From 21ce11128677bf67611b5b237b7d36aeae84c7ae Mon Sep 17 00:00:00 2001 From: miozune Date: Fri, 19 Aug 2022 11:48:24 +0900 Subject: [PATCH 1/5] Add whitelist and blacklist for generating flowers / mushrooms --- .../core/handler/BiomeDecorationHandler.java | 92 ++++++++++++------- .../common/core/handler/ConfigHandler.java | 31 +++++++ 2 files changed, 91 insertions(+), 32 deletions(-) diff --git a/src/main/java/vazkii/botania/common/core/handler/BiomeDecorationHandler.java b/src/main/java/vazkii/botania/common/core/handler/BiomeDecorationHandler.java index b5fa63798e..af6a76ac69 100644 --- a/src/main/java/vazkii/botania/common/core/handler/BiomeDecorationHandler.java +++ b/src/main/java/vazkii/botania/common/core/handler/BiomeDecorationHandler.java @@ -23,6 +23,8 @@ import cpw.mods.fml.common.eventhandler.EventPriority; import cpw.mods.fml.common.eventhandler.SubscribeEvent; +import java.util.Arrays; + public class BiomeDecorationHandler { @SubscribeEvent(priority = EventPriority.LOWEST) @@ -37,47 +39,73 @@ else if(event.world.getBiomeGenForCoords(event.chunkX, event.chunkZ) instanceof if(!flowers) return; - int dist = Math.min(8, Math.max(1, ConfigHandler.flowerPatchSize)); - for(int i = 0; i < ConfigHandler.flowerQuantity; i++) { - if(event.rand.nextInt(ConfigHandler.flowerPatchChance) == 0) { - int x = event.chunkX + event.rand.nextInt(16) + 8; - int z = event.chunkZ + event.rand.nextInt(16) + 8; - int y = event.world.getTopSolidOrLiquidBlock(x, z); - - int color = event.rand.nextInt(16); - boolean primus = event.rand.nextInt(380) == 0; - - for(int j = 0; j < ConfigHandler.flowerDensity * ConfigHandler.flowerPatchChance; j++) { - int x1 = x + event.rand.nextInt(dist * 2) - dist; - int y1 = y + event.rand.nextInt(4) - event.rand.nextInt(4); - int z1 = z + event.rand.nextInt(dist * 2) - dist; + if (ConfigHandler.flowerDimensionWhitelist.length == 0 + || Arrays.stream(ConfigHandler.flowerDimensionWhitelist).anyMatch( + d -> d == event.world.provider.dimensionId + )) { + if (Arrays.stream(ConfigHandler.flowerDimensionBlacklist).noneMatch( + d -> d == event.world.provider.dimensionId + )) { + generateFlowers(event); + } + } - if(event.world.isAirBlock(x1, y1, z1) && (!event.world.provider.hasNoSky || y1 < 127) && ModBlocks.flower.canBlockStay(event.world, x1, y1, z1)) { - if(primus) { - event.world.setBlock(x1, y1, z1, ModBlocks.specialFlower, 0, 2); - TileSpecialFlower flower = (TileSpecialFlower) event.world.getTileEntity(x1, y1, z1); - flower.setSubTile(event.rand.nextBoolean() ? LibBlockNames.SUBTILE_NIGHTSHADE_PRIME : LibBlockNames.SUBTILE_DAYBLOOM_PRIME); - SubTileDaybloom subtile = (SubTileDaybloom) flower.getSubTile(); - subtile.setPrimusPosition(); - } else { - event.world.setBlock(x1, y1, z1, ModBlocks.flower, color, 2); - if(event.rand.nextDouble() < ConfigHandler.flowerTallChance && ((BlockModFlower) ModBlocks.flower).func_149851_a(event.world, x1, y1, z1, false)) - BlockModFlower.placeDoubleFlower(event.world, x1, y1, z1, color, 0); - } - } - } + if (ConfigHandler.mushroomDimensionWhitelist.length == 0 + || Arrays.stream(ConfigHandler.mushroomDimensionWhitelist).anyMatch( + d -> d == event.world.provider.dimensionId + )) { + if (Arrays.stream(ConfigHandler.mushroomDimensionBlacklist).noneMatch( + d -> d == event.world.provider.dimensionId + )) { + generateMushrooms(event); } } + } + } - for(int i = 0; i < ConfigHandler.mushroomQuantity; i++) { + private void generateFlowers(DecorateBiomeEvent.Decorate event) { + int dist = Math.min(8, Math.max(1, ConfigHandler.flowerPatchSize)); + for(int i = 0; i < ConfigHandler.flowerQuantity; i++) { + if(event.rand.nextInt(ConfigHandler.flowerPatchChance) == 0) { int x = event.chunkX + event.rand.nextInt(16) + 8; int z = event.chunkZ + event.rand.nextInt(16) + 8; - int y = event.rand.nextInt(26) + 4; + int y = event.world.getTopSolidOrLiquidBlock(x, z); int color = event.rand.nextInt(16); - if(event.world.isAirBlock(x, y, z) && ModBlocks.mushroom.canBlockStay(event.world, x, y, z)) - event.world.setBlock(x, y, z, ModBlocks.mushroom, color, 2); + boolean primus = event.rand.nextInt(380) == 0; + + for(int j = 0; j < ConfigHandler.flowerDensity * ConfigHandler.flowerPatchChance; j++) { + int x1 = x + event.rand.nextInt(dist * 2) - dist; + int y1 = y + event.rand.nextInt(4) - event.rand.nextInt(4); + int z1 = z + event.rand.nextInt(dist * 2) - dist; + + if(event.world.isAirBlock(x1, y1, z1) && (!event.world.provider.hasNoSky || y1 < 127) && ModBlocks.flower.canBlockStay(event.world, x1, y1, z1)) { + if(primus) { + event.world.setBlock(x1, y1, z1, ModBlocks.specialFlower, 0, 2); + TileSpecialFlower flower = (TileSpecialFlower) event.world.getTileEntity(x1, y1, z1); + flower.setSubTile(event.rand.nextBoolean() ? LibBlockNames.SUBTILE_NIGHTSHADE_PRIME : LibBlockNames.SUBTILE_DAYBLOOM_PRIME); + SubTileDaybloom subtile = (SubTileDaybloom) flower.getSubTile(); + subtile.setPrimusPosition(); + } else { + event.world.setBlock(x1, y1, z1, ModBlocks.flower, color, 2); + if(event.rand.nextDouble() < ConfigHandler.flowerTallChance && ((BlockModFlower) ModBlocks.flower).func_149851_a(event.world, x1, y1, z1, false)) + BlockModFlower.placeDoubleFlower(event.world, x1, y1, z1, color, 0); + } + } + } } } } + + private void generateMushrooms(DecorateBiomeEvent.Decorate event) { + for(int i = 0; i < ConfigHandler.mushroomQuantity; i++) { + int x = event.chunkX + event.rand.nextInt(16) + 8; + int z = event.chunkZ + event.rand.nextInt(16) + 8; + int y = event.rand.nextInt(26) + 4; + + int color = event.rand.nextInt(16); + if(event.world.isAirBlock(x, y, z) && ModBlocks.mushroom.canBlockStay(event.world, x, y, z)) + event.world.setBlock(x, y, z, ModBlocks.mushroom, color, 2); + } + } } \ No newline at end of file diff --git a/src/main/java/vazkii/botania/common/core/handler/ConfigHandler.java b/src/main/java/vazkii/botania/common/core/handler/ConfigHandler.java index 03e032ac49..ef734af58f 100644 --- a/src/main/java/vazkii/botania/common/core/handler/ConfigHandler.java +++ b/src/main/java/vazkii/botania/common/core/handler/ConfigHandler.java @@ -101,6 +101,11 @@ public final class ConfigHandler { public static double flowerTallChance = 0.05; public static int mushroomQuantity = 40; + public static int[] flowerDimensionWhitelist = new int[]{}; + public static int[] flowerDimensionBlacklist = new int[]{}; + public static int[] mushroomDimensionWhitelist = new int[]{}; + public static int[] mushroomDimensionBlacklist = new int[]{}; + private static boolean verifiedPotionArray = false; private static int potionArrayLimit = 0; @@ -286,6 +291,18 @@ public static void load() { desc = "Enables all built-in recipes. This can be false for expert modpacks that wish to supply their own."; enableDefaultRecipes = loadPropBool("recipes.enabled", desc, enableDefaultRecipes); + desc = "Whitelist of which dimension generates Botania flowers. Empty means any dimension can."; + flowerDimensionWhitelist = loadPropIntArray("worldgen.flower.dimensionWhitelist", desc, flowerDimensionWhitelist); + + desc = "Blacklist of which dimension generates Botania flowers."; + flowerDimensionBlacklist = loadPropIntArray("worldgen.flower.dimensionBlacklist", desc, flowerDimensionBlacklist); + + desc = "Whitelist of which dimension generates Botania mushrooms. Empty means any dimension can."; + mushroomDimensionWhitelist = loadPropIntArray("worldgen.mushroom.dimensionWhitelist", desc, mushroomDimensionWhitelist); + + desc = "Blacklist of which dimension generates Botania mushrooms."; + mushroomDimensionBlacklist = loadPropIntArray("worldgen.mushroom.dimensionBlacklist", desc, mushroomDimensionBlacklist); + potionIDSoulCross = loadPropPotionId(LibPotionNames.SOUL_CROSS, potionIDSoulCross); potionIDFeatherfeet = loadPropPotionId(LibPotionNames.FEATHER_FEET, potionIDFeatherfeet); potionIDEmptiness = loadPropPotionId(LibPotionNames.EMPTINESS, potionIDEmptiness); @@ -334,6 +351,16 @@ public static boolean loadPropBool(String propName, String desc, boolean default return prop.getBoolean(default_); } + public static int[] loadPropIntArray(String propName, String desc, int[] intArray) { + Property prop = config.get(Configuration.CATEGORY_GENERAL, propName, intArray); + prop.comment = desc; + + if(adaptor != null) + adaptor.adaptPropertyIntArray(prop, prop.getIntList()); + + return prop.getIntList(); + } + public static int loadPropPotionId(String propName, int default_) { if(!verifiedPotionArray) verifyPotionArray(); @@ -455,6 +482,10 @@ public void adaptPropertyBool(Property prop, boolean val) { this.adaptProperty(prop, val); } + public void adaptPropertyIntArray(Property prop, int[] val) { + this.adaptProperty(prop, val); + } + public static class AdaptableValue { public final int version; From 9bf784e82c1ce44765e92dc7d6568b9ed9180361 Mon Sep 17 00:00:00 2001 From: miozune Date: Fri, 19 Aug 2022 11:52:26 +0900 Subject: [PATCH 2/5] updateBuildScript & spotlessApply --- build.gradle | 435 +- settings.gradle | 10 + .../java/vazkii/botania/api/BotaniaAPI.java | 1258 ++-- .../vazkii/botania/api/boss/IBotaniaBoss.java | 65 +- .../api/boss/IBotaniaBossWithShader.java | 35 +- .../java/vazkii/botania/api/brew/Brew.java | 206 +- .../botania/api/brew/IBrewContainer.java | 27 +- .../vazkii/botania/api/brew/IBrewItem.java | 7 +- .../botania/api/corporea/CorporeaHelper.java | 584 +- .../botania/api/corporea/CorporeaRequest.java | 27 +- .../api/corporea/CorporeaRequestEvent.java | 36 +- .../ICorporeaAutoCompleteController.java | 15 +- .../api/corporea/ICorporeaInterceptor.java | 44 +- .../api/corporea/ICorporeaRequestor.java | 13 +- .../botania/api/corporea/ICorporeaSpark.java | 114 +- .../api/corporea/IWrappedInventory.java | 65 +- .../api/internal/DummyManaNetwork.java | 48 +- .../api/internal/DummyMethodHandler.java | 399 +- .../botania/api/internal/DummyPage.java | 23 +- .../botania/api/internal/DummySubTile.java | 8 +- .../api/internal/IGuiLexiconEntry.java | 97 +- .../api/internal/IInternalMethodHandler.java | 111 +- .../botania/api/internal/IManaBurst.java | 56 +- .../botania/api/internal/IManaNetwork.java | 79 +- .../botania/api/internal/ShaderCallback.java | 7 +- .../api/internal/VanillaPacketDispatcher.java | 41 +- .../api/item/IAncientWillContainer.java | 9 +- .../vazkii/botania/api/item/IAvatarTile.java | 23 +- .../botania/api/item/IAvatarWieldable.java | 21 +- .../botania/api/item/IBaubleRender.java | 92 +- .../botania/api/item/IBlockProvider.java | 34 +- .../botania/api/item/IBurstViewerBauble.java | 8 +- .../botania/api/item/ICosmeticAttachable.java | 21 +- .../botania/api/item/ICosmeticBauble.java | 8 +- .../vazkii/botania/api/item/IDyablePool.java | 11 +- .../botania/api/item/IExoflameHeatable.java | 47 +- .../api/item/IExtendedPlayerController.java | 20 +- ...tendedWireframeCoordinateListProvider.java | 13 +- .../botania/api/item/IFlowerPlaceable.java | 15 +- .../botania/api/item/IFlowerlessBiome.java | 12 +- .../botania/api/item/IFlowerlessWorld.java | 12 +- .../botania/api/item/IGrassHornExcempt.java | 7 +- .../botania/api/item/IHornHarvestable.java | 88 +- .../botania/api/item/IManaDissolvable.java | 15 +- .../api/item/IManaProficiencyArmor.java | 34 +- .../botania/api/item/IPetalApothecary.java | 21 +- .../botania/api/item/IPhantomInkable.java | 9 +- .../botania/api/item/IPixieSpawner.java | 17 +- .../java/vazkii/botania/api/item/IRelic.java | 37 +- .../botania/api/item/ISequentialBreaker.java | 10 +- .../botania/api/item/ISortableTool.java | 55 +- .../IWireframeCoordinateListProvider.java | 22 +- .../api/item/TinyPotatoRenderEvent.java | 31 +- .../lexicon/BotaniaTutorialStartEvent.java | 16 +- .../botania/api/lexicon/IAddonEntry.java | 15 +- .../vazkii/botania/api/lexicon/ILexicon.java | 19 +- .../botania/api/lexicon/ILexiconable.java | 13 +- .../api/lexicon/IRecipeKeyProvider.java | 7 +- .../botania/api/lexicon/ITwoNamedPage.java | 9 +- .../botania/api/lexicon/KnowledgeType.java | 22 +- .../botania/api/lexicon/LexiconCategory.java | 99 +- .../botania/api/lexicon/LexiconEntry.java | 289 +- .../botania/api/lexicon/LexiconPage.java | 189 +- .../api/lexicon/LexiconRecipeMappings.java | 83 +- .../multiblock/IMultiblockRenderHook.java | 19 +- .../api/lexicon/multiblock/Multiblock.java | 306 +- .../api/lexicon/multiblock/MultiblockSet.java | 38 +- .../multiblock/component/AnyComponent.java | 21 +- .../component/ColorSwitchingComponent.java | 35 +- .../multiblock/component/FlowerComponent.java | 27 +- .../component/MultiblockComponent.java | 147 +- .../botania/api/mana/BurstProperties.java | 39 +- .../botania/api/mana/IClientManaHandler.java | 8 +- .../botania/api/mana/ICompositableLens.java | 23 +- .../api/mana/ICreativeManaProvider.java | 8 +- .../vazkii/botania/api/mana/IDirectioned.java | 9 +- .../botania/api/mana/IIdentifiable.java | 7 +- .../vazkii/botania/api/mana/IKeyLocked.java | 13 +- .../botania/api/mana/ILaputaImmobile.java | 7 +- .../java/vazkii/botania/api/mana/ILens.java | 39 +- .../vazkii/botania/api/mana/ILensControl.java | 25 +- .../vazkii/botania/api/mana/ILensEffect.java | 48 +- .../vazkii/botania/api/mana/IManaBlock.java | 13 +- .../botania/api/mana/IManaCollector.java | 35 +- .../botania/api/mana/IManaCollisionGhost.java | 7 +- .../botania/api/mana/IManaDiscountArmor.java | 19 +- .../botania/api/mana/IManaGivingItem.java | 8 +- .../vazkii/botania/api/mana/IManaItem.java | 81 +- .../vazkii/botania/api/mana/IManaPool.java | 17 +- .../botania/api/mana/IManaReceiver.java | 31 +- .../botania/api/mana/IManaSpreader.java | 16 +- .../botania/api/mana/IManaTooltipDisplay.java | 13 +- .../vazkii/botania/api/mana/IManaTrigger.java | 7 +- .../botania/api/mana/IManaUsingItem.java | 7 +- .../vazkii/botania/api/mana/IPingable.java | 20 +- .../api/mana/IPoolOverlayProvider.java | 7 +- .../botania/api/mana/IRedirectable.java | 18 +- .../botania/api/mana/IThrottledPacket.java | 7 +- .../botania/api/mana/ITinyPlanetExcempt.java | 7 +- .../botania/api/mana/ManaItemHandler.java | 459 +- .../botania/api/mana/ManaNetworkEvent.java | 82 +- .../botania/api/mana/TileSignature.java | 13 +- .../api/mana/spark/ISparkAttachable.java | 77 +- .../botania/api/mana/spark/ISparkEntity.java | 91 +- .../botania/api/mana/spark/SparkHelper.java | 25 +- .../java/vazkii/botania/api/package-info.java | 2 +- .../api/recipe/ElvenPortalUpdateEvent.java | 33 +- .../vazkii/botania/api/recipe/IElvenItem.java | 3 +- .../botania/api/recipe/IFlowerComponent.java | 9 +- .../vazkii/botania/api/recipe/RecipeBrew.java | 174 +- .../botania/api/recipe/RecipeElvenTrade.java | 156 +- .../api/recipe/RecipeManaInfusion.java | 131 +- .../botania/api/recipe/RecipeMiniFlower.java | 30 +- .../botania/api/recipe/RecipePetals.java | 145 +- .../botania/api/recipe/RecipePureDaisy.java | 146 +- .../botania/api/recipe/RecipeRuneAltar.java | 21 +- .../botania/api/subtile/ISpecialFlower.java | 8 +- .../api/subtile/ISubTileContainer.java | 23 +- .../subtile/ISubTileSlowableContainer.java | 13 +- .../botania/api/subtile/RadiusDescriptor.java | 142 +- .../botania/api/subtile/SubTileEntity.java | 418 +- .../api/subtile/SubTileFunctional.java | 409 +- .../api/subtile/SubTileGenerating.java | 606 +- .../api/subtile/signature/BasicSignature.java | 86 +- .../api/subtile/signature/PassiveFlower.java | 8 +- .../subtile/signature/SubTileSignature.java | 66 +- .../botania/api/wand/ICoordBoundItem.java | 9 +- .../vazkii/botania/api/wand/ITileBound.java | 17 +- .../botania/api/wand/IWandBindable.java | 23 +- .../vazkii/botania/api/wand/IWandHUD.java | 7 +- .../vazkii/botania/api/wand/IWandable.java | 15 +- .../api/wand/IWireframeAABBProvider.java | 7 +- .../botania/api/wiki/IWikiProvider.java | 29 +- .../botania/api/wiki/SimpleWikiProvider.java | 133 +- .../vazkii/botania/api/wiki/WikiHooks.java | 38 +- .../botania/client/challenge/Challenge.java | 35 +- .../client/challenge/EnumChallengeLevel.java | 28 +- .../client/challenge/ModChallenges.java | 77 +- .../core/handler/BaubleRenderHandler.java | 224 +- .../client/core/handler/BossBarHandler.java | 168 +- .../core/handler/BotaniaPlayerController.java | 41 +- .../core/handler/BoundTileRenderer.java | 301 +- .../core/handler/ClientTickHandler.java | 153 +- .../handler/ContributorFancinessHandler.java | 324 +- .../handler/CorporeaAutoCompleteHandler.java | 304 +- .../client/core/handler/DebugHandler.java | 72 +- .../client/core/handler/HUDHandler.java | 875 +-- .../handler/ItemsRemainingRenderHandler.java | 163 +- .../client/core/handler/LightningHandler.java | 998 +-- .../core/handler/MultiblockBlockAccess.java | 175 +- .../core/handler/MultiblockRenderHandler.java | 305 +- .../handler/PersistentVariableHelper.java | 267 +- .../core/handler/RedStringRenderer.java | 175 +- .../handler/SubTileRadiusRenderHandler.java | 266 +- .../TooltipAdditionDisplayHandler.java | 388 +- .../client/core/handler/TooltipHandler.java | 36 +- .../client/core/helper/FontHelper.java | 45 +- .../client/core/helper/IconHelper.java | 67 +- .../client/core/helper/RenderHelper.java | 446 +- .../client/core/helper/ShaderHelper.java | 329 +- .../client/core/proxy/ClientProxy.java | 735 ++- .../botania/client/core/proxy/GuiFactory.java | 46 +- .../vazkii/botania/client/fx/FXSparkle.java | 457 +- .../java/vazkii/botania/client/fx/FXWisp.java | 291 +- .../client/fx/ParticleRenderDispatcher.java | 68 +- .../client/gui/GuiAchievementsHacky.java | 25 +- .../botania/client/gui/GuiBotaniaConfig.java | 19 +- .../vazkii/botania/client/gui/SlotLocked.java | 27 +- .../client/gui/bag/ContainerFlowerBag.java | 149 +- .../botania/client/gui/bag/GuiFlowerBag.java | 80 +- .../client/gui/bag/InventoryFlowerBag.java | 274 +- .../botania/client/gui/bag/SlotFlower.java | 35 +- .../client/gui/box/ContainerBaubleBox.java | 193 +- .../botania/client/gui/box/GuiBaubleBox.java | 67 +- .../client/gui/box/InventoryBaubleBox.java | 274 +- .../botania/client/gui/box/SlotAnyBauble.java | 33 +- .../gui/crafting/ContainerCraftingHalo.java | 81 +- .../client/gui/crafting/GuiCraftingHalo.java | 47 +- .../gui/crafting/InventoryCraftingHalo.java | 11 +- .../client/gui/lexicon/GuiLexicon.java | 1191 ++-- .../gui/lexicon/GuiLexiconChallenge.java | 313 +- .../gui/lexicon/GuiLexiconChallengesList.java | 250 +- .../client/gui/lexicon/GuiLexiconEntry.java | 754 ++- .../client/gui/lexicon/GuiLexiconHistory.java | 83 +- .../client/gui/lexicon/GuiLexiconIndex.java | 882 ++- .../botania/client/gui/lexicon/IParented.java | 3 +- .../lexicon/button/GuiButtonAchievement.java | 42 +- .../gui/lexicon/button/GuiButtonBack.java | 56 +- .../button/GuiButtonBackWithShift.java | 22 +- .../gui/lexicon/button/GuiButtonBookmark.java | 54 +- .../gui/lexicon/button/GuiButtonCategory.java | 207 +- .../button/GuiButtonChallengeIcon.java | 75 +- .../button/GuiButtonChallengeInfo.java | 40 +- .../lexicon/button/GuiButtonChallenges.java | 42 +- .../gui/lexicon/button/GuiButtonDoot.java | 60 +- .../gui/lexicon/button/GuiButtonHistory.java | 40 +- .../lexicon/button/GuiButtonInvisible.java | 189 +- .../gui/lexicon/button/GuiButtonLexicon.java | 20 +- .../gui/lexicon/button/GuiButtonNotes.java | 66 +- .../gui/lexicon/button/GuiButtonOptions.java | 43 +- .../gui/lexicon/button/GuiButtonPage.java | 55 +- .../gui/lexicon/button/GuiButtonShare.java | 43 +- .../button/GuiButtonUpdateWarning.java | 56 +- .../lexicon/button/GuiButtonViewOnline.java | 45 +- .../integration/nei/NEIBotaniaConfig.java | 72 +- .../client/integration/nei/NEIGuiHooks.java | 15 +- .../integration/nei/NEIInputHandler.java | 161 +- .../nei/recipe/RecipeHandlerBrewery.java | 226 +- .../nei/recipe/RecipeHandlerElvenTrade.java | 288 +- .../recipe/RecipeHandlerFloatingFlowers.java | 126 +- .../recipe/RecipeHandlerLexicaBotania.java | 260 +- .../nei/recipe/RecipeHandlerManaPool.java | 229 +- .../recipe/RecipeHandlerPetalApothecary.java | 241 +- .../nei/recipe/RecipeHandlerPureDaisy.java | 204 +- .../nei/recipe/RecipeHandlerRunicAltar.java | 86 +- .../botania/client/lib/LibRenderIDs.java | 45 +- .../botania/client/lib/LibResources.java | 293 +- .../botania/client/model/IPylonModel.java | 11 +- .../botania/client/model/ModelAltar.java | 138 +- .../botania/client/model/ModelAvatar.java | 99 +- .../botania/client/model/ModelBellows.java | 136 +- .../client/model/ModelBlackHoleCube.java | 165 +- .../botania/client/model/ModelBrewery.java | 164 +- .../botania/client/model/ModelCocoon.java | 27 +- .../client/model/ModelCrystalCube.java | 64 +- .../botania/client/model/ModelHourglass.java | 155 +- .../client/model/ModelIncensePlate.java | 47 +- .../botania/client/model/ModelMiniIsland.java | 127 +- .../botania/client/model/ModelPixie.java | 95 +- .../botania/client/model/ModelPool.java | 80 +- .../botania/client/model/ModelPump.java | 85 +- .../botania/client/model/ModelPylon.java | 37 +- .../botania/client/model/ModelPylonOld.java | 273 +- .../client/model/ModelSkullOverride.java | 61 +- .../client/model/ModelSpawnerClaw.java | 127 +- .../client/model/ModelSpinningCubes.java | 138 +- .../botania/client/model/ModelSpreader.java | 146 +- .../client/model/ModelTeruTeruBozu.java | 75 +- .../botania/client/model/ModelTinyPotato.java | 29 +- .../model/armor/ModelArmorElementium.java | 469 +- .../model/armor/ModelArmorManasteel.java | 349 +- .../model/armor/ModelArmorManaweave.java | 329 +- .../model/armor/ModelArmorTerrasteel.java | 507 +- .../client/render/block/InterpolatedIcon.java | 98 +- .../client/render/block/RenderAltar.java | 57 +- .../client/render/block/RenderAvatar.java | 54 +- .../client/render/block/RenderBellows.java | 56 +- .../client/render/block/RenderBrewery.java | 60 +- .../client/render/block/RenderCocoon.java | 54 +- .../block/RenderCorporeaCrystalCube.java | 58 +- .../render/block/RenderCorporeaIndex.java | 60 +- .../render/block/RenderDoubleFlower.java | 99 +- .../render/block/RenderFloatingFlower.java | 40 +- .../client/render/block/RenderHourglass.java | 58 +- .../render/block/RenderIncensePlate.java | 60 +- .../client/render/block/RenderPool.java | 58 +- .../client/render/block/RenderPump.java | 54 +- .../client/render/block/RenderPylon.java | 58 +- .../render/block/RenderSpawnerClaw.java | 54 +- .../render/block/RenderSpecialFlower.java | 242 +- .../client/render/block/RenderSpreader.java | 66 +- .../render/block/RenderTeruTeruBozu.java | 54 +- .../client/render/block/RenderTinyPotato.java | 54 +- .../render/entity/RenderBabylonWeapon.java | 156 +- .../render/entity/RenderCorporeaSpark.java | 161 +- .../render/entity/RenderDoppleganger.java | 129 +- .../client/render/entity/RenderManaStorm.java | 42 +- .../render/entity/RenderPinkWither.java | 39 +- .../client/render/entity/RenderPixie.java | 113 +- .../render/entity/RenderPoolMinecart.java | 18 +- .../client/render/entity/RenderSpark.java | 17 +- .../client/render/entity/RenderSparkBase.java | 180 +- .../render/entity/RenderThornChakram.java | 94 +- .../botania/client/render/item/RenderBow.java | 127 +- .../render/item/RenderFloatingFlowerItem.java | 61 +- .../client/render/item/RenderLens.java | 194 +- .../client/render/item/RenderLexicon.java | 184 +- .../render/item/RenderTransparentItem.java | 104 +- .../render/tile/RenderTileAlfPortal.java | 96 +- .../client/render/tile/RenderTileAltar.java | 334 +- .../client/render/tile/RenderTileAvatar.java | 157 +- .../client/render/tile/RenderTileBellows.java | 51 +- .../client/render/tile/RenderTileBrewery.java | 149 +- .../client/render/tile/RenderTileCocoon.java | 66 +- .../tile/RenderTileCorporeaCrystalCube.java | 172 +- .../render/tile/RenderTileCorporeaIndex.java | 89 +- .../render/tile/RenderTileEnchanter.java | 184 +- .../render/tile/RenderTileFloatingFlower.java | 86 +- .../render/tile/RenderTileHourglass.java | 82 +- .../render/tile/RenderTileIncensePlate.java | 107 +- .../render/tile/RenderTileLightRelay.java | 120 +- .../client/render/tile/RenderTilePool.java | 258 +- .../client/render/tile/RenderTilePrism.java | 52 +- .../client/render/tile/RenderTilePump.java | 51 +- .../client/render/tile/RenderTilePylon.java | 210 +- .../render/tile/RenderTileRedString.java | 15 +- .../render/tile/RenderTileRuneAltar.java | 206 +- .../render/tile/RenderTileSkullOverride.java | 138 +- .../render/tile/RenderTileSparkChanger.java | 79 +- .../render/tile/RenderTileSpawnerClaw.java | 39 +- .../render/tile/RenderTileSpreader.java | 196 +- .../render/tile/RenderTileStarfield.java | 186 +- .../render/tile/RenderTileTerraPlate.java | 91 +- .../render/tile/RenderTileTeruTeruBozu.java | 76 +- .../render/tile/RenderTileTinyPotato.java | 667 +- .../render/world/SkyblockRenderEvents.java | 26 +- .../render/world/SkyblockSkyRenderer.java | 685 +- .../java/vazkii/botania/common/Botania.java | 158 +- .../botania/common/CustomBotaniaAPI.java | 6 +- .../common/achievement/AchievementMod.java | 33 +- .../achievement/AchievementTriggerer.java | 43 +- .../common/achievement/ICraftAchievement.java | 7 +- .../achievement/IPickupAchievement.java | 7 +- .../common/achievement/ModAchievements.java | 352 +- .../botania/common/block/BlockAlfPortal.java | 78 +- .../botania/common/block/BlockAltGrass.java | 259 +- .../botania/common/block/BlockAltar.java | 503 +- .../botania/common/block/BlockAvatar.java | 289 +- .../botania/common/block/BlockBifrost.java | 157 +- .../common/block/BlockBifrostPerm.java | 103 +- .../common/block/BlockCacophonium.java | 142 +- .../botania/common/block/BlockCamo.java | 248 +- .../botania/common/block/BlockCell.java | 46 +- .../botania/common/block/BlockCocoon.java | 122 +- .../botania/common/block/BlockDreamwood.java | 24 +- .../common/block/BlockEnchantedSoil.java | 111 +- .../botania/common/block/BlockEnderEye.java | 71 +- .../botania/common/block/BlockFakeAir.java | 170 +- .../botania/common/block/BlockFelPumpkin.java | 149 +- .../block/BlockFloatingSpecialFlower.java | 273 +- .../botania/common/block/BlockForestEye.java | 92 +- .../botania/common/block/BlockGaiaHead.java | 139 +- .../botania/common/block/BlockGhostRail.java | 108 +- .../botania/common/block/BlockHourglass.java | 334 +- .../common/block/BlockIncensePlate.java | 241 +- .../common/block/BlockLightLauncher.java | 117 +- .../botania/common/block/BlockLightRelay.java | 237 +- .../botania/common/block/BlockLivingrock.java | 100 +- .../botania/common/block/BlockLivingwood.java | 152 +- .../botania/common/block/BlockManaBomb.java | 53 +- .../vazkii/botania/common/block/BlockMod.java | 80 +- .../common/block/BlockModContainer.java | 85 +- .../common/block/BlockModDoubleFlower.java | 443 +- .../botania/common/block/BlockModFlower.java | 242 +- .../botania/common/block/BlockOpenCrate.java | 350 +- .../common/block/BlockPistonRelay.java | 502 +- .../botania/common/block/BlockPlatform.java | 167 +- .../botania/common/block/BlockPylon.java | 162 +- .../botania/common/block/BlockRoot.java | 59 +- .../botania/common/block/BlockSolidVines.java | 74 +- .../common/block/BlockSparkChanger.java | 294 +- .../common/block/BlockSpecialFlower.java | 458 +- .../botania/common/block/BlockStorage.java | 104 +- .../common/block/BlockTeruTeruBozu.java | 203 +- .../botania/common/block/BlockTinyPlanet.java | 63 +- .../botania/common/block/ModBlocks.java | 693 +- .../botania/common/block/ModFluffBlocks.java | 681 +- .../botania/common/block/ModMultiblocks.java | 25 +- .../block/corporea/BlockCorporeaBase.java | 115 +- .../corporea/BlockCorporeaCrystalCube.java | 150 +- .../block/corporea/BlockCorporeaFunnel.java | 73 +- .../block/corporea/BlockCorporeaIndex.java | 71 +- .../corporea/BlockCorporeaInterceptor.java | 85 +- .../block/corporea/BlockCorporeaRetainer.java | 79 +- .../common/block/decor/Block18Stone.java | 94 +- .../common/block/decor/BlockBlaze.java | 46 +- .../common/block/decor/BlockBuriedPetals.java | 92 +- .../common/block/decor/BlockCustomBrick.java | 100 +- .../common/block/decor/BlockDirtPath.java | 121 +- .../common/block/decor/BlockElfGlass.java | 65 +- .../block/decor/BlockEndStoneBrick.java | 97 +- .../block/decor/BlockFloatingFlower.java | 261 +- .../common/block/decor/BlockManaBeacon.java | 157 +- .../common/block/decor/BlockManaFlame.java | 180 +- .../common/block/decor/BlockManaGlass.java | 69 +- .../common/block/decor/BlockModMushroom.java | 233 +- .../common/block/decor/BlockPavement.java | 96 +- .../common/block/decor/BlockPetalBlock.java | 83 +- .../common/block/decor/BlockPrismarine.java | 126 +- .../common/block/decor/BlockReeds.java | 74 +- .../common/block/decor/BlockSeaLamp.java | 43 +- .../common/block/decor/BlockShimmerrock.java | 62 +- .../block/decor/BlockShimmerwoodPlanks.java | 62 +- .../common/block/decor/BlockShinyFlower.java | 103 +- .../common/block/decor/BlockStarfield.java | 74 +- .../common/block/decor/BlockThatch.java | 25 +- .../common/block/decor/BlockTinyPotato.java | 213 +- .../common/block/decor/BlockUnstable.java | 146 +- .../common/block/decor/IFloatingFlower.java | 111 +- .../decor/biomestone/BlockBiomeStone.java | 102 +- .../decor/biomestone/BlockBiomeStoneA.java | 19 +- .../decor/biomestone/BlockBiomeStoneB.java | 11 +- .../block/decor/panes/BlockAlfglassPane.java | 11 +- .../block/decor/panes/BlockBifrostPane.java | 46 +- .../block/decor/panes/BlockManaglassPane.java | 11 +- .../block/decor/panes/BlockModPane.java | 112 +- .../decor/quartz/BlockSpecialQuartz.java | 251 +- .../decor/quartz/BlockSpecialQuartzSlab.java | 156 +- .../quartz/BlockSpecialQuartzStairs.java | 23 +- .../block/decor/slabs/Block18StoneSlab.java | 51 +- .../decor/slabs/BlockBiomeStoneSlab.java | 51 +- .../block/decor/slabs/BlockDirtPathSlab.java | 37 +- .../block/decor/slabs/BlockEndStoneSlab.java | 41 +- .../decor/slabs/BlockEnderBrickSlab.java | 41 +- .../block/decor/slabs/BlockLivingSlab.java | 34 +- .../block/decor/slabs/BlockModSlab.java | 118 +- .../block/decor/slabs/BlockPavementSlab.java | 52 +- .../block/decor/slabs/BlockReedSlab.java | 46 +- .../block/decor/slabs/BlockThatchSlab.java | 46 +- .../slabs/bricks/BlockCustomBrickSlab.java | 57 +- .../slabs/bricks/BlockSnowBrickSlab.java | 29 +- .../slabs/bricks/BlockSoulBrickSlab.java | 27 +- .../decor/slabs/bricks/BlockTileSlab.java | 27 +- .../slabs/living/BlockDreamwoodPlankSlab.java | 25 +- .../slabs/living/BlockDreamwoodSlab.java | 25 +- .../living/BlockLivingrockBrickSlab.java | 29 +- .../slabs/living/BlockLivingrockSlab.java | 29 +- .../living/BlockLivingwoodPlankSlab.java | 25 +- .../slabs/living/BlockLivingwoodSlab.java | 25 +- .../slabs/living/BlockShimmerrockSlab.java | 33 +- .../living/BlockShimmerwoodPlankSlab.java | 32 +- .../prismarine/BlockDarkPrismarineSlab.java | 23 +- .../prismarine/BlockPrismarineBrickSlab.java | 23 +- .../slabs/prismarine/BlockPrismarineSlab.java | 51 +- .../decor/stairs/Block18StoneStairs.java | 19 +- .../decor/stairs/BlockBiomeStoneStairs.java | 19 +- .../decor/stairs/BlockEndStoneStairs.java | 19 +- .../decor/stairs/BlockEnderBrickStairs.java | 19 +- .../block/decor/stairs/BlockLivingStairs.java | 7 +- .../block/decor/stairs/BlockModStairs.java | 33 +- .../decor/stairs/BlockPavementStairs.java | 19 +- .../block/decor/stairs/BlockReedStairs.java | 20 +- .../block/decor/stairs/BlockThatchStairs.java | 20 +- .../stairs/bricks/BlockCustomBrickStairs.java | 21 +- .../stairs/bricks/BlockSnowBrickStairs.java | 11 +- .../stairs/bricks/BlockSoulBrickStairs.java | 11 +- .../decor/stairs/bricks/BlockTileStairs.java | 11 +- .../living/BlockDreamwoodPlankStairs.java | 7 +- .../stairs/living/BlockDreamwoodStairs.java | 7 +- .../living/BlockLivingrockBrickStairs.java | 7 +- .../stairs/living/BlockLivingrockStairs.java | 7 +- .../living/BlockLivingwoodPlankStairs.java | 7 +- .../stairs/living/BlockLivingwoodStairs.java | 7 +- .../stairs/living/BlockShimmerrockStairs.java | 11 +- .../living/BlockShimmerwoodPlankStairs.java | 11 +- .../prismarine/BlockDarkPrismarineStairs.java | 8 +- .../BlockPrismarineBrickStairs.java | 8 +- .../prismarine/BlockPrismarineStairs.java | 21 +- .../block/decor/walls/Block18StoneWall.java | 23 +- .../decor/walls/BlockBiomeStoneWall.java | 23 +- .../block/decor/walls/BlockModWall.java | 80 +- .../decor/walls/BlockPrismarineWall.java | 25 +- .../block/decor/walls/BlockReedWall.java | 15 +- .../block/decor/walls/BlockVariantWall.java | 64 +- .../walls/living/BlockDreamwoodWall.java | 15 +- .../walls/living/BlockLivingrockWall.java | 17 +- .../walls/living/BlockLivingwoodWall.java | 15 +- .../dispenser/BehaviourPoolMinecart.java | 75 +- .../block/dispenser/BehaviourSeeds.java | 41 +- .../common/block/dispenser/BehaviourWand.java | 43 +- .../block/mana/BlockAlchemyCatalyst.java | 62 +- .../common/block/mana/BlockBellows.java | 107 +- .../common/block/mana/BlockBrewery.java | 275 +- .../block/mana/BlockConjurationCatalyst.java | 18 +- .../common/block/mana/BlockDistributor.java | 65 +- .../common/block/mana/BlockEnchanter.java | 253 +- .../common/block/mana/BlockForestDrum.java | 292 +- .../common/block/mana/BlockManaDetector.java | 90 +- .../common/block/mana/BlockManaVoid.java | 65 +- .../botania/common/block/mana/BlockPool.java | 320 +- .../botania/common/block/mana/BlockPrism.java | 318 +- .../botania/common/block/mana/BlockPump.java | 163 +- .../common/block/mana/BlockRFGenerator.java | 51 +- .../common/block/mana/BlockRuneAltar.java | 273 +- .../common/block/mana/BlockSpawnerClaw.java | 80 +- .../common/block/mana/BlockSpreader.java | 434 +- .../common/block/mana/BlockTerraPlate.java | 183 +- .../common/block/mana/BlockTurntable.java | 72 +- .../common/block/string/BlockRedString.java | 87 +- .../string/BlockRedStringComparator.java | 35 +- .../block/string/BlockRedStringContainer.java | 19 +- .../block/string/BlockRedStringDispenser.java | 41 +- .../string/BlockRedStringFertilizer.java | 52 +- .../string/BlockRedStringInterceptor.java | 78 +- .../block/string/BlockRedStringRelay.java | 19 +- .../common/block/subtile/SubTileDecor.java | 19 +- .../common/block/subtile/SubTileManastar.java | 66 +- .../block/subtile/SubTilePureDaisy.java | 200 +- .../functional/SubTileAgricarnation.java | 174 +- .../subtile/functional/SubTileBellethorn.java | 177 +- .../subtile/functional/SubTileBubbell.java | 186 +- .../subtile/functional/SubTileClayconia.java | 182 +- .../subtile/functional/SubTileDaffomill.java | 254 +- .../subtile/functional/SubTileDreadthorn.java | 56 +- .../subtile/functional/SubTileExoflame.java | 204 +- .../functional/SubTileFallenKanade.java | 78 +- .../functional/SubTileHeiseiDream.java | 180 +- .../subtile/functional/SubTileHopperhock.java | 487 +- .../subtile/functional/SubTileHyacidus.java | 91 +- .../functional/SubTileJadedAmaranthus.java | 130 +- .../subtile/functional/SubTileJiyuulia.java | 53 +- .../subtile/functional/SubTileLoonuim.java | 94 +- .../functional/SubTileMarimorphosis.java | 247 +- .../subtile/functional/SubTileMedumone.java | 85 +- .../subtile/functional/SubTileOrechid.java | 288 +- .../functional/SubTileOrechidIgnem.java | 68 +- .../functional/SubTilePollidisiac.java | 122 +- .../functional/SubTileRannuncarpus.java | 435 +- .../subtile/functional/SubTileSolegnolia.java | 143 +- .../functional/SubTileSpectranthemum.java | 283 +- .../functional/SubTileTangleberrie.java | 156 +- .../subtile/functional/SubTileTigerseye.java | 169 +- .../subtile/functional/SubTileVinculotus.java | 179 +- .../subtile/generating/SubTileArcaneRose.java | 75 +- .../generating/SubTileDandelifeon.java | 357 +- .../subtile/generating/SubTileDaybloom.java | 225 +- .../subtile/generating/SubTileEndoflame.java | 248 +- .../generating/SubTileEntropinnyum.java | 129 +- .../generating/SubTileGourmaryllis.java | 192 +- .../generating/SubTileHydroangeas.java | 345 +- .../subtile/generating/SubTileKekimurus.java | 100 +- .../subtile/generating/SubTileMunchdew.java | 257 +- .../subtile/generating/SubTileNarslimmus.java | 171 +- .../subtile/generating/SubTileNightshade.java | 70 +- .../generating/SubTilePassiveGenerating.java | 13 +- .../subtile/generating/SubTileRafflowsia.java | 213 +- .../subtile/generating/SubTileSpectrolus.java | 220 +- .../subtile/generating/SubTileThermalily.java | 104 +- .../common/block/tile/TileAlfPortal.java | 662 +- .../botania/common/block/tile/TileAltar.java | 736 ++- .../botania/common/block/tile/TileAvatar.java | 231 +- .../common/block/tile/TileBifrost.java | 64 +- .../common/block/tile/TileBrewery.java | 496 +- .../common/block/tile/TileCacophonium.java | 42 +- .../botania/common/block/tile/TileCamo.java | 65 +- .../botania/common/block/tile/TileCell.java | 133 +- .../botania/common/block/tile/TileCocoon.java | 155 +- .../common/block/tile/TileCraftCrate.java | 356 +- .../common/block/tile/TileEnchanter.java | 803 +-- .../common/block/tile/TileEnderEye.java | 75 +- .../common/block/tile/TileFakeAir.java | 77 +- .../common/block/tile/TileFloatingFlower.java | 83 +- .../block/tile/TileFloatingSpecialFlower.java | 91 +- .../common/block/tile/TileForestEye.java | 34 +- .../common/block/tile/TileGaiaHead.java | 8 +- .../common/block/tile/TileHourglass.java | 285 +- .../common/block/tile/TileIncensePlate.java | 274 +- .../common/block/tile/TileLightRelay.java | 573 +- .../common/block/tile/TileManaBeacon.java | 60 +- .../common/block/tile/TileManaFlame.java | 93 +- .../botania/common/block/tile/TileMod.java | 59 +- .../common/block/tile/TileOpenCrate.java | 93 +- .../common/block/tile/TilePlatform.java | 83 +- .../botania/common/block/tile/TilePylon.java | 202 +- .../common/block/tile/TileRuneAltar.java | 776 +-- .../block/tile/TileSimpleInventory.java | 192 +- .../common/block/tile/TileSparkChanger.java | 111 +- .../common/block/tile/TileSpawnerClaw.java | 282 +- .../common/block/tile/TileSpecialFlower.java | 394 +- .../common/block/tile/TileSpiritShrine.java | 123 +- .../common/block/tile/TileStarfield.java | 71 +- .../common/block/tile/TileTerraPlate.java | 438 +- .../common/block/tile/TileTeruTeruBozu.java | 25 +- .../common/block/tile/TileTinyPlanet.java | 21 +- .../common/block/tile/TileTinyPotato.java | 79 +- .../block/tile/corporea/TileCorporeaBase.java | 11 +- .../corporea/TileCorporeaCrystalCube.java | 261 +- .../tile/corporea/TileCorporeaFunnel.java | 165 +- .../tile/corporea/TileCorporeaIndex.java | 641 +- .../corporea/TileCorporeaInterceptor.java | 179 +- .../tile/corporea/TileCorporeaRetainer.java | 206 +- .../common/block/tile/mana/TileBellows.java | 228 +- .../block/tile/mana/TileDistributor.java | 78 +- .../block/tile/mana/TileManaDetector.java | 52 +- .../common/block/tile/mana/TileManaVoid.java | 66 +- .../common/block/tile/mana/TilePool.java | 784 +-- .../common/block/tile/mana/TilePrism.java | 107 +- .../common/block/tile/mana/TilePump.java | 165 +- .../block/tile/mana/TileRFGenerator.java | 250 +- .../common/block/tile/mana/TileSpreader.java | 1417 ++-- .../common/block/tile/mana/TileTurntable.java | 133 +- .../block/tile/string/TileRedString.java | 141 +- .../tile/string/TileRedStringComparator.java | 68 +- .../tile/string/TileRedStringContainer.java | 254 +- .../tile/string/TileRedStringDispenser.java | 36 +- .../tile/string/TileRedStringFertilizer.java | 58 +- .../tile/string/TileRedStringInterceptor.java | 93 +- .../block/tile/string/TileRedStringRelay.java | 21 +- .../vazkii/botania/common/brew/BrewMod.java | 21 +- .../botania/common/brew/BrewModPotion.java | 11 +- .../vazkii/botania/common/brew/ModBrews.java | 132 +- .../botania/common/brew/ModPotions.java | 77 +- .../common/brew/potion/PotionAllure.java | 32 +- .../common/brew/potion/PotionBloodthirst.java | 50 +- .../common/brew/potion/PotionClear.java | 27 +- .../common/brew/potion/PotionEmptiness.java | 50 +- .../common/brew/potion/PotionFeatherfeet.java | 26 +- .../botania/common/brew/potion/PotionMod.java | 45 +- .../common/brew/potion/PotionSoulCross.java | 32 +- .../common/core/BotaniaCreativeTab.java | 794 ++- .../common/core/command/CommandOpen.java | 70 +- .../common/core/command/CommandShare.java | 61 +- .../core/command/CommandSkyblockSpread.java | 73 +- .../common/core/handler/AliasHandler.java | 86 +- .../core/handler/BiomeDecorationHandler.java | 163 +- .../common/core/handler/ChestGenHandler.java | 71 +- .../core/handler/CommonTickHandler.java | 55 +- .../common/core/handler/ConfigHandler.java | 876 +-- .../common/core/handler/IMCHandler.java | 30 +- .../core/handler/InternalMethodHandler.java | 454 +- .../core/handler/ManaNetworkHandler.java | 234 +- .../common/core/handler/PixieHandler.java | 81 +- .../common/core/handler/SheddingHandler.java | 246 +- .../core/handler/SpawnerChangingHandler.java | 44 +- .../handler/TerrasteelCraftingHandler.java | 335 +- .../common/core/helper/ExperienceHelper.java | 71 +- .../common/core/helper/InventoryHelper.java | 665 +- .../common/core/helper/ItemNBTHelper.java | 431 +- .../common/core/helper/MathHelper.java | 44 +- .../common/core/helper/ObfuscationHelper.java | 12 +- .../botania/common/core/helper/Quat.java | 212 +- .../botania/common/core/helper/Vector3.java | 555 +- .../common/core/proxy/CommonProxy.java | 525 +- .../common/crafting/ModBrewRecipes.java | 202 +- .../common/crafting/ModCraftingRecipes.java | 5839 ++++++++++------- .../common/crafting/ModElvenTradeRecipes.java | 72 +- .../crafting/ModManaAlchemyRecipes.java | 348 +- .../crafting/ModManaConjurationRecipes.java | 73 +- .../crafting/ModManaInfusionRecipes.java | 157 +- .../common/crafting/ModPetalRecipes.java | 527 +- .../common/crafting/ModPureDaisyRecipes.java | 25 +- .../common/crafting/ModRuneRecipes.java | 223 +- .../crafting/recipe/AesirRingRecipe.java | 92 +- .../crafting/recipe/AncientWillRecipe.java | 91 +- .../BlackHoleTalismanExtractRecipe.java | 77 +- .../crafting/recipe/CompositeLensRecipe.java | 105 +- .../crafting/recipe/CosmeticAttachRecipe.java | 93 +- .../crafting/recipe/CosmeticRemoveRecipe.java | 77 +- .../common/crafting/recipe/HeadRecipe.java | 70 +- .../crafting/recipe/HelmRevealingRecipe.java | 156 +- .../common/crafting/recipe/KeepIvyRecipe.java | 79 +- .../crafting/recipe/LensDyeingRecipe.java | 163 +- .../crafting/recipe/ManaGunClipRecipe.java | 88 +- .../crafting/recipe/ManaGunLensRecipe.java | 113 +- .../recipe/ManaGunRemoveLensRecipe.java | 90 +- .../crafting/recipe/PhantomInkRecipe.java | 81 +- .../crafting/recipe/RegenIvyRecipe.java | 102 +- .../recipe/SpecialFloatingFlowerRecipe.java | 77 +- .../crafting/recipe/SpellClothRecipe.java | 86 +- .../recipe/TerraPickTippingRecipe.java | 79 +- .../common/entity/EntityBabylonWeapon.java | 406 +- .../common/entity/EntityCorporeaSpark.java | 562 +- .../common/entity/EntityDoppleganger.java | 1845 +++--- .../common/entity/EntityEnderAirBottle.java | 93 +- .../common/entity/EntityFallingStar.java | 107 +- .../common/entity/EntityFlameRing.java | 182 +- .../common/entity/EntityFlyingCreature.java | 127 +- .../common/entity/EntityMagicLandmine.java | 144 +- .../common/entity/EntityMagicMissile.java | 330 +- .../common/entity/EntityManaBurst.java | 1753 ++--- .../common/entity/EntityManaStorm.java | 154 +- .../common/entity/EntityPinkWither.java | 148 +- .../botania/common/entity/EntityPixie.java | 235 +- .../common/entity/EntityPoolMinecart.java | 253 +- .../common/entity/EntitySignalFlare.java | 115 +- .../botania/common/entity/EntitySpark.java | 679 +- .../common/entity/EntityThornChakram.java | 278 +- .../common/entity/EntityThrowableCopy.java | 668 +- .../common/entity/EntityThrownItem.java | 230 +- .../botania/common/entity/EntityVineBall.java | 85 +- .../botania/common/entity/ModEntities.java | 69 +- .../buildcraft/StatementAPIPlugin.java | 99 +- .../integration/buildcraft/StatementBase.java | 44 +- .../buildcraft/TriggerManaDetector.java | 74 +- .../buildcraft/TriggerManaLevel.java | 92 +- .../buildcraft/TriggerRuneAltarCanCraft.java | 42 +- .../coloredlights/ColoredLightHelper.java | 71 +- .../coloredlights/ILightHelper.java | 9 +- .../coloredlights/LightHelper.java | 16 +- .../coloredlights/LightHelperColored.java | 21 +- .../coloredlights/LightHelperVanilla.java | 21 +- .../corporea/WrappedDeepStorage.java | 218 +- .../corporea/WrappedIInventory.java | 140 +- .../corporea/WrappedInventoryBase.java | 64 +- .../corporea/WrappedStorageDrawers.java | 174 +- .../integration/etfuturum/ModBanners.java | 62 +- .../multipart/MultipartHandler.java | 95 +- .../botania/common/item/Item16Colors.java | 62 +- .../botania/common/item/ItemAncientWill.java | 80 +- .../common/item/ItemAutocraftingHalo.java | 40 +- .../botania/common/item/ItemBaubleBox.java | 83 +- .../common/item/ItemBlackHoleTalisman.java | 593 +- .../botania/common/item/ItemBlackLotus.java | 120 +- .../botania/common/item/ItemBottledMana.java | 429 +- .../botania/common/item/ItemCacophonium.java | 257 +- .../vazkii/botania/common/item/ItemClip.java | 13 +- .../common/item/ItemCorporeaSpark.java | 100 +- .../botania/common/item/ItemCraftPattern.java | 75 +- .../botania/common/item/ItemCraftingHalo.java | 1107 ++-- .../botania/common/item/ItemEnderHand.java | 114 +- .../botania/common/item/ItemFertilizer.java | 105 +- .../botania/common/item/ItemFlowerBag.java | 257 +- .../botania/common/item/ItemGaiaHead.java | 152 +- .../botania/common/item/ItemGrassHorn.java | 263 +- .../botania/common/item/ItemGrassSeeds.java | 702 +- .../botania/common/item/ItemKeepIvy.java | 151 +- .../botania/common/item/ItemLaputaShard.java | 488 +- .../botania/common/item/ItemLexicon.java | 365 +- .../botania/common/item/ItemManaCookie.java | 84 +- .../botania/common/item/ItemManaGun.java | 607 +- .../botania/common/item/ItemManaMirror.java | 491 +- .../botania/common/item/ItemManaTablet.java | 306 +- .../vazkii/botania/common/item/ItemMod.java | 49 +- .../common/item/ItemObedienceStick.java | 148 +- .../botania/common/item/ItemOpenBucket.java | 82 +- .../common/item/ItemOvergrowthSeed.java | 53 +- .../botania/common/item/ItemPhantomInk.java | 17 +- .../botania/common/item/ItemPinkinator.java | 77 +- .../botania/common/item/ItemPoolMinecart.java | 117 +- .../botania/common/item/ItemRegenIvy.java | 54 +- .../botania/common/item/ItemSextant.java | 278 +- .../botania/common/item/ItemSignalFlare.java | 229 +- .../botania/common/item/ItemSlimeBottle.java | 66 +- .../botania/common/item/ItemSlingshot.java | 87 +- .../vazkii/botania/common/item/ItemSpark.java | 87 +- .../botania/common/item/ItemSparkUpgrade.java | 82 +- .../botania/common/item/ItemSpawnerMover.java | 393 +- .../botania/common/item/ItemSpellCloth.java | 81 +- .../common/item/ItemTemperanceStone.java | 95 +- .../botania/common/item/ItemThornChakram.java | 85 +- .../botania/common/item/ItemTwigWand.java | 545 +- .../botania/common/item/ItemVineBall.java | 28 +- .../vazkii/botania/common/item/ItemVirus.java | 172 +- .../botania/common/item/ItemWaterBowl.java | 13 +- .../botania/common/item/ItemWorldSeed.java | 66 +- .../vazkii/botania/common/item/ModItems.java | 682 +- .../common/item/block/IRarityBlock.java | 7 +- .../common/item/block/ItemBlockDreamwood.java | 15 +- .../common/item/block/ItemBlockElven.java | 19 +- .../block/ItemBlockFloatingSpecialFlower.java | 23 +- .../common/item/block/ItemBlockMod.java | 53 +- .../common/item/block/ItemBlockModSlab.java | 19 +- .../common/item/block/ItemBlockPool.java | 23 +- .../item/block/ItemBlockSpecialFlower.java | 209 +- .../item/block/ItemBlockSpecialQuartz.java | 22 +- .../common/item/block/ItemBlockStorage.java | 18 +- .../item/block/ItemBlockTinyPotato.java | 84 +- .../block/ItemBlockWithMetadataAndName.java | 61 +- .../common/item/brew/ItemBrewBase.java | 318 +- .../common/item/brew/ItemBrewFlask.java | 11 +- .../common/item/brew/ItemBrewVial.java | 11 +- .../common/item/brew/ItemIncenseStick.java | 228 +- .../botania/common/item/brew/ItemVial.java | 77 +- .../armor/elementium/ItemElementiumArmor.java | 138 +- .../armor/elementium/ItemElementiumBoots.java | 15 +- .../armor/elementium/ItemElementiumChest.java | 15 +- .../armor/elementium/ItemElementiumHelm.java | 29 +- .../armor/elementium/ItemElementiumLegs.java | 15 +- .../armor/manasteel/ItemManasteelArmor.java | 430 +- .../armor/manasteel/ItemManasteelBoots.java | 11 +- .../armor/manasteel/ItemManasteelChest.java | 11 +- .../armor/manasteel/ItemManasteelHelm.java | 25 +- .../armor/manasteel/ItemManasteelLegs.java | 11 +- .../armor/manaweave/ItemManaweaveArmor.java | 214 +- .../armor/manaweave/ItemManaweaveBoots.java | 11 +- .../armor/manaweave/ItemManaweaveChest.java | 12 +- .../armor/manaweave/ItemManaweaveHelm.java | 59 +- .../armor/manaweave/ItemManaweaveLegs.java | 11 +- .../armor/terrasteel/ItemTerrasteelArmor.java | 172 +- .../armor/terrasteel/ItemTerrasteelBoots.java | 11 +- .../armor/terrasteel/ItemTerrasteelChest.java | 11 +- .../armor/terrasteel/ItemTerrasteelHelm.java | 250 +- .../armor/terrasteel/ItemTerrasteelLegs.java | 11 +- .../item/equipment/bauble/ItemAuraRing.java | 53 +- .../item/equipment/bauble/ItemBauble.java | 375 +- .../equipment/bauble/ItemBaubleCosmetic.java | 582 +- .../equipment/bauble/ItemBaubleModifier.java | 44 +- .../equipment/bauble/ItemBloodPendant.java | 344 +- .../item/equipment/bauble/ItemDivaCharm.java | 164 +- .../equipment/bauble/ItemFlightTiara.java | 1009 +-- .../equipment/bauble/ItemGoldenLaurel.java | 109 +- .../equipment/bauble/ItemGreaterAuraRing.java | 18 +- .../bauble/ItemGreaterMagnetRing.java | 11 +- .../equipment/bauble/ItemGreaterManaRing.java | 21 +- .../item/equipment/bauble/ItemHolyCloak.java | 240 +- .../item/equipment/bauble/ItemIcePendant.java | 217 +- .../item/equipment/bauble/ItemItemFinder.java | 413 +- .../equipment/bauble/ItemKnockbackBelt.java | 72 +- .../equipment/bauble/ItemLavaPendant.java | 79 +- .../item/equipment/bauble/ItemMagnetRing.java | 274 +- .../item/equipment/bauble/ItemManaRing.java | 188 +- .../item/equipment/bauble/ItemMiningRing.java | 73 +- .../item/equipment/bauble/ItemMonocle.java | 178 +- .../item/equipment/bauble/ItemPixieRing.java | 29 +- .../item/equipment/bauble/ItemReachRing.java | 37 +- .../equipment/bauble/ItemSpeedUpBelt.java | 81 +- .../bauble/ItemSuperLavaPendant.java | 93 +- .../equipment/bauble/ItemSuperTravelBelt.java | 20 +- .../item/equipment/bauble/ItemSwapRing.java | 110 +- .../item/equipment/bauble/ItemTinyPlanet.java | 162 +- .../item/equipment/bauble/ItemTravelBelt.java | 289 +- .../equipment/bauble/ItemUnholyCloak.java | 83 +- .../item/equipment/bauble/ItemWaterRing.java | 97 +- .../item/equipment/tool/ItemEnderDagger.java | 96 +- .../item/equipment/tool/ItemGlassPick.java | 72 +- .../item/equipment/tool/ItemStarSword.java | 95 +- .../item/equipment/tool/ItemThunderSword.java | 130 +- .../item/equipment/tool/ToolCommons.java | 316 +- .../equipment/tool/bow/ItemCrystalBow.java | 65 +- .../equipment/tool/bow/ItemLivingwoodBow.java | 294 +- .../tool/elementium/ItemElementiumAxe.java | 79 +- .../tool/elementium/ItemElementiumPick.java | 83 +- .../tool/elementium/ItemElementiumShears.java | 128 +- .../tool/elementium/ItemElementiumShovel.java | 56 +- .../tool/elementium/ItemElementiumSword.java | 15 +- .../tool/manasteel/ItemManasteelAxe.java | 217 +- .../tool/manasteel/ItemManasteelPick.java | 214 +- .../tool/manasteel/ItemManasteelShears.java | 230 +- .../tool/manasteel/ItemManasteelShovel.java | 239 +- .../tool/manasteel/ItemManasteelSword.java | 172 +- .../tool/terrasteel/ItemTerraAxe.java | 760 +-- .../tool/terrasteel/ItemTerraPick.java | 554 +- .../tool/terrasteel/ItemTerraSword.java | 224 +- .../ItemElementiumHelmRevealing.java | 42 +- .../thaumcraft/ItemManaInkwell.java | 194 +- .../ItemManasteelHelmRevealing.java | 52 +- .../ItemTerrasteelHelmRevealing.java | 44 +- .../botania/common/item/lens/ItemLens.java | 651 +- .../vazkii/botania/common/item/lens/Lens.java | 62 +- .../botania/common/item/lens/LensBounce.java | 43 +- .../botania/common/item/lens/LensDamage.java | 47 +- .../common/item/lens/LensEfficiency.java | 15 +- .../common/item/lens/LensExplosive.java | 35 +- .../botania/common/item/lens/LensFire.java | 60 +- .../common/item/lens/LensFirework.java | 87 +- .../botania/common/item/lens/LensFlare.java | 86 +- .../botania/common/item/lens/LensGravity.java | 15 +- .../common/item/lens/LensInfluence.java | 97 +- .../botania/common/item/lens/LensLight.java | 64 +- .../botania/common/item/lens/LensMagnet.java | 110 +- .../botania/common/item/lens/LensMine.java | 103 +- .../botania/common/item/lens/LensPaint.java | 150 +- .../botania/common/item/lens/LensPhantom.java | 27 +- .../botania/common/item/lens/LensPiston.java | 61 +- .../botania/common/item/lens/LensPower.java | 17 +- .../common/item/lens/LensRedirect.java | 100 +- .../botania/common/item/lens/LensSpeed.java | 19 +- .../botania/common/item/lens/LensStorm.java | 32 +- .../botania/common/item/lens/LensTime.java | 15 +- .../botania/common/item/lens/LensWarp.java | 52 +- .../botania/common/item/lens/LensWeight.java | 55 +- .../botania/common/item/material/ItemDye.java | 96 +- .../common/item/material/ItemManaPetal.java | 26 +- .../item/material/ItemManaResource.java | 307 +- .../item/material/ItemPestleAndMortar.java | 25 +- .../common/item/material/ItemPetal.java | 67 +- .../common/item/material/ItemQuartz.java | 67 +- .../common/item/material/ItemRune.java | 84 +- .../common/item/record/ItemModRecord.java | 72 +- .../common/item/record/ItemRecordGaia1.java | 11 +- .../common/item/record/ItemRecordGaia2.java | 11 +- .../common/item/relic/ItemAesirRing.java | 181 +- .../botania/common/item/relic/ItemDice.java | 139 +- .../common/item/relic/ItemExcaliber.java | 40 +- .../common/item/relic/ItemFlugelEye.java | 861 +-- .../common/item/relic/ItemInfiniteFruit.java | 127 +- .../common/item/relic/ItemKingKey.java | 230 +- .../common/item/relic/ItemLokiRing.java | 521 +- .../common/item/relic/ItemOdinRing.java | 159 +- .../botania/common/item/relic/ItemRelic.java | 247 +- .../common/item/relic/ItemRelicBauble.java | 139 +- .../common/item/relic/ItemThorRing.java | 43 +- .../common/item/rod/ItemCobbleRod.java | 98 +- .../botania/common/item/rod/ItemDirtRod.java | 198 +- .../common/item/rod/ItemDiviningRod.java | 137 +- .../common/item/rod/ItemExchangeRod.java | 790 +-- .../botania/common/item/rod/ItemFireRod.java | 117 +- .../common/item/rod/ItemGravityRod.java | 434 +- .../common/item/rod/ItemMissileRod.java | 177 +- .../common/item/rod/ItemRainbowRod.java | 351 +- .../common/item/rod/ItemSkyDirtRod.java | 69 +- .../botania/common/item/rod/ItemSmeltRod.java | 236 +- .../common/item/rod/ItemTerraformRod.java | 360 +- .../common/item/rod/ItemTornadoRod.java | 319 +- .../botania/common/item/rod/ItemWaterRod.java | 87 +- .../botania/common/lexicon/ALexiconEntry.java | 9 +- .../common/lexicon/BLexiconCategory.java | 16 +- .../botania/common/lexicon/BLexiconEntry.java | 88 +- .../botania/common/lexicon/CLexiconEntry.java | 23 +- .../botania/common/lexicon/DLexiconEntry.java | 19 +- .../botania/common/lexicon/HLexiconEntry.java | 19 +- .../botania/common/lexicon/LexiconData.java | 3238 +++++---- .../botania/common/lexicon/RLexiconEntry.java | 40 +- .../botania/common/lexicon/TLexiconEntry.java | 18 +- .../common/lexicon/WIPLexiconEntry.java | 19 +- .../botania/common/lexicon/WLexiconEntry.java | 32 +- .../botania/common/lexicon/page/PageBrew.java | 178 +- .../lexicon/page/PageCraftingRecipe.java | 327 +- .../common/lexicon/page/PageElvenRecipe.java | 193 +- .../common/lexicon/page/PageEntity.java | 182 +- .../common/lexicon/page/PageGuide.java | 65 +- .../common/lexicon/page/PageImage.java | 61 +- .../common/lexicon/page/PageLoreText.java | 35 +- .../lexicon/page/PageManaInfusionRecipe.java | 260 +- .../common/lexicon/page/PageMultiblock.java | 229 +- .../common/lexicon/page/PagePetalRecipe.java | 226 +- .../common/lexicon/page/PageRecipe.java | 329 +- .../common/lexicon/page/PageRuneRecipe.java | 81 +- .../common/lexicon/page/PageShedding.java | 242 +- .../common/lexicon/page/PageTerrasteel.java | 154 +- .../botania/common/lexicon/page/PageText.java | 218 +- .../common/lexicon/page/PageTutorial.java | 112 +- .../common/lib/LibAchievementNames.java | 103 +- .../botania/common/lib/LibBlockNames.java | 293 +- .../botania/common/lib/LibBrewNames.java | 47 +- .../botania/common/lib/LibEntityNames.java | 43 +- .../vazkii/botania/common/lib/LibGuiIDs.java | 13 +- .../botania/common/lib/LibItemNames.java | 402 +- .../vazkii/botania/common/lib/LibLexicon.java | 484 +- .../vazkii/botania/common/lib/LibMisc.java | 48 +- .../botania/common/lib/LibObfuscation.java | 117 +- .../vazkii/botania/common/lib/LibOreDict.java | 152 +- .../botania/common/lib/LibPotionNames.java | 17 +- .../botania/common/lib/LibTriggerNames.java | 10 +- .../botania/common/network/GuiHandler.java | 61 +- .../common/world/SkyblockWorldEvents.java | 324 +- .../common/world/WorldTypeSkyblock.java | 80 +- 927 files changed, 74293 insertions(+), 69700 deletions(-) create mode 100644 settings.gradle diff --git a/build.gradle b/build.gradle index 5ea36f38c9..046db33f4a 100644 --- a/build.gradle +++ b/build.gradle @@ -1,22 +1,27 @@ -//version: 1644612407 +//version: 1660491897 /* -DO NOT CHANGE THIS FILE! + DO NOT CHANGE THIS FILE! + Also, you may replace this file at any time if there is an update available. + Please check https://github.com/GTNewHorizons/ExampleMod1.7.10/blob/main/build.gradle for updates. + */ -Also, you may replace this file at any time if there is an update available. -Please check https://github.com/GTNewHorizons/ExampleMod1.7.10/blob/main/build.gradle for updates. -*/ - -import org.gradle.internal.logging.text.StyledTextOutput -import org.gradle.internal.logging.text.StyledTextOutputFactory -import org.gradle.internal.logging.text.StyledTextOutput.Style import com.github.jengelman.gradle.plugins.shadow.tasks.ConfigureShadowRelocation import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar +import org.gradle.internal.logging.text.StyledTextOutput.Style +import org.gradle.internal.logging.text.StyledTextOutputFactory +import java.nio.file.Files +import java.nio.file.Paths import java.util.concurrent.TimeUnit +import java.util.zip.ZipEntry +import java.util.zip.ZipInputStream +import java.util.zip.ZipOutputStream buildscript { repositories { + mavenCentral() + maven { name 'forge' url 'https://maven.minecraftforge.net' @@ -38,21 +43,29 @@ buildscript { classpath 'com.github.GTNewHorizons:ForgeGradle:1.2.7' } } - plugins { id 'java-library' id 'idea' id 'eclipse' id 'scala' id 'maven-publish' - id 'org.jetbrains.kotlin.jvm' version '1.5.30' apply false - id 'org.jetbrains.kotlin.kapt' version '1.5.30' apply false + id 'org.jetbrains.kotlin.jvm' version '1.5.30' apply false + id 'org.jetbrains.kotlin.kapt' version '1.5.30' apply false + id 'com.google.devtools.ksp' version '1.5.30-1.0.0' apply false id 'org.ajoberstar.grgit' version '4.1.1' id 'com.github.johnrengelman.shadow' version '4.0.4' - id 'com.palantir.git-version' version '0.13.0' apply false + id 'com.palantir.git-version' version '0.13.0' apply false id 'de.undercouch.download' version '5.0.1' - id 'com.github.gmazzo.buildconfig' version '3.0.3' apply false + id 'com.github.gmazzo.buildconfig' version '3.0.3' apply false + id "com.diffplug.spotless" version "6.7.2" } +verifySettingsGradle() + +dependencies { + implementation 'com.diffplug:blowdryer:1.6.0' +} + +apply plugin: 'com.diffplug.blowdryer' if (project.file('.git/HEAD').isFile()) { apply plugin: 'com.palantir.git-version' @@ -77,6 +90,7 @@ idea { downloadSources = true } } +apply from: Blowdryer.file('spotless.gradle') if(JavaVersion.current() != JavaVersion.VERSION_1_8) { throw new GradleException("This project requires Java 8, but it's running on " + JavaVersion.current()) @@ -103,8 +117,11 @@ checkPropertyExists("containsMixinsAndOrCoreModOnly") checkPropertyExists("usesShadowedDependencies") checkPropertyExists("developmentEnvironmentUserName") -boolean noPublishedSources = project.findProperty("noPublishedSources") ? project.noPublishedSources.toBoolean() : false - +boolean noPublishedSources = project.hasProperty("noPublishedSources") ? project.noPublishedSources.toBoolean() : false +boolean usesMixinDebug = project.hasProperty('usesMixinDebug') ?: project.usesMixins.toBoolean() +boolean forceEnableMixins = project.hasProperty('forceEnableMixins') ? project.forceEnableMixins.toBoolean() : false +String channel = project.hasProperty('channel') ? project.channel : 'stable' +String mappingsVersion = project.hasProperty('mappingsVersion') ? project.mappingsVersion : '12' String javaSourceDir = "src/main/java/" String scalaSourceDir = "src/main/scala/" String kotlinSourceDir = "src/main/kotlin/" @@ -175,7 +192,7 @@ configurations.all { try { 'git config core.fileMode false'.execute() } -catch (Exception e) { +catch (Exception ignored) { out.style(Style.Failure).println("git isn't installed at all") } @@ -185,12 +202,12 @@ String versionOverride = System.getenv("VERSION") ?: null try { identifiedVersion = versionOverride == null ? gitVersion() : versionOverride } -catch (Exception e) { +catch (Exception ignored) { out.style(Style.Failure).text( - 'This mod must be version controlled by Git AND the repository must provide at least one tag,\n' + - 'or the VERSION override must be set! ').style(Style.SuccessHeader).text('(Do NOT download from GitHub using the ZIP option, instead\n' + - 'clone the repository, see ').style(Style.Info).text('https://gtnh.miraheze.org/wiki/Development').style(Style.SuccessHeader).println(' for details.)' - ) + 'This mod must be version controlled by Git AND the repository must provide at least one tag,\n' + + 'or the VERSION override must be set! ').style(Style.SuccessHeader).text('(Do NOT download from GitHub using the ZIP option, instead\n' + + 'clone the repository, see ').style(Style.Info).text('https://gtnh.miraheze.org/wiki/Development').style(Style.SuccessHeader).println(' for details.)' + ) versionOverride = 'NO-GIT-TAG-SET' identifiedVersion = versionOverride } @@ -199,7 +216,7 @@ ext { modVersion = identifiedVersion } -if( identifiedVersion.equals(versionOverride) ) { +if(identifiedVersion == versionOverride) { out.style(Style.Failure).text('Override version to ').style(Style.Identifier).text(modVersion).style(Style.Failure).println('!\7') } @@ -214,13 +231,17 @@ else { def arguments = [] def jvmArguments = [] -if(usesMixins.toBoolean()) { +if (usesMixins.toBoolean() || forceEnableMixins) { arguments += [ - "--tweakClass org.spongepowered.asm.launch.MixinTweaker" - ] - jvmArguments += [ - "-Dmixin.debug.countInjections=true", "-Dmixin.debug.verbose=true", "-Dmixin.debug.export=true" + "--tweakClass org.spongepowered.asm.launch.MixinTweaker" ] + if (usesMixinDebug.toBoolean()) { + jvmArguments += [ + "-Dmixin.debug.countInjections=true", + "-Dmixin.debug.verbose=true", + "-Dmixin.debug.export=true" + ] + } } minecraft { @@ -275,7 +296,7 @@ repositories { name 'Overmind forge repo mirror' url 'https://gregtech.overminddl1.com/' } - if(usesMixins.toBoolean()) { + if(usesMixins.toBoolean() || forceEnableMixins) { maven { name 'sponge' url 'https://repo.spongepowered.org/repository/maven-public' @@ -292,6 +313,8 @@ dependencies { annotationProcessor('com.google.guava:guava:24.1.1-jre') annotationProcessor('com.google.code.gson:gson:2.8.6') annotationProcessor('org.spongepowered:mixin:0.8-SNAPSHOT') + } + if(usesMixins.toBoolean() || forceEnableMixins) { // using 0.8 to workaround a issue in 0.7 which fails mixin application compile('com.github.GTNewHorizons:SpongePoweredMixin:0.7.12-GTNH') { // Mixin includes a lot of dependencies that are too up-to-date @@ -312,18 +335,23 @@ def refMap = "${tasks.compileJava.temporaryDir}" + File.separator + mixingConfig def mixinSrg = "${tasks.reobf.temporaryDir}" + File.separator + "mixins.srg" task generateAssets { - if(usesMixins.toBoolean()) { - getFile("/src/main/resources/mixins." + modId + ".json").text = """{ + if (usesMixins.toBoolean()) { + def mixinConfigFile = getFile("/src/main/resources/mixins." + modId + ".json"); + if (!mixinConfigFile.exists()) { + mixinConfigFile.text = """{ "required": true, "minVersion": "0.7.11", "package": "${modGroup}.${mixinsPackage}", "plugin": "${modGroup}.${mixinPlugin}", "refmap": "${mixingConfigRefMap}", "target": "@env(DEFAULT)", - "compatibilityLevel": "JAVA_8" + "compatibilityLevel": "JAVA_8", + "mixins": [], + "client": [], + "server": [] } - """ + } } } @@ -344,7 +372,10 @@ shadowJar { } minimize() // This will only allow shading for actually used classes - configurations = [project.configurations.shadowImplementation, project.configurations.shadowCompile] + configurations = [ + project.configurations.shadowImplementation, + project.configurations.shadowCompile + ] dependsOn(relocateShadowJar) } @@ -366,7 +397,7 @@ jar { } reobf { - if(usesMixins.toBoolean()) { + if(usesMixins.toBoolean() && file(mixinSrg).exists()) { addExtraSrgFile mixinSrg } } @@ -375,12 +406,12 @@ afterEvaluate { if(usesMixins.toBoolean()) { tasks.compileJava { options.compilerArgs += [ - "-AreobfSrgFile=${tasks.reobf.srg}", - "-AoutSrgFile=${mixinSrg}", - "-AoutRefMapFile=${refMap}", - // Elan: from what I understand they are just some linter configs so you get some warning on how to properly code - "-XDenableSunApiLintControl", - "-XDignore.symbol.file" + "-AreobfSrgFile=${tasks.reobf.srg}", + "-AoutSrgFile=${mixinSrg}", + "-AoutRefMapFile=${refMap}", + // Elan: from what I understand they are just some linter configs so you get some warning on how to properly code + "-XDenableSunApiLintControl", + "-XDignore.symbol.file" ] } } @@ -389,8 +420,8 @@ afterEvaluate { runClient { if(developmentEnvironmentUserName) { arguments += [ - "--username", - developmentEnvironmentUserName + "--username", + developmentEnvironmentUserName ] } @@ -408,13 +439,14 @@ tasks.withType(JavaExec).configureEach { javaToolchains.launcherFor { languageVersion = projectJavaVersion } - ) + ) } processResources { // this will ensure that this task is redone when the versions change. inputs.property "version", project.version inputs.property "mcversion", project.minecraft.version + exclude("spotless.gradle") // replace stuff in mcmod.info, nothing else from(sourceSets.main.resources.srcDirs) { @@ -422,9 +454,9 @@ processResources { // replace modVersion and minecraftVersion expand "minecraftVersion": project.minecraft.version, - "modVersion": modVersion, - "modId": modId, - "modName": modName + "modVersion": modVersion, + "modId": modId, + "modName": modName } if(usesMixins.toBoolean()) { @@ -434,12 +466,13 @@ processResources { // copy everything else that's not the mcmod.info from(sourceSets.main.resources.srcDirs) { exclude 'mcmod.info' + exclude 'spotless.gradle' } } def getManifestAttributes() { def manifestAttributes = [:] - if(containsMixinsAndOrCoreModOnly.toBoolean() == false && (usesMixins.toBoolean() || coreModClass)) { + if(!containsMixinsAndOrCoreModOnly.toBoolean() && (usesMixins.toBoolean() || coreModClass)) { manifestAttributes += ["FMLCorePluginContainsFMLMod": true] } @@ -453,16 +486,16 @@ def getManifestAttributes() { if(usesMixins.toBoolean()) { manifestAttributes += [ - "TweakClass" : "org.spongepowered.asm.launch.MixinTweaker", - "MixinConfigs" : "mixins." + modId + ".json", - "ForceLoadAsMod" : containsMixinsAndOrCoreModOnly.toBoolean() == false + "TweakClass" : "org.spongepowered.asm.launch.MixinTweaker", + "MixinConfigs" : "mixins." + modId + ".json", + "ForceLoadAsMod" : !containsMixinsAndOrCoreModOnly.toBoolean() ] } return manifestAttributes } task sourcesJar(type: Jar) { - from (sourceSets.main.allJava) + from (sourceSets.main.allSource) from (file("$projectDir/LICENSE")) getArchiveClassifier().set('sources') } @@ -482,7 +515,10 @@ task shadowDevJar(type: ShadowJar) { } minimize() // This will only allow shading for actually used classes - configurations = [project.configurations.shadowImplementation, project.configurations.shadowCompile] + configurations = [ + project.configurations.shadowImplementation, + project.configurations.shadowCompile + ] } task relocateShadowDevJar(type: ConfigureShadowRelocation) { @@ -517,7 +553,7 @@ task devJar(type: Jar) { } task apiJar(type: Jar) { - from (sourceSets.main.allJava) { + from (sourceSets.main.allSource) { include modGroup.toString().replaceAll("\\.", "/") + "/" + apiPackage.toString().replaceAll("\\.", "/") + '/**' } @@ -548,6 +584,9 @@ tasks.withType(GenerateModuleMetadata) { enabled = false } +// workaround variable hiding in pom processing +def projectConfigs = project.configurations + publishing { publications { maven(MavenPublication) { @@ -556,7 +595,7 @@ publishing { artifact source: shadowJar, classifier: "" } if(!noPublishedSources) { - artifact source: sourcesJar, classifier: "src" + artifact source: sourcesJar, classifier: "sources" } artifact source: usesShadowedDependencies.toBoolean() ? shadowDevJar : devJar, classifier: "dev" if (apiPackage) { @@ -568,16 +607,23 @@ publishing { // Using the identified version, not project.version as it has the prepended 1.7.10 version = System.getenv("RELEASE_VERSION") ?: identifiedVersion - // remove extra garbage from who knows where + // remove extra garbage from minecraft and minecraftDeps configuration pom.withXml { - def badPomGroup = ['net.minecraft', 'com.google.code.findbugs', 'org.ow2.asm', 'com.typesafe.akka', 'com.typesafe', 'org.scala-lang', - 'org.scala-lang.plugins', 'net.sf.jopt-simple', 'lzma', 'com.mojang', 'org.apache.commons', 'org.apache.httpcomponents', - 'commons-logging', 'java3d', 'net.sf.trove4j', 'com.ibm.icu', 'com.paulscode', 'io.netty', 'com.google.guava', - 'commons-io', 'commons-codec', 'net.java.jinput', 'net.java.jutils', 'com.google.code.gson', 'org.apache.logging.log4j', - 'org.lwjgl.lwjgl', 'tv.twitch', 'org.jetbrains.kotlin', ''] + def badArtifacts = [:].withDefault {[] as Set} + for (configuration in [ + projectConfigs.minecraft, + projectConfigs.minecraftDeps + ]) { + for (dependency in configuration.allDependencies) { + badArtifacts[dependency.group == null ? "" : dependency.group] += dependency.name + } + } + // example for specifying extra stuff to ignore + // badArtifacts["org.example.group"] += "artifactName" + Node pomNode = asNode() pomNode.dependencies.'*'.findAll() { - badPomGroup.contains(it.groupId.text()) + badArtifacts[it.groupId.text()].contains(it.artifactId.text()) }.each() { it.parent().remove(it) } @@ -601,11 +647,11 @@ task updateBuildScript { doLast { if (performBuildScriptUpdate(projectDir.toString())) return - print("Build script already up-to-date!") + print("Build script already up-to-date!") } } -if (isNewBuildScriptVersionAvailable(projectDir.toString())) { +if (!project.getGradle().startParameter.isOffline() && isNewBuildScriptVersionAvailable(projectDir.toString())) { if (autoUpdateBuildScript.toBoolean()) { performBuildScriptUpdate(projectDir.toString()) } else { @@ -616,12 +662,26 @@ if (isNewBuildScriptVersionAvailable(projectDir.toString())) { static URL availableBuildScriptUrl() { new URL("https://raw.githubusercontent.com/GTNewHorizons/ExampleMod1.7.10/main/build.gradle") } +static URL exampleSettingsGradleUrl() { + new URL("https://raw.githubusercontent.com/GTNewHorizons/ExampleMod1.7.10/main/settings.gradle.example") +} + + +def verifySettingsGradle() { + def settingsFile = getFile("settings.gradle") + if (!settingsFile.exists()) { + println("Downloading default settings.gradle") + exampleSettingsGradleUrl().withInputStream { i -> settingsFile.withOutputStream { it << i } } + throw new GradleException("Settings.gradle has been updated, please re-run task.") + } +} boolean performBuildScriptUpdate(String projectDir) { if (isNewBuildScriptVersionAvailable(projectDir)) { def buildscriptFile = getFile("build.gradle") availableBuildScriptUrl().withInputStream { i -> buildscriptFile.withOutputStream { it << i } } out.style(Style.Success).print("Build script updated. Please REIMPORT the project or RESTART your IDE!") + verifySettingsGradle() return true } return false @@ -652,80 +712,225 @@ configure(updateBuildScript) { description = 'Updates the build script to the latest version' } -// Deobfuscation +// Parameter Deobfuscation -def deobf(String sourceURL) { - try { - URL url = new URL(sourceURL) - String fileName = url.getFile() - - //get rid of directories: - int lastSlash = fileName.lastIndexOf("/") - if(lastSlash > 0) { - fileName = fileName.substring(lastSlash + 1) +task deobfParams { + doLast { + + String mcpDir = "$project.gradle.gradleUserHomeDir/caches/minecraft/de/oceanlabs/mcp/mcp_$channel/$mappingsVersion" + String mcpZIP = "$mcpDir/mcp_$channel-$mappingsVersion-${minecraftVersion}.zip" + String paramsCSV = "$mcpDir/params.csv" + + download.run { + src "https://maven.minecraftforge.net/de/oceanlabs/mcp/mcp_$channel/$mappingsVersion-$minecraftVersion/mcp_$channel-$mappingsVersion-${minecraftVersion}.zip" + dest mcpZIP + overwrite false } - //get rid of extension: - if(fileName.endsWith(".jar")) { - fileName = fileName.substring(0, fileName.lastIndexOf(".")) + + if(!file(paramsCSV).exists()) { + println("Extracting MCP archive ...") + unzip(mcpZIP, mcpDir) } - String hostName = url.getHost() - if(hostName.startsWith("www.")) { - hostName = hostName.substring(4) + println("Parsing params.csv ...") + Map params = new HashMap<>() + Files.lines(Paths.get(paramsCSV)).forEach{line -> + String[] cells = line.split(",") + if(cells.length > 2 && cells[0].matches("p_i?\\d+_\\d+_")) { + params.put(cells[0], cells[1]) + } } - List parts = Arrays.asList(hostName.split("\\.")) - Collections.reverse(parts) - hostName = String.join(".", parts) - return deobf(sourceURL, hostName + "/" + fileName) - } catch(Exception e) { - return deobf(sourceURL, "deobf/" + String.valueOf(sourceURL.hashCode())) - } + out.style(Style.Success).println("Modified ${replaceParams(file("$projectDir/src/main/java"), params)} files!") + out.style(Style.Failure).println("Don't forget to verify that the code still works as before!\n It could be broken due to duplicate variables existing now\n or parameters taking priority over other variables.") +} } -// The method above is to be preferred. Use this method if the filename is not at the end of the URL. -def deobf(String sourceURL, String fileName) { - String cacheDir = System.getProperty("user.home") + "/.gradle/caches/" - String bon2Dir = cacheDir + "forge_gradle/deobf" - String bon2File = bon2Dir + "/BON2-2.5.0.jar" - String obfFile = cacheDir + "modules-2/files-2.1/" + fileName + ".jar" - String deobfFile = cacheDir + "modules-2/files-2.1/" + fileName + "-deobf.jar" +static int replaceParams(File file, Map params) { +int fileCount = 0 - if(file(deobfFile).exists()) { - return files(deobfFile) +if(file.isDirectory()) { + for(File f : file.listFiles()) { + fileCount += replaceParams(f, params) } - - download.run { - src 'https://github.com/GTNewHorizons/BON2/releases/download/2.5.0/BON2-2.5.0.CUSTOM-all.jar' - dest bon2File - quiet true - overwrite false + return fileCount +} +println("Visiting ${file.getName()} ...") +try { + String content = new String(Files.readAllBytes(file.toPath())) + int hash = content.hashCode() + params.forEach{key, value -> + content = content.replaceAll(key, value) + } + if(hash != content.hashCode()) { + Files.write(file.toPath(), content.getBytes("UTF-8")) + return 1 + } +} catch(Exception e) { + e.printStackTrace() +} +return 0 +} + +// Credit: bitsnaps (https://gist.github.com/bitsnaps/00947f2dce66f4bbdabc67d7e7b33681) +static unzip(String zipFileName, String outputDir) { +byte[] buffer = new byte[16384] +ZipInputStream zis = new ZipInputStream(new FileInputStream(zipFileName)) +ZipEntry zipEntry = zis.getNextEntry() +while (zipEntry != null) { + File newFile = new File(outputDir + File.separator, zipEntry.name) + if (zipEntry.isDirectory()) { + if (!newFile.isDirectory() && !newFile.mkdirs()) { + throw new IOException("Failed to create directory $newFile") + } + } else { + // fix for Windows-created archives + File parent = newFile.parentFile + if (!parent.isDirectory() && !parent.mkdirs()) { + throw new IOException("Failed to create directory $parent") + } + // write file content + FileOutputStream fos = new FileOutputStream(newFile) + int len = 0 + while ((len = zis.read(buffer)) > 0) { + fos.write(buffer, 0, len) + } + fos.close() } + zipEntry = zis.getNextEntry() +} +zis.closeEntry() +zis.close() +} + +configure(deobfParams) { +group = 'forgegradle' +description = 'Rename all obfuscated parameter names inherited from Minecraft classes' +} + +// Dependency Deobfuscation + +def deobf(String sourceURL) { +try { + URL url = new URL(sourceURL) + String fileName = url.getFile() - download.run { - src sourceURL - dest obfFile - quiet true - overwrite false + //get rid of directories: + int lastSlash = fileName.lastIndexOf("/") + if(lastSlash > 0) { + fileName = fileName.substring(lastSlash + 1) + } + //get rid of extension: + if(fileName.endsWith(".jar") || fileName.endsWith(".litemod")) { + fileName = fileName.substring(0, fileName.lastIndexOf(".")) } - exec { - commandLine 'java', '-jar', bon2File, '--inputJar', obfFile, '--outputJar', deobfFile, '--mcVer', '1.7.10', '--mappingsVer', 'stable_12', '--notch' - workingDir bon2Dir - standardOutput = new ByteArrayOutputStream() + String hostName = url.getHost() + if(hostName.startsWith("www.")) { + hostName = hostName.substring(4) } + List parts = Arrays.asList(hostName.split("\\.")) + Collections.reverse(parts) + hostName = String.join(".", parts) + + return deobf(sourceURL, "$hostName/$fileName") +} catch(Exception e) { + return deobf(sourceURL, "deobf/${sourceURL.hashCode()}") +} +} +// The method above is to be preferred. Use this method if the filename is not at the end of the URL. +def deobf(String sourceURL, String rawFileName) { +String bon2Version = "2.5.1" +String fileName = URLDecoder.decode(rawFileName, "UTF-8") +String cacheDir = "$project.gradle.gradleUserHomeDir/caches" +String bon2Dir = "$cacheDir/forge_gradle/deobf" +String bon2File = "$bon2Dir/BON2-${bon2Version}.jar" +String obfFile = "$cacheDir/modules-2/files-2.1/${fileName}.jar" +String deobfFile = "$cacheDir/modules-2/files-2.1/${fileName}-deobf.jar" + +if(file(deobfFile).exists()) { return files(deobfFile) } +String mappingsVer +String remoteMappings = project.hasProperty('remoteMappings') ? project.remoteMappings : 'https://raw.githubusercontent.com/MinecraftForge/FML/1.7.10/conf/' +if(remoteMappings) { + String id = "${forgeVersion.split("\\.")[3]}-$minecraftVersion" + String mappingsZIP = "$cacheDir/forge_gradle/maven_downloader/de/oceanlabs/mcp/mcp_snapshot_nodoc/$id/mcp_snapshot_nodoc-${id}.zip" + + zipMappings(mappingsZIP, remoteMappings, bon2Dir) + + mappingsVer = "snapshot_$id" +} else { + mappingsVer = "${channel}_$mappingsVersion" +} + +download.run { + src "http://jenkins.usrv.eu:8081/nexus/content/repositories/releases/com/github/parker8283/BON2/$bon2Version-CUSTOM/BON2-$bon2Version-CUSTOM-all.jar" + dest bon2File + quiet true + overwrite false +} + +download.run { + src sourceURL + dest obfFile + quiet true + overwrite false +} + +exec { + commandLine 'java', '-jar', bon2File, '--inputJar', obfFile, '--outputJar', deobfFile, '--mcVer', minecraftVersion, '--mappingsVer', mappingsVer, '--notch' + workingDir bon2Dir + standardOutput = new FileOutputStream("${deobfFile}.log") +} + +return files(deobfFile) +} + +def zipMappings(String zipPath, String url, String bon2Dir) { +File zipFile = new File(zipPath) +if(zipFile.exists()) { + return +} + +String fieldsCache = "$bon2Dir/data/fields.csv" +String methodsCache = "$bon2Dir/data/methods.csv" + +download.run { + src "${url}fields.csv" + dest fieldsCache + quiet true +} +download.run { + src "${url}methods.csv" + dest methodsCache + quiet true +} + +zipFile.getParentFile().mkdirs() +ZipOutputStream zos = new ZipOutputStream(new FileOutputStream(zipFile)) + +zos.putNextEntry(new ZipEntry("fields.csv")) +Files.copy(Paths.get(fieldsCache), zos) +zos.closeEntry() + +zos.putNextEntry(new ZipEntry("methods.csv")) +Files.copy(Paths.get(methodsCache), zos) +zos.closeEntry() + +zos.close() +} + // Helper methods def checkPropertyExists(String propertyName) { - if (project.hasProperty(propertyName) == false) { - throw new GradleException("This project requires a property \"" + propertyName + "\"! Please add it your \"gradle.properties\". You can find all properties and their description here: https://github.com/GTNewHorizons/ExampleMod1.7.10/blob/main/gradle.properties") - } +if (!project.hasProperty(propertyName)) { + throw new GradleException("This project requires a property \"" + propertyName + "\"! Please add it your \"gradle.properties\". You can find all properties and their description here: https://github.com/GTNewHorizons/ExampleMod1.7.10/blob/main/gradle.properties") +} } def getFile(String relativePath) { - return new File(projectDir, relativePath) +return new File(projectDir, relativePath) } diff --git a/settings.gradle b/settings.gradle new file mode 100644 index 0000000000..97d8f71c52 --- /dev/null +++ b/settings.gradle @@ -0,0 +1,10 @@ +plugins { + id 'com.diffplug.blowdryerSetup' version '1.6.0' +} + +apply plugin: 'com.diffplug.blowdryerSetup' + +blowdryerSetup { + github('GTNewHorizons/ExampleMod1.7.10', 'tag', '0.1.4') + //devLocal '.' // Use this when testing config updates locally +} diff --git a/src/main/java/vazkii/botania/api/BotaniaAPI.java b/src/main/java/vazkii/botania/api/BotaniaAPI.java index 2fc841b3bf..77549e44ff 100644 --- a/src/main/java/vazkii/botania/api/BotaniaAPI.java +++ b/src/main/java/vazkii/botania/api/BotaniaAPI.java @@ -2,14 +2,17 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jan 14, 2014, 6:15:28 PM (GMT)] */ package vazkii.botania.api; +import com.google.common.collect.BiMap; +import com.google.common.collect.HashBiMap; +import cpw.mods.fml.common.Loader; import java.util.ArrayList; import java.util.HashMap; import java.util.LinkedHashMap; @@ -17,7 +20,6 @@ import java.util.List; import java.util.Map; import java.util.Set; - import net.minecraft.block.Block; import net.minecraft.entity.Entity; import net.minecraft.init.Blocks; @@ -53,626 +55,636 @@ import vazkii.botania.api.wiki.SimpleWikiProvider; import vazkii.botania.api.wiki.WikiHooks; -import com.google.common.collect.BiMap; -import com.google.common.collect.HashBiMap; - -import cpw.mods.fml.common.Loader; - public final class BotaniaAPI { - private static List categories = new ArrayList(); - private static List allEntries = new ArrayList(); - - public static Map knowledgeTypes = new HashMap(); - - public static Map brewMap = new LinkedHashMap(); - - public static List disposableBlocks = new ArrayList(); - public static List semiDisposableBlocks = new ArrayList(); - - public static List petalRecipes = new ArrayList(); - public static List pureDaisyRecipes = new ArrayList(); - public static List manaInfusionRecipes = new ArrayList(); - public static List runeAltarRecipes = new ArrayList(); - public static List elvenTradeRecipes = new ArrayList(); - public static List brewRecipes = new ArrayList(); - public static List miniFlowerRecipes = new ArrayList(); - - private static BiMap> subTiles = HashBiMap.> create(); - private static Map, SubTileSignature> subTileSignatures = new HashMap, SubTileSignature>(); - public static Set subtilesForCreativeMenu = new LinkedHashSet(); - public static Map subTileMods = new HashMap(); - public static BiMap miniFlowers = HashBiMap. create(); - - public static Map oreWeights = new HashMap(); - public static Map oreWeightsNether = new HashMap(); - public static Map seeds = new HashMap(); - public static Set looniumBlacklist = new LinkedHashSet(); - public static Set paintableBlocks = new LinkedHashSet(); - public static Set magnetBlacklist = new LinkedHashSet(); - public static Set> gravityRodBlacklist = new LinkedHashSet>(); - - public static ArmorMaterial manasteelArmorMaterial = EnumHelper.addArmorMaterial("MANASTEEL", 16, new int[] { 2, 6, 5, 2 }, 18); - public static ToolMaterial manasteelToolMaterial = EnumHelper.addToolMaterial("MANASTEEL", 3, 300, 6.2F, 2F, 20); - - public static ArmorMaterial elementiumArmorMaterial = EnumHelper.addArmorMaterial("B_ELEMENTIUM", 18, new int[] { 2, 6, 5, 2 }, 18); - public static ToolMaterial elementiumToolMaterial = EnumHelper.addToolMaterial("B_ELEMENTIUM", 3, 720, 6.2F, 2F, 20); - - public static ArmorMaterial terrasteelArmorMaterial = EnumHelper.addArmorMaterial("TERRASTEEL", 34, new int[] {3, 8, 6, 3}, 26); - public static ToolMaterial terrasteelToolMaterial = EnumHelper.addToolMaterial("TERRASTEEL", 4, 2300, 9F, 3F, 26); - - public static ArmorMaterial manaweaveArmorMaterial = EnumHelper.addArmorMaterial("MANAWEAVE", 5, new int[] { 1, 2, 2, 1 }, 18); - - public static EnumRarity rarityRelic = EnumHelper.addRarity("RELIC", EnumChatFormatting.GOLD, "Relic"); - - public static KnowledgeType basicKnowledge; - public static KnowledgeType elvenKnowledge; - - // This is here for completeness sake, but you shouldn't use it - public static KnowledgeType relicKnowledge; - - // All of these categories are initialized during botania's PreInit stage. - public static LexiconCategory categoryBasics; - public static LexiconCategory categoryMana; - public static LexiconCategory categoryFunctionalFlowers; - public static LexiconCategory categoryGenerationFlowers; - public static LexiconCategory categoryDevices; - public static LexiconCategory categoryTools; - public static LexiconCategory categoryBaubles; - public static LexiconCategory categoryEnder; - public static LexiconCategory categoryAlfhomancy; - public static LexiconCategory categoryMisc; - - public static Brew fallbackBrew = new Brew("fallback", "botania.brew.fallback", 0, 0); - - static { - registerSubTile("", DummySubTile.class); - - basicKnowledge = registerKnowledgeType("minecraft", EnumChatFormatting.RESET, true); - elvenKnowledge = registerKnowledgeType("alfheim", EnumChatFormatting.DARK_GREEN, false); - relicKnowledge = registerKnowledgeType("relic", EnumChatFormatting.DARK_PURPLE, false); - - addOreWeight("oreAluminum", 3940); // Tinkers' Construct - addOreWeight("oreAmber", 2075); // Thaumcraft - addOreWeight("oreApatite", 1595); // Forestry - addOreWeight("oreBlueTopaz", 3195); // Ars Magica - addOreWeight("oreCertusQuartz", 3975); // Applied Energistics - addOreWeight("oreChimerite", 3970); // Ars Magica - addOreWeight("oreCinnabar", 2585); // Thaumcraft - addOreWeight("oreCoal", 46525); // Vanilla - addOreWeight("oreCopper", 8325); // IC2, Thermal Expansion, Tinkers' Construct, etc. - addOreWeight("oreDark", 1350); // EvilCraft - addOreWeight("oreDarkIron", 1700); // Factorization (older versions) - addOreWeight("oreFzDarkIron", 1700); // Factorization (newer versions) - addOreWeight("oreDiamond", 1265); // Vanilla - addOreWeight("oreEmerald", 780); // Vanilla - addOreWeight("oreGalena", 1000); // Factorization - addOreWeight("oreGold", 2970); // Vanilla - addOreWeight("oreInfusedAir", 925); // Thaumcraft - addOreWeight("oreInfusedEarth", 925); // Thaumcraft - addOreWeight("oreInfusedEntropy", 925); // Thaumcraft - addOreWeight("oreInfusedFire", 925); // Thaumcraft - addOreWeight("oreInfusedOrder", 925); // Thaumcraft - addOreWeight("oreInfusedWater", 925); // Thaumcraft - addOreWeight("oreIron", 20665); // Vanilla - addOreWeight("oreLapis", 1285); // Vanilla - addOreWeight("oreLead", 7985); // IC2, Thermal Expansion, Factorization, etc. - addOreWeight("oreMCropsEssence", 3085); // Magical Crops - addOreWeight("oreMithril", 8); // Thermal Expansion - addOreWeight("oreNickel", 2275); // Thermal Expansion - addOreWeight("oreOlivine", 1100); // Project RED - addOreWeight("orePlatinum", 365); // Thermal Expansion - addOreWeight("oreRedstone", 6885); // Vanilla - addOreWeight("oreRuby", 1100); // Project RED - addOreWeight("oreSapphire", 1100); // Project RED - addOreWeight("oreSilver", 6300); // Thermal Expansion, Factorization, etc. - addOreWeight("oreSulfur", 1105); // Railcraft - addOreWeight("oreTin", 9450); // IC2, Thermal Expansion, etc. - addOreWeight("oreUranium", 1337); // IC2 - addOreWeight("oreVinteum", 5925); // Ars Magica - addOreWeight("oreYellorite", 3520); // Big Reactors - addOreWeight("oreZinc", 6485); // Flaxbeard's Steam Power - addOreWeight("oreMythril", 6485); // Simple Ores2 - addOreWeight("oreAdamantium", 2275); // Simple Ores2 - addOreWeight("oreTungsten", 3520); // Simple Tungsten - - addOreWeightNether("oreQuartz", 19600); // Vanilla - addOreWeightNether("oreCobalt", 500); // Tinker's Construct - addOreWeightNether("oreArdite", 500); // Tinker's Construct - addOreWeightNether("oreFirestone", 5); // Railcraft - addOreWeightNether("oreNetherCoal", 17000); // Nether Ores - addOreWeightNether("oreNetherCopper", 4700); // Nether Ores - addOreWeightNether("oreNetherDiamond", 175); // Nether Ores - addOreWeightNether("oreNetherEssence", 2460); // Magical Crops - addOreWeightNether("oreNetherGold", 3635); // Nether Ores - addOreWeightNether("oreNetherIron", 5790); // Nether Ores - addOreWeightNether("oreNetherLapis", 3250); // Nether Ores - addOreWeightNether("oreNetherLead", 2790); // Nether Ores - addOreWeightNether("oreNetherNickel", 1790); // Nether Ores - addOreWeightNether("oreNetherPlatinum", 170); // Nether Ores - addOreWeightNether("oreNetherRedstone", 5600); // Nether Ores - addOreWeightNether("oreNetherSilver", 1550); // Nether Ores - addOreWeightNether("oreNetherSteel", 1690); // Nether Ores - addOreWeightNether("oreNetherTin", 3750); // Nether Ores - addOreWeightNether("oreFyrite", 1000); // Netherrocks - addOreWeightNether("oreAshstone", 1000); // Netherrocks - addOreWeightNether("oreDragonstone", 175); // Netherrocks - addOreWeightNether("oreArgonite", 1000); // Netherrocks - addOreWeightNether("oreOnyx", 500); // SimpleOres 2 - addOreWeightNether("oreHaditeCoal", 500); // Hadite - - addSeed(Items.wheat_seeds, Blocks.wheat); - addSeed(Items.potato, Blocks.potatoes); - addSeed(Items.carrot, Blocks.carrots); - addSeed(Items.nether_wart, Blocks.nether_wart); - addSeed(Items.pumpkin_seeds, Blocks.pumpkin_stem); - addSeed(Items.melon_seeds, Blocks.melon_stem); - - registerModWiki("Minecraft", new SimpleWikiProvider("Minecraft Wiki", "http://minecraft.gamepedia.com/%s")); - - IWikiProvider technicWiki = new SimpleWikiProvider("Technic Wiki", "http://wiki.technicpack.net/%s"); - IWikiProvider mekanismWiki = new SimpleWikiProvider("Mekanism Wiki", "http://wiki.aidancbrady.com/wiki/%s"); - IWikiProvider buildcraftWiki = new SimpleWikiProvider("BuildCraft Wiki", "http://www.mod-buildcraft.com/wiki/doku.php?id=%s"); - - registerModWiki("Mekanism", mekanismWiki); - registerModWiki("MekanismGenerators", mekanismWiki); - registerModWiki("MekanismTools", mekanismWiki); - registerModWiki("EnderIO", new SimpleWikiProvider("EnderIO Wiki", "http://wiki.enderio.com/%s")); - registerModWiki("TropiCraft", new SimpleWikiProvider("Tropicraft Wiki", "http://wiki.tropicraft.net/wiki/%s")); - registerModWiki("RandomThings", new SimpleWikiProvider("Random Things Wiki", "http://randomthingsminecraftmod.wikispaces.com/%s")); - registerModWiki("Witchery", new SimpleWikiProvider("Witchery Wiki", "https://sites.google.com/site/witcherymod/%s", "-", true)); - registerModWiki("AppliedEnergistics2", new SimpleWikiProvider("AE2 Wiki", "http://ae-mod.info/%s")); - registerModWiki("BigReactors", technicWiki); - registerModWiki("BuildCraft|Core", buildcraftWiki); - registerModWiki("BuildCraft|Builders", buildcraftWiki); - registerModWiki("BuildCraft|Energy", buildcraftWiki); - registerModWiki("BuildCraft|Factory", buildcraftWiki); - registerModWiki("BuildCraft|Silicon", buildcraftWiki); - registerModWiki("BuildCraft|Transport", buildcraftWiki); - registerModWiki("ArsMagica2", new SimpleWikiProvider("ArsMagica2 Wiki", "http://wiki.arsmagicamod.com/wiki/%s")); - registerModWiki("PneumaticCraft", new SimpleWikiProvider("PneumaticCraft Wiki", "http://www.minemaarten.com/wikis/pneumaticcraft-wiki/pneumaticcraft-wiki-%s")); - registerModWiki("StevesCarts2", new SimpleWikiProvider("Steve's Carts Wiki", "http://stevescarts2.wikispaces.com/%s")); - registerModWiki("GanysSurface", new SimpleWikiProvider("Gany's Surface Wiki", "http://ganys-surface.wikia.com/wiki/%s")); - registerModWiki("GanysNether", new SimpleWikiProvider("Gany's Nether Wiki", "http://ganys-nether.wikia.com/wiki/%s")); - registerModWiki("GanysEnd", new SimpleWikiProvider("Gany's End Wiki", "http://ganys-end.wikia.com/wiki/%s")); - - registerPaintableBlock(Blocks.stained_glass); - registerPaintableBlock(Blocks.stained_glass_pane); - registerPaintableBlock(Blocks.stained_hardened_clay); - registerPaintableBlock(Blocks.wool); - registerPaintableBlock(Blocks.carpet); - - registerDisposableBlock("dirt"); // Vanilla - registerDisposableBlock("sand"); // Vanilla - registerDisposableBlock("gravel"); // Vanilla - registerDisposableBlock("cobblestone"); // Vanilla - registerDisposableBlock("netherrack"); // Vanilla - registerSemiDisposableBlock("stoneAndesite"); // Botania - registerSemiDisposableBlock("stoneBasalt"); // Botania - registerSemiDisposableBlock("stoneDiorite"); // Botania - registerSemiDisposableBlock("stoneGranite"); // Botania - } - - /** - * The internal method handler in use. - * DO NOT OVERWRITE THIS OR YOU'RE GOING TO FEEL MY WRATH WHEN I UPDATE THE API. - * The fact I have to write that means some moron already tried, don't be that moron. - * @see IInternalMethodHandler - */ - public static IInternalMethodHandler internalHandler = new DummyMethodHandler(); - - /** - * Registers a new Knowledge Type. - * @param id The ID for this knowledge type. - * @param color The color to display this knowledge type as. - */ - public static KnowledgeType registerKnowledgeType(String id, EnumChatFormatting color, boolean autoUnlock) { - KnowledgeType type = new KnowledgeType(id, color, autoUnlock); - knowledgeTypes.put(id, type); - return type; - } - - /** - * Registers a Brew and returns it. - */ - public static Brew registerBrew(Brew brew) { - brewMap.put(brew.getKey(), brew); - return brew; - } - - /** - * Gets a brew from the key passed in, returns the fallback if - * it's not in the map. - */ - public static Brew getBrewFromKey(String key) { - if(brewMap.containsKey(key)) - return brewMap.get(key); - return fallbackBrew; - } - - /* - * Registers a Block as disposable using its Ore Dictionary Name. - */ - public static void registerDisposableBlock(String oreDictName) { - disposableBlocks.add(oreDictName); - } - - /* - * Registers a Block as semi disposable using its Ore Dictionary Name. - * This means it will not be trashed when sneaking. - */ - public static void registerSemiDisposableBlock(String oreDictName) { - semiDisposableBlocks.add(oreDictName); - } - - /** - * Registers a paintableBlock and returns it. - */ - public static Block registerPaintableBlock(Block paintable){ - paintableBlocks.add(paintable); - return paintable; - } - - /* - * Blacklists an Entity from being affected by the Rod of the Shaded Mesa. - * Pass in the class for the Entity, e.g. EntityCow.class - */ - public static void blacklistEntityFromGravityRod(Class entity) { - gravityRodBlacklist.add(entity); - } - - /* - * Checks if the provided Entity is contained in the Blacklist. - * Pass in the class for the Entity, e.g. entity.getClass() - */ - public static boolean isEntityBlacklistedFromGravityRod(Class entity) { - return gravityRodBlacklist.contains(entity); - } - - /** - * Blacklists an item from being pulled by the Ring of Magnetization. - * Short.MAX_VALUE can be used as the stack's damage for a wildcard. - */ - public static void blacklistItemFromMagnet(ItemStack stack) { - String key = getMagnetKey(stack); - magnetBlacklist.add(key); - } - - /** - * Blacklists a block from having items on top of it being pulled by the Ring of Magnetization. - * Short.MAX_VALUE can be used as meta for a wildcard. - */ - public static void blacklistBlockFromMagnet(Block block, int meta) { - String key = getMagnetKey(block, meta); - magnetBlacklist.add(key); - } - - public static boolean isItemBlacklistedFromMagnet(ItemStack stack) { - return isItemBlacklistedFromMagnet(stack, 0); - } - - public static boolean isItemBlacklistedFromMagnet(ItemStack stack, int recursion) { - if(recursion > 5) - return false; - - if(stack.getItemDamage() != Short.MAX_VALUE) { - ItemStack copy = new ItemStack(stack.getItem(), 0, Short.MAX_VALUE); - boolean general = isItemBlacklistedFromMagnet(copy, recursion + 1); - if(general) - return true; - } - - String key = getMagnetKey(stack); - return magnetBlacklist.contains(key); - } - - public static boolean isBlockBlacklistedFromMagnet(Block block, int meta) { - return isBlockBlacklistedFromMagnet(block, meta, 0); - } - - public static boolean isBlockBlacklistedFromMagnet(Block block, int meta, int recursion) { - if(recursion >= 5) - return false; - - if(meta != Short.MAX_VALUE) { - boolean general = isBlockBlacklistedFromMagnet(block, Short.MAX_VALUE, recursion + 1); - if(general) - return true; - } - - String key = getMagnetKey(block, meta); - return magnetBlacklist.contains(key); - } - - /** - * Registers a Petal Recipe. - * @param output The ItemStack to craft. - * @param inputs The objects for crafting. Can be ItemStack, MappableStackWrapper - * or String (case for Ore Dictionary). The array can't be larger than 16. - * @return The recipe created. - */ - public static RecipePetals registerPetalRecipe(ItemStack output, Object... inputs) { - RecipePetals recipe = new RecipePetals(output, inputs); - petalRecipes.add(recipe); - return recipe; - } - - /** - * Registers a Pure Daisy Recipe. - * @param input The block that works as an input for the recipe. Can be a Block or an oredict String. - * @param output The block to be placed upon recipe completion. - * @param outputMeta The metadata to be placed upon recipe completion. - * @return The recipe created. - */ - public static RecipePureDaisy registerPureDaisyRecipe(Object input, Block output, int outputMeta) { - RecipePureDaisy recipe = new RecipePureDaisy(input, output, outputMeta); - pureDaisyRecipes.add(recipe); - return recipe; - } - - /** - * Registers a Rune Altar Recipe. - * @param output The ItemStack to craft. - * @param mana The amount of mana required. Don't go over 100000! - * @param inputs The objects for crafting. Can be ItemStack, MappableStackWrapper - * or String (case for Ore Dictionary). The array can't be larger than 16. - * @return The recipe created. - */ - public static RecipeRuneAltar registerRuneAltarRecipe(ItemStack output, int mana, Object... inputs) { - RecipeRuneAltar recipe = new RecipeRuneAltar(output, mana, inputs); - runeAltarRecipes.add(recipe); - return recipe; - } - - /** - * Registers a Mana Infusion Recipe (throw an item in a mana pool) - * @param output The ItemStack to craft - * @param input The input item, be it an ItemStack or an ore dictionary entry String. - * @param mana The amount of mana required. Don't go over 100000! - * @return The recipe created. - */ - public static RecipeManaInfusion registerManaInfusionRecipe(ItemStack output, Object input, int mana) { - RecipeManaInfusion recipe = new RecipeManaInfusion(output, input, mana); - manaInfusionRecipes.add(recipe); - return recipe; - } - - /** - * Register a Mana Infusion Recipe and flags it as an Alchemy recipe (requires an - * Alchemy Catalyst below the pool). - * @see BotaniaAPI#registerManaInfusionRecipe - */ - public static RecipeManaInfusion registerManaAlchemyRecipe(ItemStack output, Object input, int mana) { - RecipeManaInfusion recipe = new RecipeManaInfusion(output, input, mana); - recipe.setAlchemy(true); - manaInfusionRecipes.add(0, recipe); - return recipe; - } - - /** - * Register a Mana Infusion Recipe and flags it as an Conjuration recipe (requires a - * Conjuration Catalyst below the pool). - * @see BotaniaAPI#registerManaInfusionRecipe - */ - public static RecipeManaInfusion registerManaConjurationRecipe(ItemStack output, Object input, int mana) { - RecipeManaInfusion recipe = new RecipeManaInfusion(output, input, mana); - recipe.setConjuration(true); - manaInfusionRecipes.add(0, recipe); - return recipe; - } - - /** - * Registers a Elven Trade recipe (throw an item in an Alfheim Portal). - * @param output The ItemStack to return. - * @param inputs The items required, can be ItemStack or ore dictionary entry string. - * @return The recipe created. - */ - public static RecipeElvenTrade registerElvenTradeRecipe(ItemStack output, Object... inputs) { - RecipeElvenTrade recipe = new RecipeElvenTrade(output, inputs); - elvenTradeRecipes.add(recipe); - return recipe; - } - - /** - * Registers a Brew Recipe (for the Botanical Brewery). - * @param brew The brew in to be set in this recipe. - * @inputs The items used in the recipe, no more than 6. - */ - public static RecipeBrew registerBrewRecipe(Brew brew, Object... inputs) { - RecipeBrew recipe = new RecipeBrew(brew, inputs); - brewRecipes.add(recipe); - return recipe; - } - - /** - * Registers a SubTileEntity, a new special flower. Look in the subtile package of the API. - * If you call this after PostInit you're a failiure and we are very disappointed in you. - */ - public static void registerSubTile(String key, Class subtileClass) { - subTiles.put(key, subtileClass); - subTileMods.put(key, Loader.instance().activeModContainer().getModId()); - } - - /** - * Register a SubTileEntity and makes it a mini flower. Also adds the recipe and returns it. - * @see BotaniaAPI#registerSubTile - */ - public static RecipeManaInfusion registerMiniSubTile(String key, Class subtileClass, String original) { - registerSubTile(key, subtileClass); - miniFlowers.put(original, key); - - RecipeMiniFlower recipe = new RecipeMiniFlower(key, original, 2500); - manaInfusionRecipes.add(recipe); - miniFlowerRecipes.add(recipe); - return recipe; - } - - /** - * Registers a SubTileEntity's signature. - * @see SubTileSignature - */ - public static void registerSubTileSignature(Class subtileClass, SubTileSignature signature) { - subTileSignatures.put(subtileClass, signature); - } - - /** - * Gets the singleton signature for a SubTileEntity class. Registers a fallback if one wasn't registered - * before the call. - */ - public static SubTileSignature getSignatureForClass(Class subtileClass) { - if(!subTileSignatures.containsKey(subtileClass)) - registerSubTileSignature(subtileClass, new BasicSignature(subTiles.inverse().get(subtileClass))); - - return subTileSignatures.get(subtileClass); - } - - /** - * Gets the singleton signature for a SubTileEntity's name. Registers a fallback if one wasn't registered - * before the call. - */ - public static SubTileSignature getSignatureForName(String name) { - Class subtileClass = subTiles.get(name); - return getSignatureForClass(subtileClass); - } - - /** - * Adds the key for a SubTileEntity into the creative menu. This goes into the - * subtilesForCreativeMenu Set. This does not need to be called for mini flowers, - * those will just use the mini flower map to add themselves next to the source. - */ - public static void addSubTileToCreativeMenu(String key) { - subtilesForCreativeMenu.add(key); - } - - /** - * Adds a category to the list of registered categories to appear in the Lexicon. - */ - public static void addCategory(LexiconCategory category) { - categories.add(category); - } - - /** - * Gets all registered categories. - */ - public static List getAllCategories() { - return categories; - } - - /** - * Gets all registered entries. - */ - public static List getAllEntries() { - return allEntries; - } - - /** - * Registers a Lexicon Entry and adds it to the category passed in. - */ - public static void addEntry(LexiconEntry entry, LexiconCategory category) { - allEntries.add(entry); - category.entries.add(entry); - } - - /** - * Maps an ore (ore dictionary key) to it's weight on the world generation. This - * is used for the Orechid flower. Check the static block in the BotaniaAPI class - * to get the weights for the vanilla blocks.
- * Alternatively get the values with the OreDetector mod:
- * https://gist.github.com/Vazkii/9493322 - */ - public static void addOreWeight(String ore, int weight) { - oreWeights.put(ore, weight); - } - - /** - * Maps an ore (ore dictionary key) to it's weight on the nether world generation. This - * is used for the Orechid Ignem flower. Check the static block in the BotaniaAPI class - * to get the weights for the vanilla blocks.
- * Alternatively get the values with the OreDetector mod:
- * https://gist.github.com/Vazkii/9493322 - */ - public static void addOreWeightNether(String ore, int weight) { - if(ore.contains("Nether") && OreDictionary.getOres(ore.replace("Nether", "")).size() == 0) - return; - - oreWeightsNether.put(ore, weight); - } - - public static int getOreWeight(String ore) { - return oreWeights.get(ore); - } - - public static int getOreWeightNether(String ore) { - return oreWeightsNether.get(ore); - } - - /** - * Allows an item to be counted as a seed. Any item in this list can be - * dispensed by a dispenser, the block is the block to be placed. - */ - public static void addSeed(Item item, Block block) { - seeds.put(item, block); - } - - /** - * Blacklists an item from the Loonium drop table. - */ - public static void blackListItemFromLoonium(Item item) { - looniumBlacklist.add(item); - } - - /** - * Gets the last recipe to have been added to the recipe list. - */ - public static IRecipe getLatestAddedRecipe() { - List list = CraftingManager.getInstance().getRecipeList(); - return list.get(list.size() - 1); - } - - /** - * Gets the last x recipes added to the recipe list. - */ - public static List getLatestAddedRecipes(int x) { - List list = CraftingManager.getInstance().getRecipeList(); - List newList = new ArrayList(); - for(int i = x - 1; i >= 0; i--) - newList.add(list.get(list.size() - 1 - i)); - - return newList; - } - - /** - * Registers a Wiki provider for a mod so it uses that instead of the fallback - * FTB wiki. Make sure to call this on PostInit only! - */ - public static void registerModWiki(String mod, IWikiProvider provider) { - WikiHooks.registerModWiki(mod, provider); - } - - public static Class getSubTileMapping(String key) { - if(!subTiles.containsKey(key)) - key = ""; - - return subTiles.get(key); - } - - public static String getSubTileStringMapping(Class clazz) { - return subTiles.inverse().get(clazz); - } - - public static Set getAllSubTiles() { - return subTiles.keySet(); - } - - private static String getMagnetKey(ItemStack stack) { - if(stack == null) - return ""; - - return "i_" + stack.getItem().getUnlocalizedName() + "@" + stack.getItemDamage(); - } - - private static String getMagnetKey(Block block, int meta) { - return "bm_" + block.getUnlocalizedName() + "@" + meta; - } - + private static List categories = new ArrayList(); + private static List allEntries = new ArrayList(); + + public static Map knowledgeTypes = new HashMap(); + + public static Map brewMap = new LinkedHashMap(); + + public static List disposableBlocks = new ArrayList(); + public static List semiDisposableBlocks = new ArrayList(); + + public static List petalRecipes = new ArrayList(); + public static List pureDaisyRecipes = new ArrayList(); + public static List manaInfusionRecipes = new ArrayList(); + public static List runeAltarRecipes = new ArrayList(); + public static List elvenTradeRecipes = new ArrayList(); + public static List brewRecipes = new ArrayList(); + public static List miniFlowerRecipes = new ArrayList(); + + private static BiMap> subTiles = + HashBiMap.>create(); + private static Map, SubTileSignature> subTileSignatures = + new HashMap, SubTileSignature>(); + public static Set subtilesForCreativeMenu = new LinkedHashSet(); + public static Map subTileMods = new HashMap(); + public static BiMap miniFlowers = HashBiMap.create(); + + public static Map oreWeights = new HashMap(); + public static Map oreWeightsNether = new HashMap(); + public static Map seeds = new HashMap(); + public static Set looniumBlacklist = new LinkedHashSet(); + public static Set paintableBlocks = new LinkedHashSet(); + public static Set magnetBlacklist = new LinkedHashSet(); + public static Set> gravityRodBlacklist = new LinkedHashSet>(); + + public static ArmorMaterial manasteelArmorMaterial = + EnumHelper.addArmorMaterial("MANASTEEL", 16, new int[] {2, 6, 5, 2}, 18); + public static ToolMaterial manasteelToolMaterial = EnumHelper.addToolMaterial("MANASTEEL", 3, 300, 6.2F, 2F, 20); + + public static ArmorMaterial elementiumArmorMaterial = + EnumHelper.addArmorMaterial("B_ELEMENTIUM", 18, new int[] {2, 6, 5, 2}, 18); + public static ToolMaterial elementiumToolMaterial = + EnumHelper.addToolMaterial("B_ELEMENTIUM", 3, 720, 6.2F, 2F, 20); + + public static ArmorMaterial terrasteelArmorMaterial = + EnumHelper.addArmorMaterial("TERRASTEEL", 34, new int[] {3, 8, 6, 3}, 26); + public static ToolMaterial terrasteelToolMaterial = EnumHelper.addToolMaterial("TERRASTEEL", 4, 2300, 9F, 3F, 26); + + public static ArmorMaterial manaweaveArmorMaterial = + EnumHelper.addArmorMaterial("MANAWEAVE", 5, new int[] {1, 2, 2, 1}, 18); + + public static EnumRarity rarityRelic = EnumHelper.addRarity("RELIC", EnumChatFormatting.GOLD, "Relic"); + + public static KnowledgeType basicKnowledge; + public static KnowledgeType elvenKnowledge; + + // This is here for completeness sake, but you shouldn't use it + public static KnowledgeType relicKnowledge; + + // All of these categories are initialized during botania's PreInit stage. + public static LexiconCategory categoryBasics; + public static LexiconCategory categoryMana; + public static LexiconCategory categoryFunctionalFlowers; + public static LexiconCategory categoryGenerationFlowers; + public static LexiconCategory categoryDevices; + public static LexiconCategory categoryTools; + public static LexiconCategory categoryBaubles; + public static LexiconCategory categoryEnder; + public static LexiconCategory categoryAlfhomancy; + public static LexiconCategory categoryMisc; + + public static Brew fallbackBrew = new Brew("fallback", "botania.brew.fallback", 0, 0); + + static { + registerSubTile("", DummySubTile.class); + + basicKnowledge = registerKnowledgeType("minecraft", EnumChatFormatting.RESET, true); + elvenKnowledge = registerKnowledgeType("alfheim", EnumChatFormatting.DARK_GREEN, false); + relicKnowledge = registerKnowledgeType("relic", EnumChatFormatting.DARK_PURPLE, false); + + addOreWeight("oreAluminum", 3940); // Tinkers' Construct + addOreWeight("oreAmber", 2075); // Thaumcraft + addOreWeight("oreApatite", 1595); // Forestry + addOreWeight("oreBlueTopaz", 3195); // Ars Magica + addOreWeight("oreCertusQuartz", 3975); // Applied Energistics + addOreWeight("oreChimerite", 3970); // Ars Magica + addOreWeight("oreCinnabar", 2585); // Thaumcraft + addOreWeight("oreCoal", 46525); // Vanilla + addOreWeight("oreCopper", 8325); // IC2, Thermal Expansion, Tinkers' Construct, etc. + addOreWeight("oreDark", 1350); // EvilCraft + addOreWeight("oreDarkIron", 1700); // Factorization (older versions) + addOreWeight("oreFzDarkIron", 1700); // Factorization (newer versions) + addOreWeight("oreDiamond", 1265); // Vanilla + addOreWeight("oreEmerald", 780); // Vanilla + addOreWeight("oreGalena", 1000); // Factorization + addOreWeight("oreGold", 2970); // Vanilla + addOreWeight("oreInfusedAir", 925); // Thaumcraft + addOreWeight("oreInfusedEarth", 925); // Thaumcraft + addOreWeight("oreInfusedEntropy", 925); // Thaumcraft + addOreWeight("oreInfusedFire", 925); // Thaumcraft + addOreWeight("oreInfusedOrder", 925); // Thaumcraft + addOreWeight("oreInfusedWater", 925); // Thaumcraft + addOreWeight("oreIron", 20665); // Vanilla + addOreWeight("oreLapis", 1285); // Vanilla + addOreWeight("oreLead", 7985); // IC2, Thermal Expansion, Factorization, etc. + addOreWeight("oreMCropsEssence", 3085); // Magical Crops + addOreWeight("oreMithril", 8); // Thermal Expansion + addOreWeight("oreNickel", 2275); // Thermal Expansion + addOreWeight("oreOlivine", 1100); // Project RED + addOreWeight("orePlatinum", 365); // Thermal Expansion + addOreWeight("oreRedstone", 6885); // Vanilla + addOreWeight("oreRuby", 1100); // Project RED + addOreWeight("oreSapphire", 1100); // Project RED + addOreWeight("oreSilver", 6300); // Thermal Expansion, Factorization, etc. + addOreWeight("oreSulfur", 1105); // Railcraft + addOreWeight("oreTin", 9450); // IC2, Thermal Expansion, etc. + addOreWeight("oreUranium", 1337); // IC2 + addOreWeight("oreVinteum", 5925); // Ars Magica + addOreWeight("oreYellorite", 3520); // Big Reactors + addOreWeight("oreZinc", 6485); // Flaxbeard's Steam Power + addOreWeight("oreMythril", 6485); // Simple Ores2 + addOreWeight("oreAdamantium", 2275); // Simple Ores2 + addOreWeight("oreTungsten", 3520); // Simple Tungsten + + addOreWeightNether("oreQuartz", 19600); // Vanilla + addOreWeightNether("oreCobalt", 500); // Tinker's Construct + addOreWeightNether("oreArdite", 500); // Tinker's Construct + addOreWeightNether("oreFirestone", 5); // Railcraft + addOreWeightNether("oreNetherCoal", 17000); // Nether Ores + addOreWeightNether("oreNetherCopper", 4700); // Nether Ores + addOreWeightNether("oreNetherDiamond", 175); // Nether Ores + addOreWeightNether("oreNetherEssence", 2460); // Magical Crops + addOreWeightNether("oreNetherGold", 3635); // Nether Ores + addOreWeightNether("oreNetherIron", 5790); // Nether Ores + addOreWeightNether("oreNetherLapis", 3250); // Nether Ores + addOreWeightNether("oreNetherLead", 2790); // Nether Ores + addOreWeightNether("oreNetherNickel", 1790); // Nether Ores + addOreWeightNether("oreNetherPlatinum", 170); // Nether Ores + addOreWeightNether("oreNetherRedstone", 5600); // Nether Ores + addOreWeightNether("oreNetherSilver", 1550); // Nether Ores + addOreWeightNether("oreNetherSteel", 1690); // Nether Ores + addOreWeightNether("oreNetherTin", 3750); // Nether Ores + addOreWeightNether("oreFyrite", 1000); // Netherrocks + addOreWeightNether("oreAshstone", 1000); // Netherrocks + addOreWeightNether("oreDragonstone", 175); // Netherrocks + addOreWeightNether("oreArgonite", 1000); // Netherrocks + addOreWeightNether("oreOnyx", 500); // SimpleOres 2 + addOreWeightNether("oreHaditeCoal", 500); // Hadite + + addSeed(Items.wheat_seeds, Blocks.wheat); + addSeed(Items.potato, Blocks.potatoes); + addSeed(Items.carrot, Blocks.carrots); + addSeed(Items.nether_wart, Blocks.nether_wart); + addSeed(Items.pumpkin_seeds, Blocks.pumpkin_stem); + addSeed(Items.melon_seeds, Blocks.melon_stem); + + registerModWiki("Minecraft", new SimpleWikiProvider("Minecraft Wiki", "http://minecraft.gamepedia.com/%s")); + + IWikiProvider technicWiki = new SimpleWikiProvider("Technic Wiki", "http://wiki.technicpack.net/%s"); + IWikiProvider mekanismWiki = new SimpleWikiProvider("Mekanism Wiki", "http://wiki.aidancbrady.com/wiki/%s"); + IWikiProvider buildcraftWiki = + new SimpleWikiProvider("BuildCraft Wiki", "http://www.mod-buildcraft.com/wiki/doku.php?id=%s"); + + registerModWiki("Mekanism", mekanismWiki); + registerModWiki("MekanismGenerators", mekanismWiki); + registerModWiki("MekanismTools", mekanismWiki); + registerModWiki("EnderIO", new SimpleWikiProvider("EnderIO Wiki", "http://wiki.enderio.com/%s")); + registerModWiki("TropiCraft", new SimpleWikiProvider("Tropicraft Wiki", "http://wiki.tropicraft.net/wiki/%s")); + registerModWiki( + "RandomThings", + new SimpleWikiProvider("Random Things Wiki", "http://randomthingsminecraftmod.wikispaces.com/%s")); + registerModWiki( + "Witchery", + new SimpleWikiProvider("Witchery Wiki", "https://sites.google.com/site/witcherymod/%s", "-", true)); + registerModWiki("AppliedEnergistics2", new SimpleWikiProvider("AE2 Wiki", "http://ae-mod.info/%s")); + registerModWiki("BigReactors", technicWiki); + registerModWiki("BuildCraft|Core", buildcraftWiki); + registerModWiki("BuildCraft|Builders", buildcraftWiki); + registerModWiki("BuildCraft|Energy", buildcraftWiki); + registerModWiki("BuildCraft|Factory", buildcraftWiki); + registerModWiki("BuildCraft|Silicon", buildcraftWiki); + registerModWiki("BuildCraft|Transport", buildcraftWiki); + registerModWiki( + "ArsMagica2", new SimpleWikiProvider("ArsMagica2 Wiki", "http://wiki.arsmagicamod.com/wiki/%s")); + registerModWiki( + "PneumaticCraft", + new SimpleWikiProvider( + "PneumaticCraft Wiki", + "http://www.minemaarten.com/wikis/pneumaticcraft-wiki/pneumaticcraft-wiki-%s")); + registerModWiki( + "StevesCarts2", new SimpleWikiProvider("Steve's Carts Wiki", "http://stevescarts2.wikispaces.com/%s")); + registerModWiki( + "GanysSurface", + new SimpleWikiProvider("Gany's Surface Wiki", "http://ganys-surface.wikia.com/wiki/%s")); + registerModWiki( + "GanysNether", new SimpleWikiProvider("Gany's Nether Wiki", "http://ganys-nether.wikia.com/wiki/%s")); + registerModWiki("GanysEnd", new SimpleWikiProvider("Gany's End Wiki", "http://ganys-end.wikia.com/wiki/%s")); + + registerPaintableBlock(Blocks.stained_glass); + registerPaintableBlock(Blocks.stained_glass_pane); + registerPaintableBlock(Blocks.stained_hardened_clay); + registerPaintableBlock(Blocks.wool); + registerPaintableBlock(Blocks.carpet); + + registerDisposableBlock("dirt"); // Vanilla + registerDisposableBlock("sand"); // Vanilla + registerDisposableBlock("gravel"); // Vanilla + registerDisposableBlock("cobblestone"); // Vanilla + registerDisposableBlock("netherrack"); // Vanilla + registerSemiDisposableBlock("stoneAndesite"); // Botania + registerSemiDisposableBlock("stoneBasalt"); // Botania + registerSemiDisposableBlock("stoneDiorite"); // Botania + registerSemiDisposableBlock("stoneGranite"); // Botania + } + + /** + * The internal method handler in use. + * DO NOT OVERWRITE THIS OR YOU'RE GOING TO FEEL MY WRATH WHEN I UPDATE THE API. + * The fact I have to write that means some moron already tried, don't be that moron. + * @see IInternalMethodHandler + */ + public static IInternalMethodHandler internalHandler = new DummyMethodHandler(); + + /** + * Registers a new Knowledge Type. + * @param id The ID for this knowledge type. + * @param color The color to display this knowledge type as. + */ + public static KnowledgeType registerKnowledgeType(String id, EnumChatFormatting color, boolean autoUnlock) { + KnowledgeType type = new KnowledgeType(id, color, autoUnlock); + knowledgeTypes.put(id, type); + return type; + } + + /** + * Registers a Brew and returns it. + */ + public static Brew registerBrew(Brew brew) { + brewMap.put(brew.getKey(), brew); + return brew; + } + + /** + * Gets a brew from the key passed in, returns the fallback if + * it's not in the map. + */ + public static Brew getBrewFromKey(String key) { + if (brewMap.containsKey(key)) return brewMap.get(key); + return fallbackBrew; + } + + /* + * Registers a Block as disposable using its Ore Dictionary Name. + */ + public static void registerDisposableBlock(String oreDictName) { + disposableBlocks.add(oreDictName); + } + + /* + * Registers a Block as semi disposable using its Ore Dictionary Name. + * This means it will not be trashed when sneaking. + */ + public static void registerSemiDisposableBlock(String oreDictName) { + semiDisposableBlocks.add(oreDictName); + } + + /** + * Registers a paintableBlock and returns it. + */ + public static Block registerPaintableBlock(Block paintable) { + paintableBlocks.add(paintable); + return paintable; + } + + /* + * Blacklists an Entity from being affected by the Rod of the Shaded Mesa. + * Pass in the class for the Entity, e.g. EntityCow.class + */ + public static void blacklistEntityFromGravityRod(Class entity) { + gravityRodBlacklist.add(entity); + } + + /* + * Checks if the provided Entity is contained in the Blacklist. + * Pass in the class for the Entity, e.g. entity.getClass() + */ + public static boolean isEntityBlacklistedFromGravityRod(Class entity) { + return gravityRodBlacklist.contains(entity); + } + + /** + * Blacklists an item from being pulled by the Ring of Magnetization. + * Short.MAX_VALUE can be used as the stack's damage for a wildcard. + */ + public static void blacklistItemFromMagnet(ItemStack stack) { + String key = getMagnetKey(stack); + magnetBlacklist.add(key); + } + + /** + * Blacklists a block from having items on top of it being pulled by the Ring of Magnetization. + * Short.MAX_VALUE can be used as meta for a wildcard. + */ + public static void blacklistBlockFromMagnet(Block block, int meta) { + String key = getMagnetKey(block, meta); + magnetBlacklist.add(key); + } + + public static boolean isItemBlacklistedFromMagnet(ItemStack stack) { + return isItemBlacklistedFromMagnet(stack, 0); + } + + public static boolean isItemBlacklistedFromMagnet(ItemStack stack, int recursion) { + if (recursion > 5) return false; + + if (stack.getItemDamage() != Short.MAX_VALUE) { + ItemStack copy = new ItemStack(stack.getItem(), 0, Short.MAX_VALUE); + boolean general = isItemBlacklistedFromMagnet(copy, recursion + 1); + if (general) return true; + } + + String key = getMagnetKey(stack); + return magnetBlacklist.contains(key); + } + + public static boolean isBlockBlacklistedFromMagnet(Block block, int meta) { + return isBlockBlacklistedFromMagnet(block, meta, 0); + } + + public static boolean isBlockBlacklistedFromMagnet(Block block, int meta, int recursion) { + if (recursion >= 5) return false; + + if (meta != Short.MAX_VALUE) { + boolean general = isBlockBlacklistedFromMagnet(block, Short.MAX_VALUE, recursion + 1); + if (general) return true; + } + + String key = getMagnetKey(block, meta); + return magnetBlacklist.contains(key); + } + + /** + * Registers a Petal Recipe. + * @param output The ItemStack to craft. + * @param inputs The objects for crafting. Can be ItemStack, MappableStackWrapper + * or String (case for Ore Dictionary). The array can't be larger than 16. + * @return The recipe created. + */ + public static RecipePetals registerPetalRecipe(ItemStack output, Object... inputs) { + RecipePetals recipe = new RecipePetals(output, inputs); + petalRecipes.add(recipe); + return recipe; + } + + /** + * Registers a Pure Daisy Recipe. + * @param input The block that works as an input for the recipe. Can be a Block or an oredict String. + * @param output The block to be placed upon recipe completion. + * @param outputMeta The metadata to be placed upon recipe completion. + * @return The recipe created. + */ + public static RecipePureDaisy registerPureDaisyRecipe(Object input, Block output, int outputMeta) { + RecipePureDaisy recipe = new RecipePureDaisy(input, output, outputMeta); + pureDaisyRecipes.add(recipe); + return recipe; + } + + /** + * Registers a Rune Altar Recipe. + * @param output The ItemStack to craft. + * @param mana The amount of mana required. Don't go over 100000! + * @param inputs The objects for crafting. Can be ItemStack, MappableStackWrapper + * or String (case for Ore Dictionary). The array can't be larger than 16. + * @return The recipe created. + */ + public static RecipeRuneAltar registerRuneAltarRecipe(ItemStack output, int mana, Object... inputs) { + RecipeRuneAltar recipe = new RecipeRuneAltar(output, mana, inputs); + runeAltarRecipes.add(recipe); + return recipe; + } + + /** + * Registers a Mana Infusion Recipe (throw an item in a mana pool) + * @param output The ItemStack to craft + * @param input The input item, be it an ItemStack or an ore dictionary entry String. + * @param mana The amount of mana required. Don't go over 100000! + * @return The recipe created. + */ + public static RecipeManaInfusion registerManaInfusionRecipe(ItemStack output, Object input, int mana) { + RecipeManaInfusion recipe = new RecipeManaInfusion(output, input, mana); + manaInfusionRecipes.add(recipe); + return recipe; + } + + /** + * Register a Mana Infusion Recipe and flags it as an Alchemy recipe (requires an + * Alchemy Catalyst below the pool). + * @see BotaniaAPI#registerManaInfusionRecipe + */ + public static RecipeManaInfusion registerManaAlchemyRecipe(ItemStack output, Object input, int mana) { + RecipeManaInfusion recipe = new RecipeManaInfusion(output, input, mana); + recipe.setAlchemy(true); + manaInfusionRecipes.add(0, recipe); + return recipe; + } + + /** + * Register a Mana Infusion Recipe and flags it as an Conjuration recipe (requires a + * Conjuration Catalyst below the pool). + * @see BotaniaAPI#registerManaInfusionRecipe + */ + public static RecipeManaInfusion registerManaConjurationRecipe(ItemStack output, Object input, int mana) { + RecipeManaInfusion recipe = new RecipeManaInfusion(output, input, mana); + recipe.setConjuration(true); + manaInfusionRecipes.add(0, recipe); + return recipe; + } + + /** + * Registers a Elven Trade recipe (throw an item in an Alfheim Portal). + * @param output The ItemStack to return. + * @param inputs The items required, can be ItemStack or ore dictionary entry string. + * @return The recipe created. + */ + public static RecipeElvenTrade registerElvenTradeRecipe(ItemStack output, Object... inputs) { + RecipeElvenTrade recipe = new RecipeElvenTrade(output, inputs); + elvenTradeRecipes.add(recipe); + return recipe; + } + + /** + * Registers a Brew Recipe (for the Botanical Brewery). + * @param brew The brew in to be set in this recipe. + * @inputs The items used in the recipe, no more than 6. + */ + public static RecipeBrew registerBrewRecipe(Brew brew, Object... inputs) { + RecipeBrew recipe = new RecipeBrew(brew, inputs); + brewRecipes.add(recipe); + return recipe; + } + + /** + * Registers a SubTileEntity, a new special flower. Look in the subtile package of the API. + * If you call this after PostInit you're a failiure and we are very disappointed in you. + */ + public static void registerSubTile(String key, Class subtileClass) { + subTiles.put(key, subtileClass); + subTileMods.put(key, Loader.instance().activeModContainer().getModId()); + } + + /** + * Register a SubTileEntity and makes it a mini flower. Also adds the recipe and returns it. + * @see BotaniaAPI#registerSubTile + */ + public static RecipeManaInfusion registerMiniSubTile( + String key, Class subtileClass, String original) { + registerSubTile(key, subtileClass); + miniFlowers.put(original, key); + + RecipeMiniFlower recipe = new RecipeMiniFlower(key, original, 2500); + manaInfusionRecipes.add(recipe); + miniFlowerRecipes.add(recipe); + return recipe; + } + + /** + * Registers a SubTileEntity's signature. + * @see SubTileSignature + */ + public static void registerSubTileSignature( + Class subtileClass, SubTileSignature signature) { + subTileSignatures.put(subtileClass, signature); + } + + /** + * Gets the singleton signature for a SubTileEntity class. Registers a fallback if one wasn't registered + * before the call. + */ + public static SubTileSignature getSignatureForClass(Class subtileClass) { + if (!subTileSignatures.containsKey(subtileClass)) + registerSubTileSignature( + subtileClass, new BasicSignature(subTiles.inverse().get(subtileClass))); + + return subTileSignatures.get(subtileClass); + } + + /** + * Gets the singleton signature for a SubTileEntity's name. Registers a fallback if one wasn't registered + * before the call. + */ + public static SubTileSignature getSignatureForName(String name) { + Class subtileClass = subTiles.get(name); + return getSignatureForClass(subtileClass); + } + + /** + * Adds the key for a SubTileEntity into the creative menu. This goes into the + * subtilesForCreativeMenu Set. This does not need to be called for mini flowers, + * those will just use the mini flower map to add themselves next to the source. + */ + public static void addSubTileToCreativeMenu(String key) { + subtilesForCreativeMenu.add(key); + } + + /** + * Adds a category to the list of registered categories to appear in the Lexicon. + */ + public static void addCategory(LexiconCategory category) { + categories.add(category); + } + + /** + * Gets all registered categories. + */ + public static List getAllCategories() { + return categories; + } + + /** + * Gets all registered entries. + */ + public static List getAllEntries() { + return allEntries; + } + + /** + * Registers a Lexicon Entry and adds it to the category passed in. + */ + public static void addEntry(LexiconEntry entry, LexiconCategory category) { + allEntries.add(entry); + category.entries.add(entry); + } + + /** + * Maps an ore (ore dictionary key) to it's weight on the world generation. This + * is used for the Orechid flower. Check the static block in the BotaniaAPI class + * to get the weights for the vanilla blocks.
+ * Alternatively get the values with the OreDetector mod:
+ * https://gist.github.com/Vazkii/9493322 + */ + public static void addOreWeight(String ore, int weight) { + oreWeights.put(ore, weight); + } + + /** + * Maps an ore (ore dictionary key) to it's weight on the nether world generation. This + * is used for the Orechid Ignem flower. Check the static block in the BotaniaAPI class + * to get the weights for the vanilla blocks.
+ * Alternatively get the values with the OreDetector mod:
+ * https://gist.github.com/Vazkii/9493322 + */ + public static void addOreWeightNether(String ore, int weight) { + if (ore.contains("Nether") + && OreDictionary.getOres(ore.replace("Nether", "")).size() == 0) return; + + oreWeightsNether.put(ore, weight); + } + + public static int getOreWeight(String ore) { + return oreWeights.get(ore); + } + + public static int getOreWeightNether(String ore) { + return oreWeightsNether.get(ore); + } + + /** + * Allows an item to be counted as a seed. Any item in this list can be + * dispensed by a dispenser, the block is the block to be placed. + */ + public static void addSeed(Item item, Block block) { + seeds.put(item, block); + } + + /** + * Blacklists an item from the Loonium drop table. + */ + public static void blackListItemFromLoonium(Item item) { + looniumBlacklist.add(item); + } + + /** + * Gets the last recipe to have been added to the recipe list. + */ + public static IRecipe getLatestAddedRecipe() { + List list = CraftingManager.getInstance().getRecipeList(); + return list.get(list.size() - 1); + } + + /** + * Gets the last x recipes added to the recipe list. + */ + public static List getLatestAddedRecipes(int x) { + List list = CraftingManager.getInstance().getRecipeList(); + List newList = new ArrayList(); + for (int i = x - 1; i >= 0; i--) newList.add(list.get(list.size() - 1 - i)); + + return newList; + } + + /** + * Registers a Wiki provider for a mod so it uses that instead of the fallback + * FTB wiki. Make sure to call this on PostInit only! + */ + public static void registerModWiki(String mod, IWikiProvider provider) { + WikiHooks.registerModWiki(mod, provider); + } + + public static Class getSubTileMapping(String key) { + if (!subTiles.containsKey(key)) key = ""; + + return subTiles.get(key); + } + + public static String getSubTileStringMapping(Class clazz) { + return subTiles.inverse().get(clazz); + } + + public static Set getAllSubTiles() { + return subTiles.keySet(); + } + + private static String getMagnetKey(ItemStack stack) { + if (stack == null) return ""; + + return "i_" + stack.getItem().getUnlocalizedName() + "@" + stack.getItemDamage(); + } + + private static String getMagnetKey(Block block, int meta) { + return "bm_" + block.getUnlocalizedName() + "@" + meta; + } } diff --git a/src/main/java/vazkii/botania/api/boss/IBotaniaBoss.java b/src/main/java/vazkii/botania/api/boss/IBotaniaBoss.java index d337e6ae8f..4894feef04 100644 --- a/src/main/java/vazkii/botania/api/boss/IBotaniaBoss.java +++ b/src/main/java/vazkii/botania/api/boss/IBotaniaBoss.java @@ -2,21 +2,20 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Oct 29, 2014, 6:09:48 PM (GMT)] */ package vazkii.botania.api.boss; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; import java.awt.Rectangle; - import net.minecraft.client.gui.ScaledResolution; import net.minecraft.entity.boss.IBossDisplayData; import net.minecraft.util.ResourceLocation; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; /** * An extension of IBossDisplayData. This counts as a botania boss and as a normal @@ -28,35 +27,35 @@ */ public interface IBotaniaBoss extends IBossDisplayData { - /** - * The ResourceLocation to bind for this boss's boss bar. - * You can use BotaniaAPI.internalMethodHandler.getDefaultBossBarTexture() to get - * the one used by botania bosses. - */ - @SideOnly(Side.CLIENT) - public ResourceLocation getBossBarTexture(); + /** + * The ResourceLocation to bind for this boss's boss bar. + * You can use BotaniaAPI.internalMethodHandler.getDefaultBossBarTexture() to get + * the one used by botania bosses. + */ + @SideOnly(Side.CLIENT) + public ResourceLocation getBossBarTexture(); - /** - * A Rectangle instance delimiting the uv, width and height of this boss's - * boss bar texture. This is for the background, not the bar that shows - * the HP. - */ - @SideOnly(Side.CLIENT) - public Rectangle getBossBarTextureRect(); + /** + * A Rectangle instance delimiting the uv, width and height of this boss's + * boss bar texture. This is for the background, not the bar that shows + * the HP. + */ + @SideOnly(Side.CLIENT) + public Rectangle getBossBarTextureRect(); - /** - * A Rectangle instance delimiting the uv, width and height of this boss's - * boss bar HP texture. This is for the foreground that shows how much - * HP the boss has. The width of the rectangle will be multiplied by the - * faction of the boss's current HP by max HP. - */ - @SideOnly(Side.CLIENT) - public Rectangle getBossBarHPTextureRect(); + /** + * A Rectangle instance delimiting the uv, width and height of this boss's + * boss bar HP texture. This is for the foreground that shows how much + * HP the boss has. The width of the rectangle will be multiplied by the + * faction of the boss's current HP by max HP. + */ + @SideOnly(Side.CLIENT) + public Rectangle getBossBarHPTextureRect(); - /** - * A callback for when this boss's boss bar renders, you can do aditional rendering - * here if needed. - */ - @SideOnly(Side.CLIENT) - public void bossBarRenderCallback(ScaledResolution res, int x, int y); + /** + * A callback for when this boss's boss bar renders, you can do aditional rendering + * here if needed. + */ + @SideOnly(Side.CLIENT) + public void bossBarRenderCallback(ScaledResolution res, int x, int y); } diff --git a/src/main/java/vazkii/botania/api/boss/IBotaniaBossWithShader.java b/src/main/java/vazkii/botania/api/boss/IBotaniaBossWithShader.java index 82221d37e6..2281356fd9 100644 --- a/src/main/java/vazkii/botania/api/boss/IBotaniaBossWithShader.java +++ b/src/main/java/vazkii/botania/api/boss/IBotaniaBossWithShader.java @@ -2,17 +2,17 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Oct 29, 2014, 6:13:21 PM (GMT)] */ package vazkii.botania.api.boss; -import vazkii.botania.api.internal.ShaderCallback; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; +import vazkii.botania.api.internal.ShaderCallback; /** * A Botania boss whose HP bar makes use of shaders. Shaders @@ -23,20 +23,19 @@ */ public interface IBotaniaBossWithShader extends IBotaniaBoss { - /** - * The Shader Program to use for this boss bar. Return 0 case - * you don't want a shader to be used. You can use separate shaders - * for the background and foreground. - * @param background True if rendering the background of the boss bar, - * false if rendering the bar itself that shows the HP. - */ - @SideOnly(Side.CLIENT) - public int getBossBarShaderProgram(boolean background); - - /** - * A callback for the shader, used to pass in uniforms. Return null for no callback. - */ - @SideOnly(Side.CLIENT) - public ShaderCallback getBossBarShaderCallback(boolean background, int shader); + /** + * The Shader Program to use for this boss bar. Return 0 case + * you don't want a shader to be used. You can use separate shaders + * for the background and foreground. + * @param background True if rendering the background of the boss bar, + * false if rendering the bar itself that shows the HP. + */ + @SideOnly(Side.CLIENT) + public int getBossBarShaderProgram(boolean background); + /** + * A callback for the shader, used to pass in uniforms. Return null for no callback. + */ + @SideOnly(Side.CLIENT) + public ShaderCallback getBossBarShaderCallback(boolean background, int shader); } diff --git a/src/main/java/vazkii/botania/api/brew/Brew.java b/src/main/java/vazkii/botania/api/brew/Brew.java index d0dd6ba4d5..ba3112bb50 100644 --- a/src/main/java/vazkii/botania/api/brew/Brew.java +++ b/src/main/java/vazkii/botania/api/brew/Brew.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Nov 1, 2014, 6:22:54 PM (GMT)] */ package vazkii.botania.api.brew; @@ -13,7 +13,6 @@ import java.util.ArrayList; import java.util.Arrays; import java.util.List; - import net.minecraft.item.ItemStack; import net.minecraft.potion.PotionEffect; @@ -22,105 +21,104 @@ */ public class Brew { - String key; - String name; - int color; - int cost; - List effects; - boolean canInfuseBloodPendant = true; - boolean canInfuseIncense = true; - - /** - * @param name The unlocalized name of this potion. - * @param color The color for the potion to be rendered in the bottle, note that it will get - * changed a bit when it renders (for more or less brightness) to give a fancy effect. - * @param cost The cost, in Mana for this brew. - * @param effects A list of effects to apply to the player when they drink it. - */ - public Brew(String key, String name, int color, int cost, PotionEffect... effects) { - this.key = key; - this.name = name; - this.color = color; - this.cost = cost; - this.effects = new ArrayList(Arrays.asList(effects)); - } - - /** - * Sets this brew to not be able to be infused onto the Tainted Blood Pendant. - */ - public Brew setNotBloodPendantInfusable() { - canInfuseBloodPendant = false; - return this; - } - - /** - * Sets this brew to not be able to be infused onto Incense Sticks. - */ - public Brew setNotIncenseInfusable() { - canInfuseIncense = false; - return this; - } - - public boolean canInfuseBloodPendant() { - return canInfuseBloodPendant; - } - - public boolean canInfuseIncense() { - return canInfuseIncense; - } - - /** - * Returns the key for this brew, for it to be found in the map in the API. - * This should ALWAYS return the same result. - */ - public String getKey() { - return key; - } - - /** - * Gets the insensitive unlocalized name. This is used for the lexicon. - */ - public String getUnlocalizedName() { - return name; - } - - /** - * Gets the unlocalized name for the ItemStack passed in. - */ - public String getUnlocalizedName(ItemStack stack) { - return getUnlocalizedName(); - } - - /** - * Gets the display color for the ItemStack passed in. Note that for - * the lexicon, this passes in a botania Managlass Vial or an - * Alfglass Flask at all times. - */ - public int getColor(ItemStack stack) { - return color; - } - - /** - * Gets the insensitive unlocalized mana cost. This is used for the lexicon. - */ - public int getManaCost() { - return cost; - } - - /** - * Gets the mana cost for the ItemStack passed in. - */ - public int getManaCost(ItemStack stack) { - return getManaCost(); - } - - /** - * Gets the list of potion effects for the ItemStack passed in. - * Note that for the lexicon, this passes in a botania Managlass - * Vial or an Alfglass Flask at all times. - */ - public List getPotionEffects(ItemStack stack) { - return effects; - } - + String key; + String name; + int color; + int cost; + List effects; + boolean canInfuseBloodPendant = true; + boolean canInfuseIncense = true; + + /** + * @param name The unlocalized name of this potion. + * @param color The color for the potion to be rendered in the bottle, note that it will get + * changed a bit when it renders (for more or less brightness) to give a fancy effect. + * @param cost The cost, in Mana for this brew. + * @param effects A list of effects to apply to the player when they drink it. + */ + public Brew(String key, String name, int color, int cost, PotionEffect... effects) { + this.key = key; + this.name = name; + this.color = color; + this.cost = cost; + this.effects = new ArrayList(Arrays.asList(effects)); + } + + /** + * Sets this brew to not be able to be infused onto the Tainted Blood Pendant. + */ + public Brew setNotBloodPendantInfusable() { + canInfuseBloodPendant = false; + return this; + } + + /** + * Sets this brew to not be able to be infused onto Incense Sticks. + */ + public Brew setNotIncenseInfusable() { + canInfuseIncense = false; + return this; + } + + public boolean canInfuseBloodPendant() { + return canInfuseBloodPendant; + } + + public boolean canInfuseIncense() { + return canInfuseIncense; + } + + /** + * Returns the key for this brew, for it to be found in the map in the API. + * This should ALWAYS return the same result. + */ + public String getKey() { + return key; + } + + /** + * Gets the insensitive unlocalized name. This is used for the lexicon. + */ + public String getUnlocalizedName() { + return name; + } + + /** + * Gets the unlocalized name for the ItemStack passed in. + */ + public String getUnlocalizedName(ItemStack stack) { + return getUnlocalizedName(); + } + + /** + * Gets the display color for the ItemStack passed in. Note that for + * the lexicon, this passes in a botania Managlass Vial or an + * Alfglass Flask at all times. + */ + public int getColor(ItemStack stack) { + return color; + } + + /** + * Gets the insensitive unlocalized mana cost. This is used for the lexicon. + */ + public int getManaCost() { + return cost; + } + + /** + * Gets the mana cost for the ItemStack passed in. + */ + public int getManaCost(ItemStack stack) { + return getManaCost(); + } + + /** + * Gets the list of potion effects for the ItemStack passed in. + * Note that for the lexicon, this passes in a botania Managlass + * Vial or an Alfglass Flask at all times. + */ + public List getPotionEffects(ItemStack stack) { + return effects; + } } diff --git a/src/main/java/vazkii/botania/api/brew/IBrewContainer.java b/src/main/java/vazkii/botania/api/brew/IBrewContainer.java index 0d155ecdb2..163692240a 100644 --- a/src/main/java/vazkii/botania/api/brew/IBrewContainer.java +++ b/src/main/java/vazkii/botania/api/brew/IBrewContainer.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Nov 1, 2014, 6:26:40 PM (GMT)] */ package vazkii.botania.api.brew; @@ -19,17 +19,16 @@ */ public interface IBrewContainer { - /** - * Returs an ItemStack that should be an item that has the brew - * passed in. - */ - public ItemStack getItemForBrew(Brew brew, ItemStack stack); - - /** - * Gets the cost to add this brew onto this container. Return -1 - * to not allow for the brew to be added. Normally you'd - * use brew.getManaCost(stack); - */ - public int getManaCost(Brew brew, ItemStack stack); + /** + * Returs an ItemStack that should be an item that has the brew + * passed in. + */ + public ItemStack getItemForBrew(Brew brew, ItemStack stack); + /** + * Gets the cost to add this brew onto this container. Return -1 + * to not allow for the brew to be added. Normally you'd + * use brew.getManaCost(stack); + */ + public int getManaCost(Brew brew, ItemStack stack); } diff --git a/src/main/java/vazkii/botania/api/brew/IBrewItem.java b/src/main/java/vazkii/botania/api/brew/IBrewItem.java index d51c9fa44b..3d0d0dcef3 100644 --- a/src/main/java/vazkii/botania/api/brew/IBrewItem.java +++ b/src/main/java/vazkii/botania/api/brew/IBrewItem.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Nov 1, 2014, 9:20:33 PM (GMT)] */ package vazkii.botania.api.brew; @@ -19,6 +19,5 @@ */ public interface IBrewItem { - public Brew getBrew(ItemStack brew); - + public Brew getBrew(ItemStack brew); } diff --git a/src/main/java/vazkii/botania/api/corporea/CorporeaHelper.java b/src/main/java/vazkii/botania/api/corporea/CorporeaHelper.java index d4934d7da2..182073c187 100644 --- a/src/main/java/vazkii/botania/api/corporea/CorporeaHelper.java +++ b/src/main/java/vazkii/botania/api/corporea/CorporeaHelper.java @@ -2,13 +2,14 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Feb 14, 2015, 3:28:54 PM (GMT)] */ package vazkii.botania.api.corporea; + import java.util.ArrayList; import java.util.Collections; import java.util.HashMap; @@ -16,7 +17,6 @@ import java.util.Map; import java.util.WeakHashMap; import java.util.regex.Pattern; - import net.minecraft.inventory.IInventory; import net.minecraft.inventory.ISidedInventory; import net.minecraft.item.ItemStack; @@ -29,293 +29,293 @@ public final class CorporeaHelper { - private static final List empty = Collections.unmodifiableList(new ArrayList()); - private static final WeakHashMap, List> cachedNetworks = new WeakHashMap(); - private static final List autoCompleteControllers = new ArrayList(); - - private static final Pattern patternControlCode = Pattern.compile("(?i)\\u00A7[0-9A-FK-OR]"); - - public static final String[] WILDCARD_STRINGS = new String[] { - "...", "~", "+", "?" , "*" - }; - - /** - * How many items were matched in the last request. If java had "out" params like C# this wouldn't be needed :V - */ - public static int lastRequestMatches = 0; - /** - * How many items were extracted in the last request. - */ - public static int lastRequestExtractions = 0; - - /** - * Gets a list of all the inventories on this spark network. This list is cached for use once every tick, - * and if something changes during that tick it'll still have the first result. - */ - public static List getInventoriesOnNetwork(ICorporeaSpark spark) { - ICorporeaSpark master = spark.getMaster(); - if(master == null) - return empty; - List network = master.getConnections(); - - if(cachedNetworks.containsKey(network)) { - List cache = cachedNetworks.get(network); - if(cache != null) - return cache; - } - - List inventories = new ArrayList(); - if(network != null) - for(ICorporeaSpark otherSpark : network) - if(otherSpark != null) { - IInventory inv = otherSpark.getInventory(); - if(inv != null) - inventories.add(inv); - } - - cachedNetworks.put(network, inventories); - return inventories; - } - - /** - * Gets the amount of available items in the network of the type passed in, checking NBT or not. - * The higher level functions that use a List< IInventory > or a Map< IInventory, Integer > should be - * called instead if the context for those exists to avoid having to get the values again. - */ - public static int getCountInNetwork(ItemStack stack, ICorporeaSpark spark, boolean checkNBT) { - List inventories = getInventoriesOnNetwork(spark); - return getCountInNetwork(stack, inventories, checkNBT); - } - - /** - * Gets the amount of available items in the network of the type passed in, checking NBT or not. - * The higher level function that use a Map< IInventory, Integer > should be - * called instead if the context for this exists to avoid having to get the value again. - */ - public static int getCountInNetwork(ItemStack stack, List inventories, boolean checkNBT) { - Map map = getInventoriesWithItemInNetwork(stack, inventories, checkNBT); - return getCountInNetwork(stack, map, checkNBT); - } - - /** - * Gets the amount of available items in the network of the type passed in, checking NBT or not. - */ - public static int getCountInNetwork(ItemStack stack, Map inventories, boolean checkNBT) { - int count = 0; - - for(IInventory inv : inventories.keySet()) - count += inventories.get(inv); - - return count; - } - - /** - * Gets a Map mapping IInventories to the amount of items of the type passed in that exist - * The higher level function that use a List< IInventory > should be - * called instead if the context for this exists to avoid having to get the value again. - */ - public static Map getInventoriesWithItemInNetwork(ItemStack stack, ICorporeaSpark spark, boolean checkNBT) { - List inventories = getInventoriesOnNetwork(spark); - return getInventoriesWithItemInNetwork(stack, inventories, checkNBT); - } - - /** - * Gets a Map mapping IInventories to the amount of items of the type passed in that exist - * The deeper level function that use a List< IInventory > should be - * called instead if the context for this exists to avoid having to get the value again. - */ - public static Map getInventoriesWithItemInNetwork(ItemStack stack,List inventories, boolean checkNBT) { - Map countMap = new HashMap(); - List wrappedInventories = BotaniaAPI.internalHandler.wrapInventory(inventories); - for (IWrappedInventory inv : wrappedInventories) { - CorporeaRequest request = new CorporeaRequest(stack, checkNBT, -1); - inv.countItems(request); - if (request.foundItems > 0) { - countMap.put(inv.getWrappedObject(), request.foundItems); - } - } - - return countMap; - } - - /** - * Bridge for requestItem() using an ItemStack. - */ - public static List requestItem(ItemStack stack, ICorporeaSpark spark, boolean checkNBT, boolean doit) { - return requestItem(stack, stack.stackSize, spark, checkNBT, doit); - } - - /** - * Bridge for requestItem() using a String and an item count. - */ - public static List requestItem(String name, int count, ICorporeaSpark spark, boolean doit) { - return requestItem(name, count, spark, false, doit); - } - - /** - * Requests list of ItemStacks of the type passed in from the network, or tries to, checking NBT or not. - * This will remove the items from the adequate inventories unless the "doit" parameter is false. - * Returns a new list of ItemStacks of the items acquired or an empty list if none was found. - * Case itemCount is -1 it'll find EVERY item it can. - *

- * The "matcher" parameter has to be an ItemStack or a String, if the first it'll check if the - * two stacks are similar using the "checkNBT" parameter, else it'll check if the name of the item - * equals or matches (case a regex is passed in) the matcher string. - *

- * When requesting counting of items, individual stacks may exceed maxStackSize for - * purposes of counting huge amounts. - */ - public static List requestItem(Object matcher, int itemCount, ICorporeaSpark spark, boolean checkNBT, boolean doit) { - List stacks = new ArrayList(); - CorporeaRequestEvent event = new CorporeaRequestEvent(matcher, itemCount, spark, checkNBT, doit); - if(MinecraftForge.EVENT_BUS.post(event)) - return stacks; - - List inventories = getInventoriesOnNetwork(spark); - List inventoriesW = BotaniaAPI.internalHandler.wrapInventory(inventories); - Map interceptors = new HashMap(); - - CorporeaRequest request = new CorporeaRequest(matcher, checkNBT, itemCount); - for(IWrappedInventory inv : inventoriesW) { - ICorporeaSpark invSpark = inv.getSpark(); - - Object originalInventory = inv.getWrappedObject(); - if(originalInventory instanceof ICorporeaInterceptor) { - ICorporeaInterceptor interceptor = (ICorporeaInterceptor) originalInventory; - interceptor.interceptRequest(matcher, itemCount, invSpark, spark, stacks, inventories, doit); - interceptors.put(interceptor, invSpark); - } - - if(doit) { - stacks.addAll(inv.extractItems(request)); - } else { - stacks.addAll(inv.countItems(request)); - } - } - - lastRequestMatches = request.foundItems; - lastRequestExtractions = request.extractedItems; - - for(ICorporeaInterceptor interceptor : interceptors.keySet()) - interceptor.interceptRequestLast(matcher, itemCount, interceptors.get(interceptor), spark, stacks, inventories, doit); - - return stacks; - } - - /** - * Gets the spark attached to the inventory passed case it's a TileEntity. - */ - public static ICorporeaSpark getSparkForInventory(IInventory inv) { - if(!(inv instanceof TileEntity)) - return null; - - TileEntity tile = (TileEntity) inv; - return getSparkForBlock(tile.getWorldObj(), tile.xCoord, tile.yCoord, tile.zCoord); - } - - /** - * Gets the spark attached to the block in the coords passed in. Note that the coords passed - * in are for the block that the spark will be on, not the coords of the spark itself. - */ - public static ICorporeaSpark getSparkForBlock(World world, int x, int y, int z) { - List sparks = world.getEntitiesWithinAABB(ICorporeaSpark.class, AxisAlignedBB.getBoundingBox(x, y + 1, z, x + 1, y + 2, z + 1)); - return sparks.isEmpty() ? null : sparks.get(0); - } - - /** - * Gets if the block in the coords passed in has a spark attached. Note that the coords passed - * in are for the block that the spark will be on, not the coords of the spark itself. - */ - public static boolean doesBlockHaveSpark(World world, int x, int y, int z) { - return getSparkForBlock(world, x, y, z) != null; - } - - /** - * Gets if the slot passed in can be extracted from by a spark. - */ - public static boolean isValidSlot(IInventory inv, int slot) { - return !(inv instanceof ISidedInventory) || arrayHas(((ISidedInventory) inv).getAccessibleSlotsFromSide(ForgeDirection.UP.ordinal()), slot) && ((ISidedInventory) inv).canExtractItem(slot, inv.getStackInSlot(slot), ForgeDirection.UP.ordinal()); - } - - /** - * Gets if two stacks match. - */ - public static boolean stacksMatch(ItemStack stack1, ItemStack stack2, boolean checkNBT) { - return stack1 != null && stack2 != null && stack1.isItemEqual(stack2) && (!checkNBT || ItemStack.areItemStackTagsEqual(stack1, stack2)); - } - - /** - * Gets if the name of a stack matches the string passed in. - */ - public static boolean stacksMatch(ItemStack stack, String s) { - if(stack == null) - return false; - - boolean contains = false; - for(String wc : WILDCARD_STRINGS) { - if(s.endsWith(wc)) { - contains = true; - s = s.substring(0, s.length() - wc.length()); - } - else if(s.startsWith(wc)) { - contains = true; - s = s.substring(wc.length()); - } - - if(contains) - break; - } - - - String name = stripControlCodes(stack.getDisplayName().toLowerCase().trim()); - return equalOrContain(name, s, contains) || equalOrContain(name + "s", s, contains) || equalOrContain(name + "es", s, contains) || name.endsWith("y") && equalOrContain(name.substring(0, name.length() - 1) + "ies", s, contains); - } - - /** - * Clears the cached networks, called once per tick, should not be called outside - * of the botania code. - */ - public static void clearCache() { - cachedNetworks.clear(); - } - - /** - * Helper method to check if an int array contains an int. - */ - public static boolean arrayHas(int[] arr, int val) { - for (int element : arr) - if(element == val) - return true; - - return false; - } - - /** - * Helper method to make stacksMatch() less messy. - */ - public static boolean equalOrContain(String s1, String s2, boolean contain) { - return contain ? s1.contains(s2) : s1.equals(s2); - } - - /** - * Registers a ICorporeaAutoCompleteController - */ - public static void registerAutoCompleteController(ICorporeaAutoCompleteController controller) { - autoCompleteControllers.add(controller); - } - - /** - * Returns if the auto complete helper should run - */ - public static boolean shouldAutoComplete() { - for(ICorporeaAutoCompleteController controller : autoCompleteControllers) - if(controller.shouldAutoComplete()) - return true; - return false; - } - - // Copy from StringUtils - public static String stripControlCodes(String str) { - return patternControlCode.matcher(str).replaceAll(""); - } + private static final List empty = Collections.unmodifiableList(new ArrayList()); + private static final WeakHashMap, List> cachedNetworks = new WeakHashMap(); + private static final List autoCompleteControllers = + new ArrayList(); + + private static final Pattern patternControlCode = Pattern.compile("(?i)\\u00A7[0-9A-FK-OR]"); + + public static final String[] WILDCARD_STRINGS = new String[] {"...", "~", "+", "?", "*"}; + + /** + * How many items were matched in the last request. If java had "out" params like C# this wouldn't be needed :V + */ + public static int lastRequestMatches = 0; + /** + * How many items were extracted in the last request. + */ + public static int lastRequestExtractions = 0; + + /** + * Gets a list of all the inventories on this spark network. This list is cached for use once every tick, + * and if something changes during that tick it'll still have the first result. + */ + public static List getInventoriesOnNetwork(ICorporeaSpark spark) { + ICorporeaSpark master = spark.getMaster(); + if (master == null) return empty; + List network = master.getConnections(); + + if (cachedNetworks.containsKey(network)) { + List cache = cachedNetworks.get(network); + if (cache != null) return cache; + } + + List inventories = new ArrayList(); + if (network != null) + for (ICorporeaSpark otherSpark : network) + if (otherSpark != null) { + IInventory inv = otherSpark.getInventory(); + if (inv != null) inventories.add(inv); + } + + cachedNetworks.put(network, inventories); + return inventories; + } + + /** + * Gets the amount of available items in the network of the type passed in, checking NBT or not. + * The higher level functions that use a List< IInventory > or a Map< IInventory, Integer > should be + * called instead if the context for those exists to avoid having to get the values again. + */ + public static int getCountInNetwork(ItemStack stack, ICorporeaSpark spark, boolean checkNBT) { + List inventories = getInventoriesOnNetwork(spark); + return getCountInNetwork(stack, inventories, checkNBT); + } + + /** + * Gets the amount of available items in the network of the type passed in, checking NBT or not. + * The higher level function that use a Map< IInventory, Integer > should be + * called instead if the context for this exists to avoid having to get the value again. + */ + public static int getCountInNetwork(ItemStack stack, List inventories, boolean checkNBT) { + Map map = getInventoriesWithItemInNetwork(stack, inventories, checkNBT); + return getCountInNetwork(stack, map, checkNBT); + } + + /** + * Gets the amount of available items in the network of the type passed in, checking NBT or not. + */ + public static int getCountInNetwork(ItemStack stack, Map inventories, boolean checkNBT) { + int count = 0; + + for (IInventory inv : inventories.keySet()) count += inventories.get(inv); + + return count; + } + + /** + * Gets a Map mapping IInventories to the amount of items of the type passed in that exist + * The higher level function that use a List< IInventory > should be + * called instead if the context for this exists to avoid having to get the value again. + */ + public static Map getInventoriesWithItemInNetwork( + ItemStack stack, ICorporeaSpark spark, boolean checkNBT) { + List inventories = getInventoriesOnNetwork(spark); + return getInventoriesWithItemInNetwork(stack, inventories, checkNBT); + } + + /** + * Gets a Map mapping IInventories to the amount of items of the type passed in that exist + * The deeper level function that use a List< IInventory > should be + * called instead if the context for this exists to avoid having to get the value again. + */ + public static Map getInventoriesWithItemInNetwork( + ItemStack stack, List inventories, boolean checkNBT) { + Map countMap = new HashMap(); + List wrappedInventories = BotaniaAPI.internalHandler.wrapInventory(inventories); + for (IWrappedInventory inv : wrappedInventories) { + CorporeaRequest request = new CorporeaRequest(stack, checkNBT, -1); + inv.countItems(request); + if (request.foundItems > 0) { + countMap.put(inv.getWrappedObject(), request.foundItems); + } + } + + return countMap; + } + + /** + * Bridge for requestItem() using an ItemStack. + */ + public static List requestItem(ItemStack stack, ICorporeaSpark spark, boolean checkNBT, boolean doit) { + return requestItem(stack, stack.stackSize, spark, checkNBT, doit); + } + + /** + * Bridge for requestItem() using a String and an item count. + */ + public static List requestItem(String name, int count, ICorporeaSpark spark, boolean doit) { + return requestItem(name, count, spark, false, doit); + } + + /** + * Requests list of ItemStacks of the type passed in from the network, or tries to, checking NBT or not. + * This will remove the items from the adequate inventories unless the "doit" parameter is false. + * Returns a new list of ItemStacks of the items acquired or an empty list if none was found. + * Case itemCount is -1 it'll find EVERY item it can. + *

+ * The "matcher" parameter has to be an ItemStack or a String, if the first it'll check if the + * two stacks are similar using the "checkNBT" parameter, else it'll check if the name of the item + * equals or matches (case a regex is passed in) the matcher string. + *

+ * When requesting counting of items, individual stacks may exceed maxStackSize for + * purposes of counting huge amounts. + */ + public static List requestItem( + Object matcher, int itemCount, ICorporeaSpark spark, boolean checkNBT, boolean doit) { + List stacks = new ArrayList(); + CorporeaRequestEvent event = new CorporeaRequestEvent(matcher, itemCount, spark, checkNBT, doit); + if (MinecraftForge.EVENT_BUS.post(event)) return stacks; + + List inventories = getInventoriesOnNetwork(spark); + List inventoriesW = BotaniaAPI.internalHandler.wrapInventory(inventories); + Map interceptors = new HashMap(); + + CorporeaRequest request = new CorporeaRequest(matcher, checkNBT, itemCount); + for (IWrappedInventory inv : inventoriesW) { + ICorporeaSpark invSpark = inv.getSpark(); + + Object originalInventory = inv.getWrappedObject(); + if (originalInventory instanceof ICorporeaInterceptor) { + ICorporeaInterceptor interceptor = (ICorporeaInterceptor) originalInventory; + interceptor.interceptRequest(matcher, itemCount, invSpark, spark, stacks, inventories, doit); + interceptors.put(interceptor, invSpark); + } + + if (doit) { + stacks.addAll(inv.extractItems(request)); + } else { + stacks.addAll(inv.countItems(request)); + } + } + + lastRequestMatches = request.foundItems; + lastRequestExtractions = request.extractedItems; + + for (ICorporeaInterceptor interceptor : interceptors.keySet()) + interceptor.interceptRequestLast( + matcher, itemCount, interceptors.get(interceptor), spark, stacks, inventories, doit); + + return stacks; + } + + /** + * Gets the spark attached to the inventory passed case it's a TileEntity. + */ + public static ICorporeaSpark getSparkForInventory(IInventory inv) { + if (!(inv instanceof TileEntity)) return null; + + TileEntity tile = (TileEntity) inv; + return getSparkForBlock(tile.getWorldObj(), tile.xCoord, tile.yCoord, tile.zCoord); + } + + /** + * Gets the spark attached to the block in the coords passed in. Note that the coords passed + * in are for the block that the spark will be on, not the coords of the spark itself. + */ + public static ICorporeaSpark getSparkForBlock(World world, int x, int y, int z) { + List sparks = world.getEntitiesWithinAABB( + ICorporeaSpark.class, AxisAlignedBB.getBoundingBox(x, y + 1, z, x + 1, y + 2, z + 1)); + return sparks.isEmpty() ? null : sparks.get(0); + } + + /** + * Gets if the block in the coords passed in has a spark attached. Note that the coords passed + * in are for the block that the spark will be on, not the coords of the spark itself. + */ + public static boolean doesBlockHaveSpark(World world, int x, int y, int z) { + return getSparkForBlock(world, x, y, z) != null; + } + + /** + * Gets if the slot passed in can be extracted from by a spark. + */ + public static boolean isValidSlot(IInventory inv, int slot) { + return !(inv instanceof ISidedInventory) + || arrayHas(((ISidedInventory) inv).getAccessibleSlotsFromSide(ForgeDirection.UP.ordinal()), slot) + && ((ISidedInventory) inv) + .canExtractItem(slot, inv.getStackInSlot(slot), ForgeDirection.UP.ordinal()); + } + + /** + * Gets if two stacks match. + */ + public static boolean stacksMatch(ItemStack stack1, ItemStack stack2, boolean checkNBT) { + return stack1 != null + && stack2 != null + && stack1.isItemEqual(stack2) + && (!checkNBT || ItemStack.areItemStackTagsEqual(stack1, stack2)); + } + + /** + * Gets if the name of a stack matches the string passed in. + */ + public static boolean stacksMatch(ItemStack stack, String s) { + if (stack == null) return false; + + boolean contains = false; + for (String wc : WILDCARD_STRINGS) { + if (s.endsWith(wc)) { + contains = true; + s = s.substring(0, s.length() - wc.length()); + } else if (s.startsWith(wc)) { + contains = true; + s = s.substring(wc.length()); + } + + if (contains) break; + } + + String name = stripControlCodes(stack.getDisplayName().toLowerCase().trim()); + return equalOrContain(name, s, contains) + || equalOrContain(name + "s", s, contains) + || equalOrContain(name + "es", s, contains) + || name.endsWith("y") && equalOrContain(name.substring(0, name.length() - 1) + "ies", s, contains); + } + + /** + * Clears the cached networks, called once per tick, should not be called outside + * of the botania code. + */ + public static void clearCache() { + cachedNetworks.clear(); + } + + /** + * Helper method to check if an int array contains an int. + */ + public static boolean arrayHas(int[] arr, int val) { + for (int element : arr) if (element == val) return true; + + return false; + } + + /** + * Helper method to make stacksMatch() less messy. + */ + public static boolean equalOrContain(String s1, String s2, boolean contain) { + return contain ? s1.contains(s2) : s1.equals(s2); + } + + /** + * Registers a ICorporeaAutoCompleteController + */ + public static void registerAutoCompleteController(ICorporeaAutoCompleteController controller) { + autoCompleteControllers.add(controller); + } + + /** + * Returns if the auto complete helper should run + */ + public static boolean shouldAutoComplete() { + for (ICorporeaAutoCompleteController controller : autoCompleteControllers) + if (controller.shouldAutoComplete()) return true; + return false; + } + + // Copy from StringUtils + public static String stripControlCodes(String str) { + return patternControlCode.matcher(str).replaceAll(""); + } } diff --git a/src/main/java/vazkii/botania/api/corporea/CorporeaRequest.java b/src/main/java/vazkii/botania/api/corporea/CorporeaRequest.java index b1156e5847..a6461998a3 100644 --- a/src/main/java/vazkii/botania/api/corporea/CorporeaRequest.java +++ b/src/main/java/vazkii/botania/api/corporea/CorporeaRequest.java @@ -2,25 +2,24 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * */ package vazkii.botania.api.corporea; public class CorporeaRequest { - public Object matcher; - public boolean checkNBT; - public int count; - public int foundItems = 0; - public int extractedItems = 0; - - public CorporeaRequest(Object matcher, boolean checkNBT, int count) { - super(); - this.matcher = matcher; - this.checkNBT = checkNBT; - this.count = count; - } + public Object matcher; + public boolean checkNBT; + public int count; + public int foundItems = 0; + public int extractedItems = 0; + public CorporeaRequest(Object matcher, boolean checkNBT, int count) { + super(); + this.matcher = matcher; + this.checkNBT = checkNBT; + this.count = count; + } } diff --git a/src/main/java/vazkii/botania/api/corporea/CorporeaRequestEvent.java b/src/main/java/vazkii/botania/api/corporea/CorporeaRequestEvent.java index a55ef7b75a..ecf2a27911 100644 --- a/src/main/java/vazkii/botania/api/corporea/CorporeaRequestEvent.java +++ b/src/main/java/vazkii/botania/api/corporea/CorporeaRequestEvent.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Apr 30, 2015, 2:55:57 PM (GMT)] */ package vazkii.botania.api.corporea; @@ -19,22 +19,20 @@ @Cancelable public class CorporeaRequestEvent extends Event { - public final Object request; - public final int count; - public final ICorporeaSpark spark; - public final boolean checkNBT; - /** - * If false then items won't be pulled. - */ - public final boolean realRequest; - - public CorporeaRequestEvent(Object request, int count, ICorporeaSpark spark, boolean nbt, boolean real) { - this.request = request; - this.count = count; - this.spark = spark; - checkNBT = nbt; - realRequest = real; - } - + public final Object request; + public final int count; + public final ICorporeaSpark spark; + public final boolean checkNBT; + /** + * If false then items won't be pulled. + */ + public final boolean realRequest; + public CorporeaRequestEvent(Object request, int count, ICorporeaSpark spark, boolean nbt, boolean real) { + this.request = request; + this.count = count; + this.spark = spark; + checkNBT = nbt; + realRequest = real; + } } diff --git a/src/main/java/vazkii/botania/api/corporea/ICorporeaAutoCompleteController.java b/src/main/java/vazkii/botania/api/corporea/ICorporeaAutoCompleteController.java index fc0a3e9b9a..8f47a9039d 100644 --- a/src/main/java/vazkii/botania/api/corporea/ICorporeaAutoCompleteController.java +++ b/src/main/java/vazkii/botania/api/corporea/ICorporeaAutoCompleteController.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [June 8, 2015, 1:04:05 PM (GMT)] */ package vazkii.botania.api.corporea; @@ -18,10 +18,9 @@ */ public interface ICorporeaAutoCompleteController { - /** - * Return true if auto completion should be enabled. - */ - @SideOnly(Side.CLIENT) - public boolean shouldAutoComplete(); - + /** + * Return true if auto completion should be enabled. + */ + @SideOnly(Side.CLIENT) + public boolean shouldAutoComplete(); } diff --git a/src/main/java/vazkii/botania/api/corporea/ICorporeaInterceptor.java b/src/main/java/vazkii/botania/api/corporea/ICorporeaInterceptor.java index eeea16a79c..3b839fe785 100644 --- a/src/main/java/vazkii/botania/api/corporea/ICorporeaInterceptor.java +++ b/src/main/java/vazkii/botania/api/corporea/ICorporeaInterceptor.java @@ -2,16 +2,15 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Apr 19, 2015, 6:23:31 PM (GMT)] */ package vazkii.botania.api.corporea; import java.util.List; - import net.minecraft.inventory.IInventory; import net.minecraft.item.ItemStack; @@ -21,18 +20,31 @@ */ public interface ICorporeaInterceptor { - /** - * Intercepts a request as it goes. The list of inventories has all the inventories - * at this point, but the list of stacks is not complete. The request parameter can - * be either a String or ItemStack. - */ - public void interceptRequest(Object request, int count, ICorporeaSpark spark, ICorporeaSpark source, List stacks, List inventories, boolean doit); - - /** - * Intercepts a request after all the stacks have been found and processed. Both the - * list of inventories and stacks is complete at this point. The request parameter can - * be either a String or ItemStack. - */ - public void interceptRequestLast(Object request, int count, ICorporeaSpark spark, ICorporeaSpark source, List stacks, List inventories, boolean doit); + /** + * Intercepts a request as it goes. The list of inventories has all the inventories + * at this point, but the list of stacks is not complete. The request parameter can + * be either a String or ItemStack. + */ + public void interceptRequest( + Object request, + int count, + ICorporeaSpark spark, + ICorporeaSpark source, + List stacks, + List inventories, + boolean doit); + /** + * Intercepts a request after all the stacks have been found and processed. Both the + * list of inventories and stacks is complete at this point. The request parameter can + * be either a String or ItemStack. + */ + public void interceptRequestLast( + Object request, + int count, + ICorporeaSpark spark, + ICorporeaSpark source, + List stacks, + List inventories, + boolean doit); } diff --git a/src/main/java/vazkii/botania/api/corporea/ICorporeaRequestor.java b/src/main/java/vazkii/botania/api/corporea/ICorporeaRequestor.java index 66881b5b3d..11be4d26ff 100644 --- a/src/main/java/vazkii/botania/api/corporea/ICorporeaRequestor.java +++ b/src/main/java/vazkii/botania/api/corporea/ICorporeaRequestor.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Sep 28, 2015, 11:25:48 AM (GMT)] */ package vazkii.botania.api.corporea; @@ -17,9 +17,8 @@ */ public interface ICorporeaRequestor { - /* - * Executes the passed in request. - */ - public void doCorporeaRequest(Object request, int count, ICorporeaSpark spark); - + /* + * Executes the passed in request. + */ + public void doCorporeaRequest(Object request, int count, ICorporeaSpark spark); } diff --git a/src/main/java/vazkii/botania/api/corporea/ICorporeaSpark.java b/src/main/java/vazkii/botania/api/corporea/ICorporeaSpark.java index 943e29e726..090363ba29 100644 --- a/src/main/java/vazkii/botania/api/corporea/ICorporeaSpark.java +++ b/src/main/java/vazkii/botania/api/corporea/ICorporeaSpark.java @@ -2,16 +2,15 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Feb 13, 2015, 10:53:05 PM (GMT)] */ package vazkii.botania.api.corporea; import java.util.List; - import net.minecraft.inventory.IInventory; import net.minecraft.item.ItemStack; @@ -21,67 +20,66 @@ */ public interface ICorporeaSpark { - /** - * Called to register the connections for the spark network passed in. Parameters include the master spark, - * which is the one that initiated the chain call, the referrer which passed the call to this instance - * and the List of sparks connected. Normal behavior should be to find any sparks around that are not - * already present in the list of connections and add them to it, passing the function call to them. - *

- * The connections List and the master Spark should be kept in this instance as pointers for use in - * getConnections() and getMaster() and passed in to any subsequent registerConnections calls on sparks - * found nearby. This is only called whenever a new spark is added or removed from and to the network, - * at that point the connection list in the master spark would be cleared out, also clearing out the one - * in this instance, as it should be a pointer. - */ - public void registerConnections(ICorporeaSpark master, ICorporeaSpark referrer, List connections); - - /** - * Gets the inventory this spark is bound to, generally the one right below it. - */ - public IInventory getInventory(); + /** + * Called to register the connections for the spark network passed in. Parameters include the master spark, + * which is the one that initiated the chain call, the referrer which passed the call to this instance + * and the List of sparks connected. Normal behavior should be to find any sparks around that are not + * already present in the list of connections and add them to it, passing the function call to them. + *

+ * The connections List and the master Spark should be kept in this instance as pointers for use in + * getConnections() and getMaster() and passed in to any subsequent registerConnections calls on sparks + * found nearby. This is only called whenever a new spark is added or removed from and to the network, + * at that point the connection list in the master spark would be cleared out, also clearing out the one + * in this instance, as it should be a pointer. + */ + public void registerConnections(ICorporeaSpark master, ICorporeaSpark referrer, List connections); - /** - * Gets the list of sparks this spark is connected to, see registerConnections(). This list - * should also include itself. This list must be checked against on a regular basis to verify - * that the spark is still in the network, if that's not the case, the pointer should be - * eliminated. - */ - public List getConnections(); + /** + * Gets the inventory this spark is bound to, generally the one right below it. + */ + public IInventory getInventory(); - /** - * Gets the list of sparks that this spark added to the list of connections during registerConnections(), this - * is mainly used to create a non messy chain of particles to display the network when a spark is right - * clicked with a wand. - */ - public List getRelatives(); + /** + * Gets the list of sparks this spark is connected to, see registerConnections(). This list + * should also include itself. This list must be checked against on a regular basis to verify + * that the spark is still in the network, if that's not the case, the pointer should be + * eliminated. + */ + public List getConnections(); - /** - * Gets the master spark in this network, see registerConnections(). The value this returns - * should be null and the pointer should be eliminated if the spark is no longer present - * in the network. - */ - public ICorporeaSpark getMaster(); + /** + * Gets the list of sparks that this spark added to the list of connections during registerConnections(), this + * is mainly used to create a non messy chain of particles to display the network when a spark is right + * clicked with a wand. + */ + public List getRelatives(); - /** - * Called when an item is extracted from the inventory this spark is attached to through this - * spark. - */ - public void onItemExtracted(ItemStack stack); + /** + * Gets the master spark in this network, see registerConnections(). The value this returns + * should be null and the pointer should be eliminated if the spark is no longer present + * in the network. + */ + public ICorporeaSpark getMaster(); - /** - * Called when this spark requests items, passes in the result of the request and not the actual requested stack(s). - */ - public void onItemsRequested(List stacks); + /** + * Called when an item is extracted from the inventory this spark is attached to through this + * spark. + */ + public void onItemExtracted(ItemStack stack); - /** - * Gets if this spark is considered a master spark. - */ - public boolean isMaster(); + /** + * Called when this spark requests items, passes in the result of the request and not the actual requested stack(s). + */ + public void onItemsRequested(List stacks); - /** - * Gets the network that this spark is on, or the color it's displaying. Sparks may only connect to others - * of the same network, and on changing network should trigger a re-cache of the previous network. - */ - public int getNetwork(); + /** + * Gets if this spark is considered a master spark. + */ + public boolean isMaster(); + /** + * Gets the network that this spark is on, or the color it's displaying. Sparks may only connect to others + * of the same network, and on changing network should trigger a re-cache of the previous network. + */ + public int getNetwork(); } diff --git a/src/main/java/vazkii/botania/api/corporea/IWrappedInventory.java b/src/main/java/vazkii/botania/api/corporea/IWrappedInventory.java index 0b588f2387..1ea6dc88e3 100644 --- a/src/main/java/vazkii/botania/api/corporea/IWrappedInventory.java +++ b/src/main/java/vazkii/botania/api/corporea/IWrappedInventory.java @@ -2,15 +2,14 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * */ package vazkii.botania.api.corporea; import java.util.List; - import net.minecraft.inventory.IInventory; import net.minecraft.item.ItemStack; @@ -21,37 +20,37 @@ */ public interface IWrappedInventory { - /** - * Break encapsulation and exposes original inventory. - */ - IInventory getWrappedObject(); + /** + * Break encapsulation and exposes original inventory. + */ + IInventory getWrappedObject(); - /** - * Counts items in the inventory matching the request - * - * @param request - * - specifies what should be found - * @return List of ItemStack, individual stacks may exceed maxStackSize for - * purposes of counting huge amounts. To get final count requestor - * should sum stackSize of all stacks. - */ - List countItems(CorporeaRequest request); + /** + * Counts items in the inventory matching the request + * + * @param request + * - specifies what should be found + * @return List of ItemStack, individual stacks may exceed maxStackSize for + * purposes of counting huge amounts. To get final count requestor + * should sum stackSize of all stacks. + */ + List countItems(CorporeaRequest request); - /** - * Convenience method for accessing spark over inventory - */ - ICorporeaSpark getSpark(); + /** + * Convenience method for accessing spark over inventory + */ + ICorporeaSpark getSpark(); - /** - * Extracts items matching request from the inventory.
- * {@link CorporeaRequest#count} is updated to reflect how many items are - * yet to be extracted.
- * {@link CorporeaRequest#foundItems} and - * {@link CorporeaRequest#extractedItems} are updated to reflect how many - * items were found and extracted. - * - * @param request - * @return List of ItemStacks to be delivered to the destination. - */ - List extractItems(CorporeaRequest request); + /** + * Extracts items matching request from the inventory.
+ * {@link CorporeaRequest#count} is updated to reflect how many items are + * yet to be extracted.
+ * {@link CorporeaRequest#foundItems} and + * {@link CorporeaRequest#extractedItems} are updated to reflect how many + * items were found and extracted. + * + * @param request + * @return List of ItemStacks to be delivered to the destination. + */ + List extractItems(CorporeaRequest request); } diff --git a/src/main/java/vazkii/botania/api/internal/DummyManaNetwork.java b/src/main/java/vazkii/botania/api/internal/DummyManaNetwork.java index f74d0cac9b..3ce9d20ee0 100644 --- a/src/main/java/vazkii/botania/api/internal/DummyManaNetwork.java +++ b/src/main/java/vazkii/botania/api/internal/DummyManaNetwork.java @@ -2,17 +2,16 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Mar 7, 2014, 3:47:43 PM (GMT)] */ package vazkii.botania.api.internal; import java.util.ArrayList; import java.util.List; - import net.minecraft.tileentity.TileEntity; import net.minecraft.util.ChunkCoordinates; import net.minecraft.world.World; @@ -20,31 +19,30 @@ public class DummyManaNetwork implements IManaNetwork { - public static final DummyManaNetwork instance = new DummyManaNetwork(); - - @Override - public void clear() { - // NO-OP - } + public static final DummyManaNetwork instance = new DummyManaNetwork(); - @Override - public TileEntity getClosestPool(ChunkCoordinates pos, World world, int limit) { - return null; - } + @Override + public void clear() { + // NO-OP + } - @Override - public TileEntity getClosestCollector(ChunkCoordinates pos, World world, int limit) { - return null; - } + @Override + public TileEntity getClosestPool(ChunkCoordinates pos, World world, int limit) { + return null; + } - @Override - public List getAllCollectorsInWorld(World world) { - return new ArrayList(); - } + @Override + public TileEntity getClosestCollector(ChunkCoordinates pos, World world, int limit) { + return null; + } - @Override - public List getAllPoolsInWorld(World world) { - return new ArrayList(); - } + @Override + public List getAllCollectorsInWorld(World world) { + return new ArrayList(); + } + @Override + public List getAllPoolsInWorld(World world) { + return new ArrayList(); + } } diff --git a/src/main/java/vazkii/botania/api/internal/DummyMethodHandler.java b/src/main/java/vazkii/botania/api/internal/DummyMethodHandler.java index 88ddf474d7..80c636962d 100644 --- a/src/main/java/vazkii/botania/api/internal/DummyMethodHandler.java +++ b/src/main/java/vazkii/botania/api/internal/DummyMethodHandler.java @@ -2,16 +2,15 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jan 14, 2014, 6:43:03 PM (GMT)] */ package vazkii.botania.api.internal; import java.util.List; - import net.minecraft.client.gui.ScaledResolution; import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.entity.Entity; @@ -38,198 +37,204 @@ public class DummyMethodHandler implements IInternalMethodHandler { - @Override - public LexiconPage textPage(String key) { - return dummyPage(key); - } - - @Override - public LexiconPage elfPaperTextPage(String key) { - return dummyPage(key); - } - - @Override - public LexiconPage imagePage(String key, String resource) { - return dummyPage(key); - } - - @Override - public LexiconPage craftingRecipesPage(String key, List recipes) { - return dummyPage(key); - } - - @Override - public LexiconPage craftingRecipePage(String key, IRecipe recipe) { - return dummyPage(key); - } - - @Override - public LexiconPage petalRecipesPage(String key, List recipes) { - return dummyPage(key); - } - - @Override - public LexiconPage petalRecipePage(String key, RecipePetals recipe) { - return dummyPage(key); - } - - @Override - public LexiconPage runeRecipesPage(String key, List recipes) { - return dummyPage(key); - } - - @Override - public LexiconPage runeRecipePage(String key, RecipeRuneAltar recipe) { - return dummyPage(key); - } - - @Override - public LexiconPage manaInfusionRecipesPage(String key, List recipes) { - return dummyPage(key); - } - - @Override - public LexiconPage manaInfusionRecipePage(String key, RecipeManaInfusion recipe) { - return dummyPage(key); - } - - @Override - public LexiconPage elvenTradePage(String key, List recipes) { - return dummyPage(key); - } - - @Override - public LexiconPage elvenTradesPage(String key, RecipeElvenTrade recipe) { - return dummyPage(key); - } - - @Override - public LexiconPage brewPage(String key, String bottomText, RecipeBrew recipe) { - return dummyPage(key); - } - - @Override - public LexiconPage multiblockPage(String key, MultiblockSet mb) { - return dummyPage(key); - } - - private LexiconPage dummyPage(String key) { - return new DummyPage(key); - } - - @Override - public ItemStack getSubTileAsStack(String subTile) { - return new ItemStack(Blocks.stone, 0, 0); - } - - @Override - public ItemStack getSubTileAsFloatingFlowerStack(String subTile) { - return getSubTileAsStack(subTile); - } - - @Override - public String getStackSubTileKey(ItemStack stack) { - return null; - } - - @Override - public IIcon getSubTileIconForName(String name) { - return Blocks.red_flower.getIcon(0, 0); - } - - @Override - public void registerBasicSignatureIcons(String name, IIconRegister register) { - // NO-OP - } - - @Override - public IManaNetwork getManaNetworkInstance() { - return DummyManaNetwork.instance; - } - - @Override - public void drawSimpleManaHUD(int color, int mana, int maxMana, String name, ScaledResolution res) { - // NO-OP - } - - @Override - public void drawComplexManaHUD(int color, int mana, int maxMana, String name, ScaledResolution res, ItemStack bindDisplay, boolean properlyBound) { - // NO-OP - } - - @Override - public ItemStack getBindDisplayForFlowerType(SubTileEntity e) { - return new ItemStack(Blocks.stone, 0, 0); - } - - @Override - public void renderLexiconText(int x, int y, int width, int height, String unlocalizedText) { - // NO-OP - } - - @Override - public void sparkleFX(World world, double x, double y, double z, float r, float g, float b, float size, int m) { - // NO-OP - } - - @Override - public IInventory getBaublesInventory(EntityPlayer player) { - return null; - } - - @Override - public boolean shouldForceCheck() { - return true; - } - - @Override - public int getPassiveFlowerDecay() { - return 0; - } - - @Override - public ResourceLocation getDefaultBossBarTexture() { - return null; - } - - @Override - public void setBossStatus(IBotaniaBoss status) { - // NO-OP - } - - @Override - public boolean isBuildcraftPipe(TileEntity tile) { - return false; - } - - @Override - public void breakOnAllCursors(EntityPlayer player, Item item, ItemStack stack, int x, int y, int z, int side) { - // NO-OP - } - - @Override - public boolean hasSolegnoliaAround(Entity e) { - return false; - } - - @Override - public long getWorldElapsedTicks() { - return 0; - } - - @Override - public boolean isBotaniaFlower(World world, int x, int y, int z) { - return false; - } - - @Override - public void sendBaubleUpdatePacket(EntityPlayer player, int slot) { - // NO-OP - } - - @Override - public List wrapInventory(List inventories) { - return null; - } - + @Override + public LexiconPage textPage(String key) { + return dummyPage(key); + } + + @Override + public LexiconPage elfPaperTextPage(String key) { + return dummyPage(key); + } + + @Override + public LexiconPage imagePage(String key, String resource) { + return dummyPage(key); + } + + @Override + public LexiconPage craftingRecipesPage(String key, List recipes) { + return dummyPage(key); + } + + @Override + public LexiconPage craftingRecipePage(String key, IRecipe recipe) { + return dummyPage(key); + } + + @Override + public LexiconPage petalRecipesPage(String key, List recipes) { + return dummyPage(key); + } + + @Override + public LexiconPage petalRecipePage(String key, RecipePetals recipe) { + return dummyPage(key); + } + + @Override + public LexiconPage runeRecipesPage(String key, List recipes) { + return dummyPage(key); + } + + @Override + public LexiconPage runeRecipePage(String key, RecipeRuneAltar recipe) { + return dummyPage(key); + } + + @Override + public LexiconPage manaInfusionRecipesPage(String key, List recipes) { + return dummyPage(key); + } + + @Override + public LexiconPage manaInfusionRecipePage(String key, RecipeManaInfusion recipe) { + return dummyPage(key); + } + + @Override + public LexiconPage elvenTradePage(String key, List recipes) { + return dummyPage(key); + } + + @Override + public LexiconPage elvenTradesPage(String key, RecipeElvenTrade recipe) { + return dummyPage(key); + } + + @Override + public LexiconPage brewPage(String key, String bottomText, RecipeBrew recipe) { + return dummyPage(key); + } + + @Override + public LexiconPage multiblockPage(String key, MultiblockSet mb) { + return dummyPage(key); + } + + private LexiconPage dummyPage(String key) { + return new DummyPage(key); + } + + @Override + public ItemStack getSubTileAsStack(String subTile) { + return new ItemStack(Blocks.stone, 0, 0); + } + + @Override + public ItemStack getSubTileAsFloatingFlowerStack(String subTile) { + return getSubTileAsStack(subTile); + } + + @Override + public String getStackSubTileKey(ItemStack stack) { + return null; + } + + @Override + public IIcon getSubTileIconForName(String name) { + return Blocks.red_flower.getIcon(0, 0); + } + + @Override + public void registerBasicSignatureIcons(String name, IIconRegister register) { + // NO-OP + } + + @Override + public IManaNetwork getManaNetworkInstance() { + return DummyManaNetwork.instance; + } + + @Override + public void drawSimpleManaHUD(int color, int mana, int maxMana, String name, ScaledResolution res) { + // NO-OP + } + + @Override + public void drawComplexManaHUD( + int color, + int mana, + int maxMana, + String name, + ScaledResolution res, + ItemStack bindDisplay, + boolean properlyBound) { + // NO-OP + } + + @Override + public ItemStack getBindDisplayForFlowerType(SubTileEntity e) { + return new ItemStack(Blocks.stone, 0, 0); + } + + @Override + public void renderLexiconText(int x, int y, int width, int height, String unlocalizedText) { + // NO-OP + } + + @Override + public void sparkleFX(World world, double x, double y, double z, float r, float g, float b, float size, int m) { + // NO-OP + } + + @Override + public IInventory getBaublesInventory(EntityPlayer player) { + return null; + } + + @Override + public boolean shouldForceCheck() { + return true; + } + + @Override + public int getPassiveFlowerDecay() { + return 0; + } + + @Override + public ResourceLocation getDefaultBossBarTexture() { + return null; + } + + @Override + public void setBossStatus(IBotaniaBoss status) { + // NO-OP + } + + @Override + public boolean isBuildcraftPipe(TileEntity tile) { + return false; + } + + @Override + public void breakOnAllCursors(EntityPlayer player, Item item, ItemStack stack, int x, int y, int z, int side) { + // NO-OP + } + + @Override + public boolean hasSolegnoliaAround(Entity e) { + return false; + } + + @Override + public long getWorldElapsedTicks() { + return 0; + } + + @Override + public boolean isBotaniaFlower(World world, int x, int y, int z) { + return false; + } + + @Override + public void sendBaubleUpdatePacket(EntityPlayer player, int slot) { + // NO-OP + } + + @Override + public List wrapInventory(List inventories) { + return null; + } } diff --git a/src/main/java/vazkii/botania/api/internal/DummyPage.java b/src/main/java/vazkii/botania/api/internal/DummyPage.java index 843198c416..481f1c8f8c 100644 --- a/src/main/java/vazkii/botania/api/internal/DummyPage.java +++ b/src/main/java/vazkii/botania/api/internal/DummyPage.java @@ -2,17 +2,17 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jan 14, 2014, 6:41:23 PM (GMT)] */ package vazkii.botania.api.internal; -import vazkii.botania.api.lexicon.LexiconPage; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; +import vazkii.botania.api.lexicon.LexiconPage; /** * A dummy page. It does absolutely nothing and is only @@ -21,14 +21,13 @@ */ public class DummyPage extends LexiconPage { - public DummyPage(String unlocalizedName) { - super(unlocalizedName); - } - - @Override - @SideOnly(Side.CLIENT) - public void renderScreen(IGuiLexiconEntry gui, int x, int y) { - // NO-OP - } + public DummyPage(String unlocalizedName) { + super(unlocalizedName); + } + @Override + @SideOnly(Side.CLIENT) + public void renderScreen(IGuiLexiconEntry gui, int x, int y) { + // NO-OP + } } diff --git a/src/main/java/vazkii/botania/api/internal/DummySubTile.java b/src/main/java/vazkii/botania/api/internal/DummySubTile.java index d8ac6ab5b6..e8ae39c926 100644 --- a/src/main/java/vazkii/botania/api/internal/DummySubTile.java +++ b/src/main/java/vazkii/botania/api/internal/DummySubTile.java @@ -2,16 +2,14 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jan 24, 2014, 4:17:33 PM (GMT)] */ package vazkii.botania.api.internal; import vazkii.botania.api.subtile.SubTileEntity; -public class DummySubTile extends SubTileEntity { - -} +public class DummySubTile extends SubTileEntity {} diff --git a/src/main/java/vazkii/botania/api/internal/IGuiLexiconEntry.java b/src/main/java/vazkii/botania/api/internal/IGuiLexiconEntry.java index b0d4d6ef4d..6dd78a31e4 100644 --- a/src/main/java/vazkii/botania/api/internal/IGuiLexiconEntry.java +++ b/src/main/java/vazkii/botania/api/internal/IGuiLexiconEntry.java @@ -2,16 +2,15 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jan 14, 2014, 6:48:41 PM (GMT)] */ package vazkii.botania.api.internal; import java.util.List; - import net.minecraft.client.gui.GuiButton; import vazkii.botania.api.lexicon.LexiconEntry; @@ -22,60 +21,60 @@ */ public interface IGuiLexiconEntry { - /** - * Gets the entry currently portrayed in this gui. - */ - public LexiconEntry getEntry(); + /** + * Gets the entry currently portrayed in this gui. + */ + public LexiconEntry getEntry(); - /** - * Gets the current page the lexicon GUI is browsing. - */ - public int getPageOn(); + /** + * Gets the current page the lexicon GUI is browsing. + */ + public int getPageOn(); - /** - * Gets the leftmost part of the GUI. - */ - public int getLeft(); + /** + * Gets the leftmost part of the GUI. + */ + public int getLeft(); - /** - * Gets the topmost part of the GUI. - */ - public int getTop(); + /** + * Gets the topmost part of the GUI. + */ + public int getTop(); - /** - * Gets the GUI's width. - */ - public int getWidth(); + /** + * Gets the GUI's width. + */ + public int getWidth(); - /** - * Gets the GUI's height - */ - public int getHeight(); + /** + * Gets the GUI's height + */ + public int getHeight(); - /** - * Gets the GUI's Z level for rendering. - */ - public float getZLevel(); + /** + * Gets the GUI's Z level for rendering. + */ + public float getZLevel(); - /** - * Gets the list of buttons in this gui. - */ - public List getButtonList(); + /** + * Gets the list of buttons in this gui. + */ + public List getButtonList(); - /** - * Gets the total amount of ticks (+ partial ticks) the player - * has been in this gui. - */ - public float getElapsedTicks(); + /** + * Gets the total amount of ticks (+ partial ticks) the player + * has been in this gui. + */ + public float getElapsedTicks(); - /** - * Gets the current partial ticks. - */ - public float getPartialTicks(); + /** + * Gets the current partial ticks. + */ + public float getPartialTicks(); - /** - * Gets the delta (1F = 1 tick) between this render call - * and the last one. - */ - public float getTickDelta(); + /** + * Gets the delta (1F = 1 tick) between this render call + * and the last one. + */ + public float getTickDelta(); } diff --git a/src/main/java/vazkii/botania/api/internal/IInternalMethodHandler.java b/src/main/java/vazkii/botania/api/internal/IInternalMethodHandler.java index b0e3d10bd9..7e64ea5565 100644 --- a/src/main/java/vazkii/botania/api/internal/IInternalMethodHandler.java +++ b/src/main/java/vazkii/botania/api/internal/IInternalMethodHandler.java @@ -2,16 +2,17 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jan 14, 2014, 6:34:34 PM (GMT)] */ package vazkii.botania.api.internal; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; import java.util.List; - import net.minecraft.client.gui.ScaledResolution; import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.entity.Entity; @@ -34,8 +35,6 @@ import vazkii.botania.api.recipe.RecipePetals; import vazkii.botania.api.recipe.RecipeRuneAltar; import vazkii.botania.api.subtile.SubTileEntity; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; /** * Any methods that refer to internal methods in Botania are here. @@ -46,89 +45,95 @@ */ public interface IInternalMethodHandler { - public LexiconPage textPage(String key); - - public LexiconPage elfPaperTextPage(String key); + public LexiconPage textPage(String key); - public LexiconPage imagePage(String key, String resource); + public LexiconPage elfPaperTextPage(String key); - public LexiconPage craftingRecipesPage(String key, List recipes); + public LexiconPage imagePage(String key, String resource); - public LexiconPage craftingRecipePage(String key, IRecipe recipe); + public LexiconPage craftingRecipesPage(String key, List recipes); - public LexiconPage petalRecipesPage(String key, List recipes); + public LexiconPage craftingRecipePage(String key, IRecipe recipe); - public LexiconPage petalRecipePage(String key, RecipePetals recipe); + public LexiconPage petalRecipesPage(String key, List recipes); - public LexiconPage runeRecipesPage(String key, List recipes); + public LexiconPage petalRecipePage(String key, RecipePetals recipe); - public LexiconPage runeRecipePage(String key, RecipeRuneAltar recipe); + public LexiconPage runeRecipesPage(String key, List recipes); - public LexiconPage manaInfusionRecipesPage(String key, List recipes); + public LexiconPage runeRecipePage(String key, RecipeRuneAltar recipe); - public LexiconPage manaInfusionRecipePage(String key, RecipeManaInfusion recipe); + public LexiconPage manaInfusionRecipesPage(String key, List recipes); - public LexiconPage elvenTradePage(String key, List recipes); + public LexiconPage manaInfusionRecipePage(String key, RecipeManaInfusion recipe); - public LexiconPage elvenTradesPage(String key, RecipeElvenTrade recipe); + public LexiconPage elvenTradePage(String key, List recipes); - public LexiconPage brewPage(String key, String bottomText, RecipeBrew recipe); + public LexiconPage elvenTradesPage(String key, RecipeElvenTrade recipe); - public LexiconPage multiblockPage(String key, MultiblockSet mb); + public LexiconPage brewPage(String key, String bottomText, RecipeBrew recipe); - public IManaNetwork getManaNetworkInstance(); + public LexiconPage multiblockPage(String key, MultiblockSet mb); - public ItemStack getSubTileAsStack(String subTile); + public IManaNetwork getManaNetworkInstance(); - public ItemStack getSubTileAsFloatingFlowerStack(String subTile); + public ItemStack getSubTileAsStack(String subTile); - public String getStackSubTileKey(ItemStack stack); + public ItemStack getSubTileAsFloatingFlowerStack(String subTile); - public IIcon getSubTileIconForName(String name); + public String getStackSubTileKey(ItemStack stack); - public void registerBasicSignatureIcons(String name, IIconRegister register); + public IIcon getSubTileIconForName(String name); - public boolean shouldForceCheck(); + public void registerBasicSignatureIcons(String name, IIconRegister register); - public int getPassiveFlowerDecay(); + public boolean shouldForceCheck(); - public IInventory getBaublesInventory(EntityPlayer player); + public int getPassiveFlowerDecay(); - public void breakOnAllCursors(EntityPlayer player, Item item, ItemStack stack, int x, int y, int z, int side); + public IInventory getBaublesInventory(EntityPlayer player); - public boolean hasSolegnoliaAround(Entity e); + public void breakOnAllCursors(EntityPlayer player, Item item, ItemStack stack, int x, int y, int z, int side); - @SideOnly(Side.CLIENT) - public void drawSimpleManaHUD(int color, int mana, int maxMana, String name, ScaledResolution res); + public boolean hasSolegnoliaAround(Entity e); - @SideOnly(Side.CLIENT) - public void drawComplexManaHUD(int color, int mana, int maxMana, String name, ScaledResolution res, ItemStack bindDisplay, boolean properlyBound); + @SideOnly(Side.CLIENT) + public void drawSimpleManaHUD(int color, int mana, int maxMana, String name, ScaledResolution res); - @SideOnly(Side.CLIENT) - public ItemStack getBindDisplayForFlowerType(SubTileEntity e); + @SideOnly(Side.CLIENT) + public void drawComplexManaHUD( + int color, + int mana, + int maxMana, + String name, + ScaledResolution res, + ItemStack bindDisplay, + boolean properlyBound); - @SideOnly(Side.CLIENT) - public void renderLexiconText(int x, int y, int width, int height, String unlocalizedText); + @SideOnly(Side.CLIENT) + public ItemStack getBindDisplayForFlowerType(SubTileEntity e); - @SideOnly(Side.CLIENT) - public ResourceLocation getDefaultBossBarTexture(); + @SideOnly(Side.CLIENT) + public void renderLexiconText(int x, int y, int width, int height, String unlocalizedText); - @SideOnly(Side.CLIENT) - public void setBossStatus(IBotaniaBoss status); + @SideOnly(Side.CLIENT) + public ResourceLocation getDefaultBossBarTexture(); - public boolean isBuildcraftPipe(TileEntity tile); + @SideOnly(Side.CLIENT) + public void setBossStatus(IBotaniaBoss status); - public void sparkleFX(World world, double x, double y, double z, float r, float g, float b, float size, int m); + public boolean isBuildcraftPipe(TileEntity tile); - public long getWorldElapsedTicks(); + public void sparkleFX(World world, double x, double y, double z, float r, float g, float b, float size, int m); - public boolean isBotaniaFlower(World world, int x, int y, int z); + public long getWorldElapsedTicks(); - public void sendBaubleUpdatePacket(EntityPlayer player, int slot); + public boolean isBotaniaFlower(World world, int x, int y, int z); - /** - * Wrap inventories in the network into wrappers providing compatibility for storage mods. - */ - List wrapInventory(List inventories); + public void sendBaubleUpdatePacket(EntityPlayer player, int slot); + /** + * Wrap inventories in the network into wrappers providing compatibility for storage mods. + */ + List wrapInventory(List inventories); } diff --git a/src/main/java/vazkii/botania/api/internal/IManaBurst.java b/src/main/java/vazkii/botania/api/internal/IManaBurst.java index 945aa9916a..a998df7c0d 100644 --- a/src/main/java/vazkii/botania/api/internal/IManaBurst.java +++ b/src/main/java/vazkii/botania/api/internal/IManaBurst.java @@ -2,16 +2,15 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jan 31, 2014, 4:36:13 PM (GMT)] */ package vazkii.botania.api.internal; import java.util.UUID; - import net.minecraft.item.ItemStack; import net.minecraft.util.ChunkCoordinates; @@ -20,54 +19,53 @@ */ public interface IManaBurst { - public boolean isFake(); - - public void setMotion(double x, double y, double z); + public boolean isFake(); - public int getColor(); + public void setMotion(double x, double y, double z); - public void setColor(int color); + public int getColor(); - public int getMana(); + public void setColor(int color); - public void setMana(int mana); + public int getMana(); - public int getStartingMana(); + public void setMana(int mana); - public void setStartingMana(int mana); + public int getStartingMana(); - public int getMinManaLoss(); + public void setStartingMana(int mana); - public void setMinManaLoss(int minManaLoss); + public int getMinManaLoss(); - public float getManaLossPerTick(); + public void setMinManaLoss(int minManaLoss); - public void setManaLossPerTick(float mana); + public float getManaLossPerTick(); - public float getGravity(); + public void setManaLossPerTick(float mana); - public void setGravity(float gravity); + public float getGravity(); - public ChunkCoordinates getBurstSourceChunkCoordinates(); + public void setGravity(float gravity); - public void setBurstSourceCoords(int x, int y, int z); + public ChunkCoordinates getBurstSourceChunkCoordinates(); - public ItemStack getSourceLens(); + public void setBurstSourceCoords(int x, int y, int z); - public void setSourceLens(ItemStack lens); + public ItemStack getSourceLens(); - public boolean hasAlreadyCollidedAt(int x, int y, int z); + public void setSourceLens(ItemStack lens); - public void setCollidedAt(int x, int y, int z); + public boolean hasAlreadyCollidedAt(int x, int y, int z); - public int getTicksExisted(); + public void setCollidedAt(int x, int y, int z); - public void setFake(boolean fake); + public int getTicksExisted(); - public void setShooterUUID(UUID uuid); + public void setFake(boolean fake); - public UUID getShooterUIID(); + public void setShooterUUID(UUID uuid); - public void ping(); + public UUID getShooterUIID(); + public void ping(); } diff --git a/src/main/java/vazkii/botania/api/internal/IManaNetwork.java b/src/main/java/vazkii/botania/api/internal/IManaNetwork.java index fc4553e46c..81183cbc51 100644 --- a/src/main/java/vazkii/botania/api/internal/IManaNetwork.java +++ b/src/main/java/vazkii/botania/api/internal/IManaNetwork.java @@ -2,16 +2,15 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Mar 7, 2014, 3:39:48 PM (GMT)] */ package vazkii.botania.api.internal; import java.util.List; - import net.minecraft.tileentity.TileEntity; import net.minecraft.util.ChunkCoordinates; import net.minecraft.world.World; @@ -23,45 +22,45 @@ */ public interface IManaNetwork { - /** - * Clears the entire Mana Network of all it's contents, you probably - * don't want to call this unless you have a very good reason. - */ - public void clear(); + /** + * Clears the entire Mana Network of all it's contents, you probably + * don't want to call this unless you have a very good reason. + */ + public void clear(); - /** - * Gets the closest Mana Collector (eg. Mana Spreader) in the network to the Chunk - * Coordinates passed in, in the given dimension.
- * A way of getting the dimension is via worldObj.provider.dimensionId
- * Note that this function *can* get performance intensive, it's reccomended you - * call it sparingly and take cache of the value returned. - * @param limit The maximum distance the closest block can be, if the closest block - * is farther away than that, null will be returned instead. - */ - public TileEntity getClosestCollector(ChunkCoordinates pos, World world, int limit); + /** + * Gets the closest Mana Collector (eg. Mana Spreader) in the network to the Chunk + * Coordinates passed in, in the given dimension.
+ * A way of getting the dimension is via worldObj.provider.dimensionId
+ * Note that this function *can* get performance intensive, it's reccomended you + * call it sparingly and take cache of the value returned. + * @param limit The maximum distance the closest block can be, if the closest block + * is farther away than that, null will be returned instead. + */ + public TileEntity getClosestCollector(ChunkCoordinates pos, World world, int limit); - /** - * Gets the closest Mana Pool in the network to the Chunk Coordinates passed in, - * in the given dimension.
- * A way of getting the dimension is via worldObj.provider.dimensionId
- * Note that this function *can* get performance intensive, it's reccomended you - * call it sparingly and take cache of the value returned. - * @param limit The maximum distance the closest block can be, if the closest block - * is farther away than that, null will be returned instead. - */ - public TileEntity getClosestPool(ChunkCoordinates pos, World world, int limit); + /** + * Gets the closest Mana Pool in the network to the Chunk Coordinates passed in, + * in the given dimension.
+ * A way of getting the dimension is via worldObj.provider.dimensionId
+ * Note that this function *can* get performance intensive, it's reccomended you + * call it sparingly and take cache of the value returned. + * @param limit The maximum distance the closest block can be, if the closest block + * is farther away than that, null will be returned instead. + */ + public TileEntity getClosestPool(ChunkCoordinates pos, World world, int limit); - /** - * Gets the list of all Mana Collectors (eg. Mana Spreader) in the dimension - * passed in. Note that this is the actual list and not a copy, make sure to - * clone the list if you intend to change it in any way. - */ - public List getAllCollectorsInWorld(World world); + /** + * Gets the list of all Mana Collectors (eg. Mana Spreader) in the dimension + * passed in. Note that this is the actual list and not a copy, make sure to + * clone the list if you intend to change it in any way. + */ + public List getAllCollectorsInWorld(World world); - /** - * Gets the list of all Mana Pools in the dimension passed in. Note that this - * is the actual list and not a copy, make sure to clone the list if you intend - * to change it in any way. - */ - public List getAllPoolsInWorld(World world); + /** + * Gets the list of all Mana Pools in the dimension passed in. Note that this + * is the actual list and not a copy, make sure to clone the list if you intend + * to change it in any way. + */ + public List getAllPoolsInWorld(World world); } diff --git a/src/main/java/vazkii/botania/api/internal/ShaderCallback.java b/src/main/java/vazkii/botania/api/internal/ShaderCallback.java index 12186a2319..ee625ee5bc 100644 --- a/src/main/java/vazkii/botania/api/internal/ShaderCallback.java +++ b/src/main/java/vazkii/botania/api/internal/ShaderCallback.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Oct 29, 2014, 6:31:35 PM (GMT)] */ package vazkii.botania.api.internal; @@ -15,6 +15,5 @@ */ public abstract class ShaderCallback { - public abstract void call(int shader); - + public abstract void call(int shader); } diff --git a/src/main/java/vazkii/botania/api/internal/VanillaPacketDispatcher.java b/src/main/java/vazkii/botania/api/internal/VanillaPacketDispatcher.java index dff8b96360..4884edd8b4 100644 --- a/src/main/java/vazkii/botania/api/internal/VanillaPacketDispatcher.java +++ b/src/main/java/vazkii/botania/api/internal/VanillaPacketDispatcher.java @@ -2,41 +2,38 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Apr 9, 2015, 9:38:44 PM (GMT)] */ package vazkii.botania.api.internal; import java.util.List; - import net.minecraft.entity.player.EntityPlayerMP; import net.minecraft.tileentity.TileEntity; import net.minecraft.world.World; public final class VanillaPacketDispatcher { - public static void dispatchTEToNearbyPlayers(TileEntity tile) { - World world = tile.getWorldObj(); - List players = world.playerEntities; - for(Object player : players) - if(player instanceof EntityPlayerMP) { - EntityPlayerMP mp = (EntityPlayerMP) player; - if(pointDistancePlane(mp.posX, mp.posZ, tile.xCoord + 0.5, tile.zCoord + 0.5) < 64) - ((EntityPlayerMP) player).playerNetServerHandler.sendPacket(tile.getDescriptionPacket()); - } - } - - public static void dispatchTEToNearbyPlayers(World world, int x, int y, int z) { - TileEntity tile = world.getTileEntity(x, y, z); - if(tile != null) - dispatchTEToNearbyPlayers(tile); - } + public static void dispatchTEToNearbyPlayers(TileEntity tile) { + World world = tile.getWorldObj(); + List players = world.playerEntities; + for (Object player : players) + if (player instanceof EntityPlayerMP) { + EntityPlayerMP mp = (EntityPlayerMP) player; + if (pointDistancePlane(mp.posX, mp.posZ, tile.xCoord + 0.5, tile.zCoord + 0.5) < 64) + ((EntityPlayerMP) player).playerNetServerHandler.sendPacket(tile.getDescriptionPacket()); + } + } - public static float pointDistancePlane(double x1, double y1, double x2, double y2) { - return (float) Math.hypot(x1 - x2, y1 - y2); - } + public static void dispatchTEToNearbyPlayers(World world, int x, int y, int z) { + TileEntity tile = world.getTileEntity(x, y, z); + if (tile != null) dispatchTEToNearbyPlayers(tile); + } + public static float pointDistancePlane(double x1, double y1, double x2, double y2) { + return (float) Math.hypot(x1 - x2, y1 - y2); + } } diff --git a/src/main/java/vazkii/botania/api/item/IAncientWillContainer.java b/src/main/java/vazkii/botania/api/item/IAncientWillContainer.java index 2d2abe2b3c..a5d87ffa1e 100644 --- a/src/main/java/vazkii/botania/api/item/IAncientWillContainer.java +++ b/src/main/java/vazkii/botania/api/item/IAncientWillContainer.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jan 30, 2015, 11:24:54 PM (GMT)] */ package vazkii.botania.api.item; @@ -18,8 +18,7 @@ */ public interface IAncientWillContainer { - public void addAncientWill(ItemStack stack, int will); - - public boolean hasAncientWill(ItemStack stack, int will); + public void addAncientWill(ItemStack stack, int will); + public boolean hasAncientWill(ItemStack stack, int will); } diff --git a/src/main/java/vazkii/botania/api/item/IAvatarTile.java b/src/main/java/vazkii/botania/api/item/IAvatarTile.java index c89f903b22..bfdc245a06 100644 --- a/src/main/java/vazkii/botania/api/item/IAvatarTile.java +++ b/src/main/java/vazkii/botania/api/item/IAvatarTile.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Oct 24, 2015, 7:00:21 PM (GMT)] */ package vazkii.botania.api.item; @@ -18,15 +18,14 @@ */ public interface IAvatarTile extends IInventory, IManaReceiver { - /** - * Gets the amount of ticks that have elapsed on this avatar while it's functional - * (has redstone signal). - */ - public int getElapsedFunctionalTicks(); - - /** - * Gets if this avatar is enabled (isn't powered by a redstone signal). - */ - public boolean isEnabled(); + /** + * Gets the amount of ticks that have elapsed on this avatar while it's functional + * (has redstone signal). + */ + public int getElapsedFunctionalTicks(); + /** + * Gets if this avatar is enabled (isn't powered by a redstone signal). + */ + public boolean isEnabled(); } diff --git a/src/main/java/vazkii/botania/api/item/IAvatarWieldable.java b/src/main/java/vazkii/botania/api/item/IAvatarWieldable.java index 96910090ac..559f67e564 100644 --- a/src/main/java/vazkii/botania/api/item/IAvatarWieldable.java +++ b/src/main/java/vazkii/botania/api/item/IAvatarWieldable.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Oct 24, 2015, 6:45:50 PM (GMT)] */ package vazkii.botania.api.item; @@ -18,14 +18,13 @@ */ public interface IAvatarWieldable { - /** - * Called on update of the avatar tile. - */ - public void onAvatarUpdate(IAvatarTile tile, ItemStack stack); - - /** - * Gets the overlay resource to render on top of the avatar tile. - */ - public ResourceLocation getOverlayResource(IAvatarTile tile, ItemStack stack); + /** + * Called on update of the avatar tile. + */ + public void onAvatarUpdate(IAvatarTile tile, ItemStack stack); + /** + * Gets the overlay resource to render on top of the avatar tile. + */ + public ResourceLocation getOverlayResource(IAvatarTile tile, ItemStack stack); } diff --git a/src/main/java/vazkii/botania/api/item/IBaubleRender.java b/src/main/java/vazkii/botania/api/item/IBaubleRender.java index d98a29434b..02d4bb288e 100644 --- a/src/main/java/vazkii/botania/api/item/IBaubleRender.java +++ b/src/main/java/vazkii/botania/api/item/IBaubleRender.java @@ -2,24 +2,22 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Dec 4, 2014, 3:28:43 PM (GMT)] */ package vazkii.botania.api.item; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; import net.minecraft.client.Minecraft; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; import net.minecraftforge.client.event.RenderPlayerEvent; - import org.lwjgl.opengl.GL11; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; - /** * A Bauble Item that implements this will be have hooks to render something on * the player while its equipped. @@ -28,50 +26,52 @@ */ public interface IBaubleRender { - /** - * Called for the rendering of the bauble on the player. The player instance can be - * acquired through the event parameter. Transformations are already applied for - * the RenderType passed in. Make sure to check against the type parameter for - * rendering. Will not be called if the item is a ICosmeticAttachable and - * has a cosmetic bauble attached to it. - */ - @SideOnly(Side.CLIENT) - public void onPlayerBaubleRender(ItemStack stack, RenderPlayerEvent event, RenderType type); - - /** - * A few helper methods for the render. - */ - public static class Helper { - - public static void rotateIfSneaking(EntityPlayer player) { - if(player.isSneaking()) - applySneakingRotation(); - } + /** + * Called for the rendering of the bauble on the player. The player instance can be + * acquired through the event parameter. Transformations are already applied for + * the RenderType passed in. Make sure to check against the type parameter for + * rendering. Will not be called if the item is a ICosmeticAttachable and + * has a cosmetic bauble attached to it. + */ + @SideOnly(Side.CLIENT) + public void onPlayerBaubleRender(ItemStack stack, RenderPlayerEvent event, RenderType type); - public static void applySneakingRotation() { - GL11.glRotatef(28.64789F, 1.0F, 0.0F, 0.0F); - } + /** + * A few helper methods for the render. + */ + public static class Helper { - public static void translateToHeadLevel(EntityPlayer player) { - GL11.glTranslated(0, (player != Minecraft.getMinecraft().thePlayer ? 1.68F : 0F) - player.getDefaultEyeHeight() + (player.isSneaking() ? 0.0625 : 0), 0); - } + public static void rotateIfSneaking(EntityPlayer player) { + if (player.isSneaking()) applySneakingRotation(); + } - } + public static void applySneakingRotation() { + GL11.glRotatef(28.64789F, 1.0F, 0.0F, 0.0F); + } - public static enum RenderType { - /** - * Render Type for the player's body, translations apply on the player's rotation. - * Sneaking is not handled and should be done during the render. - * @see IBaubleRender.Helper - */ - BODY, + public static void translateToHeadLevel(EntityPlayer player) { + GL11.glTranslated( + 0, + (player != Minecraft.getMinecraft().thePlayer ? 1.68F : 0F) + - player.getDefaultEyeHeight() + + (player.isSneaking() ? 0.0625 : 0), + 0); + } + } - /** - * Render Type for the player's body, translations apply on the player's head rotations. - * Sneaking is not handled and should be done during the render.~ - * @see IBaubleRender.Helper - */ - HEAD; - } + public static enum RenderType { + /** + * Render Type for the player's body, translations apply on the player's rotation. + * Sneaking is not handled and should be done during the render. + * @see IBaubleRender.Helper + */ + BODY, + /** + * Render Type for the player's body, translations apply on the player's head rotations. + * Sneaking is not handled and should be done during the render.~ + * @see IBaubleRender.Helper + */ + HEAD; + } } diff --git a/src/main/java/vazkii/botania/api/item/IBlockProvider.java b/src/main/java/vazkii/botania/api/item/IBlockProvider.java index 42f2e3f892..2efd1e2a7d 100644 --- a/src/main/java/vazkii/botania/api/item/IBlockProvider.java +++ b/src/main/java/vazkii/botania/api/item/IBlockProvider.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Aug 20, 2015, 10:31:54 PM (GMT)] */ package vazkii.botania.api.item; @@ -21,20 +21,20 @@ */ public interface IBlockProvider { - /** - * Provides the requested item. The doit paremeter specifies whether this is - * just a test (false) or if the item should actually be removed (true). - * If you need to use calls to ManaItemHandler.requestMana[Exact], use - * the requestor as the ItemStack passed in. - */ - public boolean provideBlock(EntityPlayer player, ItemStack requestor, ItemStack stack, Block block, int meta, boolean doit); - - /** - * Gets the amount of blocks of the type passed stored in this item. You must - * check for the block passed in to not give the counter for a wrong block. Returning - * -1 states that the item can provide infinite of the item passed in (for example, - * the Rod of the Lands would return -1 if the block is dirt). - */ - public int getBlockCount(EntityPlayer player, ItemStack requestor, ItemStack stack, Block block, int meta); + /** + * Provides the requested item. The doit paremeter specifies whether this is + * just a test (false) or if the item should actually be removed (true). + * If you need to use calls to ManaItemHandler.requestMana[Exact], use + * the requestor as the ItemStack passed in. + */ + public boolean provideBlock( + EntityPlayer player, ItemStack requestor, ItemStack stack, Block block, int meta, boolean doit); + /** + * Gets the amount of blocks of the type passed stored in this item. You must + * check for the block passed in to not give the counter for a wrong block. Returning + * -1 states that the item can provide infinite of the item passed in (for example, + * the Rod of the Lands would return -1 if the block is dirt). + */ + public int getBlockCount(EntityPlayer player, ItemStack requestor, ItemStack stack, Block block, int meta); } diff --git a/src/main/java/vazkii/botania/api/item/IBurstViewerBauble.java b/src/main/java/vazkii/botania/api/item/IBurstViewerBauble.java index 4402a715f3..f5f3f1fd75 100644 --- a/src/main/java/vazkii/botania/api/item/IBurstViewerBauble.java +++ b/src/main/java/vazkii/botania/api/item/IBurstViewerBauble.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jan 24, 2015, 3:08:40 PM (GMT)] */ package vazkii.botania.api.item; @@ -15,6 +15,4 @@ * Having a IBauble of this type equipped on the 0th slot (amulet) * will draw bursts without depth testing and to see sub tile radiuses. */ -public interface IBurstViewerBauble { - -} +public interface IBurstViewerBauble {} diff --git a/src/main/java/vazkii/botania/api/item/ICosmeticAttachable.java b/src/main/java/vazkii/botania/api/item/ICosmeticAttachable.java index 4fbee0ec0e..fd7d799b95 100644 --- a/src/main/java/vazkii/botania/api/item/ICosmeticAttachable.java +++ b/src/main/java/vazkii/botania/api/item/ICosmeticAttachable.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Feb 22, 2015, 8:31:39 PM (GMT)] */ package vazkii.botania.api.item; @@ -20,14 +20,13 @@ */ public interface ICosmeticAttachable { - /** - * Gets the cosmetic item stored in the stack passed in. - */ - public ItemStack getCosmeticItem(ItemStack stack); - - /** - * Sets the stack's cosmetic item to the one passed in. - */ - public void setCosmeticItem(ItemStack stack, ItemStack cosmetic); + /** + * Gets the cosmetic item stored in the stack passed in. + */ + public ItemStack getCosmeticItem(ItemStack stack); + /** + * Sets the stack's cosmetic item to the one passed in. + */ + public void setCosmeticItem(ItemStack stack, ItemStack cosmetic); } diff --git a/src/main/java/vazkii/botania/api/item/ICosmeticBauble.java b/src/main/java/vazkii/botania/api/item/ICosmeticBauble.java index d488ad4e94..7fee236866 100644 --- a/src/main/java/vazkii/botania/api/item/ICosmeticBauble.java +++ b/src/main/java/vazkii/botania/api/item/ICosmeticBauble.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Feb 22, 2015, 2:02:02 PM (GMT)] */ package vazkii.botania.api.item; @@ -15,6 +15,4 @@ * other baubles to add the render to them. Other cosmetic baubles * can't be stacked on this. */ -public interface ICosmeticBauble extends IBaubleRender { - -} +public interface ICosmeticBauble extends IBaubleRender {} diff --git a/src/main/java/vazkii/botania/api/item/IDyablePool.java b/src/main/java/vazkii/botania/api/item/IDyablePool.java index 8bb8e94eb9..a30b5838f6 100644 --- a/src/main/java/vazkii/botania/api/item/IDyablePool.java +++ b/src/main/java/vazkii/botania/api/item/IDyablePool.java @@ -2,23 +2,20 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jan 18, 2015, 12:20:44 AM (GMT)] */ package vazkii.botania.api.item; - /** * Used to define a Mana Pool that can be dyed through floral powder. */ public interface IDyablePool { - public int getColor(); - - public void setColor(int color); - + public int getColor(); + public void setColor(int color); } diff --git a/src/main/java/vazkii/botania/api/item/IExoflameHeatable.java b/src/main/java/vazkii/botania/api/item/IExoflameHeatable.java index bd007342dc..56d57fb8be 100644 --- a/src/main/java/vazkii/botania/api/item/IExoflameHeatable.java +++ b/src/main/java/vazkii/botania/api/item/IExoflameHeatable.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Aug 30, 2014, 4:28:29 PM (GMT)] */ package vazkii.botania.api.item; @@ -15,29 +15,28 @@ */ public interface IExoflameHeatable { - /** - * Can this TileEntity smelt its contents. If true, the Exoflame is allowed - * to fuel it. - */ - public boolean canSmelt(); + /** + * Can this TileEntity smelt its contents. If true, the Exoflame is allowed + * to fuel it. + */ + public boolean canSmelt(); - /** - * Gets the amount of ticks left for the fuel. If below 2, the exoflame - * will call boostBurnTime. - */ - public int getBurnTime(); + /** + * Gets the amount of ticks left for the fuel. If below 2, the exoflame + * will call boostBurnTime. + */ + public int getBurnTime(); - /** - * Called to increase the amount of time this furnace should be burning - * the fuel for. Even if it doesn't have any fuel. - */ - public void boostBurnTime(); - - /** - * Called once every two ticks to increase the speed of the furnace. Feel - * free to not do anything if all you want is to allow the exoflame to feed - * it, not make it faster. - */ - public void boostCookTime(); + /** + * Called to increase the amount of time this furnace should be burning + * the fuel for. Even if it doesn't have any fuel. + */ + public void boostBurnTime(); + /** + * Called once every two ticks to increase the speed of the furnace. Feel + * free to not do anything if all you want is to allow the exoflame to feed + * it, not make it faster. + */ + public void boostCookTime(); } diff --git a/src/main/java/vazkii/botania/api/item/IExtendedPlayerController.java b/src/main/java/vazkii/botania/api/item/IExtendedPlayerController.java index e07d076661..16ff8770a2 100644 --- a/src/main/java/vazkii/botania/api/item/IExtendedPlayerController.java +++ b/src/main/java/vazkii/botania/api/item/IExtendedPlayerController.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Aug 6, 2014, 6:02:29 PM (GMT)] */ package vazkii.botania.api.item; @@ -16,13 +16,13 @@ */ public interface IExtendedPlayerController { - /** - * Sets the extra reach the player should have. - */ - public void setReachDistanceExtension(float f); + /** + * Sets the extra reach the player should have. + */ + public void setReachDistanceExtension(float f); - /** - * Gets the current reach extension. - */ - public float getReachDistanceExtension(); + /** + * Gets the current reach extension. + */ + public float getReachDistanceExtension(); } diff --git a/src/main/java/vazkii/botania/api/item/IExtendedWireframeCoordinateListProvider.java b/src/main/java/vazkii/botania/api/item/IExtendedWireframeCoordinateListProvider.java index 7713eaa5bf..7b8e05f6e9 100644 --- a/src/main/java/vazkii/botania/api/item/IExtendedWireframeCoordinateListProvider.java +++ b/src/main/java/vazkii/botania/api/item/IExtendedWireframeCoordinateListProvider.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Apr 30, 2015, 1:43:17 PM (GMT)] */ package vazkii.botania.api.item; @@ -20,9 +20,8 @@ */ public interface IExtendedWireframeCoordinateListProvider extends IWireframeCoordinateListProvider { - /** - * Gets the source wireframe to draw, this one will be drawn thicker. - */ - public ChunkCoordinates getSourceWireframe(EntityPlayer player, ItemStack stack); - + /** + * Gets the source wireframe to draw, this one will be drawn thicker. + */ + public ChunkCoordinates getSourceWireframe(EntityPlayer player, ItemStack stack); } diff --git a/src/main/java/vazkii/botania/api/item/IFlowerPlaceable.java b/src/main/java/vazkii/botania/api/item/IFlowerPlaceable.java index 05f1f1f406..db48ed1656 100644 --- a/src/main/java/vazkii/botania/api/item/IFlowerPlaceable.java +++ b/src/main/java/vazkii/botania/api/item/IFlowerPlaceable.java @@ -2,13 +2,14 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [17/11/2015, 20:10:53 (GMT)] */ package vazkii.botania.api.item; + import net.minecraft.block.Block; import net.minecraft.item.ItemStack; import vazkii.botania.api.subtile.SubTileEntity; @@ -18,10 +19,10 @@ */ public interface IFlowerPlaceable { - /** - * Gets the block to be placed, return null to not place anything. - */ - public Block getBlockToPlaceByFlower(ItemStack stack, SubTileEntity flower, int x, int y, int z); + /** + * Gets the block to be placed, return null to not place anything. + */ + public Block getBlockToPlaceByFlower(ItemStack stack, SubTileEntity flower, int x, int y, int z); - public void onBlockPlacedByFlower(ItemStack stack, SubTileEntity flower, int x, int y, int z); + public void onBlockPlacedByFlower(ItemStack stack, SubTileEntity flower, int x, int y, int z); } diff --git a/src/main/java/vazkii/botania/api/item/IFlowerlessBiome.java b/src/main/java/vazkii/botania/api/item/IFlowerlessBiome.java index 16543e4c9a..fe31fda143 100644 --- a/src/main/java/vazkii/botania/api/item/IFlowerlessBiome.java +++ b/src/main/java/vazkii/botania/api/item/IFlowerlessBiome.java @@ -9,13 +9,15 @@ * File Created @ [? (GMT)] */ package vazkii.botania.api.item; + import net.minecraft.world.World; + /** * A BiomeGenBase that implements this will not have Botania flowers generated. */ public interface IFlowerlessBiome { - /** - * @return Should this world be allowed to generate flowers? - */ - public boolean canGenerateFlowers(World world, int x, int z); -} \ No newline at end of file + /** + * @return Should this world be allowed to generate flowers? + */ + public boolean canGenerateFlowers(World world, int x, int z); +} diff --git a/src/main/java/vazkii/botania/api/item/IFlowerlessWorld.java b/src/main/java/vazkii/botania/api/item/IFlowerlessWorld.java index 5d25d7979d..414fb04944 100644 --- a/src/main/java/vazkii/botania/api/item/IFlowerlessWorld.java +++ b/src/main/java/vazkii/botania/api/item/IFlowerlessWorld.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [? (GMT)] */ package vazkii.botania.api.item; @@ -17,8 +17,8 @@ */ public interface IFlowerlessWorld { - /** - * @return Should this world be allowed to generate flowers? - */ - public boolean generateFlowers(World world); + /** + * @return Should this world be allowed to generate flowers? + */ + public boolean generateFlowers(World world); } diff --git a/src/main/java/vazkii/botania/api/item/IGrassHornExcempt.java b/src/main/java/vazkii/botania/api/item/IGrassHornExcempt.java index 601ad91132..2397617219 100644 --- a/src/main/java/vazkii/botania/api/item/IGrassHornExcempt.java +++ b/src/main/java/vazkii/botania/api/item/IGrassHornExcempt.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Oct 29, 2014, 4:52:04 PM (GMT)] */ package vazkii.botania.api.item; @@ -20,6 +20,5 @@ @Deprecated public interface IGrassHornExcempt { - public boolean canUproot(World world, int x, int y, int z); - + public boolean canUproot(World world, int x, int y, int z); } diff --git a/src/main/java/vazkii/botania/api/item/IHornHarvestable.java b/src/main/java/vazkii/botania/api/item/IHornHarvestable.java index a74af38dcb..e958360f25 100644 --- a/src/main/java/vazkii/botania/api/item/IHornHarvestable.java +++ b/src/main/java/vazkii/botania/api/item/IHornHarvestable.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Oct 24, 2015, 11:16:00 PM (GMT)] */ package vazkii.botania.api.item; @@ -18,47 +18,45 @@ */ public interface IHornHarvestable { - /** - * Returns true if this block can be uprooted. - * Note that the stack param can be null if it's a drum breaking it. - */ - public boolean canHornHarvest(World world, int x, int y, int z, ItemStack stack, EnumHornType hornType); - - /** - * Returns true if harvestByHorn() should be called. If false it just uses the normal - * block breaking method. - * Note that the stack param can be null if it's a drum breaking it. - */ - public boolean hasSpecialHornHarvest(World world, int x, int y, int z, ItemStack stack, EnumHornType hornType); - - /** - * Called to harvest by a horn. - * Note that the stack param can be null if it's a drum breaking it. - */ - public void harvestByHorn(World world, int x, int y, int z, ItemStack stack, EnumHornType hornType); - - public static enum EnumHornType { - - /** - * Horn of the Wild, for grass and crops - */ - WILD, - - /** - * Horn of the Canopy, for leaves - */ - CANOPY, - - /** - * Horn of the Covering, for snow - */ - COVERING; - - public static EnumHornType getTypeForMeta(int meta) { - EnumHornType[] values = EnumHornType.values(); - return values[Math.min(values.length - 1, meta)]; - } - - }; - + /** + * Returns true if this block can be uprooted. + * Note that the stack param can be null if it's a drum breaking it. + */ + public boolean canHornHarvest(World world, int x, int y, int z, ItemStack stack, EnumHornType hornType); + + /** + * Returns true if harvestByHorn() should be called. If false it just uses the normal + * block breaking method. + * Note that the stack param can be null if it's a drum breaking it. + */ + public boolean hasSpecialHornHarvest(World world, int x, int y, int z, ItemStack stack, EnumHornType hornType); + + /** + * Called to harvest by a horn. + * Note that the stack param can be null if it's a drum breaking it. + */ + public void harvestByHorn(World world, int x, int y, int z, ItemStack stack, EnumHornType hornType); + + public static enum EnumHornType { + + /** + * Horn of the Wild, for grass and crops + */ + WILD, + + /** + * Horn of the Canopy, for leaves + */ + CANOPY, + + /** + * Horn of the Covering, for snow + */ + COVERING; + + public static EnumHornType getTypeForMeta(int meta) { + EnumHornType[] values = EnumHornType.values(); + return values[Math.min(values.length - 1, meta)]; + } + }; } diff --git a/src/main/java/vazkii/botania/api/item/IManaDissolvable.java b/src/main/java/vazkii/botania/api/item/IManaDissolvable.java index 0d9ad5d4e7..5e8d210b32 100644 --- a/src/main/java/vazkii/botania/api/item/IManaDissolvable.java +++ b/src/main/java/vazkii/botania/api/item/IManaDissolvable.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jan 18, 2015, 12:10:00 AM (GMT)] */ package vazkii.botania.api.item; @@ -20,10 +20,9 @@ */ public interface IManaDissolvable { - /** - * Called for every tick the item is on a mana pool. If the stack has stack - * size 0 the item is killed. This is called in both the server and client. - */ - public void onDissolveTick(IManaPool pool, ItemStack stack, EntityItem item); - + /** + * Called for every tick the item is on a mana pool. If the stack has stack + * size 0 the item is killed. This is called in both the server and client. + */ + public void onDissolveTick(IManaPool pool, ItemStack stack, EntityItem item); } diff --git a/src/main/java/vazkii/botania/api/item/IManaProficiencyArmor.java b/src/main/java/vazkii/botania/api/item/IManaProficiencyArmor.java index 595e800dbb..cc7b3f61e7 100644 --- a/src/main/java/vazkii/botania/api/item/IManaProficiencyArmor.java +++ b/src/main/java/vazkii/botania/api/item/IManaProficiencyArmor.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Aug 28, 2015, 9:04:53 PM (GMT)] */ package vazkii.botania.api.item; @@ -23,22 +23,20 @@ */ public interface IManaProficiencyArmor { - public boolean shouldGiveProficiency(ItemStack stack, int slot, EntityPlayer player); + public boolean shouldGiveProficiency(ItemStack stack, int slot, EntityPlayer player); - public final static class Helper { - - public static boolean hasProficiency(EntityPlayer player) { - for(int i = 0; i < 4; i++) { - ItemStack armor = player.getCurrentArmor(i); - if(armor != null) { - Item item = armor.getItem(); - if(item instanceof IManaProficiencyArmor && ((IManaProficiencyArmor) item).shouldGiveProficiency(armor, i, player)) - return true; - } - } - return false; - } - - } + public static final class Helper { + public static boolean hasProficiency(EntityPlayer player) { + for (int i = 0; i < 4; i++) { + ItemStack armor = player.getCurrentArmor(i); + if (armor != null) { + Item item = armor.getItem(); + if (item instanceof IManaProficiencyArmor + && ((IManaProficiencyArmor) item).shouldGiveProficiency(armor, i, player)) return true; + } + } + return false; + } + } } diff --git a/src/main/java/vazkii/botania/api/item/IPetalApothecary.java b/src/main/java/vazkii/botania/api/item/IPetalApothecary.java index 15ae69c0be..184fc79fad 100644 --- a/src/main/java/vazkii/botania/api/item/IPetalApothecary.java +++ b/src/main/java/vazkii/botania/api/item/IPetalApothecary.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Aug 30, 2014, 4:22:15 PM (GMT)] */ package vazkii.botania.api.item; @@ -16,14 +16,13 @@ */ public interface IPetalApothecary { - /** - * Sets if the the apothecary has water or not. - */ - public void setWater(boolean water); - - /** - * Does the apothecary have water in it? - */ - public boolean hasWater(); + /** + * Sets if the the apothecary has water or not. + */ + public void setWater(boolean water); + /** + * Does the apothecary have water in it? + */ + public boolean hasWater(); } diff --git a/src/main/java/vazkii/botania/api/item/IPhantomInkable.java b/src/main/java/vazkii/botania/api/item/IPhantomInkable.java index dc2f397b0b..f633723609 100644 --- a/src/main/java/vazkii/botania/api/item/IPhantomInkable.java +++ b/src/main/java/vazkii/botania/api/item/IPhantomInkable.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Mar 17, 2015, 4:57:44 PM (GMT)] */ package vazkii.botania.api.item; @@ -17,8 +17,7 @@ */ public interface IPhantomInkable { - public boolean hasPhantomInk(ItemStack stack); - - public void setPhantomInk(ItemStack stack, boolean ink); + public boolean hasPhantomInk(ItemStack stack); + public void setPhantomInk(ItemStack stack, boolean ink); } diff --git a/src/main/java/vazkii/botania/api/item/IPixieSpawner.java b/src/main/java/vazkii/botania/api/item/IPixieSpawner.java index de8c9730d1..260341f5f6 100644 --- a/src/main/java/vazkii/botania/api/item/IPixieSpawner.java +++ b/src/main/java/vazkii/botania/api/item/IPixieSpawner.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Aug 6, 2014, 6:06:27 PM (GMT)] */ package vazkii.botania.api.item; @@ -20,10 +20,9 @@ */ public interface IPixieSpawner { - /** - * The chance this item adds for pixies to be spawned. From 0.0 to 1.0. All values - * are put together when calculating. - */ - public float getPixieChance(ItemStack stack); - -} \ No newline at end of file + /** + * The chance this item adds for pixies to be spawned. From 0.0 to 1.0. All values + * are put together when calculating. + */ + public float getPixieChance(ItemStack stack); +} diff --git a/src/main/java/vazkii/botania/api/item/IRelic.java b/src/main/java/vazkii/botania/api/item/IRelic.java index aecd1cde43..deeb9e1bcd 100644 --- a/src/main/java/vazkii/botania/api/item/IRelic.java +++ b/src/main/java/vazkii/botania/api/item/IRelic.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Mar 29, 2015, 7:17:41 PM (GMT)] */ package vazkii.botania.api.item; @@ -19,24 +19,23 @@ */ public interface IRelic { - /** - * Binds to the player name passed in. - */ - public void bindToUsername(String playerName, ItemStack stack); + /** + * Binds to the player name passed in. + */ + public void bindToUsername(String playerName, ItemStack stack); - /** - * Gets the username of the person this relic is bound to. - */ - public String getSoulbindUsername(ItemStack stack); + /** + * Gets the username of the person this relic is bound to. + */ + public String getSoulbindUsername(ItemStack stack); - /** - * Sets the achievement that this relic binds to. - */ - public void setBindAchievement(Achievement achievement); - - /** - * Gets the achievement that this relic binds to. - */ - public Achievement getBindAchievement(); + /** + * Sets the achievement that this relic binds to. + */ + public void setBindAchievement(Achievement achievement); + /** + * Gets the achievement that this relic binds to. + */ + public Achievement getBindAchievement(); } diff --git a/src/main/java/vazkii/botania/api/item/ISequentialBreaker.java b/src/main/java/vazkii/botania/api/item/ISequentialBreaker.java index 87af2d04db..a1eae9892e 100644 --- a/src/main/java/vazkii/botania/api/item/ISequentialBreaker.java +++ b/src/main/java/vazkii/botania/api/item/ISequentialBreaker.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Mar 30, 2015, 2:46:05 PM (GMT)] */ package vazkii.botania.api.item; @@ -20,8 +20,8 @@ */ public interface ISequentialBreaker { - public void breakOtherBlock(EntityPlayer player, ItemStack stack, int x, int y, int z, int originX, int originY, int originZ, int side); - - public boolean disposeOfTrashBlocks(ItemStack stack); + public void breakOtherBlock( + EntityPlayer player, ItemStack stack, int x, int y, int z, int originX, int originY, int originZ, int side); + public boolean disposeOfTrashBlocks(ItemStack stack); } diff --git a/src/main/java/vazkii/botania/api/item/ISortableTool.java b/src/main/java/vazkii/botania/api/item/ISortableTool.java index af450bceef..908e0adac0 100644 --- a/src/main/java/vazkii/botania/api/item/ISortableTool.java +++ b/src/main/java/vazkii/botania/api/item/ISortableTool.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Feb 23, 2015, 7:03:48 PM (GMT)] */ package vazkii.botania.api.item; @@ -18,30 +18,31 @@ */ public interface ISortableTool { - /** - * Gets the type of tool that this is. A pick, axe or shovel. - */ - public ToolType getSortingType(ItemStack stack); + /** + * Gets the type of tool that this is. A pick, axe or shovel. + */ + public ToolType getSortingType(ItemStack stack); - /** - * Gets the priority that this tool should have when being sorted. The - * tool with the highest priority will be picked. The way this is specified - * should be (tool-level) * 100 + (tool-modifier) * 10 + (efficiency-level). - *

- * For example, a Manasteel Pickaxe is tool-level 10 and it doesn't have - * modifiers. Assuming Efficiency 4, the priority should be 10 * 100 + 4 = 1004. - * This will rate higher than a similar pickaxe with Efficiency 3.
- * A Terra Shatterer has a modifier, its rank and is tool-level 20. With Efficiency - * 5 and rank B (2) the priority should be 20 * 100 + 2 * 10 + 5 = 2025. - *

- * All intermediate tool levels are there for other mod tools that wish to occupy the spots inbetween. - * Of course, you don't have to always adhere to this. Tools like the Vitreous Pickaxe don't, - * that one in particular is priority 0 so it's never picked. - */ - public int getSortingPriority(ItemStack stack); + /** + * Gets the priority that this tool should have when being sorted. The + * tool with the highest priority will be picked. The way this is specified + * should be (tool-level) * 100 + (tool-modifier) * 10 + (efficiency-level). + *

+ * For example, a Manasteel Pickaxe is tool-level 10 and it doesn't have + * modifiers. Assuming Efficiency 4, the priority should be 10 * 100 + 4 = 1004. + * This will rate higher than a similar pickaxe with Efficiency 3.
+ * A Terra Shatterer has a modifier, its rank and is tool-level 20. With Efficiency + * 5 and rank B (2) the priority should be 20 * 100 + 2 * 10 + 5 = 2025. + *

+ * All intermediate tool levels are there for other mod tools that wish to occupy the spots inbetween. + * Of course, you don't have to always adhere to this. Tools like the Vitreous Pickaxe don't, + * that one in particular is priority 0 so it's never picked. + */ + public int getSortingPriority(ItemStack stack); - public static enum ToolType { - PICK, AXE, SHOVEL - } - -} \ No newline at end of file + public static enum ToolType { + PICK, + AXE, + SHOVEL + } +} diff --git a/src/main/java/vazkii/botania/api/item/IWireframeCoordinateListProvider.java b/src/main/java/vazkii/botania/api/item/IWireframeCoordinateListProvider.java index ae0863ce7b..2bab862d2f 100644 --- a/src/main/java/vazkii/botania/api/item/IWireframeCoordinateListProvider.java +++ b/src/main/java/vazkii/botania/api/item/IWireframeCoordinateListProvider.java @@ -2,21 +2,20 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Mar 29, 2015, 11:30:41 PM (GMT)] */ package vazkii.botania.api.item; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; import java.util.List; - import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; import net.minecraft.util.ChunkCoordinates; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; /** * An item that implements this will allow for various wireframes to be drawn @@ -25,11 +24,10 @@ */ public interface IWireframeCoordinateListProvider { - /** - * Returns a list of ChunkCoordinates for the wireframes to draw. - * Can be null. - */ - @SideOnly(Side.CLIENT) - public List getWireframesToDraw(EntityPlayer player, ItemStack stack); - + /** + * Returns a list of ChunkCoordinates for the wireframes to draw. + * Can be null. + */ + @SideOnly(Side.CLIENT) + public List getWireframesToDraw(EntityPlayer player, ItemStack stack); } diff --git a/src/main/java/vazkii/botania/api/item/TinyPotatoRenderEvent.java b/src/main/java/vazkii/botania/api/item/TinyPotatoRenderEvent.java index 8b51c2634c..8974fa7ae6 100644 --- a/src/main/java/vazkii/botania/api/item/TinyPotatoRenderEvent.java +++ b/src/main/java/vazkii/botania/api/item/TinyPotatoRenderEvent.java @@ -2,18 +2,18 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jul 25, 2015, 8:02:41 PM (GMT)] */ package vazkii.botania.api.item; -import net.minecraft.tileentity.TileEntity; import cpw.mods.fml.common.eventhandler.Event; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; +import net.minecraft.tileentity.TileEntity; /** * Why would you ever want this ._. @@ -21,18 +21,17 @@ @SideOnly(Side.CLIENT) public class TinyPotatoRenderEvent extends Event { - public final TileEntity tile; - public final String name; - public final double x, y, z; - public final float partTicks; - - public TinyPotatoRenderEvent(TileEntity tile, String name, double x, double y, double z, float partTicks) { - this.tile = tile; - this.name = name; - this.x = x; - this.y = y; - this.z = z; - this.partTicks = partTicks; - } + public final TileEntity tile; + public final String name; + public final double x, y, z; + public final float partTicks; + public TinyPotatoRenderEvent(TileEntity tile, String name, double x, double y, double z, float partTicks) { + this.tile = tile; + this.name = name; + this.x = x; + this.y = y; + this.z = z; + this.partTicks = partTicks; + } } diff --git a/src/main/java/vazkii/botania/api/lexicon/BotaniaTutorialStartEvent.java b/src/main/java/vazkii/botania/api/lexicon/BotaniaTutorialStartEvent.java index c082572b8b..c03ea5b799 100644 --- a/src/main/java/vazkii/botania/api/lexicon/BotaniaTutorialStartEvent.java +++ b/src/main/java/vazkii/botania/api/lexicon/BotaniaTutorialStartEvent.java @@ -2,17 +2,16 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [04/12/2015, 18:29:56 (GMT)] */ package vazkii.botania.api.lexicon; -import java.util.Queue; - import cpw.mods.fml.common.eventhandler.Event; +import java.util.Queue; /** * Fired when the Lexica Botania's tutorial is started. You can add your @@ -20,10 +19,9 @@ */ public class BotaniaTutorialStartEvent extends Event { - public final Queue tutorial; - - public BotaniaTutorialStartEvent(Queue tutorial) { - this.tutorial = tutorial; - } + public final Queue tutorial; + public BotaniaTutorialStartEvent(Queue tutorial) { + this.tutorial = tutorial; + } } diff --git a/src/main/java/vazkii/botania/api/lexicon/IAddonEntry.java b/src/main/java/vazkii/botania/api/lexicon/IAddonEntry.java index a92e608c57..13225b8b4d 100644 --- a/src/main/java/vazkii/botania/api/lexicon/IAddonEntry.java +++ b/src/main/java/vazkii/botania/api/lexicon/IAddonEntry.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jun 8, 2014, 7:02:48 PM (GMT)] */ package vazkii.botania.api.lexicon; @@ -19,10 +19,9 @@ */ public interface IAddonEntry { - /** - * Returns the unlocalized subtitle to show below the title. Here you'd - * return something like "(This Entry is provided by the Botanic Tinkerer addon)". - */ - public String getSubtitle(); - + /** + * Returns the unlocalized subtitle to show below the title. Here you'd + * return something like "(This Entry is provided by the Botanic Tinkerer addon)". + */ + public String getSubtitle(); } diff --git a/src/main/java/vazkii/botania/api/lexicon/ILexicon.java b/src/main/java/vazkii/botania/api/lexicon/ILexicon.java index ee07e17fc0..925ee046d1 100644 --- a/src/main/java/vazkii/botania/api/lexicon/ILexicon.java +++ b/src/main/java/vazkii/botania/api/lexicon/ILexicon.java @@ -7,15 +7,14 @@ */ public interface ILexicon { - /** - * Gets if a specific knowledge is unlocked. Check the knowledge types in - * BotaniaAPI. - */ - public boolean isKnowledgeUnlocked(ItemStack stack, KnowledgeType knowledge); - - /** - * Unlocks a specfic type of knowledge. - */ - public void unlockKnowledge(ItemStack stack, KnowledgeType knowledge); + /** + * Gets if a specific knowledge is unlocked. Check the knowledge types in + * BotaniaAPI. + */ + public boolean isKnowledgeUnlocked(ItemStack stack, KnowledgeType knowledge); + /** + * Unlocks a specfic type of knowledge. + */ + public void unlockKnowledge(ItemStack stack, KnowledgeType knowledge); } diff --git a/src/main/java/vazkii/botania/api/lexicon/ILexiconable.java b/src/main/java/vazkii/botania/api/lexicon/ILexiconable.java index 5baff9f51d..b236773c24 100644 --- a/src/main/java/vazkii/botania/api/lexicon/ILexiconable.java +++ b/src/main/java/vazkii/botania/api/lexicon/ILexiconable.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jan 20, 2014, 7:05:44 PM (GMT)] */ package vazkii.botania.api.lexicon; @@ -20,9 +20,8 @@ */ public interface ILexiconable { - /** - * Gets the lexicon entry to open at this location. null works too. - */ - public LexiconEntry getEntry(World world, int x, int y, int z, EntityPlayer player, ItemStack lexicon); - + /** + * Gets the lexicon entry to open at this location. null works too. + */ + public LexiconEntry getEntry(World world, int x, int y, int z, EntityPlayer player, ItemStack lexicon); } diff --git a/src/main/java/vazkii/botania/api/lexicon/IRecipeKeyProvider.java b/src/main/java/vazkii/botania/api/lexicon/IRecipeKeyProvider.java index 5b0c0631f8..06249fe4d9 100644 --- a/src/main/java/vazkii/botania/api/lexicon/IRecipeKeyProvider.java +++ b/src/main/java/vazkii/botania/api/lexicon/IRecipeKeyProvider.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Mar 20, 2014, 6:08:48 PM (GMT)] */ package vazkii.botania.api.lexicon; @@ -18,6 +18,5 @@ */ public interface IRecipeKeyProvider { - public String getKey(ItemStack stack); - + public String getKey(ItemStack stack); } diff --git a/src/main/java/vazkii/botania/api/lexicon/ITwoNamedPage.java b/src/main/java/vazkii/botania/api/lexicon/ITwoNamedPage.java index 073b8704cd..1801a135c5 100644 --- a/src/main/java/vazkii/botania/api/lexicon/ITwoNamedPage.java +++ b/src/main/java/vazkii/botania/api/lexicon/ITwoNamedPage.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Nov 3, 2014, 2:59:55 PM (GMT)] */ package vazkii.botania.api.lexicon; @@ -16,8 +16,7 @@ */ public interface ITwoNamedPage { - public void setSecondUnlocalizedName(String name); - - public String getSecondUnlocalizedName(); + public void setSecondUnlocalizedName(String name); + public String getSecondUnlocalizedName(); } diff --git a/src/main/java/vazkii/botania/api/lexicon/KnowledgeType.java b/src/main/java/vazkii/botania/api/lexicon/KnowledgeType.java index 5a08c9ceb4..0104b04115 100644 --- a/src/main/java/vazkii/botania/api/lexicon/KnowledgeType.java +++ b/src/main/java/vazkii/botania/api/lexicon/KnowledgeType.java @@ -4,17 +4,17 @@ public class KnowledgeType { - public final String id; - public final EnumChatFormatting color; - public final boolean autoUnlock; + public final String id; + public final EnumChatFormatting color; + public final boolean autoUnlock; - public KnowledgeType(String id, EnumChatFormatting color, boolean autoUnlock) { - this.id = id; - this.color = color; - this.autoUnlock = autoUnlock; - } + public KnowledgeType(String id, EnumChatFormatting color, boolean autoUnlock) { + this.id = id; + this.color = color; + this.autoUnlock = autoUnlock; + } - public String getUnlocalizedName() { - return "botania.knowledge." + id; - } + public String getUnlocalizedName() { + return "botania.knowledge." + id; + } } diff --git a/src/main/java/vazkii/botania/api/lexicon/LexiconCategory.java b/src/main/java/vazkii/botania/api/lexicon/LexiconCategory.java index 06f678d0d6..8e9ef29e4c 100644 --- a/src/main/java/vazkii/botania/api/lexicon/LexiconCategory.java +++ b/src/main/java/vazkii/botania/api/lexicon/LexiconCategory.java @@ -2,75 +2,74 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jan 14, 2014, 6:23:47 PM (GMT)] */ package vazkii.botania.api.lexicon; import java.util.ArrayList; import java.util.List; - import net.minecraft.util.ResourceLocation; public class LexiconCategory implements Comparable { - private static int count = 0; + private static int count = 0; - public final String unlocalizedName; - public final List entries = new ArrayList(); - private final int sortingId; - private ResourceLocation icon; - private int priority = 5; + public final String unlocalizedName; + public final List entries = new ArrayList(); + private final int sortingId; + private ResourceLocation icon; + private int priority = 5; - /** - * @param unlocalizedName The unlocalized name of this category. This will be localized by the client display. - */ - public LexiconCategory(String unlocalizedName) { - this.unlocalizedName = unlocalizedName; - sortingId = count; - count++; - } + /** + * @param unlocalizedName The unlocalized name of this category. This will be localized by the client display. + */ + public LexiconCategory(String unlocalizedName) { + this.unlocalizedName = unlocalizedName; + sortingId = count; + count++; + } - public String getUnlocalizedName() { - return unlocalizedName; - } + public String getUnlocalizedName() { + return unlocalizedName; + } - /** - * Sets the priority for this category for sorting. Higher numbers - * means they'll appear first in the book. The basics category - * is 9, the miscellaneous category is 0, other vanilla botania categories - * are 5. Using 9 and 0 is not recommended, since having your - * categories before basics or after miscellaneous is a bad idea. - * If two categories have the same priority they'll be sorted - * by insertion order. - */ - public LexiconCategory setPriority(int priority) { - this.priority = priority; - return this; - } + /** + * Sets the priority for this category for sorting. Higher numbers + * means they'll appear first in the book. The basics category + * is 9, the miscellaneous category is 0, other vanilla botania categories + * are 5. Using 9 and 0 is not recommended, since having your + * categories before basics or after miscellaneous is a bad idea. + * If two categories have the same priority they'll be sorted + * by insertion order. + */ + public LexiconCategory setPriority(int priority) { + this.priority = priority; + return this; + } - public int getSortingPriority() { - return priority; - } + public int getSortingPriority() { + return priority; + } - public final int getSortingId() { - return sortingId; - } + public final int getSortingId() { + return sortingId; + } - public LexiconCategory setIcon(ResourceLocation icon) { - this.icon = icon; - return this; - } + public LexiconCategory setIcon(ResourceLocation icon) { + this.icon = icon; + return this; + } - public ResourceLocation getIcon() { - return icon; - } + public ResourceLocation getIcon() { + return icon; + } - @Override - public int compareTo(LexiconCategory category) { - return priority == category.priority ? sortingId - category.sortingId : category.priority - priority; - } + @Override + public int compareTo(LexiconCategory category) { + return priority == category.priority ? sortingId - category.sortingId : category.priority - priority; + } } diff --git a/src/main/java/vazkii/botania/api/lexicon/LexiconEntry.java b/src/main/java/vazkii/botania/api/lexicon/LexiconEntry.java index 2bc025065f..93f79d5ce9 100644 --- a/src/main/java/vazkii/botania/api/lexicon/LexiconEntry.java +++ b/src/main/java/vazkii/botania/api/lexicon/LexiconEntry.java @@ -2,165 +2,160 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jan 14, 2014, 6:17:06 PM (GMT)] */ package vazkii.botania.api.lexicon; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; import java.util.ArrayList; import java.util.Arrays; import java.util.List; - import net.minecraft.item.ItemStack; import net.minecraft.util.StatCollector; import vazkii.botania.api.BotaniaAPI; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; public class LexiconEntry implements Comparable { - public final String unlocalizedName; - public final LexiconCategory category; - - private KnowledgeType type = BotaniaAPI.basicKnowledge; - - public List pages = new ArrayList(); - private boolean priority = false; - private ItemStack icon = null; - - private List extraDisplayedRecipes = new ArrayList(); - - /** - * @param unlocalizedName The unlocalized name of this entry. This will be localized by the client display. - */ - public LexiconEntry(String unlocalizedName, LexiconCategory category) { - this.unlocalizedName = unlocalizedName; - this.category = category; - } - - /** - * Sets this page as prioritized, as in, will appear before others in the lexicon. - */ - public LexiconEntry setPriority() { - priority = true; - return this; - } - - /** - * Sets the Knowledge type of this entry. - */ - public LexiconEntry setKnowledgeType(KnowledgeType type) { - this.type = type; - return this; - } - - public KnowledgeType getKnowledgeType() { - return type; - } - - /** - * Sets the display icon for this entry. Overriding the one already there. When adding recipe pages to the - * entry, this will be called once for the result of the first found recipe. - */ - public void setIcon(ItemStack stack) { - icon = stack; - } - - public ItemStack getIcon() { - return icon; - } - - public boolean isPriority() { - return priority; - } - - public String getUnlocalizedName() { - return unlocalizedName; - } - - public String getTagline() { - return null; // Override this if you want a tagline. You probably do - } - - @SideOnly(Side.CLIENT) - public boolean isVisible() { - return true; - } - - /** - * Sets what pages you want this entry to have. - */ - public LexiconEntry setLexiconPages(LexiconPage... pages) { - this.pages.addAll(Arrays.asList(pages)); - - for(int i = 0; i < this.pages.size(); i++) { - LexiconPage page = this.pages.get(i); - if(!page.skipRegistry) - page.onPageAdded(this, i); - } - - return this; - } - - /** - * Returns the web link for this entry. If this isn't null, looking at this entry will - * show a "View Online" button in the book. The String returned should be the URL to - * open when the button is clicked. - */ - public String getWebLink() { - return null; - } - - /** - * Adds a page to the list of pages. - */ - public void addPage(LexiconPage page) { - pages.add(page); - } - - public final String getNameForSorting() { - return (priority ? 0 : 1) + StatCollector.translateToLocal(getUnlocalizedName()); - } - - public List getDisplayedRecipes() { - ArrayList list = new ArrayList(); - for(LexiconPage page : pages) { - List l = page.getDisplayedRecipes(); - - if(l != null) { - ArrayList itemsAddedThisPage = new ArrayList(); - - for(ItemStack s : l) { - addItem: { - for(ItemStack s1 : itemsAddedThisPage) - if(s1.getItem() == s.getItem()) - break addItem; - for(ItemStack s1 : list) - if(s1.isItemEqual(s) && ItemStack.areItemStackTagsEqual(s1, s)) - break addItem; - - itemsAddedThisPage.add(s); - list.add(s); - } - } - } - } - - list.addAll(extraDisplayedRecipes); - - return list; - } - - public void addExtraDisplayedRecipe(ItemStack stack) { - extraDisplayedRecipes.add(stack); - } - - @Override - public int compareTo(LexiconEntry o) { - return getNameForSorting().compareTo(o.getNameForSorting()); - } - -} \ No newline at end of file + public final String unlocalizedName; + public final LexiconCategory category; + + private KnowledgeType type = BotaniaAPI.basicKnowledge; + + public List pages = new ArrayList(); + private boolean priority = false; + private ItemStack icon = null; + + private List extraDisplayedRecipes = new ArrayList(); + + /** + * @param unlocalizedName The unlocalized name of this entry. This will be localized by the client display. + */ + public LexiconEntry(String unlocalizedName, LexiconCategory category) { + this.unlocalizedName = unlocalizedName; + this.category = category; + } + + /** + * Sets this page as prioritized, as in, will appear before others in the lexicon. + */ + public LexiconEntry setPriority() { + priority = true; + return this; + } + + /** + * Sets the Knowledge type of this entry. + */ + public LexiconEntry setKnowledgeType(KnowledgeType type) { + this.type = type; + return this; + } + + public KnowledgeType getKnowledgeType() { + return type; + } + + /** + * Sets the display icon for this entry. Overriding the one already there. When adding recipe pages to the + * entry, this will be called once for the result of the first found recipe. + */ + public void setIcon(ItemStack stack) { + icon = stack; + } + + public ItemStack getIcon() { + return icon; + } + + public boolean isPriority() { + return priority; + } + + public String getUnlocalizedName() { + return unlocalizedName; + } + + public String getTagline() { + return null; // Override this if you want a tagline. You probably do + } + + @SideOnly(Side.CLIENT) + public boolean isVisible() { + return true; + } + + /** + * Sets what pages you want this entry to have. + */ + public LexiconEntry setLexiconPages(LexiconPage... pages) { + this.pages.addAll(Arrays.asList(pages)); + + for (int i = 0; i < this.pages.size(); i++) { + LexiconPage page = this.pages.get(i); + if (!page.skipRegistry) page.onPageAdded(this, i); + } + + return this; + } + + /** + * Returns the web link for this entry. If this isn't null, looking at this entry will + * show a "View Online" button in the book. The String returned should be the URL to + * open when the button is clicked. + */ + public String getWebLink() { + return null; + } + + /** + * Adds a page to the list of pages. + */ + public void addPage(LexiconPage page) { + pages.add(page); + } + + public final String getNameForSorting() { + return (priority ? 0 : 1) + StatCollector.translateToLocal(getUnlocalizedName()); + } + + public List getDisplayedRecipes() { + ArrayList list = new ArrayList(); + for (LexiconPage page : pages) { + List l = page.getDisplayedRecipes(); + + if (l != null) { + ArrayList itemsAddedThisPage = new ArrayList(); + + for (ItemStack s : l) { + addItem: + { + for (ItemStack s1 : itemsAddedThisPage) if (s1.getItem() == s.getItem()) break addItem; + for (ItemStack s1 : list) + if (s1.isItemEqual(s) && ItemStack.areItemStackTagsEqual(s1, s)) break addItem; + + itemsAddedThisPage.add(s); + list.add(s); + } + } + } + } + + list.addAll(extraDisplayedRecipes); + + return list; + } + + public void addExtraDisplayedRecipe(ItemStack stack) { + extraDisplayedRecipes.add(stack); + } + + @Override + public int compareTo(LexiconEntry o) { + return getNameForSorting().compareTo(o.getNameForSorting()); + } +} diff --git a/src/main/java/vazkii/botania/api/lexicon/LexiconPage.java b/src/main/java/vazkii/botania/api/lexicon/LexiconPage.java index 9880b9e9e9..3c22b665cd 100644 --- a/src/main/java/vazkii/botania/api/lexicon/LexiconPage.java +++ b/src/main/java/vazkii/botania/api/lexicon/LexiconPage.java @@ -2,112 +2,111 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jan 14, 2014, 6:17:24 PM (GMT)] */ package vazkii.botania.api.lexicon; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; import java.util.List; - import net.minecraft.client.gui.GuiButton; import net.minecraft.item.ItemStack; import vazkii.botania.api.internal.IGuiLexiconEntry; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; public abstract class LexiconPage { - public String unlocalizedName; - public boolean skipRegistry; - - public LexiconPage(String unlocalizedName) { - this.unlocalizedName = unlocalizedName; - } - - /** - * Does the rendering for this page. - * @param gui The active GuiScreen - * @param mx The mouse's relative X position. - * @param my The mouse's relative Y position. - */ - @SideOnly(Side.CLIENT) - public abstract void renderScreen(IGuiLexiconEntry gui, int mx, int my); - - /** - * Called per update tick. Non gui-sensitive version, kept for backwards compatibility only. - */ - @SideOnly(Side.CLIENT) - public void updateScreen() { - // NO-OP - } - - /** - * Called per update tick. Feel free to override fully, the - * call to updateScreen() is for backwards compatibility. - */ - @SideOnly(Side.CLIENT) - public void updateScreen(IGuiLexiconEntry gui) { - updateScreen(); - } - - /** - * Called when this page is opened, be it via initGui() or when the player changes page. - * You can add buttons and whatever you'd do on initGui() here. - */ - @SideOnly(Side.CLIENT) - public void onOpened(IGuiLexiconEntry gui) { - // NO-OP - } - - /** - * Called when this page is opened, be it via closing the gui or when the player changes page. - * Make sure to dispose of anything you don't use any more, such as buttons in the gui's buttonList. - */ - @SideOnly(Side.CLIENT) - public void onClosed(IGuiLexiconEntry gui) { - // NO-OP - } - - /** - * Called when a button is pressed, equivalent to GuiScreen.actionPerformed. - */ - @SideOnly(Side.CLIENT) - public void onActionPerformed(IGuiLexiconEntry gui, GuiButton button) { - // NO-OP - } - - /** - * Called when a key is pressed. - */ - @SideOnly(Side.CLIENT) - public void onKeyPressed(char c, int key) { - // NO-OP - } - - /** - * Called when {@link LexiconEntry#setLexiconPages(LexiconPage...)} is called. - */ - public void onPageAdded(LexiconEntry entry, int index) { - // NO-OP - } - - /** - * Shows the list of recipes present in this page for display in the category - * page. Can return null for an entry with no recipes. - */ - public List getDisplayedRecipes() { - return null; - } - - public String getUnlocalizedName() { - return unlocalizedName; - } - - public LexiconPage setSkipRegistry() { - skipRegistry = true; - return this; - } + public String unlocalizedName; + public boolean skipRegistry; + + public LexiconPage(String unlocalizedName) { + this.unlocalizedName = unlocalizedName; + } + + /** + * Does the rendering for this page. + * @param gui The active GuiScreen + * @param mx The mouse's relative X position. + * @param my The mouse's relative Y position. + */ + @SideOnly(Side.CLIENT) + public abstract void renderScreen(IGuiLexiconEntry gui, int mx, int my); + + /** + * Called per update tick. Non gui-sensitive version, kept for backwards compatibility only. + */ + @SideOnly(Side.CLIENT) + public void updateScreen() { + // NO-OP + } + + /** + * Called per update tick. Feel free to override fully, the + * call to updateScreen() is for backwards compatibility. + */ + @SideOnly(Side.CLIENT) + public void updateScreen(IGuiLexiconEntry gui) { + updateScreen(); + } + + /** + * Called when this page is opened, be it via initGui() or when the player changes page. + * You can add buttons and whatever you'd do on initGui() here. + */ + @SideOnly(Side.CLIENT) + public void onOpened(IGuiLexiconEntry gui) { + // NO-OP + } + + /** + * Called when this page is opened, be it via closing the gui or when the player changes page. + * Make sure to dispose of anything you don't use any more, such as buttons in the gui's buttonList. + */ + @SideOnly(Side.CLIENT) + public void onClosed(IGuiLexiconEntry gui) { + // NO-OP + } + + /** + * Called when a button is pressed, equivalent to GuiScreen.actionPerformed. + */ + @SideOnly(Side.CLIENT) + public void onActionPerformed(IGuiLexiconEntry gui, GuiButton button) { + // NO-OP + } + + /** + * Called when a key is pressed. + */ + @SideOnly(Side.CLIENT) + public void onKeyPressed(char c, int key) { + // NO-OP + } + + /** + * Called when {@link LexiconEntry#setLexiconPages(LexiconPage...)} is called. + */ + public void onPageAdded(LexiconEntry entry, int index) { + // NO-OP + } + + /** + * Shows the list of recipes present in this page for display in the category + * page. Can return null for an entry with no recipes. + */ + public List getDisplayedRecipes() { + return null; + } + + public String getUnlocalizedName() { + return unlocalizedName; + } + + public LexiconPage setSkipRegistry() { + skipRegistry = true; + return this; + } } diff --git a/src/main/java/vazkii/botania/api/lexicon/LexiconRecipeMappings.java b/src/main/java/vazkii/botania/api/lexicon/LexiconRecipeMappings.java index 8202a40a79..fa8a581e52 100644 --- a/src/main/java/vazkii/botania/api/lexicon/LexiconRecipeMappings.java +++ b/src/main/java/vazkii/botania/api/lexicon/LexiconRecipeMappings.java @@ -2,17 +2,16 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Mar 6, 2014, 3:54:12 PM (GMT)] */ package vazkii.botania.api.lexicon; import java.util.HashMap; import java.util.Map; - import net.minecraft.item.ItemStack; import vazkii.botania.api.mana.IManaItem; @@ -23,56 +22,52 @@ */ public final class LexiconRecipeMappings { - private static Map mappings = new HashMap(); + private static Map mappings = new HashMap(); + + /** + * Maps the given stack to the given page of the entry. + */ + public static void map(ItemStack stack, LexiconEntry entry, int page, boolean force) { + EntryData data = new EntryData(entry, page); + String str = stackToString(stack); - /** - * Maps the given stack to the given page of the entry. - */ - public static void map(ItemStack stack, LexiconEntry entry, int page, boolean force) { - EntryData data = new EntryData(entry, page); - String str = stackToString(stack); + if (force || !mappings.containsKey(str)) mappings.put(str, data); + if (entry.getIcon() == null) entry.setIcon(stack.copy()); + } - if(force || !mappings.containsKey(str)) - mappings.put(str, data); - if(entry.getIcon() == null) - entry.setIcon(stack.copy()); - } + public static void map(ItemStack stack, LexiconEntry entry, int page) { + map(stack, entry, page, false); + } - public static void map(ItemStack stack, LexiconEntry entry, int page) { - map(stack, entry, page, false); - } + public static void remove(ItemStack stack) { + mappings.remove(stackToString(stack)); + } - public static void remove(ItemStack stack) { - mappings.remove(stackToString(stack)); - } + public static EntryData getDataForStack(ItemStack stack) { + return mappings.get(stackToString(stack)); + } - public static EntryData getDataForStack(ItemStack stack) { - return mappings.get(stackToString(stack)); - } - - public static String stackToString(ItemStack stack) { - if(stack == null || stack.getItem() == null) - return "NULL"; - - if(stack.hasTagCompound() && stack.getItem() instanceof IRecipeKeyProvider) - return ((IRecipeKeyProvider) stack.getItem()).getKey(stack); + public static String stackToString(ItemStack stack) { + if (stack == null || stack.getItem() == null) return "NULL"; - return stack.getUnlocalizedName() + (ignoreMeta(stack) ? "" : "~" + stack.getItemDamage()); - } + if (stack.hasTagCompound() && stack.getItem() instanceof IRecipeKeyProvider) + return ((IRecipeKeyProvider) stack.getItem()).getKey(stack); - public static boolean ignoreMeta(ItemStack stack) { - return stack.isItemStackDamageable() || stack.getItem() instanceof IManaItem; - } + return stack.getUnlocalizedName() + (ignoreMeta(stack) ? "" : "~" + stack.getItemDamage()); + } - public static class EntryData { + public static boolean ignoreMeta(ItemStack stack) { + return stack.isItemStackDamageable() || stack.getItem() instanceof IManaItem; + } - public final LexiconEntry entry; - public final int page; + public static class EntryData { - public EntryData(LexiconEntry entry, int page) { - this.entry = entry; - this.page = page; - } + public final LexiconEntry entry; + public final int page; - } + public EntryData(LexiconEntry entry, int page) { + this.entry = entry; + this.page = page; + } + } } diff --git a/src/main/java/vazkii/botania/api/lexicon/multiblock/IMultiblockRenderHook.java b/src/main/java/vazkii/botania/api/lexicon/multiblock/IMultiblockRenderHook.java index 9d05c40d94..0e20e5717d 100644 --- a/src/main/java/vazkii/botania/api/lexicon/multiblock/IMultiblockRenderHook.java +++ b/src/main/java/vazkii/botania/api/lexicon/multiblock/IMultiblockRenderHook.java @@ -2,17 +2,16 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jun 27, 2015, 7:48:47 PM (GMT)] */ package vazkii.botania.api.lexicon.multiblock; import java.util.HashMap; import java.util.Map; - import net.minecraft.block.Block; import net.minecraft.client.renderer.RenderBlocks; import net.minecraft.world.IBlockAccess; @@ -23,10 +22,16 @@ */ public interface IMultiblockRenderHook { - public static Map renderHooks = new HashMap(); - - public void renderBlockForMultiblock(IBlockAccess world, Multiblock mb, Block block, int meta, RenderBlocks renderBlocks, MultiblockComponent comp, float alpha); + public static Map renderHooks = new HashMap(); - public boolean needsTranslate(Block block); + public void renderBlockForMultiblock( + IBlockAccess world, + Multiblock mb, + Block block, + int meta, + RenderBlocks renderBlocks, + MultiblockComponent comp, + float alpha); + public boolean needsTranslate(Block block); } diff --git a/src/main/java/vazkii/botania/api/lexicon/multiblock/Multiblock.java b/src/main/java/vazkii/botania/api/lexicon/multiblock/Multiblock.java index 4cf34b8582..0e73930125 100644 --- a/src/main/java/vazkii/botania/api/lexicon/multiblock/Multiblock.java +++ b/src/main/java/vazkii/botania/api/lexicon/multiblock/Multiblock.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jun 27, 2015, 2:37:22 PM (GMT)] */ package vazkii.botania.api.lexicon.multiblock; @@ -14,7 +14,6 @@ import java.util.Arrays; import java.util.HashMap; import java.util.List; - import net.minecraft.block.Block; import net.minecraft.item.ItemStack; import net.minecraft.util.ChunkCoordinates; @@ -27,162 +26,147 @@ */ public class Multiblock { - public List components = new ArrayList(); - public List materials = new ArrayList(); - - public int minX, minY, minZ, maxX, maxY, maxZ, offX, offY, offZ; - - public HashMap, MultiblockComponent> locationCache = new HashMap, MultiblockComponent>(); - - /** - * Adds a multiblock component to this multiblock. The component's x y z - * coords should be pivoted to the center of the structure. - */ - public void addComponent(MultiblockComponent component) { - if(getComponentForLocation(component.relPos.posX, component.relPos.posY, component.relPos.posZ) != null) - throw new IllegalArgumentException("Location in multiblock already occupied"); - components.add(component); - changeAxisForNewComponent(component.relPos.posX, component.relPos.posY, component.relPos.posZ); - calculateCostForNewComponent(component); - addComponentToLocationCache(component); - } - - /** - * Constructs and adds a multiblock component to this multiblock. The x y z - * coords should be pivoted to the center of the structure. - */ - public void addComponent(int x, int y, int z, Block block, int meta) { - addComponent(new MultiblockComponent(new ChunkCoordinates(x, y, z), block, meta)); - } - - private void changeAxisForNewComponent(int x, int y, int z) { - if(x < minX) - minX = x; - else if(x > maxX) - maxX = x; - - if(y < minY) - minY = y; - else if(y > maxY) - maxY = y; - - if(z < minZ) - minZ = z; - else if(z > maxZ) - maxZ = z; - } - - private void calculateCostForNewComponent(MultiblockComponent comp) { - ItemStack[] materials = comp.getMaterials(); - if(materials != null) - for(ItemStack stack : materials) - addStack(stack); - } - - private void addStack(ItemStack stack) { - if(stack == null) - return; - - for(ItemStack oStack : materials) - if(oStack.isItemEqual(stack) && ItemStack.areItemStackTagsEqual(oStack, stack)) { - oStack.stackSize += stack.stackSize; - return; - } - - materials.add(stack); - } - - public void setRenderOffset(int x, int y, int z) { - offX = x; - offY = y; - offZ = z; - } - - public List getComponents() { - return components; - } - - /** - * Rotates this multiblock by the angle passed in. For the best results, use - * only multiples of pi/2. - */ - public void rotate(double angle) { - for(MultiblockComponent comp : getComponents()) - comp.rotate(angle); - updateLocationCache(); - } - - public Multiblock copy() { - Multiblock mb = new Multiblock(); - for(MultiblockComponent comp : getComponents()) - mb.addComponent(comp.copy()); - - return mb; - } - - /** - * Creates a length 4 array of all the rotations multiple of pi/2 required - * to render this multiblock in the world relevant to the 4 cardinal - * orientations. - */ - public Multiblock[] createRotations() { - Multiblock[] blocks = new Multiblock[4]; - blocks[0] = this; - blocks[1] = blocks[0].copy(); - blocks[1].rotate(Math.PI / 2); - blocks[2] = blocks[1].copy(); - blocks[2].rotate(Math.PI / 2); - blocks[3] = blocks[2].copy(); - blocks[3].rotate(Math.PI / 2); - - return blocks; - } - - /** - * Makes a MultiblockSet from this Multiblock and its rotations using - * createRotations(). - */ - public MultiblockSet makeSet() { - return new MultiblockSet(this); - } - - public int getXSize() { - return Math.abs(minX) + Math.abs(maxX) + 1; - } - - public int getYSize() { - return Math.abs(minY) + Math.abs(maxY) + 1; - } - - public int getZSize() { - return Math.abs(minZ) + Math.abs(maxZ) + 1; - } - - /** - * Rebuilds the location cache - */ - public void updateLocationCache() { - locationCache.clear(); - for(MultiblockComponent comp : components) - addComponentToLocationCache(comp); - } - - /** - * Adds a single component to the location cache - */ - private void addComponentToLocationCache(MultiblockComponent comp) { - ChunkCoordinates pos = comp.getRelativePosition(); - locationCache.put(Arrays.asList( - pos.posX, - pos.posY, - pos.posZ - ), comp); - } - - /** - * Gets the component for a given location - */ - public MultiblockComponent getComponentForLocation(int x, int y, int z) { - return locationCache.get(Arrays.asList(x, y, z)); - } + public List components = new ArrayList(); + public List materials = new ArrayList(); + + public int minX, minY, minZ, maxX, maxY, maxZ, offX, offY, offZ; + + public HashMap, MultiblockComponent> locationCache = + new HashMap, MultiblockComponent>(); + + /** + * Adds a multiblock component to this multiblock. The component's x y z + * coords should be pivoted to the center of the structure. + */ + public void addComponent(MultiblockComponent component) { + if (getComponentForLocation(component.relPos.posX, component.relPos.posY, component.relPos.posZ) != null) + throw new IllegalArgumentException("Location in multiblock already occupied"); + components.add(component); + changeAxisForNewComponent(component.relPos.posX, component.relPos.posY, component.relPos.posZ); + calculateCostForNewComponent(component); + addComponentToLocationCache(component); + } + + /** + * Constructs and adds a multiblock component to this multiblock. The x y z + * coords should be pivoted to the center of the structure. + */ + public void addComponent(int x, int y, int z, Block block, int meta) { + addComponent(new MultiblockComponent(new ChunkCoordinates(x, y, z), block, meta)); + } + + private void changeAxisForNewComponent(int x, int y, int z) { + if (x < minX) minX = x; + else if (x > maxX) maxX = x; + + if (y < minY) minY = y; + else if (y > maxY) maxY = y; + + if (z < minZ) minZ = z; + else if (z > maxZ) maxZ = z; + } + + private void calculateCostForNewComponent(MultiblockComponent comp) { + ItemStack[] materials = comp.getMaterials(); + if (materials != null) for (ItemStack stack : materials) addStack(stack); + } + + private void addStack(ItemStack stack) { + if (stack == null) return; + + for (ItemStack oStack : materials) + if (oStack.isItemEqual(stack) && ItemStack.areItemStackTagsEqual(oStack, stack)) { + oStack.stackSize += stack.stackSize; + return; + } + + materials.add(stack); + } + + public void setRenderOffset(int x, int y, int z) { + offX = x; + offY = y; + offZ = z; + } + + public List getComponents() { + return components; + } + + /** + * Rotates this multiblock by the angle passed in. For the best results, use + * only multiples of pi/2. + */ + public void rotate(double angle) { + for (MultiblockComponent comp : getComponents()) comp.rotate(angle); + updateLocationCache(); + } + + public Multiblock copy() { + Multiblock mb = new Multiblock(); + for (MultiblockComponent comp : getComponents()) mb.addComponent(comp.copy()); + + return mb; + } + + /** + * Creates a length 4 array of all the rotations multiple of pi/2 required + * to render this multiblock in the world relevant to the 4 cardinal + * orientations. + */ + public Multiblock[] createRotations() { + Multiblock[] blocks = new Multiblock[4]; + blocks[0] = this; + blocks[1] = blocks[0].copy(); + blocks[1].rotate(Math.PI / 2); + blocks[2] = blocks[1].copy(); + blocks[2].rotate(Math.PI / 2); + blocks[3] = blocks[2].copy(); + blocks[3].rotate(Math.PI / 2); + + return blocks; + } + + /** + * Makes a MultiblockSet from this Multiblock and its rotations using + * createRotations(). + */ + public MultiblockSet makeSet() { + return new MultiblockSet(this); + } + + public int getXSize() { + return Math.abs(minX) + Math.abs(maxX) + 1; + } + + public int getYSize() { + return Math.abs(minY) + Math.abs(maxY) + 1; + } + + public int getZSize() { + return Math.abs(minZ) + Math.abs(maxZ) + 1; + } + + /** + * Rebuilds the location cache + */ + public void updateLocationCache() { + locationCache.clear(); + for (MultiblockComponent comp : components) addComponentToLocationCache(comp); + } + + /** + * Adds a single component to the location cache + */ + private void addComponentToLocationCache(MultiblockComponent comp) { + ChunkCoordinates pos = comp.getRelativePosition(); + locationCache.put(Arrays.asList(pos.posX, pos.posY, pos.posZ), comp); + } + + /** + * Gets the component for a given location + */ + public MultiblockComponent getComponentForLocation(int x, int y, int z) { + return locationCache.get(Arrays.asList(x, y, z)); + } } diff --git a/src/main/java/vazkii/botania/api/lexicon/multiblock/MultiblockSet.java b/src/main/java/vazkii/botania/api/lexicon/multiblock/MultiblockSet.java index c0435f81e1..1fb57345f7 100644 --- a/src/main/java/vazkii/botania/api/lexicon/multiblock/MultiblockSet.java +++ b/src/main/java/vazkii/botania/api/lexicon/multiblock/MultiblockSet.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jun 27, 2015, 7:31:58 PM (GMT)] */ package vazkii.botania.api.lexicon.multiblock; @@ -18,26 +18,26 @@ */ public class MultiblockSet { - private final Multiblock[] mbs; + private final Multiblock[] mbs; - public MultiblockSet(Multiblock[] mbs) { - this.mbs = mbs; - } + public MultiblockSet(Multiblock[] mbs) { + this.mbs = mbs; + } - public MultiblockSet(Multiblock mb) { - this(mb.createRotations()); - } + public MultiblockSet(Multiblock mb) { + this(mb.createRotations()); + } - public Multiblock getForEntity(Entity e) { - return getForRotation(e.rotationYaw); - } + public Multiblock getForEntity(Entity e) { + return getForRotation(e.rotationYaw); + } - public Multiblock getForRotation(double rotation) { - int facing = MathHelper.floor_double(rotation * 4.0 / 360.0 + 0.5) & 3; - return getForIndex(facing); - } + public Multiblock getForRotation(double rotation) { + int facing = MathHelper.floor_double(rotation * 4.0 / 360.0 + 0.5) & 3; + return getForIndex(facing); + } - public Multiblock getForIndex(int index) { - return mbs[Math.min(mbs.length - 1, index)]; - } + public Multiblock getForIndex(int index) { + return mbs[Math.min(mbs.length - 1, index)]; + } } diff --git a/src/main/java/vazkii/botania/api/lexicon/multiblock/component/AnyComponent.java b/src/main/java/vazkii/botania/api/lexicon/multiblock/component/AnyComponent.java index f7a159b20b..ac99056123 100644 --- a/src/main/java/vazkii/botania/api/lexicon/multiblock/component/AnyComponent.java +++ b/src/main/java/vazkii/botania/api/lexicon/multiblock/component/AnyComponent.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [01/11/2015, 19:05:57 (GMT)] */ package vazkii.botania.api.lexicon.multiblock.component; @@ -19,14 +19,13 @@ */ public class AnyComponent extends MultiblockComponent { - public AnyComponent(ChunkCoordinates relPos, Block block, int meta) { - super(relPos, block, meta); - } - - @Override - public boolean matches(World world, int x, int y, int z) { - Block block = world.getBlock(x, y, z); - return !block.isAir(world, x, y, z) && block.getCollisionBoundingBoxFromPool(world, x, y, z) != null; - } + public AnyComponent(ChunkCoordinates relPos, Block block, int meta) { + super(relPos, block, meta); + } + @Override + public boolean matches(World world, int x, int y, int z) { + Block block = world.getBlock(x, y, z); + return !block.isAir(world, x, y, z) && block.getCollisionBoundingBoxFromPool(world, x, y, z) != null; + } } diff --git a/src/main/java/vazkii/botania/api/lexicon/multiblock/component/ColorSwitchingComponent.java b/src/main/java/vazkii/botania/api/lexicon/multiblock/component/ColorSwitchingComponent.java index 27eb32ae2d..1b083d36cf 100644 --- a/src/main/java/vazkii/botania/api/lexicon/multiblock/component/ColorSwitchingComponent.java +++ b/src/main/java/vazkii/botania/api/lexicon/multiblock/component/ColorSwitchingComponent.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jun 27, 2015, 7:20:09 PM (GMT)] */ package vazkii.botania.api.lexicon.multiblock.component; @@ -21,23 +21,22 @@ */ public class ColorSwitchingComponent extends MultiblockComponent { - public ColorSwitchingComponent(ChunkCoordinates relPos, Block block) { - super(relPos, block, -1); - } + public ColorSwitchingComponent(ChunkCoordinates relPos, Block block) { + super(relPos, block, -1); + } - @Override - public int getMeta() { - return (int) (BotaniaAPI.internalHandler.getWorldElapsedTicks() / 20) % 16; - } + @Override + public int getMeta() { + return (int) (BotaniaAPI.internalHandler.getWorldElapsedTicks() / 20) % 16; + } - @Override - public boolean matches(World world, int x, int y, int z) { - return world.getBlock(x, y, z) == getBlock(); - } - - @Override - public MultiblockComponent copy() { - return new ColorSwitchingComponent(relPos, block); - } + @Override + public boolean matches(World world, int x, int y, int z) { + return world.getBlock(x, y, z) == getBlock(); + } + @Override + public MultiblockComponent copy() { + return new ColorSwitchingComponent(relPos, block); + } } diff --git a/src/main/java/vazkii/botania/api/lexicon/multiblock/component/FlowerComponent.java b/src/main/java/vazkii/botania/api/lexicon/multiblock/component/FlowerComponent.java index 8a4f0ad72b..979ac24258 100644 --- a/src/main/java/vazkii/botania/api/lexicon/multiblock/component/FlowerComponent.java +++ b/src/main/java/vazkii/botania/api/lexicon/multiblock/component/FlowerComponent.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jun 28, 2015, 3:23:15 PM (GMT)] */ package vazkii.botania.api.lexicon.multiblock.component; @@ -20,18 +20,17 @@ */ public class FlowerComponent extends ColorSwitchingComponent { - public FlowerComponent(ChunkCoordinates relPos, Block block) { - super(relPos, block); - } + public FlowerComponent(ChunkCoordinates relPos, Block block) { + super(relPos, block); + } - @Override - public boolean matches(World world, int x, int y, int z) { - return BotaniaAPI.internalHandler.isBotaniaFlower(world, x, y, z); - } - - @Override - public MultiblockComponent copy() { - return new FlowerComponent(relPos, block); - } + @Override + public boolean matches(World world, int x, int y, int z) { + return BotaniaAPI.internalHandler.isBotaniaFlower(world, x, y, z); + } + @Override + public MultiblockComponent copy() { + return new FlowerComponent(relPos, block); + } } diff --git a/src/main/java/vazkii/botania/api/lexicon/multiblock/component/MultiblockComponent.java b/src/main/java/vazkii/botania/api/lexicon/multiblock/component/MultiblockComponent.java index b1a7d895fa..b1e98401f5 100644 --- a/src/main/java/vazkii/botania/api/lexicon/multiblock/component/MultiblockComponent.java +++ b/src/main/java/vazkii/botania/api/lexicon/multiblock/component/MultiblockComponent.java @@ -2,21 +2,21 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jun 27, 2015, 2:42:32 PM (GMT)] */ package vazkii.botania.api.lexicon.multiblock.component; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; import net.minecraft.block.Block; import net.minecraft.item.ItemStack; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.ChunkCoordinates; import net.minecraft.world.World; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; /** * A component of a multiblock, the normal one @@ -24,73 +24,74 @@ */ public class MultiblockComponent { - public ChunkCoordinates relPos; - public final Block block; - public final int meta; - public final TileEntity tileEntity; - public boolean doFancyRender; - - public MultiblockComponent(ChunkCoordinates relPos, Block block, int meta) { - this(relPos, block, meta, null); - } - - public MultiblockComponent(ChunkCoordinates relPos, Block block, int meta, boolean doFancyRender) { - this(relPos, block, meta, doFancyRender, null); - } - - public MultiblockComponent(ChunkCoordinates relPos, Block block, int meta, TileEntity tileEntity) { - this(relPos, block, meta, block.hasTileEntity() == (tileEntity != null), tileEntity); - } - - public MultiblockComponent(ChunkCoordinates relPos, Block block, int meta, boolean doFancyRender, TileEntity tileEntity) { - this.relPos = relPos; - this.block = block; - this.meta = meta; - this.tileEntity = tileEntity; - this.doFancyRender = doFancyRender; - } - - public ChunkCoordinates getRelativePosition() { - return relPos; - } - - public Block getBlock() { - return block; - } - - public int getMeta() { - return meta; - } - - public boolean matches(World world, int x, int y, int z) { - return world.getBlock(x, y, z) == getBlock() && (meta == -1 || world.getBlockMetadata(x, y, z) == meta); - } - - public ItemStack[] getMaterials() { - return new ItemStack[] { new ItemStack(block, 1, meta) }; - } - - public void rotate(double angle) { - double x = relPos.posX; - double z = relPos.posZ; - double sin = Math.sin(angle); - double cos = Math.cos(angle); - - double xn = x * cos - z * sin; - double zn = x * sin + z * cos; - relPos = new ChunkCoordinates((int) Math.round(xn), relPos.posY, (int) Math.round(zn)); - } - - public MultiblockComponent copy() { - return new MultiblockComponent(relPos, block, meta, tileEntity); - } - - public TileEntity getTileEntity() { - return tileEntity; - } - - @SideOnly(Side.CLIENT) - public boolean shouldDoFancyRender() { - return doFancyRender; - } + public ChunkCoordinates relPos; + public final Block block; + public final int meta; + public final TileEntity tileEntity; + public boolean doFancyRender; + + public MultiblockComponent(ChunkCoordinates relPos, Block block, int meta) { + this(relPos, block, meta, null); + } + + public MultiblockComponent(ChunkCoordinates relPos, Block block, int meta, boolean doFancyRender) { + this(relPos, block, meta, doFancyRender, null); + } + + public MultiblockComponent(ChunkCoordinates relPos, Block block, int meta, TileEntity tileEntity) { + this(relPos, block, meta, block.hasTileEntity() == (tileEntity != null), tileEntity); + } + + public MultiblockComponent( + ChunkCoordinates relPos, Block block, int meta, boolean doFancyRender, TileEntity tileEntity) { + this.relPos = relPos; + this.block = block; + this.meta = meta; + this.tileEntity = tileEntity; + this.doFancyRender = doFancyRender; + } + + public ChunkCoordinates getRelativePosition() { + return relPos; + } + + public Block getBlock() { + return block; + } + + public int getMeta() { + return meta; + } + + public boolean matches(World world, int x, int y, int z) { + return world.getBlock(x, y, z) == getBlock() && (meta == -1 || world.getBlockMetadata(x, y, z) == meta); + } + + public ItemStack[] getMaterials() { + return new ItemStack[] {new ItemStack(block, 1, meta)}; + } + + public void rotate(double angle) { + double x = relPos.posX; + double z = relPos.posZ; + double sin = Math.sin(angle); + double cos = Math.cos(angle); + + double xn = x * cos - z * sin; + double zn = x * sin + z * cos; + relPos = new ChunkCoordinates((int) Math.round(xn), relPos.posY, (int) Math.round(zn)); + } + + public MultiblockComponent copy() { + return new MultiblockComponent(relPos, block, meta, tileEntity); + } + + public TileEntity getTileEntity() { + return tileEntity; + } + + @SideOnly(Side.CLIENT) + public boolean shouldDoFancyRender() { + return doFancyRender; + } } diff --git a/src/main/java/vazkii/botania/api/mana/BurstProperties.java b/src/main/java/vazkii/botania/api/mana/BurstProperties.java index 75ff0f8d2a..4d1f367e87 100644 --- a/src/main/java/vazkii/botania/api/mana/BurstProperties.java +++ b/src/main/java/vazkii/botania/api/mana/BurstProperties.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jan 31, 2014, 3:49:30 PM (GMT)] */ package vazkii.botania.api.mana; @@ -16,21 +16,26 @@ */ public final class BurstProperties { - public int maxMana; - public int ticksBeforeManaLoss; - public float manaLossPerTick; - public float gravity; - public float motionModifier; + public int maxMana; + public int ticksBeforeManaLoss; + public float manaLossPerTick; + public float gravity; + public float motionModifier; - public int color; - - public BurstProperties(int maxMana, int ticksBeforeManaLoss, float manaLossPerTick, float gravity, float motionModifier, int color) { - this.maxMana = maxMana; - this.ticksBeforeManaLoss = ticksBeforeManaLoss; - this.manaLossPerTick = manaLossPerTick; - this.gravity = gravity; - this.motionModifier = motionModifier; - this.color = color; - } + public int color; + public BurstProperties( + int maxMana, + int ticksBeforeManaLoss, + float manaLossPerTick, + float gravity, + float motionModifier, + int color) { + this.maxMana = maxMana; + this.ticksBeforeManaLoss = ticksBeforeManaLoss; + this.manaLossPerTick = manaLossPerTick; + this.gravity = gravity; + this.motionModifier = motionModifier; + this.color = color; + } } diff --git a/src/main/java/vazkii/botania/api/mana/IClientManaHandler.java b/src/main/java/vazkii/botania/api/mana/IClientManaHandler.java index aea14b9e81..0cca7dbc7e 100644 --- a/src/main/java/vazkii/botania/api/mana/IClientManaHandler.java +++ b/src/main/java/vazkii/botania/api/mana/IClientManaHandler.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jul 2, 2014, 5:26:02 PM (GMT)] */ package vazkii.botania.api.mana; @@ -15,6 +15,4 @@ * called on both client and server. If this is not implemented * the call will only occur on the server. */ -public interface IClientManaHandler extends IManaReceiver { - -} +public interface IClientManaHandler extends IManaReceiver {} diff --git a/src/main/java/vazkii/botania/api/mana/ICompositableLens.java b/src/main/java/vazkii/botania/api/mana/ICompositableLens.java index 775719d8d6..8d1deaaf24 100644 --- a/src/main/java/vazkii/botania/api/mana/ICompositableLens.java +++ b/src/main/java/vazkii/botania/api/mana/ICompositableLens.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Nov 23, 2015, 10:30:34 AM (GMT)] */ package vazkii.botania.api.mana; @@ -17,16 +17,13 @@ */ public interface ICompositableLens extends ILens { - /** - * Returns the properties of the itemstack, used to check if two lenses can combine. - */ - public int getProps(ItemStack stack); - - /** - * Checks if the lens is combinable. - */ - public boolean isCombinable(ItemStack stack); + /** + * Returns the properties of the itemstack, used to check if two lenses can combine. + */ + public int getProps(ItemStack stack); + /** + * Checks if the lens is combinable. + */ + public boolean isCombinable(ItemStack stack); } - - diff --git a/src/main/java/vazkii/botania/api/mana/ICreativeManaProvider.java b/src/main/java/vazkii/botania/api/mana/ICreativeManaProvider.java index 2556663c29..15febc47b6 100644 --- a/src/main/java/vazkii/botania/api/mana/ICreativeManaProvider.java +++ b/src/main/java/vazkii/botania/api/mana/ICreativeManaProvider.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [May 25, 2014, 7:34:00 PM (GMT)] */ package vazkii.botania.api.mana; @@ -19,7 +19,5 @@ */ public interface ICreativeManaProvider { - public boolean isCreative(ItemStack stack); - + public boolean isCreative(ItemStack stack); } - diff --git a/src/main/java/vazkii/botania/api/mana/IDirectioned.java b/src/main/java/vazkii/botania/api/mana/IDirectioned.java index ff856f774d..374aa43f62 100644 --- a/src/main/java/vazkii/botania/api/mana/IDirectioned.java +++ b/src/main/java/vazkii/botania/api/mana/IDirectioned.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [15/11/2015, 19:27:07 (GMT)] */ package vazkii.botania.api.mana; @@ -17,8 +17,7 @@ */ public interface IDirectioned { - public float getRotationX(); - - public float getRotationY(); + public float getRotationX(); + public float getRotationY(); } diff --git a/src/main/java/vazkii/botania/api/mana/IIdentifiable.java b/src/main/java/vazkii/botania/api/mana/IIdentifiable.java index 65f2edc028..705cca1809 100644 --- a/src/main/java/vazkii/botania/api/mana/IIdentifiable.java +++ b/src/main/java/vazkii/botania/api/mana/IIdentifiable.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jun 19, 2015, 10:05:24 PM (GMT)] */ package vazkii.botania.api.mana; @@ -18,6 +18,5 @@ */ public interface IIdentifiable { - public UUID getIdentifier(); - + public UUID getIdentifier(); } diff --git a/src/main/java/vazkii/botania/api/mana/IKeyLocked.java b/src/main/java/vazkii/botania/api/mana/IKeyLocked.java index ce71694e47..7db7dc75e8 100644 --- a/src/main/java/vazkii/botania/api/mana/IKeyLocked.java +++ b/src/main/java/vazkii/botania/api/mana/IKeyLocked.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jul 11, 2014, 4:29:32 PM (GMT)] */ package vazkii.botania.api.mana; @@ -13,17 +13,16 @@ /** * A TileEntity that implements this interface has an IO key lock. This * interface defines an input and output key.

- * + * * A Spreader can only shoot mana into a IKeyLocked interfaced TE if the Input * key of the TE is equal to the Output key of the Spreader.

- * + * * A Spreader can only pull mana from a IKeyLocked interfaced IManaPool TE if the * Output key of the IManaPool is equal to the Input key of the Spreader. */ public interface IKeyLocked { - public String getInputKey(); - - public String getOutputKey(); + public String getInputKey(); + public String getOutputKey(); } diff --git a/src/main/java/vazkii/botania/api/mana/ILaputaImmobile.java b/src/main/java/vazkii/botania/api/mana/ILaputaImmobile.java index dfa2945134..e2ea58a2bf 100644 --- a/src/main/java/vazkii/botania/api/mana/ILaputaImmobile.java +++ b/src/main/java/vazkii/botania/api/mana/ILaputaImmobile.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jul 26, 2014, 9:51:58 PM (GMT)] */ package vazkii.botania.api.mana; @@ -17,6 +17,5 @@ */ public interface ILaputaImmobile { - public boolean canMove(World world, int x, int y, int z); - + public boolean canMove(World world, int x, int y, int z); } diff --git a/src/main/java/vazkii/botania/api/mana/ILens.java b/src/main/java/vazkii/botania/api/mana/ILens.java index d125e57295..2f6cc7f802 100644 --- a/src/main/java/vazkii/botania/api/mana/ILens.java +++ b/src/main/java/vazkii/botania/api/mana/ILens.java @@ -2,41 +2,40 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jan 31, 2014, 3:03:04 PM (GMT)] */ package vazkii.botania.api.mana; -import net.minecraft.item.ItemStack; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; +import net.minecraft.item.ItemStack; /** * Have an Item implement this to be counted as a lens for the mana spreader. */ public interface ILens extends ILensEffect { - @SideOnly(Side.CLIENT) - public int getLensColor(ItemStack stack); - - /** - * Can the source lens be combined with the composite lens? This is called - * for both the ILens instance of ItemStack.getItem() of sourceLens and compositeLens. - */ - public boolean canCombineLenses(ItemStack sourceLens, ItemStack compositeLens); + @SideOnly(Side.CLIENT) + public int getLensColor(ItemStack stack); - /** - * Gets the composite lens in the stack passed in, return null for none. - */ - public ItemStack getCompositeLens(ItemStack stack); + /** + * Can the source lens be combined with the composite lens? This is called + * for both the ILens instance of ItemStack.getItem() of sourceLens and compositeLens. + */ + public boolean canCombineLenses(ItemStack sourceLens, ItemStack compositeLens); - /** - * Sets the composite lens for the sourceLens as the compositeLens, returns - * the ItemStack with the combination. - */ - public ItemStack setCompositeLens(ItemStack sourceLens, ItemStack compositeLens); + /** + * Gets the composite lens in the stack passed in, return null for none. + */ + public ItemStack getCompositeLens(ItemStack stack); + /** + * Sets the composite lens for the sourceLens as the compositeLens, returns + * the ItemStack with the combination. + */ + public ItemStack setCompositeLens(ItemStack sourceLens, ItemStack compositeLens); } diff --git a/src/main/java/vazkii/botania/api/mana/ILensControl.java b/src/main/java/vazkii/botania/api/mana/ILensControl.java index ad0cc6c693..ad1e946f3c 100644 --- a/src/main/java/vazkii/botania/api/mana/ILensControl.java +++ b/src/main/java/vazkii/botania/api/mana/ILensControl.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [15/11/2015, 21:00:32 (GMT)] */ package vazkii.botania.api.mana; @@ -18,18 +18,17 @@ */ public interface ILensControl extends ILens { - public boolean isControlLens(ItemStack stack); + public boolean isControlLens(ItemStack stack); - public boolean allowBurstShooting(ItemStack stack, IManaSpreader spreader, boolean redstone); + public boolean allowBurstShooting(ItemStack stack, IManaSpreader spreader, boolean redstone); - /** - * Used for the tick of a non-redstone spreader. - */ - public void onControlledSpreaderTick(ItemStack stack, IManaSpreader spreader, boolean redstone); - - /** - * Used for when a redstone spreader gets a pulse. - */ - public void onControlledSpreaderPulse(ItemStack stack, IManaSpreader spreader, boolean redstone); + /** + * Used for the tick of a non-redstone spreader. + */ + public void onControlledSpreaderTick(ItemStack stack, IManaSpreader spreader, boolean redstone); + /** + * Used for when a redstone spreader gets a pulse. + */ + public void onControlledSpreaderPulse(ItemStack stack, IManaSpreader spreader, boolean redstone); } diff --git a/src/main/java/vazkii/botania/api/mana/ILensEffect.java b/src/main/java/vazkii/botania/api/mana/ILensEffect.java index 4c88f55241..790ccea8bf 100644 --- a/src/main/java/vazkii/botania/api/mana/ILensEffect.java +++ b/src/main/java/vazkii/botania/api/mana/ILensEffect.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Apr 14, 2014, 7:30:00 PM (GMT)] */ package vazkii.botania.api.mana; @@ -20,29 +20,29 @@ */ public interface ILensEffect { - /** - * Called when a mana spreader that has this focus shoots a burst. This is where - * you change the properties of the burst. - */ - public void apply(ItemStack stack, BurstProperties props); + /** + * Called when a mana spreader that has this focus shoots a burst. This is where + * you change the properties of the burst. + */ + public void apply(ItemStack stack, BurstProperties props); - /** - * Called when a mana burst fired from a mana spreader with this focus collides against - * any block. This is called after the collision is handled. - * @return True to kill the burst. False to keep it alive. - */ - public boolean collideBurst(IManaBurst burst, MovingObjectPosition pos, boolean isManaBlock, boolean dead, ItemStack stack); + /** + * Called when a mana burst fired from a mana spreader with this focus collides against + * any block. This is called after the collision is handled. + * @return True to kill the burst. False to keep it alive. + */ + public boolean collideBurst( + IManaBurst burst, MovingObjectPosition pos, boolean isManaBlock, boolean dead, ItemStack stack); - /** - * Called when a mana burst fired from a mana spreader with this focus is updated. - * This is called before the update is handled. - */ - public void updateBurst(IManaBurst burst, ItemStack stack); - - /** - * Called when the mana burst should do it's particles. Return false to not - * do any particles. - */ - public boolean doParticles(IManaBurst burst, ItemStack stack); + /** + * Called when a mana burst fired from a mana spreader with this focus is updated. + * This is called before the update is handled. + */ + public void updateBurst(IManaBurst burst, ItemStack stack); + /** + * Called when the mana burst should do it's particles. Return false to not + * do any particles. + */ + public boolean doParticles(IManaBurst burst, ItemStack stack); } diff --git a/src/main/java/vazkii/botania/api/mana/IManaBlock.java b/src/main/java/vazkii/botania/api/mana/IManaBlock.java index 56aa037c75..0db24c9998 100644 --- a/src/main/java/vazkii/botania/api/mana/IManaBlock.java +++ b/src/main/java/vazkii/botania/api/mana/IManaBlock.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jan 22, 2014, 4:59:05 PM (GMT)] */ package vazkii.botania.api.mana; @@ -17,9 +17,8 @@ */ public interface IManaBlock { - /** - * Gets the amount of mana currently in this block. - */ - public int getCurrentMana(); - + /** + * Gets the amount of mana currently in this block. + */ + public int getCurrentMana(); } diff --git a/src/main/java/vazkii/botania/api/mana/IManaCollector.java b/src/main/java/vazkii/botania/api/mana/IManaCollector.java index 280e46007e..772d0ddd1e 100644 --- a/src/main/java/vazkii/botania/api/mana/IManaCollector.java +++ b/src/main/java/vazkii/botania/api/mana/IManaCollector.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jan 22, 2014, 5:01:19 PM (GMT)] */ package vazkii.botania.api.mana; @@ -15,28 +15,27 @@ /** * Any TileEntity that implements this is considered a mana collector, by * which nearby generating flowers will pump mana into it.

- * + * * Implementation Instructions:
* - Override invalidate() and onChunkUnload(), calling ManaNetworkEvent.removeCollector(this); on both.
* - On the first tick of onUpdate(), call ManaNetworkEvent.addCollector(this); */ public interface IManaCollector extends IManaReceiver { - /** - * Called every tick on the client case the player is holding a Wand of the Forest. - */ - public void onClientDisplayTick(); + /** + * Called every tick on the client case the player is holding a Wand of the Forest. + */ + public void onClientDisplayTick(); - /** - * Get the multiplier of mana to input into the block, 1.0 is the original amount of mana - * in the burst. 0.9, for example, is 90%, so 10% of the mana in the burst will get - * dissipated. - */ - public float getManaYieldMultiplier(IManaBurst burst); - - /** - * Gets the maximum amount of mana this collector can have. - */ - public int getMaxMana(); + /** + * Get the multiplier of mana to input into the block, 1.0 is the original amount of mana + * in the burst. 0.9, for example, is 90%, so 10% of the mana in the burst will get + * dissipated. + */ + public float getManaYieldMultiplier(IManaBurst burst); + /** + * Gets the maximum amount of mana this collector can have. + */ + public int getMaxMana(); } diff --git a/src/main/java/vazkii/botania/api/mana/IManaCollisionGhost.java b/src/main/java/vazkii/botania/api/mana/IManaCollisionGhost.java index 76b537ed1c..2cdf1399f4 100644 --- a/src/main/java/vazkii/botania/api/mana/IManaCollisionGhost.java +++ b/src/main/java/vazkii/botania/api/mana/IManaCollisionGhost.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Mar 10, 2014, 7:49:19 PM (GMT)] */ package vazkii.botania.api.mana; @@ -16,6 +16,5 @@ */ public interface IManaCollisionGhost { - public boolean isGhost(); - + public boolean isGhost(); } diff --git a/src/main/java/vazkii/botania/api/mana/IManaDiscountArmor.java b/src/main/java/vazkii/botania/api/mana/IManaDiscountArmor.java index 56a9683f98..3aa1128b17 100644 --- a/src/main/java/vazkii/botania/api/mana/IManaDiscountArmor.java +++ b/src/main/java/vazkii/botania/api/mana/IManaDiscountArmor.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jan 28, 2015, 9:22:53 PM (GMT)] */ package vazkii.botania.api.mana; @@ -20,12 +20,11 @@ */ public interface IManaDiscountArmor { - /** - * Gets the mana discount that this piece of armor provides. This is added - * together to create the full discount. - * Value is to be from 0.0 to 1.0. 0.1 is 10% discount, as an example. - * You can also return negative values to make tools cost more. - */ - public float getDiscount(ItemStack stack, int slot, EntityPlayer player); - + /** + * Gets the mana discount that this piece of armor provides. This is added + * together to create the full discount. + * Value is to be from 0.0 to 1.0. 0.1 is 10% discount, as an example. + * You can also return negative values to make tools cost more. + */ + public float getDiscount(ItemStack stack, int slot, EntityPlayer player); } diff --git a/src/main/java/vazkii/botania/api/mana/IManaGivingItem.java b/src/main/java/vazkii/botania/api/mana/IManaGivingItem.java index a1d7f04d9f..4e7f414a08 100644 --- a/src/main/java/vazkii/botania/api/mana/IManaGivingItem.java +++ b/src/main/java/vazkii/botania/api/mana/IManaGivingItem.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [08/12/2015, 18:10:29 (GMT)] */ package vazkii.botania.api.mana; @@ -15,6 +15,4 @@ * This is used in botania for the terra shatterer to not be constantly * receiving mana from these items.. */ -public interface IManaGivingItem { - -} +public interface IManaGivingItem {} diff --git a/src/main/java/vazkii/botania/api/mana/IManaItem.java b/src/main/java/vazkii/botania/api/mana/IManaItem.java index f4463fb1df..f507d81687 100644 --- a/src/main/java/vazkii/botania/api/mana/IManaItem.java +++ b/src/main/java/vazkii/botania/api/mana/IManaItem.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Mar 6, 2014, 9:07:40 AM (GMT)] */ package vazkii.botania.api.mana; @@ -19,50 +19,49 @@ */ public interface IManaItem { - /** - * Gets the amount of mana this item contains - */ - public int getMana(ItemStack stack); + /** + * Gets the amount of mana this item contains + */ + public int getMana(ItemStack stack); - /** - * Gets the max amount of mana this item can hold. - */ - public int getMaxMana(ItemStack stack); + /** + * Gets the max amount of mana this item can hold. + */ + public int getMaxMana(ItemStack stack); - /** - * Adds mana to this item. - */ - public void addMana(ItemStack stack, int mana); + /** + * Adds mana to this item. + */ + public void addMana(ItemStack stack, int mana); - /** - * Can this item receive mana from a mana Pool? - * @param pool The pool it's receiving mana from, can be casted to IManaPool. - * @see IManaPool#isOutputtingPower() - */ - public boolean canReceiveManaFromPool(ItemStack stack, TileEntity pool); + /** + * Can this item receive mana from a mana Pool? + * @param pool The pool it's receiving mana from, can be casted to IManaPool. + * @see IManaPool#isOutputtingPower() + */ + public boolean canReceiveManaFromPool(ItemStack stack, TileEntity pool); - /** - * Can this item recieve mana from another item? - */ - public boolean canReceiveManaFromItem(ItemStack stack, ItemStack otherStack); + /** + * Can this item recieve mana from another item? + */ + public boolean canReceiveManaFromItem(ItemStack stack, ItemStack otherStack); - /** - * Can this item export mana to a mana Pool? - * @param pool The pool it's exporting mana to, can be casted to IManaPool. - * @see IManaPool#isOutputtingPower() - */ - public boolean canExportManaToPool(ItemStack stack,TileEntity pool); + /** + * Can this item export mana to a mana Pool? + * @param pool The pool it's exporting mana to, can be casted to IManaPool. + * @see IManaPool#isOutputtingPower() + */ + public boolean canExportManaToPool(ItemStack stack, TileEntity pool); - /** - * Can this item export mana to another item? - */ - public boolean canExportManaToItem(ItemStack stack, ItemStack otherStack); - - /** - * If this item simply does not export mana at all, set this to true. This is - * used to skip items that contain mana but can't export it when drawing the - * mana bar above the XP bar. - */ - public boolean isNoExport(ItemStack stack); + /** + * Can this item export mana to another item? + */ + public boolean canExportManaToItem(ItemStack stack, ItemStack otherStack); + /** + * If this item simply does not export mana at all, set this to true. This is + * used to skip items that contain mana but can't export it when drawing the + * mana bar above the XP bar. + */ + public boolean isNoExport(ItemStack stack); } diff --git a/src/main/java/vazkii/botania/api/mana/IManaPool.java b/src/main/java/vazkii/botania/api/mana/IManaPool.java index df523a62c7..fa0e1b5b8f 100644 --- a/src/main/java/vazkii/botania/api/mana/IManaPool.java +++ b/src/main/java/vazkii/botania/api/mana/IManaPool.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jan 22, 2014, 5:03:09 PM (GMT)] */ package vazkii.botania.api.mana; @@ -14,17 +14,16 @@ * Any TileEntity that implements this is considered a Mana Pool, * by which nearby functional flowers will pull mana from it.
* Mana Distributors will also accept it as valid output.

- * + * * Implementation Instructions:
* - Override invalidate() and onChunkUnload(), calling ManaNetworkEvent.removePool(this); on both.
* - On the first tick of onUpdate(), call ManaNetworkEvent.addPool(this); */ public interface IManaPool extends IManaReceiver { - /** - * Returns false if the mana pool is accepting power from other power items, - * true if it's sending power into them. - */ - public boolean isOutputtingPower(); - + /** + * Returns false if the mana pool is accepting power from other power items, + * true if it's sending power into them. + */ + public boolean isOutputtingPower(); } diff --git a/src/main/java/vazkii/botania/api/mana/IManaReceiver.java b/src/main/java/vazkii/botania/api/mana/IManaReceiver.java index 178856fad2..37b9c0c3fe 100644 --- a/src/main/java/vazkii/botania/api/mana/IManaReceiver.java +++ b/src/main/java/vazkii/botania/api/mana/IManaReceiver.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jan 22, 2014, 4:55:00 PM (GMT)] */ package vazkii.botania.api.mana; @@ -15,20 +15,19 @@ */ public interface IManaReceiver extends IManaBlock { - /** - * Is this Mana Receiver is full? Being full means no mana bursts will be sent. - */ - public boolean isFull(); + /** + * Is this Mana Receiver is full? Being full means no mana bursts will be sent. + */ + public boolean isFull(); - /** - * Called when this receiver receives mana. - */ - public void recieveMana(int mana); - - /** - * Can this tile receive mana from bursts? Generally set to false for - * implementations of IManaCollector. - */ - public boolean canRecieveManaFromBursts(); + /** + * Called when this receiver receives mana. + */ + public void recieveMana(int mana); + /** + * Can this tile receive mana from bursts? Generally set to false for + * implementations of IManaCollector. + */ + public boolean canRecieveManaFromBursts(); } diff --git a/src/main/java/vazkii/botania/api/mana/IManaSpreader.java b/src/main/java/vazkii/botania/api/mana/IManaSpreader.java index 61b9f8e32c..0bb57d1560 100644 --- a/src/main/java/vazkii/botania/api/mana/IManaSpreader.java +++ b/src/main/java/vazkii/botania/api/mana/IManaSpreader.java @@ -2,29 +2,27 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Apr 18, 2015, 7:30:00 PM (GMT)] */ package vazkii.botania.api.mana; - /** * Any TileEntity that implements this is considered a Mana Spreader, * by which can fire mana bursts as a spreader. */ public interface IManaSpreader extends IManaBlock, IPingable, IDirectioned { - public void setCanShoot(boolean canShoot); - - public int getBurstParticleTick(); + public void setCanShoot(boolean canShoot); - public void setBurstParticleTick(int i); + public int getBurstParticleTick(); - public int getLastBurstDeathTick(); + public void setBurstParticleTick(int i); - public void setLastBurstDeathTick(int ticksExisted); + public int getLastBurstDeathTick(); + public void setLastBurstDeathTick(int ticksExisted); } diff --git a/src/main/java/vazkii/botania/api/mana/IManaTooltipDisplay.java b/src/main/java/vazkii/botania/api/mana/IManaTooltipDisplay.java index 21de4740e8..7f1c79fb6f 100644 --- a/src/main/java/vazkii/botania/api/mana/IManaTooltipDisplay.java +++ b/src/main/java/vazkii/botania/api/mana/IManaTooltipDisplay.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Oct 23, 2015, 3:54:03 PM (GMT)] */ package vazkii.botania.api.mana; @@ -18,9 +18,8 @@ */ public interface IManaTooltipDisplay { - /** - * Returns the fraction of mana in this item for display. From 0 to 1 (exclusive). - */ - public float getManaFractionForDisplay(ItemStack stack); - + /** + * Returns the fraction of mana in this item for display. From 0 to 1 (exclusive). + */ + public float getManaFractionForDisplay(ItemStack stack); } diff --git a/src/main/java/vazkii/botania/api/mana/IManaTrigger.java b/src/main/java/vazkii/botania/api/mana/IManaTrigger.java index 61aadfcaad..6b26afba4d 100644 --- a/src/main/java/vazkii/botania/api/mana/IManaTrigger.java +++ b/src/main/java/vazkii/botania/api/mana/IManaTrigger.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [May 16, 2014, 7:52:53 PM (GMT)] */ package vazkii.botania.api.mana; @@ -18,6 +18,5 @@ */ public interface IManaTrigger { - public void onBurstCollision(IManaBurst burst, World world, int x, int y, int z); - + public void onBurstCollision(IManaBurst burst, World world, int x, int y, int z); } diff --git a/src/main/java/vazkii/botania/api/mana/IManaUsingItem.java b/src/main/java/vazkii/botania/api/mana/IManaUsingItem.java index 9fe55fc464..ddf1a23200 100644 --- a/src/main/java/vazkii/botania/api/mana/IManaUsingItem.java +++ b/src/main/java/vazkii/botania/api/mana/IManaUsingItem.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [May 25, 2014, 7:32:10 PM (GMT)] */ package vazkii.botania.api.mana; @@ -20,6 +20,5 @@ */ public interface IManaUsingItem { - public boolean usesMana(ItemStack stack); - + public boolean usesMana(ItemStack stack); } diff --git a/src/main/java/vazkii/botania/api/mana/IPingable.java b/src/main/java/vazkii/botania/api/mana/IPingable.java index 1605b428e2..a52ab3b83b 100644 --- a/src/main/java/vazkii/botania/api/mana/IPingable.java +++ b/src/main/java/vazkii/botania/api/mana/IPingable.java @@ -2,16 +2,15 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jun 19, 2015, 9:52:05 PM (GMT)] */ package vazkii.botania.api.mana; import java.util.UUID; - import vazkii.botania.api.internal.IManaBurst; /** @@ -20,12 +19,11 @@ */ public interface IPingable extends IIdentifiable { - /** - * Pings this object back, telling it that the burst passed in is still alive - * in the world. The UUID parameter should be the UUID with which the burst - * was created, this is used to let the object handle the check for if it's the - * correct ID internally. IManaBurst implementations should do this every tick. - */ - public void pingback(IManaBurst burst, UUID expectedIdentity); - + /** + * Pings this object back, telling it that the burst passed in is still alive + * in the world. The UUID parameter should be the UUID with which the burst + * was created, this is used to let the object handle the check for if it's the + * correct ID internally. IManaBurst implementations should do this every tick. + */ + public void pingback(IManaBurst burst, UUID expectedIdentity); } diff --git a/src/main/java/vazkii/botania/api/mana/IPoolOverlayProvider.java b/src/main/java/vazkii/botania/api/mana/IPoolOverlayProvider.java index e443e2c1b7..8ab53220a1 100644 --- a/src/main/java/vazkii/botania/api/mana/IPoolOverlayProvider.java +++ b/src/main/java/vazkii/botania/api/mana/IPoolOverlayProvider.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jul 2, 2014, 6:36:54 PM (GMT)] */ package vazkii.botania.api.mana; @@ -20,6 +20,5 @@ */ public interface IPoolOverlayProvider { - public IIcon getIcon(World world, int x, int y, int z); - + public IIcon getIcon(World world, int x, int y, int z); } diff --git a/src/main/java/vazkii/botania/api/mana/IRedirectable.java b/src/main/java/vazkii/botania/api/mana/IRedirectable.java index 00a1b6aa79..2f484d674a 100644 --- a/src/main/java/vazkii/botania/api/mana/IRedirectable.java +++ b/src/main/java/vazkii/botania/api/mana/IRedirectable.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [15/11/2015, 19:28:18 (GMT)] */ package vazkii.botania.api.mana; @@ -17,13 +17,13 @@ */ public interface IRedirectable extends IDirectioned { - public void setRotationX(float rot); + public void setRotationX(float rot); - public void setRotationY(float rot); + public void setRotationY(float rot); - /** - * This should be called after rotation setting is done to allow - * for the block to re-calculate. - */ - public void commitRedirection(); + /** + * This should be called after rotation setting is done to allow + * for the block to re-calculate. + */ + public void commitRedirection(); } diff --git a/src/main/java/vazkii/botania/api/mana/IThrottledPacket.java b/src/main/java/vazkii/botania/api/mana/IThrottledPacket.java index ff760bed0d..72f6c6649d 100644 --- a/src/main/java/vazkii/botania/api/mana/IThrottledPacket.java +++ b/src/main/java/vazkii/botania/api/mana/IThrottledPacket.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Apr 12, 2015, 3:08:09 PM (GMT)] */ package vazkii.botania.api.mana; @@ -17,6 +17,5 @@ */ public interface IThrottledPacket { - public void markDispatchable(); - + public void markDispatchable(); } diff --git a/src/main/java/vazkii/botania/api/mana/ITinyPlanetExcempt.java b/src/main/java/vazkii/botania/api/mana/ITinyPlanetExcempt.java index a82114c3af..a96226a490 100644 --- a/src/main/java/vazkii/botania/api/mana/ITinyPlanetExcempt.java +++ b/src/main/java/vazkii/botania/api/mana/ITinyPlanetExcempt.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jul 22, 2014, 2:26:14 PM (GMT)] */ package vazkii.botania.api.mana; @@ -18,6 +18,5 @@ */ public interface ITinyPlanetExcempt { - public boolean shouldPull(ItemStack stack); - + public boolean shouldPull(ItemStack stack); } diff --git a/src/main/java/vazkii/botania/api/mana/ManaItemHandler.java b/src/main/java/vazkii/botania/api/mana/ManaItemHandler.java index d261d55038..82dcbf12e4 100644 --- a/src/main/java/vazkii/botania/api/mana/ManaItemHandler.java +++ b/src/main/java/vazkii/botania/api/mana/ManaItemHandler.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Mar 13, 2014, 5:32:24 PM (GMT)] */ package vazkii.botania.api.mana; @@ -17,239 +17,224 @@ public final class ManaItemHandler { - /** - * Requests mana from items in a given player's inventory. - * @param manaToGet How much mana is to be requested, if less mana exists than this amount, - * the amount of mana existent will be returned instead, if you want exact values use requestManaExact. - * @param remove If true, the mana will be removed from the target item. Set to false to just check. - * @return The amount of mana received from the request. - */ - public static int requestMana(ItemStack stack, EntityPlayer player, int manaToGet, boolean remove) { - if(stack == null) - return 0; - - IInventory mainInv = player.inventory; - IInventory baublesInv = BotaniaAPI.internalHandler.getBaublesInventory(player); - - int invSize = mainInv.getSizeInventory(); - int size = invSize; - if(baublesInv != null) - size += baublesInv.getSizeInventory(); - - for(int i = 0; i < size; i++) { - boolean useBaubles = i >= invSize; - IInventory inv = useBaubles ? baublesInv : mainInv; - int slot = i - (useBaubles ? invSize : 0); - ItemStack stackInSlot = inv.getStackInSlot(slot); - if(stackInSlot == stack) - continue; - - if(stackInSlot != null && stackInSlot.getItem() instanceof IManaItem) { - IManaItem manaItem = (IManaItem) stackInSlot.getItem(); - if(manaItem.canExportManaToItem(stackInSlot, stack) && manaItem.getMana(stackInSlot) > 0) { - if(stack.getItem() instanceof IManaItem && !((IManaItem) stack.getItem()).canReceiveManaFromItem(stack, stackInSlot)) - continue; - - int mana = Math.min(manaToGet, manaItem.getMana(stackInSlot)); - - if(remove) - manaItem.addMana(stackInSlot, -mana); - if(useBaubles) - BotaniaAPI.internalHandler.sendBaubleUpdatePacket(player, slot); - - return mana; - } - } - } - - return 0; - } - - /** - * Requests an exact amount of mana from items in a given player's inventory. - * @param manaToGet How much mana is to be requested, if less mana exists than this amount, - * false will be returned instead, and nothing will happen. - * @param remove If true, the mana will be removed from the target item. Set to false to just check. - * @return If the request was succesful. - */ - public static boolean requestManaExact(ItemStack stack, EntityPlayer player, int manaToGet, boolean remove) { - if(stack == null) - return false; - - IInventory mainInv = player.inventory; - IInventory baublesInv = BotaniaAPI.internalHandler.getBaublesInventory(player); - - int invSize = mainInv.getSizeInventory(); - int size = invSize; - if(baublesInv != null) - size += baublesInv.getSizeInventory(); - - for(int i = 0; i < size; i++) { - boolean useBaubles = i >= invSize; - IInventory inv = useBaubles ? baublesInv : mainInv; - int slot = i - (useBaubles ? invSize : 0); - ItemStack stackInSlot = inv.getStackInSlot(slot); - if(stackInSlot == stack) - continue; - - if(stackInSlot != null && stackInSlot.getItem() instanceof IManaItem) { - IManaItem manaItemSlot = (IManaItem) stackInSlot.getItem(); - if(manaItemSlot.canExportManaToItem(stackInSlot, stack) && manaItemSlot.getMana(stackInSlot) > manaToGet) { - if(stack.getItem() instanceof IManaItem && !((IManaItem) stack.getItem()).canReceiveManaFromItem(stack, stackInSlot)) - continue; - - if(remove) - manaItemSlot.addMana(stackInSlot, -manaToGet); - if(useBaubles) - BotaniaAPI.internalHandler.sendBaubleUpdatePacket(player, slot); - - return true; - } - } - } - - return false; - } - - /** - * Dispatches mana to items in a given player's inventory. Note that this method - * does not automatically remove mana from the item which is exporting. - * @param manaToSend How much mana is to be sent. - * @param remove If true, the mana will be added from the target item. Set to false to just check. - * @return The amount of mana actually sent. - */ - public static int dispatchMana(ItemStack stack, EntityPlayer player, int manaToSend, boolean add) { - if(stack == null) - return 0; - - IInventory mainInv = player.inventory; - IInventory baublesInv = BotaniaAPI.internalHandler.getBaublesInventory(player); - - int invSize = mainInv.getSizeInventory(); - int size = invSize; - if(baublesInv != null) - size += baublesInv.getSizeInventory(); - - for(int i = 0; i < size; i++) { - boolean useBaubles = i >= invSize; - IInventory inv = useBaubles ? baublesInv : mainInv; - int slot = i - (useBaubles ? invSize : 0); - ItemStack stackInSlot = inv.getStackInSlot(slot); - if(stackInSlot == stack) - continue; - - if(stackInSlot != null && stackInSlot.getItem() instanceof IManaItem) { - IManaItem manaItemSlot = (IManaItem) stackInSlot.getItem(); - - if(manaItemSlot.canReceiveManaFromItem(stackInSlot, stack)) { - if(stack.getItem() instanceof IManaItem && !((IManaItem) stack.getItem()).canExportManaToItem(stack, stackInSlot)) - continue; - - int received = 0; - if(manaItemSlot.getMana(stackInSlot) + manaToSend <= manaItemSlot.getMaxMana(stackInSlot)) - received = manaToSend; - else received = manaToSend - (manaItemSlot.getMana(stackInSlot) + manaToSend - manaItemSlot.getMaxMana(stackInSlot)); - - - if(add) - manaItemSlot.addMana(stackInSlot, manaToSend); - if(useBaubles) - BotaniaAPI.internalHandler.sendBaubleUpdatePacket(player, slot); - - return received; - } - } - } - - return 0; - } - - /** - * Dispatches an exact amount of mana to items in a given player's inventory. Note that this method - * does not automatically remove mana from the item which is exporting. - * @param manaToSend How much mana is to be sent. - * @param remove If true, the mana will be added from the target item. Set to false to just check. - * @return If an item received the mana sent. - */ - public static boolean dispatchManaExact(ItemStack stack, EntityPlayer player, int manaToSend, boolean add) { - if(stack == null) - return false; - - IInventory mainInv = player.inventory; - IInventory baublesInv = BotaniaAPI.internalHandler.getBaublesInventory(player); - - int invSize = mainInv.getSizeInventory(); - int size = invSize; - if(baublesInv != null) - size += baublesInv.getSizeInventory(); - - for(int i = 0; i < size; i++) { - boolean useBaubles = i >= invSize; - IInventory inv = useBaubles ? baublesInv : mainInv; - int slot = i - (useBaubles ? invSize : 0); - ItemStack stackInSlot = inv.getStackInSlot(slot); - if(stackInSlot == stack) - continue; - - if(stackInSlot != null && stackInSlot.getItem() instanceof IManaItem) { - IManaItem manaItemSlot = (IManaItem) stackInSlot.getItem(); - if(manaItemSlot.getMana(stackInSlot) + manaToSend <= manaItemSlot.getMaxMana(stackInSlot) && manaItemSlot.canReceiveManaFromItem(stackInSlot, stack)) { - if(stack.getItem() instanceof IManaItem && !((IManaItem) stack.getItem()).canExportManaToItem(stack, stackInSlot)) - continue; - - if(add) - manaItemSlot.addMana(stackInSlot, manaToSend); - if(useBaubles) - BotaniaAPI.internalHandler.sendBaubleUpdatePacket(player, slot); - - return true; - } - } - } - - return false; - } - - /** - * Requests mana from items in a given player's inventory. This version also - * checks for IManaDiscountArmor items equipped to lower the cost. - * @param manaToGet How much mana is to be requested, if less mana exists than this amount, - * the amount of mana existent will be returned instead, if you want exact values use requestManaExact. - * @param remove If true, the mana will be removed from the target item. Set to false to just check. - * @return The amount of mana received from the request. - */ - public static int requestManaForTool(ItemStack stack, EntityPlayer player, int manaToGet, boolean remove) { - float multiplier = Math.max(0F, 1F - getFullDiscountForTools(player)); - int cost = (int) (manaToGet * multiplier); - return (int) (requestMana(stack, player, cost, remove) / multiplier); - } - - /** - * Requests an exact amount of mana from items in a given player's inventory. This version also - * checks for IManaDiscountArmor items equipped to lower the cost. - * @param manaToGet How much mana is to be requested, if less mana exists than this amount, - * false will be returned instead, and nothing will happen. - * @param remove If true, the mana will be removed from the target item. Set to false to just check. - * @return If the request was succesful. - */ - public static boolean requestManaExactForTool(ItemStack stack, EntityPlayer player, int manaToGet, boolean remove) { - float multiplier = Math.max(0F, 1F - getFullDiscountForTools(player)); - int cost = (int) (manaToGet * multiplier); - return requestManaExact(stack, player, cost, remove); - } - - /** - * Gets the sum of all the discounts on IManaDiscountArmor items equipped - * on the player passed in. - */ - public static float getFullDiscountForTools(EntityPlayer player) { - float discount = 0F; - for(int i = 0; i < player.inventory.armorInventory.length; i++) { - ItemStack armor = player.inventory.armorInventory[i]; - if(armor != null && armor.getItem() instanceof IManaDiscountArmor) - discount += ((IManaDiscountArmor) armor.getItem()).getDiscount(armor, i, player); - } - - return discount; - } + /** + * Requests mana from items in a given player's inventory. + * @param manaToGet How much mana is to be requested, if less mana exists than this amount, + * the amount of mana existent will be returned instead, if you want exact values use requestManaExact. + * @param remove If true, the mana will be removed from the target item. Set to false to just check. + * @return The amount of mana received from the request. + */ + public static int requestMana(ItemStack stack, EntityPlayer player, int manaToGet, boolean remove) { + if (stack == null) return 0; + + IInventory mainInv = player.inventory; + IInventory baublesInv = BotaniaAPI.internalHandler.getBaublesInventory(player); + + int invSize = mainInv.getSizeInventory(); + int size = invSize; + if (baublesInv != null) size += baublesInv.getSizeInventory(); + + for (int i = 0; i < size; i++) { + boolean useBaubles = i >= invSize; + IInventory inv = useBaubles ? baublesInv : mainInv; + int slot = i - (useBaubles ? invSize : 0); + ItemStack stackInSlot = inv.getStackInSlot(slot); + if (stackInSlot == stack) continue; + + if (stackInSlot != null && stackInSlot.getItem() instanceof IManaItem) { + IManaItem manaItem = (IManaItem) stackInSlot.getItem(); + if (manaItem.canExportManaToItem(stackInSlot, stack) && manaItem.getMana(stackInSlot) > 0) { + if (stack.getItem() instanceof IManaItem + && !((IManaItem) stack.getItem()).canReceiveManaFromItem(stack, stackInSlot)) continue; + + int mana = Math.min(manaToGet, manaItem.getMana(stackInSlot)); + + if (remove) manaItem.addMana(stackInSlot, -mana); + if (useBaubles) BotaniaAPI.internalHandler.sendBaubleUpdatePacket(player, slot); + + return mana; + } + } + } + + return 0; + } + + /** + * Requests an exact amount of mana from items in a given player's inventory. + * @param manaToGet How much mana is to be requested, if less mana exists than this amount, + * false will be returned instead, and nothing will happen. + * @param remove If true, the mana will be removed from the target item. Set to false to just check. + * @return If the request was succesful. + */ + public static boolean requestManaExact(ItemStack stack, EntityPlayer player, int manaToGet, boolean remove) { + if (stack == null) return false; + + IInventory mainInv = player.inventory; + IInventory baublesInv = BotaniaAPI.internalHandler.getBaublesInventory(player); + + int invSize = mainInv.getSizeInventory(); + int size = invSize; + if (baublesInv != null) size += baublesInv.getSizeInventory(); + + for (int i = 0; i < size; i++) { + boolean useBaubles = i >= invSize; + IInventory inv = useBaubles ? baublesInv : mainInv; + int slot = i - (useBaubles ? invSize : 0); + ItemStack stackInSlot = inv.getStackInSlot(slot); + if (stackInSlot == stack) continue; + + if (stackInSlot != null && stackInSlot.getItem() instanceof IManaItem) { + IManaItem manaItemSlot = (IManaItem) stackInSlot.getItem(); + if (manaItemSlot.canExportManaToItem(stackInSlot, stack) + && manaItemSlot.getMana(stackInSlot) > manaToGet) { + if (stack.getItem() instanceof IManaItem + && !((IManaItem) stack.getItem()).canReceiveManaFromItem(stack, stackInSlot)) continue; + + if (remove) manaItemSlot.addMana(stackInSlot, -manaToGet); + if (useBaubles) BotaniaAPI.internalHandler.sendBaubleUpdatePacket(player, slot); + + return true; + } + } + } + + return false; + } + + /** + * Dispatches mana to items in a given player's inventory. Note that this method + * does not automatically remove mana from the item which is exporting. + * @param manaToSend How much mana is to be sent. + * @param remove If true, the mana will be added from the target item. Set to false to just check. + * @return The amount of mana actually sent. + */ + public static int dispatchMana(ItemStack stack, EntityPlayer player, int manaToSend, boolean add) { + if (stack == null) return 0; + + IInventory mainInv = player.inventory; + IInventory baublesInv = BotaniaAPI.internalHandler.getBaublesInventory(player); + + int invSize = mainInv.getSizeInventory(); + int size = invSize; + if (baublesInv != null) size += baublesInv.getSizeInventory(); + + for (int i = 0; i < size; i++) { + boolean useBaubles = i >= invSize; + IInventory inv = useBaubles ? baublesInv : mainInv; + int slot = i - (useBaubles ? invSize : 0); + ItemStack stackInSlot = inv.getStackInSlot(slot); + if (stackInSlot == stack) continue; + + if (stackInSlot != null && stackInSlot.getItem() instanceof IManaItem) { + IManaItem manaItemSlot = (IManaItem) stackInSlot.getItem(); + + if (manaItemSlot.canReceiveManaFromItem(stackInSlot, stack)) { + if (stack.getItem() instanceof IManaItem + && !((IManaItem) stack.getItem()).canExportManaToItem(stack, stackInSlot)) continue; + + int received = 0; + if (manaItemSlot.getMana(stackInSlot) + manaToSend <= manaItemSlot.getMaxMana(stackInSlot)) + received = manaToSend; + else + received = manaToSend + - (manaItemSlot.getMana(stackInSlot) + + manaToSend + - manaItemSlot.getMaxMana(stackInSlot)); + + if (add) manaItemSlot.addMana(stackInSlot, manaToSend); + if (useBaubles) BotaniaAPI.internalHandler.sendBaubleUpdatePacket(player, slot); + + return received; + } + } + } + + return 0; + } + + /** + * Dispatches an exact amount of mana to items in a given player's inventory. Note that this method + * does not automatically remove mana from the item which is exporting. + * @param manaToSend How much mana is to be sent. + * @param remove If true, the mana will be added from the target item. Set to false to just check. + * @return If an item received the mana sent. + */ + public static boolean dispatchManaExact(ItemStack stack, EntityPlayer player, int manaToSend, boolean add) { + if (stack == null) return false; + + IInventory mainInv = player.inventory; + IInventory baublesInv = BotaniaAPI.internalHandler.getBaublesInventory(player); + + int invSize = mainInv.getSizeInventory(); + int size = invSize; + if (baublesInv != null) size += baublesInv.getSizeInventory(); + + for (int i = 0; i < size; i++) { + boolean useBaubles = i >= invSize; + IInventory inv = useBaubles ? baublesInv : mainInv; + int slot = i - (useBaubles ? invSize : 0); + ItemStack stackInSlot = inv.getStackInSlot(slot); + if (stackInSlot == stack) continue; + + if (stackInSlot != null && stackInSlot.getItem() instanceof IManaItem) { + IManaItem manaItemSlot = (IManaItem) stackInSlot.getItem(); + if (manaItemSlot.getMana(stackInSlot) + manaToSend <= manaItemSlot.getMaxMana(stackInSlot) + && manaItemSlot.canReceiveManaFromItem(stackInSlot, stack)) { + if (stack.getItem() instanceof IManaItem + && !((IManaItem) stack.getItem()).canExportManaToItem(stack, stackInSlot)) continue; + + if (add) manaItemSlot.addMana(stackInSlot, manaToSend); + if (useBaubles) BotaniaAPI.internalHandler.sendBaubleUpdatePacket(player, slot); + + return true; + } + } + } + + return false; + } + + /** + * Requests mana from items in a given player's inventory. This version also + * checks for IManaDiscountArmor items equipped to lower the cost. + * @param manaToGet How much mana is to be requested, if less mana exists than this amount, + * the amount of mana existent will be returned instead, if you want exact values use requestManaExact. + * @param remove If true, the mana will be removed from the target item. Set to false to just check. + * @return The amount of mana received from the request. + */ + public static int requestManaForTool(ItemStack stack, EntityPlayer player, int manaToGet, boolean remove) { + float multiplier = Math.max(0F, 1F - getFullDiscountForTools(player)); + int cost = (int) (manaToGet * multiplier); + return (int) (requestMana(stack, player, cost, remove) / multiplier); + } + + /** + * Requests an exact amount of mana from items in a given player's inventory. This version also + * checks for IManaDiscountArmor items equipped to lower the cost. + * @param manaToGet How much mana is to be requested, if less mana exists than this amount, + * false will be returned instead, and nothing will happen. + * @param remove If true, the mana will be removed from the target item. Set to false to just check. + * @return If the request was succesful. + */ + public static boolean requestManaExactForTool(ItemStack stack, EntityPlayer player, int manaToGet, boolean remove) { + float multiplier = Math.max(0F, 1F - getFullDiscountForTools(player)); + int cost = (int) (manaToGet * multiplier); + return requestManaExact(stack, player, cost, remove); + } + + /** + * Gets the sum of all the discounts on IManaDiscountArmor items equipped + * on the player passed in. + */ + public static float getFullDiscountForTools(EntityPlayer player) { + float discount = 0F; + for (int i = 0; i < player.inventory.armorInventory.length; i++) { + ItemStack armor = player.inventory.armorInventory[i]; + if (armor != null && armor.getItem() instanceof IManaDiscountArmor) + discount += ((IManaDiscountArmor) armor.getItem()).getDiscount(armor, i, player); + } + + return discount; + } } diff --git a/src/main/java/vazkii/botania/api/mana/ManaNetworkEvent.java b/src/main/java/vazkii/botania/api/mana/ManaNetworkEvent.java index 9116602c56..46d73b443d 100644 --- a/src/main/java/vazkii/botania/api/mana/ManaNetworkEvent.java +++ b/src/main/java/vazkii/botania/api/mana/ManaNetworkEvent.java @@ -2,55 +2,57 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jan 22, 2014, 5:04:30 PM (GMT)] */ package vazkii.botania.api.mana; +import cpw.mods.fml.common.eventhandler.Event; import net.minecraft.tileentity.TileEntity; import net.minecraftforge.common.MinecraftForge; -import cpw.mods.fml.common.eventhandler.Event; public class ManaNetworkEvent extends Event { - public final TileEntity tile; - public final ManaBlockType type; - public final Action action; - - public ManaNetworkEvent(TileEntity tile, ManaBlockType type, Action action) { - this.tile = tile; - this.type = type; - this.action = action; - } - - public static void addCollector(TileEntity tile) { - ManaNetworkEvent event = new ManaNetworkEvent(tile, ManaBlockType.COLLECTOR, Action.ADD); - MinecraftForge.EVENT_BUS.post(event); - } - - public static void removeCollector(TileEntity tile) { - ManaNetworkEvent event = new ManaNetworkEvent(tile, ManaBlockType.COLLECTOR, Action.REMOVE); - MinecraftForge.EVENT_BUS.post(event); - } - - public static void addPool(TileEntity tile) { - ManaNetworkEvent event = new ManaNetworkEvent(tile, ManaBlockType.POOL, Action.ADD); - MinecraftForge.EVENT_BUS.post(event); - } - - public static void removePool(TileEntity tile) { - ManaNetworkEvent event = new ManaNetworkEvent(tile, ManaBlockType.POOL, Action.REMOVE); - MinecraftForge.EVENT_BUS.post(event); - } - - public enum ManaBlockType { - POOL, COLLECTOR - } - - public enum Action { - REMOVE, ADD - } + public final TileEntity tile; + public final ManaBlockType type; + public final Action action; + + public ManaNetworkEvent(TileEntity tile, ManaBlockType type, Action action) { + this.tile = tile; + this.type = type; + this.action = action; + } + + public static void addCollector(TileEntity tile) { + ManaNetworkEvent event = new ManaNetworkEvent(tile, ManaBlockType.COLLECTOR, Action.ADD); + MinecraftForge.EVENT_BUS.post(event); + } + + public static void removeCollector(TileEntity tile) { + ManaNetworkEvent event = new ManaNetworkEvent(tile, ManaBlockType.COLLECTOR, Action.REMOVE); + MinecraftForge.EVENT_BUS.post(event); + } + + public static void addPool(TileEntity tile) { + ManaNetworkEvent event = new ManaNetworkEvent(tile, ManaBlockType.POOL, Action.ADD); + MinecraftForge.EVENT_BUS.post(event); + } + + public static void removePool(TileEntity tile) { + ManaNetworkEvent event = new ManaNetworkEvent(tile, ManaBlockType.POOL, Action.REMOVE); + MinecraftForge.EVENT_BUS.post(event); + } + + public enum ManaBlockType { + POOL, + COLLECTOR + } + + public enum Action { + REMOVE, + ADD + } } diff --git a/src/main/java/vazkii/botania/api/mana/TileSignature.java b/src/main/java/vazkii/botania/api/mana/TileSignature.java index 5573670da1..ae60ecb107 100644 --- a/src/main/java/vazkii/botania/api/mana/TileSignature.java +++ b/src/main/java/vazkii/botania/api/mana/TileSignature.java @@ -4,12 +4,11 @@ public class TileSignature { - public final TileEntity tile; - public final boolean remoteWorld; - - public TileSignature(TileEntity tile, boolean remoteWorld) { - this.tile = tile; - this.remoteWorld = remoteWorld; - } + public final TileEntity tile; + public final boolean remoteWorld; + public TileSignature(TileEntity tile, boolean remoteWorld) { + this.tile = tile; + this.remoteWorld = remoteWorld; + } } diff --git a/src/main/java/vazkii/botania/api/mana/spark/ISparkAttachable.java b/src/main/java/vazkii/botania/api/mana/spark/ISparkAttachable.java index 880e169fea..75c3d8d264 100644 --- a/src/main/java/vazkii/botania/api/mana/spark/ISparkAttachable.java +++ b/src/main/java/vazkii/botania/api/mana/spark/ISparkAttachable.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Aug 21, 2014, 5:44:13 PM (GMT)] */ package vazkii.botania.api.mana.spark; @@ -19,41 +19,40 @@ */ public interface ISparkAttachable extends IManaReceiver { - /** - * Can this block have a Spark attached to it. Note that this will not - * unattach the Spark if it's changed later. - */ - public boolean canAttachSpark(ItemStack stack); - - /** - * Called when the Spark is attached. - */ - public void attachSpark(ISparkEntity entity); - - /** - * Returns how much space for mana is available in this block, normally the total - the current. - * Should NEVER return negative values. Make sure to check against that. - */ - public int getAvailableSpaceForMana(); - - /** - * Gets the Spark that is attached to this block. A common implementation is - * to check for Spark entities above: - * - List sparks = worldObj.getEntitiesWithinAABB(ISparkEntity.class, AxisAlignedBB.getBoundingBox(xCoord, yCoord + 1, zCoord, xCoord + 1, yCoord + 2, zCoord + 1)); - if(sparks.size() == 1) { - Entity e = (Entity) sparks.get(0); - return (ISparkEntity) e; - } - - return null; - */ - public ISparkEntity getAttachedSpark(); - - /** - * Return true if this Tile no longer requires mana and all Sparks - * transferring mana to it should cancel their transfer. - */ - public boolean areIncomingTranfersDone(); - + /** + * Can this block have a Spark attached to it. Note that this will not + * unattach the Spark if it's changed later. + */ + public boolean canAttachSpark(ItemStack stack); + + /** + * Called when the Spark is attached. + */ + public void attachSpark(ISparkEntity entity); + + /** + * Returns how much space for mana is available in this block, normally the total - the current. + * Should NEVER return negative values. Make sure to check against that. + */ + public int getAvailableSpaceForMana(); + + /** + * Gets the Spark that is attached to this block. A common implementation is + * to check for Spark entities above: + * + * List sparks = worldObj.getEntitiesWithinAABB(ISparkEntity.class, AxisAlignedBB.getBoundingBox(xCoord, yCoord + 1, zCoord, xCoord + 1, yCoord + 2, zCoord + 1)); + * if(sparks.size() == 1) { + * Entity e = (Entity) sparks.get(0); + * return (ISparkEntity) e; + * } + * + * return null; + */ + public ISparkEntity getAttachedSpark(); + + /** + * Return true if this Tile no longer requires mana and all Sparks + * transferring mana to it should cancel their transfer. + */ + public boolean areIncomingTranfersDone(); } diff --git a/src/main/java/vazkii/botania/api/mana/spark/ISparkEntity.java b/src/main/java/vazkii/botania/api/mana/spark/ISparkEntity.java index e35076ceb6..6fed71eae4 100644 --- a/src/main/java/vazkii/botania/api/mana/spark/ISparkEntity.java +++ b/src/main/java/vazkii/botania/api/mana/spark/ISparkEntity.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Aug 21, 2014, 5:44:07 PM (GMT)] */ package vazkii.botania.api.mana.spark; @@ -17,48 +17,47 @@ */ public interface ISparkEntity { - /** - * Which TileEntity is this Spark attached to? A common implementation is checking the block below. - * - int x = MathHelper.floor_double(posX); - int y = MathHelper.floor_double(posY) - 1; - int z = MathHelper.floor_double(posZ); - TileEntity tile = worldObj.getTileEntity(x, y, z); - if(tile != null && tile instanceof ISparkAttachable) - return (ISparkAttachable) tile; - - return null; - */ - public ISparkAttachable getAttachedTile(); - - /** - * Gets a collection of all Sparks this is tranfering to. - */ - public Collection getTransfers(); - - /** - * Registers the Spark passed in as a Spark meant for mana to be transfered towards. - */ - public void registerTransfer(ISparkEntity entity); - - /** - * Gets which upgrade is in this Spark.
- * 0: None
- * 1: Dispersive
- * 2: Dominant
- * 3: Recessive
- * 4: Isolated - */ - public int getUpgrade(); - - /** - * Sets the upgrade on this Spark. See {@link ISparkEntity#getUpgrade} - */ - public void setUpgrade(int upgrade); - - /** - * See {@link ISparkAttachable#areIncomingTranfersDone()} - */ - public boolean areIncomingTransfersDone(); - + /** + * Which TileEntity is this Spark attached to? A common implementation is checking the block below. + * + * int x = MathHelper.floor_double(posX); + * int y = MathHelper.floor_double(posY) - 1; + * int z = MathHelper.floor_double(posZ); + * TileEntity tile = worldObj.getTileEntity(x, y, z); + * if(tile != null && tile instanceof ISparkAttachable) + * return (ISparkAttachable) tile; + * + * return null; + */ + public ISparkAttachable getAttachedTile(); + + /** + * Gets a collection of all Sparks this is tranfering to. + */ + public Collection getTransfers(); + + /** + * Registers the Spark passed in as a Spark meant for mana to be transfered towards. + */ + public void registerTransfer(ISparkEntity entity); + + /** + * Gets which upgrade is in this Spark.
+ * 0: None
+ * 1: Dispersive
+ * 2: Dominant
+ * 3: Recessive
+ * 4: Isolated + */ + public int getUpgrade(); + + /** + * Sets the upgrade on this Spark. See {@link ISparkEntity#getUpgrade} + */ + public void setUpgrade(int upgrade); + + /** + * See {@link ISparkAttachable#areIncomingTranfersDone()} + */ + public boolean areIncomingTransfersDone(); } diff --git a/src/main/java/vazkii/botania/api/mana/spark/SparkHelper.java b/src/main/java/vazkii/botania/api/mana/spark/SparkHelper.java index 7351036cf1..9baf3fa81e 100644 --- a/src/main/java/vazkii/botania/api/mana/spark/SparkHelper.java +++ b/src/main/java/vazkii/botania/api/mana/spark/SparkHelper.java @@ -2,31 +2,30 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Aug 21, 2014, 7:16:11 PM (GMT)] */ package vazkii.botania.api.mana.spark; import java.util.List; - import net.minecraft.util.AxisAlignedBB; import net.minecraft.world.World; public final class SparkHelper { - public static final int SPARK_SCAN_RANGE = 12; - - public static List getSparksAround(World world, double x, double y, double z) { - return SparkHelper.getEntitiesAround(ISparkEntity.class, world, x, y, z); - } + public static final int SPARK_SCAN_RANGE = 12; - public static List getEntitiesAround(Class clazz, World world, double x, double y, double z) { - int r = SPARK_SCAN_RANGE; - List entities = world.getEntitiesWithinAABB(clazz, AxisAlignedBB.getBoundingBox(x - r, y - r, z - r, x + r, y + r, z + r)); - return entities; - } + public static List getSparksAround(World world, double x, double y, double z) { + return SparkHelper.getEntitiesAround(ISparkEntity.class, world, x, y, z); + } + public static List getEntitiesAround(Class clazz, World world, double x, double y, double z) { + int r = SPARK_SCAN_RANGE; + List entities = world.getEntitiesWithinAABB( + clazz, AxisAlignedBB.getBoundingBox(x - r, y - r, z - r, x + r, y + r, z + r)); + return entities; + } } diff --git a/src/main/java/vazkii/botania/api/package-info.java b/src/main/java/vazkii/botania/api/package-info.java index f5ba9c0248..deffdad863 100644 --- a/src/main/java/vazkii/botania/api/package-info.java +++ b/src/main/java/vazkii/botania/api/package-info.java @@ -1,4 +1,4 @@ @API(owner = "Botania", apiVersion = "76", provides = "BotaniaAPI") package vazkii.botania.api; -import cpw.mods.fml.common.API; +import cpw.mods.fml.common.API; diff --git a/src/main/java/vazkii/botania/api/recipe/ElvenPortalUpdateEvent.java b/src/main/java/vazkii/botania/api/recipe/ElvenPortalUpdateEvent.java index 40d971359d..368ecacb22 100644 --- a/src/main/java/vazkii/botania/api/recipe/ElvenPortalUpdateEvent.java +++ b/src/main/java/vazkii/botania/api/recipe/ElvenPortalUpdateEvent.java @@ -2,20 +2,19 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Apr 17, 2015, 4:58:30 PM (GMT)] */ package vazkii.botania.api.recipe; +import cpw.mods.fml.common.eventhandler.Event; import java.util.List; - import net.minecraft.item.ItemStack; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.AxisAlignedBB; -import cpw.mods.fml.common.eventhandler.Event; /** * An event fired when an Elven Portal TE updates. The portal's @@ -24,19 +23,19 @@ */ public class ElvenPortalUpdateEvent extends Event { - /** - * May be casted to TileAlfPortal if you have botania code access aside from the API. - */ - public final TileEntity portalTile; - public final AxisAlignedBB aabb; - public boolean open; - public final List stacksInside; + /** + * May be casted to TileAlfPortal if you have botania code access aside from the API. + */ + public final TileEntity portalTile; - public ElvenPortalUpdateEvent(TileEntity te, AxisAlignedBB aabb, boolean open, List stacks) { - portalTile = te; - this.aabb = aabb; - this.open = open; - stacksInside = stacks; - } + public final AxisAlignedBB aabb; + public boolean open; + public final List stacksInside; + public ElvenPortalUpdateEvent(TileEntity te, AxisAlignedBB aabb, boolean open, List stacks) { + portalTile = te; + this.aabb = aabb; + this.open = open; + stacksInside = stacks; + } } diff --git a/src/main/java/vazkii/botania/api/recipe/IElvenItem.java b/src/main/java/vazkii/botania/api/recipe/IElvenItem.java index e614014d00..4bcbb80843 100644 --- a/src/main/java/vazkii/botania/api/recipe/IElvenItem.java +++ b/src/main/java/vazkii/botania/api/recipe/IElvenItem.java @@ -9,6 +9,5 @@ */ public interface IElvenItem { - public boolean isElvenItem(ItemStack stack); - + public boolean isElvenItem(ItemStack stack); } diff --git a/src/main/java/vazkii/botania/api/recipe/IFlowerComponent.java b/src/main/java/vazkii/botania/api/recipe/IFlowerComponent.java index ca46124123..9da22c5b8f 100644 --- a/src/main/java/vazkii/botania/api/recipe/IFlowerComponent.java +++ b/src/main/java/vazkii/botania/api/recipe/IFlowerComponent.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Feb 15, 2014, 2:36:35 PM (GMT)] */ package vazkii.botania.api.recipe; @@ -18,8 +18,7 @@ */ public interface IFlowerComponent { - public boolean canFit(ItemStack stack, IInventory apothecary); - - public int getParticleColor(ItemStack stack); + public boolean canFit(ItemStack stack, IInventory apothecary); + public int getParticleColor(ItemStack stack); } diff --git a/src/main/java/vazkii/botania/api/recipe/RecipeBrew.java b/src/main/java/vazkii/botania/api/recipe/RecipeBrew.java index 95577784ef..01a02e0c85 100644 --- a/src/main/java/vazkii/botania/api/recipe/RecipeBrew.java +++ b/src/main/java/vazkii/botania/api/recipe/RecipeBrew.java @@ -2,17 +2,16 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Nov 1, 2014, 8:52:00 PM (GMT)] */ package vazkii.botania.api.recipe; import java.util.ArrayList; import java.util.List; - import net.minecraft.init.Items; import net.minecraft.inventory.IInventory; import net.minecraft.item.ItemStack; @@ -22,93 +21,84 @@ public class RecipeBrew { - Brew brew; - List inputs; - - public RecipeBrew(Brew brew, Object... inputs) { - this.brew = brew; - - List inputsToSet = new ArrayList(); - for(Object obj : inputs) { - if(obj instanceof String || obj instanceof ItemStack) - inputsToSet.add(obj); - else throw new IllegalArgumentException("Invalid input"); - } - - this.inputs = inputsToSet; - } - - public boolean matches(IInventory inv) { - List inputsMissing = new ArrayList(inputs); - - for(int i = 0; i < inv.getSizeInventory(); i++) { - ItemStack stack = inv.getStackInSlot(i); - if(stack == null) - break; - - if(stack.getItem() instanceof IBrewContainer) - continue; - - int stackIndex = -1, oredictIndex = -1; - - for(int j = 0; j < inputsMissing.size(); j++) { - Object input = inputsMissing.get(j); - if(input instanceof String) { - List validStacks = OreDictionary.getOres((String) input); - boolean found = false; - for(ItemStack ostack : validStacks) { - ItemStack cstack = ostack.copy(); - if(cstack.getItemDamage() == Short.MAX_VALUE) - cstack.setItemDamage(stack.getItemDamage()); - - if(stack.isItemEqual(cstack)) { - oredictIndex = j; - found = true; - break; - } - } - - - if(found) - break; - } else if(input instanceof ItemStack && simpleAreStacksEqual((ItemStack) input, stack)) { - stackIndex = j; - break; - } - } - - if(stackIndex != -1) - inputsMissing.remove(stackIndex); - else if(oredictIndex != -1) - inputsMissing.remove(oredictIndex); - else return false; - } - - return inputsMissing.isEmpty(); - } - - boolean simpleAreStacksEqual(ItemStack stack, ItemStack stack2) { - return stack.getItem() == stack2.getItem() && stack.getItemDamage() == stack2.getItemDamage(); - } - - public List getInputs() { - return new ArrayList(inputs); - } - - public Brew getBrew() { - return brew; - } - - public int getManaUsage() { - return brew.getManaCost(); - } - - public ItemStack getOutput(ItemStack stack) { - if(stack == null || !(stack.getItem() instanceof IBrewContainer)) - return new ItemStack(Items.glass_bottle); // Fallback... - IBrewContainer container = (IBrewContainer) stack.getItem(); - - return container.getItemForBrew(brew, stack); - } - + Brew brew; + List inputs; + + public RecipeBrew(Brew brew, Object... inputs) { + this.brew = brew; + + List inputsToSet = new ArrayList(); + for (Object obj : inputs) { + if (obj instanceof String || obj instanceof ItemStack) inputsToSet.add(obj); + else throw new IllegalArgumentException("Invalid input"); + } + + this.inputs = inputsToSet; + } + + public boolean matches(IInventory inv) { + List inputsMissing = new ArrayList(inputs); + + for (int i = 0; i < inv.getSizeInventory(); i++) { + ItemStack stack = inv.getStackInSlot(i); + if (stack == null) break; + + if (stack.getItem() instanceof IBrewContainer) continue; + + int stackIndex = -1, oredictIndex = -1; + + for (int j = 0; j < inputsMissing.size(); j++) { + Object input = inputsMissing.get(j); + if (input instanceof String) { + List validStacks = OreDictionary.getOres((String) input); + boolean found = false; + for (ItemStack ostack : validStacks) { + ItemStack cstack = ostack.copy(); + if (cstack.getItemDamage() == Short.MAX_VALUE) cstack.setItemDamage(stack.getItemDamage()); + + if (stack.isItemEqual(cstack)) { + oredictIndex = j; + found = true; + break; + } + } + + if (found) break; + } else if (input instanceof ItemStack && simpleAreStacksEqual((ItemStack) input, stack)) { + stackIndex = j; + break; + } + } + + if (stackIndex != -1) inputsMissing.remove(stackIndex); + else if (oredictIndex != -1) inputsMissing.remove(oredictIndex); + else return false; + } + + return inputsMissing.isEmpty(); + } + + boolean simpleAreStacksEqual(ItemStack stack, ItemStack stack2) { + return stack.getItem() == stack2.getItem() && stack.getItemDamage() == stack2.getItemDamage(); + } + + public List getInputs() { + return new ArrayList(inputs); + } + + public Brew getBrew() { + return brew; + } + + public int getManaUsage() { + return brew.getManaCost(); + } + + public ItemStack getOutput(ItemStack stack) { + if (stack == null || !(stack.getItem() instanceof IBrewContainer)) + return new ItemStack(Items.glass_bottle); // Fallback... + IBrewContainer container = (IBrewContainer) stack.getItem(); + + return container.getItemForBrew(brew, stack); + } } diff --git a/src/main/java/vazkii/botania/api/recipe/RecipeElvenTrade.java b/src/main/java/vazkii/botania/api/recipe/RecipeElvenTrade.java index dbea13e86c..9e14b6738c 100644 --- a/src/main/java/vazkii/botania/api/recipe/RecipeElvenTrade.java +++ b/src/main/java/vazkii/botania/api/recipe/RecipeElvenTrade.java @@ -2,93 +2,81 @@ import java.util.ArrayList; import java.util.List; - import net.minecraft.item.ItemStack; import net.minecraftforge.oredict.OreDictionary; public class RecipeElvenTrade { - ItemStack output; - List inputs; - - public RecipeElvenTrade(ItemStack output, Object... inputs) { - this.output = output; - - List inputsToSet = new ArrayList(); - for(Object obj : inputs) { - if(obj instanceof String || obj instanceof ItemStack) - inputsToSet.add(obj); - else throw new IllegalArgumentException("Invalid input"); - } - - this.inputs = inputsToSet; - } - - public boolean matches(List stacks, boolean remove) { - List inputsMissing = new ArrayList(inputs); - List stacksToRemove = new ArrayList(); - - for(ItemStack stack : stacks) { - if(stack == null) { - continue; - } - if(inputsMissing.isEmpty()) - break; - - int stackIndex = -1, oredictIndex = -1; - - for(int j = 0; j < inputsMissing.size(); j++) { - Object input = inputsMissing.get(j); - if(input instanceof String) { - List validStacks = OreDictionary.getOres((String) input); - boolean found = false; - for(ItemStack ostack : validStacks) { - ItemStack cstack = ostack.copy(); - if(cstack.getItemDamage() == Short.MAX_VALUE) - cstack.setItemDamage(stack.getItemDamage()); - - if(stack.isItemEqual(cstack)) { - if(!stacksToRemove.contains(stack)) - stacksToRemove.add(stack); - oredictIndex = j; - found = true; - break; - } - } - - if(found) - break; - } else if(input instanceof ItemStack && simpleAreStacksEqual((ItemStack) input, stack)) { - if(!stacksToRemove.contains(stack)) - stacksToRemove.add(stack); - stackIndex = j; - break; - } - } - - if(stackIndex != -1) - inputsMissing.remove(stackIndex); - else if(oredictIndex != -1) - inputsMissing.remove(oredictIndex); - } - - if(remove) - for(ItemStack r : stacksToRemove) - stacks.remove(r); - - return inputsMissing.isEmpty(); - } - - boolean simpleAreStacksEqual(ItemStack stack, ItemStack stack2) { - return stack.getItem() == stack2.getItem() && stack.getItemDamage() == stack2.getItemDamage(); - } - - public List getInputs() { - return new ArrayList(inputs); - } - - public ItemStack getOutput() { - return output; - } - + ItemStack output; + List inputs; + + public RecipeElvenTrade(ItemStack output, Object... inputs) { + this.output = output; + + List inputsToSet = new ArrayList(); + for (Object obj : inputs) { + if (obj instanceof String || obj instanceof ItemStack) inputsToSet.add(obj); + else throw new IllegalArgumentException("Invalid input"); + } + + this.inputs = inputsToSet; + } + + public boolean matches(List stacks, boolean remove) { + List inputsMissing = new ArrayList(inputs); + List stacksToRemove = new ArrayList(); + + for (ItemStack stack : stacks) { + if (stack == null) { + continue; + } + if (inputsMissing.isEmpty()) break; + + int stackIndex = -1, oredictIndex = -1; + + for (int j = 0; j < inputsMissing.size(); j++) { + Object input = inputsMissing.get(j); + if (input instanceof String) { + List validStacks = OreDictionary.getOres((String) input); + boolean found = false; + for (ItemStack ostack : validStacks) { + ItemStack cstack = ostack.copy(); + if (cstack.getItemDamage() == Short.MAX_VALUE) cstack.setItemDamage(stack.getItemDamage()); + + if (stack.isItemEqual(cstack)) { + if (!stacksToRemove.contains(stack)) stacksToRemove.add(stack); + oredictIndex = j; + found = true; + break; + } + } + + if (found) break; + } else if (input instanceof ItemStack && simpleAreStacksEqual((ItemStack) input, stack)) { + if (!stacksToRemove.contains(stack)) stacksToRemove.add(stack); + stackIndex = j; + break; + } + } + + if (stackIndex != -1) inputsMissing.remove(stackIndex); + else if (oredictIndex != -1) inputsMissing.remove(oredictIndex); + } + + if (remove) for (ItemStack r : stacksToRemove) stacks.remove(r); + + return inputsMissing.isEmpty(); + } + + boolean simpleAreStacksEqual(ItemStack stack, ItemStack stack2) { + return stack.getItem() == stack2.getItem() && stack.getItemDamage() == stack2.getItemDamage(); + } + + public List getInputs() { + return new ArrayList(inputs); + } + + public ItemStack getOutput() { + return output; + } } diff --git a/src/main/java/vazkii/botania/api/recipe/RecipeManaInfusion.java b/src/main/java/vazkii/botania/api/recipe/RecipeManaInfusion.java index 368c8d4c43..b5dc0b70df 100644 --- a/src/main/java/vazkii/botania/api/recipe/RecipeManaInfusion.java +++ b/src/main/java/vazkii/botania/api/recipe/RecipeManaInfusion.java @@ -2,84 +2,79 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jan 30, 2014, 5:57:07 PM (GMT)] */ package vazkii.botania.api.recipe; import java.util.List; - import net.minecraft.item.ItemStack; import net.minecraftforge.oredict.OreDictionary; public class RecipeManaInfusion { - ItemStack output; - Object input; - int mana; - boolean isAlchemy = false; - boolean isConjuration = false; - - public RecipeManaInfusion(ItemStack output, Object input, int mana) { - this.output = output; - this.input = input; - this.mana = mana; - } - - public boolean matches(ItemStack stack) { - if(input instanceof ItemStack) { - ItemStack inputCopy = ((ItemStack) input).copy(); - if(inputCopy.getItemDamage() == Short.MAX_VALUE) - inputCopy.setItemDamage(stack.getItemDamage()); - - return stack.isItemEqual(inputCopy); - } - - if(input instanceof String) { - List validStacks = OreDictionary.getOres((String) input); - - for(ItemStack ostack : validStacks) { - ItemStack cstack = ostack.copy(); - if(cstack.getItemDamage() == Short.MAX_VALUE) - cstack.setItemDamage(stack.getItemDamage()); - - if(stack.isItemEqual(cstack)) - return true; - } - } - - return false; - } - - public void setAlchemy(boolean alchemy) { - isAlchemy = alchemy; - } - - public boolean isAlchemy() { - return isAlchemy; - } - - public void setConjuration(boolean conjuration) { - isConjuration = conjuration; - } - - public boolean isConjuration() { - return isConjuration; - } - - public Object getInput() { - return input; - } - - public ItemStack getOutput() { - return output; - } - - public int getManaToConsume() { - return mana; - } -} + ItemStack output; + Object input; + int mana; + boolean isAlchemy = false; + boolean isConjuration = false; + + public RecipeManaInfusion(ItemStack output, Object input, int mana) { + this.output = output; + this.input = input; + this.mana = mana; + } + + public boolean matches(ItemStack stack) { + if (input instanceof ItemStack) { + ItemStack inputCopy = ((ItemStack) input).copy(); + if (inputCopy.getItemDamage() == Short.MAX_VALUE) inputCopy.setItemDamage(stack.getItemDamage()); + + return stack.isItemEqual(inputCopy); + } + + if (input instanceof String) { + List validStacks = OreDictionary.getOres((String) input); + + for (ItemStack ostack : validStacks) { + ItemStack cstack = ostack.copy(); + if (cstack.getItemDamage() == Short.MAX_VALUE) cstack.setItemDamage(stack.getItemDamage()); + + if (stack.isItemEqual(cstack)) return true; + } + } + return false; + } + + public void setAlchemy(boolean alchemy) { + isAlchemy = alchemy; + } + + public boolean isAlchemy() { + return isAlchemy; + } + + public void setConjuration(boolean conjuration) { + isConjuration = conjuration; + } + + public boolean isConjuration() { + return isConjuration; + } + + public Object getInput() { + return input; + } + + public ItemStack getOutput() { + return output; + } + + public int getManaToConsume() { + return mana; + } +} diff --git a/src/main/java/vazkii/botania/api/recipe/RecipeMiniFlower.java b/src/main/java/vazkii/botania/api/recipe/RecipeMiniFlower.java index 92908c0a7e..62932f0b57 100644 --- a/src/main/java/vazkii/botania/api/recipe/RecipeMiniFlower.java +++ b/src/main/java/vazkii/botania/api/recipe/RecipeMiniFlower.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Apr 22, 2015, 5:57:59 PM (GMT)] */ package vazkii.botania.api.recipe; @@ -15,16 +15,20 @@ public class RecipeMiniFlower extends RecipeManaInfusion { - public RecipeMiniFlower(String flower, String mini, int mana) { - super(BotaniaAPI.internalHandler.getSubTileAsStack(flower), BotaniaAPI.internalHandler.getSubTileAsStack(mini), mana); - setAlchemy(true); - } - - @Override - public boolean matches(ItemStack stack) { - String key = BotaniaAPI.internalHandler.getStackSubTileKey(stack); - String input = this.input instanceof String ? (String) this.input : BotaniaAPI.internalHandler.getStackSubTileKey((ItemStack) this.input); - return key != null && key.equals(input); - } + public RecipeMiniFlower(String flower, String mini, int mana) { + super( + BotaniaAPI.internalHandler.getSubTileAsStack(flower), + BotaniaAPI.internalHandler.getSubTileAsStack(mini), + mana); + setAlchemy(true); + } + @Override + public boolean matches(ItemStack stack) { + String key = BotaniaAPI.internalHandler.getStackSubTileKey(stack); + String input = this.input instanceof String + ? (String) this.input + : BotaniaAPI.internalHandler.getStackSubTileKey((ItemStack) this.input); + return key != null && key.equals(input); + } } diff --git a/src/main/java/vazkii/botania/api/recipe/RecipePetals.java b/src/main/java/vazkii/botania/api/recipe/RecipePetals.java index 60e46357fb..d2f54060e4 100644 --- a/src/main/java/vazkii/botania/api/recipe/RecipePetals.java +++ b/src/main/java/vazkii/botania/api/recipe/RecipePetals.java @@ -2,95 +2,86 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jan 22, 2014, 2:02:44 PM (GMT)] */ package vazkii.botania.api.recipe; import java.util.ArrayList; import java.util.List; - import net.minecraft.inventory.IInventory; import net.minecraft.item.ItemStack; import net.minecraftforge.oredict.OreDictionary; public class RecipePetals { - ItemStack output; - List inputs; - - public RecipePetals(ItemStack output, Object... inputs) { - this.output = output; - - List inputsToSet = new ArrayList(); - for(Object obj : inputs) { - if(obj instanceof String || obj instanceof ItemStack) - inputsToSet.add(obj); - else throw new IllegalArgumentException("Invalid input"); - } - - this.inputs = inputsToSet; - } - - public boolean matches(IInventory inv) { - List inputsMissing = new ArrayList(inputs); - - for(int i = 0; i < inv.getSizeInventory(); i++) { - ItemStack stack = inv.getStackInSlot(i); - if(stack == null) - break; - - int stackIndex = -1, oredictIndex = -1; - - for(int j = 0; j < inputsMissing.size(); j++) { - Object input = inputsMissing.get(j); - if(input instanceof String) { - List validStacks = OreDictionary.getOres((String) input); - boolean found = false; - for(ItemStack ostack : validStacks) { - ItemStack cstack = ostack.copy(); - if(cstack.getItemDamage() == Short.MAX_VALUE) - cstack.setItemDamage(stack.getItemDamage()); - - if(stack.isItemEqual(cstack)) { - oredictIndex = j; - found = true; - break; - } - } - - - if(found) - break; - } else if(input instanceof ItemStack && simpleAreStacksEqual((ItemStack) input, stack)) { - stackIndex = j; - break; - } - } - - if(stackIndex != -1) - inputsMissing.remove(stackIndex); - else if(oredictIndex != -1) - inputsMissing.remove(oredictIndex); - else return false; - } - - return inputsMissing.isEmpty(); - } - - boolean simpleAreStacksEqual(ItemStack stack, ItemStack stack2) { - return stack.getItem() == stack2.getItem() && stack.getItemDamage() == stack2.getItemDamage(); - } - - public List getInputs() { - return new ArrayList(inputs); - } - - public ItemStack getOutput() { - return output; - } - + ItemStack output; + List inputs; + + public RecipePetals(ItemStack output, Object... inputs) { + this.output = output; + + List inputsToSet = new ArrayList(); + for (Object obj : inputs) { + if (obj instanceof String || obj instanceof ItemStack) inputsToSet.add(obj); + else throw new IllegalArgumentException("Invalid input"); + } + + this.inputs = inputsToSet; + } + + public boolean matches(IInventory inv) { + List inputsMissing = new ArrayList(inputs); + + for (int i = 0; i < inv.getSizeInventory(); i++) { + ItemStack stack = inv.getStackInSlot(i); + if (stack == null) break; + + int stackIndex = -1, oredictIndex = -1; + + for (int j = 0; j < inputsMissing.size(); j++) { + Object input = inputsMissing.get(j); + if (input instanceof String) { + List validStacks = OreDictionary.getOres((String) input); + boolean found = false; + for (ItemStack ostack : validStacks) { + ItemStack cstack = ostack.copy(); + if (cstack.getItemDamage() == Short.MAX_VALUE) cstack.setItemDamage(stack.getItemDamage()); + + if (stack.isItemEqual(cstack)) { + oredictIndex = j; + found = true; + break; + } + } + + if (found) break; + } else if (input instanceof ItemStack && simpleAreStacksEqual((ItemStack) input, stack)) { + stackIndex = j; + break; + } + } + + if (stackIndex != -1) inputsMissing.remove(stackIndex); + else if (oredictIndex != -1) inputsMissing.remove(oredictIndex); + else return false; + } + + return inputsMissing.isEmpty(); + } + + boolean simpleAreStacksEqual(ItemStack stack, ItemStack stack2) { + return stack.getItem() == stack2.getItem() && stack.getItemDamage() == stack2.getItemDamage(); + } + + public List getInputs() { + return new ArrayList(inputs); + } + + public ItemStack getOutput() { + return output; + } } diff --git a/src/main/java/vazkii/botania/api/recipe/RecipePureDaisy.java b/src/main/java/vazkii/botania/api/recipe/RecipePureDaisy.java index 19248e69bd..d3cedc6abe 100644 --- a/src/main/java/vazkii/botania/api/recipe/RecipePureDaisy.java +++ b/src/main/java/vazkii/botania/api/recipe/RecipePureDaisy.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Apr 17, 2015, 5:07:25 PM (GMT)] */ package vazkii.botania.api.recipe; @@ -13,7 +13,6 @@ import java.util.HashMap; import java.util.List; import java.util.Map; - import net.minecraft.block.Block; import net.minecraft.item.ItemStack; import net.minecraft.world.World; @@ -22,78 +21,71 @@ public class RecipePureDaisy { - private static final Map> oreMap = new HashMap(); - - Object input; - Block output; - int outputMeta; - - public RecipePureDaisy(Object input, Block output, int outputMeta) { - this.input = input; - this.output = output; - this.outputMeta = outputMeta; - - if(input != null && !(input instanceof String || input instanceof Block)) - throw new IllegalArgumentException("input must be an oredict String or a Block."); - } - - /** - * This gets called every tick, please be careful with your checks. - */ - public boolean matches(World world, int x, int y, int z, SubTileEntity pureDaisy, Block block, int meta) { - if(input instanceof Block) - return block == input; - - ItemStack stack = new ItemStack(block, 1, meta); - String oredict = (String) input; - return isOreDict(stack, oredict); - } - - public boolean isOreDict(ItemStack stack, String entry) { - if(stack == null || stack.getItem() == null) - return false; - - List ores; - if(oreMap.containsKey(entry)) - ores = oreMap.get(entry); - else { - ores = OreDictionary.getOres(entry); - oreMap.put(entry, ores); - } - - for(ItemStack ostack : ores) { - ItemStack cstack = ostack.copy(); - if(cstack.getItemDamage() == Short.MAX_VALUE) - cstack.setItemDamage(stack.getItemDamage()); - - if(stack.isItemEqual(cstack)) - return true; - } - - return false; - } - - /** - * Returns true if the block was placed (and if the Pure Daisy should do particles and stuffs). - * Should only place the block if !world.isRemote, but should return true if it would've placed - * it otherwise. You may return false to cancel the normal particles and do your own. - */ - public boolean set(World world, int x, int y, int z, SubTileEntity pureDaisy) { - if(!world.isRemote) - world.setBlock(x, y, z, output, outputMeta, 1 | 2); - return true; - } - - public Object getInput() { - return input; - } - - public Block getOutput() { - return output; - } - - public int getOutputMeta() { - return outputMeta; - } - + private static final Map> oreMap = new HashMap(); + + Object input; + Block output; + int outputMeta; + + public RecipePureDaisy(Object input, Block output, int outputMeta) { + this.input = input; + this.output = output; + this.outputMeta = outputMeta; + + if (input != null && !(input instanceof String || input instanceof Block)) + throw new IllegalArgumentException("input must be an oredict String or a Block."); + } + + /** + * This gets called every tick, please be careful with your checks. + */ + public boolean matches(World world, int x, int y, int z, SubTileEntity pureDaisy, Block block, int meta) { + if (input instanceof Block) return block == input; + + ItemStack stack = new ItemStack(block, 1, meta); + String oredict = (String) input; + return isOreDict(stack, oredict); + } + + public boolean isOreDict(ItemStack stack, String entry) { + if (stack == null || stack.getItem() == null) return false; + + List ores; + if (oreMap.containsKey(entry)) ores = oreMap.get(entry); + else { + ores = OreDictionary.getOres(entry); + oreMap.put(entry, ores); + } + + for (ItemStack ostack : ores) { + ItemStack cstack = ostack.copy(); + if (cstack.getItemDamage() == Short.MAX_VALUE) cstack.setItemDamage(stack.getItemDamage()); + + if (stack.isItemEqual(cstack)) return true; + } + + return false; + } + + /** + * Returns true if the block was placed (and if the Pure Daisy should do particles and stuffs). + * Should only place the block if !world.isRemote, but should return true if it would've placed + * it otherwise. You may return false to cancel the normal particles and do your own. + */ + public boolean set(World world, int x, int y, int z, SubTileEntity pureDaisy) { + if (!world.isRemote) world.setBlock(x, y, z, output, outputMeta, 1 | 2); + return true; + } + + public Object getInput() { + return input; + } + + public Block getOutput() { + return output; + } + + public int getOutputMeta() { + return outputMeta; + } } diff --git a/src/main/java/vazkii/botania/api/recipe/RecipeRuneAltar.java b/src/main/java/vazkii/botania/api/recipe/RecipeRuneAltar.java index f8bb211c10..9036f19a7c 100644 --- a/src/main/java/vazkii/botania/api/recipe/RecipeRuneAltar.java +++ b/src/main/java/vazkii/botania/api/recipe/RecipeRuneAltar.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Feb 5, 2014, 1:41:14 PM (GMT)] */ package vazkii.botania.api.recipe; @@ -14,15 +14,14 @@ public class RecipeRuneAltar extends RecipePetals { - int mana; + int mana; - public RecipeRuneAltar(ItemStack output, int mana, Object... inputs) { - super(output, inputs); - this.mana = mana; - } - - public int getManaUsage() { - return mana; - } + public RecipeRuneAltar(ItemStack output, int mana, Object... inputs) { + super(output, inputs); + this.mana = mana; + } + public int getManaUsage() { + return mana; + } } diff --git a/src/main/java/vazkii/botania/api/subtile/ISpecialFlower.java b/src/main/java/vazkii/botania/api/subtile/ISpecialFlower.java index 3bca4313c1..862670509f 100644 --- a/src/main/java/vazkii/botania/api/subtile/ISpecialFlower.java +++ b/src/main/java/vazkii/botania/api/subtile/ISpecialFlower.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jan 22, 2014, 7:12:28 PM (GMT)] */ package vazkii.botania.api.subtile; @@ -15,6 +15,4 @@ * BlockFlower would be checked against, but isn't convenient for * the special flowers with effects. For Azanor and Lycaon. */ -public interface ISpecialFlower { - -} +public interface ISpecialFlower {} diff --git a/src/main/java/vazkii/botania/api/subtile/ISubTileContainer.java b/src/main/java/vazkii/botania/api/subtile/ISubTileContainer.java index 3a99d6d868..a36b7accea 100644 --- a/src/main/java/vazkii/botania/api/subtile/ISubTileContainer.java +++ b/src/main/java/vazkii/botania/api/subtile/ISubTileContainer.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Aug 26, 2014, 5:42:16 PM (GMT)] */ package vazkii.botania.api.subtile; @@ -15,15 +15,14 @@ */ public interface ISubTileContainer { - /** - * Gets the SubTile in this block. Generally shouldn't return null, but in that - * case use the fallback DummySubTile. - */ - public SubTileEntity getSubTile(); - - /** - * Sets the SubTile on this block from it's name. - */ - public void setSubTile(String name); + /** + * Gets the SubTile in this block. Generally shouldn't return null, but in that + * case use the fallback DummySubTile. + */ + public SubTileEntity getSubTile(); + /** + * Sets the SubTile on this block from it's name. + */ + public void setSubTile(String name); } diff --git a/src/main/java/vazkii/botania/api/subtile/ISubTileSlowableContainer.java b/src/main/java/vazkii/botania/api/subtile/ISubTileSlowableContainer.java index 6092cd618c..1fa0e00905 100644 --- a/src/main/java/vazkii/botania/api/subtile/ISubTileSlowableContainer.java +++ b/src/main/java/vazkii/botania/api/subtile/ISubTileSlowableContainer.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [29/12/2015, 23:00:06 (GMT)] */ package vazkii.botania.api.subtile; @@ -18,9 +18,8 @@ */ public interface ISubTileSlowableContainer extends ISubTileContainer { - public static final int SLOWDOWN_FACTOR_PODZOL = 5; - public static final int SLOWDOWN_FACTOR_MYCEL = 10; - - public int getSlowdownFactor(); - + public static final int SLOWDOWN_FACTOR_PODZOL = 5; + public static final int SLOWDOWN_FACTOR_MYCEL = 10; + + public int getSlowdownFactor(); } diff --git a/src/main/java/vazkii/botania/api/subtile/RadiusDescriptor.java b/src/main/java/vazkii/botania/api/subtile/RadiusDescriptor.java index f57b6fa71d..0d5f01ab03 100644 --- a/src/main/java/vazkii/botania/api/subtile/RadiusDescriptor.java +++ b/src/main/java/vazkii/botania/api/subtile/RadiusDescriptor.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Mar 31, 2015, 2:59:19 PM (GMT)] */ package vazkii.botania.api.subtile; @@ -19,71 +19,75 @@ */ public class RadiusDescriptor { - final ChunkCoordinates subtileCoords; - - public RadiusDescriptor(ChunkCoordinates subtileCoords) { - this.subtileCoords = subtileCoords; - } - - public ChunkCoordinates getSubtileCoords() { - return subtileCoords; - } - - public boolean isCircle() { - return false; - } - - public double getCircleRadius() { - return 0; - } - - public AxisAlignedBB getAABB() { - return null; - } - - public static class Circle extends RadiusDescriptor { - - final double radius; - - public Circle(ChunkCoordinates subtileCoords, double radius) { - super(subtileCoords); - this.radius = radius; - } - - @Override - public boolean isCircle() { - return true; - } - - @Override - public double getCircleRadius() { - return radius; - } - - } - - public static class Rectangle extends RadiusDescriptor { - - final AxisAlignedBB aabb; - - public Rectangle(ChunkCoordinates subtileCoords, AxisAlignedBB aabb) { - super(subtileCoords); - this.aabb = aabb; - } - - @Override - public AxisAlignedBB getAABB() { - return aabb; - } - - } - - public static class Square extends Rectangle { - - public Square(ChunkCoordinates subtileCoords, int expand) { - super(subtileCoords, AxisAlignedBB.getBoundingBox(subtileCoords.posX - expand, subtileCoords.posY, subtileCoords.posZ - expand, subtileCoords.posX + 1 + expand, subtileCoords.posY, subtileCoords.posZ + 1 + expand)); - } - - } - + final ChunkCoordinates subtileCoords; + + public RadiusDescriptor(ChunkCoordinates subtileCoords) { + this.subtileCoords = subtileCoords; + } + + public ChunkCoordinates getSubtileCoords() { + return subtileCoords; + } + + public boolean isCircle() { + return false; + } + + public double getCircleRadius() { + return 0; + } + + public AxisAlignedBB getAABB() { + return null; + } + + public static class Circle extends RadiusDescriptor { + + final double radius; + + public Circle(ChunkCoordinates subtileCoords, double radius) { + super(subtileCoords); + this.radius = radius; + } + + @Override + public boolean isCircle() { + return true; + } + + @Override + public double getCircleRadius() { + return radius; + } + } + + public static class Rectangle extends RadiusDescriptor { + + final AxisAlignedBB aabb; + + public Rectangle(ChunkCoordinates subtileCoords, AxisAlignedBB aabb) { + super(subtileCoords); + this.aabb = aabb; + } + + @Override + public AxisAlignedBB getAABB() { + return aabb; + } + } + + public static class Square extends Rectangle { + + public Square(ChunkCoordinates subtileCoords, int expand) { + super( + subtileCoords, + AxisAlignedBB.getBoundingBox( + subtileCoords.posX - expand, + subtileCoords.posY, + subtileCoords.posZ - expand, + subtileCoords.posX + 1 + expand, + subtileCoords.posY, + subtileCoords.posZ + 1 + expand)); + } + } } diff --git a/src/main/java/vazkii/botania/api/subtile/SubTileEntity.java b/src/main/java/vazkii/botania/api/subtile/SubTileEntity.java index 2b98121c16..ad16ca6df4 100644 --- a/src/main/java/vazkii/botania/api/subtile/SubTileEntity.java +++ b/src/main/java/vazkii/botania/api/subtile/SubTileEntity.java @@ -2,16 +2,17 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jan 24, 2014, 3:59:06 PM (GMT)] */ package vazkii.botania.api.subtile; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; import java.util.ArrayList; - import net.minecraft.client.Minecraft; import net.minecraft.client.gui.ScaledResolution; import net.minecraft.entity.EntityLivingBase; @@ -26,8 +27,6 @@ import vazkii.botania.api.internal.VanillaPacketDispatcher; import vazkii.botania.api.lexicon.LexiconEntry; import vazkii.botania.api.wand.IWandBindable; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; /** * A Sub-TileEntity, this is used for the flower system. Make sure to map subclasses @@ -36,208 +35,209 @@ */ public class SubTileEntity { - protected TileEntity supertile; - - public int ticksExisted = 0; - - /** true if this flower is working on Enchanted Soil **/ - public boolean overgrowth = false; - /** true if this flower is working on Enchanted Soil and this is the second tick **/ - public boolean overgrowthBoost = false; - - /** The Tag items should use to store which sub tile they are. **/ - public static final String TAG_TYPE = "type"; - public static final String TAG_TICKS_EXISTED = "ticksExisted"; - - public void setSupertile(TileEntity tile) { - supertile = tile; - } - - public boolean canUpdate() { - return true; - } - - public void onUpdate() { - ticksExisted++; - } - - public final void writeToPacketNBTInternal(NBTTagCompound cmp) { - cmp.setInteger(TAG_TICKS_EXISTED, ticksExisted); - writeToPacketNBT(cmp); - } - - public final void readFromPacketNBTInternal(NBTTagCompound cmp) { - if(cmp.hasKey(TAG_TICKS_EXISTED)) - ticksExisted = cmp.getInteger(TAG_TICKS_EXISTED); - readFromPacketNBT(cmp); - } - - /** - * Writes some extra data to a network packet. This data is read - * by readFromPacketNBT on the client that receives the packet. - * Note: This method is also used to write to the world NBT. - */ - public void writeToPacketNBT(NBTTagCompound cmp) { } - - /** - * Reads data from a network packet. This data is written by - * writeToPacketNBT in the server. Note: This method is also used - * to read from the world NBT. - */ - public void readFromPacketNBT(NBTTagCompound cmp) { } - - public void sync() { - VanillaPacketDispatcher.dispatchTEToNearbyPlayers(supertile); - } - - public String getUnlocalizedName() { - return BotaniaAPI.getSubTileStringMapping(getClass()); - } - - /** - * Gets the icon for this SubTileEntity, this is a block icon. - */ - @SideOnly(Side.CLIENT) - public IIcon getIcon() { - return BotaniaAPI.internalHandler.getSubTileIconForName(getUnlocalizedName()); - } - - /** - * Called when a Wand of the Forest is used on this sub tile. Note that the - * player parameter can be null if this is called from a dispenser. - */ - public boolean onWanded(EntityPlayer player, ItemStack wand) { - return false; - } - - /** - * Called when this sub tile is placed in the world (by an entity). - */ - public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase entity, ItemStack stack) { - // NO-OP - } - - /** - * Called when a player right clicks this sub tile. - */ - public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int side, float hitX, float hitY, float hitZ) { return false; } - - /** - * Called when this sub tile is added to the world. - */ - public void onBlockAdded(World world, int x, int y, int z) { - //NO-OP - } - - /** - * Called when this sub tile is harvested - */ - public void onBlockHarvested(World world, int x, int y, int z, int side, EntityPlayer player) { - //NO-OP - } - - /** - * Allows additional processing of sub tile drops - */ - public ArrayList getDrops(ArrayList list) { - return list; - } - - /** - * Gets which Lexicon Entry to open when this sub tile is right clicked with a lexicon. - */ - public LexiconEntry getEntry() { - return null; - } - - /** - * Gets the block coordinates this is bound to, for use with the wireframe render - * when the sub tile is being hovered with a wand of the forest. - */ - @SideOnly(Side.CLIENT) - public ChunkCoordinates getBinding() { - return null; - } - - /** - * Returns a descriptor for the radius of this sub tile. This is called while a player - * is looking at the block with a Manaseer Monocle (IBurstViewerBauble). - */ - @SideOnly(Side.CLIENT) - public RadiusDescriptor getRadius() { - return null; - } - - /** - * Gets a ChunkCoordinates instance with the position of this sub tile. - */ - public ChunkCoordinates toChunkCoordinates() { - return new ChunkCoordinates(supertile.xCoord, supertile.yCoord, supertile.zCoord); - } - - /** - * @see IWandBindable#canSelect(EntityPlayer, ItemStack, int, int, int, int) - */ - public boolean canSelect(EntityPlayer player, ItemStack wand, int x, int y, int z, int side) { - return false; - } - - /** - * @see IWandBindable#bindTo(EntityPlayer, ItemStack, int, int, int, int) - */ - public boolean bindTo(EntityPlayer player, ItemStack wand, int x, int y, int z, int side) { - return false; - } - - /** - * Called on the client when the block being pointed at is the one with this sub tile. - * Used to render a HUD portraying some data from this sub tile. - */ - @SideOnly(Side.CLIENT) - public void renderHUD(Minecraft mc, ScaledResolution res) { - // NO-OP - } - - /** - * Gets the light value for this SubTileEntity, this is a int (-1 to default to the flower) - */ - public int getLightValue() { - return -1; - } - - /** - * Gets the comparator input value for this SubTileEntity - */ - public int getComparatorInputOverride(int side) { - return 0; - } - - /** - * Gets the redstone power level for this SubTileEntity - */ - public int getPowerLevel(int side) { - return 0; - } - - /** - * Gets if this SubTileEntity is affected by Enchanted Soil's speed boost. - */ - public boolean isOvergrowthAffected() { - return true; - } - - /** - * Gets ths slowdown factor of this SubTile. - * @see ISubTileSlowableContainer - */ - public int getSlowdownFactor() { - if(supertile instanceof ISubTileSlowableContainer) { - ISubTileSlowableContainer slowable = (ISubTileSlowableContainer) supertile; - return slowable.getSlowdownFactor(); - } - - return 0; - } - - + protected TileEntity supertile; + + public int ticksExisted = 0; + + /** true if this flower is working on Enchanted Soil **/ + public boolean overgrowth = false; + /** true if this flower is working on Enchanted Soil and this is the second tick **/ + public boolean overgrowthBoost = false; + + /** The Tag items should use to store which sub tile they are. **/ + public static final String TAG_TYPE = "type"; + + public static final String TAG_TICKS_EXISTED = "ticksExisted"; + + public void setSupertile(TileEntity tile) { + supertile = tile; + } + + public boolean canUpdate() { + return true; + } + + public void onUpdate() { + ticksExisted++; + } + + public final void writeToPacketNBTInternal(NBTTagCompound cmp) { + cmp.setInteger(TAG_TICKS_EXISTED, ticksExisted); + writeToPacketNBT(cmp); + } + + public final void readFromPacketNBTInternal(NBTTagCompound cmp) { + if (cmp.hasKey(TAG_TICKS_EXISTED)) ticksExisted = cmp.getInteger(TAG_TICKS_EXISTED); + readFromPacketNBT(cmp); + } + + /** + * Writes some extra data to a network packet. This data is read + * by readFromPacketNBT on the client that receives the packet. + * Note: This method is also used to write to the world NBT. + */ + public void writeToPacketNBT(NBTTagCompound cmp) {} + + /** + * Reads data from a network packet. This data is written by + * writeToPacketNBT in the server. Note: This method is also used + * to read from the world NBT. + */ + public void readFromPacketNBT(NBTTagCompound cmp) {} + + public void sync() { + VanillaPacketDispatcher.dispatchTEToNearbyPlayers(supertile); + } + + public String getUnlocalizedName() { + return BotaniaAPI.getSubTileStringMapping(getClass()); + } + + /** + * Gets the icon for this SubTileEntity, this is a block icon. + */ + @SideOnly(Side.CLIENT) + public IIcon getIcon() { + return BotaniaAPI.internalHandler.getSubTileIconForName(getUnlocalizedName()); + } + + /** + * Called when a Wand of the Forest is used on this sub tile. Note that the + * player parameter can be null if this is called from a dispenser. + */ + public boolean onWanded(EntityPlayer player, ItemStack wand) { + return false; + } + + /** + * Called when this sub tile is placed in the world (by an entity). + */ + public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase entity, ItemStack stack) { + // NO-OP + } + + /** + * Called when a player right clicks this sub tile. + */ + public boolean onBlockActivated( + World world, int x, int y, int z, EntityPlayer player, int side, float hitX, float hitY, float hitZ) { + return false; + } + + /** + * Called when this sub tile is added to the world. + */ + public void onBlockAdded(World world, int x, int y, int z) { + // NO-OP + } + + /** + * Called when this sub tile is harvested + */ + public void onBlockHarvested(World world, int x, int y, int z, int side, EntityPlayer player) { + // NO-OP + } + + /** + * Allows additional processing of sub tile drops + */ + public ArrayList getDrops(ArrayList list) { + return list; + } + + /** + * Gets which Lexicon Entry to open when this sub tile is right clicked with a lexicon. + */ + public LexiconEntry getEntry() { + return null; + } + + /** + * Gets the block coordinates this is bound to, for use with the wireframe render + * when the sub tile is being hovered with a wand of the forest. + */ + @SideOnly(Side.CLIENT) + public ChunkCoordinates getBinding() { + return null; + } + + /** + * Returns a descriptor for the radius of this sub tile. This is called while a player + * is looking at the block with a Manaseer Monocle (IBurstViewerBauble). + */ + @SideOnly(Side.CLIENT) + public RadiusDescriptor getRadius() { + return null; + } + + /** + * Gets a ChunkCoordinates instance with the position of this sub tile. + */ + public ChunkCoordinates toChunkCoordinates() { + return new ChunkCoordinates(supertile.xCoord, supertile.yCoord, supertile.zCoord); + } + + /** + * @see IWandBindable#canSelect(EntityPlayer, ItemStack, int, int, int, int) + */ + public boolean canSelect(EntityPlayer player, ItemStack wand, int x, int y, int z, int side) { + return false; + } + + /** + * @see IWandBindable#bindTo(EntityPlayer, ItemStack, int, int, int, int) + */ + public boolean bindTo(EntityPlayer player, ItemStack wand, int x, int y, int z, int side) { + return false; + } + + /** + * Called on the client when the block being pointed at is the one with this sub tile. + * Used to render a HUD portraying some data from this sub tile. + */ + @SideOnly(Side.CLIENT) + public void renderHUD(Minecraft mc, ScaledResolution res) { + // NO-OP + } + + /** + * Gets the light value for this SubTileEntity, this is a int (-1 to default to the flower) + */ + public int getLightValue() { + return -1; + } + + /** + * Gets the comparator input value for this SubTileEntity + */ + public int getComparatorInputOverride(int side) { + return 0; + } + + /** + * Gets the redstone power level for this SubTileEntity + */ + public int getPowerLevel(int side) { + return 0; + } + + /** + * Gets if this SubTileEntity is affected by Enchanted Soil's speed boost. + */ + public boolean isOvergrowthAffected() { + return true; + } + + /** + * Gets ths slowdown factor of this SubTile. + * @see ISubTileSlowableContainer + */ + public int getSlowdownFactor() { + if (supertile instanceof ISubTileSlowableContainer) { + ISubTileSlowableContainer slowable = (ISubTileSlowableContainer) supertile; + return slowable.getSlowdownFactor(); + } + + return 0; + } } diff --git a/src/main/java/vazkii/botania/api/subtile/SubTileFunctional.java b/src/main/java/vazkii/botania/api/subtile/SubTileFunctional.java index d6156eafed..ad8df9a391 100644 --- a/src/main/java/vazkii/botania/api/subtile/SubTileFunctional.java +++ b/src/main/java/vazkii/botania/api/subtile/SubTileFunctional.java @@ -2,16 +2,15 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jan 24, 2014, 8:03:44 PM (GMT)] */ package vazkii.botania.api.subtile; import java.awt.Color; - import net.minecraft.client.Minecraft; import net.minecraft.client.gui.ScaledResolution; import net.minecraft.entity.player.EntityPlayer; @@ -30,191 +29,221 @@ */ public class SubTileFunctional extends SubTileEntity { - public static final int RANGE = 10; - - private static final String TAG_MANA = "mana"; - - private static final String TAG_POOL_X = "poolX"; - private static final String TAG_POOL_Y = "poolY"; - private static final String TAG_POOL_Z = "poolZ"; - - public int mana; - - public int redstoneSignal = 0; - - int sizeLastCheck = -1; - TileEntity linkedPool = null; - public int knownMana = -1; - - ChunkCoordinates cachedPoolCoordinates = null; - - /** - * If set to true, redstoneSignal will be updated every tick. - */ - public boolean acceptsRedstone() { - return false; - } - - @Override - public void onUpdate() { - super.onUpdate(); - - linkPool(); - - if(linkedPool != null && isValidBinding()) { - IManaPool pool = (IManaPool) linkedPool; - int manaInPool = pool.getCurrentMana(); - int manaMissing = getMaxMana() - mana; - int manaToRemove = Math.min(manaMissing, manaInPool); - pool.recieveMana(-manaToRemove); - addMana(manaToRemove); - } - - if(acceptsRedstone()) { - redstoneSignal = 0; - for(ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS) { - int redstoneSide = supertile.getWorldObj().getIndirectPowerLevelTo(supertile.xCoord + dir.offsetX, supertile.yCoord + dir.offsetY, supertile.zCoord + dir.offsetZ, dir.ordinal()); - redstoneSignal = Math.max(redstoneSignal, redstoneSide); - } - } - - if(supertile.getWorldObj().isRemote) { - double particleChance = 1F - (double) mana / (double) getMaxMana() / 3.5F; - Color color = new Color(getColor()); - if(Math.random() > particleChance) - BotaniaAPI.internalHandler.sparkleFX(supertile.getWorldObj(), supertile.xCoord + 0.3 + Math.random() * 0.5, supertile.yCoord + 0.5 + Math.random() * 0.5, supertile.zCoord + 0.3 + Math.random() * 0.5, color.getRed() / 255F, color.getGreen() / 255F, color.getBlue() / 255F, (float) Math.random(), 5); - } - } - - public void linkPool() { - boolean needsNew = false; - if(linkedPool == null) { - needsNew = true; - - if(cachedPoolCoordinates != null) { - needsNew = false; - if(supertile.getWorldObj().blockExists(cachedPoolCoordinates.posX, cachedPoolCoordinates.posY, cachedPoolCoordinates.posZ)) { - needsNew = true; - TileEntity tileAt = supertile.getWorldObj().getTileEntity(cachedPoolCoordinates.posX, cachedPoolCoordinates.posY, cachedPoolCoordinates.posZ); - if(tileAt != null && tileAt instanceof IManaPool && !tileAt.isInvalid()) { - linkedPool = tileAt; - needsNew = false; - } - cachedPoolCoordinates = null; - } - } - } else { - TileEntity tileAt = supertile.getWorldObj().getTileEntity(linkedPool.xCoord, linkedPool.yCoord, linkedPool.zCoord); - if(tileAt != null && tileAt instanceof IManaPool) - linkedPool = tileAt; - } - - if(needsNew && ticksExisted == 1) { // Only for new flowers - IManaNetwork network = BotaniaAPI.internalHandler.getManaNetworkInstance(); - int size = network.getAllPoolsInWorld(supertile.getWorldObj()).size(); - if(BotaniaAPI.internalHandler.shouldForceCheck() || size != sizeLastCheck) { - ChunkCoordinates coords = new ChunkCoordinates(supertile.xCoord, supertile.yCoord, supertile.zCoord); - linkedPool = network.getClosestPool(coords, supertile.getWorldObj(), RANGE); - sizeLastCheck = size; - } - } - } - - public void linkToForcefully(TileEntity pool) { - linkedPool = pool; - } - - public void addMana(int mana) { - this.mana = Math.min(getMaxMana(), this.mana + mana); - } - - @Override - public boolean onWanded(EntityPlayer player, ItemStack wand) { - if(player == null) - return false; - - knownMana = mana; - player.worldObj.playSoundAtEntity(player, "botania:ding", 0.1F, 1F); - - return super.onWanded(player, wand); - } - - public int getMaxMana() { - return 20; - } - - public int getColor() { - return 0xFFFFFF; - } - - @Override - public void readFromPacketNBT(NBTTagCompound cmp) { - mana = cmp.getInteger(TAG_MANA); - - int x = cmp.getInteger(TAG_POOL_X); - int y = cmp.getInteger(TAG_POOL_Y); - int z = cmp.getInteger(TAG_POOL_Z); - - cachedPoolCoordinates = y < 0 ? null : new ChunkCoordinates(x, y, z); - } - - @Override - public void writeToPacketNBT(NBTTagCompound cmp) { - cmp.setInteger(TAG_MANA, mana); - - if(cachedPoolCoordinates != null) { - cmp.setInteger(TAG_POOL_X, cachedPoolCoordinates.posX); - cmp.setInteger(TAG_POOL_Y, cachedPoolCoordinates.posY); - cmp.setInteger(TAG_POOL_Z, cachedPoolCoordinates.posZ); - } else { - int x = linkedPool == null ? 0 : linkedPool.xCoord; - int y = linkedPool == null ? -1 : linkedPool.yCoord; - int z = linkedPool == null ? 0 : linkedPool.zCoord; - - cmp.setInteger(TAG_POOL_X, x); - cmp.setInteger(TAG_POOL_Y, y); - cmp.setInteger(TAG_POOL_Z, z); - } - } - - @Override - public ChunkCoordinates getBinding() { - if(linkedPool == null) - return null; - return new ChunkCoordinates(linkedPool.xCoord, linkedPool.yCoord, linkedPool.zCoord); - } - - @Override - public boolean canSelect(EntityPlayer player, ItemStack wand, int x, int y, int z, int side) { - return true; - } - - @Override - public boolean bindTo(EntityPlayer player, ItemStack wand, int x, int y, int z, int side) { - int range = 10; - range *= range; - - double dist = (x - supertile.xCoord) * (x - supertile.xCoord) + (y - supertile.yCoord) * (y - supertile.yCoord) + (z - supertile.zCoord) * (z - supertile.zCoord); - if(range >= dist) { - TileEntity tile = player.worldObj.getTileEntity(x, y, z); - if(tile instanceof IManaPool) { - linkedPool = tile; - return true; - } - } - - return false; - } - - public boolean isValidBinding() { - return linkedPool != null && !linkedPool.isInvalid() && supertile.getWorldObj().getTileEntity(linkedPool.xCoord, linkedPool.yCoord, linkedPool.zCoord) == linkedPool; - } - - @Override - public void renderHUD(Minecraft mc, ScaledResolution res) { - String name = StatCollector.translateToLocal("tile.botania:flower." + getUnlocalizedName() + ".name"); - int color = getColor(); - BotaniaAPI.internalHandler.drawComplexManaHUD(color, knownMana, getMaxMana(), name, res, BotaniaAPI.internalHandler.getBindDisplayForFlowerType(this), isValidBinding()); - } - + public static final int RANGE = 10; + + private static final String TAG_MANA = "mana"; + + private static final String TAG_POOL_X = "poolX"; + private static final String TAG_POOL_Y = "poolY"; + private static final String TAG_POOL_Z = "poolZ"; + + public int mana; + + public int redstoneSignal = 0; + + int sizeLastCheck = -1; + TileEntity linkedPool = null; + public int knownMana = -1; + + ChunkCoordinates cachedPoolCoordinates = null; + + /** + * If set to true, redstoneSignal will be updated every tick. + */ + public boolean acceptsRedstone() { + return false; + } + + @Override + public void onUpdate() { + super.onUpdate(); + + linkPool(); + + if (linkedPool != null && isValidBinding()) { + IManaPool pool = (IManaPool) linkedPool; + int manaInPool = pool.getCurrentMana(); + int manaMissing = getMaxMana() - mana; + int manaToRemove = Math.min(manaMissing, manaInPool); + pool.recieveMana(-manaToRemove); + addMana(manaToRemove); + } + + if (acceptsRedstone()) { + redstoneSignal = 0; + for (ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS) { + int redstoneSide = supertile + .getWorldObj() + .getIndirectPowerLevelTo( + supertile.xCoord + dir.offsetX, + supertile.yCoord + dir.offsetY, + supertile.zCoord + dir.offsetZ, + dir.ordinal()); + redstoneSignal = Math.max(redstoneSignal, redstoneSide); + } + } + + if (supertile.getWorldObj().isRemote) { + double particleChance = 1F - (double) mana / (double) getMaxMana() / 3.5F; + Color color = new Color(getColor()); + if (Math.random() > particleChance) + BotaniaAPI.internalHandler.sparkleFX( + supertile.getWorldObj(), + supertile.xCoord + 0.3 + Math.random() * 0.5, + supertile.yCoord + 0.5 + Math.random() * 0.5, + supertile.zCoord + 0.3 + Math.random() * 0.5, + color.getRed() / 255F, + color.getGreen() / 255F, + color.getBlue() / 255F, + (float) Math.random(), + 5); + } + } + + public void linkPool() { + boolean needsNew = false; + if (linkedPool == null) { + needsNew = true; + + if (cachedPoolCoordinates != null) { + needsNew = false; + if (supertile + .getWorldObj() + .blockExists( + cachedPoolCoordinates.posX, cachedPoolCoordinates.posY, cachedPoolCoordinates.posZ)) { + needsNew = true; + TileEntity tileAt = supertile + .getWorldObj() + .getTileEntity( + cachedPoolCoordinates.posX, cachedPoolCoordinates.posY, cachedPoolCoordinates.posZ); + if (tileAt != null && tileAt instanceof IManaPool && !tileAt.isInvalid()) { + linkedPool = tileAt; + needsNew = false; + } + cachedPoolCoordinates = null; + } + } + } else { + TileEntity tileAt = + supertile.getWorldObj().getTileEntity(linkedPool.xCoord, linkedPool.yCoord, linkedPool.zCoord); + if (tileAt != null && tileAt instanceof IManaPool) linkedPool = tileAt; + } + + if (needsNew && ticksExisted == 1) { // Only for new flowers + IManaNetwork network = BotaniaAPI.internalHandler.getManaNetworkInstance(); + int size = network.getAllPoolsInWorld(supertile.getWorldObj()).size(); + if (BotaniaAPI.internalHandler.shouldForceCheck() || size != sizeLastCheck) { + ChunkCoordinates coords = new ChunkCoordinates(supertile.xCoord, supertile.yCoord, supertile.zCoord); + linkedPool = network.getClosestPool(coords, supertile.getWorldObj(), RANGE); + sizeLastCheck = size; + } + } + } + + public void linkToForcefully(TileEntity pool) { + linkedPool = pool; + } + + public void addMana(int mana) { + this.mana = Math.min(getMaxMana(), this.mana + mana); + } + + @Override + public boolean onWanded(EntityPlayer player, ItemStack wand) { + if (player == null) return false; + + knownMana = mana; + player.worldObj.playSoundAtEntity(player, "botania:ding", 0.1F, 1F); + + return super.onWanded(player, wand); + } + + public int getMaxMana() { + return 20; + } + + public int getColor() { + return 0xFFFFFF; + } + + @Override + public void readFromPacketNBT(NBTTagCompound cmp) { + mana = cmp.getInteger(TAG_MANA); + + int x = cmp.getInteger(TAG_POOL_X); + int y = cmp.getInteger(TAG_POOL_Y); + int z = cmp.getInteger(TAG_POOL_Z); + + cachedPoolCoordinates = y < 0 ? null : new ChunkCoordinates(x, y, z); + } + + @Override + public void writeToPacketNBT(NBTTagCompound cmp) { + cmp.setInteger(TAG_MANA, mana); + + if (cachedPoolCoordinates != null) { + cmp.setInteger(TAG_POOL_X, cachedPoolCoordinates.posX); + cmp.setInteger(TAG_POOL_Y, cachedPoolCoordinates.posY); + cmp.setInteger(TAG_POOL_Z, cachedPoolCoordinates.posZ); + } else { + int x = linkedPool == null ? 0 : linkedPool.xCoord; + int y = linkedPool == null ? -1 : linkedPool.yCoord; + int z = linkedPool == null ? 0 : linkedPool.zCoord; + + cmp.setInteger(TAG_POOL_X, x); + cmp.setInteger(TAG_POOL_Y, y); + cmp.setInteger(TAG_POOL_Z, z); + } + } + + @Override + public ChunkCoordinates getBinding() { + if (linkedPool == null) return null; + return new ChunkCoordinates(linkedPool.xCoord, linkedPool.yCoord, linkedPool.zCoord); + } + + @Override + public boolean canSelect(EntityPlayer player, ItemStack wand, int x, int y, int z, int side) { + return true; + } + + @Override + public boolean bindTo(EntityPlayer player, ItemStack wand, int x, int y, int z, int side) { + int range = 10; + range *= range; + + double dist = (x - supertile.xCoord) * (x - supertile.xCoord) + + (y - supertile.yCoord) * (y - supertile.yCoord) + + (z - supertile.zCoord) * (z - supertile.zCoord); + if (range >= dist) { + TileEntity tile = player.worldObj.getTileEntity(x, y, z); + if (tile instanceof IManaPool) { + linkedPool = tile; + return true; + } + } + + return false; + } + + public boolean isValidBinding() { + return linkedPool != null + && !linkedPool.isInvalid() + && supertile.getWorldObj().getTileEntity(linkedPool.xCoord, linkedPool.yCoord, linkedPool.zCoord) + == linkedPool; + } + + @Override + public void renderHUD(Minecraft mc, ScaledResolution res) { + String name = StatCollector.translateToLocal("tile.botania:flower." + getUnlocalizedName() + ".name"); + int color = getColor(); + BotaniaAPI.internalHandler.drawComplexManaHUD( + color, + knownMana, + getMaxMana(), + name, + res, + BotaniaAPI.internalHandler.getBindDisplayForFlowerType(this), + isValidBinding()); + } } diff --git a/src/main/java/vazkii/botania/api/subtile/SubTileGenerating.java b/src/main/java/vazkii/botania/api/subtile/SubTileGenerating.java index 02f7a23afc..f9f02d123e 100644 --- a/src/main/java/vazkii/botania/api/subtile/SubTileGenerating.java +++ b/src/main/java/vazkii/botania/api/subtile/SubTileGenerating.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jan 24, 2014, 8:03:36 PM (GMT)] */ package vazkii.botania.api.subtile; @@ -13,7 +13,6 @@ import java.awt.Color; import java.util.ArrayList; import java.util.List; - import net.minecraft.block.Block; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.ScaledResolution; @@ -36,280 +35,329 @@ */ public class SubTileGenerating extends SubTileEntity { - public static final int RANGE = 6; - - private static final String TAG_MANA = "mana"; - - private static final String TAG_COLLECTOR_X = "collectorX"; - private static final String TAG_COLLECTOR_Y = "collectorY"; - private static final String TAG_COLLECTOR_Z = "collectorZ"; - private static final String TAG_PASSIVE_DECAY_TICKS = "passiveDecayTicks"; - - protected int mana; - - public int redstoneSignal = 0; - - int sizeLastCheck = -1; - protected TileEntity linkedCollector = null; - public int knownMana = -1; - public int passiveDecayTicks; - - ChunkCoordinates cachedCollectorCoordinates = null; - - /** - * If set to true, redstoneSignal will be updated every tick. - */ - public boolean acceptsRedstone() { - return false; - } - - @Override - public void onUpdate() { - super.onUpdate(); - - linkCollector(); - - if(canGeneratePassively()) { - int delay = getDelayBetweenPassiveGeneration(); - if(delay > 0 && ticksExisted % delay == 0 && !supertile.getWorldObj().isRemote) { - if(shouldSyncPassiveGeneration()) - sync(); - addMana(getValueForPassiveGeneration()); - } - } - emptyManaIntoCollector(); - - if(acceptsRedstone()) { - redstoneSignal = 0; - for(ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS) { - int redstoneSide = supertile.getWorldObj().getIndirectPowerLevelTo(supertile.xCoord + dir.offsetX, supertile.yCoord + dir.offsetY, supertile.zCoord + dir.offsetZ, dir.ordinal()); - redstoneSignal = Math.max(redstoneSignal, redstoneSide); - } - } - - if(supertile.getWorldObj().isRemote) { - double particleChance = 1F - (double) mana / (double) getMaxMana() / 3.5F; - Color color = new Color(getColor()); - if(Math.random() > particleChance) - BotaniaAPI.internalHandler.sparkleFX(supertile.getWorldObj(), supertile.xCoord + 0.3 + Math.random() * 0.5, supertile.yCoord + 0.5 + Math.random() * 0.5, supertile.zCoord + 0.3 + Math.random() * 0.5, color.getRed() / 255F, color.getGreen() / 255F, color.getBlue() / 255F, (float) Math.random(), 5); - } - - boolean passive = isPassiveFlower(); - if(!supertile.getWorldObj().isRemote) { - int muhBalance = BotaniaAPI.internalHandler.getPassiveFlowerDecay(); - - if(passive && muhBalance > 0 && passiveDecayTicks > muhBalance) { - supertile.getWorldObj().playAuxSFX(2001, supertile.xCoord, supertile.yCoord, supertile.zCoord, Block.getIdFromBlock(supertile.getBlockType())); - if(supertile.getWorldObj().getBlock(supertile.xCoord, supertile.yCoord - 1, supertile.zCoord).isSideSolid(supertile.getWorldObj(), supertile.xCoord, supertile.yCoord - 1, supertile.zCoord, ForgeDirection.UP)) - supertile.getWorldObj().setBlock(supertile.xCoord, supertile.yCoord, supertile.zCoord, Blocks.deadbush); - else supertile.getWorldObj().setBlockToAir(supertile.xCoord, supertile.yCoord, supertile.zCoord); - } - } - - if(!overgrowth && passive) - passiveDecayTicks++; - } - - public void linkCollector() { - boolean needsNew = false; - if(linkedCollector == null) { - needsNew = true; - - if(cachedCollectorCoordinates != null) { - needsNew = false; - if(supertile.getWorldObj().blockExists(cachedCollectorCoordinates.posX, cachedCollectorCoordinates.posY, cachedCollectorCoordinates.posZ)) { - needsNew = true; - TileEntity tileAt = supertile.getWorldObj().getTileEntity(cachedCollectorCoordinates.posX, cachedCollectorCoordinates.posY, cachedCollectorCoordinates.posZ); - if(tileAt != null && tileAt instanceof IManaCollector && !tileAt.isInvalid()) { - linkedCollector = tileAt; - needsNew = false; - } - cachedCollectorCoordinates = null; - } - } - } else { - TileEntity tileAt = supertile.getWorldObj().getTileEntity(linkedCollector.xCoord, linkedCollector.yCoord, linkedCollector.zCoord); - if(tileAt != null && tileAt instanceof IManaCollector) - linkedCollector = tileAt; - } - - if(needsNew && ticksExisted == 1) { // New flowers only - IManaNetwork network = BotaniaAPI.internalHandler.getManaNetworkInstance(); - int size = network.getAllCollectorsInWorld(supertile.getWorldObj()).size(); - if(BotaniaAPI.internalHandler.shouldForceCheck() || size != sizeLastCheck) { - ChunkCoordinates coords = new ChunkCoordinates(supertile.xCoord, supertile.yCoord, supertile.zCoord); - linkedCollector = network.getClosestCollector(coords, supertile.getWorldObj(), RANGE); - sizeLastCheck = size; - } - } - } - - public void linkToForcefully(TileEntity collector) { - linkedCollector = collector; - } - - public void addMana(int mana) { - this.mana = Math.min(getMaxMana(), this.mana + mana); - } - - public void emptyManaIntoCollector() { - if(linkedCollector != null && isValidBinding()) { - IManaCollector collector = (IManaCollector) linkedCollector; - if(!collector.isFull() && mana > 0) { - int manaval = Math.min(mana, collector.getMaxMana() - collector.getCurrentMana()); - mana -= manaval; - collector.recieveMana(manaval); - } - } - } - - public boolean isPassiveFlower() { - return false; - } - - public boolean shouldSyncPassiveGeneration() { - return false; - } - - public boolean canGeneratePassively() { - return false; - } - - public int getDelayBetweenPassiveGeneration() { - return 20; - } - - public int getValueForPassiveGeneration() { - return 1; - } - - @Override - public ArrayList getDrops(ArrayList list) { - ArrayList drops = super.getDrops(list); - populateDropStackNBTs(drops); - return drops; - } - - public void populateDropStackNBTs(List drops) { - if(isPassiveFlower() && ticksExisted > 0 && BotaniaAPI.internalHandler.getPassiveFlowerDecay() > 0) { - ItemStack drop = drops.get(0); - if(drop != null) { - if(!drop.hasTagCompound()) - drop.setTagCompound(new NBTTagCompound()); - NBTTagCompound cmp = drop.getTagCompound(); - cmp.setInteger(TAG_PASSIVE_DECAY_TICKS, passiveDecayTicks); - } - } - } - - @Override - public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase entity, ItemStack stack) { - super.onBlockPlacedBy(world, x, y, z, entity, stack); - if(isPassiveFlower()) { - NBTTagCompound cmp = stack.getTagCompound(); - passiveDecayTicks = cmp.getInteger(TAG_PASSIVE_DECAY_TICKS); - } - } - - @Override - public boolean onWanded(EntityPlayer player, ItemStack wand) { - if(player == null) - return false; - - if(!player.worldObj.isRemote) - sync(); - - knownMana = mana; - player.worldObj.playSoundAtEntity(player, "botania:ding", 0.1F, 1F); - - return super.onWanded(player, wand); - } - - public int getMaxMana() { - return 20; - } - - public int getColor() { - return 0xFFFFFF; - } - - @Override - public void readFromPacketNBT(NBTTagCompound cmp) { - mana = cmp.getInteger(TAG_MANA); - passiveDecayTicks = cmp.getInteger(TAG_PASSIVE_DECAY_TICKS); - - int x = cmp.getInteger(TAG_COLLECTOR_X); - int y = cmp.getInteger(TAG_COLLECTOR_Y); - int z = cmp.getInteger(TAG_COLLECTOR_Z); - - cachedCollectorCoordinates = y < 0 ? null : new ChunkCoordinates(x, y, z); - } - - @Override - public void writeToPacketNBT(NBTTagCompound cmp) { - cmp.setInteger(TAG_MANA, mana); - cmp.setInteger(TAG_TICKS_EXISTED, ticksExisted); - cmp.setInteger(TAG_PASSIVE_DECAY_TICKS, passiveDecayTicks); - - if(cachedCollectorCoordinates != null) { - cmp.setInteger(TAG_COLLECTOR_X, cachedCollectorCoordinates.posX); - cmp.setInteger(TAG_COLLECTOR_Y, cachedCollectorCoordinates.posY); - cmp.setInteger(TAG_COLLECTOR_Z, cachedCollectorCoordinates.posZ); - } else { - int x = linkedCollector == null ? 0 : linkedCollector.xCoord; - int y = linkedCollector == null ? -1 : linkedCollector.yCoord; - int z = linkedCollector == null ? 0 : linkedCollector.zCoord; - - cmp.setInteger(TAG_COLLECTOR_X, x); - cmp.setInteger(TAG_COLLECTOR_Y, y); - cmp.setInteger(TAG_COLLECTOR_Z, z); - } - } - - @Override - public ChunkCoordinates getBinding() { - if(linkedCollector == null) - return null; - return new ChunkCoordinates(linkedCollector.xCoord, linkedCollector.yCoord, linkedCollector.zCoord); - } - - @Override - public boolean canSelect(EntityPlayer player, ItemStack wand, int x, int y, int z, int side) { - return true; - } - - @Override - public boolean bindTo(EntityPlayer player, ItemStack wand, int x, int y, int z, int side) { - int range = 6; - range *= range; - - double dist = (x - supertile.xCoord) * (x - supertile.xCoord) + (y - supertile.yCoord) * (y - supertile.yCoord) + (z - supertile.zCoord) * (z - supertile.zCoord); - if(range >= dist) { - TileEntity tile = player.worldObj.getTileEntity(x, y, z); - if(tile instanceof IManaCollector) { - linkedCollector = tile; - return true; - } - } - - return false; - } - - - public boolean isValidBinding() { - return linkedCollector != null && !linkedCollector.isInvalid() && supertile.getWorldObj().getTileEntity(linkedCollector.xCoord, linkedCollector.yCoord, linkedCollector.zCoord) == linkedCollector; - } - - @Override - public void renderHUD(Minecraft mc, ScaledResolution res) { - String name = StatCollector.translateToLocal("tile.botania:flower." + getUnlocalizedName() + ".name"); - int color = getColor(); - BotaniaAPI.internalHandler.drawComplexManaHUD(color, knownMana, getMaxMana(), name, res, BotaniaAPI.internalHandler.getBindDisplayForFlowerType(this), isValidBinding()); - } - - @Override - public boolean isOvergrowthAffected() { - return !isPassiveFlower(); - } - + public static final int RANGE = 6; + + private static final String TAG_MANA = "mana"; + + private static final String TAG_COLLECTOR_X = "collectorX"; + private static final String TAG_COLLECTOR_Y = "collectorY"; + private static final String TAG_COLLECTOR_Z = "collectorZ"; + private static final String TAG_PASSIVE_DECAY_TICKS = "passiveDecayTicks"; + + protected int mana; + + public int redstoneSignal = 0; + + int sizeLastCheck = -1; + protected TileEntity linkedCollector = null; + public int knownMana = -1; + public int passiveDecayTicks; + + ChunkCoordinates cachedCollectorCoordinates = null; + + /** + * If set to true, redstoneSignal will be updated every tick. + */ + public boolean acceptsRedstone() { + return false; + } + + @Override + public void onUpdate() { + super.onUpdate(); + + linkCollector(); + + if (canGeneratePassively()) { + int delay = getDelayBetweenPassiveGeneration(); + if (delay > 0 && ticksExisted % delay == 0 && !supertile.getWorldObj().isRemote) { + if (shouldSyncPassiveGeneration()) sync(); + addMana(getValueForPassiveGeneration()); + } + } + emptyManaIntoCollector(); + + if (acceptsRedstone()) { + redstoneSignal = 0; + for (ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS) { + int redstoneSide = supertile + .getWorldObj() + .getIndirectPowerLevelTo( + supertile.xCoord + dir.offsetX, + supertile.yCoord + dir.offsetY, + supertile.zCoord + dir.offsetZ, + dir.ordinal()); + redstoneSignal = Math.max(redstoneSignal, redstoneSide); + } + } + + if (supertile.getWorldObj().isRemote) { + double particleChance = 1F - (double) mana / (double) getMaxMana() / 3.5F; + Color color = new Color(getColor()); + if (Math.random() > particleChance) + BotaniaAPI.internalHandler.sparkleFX( + supertile.getWorldObj(), + supertile.xCoord + 0.3 + Math.random() * 0.5, + supertile.yCoord + 0.5 + Math.random() * 0.5, + supertile.zCoord + 0.3 + Math.random() * 0.5, + color.getRed() / 255F, + color.getGreen() / 255F, + color.getBlue() / 255F, + (float) Math.random(), + 5); + } + + boolean passive = isPassiveFlower(); + if (!supertile.getWorldObj().isRemote) { + int muhBalance = BotaniaAPI.internalHandler.getPassiveFlowerDecay(); + + if (passive && muhBalance > 0 && passiveDecayTicks > muhBalance) { + supertile + .getWorldObj() + .playAuxSFX( + 2001, + supertile.xCoord, + supertile.yCoord, + supertile.zCoord, + Block.getIdFromBlock(supertile.getBlockType())); + if (supertile + .getWorldObj() + .getBlock(supertile.xCoord, supertile.yCoord - 1, supertile.zCoord) + .isSideSolid( + supertile.getWorldObj(), + supertile.xCoord, + supertile.yCoord - 1, + supertile.zCoord, + ForgeDirection.UP)) + supertile + .getWorldObj() + .setBlock(supertile.xCoord, supertile.yCoord, supertile.zCoord, Blocks.deadbush); + else supertile.getWorldObj().setBlockToAir(supertile.xCoord, supertile.yCoord, supertile.zCoord); + } + } + + if (!overgrowth && passive) passiveDecayTicks++; + } + + public void linkCollector() { + boolean needsNew = false; + if (linkedCollector == null) { + needsNew = true; + + if (cachedCollectorCoordinates != null) { + needsNew = false; + if (supertile + .getWorldObj() + .blockExists( + cachedCollectorCoordinates.posX, + cachedCollectorCoordinates.posY, + cachedCollectorCoordinates.posZ)) { + needsNew = true; + TileEntity tileAt = supertile + .getWorldObj() + .getTileEntity( + cachedCollectorCoordinates.posX, + cachedCollectorCoordinates.posY, + cachedCollectorCoordinates.posZ); + if (tileAt != null && tileAt instanceof IManaCollector && !tileAt.isInvalid()) { + linkedCollector = tileAt; + needsNew = false; + } + cachedCollectorCoordinates = null; + } + } + } else { + TileEntity tileAt = supertile + .getWorldObj() + .getTileEntity(linkedCollector.xCoord, linkedCollector.yCoord, linkedCollector.zCoord); + if (tileAt != null && tileAt instanceof IManaCollector) linkedCollector = tileAt; + } + + if (needsNew && ticksExisted == 1) { // New flowers only + IManaNetwork network = BotaniaAPI.internalHandler.getManaNetworkInstance(); + int size = network.getAllCollectorsInWorld(supertile.getWorldObj()).size(); + if (BotaniaAPI.internalHandler.shouldForceCheck() || size != sizeLastCheck) { + ChunkCoordinates coords = new ChunkCoordinates(supertile.xCoord, supertile.yCoord, supertile.zCoord); + linkedCollector = network.getClosestCollector(coords, supertile.getWorldObj(), RANGE); + sizeLastCheck = size; + } + } + } + + public void linkToForcefully(TileEntity collector) { + linkedCollector = collector; + } + + public void addMana(int mana) { + this.mana = Math.min(getMaxMana(), this.mana + mana); + } + + public void emptyManaIntoCollector() { + if (linkedCollector != null && isValidBinding()) { + IManaCollector collector = (IManaCollector) linkedCollector; + if (!collector.isFull() && mana > 0) { + int manaval = Math.min(mana, collector.getMaxMana() - collector.getCurrentMana()); + mana -= manaval; + collector.recieveMana(manaval); + } + } + } + + public boolean isPassiveFlower() { + return false; + } + + public boolean shouldSyncPassiveGeneration() { + return false; + } + + public boolean canGeneratePassively() { + return false; + } + + public int getDelayBetweenPassiveGeneration() { + return 20; + } + + public int getValueForPassiveGeneration() { + return 1; + } + + @Override + public ArrayList getDrops(ArrayList list) { + ArrayList drops = super.getDrops(list); + populateDropStackNBTs(drops); + return drops; + } + + public void populateDropStackNBTs(List drops) { + if (isPassiveFlower() && ticksExisted > 0 && BotaniaAPI.internalHandler.getPassiveFlowerDecay() > 0) { + ItemStack drop = drops.get(0); + if (drop != null) { + if (!drop.hasTagCompound()) drop.setTagCompound(new NBTTagCompound()); + NBTTagCompound cmp = drop.getTagCompound(); + cmp.setInteger(TAG_PASSIVE_DECAY_TICKS, passiveDecayTicks); + } + } + } + + @Override + public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase entity, ItemStack stack) { + super.onBlockPlacedBy(world, x, y, z, entity, stack); + if (isPassiveFlower()) { + NBTTagCompound cmp = stack.getTagCompound(); + passiveDecayTicks = cmp.getInteger(TAG_PASSIVE_DECAY_TICKS); + } + } + + @Override + public boolean onWanded(EntityPlayer player, ItemStack wand) { + if (player == null) return false; + + if (!player.worldObj.isRemote) sync(); + + knownMana = mana; + player.worldObj.playSoundAtEntity(player, "botania:ding", 0.1F, 1F); + + return super.onWanded(player, wand); + } + + public int getMaxMana() { + return 20; + } + + public int getColor() { + return 0xFFFFFF; + } + + @Override + public void readFromPacketNBT(NBTTagCompound cmp) { + mana = cmp.getInteger(TAG_MANA); + passiveDecayTicks = cmp.getInteger(TAG_PASSIVE_DECAY_TICKS); + + int x = cmp.getInteger(TAG_COLLECTOR_X); + int y = cmp.getInteger(TAG_COLLECTOR_Y); + int z = cmp.getInteger(TAG_COLLECTOR_Z); + + cachedCollectorCoordinates = y < 0 ? null : new ChunkCoordinates(x, y, z); + } + + @Override + public void writeToPacketNBT(NBTTagCompound cmp) { + cmp.setInteger(TAG_MANA, mana); + cmp.setInteger(TAG_TICKS_EXISTED, ticksExisted); + cmp.setInteger(TAG_PASSIVE_DECAY_TICKS, passiveDecayTicks); + + if (cachedCollectorCoordinates != null) { + cmp.setInteger(TAG_COLLECTOR_X, cachedCollectorCoordinates.posX); + cmp.setInteger(TAG_COLLECTOR_Y, cachedCollectorCoordinates.posY); + cmp.setInteger(TAG_COLLECTOR_Z, cachedCollectorCoordinates.posZ); + } else { + int x = linkedCollector == null ? 0 : linkedCollector.xCoord; + int y = linkedCollector == null ? -1 : linkedCollector.yCoord; + int z = linkedCollector == null ? 0 : linkedCollector.zCoord; + + cmp.setInteger(TAG_COLLECTOR_X, x); + cmp.setInteger(TAG_COLLECTOR_Y, y); + cmp.setInteger(TAG_COLLECTOR_Z, z); + } + } + + @Override + public ChunkCoordinates getBinding() { + if (linkedCollector == null) return null; + return new ChunkCoordinates(linkedCollector.xCoord, linkedCollector.yCoord, linkedCollector.zCoord); + } + + @Override + public boolean canSelect(EntityPlayer player, ItemStack wand, int x, int y, int z, int side) { + return true; + } + + @Override + public boolean bindTo(EntityPlayer player, ItemStack wand, int x, int y, int z, int side) { + int range = 6; + range *= range; + + double dist = (x - supertile.xCoord) * (x - supertile.xCoord) + + (y - supertile.yCoord) * (y - supertile.yCoord) + + (z - supertile.zCoord) * (z - supertile.zCoord); + if (range >= dist) { + TileEntity tile = player.worldObj.getTileEntity(x, y, z); + if (tile instanceof IManaCollector) { + linkedCollector = tile; + return true; + } + } + + return false; + } + + public boolean isValidBinding() { + return linkedCollector != null + && !linkedCollector.isInvalid() + && supertile + .getWorldObj() + .getTileEntity(linkedCollector.xCoord, linkedCollector.yCoord, linkedCollector.zCoord) + == linkedCollector; + } + + @Override + public void renderHUD(Minecraft mc, ScaledResolution res) { + String name = StatCollector.translateToLocal("tile.botania:flower." + getUnlocalizedName() + ".name"); + int color = getColor(); + BotaniaAPI.internalHandler.drawComplexManaHUD( + color, + knownMana, + getMaxMana(), + name, + res, + BotaniaAPI.internalHandler.getBindDisplayForFlowerType(this), + isValidBinding()); + } + + @Override + public boolean isOvergrowthAffected() { + return !isPassiveFlower(); + } } diff --git a/src/main/java/vazkii/botania/api/subtile/signature/BasicSignature.java b/src/main/java/vazkii/botania/api/subtile/signature/BasicSignature.java index b3f5e47ce1..8893908e0b 100644 --- a/src/main/java/vazkii/botania/api/subtile/signature/BasicSignature.java +++ b/src/main/java/vazkii/botania/api/subtile/signature/BasicSignature.java @@ -2,16 +2,15 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Oct 17, 2014, 5:34:35 PM (GMT)] */ package vazkii.botania.api.subtile.signature; import java.util.List; - import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; @@ -28,61 +27,56 @@ */ public class BasicSignature extends SubTileSignature { - final String name; - - public BasicSignature(String name) { - this.name = name; - } + final String name; - @Override - public void registerIcons(IIconRegister register) { - BotaniaAPI.internalHandler.registerBasicSignatureIcons(name, register); - } + public BasicSignature(String name) { + this.name = name; + } - @Override - public IIcon getIconForStack(ItemStack stack) { - return BotaniaAPI.internalHandler.getSubTileIconForName(name); - } + @Override + public void registerIcons(IIconRegister register) { + BotaniaAPI.internalHandler.registerBasicSignatureIcons(name, register); + } - @Override - public String getUnlocalizedNameForStack(ItemStack stack) { - return unlocalizedName(""); - } + @Override + public IIcon getIconForStack(ItemStack stack) { + return BotaniaAPI.internalHandler.getSubTileIconForName(name); + } - @Override - public String getUnlocalizedLoreTextForStack(ItemStack stack) { - return unlocalizedName(".reference"); - } + @Override + public String getUnlocalizedNameForStack(ItemStack stack) { + return unlocalizedName(""); + } - public String getName() { - return name; - } + @Override + public String getUnlocalizedLoreTextForStack(ItemStack stack) { + return unlocalizedName(".reference"); + } - public String getType() { - Class clazz = BotaniaAPI.getSubTileMapping(name); + public String getName() { + return name; + } - if(clazz == null) - return "uwotm8"; + public String getType() { + Class clazz = BotaniaAPI.getSubTileMapping(name); - if(clazz.getAnnotation(PassiveFlower.class) != null) - return "botania.flowerType.passiveGenerating"; + if (clazz == null) return "uwotm8"; - if(SubTileGenerating.class.isAssignableFrom(clazz)) - return "botania.flowerType.generating"; + if (clazz.getAnnotation(PassiveFlower.class) != null) return "botania.flowerType.passiveGenerating"; - if(SubTileFunctional.class.isAssignableFrom(clazz)) - return "botania.flowerType.functional"; + if (SubTileGenerating.class.isAssignableFrom(clazz)) return "botania.flowerType.generating"; - return "botania.flowerType.misc"; - } + if (SubTileFunctional.class.isAssignableFrom(clazz)) return "botania.flowerType.functional"; - @Override - public void addTooltip(ItemStack stack, EntityPlayer player, List tooltip) { - tooltip.add(EnumChatFormatting.BLUE + StatCollector.translateToLocal(getType())); - } + return "botania.flowerType.misc"; + } - private String unlocalizedName(String end) { - return "tile.botania:" + SubTileSignature.SPECIAL_FLOWER_PREFIX + name + end; - } + @Override + public void addTooltip(ItemStack stack, EntityPlayer player, List tooltip) { + tooltip.add(EnumChatFormatting.BLUE + StatCollector.translateToLocal(getType())); + } + private String unlocalizedName(String end) { + return "tile.botania:" + SubTileSignature.SPECIAL_FLOWER_PREFIX + name + end; + } } diff --git a/src/main/java/vazkii/botania/api/subtile/signature/PassiveFlower.java b/src/main/java/vazkii/botania/api/subtile/signature/PassiveFlower.java index 008fa83b63..bc65f0a8e0 100644 --- a/src/main/java/vazkii/botania/api/subtile/signature/PassiveFlower.java +++ b/src/main/java/vazkii/botania/api/subtile/signature/PassiveFlower.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [04/12/2015, 16:47:01 (GMT)] */ package vazkii.botania.api.subtile.signature; @@ -23,6 +23,4 @@ */ @Retention(value = RUNTIME) @Target(value = TYPE) -public @interface PassiveFlower { - -} +public @interface PassiveFlower {} diff --git a/src/main/java/vazkii/botania/api/subtile/signature/SubTileSignature.java b/src/main/java/vazkii/botania/api/subtile/signature/SubTileSignature.java index 65fac22650..4e85dbeaa8 100644 --- a/src/main/java/vazkii/botania/api/subtile/signature/SubTileSignature.java +++ b/src/main/java/vazkii/botania/api/subtile/signature/SubTileSignature.java @@ -2,16 +2,15 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Oct 17, 2014, 5:29:26 PM (GMT)] */ package vazkii.botania.api.subtile.signature; import java.util.List; - import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; @@ -22,35 +21,34 @@ */ public abstract class SubTileSignature { - public static final String SPECIAL_FLOWER_PREFIX = "flower."; - - /** - * Equivalent to Block.registerBlockIcons. - */ - public abstract void registerIcons(IIconRegister register); - - /** - * Gets the icon to display for the flower item. - */ - public abstract IIcon getIconForStack(ItemStack stack); - - /** - * Gets the display name for the flower item. - */ - public abstract String getUnlocalizedNameForStack(ItemStack stack); - - /** - * Gets the lore text for the flower item, displayed in the item's tooltip. - * If you do not want a reference return a key that does not have localization such - * as "botaniamisc.noloc". - */ - public abstract String getUnlocalizedLoreTextForStack(ItemStack stack); - - /** - * Adds additional text to the tooltip. This text is added after getUnlocalizedLoreTextForStack. - */ - public void addTooltip(ItemStack stack, EntityPlayer player, List tooltip) { - // NO-OP - } - + public static final String SPECIAL_FLOWER_PREFIX = "flower."; + + /** + * Equivalent to Block.registerBlockIcons. + */ + public abstract void registerIcons(IIconRegister register); + + /** + * Gets the icon to display for the flower item. + */ + public abstract IIcon getIconForStack(ItemStack stack); + + /** + * Gets the display name for the flower item. + */ + public abstract String getUnlocalizedNameForStack(ItemStack stack); + + /** + * Gets the lore text for the flower item, displayed in the item's tooltip. + * If you do not want a reference return a key that does not have localization such + * as "botaniamisc.noloc". + */ + public abstract String getUnlocalizedLoreTextForStack(ItemStack stack); + + /** + * Adds additional text to the tooltip. This text is added after getUnlocalizedLoreTextForStack. + */ + public void addTooltip(ItemStack stack, EntityPlayer player, List tooltip) { + // NO-OP + } } diff --git a/src/main/java/vazkii/botania/api/wand/ICoordBoundItem.java b/src/main/java/vazkii/botania/api/wand/ICoordBoundItem.java index f7c8036d78..9810a97486 100644 --- a/src/main/java/vazkii/botania/api/wand/ICoordBoundItem.java +++ b/src/main/java/vazkii/botania/api/wand/ICoordBoundItem.java @@ -1,9 +1,9 @@ package vazkii.botania.api.wand; -import net.minecraft.item.ItemStack; -import net.minecraft.util.ChunkCoordinates; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; +import net.minecraft.item.ItemStack; +import net.minecraft.util.ChunkCoordinates; /** * The item equivalent of ITileBound, renders when the @@ -12,7 +12,6 @@ */ public interface ICoordBoundItem { - @SideOnly(Side.CLIENT) - public ChunkCoordinates getBinding(ItemStack stack); - + @SideOnly(Side.CLIENT) + public ChunkCoordinates getBinding(ItemStack stack); } diff --git a/src/main/java/vazkii/botania/api/wand/ITileBound.java b/src/main/java/vazkii/botania/api/wand/ITileBound.java index 199390b5a5..d08f410ce7 100644 --- a/src/main/java/vazkii/botania/api/wand/ITileBound.java +++ b/src/main/java/vazkii/botania/api/wand/ITileBound.java @@ -2,17 +2,17 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Mar 24, 2014, 6:47:53 PM (GMT)] */ package vazkii.botania.api.wand; -import net.minecraft.util.ChunkCoordinates; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; +import net.minecraft.util.ChunkCoordinates; /** * Any TileEntity that implements this is technically bound @@ -21,10 +21,9 @@ */ public interface ITileBound { - /** - * Gets where this block is bound to, can return null. - */ - @SideOnly(Side.CLIENT) - public ChunkCoordinates getBinding(); - + /** + * Gets where this block is bound to, can return null. + */ + @SideOnly(Side.CLIENT) + public ChunkCoordinates getBinding(); } diff --git a/src/main/java/vazkii/botania/api/wand/IWandBindable.java b/src/main/java/vazkii/botania/api/wand/IWandBindable.java index 0c5786c12f..221502d6a4 100644 --- a/src/main/java/vazkii/botania/api/wand/IWandBindable.java +++ b/src/main/java/vazkii/botania/api/wand/IWandBindable.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Oct 9, 2014, 3:01:58 PM (GMT)] */ package vazkii.botania.api.wand; @@ -20,15 +20,14 @@ */ public interface IWandBindable extends ITileBound { - /** - * Return true if the Wand can select this tile. - */ - public boolean canSelect(EntityPlayer player, ItemStack wand, int x, int y, int z, int side); - - /** - * Call to bind the TileEntity to where the player clicked. Return true to deselect - * the TileEntity for another bind or false case the TileEntity should stay selected. - */ - public boolean bindTo(EntityPlayer player, ItemStack wand, int x, int y, int z, int side); + /** + * Return true if the Wand can select this tile. + */ + public boolean canSelect(EntityPlayer player, ItemStack wand, int x, int y, int z, int side); + /** + * Call to bind the TileEntity to where the player clicked. Return true to deselect + * the TileEntity for another bind or false case the TileEntity should stay selected. + */ + public boolean bindTo(EntityPlayer player, ItemStack wand, int x, int y, int z, int side); } diff --git a/src/main/java/vazkii/botania/api/wand/IWandHUD.java b/src/main/java/vazkii/botania/api/wand/IWandHUD.java index a75e44abc8..0b3f30f3ac 100644 --- a/src/main/java/vazkii/botania/api/wand/IWandHUD.java +++ b/src/main/java/vazkii/botania/api/wand/IWandHUD.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Feb 5, 2014, 1:34:44 PM (GMT)] */ package vazkii.botania.api.wand; @@ -20,6 +20,5 @@ */ public interface IWandHUD { - public void renderHUD(Minecraft mc, ScaledResolution res, World world, int x, int y, int z); - + public void renderHUD(Minecraft mc, ScaledResolution res, World world, int x, int y, int z); } diff --git a/src/main/java/vazkii/botania/api/wand/IWandable.java b/src/main/java/vazkii/botania/api/wand/IWandable.java index 52349fa056..15e1177a84 100644 --- a/src/main/java/vazkii/botania/api/wand/IWandable.java +++ b/src/main/java/vazkii/botania/api/wand/IWandable.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jan 22, 2014, 5:12:53 PM (GMT)] */ package vazkii.botania.api.wand; @@ -19,10 +19,9 @@ */ public interface IWandable { - /** - * Called when the block is used by a wand. Note that the player parameter can be null - * if this function is called from a dispenser. - */ - public boolean onUsedByWand(EntityPlayer player, ItemStack stack, World world, int x, int y, int z, int side); - + /** + * Called when the block is used by a wand. Note that the player parameter can be null + * if this function is called from a dispenser. + */ + public boolean onUsedByWand(EntityPlayer player, ItemStack stack, World world, int x, int y, int z, int side); } diff --git a/src/main/java/vazkii/botania/api/wand/IWireframeAABBProvider.java b/src/main/java/vazkii/botania/api/wand/IWireframeAABBProvider.java index 3b6e807e7b..0d63924fdf 100644 --- a/src/main/java/vazkii/botania/api/wand/IWireframeAABBProvider.java +++ b/src/main/java/vazkii/botania/api/wand/IWireframeAABBProvider.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Apr 19, 2014, 7:23:59 PM (GMT)] */ package vazkii.botania.api.wand; @@ -19,6 +19,5 @@ */ public interface IWireframeAABBProvider { - public AxisAlignedBB getWireframeAABB(World world, int x, int y, int z); - + public AxisAlignedBB getWireframeAABB(World world, int x, int y, int z); } diff --git a/src/main/java/vazkii/botania/api/wiki/IWikiProvider.java b/src/main/java/vazkii/botania/api/wiki/IWikiProvider.java index 285c1549eb..f470f4a437 100644 --- a/src/main/java/vazkii/botania/api/wiki/IWikiProvider.java +++ b/src/main/java/vazkii/botania/api/wiki/IWikiProvider.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Sep 2, 2014, 5:57:35 PM (GMT)] */ package vazkii.botania.api.wiki; @@ -20,19 +20,18 @@ */ public interface IWikiProvider { - /** - * Gets the name of the block being looked at for display. - */ - public String getBlockName(World world, MovingObjectPosition pos); + /** + * Gets the name of the block being looked at for display. + */ + public String getBlockName(World world, MovingObjectPosition pos); - /** - * Gets the URL to open when the block is clicked. - */ - public String getWikiURL(World world, MovingObjectPosition pos); - - /** - * Gets the name of the wiki for display. - */ - public String getWikiName(World world, MovingObjectPosition pos); + /** + * Gets the URL to open when the block is clicked. + */ + public String getWikiURL(World world, MovingObjectPosition pos); + /** + * Gets the name of the wiki for display. + */ + public String getWikiName(World world, MovingObjectPosition pos); } diff --git a/src/main/java/vazkii/botania/api/wiki/SimpleWikiProvider.java b/src/main/java/vazkii/botania/api/wiki/SimpleWikiProvider.java index f03e07c8cf..56077fac4b 100644 --- a/src/main/java/vazkii/botania/api/wiki/SimpleWikiProvider.java +++ b/src/main/java/vazkii/botania/api/wiki/SimpleWikiProvider.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Sep 2, 2014, 5:58:39 PM (GMT)] */ package vazkii.botania.api.wiki; @@ -14,77 +14,70 @@ import net.minecraft.item.ItemStack; import net.minecraft.util.MovingObjectPosition; import net.minecraft.world.World; - import org.apache.commons.lang3.text.WordUtils; public class SimpleWikiProvider implements IWikiProvider { - final String name, urlBase, replacement; - final boolean lowercase; - - public SimpleWikiProvider(String name, String urlBase) { - this(name, urlBase, "%20"); - } - - public SimpleWikiProvider(String name, String urlBase, boolean lowercase) { - this(name, urlBase, "%20", lowercase); - } - - public SimpleWikiProvider(String name, String urlBase, String replacement) { - this.name = name; - this.urlBase = urlBase; - this.replacement = replacement; - lowercase = false; - } - - public SimpleWikiProvider(String name, String urlBase, String replacement, boolean lowercase) { - this.name = name; - this.urlBase = urlBase; - this.replacement = replacement; - this.lowercase = lowercase; - } - - @Override - public String getBlockName(World world, MovingObjectPosition pos) { - int x = pos.blockX; - int y = pos.blockY; - int z = pos.blockZ; - - Block block = world.getBlock(x, y, z); - if(block == null) - return null; - - ItemStack stack = block.getPickBlock(pos, world, x, y, z); - - if(stack == null || stack.getItem() == null) - stack = new ItemStack(block, 1, world.getBlockMetadata(x, y, z)); - - if(stack.getItem() == null) - return null; - - String name = stack.getDisplayName(); - if(name == null || name.isEmpty()) - return null; - - return name; - } - - @Override - public String getWikiURL(World world, MovingObjectPosition pos) { - String name = getBlockName(world, pos); - if(name == null) - return null; - - if(lowercase) { - return String.format(urlBase, name.toLowerCase().replaceAll(" ", replacement)); - } else { - return String.format(urlBase, WordUtils.capitalizeFully(name).replaceAll(" ", replacement)); - } - } - - @Override - public String getWikiName(World world, MovingObjectPosition pos) { - return name; - } + final String name, urlBase, replacement; + final boolean lowercase; + + public SimpleWikiProvider(String name, String urlBase) { + this(name, urlBase, "%20"); + } + + public SimpleWikiProvider(String name, String urlBase, boolean lowercase) { + this(name, urlBase, "%20", lowercase); + } + + public SimpleWikiProvider(String name, String urlBase, String replacement) { + this.name = name; + this.urlBase = urlBase; + this.replacement = replacement; + lowercase = false; + } + + public SimpleWikiProvider(String name, String urlBase, String replacement, boolean lowercase) { + this.name = name; + this.urlBase = urlBase; + this.replacement = replacement; + this.lowercase = lowercase; + } + + @Override + public String getBlockName(World world, MovingObjectPosition pos) { + int x = pos.blockX; + int y = pos.blockY; + int z = pos.blockZ; + + Block block = world.getBlock(x, y, z); + if (block == null) return null; + + ItemStack stack = block.getPickBlock(pos, world, x, y, z); + + if (stack == null || stack.getItem() == null) stack = new ItemStack(block, 1, world.getBlockMetadata(x, y, z)); + + if (stack.getItem() == null) return null; + + String name = stack.getDisplayName(); + if (name == null || name.isEmpty()) return null; + + return name; + } + + @Override + public String getWikiURL(World world, MovingObjectPosition pos) { + String name = getBlockName(world, pos); + if (name == null) return null; + + if (lowercase) { + return String.format(urlBase, name.toLowerCase().replaceAll(" ", replacement)); + } else { + return String.format(urlBase, WordUtils.capitalizeFully(name).replaceAll(" ", replacement)); + } + } + @Override + public String getWikiName(World world, MovingObjectPosition pos) { + return name; + } } diff --git a/src/main/java/vazkii/botania/api/wiki/WikiHooks.java b/src/main/java/vazkii/botania/api/wiki/WikiHooks.java index ae42fd82e6..470bc72284 100644 --- a/src/main/java/vazkii/botania/api/wiki/WikiHooks.java +++ b/src/main/java/vazkii/botania/api/wiki/WikiHooks.java @@ -2,41 +2,39 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Sep 2, 2014, 6:05:03 PM (GMT)] */ package vazkii.botania.api.wiki; +import cpw.mods.fml.common.registry.GameRegistry; +import cpw.mods.fml.common.registry.GameRegistry.UniqueIdentifier; import java.util.HashMap; import java.util.Map; - import net.minecraft.block.Block; -import cpw.mods.fml.common.registry.GameRegistry; -import cpw.mods.fml.common.registry.GameRegistry.UniqueIdentifier; public class WikiHooks { - private static final IWikiProvider FALLBACK_PROVIDER = new SimpleWikiProvider("FTB Wiki", "http://ftb.gamepedia.com/%s"); - - private static final Map modWikis = new HashMap(); + private static final IWikiProvider FALLBACK_PROVIDER = + new SimpleWikiProvider("FTB Wiki", "http://ftb.gamepedia.com/%s"); - public static IWikiProvider getWikiFor(Block block) { - UniqueIdentifier mod = GameRegistry.findUniqueIdentifierFor(block); - return getWikiFor(mod == null ? "" : mod.modId.toLowerCase()); - } + private static final Map modWikis = new HashMap(); - public static IWikiProvider getWikiFor(String mod) { - if(!modWikis.containsKey(mod)) - modWikis.put(mod, FALLBACK_PROVIDER); + public static IWikiProvider getWikiFor(Block block) { + UniqueIdentifier mod = GameRegistry.findUniqueIdentifierFor(block); + return getWikiFor(mod == null ? "" : mod.modId.toLowerCase()); + } - return modWikis.get(mod); - } + public static IWikiProvider getWikiFor(String mod) { + if (!modWikis.containsKey(mod)) modWikis.put(mod, FALLBACK_PROVIDER); - public static void registerModWiki(String mod, IWikiProvider provider) { - modWikis.put(mod.toLowerCase(), provider); - } + return modWikis.get(mod); + } + public static void registerModWiki(String mod, IWikiProvider provider) { + modWikis.put(mod.toLowerCase(), provider); + } } diff --git a/src/main/java/vazkii/botania/client/challenge/Challenge.java b/src/main/java/vazkii/botania/client/challenge/Challenge.java index ea3dc228ff..0d5fc93a1b 100644 --- a/src/main/java/vazkii/botania/client/challenge/Challenge.java +++ b/src/main/java/vazkii/botania/client/challenge/Challenge.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jun 29, 2015, 4:45:25 PM (GMT)] */ package vazkii.botania.client.challenge; @@ -15,23 +15,22 @@ public class Challenge { - public final String unlocalizedName; - public final ItemStack icon; - public final EnumChallengeLevel level; - public boolean complete = false; + public final String unlocalizedName; + public final ItemStack icon; + public final EnumChallengeLevel level; + public boolean complete = false; - public Challenge(String unlocalizedName, ItemStack icon, EnumChallengeLevel level) { - this.unlocalizedName = unlocalizedName; - this.icon = icon; - this.level = level; - } + public Challenge(String unlocalizedName, ItemStack icon, EnumChallengeLevel level) { + this.unlocalizedName = unlocalizedName; + this.icon = icon; + this.level = level; + } - public void writeToNBT(NBTTagCompound cmp) { - cmp.setBoolean(unlocalizedName, complete); - } - - public void readFromNBT(NBTTagCompound cmp) { - complete = cmp.getBoolean(unlocalizedName); - } + public void writeToNBT(NBTTagCompound cmp) { + cmp.setBoolean(unlocalizedName, complete); + } + public void readFromNBT(NBTTagCompound cmp) { + complete = cmp.getBoolean(unlocalizedName); + } } diff --git a/src/main/java/vazkii/botania/client/challenge/EnumChallengeLevel.java b/src/main/java/vazkii/botania/client/challenge/EnumChallengeLevel.java index 8abb8ca4a4..e9bbc5301a 100644 --- a/src/main/java/vazkii/botania/client/challenge/EnumChallengeLevel.java +++ b/src/main/java/vazkii/botania/client/challenge/EnumChallengeLevel.java @@ -2,29 +2,27 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jun 29, 2015, 4:46:16 PM (GMT)] */ package vazkii.botania.client.challenge; public enum EnumChallengeLevel { + EASY("botania.challengelevel.easy"), + NORMAL("botania.challengelevel.normal"), + HARD("botania.challengelevel.hard"), + LUNATIC("botania.challengelevel.lunatic"); - EASY("botania.challengelevel.easy"), - NORMAL("botania.challengelevel.normal"), - HARD("botania.challengelevel.hard"), - LUNATIC("botania.challengelevel.lunatic"); + String name; - String name; - - private EnumChallengeLevel(String name) { - this.name = name; - } - - public String getName() { - return name; - } + private EnumChallengeLevel(String name) { + this.name = name; + } + public String getName() { + return name; + } } diff --git a/src/main/java/vazkii/botania/client/challenge/ModChallenges.java b/src/main/java/vazkii/botania/client/challenge/ModChallenges.java index 4e1ba5e312..6825ba5b0b 100644 --- a/src/main/java/vazkii/botania/client/challenge/ModChallenges.java +++ b/src/main/java/vazkii/botania/client/challenge/ModChallenges.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jun 29, 2015, 4:44:49 PM (GMT)] */ package vazkii.botania.client.challenge; @@ -14,7 +14,6 @@ import java.util.EnumMap; import java.util.HashMap; import java.util.List; - import net.minecraft.init.Blocks; import net.minecraft.init.Items; import net.minecraft.item.ItemStack; @@ -25,41 +24,51 @@ public final class ModChallenges { - public static final EnumMap> challenges = new EnumMap(EnumChallengeLevel.class); - public static final HashMap challengeLookup = new HashMap(); - - public static void init() { - for(EnumChallengeLevel level : EnumChallengeLevel.class.getEnumConstants()) - challenges.put(level, new ArrayList()); + public static final EnumMap> challenges = new EnumMap(EnumChallengeLevel.class); + public static final HashMap challengeLookup = new HashMap(); - addChallenge(EnumChallengeLevel.EASY, "flowerFarm", new ItemStack(ModBlocks.flower, 1, 6)); - addChallenge(EnumChallengeLevel.EASY, "recordFarm", new ItemStack(Items.record_13)); - addChallenge(EnumChallengeLevel.EASY, "reedFarm", new ItemStack(Items.reeds)); - addChallenge(EnumChallengeLevel.EASY, "cobbleGen", new ItemStack(Blocks.cobblestone)); - addChallenge(EnumChallengeLevel.EASY, "pureDaisy", ItemBlockSpecialFlower.ofType(LibBlockNames.SUBTILE_PUREDAISY)); - addChallenge(EnumChallengeLevel.EASY, "battery", new ItemStack(ModBlocks.pool)); + public static void init() { + for (EnumChallengeLevel level : EnumChallengeLevel.class.getEnumConstants()) + challenges.put(level, new ArrayList()); - addChallenge(EnumChallengeLevel.NORMAL, "apothecaryRefill", new ItemStack(ModBlocks.altar)); - addChallenge(EnumChallengeLevel.NORMAL, "treeFarm", new ItemStack(Blocks.sapling)); - addChallenge(EnumChallengeLevel.NORMAL, "fullCropFarm", new ItemStack(Items.wheat_seeds)); - addChallenge(EnumChallengeLevel.NORMAL, "animalFarm", new ItemStack(Items.leather)); - addChallenge(EnumChallengeLevel.NORMAL, "boneMealFarm", new ItemStack(Items.dye, 1, 15)); - addChallenge(EnumChallengeLevel.NORMAL, "orechid", ItemBlockSpecialFlower.ofType(LibBlockNames.SUBTILE_ORECHID)); + addChallenge(EnumChallengeLevel.EASY, "flowerFarm", new ItemStack(ModBlocks.flower, 1, 6)); + addChallenge(EnumChallengeLevel.EASY, "recordFarm", new ItemStack(Items.record_13)); + addChallenge(EnumChallengeLevel.EASY, "reedFarm", new ItemStack(Items.reeds)); + addChallenge(EnumChallengeLevel.EASY, "cobbleGen", new ItemStack(Blocks.cobblestone)); + addChallenge( + EnumChallengeLevel.EASY, "pureDaisy", ItemBlockSpecialFlower.ofType(LibBlockNames.SUBTILE_PUREDAISY)); + addChallenge(EnumChallengeLevel.EASY, "battery", new ItemStack(ModBlocks.pool)); - addChallenge(EnumChallengeLevel.HARD, "mobTower", new ItemStack(Items.bone)); - addChallenge(EnumChallengeLevel.HARD, "entropinnyumSetup", ItemBlockSpecialFlower.ofType(LibBlockNames.SUBTILE_ENTROPINNYUM)); - addChallenge(EnumChallengeLevel.HARD, "spectrolusSetup", ItemBlockSpecialFlower.ofType(LibBlockNames.SUBTILE_SPECTROLUS)); - addChallenge(EnumChallengeLevel.HARD, "potionBrewer", new ItemStack(ModBlocks.brewery)); + addChallenge(EnumChallengeLevel.NORMAL, "apothecaryRefill", new ItemStack(ModBlocks.altar)); + addChallenge(EnumChallengeLevel.NORMAL, "treeFarm", new ItemStack(Blocks.sapling)); + addChallenge(EnumChallengeLevel.NORMAL, "fullCropFarm", new ItemStack(Items.wheat_seeds)); + addChallenge(EnumChallengeLevel.NORMAL, "animalFarm", new ItemStack(Items.leather)); + addChallenge(EnumChallengeLevel.NORMAL, "boneMealFarm", new ItemStack(Items.dye, 1, 15)); + addChallenge( + EnumChallengeLevel.NORMAL, "orechid", ItemBlockSpecialFlower.ofType(LibBlockNames.SUBTILE_ORECHID)); - addChallenge(EnumChallengeLevel.LUNATIC, "kekimurusSetup", ItemBlockSpecialFlower.ofType(LibBlockNames.SUBTILE_KEKIMURUS)); - addChallenge(EnumChallengeLevel.LUNATIC, "autoQuarry", new ItemStack(Items.diamond_pickaxe)); - addChallenge(EnumChallengeLevel.LUNATIC, "runeCrafter", new ItemStack(ModItems.rune)); - } + addChallenge(EnumChallengeLevel.HARD, "mobTower", new ItemStack(Items.bone)); + addChallenge( + EnumChallengeLevel.HARD, + "entropinnyumSetup", + ItemBlockSpecialFlower.ofType(LibBlockNames.SUBTILE_ENTROPINNYUM)); + addChallenge( + EnumChallengeLevel.HARD, + "spectrolusSetup", + ItemBlockSpecialFlower.ofType(LibBlockNames.SUBTILE_SPECTROLUS)); + addChallenge(EnumChallengeLevel.HARD, "potionBrewer", new ItemStack(ModBlocks.brewery)); - public static void addChallenge(EnumChallengeLevel level, String name, ItemStack icon) { - Challenge c = new Challenge("botania.challenge." + name, icon, level); - challenges.get(level).add(c); - challengeLookup.put(c.unlocalizedName, c); - } + addChallenge( + EnumChallengeLevel.LUNATIC, + "kekimurusSetup", + ItemBlockSpecialFlower.ofType(LibBlockNames.SUBTILE_KEKIMURUS)); + addChallenge(EnumChallengeLevel.LUNATIC, "autoQuarry", new ItemStack(Items.diamond_pickaxe)); + addChallenge(EnumChallengeLevel.LUNATIC, "runeCrafter", new ItemStack(ModItems.rune)); + } + public static void addChallenge(EnumChallengeLevel level, String name, ItemStack icon) { + Challenge c = new Challenge("botania.challenge." + name, icon, level); + challenges.get(level).add(c); + challengeLookup.put(c.unlocalizedName, c); + } } diff --git a/src/main/java/vazkii/botania/client/core/handler/BaubleRenderHandler.java b/src/main/java/vazkii/botania/client/core/handler/BaubleRenderHandler.java index 460e7363c9..d86c05603d 100644 --- a/src/main/java/vazkii/botania/client/core/handler/BaubleRenderHandler.java +++ b/src/main/java/vazkii/botania/client/core/handler/BaubleRenderHandler.java @@ -2,16 +2,18 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Aug 27, 2014, 8:55:00 PM (GMT)] */ package vazkii.botania.client.core.handler; +import baubles.common.container.InventoryBaubles; +import baubles.common.lib.PlayerHandler; +import cpw.mods.fml.common.eventhandler.SubscribeEvent; import java.awt.Color; - import net.minecraft.client.Minecraft; import net.minecraft.client.renderer.ItemRenderer; import net.minecraft.client.renderer.OpenGlHelper; @@ -23,9 +25,7 @@ import net.minecraft.potion.Potion; import net.minecraft.util.IIcon; import net.minecraftforge.client.event.RenderPlayerEvent; - import org.lwjgl.opengl.GL11; - import vazkii.botania.api.item.IBaubleRender; import vazkii.botania.api.item.IBaubleRender.Helper; import vazkii.botania.api.item.IBaubleRender.RenderType; @@ -34,116 +34,112 @@ import vazkii.botania.common.core.handler.ConfigHandler; import vazkii.botania.common.item.ModItems; import vazkii.botania.common.item.equipment.armor.terrasteel.ItemTerrasteelHelm; -import baubles.common.container.InventoryBaubles; -import baubles.common.lib.PlayerHandler; -import cpw.mods.fml.common.eventhandler.SubscribeEvent; public final class BaubleRenderHandler { - @SubscribeEvent - public void onPlayerRender(RenderPlayerEvent.Specials.Post event) { - if(!ConfigHandler.renderBaubles || event.entityLiving.getActivePotionEffect(Potion.invisibility) != null) - return; - - EntityPlayer player = event.entityPlayer; - InventoryBaubles inv = PlayerHandler.getPlayerBaubles(player); - - dispatchRenders(inv, event, RenderType.BODY); - if(inv.getStackInSlot(3) != null) - renderManaTablet(event); - - float yaw = player.prevRotationYawHead + (player.rotationYawHead - player.prevRotationYawHead) * event.partialRenderTick; - float yawOffset = player.prevRenderYawOffset + (player.renderYawOffset - player.prevRenderYawOffset) * event.partialRenderTick; - float pitch = player.prevRotationPitch + (player.rotationPitch - player.prevRotationPitch) * event.partialRenderTick; - - GL11.glPushMatrix(); - GL11.glRotatef(yawOffset, 0, -1, 0); - GL11.glRotatef(yaw - 270, 0, 1, 0); - GL11.glRotatef(pitch, 0, 0, 1); - dispatchRenders(inv, event, RenderType.HEAD); - - ItemStack helm = player.inventory.armorItemInSlot(3); - if(helm != null && helm.getItem() instanceof ItemTerrasteelHelm) - ItemTerrasteelHelm.renderOnPlayer(helm, event); - - ContributorFancinessHandler.render(event); - GL11.glPopMatrix(); - } - - private void dispatchRenders(InventoryBaubles inv, RenderPlayerEvent event, RenderType type) { - for(int i = 0; i < inv.getSizeInventory(); i++) { - ItemStack stack = inv.getStackInSlot(i); - if(stack != null) { - Item item = stack.getItem(); - - if(item instanceof IPhantomInkable) { - IPhantomInkable inkable = (IPhantomInkable) item; - if(inkable.hasPhantomInk(stack)) - continue; - } - - if(item instanceof ICosmeticAttachable) { - ICosmeticAttachable attachable = (ICosmeticAttachable) item; - ItemStack cosmetic = attachable.getCosmeticItem(stack); - if(cosmetic != null) { - GL11.glPushMatrix(); - GL11.glColor4f(1F, 1F, 1F, 1F); - ((IBaubleRender) cosmetic.getItem()).onPlayerBaubleRender(cosmetic, event, type); - GL11.glPopMatrix(); - continue; - } - } - - if(item instanceof IBaubleRender) { - GL11.glPushMatrix(); - GL11.glColor4f(1F, 1F, 1F, 1F); - ((IBaubleRender) stack.getItem()).onPlayerBaubleRender(stack, event, type); - GL11.glPopMatrix(); - } - } - } - } - - private void renderManaTablet(RenderPlayerEvent event) { - EntityPlayer player = event.entityPlayer; - boolean renderedOne = false; - for(int i = 0; i < player.inventory.getSizeInventory(); i++) { - ItemStack stack = player.inventory.getStackInSlot(i); - if(stack != null && stack.getItem() == ModItems.manaTablet) { - Item item = stack.getItem(); - GL11.glPushMatrix(); - Minecraft.getMinecraft().renderEngine.bindTexture(TextureMap.locationItemsTexture); - Helper.rotateIfSneaking(event.entityPlayer); - boolean armor = event.entityPlayer.getCurrentArmor(1) != null; - GL11.glRotatef(180F, 1F, 0F, 0F); - GL11.glRotatef(90F, 0F, 1F, 0F); - GL11.glTranslatef(-0.25F, -0.85F, renderedOne ? armor ? 0.2F : 0.28F : armor ? -0.3F : -0.25F); - GL11.glScalef(0.5F, 0.5F, 0.5F); - - GL11.glColor3f(1F, 1F, 1F); - int light = 15728880; - int lightmapX = light % 65536; - int lightmapY = light / 65536; - OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, lightmapX, lightmapY); - for(int j = 0; j < 2; j++) { - IIcon icon = item.getIcon(stack, j); - float f = icon.getMinU(); - float f1 = icon.getMaxU(); - float f2 = icon.getMinV(); - float f3 = icon.getMaxV(); - ItemRenderer.renderItemIn2D(Tessellator.instance, f1, f2, f, f3, icon.getIconWidth(), icon.getIconHeight(), 1F / 16F); - - Color color = new Color(item.getColorFromItemStack(stack, 1)); - GL11.glColor3ub((byte) color.getRed(), (byte) color.getGreen(), (byte) color.getBlue()); - } - GL11.glPopMatrix(); - - if(renderedOne) - return; - renderedOne = true; - } - } - } - - + @SubscribeEvent + public void onPlayerRender(RenderPlayerEvent.Specials.Post event) { + if (!ConfigHandler.renderBaubles || event.entityLiving.getActivePotionEffect(Potion.invisibility) != null) + return; + + EntityPlayer player = event.entityPlayer; + InventoryBaubles inv = PlayerHandler.getPlayerBaubles(player); + + dispatchRenders(inv, event, RenderType.BODY); + if (inv.getStackInSlot(3) != null) renderManaTablet(event); + + float yaw = player.prevRotationYawHead + + (player.rotationYawHead - player.prevRotationYawHead) * event.partialRenderTick; + float yawOffset = player.prevRenderYawOffset + + (player.renderYawOffset - player.prevRenderYawOffset) * event.partialRenderTick; + float pitch = + player.prevRotationPitch + (player.rotationPitch - player.prevRotationPitch) * event.partialRenderTick; + + GL11.glPushMatrix(); + GL11.glRotatef(yawOffset, 0, -1, 0); + GL11.glRotatef(yaw - 270, 0, 1, 0); + GL11.glRotatef(pitch, 0, 0, 1); + dispatchRenders(inv, event, RenderType.HEAD); + + ItemStack helm = player.inventory.armorItemInSlot(3); + if (helm != null && helm.getItem() instanceof ItemTerrasteelHelm) + ItemTerrasteelHelm.renderOnPlayer(helm, event); + + ContributorFancinessHandler.render(event); + GL11.glPopMatrix(); + } + + private void dispatchRenders(InventoryBaubles inv, RenderPlayerEvent event, RenderType type) { + for (int i = 0; i < inv.getSizeInventory(); i++) { + ItemStack stack = inv.getStackInSlot(i); + if (stack != null) { + Item item = stack.getItem(); + + if (item instanceof IPhantomInkable) { + IPhantomInkable inkable = (IPhantomInkable) item; + if (inkable.hasPhantomInk(stack)) continue; + } + + if (item instanceof ICosmeticAttachable) { + ICosmeticAttachable attachable = (ICosmeticAttachable) item; + ItemStack cosmetic = attachable.getCosmeticItem(stack); + if (cosmetic != null) { + GL11.glPushMatrix(); + GL11.glColor4f(1F, 1F, 1F, 1F); + ((IBaubleRender) cosmetic.getItem()).onPlayerBaubleRender(cosmetic, event, type); + GL11.glPopMatrix(); + continue; + } + } + + if (item instanceof IBaubleRender) { + GL11.glPushMatrix(); + GL11.glColor4f(1F, 1F, 1F, 1F); + ((IBaubleRender) stack.getItem()).onPlayerBaubleRender(stack, event, type); + GL11.glPopMatrix(); + } + } + } + } + + private void renderManaTablet(RenderPlayerEvent event) { + EntityPlayer player = event.entityPlayer; + boolean renderedOne = false; + for (int i = 0; i < player.inventory.getSizeInventory(); i++) { + ItemStack stack = player.inventory.getStackInSlot(i); + if (stack != null && stack.getItem() == ModItems.manaTablet) { + Item item = stack.getItem(); + GL11.glPushMatrix(); + Minecraft.getMinecraft().renderEngine.bindTexture(TextureMap.locationItemsTexture); + Helper.rotateIfSneaking(event.entityPlayer); + boolean armor = event.entityPlayer.getCurrentArmor(1) != null; + GL11.glRotatef(180F, 1F, 0F, 0F); + GL11.glRotatef(90F, 0F, 1F, 0F); + GL11.glTranslatef(-0.25F, -0.85F, renderedOne ? armor ? 0.2F : 0.28F : armor ? -0.3F : -0.25F); + GL11.glScalef(0.5F, 0.5F, 0.5F); + + GL11.glColor3f(1F, 1F, 1F); + int light = 15728880; + int lightmapX = light % 65536; + int lightmapY = light / 65536; + OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, lightmapX, lightmapY); + for (int j = 0; j < 2; j++) { + IIcon icon = item.getIcon(stack, j); + float f = icon.getMinU(); + float f1 = icon.getMaxU(); + float f2 = icon.getMinV(); + float f3 = icon.getMaxV(); + ItemRenderer.renderItemIn2D( + Tessellator.instance, f1, f2, f, f3, icon.getIconWidth(), icon.getIconHeight(), 1F / 16F); + + Color color = new Color(item.getColorFromItemStack(stack, 1)); + GL11.glColor3ub((byte) color.getRed(), (byte) color.getGreen(), (byte) color.getBlue()); + } + GL11.glPopMatrix(); + + if (renderedOne) return; + renderedOne = true; + } + } + } } diff --git a/src/main/java/vazkii/botania/client/core/handler/BossBarHandler.java b/src/main/java/vazkii/botania/client/core/handler/BossBarHandler.java index ec61a9366d..f4ad0550fb 100644 --- a/src/main/java/vazkii/botania/client/core/handler/BossBarHandler.java +++ b/src/main/java/vazkii/botania/client/core/handler/BossBarHandler.java @@ -2,25 +2,22 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Oct 29, 2014, 6:46:10 PM (GMT)] */ package vazkii.botania.client.core.handler; import java.awt.Rectangle; - import net.minecraft.client.Minecraft; import net.minecraft.client.gui.ScaledResolution; import net.minecraft.entity.Entity; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.util.ResourceLocation; - import org.lwjgl.opengl.ARBShaderObjects; import org.lwjgl.opengl.GL11; - import vazkii.botania.api.boss.IBotaniaBoss; import vazkii.botania.api.boss.IBotaniaBossWithShader; import vazkii.botania.api.internal.ShaderCallback; @@ -31,86 +28,83 @@ public final class BossBarHandler { - public static final ResourceLocation defaultBossBar = new ResourceLocation(LibResources.GUI_BOSS_BAR); - static IBotaniaBoss currentBoss; - - private static final BarCallback barUniformCallback = new BarCallback(); - - public static void setCurrentBoss(IBotaniaBoss status) { - currentBoss = status; - } - - public static void render(ScaledResolution res) { - if(currentBoss == null) - return; - - Minecraft mc = Minecraft.getMinecraft(); - Rectangle bgRect = currentBoss.getBossBarTextureRect(); - Rectangle fgRect = currentBoss.getBossBarHPTextureRect(); - String name = currentBoss.func_145748_c_().getFormattedText(); - int c = res.getScaledWidth() / 2; - int x = c - bgRect.width / 2; - int y = 20; - int xf = x + (bgRect.width - fgRect.width) / 2; - int yf = y + (bgRect.height - fgRect.height) / 2; - int fw = (int) ((double) fgRect.width * (currentBoss.getHealth() / currentBoss.getMaxHealth())); - int tx = c - mc.fontRenderer.getStringWidth(name) / 2; - - GL11.glColor4f(1F, 1F, 1F, 1F); - currentBoss.bossBarRenderCallback(res, x, y); - GL11.glEnable(GL11.GL_BLEND); - GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); - mc.renderEngine.bindTexture(currentBoss.getBossBarTexture()); - drawBar(x, y, bgRect.x, bgRect.y, bgRect.width, bgRect.height, true); - drawBar(xf, yf, fgRect.x, fgRect.y, fw, fgRect.height, false); - mc.fontRenderer.drawStringWithShadow(name, tx, y - 10, 0xA2018C); - GL11.glEnable(GL11.GL_BLEND); - - Entity e = (Entity) currentBoss; - EntityPlayer p = mc.thePlayer; - if(e.isDead || !p.worldObj.loadedEntityList.contains(e) || MathHelper.pointDistanceSpace(e.posX, e.posY, e.posZ, p.posX, p.posY, p.posZ) > 32) - currentBoss = null; - } - - public static void drawBar(int x, int y, int u, int v, int w, int h, boolean bg) { - boolean useShader = currentBoss instanceof IBotaniaBossWithShader; - if(useShader) { - IBotaniaBossWithShader shader = (IBotaniaBossWithShader) currentBoss; - int program = shader.getBossBarShaderProgram(bg); - ShaderCallback callback = program == 0 ? null : shader.getBossBarShaderCallback(bg, program); - barUniformCallback.set(u, v, callback); - - ShaderHelper.useShader(program, barUniformCallback); - } - - RenderHelper.drawTexturedModalRect(x, y, 0, u, v, w, h); - - if(useShader) - ShaderHelper.releaseShader(); - } - - static class BarCallback extends ShaderCallback { - int x, y; - ShaderCallback callback; - - @Override - public void call(int shader) { - int startXUniform = ARBShaderObjects.glGetUniformLocationARB(shader, "startX"); - int startYUniform = ARBShaderObjects.glGetUniformLocationARB(shader, "startY"); - - - ARBShaderObjects.glUniform1iARB(startXUniform, x); - ARBShaderObjects.glUniform1iARB(startYUniform, y); - - if(callback != null) - callback.call(shader); - } - - void set(int x, int y, ShaderCallback callback) { - this.x = x; - this.y = y; - this.callback = callback; - } - } - + public static final ResourceLocation defaultBossBar = new ResourceLocation(LibResources.GUI_BOSS_BAR); + static IBotaniaBoss currentBoss; + + private static final BarCallback barUniformCallback = new BarCallback(); + + public static void setCurrentBoss(IBotaniaBoss status) { + currentBoss = status; + } + + public static void render(ScaledResolution res) { + if (currentBoss == null) return; + + Minecraft mc = Minecraft.getMinecraft(); + Rectangle bgRect = currentBoss.getBossBarTextureRect(); + Rectangle fgRect = currentBoss.getBossBarHPTextureRect(); + String name = currentBoss.func_145748_c_().getFormattedText(); + int c = res.getScaledWidth() / 2; + int x = c - bgRect.width / 2; + int y = 20; + int xf = x + (bgRect.width - fgRect.width) / 2; + int yf = y + (bgRect.height - fgRect.height) / 2; + int fw = (int) ((double) fgRect.width * (currentBoss.getHealth() / currentBoss.getMaxHealth())); + int tx = c - mc.fontRenderer.getStringWidth(name) / 2; + + GL11.glColor4f(1F, 1F, 1F, 1F); + currentBoss.bossBarRenderCallback(res, x, y); + GL11.glEnable(GL11.GL_BLEND); + GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); + mc.renderEngine.bindTexture(currentBoss.getBossBarTexture()); + drawBar(x, y, bgRect.x, bgRect.y, bgRect.width, bgRect.height, true); + drawBar(xf, yf, fgRect.x, fgRect.y, fw, fgRect.height, false); + mc.fontRenderer.drawStringWithShadow(name, tx, y - 10, 0xA2018C); + GL11.glEnable(GL11.GL_BLEND); + + Entity e = (Entity) currentBoss; + EntityPlayer p = mc.thePlayer; + if (e.isDead + || !p.worldObj.loadedEntityList.contains(e) + || MathHelper.pointDistanceSpace(e.posX, e.posY, e.posZ, p.posX, p.posY, p.posZ) > 32) + currentBoss = null; + } + + public static void drawBar(int x, int y, int u, int v, int w, int h, boolean bg) { + boolean useShader = currentBoss instanceof IBotaniaBossWithShader; + if (useShader) { + IBotaniaBossWithShader shader = (IBotaniaBossWithShader) currentBoss; + int program = shader.getBossBarShaderProgram(bg); + ShaderCallback callback = program == 0 ? null : shader.getBossBarShaderCallback(bg, program); + barUniformCallback.set(u, v, callback); + + ShaderHelper.useShader(program, barUniformCallback); + } + + RenderHelper.drawTexturedModalRect(x, y, 0, u, v, w, h); + + if (useShader) ShaderHelper.releaseShader(); + } + + static class BarCallback extends ShaderCallback { + int x, y; + ShaderCallback callback; + + @Override + public void call(int shader) { + int startXUniform = ARBShaderObjects.glGetUniformLocationARB(shader, "startX"); + int startYUniform = ARBShaderObjects.glGetUniformLocationARB(shader, "startY"); + + ARBShaderObjects.glUniform1iARB(startXUniform, x); + ARBShaderObjects.glUniform1iARB(startYUniform, y); + + if (callback != null) callback.call(shader); + } + + void set(int x, int y, ShaderCallback callback) { + this.x = x; + this.y = y; + this.callback = callback; + } + } } diff --git a/src/main/java/vazkii/botania/client/core/handler/BotaniaPlayerController.java b/src/main/java/vazkii/botania/client/core/handler/BotaniaPlayerController.java index a9610ad3a3..c9c649109d 100644 --- a/src/main/java/vazkii/botania/client/core/handler/BotaniaPlayerController.java +++ b/src/main/java/vazkii/botania/client/core/handler/BotaniaPlayerController.java @@ -2,43 +2,42 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jul 22, 2014, 3:33:25 PM (GMT)] */ package vazkii.botania.client.core.handler; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; import net.minecraft.client.Minecraft; import net.minecraft.client.multiplayer.PlayerControllerMP; import net.minecraft.client.network.NetHandlerPlayClient; import vazkii.botania.api.item.IExtendedPlayerController; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; @SideOnly(Side.CLIENT) public class BotaniaPlayerController extends PlayerControllerMP implements IExtendedPlayerController { - private float distance = 0F; - - public BotaniaPlayerController(Minecraft p_i45062_1_, NetHandlerPlayClient p_i45062_2_) { - super(p_i45062_1_, p_i45062_2_); - } + private float distance = 0F; - @Override - public float getBlockReachDistance() { - return super.getBlockReachDistance() + distance; - } + public BotaniaPlayerController(Minecraft p_i45062_1_, NetHandlerPlayClient p_i45062_2_) { + super(p_i45062_1_, p_i45062_2_); + } - @Override - public void setReachDistanceExtension(float f) { - distance = f; - } + @Override + public float getBlockReachDistance() { + return super.getBlockReachDistance() + distance; + } - @Override - public float getReachDistanceExtension() { - return distance; - } + @Override + public void setReachDistanceExtension(float f) { + distance = f; + } + @Override + public float getReachDistanceExtension() { + return distance; + } } diff --git a/src/main/java/vazkii/botania/client/core/handler/BoundTileRenderer.java b/src/main/java/vazkii/botania/client/core/handler/BoundTileRenderer.java index 232d8a3107..5203e217f9 100644 --- a/src/main/java/vazkii/botania/client/core/handler/BoundTileRenderer.java +++ b/src/main/java/vazkii/botania/client/core/handler/BoundTileRenderer.java @@ -2,17 +2,17 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Mar 24, 2014, 7:02:37 PM (GMT)] */ package vazkii.botania.client.core.handler; +import cpw.mods.fml.common.eventhandler.SubscribeEvent; import java.awt.Color; import java.util.List; - import net.minecraft.block.Block; import net.minecraft.client.Minecraft; import net.minecraft.client.renderer.Tessellator; @@ -24,164 +24,161 @@ import net.minecraft.util.ChunkCoordinates; import net.minecraft.world.World; import net.minecraftforge.client.event.RenderWorldLastEvent; - import org.lwjgl.opengl.GL11; - import vazkii.botania.api.BotaniaAPI; import vazkii.botania.api.item.IExtendedWireframeCoordinateListProvider; import vazkii.botania.api.item.IWireframeCoordinateListProvider; import vazkii.botania.api.wand.ICoordBoundItem; import vazkii.botania.api.wand.IWireframeAABBProvider; -import cpw.mods.fml.common.eventhandler.SubscribeEvent; public final class BoundTileRenderer { - @SubscribeEvent - public void onWorldRenderLast(RenderWorldLastEvent event) { - GL11.glPushMatrix(); - GL11.glPushAttrib(GL11.GL_LIGHTING); - GL11.glDisable(GL11.GL_DEPTH_TEST); - GL11.glDisable(GL11.GL_TEXTURE_2D); - GL11.glDisable(GL11.GL_LIGHTING); - GL11.glEnable(GL11.GL_BLEND); - - Tessellator.renderingWorldRenderer = false; - - EntityPlayer player = Minecraft.getMinecraft().thePlayer; - ItemStack stack = player.getCurrentEquippedItem(); - int color = Color.HSBtoRGB(ClientTickHandler.ticksInGame % 200 / 200F, 0.6F, 1F); - if(stack != null && stack.getItem() instanceof ICoordBoundItem) { - ChunkCoordinates coords = ((ICoordBoundItem) stack.getItem()).getBinding(stack); - if(coords != null) - renderBlockOutlineAt(coords, color); - } - - IInventory mainInv = player.inventory; - IInventory baublesInv = BotaniaAPI.internalHandler.getBaublesInventory(player); - - int invSize = mainInv.getSizeInventory(); - int size = invSize; - if(baublesInv != null) - size += baublesInv.getSizeInventory(); - - for(int i = 0; i < size; i++) { - boolean useBaubles = i >= invSize; - IInventory inv = useBaubles ? baublesInv : mainInv; - ItemStack stackInSlot = inv.getStackInSlot(i - (useBaubles ? invSize : 0)); - - if(stackInSlot != null && stackInSlot.getItem() instanceof IWireframeCoordinateListProvider) { - IWireframeCoordinateListProvider provider = (IWireframeCoordinateListProvider) stackInSlot.getItem(); - List coordsList = provider.getWireframesToDraw(player, stackInSlot); - if(coordsList != null) - for(ChunkCoordinates coords : coordsList) - renderBlockOutlineAt(coords, color); - - if(stackInSlot.getItem() instanceof IExtendedWireframeCoordinateListProvider) { - ChunkCoordinates coords = ((IExtendedWireframeCoordinateListProvider) stackInSlot.getItem()).getSourceWireframe(player, stackInSlot); - if(coords != null && coords.posY > -1) - renderBlockOutlineAt(coords, color, 5F); - } - } - } - - GL11.glEnable(GL11.GL_DEPTH_TEST); - GL11.glEnable(GL11.GL_TEXTURE_2D); - GL11.glDisable(GL11.GL_BLEND); - GL11.glPopAttrib(); - GL11.glPopMatrix(); - } - - private void renderBlockOutlineAt(ChunkCoordinates pos, int color) { - renderBlockOutlineAt(pos, color, 1F); - } - - private void renderBlockOutlineAt(ChunkCoordinates pos, int color, float thickness) { - GL11.glPushMatrix(); - GL11.glTranslated(pos.posX - RenderManager.renderPosX, pos.posY - RenderManager.renderPosY, pos.posZ - RenderManager.renderPosZ + 1); - Color colorRGB = new Color(color); - GL11.glColor4ub((byte) colorRGB.getRed(), (byte) colorRGB.getGreen(), (byte) colorRGB.getBlue(), (byte) 255); - - World world = Minecraft.getMinecraft().theWorld; - Block block = world.getBlock(pos.posX, pos.posY, pos.posZ); - drawWireframe : { - if(block != null) { - AxisAlignedBB axis; - - if(block instanceof IWireframeAABBProvider) - axis = ((IWireframeAABBProvider) block).getWireframeAABB(world, pos.posX, pos.posY, pos.posZ); - else axis = block.getSelectedBoundingBoxFromPool(world, pos.posX, pos.posY, pos.posZ); - - if(axis == null) - break drawWireframe; - - axis.minX -= pos.posX; - axis.maxX -= pos.posX; - axis.minY -= pos.posY; - axis.maxY -= pos.posY; - axis.minZ -= pos.posZ + 1; - axis.maxZ -= pos.posZ + 1; - - GL11.glScalef(1F, 1F, 1F); - - GL11.glLineWidth(thickness); - renderBlockOutline(axis); - - GL11.glLineWidth(thickness + 3F); - GL11.glColor4ub((byte) colorRGB.getRed(), (byte) colorRGB.getGreen(), (byte) colorRGB.getBlue(), (byte) 64); - renderBlockOutline(axis); - } - } - - GL11.glPopMatrix(); - } - - private void renderBlockOutline(AxisAlignedBB aabb) { - Tessellator tessellator = Tessellator.instance; - - double ix = aabb.minX; - double iy = aabb.minY; - double iz = aabb.minZ; - double ax = aabb.maxX; - double ay = aabb.maxY; - double az = aabb.maxZ; - - tessellator.startDrawing(GL11.GL_LINES); - tessellator.addVertex(ix, iy, iz); - tessellator.addVertex(ix, ay, iz); - - tessellator.addVertex(ix, ay, iz); - tessellator.addVertex(ax, ay, iz); - - tessellator.addVertex(ax, ay, iz); - tessellator.addVertex(ax, iy, iz); - - tessellator.addVertex(ax, iy, iz); - tessellator.addVertex(ix, iy, iz); - - tessellator.addVertex(ix, iy, az); - tessellator.addVertex(ix, ay, az); - - tessellator.addVertex(ix, iy, az); - tessellator.addVertex(ax, iy, az); - - tessellator.addVertex(ax, iy, az); - tessellator.addVertex(ax, ay, az); - - tessellator.addVertex(ix, ay, az); - tessellator.addVertex(ax, ay, az); - - tessellator.addVertex(ix, iy, iz); - tessellator.addVertex(ix, iy, az); - - tessellator.addVertex(ix, ay, iz); - tessellator.addVertex(ix, ay, az); - - tessellator.addVertex(ax, iy, iz); - tessellator.addVertex(ax, iy, az); + @SubscribeEvent + public void onWorldRenderLast(RenderWorldLastEvent event) { + GL11.glPushMatrix(); + GL11.glPushAttrib(GL11.GL_LIGHTING); + GL11.glDisable(GL11.GL_DEPTH_TEST); + GL11.glDisable(GL11.GL_TEXTURE_2D); + GL11.glDisable(GL11.GL_LIGHTING); + GL11.glEnable(GL11.GL_BLEND); + + Tessellator.renderingWorldRenderer = false; + + EntityPlayer player = Minecraft.getMinecraft().thePlayer; + ItemStack stack = player.getCurrentEquippedItem(); + int color = Color.HSBtoRGB(ClientTickHandler.ticksInGame % 200 / 200F, 0.6F, 1F); + if (stack != null && stack.getItem() instanceof ICoordBoundItem) { + ChunkCoordinates coords = ((ICoordBoundItem) stack.getItem()).getBinding(stack); + if (coords != null) renderBlockOutlineAt(coords, color); + } + + IInventory mainInv = player.inventory; + IInventory baublesInv = BotaniaAPI.internalHandler.getBaublesInventory(player); + + int invSize = mainInv.getSizeInventory(); + int size = invSize; + if (baublesInv != null) size += baublesInv.getSizeInventory(); + + for (int i = 0; i < size; i++) { + boolean useBaubles = i >= invSize; + IInventory inv = useBaubles ? baublesInv : mainInv; + ItemStack stackInSlot = inv.getStackInSlot(i - (useBaubles ? invSize : 0)); + + if (stackInSlot != null && stackInSlot.getItem() instanceof IWireframeCoordinateListProvider) { + IWireframeCoordinateListProvider provider = (IWireframeCoordinateListProvider) stackInSlot.getItem(); + List coordsList = provider.getWireframesToDraw(player, stackInSlot); + if (coordsList != null) for (ChunkCoordinates coords : coordsList) renderBlockOutlineAt(coords, color); + + if (stackInSlot.getItem() instanceof IExtendedWireframeCoordinateListProvider) { + ChunkCoordinates coords = ((IExtendedWireframeCoordinateListProvider) stackInSlot.getItem()) + .getSourceWireframe(player, stackInSlot); + if (coords != null && coords.posY > -1) renderBlockOutlineAt(coords, color, 5F); + } + } + } + + GL11.glEnable(GL11.GL_DEPTH_TEST); + GL11.glEnable(GL11.GL_TEXTURE_2D); + GL11.glDisable(GL11.GL_BLEND); + GL11.glPopAttrib(); + GL11.glPopMatrix(); + } + + private void renderBlockOutlineAt(ChunkCoordinates pos, int color) { + renderBlockOutlineAt(pos, color, 1F); + } + + private void renderBlockOutlineAt(ChunkCoordinates pos, int color, float thickness) { + GL11.glPushMatrix(); + GL11.glTranslated( + pos.posX - RenderManager.renderPosX, + pos.posY - RenderManager.renderPosY, + pos.posZ - RenderManager.renderPosZ + 1); + Color colorRGB = new Color(color); + GL11.glColor4ub((byte) colorRGB.getRed(), (byte) colorRGB.getGreen(), (byte) colorRGB.getBlue(), (byte) 255); + + World world = Minecraft.getMinecraft().theWorld; + Block block = world.getBlock(pos.posX, pos.posY, pos.posZ); + drawWireframe: + { + if (block != null) { + AxisAlignedBB axis; + + if (block instanceof IWireframeAABBProvider) + axis = ((IWireframeAABBProvider) block).getWireframeAABB(world, pos.posX, pos.posY, pos.posZ); + else axis = block.getSelectedBoundingBoxFromPool(world, pos.posX, pos.posY, pos.posZ); + + if (axis == null) break drawWireframe; + + axis.minX -= pos.posX; + axis.maxX -= pos.posX; + axis.minY -= pos.posY; + axis.maxY -= pos.posY; + axis.minZ -= pos.posZ + 1; + axis.maxZ -= pos.posZ + 1; + + GL11.glScalef(1F, 1F, 1F); + + GL11.glLineWidth(thickness); + renderBlockOutline(axis); + + GL11.glLineWidth(thickness + 3F); + GL11.glColor4ub( + (byte) colorRGB.getRed(), (byte) colorRGB.getGreen(), (byte) colorRGB.getBlue(), (byte) 64); + renderBlockOutline(axis); + } + } + + GL11.glPopMatrix(); + } + + private void renderBlockOutline(AxisAlignedBB aabb) { + Tessellator tessellator = Tessellator.instance; + + double ix = aabb.minX; + double iy = aabb.minY; + double iz = aabb.minZ; + double ax = aabb.maxX; + double ay = aabb.maxY; + double az = aabb.maxZ; + + tessellator.startDrawing(GL11.GL_LINES); + tessellator.addVertex(ix, iy, iz); + tessellator.addVertex(ix, ay, iz); + + tessellator.addVertex(ix, ay, iz); + tessellator.addVertex(ax, ay, iz); + + tessellator.addVertex(ax, ay, iz); + tessellator.addVertex(ax, iy, iz); + + tessellator.addVertex(ax, iy, iz); + tessellator.addVertex(ix, iy, iz); + + tessellator.addVertex(ix, iy, az); + tessellator.addVertex(ix, ay, az); + + tessellator.addVertex(ix, iy, az); + tessellator.addVertex(ax, iy, az); + + tessellator.addVertex(ax, iy, az); + tessellator.addVertex(ax, ay, az); + + tessellator.addVertex(ix, ay, az); + tessellator.addVertex(ax, ay, az); + + tessellator.addVertex(ix, iy, iz); + tessellator.addVertex(ix, iy, az); + + tessellator.addVertex(ix, ay, iz); + tessellator.addVertex(ix, ay, az); + + tessellator.addVertex(ax, iy, iz); + tessellator.addVertex(ax, iy, az); - tessellator.addVertex(ax, ay, iz); - tessellator.addVertex(ax, ay, az); + tessellator.addVertex(ax, ay, iz); + tessellator.addVertex(ax, ay, az); - tessellator.draw(); - } + tessellator.draw(); + } } diff --git a/src/main/java/vazkii/botania/client/core/handler/ClientTickHandler.java b/src/main/java/vazkii/botania/client/core/handler/ClientTickHandler.java index 3f88f926a0..4d216681d6 100644 --- a/src/main/java/vazkii/botania/client/core/handler/ClientTickHandler.java +++ b/src/main/java/vazkii/botania/client/core/handler/ClientTickHandler.java @@ -2,17 +2,20 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Feb 3, 2014, 9:59:17 PM (GMT)] */ package vazkii.botania.client.core.handler; +import cpw.mods.fml.common.eventhandler.SubscribeEvent; +import cpw.mods.fml.common.gameevent.TickEvent.ClientTickEvent; +import cpw.mods.fml.common.gameevent.TickEvent.Phase; +import cpw.mods.fml.common.gameevent.TickEvent.RenderTickEvent; import java.util.ArrayList; import java.util.List; - import net.minecraft.client.Minecraft; import net.minecraft.client.gui.GuiScreen; import net.minecraft.entity.player.EntityPlayer; @@ -26,95 +29,83 @@ import vazkii.botania.common.block.tile.corporea.TileCorporeaIndex; import vazkii.botania.common.core.handler.ManaNetworkHandler; import vazkii.botania.common.item.ItemTwigWand; -import cpw.mods.fml.common.eventhandler.SubscribeEvent; -import cpw.mods.fml.common.gameevent.TickEvent.ClientTickEvent; -import cpw.mods.fml.common.gameevent.TickEvent.Phase; -import cpw.mods.fml.common.gameevent.TickEvent.RenderTickEvent; public class ClientTickHandler { - public static int ticksWithLexicaOpen = 0; - public static int pageFlipTicks = 0; - public static int ticksInGame = 0; - public static float partialTicks = 0; - public static float delta = 0; - public static float total = 0; - - private void calcDelta() { - float oldTotal = total; - total = ticksInGame + partialTicks; - delta = total - oldTotal; - } + public static int ticksWithLexicaOpen = 0; + public static int pageFlipTicks = 0; + public static int ticksInGame = 0; + public static float partialTicks = 0; + public static float delta = 0; + public static float total = 0; - @SubscribeEvent - public void renderTick(RenderTickEvent event) { - if(event.phase == Phase.START) - partialTicks = event.renderTickTime; - else { - TooltipAdditionDisplayHandler.render(); - calcDelta(); - } - } + private void calcDelta() { + float oldTotal = total; + total = ticksInGame + partialTicks; + delta = total - oldTotal; + } - @SubscribeEvent - public void clientTickEnd(ClientTickEvent event) { - if(event.phase == Phase.END) { - LightningBolt.update(); - RedStringRenderer.tick(); - ItemsRemainingRenderHandler.tick(); + @SubscribeEvent + public void renderTick(RenderTickEvent event) { + if (event.phase == Phase.START) partialTicks = event.renderTickTime; + else { + TooltipAdditionDisplayHandler.render(); + calcDelta(); + } + } - if(Minecraft.getMinecraft().theWorld == null) { - ManaNetworkHandler.instance.clear(); - TileCorporeaIndex.indexes.clear(); - SubTileVinculotus.existingFlowers.clear(); - } + @SubscribeEvent + public void clientTickEnd(ClientTickEvent event) { + if (event.phase == Phase.END) { + LightningBolt.update(); + RedStringRenderer.tick(); + ItemsRemainingRenderHandler.tick(); - GuiScreen gui = Minecraft.getMinecraft().currentScreen; - if(gui == null || !gui.doesGuiPauseGame()) { - ticksInGame++; - partialTicks = 0; + if (Minecraft.getMinecraft().theWorld == null) { + ManaNetworkHandler.instance.clear(); + TileCorporeaIndex.indexes.clear(); + SubTileVinculotus.existingFlowers.clear(); + } - EntityPlayer player = Minecraft.getMinecraft().thePlayer; - if(player != null) { - ItemStack stack = player.getCurrentEquippedItem(); - if(stack != null && stack.getItem() instanceof ItemTwigWand) { - List list = new ArrayList(ManaNetworkHandler.instance.getAllCollectorsInWorld(Minecraft.getMinecraft().theWorld)); - for(TileSignature sig : list) { - if(!sig.remoteWorld) - continue; + GuiScreen gui = Minecraft.getMinecraft().currentScreen; + if (gui == null || !gui.doesGuiPauseGame()) { + ticksInGame++; + partialTicks = 0; - TileEntity tile = sig.tile; - if(tile instanceof IManaCollector) - ((IManaCollector) tile).onClientDisplayTick(); - } - } - } - } + EntityPlayer player = Minecraft.getMinecraft().thePlayer; + if (player != null) { + ItemStack stack = player.getCurrentEquippedItem(); + if (stack != null && stack.getItem() instanceof ItemTwigWand) { + List list = new ArrayList( + ManaNetworkHandler.instance.getAllCollectorsInWorld(Minecraft.getMinecraft().theWorld)); + for (TileSignature sig : list) { + if (!sig.remoteWorld) continue; - int ticksToOpen = 10; - if(gui instanceof GuiLexicon) { - if(ticksWithLexicaOpen < 0) - ticksWithLexicaOpen = 0; - if(ticksWithLexicaOpen < ticksToOpen) - ticksWithLexicaOpen++; - if(pageFlipTicks > 0) - pageFlipTicks--; - } else { - pageFlipTicks = 0; - if(ticksWithLexicaOpen > 0) { - if(ticksWithLexicaOpen > ticksToOpen) - ticksWithLexicaOpen = ticksToOpen; - ticksWithLexicaOpen--; - } - } + TileEntity tile = sig.tile; + if (tile instanceof IManaCollector) ((IManaCollector) tile).onClientDisplayTick(); + } + } + } + } - calcDelta(); - } - } + int ticksToOpen = 10; + if (gui instanceof GuiLexicon) { + if (ticksWithLexicaOpen < 0) ticksWithLexicaOpen = 0; + if (ticksWithLexicaOpen < ticksToOpen) ticksWithLexicaOpen++; + if (pageFlipTicks > 0) pageFlipTicks--; + } else { + pageFlipTicks = 0; + if (ticksWithLexicaOpen > 0) { + if (ticksWithLexicaOpen > ticksToOpen) ticksWithLexicaOpen = ticksToOpen; + ticksWithLexicaOpen--; + } + } - public static void notifyPageChange() { - if(pageFlipTicks == 0) - pageFlipTicks = 5; - } + calcDelta(); + } + } + public static void notifyPageChange() { + if (pageFlipTicks == 0) pageFlipTicks = 5; + } } diff --git a/src/main/java/vazkii/botania/client/core/handler/ContributorFancinessHandler.java b/src/main/java/vazkii/botania/client/core/handler/ContributorFancinessHandler.java index 2a652019b4..be8c2262a4 100644 --- a/src/main/java/vazkii/botania/client/core/handler/ContributorFancinessHandler.java +++ b/src/main/java/vazkii/botania/client/core/handler/ContributorFancinessHandler.java @@ -2,20 +2,20 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Apr 9, 2015, 5:35:26 PM (GMT)] */ package vazkii.botania.client.core.handler; +import cpw.mods.fml.common.FMLLog; import java.io.InputStreamReader; import java.net.URL; import java.util.HashMap; import java.util.Map; import java.util.Properties; - import net.minecraft.client.Minecraft; import net.minecraft.client.renderer.ItemRenderer; import net.minecraft.client.renderer.Tessellator; @@ -23,9 +23,7 @@ import net.minecraft.client.settings.GameSettings.Options; import net.minecraft.util.IIcon; import net.minecraftforge.client.event.RenderPlayerEvent; - import org.lwjgl.opengl.GL11; - import vazkii.botania.api.BotaniaAPI; import vazkii.botania.api.item.IBaubleRender.Helper; import vazkii.botania.api.subtile.signature.SubTileSignature; @@ -34,165 +32,165 @@ import vazkii.botania.common.item.ModItems; import vazkii.botania.common.item.block.ItemBlockSpecialFlower; import vazkii.botania.common.item.material.ItemManaResource; -import cpw.mods.fml.common.FMLLog; public final class ContributorFancinessHandler { - public volatile static Map flowerMap = null; - private volatile static boolean startedLoading = false; - - private static boolean phi = true; - - public static void render(RenderPlayerEvent.Specials event) { - String name = event.entityPlayer.getDisplayName(); - - if(name.equals("Vazkii") || name.equals("_phi")) { - if(phi) - renderPhiFlower(event); - else renderTwintails(event); - } else if(name.equals("haighyorkie")) - renderGoldfish(event); - - firstStart(); - - name = name.toLowerCase(); - if(Minecraft.getMinecraft().gameSettings.getOptionOrdinalValue(Options.SHOW_CAPE) && flowerMap != null && flowerMap.containsKey(name)) - renderFlower(event, flowerMap.get(name)); - } - - public static void firstStart() { - if(!startedLoading) { - new ThreadContributorListLoader(); - startedLoading = true; - } - } - - public static void load(Properties props) { - flowerMap = new HashMap(); - for(String key : props.stringPropertyNames()) { - String value = props.getProperty(key); - - try { - int i = Integer.parseInt(value); - if(i < 0 || i >= 16) - throw new NumberFormatException(); - flowerMap.put(key, ModBlocks.flower.func_149735_b(0, i)); - } catch(NumberFormatException e) { - SubTileSignature sig = BotaniaAPI.getSignatureForName(value); - if(sig != null) - flowerMap.put(key, ItemBlockSpecialFlower.ofType(value).getIconIndex()); - } - } - } - - private static void renderTwintails(RenderPlayerEvent event) { - GL11.glPushMatrix(); - IIcon icon = ((ItemManaResource) ModItems.manaResource).tailIcon; - float f = icon.getMinU(); - float f1 = icon.getMaxU(); - float f2 = icon.getMinV(); - float f3 = icon.getMaxV(); - Helper.translateToHeadLevel(event.entityPlayer); - Minecraft.getMinecraft().renderEngine.bindTexture(TextureMap.locationItemsTexture); - GL11.glColor4f(1F, 1F, 1F, 1F); - GL11.glRotatef(90F, 0F, 1F, 0F); - float t = 0.13F; - GL11.glTranslatef(t, -0.5F, -0.1F); - if(event.entityPlayer.motionY < 0) - GL11.glRotatef((float) event.entityPlayer.motionY * 20F, 1F, 0F, 0F); - - float r = -18F + (float) Math.sin((ClientTickHandler.ticksInGame + event.partialRenderTick) * 0.05F) * 2F; - GL11.glRotatef(r, 0F, 0F, 1F); - float s = 0.9F; - GL11.glScalef(s, s, s); - ItemRenderer.renderItemIn2D(Tessellator.instance, f1, f2, f, f3, icon.getIconWidth(), icon.getIconHeight(), 1F / 16F); - GL11.glRotatef(-r, 0F, 0F, 1F); - GL11.glTranslatef(-t, -0F, 0F); - GL11.glScalef(-1F, 1F, 1F); - GL11.glTranslatef(t, -0F, 0F); - GL11.glRotatef(r, 0F, 0F, 1F); - ItemRenderer.renderItemIn2D(Tessellator.instance, f1, f2, f, f3, icon.getIconWidth(), icon.getIconHeight(), 1F / 16F); - GL11.glPopMatrix(); - } - - private static void renderPhiFlower(RenderPlayerEvent event) { - GL11.glPushMatrix(); - IIcon icon = ((ItemManaResource) ModItems.manaResource).phiFlowerIcon; - float f = icon.getMinU(); - float f1 = icon.getMaxU(); - float f2 = icon.getMinV(); - float f3 = icon.getMaxV(); - Helper.translateToHeadLevel(event.entityPlayer); - GL11.glRotatef(90F, 0F, 1F, 0F); - GL11.glRotatef(180F, 1F, 0F, 0F); - GL11.glTranslatef(-0.4F, 0.1F, -0.25F); - Minecraft.getMinecraft().renderEngine.bindTexture(TextureMap.locationItemsTexture); - GL11.glRotatef(90F, 0F, 1F, 0F); - GL11.glScalef(0.4F, 0.4F, 0.4F); - GL11.glTranslatef(-1.2F, 0.2F, 0.125F); - GL11.glRotatef(20F, 1F, 0F, 0F); - ItemRenderer.renderItemIn2D(Tessellator.instance, f1, f2, f, f3, icon.getIconWidth(), icon.getIconHeight(), 1F / 16F); - GL11.glPopMatrix(); - } - - private static void renderGoldfish(RenderPlayerEvent event) { - GL11.glPushMatrix(); - IIcon icon = ((ItemManaResource) ModItems.manaResource).goldfishIcon; - float f = icon.getMinU(); - float f1 = icon.getMaxU(); - float f2 = icon.getMinV(); - float f3 = icon.getMaxV(); - Helper.rotateIfSneaking(event.entityPlayer); - GL11.glRotatef(90F, 0F, 1F, 0F); - GL11.glRotatef(180F, 0F, 0F, 1F); - GL11.glTranslatef(-0.75F, 0.5F, 0F); - GL11.glScalef(0.4F, 0.4F, 0.4F); - GL11.glTranslatef(1.2F, 0.5F, 0F); - Minecraft.getMinecraft().renderEngine.bindTexture(TextureMap.locationItemsTexture); - ItemRenderer.renderItemIn2D(Tessellator.instance, f1, f2, f, f3, icon.getIconWidth(), icon.getIconHeight(), 1F / 16F); - GL11.glPopMatrix(); - } - - private static void renderFlower(RenderPlayerEvent event, IIcon icon) { - GL11.glPushMatrix(); - Helper.translateToHeadLevel(event.entityPlayer); - Minecraft.getMinecraft().renderEngine.bindTexture(TextureMap.locationBlocksTexture); - float f = icon.getMinU(); - float f1 = icon.getMaxU(); - float f2 = icon.getMinV(); - float f3 = icon.getMaxV(); - GL11.glRotatef(180F, 0F, 0F, 1F); - GL11.glRotatef(90F, 0F, 1F, 0F); - GL11.glScalef(0.5F, 0.5F, 0.5F); - GL11.glTranslatef(-0.5F, 0.7F, 0F); - - ShaderHelper.useShader(ShaderHelper.gold); - ItemRenderer.renderItemIn2D(Tessellator.instance, f1, f2, f, f3, icon.getIconWidth(), icon.getIconHeight(), 1F / 16F); - ShaderHelper.releaseShader(); - GL11.glPopMatrix(); - } - - public static class ThreadContributorListLoader extends Thread { - - public ThreadContributorListLoader() { - setName("Botania Contributor Fanciness Thread"); - setDaemon(true); - start(); - } - - @Override - public void run() { - try { - URL url = new URL("https://raw.githubusercontent.com/Vazkii/Botania/master/contributors.properties"); - Properties props = new Properties(); - props.load(new InputStreamReader(url.openStream())); - load(props); - } catch(Exception e) { - FMLLog.info("[Botania] Could not load contributors list. Either you're offline or github is down. Nothing to worry about, carry on~"); - e.printStackTrace(); - } - } - - } - + public static volatile Map flowerMap = null; + private static volatile boolean startedLoading = false; + + private static boolean phi = true; + + public static void render(RenderPlayerEvent.Specials event) { + String name = event.entityPlayer.getDisplayName(); + + if (name.equals("Vazkii") || name.equals("_phi")) { + if (phi) renderPhiFlower(event); + else renderTwintails(event); + } else if (name.equals("haighyorkie")) renderGoldfish(event); + + firstStart(); + + name = name.toLowerCase(); + if (Minecraft.getMinecraft().gameSettings.getOptionOrdinalValue(Options.SHOW_CAPE) + && flowerMap != null + && flowerMap.containsKey(name)) renderFlower(event, flowerMap.get(name)); + } + + public static void firstStart() { + if (!startedLoading) { + new ThreadContributorListLoader(); + startedLoading = true; + } + } + + public static void load(Properties props) { + flowerMap = new HashMap(); + for (String key : props.stringPropertyNames()) { + String value = props.getProperty(key); + + try { + int i = Integer.parseInt(value); + if (i < 0 || i >= 16) throw new NumberFormatException(); + flowerMap.put(key, ModBlocks.flower.func_149735_b(0, i)); + } catch (NumberFormatException e) { + SubTileSignature sig = BotaniaAPI.getSignatureForName(value); + if (sig != null) + flowerMap.put(key, ItemBlockSpecialFlower.ofType(value).getIconIndex()); + } + } + } + + private static void renderTwintails(RenderPlayerEvent event) { + GL11.glPushMatrix(); + IIcon icon = ((ItemManaResource) ModItems.manaResource).tailIcon; + float f = icon.getMinU(); + float f1 = icon.getMaxU(); + float f2 = icon.getMinV(); + float f3 = icon.getMaxV(); + Helper.translateToHeadLevel(event.entityPlayer); + Minecraft.getMinecraft().renderEngine.bindTexture(TextureMap.locationItemsTexture); + GL11.glColor4f(1F, 1F, 1F, 1F); + GL11.glRotatef(90F, 0F, 1F, 0F); + float t = 0.13F; + GL11.glTranslatef(t, -0.5F, -0.1F); + if (event.entityPlayer.motionY < 0) GL11.glRotatef((float) event.entityPlayer.motionY * 20F, 1F, 0F, 0F); + + float r = -18F + (float) Math.sin((ClientTickHandler.ticksInGame + event.partialRenderTick) * 0.05F) * 2F; + GL11.glRotatef(r, 0F, 0F, 1F); + float s = 0.9F; + GL11.glScalef(s, s, s); + ItemRenderer.renderItemIn2D( + Tessellator.instance, f1, f2, f, f3, icon.getIconWidth(), icon.getIconHeight(), 1F / 16F); + GL11.glRotatef(-r, 0F, 0F, 1F); + GL11.glTranslatef(-t, -0F, 0F); + GL11.glScalef(-1F, 1F, 1F); + GL11.glTranslatef(t, -0F, 0F); + GL11.glRotatef(r, 0F, 0F, 1F); + ItemRenderer.renderItemIn2D( + Tessellator.instance, f1, f2, f, f3, icon.getIconWidth(), icon.getIconHeight(), 1F / 16F); + GL11.glPopMatrix(); + } + + private static void renderPhiFlower(RenderPlayerEvent event) { + GL11.glPushMatrix(); + IIcon icon = ((ItemManaResource) ModItems.manaResource).phiFlowerIcon; + float f = icon.getMinU(); + float f1 = icon.getMaxU(); + float f2 = icon.getMinV(); + float f3 = icon.getMaxV(); + Helper.translateToHeadLevel(event.entityPlayer); + GL11.glRotatef(90F, 0F, 1F, 0F); + GL11.glRotatef(180F, 1F, 0F, 0F); + GL11.glTranslatef(-0.4F, 0.1F, -0.25F); + Minecraft.getMinecraft().renderEngine.bindTexture(TextureMap.locationItemsTexture); + GL11.glRotatef(90F, 0F, 1F, 0F); + GL11.glScalef(0.4F, 0.4F, 0.4F); + GL11.glTranslatef(-1.2F, 0.2F, 0.125F); + GL11.glRotatef(20F, 1F, 0F, 0F); + ItemRenderer.renderItemIn2D( + Tessellator.instance, f1, f2, f, f3, icon.getIconWidth(), icon.getIconHeight(), 1F / 16F); + GL11.glPopMatrix(); + } + + private static void renderGoldfish(RenderPlayerEvent event) { + GL11.glPushMatrix(); + IIcon icon = ((ItemManaResource) ModItems.manaResource).goldfishIcon; + float f = icon.getMinU(); + float f1 = icon.getMaxU(); + float f2 = icon.getMinV(); + float f3 = icon.getMaxV(); + Helper.rotateIfSneaking(event.entityPlayer); + GL11.glRotatef(90F, 0F, 1F, 0F); + GL11.glRotatef(180F, 0F, 0F, 1F); + GL11.glTranslatef(-0.75F, 0.5F, 0F); + GL11.glScalef(0.4F, 0.4F, 0.4F); + GL11.glTranslatef(1.2F, 0.5F, 0F); + Minecraft.getMinecraft().renderEngine.bindTexture(TextureMap.locationItemsTexture); + ItemRenderer.renderItemIn2D( + Tessellator.instance, f1, f2, f, f3, icon.getIconWidth(), icon.getIconHeight(), 1F / 16F); + GL11.glPopMatrix(); + } + + private static void renderFlower(RenderPlayerEvent event, IIcon icon) { + GL11.glPushMatrix(); + Helper.translateToHeadLevel(event.entityPlayer); + Minecraft.getMinecraft().renderEngine.bindTexture(TextureMap.locationBlocksTexture); + float f = icon.getMinU(); + float f1 = icon.getMaxU(); + float f2 = icon.getMinV(); + float f3 = icon.getMaxV(); + GL11.glRotatef(180F, 0F, 0F, 1F); + GL11.glRotatef(90F, 0F, 1F, 0F); + GL11.glScalef(0.5F, 0.5F, 0.5F); + GL11.glTranslatef(-0.5F, 0.7F, 0F); + + ShaderHelper.useShader(ShaderHelper.gold); + ItemRenderer.renderItemIn2D( + Tessellator.instance, f1, f2, f, f3, icon.getIconWidth(), icon.getIconHeight(), 1F / 16F); + ShaderHelper.releaseShader(); + GL11.glPopMatrix(); + } + + public static class ThreadContributorListLoader extends Thread { + + public ThreadContributorListLoader() { + setName("Botania Contributor Fanciness Thread"); + setDaemon(true); + start(); + } + + @Override + public void run() { + try { + URL url = new URL("https://raw.githubusercontent.com/Vazkii/Botania/master/contributors.properties"); + Properties props = new Properties(); + props.load(new InputStreamReader(url.openStream())); + load(props); + } catch (Exception e) { + FMLLog.info( + "[Botania] Could not load contributors list. Either you're offline or github is down. Nothing to worry about, carry on~"); + e.printStackTrace(); + } + } + } } diff --git a/src/main/java/vazkii/botania/client/core/handler/CorporeaAutoCompleteHandler.java b/src/main/java/vazkii/botania/client/core/handler/CorporeaAutoCompleteHandler.java index b33560e04a..3575e8c5b9 100644 --- a/src/main/java/vazkii/botania/client/core/handler/CorporeaAutoCompleteHandler.java +++ b/src/main/java/vazkii/botania/client/core/handler/CorporeaAutoCompleteHandler.java @@ -2,21 +2,24 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [June 8, 2015, 12:55:20 AM (GMT)] */ package vazkii.botania.client.core.handler; +import cpw.mods.fml.common.eventhandler.SubscribeEvent; +import cpw.mods.fml.common.gameevent.TickEvent.ClientTickEvent; +import cpw.mods.fml.common.gameevent.TickEvent.Phase; +import cpw.mods.fml.relauncher.ReflectionHelper; import java.util.ArrayList; import java.util.Comparator; import java.util.Iterator; import java.util.List; import java.util.SortedSet; import java.util.TreeSet; - import net.minecraft.client.Minecraft; import net.minecraft.client.gui.GuiChat; import net.minecraft.client.gui.GuiScreen; @@ -25,166 +28,149 @@ import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.util.ChatComponentText; - import org.lwjgl.input.Keyboard; - import vazkii.botania.api.corporea.CorporeaHelper; import vazkii.botania.common.lib.LibObfuscation; -import cpw.mods.fml.common.eventhandler.SubscribeEvent; -import cpw.mods.fml.common.gameevent.TickEvent.ClientTickEvent; -import cpw.mods.fml.common.gameevent.TickEvent.Phase; -import cpw.mods.fml.relauncher.ReflectionHelper; public class CorporeaAutoCompleteHandler { - boolean isAutoCompleted = false; - String originalString = ""; - List completions = new ArrayList(); - int position; - - static TreeSet itemNames = new TreeSet( - new Comparator() { - @Override - public int compare(String arg0, String arg1) { - return arg0.compareToIgnoreCase(arg1); - } - }); - - private boolean tabLastTick = false; - - public static void updateItemList() { - itemNames.clear(); - Iterator iterator = Item.itemRegistry.iterator(); - ArrayList curList = new ArrayList(); - - while(iterator.hasNext()) { - Item item = iterator.next(); - - if(item != null && item.getCreativeTab() != null) { - curList.clear(); - try { - item.getSubItems(item, (CreativeTabs) null, curList); - for(ItemStack stack : curList) - itemNames.add(CorporeaHelper.stripControlCodes(stack.getDisplayName().trim())); - } - catch (Exception e) {} - } - } - } - - @SubscribeEvent - public void onTick(ClientTickEvent event) { - if(event.phase != Phase.END) - return; - GuiScreen screen = Minecraft.getMinecraft().currentScreen; - if(!(screen instanceof GuiChat)) { - isAutoCompleted = false; - return; - } - GuiChat chat = (GuiChat) screen; - if(isAutoCompleted) { - boolean valid = ReflectionHelper.getPrivateValue(GuiChat.class, chat, LibObfuscation.COMPLETE_FLAG); - if(!valid) - isAutoCompleted = false; - } - if(Keyboard.isKeyDown(15)) { - if(tabLastTick) - return; - tabLastTick = true; - } else { - tabLastTick = false; - return; - } - - if(!CorporeaHelper.shouldAutoComplete()) - return; - - GuiTextField inputField = ReflectionHelper.getPrivateValue(GuiChat.class, chat, LibObfuscation.INPUT_FIELD); - if(!isAutoCompleted) - buildAutoCompletes(inputField, chat); - if(isAutoCompleted && !completions.isEmpty()) - advanceAutoComplete(inputField, chat); - } - - private void advanceAutoComplete(GuiTextField inputField, GuiChat chat) { - position++; - if(position >= completions.size()) - position -= completions.size(); - CompletionData data = completions.get(position); - String str = originalString.substring(0, originalString.length() - data.prefixLength) + data.string; - inputField.setText(str); - } - - private void buildAutoCompletes(GuiTextField inputField, GuiChat chat) { - String leftOfCursor; - if(inputField.getCursorPosition() == 0) - leftOfCursor = ""; - else - leftOfCursor = inputField.getText().substring(0, inputField.getCursorPosition()); - if(leftOfCursor.length() == 0 || leftOfCursor.charAt(0) == '/') - return; - completions = getNames(leftOfCursor); - if(completions.isEmpty()) - return; - position = -1; - ReflectionHelper.setPrivateValue(GuiChat.class, chat, true, LibObfuscation.COMPLETE_FLAG); - StringBuilder stringbuilder = new StringBuilder(); - CompletionData data; - for(Iterator iterator = completions.iterator(); iterator.hasNext(); stringbuilder.append(data.string)) { - data = iterator.next(); - if(stringbuilder.length() > 0) - stringbuilder.append(", "); - } - - Minecraft.getMinecraft().ingameGUI.getChatGUI().printChatMessageWithOptionalDeletion(new ChatComponentText(stringbuilder.toString()), 1); - isAutoCompleted = true; - originalString = inputField.getText(); - } - - private ArrayList getNames(String prefix) { - String s = prefix.trim(); - if(s.isEmpty()) - return new ArrayList(); - - TreeSet result = new TreeSet(); - String[] words = s.split(" "); - int i = words.length - 1; - String curPrefix = words[i]; - while(i >= 0) { - result.addAll(getNamesStartingWith(curPrefix.toLowerCase())); - i--; - if(i >= 0) - curPrefix = words[i] + " " + curPrefix; - } - return new ArrayList(result); - } - - private List getNamesStartingWith(String prefix) { - ArrayList result = new ArrayList(); - int length = prefix.length(); - SortedSet after = itemNames.tailSet(prefix); - for(String str : after) { - if(str.toLowerCase().startsWith(prefix)) - result.add(new CompletionData(str, length)); - else return result; - } - return result; - } - - private static class CompletionData implements Comparable { - - private String string; - private int prefixLength; - - public CompletionData(String string, int prefixLength) { - this.string = string; - this.prefixLength = prefixLength; - } - - @Override - public int compareTo(CompletionData arg0) { - return string.compareTo(arg0.string); - } - } - + boolean isAutoCompleted = false; + String originalString = ""; + List completions = new ArrayList(); + int position; + + static TreeSet itemNames = new TreeSet(new Comparator() { + @Override + public int compare(String arg0, String arg1) { + return arg0.compareToIgnoreCase(arg1); + } + }); + + private boolean tabLastTick = false; + + public static void updateItemList() { + itemNames.clear(); + Iterator iterator = Item.itemRegistry.iterator(); + ArrayList curList = new ArrayList(); + + while (iterator.hasNext()) { + Item item = iterator.next(); + + if (item != null && item.getCreativeTab() != null) { + curList.clear(); + try { + item.getSubItems(item, (CreativeTabs) null, curList); + for (ItemStack stack : curList) + itemNames.add(CorporeaHelper.stripControlCodes( + stack.getDisplayName().trim())); + } catch (Exception e) { + } + } + } + } + + @SubscribeEvent + public void onTick(ClientTickEvent event) { + if (event.phase != Phase.END) return; + GuiScreen screen = Minecraft.getMinecraft().currentScreen; + if (!(screen instanceof GuiChat)) { + isAutoCompleted = false; + return; + } + GuiChat chat = (GuiChat) screen; + if (isAutoCompleted) { + boolean valid = ReflectionHelper.getPrivateValue(GuiChat.class, chat, LibObfuscation.COMPLETE_FLAG); + if (!valid) isAutoCompleted = false; + } + if (Keyboard.isKeyDown(15)) { + if (tabLastTick) return; + tabLastTick = true; + } else { + tabLastTick = false; + return; + } + + if (!CorporeaHelper.shouldAutoComplete()) return; + + GuiTextField inputField = ReflectionHelper.getPrivateValue(GuiChat.class, chat, LibObfuscation.INPUT_FIELD); + if (!isAutoCompleted) buildAutoCompletes(inputField, chat); + if (isAutoCompleted && !completions.isEmpty()) advanceAutoComplete(inputField, chat); + } + + private void advanceAutoComplete(GuiTextField inputField, GuiChat chat) { + position++; + if (position >= completions.size()) position -= completions.size(); + CompletionData data = completions.get(position); + String str = originalString.substring(0, originalString.length() - data.prefixLength) + data.string; + inputField.setText(str); + } + + private void buildAutoCompletes(GuiTextField inputField, GuiChat chat) { + String leftOfCursor; + if (inputField.getCursorPosition() == 0) leftOfCursor = ""; + else leftOfCursor = inputField.getText().substring(0, inputField.getCursorPosition()); + if (leftOfCursor.length() == 0 || leftOfCursor.charAt(0) == '/') return; + completions = getNames(leftOfCursor); + if (completions.isEmpty()) return; + position = -1; + ReflectionHelper.setPrivateValue(GuiChat.class, chat, true, LibObfuscation.COMPLETE_FLAG); + StringBuilder stringbuilder = new StringBuilder(); + CompletionData data; + for (Iterator iterator = completions.iterator(); + iterator.hasNext(); + stringbuilder.append(data.string)) { + data = iterator.next(); + if (stringbuilder.length() > 0) stringbuilder.append(", "); + } + + Minecraft.getMinecraft() + .ingameGUI + .getChatGUI() + .printChatMessageWithOptionalDeletion(new ChatComponentText(stringbuilder.toString()), 1); + isAutoCompleted = true; + originalString = inputField.getText(); + } + + private ArrayList getNames(String prefix) { + String s = prefix.trim(); + if (s.isEmpty()) return new ArrayList(); + + TreeSet result = new TreeSet(); + String[] words = s.split(" "); + int i = words.length - 1; + String curPrefix = words[i]; + while (i >= 0) { + result.addAll(getNamesStartingWith(curPrefix.toLowerCase())); + i--; + if (i >= 0) curPrefix = words[i] + " " + curPrefix; + } + return new ArrayList(result); + } + + private List getNamesStartingWith(String prefix) { + ArrayList result = new ArrayList(); + int length = prefix.length(); + SortedSet after = itemNames.tailSet(prefix); + for (String str : after) { + if (str.toLowerCase().startsWith(prefix)) result.add(new CompletionData(str, length)); + else return result; + } + return result; + } + + private static class CompletionData implements Comparable { + + private String string; + private int prefixLength; + + public CompletionData(String string, int prefixLength) { + this.string = string; + this.prefixLength = prefixLength; + } + + @Override + public int compareTo(CompletionData arg0) { + return string.compareTo(arg0.string); + } + } } diff --git a/src/main/java/vazkii/botania/client/core/handler/DebugHandler.java b/src/main/java/vazkii/botania/client/core/handler/DebugHandler.java index 9e6055b7a2..c2a239bb7e 100644 --- a/src/main/java/vazkii/botania/client/core/handler/DebugHandler.java +++ b/src/main/java/vazkii/botania/client/core/handler/DebugHandler.java @@ -2,67 +2,67 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Oct 21, 2014, 4:58:55 PM (GMT)] */ package vazkii.botania.client.core.handler; +import cpw.mods.fml.common.eventhandler.SubscribeEvent; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.GuiScreen; import net.minecraft.util.EnumChatFormatting; import net.minecraft.world.World; import net.minecraftforge.client.event.RenderGameOverlayEvent; - import org.lwjgl.opengl.ARBFragmentShader; import org.lwjgl.opengl.ContextCapabilities; import org.lwjgl.opengl.GL11; import org.lwjgl.opengl.GL20; import org.lwjgl.opengl.GLContext; - import vazkii.botania.client.fx.ParticleRenderDispatcher; import vazkii.botania.common.core.handler.ConfigHandler; import vazkii.botania.common.core.handler.ManaNetworkHandler; import vazkii.botania.common.lib.LibMisc; -import cpw.mods.fml.common.eventhandler.SubscribeEvent; public final class DebugHandler { - private static final String PREFIX = EnumChatFormatting.GREEN + "[Botania] " + EnumChatFormatting.RESET; - - @SubscribeEvent - public void onDrawDebugText(RenderGameOverlayEvent.Text event) { - World world = Minecraft.getMinecraft().theWorld; - if(Minecraft.getMinecraft().gameSettings.showDebugInfo) { - event.left.add(null); - String version = LibMisc.VERSION; - if(version.contains("GRADLE")) - version = "N/A"; - - event.left.add(PREFIX + "pS: " + ParticleRenderDispatcher.sparkleFxCount + ", pFS: " + ParticleRenderDispatcher.fakeSparkleFxCount + ", pW: " + ParticleRenderDispatcher.wispFxCount + ", pDIW: " + ParticleRenderDispatcher.depthIgnoringWispFxCount + ", pLB: " + ParticleRenderDispatcher.lightningCount); - event.left.add(PREFIX + "netColl: " + ManaNetworkHandler.instance.getAllCollectorsInWorld(world).size() + ", netPool: " + ManaNetworkHandler.instance.getAllPoolsInWorld(world).size() + ", rv: " + version); + private static final String PREFIX = EnumChatFormatting.GREEN + "[Botania] " + EnumChatFormatting.RESET; - if(GuiScreen.isCtrlKeyDown() && GuiScreen.isShiftKeyDown()) { - event.left.add(PREFIX + "Config Context"); - event.left.add(" shaders.enabled: " + ConfigHandler.useShaders); - event.left.add(" shaders.secondaryUnit: " + ConfigHandler.glSecondaryTextureUnit); + @SubscribeEvent + public void onDrawDebugText(RenderGameOverlayEvent.Text event) { + World world = Minecraft.getMinecraft().theWorld; + if (Minecraft.getMinecraft().gameSettings.showDebugInfo) { + event.left.add(null); + String version = LibMisc.VERSION; + if (version.contains("GRADLE")) version = "N/A"; - ContextCapabilities caps = GLContext.getCapabilities(); - event.left.add(PREFIX + "OpenGL Context"); - event.left.add(" GL_VERSION: " + GL11.glGetString(GL11.GL_VERSION)); - event.left.add(" GL_RENDERER: " + GL11.glGetString(GL11.GL_RENDERER)); - event.left.add(" GL_SHADING_LANGUAGE_VERSION: " + GL11.glGetString(GL20.GL_SHADING_LANGUAGE_VERSION)); - event.left.add(" GL_MAX_TEXTURE_IMAGE_UNITS_ARB: " + GL11.glGetInteger(ARBFragmentShader.GL_MAX_TEXTURE_IMAGE_UNITS_ARB)); - event.left.add(" GL_ARB_multitexture: " + caps.GL_ARB_multitexture); - event.left.add(" GL_ARB_texture_non_power_of_two: " + caps.GL_ARB_texture_non_power_of_two); - event.left.add(" OpenGL13: " + caps.OpenGL13); - } else if(Minecraft.isRunningOnMac) - event.left.add(PREFIX + "SHIFT+CMD for context"); - else event.left.add(PREFIX + "SHIFT+CTRL for context"); - } - } + event.left.add(PREFIX + "pS: " + ParticleRenderDispatcher.sparkleFxCount + ", pFS: " + + ParticleRenderDispatcher.fakeSparkleFxCount + ", pW: " + ParticleRenderDispatcher.wispFxCount + + ", pDIW: " + ParticleRenderDispatcher.depthIgnoringWispFxCount + ", pLB: " + + ParticleRenderDispatcher.lightningCount); + event.left.add(PREFIX + "netColl: " + + ManaNetworkHandler.instance.getAllCollectorsInWorld(world).size() + ", netPool: " + + ManaNetworkHandler.instance.getAllPoolsInWorld(world).size() + ", rv: " + version); + if (GuiScreen.isCtrlKeyDown() && GuiScreen.isShiftKeyDown()) { + event.left.add(PREFIX + "Config Context"); + event.left.add(" shaders.enabled: " + ConfigHandler.useShaders); + event.left.add(" shaders.secondaryUnit: " + ConfigHandler.glSecondaryTextureUnit); + ContextCapabilities caps = GLContext.getCapabilities(); + event.left.add(PREFIX + "OpenGL Context"); + event.left.add(" GL_VERSION: " + GL11.glGetString(GL11.GL_VERSION)); + event.left.add(" GL_RENDERER: " + GL11.glGetString(GL11.GL_RENDERER)); + event.left.add(" GL_SHADING_LANGUAGE_VERSION: " + GL11.glGetString(GL20.GL_SHADING_LANGUAGE_VERSION)); + event.left.add(" GL_MAX_TEXTURE_IMAGE_UNITS_ARB: " + + GL11.glGetInteger(ARBFragmentShader.GL_MAX_TEXTURE_IMAGE_UNITS_ARB)); + event.left.add(" GL_ARB_multitexture: " + caps.GL_ARB_multitexture); + event.left.add(" GL_ARB_texture_non_power_of_two: " + caps.GL_ARB_texture_non_power_of_two); + event.left.add(" OpenGL13: " + caps.OpenGL13); + } else if (Minecraft.isRunningOnMac) event.left.add(PREFIX + "SHIFT+CMD for context"); + else event.left.add(PREFIX + "SHIFT+CTRL for context"); + } + } } diff --git a/src/main/java/vazkii/botania/client/core/handler/HUDHandler.java b/src/main/java/vazkii/botania/client/core/handler/HUDHandler.java index 576ae446ee..936eb6aaf1 100644 --- a/src/main/java/vazkii/botania/client/core/handler/HUDHandler.java +++ b/src/main/java/vazkii/botania/client/core/handler/HUDHandler.java @@ -2,16 +2,19 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jan 25, 2014, 6:11:10 PM (GMT)] */ package vazkii.botania.client.core.handler; +import baubles.common.lib.PlayerHandler; +import cpw.mods.fml.common.eventhandler.EventPriority; +import cpw.mods.fml.common.eventhandler.SubscribeEvent; +import cpw.mods.fml.relauncher.ReflectionHelper; import java.awt.Color; - import net.minecraft.block.Block; import net.minecraft.block.BlockLiquid; import net.minecraft.client.Minecraft; @@ -33,10 +36,8 @@ import net.minecraft.util.StatCollector; import net.minecraftforge.client.event.RenderGameOverlayEvent; import net.minecraftforge.client.event.RenderGameOverlayEvent.ElementType; - import org.lwjgl.opengl.GL11; import org.lwjgl.opengl.GL12; - import vazkii.botania.api.BotaniaAPI; import vazkii.botania.api.lexicon.ILexicon; import vazkii.botania.api.lexicon.ILexiconable; @@ -65,423 +66,455 @@ import vazkii.botania.common.item.equipment.bauble.ItemFlightTiara; import vazkii.botania.common.item.equipment.bauble.ItemMonocle; import vazkii.botania.common.lib.LibObfuscation; -import baubles.common.lib.PlayerHandler; -import cpw.mods.fml.common.eventhandler.EventPriority; -import cpw.mods.fml.common.eventhandler.SubscribeEvent; -import cpw.mods.fml.relauncher.ReflectionHelper; public final class HUDHandler { - public static final ResourceLocation manaBar = new ResourceLocation(LibResources.GUI_MANA_HUD); - - @SubscribeEvent(priority = EventPriority.HIGHEST) - public void onDrawScreenPre(RenderGameOverlayEvent.Pre event) { - Minecraft mc = Minecraft.getMinecraft(); - Profiler profiler = mc.mcProfiler; - - if(event.type == ElementType.HEALTH) { - profiler.startSection("botania-hud"); - ItemStack amulet = PlayerHandler.getPlayerBaubles(mc.thePlayer).getStackInSlot(0); - if(amulet != null && amulet.getItem() == ModItems.flightTiara) { - profiler.startSection("flugelTiara"); - ItemFlightTiara.renderHUD(event.resolution, mc.thePlayer, amulet); - profiler.endSection(); - } - profiler.endSection(); - } - } - - @SubscribeEvent - public void onDrawScreenPost(RenderGameOverlayEvent.Post event) { - Minecraft mc = Minecraft.getMinecraft(); - Profiler profiler = mc.mcProfiler; - ItemStack equippedStack = mc.thePlayer.getCurrentEquippedItem(); - - if(event.type == ElementType.ALL) { - profiler.startSection("botania-hud"); - MovingObjectPosition pos = mc.objectMouseOver; - - if(pos != null) { - Block block = mc.theWorld.getBlock(pos.blockX, pos.blockY, pos.blockZ); - TileEntity tile = mc.theWorld.getTileEntity(pos.blockX, pos.blockY, pos.blockZ); - - if(equippedStack != null) { - if(pos != null && equippedStack.getItem() == ModItems.twigWand) { - renderWandModeDisplay(event.resolution); - - if(block instanceof IWandHUD) { - profiler.startSection("wandItem"); - ((IWandHUD) block).renderHUD(mc, event.resolution, mc.theWorld, pos.blockX, pos.blockY, pos.blockZ); - profiler.endSection(); - } - } else if(pos != null && equippedStack.getItem() instanceof ILexicon) - drawLexiconHUD(mc.thePlayer.getCurrentEquippedItem(), block, pos, event.resolution); - if(tile != null && tile instanceof TilePool) - renderPoolRecipeHUD(event.resolution, (TilePool) tile, equippedStack); - } - if(tile != null && tile instanceof TileAltar) - ((TileAltar) tile).renderHUD(mc, event.resolution); - else if(tile != null && tile instanceof TileRuneAltar) - ((TileRuneAltar) tile).renderHUD(mc, event.resolution); - - if(tile != null && tile instanceof TileCorporeaCrystalCube) - renderCrystalCubeHUD(event.resolution, (TileCorporeaCrystalCube) tile); - } - - if(!TileCorporeaIndex.getInputHandler().getNearbyIndexes(mc.thePlayer).isEmpty() && mc.currentScreen != null && mc.currentScreen instanceof GuiChat) { - profiler.startSection("nearIndex"); - renderNearIndexDisplay(event.resolution); - profiler.endSection(); - } - - if(MultiblockRenderHandler.currentMultiblock != null && MultiblockRenderHandler.anchor == null) { - profiler.startSection("multiblockRightClick"); - String s = StatCollector.translateToLocal("botaniamisc.rightClickToAnchor"); - mc.fontRenderer.drawStringWithShadow(s, event.resolution.getScaledWidth() / 2 - mc.fontRenderer.getStringWidth(s) / 2, event.resolution.getScaledHeight() / 2 - 30, 0xFFFFFF); - profiler.endSection(); - } - - if(equippedStack != null && equippedStack.getItem() instanceof ItemCraftingHalo) { - profiler.startSection("craftingHalo"); - ItemCraftingHalo.renderHUD(event.resolution, mc.thePlayer, equippedStack); - profiler.endSection(); - } - - if(equippedStack != null && equippedStack.getItem() instanceof ItemSextant) { - profiler.startSection("sextant"); - ItemSextant.renderHUD(event.resolution, mc.thePlayer, equippedStack); - profiler.endSection(); - } - - /*if(equippedStack != null && equippedStack.getItem() == ModItems.flugelEye) { - profiler.startSection("flugelEye"); - ItemFlugelEye.renderHUD(event.resolution, mc.thePlayer, equippedStack); - profiler.endSection(); - }*/ - - if(Botania.proxy.isClientPlayerWearingMonocle()) { - profiler.startSection("monocle"); - ItemMonocle.renderHUD(event.resolution, mc.thePlayer); - profiler.endSection(); - } - - profiler.startSection("manaBar"); - EntityPlayer player = mc.thePlayer; - int totalMana = 0; - int totalMaxMana = 0; - boolean anyRequest = false; - boolean creative = false; - - IInventory mainInv = player.inventory; - IInventory baublesInv = PlayerHandler.getPlayerBaubles(player); - - int invSize = mainInv.getSizeInventory(); - int size = invSize; - if(baublesInv != null) - size += baublesInv.getSizeInventory(); - - for(int i = 0; i < size; i++) { - boolean useBaubles = i >= invSize; - IInventory inv = useBaubles ? baublesInv : mainInv; - ItemStack stack = inv.getStackInSlot(i - (useBaubles ? invSize : 0)); - - if(stack != null) { - Item item = stack.getItem(); - if(item instanceof IManaUsingItem) - anyRequest = anyRequest || ((IManaUsingItem) item).usesMana(stack); - - if(item instanceof IManaItem) { - if(!((IManaItem) item).isNoExport(stack)) { - totalMana += ((IManaItem) item).getMana(stack); - totalMaxMana += ((IManaItem) item).getMaxMana(stack); - } - } - - if(item instanceof ICreativeManaProvider && ((ICreativeManaProvider) item).isCreative(stack)) - creative = true; - } - } - - if(anyRequest) - renderManaInvBar(event.resolution, creative, totalMana, totalMaxMana); - - profiler.endStartSection("bossBar"); - BossBarHandler.render(event.resolution); - profiler.endStartSection("itemsRemaining"); - ItemsRemainingRenderHandler.render(event.resolution, event.partialTicks); - profiler.endSection(); - profiler.endSection(); - - GL11.glColor4f(1F, 1F, 1F, 1F); - } - } - - private void renderWandModeDisplay(ScaledResolution res) { - Minecraft mc = Minecraft.getMinecraft(); - Profiler profiler = mc.mcProfiler; - - profiler.startSection("wandMode"); - int ticks = ReflectionHelper.getPrivateValue(GuiIngame.class, mc.ingameGUI, LibObfuscation.REMAINING_HIGHLIGHT_TICKS); - ticks -= 15; - if(ticks > 0) { - int alpha = Math.min(255, (int) (ticks * 256.0F / 10.0F)); - int color = 0x00CC00 + (alpha << 24); - String disp = StatCollector.translateToLocal(ItemTwigWand.getModeString(mc.thePlayer.getCurrentEquippedItem())); - - int x = res.getScaledWidth() / 2 - mc.fontRenderer.getStringWidth(disp) / 2; - int y = res.getScaledHeight() - 70; - - GL11.glEnable(GL11.GL_BLEND); - GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); - mc.fontRenderer.drawStringWithShadow(disp, x, y, color); - GL11.glDisable(GL11.GL_BLEND); - } - profiler.endSection(); - } - - private void renderManaInvBar(ScaledResolution res, boolean hasCreative, int totalMana, int totalMaxMana) { - Minecraft mc = Minecraft.getMinecraft(); - int width = 182; - int x = res.getScaledWidth() / 2 - width / 2; - int y = res.getScaledHeight() - ConfigHandler.manaBarHeight; - - if(!hasCreative) { - if(totalMaxMana == 0) - width = 0; - else width *= (double) totalMana / (double) totalMaxMana; - } - - if(width == 0) { - if(totalMana > 0) - width = 1; - else return; - } - - Color color = new Color(Color.HSBtoRGB(0.55F, (float) Math.min(1F, Math.sin(System.currentTimeMillis() / 200D) * 0.5 + 1F), 1F)); - GL11.glColor4ub((byte) color.getRed(), (byte) color.getGreen(), (byte) color.getBlue(), (byte) (255 - color.getRed())); - mc.renderEngine.bindTexture(manaBar); - - GL11.glEnable(GL11.GL_BLEND); - GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); - RenderHelper.drawTexturedModalRect(x, y, 0, 0, 251, width, 5); - GL11.glDisable(GL11.GL_BLEND); - } - - private void renderPoolRecipeHUD(ScaledResolution res, TilePool tile, ItemStack stack) { - Minecraft mc = Minecraft.getMinecraft(); - Profiler profiler = mc.mcProfiler; - - profiler.startSection("poolRecipe"); - for(RecipeManaInfusion recipe : BotaniaAPI.manaInfusionRecipes) { - if(recipe.matches(stack)) { - if((!recipe.isAlchemy() || tile.alchemy) && (!recipe.isConjuration() || tile.conjuration)) { - int x = res.getScaledWidth() / 2 - 11; - int y = res.getScaledHeight() / 2 + 10; - - int u = tile.getCurrentMana() >= recipe.getManaToConsume() ? 0 : 22; - int v = mc.thePlayer.getCommandSenderName().equals("haighyorkie") && mc.thePlayer.isSneaking() ? 23 : 8; - - GL11.glEnable(GL11.GL_BLEND); - GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); - - mc.renderEngine.bindTexture(manaBar); - RenderHelper.drawTexturedModalRect(x, y, 0, u, v, 22, 15); - GL11.glColor4f(1F, 1F, 1F, 1F); - - net.minecraft.client.renderer.RenderHelper.enableGUIStandardItemLighting(); - RenderItem.getInstance().renderItemAndEffectIntoGUI(mc.fontRenderer, mc.renderEngine, stack, x - 20, y); - RenderItem.getInstance().renderItemAndEffectIntoGUI(mc.fontRenderer, mc.renderEngine, recipe.getOutput(), x + 26, y); - RenderItem.getInstance().renderItemOverlayIntoGUI(mc.fontRenderer, mc.renderEngine, recipe.getOutput(), x + 26, y); - net.minecraft.client.renderer.RenderHelper.disableStandardItemLighting(); - - GL11.glDisable(GL11.GL_LIGHTING); - GL11.glDisable(GL11.GL_BLEND); - - break; - } - } - } - profiler.endSection(); - } - - private void renderCrystalCubeHUD(ScaledResolution res, TileCorporeaCrystalCube tile) { - Minecraft mc = Minecraft.getMinecraft(); - Profiler profiler = mc.mcProfiler; - - profiler.startSection("crystalCube"); - ItemStack target = tile.getRequestTarget(); - if(target != null) { - String s1 = target.getDisplayName(); - String s2 = tile.getItemCount() + "x"; - int strlen = Math.max(mc.fontRenderer.getStringWidth(s1), mc.fontRenderer.getStringWidth(s2)); - int w = res.getScaledWidth(); - int h = res.getScaledHeight(); - Gui.drawRect(w / 2 + 8, h / 2 - 12, w / 2 + strlen + 32, h / 2 + 10, 0x44000000); - Gui.drawRect(w / 2 + 6, h / 2 - 14, w / 2 + strlen + 34, h / 2 + 12, 0x44000000); - - mc.fontRenderer.drawStringWithShadow(target.getDisplayName(), w / 2 + 30, h / 2 - 10, 0x6666FF); - mc.fontRenderer.drawStringWithShadow(tile.getItemCount() + "x", w / 2 + 30, h / 2, 0xFFFFFF); - net.minecraft.client.renderer.RenderHelper.enableGUIStandardItemLighting(); - GL11.glEnable(GL12.GL_RESCALE_NORMAL); - RenderItem.getInstance().renderItemAndEffectIntoGUI(mc.fontRenderer, mc.renderEngine, target, w / 2 + 10, h / 2 - 10); - net.minecraft.client.renderer.RenderHelper.disableStandardItemLighting(); - } - - profiler.endSection(); - } - - private void drawLexiconHUD(ItemStack stack, Block block, MovingObjectPosition pos, ScaledResolution res) { - Minecraft mc = Minecraft.getMinecraft(); - Profiler profiler = mc.mcProfiler; - - profiler.startSection("lexicon"); - FontRenderer font = mc.fontRenderer; - boolean draw = false; - String drawStr = ""; - String secondLine = ""; - - GL11.glEnable(GL11.GL_BLEND); - GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); - int sx = res.getScaledWidth() / 2 - 17; - int sy = res.getScaledHeight() / 2 + 2; - - if(block instanceof ILexiconable) { - LexiconEntry entry = ((ILexiconable) block).getEntry(mc.theWorld, pos.blockX, pos.blockY, pos.blockZ, mc.thePlayer, mc.thePlayer.getCurrentEquippedItem()); - if(entry != null) { - if(!((ILexicon) stack.getItem()).isKnowledgeUnlocked(stack, entry.getKnowledgeType())) - font = mc.standardGalacticFontRenderer; - - drawStr = StatCollector.translateToLocal(entry.getUnlocalizedName()); - secondLine = EnumChatFormatting.ITALIC + StatCollector.translateToLocal(entry.getTagline()); - draw = true; - } - } - - if(!draw && pos.entityHit == null) { - profiler.startSection("wikiLookup"); - if(!block.isAir(mc.theWorld, pos.blockX, pos.blockY, pos.blockZ) && !(block instanceof BlockLiquid)) { - IWikiProvider provider = WikiHooks.getWikiFor(block); - String url = provider.getWikiURL(mc.theWorld, pos); - if(url != null && !url.isEmpty()) { - String name = provider.getBlockName(mc.theWorld, pos); - String wikiName = provider.getWikiName(mc.theWorld, pos); - drawStr = name + " @ " + EnumChatFormatting.AQUA + wikiName; - draw = true; - } - } - profiler.endSection(); - } - - if(draw) { - if(!mc.thePlayer.isSneaking()) { - drawStr = "?"; - secondLine = ""; - font = mc.fontRenderer; - } - - RenderItem.getInstance().renderItemIntoGUI(mc.fontRenderer, mc.renderEngine, new ItemStack(ModItems.lexicon), sx, sy); - GL11.glDisable(GL11.GL_LIGHTING); - font.drawStringWithShadow(drawStr, sx + 10, sy + 8, 0xFFFFFFFF); - font.drawStringWithShadow(secondLine, sx + 10, sy + 18, 0xFFAAAAAA); - - if(!mc.thePlayer.isSneaking()) { - GL11.glScalef(0.5F, 0.5F, 1F); - mc.fontRenderer.drawStringWithShadow(EnumChatFormatting.BOLD + "Shift", (sx + 10) * 2 - 16, (sy + 8) * 2 + 20, 0xFFFFFFFF); - GL11.glScalef(2F, 2F, 1F); - } - } - - GL11.glDisable(GL11.GL_BLEND); - GL11.glColor4f(1F, 1F, 1F, 1F); - profiler.endSection(); - } - - private void renderNearIndexDisplay(ScaledResolution res) { - Minecraft mc = Minecraft.getMinecraft(); - String txt0 = StatCollector.translateToLocal("botaniamisc.nearIndex0"); - String txt1 = EnumChatFormatting.GRAY + StatCollector.translateToLocal("botaniamisc.nearIndex1"); - String txt2 = EnumChatFormatting.GRAY + StatCollector.translateToLocal("botaniamisc.nearIndex2"); - - int l = Math.max(mc.fontRenderer.getStringWidth(txt0), Math.max(mc.fontRenderer.getStringWidth(txt1), mc.fontRenderer.getStringWidth(txt2))) + 20; - int x = res.getScaledWidth() - l - 20; - int y = res.getScaledHeight() - 60; - - Gui.drawRect(x - 6, y - 6, x + l + 6, y + 37, 0x44000000); - Gui.drawRect(x - 4, y - 4, x + l + 4, y + 35, 0x44000000); - net.minecraft.client.renderer.RenderHelper.enableGUIStandardItemLighting(); - GL11.glEnable(GL12.GL_RESCALE_NORMAL); - RenderItem.getInstance().renderItemAndEffectIntoGUI(mc.fontRenderer, mc.renderEngine, new ItemStack(ModBlocks.corporeaIndex), x, y + 10); - net.minecraft.client.renderer.RenderHelper.disableStandardItemLighting(); - - mc.fontRenderer.drawStringWithShadow(txt0, x + 20, y, 0xFFFFFF); - mc.fontRenderer.drawStringWithShadow(txt1, x + 20, y + 14, 0xFFFFFF); - mc.fontRenderer.drawStringWithShadow(txt2, x + 20, y + 24, 0xFFFFFF); - } - - public static void drawSimpleManaHUD(int color, int mana, int maxMana, String name, ScaledResolution res) { - GL11.glEnable(GL11.GL_BLEND); - GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); - Minecraft mc = Minecraft.getMinecraft(); - int x = res.getScaledWidth() / 2 - mc.fontRenderer.getStringWidth(name) / 2; - int y = res.getScaledHeight() / 2 + 10; - - mc.fontRenderer.drawStringWithShadow(name, x, y, color); - - x = res.getScaledWidth() / 2 - 51; - y += 10; - - renderManaBar(x, y, color, mana < 0 ? 0.5F : 1F, mana, maxMana); - - if(mana < 0) { - String text = StatCollector.translateToLocal("botaniamisc.statusUnknown"); - x = res.getScaledWidth() / 2 - mc.fontRenderer.getStringWidth(text) / 2; - y -= 1; - mc.fontRenderer.drawString(text, x, y, color); - } - - GL11.glDisable(GL11.GL_BLEND); - } - - public static void drawComplexManaHUD(int color, int mana, int maxMana, String name, ScaledResolution res, ItemStack bindDisplay, boolean properlyBound) { - drawSimpleManaHUD(color, mana, maxMana, name, res); - - Minecraft mc = Minecraft.getMinecraft(); - - int x = res.getScaledWidth() / 2 + 55; - int y = res.getScaledHeight() / 2 + 12; - - net.minecraft.client.renderer.RenderHelper.enableGUIStandardItemLighting(); - GL11.glEnable(GL12.GL_RESCALE_NORMAL); - RenderItem.getInstance().renderItemAndEffectIntoGUI(mc.fontRenderer, mc.renderEngine, bindDisplay, x, y); - net.minecraft.client.renderer.RenderHelper.disableStandardItemLighting(); - - GL11.glDisable(GL11.GL_DEPTH_TEST); - if(properlyBound) { - mc.fontRenderer.drawStringWithShadow("\u2714", x + 10, y + 9, 0x004C00); - mc.fontRenderer.drawStringWithShadow("\u2714", x + 10, y + 8, 0x0BD20D); - } else { - mc.fontRenderer.drawStringWithShadow("\u2718", x + 10, y + 9, 0x4C0000); - mc.fontRenderer.drawStringWithShadow("\u2718", x + 10, y + 8, 0xD2080D); - } - GL11.glEnable(GL11.GL_DEPTH_TEST); - } - - public static void renderManaBar(int x, int y, int color, float alpha, int mana, int maxMana) { - Minecraft mc = Minecraft.getMinecraft(); - - GL11.glColor4f(1F, 1F, 1F, alpha); - mc.renderEngine.bindTexture(manaBar); - RenderHelper.drawTexturedModalRect(x, y, 0, 0, 0, 102, 5); - - int manaPercentage = Math.max(0, (int) ((double) mana / (double) maxMana * 100)); - - if(manaPercentage == 0 && mana > 0) - manaPercentage = 1; - - RenderHelper.drawTexturedModalRect(x + 1, y + 1, 0, 0, 5, 100, 3); - - Color color_ = new Color(color); - GL11.glColor4ub((byte) color_.getRed(), (byte) color_.getGreen(),(byte) color_.getBlue(), (byte) (255F * alpha)); - RenderHelper.drawTexturedModalRect(x + 1, y + 1, 0, 0, 5, Math.min(100, manaPercentage), 3); - } + public static final ResourceLocation manaBar = new ResourceLocation(LibResources.GUI_MANA_HUD); + + @SubscribeEvent(priority = EventPriority.HIGHEST) + public void onDrawScreenPre(RenderGameOverlayEvent.Pre event) { + Minecraft mc = Minecraft.getMinecraft(); + Profiler profiler = mc.mcProfiler; + + if (event.type == ElementType.HEALTH) { + profiler.startSection("botania-hud"); + ItemStack amulet = PlayerHandler.getPlayerBaubles(mc.thePlayer).getStackInSlot(0); + if (amulet != null && amulet.getItem() == ModItems.flightTiara) { + profiler.startSection("flugelTiara"); + ItemFlightTiara.renderHUD(event.resolution, mc.thePlayer, amulet); + profiler.endSection(); + } + profiler.endSection(); + } + } + + @SubscribeEvent + public void onDrawScreenPost(RenderGameOverlayEvent.Post event) { + Minecraft mc = Minecraft.getMinecraft(); + Profiler profiler = mc.mcProfiler; + ItemStack equippedStack = mc.thePlayer.getCurrentEquippedItem(); + + if (event.type == ElementType.ALL) { + profiler.startSection("botania-hud"); + MovingObjectPosition pos = mc.objectMouseOver; + + if (pos != null) { + Block block = mc.theWorld.getBlock(pos.blockX, pos.blockY, pos.blockZ); + TileEntity tile = mc.theWorld.getTileEntity(pos.blockX, pos.blockY, pos.blockZ); + + if (equippedStack != null) { + if (pos != null && equippedStack.getItem() == ModItems.twigWand) { + renderWandModeDisplay(event.resolution); + + if (block instanceof IWandHUD) { + profiler.startSection("wandItem"); + ((IWandHUD) block) + .renderHUD(mc, event.resolution, mc.theWorld, pos.blockX, pos.blockY, pos.blockZ); + profiler.endSection(); + } + } else if (pos != null && equippedStack.getItem() instanceof ILexicon) + drawLexiconHUD(mc.thePlayer.getCurrentEquippedItem(), block, pos, event.resolution); + if (tile != null && tile instanceof TilePool) + renderPoolRecipeHUD(event.resolution, (TilePool) tile, equippedStack); + } + if (tile != null && tile instanceof TileAltar) ((TileAltar) tile).renderHUD(mc, event.resolution); + else if (tile != null && tile instanceof TileRuneAltar) + ((TileRuneAltar) tile).renderHUD(mc, event.resolution); + + if (tile != null && tile instanceof TileCorporeaCrystalCube) + renderCrystalCubeHUD(event.resolution, (TileCorporeaCrystalCube) tile); + } + + if (!TileCorporeaIndex.getInputHandler() + .getNearbyIndexes(mc.thePlayer) + .isEmpty() + && mc.currentScreen != null + && mc.currentScreen instanceof GuiChat) { + profiler.startSection("nearIndex"); + renderNearIndexDisplay(event.resolution); + profiler.endSection(); + } + + if (MultiblockRenderHandler.currentMultiblock != null && MultiblockRenderHandler.anchor == null) { + profiler.startSection("multiblockRightClick"); + String s = StatCollector.translateToLocal("botaniamisc.rightClickToAnchor"); + mc.fontRenderer.drawStringWithShadow( + s, + event.resolution.getScaledWidth() / 2 - mc.fontRenderer.getStringWidth(s) / 2, + event.resolution.getScaledHeight() / 2 - 30, + 0xFFFFFF); + profiler.endSection(); + } + + if (equippedStack != null && equippedStack.getItem() instanceof ItemCraftingHalo) { + profiler.startSection("craftingHalo"); + ItemCraftingHalo.renderHUD(event.resolution, mc.thePlayer, equippedStack); + profiler.endSection(); + } + + if (equippedStack != null && equippedStack.getItem() instanceof ItemSextant) { + profiler.startSection("sextant"); + ItemSextant.renderHUD(event.resolution, mc.thePlayer, equippedStack); + profiler.endSection(); + } + + /*if(equippedStack != null && equippedStack.getItem() == ModItems.flugelEye) { + profiler.startSection("flugelEye"); + ItemFlugelEye.renderHUD(event.resolution, mc.thePlayer, equippedStack); + profiler.endSection(); + }*/ + + if (Botania.proxy.isClientPlayerWearingMonocle()) { + profiler.startSection("monocle"); + ItemMonocle.renderHUD(event.resolution, mc.thePlayer); + profiler.endSection(); + } + + profiler.startSection("manaBar"); + EntityPlayer player = mc.thePlayer; + int totalMana = 0; + int totalMaxMana = 0; + boolean anyRequest = false; + boolean creative = false; + + IInventory mainInv = player.inventory; + IInventory baublesInv = PlayerHandler.getPlayerBaubles(player); + + int invSize = mainInv.getSizeInventory(); + int size = invSize; + if (baublesInv != null) size += baublesInv.getSizeInventory(); + + for (int i = 0; i < size; i++) { + boolean useBaubles = i >= invSize; + IInventory inv = useBaubles ? baublesInv : mainInv; + ItemStack stack = inv.getStackInSlot(i - (useBaubles ? invSize : 0)); + + if (stack != null) { + Item item = stack.getItem(); + if (item instanceof IManaUsingItem) + anyRequest = anyRequest || ((IManaUsingItem) item).usesMana(stack); + + if (item instanceof IManaItem) { + if (!((IManaItem) item).isNoExport(stack)) { + totalMana += ((IManaItem) item).getMana(stack); + totalMaxMana += ((IManaItem) item).getMaxMana(stack); + } + } + + if (item instanceof ICreativeManaProvider && ((ICreativeManaProvider) item).isCreative(stack)) + creative = true; + } + } + + if (anyRequest) renderManaInvBar(event.resolution, creative, totalMana, totalMaxMana); + + profiler.endStartSection("bossBar"); + BossBarHandler.render(event.resolution); + profiler.endStartSection("itemsRemaining"); + ItemsRemainingRenderHandler.render(event.resolution, event.partialTicks); + profiler.endSection(); + profiler.endSection(); + + GL11.glColor4f(1F, 1F, 1F, 1F); + } + } + + private void renderWandModeDisplay(ScaledResolution res) { + Minecraft mc = Minecraft.getMinecraft(); + Profiler profiler = mc.mcProfiler; + + profiler.startSection("wandMode"); + int ticks = ReflectionHelper.getPrivateValue( + GuiIngame.class, mc.ingameGUI, LibObfuscation.REMAINING_HIGHLIGHT_TICKS); + ticks -= 15; + if (ticks > 0) { + int alpha = Math.min(255, (int) (ticks * 256.0F / 10.0F)); + int color = 0x00CC00 + (alpha << 24); + String disp = + StatCollector.translateToLocal(ItemTwigWand.getModeString(mc.thePlayer.getCurrentEquippedItem())); + + int x = res.getScaledWidth() / 2 - mc.fontRenderer.getStringWidth(disp) / 2; + int y = res.getScaledHeight() - 70; + + GL11.glEnable(GL11.GL_BLEND); + GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); + mc.fontRenderer.drawStringWithShadow(disp, x, y, color); + GL11.glDisable(GL11.GL_BLEND); + } + profiler.endSection(); + } + + private void renderManaInvBar(ScaledResolution res, boolean hasCreative, int totalMana, int totalMaxMana) { + Minecraft mc = Minecraft.getMinecraft(); + int width = 182; + int x = res.getScaledWidth() / 2 - width / 2; + int y = res.getScaledHeight() - ConfigHandler.manaBarHeight; + + if (!hasCreative) { + if (totalMaxMana == 0) width = 0; + else width *= (double) totalMana / (double) totalMaxMana; + } + + if (width == 0) { + if (totalMana > 0) width = 1; + else return; + } + + Color color = new Color(Color.HSBtoRGB( + 0.55F, (float) Math.min(1F, Math.sin(System.currentTimeMillis() / 200D) * 0.5 + 1F), 1F)); + GL11.glColor4ub( + (byte) color.getRed(), (byte) color.getGreen(), (byte) color.getBlue(), (byte) (255 - color.getRed())); + mc.renderEngine.bindTexture(manaBar); + + GL11.glEnable(GL11.GL_BLEND); + GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); + RenderHelper.drawTexturedModalRect(x, y, 0, 0, 251, width, 5); + GL11.glDisable(GL11.GL_BLEND); + } + + private void renderPoolRecipeHUD(ScaledResolution res, TilePool tile, ItemStack stack) { + Minecraft mc = Minecraft.getMinecraft(); + Profiler profiler = mc.mcProfiler; + + profiler.startSection("poolRecipe"); + for (RecipeManaInfusion recipe : BotaniaAPI.manaInfusionRecipes) { + if (recipe.matches(stack)) { + if ((!recipe.isAlchemy() || tile.alchemy) && (!recipe.isConjuration() || tile.conjuration)) { + int x = res.getScaledWidth() / 2 - 11; + int y = res.getScaledHeight() / 2 + 10; + + int u = tile.getCurrentMana() >= recipe.getManaToConsume() ? 0 : 22; + int v = mc.thePlayer.getCommandSenderName().equals("haighyorkie") && mc.thePlayer.isSneaking() + ? 23 + : 8; + + GL11.glEnable(GL11.GL_BLEND); + GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); + + mc.renderEngine.bindTexture(manaBar); + RenderHelper.drawTexturedModalRect(x, y, 0, u, v, 22, 15); + GL11.glColor4f(1F, 1F, 1F, 1F); + + net.minecraft.client.renderer.RenderHelper.enableGUIStandardItemLighting(); + RenderItem.getInstance() + .renderItemAndEffectIntoGUI(mc.fontRenderer, mc.renderEngine, stack, x - 20, y); + RenderItem.getInstance() + .renderItemAndEffectIntoGUI( + mc.fontRenderer, mc.renderEngine, recipe.getOutput(), x + 26, y); + RenderItem.getInstance() + .renderItemOverlayIntoGUI(mc.fontRenderer, mc.renderEngine, recipe.getOutput(), x + 26, y); + net.minecraft.client.renderer.RenderHelper.disableStandardItemLighting(); + + GL11.glDisable(GL11.GL_LIGHTING); + GL11.glDisable(GL11.GL_BLEND); + + break; + } + } + } + profiler.endSection(); + } + + private void renderCrystalCubeHUD(ScaledResolution res, TileCorporeaCrystalCube tile) { + Minecraft mc = Minecraft.getMinecraft(); + Profiler profiler = mc.mcProfiler; + + profiler.startSection("crystalCube"); + ItemStack target = tile.getRequestTarget(); + if (target != null) { + String s1 = target.getDisplayName(); + String s2 = tile.getItemCount() + "x"; + int strlen = Math.max(mc.fontRenderer.getStringWidth(s1), mc.fontRenderer.getStringWidth(s2)); + int w = res.getScaledWidth(); + int h = res.getScaledHeight(); + Gui.drawRect(w / 2 + 8, h / 2 - 12, w / 2 + strlen + 32, h / 2 + 10, 0x44000000); + Gui.drawRect(w / 2 + 6, h / 2 - 14, w / 2 + strlen + 34, h / 2 + 12, 0x44000000); + + mc.fontRenderer.drawStringWithShadow(target.getDisplayName(), w / 2 + 30, h / 2 - 10, 0x6666FF); + mc.fontRenderer.drawStringWithShadow(tile.getItemCount() + "x", w / 2 + 30, h / 2, 0xFFFFFF); + net.minecraft.client.renderer.RenderHelper.enableGUIStandardItemLighting(); + GL11.glEnable(GL12.GL_RESCALE_NORMAL); + RenderItem.getInstance() + .renderItemAndEffectIntoGUI(mc.fontRenderer, mc.renderEngine, target, w / 2 + 10, h / 2 - 10); + net.minecraft.client.renderer.RenderHelper.disableStandardItemLighting(); + } + + profiler.endSection(); + } + + private void drawLexiconHUD(ItemStack stack, Block block, MovingObjectPosition pos, ScaledResolution res) { + Minecraft mc = Minecraft.getMinecraft(); + Profiler profiler = mc.mcProfiler; + + profiler.startSection("lexicon"); + FontRenderer font = mc.fontRenderer; + boolean draw = false; + String drawStr = ""; + String secondLine = ""; + + GL11.glEnable(GL11.GL_BLEND); + GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); + int sx = res.getScaledWidth() / 2 - 17; + int sy = res.getScaledHeight() / 2 + 2; + + if (block instanceof ILexiconable) { + LexiconEntry entry = ((ILexiconable) block) + .getEntry( + mc.theWorld, + pos.blockX, + pos.blockY, + pos.blockZ, + mc.thePlayer, + mc.thePlayer.getCurrentEquippedItem()); + if (entry != null) { + if (!((ILexicon) stack.getItem()).isKnowledgeUnlocked(stack, entry.getKnowledgeType())) + font = mc.standardGalacticFontRenderer; + + drawStr = StatCollector.translateToLocal(entry.getUnlocalizedName()); + secondLine = EnumChatFormatting.ITALIC + StatCollector.translateToLocal(entry.getTagline()); + draw = true; + } + } + + if (!draw && pos.entityHit == null) { + profiler.startSection("wikiLookup"); + if (!block.isAir(mc.theWorld, pos.blockX, pos.blockY, pos.blockZ) && !(block instanceof BlockLiquid)) { + IWikiProvider provider = WikiHooks.getWikiFor(block); + String url = provider.getWikiURL(mc.theWorld, pos); + if (url != null && !url.isEmpty()) { + String name = provider.getBlockName(mc.theWorld, pos); + String wikiName = provider.getWikiName(mc.theWorld, pos); + drawStr = name + " @ " + EnumChatFormatting.AQUA + wikiName; + draw = true; + } + } + profiler.endSection(); + } + + if (draw) { + if (!mc.thePlayer.isSneaking()) { + drawStr = "?"; + secondLine = ""; + font = mc.fontRenderer; + } + + RenderItem.getInstance() + .renderItemIntoGUI(mc.fontRenderer, mc.renderEngine, new ItemStack(ModItems.lexicon), sx, sy); + GL11.glDisable(GL11.GL_LIGHTING); + font.drawStringWithShadow(drawStr, sx + 10, sy + 8, 0xFFFFFFFF); + font.drawStringWithShadow(secondLine, sx + 10, sy + 18, 0xFFAAAAAA); + + if (!mc.thePlayer.isSneaking()) { + GL11.glScalef(0.5F, 0.5F, 1F); + mc.fontRenderer.drawStringWithShadow( + EnumChatFormatting.BOLD + "Shift", (sx + 10) * 2 - 16, (sy + 8) * 2 + 20, 0xFFFFFFFF); + GL11.glScalef(2F, 2F, 1F); + } + } + + GL11.glDisable(GL11.GL_BLEND); + GL11.glColor4f(1F, 1F, 1F, 1F); + profiler.endSection(); + } + + private void renderNearIndexDisplay(ScaledResolution res) { + Minecraft mc = Minecraft.getMinecraft(); + String txt0 = StatCollector.translateToLocal("botaniamisc.nearIndex0"); + String txt1 = EnumChatFormatting.GRAY + StatCollector.translateToLocal("botaniamisc.nearIndex1"); + String txt2 = EnumChatFormatting.GRAY + StatCollector.translateToLocal("botaniamisc.nearIndex2"); + + int l = Math.max( + mc.fontRenderer.getStringWidth(txt0), + Math.max(mc.fontRenderer.getStringWidth(txt1), mc.fontRenderer.getStringWidth(txt2))) + + 20; + int x = res.getScaledWidth() - l - 20; + int y = res.getScaledHeight() - 60; + + Gui.drawRect(x - 6, y - 6, x + l + 6, y + 37, 0x44000000); + Gui.drawRect(x - 4, y - 4, x + l + 4, y + 35, 0x44000000); + net.minecraft.client.renderer.RenderHelper.enableGUIStandardItemLighting(); + GL11.glEnable(GL12.GL_RESCALE_NORMAL); + RenderItem.getInstance() + .renderItemAndEffectIntoGUI( + mc.fontRenderer, mc.renderEngine, new ItemStack(ModBlocks.corporeaIndex), x, y + 10); + net.minecraft.client.renderer.RenderHelper.disableStandardItemLighting(); + + mc.fontRenderer.drawStringWithShadow(txt0, x + 20, y, 0xFFFFFF); + mc.fontRenderer.drawStringWithShadow(txt1, x + 20, y + 14, 0xFFFFFF); + mc.fontRenderer.drawStringWithShadow(txt2, x + 20, y + 24, 0xFFFFFF); + } + + public static void drawSimpleManaHUD(int color, int mana, int maxMana, String name, ScaledResolution res) { + GL11.glEnable(GL11.GL_BLEND); + GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); + Minecraft mc = Minecraft.getMinecraft(); + int x = res.getScaledWidth() / 2 - mc.fontRenderer.getStringWidth(name) / 2; + int y = res.getScaledHeight() / 2 + 10; + + mc.fontRenderer.drawStringWithShadow(name, x, y, color); + + x = res.getScaledWidth() / 2 - 51; + y += 10; + + renderManaBar(x, y, color, mana < 0 ? 0.5F : 1F, mana, maxMana); + + if (mana < 0) { + String text = StatCollector.translateToLocal("botaniamisc.statusUnknown"); + x = res.getScaledWidth() / 2 - mc.fontRenderer.getStringWidth(text) / 2; + y -= 1; + mc.fontRenderer.drawString(text, x, y, color); + } + + GL11.glDisable(GL11.GL_BLEND); + } + + public static void drawComplexManaHUD( + int color, + int mana, + int maxMana, + String name, + ScaledResolution res, + ItemStack bindDisplay, + boolean properlyBound) { + drawSimpleManaHUD(color, mana, maxMana, name, res); + + Minecraft mc = Minecraft.getMinecraft(); + + int x = res.getScaledWidth() / 2 + 55; + int y = res.getScaledHeight() / 2 + 12; + + net.minecraft.client.renderer.RenderHelper.enableGUIStandardItemLighting(); + GL11.glEnable(GL12.GL_RESCALE_NORMAL); + RenderItem.getInstance().renderItemAndEffectIntoGUI(mc.fontRenderer, mc.renderEngine, bindDisplay, x, y); + net.minecraft.client.renderer.RenderHelper.disableStandardItemLighting(); + + GL11.glDisable(GL11.GL_DEPTH_TEST); + if (properlyBound) { + mc.fontRenderer.drawStringWithShadow("\u2714", x + 10, y + 9, 0x004C00); + mc.fontRenderer.drawStringWithShadow("\u2714", x + 10, y + 8, 0x0BD20D); + } else { + mc.fontRenderer.drawStringWithShadow("\u2718", x + 10, y + 9, 0x4C0000); + mc.fontRenderer.drawStringWithShadow("\u2718", x + 10, y + 8, 0xD2080D); + } + GL11.glEnable(GL11.GL_DEPTH_TEST); + } + + public static void renderManaBar(int x, int y, int color, float alpha, int mana, int maxMana) { + Minecraft mc = Minecraft.getMinecraft(); + + GL11.glColor4f(1F, 1F, 1F, alpha); + mc.renderEngine.bindTexture(manaBar); + RenderHelper.drawTexturedModalRect(x, y, 0, 0, 0, 102, 5); + + int manaPercentage = Math.max(0, (int) ((double) mana / (double) maxMana * 100)); + + if (manaPercentage == 0 && mana > 0) manaPercentage = 1; + + RenderHelper.drawTexturedModalRect(x + 1, y + 1, 0, 0, 5, 100, 3); + + Color color_ = new Color(color); + GL11.glColor4ub( + (byte) color_.getRed(), (byte) color_.getGreen(), (byte) color_.getBlue(), (byte) (255F * alpha)); + RenderHelper.drawTexturedModalRect(x + 1, y + 1, 0, 0, 5, Math.min(100, manaPercentage), 3); + } } diff --git a/src/main/java/vazkii/botania/client/core/handler/ItemsRemainingRenderHandler.java b/src/main/java/vazkii/botania/client/core/handler/ItemsRemainingRenderHandler.java index 4e41b8c15e..eb1f9e582a 100644 --- a/src/main/java/vazkii/botania/client/core/handler/ItemsRemainingRenderHandler.java +++ b/src/main/java/vazkii/botania/client/core/handler/ItemsRemainingRenderHandler.java @@ -2,16 +2,17 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jan 23, 2015, 9:22:10 PM (GMT)] */ package vazkii.botania.client.core.handler; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; import java.util.regex.Pattern; - import net.minecraft.client.Minecraft; import net.minecraft.client.gui.ScaledResolution; import net.minecraft.client.renderer.RenderHelper; @@ -19,90 +20,84 @@ import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; import net.minecraft.util.EnumChatFormatting; - import org.lwjgl.opengl.GL11; import org.lwjgl.opengl.GL12; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; - public final class ItemsRemainingRenderHandler { - private static int maxTicks = 30; - private static int leaveTicks = 20; - - private static ItemStack stack; - private static int ticks, count; - - @SideOnly(Side.CLIENT) - public static void render(ScaledResolution resolution, float partTicks) { - if(ticks > 0 && stack != null) { - int pos = maxTicks - ticks; - Minecraft mc = Minecraft.getMinecraft(); - int x = resolution.getScaledWidth() / 2 + 10 + Math.max(0, pos - leaveTicks); - int y = resolution.getScaledHeight() / 2; - - int start = maxTicks - leaveTicks; - float alpha = ticks + partTicks > start ? 1F : (ticks + partTicks) / start; - - GL11.glDisable(GL11.GL_ALPHA_TEST); - GL11.glEnable(GL11.GL_BLEND); - GL11.glEnable(GL12.GL_RESCALE_NORMAL); - GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); - - GL11.glColor4f(1F, 1F, 1F, alpha); - RenderHelper.enableGUIStandardItemLighting(); - int xp = x + (int) (16F * (1F - alpha)); - GL11.glTranslatef(xp, y, 0F); - GL11.glScalef(alpha, 1F, 1F); - RenderItem.getInstance().renderItemAndEffectIntoGUI(mc.fontRenderer, mc.renderEngine, stack, 0, 0); - GL11.glScalef(1F / alpha,1F, 1F); - GL11.glTranslatef(-xp, -y, 0F); - RenderHelper.disableStandardItemLighting(); - GL11.glColor4f(1F, 1F, 1F, 1F); - GL11.glEnable(GL11.GL_BLEND); - - String text = EnumChatFormatting.GREEN + stack.getDisplayName(); - if(count >= 0) { - int max = stack.getMaxStackSize(); - int stacks = count / max; - int rem = count % max; - - if(stacks == 0) - text = "" + count; - else text = count + " (" + EnumChatFormatting.AQUA + stacks + EnumChatFormatting.RESET + "*" + EnumChatFormatting.GRAY + max + EnumChatFormatting.RESET + "+" + EnumChatFormatting.YELLOW + rem + EnumChatFormatting.RESET + ")"; - } else if(count == -1) - text = "\u221E"; - - int color = 0x00FFFFFF | (int) (alpha * 0xFF) << 24; - mc.fontRenderer.drawStringWithShadow(text, x + 20, y + 6, color); - - GL11.glDisable(GL11.GL_BLEND); - GL11.glEnable(GL11.GL_ALPHA_TEST); - } - } - - @SideOnly(Side.CLIENT) - public static void tick() { - if(ticks > 0) - --ticks; - } - - public static void set(ItemStack stack, int count) { - ItemsRemainingRenderHandler.stack = stack; - ItemsRemainingRenderHandler.count = count; - ticks = stack == null ? 0 : maxTicks; - } - - public static void set(EntityPlayer player, ItemStack displayStack, Pattern pattern) { - int count = 0; - for(int i = 0; i < player.inventory.getSizeInventory(); i++) { - ItemStack stack = player.inventory.getStackInSlot(i); - if(stack != null && pattern.matcher(stack.getUnlocalizedName()).find()) - count += stack.stackSize; - } - - set(displayStack, count); - } - + private static int maxTicks = 30; + private static int leaveTicks = 20; + + private static ItemStack stack; + private static int ticks, count; + + @SideOnly(Side.CLIENT) + public static void render(ScaledResolution resolution, float partTicks) { + if (ticks > 0 && stack != null) { + int pos = maxTicks - ticks; + Minecraft mc = Minecraft.getMinecraft(); + int x = resolution.getScaledWidth() / 2 + 10 + Math.max(0, pos - leaveTicks); + int y = resolution.getScaledHeight() / 2; + + int start = maxTicks - leaveTicks; + float alpha = ticks + partTicks > start ? 1F : (ticks + partTicks) / start; + + GL11.glDisable(GL11.GL_ALPHA_TEST); + GL11.glEnable(GL11.GL_BLEND); + GL11.glEnable(GL12.GL_RESCALE_NORMAL); + GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); + + GL11.glColor4f(1F, 1F, 1F, alpha); + RenderHelper.enableGUIStandardItemLighting(); + int xp = x + (int) (16F * (1F - alpha)); + GL11.glTranslatef(xp, y, 0F); + GL11.glScalef(alpha, 1F, 1F); + RenderItem.getInstance().renderItemAndEffectIntoGUI(mc.fontRenderer, mc.renderEngine, stack, 0, 0); + GL11.glScalef(1F / alpha, 1F, 1F); + GL11.glTranslatef(-xp, -y, 0F); + RenderHelper.disableStandardItemLighting(); + GL11.glColor4f(1F, 1F, 1F, 1F); + GL11.glEnable(GL11.GL_BLEND); + + String text = EnumChatFormatting.GREEN + stack.getDisplayName(); + if (count >= 0) { + int max = stack.getMaxStackSize(); + int stacks = count / max; + int rem = count % max; + + if (stacks == 0) text = "" + count; + else + text = count + " (" + EnumChatFormatting.AQUA + stacks + EnumChatFormatting.RESET + "*" + + EnumChatFormatting.GRAY + max + EnumChatFormatting.RESET + "+" + EnumChatFormatting.YELLOW + + rem + EnumChatFormatting.RESET + ")"; + } else if (count == -1) text = "\u221E"; + + int color = 0x00FFFFFF | (int) (alpha * 0xFF) << 24; + mc.fontRenderer.drawStringWithShadow(text, x + 20, y + 6, color); + + GL11.glDisable(GL11.GL_BLEND); + GL11.glEnable(GL11.GL_ALPHA_TEST); + } + } + + @SideOnly(Side.CLIENT) + public static void tick() { + if (ticks > 0) --ticks; + } + + public static void set(ItemStack stack, int count) { + ItemsRemainingRenderHandler.stack = stack; + ItemsRemainingRenderHandler.count = count; + ticks = stack == null ? 0 : maxTicks; + } + + public static void set(EntityPlayer player, ItemStack displayStack, Pattern pattern) { + int count = 0; + for (int i = 0; i < player.inventory.getSizeInventory(); i++) { + ItemStack stack = player.inventory.getStackInSlot(i); + if (stack != null && pattern.matcher(stack.getUnlocalizedName()).find()) count += stack.stackSize; + } + + set(displayStack, count); + } } diff --git a/src/main/java/vazkii/botania/client/core/handler/LightningHandler.java b/src/main/java/vazkii/botania/client/core/handler/LightningHandler.java index d66b638a36..9804ba2afe 100644 --- a/src/main/java/vazkii/botania/client/core/handler/LightningHandler.java +++ b/src/main/java/vazkii/botania/client/core/handler/LightningHandler.java @@ -2,14 +2,15 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Feb 3, 2014, 9:05:38 PM (GMT)] */ package vazkii.botania.client.core.handler; +import cpw.mods.fml.common.eventhandler.SubscribeEvent; import java.awt.Color; import java.util.ArrayList; import java.util.Collections; @@ -18,7 +19,6 @@ import java.util.Iterator; import java.util.Random; import java.util.concurrent.ConcurrentLinkedQueue; - import net.minecraft.block.Block; import net.minecraft.client.Minecraft; import net.minecraft.client.renderer.ActiveRenderInfo; @@ -33,468 +33,548 @@ import net.minecraft.util.ResourceLocation; import net.minecraft.world.World; import net.minecraftforge.client.event.RenderWorldLastEvent; - import org.lwjgl.opengl.GL11; - import vazkii.botania.client.core.handler.LightningHandler.LightningBolt.Segment; import vazkii.botania.client.fx.ParticleRenderDispatcher; import vazkii.botania.client.lib.LibResources; import vazkii.botania.common.core.helper.Vector3; -import cpw.mods.fml.common.eventhandler.SubscribeEvent; public class LightningHandler { - private static final ResourceLocation outsideResource = new ResourceLocation(LibResources.MISC_WISP_LARGE); - private static final ResourceLocation insideResource = new ResourceLocation(LibResources.MISC_WISP_SMALL); - - static double interpPosX; - static double interpPosY; - static double interpPosZ; - - private static Vector3 getRelativeViewVector(Vector3 pos) { - Entity renderEntity = Minecraft.getMinecraft().renderViewEntity; - return new Vector3((float) renderEntity.posX - pos.x, (float) renderEntity.posY + renderEntity.getEyeHeight() - pos.y, (float) renderEntity.posZ - pos.z); - } - - @SubscribeEvent - public void onRenderWorldLast(RenderWorldLastEvent event) { - Profiler profiler = Minecraft.getMinecraft().mcProfiler; - - profiler.startSection("botania-particles"); - ParticleRenderDispatcher.dispatch(); - profiler.startSection("redString"); - RedStringRenderer.renderAll(); - profiler.endStartSection("lightning"); - - float frame = event.partialTicks; - Entity entity = Minecraft.getMinecraft().thePlayer; - TextureManager render = Minecraft.getMinecraft().renderEngine; - - interpPosX = entity.lastTickPosX + (entity.posX - entity.lastTickPosX) * frame; - interpPosY = entity.lastTickPosY + (entity.posY - entity.lastTickPosY) * frame; - interpPosZ = entity.lastTickPosZ + (entity.posZ - entity.lastTickPosZ) * frame; - - GL11.glPushMatrix(); - GL11.glTranslated(-interpPosX, -interpPosY, -interpPosZ); - - Tessellator tessellator = Tessellator.instance; - - GL11.glDepthMask(false); - GL11.glEnable(GL11.GL_BLEND); - GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); - - ParticleRenderDispatcher.lightningCount = 0; - - render.bindTexture(outsideResource); - tessellator.startDrawingQuads(); - tessellator.setBrightness(0xF000F0); - for(LightningBolt bolt : LightningBolt.boltlist) - renderBolt(bolt, tessellator, frame, ActiveRenderInfo.rotationX, ActiveRenderInfo.rotationXZ, ActiveRenderInfo.rotationZ, ActiveRenderInfo.rotationXY, 0, false); - tessellator.draw(); - - render.bindTexture(insideResource); - tessellator.startDrawingQuads(); - tessellator.setBrightness(0xF000F0); - for(LightningBolt bolt : LightningBolt.boltlist) - renderBolt(bolt, tessellator, frame, ActiveRenderInfo.rotationX, ActiveRenderInfo.rotationXZ, ActiveRenderInfo.rotationZ, ActiveRenderInfo.rotationXY, 1, true); - tessellator.draw(); - - GL11.glDisable(GL11.GL_BLEND); - GL11.glDepthMask(true); - - GL11.glTranslated(interpPosX, interpPosY, interpPosZ); - GL11.glPopMatrix(); - - profiler.endSection(); - profiler.endSection(); - - } - - public static void spawnLightningBolt(World world, Vector3 vectorStart, Vector3 vectorEnd, float ticksPerMeter, long seed, int colorOuter, int colorInner) { - LightningBolt bolt = new LightningBolt(world, vectorStart, vectorEnd, ticksPerMeter, seed, colorOuter, colorInner); - bolt.defaultFractal(); - bolt.finalizeBolt(); - LightningBolt.boltlist.add(bolt); - } - - private void renderBolt(LightningBolt bolt, Tessellator tessellator, float partialframe, float cosyaw, float cospitch, float sinyaw, float cossinpitch, int pass, boolean inner) { - ParticleRenderDispatcher.lightningCount++; - float boltage = bolt.particleAge < 0 ? 0 : (float) bolt.particleAge / (float) bolt.particleMaxAge; - float mainalpha = 1; - if(pass == 0) - mainalpha = (1 - boltage) * 0.4F; - else mainalpha = 1 - boltage * 0.5F; - - int expandTime = (int) (bolt.length * bolt.speed); - - int renderstart = (int) ((expandTime / 2 - bolt.particleMaxAge + bolt.particleAge) / (float) (expandTime / 2) * bolt.numsegments0); - int renderend = (int) ((bolt.particleAge + expandTime) / (float) expandTime * bolt.numsegments0); - - for(Segment rendersegment : bolt.segments) { - if(rendersegment.segmentno < renderstart || rendersegment.segmentno > renderend) - continue; - - Vector3 playervec = getRelativeViewVector(rendersegment.startpoint.point).multiply(-1); - - double width = 0.025F * (playervec.mag() / 5 + 1) * (1 + rendersegment.light) * 0.5F; - - Vector3 diff1 = playervec.copy().crossProduct(rendersegment.prevdiff).normalize().multiply(width / rendersegment.sinprev); - Vector3 diff2 = playervec.copy().crossProduct(rendersegment.nextdiff).normalize().multiply(width / rendersegment.sinnext); - - Vector3 startvec = rendersegment.startpoint.point; - Vector3 endvec = rendersegment.endpoint.point; - - int color = inner ? bolt.colorInner : bolt.colorOuter; - tessellator.setColorRGBA_I(color, (int) (mainalpha * rendersegment.light * new Color(color).getAlpha())); - - tessellator.addVertexWithUV(endvec.x - diff2.x, endvec.y - diff2.y, endvec.z - diff2.z, 0.5, 0); - tessellator.addVertexWithUV(startvec.x - diff1.x, startvec.y - diff1.y, startvec.z - diff1.z, 0.5, 0); - tessellator.addVertexWithUV(startvec.x + diff1.x, startvec.y + diff1.y, startvec.z + diff1.z, 0.5, 1); - tessellator.addVertexWithUV(endvec.x + diff2.x, endvec.y + diff2.y, endvec.z + diff2.z, 0.5, 1); - - if(rendersegment.next == null) { - Vector3 roundend = rendersegment.endpoint.point.copy().add(rendersegment.diff.copy().normalize().multiply(width)); - - tessellator.addVertexWithUV(roundend.x - diff2.x, roundend.y - diff2.y, roundend.z - diff2.z, 0, 0); - tessellator.addVertexWithUV(endvec.x - diff2.x, endvec.y - diff2.y, endvec.z - diff2.z, 0.5, 0); - tessellator.addVertexWithUV(endvec.x + diff2.x, endvec.y + diff2.y, endvec.z + diff2.z, 0.5, 1); - tessellator.addVertexWithUV(roundend.x + diff2.x, roundend.y + diff2.y, roundend.z + diff2.z, 0, 1); - } - - if(rendersegment.prev == null) { - Vector3 roundend = rendersegment.startpoint.point.copy().subtract(rendersegment.diff.copy().normalize().multiply(width)); - - tessellator.addVertexWithUV(startvec.x - diff1.x, startvec.y - diff1.y, startvec.z - diff1.z, 0.5, 0); - tessellator.addVertexWithUV(roundend.x - diff1.x, roundend.y - diff1.y, roundend.z - diff1.z, 0, 0); - tessellator.addVertexWithUV(roundend.x + diff1.x, roundend.y + diff1.y, roundend.z + diff1.z, 0, 1); - tessellator.addVertexWithUV(startvec.x + diff1.x, startvec.y + diff1.y, startvec.z + diff1.z, 0.5, 1); - } - } - } - - public static class LightningBolt { - - public ArrayList segments = new ArrayList(); - public Vector3 start; - public Vector3 end; - ChunkCoordinates target; - HashMap splitparents = new HashMap(); - - public double length; - public int numsegments0; - private int numsplits; - private boolean finalized; - private Random rand; - public long seed; - - public int particleAge; - public int particleMaxAge; - public boolean isDead; - private AxisAlignedBB boundingBox; - - private World world; - private Entity source; - - public static ConcurrentLinkedQueue boltlist = new ConcurrentLinkedQueue(); - - public float speed = 1.5F; - public static final int fadetime = 20; - - public static int playerdamage = 1; - public static int entitydamage = 1; - - public int colorOuter; - public int colorInner; - - public class BoltPoint { - - public BoltPoint(Vector3 basepoint, Vector3 offsetvec) { - point = basepoint.copy().add(offsetvec); - this.basepoint = basepoint; - this.offsetvec = offsetvec; - } - - public Vector3 point; - Vector3 basepoint; - Vector3 offsetvec; - } - - public class SegmentSorter implements Comparator { - - @Override - public int compare(Segment o1, Segment o2) { - int comp = Integer.valueOf(o1.splitno).compareTo(o2.splitno); - if(comp == 0) - return Integer.valueOf(o1.segmentno).compareTo(o2.segmentno); - else return comp; - } - } - - public class SegmentLightSorter implements Comparator { - @Override - public int compare(Segment o1, Segment o2) { - return Float.compare(o2.light, o1.light); - } - } - - public class Segment { - public Segment(BoltPoint start, BoltPoint end, float light, int segmentnumber, int splitnumber) { - startpoint = start; - endpoint = end; - this.light = light; - segmentno = segmentnumber; - splitno = splitnumber; - - calcDiff(); - } - - public Segment(Vector3 start, Vector3 end) { - this(new BoltPoint(start, new Vector3(0, 0, 0)), new BoltPoint(end, new Vector3(0, 0, 0)), 1, 0, 0); - } - - public void calcDiff() { - diff = endpoint.point.copy().subtract(startpoint.point); - } - - public void calcEndDiffs() { - if(prev != null) { - Vector3 prevdiffnorm = prev.diff.copy().normalize(); - Vector3 thisdiffnorm = diff.copy().normalize(); - - prevdiff = thisdiffnorm.copy().add(prevdiffnorm).normalize(); - sinprev = (float) Math.sin(thisdiffnorm.angle(prevdiffnorm.multiply(-1)) / 2); - } else { - prevdiff = diff.copy().normalize(); - sinprev = 1; - } - - if(next != null) { - Vector3 nextdiffnorm = next.diff.copy().normalize(); - Vector3 thisdiffnorm = diff.copy().normalize(); - - nextdiff = thisdiffnorm.add(nextdiffnorm).normalize(); - sinnext = (float) Math.sin(thisdiffnorm.angle(nextdiffnorm.multiply(-1)) / 2); - } else { - nextdiff = diff.copy().normalize(); - sinnext = 1; - } - } - - @Override - public String toString() { - return startpoint.point.toString() + " " + endpoint.point.toString(); - } - - public BoltPoint startpoint; - public BoltPoint endpoint; - - public Vector3 diff; - - public Segment prev; - public Segment next; - - public Vector3 nextdiff; - public Vector3 prevdiff; - - public float sinprev; - public float sinnext; - public float light; - - public int segmentno; - public int splitno; - } - - public LightningBolt(World world, Vector3 sourcevec, Vector3 targetvec, float ticksPerMeter, long seed, int colorOuter, int colorInner) { - this.world = world; - this.seed = seed; - rand = new Random(seed); - - start = sourcevec; - end = targetvec; - - speed = ticksPerMeter; - - this.colorOuter = colorOuter; - this.colorInner = colorInner; - - numsegments0 = 1; - - length = end.copy().subtract(start).mag(); - particleMaxAge = fadetime + rand.nextInt(fadetime) - fadetime / 2; - particleAge = -(int) (length * speed); - - boundingBox = AxisAlignedBB.getBoundingBox(0, 0, 0, 0, 0, 0); - boundingBox.setBB(AxisAlignedBB.getBoundingBox(Math.min(start.x, end.x), Math.min(start.y, end.y), Math.min(start.z, end.z), Math.max(start.x, end.x), Math.max(start.y, end.y), Math.max(start.z, end.z)).expand(length / 2, length / 2, length / 2)); - - segments.add(new Segment(start, end)); - } - - public static Vector3 getFocalPoint(TileEntity tile) { - return Vector3.fromTileEntityCenter(tile); - } - - public LightningBolt(World world, Vector3 sourcevec, TileEntity target, float ticksPerMeter, long seed, int colorOuter, int colorInner) { - this(world, sourcevec, getFocalPoint(target), ticksPerMeter, seed, colorOuter, colorInner); - this.target = new ChunkCoordinates(target.xCoord, target.yCoord, target.zCoord); - } - - public void setWrapper(Entity entity) { - source = entity; - } - - public void fractal(int splits, double amount, double splitchance, double splitlength, double splitangle) { - if(finalized) - return; - - ArrayList oldsegments = segments; - segments = new ArrayList(); - - Segment prev = null; - - for(Segment segment : oldsegments) { - prev = segment.prev; - - Vector3 subsegment = segment.diff.copy().multiply(1F / splits); - - BoltPoint[] newpoints = new BoltPoint[splits + 1]; - - Vector3 startpoint = segment.startpoint.point; - newpoints[0] = segment.startpoint; - newpoints[splits] = segment.endpoint; - - for(int i = 1; i < splits; i++) { - Vector3 randoff = segment.diff.copy().perpendicular().normalize().rotate(rand.nextFloat() * 360, segment.diff); - randoff.multiply((rand.nextFloat() - 0.5F) * amount * 2); - - Vector3 basepoint = startpoint.copy().add(subsegment.copy().multiply(i)); - - newpoints[i] = new BoltPoint(basepoint, randoff); - } - - for(int i = 0; i < splits; i++) { - Segment next = new Segment(newpoints[i], newpoints[i + 1], segment.light, segment.segmentno * splits + i, segment.splitno); - next.prev = prev; - if (prev != null) - prev.next = next; - - if(i != 0 && rand.nextFloat() < splitchance) { - Vector3 splitrot = next.diff.copy().xCrossProduct().rotate(rand.nextFloat() * 360, next.diff); - Vector3 diff = next.diff.copy().rotate((rand.nextFloat() * 0.66F + 0.33F) * splitangle, splitrot).multiply(splitlength); - - numsplits++; - splitparents.put(numsplits, next.splitno); - - Segment split = new Segment(newpoints[i], new BoltPoint(newpoints[i + 1].basepoint, newpoints[i + 1].offsetvec.copy().add(diff)), segment.light / 2F, next.segmentno, numsplits); - split.prev = prev; - - segments.add(split); - } - - prev = next; - segments.add(next); - } - - if(segment.next != null) - segment.next.prev = prev; - } - - numsegments0 *= splits; - } - - public void defaultFractal() { - fractal(2, length / 1.5, 0.7F, 0.7F, 45); - fractal(2, length / 4, 0.5F, 0.8F, 50); - fractal(2, length / 15, 0.5F, 0.9F, 55); - fractal(2, length / 30, 0.5F, 1.0F, 60); - fractal(2, length / 60, 0, 0, 0); - fractal(2, length / 100, 0, 0, 0); - fractal(2, length / 400, 0, 0, 0); - } - - private float rayTraceResistance(Vector3 start, Vector3 end, float prevresistance) { - MovingObjectPosition mop = world.rayTraceBlocks(start.toVec3D(), end.toVec3D()); - - if(mop == null) - return prevresistance; - - if(mop.typeOfHit == MovingObjectPosition.MovingObjectType.BLOCK) { - Block block = world.getBlock(mop.blockX, mop.blockY, mop.blockZ); - - if(world.isAirBlock(mop.blockX, mop.blockY, mop.blockZ)) - return prevresistance; - - return prevresistance + block.getExplosionResistance(source) + 0.3F; - } else return prevresistance; - } - - private void calculateCollisionAndDiffs() { - HashMap lastactivesegment = new HashMap(); - - Collections.sort(segments, new SegmentSorter()); - - int lastsplitcalc = 0; - int lastactiveseg = 0;// unterminated - float splitresistance = 0; - - for(Segment segment : segments) { - if(segment.splitno > lastsplitcalc) { - lastactivesegment.put(lastsplitcalc, lastactiveseg); - lastsplitcalc = segment.splitno; - lastactiveseg = lastactivesegment.get(splitparents.get(segment.splitno)); - splitresistance = lastactiveseg < segment.segmentno ? 50 : 0; - } - - if(splitresistance >= 40 * segment.light) - continue; - - splitresistance = rayTraceResistance(segment.startpoint.point, segment.endpoint.point, splitresistance); - lastactiveseg = segment.segmentno; - } - lastactivesegment.put(lastsplitcalc, lastactiveseg); + private static final ResourceLocation outsideResource = new ResourceLocation(LibResources.MISC_WISP_LARGE); + private static final ResourceLocation insideResource = new ResourceLocation(LibResources.MISC_WISP_SMALL); + + static double interpPosX; + static double interpPosY; + static double interpPosZ; + + private static Vector3 getRelativeViewVector(Vector3 pos) { + Entity renderEntity = Minecraft.getMinecraft().renderViewEntity; + return new Vector3( + (float) renderEntity.posX - pos.x, + (float) renderEntity.posY + renderEntity.getEyeHeight() - pos.y, + (float) renderEntity.posZ - pos.z); + } + + @SubscribeEvent + public void onRenderWorldLast(RenderWorldLastEvent event) { + Profiler profiler = Minecraft.getMinecraft().mcProfiler; + + profiler.startSection("botania-particles"); + ParticleRenderDispatcher.dispatch(); + profiler.startSection("redString"); + RedStringRenderer.renderAll(); + profiler.endStartSection("lightning"); + + float frame = event.partialTicks; + Entity entity = Minecraft.getMinecraft().thePlayer; + TextureManager render = Minecraft.getMinecraft().renderEngine; + + interpPosX = entity.lastTickPosX + (entity.posX - entity.lastTickPosX) * frame; + interpPosY = entity.lastTickPosY + (entity.posY - entity.lastTickPosY) * frame; + interpPosZ = entity.lastTickPosZ + (entity.posZ - entity.lastTickPosZ) * frame; + + GL11.glPushMatrix(); + GL11.glTranslated(-interpPosX, -interpPosY, -interpPosZ); + + Tessellator tessellator = Tessellator.instance; + + GL11.glDepthMask(false); + GL11.glEnable(GL11.GL_BLEND); + GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); + + ParticleRenderDispatcher.lightningCount = 0; + + render.bindTexture(outsideResource); + tessellator.startDrawingQuads(); + tessellator.setBrightness(0xF000F0); + for (LightningBolt bolt : LightningBolt.boltlist) + renderBolt( + bolt, + tessellator, + frame, + ActiveRenderInfo.rotationX, + ActiveRenderInfo.rotationXZ, + ActiveRenderInfo.rotationZ, + ActiveRenderInfo.rotationXY, + 0, + false); + tessellator.draw(); + + render.bindTexture(insideResource); + tessellator.startDrawingQuads(); + tessellator.setBrightness(0xF000F0); + for (LightningBolt bolt : LightningBolt.boltlist) + renderBolt( + bolt, + tessellator, + frame, + ActiveRenderInfo.rotationX, + ActiveRenderInfo.rotationXZ, + ActiveRenderInfo.rotationZ, + ActiveRenderInfo.rotationXY, + 1, + true); + tessellator.draw(); + + GL11.glDisable(GL11.GL_BLEND); + GL11.glDepthMask(true); + + GL11.glTranslated(interpPosX, interpPosY, interpPosZ); + GL11.glPopMatrix(); + + profiler.endSection(); + profiler.endSection(); + } + + public static void spawnLightningBolt( + World world, + Vector3 vectorStart, + Vector3 vectorEnd, + float ticksPerMeter, + long seed, + int colorOuter, + int colorInner) { + LightningBolt bolt = + new LightningBolt(world, vectorStart, vectorEnd, ticksPerMeter, seed, colorOuter, colorInner); + bolt.defaultFractal(); + bolt.finalizeBolt(); + LightningBolt.boltlist.add(bolt); + } + + private void renderBolt( + LightningBolt bolt, + Tessellator tessellator, + float partialframe, + float cosyaw, + float cospitch, + float sinyaw, + float cossinpitch, + int pass, + boolean inner) { + ParticleRenderDispatcher.lightningCount++; + float boltage = bolt.particleAge < 0 ? 0 : (float) bolt.particleAge / (float) bolt.particleMaxAge; + float mainalpha = 1; + if (pass == 0) mainalpha = (1 - boltage) * 0.4F; + else mainalpha = 1 - boltage * 0.5F; + + int expandTime = (int) (bolt.length * bolt.speed); + + int renderstart = (int) ((expandTime / 2 - bolt.particleMaxAge + bolt.particleAge) + / (float) (expandTime / 2) + * bolt.numsegments0); + int renderend = (int) ((bolt.particleAge + expandTime) / (float) expandTime * bolt.numsegments0); + + for (Segment rendersegment : bolt.segments) { + if (rendersegment.segmentno < renderstart || rendersegment.segmentno > renderend) continue; + + Vector3 playervec = + getRelativeViewVector(rendersegment.startpoint.point).multiply(-1); + + double width = 0.025F * (playervec.mag() / 5 + 1) * (1 + rendersegment.light) * 0.5F; + + Vector3 diff1 = playervec + .copy() + .crossProduct(rendersegment.prevdiff) + .normalize() + .multiply(width / rendersegment.sinprev); + Vector3 diff2 = playervec + .copy() + .crossProduct(rendersegment.nextdiff) + .normalize() + .multiply(width / rendersegment.sinnext); + + Vector3 startvec = rendersegment.startpoint.point; + Vector3 endvec = rendersegment.endpoint.point; + + int color = inner ? bolt.colorInner : bolt.colorOuter; + tessellator.setColorRGBA_I(color, (int) (mainalpha * rendersegment.light * new Color(color).getAlpha())); + + tessellator.addVertexWithUV(endvec.x - diff2.x, endvec.y - diff2.y, endvec.z - diff2.z, 0.5, 0); + tessellator.addVertexWithUV(startvec.x - diff1.x, startvec.y - diff1.y, startvec.z - diff1.z, 0.5, 0); + tessellator.addVertexWithUV(startvec.x + diff1.x, startvec.y + diff1.y, startvec.z + diff1.z, 0.5, 1); + tessellator.addVertexWithUV(endvec.x + diff2.x, endvec.y + diff2.y, endvec.z + diff2.z, 0.5, 1); + + if (rendersegment.next == null) { + Vector3 roundend = rendersegment + .endpoint + .point + .copy() + .add(rendersegment.diff.copy().normalize().multiply(width)); + + tessellator.addVertexWithUV(roundend.x - diff2.x, roundend.y - diff2.y, roundend.z - diff2.z, 0, 0); + tessellator.addVertexWithUV(endvec.x - diff2.x, endvec.y - diff2.y, endvec.z - diff2.z, 0.5, 0); + tessellator.addVertexWithUV(endvec.x + diff2.x, endvec.y + diff2.y, endvec.z + diff2.z, 0.5, 1); + tessellator.addVertexWithUV(roundend.x + diff2.x, roundend.y + diff2.y, roundend.z + diff2.z, 0, 1); + } + + if (rendersegment.prev == null) { + Vector3 roundend = rendersegment + .startpoint + .point + .copy() + .subtract(rendersegment.diff.copy().normalize().multiply(width)); + + tessellator.addVertexWithUV(startvec.x - diff1.x, startvec.y - diff1.y, startvec.z - diff1.z, 0.5, 0); + tessellator.addVertexWithUV(roundend.x - diff1.x, roundend.y - diff1.y, roundend.z - diff1.z, 0, 0); + tessellator.addVertexWithUV(roundend.x + diff1.x, roundend.y + diff1.y, roundend.z + diff1.z, 0, 1); + tessellator.addVertexWithUV(startvec.x + diff1.x, startvec.y + diff1.y, startvec.z + diff1.z, 0.5, 1); + } + } + } + + public static class LightningBolt { + + public ArrayList segments = new ArrayList(); + public Vector3 start; + public Vector3 end; + ChunkCoordinates target; + HashMap splitparents = new HashMap(); + + public double length; + public int numsegments0; + private int numsplits; + private boolean finalized; + private Random rand; + public long seed; + + public int particleAge; + public int particleMaxAge; + public boolean isDead; + private AxisAlignedBB boundingBox; + + private World world; + private Entity source; + + public static ConcurrentLinkedQueue boltlist = new ConcurrentLinkedQueue(); + + public float speed = 1.5F; + public static final int fadetime = 20; + + public static int playerdamage = 1; + public static int entitydamage = 1; + + public int colorOuter; + public int colorInner; + + public class BoltPoint { + + public BoltPoint(Vector3 basepoint, Vector3 offsetvec) { + point = basepoint.copy().add(offsetvec); + this.basepoint = basepoint; + this.offsetvec = offsetvec; + } + + public Vector3 point; + Vector3 basepoint; + Vector3 offsetvec; + } + + public class SegmentSorter implements Comparator { + + @Override + public int compare(Segment o1, Segment o2) { + int comp = Integer.valueOf(o1.splitno).compareTo(o2.splitno); + if (comp == 0) return Integer.valueOf(o1.segmentno).compareTo(o2.segmentno); + else return comp; + } + } + + public class SegmentLightSorter implements Comparator { + @Override + public int compare(Segment o1, Segment o2) { + return Float.compare(o2.light, o1.light); + } + } + + public class Segment { + public Segment(BoltPoint start, BoltPoint end, float light, int segmentnumber, int splitnumber) { + startpoint = start; + endpoint = end; + this.light = light; + segmentno = segmentnumber; + splitno = splitnumber; + + calcDiff(); + } + + public Segment(Vector3 start, Vector3 end) { + this(new BoltPoint(start, new Vector3(0, 0, 0)), new BoltPoint(end, new Vector3(0, 0, 0)), 1, 0, 0); + } + + public void calcDiff() { + diff = endpoint.point.copy().subtract(startpoint.point); + } + + public void calcEndDiffs() { + if (prev != null) { + Vector3 prevdiffnorm = prev.diff.copy().normalize(); + Vector3 thisdiffnorm = diff.copy().normalize(); + + prevdiff = thisdiffnorm.copy().add(prevdiffnorm).normalize(); + sinprev = (float) Math.sin(thisdiffnorm.angle(prevdiffnorm.multiply(-1)) / 2); + } else { + prevdiff = diff.copy().normalize(); + sinprev = 1; + } + + if (next != null) { + Vector3 nextdiffnorm = next.diff.copy().normalize(); + Vector3 thisdiffnorm = diff.copy().normalize(); + + nextdiff = thisdiffnorm.add(nextdiffnorm).normalize(); + sinnext = (float) Math.sin(thisdiffnorm.angle(nextdiffnorm.multiply(-1)) / 2); + } else { + nextdiff = diff.copy().normalize(); + sinnext = 1; + } + } + + @Override + public String toString() { + return startpoint.point.toString() + " " + endpoint.point.toString(); + } + + public BoltPoint startpoint; + public BoltPoint endpoint; + + public Vector3 diff; + + public Segment prev; + public Segment next; + + public Vector3 nextdiff; + public Vector3 prevdiff; + + public float sinprev; + public float sinnext; + public float light; + + public int segmentno; + public int splitno; + } + + public LightningBolt( + World world, + Vector3 sourcevec, + Vector3 targetvec, + float ticksPerMeter, + long seed, + int colorOuter, + int colorInner) { + this.world = world; + this.seed = seed; + rand = new Random(seed); + + start = sourcevec; + end = targetvec; + + speed = ticksPerMeter; + + this.colorOuter = colorOuter; + this.colorInner = colorInner; + + numsegments0 = 1; + + length = end.copy().subtract(start).mag(); + particleMaxAge = fadetime + rand.nextInt(fadetime) - fadetime / 2; + particleAge = -(int) (length * speed); + + boundingBox = AxisAlignedBB.getBoundingBox(0, 0, 0, 0, 0, 0); + boundingBox.setBB(AxisAlignedBB.getBoundingBox( + Math.min(start.x, end.x), + Math.min(start.y, end.y), + Math.min(start.z, end.z), + Math.max(start.x, end.x), + Math.max(start.y, end.y), + Math.max(start.z, end.z)) + .expand(length / 2, length / 2, length / 2)); + + segments.add(new Segment(start, end)); + } + + public static Vector3 getFocalPoint(TileEntity tile) { + return Vector3.fromTileEntityCenter(tile); + } + + public LightningBolt( + World world, + Vector3 sourcevec, + TileEntity target, + float ticksPerMeter, + long seed, + int colorOuter, + int colorInner) { + this(world, sourcevec, getFocalPoint(target), ticksPerMeter, seed, colorOuter, colorInner); + this.target = new ChunkCoordinates(target.xCoord, target.yCoord, target.zCoord); + } + + public void setWrapper(Entity entity) { + source = entity; + } + + public void fractal(int splits, double amount, double splitchance, double splitlength, double splitangle) { + if (finalized) return; + + ArrayList oldsegments = segments; + segments = new ArrayList(); + + Segment prev = null; + + for (Segment segment : oldsegments) { + prev = segment.prev; + + Vector3 subsegment = segment.diff.copy().multiply(1F / splits); + + BoltPoint[] newpoints = new BoltPoint[splits + 1]; + + Vector3 startpoint = segment.startpoint.point; + newpoints[0] = segment.startpoint; + newpoints[splits] = segment.endpoint; + + for (int i = 1; i < splits; i++) { + Vector3 randoff = segment.diff + .copy() + .perpendicular() + .normalize() + .rotate(rand.nextFloat() * 360, segment.diff); + randoff.multiply((rand.nextFloat() - 0.5F) * amount * 2); + + Vector3 basepoint = startpoint.copy().add(subsegment.copy().multiply(i)); + + newpoints[i] = new BoltPoint(basepoint, randoff); + } + + for (int i = 0; i < splits; i++) { + Segment next = new Segment( + newpoints[i], + newpoints[i + 1], + segment.light, + segment.segmentno * splits + i, + segment.splitno); + next.prev = prev; + if (prev != null) prev.next = next; + + if (i != 0 && rand.nextFloat() < splitchance) { + Vector3 splitrot = next.diff.copy().xCrossProduct().rotate(rand.nextFloat() * 360, next.diff); + Vector3 diff = next.diff + .copy() + .rotate((rand.nextFloat() * 0.66F + 0.33F) * splitangle, splitrot) + .multiply(splitlength); + + numsplits++; + splitparents.put(numsplits, next.splitno); + + Segment split = new Segment( + newpoints[i], + new BoltPoint( + newpoints[i + 1].basepoint, + newpoints[i + 1].offsetvec.copy().add(diff)), + segment.light / 2F, + next.segmentno, + numsplits); + split.prev = prev; + + segments.add(split); + } + + prev = next; + segments.add(next); + } + + if (segment.next != null) segment.next.prev = prev; + } + + numsegments0 *= splits; + } + + public void defaultFractal() { + fractal(2, length / 1.5, 0.7F, 0.7F, 45); + fractal(2, length / 4, 0.5F, 0.8F, 50); + fractal(2, length / 15, 0.5F, 0.9F, 55); + fractal(2, length / 30, 0.5F, 1.0F, 60); + fractal(2, length / 60, 0, 0, 0); + fractal(2, length / 100, 0, 0, 0); + fractal(2, length / 400, 0, 0, 0); + } + + private float rayTraceResistance(Vector3 start, Vector3 end, float prevresistance) { + MovingObjectPosition mop = world.rayTraceBlocks(start.toVec3D(), end.toVec3D()); + + if (mop == null) return prevresistance; + + if (mop.typeOfHit == MovingObjectPosition.MovingObjectType.BLOCK) { + Block block = world.getBlock(mop.blockX, mop.blockY, mop.blockZ); + + if (world.isAirBlock(mop.blockX, mop.blockY, mop.blockZ)) return prevresistance; + + return prevresistance + block.getExplosionResistance(source) + 0.3F; + } else return prevresistance; + } + + private void calculateCollisionAndDiffs() { + HashMap lastactivesegment = new HashMap(); + + Collections.sort(segments, new SegmentSorter()); + + int lastsplitcalc = 0; + int lastactiveseg = 0; // unterminated + float splitresistance = 0; + + for (Segment segment : segments) { + if (segment.splitno > lastsplitcalc) { + lastactivesegment.put(lastsplitcalc, lastactiveseg); + lastsplitcalc = segment.splitno; + lastactiveseg = lastactivesegment.get(splitparents.get(segment.splitno)); + splitresistance = lastactiveseg < segment.segmentno ? 50 : 0; + } + + if (splitresistance >= 40 * segment.light) continue; + + splitresistance = rayTraceResistance(segment.startpoint.point, segment.endpoint.point, splitresistance); + lastactiveseg = segment.segmentno; + } + lastactivesegment.put(lastsplitcalc, lastactiveseg); + + lastsplitcalc = 0; + lastactiveseg = lastactivesegment.get(0); + for (Iterator iterator = segments.iterator(); iterator.hasNext(); ) { + Segment segment = iterator.next(); + if (lastsplitcalc != segment.splitno) { + lastsplitcalc = segment.splitno; + lastactiveseg = lastactivesegment.get(segment.splitno); + } + + if (segment.segmentno > lastactiveseg) iterator.remove(); + segment.calcEndDiffs(); + } + } + + public void finalizeBolt() { + if (finalized) return; + finalized = true; + + calculateCollisionAndDiffs(); + + Collections.sort(segments, new SegmentLightSorter()); + + boltlist.add(this); + } + + public void onUpdate() { + particleAge++; + + if (particleAge >= particleMaxAge) isDead = true; + } + + // Called in ClientTickHandler + public static void update() { + for (Iterator iterator = boltlist.iterator(); iterator.hasNext(); ) { + LightningBolt bolt = iterator.next(); - lastsplitcalc = 0; - lastactiveseg = lastactivesegment.get(0); - for(Iterator iterator = segments.iterator(); iterator.hasNext();) { - Segment segment = iterator.next(); - if(lastsplitcalc != segment.splitno) { - lastsplitcalc = segment.splitno; - lastactiveseg = lastactivesegment.get(segment.splitno); - } - - if(segment.segmentno > lastactiveseg) - iterator.remove(); - segment.calcEndDiffs(); - } - } - - public void finalizeBolt() { - if(finalized) - return; - finalized = true; - - calculateCollisionAndDiffs(); - - Collections.sort(segments, new SegmentLightSorter()); - - boltlist.add(this); - } - - public void onUpdate() { - particleAge++; - - if (particleAge >= particleMaxAge) - isDead = true; - } - - // Called in ClientTickHandler - public static void update() { - for(Iterator iterator = boltlist.iterator(); iterator.hasNext();) { - LightningBolt bolt = iterator.next(); - - bolt.onUpdate(); - if(bolt.isDead) - iterator.remove(); - } - } - } -} \ No newline at end of file + bolt.onUpdate(); + if (bolt.isDead) iterator.remove(); + } + } + } +} diff --git a/src/main/java/vazkii/botania/client/core/handler/MultiblockBlockAccess.java b/src/main/java/vazkii/botania/client/core/handler/MultiblockBlockAccess.java index c59ac25056..19d2b67f75 100644 --- a/src/main/java/vazkii/botania/client/core/handler/MultiblockBlockAccess.java +++ b/src/main/java/vazkii/botania/client/core/handler/MultiblockBlockAccess.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Aug 31, 2015, 11:40:59 PM (GMT)] */ package vazkii.botania.client.core.handler; @@ -25,108 +25,95 @@ */ public class MultiblockBlockAccess implements IBlockAccess { - protected IBlockAccess originalBlockAccess; - protected boolean hasBlockAccess = false; - protected Multiblock multiblock; - protected int anchorX, anchorY, anchorZ; + protected IBlockAccess originalBlockAccess; + protected boolean hasBlockAccess = false; + protected Multiblock multiblock; + protected int anchorX, anchorY, anchorZ; - @Override - public Block getBlock(int x, int y, int z) { - MultiblockComponent comp=getComponent(x, y, z); - if(comp != null) - return comp.getBlock(); - if(hasBlockAccess) - return originalBlockAccess.getBlock(x, y, z); - return Blocks.air; - } + @Override + public Block getBlock(int x, int y, int z) { + MultiblockComponent comp = getComponent(x, y, z); + if (comp != null) return comp.getBlock(); + if (hasBlockAccess) return originalBlockAccess.getBlock(x, y, z); + return Blocks.air; + } - @Override - public TileEntity getTileEntity(int x, int y, int z) { - MultiblockComponent comp=getComponent(x, y, z); - if(comp != null) - return comp.getTileEntity(); - if(hasBlockAccess) - return originalBlockAccess.getTileEntity(x, y, z); - return null; - } + @Override + public TileEntity getTileEntity(int x, int y, int z) { + MultiblockComponent comp = getComponent(x, y, z); + if (comp != null) return comp.getTileEntity(); + if (hasBlockAccess) return originalBlockAccess.getTileEntity(x, y, z); + return null; + } - @Override - public int getLightBrightnessForSkyBlocks(int x, int y, int z, int p_72802_4_) { - if(hasBlockAccess) - return originalBlockAccess.getLightBrightnessForSkyBlocks(x,y,z,p_72802_4_); - return 15728640; - } + @Override + public int getLightBrightnessForSkyBlocks(int x, int y, int z, int p_72802_4_) { + if (hasBlockAccess) return originalBlockAccess.getLightBrightnessForSkyBlocks(x, y, z, p_72802_4_); + return 15728640; + } - @Override - public int getBlockMetadata(int x, int y, int z) { - MultiblockComponent comp=getComponent(x, y, z); - if(comp != null) - return comp.getMeta(); - if(hasBlockAccess) - return originalBlockAccess.getBlockMetadata(x, y, z); - return 0; - } + @Override + public int getBlockMetadata(int x, int y, int z) { + MultiblockComponent comp = getComponent(x, y, z); + if (comp != null) return comp.getMeta(); + if (hasBlockAccess) return originalBlockAccess.getBlockMetadata(x, y, z); + return 0; + } - @Override - public int isBlockProvidingPowerTo(int x, int y, int z, int direction) { - return 0; - } + @Override + public int isBlockProvidingPowerTo(int x, int y, int z, int direction) { + return 0; + } - @Override - public boolean isAirBlock(int x, int y, int z) { - MultiblockComponent comp=getComponent(x, y, z); - if(comp != null) - return false; - if(hasBlockAccess) - return originalBlockAccess.isAirBlock(x, y, z); - return true; - } + @Override + public boolean isAirBlock(int x, int y, int z) { + MultiblockComponent comp = getComponent(x, y, z); + if (comp != null) return false; + if (hasBlockAccess) return originalBlockAccess.isAirBlock(x, y, z); + return true; + } - @Override - public BiomeGenBase getBiomeGenForCoords(int x, int z) { - if(hasBlockAccess) - return originalBlockAccess.getBiomeGenForCoords(x, z); - return null; - } + @Override + public BiomeGenBase getBiomeGenForCoords(int x, int z) { + if (hasBlockAccess) return originalBlockAccess.getBiomeGenForCoords(x, z); + return null; + } - @Override - public int getHeight() { - if(hasBlockAccess) - return originalBlockAccess.getHeight(); - return 256; - } + @Override + public int getHeight() { + if (hasBlockAccess) return originalBlockAccess.getHeight(); + return 256; + } - @Override - public boolean extendedLevelsInChunkCache() { - if(hasBlockAccess) - return originalBlockAccess.extendedLevelsInChunkCache(); - return false; - } + @Override + public boolean extendedLevelsInChunkCache() { + if (hasBlockAccess) return originalBlockAccess.extendedLevelsInChunkCache(); + return false; + } - @Override - public boolean isSideSolid(int x, int y, int z, ForgeDirection side, boolean _default) { - if(hasBlockAccess) - return originalBlockAccess.isSideSolid(x, y, z, side, _default); - return _default; - } + @Override + public boolean isSideSolid(int x, int y, int z, ForgeDirection side, boolean _default) { + if (hasBlockAccess) return originalBlockAccess.isSideSolid(x, y, z, side, _default); + return _default; + } - /** - * Updates the block access to the new parameters - */ - public void update(IBlockAccess access, Multiblock mb, int anchorX, int anchorY, int anchorZ) { - originalBlockAccess = access; - multiblock = mb; - this.anchorX = anchorX; - this.anchorY = anchorY; - this.anchorZ = anchorZ; - hasBlockAccess = access != null; - } + /** + * Updates the block access to the new parameters + */ + public void update(IBlockAccess access, Multiblock mb, int anchorX, int anchorY, int anchorZ) { + originalBlockAccess = access; + multiblock = mb; + this.anchorX = anchorX; + this.anchorY = anchorY; + this.anchorZ = anchorZ; + hasBlockAccess = access != null; + } - /** - * Returns the multiblock component for the coordinates, adjusted based on the anchor - */ - protected MultiblockComponent getComponent(int x, int y, int z) { - MultiblockComponent comp = multiblock.getComponentForLocation(x - anchorX, y - anchorY, z - anchorZ); - return comp; - } + /** + * Returns the multiblock component for the coordinates, adjusted based on the anchor + */ + protected MultiblockComponent getComponent(int x, int y, int z) { + MultiblockComponent comp = multiblock.getComponentForLocation(x - anchorX, y - anchorY, z - anchorZ); + return comp; + } } diff --git a/src/main/java/vazkii/botania/client/core/handler/MultiblockRenderHandler.java b/src/main/java/vazkii/botania/client/core/handler/MultiblockRenderHandler.java index 14295ff78b..f55ed52f4e 100644 --- a/src/main/java/vazkii/botania/client/core/handler/MultiblockRenderHandler.java +++ b/src/main/java/vazkii/botania/client/core/handler/MultiblockRenderHandler.java @@ -2,14 +2,15 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jun 27, 2015, 7:28:29 PM (GMT)] */ package vazkii.botania.client.core.handler; +import cpw.mods.fml.common.eventhandler.SubscribeEvent; import net.minecraft.block.Block; import net.minecraft.client.Minecraft; import net.minecraft.client.renderer.RenderBlocks; @@ -28,164 +29,160 @@ import net.minecraftforge.client.event.RenderWorldLastEvent; import net.minecraftforge.event.entity.player.PlayerInteractEvent; import net.minecraftforge.event.entity.player.PlayerInteractEvent.Action; - import org.lwjgl.opengl.GL11; - import vazkii.botania.api.lexicon.multiblock.IMultiblockRenderHook; import vazkii.botania.api.lexicon.multiblock.Multiblock; import vazkii.botania.api.lexicon.multiblock.MultiblockSet; import vazkii.botania.api.lexicon.multiblock.component.MultiblockComponent; -import cpw.mods.fml.common.eventhandler.SubscribeEvent; public final class MultiblockRenderHandler { - public static boolean rendering = false; - - private static MultiblockBlockAccess blockAccess = new MultiblockBlockAccess(); - - private static RenderBlocks blockRender = RenderBlocks.getInstance(); - public static MultiblockSet currentMultiblock; - public static ChunkCoordinates anchor; - public static int angle; - public static int dimension; - - public static void setMultiblock(MultiblockSet set) { - currentMultiblock = set; - anchor = null; - angle = 0; - - Minecraft mc = Minecraft.getMinecraft(); - if(mc.theWorld != null) - dimension = mc.theWorld.provider.dimensionId; - } - - @SubscribeEvent - public void onWorldRenderLast(RenderWorldLastEvent event) { - Minecraft mc = Minecraft.getMinecraft(); - if(mc.thePlayer != null && mc.objectMouseOver != null && (!mc.thePlayer.isSneaking() || anchor != null)) { - mc.thePlayer.getCurrentEquippedItem(); - renderPlayerLook(mc.thePlayer, mc.objectMouseOver); - } - } - - @SubscribeEvent - public void onPlayerInteract(PlayerInteractEvent event) { - if(currentMultiblock != null && anchor == null && event.action == Action.RIGHT_CLICK_BLOCK && event.entityPlayer == Minecraft.getMinecraft().thePlayer) { - anchor = new ChunkCoordinates(event.x, event.y, event.z); - angle = MathHelper.floor_double(event.entityPlayer.rotationYaw * 4.0 / 360.0 + 0.5) & 3; - event.setCanceled(true); - } - } - - private void renderPlayerLook(EntityPlayer player, MovingObjectPosition src) { - if(currentMultiblock != null && dimension == player.worldObj.provider.dimensionId) { - int anchorX = anchor != null ? anchor.posX : src.blockX; - int anchorY = anchor != null ? anchor.posY : src.blockY; - int anchorZ = anchor != null ? anchor.posZ : src.blockZ; - - GL11.glPushMatrix(); - GL11.glPushAttrib(GL11.GL_LIGHTING); - GL11.glEnable(GL11.GL_BLEND); - GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); - GL11.glDisable(GL11.GL_LIGHTING); - rendering = true; - Multiblock mb = anchor != null ? currentMultiblock.getForIndex(angle) : currentMultiblock.getForEntity(player); - boolean didAny = false; - - blockAccess.update(player.worldObj, mb, anchorX, anchorY, anchorZ); - - for(MultiblockComponent comp : mb.getComponents()) - if(renderComponentInWorld(player.worldObj, mb, comp, anchorX, anchorY, anchorZ)) - didAny = true; - rendering = false; - GL11.glPopAttrib(); - GL11.glPopMatrix(); - - if(!didAny) { - setMultiblock(null); - player.addChatComponentMessage(new ChatComponentTranslation("botaniamisc.structureComplete").setChatStyle(new ChatStyle().setColor(EnumChatFormatting.GREEN))); - } - } - } - - private boolean renderComponentInWorld(World world, Multiblock mb, MultiblockComponent comp, int anchorX, int anchorY, int anchorZ) { - ChunkCoordinates pos = comp.getRelativePosition(); - int x = pos.posX + anchorX; - int y = pos.posY + anchorY; - int z = pos.posZ + anchorZ; - if(anchor != null && comp.matches(world, x, y, z)) - return false; - - GL11.glPushMatrix(); - GL11.glTranslated(-RenderManager.renderPosX, -RenderManager.renderPosY, -RenderManager.renderPosZ); - GL11.glDisable(GL11.GL_DEPTH_TEST); - doRenderComponent(mb, comp, x, y, z, 0.4F); - GL11.glPopMatrix(); - return true; - } - - public static void renderMultiblockOnPage(Multiblock mb) { - GL11.glTranslated(-0.5, -0.5, -0.5); - blockAccess.update(null, mb, mb.offX, mb.offY, mb.offZ); - for(MultiblockComponent comp : mb.getComponents()) { - ChunkCoordinates pos = comp.getRelativePosition(); - doRenderComponent(mb, comp, pos.posX + mb.offX, pos.posY + mb.offY, pos.posZ + mb.offZ, 1); - } - } - - private static void doRenderComponent(Multiblock mb, MultiblockComponent comp, int x, int y, int z, float alpha) { - GL11.glPushMatrix(); - GL11.glEnable(GL11.GL_BLEND); - GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); - Block block = comp.getBlock(); - int meta = comp.getMeta(); - Minecraft.getMinecraft().renderEngine.bindTexture(TextureMap.locationBlocksTexture); - blockRender.useInventoryTint = false; - if(block == null) - return; - if(IMultiblockRenderHook.renderHooks.containsKey(block)) { - GL11.glColor4f(1F, 1F, 1F, alpha); - IMultiblockRenderHook renderHook = IMultiblockRenderHook.renderHooks.get(block); - if(renderHook.needsTranslate(block)) { - GL11.glTranslated(x + 0.5, y + 0.5, z + 0.5); - } - renderHook.renderBlockForMultiblock(blockAccess, mb, block, comp.getMeta(), blockRender, comp, alpha); - } - else { - if(comp.shouldDoFancyRender()) { - int color = block.colorMultiplier(blockAccess, x, y, z); - float red = (color >> 16 & 255) / 255.0F; - float green = (color >> 8 & 255) / 255.0F; - float blue = (color & 255) / 255.0F; - GL11.glColor4f(red, green, blue, alpha); - IBlockAccess oldBlockAccess = blockRender.blockAccess; - blockRender.blockAccess = blockAccess; - Tessellator tessellator = Tessellator.instance; - blockRender.renderAllFaces = true; - tessellator.startDrawingQuads(); - tessellator.disableColor(); - try { - blockRender.renderBlockByRenderType(block, x, y, z); - } - catch(Exception e) { - comp.doFancyRender = false; - } - tessellator.draw(); - blockRender.renderAllFaces = false; - blockRender.blockAccess = oldBlockAccess; - } - else { - int color = block.getRenderColor(meta); - float red = (color >> 16 & 255) / 255.0F; - float green = (color >> 8 & 255) / 255.0F; - float blue = (color & 255) / 255.0F; - GL11.glColor4f(red, green, blue, alpha); - GL11.glTranslated(x + 0.5, y + 0.5, z + 0.5); - blockRender.renderBlockAsItem(block, meta, 1F); - } - } - GL11.glColor4f(1F, 1F, 1F, 1F); - GL11.glEnable(GL11.GL_DEPTH_TEST); - GL11.glPopMatrix(); - } + public static boolean rendering = false; + + private static MultiblockBlockAccess blockAccess = new MultiblockBlockAccess(); + + private static RenderBlocks blockRender = RenderBlocks.getInstance(); + public static MultiblockSet currentMultiblock; + public static ChunkCoordinates anchor; + public static int angle; + public static int dimension; + + public static void setMultiblock(MultiblockSet set) { + currentMultiblock = set; + anchor = null; + angle = 0; + + Minecraft mc = Minecraft.getMinecraft(); + if (mc.theWorld != null) dimension = mc.theWorld.provider.dimensionId; + } + + @SubscribeEvent + public void onWorldRenderLast(RenderWorldLastEvent event) { + Minecraft mc = Minecraft.getMinecraft(); + if (mc.thePlayer != null && mc.objectMouseOver != null && (!mc.thePlayer.isSneaking() || anchor != null)) { + mc.thePlayer.getCurrentEquippedItem(); + renderPlayerLook(mc.thePlayer, mc.objectMouseOver); + } + } + + @SubscribeEvent + public void onPlayerInteract(PlayerInteractEvent event) { + if (currentMultiblock != null + && anchor == null + && event.action == Action.RIGHT_CLICK_BLOCK + && event.entityPlayer == Minecraft.getMinecraft().thePlayer) { + anchor = new ChunkCoordinates(event.x, event.y, event.z); + angle = MathHelper.floor_double(event.entityPlayer.rotationYaw * 4.0 / 360.0 + 0.5) & 3; + event.setCanceled(true); + } + } + + private void renderPlayerLook(EntityPlayer player, MovingObjectPosition src) { + if (currentMultiblock != null && dimension == player.worldObj.provider.dimensionId) { + int anchorX = anchor != null ? anchor.posX : src.blockX; + int anchorY = anchor != null ? anchor.posY : src.blockY; + int anchorZ = anchor != null ? anchor.posZ : src.blockZ; + + GL11.glPushMatrix(); + GL11.glPushAttrib(GL11.GL_LIGHTING); + GL11.glEnable(GL11.GL_BLEND); + GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); + GL11.glDisable(GL11.GL_LIGHTING); + rendering = true; + Multiblock mb = + anchor != null ? currentMultiblock.getForIndex(angle) : currentMultiblock.getForEntity(player); + boolean didAny = false; + + blockAccess.update(player.worldObj, mb, anchorX, anchorY, anchorZ); + + for (MultiblockComponent comp : mb.getComponents()) + if (renderComponentInWorld(player.worldObj, mb, comp, anchorX, anchorY, anchorZ)) didAny = true; + rendering = false; + GL11.glPopAttrib(); + GL11.glPopMatrix(); + + if (!didAny) { + setMultiblock(null); + player.addChatComponentMessage(new ChatComponentTranslation("botaniamisc.structureComplete") + .setChatStyle(new ChatStyle().setColor(EnumChatFormatting.GREEN))); + } + } + } + + private boolean renderComponentInWorld( + World world, Multiblock mb, MultiblockComponent comp, int anchorX, int anchorY, int anchorZ) { + ChunkCoordinates pos = comp.getRelativePosition(); + int x = pos.posX + anchorX; + int y = pos.posY + anchorY; + int z = pos.posZ + anchorZ; + if (anchor != null && comp.matches(world, x, y, z)) return false; + + GL11.glPushMatrix(); + GL11.glTranslated(-RenderManager.renderPosX, -RenderManager.renderPosY, -RenderManager.renderPosZ); + GL11.glDisable(GL11.GL_DEPTH_TEST); + doRenderComponent(mb, comp, x, y, z, 0.4F); + GL11.glPopMatrix(); + return true; + } + + public static void renderMultiblockOnPage(Multiblock mb) { + GL11.glTranslated(-0.5, -0.5, -0.5); + blockAccess.update(null, mb, mb.offX, mb.offY, mb.offZ); + for (MultiblockComponent comp : mb.getComponents()) { + ChunkCoordinates pos = comp.getRelativePosition(); + doRenderComponent(mb, comp, pos.posX + mb.offX, pos.posY + mb.offY, pos.posZ + mb.offZ, 1); + } + } + + private static void doRenderComponent(Multiblock mb, MultiblockComponent comp, int x, int y, int z, float alpha) { + GL11.glPushMatrix(); + GL11.glEnable(GL11.GL_BLEND); + GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); + Block block = comp.getBlock(); + int meta = comp.getMeta(); + Minecraft.getMinecraft().renderEngine.bindTexture(TextureMap.locationBlocksTexture); + blockRender.useInventoryTint = false; + if (block == null) return; + if (IMultiblockRenderHook.renderHooks.containsKey(block)) { + GL11.glColor4f(1F, 1F, 1F, alpha); + IMultiblockRenderHook renderHook = IMultiblockRenderHook.renderHooks.get(block); + if (renderHook.needsTranslate(block)) { + GL11.glTranslated(x + 0.5, y + 0.5, z + 0.5); + } + renderHook.renderBlockForMultiblock(blockAccess, mb, block, comp.getMeta(), blockRender, comp, alpha); + } else { + if (comp.shouldDoFancyRender()) { + int color = block.colorMultiplier(blockAccess, x, y, z); + float red = (color >> 16 & 255) / 255.0F; + float green = (color >> 8 & 255) / 255.0F; + float blue = (color & 255) / 255.0F; + GL11.glColor4f(red, green, blue, alpha); + IBlockAccess oldBlockAccess = blockRender.blockAccess; + blockRender.blockAccess = blockAccess; + Tessellator tessellator = Tessellator.instance; + blockRender.renderAllFaces = true; + tessellator.startDrawingQuads(); + tessellator.disableColor(); + try { + blockRender.renderBlockByRenderType(block, x, y, z); + } catch (Exception e) { + comp.doFancyRender = false; + } + tessellator.draw(); + blockRender.renderAllFaces = false; + blockRender.blockAccess = oldBlockAccess; + } else { + int color = block.getRenderColor(meta); + float red = (color >> 16 & 255) / 255.0F; + float green = (color >> 8 & 255) / 255.0F; + float blue = (color & 255) / 255.0F; + GL11.glColor4f(red, green, blue, alpha); + GL11.glTranslated(x + 0.5, y + 0.5, z + 0.5); + blockRender.renderBlockAsItem(block, meta, 1F); + } + } + GL11.glColor4f(1F, 1F, 1F, 1F); + GL11.glEnable(GL11.GL_DEPTH_TEST); + GL11.glPopMatrix(); + } } diff --git a/src/main/java/vazkii/botania/client/core/handler/PersistentVariableHelper.java b/src/main/java/vazkii/botania/client/core/handler/PersistentVariableHelper.java index 3cceab2437..b276cbf4ff 100644 --- a/src/main/java/vazkii/botania/client/core/handler/PersistentVariableHelper.java +++ b/src/main/java/vazkii/botania/client/core/handler/PersistentVariableHelper.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jun 24, 2015, 5:54:45 PM (GMT)] */ package vazkii.botania.client.core.handler; @@ -16,7 +16,6 @@ import java.io.IOException; import java.util.List; import java.util.Set; - import net.minecraft.nbt.CompressedStreamTools; import net.minecraft.nbt.NBTTagCompound; import vazkii.botania.client.challenge.Challenge; @@ -26,139 +25,131 @@ public final class PersistentVariableHelper { - private static final String TAG_FIRST_LOAD = "firstLoad"; - private static final String TAG_DOG = "dog"; - private static final String TAG_BOOKMARK_COUNT = "bookmarkCount"; - private static final String TAG_BOOKMARK_PREFIX = "bookmark"; - private static final String TAG_BOOKMARKS = "bookmarks"; - private static final String TAG_CHALLENGES = "challenges"; - private static final String TAG_LEXICON_NOTES = "lexiconNotes"; - private static final String TAG_LAST_BOTANIA_VERSION = "lastBotaniaVersion"; - - private static File cacheFile; - - public static boolean firstLoad = true; - public static boolean dog = true; - public static String lastBotaniaVersion = ""; - - public static void save() throws IOException { - NBTTagCompound cmp = new NBTTagCompound(); - - List bookmarks = GuiLexicon.bookmarks; - int count = bookmarks.size(); - cmp.setInteger(TAG_BOOKMARK_COUNT, count); - NBTTagCompound bookmarksCmp = new NBTTagCompound(); - for(int i = 0; i < count; i++) { - GuiLexicon lex = bookmarks.get(i); - NBTTagCompound bookmarkCmp = new NBTTagCompound(); - lex.serialize(bookmarkCmp); - bookmarksCmp.setTag(TAG_BOOKMARK_PREFIX + i, bookmarkCmp); - } - cmp.setTag(TAG_BOOKMARKS, bookmarksCmp); - - NBTTagCompound challengesCmp = new NBTTagCompound(); - for(Challenge c : ModChallenges.challengeLookup.values()) - c.writeToNBT(challengesCmp); - cmp.setTag(TAG_CHALLENGES, challengesCmp); - - NBTTagCompound notesCmp = new NBTTagCompound(); - for(String s : GuiLexicon.notes.keySet()) { - String note = GuiLexicon.notes.get(s); - if(note != null && !note.trim().isEmpty()) - notesCmp.setString(s, note); - } - cmp.setTag(TAG_LEXICON_NOTES, notesCmp); - - cmp.setBoolean(TAG_FIRST_LOAD, firstLoad); - cmp.setBoolean(TAG_DOG, dog); - cmp.setString(TAG_LAST_BOTANIA_VERSION, lastBotaniaVersion); - - injectNBTToFile(cmp, getCacheFile()); - } - - public static void load() throws IOException { - NBTTagCompound cmp = getCacheCompound(); - - int count = cmp.getInteger(TAG_BOOKMARK_COUNT); - GuiLexicon.bookmarks.clear(); - if(count > 0) { - NBTTagCompound bookmarksCmp = cmp.getCompoundTag(TAG_BOOKMARKS); - for(int i = 0; i < count; i++) { - NBTTagCompound bookmarkCmp = bookmarksCmp.getCompoundTag(TAG_BOOKMARK_PREFIX + i); - GuiLexicon gui = GuiLexicon.create(bookmarkCmp); - if(gui != null) { - GuiLexicon.bookmarks.add(gui); - GuiLexicon.bookmarkKeys.add(gui.getNotesKey()); - } - } - } - - if(cmp.hasKey(TAG_CHALLENGES)) { - NBTTagCompound challengesCmp = cmp.getCompoundTag(TAG_CHALLENGES); - for(Challenge c : ModChallenges.challengeLookup.values()) - c.readFromNBT(challengesCmp); - } - - if(cmp.hasKey(TAG_LEXICON_NOTES)) { - NBTTagCompound notesCmp = cmp.getCompoundTag(TAG_LEXICON_NOTES); - Set keys = notesCmp.func_150296_c(); - GuiLexicon.notes.clear(); - for(String key : keys) - GuiLexicon.notes.put(key, notesCmp.getString(key)); - } - - lastBotaniaVersion = cmp.hasKey(TAG_LAST_BOTANIA_VERSION) ? cmp.getString(TAG_LAST_BOTANIA_VERSION) : "(N/A)"; - - firstLoad = cmp.hasKey(TAG_FIRST_LOAD) ? cmp.getBoolean(TAG_FIRST_LOAD) : firstLoad; - if(firstLoad) - lastBotaniaVersion = LibMisc.VERSION; - - dog = cmp.getBoolean(TAG_DOG); - } - - public static void saveSafe() { - try { - save(); - } catch (IOException e) { - e.printStackTrace(); - } - } - - public static void setCacheFile(File f) { - cacheFile = f; - } - - public static File getCacheFile() throws IOException { - if(!cacheFile.exists()) - cacheFile.createNewFile(); - - return cacheFile; - } - - public static NBTTagCompound getCacheCompound() throws IOException { - return getCacheCompound(getCacheFile()); - } - - public static NBTTagCompound getCacheCompound(File cache) throws IOException { - if(cache == null) - throw new RuntimeException("No cache file!"); - - try { - NBTTagCompound cmp = CompressedStreamTools.readCompressed(new FileInputStream(cache)); - return cmp; - } catch(IOException e) { - NBTTagCompound cmp = new NBTTagCompound(); - CompressedStreamTools.writeCompressed(cmp, new FileOutputStream(cache)); - return getCacheCompound(cache); - } - } - - public static void injectNBTToFile(NBTTagCompound cmp, File f) { - try { - CompressedStreamTools.writeCompressed(cmp, new FileOutputStream(f)); - } catch(IOException e) { - e.printStackTrace(); - } - } - + private static final String TAG_FIRST_LOAD = "firstLoad"; + private static final String TAG_DOG = "dog"; + private static final String TAG_BOOKMARK_COUNT = "bookmarkCount"; + private static final String TAG_BOOKMARK_PREFIX = "bookmark"; + private static final String TAG_BOOKMARKS = "bookmarks"; + private static final String TAG_CHALLENGES = "challenges"; + private static final String TAG_LEXICON_NOTES = "lexiconNotes"; + private static final String TAG_LAST_BOTANIA_VERSION = "lastBotaniaVersion"; + + private static File cacheFile; + + public static boolean firstLoad = true; + public static boolean dog = true; + public static String lastBotaniaVersion = ""; + + public static void save() throws IOException { + NBTTagCompound cmp = new NBTTagCompound(); + + List bookmarks = GuiLexicon.bookmarks; + int count = bookmarks.size(); + cmp.setInteger(TAG_BOOKMARK_COUNT, count); + NBTTagCompound bookmarksCmp = new NBTTagCompound(); + for (int i = 0; i < count; i++) { + GuiLexicon lex = bookmarks.get(i); + NBTTagCompound bookmarkCmp = new NBTTagCompound(); + lex.serialize(bookmarkCmp); + bookmarksCmp.setTag(TAG_BOOKMARK_PREFIX + i, bookmarkCmp); + } + cmp.setTag(TAG_BOOKMARKS, bookmarksCmp); + + NBTTagCompound challengesCmp = new NBTTagCompound(); + for (Challenge c : ModChallenges.challengeLookup.values()) c.writeToNBT(challengesCmp); + cmp.setTag(TAG_CHALLENGES, challengesCmp); + + NBTTagCompound notesCmp = new NBTTagCompound(); + for (String s : GuiLexicon.notes.keySet()) { + String note = GuiLexicon.notes.get(s); + if (note != null && !note.trim().isEmpty()) notesCmp.setString(s, note); + } + cmp.setTag(TAG_LEXICON_NOTES, notesCmp); + + cmp.setBoolean(TAG_FIRST_LOAD, firstLoad); + cmp.setBoolean(TAG_DOG, dog); + cmp.setString(TAG_LAST_BOTANIA_VERSION, lastBotaniaVersion); + + injectNBTToFile(cmp, getCacheFile()); + } + + public static void load() throws IOException { + NBTTagCompound cmp = getCacheCompound(); + + int count = cmp.getInteger(TAG_BOOKMARK_COUNT); + GuiLexicon.bookmarks.clear(); + if (count > 0) { + NBTTagCompound bookmarksCmp = cmp.getCompoundTag(TAG_BOOKMARKS); + for (int i = 0; i < count; i++) { + NBTTagCompound bookmarkCmp = bookmarksCmp.getCompoundTag(TAG_BOOKMARK_PREFIX + i); + GuiLexicon gui = GuiLexicon.create(bookmarkCmp); + if (gui != null) { + GuiLexicon.bookmarks.add(gui); + GuiLexicon.bookmarkKeys.add(gui.getNotesKey()); + } + } + } + + if (cmp.hasKey(TAG_CHALLENGES)) { + NBTTagCompound challengesCmp = cmp.getCompoundTag(TAG_CHALLENGES); + for (Challenge c : ModChallenges.challengeLookup.values()) c.readFromNBT(challengesCmp); + } + + if (cmp.hasKey(TAG_LEXICON_NOTES)) { + NBTTagCompound notesCmp = cmp.getCompoundTag(TAG_LEXICON_NOTES); + Set keys = notesCmp.func_150296_c(); + GuiLexicon.notes.clear(); + for (String key : keys) GuiLexicon.notes.put(key, notesCmp.getString(key)); + } + + lastBotaniaVersion = cmp.hasKey(TAG_LAST_BOTANIA_VERSION) ? cmp.getString(TAG_LAST_BOTANIA_VERSION) : "(N/A)"; + + firstLoad = cmp.hasKey(TAG_FIRST_LOAD) ? cmp.getBoolean(TAG_FIRST_LOAD) : firstLoad; + if (firstLoad) lastBotaniaVersion = LibMisc.VERSION; + + dog = cmp.getBoolean(TAG_DOG); + } + + public static void saveSafe() { + try { + save(); + } catch (IOException e) { + e.printStackTrace(); + } + } + + public static void setCacheFile(File f) { + cacheFile = f; + } + + public static File getCacheFile() throws IOException { + if (!cacheFile.exists()) cacheFile.createNewFile(); + + return cacheFile; + } + + public static NBTTagCompound getCacheCompound() throws IOException { + return getCacheCompound(getCacheFile()); + } + + public static NBTTagCompound getCacheCompound(File cache) throws IOException { + if (cache == null) throw new RuntimeException("No cache file!"); + + try { + NBTTagCompound cmp = CompressedStreamTools.readCompressed(new FileInputStream(cache)); + return cmp; + } catch (IOException e) { + NBTTagCompound cmp = new NBTTagCompound(); + CompressedStreamTools.writeCompressed(cmp, new FileOutputStream(cache)); + return getCacheCompound(cache); + } + } + + public static void injectNBTToFile(NBTTagCompound cmp, File f) { + try { + CompressedStreamTools.writeCompressed(cmp, new FileOutputStream(f)); + } catch (IOException e) { + e.printStackTrace(); + } + } } diff --git a/src/main/java/vazkii/botania/client/core/handler/RedStringRenderer.java b/src/main/java/vazkii/botania/client/core/handler/RedStringRenderer.java index fdcd0a268a..a67d0afa42 100644 --- a/src/main/java/vazkii/botania/client/core/handler/RedStringRenderer.java +++ b/src/main/java/vazkii/botania/client/core/handler/RedStringRenderer.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Nov 14, 2014, 7:05:32 PM (GMT)] */ package vazkii.botania.client.core.handler; @@ -13,101 +13,104 @@ import java.util.ArrayDeque; import java.util.Queue; import java.util.Random; - import net.minecraft.client.Minecraft; import net.minecraft.client.renderer.Tessellator; import net.minecraft.client.renderer.entity.RenderManager; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.util.ChunkCoordinates; import net.minecraftforge.common.util.ForgeDirection; - import org.lwjgl.opengl.GL11; - import vazkii.botania.common.block.tile.string.TileRedString; import vazkii.botania.common.core.helper.Vector3; import vazkii.botania.common.item.ModItems; public final class RedStringRenderer { - public static final Queue redStringTiles = new ArrayDeque(); - static float sizeAlpha = 0F; - - public static void renderAll() { - if(!redStringTiles.isEmpty()) { - GL11.glPushMatrix(); - GL11.glDisable(GL11.GL_TEXTURE_2D); - GL11.glEnable(GL11.GL_BLEND); - GL11.glPushAttrib(GL11.GL_LIGHTING); - GL11.glDisable(GL11.GL_LIGHTING); - GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); - GL11.glColor4f(1F, 0F, 0F, sizeAlpha); - - Tessellator.renderingWorldRenderer = false; - TileRedString tile; - while((tile = redStringTiles.poll()) != null) - renderTile(tile); - - GL11.glEnable(GL11.GL_TEXTURE_2D); - GL11.glDisable(GL11.GL_BLEND); - GL11.glPopAttrib(); - GL11.glPopMatrix(); - - } - } - - public static void tick() { - EntityPlayer player = Minecraft.getMinecraft().thePlayer; - boolean hasWand = player != null && player.getCurrentEquippedItem() != null && player.getCurrentEquippedItem().getItem() == ModItems.twigWand; - if(sizeAlpha > 0F && !hasWand) - sizeAlpha -= 0.1F; - else if(sizeAlpha < 1F &&hasWand) - sizeAlpha += 0.1F; - } - - private static void renderTile(TileRedString tile) { - ForgeDirection dir = ForgeDirection.getOrientation(tile.getBlockMetadata()); - ChunkCoordinates bind = tile.getBinding(); - - if(bind != null) { - GL11.glPushMatrix(); - GL11.glTranslated(tile.xCoord + 0.5 - RenderManager.renderPosX, tile.yCoord + 0.5 - RenderManager.renderPosY, tile.zCoord + 0.5 - RenderManager.renderPosZ); - Vector3 vecOrig = new Vector3(bind.posX - tile.xCoord, bind.posY - tile.yCoord, bind.posZ - tile.zCoord); - Vector3 vecNorm = vecOrig.copy().normalize(); - Vector3 vecMag = vecNorm.copy().multiply(0.025); - Vector3 vecApply = vecMag.copy(); - - int stages = (int) (vecOrig.mag() / vecMag.mag()); - - Tessellator tessellator = Tessellator.instance; - GL11.glLineWidth(1F); - tessellator.startDrawing(GL11.GL_LINES); - - double len = (double) -ClientTickHandler.ticksInGame / 100F + new Random(dir.ordinal() ^ tile.xCoord ^ tile.yCoord ^ tile.zCoord).nextInt(10000); - double add = vecMag.mag(); - double rand = Math.random() - 0.5; - for(int i = 0; i < stages; i++) { - addVertexAtWithTranslation(tessellator, dir, vecApply.x, vecApply.y, vecApply.z, rand, len); - rand = Math.random() - 0.5; - vecApply.add(vecMag); - len += add; - addVertexAtWithTranslation(tessellator, dir, vecApply.x, vecApply.y, vecApply.z, rand, len); - } - - tessellator.draw(); - - GL11.glPopMatrix(); - } - } - - private static void addVertexAtWithTranslation(Tessellator tess, ForgeDirection dir, double xpos, double ypos, double zpos, double rand, double l) { - double freq = 20; - double ampl = (0.15 * (Math.sin(l * 2F) * 0.5 + 0.5) + 0.1) * sizeAlpha; - double randMul = 0.05; - double x = xpos + Math.sin(l * freq) * ampl * Math.abs(Math.abs(dir.offsetX) - 1) + rand * randMul; - double y = ypos + Math.cos(l * freq) * ampl * Math.abs(Math.abs(dir.offsetY) - 1) + rand * randMul; - double z = zpos + (dir.offsetY == 0 ? Math.sin(l * freq) : Math.cos(l * freq)) * ampl * Math.abs(Math.abs(dir.offsetZ) - 1) + rand * randMul; - - tess.addVertex(x, y, z); - } - + public static final Queue redStringTiles = new ArrayDeque(); + static float sizeAlpha = 0F; + + public static void renderAll() { + if (!redStringTiles.isEmpty()) { + GL11.glPushMatrix(); + GL11.glDisable(GL11.GL_TEXTURE_2D); + GL11.glEnable(GL11.GL_BLEND); + GL11.glPushAttrib(GL11.GL_LIGHTING); + GL11.glDisable(GL11.GL_LIGHTING); + GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); + GL11.glColor4f(1F, 0F, 0F, sizeAlpha); + + Tessellator.renderingWorldRenderer = false; + TileRedString tile; + while ((tile = redStringTiles.poll()) != null) renderTile(tile); + + GL11.glEnable(GL11.GL_TEXTURE_2D); + GL11.glDisable(GL11.GL_BLEND); + GL11.glPopAttrib(); + GL11.glPopMatrix(); + } + } + + public static void tick() { + EntityPlayer player = Minecraft.getMinecraft().thePlayer; + boolean hasWand = player != null + && player.getCurrentEquippedItem() != null + && player.getCurrentEquippedItem().getItem() == ModItems.twigWand; + if (sizeAlpha > 0F && !hasWand) sizeAlpha -= 0.1F; + else if (sizeAlpha < 1F && hasWand) sizeAlpha += 0.1F; + } + + private static void renderTile(TileRedString tile) { + ForgeDirection dir = ForgeDirection.getOrientation(tile.getBlockMetadata()); + ChunkCoordinates bind = tile.getBinding(); + + if (bind != null) { + GL11.glPushMatrix(); + GL11.glTranslated( + tile.xCoord + 0.5 - RenderManager.renderPosX, + tile.yCoord + 0.5 - RenderManager.renderPosY, + tile.zCoord + 0.5 - RenderManager.renderPosZ); + Vector3 vecOrig = new Vector3(bind.posX - tile.xCoord, bind.posY - tile.yCoord, bind.posZ - tile.zCoord); + Vector3 vecNorm = vecOrig.copy().normalize(); + Vector3 vecMag = vecNorm.copy().multiply(0.025); + Vector3 vecApply = vecMag.copy(); + + int stages = (int) (vecOrig.mag() / vecMag.mag()); + + Tessellator tessellator = Tessellator.instance; + GL11.glLineWidth(1F); + tessellator.startDrawing(GL11.GL_LINES); + + double len = (double) -ClientTickHandler.ticksInGame / 100F + + new Random(dir.ordinal() ^ tile.xCoord ^ tile.yCoord ^ tile.zCoord).nextInt(10000); + double add = vecMag.mag(); + double rand = Math.random() - 0.5; + for (int i = 0; i < stages; i++) { + addVertexAtWithTranslation(tessellator, dir, vecApply.x, vecApply.y, vecApply.z, rand, len); + rand = Math.random() - 0.5; + vecApply.add(vecMag); + len += add; + addVertexAtWithTranslation(tessellator, dir, vecApply.x, vecApply.y, vecApply.z, rand, len); + } + + tessellator.draw(); + + GL11.glPopMatrix(); + } + } + + private static void addVertexAtWithTranslation( + Tessellator tess, ForgeDirection dir, double xpos, double ypos, double zpos, double rand, double l) { + double freq = 20; + double ampl = (0.15 * (Math.sin(l * 2F) * 0.5 + 0.5) + 0.1) * sizeAlpha; + double randMul = 0.05; + double x = xpos + Math.sin(l * freq) * ampl * Math.abs(Math.abs(dir.offsetX) - 1) + rand * randMul; + double y = ypos + Math.cos(l * freq) * ampl * Math.abs(Math.abs(dir.offsetY) - 1) + rand * randMul; + double z = zpos + + (dir.offsetY == 0 ? Math.sin(l * freq) : Math.cos(l * freq)) + * ampl + * Math.abs(Math.abs(dir.offsetZ) - 1) + + rand * randMul; + + tess.addVertex(x, y, z); + } } diff --git a/src/main/java/vazkii/botania/client/core/handler/SubTileRadiusRenderHandler.java b/src/main/java/vazkii/botania/client/core/handler/SubTileRadiusRenderHandler.java index ca13332237..5bc5f7cc61 100644 --- a/src/main/java/vazkii/botania/client/core/handler/SubTileRadiusRenderHandler.java +++ b/src/main/java/vazkii/botania/client/core/handler/SubTileRadiusRenderHandler.java @@ -2,16 +2,16 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Mar 31, 2015, 3:16:02 PM (GMT)] */ package vazkii.botania.client.core.handler; +import cpw.mods.fml.common.eventhandler.SubscribeEvent; import java.awt.Color; - import net.minecraft.client.Minecraft; import net.minecraft.client.renderer.Tessellator; import net.minecraft.client.renderer.entity.RenderManager; @@ -21,147 +21,141 @@ import net.minecraft.util.ChunkCoordinates; import net.minecraft.util.MovingObjectPosition; import net.minecraftforge.client.event.RenderWorldLastEvent; - import org.lwjgl.opengl.GL11; - import vazkii.botania.api.subtile.ISubTileContainer; import vazkii.botania.api.subtile.RadiusDescriptor; import vazkii.botania.api.subtile.SubTileEntity; import vazkii.botania.common.Botania; import vazkii.botania.common.item.ItemTwigWand; import vazkii.botania.common.item.ModItems; -import cpw.mods.fml.common.eventhandler.SubscribeEvent; public final class SubTileRadiusRenderHandler { - @SubscribeEvent - public void onWorldRenderLast(RenderWorldLastEvent event) { - Minecraft mc = Minecraft.getMinecraft(); - MovingObjectPosition pos = mc.objectMouseOver; - - if(!Botania.proxy.isClientPlayerWearingMonocle() || pos == null || pos.entityHit != null) - return; - int x = pos.blockX; - int y = pos.blockY; - int z = pos.blockZ; - - ItemStack stackHeld = mc.thePlayer.getCurrentEquippedItem(); - if(stackHeld != null && stackHeld.getItem() == ModItems.twigWand && ItemTwigWand.getBindMode(stackHeld)) { - ChunkCoordinates coords = ItemTwigWand.getBoundTile(stackHeld); - if(coords.posY != -1) { - x = coords.posX; - y = coords.posY; - z = coords.posZ; - } - } - - TileEntity tile = mc.theWorld.getTileEntity(x, y, z); - if(tile == null || !(tile instanceof ISubTileContainer)) - return; - ISubTileContainer container = (ISubTileContainer) tile; - SubTileEntity subtile = container.getSubTile(); - if(subtile == null) - return; - RadiusDescriptor descriptor = subtile.getRadius(); - if(descriptor == null) - return; - - GL11.glPushMatrix(); - GL11.glDisable(GL11.GL_TEXTURE_2D); - GL11.glPushAttrib(GL11.GL_LIGHTING); - GL11.glDisable(GL11.GL_LIGHTING); - GL11.glEnable(GL11.GL_BLEND); - GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); - Tessellator.renderingWorldRenderer = false; - - if(descriptor.isCircle()) - renderCircle(descriptor.getSubtileCoords(), descriptor.getCircleRadius()); - else renderRectangle(descriptor.getAABB()); - - GL11.glEnable(GL11.GL_TEXTURE_2D); - GL11.glDisable(GL11.GL_BLEND); - GL11.glPopAttrib(); - GL11.glPopMatrix(); - } - - public void renderRectangle(AxisAlignedBB aabb) { - GL11.glPushMatrix(); - GL11.glTranslated(aabb.minX - RenderManager.renderPosX, aabb.minY - RenderManager.renderPosY, aabb.minZ - RenderManager.renderPosZ); - int color = Color.HSBtoRGB(ClientTickHandler.ticksInGame % 200 / 200F, 0.6F, 1F); - - Color colorRGB = new Color(color); - GL11.glColor4ub((byte) colorRGB.getRed(), (byte) colorRGB.getGreen(), (byte) colorRGB.getBlue(), (byte) 32); - - double f = 1F / 16F; - double x = aabb.maxX - aabb.minX - f; - double z = aabb.maxZ - aabb.minZ - f; - - Tessellator tessellator = Tessellator.instance; - tessellator.startDrawingQuads(); - tessellator.addVertex(x, f, f); - tessellator.addVertex(f, f, f); - tessellator.addVertex(f, f, z); - tessellator.addVertex(x, f, z); - tessellator.draw(); - - x += f; - z += f; - double f1 = f + f / 4F; - GL11.glColor4ub((byte) colorRGB.getRed(), (byte) colorRGB.getGreen(), (byte) colorRGB.getBlue(), (byte) 64); - tessellator.startDrawingQuads(); - tessellator.addVertex(x, f1, 0); - tessellator.addVertex(0, f1, 0); - tessellator.addVertex(0, f1, z); - tessellator.addVertex(x, f1, z); - tessellator.draw(); - - GL11.glPopMatrix(); - } - - public void renderCircle(ChunkCoordinates center, double radius) { - GL11.glPushMatrix(); - double x = center.posX + 0.5; - double y = center.posY; - double z = center.posZ + 0.5; - GL11.glTranslated(x - RenderManager.renderPosX, y - RenderManager.renderPosY, z - RenderManager.renderPosZ); - int color = Color.HSBtoRGB(ClientTickHandler.ticksInGame % 200 / 200F, 0.6F, 1F); - - Color colorRGB = new Color(color); - GL11.glColor4ub((byte) colorRGB.getRed(), (byte) colorRGB.getGreen(), (byte) colorRGB.getBlue(), (byte) 32); - - double f = 1F / 16F; - - int totalAngles = 360; - int drawAngles = 360; - int step = totalAngles / drawAngles; - - radius -= f; - Tessellator tessellator = Tessellator.instance; - tessellator.startDrawing(GL11.GL_TRIANGLE_FAN); - tessellator.addVertex(0, f, 0); - for(int i = 0; i < totalAngles + 1; i += step) { - double rad = (totalAngles - i) * Math.PI / 180.0; - double xp = Math.cos(rad) * radius; - double zp = Math.sin(rad) * radius; - tessellator.addVertex(xp, f, zp); - } - tessellator.addVertex(0, f, 0); - tessellator.draw(); - - radius += f; - double f1 = f + f / 4F; - GL11.glColor4ub((byte) colorRGB.getRed(), (byte) colorRGB.getGreen(), (byte) colorRGB.getBlue(), (byte) 64); - tessellator.startDrawing(GL11.GL_TRIANGLE_FAN); - tessellator.addVertex(0, f1, 0); - for(int i = 0; i < totalAngles + 1; i += step) { - double rad = (totalAngles - i) * Math.PI / 180.0; - double xp = Math.cos(rad) * radius; - double zp = Math.sin(rad) * radius; - tessellator.addVertex(xp, f1, zp); - } - tessellator.addVertex(0, f1, 0); - tessellator.draw(); - GL11.glPopMatrix(); - } - + @SubscribeEvent + public void onWorldRenderLast(RenderWorldLastEvent event) { + Minecraft mc = Minecraft.getMinecraft(); + MovingObjectPosition pos = mc.objectMouseOver; + + if (!Botania.proxy.isClientPlayerWearingMonocle() || pos == null || pos.entityHit != null) return; + int x = pos.blockX; + int y = pos.blockY; + int z = pos.blockZ; + + ItemStack stackHeld = mc.thePlayer.getCurrentEquippedItem(); + if (stackHeld != null && stackHeld.getItem() == ModItems.twigWand && ItemTwigWand.getBindMode(stackHeld)) { + ChunkCoordinates coords = ItemTwigWand.getBoundTile(stackHeld); + if (coords.posY != -1) { + x = coords.posX; + y = coords.posY; + z = coords.posZ; + } + } + + TileEntity tile = mc.theWorld.getTileEntity(x, y, z); + if (tile == null || !(tile instanceof ISubTileContainer)) return; + ISubTileContainer container = (ISubTileContainer) tile; + SubTileEntity subtile = container.getSubTile(); + if (subtile == null) return; + RadiusDescriptor descriptor = subtile.getRadius(); + if (descriptor == null) return; + + GL11.glPushMatrix(); + GL11.glDisable(GL11.GL_TEXTURE_2D); + GL11.glPushAttrib(GL11.GL_LIGHTING); + GL11.glDisable(GL11.GL_LIGHTING); + GL11.glEnable(GL11.GL_BLEND); + GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); + Tessellator.renderingWorldRenderer = false; + + if (descriptor.isCircle()) renderCircle(descriptor.getSubtileCoords(), descriptor.getCircleRadius()); + else renderRectangle(descriptor.getAABB()); + + GL11.glEnable(GL11.GL_TEXTURE_2D); + GL11.glDisable(GL11.GL_BLEND); + GL11.glPopAttrib(); + GL11.glPopMatrix(); + } + + public void renderRectangle(AxisAlignedBB aabb) { + GL11.glPushMatrix(); + GL11.glTranslated( + aabb.minX - RenderManager.renderPosX, + aabb.minY - RenderManager.renderPosY, + aabb.minZ - RenderManager.renderPosZ); + int color = Color.HSBtoRGB(ClientTickHandler.ticksInGame % 200 / 200F, 0.6F, 1F); + + Color colorRGB = new Color(color); + GL11.glColor4ub((byte) colorRGB.getRed(), (byte) colorRGB.getGreen(), (byte) colorRGB.getBlue(), (byte) 32); + + double f = 1F / 16F; + double x = aabb.maxX - aabb.minX - f; + double z = aabb.maxZ - aabb.minZ - f; + + Tessellator tessellator = Tessellator.instance; + tessellator.startDrawingQuads(); + tessellator.addVertex(x, f, f); + tessellator.addVertex(f, f, f); + tessellator.addVertex(f, f, z); + tessellator.addVertex(x, f, z); + tessellator.draw(); + + x += f; + z += f; + double f1 = f + f / 4F; + GL11.glColor4ub((byte) colorRGB.getRed(), (byte) colorRGB.getGreen(), (byte) colorRGB.getBlue(), (byte) 64); + tessellator.startDrawingQuads(); + tessellator.addVertex(x, f1, 0); + tessellator.addVertex(0, f1, 0); + tessellator.addVertex(0, f1, z); + tessellator.addVertex(x, f1, z); + tessellator.draw(); + + GL11.glPopMatrix(); + } + + public void renderCircle(ChunkCoordinates center, double radius) { + GL11.glPushMatrix(); + double x = center.posX + 0.5; + double y = center.posY; + double z = center.posZ + 0.5; + GL11.glTranslated(x - RenderManager.renderPosX, y - RenderManager.renderPosY, z - RenderManager.renderPosZ); + int color = Color.HSBtoRGB(ClientTickHandler.ticksInGame % 200 / 200F, 0.6F, 1F); + + Color colorRGB = new Color(color); + GL11.glColor4ub((byte) colorRGB.getRed(), (byte) colorRGB.getGreen(), (byte) colorRGB.getBlue(), (byte) 32); + + double f = 1F / 16F; + + int totalAngles = 360; + int drawAngles = 360; + int step = totalAngles / drawAngles; + + radius -= f; + Tessellator tessellator = Tessellator.instance; + tessellator.startDrawing(GL11.GL_TRIANGLE_FAN); + tessellator.addVertex(0, f, 0); + for (int i = 0; i < totalAngles + 1; i += step) { + double rad = (totalAngles - i) * Math.PI / 180.0; + double xp = Math.cos(rad) * radius; + double zp = Math.sin(rad) * radius; + tessellator.addVertex(xp, f, zp); + } + tessellator.addVertex(0, f, 0); + tessellator.draw(); + + radius += f; + double f1 = f + f / 4F; + GL11.glColor4ub((byte) colorRGB.getRed(), (byte) colorRGB.getGreen(), (byte) colorRGB.getBlue(), (byte) 64); + tessellator.startDrawing(GL11.GL_TRIANGLE_FAN); + tessellator.addVertex(0, f1, 0); + for (int i = 0; i < totalAngles + 1; i += step) { + double rad = (totalAngles - i) * Math.PI / 180.0; + double xp = Math.cos(rad) * radius; + double zp = Math.sin(rad) * radius; + tessellator.addVertex(xp, f1, zp); + } + tessellator.addVertex(0, f1, 0); + tessellator.draw(); + GL11.glPopMatrix(); + } } diff --git a/src/main/java/vazkii/botania/client/core/handler/TooltipAdditionDisplayHandler.java b/src/main/java/vazkii/botania/client/core/handler/TooltipAdditionDisplayHandler.java index e7e7b8337a..5b3c789ac0 100644 --- a/src/main/java/vazkii/botania/client/core/handler/TooltipAdditionDisplayHandler.java +++ b/src/main/java/vazkii/botania/client/core/handler/TooltipAdditionDisplayHandler.java @@ -2,18 +2,18 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Apr 23, 2015, 4:24:56 PM (GMT)] */ package vazkii.botania.client.core.handler; +import cpw.mods.fml.relauncher.ReflectionHelper; import java.awt.Color; import java.util.ArrayList; import java.util.List; - import net.minecraft.client.Minecraft; import net.minecraft.client.gui.FontRenderer; import net.minecraft.client.gui.Gui; @@ -26,10 +26,8 @@ import net.minecraft.item.ItemStack; import net.minecraft.util.EnumChatFormatting; import net.minecraft.util.StatCollector; - import org.lwjgl.input.Mouse; import org.lwjgl.opengl.GL11; - import vazkii.botania.api.lexicon.ILexicon; import vazkii.botania.api.lexicon.LexiconRecipeMappings; import vazkii.botania.api.lexicon.LexiconRecipeMappings.EntryData; @@ -40,171 +38,223 @@ import vazkii.botania.common.item.ModItems; import vazkii.botania.common.item.equipment.tool.terrasteel.ItemTerraPick; import vazkii.botania.common.lib.LibObfuscation; -import cpw.mods.fml.relauncher.ReflectionHelper; public final class TooltipAdditionDisplayHandler { - private static float lexiconLookupTime = 0F; - - public static void render() { - Minecraft mc = Minecraft.getMinecraft(); - GuiScreen gui = mc.currentScreen; - if(gui != null && gui instanceof GuiContainer && mc.thePlayer != null && mc.thePlayer.inventory.getItemStack() == null) { - GuiContainer container = (GuiContainer) gui; - Slot slot = ReflectionHelper.getPrivateValue(GuiContainer.class, container, LibObfuscation.THE_SLOT); - if(slot != null && slot.getHasStack()) { - ItemStack stack = slot.getStack(); - if(stack != null) { - ScaledResolution res = new ScaledResolution(mc, mc.displayWidth, mc.displayHeight); - FontRenderer font = mc.fontRenderer; - int mouseX = Mouse.getX() * res.getScaledWidth() / mc.displayWidth; - int mouseY = res.getScaledHeight() - Mouse.getY() * res.getScaledHeight() / mc.displayHeight; - - List tooltip; - try { - tooltip = stack.getTooltip(mc.thePlayer, mc.gameSettings.advancedItemTooltips); - } catch(Exception e) { - tooltip = new ArrayList(); - } - int width = 0; - for(String s : tooltip) - width = Math.max(width, font.getStringWidth(s) + 2); - int tooltipHeight = (tooltip.size() - 1) * 10 + 5; - - int height = 3; - int offx = 11; - int offy = 17; - - boolean offscreen = mouseX + width + 19 >= res.getScaledWidth(); - - int fixY = res.getScaledHeight() - (mouseY + tooltipHeight); - if(fixY < 0) - offy -= fixY; - if(offscreen) - offx = -13 - width; - - if(stack.getItem() instanceof ItemTerraPick) - drawTerraPick(stack, mouseX, mouseY, offx, offy, width, height, font); - else if(stack.getItem() instanceof IManaTooltipDisplay) - drawManaBar(stack, (IManaTooltipDisplay) stack.getItem(), mouseX, mouseY, offx, offy, width, height); - - EntryData data = LexiconRecipeMappings.getDataForStack(stack); - if(data != null) { - int lexSlot = -1; - ItemStack lexiconStack = null; - - for(int i = 0; i < InventoryPlayer.getHotbarSize(); i++) { - ItemStack stackAt = mc.thePlayer.inventory.getStackInSlot(i); - if(stackAt != null && stackAt.getItem() instanceof ILexicon && ((ILexicon) stackAt.getItem()).isKnowledgeUnlocked(stackAt, data.entry.getKnowledgeType())) { - lexiconStack = stackAt; - lexSlot = i; - break; - } - } - - if(lexSlot > -1) { - int x = mouseX + offx - 34; - int y = mouseY - offy; - GL11.glDisable(GL11.GL_DEPTH_TEST); - - Gui.drawRect(x - 4, y - 4, x + 20, y + 26, 0x44000000); - Gui.drawRect(x - 6, y - 6, x + 22, y + 28, 0x44000000); - - if(ConfigHandler.useShiftForQuickLookup ? GuiScreen.isShiftKeyDown() : GuiScreen.isCtrlKeyDown()) { - lexiconLookupTime += ClientTickHandler.delta; - - int cx = x + 8; - int cy = y + 8; - float r = 12; - float time = 20F; - float angles = lexiconLookupTime / time * 360F; - - GL11.glDisable(GL11.GL_LIGHTING); - GL11.glDisable(GL11.GL_TEXTURE_2D); - GL11.glShadeModel(GL11.GL_SMOOTH); - GL11.glEnable(GL11.GL_BLEND); - GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); - GL11.glBegin(GL11.GL_TRIANGLE_FAN); - - float a = 0.5F + 0.2F * ((float) Math.cos((double) (ClientTickHandler.ticksInGame + ClientTickHandler.partialTicks) / 10) * 0.5F + 0.5F); - GL11.glColor4f(0F, 0.5F, 0F, a); - GL11.glVertex2i(cx, cy); - GL11.glColor4f(0F, 1F, 0F, 1F); - - for(float i = angles; i > 0; i--) { - double rad = (i - 90) / 180F * Math.PI; - GL11.glVertex2d(cx + Math.cos(rad) * r, cy + Math.sin(rad) * r); - } - GL11.glVertex2i(cx, cy); - GL11.glEnd(); - - GL11.glDisable(GL11.GL_BLEND); - GL11.glEnable(GL11.GL_TEXTURE_2D); - GL11.glShadeModel(GL11.GL_FLAT); - - if(lexiconLookupTime >= time) { - mc.thePlayer.inventory.currentItem = lexSlot; - Botania.proxy.setEntryToOpen(data.entry); - Botania.proxy.setLexiconStack(lexiconStack); - mc.thePlayer.closeScreen(); - ItemLexicon.openBook(mc.thePlayer, lexiconStack, mc.theWorld, false); - - } - } else lexiconLookupTime = 0F; - - RenderItem.getInstance().renderItemIntoGUI(mc.fontRenderer, mc.renderEngine, new ItemStack(ModItems.lexicon), x, y); - GL11.glDisable(GL11.GL_LIGHTING); - - font.drawStringWithShadow("?", x + 10, y + 8, 0xFFFFFFFF); - GL11.glScalef(0.5F, 0.5F, 1F); - boolean mac = Minecraft.isRunningOnMac; - mc.fontRenderer.drawStringWithShadow(EnumChatFormatting.BOLD + (ConfigHandler.useShiftForQuickLookup ? "Shift" : mac ? "Cmd" : "Ctrl"), (x + 10) * 2 - 16, (y + 8) * 2 + 20, 0xFFFFFFFF); - GL11.glScalef(2F, 2F, 1F); - - GL11.glEnable(GL11.GL_DEPTH_TEST); - } else lexiconLookupTime = 0F; - } else lexiconLookupTime = 0F; - } else lexiconLookupTime = 0F; - } else lexiconLookupTime = 0F; - } else lexiconLookupTime = 0F; - } - - private static void drawTerraPick(ItemStack stack, int mouseX, int mouseY, int offx, int offy, int width, int height, FontRenderer font) { - int level = ItemTerraPick.getLevel(stack); - int max = ItemTerraPick.LEVELS[Math.min(ItemTerraPick.LEVELS.length - 1, level + 1)]; - boolean ss = level >= ItemTerraPick.LEVELS.length - 1; - int curr = ItemTerraPick.getMana_(stack); - float percent = level == 0 ? 0F : (float) curr / (float) max; - int rainbowWidth = Math.min(width - (ss ? 0 : 1), (int) (width * percent)); - float huePer = width == 0 ? 0F : 1F / width; - float hueOff = (ClientTickHandler.ticksInGame + ClientTickHandler.partialTicks) * 0.01F; - - GL11.glDisable(GL11.GL_DEPTH_TEST); - Gui.drawRect(mouseX + offx - 1, mouseY - offy - height - 1, mouseX + offx + width + 1, mouseY - offy, 0xFF000000); - for(int i = 0; i < rainbowWidth; i++) - Gui.drawRect(mouseX + offx + i, mouseY - offy - height, mouseX + offx + i + 1, mouseY - offy, Color.HSBtoRGB(hueOff + huePer * i, 1F, 1F)); - Gui.drawRect(mouseX + offx + rainbowWidth, mouseY - offy - height, mouseX + offx + width, mouseY - offy, 0xFF555555); - - String rank = StatCollector.translateToLocal("botania.rank" + level).replaceAll("&", "\u00a7"); - GL11.glPushAttrib(GL11.GL_LIGHTING); - GL11.glDisable(GL11.GL_LIGHTING); - font.drawStringWithShadow(rank, mouseX + offx, mouseY - offy - 12, 0xFFFFFF); - if(!ss) { - rank = StatCollector.translateToLocal("botania.rank" + (level + 1)).replaceAll("&", "\u00a7"); - font.drawStringWithShadow(rank, mouseX + offx + width - font.getStringWidth(rank), mouseY - offy - 12, 0xFFFFFF); - } - GL11.glEnable(GL11.GL_DEPTH_TEST); - GL11.glPopAttrib(); - } - - private static void drawManaBar(ItemStack stack, IManaTooltipDisplay display, int mouseX, int mouseY, int offx, int offy, int width, int height) { - float fraction = display.getManaFractionForDisplay(stack); - int manaBarWidth = (int) Math.ceil(width * fraction); - - GL11.glDisable(GL11.GL_DEPTH_TEST); - Gui.drawRect(mouseX + offx - 1, mouseY - offy - height - 1, mouseX + offx + width + 1, mouseY - offy, 0xFF000000); - Gui.drawRect(mouseX + offx, mouseY - offy - height, mouseX + offx + manaBarWidth, mouseY - offy, Color.HSBtoRGB(0.528F, ((float) Math.sin((ClientTickHandler.ticksInGame + ClientTickHandler.partialTicks) * 0.2) + 1F) * 0.3F + 0.4F, 1F)); - Gui.drawRect(mouseX + offx + manaBarWidth, mouseY - offy - height, mouseX + offx + width, mouseY - offy, 0xFF555555); - } - + private static float lexiconLookupTime = 0F; + + public static void render() { + Minecraft mc = Minecraft.getMinecraft(); + GuiScreen gui = mc.currentScreen; + if (gui != null + && gui instanceof GuiContainer + && mc.thePlayer != null + && mc.thePlayer.inventory.getItemStack() == null) { + GuiContainer container = (GuiContainer) gui; + Slot slot = ReflectionHelper.getPrivateValue(GuiContainer.class, container, LibObfuscation.THE_SLOT); + if (slot != null && slot.getHasStack()) { + ItemStack stack = slot.getStack(); + if (stack != null) { + ScaledResolution res = new ScaledResolution(mc, mc.displayWidth, mc.displayHeight); + FontRenderer font = mc.fontRenderer; + int mouseX = Mouse.getX() * res.getScaledWidth() / mc.displayWidth; + int mouseY = res.getScaledHeight() - Mouse.getY() * res.getScaledHeight() / mc.displayHeight; + + List tooltip; + try { + tooltip = stack.getTooltip(mc.thePlayer, mc.gameSettings.advancedItemTooltips); + } catch (Exception e) { + tooltip = new ArrayList(); + } + int width = 0; + for (String s : tooltip) width = Math.max(width, font.getStringWidth(s) + 2); + int tooltipHeight = (tooltip.size() - 1) * 10 + 5; + + int height = 3; + int offx = 11; + int offy = 17; + + boolean offscreen = mouseX + width + 19 >= res.getScaledWidth(); + + int fixY = res.getScaledHeight() - (mouseY + tooltipHeight); + if (fixY < 0) offy -= fixY; + if (offscreen) offx = -13 - width; + + if (stack.getItem() instanceof ItemTerraPick) + drawTerraPick(stack, mouseX, mouseY, offx, offy, width, height, font); + else if (stack.getItem() instanceof IManaTooltipDisplay) + drawManaBar( + stack, + (IManaTooltipDisplay) stack.getItem(), + mouseX, + mouseY, + offx, + offy, + width, + height); + + EntryData data = LexiconRecipeMappings.getDataForStack(stack); + if (data != null) { + int lexSlot = -1; + ItemStack lexiconStack = null; + + for (int i = 0; i < InventoryPlayer.getHotbarSize(); i++) { + ItemStack stackAt = mc.thePlayer.inventory.getStackInSlot(i); + if (stackAt != null + && stackAt.getItem() instanceof ILexicon + && ((ILexicon) stackAt.getItem()) + .isKnowledgeUnlocked(stackAt, data.entry.getKnowledgeType())) { + lexiconStack = stackAt; + lexSlot = i; + break; + } + } + + if (lexSlot > -1) { + int x = mouseX + offx - 34; + int y = mouseY - offy; + GL11.glDisable(GL11.GL_DEPTH_TEST); + + Gui.drawRect(x - 4, y - 4, x + 20, y + 26, 0x44000000); + Gui.drawRect(x - 6, y - 6, x + 22, y + 28, 0x44000000); + + if (ConfigHandler.useShiftForQuickLookup + ? GuiScreen.isShiftKeyDown() + : GuiScreen.isCtrlKeyDown()) { + lexiconLookupTime += ClientTickHandler.delta; + + int cx = x + 8; + int cy = y + 8; + float r = 12; + float time = 20F; + float angles = lexiconLookupTime / time * 360F; + + GL11.glDisable(GL11.GL_LIGHTING); + GL11.glDisable(GL11.GL_TEXTURE_2D); + GL11.glShadeModel(GL11.GL_SMOOTH); + GL11.glEnable(GL11.GL_BLEND); + GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); + GL11.glBegin(GL11.GL_TRIANGLE_FAN); + + float a = 0.5F + + 0.2F + * ((float) Math.cos((double) (ClientTickHandler.ticksInGame + + ClientTickHandler.partialTicks) + / 10) + * 0.5F + + 0.5F); + GL11.glColor4f(0F, 0.5F, 0F, a); + GL11.glVertex2i(cx, cy); + GL11.glColor4f(0F, 1F, 0F, 1F); + + for (float i = angles; i > 0; i--) { + double rad = (i - 90) / 180F * Math.PI; + GL11.glVertex2d(cx + Math.cos(rad) * r, cy + Math.sin(rad) * r); + } + GL11.glVertex2i(cx, cy); + GL11.glEnd(); + + GL11.glDisable(GL11.GL_BLEND); + GL11.glEnable(GL11.GL_TEXTURE_2D); + GL11.glShadeModel(GL11.GL_FLAT); + + if (lexiconLookupTime >= time) { + mc.thePlayer.inventory.currentItem = lexSlot; + Botania.proxy.setEntryToOpen(data.entry); + Botania.proxy.setLexiconStack(lexiconStack); + mc.thePlayer.closeScreen(); + ItemLexicon.openBook(mc.thePlayer, lexiconStack, mc.theWorld, false); + } + } else lexiconLookupTime = 0F; + + RenderItem.getInstance() + .renderItemIntoGUI( + mc.fontRenderer, mc.renderEngine, new ItemStack(ModItems.lexicon), x, y); + GL11.glDisable(GL11.GL_LIGHTING); + + font.drawStringWithShadow("?", x + 10, y + 8, 0xFFFFFFFF); + GL11.glScalef(0.5F, 0.5F, 1F); + boolean mac = Minecraft.isRunningOnMac; + mc.fontRenderer.drawStringWithShadow( + EnumChatFormatting.BOLD + + (ConfigHandler.useShiftForQuickLookup ? "Shift" : mac ? "Cmd" : "Ctrl"), + (x + 10) * 2 - 16, + (y + 8) * 2 + 20, + 0xFFFFFFFF); + GL11.glScalef(2F, 2F, 1F); + + GL11.glEnable(GL11.GL_DEPTH_TEST); + } else lexiconLookupTime = 0F; + } else lexiconLookupTime = 0F; + } else lexiconLookupTime = 0F; + } else lexiconLookupTime = 0F; + } else lexiconLookupTime = 0F; + } + + private static void drawTerraPick( + ItemStack stack, int mouseX, int mouseY, int offx, int offy, int width, int height, FontRenderer font) { + int level = ItemTerraPick.getLevel(stack); + int max = ItemTerraPick.LEVELS[Math.min(ItemTerraPick.LEVELS.length - 1, level + 1)]; + boolean ss = level >= ItemTerraPick.LEVELS.length - 1; + int curr = ItemTerraPick.getMana_(stack); + float percent = level == 0 ? 0F : (float) curr / (float) max; + int rainbowWidth = Math.min(width - (ss ? 0 : 1), (int) (width * percent)); + float huePer = width == 0 ? 0F : 1F / width; + float hueOff = (ClientTickHandler.ticksInGame + ClientTickHandler.partialTicks) * 0.01F; + + GL11.glDisable(GL11.GL_DEPTH_TEST); + Gui.drawRect( + mouseX + offx - 1, mouseY - offy - height - 1, mouseX + offx + width + 1, mouseY - offy, 0xFF000000); + for (int i = 0; i < rainbowWidth; i++) + Gui.drawRect( + mouseX + offx + i, + mouseY - offy - height, + mouseX + offx + i + 1, + mouseY - offy, + Color.HSBtoRGB(hueOff + huePer * i, 1F, 1F)); + Gui.drawRect( + mouseX + offx + rainbowWidth, mouseY - offy - height, mouseX + offx + width, mouseY - offy, 0xFF555555); + + String rank = StatCollector.translateToLocal("botania.rank" + level).replaceAll("&", "\u00a7"); + GL11.glPushAttrib(GL11.GL_LIGHTING); + GL11.glDisable(GL11.GL_LIGHTING); + font.drawStringWithShadow(rank, mouseX + offx, mouseY - offy - 12, 0xFFFFFF); + if (!ss) { + rank = StatCollector.translateToLocal("botania.rank" + (level + 1)).replaceAll("&", "\u00a7"); + font.drawStringWithShadow( + rank, mouseX + offx + width - font.getStringWidth(rank), mouseY - offy - 12, 0xFFFFFF); + } + GL11.glEnable(GL11.GL_DEPTH_TEST); + GL11.glPopAttrib(); + } + + private static void drawManaBar( + ItemStack stack, + IManaTooltipDisplay display, + int mouseX, + int mouseY, + int offx, + int offy, + int width, + int height) { + float fraction = display.getManaFractionForDisplay(stack); + int manaBarWidth = (int) Math.ceil(width * fraction); + + GL11.glDisable(GL11.GL_DEPTH_TEST); + Gui.drawRect( + mouseX + offx - 1, mouseY - offy - height - 1, mouseX + offx + width + 1, mouseY - offy, 0xFF000000); + Gui.drawRect( + mouseX + offx, + mouseY - offy - height, + mouseX + offx + manaBarWidth, + mouseY - offy, + Color.HSBtoRGB( + 0.528F, + ((float) Math.sin((ClientTickHandler.ticksInGame + ClientTickHandler.partialTicks) * 0.2) + 1F) + * 0.3F + + 0.4F, + 1F)); + Gui.drawRect( + mouseX + offx + manaBarWidth, mouseY - offy - height, mouseX + offx + width, mouseY - offy, 0xFF555555); + } } diff --git a/src/main/java/vazkii/botania/client/core/handler/TooltipHandler.java b/src/main/java/vazkii/botania/client/core/handler/TooltipHandler.java index 6d1ae432e8..f336d34fed 100644 --- a/src/main/java/vazkii/botania/client/core/handler/TooltipHandler.java +++ b/src/main/java/vazkii/botania/client/core/handler/TooltipHandler.java @@ -2,14 +2,16 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jul 26, 2014, 2:33:04 AM (GMT)] */ package vazkii.botania.client.core.handler; +import cpw.mods.fml.common.eventhandler.EventPriority; +import cpw.mods.fml.common.eventhandler.SubscribeEvent; import net.minecraft.init.Blocks; import net.minecraft.item.Item; import net.minecraft.util.StatCollector; @@ -17,23 +19,23 @@ import vazkii.botania.common.core.helper.ItemNBTHelper; import vazkii.botania.common.item.ItemKeepIvy; import vazkii.botania.common.item.ItemRegenIvy; -import cpw.mods.fml.common.eventhandler.EventPriority; -import cpw.mods.fml.common.eventhandler.SubscribeEvent; public final class TooltipHandler { - @SubscribeEvent(priority = EventPriority.HIGHEST) - public void onTooltipEvent(ItemTooltipEvent event) { - if(event.itemStack.getItem() == Item.getItemFromBlock(Blocks.dirt) && event.itemStack.getItemDamage() == 1) { - event.toolTip.add(StatCollector.translateToLocal("botaniamisc.coarseDirt0")); - event.toolTip.add(StatCollector.translateToLocal("botaniamisc.coarseDirt1")); - } else if(event.itemStack.getItem() == Item.getItemFromBlock(Blocks.mob_spawner) && event.entityPlayer.capabilities.isCreativeMode) - event.toolTip.add(StatCollector.translateToLocal("botaniamisc.spawnerTip")); - - if(ItemNBTHelper.detectNBT(event.itemStack) && ItemNBTHelper.getBoolean(event.itemStack, ItemRegenIvy.TAG_REGEN, false)) - event.toolTip.add(StatCollector.translateToLocal("botaniamisc.hasIvy")); - if(ItemNBTHelper.detectNBT(event.itemStack) && ItemNBTHelper.getBoolean(event.itemStack, ItemKeepIvy.TAG_KEEP, false)) - event.toolTip.add(StatCollector.translateToLocal("botaniamisc.hasKeepIvy")); - } + @SubscribeEvent(priority = EventPriority.HIGHEST) + public void onTooltipEvent(ItemTooltipEvent event) { + if (event.itemStack.getItem() == Item.getItemFromBlock(Blocks.dirt) && event.itemStack.getItemDamage() == 1) { + event.toolTip.add(StatCollector.translateToLocal("botaniamisc.coarseDirt0")); + event.toolTip.add(StatCollector.translateToLocal("botaniamisc.coarseDirt1")); + } else if (event.itemStack.getItem() == Item.getItemFromBlock(Blocks.mob_spawner) + && event.entityPlayer.capabilities.isCreativeMode) + event.toolTip.add(StatCollector.translateToLocal("botaniamisc.spawnerTip")); + if (ItemNBTHelper.detectNBT(event.itemStack) + && ItemNBTHelper.getBoolean(event.itemStack, ItemRegenIvy.TAG_REGEN, false)) + event.toolTip.add(StatCollector.translateToLocal("botaniamisc.hasIvy")); + if (ItemNBTHelper.detectNBT(event.itemStack) + && ItemNBTHelper.getBoolean(event.itemStack, ItemKeepIvy.TAG_KEEP, false)) + event.toolTip.add(StatCollector.translateToLocal("botaniamisc.hasKeepIvy")); + } } diff --git a/src/main/java/vazkii/botania/client/core/helper/FontHelper.java b/src/main/java/vazkii/botania/client/core/helper/FontHelper.java index e1f5ed5c01..8451abb2d0 100644 --- a/src/main/java/vazkii/botania/client/core/helper/FontHelper.java +++ b/src/main/java/vazkii/botania/client/core/helper/FontHelper.java @@ -2,41 +2,38 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jan 16, 2014, 5:30:52 PM (GMT)] */ package vazkii.botania.client.core.helper; public final class FontHelper { - public static boolean isFormatColor(char par0) { - return par0 >= 48 && par0 <= 57 || par0 >= 97 && par0 <= 102 || par0 >= 65 && par0 <= 70; - } + public static boolean isFormatColor(char par0) { + return par0 >= 48 && par0 <= 57 || par0 >= 97 && par0 <= 102 || par0 >= 65 && par0 <= 70; + } - public static boolean isFormatSpecial(char par0) { - return par0 >= 107 && par0 <= 111 || par0 >= 75 && par0 <= 79 || par0 == 114 || par0 == 82; - } + public static boolean isFormatSpecial(char par0) { + return par0 >= 107 && par0 <= 111 || par0 >= 75 && par0 <= 79 || par0 == 114 || par0 == 82; + } - public static String getFormatFromString(String par0Str) { - String s1 = ""; - int i = -1; - int j = par0Str.length(); + public static String getFormatFromString(String par0Str) { + String s1 = ""; + int i = -1; + int j = par0Str.length(); - while ((i = par0Str.indexOf(167, i + 1)) != -1) { - if (i < j - 1) { - char c0 = par0Str.charAt(i + 1); + while ((i = par0Str.indexOf(167, i + 1)) != -1) { + if (i < j - 1) { + char c0 = par0Str.charAt(i + 1); - if (isFormatColor(c0)) - s1 = "\u00a7" + c0; - else if (isFormatSpecial(c0)) - s1 = s1 + "\u00a7" + c0; - } - } - - return s1; - } + if (isFormatColor(c0)) s1 = "\u00a7" + c0; + else if (isFormatSpecial(c0)) s1 = s1 + "\u00a7" + c0; + } + } + return s1; + } } diff --git a/src/main/java/vazkii/botania/client/core/helper/IconHelper.java b/src/main/java/vazkii/botania/client/core/helper/IconHelper.java index bf3c2304ba..222f266b56 100644 --- a/src/main/java/vazkii/botania/client/core/helper/IconHelper.java +++ b/src/main/java/vazkii/botania/client/core/helper/IconHelper.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jan 14, 2014, 5:28:21 PM (GMT)] */ package vazkii.botania.client.core.helper; @@ -18,44 +18,43 @@ public final class IconHelper { - public static IIcon forName(IIconRegister ir, String name) { - return ir.registerIcon(LibResources.PREFIX_MOD + name); - } + public static IIcon forName(IIconRegister ir, String name) { + return ir.registerIcon(LibResources.PREFIX_MOD + name); + } - public static IIcon forName(IIconRegister ir, String name, String dir) { - return ir.registerIcon(LibResources.PREFIX_MOD + dir + "/" + name); - } + public static IIcon forName(IIconRegister ir, String name, String dir) { + return ir.registerIcon(LibResources.PREFIX_MOD + dir + "/" + name); + } - public static IIcon forBlock(IIconRegister ir, Block block) { - return forName(ir, block.getUnlocalizedName().replaceAll("tile\\.", "")); - } + public static IIcon forBlock(IIconRegister ir, Block block) { + return forName(ir, block.getUnlocalizedName().replaceAll("tile\\.", "")); + } - public static IIcon forBlock(IIconRegister ir, Block block, int i) { - return forBlock(ir, block, Integer.toString(i)); - } + public static IIcon forBlock(IIconRegister ir, Block block, int i) { + return forBlock(ir, block, Integer.toString(i)); + } - public static IIcon forBlock(IIconRegister ir, Block block, int i, String dir) { - return forBlock(ir, block, Integer.toString(i), dir); - } + public static IIcon forBlock(IIconRegister ir, Block block, int i, String dir) { + return forBlock(ir, block, Integer.toString(i), dir); + } - public static IIcon forBlock(IIconRegister ir, Block block, String s) { - return forName(ir, block.getUnlocalizedName().replaceAll("tile\\.", "") + s); - } + public static IIcon forBlock(IIconRegister ir, Block block, String s) { + return forName(ir, block.getUnlocalizedName().replaceAll("tile\\.", "") + s); + } - public static IIcon forBlock(IIconRegister ir, Block block, String s, String dir) { - return forName(ir, block.getUnlocalizedName().replaceAll("tile\\.", "") + s, dir); - } + public static IIcon forBlock(IIconRegister ir, Block block, String s, String dir) { + return forName(ir, block.getUnlocalizedName().replaceAll("tile\\.", "") + s, dir); + } - public static IIcon forItem(IIconRegister ir, Item item) { - return forName(ir, item.getUnlocalizedName().replaceAll("item\\.", "")); - } + public static IIcon forItem(IIconRegister ir, Item item) { + return forName(ir, item.getUnlocalizedName().replaceAll("item\\.", "")); + } - public static IIcon forItem(IIconRegister ir, Item item, int i) { - return forItem(ir, item, Integer.toString(i)); - } + public static IIcon forItem(IIconRegister ir, Item item, int i) { + return forItem(ir, item, Integer.toString(i)); + } - public static IIcon forItem(IIconRegister ir, Item item, String s) { - return forName(ir, item.getUnlocalizedName().replaceAll("item\\.", "") + s); - } - -} \ No newline at end of file + public static IIcon forItem(IIconRegister ir, Item item, String s) { + return forName(ir, item.getUnlocalizedName().replaceAll("item\\.", "") + s); + } +} diff --git a/src/main/java/vazkii/botania/client/core/helper/RenderHelper.java b/src/main/java/vazkii/botania/client/core/helper/RenderHelper.java index ff177cbd1a..db5e006862 100644 --- a/src/main/java/vazkii/botania/client/core/helper/RenderHelper.java +++ b/src/main/java/vazkii/botania/client/core/helper/RenderHelper.java @@ -2,17 +2,16 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jan 19, 2014, 5:40:38 PM (GMT)] */ package vazkii.botania.client.core.helper; import java.util.List; import java.util.Random; - import net.minecraft.client.Minecraft; import net.minecraft.client.gui.FontRenderer; import net.minecraft.client.renderer.Tessellator; @@ -20,233 +19,230 @@ import net.minecraft.client.settings.KeyBinding; import net.minecraft.item.ItemStack; import net.minecraft.util.ResourceLocation; - import org.lwjgl.input.Keyboard; import org.lwjgl.opengl.GL11; - import vazkii.botania.client.core.handler.ClientTickHandler; import vazkii.botania.client.lib.LibResources; public final class RenderHelper { - public static void renderTooltip(int x, int y, List tooltipData) { - int color = 0x505000ff; - int color2 = 0xf0100010; - - renderTooltip(x, y, tooltipData, color, color2); - } - - public static void renderTooltipOrange(int x, int y, List tooltipData) { - int color = 0x50a06600; - int color2 = 0xf01e1200; - - renderTooltip(x, y, tooltipData, color, color2); - } - - public static void renderTooltipGreen(int x, int y, List tooltipData) { - int color = 0x5000a000; - int color2 = 0xf0001e00; - - renderTooltip(x, y, tooltipData, color, color2); - } - - public static void renderTooltip(int x, int y, List tooltipData, int color, int color2) { - boolean lighting = GL11.glGetBoolean(GL11.GL_LIGHTING); - if(lighting) - net.minecraft.client.renderer.RenderHelper.disableStandardItemLighting(); - - if (!tooltipData.isEmpty()) { - int var5 = 0; - int var6; - int var7; - FontRenderer fontRenderer = Minecraft.getMinecraft().fontRenderer; - for (var6 = 0; var6 < tooltipData.size(); ++var6) { - var7 = fontRenderer.getStringWidth(tooltipData.get(var6)); - if (var7 > var5) - var5 = var7; - } - var6 = x + 12; - var7 = y - 12; - int var9 = 8; - if (tooltipData.size() > 1) - var9 += 2 + (tooltipData.size() - 1) * 10; - float z = 300F; - drawGradientRect(var6 - 3, var7 - 4, z, var6 + var5 + 3, var7 - 3, color2, color2); - drawGradientRect(var6 - 3, var7 + var9 + 3, z, var6 + var5 + 3, var7 + var9 + 4, color2, color2); - drawGradientRect(var6 - 3, var7 - 3, z, var6 + var5 + 3, var7 + var9 + 3, color2, color2); - drawGradientRect(var6 - 4, var7 - 3, z, var6 - 3, var7 + var9 + 3, color2, color2); - drawGradientRect(var6 + var5 + 3, var7 - 3, z, var6 + var5 + 4, var7 + var9 + 3, color2, color2); - int var12 = (color & 0xFFFFFF) >> 1 | color & -16777216; - drawGradientRect(var6 - 3, var7 - 3 + 1, z, var6 - 3 + 1, var7 + var9 + 3 - 1, color, var12); - drawGradientRect(var6 + var5 + 2, var7 - 3 + 1, z, var6 + var5 + 3, var7 + var9 + 3 - 1, color, var12); - drawGradientRect(var6 - 3, var7 - 3, z, var6 + var5 + 3, var7 - 3 + 1, color, color); - drawGradientRect(var6 - 3, var7 + var9 + 2, z, var6 + var5 + 3, var7 + var9 + 3, var12, var12); - - GL11.glDisable(GL11.GL_DEPTH_TEST); - for (int var13 = 0; var13 < tooltipData.size(); ++var13) { - String var14 = tooltipData.get(var13); - fontRenderer.drawStringWithShadow(var14, var6, var7, -1); - if (var13 == 0) - var7 += 2; - var7 += 10; - } - GL11.glEnable(GL11.GL_DEPTH_TEST); - } - if(!lighting) - net.minecraft.client.renderer.RenderHelper.disableStandardItemLighting(); - GL11.glColor4f(1F, 1F, 1F, 1F); - } - - public static void drawGradientRect(int par1, int par2, float z, int par3, int par4, int par5, int par6) { - float var7 = (par5 >> 24 & 255) / 255F; - float var8 = (par5 >> 16 & 255) / 255F; - float var9 = (par5 >> 8 & 255) / 255F; - float var10 = (par5 & 255) / 255F; - float var11 = (par6 >> 24 & 255) / 255F; - float var12 = (par6 >> 16 & 255) / 255F; - float var13 = (par6 >> 8 & 255) / 255F; - float var14 = (par6 & 255) / 255F; - GL11.glDisable(GL11.GL_TEXTURE_2D); - GL11.glEnable(GL11.GL_BLEND); - GL11.glDisable(GL11.GL_ALPHA_TEST); - GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); - GL11.glShadeModel(GL11.GL_SMOOTH); - Tessellator var15 = Tessellator.instance; - var15.startDrawingQuads(); - var15.setColorRGBA_F(var8, var9, var10, var7); - var15.addVertex(par3, par2, z); - var15.addVertex(par1, par2, z); - var15.setColorRGBA_F(var12, var13, var14, var11); - var15.addVertex(par1, par4, z); - var15.addVertex(par3, par4, z); - var15.draw(); - GL11.glShadeModel(GL11.GL_FLAT); - GL11.glDisable(GL11.GL_BLEND); - GL11.glEnable(GL11.GL_ALPHA_TEST); - GL11.glEnable(GL11.GL_TEXTURE_2D); - } - - public static void drawTexturedModalRect(int par1, int par2, float z, int par3, int par4, int par5, int par6) { - drawTexturedModalRect(par1, par2, z, par3, par4, par5, par6, 0.00390625F, 0.00390625F); - } - - public static void drawTexturedModalRect(int par1, int par2, float z, int par3, int par4, int par5, int par6, float f, float f1) { - Tessellator tessellator = Tessellator.instance; - tessellator.startDrawingQuads(); - tessellator.addVertexWithUV(par1 + 0, par2 + par6, z, (par3 + 0) * f, (par4 + par6) * f1); - tessellator.addVertexWithUV(par1 + par5, par2 + par6, z, (par3 + par5) * f, (par4 + par6) * f1); - tessellator.addVertexWithUV(par1 + par5, par2 + 0, z, (par3 + par5) * f, (par4 + 0) * f1); - tessellator.addVertexWithUV(par1 + 0, par2 + 0, z, (par3 + 0) * f, (par4 + 0) * f1); - tessellator.draw(); - } - - public static void renderStar(int color, float xScale, float yScale, float zScale, long seed) { - Tessellator tessellator = Tessellator.instance; - - int ticks = ClientTickHandler.ticksInGame % 200; - if (ticks >= 100) - ticks = 200 - ticks - 1; - - float f1 = ticks / 200F; - float f2 = 0F; - if (f1 > 0.7F) - f2 = (f1 - 0.7F) / 0.2F; - Random random = new Random(seed); - - GL11.glPushMatrix(); - GL11.glDisable(GL11.GL_TEXTURE_2D); - GL11.glShadeModel(GL11.GL_SMOOTH); - GL11.glEnable(GL11.GL_BLEND); - GL11.glBlendFunc(770, 1); - GL11.glDisable(GL11.GL_ALPHA_TEST); - GL11.glEnable(GL11.GL_CULL_FACE); - GL11.glDepthMask(false); - GL11.glScalef(xScale, yScale, zScale); - - for (int i = 0; i < (f1 + f1 * f1) / 2F * 90F + 30F; i++) { - GL11.glRotatef(random.nextFloat() * 360F, 1F, 0F, 0F); - GL11.glRotatef(random.nextFloat() * 360F, 0F, 1F, 0F); - GL11.glRotatef(random.nextFloat() * 360F, 0F, 0F, 1F); - GL11.glRotatef(random.nextFloat() * 360F, 1F, 0F, 0F); - GL11.glRotatef(random.nextFloat() * 360F, 0F, 1F, 0F); - GL11.glRotatef(random.nextFloat() * 360F + f1 * 90F, 0F, 0F, 1F); - tessellator.startDrawing(GL11.GL_TRIANGLE_FAN); - float f3 = random.nextFloat() * 20F + 5F + f2 * 10F; - float f4 = random.nextFloat() * 2F + 1F + f2 * 2F; - tessellator.setColorRGBA_I(color, (int) (255F * (1F - f2))); - tessellator.addVertex(0, 0, 0); - tessellator.setColorRGBA_F(0F, 0F, 0F, 0); - tessellator.addVertex(-0.866D * f4, f3, -0.5F * f4); - tessellator.addVertex(0.866D * f4, f3, -0.5F * f4); - tessellator.addVertex(0, f3, 1F * f4); - tessellator.addVertex(-0.866D * f4, f3, -0.5F * f4); - tessellator.draw(); - } - - GL11.glDepthMask(true); - GL11.glDisable(GL11.GL_CULL_FACE); - GL11.glDisable(GL11.GL_BLEND); - GL11.glShadeModel(GL11.GL_FLAT); - GL11.glColor4f(1F, 1F, 1F, 1F); - GL11.glEnable(GL11.GL_TEXTURE_2D); - GL11.glEnable(GL11.GL_ALPHA_TEST); - GL11.glPopMatrix(); - } - - public static void renderProgressPie(int x, int y, float progress, ItemStack stack) { - Minecraft mc = Minecraft.getMinecraft(); - RenderItem.getInstance().renderItemAndEffectIntoGUI(mc.fontRenderer, mc.renderEngine, stack, x, y); - - GL11.glClear(GL11.GL_DEPTH_BUFFER_BIT); - GL11.glEnable(GL11.GL_STENCIL_TEST); - GL11.glColorMask(false, false, false, false); - GL11.glDepthMask(false); - GL11.glStencilFunc(GL11.GL_NEVER, 1, 0xFF); - GL11.glStencilOp(GL11.GL_REPLACE, GL11.GL_KEEP, GL11.GL_KEEP); - GL11.glStencilMask(0xFF); - RenderItem.getInstance().renderItemAndEffectIntoGUI(mc.fontRenderer, mc.renderEngine, stack, x, y); - - mc.renderEngine.bindTexture(new ResourceLocation(LibResources.GUI_MANA_HUD)); - int r = 10; - int centerX = x + 8; - int centerY = y + 8; - int degs = (int) (360 * progress); - float a = 0.5F + 0.2F * ((float) Math.cos((double) (ClientTickHandler.ticksInGame + ClientTickHandler.partialTicks) / 10) * 0.5F + 0.5F); - - GL11.glDisable(GL11.GL_LIGHTING); - GL11.glDisable(GL11.GL_TEXTURE_2D); - GL11.glShadeModel(GL11.GL_SMOOTH); - GL11.glEnable(GL11.GL_BLEND); - GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); - GL11.glColorMask(true, true, true, true); - GL11.glDepthMask(true); - GL11.glStencilMask(0x00); - GL11.glStencilFunc(GL11.GL_EQUAL, 1, 0xFF); - GL11.glBegin(GL11.GL_TRIANGLE_FAN); - GL11.glColor4f(0F, 0.5F, 0.5F, a); - GL11.glVertex2i(centerX, centerY); - GL11.glColor4f(0F, 1F, 0.5F, a); - for(int i = degs; i > 0; i--) { - double rad = (i - 90) / 180F * Math.PI; - GL11.glVertex2d(centerX + Math.cos(rad) * r, centerY + Math.sin(rad) * r); - } - GL11.glVertex2i(centerX, centerY); - GL11.glEnd(); - GL11.glDisable(GL11.GL_BLEND); - GL11.glEnable(GL11.GL_TEXTURE_2D); - GL11.glShadeModel(GL11.GL_FLAT); - GL11.glDisable(GL11.GL_STENCIL_TEST); - } - - public static String getKeyDisplayString(String keyName) { - String key = null; - KeyBinding[] keys = Minecraft.getMinecraft().gameSettings.keyBindings; - for(KeyBinding otherKey : keys) - if(otherKey.getKeyDescription().equals(keyName)) { - key = Keyboard.getKeyName(otherKey.getKeyCode()); - break; - } - - return key; - } + public static void renderTooltip(int x, int y, List tooltipData) { + int color = 0x505000ff; + int color2 = 0xf0100010; + + renderTooltip(x, y, tooltipData, color, color2); + } + + public static void renderTooltipOrange(int x, int y, List tooltipData) { + int color = 0x50a06600; + int color2 = 0xf01e1200; + + renderTooltip(x, y, tooltipData, color, color2); + } + + public static void renderTooltipGreen(int x, int y, List tooltipData) { + int color = 0x5000a000; + int color2 = 0xf0001e00; + + renderTooltip(x, y, tooltipData, color, color2); + } + + public static void renderTooltip(int x, int y, List tooltipData, int color, int color2) { + boolean lighting = GL11.glGetBoolean(GL11.GL_LIGHTING); + if (lighting) net.minecraft.client.renderer.RenderHelper.disableStandardItemLighting(); + + if (!tooltipData.isEmpty()) { + int var5 = 0; + int var6; + int var7; + FontRenderer fontRenderer = Minecraft.getMinecraft().fontRenderer; + for (var6 = 0; var6 < tooltipData.size(); ++var6) { + var7 = fontRenderer.getStringWidth(tooltipData.get(var6)); + if (var7 > var5) var5 = var7; + } + var6 = x + 12; + var7 = y - 12; + int var9 = 8; + if (tooltipData.size() > 1) var9 += 2 + (tooltipData.size() - 1) * 10; + float z = 300F; + drawGradientRect(var6 - 3, var7 - 4, z, var6 + var5 + 3, var7 - 3, color2, color2); + drawGradientRect(var6 - 3, var7 + var9 + 3, z, var6 + var5 + 3, var7 + var9 + 4, color2, color2); + drawGradientRect(var6 - 3, var7 - 3, z, var6 + var5 + 3, var7 + var9 + 3, color2, color2); + drawGradientRect(var6 - 4, var7 - 3, z, var6 - 3, var7 + var9 + 3, color2, color2); + drawGradientRect(var6 + var5 + 3, var7 - 3, z, var6 + var5 + 4, var7 + var9 + 3, color2, color2); + int var12 = (color & 0xFFFFFF) >> 1 | color & -16777216; + drawGradientRect(var6 - 3, var7 - 3 + 1, z, var6 - 3 + 1, var7 + var9 + 3 - 1, color, var12); + drawGradientRect(var6 + var5 + 2, var7 - 3 + 1, z, var6 + var5 + 3, var7 + var9 + 3 - 1, color, var12); + drawGradientRect(var6 - 3, var7 - 3, z, var6 + var5 + 3, var7 - 3 + 1, color, color); + drawGradientRect(var6 - 3, var7 + var9 + 2, z, var6 + var5 + 3, var7 + var9 + 3, var12, var12); + + GL11.glDisable(GL11.GL_DEPTH_TEST); + for (int var13 = 0; var13 < tooltipData.size(); ++var13) { + String var14 = tooltipData.get(var13); + fontRenderer.drawStringWithShadow(var14, var6, var7, -1); + if (var13 == 0) var7 += 2; + var7 += 10; + } + GL11.glEnable(GL11.GL_DEPTH_TEST); + } + if (!lighting) net.minecraft.client.renderer.RenderHelper.disableStandardItemLighting(); + GL11.glColor4f(1F, 1F, 1F, 1F); + } + + public static void drawGradientRect(int par1, int par2, float z, int par3, int par4, int par5, int par6) { + float var7 = (par5 >> 24 & 255) / 255F; + float var8 = (par5 >> 16 & 255) / 255F; + float var9 = (par5 >> 8 & 255) / 255F; + float var10 = (par5 & 255) / 255F; + float var11 = (par6 >> 24 & 255) / 255F; + float var12 = (par6 >> 16 & 255) / 255F; + float var13 = (par6 >> 8 & 255) / 255F; + float var14 = (par6 & 255) / 255F; + GL11.glDisable(GL11.GL_TEXTURE_2D); + GL11.glEnable(GL11.GL_BLEND); + GL11.glDisable(GL11.GL_ALPHA_TEST); + GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); + GL11.glShadeModel(GL11.GL_SMOOTH); + Tessellator var15 = Tessellator.instance; + var15.startDrawingQuads(); + var15.setColorRGBA_F(var8, var9, var10, var7); + var15.addVertex(par3, par2, z); + var15.addVertex(par1, par2, z); + var15.setColorRGBA_F(var12, var13, var14, var11); + var15.addVertex(par1, par4, z); + var15.addVertex(par3, par4, z); + var15.draw(); + GL11.glShadeModel(GL11.GL_FLAT); + GL11.glDisable(GL11.GL_BLEND); + GL11.glEnable(GL11.GL_ALPHA_TEST); + GL11.glEnable(GL11.GL_TEXTURE_2D); + } + + public static void drawTexturedModalRect(int par1, int par2, float z, int par3, int par4, int par5, int par6) { + drawTexturedModalRect(par1, par2, z, par3, par4, par5, par6, 0.00390625F, 0.00390625F); + } + + public static void drawTexturedModalRect( + int par1, int par2, float z, int par3, int par4, int par5, int par6, float f, float f1) { + Tessellator tessellator = Tessellator.instance; + tessellator.startDrawingQuads(); + tessellator.addVertexWithUV(par1 + 0, par2 + par6, z, (par3 + 0) * f, (par4 + par6) * f1); + tessellator.addVertexWithUV(par1 + par5, par2 + par6, z, (par3 + par5) * f, (par4 + par6) * f1); + tessellator.addVertexWithUV(par1 + par5, par2 + 0, z, (par3 + par5) * f, (par4 + 0) * f1); + tessellator.addVertexWithUV(par1 + 0, par2 + 0, z, (par3 + 0) * f, (par4 + 0) * f1); + tessellator.draw(); + } + + public static void renderStar(int color, float xScale, float yScale, float zScale, long seed) { + Tessellator tessellator = Tessellator.instance; + + int ticks = ClientTickHandler.ticksInGame % 200; + if (ticks >= 100) ticks = 200 - ticks - 1; + + float f1 = ticks / 200F; + float f2 = 0F; + if (f1 > 0.7F) f2 = (f1 - 0.7F) / 0.2F; + Random random = new Random(seed); + + GL11.glPushMatrix(); + GL11.glDisable(GL11.GL_TEXTURE_2D); + GL11.glShadeModel(GL11.GL_SMOOTH); + GL11.glEnable(GL11.GL_BLEND); + GL11.glBlendFunc(770, 1); + GL11.glDisable(GL11.GL_ALPHA_TEST); + GL11.glEnable(GL11.GL_CULL_FACE); + GL11.glDepthMask(false); + GL11.glScalef(xScale, yScale, zScale); + + for (int i = 0; i < (f1 + f1 * f1) / 2F * 90F + 30F; i++) { + GL11.glRotatef(random.nextFloat() * 360F, 1F, 0F, 0F); + GL11.glRotatef(random.nextFloat() * 360F, 0F, 1F, 0F); + GL11.glRotatef(random.nextFloat() * 360F, 0F, 0F, 1F); + GL11.glRotatef(random.nextFloat() * 360F, 1F, 0F, 0F); + GL11.glRotatef(random.nextFloat() * 360F, 0F, 1F, 0F); + GL11.glRotatef(random.nextFloat() * 360F + f1 * 90F, 0F, 0F, 1F); + tessellator.startDrawing(GL11.GL_TRIANGLE_FAN); + float f3 = random.nextFloat() * 20F + 5F + f2 * 10F; + float f4 = random.nextFloat() * 2F + 1F + f2 * 2F; + tessellator.setColorRGBA_I(color, (int) (255F * (1F - f2))); + tessellator.addVertex(0, 0, 0); + tessellator.setColorRGBA_F(0F, 0F, 0F, 0); + tessellator.addVertex(-0.866D * f4, f3, -0.5F * f4); + tessellator.addVertex(0.866D * f4, f3, -0.5F * f4); + tessellator.addVertex(0, f3, 1F * f4); + tessellator.addVertex(-0.866D * f4, f3, -0.5F * f4); + tessellator.draw(); + } + + GL11.glDepthMask(true); + GL11.glDisable(GL11.GL_CULL_FACE); + GL11.glDisable(GL11.GL_BLEND); + GL11.glShadeModel(GL11.GL_FLAT); + GL11.glColor4f(1F, 1F, 1F, 1F); + GL11.glEnable(GL11.GL_TEXTURE_2D); + GL11.glEnable(GL11.GL_ALPHA_TEST); + GL11.glPopMatrix(); + } + + public static void renderProgressPie(int x, int y, float progress, ItemStack stack) { + Minecraft mc = Minecraft.getMinecraft(); + RenderItem.getInstance().renderItemAndEffectIntoGUI(mc.fontRenderer, mc.renderEngine, stack, x, y); + + GL11.glClear(GL11.GL_DEPTH_BUFFER_BIT); + GL11.glEnable(GL11.GL_STENCIL_TEST); + GL11.glColorMask(false, false, false, false); + GL11.glDepthMask(false); + GL11.glStencilFunc(GL11.GL_NEVER, 1, 0xFF); + GL11.glStencilOp(GL11.GL_REPLACE, GL11.GL_KEEP, GL11.GL_KEEP); + GL11.glStencilMask(0xFF); + RenderItem.getInstance().renderItemAndEffectIntoGUI(mc.fontRenderer, mc.renderEngine, stack, x, y); + + mc.renderEngine.bindTexture(new ResourceLocation(LibResources.GUI_MANA_HUD)); + int r = 10; + int centerX = x + 8; + int centerY = y + 8; + int degs = (int) (360 * progress); + float a = 0.5F + + 0.2F + * ((float) Math.cos((double) (ClientTickHandler.ticksInGame + ClientTickHandler.partialTicks) + / 10) + * 0.5F + + 0.5F); + + GL11.glDisable(GL11.GL_LIGHTING); + GL11.glDisable(GL11.GL_TEXTURE_2D); + GL11.glShadeModel(GL11.GL_SMOOTH); + GL11.glEnable(GL11.GL_BLEND); + GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); + GL11.glColorMask(true, true, true, true); + GL11.glDepthMask(true); + GL11.glStencilMask(0x00); + GL11.glStencilFunc(GL11.GL_EQUAL, 1, 0xFF); + GL11.glBegin(GL11.GL_TRIANGLE_FAN); + GL11.glColor4f(0F, 0.5F, 0.5F, a); + GL11.glVertex2i(centerX, centerY); + GL11.glColor4f(0F, 1F, 0.5F, a); + for (int i = degs; i > 0; i--) { + double rad = (i - 90) / 180F * Math.PI; + GL11.glVertex2d(centerX + Math.cos(rad) * r, centerY + Math.sin(rad) * r); + } + GL11.glVertex2i(centerX, centerY); + GL11.glEnd(); + GL11.glDisable(GL11.GL_BLEND); + GL11.glEnable(GL11.GL_TEXTURE_2D); + GL11.glShadeModel(GL11.GL_FLAT); + GL11.glDisable(GL11.GL_STENCIL_TEST); + } + + public static String getKeyDisplayString(String keyName) { + String key = null; + KeyBinding[] keys = Minecraft.getMinecraft().gameSettings.keyBindings; + for (KeyBinding otherKey : keys) + if (otherKey.getKeyDescription().equals(keyName)) { + key = Keyboard.getKeyName(otherKey.getKeyCode()); + break; + } + + return key; + } } diff --git a/src/main/java/vazkii/botania/client/core/helper/ShaderHelper.java b/src/main/java/vazkii/botania/client/core/helper/ShaderHelper.java index 1923a011bd..3755c8b1e5 100644 --- a/src/main/java/vazkii/botania/client/core/helper/ShaderHelper.java +++ b/src/main/java/vazkii/botania/client/core/helper/ShaderHelper.java @@ -2,199 +2,182 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Apr 9, 2014, 11:20:26 PM (GMT)] */ package vazkii.botania.client.core.helper; +import cpw.mods.fml.common.FMLLog; import java.io.BufferedReader; import java.io.InputStream; import java.io.InputStreamReader; - import net.minecraft.client.renderer.OpenGlHelper; - import org.apache.logging.log4j.Level; import org.lwjgl.opengl.ARBFragmentShader; import org.lwjgl.opengl.ARBShaderObjects; import org.lwjgl.opengl.ARBVertexShader; import org.lwjgl.opengl.GL11; - import vazkii.botania.api.internal.ShaderCallback; import vazkii.botania.client.core.handler.ClientTickHandler; import vazkii.botania.client.lib.LibResources; import vazkii.botania.common.core.handler.ConfigHandler; -import cpw.mods.fml.common.FMLLog; public final class ShaderHelper { - private static final int VERT = ARBVertexShader.GL_VERTEX_SHADER_ARB; - private static final int FRAG = ARBFragmentShader.GL_FRAGMENT_SHADER_ARB; - - public static int pylonGlow = 0; - public static int enchanterRune = 0; - public static int manaPool = 0; - public static int doppleganger = 0; - public static int halo = 0; - public static int dopplegangerBar = 0; - public static int terraPlateRune = 0; - public static int filmGrain = 0; - public static int gold = 0; - public static int categoryButton = 0; - - public static void initShaders() { - if(!useShaders()) - return; - - pylonGlow = createProgram(null, LibResources.SHADER_PYLON_GLOW_FRAG); - enchanterRune = createProgram(null, LibResources.SHADER_ENCHANTER_RUNE_FRAG); - manaPool = createProgram(null, LibResources.SHADER_MANA_POOL_FRAG); - doppleganger = createProgram(LibResources.SHADER_DOPLLEGANGER_VERT, LibResources.SHADER_DOPLLEGANGER_FRAG); - halo = createProgram(null, LibResources.SHADER_HALO_FRAG); - dopplegangerBar = createProgram(null, LibResources.SHADER_DOPLLEGANGER_BAR_FRAG); - terraPlateRune = createProgram(null, LibResources.SHADER_TERRA_PLATE_RUNE_FRAG); - filmGrain = createProgram(null, LibResources.SHADER_FILM_GRAIN_FRAG); - gold = createProgram(null, LibResources.SHADER_GOLD_FRAG); - categoryButton = createProgram(null, LibResources.SHADER_CATEGORY_BUTTON_FRAG); - } - - public static void useShader(int shader, ShaderCallback callback) { - if(!useShaders()) - return; - - ARBShaderObjects.glUseProgramObjectARB(shader); - - if(shader != 0) { - int time = ARBShaderObjects.glGetUniformLocationARB(shader, "time"); - ARBShaderObjects.glUniform1iARB(time, ClientTickHandler.ticksInGame); - - if(callback != null) - callback.call(shader); - } - } - - public static void useShader(int shader) { - useShader(shader, null); - } - - public static void releaseShader() { - useShader(0); - } - - public static boolean useShaders() { - return ConfigHandler.useShaders && OpenGlHelper.shadersSupported; - } - - // Most of the code taken from the LWJGL wiki - // http://lwjgl.org/wiki/index.php?title=GLSL_Shaders_with_LWJGL - - private static int createProgram(String vert, String frag) { - int vertId = 0, fragId = 0, program = 0; - if(vert != null) - vertId = createShader(vert, VERT); - if(frag != null) - fragId = createShader(frag, FRAG); - - program = ARBShaderObjects.glCreateProgramObjectARB(); - if(program == 0) - return 0; - - if(vert != null) - ARBShaderObjects.glAttachObjectARB(program, vertId); - if(frag != null) - ARBShaderObjects.glAttachObjectARB(program, fragId); - - ARBShaderObjects.glLinkProgramARB(program); - if(ARBShaderObjects.glGetObjectParameteriARB(program, ARBShaderObjects.GL_OBJECT_LINK_STATUS_ARB) == GL11.GL_FALSE) { - FMLLog.log(Level.ERROR, getLogInfo(program)); - return 0; - } - - ARBShaderObjects.glValidateProgramARB(program); - if (ARBShaderObjects.glGetObjectParameteriARB(program, ARBShaderObjects.GL_OBJECT_VALIDATE_STATUS_ARB) == GL11.GL_FALSE) { - FMLLog.log(Level.ERROR, getLogInfo(program)); - return 0; - } - - return program; - } - - private static int createShader(String filename, int shaderType){ - int shader = 0; - try { - shader = ARBShaderObjects.glCreateShaderObjectARB(shaderType); - - if(shader == 0) - return 0; - - ARBShaderObjects.glShaderSourceARB(shader, readFileAsString(filename)); - ARBShaderObjects.glCompileShaderARB(shader); - - if (ARBShaderObjects.glGetObjectParameteriARB(shader, ARBShaderObjects.GL_OBJECT_COMPILE_STATUS_ARB) == GL11.GL_FALSE) - throw new RuntimeException("Error creating shader: " + getLogInfo(shader)); - - return shader; - } - catch(Exception e) { - ARBShaderObjects.glDeleteObjectARB(shader); - e.printStackTrace(); - return -1; - } - } - - private static String getLogInfo(int obj) { - return ARBShaderObjects.glGetInfoLogARB(obj, ARBShaderObjects.glGetObjectParameteriARB(obj, ARBShaderObjects.GL_OBJECT_INFO_LOG_LENGTH_ARB)); - } - - private static String readFileAsString(String filename) throws Exception { - StringBuilder source = new StringBuilder(); - InputStream in = ShaderHelper.class.getResourceAsStream(filename); - Exception exception = null; - BufferedReader reader; - - if(in == null) - return ""; - - try { - reader = new BufferedReader(new InputStreamReader(in, "UTF-8")); - - Exception innerExc= null; - try { - String line; - while((line = reader.readLine()) != null) - source.append(line).append('\n'); - } catch(Exception exc) { - exception = exc; - } finally { - try { - reader.close(); - } catch(Exception exc) { - if(innerExc == null) - innerExc = exc; - else exc.printStackTrace(); - } - } - - if(innerExc != null) - throw innerExc; - } catch(Exception exc) { - exception = exc; - } finally { - try { - in.close(); - } catch(Exception exc) { - if(exception == null) - exception = exc; - else exc.printStackTrace(); - } - - if(exception != null) - throw exception; - } - - return source.toString(); - } - + private static final int VERT = ARBVertexShader.GL_VERTEX_SHADER_ARB; + private static final int FRAG = ARBFragmentShader.GL_FRAGMENT_SHADER_ARB; + + public static int pylonGlow = 0; + public static int enchanterRune = 0; + public static int manaPool = 0; + public static int doppleganger = 0; + public static int halo = 0; + public static int dopplegangerBar = 0; + public static int terraPlateRune = 0; + public static int filmGrain = 0; + public static int gold = 0; + public static int categoryButton = 0; + + public static void initShaders() { + if (!useShaders()) return; + + pylonGlow = createProgram(null, LibResources.SHADER_PYLON_GLOW_FRAG); + enchanterRune = createProgram(null, LibResources.SHADER_ENCHANTER_RUNE_FRAG); + manaPool = createProgram(null, LibResources.SHADER_MANA_POOL_FRAG); + doppleganger = createProgram(LibResources.SHADER_DOPLLEGANGER_VERT, LibResources.SHADER_DOPLLEGANGER_FRAG); + halo = createProgram(null, LibResources.SHADER_HALO_FRAG); + dopplegangerBar = createProgram(null, LibResources.SHADER_DOPLLEGANGER_BAR_FRAG); + terraPlateRune = createProgram(null, LibResources.SHADER_TERRA_PLATE_RUNE_FRAG); + filmGrain = createProgram(null, LibResources.SHADER_FILM_GRAIN_FRAG); + gold = createProgram(null, LibResources.SHADER_GOLD_FRAG); + categoryButton = createProgram(null, LibResources.SHADER_CATEGORY_BUTTON_FRAG); + } + + public static void useShader(int shader, ShaderCallback callback) { + if (!useShaders()) return; + + ARBShaderObjects.glUseProgramObjectARB(shader); + + if (shader != 0) { + int time = ARBShaderObjects.glGetUniformLocationARB(shader, "time"); + ARBShaderObjects.glUniform1iARB(time, ClientTickHandler.ticksInGame); + + if (callback != null) callback.call(shader); + } + } + + public static void useShader(int shader) { + useShader(shader, null); + } + + public static void releaseShader() { + useShader(0); + } + + public static boolean useShaders() { + return ConfigHandler.useShaders && OpenGlHelper.shadersSupported; + } + + // Most of the code taken from the LWJGL wiki + // http://lwjgl.org/wiki/index.php?title=GLSL_Shaders_with_LWJGL + + private static int createProgram(String vert, String frag) { + int vertId = 0, fragId = 0, program = 0; + if (vert != null) vertId = createShader(vert, VERT); + if (frag != null) fragId = createShader(frag, FRAG); + + program = ARBShaderObjects.glCreateProgramObjectARB(); + if (program == 0) return 0; + + if (vert != null) ARBShaderObjects.glAttachObjectARB(program, vertId); + if (frag != null) ARBShaderObjects.glAttachObjectARB(program, fragId); + + ARBShaderObjects.glLinkProgramARB(program); + if (ARBShaderObjects.glGetObjectParameteriARB(program, ARBShaderObjects.GL_OBJECT_LINK_STATUS_ARB) + == GL11.GL_FALSE) { + FMLLog.log(Level.ERROR, getLogInfo(program)); + return 0; + } + + ARBShaderObjects.glValidateProgramARB(program); + if (ARBShaderObjects.glGetObjectParameteriARB(program, ARBShaderObjects.GL_OBJECT_VALIDATE_STATUS_ARB) + == GL11.GL_FALSE) { + FMLLog.log(Level.ERROR, getLogInfo(program)); + return 0; + } + + return program; + } + + private static int createShader(String filename, int shaderType) { + int shader = 0; + try { + shader = ARBShaderObjects.glCreateShaderObjectARB(shaderType); + + if (shader == 0) return 0; + + ARBShaderObjects.glShaderSourceARB(shader, readFileAsString(filename)); + ARBShaderObjects.glCompileShaderARB(shader); + + if (ARBShaderObjects.glGetObjectParameteriARB(shader, ARBShaderObjects.GL_OBJECT_COMPILE_STATUS_ARB) + == GL11.GL_FALSE) throw new RuntimeException("Error creating shader: " + getLogInfo(shader)); + + return shader; + } catch (Exception e) { + ARBShaderObjects.glDeleteObjectARB(shader); + e.printStackTrace(); + return -1; + } + } + + private static String getLogInfo(int obj) { + return ARBShaderObjects.glGetInfoLogARB( + obj, ARBShaderObjects.glGetObjectParameteriARB(obj, ARBShaderObjects.GL_OBJECT_INFO_LOG_LENGTH_ARB)); + } + + private static String readFileAsString(String filename) throws Exception { + StringBuilder source = new StringBuilder(); + InputStream in = ShaderHelper.class.getResourceAsStream(filename); + Exception exception = null; + BufferedReader reader; + + if (in == null) return ""; + + try { + reader = new BufferedReader(new InputStreamReader(in, "UTF-8")); + + Exception innerExc = null; + try { + String line; + while ((line = reader.readLine()) != null) source.append(line).append('\n'); + } catch (Exception exc) { + exception = exc; + } finally { + try { + reader.close(); + } catch (Exception exc) { + if (innerExc == null) innerExc = exc; + else exc.printStackTrace(); + } + } + + if (innerExc != null) throw innerExc; + } catch (Exception exc) { + exception = exc; + } finally { + try { + in.close(); + } catch (Exception exc) { + if (exception == null) exception = exc; + else exc.printStackTrace(); + } + + if (exception != null) throw exception; + } + + return source.toString(); + } } diff --git a/src/main/java/vazkii/botania/client/core/proxy/ClientProxy.java b/src/main/java/vazkii/botania/client/core/proxy/ClientProxy.java index ac491c3e19..f59303c2c1 100644 --- a/src/main/java/vazkii/botania/client/core/proxy/ClientProxy.java +++ b/src/main/java/vazkii/botania/client/core/proxy/ClientProxy.java @@ -2,20 +2,28 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jan 13, 2014, 7:46:05 PM (GMT)] */ package vazkii.botania.client.core.proxy; +import cpw.mods.fml.client.registry.ClientRegistry; +import cpw.mods.fml.client.registry.RenderingRegistry; +import cpw.mods.fml.common.FMLCommonHandler; +import cpw.mods.fml.common.FMLLog; +import cpw.mods.fml.common.Optional; +import cpw.mods.fml.common.event.FMLInitializationEvent; +import cpw.mods.fml.common.event.FMLPostInitializationEvent; +import cpw.mods.fml.common.event.FMLPreInitializationEvent; +import cpw.mods.fml.relauncher.ReflectionHelper; import java.awt.Desktop; import java.io.File; import java.io.IOException; import java.net.URI; import java.util.Calendar; - import net.minecraft.block.Block; import net.minecraft.client.Minecraft; import net.minecraft.client.multiplayer.PlayerControllerMP; @@ -123,7 +131,6 @@ import vazkii.botania.client.render.tile.RenderTileTeruTeruBozu; import vazkii.botania.client.render.tile.RenderTileTinyPotato; import vazkii.botania.client.render.world.SkyblockRenderEvents; -import vazkii.botania.common.Botania; import vazkii.botania.common.block.ModBlocks; import vazkii.botania.common.block.tile.TileAlfPortal; import vazkii.botania.common.block.tile.TileAltar; @@ -173,363 +180,371 @@ import vazkii.botania.common.item.equipment.bauble.ItemMonocle; import vazkii.botania.common.lexicon.LexiconData; import vazkii.botania.common.lib.LibObfuscation; -import cpw.mods.fml.client.registry.ClientRegistry; -import cpw.mods.fml.client.registry.RenderingRegistry; -import cpw.mods.fml.common.FMLCommonHandler; -import cpw.mods.fml.common.FMLLog; -import cpw.mods.fml.common.Optional; -import cpw.mods.fml.common.event.FMLInitializationEvent; -import cpw.mods.fml.common.event.FMLPostInitializationEvent; -import cpw.mods.fml.common.event.FMLPreInitializationEvent; -import cpw.mods.fml.relauncher.ReflectionHelper; public class ClientProxy extends CommonProxy { - public static boolean jingleTheBells = false; - public static boolean dootDoot = false; - - @Override - public void preInit(FMLPreInitializationEvent event) { - PersistentVariableHelper.setCacheFile(new File(Minecraft.getMinecraft().mcDataDir, "BotaniaVars.dat")); - try { - PersistentVariableHelper.load(); - PersistentVariableHelper.save(); - } catch (IOException e) { - FMLLog.severe("Botania's persistent Variables couldn't load!"); - e.printStackTrace(); - } - - super.preInit(event); - } - - @Override - public void init(FMLInitializationEvent event) { - super.init(event); - - ModChallenges.init(); - - FMLCommonHandler.instance().bus().register(new ClientTickHandler()); - MinecraftForge.EVENT_BUS.register(new HUDHandler()); - MinecraftForge.EVENT_BUS.register(new LightningHandler()); - if(ConfigHandler.boundBlockWireframe) - MinecraftForge.EVENT_BUS.register(new BoundTileRenderer()); - MinecraftForge.EVENT_BUS.register(new TooltipHandler()); - MinecraftForge.EVENT_BUS.register(new BaubleRenderHandler()); - MinecraftForge.EVENT_BUS.register(new DebugHandler()); - MinecraftForge.EVENT_BUS.register(new SubTileRadiusRenderHandler()); - MinecraftForge.EVENT_BUS.register(new MultiblockRenderHandler()); - MinecraftForge.EVENT_BUS.register(new SkyblockRenderEvents()); - FMLCommonHandler.instance().bus().register(new CorporeaAutoCompleteHandler()); - - if(ConfigHandler.enableSeasonalFeatures) { - Calendar calendar = Calendar.getInstance(); - if((calendar.get(2) == 11 && calendar.get(5) >= 16) || (calendar.get(2) == 0 && calendar.get(5) <= 2)) - jingleTheBells = true; - if(calendar.get(2) == 9) - dootDoot = true; - } - - initRenderers(); - } - - @Override - public void postInit(FMLPostInitializationEvent event) { - super.postInit(event); - CorporeaAutoCompleteHandler.updateItemList(); - } - - private void initRenderers() { - LibRenderIDs.idAltar = RenderingRegistry.getNextAvailableRenderId(); - LibRenderIDs.idSpecialFlower = RenderingRegistry.getNextAvailableRenderId(); - LibRenderIDs.idSpreader = RenderingRegistry.getNextAvailableRenderId(); - LibRenderIDs.idPool = RenderingRegistry.getNextAvailableRenderId(); - LibRenderIDs.idPylon = RenderingRegistry.getNextAvailableRenderId(); - LibRenderIDs.idMiniIsland = RenderingRegistry.getNextAvailableRenderId(); - LibRenderIDs.idTinyPotato = RenderingRegistry.getNextAvailableRenderId(); - LibRenderIDs.idSpawnerClaw = RenderingRegistry.getNextAvailableRenderId(); - LibRenderIDs.idBrewery = RenderingRegistry.getNextAvailableRenderId(); - LibRenderIDs.idCorporeaIndex = RenderingRegistry.getNextAvailableRenderId(); - LibRenderIDs.idPump = RenderingRegistry.getNextAvailableRenderId(); - LibRenderIDs.idDoubleFlower = RenderingRegistry.getNextAvailableRenderId(); - LibRenderIDs.idCorporeaCrystalCybe = RenderingRegistry.getNextAvailableRenderId(); - LibRenderIDs.idIncensePlate = RenderingRegistry.getNextAvailableRenderId(); - LibRenderIDs.idHourglass = RenderingRegistry.getNextAvailableRenderId(); - LibRenderIDs.idCocoon = RenderingRegistry.getNextAvailableRenderId(); - LibRenderIDs.idLightRelay = RenderingRegistry.getNextAvailableRenderId(); - LibRenderIDs.idBellows = RenderingRegistry.getNextAvailableRenderId(); - LibRenderIDs.idTeruTeruBozu = RenderingRegistry.getNextAvailableRenderId(); - LibRenderIDs.idAvatar = RenderingRegistry.getNextAvailableRenderId(); - - RenderSpecialFlower specialFlowerRender = new RenderSpecialFlower(LibRenderIDs.idSpecialFlower); - RenderingRegistry.registerBlockHandler(new RenderAltar()); - RenderingRegistry.registerBlockHandler(specialFlowerRender); - RenderingRegistry.registerBlockHandler(new RenderSpreader()); - RenderingRegistry.registerBlockHandler(new RenderPool()); - RenderingRegistry.registerBlockHandler(new RenderPylon()); - RenderingRegistry.registerBlockHandler(new RenderFloatingFlower()); - RenderingRegistry.registerBlockHandler(new RenderTinyPotato()); - RenderingRegistry.registerBlockHandler(new RenderSpawnerClaw()); - RenderingRegistry.registerBlockHandler(new RenderBrewery()); - RenderingRegistry.registerBlockHandler(new RenderCorporeaIndex()); - RenderingRegistry.registerBlockHandler(new RenderPump()); - RenderingRegistry.registerBlockHandler(new RenderDoubleFlower()); - RenderingRegistry.registerBlockHandler(new RenderCorporeaCrystalCube()); - RenderingRegistry.registerBlockHandler(new RenderIncensePlate()); - RenderingRegistry.registerBlockHandler(new RenderHourglass()); - RenderingRegistry.registerBlockHandler(new RenderCocoon()); - RenderingRegistry.registerBlockHandler(new RenderBellows()); - RenderingRegistry.registerBlockHandler(new RenderTeruTeruBozu()); - RenderingRegistry.registerBlockHandler(new RenderAvatar()); - - IMultiblockRenderHook.renderHooks.put(ModBlocks.flower, specialFlowerRender); - IMultiblockRenderHook.renderHooks.put(ModBlocks.shinyFlower, specialFlowerRender); - - RenderTransparentItem renderTransparentItem = new RenderTransparentItem(); - RenderFloatingFlowerItem renderFloatingFlower = new RenderFloatingFlowerItem(); - RenderBow renderBow = new RenderBow(); - - MinecraftForgeClient.registerItemRenderer(ModItems.lens, new RenderLens()); - if(ConfigHandler.lexicon3dModel) - MinecraftForgeClient.registerItemRenderer(ModItems.lexicon, new RenderLexicon()); - MinecraftForgeClient.registerItemRenderer(ModItems.glassPick, renderTransparentItem); - MinecraftForgeClient.registerItemRenderer(ModItems.spark, renderTransparentItem); - MinecraftForgeClient.registerItemRenderer(Item.getItemFromBlock(ModBlocks.floatingFlower), renderFloatingFlower); - MinecraftForgeClient.registerItemRenderer(Item.getItemFromBlock(ModBlocks.floatingSpecialFlower), renderFloatingFlower); - MinecraftForgeClient.registerItemRenderer(ModItems.livingwoodBow, renderBow); - MinecraftForgeClient.registerItemRenderer(ModItems.crystalBow, renderBow); - - RenderTileFloatingFlower renderTileFloatingFlower = new RenderTileFloatingFlower(); - ClientRegistry.bindTileEntitySpecialRenderer(TileAltar.class, new RenderTileAltar()); - ClientRegistry.bindTileEntitySpecialRenderer(TileSpreader.class, new RenderTileSpreader()); - ClientRegistry.bindTileEntitySpecialRenderer(TilePool.class, new RenderTilePool()); - ClientRegistry.bindTileEntitySpecialRenderer(TileRuneAltar.class, new RenderTileRuneAltar()); - ClientRegistry.bindTileEntitySpecialRenderer(TilePylon.class, new RenderTilePylon()); - ClientRegistry.bindTileEntitySpecialRenderer(TileEnchanter.class, new RenderTileEnchanter()); - ClientRegistry.bindTileEntitySpecialRenderer(TileAlfPortal.class, new RenderTileAlfPortal()); - ClientRegistry.bindTileEntitySpecialRenderer(TileFloatingFlower.class, renderTileFloatingFlower); - ClientRegistry.bindTileEntitySpecialRenderer(TileFloatingSpecialFlower.class, renderTileFloatingFlower); - ClientRegistry.bindTileEntitySpecialRenderer(TileTinyPotato.class, new RenderTileTinyPotato()); - ClientRegistry.bindTileEntitySpecialRenderer(TileSpawnerClaw.class, new RenderTileSpawnerClaw()); - ClientRegistry.bindTileEntitySpecialRenderer(TileStarfield.class, new RenderTileStarfield()); - ClientRegistry.bindTileEntitySpecialRenderer(TileBrewery.class, new RenderTileBrewery()); - ClientRegistry.bindTileEntitySpecialRenderer(TileTerraPlate.class, new RenderTileTerraPlate()); - ClientRegistry.bindTileEntitySpecialRenderer(TileRedString.class, new RenderTileRedString()); - ClientRegistry.bindTileEntitySpecialRenderer(TilePrism.class, new RenderTilePrism()); - ClientRegistry.bindTileEntitySpecialRenderer(TileCorporeaIndex.class, new RenderTileCorporeaIndex()); - ClientRegistry.bindTileEntitySpecialRenderer(TilePump.class, new RenderTilePump()); - ClientRegistry.bindTileEntitySpecialRenderer(TileCorporeaCrystalCube.class, new RenderTileCorporeaCrystalCube()); - ClientRegistry.bindTileEntitySpecialRenderer(TileIncensePlate.class, new RenderTileIncensePlate()); - ClientRegistry.bindTileEntitySpecialRenderer(TileHourglass.class, new RenderTileHourglass()); - ClientRegistry.bindTileEntitySpecialRenderer(TileSparkChanger.class, new RenderTileSparkChanger()); - ClientRegistry.bindTileEntitySpecialRenderer(TileCocoon.class, new RenderTileCocoon()); - ClientRegistry.bindTileEntitySpecialRenderer(TileLightRelay.class, new RenderTileLightRelay()); - ClientRegistry.bindTileEntitySpecialRenderer(TileBellows.class, new RenderTileBellows()); - ClientRegistry.bindTileEntitySpecialRenderer(TileGaiaHead.class, new RenderTileSkullOverride()); - ClientRegistry.bindTileEntitySpecialRenderer(TileTeruTeruBozu.class, new RenderTileTeruTeruBozu()); - ClientRegistry.bindTileEntitySpecialRenderer(TileAvatar.class, new RenderTileAvatar()); - - ClientRegistry.bindTileEntitySpecialRenderer(TileEntitySkull.class, new RenderTileSkullOverride()); - - RenderingRegistry.registerEntityRenderingHandler(EntityPixie.class, new RenderPixie()); - RenderingRegistry.registerEntityRenderingHandler(EntityVineBall.class, new RenderSnowball(ModItems.vineBall)); - RenderingRegistry.registerEntityRenderingHandler(EntityDoppleganger.class, new RenderDoppleganger()); - RenderingRegistry.registerEntityRenderingHandler(EntitySpark.class, new RenderSpark()); - RenderingRegistry.registerEntityRenderingHandler(EntityThornChakram.class, new RenderThornChakram()); - RenderingRegistry.registerEntityRenderingHandler(EntityCorporeaSpark.class, new RenderCorporeaSpark()); - RenderingRegistry.registerEntityRenderingHandler(EntityEnderAirBottle.class, new RenderSnowball(ModItems.manaResource, 15)); - RenderingRegistry.registerEntityRenderingHandler(EntityPoolMinecart.class, new RenderPoolMinecart()); - RenderingRegistry.registerEntityRenderingHandler(EntityPinkWither.class, new RenderPinkWither()); - RenderingRegistry.registerEntityRenderingHandler(EntityManaStorm.class, new RenderManaStorm()); - RenderingRegistry.registerEntityRenderingHandler(EntityBabylonWeapon.class, new RenderBabylonWeapon()); - - ShaderHelper.initShaders(); - } - - @Override - @Optional.Method(modid = "NotEnoughItems") - public void registerNEIStuff() { - NEIGuiHooks.init(); - } - - @Override - public void setEntryToOpen(LexiconEntry entry) { - GuiLexicon.currentOpenLexicon = new GuiLexiconEntry(entry, new GuiLexiconIndex(entry.category)); - } - - @Override - public void setToTutorialIfFirstLaunch() { - if(PersistentVariableHelper.firstLoad) - GuiLexicon.currentOpenLexicon = new GuiLexiconEntry(LexiconData.welcome, new GuiLexiconEntry(LexiconData.tutorial, new GuiLexicon())).setFirstEntry(); - } - - @Override - public void setLexiconStack(ItemStack stack) { - GuiLexicon.stackUsed = stack; - } - - @Override - public boolean isTheClientPlayer(EntityLivingBase entity) { - return entity == Minecraft.getMinecraft().thePlayer; - } - - @Override - public boolean isClientPlayerWearingMonocle() { - return ItemMonocle.hasMonocle(Minecraft.getMinecraft().thePlayer); - } - - @Override - public void setExtraReach(EntityLivingBase entity, float reach) { - super.setExtraReach(entity, reach); - Minecraft mc = Minecraft.getMinecraft(); - EntityPlayer player = mc.thePlayer; - if(entity == player) { - if(!(mc.playerController instanceof IExtendedPlayerController)) { - GameType type = ReflectionHelper.getPrivateValue(PlayerControllerMP.class, mc.playerController, LibObfuscation.CURRENT_GAME_TYPE); - NetHandlerPlayClient net = ReflectionHelper.getPrivateValue(PlayerControllerMP.class, mc.playerController, LibObfuscation.NET_CLIENT_HANDLER); - BotaniaPlayerController controller = new BotaniaPlayerController(mc, net); - boolean isFlying = player.capabilities.isFlying; - boolean allowFlying = player.capabilities.allowFlying; - controller.setGameType(type); - player.capabilities.isFlying = isFlying; - player.capabilities.allowFlying = allowFlying; - mc.playerController = controller; - } - - ((IExtendedPlayerController) mc.playerController).setReachDistanceExtension(Math.max(0, ((IExtendedPlayerController) mc.playerController).getReachDistanceExtension() + reach)); - } - } - - @Override - public boolean openWikiPage(World world, Block block, MovingObjectPosition pos) { - IWikiProvider wiki = WikiHooks.getWikiFor(block); - String url = wiki.getWikiURL(world, pos); - if(url != null && !url.isEmpty()) { - try { - Desktop.getDesktop().browse(new URI(url)); - } catch(Exception e) { - e.printStackTrace(); - return false; - } - return true; - } - return false; - } - - @Override - public void playRecordClientSided(World world, int x, int y, int z, ItemRecord record) { - Minecraft mc = Minecraft.getMinecraft(); - if(record == null) - world.playAuxSFXAtEntity(null, 1005, x, y, z, 0); - else { - world.playAuxSFXAtEntity(null, 1005, x, y, z, Item.getIdFromItem(record)); - mc.ingameGUI.setRecordPlayingMessage(record.getRecordNameLocal()); - } - } - - @Override - public long getWorldElapsedTicks() { - return ClientTickHandler.ticksInGame; - } - - @Override - public void setMultiblock(World world, int x, int y, int z, double radius, Block block) { - MultiblockSextant mb = new MultiblockSextant(); - - int iradius = (int) radius + 1; - for(int i = 0; i < iradius * 2 + 1; i++) - for(int j = 0; j < iradius * 2 + 1; j++) { - int xp = x + i - iradius; - int zp = z + j - iradius; - if((int) Math.floor(MathHelper.pointDistancePlane(xp, zp, x, z)) == iradius - 1) - mb.addComponent(new AnyComponent(new ChunkCoordinates(xp - x, 1, zp - z), block, 0)); - } - - MultiblockRenderHandler.setMultiblock(mb.makeSet()); - MultiblockRenderHandler.anchor = new ChunkCoordinates(x, y, z); - } - - @Override - public void removeSextantMultiblock() { - MultiblockSet set = MultiblockRenderHandler.currentMultiblock; - if(set != null) { - Multiblock mb = set.getForIndex(0); - if(mb instanceof MultiblockSextant) - MultiblockRenderHandler.setMultiblock(null); - } - } - - private static boolean noclipEnabled = false; - private static boolean corruptSparkle = false; - - @Override - public void setSparkleFXNoClip(boolean noclip) { - noclipEnabled = noclip; - } - - @Override - public void setSparkleFXCorrupt(boolean corrupt) { - corruptSparkle = corrupt; - } - - @Override - public void sparkleFX(World world, double x, double y, double z, float r, float g, float b, float size, int m, boolean fake) { - if(!doParticle(world) && !fake) - return; - - FXSparkle sparkle = new FXSparkle(world, x, y, z, size, r, g, b, m); - sparkle.fake = sparkle.noClip = fake; - if(noclipEnabled) - sparkle.noClip = true; - if(corruptSparkle) - sparkle.corrupt = true; - Minecraft.getMinecraft().effectRenderer.addEffect(sparkle); - } - - private static boolean distanceLimit = true; - private static boolean depthTest = true; - - @Override - public void setWispFXDistanceLimit(boolean limit) { - distanceLimit = limit; - } - - @Override - public void setWispFXDepthTest(boolean test) { - depthTest = test; - } - - @Override - public void wispFX(World world, double x, double y, double z, float r, float g, float b, float size, float motionx, float motiony, float motionz, float maxAgeMul) { - if(!doParticle(world)) - return; - - FXWisp wisp = new FXWisp(world, x, y, z, size, r, g, b, distanceLimit, depthTest, maxAgeMul); - wisp.motionX = motionx; - wisp.motionY = motiony; - wisp.motionZ = motionz; - - Minecraft.getMinecraft().effectRenderer.addEffect(wisp); - } - - private boolean doParticle(World world) { - if(!world.isRemote) - return false; - - if(!ConfigHandler.useVanillaParticleLimiter) - return true; - - float chance = 1F; - if(Minecraft.getMinecraft().gameSettings.particleSetting == 1) - chance = 0.6F; - else if(Minecraft.getMinecraft().gameSettings.particleSetting == 2) - chance = 0.2F; - - return chance == 1F || Math.random() < chance; - } - - @Override - public void lightningFX(World world, Vector3 vectorStart, Vector3 vectorEnd, float ticksPerMeter, long seed, int colorOuter, int colorInner) { - LightningHandler.spawnLightningBolt(world, vectorStart, vectorEnd, ticksPerMeter, seed, colorOuter, colorInner); - } + public static boolean jingleTheBells = false; + public static boolean dootDoot = false; + + @Override + public void preInit(FMLPreInitializationEvent event) { + PersistentVariableHelper.setCacheFile(new File(Minecraft.getMinecraft().mcDataDir, "BotaniaVars.dat")); + try { + PersistentVariableHelper.load(); + PersistentVariableHelper.save(); + } catch (IOException e) { + FMLLog.severe("Botania's persistent Variables couldn't load!"); + e.printStackTrace(); + } + + super.preInit(event); + } + + @Override + public void init(FMLInitializationEvent event) { + super.init(event); + + ModChallenges.init(); + + FMLCommonHandler.instance().bus().register(new ClientTickHandler()); + MinecraftForge.EVENT_BUS.register(new HUDHandler()); + MinecraftForge.EVENT_BUS.register(new LightningHandler()); + if (ConfigHandler.boundBlockWireframe) MinecraftForge.EVENT_BUS.register(new BoundTileRenderer()); + MinecraftForge.EVENT_BUS.register(new TooltipHandler()); + MinecraftForge.EVENT_BUS.register(new BaubleRenderHandler()); + MinecraftForge.EVENT_BUS.register(new DebugHandler()); + MinecraftForge.EVENT_BUS.register(new SubTileRadiusRenderHandler()); + MinecraftForge.EVENT_BUS.register(new MultiblockRenderHandler()); + MinecraftForge.EVENT_BUS.register(new SkyblockRenderEvents()); + FMLCommonHandler.instance().bus().register(new CorporeaAutoCompleteHandler()); + + if (ConfigHandler.enableSeasonalFeatures) { + Calendar calendar = Calendar.getInstance(); + if ((calendar.get(2) == 11 && calendar.get(5) >= 16) || (calendar.get(2) == 0 && calendar.get(5) <= 2)) + jingleTheBells = true; + if (calendar.get(2) == 9) dootDoot = true; + } + + initRenderers(); + } + + @Override + public void postInit(FMLPostInitializationEvent event) { + super.postInit(event); + CorporeaAutoCompleteHandler.updateItemList(); + } + + private void initRenderers() { + LibRenderIDs.idAltar = RenderingRegistry.getNextAvailableRenderId(); + LibRenderIDs.idSpecialFlower = RenderingRegistry.getNextAvailableRenderId(); + LibRenderIDs.idSpreader = RenderingRegistry.getNextAvailableRenderId(); + LibRenderIDs.idPool = RenderingRegistry.getNextAvailableRenderId(); + LibRenderIDs.idPylon = RenderingRegistry.getNextAvailableRenderId(); + LibRenderIDs.idMiniIsland = RenderingRegistry.getNextAvailableRenderId(); + LibRenderIDs.idTinyPotato = RenderingRegistry.getNextAvailableRenderId(); + LibRenderIDs.idSpawnerClaw = RenderingRegistry.getNextAvailableRenderId(); + LibRenderIDs.idBrewery = RenderingRegistry.getNextAvailableRenderId(); + LibRenderIDs.idCorporeaIndex = RenderingRegistry.getNextAvailableRenderId(); + LibRenderIDs.idPump = RenderingRegistry.getNextAvailableRenderId(); + LibRenderIDs.idDoubleFlower = RenderingRegistry.getNextAvailableRenderId(); + LibRenderIDs.idCorporeaCrystalCybe = RenderingRegistry.getNextAvailableRenderId(); + LibRenderIDs.idIncensePlate = RenderingRegistry.getNextAvailableRenderId(); + LibRenderIDs.idHourglass = RenderingRegistry.getNextAvailableRenderId(); + LibRenderIDs.idCocoon = RenderingRegistry.getNextAvailableRenderId(); + LibRenderIDs.idLightRelay = RenderingRegistry.getNextAvailableRenderId(); + LibRenderIDs.idBellows = RenderingRegistry.getNextAvailableRenderId(); + LibRenderIDs.idTeruTeruBozu = RenderingRegistry.getNextAvailableRenderId(); + LibRenderIDs.idAvatar = RenderingRegistry.getNextAvailableRenderId(); + + RenderSpecialFlower specialFlowerRender = new RenderSpecialFlower(LibRenderIDs.idSpecialFlower); + RenderingRegistry.registerBlockHandler(new RenderAltar()); + RenderingRegistry.registerBlockHandler(specialFlowerRender); + RenderingRegistry.registerBlockHandler(new RenderSpreader()); + RenderingRegistry.registerBlockHandler(new RenderPool()); + RenderingRegistry.registerBlockHandler(new RenderPylon()); + RenderingRegistry.registerBlockHandler(new RenderFloatingFlower()); + RenderingRegistry.registerBlockHandler(new RenderTinyPotato()); + RenderingRegistry.registerBlockHandler(new RenderSpawnerClaw()); + RenderingRegistry.registerBlockHandler(new RenderBrewery()); + RenderingRegistry.registerBlockHandler(new RenderCorporeaIndex()); + RenderingRegistry.registerBlockHandler(new RenderPump()); + RenderingRegistry.registerBlockHandler(new RenderDoubleFlower()); + RenderingRegistry.registerBlockHandler(new RenderCorporeaCrystalCube()); + RenderingRegistry.registerBlockHandler(new RenderIncensePlate()); + RenderingRegistry.registerBlockHandler(new RenderHourglass()); + RenderingRegistry.registerBlockHandler(new RenderCocoon()); + RenderingRegistry.registerBlockHandler(new RenderBellows()); + RenderingRegistry.registerBlockHandler(new RenderTeruTeruBozu()); + RenderingRegistry.registerBlockHandler(new RenderAvatar()); + + IMultiblockRenderHook.renderHooks.put(ModBlocks.flower, specialFlowerRender); + IMultiblockRenderHook.renderHooks.put(ModBlocks.shinyFlower, specialFlowerRender); + + RenderTransparentItem renderTransparentItem = new RenderTransparentItem(); + RenderFloatingFlowerItem renderFloatingFlower = new RenderFloatingFlowerItem(); + RenderBow renderBow = new RenderBow(); + + MinecraftForgeClient.registerItemRenderer(ModItems.lens, new RenderLens()); + if (ConfigHandler.lexicon3dModel) + MinecraftForgeClient.registerItemRenderer(ModItems.lexicon, new RenderLexicon()); + MinecraftForgeClient.registerItemRenderer(ModItems.glassPick, renderTransparentItem); + MinecraftForgeClient.registerItemRenderer(ModItems.spark, renderTransparentItem); + MinecraftForgeClient.registerItemRenderer( + Item.getItemFromBlock(ModBlocks.floatingFlower), renderFloatingFlower); + MinecraftForgeClient.registerItemRenderer( + Item.getItemFromBlock(ModBlocks.floatingSpecialFlower), renderFloatingFlower); + MinecraftForgeClient.registerItemRenderer(ModItems.livingwoodBow, renderBow); + MinecraftForgeClient.registerItemRenderer(ModItems.crystalBow, renderBow); + + RenderTileFloatingFlower renderTileFloatingFlower = new RenderTileFloatingFlower(); + ClientRegistry.bindTileEntitySpecialRenderer(TileAltar.class, new RenderTileAltar()); + ClientRegistry.bindTileEntitySpecialRenderer(TileSpreader.class, new RenderTileSpreader()); + ClientRegistry.bindTileEntitySpecialRenderer(TilePool.class, new RenderTilePool()); + ClientRegistry.bindTileEntitySpecialRenderer(TileRuneAltar.class, new RenderTileRuneAltar()); + ClientRegistry.bindTileEntitySpecialRenderer(TilePylon.class, new RenderTilePylon()); + ClientRegistry.bindTileEntitySpecialRenderer(TileEnchanter.class, new RenderTileEnchanter()); + ClientRegistry.bindTileEntitySpecialRenderer(TileAlfPortal.class, new RenderTileAlfPortal()); + ClientRegistry.bindTileEntitySpecialRenderer(TileFloatingFlower.class, renderTileFloatingFlower); + ClientRegistry.bindTileEntitySpecialRenderer(TileFloatingSpecialFlower.class, renderTileFloatingFlower); + ClientRegistry.bindTileEntitySpecialRenderer(TileTinyPotato.class, new RenderTileTinyPotato()); + ClientRegistry.bindTileEntitySpecialRenderer(TileSpawnerClaw.class, new RenderTileSpawnerClaw()); + ClientRegistry.bindTileEntitySpecialRenderer(TileStarfield.class, new RenderTileStarfield()); + ClientRegistry.bindTileEntitySpecialRenderer(TileBrewery.class, new RenderTileBrewery()); + ClientRegistry.bindTileEntitySpecialRenderer(TileTerraPlate.class, new RenderTileTerraPlate()); + ClientRegistry.bindTileEntitySpecialRenderer(TileRedString.class, new RenderTileRedString()); + ClientRegistry.bindTileEntitySpecialRenderer(TilePrism.class, new RenderTilePrism()); + ClientRegistry.bindTileEntitySpecialRenderer(TileCorporeaIndex.class, new RenderTileCorporeaIndex()); + ClientRegistry.bindTileEntitySpecialRenderer(TilePump.class, new RenderTilePump()); + ClientRegistry.bindTileEntitySpecialRenderer( + TileCorporeaCrystalCube.class, new RenderTileCorporeaCrystalCube()); + ClientRegistry.bindTileEntitySpecialRenderer(TileIncensePlate.class, new RenderTileIncensePlate()); + ClientRegistry.bindTileEntitySpecialRenderer(TileHourglass.class, new RenderTileHourglass()); + ClientRegistry.bindTileEntitySpecialRenderer(TileSparkChanger.class, new RenderTileSparkChanger()); + ClientRegistry.bindTileEntitySpecialRenderer(TileCocoon.class, new RenderTileCocoon()); + ClientRegistry.bindTileEntitySpecialRenderer(TileLightRelay.class, new RenderTileLightRelay()); + ClientRegistry.bindTileEntitySpecialRenderer(TileBellows.class, new RenderTileBellows()); + ClientRegistry.bindTileEntitySpecialRenderer(TileGaiaHead.class, new RenderTileSkullOverride()); + ClientRegistry.bindTileEntitySpecialRenderer(TileTeruTeruBozu.class, new RenderTileTeruTeruBozu()); + ClientRegistry.bindTileEntitySpecialRenderer(TileAvatar.class, new RenderTileAvatar()); + + ClientRegistry.bindTileEntitySpecialRenderer(TileEntitySkull.class, new RenderTileSkullOverride()); + + RenderingRegistry.registerEntityRenderingHandler(EntityPixie.class, new RenderPixie()); + RenderingRegistry.registerEntityRenderingHandler(EntityVineBall.class, new RenderSnowball(ModItems.vineBall)); + RenderingRegistry.registerEntityRenderingHandler(EntityDoppleganger.class, new RenderDoppleganger()); + RenderingRegistry.registerEntityRenderingHandler(EntitySpark.class, new RenderSpark()); + RenderingRegistry.registerEntityRenderingHandler(EntityThornChakram.class, new RenderThornChakram()); + RenderingRegistry.registerEntityRenderingHandler(EntityCorporeaSpark.class, new RenderCorporeaSpark()); + RenderingRegistry.registerEntityRenderingHandler( + EntityEnderAirBottle.class, new RenderSnowball(ModItems.manaResource, 15)); + RenderingRegistry.registerEntityRenderingHandler(EntityPoolMinecart.class, new RenderPoolMinecart()); + RenderingRegistry.registerEntityRenderingHandler(EntityPinkWither.class, new RenderPinkWither()); + RenderingRegistry.registerEntityRenderingHandler(EntityManaStorm.class, new RenderManaStorm()); + RenderingRegistry.registerEntityRenderingHandler(EntityBabylonWeapon.class, new RenderBabylonWeapon()); + + ShaderHelper.initShaders(); + } + + @Override + @Optional.Method(modid = "NotEnoughItems") + public void registerNEIStuff() { + NEIGuiHooks.init(); + } + + @Override + public void setEntryToOpen(LexiconEntry entry) { + GuiLexicon.currentOpenLexicon = new GuiLexiconEntry(entry, new GuiLexiconIndex(entry.category)); + } + + @Override + public void setToTutorialIfFirstLaunch() { + if (PersistentVariableHelper.firstLoad) + GuiLexicon.currentOpenLexicon = new GuiLexiconEntry( + LexiconData.welcome, new GuiLexiconEntry(LexiconData.tutorial, new GuiLexicon())) + .setFirstEntry(); + } + + @Override + public void setLexiconStack(ItemStack stack) { + GuiLexicon.stackUsed = stack; + } + + @Override + public boolean isTheClientPlayer(EntityLivingBase entity) { + return entity == Minecraft.getMinecraft().thePlayer; + } + + @Override + public boolean isClientPlayerWearingMonocle() { + return ItemMonocle.hasMonocle(Minecraft.getMinecraft().thePlayer); + } + + @Override + public void setExtraReach(EntityLivingBase entity, float reach) { + super.setExtraReach(entity, reach); + Minecraft mc = Minecraft.getMinecraft(); + EntityPlayer player = mc.thePlayer; + if (entity == player) { + if (!(mc.playerController instanceof IExtendedPlayerController)) { + GameType type = ReflectionHelper.getPrivateValue( + PlayerControllerMP.class, mc.playerController, LibObfuscation.CURRENT_GAME_TYPE); + NetHandlerPlayClient net = ReflectionHelper.getPrivateValue( + PlayerControllerMP.class, mc.playerController, LibObfuscation.NET_CLIENT_HANDLER); + BotaniaPlayerController controller = new BotaniaPlayerController(mc, net); + boolean isFlying = player.capabilities.isFlying; + boolean allowFlying = player.capabilities.allowFlying; + controller.setGameType(type); + player.capabilities.isFlying = isFlying; + player.capabilities.allowFlying = allowFlying; + mc.playerController = controller; + } + + ((IExtendedPlayerController) mc.playerController) + .setReachDistanceExtension(Math.max( + 0, ((IExtendedPlayerController) mc.playerController).getReachDistanceExtension() + reach)); + } + } + + @Override + public boolean openWikiPage(World world, Block block, MovingObjectPosition pos) { + IWikiProvider wiki = WikiHooks.getWikiFor(block); + String url = wiki.getWikiURL(world, pos); + if (url != null && !url.isEmpty()) { + try { + Desktop.getDesktop().browse(new URI(url)); + } catch (Exception e) { + e.printStackTrace(); + return false; + } + return true; + } + return false; + } + + @Override + public void playRecordClientSided(World world, int x, int y, int z, ItemRecord record) { + Minecraft mc = Minecraft.getMinecraft(); + if (record == null) world.playAuxSFXAtEntity(null, 1005, x, y, z, 0); + else { + world.playAuxSFXAtEntity(null, 1005, x, y, z, Item.getIdFromItem(record)); + mc.ingameGUI.setRecordPlayingMessage(record.getRecordNameLocal()); + } + } + + @Override + public long getWorldElapsedTicks() { + return ClientTickHandler.ticksInGame; + } + + @Override + public void setMultiblock(World world, int x, int y, int z, double radius, Block block) { + MultiblockSextant mb = new MultiblockSextant(); + + int iradius = (int) radius + 1; + for (int i = 0; i < iradius * 2 + 1; i++) + for (int j = 0; j < iradius * 2 + 1; j++) { + int xp = x + i - iradius; + int zp = z + j - iradius; + if ((int) Math.floor(MathHelper.pointDistancePlane(xp, zp, x, z)) == iradius - 1) + mb.addComponent(new AnyComponent(new ChunkCoordinates(xp - x, 1, zp - z), block, 0)); + } + + MultiblockRenderHandler.setMultiblock(mb.makeSet()); + MultiblockRenderHandler.anchor = new ChunkCoordinates(x, y, z); + } + + @Override + public void removeSextantMultiblock() { + MultiblockSet set = MultiblockRenderHandler.currentMultiblock; + if (set != null) { + Multiblock mb = set.getForIndex(0); + if (mb instanceof MultiblockSextant) MultiblockRenderHandler.setMultiblock(null); + } + } + + private static boolean noclipEnabled = false; + private static boolean corruptSparkle = false; + + @Override + public void setSparkleFXNoClip(boolean noclip) { + noclipEnabled = noclip; + } + + @Override + public void setSparkleFXCorrupt(boolean corrupt) { + corruptSparkle = corrupt; + } + + @Override + public void sparkleFX( + World world, double x, double y, double z, float r, float g, float b, float size, int m, boolean fake) { + if (!doParticle(world) && !fake) return; + + FXSparkle sparkle = new FXSparkle(world, x, y, z, size, r, g, b, m); + sparkle.fake = sparkle.noClip = fake; + if (noclipEnabled) sparkle.noClip = true; + if (corruptSparkle) sparkle.corrupt = true; + Minecraft.getMinecraft().effectRenderer.addEffect(sparkle); + } + + private static boolean distanceLimit = true; + private static boolean depthTest = true; + + @Override + public void setWispFXDistanceLimit(boolean limit) { + distanceLimit = limit; + } + + @Override + public void setWispFXDepthTest(boolean test) { + depthTest = test; + } + + @Override + public void wispFX( + World world, + double x, + double y, + double z, + float r, + float g, + float b, + float size, + float motionx, + float motiony, + float motionz, + float maxAgeMul) { + if (!doParticle(world)) return; + + FXWisp wisp = new FXWisp(world, x, y, z, size, r, g, b, distanceLimit, depthTest, maxAgeMul); + wisp.motionX = motionx; + wisp.motionY = motiony; + wisp.motionZ = motionz; + + Minecraft.getMinecraft().effectRenderer.addEffect(wisp); + } + + private boolean doParticle(World world) { + if (!world.isRemote) return false; + + if (!ConfigHandler.useVanillaParticleLimiter) return true; + + float chance = 1F; + if (Minecraft.getMinecraft().gameSettings.particleSetting == 1) chance = 0.6F; + else if (Minecraft.getMinecraft().gameSettings.particleSetting == 2) chance = 0.2F; + + return chance == 1F || Math.random() < chance; + } + + @Override + public void lightningFX( + World world, + Vector3 vectorStart, + Vector3 vectorEnd, + float ticksPerMeter, + long seed, + int colorOuter, + int colorInner) { + LightningHandler.spawnLightningBolt(world, vectorStart, vectorEnd, ticksPerMeter, seed, colorOuter, colorInner); + } } - diff --git a/src/main/java/vazkii/botania/client/core/proxy/GuiFactory.java b/src/main/java/vazkii/botania/client/core/proxy/GuiFactory.java index 2a558708d4..ded018ce14 100644 --- a/src/main/java/vazkii/botania/client/core/proxy/GuiFactory.java +++ b/src/main/java/vazkii/botania/client/core/proxy/GuiFactory.java @@ -2,41 +2,39 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jun 27, 2014, 1:50:49 AM (GMT)] */ package vazkii.botania.client.core.proxy; +import cpw.mods.fml.client.IModGuiFactory; import java.util.Set; - import net.minecraft.client.Minecraft; import net.minecraft.client.gui.GuiScreen; import vazkii.botania.client.gui.GuiBotaniaConfig; -import cpw.mods.fml.client.IModGuiFactory; public class GuiFactory implements IModGuiFactory { - @Override - public void initialize(Minecraft minecraftInstance) { - // NO-OP - } - - @Override - public Class mainConfigGuiClass() { - return GuiBotaniaConfig.class; - } - - @Override - public Set runtimeGuiCategories() { - return null; - } - - @Override - public RuntimeOptionGuiHandler getHandlerFor(RuntimeOptionCategoryElement element) { - return null; - } - + @Override + public void initialize(Minecraft minecraftInstance) { + // NO-OP + } + + @Override + public Class mainConfigGuiClass() { + return GuiBotaniaConfig.class; + } + + @Override + public Set runtimeGuiCategories() { + return null; + } + + @Override + public RuntimeOptionGuiHandler getHandlerFor(RuntimeOptionCategoryElement element) { + return null; + } } diff --git a/src/main/java/vazkii/botania/client/fx/FXSparkle.java b/src/main/java/vazkii/botania/client/fx/FXSparkle.java index 61a5636319..89559f1e82 100644 --- a/src/main/java/vazkii/botania/client/fx/FXSparkle.java +++ b/src/main/java/vazkii/botania/client/fx/FXSparkle.java @@ -2,26 +2,23 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [? (GMT)] */ package vazkii.botania.client.fx; import java.util.ArrayDeque; import java.util.Queue; - import net.minecraft.client.Minecraft; import net.minecraft.client.particle.EntityFX; import net.minecraft.client.renderer.Tessellator; import net.minecraft.util.MathHelper; import net.minecraft.util.ResourceLocation; import net.minecraft.world.World; - import org.lwjgl.opengl.GL11; - import vazkii.botania.client.core.helper.ShaderHelper; import vazkii.botania.client.lib.LibResources; import vazkii.botania.common.core.handler.ConfigHandler; @@ -29,230 +26,228 @@ public class FXSparkle extends EntityFX { - public static final ResourceLocation particles = new ResourceLocation(LibResources.MISC_PARTICLES); - - public static Queue queuedRenders = new ArrayDeque(); - public static Queue queuedCorruptRenders = new ArrayDeque(); - - // Queue values - float f; - float f1; - float f2; - float f3; - float f4; - float f5; - - public FXSparkle(World world, double x, double y, double z, float size, float red, float green, float blue, int m) { - super(world, x, y, z, 0.0D, 0.0D, 0.0D); - - particleRed = red; - particleGreen = green; - particleBlue = blue; - particleGravity = 0; - motionX = motionY = motionZ = 0; - particleScale *= size; - particleMaxAge = 3 * m; - multiplier = m; - noClip = false; - setSize(0.01F, 0.01F); - prevPosX = posX; - prevPosY = posY; - prevPosZ = posZ; - } - - public static void dispatchQueuedRenders(Tessellator tessellator) { - ParticleRenderDispatcher.sparkleFxCount = 0; - ParticleRenderDispatcher.fakeSparkleFxCount = 0; - - GL11.glColor4f(1.0F, 1.0F, 1.0F, 0.75F); - Minecraft.getMinecraft().renderEngine.bindTexture(ConfigHandler.matrixMode ? ObfuscationHelper.getParticleTexture() : particles); - - tessellator.startDrawingQuads(); - for(FXSparkle sparkle : queuedRenders) - sparkle.renderQueued(tessellator); - tessellator.draw(); - - ShaderHelper.useShader(ShaderHelper.filmGrain); - tessellator.startDrawingQuads(); - for(FXSparkle sparkle : queuedCorruptRenders) - sparkle.renderQueued(tessellator); - tessellator.draw(); - ShaderHelper.releaseShader(); - - queuedRenders.clear(); - queuedCorruptRenders.clear(); - } - - private void renderQueued(Tessellator tessellator) { - if(fake) - ParticleRenderDispatcher.fakeSparkleFxCount++; - else ParticleRenderDispatcher.sparkleFxCount++; - - int part = particle + particleAge/multiplier; - - float var8 = part % 8 / 8.0F; - float var9 = var8 + 0.0624375F*2; - float var10 = part / 8 / 8.0F; - float var11 = var10 + 0.0624375F*2; - float var12 = 0.1F * particleScale; - if (shrink) var12 *= (particleMaxAge-particleAge+1)/(float)particleMaxAge; - float var13 = (float)(prevPosX + (posX - prevPosX) * f - interpPosX); - float var14 = (float)(prevPosY + (posY - prevPosY) * f - interpPosY); - float var15 = (float)(prevPosZ + (posZ - prevPosZ) * f - interpPosZ); - float var16 = 1.0F; - - tessellator.setBrightness(0x0000f0); - - tessellator.setColorRGBA_F(particleRed * var16, particleGreen * var16, particleBlue * var16, 1); - tessellator.addVertexWithUV(var13 - f1 * var12 - f4 * var12, var14 - f2 * var12, var15 - f3 * var12 - f5 * var12, var9, var11); - tessellator.addVertexWithUV(var13 - f1 * var12 + f4 * var12, var14 + f2 * var12, var15 - f3 * var12 + f5 * var12, var9, var10); - tessellator.addVertexWithUV(var13 + f1 * var12 + f4 * var12, var14 + f2 * var12, var15 + f3 * var12 + f5 * var12, var8, var10); - tessellator.addVertexWithUV(var13 + f1 * var12 - f4 * var12, var14 - f2 * var12, var15 + f3 * var12 - f5 * var12, var8, var11); - - } - - @Override - public void renderParticle(Tessellator tessellator, float f, float f1, float f2, float f3, float f4, float f5) { - this.f = f; - this.f1 = f1; - this.f2 = f2; - this.f3 = f3; - this.f4 = f4; - this.f5 = f5; - - if(corrupt) - queuedCorruptRenders.add(this); - else queuedRenders.add(this); - } - - @Override - public void onUpdate() { - prevPosX = posX; - prevPosY = posY; - prevPosZ = posZ; - - if (particleAge++ >= particleMaxAge) - setDead(); - - motionY -= 0.04D * particleGravity; - - if (!noClip && !fake) - pushOutOfBlocks(posX, (boundingBox.minY + boundingBox.maxY) / 2.0D, posZ); - - posX += motionX; - posY += motionY; - posZ += motionZ; - - if (slowdown) { - motionX *= 0.908000001907348633D; - motionY *= 0.908000001907348633D; - motionZ *= 0.908000001907348633D; - - if (onGround) { - motionX *= 0.69999998807907104D; - motionZ *= 0.69999998807907104D; - } - } - - if(fake && particleAge > 1) - setDead(); - } - - public void setGravity(float value) { - particleGravity = value; - } - - protected boolean pushOutOfBlocks(double par1, double par3, double par5) { - int var7 = MathHelper.floor_double(par1); - int var8 = MathHelper.floor_double(par3); - int var9 = MathHelper.floor_double(par5); - double var10 = par1 - var7; - double var12 = par3 - var8; - double var14 = par5 - var9; - - if (!worldObj.isAirBlock(var7, var8, var9)) { - boolean var16 = !worldObj.isBlockNormalCubeDefault(var7 - 1, var8, var9, false); - boolean var17 = !worldObj.isBlockNormalCubeDefault(var7 + 1, var8, var9, false); - boolean var18 = !worldObj.isBlockNormalCubeDefault(var7, var8 - 1, var9, false); - boolean var19 = !worldObj.isBlockNormalCubeDefault(var7, var8 + 1, var9, false); - boolean var20 = !worldObj.isBlockNormalCubeDefault(var7, var8, var9 - 1, false); - boolean var21 = !worldObj.isBlockNormalCubeDefault(var7, var8, var9 + 1, false); - byte var22 = -1; - double var23 = 9999.0D; - - if (var16 && var10 < var23) { - var23 = var10; - var22 = 0; - } - - if (var17 && 1.0D - var10 < var23) { - var23 = 1.0D - var10; - var22 = 1; - } - - if (var18 && var12 < var23) { - var23 = var12; - var22 = 2; - } - - if (var19 && 1.0D - var12 < var23) { - var23 = 1.0D - var12; - var22 = 3; - } - - if (var20 && var14 < var23) { - var23 = var14; - var22 = 4; - } - - if (var21 && 1.0D - var14 < var23) { - var23 = 1.0D - var14; - var22 = 5; - } - - float var25 = rand.nextFloat() * 0.05F + 0.025F; - float var26 = (rand.nextFloat() - rand.nextFloat()) * 0.1F; - - if (var22 == 0) { - motionX = -var25; - motionY=motionZ=var26; - } - - if (var22 == 1) { - motionX = var25; - motionY=motionZ=var26; - } - - if (var22 == 2) { - motionY = -var25; - motionX=motionZ=var26; - } - - if (var22 == 3) { - motionY = var25; - motionX=motionZ=var26; - } - - if (var22 == 4) { - motionZ = -var25; - motionY=motionX=var26; - } - - if (var22 == 5) { - motionZ = var25; - motionY=motionX=var26; - } - - return true; - } else return false; - } - - public boolean corrupt = false; - public boolean fake = false; - public int multiplier = 2; - public boolean shrink = true; - public int particle = 16; - public boolean tinkle = false; - public boolean slowdown = true; - public int currentColor = 0; + public static final ResourceLocation particles = new ResourceLocation(LibResources.MISC_PARTICLES); + + public static Queue queuedRenders = new ArrayDeque(); + public static Queue queuedCorruptRenders = new ArrayDeque(); + + // Queue values + float f; + float f1; + float f2; + float f3; + float f4; + float f5; + + public FXSparkle(World world, double x, double y, double z, float size, float red, float green, float blue, int m) { + super(world, x, y, z, 0.0D, 0.0D, 0.0D); + + particleRed = red; + particleGreen = green; + particleBlue = blue; + particleGravity = 0; + motionX = motionY = motionZ = 0; + particleScale *= size; + particleMaxAge = 3 * m; + multiplier = m; + noClip = false; + setSize(0.01F, 0.01F); + prevPosX = posX; + prevPosY = posY; + prevPosZ = posZ; + } + + public static void dispatchQueuedRenders(Tessellator tessellator) { + ParticleRenderDispatcher.sparkleFxCount = 0; + ParticleRenderDispatcher.fakeSparkleFxCount = 0; + + GL11.glColor4f(1.0F, 1.0F, 1.0F, 0.75F); + Minecraft.getMinecraft() + .renderEngine + .bindTexture(ConfigHandler.matrixMode ? ObfuscationHelper.getParticleTexture() : particles); + + tessellator.startDrawingQuads(); + for (FXSparkle sparkle : queuedRenders) sparkle.renderQueued(tessellator); + tessellator.draw(); + + ShaderHelper.useShader(ShaderHelper.filmGrain); + tessellator.startDrawingQuads(); + for (FXSparkle sparkle : queuedCorruptRenders) sparkle.renderQueued(tessellator); + tessellator.draw(); + ShaderHelper.releaseShader(); + + queuedRenders.clear(); + queuedCorruptRenders.clear(); + } + + private void renderQueued(Tessellator tessellator) { + if (fake) ParticleRenderDispatcher.fakeSparkleFxCount++; + else ParticleRenderDispatcher.sparkleFxCount++; + + int part = particle + particleAge / multiplier; + + float var8 = part % 8 / 8.0F; + float var9 = var8 + 0.0624375F * 2; + float var10 = part / 8 / 8.0F; + float var11 = var10 + 0.0624375F * 2; + float var12 = 0.1F * particleScale; + if (shrink) var12 *= (particleMaxAge - particleAge + 1) / (float) particleMaxAge; + float var13 = (float) (prevPosX + (posX - prevPosX) * f - interpPosX); + float var14 = (float) (prevPosY + (posY - prevPosY) * f - interpPosY); + float var15 = (float) (prevPosZ + (posZ - prevPosZ) * f - interpPosZ); + float var16 = 1.0F; + + tessellator.setBrightness(0x0000f0); + + tessellator.setColorRGBA_F(particleRed * var16, particleGreen * var16, particleBlue * var16, 1); + tessellator.addVertexWithUV( + var13 - f1 * var12 - f4 * var12, var14 - f2 * var12, var15 - f3 * var12 - f5 * var12, var9, var11); + tessellator.addVertexWithUV( + var13 - f1 * var12 + f4 * var12, var14 + f2 * var12, var15 - f3 * var12 + f5 * var12, var9, var10); + tessellator.addVertexWithUV( + var13 + f1 * var12 + f4 * var12, var14 + f2 * var12, var15 + f3 * var12 + f5 * var12, var8, var10); + tessellator.addVertexWithUV( + var13 + f1 * var12 - f4 * var12, var14 - f2 * var12, var15 + f3 * var12 - f5 * var12, var8, var11); + } + + @Override + public void renderParticle(Tessellator tessellator, float f, float f1, float f2, float f3, float f4, float f5) { + this.f = f; + this.f1 = f1; + this.f2 = f2; + this.f3 = f3; + this.f4 = f4; + this.f5 = f5; + + if (corrupt) queuedCorruptRenders.add(this); + else queuedRenders.add(this); + } + + @Override + public void onUpdate() { + prevPosX = posX; + prevPosY = posY; + prevPosZ = posZ; + + if (particleAge++ >= particleMaxAge) setDead(); + + motionY -= 0.04D * particleGravity; + + if (!noClip && !fake) pushOutOfBlocks(posX, (boundingBox.minY + boundingBox.maxY) / 2.0D, posZ); + + posX += motionX; + posY += motionY; + posZ += motionZ; + + if (slowdown) { + motionX *= 0.908000001907348633D; + motionY *= 0.908000001907348633D; + motionZ *= 0.908000001907348633D; + + if (onGround) { + motionX *= 0.69999998807907104D; + motionZ *= 0.69999998807907104D; + } + } + + if (fake && particleAge > 1) setDead(); + } + + public void setGravity(float value) { + particleGravity = value; + } + + protected boolean pushOutOfBlocks(double par1, double par3, double par5) { + int var7 = MathHelper.floor_double(par1); + int var8 = MathHelper.floor_double(par3); + int var9 = MathHelper.floor_double(par5); + double var10 = par1 - var7; + double var12 = par3 - var8; + double var14 = par5 - var9; + + if (!worldObj.isAirBlock(var7, var8, var9)) { + boolean var16 = !worldObj.isBlockNormalCubeDefault(var7 - 1, var8, var9, false); + boolean var17 = !worldObj.isBlockNormalCubeDefault(var7 + 1, var8, var9, false); + boolean var18 = !worldObj.isBlockNormalCubeDefault(var7, var8 - 1, var9, false); + boolean var19 = !worldObj.isBlockNormalCubeDefault(var7, var8 + 1, var9, false); + boolean var20 = !worldObj.isBlockNormalCubeDefault(var7, var8, var9 - 1, false); + boolean var21 = !worldObj.isBlockNormalCubeDefault(var7, var8, var9 + 1, false); + byte var22 = -1; + double var23 = 9999.0D; + + if (var16 && var10 < var23) { + var23 = var10; + var22 = 0; + } + + if (var17 && 1.0D - var10 < var23) { + var23 = 1.0D - var10; + var22 = 1; + } + + if (var18 && var12 < var23) { + var23 = var12; + var22 = 2; + } + + if (var19 && 1.0D - var12 < var23) { + var23 = 1.0D - var12; + var22 = 3; + } + + if (var20 && var14 < var23) { + var23 = var14; + var22 = 4; + } + + if (var21 && 1.0D - var14 < var23) { + var23 = 1.0D - var14; + var22 = 5; + } + + float var25 = rand.nextFloat() * 0.05F + 0.025F; + float var26 = (rand.nextFloat() - rand.nextFloat()) * 0.1F; + + if (var22 == 0) { + motionX = -var25; + motionY = motionZ = var26; + } + + if (var22 == 1) { + motionX = var25; + motionY = motionZ = var26; + } + + if (var22 == 2) { + motionY = -var25; + motionX = motionZ = var26; + } + + if (var22 == 3) { + motionY = var25; + motionX = motionZ = var26; + } + + if (var22 == 4) { + motionZ = -var25; + motionY = motionX = var26; + } + + if (var22 == 5) { + motionZ = var25; + motionY = motionX = var26; + } + + return true; + } else return false; + } + + public boolean corrupt = false; + public boolean fake = false; + public int multiplier = 2; + public boolean shrink = true; + public int particle = 16; + public boolean tinkle = false; + public boolean slowdown = true; + public int currentColor = 0; } diff --git a/src/main/java/vazkii/botania/client/fx/FXWisp.java b/src/main/java/vazkii/botania/client/fx/FXWisp.java index 05ad91c989..2369b461dc 100644 --- a/src/main/java/vazkii/botania/client/fx/FXWisp.java +++ b/src/main/java/vazkii/botania/client/fx/FXWisp.java @@ -2,169 +2,172 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [? (GMT)] */ package vazkii.botania.client.fx; +import cpw.mods.fml.client.FMLClientHandler; import java.util.ArrayDeque; import java.util.Queue; - import net.minecraft.client.Minecraft; import net.minecraft.client.particle.EntityFX; import net.minecraft.client.renderer.Tessellator; import net.minecraft.entity.EntityLivingBase; import net.minecraft.util.ResourceLocation; import net.minecraft.world.World; - import org.lwjgl.opengl.GL11; - import vazkii.botania.client.lib.LibResources; import vazkii.botania.common.core.handler.ConfigHandler; import vazkii.botania.common.core.helper.ObfuscationHelper; -import cpw.mods.fml.client.FMLClientHandler; public class FXWisp extends EntityFX { - public static final ResourceLocation particles = new ResourceLocation(LibResources.MISC_WISP_LARGE); - - public static Queue queuedRenders = new ArrayDeque(); - public static Queue queuedDepthIgnoringRenders = new ArrayDeque(); - - // Queue values - float f; - float f1; - float f2; - float f3; - float f4; - float f5; - - public FXWisp(World world, double d, double d1, double d2, float size, float red, float green, float blue, boolean distanceLimit, boolean depthTest, float maxAgeMul) { - super(world, d, d1, d2, 0.0D, 0.0D, 0.0D); - particleRed = red; - particleGreen = green; - particleBlue = blue; - particleGravity = 0; - motionX = motionY = motionZ = 0; - particleScale *= size; - moteParticleScale = particleScale; - particleMaxAge = (int)(28D / (Math.random() * 0.3D + 0.7D) * maxAgeMul); - this.depthTest = depthTest; - - moteHalfLife = particleMaxAge / 2; - noClip = true; - setSize(0.01F, 0.01F); - EntityLivingBase renderentity = FMLClientHandler.instance().getClient().renderViewEntity; - - if(distanceLimit) { - int visibleDistance = 50; - if (!FMLClientHandler.instance().getClient().gameSettings.fancyGraphics) - visibleDistance = 25; - - if (renderentity == null || renderentity.getDistance(posX, posY, posZ) > visibleDistance) - particleMaxAge = 0; - } - - prevPosX = posX; - prevPosY = posY; - prevPosZ = posZ; - } - - public static void dispatchQueuedRenders(Tessellator tessellator) { - ParticleRenderDispatcher.wispFxCount = 0; - ParticleRenderDispatcher.depthIgnoringWispFxCount = 0; - - GL11.glColor4f(1.0F, 1.0F, 1.0F, 0.75F); - Minecraft.getMinecraft().renderEngine.bindTexture(ConfigHandler.matrixMode ? ObfuscationHelper.getParticleTexture() : particles); - - if(!queuedRenders.isEmpty()) { - tessellator.startDrawingQuads(); - for(FXWisp wisp : queuedRenders) - wisp.renderQueued(tessellator, true); - tessellator.draw(); - } - - if(!queuedDepthIgnoringRenders.isEmpty()) { - GL11.glDisable(GL11.GL_DEPTH_TEST); - tessellator.startDrawingQuads(); - for(FXWisp wisp : queuedDepthIgnoringRenders) - wisp.renderQueued(tessellator, false); - tessellator.draw(); - GL11.glEnable(GL11.GL_DEPTH_TEST); - } - - queuedRenders.clear(); - queuedDepthIgnoringRenders.clear(); - } - - private void renderQueued(Tessellator tessellator, boolean depthEnabled) { - if(depthEnabled) - ParticleRenderDispatcher.wispFxCount++; - else ParticleRenderDispatcher.depthIgnoringWispFxCount++; - - float agescale = 0; - agescale = (float)particleAge / (float) moteHalfLife; - if (agescale > 1F) - agescale = 2 - agescale; - - particleScale = moteParticleScale * agescale; - - float f10 = 0.5F * 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); - - tessellator.setBrightness(240); - tessellator.setColorRGBA_F(particleRed, particleGreen, particleBlue, 0.5F); - 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); - } - - @Override - public void renderParticle(Tessellator tessellator, float f, float f1, float f2, float f3, float f4, float f5) { - this.f = f; - this.f1 = f1; - this.f2 = f2; - this.f3 = f3; - this.f4 = f4; - this.f5 = f5; - - if(depthTest) - queuedRenders.add(this); - else queuedDepthIgnoringRenders.add(this); - } - - @Override - public void onUpdate() { - prevPosX = posX; - prevPosY = posY; - prevPosZ = posZ; - - if (particleAge++ >= particleMaxAge) - setDead(); - - motionY -= 0.04D * particleGravity; - posX += motionX; - posY += motionY; - posZ += motionZ; - motionX *= 0.98000001907348633D; - motionY *= 0.98000001907348633D; - motionZ *= 0.98000001907348633D; - } - - public void setGravity(float value) { - particleGravity = value; - } - - boolean depthTest = true; - public boolean distanceLimit = true; - float moteParticleScale; - int moteHalfLife; - public boolean tinkle = false; - public int blendmode = 1; + public static final ResourceLocation particles = new ResourceLocation(LibResources.MISC_WISP_LARGE); + + public static Queue queuedRenders = new ArrayDeque(); + public static Queue queuedDepthIgnoringRenders = new ArrayDeque(); + + // Queue values + float f; + float f1; + float f2; + float f3; + float f4; + float f5; + + public FXWisp( + World world, + double d, + double d1, + double d2, + float size, + float red, + float green, + float blue, + boolean distanceLimit, + boolean depthTest, + float maxAgeMul) { + super(world, d, d1, d2, 0.0D, 0.0D, 0.0D); + particleRed = red; + particleGreen = green; + particleBlue = blue; + particleGravity = 0; + motionX = motionY = motionZ = 0; + particleScale *= size; + moteParticleScale = particleScale; + particleMaxAge = (int) (28D / (Math.random() * 0.3D + 0.7D) * maxAgeMul); + this.depthTest = depthTest; + + moteHalfLife = particleMaxAge / 2; + noClip = true; + setSize(0.01F, 0.01F); + EntityLivingBase renderentity = FMLClientHandler.instance().getClient().renderViewEntity; + + if (distanceLimit) { + int visibleDistance = 50; + if (!FMLClientHandler.instance().getClient().gameSettings.fancyGraphics) visibleDistance = 25; + + if (renderentity == null || renderentity.getDistance(posX, posY, posZ) > visibleDistance) + particleMaxAge = 0; + } + + prevPosX = posX; + prevPosY = posY; + prevPosZ = posZ; + } + + public static void dispatchQueuedRenders(Tessellator tessellator) { + ParticleRenderDispatcher.wispFxCount = 0; + ParticleRenderDispatcher.depthIgnoringWispFxCount = 0; + + GL11.glColor4f(1.0F, 1.0F, 1.0F, 0.75F); + Minecraft.getMinecraft() + .renderEngine + .bindTexture(ConfigHandler.matrixMode ? ObfuscationHelper.getParticleTexture() : particles); + + if (!queuedRenders.isEmpty()) { + tessellator.startDrawingQuads(); + for (FXWisp wisp : queuedRenders) wisp.renderQueued(tessellator, true); + tessellator.draw(); + } + + if (!queuedDepthIgnoringRenders.isEmpty()) { + GL11.glDisable(GL11.GL_DEPTH_TEST); + tessellator.startDrawingQuads(); + for (FXWisp wisp : queuedDepthIgnoringRenders) wisp.renderQueued(tessellator, false); + tessellator.draw(); + GL11.glEnable(GL11.GL_DEPTH_TEST); + } + + queuedRenders.clear(); + queuedDepthIgnoringRenders.clear(); + } + + private void renderQueued(Tessellator tessellator, boolean depthEnabled) { + if (depthEnabled) ParticleRenderDispatcher.wispFxCount++; + else ParticleRenderDispatcher.depthIgnoringWispFxCount++; + + float agescale = 0; + agescale = (float) particleAge / (float) moteHalfLife; + if (agescale > 1F) agescale = 2 - agescale; + + particleScale = moteParticleScale * agescale; + + float f10 = 0.5F * 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); + + tessellator.setBrightness(240); + tessellator.setColorRGBA_F(particleRed, particleGreen, particleBlue, 0.5F); + 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); + } + + @Override + public void renderParticle(Tessellator tessellator, float f, float f1, float f2, float f3, float f4, float f5) { + this.f = f; + this.f1 = f1; + this.f2 = f2; + this.f3 = f3; + this.f4 = f4; + this.f5 = f5; + + if (depthTest) queuedRenders.add(this); + else queuedDepthIgnoringRenders.add(this); + } + + @Override + public void onUpdate() { + prevPosX = posX; + prevPosY = posY; + prevPosZ = posZ; + + if (particleAge++ >= particleMaxAge) setDead(); + + motionY -= 0.04D * particleGravity; + posX += motionX; + posY += motionY; + posZ += motionZ; + motionX *= 0.98000001907348633D; + motionY *= 0.98000001907348633D; + motionZ *= 0.98000001907348633D; + } + + public void setGravity(float value) { + particleGravity = value; + } + + boolean depthTest = true; + public boolean distanceLimit = true; + float moteParticleScale; + int moteHalfLife; + public boolean tinkle = false; + public int blendmode = 1; } diff --git a/src/main/java/vazkii/botania/client/fx/ParticleRenderDispatcher.java b/src/main/java/vazkii/botania/client/fx/ParticleRenderDispatcher.java index 51915027f7..5adea9a5a3 100644 --- a/src/main/java/vazkii/botania/client/fx/ParticleRenderDispatcher.java +++ b/src/main/java/vazkii/botania/client/fx/ParticleRenderDispatcher.java @@ -2,11 +2,11 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under a * Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License * (http://creativecommons.org/licenses/by-nc-sa/3.0/deed.en_GB) - * + * * File Created @ [Jul 2, 2014, 12:12:45 AM (GMT)] */ package vazkii.botania.client.fx; @@ -14,41 +14,39 @@ import net.minecraft.client.Minecraft; import net.minecraft.client.renderer.Tessellator; import net.minecraft.profiler.Profiler; - import org.lwjgl.opengl.GL11; public final class ParticleRenderDispatcher { - public static int wispFxCount = 0; - public static int depthIgnoringWispFxCount = 0; - public static int sparkleFxCount = 0; - public static int fakeSparkleFxCount = 0; - public static int lightningCount = 0; - - // Called from LightningHandler.onRenderWorldLast since that was - // already registered. /shrug - public static void dispatch() { - Tessellator tessellator = Tessellator.instance; - - Profiler profiler = Minecraft.getMinecraft().mcProfiler; - - GL11.glPushAttrib(GL11.GL_LIGHTING); - GL11.glDepthMask(false); - GL11.glEnable(GL11.GL_BLEND); - GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE); - GL11.glAlphaFunc(GL11.GL_GREATER, 0.003921569F); - GL11.glDisable(GL11.GL_LIGHTING); - - profiler.startSection("sparkle"); - FXSparkle.dispatchQueuedRenders(tessellator); - profiler.endStartSection("wisp"); - FXWisp.dispatchQueuedRenders(tessellator); - profiler.endSection(); - - GL11.glAlphaFunc(GL11.GL_GREATER, 0.1F); - GL11.glDisable(GL11.GL_BLEND); - GL11.glDepthMask(true); - GL11.glPopAttrib(); - } - + public static int wispFxCount = 0; + public static int depthIgnoringWispFxCount = 0; + public static int sparkleFxCount = 0; + public static int fakeSparkleFxCount = 0; + public static int lightningCount = 0; + + // Called from LightningHandler.onRenderWorldLast since that was + // already registered. /shrug + public static void dispatch() { + Tessellator tessellator = Tessellator.instance; + + Profiler profiler = Minecraft.getMinecraft().mcProfiler; + + GL11.glPushAttrib(GL11.GL_LIGHTING); + GL11.glDepthMask(false); + GL11.glEnable(GL11.GL_BLEND); + GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE); + GL11.glAlphaFunc(GL11.GL_GREATER, 0.003921569F); + GL11.glDisable(GL11.GL_LIGHTING); + + profiler.startSection("sparkle"); + FXSparkle.dispatchQueuedRenders(tessellator); + profiler.endStartSection("wisp"); + FXWisp.dispatchQueuedRenders(tessellator); + profiler.endSection(); + + GL11.glAlphaFunc(GL11.GL_GREATER, 0.1F); + GL11.glDisable(GL11.GL_BLEND); + GL11.glDepthMask(true); + GL11.glPopAttrib(); + } } diff --git a/src/main/java/vazkii/botania/client/gui/GuiAchievementsHacky.java b/src/main/java/vazkii/botania/client/gui/GuiAchievementsHacky.java index 9891b66ed3..19d1fe05cf 100644 --- a/src/main/java/vazkii/botania/client/gui/GuiAchievementsHacky.java +++ b/src/main/java/vazkii/botania/client/gui/GuiAchievementsHacky.java @@ -2,32 +2,31 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Apr 3, 2015, 5:55:36 PM (GMT)] */ package vazkii.botania.client.gui; +import cpw.mods.fml.relauncher.ReflectionHelper; import net.minecraft.client.gui.GuiButton; import net.minecraft.client.gui.GuiScreen; import net.minecraft.client.gui.achievement.GuiAchievements; import net.minecraft.stats.StatFileWriter; import vazkii.botania.common.achievement.ModAchievements; -import cpw.mods.fml.relauncher.ReflectionHelper; public class GuiAchievementsHacky extends GuiAchievements { - public GuiAchievementsHacky(GuiScreen p_i45026_1_, StatFileWriter p_i45026_2_) { - super(p_i45026_1_, p_i45026_2_); - ReflectionHelper.setPrivateValue(GuiAchievements.class, this, ModAchievements.pageIndex, "currentPage"); - } - - @Override - public void initGui() { - super.initGui(); - ((GuiButton) buttonList.get(1)).displayString = ModAchievements.botaniaPage.getName(); - } + public GuiAchievementsHacky(GuiScreen p_i45026_1_, StatFileWriter p_i45026_2_) { + super(p_i45026_1_, p_i45026_2_); + ReflectionHelper.setPrivateValue(GuiAchievements.class, this, ModAchievements.pageIndex, "currentPage"); + } + @Override + public void initGui() { + super.initGui(); + ((GuiButton) buttonList.get(1)).displayString = ModAchievements.botaniaPage.getName(); + } } diff --git a/src/main/java/vazkii/botania/client/gui/GuiBotaniaConfig.java b/src/main/java/vazkii/botania/client/gui/GuiBotaniaConfig.java index 4f9d20e1b1..c1b2ebaaa6 100644 --- a/src/main/java/vazkii/botania/client/gui/GuiBotaniaConfig.java +++ b/src/main/java/vazkii/botania/client/gui/GuiBotaniaConfig.java @@ -2,25 +2,30 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jun 27, 2014, 1:52:33 AM (GMT)] */ package vazkii.botania.client.gui; +import cpw.mods.fml.client.config.GuiConfig; import net.minecraft.client.gui.GuiScreen; import net.minecraftforge.common.config.ConfigElement; import net.minecraftforge.common.config.Configuration; import vazkii.botania.common.core.handler.ConfigHandler; import vazkii.botania.common.lib.LibMisc; -import cpw.mods.fml.client.config.GuiConfig; public class GuiBotaniaConfig extends GuiConfig { - public GuiBotaniaConfig(GuiScreen parentScreen) { - super(parentScreen, new ConfigElement(ConfigHandler.config.getCategory(Configuration.CATEGORY_GENERAL)).getChildElements(), LibMisc.MOD_ID, false, false, GuiConfig.getAbridgedConfigPath(ConfigHandler.config.toString())); - } - + public GuiBotaniaConfig(GuiScreen parentScreen) { + super( + parentScreen, + new ConfigElement(ConfigHandler.config.getCategory(Configuration.CATEGORY_GENERAL)).getChildElements(), + LibMisc.MOD_ID, + false, + false, + GuiConfig.getAbridgedConfigPath(ConfigHandler.config.toString())); + } } diff --git a/src/main/java/vazkii/botania/client/gui/SlotLocked.java b/src/main/java/vazkii/botania/client/gui/SlotLocked.java index 72b7ccadd5..1bfe03ff01 100644 --- a/src/main/java/vazkii/botania/client/gui/SlotLocked.java +++ b/src/main/java/vazkii/botania/client/gui/SlotLocked.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Sep 6, 2015, 1:11:25 AM (GMT)] */ package vazkii.botania.client.gui; @@ -17,18 +17,17 @@ public class SlotLocked extends Slot { - public SlotLocked(IInventory p_i1824_1_, int p_i1824_2_, int p_i1824_3_, int p_i1824_4_) { - super(p_i1824_1_, p_i1824_2_, p_i1824_3_, p_i1824_4_); - } + public SlotLocked(IInventory p_i1824_1_, int p_i1824_2_, int p_i1824_3_, int p_i1824_4_) { + super(p_i1824_1_, p_i1824_2_, p_i1824_3_, p_i1824_4_); + } - @Override - public boolean canTakeStack(EntityPlayer p_82869_1_) { - return false; - } - - @Override - public boolean isItemValid(ItemStack p_75214_1_) { - return false; - } + @Override + public boolean canTakeStack(EntityPlayer p_82869_1_) { + return false; + } + @Override + public boolean isItemValid(ItemStack p_75214_1_) { + return false; + } } diff --git a/src/main/java/vazkii/botania/client/gui/bag/ContainerFlowerBag.java b/src/main/java/vazkii/botania/client/gui/bag/ContainerFlowerBag.java index 5160afa2a3..dabce7e0d2 100644 --- a/src/main/java/vazkii/botania/client/gui/bag/ContainerFlowerBag.java +++ b/src/main/java/vazkii/botania/client/gui/bag/ContainerFlowerBag.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Mar 16, 2015, 6:42:40 PM (GMT)] */ package vazkii.botania.client.gui.bag; @@ -19,81 +19,72 @@ public class ContainerFlowerBag extends Container { - InventoryFlowerBag flowerBagInv; - - public ContainerFlowerBag(EntityPlayer player) { - int i; - int j; - - int slot = player.inventory.currentItem; - IInventory playerInv = player.inventory; - flowerBagInv = new InventoryFlowerBag(player, slot); - - for(i = 0; i < 2; ++i) - for(j = 0; j < 8; ++j) { - int k = j + i * 8; - addSlotToContainer(new SlotFlower(flowerBagInv, k, 17 + j * 18, 26 + i * 18, k)); - } - - for(i = 0; i < 3; ++i) - for(j = 0; j < 9; ++j) - addSlotToContainer(new Slot(playerInv, j + i * 9 + 9, 8 + j * 18, 84 + i * 18)); - - for(i = 0; i < 9; ++i) { - if(player.inventory.currentItem == i) - addSlotToContainer(new SlotLocked(playerInv, i, 8 + i * 18, 142)); - else addSlotToContainer(new Slot(playerInv, i, 8 + i * 18, 142)); - } - - } - - @Override - public boolean canInteractWith(EntityPlayer player) { - boolean can = flowerBagInv.isUseableByPlayer(player); - if(!can) - onContainerClosed(player); - - return can; - } - - @Override - public void onContainerClosed(EntityPlayer player) { - super.onContainerClosed(player); - flowerBagInv.pushInventory(); - } - - @Override - public ItemStack transferStackInSlot(EntityPlayer p_82846_1_, int p_82846_2_) { - ItemStack itemstack = null; - Slot slot = (Slot)inventorySlots.get(p_82846_2_); - - if(slot != null && slot.getHasStack()) { - ItemStack itemstack1 = slot.getStack(); - itemstack = itemstack1.copy(); - - if(p_82846_2_ < 16) { - if(!mergeItemStack(itemstack1, 16, 52, true)) - return null; - } else { - int i = itemstack.getItemDamage(); - if(i < 16) { - Slot slot1 = (Slot)inventorySlots.get(i); - if(slot1.isItemValid(itemstack) && !mergeItemStack(itemstack1, i, i + 1, true)) - return null; - } - } - - if(itemstack1.stackSize == 0) - slot.putStack((ItemStack)null); - else slot.onSlotChanged(); - - if(itemstack1.stackSize == itemstack.stackSize) - return null; - - slot.onPickupFromSlot(p_82846_1_, itemstack1); - } - - return itemstack; - } - + InventoryFlowerBag flowerBagInv; + + public ContainerFlowerBag(EntityPlayer player) { + int i; + int j; + + int slot = player.inventory.currentItem; + IInventory playerInv = player.inventory; + flowerBagInv = new InventoryFlowerBag(player, slot); + + for (i = 0; i < 2; ++i) + for (j = 0; j < 8; ++j) { + int k = j + i * 8; + addSlotToContainer(new SlotFlower(flowerBagInv, k, 17 + j * 18, 26 + i * 18, k)); + } + + for (i = 0; i < 3; ++i) + for (j = 0; j < 9; ++j) addSlotToContainer(new Slot(playerInv, j + i * 9 + 9, 8 + j * 18, 84 + i * 18)); + + for (i = 0; i < 9; ++i) { + if (player.inventory.currentItem == i) addSlotToContainer(new SlotLocked(playerInv, i, 8 + i * 18, 142)); + else addSlotToContainer(new Slot(playerInv, i, 8 + i * 18, 142)); + } + } + + @Override + public boolean canInteractWith(EntityPlayer player) { + boolean can = flowerBagInv.isUseableByPlayer(player); + if (!can) onContainerClosed(player); + + return can; + } + + @Override + public void onContainerClosed(EntityPlayer player) { + super.onContainerClosed(player); + flowerBagInv.pushInventory(); + } + + @Override + public ItemStack transferStackInSlot(EntityPlayer p_82846_1_, int p_82846_2_) { + ItemStack itemstack = null; + Slot slot = (Slot) inventorySlots.get(p_82846_2_); + + if (slot != null && slot.getHasStack()) { + ItemStack itemstack1 = slot.getStack(); + itemstack = itemstack1.copy(); + + if (p_82846_2_ < 16) { + if (!mergeItemStack(itemstack1, 16, 52, true)) return null; + } else { + int i = itemstack.getItemDamage(); + if (i < 16) { + Slot slot1 = (Slot) inventorySlots.get(i); + if (slot1.isItemValid(itemstack) && !mergeItemStack(itemstack1, i, i + 1, true)) return null; + } + } + + if (itemstack1.stackSize == 0) slot.putStack((ItemStack) null); + else slot.onSlotChanged(); + + if (itemstack1.stackSize == itemstack.stackSize) return null; + + slot.onPickupFromSlot(p_82846_1_, itemstack1); + } + + return itemstack; + } } diff --git a/src/main/java/vazkii/botania/client/gui/bag/GuiFlowerBag.java b/src/main/java/vazkii/botania/client/gui/bag/GuiFlowerBag.java index b3cee8997c..ef30040453 100644 --- a/src/main/java/vazkii/botania/client/gui/bag/GuiFlowerBag.java +++ b/src/main/java/vazkii/botania/client/gui/bag/GuiFlowerBag.java @@ -2,16 +2,15 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Mar 16, 2015, 6:42:43 PM (GMT)] */ package vazkii.botania.client.gui.bag; import java.util.List; - import net.minecraft.client.gui.inventory.GuiContainer; import net.minecraft.client.renderer.RenderHelper; import net.minecraft.client.renderer.entity.RenderItem; @@ -21,54 +20,51 @@ import net.minecraft.item.ItemStack; import net.minecraft.util.ResourceLocation; import net.minecraft.util.StatCollector; - import org.lwjgl.opengl.GL11; - import vazkii.botania.client.lib.LibResources; import vazkii.botania.common.block.ModBlocks; public class GuiFlowerBag extends GuiContainer { - private static final ResourceLocation texture = new ResourceLocation(LibResources.GUI_FLOWER_BAG); - - public GuiFlowerBag(EntityPlayer player) { - super(new ContainerFlowerBag(player)); - } + private static final ResourceLocation texture = new ResourceLocation(LibResources.GUI_FLOWER_BAG); - @Override - protected void drawGuiContainerForegroundLayer(int p_146979_1_, int p_146979_2_) { - String s = StatCollector.translateToLocal("item.botania:flowerBag.name"); - fontRendererObj.drawString(s, xSize / 2 - fontRendererObj.getStringWidth(s) / 2, 6, 4210752); - fontRendererObj.drawString(I18n.format("container.inventory", new Object[0]), 8, ySize - 96 + 2, 4210752); - } + public GuiFlowerBag(EntityPlayer player) { + super(new ContainerFlowerBag(player)); + } - @Override - protected void drawGuiContainerBackgroundLayer(float p_146976_1_, int p_146976_2_, int p_146976_3_) { - GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); - mc.getTextureManager().bindTexture(texture); - int k = (width - xSize) / 2; - int l = (height - ySize) / 2; - drawTexturedModalRect(k, l, 0, 0, xSize, ySize); + @Override + protected void drawGuiContainerForegroundLayer(int p_146979_1_, int p_146979_2_) { + String s = StatCollector.translateToLocal("item.botania:flowerBag.name"); + fontRendererObj.drawString(s, xSize / 2 - fontRendererObj.getStringWidth(s) / 2, 6, 4210752); + fontRendererObj.drawString(I18n.format("container.inventory", new Object[0]), 8, ySize - 96 + 2, 4210752); + } - List slotList = inventorySlots.inventorySlots; - for(Slot slot : slotList) - if(slot instanceof SlotFlower) { - SlotFlower slotf = (SlotFlower) slot; - if(!slotf.getHasStack()) { - ItemStack stack = new ItemStack(ModBlocks.flower, 0, slotf.color); - int x = guiLeft + slotf.xDisplayPosition; - int y = guiTop + slotf.yDisplayPosition; - RenderHelper.enableGUIStandardItemLighting(); - RenderItem.getInstance().renderItemIntoGUI(mc.fontRenderer, mc.renderEngine, stack, x, y); - RenderHelper.disableStandardItemLighting(); - mc.fontRenderer.drawStringWithShadow("0", x + 11, y + 9, 0xFF6666); - } - } - } + @Override + protected void drawGuiContainerBackgroundLayer(float p_146976_1_, int p_146976_2_, int p_146976_3_) { + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + mc.getTextureManager().bindTexture(texture); + int k = (width - xSize) / 2; + int l = (height - ySize) / 2; + drawTexturedModalRect(k, l, 0, 0, xSize, ySize); - @Override - protected boolean checkHotbarKeys(int p_146983_1_) { - return false; - } + List slotList = inventorySlots.inventorySlots; + for (Slot slot : slotList) + if (slot instanceof SlotFlower) { + SlotFlower slotf = (SlotFlower) slot; + if (!slotf.getHasStack()) { + ItemStack stack = new ItemStack(ModBlocks.flower, 0, slotf.color); + int x = guiLeft + slotf.xDisplayPosition; + int y = guiTop + slotf.yDisplayPosition; + RenderHelper.enableGUIStandardItemLighting(); + RenderItem.getInstance().renderItemIntoGUI(mc.fontRenderer, mc.renderEngine, stack, x, y); + RenderHelper.disableStandardItemLighting(); + mc.fontRenderer.drawStringWithShadow("0", x + 11, y + 9, 0xFF6666); + } + } + } + @Override + protected boolean checkHotbarKeys(int p_146983_1_) { + return false; + } } diff --git a/src/main/java/vazkii/botania/client/gui/bag/InventoryFlowerBag.java b/src/main/java/vazkii/botania/client/gui/bag/InventoryFlowerBag.java index 10fcb06f97..b9c283e938 100644 --- a/src/main/java/vazkii/botania/client/gui/bag/InventoryFlowerBag.java +++ b/src/main/java/vazkii/botania/client/gui/bag/InventoryFlowerBag.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Mar 16, 2015, 6:42:56 PM (GMT)] */ package vazkii.botania.client.gui.bag; @@ -19,142 +19,136 @@ public class InventoryFlowerBag implements IInventory { - private static final ItemStack[] FALLBACK_INVENTORY = new ItemStack[16]; - - EntityPlayer player; - int slot; - ItemStack[] stacks = null; - - boolean invPushed = false; - ItemStack storedInv = null; - - public InventoryFlowerBag(EntityPlayer player, int slot) { - this.player = player; - this.slot = slot; - } - - public static boolean isFlowerBag(ItemStack stack) { - return stack != null && stack.getItem() == ModItems.flowerBag; - } - - ItemStack getStack() { - ItemStack stack = player.inventory.getStackInSlot(slot); - if(stack != null) - storedInv = stack; - return stack; - } - - ItemStack[] getInventory() { - if(stacks != null) - return stacks; - - ItemStack stack = getStack(); - if(isFlowerBag(getStack())) { - stacks = ItemFlowerBag.loadStacks(stack); - return stacks; - } - - return FALLBACK_INVENTORY; - } - - public void pushInventory() { - if(invPushed) - return; - - ItemStack stack = getStack(); - if(stack == null) - stack = storedInv; - - if(stack != null) { - ItemStack[] inv = getInventory(); - ItemFlowerBag.setStacks(stack, inv); - } - - invPushed = true; - } - - @Override - public int getSizeInventory() { - return 16; - } - - @Override - public ItemStack getStackInSlot(int i) { - return getInventory()[i]; - } - - @Override - public ItemStack decrStackSize(int i, int j) { - ItemStack[] inventorySlots = getInventory(); - if (inventorySlots[i] != null) { - ItemStack stackAt; - - if (inventorySlots[i].stackSize <= j) { - stackAt = inventorySlots[i]; - inventorySlots[i] = null; - return stackAt; - } else { - stackAt = inventorySlots[i].splitStack(j); - - if (inventorySlots[i].stackSize == 0) - inventorySlots[i] = null; - - return stackAt; - } - } - - return null; - } - - @Override - public ItemStack getStackInSlotOnClosing(int i) { - return getStackInSlot(i); - } - - @Override - public void setInventorySlotContents(int i, ItemStack itemstack) { - ItemStack[] inventorySlots = getInventory(); - inventorySlots[i] = itemstack; - } - - @Override - public int getInventoryStackLimit() { - return isFlowerBag(getStack()) ? 64 : 0; - } - - @Override - public boolean isUseableByPlayer(EntityPlayer entityplayer) { - return isFlowerBag(getStack()); - } - - @Override - public boolean isItemValidForSlot(int i, ItemStack itemstack) { - return isFlowerBag(getStack()); - } - - @Override - public boolean hasCustomInventoryName() { - return false; - } - - @Override - public void openInventory() { - // NO-OP - } - - @Override - public void closeInventory() { - // NO-OP - } - - @Override - public String getInventoryName() { - return LibItemNames.FLOWER_BAG; - } - - @Override - public void markDirty() { - // NO-OP - } - + private static final ItemStack[] FALLBACK_INVENTORY = new ItemStack[16]; + + EntityPlayer player; + int slot; + ItemStack[] stacks = null; + + boolean invPushed = false; + ItemStack storedInv = null; + + public InventoryFlowerBag(EntityPlayer player, int slot) { + this.player = player; + this.slot = slot; + } + + public static boolean isFlowerBag(ItemStack stack) { + return stack != null && stack.getItem() == ModItems.flowerBag; + } + + ItemStack getStack() { + ItemStack stack = player.inventory.getStackInSlot(slot); + if (stack != null) storedInv = stack; + return stack; + } + + ItemStack[] getInventory() { + if (stacks != null) return stacks; + + ItemStack stack = getStack(); + if (isFlowerBag(getStack())) { + stacks = ItemFlowerBag.loadStacks(stack); + return stacks; + } + + return FALLBACK_INVENTORY; + } + + public void pushInventory() { + if (invPushed) return; + + ItemStack stack = getStack(); + if (stack == null) stack = storedInv; + + if (stack != null) { + ItemStack[] inv = getInventory(); + ItemFlowerBag.setStacks(stack, inv); + } + + invPushed = true; + } + + @Override + public int getSizeInventory() { + return 16; + } + + @Override + public ItemStack getStackInSlot(int i) { + return getInventory()[i]; + } + + @Override + public ItemStack decrStackSize(int i, int j) { + ItemStack[] inventorySlots = getInventory(); + if (inventorySlots[i] != null) { + ItemStack stackAt; + + if (inventorySlots[i].stackSize <= j) { + stackAt = inventorySlots[i]; + inventorySlots[i] = null; + return stackAt; + } else { + stackAt = inventorySlots[i].splitStack(j); + + if (inventorySlots[i].stackSize == 0) inventorySlots[i] = null; + + return stackAt; + } + } + + return null; + } + + @Override + public ItemStack getStackInSlotOnClosing(int i) { + return getStackInSlot(i); + } + + @Override + public void setInventorySlotContents(int i, ItemStack itemstack) { + ItemStack[] inventorySlots = getInventory(); + inventorySlots[i] = itemstack; + } + + @Override + public int getInventoryStackLimit() { + return isFlowerBag(getStack()) ? 64 : 0; + } + + @Override + public boolean isUseableByPlayer(EntityPlayer entityplayer) { + return isFlowerBag(getStack()); + } + + @Override + public boolean isItemValidForSlot(int i, ItemStack itemstack) { + return isFlowerBag(getStack()); + } + + @Override + public boolean hasCustomInventoryName() { + return false; + } + + @Override + public void openInventory() { + // NO-OP + } + + @Override + public void closeInventory() { + // NO-OP + } + + @Override + public String getInventoryName() { + return LibItemNames.FLOWER_BAG; + } + + @Override + public void markDirty() { + // NO-OP + } } diff --git a/src/main/java/vazkii/botania/client/gui/bag/SlotFlower.java b/src/main/java/vazkii/botania/client/gui/bag/SlotFlower.java index ba4c32378a..0348a97540 100644 --- a/src/main/java/vazkii/botania/client/gui/bag/SlotFlower.java +++ b/src/main/java/vazkii/botania/client/gui/bag/SlotFlower.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Mar 16, 2015, 7:20:05 PM (GMT)] */ package vazkii.botania.client.gui.bag; @@ -17,23 +17,22 @@ public class SlotFlower extends Slot { - InventoryFlowerBag inv; - int color; + InventoryFlowerBag inv; + int color; - public SlotFlower(InventoryFlowerBag p_i1824_1_, int p_i1824_2_, int p_i1824_3_, int p_i1824_4_, int color) { - super(p_i1824_1_, p_i1824_2_, p_i1824_3_, p_i1824_4_); - this.color = color; - inv = p_i1824_1_; - } + public SlotFlower(InventoryFlowerBag p_i1824_1_, int p_i1824_2_, int p_i1824_3_, int p_i1824_4_, int color) { + super(p_i1824_1_, p_i1824_2_, p_i1824_3_, p_i1824_4_); + this.color = color; + inv = p_i1824_1_; + } - @Override - public void onSlotChange(ItemStack oldStack, ItemStack newStack) { - inv.setInventorySlotContents(color, newStack); - } - - @Override - public boolean isItemValid(ItemStack stack) { - return stack.getItem() == Item.getItemFromBlock(ModBlocks.flower) && stack.getItemDamage() == color; - } + @Override + public void onSlotChange(ItemStack oldStack, ItemStack newStack) { + inv.setInventorySlotContents(color, newStack); + } + @Override + public boolean isItemValid(ItemStack stack) { + return stack.getItem() == Item.getItemFromBlock(ModBlocks.flower) && stack.getItemDamage() == color; + } } diff --git a/src/main/java/vazkii/botania/client/gui/box/ContainerBaubleBox.java b/src/main/java/vazkii/botania/client/gui/box/ContainerBaubleBox.java index 24d54be75b..3445f09d21 100644 --- a/src/main/java/vazkii/botania/client/gui/box/ContainerBaubleBox.java +++ b/src/main/java/vazkii/botania/client/gui/box/ContainerBaubleBox.java @@ -2,14 +2,19 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [25/11/2015, 19:59:06 (GMT)] */ package vazkii.botania.client.gui.box; +import baubles.api.BaubleType; +import baubles.api.IBauble; +import baubles.common.container.InventoryBaubles; +import baubles.common.container.SlotBauble; +import baubles.common.lib.PlayerHandler; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.inventory.Container; import net.minecraft.inventory.IInventory; @@ -17,106 +22,92 @@ import net.minecraft.item.ItemStack; import vazkii.botania.api.mana.IManaItem; import vazkii.botania.client.gui.SlotLocked; -import baubles.api.BaubleType; -import baubles.api.IBauble; -import baubles.common.container.InventoryBaubles; -import baubles.common.container.SlotBauble; -import baubles.common.lib.PlayerHandler; public class ContainerBaubleBox extends Container { - InventoryBaubleBox baubleBoxInv; - InventoryBaubles baubles; - - public ContainerBaubleBox(EntityPlayer player) { - int i; - int j; - - int slot = player.inventory.currentItem; - IInventory playerInv = player.inventory; - baubleBoxInv = new InventoryBaubleBox(player, slot); - - baubles = new InventoryBaubles(player); - baubles.setEventHandler(this); - if(!player.worldObj.isRemote) - baubles.stackList = PlayerHandler.getPlayerBaubles(player).stackList; - - addSlotToContainer(new SlotBauble(baubles, BaubleType.AMULET, 0, 8, 8 + 0 * 18)); - addSlotToContainer(new SlotBauble(baubles, BaubleType.RING, 1, 8, 8 + 1 * 18)); - addSlotToContainer(new SlotBauble(baubles, BaubleType.RING, 2, 8, 8 + 2 * 18)); - addSlotToContainer(new SlotBauble(baubles, BaubleType.BELT, 3, 8, 8 + 3 * 18)); - - for(i = 0; i < 4; ++i) - for(j = 0; j < 6; ++j) { - int k = j + i * 6; - addSlotToContainer(new SlotAnyBauble(baubleBoxInv, k, 62 + j * 18, 8 + i * 18)); - } - - for(i = 0; i < 3; ++i) - for(j = 0; j < 9; ++j) - addSlotToContainer(new Slot(playerInv, j + i * 9 + 9, 8 + j * 18, 84 + i * 18)); - - for(i = 0; i < 9; ++i) { - if(player.inventory.currentItem == i) - addSlotToContainer(new SlotLocked(playerInv, i, 8 + i * 18, 142)); - else addSlotToContainer(new Slot(playerInv, i, 8 + i * 18, 142)); - } - - } - - @Override - public boolean canInteractWith(EntityPlayer player) { - boolean can = baubleBoxInv.isUseableByPlayer(player); - if(!can) - onContainerClosed(player); - - return can; - } - - @Override - public void onContainerClosed(EntityPlayer player) { - super.onContainerClosed(player); - baubleBoxInv.pushInventory(); - - if(!player.worldObj.isRemote) - PlayerHandler.setPlayerBaubles(player, baubles); - } - - @Override - public void putStacksInSlots(ItemStack[] p_75131_1_) { - baubles.blockEvents = true; - super.putStacksInSlots(p_75131_1_); - } - - @Override - public ItemStack transferStackInSlot(EntityPlayer p_82846_1_, int p_82846_2_) { - ItemStack itemstack = null; - Slot slot = (Slot)inventorySlots.get(p_82846_2_); - - if(slot != null && slot.getHasStack()) { - ItemStack itemstack1 = slot.getStack(); - itemstack = itemstack1.copy(); - - System.out.println(p_82846_2_ + " " + itemstack); - if(p_82846_2_ < 28) { - if(!mergeItemStack(itemstack1, 28, 64, true)) - return null; - } else { - if(itemstack1 != null && (itemstack1.getItem() instanceof IBauble || itemstack1.getItem() instanceof IManaItem) && !mergeItemStack(itemstack1, 4, 28, false)) - return null; - } - - if(itemstack1.stackSize == 0) - slot.putStack((ItemStack)null); - else slot.onSlotChanged(); - - if(itemstack1.stackSize == itemstack.stackSize) - return null; - - slot.onPickupFromSlot(p_82846_1_, itemstack1); - } - - return itemstack; - } - + InventoryBaubleBox baubleBoxInv; + InventoryBaubles baubles; + + public ContainerBaubleBox(EntityPlayer player) { + int i; + int j; + + int slot = player.inventory.currentItem; + IInventory playerInv = player.inventory; + baubleBoxInv = new InventoryBaubleBox(player, slot); + + baubles = new InventoryBaubles(player); + baubles.setEventHandler(this); + if (!player.worldObj.isRemote) baubles.stackList = PlayerHandler.getPlayerBaubles(player).stackList; + + addSlotToContainer(new SlotBauble(baubles, BaubleType.AMULET, 0, 8, 8 + 0 * 18)); + addSlotToContainer(new SlotBauble(baubles, BaubleType.RING, 1, 8, 8 + 1 * 18)); + addSlotToContainer(new SlotBauble(baubles, BaubleType.RING, 2, 8, 8 + 2 * 18)); + addSlotToContainer(new SlotBauble(baubles, BaubleType.BELT, 3, 8, 8 + 3 * 18)); + + for (i = 0; i < 4; ++i) + for (j = 0; j < 6; ++j) { + int k = j + i * 6; + addSlotToContainer(new SlotAnyBauble(baubleBoxInv, k, 62 + j * 18, 8 + i * 18)); + } + + for (i = 0; i < 3; ++i) + for (j = 0; j < 9; ++j) addSlotToContainer(new Slot(playerInv, j + i * 9 + 9, 8 + j * 18, 84 + i * 18)); + + for (i = 0; i < 9; ++i) { + if (player.inventory.currentItem == i) addSlotToContainer(new SlotLocked(playerInv, i, 8 + i * 18, 142)); + else addSlotToContainer(new Slot(playerInv, i, 8 + i * 18, 142)); + } + } + + @Override + public boolean canInteractWith(EntityPlayer player) { + boolean can = baubleBoxInv.isUseableByPlayer(player); + if (!can) onContainerClosed(player); + + return can; + } + + @Override + public void onContainerClosed(EntityPlayer player) { + super.onContainerClosed(player); + baubleBoxInv.pushInventory(); + + if (!player.worldObj.isRemote) PlayerHandler.setPlayerBaubles(player, baubles); + } + + @Override + public void putStacksInSlots(ItemStack[] p_75131_1_) { + baubles.blockEvents = true; + super.putStacksInSlots(p_75131_1_); + } + + @Override + public ItemStack transferStackInSlot(EntityPlayer p_82846_1_, int p_82846_2_) { + ItemStack itemstack = null; + Slot slot = (Slot) inventorySlots.get(p_82846_2_); + + if (slot != null && slot.getHasStack()) { + ItemStack itemstack1 = slot.getStack(); + itemstack = itemstack1.copy(); + + System.out.println(p_82846_2_ + " " + itemstack); + if (p_82846_2_ < 28) { + if (!mergeItemStack(itemstack1, 28, 64, true)) return null; + } else { + if (itemstack1 != null + && (itemstack1.getItem() instanceof IBauble || itemstack1.getItem() instanceof IManaItem) + && !mergeItemStack(itemstack1, 4, 28, false)) return null; + } + + if (itemstack1.stackSize == 0) slot.putStack((ItemStack) null); + else slot.onSlotChanged(); + + if (itemstack1.stackSize == itemstack.stackSize) return null; + + slot.onPickupFromSlot(p_82846_1_, itemstack1); + } + + return itemstack; + } } diff --git a/src/main/java/vazkii/botania/client/gui/box/GuiBaubleBox.java b/src/main/java/vazkii/botania/client/gui/box/GuiBaubleBox.java index 798a95373b..c0c5edf9b8 100644 --- a/src/main/java/vazkii/botania/client/gui/box/GuiBaubleBox.java +++ b/src/main/java/vazkii/botania/client/gui/box/GuiBaubleBox.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [25/11/2015, 19:59:11 (GMT)] */ package vazkii.botania.client.gui.box; @@ -15,39 +15,42 @@ import net.minecraft.entity.player.EntityPlayer; import net.minecraft.inventory.Slot; import net.minecraft.util.ResourceLocation; - import org.lwjgl.opengl.GL11; - import vazkii.botania.client.lib.LibResources; public class GuiBaubleBox extends InventoryEffectRenderer { - private static final ResourceLocation texture = new ResourceLocation(LibResources.GUI_BAUBLE_BOX); - - public GuiBaubleBox(EntityPlayer player) { - super(new ContainerBaubleBox(player)); - } - - @Override - protected boolean checkHotbarKeys(int p_146983_1_) { - return false; - } - - @Override - protected void drawGuiContainerBackgroundLayer(float p_146976_1_, int p_146976_2_, int p_146976_3_) { - GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); - mc.getTextureManager().bindTexture(texture); - int k = (width - xSize) / 2; - int l = (height - ySize) / 2; - drawTexturedModalRect(k, l, 0, 0, xSize, ySize); - - for(int i1 = 0; i1 < 4; ++i1) { - Slot slot = (Slot) inventorySlots.inventorySlots.get(i1); - if(slot.getHasStack() && slot.getSlotStackLimit() == 1) - drawTexturedModalRect(k+slot.xDisplayPosition, l+slot.yDisplayPosition, 200, 0, 16, 16); - } - - GuiInventory.func_147046_a(guiLeft + 43, guiTop + 61, 20, guiLeft + 43 - p_146976_2_, guiTop + 45 - 30 - p_146976_3_, mc.thePlayer); - } - + private static final ResourceLocation texture = new ResourceLocation(LibResources.GUI_BAUBLE_BOX); + + public GuiBaubleBox(EntityPlayer player) { + super(new ContainerBaubleBox(player)); + } + + @Override + protected boolean checkHotbarKeys(int p_146983_1_) { + return false; + } + + @Override + protected void drawGuiContainerBackgroundLayer(float p_146976_1_, int p_146976_2_, int p_146976_3_) { + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + mc.getTextureManager().bindTexture(texture); + int k = (width - xSize) / 2; + int l = (height - ySize) / 2; + drawTexturedModalRect(k, l, 0, 0, xSize, ySize); + + for (int i1 = 0; i1 < 4; ++i1) { + Slot slot = (Slot) inventorySlots.inventorySlots.get(i1); + if (slot.getHasStack() && slot.getSlotStackLimit() == 1) + drawTexturedModalRect(k + slot.xDisplayPosition, l + slot.yDisplayPosition, 200, 0, 16, 16); + } + + GuiInventory.func_147046_a( + guiLeft + 43, + guiTop + 61, + 20, + guiLeft + 43 - p_146976_2_, + guiTop + 45 - 30 - p_146976_3_, + mc.thePlayer); + } } diff --git a/src/main/java/vazkii/botania/client/gui/box/InventoryBaubleBox.java b/src/main/java/vazkii/botania/client/gui/box/InventoryBaubleBox.java index 415eee637c..6cdc8c690b 100644 --- a/src/main/java/vazkii/botania/client/gui/box/InventoryBaubleBox.java +++ b/src/main/java/vazkii/botania/client/gui/box/InventoryBaubleBox.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [25/11/2015, 19:59:16 (GMT)] */ package vazkii.botania.client.gui.box; @@ -19,142 +19,136 @@ public class InventoryBaubleBox implements IInventory { - private static final ItemStack[] FALLBACK_INVENTORY = new ItemStack[16]; - - EntityPlayer player; - int slot; - ItemStack[] stacks = null; - - boolean invPushed = false; - ItemStack storedInv = null; - - public InventoryBaubleBox(EntityPlayer player, int slot) { - this.player = player; - this.slot = slot; - } - - public static boolean isBaubleBox(ItemStack stack) { - return stack != null && stack.getItem() == ModItems.baubleBox; - } - - ItemStack getStack() { - ItemStack stack = player.inventory.getStackInSlot(slot); - if(stack != null) - storedInv = stack; - return stack; - } - - ItemStack[] getInventory() { - if(stacks != null) - return stacks; - - ItemStack stack = getStack(); - if(isBaubleBox(getStack())) { - stacks = ItemBaubleBox.loadStacks(stack); - return stacks; - } - - return FALLBACK_INVENTORY; - } - - public void pushInventory() { - if(invPushed) - return; - - ItemStack stack = getStack(); - if(stack == null) - stack = storedInv; - - if(stack != null) { - ItemStack[] inv = getInventory(); - ItemBaubleBox.setStacks(stack, inv); - } - - invPushed = true; - } - - @Override - public int getSizeInventory() { - return 16; - } - - @Override - public ItemStack getStackInSlot(int i) { - return getInventory()[i]; - } - - @Override - public ItemStack decrStackSize(int i, int j) { - ItemStack[] inventorySlots = getInventory(); - if (inventorySlots[i] != null) { - ItemStack stackAt; - - if (inventorySlots[i].stackSize <= j) { - stackAt = inventorySlots[i]; - inventorySlots[i] = null; - return stackAt; - } else { - stackAt = inventorySlots[i].splitStack(j); - - if (inventorySlots[i].stackSize == 0) - inventorySlots[i] = null; - - return stackAt; - } - } - - return null; - } - - @Override - public ItemStack getStackInSlotOnClosing(int i) { - return getStackInSlot(i); - } - - @Override - public void setInventorySlotContents(int slot, ItemStack itemstack) { - ItemStack[] inventorySlots = getInventory(); - inventorySlots[slot] = itemstack; - } - - @Override - public int getInventoryStackLimit() { - return isBaubleBox(getStack()) ? 64 : 0; - } - - @Override - public boolean isUseableByPlayer(EntityPlayer entityplayer) { - return isBaubleBox(getStack()); - } - - @Override - public boolean isItemValidForSlot(int i, ItemStack itemstack) { - return isBaubleBox(getStack()); - } - - @Override - public boolean hasCustomInventoryName() { - return false; - } - - @Override - public void openInventory() { - // NO-OP - } - - @Override - public void closeInventory() { - // NO-OP - } - - @Override - public String getInventoryName() { - return LibItemNames.BAUBLE_BOX; - } - - @Override - public void markDirty() { - // NO-OP - } - + private static final ItemStack[] FALLBACK_INVENTORY = new ItemStack[16]; + + EntityPlayer player; + int slot; + ItemStack[] stacks = null; + + boolean invPushed = false; + ItemStack storedInv = null; + + public InventoryBaubleBox(EntityPlayer player, int slot) { + this.player = player; + this.slot = slot; + } + + public static boolean isBaubleBox(ItemStack stack) { + return stack != null && stack.getItem() == ModItems.baubleBox; + } + + ItemStack getStack() { + ItemStack stack = player.inventory.getStackInSlot(slot); + if (stack != null) storedInv = stack; + return stack; + } + + ItemStack[] getInventory() { + if (stacks != null) return stacks; + + ItemStack stack = getStack(); + if (isBaubleBox(getStack())) { + stacks = ItemBaubleBox.loadStacks(stack); + return stacks; + } + + return FALLBACK_INVENTORY; + } + + public void pushInventory() { + if (invPushed) return; + + ItemStack stack = getStack(); + if (stack == null) stack = storedInv; + + if (stack != null) { + ItemStack[] inv = getInventory(); + ItemBaubleBox.setStacks(stack, inv); + } + + invPushed = true; + } + + @Override + public int getSizeInventory() { + return 16; + } + + @Override + public ItemStack getStackInSlot(int i) { + return getInventory()[i]; + } + + @Override + public ItemStack decrStackSize(int i, int j) { + ItemStack[] inventorySlots = getInventory(); + if (inventorySlots[i] != null) { + ItemStack stackAt; + + if (inventorySlots[i].stackSize <= j) { + stackAt = inventorySlots[i]; + inventorySlots[i] = null; + return stackAt; + } else { + stackAt = inventorySlots[i].splitStack(j); + + if (inventorySlots[i].stackSize == 0) inventorySlots[i] = null; + + return stackAt; + } + } + + return null; + } + + @Override + public ItemStack getStackInSlotOnClosing(int i) { + return getStackInSlot(i); + } + + @Override + public void setInventorySlotContents(int slot, ItemStack itemstack) { + ItemStack[] inventorySlots = getInventory(); + inventorySlots[slot] = itemstack; + } + + @Override + public int getInventoryStackLimit() { + return isBaubleBox(getStack()) ? 64 : 0; + } + + @Override + public boolean isUseableByPlayer(EntityPlayer entityplayer) { + return isBaubleBox(getStack()); + } + + @Override + public boolean isItemValidForSlot(int i, ItemStack itemstack) { + return isBaubleBox(getStack()); + } + + @Override + public boolean hasCustomInventoryName() { + return false; + } + + @Override + public void openInventory() { + // NO-OP + } + + @Override + public void closeInventory() { + // NO-OP + } + + @Override + public String getInventoryName() { + return LibItemNames.BAUBLE_BOX; + } + + @Override + public void markDirty() { + // NO-OP + } } diff --git a/src/main/java/vazkii/botania/client/gui/box/SlotAnyBauble.java b/src/main/java/vazkii/botania/client/gui/box/SlotAnyBauble.java index e19453b9bc..6464ca4751 100644 --- a/src/main/java/vazkii/botania/client/gui/box/SlotAnyBauble.java +++ b/src/main/java/vazkii/botania/client/gui/box/SlotAnyBauble.java @@ -2,36 +2,35 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [25/11/2015, 19:59:22 (GMT)] */ package vazkii.botania.client.gui.box; +import baubles.api.IBauble; import net.minecraft.inventory.Slot; import net.minecraft.item.ItemStack; import vazkii.botania.api.mana.IManaItem; -import baubles.api.IBauble; public class SlotAnyBauble extends Slot { - InventoryBaubleBox inv; - - public SlotAnyBauble(InventoryBaubleBox p_i1824_1_, int p_i1824_2_, int p_i1824_3_, int p_i1824_4_) { - super(p_i1824_1_, p_i1824_2_, p_i1824_3_, p_i1824_4_); - inv = p_i1824_1_; - } + InventoryBaubleBox inv; - @Override - public void onSlotChange(ItemStack oldStack, ItemStack newStack) { - inv.setInventorySlotContents(slotNumber, newStack); - } + public SlotAnyBauble(InventoryBaubleBox p_i1824_1_, int p_i1824_2_, int p_i1824_3_, int p_i1824_4_) { + super(p_i1824_1_, p_i1824_2_, p_i1824_3_, p_i1824_4_); + inv = p_i1824_1_; + } - @Override - public boolean isItemValid(ItemStack stack) { - return stack.getItem() instanceof IBauble || stack.getItem() instanceof IManaItem; - } + @Override + public void onSlotChange(ItemStack oldStack, ItemStack newStack) { + inv.setInventorySlotContents(slotNumber, newStack); + } + @Override + public boolean isItemValid(ItemStack stack) { + return stack.getItem() instanceof IBauble || stack.getItem() instanceof IManaItem; + } } diff --git a/src/main/java/vazkii/botania/client/gui/crafting/ContainerCraftingHalo.java b/src/main/java/vazkii/botania/client/gui/crafting/ContainerCraftingHalo.java index e335f52298..d946b88c38 100644 --- a/src/main/java/vazkii/botania/client/gui/crafting/ContainerCraftingHalo.java +++ b/src/main/java/vazkii/botania/client/gui/crafting/ContainerCraftingHalo.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Dec 15, 2014, 6:02:52 PM (GMT)] */ package vazkii.botania.client.gui.crafting; @@ -19,45 +19,40 @@ public class ContainerCraftingHalo extends ContainerWorkbench { - public ContainerCraftingHalo(InventoryPlayer p_i1808_1_, World p_i1808_2_) { - super(p_i1808_1_, p_i1808_2_, 0, 0, 0); - - craftMatrix = new InventoryCraftingHalo(this, 3, 3); - - inventorySlots.clear(); - inventoryItemStacks.clear(); - - // Le copypasta - addSlotToContainer(new SlotCrafting(p_i1808_1_.player, craftMatrix, craftResult, 0, 124, 35)); - int l; - int i1; - - for (l = 0; l < 3; ++l) - { - for (i1 = 0; i1 < 3; ++i1) - { - addSlotToContainer(new Slot(craftMatrix, i1 + l * 3, 30 + i1 * 18, 17 + l * 18)); - } - } - - for (l = 0; l < 3; ++l) - { - for (i1 = 0; i1 < 9; ++i1) - { - addSlotToContainer(new Slot(p_i1808_1_, i1 + l * 9 + 9, 8 + i1 * 18, 84 + l * 18)); - } - } - - for (l = 0; l < 9; ++l) - { - addSlotToContainer(new Slot(p_i1808_1_, l, 8 + l * 18, 142)); - } - - onCraftMatrixChanged(craftMatrix); - } - - @Override - public boolean canInteractWith(EntityPlayer p_75145_1_) { - return true; - } + public ContainerCraftingHalo(InventoryPlayer p_i1808_1_, World p_i1808_2_) { + super(p_i1808_1_, p_i1808_2_, 0, 0, 0); + + craftMatrix = new InventoryCraftingHalo(this, 3, 3); + + inventorySlots.clear(); + inventoryItemStacks.clear(); + + // Le copypasta + addSlotToContainer(new SlotCrafting(p_i1808_1_.player, craftMatrix, craftResult, 0, 124, 35)); + int l; + int i1; + + for (l = 0; l < 3; ++l) { + for (i1 = 0; i1 < 3; ++i1) { + addSlotToContainer(new Slot(craftMatrix, i1 + l * 3, 30 + i1 * 18, 17 + l * 18)); + } + } + + for (l = 0; l < 3; ++l) { + for (i1 = 0; i1 < 9; ++i1) { + addSlotToContainer(new Slot(p_i1808_1_, i1 + l * 9 + 9, 8 + i1 * 18, 84 + l * 18)); + } + } + + for (l = 0; l < 9; ++l) { + addSlotToContainer(new Slot(p_i1808_1_, l, 8 + l * 18, 142)); + } + + onCraftMatrixChanged(craftMatrix); + } + + @Override + public boolean canInteractWith(EntityPlayer p_75145_1_) { + return true; + } } diff --git a/src/main/java/vazkii/botania/client/gui/crafting/GuiCraftingHalo.java b/src/main/java/vazkii/botania/client/gui/crafting/GuiCraftingHalo.java index fbc503ff61..c14dab3665 100644 --- a/src/main/java/vazkii/botania/client/gui/crafting/GuiCraftingHalo.java +++ b/src/main/java/vazkii/botania/client/gui/crafting/GuiCraftingHalo.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Dec 15, 2014, 6:02:04 PM (GMT)] */ package vazkii.botania.client.gui.crafting; @@ -15,31 +15,30 @@ import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.util.ResourceLocation; import net.minecraft.world.World; - import org.lwjgl.opengl.GL11; // This is pretty much a copypasta of GuiCrafting >_> public class GuiCraftingHalo extends GuiContainer { - private static final ResourceLocation craftingTableGuiTextures = new ResourceLocation("textures/gui/container/crafting_table.png"); - - public GuiCraftingHalo(InventoryPlayer p_i1084_1_, World p_i1084_2_) { - super(new ContainerCraftingHalo(p_i1084_1_, p_i1084_2_)); - } - - @Override - protected void drawGuiContainerForegroundLayer(int p_146979_1_, int p_146979_2_) { - fontRendererObj.drawString(I18n.format("container.crafting", new Object[0]), 28, 6, 4210752); - fontRendererObj.drawString(I18n.format("container.inventory", new Object[0]), 8, ySize - 96 + 2, 4210752); - } - - @Override - protected void drawGuiContainerBackgroundLayer(float p_146976_1_, int p_146976_2_, int p_146976_3_) { - GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); - mc.getTextureManager().bindTexture(craftingTableGuiTextures); - int k = (width - xSize) / 2; - int l = (height - ySize) / 2; - drawTexturedModalRect(k, l, 0, 0, xSize, ySize); - } - + private static final ResourceLocation craftingTableGuiTextures = + new ResourceLocation("textures/gui/container/crafting_table.png"); + + public GuiCraftingHalo(InventoryPlayer p_i1084_1_, World p_i1084_2_) { + super(new ContainerCraftingHalo(p_i1084_1_, p_i1084_2_)); + } + + @Override + protected void drawGuiContainerForegroundLayer(int p_146979_1_, int p_146979_2_) { + fontRendererObj.drawString(I18n.format("container.crafting", new Object[0]), 28, 6, 4210752); + fontRendererObj.drawString(I18n.format("container.inventory", new Object[0]), 8, ySize - 96 + 2, 4210752); + } + + @Override + protected void drawGuiContainerBackgroundLayer(float p_146976_1_, int p_146976_2_, int p_146976_3_) { + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + mc.getTextureManager().bindTexture(craftingTableGuiTextures); + int k = (width - xSize) / 2; + int l = (height - ySize) / 2; + drawTexturedModalRect(k, l, 0, 0, xSize, ySize); + } } diff --git a/src/main/java/vazkii/botania/client/gui/crafting/InventoryCraftingHalo.java b/src/main/java/vazkii/botania/client/gui/crafting/InventoryCraftingHalo.java index 6089d66717..708aaa99c0 100644 --- a/src/main/java/vazkii/botania/client/gui/crafting/InventoryCraftingHalo.java +++ b/src/main/java/vazkii/botania/client/gui/crafting/InventoryCraftingHalo.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Dec 20, 2014, 4:29:09 PM (GMT)] */ package vazkii.botania.client.gui.crafting; @@ -15,8 +15,7 @@ public class InventoryCraftingHalo extends InventoryCrafting { - public InventoryCraftingHalo(Container p_i1807_1_, int p_i1807_2_, int p_i1807_3_) { - super(p_i1807_1_, p_i1807_2_, p_i1807_3_); - } - + public InventoryCraftingHalo(Container p_i1807_1_, int p_i1807_2_, int p_i1807_3_) { + super(p_i1807_1_, p_i1807_2_, p_i1807_3_); + } } diff --git a/src/main/java/vazkii/botania/client/gui/lexicon/GuiLexicon.java b/src/main/java/vazkii/botania/client/gui/lexicon/GuiLexicon.java index e329a71223..c52589f2ee 100644 --- a/src/main/java/vazkii/botania/client/gui/lexicon/GuiLexicon.java +++ b/src/main/java/vazkii/botania/client/gui/lexicon/GuiLexicon.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jan 14, 2014, 6:48:05 PM (GMT)] */ package vazkii.botania.client.gui.lexicon; @@ -20,7 +20,6 @@ import java.util.HashMap; import java.util.List; import java.util.Queue; - import net.minecraft.client.Minecraft; import net.minecraft.client.audio.PositionedSoundRecord; import net.minecraft.client.gui.FontRenderer; @@ -33,10 +32,8 @@ import net.minecraft.util.ResourceLocation; import net.minecraft.util.StatCollector; import net.minecraftforge.common.MinecraftForge; - import org.lwjgl.input.Keyboard; import org.lwjgl.opengl.GL11; - import vazkii.botania.api.BotaniaAPI; import vazkii.botania.api.lexicon.BotaniaTutorialStartEvent; import vazkii.botania.api.lexicon.LexiconCategory; @@ -67,595 +64,597 @@ public class GuiLexicon extends GuiScreen { - public static GuiLexicon currentOpenLexicon = new GuiLexicon(); - public static ItemStack stackUsed; - - public static HashMap notes = new HashMap(); - - private static final String TAG_TYPE = "type"; - - private static final int[] KONAMI_CODE = { 200, 200, 208, 208, 203, 205, 203, 205, 48, 30 }; - - public static final int BOOKMARK_START = 1337; - public static final int NOTES_BUTTON_ID = 1336; // random button tho - public static final int MAX_BOOKMARK_COUNT = 8; - public static List bookmarks = new ArrayList(); - public static List bookmarkKeys = new ArrayList(); - boolean bookmarksNeedPopulation = false; - - public static Queue tutorial = new ArrayDeque(); - - public static final ResourceLocation texture = new ResourceLocation(LibResources.GUI_LEXICON); - public static final ResourceLocation textureToff = new ResourceLocation(LibResources.GUI_TOFF); - - public float lastTime = 0F; - public float partialTicks = 0F; - public float timeDelta = 0F; - - private static final int TUTORIAL_ARROW_WIDTH = 10; - private static final int TUTORIAL_ARROW_HEIGHT = 12; - boolean hasTutorialArrow; - int tutorialArrowX, tutorialArrowY; - int konamiIndex; - - private static final int NOTE_TWEEN_TIME = 5; - public static boolean notesEnabled; - static int notesMoveTime; - public String note = ""; - public String categoryHighlight = ""; - - List allCategories; - - String title; - int guiWidth = 146; - int guiHeight = 180; - int left, top; - - @Override - public final void initGui() { - super.initGui(); - - if(PersistentVariableHelper.firstLoad) { - PersistentVariableHelper.firstLoad = false; - PersistentVariableHelper.saveSafe(); - } - - String key = getNotesKey(); - if(notes.containsKey(key)) - note = notes.get(key); - - onInitGui(); - - putTutorialArrow(); - } - - public void onInitGui() { - allCategories = new ArrayList(BotaniaAPI.getAllCategories()); - Collections.sort(allCategories); - - lastTime = ClientTickHandler.ticksInGame; - - title = stackUsed.getDisplayName(); - currentOpenLexicon = this; - - left = width / 2 - guiWidth / 2; - top = height / 2 - guiHeight / 2; - - buttonList.clear(); - if(isIndex()) { - int x = 18; - for(int i = 0; i < 12; i++) { - int y = 16 + i * 12; - buttonList.add(new GuiButtonInvisible((GuiLexiconIndex) this, i, left + x, top + y, 110, 10, "")); - } - populateIndex(); - } else if(isCategoryIndex()) { - int categories = allCategories.size(); - for(int i = 0; i < categories + 1; i++) { - LexiconCategory category = null; - category = i >= categories ? null : allCategories.get(i); - int perline = 5; - int x = i % perline; - int y = i / perline; - - int size = 22; - GuiButtonCategory button = new GuiButtonCategory(i, left + 18 + x * size, top + 50 + y * size, this, category); - buttonList.add(button); - } - } - populateBookmarks(); - if(isMainPage()) { - buttonList.add(new GuiButtonOptions(-1, left - 6, top + guiHeight - 54)); - buttonList.add(new GuiButtonAchievement(-2, left - 6, top + guiHeight - 40)); - buttonList.add(new GuiButtonChallenges(-3, left - 6, top + guiHeight - 25)); - - GuiButtonUpdateWarning button = new GuiButtonUpdateWarning(-4, left - 6, top + guiHeight - 70); - buttonList.add(button); - - if(PersistentVariableHelper.lastBotaniaVersion.equals(LibMisc.VERSION)) { - button.enabled = false; - button.visible = false; - } - - if(Calendar.getInstance().get(Calendar.MONTH) == Calendar.NOVEMBER && Calendar.getInstance().get(Calendar.DATE) == 22) - buttonList.add(new GuiButtonDoot(-99, left + 100, top + 12)); - } - - buttonList.add(new GuiButtonNotes(this, NOTES_BUTTON_ID, left - 4, top - 4)); - } - - @Override - public void updateScreen() { - if(notesEnabled && notesMoveTime < NOTE_TWEEN_TIME) - notesMoveTime++; - else if(!notesEnabled && notesMoveTime > 0) - notesMoveTime--; - } - - @Override - public void drawScreen(int par1, int par2, float par3) { - float time = ClientTickHandler.ticksInGame + par3; - timeDelta = time - lastTime; - lastTime = time; - partialTicks = par3; - - GL11.glColor4f(1F, 1F, 1F, 1F); - mc.renderEngine.bindTexture(texture); - drawNotes(par3); - - GL11.glColor4f(1F, 1F, 1F, 1F); - mc.renderEngine.bindTexture(texture); - drawTexturedModalRect(left, top, 0, 0, guiWidth, guiHeight); - - if(ClientProxy.jingleTheBells) - drawTexturedModalRect(left + 3, top + 1, 0, 212, 138, 6); - - String subtitle = getSubtitle(); - if(subtitle != null) - drawBookmark(left + guiWidth / 2, top - getTitleHeight() + 10, subtitle, true, 191); - drawBookmark(left + guiWidth / 2, top - getTitleHeight(), getTitle(), true); - - if(isMainPage()) - drawHeader(); - - if(bookmarksNeedPopulation) { - populateBookmarks(); - bookmarksNeedPopulation = false; - } - - if(mc.thePlayer.getCommandSenderName().equals("haighyorkie")) { - GL11.glColor4f(1F, 1F, 1F, 1F); - mc.renderEngine.bindTexture(texture); - drawTexturedModalRect(left - 19, top + 42, 67, 180, 19, 26); - if(par1 >= left - 19 && par1 < left && par2 >= top + 62 && par2 < top + 88) { - mc.renderEngine.bindTexture(textureToff); - GL11.glPushMatrix(); - GL11.glScalef(0.5F, 0.5F, 0.5F); - GL11.glEnable(GL11.GL_BLEND); - GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); - GL11.glTranslatef(0F, 0F, 2F); - - int w = 256; - int h = 152; - int x = (int) ((ClientTickHandler.ticksInGame + par3) * 6) % (width + w) - w; - int y = (int) (top + guiHeight / 2 - h / 4 + Math.sin((ClientTickHandler.ticksInGame + par3) / 6.0) * 40); - - drawTexturedModalRect(x * 2, y * 2, 0, 0, w, h); - GL11.glDisable(GL11.GL_BLEND); - GL11.glPopMatrix(); - - RenderHelper.renderTooltip(par1, par2, Arrays.asList(EnumChatFormatting.GOLD + "#goldfishchris", EnumChatFormatting.AQUA + "IT SAYS MANUAL")); - } - } - - super.drawScreen(par1, par2, par3); - - if(hasTutorialArrow) { - mc.renderEngine.bindTexture(texture); - GL11.glEnable(GL11.GL_BLEND); - GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); - GL11.glColor4f(1F, 1F, 1F, 0.7F + (float) (Math.sin((ClientTickHandler.ticksInGame + par3) * 0.3F) + 1) * 0.15F); - drawTexturedModalRect(tutorialArrowX, tutorialArrowY, 20, 200, TUTORIAL_ARROW_WIDTH, TUTORIAL_ARROW_HEIGHT); - GL11.glDisable(GL11.GL_BLEND); - } - } - - public void drawNotes(float part) { - int size = 105; - - float time = notesMoveTime; - if(notesMoveTime < NOTE_TWEEN_TIME && notesEnabled) - time += part; - else if(notesMoveTime > 0 && !notesEnabled) - time -= part; - - int drawSize = (int) (size * time / NOTE_TWEEN_TIME); - int x = left - drawSize; - int y = top + 10; - - drawTexturedModalRect(x, y, 146, 0, drawSize, 125); - - String noteDisplay = note; - if(notesEnabled && ClientTickHandler.ticksInGame % 20 < 10) - noteDisplay += "&r_"; - - fontRendererObj.drawString(StatCollector.translateToLocal("botaniamisc.notes"), x + 5, y - 7, 0x666666); - - boolean unicode = fontRendererObj.getUnicodeFlag(); - fontRendererObj.setUnicodeFlag(true); - - PageText.renderText(x + 5, y - 3, 92, 120, 0, noteDisplay); - fontRendererObj.setUnicodeFlag(unicode); - } - - - public void drawBookmark(int x, int y, String s, boolean drawLeft) { - drawBookmark(x, y, s, drawLeft, 180); - } - - public void drawBookmark(int x, int y, String s, boolean drawLeft, int v) { - drawBookmark(x, y, s, drawLeft, 0x111111, v); - } - - public void drawBookmark(int x, int y, String s, boolean drawLeft, int color, int v) { - // This function is called from the buttons so I can't use fontRendererObj - FontRenderer font = Minecraft.getMinecraft().fontRenderer; - boolean unicode = font.getUnicodeFlag(); - font.setUnicodeFlag(true); - int l = font.getStringWidth(s); - int fontOff = 0; - - if(!drawLeft) { - x += l / 2; - fontOff = 2; - } - - Minecraft.getMinecraft().renderEngine.bindTexture(texture); - - GL11.glColor4f(1F, 1F, 1F, 1F); - drawTexturedModalRect(x + l / 2 + 3, y - 1, 54, v, 6, 11); - if(drawLeft) - drawTexturedModalRect(x - l / 2 - 9, y - 1, 61, v, 6, 11); - for(int i = 0; i < l + 6; i++) - drawTexturedModalRect(x - l / 2 - 3 + i, y - 1, 60, v, 1, 11); - - font.drawString(s, x - l / 2 + fontOff, y, color, false); - font.setUnicodeFlag(unicode); - } - - void drawHeader() { - GL11.glPushMatrix(); - GL11.glColor4f(1F, 1F, 1F, 1F); - Minecraft.getMinecraft().renderEngine.bindTexture(texture); - drawTexturedModalRect(left - 8, top + 9, 0, 224, 140, 31); - - int color = 0xffd200; - boolean unicode = fontRendererObj.getUnicodeFlag(); - fontRendererObj.drawString(title, left + 18, top + 13, color); - fontRendererObj.setUnicodeFlag(true); - fontRendererObj.drawString(String.format(StatCollector.translateToLocal("botaniamisc.edition"), ItemLexicon.getEdition()), left + 24, top + 22, color); - - String s = EnumChatFormatting.BOLD + categoryHighlight; - fontRendererObj.drawString(s, left + guiWidth / 2 - fontRendererObj.getStringWidth(s) / 2, top + 36, 0); - - fontRendererObj.setUnicodeFlag(unicode); - GL11.glPopMatrix(); - - categoryHighlight = ""; - } - - boolean isMainPage() { - return true; - } - - @Override - protected void actionPerformed(GuiButton par1GuiButton) { - if(par1GuiButton.id >= BOOKMARK_START) { - if(par1GuiButton.id >= BOOKMARK_START + MAX_BOOKMARK_COUNT) { - if(par1GuiButton instanceof GuiButtonChallengeInfo) - mc.displayGuiScreen(new GuiLexiconEntry(LexiconData.challenges, this)); - else mc.displayGuiScreen(new GuiLexiconHistory()); - ClientTickHandler.notifyPageChange(); - } else handleBookmark(par1GuiButton); - } else if(par1GuiButton instanceof GuiButtonCategory) { - LexiconCategory category = ((GuiButtonCategory) par1GuiButton).getCategory(); - - mc.displayGuiScreen(new GuiLexiconIndex(category)); - ClientTickHandler.notifyPageChange(); - } else switch(par1GuiButton.id) { - case -1 : - mc.displayGuiScreen(new GuiBotaniaConfig(this)); - break; - case -2 : - mc.displayGuiScreen(new GuiAchievementsHacky(this, mc.thePlayer.getStatFileWriter())); - break; - case -3 : - mc.displayGuiScreen(new GuiLexiconChallengesList()); - break; - case -4 : - if(isShiftKeyDown()) { - try { - if(Desktop.isDesktopSupported()) - Desktop.getDesktop().browse(new URI("http://botaniamod.net/changelog.php#" + PersistentVariableHelper.lastBotaniaVersion.replaceAll("\\.|\\s", "-"))); - } catch (Exception e) { - e.printStackTrace(); - } - } else { - PersistentVariableHelper.lastBotaniaVersion = LibMisc.VERSION; - PersistentVariableHelper.saveSafe(); - par1GuiButton.visible = false; - par1GuiButton.enabled = false; - } - - break; - case NOTES_BUTTON_ID : - notesEnabled = !notesEnabled; - break; - } - } - - public void handleBookmark(GuiButton par1GuiButton) { - boolean modified = false; - int i = par1GuiButton.id - BOOKMARK_START; - String key = getNotesKey(); - if(i == bookmarks.size()) { - if(!bookmarkKeys.contains(key)) { - bookmarks.add(copy()); - bookmarkKeys.add(key); - modified = true; - } - } else { - if(isShiftKeyDown()) { - bookmarks.remove(i); - bookmarkKeys.remove(i); - - modified = true; - } else { - GuiLexicon bookmark = bookmarks.get(i).copy(); - if(!bookmark.getTitle().equals(getTitle())) { - Minecraft.getMinecraft().displayGuiScreen(bookmark); - if(bookmark instanceof IParented) - ((IParented) bookmark).setParent(this); - ClientTickHandler.notifyPageChange(); - } - } - } - - bookmarksNeedPopulation = true; - if(modified) - PersistentVariableHelper.saveSafe(); - } - - @Override - public boolean doesGuiPauseGame() { - return false; - } - - public int bookmarkWidth(String b) { - if(fontRendererObj == null) - fontRendererObj = Minecraft.getMinecraft().fontRenderer; - - boolean unicode = fontRendererObj.getUnicodeFlag(); - fontRendererObj.setUnicodeFlag(true); - int width = fontRendererObj.getStringWidth(b) + 15; - fontRendererObj.setUnicodeFlag(unicode); - return width; - } - - String getTitle() { - return title; - } - - String getSubtitle() { - return null; - } - - int getTitleHeight() { - return getSubtitle() == null ? 12 : 22; - } - - boolean isIndex() { - return false; - } - - boolean isChallenge() { - return false; - } - - boolean isCategoryIndex() { - return true; - } - - void populateIndex() { - List categoryList = BotaniaAPI.getAllCategories(); - int shift = 2; - for(int i = shift; i < 12; i++) { - int i_ = i - shift; - GuiButtonInvisible button = (GuiButtonInvisible) buttonList.get(i); - LexiconCategory category = i_ >= categoryList.size() ? null : categoryList.get(i_); - if(category != null) - button.displayString = StatCollector.translateToLocal(category.getUnlocalizedName()); - else { - button.displayString = StatCollector.translateToLocal("botaniamisc.lexiconIndex"); - break; - } - } - } - - void populateBookmarks() { - List remove = new ArrayList(); - List buttons = buttonList; - for(GuiButton button : buttons) - if(button.id >= BOOKMARK_START) - remove.add(button); - buttonList.removeAll(remove); - - int len = bookmarks.size(); - boolean thisExists = false; - for(GuiLexicon lex : bookmarks) - if(lex.getTitle().equals(getTitle())) - thisExists = true; - - boolean addEnabled = len < MAX_BOOKMARK_COUNT && this instanceof IParented && !thisExists; - for(int i = 0; i < len + (addEnabled ? 1 : 0); i++) { - boolean isAdd = i == bookmarks.size(); - GuiLexicon gui = isAdd ? null : bookmarks.get(i); - buttonList.add(new GuiButtonBookmark(BOOKMARK_START + i, left + 138, top + 18 + 14 * i, gui == null ? this : gui, gui == null ? "+" : gui.getTitle())); - } - - if(isMainPage()) - buttonList.add(new GuiButtonHistory(BOOKMARK_START + MAX_BOOKMARK_COUNT, left + 138, top + guiHeight - 24, StatCollector.translateToLocal("botaniamisc.history"), this)); - else if(isChallenge()) - buttonList.add(new GuiButtonChallengeInfo(BOOKMARK_START + MAX_BOOKMARK_COUNT, left + 138, top + guiHeight - 24, StatCollector.translateToLocal("botaniamisc.info"), this)); - } - - public static void startTutorial() { - tutorial.clear(); - - tutorial.add(LexiconData.lexicon); - tutorial.add(LexiconData.flowers); - tutorial.add(LexiconData.apothecary); - tutorial.add(LexiconData.pureDaisy); - tutorial.add(LexiconData.wand); - tutorial.add(LexiconData.manaIntro); - tutorial.add(LexiconData.pool); - tutorial.add(LexiconData.spreader); - if(ConfigHandler.hardcorePassiveGeneration > 0) - tutorial.add(LexiconData.generatingIntro); - tutorial.add(LexiconData.passiveGen); - tutorial.add(LexiconData.daybloom); - tutorial.add(LexiconData.functionalIntro); - tutorial.add(LexiconData.runicAltar); - - MinecraftForge.EVENT_BUS.post(new BotaniaTutorialStartEvent(tutorial)); - } - - public final void putTutorialArrow() { - hasTutorialArrow = !tutorial.isEmpty(); - if(hasTutorialArrow) - positionTutorialArrow(); - } - - public void positionTutorialArrow() { - LexiconEntry entry = tutorial.peek(); - LexiconCategory category = entry.category; - - List buttons = buttonList; - for(GuiButton button : buttons) - if(button instanceof GuiButtonCategory) { - GuiButtonCategory catButton = (GuiButtonCategory) button; - if(catButton.getCategory() == category) { - orientTutorialArrowWithButton(button); - break; - } - } - } - - public void orientTutorialArrowWithButton(GuiButton button) { - tutorialArrowX = button.xPosition - TUTORIAL_ARROW_WIDTH; - tutorialArrowY = button.yPosition - TUTORIAL_ARROW_HEIGHT; - } - - boolean closeScreenOnInvKey() { - return true; - } - - @Override - protected void keyTyped(char par1, int par2) { - handleNoteKey(par1, par2); - - if(!notesEnabled && closeScreenOnInvKey() && mc.gameSettings.keyBindInventory.getKeyCode() == par2) { - mc.displayGuiScreen(null); - mc.setIngameFocus(); - } - - if(par2 == KONAMI_CODE[konamiIndex]) { - konamiIndex++; - if(konamiIndex >= KONAMI_CODE.length) { - mc.getSoundHandler().playSound(PositionedSoundRecord.func_147673_a(new ResourceLocation("botania:way"))); - konamiIndex = 0; - } - } else konamiIndex = 0; - - super.keyTyped(par1, par2); - } - - public void handleNoteKey(char par1, int par2) { - if(notesEnabled) { - Keyboard.enableRepeatEvents(true); - boolean changed = false; - - if(par2 == 14 && note.length() > 0) { - if(isCtrlKeyDown()) - note = ""; - else { - if(note.endsWith("
")) - note = note.substring(0, note.length() - 4); - else note = note.substring(0, note.length() - 1); - } - changed = true; - } - - if((ChatAllowedCharacters.isAllowedCharacter(par1) || par2 == 28) && note.length() < 250) { - note += par2 == 28 ? "
" : par1; - changed = true; - } - - if(changed) { - notes.put(getNotesKey(), note); - PersistentVariableHelper.saveSafe(); - } - } else Keyboard.enableRepeatEvents(false); - } - - public static GuiLexicon create(NBTTagCompound cmp) { - String type = cmp.getString(TAG_TYPE); - try { - GuiLexicon lex = (GuiLexicon) Class.forName(type).newInstance(); - if(lex != null) - lex.load(cmp); - if(isValidLexiconGui(lex)) - return lex; - return null; - } catch (Exception e) { - e.printStackTrace(); - return null; - } - } - - public void serialize(NBTTagCompound cmp) { - cmp.setString(TAG_TYPE, getClass().getName()); - } - - public String getNotesKey() { - return "index"; - } - - public void load(NBTTagCompound cmp) { - // NO-OP - } - - public GuiLexicon copy() { - return new GuiLexicon(); - } - - public static boolean isValidLexiconGui(GuiLexicon gui) { - if(gui == null) - return false; - if(gui.isCategoryIndex() || gui.isChallenge()) - return true; - if(gui.isIndex()) { - GuiLexiconIndex indexGui = (GuiLexiconIndex) gui; - if(indexGui.category == null) - return true; - return BotaniaAPI.getAllCategories().contains(indexGui.category); - } - - GuiLexiconEntry entryGui = (GuiLexiconEntry) gui; - if(!BotaniaAPI.getAllEntries().contains(entryGui.entry)) - return false; - - return entryGui.page < entryGui.entry.pages.size(); - } + public static GuiLexicon currentOpenLexicon = new GuiLexicon(); + public static ItemStack stackUsed; + + public static HashMap notes = new HashMap(); + + private static final String TAG_TYPE = "type"; + + private static final int[] KONAMI_CODE = {200, 200, 208, 208, 203, 205, 203, 205, 48, 30}; + + public static final int BOOKMARK_START = 1337; + public static final int NOTES_BUTTON_ID = 1336; // random button tho + public static final int MAX_BOOKMARK_COUNT = 8; + public static List bookmarks = new ArrayList(); + public static List bookmarkKeys = new ArrayList(); + boolean bookmarksNeedPopulation = false; + + public static Queue tutorial = new ArrayDeque(); + + public static final ResourceLocation texture = new ResourceLocation(LibResources.GUI_LEXICON); + public static final ResourceLocation textureToff = new ResourceLocation(LibResources.GUI_TOFF); + + public float lastTime = 0F; + public float partialTicks = 0F; + public float timeDelta = 0F; + + private static final int TUTORIAL_ARROW_WIDTH = 10; + private static final int TUTORIAL_ARROW_HEIGHT = 12; + boolean hasTutorialArrow; + int tutorialArrowX, tutorialArrowY; + int konamiIndex; + + private static final int NOTE_TWEEN_TIME = 5; + public static boolean notesEnabled; + static int notesMoveTime; + public String note = ""; + public String categoryHighlight = ""; + + List allCategories; + + String title; + int guiWidth = 146; + int guiHeight = 180; + int left, top; + + @Override + public final void initGui() { + super.initGui(); + + if (PersistentVariableHelper.firstLoad) { + PersistentVariableHelper.firstLoad = false; + PersistentVariableHelper.saveSafe(); + } + + String key = getNotesKey(); + if (notes.containsKey(key)) note = notes.get(key); + + onInitGui(); + + putTutorialArrow(); + } + + public void onInitGui() { + allCategories = new ArrayList(BotaniaAPI.getAllCategories()); + Collections.sort(allCategories); + + lastTime = ClientTickHandler.ticksInGame; + + title = stackUsed.getDisplayName(); + currentOpenLexicon = this; + + left = width / 2 - guiWidth / 2; + top = height / 2 - guiHeight / 2; + + buttonList.clear(); + if (isIndex()) { + int x = 18; + for (int i = 0; i < 12; i++) { + int y = 16 + i * 12; + buttonList.add(new GuiButtonInvisible((GuiLexiconIndex) this, i, left + x, top + y, 110, 10, "")); + } + populateIndex(); + } else if (isCategoryIndex()) { + int categories = allCategories.size(); + for (int i = 0; i < categories + 1; i++) { + LexiconCategory category = null; + category = i >= categories ? null : allCategories.get(i); + int perline = 5; + int x = i % perline; + int y = i / perline; + + int size = 22; + GuiButtonCategory button = + new GuiButtonCategory(i, left + 18 + x * size, top + 50 + y * size, this, category); + buttonList.add(button); + } + } + populateBookmarks(); + if (isMainPage()) { + buttonList.add(new GuiButtonOptions(-1, left - 6, top + guiHeight - 54)); + buttonList.add(new GuiButtonAchievement(-2, left - 6, top + guiHeight - 40)); + buttonList.add(new GuiButtonChallenges(-3, left - 6, top + guiHeight - 25)); + + GuiButtonUpdateWarning button = new GuiButtonUpdateWarning(-4, left - 6, top + guiHeight - 70); + buttonList.add(button); + + if (PersistentVariableHelper.lastBotaniaVersion.equals(LibMisc.VERSION)) { + button.enabled = false; + button.visible = false; + } + + if (Calendar.getInstance().get(Calendar.MONTH) == Calendar.NOVEMBER + && Calendar.getInstance().get(Calendar.DATE) == 22) + buttonList.add(new GuiButtonDoot(-99, left + 100, top + 12)); + } + + buttonList.add(new GuiButtonNotes(this, NOTES_BUTTON_ID, left - 4, top - 4)); + } + + @Override + public void updateScreen() { + if (notesEnabled && notesMoveTime < NOTE_TWEEN_TIME) notesMoveTime++; + else if (!notesEnabled && notesMoveTime > 0) notesMoveTime--; + } + + @Override + public void drawScreen(int par1, int par2, float par3) { + float time = ClientTickHandler.ticksInGame + par3; + timeDelta = time - lastTime; + lastTime = time; + partialTicks = par3; + + GL11.glColor4f(1F, 1F, 1F, 1F); + mc.renderEngine.bindTexture(texture); + drawNotes(par3); + + GL11.glColor4f(1F, 1F, 1F, 1F); + mc.renderEngine.bindTexture(texture); + drawTexturedModalRect(left, top, 0, 0, guiWidth, guiHeight); + + if (ClientProxy.jingleTheBells) drawTexturedModalRect(left + 3, top + 1, 0, 212, 138, 6); + + String subtitle = getSubtitle(); + if (subtitle != null) drawBookmark(left + guiWidth / 2, top - getTitleHeight() + 10, subtitle, true, 191); + drawBookmark(left + guiWidth / 2, top - getTitleHeight(), getTitle(), true); + + if (isMainPage()) drawHeader(); + + if (bookmarksNeedPopulation) { + populateBookmarks(); + bookmarksNeedPopulation = false; + } + + if (mc.thePlayer.getCommandSenderName().equals("haighyorkie")) { + GL11.glColor4f(1F, 1F, 1F, 1F); + mc.renderEngine.bindTexture(texture); + drawTexturedModalRect(left - 19, top + 42, 67, 180, 19, 26); + if (par1 >= left - 19 && par1 < left && par2 >= top + 62 && par2 < top + 88) { + mc.renderEngine.bindTexture(textureToff); + GL11.glPushMatrix(); + GL11.glScalef(0.5F, 0.5F, 0.5F); + GL11.glEnable(GL11.GL_BLEND); + GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); + GL11.glTranslatef(0F, 0F, 2F); + + int w = 256; + int h = 152; + int x = (int) ((ClientTickHandler.ticksInGame + par3) * 6) % (width + w) - w; + int y = (int) + (top + guiHeight / 2 - h / 4 + Math.sin((ClientTickHandler.ticksInGame + par3) / 6.0) * 40); + + drawTexturedModalRect(x * 2, y * 2, 0, 0, w, h); + GL11.glDisable(GL11.GL_BLEND); + GL11.glPopMatrix(); + + RenderHelper.renderTooltip( + par1, + par2, + Arrays.asList( + EnumChatFormatting.GOLD + "#goldfishchris", + EnumChatFormatting.AQUA + "IT SAYS MANUAL")); + } + } + + super.drawScreen(par1, par2, par3); + + if (hasTutorialArrow) { + mc.renderEngine.bindTexture(texture); + GL11.glEnable(GL11.GL_BLEND); + GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); + GL11.glColor4f( + 1F, 1F, 1F, 0.7F + (float) (Math.sin((ClientTickHandler.ticksInGame + par3) * 0.3F) + 1) * 0.15F); + drawTexturedModalRect(tutorialArrowX, tutorialArrowY, 20, 200, TUTORIAL_ARROW_WIDTH, TUTORIAL_ARROW_HEIGHT); + GL11.glDisable(GL11.GL_BLEND); + } + } + + public void drawNotes(float part) { + int size = 105; + + float time = notesMoveTime; + if (notesMoveTime < NOTE_TWEEN_TIME && notesEnabled) time += part; + else if (notesMoveTime > 0 && !notesEnabled) time -= part; + + int drawSize = (int) (size * time / NOTE_TWEEN_TIME); + int x = left - drawSize; + int y = top + 10; + + drawTexturedModalRect(x, y, 146, 0, drawSize, 125); + + String noteDisplay = note; + if (notesEnabled && ClientTickHandler.ticksInGame % 20 < 10) noteDisplay += "&r_"; + + fontRendererObj.drawString(StatCollector.translateToLocal("botaniamisc.notes"), x + 5, y - 7, 0x666666); + + boolean unicode = fontRendererObj.getUnicodeFlag(); + fontRendererObj.setUnicodeFlag(true); + + PageText.renderText(x + 5, y - 3, 92, 120, 0, noteDisplay); + fontRendererObj.setUnicodeFlag(unicode); + } + + public void drawBookmark(int x, int y, String s, boolean drawLeft) { + drawBookmark(x, y, s, drawLeft, 180); + } + + public void drawBookmark(int x, int y, String s, boolean drawLeft, int v) { + drawBookmark(x, y, s, drawLeft, 0x111111, v); + } + + public void drawBookmark(int x, int y, String s, boolean drawLeft, int color, int v) { + // This function is called from the buttons so I can't use fontRendererObj + FontRenderer font = Minecraft.getMinecraft().fontRenderer; + boolean unicode = font.getUnicodeFlag(); + font.setUnicodeFlag(true); + int l = font.getStringWidth(s); + int fontOff = 0; + + if (!drawLeft) { + x += l / 2; + fontOff = 2; + } + + Minecraft.getMinecraft().renderEngine.bindTexture(texture); + + GL11.glColor4f(1F, 1F, 1F, 1F); + drawTexturedModalRect(x + l / 2 + 3, y - 1, 54, v, 6, 11); + if (drawLeft) drawTexturedModalRect(x - l / 2 - 9, y - 1, 61, v, 6, 11); + for (int i = 0; i < l + 6; i++) drawTexturedModalRect(x - l / 2 - 3 + i, y - 1, 60, v, 1, 11); + + font.drawString(s, x - l / 2 + fontOff, y, color, false); + font.setUnicodeFlag(unicode); + } + + void drawHeader() { + GL11.glPushMatrix(); + GL11.glColor4f(1F, 1F, 1F, 1F); + Minecraft.getMinecraft().renderEngine.bindTexture(texture); + drawTexturedModalRect(left - 8, top + 9, 0, 224, 140, 31); + + int color = 0xffd200; + boolean unicode = fontRendererObj.getUnicodeFlag(); + fontRendererObj.drawString(title, left + 18, top + 13, color); + fontRendererObj.setUnicodeFlag(true); + fontRendererObj.drawString( + String.format(StatCollector.translateToLocal("botaniamisc.edition"), ItemLexicon.getEdition()), + left + 24, + top + 22, + color); + + String s = EnumChatFormatting.BOLD + categoryHighlight; + fontRendererObj.drawString(s, left + guiWidth / 2 - fontRendererObj.getStringWidth(s) / 2, top + 36, 0); + + fontRendererObj.setUnicodeFlag(unicode); + GL11.glPopMatrix(); + + categoryHighlight = ""; + } + + boolean isMainPage() { + return true; + } + + @Override + protected void actionPerformed(GuiButton par1GuiButton) { + if (par1GuiButton.id >= BOOKMARK_START) { + if (par1GuiButton.id >= BOOKMARK_START + MAX_BOOKMARK_COUNT) { + if (par1GuiButton instanceof GuiButtonChallengeInfo) + mc.displayGuiScreen(new GuiLexiconEntry(LexiconData.challenges, this)); + else mc.displayGuiScreen(new GuiLexiconHistory()); + ClientTickHandler.notifyPageChange(); + } else handleBookmark(par1GuiButton); + } else if (par1GuiButton instanceof GuiButtonCategory) { + LexiconCategory category = ((GuiButtonCategory) par1GuiButton).getCategory(); + + mc.displayGuiScreen(new GuiLexiconIndex(category)); + ClientTickHandler.notifyPageChange(); + } else + switch (par1GuiButton.id) { + case -1: + mc.displayGuiScreen(new GuiBotaniaConfig(this)); + break; + case -2: + mc.displayGuiScreen(new GuiAchievementsHacky(this, mc.thePlayer.getStatFileWriter())); + break; + case -3: + mc.displayGuiScreen(new GuiLexiconChallengesList()); + break; + case -4: + if (isShiftKeyDown()) { + try { + if (Desktop.isDesktopSupported()) + Desktop.getDesktop() + .browse(new URI("http://botaniamod.net/changelog.php#" + + PersistentVariableHelper.lastBotaniaVersion.replaceAll( + "\\.|\\s", "-"))); + } catch (Exception e) { + e.printStackTrace(); + } + } else { + PersistentVariableHelper.lastBotaniaVersion = LibMisc.VERSION; + PersistentVariableHelper.saveSafe(); + par1GuiButton.visible = false; + par1GuiButton.enabled = false; + } + + break; + case NOTES_BUTTON_ID: + notesEnabled = !notesEnabled; + break; + } + } + + public void handleBookmark(GuiButton par1GuiButton) { + boolean modified = false; + int i = par1GuiButton.id - BOOKMARK_START; + String key = getNotesKey(); + if (i == bookmarks.size()) { + if (!bookmarkKeys.contains(key)) { + bookmarks.add(copy()); + bookmarkKeys.add(key); + modified = true; + } + } else { + if (isShiftKeyDown()) { + bookmarks.remove(i); + bookmarkKeys.remove(i); + + modified = true; + } else { + GuiLexicon bookmark = bookmarks.get(i).copy(); + if (!bookmark.getTitle().equals(getTitle())) { + Minecraft.getMinecraft().displayGuiScreen(bookmark); + if (bookmark instanceof IParented) ((IParented) bookmark).setParent(this); + ClientTickHandler.notifyPageChange(); + } + } + } + + bookmarksNeedPopulation = true; + if (modified) PersistentVariableHelper.saveSafe(); + } + + @Override + public boolean doesGuiPauseGame() { + return false; + } + + public int bookmarkWidth(String b) { + if (fontRendererObj == null) fontRendererObj = Minecraft.getMinecraft().fontRenderer; + + boolean unicode = fontRendererObj.getUnicodeFlag(); + fontRendererObj.setUnicodeFlag(true); + int width = fontRendererObj.getStringWidth(b) + 15; + fontRendererObj.setUnicodeFlag(unicode); + return width; + } + + String getTitle() { + return title; + } + + String getSubtitle() { + return null; + } + + int getTitleHeight() { + return getSubtitle() == null ? 12 : 22; + } + + boolean isIndex() { + return false; + } + + boolean isChallenge() { + return false; + } + + boolean isCategoryIndex() { + return true; + } + + void populateIndex() { + List categoryList = BotaniaAPI.getAllCategories(); + int shift = 2; + for (int i = shift; i < 12; i++) { + int i_ = i - shift; + GuiButtonInvisible button = (GuiButtonInvisible) buttonList.get(i); + LexiconCategory category = i_ >= categoryList.size() ? null : categoryList.get(i_); + if (category != null) button.displayString = StatCollector.translateToLocal(category.getUnlocalizedName()); + else { + button.displayString = StatCollector.translateToLocal("botaniamisc.lexiconIndex"); + break; + } + } + } + + void populateBookmarks() { + List remove = new ArrayList(); + List buttons = buttonList; + for (GuiButton button : buttons) if (button.id >= BOOKMARK_START) remove.add(button); + buttonList.removeAll(remove); + + int len = bookmarks.size(); + boolean thisExists = false; + for (GuiLexicon lex : bookmarks) if (lex.getTitle().equals(getTitle())) thisExists = true; + + boolean addEnabled = len < MAX_BOOKMARK_COUNT && this instanceof IParented && !thisExists; + for (int i = 0; i < len + (addEnabled ? 1 : 0); i++) { + boolean isAdd = i == bookmarks.size(); + GuiLexicon gui = isAdd ? null : bookmarks.get(i); + buttonList.add(new GuiButtonBookmark( + BOOKMARK_START + i, + left + 138, + top + 18 + 14 * i, + gui == null ? this : gui, + gui == null ? "+" : gui.getTitle())); + } + + if (isMainPage()) + buttonList.add(new GuiButtonHistory( + BOOKMARK_START + MAX_BOOKMARK_COUNT, + left + 138, + top + guiHeight - 24, + StatCollector.translateToLocal("botaniamisc.history"), + this)); + else if (isChallenge()) + buttonList.add(new GuiButtonChallengeInfo( + BOOKMARK_START + MAX_BOOKMARK_COUNT, + left + 138, + top + guiHeight - 24, + StatCollector.translateToLocal("botaniamisc.info"), + this)); + } + + public static void startTutorial() { + tutorial.clear(); + + tutorial.add(LexiconData.lexicon); + tutorial.add(LexiconData.flowers); + tutorial.add(LexiconData.apothecary); + tutorial.add(LexiconData.pureDaisy); + tutorial.add(LexiconData.wand); + tutorial.add(LexiconData.manaIntro); + tutorial.add(LexiconData.pool); + tutorial.add(LexiconData.spreader); + if (ConfigHandler.hardcorePassiveGeneration > 0) tutorial.add(LexiconData.generatingIntro); + tutorial.add(LexiconData.passiveGen); + tutorial.add(LexiconData.daybloom); + tutorial.add(LexiconData.functionalIntro); + tutorial.add(LexiconData.runicAltar); + + MinecraftForge.EVENT_BUS.post(new BotaniaTutorialStartEvent(tutorial)); + } + + public final void putTutorialArrow() { + hasTutorialArrow = !tutorial.isEmpty(); + if (hasTutorialArrow) positionTutorialArrow(); + } + + public void positionTutorialArrow() { + LexiconEntry entry = tutorial.peek(); + LexiconCategory category = entry.category; + + List buttons = buttonList; + for (GuiButton button : buttons) + if (button instanceof GuiButtonCategory) { + GuiButtonCategory catButton = (GuiButtonCategory) button; + if (catButton.getCategory() == category) { + orientTutorialArrowWithButton(button); + break; + } + } + } + + public void orientTutorialArrowWithButton(GuiButton button) { + tutorialArrowX = button.xPosition - TUTORIAL_ARROW_WIDTH; + tutorialArrowY = button.yPosition - TUTORIAL_ARROW_HEIGHT; + } + + boolean closeScreenOnInvKey() { + return true; + } + + @Override + protected void keyTyped(char par1, int par2) { + handleNoteKey(par1, par2); + + if (!notesEnabled && closeScreenOnInvKey() && mc.gameSettings.keyBindInventory.getKeyCode() == par2) { + mc.displayGuiScreen(null); + mc.setIngameFocus(); + } + + if (par2 == KONAMI_CODE[konamiIndex]) { + konamiIndex++; + if (konamiIndex >= KONAMI_CODE.length) { + mc.getSoundHandler() + .playSound(PositionedSoundRecord.func_147673_a(new ResourceLocation("botania:way"))); + konamiIndex = 0; + } + } else konamiIndex = 0; + + super.keyTyped(par1, par2); + } + + public void handleNoteKey(char par1, int par2) { + if (notesEnabled) { + Keyboard.enableRepeatEvents(true); + boolean changed = false; + + if (par2 == 14 && note.length() > 0) { + if (isCtrlKeyDown()) note = ""; + else { + if (note.endsWith("
")) note = note.substring(0, note.length() - 4); + else note = note.substring(0, note.length() - 1); + } + changed = true; + } + + if ((ChatAllowedCharacters.isAllowedCharacter(par1) || par2 == 28) && note.length() < 250) { + note += par2 == 28 ? "
" : par1; + changed = true; + } + + if (changed) { + notes.put(getNotesKey(), note); + PersistentVariableHelper.saveSafe(); + } + } else Keyboard.enableRepeatEvents(false); + } + + public static GuiLexicon create(NBTTagCompound cmp) { + String type = cmp.getString(TAG_TYPE); + try { + GuiLexicon lex = (GuiLexicon) Class.forName(type).newInstance(); + if (lex != null) lex.load(cmp); + if (isValidLexiconGui(lex)) return lex; + return null; + } catch (Exception e) { + e.printStackTrace(); + return null; + } + } + + public void serialize(NBTTagCompound cmp) { + cmp.setString(TAG_TYPE, getClass().getName()); + } + + public String getNotesKey() { + return "index"; + } + + public void load(NBTTagCompound cmp) { + // NO-OP + } + + public GuiLexicon copy() { + return new GuiLexicon(); + } + + public static boolean isValidLexiconGui(GuiLexicon gui) { + if (gui == null) return false; + if (gui.isCategoryIndex() || gui.isChallenge()) return true; + if (gui.isIndex()) { + GuiLexiconIndex indexGui = (GuiLexiconIndex) gui; + if (indexGui.category == null) return true; + return BotaniaAPI.getAllCategories().contains(indexGui.category); + } + + GuiLexiconEntry entryGui = (GuiLexiconEntry) gui; + if (!BotaniaAPI.getAllEntries().contains(entryGui.entry)) return false; + + return entryGui.page < entryGui.entry.pages.size(); + } } - diff --git a/src/main/java/vazkii/botania/client/gui/lexicon/GuiLexiconChallenge.java b/src/main/java/vazkii/botania/client/gui/lexicon/GuiLexiconChallenge.java index 5f852aedce..a664710f55 100644 --- a/src/main/java/vazkii/botania/client/gui/lexicon/GuiLexiconChallenge.java +++ b/src/main/java/vazkii/botania/client/gui/lexicon/GuiLexiconChallenge.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jun 29, 2015, 5:25:06 PM (GMT)] */ package vazkii.botania.client.gui.lexicon; @@ -16,10 +16,8 @@ import net.minecraft.nbt.NBTTagCompound; import net.minecraft.util.EnumChatFormatting; import net.minecraft.util.StatCollector; - import org.lwjgl.opengl.GL11; import org.lwjgl.opengl.GL12; - import vazkii.botania.client.challenge.Challenge; import vazkii.botania.client.challenge.ModChallenges; import vazkii.botania.client.core.handler.ClientTickHandler; @@ -29,153 +27,162 @@ public class GuiLexiconChallenge extends GuiLexicon implements IParented { - private static final String TAG_CHALLENGE = "challenge"; - - Challenge challenge; - GuiLexicon parent; - GuiButton backButton, completeButton; - - public GuiLexiconChallenge() { - parent = new GuiLexiconChallengesList(); - } - - public GuiLexiconChallenge(GuiLexicon parent, Challenge challenge) { - this.parent = parent; - this.challenge = challenge; - setTitle(); - } - - public void setTitle() { - title = challenge == null ? "(null)" : StatCollector.translateToLocal(challenge.unlocalizedName); - } - - @Override - public void onInitGui() { - super.onInitGui(); - setTitle(); - - buttonList.add(backButton = new GuiButtonBack(12, left + guiWidth / 2 - 8, top + guiHeight + 2)); - buttonList.add(completeButton = new GuiButton(13, left + 20, top + guiHeight - 35, guiWidth - 40, 20, "")); - setCompleteButtonTitle(); - } - - @Override - public void drawScreen(int par1, int par2, float par3) { - super.drawScreen(par1, par2, par3); - - RenderHelper.enableGUIStandardItemLighting(); - GL11.glEnable(GL12.GL_RESCALE_NORMAL); - RenderItem.getInstance().renderItemIntoGUI(fontRendererObj, mc.renderEngine, challenge.icon, left + 18, top + 15); - RenderHelper.disableStandardItemLighting(); - GL11.glEnable(GL11.GL_BLEND); - - boolean unicode = fontRendererObj.getUnicodeFlag(); - fontRendererObj.setUnicodeFlag(true); - fontRendererObj.drawString(EnumChatFormatting.BOLD + StatCollector.translateToLocal(challenge.unlocalizedName), left + 38, top + 13, 0); - fontRendererObj.drawString(StatCollector.translateToLocal(challenge.level.getName()) + " / " + (challenge.complete ? EnumChatFormatting.DARK_GREEN : EnumChatFormatting.DARK_RED) + StatCollector.translateToLocal(challenge.complete ? "botaniamisc.completed" : "botaniamisc.notCompleted"), left + 38, top + 23, 0); - - int width = guiWidth - 30; - int x = left + 16; - int y = top + 28; - - PageText.renderText(x, y, width, guiHeight, challenge.unlocalizedName + ".desc"); - fontRendererObj.setUnicodeFlag(unicode); - } - - @Override - protected void keyTyped(char par1, int par2) { - if(par2 == 14 && !notesEnabled) // Backspace - back(); - else if(par2 == 199) { // Home - mc.displayGuiScreen(new GuiLexicon()); - ClientTickHandler.notifyPageChange(); - } - - super.keyTyped(par1, par2); - } - - @Override - protected void mouseClicked(int par1, int par2, int par3) { - super.mouseClicked(par1, par2, par3); - - if(par3 == 1) - back(); - } - - @Override - protected void actionPerformed(GuiButton par1GuiButton) { - if(par1GuiButton.id >= BOOKMARK_START) - super.actionPerformed(par1GuiButton); - else if(par1GuiButton.id == 12) { - mc.displayGuiScreen(parent); - ClientTickHandler.notifyPageChange(); - } else if(par1GuiButton.id == 13) { - challenge.complete = !challenge.complete; - setCompleteButtonTitle(); - PersistentVariableHelper.saveSafe(); - } else if(par1GuiButton.id == NOTES_BUTTON_ID) - notesEnabled = !notesEnabled; - } - - void setCompleteButtonTitle() { - completeButton.displayString = StatCollector.translateToLocal(challenge.complete ? "botaniamisc.markNotCompleted" : "botaniamisc.markCompleted"); - } - - void back() { - if(backButton.enabled) { - actionPerformed(backButton); - backButton.func_146113_a(mc.getSoundHandler()); - } - } - - @Override - public void setParent(GuiLexicon gui) { - parent = gui; - } - - @Override - boolean isMainPage() { - return false; - } - - @Override - String getTitle() { - return title; - } - - @Override - boolean isChallenge() { - return true; - } - - @Override - boolean isCategoryIndex() { - return false; - } - - @Override - public GuiLexicon copy() { - return new GuiLexiconChallenge(parent, challenge); - } - - @Override - public void serialize(NBTTagCompound cmp) { - super.serialize(cmp); - cmp.setString(TAG_CHALLENGE, challenge.unlocalizedName); - } - - @Override - public void load(NBTTagCompound cmp) { - super.load(cmp); - String challengeName = cmp.getString(TAG_CHALLENGE); - Challenge c = ModChallenges.challengeLookup.get(challengeName); - challenge = c; - setTitle(); - } - - @Override - public String getNotesKey() { - return "challenge_" + challenge.unlocalizedName; - } - + private static final String TAG_CHALLENGE = "challenge"; + + Challenge challenge; + GuiLexicon parent; + GuiButton backButton, completeButton; + + public GuiLexiconChallenge() { + parent = new GuiLexiconChallengesList(); + } + + public GuiLexiconChallenge(GuiLexicon parent, Challenge challenge) { + this.parent = parent; + this.challenge = challenge; + setTitle(); + } + + public void setTitle() { + title = challenge == null ? "(null)" : StatCollector.translateToLocal(challenge.unlocalizedName); + } + + @Override + public void onInitGui() { + super.onInitGui(); + setTitle(); + + buttonList.add(backButton = new GuiButtonBack(12, left + guiWidth / 2 - 8, top + guiHeight + 2)); + buttonList.add(completeButton = new GuiButton(13, left + 20, top + guiHeight - 35, guiWidth - 40, 20, "")); + setCompleteButtonTitle(); + } + + @Override + public void drawScreen(int par1, int par2, float par3) { + super.drawScreen(par1, par2, par3); + + RenderHelper.enableGUIStandardItemLighting(); + GL11.glEnable(GL12.GL_RESCALE_NORMAL); + RenderItem.getInstance() + .renderItemIntoGUI(fontRendererObj, mc.renderEngine, challenge.icon, left + 18, top + 15); + RenderHelper.disableStandardItemLighting(); + GL11.glEnable(GL11.GL_BLEND); + + boolean unicode = fontRendererObj.getUnicodeFlag(); + fontRendererObj.setUnicodeFlag(true); + fontRendererObj.drawString( + EnumChatFormatting.BOLD + StatCollector.translateToLocal(challenge.unlocalizedName), + left + 38, + top + 13, + 0); + fontRendererObj.drawString( + StatCollector.translateToLocal(challenge.level.getName()) + " / " + + (challenge.complete ? EnumChatFormatting.DARK_GREEN : EnumChatFormatting.DARK_RED) + + StatCollector.translateToLocal( + challenge.complete ? "botaniamisc.completed" : "botaniamisc.notCompleted"), + left + 38, + top + 23, + 0); + + int width = guiWidth - 30; + int x = left + 16; + int y = top + 28; + + PageText.renderText(x, y, width, guiHeight, challenge.unlocalizedName + ".desc"); + fontRendererObj.setUnicodeFlag(unicode); + } + + @Override + protected void keyTyped(char par1, int par2) { + if (par2 == 14 && !notesEnabled) // Backspace + back(); + else if (par2 == 199) { // Home + mc.displayGuiScreen(new GuiLexicon()); + ClientTickHandler.notifyPageChange(); + } + + super.keyTyped(par1, par2); + } + + @Override + protected void mouseClicked(int par1, int par2, int par3) { + super.mouseClicked(par1, par2, par3); + + if (par3 == 1) back(); + } + + @Override + protected void actionPerformed(GuiButton par1GuiButton) { + if (par1GuiButton.id >= BOOKMARK_START) super.actionPerformed(par1GuiButton); + else if (par1GuiButton.id == 12) { + mc.displayGuiScreen(parent); + ClientTickHandler.notifyPageChange(); + } else if (par1GuiButton.id == 13) { + challenge.complete = !challenge.complete; + setCompleteButtonTitle(); + PersistentVariableHelper.saveSafe(); + } else if (par1GuiButton.id == NOTES_BUTTON_ID) notesEnabled = !notesEnabled; + } + + void setCompleteButtonTitle() { + completeButton.displayString = StatCollector.translateToLocal( + challenge.complete ? "botaniamisc.markNotCompleted" : "botaniamisc.markCompleted"); + } + + void back() { + if (backButton.enabled) { + actionPerformed(backButton); + backButton.func_146113_a(mc.getSoundHandler()); + } + } + + @Override + public void setParent(GuiLexicon gui) { + parent = gui; + } + + @Override + boolean isMainPage() { + return false; + } + + @Override + String getTitle() { + return title; + } + + @Override + boolean isChallenge() { + return true; + } + + @Override + boolean isCategoryIndex() { + return false; + } + + @Override + public GuiLexicon copy() { + return new GuiLexiconChallenge(parent, challenge); + } + + @Override + public void serialize(NBTTagCompound cmp) { + super.serialize(cmp); + cmp.setString(TAG_CHALLENGE, challenge.unlocalizedName); + } + + @Override + public void load(NBTTagCompound cmp) { + super.load(cmp); + String challengeName = cmp.getString(TAG_CHALLENGE); + Challenge c = ModChallenges.challengeLookup.get(challengeName); + challenge = c; + setTitle(); + } + + @Override + public String getNotesKey() { + return "challenge_" + challenge.unlocalizedName; + } } diff --git a/src/main/java/vazkii/botania/client/gui/lexicon/GuiLexiconChallengesList.java b/src/main/java/vazkii/botania/client/gui/lexicon/GuiLexiconChallengesList.java index 66484f628e..0e6b1c4cb7 100644 --- a/src/main/java/vazkii/botania/client/gui/lexicon/GuiLexiconChallengesList.java +++ b/src/main/java/vazkii/botania/client/gui/lexicon/GuiLexiconChallengesList.java @@ -2,16 +2,15 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jun 29, 2015, 4:24:07 PM (GMT)] */ package vazkii.botania.client.gui.lexicon; import java.util.List; - import net.minecraft.client.gui.GuiButton; import net.minecraft.util.EnumChatFormatting; import net.minecraft.util.StatCollector; @@ -24,127 +23,126 @@ public class GuiLexiconChallengesList extends GuiLexicon implements IParented { - GuiLexicon parent; - GuiButton backButton; - - public GuiLexiconChallengesList() { - parent = new GuiLexicon(); - title = StatCollector.translateToLocal("botaniamisc.challenges"); - } - - @Override - public void onInitGui() { - super.onInitGui(); - title = StatCollector.translateToLocal("botaniamisc.challenges"); - - buttonList.add(backButton = new GuiButtonBack(12, left + guiWidth / 2 - 8, top + guiHeight + 2)); - - int perline = 6; - int i = 13; - int y = top + 20; - for(EnumChallengeLevel level : EnumChallengeLevel.class.getEnumConstants()) { - int j = 0; - for(Challenge c : ModChallenges.challenges.get(level)) { - buttonList.add(new GuiButtonChallengeIcon(i, left + 20 + j % perline * 18, y + j / perline * 17, c)); - i++; - j++; - } - y += 44; - } - } - - @Override - public void drawScreen(int par1, int par2, float par3) { - super.drawScreen(par1, par2, par3); - - boolean unicode = fontRendererObj.getUnicodeFlag(); - fontRendererObj.setUnicodeFlag(true); - for(EnumChallengeLevel level : EnumChallengeLevel.class.getEnumConstants()) { - List list = ModChallenges.challenges.get(level); - int complete = 0; - for(Challenge c : list) - if(c.complete) - complete++; - - fontRendererObj.drawString(EnumChatFormatting.BOLD + StatCollector.translateToLocal(level.getName()) + EnumChatFormatting.RESET + " (" + complete + "/" + list.size() + ")", left + 20, top + 11 + level.ordinal() * 44, 0); - } - fontRendererObj.setUnicodeFlag(unicode); - } - - @Override - protected void keyTyped(char par1, int par2) { - if(par2 == 14 && !notesEnabled) // Backspace - back(); - else if(par2 == 199) { // Home - mc.displayGuiScreen(new GuiLexicon()); - ClientTickHandler.notifyPageChange(); - } - - super.keyTyped(par1, par2); - } - - @Override - protected void mouseClicked(int par1, int par2, int par3) { - super.mouseClicked(par1, par2, par3); - - if(par3 == 1) - back(); - } - - @Override - protected void actionPerformed(GuiButton par1GuiButton) { - if(par1GuiButton.id >= BOOKMARK_START) - super.actionPerformed(par1GuiButton); - else if(par1GuiButton.id == 12) { - mc.displayGuiScreen(parent); - ClientTickHandler.notifyPageChange(); - } else if(par1GuiButton instanceof GuiButtonChallengeIcon) { - GuiButtonChallengeIcon cbutton = (GuiButtonChallengeIcon) par1GuiButton; - mc.displayGuiScreen(new GuiLexiconChallenge(this, cbutton.challenge)); - } else if(par1GuiButton.id == NOTES_BUTTON_ID) - notesEnabled = !notesEnabled; - } - - void back() { - if(backButton.enabled) { - actionPerformed(backButton); - backButton.func_146113_a(mc.getSoundHandler()); - } - } - - @Override - public void setParent(GuiLexicon gui) { - parent = gui; - } - - @Override - boolean isMainPage() { - return false; - } - - @Override - String getTitle() { - return title; - } - - @Override - boolean isChallenge() { - return true; - } - - @Override - boolean isCategoryIndex() { - return false; - } - - @Override - public GuiLexicon copy() { - return new GuiLexiconChallengesList(); - } - - @Override - public String getNotesKey() { - return "challengelist"; - } - + GuiLexicon parent; + GuiButton backButton; + + public GuiLexiconChallengesList() { + parent = new GuiLexicon(); + title = StatCollector.translateToLocal("botaniamisc.challenges"); + } + + @Override + public void onInitGui() { + super.onInitGui(); + title = StatCollector.translateToLocal("botaniamisc.challenges"); + + buttonList.add(backButton = new GuiButtonBack(12, left + guiWidth / 2 - 8, top + guiHeight + 2)); + + int perline = 6; + int i = 13; + int y = top + 20; + for (EnumChallengeLevel level : EnumChallengeLevel.class.getEnumConstants()) { + int j = 0; + for (Challenge c : ModChallenges.challenges.get(level)) { + buttonList.add(new GuiButtonChallengeIcon(i, left + 20 + j % perline * 18, y + j / perline * 17, c)); + i++; + j++; + } + y += 44; + } + } + + @Override + public void drawScreen(int par1, int par2, float par3) { + super.drawScreen(par1, par2, par3); + + boolean unicode = fontRendererObj.getUnicodeFlag(); + fontRendererObj.setUnicodeFlag(true); + for (EnumChallengeLevel level : EnumChallengeLevel.class.getEnumConstants()) { + List list = ModChallenges.challenges.get(level); + int complete = 0; + for (Challenge c : list) if (c.complete) complete++; + + fontRendererObj.drawString( + EnumChatFormatting.BOLD + StatCollector.translateToLocal(level.getName()) + EnumChatFormatting.RESET + + " (" + complete + "/" + list.size() + ")", + left + 20, + top + 11 + level.ordinal() * 44, + 0); + } + fontRendererObj.setUnicodeFlag(unicode); + } + + @Override + protected void keyTyped(char par1, int par2) { + if (par2 == 14 && !notesEnabled) // Backspace + back(); + else if (par2 == 199) { // Home + mc.displayGuiScreen(new GuiLexicon()); + ClientTickHandler.notifyPageChange(); + } + + super.keyTyped(par1, par2); + } + + @Override + protected void mouseClicked(int par1, int par2, int par3) { + super.mouseClicked(par1, par2, par3); + + if (par3 == 1) back(); + } + + @Override + protected void actionPerformed(GuiButton par1GuiButton) { + if (par1GuiButton.id >= BOOKMARK_START) super.actionPerformed(par1GuiButton); + else if (par1GuiButton.id == 12) { + mc.displayGuiScreen(parent); + ClientTickHandler.notifyPageChange(); + } else if (par1GuiButton instanceof GuiButtonChallengeIcon) { + GuiButtonChallengeIcon cbutton = (GuiButtonChallengeIcon) par1GuiButton; + mc.displayGuiScreen(new GuiLexiconChallenge(this, cbutton.challenge)); + } else if (par1GuiButton.id == NOTES_BUTTON_ID) notesEnabled = !notesEnabled; + } + + void back() { + if (backButton.enabled) { + actionPerformed(backButton); + backButton.func_146113_a(mc.getSoundHandler()); + } + } + + @Override + public void setParent(GuiLexicon gui) { + parent = gui; + } + + @Override + boolean isMainPage() { + return false; + } + + @Override + String getTitle() { + return title; + } + + @Override + boolean isChallenge() { + return true; + } + + @Override + boolean isCategoryIndex() { + return false; + } + + @Override + public GuiLexicon copy() { + return new GuiLexiconChallengesList(); + } + + @Override + public String getNotesKey() { + return "challengelist"; + } } diff --git a/src/main/java/vazkii/botania/client/gui/lexicon/GuiLexiconEntry.java b/src/main/java/vazkii/botania/client/gui/lexicon/GuiLexiconEntry.java index 4aebd5db32..e23559920e 100644 --- a/src/main/java/vazkii/botania/client/gui/lexicon/GuiLexiconEntry.java +++ b/src/main/java/vazkii/botania/client/gui/lexicon/GuiLexiconEntry.java @@ -13,7 +13,6 @@ import java.awt.Desktop; import java.net.URI; import java.util.List; - import net.minecraft.client.Minecraft; import net.minecraft.client.gui.GuiButton; import net.minecraft.client.gui.GuiScreen; @@ -22,9 +21,7 @@ import net.minecraft.util.ChatStyle; import net.minecraft.util.EnumChatFormatting; import net.minecraft.util.StatCollector; - import org.lwjgl.input.Mouse; - import vazkii.botania.api.BotaniaAPI; import vazkii.botania.api.internal.IGuiLexiconEntry; import vazkii.botania.api.lexicon.IAddonEntry; @@ -38,384 +35,375 @@ public class GuiLexiconEntry extends GuiLexicon implements IGuiLexiconEntry, IParented { - private static final String TAG_ENTRY = "entry"; - private static final String TAG_PAGE = "page"; - - public int page = 0; - public boolean firstEntry = false; - LexiconEntry entry; - GuiScreen parent; - String title; - String subtitle; - - GuiButton leftButton, rightButton, backButton; - - public GuiLexiconEntry() { - parent = new GuiLexicon(); - setTitle(); - } - - public GuiLexiconEntry(LexiconEntry entry, GuiScreen parent) { - this.entry = entry; - this.parent = parent; - setTitle(); - } - - public void setTitle() { - if(entry == null) { - title = "(null)"; - return; - } - - title = StatCollector.translateToLocal(entry.getUnlocalizedName()); - if(entry instanceof IAddonEntry) - subtitle = StatCollector.translateToLocal(((IAddonEntry) entry).getSubtitle()); - else subtitle = null; - } - - @Override - public void onInitGui() { - super.onInitGui(); - - buttonList.add(backButton = new GuiButtonBackWithShift(0, left + guiWidth / 2 - 8, top + guiHeight + 2)); - buttonList.add(leftButton = new GuiButtonPage(1, left, top + guiHeight - 10, false)); - buttonList.add(rightButton = new GuiButtonPage(2, left + guiWidth - 18, top + guiHeight - 10, true)); - buttonList.add(new GuiButtonShare(3, left + guiWidth - 6, top - 2)); - if(entry.getWebLink() != null) - buttonList.add(new GuiButtonViewOnline(4, left - 8, top + 12)); - - if(!GuiLexicon.isValidLexiconGui(this)) { - currentOpenLexicon = new GuiLexicon(); - mc.displayGuiScreen(currentOpenLexicon); - ClientTickHandler.notifyPageChange(); - return; - } - - LexiconPage page = entry.pages.get(this.page); - - page.onOpened(this); - updatePageButtons(); - GuiLexiconHistory.visit(entry); - } - - @Override - public LexiconEntry getEntry() { - return entry; - } - - @Override - public int getPageOn() { - return page; - } - - @Override - boolean isMainPage() { - return false; - } - - @Override - String getTitle() { - return String.format("%s " + EnumChatFormatting.ITALIC + "(%s/%s)", title, page + 1, entry.pages.size()); - } - - @Override - String getSubtitle() { - return subtitle; - } - - @Override - boolean isCategoryIndex() { - return false; - } - - @Override - protected void actionPerformed(GuiButton par1GuiButton) { - LexiconPage currentPage = entry.pages.get(page); - LexiconPage newPage; - - if(par1GuiButton.id >= BOOKMARK_START) - handleBookmark(par1GuiButton); - else if(par1GuiButton.id == NOTES_BUTTON_ID) - notesEnabled = !notesEnabled; - else - switch(par1GuiButton.id) { - case 0 : - currentPage.onClosed(this); - mc.displayGuiScreen(GuiScreen.isShiftKeyDown() ? new GuiLexicon() : parent); - ClientTickHandler.notifyPageChange(); - break; - case 1 : - currentPage.onClosed(this); - page--; - newPage = entry.pages.get(page); - newPage.onOpened(this); - - ClientTickHandler.notifyPageChange(); - break; - case 2 : - currentPage.onClosed(this); - page++; - newPage = entry.pages.get(page); - newPage.onOpened(this); - - ClientTickHandler.notifyPageChange(); - break; - case 3 : - Minecraft mc = Minecraft.getMinecraft(); - String cmd = "/botania-share " + entry.getUnlocalizedName(); - - mc.ingameGUI.getChatGUI().addToSentMessages(cmd); - mc.thePlayer.sendChatMessage(cmd); - break; - case 4 : - try { - if(Desktop.isDesktopSupported()) - Desktop.getDesktop().browse(new URI(entry.getWebLink())); - } catch(Exception e) { - e.printStackTrace(); - } - } - - updatePageButtons(); - currentPage.onActionPerformed(this, par1GuiButton); - } - - public GuiLexiconEntry setFirstEntry() { - firstEntry = true; - return this; - } - - public void updatePageButtons() { - leftButton.enabled = page != 0; - rightButton.enabled = page + 1 < entry.pages.size(); - if(firstEntry) - backButton.enabled = !rightButton.enabled; - } - - @Override - public void drawScreen(int par1, int par2, float par3) { - super.drawScreen(par1, par2, par3); - - LexiconPage page = entry.pages.get(this.page); - page.renderScreen(this, par1, par2); - } - - @Override - public void updateScreen() { - super.updateScreen(); - - LexiconPage page = entry.pages.get(this.page); - page.updateScreen(this); - - if(this.page == entry.pages.size() - 1) { - LexiconEntry entry = tutorial.peek(); - if(entry == this.entry) { - tutorial.poll(); - positionTutorialArrow(); - if(tutorial.isEmpty()) { - mc.thePlayer.addChatMessage(new ChatComponentTranslation("botaniamisc.tutorialEnded").setChatStyle(new ChatStyle().setColor(EnumChatFormatting.RED))); - hasTutorialArrow = false; - } - } - } - } - - @Override - public void positionTutorialArrow() { - LexiconEntry entry = tutorial.peek(); - if(entry != this.entry) { - orientTutorialArrowWithButton(backButton); - return; - } - - if(rightButton.enabled && rightButton.visible) - orientTutorialArrowWithButton(rightButton); - } - - @Override - public int getLeft() { - return left; - } - - @Override - public int getTop() { - return top; - } - - @Override - public int getWidth() { - return guiWidth; - } - - @Override - public int getHeight() { - return guiHeight; - } - - @Override - public float getZLevel() { - return zLevel; - } - - @Override - public void setParent(GuiLexicon gui) { - parent = gui; - } - - int fx = 0; - boolean swiped = false; - - @Override - protected void mouseClickMove(int x, int y, int button, long time) { - if(button == 0 && Math.abs(x - fx) > 100 && mc.gameSettings.touchscreen && !swiped) { - double swipe = (x - fx) / Math.max(1, (double) time); - if(swipe < 0.5) { - nextPage(); - swiped = true; - } else if(swipe > 0.5) { - prevPage(); - swiped = true; - } - } - } - - @Override - protected void mouseClicked(int par1, int par2, int par3) { - super.mouseClicked(par1, par2, par3); - - fx = par1; - switch(par3) { - case 1: - back(); - break; - case 3: - nextPage(); - break; - case 4: - prevPage(); - break; - } - } - - @Override - public void handleMouseInput() { - super.handleMouseInput(); - - if(Mouse.getEventButton() == 0) - swiped = false; - - int w = Mouse.getEventDWheel(); - if(w < 0) - nextPage(); - else if(w > 0) - prevPage(); - } - - @Override - protected void keyTyped(char par1, int par2) { - handleNoteKey(par1, par2); - - LexiconPage page = entry.pages.get(this.page); - page.onKeyPressed(par1, par2); - - if(par2 == 1) { - mc.displayGuiScreen((GuiScreen)null); - mc.setIngameFocus(); - } else if(par2 == 203 || par2 == 200 || par2 == 201) // Left, Up, Page Up - prevPage(); - else if(par2 == 205 || par2 == 208 || par2 == 209) // Right, Down Page Down - nextPage(); - if(par2 == 14 && !notesEnabled) // Backspace - back(); - else if(par2 == 199) { // Home - mc.displayGuiScreen(new GuiLexicon()); - ClientTickHandler.notifyPageChange(); - } - } - - void back() { - if(backButton.enabled) { - actionPerformed(backButton); - backButton.func_146113_a(mc.getSoundHandler()); - } - } - - void nextPage() { - if(rightButton.enabled) { - actionPerformed(rightButton); - rightButton.func_146113_a(mc.getSoundHandler()); - updateNote(); - } - } - - void prevPage() { - if(leftButton.enabled) { - actionPerformed(leftButton); - leftButton.func_146113_a(mc.getSoundHandler()); - updateNote(); - } - } - - void updateNote() { - String key = getNotesKey(); - if(!notes.containsKey(key)) - note = ""; - else note = notes.get(key); - } - - @Override - public List getButtonList() { - return buttonList; - } - - @Override - public float getElapsedTicks() { - return lastTime; - } - - @Override - public float getPartialTicks() { - return partialTicks; - } - - @Override - public float getTickDelta() { - return timeDelta; - } - - @Override - public void serialize(NBTTagCompound cmp) { - super.serialize(cmp); - cmp.setString(TAG_ENTRY, entry.getUnlocalizedName()); - cmp.setInteger(TAG_PAGE, page); - } - - @Override - public void load(NBTTagCompound cmp) { - super.load(cmp); - - String entryStr = cmp.getString(TAG_ENTRY); - for(LexiconEntry entry : BotaniaAPI.getAllEntries()) - if(entry.getUnlocalizedName().equals(entryStr)) { - this.entry = entry; - break; - } - - page = cmp.getInteger(TAG_PAGE); - - setTitle(); - } - - @Override - public GuiLexicon copy() { - GuiLexiconEntry gui = new GuiLexiconEntry(entry, new GuiScreen()); - gui.page = page; - gui.setTitle(); - return gui; - } - - @Override - public String getNotesKey() { - return "entry_" + entry.unlocalizedName + "_" + page; - } + private static final String TAG_ENTRY = "entry"; + private static final String TAG_PAGE = "page"; + + public int page = 0; + public boolean firstEntry = false; + LexiconEntry entry; + GuiScreen parent; + String title; + String subtitle; + + GuiButton leftButton, rightButton, backButton; + + public GuiLexiconEntry() { + parent = new GuiLexicon(); + setTitle(); + } + + public GuiLexiconEntry(LexiconEntry entry, GuiScreen parent) { + this.entry = entry; + this.parent = parent; + setTitle(); + } + + public void setTitle() { + if (entry == null) { + title = "(null)"; + return; + } + + title = StatCollector.translateToLocal(entry.getUnlocalizedName()); + if (entry instanceof IAddonEntry) + subtitle = StatCollector.translateToLocal(((IAddonEntry) entry).getSubtitle()); + else subtitle = null; + } + + @Override + public void onInitGui() { + super.onInitGui(); + + buttonList.add(backButton = new GuiButtonBackWithShift(0, left + guiWidth / 2 - 8, top + guiHeight + 2)); + buttonList.add(leftButton = new GuiButtonPage(1, left, top + guiHeight - 10, false)); + buttonList.add(rightButton = new GuiButtonPage(2, left + guiWidth - 18, top + guiHeight - 10, true)); + buttonList.add(new GuiButtonShare(3, left + guiWidth - 6, top - 2)); + if (entry.getWebLink() != null) buttonList.add(new GuiButtonViewOnline(4, left - 8, top + 12)); + + if (!GuiLexicon.isValidLexiconGui(this)) { + currentOpenLexicon = new GuiLexicon(); + mc.displayGuiScreen(currentOpenLexicon); + ClientTickHandler.notifyPageChange(); + return; + } + + LexiconPage page = entry.pages.get(this.page); + + page.onOpened(this); + updatePageButtons(); + GuiLexiconHistory.visit(entry); + } + + @Override + public LexiconEntry getEntry() { + return entry; + } + + @Override + public int getPageOn() { + return page; + } + + @Override + boolean isMainPage() { + return false; + } + + @Override + String getTitle() { + return String.format("%s " + EnumChatFormatting.ITALIC + "(%s/%s)", title, page + 1, entry.pages.size()); + } + + @Override + String getSubtitle() { + return subtitle; + } + + @Override + boolean isCategoryIndex() { + return false; + } + + @Override + protected void actionPerformed(GuiButton par1GuiButton) { + LexiconPage currentPage = entry.pages.get(page); + LexiconPage newPage; + + if (par1GuiButton.id >= BOOKMARK_START) handleBookmark(par1GuiButton); + else if (par1GuiButton.id == NOTES_BUTTON_ID) notesEnabled = !notesEnabled; + else + switch (par1GuiButton.id) { + case 0: + currentPage.onClosed(this); + mc.displayGuiScreen(GuiScreen.isShiftKeyDown() ? new GuiLexicon() : parent); + ClientTickHandler.notifyPageChange(); + break; + case 1: + currentPage.onClosed(this); + page--; + newPage = entry.pages.get(page); + newPage.onOpened(this); + + ClientTickHandler.notifyPageChange(); + break; + case 2: + currentPage.onClosed(this); + page++; + newPage = entry.pages.get(page); + newPage.onOpened(this); + + ClientTickHandler.notifyPageChange(); + break; + case 3: + Minecraft mc = Minecraft.getMinecraft(); + String cmd = "/botania-share " + entry.getUnlocalizedName(); + + mc.ingameGUI.getChatGUI().addToSentMessages(cmd); + mc.thePlayer.sendChatMessage(cmd); + break; + case 4: + try { + if (Desktop.isDesktopSupported()) Desktop.getDesktop().browse(new URI(entry.getWebLink())); + } catch (Exception e) { + e.printStackTrace(); + } + } + + updatePageButtons(); + currentPage.onActionPerformed(this, par1GuiButton); + } + + public GuiLexiconEntry setFirstEntry() { + firstEntry = true; + return this; + } + + public void updatePageButtons() { + leftButton.enabled = page != 0; + rightButton.enabled = page + 1 < entry.pages.size(); + if (firstEntry) backButton.enabled = !rightButton.enabled; + } + + @Override + public void drawScreen(int par1, int par2, float par3) { + super.drawScreen(par1, par2, par3); + + LexiconPage page = entry.pages.get(this.page); + page.renderScreen(this, par1, par2); + } + + @Override + public void updateScreen() { + super.updateScreen(); + + LexiconPage page = entry.pages.get(this.page); + page.updateScreen(this); + + if (this.page == entry.pages.size() - 1) { + LexiconEntry entry = tutorial.peek(); + if (entry == this.entry) { + tutorial.poll(); + positionTutorialArrow(); + if (tutorial.isEmpty()) { + mc.thePlayer.addChatMessage(new ChatComponentTranslation("botaniamisc.tutorialEnded") + .setChatStyle(new ChatStyle().setColor(EnumChatFormatting.RED))); + hasTutorialArrow = false; + } + } + } + } + + @Override + public void positionTutorialArrow() { + LexiconEntry entry = tutorial.peek(); + if (entry != this.entry) { + orientTutorialArrowWithButton(backButton); + return; + } + + if (rightButton.enabled && rightButton.visible) orientTutorialArrowWithButton(rightButton); + } + + @Override + public int getLeft() { + return left; + } + + @Override + public int getTop() { + return top; + } + + @Override + public int getWidth() { + return guiWidth; + } + + @Override + public int getHeight() { + return guiHeight; + } + + @Override + public float getZLevel() { + return zLevel; + } + + @Override + public void setParent(GuiLexicon gui) { + parent = gui; + } + + int fx = 0; + boolean swiped = false; + + @Override + protected void mouseClickMove(int x, int y, int button, long time) { + if (button == 0 && Math.abs(x - fx) > 100 && mc.gameSettings.touchscreen && !swiped) { + double swipe = (x - fx) / Math.max(1, (double) time); + if (swipe < 0.5) { + nextPage(); + swiped = true; + } else if (swipe > 0.5) { + prevPage(); + swiped = true; + } + } + } + + @Override + protected void mouseClicked(int par1, int par2, int par3) { + super.mouseClicked(par1, par2, par3); + + fx = par1; + switch (par3) { + case 1: + back(); + break; + case 3: + nextPage(); + break; + case 4: + prevPage(); + break; + } + } + + @Override + public void handleMouseInput() { + super.handleMouseInput(); + + if (Mouse.getEventButton() == 0) swiped = false; + + int w = Mouse.getEventDWheel(); + if (w < 0) nextPage(); + else if (w > 0) prevPage(); + } + + @Override + protected void keyTyped(char par1, int par2) { + handleNoteKey(par1, par2); + + LexiconPage page = entry.pages.get(this.page); + page.onKeyPressed(par1, par2); + + if (par2 == 1) { + mc.displayGuiScreen((GuiScreen) null); + mc.setIngameFocus(); + } else if (par2 == 203 || par2 == 200 || par2 == 201) // Left, Up, Page Up + prevPage(); + else if (par2 == 205 || par2 == 208 || par2 == 209) // Right, Down Page Down + nextPage(); + if (par2 == 14 && !notesEnabled) // Backspace + back(); + else if (par2 == 199) { // Home + mc.displayGuiScreen(new GuiLexicon()); + ClientTickHandler.notifyPageChange(); + } + } + + void back() { + if (backButton.enabled) { + actionPerformed(backButton); + backButton.func_146113_a(mc.getSoundHandler()); + } + } + + void nextPage() { + if (rightButton.enabled) { + actionPerformed(rightButton); + rightButton.func_146113_a(mc.getSoundHandler()); + updateNote(); + } + } + + void prevPage() { + if (leftButton.enabled) { + actionPerformed(leftButton); + leftButton.func_146113_a(mc.getSoundHandler()); + updateNote(); + } + } + + void updateNote() { + String key = getNotesKey(); + if (!notes.containsKey(key)) note = ""; + else note = notes.get(key); + } + + @Override + public List getButtonList() { + return buttonList; + } + + @Override + public float getElapsedTicks() { + return lastTime; + } + + @Override + public float getPartialTicks() { + return partialTicks; + } + + @Override + public float getTickDelta() { + return timeDelta; + } + + @Override + public void serialize(NBTTagCompound cmp) { + super.serialize(cmp); + cmp.setString(TAG_ENTRY, entry.getUnlocalizedName()); + cmp.setInteger(TAG_PAGE, page); + } + + @Override + public void load(NBTTagCompound cmp) { + super.load(cmp); + + String entryStr = cmp.getString(TAG_ENTRY); + for (LexiconEntry entry : BotaniaAPI.getAllEntries()) + if (entry.getUnlocalizedName().equals(entryStr)) { + this.entry = entry; + break; + } + + page = cmp.getInteger(TAG_PAGE); + + setTitle(); + } + + @Override + public GuiLexicon copy() { + GuiLexiconEntry gui = new GuiLexiconEntry(entry, new GuiScreen()); + gui.page = page; + gui.setTitle(); + return gui; + } + + @Override + public String getNotesKey() { + return "entry_" + entry.unlocalizedName + "_" + page; + } } diff --git a/src/main/java/vazkii/botania/client/gui/lexicon/GuiLexiconHistory.java b/src/main/java/vazkii/botania/client/gui/lexicon/GuiLexiconHistory.java index 159d793a4c..b425d92641 100644 --- a/src/main/java/vazkii/botania/client/gui/lexicon/GuiLexiconHistory.java +++ b/src/main/java/vazkii/botania/client/gui/lexicon/GuiLexiconHistory.java @@ -2,17 +2,16 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Mar 2, 2015, 6:27:58 PM (GMT)] */ package vazkii.botania.client.gui.lexicon; import java.util.ArrayList; import java.util.List; - import net.minecraft.nbt.NBTTagCompound; import net.minecraft.util.StatCollector; import vazkii.botania.api.lexicon.ILexicon; @@ -20,43 +19,43 @@ public class GuiLexiconHistory extends GuiLexiconIndex { - public static List history = new ArrayList(); - - public GuiLexiconHistory() { - super(null); - title = StatCollector.translateToLocal("botaniamisc.historyLong"); - } - - @Override - void buildEntries() { - entriesToDisplay.clear(); - ILexicon lex = (ILexicon) stackUsed.getItem(); - for(int i = history.size() - 1; i >= 0; i--) { - LexiconEntry entry = history.get(i); - if(lex.isKnowledgeUnlocked(stackUsed, entry.getKnowledgeType()) && StatCollector.translateToLocal(entry.getUnlocalizedName()).toLowerCase().contains(searchField.getText().toLowerCase().trim())) - entriesToDisplay.add(entry); - } - } - - public static void visit(LexiconEntry entry) { - if(history.contains(entry)) - history.remove(entry); - history.add(entry); - } - - @Override - public GuiLexicon copy() { - return new GuiLexiconHistory(); - } - - @Override - public void load(NBTTagCompound cmp) { - // NO-OP - } - - @Override - public String getNotesKey() { - return "history"; - } - + public static List history = new ArrayList(); + + public GuiLexiconHistory() { + super(null); + title = StatCollector.translateToLocal("botaniamisc.historyLong"); + } + + @Override + void buildEntries() { + entriesToDisplay.clear(); + ILexicon lex = (ILexicon) stackUsed.getItem(); + for (int i = history.size() - 1; i >= 0; i--) { + LexiconEntry entry = history.get(i); + if (lex.isKnowledgeUnlocked(stackUsed, entry.getKnowledgeType()) + && StatCollector.translateToLocal(entry.getUnlocalizedName()) + .toLowerCase() + .contains(searchField.getText().toLowerCase().trim())) entriesToDisplay.add(entry); + } + } + + public static void visit(LexiconEntry entry) { + if (history.contains(entry)) history.remove(entry); + history.add(entry); + } + + @Override + public GuiLexicon copy() { + return new GuiLexiconHistory(); + } + + @Override + public void load(NBTTagCompound cmp) { + // NO-OP + } + + @Override + public String getNotesKey() { + return "history"; + } } diff --git a/src/main/java/vazkii/botania/client/gui/lexicon/GuiLexiconIndex.java b/src/main/java/vazkii/botania/client/gui/lexicon/GuiLexiconIndex.java index 2f1d23054e..9ea3590810 100644 --- a/src/main/java/vazkii/botania/client/gui/lexicon/GuiLexiconIndex.java +++ b/src/main/java/vazkii/botania/client/gui/lexicon/GuiLexiconIndex.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jan 14, 2014, 6:46:59 PM (GMT)] */ package vazkii.botania.client.gui.lexicon; @@ -13,7 +13,6 @@ import java.util.ArrayList; import java.util.Collections; import java.util.List; - import net.minecraft.client.gui.Gui; import net.minecraft.client.gui.GuiButton; import net.minecraft.client.gui.GuiTextField; @@ -23,11 +22,9 @@ import net.minecraft.nbt.NBTTagCompound; import net.minecraft.util.EnumChatFormatting; import net.minecraft.util.StatCollector; - import org.lwjgl.input.Mouse; import org.lwjgl.opengl.GL11; import org.lwjgl.opengl.GL12; - import vazkii.botania.api.BotaniaAPI; import vazkii.botania.api.lexicon.ILexicon; import vazkii.botania.api.lexicon.LexiconCategory; @@ -40,445 +37,438 @@ public class GuiLexiconIndex extends GuiLexicon implements IParented { - private static final String TAG_CATEGORY = "category"; - private static final String TAG_PAGE = "page"; - - LexiconCategory category; - String title; - int page = 0; - - int tutPage = -1; - - GuiButton leftButton, rightButton, backButton; - GuiLexicon parent; - GuiTextField searchField; - - GuiButton currentButton; - LexiconEntry currentEntry; - float infoTime; - - List entriesToDisplay = new ArrayList(); - - public GuiLexiconIndex() { - parent = new GuiLexicon(); - } - - public GuiLexiconIndex(LexiconCategory category) { - this.category = category; - parent = new GuiLexicon(); - setTitle(); - } - - public void setTitle() { - title = StatCollector.translateToLocal(category == null ? "botaniamisc.lexiconIndex" : category.getUnlocalizedName()); - } - - @Override - boolean isMainPage() { - return false; - } - - @Override - String getTitle() { - return title; - } - - @Override - boolean isIndex() { - return true; - } - - @Override - boolean isCategoryIndex() { - return false; - } - - @Override - public void onInitGui() { - super.onInitGui(); - - if(!GuiLexicon.isValidLexiconGui(this)) { - currentOpenLexicon = new GuiLexicon(); - mc.displayGuiScreen(currentOpenLexicon); - ClientTickHandler.notifyPageChange(); - return; - } - - buttonList.add(backButton = new GuiButtonBack(12, left + guiWidth / 2 - 8, top + guiHeight + 2)); - buttonList.add(leftButton = new GuiButtonPage(13, left, top + guiHeight - 10, false)); - buttonList.add(rightButton = new GuiButtonPage(14, left + guiWidth - 18, top + guiHeight - 10, true)); - - searchField = new GuiTextField(fontRendererObj, left + guiWidth / 2 + 28, top + guiHeight + 6, 200, 10); - searchField.setCanLoseFocus(false); - searchField.setFocused(true); - searchField.setEnableBackgroundDrawing(false); - - updateAll(); - } - - void updateAll() { - buildEntries(); - updatePageButtons(); - populateIndex(); - } - - void buildEntries() { - entriesToDisplay.clear(); - ILexicon lex = (ILexicon) stackUsed.getItem(); - for(LexiconEntry entry : category == null ? BotaniaAPI.getAllEntries() : category.entries) { - if(entry.isVisible() && lex.isKnowledgeUnlocked(stackUsed, entry.getKnowledgeType()) && matchesSearch(entry)) - entriesToDisplay.add(entry); - } - Collections.sort(entriesToDisplay); - } - - boolean matchesSearch(LexiconEntry e) { - String search = searchField.getText().trim(); - if(search.isEmpty()) - return true; - - search = search.toLowerCase(); - if(StatCollector.translateToLocal(e.getUnlocalizedName()).toLowerCase().contains(search)) - return true; - - for(ItemStack stack : e.getDisplayedRecipes()) { - String stackName = stack.getDisplayName().toLowerCase().trim(); - if(stackName.contains(search)) - return true; - } - - return false; - } - - @Override - void populateIndex() { - LexiconEntry tutEntry = tutorial != null && !tutorial.isEmpty() ? tutorial.peek() : null; - - for(int i = page * 12; i < (page + 1) * 12; i++) { - GuiButtonInvisible button = (GuiButtonInvisible) buttonList.get(i - page * 12); - LexiconEntry entry = i >= entriesToDisplay.size() ? null : entriesToDisplay.get(i); - if(entry != null) { - button.displayString = entry.getKnowledgeType().color + "" + (entry.isPriority() ? EnumChatFormatting.ITALIC : "") + StatCollector.translateToLocal(entry.getUnlocalizedName()); - button.displayStack = entry.getIcon(); - if(entry == tutEntry) - tutPage = page; - - if(entry instanceof DLexiconEntry) - button.dog = true; - } else button.displayString = ""; - } - } - - public void setHoveredButton(GuiButtonInvisible b) { - if(b == null) - currentEntry = null; - else currentEntry = entriesToDisplay.get(b.id + page * 12); - currentButton = b; - } - - @Override - public void drawScreen(int par1, int par2, float par3) { - super.drawScreen(par1, par2, par3); - - if(!searchField.getText().isEmpty()) { - drawBookmark(left + 138, top + guiHeight - 24, " " + searchField.getText(), false); - mc.renderEngine.bindTexture(texture); - GL11.glColor4f(1F, 1F, 1F, 1F); - drawTexturedModalRect(left + 134, top + guiHeight - 26, 86, 180, 12, 12); - - if(entriesToDisplay.size() == 1) { - boolean unicode = mc.fontRenderer.getUnicodeFlag(); - mc.fontRenderer.setUnicodeFlag(true); - String s = StatCollector.translateToLocal("botaniamisc.enterToView"); - mc.fontRenderer.drawString(s, left + guiWidth / 2 - mc.fontRenderer.getStringWidth(s) / 2, top + 30, 0x666666); - mc.fontRenderer.setUnicodeFlag(unicode); - } - } else { - boolean unicode = mc.fontRenderer.getUnicodeFlag(); - mc.fontRenderer.setUnicodeFlag(true); - String s = StatCollector.translateToLocal("botaniamisc.typeToSearch"); - mc.fontRenderer.drawString(s, left + 120 - mc.fontRenderer.getStringWidth(s), top + guiHeight - 18, 0x666666); - mc.fontRenderer.setUnicodeFlag(unicode); - } - - float animationTime = 4F; - if(isShiftKeyDown()) { - if(currentButton != null) - infoTime = Math.min(animationTime, infoTime + timeDelta); - } else { - infoTime = Math.max(0, infoTime - timeDelta); - - if(currentButton != null && infoTime == 0) { - int x = par1 + 10; - int y = par2; - - x = currentButton.xPosition - 20; - y = currentButton.yPosition; - - mc.fontRenderer.drawStringWithShadow("?", x, y, 0xFFFFFF); - GL11.glScalef(0.5F, 0.5F, 1F); - mc.fontRenderer.drawStringWithShadow(EnumChatFormatting.BOLD + "Shift", x * 2 - 6, y * 2 + 20, 0xFFFFFF); - GL11.glScalef(2F, 2F, 1F); - } - } - - if(currentButton != null && infoTime > 0) { - float fract = infoTime / animationTime; - - int x = currentButton.xPosition; - int y = currentButton.yPosition; - String s = StatCollector.translateToLocal(currentEntry.getTagline()); - boolean unicode = mc.fontRenderer.getUnicodeFlag(); - mc.fontRenderer.setUnicodeFlag(true); - int width = mc.fontRenderer.getStringWidth(s); - - GL11.glPushMatrix(); - GL11.glTranslatef(x, y, 0); - GL11.glScalef(fract, 1F, 1F); - Gui.drawRect(12, -30, width + 20, -2, 0x44000000); - Gui.drawRect(10, -32, width + 22, -2, 0x44000000); - drawBookmark(width / 2 + 16, -8, s, true, 0xFFFFFF, 180); - mc.fontRenderer.setUnicodeFlag(unicode); - - net.minecraft.client.renderer.RenderHelper.enableGUIStandardItemLighting(); - GL11.glEnable(GL12.GL_RESCALE_NORMAL); - ItemStack paper = new ItemStack(Items.paper, currentEntry.pages.size()); - - RenderItem.getInstance().renderItemAndEffectIntoGUI(mc.fontRenderer, mc.renderEngine, paper, 14, -28); - RenderItem.getInstance().renderItemOverlayIntoGUI(mc.fontRenderer, mc.renderEngine, paper, 14, -28); - List stacks = currentEntry.getDisplayedRecipes(); - - if(stacks.size() > 0) { - int spaceForEach = Math.min(18, (width - 30) / stacks.size()); - for(int i = 0; i < stacks.size(); i++) { - ItemStack stack = stacks.get(i); - RenderItem.getInstance().renderItemAndEffectIntoGUI(mc.fontRenderer, mc.renderEngine, stack, 38 + spaceForEach * i, -28); - } - } - - net.minecraft.client.renderer.RenderHelper.disableStandardItemLighting(); - - GL11.glPopMatrix(); - } - - setHoveredButton(null); - } - - @Override - public void positionTutorialArrow() { - LexiconEntry entry = tutorial.peek(); - LexiconCategory category = entry.category; - if(category != this.category) { - orientTutorialArrowWithButton(backButton); - return; - } - - if(tutPage != -1 && tutPage != page) { - orientTutorialArrowWithButton(tutPage < page ? leftButton : rightButton); - return; - } - - List buttons = buttonList; - for(GuiButton button : buttons) { - int id = button.id; - int index = id + page * 12; - if(index >= entriesToDisplay.size()) - continue; - - if(entry == entriesToDisplay.get(index)) { - orientTutorialArrowWithButton(id >= 12 ? rightButton : button); - break; - } - } - } - - @Override - protected void actionPerformed(GuiButton par1GuiButton) { - if(par1GuiButton.id >= BOOKMARK_START) - handleBookmark(par1GuiButton); - else if(par1GuiButton.id == NOTES_BUTTON_ID) - notesEnabled = !notesEnabled; - else - switch(par1GuiButton.id) { - case 12 : - mc.displayGuiScreen(parent); - ClientTickHandler.notifyPageChange(); - break; - case 13 : - page--; - updatePageButtons(); - populateIndex(); - ClientTickHandler.notifyPageChange(); - break; - case 14 : - page++; - updatePageButtons(); - populateIndex(); - ClientTickHandler.notifyPageChange(); - break; - default : - if(par1GuiButton instanceof GuiButtonInvisible && ((GuiButtonInvisible) par1GuiButton).dog) - ((GuiButtonInvisible) par1GuiButton).click(); - else { - int index = par1GuiButton.id + page * 12; - openEntry(index); - } - } - } - - void openEntry(int index) { - if(index >= entriesToDisplay.size()) - return; - - LexiconEntry entry = entriesToDisplay.get(index); - mc.displayGuiScreen(new GuiLexiconEntry(entry, this)); - ClientTickHandler.notifyPageChange(); - } - - public void updatePageButtons() { - leftButton.enabled = page != 0; - rightButton.enabled = page < (entriesToDisplay.size() - 1) / 12; - putTutorialArrow(); - } - - @Override - public void setParent(GuiLexicon gui) { - parent = gui; - } - - int fx = 0; - boolean swiped = false; - - @Override - protected void mouseClickMove(int x, int y, int button, long time) { - if(button == 0 && Math.abs(x - fx) > 100 && mc.gameSettings.touchscreen && !swiped) { - double swipe = (x - fx) / Math.max(1, (double) time); - if(swipe < 0.5) { - nextPage(); - swiped = true; - } else if(swipe > 0.5) { - prevPage(); - swiped = true; - } - } - } - - @Override - protected void mouseClicked(int par1, int par2, int par3) { - super.mouseClicked(par1, par2, par3); - - searchField.mouseClicked(par1, par2, par3); - fx = par1; - switch(par3) { - case 1: - back(); - break; - case 3: - nextPage(); - break; - case 4: - prevPage(); - break; - } - } - - @Override - public void handleMouseInput() { - super.handleMouseInput(); - - if(Mouse.getEventButton() == 0) - swiped = false; - - int w = Mouse.getEventDWheel(); - if(w < 0) - nextPage(); - else if(w > 0) - prevPage(); - } - - @Override - boolean closeScreenOnInvKey() { - return false; - } - - @Override - protected void keyTyped(char par1, int par2) { - if(par2 == 203 || par2 == 200 || par2 == 201) // Left, Up, Page Up - prevPage(); - else if(par2 == 205 || par2 == 208 || par2 == 209) // Right, Down Page Down - nextPage(); - else if(par2 == 14 && !notesEnabled && searchField.getText().isEmpty()) // Backspace - back(); - else if(par2 == 199) { // Home - mc.displayGuiScreen(new GuiLexicon()); - ClientTickHandler.notifyPageChange(); - } else if(par2 == 28 && entriesToDisplay.size() == 1) // Enter - openEntry(0); - - if(!notesEnabled) { - String search = searchField.getText(); - searchField.textboxKeyTyped(par1, par2); - if(!searchField.getText().equalsIgnoreCase(search)) - updateAll(); - } - - super.keyTyped(par1, par2); - } - - void back() { - if(backButton.enabled) { - actionPerformed(backButton); - backButton.func_146113_a(mc.getSoundHandler()); - } - } - - void nextPage() { - if(rightButton.enabled) { - actionPerformed(rightButton); - rightButton.func_146113_a(mc.getSoundHandler()); - } - } - - void prevPage() { - if(leftButton.enabled) { - actionPerformed(leftButton); - leftButton.func_146113_a(mc.getSoundHandler()); - } - } - - @Override - public void serialize(NBTTagCompound cmp) { - super.serialize(cmp); - cmp.setString(TAG_CATEGORY, category == null ? "" : category.getUnlocalizedName()); - cmp.setInteger(TAG_PAGE, page); - } - - @Override - public void load(NBTTagCompound cmp) { - super.load(cmp); - String categoryStr = cmp.getString(TAG_CATEGORY); - if(categoryStr.isEmpty()) - category = null; - else for(LexiconCategory cat : BotaniaAPI.getAllCategories()) - if(cat.getUnlocalizedName().equals(categoryStr)) { - category = cat; - break; - } - page = cmp.getInteger(TAG_PAGE); - setTitle(); - } - - @Override - public GuiLexicon copy() { - GuiLexiconIndex gui = new GuiLexiconIndex(category); - gui.page = page; - gui.setTitle(); - return gui; - } - - @Override - public String getNotesKey() { - return "category_" + (category == null ? "lexindex" : category.unlocalizedName); - } + private static final String TAG_CATEGORY = "category"; + private static final String TAG_PAGE = "page"; + + LexiconCategory category; + String title; + int page = 0; + + int tutPage = -1; + + GuiButton leftButton, rightButton, backButton; + GuiLexicon parent; + GuiTextField searchField; + + GuiButton currentButton; + LexiconEntry currentEntry; + float infoTime; + + List entriesToDisplay = new ArrayList(); + + public GuiLexiconIndex() { + parent = new GuiLexicon(); + } + + public GuiLexiconIndex(LexiconCategory category) { + this.category = category; + parent = new GuiLexicon(); + setTitle(); + } + + public void setTitle() { + title = StatCollector.translateToLocal( + category == null ? "botaniamisc.lexiconIndex" : category.getUnlocalizedName()); + } + + @Override + boolean isMainPage() { + return false; + } + + @Override + String getTitle() { + return title; + } + + @Override + boolean isIndex() { + return true; + } + + @Override + boolean isCategoryIndex() { + return false; + } + + @Override + public void onInitGui() { + super.onInitGui(); + + if (!GuiLexicon.isValidLexiconGui(this)) { + currentOpenLexicon = new GuiLexicon(); + mc.displayGuiScreen(currentOpenLexicon); + ClientTickHandler.notifyPageChange(); + return; + } + + buttonList.add(backButton = new GuiButtonBack(12, left + guiWidth / 2 - 8, top + guiHeight + 2)); + buttonList.add(leftButton = new GuiButtonPage(13, left, top + guiHeight - 10, false)); + buttonList.add(rightButton = new GuiButtonPage(14, left + guiWidth - 18, top + guiHeight - 10, true)); + + searchField = new GuiTextField(fontRendererObj, left + guiWidth / 2 + 28, top + guiHeight + 6, 200, 10); + searchField.setCanLoseFocus(false); + searchField.setFocused(true); + searchField.setEnableBackgroundDrawing(false); + + updateAll(); + } + + void updateAll() { + buildEntries(); + updatePageButtons(); + populateIndex(); + } + + void buildEntries() { + entriesToDisplay.clear(); + ILexicon lex = (ILexicon) stackUsed.getItem(); + for (LexiconEntry entry : category == null ? BotaniaAPI.getAllEntries() : category.entries) { + if (entry.isVisible() + && lex.isKnowledgeUnlocked(stackUsed, entry.getKnowledgeType()) + && matchesSearch(entry)) entriesToDisplay.add(entry); + } + Collections.sort(entriesToDisplay); + } + + boolean matchesSearch(LexiconEntry e) { + String search = searchField.getText().trim(); + if (search.isEmpty()) return true; + + search = search.toLowerCase(); + if (StatCollector.translateToLocal(e.getUnlocalizedName()).toLowerCase().contains(search)) return true; + + for (ItemStack stack : e.getDisplayedRecipes()) { + String stackName = stack.getDisplayName().toLowerCase().trim(); + if (stackName.contains(search)) return true; + } + + return false; + } + + @Override + void populateIndex() { + LexiconEntry tutEntry = tutorial != null && !tutorial.isEmpty() ? tutorial.peek() : null; + + for (int i = page * 12; i < (page + 1) * 12; i++) { + GuiButtonInvisible button = (GuiButtonInvisible) buttonList.get(i - page * 12); + LexiconEntry entry = i >= entriesToDisplay.size() ? null : entriesToDisplay.get(i); + if (entry != null) { + button.displayString = + entry.getKnowledgeType().color + "" + (entry.isPriority() ? EnumChatFormatting.ITALIC : "") + + StatCollector.translateToLocal(entry.getUnlocalizedName()); + button.displayStack = entry.getIcon(); + if (entry == tutEntry) tutPage = page; + + if (entry instanceof DLexiconEntry) button.dog = true; + } else button.displayString = ""; + } + } + + public void setHoveredButton(GuiButtonInvisible b) { + if (b == null) currentEntry = null; + else currentEntry = entriesToDisplay.get(b.id + page * 12); + currentButton = b; + } + + @Override + public void drawScreen(int par1, int par2, float par3) { + super.drawScreen(par1, par2, par3); + + if (!searchField.getText().isEmpty()) { + drawBookmark(left + 138, top + guiHeight - 24, " " + searchField.getText(), false); + mc.renderEngine.bindTexture(texture); + GL11.glColor4f(1F, 1F, 1F, 1F); + drawTexturedModalRect(left + 134, top + guiHeight - 26, 86, 180, 12, 12); + + if (entriesToDisplay.size() == 1) { + boolean unicode = mc.fontRenderer.getUnicodeFlag(); + mc.fontRenderer.setUnicodeFlag(true); + String s = StatCollector.translateToLocal("botaniamisc.enterToView"); + mc.fontRenderer.drawString( + s, left + guiWidth / 2 - mc.fontRenderer.getStringWidth(s) / 2, top + 30, 0x666666); + mc.fontRenderer.setUnicodeFlag(unicode); + } + } else { + boolean unicode = mc.fontRenderer.getUnicodeFlag(); + mc.fontRenderer.setUnicodeFlag(true); + String s = StatCollector.translateToLocal("botaniamisc.typeToSearch"); + mc.fontRenderer.drawString( + s, left + 120 - mc.fontRenderer.getStringWidth(s), top + guiHeight - 18, 0x666666); + mc.fontRenderer.setUnicodeFlag(unicode); + } + + float animationTime = 4F; + if (isShiftKeyDown()) { + if (currentButton != null) infoTime = Math.min(animationTime, infoTime + timeDelta); + } else { + infoTime = Math.max(0, infoTime - timeDelta); + + if (currentButton != null && infoTime == 0) { + int x = par1 + 10; + int y = par2; + + x = currentButton.xPosition - 20; + y = currentButton.yPosition; + + mc.fontRenderer.drawStringWithShadow("?", x, y, 0xFFFFFF); + GL11.glScalef(0.5F, 0.5F, 1F); + mc.fontRenderer.drawStringWithShadow( + EnumChatFormatting.BOLD + "Shift", x * 2 - 6, y * 2 + 20, 0xFFFFFF); + GL11.glScalef(2F, 2F, 1F); + } + } + + if (currentButton != null && infoTime > 0) { + float fract = infoTime / animationTime; + + int x = currentButton.xPosition; + int y = currentButton.yPosition; + String s = StatCollector.translateToLocal(currentEntry.getTagline()); + boolean unicode = mc.fontRenderer.getUnicodeFlag(); + mc.fontRenderer.setUnicodeFlag(true); + int width = mc.fontRenderer.getStringWidth(s); + + GL11.glPushMatrix(); + GL11.glTranslatef(x, y, 0); + GL11.glScalef(fract, 1F, 1F); + Gui.drawRect(12, -30, width + 20, -2, 0x44000000); + Gui.drawRect(10, -32, width + 22, -2, 0x44000000); + drawBookmark(width / 2 + 16, -8, s, true, 0xFFFFFF, 180); + mc.fontRenderer.setUnicodeFlag(unicode); + + net.minecraft.client.renderer.RenderHelper.enableGUIStandardItemLighting(); + GL11.glEnable(GL12.GL_RESCALE_NORMAL); + ItemStack paper = new ItemStack(Items.paper, currentEntry.pages.size()); + + RenderItem.getInstance().renderItemAndEffectIntoGUI(mc.fontRenderer, mc.renderEngine, paper, 14, -28); + RenderItem.getInstance().renderItemOverlayIntoGUI(mc.fontRenderer, mc.renderEngine, paper, 14, -28); + List stacks = currentEntry.getDisplayedRecipes(); + + if (stacks.size() > 0) { + int spaceForEach = Math.min(18, (width - 30) / stacks.size()); + for (int i = 0; i < stacks.size(); i++) { + ItemStack stack = stacks.get(i); + RenderItem.getInstance() + .renderItemAndEffectIntoGUI( + mc.fontRenderer, mc.renderEngine, stack, 38 + spaceForEach * i, -28); + } + } + + net.minecraft.client.renderer.RenderHelper.disableStandardItemLighting(); + + GL11.glPopMatrix(); + } + + setHoveredButton(null); + } + + @Override + public void positionTutorialArrow() { + LexiconEntry entry = tutorial.peek(); + LexiconCategory category = entry.category; + if (category != this.category) { + orientTutorialArrowWithButton(backButton); + return; + } + + if (tutPage != -1 && tutPage != page) { + orientTutorialArrowWithButton(tutPage < page ? leftButton : rightButton); + return; + } + + List buttons = buttonList; + for (GuiButton button : buttons) { + int id = button.id; + int index = id + page * 12; + if (index >= entriesToDisplay.size()) continue; + + if (entry == entriesToDisplay.get(index)) { + orientTutorialArrowWithButton(id >= 12 ? rightButton : button); + break; + } + } + } + + @Override + protected void actionPerformed(GuiButton par1GuiButton) { + if (par1GuiButton.id >= BOOKMARK_START) handleBookmark(par1GuiButton); + else if (par1GuiButton.id == NOTES_BUTTON_ID) notesEnabled = !notesEnabled; + else + switch (par1GuiButton.id) { + case 12: + mc.displayGuiScreen(parent); + ClientTickHandler.notifyPageChange(); + break; + case 13: + page--; + updatePageButtons(); + populateIndex(); + ClientTickHandler.notifyPageChange(); + break; + case 14: + page++; + updatePageButtons(); + populateIndex(); + ClientTickHandler.notifyPageChange(); + break; + default: + if (par1GuiButton instanceof GuiButtonInvisible && ((GuiButtonInvisible) par1GuiButton).dog) + ((GuiButtonInvisible) par1GuiButton).click(); + else { + int index = par1GuiButton.id + page * 12; + openEntry(index); + } + } + } + + void openEntry(int index) { + if (index >= entriesToDisplay.size()) return; + + LexiconEntry entry = entriesToDisplay.get(index); + mc.displayGuiScreen(new GuiLexiconEntry(entry, this)); + ClientTickHandler.notifyPageChange(); + } + + public void updatePageButtons() { + leftButton.enabled = page != 0; + rightButton.enabled = page < (entriesToDisplay.size() - 1) / 12; + putTutorialArrow(); + } + + @Override + public void setParent(GuiLexicon gui) { + parent = gui; + } + + int fx = 0; + boolean swiped = false; + + @Override + protected void mouseClickMove(int x, int y, int button, long time) { + if (button == 0 && Math.abs(x - fx) > 100 && mc.gameSettings.touchscreen && !swiped) { + double swipe = (x - fx) / Math.max(1, (double) time); + if (swipe < 0.5) { + nextPage(); + swiped = true; + } else if (swipe > 0.5) { + prevPage(); + swiped = true; + } + } + } + + @Override + protected void mouseClicked(int par1, int par2, int par3) { + super.mouseClicked(par1, par2, par3); + + searchField.mouseClicked(par1, par2, par3); + fx = par1; + switch (par3) { + case 1: + back(); + break; + case 3: + nextPage(); + break; + case 4: + prevPage(); + break; + } + } + + @Override + public void handleMouseInput() { + super.handleMouseInput(); + + if (Mouse.getEventButton() == 0) swiped = false; + + int w = Mouse.getEventDWheel(); + if (w < 0) nextPage(); + else if (w > 0) prevPage(); + } + + @Override + boolean closeScreenOnInvKey() { + return false; + } + + @Override + protected void keyTyped(char par1, int par2) { + if (par2 == 203 || par2 == 200 || par2 == 201) // Left, Up, Page Up + prevPage(); + else if (par2 == 205 || par2 == 208 || par2 == 209) // Right, Down Page Down + nextPage(); + else if (par2 == 14 && !notesEnabled && searchField.getText().isEmpty()) // Backspace + back(); + else if (par2 == 199) { // Home + mc.displayGuiScreen(new GuiLexicon()); + ClientTickHandler.notifyPageChange(); + } else if (par2 == 28 && entriesToDisplay.size() == 1) // Enter + openEntry(0); + + if (!notesEnabled) { + String search = searchField.getText(); + searchField.textboxKeyTyped(par1, par2); + if (!searchField.getText().equalsIgnoreCase(search)) updateAll(); + } + + super.keyTyped(par1, par2); + } + + void back() { + if (backButton.enabled) { + actionPerformed(backButton); + backButton.func_146113_a(mc.getSoundHandler()); + } + } + + void nextPage() { + if (rightButton.enabled) { + actionPerformed(rightButton); + rightButton.func_146113_a(mc.getSoundHandler()); + } + } + + void prevPage() { + if (leftButton.enabled) { + actionPerformed(leftButton); + leftButton.func_146113_a(mc.getSoundHandler()); + } + } + + @Override + public void serialize(NBTTagCompound cmp) { + super.serialize(cmp); + cmp.setString(TAG_CATEGORY, category == null ? "" : category.getUnlocalizedName()); + cmp.setInteger(TAG_PAGE, page); + } + + @Override + public void load(NBTTagCompound cmp) { + super.load(cmp); + String categoryStr = cmp.getString(TAG_CATEGORY); + if (categoryStr.isEmpty()) category = null; + else + for (LexiconCategory cat : BotaniaAPI.getAllCategories()) + if (cat.getUnlocalizedName().equals(categoryStr)) { + category = cat; + break; + } + page = cmp.getInteger(TAG_PAGE); + setTitle(); + } + + @Override + public GuiLexicon copy() { + GuiLexiconIndex gui = new GuiLexiconIndex(category); + gui.page = page; + gui.setTitle(); + return gui; + } + + @Override + public String getNotesKey() { + return "category_" + (category == null ? "lexindex" : category.unlocalizedName); + } } - diff --git a/src/main/java/vazkii/botania/client/gui/lexicon/IParented.java b/src/main/java/vazkii/botania/client/gui/lexicon/IParented.java index 7705930413..20523d78ee 100644 --- a/src/main/java/vazkii/botania/client/gui/lexicon/IParented.java +++ b/src/main/java/vazkii/botania/client/gui/lexicon/IParented.java @@ -2,6 +2,5 @@ public interface IParented { - public void setParent(GuiLexicon gui); - + public void setParent(GuiLexicon gui); } diff --git a/src/main/java/vazkii/botania/client/gui/lexicon/button/GuiButtonAchievement.java b/src/main/java/vazkii/botania/client/gui/lexicon/button/GuiButtonAchievement.java index 822add3436..5e6ee04ad7 100644 --- a/src/main/java/vazkii/botania/client/gui/lexicon/button/GuiButtonAchievement.java +++ b/src/main/java/vazkii/botania/client/gui/lexicon/button/GuiButtonAchievement.java @@ -2,47 +2,43 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Apr 3, 2015, 5:44:36 PM (GMT)] */ package vazkii.botania.client.gui.lexicon.button; import java.util.ArrayList; import java.util.List; - import net.minecraft.client.Minecraft; import net.minecraft.util.EnumChatFormatting; import net.minecraft.util.StatCollector; - import org.lwjgl.opengl.GL11; - import vazkii.botania.client.core.helper.RenderHelper; import vazkii.botania.client.gui.lexicon.GuiLexicon; public class GuiButtonAchievement extends GuiButtonLexicon { - public GuiButtonAchievement(int id, int x, int y) { - super(id, x, y, 11, 11, ""); - } - - @Override - public void drawButton(Minecraft par1Minecraft, int par2, int par3) { - field_146123_n = par2 >= xPosition && par3 >= yPosition && par2 < xPosition + width && par3 < yPosition + height; - int k = getHoverState(field_146123_n); + public GuiButtonAchievement(int id, int x, int y) { + super(id, x, y, 11, 11, ""); + } - par1Minecraft.renderEngine.bindTexture(GuiLexicon.texture); - GL11.glColor4f(1F, 1F, 1F, 1F); - drawTexturedModalRect(xPosition, yPosition, k == 2 ? 109 : 98, 191, 11, 11); + @Override + public void drawButton(Minecraft par1Minecraft, int par2, int par3) { + field_146123_n = + par2 >= xPosition && par3 >= yPosition && par2 < xPosition + width && par3 < yPosition + height; + int k = getHoverState(field_146123_n); - List tooltip = new ArrayList(); - tooltip.add(EnumChatFormatting.YELLOW + StatCollector.translateToLocal("botaniamisc.achievements")); + par1Minecraft.renderEngine.bindTexture(GuiLexicon.texture); + GL11.glColor4f(1F, 1F, 1F, 1F); + drawTexturedModalRect(xPosition, yPosition, k == 2 ? 109 : 98, 191, 11, 11); - int tooltipY = (tooltip.size() - 1) * 10; - if(k == 2) - RenderHelper.renderTooltip(par2, par3 + tooltipY, tooltip); - } + List tooltip = new ArrayList(); + tooltip.add(EnumChatFormatting.YELLOW + StatCollector.translateToLocal("botaniamisc.achievements")); -} \ No newline at end of file + int tooltipY = (tooltip.size() - 1) * 10; + if (k == 2) RenderHelper.renderTooltip(par2, par3 + tooltipY, tooltip); + } +} diff --git a/src/main/java/vazkii/botania/client/gui/lexicon/button/GuiButtonBack.java b/src/main/java/vazkii/botania/client/gui/lexicon/button/GuiButtonBack.java index 75f3de6277..41dd8b48d1 100644 --- a/src/main/java/vazkii/botania/client/gui/lexicon/button/GuiButtonBack.java +++ b/src/main/java/vazkii/botania/client/gui/lexicon/button/GuiButtonBack.java @@ -2,50 +2,46 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jan 14, 2014, 9:54:21 PM (GMT)] */ package vazkii.botania.client.gui.lexicon.button; import java.util.Arrays; import java.util.List; - import net.minecraft.client.Minecraft; import net.minecraft.util.StatCollector; - import org.lwjgl.opengl.GL11; - import vazkii.botania.client.core.helper.RenderHelper; import vazkii.botania.client.gui.lexicon.GuiLexicon; public class GuiButtonBack extends GuiButtonLexicon { - public GuiButtonBack(int par1, int par2, int par3) { - super(par1, par2, par3, 18, 9, ""); - } - - @Override - public void drawButton(Minecraft par1Minecraft, int par2, int par3) { - if(enabled) { - field_146123_n = par2 >= xPosition && par3 >= yPosition && par2 < xPosition + width && par3 < yPosition + height; - int k = getHoverState(field_146123_n); - - par1Minecraft.renderEngine.bindTexture(GuiLexicon.texture); - GL11.glColor4f(1F, 1F, 1F, 1F); - drawTexturedModalRect(xPosition, yPosition, 36, k == 2 ? 180 : 189, 18, 9); - - List tooltip = getTooltip(); - int tooltipY = (tooltip.size() - 1) * 10; - if(k == 2) - RenderHelper.renderTooltip(par2, par3 + tooltipY, tooltip); - } - } - - public List getTooltip() { - return Arrays.asList(StatCollector.translateToLocal("botaniamisc.back")); - } - + public GuiButtonBack(int par1, int par2, int par3) { + super(par1, par2, par3, 18, 9, ""); + } + + @Override + public void drawButton(Minecraft par1Minecraft, int par2, int par3) { + if (enabled) { + field_146123_n = + par2 >= xPosition && par3 >= yPosition && par2 < xPosition + width && par3 < yPosition + height; + int k = getHoverState(field_146123_n); + + par1Minecraft.renderEngine.bindTexture(GuiLexicon.texture); + GL11.glColor4f(1F, 1F, 1F, 1F); + drawTexturedModalRect(xPosition, yPosition, 36, k == 2 ? 180 : 189, 18, 9); + + List tooltip = getTooltip(); + int tooltipY = (tooltip.size() - 1) * 10; + if (k == 2) RenderHelper.renderTooltip(par2, par3 + tooltipY, tooltip); + } + } + + public List getTooltip() { + return Arrays.asList(StatCollector.translateToLocal("botaniamisc.back")); + } } diff --git a/src/main/java/vazkii/botania/client/gui/lexicon/button/GuiButtonBackWithShift.java b/src/main/java/vazkii/botania/client/gui/lexicon/button/GuiButtonBackWithShift.java index 329edad85d..b9223c4929 100644 --- a/src/main/java/vazkii/botania/client/gui/lexicon/button/GuiButtonBackWithShift.java +++ b/src/main/java/vazkii/botania/client/gui/lexicon/button/GuiButtonBackWithShift.java @@ -2,29 +2,29 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Mar 6, 2014, 6:35:32 PM (GMT)] */ package vazkii.botania.client.gui.lexicon.button; import java.util.Arrays; import java.util.List; - import net.minecraft.util.EnumChatFormatting; import net.minecraft.util.StatCollector; public class GuiButtonBackWithShift extends GuiButtonBack { - public GuiButtonBackWithShift(int par1, int par2, int par3) { - super(par1, par2, par3); - } - - @Override - public List getTooltip() { - return Arrays.asList(StatCollector.translateToLocal("botaniamisc.back"), EnumChatFormatting.GRAY + StatCollector.translateToLocal("botaniamisc.clickToIndex")); - } + public GuiButtonBackWithShift(int par1, int par2, int par3) { + super(par1, par2, par3); + } + @Override + public List getTooltip() { + return Arrays.asList( + StatCollector.translateToLocal("botaniamisc.back"), + EnumChatFormatting.GRAY + StatCollector.translateToLocal("botaniamisc.clickToIndex")); + } } diff --git a/src/main/java/vazkii/botania/client/gui/lexicon/button/GuiButtonBookmark.java b/src/main/java/vazkii/botania/client/gui/lexicon/button/GuiButtonBookmark.java index 8f972bb1e7..95a17d1606 100644 --- a/src/main/java/vazkii/botania/client/gui/lexicon/button/GuiButtonBookmark.java +++ b/src/main/java/vazkii/botania/client/gui/lexicon/button/GuiButtonBookmark.java @@ -2,7 +2,6 @@ import java.util.ArrayList; import java.util.List; - import net.minecraft.client.Minecraft; import net.minecraft.util.EnumChatFormatting; import net.minecraft.util.StatCollector; @@ -11,31 +10,30 @@ public class GuiButtonBookmark extends GuiButtonLexicon { - GuiLexicon gui; - - public GuiButtonBookmark(int par1, int par2, int par3, GuiLexicon gui, String str) { - super(par1, par2, par3, gui.bookmarkWidth(str) + 5, 11, str); - this.gui = gui; - } - - @Override - public void drawButton(Minecraft mc, int par2, int par3) { - gui.drawBookmark(xPosition, yPosition, displayString, false); - field_146123_n = par2 >= xPosition && par3 >= yPosition && par2 < xPosition + width && par3 < yPosition + height; - int k = getHoverState(field_146123_n); - - List tooltip = new ArrayList(); - if(displayString.equals("+")) - tooltip.add(StatCollector.translateToLocal("botaniamisc.clickToAdd")); - else { - tooltip.add(String.format(StatCollector.translateToLocal("botaniamisc.bookmark"), id - GuiLexicon.BOOKMARK_START + 1)); - tooltip.add(EnumChatFormatting.GRAY + StatCollector.translateToLocal("botaniamisc.clickToSee")); - tooltip.add(EnumChatFormatting.GRAY + StatCollector.translateToLocal("botaniamisc.shiftToRemove")); - } - - int tooltipY = (tooltip.size() + 1) * 5; - if(k == 2) - RenderHelper.renderTooltip(par2, par3 + tooltipY, tooltip); - } - + GuiLexicon gui; + + public GuiButtonBookmark(int par1, int par2, int par3, GuiLexicon gui, String str) { + super(par1, par2, par3, gui.bookmarkWidth(str) + 5, 11, str); + this.gui = gui; + } + + @Override + public void drawButton(Minecraft mc, int par2, int par3) { + gui.drawBookmark(xPosition, yPosition, displayString, false); + field_146123_n = + par2 >= xPosition && par3 >= yPosition && par2 < xPosition + width && par3 < yPosition + height; + int k = getHoverState(field_146123_n); + + List tooltip = new ArrayList(); + if (displayString.equals("+")) tooltip.add(StatCollector.translateToLocal("botaniamisc.clickToAdd")); + else { + tooltip.add(String.format( + StatCollector.translateToLocal("botaniamisc.bookmark"), id - GuiLexicon.BOOKMARK_START + 1)); + tooltip.add(EnumChatFormatting.GRAY + StatCollector.translateToLocal("botaniamisc.clickToSee")); + tooltip.add(EnumChatFormatting.GRAY + StatCollector.translateToLocal("botaniamisc.shiftToRemove")); + } + + int tooltipY = (tooltip.size() + 1) * 5; + if (k == 2) RenderHelper.renderTooltip(par2, par3 + tooltipY, tooltip); + } } diff --git a/src/main/java/vazkii/botania/client/gui/lexicon/button/GuiButtonCategory.java b/src/main/java/vazkii/botania/client/gui/lexicon/button/GuiButtonCategory.java index ca6b49d3c1..364f5605c0 100644 --- a/src/main/java/vazkii/botania/client/gui/lexicon/button/GuiButtonCategory.java +++ b/src/main/java/vazkii/botania/client/gui/lexicon/button/GuiButtonCategory.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Oct 18, 2014, 4:00:30 PM (GMT)] */ package vazkii.botania.client.gui.lexicon.button; @@ -15,11 +15,9 @@ import net.minecraft.client.renderer.texture.TextureManager; import net.minecraft.util.ResourceLocation; import net.minecraft.util.StatCollector; - import org.lwjgl.opengl.ARBMultitexture; import org.lwjgl.opengl.ARBShaderObjects; import org.lwjgl.opengl.GL11; - import vazkii.botania.api.internal.ShaderCallback; import vazkii.botania.api.lexicon.LexiconCategory; import vazkii.botania.client.core.helper.RenderHelper; @@ -30,107 +28,102 @@ public class GuiButtonCategory extends GuiButtonLexicon { - private static final ResourceLocation fallbackResource = new ResourceLocation(LibResources.CATEGORY_INDEX); - private static final ResourceLocation stencilResource = new ResourceLocation(LibResources.GUI_STENCIL); - - private ShaderCallback shaderCallback = new ShaderCallback() { - - @Override - public void call(int shader) { - TextureManager r = Minecraft.getMinecraft().renderEngine; - int heightMatchUniform = ARBShaderObjects.glGetUniformLocationARB(shader, "heightMatch"); - int imageUniform = ARBShaderObjects.glGetUniformLocationARB(shader, "image"); - int maskUniform = ARBShaderObjects.glGetUniformLocationARB(shader, "mask"); - - float heightMatch = ticksHovered / time; - OpenGlHelper.setActiveTexture(ARBMultitexture.GL_TEXTURE0_ARB); - GL11.glBindTexture(GL11.GL_TEXTURE_2D, r.getTexture(resource).getGlTextureId()); - ARBShaderObjects.glUniform1iARB(imageUniform, 0); - - OpenGlHelper.setActiveTexture(ARBMultitexture.GL_TEXTURE0_ARB + ConfigHandler.glSecondaryTextureUnit); - GL11.glEnable(GL11.GL_TEXTURE_2D); - GL11.glGetInteger(GL11.GL_TEXTURE_BINDING_2D); - GL11.glBindTexture(GL11.GL_TEXTURE_2D, r.getTexture(stencilResource).getGlTextureId()); - ARBShaderObjects.glUniform1iARB(maskUniform, ConfigHandler.glSecondaryTextureUnit); - - ARBShaderObjects.glUniform1fARB(heightMatchUniform, heightMatch); - } - }; - static boolean boundStencil = false; - - GuiLexicon gui; - LexiconCategory category; - ResourceLocation resource = null; - float ticksHovered = 0F; - float time = 12F; - int activeTex = 0; - - public GuiButtonCategory(int id, int x, int y, GuiLexicon gui, LexiconCategory category) { - super(id, x, y, 16, 16, ""); - this.gui = gui; - this.category = category; - } - - @Override - public void drawButton(Minecraft mc, int mx, int my) { - boolean inside = mx >= xPosition && my >= yPosition && mx < xPosition + width && my < yPosition + height; - if(inside) - ticksHovered = Math.min(time, ticksHovered + gui.timeDelta); - else ticksHovered = Math.max(0F, ticksHovered - gui.timeDelta); - - if(resource == null) { - if(category == null) - resource = fallbackResource; - else resource = category.getIcon(); - if(resource == null) - resource = fallbackResource; - } - - float s = 1F / 32F; - GL11.glPushMatrix(); - GL11.glEnable(GL11.GL_BLEND); - GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); - GL11.glScalef(0.5F, 0.5F, 0.5F); - GL11.glColor4f(1F, 1F, 1F, 1F); - - if(!boundStencil) { // Allow for the texture manager to take care of the ResourceLocation before we use it directly with gl - mc.renderEngine.bindTexture(stencilResource); - boundStencil = true; - } - mc.renderEngine.bindTexture(resource); - - int texture = 0; - boolean shaders = ShaderHelper.useShaders(); - - if(shaders) { - OpenGlHelper.setActiveTexture(ARBMultitexture.GL_TEXTURE0_ARB + ConfigHandler.glSecondaryTextureUnit); - texture = GL11.glGetInteger(GL11.GL_TEXTURE_BINDING_2D); - } - - ShaderHelper.useShader(ShaderHelper.categoryButton, shaderCallback); - RenderHelper.drawTexturedModalRect(xPosition * 2, yPosition * 2, zLevel * 2, 0, 0, 32, 32, s, s); - ShaderHelper.releaseShader(); - - if(shaders) { - OpenGlHelper.setActiveTexture(ARBMultitexture.GL_TEXTURE0_ARB + ConfigHandler.glSecondaryTextureUnit); - GL11.glBindTexture(GL11.GL_TEXTURE_2D, texture); - OpenGlHelper.setActiveTexture(ARBMultitexture.GL_TEXTURE0_ARB); - } - - GL11.glPopMatrix(); - - if(inside) - gui.categoryHighlight = StatCollector.translateToLocal(getTooltipText()); - } - - String getTooltipText() { - if(category == null) - return "botaniamisc.lexiconIndex"; - return category.getUnlocalizedName(); - } - - public LexiconCategory getCategory() { - return category; - } - + private static final ResourceLocation fallbackResource = new ResourceLocation(LibResources.CATEGORY_INDEX); + private static final ResourceLocation stencilResource = new ResourceLocation(LibResources.GUI_STENCIL); + + private ShaderCallback shaderCallback = new ShaderCallback() { + + @Override + public void call(int shader) { + TextureManager r = Minecraft.getMinecraft().renderEngine; + int heightMatchUniform = ARBShaderObjects.glGetUniformLocationARB(shader, "heightMatch"); + int imageUniform = ARBShaderObjects.glGetUniformLocationARB(shader, "image"); + int maskUniform = ARBShaderObjects.glGetUniformLocationARB(shader, "mask"); + + float heightMatch = ticksHovered / time; + OpenGlHelper.setActiveTexture(ARBMultitexture.GL_TEXTURE0_ARB); + GL11.glBindTexture(GL11.GL_TEXTURE_2D, r.getTexture(resource).getGlTextureId()); + ARBShaderObjects.glUniform1iARB(imageUniform, 0); + + OpenGlHelper.setActiveTexture(ARBMultitexture.GL_TEXTURE0_ARB + ConfigHandler.glSecondaryTextureUnit); + GL11.glEnable(GL11.GL_TEXTURE_2D); + GL11.glGetInteger(GL11.GL_TEXTURE_BINDING_2D); + GL11.glBindTexture(GL11.GL_TEXTURE_2D, r.getTexture(stencilResource).getGlTextureId()); + ARBShaderObjects.glUniform1iARB(maskUniform, ConfigHandler.glSecondaryTextureUnit); + + ARBShaderObjects.glUniform1fARB(heightMatchUniform, heightMatch); + } + }; + static boolean boundStencil = false; + + GuiLexicon gui; + LexiconCategory category; + ResourceLocation resource = null; + float ticksHovered = 0F; + float time = 12F; + int activeTex = 0; + + public GuiButtonCategory(int id, int x, int y, GuiLexicon gui, LexiconCategory category) { + super(id, x, y, 16, 16, ""); + this.gui = gui; + this.category = category; + } + + @Override + public void drawButton(Minecraft mc, int mx, int my) { + boolean inside = mx >= xPosition && my >= yPosition && mx < xPosition + width && my < yPosition + height; + if (inside) ticksHovered = Math.min(time, ticksHovered + gui.timeDelta); + else ticksHovered = Math.max(0F, ticksHovered - gui.timeDelta); + + if (resource == null) { + if (category == null) resource = fallbackResource; + else resource = category.getIcon(); + if (resource == null) resource = fallbackResource; + } + + float s = 1F / 32F; + GL11.glPushMatrix(); + GL11.glEnable(GL11.GL_BLEND); + GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); + GL11.glScalef(0.5F, 0.5F, 0.5F); + GL11.glColor4f(1F, 1F, 1F, 1F); + + if (!boundStencil) { // Allow for the texture manager to take care of the ResourceLocation before we use it + // directly with gl + mc.renderEngine.bindTexture(stencilResource); + boundStencil = true; + } + mc.renderEngine.bindTexture(resource); + + int texture = 0; + boolean shaders = ShaderHelper.useShaders(); + + if (shaders) { + OpenGlHelper.setActiveTexture(ARBMultitexture.GL_TEXTURE0_ARB + ConfigHandler.glSecondaryTextureUnit); + texture = GL11.glGetInteger(GL11.GL_TEXTURE_BINDING_2D); + } + + ShaderHelper.useShader(ShaderHelper.categoryButton, shaderCallback); + RenderHelper.drawTexturedModalRect(xPosition * 2, yPosition * 2, zLevel * 2, 0, 0, 32, 32, s, s); + ShaderHelper.releaseShader(); + + if (shaders) { + OpenGlHelper.setActiveTexture(ARBMultitexture.GL_TEXTURE0_ARB + ConfigHandler.glSecondaryTextureUnit); + GL11.glBindTexture(GL11.GL_TEXTURE_2D, texture); + OpenGlHelper.setActiveTexture(ARBMultitexture.GL_TEXTURE0_ARB); + } + + GL11.glPopMatrix(); + + if (inside) gui.categoryHighlight = StatCollector.translateToLocal(getTooltipText()); + } + + String getTooltipText() { + if (category == null) return "botaniamisc.lexiconIndex"; + return category.getUnlocalizedName(); + } + + public LexiconCategory getCategory() { + return category; + } } diff --git a/src/main/java/vazkii/botania/client/gui/lexicon/button/GuiButtonChallengeIcon.java b/src/main/java/vazkii/botania/client/gui/lexicon/button/GuiButtonChallengeIcon.java index b75da43aae..a407ae753e 100644 --- a/src/main/java/vazkii/botania/client/gui/lexicon/button/GuiButtonChallengeIcon.java +++ b/src/main/java/vazkii/botania/client/gui/lexicon/button/GuiButtonChallengeIcon.java @@ -2,62 +2,59 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jun 29, 2015, 5:00:30 PM (GMT)] */ package vazkii.botania.client.gui.lexicon.button; import java.util.ArrayList; import java.util.List; - import net.minecraft.client.Minecraft; import net.minecraft.client.renderer.RenderHelper; import net.minecraft.client.renderer.entity.RenderItem; import net.minecraft.util.EnumChatFormatting; import net.minecraft.util.StatCollector; - import org.lwjgl.opengl.GL11; import org.lwjgl.opengl.GL12; - import vazkii.botania.client.challenge.Challenge; public class GuiButtonChallengeIcon extends GuiButtonLexicon { - public Challenge challenge; - - public GuiButtonChallengeIcon(int id, int x, int y, Challenge challenge) { - super(id, x, y, 16, 16, ""); - this.challenge = challenge; - } - - @Override - public void drawButton(Minecraft par1Minecraft, int par2, int par3) { - field_146123_n = par2 >= xPosition && par3 >= yPosition && par2 < xPosition + width && par3 < yPosition + height; - int k = getHoverState(field_146123_n); - - RenderHelper.enableGUIStandardItemLighting(); - GL11.glEnable(GL12.GL_RESCALE_NORMAL); - RenderItem.getInstance().renderItemIntoGUI(par1Minecraft.fontRenderer, par1Minecraft.renderEngine, challenge.icon, xPosition, yPosition); - RenderHelper.disableStandardItemLighting(); - GL11.glEnable(GL11.GL_BLEND); - - if(challenge.complete) { - GL11.glDisable(GL11.GL_DEPTH_TEST); - par1Minecraft.fontRenderer.drawStringWithShadow("\u2714", xPosition + 10, yPosition + 9, 0x004C00); - par1Minecraft.fontRenderer.drawStringWithShadow("\u2714", xPosition + 10, yPosition + 8, 0x0BD20D); - GL11.glEnable(GL11.GL_DEPTH_TEST); - } - - - List tooltip = new ArrayList(); - tooltip.add(EnumChatFormatting.AQUA + StatCollector.translateToLocal(challenge.unlocalizedName)); - - int tooltipY = (tooltip.size() - 1) * 10; - if(k == 2) - vazkii.botania.client.core.helper.RenderHelper.renderTooltip(par2, par3 + tooltipY, tooltip); - } - + public Challenge challenge; + + public GuiButtonChallengeIcon(int id, int x, int y, Challenge challenge) { + super(id, x, y, 16, 16, ""); + this.challenge = challenge; + } + + @Override + public void drawButton(Minecraft par1Minecraft, int par2, int par3) { + field_146123_n = + par2 >= xPosition && par3 >= yPosition && par2 < xPosition + width && par3 < yPosition + height; + int k = getHoverState(field_146123_n); + + RenderHelper.enableGUIStandardItemLighting(); + GL11.glEnable(GL12.GL_RESCALE_NORMAL); + RenderItem.getInstance() + .renderItemIntoGUI( + par1Minecraft.fontRenderer, par1Minecraft.renderEngine, challenge.icon, xPosition, yPosition); + RenderHelper.disableStandardItemLighting(); + GL11.glEnable(GL11.GL_BLEND); + + if (challenge.complete) { + GL11.glDisable(GL11.GL_DEPTH_TEST); + par1Minecraft.fontRenderer.drawStringWithShadow("\u2714", xPosition + 10, yPosition + 9, 0x004C00); + par1Minecraft.fontRenderer.drawStringWithShadow("\u2714", xPosition + 10, yPosition + 8, 0x0BD20D); + GL11.glEnable(GL11.GL_DEPTH_TEST); + } + + List tooltip = new ArrayList(); + tooltip.add(EnumChatFormatting.AQUA + StatCollector.translateToLocal(challenge.unlocalizedName)); + + int tooltipY = (tooltip.size() - 1) * 10; + if (k == 2) vazkii.botania.client.core.helper.RenderHelper.renderTooltip(par2, par3 + tooltipY, tooltip); + } } diff --git a/src/main/java/vazkii/botania/client/gui/lexicon/button/GuiButtonChallengeInfo.java b/src/main/java/vazkii/botania/client/gui/lexicon/button/GuiButtonChallengeInfo.java index 0dd4fe65a4..806e14dc7e 100644 --- a/src/main/java/vazkii/botania/client/gui/lexicon/button/GuiButtonChallengeInfo.java +++ b/src/main/java/vazkii/botania/client/gui/lexicon/button/GuiButtonChallengeInfo.java @@ -2,17 +2,16 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jun 29, 2015, 7:42:52 PM (GMT)] */ package vazkii.botania.client.gui.lexicon.button; import java.util.ArrayList; import java.util.List; - import net.minecraft.client.Minecraft; import net.minecraft.util.StatCollector; import vazkii.botania.client.core.helper.RenderHelper; @@ -20,25 +19,24 @@ public class GuiButtonChallengeInfo extends GuiButtonLexicon { - GuiLexicon gui; - - public GuiButtonChallengeInfo(int par1, int par2, int par3, String str, GuiLexicon gui) { - super(par1, par2, par3, gui.bookmarkWidth(str) + 5, 11, str); - this.gui = gui; - } + GuiLexicon gui; - @Override - public void drawButton(Minecraft mc, int par2, int par3) { - gui.drawBookmark(xPosition, yPosition, displayString, false); - field_146123_n = par2 >= xPosition && par3 >= yPosition && par2 < xPosition + width && par3 < yPosition + height; - int k = getHoverState(field_146123_n); + public GuiButtonChallengeInfo(int par1, int par2, int par3, String str, GuiLexicon gui) { + super(par1, par2, par3, gui.bookmarkWidth(str) + 5, 11, str); + this.gui = gui; + } - List tooltip = new ArrayList(); - tooltip.add(StatCollector.translateToLocal("botaniamisc.challengeInfo")); + @Override + public void drawButton(Minecraft mc, int par2, int par3) { + gui.drawBookmark(xPosition, yPosition, displayString, false); + field_146123_n = + par2 >= xPosition && par3 >= yPosition && par2 < xPosition + width && par3 < yPosition + height; + int k = getHoverState(field_146123_n); - int tooltipY = (tooltip.size() + 1) * 5; - if(k == 2) - RenderHelper.renderTooltip(par2, par3 + tooltipY, tooltip); - } + List tooltip = new ArrayList(); + tooltip.add(StatCollector.translateToLocal("botaniamisc.challengeInfo")); -} \ No newline at end of file + int tooltipY = (tooltip.size() + 1) * 5; + if (k == 2) RenderHelper.renderTooltip(par2, par3 + tooltipY, tooltip); + } +} diff --git a/src/main/java/vazkii/botania/client/gui/lexicon/button/GuiButtonChallenges.java b/src/main/java/vazkii/botania/client/gui/lexicon/button/GuiButtonChallenges.java index 826dfa2c51..a3d9cba38e 100644 --- a/src/main/java/vazkii/botania/client/gui/lexicon/button/GuiButtonChallenges.java +++ b/src/main/java/vazkii/botania/client/gui/lexicon/button/GuiButtonChallenges.java @@ -2,47 +2,43 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jun 29, 2015, 4:16:09 PM (GMT)] */ package vazkii.botania.client.gui.lexicon.button; import java.util.ArrayList; import java.util.List; - import net.minecraft.client.Minecraft; import net.minecraft.util.EnumChatFormatting; import net.minecraft.util.StatCollector; - import org.lwjgl.opengl.GL11; - import vazkii.botania.client.core.helper.RenderHelper; import vazkii.botania.client.gui.lexicon.GuiLexicon; public class GuiButtonChallenges extends GuiButtonLexicon { - public GuiButtonChallenges(int id, int x, int y) { - super(id, x, y, 11, 11, ""); - } - - @Override - public void drawButton(Minecraft par1Minecraft, int par2, int par3) { - field_146123_n = par2 >= xPosition && par3 >= yPosition && par2 < xPosition + width && par3 < yPosition + height; - int k = getHoverState(field_146123_n); + public GuiButtonChallenges(int id, int x, int y) { + super(id, x, y, 11, 11, ""); + } - par1Minecraft.renderEngine.bindTexture(GuiLexicon.texture); - GL11.glColor4f(1F, 1F, 1F, 1F); - drawTexturedModalRect(xPosition, yPosition, k == 2 ? 131 : 120, 180, 11, 11); + @Override + public void drawButton(Minecraft par1Minecraft, int par2, int par3) { + field_146123_n = + par2 >= xPosition && par3 >= yPosition && par2 < xPosition + width && par3 < yPosition + height; + int k = getHoverState(field_146123_n); - List tooltip = new ArrayList(); - tooltip.add(EnumChatFormatting.YELLOW + StatCollector.translateToLocal("botaniamisc.challenges")); + par1Minecraft.renderEngine.bindTexture(GuiLexicon.texture); + GL11.glColor4f(1F, 1F, 1F, 1F); + drawTexturedModalRect(xPosition, yPosition, k == 2 ? 131 : 120, 180, 11, 11); - int tooltipY = (tooltip.size() - 1) * 10; - if(k == 2) - RenderHelper.renderTooltip(par2, par3 + tooltipY, tooltip); - } + List tooltip = new ArrayList(); + tooltip.add(EnumChatFormatting.YELLOW + StatCollector.translateToLocal("botaniamisc.challenges")); -} \ No newline at end of file + int tooltipY = (tooltip.size() - 1) * 10; + if (k == 2) RenderHelper.renderTooltip(par2, par3 + tooltipY, tooltip); + } +} diff --git a/src/main/java/vazkii/botania/client/gui/lexicon/button/GuiButtonDoot.java b/src/main/java/vazkii/botania/client/gui/lexicon/button/GuiButtonDoot.java index 1b2646b9e1..f47c39f0e8 100644 --- a/src/main/java/vazkii/botania/client/gui/lexicon/button/GuiButtonDoot.java +++ b/src/main/java/vazkii/botania/client/gui/lexicon/button/GuiButtonDoot.java @@ -2,26 +2,23 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Oct 11, 2015, 7:04:46 PM (GMT)] */ package vazkii.botania.client.gui.lexicon.button; import java.util.ArrayList; import java.util.List; - import net.minecraft.client.Minecraft; import net.minecraft.client.renderer.entity.RenderItem; import net.minecraft.client.renderer.texture.TextureMap; import net.minecraft.init.Items; import net.minecraft.item.ItemStack; import net.minecraft.util.EnumChatFormatting; - import org.lwjgl.opengl.GL11; - import vazkii.botania.client.core.helper.RenderHelper; import vazkii.botania.common.item.ModItems; @@ -29,31 +26,40 @@ // I should've done this last year public class GuiButtonDoot extends GuiButtonLexicon { - public GuiButtonDoot(int id, int x, int y) { - super(id, x, y, 16, 16, ""); - } + public GuiButtonDoot(int id, int x, int y) { + super(id, x, y, 16, 16, ""); + } - @Override - public void drawButton(Minecraft par1Minecraft, int par2, int par3) { - field_146123_n = par2 >= xPosition && par3 >= yPosition && par2 < xPosition + width && par3 < yPosition + height; - int k = getHoverState(field_146123_n); + @Override + public void drawButton(Minecraft par1Minecraft, int par2, int par3) { + field_146123_n = + par2 >= xPosition && par3 >= yPosition && par2 < xPosition + width && par3 < yPosition + height; + int k = getHoverState(field_146123_n); - par1Minecraft.renderEngine.bindTexture(TextureMap.locationItemsTexture); - GL11.glColor4f(1F, 1F, 1F, 1F); - RenderItem.getInstance().renderItemIntoGUI(par1Minecraft.fontRenderer, par1Minecraft.renderEngine, new ItemStack(ModItems.cacophonium), xPosition, yPosition); - RenderItem.getInstance().renderItemIntoGUI(par1Minecraft.fontRenderer, par1Minecraft.renderEngine, new ItemStack(Items.fireworks), xPosition + 8, yPosition + 2); + par1Minecraft.renderEngine.bindTexture(TextureMap.locationItemsTexture); + GL11.glColor4f(1F, 1F, 1F, 1F); + RenderItem.getInstance() + .renderItemIntoGUI( + par1Minecraft.fontRenderer, + par1Minecraft.renderEngine, + new ItemStack(ModItems.cacophonium), + xPosition, + yPosition); + RenderItem.getInstance() + .renderItemIntoGUI( + par1Minecraft.fontRenderer, + par1Minecraft.renderEngine, + new ItemStack(Items.fireworks), + xPosition + 8, + yPosition + 2); - GL11.glDisable(GL11.GL_LIGHTING); + GL11.glDisable(GL11.GL_LIGHTING); + List tooltip = new ArrayList(); + tooltip.add(EnumChatFormatting.LIGHT_PURPLE + "Happy Birthday Vazkii!"); + tooltip.add(EnumChatFormatting.GRAY + "doot doot"); - List tooltip = new ArrayList(); - tooltip.add(EnumChatFormatting.LIGHT_PURPLE + "Happy Birthday Vazkii!"); - tooltip.add(EnumChatFormatting.GRAY + "doot doot"); - - if(k == 2) - RenderHelper.renderTooltip(xPosition - 100, yPosition + 36, tooltip); - GL11.glEnable(GL11.GL_ALPHA_TEST); - } - + if (k == 2) RenderHelper.renderTooltip(xPosition - 100, yPosition + 36, tooltip); + GL11.glEnable(GL11.GL_ALPHA_TEST); + } } - diff --git a/src/main/java/vazkii/botania/client/gui/lexicon/button/GuiButtonHistory.java b/src/main/java/vazkii/botania/client/gui/lexicon/button/GuiButtonHistory.java index b5f1fd75e1..179cca43fb 100644 --- a/src/main/java/vazkii/botania/client/gui/lexicon/button/GuiButtonHistory.java +++ b/src/main/java/vazkii/botania/client/gui/lexicon/button/GuiButtonHistory.java @@ -2,17 +2,16 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Mar 2, 2015, 6:01:26 PM (GMT)] */ package vazkii.botania.client.gui.lexicon.button; import java.util.ArrayList; import java.util.List; - import net.minecraft.client.Minecraft; import net.minecraft.util.EnumChatFormatting; import net.minecraft.util.StatCollector; @@ -21,26 +20,25 @@ public class GuiButtonHistory extends GuiButtonLexicon { - GuiLexicon gui; - - public GuiButtonHistory(int par1, int par2, int par3, String str, GuiLexicon gui) { - super(par1, par2, par3, gui.bookmarkWidth(str) + 5, 11, str); - this.gui = gui; - } + GuiLexicon gui; - @Override - public void drawButton(Minecraft mc, int par2, int par3) { - gui.drawBookmark(xPosition, yPosition, displayString, false); - field_146123_n = par2 >= xPosition && par3 >= yPosition && par2 < xPosition + width && par3 < yPosition + height; - int k = getHoverState(field_146123_n); + public GuiButtonHistory(int par1, int par2, int par3, String str, GuiLexicon gui) { + super(par1, par2, par3, gui.bookmarkWidth(str) + 5, 11, str); + this.gui = gui; + } - List tooltip = new ArrayList(); - tooltip.add(StatCollector.translateToLocal("botaniamisc.historyLong")); - tooltip.add(EnumChatFormatting.GRAY + StatCollector.translateToLocal("botaniamisc.historyDesc")); + @Override + public void drawButton(Minecraft mc, int par2, int par3) { + gui.drawBookmark(xPosition, yPosition, displayString, false); + field_146123_n = + par2 >= xPosition && par3 >= yPosition && par2 < xPosition + width && par3 < yPosition + height; + int k = getHoverState(field_146123_n); - int tooltipY = (tooltip.size() + 1) * 5; - if(k == 2) - RenderHelper.renderTooltip(par2, par3 + tooltipY, tooltip); - } + List tooltip = new ArrayList(); + tooltip.add(StatCollector.translateToLocal("botaniamisc.historyLong")); + tooltip.add(EnumChatFormatting.GRAY + StatCollector.translateToLocal("botaniamisc.historyDesc")); + int tooltipY = (tooltip.size() + 1) * 5; + if (k == 2) RenderHelper.renderTooltip(par2, par3 + tooltipY, tooltip); + } } diff --git a/src/main/java/vazkii/botania/client/gui/lexicon/button/GuiButtonInvisible.java b/src/main/java/vazkii/botania/client/gui/lexicon/button/GuiButtonInvisible.java index cbfb7d6097..291f9d4494 100644 --- a/src/main/java/vazkii/botania/client/gui/lexicon/button/GuiButtonInvisible.java +++ b/src/main/java/vazkii/botania/client/gui/lexicon/button/GuiButtonInvisible.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jan 14, 2014, 8:34:01 PM (GMT)] */ package vazkii.botania.client.gui.lexicon.button; @@ -16,10 +16,8 @@ import net.minecraft.item.ItemStack; import net.minecraft.util.EnumChatFormatting; import net.minecraft.util.ResourceLocation; - import org.lwjgl.opengl.GL11; import org.lwjgl.opengl.GL12; - import vazkii.botania.client.core.handler.ClientTickHandler; import vazkii.botania.client.core.handler.PersistentVariableHelper; import vazkii.botania.client.core.helper.FontHelper; @@ -29,91 +27,102 @@ public class GuiButtonInvisible extends GuiButtonLexicon { - private static final ResourceLocation dogResource = new ResourceLocation(LibResources.GUI_DOG); - - GuiLexiconIndex gui; - public ItemStack displayStack = null; - public boolean dog = false; - float timeHover = 0; - - boolean enableDog = false; - double dogPos = 0; - - public GuiButtonInvisible(GuiLexiconIndex gui, int par1, int par2, int par3, int par4, int par5, String par6Str) { - super(par1, par2, par3, par4, par5, par6Str); - this.gui = gui; - } - - public void click() { - enableDog = true; - PersistentVariableHelper.dog = true; - PersistentVariableHelper.saveSafe(); - } - - @Override - public void drawButton(Minecraft par1Minecraft, int par2, int par3) { - if(enableDog) { - dogPos += ClientTickHandler.delta * 10; - - par1Minecraft.renderEngine.bindTexture(dogResource); - float f = 1F / 64F; - GL11.glTranslated(dogPos, 0, 0); - GL11.glColor4f(1F, 1F, 1F, 1F); - vazkii.botania.client.core.helper.RenderHelper.drawTexturedModalRect(0, yPosition, zLevel + 10, (dogPos % 100 < 50) ? 23 : 0, 0, 23, 19, f, f); - xPosition = (int) Math.max(xPosition, dogPos + 10); - - GL11.glTranslated(-dogPos, 0, 0); - } - - field_146123_n = par2 >= xPosition && par3 >= yPosition && par2 < xPosition + width && par3 < yPosition + height; - int k = getHoverState(field_146123_n); - boolean showStack = displayStack != null && !displayString.isEmpty(); - - if(!displayString.isEmpty() && k == 2) { - timeHover = Math.min(5, timeHover + gui.timeDelta); - gui.setHoveredButton(this); - } else timeHover = Math.max(0, timeHover - gui.timeDelta); - - GL11.glPushMatrix(); - GL11.glEnable(GL11.GL_BLEND); - GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); - - GL11.glDisable(GL11.GL_ALPHA_TEST); - int color = 0; - String format = FontHelper.getFormatFromString(displayString); - if(format.length() > 1) { - char key = format.charAt(format.length() - 1); - if(key == 'o' && format.length() > 3) - key = format.charAt(1); - - for(EnumChatFormatting ecf : EnumChatFormatting.class.getEnumConstants()) - if(ecf.getFormattingCode() == key) { - if(ecf.ordinal() > 15) - ecf = EnumChatFormatting.BLACK; - color = LibMisc.CONTROL_CODE_COLORS[ecf.ordinal()]; - break; - } - } - - int maxalpha = 0x22; - int alpha = Math.min(maxalpha, (int) (timeHover / 4 * maxalpha)); - drawRect(xPosition - 5, yPosition, (int) (xPosition - 5 + timeHover * 24), yPosition + height, alpha << 24 | color); - GL11.glEnable(GL11.GL_ALPHA_TEST); - - boolean unicode = par1Minecraft.fontRenderer.getUnicodeFlag(); - par1Minecraft.fontRenderer.setUnicodeFlag(true); - par1Minecraft.fontRenderer.drawString(displayString, xPosition + (showStack ? 7 : 0), yPosition + (height - 8) / 2, 0); - par1Minecraft.fontRenderer.setUnicodeFlag(unicode); - - if(showStack) { - GL11.glScalef(0.5F, 0.5F, 0.5F); - RenderHelper.enableGUIStandardItemLighting(); - GL11.glEnable(GL12.GL_RESCALE_NORMAL); - RenderItem.getInstance().renderItemIntoGUI(par1Minecraft.fontRenderer, par1Minecraft.renderEngine, displayStack, xPosition * 2 - 6, yPosition * 2 + 4); - RenderHelper.disableStandardItemLighting(); - GL11.glEnable(GL11.GL_BLEND); - } - GL11.glPopMatrix(); - } + private static final ResourceLocation dogResource = new ResourceLocation(LibResources.GUI_DOG); + + GuiLexiconIndex gui; + public ItemStack displayStack = null; + public boolean dog = false; + float timeHover = 0; + + boolean enableDog = false; + double dogPos = 0; + + public GuiButtonInvisible(GuiLexiconIndex gui, int par1, int par2, int par3, int par4, int par5, String par6Str) { + super(par1, par2, par3, par4, par5, par6Str); + this.gui = gui; + } + + public void click() { + enableDog = true; + PersistentVariableHelper.dog = true; + PersistentVariableHelper.saveSafe(); + } + + @Override + public void drawButton(Minecraft par1Minecraft, int par2, int par3) { + if (enableDog) { + dogPos += ClientTickHandler.delta * 10; + + par1Minecraft.renderEngine.bindTexture(dogResource); + float f = 1F / 64F; + GL11.glTranslated(dogPos, 0, 0); + GL11.glColor4f(1F, 1F, 1F, 1F); + vazkii.botania.client.core.helper.RenderHelper.drawTexturedModalRect( + 0, yPosition, zLevel + 10, (dogPos % 100 < 50) ? 23 : 0, 0, 23, 19, f, f); + xPosition = (int) Math.max(xPosition, dogPos + 10); + + GL11.glTranslated(-dogPos, 0, 0); + } + + field_146123_n = + par2 >= xPosition && par3 >= yPosition && par2 < xPosition + width && par3 < yPosition + height; + int k = getHoverState(field_146123_n); + boolean showStack = displayStack != null && !displayString.isEmpty(); + + if (!displayString.isEmpty() && k == 2) { + timeHover = Math.min(5, timeHover + gui.timeDelta); + gui.setHoveredButton(this); + } else timeHover = Math.max(0, timeHover - gui.timeDelta); + + GL11.glPushMatrix(); + GL11.glEnable(GL11.GL_BLEND); + GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); + + GL11.glDisable(GL11.GL_ALPHA_TEST); + int color = 0; + String format = FontHelper.getFormatFromString(displayString); + if (format.length() > 1) { + char key = format.charAt(format.length() - 1); + if (key == 'o' && format.length() > 3) key = format.charAt(1); + + for (EnumChatFormatting ecf : EnumChatFormatting.class.getEnumConstants()) + if (ecf.getFormattingCode() == key) { + if (ecf.ordinal() > 15) ecf = EnumChatFormatting.BLACK; + color = LibMisc.CONTROL_CODE_COLORS[ecf.ordinal()]; + break; + } + } + + int maxalpha = 0x22; + int alpha = Math.min(maxalpha, (int) (timeHover / 4 * maxalpha)); + drawRect( + xPosition - 5, + yPosition, + (int) (xPosition - 5 + timeHover * 24), + yPosition + height, + alpha << 24 | color); + GL11.glEnable(GL11.GL_ALPHA_TEST); + + boolean unicode = par1Minecraft.fontRenderer.getUnicodeFlag(); + par1Minecraft.fontRenderer.setUnicodeFlag(true); + par1Minecraft.fontRenderer.drawString( + displayString, xPosition + (showStack ? 7 : 0), yPosition + (height - 8) / 2, 0); + par1Minecraft.fontRenderer.setUnicodeFlag(unicode); + if (showStack) { + GL11.glScalef(0.5F, 0.5F, 0.5F); + RenderHelper.enableGUIStandardItemLighting(); + GL11.glEnable(GL12.GL_RESCALE_NORMAL); + RenderItem.getInstance() + .renderItemIntoGUI( + par1Minecraft.fontRenderer, + par1Minecraft.renderEngine, + displayStack, + xPosition * 2 - 6, + yPosition * 2 + 4); + RenderHelper.disableStandardItemLighting(); + GL11.glEnable(GL11.GL_BLEND); + } + GL11.glPopMatrix(); + } } diff --git a/src/main/java/vazkii/botania/client/gui/lexicon/button/GuiButtonLexicon.java b/src/main/java/vazkii/botania/client/gui/lexicon/button/GuiButtonLexicon.java index b352679b95..52f6b669ba 100644 --- a/src/main/java/vazkii/botania/client/gui/lexicon/button/GuiButtonLexicon.java +++ b/src/main/java/vazkii/botania/client/gui/lexicon/button/GuiButtonLexicon.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Aug 7, 2014, 5:53:16 PM (GMT)] */ package vazkii.botania.client.gui.lexicon.button; @@ -17,13 +17,13 @@ public class GuiButtonLexicon extends GuiButton { - public GuiButtonLexicon(int p_i1021_1_, int p_i1021_2_, int p_i1021_3_, int p_i1021_4_, int p_i1021_5_, String p_i1021_6_) { - super(p_i1021_1_, p_i1021_2_, p_i1021_3_, p_i1021_4_, p_i1021_5_, p_i1021_6_); - } - - @Override - public void func_146113_a(SoundHandler p_146113_1_) { - p_146113_1_.playSound(PositionedSoundRecord.func_147674_a(new ResourceLocation("botania:lexiconPage"), 1.0F)); - } + public GuiButtonLexicon( + int p_i1021_1_, int p_i1021_2_, int p_i1021_3_, int p_i1021_4_, int p_i1021_5_, String p_i1021_6_) { + super(p_i1021_1_, p_i1021_2_, p_i1021_3_, p_i1021_4_, p_i1021_5_, p_i1021_6_); + } + @Override + public void func_146113_a(SoundHandler p_146113_1_) { + p_146113_1_.playSound(PositionedSoundRecord.func_147674_a(new ResourceLocation("botania:lexiconPage"), 1.0F)); + } } diff --git a/src/main/java/vazkii/botania/client/gui/lexicon/button/GuiButtonNotes.java b/src/main/java/vazkii/botania/client/gui/lexicon/button/GuiButtonNotes.java index 28729ab7d6..6d38cc9f44 100644 --- a/src/main/java/vazkii/botania/client/gui/lexicon/button/GuiButtonNotes.java +++ b/src/main/java/vazkii/botania/client/gui/lexicon/button/GuiButtonNotes.java @@ -2,56 +2,52 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jul 24, 2015, 2:49:36 AM (GMT)] */ package vazkii.botania.client.gui.lexicon.button; import java.util.ArrayList; import java.util.List; - import net.minecraft.client.Minecraft; import net.minecraft.util.EnumChatFormatting; import net.minecraft.util.StatCollector; - import org.lwjgl.opengl.GL11; - import vazkii.botania.client.core.helper.RenderHelper; import vazkii.botania.client.gui.lexicon.GuiLexicon; public class GuiButtonNotes extends GuiButtonLexicon { - GuiLexicon parent; - - public GuiButtonNotes(GuiLexicon parent, int id, int x, int y) { - super(id, x, y, 11, 11, ""); - this.parent = parent; - } - - @Override - public void drawButton(Minecraft par1Minecraft, int par2, int par3) { - field_146123_n = par2 >= xPosition && par3 >= yPosition && par2 < xPosition + width && par3 < yPosition + height; - int k = getHoverState(field_146123_n); - - par1Minecraft.renderEngine.bindTexture(GuiLexicon.texture); - GL11.glColor4f(1F, 1F, 1F, 1F); - drawTexturedModalRect(xPosition, yPosition, k == 2 ? 130 : 120, 191, 10, 11); - - List tooltip = new ArrayList(); - if(GuiLexicon.notesEnabled) - tooltip.add(EnumChatFormatting.GREEN + StatCollector.translateToLocal("botaniamisc.hideNotes")); - else { - tooltip.add(EnumChatFormatting.GREEN + StatCollector.translateToLocal("botaniamisc.showNotes")); - if(parent.note != null && !parent.note.isEmpty()) - Minecraft.getMinecraft().fontRenderer.drawStringWithShadow("!", xPosition + 10, yPosition, 0xFF0000); - } - - int tooltipY = (tooltip.size() - 1) * 10; - if(k == 2) - RenderHelper.renderTooltip(par2, par3 + tooltipY, tooltip); - } - + GuiLexicon parent; + + public GuiButtonNotes(GuiLexicon parent, int id, int x, int y) { + super(id, x, y, 11, 11, ""); + this.parent = parent; + } + + @Override + public void drawButton(Minecraft par1Minecraft, int par2, int par3) { + field_146123_n = + par2 >= xPosition && par3 >= yPosition && par2 < xPosition + width && par3 < yPosition + height; + int k = getHoverState(field_146123_n); + + par1Minecraft.renderEngine.bindTexture(GuiLexicon.texture); + GL11.glColor4f(1F, 1F, 1F, 1F); + drawTexturedModalRect(xPosition, yPosition, k == 2 ? 130 : 120, 191, 10, 11); + + List tooltip = new ArrayList(); + if (GuiLexicon.notesEnabled) + tooltip.add(EnumChatFormatting.GREEN + StatCollector.translateToLocal("botaniamisc.hideNotes")); + else { + tooltip.add(EnumChatFormatting.GREEN + StatCollector.translateToLocal("botaniamisc.showNotes")); + if (parent.note != null && !parent.note.isEmpty()) + Minecraft.getMinecraft().fontRenderer.drawStringWithShadow("!", xPosition + 10, yPosition, 0xFF0000); + } + + int tooltipY = (tooltip.size() - 1) * 10; + if (k == 2) RenderHelper.renderTooltip(par2, par3 + tooltipY, tooltip); + } } diff --git a/src/main/java/vazkii/botania/client/gui/lexicon/button/GuiButtonOptions.java b/src/main/java/vazkii/botania/client/gui/lexicon/button/GuiButtonOptions.java index 013f9bceb2..e5eb5d953d 100644 --- a/src/main/java/vazkii/botania/client/gui/lexicon/button/GuiButtonOptions.java +++ b/src/main/java/vazkii/botania/client/gui/lexicon/button/GuiButtonOptions.java @@ -2,48 +2,45 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Mar 6, 2015, 1:14:05 PM (GMT)] */ package vazkii.botania.client.gui.lexicon.button; import java.util.ArrayList; import java.util.List; - import net.minecraft.client.Minecraft; import net.minecraft.util.EnumChatFormatting; import net.minecraft.util.StatCollector; - import org.lwjgl.opengl.GL11; - import vazkii.botania.client.core.helper.RenderHelper; import vazkii.botania.client.gui.lexicon.GuiLexicon; public class GuiButtonOptions extends GuiButtonLexicon { - public GuiButtonOptions(int id, int x, int y) { - super(id, x, y, 11, 11, ""); - } - - @Override - public void drawButton(Minecraft par1Minecraft, int par2, int par3) { - field_146123_n = par2 >= xPosition && par3 >= yPosition && par2 < xPosition + width && par3 < yPosition + height; - int k = getHoverState(field_146123_n); + public GuiButtonOptions(int id, int x, int y) { + super(id, x, y, 11, 11, ""); + } - par1Minecraft.renderEngine.bindTexture(GuiLexicon.texture); - GL11.glColor4f(1F, 1F, 1F, 1F); - drawTexturedModalRect(xPosition, yPosition, k == 2 ? 109 : 98, 180, 11, 11); + @Override + public void drawButton(Minecraft par1Minecraft, int par2, int par3) { + field_146123_n = + par2 >= xPosition && par3 >= yPosition && par2 < xPosition + width && par3 < yPosition + height; + int k = getHoverState(field_146123_n); - List tooltip = new ArrayList(); - for(int i = 0; i < 3; i++) - tooltip.add((i == 0 ? EnumChatFormatting.RED : EnumChatFormatting.GRAY) + StatCollector.translateToLocal("botaniamisc.lexiconOptions" + i)); + par1Minecraft.renderEngine.bindTexture(GuiLexicon.texture); + GL11.glColor4f(1F, 1F, 1F, 1F); + drawTexturedModalRect(xPosition, yPosition, k == 2 ? 109 : 98, 180, 11, 11); - int tooltipY = (tooltip.size() - 1) * 10; - if(k == 2) - RenderHelper.renderTooltip(par2, par3 + tooltipY, tooltip); - } + List tooltip = new ArrayList(); + for (int i = 0; i < 3; i++) + tooltip.add((i == 0 ? EnumChatFormatting.RED : EnumChatFormatting.GRAY) + + StatCollector.translateToLocal("botaniamisc.lexiconOptions" + i)); + int tooltipY = (tooltip.size() - 1) * 10; + if (k == 2) RenderHelper.renderTooltip(par2, par3 + tooltipY, tooltip); + } } diff --git a/src/main/java/vazkii/botania/client/gui/lexicon/button/GuiButtonPage.java b/src/main/java/vazkii/botania/client/gui/lexicon/button/GuiButtonPage.java index fdd0bc7e8b..a04173e7b8 100644 --- a/src/main/java/vazkii/botania/client/gui/lexicon/button/GuiButtonPage.java +++ b/src/main/java/vazkii/botania/client/gui/lexicon/button/GuiButtonPage.java @@ -2,46 +2,47 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jan 16, 2014, 4:52:06 PM (GMT)] */ package vazkii.botania.client.gui.lexicon.button; import java.util.Arrays; - import net.minecraft.client.Minecraft; import net.minecraft.util.StatCollector; - import org.lwjgl.opengl.GL11; - import vazkii.botania.client.core.helper.RenderHelper; import vazkii.botania.client.gui.lexicon.GuiLexicon; public class GuiButtonPage extends GuiButtonLexicon { - boolean right; - - public GuiButtonPage(int par1, int par2, int par3, boolean right) { - super(par1, par2, par3, 18, 10, ""); - this.right = right; - } - - @Override - public void drawButton(Minecraft par1Minecraft, int par2, int par3) { - if(enabled) { - field_146123_n = par2 >= xPosition && par3 >= yPosition && par2 < xPosition + width && par3 < yPosition + height; - int k = getHoverState(field_146123_n); - - par1Minecraft.renderEngine.bindTexture(GuiLexicon.texture); - GL11.glColor4f(1F, 1F, 1F, 1F); - drawTexturedModalRect(xPosition, yPosition, k == 2 ? 18 : 0, right ? 180 : 190, 18, 10); - - if(k == 2) - RenderHelper.renderTooltip(par2, par3, Arrays.asList(StatCollector.translateToLocal(right ? "botaniamisc.nextPage" : "botaniamisc.prevPage"))); - } - } - + boolean right; + + public GuiButtonPage(int par1, int par2, int par3, boolean right) { + super(par1, par2, par3, 18, 10, ""); + this.right = right; + } + + @Override + public void drawButton(Minecraft par1Minecraft, int par2, int par3) { + if (enabled) { + field_146123_n = + par2 >= xPosition && par3 >= yPosition && par2 < xPosition + width && par3 < yPosition + height; + int k = getHoverState(field_146123_n); + + par1Minecraft.renderEngine.bindTexture(GuiLexicon.texture); + GL11.glColor4f(1F, 1F, 1F, 1F); + drawTexturedModalRect(xPosition, yPosition, k == 2 ? 18 : 0, right ? 180 : 190, 18, 10); + + if (k == 2) + RenderHelper.renderTooltip( + par2, + par3, + Arrays.asList(StatCollector.translateToLocal( + right ? "botaniamisc.nextPage" : "botaniamisc.prevPage"))); + } + } } diff --git a/src/main/java/vazkii/botania/client/gui/lexicon/button/GuiButtonShare.java b/src/main/java/vazkii/botania/client/gui/lexicon/button/GuiButtonShare.java index 339cc48dd7..d2cf5a83bf 100644 --- a/src/main/java/vazkii/botania/client/gui/lexicon/button/GuiButtonShare.java +++ b/src/main/java/vazkii/botania/client/gui/lexicon/button/GuiButtonShare.java @@ -2,48 +2,45 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Sep 24, 2014, 3:49:21 PM (GMT)] */ package vazkii.botania.client.gui.lexicon.button; import java.util.Arrays; import java.util.List; - import net.minecraft.client.Minecraft; import net.minecraft.util.EnumChatFormatting; import net.minecraft.util.StatCollector; - import org.lwjgl.opengl.GL11; - import vazkii.botania.client.core.helper.RenderHelper; import vazkii.botania.client.gui.lexicon.GuiLexicon; public class GuiButtonShare extends GuiButtonLexicon { - public GuiButtonShare(int par1, int par2, int par3) { - super(par1, par2, par3, 10, 12, ""); - } + public GuiButtonShare(int par1, int par2, int par3) { + super(par1, par2, par3, 10, 12, ""); + } - @Override - public void drawButton(Minecraft par1Minecraft, int par2, int par3) { - field_146123_n = par2 >= xPosition && par3 >= yPosition && par2 < xPosition + width && par3 < yPosition + height; - int k = getHoverState(field_146123_n); + @Override + public void drawButton(Minecraft par1Minecraft, int par2, int par3) { + field_146123_n = + par2 >= xPosition && par3 >= yPosition && par2 < xPosition + width && par3 < yPosition + height; + int k = getHoverState(field_146123_n); - par1Minecraft.renderEngine.bindTexture(GuiLexicon.texture); - GL11.glColor4f(1F, 1F, 1F, 1F); - drawTexturedModalRect(xPosition, yPosition, k == 2 ? 10 : 0 , 200, 10, 12); + par1Minecraft.renderEngine.bindTexture(GuiLexicon.texture); + GL11.glColor4f(1F, 1F, 1F, 1F); + drawTexturedModalRect(xPosition, yPosition, k == 2 ? 10 : 0, 200, 10, 12); - List tooltip = getTooltip(); - int tooltipY = (tooltip.size() - 1) * 10; - if(k == 2) - RenderHelper.renderTooltip(par2, par3 + tooltipY, tooltip); - } + List tooltip = getTooltip(); + int tooltipY = (tooltip.size() - 1) * 10; + if (k == 2) RenderHelper.renderTooltip(par2, par3 + tooltipY, tooltip); + } - public List getTooltip() { - return Arrays.asList(EnumChatFormatting.AQUA + StatCollector.translateToLocal("botaniamisc.clickToShare")); - } + public List getTooltip() { + return Arrays.asList(EnumChatFormatting.AQUA + StatCollector.translateToLocal("botaniamisc.clickToShare")); + } } diff --git a/src/main/java/vazkii/botania/client/gui/lexicon/button/GuiButtonUpdateWarning.java b/src/main/java/vazkii/botania/client/gui/lexicon/button/GuiButtonUpdateWarning.java index 7f50bc6720..6c32835ff7 100644 --- a/src/main/java/vazkii/botania/client/gui/lexicon/button/GuiButtonUpdateWarning.java +++ b/src/main/java/vazkii/botania/client/gui/lexicon/button/GuiButtonUpdateWarning.java @@ -2,23 +2,20 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Aug 25, 2015, 6:13:11 PM (GMT)] */ package vazkii.botania.client.gui.lexicon.button; import java.util.ArrayList; import java.util.List; - import net.minecraft.client.Minecraft; import net.minecraft.util.EnumChatFormatting; import net.minecraft.util.StatCollector; - import org.lwjgl.opengl.GL11; - import vazkii.botania.client.core.handler.ClientTickHandler; import vazkii.botania.client.core.handler.PersistentVariableHelper; import vazkii.botania.client.core.helper.RenderHelper; @@ -26,35 +23,34 @@ public class GuiButtonUpdateWarning extends GuiButtonLexicon { - public GuiButtonUpdateWarning(int id, int x, int y) { - super(id, x, y, 11, 11, ""); - } - - @Override - public void drawButton(Minecraft par1Minecraft, int par2, int par3) { - if(!visible || !enabled) - return; + public GuiButtonUpdateWarning(int id, int x, int y) { + super(id, x, y, 11, 11, ""); + } - field_146123_n = par2 >= xPosition && par3 >= yPosition && par2 < xPosition + width && par3 < yPosition + height; - int k = getHoverState(field_146123_n); + @Override + public void drawButton(Minecraft par1Minecraft, int par2, int par3) { + if (!visible || !enabled) return; - boolean red = k == 2 || ClientTickHandler.ticksInGame % 10 < 5; + field_146123_n = + par2 >= xPosition && par3 >= yPosition && par2 < xPosition + width && par3 < yPosition + height; + int k = getHoverState(field_146123_n); - par1Minecraft.renderEngine.bindTexture(GuiLexicon.texture); - GL11.glColor4f(1F, 1F, 1F, 1F); - drawTexturedModalRect(xPosition, yPosition, red ? 153 : 142, 180, 11, 11); + boolean red = k == 2 || ClientTickHandler.ticksInGame % 10 < 5; - List tooltip = new ArrayList(); - String version = PersistentVariableHelper.lastBotaniaVersion; - for(int i = 0; i < 6; i++) { - tooltip.add(EnumChatFormatting.GRAY + String.format(StatCollector.translateToLocal("botaniamisc.changes" + i), version).replaceAll("&", "\u00a7")); - if(i == 3) - tooltip.add(""); - } + par1Minecraft.renderEngine.bindTexture(GuiLexicon.texture); + GL11.glColor4f(1F, 1F, 1F, 1F); + drawTexturedModalRect(xPosition, yPosition, red ? 153 : 142, 180, 11, 11); - int tooltipY = (tooltip.size() - 1) * 10 - 25; - if(k == 2) - RenderHelper.renderTooltip(par2 - 125, par3 + tooltipY, tooltip); - } + List tooltip = new ArrayList(); + String version = PersistentVariableHelper.lastBotaniaVersion; + for (int i = 0; i < 6; i++) { + tooltip.add(EnumChatFormatting.GRAY + + String.format(StatCollector.translateToLocal("botaniamisc.changes" + i), version) + .replaceAll("&", "\u00a7")); + if (i == 3) tooltip.add(""); + } + int tooltipY = (tooltip.size() - 1) * 10 - 25; + if (k == 2) RenderHelper.renderTooltip(par2 - 125, par3 + tooltipY, tooltip); + } } diff --git a/src/main/java/vazkii/botania/client/gui/lexicon/button/GuiButtonViewOnline.java b/src/main/java/vazkii/botania/client/gui/lexicon/button/GuiButtonViewOnline.java index 3cfb30b454..45d84dbe40 100644 --- a/src/main/java/vazkii/botania/client/gui/lexicon/button/GuiButtonViewOnline.java +++ b/src/main/java/vazkii/botania/client/gui/lexicon/button/GuiButtonViewOnline.java @@ -2,45 +2,42 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Mar 2, 2015, 5:34:05 PM (GMT)] */ package vazkii.botania.client.gui.lexicon.button; import java.util.Arrays; import java.util.List; - import net.minecraft.client.Minecraft; import net.minecraft.util.EnumChatFormatting; import net.minecraft.util.StatCollector; - import org.lwjgl.opengl.GL11; - import vazkii.botania.client.core.helper.RenderHelper; import vazkii.botania.client.gui.lexicon.GuiLexicon; public class GuiButtonViewOnline extends GuiButtonLexicon { - public GuiButtonViewOnline(int id, int x, int y) { - super(id, x, y, 11, 11, ""); - } - - @Override - public void drawButton(Minecraft par1Minecraft, int par2, int par3) { - field_146123_n = par2 >= xPosition && par3 >= yPosition && par2 < xPosition + width && par3 < yPosition + height; - int k = getHoverState(field_146123_n); - - par1Minecraft.renderEngine.bindTexture(GuiLexicon.texture); - GL11.glColor4f(1F, 1F, 1F, 1F); - drawTexturedModalRect(xPosition, yPosition, k == 2 ? 41 : 30, 200, 11, 11); - - List tooltip = Arrays.asList(EnumChatFormatting.AQUA + StatCollector.translateToLocal("botaniamisc.viewOnline")); - int tooltipY = (tooltip.size() - 1) * 10; - if(k == 2) - RenderHelper.renderTooltip(par2, par3 + tooltipY, tooltip); - } - + public GuiButtonViewOnline(int id, int x, int y) { + super(id, x, y, 11, 11, ""); + } + + @Override + public void drawButton(Minecraft par1Minecraft, int par2, int par3) { + field_146123_n = + par2 >= xPosition && par3 >= yPosition && par2 < xPosition + width && par3 < yPosition + height; + int k = getHoverState(field_146123_n); + + par1Minecraft.renderEngine.bindTexture(GuiLexicon.texture); + GL11.glColor4f(1F, 1F, 1F, 1F); + drawTexturedModalRect(xPosition, yPosition, k == 2 ? 41 : 30, 200, 11, 11); + + List tooltip = + Arrays.asList(EnumChatFormatting.AQUA + StatCollector.translateToLocal("botaniamisc.viewOnline")); + int tooltipY = (tooltip.size() - 1) * 10; + if (k == 2) RenderHelper.renderTooltip(par2, par3 + tooltipY, tooltip); + } } diff --git a/src/main/java/vazkii/botania/client/integration/nei/NEIBotaniaConfig.java b/src/main/java/vazkii/botania/client/integration/nei/NEIBotaniaConfig.java index 277bd5806b..4d3f534b53 100644 --- a/src/main/java/vazkii/botania/client/integration/nei/NEIBotaniaConfig.java +++ b/src/main/java/vazkii/botania/client/integration/nei/NEIBotaniaConfig.java @@ -1,7 +1,9 @@ package vazkii.botania.client.integration.nei; +import codechicken.nei.api.API; +import codechicken.nei.api.IConfigureNEI; +import codechicken.nei.guihook.GuiContainerManager; import org.lwjgl.input.Keyboard; - import vazkii.botania.client.integration.nei.recipe.RecipeHandlerBrewery; import vazkii.botania.client.integration.nei.recipe.RecipeHandlerElvenTrade; import vazkii.botania.client.integration.nei.recipe.RecipeHandlerFloatingFlowers; @@ -11,52 +13,48 @@ import vazkii.botania.client.integration.nei.recipe.RecipeHandlerPureDaisy; import vazkii.botania.client.integration.nei.recipe.RecipeHandlerRunicAltar; import vazkii.botania.common.lib.LibMisc; -import codechicken.nei.api.API; -import codechicken.nei.api.IConfigureNEI; -import codechicken.nei.guihook.GuiContainerManager; public class NEIBotaniaConfig implements IConfigureNEI { - public static final String CORPOREA_KEY = "gui.botania_corporea_request"; - - @Override - public String getName() { - return LibMisc.MOD_NAME; - } + public static final String CORPOREA_KEY = "gui.botania_corporea_request"; + + @Override + public String getName() { + return LibMisc.MOD_NAME; + } + + @Override + public String getVersion() { + return LibMisc.VERSION; + } - @Override - public String getVersion() { - return LibMisc.VERSION; - } + @Override + public void loadConfig() { + API.registerRecipeHandler(new RecipeHandlerFloatingFlowers()); + API.registerUsageHandler(new RecipeHandlerFloatingFlowers()); - @Override - public void loadConfig() { - API.registerRecipeHandler(new RecipeHandlerFloatingFlowers()); - API.registerUsageHandler(new RecipeHandlerFloatingFlowers()); + API.registerRecipeHandler(new RecipeHandlerPetalApothecary()); + API.registerUsageHandler(new RecipeHandlerPetalApothecary()); - API.registerRecipeHandler(new RecipeHandlerPetalApothecary()); - API.registerUsageHandler(new RecipeHandlerPetalApothecary()); + API.registerRecipeHandler(new RecipeHandlerRunicAltar()); + API.registerUsageHandler(new RecipeHandlerRunicAltar()); - API.registerRecipeHandler(new RecipeHandlerRunicAltar()); - API.registerUsageHandler(new RecipeHandlerRunicAltar()); + API.registerRecipeHandler(new RecipeHandlerManaPool()); + API.registerUsageHandler(new RecipeHandlerManaPool()); - API.registerRecipeHandler(new RecipeHandlerManaPool()); - API.registerUsageHandler(new RecipeHandlerManaPool()); + API.registerRecipeHandler(new RecipeHandlerElvenTrade()); + API.registerUsageHandler(new RecipeHandlerElvenTrade()); - API.registerRecipeHandler(new RecipeHandlerElvenTrade()); - API.registerUsageHandler(new RecipeHandlerElvenTrade()); + API.registerRecipeHandler(new RecipeHandlerBrewery()); + API.registerUsageHandler(new RecipeHandlerBrewery()); - API.registerRecipeHandler(new RecipeHandlerBrewery()); - API.registerUsageHandler(new RecipeHandlerBrewery()); + API.registerRecipeHandler(new RecipeHandlerPureDaisy()); + API.registerUsageHandler(new RecipeHandlerPureDaisy()); - API.registerRecipeHandler(new RecipeHandlerPureDaisy()); - API.registerUsageHandler(new RecipeHandlerPureDaisy()); - - API.registerRecipeHandler(new RecipeHandlerLexicaBotania()); - API.registerUsageHandler(new RecipeHandlerLexicaBotania()); - - API.addKeyBind(CORPOREA_KEY, Keyboard.KEY_C); - GuiContainerManager.addInputHandler(new NEIInputHandler()); - } + API.registerRecipeHandler(new RecipeHandlerLexicaBotania()); + API.registerUsageHandler(new RecipeHandlerLexicaBotania()); + API.addKeyBind(CORPOREA_KEY, Keyboard.KEY_C); + GuiContainerManager.addInputHandler(new NEIInputHandler()); + } } diff --git a/src/main/java/vazkii/botania/client/integration/nei/NEIGuiHooks.java b/src/main/java/vazkii/botania/client/integration/nei/NEIGuiHooks.java index 37953eeaf2..ae5719a45b 100644 --- a/src/main/java/vazkii/botania/client/integration/nei/NEIGuiHooks.java +++ b/src/main/java/vazkii/botania/client/integration/nei/NEIGuiHooks.java @@ -2,23 +2,22 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Dec 15, 2014, 6:09:38 PM (GMT)] */ package vazkii.botania.client.integration.nei; -import vazkii.botania.client.gui.crafting.GuiCraftingHalo; import codechicken.nei.api.API; import codechicken.nei.recipe.DefaultOverlayHandler; +import vazkii.botania.client.gui.crafting.GuiCraftingHalo; public class NEIGuiHooks { - public static void init() { - API.registerGuiOverlay(GuiCraftingHalo.class, "crafting"); - API.registerGuiOverlayHandler(GuiCraftingHalo.class, new DefaultOverlayHandler(), "crafting"); - } - + public static void init() { + API.registerGuiOverlay(GuiCraftingHalo.class, "crafting"); + API.registerGuiOverlayHandler(GuiCraftingHalo.class, new DefaultOverlayHandler(), "crafting"); + } } diff --git a/src/main/java/vazkii/botania/client/integration/nei/NEIInputHandler.java b/src/main/java/vazkii/botania/client/integration/nei/NEIInputHandler.java index e1ea061889..1e6949b97c 100644 --- a/src/main/java/vazkii/botania/client/integration/nei/NEIInputHandler.java +++ b/src/main/java/vazkii/botania/client/integration/nei/NEIInputHandler.java @@ -2,102 +2,95 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [25/12/2015, 02:22:32 (GMT)] */ package vazkii.botania.client.integration.nei; -import vazkii.botania.api.corporea.CorporeaHelper; -import vazkii.botania.common.block.tile.corporea.TileCorporeaIndex; -import net.minecraft.client.Minecraft; -import net.minecraft.client.gui.GuiScreen; -import net.minecraft.client.gui.inventory.GuiContainer; -import net.minecraft.item.ItemStack; -import net.minecraft.util.MathHelper; import codechicken.nei.LayoutManager; import codechicken.nei.NEIClientConfig; import codechicken.nei.guihook.GuiContainerManager; import codechicken.nei.guihook.IContainerInputHandler; +import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.inventory.GuiContainer; +import net.minecraft.item.ItemStack; +import vazkii.botania.api.corporea.CorporeaHelper; +import vazkii.botania.common.block.tile.corporea.TileCorporeaIndex; public class NEIInputHandler implements IContainerInputHandler { - @Override - public boolean keyTyped(GuiContainer gui, char c, int i) { - Minecraft mc = Minecraft.getMinecraft(); - if(TileCorporeaIndex.InputHandler.getNearbyIndexes(mc.thePlayer).isEmpty()) - return false; - - int bind = NEIClientConfig.getKeyBinding(NEIBotaniaConfig.CORPOREA_KEY); - - if(i == bind) { - LayoutManager layoutManager = LayoutManager.instance(); - if(layoutManager != null && LayoutManager.itemPanel != null && !NEIClientConfig.isHidden()) { - ItemStack stack = GuiContainerManager.getStackMouseOver(gui); - if(stack != null && stack.getItem() != null) { - int count = 1; - int max = stack.getMaxStackSize(); - if(gui.isShiftKeyDown()) { - count = max; - if(gui.isCtrlKeyDown()) - count /= 4; - } else if(gui.isCtrlKeyDown()) - count = max / 2; - - if(count > 0) { - String name = CorporeaHelper.stripControlCodes(stack.getDisplayName()); - String full = count + " " + name; - - mc.ingameGUI.getChatGUI().addToSentMessages(full); - mc.thePlayer.sendChatMessage(full); - return true; - } - } - } - } - - return false; - } - - @Override - public boolean lastKeyTyped(GuiContainer arg0, char arg1, int arg2) { - return false; - } - - @Override - public boolean mouseClicked(GuiContainer arg0, int arg1, int arg2, int arg3) { - return false; - } - - @Override - public boolean mouseScrolled(GuiContainer arg0, int arg1, int arg2, int arg3) { - return false; - } - - @Override - public void onKeyTyped(GuiContainer arg0, char arg1, int arg2) { - // NO-OP - } - - @Override - public void onMouseClicked(GuiContainer arg0, int arg1, int arg2, int arg3) { - } - - @Override - public void onMouseDragged(GuiContainer arg0, int arg1, int arg2, int arg3, long arg4) { - // NO-OP - } - - @Override - public void onMouseScrolled(GuiContainer arg0, int arg1, int arg2, int arg3) { - // NO-OP - } - - @Override - public void onMouseUp(GuiContainer arg0, int arg1, int arg2, int arg3) { - // NO-OP - } + @Override + public boolean keyTyped(GuiContainer gui, char c, int i) { + Minecraft mc = Minecraft.getMinecraft(); + if (TileCorporeaIndex.InputHandler.getNearbyIndexes(mc.thePlayer).isEmpty()) return false; + + int bind = NEIClientConfig.getKeyBinding(NEIBotaniaConfig.CORPOREA_KEY); + + if (i == bind) { + LayoutManager layoutManager = LayoutManager.instance(); + if (layoutManager != null && LayoutManager.itemPanel != null && !NEIClientConfig.isHidden()) { + ItemStack stack = GuiContainerManager.getStackMouseOver(gui); + if (stack != null && stack.getItem() != null) { + int count = 1; + int max = stack.getMaxStackSize(); + if (gui.isShiftKeyDown()) { + count = max; + if (gui.isCtrlKeyDown()) count /= 4; + } else if (gui.isCtrlKeyDown()) count = max / 2; + + if (count > 0) { + String name = CorporeaHelper.stripControlCodes(stack.getDisplayName()); + String full = count + " " + name; + + mc.ingameGUI.getChatGUI().addToSentMessages(full); + mc.thePlayer.sendChatMessage(full); + return true; + } + } + } + } + + return false; + } + + @Override + public boolean lastKeyTyped(GuiContainer arg0, char arg1, int arg2) { + return false; + } + + @Override + public boolean mouseClicked(GuiContainer arg0, int arg1, int arg2, int arg3) { + return false; + } + + @Override + public boolean mouseScrolled(GuiContainer arg0, int arg1, int arg2, int arg3) { + return false; + } + + @Override + public void onKeyTyped(GuiContainer arg0, char arg1, int arg2) { + // NO-OP + } + + @Override + public void onMouseClicked(GuiContainer arg0, int arg1, int arg2, int arg3) {} + + @Override + public void onMouseDragged(GuiContainer arg0, int arg1, int arg2, int arg3, long arg4) { + // NO-OP + } + + @Override + public void onMouseScrolled(GuiContainer arg0, int arg1, int arg2, int arg3) { + // NO-OP + } + @Override + public void onMouseUp(GuiContainer arg0, int arg1, int arg2, int arg3) { + // NO-OP + } } diff --git a/src/main/java/vazkii/botania/client/integration/nei/recipe/RecipeHandlerBrewery.java b/src/main/java/vazkii/botania/client/integration/nei/recipe/RecipeHandlerBrewery.java index 0f4a091e9f..e98eeca134 100644 --- a/src/main/java/vazkii/botania/client/integration/nei/recipe/RecipeHandlerBrewery.java +++ b/src/main/java/vazkii/botania/client/integration/nei/recipe/RecipeHandlerBrewery.java @@ -1,15 +1,15 @@ package vazkii.botania.client.integration.nei.recipe; +import codechicken.lib.gui.GuiDraw; +import codechicken.nei.PositionedStack; +import codechicken.nei.recipe.TemplateRecipeHandler; import java.awt.Rectangle; import java.util.ArrayList; import java.util.List; - import net.minecraft.item.ItemStack; import net.minecraft.util.StatCollector; import net.minecraftforge.oredict.OreDictionary; - import org.lwjgl.opengl.GL11; - import vazkii.botania.api.BotaniaAPI; import vazkii.botania.api.brew.IBrewContainer; import vazkii.botania.api.brew.IBrewItem; @@ -17,124 +17,110 @@ import vazkii.botania.client.lib.LibResources; import vazkii.botania.common.core.helper.ItemNBTHelper; import vazkii.botania.common.item.ModItems; -import codechicken.lib.gui.GuiDraw; -import codechicken.nei.PositionedStack; -import codechicken.nei.recipe.TemplateRecipeHandler; public class RecipeHandlerBrewery extends TemplateRecipeHandler { - public class CachedBreweryRecipe extends CachedRecipe { - - public List inputs = new ArrayList(); - public PositionedStack output; - public int mana; - - public CachedBreweryRecipe(RecipeBrew recipe, ItemStack vial) { - if(recipe == null) - return; - - setIngredients(recipe.getInputs()); - ItemStack toVial; - if (vial == null) - toVial = new ItemStack(ModItems.vial); - else - toVial = vial.copy(); - toVial.stackSize = 1; - inputs.add(new PositionedStack(toVial, 39, 42)); - - output = new PositionedStack(recipe.getOutput(toVial), 87, 42); - } - - public CachedBreweryRecipe(RecipeBrew recipe) { - this(recipe, null); - } - - public void setIngredients(List inputs) { - int left = 96 - inputs.size() * 18 / 2; - - int i = 0; - for (Object o : inputs) { - if (o instanceof String) - this.inputs.add(new PositionedStack(OreDictionary.getOres((String) o), left + i * 18, 6)); - else - this.inputs.add(new PositionedStack(o, left + i * 18, 6)); - - i++; - } - } - - @Override - public List getIngredients() { - return getCycledIngredients(cycleticks / 20, inputs); - } - - @Override - public PositionedStack getResult() { - return output; - } - - } - - @Override - public String getRecipeName() { - return StatCollector.translateToLocal("botania.nei.brewery"); - } - - @Override - public String getGuiTexture() { - return LibResources.GUI_NEI_BREWERY; - } - - @Override - public void loadTransferRects() { - transferRects.add(new RecipeTransferRect(new Rectangle(87, 25, 15, 14), "botania.brewery")); - } - - @Override - public void drawBackground(int recipe) { - GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); - GuiDraw.changeTexture(getGuiTexture()); - GuiDraw.drawTexturedModalRect(0, 0, 0, 0, 166, 65); - } - - @Override - public void loadCraftingRecipes(String outputId, Object... results) { - if(outputId.equals("botania.brewery")) - for(RecipeBrew recipe : BotaniaAPI.brewRecipes) - arecipes.add(new CachedBreweryRecipe(recipe)); - else super.loadCraftingRecipes(outputId, results); - } - - @Override - public void loadCraftingRecipes(ItemStack result) { - if(result.getItem() instanceof IBrewItem) - for(RecipeBrew recipe : BotaniaAPI.brewRecipes) { - if(recipe == null) - continue; - - if(((IBrewItem) result.getItem()).getBrew(result) == recipe.getBrew()) - arecipes.add(new CachedBreweryRecipe(recipe)); - } - } - - @Override - public void loadUsageRecipes(ItemStack ingredient) { - if(ingredient.getItem() instanceof IBrewContainer) { - for(RecipeBrew recipe : BotaniaAPI.brewRecipes) { - if(recipe == null) - continue; - - if(recipe.getOutput(ingredient) != null) - arecipes.add(new CachedBreweryRecipe(recipe, ingredient)); - } - } else for(RecipeBrew recipe : BotaniaAPI.brewRecipes) { - if(recipe == null) - continue; - - CachedBreweryRecipe crecipe = new CachedBreweryRecipe(recipe); - if(ItemNBTHelper.cachedRecipeContainsWithNBT(crecipe.inputs, ingredient)) - arecipes.add(crecipe); - } - } - + public class CachedBreweryRecipe extends CachedRecipe { + + public List inputs = new ArrayList(); + public PositionedStack output; + public int mana; + + public CachedBreweryRecipe(RecipeBrew recipe, ItemStack vial) { + if (recipe == null) return; + + setIngredients(recipe.getInputs()); + ItemStack toVial; + if (vial == null) toVial = new ItemStack(ModItems.vial); + else toVial = vial.copy(); + toVial.stackSize = 1; + inputs.add(new PositionedStack(toVial, 39, 42)); + + output = new PositionedStack(recipe.getOutput(toVial), 87, 42); + } + + public CachedBreweryRecipe(RecipeBrew recipe) { + this(recipe, null); + } + + public void setIngredients(List inputs) { + int left = 96 - inputs.size() * 18 / 2; + + int i = 0; + for (Object o : inputs) { + if (o instanceof String) + this.inputs.add(new PositionedStack(OreDictionary.getOres((String) o), left + i * 18, 6)); + else this.inputs.add(new PositionedStack(o, left + i * 18, 6)); + + i++; + } + } + + @Override + public List getIngredients() { + return getCycledIngredients(cycleticks / 20, inputs); + } + + @Override + public PositionedStack getResult() { + return output; + } + } + + @Override + public String getRecipeName() { + return StatCollector.translateToLocal("botania.nei.brewery"); + } + + @Override + public String getGuiTexture() { + return LibResources.GUI_NEI_BREWERY; + } + + @Override + public void loadTransferRects() { + transferRects.add(new RecipeTransferRect(new Rectangle(87, 25, 15, 14), "botania.brewery")); + } + + @Override + public void drawBackground(int recipe) { + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + GuiDraw.changeTexture(getGuiTexture()); + GuiDraw.drawTexturedModalRect(0, 0, 0, 0, 166, 65); + } + + @Override + public void loadCraftingRecipes(String outputId, Object... results) { + if (outputId.equals("botania.brewery")) + for (RecipeBrew recipe : BotaniaAPI.brewRecipes) arecipes.add(new CachedBreweryRecipe(recipe)); + else super.loadCraftingRecipes(outputId, results); + } + + @Override + public void loadCraftingRecipes(ItemStack result) { + if (result.getItem() instanceof IBrewItem) + for (RecipeBrew recipe : BotaniaAPI.brewRecipes) { + if (recipe == null) continue; + + if (((IBrewItem) result.getItem()).getBrew(result) == recipe.getBrew()) + arecipes.add(new CachedBreweryRecipe(recipe)); + } + } + + @Override + public void loadUsageRecipes(ItemStack ingredient) { + if (ingredient.getItem() instanceof IBrewContainer) { + for (RecipeBrew recipe : BotaniaAPI.brewRecipes) { + if (recipe == null) continue; + + if (recipe.getOutput(ingredient) != null) arecipes.add(new CachedBreweryRecipe(recipe, ingredient)); + } + } else + for (RecipeBrew recipe : BotaniaAPI.brewRecipes) { + if (recipe == null) continue; + + CachedBreweryRecipe crecipe = new CachedBreweryRecipe(recipe); + if (ItemNBTHelper.cachedRecipeContainsWithNBT(crecipe.inputs, ingredient)) arecipes.add(crecipe); + } + } } diff --git a/src/main/java/vazkii/botania/client/integration/nei/recipe/RecipeHandlerElvenTrade.java b/src/main/java/vazkii/botania/client/integration/nei/recipe/RecipeHandlerElvenTrade.java index b8835187dc..7e0468d1bb 100644 --- a/src/main/java/vazkii/botania/client/integration/nei/recipe/RecipeHandlerElvenTrade.java +++ b/src/main/java/vazkii/botania/client/integration/nei/recipe/RecipeHandlerElvenTrade.java @@ -1,169 +1,163 @@ package vazkii.botania.client.integration.nei.recipe; +import codechicken.lib.gui.GuiDraw; +import codechicken.nei.NEIServerUtils; +import codechicken.nei.PositionedStack; +import codechicken.nei.recipe.TemplateRecipeHandler; import java.awt.Rectangle; import java.util.ArrayList; import java.util.Arrays; import java.util.List; import java.util.stream.Collectors; - import net.minecraft.client.renderer.entity.RenderItem; import net.minecraft.client.renderer.texture.TextureMap; import net.minecraft.item.ItemStack; import net.minecraft.util.StatCollector; import net.minecraftforge.oredict.OreDictionary; - import org.lwjgl.opengl.GL11; - import vazkii.botania.api.BotaniaAPI; import vazkii.botania.api.recipe.RecipeElvenTrade; import vazkii.botania.client.lib.LibResources; import vazkii.botania.common.block.BlockAlfPortal; -import codechicken.lib.gui.GuiDraw; -import codechicken.nei.NEIServerUtils; -import codechicken.nei.PositionedStack; -import codechicken.nei.recipe.TemplateRecipeHandler; import vazkii.botania.common.core.helper.ItemNBTHelper; public class RecipeHandlerElvenTrade extends TemplateRecipeHandler { - public class CachedElvenTradeRecipe extends CachedRecipe { - - public List inputs = new ArrayList(); - public PositionedStack output; - - public CachedElvenTradeRecipe(RecipeElvenTrade recipe) { - if(recipe == null) - return; - - setIngredients(recipe.getInputs()); - output = new PositionedStack(recipe.getOutput(), 107, 46); - } - - public void setIngredients(List inputs) { - int i = 0; - for(Object o : inputs) { - if(o instanceof String) - this.inputs.add(new PositionedStack(OreDictionary.getOres((String) o), 60 + i * 18, 6)); - else this.inputs.add(new PositionedStack(o, 60 + i * 18, 6)); - - i++; - } - } - - @Override - public List getIngredients() { - return getCycledIngredients(cycleticks / 20, inputs); - } - - @Override - public PositionedStack getResult() { - return output; - } - - } - - @Override - public String getRecipeName() { - return StatCollector.translateToLocal("botania.nei.elvenTrade"); - } - - @Override - public String getGuiTexture() { - return LibResources.GUI_NEI_BLANK; - } - - @Override - public void loadTransferRects() { - transferRects.add(new RecipeTransferRect(new Rectangle(35, 30, 48, 48), "botania.elvenTrade")); - } - - @Override - public int recipiesPerPage() { - return 1; - } - - @Override - public void drawBackground(int recipe) { - super.drawBackground(recipe); - GL11.glEnable(GL11.GL_BLEND); - GL11.glColor4f(1.0F, 1.0F, 1.0F, 0.7F); - GuiDraw.changeTexture(LibResources.GUI_ELVEN_TRADE_OVERLAY); - GuiDraw.drawTexturedModalRect(30, 10, 17, 17, 100, 80); - GL11.glDisable(GL11.GL_BLEND); - GuiDraw.changeTexture(TextureMap.locationBlocksTexture); - RenderItem.getInstance().renderIcon(35, 29, BlockAlfPortal.portalTex, 48, 48); - } - - private static boolean hasElvenKnowledge() { - /*EntityPlayer player = Minecraft.getMinecraft().thePlayer; - if (player != null) { - for (ItemStack stack : player.inventory.mainInventory) { - if (stack != null && stack.getItem() instanceof ILexicon) { - ILexicon lexicon = (ILexicon) stack.getItem(); - if (lexicon.isKnowledgeUnlocked(stack, BotaniaAPI.elvenKnowledge)) { - return true; - } - } - } - } - return false;*/ - return true; - } - - @Override - public void loadCraftingRecipes(String outputId, Object... results) { - if(outputId.equals("botania.elvenTrade") && hasElvenKnowledge()) { - if(hasElvenKnowledge()) { - for(RecipeElvenTrade recipe : filteredElvenTradeRecipes()) { - arecipes.add(new CachedElvenTradeRecipe(recipe)); - } - } - } else super.loadCraftingRecipes(outputId, results); - } - - @Override - public void loadCraftingRecipes(ItemStack result) { - if(hasElvenKnowledge()) { - for(RecipeElvenTrade recipe : filteredElvenTradeRecipes()) { - if(ItemNBTHelper.areStacksSameTypeCraftingWithNBT(recipe.getOutput(), result)) - arecipes.add(new CachedElvenTradeRecipe(recipe)); - } - } - } - - @Override - public void loadUsageRecipes(ItemStack ingredient) { - if(hasElvenKnowledge()) { - for(RecipeElvenTrade recipe : filteredElvenTradeRecipes()) { - CachedElvenTradeRecipe crecipe = new CachedElvenTradeRecipe(recipe); - if(ItemNBTHelper.cachedRecipeContainsWithNBT(crecipe.inputs, ingredient)) - arecipes.add(crecipe); - } - } - } - - // hide dummy recipes - private List filteredElvenTradeRecipes() { - return BotaniaAPI.elvenTradeRecipes - .stream() - .filter(recipe -> { - if (recipe == null) { - return false; - } - if (recipe.getInputs().size() == 1) { - return !stackSame(recipe.getOutput(), recipe.getInputs().get(0)); - } - return true; - }) - .collect(Collectors.toList()); - } - - private boolean stackSame(ItemStack stack, Object obj) { - if (obj instanceof String) { - return OreDictionary.getOres((String) obj).stream().anyMatch(s -> ItemNBTHelper.areStacksSameTypeCraftingWithNBT(stack, s)); - } else { - return Arrays.stream(NEIServerUtils.extractRecipeItems(obj)).anyMatch(s -> ItemNBTHelper.areStacksSameTypeCraftingWithNBT(stack, s)); - } - } - + public class CachedElvenTradeRecipe extends CachedRecipe { + + public List inputs = new ArrayList(); + public PositionedStack output; + + public CachedElvenTradeRecipe(RecipeElvenTrade recipe) { + if (recipe == null) return; + + setIngredients(recipe.getInputs()); + output = new PositionedStack(recipe.getOutput(), 107, 46); + } + + public void setIngredients(List inputs) { + int i = 0; + for (Object o : inputs) { + if (o instanceof String) + this.inputs.add(new PositionedStack(OreDictionary.getOres((String) o), 60 + i * 18, 6)); + else this.inputs.add(new PositionedStack(o, 60 + i * 18, 6)); + + i++; + } + } + + @Override + public List getIngredients() { + return getCycledIngredients(cycleticks / 20, inputs); + } + + @Override + public PositionedStack getResult() { + return output; + } + } + + @Override + public String getRecipeName() { + return StatCollector.translateToLocal("botania.nei.elvenTrade"); + } + + @Override + public String getGuiTexture() { + return LibResources.GUI_NEI_BLANK; + } + + @Override + public void loadTransferRects() { + transferRects.add(new RecipeTransferRect(new Rectangle(35, 30, 48, 48), "botania.elvenTrade")); + } + + @Override + public int recipiesPerPage() { + return 1; + } + + @Override + public void drawBackground(int recipe) { + super.drawBackground(recipe); + GL11.glEnable(GL11.GL_BLEND); + GL11.glColor4f(1.0F, 1.0F, 1.0F, 0.7F); + GuiDraw.changeTexture(LibResources.GUI_ELVEN_TRADE_OVERLAY); + GuiDraw.drawTexturedModalRect(30, 10, 17, 17, 100, 80); + GL11.glDisable(GL11.GL_BLEND); + GuiDraw.changeTexture(TextureMap.locationBlocksTexture); + RenderItem.getInstance().renderIcon(35, 29, BlockAlfPortal.portalTex, 48, 48); + } + + private static boolean hasElvenKnowledge() { + /*EntityPlayer player = Minecraft.getMinecraft().thePlayer; + if (player != null) { + for (ItemStack stack : player.inventory.mainInventory) { + if (stack != null && stack.getItem() instanceof ILexicon) { + ILexicon lexicon = (ILexicon) stack.getItem(); + if (lexicon.isKnowledgeUnlocked(stack, BotaniaAPI.elvenKnowledge)) { + return true; + } + } + } + } + return false;*/ + return true; + } + + @Override + public void loadCraftingRecipes(String outputId, Object... results) { + if (outputId.equals("botania.elvenTrade") && hasElvenKnowledge()) { + if (hasElvenKnowledge()) { + for (RecipeElvenTrade recipe : filteredElvenTradeRecipes()) { + arecipes.add(new CachedElvenTradeRecipe(recipe)); + } + } + } else super.loadCraftingRecipes(outputId, results); + } + + @Override + public void loadCraftingRecipes(ItemStack result) { + if (hasElvenKnowledge()) { + for (RecipeElvenTrade recipe : filteredElvenTradeRecipes()) { + if (ItemNBTHelper.areStacksSameTypeCraftingWithNBT(recipe.getOutput(), result)) + arecipes.add(new CachedElvenTradeRecipe(recipe)); + } + } + } + + @Override + public void loadUsageRecipes(ItemStack ingredient) { + if (hasElvenKnowledge()) { + for (RecipeElvenTrade recipe : filteredElvenTradeRecipes()) { + CachedElvenTradeRecipe crecipe = new CachedElvenTradeRecipe(recipe); + if (ItemNBTHelper.cachedRecipeContainsWithNBT(crecipe.inputs, ingredient)) arecipes.add(crecipe); + } + } + } + + // hide dummy recipes + private List filteredElvenTradeRecipes() { + return BotaniaAPI.elvenTradeRecipes.stream() + .filter(recipe -> { + if (recipe == null) { + return false; + } + if (recipe.getInputs().size() == 1) { + return !stackSame(recipe.getOutput(), recipe.getInputs().get(0)); + } + return true; + }) + .collect(Collectors.toList()); + } + + private boolean stackSame(ItemStack stack, Object obj) { + if (obj instanceof String) { + return OreDictionary.getOres((String) obj).stream() + .anyMatch(s -> ItemNBTHelper.areStacksSameTypeCraftingWithNBT(stack, s)); + } else { + return Arrays.stream(NEIServerUtils.extractRecipeItems(obj)) + .anyMatch(s -> ItemNBTHelper.areStacksSameTypeCraftingWithNBT(stack, s)); + } + } } diff --git a/src/main/java/vazkii/botania/client/integration/nei/recipe/RecipeHandlerFloatingFlowers.java b/src/main/java/vazkii/botania/client/integration/nei/recipe/RecipeHandlerFloatingFlowers.java index d1a1f397a2..f1932c8068 100644 --- a/src/main/java/vazkii/botania/client/integration/nei/recipe/RecipeHandlerFloatingFlowers.java +++ b/src/main/java/vazkii/botania/client/integration/nei/recipe/RecipeHandlerFloatingFlowers.java @@ -1,9 +1,10 @@ package vazkii.botania.client.integration.nei.recipe; +import codechicken.nei.PositionedStack; +import codechicken.nei.recipe.TemplateRecipeHandler; import java.awt.Rectangle; import java.util.ArrayList; import java.util.List; - import net.minecraft.block.Block; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; @@ -12,70 +13,67 @@ import vazkii.botania.common.block.BlockFloatingSpecialFlower; import vazkii.botania.common.block.BlockSpecialFlower; import vazkii.botania.common.block.ModBlocks; -import codechicken.nei.PositionedStack; -import codechicken.nei.recipe.TemplateRecipeHandler; public class RecipeHandlerFloatingFlowers extends TemplateRecipeHandler { - public class CachedFloatingFlowerRecipe extends CachedRecipe { - - public List inputs = new ArrayList(); - public PositionedStack output; - - public CachedFloatingFlowerRecipe(ItemStack floatingFlower, ItemStack specialFlower, ItemStack output) { - inputs.add(new PositionedStack(floatingFlower, 25, 6)); - inputs.add(new PositionedStack(specialFlower, 43, 6)); - this.output = new PositionedStack(output, 119, 24); - this.output.setMaxSize(1); - } - - @Override - public List getIngredients() { - return getCycledIngredients(cycleticks / 20, inputs); - } - - @Override - public PositionedStack getResult() { - return output; - } - - } - - @Override - public String getRecipeName() { - return StatCollector.translateToLocal("botania.nei.floatingFlowers"); - } - - @Override - public void loadTransferRects() { - transferRects.add(new RecipeTransferRect(new Rectangle(84, 23, 24, 18), "crafting")); - } - - @Override - public String getGuiTexture() { - return "textures/gui/container/crafting_table.png"; - } - - @Override - public void loadCraftingRecipes(ItemStack result) { - if(Block.getBlockFromItem(result.getItem()) instanceof BlockFloatingSpecialFlower) { - ItemStack floatingFlower = new ItemStack(ModBlocks.floatingFlower, 1, OreDictionary.WILDCARD_VALUE); - ItemStack specialFlower = new ItemStack(ModBlocks.specialFlower); - specialFlower.setTagCompound((NBTTagCompound) result.getTagCompound().copy()); - - arecipes.add(new CachedFloatingFlowerRecipe(floatingFlower, specialFlower, result.copy())); - } - } - - @Override - public void loadUsageRecipes(ItemStack ingredient) { - if(Block.getBlockFromItem(ingredient.getItem()) instanceof BlockSpecialFlower) { - ItemStack floatingFlower = new ItemStack(ModBlocks.floatingFlower, 1, OreDictionary.WILDCARD_VALUE); - ItemStack result = new ItemStack(ModBlocks.floatingSpecialFlower); - result.setTagCompound((NBTTagCompound) ingredient.getTagCompound().copy()); - - arecipes.add(new CachedFloatingFlowerRecipe(floatingFlower, ingredient.copy(), result)); - } - } - + public class CachedFloatingFlowerRecipe extends CachedRecipe { + + public List inputs = new ArrayList(); + public PositionedStack output; + + public CachedFloatingFlowerRecipe(ItemStack floatingFlower, ItemStack specialFlower, ItemStack output) { + inputs.add(new PositionedStack(floatingFlower, 25, 6)); + inputs.add(new PositionedStack(specialFlower, 43, 6)); + this.output = new PositionedStack(output, 119, 24); + this.output.setMaxSize(1); + } + + @Override + public List getIngredients() { + return getCycledIngredients(cycleticks / 20, inputs); + } + + @Override + public PositionedStack getResult() { + return output; + } + } + + @Override + public String getRecipeName() { + return StatCollector.translateToLocal("botania.nei.floatingFlowers"); + } + + @Override + public void loadTransferRects() { + transferRects.add(new RecipeTransferRect(new Rectangle(84, 23, 24, 18), "crafting")); + } + + @Override + public String getGuiTexture() { + return "textures/gui/container/crafting_table.png"; + } + + @Override + public void loadCraftingRecipes(ItemStack result) { + if (Block.getBlockFromItem(result.getItem()) instanceof BlockFloatingSpecialFlower) { + ItemStack floatingFlower = new ItemStack(ModBlocks.floatingFlower, 1, OreDictionary.WILDCARD_VALUE); + ItemStack specialFlower = new ItemStack(ModBlocks.specialFlower); + specialFlower.setTagCompound( + (NBTTagCompound) result.getTagCompound().copy()); + + arecipes.add(new CachedFloatingFlowerRecipe(floatingFlower, specialFlower, result.copy())); + } + } + + @Override + public void loadUsageRecipes(ItemStack ingredient) { + if (Block.getBlockFromItem(ingredient.getItem()) instanceof BlockSpecialFlower) { + ItemStack floatingFlower = new ItemStack(ModBlocks.floatingFlower, 1, OreDictionary.WILDCARD_VALUE); + ItemStack result = new ItemStack(ModBlocks.floatingSpecialFlower); + result.setTagCompound((NBTTagCompound) ingredient.getTagCompound().copy()); + + arecipes.add(new CachedFloatingFlowerRecipe(floatingFlower, ingredient.copy(), result)); + } + } } diff --git a/src/main/java/vazkii/botania/client/integration/nei/recipe/RecipeHandlerLexicaBotania.java b/src/main/java/vazkii/botania/client/integration/nei/recipe/RecipeHandlerLexicaBotania.java index ea1933074e..fa544e55a7 100644 --- a/src/main/java/vazkii/botania/client/integration/nei/recipe/RecipeHandlerLexicaBotania.java +++ b/src/main/java/vazkii/botania/client/integration/nei/recipe/RecipeHandlerLexicaBotania.java @@ -2,170 +2,150 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [12/12/2015, 23:25:47 (GMT)] */ package vazkii.botania.client.integration.nei.recipe; +import codechicken.nei.PositionedStack; +import codechicken.nei.recipe.TemplateRecipeHandler; +import codechicken.nei.recipe.TemplateRecipeHandler.CachedRecipe; +import codechicken.nei.recipe.TemplateRecipeHandler.RecipeTransferRect; import java.awt.Rectangle; import java.util.ArrayList; import java.util.Collection; import java.util.List; - import net.minecraft.client.Minecraft; import net.minecraft.client.gui.FontRenderer; import net.minecraft.client.gui.GuiScreen; -import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.util.EnumChatFormatting; import net.minecraft.util.StatCollector; -import net.minecraftforge.oredict.OreDictionary; - -import org.lwjgl.opengl.GL11; - import vazkii.botania.api.BotaniaAPI; import vazkii.botania.api.lexicon.KnowledgeType; import vazkii.botania.api.lexicon.LexiconEntry; import vazkii.botania.api.lexicon.LexiconRecipeMappings; -import vazkii.botania.api.recipe.RecipeManaInfusion; -import vazkii.botania.client.core.handler.HUDHandler; -import vazkii.botania.client.integration.nei.recipe.RecipeHandlerManaPool.CachedManaPoolRecipe; import vazkii.botania.client.lib.LibResources; -import vazkii.botania.client.render.tile.RenderTilePool; -import vazkii.botania.common.block.ModBlocks; -import vazkii.botania.common.block.tile.mana.TilePool; -import vazkii.botania.common.core.helper.InventoryHelper; import vazkii.botania.common.item.ModItems; -import vazkii.botania.common.lexicon.LexiconData; -import vazkii.botania.common.lexicon.page.PageRecipe; import vazkii.botania.common.lexicon.page.PageText; -import codechicken.lib.gui.GuiDraw; -import codechicken.nei.NEIServerUtils; -import codechicken.nei.PositionedStack; -import codechicken.nei.recipe.TemplateRecipeHandler; -import codechicken.nei.recipe.TemplateRecipeHandler.CachedRecipe; -import codechicken.nei.recipe.TemplateRecipeHandler.RecipeTransferRect; public class RecipeHandlerLexicaBotania extends TemplateRecipeHandler { - public class CachedLexicaBotaniaRecipe extends CachedRecipe { - - public LexiconEntry entry; - public PositionedStack item; - public List otherStacks = new ArrayList(); - - public CachedLexicaBotaniaRecipe(ItemStack stack, LexiconEntry entry) { - otherStacks.add(new PositionedStack(new ItemStack(ModItems.lexicon), 51, 5)); - item = new PositionedStack(stack, 91, 5); - this.entry = entry; - } - - @Override - public List getIngredients() { - return otherStacks; - } - - @Override - public PositionedStack getResult() { - return item; - } - - @Override - public List getOtherStacks() { - return otherStacks; - } - - @Override - public boolean contains(Collection ingredients, ItemStack ingredient) { - return ingredient.getItem() == ModItems.lexicon; - } - - } - - @Override - public String getRecipeName() { - return StatCollector.translateToLocal("botania.nei.lexica"); - } - - @Override - public String getGuiTexture() { - return LibResources.GUI_NEI_BLANK; - } - - @Override - public int recipiesPerPage() { - return 1; - } - - @Override - public void loadTransferRects() { - transferRects.add(new RecipeTransferRect(new Rectangle(50, 4, 18, 18), "botania.lexica")); - } - - @Override - public void drawBackground(int recipe) { - super.drawBackground(recipe); - - FontRenderer font = Minecraft.getMinecraft().fontRenderer; - CachedLexicaBotaniaRecipe recipeObj = ((CachedLexicaBotaniaRecipe) arecipes.get(recipe)); - - String s = EnumChatFormatting.UNDERLINE + StatCollector.translateToLocal(recipeObj.entry.getUnlocalizedName()); - font.drawString(s, 82 - font.getStringWidth(s) / 2, 30, 4210752); - - KnowledgeType type = recipeObj.entry.getKnowledgeType(); - s = type.color + StatCollector.translateToLocal(type.getUnlocalizedName()).replaceAll("\\&.", ""); - font.drawString(s, 82 - font.getStringWidth(s) / 2, 42, 4210752); - - s = "\"" + StatCollector.translateToLocal(recipeObj.entry.getTagline()) + "\""; - PageText.renderText(5, 42, 160, 200, s); - - String key = LexiconRecipeMappings.stackToString(recipeObj.item.item); - String quickInfo = "botania.nei.quickInfo:" + key; - String quickInfoLocal = StatCollector.translateToLocal(quickInfo); - - if(GuiScreen.isShiftKeyDown() && GuiScreen.isCtrlKeyDown() && Minecraft.getMinecraft().gameSettings.advancedItemTooltips) - s = "name: " + key; - else if(quickInfo.equals(quickInfoLocal)) - s = StatCollector.translateToLocal("botania.nei.lexicaNoInfo"); - else { - s = StatCollector.translateToLocal("botania.nei.lexicaSeparator"); - font.drawString(s, 82 - font.getStringWidth(s) / 2, 80, 4210752); - s = quickInfoLocal; - } - - PageText.renderText(5, 80, 160, 200, s); - } - - @Override - public void loadCraftingRecipes(String outputId, Object... results) { - if(outputId.equals("botania.lexica")) { - for(LexiconEntry entry : BotaniaAPI.getAllEntries()) { - List stacks = entry.getDisplayedRecipes(); - for(ItemStack stack : stacks) - arecipes.add(new CachedLexicaBotaniaRecipe(stack, entry)); - } - } else super.loadCraftingRecipes(outputId, results); - } - - @Override - public void loadCraftingRecipes(ItemStack result) { - for(LexiconEntry entry : BotaniaAPI.getAllEntries()) { - List stacks = entry.getDisplayedRecipes(); - for(ItemStack stack : stacks) { - String key1 = LexiconRecipeMappings.stackToString(stack); - String key2 = LexiconRecipeMappings.stackToString(result); - if(key1.equals(key2)) - arecipes.add(new CachedLexicaBotaniaRecipe(stack, entry)); - } - } - } - - @Override - public void loadUsageRecipes(ItemStack ingredient) { - // NO-OP - } - + public class CachedLexicaBotaniaRecipe extends CachedRecipe { + + public LexiconEntry entry; + public PositionedStack item; + public List otherStacks = new ArrayList(); + + public CachedLexicaBotaniaRecipe(ItemStack stack, LexiconEntry entry) { + otherStacks.add(new PositionedStack(new ItemStack(ModItems.lexicon), 51, 5)); + item = new PositionedStack(stack, 91, 5); + this.entry = entry; + } + + @Override + public List getIngredients() { + return otherStacks; + } + + @Override + public PositionedStack getResult() { + return item; + } + + @Override + public List getOtherStacks() { + return otherStacks; + } + + @Override + public boolean contains(Collection ingredients, ItemStack ingredient) { + return ingredient.getItem() == ModItems.lexicon; + } + } + + @Override + public String getRecipeName() { + return StatCollector.translateToLocal("botania.nei.lexica"); + } + + @Override + public String getGuiTexture() { + return LibResources.GUI_NEI_BLANK; + } + + @Override + public int recipiesPerPage() { + return 1; + } + + @Override + public void loadTransferRects() { + transferRects.add(new RecipeTransferRect(new Rectangle(50, 4, 18, 18), "botania.lexica")); + } + + @Override + public void drawBackground(int recipe) { + super.drawBackground(recipe); + + FontRenderer font = Minecraft.getMinecraft().fontRenderer; + CachedLexicaBotaniaRecipe recipeObj = ((CachedLexicaBotaniaRecipe) arecipes.get(recipe)); + + String s = EnumChatFormatting.UNDERLINE + StatCollector.translateToLocal(recipeObj.entry.getUnlocalizedName()); + font.drawString(s, 82 - font.getStringWidth(s) / 2, 30, 4210752); + + KnowledgeType type = recipeObj.entry.getKnowledgeType(); + s = type.color + + StatCollector.translateToLocal(type.getUnlocalizedName()).replaceAll("\\&.", ""); + font.drawString(s, 82 - font.getStringWidth(s) / 2, 42, 4210752); + + s = "\"" + StatCollector.translateToLocal(recipeObj.entry.getTagline()) + "\""; + PageText.renderText(5, 42, 160, 200, s); + + String key = LexiconRecipeMappings.stackToString(recipeObj.item.item); + String quickInfo = "botania.nei.quickInfo:" + key; + String quickInfoLocal = StatCollector.translateToLocal(quickInfo); + + if (GuiScreen.isShiftKeyDown() + && GuiScreen.isCtrlKeyDown() + && Minecraft.getMinecraft().gameSettings.advancedItemTooltips) s = "name: " + key; + else if (quickInfo.equals(quickInfoLocal)) s = StatCollector.translateToLocal("botania.nei.lexicaNoInfo"); + else { + s = StatCollector.translateToLocal("botania.nei.lexicaSeparator"); + font.drawString(s, 82 - font.getStringWidth(s) / 2, 80, 4210752); + s = quickInfoLocal; + } + + PageText.renderText(5, 80, 160, 200, s); + } + + @Override + public void loadCraftingRecipes(String outputId, Object... results) { + if (outputId.equals("botania.lexica")) { + for (LexiconEntry entry : BotaniaAPI.getAllEntries()) { + List stacks = entry.getDisplayedRecipes(); + for (ItemStack stack : stacks) arecipes.add(new CachedLexicaBotaniaRecipe(stack, entry)); + } + } else super.loadCraftingRecipes(outputId, results); + } + + @Override + public void loadCraftingRecipes(ItemStack result) { + for (LexiconEntry entry : BotaniaAPI.getAllEntries()) { + List stacks = entry.getDisplayedRecipes(); + for (ItemStack stack : stacks) { + String key1 = LexiconRecipeMappings.stackToString(stack); + String key2 = LexiconRecipeMappings.stackToString(result); + if (key1.equals(key2)) arecipes.add(new CachedLexicaBotaniaRecipe(stack, entry)); + } + } + } + + @Override + public void loadUsageRecipes(ItemStack ingredient) { + // NO-OP + } } diff --git a/src/main/java/vazkii/botania/client/integration/nei/recipe/RecipeHandlerManaPool.java b/src/main/java/vazkii/botania/client/integration/nei/recipe/RecipeHandlerManaPool.java index 3548d41266..c4a115ccab 100644 --- a/src/main/java/vazkii/botania/client/integration/nei/recipe/RecipeHandlerManaPool.java +++ b/src/main/java/vazkii/botania/client/integration/nei/recipe/RecipeHandlerManaPool.java @@ -1,17 +1,16 @@ package vazkii.botania.client.integration.nei.recipe; +import codechicken.lib.gui.GuiDraw; +import codechicken.nei.PositionedStack; +import codechicken.nei.recipe.TemplateRecipeHandler; import java.awt.Rectangle; import java.util.ArrayList; -import java.util.Collection; import java.util.List; - import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.util.StatCollector; import net.minecraftforge.oredict.OreDictionary; - import org.lwjgl.opengl.GL11; - import vazkii.botania.api.BotaniaAPI; import vazkii.botania.api.recipe.RecipeManaInfusion; import vazkii.botania.client.core.handler.HUDHandler; @@ -19,120 +18,118 @@ import vazkii.botania.client.render.tile.RenderTilePool; import vazkii.botania.common.block.ModBlocks; import vazkii.botania.common.block.tile.mana.TilePool; -import codechicken.lib.gui.GuiDraw; -import codechicken.nei.NEIServerUtils; -import codechicken.nei.PositionedStack; -import codechicken.nei.recipe.TemplateRecipeHandler; import vazkii.botania.common.core.helper.ItemNBTHelper; public class RecipeHandlerManaPool extends TemplateRecipeHandler { - public class CachedManaPoolRecipe extends CachedRecipe { - - public List inputs = new ArrayList(); - public PositionedStack output; - public List otherStacks = new ArrayList(); - public int mana; - - public CachedManaPoolRecipe(RecipeManaInfusion recipe) { - if(recipe == null) - return; - inputs.add(new PositionedStack(new ItemStack(ModBlocks.pool, 1, recipe.getOutput().getItem() == Item.getItemFromBlock(ModBlocks.pool) ? 2 : 0), 71, 37)); - - if(recipe.getInput() instanceof String) - inputs.add(new PositionedStack(OreDictionary.getOres((String) recipe.getInput()), 42, 37)); - else inputs.add(new PositionedStack(recipe.getInput(), 42, 37)); - - if(recipe.isAlchemy()) - otherStacks.add(new PositionedStack(new ItemStack(ModBlocks.alchemyCatalyst), 10, 37)); - else if (recipe.isConjuration()) - otherStacks.add(new PositionedStack(new ItemStack(ModBlocks.conjurationCatalyst), 10, 37)); - - output = new PositionedStack(recipe.getOutput(), 101, 37); - mana = recipe.getManaToConsume(); - } - - @Override - public List getIngredients() { - return getCycledIngredients(cycleticks / 20, inputs); - } - - @Override - public PositionedStack getResult() { - return output; - } - - @Override - public List getOtherStacks() { - return otherStacks; - } - - } - - @Override - public String getRecipeName() { - return StatCollector.translateToLocal("botania.nei.manaPool"); - } - - @Override - public String getGuiTexture() { - return LibResources.GUI_NEI_BLANK; - } - - @Override - public int recipiesPerPage() { - return 1; - } - - @Override - public void loadTransferRects() { - transferRects.add(new RecipeTransferRect(new Rectangle(70, 36, 18, 18), "botania.manaPool")); - } - - @Override - public void drawBackground(int recipe) { - super.drawBackground(recipe); - GL11.glEnable(GL11.GL_BLEND); - GL11.glColor4f(1.0F, 1.0F, 1.0F, 0.5F); - GuiDraw.changeTexture(LibResources.GUI_MANA_INFUSION_OVERLAY); - GuiDraw.drawTexturedModalRect(45, 20, 38, 35, 92, 50); - HUDHandler.renderManaBar(32, 80, 0x0000FF, 0.75F, ((CachedManaPoolRecipe) arecipes.get(recipe)).mana, TilePool.MAX_MANA / 10); - RenderTilePool.forceMana = true; - } - - @Override - public void loadCraftingRecipes(String outputId, Object... results) { - if(outputId.equals("botania.manaPool")) { - for(RecipeManaInfusion recipe : BotaniaAPI.manaInfusionRecipes) { - if(recipe == null) - continue; - - arecipes.add(new CachedManaPoolRecipe(recipe)); - } - } else super.loadCraftingRecipes(outputId, results); - } - - @Override - public void loadCraftingRecipes(ItemStack result) { - for(RecipeManaInfusion recipe : BotaniaAPI.manaInfusionRecipes) { - if(recipe == null) - continue; - - if(ItemNBTHelper.areStacksSameTypeCraftingWithNBT(recipe.getOutput(), result)) - arecipes.add(new CachedManaPoolRecipe(recipe)); - } - } - - @Override - public void loadUsageRecipes(ItemStack ingredient) { - for(RecipeManaInfusion recipe : BotaniaAPI.manaInfusionRecipes) { - if(recipe == null) - continue; - - CachedManaPoolRecipe crecipe = new CachedManaPoolRecipe(recipe); - if(ItemNBTHelper.cachedRecipeContainsWithNBT(crecipe.getIngredients(), ingredient) || ItemNBTHelper.cachedRecipeContainsWithNBT(crecipe.getOtherStacks(), ingredient)) - arecipes.add(crecipe); - } - } - + public class CachedManaPoolRecipe extends CachedRecipe { + + public List inputs = new ArrayList(); + public PositionedStack output; + public List otherStacks = new ArrayList(); + public int mana; + + public CachedManaPoolRecipe(RecipeManaInfusion recipe) { + if (recipe == null) return; + inputs.add(new PositionedStack( + new ItemStack( + ModBlocks.pool, + 1, + recipe.getOutput().getItem() == Item.getItemFromBlock(ModBlocks.pool) ? 2 : 0), + 71, + 37)); + + if (recipe.getInput() instanceof String) + inputs.add(new PositionedStack(OreDictionary.getOres((String) recipe.getInput()), 42, 37)); + else inputs.add(new PositionedStack(recipe.getInput(), 42, 37)); + + if (recipe.isAlchemy()) + otherStacks.add(new PositionedStack(new ItemStack(ModBlocks.alchemyCatalyst), 10, 37)); + else if (recipe.isConjuration()) + otherStacks.add(new PositionedStack(new ItemStack(ModBlocks.conjurationCatalyst), 10, 37)); + + output = new PositionedStack(recipe.getOutput(), 101, 37); + mana = recipe.getManaToConsume(); + } + + @Override + public List getIngredients() { + return getCycledIngredients(cycleticks / 20, inputs); + } + + @Override + public PositionedStack getResult() { + return output; + } + + @Override + public List getOtherStacks() { + return otherStacks; + } + } + + @Override + public String getRecipeName() { + return StatCollector.translateToLocal("botania.nei.manaPool"); + } + + @Override + public String getGuiTexture() { + return LibResources.GUI_NEI_BLANK; + } + + @Override + public int recipiesPerPage() { + return 1; + } + + @Override + public void loadTransferRects() { + transferRects.add(new RecipeTransferRect(new Rectangle(70, 36, 18, 18), "botania.manaPool")); + } + + @Override + public void drawBackground(int recipe) { + super.drawBackground(recipe); + GL11.glEnable(GL11.GL_BLEND); + GL11.glColor4f(1.0F, 1.0F, 1.0F, 0.5F); + GuiDraw.changeTexture(LibResources.GUI_MANA_INFUSION_OVERLAY); + GuiDraw.drawTexturedModalRect(45, 20, 38, 35, 92, 50); + HUDHandler.renderManaBar( + 32, 80, 0x0000FF, 0.75F, ((CachedManaPoolRecipe) arecipes.get(recipe)).mana, TilePool.MAX_MANA / 10); + RenderTilePool.forceMana = true; + } + + @Override + public void loadCraftingRecipes(String outputId, Object... results) { + if (outputId.equals("botania.manaPool")) { + for (RecipeManaInfusion recipe : BotaniaAPI.manaInfusionRecipes) { + if (recipe == null) continue; + + arecipes.add(new CachedManaPoolRecipe(recipe)); + } + } else super.loadCraftingRecipes(outputId, results); + } + + @Override + public void loadCraftingRecipes(ItemStack result) { + for (RecipeManaInfusion recipe : BotaniaAPI.manaInfusionRecipes) { + if (recipe == null) continue; + + if (ItemNBTHelper.areStacksSameTypeCraftingWithNBT(recipe.getOutput(), result)) + arecipes.add(new CachedManaPoolRecipe(recipe)); + } + } + + @Override + public void loadUsageRecipes(ItemStack ingredient) { + for (RecipeManaInfusion recipe : BotaniaAPI.manaInfusionRecipes) { + if (recipe == null) continue; + + CachedManaPoolRecipe crecipe = new CachedManaPoolRecipe(recipe); + if (ItemNBTHelper.cachedRecipeContainsWithNBT(crecipe.getIngredients(), ingredient) + || ItemNBTHelper.cachedRecipeContainsWithNBT(crecipe.getOtherStacks(), ingredient)) + arecipes.add(crecipe); + } + } } diff --git a/src/main/java/vazkii/botania/client/integration/nei/recipe/RecipeHandlerPetalApothecary.java b/src/main/java/vazkii/botania/client/integration/nei/recipe/RecipeHandlerPetalApothecary.java index f085bfb575..dd49c58e83 100644 --- a/src/main/java/vazkii/botania/client/integration/nei/recipe/RecipeHandlerPetalApothecary.java +++ b/src/main/java/vazkii/botania/client/integration/nei/recipe/RecipeHandlerPetalApothecary.java @@ -1,143 +1,136 @@ package vazkii.botania.client.integration.nei.recipe; +import codechicken.lib.gui.GuiDraw; +import codechicken.nei.NEIServerUtils; +import codechicken.nei.PositionedStack; +import codechicken.nei.recipe.TemplateRecipeHandler; import java.awt.Rectangle; import java.util.ArrayList; import java.util.List; - import net.minecraft.init.Items; import net.minecraft.item.ItemStack; import net.minecraft.util.StatCollector; import net.minecraftforge.oredict.OreDictionary; - import org.lwjgl.opengl.GL11; - import vazkii.botania.api.BotaniaAPI; import vazkii.botania.api.recipe.RecipePetals; import vazkii.botania.client.lib.LibResources; import vazkii.botania.common.block.ModBlocks; -import codechicken.lib.gui.GuiDraw; -import codechicken.nei.NEIServerUtils; -import codechicken.nei.PositionedStack; -import codechicken.nei.recipe.TemplateRecipeHandler; import vazkii.botania.common.core.helper.ItemNBTHelper; public class RecipeHandlerPetalApothecary extends TemplateRecipeHandler { - public class CachedPetalApothecaryRecipe extends CachedRecipe { - - public List inputs = new ArrayList(); - public PositionedStack output; - - public CachedPetalApothecaryRecipe(RecipePetals recipe, boolean addCenterItem) { - setIngredients(recipe.getInputs()); - output = new PositionedStack(recipe.getOutput(), 111, 21); - if(addCenterItem) - inputs.add(new PositionedStack(new ItemStack(ModBlocks.altar), 73, 55)); - } - - public CachedPetalApothecaryRecipe(RecipePetals recipe) { - this(recipe, true); - } - - public void setIngredients(List inputs) { - float degreePerInput = 360F / inputs.size(); - float currentDegree = -90F; - - for(Object o : inputs) { - int posX = (int) Math.round(73 + Math.cos(currentDegree * Math.PI / 180D) * 32); - int posY = (int) Math.round(55 + Math.sin(currentDegree * Math.PI / 180D) * 32); - - if(o instanceof String) - this.inputs.add(new PositionedStack(OreDictionary.getOres((String) o), posX, posY)); - else this.inputs.add(new PositionedStack(o, posX, posY)); - currentDegree += degreePerInput; - } - } - - @Override - public List getIngredients() { - return getCycledIngredients(cycleticks / 20, inputs); - } - - @Override - public PositionedStack getResult() { - return output; - } - - } - - @Override - public String getRecipeName() { - return StatCollector.translateToLocal("botania.nei.petalApothecary"); - } - - public String getRecipeID() { - return "botania.petalApothecary"; - } - - @Override - public String getGuiTexture() { - return LibResources.GUI_NEI_BLANK; - } - - @Override - public void loadTransferRects() { - transferRects.add(new RecipeTransferRect(new Rectangle(72, 54, 18, 18), getRecipeID())); - } - - @Override - public int recipiesPerPage() { - return 1; - } - - @Override - public void drawBackground(int recipe) { - super.drawBackground(recipe); - GL11.glEnable(GL11.GL_BLEND); - GL11.glColor4f(1.0F, 1.0F, 1.0F, 0.5F); - GuiDraw.changeTexture(LibResources.GUI_PETAL_OVERLAY); - GuiDraw.drawTexturedModalRect(45, 10, 38, 7, 92, 92); - } - - public List getRecipes() { - return BotaniaAPI.petalRecipes; - } - - public CachedPetalApothecaryRecipe getCachedRecipe(RecipePetals recipe) { - return new CachedPetalApothecaryRecipe(recipe); - } - - @Override - public void loadCraftingRecipes(String outputId, Object... results) { - if(outputId.equals(getRecipeID())) { - for(RecipePetals recipe : getRecipes()) - if(recipe.getOutput().getItem() != Items.skull) - arecipes.add(getCachedRecipe(recipe)); - } else super.loadCraftingRecipes(outputId, results); - } - - @Override - public void loadCraftingRecipes(ItemStack result) { - for(RecipePetals recipe : getRecipes()){ - if(recipe == null) - continue; - - if(recipe.getOutput().stackTagCompound != null && ItemNBTHelper.areStacksSameTypeWithNBT(recipe.getOutput(), result) || recipe.getOutput().stackTagCompound == null && NEIServerUtils.areStacksSameTypeCrafting(recipe.getOutput(), result) && recipe.getOutput().getItem() != Items.skull) - arecipes.add(getCachedRecipe(recipe)); - } - } - - @Override - public void loadUsageRecipes(ItemStack ingredient) { - for(RecipePetals recipe : getRecipes()) { - if(recipe == null) - continue; - - CachedPetalApothecaryRecipe crecipe = getCachedRecipe(recipe); - if(ItemNBTHelper.cachedRecipeContainsWithNBT(crecipe.inputs, ingredient) && recipe.getOutput().getItem() != Items.skull) - arecipes.add(crecipe); - } - } - - + public class CachedPetalApothecaryRecipe extends CachedRecipe { + + public List inputs = new ArrayList(); + public PositionedStack output; + + public CachedPetalApothecaryRecipe(RecipePetals recipe, boolean addCenterItem) { + setIngredients(recipe.getInputs()); + output = new PositionedStack(recipe.getOutput(), 111, 21); + if (addCenterItem) inputs.add(new PositionedStack(new ItemStack(ModBlocks.altar), 73, 55)); + } + + public CachedPetalApothecaryRecipe(RecipePetals recipe) { + this(recipe, true); + } + + public void setIngredients(List inputs) { + float degreePerInput = 360F / inputs.size(); + float currentDegree = -90F; + + for (Object o : inputs) { + int posX = (int) Math.round(73 + Math.cos(currentDegree * Math.PI / 180D) * 32); + int posY = (int) Math.round(55 + Math.sin(currentDegree * Math.PI / 180D) * 32); + + if (o instanceof String) + this.inputs.add(new PositionedStack(OreDictionary.getOres((String) o), posX, posY)); + else this.inputs.add(new PositionedStack(o, posX, posY)); + currentDegree += degreePerInput; + } + } + + @Override + public List getIngredients() { + return getCycledIngredients(cycleticks / 20, inputs); + } + + @Override + public PositionedStack getResult() { + return output; + } + } + + @Override + public String getRecipeName() { + return StatCollector.translateToLocal("botania.nei.petalApothecary"); + } + + public String getRecipeID() { + return "botania.petalApothecary"; + } + + @Override + public String getGuiTexture() { + return LibResources.GUI_NEI_BLANK; + } + + @Override + public void loadTransferRects() { + transferRects.add(new RecipeTransferRect(new Rectangle(72, 54, 18, 18), getRecipeID())); + } + + @Override + public int recipiesPerPage() { + return 1; + } + + @Override + public void drawBackground(int recipe) { + super.drawBackground(recipe); + GL11.glEnable(GL11.GL_BLEND); + GL11.glColor4f(1.0F, 1.0F, 1.0F, 0.5F); + GuiDraw.changeTexture(LibResources.GUI_PETAL_OVERLAY); + GuiDraw.drawTexturedModalRect(45, 10, 38, 7, 92, 92); + } + + public List getRecipes() { + return BotaniaAPI.petalRecipes; + } + + public CachedPetalApothecaryRecipe getCachedRecipe(RecipePetals recipe) { + return new CachedPetalApothecaryRecipe(recipe); + } + + @Override + public void loadCraftingRecipes(String outputId, Object... results) { + if (outputId.equals(getRecipeID())) { + for (RecipePetals recipe : getRecipes()) + if (recipe.getOutput().getItem() != Items.skull) arecipes.add(getCachedRecipe(recipe)); + } else super.loadCraftingRecipes(outputId, results); + } + + @Override + public void loadCraftingRecipes(ItemStack result) { + for (RecipePetals recipe : getRecipes()) { + if (recipe == null) continue; + + if (recipe.getOutput().stackTagCompound != null + && ItemNBTHelper.areStacksSameTypeWithNBT(recipe.getOutput(), result) + || recipe.getOutput().stackTagCompound == null + && NEIServerUtils.areStacksSameTypeCrafting(recipe.getOutput(), result) + && recipe.getOutput().getItem() != Items.skull) arecipes.add(getCachedRecipe(recipe)); + } + } + + @Override + public void loadUsageRecipes(ItemStack ingredient) { + for (RecipePetals recipe : getRecipes()) { + if (recipe == null) continue; + + CachedPetalApothecaryRecipe crecipe = getCachedRecipe(recipe); + if (ItemNBTHelper.cachedRecipeContainsWithNBT(crecipe.inputs, ingredient) + && recipe.getOutput().getItem() != Items.skull) arecipes.add(crecipe); + } + } } diff --git a/src/main/java/vazkii/botania/client/integration/nei/recipe/RecipeHandlerPureDaisy.java b/src/main/java/vazkii/botania/client/integration/nei/recipe/RecipeHandlerPureDaisy.java index a4a49890ac..61017d108a 100644 --- a/src/main/java/vazkii/botania/client/integration/nei/recipe/RecipeHandlerPureDaisy.java +++ b/src/main/java/vazkii/botania/client/integration/nei/recipe/RecipeHandlerPureDaisy.java @@ -1,127 +1,117 @@ package vazkii.botania.client.integration.nei.recipe; +import codechicken.lib.gui.GuiDraw; +import codechicken.nei.PositionedStack; +import codechicken.nei.recipe.TemplateRecipeHandler; import java.awt.Rectangle; import java.util.ArrayList; -import java.util.Collection; import java.util.List; - import net.minecraft.block.Block; import net.minecraft.item.ItemStack; import net.minecraft.util.StatCollector; import net.minecraftforge.oredict.OreDictionary; - import org.lwjgl.opengl.GL11; - import vazkii.botania.api.BotaniaAPI; import vazkii.botania.api.recipe.RecipePureDaisy; import vazkii.botania.client.lib.LibResources; import vazkii.botania.common.core.helper.ItemNBTHelper; import vazkii.botania.common.item.block.ItemBlockSpecialFlower; import vazkii.botania.common.lib.LibBlockNames; -import codechicken.lib.gui.GuiDraw; -import codechicken.nei.NEIServerUtils; -import codechicken.nei.PositionedStack; -import codechicken.nei.recipe.TemplateRecipeHandler; public class RecipeHandlerPureDaisy extends TemplateRecipeHandler { - public class CachedPureDaisyRecipe extends CachedRecipe { - - public List inputs = new ArrayList(); - public PositionedStack output; - public List otherStacks = new ArrayList(); - - public CachedPureDaisyRecipe(RecipePureDaisy recipe) { - if(recipe == null) - return; - inputs.add(new PositionedStack(ItemBlockSpecialFlower.ofType(LibBlockNames.SUBTILE_PUREDAISY), 71, 23)); - - if(recipe.getInput() instanceof String) - inputs.add(new PositionedStack(OreDictionary.getOres((String) recipe.getInput()), 42, 23)); - else inputs.add(new PositionedStack(new ItemStack((Block) recipe.getInput()), 42, 23)); - - output = new PositionedStack(new ItemStack(recipe.getOutput()), 101, 23); - } - - @Override - public List getIngredients() { - return getCycledIngredients(cycleticks / 20, inputs); - } - - @Override - public PositionedStack getResult() { - return output; - } - - @Override - public List getOtherStacks() { - return otherStacks; - } - - } - - @Override - public String getRecipeName() { - return StatCollector.translateToLocal("botania.nei.pureDaisy"); - } - - @Override - public String getGuiTexture() { - return LibResources.GUI_NEI_BLANK; - } - - @Override - public int recipiesPerPage() { - return 2; - } - - @Override - public void loadTransferRects() { - transferRects.add(new RecipeTransferRect(new Rectangle(70, 22, 18, 18), "botania.pureDaisy")); - } - - @Override - public void drawBackground(int recipe) { - super.drawBackground(recipe); - GL11.glEnable(GL11.GL_BLEND); - GL11.glColor4f(1.0F, 1.0F, 1.0F, 0.5F); - GuiDraw.changeTexture(LibResources.GUI_PURE_DAISY_OVERLAY); - GuiDraw.drawTexturedModalRect(45, 10, 0, 0, 65, 44); - } - - @Override - public void loadCraftingRecipes(String outputId, Object... results) { - if(outputId.equals("botania.pureDaisy")) { - for(RecipePureDaisy recipe : BotaniaAPI.pureDaisyRecipes) { - if(recipe == null) - continue; - - arecipes.add(new CachedPureDaisyRecipe(recipe)); - } - } else super.loadCraftingRecipes(outputId, results); - } - - @Override - public void loadCraftingRecipes(ItemStack result) { - for(RecipePureDaisy recipe : BotaniaAPI.pureDaisyRecipes) { - if(recipe == null) - continue; - - if(ItemNBTHelper.areStacksSameTypeCraftingWithNBT(new ItemStack(recipe.getOutput()), result)) - arecipes.add(new CachedPureDaisyRecipe(recipe)); - } - } - - @Override - public void loadUsageRecipes(ItemStack ingredient) { - for(RecipePureDaisy recipe : BotaniaAPI.pureDaisyRecipes) { - if(recipe == null) - continue; - - CachedPureDaisyRecipe crecipe = new CachedPureDaisyRecipe(recipe); - if(ItemNBTHelper.cachedRecipeContainsWithNBT(crecipe.getIngredients(), ingredient) || ItemNBTHelper.cachedRecipeContainsWithNBT(crecipe.getOtherStacks(), ingredient)) - arecipes.add(crecipe); - } - } - + public class CachedPureDaisyRecipe extends CachedRecipe { + + public List inputs = new ArrayList(); + public PositionedStack output; + public List otherStacks = new ArrayList(); + + public CachedPureDaisyRecipe(RecipePureDaisy recipe) { + if (recipe == null) return; + inputs.add(new PositionedStack(ItemBlockSpecialFlower.ofType(LibBlockNames.SUBTILE_PUREDAISY), 71, 23)); + + if (recipe.getInput() instanceof String) + inputs.add(new PositionedStack(OreDictionary.getOres((String) recipe.getInput()), 42, 23)); + else inputs.add(new PositionedStack(new ItemStack((Block) recipe.getInput()), 42, 23)); + + output = new PositionedStack(new ItemStack(recipe.getOutput()), 101, 23); + } + + @Override + public List getIngredients() { + return getCycledIngredients(cycleticks / 20, inputs); + } + + @Override + public PositionedStack getResult() { + return output; + } + + @Override + public List getOtherStacks() { + return otherStacks; + } + } + + @Override + public String getRecipeName() { + return StatCollector.translateToLocal("botania.nei.pureDaisy"); + } + + @Override + public String getGuiTexture() { + return LibResources.GUI_NEI_BLANK; + } + + @Override + public int recipiesPerPage() { + return 2; + } + + @Override + public void loadTransferRects() { + transferRects.add(new RecipeTransferRect(new Rectangle(70, 22, 18, 18), "botania.pureDaisy")); + } + + @Override + public void drawBackground(int recipe) { + super.drawBackground(recipe); + GL11.glEnable(GL11.GL_BLEND); + GL11.glColor4f(1.0F, 1.0F, 1.0F, 0.5F); + GuiDraw.changeTexture(LibResources.GUI_PURE_DAISY_OVERLAY); + GuiDraw.drawTexturedModalRect(45, 10, 0, 0, 65, 44); + } + + @Override + public void loadCraftingRecipes(String outputId, Object... results) { + if (outputId.equals("botania.pureDaisy")) { + for (RecipePureDaisy recipe : BotaniaAPI.pureDaisyRecipes) { + if (recipe == null) continue; + + arecipes.add(new CachedPureDaisyRecipe(recipe)); + } + } else super.loadCraftingRecipes(outputId, results); + } + + @Override + public void loadCraftingRecipes(ItemStack result) { + for (RecipePureDaisy recipe : BotaniaAPI.pureDaisyRecipes) { + if (recipe == null) continue; + + if (ItemNBTHelper.areStacksSameTypeCraftingWithNBT(new ItemStack(recipe.getOutput()), result)) + arecipes.add(new CachedPureDaisyRecipe(recipe)); + } + } + + @Override + public void loadUsageRecipes(ItemStack ingredient) { + for (RecipePureDaisy recipe : BotaniaAPI.pureDaisyRecipes) { + if (recipe == null) continue; + + CachedPureDaisyRecipe crecipe = new CachedPureDaisyRecipe(recipe); + if (ItemNBTHelper.cachedRecipeContainsWithNBT(crecipe.getIngredients(), ingredient) + || ItemNBTHelper.cachedRecipeContainsWithNBT(crecipe.getOtherStacks(), ingredient)) + arecipes.add(crecipe); + } + } } diff --git a/src/main/java/vazkii/botania/client/integration/nei/recipe/RecipeHandlerRunicAltar.java b/src/main/java/vazkii/botania/client/integration/nei/recipe/RecipeHandlerRunicAltar.java index 506ad540df..b15f972366 100644 --- a/src/main/java/vazkii/botania/client/integration/nei/recipe/RecipeHandlerRunicAltar.java +++ b/src/main/java/vazkii/botania/client/integration/nei/recipe/RecipeHandlerRunicAltar.java @@ -1,7 +1,7 @@ package vazkii.botania.client.integration.nei.recipe; +import codechicken.nei.PositionedStack; import java.util.List; - import net.minecraft.item.ItemStack; import net.minecraft.util.StatCollector; import vazkii.botania.api.BotaniaAPI; @@ -10,48 +10,50 @@ import vazkii.botania.client.core.handler.HUDHandler; import vazkii.botania.common.block.ModBlocks; import vazkii.botania.common.block.tile.mana.TilePool; -import codechicken.nei.PositionedStack; public class RecipeHandlerRunicAltar extends RecipeHandlerPetalApothecary { - public class CachedRunicAltarRecipe extends CachedPetalApothecaryRecipe { - - public int manaUsage; - - public CachedRunicAltarRecipe(RecipeRuneAltar recipe) { - super(recipe, false); - if(recipe == null) - return; - manaUsage = recipe.getManaUsage(); - inputs.add(new PositionedStack(new ItemStack(ModBlocks.runeAltar), 73, 55)); - } - - } - - @Override - public String getRecipeName() { - return StatCollector.translateToLocal("botania.nei.runicAltar"); - } - - @Override - public String getRecipeID() { - return "botania.runicAltar"; - } - - @Override - public void drawBackground(int recipe) { - super.drawBackground(recipe); - HUDHandler.renderManaBar(32, 113, 0x0000FF, 0.75F, ((CachedRunicAltarRecipe) arecipes.get(recipe)).manaUsage, TilePool.MAX_MANA / 10); - } - - @Override - public List getRecipes() { - return BotaniaAPI.runeAltarRecipes; - } - - @Override - public CachedPetalApothecaryRecipe getCachedRecipe(RecipePetals recipe) { - return new CachedRunicAltarRecipe((RecipeRuneAltar) recipe); - } - + public class CachedRunicAltarRecipe extends CachedPetalApothecaryRecipe { + + public int manaUsage; + + public CachedRunicAltarRecipe(RecipeRuneAltar recipe) { + super(recipe, false); + if (recipe == null) return; + manaUsage = recipe.getManaUsage(); + inputs.add(new PositionedStack(new ItemStack(ModBlocks.runeAltar), 73, 55)); + } + } + + @Override + public String getRecipeName() { + return StatCollector.translateToLocal("botania.nei.runicAltar"); + } + + @Override + public String getRecipeID() { + return "botania.runicAltar"; + } + + @Override + public void drawBackground(int recipe) { + super.drawBackground(recipe); + HUDHandler.renderManaBar( + 32, + 113, + 0x0000FF, + 0.75F, + ((CachedRunicAltarRecipe) arecipes.get(recipe)).manaUsage, + TilePool.MAX_MANA / 10); + } + + @Override + public List getRecipes() { + return BotaniaAPI.runeAltarRecipes; + } + + @Override + public CachedPetalApothecaryRecipe getCachedRecipe(RecipePetals recipe) { + return new CachedRunicAltarRecipe((RecipeRuneAltar) recipe); + } } diff --git a/src/main/java/vazkii/botania/client/lib/LibRenderIDs.java b/src/main/java/vazkii/botania/client/lib/LibRenderIDs.java index 75f424b70b..4ddf26fca5 100644 --- a/src/main/java/vazkii/botania/client/lib/LibRenderIDs.java +++ b/src/main/java/vazkii/botania/client/lib/LibRenderIDs.java @@ -2,35 +2,34 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jan 21, 2014, 8:03:06 PM (GMT)] */ package vazkii.botania.client.lib; public final class LibRenderIDs { - public static int idAltar = -1; - public static int idSpecialFlower = -1; - public static int idSpreader = -1; - public static int idPool = -1; - public static int idPylon = -1; - public static int idMiniIsland = -1; - public static int idTinyPotato = -1; - public static int idSpawnerClaw = -1; - public static int idBrewery = -1; - public static int idCorporeaIndex = -1; - public static int idPump = -1; - public static int idDoubleFlower = -1; - public static int idCorporeaCrystalCybe = -1; - public static int idIncensePlate = -1; - public static int idHourglass = -1; - public static int idCocoon = -1; - public static int idLightRelay = -1; - public static int idBellows = -1; - public static int idTeruTeruBozu = -1; - public static int idAvatar = -1; - + public static int idAltar = -1; + public static int idSpecialFlower = -1; + public static int idSpreader = -1; + public static int idPool = -1; + public static int idPylon = -1; + public static int idMiniIsland = -1; + public static int idTinyPotato = -1; + public static int idSpawnerClaw = -1; + public static int idBrewery = -1; + public static int idCorporeaIndex = -1; + public static int idPump = -1; + public static int idDoubleFlower = -1; + public static int idCorporeaCrystalCybe = -1; + public static int idIncensePlate = -1; + public static int idHourglass = -1; + public static int idCocoon = -1; + public static int idLightRelay = -1; + public static int idBellows = -1; + public static int idTeruTeruBozu = -1; + public static int idAvatar = -1; } diff --git a/src/main/java/vazkii/botania/client/lib/LibResources.java b/src/main/java/vazkii/botania/client/lib/LibResources.java index 584d12181a..15d7e26312 100644 --- a/src/main/java/vazkii/botania/client/lib/LibResources.java +++ b/src/main/java/vazkii/botania/client/lib/LibResources.java @@ -2,169 +2,168 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jan 14, 2014, 5:29:31 PM (GMT)] */ package vazkii.botania.client.lib; public final class LibResources { - public static final String PREFIX_MOD = "botania:"; + public static final String PREFIX_MOD = "botania:"; - public static final String PREFIX_LANG = "/assets/botania/lang/"; - public static final String PREFIX_SHADER = "/assets/botania/shader/"; + public static final String PREFIX_LANG = "/assets/botania/lang/"; + public static final String PREFIX_SHADER = "/assets/botania/shader/"; - public static final String PREFIX_GUI = PREFIX_MOD + "textures/gui/"; - public static final String PREFIX_ENTRIES = PREFIX_GUI + "entries/"; - public static final String PREFIX_MODEL = PREFIX_MOD + "textures/model/"; - public static final String PREFIX_MISC = PREFIX_MOD + "textures/misc/"; - public static final String PREFIX_OBJ_MODEL = PREFIX_MOD + "model/"; - public static final String PREFIX_CATEGORIES = PREFIX_GUI + "categories/"; + public static final String PREFIX_GUI = PREFIX_MOD + "textures/gui/"; + public static final String PREFIX_ENTRIES = PREFIX_GUI + "entries/"; + public static final String PREFIX_MODEL = PREFIX_MOD + "textures/model/"; + public static final String PREFIX_MISC = PREFIX_MOD + "textures/misc/"; + public static final String PREFIX_OBJ_MODEL = PREFIX_MOD + "model/"; + public static final String PREFIX_CATEGORIES = PREFIX_GUI + "categories/"; - public static final String EMTPY_TEXTURE = "emptyTexture"; + public static final String EMTPY_TEXTURE = "emptyTexture"; - public static final String GUI_MANA_HUD = PREFIX_GUI + "manaHud.png"; - public static final String GUI_LEXICON = PREFIX_GUI + "lexicon.png"; - public static final String GUI_PAPER = PREFIX_GUI + "paper.png"; - public static final String GUI_CRAFTING_OVERLAY = PREFIX_GUI + "craftingOverlay.png"; - public static final String GUI_MANA_INFUSION_OVERLAY = PREFIX_GUI + "manaInfusionOverlay.png"; - public static final String GUI_PURE_DAISY_OVERLAY = PREFIX_GUI + "pureDaisyOverlay.png"; - public static final String GUI_PETAL_OVERLAY = PREFIX_GUI + "petalOverlay.png"; - public static final String GUI_TERRASTEEL_OVERLAY = PREFIX_GUI + "terrasteelOverlay.png"; - public static final String GUI_ELVEN_TRADE_OVERLAY = PREFIX_GUI + "elvenTradeOverlay.png"; - public static final String GUI_SHEDDING_OVERLAY = PREFIX_GUI + "sheddingOverlay.png"; - public static final String GUI_MULTIBLOCK_OVERLAY = PREFIX_GUI + "multiblockOverlay.png"; - public static final String GUI_CREATIVE = "botania.png"; - public static final String GUI_TOFF = PREFIX_GUI + "toff.png"; - public static final String GUI_BOSS_BAR = PREFIX_GUI + "bossBar.png"; - public static final String GUI_POTIONS = PREFIX_GUI + "potions.png"; - public static final String GUI_NEI_BLANK = PREFIX_GUI + "neiBlank.png"; - public static final String GUI_NEI_BREWERY = PREFIX_GUI + "neiBrewery.png"; - public static final String GUI_FLOWER_BAG = PREFIX_GUI + "flowerBag.png"; - public static final String GUI_BAUBLE_BOX = PREFIX_GUI + "baubleBox.png"; - public static final String GUI_HUD_ICONS = PREFIX_GUI + "hudIcons.png"; - public static final String GUI_STENCIL = PREFIX_GUI + "stencil.png"; - public static final String GUI_DOG = PREFIX_GUI + "dog.png"; - public static final String GUI_FLOWEY = PREFIX_GUI + "flowey.png"; + public static final String GUI_MANA_HUD = PREFIX_GUI + "manaHud.png"; + public static final String GUI_LEXICON = PREFIX_GUI + "lexicon.png"; + public static final String GUI_PAPER = PREFIX_GUI + "paper.png"; + public static final String GUI_CRAFTING_OVERLAY = PREFIX_GUI + "craftingOverlay.png"; + public static final String GUI_MANA_INFUSION_OVERLAY = PREFIX_GUI + "manaInfusionOverlay.png"; + public static final String GUI_PURE_DAISY_OVERLAY = PREFIX_GUI + "pureDaisyOverlay.png"; + public static final String GUI_PETAL_OVERLAY = PREFIX_GUI + "petalOverlay.png"; + public static final String GUI_TERRASTEEL_OVERLAY = PREFIX_GUI + "terrasteelOverlay.png"; + public static final String GUI_ELVEN_TRADE_OVERLAY = PREFIX_GUI + "elvenTradeOverlay.png"; + public static final String GUI_SHEDDING_OVERLAY = PREFIX_GUI + "sheddingOverlay.png"; + public static final String GUI_MULTIBLOCK_OVERLAY = PREFIX_GUI + "multiblockOverlay.png"; + public static final String GUI_CREATIVE = "botania.png"; + public static final String GUI_TOFF = PREFIX_GUI + "toff.png"; + public static final String GUI_BOSS_BAR = PREFIX_GUI + "bossBar.png"; + public static final String GUI_POTIONS = PREFIX_GUI + "potions.png"; + public static final String GUI_NEI_BLANK = PREFIX_GUI + "neiBlank.png"; + public static final String GUI_NEI_BREWERY = PREFIX_GUI + "neiBrewery.png"; + public static final String GUI_FLOWER_BAG = PREFIX_GUI + "flowerBag.png"; + public static final String GUI_BAUBLE_BOX = PREFIX_GUI + "baubleBox.png"; + public static final String GUI_HUD_ICONS = PREFIX_GUI + "hudIcons.png"; + public static final String GUI_STENCIL = PREFIX_GUI + "stencil.png"; + public static final String GUI_DOG = PREFIX_GUI + "dog.png"; + public static final String GUI_FLOWEY = PREFIX_GUI + "flowey.png"; - public static final String ENTRY_FLOWERS = PREFIX_ENTRIES + "flowers.png"; - public static final String ENTRY_APOTHECARY = PREFIX_ENTRIES + "apothecary.png"; - public static final String ENTRY_PURE_DAISY = PREFIX_ENTRIES + "pureDaisy.png"; - public static final String ENTRY_SPREADER = PREFIX_ENTRIES + "spreader.png"; - public static final String ENTRY_UNSTABLE_BLOCK = PREFIX_ENTRIES + "unstableBlock.png"; - public static final String ENTRY_UNSTABLE_BEACON = PREFIX_ENTRIES + "unstableBeacon.png"; - public static final String ENTRY_BAUBLES = PREFIX_ENTRIES + "baubles.png"; - public static final String ENTRY_ELVEN_GARDE = PREFIX_ENTRIES + "elvenGarde.png"; - public static final String ENTRY_DIMINISHING_RETURNS = PREFIX_ENTRIES + "diminishingReturns.png"; - public static final String ENTRY_HYDROANGEAS = PREFIX_ENTRIES + "hydroangeas.png"; - public static final String ENTRY_CRAFT_CRATE = PREFIX_ENTRIES + "craftCrate.png"; - public static final String ENTRY_AZULEJOS = PREFIX_ENTRIES + "azulejos.png"; - public static final String ENTRY_METAMORPHIC_STONES = PREFIX_ENTRIES + "metamorphicStones.png"; - public static final String ENTRY_BANNERS = PREFIX_ENTRIES + "banners.png"; + public static final String ENTRY_FLOWERS = PREFIX_ENTRIES + "flowers.png"; + public static final String ENTRY_APOTHECARY = PREFIX_ENTRIES + "apothecary.png"; + public static final String ENTRY_PURE_DAISY = PREFIX_ENTRIES + "pureDaisy.png"; + public static final String ENTRY_SPREADER = PREFIX_ENTRIES + "spreader.png"; + public static final String ENTRY_UNSTABLE_BLOCK = PREFIX_ENTRIES + "unstableBlock.png"; + public static final String ENTRY_UNSTABLE_BEACON = PREFIX_ENTRIES + "unstableBeacon.png"; + public static final String ENTRY_BAUBLES = PREFIX_ENTRIES + "baubles.png"; + public static final String ENTRY_ELVEN_GARDE = PREFIX_ENTRIES + "elvenGarde.png"; + public static final String ENTRY_DIMINISHING_RETURNS = PREFIX_ENTRIES + "diminishingReturns.png"; + public static final String ENTRY_HYDROANGEAS = PREFIX_ENTRIES + "hydroangeas.png"; + public static final String ENTRY_CRAFT_CRATE = PREFIX_ENTRIES + "craftCrate.png"; + public static final String ENTRY_AZULEJOS = PREFIX_ENTRIES + "azulejos.png"; + public static final String ENTRY_METAMORPHIC_STONES = PREFIX_ENTRIES + "metamorphicStones.png"; + public static final String ENTRY_BANNERS = PREFIX_ENTRIES + "banners.png"; - public static final String MODEL_ALTAR = PREFIX_MODEL + "altar.png"; - public static final String MODEL_ALTAR_META = PREFIX_MODEL + "altarMeta%d.png"; - public static final String MODEL_ALTAR_MOSSY = PREFIX_MODEL + "altarMossy.png"; - public static final String MODEL_SPREADER = PREFIX_MODEL + "spreader.png"; - public static final String MODEL_SPREADER_REDSTONE = PREFIX_MODEL + "spreaderRedstone.png"; - public static final String MODEL_SPREADER_DREAMWOOD = PREFIX_MODEL + "spreaderDreamwood.png"; - public static final String MODEL_SPREADER_HALLOWEEN = PREFIX_MODEL + "spreader_halloween.png"; - public static final String MODEL_SPREADER_REDSTONE_HALLOWEEN = PREFIX_MODEL + "spreaderRedstone_halloween.png"; - public static final String MODEL_SPREADER_DREAMWOOD_HALLOWEEN = PREFIX_MODEL + "spreaderDreamwood_halloween.png"; - public static final String MODEL_POOL = PREFIX_MODEL + "pool.png"; - public static final String MODEL_INFINITE_POOL = PREFIX_MODEL + "infinitePool.png"; - public static final String MODEL_DILUTED_POOL = PREFIX_MODEL + "dilutedPool.png"; - public static final String MODEL_PYLON_OLD = PREFIX_MODEL + "pylonOld.png"; - public static final String MODEL_PYLON = PREFIX_MODEL + "pylon.png"; - public static final String MODEL_PYLON_GREEN_OLD = PREFIX_MODEL + "pylonOld1.png"; - public static final String MODEL_PYLON_GREEN = PREFIX_MODEL + "pylon1.png"; - public static final String MODEL_PYLON_PINK_OLD = PREFIX_MODEL + "pylonOld2.png"; - public static final String MODEL_PYLON_PINK = PREFIX_MODEL + "pylon2.png"; - public static final String MODEL_LEXICA = PREFIX_MODEL + "lexica.png"; - public static final String MODEL_MANASTEEL_0 = PREFIX_MODEL + "manasteel0.png"; - public static final String MODEL_MANASTEEL_1 = PREFIX_MODEL + "manasteel1.png"; - public static final String MODEL_MANASTEEL_2 = PREFIX_MODEL + "manasteel2.png"; - public static final String MODEL_MANASTEEL_NEW = PREFIX_MODEL + "manasteelNew.png"; - public static final String MODEL_TERRASTEEL_0 = PREFIX_MODEL + "terrasteel0.png"; - public static final String MODEL_TERRASTEEL_1 = PREFIX_MODEL + "terrasteel1.png"; - public static final String MODEL_TERRASTEEL_2 = PREFIX_MODEL + "terrasteel2.png"; - public static final String MODEL_TERRASTEEL_NEW = PREFIX_MODEL + "terrasteelNew.png"; - public static final String MODEL_ELEMENTIUM_0 = PREFIX_MODEL + "elementium0.png"; - public static final String MODEL_ELEMENTIUM_1 = PREFIX_MODEL + "elementium1.png"; - public static final String MODEL_ELEMENTIUM_2 = PREFIX_MODEL + "elementium2.png"; - public static final String MODEL_ELEMENTIUM_NEW = PREFIX_MODEL + "elementiumNew.png"; - public static final String MODEL_MANAWEAVE_0 = PREFIX_MODEL + "manaweave0.png"; - public static final String MODEL_MANAWEAVE_1 = PREFIX_MODEL + "manaweave1.png"; - public static final String MODEL_MANAWEAVE_NEW = PREFIX_MODEL + "manaweaveNew.png"; - public static final String MODEL_MANAWEAVE_NEW_HOLIDAY = PREFIX_MODEL + "manaweaveNewHoliday.png"; - public static final String MODEL_PIXIE = PREFIX_MODEL + "pixie.png"; - public static final String MODEL_TINY_POTATO = PREFIX_MODEL + "tinyPotato.png"; - public static final String MODEL_TINY_POTATO_GS = PREFIX_MODEL + "tinyPotatoGray.png"; - public static final String MODEL_TINY_POTATO_HALLOWEEN = PREFIX_MODEL + "tinyPotato_halloween.png"; - public static final String MODEL_SPAWNER_CLAW = PREFIX_MODEL + "spawnerClaw.png"; - public static final String MODEL_BREWERY = PREFIX_MODEL + "brewery.png"; - public static final String MODEL_TRAVEL_BELT = PREFIX_MODEL + "travelBelt.png"; - public static final String MODEL_SUPER_TRAVEL_BELT = PREFIX_MODEL + "superTravelBelt.png"; - public static final String MODEL_SPEED_UP_BELT = PREFIX_MODEL + "speedUpBelt.png"; - public static final String MODEL_KNOCKBACK_BELT = PREFIX_MODEL + "knockbackBelt.png"; - public static final String MODEL_HOLY_CLOAK = PREFIX_MODEL + "holyCloak.png"; - public static final String MODEL_UNHOLY_CLOAK = PREFIX_MODEL + "unholyCloak.png"; - public static final String MODEL_CORPOREA_INDEX = PREFIX_MODEL + "corporeaIndex.png"; - public static final String MODEL_INVISIBLE_ARMOR = PREFIX_MODEL + "invisibleArmor.png"; - public static final String MODEL_PUMP = PREFIX_MODEL + "pump.png"; - public static final String MODEL_MINI_ISLAND = PREFIX_MODEL + "miniIsland.png"; - public static final String MODEL_MINI_ISLAND_PODZOL = PREFIX_MODEL + "miniIslandPodzol.png"; - public static final String MODEL_MINI_ISLAND_MYCEL = PREFIX_MODEL + "miniIslandMycelium.png"; - public static final String MODEL_MINI_ISLAND_SNOW = PREFIX_MODEL + "miniIslandSnow.png"; - public static final String MODEL_MINI_ISLAND_DRY = PREFIX_MODEL + "miniIslandDry.png"; - public static final String MODEL_MINI_ISLAND_GOLDEN = PREFIX_MODEL + "miniIslandGolden.png"; - public static final String MODEL_MINI_ISLAND_VIVID = PREFIX_MODEL + "miniIslandVivid.png"; - public static final String MODEL_MINI_ISLAND_SCORCHED = PREFIX_MODEL + "miniIslandScorched.png"; - public static final String MODEL_MINI_ISLAND_INFUSED = PREFIX_MODEL + "miniIslandInfused.png"; - public static final String MODEL_MINI_ISLAND_MUTATED = PREFIX_MODEL + "miniIslandMutated.png"; - public static final String MODEL_PINK_WITHER = PREFIX_MODEL + "pinkWither.png"; - public static final String MODEL_CRYSTAL_CUBE = PREFIX_MODEL + "crystalCube.png"; - public static final String MODEL_INCENSE_PLATE = PREFIX_MODEL + "incensePlate.png"; - public static final String MODEL_HOURGLASS = PREFIX_MODEL + "hourglass.png"; - public static final String MODEL_COCOON = PREFIX_MODEL + "cocoon.png"; - public static final String MODEL_BELLOWS = PREFIX_MODEL + "bellows.png"; - public static final String MODEL_TERU_TERU_BOZU = PREFIX_MODEL + "teruTeruBozu.png"; - public static final String MODEL_TERU_TERU_BOZU_HALLOWEEN = PREFIX_MODEL + "teruTeruBozu_halloween.png"; - public static final String MODEL_AVATAR = PREFIX_MODEL + "avatar.png"; - public static final String MODEL_AVATAR_DIVINING = PREFIX_MODEL + "avatarDivining.png"; - public static final String MODEL_AVATAR_FIRE = PREFIX_MODEL + "avatarFire.png"; - public static final String MODEL_AVATAR_MISSILE = PREFIX_MODEL + "avatarMissile.png"; - public static final String MODEL_AVATAR_RAINBOW = PREFIX_MODEL + "avatarRainbow.png"; - public static final String MODEL_AVATAR_TORNADO = PREFIX_MODEL + "avatarTornado.png"; + public static final String MODEL_ALTAR = PREFIX_MODEL + "altar.png"; + public static final String MODEL_ALTAR_META = PREFIX_MODEL + "altarMeta%d.png"; + public static final String MODEL_ALTAR_MOSSY = PREFIX_MODEL + "altarMossy.png"; + public static final String MODEL_SPREADER = PREFIX_MODEL + "spreader.png"; + public static final String MODEL_SPREADER_REDSTONE = PREFIX_MODEL + "spreaderRedstone.png"; + public static final String MODEL_SPREADER_DREAMWOOD = PREFIX_MODEL + "spreaderDreamwood.png"; + public static final String MODEL_SPREADER_HALLOWEEN = PREFIX_MODEL + "spreader_halloween.png"; + public static final String MODEL_SPREADER_REDSTONE_HALLOWEEN = PREFIX_MODEL + "spreaderRedstone_halloween.png"; + public static final String MODEL_SPREADER_DREAMWOOD_HALLOWEEN = PREFIX_MODEL + "spreaderDreamwood_halloween.png"; + public static final String MODEL_POOL = PREFIX_MODEL + "pool.png"; + public static final String MODEL_INFINITE_POOL = PREFIX_MODEL + "infinitePool.png"; + public static final String MODEL_DILUTED_POOL = PREFIX_MODEL + "dilutedPool.png"; + public static final String MODEL_PYLON_OLD = PREFIX_MODEL + "pylonOld.png"; + public static final String MODEL_PYLON = PREFIX_MODEL + "pylon.png"; + public static final String MODEL_PYLON_GREEN_OLD = PREFIX_MODEL + "pylonOld1.png"; + public static final String MODEL_PYLON_GREEN = PREFIX_MODEL + "pylon1.png"; + public static final String MODEL_PYLON_PINK_OLD = PREFIX_MODEL + "pylonOld2.png"; + public static final String MODEL_PYLON_PINK = PREFIX_MODEL + "pylon2.png"; + public static final String MODEL_LEXICA = PREFIX_MODEL + "lexica.png"; + public static final String MODEL_MANASTEEL_0 = PREFIX_MODEL + "manasteel0.png"; + public static final String MODEL_MANASTEEL_1 = PREFIX_MODEL + "manasteel1.png"; + public static final String MODEL_MANASTEEL_2 = PREFIX_MODEL + "manasteel2.png"; + public static final String MODEL_MANASTEEL_NEW = PREFIX_MODEL + "manasteelNew.png"; + public static final String MODEL_TERRASTEEL_0 = PREFIX_MODEL + "terrasteel0.png"; + public static final String MODEL_TERRASTEEL_1 = PREFIX_MODEL + "terrasteel1.png"; + public static final String MODEL_TERRASTEEL_2 = PREFIX_MODEL + "terrasteel2.png"; + public static final String MODEL_TERRASTEEL_NEW = PREFIX_MODEL + "terrasteelNew.png"; + public static final String MODEL_ELEMENTIUM_0 = PREFIX_MODEL + "elementium0.png"; + public static final String MODEL_ELEMENTIUM_1 = PREFIX_MODEL + "elementium1.png"; + public static final String MODEL_ELEMENTIUM_2 = PREFIX_MODEL + "elementium2.png"; + public static final String MODEL_ELEMENTIUM_NEW = PREFIX_MODEL + "elementiumNew.png"; + public static final String MODEL_MANAWEAVE_0 = PREFIX_MODEL + "manaweave0.png"; + public static final String MODEL_MANAWEAVE_1 = PREFIX_MODEL + "manaweave1.png"; + public static final String MODEL_MANAWEAVE_NEW = PREFIX_MODEL + "manaweaveNew.png"; + public static final String MODEL_MANAWEAVE_NEW_HOLIDAY = PREFIX_MODEL + "manaweaveNewHoliday.png"; + public static final String MODEL_PIXIE = PREFIX_MODEL + "pixie.png"; + public static final String MODEL_TINY_POTATO = PREFIX_MODEL + "tinyPotato.png"; + public static final String MODEL_TINY_POTATO_GS = PREFIX_MODEL + "tinyPotatoGray.png"; + public static final String MODEL_TINY_POTATO_HALLOWEEN = PREFIX_MODEL + "tinyPotato_halloween.png"; + public static final String MODEL_SPAWNER_CLAW = PREFIX_MODEL + "spawnerClaw.png"; + public static final String MODEL_BREWERY = PREFIX_MODEL + "brewery.png"; + public static final String MODEL_TRAVEL_BELT = PREFIX_MODEL + "travelBelt.png"; + public static final String MODEL_SUPER_TRAVEL_BELT = PREFIX_MODEL + "superTravelBelt.png"; + public static final String MODEL_SPEED_UP_BELT = PREFIX_MODEL + "speedUpBelt.png"; + public static final String MODEL_KNOCKBACK_BELT = PREFIX_MODEL + "knockbackBelt.png"; + public static final String MODEL_HOLY_CLOAK = PREFIX_MODEL + "holyCloak.png"; + public static final String MODEL_UNHOLY_CLOAK = PREFIX_MODEL + "unholyCloak.png"; + public static final String MODEL_CORPOREA_INDEX = PREFIX_MODEL + "corporeaIndex.png"; + public static final String MODEL_INVISIBLE_ARMOR = PREFIX_MODEL + "invisibleArmor.png"; + public static final String MODEL_PUMP = PREFIX_MODEL + "pump.png"; + public static final String MODEL_MINI_ISLAND = PREFIX_MODEL + "miniIsland.png"; + public static final String MODEL_MINI_ISLAND_PODZOL = PREFIX_MODEL + "miniIslandPodzol.png"; + public static final String MODEL_MINI_ISLAND_MYCEL = PREFIX_MODEL + "miniIslandMycelium.png"; + public static final String MODEL_MINI_ISLAND_SNOW = PREFIX_MODEL + "miniIslandSnow.png"; + public static final String MODEL_MINI_ISLAND_DRY = PREFIX_MODEL + "miniIslandDry.png"; + public static final String MODEL_MINI_ISLAND_GOLDEN = PREFIX_MODEL + "miniIslandGolden.png"; + public static final String MODEL_MINI_ISLAND_VIVID = PREFIX_MODEL + "miniIslandVivid.png"; + public static final String MODEL_MINI_ISLAND_SCORCHED = PREFIX_MODEL + "miniIslandScorched.png"; + public static final String MODEL_MINI_ISLAND_INFUSED = PREFIX_MODEL + "miniIslandInfused.png"; + public static final String MODEL_MINI_ISLAND_MUTATED = PREFIX_MODEL + "miniIslandMutated.png"; + public static final String MODEL_PINK_WITHER = PREFIX_MODEL + "pinkWither.png"; + public static final String MODEL_CRYSTAL_CUBE = PREFIX_MODEL + "crystalCube.png"; + public static final String MODEL_INCENSE_PLATE = PREFIX_MODEL + "incensePlate.png"; + public static final String MODEL_HOURGLASS = PREFIX_MODEL + "hourglass.png"; + public static final String MODEL_COCOON = PREFIX_MODEL + "cocoon.png"; + public static final String MODEL_BELLOWS = PREFIX_MODEL + "bellows.png"; + public static final String MODEL_TERU_TERU_BOZU = PREFIX_MODEL + "teruTeruBozu.png"; + public static final String MODEL_TERU_TERU_BOZU_HALLOWEEN = PREFIX_MODEL + "teruTeruBozu_halloween.png"; + public static final String MODEL_AVATAR = PREFIX_MODEL + "avatar.png"; + public static final String MODEL_AVATAR_DIVINING = PREFIX_MODEL + "avatarDivining.png"; + public static final String MODEL_AVATAR_FIRE = PREFIX_MODEL + "avatarFire.png"; + public static final String MODEL_AVATAR_MISSILE = PREFIX_MODEL + "avatarMissile.png"; + public static final String MODEL_AVATAR_RAINBOW = PREFIX_MODEL + "avatarRainbow.png"; + public static final String MODEL_AVATAR_TORNADO = PREFIX_MODEL + "avatarTornado.png"; - public static final String MISC_PARTICLES = PREFIX_MISC + "particles.png"; - public static final String MISC_WISP_LARGE = PREFIX_MISC + "wispLarge.png"; - public static final String MISC_WISP_SMALL = PREFIX_MISC + "wispSmall.png"; - public static final String MISC_HALO = PREFIX_MISC + "halo.png"; - public static final String MISC_GLOW_GREEN = PREFIX_MISC + "glow0.png"; - public static final String MISC_GLOW_CYAN = PREFIX_MISC + "glow1.png"; - public static final String MISC_BABYLON = PREFIX_MISC + "babylon.png"; - public static final String MISC_SKYBOX = PREFIX_MISC + "skybox.png"; - public static final String MISC_RAINBOW = PREFIX_MISC + "rainbow.png"; - public static final String MISC_PLANET = PREFIX_MISC + "planet"; + public static final String MISC_PARTICLES = PREFIX_MISC + "particles.png"; + public static final String MISC_WISP_LARGE = PREFIX_MISC + "wispLarge.png"; + public static final String MISC_WISP_SMALL = PREFIX_MISC + "wispSmall.png"; + public static final String MISC_HALO = PREFIX_MISC + "halo.png"; + public static final String MISC_GLOW_GREEN = PREFIX_MISC + "glow0.png"; + public static final String MISC_GLOW_CYAN = PREFIX_MISC + "glow1.png"; + public static final String MISC_BABYLON = PREFIX_MISC + "babylon.png"; + public static final String MISC_SKYBOX = PREFIX_MISC + "skybox.png"; + public static final String MISC_RAINBOW = PREFIX_MISC + "rainbow.png"; + public static final String MISC_PLANET = PREFIX_MISC + "planet"; - public static final String OBJ_MODEL_PYLON = PREFIX_OBJ_MODEL + "pylon.obj"; + public static final String OBJ_MODEL_PYLON = PREFIX_OBJ_MODEL + "pylon.obj"; - public static final String CATEGORY_INDEX = PREFIX_CATEGORIES + "index.png"; - - public static final String SHADER_PYLON_GLOW_FRAG = PREFIX_SHADER + "pylon_glow.frag"; - public static final String SHADER_ENCHANTER_RUNE_FRAG = PREFIX_SHADER + "enchanter_rune.frag"; - public static final String SHADER_MANA_POOL_FRAG = PREFIX_SHADER + "mana_pool.frag"; - public static final String SHADER_DOPLLEGANGER_VERT = PREFIX_SHADER + "doppleganger.vert"; - public static final String SHADER_DOPLLEGANGER_FRAG = PREFIX_SHADER + "doppleganger.frag"; - public static final String SHADER_HALO_FRAG = PREFIX_SHADER + "halo.frag"; - public static final String SHADER_DOPLLEGANGER_BAR_FRAG = PREFIX_SHADER + "doppleganger_bar.frag"; - public static final String SHADER_TERRA_PLATE_RUNE_FRAG = PREFIX_SHADER + "terra_plate_rune.frag"; - public static final String SHADER_FILM_GRAIN_FRAG = PREFIX_SHADER + "film_grain.frag"; - public static final String SHADER_GOLD_FRAG = PREFIX_SHADER + "gold.frag"; - public static final String SHADER_CATEGORY_BUTTON_FRAG = PREFIX_SHADER + "category_button.frag"; + public static final String CATEGORY_INDEX = PREFIX_CATEGORIES + "index.png"; + public static final String SHADER_PYLON_GLOW_FRAG = PREFIX_SHADER + "pylon_glow.frag"; + public static final String SHADER_ENCHANTER_RUNE_FRAG = PREFIX_SHADER + "enchanter_rune.frag"; + public static final String SHADER_MANA_POOL_FRAG = PREFIX_SHADER + "mana_pool.frag"; + public static final String SHADER_DOPLLEGANGER_VERT = PREFIX_SHADER + "doppleganger.vert"; + public static final String SHADER_DOPLLEGANGER_FRAG = PREFIX_SHADER + "doppleganger.frag"; + public static final String SHADER_HALO_FRAG = PREFIX_SHADER + "halo.frag"; + public static final String SHADER_DOPLLEGANGER_BAR_FRAG = PREFIX_SHADER + "doppleganger_bar.frag"; + public static final String SHADER_TERRA_PLATE_RUNE_FRAG = PREFIX_SHADER + "terra_plate_rune.frag"; + public static final String SHADER_FILM_GRAIN_FRAG = PREFIX_SHADER + "film_grain.frag"; + public static final String SHADER_GOLD_FRAG = PREFIX_SHADER + "gold.frag"; + public static final String SHADER_CATEGORY_BUTTON_FRAG = PREFIX_SHADER + "category_button.frag"; } diff --git a/src/main/java/vazkii/botania/client/model/IPylonModel.java b/src/main/java/vazkii/botania/client/model/IPylonModel.java index c795092a56..d3a2f9e1a1 100644 --- a/src/main/java/vazkii/botania/client/model/IPylonModel.java +++ b/src/main/java/vazkii/botania/client/model/IPylonModel.java @@ -2,18 +2,19 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Apr 1, 2014, 6:23:24 PM (GMT)] */ package vazkii.botania.client.model; public interface IPylonModel { - public void renderCrystal(); - public void renderRing(); - public void renderGems(); + public void renderCrystal(); + public void renderRing(); + + public void renderGems(); } diff --git a/src/main/java/vazkii/botania/client/model/ModelAltar.java b/src/main/java/vazkii/botania/client/model/ModelAltar.java index b8827a24d3..e4c65cbbc6 100644 --- a/src/main/java/vazkii/botania/client/model/ModelAltar.java +++ b/src/main/java/vazkii/botania/client/model/ModelAltar.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jan 21, 2014, 7:56:15 PM (GMT)] */ package vazkii.botania.client.model; @@ -15,74 +15,74 @@ public class ModelAltar extends ModelBase { - ModelRenderer gobletBase; - ModelRenderer gobletBase2; - ModelRenderer gobletBase3; - ModelRenderer gobletStand; - ModelRenderer kelkBase; - ModelRenderer kelkBase2; - ModelRenderer kelkWall1; - ModelRenderer kelkWall2; - ModelRenderer kelkWall3; - ModelRenderer kelkWall4; + ModelRenderer gobletBase; + ModelRenderer gobletBase2; + ModelRenderer gobletBase3; + ModelRenderer gobletStand; + ModelRenderer kelkBase; + ModelRenderer kelkBase2; + ModelRenderer kelkWall1; + ModelRenderer kelkWall2; + ModelRenderer kelkWall3; + ModelRenderer kelkWall4; - public ModelAltar() { - textureWidth = 256; - textureHeight = 128; + public ModelAltar() { + textureWidth = 256; + textureHeight = 128; - gobletBase = new ModelRenderer(this, 0, 0); - gobletBase.addBox(0F, 0F, 0F, 16, 2, 16); - gobletBase.setRotationPoint(-8F, 22F, -8F); - gobletBase.setTextureSize(256, 128); - gobletBase2 = new ModelRenderer(this, 0, 18); - gobletBase2.addBox(0F, 0F, 0F, 14, 1, 14); - gobletBase2.setRotationPoint(-7F, 21F, -7F); - gobletBase2.setTextureSize(256, 128); - gobletStand = new ModelRenderer(this, 68, 0); - gobletStand.addBox(0F, 0F, 0F, 6, 8, 6); - gobletStand.setRotationPoint(-3F, 12F, -3F); - gobletStand.setTextureSize(256, 128); - gobletBase3 = new ModelRenderer(this, 0, 33); - gobletBase3.addBox(0F, 0F, 0F, 12, 1, 12); - gobletBase3.setRotationPoint(-6F, 20F, -6F); - gobletBase3.setTextureSize(256, 128); - kelkBase = new ModelRenderer(this, 72, 45); - kelkBase.addBox(0F, 0F, 0F, 8, 1, 8); - kelkBase.setRotationPoint(-4F, 11F, -4F); - kelkBase.setTextureSize(256, 128); - kelkBase2 = new ModelRenderer(this, 72, 34); - kelkBase2.addBox(0F, 0F, 0F, 10, 1, 10); - kelkBase2.setRotationPoint(-5F, 10F, -5F); - kelkBase2.setTextureSize(256, 128); - kelkWall1 = new ModelRenderer(this, 72, 18); - kelkWall1.addBox(0F, 0F, 0F, 1, 6, 10); - kelkWall1.setRotationPoint(5F, 4F, -5F); - kelkWall1.setTextureSize(256, 128); - kelkWall2 = new ModelRenderer(this, 72, 18); - kelkWall2.addBox(0F, 0F, 0F, 1, 6, 10); - kelkWall2.setRotationPoint(-6F, 4F, -5F); - kelkWall2.setTextureSize(256, 128); - kelkWall3 = new ModelRenderer(this, 94, 18); - kelkWall3.addBox(0F, 0F, 0F, 10, 6, 1); - kelkWall3.setRotationPoint(-5F, 4F, 5F); - kelkWall3.setTextureSize(256, 128); - kelkWall4 = new ModelRenderer(this, 94, 18); - kelkWall4.addBox(0F, 0F, 0F, 10, 6, 1); - kelkWall4.setRotationPoint(-5F, 4F, -6F); - kelkWall4.setTextureSize(256, 128); - } + gobletBase = new ModelRenderer(this, 0, 0); + gobletBase.addBox(0F, 0F, 0F, 16, 2, 16); + gobletBase.setRotationPoint(-8F, 22F, -8F); + gobletBase.setTextureSize(256, 128); + gobletBase2 = new ModelRenderer(this, 0, 18); + gobletBase2.addBox(0F, 0F, 0F, 14, 1, 14); + gobletBase2.setRotationPoint(-7F, 21F, -7F); + gobletBase2.setTextureSize(256, 128); + gobletStand = new ModelRenderer(this, 68, 0); + gobletStand.addBox(0F, 0F, 0F, 6, 8, 6); + gobletStand.setRotationPoint(-3F, 12F, -3F); + gobletStand.setTextureSize(256, 128); + gobletBase3 = new ModelRenderer(this, 0, 33); + gobletBase3.addBox(0F, 0F, 0F, 12, 1, 12); + gobletBase3.setRotationPoint(-6F, 20F, -6F); + gobletBase3.setTextureSize(256, 128); + kelkBase = new ModelRenderer(this, 72, 45); + kelkBase.addBox(0F, 0F, 0F, 8, 1, 8); + kelkBase.setRotationPoint(-4F, 11F, -4F); + kelkBase.setTextureSize(256, 128); + kelkBase2 = new ModelRenderer(this, 72, 34); + kelkBase2.addBox(0F, 0F, 0F, 10, 1, 10); + kelkBase2.setRotationPoint(-5F, 10F, -5F); + kelkBase2.setTextureSize(256, 128); + kelkWall1 = new ModelRenderer(this, 72, 18); + kelkWall1.addBox(0F, 0F, 0F, 1, 6, 10); + kelkWall1.setRotationPoint(5F, 4F, -5F); + kelkWall1.setTextureSize(256, 128); + kelkWall2 = new ModelRenderer(this, 72, 18); + kelkWall2.addBox(0F, 0F, 0F, 1, 6, 10); + kelkWall2.setRotationPoint(-6F, 4F, -5F); + kelkWall2.setTextureSize(256, 128); + kelkWall3 = new ModelRenderer(this, 94, 18); + kelkWall3.addBox(0F, 0F, 0F, 10, 6, 1); + kelkWall3.setRotationPoint(-5F, 4F, 5F); + kelkWall3.setTextureSize(256, 128); + kelkWall4 = new ModelRenderer(this, 94, 18); + kelkWall4.addBox(0F, 0F, 0F, 10, 6, 1); + kelkWall4.setRotationPoint(-5F, 4F, -6F); + kelkWall4.setTextureSize(256, 128); + } - public void render() { - float f = 1F / 16F; - gobletBase.render(f); - gobletBase2.render(f); - gobletBase3.render(f); - gobletStand.render(f); - kelkBase.render(f); - kelkBase2.render(f); - kelkWall1.render(f); - kelkWall2.render(f); - kelkWall3.render(f); - kelkWall4.render(f); - } + public void render() { + float f = 1F / 16F; + gobletBase.render(f); + gobletBase2.render(f); + gobletBase3.render(f); + gobletStand.render(f); + kelkBase.render(f); + kelkBase2.render(f); + kelkWall1.render(f); + kelkWall2.render(f); + kelkWall3.render(f); + kelkWall4.render(f); + } } diff --git a/src/main/java/vazkii/botania/client/model/ModelAvatar.java b/src/main/java/vazkii/botania/client/model/ModelAvatar.java index 934471b34a..c3b20f90ff 100644 --- a/src/main/java/vazkii/botania/client/model/ModelAvatar.java +++ b/src/main/java/vazkii/botania/client/model/ModelAvatar.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [? (GMT)] */ package vazkii.botania.client.model; @@ -15,54 +15,53 @@ public class ModelAvatar extends ModelBase { - public ModelRenderer body; - public ModelRenderer rightarm; - public ModelRenderer leftarm; - public ModelRenderer rightleg; - public ModelRenderer leftleg; - public ModelRenderer head; + public ModelRenderer body; + public ModelRenderer rightarm; + public ModelRenderer leftarm; + public ModelRenderer rightleg; + public ModelRenderer leftleg; + public ModelRenderer head; - public ModelAvatar() { - textureWidth = 32; - textureHeight = 32; - leftleg = new ModelRenderer(this, 0, 20); - leftleg.mirror = true; - leftleg.setRotationPoint(1.5F, 18.0F, -0.5F); - leftleg.addBox(-1.5F, 0.0F, -1.5F, 3, 6, 3, 0.0F); - rightarm = new ModelRenderer(this, 0, 20); - rightarm.setRotationPoint(-3.0F, 15.0F, -1.0F); - rightarm.addBox(-2.0F, -1.0F, -1.0F, 2, 6, 3, 0.0F); - setRotateAngle(rightarm, 0.0F, -0.0F, 0.08726646259971647F); - leftarm = new ModelRenderer(this, 0, 20); - leftarm.mirror = true; - leftarm.setRotationPoint(3.0F, 15.0F, -1.0F); - leftarm.addBox(0.0F, -1.0F, -1.0F, 2, 6, 3, 0.0F); - setRotateAngle(leftarm, 0.0F, -0.0F, -0.08726646259971647F); - head = new ModelRenderer(this, 0, 0); - head.setRotationPoint(0.0F, 14.0F, 0.0F); - head.addBox(-3.0F, -6.0F, -3.0F, 6, 6, 6, 0.0F); - rightleg = new ModelRenderer(this, 0, 20); - rightleg.setRotationPoint(-1.5F, 18.0F, -0.5F); - rightleg.addBox(-1.5F, 0.0F, -1.5F, 3, 6, 3, 0.0F); - body = new ModelRenderer(this, 0, 12); - body.setRotationPoint(0.0F, 14.0F, 0.0F); - body.addBox(-3.0F, 0.0F, -2.0F, 6, 4, 4, 0.0F); - } + public ModelAvatar() { + textureWidth = 32; + textureHeight = 32; + leftleg = new ModelRenderer(this, 0, 20); + leftleg.mirror = true; + leftleg.setRotationPoint(1.5F, 18.0F, -0.5F); + leftleg.addBox(-1.5F, 0.0F, -1.5F, 3, 6, 3, 0.0F); + rightarm = new ModelRenderer(this, 0, 20); + rightarm.setRotationPoint(-3.0F, 15.0F, -1.0F); + rightarm.addBox(-2.0F, -1.0F, -1.0F, 2, 6, 3, 0.0F); + setRotateAngle(rightarm, 0.0F, -0.0F, 0.08726646259971647F); + leftarm = new ModelRenderer(this, 0, 20); + leftarm.mirror = true; + leftarm.setRotationPoint(3.0F, 15.0F, -1.0F); + leftarm.addBox(0.0F, -1.0F, -1.0F, 2, 6, 3, 0.0F); + setRotateAngle(leftarm, 0.0F, -0.0F, -0.08726646259971647F); + head = new ModelRenderer(this, 0, 0); + head.setRotationPoint(0.0F, 14.0F, 0.0F); + head.addBox(-3.0F, -6.0F, -3.0F, 6, 6, 6, 0.0F); + rightleg = new ModelRenderer(this, 0, 20); + rightleg.setRotationPoint(-1.5F, 18.0F, -0.5F); + rightleg.addBox(-1.5F, 0.0F, -1.5F, 3, 6, 3, 0.0F); + body = new ModelRenderer(this, 0, 12); + body.setRotationPoint(0.0F, 14.0F, 0.0F); + body.addBox(-3.0F, 0.0F, -2.0F, 6, 4, 4, 0.0F); + } - public void render() { - float f5 = 1F / 15F; - leftleg.render(f5); - rightarm.render(f5); - leftarm.render(f5); - head.render(f5); - rightleg.render(f5); - body.render(f5); - } + public void render() { + float f5 = 1F / 15F; + leftleg.render(f5); + rightarm.render(f5); + leftarm.render(f5); + head.render(f5); + rightleg.render(f5); + body.render(f5); + } - public void setRotateAngle(ModelRenderer modelRenderer, float x, float y, float z) { - modelRenderer.rotateAngleX = x; - modelRenderer.rotateAngleY = y; - modelRenderer.rotateAngleZ = z; - } - -} \ No newline at end of file + public void setRotateAngle(ModelRenderer modelRenderer, float x, float y, float z) { + modelRenderer.rotateAngleX = x; + modelRenderer.rotateAngleY = y; + modelRenderer.rotateAngleZ = z; + } +} diff --git a/src/main/java/vazkii/botania/client/model/ModelBellows.java b/src/main/java/vazkii/botania/client/model/ModelBellows.java index f086f946e6..6a71cdacd7 100644 --- a/src/main/java/vazkii/botania/client/model/ModelBellows.java +++ b/src/main/java/vazkii/botania/client/model/ModelBellows.java @@ -2,91 +2,89 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Aug 28, 2015, 5:16:17 PM (GMT)] */ package vazkii.botania.client.model; import net.minecraft.client.model.ModelBase; import net.minecraft.client.model.ModelRenderer; - import org.lwjgl.opengl.GL11; public class ModelBellows extends ModelBase { - ModelRenderer Base; - ModelRenderer Top; - ModelRenderer Funnel; - ModelRenderer Pipe; - ModelRenderer Handle1; - ModelRenderer Handle2; - ModelRenderer Handle3; - - public ModelBellows() { - textureWidth = 64; - textureHeight = 32; - - Base = new ModelRenderer(this, 0, 0); - Base.addBox(0F, 0F, 0F, 10, 2, 10); - Base.setRotationPoint(-5F, 22F, -5F); - Base.setTextureSize(64, 32); - Base.mirror = true; - Top = new ModelRenderer(this, 0, 14); - Top.addBox(0F, 0F, 0F, 8, 1, 8); - Top.setRotationPoint(-4F, 14F, -4F); - Top.setTextureSize(64, 32); - Top.mirror = true; - Funnel = new ModelRenderer(this, 34, 14); - Funnel.addBox(0F, 0F, 0F, 6, 7, 6); - Funnel.setRotationPoint(0F, 0F, 0F); - Funnel.setTextureSize(64, 32); - Funnel.mirror = true; - Pipe = new ModelRenderer(this, 43, 1); - Pipe.addBox(0F, 0F, 0F, 2, 2, 3); - Pipe.setRotationPoint(-1F, 22F, -8F); - Pipe.setTextureSize(64, 32); - Pipe.mirror = true; - Handle1 = new ModelRenderer(this, 43, 8); - Handle1.addBox(0F, 0F, -0.5F, 1, 2, 1); - Handle1.setRotationPoint(-2F, 12F, 0F); - Handle1.setTextureSize(64, 32); - Handle1.mirror = true; - Handle2 = new ModelRenderer(this, 48, 8); - Handle2.addBox(1F, 0F, -0.5F, 2, 1, 1); - Handle2.setRotationPoint(-2F, 12F, 0F); - Handle2.setTextureSize(64, 32); - Handle2.mirror = true; - Handle3 = new ModelRenderer(this, 55, 8); - Handle3.addBox(3F, 0F, -0.5F, 1, 2, 1); - Handle3.setRotationPoint(-2F, 12F, 0F); - Handle3.setTextureSize(64, 32); - Handle3.mirror = true; - } + ModelRenderer Base; + ModelRenderer Top; + ModelRenderer Funnel; + ModelRenderer Pipe; + ModelRenderer Handle1; + ModelRenderer Handle2; + ModelRenderer Handle3; - public void render(float fract) { - float f5 = 1F / 16F; - Base.render(f5); - Pipe.render(f5); + public ModelBellows() { + textureWidth = 64; + textureHeight = 32; - //float fract = Math.max(0.1F, (float) (Math.sin(((double) ClientTickHandler.ticksInGame + ClientTickHandler.partialTicks) * 0.2) + 1F) * 0.5F); - float mov = (1F - fract) * 0.5F; + Base = new ModelRenderer(this, 0, 0); + Base.addBox(0F, 0F, 0F, 10, 2, 10); + Base.setRotationPoint(-5F, 22F, -5F); + Base.setTextureSize(64, 32); + Base.mirror = true; + Top = new ModelRenderer(this, 0, 14); + Top.addBox(0F, 0F, 0F, 8, 1, 8); + Top.setRotationPoint(-4F, 14F, -4F); + Top.setTextureSize(64, 32); + Top.mirror = true; + Funnel = new ModelRenderer(this, 34, 14); + Funnel.addBox(0F, 0F, 0F, 6, 7, 6); + Funnel.setRotationPoint(0F, 0F, 0F); + Funnel.setTextureSize(64, 32); + Funnel.mirror = true; + Pipe = new ModelRenderer(this, 43, 1); + Pipe.addBox(0F, 0F, 0F, 2, 2, 3); + Pipe.setRotationPoint(-1F, 22F, -8F); + Pipe.setTextureSize(64, 32); + Pipe.mirror = true; + Handle1 = new ModelRenderer(this, 43, 8); + Handle1.addBox(0F, 0F, -0.5F, 1, 2, 1); + Handle1.setRotationPoint(-2F, 12F, 0F); + Handle1.setTextureSize(64, 32); + Handle1.mirror = true; + Handle2 = new ModelRenderer(this, 48, 8); + Handle2.addBox(1F, 0F, -0.5F, 2, 1, 1); + Handle2.setRotationPoint(-2F, 12F, 0F); + Handle2.setTextureSize(64, 32); + Handle2.mirror = true; + Handle3 = new ModelRenderer(this, 55, 8); + Handle3.addBox(3F, 0F, -0.5F, 1, 2, 1); + Handle3.setRotationPoint(-2F, 12F, 0F); + Handle3.setTextureSize(64, 32); + Handle3.mirror = true; + } - GL11.glTranslatef(0F, mov, 0F); - Top.render(f5); - Handle1.render(f5); - Handle2.render(f5); - Handle3.render(f5); - GL11.glTranslatef(0F, -mov, 0F); + public void render(float fract) { + float f5 = 1F / 16F; + Base.render(f5); + Pipe.render(f5); - GL11.glRotatef(180F, 1F, 0F, 0F); - GL11.glTranslatef(-0.19F, -1.375F, -0.19F); - GL11.glScalef(1F, fract, 1F); - Funnel.render(f5); - GL11.glScalef(1F, 1F / fract, 1F); - } + // float fract = Math.max(0.1F, (float) (Math.sin(((double) ClientTickHandler.ticksInGame + + // ClientTickHandler.partialTicks) * 0.2) + 1F) * 0.5F); + float mov = (1F - fract) * 0.5F; + GL11.glTranslatef(0F, mov, 0F); + Top.render(f5); + Handle1.render(f5); + Handle2.render(f5); + Handle3.render(f5); + GL11.glTranslatef(0F, -mov, 0F); + GL11.glRotatef(180F, 1F, 0F, 0F); + GL11.glTranslatef(-0.19F, -1.375F, -0.19F); + GL11.glScalef(1F, fract, 1F); + Funnel.render(f5); + GL11.glScalef(1F, 1F / fract, 1F); + } } diff --git a/src/main/java/vazkii/botania/client/model/ModelBlackHoleCube.java b/src/main/java/vazkii/botania/client/model/ModelBlackHoleCube.java index 1c770b3b3c..a1e7f58de1 100644 --- a/src/main/java/vazkii/botania/client/model/ModelBlackHoleCube.java +++ b/src/main/java/vazkii/botania/client/model/ModelBlackHoleCube.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [? (GMT)] */ package vazkii.botania.client.model; @@ -15,88 +15,87 @@ import net.minecraft.entity.Entity; public class ModelBlackHoleCube extends ModelBase { - public ModelRenderer shape1; - public ModelRenderer shape1_1; - public ModelRenderer shape1_2; - public ModelRenderer shape1_3; - public ModelRenderer shape1_4; - public ModelRenderer shape1_5; - public ModelRenderer shape1_6; - public ModelRenderer shape1_7; - public ModelRenderer shape1_8; - public ModelRenderer shape1_9; - public ModelRenderer shape1_10; - public ModelRenderer shape1_11; + public ModelRenderer shape1; + public ModelRenderer shape1_1; + public ModelRenderer shape1_2; + public ModelRenderer shape1_3; + public ModelRenderer shape1_4; + public ModelRenderer shape1_5; + public ModelRenderer shape1_6; + public ModelRenderer shape1_7; + public ModelRenderer shape1_8; + public ModelRenderer shape1_9; + public ModelRenderer shape1_10; + public ModelRenderer shape1_11; - public ModelBlackHoleCube() { - textureWidth = 36; - textureHeight = 2; - shape1_3 = new ModelRenderer(this, 0, 0); - shape1_3.setRotationPoint(0.0F, 16.0F, 0.0F); - shape1_3.addBox(-7.0F, 7.0F, -8.0F, 14, 1, 1, 0.0F); - setRotateAngle(shape1_3, 0.0F, 1.5707963267948966F, 0.0F); - shape1_7 = new ModelRenderer(this, 0, 0); - shape1_7.setRotationPoint(0.0F, 16.0F, 0.0F); - shape1_7.addBox(-7.0F, -8.0F, -8.0F, 14, 1, 1, 0.0F); - setRotateAngle(shape1_7, 0.0F, 1.5707963267948966F, 0.0F); - shape1_9 = new ModelRenderer(this, 0, 0); - shape1_9.setRotationPoint(0.0F, 16.0F, 0.0F); - shape1_9.addBox(-7.0F, 7.0F, 7.0F, 14, 1, 1, 0.0F); - setRotateAngle(shape1_9, 0.0F, 3.141592653589793F, 1.5707963267948966F); - shape1_11 = new ModelRenderer(this, 0, 0); - shape1_11.setRotationPoint(0.0F, 16.0F, 0.0F); - shape1_11.addBox(-7.0F, 7.0F, -8.0F, 14, 1, 1, 0.0F); - setRotateAngle(shape1_11, 0.0F, 3.141592653589793F, 1.5707963267948966F); - shape1 = new ModelRenderer(this, 0, 0); - shape1.setRotationPoint(0.0F, 16.0F, 0.0F); - shape1.addBox(-8.0F, 7.0F, 7.0F, 16, 1, 1, 0.0F); - shape1_4 = new ModelRenderer(this, 0, 0); - shape1_4.setRotationPoint(0.0F, 16.0F, 0.0F); - shape1_4.addBox(-8.0F, 7.0F, -8.0F, 16, 1, 1, 0.0F); - shape1_8 = new ModelRenderer(this, 0, 0); - shape1_8.setRotationPoint(0.0F, 16.0F, 0.0F); - shape1_8.addBox(-7.0F, -8.0F, -8.0F, 14, 1, 1, 0.0F); - setRotateAngle(shape1_8, 0.0F, 3.141592653589793F, 1.5707963267948966F); - shape1_2 = new ModelRenderer(this, 0, 0); - shape1_2.setRotationPoint(0.0F, 16.0F, 0.0F); - shape1_2.addBox(-8.0F, -8.0F, -8.0F, 16, 1, 1, 0.0F); - shape1_1 = new ModelRenderer(this, 0, 0); - shape1_1.setRotationPoint(0.0F, 16.0F, 0.0F); - shape1_1.addBox(-8.0F, -8.0F, 7.0F, 16, 1, 1, 0.0F); - shape1_6 = new ModelRenderer(this, 0, 0); - shape1_6.setRotationPoint(0.0F, 16.0F, 0.0F); - shape1_6.addBox(-7.0F, -8.0F, -8.0F, 14, 1, 1, 0.0F); - setRotateAngle(shape1_6, 0.0F, -1.5707963267948966F, 0.0F); - shape1_10 = new ModelRenderer(this, 0, 0); - shape1_10.setRotationPoint(0.0F, 16.0F, 0.0F); - shape1_10.addBox(-7.0F, -8.0F, 7.0F, 14, 1, 1, 0.0F); - setRotateAngle(shape1_10, 0.0F, 3.141592653589793F, 1.5707963267948966F); - shape1_5 = new ModelRenderer(this, 0, 0); - shape1_5.setRotationPoint(0.0F, 16.0F, 0.0F); - shape1_5.addBox(-7.0F, 7.0F, -8.0F, 14, 1, 1, 0.0F); - setRotateAngle(shape1_5, 0.0F, -1.5707963267948966F, 0.0F); - } + public ModelBlackHoleCube() { + textureWidth = 36; + textureHeight = 2; + shape1_3 = new ModelRenderer(this, 0, 0); + shape1_3.setRotationPoint(0.0F, 16.0F, 0.0F); + shape1_3.addBox(-7.0F, 7.0F, -8.0F, 14, 1, 1, 0.0F); + setRotateAngle(shape1_3, 0.0F, 1.5707963267948966F, 0.0F); + shape1_7 = new ModelRenderer(this, 0, 0); + shape1_7.setRotationPoint(0.0F, 16.0F, 0.0F); + shape1_7.addBox(-7.0F, -8.0F, -8.0F, 14, 1, 1, 0.0F); + setRotateAngle(shape1_7, 0.0F, 1.5707963267948966F, 0.0F); + shape1_9 = new ModelRenderer(this, 0, 0); + shape1_9.setRotationPoint(0.0F, 16.0F, 0.0F); + shape1_9.addBox(-7.0F, 7.0F, 7.0F, 14, 1, 1, 0.0F); + setRotateAngle(shape1_9, 0.0F, 3.141592653589793F, 1.5707963267948966F); + shape1_11 = new ModelRenderer(this, 0, 0); + shape1_11.setRotationPoint(0.0F, 16.0F, 0.0F); + shape1_11.addBox(-7.0F, 7.0F, -8.0F, 14, 1, 1, 0.0F); + setRotateAngle(shape1_11, 0.0F, 3.141592653589793F, 1.5707963267948966F); + shape1 = new ModelRenderer(this, 0, 0); + shape1.setRotationPoint(0.0F, 16.0F, 0.0F); + shape1.addBox(-8.0F, 7.0F, 7.0F, 16, 1, 1, 0.0F); + shape1_4 = new ModelRenderer(this, 0, 0); + shape1_4.setRotationPoint(0.0F, 16.0F, 0.0F); + shape1_4.addBox(-8.0F, 7.0F, -8.0F, 16, 1, 1, 0.0F); + shape1_8 = new ModelRenderer(this, 0, 0); + shape1_8.setRotationPoint(0.0F, 16.0F, 0.0F); + shape1_8.addBox(-7.0F, -8.0F, -8.0F, 14, 1, 1, 0.0F); + setRotateAngle(shape1_8, 0.0F, 3.141592653589793F, 1.5707963267948966F); + shape1_2 = new ModelRenderer(this, 0, 0); + shape1_2.setRotationPoint(0.0F, 16.0F, 0.0F); + shape1_2.addBox(-8.0F, -8.0F, -8.0F, 16, 1, 1, 0.0F); + shape1_1 = new ModelRenderer(this, 0, 0); + shape1_1.setRotationPoint(0.0F, 16.0F, 0.0F); + shape1_1.addBox(-8.0F, -8.0F, 7.0F, 16, 1, 1, 0.0F); + shape1_6 = new ModelRenderer(this, 0, 0); + shape1_6.setRotationPoint(0.0F, 16.0F, 0.0F); + shape1_6.addBox(-7.0F, -8.0F, -8.0F, 14, 1, 1, 0.0F); + setRotateAngle(shape1_6, 0.0F, -1.5707963267948966F, 0.0F); + shape1_10 = new ModelRenderer(this, 0, 0); + shape1_10.setRotationPoint(0.0F, 16.0F, 0.0F); + shape1_10.addBox(-7.0F, -8.0F, 7.0F, 14, 1, 1, 0.0F); + setRotateAngle(shape1_10, 0.0F, 3.141592653589793F, 1.5707963267948966F); + shape1_5 = new ModelRenderer(this, 0, 0); + shape1_5.setRotationPoint(0.0F, 16.0F, 0.0F); + shape1_5.addBox(-7.0F, 7.0F, -8.0F, 14, 1, 1, 0.0F); + setRotateAngle(shape1_5, 0.0F, -1.5707963267948966F, 0.0F); + } - @Override - public void render(Entity entity, float f, float f1, float f2, float f3, float f4, float f5) { - shape1_3.render(f5); - shape1_7.render(f5); - shape1_9.render(f5); - shape1_11.render(f5); - shape1.render(f5); - shape1_4.render(f5); - shape1_8.render(f5); - shape1_2.render(f5); - shape1_1.render(f5); - shape1_6.render(f5); - shape1_10.render(f5); - shape1_5.render(f5); - } + @Override + public void render(Entity entity, float f, float f1, float f2, float f3, float f4, float f5) { + shape1_3.render(f5); + shape1_7.render(f5); + shape1_9.render(f5); + shape1_11.render(f5); + shape1.render(f5); + shape1_4.render(f5); + shape1_8.render(f5); + shape1_2.render(f5); + shape1_1.render(f5); + shape1_6.render(f5); + shape1_10.render(f5); + shape1_5.render(f5); + } - - public void setRotateAngle(ModelRenderer modelRenderer, float x, float y, float z) { - modelRenderer.rotateAngleX = x; - modelRenderer.rotateAngleY = y; - modelRenderer.rotateAngleZ = z; - } + public void setRotateAngle(ModelRenderer modelRenderer, float x, float y, float z) { + modelRenderer.rotateAngleX = x; + modelRenderer.rotateAngleY = y; + modelRenderer.rotateAngleZ = z; + } } diff --git a/src/main/java/vazkii/botania/client/model/ModelBrewery.java b/src/main/java/vazkii/botania/client/model/ModelBrewery.java index aa24757c4b..3c6134b2f1 100644 --- a/src/main/java/vazkii/botania/client/model/ModelBrewery.java +++ b/src/main/java/vazkii/botania/client/model/ModelBrewery.java @@ -2,101 +2,97 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Oct 31, 2014, 4:33:55 PM (GMT)] */ package vazkii.botania.client.model; import net.minecraft.client.model.ModelBase; import net.minecraft.client.model.ModelRenderer; - import org.lwjgl.opengl.GL11; - import vazkii.botania.client.render.tile.RenderTileBrewery; public class ModelBrewery extends ModelBase { - ModelRenderer Pole; - ModelRenderer Top; - ModelRenderer Bottom; - ModelRenderer Plate; - - public ModelBrewery() { - textureWidth = 64; - textureHeight = 32; - - Pole = new ModelRenderer(this, 0, 6); - Pole.addBox(0F, 0F, 0F, 2, 10, 2); - Pole.setRotationPoint(-1F, 10F, -1F); - Pole.setTextureSize(64, 32); - Top = new ModelRenderer(this, 18, 0); - Top.addBox(0F, 0F, 0F, 4, 1, 4); - Top.setRotationPoint(-2F, 9F, -2F); - Top.setTextureSize(64, 32); - Bottom = new ModelRenderer(this, 18, 7); - Bottom.addBox(0F, 0F, 0F, 4, 1, 4); - Bottom.setRotationPoint(-2F, 20F, -2F); - Bottom.setTextureSize(64, 32); - Plate = new ModelRenderer(this, 0, 0); - Plate.addBox(5F, 0F, -2F, 4, 1, 4); - Plate.setRotationPoint(0F, 17F, 0F); - Plate.setTextureSize(64, 32); - } - - public void render(RenderTileBrewery render, double time) { - float f = 1F / 16F; - - float offset = (float) Math.sin(time / 40) * 0.1F + 0.05F; - int plates = render.brewery.getSizeInventory() - 1; - float deg = (float) time / 16F; - float polerot = -deg * 25F; - - GL11.glTranslatef(0F, offset, 0F); - GL11.glRotatef(polerot, 0F, 1F, 0F); - if(render.brewery.getStackInSlot(0) != null) { - GL11.glRotatef(180F, 1F, 0F, 0F); - GL11.glTranslatef(-1F / 8F, -0.5F, 1F / 128F); - render.renderItemStack(render.brewery.getStackInSlot(0)); - GL11.glTranslatef(1F / 8F, 0.5F, -1F / 128F); - GL11.glRotatef(-180F, 1F, 0F, 0F); - } - - Pole.render(f); - Top.render(f); - Bottom.render(f); - GL11.glRotatef(-polerot, 0F, 1F, 0F); - - float degper = (float) (2F * Math.PI) / plates; - for(int i = 0; i < plates; i++) { - Plate.rotateAngleY = deg; - float offset1 = (float) Math.sin(time / 20 + i * 40F) * 0.2F - 0.2F; - if(time == -1) - offset1 = 0F; - - GL11.glTranslatef(0F, offset1, 0F); - if(render.brewery.getStackInSlot(i + 1) != null) { - float rot = Plate.rotateAngleY * 180F / (float) Math.PI; - float transX = 0.3125F; - float transY = 1.06F; - float transZ = 0.1245F; - GL11.glRotatef(rot, 0F, 1F, 0F); - GL11.glTranslatef(transX, transY, transZ); - GL11.glRotatef(-90F, 1F, 0F, 0F); - render.renderItemStack(render.brewery.getStackInSlot(i + 1)); - GL11.glRotatef(90F, 1F, 0F, 0F); - GL11.glTranslatef(-transX, -transY, -transZ); - GL11.glRotatef(-rot, 0F, 1F, 0F); - } - - Plate.render(f); - GL11.glTranslatef(0F, -offset1, 0F); - - deg += degper; - } - GL11.glTranslatef(0F, -offset, 0F); - } - + ModelRenderer Pole; + ModelRenderer Top; + ModelRenderer Bottom; + ModelRenderer Plate; + + public ModelBrewery() { + textureWidth = 64; + textureHeight = 32; + + Pole = new ModelRenderer(this, 0, 6); + Pole.addBox(0F, 0F, 0F, 2, 10, 2); + Pole.setRotationPoint(-1F, 10F, -1F); + Pole.setTextureSize(64, 32); + Top = new ModelRenderer(this, 18, 0); + Top.addBox(0F, 0F, 0F, 4, 1, 4); + Top.setRotationPoint(-2F, 9F, -2F); + Top.setTextureSize(64, 32); + Bottom = new ModelRenderer(this, 18, 7); + Bottom.addBox(0F, 0F, 0F, 4, 1, 4); + Bottom.setRotationPoint(-2F, 20F, -2F); + Bottom.setTextureSize(64, 32); + Plate = new ModelRenderer(this, 0, 0); + Plate.addBox(5F, 0F, -2F, 4, 1, 4); + Plate.setRotationPoint(0F, 17F, 0F); + Plate.setTextureSize(64, 32); + } + + public void render(RenderTileBrewery render, double time) { + float f = 1F / 16F; + + float offset = (float) Math.sin(time / 40) * 0.1F + 0.05F; + int plates = render.brewery.getSizeInventory() - 1; + float deg = (float) time / 16F; + float polerot = -deg * 25F; + + GL11.glTranslatef(0F, offset, 0F); + GL11.glRotatef(polerot, 0F, 1F, 0F); + if (render.brewery.getStackInSlot(0) != null) { + GL11.glRotatef(180F, 1F, 0F, 0F); + GL11.glTranslatef(-1F / 8F, -0.5F, 1F / 128F); + render.renderItemStack(render.brewery.getStackInSlot(0)); + GL11.glTranslatef(1F / 8F, 0.5F, -1F / 128F); + GL11.glRotatef(-180F, 1F, 0F, 0F); + } + + Pole.render(f); + Top.render(f); + Bottom.render(f); + GL11.glRotatef(-polerot, 0F, 1F, 0F); + + float degper = (float) (2F * Math.PI) / plates; + for (int i = 0; i < plates; i++) { + Plate.rotateAngleY = deg; + float offset1 = (float) Math.sin(time / 20 + i * 40F) * 0.2F - 0.2F; + if (time == -1) offset1 = 0F; + + GL11.glTranslatef(0F, offset1, 0F); + if (render.brewery.getStackInSlot(i + 1) != null) { + float rot = Plate.rotateAngleY * 180F / (float) Math.PI; + float transX = 0.3125F; + float transY = 1.06F; + float transZ = 0.1245F; + GL11.glRotatef(rot, 0F, 1F, 0F); + GL11.glTranslatef(transX, transY, transZ); + GL11.glRotatef(-90F, 1F, 0F, 0F); + render.renderItemStack(render.brewery.getStackInSlot(i + 1)); + GL11.glRotatef(90F, 1F, 0F, 0F); + GL11.glTranslatef(-transX, -transY, -transZ); + GL11.glRotatef(-rot, 0F, 1F, 0F); + } + + Plate.render(f); + GL11.glTranslatef(0F, -offset1, 0F); + + deg += degper; + } + GL11.glTranslatef(0F, -offset, 0F); + } } diff --git a/src/main/java/vazkii/botania/client/model/ModelCocoon.java b/src/main/java/vazkii/botania/client/model/ModelCocoon.java index 2fbc79c1bd..484a449c4a 100644 --- a/src/main/java/vazkii/botania/client/model/ModelCocoon.java +++ b/src/main/java/vazkii/botania/client/model/ModelCocoon.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [? (GMT)] */ package vazkii.botania.client.model; @@ -15,18 +15,17 @@ public class ModelCocoon extends ModelBase { - public ModelRenderer shape; + public ModelRenderer shape; - public ModelCocoon() { - textureWidth = 64; - textureHeight = 32; - shape = new ModelRenderer(this, 0, 0); - shape.setRotationPoint(0.0F, 22.0F, 0.0F); - shape.addBox(-5.0F, -8.0F, -7.0F, 10, 10, 14, 0.0F); - } - - public void render() { - shape.render(1F / 16F); - } + public ModelCocoon() { + textureWidth = 64; + textureHeight = 32; + shape = new ModelRenderer(this, 0, 0); + shape.setRotationPoint(0.0F, 22.0F, 0.0F); + shape.addBox(-5.0F, -8.0F, -7.0F, 10, 10, 14, 0.0F); + } + public void render() { + shape.render(1F / 16F); + } } diff --git a/src/main/java/vazkii/botania/client/model/ModelCrystalCube.java b/src/main/java/vazkii/botania/client/model/ModelCrystalCube.java index 80addf965e..ae87545ecd 100644 --- a/src/main/java/vazkii/botania/client/model/ModelCrystalCube.java +++ b/src/main/java/vazkii/botania/client/model/ModelCrystalCube.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [? (GMT)] */ package vazkii.botania.client.model; @@ -14,38 +14,38 @@ import net.minecraft.client.model.ModelRenderer; public class ModelCrystalCube extends ModelBase { - public ModelRenderer cube; - public ModelRenderer base1; - public ModelRenderer base2; + public ModelRenderer cube; + public ModelRenderer base1; + public ModelRenderer base2; - public ModelCrystalCube() { - textureWidth = 48; - textureHeight = 32; - cube = new ModelRenderer(this, 0, 0); - cube.setRotationPoint(0.0F, 12.0F, 0.0F); - cube.addBox(-4.0F, -4.0F, -4.0F, 8, 8, 8, 0.0F); - base1 = new ModelRenderer(this, 22, 0); - base1.setRotationPoint(0.0F, 16.0F, 0.0F); - base1.addBox(-3.0F, 7.0F, -3.0F, 6, 1, 6, 0.0F); - base2 = new ModelRenderer(this, 0, 16); - base2.setRotationPoint(0.0F, 0.0F, 0.0F); - base2.addBox(-5.0F, 3.0F, -5.0F, 10, 4, 10, 0.0F); - base1.addChild(base2); - } + public ModelCrystalCube() { + textureWidth = 48; + textureHeight = 32; + cube = new ModelRenderer(this, 0, 0); + cube.setRotationPoint(0.0F, 12.0F, 0.0F); + cube.addBox(-4.0F, -4.0F, -4.0F, 8, 8, 8, 0.0F); + base1 = new ModelRenderer(this, 22, 0); + base1.setRotationPoint(0.0F, 16.0F, 0.0F); + base1.addBox(-3.0F, 7.0F, -3.0F, 6, 1, 6, 0.0F); + base2 = new ModelRenderer(this, 0, 16); + base2.setRotationPoint(0.0F, 0.0F, 0.0F); + base2.addBox(-5.0F, 3.0F, -5.0F, 10, 4, 10, 0.0F); + base1.addChild(base2); + } - public void renderBase() { - float f5 = 1F / 16F; - base1.render(f5); - } + public void renderBase() { + float f5 = 1F / 16F; + base1.render(f5); + } - public void renderCube() { - float f5 = 1F / 16F; - cube.render(f5); - } + public void renderCube() { + float f5 = 1F / 16F; + cube.render(f5); + } - public void setRotateAngle(ModelRenderer modelRenderer, float x, float y, float z) { - modelRenderer.rotateAngleX = x; - modelRenderer.rotateAngleY = y; - modelRenderer.rotateAngleZ = z; - } + public void setRotateAngle(ModelRenderer modelRenderer, float x, float y, float z) { + modelRenderer.rotateAngleX = x; + modelRenderer.rotateAngleY = y; + modelRenderer.rotateAngleZ = z; + } } diff --git a/src/main/java/vazkii/botania/client/model/ModelHourglass.java b/src/main/java/vazkii/botania/client/model/ModelHourglass.java index a1ca14ddc7..2b457f0924 100644 --- a/src/main/java/vazkii/botania/client/model/ModelHourglass.java +++ b/src/main/java/vazkii/botania/client/model/ModelHourglass.java @@ -2,105 +2,100 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [? (GMT)] */ package vazkii.botania.client.model; import java.awt.Color; - import net.minecraft.client.model.ModelBase; import net.minecraft.client.model.ModelRenderer; - import org.lwjgl.opengl.GL11; public class ModelHourglass extends ModelBase { - public ModelRenderer ring; - public ModelRenderer base1; - public ModelRenderer base2; - public ModelRenderer glass1; - public ModelRenderer sand1; - public ModelRenderer glass2; - public ModelRenderer sand2; - - public ModelHourglass() { - textureWidth = 48; - textureHeight = 24; - sand2 = new ModelRenderer(this, 24, 0); - sand2.setRotationPoint(0.0F, 0.0F, 0.0F); - sand2.addBox(0F, 0F, 0F, 5, 5, 5, 0.0F); // -2.5F, 1.0F, -2.5F - sand1 = new ModelRenderer(this, 24, 0); - sand1.setRotationPoint(0.0F, 0.0F, 0.0F); - sand1.addBox(0F, 0F, 0F, 5, 5, 5, 0.0F); // -2.5F, -6.0F, -2.5F - glass1 = new ModelRenderer(this, 0, 0); - glass1.setRotationPoint(0.0F, 0.0F, 0.0F); - glass1.addBox(-3.0F, -6.501F, -3.0F, 6, 6, 6, 0.0F); - base2 = new ModelRenderer(this, 0, 12); - base2.setRotationPoint(0.0F, 0.0F, 0.0F); - base2.addBox(-3.5F, 6.502F, -3.5F, 7, 1, 7, 0.0F); - base1 = new ModelRenderer(this, 0, 12); - base1.setRotationPoint(0.0F, 0.0F, 0.0F); - base1.addBox(-3.5F, -7.502F, -3.5F, 7, 1, 7, 0.0F); - ring = new ModelRenderer(this, 28, 12); - ring.setRotationPoint(0.0F, 15.5F, 0.0F); - ring.addBox(-2.0F, -16F, -2.0F, 4, 1, 4, 0.0F); - glass2 = new ModelRenderer(this, 0, 0); - glass2.setRotationPoint(0.0F, 0.0F, 0.0F); - glass2.addBox(-3.0F, 0.501F, -3.0F, 6, 6, 6, 0.0F); - } + public ModelRenderer ring; + public ModelRenderer base1; + public ModelRenderer base2; + public ModelRenderer glass1; + public ModelRenderer sand1; + public ModelRenderer glass2; + public ModelRenderer sand2; - public void render(float fract1, float fract2, boolean flip, int color) { - if(flip) { - float fract3 = fract1; - fract1 = fract2; - fract2 = fract3; - } + public ModelHourglass() { + textureWidth = 48; + textureHeight = 24; + sand2 = new ModelRenderer(this, 24, 0); + sand2.setRotationPoint(0.0F, 0.0F, 0.0F); + sand2.addBox(0F, 0F, 0F, 5, 5, 5, 0.0F); // -2.5F, 1.0F, -2.5F + sand1 = new ModelRenderer(this, 24, 0); + sand1.setRotationPoint(0.0F, 0.0F, 0.0F); + sand1.addBox(0F, 0F, 0F, 5, 5, 5, 0.0F); // -2.5F, -6.0F, -2.5F + glass1 = new ModelRenderer(this, 0, 0); + glass1.setRotationPoint(0.0F, 0.0F, 0.0F); + glass1.addBox(-3.0F, -6.501F, -3.0F, 6, 6, 6, 0.0F); + base2 = new ModelRenderer(this, 0, 12); + base2.setRotationPoint(0.0F, 0.0F, 0.0F); + base2.addBox(-3.5F, 6.502F, -3.5F, 7, 1, 7, 0.0F); + base1 = new ModelRenderer(this, 0, 12); + base1.setRotationPoint(0.0F, 0.0F, 0.0F); + base1.addBox(-3.5F, -7.502F, -3.5F, 7, 1, 7, 0.0F); + ring = new ModelRenderer(this, 28, 12); + ring.setRotationPoint(0.0F, 15.5F, 0.0F); + ring.addBox(-2.0F, -16F, -2.0F, 4, 1, 4, 0.0F); + glass2 = new ModelRenderer(this, 0, 0); + glass2.setRotationPoint(0.0F, 0.0F, 0.0F); + glass2.addBox(-3.0F, 0.501F, -3.0F, 6, 6, 6, 0.0F); + } - float f = 1F / 16F; - ring.render(f); - base1.render(f); - base2.render(f); - Color c = new Color(color); - GL11.glColor3ub((byte) c.getRed(), (byte) c.getGreen(), (byte) c.getBlue()); - GL11.glPushAttrib(GL11.GL_NORMALIZE); - GL11.glEnable(GL11.GL_NORMALIZE); + public void render(float fract1, float fract2, boolean flip, int color) { + if (flip) { + float fract3 = fract1; + fract1 = fract2; + fract2 = fract3; + } - if(fract1 > 0) { - GL11.glPushMatrix(); - if(flip) - GL11.glTranslatef(-2.5F * f, 1.0F * f, -2.5F * f); - else { - GL11.glRotatef(180F, 0F, 0F, 1F); - GL11.glTranslatef(-2.5F * f, -6.0F * f, -2.5F * f); - } + float f = 1F / 16F; + ring.render(f); + base1.render(f); + base2.render(f); + Color c = new Color(color); + GL11.glColor3ub((byte) c.getRed(), (byte) c.getGreen(), (byte) c.getBlue()); + GL11.glPushAttrib(GL11.GL_NORMALIZE); + GL11.glEnable(GL11.GL_NORMALIZE); - GL11.glScalef(1F, fract1, 1F); - sand1.render(f); - GL11.glPopMatrix(); - } + if (fract1 > 0) { + GL11.glPushMatrix(); + if (flip) GL11.glTranslatef(-2.5F * f, 1.0F * f, -2.5F * f); + else { + GL11.glRotatef(180F, 0F, 0F, 1F); + GL11.glTranslatef(-2.5F * f, -6.0F * f, -2.5F * f); + } - if(fract2 > 0) { - GL11.glPushMatrix(); - if(flip) - GL11.glTranslatef(-2.5F * f, -6.0F * f, -2.5F * f); - else { - GL11.glRotatef(180F, 0F, 0F, 1F); - GL11.glTranslatef(-2.5F * f, 1.0F * f, -2.5F * f); - } + GL11.glScalef(1F, fract1, 1F); + sand1.render(f); + GL11.glPopMatrix(); + } - GL11.glScalef(1F, fract2, 1F); - sand2.render(f); - GL11.glPopMatrix(); - } + if (fract2 > 0) { + GL11.glPushMatrix(); + if (flip) GL11.glTranslatef(-2.5F * f, -6.0F * f, -2.5F * f); + else { + GL11.glRotatef(180F, 0F, 0F, 1F); + GL11.glTranslatef(-2.5F * f, 1.0F * f, -2.5F * f); + } - GL11.glPopAttrib(); - GL11.glColor3f(1F, 1F, 1F); - glass1.render(f); - glass2.render(f); - } + GL11.glScalef(1F, fract2, 1F); + sand2.render(f); + GL11.glPopMatrix(); + } + GL11.glPopAttrib(); + GL11.glColor3f(1F, 1F, 1F); + glass1.render(f); + glass2.render(f); + } } diff --git a/src/main/java/vazkii/botania/client/model/ModelIncensePlate.java b/src/main/java/vazkii/botania/client/model/ModelIncensePlate.java index d7fa2eadb3..02e2363adb 100644 --- a/src/main/java/vazkii/botania/client/model/ModelIncensePlate.java +++ b/src/main/java/vazkii/botania/client/model/ModelIncensePlate.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [May 15, 2015, 4:17:37 PM (GMT)] */ package vazkii.botania.client.model; @@ -15,29 +15,28 @@ public class ModelIncensePlate extends ModelBase { - ModelRenderer Plate; - ModelRenderer High; + ModelRenderer Plate; + ModelRenderer High; - public ModelIncensePlate() { - textureWidth = 64; - textureHeight = 32; + public ModelIncensePlate() { + textureWidth = 64; + textureHeight = 32; - Plate = new ModelRenderer(this, 0, 0); - Plate.addBox(0F, 0F, 0F, 12, 1, 4); - Plate.setRotationPoint(-6F, 23F, -2F); - Plate.setTextureSize(64, 32); - Plate.mirror = true; - High = new ModelRenderer(this, 0, 6); - High.addBox(0F, 0F, 0F, 3, 1, 4); - High.setRotationPoint(-6F, 22F, -2F); - High.setTextureSize(64, 32); - High.mirror = true; - } - - public void render() { - float f5 = 1F / 16F; - Plate.render(f5); - High.render(f5); - } + Plate = new ModelRenderer(this, 0, 0); + Plate.addBox(0F, 0F, 0F, 12, 1, 4); + Plate.setRotationPoint(-6F, 23F, -2F); + Plate.setTextureSize(64, 32); + Plate.mirror = true; + High = new ModelRenderer(this, 0, 6); + High.addBox(0F, 0F, 0F, 3, 1, 4); + High.setRotationPoint(-6F, 22F, -2F); + High.setTextureSize(64, 32); + High.mirror = true; + } + public void render() { + float f5 = 1F / 16F; + Plate.render(f5); + High.render(f5); + } } diff --git a/src/main/java/vazkii/botania/client/model/ModelMiniIsland.java b/src/main/java/vazkii/botania/client/model/ModelMiniIsland.java index 4b9f2c19cb..99912b1e4f 100644 --- a/src/main/java/vazkii/botania/client/model/ModelMiniIsland.java +++ b/src/main/java/vazkii/botania/client/model/ModelMiniIsland.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jul 8, 2014, 10:07:54 PM (GMT)] */ package vazkii.botania.client.model; @@ -15,70 +15,69 @@ public class ModelMiniIsland extends ModelBase { - ModelRenderer island; + ModelRenderer island; - public ModelMiniIsland() { - textureWidth = 64; - textureHeight = 32; + public ModelMiniIsland() { + textureWidth = 64; + textureHeight = 32; - setTextureOffset("island.Shape0", 0, 0); - setTextureOffset("island.Shape1-1", 8, 0); - setTextureOffset("island.Shape1-2", 16, 0); - setTextureOffset("island.Shape1-3", 24, 0); - setTextureOffset("island.Shape1-4", 32, 0); - setTextureOffset("island.Shape2-1", 8, 6); - setTextureOffset("island.Shape2-2", 16, 6); - setTextureOffset("island.Shape2-3", 24, 6); - setTextureOffset("island.Shape2-4", 32, 6); - setTextureOffset("island.Shape2-5", 8, 11); - setTextureOffset("island.Shape2-6", 16, 11); - setTextureOffset("island.Shape2-7", 24, 11); - setTextureOffset("island.Shape2-8", 32, 11); - setTextureOffset("island.Shape3-1", 8, 16); - setTextureOffset("island.Shape3-2", 16, 16); - setTextureOffset("island.Shape3-3", 24, 16); - setTextureOffset("island.Shape3-4", 32, 16); - setTextureOffset("island.Shape3-5", 8, 20); - setTextureOffset("island.Shape3-6", 16, 20); - setTextureOffset("island.Shape3-7", 24, 20); - setTextureOffset("island.Shape3-8", 32, 20); - setTextureOffset("island.Shape4-1", 8, 24); - setTextureOffset("island.Shape4-2", 16, 24); - setTextureOffset("island.Shape4-3", 24, 24); - setTextureOffset("island.Shape4-4", 32, 24); + setTextureOffset("island.Shape0", 0, 0); + setTextureOffset("island.Shape1-1", 8, 0); + setTextureOffset("island.Shape1-2", 16, 0); + setTextureOffset("island.Shape1-3", 24, 0); + setTextureOffset("island.Shape1-4", 32, 0); + setTextureOffset("island.Shape2-1", 8, 6); + setTextureOffset("island.Shape2-2", 16, 6); + setTextureOffset("island.Shape2-3", 24, 6); + setTextureOffset("island.Shape2-4", 32, 6); + setTextureOffset("island.Shape2-5", 8, 11); + setTextureOffset("island.Shape2-6", 16, 11); + setTextureOffset("island.Shape2-7", 24, 11); + setTextureOffset("island.Shape2-8", 32, 11); + setTextureOffset("island.Shape3-1", 8, 16); + setTextureOffset("island.Shape3-2", 16, 16); + setTextureOffset("island.Shape3-3", 24, 16); + setTextureOffset("island.Shape3-4", 32, 16); + setTextureOffset("island.Shape3-5", 8, 20); + setTextureOffset("island.Shape3-6", 16, 20); + setTextureOffset("island.Shape3-7", 24, 20); + setTextureOffset("island.Shape3-8", 32, 20); + setTextureOffset("island.Shape4-1", 8, 24); + setTextureOffset("island.Shape4-2", 16, 24); + setTextureOffset("island.Shape4-3", 24, 24); + setTextureOffset("island.Shape4-4", 32, 24); - island = new ModelRenderer(this, "island"); - island.setRotationPoint(0F, 16F, 0F); - // island.mirror = true; - island.addBox("Shape0", -1F, 0F, -1F, 2, 5, 2); - island.addBox("Shape1-1", -1F, 0F, -3F, 2, 4, 2); - island.addBox("Shape1-2", 1F, 0F, -1F, 2, 4, 2); - island.addBox("Shape1-3", -1F, 0F, 1F, 2, 4, 2); - island.addBox("Shape1-4", -3F, 0F, -1F, 2, 4, 2); - island.addBox("Shape2-1", -1F, 0F, -5F, 2, 3, 2); - island.addBox("Shape2-2", 3F, 0F, -1F, 2, 3, 2); - island.addBox("Shape2-3", -1F, 0F, 3F, 2, 3, 2); - island.addBox("Shape2-4", -5F, 0F, -1F, 2, 3, 2); - island.addBox("Shape2-5", 1F, 0F, -3F, 2, 3, 2); - island.addBox("Shape2-6", 1F, 0F, 1F, 2, 3, 2); - island.addBox("Shape2-7", -3F, 0F, 1F, 2, 3, 2); - island.addBox("Shape2-8", -3F, 0F, -3F, 2, 3, 2); - island.addBox("Shape3-1", 1F, 0F, -5F, 2, 2, 2); - island.addBox("Shape3-2", 3F, 0F, 1F, 2, 2, 2); - island.addBox("Shape3-3", -3F, 0F, 3F, 2, 2, 2); - island.addBox("Shape3-4", -5F, 0F, -3F, 2, 2, 2); - island.addBox("Shape3-5", 3F, 0F, -3F, 2, 2, 2); - island.addBox("Shape3-6", 1F, 0F, 3F, 2, 2, 2); - island.addBox("Shape3-7", -5F, 0F, 1F, 2, 2, 2); - island.addBox("Shape3-8", -3F, 0F, -5F, 2, 2, 2); - island.addBox("Shape4-1", 3F, 0F, -5F, 2, 1, 2); - island.addBox("Shape4-2", 3F, 0F, 3F, 2, 1, 2); - island.addBox("Shape4-3", -5F, 0F, 3F, 2, 1, 2); - island.addBox("Shape4-4", -5F, 0F, -5F, 2, 1, 2); - } - - public void render() { - island.render(1F / 16F); - } + island = new ModelRenderer(this, "island"); + island.setRotationPoint(0F, 16F, 0F); + // island.mirror = true; + island.addBox("Shape0", -1F, 0F, -1F, 2, 5, 2); + island.addBox("Shape1-1", -1F, 0F, -3F, 2, 4, 2); + island.addBox("Shape1-2", 1F, 0F, -1F, 2, 4, 2); + island.addBox("Shape1-3", -1F, 0F, 1F, 2, 4, 2); + island.addBox("Shape1-4", -3F, 0F, -1F, 2, 4, 2); + island.addBox("Shape2-1", -1F, 0F, -5F, 2, 3, 2); + island.addBox("Shape2-2", 3F, 0F, -1F, 2, 3, 2); + island.addBox("Shape2-3", -1F, 0F, 3F, 2, 3, 2); + island.addBox("Shape2-4", -5F, 0F, -1F, 2, 3, 2); + island.addBox("Shape2-5", 1F, 0F, -3F, 2, 3, 2); + island.addBox("Shape2-6", 1F, 0F, 1F, 2, 3, 2); + island.addBox("Shape2-7", -3F, 0F, 1F, 2, 3, 2); + island.addBox("Shape2-8", -3F, 0F, -3F, 2, 3, 2); + island.addBox("Shape3-1", 1F, 0F, -5F, 2, 2, 2); + island.addBox("Shape3-2", 3F, 0F, 1F, 2, 2, 2); + island.addBox("Shape3-3", -3F, 0F, 3F, 2, 2, 2); + island.addBox("Shape3-4", -5F, 0F, -3F, 2, 2, 2); + island.addBox("Shape3-5", 3F, 0F, -3F, 2, 2, 2); + island.addBox("Shape3-6", 1F, 0F, 3F, 2, 2, 2); + island.addBox("Shape3-7", -5F, 0F, 1F, 2, 2, 2); + island.addBox("Shape3-8", -3F, 0F, -5F, 2, 2, 2); + island.addBox("Shape4-1", 3F, 0F, -5F, 2, 1, 2); + island.addBox("Shape4-2", 3F, 0F, 3F, 2, 1, 2); + island.addBox("Shape4-3", -5F, 0F, 3F, 2, 1, 2); + island.addBox("Shape4-4", -5F, 0F, -5F, 2, 1, 2); + } + public void render() { + island.render(1F / 16F); + } } diff --git a/src/main/java/vazkii/botania/client/model/ModelPixie.java b/src/main/java/vazkii/botania/client/model/ModelPixie.java index 902ab687e9..72709abdf6 100644 --- a/src/main/java/vazkii/botania/client/model/ModelPixie.java +++ b/src/main/java/vazkii/botania/client/model/ModelPixie.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [? (GMT)] */ package vazkii.botania.client.model; @@ -17,55 +17,54 @@ public class ModelPixie extends ModelBase { - ModelRenderer Body; - ModelRenderer LeftWing; - ModelRenderer RightWing; + ModelRenderer Body; + ModelRenderer LeftWing; + ModelRenderer RightWing; - public ModelPixie() { - textureWidth = 64; - textureHeight = 32; + public ModelPixie() { + textureWidth = 64; + textureHeight = 32; - Body = new ModelRenderer(this, 0, 0); - Body.addBox(0F, 0F, 0F, 4, 4, 4); - Body.setRotationPoint(-2F, 16F, -2F); - Body.setTextureSize(64, 32); - Body.mirror = true; - setRotation(Body, 0F, 0F, 0F); - LeftWing = new ModelRenderer(this, 32, 0); - LeftWing.addBox(0F, 0F, -1F, 0, 4, 7); - LeftWing.setRotationPoint(2F, 15F, 2F); - LeftWing.setTextureSize(64, 32); - LeftWing.mirror = true; - setRotation(LeftWing, 0F, 0F, 0F); - RightWing = new ModelRenderer(this, 50, 0); - RightWing.addBox(0F, 0F, -1F, 0, 4, 7); - RightWing.setRotationPoint(-2F, 15F, 2F); - RightWing.setTextureSize(64, 32); - RightWing.mirror = true; - setRotation(RightWing, 0F, 0F, 0F); - } + Body = new ModelRenderer(this, 0, 0); + Body.addBox(0F, 0F, 0F, 4, 4, 4); + Body.setRotationPoint(-2F, 16F, -2F); + Body.setTextureSize(64, 32); + Body.mirror = true; + setRotation(Body, 0F, 0F, 0F); + LeftWing = new ModelRenderer(this, 32, 0); + LeftWing.addBox(0F, 0F, -1F, 0, 4, 7); + LeftWing.setRotationPoint(2F, 15F, 2F); + LeftWing.setTextureSize(64, 32); + LeftWing.mirror = true; + setRotation(LeftWing, 0F, 0F, 0F); + RightWing = new ModelRenderer(this, 50, 0); + RightWing.addBox(0F, 0F, -1F, 0, 4, 7); + RightWing.setRotationPoint(-2F, 15F, 2F); + RightWing.setTextureSize(64, 32); + RightWing.mirror = true; + setRotation(RightWing, 0F, 0F, 0F); + } - @Override - public void render(Entity entity, float f, float f1, float f2, float f3, float f4, float f5) { - super.render(entity, f, f1, f2, f3, f4, f5); - setRotationAngles(f, f1, f2, f3, f4, f5, entity); - Body.render(f5); - LeftWing.render(f5); - RightWing.render(f5); - } + @Override + public void render(Entity entity, float f, float f1, float f2, float f3, float f4, float f5) { + super.render(entity, f, f1, f2, f3, f4, f5); + setRotationAngles(f, f1, f2, f3, f4, f5, entity); + Body.render(f5); + LeftWing.render(f5); + RightWing.render(f5); + } - private void setRotation(ModelRenderer model, float x, float y, float z) { - model.rotateAngleX = x; - model.rotateAngleY = y; - model.rotateAngleZ = z; - } + private void setRotation(ModelRenderer model, float x, float y, float z) { + model.rotateAngleX = x; + model.rotateAngleY = y; + model.rotateAngleZ = z; + } - @Override - public void setRotationAngles(float f, float f1, float f2, float f3, float f4, float f5, Entity entity) { - super.setRotationAngles(f, f1, f2, f3, f4, f5, entity); + @Override + public void setRotationAngles(float f, float f1, float f2, float f3, float f4, float f5, Entity entity) { + super.setRotationAngles(f, f1, f2, f3, f4, f5, entity); - RightWing.rotateAngleY = -(MathHelper.cos(f2 * 1.7F) * (float)Math.PI * 0.5F); - LeftWing.rotateAngleY = MathHelper.cos(f2 * 1.7F) * (float)Math.PI * 0.5F; - } - -} \ No newline at end of file + RightWing.rotateAngleY = -(MathHelper.cos(f2 * 1.7F) * (float) Math.PI * 0.5F); + LeftWing.rotateAngleY = MathHelper.cos(f2 * 1.7F) * (float) Math.PI * 0.5F; + } +} diff --git a/src/main/java/vazkii/botania/client/model/ModelPool.java b/src/main/java/vazkii/botania/client/model/ModelPool.java index 1cc52537a0..dff7ccbd00 100644 --- a/src/main/java/vazkii/botania/client/model/ModelPool.java +++ b/src/main/java/vazkii/botania/client/model/ModelPool.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jan 25, 2014, 1:53:32 PM (GMT)] */ package vazkii.botania.client.model; @@ -15,44 +15,44 @@ public class ModelPool extends ModelBase { - ModelRenderer base; - ModelRenderer side1; - ModelRenderer side2; - ModelRenderer side3; - ModelRenderer side4; + ModelRenderer base; + ModelRenderer side1; + ModelRenderer side2; + ModelRenderer side3; + ModelRenderer side4; - public ModelPool() { - textureWidth = 64; - textureHeight = 32; + public ModelPool() { + textureWidth = 64; + textureHeight = 32; - base = new ModelRenderer(this, 0, 0); - base.addBox(0F, 0F, 0F, 16, 1, 16); - base.setRotationPoint(-8F, 23F, -8F); - base.setTextureSize(64, 32); - side1 = new ModelRenderer(this, 0, 0); - side1.addBox(0F, 0F, 0F, 16, 7, 1); - side1.setRotationPoint(-8F, 16F, 7F); - side1.setTextureSize(64, 32); - side2 = new ModelRenderer(this, 0, 0); - side2.addBox(0F, 0F, 0F, 16, 7, 1); - side2.setRotationPoint(-8F, 16F, -8F); - side2.setTextureSize(64, 32); - side3 = new ModelRenderer(this, 0, 0); - side3.addBox(0F, 0F, 0F, 1, 7, 14); - side3.setRotationPoint(-8F, 16F, -7F); - side3.setTextureSize(64, 32); - side4 = new ModelRenderer(this, 0, 0); - side4.addBox(0F, 0F, 0F, 1, 7, 14); - side4.setRotationPoint(7F, 16F, -7F); - side4.setTextureSize(64, 32); - } + base = new ModelRenderer(this, 0, 0); + base.addBox(0F, 0F, 0F, 16, 1, 16); + base.setRotationPoint(-8F, 23F, -8F); + base.setTextureSize(64, 32); + side1 = new ModelRenderer(this, 0, 0); + side1.addBox(0F, 0F, 0F, 16, 7, 1); + side1.setRotationPoint(-8F, 16F, 7F); + side1.setTextureSize(64, 32); + side2 = new ModelRenderer(this, 0, 0); + side2.addBox(0F, 0F, 0F, 16, 7, 1); + side2.setRotationPoint(-8F, 16F, -8F); + side2.setTextureSize(64, 32); + side3 = new ModelRenderer(this, 0, 0); + side3.addBox(0F, 0F, 0F, 1, 7, 14); + side3.setRotationPoint(-8F, 16F, -7F); + side3.setTextureSize(64, 32); + side4 = new ModelRenderer(this, 0, 0); + side4.addBox(0F, 0F, 0F, 1, 7, 14); + side4.setRotationPoint(7F, 16F, -7F); + side4.setTextureSize(64, 32); + } - public void render() { - float f = 1F / 16F; - base.render(f); - side1.render(f); - side2.render(f); - side3.render(f); - side4.render(f); - } -} \ No newline at end of file + public void render() { + float f = 1F / 16F; + base.render(f); + side1.render(f); + side2.render(f); + side3.render(f); + side4.render(f); + } +} diff --git a/src/main/java/vazkii/botania/client/model/ModelPump.java b/src/main/java/vazkii/botania/client/model/ModelPump.java index e869a3d5e3..967be99568 100644 --- a/src/main/java/vazkii/botania/client/model/ModelPump.java +++ b/src/main/java/vazkii/botania/client/model/ModelPump.java @@ -2,70 +2,65 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [? (GMT)] */ package vazkii.botania.client.model; import java.util.ArrayList; - import net.minecraft.client.model.ModelBase; import net.minecraft.client.model.ModelRenderer; -public class ModelPump extends ModelBase{ - - private ArrayList parts = new ArrayList(); - - private ArrayList innerRing = new ArrayList(); - private ArrayList outerRing = new ArrayList(); +public class ModelPump extends ModelBase { - public ModelPump() { - textureWidth = 64; - textureHeight = 32; + private ArrayList parts = new ArrayList(); - ModelRenderer main = new ModelRenderer(this, 0, 0); - main.addBox(-2.0F, -2.0F, -7.0F, 4, 4, 14); - main.setRotationPoint(0.0F, 4.0F, 0.0F); + private ArrayList innerRing = new ArrayList(); + private ArrayList outerRing = new ArrayList(); - for(float r = 0; r <= Math.PI * 2; r += Math.PI) { - ModelRenderer side = new ModelRenderer(this, 22, 0); + public ModelPump() { + textureWidth = 64; + textureHeight = 32; - side.addBox(-4.0F, -4.0F, 7.0F, 8, 8, 1); - side.setRotationPoint(0.0F, 0.0F, 0.0F); - side.rotateAngleY = r; - main.addChild(side); - } + ModelRenderer main = new ModelRenderer(this, 0, 0); + main.addBox(-2.0F, -2.0F, -7.0F, 4, 4, 14); + main.setRotationPoint(0.0F, 4.0F, 0.0F); - for(float r = 0; r <= Math.PI * 2; r += Math.PI / 2) { - ModelRenderer innerPlate = new ModelRenderer(this, 0, 18); - ModelRenderer outerPlate = new ModelRenderer(this, 22, 18); + for (float r = 0; r <= Math.PI * 2; r += Math.PI) { + ModelRenderer side = new ModelRenderer(this, 22, 0); - innerPlate.addBox(-3.0F, -3.0F, -7.0F, 5, 1, 6); - innerPlate.setRotationPoint(0.0F, 4.0F, 0.0F); - innerPlate.rotateAngleZ = r; - innerRing.add(innerPlate); - parts.add(innerPlate); + side.addBox(-4.0F, -4.0F, 7.0F, 8, 8, 1); + side.setRotationPoint(0.0F, 0.0F, 0.0F); + side.rotateAngleY = r; + main.addChild(side); + } + for (float r = 0; r <= Math.PI * 2; r += Math.PI / 2) { + ModelRenderer innerPlate = new ModelRenderer(this, 0, 18); + ModelRenderer outerPlate = new ModelRenderer(this, 22, 18); - outerPlate.addBox(-4.0F, -4.0F, 3.0F, 7, 1, 4); - outerPlate.setRotationPoint(0.0F, 4.0F, 0.0F); - outerPlate.rotateAngleZ = r; - outerRing.add(outerPlate); - parts.add(outerPlate); - } + innerPlate.addBox(-3.0F, -3.0F, -7.0F, 5, 1, 6); + innerPlate.setRotationPoint(0.0F, 4.0F, 0.0F); + innerPlate.rotateAngleZ = r; + innerRing.add(innerPlate); + parts.add(innerPlate); - parts.add(main); + outerPlate.addBox(-4.0F, -4.0F, 3.0F, 7, 1, 4); + outerPlate.setRotationPoint(0.0F, 4.0F, 0.0F); + outerPlate.rotateAngleZ = r; + outerRing.add(outerPlate); + parts.add(outerPlate); + } - } + parts.add(main); + } - public void render(float ringPos) { - for(ModelRenderer iRing : innerRing) - iRing.rotationPointZ = ringPos; + public void render(float ringPos) { + for (ModelRenderer iRing : innerRing) iRing.rotationPointZ = ringPos; - for(ModelRenderer part : parts) - part.render(1F / 16F); - } -} \ No newline at end of file + for (ModelRenderer part : parts) part.render(1F / 16F); + } +} diff --git a/src/main/java/vazkii/botania/client/model/ModelPylon.java b/src/main/java/vazkii/botania/client/model/ModelPylon.java index 3b90bf3717..3779b423c2 100644 --- a/src/main/java/vazkii/botania/client/model/ModelPylon.java +++ b/src/main/java/vazkii/botania/client/model/ModelPylon.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Apr 1, 2014, 6:21:48 PM (GMT)] */ package vazkii.botania.client.model; @@ -17,25 +17,24 @@ public class ModelPylon implements IPylonModel { - private IModelCustom model; + private IModelCustom model; - public ModelPylon() { - model = AdvancedModelLoader.loadModel(new ResourceLocation(LibResources.OBJ_MODEL_PYLON)); - } + public ModelPylon() { + model = AdvancedModelLoader.loadModel(new ResourceLocation(LibResources.OBJ_MODEL_PYLON)); + } - @Override - public void renderCrystal() { - model.renderPart("Crystal"); - } + @Override + public void renderCrystal() { + model.renderPart("Crystal"); + } - @Override - public void renderRing() { - model.renderAllExcept("Crystal", "Ring_Gem01", "Ring_Gem02", "Ring_Gem03", "Ring_Gem04"); - } + @Override + public void renderRing() { + model.renderAllExcept("Crystal", "Ring_Gem01", "Ring_Gem02", "Ring_Gem03", "Ring_Gem04"); + } - @Override - public void renderGems() { - for(int i = 1; i < 5; i++) - model.renderPart("Ring_Gem0" + i); - } + @Override + public void renderGems() { + for (int i = 1; i < 5; i++) model.renderPart("Ring_Gem0" + i); + } } diff --git a/src/main/java/vazkii/botania/client/model/ModelPylonOld.java b/src/main/java/vazkii/botania/client/model/ModelPylonOld.java index c600dd261f..862ae8b083 100644 --- a/src/main/java/vazkii/botania/client/model/ModelPylonOld.java +++ b/src/main/java/vazkii/botania/client/model/ModelPylonOld.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Feb 18, 2014, 10:05:39 PM (GMT)] */ package vazkii.botania.client.model; @@ -15,144 +15,143 @@ public class ModelPylonOld extends ModelBase implements IPylonModel { - ModelRenderer crystal1; - ModelRenderer crystal2; - ModelRenderer crystal3; - ModelRenderer crystal4; - ModelRenderer crystal5; - ModelRenderer crystal6; - ModelRenderer crystal7; - ModelRenderer crystal8; - ModelRenderer outside1; - ModelRenderer outside2; - ModelRenderer outside3; - ModelRenderer outside4; - ModelRenderer outside5; - ModelRenderer outside6; - ModelRenderer outside7; - ModelRenderer outside8; + ModelRenderer crystal1; + ModelRenderer crystal2; + ModelRenderer crystal3; + ModelRenderer crystal4; + ModelRenderer crystal5; + ModelRenderer crystal6; + ModelRenderer crystal7; + ModelRenderer crystal8; + ModelRenderer outside1; + ModelRenderer outside2; + ModelRenderer outside3; + ModelRenderer outside4; + ModelRenderer outside5; + ModelRenderer outside6; + ModelRenderer outside7; + ModelRenderer outside8; - public ModelPylonOld() { - textureWidth = 64; - textureHeight = 32; + public ModelPylonOld() { + textureWidth = 64; + textureHeight = 32; - crystal1 = new ModelRenderer(this, 0, 0); - crystal1.addBox(-1.5F, -7F, -1F, 3, 7, 2); - crystal1.setRotationPoint(0F, 23F, 0F); - crystal1.setTextureSize(256, 128); - setRotation(crystal1, 0.1396263F, -0.418879F, 0F); - crystal2 = new ModelRenderer(this, 0, 0); - crystal2.addBox(-1.5F, -7F, -1F, 3, 7, 2); - crystal2.setRotationPoint(0F, 23F, 0F); - crystal2.setTextureSize(256, 128); - setRotation(crystal2, -0.1396263F, 0.418879F, 0F); - crystal3 = new ModelRenderer(this, 0, 0); - crystal3.addBox(-1.5F, -7F, -1F, 3, 7, 2); - crystal3.setRotationPoint(0F, 23F, 0F); - crystal3.setTextureSize(256, 128); - setRotation(crystal3, 0.1396263F, 0.418879F, 0F); - crystal4 = new ModelRenderer(this, 0, 0); - crystal4.addBox(-1.5F, -7F, -1F, 3, 7, 2); - crystal4.setRotationPoint(0F, 23F, 0F); - crystal4.setTextureSize(256, 128); - setRotation(crystal4, -0.1396263F, -0.418879F, 0F); - crystal5 = new ModelRenderer(this, 0, 0); - crystal5.addBox(-1.5F, 0F, -1F, 3, 7, 2); - crystal5.setRotationPoint(0F, 10F, 0F); - crystal5.setTextureSize(256, 128); - setRotation(crystal5, 0.1396263F, 0.418879F, 0F); - crystal6 = new ModelRenderer(this, 0, 0); - crystal6.addBox(-1.5F, 0F, -1F, 3, 7, 2); - crystal6.setRotationPoint(0F, 10F, 0F); - crystal6.setTextureSize(256, 128); - setRotation(crystal6, 0.1396263F, -0.418879F, 0F); - crystal7 = new ModelRenderer(this, 0, 0); - crystal7.addBox(-1.5F, 0F, -1F, 3, 7, 2); - crystal7.setRotationPoint(0F, 10F, 0F); - crystal7.setTextureSize(256, 128); - setRotation(crystal7, -0.1396263F, -0.418879F, 0F); - crystal8 = new ModelRenderer(this, 0, 0); - crystal8.addBox(-1.5F, 0F, -1F, 3, 7, 2); - crystal8.setRotationPoint(0F, 10F, 0F); - crystal8.setTextureSize(256, 128); - setRotation(crystal8, -0.1396263F, 0.418879F, 0F); - outside1 = new ModelRenderer(this, 17, 0); - outside1.addBox(0F, -4F, -1.5F, 1, 8, 3); - outside1.setRotationPoint(4F, 18F, 0F); - outside1.setTextureSize(256, 128); - setRotation(outside1, 0F, 0F, 0.1396263F); - outside2 = new ModelRenderer(this, 17, 0); - outside2.addBox(-1F, -4F, -1.5F, 1, 8, 3); - outside2.setRotationPoint(-4F, 18F, 0F); - outside2.setTextureSize(256, 128); - setRotation(outside2, 0F, 0F, -0.1396263F); - outside3 = new ModelRenderer(this, 26, 0); - outside3.addBox(-1.5F, -3F, -1F, 3, 6, 1); - outside3.setRotationPoint(0F, 18F, -4F); - outside3.setTextureSize(256, 128); - setRotation(outside3, 0.0698132F, 0F, 0F); - outside4 = new ModelRenderer(this, 26, 0); - outside4.addBox(-1.5F, -3F, 0F, 3, 6, 1); - outside4.setRotationPoint(0F, 18F, 4F); - outside4.setTextureSize(256, 128); - setRotation(outside4, -0.0698132F, 0F, 0F); - outside5 = new ModelRenderer(this, 27, 0); - outside5.addBox(0F, 0F, -4F, 1, 2, 8); - outside5.setRotationPoint(3F, 18F, 0F); - outside5.setTextureSize(256, 128); - setRotation(outside5, 0F, 0F, 0F); - outside6 = new ModelRenderer(this, 27, 0); - outside6.addBox(-1F, -1F, -4F, 1, 2, 8); - outside6.setRotationPoint(-3F, 19F, 0F); - outside6.setTextureSize(256, 128); - setRotation(outside6, 0F, 0F, 0F); - outside7 = new ModelRenderer(this, 17, 12); - outside7.addBox(-3F, -1F, 0F, 6, 2, 1); - outside7.setRotationPoint(0F, 19F, 3F); - outside7.setTextureSize(256, 128); - setRotation(outside7, 0F, 0F, 0F); - outside8 = new ModelRenderer(this, 17, 12); - outside8.addBox(-3F, -1F, -1F, 6, 2, 1); - outside8.setRotationPoint(0F, 19F, -3F); - outside8.setTextureSize(256, 128); - setRotation(outside8, 0F, 0F, 0F); - } + crystal1 = new ModelRenderer(this, 0, 0); + crystal1.addBox(-1.5F, -7F, -1F, 3, 7, 2); + crystal1.setRotationPoint(0F, 23F, 0F); + crystal1.setTextureSize(256, 128); + setRotation(crystal1, 0.1396263F, -0.418879F, 0F); + crystal2 = new ModelRenderer(this, 0, 0); + crystal2.addBox(-1.5F, -7F, -1F, 3, 7, 2); + crystal2.setRotationPoint(0F, 23F, 0F); + crystal2.setTextureSize(256, 128); + setRotation(crystal2, -0.1396263F, 0.418879F, 0F); + crystal3 = new ModelRenderer(this, 0, 0); + crystal3.addBox(-1.5F, -7F, -1F, 3, 7, 2); + crystal3.setRotationPoint(0F, 23F, 0F); + crystal3.setTextureSize(256, 128); + setRotation(crystal3, 0.1396263F, 0.418879F, 0F); + crystal4 = new ModelRenderer(this, 0, 0); + crystal4.addBox(-1.5F, -7F, -1F, 3, 7, 2); + crystal4.setRotationPoint(0F, 23F, 0F); + crystal4.setTextureSize(256, 128); + setRotation(crystal4, -0.1396263F, -0.418879F, 0F); + crystal5 = new ModelRenderer(this, 0, 0); + crystal5.addBox(-1.5F, 0F, -1F, 3, 7, 2); + crystal5.setRotationPoint(0F, 10F, 0F); + crystal5.setTextureSize(256, 128); + setRotation(crystal5, 0.1396263F, 0.418879F, 0F); + crystal6 = new ModelRenderer(this, 0, 0); + crystal6.addBox(-1.5F, 0F, -1F, 3, 7, 2); + crystal6.setRotationPoint(0F, 10F, 0F); + crystal6.setTextureSize(256, 128); + setRotation(crystal6, 0.1396263F, -0.418879F, 0F); + crystal7 = new ModelRenderer(this, 0, 0); + crystal7.addBox(-1.5F, 0F, -1F, 3, 7, 2); + crystal7.setRotationPoint(0F, 10F, 0F); + crystal7.setTextureSize(256, 128); + setRotation(crystal7, -0.1396263F, -0.418879F, 0F); + crystal8 = new ModelRenderer(this, 0, 0); + crystal8.addBox(-1.5F, 0F, -1F, 3, 7, 2); + crystal8.setRotationPoint(0F, 10F, 0F); + crystal8.setTextureSize(256, 128); + setRotation(crystal8, -0.1396263F, 0.418879F, 0F); + outside1 = new ModelRenderer(this, 17, 0); + outside1.addBox(0F, -4F, -1.5F, 1, 8, 3); + outside1.setRotationPoint(4F, 18F, 0F); + outside1.setTextureSize(256, 128); + setRotation(outside1, 0F, 0F, 0.1396263F); + outside2 = new ModelRenderer(this, 17, 0); + outside2.addBox(-1F, -4F, -1.5F, 1, 8, 3); + outside2.setRotationPoint(-4F, 18F, 0F); + outside2.setTextureSize(256, 128); + setRotation(outside2, 0F, 0F, -0.1396263F); + outside3 = new ModelRenderer(this, 26, 0); + outside3.addBox(-1.5F, -3F, -1F, 3, 6, 1); + outside3.setRotationPoint(0F, 18F, -4F); + outside3.setTextureSize(256, 128); + setRotation(outside3, 0.0698132F, 0F, 0F); + outside4 = new ModelRenderer(this, 26, 0); + outside4.addBox(-1.5F, -3F, 0F, 3, 6, 1); + outside4.setRotationPoint(0F, 18F, 4F); + outside4.setTextureSize(256, 128); + setRotation(outside4, -0.0698132F, 0F, 0F); + outside5 = new ModelRenderer(this, 27, 0); + outside5.addBox(0F, 0F, -4F, 1, 2, 8); + outside5.setRotationPoint(3F, 18F, 0F); + outside5.setTextureSize(256, 128); + setRotation(outside5, 0F, 0F, 0F); + outside6 = new ModelRenderer(this, 27, 0); + outside6.addBox(-1F, -1F, -4F, 1, 2, 8); + outside6.setRotationPoint(-3F, 19F, 0F); + outside6.setTextureSize(256, 128); + setRotation(outside6, 0F, 0F, 0F); + outside7 = new ModelRenderer(this, 17, 12); + outside7.addBox(-3F, -1F, 0F, 6, 2, 1); + outside7.setRotationPoint(0F, 19F, 3F); + outside7.setTextureSize(256, 128); + setRotation(outside7, 0F, 0F, 0F); + outside8 = new ModelRenderer(this, 17, 12); + outside8.addBox(-3F, -1F, -1F, 6, 2, 1); + outside8.setRotationPoint(0F, 19F, -3F); + outside8.setTextureSize(256, 128); + setRotation(outside8, 0F, 0F, 0F); + } - @Override - public void renderCrystal() { - float f = 1F / 16F; - crystal1.render(f); - crystal2.render(f); - crystal3.render(f); - crystal4.render(f); - crystal5.render(f); - crystal6.render(f); - crystal7.render(f); - crystal8.render(f); - } + @Override + public void renderCrystal() { + float f = 1F / 16F; + crystal1.render(f); + crystal2.render(f); + crystal3.render(f); + crystal4.render(f); + crystal5.render(f); + crystal6.render(f); + crystal7.render(f); + crystal8.render(f); + } - @Override - public void renderRing() { - float f = 1F / 16F; - outside1.render(f); - outside2.render(f); - outside3.render(f); - outside4.render(f); - outside5.render(f); - outside6.render(f); - outside7.render(f); - outside8.render(f); - } + @Override + public void renderRing() { + float f = 1F / 16F; + outside1.render(f); + outside2.render(f); + outside3.render(f); + outside4.render(f); + outside5.render(f); + outside6.render(f); + outside7.render(f); + outside8.render(f); + } - private void setRotation(ModelRenderer model, float x, float y, float z) { - model.rotateAngleX = x; - model.rotateAngleY = y; - model.rotateAngleZ = z; - } + private void setRotation(ModelRenderer model, float x, float y, float z) { + model.rotateAngleX = x; + model.rotateAngleY = y; + model.rotateAngleZ = z; + } - @Override - public void renderGems() { - // NO-OP - } - -} \ No newline at end of file + @Override + public void renderGems() { + // NO-OP + } +} diff --git a/src/main/java/vazkii/botania/client/model/ModelSkullOverride.java b/src/main/java/vazkii/botania/client/model/ModelSkullOverride.java index 1ad6c4258d..93d0650269 100644 --- a/src/main/java/vazkii/botania/client/model/ModelSkullOverride.java +++ b/src/main/java/vazkii/botania/client/model/ModelSkullOverride.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [? (GMT)] */ package vazkii.botania.client.model; @@ -16,35 +16,36 @@ public class ModelSkullOverride extends ModelBase { - private final ModelRenderer bipedHead; - private final ModelRenderer bipedHeadwear; + private final ModelRenderer bipedHead; + private final ModelRenderer bipedHeadwear; - public ModelSkullOverride() { - textureWidth = 64; - textureHeight = 32; - bipedHead = new ModelRenderer(this, 0, 0); - bipedHead.addBox(-4.0F, -8.0F, -4.0F, 8, 8, 8, 0F); - bipedHead.setRotationPoint(0.0F, 0.0F, 0.0F); - bipedHeadwear = new ModelRenderer(this, 32, 0); - bipedHeadwear.addBox(-4.0F, -8.0F, -4.0F, 8, 8, 8, 0.5F); - bipedHeadwear.setRotationPoint(0.0F, 0.0F, 0.0F); - } + public ModelSkullOverride() { + textureWidth = 64; + textureHeight = 32; + bipedHead = new ModelRenderer(this, 0, 0); + bipedHead.addBox(-4.0F, -8.0F, -4.0F, 8, 8, 8, 0F); + bipedHead.setRotationPoint(0.0F, 0.0F, 0.0F); + bipedHeadwear = new ModelRenderer(this, 32, 0); + bipedHeadwear.addBox(-4.0F, -8.0F, -4.0F, 8, 8, 8, 0.5F); + bipedHeadwear.setRotationPoint(0.0F, 0.0F, 0.0F); + } - public void renderWithoutRotation(float par1) { - bipedHead.render(par1); - bipedHeadwear.render(par1); - } + public void renderWithoutRotation(float par1) { + bipedHead.render(par1); + bipedHeadwear.render(par1); + } - @Override - public void render(Entity par1Entity, float par2, float par3, float par4, float par5, float par6, float par7) { - setRotationAngles(par2, par3, par4, par5, par6, par7, par1Entity); - bipedHead.render(par7); - bipedHeadwear.render(par7); - } + @Override + public void render(Entity par1Entity, float par2, float par3, float par4, float par5, float par6, float par7) { + setRotationAngles(par2, par3, par4, par5, par6, par7, par1Entity); + bipedHead.render(par7); + bipedHeadwear.render(par7); + } - @Override - public void setRotationAngles(float par1, float par2, float par3, float par4, float par5, float par6, Entity par7Entity) { - bipedHead.rotateAngleY = bipedHeadwear.rotateAngleY = par4 / (180F / (float)Math.PI); - bipedHead.rotateAngleX = bipedHeadwear.rotateAngleX = par5 / (180F / (float)Math.PI); - } -} \ No newline at end of file + @Override + public void setRotationAngles( + float par1, float par2, float par3, float par4, float par5, float par6, Entity par7Entity) { + bipedHead.rotateAngleY = bipedHeadwear.rotateAngleY = par4 / (180F / (float) Math.PI); + bipedHead.rotateAngleX = bipedHeadwear.rotateAngleX = par5 / (180F / (float) Math.PI); + } +} diff --git a/src/main/java/vazkii/botania/client/model/ModelSpawnerClaw.java b/src/main/java/vazkii/botania/client/model/ModelSpawnerClaw.java index 4504ef8c66..ce1291f68c 100644 --- a/src/main/java/vazkii/botania/client/model/ModelSpawnerClaw.java +++ b/src/main/java/vazkii/botania/client/model/ModelSpawnerClaw.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jul 23, 2014, 5:46:38 PM (GMT)] */ package vazkii.botania.client.model; @@ -14,69 +14,68 @@ import net.minecraft.client.model.ModelRenderer; public class ModelSpawnerClaw extends ModelBase { - ModelRenderer Plate; - ModelRenderer Claw1; - ModelRenderer Claw2; - ModelRenderer Claw3; - ModelRenderer Claw4; - ModelRenderer Claw5; - ModelRenderer Claw6; - ModelRenderer Claw7; - ModelRenderer Claw8; + ModelRenderer Plate; + ModelRenderer Claw1; + ModelRenderer Claw2; + ModelRenderer Claw3; + ModelRenderer Claw4; + ModelRenderer Claw5; + ModelRenderer Claw6; + ModelRenderer Claw7; + ModelRenderer Claw8; - public ModelSpawnerClaw() { - textureWidth = 64; - textureHeight = 32; + public ModelSpawnerClaw() { + textureWidth = 64; + textureHeight = 32; - Plate = new ModelRenderer(this, 0, 0); - Plate.addBox(0F, 0F, 0F, 12, 1, 12); - Plate.setRotationPoint(-6F, 23F, -6F); - Plate.setTextureSize(64, 32); - Claw1 = new ModelRenderer(this, 0, 14); - Claw1.addBox(0F, 0F, 0F, 2, 1, 3); - Claw1.setRotationPoint(-1F, 23F, 6F); - Claw1.setTextureSize(64, 32); - Claw2 = new ModelRenderer(this, 11, 14); - Claw2.addBox(0F, 0F, 0F, 2, 1, 3); - Claw2.setRotationPoint(-1F, 23F, -9F); - Claw2.setTextureSize(64, 32); - Claw3 = new ModelRenderer(this, 0, 19); - Claw3.addBox(0F, 0F, 0F, 3, 1, 2); - Claw3.setRotationPoint(-9F, 23F, -1F); - Claw3.setTextureSize(64, 32); - Claw4 = new ModelRenderer(this, 11, 19); - Claw4.addBox(0F, 0F, 0F, 3, 1, 2); - Claw4.setRotationPoint(6F, 23F, -1F); - Claw4.setTextureSize(64, 32); - Claw5 = new ModelRenderer(this, 23, 16); - Claw5.addBox(0F, 0F, 0F, 2, 5, 1); - Claw5.setRotationPoint(-1F, 24F, 8F); - Claw5.setTextureSize(64, 32); - Claw6 = new ModelRenderer(this, 30, 16); - Claw6.addBox(0F, 0F, 0F, 1, 5, 2); - Claw6.setRotationPoint(8F, 24F, -1F); - Claw6.setTextureSize(64, 32); - Claw7 = new ModelRenderer(this, 37, 16); - Claw7.addBox(0F, 0F, 0F, 2, 5, 1); - Claw7.setRotationPoint(-1F, 24F, -9F); - Claw7.setTextureSize(64, 32); - Claw8 = new ModelRenderer(this, 44, 16); - Claw8.addBox(0F, 0F, 0F, 1, 5, 2); - Claw8.setRotationPoint(-9F, 24F, -1F); - Claw8.setTextureSize(64, 32); - } - - public void render() { - float f5 = 1F / 16F; - Plate.render(f5); - Claw1.render(f5); - Claw2.render(f5); - Claw3.render(f5); - Claw4.render(f5); - Claw5.render(f5); - Claw6.render(f5); - Claw7.render(f5); - Claw8.render(f5); - } + Plate = new ModelRenderer(this, 0, 0); + Plate.addBox(0F, 0F, 0F, 12, 1, 12); + Plate.setRotationPoint(-6F, 23F, -6F); + Plate.setTextureSize(64, 32); + Claw1 = new ModelRenderer(this, 0, 14); + Claw1.addBox(0F, 0F, 0F, 2, 1, 3); + Claw1.setRotationPoint(-1F, 23F, 6F); + Claw1.setTextureSize(64, 32); + Claw2 = new ModelRenderer(this, 11, 14); + Claw2.addBox(0F, 0F, 0F, 2, 1, 3); + Claw2.setRotationPoint(-1F, 23F, -9F); + Claw2.setTextureSize(64, 32); + Claw3 = new ModelRenderer(this, 0, 19); + Claw3.addBox(0F, 0F, 0F, 3, 1, 2); + Claw3.setRotationPoint(-9F, 23F, -1F); + Claw3.setTextureSize(64, 32); + Claw4 = new ModelRenderer(this, 11, 19); + Claw4.addBox(0F, 0F, 0F, 3, 1, 2); + Claw4.setRotationPoint(6F, 23F, -1F); + Claw4.setTextureSize(64, 32); + Claw5 = new ModelRenderer(this, 23, 16); + Claw5.addBox(0F, 0F, 0F, 2, 5, 1); + Claw5.setRotationPoint(-1F, 24F, 8F); + Claw5.setTextureSize(64, 32); + Claw6 = new ModelRenderer(this, 30, 16); + Claw6.addBox(0F, 0F, 0F, 1, 5, 2); + Claw6.setRotationPoint(8F, 24F, -1F); + Claw6.setTextureSize(64, 32); + Claw7 = new ModelRenderer(this, 37, 16); + Claw7.addBox(0F, 0F, 0F, 2, 5, 1); + Claw7.setRotationPoint(-1F, 24F, -9F); + Claw7.setTextureSize(64, 32); + Claw8 = new ModelRenderer(this, 44, 16); + Claw8.addBox(0F, 0F, 0F, 1, 5, 2); + Claw8.setRotationPoint(-9F, 24F, -1F); + Claw8.setTextureSize(64, 32); + } + public void render() { + float f5 = 1F / 16F; + Plate.render(f5); + Claw1.render(f5); + Claw2.render(f5); + Claw3.render(f5); + Claw4.render(f5); + Claw5.render(f5); + Claw6.render(f5); + Claw7.render(f5); + Claw8.render(f5); + } } diff --git a/src/main/java/vazkii/botania/client/model/ModelSpinningCubes.java b/src/main/java/vazkii/botania/client/model/ModelSpinningCubes.java index 2220b450c0..dbd1773c6b 100644 --- a/src/main/java/vazkii/botania/client/model/ModelSpinningCubes.java +++ b/src/main/java/vazkii/botania/client/model/ModelSpinningCubes.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Feb 2, 2014, 6:37:00 PM (GMT)] */ package vazkii.botania.client.model; @@ -13,78 +13,74 @@ import net.minecraft.client.model.ModelBase; import net.minecraft.client.model.ModelRenderer; import net.minecraft.client.renderer.OpenGlHelper; - import org.lwjgl.opengl.GL11; - import vazkii.botania.client.core.handler.ClientTickHandler; public class ModelSpinningCubes extends ModelBase { - ModelRenderer spinningCube; - - public ModelSpinningCubes() { - spinningCube = new ModelRenderer(this, 42, 0); - spinningCube.addBox(0F, 0F, 0F, 1, 1, 1); - spinningCube.setRotationPoint(0F, 0F, 0F); - spinningCube.setTextureSize(64, 64); - } - - public void renderSpinningCubes(int cubes, int repeat, int origRepeat) { - GL11.glDisable(GL11.GL_TEXTURE_2D); - - final float modifier = 6F; - final float rotationModifier = 0.2F; - final float radiusBase = 0.35F; - final float radiusMod = 0.05F; - - double ticks = ClientTickHandler.ticksInGame + ClientTickHandler.partialTicks - 1.3 * (origRepeat - repeat); - float offsetPerCube = 360 / cubes; - - GL11.glPushMatrix(); - GL11.glTranslatef(-0.025F, 0.85F, -0.025F); - for(int i = 0; i < cubes; i++) { - float offset = offsetPerCube * i; - float deg = (int) (ticks / rotationModifier % 360F + offset); - float rad = deg * (float) Math.PI / 180F; - float radiusX = (float) (radiusBase + radiusMod * Math.sin(ticks / modifier)); - float radiusZ = (float) (radiusBase + radiusMod * Math.cos(ticks / modifier)); - float x = (float) (radiusX * Math.cos(rad)); - float z = (float) (radiusZ * Math.sin(rad)); - float y = (float) Math.cos((ticks + 50 * i) / 5F) / 10F; - - GL11.glPushMatrix(); - GL11.glTranslatef(x, y, z); - float xRotate = (float) Math.sin(ticks * rotationModifier) / 2F; - float yRotate = (float) Math.max(0.6F, Math.sin(ticks * 0.1F) / 2F + 0.5F); - float zRotate = (float) Math.cos(ticks * rotationModifier) / 2F; - - GL11.glRotatef(deg, xRotate, yRotate, zRotate); - if(repeat < origRepeat) { - GL11.glColor4f(1F, 1F, 1F, (float) repeat / (float) origRepeat * 0.4F); - GL11.glEnable(GL11.GL_BLEND); - GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); - GL11.glDisable(GL11.GL_ALPHA_TEST); - } else GL11.glColor4f(1F, 1F, 1F, 1F); - - int light = 15728880; - int lightmapX = light % 65536; - int lightmapY = light / 65536; - - OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, lightmapX, lightmapY); - spinningCube.render(1F / 16F); - - if(repeat < origRepeat) { - GL11.glDisable(GL11.GL_BLEND); - GL11.glEnable(GL11.GL_ALPHA_TEST); - } - - GL11.glPopMatrix(); - } - GL11.glPopMatrix(); - GL11.glEnable(GL11.GL_TEXTURE_2D); - - if(repeat != 0) - renderSpinningCubes(cubes, repeat - 1, origRepeat); - } - + ModelRenderer spinningCube; + + public ModelSpinningCubes() { + spinningCube = new ModelRenderer(this, 42, 0); + spinningCube.addBox(0F, 0F, 0F, 1, 1, 1); + spinningCube.setRotationPoint(0F, 0F, 0F); + spinningCube.setTextureSize(64, 64); + } + + public void renderSpinningCubes(int cubes, int repeat, int origRepeat) { + GL11.glDisable(GL11.GL_TEXTURE_2D); + + final float modifier = 6F; + final float rotationModifier = 0.2F; + final float radiusBase = 0.35F; + final float radiusMod = 0.05F; + + double ticks = ClientTickHandler.ticksInGame + ClientTickHandler.partialTicks - 1.3 * (origRepeat - repeat); + float offsetPerCube = 360 / cubes; + + GL11.glPushMatrix(); + GL11.glTranslatef(-0.025F, 0.85F, -0.025F); + for (int i = 0; i < cubes; i++) { + float offset = offsetPerCube * i; + float deg = (int) (ticks / rotationModifier % 360F + offset); + float rad = deg * (float) Math.PI / 180F; + float radiusX = (float) (radiusBase + radiusMod * Math.sin(ticks / modifier)); + float radiusZ = (float) (radiusBase + radiusMod * Math.cos(ticks / modifier)); + float x = (float) (radiusX * Math.cos(rad)); + float z = (float) (radiusZ * Math.sin(rad)); + float y = (float) Math.cos((ticks + 50 * i) / 5F) / 10F; + + GL11.glPushMatrix(); + GL11.glTranslatef(x, y, z); + float xRotate = (float) Math.sin(ticks * rotationModifier) / 2F; + float yRotate = (float) Math.max(0.6F, Math.sin(ticks * 0.1F) / 2F + 0.5F); + float zRotate = (float) Math.cos(ticks * rotationModifier) / 2F; + + GL11.glRotatef(deg, xRotate, yRotate, zRotate); + if (repeat < origRepeat) { + GL11.glColor4f(1F, 1F, 1F, (float) repeat / (float) origRepeat * 0.4F); + GL11.glEnable(GL11.GL_BLEND); + GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); + GL11.glDisable(GL11.GL_ALPHA_TEST); + } else GL11.glColor4f(1F, 1F, 1F, 1F); + + int light = 15728880; + int lightmapX = light % 65536; + int lightmapY = light / 65536; + + OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, lightmapX, lightmapY); + spinningCube.render(1F / 16F); + + if (repeat < origRepeat) { + GL11.glDisable(GL11.GL_BLEND); + GL11.glEnable(GL11.GL_ALPHA_TEST); + } + + GL11.glPopMatrix(); + } + GL11.glPopMatrix(); + GL11.glEnable(GL11.GL_TEXTURE_2D); + + if (repeat != 0) renderSpinningCubes(cubes, repeat - 1, origRepeat); + } } diff --git a/src/main/java/vazkii/botania/client/model/ModelSpreader.java b/src/main/java/vazkii/botania/client/model/ModelSpreader.java index f0f2161dbb..6fd9255373 100644 --- a/src/main/java/vazkii/botania/client/model/ModelSpreader.java +++ b/src/main/java/vazkii/botania/client/model/ModelSpreader.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jan 25, 2014, 1:55:05 PM (GMT)] */ package vazkii.botania.client.model; @@ -15,78 +15,78 @@ public class ModelSpreader extends ModelBase { - ModelRenderer cubeSide1; - ModelRenderer cubeSide2; - ModelRenderer cubeSide3; - ModelRenderer cubeSide4; - ModelRenderer cubeSide5; - ModelRenderer cubeHole1; - ModelRenderer cubeHole2; - ModelRenderer cubeHole3; - ModelRenderer cubeHole4; - ModelRenderer cubeInside; + ModelRenderer cubeSide1; + ModelRenderer cubeSide2; + ModelRenderer cubeSide3; + ModelRenderer cubeSide4; + ModelRenderer cubeSide5; + ModelRenderer cubeHole1; + ModelRenderer cubeHole2; + ModelRenderer cubeHole3; + ModelRenderer cubeHole4; + ModelRenderer cubeInside; - public ModelSpreader() { - textureWidth = 64; - textureHeight = 32; + public ModelSpreader() { + textureWidth = 64; + textureHeight = 32; - cubeSide1 = new ModelRenderer(this, 0, 0); - cubeSide1.addBox(0F, 0F, 0F, 14, 1, 14); - cubeSide1.setRotationPoint(-7F, 22F, -7F); - cubeSide1.setTextureSize(64, 32); - cubeSide2 = new ModelRenderer(this, 0, 0); - cubeSide2.addBox(0F, 0F, 0F, 14, 13, 1); - cubeSide2.setRotationPoint(-7F, 9F, -7F); - cubeSide2.setTextureSize(64, 32); - cubeSide3 = new ModelRenderer(this, 0, 0); - cubeSide3.addBox(0F, 0F, 0F, 1, 13, 13); - cubeSide3.setRotationPoint(-7F, 9F, -6F); - cubeSide3.setTextureSize(64, 32); - cubeSide4 = new ModelRenderer(this, 0, 0); - cubeSide4.addBox(0F, 0F, 0F, 1, 13, 13); - cubeSide4.setRotationPoint(6F, 9F, -6F); - cubeSide4.setTextureSize(64, 32); - cubeSide5 = new ModelRenderer(this, 0, 0); - cubeSide5.addBox(0F, 0F, 0F, 12, 1, 13); - cubeSide5.setRotationPoint(-6F, 9F, -6F); - cubeSide5.setTextureSize(64, 32); - cubeHole1 = new ModelRenderer(this, 0, 0); - cubeHole1.addBox(0F, 0F, 0F, 4, 12, 1); - cubeHole1.setRotationPoint(2F, 10F, 6F); - cubeHole1.setTextureSize(64, 32); - cubeHole2 = new ModelRenderer(this, 0, 0); - cubeHole2.addBox(0F, 0F, 0F, 4, 12, 1); - cubeHole2.setRotationPoint(-6F, 10F, 6F); - cubeHole2.setTextureSize(64, 32); - cubeHole3 = new ModelRenderer(this, 0, 0); - cubeHole3.addBox(0F, 0F, 0F, 4, 4, 1); - cubeHole3.setRotationPoint(-2F, 18F, 6F); - cubeHole3.setTextureSize(64, 32); - cubeHole4 = new ModelRenderer(this, 0, 0); - cubeHole4.addBox(0F, 0F, 0F, 4, 4, 1); - cubeHole4.setRotationPoint(-2F, 10F, 6F); - cubeHole4.setTextureSize(64, 32); - cubeInside = new ModelRenderer(this, 30, 17); - cubeInside.addBox(0F, 0F, 0F, 6, 6, 6); - cubeInside.setRotationPoint(-3F, 13F, -3F); - cubeInside.setTextureSize(64, 32); - } + cubeSide1 = new ModelRenderer(this, 0, 0); + cubeSide1.addBox(0F, 0F, 0F, 14, 1, 14); + cubeSide1.setRotationPoint(-7F, 22F, -7F); + cubeSide1.setTextureSize(64, 32); + cubeSide2 = new ModelRenderer(this, 0, 0); + cubeSide2.addBox(0F, 0F, 0F, 14, 13, 1); + cubeSide2.setRotationPoint(-7F, 9F, -7F); + cubeSide2.setTextureSize(64, 32); + cubeSide3 = new ModelRenderer(this, 0, 0); + cubeSide3.addBox(0F, 0F, 0F, 1, 13, 13); + cubeSide3.setRotationPoint(-7F, 9F, -6F); + cubeSide3.setTextureSize(64, 32); + cubeSide4 = new ModelRenderer(this, 0, 0); + cubeSide4.addBox(0F, 0F, 0F, 1, 13, 13); + cubeSide4.setRotationPoint(6F, 9F, -6F); + cubeSide4.setTextureSize(64, 32); + cubeSide5 = new ModelRenderer(this, 0, 0); + cubeSide5.addBox(0F, 0F, 0F, 12, 1, 13); + cubeSide5.setRotationPoint(-6F, 9F, -6F); + cubeSide5.setTextureSize(64, 32); + cubeHole1 = new ModelRenderer(this, 0, 0); + cubeHole1.addBox(0F, 0F, 0F, 4, 12, 1); + cubeHole1.setRotationPoint(2F, 10F, 6F); + cubeHole1.setTextureSize(64, 32); + cubeHole2 = new ModelRenderer(this, 0, 0); + cubeHole2.addBox(0F, 0F, 0F, 4, 12, 1); + cubeHole2.setRotationPoint(-6F, 10F, 6F); + cubeHole2.setTextureSize(64, 32); + cubeHole3 = new ModelRenderer(this, 0, 0); + cubeHole3.addBox(0F, 0F, 0F, 4, 4, 1); + cubeHole3.setRotationPoint(-2F, 18F, 6F); + cubeHole3.setTextureSize(64, 32); + cubeHole4 = new ModelRenderer(this, 0, 0); + cubeHole4.addBox(0F, 0F, 0F, 4, 4, 1); + cubeHole4.setRotationPoint(-2F, 10F, 6F); + cubeHole4.setTextureSize(64, 32); + cubeInside = new ModelRenderer(this, 30, 17); + cubeInside.addBox(0F, 0F, 0F, 6, 6, 6); + cubeInside.setRotationPoint(-3F, 13F, -3F); + cubeInside.setTextureSize(64, 32); + } - public void render() { - float f = 1F / 16F; - cubeSide1.render(f); - cubeSide2.render(f); - cubeSide3.render(f); - cubeSide4.render(f); - cubeSide5.render(f); - cubeHole1.render(f); - cubeHole2.render(f); - cubeHole3.render(f); - cubeHole4.render(f); - } + public void render() { + float f = 1F / 16F; + cubeSide1.render(f); + cubeSide2.render(f); + cubeSide3.render(f); + cubeSide4.render(f); + cubeSide5.render(f); + cubeHole1.render(f); + cubeHole2.render(f); + cubeHole3.render(f); + cubeHole4.render(f); + } - public void renderCube() { - float f = 1F / 16F; - cubeInside.render(f); - } -} \ No newline at end of file + public void renderCube() { + float f = 1F / 16F; + cubeInside.render(f); + } +} diff --git a/src/main/java/vazkii/botania/client/model/ModelTeruTeruBozu.java b/src/main/java/vazkii/botania/client/model/ModelTeruTeruBozu.java index 06817df7c0..c414251bb6 100644 --- a/src/main/java/vazkii/botania/client/model/ModelTeruTeruBozu.java +++ b/src/main/java/vazkii/botania/client/model/ModelTeruTeruBozu.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [? (GMT)] */ package vazkii.botania.client.model; @@ -16,43 +16,42 @@ public class ModelTeruTeruBozu extends ModelBase { - public ModelRenderer thread; - public ModelRenderer cloth; - public ModelRenderer happyFace; - public ModelRenderer sadFace; + public ModelRenderer thread; + public ModelRenderer cloth; + public ModelRenderer happyFace; + public ModelRenderer sadFace; - public ModelTeruTeruBozu() { - textureWidth = 64; - textureHeight = 32; - sadFace = new ModelRenderer(this, 32, 0); - sadFace.setRotationPoint(0.0F, 14.5F, 0.0F); - sadFace.addBox(-4.0F, -6.0F, -4.0F, 8, 8, 8, 0.0F); - setRotateAngle(sadFace, 0.17453292519943295F, 0.0F, 0.0F); - happyFace = new ModelRenderer(this, 0, 0); - happyFace.setRotationPoint(0.0F, 14.5F, 0.0F); - happyFace.addBox(-4.0F, -6.0F, -4.0F, 8, 8, 8, 0.0F); - setRotateAngle(happyFace, -0.17453292519943295F, 0.0F, 0.0F); - thread = new ModelRenderer(this, 32, 16); - thread.setRotationPoint(0.0F, 14.0F, 0.0F); - thread.addBox(-3.0F, 2.0F, -3.0F, 6, 1, 6, 0.0F); - cloth = new ModelRenderer(this, 0, 16); - cloth.setRotationPoint(0.0F, 21.5F, -1.0F); - cloth.addBox(-4.0F, -4.0F, -4.0F, 8, 8, 8, 0.0F); - setRotateAngle(cloth, 0.7853981633974483F, 2.2689280275926285F, 1.5707963267948966F); - } + public ModelTeruTeruBozu() { + textureWidth = 64; + textureHeight = 32; + sadFace = new ModelRenderer(this, 32, 0); + sadFace.setRotationPoint(0.0F, 14.5F, 0.0F); + sadFace.addBox(-4.0F, -6.0F, -4.0F, 8, 8, 8, 0.0F); + setRotateAngle(sadFace, 0.17453292519943295F, 0.0F, 0.0F); + happyFace = new ModelRenderer(this, 0, 0); + happyFace.setRotationPoint(0.0F, 14.5F, 0.0F); + happyFace.addBox(-4.0F, -6.0F, -4.0F, 8, 8, 8, 0.0F); + setRotateAngle(happyFace, -0.17453292519943295F, 0.0F, 0.0F); + thread = new ModelRenderer(this, 32, 16); + thread.setRotationPoint(0.0F, 14.0F, 0.0F); + thread.addBox(-3.0F, 2.0F, -3.0F, 6, 1, 6, 0.0F); + cloth = new ModelRenderer(this, 0, 16); + cloth.setRotationPoint(0.0F, 21.5F, -1.0F); + cloth.addBox(-4.0F, -4.0F, -4.0F, 8, 8, 8, 0.0F); + setRotateAngle(cloth, 0.7853981633974483F, 2.2689280275926285F, 1.5707963267948966F); + } - public void render() { - float f5 = 1F / 16F; - if(Minecraft.getMinecraft().theWorld.isRaining()) - sadFace.render(f5); - else happyFace.render(f5); - thread.render(f5); - cloth.render(f5); - } + public void render() { + float f5 = 1F / 16F; + if (Minecraft.getMinecraft().theWorld.isRaining()) sadFace.render(f5); + else happyFace.render(f5); + thread.render(f5); + cloth.render(f5); + } - public void setRotateAngle(ModelRenderer modelRenderer, float x, float y, float z) { - modelRenderer.rotateAngleX = x; - modelRenderer.rotateAngleY = y; - modelRenderer.rotateAngleZ = z; - } + public void setRotateAngle(ModelRenderer modelRenderer, float x, float y, float z) { + modelRenderer.rotateAngleX = x; + modelRenderer.rotateAngleY = y; + modelRenderer.rotateAngleZ = z; + } } diff --git a/src/main/java/vazkii/botania/client/model/ModelTinyPotato.java b/src/main/java/vazkii/botania/client/model/ModelTinyPotato.java index 5415f00d05..38a82ee869 100644 --- a/src/main/java/vazkii/botania/client/model/ModelTinyPotato.java +++ b/src/main/java/vazkii/botania/client/model/ModelTinyPotato.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jul 18, 2014, 7:55:34 PM (GMT)] */ package vazkii.botania.client.model; @@ -15,20 +15,19 @@ public class ModelTinyPotato extends ModelBase { - ModelRenderer potato; + ModelRenderer potato; - public ModelTinyPotato() { - textureWidth = 64; - textureHeight = 32; + public ModelTinyPotato() { + textureWidth = 64; + textureHeight = 32; - potato = new ModelRenderer(this, 0, 0); - potato.addBox(0F, 0F, 0F, 4, 6, 4); - potato.setRotationPoint(-2F, 18F, -2F); - potato.setTextureSize(64, 32); - } - - public void render() { - potato.render(1F / 16F); - } + potato = new ModelRenderer(this, 0, 0); + potato.addBox(0F, 0F, 0F, 4, 6, 4); + potato.setRotationPoint(-2F, 18F, -2F); + potato.setTextureSize(64, 32); + } + public void render() { + potato.render(1F / 16F); + } } diff --git a/src/main/java/vazkii/botania/client/model/armor/ModelArmorElementium.java b/src/main/java/vazkii/botania/client/model/armor/ModelArmorElementium.java index 8720d8f1ec..947f955dab 100644 --- a/src/main/java/vazkii/botania/client/model/armor/ModelArmorElementium.java +++ b/src/main/java/vazkii/botania/client/model/armor/ModelArmorElementium.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [? (GMT)] */ package vazkii.botania.client.model.armor; @@ -20,248 +20,245 @@ public class ModelArmorElementium extends ModelBiped { - public ModelRenderer helm; - public ModelRenderer body; - public ModelRenderer armR; - public ModelRenderer armL; - public ModelRenderer belt; - public ModelRenderer bootR; - public ModelRenderer bootL; - public ModelRenderer helm1; - public ModelRenderer helm2; - public ModelRenderer helm3; - public ModelRenderer fairy; - public ModelRenderer helmWing1; - public ModelRenderer helmWing2; - public ModelRenderer helmWing3; - public ModelRenderer helmWing4; - public ModelRenderer body2; - public ModelRenderer armRpauldron; - public ModelRenderer wing1; - public ModelRenderer wing2; - public ModelRenderer armLpauldron; - public ModelRenderer wing1_1; - public ModelRenderer wing2_1; - public ModelRenderer legR; - public ModelRenderer legL; - public ModelRenderer bootR1; - public ModelRenderer wing1_2; - public ModelRenderer wing2_2; - public ModelRenderer bootL1; - public ModelRenderer wing1_3; - public ModelRenderer wing2_3; + public ModelRenderer helm; + public ModelRenderer body; + public ModelRenderer armR; + public ModelRenderer armL; + public ModelRenderer belt; + public ModelRenderer bootR; + public ModelRenderer bootL; + public ModelRenderer helm1; + public ModelRenderer helm2; + public ModelRenderer helm3; + public ModelRenderer fairy; + public ModelRenderer helmWing1; + public ModelRenderer helmWing2; + public ModelRenderer helmWing3; + public ModelRenderer helmWing4; + public ModelRenderer body2; + public ModelRenderer armRpauldron; + public ModelRenderer wing1; + public ModelRenderer wing2; + public ModelRenderer armLpauldron; + public ModelRenderer wing1_1; + public ModelRenderer wing2_1; + public ModelRenderer legR; + public ModelRenderer legL; + public ModelRenderer bootR1; + public ModelRenderer wing1_2; + public ModelRenderer wing2_2; + public ModelRenderer bootL1; + public ModelRenderer wing1_3; + public ModelRenderer wing2_3; - int slot; + int slot; - public ModelArmorElementium(int slot) { - this.slot = slot; + public ModelArmorElementium(int slot) { + this.slot = slot; - textureWidth = 64; - textureHeight = 128; - float s = 0.2F; - fairy = new ModelRenderer(this, 34, 32); - fairy.setRotationPoint(0.0F, 0.0F, 0.0F); - fairy.addBox(-2.0F, -8.5F, -7.0F, 4, 4, 4, s); - setRotateAngle(fairy, -0.17453292519943295F, 0.0F, 0.0F); - helm3 = new ModelRenderer(this, 0, 32); - helm3.setRotationPoint(0.0F, 0.0F, 0.0F); - helm3.addBox(-1.0F, -5.5F, -5.5F, 2, 3, 1, s); - setRotateAngle(helm3, -0.17453292519943295F, 0.0F, 0.0F); - wing1_2 = new ModelRenderer(this, 56, 43); - wing1_2.mirror = true; - wing1_2.setRotationPoint(-2.5F, 9.0F, 0.0F); - wing1_2.addBox(0.5F, -2.0F, 0.0F, 0, 2, 3, s); - setRotateAngle(wing1_2, 0.2617993877991494F, -0.7853981633974483F, -0.2617993877991494F); - helm1 = new ModelRenderer(this, 50, 32); - helm1.setRotationPoint(0.0F, 0.0F, 0.0F); - helm1.addBox(-4.0F, -5.0F, -4.5F, 1, 5, 4, s); - legL = new ModelRenderer(this, 12, 79); - legL.mirror = true; - legL.setRotationPoint(1.9F, 12.0F, 0.0F); - legL.addBox(-2.0F, 0.0F, -2.0F, 4, 6, 4, s); - setRotateAngle(legL, 0.0F, 0.0F, 0F); - armL = new ModelRenderer(this, 0, 79); - armL.mirror = true; - armL.setRotationPoint(5.0F, 2.0F, -0.0F); - armL.addBox(1.5F, 6.0F, -2.0F, 2, 4, 4, s); - setRotateAngle(armL, 0.0F, 0.0F, 0F); - armRpauldron = new ModelRenderer(this, 0, 67); - armRpauldron.setRotationPoint(0.0F, 0.0F, 0.0F); - armRpauldron.addBox(-4.0F, -2.5F, -3.0F, 5, 6, 6, s); - legR = new ModelRenderer(this, 12, 79); - legR.setRotationPoint(-1.9F, 12.0F, 0.0F); - legR.addBox(-2.0F, 0.0F, -2.0F, 4, 6, 4, s); - setRotateAngle(legR, 0.0F, 0.0F, 0F); - helmWing2 = new ModelRenderer(this, 46, 45); - helmWing2.mirror = true; - helmWing2.setRotationPoint(-4.0F, -4.0F, -1.0F); - helmWing2.addBox(-0.5F, 0.0F, 0.0F, 1, 3, 4, s); - setRotateAngle(helmWing2, -0.2617993877991494F, -0.2617993877991494F, 0.2617993877991494F); - bootL1 = new ModelRenderer(this, 12, 79); - bootL1.mirror = true; - bootL1.setRotationPoint(0.0F, 0.0F, 0.0F); - bootL1.addBox(-2.0F, 7.0F, -2.0F, 4, 1, 4, s); - armR = new ModelRenderer(this, 0, 79); - armR.setRotationPoint(-5.0F, 2.0F, 0.0F); - armR.addBox(-3.5F, 6.0F, -2.0F, 2, 4, 4, s); - setRotateAngle(armR, 0.0F, 0.0F, 0F); - bootR1 = new ModelRenderer(this, 12, 79); - bootR1.setRotationPoint(0.0F, 0.0F, 0.0F); - bootR1.addBox(-2.0F, 7.0F, -2.0F, 4, 1, 4, s); - bootR = new ModelRenderer(this, 12, 79); - bootR.setRotationPoint(-1.9F, 12.0F, 0.0F); - bootR.addBox(-2.0F, 8.0F, -3.0F, 4, 4, 5, s); - setRotateAngle(bootR, 0.0F, 0.0F, 0F); - wing2_1 = new ModelRenderer(this, 56, 42); - wing2_1.setRotationPoint(4.5F, 0.0F, 0.0F); - wing2_1.addBox(0.0F, 0.0F, -0.5F, 0, 2, 3, s); - setRotateAngle(wing2_1, 0.08726646259971647F, 0.7853981633974483F, 0.2617993877991494F); - wing2_2 = new ModelRenderer(this, 56, 44); - wing2_2.mirror = true; - wing2_2.setRotationPoint(-2.5F, 9.0F, 0.0F); - wing2_2.addBox(0.5F, 0.0F, 0.0F, 0, 1, 2, s); - setRotateAngle(wing2_2, 0.08726646259971647F, -0.7853981633974483F, -0.2617993877991494F); - bootL = new ModelRenderer(this, 12, 79); - bootL.mirror = true; - bootL.setRotationPoint(1.9F, 12.0F, 0.0F); - bootL.addBox(-2.0F, 8.0F, -3.0F, 4, 4, 5, s); - setRotateAngle(bootL, 0.0F, 0.0F, 0F); - body = new ModelRenderer(this, 0, 44); - body.setRotationPoint(0.0F, 0.0F, 0.0F); - body.addBox(-4.5F, 0.0F, -4.0F, 9, 5, 7, s); - setRotateAngle(body, 0.08726646259971647F, 0.0F, 0.0F); - belt = new ModelRenderer(this, 22, 56); - belt.setRotationPoint(0.0F, 0.0F, 0.0F); - belt.addBox(-4.5F, 9.5F, -3.0F, 9, 3, 5, s); - helm = new ModelRenderer(this, 0, 32); - helm.setRotationPoint(0.0F, 0.0F, 0.0F); - helm.addBox(-4.0F, -8.0F, -4.5F, 8, 3, 9, s); - setRotateAngle(helm, 0.08726646259971647F, 0.0F, 0.0F); - helmWing4 = new ModelRenderer(this, 46, 45); - helmWing4.setRotationPoint(4.0F, -4.0F, -1.0F); - helmWing4.addBox(-0.5F, 0.0F, 0.0F, 1, 3, 4, s); - setRotateAngle(helmWing4, -0.2617993877991494F, 0.2617993877991494F, -0.2617993877991494F); - armLpauldron = new ModelRenderer(this, 0, 67); - armLpauldron.mirror = true; - armLpauldron.setRotationPoint(0.0F, 0.0F, -0.0F); - armLpauldron.addBox(-1.0F, -2.5F, -3.0F, 5, 6, 6, s); - wing1_1 = new ModelRenderer(this, 56, 41); - wing1_1.setRotationPoint(4.5F, 0.0F, 0.0F); - wing1_1.addBox(0.0F, -3.0F, -0.5F, 0, 3, 4, s); - setRotateAngle(wing1_1, 0.2617993877991494F, 0.7853981633974483F, 0.2617993877991494F); - helm2 = new ModelRenderer(this, 50, 32); - helm2.mirror = true; - helm2.setRotationPoint(0.0F, 0.0F, 0.0F); - helm2.addBox(3.0F, -5.0F, -4.5F, 1, 5, 4, s); - wing2_3 = new ModelRenderer(this, 56, 44); - wing2_3.setRotationPoint(2.5F, 9.0F, 0.0F); - wing2_3.addBox(0.0F, 0.0F, -0.5F, 0, 1, 2, s); - setRotateAngle(wing2_3, 0.08726646259971647F, 0.7853981633974483F, 0.2617993877991494F); - wing1 = new ModelRenderer(this, 56, 41); - wing1.mirror = true; - wing1.setRotationPoint(-4.5F, 0.0F, 0.0F); - wing1.addBox(0.5F, -3.0F, 0.0F, 0, 3, 4, s); - setRotateAngle(wing1, 0.2617993877991494F, -0.7853981633974483F, -0.2617993877991494F); - body2 = new ModelRenderer(this, 0, 56); - body2.setRotationPoint(0.0F, 0.0F, 0.0F); - body2.addBox(-3.0F, 4.0F, -3.0F, 6, 6, 5, s); - setRotateAngle(body2, -0.08726646259971647F, 0.0F, 0.0F); - helmWing3 = new ModelRenderer(this, 32, 45); - helmWing3.setRotationPoint(4.0F, -4.0F, -1.0F); - helmWing3.addBox(-0.5F, -5.0F, 0.0F, 1, 5, 6, s); - setRotateAngle(helmWing3, 0.2617993877991494F, 0.5235987755982988F, 0.08726646259971647F); - helmWing1 = new ModelRenderer(this, 32, 45); - helmWing1.mirror = true; - helmWing1.setRotationPoint(-4.0F, -4.0F, -1.0F); - helmWing1.addBox(-0.5F, -5.0F, 0.0F, 1, 5, 6, s); - setRotateAngle(helmWing1, 0.2617993877991494F, -0.5235987755982988F, -0.08726646259971647F); - wing2 = new ModelRenderer(this, 56, 42); - wing2.mirror = true; - wing2.setRotationPoint(-4.5F, 0.0F, 0.0F); - wing2.addBox(0.5F, 0.0F, 0.0F, 0, 2, 3, s); - setRotateAngle(wing2, 0.08726646259971647F, -0.7853981633974483F, -0.2617993877991494F); - wing1_3 = new ModelRenderer(this, 56, 43); - wing1_3.setRotationPoint(2.5F, 9.0F, 0.0F); - wing1_3.addBox(0.0F, -2.0F, -0.5F, 0, 2, 3, s); - setRotateAngle(wing1_3, 0.2617993877991494F, 0.7853981633974483F, 0.2617993877991494F); - helm.addChild(fairy); - helm.addChild(helm3); - bootR.addChild(wing1_2); - helm.addChild(helm1); - belt.addChild(legL); - armR.addChild(armRpauldron); - belt.addChild(legR); - helm.addChild(helmWing2); - bootL.addChild(bootL1); - bootR.addChild(bootR1); - armLpauldron.addChild(wing2_1); - bootR.addChild(wing2_2); - helm.addChild(helmWing4); - armL.addChild(armLpauldron); - armLpauldron.addChild(wing1_1); - helm.addChild(helm2); - bootL.addChild(wing2_3); - armRpauldron.addChild(wing1); - body.addChild(body2); - helm.addChild(helmWing3); - helm.addChild(helmWing1); - armRpauldron.addChild(wing2); - bootL.addChild(wing1_3); - } + textureWidth = 64; + textureHeight = 128; + float s = 0.2F; + fairy = new ModelRenderer(this, 34, 32); + fairy.setRotationPoint(0.0F, 0.0F, 0.0F); + fairy.addBox(-2.0F, -8.5F, -7.0F, 4, 4, 4, s); + setRotateAngle(fairy, -0.17453292519943295F, 0.0F, 0.0F); + helm3 = new ModelRenderer(this, 0, 32); + helm3.setRotationPoint(0.0F, 0.0F, 0.0F); + helm3.addBox(-1.0F, -5.5F, -5.5F, 2, 3, 1, s); + setRotateAngle(helm3, -0.17453292519943295F, 0.0F, 0.0F); + wing1_2 = new ModelRenderer(this, 56, 43); + wing1_2.mirror = true; + wing1_2.setRotationPoint(-2.5F, 9.0F, 0.0F); + wing1_2.addBox(0.5F, -2.0F, 0.0F, 0, 2, 3, s); + setRotateAngle(wing1_2, 0.2617993877991494F, -0.7853981633974483F, -0.2617993877991494F); + helm1 = new ModelRenderer(this, 50, 32); + helm1.setRotationPoint(0.0F, 0.0F, 0.0F); + helm1.addBox(-4.0F, -5.0F, -4.5F, 1, 5, 4, s); + legL = new ModelRenderer(this, 12, 79); + legL.mirror = true; + legL.setRotationPoint(1.9F, 12.0F, 0.0F); + legL.addBox(-2.0F, 0.0F, -2.0F, 4, 6, 4, s); + setRotateAngle(legL, 0.0F, 0.0F, 0F); + armL = new ModelRenderer(this, 0, 79); + armL.mirror = true; + armL.setRotationPoint(5.0F, 2.0F, -0.0F); + armL.addBox(1.5F, 6.0F, -2.0F, 2, 4, 4, s); + setRotateAngle(armL, 0.0F, 0.0F, 0F); + armRpauldron = new ModelRenderer(this, 0, 67); + armRpauldron.setRotationPoint(0.0F, 0.0F, 0.0F); + armRpauldron.addBox(-4.0F, -2.5F, -3.0F, 5, 6, 6, s); + legR = new ModelRenderer(this, 12, 79); + legR.setRotationPoint(-1.9F, 12.0F, 0.0F); + legR.addBox(-2.0F, 0.0F, -2.0F, 4, 6, 4, s); + setRotateAngle(legR, 0.0F, 0.0F, 0F); + helmWing2 = new ModelRenderer(this, 46, 45); + helmWing2.mirror = true; + helmWing2.setRotationPoint(-4.0F, -4.0F, -1.0F); + helmWing2.addBox(-0.5F, 0.0F, 0.0F, 1, 3, 4, s); + setRotateAngle(helmWing2, -0.2617993877991494F, -0.2617993877991494F, 0.2617993877991494F); + bootL1 = new ModelRenderer(this, 12, 79); + bootL1.mirror = true; + bootL1.setRotationPoint(0.0F, 0.0F, 0.0F); + bootL1.addBox(-2.0F, 7.0F, -2.0F, 4, 1, 4, s); + armR = new ModelRenderer(this, 0, 79); + armR.setRotationPoint(-5.0F, 2.0F, 0.0F); + armR.addBox(-3.5F, 6.0F, -2.0F, 2, 4, 4, s); + setRotateAngle(armR, 0.0F, 0.0F, 0F); + bootR1 = new ModelRenderer(this, 12, 79); + bootR1.setRotationPoint(0.0F, 0.0F, 0.0F); + bootR1.addBox(-2.0F, 7.0F, -2.0F, 4, 1, 4, s); + bootR = new ModelRenderer(this, 12, 79); + bootR.setRotationPoint(-1.9F, 12.0F, 0.0F); + bootR.addBox(-2.0F, 8.0F, -3.0F, 4, 4, 5, s); + setRotateAngle(bootR, 0.0F, 0.0F, 0F); + wing2_1 = new ModelRenderer(this, 56, 42); + wing2_1.setRotationPoint(4.5F, 0.0F, 0.0F); + wing2_1.addBox(0.0F, 0.0F, -0.5F, 0, 2, 3, s); + setRotateAngle(wing2_1, 0.08726646259971647F, 0.7853981633974483F, 0.2617993877991494F); + wing2_2 = new ModelRenderer(this, 56, 44); + wing2_2.mirror = true; + wing2_2.setRotationPoint(-2.5F, 9.0F, 0.0F); + wing2_2.addBox(0.5F, 0.0F, 0.0F, 0, 1, 2, s); + setRotateAngle(wing2_2, 0.08726646259971647F, -0.7853981633974483F, -0.2617993877991494F); + bootL = new ModelRenderer(this, 12, 79); + bootL.mirror = true; + bootL.setRotationPoint(1.9F, 12.0F, 0.0F); + bootL.addBox(-2.0F, 8.0F, -3.0F, 4, 4, 5, s); + setRotateAngle(bootL, 0.0F, 0.0F, 0F); + body = new ModelRenderer(this, 0, 44); + body.setRotationPoint(0.0F, 0.0F, 0.0F); + body.addBox(-4.5F, 0.0F, -4.0F, 9, 5, 7, s); + setRotateAngle(body, 0.08726646259971647F, 0.0F, 0.0F); + belt = new ModelRenderer(this, 22, 56); + belt.setRotationPoint(0.0F, 0.0F, 0.0F); + belt.addBox(-4.5F, 9.5F, -3.0F, 9, 3, 5, s); + helm = new ModelRenderer(this, 0, 32); + helm.setRotationPoint(0.0F, 0.0F, 0.0F); + helm.addBox(-4.0F, -8.0F, -4.5F, 8, 3, 9, s); + setRotateAngle(helm, 0.08726646259971647F, 0.0F, 0.0F); + helmWing4 = new ModelRenderer(this, 46, 45); + helmWing4.setRotationPoint(4.0F, -4.0F, -1.0F); + helmWing4.addBox(-0.5F, 0.0F, 0.0F, 1, 3, 4, s); + setRotateAngle(helmWing4, -0.2617993877991494F, 0.2617993877991494F, -0.2617993877991494F); + armLpauldron = new ModelRenderer(this, 0, 67); + armLpauldron.mirror = true; + armLpauldron.setRotationPoint(0.0F, 0.0F, -0.0F); + armLpauldron.addBox(-1.0F, -2.5F, -3.0F, 5, 6, 6, s); + wing1_1 = new ModelRenderer(this, 56, 41); + wing1_1.setRotationPoint(4.5F, 0.0F, 0.0F); + wing1_1.addBox(0.0F, -3.0F, -0.5F, 0, 3, 4, s); + setRotateAngle(wing1_1, 0.2617993877991494F, 0.7853981633974483F, 0.2617993877991494F); + helm2 = new ModelRenderer(this, 50, 32); + helm2.mirror = true; + helm2.setRotationPoint(0.0F, 0.0F, 0.0F); + helm2.addBox(3.0F, -5.0F, -4.5F, 1, 5, 4, s); + wing2_3 = new ModelRenderer(this, 56, 44); + wing2_3.setRotationPoint(2.5F, 9.0F, 0.0F); + wing2_3.addBox(0.0F, 0.0F, -0.5F, 0, 1, 2, s); + setRotateAngle(wing2_3, 0.08726646259971647F, 0.7853981633974483F, 0.2617993877991494F); + wing1 = new ModelRenderer(this, 56, 41); + wing1.mirror = true; + wing1.setRotationPoint(-4.5F, 0.0F, 0.0F); + wing1.addBox(0.5F, -3.0F, 0.0F, 0, 3, 4, s); + setRotateAngle(wing1, 0.2617993877991494F, -0.7853981633974483F, -0.2617993877991494F); + body2 = new ModelRenderer(this, 0, 56); + body2.setRotationPoint(0.0F, 0.0F, 0.0F); + body2.addBox(-3.0F, 4.0F, -3.0F, 6, 6, 5, s); + setRotateAngle(body2, -0.08726646259971647F, 0.0F, 0.0F); + helmWing3 = new ModelRenderer(this, 32, 45); + helmWing3.setRotationPoint(4.0F, -4.0F, -1.0F); + helmWing3.addBox(-0.5F, -5.0F, 0.0F, 1, 5, 6, s); + setRotateAngle(helmWing3, 0.2617993877991494F, 0.5235987755982988F, 0.08726646259971647F); + helmWing1 = new ModelRenderer(this, 32, 45); + helmWing1.mirror = true; + helmWing1.setRotationPoint(-4.0F, -4.0F, -1.0F); + helmWing1.addBox(-0.5F, -5.0F, 0.0F, 1, 5, 6, s); + setRotateAngle(helmWing1, 0.2617993877991494F, -0.5235987755982988F, -0.08726646259971647F); + wing2 = new ModelRenderer(this, 56, 42); + wing2.mirror = true; + wing2.setRotationPoint(-4.5F, 0.0F, 0.0F); + wing2.addBox(0.5F, 0.0F, 0.0F, 0, 2, 3, s); + setRotateAngle(wing2, 0.08726646259971647F, -0.7853981633974483F, -0.2617993877991494F); + wing1_3 = new ModelRenderer(this, 56, 43); + wing1_3.setRotationPoint(2.5F, 9.0F, 0.0F); + wing1_3.addBox(0.0F, -2.0F, -0.5F, 0, 2, 3, s); + setRotateAngle(wing1_3, 0.2617993877991494F, 0.7853981633974483F, 0.2617993877991494F); + helm.addChild(fairy); + helm.addChild(helm3); + bootR.addChild(wing1_2); + helm.addChild(helm1); + belt.addChild(legL); + armR.addChild(armRpauldron); + belt.addChild(legR); + helm.addChild(helmWing2); + bootL.addChild(bootL1); + bootR.addChild(bootR1); + armLpauldron.addChild(wing2_1); + bootR.addChild(wing2_2); + helm.addChild(helmWing4); + armL.addChild(armLpauldron); + armLpauldron.addChild(wing1_1); + helm.addChild(helm2); + bootL.addChild(wing2_3); + armRpauldron.addChild(wing1); + body.addChild(body2); + helm.addChild(helmWing3); + helm.addChild(helmWing1); + armRpauldron.addChild(wing2); + bootL.addChild(wing1_3); + } - @Override - public void render(Entity entity, float f, float f1, float f2, float f3, float f4, float f5) { - helm.showModel = slot == 0; - body.showModel = slot == 1; - armR.showModel = slot == 1; - armL.showModel = slot == 1; - legR.showModel = slot == 2; - legL.showModel = slot == 2; - bootL.showModel = slot == 3; - bootR.showModel = slot == 3; - bipedHeadwear.showModel = false; + @Override + public void render(Entity entity, float f, float f1, float f2, float f3, float f4, float f5) { + helm.showModel = slot == 0; + body.showModel = slot == 1; + armR.showModel = slot == 1; + armL.showModel = slot == 1; + legR.showModel = slot == 2; + legL.showModel = slot == 2; + bootL.showModel = slot == 3; + bootR.showModel = slot == 3; + bipedHeadwear.showModel = false; - bipedHead = helm; - bipedBody = body; - bipedRightArm = armR; - bipedLeftArm = armL; - if(slot == 2) { - bipedRightLeg = legR; - bipedLeftLeg = legL; - } else { - bipedRightLeg = bootR; - bipedLeftLeg = bootL; - } + bipedHead = helm; + bipedBody = body; + bipedRightArm = armR; + bipedLeftArm = armL; + if (slot == 2) { + bipedRightLeg = legR; + bipedLeftLeg = legL; + } else { + bipedRightLeg = bootR; + bipedLeftLeg = bootL; + } - prepareForRender(entity); - super.render(entity, f, f1, f2, f3, f4, f5); - } + prepareForRender(entity); + super.render(entity, f, f1, f2, f3, f4, f5); + } - public void prepareForRender(Entity entity) { - EntityLivingBase living = (EntityLivingBase) entity; - isSneak = living != null ? living.isSneaking() : false; - if(living != null && living instanceof EntityPlayer) { - EntityPlayer player = (EntityPlayer) living; + public void prepareForRender(Entity entity) { + EntityLivingBase living = (EntityLivingBase) entity; + isSneak = living != null ? living.isSneaking() : false; + if (living != null && living instanceof EntityPlayer) { + EntityPlayer player = (EntityPlayer) living; - ItemStack itemstack = player.inventory.getCurrentItem(); - heldItemRight = itemstack != null ? 1 : 0; + ItemStack itemstack = player.inventory.getCurrentItem(); + heldItemRight = itemstack != null ? 1 : 0; - aimedBow = false; - if (itemstack != null && player.getItemInUseCount() > 0) { - EnumAction enumaction = itemstack.getItemUseAction(); + aimedBow = false; + if (itemstack != null && player.getItemInUseCount() > 0) { + EnumAction enumaction = itemstack.getItemUseAction(); - if (enumaction == EnumAction.block) - heldItemRight = 3; - else if (enumaction == EnumAction.bow) - aimedBow = true; - } - } - } + if (enumaction == EnumAction.block) heldItemRight = 3; + else if (enumaction == EnumAction.bow) aimedBow = true; + } + } + } - public void setRotateAngle(ModelRenderer modelRenderer, float x, float y, float z) { - modelRenderer.rotateAngleX = x; - modelRenderer.rotateAngleY = y; - modelRenderer.rotateAngleZ = z; - } - -} \ No newline at end of file + public void setRotateAngle(ModelRenderer modelRenderer, float x, float y, float z) { + modelRenderer.rotateAngleX = x; + modelRenderer.rotateAngleY = y; + modelRenderer.rotateAngleZ = z; + } +} diff --git a/src/main/java/vazkii/botania/client/model/armor/ModelArmorManasteel.java b/src/main/java/vazkii/botania/client/model/armor/ModelArmorManasteel.java index a2d163a95c..508e3d3efa 100644 --- a/src/main/java/vazkii/botania/client/model/armor/ModelArmorManasteel.java +++ b/src/main/java/vazkii/botania/client/model/armor/ModelArmorManasteel.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [? (GMT)] */ package vazkii.botania.client.model.armor; @@ -20,177 +20,174 @@ public class ModelArmorManasteel extends ModelBiped { - public ModelRenderer helm; - public ModelRenderer body; - public ModelRenderer armR; - public ModelRenderer armL; - public ModelRenderer belt; - public ModelRenderer bootR; - public ModelRenderer bootL; - public ModelRenderer helm1; - public ModelRenderer helm2; - public ModelRenderer helm3; - public ModelRenderer helm4; - public ModelRenderer helm5; - public ModelRenderer helm6; - public ModelRenderer helm7; - public ModelRenderer body2; - public ModelRenderer armRpauldron; - public ModelRenderer armLpauldron; - public ModelRenderer legR; - public ModelRenderer legL; - - int slot; - - public ModelArmorManasteel(int slot) { - this.slot = slot; - - textureWidth = 64; - textureHeight = 128; - float s = 0.2F; - armRpauldron = new ModelRenderer(this, 30, 47); - armRpauldron.setRotationPoint(0.0F, 0.0F, 0.0F); - armRpauldron.addBox(-4.0F, -2.0F, -2.5F, 4, 4, 5, 0.2F); - armL = new ModelRenderer(this, 0, 68); - armL.mirror = true; - armL.setRotationPoint(5.0F, 2.0F, -0.0F); - armL.addBox(1.0F, 3.0F, -2.0F, 2, 6, 4, s); - setRotateAngle(armL, 0.0F, 0.0F, -0.17453292519943295F); - legR = new ModelRenderer(this, 12, 68); - legR.setRotationPoint(-1.9F, 12.0F, 0.0F); - legR.addBox(-2.0F, 0.0F, -2.0F, 4, 8, 4, s); - setRotateAngle(legR, 0.0F, 0.0F, 0F); - helm3 = new ModelRenderer(this, 24, 32); - helm3.setRotationPoint(0.0F, 0.0F, 0.0F); - helm3.addBox(-1.0F, -8.5F, -6.5F, 2, 5, 1, s); - setRotateAngle(helm3, -0.17453292519943295F, 0.0F, 0.0F); - helm7 = new ModelRenderer(this, 24, 32); - helm7.setRotationPoint(0.0F, 0.0F, 0.0F); - helm7.addBox(-1.0F, -8.5F, -6.0F, 2, 3, 1, s); - setRotateAngle(helm7, -0.3490658503988659F, 0.0F, 0.0F); - bootL = new ModelRenderer(this, 28, 68); - bootL.mirror = true; - bootL.setRotationPoint(2.0F, 12.0F, 0.0F); - bootL.addBox(-2.0F, 8.0F, -3.0F, 4, 4, 5, s); - setRotateAngle(bootL, 0.0F, 0.0F, 0F); - helm4 = new ModelRenderer(this, 0, 39); - helm4.setRotationPoint(0.0F, 0.0F, 0.0F); - helm4.addBox(-4.0F, -8.0F, -0.5F, 1, 3, 5, s); - bootR = new ModelRenderer(this, 28, 68); - bootR.setRotationPoint(-2.0F, 12.0F, 0.0F); - bootR.addBox(-2.0F, 8.0F, -3.0F, 4, 4, 5, s); - setRotateAngle(bootR, 0.0F, 0.0F, 0F); - legL = new ModelRenderer(this, 12, 68); - legL.mirror = true; - legL.setRotationPoint(1.9F, 12.0F, 0.0F); - legL.addBox(-2.0F, 0.0F, -2.0F, 4, 8, 4, s); - setRotateAngle(legL, 0.0F, 0.0F, 0F); - armR = new ModelRenderer(this, 0, 68); - armR.setRotationPoint(-5.0F, 2.0F, 0.0F); - armR.addBox(-3.0F, 3.0F, -2.0F, 2, 6, 4, s); - setRotateAngle(armR, 0.0F, 0.0F, 0.17453292519943295F); - helm1 = new ModelRenderer(this, 12, 39); - helm1.setRotationPoint(0.0F, 0.0F, 0.0F); - helm1.addBox(-4.0F, -5.0F, -4.5F, 1, 3, 4, s); - helm2 = new ModelRenderer(this, 12, 39); - helm2.mirror = true; - helm2.setRotationPoint(0.0F, 0.0F, 0.0F); - helm2.addBox(3.0F, -5.0F, -4.5F, 1, 3, 4, s); - body2 = new ModelRenderer(this, 0, 59); - body2.setRotationPoint(0.0F, 0.0F, 0.0F); - body2.addBox(-4.0F, 6.0F, -2.5F, 8, 4, 5, s); - setRotateAngle(body2, -0.08726646259971647F, 0.0F, 0.0F); - body = new ModelRenderer(this, 0, 47); - body.setRotationPoint(0.0F, 0.0F, 0.0F); - body.addBox(-4.5F, 0.0F, -3.5F, 9, 6, 6, s); - setRotateAngle(body, 0.08726646259971647F, 0.0F, 0.0F); - helm6 = new ModelRenderer(this, 24, 32); - helm6.setRotationPoint(0.0F, 0.0F, 0.0F); - helm6.addBox(-1.0F, -8.5F, -5.5F, 2, 3, 1, s); - setRotateAngle(helm6, -0.5235987755982988F, 0.0F, 0.0F); - belt = new ModelRenderer(this, 26, 59); - belt.setRotationPoint(0.0F, 0.0F, 0.0F); - belt.addBox(-4.5F, 9.5F, -3.0F, 9, 3, 6, s); - helm = new ModelRenderer(this, 0, 32); - helm.setRotationPoint(0.0F, 0.0F, 0.0F); - helm.addBox(-4.0F, -8.0F, -4.5F, 8, 3, 4, s); - setRotateAngle(helm, 0.08726646259971647F, 0.0F, 0.0F); - armLpauldron = new ModelRenderer(this, 30, 47); - armLpauldron.mirror = true; - armLpauldron.setRotationPoint(0.0F, 0.0F, -0.0F); - armLpauldron.addBox(0.0F, -2.0F, -2.5F, 4, 4, 5, s); - helm5 = new ModelRenderer(this, 0, 39); - helm5.mirror = true; - helm5.setRotationPoint(0.0F, 0.0F, 0.0F); - helm5.addBox(3.0F, -8.0F, -0.5F, 1, 3, 5, s); - - helm.addChild(helm3); - helm.addChild(helm7); - helm.addChild(helm4); - helm.addChild(helm6); - helm.addChild(helm1); - helm.addChild(helm2); - helm.addChild(helm5); - body.addChild(body2); - armL.addChild(armLpauldron); - armR.addChild(armRpauldron); - belt.addChild(legR); - belt.addChild(legL); - } - - @Override - public void render(Entity entity, float f, float f1, float f2, float f3, float f4, float f5) { - helm.showModel = slot == 0; - body.showModel = slot == 1; - armR.showModel = slot == 1; - armL.showModel = slot == 1; - legR.showModel = slot == 2; - legL.showModel = slot == 2; - bootL.showModel = slot == 3; - bootR.showModel = slot == 3; - bipedHeadwear.showModel = false; - - bipedHead = helm; - bipedBody = body; - bipedRightArm = armR; - bipedLeftArm = armL; - if(slot == 2) { - bipedRightLeg = legR; - bipedLeftLeg = legL; - } else { - bipedRightLeg = bootR; - bipedLeftLeg = bootL; - } - - prepareForRender(entity); - super.render(entity, f, f1, f2, f3, f4, f5); - } - - public void prepareForRender(Entity entity) { - EntityLivingBase living = (EntityLivingBase) entity; - isSneak = living != null ? living.isSneaking() : false; - if(living != null && living instanceof EntityPlayer) { - EntityPlayer player = (EntityPlayer) living; - - ItemStack itemstack = player.inventory.getCurrentItem(); - heldItemRight = itemstack != null ? 1 : 0; - - aimedBow = false; - if (itemstack != null && player.getItemInUseCount() > 0) { - EnumAction enumaction = itemstack.getItemUseAction(); - - if (enumaction == EnumAction.block) - heldItemRight = 3; - else if(enumaction == EnumAction.bow) - aimedBow = true; - } - } - } - - public void setRotateAngle(ModelRenderer modelRenderer, float x, float y, float z) { - modelRenderer.rotateAngleX = x; - modelRenderer.rotateAngleY = y; - modelRenderer.rotateAngleZ = z; - } - -} \ No newline at end of file + public ModelRenderer helm; + public ModelRenderer body; + public ModelRenderer armR; + public ModelRenderer armL; + public ModelRenderer belt; + public ModelRenderer bootR; + public ModelRenderer bootL; + public ModelRenderer helm1; + public ModelRenderer helm2; + public ModelRenderer helm3; + public ModelRenderer helm4; + public ModelRenderer helm5; + public ModelRenderer helm6; + public ModelRenderer helm7; + public ModelRenderer body2; + public ModelRenderer armRpauldron; + public ModelRenderer armLpauldron; + public ModelRenderer legR; + public ModelRenderer legL; + + int slot; + + public ModelArmorManasteel(int slot) { + this.slot = slot; + + textureWidth = 64; + textureHeight = 128; + float s = 0.2F; + armRpauldron = new ModelRenderer(this, 30, 47); + armRpauldron.setRotationPoint(0.0F, 0.0F, 0.0F); + armRpauldron.addBox(-4.0F, -2.0F, -2.5F, 4, 4, 5, 0.2F); + armL = new ModelRenderer(this, 0, 68); + armL.mirror = true; + armL.setRotationPoint(5.0F, 2.0F, -0.0F); + armL.addBox(1.0F, 3.0F, -2.0F, 2, 6, 4, s); + setRotateAngle(armL, 0.0F, 0.0F, -0.17453292519943295F); + legR = new ModelRenderer(this, 12, 68); + legR.setRotationPoint(-1.9F, 12.0F, 0.0F); + legR.addBox(-2.0F, 0.0F, -2.0F, 4, 8, 4, s); + setRotateAngle(legR, 0.0F, 0.0F, 0F); + helm3 = new ModelRenderer(this, 24, 32); + helm3.setRotationPoint(0.0F, 0.0F, 0.0F); + helm3.addBox(-1.0F, -8.5F, -6.5F, 2, 5, 1, s); + setRotateAngle(helm3, -0.17453292519943295F, 0.0F, 0.0F); + helm7 = new ModelRenderer(this, 24, 32); + helm7.setRotationPoint(0.0F, 0.0F, 0.0F); + helm7.addBox(-1.0F, -8.5F, -6.0F, 2, 3, 1, s); + setRotateAngle(helm7, -0.3490658503988659F, 0.0F, 0.0F); + bootL = new ModelRenderer(this, 28, 68); + bootL.mirror = true; + bootL.setRotationPoint(2.0F, 12.0F, 0.0F); + bootL.addBox(-2.0F, 8.0F, -3.0F, 4, 4, 5, s); + setRotateAngle(bootL, 0.0F, 0.0F, 0F); + helm4 = new ModelRenderer(this, 0, 39); + helm4.setRotationPoint(0.0F, 0.0F, 0.0F); + helm4.addBox(-4.0F, -8.0F, -0.5F, 1, 3, 5, s); + bootR = new ModelRenderer(this, 28, 68); + bootR.setRotationPoint(-2.0F, 12.0F, 0.0F); + bootR.addBox(-2.0F, 8.0F, -3.0F, 4, 4, 5, s); + setRotateAngle(bootR, 0.0F, 0.0F, 0F); + legL = new ModelRenderer(this, 12, 68); + legL.mirror = true; + legL.setRotationPoint(1.9F, 12.0F, 0.0F); + legL.addBox(-2.0F, 0.0F, -2.0F, 4, 8, 4, s); + setRotateAngle(legL, 0.0F, 0.0F, 0F); + armR = new ModelRenderer(this, 0, 68); + armR.setRotationPoint(-5.0F, 2.0F, 0.0F); + armR.addBox(-3.0F, 3.0F, -2.0F, 2, 6, 4, s); + setRotateAngle(armR, 0.0F, 0.0F, 0.17453292519943295F); + helm1 = new ModelRenderer(this, 12, 39); + helm1.setRotationPoint(0.0F, 0.0F, 0.0F); + helm1.addBox(-4.0F, -5.0F, -4.5F, 1, 3, 4, s); + helm2 = new ModelRenderer(this, 12, 39); + helm2.mirror = true; + helm2.setRotationPoint(0.0F, 0.0F, 0.0F); + helm2.addBox(3.0F, -5.0F, -4.5F, 1, 3, 4, s); + body2 = new ModelRenderer(this, 0, 59); + body2.setRotationPoint(0.0F, 0.0F, 0.0F); + body2.addBox(-4.0F, 6.0F, -2.5F, 8, 4, 5, s); + setRotateAngle(body2, -0.08726646259971647F, 0.0F, 0.0F); + body = new ModelRenderer(this, 0, 47); + body.setRotationPoint(0.0F, 0.0F, 0.0F); + body.addBox(-4.5F, 0.0F, -3.5F, 9, 6, 6, s); + setRotateAngle(body, 0.08726646259971647F, 0.0F, 0.0F); + helm6 = new ModelRenderer(this, 24, 32); + helm6.setRotationPoint(0.0F, 0.0F, 0.0F); + helm6.addBox(-1.0F, -8.5F, -5.5F, 2, 3, 1, s); + setRotateAngle(helm6, -0.5235987755982988F, 0.0F, 0.0F); + belt = new ModelRenderer(this, 26, 59); + belt.setRotationPoint(0.0F, 0.0F, 0.0F); + belt.addBox(-4.5F, 9.5F, -3.0F, 9, 3, 6, s); + helm = new ModelRenderer(this, 0, 32); + helm.setRotationPoint(0.0F, 0.0F, 0.0F); + helm.addBox(-4.0F, -8.0F, -4.5F, 8, 3, 4, s); + setRotateAngle(helm, 0.08726646259971647F, 0.0F, 0.0F); + armLpauldron = new ModelRenderer(this, 30, 47); + armLpauldron.mirror = true; + armLpauldron.setRotationPoint(0.0F, 0.0F, -0.0F); + armLpauldron.addBox(0.0F, -2.0F, -2.5F, 4, 4, 5, s); + helm5 = new ModelRenderer(this, 0, 39); + helm5.mirror = true; + helm5.setRotationPoint(0.0F, 0.0F, 0.0F); + helm5.addBox(3.0F, -8.0F, -0.5F, 1, 3, 5, s); + + helm.addChild(helm3); + helm.addChild(helm7); + helm.addChild(helm4); + helm.addChild(helm6); + helm.addChild(helm1); + helm.addChild(helm2); + helm.addChild(helm5); + body.addChild(body2); + armL.addChild(armLpauldron); + armR.addChild(armRpauldron); + belt.addChild(legR); + belt.addChild(legL); + } + + @Override + public void render(Entity entity, float f, float f1, float f2, float f3, float f4, float f5) { + helm.showModel = slot == 0; + body.showModel = slot == 1; + armR.showModel = slot == 1; + armL.showModel = slot == 1; + legR.showModel = slot == 2; + legL.showModel = slot == 2; + bootL.showModel = slot == 3; + bootR.showModel = slot == 3; + bipedHeadwear.showModel = false; + + bipedHead = helm; + bipedBody = body; + bipedRightArm = armR; + bipedLeftArm = armL; + if (slot == 2) { + bipedRightLeg = legR; + bipedLeftLeg = legL; + } else { + bipedRightLeg = bootR; + bipedLeftLeg = bootL; + } + + prepareForRender(entity); + super.render(entity, f, f1, f2, f3, f4, f5); + } + + public void prepareForRender(Entity entity) { + EntityLivingBase living = (EntityLivingBase) entity; + isSneak = living != null ? living.isSneaking() : false; + if (living != null && living instanceof EntityPlayer) { + EntityPlayer player = (EntityPlayer) living; + + ItemStack itemstack = player.inventory.getCurrentItem(); + heldItemRight = itemstack != null ? 1 : 0; + + aimedBow = false; + if (itemstack != null && player.getItemInUseCount() > 0) { + EnumAction enumaction = itemstack.getItemUseAction(); + + if (enumaction == EnumAction.block) heldItemRight = 3; + else if (enumaction == EnumAction.bow) aimedBow = true; + } + } + } + + public void setRotateAngle(ModelRenderer modelRenderer, float x, float y, float z) { + modelRenderer.rotateAngleX = x; + modelRenderer.rotateAngleY = y; + modelRenderer.rotateAngleZ = z; + } +} diff --git a/src/main/java/vazkii/botania/client/model/armor/ModelArmorManaweave.java b/src/main/java/vazkii/botania/client/model/armor/ModelArmorManaweave.java index ce2fd8c259..27aeb53bf0 100644 --- a/src/main/java/vazkii/botania/client/model/armor/ModelArmorManaweave.java +++ b/src/main/java/vazkii/botania/client/model/armor/ModelArmorManaweave.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [? (GMT)] */ package vazkii.botania.client.model.armor; @@ -20,178 +20,175 @@ public class ModelArmorManaweave extends ModelBiped { - public ModelRenderer helm; - public ModelRenderer body; - public ModelRenderer armR; - public ModelRenderer armL; - public ModelRenderer legR; - public ModelRenderer legL; - public ModelRenderer bootR; - public ModelRenderer bootL; - public ModelRenderer helm2; - public ModelRenderer helm3; - public ModelRenderer helm4; - public ModelRenderer helmSeam1; - public ModelRenderer helmSeam2; - public ModelRenderer helmSeam3; - public ModelRenderer helmSeam4; - public ModelRenderer body2; - public ModelRenderer armRpauldron; - public ModelRenderer armLpauldron; - public ModelRenderer skirtR; - public ModelRenderer skirtL; + public ModelRenderer helm; + public ModelRenderer body; + public ModelRenderer armR; + public ModelRenderer armL; + public ModelRenderer legR; + public ModelRenderer legL; + public ModelRenderer bootR; + public ModelRenderer bootL; + public ModelRenderer helm2; + public ModelRenderer helm3; + public ModelRenderer helm4; + public ModelRenderer helmSeam1; + public ModelRenderer helmSeam2; + public ModelRenderer helmSeam3; + public ModelRenderer helmSeam4; + public ModelRenderer body2; + public ModelRenderer armRpauldron; + public ModelRenderer armLpauldron; + public ModelRenderer skirtR; + public ModelRenderer skirtL; - int slot; + int slot; - public ModelArmorManaweave(int slot) { - this.slot = slot; + public ModelArmorManaweave(int slot) { + this.slot = slot; - textureWidth = 64; - textureHeight = 128; - float s = 0.2F; - helmSeam3 = new ModelRenderer(this, 26, 61); - helmSeam3.setRotationPoint(0.0F, 0.0F, 0.0F); - helmSeam3.addBox(-0.5F, -9.5F, 5.0F, 1, 11, 1, s); - helmSeam4 = new ModelRenderer(this, 39, 64); - helmSeam4.setRotationPoint(0.0F, 0.0F, 0.0F); - helmSeam4.addBox(-0.5F, 0.5F, -1.0F, 1, 1, 6, s); - skirtL = new ModelRenderer(this, 0, 83); - skirtL.mirror = true; - skirtL.setRotationPoint(0.0F, 0.0F, 0.0F); - skirtL.addBox(-2.0F, -2.0F, -3.5F, 5, 13, 7, s); - setRotateAngle(skirtL, 0.0F, -0.17453292519943295F, -0.2617993877991494F); - armR = new ModelRenderer(this, 24, 83); - armR.setRotationPoint(-5.0F, 2.0F, 0.0F); - armR.addBox(-3.0F, -1.5F, -2.5F, 4, 10, 5, s); - setRotateAngle(armR, 0.0F, 0.0F, 0F); - armL = new ModelRenderer(this, 24, 83); - armL.mirror = true; - armL.setRotationPoint(5.0F, 2.0F, -0.0F); - armL.addBox(-1.0F, -1.5F, -2.5F, 4, 10, 5, s); - setRotateAngle(armL, 0.0F, 0.0F, 0F); - bootR = new ModelRenderer(this, 0, 103); - bootR.setRotationPoint(-2.0F, 12.0F, 0.0F); - bootR.addBox(-2.0F, 8.0F, -3.0F, 4, 4, 5, s); - setRotateAngle(bootR, 0.0F, 0.0F, 0F); - legR = new ModelRenderer(this, 42, 81); - legR.setRotationPoint(-2.0F, 12.0F, 0.0F); - legR.addBox(-2.0F, 0.0F, -2.0F, 4, 6, 4, s); - setRotateAngle(legR, 0.0F, 0.0F, 0F); - helm2 = new ModelRenderer(this, 38, 42); - helm2.setRotationPoint(0.0F, 0.0F, 0.0F); - helm2.addBox(-4.49F, -4.0F, -2.5F, 1, 5, 8, s); - skirtR = new ModelRenderer(this, 0, 83); - skirtR.setRotationPoint(0.0F, 0.0F, 0.0F); - skirtR.addBox(-3.0F, -2.0F, -3.5F, 5, 13, 7, s); - setRotateAngle(skirtR, 0.0F, 0.17453292519943295F, 0.2617993877991494F); - armRpauldron = new ModelRenderer(this, 0, 72); - armRpauldron.setRotationPoint(0.0F, 0.0F, 0.0F); - armRpauldron.addBox(-4.0F, -2.0F, -3.0F, 3, 5, 6, s); - setRotateAngle(armRpauldron, 0.0F, 0.0F, 0F); - bootL = new ModelRenderer(this, 0, 103); - bootL.setRotationPoint(2.0F, 12.0F, 0.0F); - bootL.addBox(-2.0F, 8.0F, -3.0F, 4, 4, 5, s); - setRotateAngle(bootL, 0.0F, 0.0F, 0F); - helmSeam1 = new ModelRenderer(this, 30, 61); - helmSeam1.setRotationPoint(0.0F, 0.0F, 0.0F); - helmSeam1.addBox(-0.5F, -10.5F, -5.0F, 1, 7, 2, s); - helm = new ModelRenderer(this, 0, 32); - helm.setRotationPoint(0.0F, 0.0F, 0.0F); - helm.addBox(-4.5F, -10.0F, -4.5F, 9, 6, 10, s); - setRotateAngle(helm, 0F, 0.0F, 0.0F); - armLpauldron = new ModelRenderer(this, 0, 72); - armLpauldron.mirror = true; - armLpauldron.setRotationPoint(0.0F, 0.0F, 0.0F); - armLpauldron.addBox(1.0F, -2.0F, -3.0F, 3, 5, 6, s); - setRotateAngle(armLpauldron, 0.0F, 0.0F, 0F); - helm4 = new ModelRenderer(this, 38, 32); - helm4.setRotationPoint(0.0F, 0.0F, 0.0F); - helm4.addBox(-3.5F, -4.0F, 0.49F, 7, 5, 5, s); - helmSeam2 = new ModelRenderer(this, 36, 61); - helmSeam2.setRotationPoint(0.0F, 0.0F, 0.0F); - helmSeam2.addBox(-0.5F, -10.5F, -3.0F, 1, 1, 9, s); - legL = new ModelRenderer(this, 42, 81); - legL.mirror = true; - legL.setRotationPoint(2.0F, 12.0F, 0.0F); - legL.addBox(-2.0F, 0.0F, -2.0F, 4, 6, 4, s); - setRotateAngle(legL, 0.0F, 0.0F, 0F); - body2 = new ModelRenderer(this, 0, 61); - body2.setRotationPoint(0.0F, 0.0F, 0.0F); - body2.addBox(-4.0F, 6.0F, -2.5F, 8, 6, 5, s); - body = new ModelRenderer(this, 0, 48); - body.setRotationPoint(0.0F, 0.0F, 0.0F); - body.addBox(-4.5F, 0.0F, -3.0F, 9, 7, 6, s); - helm3 = new ModelRenderer(this, 38, 42); - helm3.mirror = true; - helm3.setRotationPoint(0.0F, 0.0F, 0F); - helm3.addBox(3.49F, -4.0F, -2.5F, 1, 5, 8, s); - helm.addChild(helmSeam3); - helm.addChild(helmSeam4); - legL.addChild(skirtL); - helm.addChild(helm2); - legR.addChild(skirtR); - armR.addChild(armRpauldron); - helm.addChild(helmSeam1); - armL.addChild(armLpauldron); - helm.addChild(helm4); - helm.addChild(helmSeam2); - body.addChild(body2); - helm.addChild(helm3); - } + textureWidth = 64; + textureHeight = 128; + float s = 0.2F; + helmSeam3 = new ModelRenderer(this, 26, 61); + helmSeam3.setRotationPoint(0.0F, 0.0F, 0.0F); + helmSeam3.addBox(-0.5F, -9.5F, 5.0F, 1, 11, 1, s); + helmSeam4 = new ModelRenderer(this, 39, 64); + helmSeam4.setRotationPoint(0.0F, 0.0F, 0.0F); + helmSeam4.addBox(-0.5F, 0.5F, -1.0F, 1, 1, 6, s); + skirtL = new ModelRenderer(this, 0, 83); + skirtL.mirror = true; + skirtL.setRotationPoint(0.0F, 0.0F, 0.0F); + skirtL.addBox(-2.0F, -2.0F, -3.5F, 5, 13, 7, s); + setRotateAngle(skirtL, 0.0F, -0.17453292519943295F, -0.2617993877991494F); + armR = new ModelRenderer(this, 24, 83); + armR.setRotationPoint(-5.0F, 2.0F, 0.0F); + armR.addBox(-3.0F, -1.5F, -2.5F, 4, 10, 5, s); + setRotateAngle(armR, 0.0F, 0.0F, 0F); + armL = new ModelRenderer(this, 24, 83); + armL.mirror = true; + armL.setRotationPoint(5.0F, 2.0F, -0.0F); + armL.addBox(-1.0F, -1.5F, -2.5F, 4, 10, 5, s); + setRotateAngle(armL, 0.0F, 0.0F, 0F); + bootR = new ModelRenderer(this, 0, 103); + bootR.setRotationPoint(-2.0F, 12.0F, 0.0F); + bootR.addBox(-2.0F, 8.0F, -3.0F, 4, 4, 5, s); + setRotateAngle(bootR, 0.0F, 0.0F, 0F); + legR = new ModelRenderer(this, 42, 81); + legR.setRotationPoint(-2.0F, 12.0F, 0.0F); + legR.addBox(-2.0F, 0.0F, -2.0F, 4, 6, 4, s); + setRotateAngle(legR, 0.0F, 0.0F, 0F); + helm2 = new ModelRenderer(this, 38, 42); + helm2.setRotationPoint(0.0F, 0.0F, 0.0F); + helm2.addBox(-4.49F, -4.0F, -2.5F, 1, 5, 8, s); + skirtR = new ModelRenderer(this, 0, 83); + skirtR.setRotationPoint(0.0F, 0.0F, 0.0F); + skirtR.addBox(-3.0F, -2.0F, -3.5F, 5, 13, 7, s); + setRotateAngle(skirtR, 0.0F, 0.17453292519943295F, 0.2617993877991494F); + armRpauldron = new ModelRenderer(this, 0, 72); + armRpauldron.setRotationPoint(0.0F, 0.0F, 0.0F); + armRpauldron.addBox(-4.0F, -2.0F, -3.0F, 3, 5, 6, s); + setRotateAngle(armRpauldron, 0.0F, 0.0F, 0F); + bootL = new ModelRenderer(this, 0, 103); + bootL.setRotationPoint(2.0F, 12.0F, 0.0F); + bootL.addBox(-2.0F, 8.0F, -3.0F, 4, 4, 5, s); + setRotateAngle(bootL, 0.0F, 0.0F, 0F); + helmSeam1 = new ModelRenderer(this, 30, 61); + helmSeam1.setRotationPoint(0.0F, 0.0F, 0.0F); + helmSeam1.addBox(-0.5F, -10.5F, -5.0F, 1, 7, 2, s); + helm = new ModelRenderer(this, 0, 32); + helm.setRotationPoint(0.0F, 0.0F, 0.0F); + helm.addBox(-4.5F, -10.0F, -4.5F, 9, 6, 10, s); + setRotateAngle(helm, 0F, 0.0F, 0.0F); + armLpauldron = new ModelRenderer(this, 0, 72); + armLpauldron.mirror = true; + armLpauldron.setRotationPoint(0.0F, 0.0F, 0.0F); + armLpauldron.addBox(1.0F, -2.0F, -3.0F, 3, 5, 6, s); + setRotateAngle(armLpauldron, 0.0F, 0.0F, 0F); + helm4 = new ModelRenderer(this, 38, 32); + helm4.setRotationPoint(0.0F, 0.0F, 0.0F); + helm4.addBox(-3.5F, -4.0F, 0.49F, 7, 5, 5, s); + helmSeam2 = new ModelRenderer(this, 36, 61); + helmSeam2.setRotationPoint(0.0F, 0.0F, 0.0F); + helmSeam2.addBox(-0.5F, -10.5F, -3.0F, 1, 1, 9, s); + legL = new ModelRenderer(this, 42, 81); + legL.mirror = true; + legL.setRotationPoint(2.0F, 12.0F, 0.0F); + legL.addBox(-2.0F, 0.0F, -2.0F, 4, 6, 4, s); + setRotateAngle(legL, 0.0F, 0.0F, 0F); + body2 = new ModelRenderer(this, 0, 61); + body2.setRotationPoint(0.0F, 0.0F, 0.0F); + body2.addBox(-4.0F, 6.0F, -2.5F, 8, 6, 5, s); + body = new ModelRenderer(this, 0, 48); + body.setRotationPoint(0.0F, 0.0F, 0.0F); + body.addBox(-4.5F, 0.0F, -3.0F, 9, 7, 6, s); + helm3 = new ModelRenderer(this, 38, 42); + helm3.mirror = true; + helm3.setRotationPoint(0.0F, 0.0F, 0F); + helm3.addBox(3.49F, -4.0F, -2.5F, 1, 5, 8, s); + helm.addChild(helmSeam3); + helm.addChild(helmSeam4); + legL.addChild(skirtL); + helm.addChild(helm2); + legR.addChild(skirtR); + armR.addChild(armRpauldron); + helm.addChild(helmSeam1); + armL.addChild(armLpauldron); + helm.addChild(helm4); + helm.addChild(helmSeam2); + body.addChild(body2); + helm.addChild(helm3); + } - @Override - public void render(Entity entity, float f, float f1, float f2, float f3, float f4, float f5) { - helm.showModel = slot == 0; - body.showModel = slot == 1; - armR.showModel = slot == 1; - armL.showModel = slot == 1; - legR.showModel = slot == 2; - legL.showModel = slot == 2; - bootL.showModel = slot == 3; - bootR.showModel = slot == 3; - bipedHeadwear.showModel = false; + @Override + public void render(Entity entity, float f, float f1, float f2, float f3, float f4, float f5) { + helm.showModel = slot == 0; + body.showModel = slot == 1; + armR.showModel = slot == 1; + armL.showModel = slot == 1; + legR.showModel = slot == 2; + legL.showModel = slot == 2; + bootL.showModel = slot == 3; + bootR.showModel = slot == 3; + bipedHeadwear.showModel = false; - bipedHead = helm; - bipedBody = body; - bipedRightArm = armR; - bipedLeftArm = armL; - if(slot == 2) { - bipedRightLeg = legR; - bipedLeftLeg = legL; - } else { - bipedRightLeg = bootR; - bipedLeftLeg = bootL; - } + bipedHead = helm; + bipedBody = body; + bipedRightArm = armR; + bipedLeftArm = armL; + if (slot == 2) { + bipedRightLeg = legR; + bipedLeftLeg = legL; + } else { + bipedRightLeg = bootR; + bipedLeftLeg = bootL; + } - prepareForRender(entity); - super.render(entity, f, f1, f2, f3, f4, f5); - } + prepareForRender(entity); + super.render(entity, f, f1, f2, f3, f4, f5); + } - public void prepareForRender(Entity entity) { - EntityLivingBase living = (EntityLivingBase) entity; - isSneak = living != null ? living.isSneaking() : false; - if(living != null && living instanceof EntityPlayer) { - EntityPlayer player = (EntityPlayer) living; + public void prepareForRender(Entity entity) { + EntityLivingBase living = (EntityLivingBase) entity; + isSneak = living != null ? living.isSneaking() : false; + if (living != null && living instanceof EntityPlayer) { + EntityPlayer player = (EntityPlayer) living; - ItemStack itemstack = player.inventory.getCurrentItem(); - heldItemRight = itemstack != null ? 1 : 0; + ItemStack itemstack = player.inventory.getCurrentItem(); + heldItemRight = itemstack != null ? 1 : 0; - aimedBow = false; - if (itemstack != null && player.getItemInUseCount() > 0) { - EnumAction enumaction = itemstack.getItemUseAction(); + aimedBow = false; + if (itemstack != null && player.getItemInUseCount() > 0) { + EnumAction enumaction = itemstack.getItemUseAction(); - if (enumaction == EnumAction.block) - heldItemRight = 3; - else if (enumaction == EnumAction.bow) - aimedBow = true; - } - } - } + if (enumaction == EnumAction.block) heldItemRight = 3; + else if (enumaction == EnumAction.bow) aimedBow = true; + } + } + } - public void setRotateAngle(ModelRenderer modelRenderer, float x, float y, float z) { - modelRenderer.rotateAngleX = x; - modelRenderer.rotateAngleY = y; - modelRenderer.rotateAngleZ = z; - } - -} \ No newline at end of file + public void setRotateAngle(ModelRenderer modelRenderer, float x, float y, float z) { + modelRenderer.rotateAngleX = x; + modelRenderer.rotateAngleY = y; + modelRenderer.rotateAngleZ = z; + } +} diff --git a/src/main/java/vazkii/botania/client/model/armor/ModelArmorTerrasteel.java b/src/main/java/vazkii/botania/client/model/armor/ModelArmorTerrasteel.java index 91104c4eeb..f6bc4efc83 100644 --- a/src/main/java/vazkii/botania/client/model/armor/ModelArmorTerrasteel.java +++ b/src/main/java/vazkii/botania/client/model/armor/ModelArmorTerrasteel.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [? (GMT)] */ package vazkii.botania.client.model.armor; @@ -20,269 +20,266 @@ public class ModelArmorTerrasteel extends ModelBiped { - public ModelRenderer helm; - public ModelRenderer body; - public ModelRenderer armr; - public ModelRenderer armL; - public ModelRenderer belt; - public ModelRenderer bootR; - public ModelRenderer bootL; - public ModelRenderer helm2; - public ModelRenderer helm3; - public ModelRenderer helm4; - public ModelRenderer helmLeaf1; - public ModelRenderer helmLeaf2; - public ModelRenderer helmLeaf3; - public ModelRenderer helmLeaf4; - public ModelRenderer helmLeaf5; - public ModelRenderer helmLeaf6; - public ModelRenderer helmbranch1; - public ModelRenderer helmbranch2; - public ModelRenderer helmbranch3; - public ModelRenderer helmbranch4; - public ModelRenderer body2; - public ModelRenderer armRpauldron; - public ModelRenderer armRbranch1; - public ModelRenderer armRbranch2; - public ModelRenderer armLpauldron; - public ModelRenderer armLbranch1; - public ModelRenderer armLbranch2; - public ModelRenderer legR; - public ModelRenderer legL; - public ModelRenderer bootR1; - public ModelRenderer bootRbranch; - public ModelRenderer bootL2; - public ModelRenderer bootLbranch; + public ModelRenderer helm; + public ModelRenderer body; + public ModelRenderer armr; + public ModelRenderer armL; + public ModelRenderer belt; + public ModelRenderer bootR; + public ModelRenderer bootL; + public ModelRenderer helm2; + public ModelRenderer helm3; + public ModelRenderer helm4; + public ModelRenderer helmLeaf1; + public ModelRenderer helmLeaf2; + public ModelRenderer helmLeaf3; + public ModelRenderer helmLeaf4; + public ModelRenderer helmLeaf5; + public ModelRenderer helmLeaf6; + public ModelRenderer helmbranch1; + public ModelRenderer helmbranch2; + public ModelRenderer helmbranch3; + public ModelRenderer helmbranch4; + public ModelRenderer body2; + public ModelRenderer armRpauldron; + public ModelRenderer armRbranch1; + public ModelRenderer armRbranch2; + public ModelRenderer armLpauldron; + public ModelRenderer armLbranch1; + public ModelRenderer armLbranch2; + public ModelRenderer legR; + public ModelRenderer legL; + public ModelRenderer bootR1; + public ModelRenderer bootRbranch; + public ModelRenderer bootL2; + public ModelRenderer bootLbranch; - int slot; + int slot; - public ModelArmorTerrasteel(int slot) { - this.slot = slot; + public ModelArmorTerrasteel(int slot) { + this.slot = slot; - textureWidth = 64; - textureHeight = 128; - float s = 0.2F; - armr = new ModelRenderer(this, 0, 77); - armr.setRotationPoint(-5.0F, 2.0F, -0.0F); - armr.addBox(-3.0F, 3.0F, -2.0F, 4, 7, 4, s); - setRotateAngle(armr, 0.0F, 0.0F, 0F); - body = new ModelRenderer(this, 0, 44); - body.setRotationPoint(0.0F, 0.0F, 0.0F); - body.addBox(-4.5F, 0.0F, -3.5F, 9, 6, 6, s); - setRotateAngle(body, 0F, 0.0F, 0.0F); - helm4 = new ModelRenderer(this, 56, 32); - helm4.setRotationPoint(0.0F, 0.0F, 0.0F); - helm4.addBox(-1.0F, -7.5F, -6.5F, 2, 6, 2, s); - setRotateAngle(helm4, 0F, 0.0F, 0.0F); - bootR1 = new ModelRenderer(this, 32, 77); - bootR1.setRotationPoint(0.0F, 0.0F, 0.0F); - bootR1.addBox(-2.0F, 6.0F, -2.0F, 4, 2, 4, s); - helmbranch4 = new ModelRenderer(this, 34, 43); - helmbranch4.mirror = true; - helmbranch4.setRotationPoint(0.0F, 0.0F, 0.0F); - helmbranch4.addBox(-2.0F, -8.0F, -4.0F, 1, 2, 7, s); - setRotateAngle(helmbranch4, 0.2617993877991494F, 0.0F, 1.0471975511965976F); - bootL = new ModelRenderer(this, 32, 83); - bootL.mirror = true; - bootL.setRotationPoint(1.9F, 12.0F, 0.0F); - bootL.addBox(-2.0F, 8.0F, -3.0F, 4, 4, 5, s); - setRotateAngle(bootL, 0.0F, 0.0F, 0F); - bootR = new ModelRenderer(this, 32, 83); - bootR.setRotationPoint(-1.9F, 12.0F, 0.1F); - bootR.addBox(-2.0F, 8.0F, -3.0F, 4, 4, 5, s); - setRotateAngle(bootR, 0.0F, 0.0F, 0F); - helmLeaf5 = new ModelRenderer(this, 50, 32); - helmLeaf5.mirror = true; - helmLeaf5.setRotationPoint(0.0F, 0.2F, 0.0F); - helmLeaf5.addBox(-1.0F, -11.0F, -4.5F, 2, 5, 1, s); - setRotateAngle(helmLeaf5, -0.5235987755982988F, -0.5235987755982988F, 0.5235987755982988F); - bootLbranch = new ModelRenderer(this, 48, 77); - bootLbranch.mirror = true; - bootLbranch.setRotationPoint(0.0F, 0.0F, 0.0F); - bootLbranch.addBox(8.0F, 1.0F, -2.0F, 1, 2, 5, s); - setRotateAngle(bootLbranch, 0.2617993877991494F, 0.0F, 1.0471975511965976F); - helmLeaf4 = new ModelRenderer(this, 50, 32); - helmLeaf4.mirror = true; - helmLeaf4.setRotationPoint(0.0F, 0.2F, 0.0F); - helmLeaf4.addBox(-1.5F, -9.0F, -6.0F, 2, 3, 1, s); - setRotateAngle(helmLeaf4, -0.2617993877991494F, -0.2617993877991494F, 0.5235987755982988F); - helmLeaf2 = new ModelRenderer(this, 50, 32); - helmLeaf2.setRotationPoint(0.0F, 0.2F, 0.0F); - helmLeaf2.addBox(-1.0F, -11.0F, -4.5F, 2, 5, 1, s); - setRotateAngle(helmLeaf2, -0.5235987755982988F, 0.5235987755982988F, -0.5235987755982988F); - helm = new ModelRenderer(this, 0, 32); - helm.setRotationPoint(0.0F, 0.0F, 0.0F); - helm.addBox(-4.0F, -8.0F, -4.5F, 8, 3, 9, s); - setRotateAngle(helm, 0.08726646259971647F, 0.0F, 0.0F); - helm2 = new ModelRenderer(this, 34, 32); - helm2.setRotationPoint(0.0F, 0.0F, 0.0F); - helm2.addBox(-4.0F, -5.0F, -4.5F, 2, 5, 6, s); - helm3 = new ModelRenderer(this, 34, 32); - helm3.mirror = true; - helm3.setRotationPoint(0.0F, 0.0F, 0.0F); - helm3.addBox(2.0F, -5.0F, -4.5F, 2, 5, 6, s); - helmbranch1 = new ModelRenderer(this, 34, 43); - helmbranch1.mirror = true; - helmbranch1.setRotationPoint(0.0F, 0.0F, 0F); - helmbranch1.addBox(-2.0F, -10.0F, -1.0F, 1, 2, 7, s); - setRotateAngle(helmbranch1, 0.5235987755982988F, 0.0F, -0.08726646259971647F); - bootL2 = new ModelRenderer(this, 32, 77); - bootL2.mirror = true; - bootL2.setRotationPoint(0.0F, 0.0F, 0.0F); - bootL2.addBox(-2.0F, 6.0F, -2.0F, 4, 2, 4, s); - helmbranch2 = new ModelRenderer(this, 34, 43); - helmbranch2.setRotationPoint(0.0F, 0.0F, 0.0F); - helmbranch2.addBox(1.0F, -10.0F, -1.0F, 1, 2, 7, s); - setRotateAngle(helmbranch2, 0.5235987755982988F, 0.0F, 0.08726646259971647F); - legR = new ModelRenderer(this, 16, 77); - legR.setRotationPoint(-1.9F, 12.0F, 0.0F); - legR.addBox(-2.0F, 0.0F, -2.0F, 4, 6, 4, s); - setRotateAngle(legR, 0.0F, 0.0F, 0F); - helmLeaf6 = new ModelRenderer(this, 50, 32); - helmLeaf6.mirror = true; - helmLeaf6.setRotationPoint(0.0F, 0.2F, 0.0F); - helmLeaf6.addBox(-0.5F, -13.0F, -3.0F, 2, 7, 1, s); - setRotateAngle(helmLeaf6, -0.7853981633974483F, -0.7853981633974483F, 0.7853981633974483F); - armLbranch1 = new ModelRenderer(this, 51, 44); - armLbranch1.mirror = true; - armLbranch1.setRotationPoint(0.0F, 0.0F, -0.0F); - armLbranch1.addBox(2.5F, -5.0F, -1.0F, 1, 5, 2, s); - setRotateAngle(armLbranch1, 0.0F, 0.0F, 0.7853981633974483F); - bootRbranch = new ModelRenderer(this, 48, 77); - bootRbranch.setRotationPoint(0.0F, 0.0F, 0.0F); - bootRbranch.addBox(-9.0F, 1.0F, -2.0F, 1, 2, 5, s); - setRotateAngle(bootRbranch, 0.2617993877991494F, 0.0F, -1.0471975511965976F); - armRbranch2 = new ModelRenderer(this, 50, 43); - armRbranch2.setRotationPoint(0.0F, 0.0F, 0.0F); - armRbranch2.addBox(-1.5F, -5.0F, -1.5F, 1, 5, 3, s); - setRotateAngle(armRbranch2, 0.0F, 0.0F, -0.5235987755982988F); - helmLeaf3 = new ModelRenderer(this, 50, 32); - helmLeaf3.setRotationPoint(0.0F, 0.2F, 0.0F); - helmLeaf3.addBox(-1.5F, -13.0F, -3.0F, 2, 7, 1, s); - setRotateAngle(helmLeaf3, -0.7853981633974483F, 0.7853981633974483F, -0.7853981633974483F); - armRpauldron = new ModelRenderer(this, 0, 66); - armRpauldron.setRotationPoint(0.0F, 0.0F, 0.0F); - armRpauldron.addBox(-4.0F, -2.0F, -3.0F, 5, 5, 6, s); - armLbranch2 = new ModelRenderer(this, 50, 43); - armLbranch2.mirror = true; - armLbranch2.setRotationPoint(0.0F, 0.0F, -0.0F); - armLbranch2.addBox(0.5F, -5.0F, -1.5F, 1, 5, 3, s); - setRotateAngle(armLbranch2, 0.0F, 0.0F, 0.5235987755982988F); - armL = new ModelRenderer(this, 0, 77); - armL.mirror = true; - armL.setRotationPoint(5.0F, 2.0F, -0.0F); - armL.addBox(-1.0F, 3.0F, -2.0F, 4, 7, 4, s); - setRotateAngle(armL, 0.0F, 0.0F, 0F); - body2 = new ModelRenderer(this, 0, 57); - body2.setRotationPoint(0.0F, 0.0F, 0.0F); - body2.addBox(-4.0F, 6.0F, -2.5F, 8, 4, 5, s); - setRotateAngle(body2, -0.08726646259971647F, 0.0F, 0.0F); - helmbranch3 = new ModelRenderer(this, 34, 43); - helmbranch3.setRotationPoint(0.0F, 0.0F, 0.0F); - helmbranch3.addBox(1.0F, -8.0F, -4.0F, 1, 2, 7, s); - setRotateAngle(helmbranch3, 0.2617993877991494F, 0.0F, -1.0471975511965976F); - armRbranch1 = new ModelRenderer(this, 51, 44); - armRbranch1.setRotationPoint(0.0F, 0.0F, 0.0F); - armRbranch1.addBox(-3.5F, -5.0F, -1.0F, 1, 5, 2, s); - setRotateAngle(armRbranch1, 0.0F, 0.0F, -0.7853981633974483F); - belt = new ModelRenderer(this, 22, 66); - belt.setRotationPoint(0.0F, 0.0F, 0.0F); - belt.addBox(-4.5F, 9.5F, -3.0F, 9, 3, 6, s); - helmLeaf1 = new ModelRenderer(this, 50, 32); - helmLeaf1.setRotationPoint(0.0F, 0.2F, 0.0F); - helmLeaf1.addBox(-0.5F, -9.0F, -6.0F, 2, 3, 1, s); - setRotateAngle(helmLeaf1, -0.2617993877991494F, 0.2617993877991494F, -0.5235987755982988F); - armLpauldron = new ModelRenderer(this, 0, 66); - armLpauldron.mirror = true; - armLpauldron.setRotationPoint(0.0F, 0.0F, -0.0F); - armLpauldron.addBox(-1.0F, -2.0F, -3.0F, 5, 5, 6, s); - legL = new ModelRenderer(this, 16, 77); - legL.mirror = true; - legL.setRotationPoint(1.9F, 12.0F, 0.0F); - legL.addBox(-2.0F, 0.0F, -2.0F, 4, 6, 4, s); - setRotateAngle(legL, 0.0F, 0.0F, 0F); + textureWidth = 64; + textureHeight = 128; + float s = 0.2F; + armr = new ModelRenderer(this, 0, 77); + armr.setRotationPoint(-5.0F, 2.0F, -0.0F); + armr.addBox(-3.0F, 3.0F, -2.0F, 4, 7, 4, s); + setRotateAngle(armr, 0.0F, 0.0F, 0F); + body = new ModelRenderer(this, 0, 44); + body.setRotationPoint(0.0F, 0.0F, 0.0F); + body.addBox(-4.5F, 0.0F, -3.5F, 9, 6, 6, s); + setRotateAngle(body, 0F, 0.0F, 0.0F); + helm4 = new ModelRenderer(this, 56, 32); + helm4.setRotationPoint(0.0F, 0.0F, 0.0F); + helm4.addBox(-1.0F, -7.5F, -6.5F, 2, 6, 2, s); + setRotateAngle(helm4, 0F, 0.0F, 0.0F); + bootR1 = new ModelRenderer(this, 32, 77); + bootR1.setRotationPoint(0.0F, 0.0F, 0.0F); + bootR1.addBox(-2.0F, 6.0F, -2.0F, 4, 2, 4, s); + helmbranch4 = new ModelRenderer(this, 34, 43); + helmbranch4.mirror = true; + helmbranch4.setRotationPoint(0.0F, 0.0F, 0.0F); + helmbranch4.addBox(-2.0F, -8.0F, -4.0F, 1, 2, 7, s); + setRotateAngle(helmbranch4, 0.2617993877991494F, 0.0F, 1.0471975511965976F); + bootL = new ModelRenderer(this, 32, 83); + bootL.mirror = true; + bootL.setRotationPoint(1.9F, 12.0F, 0.0F); + bootL.addBox(-2.0F, 8.0F, -3.0F, 4, 4, 5, s); + setRotateAngle(bootL, 0.0F, 0.0F, 0F); + bootR = new ModelRenderer(this, 32, 83); + bootR.setRotationPoint(-1.9F, 12.0F, 0.1F); + bootR.addBox(-2.0F, 8.0F, -3.0F, 4, 4, 5, s); + setRotateAngle(bootR, 0.0F, 0.0F, 0F); + helmLeaf5 = new ModelRenderer(this, 50, 32); + helmLeaf5.mirror = true; + helmLeaf5.setRotationPoint(0.0F, 0.2F, 0.0F); + helmLeaf5.addBox(-1.0F, -11.0F, -4.5F, 2, 5, 1, s); + setRotateAngle(helmLeaf5, -0.5235987755982988F, -0.5235987755982988F, 0.5235987755982988F); + bootLbranch = new ModelRenderer(this, 48, 77); + bootLbranch.mirror = true; + bootLbranch.setRotationPoint(0.0F, 0.0F, 0.0F); + bootLbranch.addBox(8.0F, 1.0F, -2.0F, 1, 2, 5, s); + setRotateAngle(bootLbranch, 0.2617993877991494F, 0.0F, 1.0471975511965976F); + helmLeaf4 = new ModelRenderer(this, 50, 32); + helmLeaf4.mirror = true; + helmLeaf4.setRotationPoint(0.0F, 0.2F, 0.0F); + helmLeaf4.addBox(-1.5F, -9.0F, -6.0F, 2, 3, 1, s); + setRotateAngle(helmLeaf4, -0.2617993877991494F, -0.2617993877991494F, 0.5235987755982988F); + helmLeaf2 = new ModelRenderer(this, 50, 32); + helmLeaf2.setRotationPoint(0.0F, 0.2F, 0.0F); + helmLeaf2.addBox(-1.0F, -11.0F, -4.5F, 2, 5, 1, s); + setRotateAngle(helmLeaf2, -0.5235987755982988F, 0.5235987755982988F, -0.5235987755982988F); + helm = new ModelRenderer(this, 0, 32); + helm.setRotationPoint(0.0F, 0.0F, 0.0F); + helm.addBox(-4.0F, -8.0F, -4.5F, 8, 3, 9, s); + setRotateAngle(helm, 0.08726646259971647F, 0.0F, 0.0F); + helm2 = new ModelRenderer(this, 34, 32); + helm2.setRotationPoint(0.0F, 0.0F, 0.0F); + helm2.addBox(-4.0F, -5.0F, -4.5F, 2, 5, 6, s); + helm3 = new ModelRenderer(this, 34, 32); + helm3.mirror = true; + helm3.setRotationPoint(0.0F, 0.0F, 0.0F); + helm3.addBox(2.0F, -5.0F, -4.5F, 2, 5, 6, s); + helmbranch1 = new ModelRenderer(this, 34, 43); + helmbranch1.mirror = true; + helmbranch1.setRotationPoint(0.0F, 0.0F, 0F); + helmbranch1.addBox(-2.0F, -10.0F, -1.0F, 1, 2, 7, s); + setRotateAngle(helmbranch1, 0.5235987755982988F, 0.0F, -0.08726646259971647F); + bootL2 = new ModelRenderer(this, 32, 77); + bootL2.mirror = true; + bootL2.setRotationPoint(0.0F, 0.0F, 0.0F); + bootL2.addBox(-2.0F, 6.0F, -2.0F, 4, 2, 4, s); + helmbranch2 = new ModelRenderer(this, 34, 43); + helmbranch2.setRotationPoint(0.0F, 0.0F, 0.0F); + helmbranch2.addBox(1.0F, -10.0F, -1.0F, 1, 2, 7, s); + setRotateAngle(helmbranch2, 0.5235987755982988F, 0.0F, 0.08726646259971647F); + legR = new ModelRenderer(this, 16, 77); + legR.setRotationPoint(-1.9F, 12.0F, 0.0F); + legR.addBox(-2.0F, 0.0F, -2.0F, 4, 6, 4, s); + setRotateAngle(legR, 0.0F, 0.0F, 0F); + helmLeaf6 = new ModelRenderer(this, 50, 32); + helmLeaf6.mirror = true; + helmLeaf6.setRotationPoint(0.0F, 0.2F, 0.0F); + helmLeaf6.addBox(-0.5F, -13.0F, -3.0F, 2, 7, 1, s); + setRotateAngle(helmLeaf6, -0.7853981633974483F, -0.7853981633974483F, 0.7853981633974483F); + armLbranch1 = new ModelRenderer(this, 51, 44); + armLbranch1.mirror = true; + armLbranch1.setRotationPoint(0.0F, 0.0F, -0.0F); + armLbranch1.addBox(2.5F, -5.0F, -1.0F, 1, 5, 2, s); + setRotateAngle(armLbranch1, 0.0F, 0.0F, 0.7853981633974483F); + bootRbranch = new ModelRenderer(this, 48, 77); + bootRbranch.setRotationPoint(0.0F, 0.0F, 0.0F); + bootRbranch.addBox(-9.0F, 1.0F, -2.0F, 1, 2, 5, s); + setRotateAngle(bootRbranch, 0.2617993877991494F, 0.0F, -1.0471975511965976F); + armRbranch2 = new ModelRenderer(this, 50, 43); + armRbranch2.setRotationPoint(0.0F, 0.0F, 0.0F); + armRbranch2.addBox(-1.5F, -5.0F, -1.5F, 1, 5, 3, s); + setRotateAngle(armRbranch2, 0.0F, 0.0F, -0.5235987755982988F); + helmLeaf3 = new ModelRenderer(this, 50, 32); + helmLeaf3.setRotationPoint(0.0F, 0.2F, 0.0F); + helmLeaf3.addBox(-1.5F, -13.0F, -3.0F, 2, 7, 1, s); + setRotateAngle(helmLeaf3, -0.7853981633974483F, 0.7853981633974483F, -0.7853981633974483F); + armRpauldron = new ModelRenderer(this, 0, 66); + armRpauldron.setRotationPoint(0.0F, 0.0F, 0.0F); + armRpauldron.addBox(-4.0F, -2.0F, -3.0F, 5, 5, 6, s); + armLbranch2 = new ModelRenderer(this, 50, 43); + armLbranch2.mirror = true; + armLbranch2.setRotationPoint(0.0F, 0.0F, -0.0F); + armLbranch2.addBox(0.5F, -5.0F, -1.5F, 1, 5, 3, s); + setRotateAngle(armLbranch2, 0.0F, 0.0F, 0.5235987755982988F); + armL = new ModelRenderer(this, 0, 77); + armL.mirror = true; + armL.setRotationPoint(5.0F, 2.0F, -0.0F); + armL.addBox(-1.0F, 3.0F, -2.0F, 4, 7, 4, s); + setRotateAngle(armL, 0.0F, 0.0F, 0F); + body2 = new ModelRenderer(this, 0, 57); + body2.setRotationPoint(0.0F, 0.0F, 0.0F); + body2.addBox(-4.0F, 6.0F, -2.5F, 8, 4, 5, s); + setRotateAngle(body2, -0.08726646259971647F, 0.0F, 0.0F); + helmbranch3 = new ModelRenderer(this, 34, 43); + helmbranch3.setRotationPoint(0.0F, 0.0F, 0.0F); + helmbranch3.addBox(1.0F, -8.0F, -4.0F, 1, 2, 7, s); + setRotateAngle(helmbranch3, 0.2617993877991494F, 0.0F, -1.0471975511965976F); + armRbranch1 = new ModelRenderer(this, 51, 44); + armRbranch1.setRotationPoint(0.0F, 0.0F, 0.0F); + armRbranch1.addBox(-3.5F, -5.0F, -1.0F, 1, 5, 2, s); + setRotateAngle(armRbranch1, 0.0F, 0.0F, -0.7853981633974483F); + belt = new ModelRenderer(this, 22, 66); + belt.setRotationPoint(0.0F, 0.0F, 0.0F); + belt.addBox(-4.5F, 9.5F, -3.0F, 9, 3, 6, s); + helmLeaf1 = new ModelRenderer(this, 50, 32); + helmLeaf1.setRotationPoint(0.0F, 0.2F, 0.0F); + helmLeaf1.addBox(-0.5F, -9.0F, -6.0F, 2, 3, 1, s); + setRotateAngle(helmLeaf1, -0.2617993877991494F, 0.2617993877991494F, -0.5235987755982988F); + armLpauldron = new ModelRenderer(this, 0, 66); + armLpauldron.mirror = true; + armLpauldron.setRotationPoint(0.0F, 0.0F, -0.0F); + armLpauldron.addBox(-1.0F, -2.0F, -3.0F, 5, 5, 6, s); + legL = new ModelRenderer(this, 16, 77); + legL.mirror = true; + legL.setRotationPoint(1.9F, 12.0F, 0.0F); + legL.addBox(-2.0F, 0.0F, -2.0F, 4, 6, 4, s); + setRotateAngle(legL, 0.0F, 0.0F, 0F); - helm.addChild(helm4); - bootR.addChild(bootR1); - helm.addChild(helmbranch4); - helm.addChild(helmLeaf5); - bootL.addChild(bootLbranch); - helm.addChild(helmLeaf4); - helm.addChild(helmLeaf2); - helm.addChild(helm2); - helm.addChild(helm3); - helm.addChild(helmbranch1); - bootL.addChild(bootL2); - helm.addChild(helmbranch2); - belt.addChild(legR); - helm.addChild(helmLeaf6); - armLpauldron.addChild(armLbranch1); - bootR.addChild(bootRbranch); - armRpauldron.addChild(armRbranch2); - helm.addChild(helmLeaf3); - armr.addChild(armRpauldron); - armLpauldron.addChild(armLbranch2); - body.addChild(body2); - helm.addChild(helmbranch3); - armRpauldron.addChild(armRbranch1); - helm.addChild(helmLeaf1); - armL.addChild(armLpauldron); - belt.addChild(legL); - } + helm.addChild(helm4); + bootR.addChild(bootR1); + helm.addChild(helmbranch4); + helm.addChild(helmLeaf5); + bootL.addChild(bootLbranch); + helm.addChild(helmLeaf4); + helm.addChild(helmLeaf2); + helm.addChild(helm2); + helm.addChild(helm3); + helm.addChild(helmbranch1); + bootL.addChild(bootL2); + helm.addChild(helmbranch2); + belt.addChild(legR); + helm.addChild(helmLeaf6); + armLpauldron.addChild(armLbranch1); + bootR.addChild(bootRbranch); + armRpauldron.addChild(armRbranch2); + helm.addChild(helmLeaf3); + armr.addChild(armRpauldron); + armLpauldron.addChild(armLbranch2); + body.addChild(body2); + helm.addChild(helmbranch3); + armRpauldron.addChild(armRbranch1); + helm.addChild(helmLeaf1); + armL.addChild(armLpauldron); + belt.addChild(legL); + } - @Override - public void render(Entity entity, float f, float f1, float f2, float f3, float f4, float f5) { - helm.showModel = slot == 0; - body.showModel = slot == 1; - armr.showModel = slot == 1; - armL.showModel = slot == 1; - legR.showModel = slot == 2; - legL.showModel = slot == 2; - bootL.showModel = slot == 3; - bootR.showModel = slot == 3; - bipedHeadwear.showModel = false; + @Override + public void render(Entity entity, float f, float f1, float f2, float f3, float f4, float f5) { + helm.showModel = slot == 0; + body.showModel = slot == 1; + armr.showModel = slot == 1; + armL.showModel = slot == 1; + legR.showModel = slot == 2; + legL.showModel = slot == 2; + bootL.showModel = slot == 3; + bootR.showModel = slot == 3; + bipedHeadwear.showModel = false; - bipedHead = helm; - bipedBody = body; - bipedRightArm = armr; - bipedLeftArm = armL; - if(slot == 2) { - bipedRightLeg = legR; - bipedLeftLeg = legL; - } else { - bipedRightLeg = bootR; - bipedLeftLeg = bootL; - } + bipedHead = helm; + bipedBody = body; + bipedRightArm = armr; + bipedLeftArm = armL; + if (slot == 2) { + bipedRightLeg = legR; + bipedLeftLeg = legL; + } else { + bipedRightLeg = bootR; + bipedLeftLeg = bootL; + } - prepareForRender(entity); - super.render(entity, f, f1, f2, f3, f4, f5); - } + prepareForRender(entity); + super.render(entity, f, f1, f2, f3, f4, f5); + } - public void prepareForRender(Entity entity) { - EntityLivingBase living = (EntityLivingBase) entity; - isSneak = living != null ? living.isSneaking() : false; - if(living != null && living instanceof EntityPlayer) { - EntityPlayer player = (EntityPlayer) living; + public void prepareForRender(Entity entity) { + EntityLivingBase living = (EntityLivingBase) entity; + isSneak = living != null ? living.isSneaking() : false; + if (living != null && living instanceof EntityPlayer) { + EntityPlayer player = (EntityPlayer) living; - ItemStack itemstack = player.inventory.getCurrentItem(); - heldItemRight = itemstack != null ? 1 : 0; + ItemStack itemstack = player.inventory.getCurrentItem(); + heldItemRight = itemstack != null ? 1 : 0; - aimedBow = false; - if (itemstack != null && player.getItemInUseCount() > 0) { - EnumAction enumaction = itemstack.getItemUseAction(); + aimedBow = false; + if (itemstack != null && player.getItemInUseCount() > 0) { + EnumAction enumaction = itemstack.getItemUseAction(); - if (enumaction == EnumAction.block) - heldItemRight = 3; - else if (enumaction == EnumAction.bow) - aimedBow = true; - } - } - } - - public void setRotateAngle(ModelRenderer modelRenderer, float x, float y, float z) { - modelRenderer.rotateAngleX = x; - modelRenderer.rotateAngleY = y; - modelRenderer.rotateAngleZ = z; - } + if (enumaction == EnumAction.block) heldItemRight = 3; + else if (enumaction == EnumAction.bow) aimedBow = true; + } + } + } + public void setRotateAngle(ModelRenderer modelRenderer, float x, float y, float z) { + modelRenderer.rotateAngleX = x; + modelRenderer.rotateAngleY = y; + modelRenderer.rotateAngleZ = z; + } } diff --git a/src/main/java/vazkii/botania/client/render/block/InterpolatedIcon.java b/src/main/java/vazkii/botania/client/render/block/InterpolatedIcon.java index dbe47f01b4..2f4afee5d4 100644 --- a/src/main/java/vazkii/botania/client/render/block/InterpolatedIcon.java +++ b/src/main/java/vazkii/botania/client/render/block/InterpolatedIcon.java @@ -2,78 +2,76 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Aug 15, 2015, 5:11:16 PM (GMT)] */ package vazkii.botania.client.render.block; +import cpw.mods.fml.relauncher.ReflectionHelper; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; import java.lang.reflect.Field; - import net.minecraft.client.renderer.texture.TextureAtlasSprite; import net.minecraft.client.renderer.texture.TextureUtil; import net.minecraft.client.resources.data.AnimationMetadataSection; import vazkii.botania.common.lib.LibObfuscation; -import cpw.mods.fml.relauncher.ReflectionHelper; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; // This is all vanilla code from 1.8, thanks to ganymedes01 porting it to 1.7 :D @SideOnly(Side.CLIENT) public class InterpolatedIcon extends TextureAtlasSprite { - protected int[][] interpolatedFrameData; - private Field fanimationMetadata; + protected int[][] interpolatedFrameData; + private Field fanimationMetadata; - public InterpolatedIcon(String name) { - super(name); - fanimationMetadata = ReflectionHelper.findField(TextureAtlasSprite.class, LibObfuscation.ANIMATION_METADATA); - fanimationMetadata.setAccessible(true); - } + public InterpolatedIcon(String name) { + super(name); + fanimationMetadata = ReflectionHelper.findField(TextureAtlasSprite.class, LibObfuscation.ANIMATION_METADATA); + fanimationMetadata.setAccessible(true); + } - @Override - public void updateAnimation() { - super.updateAnimation(); - try { - updateAnimationInterpolated(); - } catch(Exception e) { - // NO-OP - } - } + @Override + public void updateAnimation() { + super.updateAnimation(); + try { + updateAnimationInterpolated(); + } catch (Exception e) { + // NO-OP + } + } - private void updateAnimationInterpolated() throws IllegalArgumentException, IllegalAccessException { - AnimationMetadataSection animationMetadata = (AnimationMetadataSection) fanimationMetadata.get(this); + private void updateAnimationInterpolated() throws IllegalArgumentException, IllegalAccessException { + AnimationMetadataSection animationMetadata = (AnimationMetadataSection) fanimationMetadata.get(this); - double d0 = 1.0D - tickCounter / (double) animationMetadata.getFrameTimeSingle(frameCounter); - int i = animationMetadata.getFrameIndex(frameCounter); - int j = animationMetadata.getFrameCount() == 0 ? framesTextureData.size() : animationMetadata.getFrameCount(); - int k = animationMetadata.getFrameIndex((frameCounter + 1) % j); + double d0 = 1.0D - tickCounter / (double) animationMetadata.getFrameTimeSingle(frameCounter); + int i = animationMetadata.getFrameIndex(frameCounter); + int j = animationMetadata.getFrameCount() == 0 ? framesTextureData.size() : animationMetadata.getFrameCount(); + int k = animationMetadata.getFrameIndex((frameCounter + 1) % j); - if(i != k && k >= 0 && k < framesTextureData.size()) { - int[][] aint = (int[][]) framesTextureData.get(i); - int[][] aint1 = (int[][]) framesTextureData.get(k); + if (i != k && k >= 0 && k < framesTextureData.size()) { + int[][] aint = (int[][]) framesTextureData.get(i); + int[][] aint1 = (int[][]) framesTextureData.get(k); - if(interpolatedFrameData == null || interpolatedFrameData.length != aint.length) - interpolatedFrameData = new int[aint.length][]; + if (interpolatedFrameData == null || interpolatedFrameData.length != aint.length) + interpolatedFrameData = new int[aint.length][]; - for(int l = 0; l < aint.length; l++) { - if (interpolatedFrameData[l] == null) - interpolatedFrameData[l] = new int[aint[l].length]; + for (int l = 0; l < aint.length; l++) { + if (interpolatedFrameData[l] == null) interpolatedFrameData[l] = new int[aint[l].length]; - if(l < aint1.length && aint1[l].length == aint[l].length) - for (int i1 = 0; i1 < aint[l].length; ++i1) { - int j1 = aint[l][i1]; - int k1 = aint1[l][i1]; - int l1 = (int) (((j1 & 16711680) >> 16) * d0 + ((k1 & 16711680) >> 16) * (1.0D - d0)); - int i2 = (int) (((j1 & 65280) >> 8) * d0 + ((k1 & 65280) >> 8) * (1.0D - d0)); - int j2 = (int) ((j1 & 255) * d0 + (k1 & 255) * (1.0D - d0)); - interpolatedFrameData[l][i1] = j1 & -16777216 | l1 << 16 | i2 << 8 | j2; - } - } + if (l < aint1.length && aint1[l].length == aint[l].length) + for (int i1 = 0; i1 < aint[l].length; ++i1) { + int j1 = aint[l][i1]; + int k1 = aint1[l][i1]; + int l1 = (int) (((j1 & 16711680) >> 16) * d0 + ((k1 & 16711680) >> 16) * (1.0D - d0)); + int i2 = (int) (((j1 & 65280) >> 8) * d0 + ((k1 & 65280) >> 8) * (1.0D - d0)); + int j2 = (int) ((j1 & 255) * d0 + (k1 & 255) * (1.0D - d0)); + interpolatedFrameData[l][i1] = j1 & -16777216 | l1 << 16 | i2 << 8 | j2; + } + } - TextureUtil.uploadTextureMipmap(interpolatedFrameData, width, height, originX, originY, false, false); - } - } -} \ No newline at end of file + TextureUtil.uploadTextureMipmap(interpolatedFrameData, width, height, originX, originY, false, false); + } + } +} diff --git a/src/main/java/vazkii/botania/client/render/block/RenderAltar.java b/src/main/java/vazkii/botania/client/render/block/RenderAltar.java index 2d1e6384e0..0812f0ba43 100644 --- a/src/main/java/vazkii/botania/client/render/block/RenderAltar.java +++ b/src/main/java/vazkii/botania/client/render/block/RenderAltar.java @@ -2,50 +2,49 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jan 21, 2014, 8:02:01 PM (GMT)] */ package vazkii.botania.client.render.block; +import cpw.mods.fml.client.registry.ISimpleBlockRenderingHandler; import net.minecraft.block.Block; import net.minecraft.client.renderer.RenderBlocks; import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher; import net.minecraft.world.IBlockAccess; - import org.lwjgl.opengl.GL11; - import vazkii.botania.client.lib.LibRenderIDs; import vazkii.botania.client.render.tile.RenderTileAltar; import vazkii.botania.common.block.tile.TileAltar; -import cpw.mods.fml.client.registry.ISimpleBlockRenderingHandler; public class RenderAltar implements ISimpleBlockRenderingHandler { - @Override - public void renderInventoryBlock(Block block, int metadata, int modelID, RenderBlocks renderer) { - GL11.glPushMatrix(); - GL11.glTranslatef(-0.5F, -0.6F, -0.5F); - GL11.glScalef(0.9F, 0.9F, 0.9F); - RenderTileAltar.forceMeta = metadata; - TileEntityRendererDispatcher.instance.renderTileEntityAt(new TileAltar(), 0.0D, 0.0D, 0.0D, 0.0F); - GL11.glPopMatrix(); - } - - @Override - public boolean renderWorldBlock(IBlockAccess world, int x, int y, int z, Block block, int modelId, RenderBlocks renderer) { - return false; - } - - @Override - public int getRenderId() { - return LibRenderIDs.idAltar; - } - - @Override - public boolean shouldRender3DInInventory(int modelId) { - return true; - } + @Override + public void renderInventoryBlock(Block block, int metadata, int modelID, RenderBlocks renderer) { + GL11.glPushMatrix(); + GL11.glTranslatef(-0.5F, -0.6F, -0.5F); + GL11.glScalef(0.9F, 0.9F, 0.9F); + RenderTileAltar.forceMeta = metadata; + TileEntityRendererDispatcher.instance.renderTileEntityAt(new TileAltar(), 0.0D, 0.0D, 0.0D, 0.0F); + GL11.glPopMatrix(); + } + + @Override + public boolean renderWorldBlock( + IBlockAccess world, int x, int y, int z, Block block, int modelId, RenderBlocks renderer) { + return false; + } + + @Override + public int getRenderId() { + return LibRenderIDs.idAltar; + } + + @Override + public boolean shouldRender3DInInventory(int modelId) { + return true; + } } diff --git a/src/main/java/vazkii/botania/client/render/block/RenderAvatar.java b/src/main/java/vazkii/botania/client/render/block/RenderAvatar.java index f850e12370..22ed39f9d0 100644 --- a/src/main/java/vazkii/botania/client/render/block/RenderAvatar.java +++ b/src/main/java/vazkii/botania/client/render/block/RenderAvatar.java @@ -2,48 +2,46 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Oct 24, 2015, 11:06:11 PM (GMT)] */ package vazkii.botania.client.render.block; +import cpw.mods.fml.client.registry.ISimpleBlockRenderingHandler; import net.minecraft.block.Block; import net.minecraft.client.renderer.RenderBlocks; import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher; import net.minecraft.world.IBlockAccess; - import org.lwjgl.opengl.GL11; - import vazkii.botania.client.lib.LibRenderIDs; import vazkii.botania.common.block.tile.TileAvatar; -import cpw.mods.fml.client.registry.ISimpleBlockRenderingHandler; public class RenderAvatar implements ISimpleBlockRenderingHandler { - @Override - public void renderInventoryBlock(Block block, int metadata, int modelID, RenderBlocks renderer) { - GL11.glPushMatrix(); - GL11.glTranslatef(-0.5F, -0.6F, -0.5F); - TileEntityRendererDispatcher.instance.renderTileEntityAt(new TileAvatar(), 0.0D, 0.0D, 0.0D, 0.0F); - GL11.glPopMatrix(); - } - - @Override - public boolean renderWorldBlock(IBlockAccess world, int x, int y, int z, Block block, int modelId, RenderBlocks renderer) { - return false; - } - - @Override - public int getRenderId() { - return LibRenderIDs.idAvatar; - } - - @Override - public boolean shouldRender3DInInventory(int modelId) { - return true; - } - + @Override + public void renderInventoryBlock(Block block, int metadata, int modelID, RenderBlocks renderer) { + GL11.glPushMatrix(); + GL11.glTranslatef(-0.5F, -0.6F, -0.5F); + TileEntityRendererDispatcher.instance.renderTileEntityAt(new TileAvatar(), 0.0D, 0.0D, 0.0D, 0.0F); + GL11.glPopMatrix(); + } + + @Override + public boolean renderWorldBlock( + IBlockAccess world, int x, int y, int z, Block block, int modelId, RenderBlocks renderer) { + return false; + } + + @Override + public int getRenderId() { + return LibRenderIDs.idAvatar; + } + + @Override + public boolean shouldRender3DInInventory(int modelId) { + return true; + } } diff --git a/src/main/java/vazkii/botania/client/render/block/RenderBellows.java b/src/main/java/vazkii/botania/client/render/block/RenderBellows.java index a1e287418c..acac3fbda2 100644 --- a/src/main/java/vazkii/botania/client/render/block/RenderBellows.java +++ b/src/main/java/vazkii/botania/client/render/block/RenderBellows.java @@ -2,49 +2,47 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Aug 28, 2015, 7:13:45 PM (GMT)] */ package vazkii.botania.client.render.block; +import cpw.mods.fml.client.registry.ISimpleBlockRenderingHandler; import net.minecraft.block.Block; import net.minecraft.client.renderer.RenderBlocks; import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher; import net.minecraft.world.IBlockAccess; - import org.lwjgl.opengl.GL11; - import vazkii.botania.client.lib.LibRenderIDs; import vazkii.botania.common.block.tile.mana.TileBellows; -import cpw.mods.fml.client.registry.ISimpleBlockRenderingHandler; public class RenderBellows implements ISimpleBlockRenderingHandler { - @Override - public void renderInventoryBlock(Block block, int metadata, int modelId, RenderBlocks renderer) { - GL11.glPushMatrix(); - GL11.glTranslatef(-0.5F, -0.3F, -0.5F); - GL11.glScalef(1.2F, 1.2F, 1.2F); - TileEntityRendererDispatcher.instance.renderTileEntityAt(new TileBellows(), 0.0D, 0.0D, 0.0D, 0.0F); - GL11.glPopMatrix(); - } - - @Override - public boolean renderWorldBlock(IBlockAccess world, int x, int y, int z, Block block, int modelId, RenderBlocks renderer) { - return false; - } - - @Override - public boolean shouldRender3DInInventory(int modelId) { - return true; - } - - @Override - public int getRenderId() { - return LibRenderIDs.idBellows; - } - + @Override + public void renderInventoryBlock(Block block, int metadata, int modelId, RenderBlocks renderer) { + GL11.glPushMatrix(); + GL11.glTranslatef(-0.5F, -0.3F, -0.5F); + GL11.glScalef(1.2F, 1.2F, 1.2F); + TileEntityRendererDispatcher.instance.renderTileEntityAt(new TileBellows(), 0.0D, 0.0D, 0.0D, 0.0F); + GL11.glPopMatrix(); + } + + @Override + public boolean renderWorldBlock( + IBlockAccess world, int x, int y, int z, Block block, int modelId, RenderBlocks renderer) { + return false; + } + + @Override + public boolean shouldRender3DInInventory(int modelId) { + return true; + } + + @Override + public int getRenderId() { + return LibRenderIDs.idBellows; + } } diff --git a/src/main/java/vazkii/botania/client/render/block/RenderBrewery.java b/src/main/java/vazkii/botania/client/render/block/RenderBrewery.java index aa2eefed38..5bda3cf6b6 100644 --- a/src/main/java/vazkii/botania/client/render/block/RenderBrewery.java +++ b/src/main/java/vazkii/botania/client/render/block/RenderBrewery.java @@ -2,52 +2,50 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Oct 31, 2014, 5:00:12 PM (GMT)] */ package vazkii.botania.client.render.block; +import cpw.mods.fml.client.registry.ISimpleBlockRenderingHandler; import net.minecraft.block.Block; import net.minecraft.client.renderer.RenderBlocks; import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher; import net.minecraft.world.IBlockAccess; - import org.lwjgl.opengl.GL11; - import vazkii.botania.client.lib.LibRenderIDs; import vazkii.botania.client.render.tile.RenderTileBrewery; import vazkii.botania.common.block.tile.TileBrewery; -import cpw.mods.fml.client.registry.ISimpleBlockRenderingHandler; public class RenderBrewery implements ISimpleBlockRenderingHandler { - @Override - public void renderInventoryBlock(Block block, int metadata, int modelId, RenderBlocks renderer) { - GL11.glPushMatrix(); - GL11.glTranslatef(-0.5F, -0.5F, -0.5F); - GL11.glScalef(1.2F, 1.2F, 1.2F); - RenderTileBrewery.rotate = false; - TileEntityRendererDispatcher.instance.renderTileEntityAt(new TileBrewery(), 0.0D, 0.0D, 0.0D, 0.0F); - RenderTileBrewery.rotate = true; - GL11.glPopMatrix(); - } - - @Override - public boolean renderWorldBlock(IBlockAccess world, int x, int y, int z, Block block, int modelId, RenderBlocks renderer) { - return false; - } - - @Override - public boolean shouldRender3DInInventory(int modelId) { - return true; - } - - @Override - public int getRenderId() { - return LibRenderIDs.idBrewery; - } - + @Override + public void renderInventoryBlock(Block block, int metadata, int modelId, RenderBlocks renderer) { + GL11.glPushMatrix(); + GL11.glTranslatef(-0.5F, -0.5F, -0.5F); + GL11.glScalef(1.2F, 1.2F, 1.2F); + RenderTileBrewery.rotate = false; + TileEntityRendererDispatcher.instance.renderTileEntityAt(new TileBrewery(), 0.0D, 0.0D, 0.0D, 0.0F); + RenderTileBrewery.rotate = true; + GL11.glPopMatrix(); + } + + @Override + public boolean renderWorldBlock( + IBlockAccess world, int x, int y, int z, Block block, int modelId, RenderBlocks renderer) { + return false; + } + + @Override + public boolean shouldRender3DInInventory(int modelId) { + return true; + } + + @Override + public int getRenderId() { + return LibRenderIDs.idBrewery; + } } diff --git a/src/main/java/vazkii/botania/client/render/block/RenderCocoon.java b/src/main/java/vazkii/botania/client/render/block/RenderCocoon.java index d74f04d174..ae3b9964bf 100644 --- a/src/main/java/vazkii/botania/client/render/block/RenderCocoon.java +++ b/src/main/java/vazkii/botania/client/render/block/RenderCocoon.java @@ -2,48 +2,46 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jul 8, 2015, 5:57:29 PM (GMT)] */ package vazkii.botania.client.render.block; +import cpw.mods.fml.client.registry.ISimpleBlockRenderingHandler; import net.minecraft.block.Block; import net.minecraft.client.renderer.RenderBlocks; import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher; import net.minecraft.world.IBlockAccess; - import org.lwjgl.opengl.GL11; - import vazkii.botania.client.lib.LibRenderIDs; import vazkii.botania.common.block.tile.TileCocoon; -import cpw.mods.fml.client.registry.ISimpleBlockRenderingHandler; public class RenderCocoon implements ISimpleBlockRenderingHandler { - @Override - public void renderInventoryBlock(Block block, int metadata, int modelID, RenderBlocks renderer) { - GL11.glPushMatrix(); - GL11.glTranslatef(-0.5F, -0.5F, -0.5F); - TileEntityRendererDispatcher.instance.renderTileEntityAt(new TileCocoon(), 0.0D, 0.0D, 0.0D, 0.0F); - GL11.glPopMatrix(); - } - - @Override - public boolean renderWorldBlock(IBlockAccess world, int x, int y, int z, Block block, int modelId, RenderBlocks renderer) { - return false; - } - - @Override - public int getRenderId() { - return LibRenderIDs.idCocoon; - } - - @Override - public boolean shouldRender3DInInventory(int modelId) { - return true; - } - + @Override + public void renderInventoryBlock(Block block, int metadata, int modelID, RenderBlocks renderer) { + GL11.glPushMatrix(); + GL11.glTranslatef(-0.5F, -0.5F, -0.5F); + TileEntityRendererDispatcher.instance.renderTileEntityAt(new TileCocoon(), 0.0D, 0.0D, 0.0D, 0.0F); + GL11.glPopMatrix(); + } + + @Override + public boolean renderWorldBlock( + IBlockAccess world, int x, int y, int z, Block block, int modelId, RenderBlocks renderer) { + return false; + } + + @Override + public int getRenderId() { + return LibRenderIDs.idCocoon; + } + + @Override + public boolean shouldRender3DInInventory(int modelId) { + return true; + } } diff --git a/src/main/java/vazkii/botania/client/render/block/RenderCorporeaCrystalCube.java b/src/main/java/vazkii/botania/client/render/block/RenderCorporeaCrystalCube.java index 1225ae73dc..27f69473c5 100644 --- a/src/main/java/vazkii/botania/client/render/block/RenderCorporeaCrystalCube.java +++ b/src/main/java/vazkii/botania/client/render/block/RenderCorporeaCrystalCube.java @@ -2,50 +2,48 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Apr 30, 2015, 6:22:32 PM (GMT)] */ package vazkii.botania.client.render.block; +import cpw.mods.fml.client.registry.ISimpleBlockRenderingHandler; import net.minecraft.block.Block; import net.minecraft.client.renderer.RenderBlocks; import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher; import net.minecraft.world.IBlockAccess; - import org.lwjgl.opengl.GL11; - import vazkii.botania.client.lib.LibRenderIDs; import vazkii.botania.common.block.tile.corporea.TileCorporeaCrystalCube; -import cpw.mods.fml.client.registry.ISimpleBlockRenderingHandler; public class RenderCorporeaCrystalCube implements ISimpleBlockRenderingHandler { - @Override - public void renderInventoryBlock(Block block, int metadata, int modelId, RenderBlocks renderer) { - GL11.glPushMatrix(); - GL11.glTranslatef(-0.5F, -0.5F, -0.5F); - GL11.glDisable(GL11.GL_ALPHA_TEST); - TileEntityRendererDispatcher.instance.renderTileEntityAt(new TileCorporeaCrystalCube(), 0.0D, 0.0D, 0.0D, 0.0F); - GL11.glEnable(GL11.GL_ALPHA_TEST); - GL11.glPopMatrix(); - } - - @Override - public boolean renderWorldBlock(IBlockAccess world, int x, int y, int z, Block block, int modelId, RenderBlocks renderer) { - return false; - } - - @Override - public boolean shouldRender3DInInventory(int modelId) { - return true; - } - - @Override - public int getRenderId() { - return LibRenderIDs.idCorporeaCrystalCybe; - } - + @Override + public void renderInventoryBlock(Block block, int metadata, int modelId, RenderBlocks renderer) { + GL11.glPushMatrix(); + GL11.glTranslatef(-0.5F, -0.5F, -0.5F); + GL11.glDisable(GL11.GL_ALPHA_TEST); + TileEntityRendererDispatcher.instance.renderTileEntityAt(new TileCorporeaCrystalCube(), 0.0D, 0.0D, 0.0D, 0.0F); + GL11.glEnable(GL11.GL_ALPHA_TEST); + GL11.glPopMatrix(); + } + + @Override + public boolean renderWorldBlock( + IBlockAccess world, int x, int y, int z, Block block, int modelId, RenderBlocks renderer) { + return false; + } + + @Override + public boolean shouldRender3DInInventory(int modelId) { + return true; + } + + @Override + public int getRenderId() { + return LibRenderIDs.idCorporeaCrystalCybe; + } } diff --git a/src/main/java/vazkii/botania/client/render/block/RenderCorporeaIndex.java b/src/main/java/vazkii/botania/client/render/block/RenderCorporeaIndex.java index 4eb43de551..c436ab96a7 100644 --- a/src/main/java/vazkii/botania/client/render/block/RenderCorporeaIndex.java +++ b/src/main/java/vazkii/botania/client/render/block/RenderCorporeaIndex.java @@ -2,52 +2,50 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Feb 15, 2015, 1:57:50 AM (GMT)] */ package vazkii.botania.client.render.block; +import cpw.mods.fml.client.registry.ISimpleBlockRenderingHandler; import net.minecraft.block.Block; import net.minecraft.client.renderer.RenderBlocks; import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher; import net.minecraft.world.IBlockAccess; - import org.lwjgl.opengl.GL11; - import vazkii.botania.client.lib.LibRenderIDs; import vazkii.botania.client.render.tile.RenderTileCorporeaIndex; import vazkii.botania.common.block.tile.corporea.TileCorporeaIndex; -import cpw.mods.fml.client.registry.ISimpleBlockRenderingHandler; public class RenderCorporeaIndex implements ISimpleBlockRenderingHandler { - @Override - public void renderInventoryBlock(Block block, int metadata, int modelId, RenderBlocks renderer) { - GL11.glPushMatrix(); - GL11.glTranslatef(-0.5F, -0.3F, -0.5F); - GL11.glScalef(1.4F, 1.4F, 1.4F); - RenderTileCorporeaIndex.move = false; - TileEntityRendererDispatcher.instance.renderTileEntityAt(new TileCorporeaIndex(), 0.0D, 0.0D, 0.0D, 0.0F); - RenderTileCorporeaIndex.move = true; - GL11.glPopMatrix(); - } - - @Override - public boolean renderWorldBlock(IBlockAccess world, int x, int y, int z, Block block, int modelId, RenderBlocks renderer) { - return false; - } - - @Override - public boolean shouldRender3DInInventory(int modelId) { - return true; - } - - @Override - public int getRenderId() { - return LibRenderIDs.idCorporeaIndex; - } - + @Override + public void renderInventoryBlock(Block block, int metadata, int modelId, RenderBlocks renderer) { + GL11.glPushMatrix(); + GL11.glTranslatef(-0.5F, -0.3F, -0.5F); + GL11.glScalef(1.4F, 1.4F, 1.4F); + RenderTileCorporeaIndex.move = false; + TileEntityRendererDispatcher.instance.renderTileEntityAt(new TileCorporeaIndex(), 0.0D, 0.0D, 0.0D, 0.0F); + RenderTileCorporeaIndex.move = true; + GL11.glPopMatrix(); + } + + @Override + public boolean renderWorldBlock( + IBlockAccess world, int x, int y, int z, Block block, int modelId, RenderBlocks renderer) { + return false; + } + + @Override + public boolean shouldRender3DInInventory(int modelId) { + return true; + } + + @Override + public int getRenderId() { + return LibRenderIDs.idCorporeaIndex; + } } diff --git a/src/main/java/vazkii/botania/client/render/block/RenderDoubleFlower.java b/src/main/java/vazkii/botania/client/render/block/RenderDoubleFlower.java index d9a9ab80b8..7901744d10 100644 --- a/src/main/java/vazkii/botania/client/render/block/RenderDoubleFlower.java +++ b/src/main/java/vazkii/botania/client/render/block/RenderDoubleFlower.java @@ -2,14 +2,15 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Mar 22, 2015, 9:00:06 PM (GMT)] */ package vazkii.botania.client.render.block; +import cpw.mods.fml.client.registry.ISimpleBlockRenderingHandler; import net.minecraft.block.Block; import net.minecraft.block.BlockDoublePlant; import net.minecraft.client.renderer.RenderBlocks; @@ -17,53 +18,65 @@ import net.minecraft.util.IIcon; import net.minecraft.world.IBlockAccess; import vazkii.botania.client.lib.LibRenderIDs; -import cpw.mods.fml.client.registry.ISimpleBlockRenderingHandler; public class RenderDoubleFlower implements ISimpleBlockRenderingHandler { - @Override - public void renderInventoryBlock(Block block, int metadata, int modelId, RenderBlocks renderer) { - // NO-OP - } - - @Override - public boolean renderWorldBlock(IBlockAccess world, int p_147774_2_, int p_147774_3_, int p_147774_4_, Block block, int modelId, RenderBlocks renderer) { - BlockDoublePlant p_147774_1_ = (BlockDoublePlant) block; - Tessellator tessellator = Tessellator.instance; - tessellator.setBrightness(p_147774_1_.getMixedBrightnessForBlock(world, p_147774_2_, p_147774_3_, p_147774_4_)); - tessellator.setColorOpaque_F(1F, 1F, 1F); - long j1 = p_147774_2_ * 3129871 ^ p_147774_4_ * 116129781L; - j1 = j1 * j1 * 42317861L + j1 * 11L; - int i1 = world.getBlockMetadata(p_147774_2_, p_147774_3_, p_147774_4_); - boolean flag1 = BlockDoublePlant.func_149887_c(i1); - if (flag1) - { - if (world.getBlock(p_147774_2_, p_147774_3_ - 1, p_147774_4_) != p_147774_1_) - { - return false; - } + @Override + public void renderInventoryBlock(Block block, int metadata, int modelId, RenderBlocks renderer) { + // NO-OP + } - BlockDoublePlant.func_149890_d(world.getBlockMetadata(p_147774_2_, p_147774_3_ - 1, p_147774_4_)); - } - else - { - BlockDoublePlant.func_149890_d(i1); - } + @Override + public boolean renderWorldBlock( + IBlockAccess world, + int p_147774_2_, + int p_147774_3_, + int p_147774_4_, + Block block, + int modelId, + RenderBlocks renderer) { + BlockDoublePlant p_147774_1_ = (BlockDoublePlant) block; + Tessellator tessellator = Tessellator.instance; + tessellator.setBrightness(p_147774_1_.getMixedBrightnessForBlock(world, p_147774_2_, p_147774_3_, p_147774_4_)); + tessellator.setColorOpaque_F(1F, 1F, 1F); + long j1 = p_147774_2_ * 3129871 ^ p_147774_4_ * 116129781L; + j1 = j1 * j1 * 42317861L + j1 * 11L; + int i1 = world.getBlockMetadata(p_147774_2_, p_147774_3_, p_147774_4_); + boolean flag1 = BlockDoublePlant.func_149887_c(i1); + if (flag1) { + if (world.getBlock(p_147774_2_, p_147774_3_ - 1, p_147774_4_) != p_147774_1_) { + return false; + } - // Only change here, to use xyz rather than side/meta - IIcon icon = renderer.getBlockIcon(block, world, p_147774_2_, p_147774_3_, p_147774_4_, 0); - RenderSpecialFlower.drawCrossedSquares(world, block, icon, p_147774_2_, p_147774_3_, p_147774_4_, p_147774_2_, p_147774_3_, p_147774_4_, 1F, renderer); - return true; - } + BlockDoublePlant.func_149890_d(world.getBlockMetadata(p_147774_2_, p_147774_3_ - 1, p_147774_4_)); + } else { + BlockDoublePlant.func_149890_d(i1); + } - @Override - public boolean shouldRender3DInInventory(int modelId) { - return false; - } + // Only change here, to use xyz rather than side/meta + IIcon icon = renderer.getBlockIcon(block, world, p_147774_2_, p_147774_3_, p_147774_4_, 0); + RenderSpecialFlower.drawCrossedSquares( + world, + block, + icon, + p_147774_2_, + p_147774_3_, + p_147774_4_, + p_147774_2_, + p_147774_3_, + p_147774_4_, + 1F, + renderer); + return true; + } - @Override - public int getRenderId() { - return LibRenderIDs.idDoubleFlower; - } + @Override + public boolean shouldRender3DInInventory(int modelId) { + return false; + } + @Override + public int getRenderId() { + return LibRenderIDs.idDoubleFlower; + } } diff --git a/src/main/java/vazkii/botania/client/render/block/RenderFloatingFlower.java b/src/main/java/vazkii/botania/client/render/block/RenderFloatingFlower.java index 4c569ce74a..3cc0c3409e 100644 --- a/src/main/java/vazkii/botania/client/render/block/RenderFloatingFlower.java +++ b/src/main/java/vazkii/botania/client/render/block/RenderFloatingFlower.java @@ -2,40 +2,40 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jul 8, 2014, 11:05:38 PM (GMT)] */ package vazkii.botania.client.render.block; +import cpw.mods.fml.client.registry.ISimpleBlockRenderingHandler; import net.minecraft.block.Block; import net.minecraft.client.renderer.RenderBlocks; import net.minecraft.world.IBlockAccess; import vazkii.botania.client.lib.LibRenderIDs; -import cpw.mods.fml.client.registry.ISimpleBlockRenderingHandler; public class RenderFloatingFlower implements ISimpleBlockRenderingHandler { - @Override - public void renderInventoryBlock(Block block, int metadata, int modelId, RenderBlocks renderer) { - // NO-OP, see RenderFloatingFlowerItem under ./item. - } - - @Override - public boolean renderWorldBlock(IBlockAccess world, int x, int y, int z, Block block, int modelId, RenderBlocks renderer) { - return false; - } + @Override + public void renderInventoryBlock(Block block, int metadata, int modelId, RenderBlocks renderer) { + // NO-OP, see RenderFloatingFlowerItem under ./item. + } - @Override - public boolean shouldRender3DInInventory(int modelId) { - return true; - } + @Override + public boolean renderWorldBlock( + IBlockAccess world, int x, int y, int z, Block block, int modelId, RenderBlocks renderer) { + return false; + } - @Override - public int getRenderId() { - return LibRenderIDs.idMiniIsland; - } + @Override + public boolean shouldRender3DInInventory(int modelId) { + return true; + } + @Override + public int getRenderId() { + return LibRenderIDs.idMiniIsland; + } } diff --git a/src/main/java/vazkii/botania/client/render/block/RenderHourglass.java b/src/main/java/vazkii/botania/client/render/block/RenderHourglass.java index 5bb3d923c8..620286f856 100644 --- a/src/main/java/vazkii/botania/client/render/block/RenderHourglass.java +++ b/src/main/java/vazkii/botania/client/render/block/RenderHourglass.java @@ -2,50 +2,48 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [May 30, 2015, 3:17:41 PM (GMT)] */ package vazkii.botania.client.render.block; +import cpw.mods.fml.client.registry.ISimpleBlockRenderingHandler; import net.minecraft.block.Block; import net.minecraft.client.renderer.RenderBlocks; import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher; import net.minecraft.world.IBlockAccess; - import org.lwjgl.opengl.GL11; - import vazkii.botania.client.lib.LibRenderIDs; import vazkii.botania.common.block.tile.TileHourglass; -import cpw.mods.fml.client.registry.ISimpleBlockRenderingHandler; public class RenderHourglass implements ISimpleBlockRenderingHandler { - @Override - public void renderInventoryBlock(Block block, int metadata, int modelID, RenderBlocks renderer) { - GL11.glPushMatrix(); - GL11.glTranslatef(-0.5F, -0.5F, -0.5F); - GL11.glDisable(GL11.GL_ALPHA_TEST); - TileEntityRendererDispatcher.instance.renderTileEntityAt(new TileHourglass(), 0.0D, 0.0D, 0.0D, 0.0F); - GL11.glEnable(GL11.GL_ALPHA_TEST); - GL11.glPopMatrix(); - } - - @Override - public boolean renderWorldBlock(IBlockAccess world, int x, int y, int z, Block block, int modelId, RenderBlocks renderer) { - return false; - } - - @Override - public int getRenderId() { - return LibRenderIDs.idHourglass; - } - - @Override - public boolean shouldRender3DInInventory(int modelId) { - return true; - } - + @Override + public void renderInventoryBlock(Block block, int metadata, int modelID, RenderBlocks renderer) { + GL11.glPushMatrix(); + GL11.glTranslatef(-0.5F, -0.5F, -0.5F); + GL11.glDisable(GL11.GL_ALPHA_TEST); + TileEntityRendererDispatcher.instance.renderTileEntityAt(new TileHourglass(), 0.0D, 0.0D, 0.0D, 0.0F); + GL11.glEnable(GL11.GL_ALPHA_TEST); + GL11.glPopMatrix(); + } + + @Override + public boolean renderWorldBlock( + IBlockAccess world, int x, int y, int z, Block block, int modelId, RenderBlocks renderer) { + return false; + } + + @Override + public int getRenderId() { + return LibRenderIDs.idHourglass; + } + + @Override + public boolean shouldRender3DInInventory(int modelId) { + return true; + } } diff --git a/src/main/java/vazkii/botania/client/render/block/RenderIncensePlate.java b/src/main/java/vazkii/botania/client/render/block/RenderIncensePlate.java index d487e4fa22..cc1a5c9698 100644 --- a/src/main/java/vazkii/botania/client/render/block/RenderIncensePlate.java +++ b/src/main/java/vazkii/botania/client/render/block/RenderIncensePlate.java @@ -2,49 +2,47 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [May 15, 2015, 5:59:56 PM (GMT)] */ package vazkii.botania.client.render.block; +import cpw.mods.fml.client.registry.ISimpleBlockRenderingHandler; import net.minecraft.block.Block; import net.minecraft.client.renderer.RenderBlocks; import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher; import net.minecraft.world.IBlockAccess; - import org.lwjgl.opengl.GL11; - import vazkii.botania.client.lib.LibRenderIDs; import vazkii.botania.common.block.tile.TileIncensePlate; -import cpw.mods.fml.client.registry.ISimpleBlockRenderingHandler; - -public class RenderIncensePlate implements ISimpleBlockRenderingHandler{ - - @Override - public void renderInventoryBlock(Block block, int metadata, int modelID, RenderBlocks renderer) { - GL11.glPushMatrix(); - GL11.glTranslatef(-0.5F, -0.1F, -0.5F); - GL11.glScalef(1.4F, 1.4F, 1.4F); - TileEntityRendererDispatcher.instance.renderTileEntityAt(new TileIncensePlate(), 0.0D, 0.0D, 0.0D, 0.0F); - GL11.glPopMatrix(); - } - - @Override - public boolean renderWorldBlock(IBlockAccess world, int x, int y, int z, Block block, int modelId, RenderBlocks renderer) { - return false; - } - - @Override - public int getRenderId() { - return LibRenderIDs.idIncensePlate; - } - - @Override - public boolean shouldRender3DInInventory(int modelId) { - return true; - } +public class RenderIncensePlate implements ISimpleBlockRenderingHandler { + + @Override + public void renderInventoryBlock(Block block, int metadata, int modelID, RenderBlocks renderer) { + GL11.glPushMatrix(); + GL11.glTranslatef(-0.5F, -0.1F, -0.5F); + GL11.glScalef(1.4F, 1.4F, 1.4F); + TileEntityRendererDispatcher.instance.renderTileEntityAt(new TileIncensePlate(), 0.0D, 0.0D, 0.0D, 0.0F); + GL11.glPopMatrix(); + } + + @Override + public boolean renderWorldBlock( + IBlockAccess world, int x, int y, int z, Block block, int modelId, RenderBlocks renderer) { + return false; + } + + @Override + public int getRenderId() { + return LibRenderIDs.idIncensePlate; + } + + @Override + public boolean shouldRender3DInInventory(int modelId) { + return true; + } } diff --git a/src/main/java/vazkii/botania/client/render/block/RenderPool.java b/src/main/java/vazkii/botania/client/render/block/RenderPool.java index 29cc7cb519..c1b1c19a0f 100644 --- a/src/main/java/vazkii/botania/client/render/block/RenderPool.java +++ b/src/main/java/vazkii/botania/client/render/block/RenderPool.java @@ -2,51 +2,49 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jan 26, 2014, 12:25:06 AM (GMT)] */ package vazkii.botania.client.render.block; +import cpw.mods.fml.client.registry.ISimpleBlockRenderingHandler; import net.minecraft.block.Block; import net.minecraft.client.renderer.RenderBlocks; import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher; import net.minecraft.world.IBlockAccess; - import org.lwjgl.opengl.GL11; - import vazkii.botania.client.lib.LibRenderIDs; import vazkii.botania.client.render.tile.RenderTilePool; import vazkii.botania.common.block.tile.mana.TilePool; -import cpw.mods.fml.client.registry.ISimpleBlockRenderingHandler; public class RenderPool implements ISimpleBlockRenderingHandler { - @Override - public void renderInventoryBlock(Block block, int metadata, int modelID, RenderBlocks renderer) { - GL11.glPushMatrix(); - GL11.glTranslatef(-0.5F, -0.5F, -0.5F); - RenderTilePool.forceMeta = metadata; - RenderTilePool.forceMana = RenderTilePool.forceMana | metadata == 1; - TileEntityRendererDispatcher.instance.renderTileEntityAt(new TilePool(), 0.0D, 0.0D, 0.0D, 0.0F); - GL11.glPopMatrix(); - } - - @Override - public boolean renderWorldBlock(IBlockAccess world, int x, int y, int z, Block block, int modelId, RenderBlocks renderer) { - return false; - } - - @Override - public int getRenderId() { - return LibRenderIDs.idPool; - } - - @Override - public boolean shouldRender3DInInventory(int modelId) { - return true; - } - + @Override + public void renderInventoryBlock(Block block, int metadata, int modelID, RenderBlocks renderer) { + GL11.glPushMatrix(); + GL11.glTranslatef(-0.5F, -0.5F, -0.5F); + RenderTilePool.forceMeta = metadata; + RenderTilePool.forceMana = RenderTilePool.forceMana | metadata == 1; + TileEntityRendererDispatcher.instance.renderTileEntityAt(new TilePool(), 0.0D, 0.0D, 0.0D, 0.0F); + GL11.glPopMatrix(); + } + + @Override + public boolean renderWorldBlock( + IBlockAccess world, int x, int y, int z, Block block, int modelId, RenderBlocks renderer) { + return false; + } + + @Override + public int getRenderId() { + return LibRenderIDs.idPool; + } + + @Override + public boolean shouldRender3DInInventory(int modelId) { + return true; + } } diff --git a/src/main/java/vazkii/botania/client/render/block/RenderPump.java b/src/main/java/vazkii/botania/client/render/block/RenderPump.java index cbf99719f6..14124f8859 100644 --- a/src/main/java/vazkii/botania/client/render/block/RenderPump.java +++ b/src/main/java/vazkii/botania/client/render/block/RenderPump.java @@ -2,48 +2,46 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Mar 18, 2015, 4:42:08 PM (GMT)] */ package vazkii.botania.client.render.block; +import cpw.mods.fml.client.registry.ISimpleBlockRenderingHandler; import net.minecraft.block.Block; import net.minecraft.client.renderer.RenderBlocks; import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher; import net.minecraft.world.IBlockAccess; - import org.lwjgl.opengl.GL11; - import vazkii.botania.client.lib.LibRenderIDs; import vazkii.botania.common.block.tile.mana.TilePump; -import cpw.mods.fml.client.registry.ISimpleBlockRenderingHandler; public class RenderPump implements ISimpleBlockRenderingHandler { - @Override - public void renderInventoryBlock(Block block, int metadata, int modelId, RenderBlocks renderer) { - GL11.glPushMatrix(); - GL11.glTranslatef(-0.5F, -0.25F, -0.5F); - TileEntityRendererDispatcher.instance.renderTileEntityAt(new TilePump(), 0.0D, 0.0D, 0.0D, 0.0F); - GL11.glPopMatrix(); - } - - @Override - public boolean renderWorldBlock(IBlockAccess world, int x, int y, int z, Block block, int modelId, RenderBlocks renderer) { - return false; - } - - @Override - public boolean shouldRender3DInInventory(int modelId) { - return true; - } - - @Override - public int getRenderId() { - return LibRenderIDs.idPump; - } - + @Override + public void renderInventoryBlock(Block block, int metadata, int modelId, RenderBlocks renderer) { + GL11.glPushMatrix(); + GL11.glTranslatef(-0.5F, -0.25F, -0.5F); + TileEntityRendererDispatcher.instance.renderTileEntityAt(new TilePump(), 0.0D, 0.0D, 0.0D, 0.0F); + GL11.glPopMatrix(); + } + + @Override + public boolean renderWorldBlock( + IBlockAccess world, int x, int y, int z, Block block, int modelId, RenderBlocks renderer) { + return false; + } + + @Override + public boolean shouldRender3DInInventory(int modelId) { + return true; + } + + @Override + public int getRenderId() { + return LibRenderIDs.idPump; + } } diff --git a/src/main/java/vazkii/botania/client/render/block/RenderPylon.java b/src/main/java/vazkii/botania/client/render/block/RenderPylon.java index aad8cfd198..3571d73ed2 100644 --- a/src/main/java/vazkii/botania/client/render/block/RenderPylon.java +++ b/src/main/java/vazkii/botania/client/render/block/RenderPylon.java @@ -2,51 +2,49 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Feb 18, 2014, 10:20:06 PM (GMT)] */ package vazkii.botania.client.render.block; +import cpw.mods.fml.client.registry.ISimpleBlockRenderingHandler; import net.minecraft.block.Block; import net.minecraft.client.renderer.RenderBlocks; import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher; import net.minecraft.world.IBlockAccess; - import org.lwjgl.opengl.GL11; - import vazkii.botania.client.lib.LibRenderIDs; import vazkii.botania.client.render.tile.RenderTilePylon; import vazkii.botania.common.block.tile.TilePylon; -import cpw.mods.fml.client.registry.ISimpleBlockRenderingHandler; public class RenderPylon implements ISimpleBlockRenderingHandler { - @Override - public void renderInventoryBlock(Block block, int metadata, int modelID, RenderBlocks renderer) { - GL11.glPushMatrix(); - GL11.glTranslatef(-0.5F, -0.7F, -0.5F); - RenderTilePylon.green = metadata == 1; - RenderTilePylon.pink = metadata == 2; - TileEntityRendererDispatcher.instance.renderTileEntityAt(new TilePylon(), 0.0D, 0.0D, 0.0D, 0.0F); - GL11.glPopMatrix(); - } - - @Override - public boolean renderWorldBlock(IBlockAccess world, int x, int y, int z, Block block, int modelId, RenderBlocks renderer) { - return false; - } - - @Override - public int getRenderId() { - return LibRenderIDs.idPylon; - } - - @Override - public boolean shouldRender3DInInventory(int modelId) { - return true; - } - + @Override + public void renderInventoryBlock(Block block, int metadata, int modelID, RenderBlocks renderer) { + GL11.glPushMatrix(); + GL11.glTranslatef(-0.5F, -0.7F, -0.5F); + RenderTilePylon.green = metadata == 1; + RenderTilePylon.pink = metadata == 2; + TileEntityRendererDispatcher.instance.renderTileEntityAt(new TilePylon(), 0.0D, 0.0D, 0.0D, 0.0F); + GL11.glPopMatrix(); + } + + @Override + public boolean renderWorldBlock( + IBlockAccess world, int x, int y, int z, Block block, int modelId, RenderBlocks renderer) { + return false; + } + + @Override + public int getRenderId() { + return LibRenderIDs.idPylon; + } + + @Override + public boolean shouldRender3DInInventory(int modelId) { + return true; + } } diff --git a/src/main/java/vazkii/botania/client/render/block/RenderSpawnerClaw.java b/src/main/java/vazkii/botania/client/render/block/RenderSpawnerClaw.java index 6c1e455132..ca6a864d83 100644 --- a/src/main/java/vazkii/botania/client/render/block/RenderSpawnerClaw.java +++ b/src/main/java/vazkii/botania/client/render/block/RenderSpawnerClaw.java @@ -2,48 +2,46 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jul 23, 2014, 6:23:54 PM (GMT)] */ package vazkii.botania.client.render.block; +import cpw.mods.fml.client.registry.ISimpleBlockRenderingHandler; import net.minecraft.block.Block; import net.minecraft.client.renderer.RenderBlocks; import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher; import net.minecraft.world.IBlockAccess; - import org.lwjgl.opengl.GL11; - import vazkii.botania.client.lib.LibRenderIDs; import vazkii.botania.common.block.tile.TileSpawnerClaw; -import cpw.mods.fml.client.registry.ISimpleBlockRenderingHandler; public class RenderSpawnerClaw implements ISimpleBlockRenderingHandler { - @Override - public void renderInventoryBlock(Block block, int metadata, int modelId, RenderBlocks renderer) { - GL11.glPushMatrix(); - GL11.glTranslatef(-0.5F, 0F, -0.5F); - TileEntityRendererDispatcher.instance.renderTileEntityAt(new TileSpawnerClaw(), 0.0D, 0.0D, 0.0D, 0.0F); - GL11.glPopMatrix(); - } - - @Override - public boolean renderWorldBlock(IBlockAccess world, int x, int y, int z, Block block, int modelId, RenderBlocks renderer) { - return false; - } - - @Override - public boolean shouldRender3DInInventory(int modelId) { - return true; - } - - @Override - public int getRenderId() { - return LibRenderIDs.idSpawnerClaw; - } - + @Override + public void renderInventoryBlock(Block block, int metadata, int modelId, RenderBlocks renderer) { + GL11.glPushMatrix(); + GL11.glTranslatef(-0.5F, 0F, -0.5F); + TileEntityRendererDispatcher.instance.renderTileEntityAt(new TileSpawnerClaw(), 0.0D, 0.0D, 0.0D, 0.0F); + GL11.glPopMatrix(); + } + + @Override + public boolean renderWorldBlock( + IBlockAccess world, int x, int y, int z, Block block, int modelId, RenderBlocks renderer) { + return false; + } + + @Override + public boolean shouldRender3DInInventory(int modelId) { + return true; + } + + @Override + public int getRenderId() { + return LibRenderIDs.idSpawnerClaw; + } } diff --git a/src/main/java/vazkii/botania/client/render/block/RenderSpecialFlower.java b/src/main/java/vazkii/botania/client/render/block/RenderSpecialFlower.java index 6de45bc66c..42076c5085 100644 --- a/src/main/java/vazkii/botania/client/render/block/RenderSpecialFlower.java +++ b/src/main/java/vazkii/botania/client/render/block/RenderSpecialFlower.java @@ -2,14 +2,15 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jan 25, 2014, 4:15:46 PM (GMT)] */ package vazkii.botania.client.render.block; +import cpw.mods.fml.client.registry.ISimpleBlockRenderingHandler; import net.minecraft.block.Block; import net.minecraft.client.renderer.EntityRenderer; import net.minecraft.client.renderer.RenderBlocks; @@ -19,117 +20,134 @@ import vazkii.botania.api.lexicon.multiblock.IMultiblockRenderHook; import vazkii.botania.api.lexicon.multiblock.Multiblock; import vazkii.botania.api.lexicon.multiblock.component.MultiblockComponent; -import cpw.mods.fml.client.registry.ISimpleBlockRenderingHandler; public class RenderSpecialFlower implements ISimpleBlockRenderingHandler, IMultiblockRenderHook { - int id; - - public RenderSpecialFlower(int id) { - this.id = id; - } - - @Override - public void renderInventoryBlock(Block block, int metadata, int modelID, RenderBlocks renderer) { - // NO-OP - } - - @Override - public boolean renderWorldBlock(IBlockAccess blockAccess, int x, int y, int z, Block block, int modelId, RenderBlocks renderer) { - return renderCrossedSquares(blockAccess, block, x, y, z, renderer); - } - - // Copied from RenderBlocks - public static boolean renderCrossedSquares(IBlockAccess blockAccess, Block par1Block, int par2, int par3, int par4, RenderBlocks render) { - Tessellator tessellator = Tessellator.instance; - tessellator.setBrightness(par1Block.getMixedBrightnessForBlock(blockAccess, par2, par3, par4)); - float f = 1.0F; - int l = par1Block.colorMultiplier(blockAccess, par2, par3, par4); - float f1 = (l >> 16 & 255) / 255.0F; - float f2 = (l >> 8 & 255) / 255.0F; - float f3 = (l & 255) / 255.0F; - - if(EntityRenderer.anaglyphEnable) { - float f4 = (f1 * 30.0F + f2 * 59.0F + f3 * 11.0F) / 100.0F; - float f5 = (f1 * 30.0F + f2 * 70.0F) / 100.0F; - float f6 = (f1 * 30.0F + f3 * 70.0F) / 100.0F; - f1 = f4; - f2 = f5; - f3 = f6; - } - - tessellator.setColorOpaque_F(f * f1, f * f2, f * f3); - double d1 = par2; - double d2 = par3; - double d0 = par4; - long sh; - - sh = par2 * 3129871 ^ par4 * 116129781L ^ par3; - sh = sh * sh * 42317861L + sh * 11L; - d1 += ((sh >> 16 & 15L) / 15.0F - 0.5D) * 0.3D; - d2 += (sh >> 32 & 15L) / 15.0F * -0.15D; - d0 += ((sh >> 24 & 15L) / 15.0F - 0.5D) * 0.3D; - - - // Only change here, to use xyz rather than side/meta - IIcon icon = render.getBlockIcon(par1Block, blockAccess, par2, par3, par4, 0); - drawCrossedSquares(blockAccess, par1Block, icon, par2, par3, par4, d1, d2, d0, 1.0F, render); - - return true; - } - - // Copied from RenderBlocks - public static void drawCrossedSquares(IBlockAccess blockAccess, Block par1Block, IIcon icon, int x, int y, int z, double par3, double par5, double par7, float par9, RenderBlocks render) { - Tessellator tessellator = Tessellator.instance; - - double d3 = icon.getMinU(); - double d4 = icon.getMinV(); - double d5 = icon.getMaxU(); - double d6 = icon.getMaxV(); - double d7 = 0.45D * par9; - double d8 = par3 + 0.5D - d7; - double d9 = par3 + 0.5D + d7; - double d10 = par7 + 0.5D - d7; - double d11 = par7 + 0.5D + d7; - tessellator.addVertexWithUV(d8, par5 + par9, d10, d3, d4); - tessellator.addVertexWithUV(d8, par5 + 0.0D, d10, d3, d6); - tessellator.addVertexWithUV(d9, par5 + 0.0D, d11, d5, d6); - tessellator.addVertexWithUV(d9, par5 + par9, d11, d5, d4); - tessellator.addVertexWithUV(d9, par5 + par9, d11, d3, d4); - tessellator.addVertexWithUV(d9, par5 + 0.0D, d11, d3, d6); - tessellator.addVertexWithUV(d8, par5 + 0.0D, d10, d5, d6); - tessellator.addVertexWithUV(d8, par5 + par9, d10, d5, d4); - tessellator.addVertexWithUV(d8, par5 + par9, d11, d3, d4); - tessellator.addVertexWithUV(d8, par5 + 0.0D, d11, d3, d6); - tessellator.addVertexWithUV(d9, par5 + 0.0D, d10, d5, d6); - tessellator.addVertexWithUV(d9, par5 + par9, d10, d5, d4); - tessellator.addVertexWithUV(d9, par5 + par9, d10, d3, d4); - tessellator.addVertexWithUV(d9, par5 + 0.0D, d10, d3, d6); - tessellator.addVertexWithUV(d8, par5 + 0.0D, d11, d5, d6); - tessellator.addVertexWithUV(d8, par5 + par9, d11, d5, d4); - } - - @Override - public int getRenderId() { - return id; - } - - @Override - public boolean shouldRender3DInInventory(int modelId) { - return false; - } - - @Override - public void renderBlockForMultiblock(IBlockAccess world, Multiblock mb, Block block, int meta, RenderBlocks renderBlocks, MultiblockComponent comp, float alpha) { - Tessellator tess = Tessellator.instance; - tess.startDrawingQuads(); - drawCrossedSquares(world, block, block.getIcon(0, meta), 0, 0, 0, -0.5, -0.5, -0.5, 1F, renderBlocks); - tess.draw(); - } - - @Override - public boolean needsTranslate(Block block) { - return true; - } - + int id; + + public RenderSpecialFlower(int id) { + this.id = id; + } + + @Override + public void renderInventoryBlock(Block block, int metadata, int modelID, RenderBlocks renderer) { + // NO-OP + } + + @Override + public boolean renderWorldBlock( + IBlockAccess blockAccess, int x, int y, int z, Block block, int modelId, RenderBlocks renderer) { + return renderCrossedSquares(blockAccess, block, x, y, z, renderer); + } + + // Copied from RenderBlocks + public static boolean renderCrossedSquares( + IBlockAccess blockAccess, Block par1Block, int par2, int par3, int par4, RenderBlocks render) { + Tessellator tessellator = Tessellator.instance; + tessellator.setBrightness(par1Block.getMixedBrightnessForBlock(blockAccess, par2, par3, par4)); + float f = 1.0F; + int l = par1Block.colorMultiplier(blockAccess, par2, par3, par4); + float f1 = (l >> 16 & 255) / 255.0F; + float f2 = (l >> 8 & 255) / 255.0F; + float f3 = (l & 255) / 255.0F; + + if (EntityRenderer.anaglyphEnable) { + float f4 = (f1 * 30.0F + f2 * 59.0F + f3 * 11.0F) / 100.0F; + float f5 = (f1 * 30.0F + f2 * 70.0F) / 100.0F; + float f6 = (f1 * 30.0F + f3 * 70.0F) / 100.0F; + f1 = f4; + f2 = f5; + f3 = f6; + } + + tessellator.setColorOpaque_F(f * f1, f * f2, f * f3); + double d1 = par2; + double d2 = par3; + double d0 = par4; + long sh; + + sh = par2 * 3129871 ^ par4 * 116129781L ^ par3; + sh = sh * sh * 42317861L + sh * 11L; + d1 += ((sh >> 16 & 15L) / 15.0F - 0.5D) * 0.3D; + d2 += (sh >> 32 & 15L) / 15.0F * -0.15D; + d0 += ((sh >> 24 & 15L) / 15.0F - 0.5D) * 0.3D; + + // Only change here, to use xyz rather than side/meta + IIcon icon = render.getBlockIcon(par1Block, blockAccess, par2, par3, par4, 0); + drawCrossedSquares(blockAccess, par1Block, icon, par2, par3, par4, d1, d2, d0, 1.0F, render); + + return true; + } + + // Copied from RenderBlocks + public static void drawCrossedSquares( + IBlockAccess blockAccess, + Block par1Block, + IIcon icon, + int x, + int y, + int z, + double par3, + double par5, + double par7, + float par9, + RenderBlocks render) { + Tessellator tessellator = Tessellator.instance; + + double d3 = icon.getMinU(); + double d4 = icon.getMinV(); + double d5 = icon.getMaxU(); + double d6 = icon.getMaxV(); + double d7 = 0.45D * par9; + double d8 = par3 + 0.5D - d7; + double d9 = par3 + 0.5D + d7; + double d10 = par7 + 0.5D - d7; + double d11 = par7 + 0.5D + d7; + tessellator.addVertexWithUV(d8, par5 + par9, d10, d3, d4); + tessellator.addVertexWithUV(d8, par5 + 0.0D, d10, d3, d6); + tessellator.addVertexWithUV(d9, par5 + 0.0D, d11, d5, d6); + tessellator.addVertexWithUV(d9, par5 + par9, d11, d5, d4); + tessellator.addVertexWithUV(d9, par5 + par9, d11, d3, d4); + tessellator.addVertexWithUV(d9, par5 + 0.0D, d11, d3, d6); + tessellator.addVertexWithUV(d8, par5 + 0.0D, d10, d5, d6); + tessellator.addVertexWithUV(d8, par5 + par9, d10, d5, d4); + tessellator.addVertexWithUV(d8, par5 + par9, d11, d3, d4); + tessellator.addVertexWithUV(d8, par5 + 0.0D, d11, d3, d6); + tessellator.addVertexWithUV(d9, par5 + 0.0D, d10, d5, d6); + tessellator.addVertexWithUV(d9, par5 + par9, d10, d5, d4); + tessellator.addVertexWithUV(d9, par5 + par9, d10, d3, d4); + tessellator.addVertexWithUV(d9, par5 + 0.0D, d10, d3, d6); + tessellator.addVertexWithUV(d8, par5 + 0.0D, d11, d5, d6); + tessellator.addVertexWithUV(d8, par5 + par9, d11, d5, d4); + } + + @Override + public int getRenderId() { + return id; + } + + @Override + public boolean shouldRender3DInInventory(int modelId) { + return false; + } + + @Override + public void renderBlockForMultiblock( + IBlockAccess world, + Multiblock mb, + Block block, + int meta, + RenderBlocks renderBlocks, + MultiblockComponent comp, + float alpha) { + Tessellator tess = Tessellator.instance; + tess.startDrawingQuads(); + drawCrossedSquares(world, block, block.getIcon(0, meta), 0, 0, 0, -0.5, -0.5, -0.5, 1F, renderBlocks); + tess.draw(); + } + + @Override + public boolean needsTranslate(Block block) { + return true; + } } diff --git a/src/main/java/vazkii/botania/client/render/block/RenderSpreader.java b/src/main/java/vazkii/botania/client/render/block/RenderSpreader.java index 946dfdb6c4..f8cf3dbf13 100644 --- a/src/main/java/vazkii/botania/client/render/block/RenderSpreader.java +++ b/src/main/java/vazkii/botania/client/render/block/RenderSpreader.java @@ -2,54 +2,52 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jan 25, 2014, 9:45:58 PM (GMT)] */ package vazkii.botania.client.render.block; +import cpw.mods.fml.client.registry.ISimpleBlockRenderingHandler; import net.minecraft.block.Block; import net.minecraft.client.renderer.RenderBlocks; import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher; import net.minecraft.world.IBlockAccess; - import org.lwjgl.opengl.GL11; - import vazkii.botania.client.lib.LibRenderIDs; import vazkii.botania.common.block.tile.mana.TileSpreader; -import cpw.mods.fml.client.registry.ISimpleBlockRenderingHandler; public class RenderSpreader implements ISimpleBlockRenderingHandler { - @Override - public void renderInventoryBlock(Block block, int metadata, int modelID, RenderBlocks renderer) { - GL11.glPushMatrix(); - GL11.glTranslatef(-0.5F, -0.5F, -0.5F); - TileSpreader.staticRedstone = metadata == 1; - TileSpreader.staticDreamwood = metadata == 2 || metadata == 3; - TileSpreader.staticUltra = metadata == 3; - - TileSpreader spreader = new TileSpreader(); - spreader.rotationX = -180F; - TileEntityRendererDispatcher.instance.renderTileEntityAt(spreader, 0.0D, 0.0D, 0.0D, 0.0F); - GL11.glPopMatrix(); - } - - @Override - public boolean renderWorldBlock(IBlockAccess world, int x, int y, int z, Block block, int modelId, RenderBlocks renderer) { - return false; - } - - @Override - public int getRenderId() { - return LibRenderIDs.idSpreader; - } - - @Override - public boolean shouldRender3DInInventory(int modelId) { - return true; - } - + @Override + public void renderInventoryBlock(Block block, int metadata, int modelID, RenderBlocks renderer) { + GL11.glPushMatrix(); + GL11.glTranslatef(-0.5F, -0.5F, -0.5F); + TileSpreader.staticRedstone = metadata == 1; + TileSpreader.staticDreamwood = metadata == 2 || metadata == 3; + TileSpreader.staticUltra = metadata == 3; + + TileSpreader spreader = new TileSpreader(); + spreader.rotationX = -180F; + TileEntityRendererDispatcher.instance.renderTileEntityAt(spreader, 0.0D, 0.0D, 0.0D, 0.0F); + GL11.glPopMatrix(); + } + + @Override + public boolean renderWorldBlock( + IBlockAccess world, int x, int y, int z, Block block, int modelId, RenderBlocks renderer) { + return false; + } + + @Override + public int getRenderId() { + return LibRenderIDs.idSpreader; + } + + @Override + public boolean shouldRender3DInInventory(int modelId) { + return true; + } } diff --git a/src/main/java/vazkii/botania/client/render/block/RenderTeruTeruBozu.java b/src/main/java/vazkii/botania/client/render/block/RenderTeruTeruBozu.java index d12f99eaab..185bb43cd5 100644 --- a/src/main/java/vazkii/botania/client/render/block/RenderTeruTeruBozu.java +++ b/src/main/java/vazkii/botania/client/render/block/RenderTeruTeruBozu.java @@ -2,48 +2,46 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Oct 1, 2015, 9:40:27 PM (GMT)] */ package vazkii.botania.client.render.block; +import cpw.mods.fml.client.registry.ISimpleBlockRenderingHandler; import net.minecraft.block.Block; import net.minecraft.client.renderer.RenderBlocks; import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher; import net.minecraft.world.IBlockAccess; - import org.lwjgl.opengl.GL11; - import vazkii.botania.client.lib.LibRenderIDs; import vazkii.botania.common.block.tile.TileTeruTeruBozu; -import cpw.mods.fml.client.registry.ISimpleBlockRenderingHandler; public class RenderTeruTeruBozu implements ISimpleBlockRenderingHandler { - @Override - public void renderInventoryBlock(Block block, int metadata, int modelID, RenderBlocks renderer) { - GL11.glPushMatrix(); - GL11.glTranslatef(-0.5F, -0.3F, -0.5F); - TileEntityRendererDispatcher.instance.renderTileEntityAt(new TileTeruTeruBozu(), 0.0D, 0.0D, 0.0D, 0.0F); - GL11.glPopMatrix(); - } - - @Override - public boolean renderWorldBlock(IBlockAccess world, int x, int y, int z, Block block, int modelId, RenderBlocks renderer) { - return false; - } - - @Override - public int getRenderId() { - return LibRenderIDs.idTeruTeruBozu; - } - - @Override - public boolean shouldRender3DInInventory(int modelId) { - return true; - } - + @Override + public void renderInventoryBlock(Block block, int metadata, int modelID, RenderBlocks renderer) { + GL11.glPushMatrix(); + GL11.glTranslatef(-0.5F, -0.3F, -0.5F); + TileEntityRendererDispatcher.instance.renderTileEntityAt(new TileTeruTeruBozu(), 0.0D, 0.0D, 0.0D, 0.0F); + GL11.glPopMatrix(); + } + + @Override + public boolean renderWorldBlock( + IBlockAccess world, int x, int y, int z, Block block, int modelId, RenderBlocks renderer) { + return false; + } + + @Override + public int getRenderId() { + return LibRenderIDs.idTeruTeruBozu; + } + + @Override + public boolean shouldRender3DInInventory(int modelId) { + return true; + } } diff --git a/src/main/java/vazkii/botania/client/render/block/RenderTinyPotato.java b/src/main/java/vazkii/botania/client/render/block/RenderTinyPotato.java index 2ba503369e..a13915da36 100644 --- a/src/main/java/vazkii/botania/client/render/block/RenderTinyPotato.java +++ b/src/main/java/vazkii/botania/client/render/block/RenderTinyPotato.java @@ -2,48 +2,46 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jul 18, 2014, 11:43:37 PM (GMT)] */ package vazkii.botania.client.render.block; +import cpw.mods.fml.client.registry.ISimpleBlockRenderingHandler; import net.minecraft.block.Block; import net.minecraft.client.renderer.RenderBlocks; import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher; import net.minecraft.world.IBlockAccess; - import org.lwjgl.opengl.GL11; - import vazkii.botania.client.lib.LibRenderIDs; import vazkii.botania.common.block.tile.TileTinyPotato; -import cpw.mods.fml.client.registry.ISimpleBlockRenderingHandler; public class RenderTinyPotato implements ISimpleBlockRenderingHandler { - @Override - public void renderInventoryBlock(Block block, int metadata, int modelId, RenderBlocks renderer) { - GL11.glPushMatrix(); - GL11.glTranslatef(-0.5F, 0F, -0.5F); - TileEntityRendererDispatcher.instance.renderTileEntityAt(new TileTinyPotato(), 0.0D, 0.0D, 0.0D, 0.0F); - GL11.glPopMatrix(); - } - - @Override - public boolean renderWorldBlock(IBlockAccess world, int x, int y, int z, Block block, int modelId, RenderBlocks renderer) { - return false; - } - - @Override - public boolean shouldRender3DInInventory(int modelId) { - return true; - } - - @Override - public int getRenderId() { - return LibRenderIDs.idTinyPotato; - } - + @Override + public void renderInventoryBlock(Block block, int metadata, int modelId, RenderBlocks renderer) { + GL11.glPushMatrix(); + GL11.glTranslatef(-0.5F, 0F, -0.5F); + TileEntityRendererDispatcher.instance.renderTileEntityAt(new TileTinyPotato(), 0.0D, 0.0D, 0.0D, 0.0F); + GL11.glPopMatrix(); + } + + @Override + public boolean renderWorldBlock( + IBlockAccess world, int x, int y, int z, Block block, int modelId, RenderBlocks renderer) { + return false; + } + + @Override + public boolean shouldRender3DInInventory(int modelId) { + return true; + } + + @Override + public int getRenderId() { + return LibRenderIDs.idTinyPotato; + } } diff --git a/src/main/java/vazkii/botania/client/render/entity/RenderBabylonWeapon.java b/src/main/java/vazkii/botania/client/render/entity/RenderBabylonWeapon.java index 0fc4712ede..ea27f08db5 100644 --- a/src/main/java/vazkii/botania/client/render/entity/RenderBabylonWeapon.java +++ b/src/main/java/vazkii/botania/client/render/entity/RenderBabylonWeapon.java @@ -2,16 +2,15 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Aug 16, 2015, 6:42:09 PM (GMT)] */ package vazkii.botania.client.render.entity; import java.util.Random; - import net.minecraft.client.Minecraft; import net.minecraft.client.renderer.ItemRenderer; import net.minecraft.client.renderer.OpenGlHelper; @@ -21,9 +20,7 @@ import net.minecraft.entity.Entity; import net.minecraft.util.IIcon; import net.minecraft.util.ResourceLocation; - import org.lwjgl.opengl.GL11; - import vazkii.botania.client.core.helper.ShaderHelper; import vazkii.botania.client.lib.LibResources; import vazkii.botania.common.entity.EntityBabylonWeapon; @@ -31,79 +28,78 @@ public class RenderBabylonWeapon extends Render { - private static final ResourceLocation babylon = new ResourceLocation(LibResources.MISC_BABYLON); - - @Override - public void doRender(Entity par1Entity, double par2, double par4, double par6, float par8, float par9) { - EntityBabylonWeapon weapon = (EntityBabylonWeapon) par1Entity; - GL11.glPushMatrix(); - GL11.glTranslatef((float)par2, (float)par4, (float)par6); - GL11.glRotatef(weapon.getRotation(), 0F, 1F, 0F); - - int live = weapon.getLiveTicks(); - int delay = weapon.getDelay(); - float charge = Math.min(10F, Math.max(live, weapon.getChargeTicks()) + par9); - float chargeMul = charge / 10F; - - GL11.glEnable(GL11.GL_BLEND); - GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); - - Minecraft.getMinecraft().renderEngine.bindTexture(TextureMap.locationItemsTexture); - GL11.glPushMatrix(); - float s = 1.5F; - GL11.glScalef(s, s, s); - GL11.glRotatef(-90F, 0F, 1F, 0F); - GL11.glRotatef(45F, 0F, 0F, 1F); - IIcon icon = ItemKingKey.weaponIcons[weapon.getVariety()]; - GL11.glColor4f(1F, 1F, 1F, chargeMul); - float f = icon.getMinU(); - float f1 = icon.getMaxU(); - float f2 = icon.getMinV(); - float f3 = icon.getMaxV(); - - OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, 240, 240); - GL11.glDisable(GL11.GL_LIGHTING); - ItemRenderer.renderItemIn2D(Tessellator.instance, f1, f2, f, f3, icon.getIconWidth(), icon.getIconHeight(), 1F / 16F); - GL11.glPopMatrix(); - - GL11.glDisable(GL11.GL_CULL_FACE); - GL11.glShadeModel(GL11.GL_SMOOTH); - GL11.glColor4f(1F, 1F, 1F, chargeMul); - - Minecraft.getMinecraft().renderEngine.bindTexture(babylon); - - Tessellator tes = Tessellator.instance; - ShaderHelper.useShader(ShaderHelper.halo); - Random rand = new Random(weapon.getUniqueID().getMostSignificantBits()); - GL11.glRotatef(-90F, 1F, 0F, 0F); - GL11.glTranslatef(0F, -0.3F + rand.nextFloat() * 0.1F, 1F); - - s = chargeMul; - if(live > delay) - s -= Math.min(1F, (live - delay + par9) * 0.2F); - s *= 2F; - GL11.glScalef(s, s, s); - - GL11.glRotatef(charge * 9F + (weapon.ticksExisted + par9) * 0.5F + rand.nextFloat() * 360F, 0F, 1F, 0F); - - tes.startDrawingQuads(); - tes.addVertexWithUV(-1, 0, -1, 0, 0); - tes.addVertexWithUV(-1, 0, 1, 0, 1); - tes.addVertexWithUV(1, 0, 1, 1, 1); - tes.addVertexWithUV(1, 0, -1, 1, 0); - tes.draw(); - - ShaderHelper.releaseShader(); - - GL11.glEnable(GL11.GL_LIGHTING); - GL11.glShadeModel(GL11.GL_FLAT); - GL11.glEnable(GL11.GL_CULL_FACE); - GL11.glPopMatrix(); - } - - @Override - protected ResourceLocation getEntityTexture(Entity p_110775_1_) { - return null; - } - + private static final ResourceLocation babylon = new ResourceLocation(LibResources.MISC_BABYLON); + + @Override + public void doRender(Entity par1Entity, double par2, double par4, double par6, float par8, float par9) { + EntityBabylonWeapon weapon = (EntityBabylonWeapon) par1Entity; + GL11.glPushMatrix(); + GL11.glTranslatef((float) par2, (float) par4, (float) par6); + GL11.glRotatef(weapon.getRotation(), 0F, 1F, 0F); + + int live = weapon.getLiveTicks(); + int delay = weapon.getDelay(); + float charge = Math.min(10F, Math.max(live, weapon.getChargeTicks()) + par9); + float chargeMul = charge / 10F; + + GL11.glEnable(GL11.GL_BLEND); + GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); + + Minecraft.getMinecraft().renderEngine.bindTexture(TextureMap.locationItemsTexture); + GL11.glPushMatrix(); + float s = 1.5F; + GL11.glScalef(s, s, s); + GL11.glRotatef(-90F, 0F, 1F, 0F); + GL11.glRotatef(45F, 0F, 0F, 1F); + IIcon icon = ItemKingKey.weaponIcons[weapon.getVariety()]; + GL11.glColor4f(1F, 1F, 1F, chargeMul); + float f = icon.getMinU(); + float f1 = icon.getMaxU(); + float f2 = icon.getMinV(); + float f3 = icon.getMaxV(); + + OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, 240, 240); + GL11.glDisable(GL11.GL_LIGHTING); + ItemRenderer.renderItemIn2D( + Tessellator.instance, f1, f2, f, f3, icon.getIconWidth(), icon.getIconHeight(), 1F / 16F); + GL11.glPopMatrix(); + + GL11.glDisable(GL11.GL_CULL_FACE); + GL11.glShadeModel(GL11.GL_SMOOTH); + GL11.glColor4f(1F, 1F, 1F, chargeMul); + + Minecraft.getMinecraft().renderEngine.bindTexture(babylon); + + Tessellator tes = Tessellator.instance; + ShaderHelper.useShader(ShaderHelper.halo); + Random rand = new Random(weapon.getUniqueID().getMostSignificantBits()); + GL11.glRotatef(-90F, 1F, 0F, 0F); + GL11.glTranslatef(0F, -0.3F + rand.nextFloat() * 0.1F, 1F); + + s = chargeMul; + if (live > delay) s -= Math.min(1F, (live - delay + par9) * 0.2F); + s *= 2F; + GL11.glScalef(s, s, s); + + GL11.glRotatef(charge * 9F + (weapon.ticksExisted + par9) * 0.5F + rand.nextFloat() * 360F, 0F, 1F, 0F); + + tes.startDrawingQuads(); + tes.addVertexWithUV(-1, 0, -1, 0, 0); + tes.addVertexWithUV(-1, 0, 1, 0, 1); + tes.addVertexWithUV(1, 0, 1, 1, 1); + tes.addVertexWithUV(1, 0, -1, 1, 0); + tes.draw(); + + ShaderHelper.releaseShader(); + + GL11.glEnable(GL11.GL_LIGHTING); + GL11.glShadeModel(GL11.GL_FLAT); + GL11.glEnable(GL11.GL_CULL_FACE); + GL11.glPopMatrix(); + } + + @Override + protected ResourceLocation getEntityTexture(Entity p_110775_1_) { + return null; + } } diff --git a/src/main/java/vazkii/botania/client/render/entity/RenderCorporeaSpark.java b/src/main/java/vazkii/botania/client/render/entity/RenderCorporeaSpark.java index 5dc731a27b..d1216aecfc 100644 --- a/src/main/java/vazkii/botania/client/render/entity/RenderCorporeaSpark.java +++ b/src/main/java/vazkii/botania/client/render/entity/RenderCorporeaSpark.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Feb 14, 2015, 1:04:34 AM (GMT)] */ package vazkii.botania.client.render.entity; @@ -21,83 +21,94 @@ import net.minecraft.item.ItemStack; import net.minecraft.util.IIcon; import net.minecraftforge.common.util.ForgeDirection; - import org.lwjgl.opengl.GL11; - import vazkii.botania.common.entity.EntityCorporeaSpark; import vazkii.botania.common.item.ItemCorporeaSpark; public class RenderCorporeaSpark extends RenderSparkBase { - @Override - public IIcon getBaseIcon(EntityCorporeaSpark entity) { - return entity.isMaster() ? ItemCorporeaSpark.worldIconMaster : ItemCorporeaSpark.worldIcon; - } - - @Override - public void colorSpinningIcon(EntityCorporeaSpark entity, float a) { - int network = Math.min(15, entity.getNetwork()); - GL11.glColor4f(EntitySheep.fleeceColorTable[network][0], EntitySheep.fleeceColorTable[network][1], EntitySheep.fleeceColorTable[network][2], a); - } - - @Override - public IIcon getSpinningIcon(EntityCorporeaSpark entity) { - return ItemCorporeaSpark.iconColorStar; - } - - @Override - public void renderCallback(EntityCorporeaSpark entity, float pticks) { - int time = entity.getItemDisplayTicks(); - if(time == 0) - return; - - float absTime = Math.abs(time) - pticks; - - GL11.glPushMatrix(); - GL11.glRotated(90F, 1F, 0F, 0F); - float scalef = 1F / 6F; - GL11.glScalef(scalef, scalef, scalef); - GL11.glEnable(GL11.GL_BLEND); - GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); - GL11.glColor4f(1F, 1F, 1F, absTime / 10); - GL11.glTranslatef(0F, 0F, -2F + (time < 0 ? -absTime : absTime) / 6); - - ItemStack stack = entity.getDisplayedItem(); - if(stack == null) - return; - - Item item = stack.getItem(); - boolean block = item instanceof ItemBlock; - Minecraft.getMinecraft().renderEngine.bindTexture(block ? TextureMap.locationBlocksTexture : TextureMap.locationItemsTexture); - IIcon icon = block ? Block.getBlockFromItem(item).getBlockTextureFromSide(ForgeDirection.UP.ordinal()) : item.getIcon(stack, 0); - - if(icon != null) { - float minU = icon.getMinU(); - float maxU = icon.getMaxU(); - float minV = icon.getMinV(); - float maxV = icon.getMaxV(); - - int pieces = 8; - float stepU = (maxU - minU) / pieces; - float stepV = (maxV - minV) / pieces; - float gap = 1F + (time > 0 ? 10F - absTime : absTime) * 0.2F; - int shift = pieces / 2; - - float scale = 1F / pieces * 3F; - GL11.glScalef(scale, scale, 1F); - for(int i = -shift; i < shift; i++) { - GL11.glTranslated(gap * i, 0F, 0F); - for(int j = -shift; j < shift; j++) { - GL11.glTranslated(0F, gap * j, 0F); - ItemRenderer.renderItemIn2D(Tessellator.instance, minU + stepU * (i + shift), minV + stepV * (j + shift + 1), minU + stepU * (i + shift + 1), minV + stepV * (j + shift), icon.getIconWidth() / pieces, icon.getIconHeight() / pieces, 1F / 8F); - GL11.glTranslated(0F, -gap * j, 0F); - } - GL11.glTranslated(-gap * i, 0F, 0F); - } - } - - GL11.glDisable(GL11.GL_BLEND); - GL11.glPopMatrix(); - } - + @Override + public IIcon getBaseIcon(EntityCorporeaSpark entity) { + return entity.isMaster() ? ItemCorporeaSpark.worldIconMaster : ItemCorporeaSpark.worldIcon; + } + + @Override + public void colorSpinningIcon(EntityCorporeaSpark entity, float a) { + int network = Math.min(15, entity.getNetwork()); + GL11.glColor4f( + EntitySheep.fleeceColorTable[network][0], + EntitySheep.fleeceColorTable[network][1], + EntitySheep.fleeceColorTable[network][2], + a); + } + + @Override + public IIcon getSpinningIcon(EntityCorporeaSpark entity) { + return ItemCorporeaSpark.iconColorStar; + } + + @Override + public void renderCallback(EntityCorporeaSpark entity, float pticks) { + int time = entity.getItemDisplayTicks(); + if (time == 0) return; + + float absTime = Math.abs(time) - pticks; + + GL11.glPushMatrix(); + GL11.glRotated(90F, 1F, 0F, 0F); + float scalef = 1F / 6F; + GL11.glScalef(scalef, scalef, scalef); + GL11.glEnable(GL11.GL_BLEND); + GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); + GL11.glColor4f(1F, 1F, 1F, absTime / 10); + GL11.glTranslatef(0F, 0F, -2F + (time < 0 ? -absTime : absTime) / 6); + + ItemStack stack = entity.getDisplayedItem(); + if (stack == null) return; + + Item item = stack.getItem(); + boolean block = item instanceof ItemBlock; + Minecraft.getMinecraft() + .renderEngine + .bindTexture(block ? TextureMap.locationBlocksTexture : TextureMap.locationItemsTexture); + IIcon icon = block + ? Block.getBlockFromItem(item).getBlockTextureFromSide(ForgeDirection.UP.ordinal()) + : item.getIcon(stack, 0); + + if (icon != null) { + float minU = icon.getMinU(); + float maxU = icon.getMaxU(); + float minV = icon.getMinV(); + float maxV = icon.getMaxV(); + + int pieces = 8; + float stepU = (maxU - minU) / pieces; + float stepV = (maxV - minV) / pieces; + float gap = 1F + (time > 0 ? 10F - absTime : absTime) * 0.2F; + int shift = pieces / 2; + + float scale = 1F / pieces * 3F; + GL11.glScalef(scale, scale, 1F); + for (int i = -shift; i < shift; i++) { + GL11.glTranslated(gap * i, 0F, 0F); + for (int j = -shift; j < shift; j++) { + GL11.glTranslated(0F, gap * j, 0F); + ItemRenderer.renderItemIn2D( + Tessellator.instance, + minU + stepU * (i + shift), + minV + stepV * (j + shift + 1), + minU + stepU * (i + shift + 1), + minV + stepV * (j + shift), + icon.getIconWidth() / pieces, + icon.getIconHeight() / pieces, + 1F / 8F); + GL11.glTranslated(0F, -gap * j, 0F); + } + GL11.glTranslated(-gap * i, 0F, 0F); + } + } + + GL11.glDisable(GL11.GL_BLEND); + GL11.glPopMatrix(); + } } diff --git a/src/main/java/vazkii/botania/client/render/entity/RenderDoppleganger.java b/src/main/java/vazkii/botania/client/render/entity/RenderDoppleganger.java index 3b8c124ba8..51b2ca39c5 100644 --- a/src/main/java/vazkii/botania/client/render/entity/RenderDoppleganger.java +++ b/src/main/java/vazkii/botania/client/render/entity/RenderDoppleganger.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jul 12, 2014, 4:07:26 PM (GMT)] */ package vazkii.botania.client.render.entity; @@ -15,9 +15,7 @@ import net.minecraft.client.renderer.entity.RenderBiped; import net.minecraft.entity.Entity; import net.minecraft.util.ResourceLocation; - import org.lwjgl.opengl.ARBShaderObjects; - import vazkii.botania.api.internal.ShaderCallback; import vazkii.botania.client.core.handler.BossBarHandler; import vazkii.botania.client.core.helper.ShaderHelper; @@ -25,66 +23,65 @@ public class RenderDoppleganger extends RenderBiped { - public static float DEFAULT_GRAIN_INTENSITY = 0.05F; - public static float DEFAULT_DISFIGURATION = 0.025F; - - public static float grainIntensity = DEFAULT_GRAIN_INTENSITY; - public static float disfiguration = DEFAULT_DISFIGURATION; - - public static ShaderCallback callback = new ShaderCallback() { - - @Override - public void call(int shader) { - // Frag Uniforms - int disfigurationUniform = ARBShaderObjects.glGetUniformLocationARB(shader, "disfiguration"); - ARBShaderObjects.glUniform1fARB(disfigurationUniform, disfiguration); - - // Vert Uniforms - int grainIntensityUniform = ARBShaderObjects.glGetUniformLocationARB(shader, "grainIntensity"); - ARBShaderObjects.glUniform1fARB(grainIntensityUniform, grainIntensity); - } - }; - - public static ShaderCallback defaultCallback = new ShaderCallback() { - - @Override - public void call(int shader) { - // Frag Uniforms - int disfigurationUniform = ARBShaderObjects.glGetUniformLocationARB(shader, "disfiguration"); - ARBShaderObjects.glUniform1fARB(disfigurationUniform, DEFAULT_DISFIGURATION); - - // Vert Uniforms - int grainIntensityUniform = ARBShaderObjects.glGetUniformLocationARB(shader, "grainIntensity"); - ARBShaderObjects.glUniform1fARB(grainIntensityUniform, DEFAULT_GRAIN_INTENSITY); - } - }; - - public RenderDoppleganger() { - super(new ModelBiped(0.5F), 0F); - } - - @Override - public void doRender(Entity par1Entity, double par2, double par4, double par6, float par8, float par9) { - EntityDoppleganger dopple = (EntityDoppleganger) par1Entity; - BossBarHandler.setCurrentBoss(dopple); - - int invulTime = dopple.getInvulTime(); - if(invulTime > 0) { - grainIntensity = invulTime > 20 ? 1F : invulTime * 0.05F; - disfiguration = grainIntensity * 0.3F; - } else { - disfiguration = (0.025F + dopple.hurtTime * ((1F - 0.15F) / 20F)) / 2F; - grainIntensity = 0.05F + dopple.hurtTime * ((1F - 0.15F) / 10F); - } - - ShaderHelper.useShader(ShaderHelper.doppleganger, callback); - super.doRender(par1Entity, par2, par4, par6, par8, par9); - ShaderHelper.releaseShader(); - } - - @Override - protected ResourceLocation getEntityTexture(Entity par1Entity) { - return Minecraft.getMinecraft().thePlayer.getLocationSkin(); - } - + public static float DEFAULT_GRAIN_INTENSITY = 0.05F; + public static float DEFAULT_DISFIGURATION = 0.025F; + + public static float grainIntensity = DEFAULT_GRAIN_INTENSITY; + public static float disfiguration = DEFAULT_DISFIGURATION; + + public static ShaderCallback callback = new ShaderCallback() { + + @Override + public void call(int shader) { + // Frag Uniforms + int disfigurationUniform = ARBShaderObjects.glGetUniformLocationARB(shader, "disfiguration"); + ARBShaderObjects.glUniform1fARB(disfigurationUniform, disfiguration); + + // Vert Uniforms + int grainIntensityUniform = ARBShaderObjects.glGetUniformLocationARB(shader, "grainIntensity"); + ARBShaderObjects.glUniform1fARB(grainIntensityUniform, grainIntensity); + } + }; + + public static ShaderCallback defaultCallback = new ShaderCallback() { + + @Override + public void call(int shader) { + // Frag Uniforms + int disfigurationUniform = ARBShaderObjects.glGetUniformLocationARB(shader, "disfiguration"); + ARBShaderObjects.glUniform1fARB(disfigurationUniform, DEFAULT_DISFIGURATION); + + // Vert Uniforms + int grainIntensityUniform = ARBShaderObjects.glGetUniformLocationARB(shader, "grainIntensity"); + ARBShaderObjects.glUniform1fARB(grainIntensityUniform, DEFAULT_GRAIN_INTENSITY); + } + }; + + public RenderDoppleganger() { + super(new ModelBiped(0.5F), 0F); + } + + @Override + public void doRender(Entity par1Entity, double par2, double par4, double par6, float par8, float par9) { + EntityDoppleganger dopple = (EntityDoppleganger) par1Entity; + BossBarHandler.setCurrentBoss(dopple); + + int invulTime = dopple.getInvulTime(); + if (invulTime > 0) { + grainIntensity = invulTime > 20 ? 1F : invulTime * 0.05F; + disfiguration = grainIntensity * 0.3F; + } else { + disfiguration = (0.025F + dopple.hurtTime * ((1F - 0.15F) / 20F)) / 2F; + grainIntensity = 0.05F + dopple.hurtTime * ((1F - 0.15F) / 10F); + } + + ShaderHelper.useShader(ShaderHelper.doppleganger, callback); + super.doRender(par1Entity, par2, par4, par6, par8, par9); + ShaderHelper.releaseShader(); + } + + @Override + protected ResourceLocation getEntityTexture(Entity par1Entity) { + return Minecraft.getMinecraft().thePlayer.getLocationSkin(); + } } diff --git a/src/main/java/vazkii/botania/client/render/entity/RenderManaStorm.java b/src/main/java/vazkii/botania/client/render/entity/RenderManaStorm.java index f0f568af4f..7f3add7762 100644 --- a/src/main/java/vazkii/botania/client/render/entity/RenderManaStorm.java +++ b/src/main/java/vazkii/botania/client/render/entity/RenderManaStorm.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jul 25, 2015, 2:32:31 AM (GMT)] */ package vazkii.botania.client.render.entity; @@ -13,31 +13,31 @@ import net.minecraft.client.renderer.entity.Render; import net.minecraft.entity.Entity; import net.minecraft.util.ResourceLocation; - import org.lwjgl.opengl.GL11; import org.lwjgl.opengl.GL12; - import vazkii.botania.client.core.helper.RenderHelper; import vazkii.botania.common.entity.EntityManaStorm; public class RenderManaStorm extends Render { - @Override - public void doRender(Entity e, double x, double y, double z, float something, float pticks) { - GL11.glPushMatrix(); - GL11.glTranslated(x, y, z); - EntityManaStorm storm = (EntityManaStorm) e; - float maxScale = 1.95F; - float scale = 0.05F + ((float) storm.burstsFired / EntityManaStorm.TOTAL_BURSTS - (storm.deathTime == 0 ? 0 : storm.deathTime + pticks) / EntityManaStorm.DEATH_TIME) * maxScale; - RenderHelper.renderStar(0x00FF00, scale, scale, scale, e.getUniqueID().getMostSignificantBits()); - GL11.glDisable(GL11.GL_BLEND); - GL11.glDisable(GL12.GL_RESCALE_NORMAL); - GL11.glPopMatrix(); - } - - @Override - protected ResourceLocation getEntityTexture(Entity p_110775_1_) { - return null; - } + @Override + public void doRender(Entity e, double x, double y, double z, float something, float pticks) { + GL11.glPushMatrix(); + GL11.glTranslated(x, y, z); + EntityManaStorm storm = (EntityManaStorm) e; + float maxScale = 1.95F; + float scale = 0.05F + + ((float) storm.burstsFired / EntityManaStorm.TOTAL_BURSTS + - (storm.deathTime == 0 ? 0 : storm.deathTime + pticks) / EntityManaStorm.DEATH_TIME) + * maxScale; + RenderHelper.renderStar(0x00FF00, scale, scale, scale, e.getUniqueID().getMostSignificantBits()); + GL11.glDisable(GL11.GL_BLEND); + GL11.glDisable(GL12.GL_RESCALE_NORMAL); + GL11.glPopMatrix(); + } + @Override + protected ResourceLocation getEntityTexture(Entity p_110775_1_) { + return null; + } } diff --git a/src/main/java/vazkii/botania/client/render/entity/RenderPinkWither.java b/src/main/java/vazkii/botania/client/render/entity/RenderPinkWither.java index a6806ca39d..3765d9b901 100644 --- a/src/main/java/vazkii/botania/client/render/entity/RenderPinkWither.java +++ b/src/main/java/vazkii/botania/client/render/entity/RenderPinkWither.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Mar 25, 2015, 5:55:59 PM (GMT)] */ package vazkii.botania.client.render.entity; @@ -18,22 +18,27 @@ public class RenderPinkWither extends RenderWither { - private static final ResourceLocation resource = new ResourceLocation(LibResources.MODEL_PINK_WITHER); + private static final ResourceLocation resource = new ResourceLocation(LibResources.MODEL_PINK_WITHER); - int idk = -1; + int idk = -1; - @Override - public void doRender(EntityWither p_76986_1_, double p_76986_2_, double p_76986_4_, double p_76986_6_, float p_76986_8_, float p_76986_9_) { - super.doRender(p_76986_1_, p_76986_2_, p_76986_4_, p_76986_6_, p_76986_8_, p_76986_9_); - if(BossStatus.bossName.equals(p_76986_1_.func_145748_c_().getFormattedText())) { - BossStatus.statusBarTime = -1; - BossStatus.hasColorModifier = false; - } - } - - @Override - protected ResourceLocation getEntityTexture(EntityWither p_110775_1_) { - return resource; - } + @Override + public void doRender( + EntityWither p_76986_1_, + double p_76986_2_, + double p_76986_4_, + double p_76986_6_, + float p_76986_8_, + float p_76986_9_) { + super.doRender(p_76986_1_, p_76986_2_, p_76986_4_, p_76986_6_, p_76986_8_, p_76986_9_); + if (BossStatus.bossName.equals(p_76986_1_.func_145748_c_().getFormattedText())) { + BossStatus.statusBarTime = -1; + BossStatus.hasColorModifier = false; + } + } + @Override + protected ResourceLocation getEntityTexture(EntityWither p_110775_1_) { + return resource; + } } diff --git a/src/main/java/vazkii/botania/client/render/entity/RenderPixie.java b/src/main/java/vazkii/botania/client/render/entity/RenderPixie.java index 4ef2757543..cdedfb416c 100644 --- a/src/main/java/vazkii/botania/client/render/entity/RenderPixie.java +++ b/src/main/java/vazkii/botania/client/render/entity/RenderPixie.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [? (GMT)] */ package vazkii.botania.client.render.entity; @@ -15,10 +15,8 @@ import net.minecraft.entity.Entity; import net.minecraft.entity.EntityLivingBase; import net.minecraft.util.ResourceLocation; - import org.lwjgl.opengl.ARBShaderObjects; import org.lwjgl.opengl.GL11; - import vazkii.botania.api.internal.ShaderCallback; import vazkii.botania.client.core.helper.ShaderHelper; import vazkii.botania.client.lib.LibResources; @@ -27,69 +25,64 @@ public class RenderPixie extends RenderLiving { - ShaderCallback callback = new ShaderCallback() { + ShaderCallback callback = new ShaderCallback() { - @Override - public void call(int shader) { - // Frag Uniforms - int disfigurationUniform = ARBShaderObjects.glGetUniformLocationARB(shader, "disfiguration"); - ARBShaderObjects.glUniform1fARB(disfigurationUniform, 0.025F); + @Override + public void call(int shader) { + // Frag Uniforms + int disfigurationUniform = ARBShaderObjects.glGetUniformLocationARB(shader, "disfiguration"); + ARBShaderObjects.glUniform1fARB(disfigurationUniform, 0.025F); - // Vert Uniforms - int grainIntensityUniform = ARBShaderObjects.glGetUniformLocationARB(shader, "grainIntensity"); - ARBShaderObjects.glUniform1fARB(grainIntensityUniform, 0.05F); - } - }; + // Vert Uniforms + int grainIntensityUniform = ARBShaderObjects.glGetUniformLocationARB(shader, "grainIntensity"); + ARBShaderObjects.glUniform1fARB(grainIntensityUniform, 0.05F); + } + }; - public RenderPixie() { - super(new ModelPixie(), 0.25F); - setRenderPassModel(new ModelPixie()); - shadowSize = 0.0F; - } + public RenderPixie() { + super(new ModelPixie(), 0.25F); + setRenderPassModel(new ModelPixie()); + shadowSize = 0.0F; + } - @Override - protected ResourceLocation getEntityTexture(Entity entity) { - return new ResourceLocation(LibResources.MODEL_PIXIE); - } + @Override + protected ResourceLocation getEntityTexture(Entity entity) { + return new ResourceLocation(LibResources.MODEL_PIXIE); + } - @Override - public void doRender(Entity par1Entity, double par2, double par4, double par6, float par8, float par9) { - EntityPixie pixie = (EntityPixie) par1Entity; + @Override + public void doRender(Entity par1Entity, double par2, double par4, double par6, float par8, float par9) { + EntityPixie pixie = (EntityPixie) par1Entity; - if(pixie.getType() == 1) - ShaderHelper.useShader(ShaderHelper.doppleganger, callback); - super.doRender(par1Entity, par2, par4, par6, par8, par9); - if(pixie.getType() == 1) - ShaderHelper.releaseShader(); - } + if (pixie.getType() == 1) ShaderHelper.useShader(ShaderHelper.doppleganger, callback); + super.doRender(par1Entity, par2, par4, par6, par8, par9); + if (pixie.getType() == 1) ShaderHelper.releaseShader(); + } - protected int setPixieBrightness(EntityPixie par1EntityPixie, int par2, float par3) { - if (par2 != 0) - return -1; - else { - bindTexture(getEntityTexture(par1EntityPixie)); - float f1 = 1.0F; - GL11.glEnable(GL11.GL_BLEND); - GL11.glDisable(GL11.GL_ALPHA_TEST); - GL11.glBlendFunc(GL11.GL_ONE, GL11.GL_ONE); + protected int setPixieBrightness(EntityPixie par1EntityPixie, int par2, float par3) { + if (par2 != 0) return -1; + else { + bindTexture(getEntityTexture(par1EntityPixie)); + float f1 = 1.0F; + GL11.glEnable(GL11.GL_BLEND); + GL11.glDisable(GL11.GL_ALPHA_TEST); + GL11.glBlendFunc(GL11.GL_ONE, GL11.GL_ONE); - if (par1EntityPixie.isInvisible()) - GL11.glDepthMask(false); - else - GL11.glDepthMask(true); + if (par1EntityPixie.isInvisible()) GL11.glDepthMask(false); + else GL11.glDepthMask(true); - char c0 = 61680; - int j = c0 % 65536; - int k = c0 / 65536; - OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, j / 1.0F, k / 1.0F); - GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); - GL11.glColor4f(1.0F, 1.0F, 1.0F, f1); - return 1; - } - } + char c0 = 61680; + int j = c0 % 65536; + int k = c0 / 65536; + OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, j / 1.0F, k / 1.0F); + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + GL11.glColor4f(1.0F, 1.0F, 1.0F, f1); + return 1; + } + } - @Override - protected int shouldRenderPass(EntityLivingBase par1EntityLivingBase, int par2, float par3) { - return setPixieBrightness((EntityPixie)par1EntityLivingBase, par2, par3); - } -} \ No newline at end of file + @Override + protected int shouldRenderPass(EntityLivingBase par1EntityLivingBase, int par2, float par3) { + return setPixieBrightness((EntityPixie) par1EntityLivingBase, par2, par3); + } +} diff --git a/src/main/java/vazkii/botania/client/render/entity/RenderPoolMinecart.java b/src/main/java/vazkii/botania/client/render/entity/RenderPoolMinecart.java index b9a043881a..1db0784861 100644 --- a/src/main/java/vazkii/botania/client/render/entity/RenderPoolMinecart.java +++ b/src/main/java/vazkii/botania/client/render/entity/RenderPoolMinecart.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Mar 17, 2015, 11:17:48 PM (GMT)] */ package vazkii.botania.client.render.entity; @@ -18,12 +18,10 @@ public class RenderPoolMinecart extends RenderMinecart { - @Override - protected void func_147910_a(EntityMinecart p_147910_1_, float p_147910_2_, Block p_147910_3_, int p_147910_4_) { - EntityPoolMinecart poolCart = (EntityPoolMinecart) p_147910_1_; - RenderTilePool.forceManaNumber = poolCart.getMana(); - super.func_147910_a(p_147910_1_, p_147910_2_, p_147910_3_, p_147910_4_); - } - - + @Override + protected void func_147910_a(EntityMinecart p_147910_1_, float p_147910_2_, Block p_147910_3_, int p_147910_4_) { + EntityPoolMinecart poolCart = (EntityPoolMinecart) p_147910_1_; + RenderTilePool.forceManaNumber = poolCart.getMana(); + super.func_147910_a(p_147910_1_, p_147910_2_, p_147910_3_, p_147910_4_); + } } diff --git a/src/main/java/vazkii/botania/client/render/entity/RenderSpark.java b/src/main/java/vazkii/botania/client/render/entity/RenderSpark.java index d28bcaca0d..091006e9d6 100644 --- a/src/main/java/vazkii/botania/client/render/entity/RenderSpark.java +++ b/src/main/java/vazkii/botania/client/render/entity/RenderSpark.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Feb 14, 2015, 1:03:11 AM (GMT)] */ package vazkii.botania.client.render.entity; @@ -16,10 +16,11 @@ public class RenderSpark extends RenderSparkBase { - @Override - public IIcon getSpinningIcon(EntitySpark entity) { - int upgrade = entity.getUpgrade() - 1; - return upgrade >= 0 && upgrade < ItemSparkUpgrade.worldIcons.length ? ItemSparkUpgrade.worldIcons[upgrade] : null; - } - + @Override + public IIcon getSpinningIcon(EntitySpark entity) { + int upgrade = entity.getUpgrade() - 1; + return upgrade >= 0 && upgrade < ItemSparkUpgrade.worldIcons.length + ? ItemSparkUpgrade.worldIcons[upgrade] + : null; + } } diff --git a/src/main/java/vazkii/botania/client/render/entity/RenderSparkBase.java b/src/main/java/vazkii/botania/client/render/entity/RenderSparkBase.java index ff1109f83e..201317469b 100644 --- a/src/main/java/vazkii/botania/client/render/entity/RenderSparkBase.java +++ b/src/main/java/vazkii/botania/client/render/entity/RenderSparkBase.java @@ -2,116 +2,114 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Aug 21, 2014, 5:53:22 PM (GMT)] */ package vazkii.botania.client.render.entity; import java.util.Random; - import net.minecraft.client.renderer.Tessellator; import net.minecraft.client.renderer.entity.RenderEntity; import net.minecraft.client.renderer.texture.TextureMap; import net.minecraft.entity.Entity; import net.minecraft.util.IIcon; import net.minecraft.util.ResourceLocation; - import org.lwjgl.opengl.GL11; import org.lwjgl.opengl.GL12; - import vazkii.botania.client.core.handler.ClientTickHandler; import vazkii.botania.common.entity.EntitySpark; import vazkii.botania.common.item.ItemSpark; public class RenderSparkBase extends RenderEntity { - @Override - public void doRender(Entity par1Entity, double par2, double par4, double par6, float par8, float par9) { - T tEntity = (T) par1Entity; - IIcon iicon = getBaseIcon(tEntity); - - GL11.glPushMatrix(); - GL11.glTranslatef((float)par2, (float)par4, (float)par6); - GL11.glEnable(GL12.GL_RESCALE_NORMAL); - GL11.glEnable(GL11.GL_BLEND); - GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); - GL11.glAlphaFunc(GL11.GL_GREATER, 0.05F); - - double time = ClientTickHandler.ticksInGame + par9; - time += new Random(par1Entity.getEntityId()).nextInt(); - float a = 0.1F + (1 - par1Entity.getDataWatcher().getWatchableObjectInt(EntitySpark.INVISIBILITY_DATA_WATCHER_KEY)) * 0.8F; - - GL11.glColor4f(1F, 1F, 1F, (0.7F + 0.3F * (float) (Math.sin(time / 5.0) + 0.5) * 2) * a); - - float scale = 0.75F + 0.1F * (float) Math.sin(time / 10); - GL11.glScalef(scale, scale, scale); - bindEntityTexture(par1Entity); - Tessellator tessellator = Tessellator.instance; - - GL11.glPushMatrix(); - float r = 180.0F - renderManager.playerViewY; - GL11.glRotatef(r, 0.0F, 1.0F, 0.0F); - GL11.glRotatef(-renderManager.playerViewX, 1F, 0F, 0F); - func_77026_a(tessellator, iicon); - - IIcon spinningIcon = getSpinningIcon(tEntity); - if(spinningIcon != null) { - GL11.glTranslatef(-0.02F + (float) Math.sin(time / 20) * 0.2F, 0.24F + (float) Math.cos(time / 20) * 0.2F, 0.005F); - GL11.glScalef(0.2F, 0.2F, 0.2F); - colorSpinningIcon(tEntity, a); - func_77026_a(tessellator, spinningIcon); - } - GL11.glPopMatrix(); - GL11.glColor4f(1F, 1F, 1F, 1F); - renderCallback(tEntity, par9); - - GL11.glDisable(GL11.GL_BLEND); - GL11.glDisable(GL12.GL_RESCALE_NORMAL); - GL11.glPopMatrix(); - } - - public IIcon getBaseIcon(T entity) { - return ItemSpark.worldIcon; - } - - public void colorSpinningIcon(T entity, float a) { - // NO-OP - } - - public IIcon getSpinningIcon(T entity) { - return null; - } - - public void renderCallback(T entity, float pticks) { - // NO-OP - } - - @Override - protected ResourceLocation getEntityTexture(Entity p_110775_1_) { - return TextureMap.locationItemsTexture; - } - - private void func_77026_a(Tessellator p_77026_1_, IIcon p_77026_2_) { - float f = p_77026_2_.getMinU(); - float f1 = p_77026_2_.getMaxU(); - float f2 = p_77026_2_.getMinV(); - float f3 = p_77026_2_.getMaxV(); - float f4 = 1.0F; - float f5 = 0.5F; - float f6 = 0.25F; - - p_77026_1_.startDrawingQuads(); - p_77026_1_.setNormal(0.0F, 1.0F, 0.0F); - p_77026_1_.setBrightness(240); - p_77026_1_.addVertexWithUV(0.0F - f5, 0.0F - f6, 0.0D, f, f3); - p_77026_1_.addVertexWithUV(f4 - f5, 0.0F - f6, 0.0D, f1, f3); - p_77026_1_.addVertexWithUV(f4 - f5, f4 - f6, 0.0D, f1, f2); - p_77026_1_.addVertexWithUV(0.0F - f5, f4 - f6, 0.0D, f, f2); - p_77026_1_.draw(); - - } - + @Override + public void doRender(Entity par1Entity, double par2, double par4, double par6, float par8, float par9) { + T tEntity = (T) par1Entity; + IIcon iicon = getBaseIcon(tEntity); + + GL11.glPushMatrix(); + GL11.glTranslatef((float) par2, (float) par4, (float) par6); + GL11.glEnable(GL12.GL_RESCALE_NORMAL); + GL11.glEnable(GL11.GL_BLEND); + GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); + GL11.glAlphaFunc(GL11.GL_GREATER, 0.05F); + + double time = ClientTickHandler.ticksInGame + par9; + time += new Random(par1Entity.getEntityId()).nextInt(); + float a = 0.1F + + (1 - par1Entity.getDataWatcher().getWatchableObjectInt(EntitySpark.INVISIBILITY_DATA_WATCHER_KEY)) + * 0.8F; + + GL11.glColor4f(1F, 1F, 1F, (0.7F + 0.3F * (float) (Math.sin(time / 5.0) + 0.5) * 2) * a); + + float scale = 0.75F + 0.1F * (float) Math.sin(time / 10); + GL11.glScalef(scale, scale, scale); + bindEntityTexture(par1Entity); + Tessellator tessellator = Tessellator.instance; + + GL11.glPushMatrix(); + float r = 180.0F - renderManager.playerViewY; + GL11.glRotatef(r, 0.0F, 1.0F, 0.0F); + GL11.glRotatef(-renderManager.playerViewX, 1F, 0F, 0F); + func_77026_a(tessellator, iicon); + + IIcon spinningIcon = getSpinningIcon(tEntity); + if (spinningIcon != null) { + GL11.glTranslatef( + -0.02F + (float) Math.sin(time / 20) * 0.2F, 0.24F + (float) Math.cos(time / 20) * 0.2F, 0.005F); + GL11.glScalef(0.2F, 0.2F, 0.2F); + colorSpinningIcon(tEntity, a); + func_77026_a(tessellator, spinningIcon); + } + GL11.glPopMatrix(); + GL11.glColor4f(1F, 1F, 1F, 1F); + renderCallback(tEntity, par9); + + GL11.glDisable(GL11.GL_BLEND); + GL11.glDisable(GL12.GL_RESCALE_NORMAL); + GL11.glPopMatrix(); + } + + public IIcon getBaseIcon(T entity) { + return ItemSpark.worldIcon; + } + + public void colorSpinningIcon(T entity, float a) { + // NO-OP + } + + public IIcon getSpinningIcon(T entity) { + return null; + } + + public void renderCallback(T entity, float pticks) { + // NO-OP + } + + @Override + protected ResourceLocation getEntityTexture(Entity p_110775_1_) { + return TextureMap.locationItemsTexture; + } + + private void func_77026_a(Tessellator p_77026_1_, IIcon p_77026_2_) { + float f = p_77026_2_.getMinU(); + float f1 = p_77026_2_.getMaxU(); + float f2 = p_77026_2_.getMinV(); + float f3 = p_77026_2_.getMaxV(); + float f4 = 1.0F; + float f5 = 0.5F; + float f6 = 0.25F; + + p_77026_1_.startDrawingQuads(); + p_77026_1_.setNormal(0.0F, 1.0F, 0.0F); + p_77026_1_.setBrightness(240); + p_77026_1_.addVertexWithUV(0.0F - f5, 0.0F - f6, 0.0D, f, f3); + p_77026_1_.addVertexWithUV(f4 - f5, 0.0F - f6, 0.0D, f1, f3); + p_77026_1_.addVertexWithUV(f4 - f5, f4 - f6, 0.0D, f1, f2); + p_77026_1_.addVertexWithUV(0.0F - f5, f4 - f6, 0.0D, f, f2); + p_77026_1_.draw(); + } } diff --git a/src/main/java/vazkii/botania/client/render/entity/RenderThornChakram.java b/src/main/java/vazkii/botania/client/render/entity/RenderThornChakram.java index e23e8a18a7..2dad7b416d 100644 --- a/src/main/java/vazkii/botania/client/render/entity/RenderThornChakram.java +++ b/src/main/java/vazkii/botania/client/render/entity/RenderThornChakram.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Aug 27, 2015, 10:02:12 PM (GMT)] */ package vazkii.botania.client.render.entity; @@ -16,60 +16,62 @@ import net.minecraft.entity.Entity; import net.minecraft.util.IIcon; import net.minecraft.util.ResourceLocation; - import org.lwjgl.opengl.GL11; import org.lwjgl.opengl.GL12; - import vazkii.botania.common.entity.EntityThornChakram; import vazkii.botania.common.item.ModItems; // Basically a bit of an extension of RenderSnowball public class RenderThornChakram extends Render { - @Override - public void doRender(Entity p_76986_1_, double p_76986_2_, double p_76986_4_, double p_76986_6_, float p_76986_8_, float p_76986_9_) { - EntityThornChakram c = (EntityThornChakram) p_76986_1_; - boolean fire = c.isFire(); - IIcon iicon = ModItems.thornChakram.getIconFromDamage(fire ? 1 : 0); - - if(iicon != null) { - GL11.glPushMatrix(); - GL11.glTranslatef((float)p_76986_2_, (float)p_76986_4_, (float)p_76986_6_); - GL11.glEnable(GL12.GL_RESCALE_NORMAL); - GL11.glScalef(0.5F, 0.5F, 0.5F); - bindEntityTexture(p_76986_1_); - Tessellator tessellator = Tessellator.instance; + @Override + public void doRender( + Entity p_76986_1_, + double p_76986_2_, + double p_76986_4_, + double p_76986_6_, + float p_76986_8_, + float p_76986_9_) { + EntityThornChakram c = (EntityThornChakram) p_76986_1_; + boolean fire = c.isFire(); + IIcon iicon = ModItems.thornChakram.getIconFromDamage(fire ? 1 : 0); - func_77026_a(tessellator, iicon, fire ? 240 : -1); - GL11.glDisable(GL12.GL_RESCALE_NORMAL); - GL11.glPopMatrix(); - } - } + if (iicon != null) { + GL11.glPushMatrix(); + GL11.glTranslatef((float) p_76986_2_, (float) p_76986_4_, (float) p_76986_6_); + GL11.glEnable(GL12.GL_RESCALE_NORMAL); + GL11.glScalef(0.5F, 0.5F, 0.5F); + bindEntityTexture(p_76986_1_); + Tessellator tessellator = Tessellator.instance; - @Override - protected ResourceLocation getEntityTexture(Entity p_110775_1_) { - return TextureMap.locationItemsTexture; - } + func_77026_a(tessellator, iicon, fire ? 240 : -1); + GL11.glDisable(GL12.GL_RESCALE_NORMAL); + GL11.glPopMatrix(); + } + } - private void func_77026_a(Tessellator p_77026_1_, IIcon p_77026_2_, int light) { - float f = p_77026_2_.getMinU(); - float f1 = p_77026_2_.getMaxU(); - float f2 = p_77026_2_.getMinV(); - float f3 = p_77026_2_.getMaxV(); - float f4 = 1.0F; - float f5 = 0.5F; - float f6 = 0.25F; - GL11.glRotatef(180.0F - renderManager.playerViewY, 0.0F, 1.0F, 0.0F); - GL11.glRotatef(-renderManager.playerViewX, 1.0F, 0.0F, 0.0F); - p_77026_1_.startDrawingQuads(); - p_77026_1_.setNormal(0.0F, 1.0F, 0.0F); - if(light != -1) - p_77026_1_.setBrightness(light); - p_77026_1_.addVertexWithUV(0.0F - f5, 0.0F - f6, 0.0D, f, f3); - p_77026_1_.addVertexWithUV(f4 - f5, 0.0F - f6, 0.0D, f1, f3); - p_77026_1_.addVertexWithUV(f4 - f5, f4 - f6, 0.0D, f1, f2); - p_77026_1_.addVertexWithUV(0.0F - f5, f4 - f6, 0.0D, f, f2); - p_77026_1_.draw(); - } + @Override + protected ResourceLocation getEntityTexture(Entity p_110775_1_) { + return TextureMap.locationItemsTexture; + } + private void func_77026_a(Tessellator p_77026_1_, IIcon p_77026_2_, int light) { + float f = p_77026_2_.getMinU(); + float f1 = p_77026_2_.getMaxU(); + float f2 = p_77026_2_.getMinV(); + float f3 = p_77026_2_.getMaxV(); + float f4 = 1.0F; + float f5 = 0.5F; + float f6 = 0.25F; + GL11.glRotatef(180.0F - renderManager.playerViewY, 0.0F, 1.0F, 0.0F); + GL11.glRotatef(-renderManager.playerViewX, 1.0F, 0.0F, 0.0F); + p_77026_1_.startDrawingQuads(); + p_77026_1_.setNormal(0.0F, 1.0F, 0.0F); + if (light != -1) p_77026_1_.setBrightness(light); + p_77026_1_.addVertexWithUV(0.0F - f5, 0.0F - f6, 0.0D, f, f3); + p_77026_1_.addVertexWithUV(f4 - f5, 0.0F - f6, 0.0D, f1, f3); + p_77026_1_.addVertexWithUV(f4 - f5, f4 - f6, 0.0D, f1, f2); + p_77026_1_.addVertexWithUV(0.0F - f5, f4 - f6, 0.0D, f, f2); + p_77026_1_.draw(); + } } diff --git a/src/main/java/vazkii/botania/client/render/item/RenderBow.java b/src/main/java/vazkii/botania/client/render/item/RenderBow.java index 8b22dc0daf..9d628bada5 100644 --- a/src/main/java/vazkii/botania/client/render/item/RenderBow.java +++ b/src/main/java/vazkii/botania/client/render/item/RenderBow.java @@ -2,93 +2,90 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Feb 28, 2015, 3:43:09 PM (GMT)] */ package vazkii.botania.client.render.item; +import cpw.mods.fml.relauncher.ReflectionHelper; import net.minecraft.client.renderer.ItemRenderer; import net.minecraft.client.renderer.Tessellator; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; import net.minecraft.util.IIcon; import net.minecraftforge.client.IItemRenderer; - import org.lwjgl.opengl.GL11; - import vazkii.botania.common.lib.LibObfuscation; -import cpw.mods.fml.relauncher.ReflectionHelper; public class RenderBow implements IItemRenderer { - @Override - public boolean handleRenderType(ItemStack item, ItemRenderType type) { - return type != ItemRenderType.INVENTORY; - } - - @Override - public boolean shouldUseRenderHelper(ItemRenderType type, ItemStack item, ItemRendererHelper helper) { - return helper == ItemRendererHelper.ENTITY_ROTATION || helper == ItemRendererHelper.ENTITY_BOBBING; - } - - @Override - public void renderItem(ItemRenderType type, ItemStack item, Object... data) { - switch(type) { - case ENTITY : { - GL11.glPushMatrix(); - GL11.glTranslatef(-0.5F, 0F, 0F); - if(item.isOnItemFrame()) - GL11.glTranslatef(0F, -0.3F, 0.01F); - render(item, null, false); - GL11.glPopMatrix(); - break; - } - case EQUIPPED : { - render(item, data[1] instanceof EntityPlayer ? (EntityPlayer) data[1] : null, true); - break; - } - case EQUIPPED_FIRST_PERSON : { - render(item, data[1] instanceof EntityPlayer ? (EntityPlayer) data[1] : null, false); - break; - } - default : break; - } - } + @Override + public boolean handleRenderType(ItemStack item, ItemRenderType type) { + return type != ItemRenderType.INVENTORY; + } - public void render(ItemStack item, EntityPlayer player, boolean transform) { - int dmg = item.getItemDamage(); - IIcon icon = item.getItem().getIconFromDamageForRenderPass(dmg, 0); - if(player != null) { - ItemStack using = ReflectionHelper.getPrivateValue(EntityPlayer.class, player, LibObfuscation.ITEM_IN_USE); - int time = ReflectionHelper.getPrivateValue(EntityPlayer.class, player, LibObfuscation.ITEM_IN_USE_COUNT); - icon = item.getItem().getIcon(item, 0, player, using, time); - if(transform) { - GL11.glTranslatef(0.2F, -0.3F, 0.1F); - //GL11.glRotatef(20.0F, 0.0F, 1.0F, 0.0F); - //GL11.glRotatef(-100.0F, 1.0F, 0.0F, 0.0F); - } - } + @Override + public boolean shouldUseRenderHelper(ItemRenderType type, ItemStack item, ItemRendererHelper helper) { + return helper == ItemRendererHelper.ENTITY_ROTATION || helper == ItemRendererHelper.ENTITY_BOBBING; + } - float f = icon.getMinU(); - float f1 = icon.getMaxU(); - float f2 = icon.getMinV(); - float f3 = icon.getMaxV(); - float scale = 1F / 16F; + @Override + public void renderItem(ItemRenderType type, ItemStack item, Object... data) { + switch (type) { + case ENTITY: { + GL11.glPushMatrix(); + GL11.glTranslatef(-0.5F, 0F, 0F); + if (item.isOnItemFrame()) GL11.glTranslatef(0F, -0.3F, 0.01F); + render(item, null, false); + GL11.glPopMatrix(); + break; + } + case EQUIPPED: { + render(item, data[1] instanceof EntityPlayer ? (EntityPlayer) data[1] : null, true); + break; + } + case EQUIPPED_FIRST_PERSON: { + render(item, data[1] instanceof EntityPlayer ? (EntityPlayer) data[1] : null, false); + break; + } + default: + break; + } + } - GL11.glPushMatrix(); - GL11.glEnable(GL11.GL_BLEND); - GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); - GL11.glColor4f(1F, 1F, 1F, 1F); - ItemRenderer.renderItemIn2D(Tessellator.instance, f1, f2, f, f3, icon.getIconWidth(), icon.getIconHeight(), scale); + public void render(ItemStack item, EntityPlayer player, boolean transform) { + int dmg = item.getItemDamage(); + IIcon icon = item.getItem().getIconFromDamageForRenderPass(dmg, 0); + if (player != null) { + ItemStack using = ReflectionHelper.getPrivateValue(EntityPlayer.class, player, LibObfuscation.ITEM_IN_USE); + int time = ReflectionHelper.getPrivateValue(EntityPlayer.class, player, LibObfuscation.ITEM_IN_USE_COUNT); + icon = item.getItem().getIcon(item, 0, player, using, time); + if (transform) { + GL11.glTranslatef(0.2F, -0.3F, 0.1F); + // GL11.glRotatef(20.0F, 0.0F, 1.0F, 0.0F); + // GL11.glRotatef(-100.0F, 1.0F, 0.0F, 0.0F); + } + } - GL11.glDisable(GL11.GL_BLEND); - GL11.glPopMatrix(); + float f = icon.getMinU(); + float f1 = icon.getMaxU(); + float f2 = icon.getMinV(); + float f3 = icon.getMaxV(); + float scale = 1F / 16F; - GL11.glColor4f(1F, 1F, 1F, 1F); - } + GL11.glPushMatrix(); + GL11.glEnable(GL11.GL_BLEND); + GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); + GL11.glColor4f(1F, 1F, 1F, 1F); + ItemRenderer.renderItemIn2D( + Tessellator.instance, f1, f2, f, f3, icon.getIconWidth(), icon.getIconHeight(), scale); + GL11.glDisable(GL11.GL_BLEND); + GL11.glPopMatrix(); + GL11.glColor4f(1F, 1F, 1F, 1F); + } } diff --git a/src/main/java/vazkii/botania/client/render/item/RenderFloatingFlowerItem.java b/src/main/java/vazkii/botania/client/render/item/RenderFloatingFlowerItem.java index 3f66ca3cba..26256bcd45 100644 --- a/src/main/java/vazkii/botania/client/render/item/RenderFloatingFlowerItem.java +++ b/src/main/java/vazkii/botania/client/render/item/RenderFloatingFlowerItem.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Nov 17, 2014, 5:48:34 PM (GMT)] */ package vazkii.botania.client.render.item; @@ -14,9 +14,7 @@ import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraftforge.client.IItemRenderer; - import org.lwjgl.opengl.GL11; - import vazkii.botania.common.block.ModBlocks; import vazkii.botania.common.block.tile.TileFloatingFlower; import vazkii.botania.common.item.block.ItemBlockFloatingSpecialFlower; @@ -24,31 +22,32 @@ public class RenderFloatingFlowerItem implements IItemRenderer { - @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 stack, Object... data) { - GL11.glPushMatrix(); - GL11.glTranslatef(-0.5F, -0.5F, -0.5F); - GL11.glEnable(GL11.GL_BLEND); - GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); - float s = 1.4F; - GL11.glScalef(s, s, s); - GL11.glRotatef(-5F, 1F, 0F, 0F); - Item item = stack.getItem(); - TileFloatingFlower.forcedStack = item instanceof ItemBlockFloatingSpecialFlower ? ItemBlockSpecialFlower.ofType(ItemBlockSpecialFlower.getType(stack)) : new ItemStack(ModBlocks.flower, 1, stack.getItemDamage()); - - TileEntityRendererDispatcher.instance.renderTileEntityAt(new TileFloatingFlower(), 0.0D, 0.0D, 0.0D, 0.0F); - GL11.glDisable(GL11.GL_BLEND); - GL11.glPopMatrix(); - } - + @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 stack, Object... data) { + GL11.glPushMatrix(); + GL11.glTranslatef(-0.5F, -0.5F, -0.5F); + GL11.glEnable(GL11.GL_BLEND); + GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); + float s = 1.4F; + GL11.glScalef(s, s, s); + GL11.glRotatef(-5F, 1F, 0F, 0F); + Item item = stack.getItem(); + TileFloatingFlower.forcedStack = item instanceof ItemBlockFloatingSpecialFlower + ? ItemBlockSpecialFlower.ofType(ItemBlockSpecialFlower.getType(stack)) + : new ItemStack(ModBlocks.flower, 1, stack.getItemDamage()); + + TileEntityRendererDispatcher.instance.renderTileEntityAt(new TileFloatingFlower(), 0.0D, 0.0D, 0.0D, 0.0F); + GL11.glDisable(GL11.GL_BLEND); + GL11.glPopMatrix(); + } } diff --git a/src/main/java/vazkii/botania/client/render/item/RenderLens.java b/src/main/java/vazkii/botania/client/render/item/RenderLens.java index a3b71c2f4d..1cfb9c2476 100644 --- a/src/main/java/vazkii/botania/client/render/item/RenderLens.java +++ b/src/main/java/vazkii/botania/client/render/item/RenderLens.java @@ -2,16 +2,15 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jan 31, 2014, 3:08:00 PM (GMT)] */ package vazkii.botania.client.render.item; import java.awt.Color; - import net.minecraft.client.Minecraft; import net.minecraft.client.renderer.ItemRenderer; import net.minecraft.client.renderer.Tessellator; @@ -19,105 +18,102 @@ import net.minecraft.item.ItemStack; import net.minecraft.util.IIcon; import net.minecraftforge.client.IItemRenderer; - import org.lwjgl.opengl.GL11; - import vazkii.botania.api.mana.ILens; import vazkii.botania.common.item.lens.ItemLens; public class RenderLens implements IItemRenderer { - static RenderItem render = new RenderItem(); - ItemRenderer renderer = new ItemRenderer(Minecraft.getMinecraft()); - - @Override - public boolean handleRenderType(ItemStack item, ItemRenderType type) { - return type != ItemRenderType.INVENTORY; - } - - @Override - public boolean shouldUseRenderHelper(ItemRenderType type, ItemStack item, ItemRendererHelper helper) { - return helper == ItemRendererHelper.ENTITY_ROTATION || helper == ItemRendererHelper.ENTITY_BOBBING; - } - - @Override - public void renderItem(ItemRenderType type, ItemStack item, Object... data) { - switch(type) { - case ENTITY : { - GL11.glPushMatrix(); - GL11.glTranslatef(-0.5F, 0F, 0F); - if(item.isOnItemFrame()) - GL11.glTranslatef(0F, -0.3F, 0.01F); - render(item); - GL11.glPopMatrix(); - break; - } - case EQUIPPED : { - render(item); - break; - } - case EQUIPPED_FIRST_PERSON : { - render(item); - break; - } - default : break; - } - } - - public static void render(ItemStack item) { - Color color = new Color(((ILens) item.getItem()).getLensColor(item)); - render(item, color.getRGB()); - } - - public static void render(ItemStack item, int color_) { - int dmg = item.getItemDamage(); - IIcon icon = item.getItem().getIconFromDamageForRenderPass(dmg, 1); - float f = icon.getMinU(); - float f1 = icon.getMaxU(); - float f2 = icon.getMinV(); - float f3 = icon.getMaxV(); - float scale = 1F / 16F; - - GL11.glColor4f(1F, 1F, 1F, 1F); - ItemRenderer.renderItemIn2D(Tessellator.instance, f1, f2, f, f3, icon.getIconWidth(), icon.getIconHeight(), scale); - - GL11.glPushMatrix(); - GL11.glEnable(GL11.GL_BLEND); - GL11.glEnable(GL11.GL_CULL_FACE); - GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); - Color color = new Color(color_); - GL11.glColor4ub((byte) color.getRed(), (byte) color.getGreen(), (byte) color.getBlue(), (byte) 255); - - boolean shiny = ItemLens.getStoredColor(item) != -1; - icon = ItemLens.iconGlass; - GL11.glScalef(scale, scale, scale); - GL11.glTranslatef(0F, 0F, -0.5F); - renderShinyLensIcon(icon, shiny); - GL11.glRotatef(180F, 0F, 1F, 0F); - GL11.glTranslatef(-16F, 0F, 0F); - renderShinyLensIcon(icon, shiny); - GL11.glDisable(GL11.GL_CULL_FACE); - GL11.glDisable(GL11.GL_BLEND); - GL11.glPopMatrix(); - - GL11.glColor4f(1F, 1F, 1F, 1F); - } - - public static void renderShinyLensIcon(IIcon icon, boolean shiny) { - float par1 = 0; - float par2 = 0; - float par4 = 16; - float par5 = 16; - float zLevel = 0F; - Tessellator tessellator = Tessellator.instance; - tessellator.startDrawingQuads(); - if(shiny) - tessellator.setBrightness(240); - tessellator.addVertexWithUV(par1 + 0, par2 + par5, zLevel, icon.getMinU(), icon.getMaxV()); - tessellator.addVertexWithUV(par1 + par4, par2 + par5, zLevel, icon.getMaxU(), icon.getMaxV()); - tessellator.addVertexWithUV(par1 + par4, par2 + 0, zLevel, icon.getMaxU(), icon.getMinV()); - tessellator.addVertexWithUV(par1 + 0, par2 + 0, zLevel, icon.getMinU(), icon.getMinV()); - tessellator.draw(); - } - -} \ No newline at end of file + static RenderItem render = new RenderItem(); + ItemRenderer renderer = new ItemRenderer(Minecraft.getMinecraft()); + + @Override + public boolean handleRenderType(ItemStack item, ItemRenderType type) { + return type != ItemRenderType.INVENTORY; + } + + @Override + public boolean shouldUseRenderHelper(ItemRenderType type, ItemStack item, ItemRendererHelper helper) { + return helper == ItemRendererHelper.ENTITY_ROTATION || helper == ItemRendererHelper.ENTITY_BOBBING; + } + + @Override + public void renderItem(ItemRenderType type, ItemStack item, Object... data) { + switch (type) { + case ENTITY: { + GL11.glPushMatrix(); + GL11.glTranslatef(-0.5F, 0F, 0F); + if (item.isOnItemFrame()) GL11.glTranslatef(0F, -0.3F, 0.01F); + render(item); + GL11.glPopMatrix(); + break; + } + case EQUIPPED: { + render(item); + break; + } + case EQUIPPED_FIRST_PERSON: { + render(item); + break; + } + default: + break; + } + } + + public static void render(ItemStack item) { + Color color = new Color(((ILens) item.getItem()).getLensColor(item)); + render(item, color.getRGB()); + } + + public static void render(ItemStack item, int color_) { + int dmg = item.getItemDamage(); + IIcon icon = item.getItem().getIconFromDamageForRenderPass(dmg, 1); + float f = icon.getMinU(); + float f1 = icon.getMaxU(); + float f2 = icon.getMinV(); + float f3 = icon.getMaxV(); + float scale = 1F / 16F; + + GL11.glColor4f(1F, 1F, 1F, 1F); + ItemRenderer.renderItemIn2D( + Tessellator.instance, f1, f2, f, f3, icon.getIconWidth(), icon.getIconHeight(), scale); + + GL11.glPushMatrix(); + GL11.glEnable(GL11.GL_BLEND); + GL11.glEnable(GL11.GL_CULL_FACE); + GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); + Color color = new Color(color_); + GL11.glColor4ub((byte) color.getRed(), (byte) color.getGreen(), (byte) color.getBlue(), (byte) 255); + + boolean shiny = ItemLens.getStoredColor(item) != -1; + icon = ItemLens.iconGlass; + GL11.glScalef(scale, scale, scale); + GL11.glTranslatef(0F, 0F, -0.5F); + renderShinyLensIcon(icon, shiny); + GL11.glRotatef(180F, 0F, 1F, 0F); + GL11.glTranslatef(-16F, 0F, 0F); + renderShinyLensIcon(icon, shiny); + GL11.glDisable(GL11.GL_CULL_FACE); + GL11.glDisable(GL11.GL_BLEND); + GL11.glPopMatrix(); + + GL11.glColor4f(1F, 1F, 1F, 1F); + } + + public static void renderShinyLensIcon(IIcon icon, boolean shiny) { + float par1 = 0; + float par2 = 0; + float par4 = 16; + float par5 = 16; + float zLevel = 0F; + Tessellator tessellator = Tessellator.instance; + tessellator.startDrawingQuads(); + if (shiny) tessellator.setBrightness(240); + tessellator.addVertexWithUV(par1 + 0, par2 + par5, zLevel, icon.getMinU(), icon.getMaxV()); + tessellator.addVertexWithUV(par1 + par4, par2 + par5, zLevel, icon.getMaxU(), icon.getMaxV()); + tessellator.addVertexWithUV(par1 + par4, par2 + 0, zLevel, icon.getMaxU(), icon.getMinV()); + tessellator.addVertexWithUV(par1 + 0, par2 + 0, zLevel, icon.getMinU(), icon.getMinV()); + tessellator.draw(); + } +} diff --git a/src/main/java/vazkii/botania/client/render/item/RenderLexicon.java b/src/main/java/vazkii/botania/client/render/item/RenderLexicon.java index 694325ae33..23cde5ae70 100644 --- a/src/main/java/vazkii/botania/client/render/item/RenderLexicon.java +++ b/src/main/java/vazkii/botania/client/render/item/RenderLexicon.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Mar 25, 2014, 8:49:01 PM (GMT)] */ package vazkii.botania.client.render.item; @@ -18,9 +18,7 @@ import net.minecraft.util.ResourceLocation; import net.minecraft.util.StatCollector; import net.minecraftforge.client.IItemRenderer; - import org.lwjgl.opengl.GL11; - import vazkii.botania.client.core.handler.ClientTickHandler; import vazkii.botania.client.gui.lexicon.GuiLexicon; import vazkii.botania.client.lib.LibResources; @@ -29,87 +27,99 @@ public class RenderLexicon implements IItemRenderer { - ModelBook model = new ModelBook(); - ResourceLocation texture = new ResourceLocation(LibResources.MODEL_LEXICA); - - @Override - public boolean handleRenderType(ItemStack item, ItemRenderType type) { - return type == ItemRenderType.EQUIPPED_FIRST_PERSON; - } - - @Override - public boolean shouldUseRenderHelper(ItemRenderType type, ItemStack item, ItemRendererHelper helper) { - return false; - } - - @Override - public void renderItem(ItemRenderType type, ItemStack item, Object... data) { - GL11.glPushMatrix(); - Minecraft mc = Minecraft.getMinecraft(); - mc.renderEngine.bindTexture(texture); - float opening = 0F; - float pageFlip = 0F; - - float ticks = ClientTickHandler.ticksWithLexicaOpen; - if(ticks > 0 && ticks < 10) { - if(mc.currentScreen instanceof GuiLexicon) - ticks += ClientTickHandler.partialTicks; - else ticks -= ClientTickHandler.partialTicks; - } - - GL11.glTranslatef(0.3F + 0.02F * ticks, 0.475F + 0.01F * ticks, -0.2F - 0.01F * ticks); - GL11.glRotatef(87.5F + ticks * 5, 0F, 1F, 0F); - GL11.glRotatef(ticks * 2.5F, 0F, 0F, 1F); - GL11.glScalef(0.9F, 0.9F, 0.9F); - opening = ticks / 12F; - - float pageFlipTicks = ClientTickHandler.pageFlipTicks; - if(pageFlipTicks > 0) - pageFlipTicks -= ClientTickHandler.partialTicks; - - pageFlip = pageFlipTicks / 5F; - - model.render(null, 0F, 0F, pageFlip, opening, 0F, 1F / 16F); - if(ticks < 3) { - FontRenderer font = Minecraft.getMinecraft().fontRenderer; - GL11.glRotatef(180F, 0F, 0F, 1F); - GL11.glTranslatef(-0.3F, -0.21F, -0.07F); - GL11.glScalef(0.0035F, 0.0035F, -0.0035F); - boolean bevo = Minecraft.getMinecraft().thePlayer.getCommandSenderName().equalsIgnoreCase("BevoLJ"); - boolean saice = Minecraft.getMinecraft().thePlayer.getCommandSenderName().equalsIgnoreCase("saice"); - - String title = ModItems.lexicon.getItemStackDisplayName(null); - String origTitle = title; - - if(Minecraft.getMinecraft().thePlayer.getCurrentEquippedItem() != null) - title = Minecraft.getMinecraft().thePlayer.getCurrentEquippedItem().getDisplayName(); - if(title.equals(origTitle) && bevo) - title = StatCollector.translateToLocal("item.botania:lexicon.bevo"); - if(title.equals(origTitle) && saice) - title = StatCollector.translateToLocal("item.botania:lexicon.saice"); - - font.drawString(font.trimStringToWidth(title, 80), 0, 0, 0xD69700); - GL11.glTranslatef(0F, 10F, 0F); - GL11.glScalef(0.6F, 0.6F, 0.6F); - font.drawString(EnumChatFormatting.ITALIC + "" + EnumChatFormatting.BOLD + String.format(StatCollector.translateToLocal("botaniamisc.edition"), ItemLexicon.getEdition()), 0, 0, 0xA07100); - - GL11.glTranslatef(0F, 15F, 0F); - font.drawString(StatCollector.translateToLocal("botaniamisc.lexiconcover0"), 0, 0, 0x79ff92); - - GL11.glTranslatef(0F, 10F, 0F); - font.drawString(StatCollector.translateToLocal("botaniamisc.lexiconcover1"), 0, 0, 0x79ff92); - - GL11.glTranslatef(0F, 50F, 0F); - font.drawString(StatCollector.translateToLocal("botaniamisc.lexiconcover2"), 0, 0, 0x79ff92); - GL11.glTranslatef(0F, 10F, 0F); - font.drawString(EnumChatFormatting.UNDERLINE + "" + EnumChatFormatting.ITALIC + StatCollector.translateToLocal("botaniamisc.lexiconcover3"), 0, 0, 0x79ff92); - if(bevo || saice) { - GL11.glTranslatef(0F, 10F, 0F); - font.drawString(StatCollector.translateToLocal("botaniamisc.lexiconcover" + (bevo ? 4 : 5)), 0, 0, 0x79ff92); - } - } - - GL11.glPopMatrix(); - } - + ModelBook model = new ModelBook(); + ResourceLocation texture = new ResourceLocation(LibResources.MODEL_LEXICA); + + @Override + public boolean handleRenderType(ItemStack item, ItemRenderType type) { + return type == ItemRenderType.EQUIPPED_FIRST_PERSON; + } + + @Override + public boolean shouldUseRenderHelper(ItemRenderType type, ItemStack item, ItemRendererHelper helper) { + return false; + } + + @Override + public void renderItem(ItemRenderType type, ItemStack item, Object... data) { + GL11.glPushMatrix(); + Minecraft mc = Minecraft.getMinecraft(); + mc.renderEngine.bindTexture(texture); + float opening = 0F; + float pageFlip = 0F; + + float ticks = ClientTickHandler.ticksWithLexicaOpen; + if (ticks > 0 && ticks < 10) { + if (mc.currentScreen instanceof GuiLexicon) ticks += ClientTickHandler.partialTicks; + else ticks -= ClientTickHandler.partialTicks; + } + + GL11.glTranslatef(0.3F + 0.02F * ticks, 0.475F + 0.01F * ticks, -0.2F - 0.01F * ticks); + GL11.glRotatef(87.5F + ticks * 5, 0F, 1F, 0F); + GL11.glRotatef(ticks * 2.5F, 0F, 0F, 1F); + GL11.glScalef(0.9F, 0.9F, 0.9F); + opening = ticks / 12F; + + float pageFlipTicks = ClientTickHandler.pageFlipTicks; + if (pageFlipTicks > 0) pageFlipTicks -= ClientTickHandler.partialTicks; + + pageFlip = pageFlipTicks / 5F; + + model.render(null, 0F, 0F, pageFlip, opening, 0F, 1F / 16F); + if (ticks < 3) { + FontRenderer font = Minecraft.getMinecraft().fontRenderer; + GL11.glRotatef(180F, 0F, 0F, 1F); + GL11.glTranslatef(-0.3F, -0.21F, -0.07F); + GL11.glScalef(0.0035F, 0.0035F, -0.0035F); + boolean bevo = + Minecraft.getMinecraft().thePlayer.getCommandSenderName().equalsIgnoreCase("BevoLJ"); + boolean saice = + Minecraft.getMinecraft().thePlayer.getCommandSenderName().equalsIgnoreCase("saice"); + + String title = ModItems.lexicon.getItemStackDisplayName(null); + String origTitle = title; + + if (Minecraft.getMinecraft().thePlayer.getCurrentEquippedItem() != null) + title = Minecraft.getMinecraft() + .thePlayer + .getCurrentEquippedItem() + .getDisplayName(); + if (title.equals(origTitle) && bevo) title = StatCollector.translateToLocal("item.botania:lexicon.bevo"); + if (title.equals(origTitle) && saice) title = StatCollector.translateToLocal("item.botania:lexicon.saice"); + + font.drawString(font.trimStringToWidth(title, 80), 0, 0, 0xD69700); + GL11.glTranslatef(0F, 10F, 0F); + GL11.glScalef(0.6F, 0.6F, 0.6F); + font.drawString( + EnumChatFormatting.ITALIC + "" + EnumChatFormatting.BOLD + + String.format( + StatCollector.translateToLocal("botaniamisc.edition"), ItemLexicon.getEdition()), + 0, + 0, + 0xA07100); + + GL11.glTranslatef(0F, 15F, 0F); + font.drawString(StatCollector.translateToLocal("botaniamisc.lexiconcover0"), 0, 0, 0x79ff92); + + GL11.glTranslatef(0F, 10F, 0F); + font.drawString(StatCollector.translateToLocal("botaniamisc.lexiconcover1"), 0, 0, 0x79ff92); + + GL11.glTranslatef(0F, 50F, 0F); + font.drawString(StatCollector.translateToLocal("botaniamisc.lexiconcover2"), 0, 0, 0x79ff92); + GL11.glTranslatef(0F, 10F, 0F); + font.drawString( + EnumChatFormatting.UNDERLINE + "" + EnumChatFormatting.ITALIC + + StatCollector.translateToLocal("botaniamisc.lexiconcover3"), + 0, + 0, + 0x79ff92); + if (bevo || saice) { + GL11.glTranslatef(0F, 10F, 0F); + font.drawString( + StatCollector.translateToLocal("botaniamisc.lexiconcover" + (bevo ? 4 : 5)), 0, 0, 0x79ff92); + } + } + + GL11.glPopMatrix(); + } } diff --git a/src/main/java/vazkii/botania/client/render/item/RenderTransparentItem.java b/src/main/java/vazkii/botania/client/render/item/RenderTransparentItem.java index 72b6bc1275..875103512f 100644 --- a/src/main/java/vazkii/botania/client/render/item/RenderTransparentItem.java +++ b/src/main/java/vazkii/botania/client/render/item/RenderTransparentItem.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Aug 6, 2014, 10:04:57 PM (GMT)] */ package vazkii.botania.client.render.item; @@ -15,65 +15,63 @@ import net.minecraft.item.ItemStack; import net.minecraft.util.IIcon; import net.minecraftforge.client.IItemRenderer; - import org.lwjgl.opengl.GL11; public class RenderTransparentItem implements IItemRenderer { - @Override - public boolean handleRenderType(ItemStack item, ItemRenderType type) { - return type != ItemRenderType.INVENTORY; - } - - @Override - public boolean shouldUseRenderHelper(ItemRenderType type, ItemStack item, ItemRendererHelper helper) { - return helper == ItemRendererHelper.ENTITY_ROTATION || helper == ItemRendererHelper.ENTITY_BOBBING; - } - - @Override - public void renderItem(ItemRenderType type, ItemStack item, Object... data) { - switch(type) { - case ENTITY : { - GL11.glPushMatrix(); - GL11.glTranslatef(-0.5F, 0F, 0F); - if(item.isOnItemFrame()) - GL11.glTranslatef(0F, -0.3F, 0.01F); - render(item); - GL11.glPopMatrix(); - break; - } - case EQUIPPED : { - render(item); - break; - } - case EQUIPPED_FIRST_PERSON : { - render(item); - break; - } - default : break; - } - } + @Override + public boolean handleRenderType(ItemStack item, ItemRenderType type) { + return type != ItemRenderType.INVENTORY; + } - public void render(ItemStack item) { - int dmg = item.getItemDamage(); - IIcon icon = item.getItem().getIconFromDamageForRenderPass(dmg, 0); - float f = icon.getMinU(); - float f1 = icon.getMaxU(); - float f2 = icon.getMinV(); - float f3 = icon.getMaxV(); - float scale = 1F / 16F; + @Override + public boolean shouldUseRenderHelper(ItemRenderType type, ItemStack item, ItemRendererHelper helper) { + return helper == ItemRendererHelper.ENTITY_ROTATION || helper == ItemRendererHelper.ENTITY_BOBBING; + } - GL11.glPushMatrix(); - GL11.glEnable(GL11.GL_BLEND); - GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); - GL11.glColor4f(1F, 1F, 1F, 1F); - ItemRenderer.renderItemIn2D(Tessellator.instance, f1, f2, f, f3, icon.getIconWidth(), icon.getIconHeight(), scale); + @Override + public void renderItem(ItemRenderType type, ItemStack item, Object... data) { + switch (type) { + case ENTITY: { + GL11.glPushMatrix(); + GL11.glTranslatef(-0.5F, 0F, 0F); + if (item.isOnItemFrame()) GL11.glTranslatef(0F, -0.3F, 0.01F); + render(item); + GL11.glPopMatrix(); + break; + } + case EQUIPPED: { + render(item); + break; + } + case EQUIPPED_FIRST_PERSON: { + render(item); + break; + } + default: + break; + } + } - GL11.glDisable(GL11.GL_BLEND); - GL11.glPopMatrix(); + public void render(ItemStack item) { + int dmg = item.getItemDamage(); + IIcon icon = item.getItem().getIconFromDamageForRenderPass(dmg, 0); + float f = icon.getMinU(); + float f1 = icon.getMaxU(); + float f2 = icon.getMinV(); + float f3 = icon.getMaxV(); + float scale = 1F / 16F; - GL11.glColor4f(1F, 1F, 1F, 1F); - } + GL11.glPushMatrix(); + GL11.glEnable(GL11.GL_BLEND); + GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); + GL11.glColor4f(1F, 1F, 1F, 1F); + ItemRenderer.renderItemIn2D( + Tessellator.instance, f1, f2, f, f3, icon.getIconWidth(), icon.getIconHeight(), scale); + GL11.glDisable(GL11.GL_BLEND); + GL11.glPopMatrix(); + GL11.glColor4f(1F, 1F, 1F, 1F); + } } diff --git a/src/main/java/vazkii/botania/client/render/tile/RenderTileAlfPortal.java b/src/main/java/vazkii/botania/client/render/tile/RenderTileAlfPortal.java index 65b77c1e1d..1481895212 100644 --- a/src/main/java/vazkii/botania/client/render/tile/RenderTileAlfPortal.java +++ b/src/main/java/vazkii/botania/client/render/tile/RenderTileAlfPortal.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jun 9, 2014, 9:55:07 PM (GMT)] */ package vazkii.botania.client.render.tile; @@ -16,66 +16,64 @@ import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.IIcon; - import org.lwjgl.opengl.GL11; - import vazkii.botania.client.core.handler.ClientTickHandler; import vazkii.botania.common.block.BlockAlfPortal; import vazkii.botania.common.block.tile.TileAlfPortal; public class RenderTileAlfPortal extends TileEntitySpecialRenderer { - @Override - public void renderTileEntityAt(TileEntity tileentity, double d0, double d1, double d2, float f) { - TileAlfPortal portal = (TileAlfPortal) tileentity; - int meta = portal.getBlockMetadata(); - if(meta == 0) - return; - - GL11.glPushMatrix(); - GL11.glTranslated(d0, d1, d2); - GL11.glTranslatef(-1F, 1F, 0.25F); + @Override + public void renderTileEntityAt(TileEntity tileentity, double d0, double d1, double d2, float f) { + TileAlfPortal portal = (TileAlfPortal) tileentity; + int meta = portal.getBlockMetadata(); + if (meta == 0) return; - GL11.glEnable(GL11.GL_BLEND); - GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); - GL11.glColor4f(1F, 1F, 1F, 1F); - GL11.glDisable(GL11.GL_ALPHA_TEST); - GL11.glEnable(GL11.GL_CULL_FACE); - float alpha = (float) Math.min(1F, (Math.sin((ClientTickHandler.ticksInGame + f) / 8D) + 1D) / 7D + 0.6D) * (Math.min(60, portal.ticksOpen) / 60F) * 0.5F; - GL11.glColor4f(1F, 1F, 1F, alpha); + GL11.glPushMatrix(); + GL11.glTranslated(d0, d1, d2); + GL11.glTranslatef(-1F, 1F, 0.25F); - Minecraft.getMinecraft().renderEngine.bindTexture(TextureMap.locationBlocksTexture); + GL11.glEnable(GL11.GL_BLEND); + GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); + GL11.glColor4f(1F, 1F, 1F, 1F); + GL11.glDisable(GL11.GL_ALPHA_TEST); + GL11.glEnable(GL11.GL_CULL_FACE); + float alpha = (float) Math.min(1F, (Math.sin((ClientTickHandler.ticksInGame + f) / 8D) + 1D) / 7D + 0.6D) + * (Math.min(60, portal.ticksOpen) / 60F) + * 0.5F; + GL11.glColor4f(1F, 1F, 1F, alpha); - if(meta == 2) { - GL11.glTranslatef(1.25F, 0F, 1.75F); - GL11.glRotatef(90F, 0F, 1F, 0F); - } + Minecraft.getMinecraft().renderEngine.bindTexture(TextureMap.locationBlocksTexture); - GL11.glDisable(GL11.GL_CULL_FACE); - GL11.glDisable(GL11.GL_LIGHTING); - renderIcon(0, 0, BlockAlfPortal.portalTex, 3, 3, 240); + if (meta == 2) { + GL11.glTranslatef(1.25F, 0F, 1.75F); + GL11.glRotatef(90F, 0F, 1F, 0F); + } - GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); - GL11.glTranslated(0F, 0F, 0.5F); - renderIcon(0, 0, BlockAlfPortal.portalTex, 3, 3, 240); + GL11.glDisable(GL11.GL_CULL_FACE); + GL11.glDisable(GL11.GL_LIGHTING); + renderIcon(0, 0, BlockAlfPortal.portalTex, 3, 3, 240); - GL11.glEnable(GL11.GL_CULL_FACE); - GL11.glEnable(GL11.GL_ALPHA_TEST); - GL11.glDisable(GL11.GL_BLEND); - GL11.glEnable(GL11.GL_LIGHTING); - GL11.glColor4f(1F, 1F, 1F, 1F); - GL11.glPopMatrix(); - } + GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); + GL11.glTranslated(0F, 0F, 0.5F); + renderIcon(0, 0, BlockAlfPortal.portalTex, 3, 3, 240); - public void renderIcon(int par1, int par2, IIcon par3Icon, int par4, int par5, int brightness) { - Tessellator tessellator = Tessellator.instance; - tessellator.startDrawingQuads(); - tessellator.setBrightness(brightness); - tessellator.addVertexWithUV(par1 + 0, par2 + par5, 0, par3Icon.getMinU(), par3Icon.getMaxV()); - tessellator.addVertexWithUV(par1 + par4, par2 + par5, 0, par3Icon.getMaxU(), par3Icon.getMaxV()); - tessellator.addVertexWithUV(par1 + par4, par2 + 0, 0, par3Icon.getMaxU(), par3Icon.getMinV()); - tessellator.addVertexWithUV(par1 + 0, par2 + 0, 0, par3Icon.getMinU(), par3Icon.getMinV()); - tessellator.draw(); - } + GL11.glEnable(GL11.GL_CULL_FACE); + GL11.glEnable(GL11.GL_ALPHA_TEST); + GL11.glDisable(GL11.GL_BLEND); + GL11.glEnable(GL11.GL_LIGHTING); + GL11.glColor4f(1F, 1F, 1F, 1F); + GL11.glPopMatrix(); + } + public void renderIcon(int par1, int par2, IIcon par3Icon, int par4, int par5, int brightness) { + Tessellator tessellator = Tessellator.instance; + tessellator.startDrawingQuads(); + tessellator.setBrightness(brightness); + tessellator.addVertexWithUV(par1 + 0, par2 + par5, 0, par3Icon.getMinU(), par3Icon.getMaxV()); + tessellator.addVertexWithUV(par1 + par4, par2 + par5, 0, par3Icon.getMaxU(), par3Icon.getMaxV()); + tessellator.addVertexWithUV(par1 + par4, par2 + 0, 0, par3Icon.getMaxU(), par3Icon.getMinV()); + tessellator.addVertexWithUV(par1 + 0, par2 + 0, 0, par3Icon.getMinU(), par3Icon.getMinV()); + tessellator.draw(); + } } diff --git a/src/main/java/vazkii/botania/client/render/tile/RenderTileAltar.java b/src/main/java/vazkii/botania/client/render/tile/RenderTileAltar.java index 3ce7df9a0b..1be031b19b 100644 --- a/src/main/java/vazkii/botania/client/render/tile/RenderTileAltar.java +++ b/src/main/java/vazkii/botania/client/render/tile/RenderTileAltar.java @@ -2,16 +2,15 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jan 21, 2014, 7:55:47 PM (GMT)] */ package vazkii.botania.client.render.tile; import java.awt.Color; - import net.minecraft.block.Block; import net.minecraft.client.Minecraft; import net.minecraft.client.renderer.ItemRenderer; @@ -26,10 +25,8 @@ import net.minecraft.tileentity.TileEntity; import net.minecraft.util.IIcon; import net.minecraft.util.ResourceLocation; - import org.lwjgl.opengl.GL11; import org.lwjgl.opengl.GL12; - import vazkii.botania.client.core.handler.ClientTickHandler; import vazkii.botania.client.lib.LibResources; import vazkii.botania.client.model.ModelAltar; @@ -37,159 +34,176 @@ public class RenderTileAltar extends TileEntitySpecialRenderer { - private static final ResourceLocation[] textures = new ResourceLocation[] { - new ResourceLocation(LibResources.MODEL_ALTAR), - new ResourceLocation(String.format(LibResources.MODEL_ALTAR_META, 0)), - new ResourceLocation(String.format(LibResources.MODEL_ALTAR_META, 1)), - new ResourceLocation(String.format(LibResources.MODEL_ALTAR_META, 2)), - new ResourceLocation(String.format(LibResources.MODEL_ALTAR_META, 3)), - new ResourceLocation(String.format(LibResources.MODEL_ALTAR_META, 4)), - new ResourceLocation(String.format(LibResources.MODEL_ALTAR_META, 5)), - new ResourceLocation(String.format(LibResources.MODEL_ALTAR_META, 6)), - new ResourceLocation(String.format(LibResources.MODEL_ALTAR_META, 7)) - }; - - private static final ResourceLocation textureMossy = new ResourceLocation(LibResources.MODEL_ALTAR_MOSSY); - - ModelAltar model = new ModelAltar(); - RenderItem renderItem = new RenderItem(); - RenderBlocks renderBlocks = new RenderBlocks(); - public static int forceMeta = -1; - - @Override - public void renderTileEntityAt(TileEntity tileentity, double d0, double d1, double d2, float pticks) { - TileAltar altar = (TileAltar) tileentity; - - GL11.glPushMatrix(); - GL11.glEnable(GL12.GL_RESCALE_NORMAL); - GL11.glColor4f(1F, 1F, 1F, 1F); - Minecraft.getMinecraft().renderEngine.bindTexture(altar.isMossy ? textureMossy : textures[Math.min(textures.length - 1, forceMeta == -1 ? tileentity.getBlockMetadata() : forceMeta)]); - - GL11.glTranslated(d0 + 0.5, d1 + 1.5, d2 + 0.5); - GL11.glScalef(1F, -1F, -1F); - model.render(); - GL11.glScalef(1F, -1F, -1F); - GL11.glEnable(GL12.GL_RESCALE_NORMAL); - - boolean water = altar.hasWater(); - boolean lava = altar.hasLava(); - if(water || lava) { - GL11.glPushMatrix(); - float s = 1F / 256F * 10F; - float v = 1F / 8F; - float w = -v * 2.5F; - - if(water) { - int petals = 0; - for(int i = 0; i < altar.getSizeInventory(); i++) - if(altar.getStackInSlot(i) != null) - petals++; - else break; - - if(petals > 0) { - Minecraft minecraft = Minecraft.getMinecraft(); - final float modifier = 6F; - final float rotationModifier = 0.25F; - final float radiusBase = 1.2F; - final float radiusMod = 0.1F; - - double ticks = (ClientTickHandler.ticksInGame + pticks) * 0.5; - float offsetPerPetal = 360 / petals; - - GL11.glPushMatrix(); - GL11.glTranslatef(-0.05F, -0.5F, 0F); - GL11.glScalef(v, v, v); - for(int i = 0; i < petals; i++) { - float offset = offsetPerPetal * i; - float deg = (int) (ticks / rotationModifier % 360F + offset); - float rad = deg * (float) Math.PI / 180F; - float radiusX = (float) (radiusBase + radiusMod * Math.sin(ticks / modifier)); - float radiusZ = (float) (radiusBase + radiusMod * Math.cos(ticks / modifier)); - float x = (float) (radiusX * Math.cos(rad)); - float z = (float) (radiusZ * Math.sin(rad)); - float y = (float) Math.cos((ticks + 50 * i) / 5F) / 10F; - - GL11.glPushMatrix(); - GL11.glTranslatef(x, y, z); - float xRotate = (float) Math.sin(ticks * rotationModifier) / 2F; - float yRotate = (float) Math.max(0.6F, Math.sin(ticks * 0.1F) / 2F + 0.5F); - float zRotate = (float) Math.cos(ticks * rotationModifier) / 2F; - - v /= 2F; - GL11.glTranslatef(v, v, v); - GL11.glRotatef(deg, xRotate, yRotate, zRotate); - GL11.glTranslatef(-v, -v, -v); - v *= 2F; - - GL11.glColor4f(1F, 1F, 1F, 1F); - - ItemStack stack = altar.getStackInSlot(i); - minecraft.renderEngine.bindTexture(stack.getItem() instanceof ItemBlock ? TextureMap.locationBlocksTexture : TextureMap.locationItemsTexture); - - if(stack.getItem() instanceof ItemBlock && RenderBlocks.renderItemIn3d(Block.getBlockFromItem(stack.getItem()).getRenderType())) { - GL11.glScalef(0.5F, 0.5F, 0.5F); - GL11.glTranslatef(1F, 1.1F, 0F); - renderBlocks.renderBlockAsItem(Block.getBlockFromItem(stack.getItem()), stack.getItemDamage(), 1F); - GL11.glTranslatef(-1F, -1.1F, 0F); - GL11.glScalef(2F, 2F, 2F); - } else { - IIcon icon = stack.getItem().getIcon(stack, 0); - if (icon != null) { - Color color = new Color(stack.getItem().getColorFromItemStack(stack, 0)); - GL11.glColor3ub((byte) color.getRed(), (byte) color.getGreen(), (byte) color.getBlue()); - float f = icon.getMinU(); - float f1 = icon.getMaxU(); - float f2 = icon.getMinV(); - float f3 = icon.getMaxV(); - ItemRenderer.renderItemIn2D(Tessellator.instance, f1, f2, f, f3, icon.getIconWidth(), icon.getIconHeight(), 1F / 16F); - GL11.glColor3f(1F, 1F, 1F); - } - } - - GL11.glPopMatrix(); - } - - GL11.glPopMatrix(); - } - } - - Minecraft.getMinecraft().renderEngine.bindTexture(TextureMap.locationBlocksTexture); - Block block = lava ? Blocks.lava : Blocks.water; - int brightness = lava ? 240 : -1; - float alpha = lava ? 1F : 0.7F; - - GL11.glEnable(GL11.GL_BLEND); - GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); - GL11.glDisable(GL11.GL_ALPHA_TEST); - if(lava) - GL11.glDisable(GL11.GL_LIGHTING); - GL11.glColor4f(1F, 1F, 1F, alpha); - GL11.glTranslatef(w, -0.3F, w); - GL11.glRotatef(90F, 1F, 0F, 0F); - GL11.glScalef(s, s, s); - - renderIcon(0, 0, block.getIcon(0, 0), 16, 16, brightness); - if(lava) - GL11.glEnable(GL11.GL_LIGHTING); - GL11.glEnable(GL11.GL_ALPHA_TEST); - GL11.glDisable(GL11.GL_BLEND); - GL11.glPopMatrix(); - } - GL11.glPopMatrix(); - - forceMeta = -1; - } - - public void renderIcon(int par1, int par2, IIcon par3Icon, int par4, int par5, int brightness) { - Tessellator tessellator = Tessellator.instance; - tessellator.startDrawingQuads(); - if(brightness != -1) - tessellator.setBrightness(brightness); - tessellator.addVertexWithUV(par1 + 0, par2 + par5, 0, par3Icon.getMinU(), par3Icon.getMaxV()); - tessellator.addVertexWithUV(par1 + par4, par2 + par5, 0, par3Icon.getMaxU(), par3Icon.getMaxV()); - tessellator.addVertexWithUV(par1 + par4, par2 + 0, 0, par3Icon.getMaxU(), par3Icon.getMinV()); - tessellator.addVertexWithUV(par1 + 0, par2 + 0, 0, par3Icon.getMinU(), par3Icon.getMinV()); - tessellator.draw(); - } - + private static final ResourceLocation[] textures = new ResourceLocation[] { + new ResourceLocation(LibResources.MODEL_ALTAR), + new ResourceLocation(String.format(LibResources.MODEL_ALTAR_META, 0)), + new ResourceLocation(String.format(LibResources.MODEL_ALTAR_META, 1)), + new ResourceLocation(String.format(LibResources.MODEL_ALTAR_META, 2)), + new ResourceLocation(String.format(LibResources.MODEL_ALTAR_META, 3)), + new ResourceLocation(String.format(LibResources.MODEL_ALTAR_META, 4)), + new ResourceLocation(String.format(LibResources.MODEL_ALTAR_META, 5)), + new ResourceLocation(String.format(LibResources.MODEL_ALTAR_META, 6)), + new ResourceLocation(String.format(LibResources.MODEL_ALTAR_META, 7)) + }; + + private static final ResourceLocation textureMossy = new ResourceLocation(LibResources.MODEL_ALTAR_MOSSY); + + ModelAltar model = new ModelAltar(); + RenderItem renderItem = new RenderItem(); + RenderBlocks renderBlocks = new RenderBlocks(); + public static int forceMeta = -1; + + @Override + public void renderTileEntityAt(TileEntity tileentity, double d0, double d1, double d2, float pticks) { + TileAltar altar = (TileAltar) tileentity; + + GL11.glPushMatrix(); + GL11.glEnable(GL12.GL_RESCALE_NORMAL); + GL11.glColor4f(1F, 1F, 1F, 1F); + Minecraft.getMinecraft() + .renderEngine + .bindTexture( + altar.isMossy + ? textureMossy + : textures[ + Math.min( + textures.length - 1, + forceMeta == -1 ? tileentity.getBlockMetadata() : forceMeta)]); + + GL11.glTranslated(d0 + 0.5, d1 + 1.5, d2 + 0.5); + GL11.glScalef(1F, -1F, -1F); + model.render(); + GL11.glScalef(1F, -1F, -1F); + GL11.glEnable(GL12.GL_RESCALE_NORMAL); + + boolean water = altar.hasWater(); + boolean lava = altar.hasLava(); + if (water || lava) { + GL11.glPushMatrix(); + float s = 1F / 256F * 10F; + float v = 1F / 8F; + float w = -v * 2.5F; + + if (water) { + int petals = 0; + for (int i = 0; i < altar.getSizeInventory(); i++) + if (altar.getStackInSlot(i) != null) petals++; + else break; + + if (petals > 0) { + Minecraft minecraft = Minecraft.getMinecraft(); + final float modifier = 6F; + final float rotationModifier = 0.25F; + final float radiusBase = 1.2F; + final float radiusMod = 0.1F; + + double ticks = (ClientTickHandler.ticksInGame + pticks) * 0.5; + float offsetPerPetal = 360 / petals; + + GL11.glPushMatrix(); + GL11.glTranslatef(-0.05F, -0.5F, 0F); + GL11.glScalef(v, v, v); + for (int i = 0; i < petals; i++) { + float offset = offsetPerPetal * i; + float deg = (int) (ticks / rotationModifier % 360F + offset); + float rad = deg * (float) Math.PI / 180F; + float radiusX = (float) (radiusBase + radiusMod * Math.sin(ticks / modifier)); + float radiusZ = (float) (radiusBase + radiusMod * Math.cos(ticks / modifier)); + float x = (float) (radiusX * Math.cos(rad)); + float z = (float) (radiusZ * Math.sin(rad)); + float y = (float) Math.cos((ticks + 50 * i) / 5F) / 10F; + + GL11.glPushMatrix(); + GL11.glTranslatef(x, y, z); + float xRotate = (float) Math.sin(ticks * rotationModifier) / 2F; + float yRotate = (float) Math.max(0.6F, Math.sin(ticks * 0.1F) / 2F + 0.5F); + float zRotate = (float) Math.cos(ticks * rotationModifier) / 2F; + + v /= 2F; + GL11.glTranslatef(v, v, v); + GL11.glRotatef(deg, xRotate, yRotate, zRotate); + GL11.glTranslatef(-v, -v, -v); + v *= 2F; + + GL11.glColor4f(1F, 1F, 1F, 1F); + + ItemStack stack = altar.getStackInSlot(i); + minecraft.renderEngine.bindTexture( + stack.getItem() instanceof ItemBlock + ? TextureMap.locationBlocksTexture + : TextureMap.locationItemsTexture); + + if (stack.getItem() instanceof ItemBlock + && RenderBlocks.renderItemIn3d( + Block.getBlockFromItem(stack.getItem()).getRenderType())) { + GL11.glScalef(0.5F, 0.5F, 0.5F); + GL11.glTranslatef(1F, 1.1F, 0F); + renderBlocks.renderBlockAsItem( + Block.getBlockFromItem(stack.getItem()), stack.getItemDamage(), 1F); + GL11.glTranslatef(-1F, -1.1F, 0F); + GL11.glScalef(2F, 2F, 2F); + } else { + IIcon icon = stack.getItem().getIcon(stack, 0); + if (icon != null) { + Color color = new Color(stack.getItem().getColorFromItemStack(stack, 0)); + GL11.glColor3ub((byte) color.getRed(), (byte) color.getGreen(), (byte) color.getBlue()); + float f = icon.getMinU(); + float f1 = icon.getMaxU(); + float f2 = icon.getMinV(); + float f3 = icon.getMaxV(); + ItemRenderer.renderItemIn2D( + Tessellator.instance, + f1, + f2, + f, + f3, + icon.getIconWidth(), + icon.getIconHeight(), + 1F / 16F); + GL11.glColor3f(1F, 1F, 1F); + } + } + + GL11.glPopMatrix(); + } + + GL11.glPopMatrix(); + } + } + + Minecraft.getMinecraft().renderEngine.bindTexture(TextureMap.locationBlocksTexture); + Block block = lava ? Blocks.lava : Blocks.water; + int brightness = lava ? 240 : -1; + float alpha = lava ? 1F : 0.7F; + + GL11.glEnable(GL11.GL_BLEND); + GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); + GL11.glDisable(GL11.GL_ALPHA_TEST); + if (lava) GL11.glDisable(GL11.GL_LIGHTING); + GL11.glColor4f(1F, 1F, 1F, alpha); + GL11.glTranslatef(w, -0.3F, w); + GL11.glRotatef(90F, 1F, 0F, 0F); + GL11.glScalef(s, s, s); + + renderIcon(0, 0, block.getIcon(0, 0), 16, 16, brightness); + if (lava) GL11.glEnable(GL11.GL_LIGHTING); + GL11.glEnable(GL11.GL_ALPHA_TEST); + GL11.glDisable(GL11.GL_BLEND); + GL11.glPopMatrix(); + } + GL11.glPopMatrix(); + + forceMeta = -1; + } + + public void renderIcon(int par1, int par2, IIcon par3Icon, int par4, int par5, int brightness) { + Tessellator tessellator = Tessellator.instance; + tessellator.startDrawingQuads(); + if (brightness != -1) tessellator.setBrightness(brightness); + tessellator.addVertexWithUV(par1 + 0, par2 + par5, 0, par3Icon.getMinU(), par3Icon.getMaxV()); + tessellator.addVertexWithUV(par1 + par4, par2 + par5, 0, par3Icon.getMaxU(), par3Icon.getMaxV()); + tessellator.addVertexWithUV(par1 + par4, par2 + 0, 0, par3Icon.getMaxU(), par3Icon.getMinV()); + tessellator.addVertexWithUV(par1 + 0, par2 + 0, 0, par3Icon.getMinU(), par3Icon.getMinV()); + tessellator.draw(); + } } diff --git a/src/main/java/vazkii/botania/client/render/tile/RenderTileAvatar.java b/src/main/java/vazkii/botania/client/render/tile/RenderTileAvatar.java index 03dd328c68..fe039c15f9 100644 --- a/src/main/java/vazkii/botania/client/render/tile/RenderTileAvatar.java +++ b/src/main/java/vazkii/botania/client/render/tile/RenderTileAvatar.java @@ -2,16 +2,15 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Oct 24, 2015, 3:51:35 PM (GMT)] */ package vazkii.botania.client.render.tile; import java.awt.Color; - import net.minecraft.client.Minecraft; import net.minecraft.client.renderer.ItemRenderer; import net.minecraft.client.renderer.OpenGlHelper; @@ -22,10 +21,8 @@ import net.minecraft.tileentity.TileEntity; import net.minecraft.util.IIcon; import net.minecraft.util.ResourceLocation; - import org.lwjgl.opengl.GL11; import org.lwjgl.opengl.GL12; - import vazkii.botania.api.item.IAvatarWieldable; import vazkii.botania.client.core.handler.ClientTickHandler; import vazkii.botania.client.lib.LibResources; @@ -34,80 +31,78 @@ public class RenderTileAvatar extends TileEntitySpecialRenderer { - private static final float[] ROTATIONS = new float[] { - 180F, 0F, 90F, 270F - }; - - private static final ResourceLocation texture = new ResourceLocation(LibResources.MODEL_AVATAR); - private static final ModelAvatar model = new ModelAvatar(); - - @Override - public void renderTileEntityAt(TileEntity tileentity, double d0, double d1, double d2, float pticks) { - TileAvatar avatar = (TileAvatar) tileentity; - - GL11.glPushMatrix(); - GL11.glEnable(GL12.GL_RESCALE_NORMAL); - GL11.glColor4f(1F, 1F, 1F, 1F); - GL11.glTranslated(d0, d1, d2); - - Minecraft.getMinecraft().renderEngine.bindTexture(texture); - int meta = avatar.getWorldObj() != null ? avatar.getBlockMetadata() : 0; - - GL11.glTranslatef(0.5F, 1.6F, 0.5F); - GL11.glScalef(1F, -1F, -1F); - GL11.glRotatef(ROTATIONS[Math.max(Math.min(ROTATIONS.length - 1, meta - 2), 0)], 0F, 1F, 0F); - model.render(); - - ItemStack stack = avatar.getStackInSlot(0); - if(stack != null) { - GL11.glPushMatrix(); - Minecraft.getMinecraft().renderEngine.bindTexture(TextureMap.locationItemsTexture); - float s = 0.4F; - GL11.glScalef(s, s, s); - GL11.glRotatef(90F, 0F, 1F, 0F); - GL11.glRotatef(180F, 0F, 0F, 1F); - GL11.glTranslated(-1.2F, -3.5F, -0.65F); - GL11.glRotatef(20F, 0F, 0F, 1F); - - int renderPass = 0; - do { - IIcon icon = stack.getItem().getIcon(stack, renderPass); - if(icon != null) { - Color color = new Color(stack.getItem().getColorFromItemStack(stack, renderPass)); - GL11.glColor3ub((byte) color.getRed(), (byte) color.getGreen(), (byte) color.getBlue()); - float f = icon.getMinU(); - float f1 = icon.getMaxU(); - float f2 = icon.getMinV(); - float f3 = icon.getMaxV(); - ItemRenderer.renderItemIn2D(Tessellator.instance, f1, f2, f, f3, icon.getIconWidth(), icon.getIconHeight(), 1F / 16F); - GL11.glColor3f(1F, 1F, 1F); - } - renderPass++; - } while(renderPass < stack.getItem().getRenderPasses(stack.getItemDamage())); - GL11.glPopMatrix(); - - IAvatarWieldable wieldable = (IAvatarWieldable) stack.getItem(); - Minecraft.getMinecraft().renderEngine.bindTexture(wieldable.getOverlayResource(avatar, stack)); - s = 1.01F; - - GL11.glPushMatrix(); - GL11.glEnable(GL11.GL_BLEND); - GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); - GL11.glScalef(s, s, s); - GL11.glTranslatef(0F, -0.01F, 0F); - int light = 15728880; - int lightmapX = light % 65536; - int lightmapY = light / 65536; - OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, lightmapX, lightmapY); - float alpha = (float) Math.sin(ClientTickHandler.ticksInGame / 20D) / 2F + 0.5F; - GL11.glColor4f(1F, 1F, 1F, alpha + 0.183F); - model.render(); - GL11.glPopMatrix(); - } - GL11.glColor3f(1F, 1F, 1F); - GL11.glScalef(1F, -1F, -1F); - GL11.glEnable(GL12.GL_RESCALE_NORMAL); - GL11.glPopMatrix(); - } - + private static final float[] ROTATIONS = new float[] {180F, 0F, 90F, 270F}; + + private static final ResourceLocation texture = new ResourceLocation(LibResources.MODEL_AVATAR); + private static final ModelAvatar model = new ModelAvatar(); + + @Override + public void renderTileEntityAt(TileEntity tileentity, double d0, double d1, double d2, float pticks) { + TileAvatar avatar = (TileAvatar) tileentity; + + GL11.glPushMatrix(); + GL11.glEnable(GL12.GL_RESCALE_NORMAL); + GL11.glColor4f(1F, 1F, 1F, 1F); + GL11.glTranslated(d0, d1, d2); + + Minecraft.getMinecraft().renderEngine.bindTexture(texture); + int meta = avatar.getWorldObj() != null ? avatar.getBlockMetadata() : 0; + + GL11.glTranslatef(0.5F, 1.6F, 0.5F); + GL11.glScalef(1F, -1F, -1F); + GL11.glRotatef(ROTATIONS[Math.max(Math.min(ROTATIONS.length - 1, meta - 2), 0)], 0F, 1F, 0F); + model.render(); + + ItemStack stack = avatar.getStackInSlot(0); + if (stack != null) { + GL11.glPushMatrix(); + Minecraft.getMinecraft().renderEngine.bindTexture(TextureMap.locationItemsTexture); + float s = 0.4F; + GL11.glScalef(s, s, s); + GL11.glRotatef(90F, 0F, 1F, 0F); + GL11.glRotatef(180F, 0F, 0F, 1F); + GL11.glTranslated(-1.2F, -3.5F, -0.65F); + GL11.glRotatef(20F, 0F, 0F, 1F); + + int renderPass = 0; + do { + IIcon icon = stack.getItem().getIcon(stack, renderPass); + if (icon != null) { + Color color = new Color(stack.getItem().getColorFromItemStack(stack, renderPass)); + GL11.glColor3ub((byte) color.getRed(), (byte) color.getGreen(), (byte) color.getBlue()); + float f = icon.getMinU(); + float f1 = icon.getMaxU(); + float f2 = icon.getMinV(); + float f3 = icon.getMaxV(); + ItemRenderer.renderItemIn2D( + Tessellator.instance, f1, f2, f, f3, icon.getIconWidth(), icon.getIconHeight(), 1F / 16F); + GL11.glColor3f(1F, 1F, 1F); + } + renderPass++; + } while (renderPass < stack.getItem().getRenderPasses(stack.getItemDamage())); + GL11.glPopMatrix(); + + IAvatarWieldable wieldable = (IAvatarWieldable) stack.getItem(); + Minecraft.getMinecraft().renderEngine.bindTexture(wieldable.getOverlayResource(avatar, stack)); + s = 1.01F; + + GL11.glPushMatrix(); + GL11.glEnable(GL11.GL_BLEND); + GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); + GL11.glScalef(s, s, s); + GL11.glTranslatef(0F, -0.01F, 0F); + int light = 15728880; + int lightmapX = light % 65536; + int lightmapY = light / 65536; + OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, lightmapX, lightmapY); + float alpha = (float) Math.sin(ClientTickHandler.ticksInGame / 20D) / 2F + 0.5F; + GL11.glColor4f(1F, 1F, 1F, alpha + 0.183F); + model.render(); + GL11.glPopMatrix(); + } + GL11.glColor3f(1F, 1F, 1F); + GL11.glScalef(1F, -1F, -1F); + GL11.glEnable(GL12.GL_RESCALE_NORMAL); + GL11.glPopMatrix(); + } } diff --git a/src/main/java/vazkii/botania/client/render/tile/RenderTileBellows.java b/src/main/java/vazkii/botania/client/render/tile/RenderTileBellows.java index 77cd868061..7ec5f51e5e 100644 --- a/src/main/java/vazkii/botania/client/render/tile/RenderTileBellows.java +++ b/src/main/java/vazkii/botania/client/render/tile/RenderTileBellows.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Aug 28, 2015, 5:30:41 PM (GMT)] */ package vazkii.botania.client.render.tile; @@ -14,43 +14,38 @@ import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.ResourceLocation; - import org.lwjgl.opengl.GL11; import org.lwjgl.opengl.GL12; - import vazkii.botania.client.lib.LibResources; import vazkii.botania.client.model.ModelBellows; import vazkii.botania.common.block.tile.mana.TileBellows; public class RenderTileBellows extends TileEntitySpecialRenderer { - private static final float[] ROTATIONS = new float[] { - 180F, 0F, 90F, 270F - }; - - private static final ResourceLocation texture = new ResourceLocation(LibResources.MODEL_BELLOWS); - private static final ModelBellows model = new ModelBellows(); + private static final float[] ROTATIONS = new float[] {180F, 0F, 90F, 270F}; - @Override - public void renderTileEntityAt(TileEntity tileentity, double d0, double d1, double d2, float f) { - TileBellows bellows = (TileBellows) tileentity; + private static final ResourceLocation texture = new ResourceLocation(LibResources.MODEL_BELLOWS); + private static final ModelBellows model = new ModelBellows(); - GL11.glPushMatrix(); - GL11.glEnable(GL12.GL_RESCALE_NORMAL); - GL11.glColor4f(1F, 1F, 1F, 1F); - GL11.glTranslated(d0, d1, d2); + @Override + public void renderTileEntityAt(TileEntity tileentity, double d0, double d1, double d2, float f) { + TileBellows bellows = (TileBellows) tileentity; - Minecraft.getMinecraft().renderEngine.bindTexture(texture); - int meta = bellows.getWorldObj() != null ? bellows.getBlockMetadata() : 0; + GL11.glPushMatrix(); + GL11.glEnable(GL12.GL_RESCALE_NORMAL); + GL11.glColor4f(1F, 1F, 1F, 1F); + GL11.glTranslated(d0, d1, d2); - GL11.glTranslatef(0.5F, 1.5F, 0.5F); - GL11.glScalef(1F, -1F, -1F); - GL11.glRotatef(ROTATIONS[Math.max(Math.min(ROTATIONS.length, meta - 2), 0)], 0F, 1F, 0F); - model.render(Math.max(0.1F, 1F - (bellows.movePos + bellows.moving * f + 0.1F))); - GL11.glColor3f(1F, 1F, 1F); - GL11.glScalef(1F, -1F, -1F); - GL11.glEnable(GL12.GL_RESCALE_NORMAL); - GL11.glPopMatrix(); - } + Minecraft.getMinecraft().renderEngine.bindTexture(texture); + int meta = bellows.getWorldObj() != null ? bellows.getBlockMetadata() : 0; + GL11.glTranslatef(0.5F, 1.5F, 0.5F); + GL11.glScalef(1F, -1F, -1F); + GL11.glRotatef(ROTATIONS[Math.max(Math.min(ROTATIONS.length, meta - 2), 0)], 0F, 1F, 0F); + model.render(Math.max(0.1F, 1F - (bellows.movePos + bellows.moving * f + 0.1F))); + GL11.glColor3f(1F, 1F, 1F); + GL11.glScalef(1F, -1F, -1F); + GL11.glEnable(GL12.GL_RESCALE_NORMAL); + GL11.glPopMatrix(); + } } diff --git a/src/main/java/vazkii/botania/client/render/tile/RenderTileBrewery.java b/src/main/java/vazkii/botania/client/render/tile/RenderTileBrewery.java index d649d0edc8..b4b3d14e04 100644 --- a/src/main/java/vazkii/botania/client/render/tile/RenderTileBrewery.java +++ b/src/main/java/vazkii/botania/client/render/tile/RenderTileBrewery.java @@ -2,16 +2,15 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Oct 31, 2014, 4:53:15 PM (GMT)] */ package vazkii.botania.client.render.tile; import java.awt.Color; - import net.minecraft.block.Block; import net.minecraft.client.Minecraft; import net.minecraft.client.renderer.ItemRenderer; @@ -26,10 +25,8 @@ import net.minecraft.util.IIcon; import net.minecraft.util.ResourceLocation; import net.minecraftforge.client.ForgeHooksClient; - import org.lwjgl.opengl.GL11; import org.lwjgl.opengl.GL12; - import vazkii.botania.client.core.handler.ClientTickHandler; import vazkii.botania.client.lib.LibResources; import vazkii.botania.client.model.ModelBrewery; @@ -37,73 +34,93 @@ public class RenderTileBrewery extends TileEntitySpecialRenderer { - private static final ResourceLocation texture = new ResourceLocation(LibResources.MODEL_BREWERY); - ModelBrewery model = new ModelBrewery(); - public TileBrewery brewery; - public static boolean rotate = true; - - @Override - public void renderTileEntityAt(TileEntity tileentity, double d0, double d1, double d2, float f) { - brewery = (TileBrewery) tileentity; - GL11.glPushMatrix(); - GL11.glEnable(GL12.GL_RESCALE_NORMAL); - GL11.glColor4f(1F, 1F, 1F, 1F); - GL11.glTranslated(d0, d1, d2); + private static final ResourceLocation texture = new ResourceLocation(LibResources.MODEL_BREWERY); + ModelBrewery model = new ModelBrewery(); + public TileBrewery brewery; + public static boolean rotate = true; - Minecraft.getMinecraft().renderEngine.bindTexture(texture); - GL11.glScalef(1F, -1F, -1F); - GL11.glTranslatef(0.5F, -1.5F, -0.5F); + @Override + public void renderTileEntityAt(TileEntity tileentity, double d0, double d1, double d2, float f) { + brewery = (TileBrewery) tileentity; + GL11.glPushMatrix(); + GL11.glEnable(GL12.GL_RESCALE_NORMAL); + GL11.glColor4f(1F, 1F, 1F, 1F); + GL11.glTranslated(d0, d1, d2); - double time = ClientTickHandler.ticksInGame + f; - if(!rotate) - time = -1; + Minecraft.getMinecraft().renderEngine.bindTexture(texture); + GL11.glScalef(1F, -1F, -1F); + GL11.glTranslatef(0.5F, -1.5F, -0.5F); - model.render(this, time); - GL11.glEnable(GL12.GL_RESCALE_NORMAL); - GL11.glPopMatrix(); - } + double time = ClientTickHandler.ticksInGame + f; + if (!rotate) time = -1; - public void renderItemStack(ItemStack stack) { - if(stack != null) { - Minecraft mc = Minecraft.getMinecraft(); - mc.renderEngine.bindTexture(stack.getItem() instanceof ItemBlock ? TextureMap.locationBlocksTexture : TextureMap.locationItemsTexture); + model.render(this, time); + GL11.glEnable(GL12.GL_RESCALE_NORMAL); + GL11.glPopMatrix(); + } - float s = 0.25F; - GL11.glScalef(s, s, s); - GL11.glScalef(2F, 2F, 2F); - if(!ForgeHooksClient.renderEntityItem(new EntityItem(brewery.getWorldObj(), brewery.xCoord, brewery.yCoord, brewery.zCoord, stack), stack, 0F, 0F, brewery.getWorldObj().rand, mc.renderEngine, RenderBlocks.getInstance(), 1)) { - GL11.glScalef(0.5F, 0.5F, 0.5F); - if(stack.getItem() instanceof ItemBlock && RenderBlocks.renderItemIn3d(Block.getBlockFromItem(stack.getItem()).getRenderType())) { - GL11.glScalef(0.5F, 0.5F, 0.5F); - GL11.glTranslatef(1F, 1.1F, 0F); - GL11.glPushMatrix(); - RenderBlocks.getInstance().renderBlockAsItem(Block.getBlockFromItem(stack.getItem()), stack.getItemDamage(), 1F); - GL11.glPopMatrix(); - GL11.glTranslatef(-1F, -1.1F, 0F); - GL11.glScalef(2F, 2F, 2F); - } else { - int renderPass = 0; - do { - IIcon icon = stack.getItem().getIcon(stack, renderPass); - if(icon != null) { - Color color = new Color(stack.getItem().getColorFromItemStack(stack, renderPass)); - GL11.glColor3ub((byte) color.getRed(), (byte) color.getGreen(), (byte) color.getBlue()); - float f = icon.getMinU(); - float f1 = icon.getMaxU(); - float f2 = icon.getMinV(); - float f3 = icon.getMaxV(); + public void renderItemStack(ItemStack stack) { + if (stack != null) { + Minecraft mc = Minecraft.getMinecraft(); + mc.renderEngine.bindTexture( + stack.getItem() instanceof ItemBlock + ? TextureMap.locationBlocksTexture + : TextureMap.locationItemsTexture); - ItemRenderer.renderItemIn2D(Tessellator.instance, f1, f2, f, f3, icon.getIconWidth(), icon.getIconHeight(), 1F / 16F); - GL11.glColor3f(1F, 1F, 1F); - } - renderPass++; - } while(renderPass < stack.getItem().getRenderPasses(stack.getItemDamage())); - } - } - GL11.glScalef(1F / s, 1F / s, 1F / s); + float s = 0.25F; + GL11.glScalef(s, s, s); + GL11.glScalef(2F, 2F, 2F); + if (!ForgeHooksClient.renderEntityItem( + new EntityItem(brewery.getWorldObj(), brewery.xCoord, brewery.yCoord, brewery.zCoord, stack), + stack, + 0F, + 0F, + brewery.getWorldObj().rand, + mc.renderEngine, + RenderBlocks.getInstance(), + 1)) { + GL11.glScalef(0.5F, 0.5F, 0.5F); + if (stack.getItem() instanceof ItemBlock + && RenderBlocks.renderItemIn3d( + Block.getBlockFromItem(stack.getItem()).getRenderType())) { + GL11.glScalef(0.5F, 0.5F, 0.5F); + GL11.glTranslatef(1F, 1.1F, 0F); + GL11.glPushMatrix(); + RenderBlocks.getInstance() + .renderBlockAsItem(Block.getBlockFromItem(stack.getItem()), stack.getItemDamage(), 1F); + GL11.glPopMatrix(); + GL11.glTranslatef(-1F, -1.1F, 0F); + GL11.glScalef(2F, 2F, 2F); + } else { + int renderPass = 0; + do { + IIcon icon = stack.getItem().getIcon(stack, renderPass); + if (icon != null) { + Color color = new Color(stack.getItem().getColorFromItemStack(stack, renderPass)); + GL11.glColor3ub((byte) color.getRed(), (byte) color.getGreen(), (byte) color.getBlue()); + float f = icon.getMinU(); + float f1 = icon.getMaxU(); + float f2 = icon.getMinV(); + float f3 = icon.getMaxV(); - Minecraft.getMinecraft().renderEngine.bindTexture(texture); - } - } + ItemRenderer.renderItemIn2D( + Tessellator.instance, + f1, + f2, + f, + f3, + icon.getIconWidth(), + icon.getIconHeight(), + 1F / 16F); + GL11.glColor3f(1F, 1F, 1F); + } + renderPass++; + } while (renderPass < stack.getItem().getRenderPasses(stack.getItemDamage())); + } + } + GL11.glScalef(1F / s, 1F / s, 1F / s); + Minecraft.getMinecraft().renderEngine.bindTexture(texture); + } + } } diff --git a/src/main/java/vazkii/botania/client/render/tile/RenderTileCocoon.java b/src/main/java/vazkii/botania/client/render/tile/RenderTileCocoon.java index ff7b4679bf..4ff0c37c12 100644 --- a/src/main/java/vazkii/botania/client/render/tile/RenderTileCocoon.java +++ b/src/main/java/vazkii/botania/client/render/tile/RenderTileCocoon.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jul 8, 2015, 4:44:23 PM (GMT)] */ package vazkii.botania.client.render.tile; @@ -14,44 +14,42 @@ import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.ResourceLocation; - import org.lwjgl.opengl.GL11; import org.lwjgl.opengl.GL12; - import vazkii.botania.client.lib.LibResources; import vazkii.botania.client.model.ModelCocoon; import vazkii.botania.common.block.tile.TileCocoon; public class RenderTileCocoon extends TileEntitySpecialRenderer { - private static final ResourceLocation texture = new ResourceLocation(LibResources.MODEL_COCOON); - ModelCocoon model = new ModelCocoon(); - - @Override - public void renderTileEntityAt(TileEntity tileentity, double d0, double d1, double d2, float f) { - TileCocoon cocoon = (TileCocoon) tileentity; - - float rot = 0F; - float modval = 60F - (float) cocoon.timePassed / (float) TileCocoon.TOTAL_TIME * 30F; - if(cocoon.timePassed % modval < 10) { - float mod = (cocoon.timePassed + f) % modval; - float v = mod / 5 * (float) Math.PI * 2; - rot = (float) Math.sin(v) * (float) Math.log(cocoon.timePassed + f); - } - - GL11.glPushMatrix(); - GL11.glEnable(GL12.GL_RESCALE_NORMAL); - GL11.glEnable(GL11.GL_BLEND); - GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); - GL11.glColor4f(1F, 1F, 1F, 1F); - GL11.glTranslated(d0, d1, d2); - Minecraft.getMinecraft().renderEngine.bindTexture(texture); - GL11.glRotatef(90F, 1F, 0F, 0F); - GL11.glTranslatef(0.5F, -0.5F - 3F / 16F, -0.5F + 1F / 16F); - GL11.glRotatef(rot, 0F, 1F, 0F); - model.render(); - GL11.glColor3f(1F, 1F, 1F); - GL11.glEnable(GL12.GL_RESCALE_NORMAL); - GL11.glPopMatrix(); - } + private static final ResourceLocation texture = new ResourceLocation(LibResources.MODEL_COCOON); + ModelCocoon model = new ModelCocoon(); + + @Override + public void renderTileEntityAt(TileEntity tileentity, double d0, double d1, double d2, float f) { + TileCocoon cocoon = (TileCocoon) tileentity; + + float rot = 0F; + float modval = 60F - (float) cocoon.timePassed / (float) TileCocoon.TOTAL_TIME * 30F; + if (cocoon.timePassed % modval < 10) { + float mod = (cocoon.timePassed + f) % modval; + float v = mod / 5 * (float) Math.PI * 2; + rot = (float) Math.sin(v) * (float) Math.log(cocoon.timePassed + f); + } + + GL11.glPushMatrix(); + GL11.glEnable(GL12.GL_RESCALE_NORMAL); + GL11.glEnable(GL11.GL_BLEND); + GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); + GL11.glColor4f(1F, 1F, 1F, 1F); + GL11.glTranslated(d0, d1, d2); + Minecraft.getMinecraft().renderEngine.bindTexture(texture); + GL11.glRotatef(90F, 1F, 0F, 0F); + GL11.glTranslatef(0.5F, -0.5F - 3F / 16F, -0.5F + 1F / 16F); + GL11.glRotatef(rot, 0F, 1F, 0F); + model.render(); + GL11.glColor3f(1F, 1F, 1F); + GL11.glEnable(GL12.GL_RESCALE_NORMAL); + GL11.glPopMatrix(); + } } diff --git a/src/main/java/vazkii/botania/client/render/tile/RenderTileCorporeaCrystalCube.java b/src/main/java/vazkii/botania/client/render/tile/RenderTileCorporeaCrystalCube.java index 71f7d6eefa..f8a6ae7803 100644 --- a/src/main/java/vazkii/botania/client/render/tile/RenderTileCorporeaCrystalCube.java +++ b/src/main/java/vazkii/botania/client/render/tile/RenderTileCorporeaCrystalCube.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Apr 30, 2015, 4:10:14 PM (GMT)] */ package vazkii.botania.client.render.tile; @@ -20,10 +20,8 @@ import net.minecraft.item.ItemStack; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.ResourceLocation; - import org.lwjgl.opengl.GL11; import org.lwjgl.opengl.GL12; - import vazkii.botania.client.core.handler.ClientTickHandler; import vazkii.botania.client.lib.LibResources; import vazkii.botania.client.model.ModelCrystalCube; @@ -31,87 +29,87 @@ public class RenderTileCorporeaCrystalCube extends TileEntitySpecialRenderer { - private static final ResourceLocation texture = new ResourceLocation(LibResources.MODEL_CRYSTAL_CUBE); - ModelCrystalCube model = new ModelCrystalCube(); - EntityItem entity = null; - - @Override - public void renderTileEntityAt(TileEntity tileentity, double d0, double d1, double d2, float f) { - TileCorporeaCrystalCube cube = (TileCorporeaCrystalCube) tileentity; - - if(entity == null) - entity = new EntityItem(cube.getWorldObj(), cube.xCoord, cube.yCoord, cube.zCoord, new ItemStack(Blocks.stone)); - - entity.age = ClientTickHandler.ticksInGame; - ItemStack stack = cube.getRequestTarget(); - entity.setEntityItemStack(stack); - - double time = ClientTickHandler.ticksInGame + f; - double worldTicks = tileentity.getWorldObj() == null ? 0 : time; - - Minecraft mc = Minecraft.getMinecraft(); - GL11.glPushMatrix(); - GL11.glEnable(GL12.GL_RESCALE_NORMAL); - GL11.glEnable(GL11.GL_BLEND); - GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); - GL11.glColor4f(1F, 1F, 1F, 1F); - GL11.glTranslated(d0, d1, d2); - mc.renderEngine.bindTexture(texture); - GL11.glTranslatef(0.5F, 1.5F, 0.5F); - GL11.glScalef(1F, -1F, -1F); - model.renderBase(); - GL11.glTranslatef(0F, (float) Math.sin(worldTicks / 20.0) * 0.05F, 0F); - if(stack != null) { - GL11.glPushMatrix(); - float s = stack.getItem() instanceof ItemBlock ? 0.7F : 0.5F; - GL11.glTranslatef(0F, 0.8F, 0F); - GL11.glScalef(s, s, s); - GL11.glRotatef(180F, 0F, 0F, 1F); - ((Render) RenderManager.instance.entityRenderMap.get(EntityItem.class)).doRender(entity, 0, 0, 0, 1F, f); - GL11.glPopMatrix(); - mc.renderEngine.bindTexture(texture); - } - - GL11.glColor4f(1F, 1F, 1F, 0.4F); - model.renderCube(); - GL11.glColor3f(1F, 1F, 1F); - - if(stack != null) { - int count = cube.getItemCount(); - String countStr = "" + count; - int color = 0xFFFFFF; - if(count > 9999) { - countStr = count / 1000 + "K"; - color = 0xFFFF00; - if(count > 9999999) { - countStr = count / 10000000 + "M"; - color = 0x00FF00; - } - } - color |= 0xA0 << 24; - int colorShade = (color & 16579836) >> 2 | color & -16777216; - - float s = 1F / 64F; - GL11.glScalef(s, s, s); - GL11.glDisable(GL11.GL_LIGHTING); - int l = mc.fontRenderer.getStringWidth(countStr); - - GL11.glTranslatef(0F, 55F, 0F); - float tr = -16.5F; - for(int i = 0; i < 4; i++) { - GL11.glRotatef(90F, 0F, 1F, 0F); - GL11.glTranslatef(0F, 0F, tr); - mc.fontRenderer.drawString(countStr, -l / 2, 0, color); - GL11.glTranslatef(0F, 0F, 0.1F); - mc.fontRenderer.drawString(countStr, -l / 2 + 1, 1, colorShade); - GL11.glTranslatef(0F, 0F, -tr - 0.1F); - } - GL11.glEnable(GL11.GL_LIGHTING); - } - - GL11.glScalef(1F, -1F, -1F); - GL11.glEnable(GL12.GL_RESCALE_NORMAL); - GL11.glPopMatrix(); - } - + private static final ResourceLocation texture = new ResourceLocation(LibResources.MODEL_CRYSTAL_CUBE); + ModelCrystalCube model = new ModelCrystalCube(); + EntityItem entity = null; + + @Override + public void renderTileEntityAt(TileEntity tileentity, double d0, double d1, double d2, float f) { + TileCorporeaCrystalCube cube = (TileCorporeaCrystalCube) tileentity; + + if (entity == null) + entity = new EntityItem( + cube.getWorldObj(), cube.xCoord, cube.yCoord, cube.zCoord, new ItemStack(Blocks.stone)); + + entity.age = ClientTickHandler.ticksInGame; + ItemStack stack = cube.getRequestTarget(); + entity.setEntityItemStack(stack); + + double time = ClientTickHandler.ticksInGame + f; + double worldTicks = tileentity.getWorldObj() == null ? 0 : time; + + Minecraft mc = Minecraft.getMinecraft(); + GL11.glPushMatrix(); + GL11.glEnable(GL12.GL_RESCALE_NORMAL); + GL11.glEnable(GL11.GL_BLEND); + GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); + GL11.glColor4f(1F, 1F, 1F, 1F); + GL11.glTranslated(d0, d1, d2); + mc.renderEngine.bindTexture(texture); + GL11.glTranslatef(0.5F, 1.5F, 0.5F); + GL11.glScalef(1F, -1F, -1F); + model.renderBase(); + GL11.glTranslatef(0F, (float) Math.sin(worldTicks / 20.0) * 0.05F, 0F); + if (stack != null) { + GL11.glPushMatrix(); + float s = stack.getItem() instanceof ItemBlock ? 0.7F : 0.5F; + GL11.glTranslatef(0F, 0.8F, 0F); + GL11.glScalef(s, s, s); + GL11.glRotatef(180F, 0F, 0F, 1F); + ((Render) RenderManager.instance.entityRenderMap.get(EntityItem.class)).doRender(entity, 0, 0, 0, 1F, f); + GL11.glPopMatrix(); + mc.renderEngine.bindTexture(texture); + } + + GL11.glColor4f(1F, 1F, 1F, 0.4F); + model.renderCube(); + GL11.glColor3f(1F, 1F, 1F); + + if (stack != null) { + int count = cube.getItemCount(); + String countStr = "" + count; + int color = 0xFFFFFF; + if (count > 9999) { + countStr = count / 1000 + "K"; + color = 0xFFFF00; + if (count > 9999999) { + countStr = count / 10000000 + "M"; + color = 0x00FF00; + } + } + color |= 0xA0 << 24; + int colorShade = (color & 16579836) >> 2 | color & -16777216; + + float s = 1F / 64F; + GL11.glScalef(s, s, s); + GL11.glDisable(GL11.GL_LIGHTING); + int l = mc.fontRenderer.getStringWidth(countStr); + + GL11.glTranslatef(0F, 55F, 0F); + float tr = -16.5F; + for (int i = 0; i < 4; i++) { + GL11.glRotatef(90F, 0F, 1F, 0F); + GL11.glTranslatef(0F, 0F, tr); + mc.fontRenderer.drawString(countStr, -l / 2, 0, color); + GL11.glTranslatef(0F, 0F, 0.1F); + mc.fontRenderer.drawString(countStr, -l / 2 + 1, 1, colorShade); + GL11.glTranslatef(0F, 0F, -tr - 0.1F); + } + GL11.glEnable(GL11.GL_LIGHTING); + } + + GL11.glScalef(1F, -1F, -1F); + GL11.glEnable(GL12.GL_RESCALE_NORMAL); + GL11.glPopMatrix(); + } } diff --git a/src/main/java/vazkii/botania/client/render/tile/RenderTileCorporeaIndex.java b/src/main/java/vazkii/botania/client/render/tile/RenderTileCorporeaIndex.java index 3e66131aa4..d3a8989be6 100644 --- a/src/main/java/vazkii/botania/client/render/tile/RenderTileCorporeaIndex.java +++ b/src/main/java/vazkii/botania/client/render/tile/RenderTileCorporeaIndex.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Feb 15, 2015, 12:54:49 AM (GMT)] */ package vazkii.botania.client.render.tile; @@ -15,59 +15,60 @@ import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.ResourceLocation; - import org.lwjgl.opengl.GL11; - import vazkii.botania.client.core.helper.RenderHelper; import vazkii.botania.client.lib.LibResources; import vazkii.botania.common.block.tile.corporea.TileCorporeaIndex; public class RenderTileCorporeaIndex extends TileEntitySpecialRenderer { - private static final ResourceLocation texture = new ResourceLocation(LibResources.MODEL_CORPOREA_INDEX); - ModelEnderCrystal crystal = new ModelEnderCrystal(0F, false); - public static boolean move = true; - - @Override - public void renderTileEntityAt(TileEntity tile, double x, double y, double z, float partticks) { - TileCorporeaIndex index = (TileCorporeaIndex) tile; + private static final ResourceLocation texture = new ResourceLocation(LibResources.MODEL_CORPOREA_INDEX); + ModelEnderCrystal crystal = new ModelEnderCrystal(0F, false); + public static boolean move = true; - GL11.glPushMatrix(); - GL11.glTranslated(x + 0.5, y, z + 0.5); - Minecraft.getMinecraft().renderEngine.bindTexture(texture); + @Override + public void renderTileEntityAt(TileEntity tile, double x, double y, double z, float partticks) { + TileCorporeaIndex index = (TileCorporeaIndex) tile; - float translation = move ? (float) ((Math.cos((index.ticksWithCloseby + (index.hasCloseby ? partticks : 0)) / 10F) * 0.5 + 0.5) * 0.25) : 0F; - float rotation = move ? index.ticks * 2 + partticks : 0F; - float scale = 0.6F; - GL11.glScalef(scale, scale, scale); - crystal.render(null, 0F, rotation, translation, 0F, 0F, 1F / 16F); - GL11.glScalef(1F / scale, 1F / scale, 1F / scale); + GL11.glPushMatrix(); + GL11.glTranslated(x + 0.5, y, z + 0.5); + Minecraft.getMinecraft().renderEngine.bindTexture(texture); - if(index.closeby > 0F) { - float starScale = 0.02F; - float starRadius = (float) TileCorporeaIndex.RADIUS * index.closeby + (index.closeby == 1F ? 0F : index.hasCloseby ? partticks : -partticks) * 0.2F; - double rads = (index.ticksWithCloseby + partticks) * 2 * Math.PI / 180; - double starX = Math.cos(rads) * starRadius; - double starZ = Math.sin(rads) * starRadius; - int color = 0xFF00FF; - int seed = index.xCoord ^ index.yCoord ^ index.zCoord; + float translation = move + ? (float) ((Math.cos((index.ticksWithCloseby + (index.hasCloseby ? partticks : 0)) / 10F) * 0.5 + 0.5) + * 0.25) + : 0F; + float rotation = move ? index.ticks * 2 + partticks : 0F; + float scale = 0.6F; + GL11.glScalef(scale, scale, scale); + crystal.render(null, 0F, rotation, translation, 0F, 0F, 1F / 16F); + GL11.glScalef(1F / scale, 1F / scale, 1F / scale); - GL11.glTranslated(starX, 0.3, starZ); - RenderHelper.renderStar(color, starScale, starScale, starScale, seed); - GL11.glTranslated(-starX * 2, 0, -starZ * 2); - RenderHelper.renderStar(color, starScale, starScale, starScale, seed); - GL11.glTranslated(starX, 0, starZ); + if (index.closeby > 0F) { + float starScale = 0.02F; + float starRadius = (float) TileCorporeaIndex.RADIUS * index.closeby + + (index.closeby == 1F ? 0F : index.hasCloseby ? partticks : -partticks) * 0.2F; + double rads = (index.ticksWithCloseby + partticks) * 2 * Math.PI / 180; + double starX = Math.cos(rads) * starRadius; + double starZ = Math.sin(rads) * starRadius; + int color = 0xFF00FF; + int seed = index.xCoord ^ index.yCoord ^ index.zCoord; - rads = -rads; - starX = Math.cos(rads) * starRadius; - starZ = Math.sin(rads) * starRadius; - GL11.glTranslated(starX, 0, starZ); - RenderHelper.renderStar(color, starScale, starScale, starScale, seed); - GL11.glTranslated(-starX * 2, 0, -starZ * 2); - RenderHelper.renderStar(color, starScale, starScale, starScale, seed); - GL11.glTranslated(starX, 0, starZ); - } - GL11.glPopMatrix(); - } + GL11.glTranslated(starX, 0.3, starZ); + RenderHelper.renderStar(color, starScale, starScale, starScale, seed); + GL11.glTranslated(-starX * 2, 0, -starZ * 2); + RenderHelper.renderStar(color, starScale, starScale, starScale, seed); + GL11.glTranslated(starX, 0, starZ); + rads = -rads; + starX = Math.cos(rads) * starRadius; + starZ = Math.sin(rads) * starRadius; + GL11.glTranslated(starX, 0, starZ); + RenderHelper.renderStar(color, starScale, starScale, starScale, seed); + GL11.glTranslated(-starX * 2, 0, -starZ * 2); + RenderHelper.renderStar(color, starScale, starScale, starScale, seed); + GL11.glTranslated(starX, 0, starZ); + } + GL11.glPopMatrix(); + } } diff --git a/src/main/java/vazkii/botania/client/render/tile/RenderTileEnchanter.java b/src/main/java/vazkii/botania/client/render/tile/RenderTileEnchanter.java index 6d9b654faa..dd9854bf90 100644 --- a/src/main/java/vazkii/botania/client/render/tile/RenderTileEnchanter.java +++ b/src/main/java/vazkii/botania/client/render/tile/RenderTileEnchanter.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Mar 15, 2014, 5:04:42 PM (GMT)] */ package vazkii.botania.client.render.tile; @@ -21,9 +21,7 @@ import net.minecraft.entity.item.EntityItem; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.IIcon; - import org.lwjgl.opengl.GL11; - import vazkii.botania.client.core.handler.ClientTickHandler; import vazkii.botania.client.core.helper.ShaderHelper; import vazkii.botania.common.block.mana.BlockEnchanter; @@ -31,91 +29,95 @@ public class RenderTileEnchanter extends TileEntitySpecialRenderer { - RenderItem renderItem = new RenderItem(); - EntityItem item; - - @Override - public void renderTileEntityAt(TileEntity tileentity, double d0, double d1, double d2, float f) { - TileEnchanter enchanter = (TileEnchanter) tileentity; - float alphaMod = 0F; - - if(enchanter.stage == 2) - alphaMod = Math.min(20, enchanter.stageTicks) / 20F; - else if(enchanter.stage == 4) - alphaMod = (20 - enchanter.stageTicks) / 20F; - else if(enchanter.stage > 2) - alphaMod = 1F; - - if(enchanter.itemToEnchant != null) { - if(item == null) - item = new EntityItem(enchanter.getWorldObj(), enchanter.xCoord, enchanter.yCoord + 1, enchanter.zCoord, enchanter.itemToEnchant); - - item.age = ClientTickHandler.ticksInGame; - item.setEntityItemStack(enchanter.itemToEnchant); - - GL11.glColor4f(1F, 1F, 1F, 1F); - GL11.glTranslatef(0.5F, 1.25F, 0.5F); - ((Render) RenderManager.instance.entityRenderMap.get(EntityItem.class)).doRender(item, d0, d1, d2, 1F, f); - GL11.glTranslatef(-0.5F, -1.25F, -0.5F); - } - - GL11.glPushMatrix(); - GL11.glTranslated(d0, d1, d2); - - GL11.glRotated(90F, 1F, 0F, 0F); - GL11.glTranslatef(-2F, -2F, -0.001F); - - GL11.glEnable(GL11.GL_BLEND); - GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); - GL11.glColor4f(1F, 1F, 1F, 1F); - GL11.glDisable(GL11.GL_ALPHA_TEST); - float alpha = (float) ((Math.sin((ClientTickHandler.ticksInGame + f) / 8D) + 1D) / 5D + 0.4D) * alphaMod; - - if(alpha > 0) { - if(ShaderHelper.useShaders()) - GL11.glColor4f(1F, 1F, 1F, alpha); - else { - int light = 15728880; - int lightmapX = light % 65536; - int lightmapY = light / 65536; - OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, lightmapX, lightmapY); - GL11.glColor4f(0.6F + (float) ((Math.cos((ClientTickHandler.ticksInGame + f) / 6D) + 1D) / 5D), 0.1F, 0.9F, alpha); - } - - Minecraft.getMinecraft().renderEngine.bindTexture(TextureMap.locationBlocksTexture); - - if(enchanter.stage == 3 || enchanter.stage == 4) { - int ticks = enchanter.stageTicks + enchanter.stage3EndTicks; - int angle = ticks * 2; - float yTranslation = Math.min(20, ticks) / 20F * 1.15F; - float scale = ticks < 10 ? 1F : 1F - Math.min(20, ticks - 10) / 20F * 0.75F; - - GL11.glTranslatef(2.5F, 2.5F, -yTranslation); - GL11.glScalef(scale, scale, 1F); - GL11.glRotatef(angle, 0F, 0F, 1F); - GL11.glTranslatef(-2.5F, -2.5F, 0F); - } - - ShaderHelper.useShader(ShaderHelper.enchanterRune); - renderIcon(0, 0, BlockEnchanter.overlay, 5, 5, 240); - ShaderHelper.releaseShader(); - } - - GL11.glEnable(GL11.GL_ALPHA_TEST); - GL11.glDisable(GL11.GL_BLEND); - GL11.glColor4f(1F, 1F, 1F, 1F); - GL11.glPopMatrix(); - } - - public void renderIcon(int par1, int par2, IIcon par3Icon, int par4, int par5, int brightness) { - Tessellator tessellator = Tessellator.instance; - tessellator.startDrawingQuads(); - tessellator.setBrightness(brightness); - tessellator.addVertexWithUV(par1 + 0, par2 + par5, 0, par3Icon.getMinU(), par3Icon.getMaxV()); - tessellator.addVertexWithUV(par1 + par4, par2 + par5, 0, par3Icon.getMaxU(), par3Icon.getMaxV()); - tessellator.addVertexWithUV(par1 + par4, par2 + 0, 0, par3Icon.getMaxU(), par3Icon.getMinV()); - tessellator.addVertexWithUV(par1 + 0, par2 + 0, 0, par3Icon.getMinU(), par3Icon.getMinV()); - tessellator.draw(); - } - + RenderItem renderItem = new RenderItem(); + EntityItem item; + + @Override + public void renderTileEntityAt(TileEntity tileentity, double d0, double d1, double d2, float f) { + TileEnchanter enchanter = (TileEnchanter) tileentity; + float alphaMod = 0F; + + if (enchanter.stage == 2) alphaMod = Math.min(20, enchanter.stageTicks) / 20F; + else if (enchanter.stage == 4) alphaMod = (20 - enchanter.stageTicks) / 20F; + else if (enchanter.stage > 2) alphaMod = 1F; + + if (enchanter.itemToEnchant != null) { + if (item == null) + item = new EntityItem( + enchanter.getWorldObj(), + enchanter.xCoord, + enchanter.yCoord + 1, + enchanter.zCoord, + enchanter.itemToEnchant); + + item.age = ClientTickHandler.ticksInGame; + item.setEntityItemStack(enchanter.itemToEnchant); + + GL11.glColor4f(1F, 1F, 1F, 1F); + GL11.glTranslatef(0.5F, 1.25F, 0.5F); + ((Render) RenderManager.instance.entityRenderMap.get(EntityItem.class)).doRender(item, d0, d1, d2, 1F, f); + GL11.glTranslatef(-0.5F, -1.25F, -0.5F); + } + + GL11.glPushMatrix(); + GL11.glTranslated(d0, d1, d2); + + GL11.glRotated(90F, 1F, 0F, 0F); + GL11.glTranslatef(-2F, -2F, -0.001F); + + GL11.glEnable(GL11.GL_BLEND); + GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); + GL11.glColor4f(1F, 1F, 1F, 1F); + GL11.glDisable(GL11.GL_ALPHA_TEST); + float alpha = (float) ((Math.sin((ClientTickHandler.ticksInGame + f) / 8D) + 1D) / 5D + 0.4D) * alphaMod; + + if (alpha > 0) { + if (ShaderHelper.useShaders()) GL11.glColor4f(1F, 1F, 1F, alpha); + else { + int light = 15728880; + int lightmapX = light % 65536; + int lightmapY = light / 65536; + OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, lightmapX, lightmapY); + GL11.glColor4f( + 0.6F + (float) ((Math.cos((ClientTickHandler.ticksInGame + f) / 6D) + 1D) / 5D), + 0.1F, + 0.9F, + alpha); + } + + Minecraft.getMinecraft().renderEngine.bindTexture(TextureMap.locationBlocksTexture); + + if (enchanter.stage == 3 || enchanter.stage == 4) { + int ticks = enchanter.stageTicks + enchanter.stage3EndTicks; + int angle = ticks * 2; + float yTranslation = Math.min(20, ticks) / 20F * 1.15F; + float scale = ticks < 10 ? 1F : 1F - Math.min(20, ticks - 10) / 20F * 0.75F; + + GL11.glTranslatef(2.5F, 2.5F, -yTranslation); + GL11.glScalef(scale, scale, 1F); + GL11.glRotatef(angle, 0F, 0F, 1F); + GL11.glTranslatef(-2.5F, -2.5F, 0F); + } + + ShaderHelper.useShader(ShaderHelper.enchanterRune); + renderIcon(0, 0, BlockEnchanter.overlay, 5, 5, 240); + ShaderHelper.releaseShader(); + } + + GL11.glEnable(GL11.GL_ALPHA_TEST); + GL11.glDisable(GL11.GL_BLEND); + GL11.glColor4f(1F, 1F, 1F, 1F); + GL11.glPopMatrix(); + } + + public void renderIcon(int par1, int par2, IIcon par3Icon, int par4, int par5, int brightness) { + Tessellator tessellator = Tessellator.instance; + tessellator.startDrawingQuads(); + tessellator.setBrightness(brightness); + tessellator.addVertexWithUV(par1 + 0, par2 + par5, 0, par3Icon.getMinU(), par3Icon.getMaxV()); + tessellator.addVertexWithUV(par1 + par4, par2 + par5, 0, par3Icon.getMaxU(), par3Icon.getMaxV()); + tessellator.addVertexWithUV(par1 + par4, par2 + 0, 0, par3Icon.getMaxU(), par3Icon.getMinV()); + tessellator.addVertexWithUV(par1 + 0, par2 + 0, 0, par3Icon.getMinU(), par3Icon.getMinV()); + tessellator.draw(); + } } diff --git a/src/main/java/vazkii/botania/client/render/tile/RenderTileFloatingFlower.java b/src/main/java/vazkii/botania/client/render/tile/RenderTileFloatingFlower.java index c688c2587f..35a68dab45 100644 --- a/src/main/java/vazkii/botania/client/render/tile/RenderTileFloatingFlower.java +++ b/src/main/java/vazkii/botania/client/render/tile/RenderTileFloatingFlower.java @@ -2,17 +2,16 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jul 8, 2014, 10:58:46 PM (GMT)] */ package vazkii.botania.client.render.tile; import java.awt.*; import java.util.Random; - import net.minecraft.client.Minecraft; import net.minecraft.client.renderer.ItemRenderer; import net.minecraft.client.renderer.Tessellator; @@ -21,60 +20,57 @@ import net.minecraft.item.ItemStack; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.IIcon; - import org.lwjgl.opengl.GL11; - import vazkii.botania.client.core.handler.ClientTickHandler; import vazkii.botania.client.model.ModelMiniIsland; import vazkii.botania.common.block.decor.IFloatingFlower; public class RenderTileFloatingFlower extends TileEntitySpecialRenderer { - private static final ModelMiniIsland model = new ModelMiniIsland(); - - @Override - public void renderTileEntityAt(TileEntity tile, double d0, double d1, double d2, float t) { - IFloatingFlower flower = (IFloatingFlower) tile; - GL11.glPushMatrix(); - GL11.glColor4f(1F, 1F, 1F, 1F); - GL11.glTranslated(d0, d1, d2); + private static final ModelMiniIsland model = new ModelMiniIsland(); - double worldTime = tile.getWorldObj() == null ? 0 : (double) (ClientTickHandler.ticksInGame + t); - if(tile.getWorldObj() != null) - worldTime += new Random(tile.xCoord ^ tile.yCoord ^ tile.zCoord).nextInt(1000); + @Override + public void renderTileEntityAt(TileEntity tile, double d0, double d1, double d2, float t) { + IFloatingFlower flower = (IFloatingFlower) tile; + GL11.glPushMatrix(); + GL11.glColor4f(1F, 1F, 1F, 1F); + GL11.glTranslated(d0, d1, d2); - GL11.glTranslatef(0.5F, 0F, 0.5F); - GL11.glRotatef(-((float) worldTime * 0.5F), 0F, 1F, 0F); - GL11.glTranslatef(-0.5F, 0F, -0.5F); + double worldTime = tile.getWorldObj() == null ? 0 : (double) (ClientTickHandler.ticksInGame + t); + if (tile.getWorldObj() != null) worldTime += new Random(tile.xCoord ^ tile.yCoord ^ tile.zCoord).nextInt(1000); - if(tile.getWorldObj() != null) { - GL11.glTranslatef(0F, (float) Math.sin(worldTime * 0.05F) * 0.1F, 0F); - GL11.glRotatef(4F * (float) Math.sin(worldTime * 0.04F), 1F, 0F, 0F); - } + GL11.glTranslatef(0.5F, 0F, 0.5F); + GL11.glRotatef(-((float) worldTime * 0.5F), 0F, 1F, 0F); + GL11.glTranslatef(-0.5F, 0F, -0.5F); - Minecraft.getMinecraft().renderEngine.bindTexture(flower.getIslandType().getResource()); - Color color = new Color(flower.getIslandType().getColor()); - GL11.glColor3f(color.getRed() / 255f, color.getGreen() / 255f, color.getBlue() / 255f); - GL11.glPushMatrix(); - GL11.glTranslatef(0.5F, 1.4F, 0.5F); - GL11.glScalef(1F, -1F, -1F); - model.render(); - GL11.glPopMatrix(); - GL11.glColor3f(1f, 1f, 1f); + if (tile.getWorldObj() != null) { + GL11.glTranslatef(0F, (float) Math.sin(worldTime * 0.05F) * 0.1F, 0F); + GL11.glRotatef(4F * (float) Math.sin(worldTime * 0.04F), 1F, 0F, 0F); + } - ItemStack stack = flower.getDisplayStack(); - IIcon icon = stack.getIconIndex(); + Minecraft.getMinecraft().renderEngine.bindTexture(flower.getIslandType().getResource()); + Color color = new Color(flower.getIslandType().getColor()); + GL11.glColor3f(color.getRed() / 255f, color.getGreen() / 255f, color.getBlue() / 255f); + GL11.glPushMatrix(); + GL11.glTranslatef(0.5F, 1.4F, 0.5F); + GL11.glScalef(1F, -1F, -1F); + model.render(); + GL11.glPopMatrix(); + GL11.glColor3f(1f, 1f, 1f); - Minecraft.getMinecraft().renderEngine.bindTexture(TextureMap.locationBlocksTexture); - float f = icon.getMinU(); - float f1 = icon.getMaxU(); - float f2 = icon.getMinV(); - float f3 = icon.getMaxV(); - GL11.glTranslatef(0.25F, 0.4F, 0.5F); - GL11.glScalef(0.5F, 0.5F, 0.5F); - ItemRenderer.renderItemIn2D(Tessellator.instance, f1, f2, f, f3, icon.getIconWidth(), icon.getIconHeight(), 1F / 32F); - GL11.glColor3f(1F, 1F, 1F); - GL11.glPopMatrix(); - } + ItemStack stack = flower.getDisplayStack(); + IIcon icon = stack.getIconIndex(); + Minecraft.getMinecraft().renderEngine.bindTexture(TextureMap.locationBlocksTexture); + float f = icon.getMinU(); + float f1 = icon.getMaxU(); + float f2 = icon.getMinV(); + float f3 = icon.getMaxV(); + GL11.glTranslatef(0.25F, 0.4F, 0.5F); + GL11.glScalef(0.5F, 0.5F, 0.5F); + ItemRenderer.renderItemIn2D( + Tessellator.instance, f1, f2, f, f3, icon.getIconWidth(), icon.getIconHeight(), 1F / 32F); + GL11.glColor3f(1F, 1F, 1F); + GL11.glPopMatrix(); + } } diff --git a/src/main/java/vazkii/botania/client/render/tile/RenderTileHourglass.java b/src/main/java/vazkii/botania/client/render/tile/RenderTileHourglass.java index c5bb50574f..1e42634094 100644 --- a/src/main/java/vazkii/botania/client/render/tile/RenderTileHourglass.java +++ b/src/main/java/vazkii/botania/client/render/tile/RenderTileHourglass.java @@ -2,24 +2,21 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [May 29, 2015, 8:19:32 PM (GMT)] */ package vazkii.botania.client.render.tile; import java.util.Random; - import net.minecraft.client.Minecraft; import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer; import net.minecraft.item.ItemStack; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.ResourceLocation; - import org.lwjgl.opengl.GL11; - import vazkii.botania.client.core.handler.ClientTickHandler; import vazkii.botania.client.lib.LibResources; import vazkii.botania.client.model.ModelHourglass; @@ -27,43 +24,40 @@ public class RenderTileHourglass extends TileEntitySpecialRenderer { - ResourceLocation texture = new ResourceLocation(LibResources.MODEL_HOURGLASS); - ModelHourglass model = new ModelHourglass(); - - @Override - public void renderTileEntityAt(TileEntity tileentity, double d0, double d1, double d2, float ticks) { - TileHourglass hourglass = (TileHourglass) tileentity; - - GL11.glPushMatrix(); - GL11.glEnable(GL11.GL_BLEND); - GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); - GL11.glColor4f(1F, 1F, 1F, 1F); - GL11.glTranslated(d0, d1, d2); - Minecraft.getMinecraft().renderEngine.bindTexture(texture); - - int wtime = tileentity.getWorldObj() == null ? 0 : ClientTickHandler.ticksInGame; - if(wtime != 0) - wtime += new Random(tileentity.xCoord ^ tileentity.yCoord ^ tileentity.zCoord).nextInt(360); - - float time = wtime == 0 ? 0 : wtime + ticks; - float x = 0.5F + (float) Math.cos(time * 0.05F) * 0.025F; - float y = 0.55F + (float) (Math.sin(time * 0.04F) + 1F) * 0.05F; - float z = 0.5F + (float) Math.sin(time * 0.05F) * 0.025F; - ItemStack stack = hourglass.getStackInSlot(0); - - float fract1 = stack == null ? 0 : hourglass.timeFraction; - float fract2 = stack == null ? 0 : 1F - hourglass.timeFraction; - GL11.glTranslatef(x, y, z); - - float rot = hourglass.flip ? 180F : 1F; - if(hourglass.flipTicks > 0) - rot += (hourglass.flipTicks - ticks) * (180F / 4F); - GL11.glRotatef(rot, 0F, 0F, 1F); - - GL11.glScalef(1F, -1F, -1F); - model.render(fract1, fract2, hourglass.flip, hourglass.getColor()); - GL11.glScalef(1F, -1F, -1F); - GL11.glPopMatrix(); - } - + ResourceLocation texture = new ResourceLocation(LibResources.MODEL_HOURGLASS); + ModelHourglass model = new ModelHourglass(); + + @Override + public void renderTileEntityAt(TileEntity tileentity, double d0, double d1, double d2, float ticks) { + TileHourglass hourglass = (TileHourglass) tileentity; + + GL11.glPushMatrix(); + GL11.glEnable(GL11.GL_BLEND); + GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); + GL11.glColor4f(1F, 1F, 1F, 1F); + GL11.glTranslated(d0, d1, d2); + Minecraft.getMinecraft().renderEngine.bindTexture(texture); + + int wtime = tileentity.getWorldObj() == null ? 0 : ClientTickHandler.ticksInGame; + if (wtime != 0) wtime += new Random(tileentity.xCoord ^ tileentity.yCoord ^ tileentity.zCoord).nextInt(360); + + float time = wtime == 0 ? 0 : wtime + ticks; + float x = 0.5F + (float) Math.cos(time * 0.05F) * 0.025F; + float y = 0.55F + (float) (Math.sin(time * 0.04F) + 1F) * 0.05F; + float z = 0.5F + (float) Math.sin(time * 0.05F) * 0.025F; + ItemStack stack = hourglass.getStackInSlot(0); + + float fract1 = stack == null ? 0 : hourglass.timeFraction; + float fract2 = stack == null ? 0 : 1F - hourglass.timeFraction; + GL11.glTranslatef(x, y, z); + + float rot = hourglass.flip ? 180F : 1F; + if (hourglass.flipTicks > 0) rot += (hourglass.flipTicks - ticks) * (180F / 4F); + GL11.glRotatef(rot, 0F, 0F, 1F); + + GL11.glScalef(1F, -1F, -1F); + model.render(fract1, fract2, hourglass.flip, hourglass.getColor()); + GL11.glScalef(1F, -1F, -1F); + GL11.glPopMatrix(); + } } diff --git a/src/main/java/vazkii/botania/client/render/tile/RenderTileIncensePlate.java b/src/main/java/vazkii/botania/client/render/tile/RenderTileIncensePlate.java index 3a786db708..312114fa48 100644 --- a/src/main/java/vazkii/botania/client/render/tile/RenderTileIncensePlate.java +++ b/src/main/java/vazkii/botania/client/render/tile/RenderTileIncensePlate.java @@ -2,16 +2,15 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [May 15, 2015, 4:27:27 PM (GMT)] */ package vazkii.botania.client.render.tile; import java.awt.Color; - import net.minecraft.client.Minecraft; import net.minecraft.client.renderer.ItemRenderer; import net.minecraft.client.renderer.Tessellator; @@ -21,71 +20,67 @@ import net.minecraft.tileentity.TileEntity; import net.minecraft.util.IIcon; import net.minecraft.util.ResourceLocation; - import org.lwjgl.opengl.GL11; import org.lwjgl.opengl.GL12; - import vazkii.botania.client.lib.LibResources; import vazkii.botania.client.model.ModelIncensePlate; import vazkii.botania.common.block.tile.TileIncensePlate; public class RenderTileIncensePlate extends TileEntitySpecialRenderer { - private static final float[] ROTATIONS = new float[] { - 180F, 0F, 90F, 270F - }; - - ResourceLocation texture = new ResourceLocation(LibResources.MODEL_INCENSE_PLATE); - ModelIncensePlate model = new ModelIncensePlate(); + private static final float[] ROTATIONS = new float[] {180F, 0F, 90F, 270F}; - @Override - public void renderTileEntityAt(TileEntity tileentity, double d0, double d1, double d2, float ticks) { - TileIncensePlate plate = (TileIncensePlate) tileentity; + ResourceLocation texture = new ResourceLocation(LibResources.MODEL_INCENSE_PLATE); + ModelIncensePlate model = new ModelIncensePlate(); - int meta = plate.getWorldObj() != null ? plate.getBlockMetadata() : 0; + @Override + public void renderTileEntityAt(TileEntity tileentity, double d0, double d1, double d2, float ticks) { + TileIncensePlate plate = (TileIncensePlate) tileentity; - GL11.glPushMatrix(); - GL11.glEnable(GL12.GL_RESCALE_NORMAL); - GL11.glEnable(GL11.GL_BLEND); - GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); - GL11.glColor4f(1F, 1F, 1F, 1F); - GL11.glTranslated(d0, d1, d2); - Minecraft.getMinecraft().renderEngine.bindTexture(texture); - GL11.glTranslatef(0.5F, 1.5F, 0.5F); - GL11.glScalef(1F, -1F, -1F); - GL11.glRotatef(ROTATIONS[Math.max(Math.min(ROTATIONS.length, meta - 2), 0)], 0F, 1F, 0F); - model.render(); - GL11.glScalef(1F, -1F, -1F); + int meta = plate.getWorldObj() != null ? plate.getBlockMetadata() : 0; - ItemStack stack = plate.getStackInSlot(0); - if(stack != null) { - GL11.glPushMatrix(); - Minecraft.getMinecraft().renderEngine.bindTexture(TextureMap.locationItemsTexture); - float s = 0.4F; - GL11.glTranslatef(0.1F, -1.46F, 0F); - GL11.glScalef(s, s, s); - GL11.glRotatef(180F, 0F, 1F, 0F); + GL11.glPushMatrix(); + GL11.glEnable(GL12.GL_RESCALE_NORMAL); + GL11.glEnable(GL11.GL_BLEND); + GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); + GL11.glColor4f(1F, 1F, 1F, 1F); + GL11.glTranslated(d0, d1, d2); + Minecraft.getMinecraft().renderEngine.bindTexture(texture); + GL11.glTranslatef(0.5F, 1.5F, 0.5F); + GL11.glScalef(1F, -1F, -1F); + GL11.glRotatef(ROTATIONS[Math.max(Math.min(ROTATIONS.length, meta - 2), 0)], 0F, 1F, 0F); + model.render(); + GL11.glScalef(1F, -1F, -1F); - int renderPass = 0; - do { - IIcon icon = stack.getItem().getIcon(stack, renderPass); - if(icon != null) { - Color color = new Color(stack.getItem().getColorFromItemStack(stack, renderPass)); - GL11.glColor3ub((byte) color.getRed(), (byte) color.getGreen(), (byte) color.getBlue()); - float f = icon.getMinU(); - float f1 = icon.getMaxU(); - float f2 = icon.getMinV(); - float f3 = icon.getMaxV(); - ItemRenderer.renderItemIn2D(Tessellator.instance, f1, f2, f, f3, icon.getIconWidth(), icon.getIconHeight(), 1F / 32F); - GL11.glColor3f(1F, 1F, 1F); - } - renderPass++; - } while(renderPass < stack.getItem().getRenderPasses(stack.getItemDamage())); - GL11.glPopMatrix(); - } - GL11.glColor3f(1F, 1F, 1F); - GL11.glEnable(GL12.GL_RESCALE_NORMAL); - GL11.glPopMatrix(); - } + ItemStack stack = plate.getStackInSlot(0); + if (stack != null) { + GL11.glPushMatrix(); + Minecraft.getMinecraft().renderEngine.bindTexture(TextureMap.locationItemsTexture); + float s = 0.4F; + GL11.glTranslatef(0.1F, -1.46F, 0F); + GL11.glScalef(s, s, s); + GL11.glRotatef(180F, 0F, 1F, 0F); + int renderPass = 0; + do { + IIcon icon = stack.getItem().getIcon(stack, renderPass); + if (icon != null) { + Color color = new Color(stack.getItem().getColorFromItemStack(stack, renderPass)); + GL11.glColor3ub((byte) color.getRed(), (byte) color.getGreen(), (byte) color.getBlue()); + float f = icon.getMinU(); + float f1 = icon.getMaxU(); + float f2 = icon.getMinV(); + float f3 = icon.getMaxV(); + ItemRenderer.renderItemIn2D( + Tessellator.instance, f1, f2, f, f3, icon.getIconWidth(), icon.getIconHeight(), 1F / 32F); + GL11.glColor3f(1F, 1F, 1F); + } + renderPass++; + } while (renderPass < stack.getItem().getRenderPasses(stack.getItemDamage())); + GL11.glPopMatrix(); + } + GL11.glColor3f(1F, 1F, 1F); + GL11.glEnable(GL12.GL_RESCALE_NORMAL); + GL11.glPopMatrix(); + } } diff --git a/src/main/java/vazkii/botania/client/render/tile/RenderTileLightRelay.java b/src/main/java/vazkii/botania/client/render/tile/RenderTileLightRelay.java index 5213ecda3a..c38670c971 100644 --- a/src/main/java/vazkii/botania/client/render/tile/RenderTileLightRelay.java +++ b/src/main/java/vazkii/botania/client/render/tile/RenderTileLightRelay.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jul 16, 2015, 5:03:57 PM (GMT)] */ package vazkii.botania.client.render.tile; @@ -17,82 +17,78 @@ import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.IIcon; - import org.lwjgl.opengl.GL11; import org.lwjgl.opengl.GL12; - import vazkii.botania.client.core.handler.ClientTickHandler; import vazkii.botania.client.core.helper.ShaderHelper; import vazkii.botania.common.block.BlockLightRelay; public class RenderTileLightRelay extends TileEntitySpecialRenderer { - @Override - public void renderTileEntityAt(TileEntity tile, double x, double y, double z, float pticks) { - Minecraft mc = Minecraft.getMinecraft(); - IIcon iicon = tile.getBlockMetadata() > 0 ? BlockLightRelay.worldIconRed : BlockLightRelay.worldIcon; + @Override + public void renderTileEntityAt(TileEntity tile, double x, double y, double z, float pticks) { + Minecraft mc = Minecraft.getMinecraft(); + IIcon iicon = tile.getBlockMetadata() > 0 ? BlockLightRelay.worldIconRed : BlockLightRelay.worldIcon; - GL11.glPushMatrix(); - GL11.glTranslated(x + 0.5, y + 0.3, z + 0.5); - GL11.glEnable(GL12.GL_RESCALE_NORMAL); - GL11.glEnable(GL11.GL_BLEND); - GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); - GL11.glAlphaFunc(GL11.GL_GREATER, 0.05F); + GL11.glPushMatrix(); + GL11.glTranslated(x + 0.5, y + 0.3, z + 0.5); + GL11.glEnable(GL12.GL_RESCALE_NORMAL); + GL11.glEnable(GL11.GL_BLEND); + GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); + GL11.glAlphaFunc(GL11.GL_GREATER, 0.05F); - double time = ClientTickHandler.ticksInGame + pticks; - GL11.glColor4f(1F, 1F, 1F, 1F); + double time = ClientTickHandler.ticksInGame + pticks; + GL11.glColor4f(1F, 1F, 1F, 1F); - float scale = 0.75F; - GL11.glScalef(scale, scale, scale); - Tessellator tessellator = Tessellator.instance; + float scale = 0.75F; + GL11.glScalef(scale, scale, scale); + Tessellator tessellator = Tessellator.instance; - GL11.glPushMatrix(); - float r = 180.0F - RenderManager.instance.playerViewY; - GL11.glRotatef(r, 0F, 1F, 0F); - GL11.glRotatef(-RenderManager.instance.playerViewX, 1F, 0F, 0F); + GL11.glPushMatrix(); + float r = 180.0F - RenderManager.instance.playerViewY; + GL11.glRotatef(r, 0F, 1F, 0F); + GL11.glRotatef(-RenderManager.instance.playerViewX, 1F, 0F, 0F); - float off = 0.25F; - GL11.glTranslatef(0F, off, 0F); - GL11.glRotated(time, 0F, 0F, 1F); - GL11.glTranslatef(0F, -off, 0F); + float off = 0.25F; + GL11.glTranslatef(0F, off, 0F); + GL11.glRotated(time, 0F, 0F, 1F); + GL11.glTranslatef(0F, -off, 0F); - mc.renderEngine.bindTexture(TextureMap.locationBlocksTexture); - ShaderHelper.useShader(ShaderHelper.halo); - func_77026_a(tessellator, iicon); - ShaderHelper.releaseShader(); - - GL11.glPopMatrix(); - GL11.glColor4f(1F, 1F, 1F, 1F); - GL11.glDisable(GL11.GL_BLEND); - GL11.glDisable(GL12.GL_RESCALE_NORMAL); - GL11.glPopMatrix(); - } + mc.renderEngine.bindTexture(TextureMap.locationBlocksTexture); + ShaderHelper.useShader(ShaderHelper.halo); + func_77026_a(tessellator, iicon); + ShaderHelper.releaseShader(); - private void func_77026_a(Tessellator p_77026_1_, IIcon p_77026_2_) { - float f = p_77026_2_.getMinU(); - float f1 = p_77026_2_.getMaxU(); - float f2 = p_77026_2_.getMinV(); - float f3 = p_77026_2_.getMaxV(); - float size = f1 - f; - float pad = size / 8F; - f += pad; - f1 -= pad; - f2 += pad; - f3 -= pad; - - float f4 = 1.0F; - float f5 = 0.5F; - float f6 = 0.25F; + GL11.glPopMatrix(); + GL11.glColor4f(1F, 1F, 1F, 1F); + GL11.glDisable(GL11.GL_BLEND); + GL11.glDisable(GL12.GL_RESCALE_NORMAL); + GL11.glPopMatrix(); + } - p_77026_1_.startDrawingQuads(); - p_77026_1_.setNormal(0.0F, 1.0F, 0.0F); - p_77026_1_.setBrightness(240); - p_77026_1_.addVertexWithUV(0.0F - f5, 0.0F - f6, 0.0D, f, f3); - p_77026_1_.addVertexWithUV(f4 - f5, 0.0F - f6, 0.0D, f1, f3); - p_77026_1_.addVertexWithUV(f4 - f5, f4 - f6, 0.0D, f1, f2); - p_77026_1_.addVertexWithUV(0.0F - f5, f4 - f6, 0.0D, f, f2); - p_77026_1_.draw(); + private void func_77026_a(Tessellator p_77026_1_, IIcon p_77026_2_) { + float f = p_77026_2_.getMinU(); + float f1 = p_77026_2_.getMaxU(); + float f2 = p_77026_2_.getMinV(); + float f3 = p_77026_2_.getMaxV(); + float size = f1 - f; + float pad = size / 8F; + f += pad; + f1 -= pad; + f2 += pad; + f3 -= pad; - } + float f4 = 1.0F; + float f5 = 0.5F; + float f6 = 0.25F; + p_77026_1_.startDrawingQuads(); + p_77026_1_.setNormal(0.0F, 1.0F, 0.0F); + p_77026_1_.setBrightness(240); + p_77026_1_.addVertexWithUV(0.0F - f5, 0.0F - f6, 0.0D, f, f3); + p_77026_1_.addVertexWithUV(f4 - f5, 0.0F - f6, 0.0D, f1, f3); + p_77026_1_.addVertexWithUV(f4 - f5, f4 - f6, 0.0D, f1, f2); + p_77026_1_.addVertexWithUV(0.0F - f5, f4 - f6, 0.0D, f, f2); + p_77026_1_.draw(); + } } diff --git a/src/main/java/vazkii/botania/client/render/tile/RenderTilePool.java b/src/main/java/vazkii/botania/client/render/tile/RenderTilePool.java index d0395960bc..90d067bb2f 100644 --- a/src/main/java/vazkii/botania/client/render/tile/RenderTilePool.java +++ b/src/main/java/vazkii/botania/client/render/tile/RenderTilePool.java @@ -2,17 +2,16 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jan 26, 2014, 12:25:11 AM (GMT)] */ package vazkii.botania.client.render.tile; import java.awt.Color; import java.util.Random; - import net.minecraft.block.Block; import net.minecraft.client.Minecraft; import net.minecraft.client.renderer.Tessellator; @@ -23,10 +22,8 @@ import net.minecraft.tileentity.TileEntity; import net.minecraft.util.IIcon; import net.minecraft.util.ResourceLocation; - import org.lwjgl.opengl.GL11; import org.lwjgl.opengl.GL12; - import vazkii.botania.api.mana.IPoolOverlayProvider; import vazkii.botania.client.core.handler.ClientTickHandler; import vazkii.botania.client.core.handler.MultiblockRenderHandler; @@ -38,129 +35,130 @@ public class RenderTilePool extends TileEntitySpecialRenderer { - private static final ResourceLocation texture = new ResourceLocation(LibResources.MODEL_POOL); - private static final ResourceLocation textureInf = new ResourceLocation(LibResources.MODEL_INFINITE_POOL); - private static final ResourceLocation textureDil = new ResourceLocation(LibResources.MODEL_DILUTED_POOL); - - private static final ModelPool model = new ModelPool(); - RenderItem renderItem = new RenderItem(); - - public static int forceMeta = 0; - public static boolean forceMana = false; - public static int forceManaNumber = -1; - - @Override - public void renderTileEntityAt(TileEntity tileentity, double d0, double d1, double d2, float f) { - TilePool pool = (TilePool) tileentity; - - GL11.glPushMatrix(); - GL11.glEnable(GL11.GL_BLEND); - GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); - GL11.glEnable(GL12.GL_RESCALE_NORMAL); - float a = MultiblockRenderHandler.rendering ? 0.6F : 1F; - GL11.glColor4f(1F, 1F, 1F, a); - GL11.glTranslated(d0, d1, d2); - boolean inf = tileentity.getWorldObj() == null ? forceMeta == 1 : tileentity.getBlockMetadata() == 1; - boolean dil = tileentity.getWorldObj() == null ? forceMeta == 2 : tileentity.getBlockMetadata() == 2; - boolean fab = tileentity.getWorldObj() == null ? forceMeta == 3 : tileentity.getBlockMetadata() == 3; - - Minecraft.getMinecraft().renderEngine.bindTexture(inf ? textureInf : dil ? textureDil : texture); - - GL11.glTranslatef(0.5F, 1.5F, 0.5F); - GL11.glScalef(1F, -1F, -1F); - if(fab) { - float time = ClientTickHandler.ticksInGame + ClientTickHandler.partialTicks; - if(tileentity != null) - time += new Random(tileentity.xCoord ^ tileentity.yCoord ^ tileentity.zCoord).nextInt(100000); - - Color color = Color.getHSBColor(time * 0.005F, 0.6F, 1F); - GL11.glColor4ub((byte) color.getRed(), (byte) color.getGreen(), (byte) color.getBlue(), (byte) 255); - } else { - int color = pool.color; - float[] acolor = EntitySheep.fleeceColorTable[color]; - GL11.glColor4f(acolor[0], acolor[1], acolor[2], a); - } - - model.render(); - GL11.glColor4f(1F, 1F, 1F, a); - GL11.glScalef(1F, -1F, -1F); - GL11.glEnable(GL12.GL_RESCALE_NORMAL); - - Minecraft.getMinecraft().renderEngine.bindTexture(TextureMap.locationBlocksTexture); - - int mana = pool.getCurrentMana(); - if(forceManaNumber > -1) - mana = forceManaNumber; - int cap = pool.manaCap; - if(cap == -1) - cap = TilePool.MAX_MANA; - - float waterLevel = (float) mana / (float) cap * 0.4F; - if(forceMana) - waterLevel = 0.4F; - - float s = 1F / 16F; - float v = 1F / 8F; - float w = -v * 3.5F; - - if(pool.getWorldObj() != null) { - Block below = pool.getWorldObj().getBlock(pool.xCoord, pool.yCoord - 1, pool.zCoord); - if(below instanceof IPoolOverlayProvider) { - IIcon overlay = ((IPoolOverlayProvider) below).getIcon(pool.getWorldObj(), pool.xCoord, pool.yCoord - 1, pool.zCoord); - if(overlay != null) { - GL11.glPushMatrix(); - GL11.glEnable(GL11.GL_BLEND); - GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); - GL11.glDisable(GL11.GL_ALPHA_TEST); - GL11.glColor4f(1F, 1F, 1F, a * (float) ((Math.sin((ClientTickHandler.ticksInGame + f) / 20.0) + 1) * 0.3 + 0.2)); - GL11.glTranslatef(-0.5F, -1F - 0.43F, -0.5F); - GL11.glRotatef(90F, 1F, 0F, 0F); - GL11.glScalef(s, s, s); - - renderIcon(0, 0, overlay, 16, 16, 240); - - GL11.glEnable(GL11.GL_ALPHA_TEST); - GL11.glDisable(GL11.GL_BLEND); - GL11.glPopMatrix(); - } - } - } - - if(waterLevel > 0) { - s = 1F / 256F * 14F; - GL11.glPushMatrix(); - GL11.glEnable(GL11.GL_BLEND); - GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); - GL11.glDisable(GL11.GL_ALPHA_TEST); - GL11.glColor4f(1F, 1F, 1F, a); - GL11.glTranslatef(w, -1F - (0.43F - waterLevel), w); - GL11.glRotatef(90F, 1F, 0F, 0F); - GL11.glScalef(s, s, s); - - ShaderHelper.useShader(ShaderHelper.manaPool); - renderIcon(0, 0, BlockPool.manaIcon, 16, 16, 240); - ShaderHelper.releaseShader(); - - GL11.glEnable(GL11.GL_ALPHA_TEST); - GL11.glDisable(GL11.GL_BLEND); - GL11.glPopMatrix(); - } - GL11.glPopMatrix(); - - forceMeta = 0; - forceMana = false; - forceManaNumber = -1; - } - - public void renderIcon(int par1, int par2, IIcon par3Icon, int par4, int par5, int brightness) { - Tessellator tessellator = Tessellator.instance; - tessellator.startDrawingQuads(); - tessellator.setBrightness(brightness); - tessellator.addVertexWithUV(par1 + 0, par2 + par5, 0, par3Icon.getMinU(), par3Icon.getMaxV()); - tessellator.addVertexWithUV(par1 + par4, par2 + par5, 0, par3Icon.getMaxU(), par3Icon.getMaxV()); - tessellator.addVertexWithUV(par1 + par4, par2 + 0, 0, par3Icon.getMaxU(), par3Icon.getMinV()); - tessellator.addVertexWithUV(par1 + 0, par2 + 0, 0, par3Icon.getMinU(), par3Icon.getMinV()); - tessellator.draw(); - } - + private static final ResourceLocation texture = new ResourceLocation(LibResources.MODEL_POOL); + private static final ResourceLocation textureInf = new ResourceLocation(LibResources.MODEL_INFINITE_POOL); + private static final ResourceLocation textureDil = new ResourceLocation(LibResources.MODEL_DILUTED_POOL); + + private static final ModelPool model = new ModelPool(); + RenderItem renderItem = new RenderItem(); + + public static int forceMeta = 0; + public static boolean forceMana = false; + public static int forceManaNumber = -1; + + @Override + public void renderTileEntityAt(TileEntity tileentity, double d0, double d1, double d2, float f) { + TilePool pool = (TilePool) tileentity; + + GL11.glPushMatrix(); + GL11.glEnable(GL11.GL_BLEND); + GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); + GL11.glEnable(GL12.GL_RESCALE_NORMAL); + float a = MultiblockRenderHandler.rendering ? 0.6F : 1F; + GL11.glColor4f(1F, 1F, 1F, a); + GL11.glTranslated(d0, d1, d2); + boolean inf = tileentity.getWorldObj() == null ? forceMeta == 1 : tileentity.getBlockMetadata() == 1; + boolean dil = tileentity.getWorldObj() == null ? forceMeta == 2 : tileentity.getBlockMetadata() == 2; + boolean fab = tileentity.getWorldObj() == null ? forceMeta == 3 : tileentity.getBlockMetadata() == 3; + + Minecraft.getMinecraft().renderEngine.bindTexture(inf ? textureInf : dil ? textureDil : texture); + + GL11.glTranslatef(0.5F, 1.5F, 0.5F); + GL11.glScalef(1F, -1F, -1F); + if (fab) { + float time = ClientTickHandler.ticksInGame + ClientTickHandler.partialTicks; + if (tileentity != null) + time += new Random(tileentity.xCoord ^ tileentity.yCoord ^ tileentity.zCoord).nextInt(100000); + + Color color = Color.getHSBColor(time * 0.005F, 0.6F, 1F); + GL11.glColor4ub((byte) color.getRed(), (byte) color.getGreen(), (byte) color.getBlue(), (byte) 255); + } else { + int color = pool.color; + float[] acolor = EntitySheep.fleeceColorTable[color]; + GL11.glColor4f(acolor[0], acolor[1], acolor[2], a); + } + + model.render(); + GL11.glColor4f(1F, 1F, 1F, a); + GL11.glScalef(1F, -1F, -1F); + GL11.glEnable(GL12.GL_RESCALE_NORMAL); + + Minecraft.getMinecraft().renderEngine.bindTexture(TextureMap.locationBlocksTexture); + + int mana = pool.getCurrentMana(); + if (forceManaNumber > -1) mana = forceManaNumber; + int cap = pool.manaCap; + if (cap == -1) cap = TilePool.MAX_MANA; + + float waterLevel = (float) mana / (float) cap * 0.4F; + if (forceMana) waterLevel = 0.4F; + + float s = 1F / 16F; + float v = 1F / 8F; + float w = -v * 3.5F; + + if (pool.getWorldObj() != null) { + Block below = pool.getWorldObj().getBlock(pool.xCoord, pool.yCoord - 1, pool.zCoord); + if (below instanceof IPoolOverlayProvider) { + IIcon overlay = ((IPoolOverlayProvider) below) + .getIcon(pool.getWorldObj(), pool.xCoord, pool.yCoord - 1, pool.zCoord); + if (overlay != null) { + GL11.glPushMatrix(); + GL11.glEnable(GL11.GL_BLEND); + GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); + GL11.glDisable(GL11.GL_ALPHA_TEST); + GL11.glColor4f( + 1F, + 1F, + 1F, + a * (float) ((Math.sin((ClientTickHandler.ticksInGame + f) / 20.0) + 1) * 0.3 + 0.2)); + GL11.glTranslatef(-0.5F, -1F - 0.43F, -0.5F); + GL11.glRotatef(90F, 1F, 0F, 0F); + GL11.glScalef(s, s, s); + + renderIcon(0, 0, overlay, 16, 16, 240); + + GL11.glEnable(GL11.GL_ALPHA_TEST); + GL11.glDisable(GL11.GL_BLEND); + GL11.glPopMatrix(); + } + } + } + + if (waterLevel > 0) { + s = 1F / 256F * 14F; + GL11.glPushMatrix(); + GL11.glEnable(GL11.GL_BLEND); + GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); + GL11.glDisable(GL11.GL_ALPHA_TEST); + GL11.glColor4f(1F, 1F, 1F, a); + GL11.glTranslatef(w, -1F - (0.43F - waterLevel), w); + GL11.glRotatef(90F, 1F, 0F, 0F); + GL11.glScalef(s, s, s); + + ShaderHelper.useShader(ShaderHelper.manaPool); + renderIcon(0, 0, BlockPool.manaIcon, 16, 16, 240); + ShaderHelper.releaseShader(); + + GL11.glEnable(GL11.GL_ALPHA_TEST); + GL11.glDisable(GL11.GL_BLEND); + GL11.glPopMatrix(); + } + GL11.glPopMatrix(); + + forceMeta = 0; + forceMana = false; + forceManaNumber = -1; + } + + public void renderIcon(int par1, int par2, IIcon par3Icon, int par4, int par5, int brightness) { + Tessellator tessellator = Tessellator.instance; + tessellator.startDrawingQuads(); + tessellator.setBrightness(brightness); + tessellator.addVertexWithUV(par1 + 0, par2 + par5, 0, par3Icon.getMinU(), par3Icon.getMaxV()); + tessellator.addVertexWithUV(par1 + par4, par2 + par5, 0, par3Icon.getMaxU(), par3Icon.getMaxV()); + tessellator.addVertexWithUV(par1 + par4, par2 + 0, 0, par3Icon.getMaxU(), par3Icon.getMinV()); + tessellator.addVertexWithUV(par1 + 0, par2 + 0, 0, par3Icon.getMinU(), par3Icon.getMinV()); + tessellator.draw(); + } } diff --git a/src/main/java/vazkii/botania/client/render/tile/RenderTilePrism.java b/src/main/java/vazkii/botania/client/render/tile/RenderTilePrism.java index e1c95c37cf..3cfcb3125d 100644 --- a/src/main/java/vazkii/botania/client/render/tile/RenderTilePrism.java +++ b/src/main/java/vazkii/botania/client/render/tile/RenderTilePrism.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jan 17, 2015, 8:05:07 PM (GMT)] */ package vazkii.botania.client.render.tile; @@ -15,9 +15,7 @@ import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer; import net.minecraft.item.ItemStack; import net.minecraft.tileentity.TileEntity; - import org.lwjgl.opengl.GL11; - import vazkii.botania.api.mana.ILens; import vazkii.botania.client.core.handler.ClientTickHandler; import vazkii.botania.client.render.item.RenderLens; @@ -25,27 +23,27 @@ public class RenderTilePrism extends TileEntitySpecialRenderer { - @Override - public void renderTileEntityAt(TileEntity tile, double x, double y, double z, float partTicks) { - TilePrism prism = (TilePrism) tile; - GL11.glPushMatrix(); - GL11.glTranslated(x, y, z); - float pos = (float) Math.sin((ClientTickHandler.ticksInGame + partTicks) * 0.05F) * 0.5F * (1F - 1F / 16F) - 0.5F; - - ItemStack stack = prism.getStackInSlot(0); - - if(stack != null) { - Minecraft.getMinecraft().renderEngine.bindTexture(TextureMap.locationItemsTexture); - if(stack.getItem() instanceof ILens) { - ILens lens = (ILens) stack.getItem(); - GL11.glPushMatrix(); - GL11.glRotatef(90F, 1F, 0F, 0F); - GL11.glTranslatef(0F, 0F, pos); - RenderLens.render(stack, lens.getLensColor(stack)); - GL11.glPopMatrix(); - } - } - GL11.glPopMatrix(); - } - + @Override + public void renderTileEntityAt(TileEntity tile, double x, double y, double z, float partTicks) { + TilePrism prism = (TilePrism) tile; + GL11.glPushMatrix(); + GL11.glTranslated(x, y, z); + float pos = + (float) Math.sin((ClientTickHandler.ticksInGame + partTicks) * 0.05F) * 0.5F * (1F - 1F / 16F) - 0.5F; + + ItemStack stack = prism.getStackInSlot(0); + + if (stack != null) { + Minecraft.getMinecraft().renderEngine.bindTexture(TextureMap.locationItemsTexture); + if (stack.getItem() instanceof ILens) { + ILens lens = (ILens) stack.getItem(); + GL11.glPushMatrix(); + GL11.glRotatef(90F, 1F, 0F, 0F); + GL11.glTranslatef(0F, 0F, pos); + RenderLens.render(stack, lens.getLensColor(stack)); + GL11.glPopMatrix(); + } + } + GL11.glPopMatrix(); + } } diff --git a/src/main/java/vazkii/botania/client/render/tile/RenderTilePump.java b/src/main/java/vazkii/botania/client/render/tile/RenderTilePump.java index 62e5611775..4429fbe980 100644 --- a/src/main/java/vazkii/botania/client/render/tile/RenderTilePump.java +++ b/src/main/java/vazkii/botania/client/render/tile/RenderTilePump.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Mar 18, 2015, 3:15:38 PM (GMT)] */ package vazkii.botania.client.render.tile; @@ -14,43 +14,38 @@ import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.ResourceLocation; - import org.lwjgl.opengl.GL11; import org.lwjgl.opengl.GL12; - import vazkii.botania.client.lib.LibResources; import vazkii.botania.client.model.ModelPump; import vazkii.botania.common.block.tile.mana.TilePump; public class RenderTilePump extends TileEntitySpecialRenderer { - private static final float[] ROTATIONS = new float[] { - 180F, 0F, 90F, 270F - }; - - private static final ResourceLocation texture = new ResourceLocation(LibResources.MODEL_PUMP); - private static final ModelPump model = new ModelPump(); + private static final float[] ROTATIONS = new float[] {180F, 0F, 90F, 270F}; - @Override - public void renderTileEntityAt(TileEntity tileentity, double d0, double d1, double d2, float f) { - TilePump pump = (TilePump) tileentity; + private static final ResourceLocation texture = new ResourceLocation(LibResources.MODEL_PUMP); + private static final ModelPump model = new ModelPump(); - GL11.glPushMatrix(); - GL11.glEnable(GL12.GL_RESCALE_NORMAL); - GL11.glColor4f(1F, 1F, 1F, 1F); - GL11.glTranslated(d0, d1, d2); + @Override + public void renderTileEntityAt(TileEntity tileentity, double d0, double d1, double d2, float f) { + TilePump pump = (TilePump) tileentity; - Minecraft.getMinecraft().renderEngine.bindTexture(texture); - int meta = pump.getWorldObj() != null ? pump.getBlockMetadata() : 0; + GL11.glPushMatrix(); + GL11.glEnable(GL12.GL_RESCALE_NORMAL); + GL11.glColor4f(1F, 1F, 1F, 1F); + GL11.glTranslated(d0, d1, d2); - GL11.glTranslatef(0.5F, 0.5F, 0.5F); - GL11.glScalef(1F, -1F, -1F); - GL11.glRotatef(ROTATIONS[Math.max(Math.min(ROTATIONS.length - 1, meta - 2), 0)], 0F, 1F, 0F); - model.render(Math.max(0F, Math.min(8F, pump.innerRingPos + pump.moving * f))); - GL11.glColor3f(1F, 1F, 1F); - GL11.glScalef(1F, -1F, -1F); - GL11.glEnable(GL12.GL_RESCALE_NORMAL); - GL11.glPopMatrix(); - } + Minecraft.getMinecraft().renderEngine.bindTexture(texture); + int meta = pump.getWorldObj() != null ? pump.getBlockMetadata() : 0; + GL11.glTranslatef(0.5F, 0.5F, 0.5F); + GL11.glScalef(1F, -1F, -1F); + GL11.glRotatef(ROTATIONS[Math.max(Math.min(ROTATIONS.length - 1, meta - 2), 0)], 0F, 1F, 0F); + model.render(Math.max(0F, Math.min(8F, pump.innerRingPos + pump.moving * f))); + GL11.glColor3f(1F, 1F, 1F); + GL11.glScalef(1F, -1F, -1F); + GL11.glEnable(GL12.GL_RESCALE_NORMAL); + GL11.glPopMatrix(); + } } diff --git a/src/main/java/vazkii/botania/client/render/tile/RenderTilePylon.java b/src/main/java/vazkii/botania/client/render/tile/RenderTilePylon.java index 209fe9596d..001b0e0917 100644 --- a/src/main/java/vazkii/botania/client/render/tile/RenderTilePylon.java +++ b/src/main/java/vazkii/botania/client/render/tile/RenderTilePylon.java @@ -2,25 +2,22 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Feb 18, 2014, 10:18:36 PM (GMT)] */ package vazkii.botania.client.render.tile; import java.util.Random; - import net.minecraft.client.Minecraft; import net.minecraft.client.renderer.OpenGlHelper; import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.ResourceLocation; - import org.lwjgl.opengl.GL11; import org.lwjgl.opengl.GL12; - import vazkii.botania.client.core.handler.ClientTickHandler; import vazkii.botania.client.core.handler.MultiblockRenderHandler; import vazkii.botania.client.core.helper.ShaderHelper; @@ -32,109 +29,102 @@ public class RenderTilePylon extends TileEntitySpecialRenderer { - private static final ResourceLocation textureOld = new ResourceLocation(LibResources.MODEL_PYLON_OLD); - private static final ResourceLocation texture = new ResourceLocation(LibResources.MODEL_PYLON); - - private static final ResourceLocation textureGreenOld = new ResourceLocation(LibResources.MODEL_PYLON_GREEN_OLD); - private static final ResourceLocation textureGreen = new ResourceLocation(LibResources.MODEL_PYLON_GREEN); - - private static final ResourceLocation texturePinkOld = new ResourceLocation(LibResources.MODEL_PYLON_PINK_OLD); - private static final ResourceLocation texturePink = new ResourceLocation(LibResources.MODEL_PYLON_PINK); - - IPylonModel model; - public static boolean green = false; - public static boolean pink = false; - - @Override - public void renderTileEntityAt(TileEntity tileentity, double d0, double d1, double d2, float pticks) { - if(model == null) - model = ConfigHandler.oldPylonModel ? new ModelPylonOld() : new ModelPylon(); - - GL11.glPushMatrix(); - GL11.glEnable(GL12.GL_RESCALE_NORMAL); - GL11.glEnable(GL11.GL_BLEND); - GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); - float a = MultiblockRenderHandler.rendering ? 0.6F : 1F; - GL11.glColor4f(1F, 1F, 1F, a); - if(tileentity.getWorldObj() != null) { - green = tileentity.getBlockMetadata() == 1; - pink = tileentity.getBlockMetadata() == 2; - } - - if(ConfigHandler.oldPylonModel) - Minecraft.getMinecraft().renderEngine.bindTexture(pink ? texturePinkOld : green ? textureGreenOld : textureOld); - else Minecraft.getMinecraft().renderEngine.bindTexture(pink ? texturePink : green ? textureGreen : texture); - - double worldTime = tileentity.getWorldObj() == null ? 0 : (double) (ClientTickHandler.ticksInGame + pticks); - - if(tileentity != null) - worldTime += new Random(tileentity.xCoord ^ tileentity.yCoord ^ tileentity.zCoord).nextInt(360); - - if(ConfigHandler.oldPylonModel) { - GL11.glTranslated(d0 + 0.5, d1 + 2.2, d2 + 0.5); - GL11.glScalef(1F, -1.5F, -1F); - } else { - GL11.glTranslated(d0 + 0.2 + (green ? -0.1 : 0), d1 + 0.05, d2 + 0.8 + (green ? 0.1 : 0)); - float scale = green ? 0.8F : 0.6F; - GL11.glScalef(scale, 0.6F, scale); - } - - if(!green) { - GL11.glPushMatrix(); - if(!ConfigHandler.oldPylonModel) - GL11.glTranslatef(0.5F, 0F, -0.5F); - GL11.glRotatef((float) worldTime * 1.5F, 0F, 1F, 0F); - if(!ConfigHandler.oldPylonModel) - GL11.glTranslatef(-0.5F, 0F, 0.5F); - - model.renderRing(); - GL11.glTranslated(0D, Math.sin(worldTime / 20D) / 20 - 0.025, 0D); - model.renderGems(); - GL11.glPopMatrix(); - } - - GL11.glPushMatrix(); - GL11.glTranslated(0D, Math.sin(worldTime / 20D) / 17.5, 0D); - - if(!ConfigHandler.oldPylonModel) - GL11.glTranslatef(0.5F, 0F, -0.5F); - - GL11.glRotatef((float) -worldTime, 0F, 1F, 0F); - if(!ConfigHandler.oldPylonModel) - GL11.glTranslatef(-0.5F, 0F, 0.5F); - - - GL11.glDisable(GL11.GL_CULL_FACE); - model.renderCrystal(); - - GL11.glColor4f(1F, 1F, 1F, a); - if(!ShaderHelper.useShaders()) { - int light = 15728880; - int lightmapX = light % 65536; - int lightmapY = light / 65536; - OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, lightmapX, lightmapY); - float alpha = (float) ((Math.sin(worldTime / 20D) / 2D + 0.5) / (ConfigHandler.oldPylonModel ? 1D : 2D)); - GL11.glColor4f(1F, 1F, 1F, a * (alpha + 0.183F)); - } - - GL11.glDisable(GL11.GL_ALPHA_TEST); - GL11.glScalef(1.1F, 1.1F, 1.1F); - if(!ConfigHandler.oldPylonModel) - GL11.glTranslatef(-0.05F, -0.1F, 0.05F); - else GL11.glTranslatef(0F, -0.09F, 0F); - - ShaderHelper.useShader(ShaderHelper.pylonGlow); - model.renderCrystal(); - ShaderHelper.releaseShader(); - - GL11.glEnable(GL11.GL_ALPHA_TEST); - GL11.glEnable(GL11.GL_CULL_FACE); - GL11.glPopMatrix(); - - GL11.glDisable(GL11.GL_BLEND); - GL11.glEnable(GL12.GL_RESCALE_NORMAL); - GL11.glPopMatrix(); - } - - + private static final ResourceLocation textureOld = new ResourceLocation(LibResources.MODEL_PYLON_OLD); + private static final ResourceLocation texture = new ResourceLocation(LibResources.MODEL_PYLON); + + private static final ResourceLocation textureGreenOld = new ResourceLocation(LibResources.MODEL_PYLON_GREEN_OLD); + private static final ResourceLocation textureGreen = new ResourceLocation(LibResources.MODEL_PYLON_GREEN); + + private static final ResourceLocation texturePinkOld = new ResourceLocation(LibResources.MODEL_PYLON_PINK_OLD); + private static final ResourceLocation texturePink = new ResourceLocation(LibResources.MODEL_PYLON_PINK); + + IPylonModel model; + public static boolean green = false; + public static boolean pink = false; + + @Override + public void renderTileEntityAt(TileEntity tileentity, double d0, double d1, double d2, float pticks) { + if (model == null) model = ConfigHandler.oldPylonModel ? new ModelPylonOld() : new ModelPylon(); + + GL11.glPushMatrix(); + GL11.glEnable(GL12.GL_RESCALE_NORMAL); + GL11.glEnable(GL11.GL_BLEND); + GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); + float a = MultiblockRenderHandler.rendering ? 0.6F : 1F; + GL11.glColor4f(1F, 1F, 1F, a); + if (tileentity.getWorldObj() != null) { + green = tileentity.getBlockMetadata() == 1; + pink = tileentity.getBlockMetadata() == 2; + } + + if (ConfigHandler.oldPylonModel) + Minecraft.getMinecraft() + .renderEngine + .bindTexture(pink ? texturePinkOld : green ? textureGreenOld : textureOld); + else Minecraft.getMinecraft().renderEngine.bindTexture(pink ? texturePink : green ? textureGreen : texture); + + double worldTime = tileentity.getWorldObj() == null ? 0 : (double) (ClientTickHandler.ticksInGame + pticks); + + if (tileentity != null) + worldTime += new Random(tileentity.xCoord ^ tileentity.yCoord ^ tileentity.zCoord).nextInt(360); + + if (ConfigHandler.oldPylonModel) { + GL11.glTranslated(d0 + 0.5, d1 + 2.2, d2 + 0.5); + GL11.glScalef(1F, -1.5F, -1F); + } else { + GL11.glTranslated(d0 + 0.2 + (green ? -0.1 : 0), d1 + 0.05, d2 + 0.8 + (green ? 0.1 : 0)); + float scale = green ? 0.8F : 0.6F; + GL11.glScalef(scale, 0.6F, scale); + } + + if (!green) { + GL11.glPushMatrix(); + if (!ConfigHandler.oldPylonModel) GL11.glTranslatef(0.5F, 0F, -0.5F); + GL11.glRotatef((float) worldTime * 1.5F, 0F, 1F, 0F); + if (!ConfigHandler.oldPylonModel) GL11.glTranslatef(-0.5F, 0F, 0.5F); + + model.renderRing(); + GL11.glTranslated(0D, Math.sin(worldTime / 20D) / 20 - 0.025, 0D); + model.renderGems(); + GL11.glPopMatrix(); + } + + GL11.glPushMatrix(); + GL11.glTranslated(0D, Math.sin(worldTime / 20D) / 17.5, 0D); + + if (!ConfigHandler.oldPylonModel) GL11.glTranslatef(0.5F, 0F, -0.5F); + + GL11.glRotatef((float) -worldTime, 0F, 1F, 0F); + if (!ConfigHandler.oldPylonModel) GL11.glTranslatef(-0.5F, 0F, 0.5F); + + GL11.glDisable(GL11.GL_CULL_FACE); + model.renderCrystal(); + + GL11.glColor4f(1F, 1F, 1F, a); + if (!ShaderHelper.useShaders()) { + int light = 15728880; + int lightmapX = light % 65536; + int lightmapY = light / 65536; + OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, lightmapX, lightmapY); + float alpha = (float) ((Math.sin(worldTime / 20D) / 2D + 0.5) / (ConfigHandler.oldPylonModel ? 1D : 2D)); + GL11.glColor4f(1F, 1F, 1F, a * (alpha + 0.183F)); + } + + GL11.glDisable(GL11.GL_ALPHA_TEST); + GL11.glScalef(1.1F, 1.1F, 1.1F); + if (!ConfigHandler.oldPylonModel) GL11.glTranslatef(-0.05F, -0.1F, 0.05F); + else GL11.glTranslatef(0F, -0.09F, 0F); + + ShaderHelper.useShader(ShaderHelper.pylonGlow); + model.renderCrystal(); + ShaderHelper.releaseShader(); + + GL11.glEnable(GL11.GL_ALPHA_TEST); + GL11.glEnable(GL11.GL_CULL_FACE); + GL11.glPopMatrix(); + + GL11.glDisable(GL11.GL_BLEND); + GL11.glEnable(GL12.GL_RESCALE_NORMAL); + GL11.glPopMatrix(); + } } diff --git a/src/main/java/vazkii/botania/client/render/tile/RenderTileRedString.java b/src/main/java/vazkii/botania/client/render/tile/RenderTileRedString.java index 24910351c5..ecfb07a829 100644 --- a/src/main/java/vazkii/botania/client/render/tile/RenderTileRedString.java +++ b/src/main/java/vazkii/botania/client/render/tile/RenderTileRedString.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Nov 14, 2014, 6:52:09 PM (GMT)] */ package vazkii.botania.client.render.tile; @@ -17,10 +17,9 @@ public class RenderTileRedString extends TileEntitySpecialRenderer { - @Override - public void renderTileEntityAt(TileEntity tileentity, double x, double y, double z, float partticks) { - TileRedString trs = (TileRedString) tileentity; - RedStringRenderer.redStringTiles.add(trs); - } + @Override + public void renderTileEntityAt(TileEntity tileentity, double x, double y, double z, float partticks) { + TileRedString trs = (TileRedString) tileentity; + RedStringRenderer.redStringTiles.add(trs); + } } - diff --git a/src/main/java/vazkii/botania/client/render/tile/RenderTileRuneAltar.java b/src/main/java/vazkii/botania/client/render/tile/RenderTileRuneAltar.java index 245c62cd91..2ffd56bdc8 100644 --- a/src/main/java/vazkii/botania/client/render/tile/RenderTileRuneAltar.java +++ b/src/main/java/vazkii/botania/client/render/tile/RenderTileRuneAltar.java @@ -2,16 +2,15 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Feb 2, 2014, 6:34:45 PM (GMT)] */ package vazkii.botania.client.render.tile; import java.awt.Color; - import net.minecraft.block.Block; import net.minecraft.client.Minecraft; import net.minecraft.client.renderer.ItemRenderer; @@ -25,9 +24,7 @@ import net.minecraft.tileentity.TileEntity; import net.minecraft.util.IIcon; import net.minecraftforge.client.ForgeHooksClient; - import org.lwjgl.opengl.GL11; - import vazkii.botania.client.core.handler.ClientTickHandler; import vazkii.botania.client.core.helper.RenderHelper; import vazkii.botania.client.model.ModelSpinningCubes; @@ -35,93 +32,114 @@ public class RenderTileRuneAltar extends TileEntitySpecialRenderer { - ModelSpinningCubes cubes = new ModelSpinningCubes(); - RenderBlocks renderBlocks = new RenderBlocks(); - - @Override - public void renderTileEntityAt(TileEntity tileentity, double x, double y, double z, float partticks) { - TileRuneAltar altar = (TileRuneAltar) tileentity; - - GL11.glPushMatrix(); - GL11.glColor4f(1F, 1F, 1F, 1F); - GL11.glTranslated(x, y, z); - - int items = 0; - for(int i = 0; i < altar.getSizeInventory(); i++) - if(altar.getStackInSlot(i) == null) - break; - else items++; - float[] angles = new float[altar.getSizeInventory()]; - - float anglePer = 360F / items; - float totalAngle = 0F; - for(int i = 0; i < angles.length; i++) - angles[i] = totalAngle += anglePer; - - double time = ClientTickHandler.ticksInGame + partticks; - - for(int i = 0; i < altar.getSizeInventory(); i++) { - GL11.glPushMatrix(); - GL11.glScalef(0.5F, 0.5F, 0.5F); - GL11.glTranslatef(1F, 2.5F, 1F); - GL11.glRotatef(angles[i] + (float) time, 0F, 1F, 0F); - GL11.glTranslatef(2.25F, 0F, 0.5F); - GL11.glRotatef(90F, 0F, 1F, 0F); - GL11.glTranslated(0D, 0.15 * Math.sin((time + i * 10) / 5D), 0F); - ItemStack stack = altar.getStackInSlot(i); - Minecraft mc = Minecraft.getMinecraft(); - if(stack != null) { - mc.renderEngine.bindTexture(stack.getItem() instanceof ItemBlock ? TextureMap.locationBlocksTexture : TextureMap.locationItemsTexture); - - GL11.glScalef(2F, 2F, 2F); - if(!ForgeHooksClient.renderEntityItem(new EntityItem(altar.getWorldObj(), altar.xCoord, altar.yCoord, altar.zCoord, stack), stack, 0F, 0F, altar.getWorldObj().rand, mc.renderEngine, renderBlocks, 1)) { - GL11.glScalef(0.5F, 0.5F, 0.5F); - if(stack.getItem() instanceof ItemBlock && RenderBlocks.renderItemIn3d(Block.getBlockFromItem(stack.getItem()).getRenderType())) { - GL11.glScalef(0.5F, 0.5F, 0.5F); - GL11.glTranslatef(1F, 1.1F, 0F); - renderBlocks.renderBlockAsItem(Block.getBlockFromItem(stack.getItem()), stack.getItemDamage(), 1F); - GL11.glTranslatef(-1F, -1.1F, 0F); - GL11.glScalef(2F, 2F, 2F); - } else { - int renderPass = 0; - do { - IIcon icon = stack.getItem().getIcon(stack, renderPass); - if(icon != null) { - Color color = new Color(stack.getItem().getColorFromItemStack(stack, renderPass)); - GL11.glColor3ub((byte) color.getRed(), (byte) color.getGreen(), (byte) color.getBlue()); - float f = icon.getMinU(); - float f1 = icon.getMaxU(); - float f2 = icon.getMinV(); - float f3 = icon.getMaxV(); - ItemRenderer.renderItemIn2D(Tessellator.instance, f1, f2, f, f3, icon.getIconWidth(), icon.getIconHeight(), 1F / 16F); - GL11.glColor3f(1F, 1F, 1F); - } - renderPass++; - } while(renderPass < stack.getItem().getRenderPasses(stack.getItemDamage())); - } - } - } - GL11.glPopMatrix(); - } - - GL11.glDisable(GL11.GL_ALPHA_TEST); - GL11.glPushMatrix(); - GL11.glTranslatef(0.5F, 1.8F, 0.5F); - GL11.glRotatef(180F, 1F, 0F, 1F); - int repeat = 15; - cubes.renderSpinningCubes(2, repeat, repeat); - GL11.glPopMatrix(); - - GL11.glTranslatef(0F, 0.2F, 0F); - float scale = altar.getTargetMana() == 0 ? 0 : (float) altar.getCurrentMana() / (float) altar.getTargetMana() / 75F; - - if(scale != 0) { - int seed = altar.xCoord ^ altar.yCoord ^ altar.zCoord; - GL11.glTranslatef(0.5F, 0.7F, 0.5F); - RenderHelper.renderStar(0x00E4D7, scale, scale, scale, seed); - } - GL11.glEnable(GL11.GL_ALPHA_TEST); - - GL11.glPopMatrix(); - } + ModelSpinningCubes cubes = new ModelSpinningCubes(); + RenderBlocks renderBlocks = new RenderBlocks(); + + @Override + public void renderTileEntityAt(TileEntity tileentity, double x, double y, double z, float partticks) { + TileRuneAltar altar = (TileRuneAltar) tileentity; + + GL11.glPushMatrix(); + GL11.glColor4f(1F, 1F, 1F, 1F); + GL11.glTranslated(x, y, z); + + int items = 0; + for (int i = 0; i < altar.getSizeInventory(); i++) + if (altar.getStackInSlot(i) == null) break; + else items++; + float[] angles = new float[altar.getSizeInventory()]; + + float anglePer = 360F / items; + float totalAngle = 0F; + for (int i = 0; i < angles.length; i++) angles[i] = totalAngle += anglePer; + + double time = ClientTickHandler.ticksInGame + partticks; + + for (int i = 0; i < altar.getSizeInventory(); i++) { + GL11.glPushMatrix(); + GL11.glScalef(0.5F, 0.5F, 0.5F); + GL11.glTranslatef(1F, 2.5F, 1F); + GL11.glRotatef(angles[i] + (float) time, 0F, 1F, 0F); + GL11.glTranslatef(2.25F, 0F, 0.5F); + GL11.glRotatef(90F, 0F, 1F, 0F); + GL11.glTranslated(0D, 0.15 * Math.sin((time + i * 10) / 5D), 0F); + ItemStack stack = altar.getStackInSlot(i); + Minecraft mc = Minecraft.getMinecraft(); + if (stack != null) { + mc.renderEngine.bindTexture( + stack.getItem() instanceof ItemBlock + ? TextureMap.locationBlocksTexture + : TextureMap.locationItemsTexture); + + GL11.glScalef(2F, 2F, 2F); + if (!ForgeHooksClient.renderEntityItem( + new EntityItem(altar.getWorldObj(), altar.xCoord, altar.yCoord, altar.zCoord, stack), + stack, + 0F, + 0F, + altar.getWorldObj().rand, + mc.renderEngine, + renderBlocks, + 1)) { + GL11.glScalef(0.5F, 0.5F, 0.5F); + if (stack.getItem() instanceof ItemBlock + && RenderBlocks.renderItemIn3d( + Block.getBlockFromItem(stack.getItem()).getRenderType())) { + GL11.glScalef(0.5F, 0.5F, 0.5F); + GL11.glTranslatef(1F, 1.1F, 0F); + renderBlocks.renderBlockAsItem( + Block.getBlockFromItem(stack.getItem()), stack.getItemDamage(), 1F); + GL11.glTranslatef(-1F, -1.1F, 0F); + GL11.glScalef(2F, 2F, 2F); + } else { + int renderPass = 0; + do { + IIcon icon = stack.getItem().getIcon(stack, renderPass); + if (icon != null) { + Color color = new Color(stack.getItem().getColorFromItemStack(stack, renderPass)); + GL11.glColor3ub((byte) color.getRed(), (byte) color.getGreen(), (byte) color.getBlue()); + float f = icon.getMinU(); + float f1 = icon.getMaxU(); + float f2 = icon.getMinV(); + float f3 = icon.getMaxV(); + ItemRenderer.renderItemIn2D( + Tessellator.instance, + f1, + f2, + f, + f3, + icon.getIconWidth(), + icon.getIconHeight(), + 1F / 16F); + GL11.glColor3f(1F, 1F, 1F); + } + renderPass++; + } while (renderPass < stack.getItem().getRenderPasses(stack.getItemDamage())); + } + } + } + GL11.glPopMatrix(); + } + + GL11.glDisable(GL11.GL_ALPHA_TEST); + GL11.glPushMatrix(); + GL11.glTranslatef(0.5F, 1.8F, 0.5F); + GL11.glRotatef(180F, 1F, 0F, 1F); + int repeat = 15; + cubes.renderSpinningCubes(2, repeat, repeat); + GL11.glPopMatrix(); + + GL11.glTranslatef(0F, 0.2F, 0F); + float scale = + altar.getTargetMana() == 0 ? 0 : (float) altar.getCurrentMana() / (float) altar.getTargetMana() / 75F; + + if (scale != 0) { + int seed = altar.xCoord ^ altar.yCoord ^ altar.zCoord; + GL11.glTranslatef(0.5F, 0.7F, 0.5F); + RenderHelper.renderStar(0x00E4D7, scale, scale, scale, seed); + } + GL11.glEnable(GL11.GL_ALPHA_TEST); + + GL11.glPopMatrix(); + } } diff --git a/src/main/java/vazkii/botania/client/render/tile/RenderTileSkullOverride.java b/src/main/java/vazkii/botania/client/render/tile/RenderTileSkullOverride.java index 5d49f06fe6..c89e8d75d3 100644 --- a/src/main/java/vazkii/botania/client/render/tile/RenderTileSkullOverride.java +++ b/src/main/java/vazkii/botania/client/render/tile/RenderTileSkullOverride.java @@ -2,90 +2,108 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [? (GMT)] */ package vazkii.botania.client.render.tile; +import com.mojang.authlib.GameProfile; +import com.mojang.authlib.minecraft.MinecraftProfileTexture; import java.util.Map; - import net.minecraft.client.Minecraft; import net.minecraft.client.entity.AbstractClientPlayer; import net.minecraft.client.renderer.tileentity.TileEntitySkullRenderer; import net.minecraft.tileentity.TileEntitySkull; import net.minecraft.util.ResourceLocation; - import org.lwjgl.opengl.GL11; import org.lwjgl.opengl.GL12; - import vazkii.botania.client.core.helper.ShaderHelper; import vazkii.botania.client.model.ModelSkullOverride; import vazkii.botania.client.render.entity.RenderDoppleganger; import vazkii.botania.common.block.tile.TileGaiaHead; -import com.mojang.authlib.GameProfile; -import com.mojang.authlib.minecraft.MinecraftProfileTexture; - public class RenderTileSkullOverride extends TileEntitySkullRenderer { - public static final ModelSkullOverride modelSkull = new ModelSkullOverride(); + public static final ModelSkullOverride modelSkull = new ModelSkullOverride(); - @Override - public void renderTileEntityAt(TileEntitySkull p_147500_1_, double p_147500_2_, double p_147500_4_, double p_147500_6_, float p_147500_8_) { - render(p_147500_1_, (float) p_147500_2_, (float) p_147500_4_, (float) p_147500_6_, p_147500_1_.getBlockMetadata() & 7, p_147500_1_.func_145906_b() * 360 / 16.0F, p_147500_1_.func_145904_a(), p_147500_1_.func_152108_a()); - } + @Override + public void renderTileEntityAt( + TileEntitySkull p_147500_1_, + double p_147500_2_, + double p_147500_4_, + double p_147500_6_, + float p_147500_8_) { + render( + p_147500_1_, + (float) p_147500_2_, + (float) p_147500_4_, + (float) p_147500_6_, + p_147500_1_.getBlockMetadata() & 7, + p_147500_1_.func_145906_b() * 360 / 16.0F, + p_147500_1_.func_145904_a(), + p_147500_1_.func_152108_a()); + } - public void render(TileEntitySkull skull, float par1, float par2, float par3, int par4, float par5, int par6, GameProfile gameProfile) { - boolean gaia = skull instanceof TileGaiaHead; - if(par6 == 3 || gaia) { - ResourceLocation resourcelocation = AbstractClientPlayer.locationStevePng; - Minecraft minecraft = Minecraft.getMinecraft(); - if(gaia) - resourcelocation = minecraft.thePlayer.getLocationSkin(); - else if(gameProfile != null) { - Map map = minecraft.func_152342_ad().func_152788_a(gameProfile); + public void render( + TileEntitySkull skull, + float par1, + float par2, + float par3, + int par4, + float par5, + int par6, + GameProfile gameProfile) { + boolean gaia = skull instanceof TileGaiaHead; + if (par6 == 3 || gaia) { + ResourceLocation resourcelocation = AbstractClientPlayer.locationStevePng; + Minecraft minecraft = Minecraft.getMinecraft(); + if (gaia) resourcelocation = minecraft.thePlayer.getLocationSkin(); + else if (gameProfile != null) { + Map map = minecraft.func_152342_ad().func_152788_a(gameProfile); - if (map.containsKey(MinecraftProfileTexture.Type.SKIN)) { - resourcelocation = minecraft.func_152342_ad().func_152792_a((MinecraftProfileTexture)map.get(MinecraftProfileTexture.Type.SKIN), MinecraftProfileTexture.Type.SKIN); - } - } - bindTexture(resourcelocation); - GL11.glPushMatrix(); - GL11.glDisable(GL11.GL_CULL_FACE); - if (par4 != 1) { - switch (par4) { - case 2: - GL11.glTranslatef(par1 + 0.5F, par2 + 0.25F, par3 + 0.74F); - break; - case 3: - GL11.glTranslatef(par1 + 0.5F, par2 + 0.25F, par3 + 0.26F); - par5 = 180.0F; - break; - case 4: - GL11.glTranslatef(par1 + 0.74F, par2 + 0.25F, par3 + 0.5F); - par5 = 270.0F; - break; - case 5: - default: - GL11.glTranslatef(par1 + 0.26F, par2 + 0.25F, par3 + 0.5F); - par5 = 90.0F; - } - } else GL11.glTranslatef(par1 + 0.5F, par2, par3 + 0.5F); + if (map.containsKey(MinecraftProfileTexture.Type.SKIN)) { + resourcelocation = minecraft + .func_152342_ad() + .func_152792_a( + (MinecraftProfileTexture) map.get(MinecraftProfileTexture.Type.SKIN), + MinecraftProfileTexture.Type.SKIN); + } + } + bindTexture(resourcelocation); + GL11.glPushMatrix(); + GL11.glDisable(GL11.GL_CULL_FACE); + if (par4 != 1) { + switch (par4) { + case 2: + GL11.glTranslatef(par1 + 0.5F, par2 + 0.25F, par3 + 0.74F); + break; + case 3: + GL11.glTranslatef(par1 + 0.5F, par2 + 0.25F, par3 + 0.26F); + par5 = 180.0F; + break; + case 4: + GL11.glTranslatef(par1 + 0.74F, par2 + 0.25F, par3 + 0.5F); + par5 = 270.0F; + break; + case 5: + default: + GL11.glTranslatef(par1 + 0.26F, par2 + 0.25F, par3 + 0.5F); + par5 = 90.0F; + } + } else GL11.glTranslatef(par1 + 0.5F, par2, par3 + 0.5F); - GL11.glEnable(GL12.GL_RESCALE_NORMAL); - GL11.glScalef(-1.0F, -1.0F, 1.0F); - GL11.glEnable(GL11.GL_ALPHA_TEST); - if(gaia) - ShaderHelper.useShader(ShaderHelper.doppleganger, RenderDoppleganger.defaultCallback); + GL11.glEnable(GL12.GL_RESCALE_NORMAL); + GL11.glScalef(-1.0F, -1.0F, 1.0F); + GL11.glEnable(GL11.GL_ALPHA_TEST); + if (gaia) ShaderHelper.useShader(ShaderHelper.doppleganger, RenderDoppleganger.defaultCallback); - modelSkull.render(null, 0F, 0F, 0F, par5, 0F, 0.0625F); + modelSkull.render(null, 0F, 0F, 0F, par5, 0F, 0.0625F); - if(gaia) - ShaderHelper.releaseShader(); - GL11.glPopMatrix(); - } else super.func_152674_a(par1, par2, par3, par4, par5, par6, gameProfile); - } -} \ No newline at end of file + if (gaia) ShaderHelper.releaseShader(); + GL11.glPopMatrix(); + } else super.func_152674_a(par1, par2, par3, par4, par5, par6, gameProfile); + } +} diff --git a/src/main/java/vazkii/botania/client/render/tile/RenderTileSparkChanger.java b/src/main/java/vazkii/botania/client/render/tile/RenderTileSparkChanger.java index 97188418e1..f4cf4d5979 100644 --- a/src/main/java/vazkii/botania/client/render/tile/RenderTileSparkChanger.java +++ b/src/main/java/vazkii/botania/client/render/tile/RenderTileSparkChanger.java @@ -2,16 +2,15 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jun 28, 2015, 10:19:20 PM (GMT)] */ package vazkii.botania.client.render.tile; import java.awt.Color; - import net.minecraft.client.Minecraft; import net.minecraft.client.renderer.ItemRenderer; import net.minecraft.client.renderer.Tessellator; @@ -20,47 +19,45 @@ import net.minecraft.item.ItemStack; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.IIcon; - import org.lwjgl.opengl.GL11; - import vazkii.botania.common.block.tile.TileSparkChanger; public class RenderTileSparkChanger extends TileEntitySpecialRenderer { - @Override - public void renderTileEntityAt(TileEntity tileentity, double d0, double d1, double d2, float pticks) { - GL11.glPushMatrix(); - GL11.glTranslated(d0, d1, d2); - GL11.glRotated(90F, 1F, 0F, 0F); - GL11.glTranslatef(0.8F, 0.2F, -0.22F); - GL11.glColor4f(1F, 1F, 1F, 1F); - ItemStack stack = ((TileSparkChanger) tileentity).getStackInSlot(0); - if(stack != null) { - GL11.glPushMatrix(); - Minecraft.getMinecraft().renderEngine.bindTexture(TextureMap.locationItemsTexture); - float s = 0.6F; - GL11.glScalef(s, s, s); - GL11.glRotatef(180F, 0F, 1F, 0F); - - int renderPass = 0; - do { - IIcon icon = stack.getItem().getIcon(stack, renderPass); - if(icon != null) { - Color color = new Color(stack.getItem().getColorFromItemStack(stack, renderPass)); - GL11.glColor3ub((byte) color.getRed(), (byte) color.getGreen(), (byte) color.getBlue()); - float f = icon.getMinU(); - float f1 = icon.getMaxU(); - float f2 = icon.getMinV(); - float f3 = icon.getMaxV(); - ItemRenderer.renderItemIn2D(Tessellator.instance, f1, f2, f, f3, icon.getIconWidth(), icon.getIconHeight(), 1F / 16F); - GL11.glColor3f(1F, 1F, 1F); - } - renderPass++; - } while(renderPass < stack.getItem().getRenderPasses(stack.getItemDamage())); - GL11.glPopMatrix(); - } - GL11.glColor4f(1F, 1F, 1F, 1F); - GL11.glPopMatrix(); - } - + @Override + public void renderTileEntityAt(TileEntity tileentity, double d0, double d1, double d2, float pticks) { + GL11.glPushMatrix(); + GL11.glTranslated(d0, d1, d2); + GL11.glRotated(90F, 1F, 0F, 0F); + GL11.glTranslatef(0.8F, 0.2F, -0.22F); + GL11.glColor4f(1F, 1F, 1F, 1F); + ItemStack stack = ((TileSparkChanger) tileentity).getStackInSlot(0); + if (stack != null) { + GL11.glPushMatrix(); + Minecraft.getMinecraft().renderEngine.bindTexture(TextureMap.locationItemsTexture); + float s = 0.6F; + GL11.glScalef(s, s, s); + GL11.glRotatef(180F, 0F, 1F, 0F); + + int renderPass = 0; + do { + IIcon icon = stack.getItem().getIcon(stack, renderPass); + if (icon != null) { + Color color = new Color(stack.getItem().getColorFromItemStack(stack, renderPass)); + GL11.glColor3ub((byte) color.getRed(), (byte) color.getGreen(), (byte) color.getBlue()); + float f = icon.getMinU(); + float f1 = icon.getMaxU(); + float f2 = icon.getMinV(); + float f3 = icon.getMaxV(); + ItemRenderer.renderItemIn2D( + Tessellator.instance, f1, f2, f, f3, icon.getIconWidth(), icon.getIconHeight(), 1F / 16F); + GL11.glColor3f(1F, 1F, 1F); + } + renderPass++; + } while (renderPass < stack.getItem().getRenderPasses(stack.getItemDamage())); + GL11.glPopMatrix(); + } + GL11.glColor4f(1F, 1F, 1F, 1F); + GL11.glPopMatrix(); + } } diff --git a/src/main/java/vazkii/botania/client/render/tile/RenderTileSpawnerClaw.java b/src/main/java/vazkii/botania/client/render/tile/RenderTileSpawnerClaw.java index 92628dc63d..c2df14d6aa 100644 --- a/src/main/java/vazkii/botania/client/render/tile/RenderTileSpawnerClaw.java +++ b/src/main/java/vazkii/botania/client/render/tile/RenderTileSpawnerClaw.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jul 23, 2014, 5:46:10 PM (GMT)] */ package vazkii.botania.client.render.tile; @@ -14,34 +14,31 @@ import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.ResourceLocation; - import org.lwjgl.opengl.GL11; import org.lwjgl.opengl.GL12; - import vazkii.botania.client.lib.LibResources; import vazkii.botania.client.model.ModelSpawnerClaw; public class RenderTileSpawnerClaw extends TileEntitySpecialRenderer { - private static final ResourceLocation texture = new ResourceLocation(LibResources.MODEL_SPAWNER_CLAW); - private static final ModelSpawnerClaw model = new ModelSpawnerClaw(); - - @Override - public void renderTileEntityAt(TileEntity var1, double d0, double d1, double d2, float var8) { - GL11.glPushMatrix(); - GL11.glEnable(GL12.GL_RESCALE_NORMAL); - GL11.glColor4f(1F, 1F, 1F, 1F); - GL11.glTranslated(d0, d1, d2); + private static final ResourceLocation texture = new ResourceLocation(LibResources.MODEL_SPAWNER_CLAW); + private static final ModelSpawnerClaw model = new ModelSpawnerClaw(); - Minecraft.getMinecraft().renderEngine.bindTexture(texture); + @Override + public void renderTileEntityAt(TileEntity var1, double d0, double d1, double d2, float var8) { + GL11.glPushMatrix(); + GL11.glEnable(GL12.GL_RESCALE_NORMAL); + GL11.glColor4f(1F, 1F, 1F, 1F); + GL11.glTranslated(d0, d1, d2); - GL11.glTranslatef(0.5F, 1.5F, 0.5F); - GL11.glScalef(1F, -1F, -1F); + Minecraft.getMinecraft().renderEngine.bindTexture(texture); - model.render(); - GL11.glColor3f(1F, 1F, 1F); - GL11.glScalef(1F, -1F, -1F); - GL11.glPopMatrix(); - } + GL11.glTranslatef(0.5F, 1.5F, 0.5F); + GL11.glScalef(1F, -1F, -1F); + model.render(); + GL11.glColor3f(1F, 1F, 1F); + GL11.glScalef(1F, -1F, -1F); + GL11.glPopMatrix(); + } } diff --git a/src/main/java/vazkii/botania/client/render/tile/RenderTileSpreader.java b/src/main/java/vazkii/botania/client/render/tile/RenderTileSpreader.java index e13a116c7c..7f38185507 100644 --- a/src/main/java/vazkii/botania/client/render/tile/RenderTileSpreader.java +++ b/src/main/java/vazkii/botania/client/render/tile/RenderTileSpreader.java @@ -2,17 +2,16 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jan 25, 2014, 9:42:31 PM (GMT)] */ package vazkii.botania.client.render.tile; import java.awt.Color; import java.util.Random; - import net.minecraft.block.Block; import net.minecraft.client.Minecraft; import net.minecraft.client.renderer.RenderBlocks; @@ -22,10 +21,8 @@ import net.minecraft.item.ItemStack; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.ResourceLocation; - import org.lwjgl.opengl.GL11; import org.lwjgl.opengl.GL12; - import vazkii.botania.api.mana.ILens; import vazkii.botania.client.core.handler.ClientTickHandler; import vazkii.botania.client.core.proxy.ClientProxy; @@ -36,94 +33,103 @@ public class RenderTileSpreader extends TileEntitySpecialRenderer { - private static final ResourceLocation texture = new ResourceLocation(LibResources.MODEL_SPREADER); - private static final ResourceLocation textureRs = new ResourceLocation(LibResources.MODEL_SPREADER_REDSTONE); - private static final ResourceLocation textureDw = new ResourceLocation(LibResources.MODEL_SPREADER_DREAMWOOD); - - private static final ResourceLocation textureHalloween = new ResourceLocation(LibResources.MODEL_SPREADER_HALLOWEEN); - private static final ResourceLocation textureRsHalloween = new ResourceLocation(LibResources.MODEL_SPREADER_REDSTONE_HALLOWEEN); - private static final ResourceLocation textureDwHalloween = new ResourceLocation(LibResources.MODEL_SPREADER_DREAMWOOD_HALLOWEEN); - - private static final ModelSpreader model = new ModelSpreader(); - - @Override - public void renderTileEntityAt(TileEntity tileentity, double d0, double d1, double d2, float ticks) { - TileSpreader spreader = (TileSpreader) tileentity; - GL11.glPushMatrix(); - GL11.glEnable(GL12.GL_RESCALE_NORMAL); - GL11.glColor4f(1F, 1F, 1F, 1F); - GL11.glTranslated(d0, d1, d2); - - GL11.glTranslatef(0.5F, 1.5F, 0.5F); - GL11.glRotatef(spreader.rotationX + 90F, 0F, 1F, 0F); - GL11.glTranslatef(0F, -1F, 0F); - GL11.glRotatef(spreader.rotationY, 1F, 0F, 0F); - GL11.glTranslatef(0F, 1F, 0F); - - ResourceLocation r = spreader.isRedstone() ? textureRs : spreader.isDreamwood() ? textureDw : texture; - if(ClientProxy.dootDoot) - r = spreader.isRedstone() ? textureRsHalloween : spreader.isDreamwood() ? textureDwHalloween : textureHalloween; - - Minecraft.getMinecraft().renderEngine.bindTexture(r); - GL11.glScalef(1F, -1F, -1F); - - double time = ClientTickHandler.ticksInGame + ticks; - - if(spreader.isULTRA_SPREADER()) { - Color color = Color.getHSBColor((float) ((time * 5 + new Random(spreader.xCoord ^ spreader.yCoord ^ spreader.zCoord).nextInt(10000)) % 360) / 360F, 0.4F, 0.9F); - GL11.glColor3f(color.getRed() / 255F, color.getGreen() / 255F, color.getBlue() / 255F); - } - model.render(); - GL11.glColor3f(1F, 1F, 1F); - - GL11.glPushMatrix(); - double worldTicks = tileentity.getWorldObj() == null ? 0 : time; - GL11.glRotatef((float) worldTicks % 360, 0F, 1F, 0F); - GL11.glTranslatef(0F, (float) Math.sin(worldTicks / 20.0) * 0.05F, 0F); - model.renderCube(); - GL11.glPopMatrix(); - GL11.glScalef(1F, -1F, -1F); - ItemStack stack = spreader.getStackInSlot(0); - - if(stack != null) { - Minecraft.getMinecraft().renderEngine.bindTexture(TextureMap.locationItemsTexture); - ILens lens = (ILens) stack.getItem(); - GL11.glPushMatrix(); - GL11.glTranslatef(-0.4F, -1.4F, -0.4375F); - GL11.glScalef(0.8F, 0.8F, 0.8F); - RenderLens.render(stack, lens.getLensColor(stack)); - GL11.glPopMatrix(); - } - - if(spreader.paddingColor != -1) { - Minecraft.getMinecraft().renderEngine.bindTexture(TextureMap.locationBlocksTexture); - - Block block = Blocks.carpet; - int color = spreader.paddingColor; - RenderBlocks render = RenderBlocks.getInstance(); - float f = 1F / 16F; - GL11.glTranslatef(0F, -f, 0F); - render.renderBlockAsItem(block, color, 1F); - GL11.glTranslatef(0F, -f * 15, 0F); - render.renderBlockAsItem(block, color, 1F); - GL11.glRotatef(90F, 1F, 0F, 0F); - GL11.glRotatef(90F, 0F, 1F, 0F); - - GL11.glPushMatrix(); - GL11.glScalef(f * 14F, 1F, 1F); - render.renderBlockAsItem(block, color, 1F); - GL11.glPopMatrix(); - - GL11.glRotatef(90F, 1F, 0F, 0F); - GL11.glTranslatef(0F, 0F, -f / 2); - GL11.glScalef(f * 14F, 1F, f * 15F); - render.renderBlockAsItem(block, color, 1F); - GL11.glTranslatef(0F, f * 15F, 0F); - render.renderBlockAsItem(block, color, 1F); - } - - GL11.glEnable(GL12.GL_RESCALE_NORMAL); - GL11.glPopMatrix(); - } - + private static final ResourceLocation texture = new ResourceLocation(LibResources.MODEL_SPREADER); + private static final ResourceLocation textureRs = new ResourceLocation(LibResources.MODEL_SPREADER_REDSTONE); + private static final ResourceLocation textureDw = new ResourceLocation(LibResources.MODEL_SPREADER_DREAMWOOD); + + private static final ResourceLocation textureHalloween = + new ResourceLocation(LibResources.MODEL_SPREADER_HALLOWEEN); + private static final ResourceLocation textureRsHalloween = + new ResourceLocation(LibResources.MODEL_SPREADER_REDSTONE_HALLOWEEN); + private static final ResourceLocation textureDwHalloween = + new ResourceLocation(LibResources.MODEL_SPREADER_DREAMWOOD_HALLOWEEN); + + private static final ModelSpreader model = new ModelSpreader(); + + @Override + public void renderTileEntityAt(TileEntity tileentity, double d0, double d1, double d2, float ticks) { + TileSpreader spreader = (TileSpreader) tileentity; + GL11.glPushMatrix(); + GL11.glEnable(GL12.GL_RESCALE_NORMAL); + GL11.glColor4f(1F, 1F, 1F, 1F); + GL11.glTranslated(d0, d1, d2); + + GL11.glTranslatef(0.5F, 1.5F, 0.5F); + GL11.glRotatef(spreader.rotationX + 90F, 0F, 1F, 0F); + GL11.glTranslatef(0F, -1F, 0F); + GL11.glRotatef(spreader.rotationY, 1F, 0F, 0F); + GL11.glTranslatef(0F, 1F, 0F); + + ResourceLocation r = spreader.isRedstone() ? textureRs : spreader.isDreamwood() ? textureDw : texture; + if (ClientProxy.dootDoot) + r = spreader.isRedstone() + ? textureRsHalloween + : spreader.isDreamwood() ? textureDwHalloween : textureHalloween; + + Minecraft.getMinecraft().renderEngine.bindTexture(r); + GL11.glScalef(1F, -1F, -1F); + + double time = ClientTickHandler.ticksInGame + ticks; + + if (spreader.isULTRA_SPREADER()) { + Color color = Color.getHSBColor( + (float) ((time * 5 + new Random(spreader.xCoord ^ spreader.yCoord ^ spreader.zCoord).nextInt(10000)) + % 360) + / 360F, + 0.4F, + 0.9F); + GL11.glColor3f(color.getRed() / 255F, color.getGreen() / 255F, color.getBlue() / 255F); + } + model.render(); + GL11.glColor3f(1F, 1F, 1F); + + GL11.glPushMatrix(); + double worldTicks = tileentity.getWorldObj() == null ? 0 : time; + GL11.glRotatef((float) worldTicks % 360, 0F, 1F, 0F); + GL11.glTranslatef(0F, (float) Math.sin(worldTicks / 20.0) * 0.05F, 0F); + model.renderCube(); + GL11.glPopMatrix(); + GL11.glScalef(1F, -1F, -1F); + ItemStack stack = spreader.getStackInSlot(0); + + if (stack != null) { + Minecraft.getMinecraft().renderEngine.bindTexture(TextureMap.locationItemsTexture); + ILens lens = (ILens) stack.getItem(); + GL11.glPushMatrix(); + GL11.glTranslatef(-0.4F, -1.4F, -0.4375F); + GL11.glScalef(0.8F, 0.8F, 0.8F); + RenderLens.render(stack, lens.getLensColor(stack)); + GL11.glPopMatrix(); + } + + if (spreader.paddingColor != -1) { + Minecraft.getMinecraft().renderEngine.bindTexture(TextureMap.locationBlocksTexture); + + Block block = Blocks.carpet; + int color = spreader.paddingColor; + RenderBlocks render = RenderBlocks.getInstance(); + float f = 1F / 16F; + GL11.glTranslatef(0F, -f, 0F); + render.renderBlockAsItem(block, color, 1F); + GL11.glTranslatef(0F, -f * 15, 0F); + render.renderBlockAsItem(block, color, 1F); + GL11.glRotatef(90F, 1F, 0F, 0F); + GL11.glRotatef(90F, 0F, 1F, 0F); + + GL11.glPushMatrix(); + GL11.glScalef(f * 14F, 1F, 1F); + render.renderBlockAsItem(block, color, 1F); + GL11.glPopMatrix(); + + GL11.glRotatef(90F, 1F, 0F, 0F); + GL11.glTranslatef(0F, 0F, -f / 2); + GL11.glScalef(f * 14F, 1F, f * 15F); + render.renderBlockAsItem(block, color, 1F); + GL11.glTranslatef(0F, f * 15F, 0F); + render.renderBlockAsItem(block, color, 1F); + } + + GL11.glEnable(GL12.GL_RESCALE_NORMAL); + GL11.glPopMatrix(); + } } diff --git a/src/main/java/vazkii/botania/client/render/tile/RenderTileStarfield.java b/src/main/java/vazkii/botania/client/render/tile/RenderTileStarfield.java index b1991082ac..2ef22f8eca 100644 --- a/src/main/java/vazkii/botania/client/render/tile/RenderTileStarfield.java +++ b/src/main/java/vazkii/botania/client/render/tile/RenderTileStarfield.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Aug 8, 2014, 2:38:15 PM (GMT)] */ package vazkii.botania.client.render.tile; @@ -13,7 +13,6 @@ import java.awt.Color; import java.nio.FloatBuffer; import java.util.Random; - import net.minecraft.client.Minecraft; import net.minecraft.client.renderer.ActiveRenderInfo; import net.minecraft.client.renderer.GLAllocation; @@ -21,7 +20,6 @@ import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.ResourceLocation; - import org.lwjgl.opengl.GL11; // THIS CODE WAS STOLEN FROM THE END PORTAL @@ -31,101 +29,103 @@ // HELP public class RenderTileStarfield extends TileEntitySpecialRenderer { - private static final ResourceLocation field_147529_c = new ResourceLocation("textures/environment/end_sky.png"); - private static final ResourceLocation field_147526_d = new ResourceLocation("textures/entity/end_portal.png"); - private static final Random field_147527_e = new Random(31100L); - FloatBuffer field_147528_b = GLAllocation.createDirectFloatBuffer(16); - @Override - public void renderTileEntityAt(TileEntity p_147500_1_, double p_147500_2_, double p_147500_4_, double p_147500_6_, float p_147500_8_) { - float f1 = (float)field_147501_a.field_147560_j; - float f2 = (float)field_147501_a.field_147561_k; - float f3 = (float)field_147501_a.field_147558_l; - GL11.glDisable(GL11.GL_LIGHTING); - field_147527_e.setSeed(31100L); - float f4 = 0.24F; + private static final ResourceLocation field_147529_c = new ResourceLocation("textures/environment/end_sky.png"); + private static final ResourceLocation field_147526_d = new ResourceLocation("textures/entity/end_portal.png"); + private static final Random field_147527_e = new Random(31100L); + FloatBuffer field_147528_b = GLAllocation.createDirectFloatBuffer(16); + + @Override + public void renderTileEntityAt( + TileEntity p_147500_1_, double p_147500_2_, double p_147500_4_, double p_147500_6_, float p_147500_8_) { + float f1 = (float) field_147501_a.field_147560_j; + float f2 = (float) field_147501_a.field_147561_k; + float f3 = (float) field_147501_a.field_147558_l; + GL11.glDisable(GL11.GL_LIGHTING); + field_147527_e.setSeed(31100L); + float f4 = 0.24F; - for(int i = 0; i < 16; ++i) { - GL11.glPushMatrix(); - float f5 = 16 - i; - float f6 = 0.0625F; - float f7 = 1.0F / (f5 + 1.0F); + for (int i = 0; i < 16; ++i) { + GL11.glPushMatrix(); + float f5 = 16 - i; + float f6 = 0.0625F; + float f7 = 1.0F / (f5 + 1.0F); - if(i == 0) { - bindTexture(field_147529_c); - f7 = 0.1F; - f5 = 65.0F; - f6 = 0.125F; - GL11.glEnable(GL11.GL_BLEND); - GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); - } + if (i == 0) { + bindTexture(field_147529_c); + f7 = 0.1F; + f5 = 65.0F; + f6 = 0.125F; + GL11.glEnable(GL11.GL_BLEND); + GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); + } - if(i == 1) { - bindTexture(field_147526_d); - GL11.glEnable(GL11.GL_BLEND); - GL11.glBlendFunc(GL11.GL_ONE, GL11.GL_ONE); - f6 = 0.5F; - } + if (i == 1) { + bindTexture(field_147526_d); + GL11.glEnable(GL11.GL_BLEND); + GL11.glBlendFunc(GL11.GL_ONE, GL11.GL_ONE); + f6 = 0.5F; + } - float f8 = (float)-(p_147500_4_ + f4); - float f9 = f8 + ActiveRenderInfo.objectY; - float f10 = f8 + f5 + ActiveRenderInfo.objectY; - float f11 = f9 / f10; - f11 += (float)(p_147500_4_ + f4); - GL11.glTranslatef(f1, f11, f3); - GL11.glTexGeni(GL11.GL_S, GL11.GL_TEXTURE_GEN_MODE, GL11.GL_OBJECT_LINEAR); - GL11.glTexGeni(GL11.GL_T, GL11.GL_TEXTURE_GEN_MODE, GL11.GL_OBJECT_LINEAR); - GL11.glTexGeni(GL11.GL_R, GL11.GL_TEXTURE_GEN_MODE, GL11.GL_OBJECT_LINEAR); - GL11.glTexGeni(GL11.GL_Q, GL11.GL_TEXTURE_GEN_MODE, GL11.GL_EYE_LINEAR); - GL11.glTexGen(GL11.GL_S, GL11.GL_OBJECT_PLANE, func_147525_a(1.0F, 0.0F, 0.0F, 0.0F)); - GL11.glTexGen(GL11.GL_T, GL11.GL_OBJECT_PLANE, func_147525_a(0.0F, 0.0F, 1.0F, 0.0F)); - GL11.glTexGen(GL11.GL_R, GL11.GL_OBJECT_PLANE, func_147525_a(0.0F, 0.0F, 0.0F, 1.0F)); - GL11.glTexGen(GL11.GL_Q, GL11.GL_EYE_PLANE, func_147525_a(0.0F, 1.0F, 0.0F, 0.0F)); - GL11.glEnable(GL11.GL_TEXTURE_GEN_S); - GL11.glEnable(GL11.GL_TEXTURE_GEN_T); - GL11.glEnable(GL11.GL_TEXTURE_GEN_R); - GL11.glEnable(GL11.GL_TEXTURE_GEN_Q); - GL11.glPopMatrix(); - GL11.glMatrixMode(GL11.GL_TEXTURE); - GL11.glPushMatrix(); - GL11.glLoadIdentity(); - GL11.glTranslatef(0.0F, Minecraft.getSystemTime() % 20000L / 20000.0F, 0.0F); - GL11.glScalef(f6, f6, f6); - GL11.glTranslatef(0.5F, 0.5F, 0.0F); - GL11.glRotatef((i * i * 4321 + i * 9) * 2.0F, 0.0F, 0.0F, 1.0F); - GL11.glTranslatef(-0.5F, -0.5F, 0.0F); - GL11.glTranslatef(-f1, -f3, -f2); - f9 = f8 + ActiveRenderInfo.objectY; - GL11.glTranslatef(ActiveRenderInfo.objectX * f5 / f9, ActiveRenderInfo.objectZ * f5 / f9, -f2); - Tessellator tessellator = Tessellator.instance; - tessellator.startDrawingQuads(); + float f8 = (float) -(p_147500_4_ + f4); + float f9 = f8 + ActiveRenderInfo.objectY; + float f10 = f8 + f5 + ActiveRenderInfo.objectY; + float f11 = f9 / f10; + f11 += (float) (p_147500_4_ + f4); + GL11.glTranslatef(f1, f11, f3); + GL11.glTexGeni(GL11.GL_S, GL11.GL_TEXTURE_GEN_MODE, GL11.GL_OBJECT_LINEAR); + GL11.glTexGeni(GL11.GL_T, GL11.GL_TEXTURE_GEN_MODE, GL11.GL_OBJECT_LINEAR); + GL11.glTexGeni(GL11.GL_R, GL11.GL_TEXTURE_GEN_MODE, GL11.GL_OBJECT_LINEAR); + GL11.glTexGeni(GL11.GL_Q, GL11.GL_TEXTURE_GEN_MODE, GL11.GL_EYE_LINEAR); + GL11.glTexGen(GL11.GL_S, GL11.GL_OBJECT_PLANE, func_147525_a(1.0F, 0.0F, 0.0F, 0.0F)); + GL11.glTexGen(GL11.GL_T, GL11.GL_OBJECT_PLANE, func_147525_a(0.0F, 0.0F, 1.0F, 0.0F)); + GL11.glTexGen(GL11.GL_R, GL11.GL_OBJECT_PLANE, func_147525_a(0.0F, 0.0F, 0.0F, 1.0F)); + GL11.glTexGen(GL11.GL_Q, GL11.GL_EYE_PLANE, func_147525_a(0.0F, 1.0F, 0.0F, 0.0F)); + GL11.glEnable(GL11.GL_TEXTURE_GEN_S); + GL11.glEnable(GL11.GL_TEXTURE_GEN_T); + GL11.glEnable(GL11.GL_TEXTURE_GEN_R); + GL11.glEnable(GL11.GL_TEXTURE_GEN_Q); + GL11.glPopMatrix(); + GL11.glMatrixMode(GL11.GL_TEXTURE); + GL11.glPushMatrix(); + GL11.glLoadIdentity(); + GL11.glTranslatef(0.0F, Minecraft.getSystemTime() % 20000L / 20000.0F, 0.0F); + GL11.glScalef(f6, f6, f6); + GL11.glTranslatef(0.5F, 0.5F, 0.0F); + GL11.glRotatef((i * i * 4321 + i * 9) * 2.0F, 0.0F, 0.0F, 1.0F); + GL11.glTranslatef(-0.5F, -0.5F, 0.0F); + GL11.glTranslatef(-f1, -f3, -f2); + f9 = f8 + ActiveRenderInfo.objectY; + GL11.glTranslatef(ActiveRenderInfo.objectX * f5 / f9, ActiveRenderInfo.objectZ * f5 / f9, -f2); + Tessellator tessellator = Tessellator.instance; + tessellator.startDrawingQuads(); - Color color = Color.getHSBColor(Minecraft.getSystemTime() / 20F % 360 / 360F, 1F, 1F); - f11 = color.getRed() / 255F; - float f12 = color.getGreen() / 255F; - float f13 = color.getBlue() / 255F; + Color color = Color.getHSBColor(Minecraft.getSystemTime() / 20F % 360 / 360F, 1F, 1F); + f11 = color.getRed() / 255F; + float f12 = color.getGreen() / 255F; + float f13 = color.getBlue() / 255F; - tessellator.setColorRGBA_F(f11 * f7, f12 * f7, f13 * f7, 1.0F); - tessellator.addVertex(p_147500_2_, p_147500_4_ + f4, p_147500_6_); - tessellator.addVertex(p_147500_2_, p_147500_4_ + f4, p_147500_6_ + 1.0D); - tessellator.addVertex(p_147500_2_ + 1.0D, p_147500_4_ + f4, p_147500_6_ + 1.0D); - tessellator.addVertex(p_147500_2_ + 1.0D, p_147500_4_ + f4, p_147500_6_); - tessellator.draw(); - GL11.glPopMatrix(); - GL11.glMatrixMode(GL11.GL_MODELVIEW); - } + tessellator.setColorRGBA_F(f11 * f7, f12 * f7, f13 * f7, 1.0F); + tessellator.addVertex(p_147500_2_, p_147500_4_ + f4, p_147500_6_); + tessellator.addVertex(p_147500_2_, p_147500_4_ + f4, p_147500_6_ + 1.0D); + tessellator.addVertex(p_147500_2_ + 1.0D, p_147500_4_ + f4, p_147500_6_ + 1.0D); + tessellator.addVertex(p_147500_2_ + 1.0D, p_147500_4_ + f4, p_147500_6_); + tessellator.draw(); + GL11.glPopMatrix(); + GL11.glMatrixMode(GL11.GL_MODELVIEW); + } - GL11.glDisable(GL11.GL_BLEND); - GL11.glDisable(GL11.GL_TEXTURE_GEN_S); - GL11.glDisable(GL11.GL_TEXTURE_GEN_T); - GL11.glDisable(GL11.GL_TEXTURE_GEN_R); - GL11.glDisable(GL11.GL_TEXTURE_GEN_Q); - GL11.glEnable(GL11.GL_LIGHTING); - } + GL11.glDisable(GL11.GL_BLEND); + GL11.glDisable(GL11.GL_TEXTURE_GEN_S); + GL11.glDisable(GL11.GL_TEXTURE_GEN_T); + GL11.glDisable(GL11.GL_TEXTURE_GEN_R); + GL11.glDisable(GL11.GL_TEXTURE_GEN_Q); + GL11.glEnable(GL11.GL_LIGHTING); + } - private FloatBuffer func_147525_a(float p_147525_1_, float p_147525_2_, float p_147525_3_, float p_147525_4_) { - field_147528_b.clear(); - field_147528_b.put(p_147525_1_).put(p_147525_2_).put(p_147525_3_).put(p_147525_4_); - field_147528_b.flip(); - return field_147528_b; - } + private FloatBuffer func_147525_a(float p_147525_1_, float p_147525_2_, float p_147525_3_, float p_147525_4_) { + field_147528_b.clear(); + field_147528_b.put(p_147525_1_).put(p_147525_2_).put(p_147525_3_).put(p_147525_4_); + field_147528_b.flip(); + return field_147528_b; + } } diff --git a/src/main/java/vazkii/botania/client/render/tile/RenderTileTerraPlate.java b/src/main/java/vazkii/botania/client/render/tile/RenderTileTerraPlate.java index c87a336dfe..def9f91135 100644 --- a/src/main/java/vazkii/botania/client/render/tile/RenderTileTerraPlate.java +++ b/src/main/java/vazkii/botania/client/render/tile/RenderTileTerraPlate.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Nov 8, 2014, 7:20:26 PM (GMT)] */ package vazkii.botania.client.render.tile; @@ -17,9 +17,7 @@ import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.IIcon; - import org.lwjgl.opengl.GL11; - import vazkii.botania.client.core.handler.ClientTickHandler; import vazkii.botania.client.core.helper.ShaderHelper; import vazkii.botania.common.block.mana.BlockTerraPlate; @@ -27,54 +25,53 @@ public class RenderTileTerraPlate extends TileEntitySpecialRenderer { - @Override - public void renderTileEntityAt(TileEntity tileentity, double d0, double d1, double d2, float f) { - TileTerraPlate plate = (TileTerraPlate) tileentity; - - float max = TileTerraPlate.MAX_MANA / 10F; - float alphaMod = Math.min(max, plate.getCurrentMana()) / max; - GL11.glPushMatrix(); - GL11.glTranslated(d0, d1, d2); + @Override + public void renderTileEntityAt(TileEntity tileentity, double d0, double d1, double d2, float f) { + TileTerraPlate plate = (TileTerraPlate) tileentity; - GL11.glRotated(90F, 1F, 0F, 0F); - GL11.glTranslatef(0F, 0F, -3F / 16F - 0.001F); + float max = TileTerraPlate.MAX_MANA / 10F; + float alphaMod = Math.min(max, plate.getCurrentMana()) / max; + GL11.glPushMatrix(); + GL11.glTranslated(d0, d1, d2); - GL11.glEnable(GL11.GL_BLEND); - GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); - GL11.glColor4f(1F, 1F, 1F, 1F); - GL11.glDisable(GL11.GL_ALPHA_TEST); - float alpha = (float) ((Math.sin((ClientTickHandler.ticksInGame + f) / 8D) + 1D) / 5D + 0.6D) * alphaMod; - if(ShaderHelper.useShaders()) - GL11.glColor4f(1F, 1F, 1F, alpha); - else { - int light = 15728880; - int lightmapX = light % 65536; - int lightmapY = light / 65536; - OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, lightmapX, lightmapY); - GL11.glColor4f(0.6F + (float) ((Math.cos((ClientTickHandler.ticksInGame + f) / 6D) + 1D) / 5D), 0.1F, 0.9F, alpha); - } + GL11.glRotated(90F, 1F, 0F, 0F); + GL11.glTranslatef(0F, 0F, -3F / 16F - 0.001F); - Minecraft.getMinecraft().renderEngine.bindTexture(TextureMap.locationBlocksTexture); + GL11.glEnable(GL11.GL_BLEND); + GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); + GL11.glColor4f(1F, 1F, 1F, 1F); + GL11.glDisable(GL11.GL_ALPHA_TEST); + float alpha = (float) ((Math.sin((ClientTickHandler.ticksInGame + f) / 8D) + 1D) / 5D + 0.6D) * alphaMod; + if (ShaderHelper.useShaders()) GL11.glColor4f(1F, 1F, 1F, alpha); + else { + int light = 15728880; + int lightmapX = light % 65536; + int lightmapY = light / 65536; + OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, lightmapX, lightmapY); + GL11.glColor4f( + 0.6F + (float) ((Math.cos((ClientTickHandler.ticksInGame + f) / 6D) + 1D) / 5D), 0.1F, 0.9F, alpha); + } - ShaderHelper.useShader(ShaderHelper.terraPlateRune); - renderIcon(0, 0, BlockTerraPlate.overlay, 1, 1, 240); - ShaderHelper.releaseShader(); + Minecraft.getMinecraft().renderEngine.bindTexture(TextureMap.locationBlocksTexture); - GL11.glEnable(GL11.GL_ALPHA_TEST); - GL11.glDisable(GL11.GL_BLEND); - GL11.glColor4f(1F, 1F, 1F, 1F); - GL11.glPopMatrix(); - } + ShaderHelper.useShader(ShaderHelper.terraPlateRune); + renderIcon(0, 0, BlockTerraPlate.overlay, 1, 1, 240); + ShaderHelper.releaseShader(); - public void renderIcon(int par1, int par2, IIcon par3Icon, int par4, int par5, int brightness) { - Tessellator tessellator = Tessellator.instance; - tessellator.startDrawingQuads(); - tessellator.setBrightness(brightness); - tessellator.addVertexWithUV(par1 + 0, par2 + par5, 0, par3Icon.getMinU(), par3Icon.getMaxV()); - tessellator.addVertexWithUV(par1 + par4, par2 + par5, 0, par3Icon.getMaxU(), par3Icon.getMaxV()); - tessellator.addVertexWithUV(par1 + par4, par2 + 0, 0, par3Icon.getMaxU(), par3Icon.getMinV()); - tessellator.addVertexWithUV(par1 + 0, par2 + 0, 0, par3Icon.getMinU(), par3Icon.getMinV()); - tessellator.draw(); - } + GL11.glEnable(GL11.GL_ALPHA_TEST); + GL11.glDisable(GL11.GL_BLEND); + GL11.glColor4f(1F, 1F, 1F, 1F); + GL11.glPopMatrix(); + } + public void renderIcon(int par1, int par2, IIcon par3Icon, int par4, int par5, int brightness) { + Tessellator tessellator = Tessellator.instance; + tessellator.startDrawingQuads(); + tessellator.setBrightness(brightness); + tessellator.addVertexWithUV(par1 + 0, par2 + par5, 0, par3Icon.getMinU(), par3Icon.getMaxV()); + tessellator.addVertexWithUV(par1 + par4, par2 + par5, 0, par3Icon.getMaxU(), par3Icon.getMaxV()); + tessellator.addVertexWithUV(par1 + par4, par2 + 0, 0, par3Icon.getMaxU(), par3Icon.getMinV()); + tessellator.addVertexWithUV(par1 + 0, par2 + 0, 0, par3Icon.getMinU(), par3Icon.getMinV()); + tessellator.draw(); + } } diff --git a/src/main/java/vazkii/botania/client/render/tile/RenderTileTeruTeruBozu.java b/src/main/java/vazkii/botania/client/render/tile/RenderTileTeruTeruBozu.java index adcb0cbc97..6fbf61077b 100644 --- a/src/main/java/vazkii/botania/client/render/tile/RenderTileTeruTeruBozu.java +++ b/src/main/java/vazkii/botania/client/render/tile/RenderTileTeruTeruBozu.java @@ -2,24 +2,21 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Oct 1, 2015, 9:02:30 PM (GMT)] */ package vazkii.botania.client.render.tile; import java.util.Random; - import net.minecraft.client.Minecraft; import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.ResourceLocation; - import org.lwjgl.opengl.GL11; import org.lwjgl.opengl.GL12; - import vazkii.botania.client.core.proxy.ClientProxy; import vazkii.botania.client.lib.LibResources; import vazkii.botania.client.model.ModelTeruTeruBozu; @@ -27,39 +24,38 @@ public class RenderTileTeruTeruBozu extends TileEntitySpecialRenderer { - private static final ResourceLocation texture = new ResourceLocation(LibResources.MODEL_TERU_TERU_BOZU); - private static final ResourceLocation textureHalloween = new ResourceLocation(LibResources.MODEL_TERU_TERU_BOZU_HALLOWEEN); - ModelTeruTeruBozu model = new ModelTeruTeruBozu(); - - @Override - public void renderTileEntityAt(TileEntity tileentity, double d0, double d1, double d2, float f) { - GL11.glPushMatrix(); - GL11.glEnable(GL12.GL_RESCALE_NORMAL); - GL11.glEnable(GL11.GL_BLEND); - GL11.glDisable(GL11.GL_CULL_FACE); - GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); - GL11.glColor4f(1F, 1F, 1F, 1F); - GL11.glTranslated(d0, d1, d2); - Minecraft.getMinecraft().renderEngine.bindTexture(ClientProxy.dootDoot ? textureHalloween : texture); - GL11.glRotatef(180F, 1F, 0F, 0F); - double time = Botania.proxy.getWorldElapsedTicks() + f; - boolean hasWorld = tileentity.getWorldObj() != null; - if(hasWorld) - time += new Random(tileentity.xCoord ^ tileentity.yCoord ^ tileentity.zCoord).nextInt(1000); - - GL11.glTranslatef(0.5F, -1.25F + (hasWorld ? (float) Math.sin(time * 0.01F) * 0.05F : 0F), -0.5F); - if(hasWorld) { - GL11.glRotated(time * 0.3, 0F, 1F, 0F); - GL11.glRotatef(4F * (float) Math.sin(time * 0.05F), 0F, 0F, 1F); - float s = 0.75F; - GL11.glScalef(s, s, s); - } - - model.render(); - GL11.glColor3f(1F, 1F, 1F); - GL11.glEnable(GL12.GL_RESCALE_NORMAL); - GL11.glEnable(GL11.GL_CULL_FACE); - GL11.glPopMatrix(); - } - + private static final ResourceLocation texture = new ResourceLocation(LibResources.MODEL_TERU_TERU_BOZU); + private static final ResourceLocation textureHalloween = + new ResourceLocation(LibResources.MODEL_TERU_TERU_BOZU_HALLOWEEN); + ModelTeruTeruBozu model = new ModelTeruTeruBozu(); + + @Override + public void renderTileEntityAt(TileEntity tileentity, double d0, double d1, double d2, float f) { + GL11.glPushMatrix(); + GL11.glEnable(GL12.GL_RESCALE_NORMAL); + GL11.glEnable(GL11.GL_BLEND); + GL11.glDisable(GL11.GL_CULL_FACE); + GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); + GL11.glColor4f(1F, 1F, 1F, 1F); + GL11.glTranslated(d0, d1, d2); + Minecraft.getMinecraft().renderEngine.bindTexture(ClientProxy.dootDoot ? textureHalloween : texture); + GL11.glRotatef(180F, 1F, 0F, 0F); + double time = Botania.proxy.getWorldElapsedTicks() + f; + boolean hasWorld = tileentity.getWorldObj() != null; + if (hasWorld) time += new Random(tileentity.xCoord ^ tileentity.yCoord ^ tileentity.zCoord).nextInt(1000); + + GL11.glTranslatef(0.5F, -1.25F + (hasWorld ? (float) Math.sin(time * 0.01F) * 0.05F : 0F), -0.5F); + if (hasWorld) { + GL11.glRotated(time * 0.3, 0F, 1F, 0F); + GL11.glRotatef(4F * (float) Math.sin(time * 0.05F), 0F, 0F, 1F); + float s = 0.75F; + GL11.glScalef(s, s, s); + } + + model.render(); + GL11.glColor3f(1F, 1F, 1F); + GL11.glEnable(GL12.GL_RESCALE_NORMAL); + GL11.glEnable(GL11.GL_CULL_FACE); + GL11.glPopMatrix(); + } } diff --git a/src/main/java/vazkii/botania/client/render/tile/RenderTileTinyPotato.java b/src/main/java/vazkii/botania/client/render/tile/RenderTileTinyPotato.java index d8883a54a7..0d4fe36aee 100644 --- a/src/main/java/vazkii/botania/client/render/tile/RenderTileTinyPotato.java +++ b/src/main/java/vazkii/botania/client/render/tile/RenderTileTinyPotato.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jul 18, 2014, 10:48:46 PM (GMT)] */ package vazkii.botania.client.render.tile; @@ -25,10 +25,8 @@ import net.minecraft.util.MovingObjectPosition; import net.minecraft.util.ResourceLocation; import net.minecraftforge.common.MinecraftForge; - import org.lwjgl.opengl.GL11; import org.lwjgl.opengl.GL12; - import vazkii.botania.api.item.TinyPotatoRenderEvent; import vazkii.botania.client.core.handler.ContributorFancinessHandler; import vazkii.botania.client.core.helper.ShaderHelper; @@ -43,358 +41,359 @@ public class RenderTileTinyPotato extends TileEntitySpecialRenderer { - private static final ResourceLocation texture = new ResourceLocation(LibResources.MODEL_TINY_POTATO); - private static final ResourceLocation textureGrayscale = new ResourceLocation(LibResources.MODEL_TINY_POTATO_GS); - private static final ResourceLocation textureHalloween = new ResourceLocation(LibResources.MODEL_TINY_POTATO_HALLOWEEN); - private static final ModelTinyPotato model = new ModelTinyPotato(); - - @Override - public void renderTileEntityAt(TileEntity var1, double d0, double d1, double d2, float var8) { - TileTinyPotato potato = (TileTinyPotato) var1; - GL11.glPushMatrix(); - GL11.glEnable(GL12.GL_RESCALE_NORMAL); - GL11.glColor4f(1F, 1F, 1F, 1F); - GL11.glTranslated(d0, d1, d2); + private static final ResourceLocation texture = new ResourceLocation(LibResources.MODEL_TINY_POTATO); + private static final ResourceLocation textureGrayscale = new ResourceLocation(LibResources.MODEL_TINY_POTATO_GS); + private static final ResourceLocation textureHalloween = + new ResourceLocation(LibResources.MODEL_TINY_POTATO_HALLOWEEN); + private static final ModelTinyPotato model = new ModelTinyPotato(); - Minecraft mc = Minecraft.getMinecraft(); - mc.renderEngine.bindTexture(ClientProxy.dootDoot ? textureHalloween : texture); - String name = potato.name.toLowerCase(); + @Override + public void renderTileEntityAt(TileEntity var1, double d0, double d1, double d2, float var8) { + TileTinyPotato potato = (TileTinyPotato) var1; + GL11.glPushMatrix(); + GL11.glEnable(GL12.GL_RESCALE_NORMAL); + GL11.glColor4f(1F, 1F, 1F, 1F); + GL11.glTranslated(d0, d1, d2); - boolean usedShader = false; - if(name.startsWith("gaia ")) { - ShaderHelper.useShader(ShaderHelper.doppleganger); - name = name.substring(5); - usedShader = true; - } else if(name.startsWith("hot ")) { - ShaderHelper.useShader(ShaderHelper.halo); - name = name.substring(4); - usedShader = true; - } else if(name.startsWith("magic ")) { - ShaderHelper.useShader(ShaderHelper.enchanterRune); - name = name.substring(6); - usedShader = true; - } else if(name.startsWith("gold ")) { - ShaderHelper.useShader(ShaderHelper.gold); - name = name.substring(5); - usedShader = true; - } else if(name.startsWith("snoop ")) { - ShaderHelper.useShader(ShaderHelper.terraPlateRune); - name = name.substring(6); - usedShader = true; - } + Minecraft mc = Minecraft.getMinecraft(); + mc.renderEngine.bindTexture(ClientProxy.dootDoot ? textureHalloween : texture); + String name = potato.name.toLowerCase(); - GL11.glTranslatef(0.5F, 1.5F, 0.5F); - GL11.glScalef(1F, -1F, -1F); - int meta = potato.getWorldObj() == null ? 3 : potato.getBlockMetadata(); - float rotY = meta * 90F - 180F; - GL11.glRotatef(rotY, 0F, 1F, 0F); + boolean usedShader = false; + if (name.startsWith("gaia ")) { + ShaderHelper.useShader(ShaderHelper.doppleganger); + name = name.substring(5); + usedShader = true; + } else if (name.startsWith("hot ")) { + ShaderHelper.useShader(ShaderHelper.halo); + name = name.substring(4); + usedShader = true; + } else if (name.startsWith("magic ")) { + ShaderHelper.useShader(ShaderHelper.enchanterRune); + name = name.substring(6); + usedShader = true; + } else if (name.startsWith("gold ")) { + ShaderHelper.useShader(ShaderHelper.gold); + name = name.substring(5); + usedShader = true; + } else if (name.startsWith("snoop ")) { + ShaderHelper.useShader(ShaderHelper.terraPlateRune); + name = name.substring(6); + usedShader = true; + } - float jump = potato.jumpTicks; - if(jump > 0) - jump -= var8; + GL11.glTranslatef(0.5F, 1.5F, 0.5F); + GL11.glScalef(1F, -1F, -1F); + int meta = potato.getWorldObj() == null ? 3 : potato.getBlockMetadata(); + float rotY = meta * 90F - 180F; + GL11.glRotatef(rotY, 0F, 1F, 0F); - float up = (float) -Math.abs(Math.sin(jump / 10 * Math.PI)) * 0.2F; - float rotZ = (float) Math.sin(jump / 10 * Math.PI) * 2; + float jump = potato.jumpTicks; + if (jump > 0) jump -= var8; - GL11.glTranslatef(0F, up, 0F); - GL11.glRotatef(rotZ, 0F, 0F, 1F); + float up = (float) -Math.abs(Math.sin(jump / 10 * Math.PI)) * 0.2F; + float rotZ = (float) Math.sin(jump / 10 * Math.PI) * 2; - GL11.glPushMatrix(); - if(name.equals("pahimar")) { - GL11.glScalef(1F, 0.3F, 1F); - GL11.glTranslatef(0F, 3.5F, 0F); - } else if(name.equals("kyle hyde")) - mc.renderEngine.bindTexture(textureGrayscale); - else if(name.equals("dinnerbone") || name.equals("grumm")) { - GL11.glRotatef(180F, 0F, 0F, 1F); - GL11.glTranslatef(0F, -2.625F, 0F); - } else if(name.equals("aureylian")) - GL11.glColor3f(1F, 0.5F, 1F); + GL11.glTranslatef(0F, up, 0F); + GL11.glRotatef(rotZ, 0F, 0F, 1F); + GL11.glPushMatrix(); + if (name.equals("pahimar")) { + GL11.glScalef(1F, 0.3F, 1F); + GL11.glTranslatef(0F, 3.5F, 0F); + } else if (name.equals("kyle hyde")) mc.renderEngine.bindTexture(textureGrayscale); + else if (name.equals("dinnerbone") || name.equals("grumm")) { + GL11.glRotatef(180F, 0F, 0F, 1F); + GL11.glTranslatef(0F, -2.625F, 0F); + } else if (name.equals("aureylian")) GL11.glColor3f(1F, 0.5F, 1F); - boolean render = !(name.equals("mami") || name.equals("soaryn") || name.equals("eloraam") && jump != 0); - if(render) - model.render(); - if(name.equals("kingdaddydmac")) { - GL11.glTranslated(0.5F, 0F, 0F); - model.render(); - } + boolean render = !(name.equals("mami") || name.equals("soaryn") || name.equals("eloraam") && jump != 0); + if (render) model.render(); + if (name.equals("kingdaddydmac")) { + GL11.glTranslated(0.5F, 0F, 0F); + model.render(); + } - if(usedShader) - ShaderHelper.releaseShader(); + if (usedShader) ShaderHelper.releaseShader(); - GL11.glPopMatrix(); + GL11.glPopMatrix(); - if(!name.isEmpty()) { - GL11.glPushMatrix(); - mc.renderEngine.bindTexture(TextureMap.locationItemsTexture); + if (!name.isEmpty()) { + GL11.glPushMatrix(); + mc.renderEngine.bindTexture(TextureMap.locationItemsTexture); - ContributorFancinessHandler.firstStart(); + ContributorFancinessHandler.firstStart(); - float scale = 1F / 4F; - GL11.glTranslatef(0F, 1F, 0F); - GL11.glScalef(scale, scale, scale); - if(name.equals("phi") || name.equals("vazkii")) { - GL11.glTranslatef(0.45F, 0F, 0.4F); - GL11.glRotatef(90F, 0F, 1F, 0F); - GL11.glRotatef(20F, 1F, 0F, 1F); - renderIcon(((ItemManaResource) ModItems.manaResource).phiFlowerIcon); + float scale = 1F / 4F; + GL11.glTranslatef(0F, 1F, 0F); + GL11.glScalef(scale, scale, scale); + if (name.equals("phi") || name.equals("vazkii")) { + GL11.glTranslatef(0.45F, 0F, 0.4F); + GL11.glRotatef(90F, 0F, 1F, 0F); + GL11.glRotatef(20F, 1F, 0F, 1F); + renderIcon(((ItemManaResource) ModItems.manaResource).phiFlowerIcon); - if(name.equals("vazkii")) { - GL11.glRotatef(-20F, 1F, 0F, 1F); - GL11.glScalef(1.25F, 1.25F, 1.25F); - GL11.glRotatef(180F, 0F, 0F, 1F); - GL11.glTranslatef(-1.5F, -1.3F, -0.75F); - renderIcon(((ItemManaResource) ModItems.manaResource).nerfBatIcon); - } - } else if(name.equals("skull kid")) { - GL11.glScalef(1.25F, 1.25F, 1.25F); - GL11.glRotatef(180F, 0F, 0F, 1F); - GL11.glTranslatef(-0.5F, -1.2F, -0.4F); - renderIcon(ModItems.cosmetic.getIconFromDamage(23)); - } else if(name.equals("kamina")) { - GL11.glScalef(1.25F, 1.25F, 1.25F); - GL11.glRotatef(180F, 0F, 0F, 1F); - GL11.glTranslatef(-0.5F, -1.1F, -0.4F); - renderIcon(ModItems.cosmetic.getIconFromDamage(26)); - } else if(name.equals("haighyorkie")) { - GL11.glScalef(1.25F, 1.25F, 1.25F); - GL11.glRotatef(180F, 0F, 0F, 1F); - GL11.glRotatef(90F, 0F, 1F, 0F); - GL11.glTranslatef(-0.5F, -1.2F, -0.4F); - renderIcon(((ItemManaResource) ModItems.manaResource).goldfishIcon); - } else if(name.equals("chitoge")) { - GL11.glScalef(1.25F, 1.25F, 1.25F); - GL11.glRotatef(180F, 0F, 0F, 1F); - GL11.glTranslatef(-0.5F, -0.7F, 0.1F); - renderIcon(ModItems.cosmetic.getIconFromDamage(7)); - } else if(name.equals("direwolf20")) { - GL11.glRotatef(180F, 0F, 0F, 1F); - GL11.glTranslatef(-0.5F, -2.2F, -0.5F); - renderIcon(ModItems.cosmetic.getIconFromDamage(0)); - } else if(name.equals("doctor")) { - GL11.glScalef(1.25F, 1.25F, 1.25F); - GL11.glRotatef(180F, 0F, 0F, 1F); - GL11.glTranslatef(-0.5F, -1.15F, -0.4F); - renderIcon(ModItems.cosmetic.getIconFromDamage(25)); - } else if(name.equals("snoo")) { - GL11.glScalef(1.25F, 1.25F, 1.25F); - GL11.glRotatef(180F, 0F, 0F, 1F); - GL11.glTranslatef(-0.5F, -0.7F, 0.1F); - GL11.glRotatef(20F, 0F, 0F, 1F); - renderIcon(ModItems.cosmetic.getIconFromDamage(24)); - } else if(name.equals("charlotte")) { - GL11.glScalef(1.25F, 1.25F, 1.25F); - GL11.glRotatef(180F, 0F, 0F, 1F); - GL11.glTranslatef(-0.5F, -1.2F, -0.4F); - renderIcon(ModItems.cosmetic.getIconFromDamage(12)); - } else if(name.equals("greg") || name.equals("gregorioust")) { - GL11.glScalef(1.25F, 1.25F, 1.25F); - GL11.glRotatef(180F, 0F, 0F, 1F); - GL11.glRotatef(90F, 0F, 1F, 0F); - GL11.glTranslatef(-0.5F, -1.5F, -0.4F); - renderIcon(Items.book.getIconFromDamage(0)); + if (name.equals("vazkii")) { + GL11.glRotatef(-20F, 1F, 0F, 1F); + GL11.glScalef(1.25F, 1.25F, 1.25F); + GL11.glRotatef(180F, 0F, 0F, 1F); + GL11.glTranslatef(-1.5F, -1.3F, -0.75F); + renderIcon(((ItemManaResource) ModItems.manaResource).nerfBatIcon); + } + } else if (name.equals("skull kid")) { + GL11.glScalef(1.25F, 1.25F, 1.25F); + GL11.glRotatef(180F, 0F, 0F, 1F); + GL11.glTranslatef(-0.5F, -1.2F, -0.4F); + renderIcon(ModItems.cosmetic.getIconFromDamage(23)); + } else if (name.equals("kamina")) { + GL11.glScalef(1.25F, 1.25F, 1.25F); + GL11.glRotatef(180F, 0F, 0F, 1F); + GL11.glTranslatef(-0.5F, -1.1F, -0.4F); + renderIcon(ModItems.cosmetic.getIconFromDamage(26)); + } else if (name.equals("haighyorkie")) { + GL11.glScalef(1.25F, 1.25F, 1.25F); + GL11.glRotatef(180F, 0F, 0F, 1F); + GL11.glRotatef(90F, 0F, 1F, 0F); + GL11.glTranslatef(-0.5F, -1.2F, -0.4F); + renderIcon(((ItemManaResource) ModItems.manaResource).goldfishIcon); + } else if (name.equals("chitoge")) { + GL11.glScalef(1.25F, 1.25F, 1.25F); + GL11.glRotatef(180F, 0F, 0F, 1F); + GL11.glTranslatef(-0.5F, -0.7F, 0.1F); + renderIcon(ModItems.cosmetic.getIconFromDamage(7)); + } else if (name.equals("direwolf20")) { + GL11.glRotatef(180F, 0F, 0F, 1F); + GL11.glTranslatef(-0.5F, -2.2F, -0.5F); + renderIcon(ModItems.cosmetic.getIconFromDamage(0)); + } else if (name.equals("doctor")) { + GL11.glScalef(1.25F, 1.25F, 1.25F); + GL11.glRotatef(180F, 0F, 0F, 1F); + GL11.glTranslatef(-0.5F, -1.15F, -0.4F); + renderIcon(ModItems.cosmetic.getIconFromDamage(25)); + } else if (name.equals("snoo")) { + GL11.glScalef(1.25F, 1.25F, 1.25F); + GL11.glRotatef(180F, 0F, 0F, 1F); + GL11.glTranslatef(-0.5F, -0.7F, 0.1F); + GL11.glRotatef(20F, 0F, 0F, 1F); + renderIcon(ModItems.cosmetic.getIconFromDamage(24)); + } else if (name.equals("charlotte")) { + GL11.glScalef(1.25F, 1.25F, 1.25F); + GL11.glRotatef(180F, 0F, 0F, 1F); + GL11.glTranslatef(-0.5F, -1.2F, -0.4F); + renderIcon(ModItems.cosmetic.getIconFromDamage(12)); + } else if (name.equals("greg") || name.equals("gregorioust")) { + GL11.glScalef(1.25F, 1.25F, 1.25F); + GL11.glRotatef(180F, 0F, 0F, 1F); + GL11.glRotatef(90F, 0F, 1F, 0F); + GL11.glTranslatef(-0.5F, -1.5F, -0.4F); + renderIcon(Items.book.getIconFromDamage(0)); - mc.renderEngine.bindTexture(TextureMap.locationBlocksTexture); - GL11.glTranslatef(0.5F, 0.5F, 0F); - GL11.glScalef(0.3F, 0.3F, 0.3F); + mc.renderEngine.bindTexture(TextureMap.locationBlocksTexture); + GL11.glTranslatef(0.5F, 0.5F, 0F); + GL11.glScalef(0.3F, 0.3F, 0.3F); - RenderBlocks.getInstance().renderBlockAsItem(Blocks.iron_ore, 0, 1F); - } else if(name.equals("profmobius")) { - GL11.glScalef(1.25F, 1.25F, 1.25F); - GL11.glRotatef(180F, 0F, 0F, 1F); - GL11.glRotatef(90F, 0F, 1F, 0F); - GL11.glTranslatef(-0.5F, -1.2F, -0.4F); - renderIcon(Items.bread.getIconFromDamage(0)); - } else if(name.equals("martysgames") || name.equals("marty")) { - GL11.glScalef(0.7F, 0.7F, 0.7F); - GL11.glRotatef(180F, 0F, 0F, 1F); - GL11.glTranslatef(-0.75F, -2.4F, -0.7F); - GL11.glRotatef(10F, 0F, 0F, 1F); - renderIcon(ItemInfiniteFruit.dasBootIcon); - } else if(name.equals("tromped")) { - GL11.glScalef(1.25F, 1.25F, 1.25F); - GL11.glRotatef(180F, 0F, 0F, 1F); - GL11.glRotatef(90F, 0F, 1F, 0F); - GL11.glTranslatef(-0.5F, -1.2F, -0.4F); - renderIcon(ModItems.cacophonium.getIconFromDamage(0)); - } else if(name.equals("kain vinosec")) { - GL11.glScalef(1.25F, 1.25F, 1.25F); - GL11.glRotatef(180F, 0F, 0F, 1F); - GL11.glRotatef(90F, 0F, 1F, 0F); - GL11.glTranslatef(-0.3F, -1.5F, -0.4F); - renderIcon(ModItems.recordGaia1.getIconFromDamage(0)); - GL11.glTranslatef(0F, 0F, 0.85F); - renderIcon(ModItems.recordGaia2.getIconFromDamage(0)); - } else if(name.equals("mankrik")) { - GL11.glScalef(1.25F, 1.25F, 1.25F); - GL11.glRotatef(180F, 0F, 0F, 1F); - GL11.glTranslatef(-0.5F, -0.2F, -0.1F); - renderIcon(ModItems.cosmetic.getIconFromDamage(31)); - } else if(name.equals("kurumi")) { - GL11.glScalef(0.4F, 0.4F, 0.4F); - GL11.glRotatef(180F, 0F, 0F, 1F); - GL11.glTranslatef(-0.9F, -2.5F, -1.3F); - renderIcon(ModItems.cosmetic.getIconFromDamage(17)); - } else if(name.equals("ichun")) { - GL11.glScalef(1.25F, 1.25F, 1.25F); - GL11.glRotatef(180F, 0F, 0F, 1F); - GL11.glTranslatef(-0.5F, -1.2F, -0.4F); - renderIcon(ModItems.cosmetic.getIconFromDamage(15)); - } else if(name.equals("wiiv") || name.equals("dylan4ever") || name.equals("dylankaiser")) { - GL11.glScalef(1.5F, 1.5F, 1.5F); - GL11.glRotatef(180F, 0F, 0F, 1F); - GL11.glRotatef(90F, 0F, 1F, 0F); - GL11.glTranslatef(-0.5F, -1.1F, -0.325F); - renderIcon(Items.painting.getIconFromDamage(0)); - } else if(name.equals("jibril")) { - GL11.glScalef(1.5F, 1.5F, 1.5F); - GL11.glTranslatef(0F, 0.7F, 0F); - GL11.glRotatef(90F, 0F, 1F, 0F); - ItemFlightTiara.renderHalo(null, var8); - } else if(name.equals("nebris")) { - mc.renderEngine.bindTexture(TextureMap.locationBlocksTexture); - GL11.glRotatef(180F, 1F, 0F, 0F); - RenderBlocks.getInstance().renderBlockAsItem(Blocks.glowstone, 0, 1F); - } else if(name.equals("ible")) { - mc.renderEngine.bindTexture(TextureMap.locationBlocksTexture); - GL11.glScalef(1.2F, 1.2F, 1.2F); - GL11.glTranslatef(0F, 0.7F, 0F); - GL11.glRotatef(180F, 1F, 0F, 0F); - GL11.glEnable(GL11.GL_BLEND); - GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); - RenderBlocks.getInstance().renderBlockAsItem(Blocks.portal, 0, 1F); - } else if(name.equals("razz") || name.equals("razzleberryfox")) { - GL11.glScalef(1.25F, 1.25F, 1.25F); - GL11.glRotatef(180F, 0F, 0F, 1F); - GL11.glRotatef(90F, 0F, 1F, 0F); - GL11.glTranslatef(-0.5F, -1F, 0.45F); - renderIcon(ModItems.cosmetic.getIconFromDamage(8)); - } else if(name.equals("etho") || name.equals("ethoslab")) { - GL11.glScalef(1.25F, 1.25F, 1.25F); - GL11.glRotatef(180F, 0F, 0F, 1F); - GL11.glRotatef(90F, 0F, 1F, 0F); - GL11.glTranslatef(-0.5F, -1.2F, -0.4F); - renderIcon(Items.cookie.getIconFromDamage(0)); - } else if(name.equals("sethbling")) { - mc.renderEngine.bindTexture(TextureMap.locationBlocksTexture); - GL11.glScalef(1.2F, 1.2F, 1.2F); - GL11.glTranslatef(0F, 0.9F, 0F); - GL11.glRotatef(180F, 1F, 0F, 0F); - RenderBlocks.getInstance().renderBlockAsItem(Blocks.command_block, 0, 1F); - } else if(name.equals("bdoubleo100") || name.equals("bdoubleo")) { - GL11.glScalef(1.25F, 1.25F, 1.25F); - GL11.glRotatef(180F, 0F, 0F, 1F); - GL11.glTranslatef(-1F, -1.1F, -0.1F); - renderIcon(Items.stick.getIconFromDamage(0)); - } else if(name.equals("kingdaddydmac")) { - GL11.glScalef(0.5F, 0.5F, 0.5F); - GL11.glRotatef(180F, 0F, 0F, 1F); - GL11.glRotatef(90F, 0F, 1F, 0F); - GL11.glTranslatef(-0.3F, -2.5F, 1.075F); - renderIcon(ModItems.manaRing.getIconFromDamage(0)); - GL11.glTranslatef(0F, 0F, -4F); - renderIcon(ModItems.manaRing.getIconFromDamage(0)); + RenderBlocks.getInstance().renderBlockAsItem(Blocks.iron_ore, 0, 1F); + } else if (name.equals("profmobius")) { + GL11.glScalef(1.25F, 1.25F, 1.25F); + GL11.glRotatef(180F, 0F, 0F, 1F); + GL11.glRotatef(90F, 0F, 1F, 0F); + GL11.glTranslatef(-0.5F, -1.2F, -0.4F); + renderIcon(Items.bread.getIconFromDamage(0)); + } else if (name.equals("martysgames") || name.equals("marty")) { + GL11.glScalef(0.7F, 0.7F, 0.7F); + GL11.glRotatef(180F, 0F, 0F, 1F); + GL11.glTranslatef(-0.75F, -2.4F, -0.7F); + GL11.glRotatef(10F, 0F, 0F, 1F); + renderIcon(ItemInfiniteFruit.dasBootIcon); + } else if (name.equals("tromped")) { + GL11.glScalef(1.25F, 1.25F, 1.25F); + GL11.glRotatef(180F, 0F, 0F, 1F); + GL11.glRotatef(90F, 0F, 1F, 0F); + GL11.glTranslatef(-0.5F, -1.2F, -0.4F); + renderIcon(ModItems.cacophonium.getIconFromDamage(0)); + } else if (name.equals("kain vinosec")) { + GL11.glScalef(1.25F, 1.25F, 1.25F); + GL11.glRotatef(180F, 0F, 0F, 1F); + GL11.glRotatef(90F, 0F, 1F, 0F); + GL11.glTranslatef(-0.3F, -1.5F, -0.4F); + renderIcon(ModItems.recordGaia1.getIconFromDamage(0)); + GL11.glTranslatef(0F, 0F, 0.85F); + renderIcon(ModItems.recordGaia2.getIconFromDamage(0)); + } else if (name.equals("mankrik")) { + GL11.glScalef(1.25F, 1.25F, 1.25F); + GL11.glRotatef(180F, 0F, 0F, 1F); + GL11.glTranslatef(-0.5F, -0.2F, -0.1F); + renderIcon(ModItems.cosmetic.getIconFromDamage(31)); + } else if (name.equals("kurumi")) { + GL11.glScalef(0.4F, 0.4F, 0.4F); + GL11.glRotatef(180F, 0F, 0F, 1F); + GL11.glTranslatef(-0.9F, -2.5F, -1.3F); + renderIcon(ModItems.cosmetic.getIconFromDamage(17)); + } else if (name.equals("ichun")) { + GL11.glScalef(1.25F, 1.25F, 1.25F); + GL11.glRotatef(180F, 0F, 0F, 1F); + GL11.glTranslatef(-0.5F, -1.2F, -0.4F); + renderIcon(ModItems.cosmetic.getIconFromDamage(15)); + } else if (name.equals("wiiv") || name.equals("dylan4ever") || name.equals("dylankaiser")) { + GL11.glScalef(1.5F, 1.5F, 1.5F); + GL11.glRotatef(180F, 0F, 0F, 1F); + GL11.glRotatef(90F, 0F, 1F, 0F); + GL11.glTranslatef(-0.5F, -1.1F, -0.325F); + renderIcon(Items.painting.getIconFromDamage(0)); + } else if (name.equals("jibril")) { + GL11.glScalef(1.5F, 1.5F, 1.5F); + GL11.glTranslatef(0F, 0.7F, 0F); + GL11.glRotatef(90F, 0F, 1F, 0F); + ItemFlightTiara.renderHalo(null, var8); + } else if (name.equals("nebris")) { + mc.renderEngine.bindTexture(TextureMap.locationBlocksTexture); + GL11.glRotatef(180F, 1F, 0F, 0F); + RenderBlocks.getInstance().renderBlockAsItem(Blocks.glowstone, 0, 1F); + } else if (name.equals("ible")) { + mc.renderEngine.bindTexture(TextureMap.locationBlocksTexture); + GL11.glScalef(1.2F, 1.2F, 1.2F); + GL11.glTranslatef(0F, 0.7F, 0F); + GL11.glRotatef(180F, 1F, 0F, 0F); + GL11.glEnable(GL11.GL_BLEND); + GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); + RenderBlocks.getInstance().renderBlockAsItem(Blocks.portal, 0, 1F); + } else if (name.equals("razz") || name.equals("razzleberryfox")) { + GL11.glScalef(1.25F, 1.25F, 1.25F); + GL11.glRotatef(180F, 0F, 0F, 1F); + GL11.glRotatef(90F, 0F, 1F, 0F); + GL11.glTranslatef(-0.5F, -1F, 0.45F); + renderIcon(ModItems.cosmetic.getIconFromDamage(8)); + } else if (name.equals("etho") || name.equals("ethoslab")) { + GL11.glScalef(1.25F, 1.25F, 1.25F); + GL11.glRotatef(180F, 0F, 0F, 1F); + GL11.glRotatef(90F, 0F, 1F, 0F); + GL11.glTranslatef(-0.5F, -1.2F, -0.4F); + renderIcon(Items.cookie.getIconFromDamage(0)); + } else if (name.equals("sethbling")) { + mc.renderEngine.bindTexture(TextureMap.locationBlocksTexture); + GL11.glScalef(1.2F, 1.2F, 1.2F); + GL11.glTranslatef(0F, 0.9F, 0F); + GL11.glRotatef(180F, 1F, 0F, 0F); + RenderBlocks.getInstance().renderBlockAsItem(Blocks.command_block, 0, 1F); + } else if (name.equals("bdoubleo100") || name.equals("bdoubleo")) { + GL11.glScalef(1.25F, 1.25F, 1.25F); + GL11.glRotatef(180F, 0F, 0F, 1F); + GL11.glTranslatef(-1F, -1.1F, -0.1F); + renderIcon(Items.stick.getIconFromDamage(0)); + } else if (name.equals("kingdaddydmac")) { + GL11.glScalef(0.5F, 0.5F, 0.5F); + GL11.glRotatef(180F, 0F, 0F, 1F); + GL11.glRotatef(90F, 0F, 1F, 0F); + GL11.glTranslatef(-0.3F, -2.5F, 1.075F); + renderIcon(ModItems.manaRing.getIconFromDamage(0)); + GL11.glTranslatef(0F, 0F, -4F); + renderIcon(ModItems.manaRing.getIconFromDamage(0)); - mc.renderEngine.bindTexture(TextureMap.locationBlocksTexture); - GL11.glScalef(1.5F, 1.5F, 1.5F); - GL11.glTranslatef(1.5F, -0.5F, 0.7F); - RenderBlocks.getInstance().renderBlockAsItem(Blocks.cake, 0, 1F); - } else if(name.equals("sjin")) { - GL11.glScalef(1.25F, 1.25F, 1.25F); - GL11.glRotatef(180F, 0F, 0F, 1F); - GL11.glTranslatef(-0.5F, -1.27F, -0.4F); - renderIcon(ModItems.cosmetic.getIconFromDamage(27)); - } else if(name.equals("martyn") || name.equals("inthelittlewood")) { - GL11.glScalef(1.25F, 1.25F, 1.25F); - GL11.glRotatef(180F, 0F, 0F, 1F); - GL11.glTranslatef(-0.5F, -0.45F, -0.1F); - mc.renderEngine.bindTexture(TextureMap.locationBlocksTexture); - renderIcon(Blocks.sapling.getIcon(0, 0)); - }else if(ContributorFancinessHandler.flowerMap != null && ContributorFancinessHandler.flowerMap.containsKey(name)) { - IIcon icon = ContributorFancinessHandler.flowerMap.get(name); - if(icon != null) { - mc.renderEngine.bindTexture(TextureMap.locationBlocksTexture); - GL11.glRotatef(180F, 1F, 0F, 0F); - GL11.glTranslatef(-0.5F, -0.5F, 0F); - ShaderHelper.useShader(ShaderHelper.gold); - renderIcon(icon); - ShaderHelper.releaseShader(); - } - } + mc.renderEngine.bindTexture(TextureMap.locationBlocksTexture); + GL11.glScalef(1.5F, 1.5F, 1.5F); + GL11.glTranslatef(1.5F, -0.5F, 0.7F); + RenderBlocks.getInstance().renderBlockAsItem(Blocks.cake, 0, 1F); + } else if (name.equals("sjin")) { + GL11.glScalef(1.25F, 1.25F, 1.25F); + GL11.glRotatef(180F, 0F, 0F, 1F); + GL11.glTranslatef(-0.5F, -1.27F, -0.4F); + renderIcon(ModItems.cosmetic.getIconFromDamage(27)); + } else if (name.equals("martyn") || name.equals("inthelittlewood")) { + GL11.glScalef(1.25F, 1.25F, 1.25F); + GL11.glRotatef(180F, 0F, 0F, 1F); + GL11.glTranslatef(-0.5F, -0.45F, -0.1F); + mc.renderEngine.bindTexture(TextureMap.locationBlocksTexture); + renderIcon(Blocks.sapling.getIcon(0, 0)); + } else if (ContributorFancinessHandler.flowerMap != null + && ContributorFancinessHandler.flowerMap.containsKey(name)) { + IIcon icon = ContributorFancinessHandler.flowerMap.get(name); + if (icon != null) { + mc.renderEngine.bindTexture(TextureMap.locationBlocksTexture); + GL11.glRotatef(180F, 1F, 0F, 0F); + GL11.glTranslatef(-0.5F, -0.5F, 0F); + ShaderHelper.useShader(ShaderHelper.gold); + renderIcon(icon); + ShaderHelper.releaseShader(); + } + } - GL11.glPopMatrix(); - } + GL11.glPopMatrix(); + } - MinecraftForge.EVENT_BUS.post(new TinyPotatoRenderEvent(potato, potato.name, d0, d1, d2, var8)); + MinecraftForge.EVENT_BUS.post(new TinyPotatoRenderEvent(potato, potato.name, d0, d1, d2, var8)); - GL11.glRotatef(-rotZ, 0F, 0F, 1F); - GL11.glRotatef(-rotY, 0F, 1F, 0F); - GL11.glColor3f(1F, 1F, 1F); - GL11.glScalef(1F, -1F, -1F); + GL11.glRotatef(-rotZ, 0F, 0F, 1F); + GL11.glRotatef(-rotY, 0F, 1F, 0F); + GL11.glColor3f(1F, 1F, 1F); + GL11.glScalef(1F, -1F, -1F); - MovingObjectPosition pos = mc.objectMouseOver; - if(!name.isEmpty() && pos != null && pos.blockX == potato.xCoord && pos.blockY == potato.yCoord && pos.blockZ == potato.zCoord) { - GL11.glPushMatrix(); - GL11.glTranslatef(0F, -0.6F, 0F); - GL11.glRotatef(-RenderManager.instance.playerViewY, 0.0F, 1.0F, 0.0F); - GL11.glRotatef(RenderManager.instance.playerViewX, 1.0F, 0.0F, 0.0F); - float f = 1.6F; - float f1 = 0.016666668F * f; - GL11.glScalef(-f1, -f1, f1); - GL11.glDisable(GL11.GL_LIGHTING); - GL11.glTranslatef(0.0F, 0F / f1, 0.0F); - GL11.glDepthMask(false); - GL11.glEnable(GL11.GL_BLEND); - OpenGlHelper.glBlendFunc(770, 771, 1, 0); - Tessellator tessellator = Tessellator.instance; - GL11.glDisable(GL11.GL_TEXTURE_2D); - tessellator.startDrawingQuads(); - int i = mc.fontRenderer.getStringWidth(potato.name) / 2; - tessellator.setColorRGBA_F(0.0F, 0.0F, 0.0F, 0.25F); - tessellator.addVertex(-i - 1, -1.0D, 0.0D); - tessellator.addVertex(-i - 1, 8.0D, 0.0D); - tessellator.addVertex(i + 1, 8.0D, 0.0D); - tessellator.addVertex(i + 1, -1.0D, 0.0D); - tessellator.draw(); - GL11.glEnable(GL11.GL_TEXTURE_2D); - GL11.glDepthMask(true); - mc.fontRenderer.drawString(potato.name, -mc.fontRenderer.getStringWidth(potato.name) / 2, 0, 0xFFFFFF); - if(name.equals("pahimar") || name.equals("soaryn")) { - GL11.glTranslatef(0F, 14F, 0F); - String s = name.equals("pahimar") ? "[WIP]" : "(soon)"; - GL11.glDepthMask(false); - GL11.glEnable(GL11.GL_BLEND); - OpenGlHelper.glBlendFunc(770, 771, 1, 0); - GL11.glDisable(GL11.GL_TEXTURE_2D); - tessellator.startDrawingQuads(); - i = mc.fontRenderer.getStringWidth(s) / 2; - tessellator.setColorRGBA_F(0.0F, 0.0F, 0.0F, 0.25F); - tessellator.addVertex(-i - 1, -1.0D, 0.0D); - tessellator.addVertex(-i - 1, 8.0D, 0.0D); - tessellator.addVertex(i + 1, 8.0D, 0.0D); - tessellator.addVertex(i + 1, -1.0D, 0.0D); - tessellator.draw(); - GL11.glEnable(GL11.GL_TEXTURE_2D); - GL11.glDepthMask(true); - mc.fontRenderer.drawString(s, -mc.fontRenderer.getStringWidth(s) / 2, 0, 0xFFFFFF); - } + MovingObjectPosition pos = mc.objectMouseOver; + if (!name.isEmpty() + && pos != null + && pos.blockX == potato.xCoord + && pos.blockY == potato.yCoord + && pos.blockZ == potato.zCoord) { + GL11.glPushMatrix(); + GL11.glTranslatef(0F, -0.6F, 0F); + GL11.glRotatef(-RenderManager.instance.playerViewY, 0.0F, 1.0F, 0.0F); + GL11.glRotatef(RenderManager.instance.playerViewX, 1.0F, 0.0F, 0.0F); + float f = 1.6F; + float f1 = 0.016666668F * f; + GL11.glScalef(-f1, -f1, f1); + GL11.glDisable(GL11.GL_LIGHTING); + GL11.glTranslatef(0.0F, 0F / f1, 0.0F); + GL11.glDepthMask(false); + GL11.glEnable(GL11.GL_BLEND); + OpenGlHelper.glBlendFunc(770, 771, 1, 0); + Tessellator tessellator = Tessellator.instance; + GL11.glDisable(GL11.GL_TEXTURE_2D); + tessellator.startDrawingQuads(); + int i = mc.fontRenderer.getStringWidth(potato.name) / 2; + tessellator.setColorRGBA_F(0.0F, 0.0F, 0.0F, 0.25F); + tessellator.addVertex(-i - 1, -1.0D, 0.0D); + tessellator.addVertex(-i - 1, 8.0D, 0.0D); + tessellator.addVertex(i + 1, 8.0D, 0.0D); + tessellator.addVertex(i + 1, -1.0D, 0.0D); + tessellator.draw(); + GL11.glEnable(GL11.GL_TEXTURE_2D); + GL11.glDepthMask(true); + mc.fontRenderer.drawString(potato.name, -mc.fontRenderer.getStringWidth(potato.name) / 2, 0, 0xFFFFFF); + if (name.equals("pahimar") || name.equals("soaryn")) { + GL11.glTranslatef(0F, 14F, 0F); + String s = name.equals("pahimar") ? "[WIP]" : "(soon)"; + GL11.glDepthMask(false); + GL11.glEnable(GL11.GL_BLEND); + OpenGlHelper.glBlendFunc(770, 771, 1, 0); + GL11.glDisable(GL11.GL_TEXTURE_2D); + tessellator.startDrawingQuads(); + i = mc.fontRenderer.getStringWidth(s) / 2; + tessellator.setColorRGBA_F(0.0F, 0.0F, 0.0F, 0.25F); + tessellator.addVertex(-i - 1, -1.0D, 0.0D); + tessellator.addVertex(-i - 1, 8.0D, 0.0D); + tessellator.addVertex(i + 1, 8.0D, 0.0D); + tessellator.addVertex(i + 1, -1.0D, 0.0D); + tessellator.draw(); + GL11.glEnable(GL11.GL_TEXTURE_2D); + GL11.glDepthMask(true); + mc.fontRenderer.drawString(s, -mc.fontRenderer.getStringWidth(s) / 2, 0, 0xFFFFFF); + } - GL11.glEnable(GL11.GL_LIGHTING); - GL11.glDisable(GL11.GL_BLEND); - GL11.glColor4f(1F, 1F, 1F, 1F); - GL11.glScalef(1F / -f1, 1F / -f1, 1F / f1); - GL11.glPopMatrix(); - } + GL11.glEnable(GL11.GL_LIGHTING); + GL11.glDisable(GL11.GL_BLEND); + GL11.glColor4f(1F, 1F, 1F, 1F); + GL11.glScalef(1F / -f1, 1F / -f1, 1F / f1); + GL11.glPopMatrix(); + } - GL11.glPopMatrix(); - } + GL11.glPopMatrix(); + } - public void renderIcon(IIcon icon) { - float f = icon.getMinU(); - float f1 = icon.getMaxU(); - float f2 = icon.getMinV(); - float f3 = icon.getMaxV(); - ItemRenderer.renderItemIn2D(Tessellator.instance, f1, f2, f, f3, icon.getIconWidth(), icon.getIconHeight(), 1F / 16F); - } -} \ No newline at end of file + public void renderIcon(IIcon icon) { + float f = icon.getMinU(); + float f1 = icon.getMaxU(); + float f2 = icon.getMinV(); + float f3 = icon.getMaxV(); + ItemRenderer.renderItemIn2D( + Tessellator.instance, f1, f2, f, f3, icon.getIconWidth(), icon.getIconHeight(), 1F / 16F); + } +} diff --git a/src/main/java/vazkii/botania/client/render/world/SkyblockRenderEvents.java b/src/main/java/vazkii/botania/client/render/world/SkyblockRenderEvents.java index 007b637fb5..a8f8388d12 100644 --- a/src/main/java/vazkii/botania/client/render/world/SkyblockRenderEvents.java +++ b/src/main/java/vazkii/botania/client/render/world/SkyblockRenderEvents.java @@ -2,30 +2,32 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [18/12/2015, 02:19:53 (GMT)] */ package vazkii.botania.client.render.world; +import cpw.mods.fml.common.eventhandler.SubscribeEvent; import net.minecraft.client.Minecraft; import net.minecraft.world.World; import net.minecraftforge.client.event.RenderWorldLastEvent; import vazkii.botania.common.core.handler.ConfigHandler; import vazkii.botania.common.world.WorldTypeSkyblock; -import cpw.mods.fml.common.eventhandler.SubscribeEvent; public final class SkyblockRenderEvents { - @SubscribeEvent - public void onRender(RenderWorldLastEvent event) { - World world = Minecraft.getMinecraft().theWorld; - if(ConfigHandler.enableFancySkybox && world.provider.dimensionId == 0 && (ConfigHandler.enableFancySkyboxInNormalWorlds || WorldTypeSkyblock.isWorldSkyblock(Minecraft.getMinecraft().theWorld))) { - if(!(world.provider.getSkyRenderer() instanceof SkyblockSkyRenderer)) - world.provider.setSkyRenderer(new SkyblockSkyRenderer()); - } - } - + @SubscribeEvent + public void onRender(RenderWorldLastEvent event) { + World world = Minecraft.getMinecraft().theWorld; + if (ConfigHandler.enableFancySkybox + && world.provider.dimensionId == 0 + && (ConfigHandler.enableFancySkyboxInNormalWorlds + || WorldTypeSkyblock.isWorldSkyblock(Minecraft.getMinecraft().theWorld))) { + if (!(world.provider.getSkyRenderer() instanceof SkyblockSkyRenderer)) + world.provider.setSkyRenderer(new SkyblockSkyRenderer()); + } + } } diff --git a/src/main/java/vazkii/botania/client/render/world/SkyblockSkyRenderer.java b/src/main/java/vazkii/botania/client/render/world/SkyblockSkyRenderer.java index 39cc7a2162..432c99b367 100644 --- a/src/main/java/vazkii/botania/client/render/world/SkyblockSkyRenderer.java +++ b/src/main/java/vazkii/botania/client/render/world/SkyblockSkyRenderer.java @@ -2,16 +2,16 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [18/12/2015, 02:06:56 (GMT)] */ package vazkii.botania.client.render.world; +import cpw.mods.fml.relauncher.ReflectionHelper; import java.util.Random; - import net.minecraft.client.Minecraft; import net.minecraft.client.multiplayer.WorldClient; import net.minecraft.client.renderer.OpenGlHelper; @@ -22,349 +22,352 @@ import net.minecraft.util.ResourceLocation; import net.minecraft.util.Vec3; import net.minecraftforge.client.IRenderHandler; - import org.lwjgl.opengl.GL11; - import vazkii.botania.client.core.handler.ClientTickHandler; import vazkii.botania.client.lib.LibResources; import vazkii.botania.common.lib.LibObfuscation; -import cpw.mods.fml.relauncher.ReflectionHelper; public class SkyblockSkyRenderer extends IRenderHandler { - private static final ResourceLocation textureSkybox = new ResourceLocation(LibResources.MISC_SKYBOX); - private static final ResourceLocation textureRainbow = new ResourceLocation(LibResources.MISC_RAINBOW); - private static final ResourceLocation textureMoonPhases = new ResourceLocation("textures/environment/moon_phases.png"); - private static final ResourceLocation textureSun = new ResourceLocation("textures/environment/sun.png"); - private static final ResourceLocation[] planetTextures = new ResourceLocation[] { - new ResourceLocation(LibResources.MISC_PLANET + "0.png"), - new ResourceLocation(LibResources.MISC_PLANET + "1.png"), - new ResourceLocation(LibResources.MISC_PLANET + "2.png"), - new ResourceLocation(LibResources.MISC_PLANET + "3.png"), - new ResourceLocation(LibResources.MISC_PLANET + "4.png"), - new ResourceLocation(LibResources.MISC_PLANET + "5.png") - }; - - @Override - public void render(float partialTicks, WorldClient world, Minecraft mc) { - boolean test = false; - if(test) - return; - - int glSkyList = ReflectionHelper.getPrivateValue(RenderGlobal.class, mc.renderGlobal, LibObfuscation.GL_SKY_LIST); - int glSkyList2 = ReflectionHelper.getPrivateValue(RenderGlobal.class, mc.renderGlobal, LibObfuscation.GL_SKY_LIST2); // Horizon line. We don't have it here - int starGLCallList = ReflectionHelper.getPrivateValue(RenderGlobal.class, mc.renderGlobal, LibObfuscation.STAR_GL_CALL_LIST); - - GL11.glDisable(GL11.GL_TEXTURE_2D); - Vec3 vec3 = world.getSkyColor(mc.renderViewEntity, partialTicks); - float f1 = (float)vec3.xCoord; - float f2 = (float)vec3.yCoord; - float f3 = (float)vec3.zCoord; - float f6; - - float insideVoid = 0; - if(mc.thePlayer.posY <= -2) - insideVoid = (float) Math.min(1F, -(mc.thePlayer.posY + 2) / 30F); - - f1 = Math.max(0F, f1 - insideVoid); - f2 = Math.max(0F, f2 - insideVoid); - f3 = Math.max(0F, f3 - insideVoid); - - Tessellator tessellator1 = Tessellator.instance; - GL11.glDepthMask(false); - GL11.glEnable(GL11.GL_FOG); - GL11.glColor3f(f1, f2, f3); - GL11.glCallList(glSkyList); - GL11.glDisable(GL11.GL_FOG); - GL11.glDisable(GL11.GL_ALPHA_TEST); - GL11.glEnable(GL11.GL_BLEND); - OpenGlHelper.glBlendFunc(770, 771, 1, 0); - RenderHelper.disableStandardItemLighting(); - float[] afloat = world.provider.calcSunriseSunsetColors(world.getCelestialAngle(partialTicks), partialTicks); - float f7; - float f8; - float f9; - float f10; - - // === Sunset - if(afloat != null) { - GL11.glDisable(GL11.GL_TEXTURE_2D); - GL11.glShadeModel(GL11.GL_SMOOTH); - GL11.glPushMatrix(); - GL11.glRotatef(90.0F, 1.0F, 0.0F, 0.0F); - GL11.glRotatef(MathHelper.sin(world.getCelestialAngleRadians(partialTicks)) < 0.0F ? 180.0F : 0.0F, 0.0F, 0.0F, 1.0F); - GL11.glRotatef(90.0F, 0.0F, 0.0F, 1.0F); - f6 = afloat[0]; - f7 = afloat[1]; - f8 = afloat[2]; - float f11; - - tessellator1.startDrawing(6); - tessellator1.setColorRGBA_F(f6, f7, f8, afloat[3] * (1F - insideVoid)); - tessellator1.addVertex(0.0D, 100.0D, 0.0D); - byte b0 = 16; - tessellator1.setColorRGBA_F(afloat[0], afloat[1], afloat[2], 0.0F); - - for(int j = 0; j <= b0; ++j) { - f11 = (float)j * (float)Math.PI * 2.0F / (float)b0; - float f12 = MathHelper.sin(f11); - float f13 = MathHelper.cos(f11); - tessellator1.addVertex((double)(f12 * 120.0F), (double)(f13 * 120.0F), (double)(-f13 * 40.0F * afloat[3])); - } - - tessellator1.draw(); - GL11.glPopMatrix(); - GL11.glShadeModel(GL11.GL_FLAT); - } - - GL11.glEnable(GL11.GL_TEXTURE_2D); - GL11.glPushMatrix(); - f6 = Math.max(0.2F, 1.0F - world.getRainStrength(partialTicks)) * (1F - insideVoid); - f7 = 0.0F; - f8 = 0.0F; - f9 = 0.0F; - - GL11.glTranslatef(f7, f8, f9); - GL11.glRotatef(-90.0F, 0.0F, 1.0F, 0.0F); - - float celAng = world.getCelestialAngle(partialTicks); - float effCelAng = celAng; - if(celAng > 0.5) - effCelAng = 0.5F - (celAng - 0.5F); - - // === Planets - f10 = 20F; - float lowA = Math.max(0F, effCelAng - 0.3F) * f6; - float a = Math.max(0.1F, lowA); - - OpenGlHelper.glBlendFunc(770, 771, 1, 0); - GL11.glPushMatrix(); - GL11.glColor4f(1F, 1F, 1F, (a * 4) * (1F - insideVoid)); - GL11.glRotatef(90F, 0.5F, 0.5F, 0.0F); - for(int p = 0; p < planetTextures.length; p++) { - mc.renderEngine.bindTexture(planetTextures[p]); - drawObject(tessellator1, f10); - - switch(p) { - case 0: - GL11.glRotatef(70F, 1F, 0F, 0F); - f10 = 12F; - break; - case 1: - GL11.glRotatef(120F, 0F, 0F, 1F); - f10 = 15F; - break; - case 2: - GL11.glRotatef(80F, 1F, 0F, 1F); - f10 = 25F; - break; - case 3: - GL11.glRotatef(100F, 0F, 0F, 1F); - f10 = 10F; - break; - case 4: - GL11.glRotatef(-60F, 1F, 0F, 0.5F); - f10 = 40F; - } - } - GL11.glColor4f(1F, 1F, 1F, 1F); - GL11.glPopMatrix(); - - // === Rays - mc.renderEngine.bindTexture(textureSkybox); - - f10 = 20F; - a = lowA; - GL11.glPushMatrix(); - OpenGlHelper.glBlendFunc(770, 1, 1, 0); - GL11.glTranslatef(0F, -1F, 0F); - GL11.glRotatef(220F, 1F, 0F, 0F); - GL11.glColor4f(1F, 1F, 1F, a); - int angles = 90; - float s = 3F; - float m = 1F; - float y = 2F; - float y0 = 0F; - float uPer = 1F / 360F; - float anglePer = 360F / angles; - double fuzzPer = (Math.PI * 10) / angles; - float rotSpeed = 1F; - float rotSpeedMod = 0.4F; - - for(int p = 0; p < 3; p++) { - float baseAngle = rotSpeed * rotSpeedMod * (ClientTickHandler.ticksInGame + ClientTickHandler.partialTicks); - GL11.glRotatef((ClientTickHandler.ticksInGame + ClientTickHandler.partialTicks) * 0.25F * rotSpeed * rotSpeedMod, 0F, 1F, 0F); - - tessellator1.startDrawingQuads(); - for(int i = 0; i < angles; i++) { - int j = i; - if(i % 2 == 0) - j--; - - float ang = j * anglePer + baseAngle; - double xp = Math.cos(ang * Math.PI / 180F) * f10; - double zp = Math.sin(ang * Math.PI / 180F) * f10; - double yo = Math.sin(fuzzPer * j) * 1; - - float ut = ang * uPer; - if(i % 2 == 0) { - tessellator1.addVertexWithUV(xp, yo + y0 + y, zp, ut, 1F); - tessellator1.addVertexWithUV(xp, yo + y0, zp, ut, 0); - } else { - tessellator1.addVertexWithUV(xp, yo + y0, zp, ut, 0); - tessellator1.addVertexWithUV(xp, yo + y0 + y, zp, ut, 1F); - } - - } - tessellator1.draw(); - - switch(p) { - case 0: - GL11.glRotatef(20F, 1F, 0F, 0F); - GL11.glColor4f(1F, 0.4F, 0.4F, a); - fuzzPer = (Math.PI * 14) / angles; - rotSpeed = 0.2F; - break; - case 1: - GL11.glRotatef(50F, 1F, 0F, 0F); - GL11.glColor4f(0.4F, 1F, 0.7F, a); - fuzzPer = (Math.PI * 6) / angles; - rotSpeed = 2F; - break; - } - } - GL11.glPopMatrix(); - - // === Rainbow - GL11.glPushMatrix(); - OpenGlHelper.glBlendFunc(770, 771, 1, 0); - mc.renderEngine.bindTexture(textureRainbow); - f10 = 10F; - float effCelAng1 = celAng; - if(effCelAng1 > 0.25F) - effCelAng1 = 1F - effCelAng1; - effCelAng1 = 0.25F - Math.min(0.25F, effCelAng1); - - long time = world.getWorldTime() + 1000; - int day = (int) (time / 24000L); - Random rand = new Random(day * 0xFF); - float angle1 = rand.nextFloat() * 360F; - float angle2 = rand.nextFloat() * 360F; - GL11.glColor4f(1F, 1F, 1F, effCelAng1 * (1F - insideVoid)); - GL11.glRotatef(angle1, 0F, 1F, 0F); - GL11.glRotatef(angle2, 0F, 0F, 1F); - - tessellator1.startDrawingQuads(); - for(int i = 0; i < angles; i++) { - int j = i; - if(i % 2 == 0) - j--; - - float ang = j * anglePer; - double xp = Math.cos(ang * Math.PI / 180F) * f10; - double zp = Math.sin(ang * Math.PI / 180F) * f10; - double yo = 0; - - float ut = ang * uPer; - if(i % 2 == 0) { - tessellator1.addVertexWithUV(xp, yo + y0 + y, zp, ut, 1F); - tessellator1.addVertexWithUV(xp, yo + y0, zp, ut, 0); - } else { - tessellator1.addVertexWithUV(xp, yo + y0, zp, ut, 0); - tessellator1.addVertexWithUV(xp, yo + y0 + y, zp, ut, 1F); - } - - } - tessellator1.draw(); - GL11.glPopMatrix(); - - GL11.glColor4f(1F, 1F, 1F, 1F - insideVoid); - - OpenGlHelper.glBlendFunc(770, 1, 1, 0); - - // === Sun - GL11.glRotatef(world.getCelestialAngle(partialTicks) * 360.0F, 1.0F, 0.0F, 0.0F); - f10 = 60.0F; - mc.renderEngine.bindTexture(textureSun); - drawObject(tessellator1, f10); - - // === Moon - f10 = 60.0F; - mc.renderEngine.bindTexture(textureMoonPhases); - int k = world.getMoonPhase(); - int l = k % 4; - int i1 = k / 4 % 2; - float f14 = (float)(l + 0) / 4.0F; - float f15 = (float)(i1 + 0) / 2.0F; - float f16 = (float)(l + 1) / 4.0F; - float f17 = (float)(i1 + 1) / 2.0F; - tessellator1.startDrawingQuads(); - tessellator1.addVertexWithUV((double)(-f10), -100.0D, (double)f10, (double)f16, (double)f17); - tessellator1.addVertexWithUV((double)f10, -100.0D, (double)f10, (double)f14, (double)f17); - tessellator1.addVertexWithUV((double)f10, -100.0D, (double)(-f10), (double)f14, (double)f15); - tessellator1.addVertexWithUV((double)(-f10), -100.0D, (double)(-f10), (double)f16, (double)f15); - tessellator1.draw(); - - // === Stars - f6 *= Math.max(0.1F, effCelAng * 2); - float t = (ClientTickHandler.ticksInGame + partialTicks + 2000) * 0.005F; - GL11.glPushMatrix(); - GL11.glDisable(GL11.GL_TEXTURE_2D); - - GL11.glPushMatrix(); - GL11.glRotatef(t * 3, 0F, 1F, 0F); - GL11.glColor4f(1F, 1F, 1F, f6); - GL11.glCallList(starGLCallList); - GL11.glPopMatrix(); - - GL11.glPushMatrix(); - GL11.glRotatef(t, 0F, 1F, 0F); - GL11.glColor4f(0.5F, 1F, 1F, f6); - GL11.glCallList(starGLCallList); - GL11.glPopMatrix(); - - GL11.glPushMatrix(); - GL11.glRotatef(t * 2, 0F, 1F, 0F); - GL11.glColor4f(1F, 0.75F, 0.75F, f6); - GL11.glCallList(starGLCallList); - GL11.glPopMatrix(); - - GL11.glPushMatrix(); - GL11.glRotatef(t * 3, 0F, 0F, 1F); - GL11.glColor4f(1F, 1F, 1F, 0.25F * f6); - GL11.glCallList(starGLCallList); - GL11.glPopMatrix(); - - GL11.glPushMatrix(); - GL11.glRotatef(t, 0F, 0F, 1F); - GL11.glColor4f(0.5F, 1F, 1F, 0.25F * f6); - GL11.glCallList(starGLCallList); - GL11.glPopMatrix(); - - GL11.glPushMatrix(); - GL11.glRotatef(t * 2, 0F, 0F, 1F); - GL11.glColor4f(1F, 0.75F, 0.75F, 0.25F * f6); - GL11.glCallList(starGLCallList); - GL11.glPopMatrix(); - - GL11.glEnable(GL11.GL_TEXTURE_2D); - GL11.glPopMatrix(); - - GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); - GL11.glDisable(GL11.GL_BLEND); - GL11.glEnable(GL11.GL_ALPHA_TEST); - GL11.glEnable(GL11.GL_FOG); - GL11.glPopMatrix(); - GL11.glDepthMask(true); - } - - private void drawObject(Tessellator tess, float f10) { - tess.startDrawingQuads(); - tess.addVertexWithUV((double)(-f10), 100.0D, (double)(-f10), 0.0D, 0.0D); - tess.addVertexWithUV((double)f10, 100.0D, (double)(-f10), 1.0D, 0.0D); - tess.addVertexWithUV((double)f10, 100.0D, (double)f10, 1.0D, 1.0D); - tess.addVertexWithUV((double)(-f10), 100.0D, (double)f10, 0.0D, 1.0D); - tess.draw(); - } - + private static final ResourceLocation textureSkybox = new ResourceLocation(LibResources.MISC_SKYBOX); + private static final ResourceLocation textureRainbow = new ResourceLocation(LibResources.MISC_RAINBOW); + private static final ResourceLocation textureMoonPhases = + new ResourceLocation("textures/environment/moon_phases.png"); + private static final ResourceLocation textureSun = new ResourceLocation("textures/environment/sun.png"); + private static final ResourceLocation[] planetTextures = new ResourceLocation[] { + new ResourceLocation(LibResources.MISC_PLANET + "0.png"), + new ResourceLocation(LibResources.MISC_PLANET + "1.png"), + new ResourceLocation(LibResources.MISC_PLANET + "2.png"), + new ResourceLocation(LibResources.MISC_PLANET + "3.png"), + new ResourceLocation(LibResources.MISC_PLANET + "4.png"), + new ResourceLocation(LibResources.MISC_PLANET + "5.png") + }; + + @Override + public void render(float partialTicks, WorldClient world, Minecraft mc) { + boolean test = false; + if (test) return; + + int glSkyList = + ReflectionHelper.getPrivateValue(RenderGlobal.class, mc.renderGlobal, LibObfuscation.GL_SKY_LIST); + int glSkyList2 = ReflectionHelper.getPrivateValue( + RenderGlobal.class, + mc.renderGlobal, + LibObfuscation.GL_SKY_LIST2); // Horizon line. We don't have it here + int starGLCallList = + ReflectionHelper.getPrivateValue(RenderGlobal.class, mc.renderGlobal, LibObfuscation.STAR_GL_CALL_LIST); + + GL11.glDisable(GL11.GL_TEXTURE_2D); + Vec3 vec3 = world.getSkyColor(mc.renderViewEntity, partialTicks); + float f1 = (float) vec3.xCoord; + float f2 = (float) vec3.yCoord; + float f3 = (float) vec3.zCoord; + float f6; + + float insideVoid = 0; + if (mc.thePlayer.posY <= -2) insideVoid = (float) Math.min(1F, -(mc.thePlayer.posY + 2) / 30F); + + f1 = Math.max(0F, f1 - insideVoid); + f2 = Math.max(0F, f2 - insideVoid); + f3 = Math.max(0F, f3 - insideVoid); + + Tessellator tessellator1 = Tessellator.instance; + GL11.glDepthMask(false); + GL11.glEnable(GL11.GL_FOG); + GL11.glColor3f(f1, f2, f3); + GL11.glCallList(glSkyList); + GL11.glDisable(GL11.GL_FOG); + GL11.glDisable(GL11.GL_ALPHA_TEST); + GL11.glEnable(GL11.GL_BLEND); + OpenGlHelper.glBlendFunc(770, 771, 1, 0); + RenderHelper.disableStandardItemLighting(); + float[] afloat = world.provider.calcSunriseSunsetColors(world.getCelestialAngle(partialTicks), partialTicks); + float f7; + float f8; + float f9; + float f10; + + // === Sunset + if (afloat != null) { + GL11.glDisable(GL11.GL_TEXTURE_2D); + GL11.glShadeModel(GL11.GL_SMOOTH); + GL11.glPushMatrix(); + GL11.glRotatef(90.0F, 1.0F, 0.0F, 0.0F); + GL11.glRotatef( + MathHelper.sin(world.getCelestialAngleRadians(partialTicks)) < 0.0F ? 180.0F : 0.0F, + 0.0F, + 0.0F, + 1.0F); + GL11.glRotatef(90.0F, 0.0F, 0.0F, 1.0F); + f6 = afloat[0]; + f7 = afloat[1]; + f8 = afloat[2]; + float f11; + + tessellator1.startDrawing(6); + tessellator1.setColorRGBA_F(f6, f7, f8, afloat[3] * (1F - insideVoid)); + tessellator1.addVertex(0.0D, 100.0D, 0.0D); + byte b0 = 16; + tessellator1.setColorRGBA_F(afloat[0], afloat[1], afloat[2], 0.0F); + + for (int j = 0; j <= b0; ++j) { + f11 = (float) j * (float) Math.PI * 2.0F / (float) b0; + float f12 = MathHelper.sin(f11); + float f13 = MathHelper.cos(f11); + tessellator1.addVertex( + (double) (f12 * 120.0F), (double) (f13 * 120.0F), (double) (-f13 * 40.0F * afloat[3])); + } + + tessellator1.draw(); + GL11.glPopMatrix(); + GL11.glShadeModel(GL11.GL_FLAT); + } + + GL11.glEnable(GL11.GL_TEXTURE_2D); + GL11.glPushMatrix(); + f6 = Math.max(0.2F, 1.0F - world.getRainStrength(partialTicks)) * (1F - insideVoid); + f7 = 0.0F; + f8 = 0.0F; + f9 = 0.0F; + + GL11.glTranslatef(f7, f8, f9); + GL11.glRotatef(-90.0F, 0.0F, 1.0F, 0.0F); + + float celAng = world.getCelestialAngle(partialTicks); + float effCelAng = celAng; + if (celAng > 0.5) effCelAng = 0.5F - (celAng - 0.5F); + + // === Planets + f10 = 20F; + float lowA = Math.max(0F, effCelAng - 0.3F) * f6; + float a = Math.max(0.1F, lowA); + + OpenGlHelper.glBlendFunc(770, 771, 1, 0); + GL11.glPushMatrix(); + GL11.glColor4f(1F, 1F, 1F, (a * 4) * (1F - insideVoid)); + GL11.glRotatef(90F, 0.5F, 0.5F, 0.0F); + for (int p = 0; p < planetTextures.length; p++) { + mc.renderEngine.bindTexture(planetTextures[p]); + drawObject(tessellator1, f10); + + switch (p) { + case 0: + GL11.glRotatef(70F, 1F, 0F, 0F); + f10 = 12F; + break; + case 1: + GL11.glRotatef(120F, 0F, 0F, 1F); + f10 = 15F; + break; + case 2: + GL11.glRotatef(80F, 1F, 0F, 1F); + f10 = 25F; + break; + case 3: + GL11.glRotatef(100F, 0F, 0F, 1F); + f10 = 10F; + break; + case 4: + GL11.glRotatef(-60F, 1F, 0F, 0.5F); + f10 = 40F; + } + } + GL11.glColor4f(1F, 1F, 1F, 1F); + GL11.glPopMatrix(); + + // === Rays + mc.renderEngine.bindTexture(textureSkybox); + + f10 = 20F; + a = lowA; + GL11.glPushMatrix(); + OpenGlHelper.glBlendFunc(770, 1, 1, 0); + GL11.glTranslatef(0F, -1F, 0F); + GL11.glRotatef(220F, 1F, 0F, 0F); + GL11.glColor4f(1F, 1F, 1F, a); + int angles = 90; + float s = 3F; + float m = 1F; + float y = 2F; + float y0 = 0F; + float uPer = 1F / 360F; + float anglePer = 360F / angles; + double fuzzPer = (Math.PI * 10) / angles; + float rotSpeed = 1F; + float rotSpeedMod = 0.4F; + + for (int p = 0; p < 3; p++) { + float baseAngle = rotSpeed * rotSpeedMod * (ClientTickHandler.ticksInGame + ClientTickHandler.partialTicks); + GL11.glRotatef( + (ClientTickHandler.ticksInGame + ClientTickHandler.partialTicks) * 0.25F * rotSpeed * rotSpeedMod, + 0F, + 1F, + 0F); + + tessellator1.startDrawingQuads(); + for (int i = 0; i < angles; i++) { + int j = i; + if (i % 2 == 0) j--; + + float ang = j * anglePer + baseAngle; + double xp = Math.cos(ang * Math.PI / 180F) * f10; + double zp = Math.sin(ang * Math.PI / 180F) * f10; + double yo = Math.sin(fuzzPer * j) * 1; + + float ut = ang * uPer; + if (i % 2 == 0) { + tessellator1.addVertexWithUV(xp, yo + y0 + y, zp, ut, 1F); + tessellator1.addVertexWithUV(xp, yo + y0, zp, ut, 0); + } else { + tessellator1.addVertexWithUV(xp, yo + y0, zp, ut, 0); + tessellator1.addVertexWithUV(xp, yo + y0 + y, zp, ut, 1F); + } + } + tessellator1.draw(); + + switch (p) { + case 0: + GL11.glRotatef(20F, 1F, 0F, 0F); + GL11.glColor4f(1F, 0.4F, 0.4F, a); + fuzzPer = (Math.PI * 14) / angles; + rotSpeed = 0.2F; + break; + case 1: + GL11.glRotatef(50F, 1F, 0F, 0F); + GL11.glColor4f(0.4F, 1F, 0.7F, a); + fuzzPer = (Math.PI * 6) / angles; + rotSpeed = 2F; + break; + } + } + GL11.glPopMatrix(); + + // === Rainbow + GL11.glPushMatrix(); + OpenGlHelper.glBlendFunc(770, 771, 1, 0); + mc.renderEngine.bindTexture(textureRainbow); + f10 = 10F; + float effCelAng1 = celAng; + if (effCelAng1 > 0.25F) effCelAng1 = 1F - effCelAng1; + effCelAng1 = 0.25F - Math.min(0.25F, effCelAng1); + + long time = world.getWorldTime() + 1000; + int day = (int) (time / 24000L); + Random rand = new Random(day * 0xFF); + float angle1 = rand.nextFloat() * 360F; + float angle2 = rand.nextFloat() * 360F; + GL11.glColor4f(1F, 1F, 1F, effCelAng1 * (1F - insideVoid)); + GL11.glRotatef(angle1, 0F, 1F, 0F); + GL11.glRotatef(angle2, 0F, 0F, 1F); + + tessellator1.startDrawingQuads(); + for (int i = 0; i < angles; i++) { + int j = i; + if (i % 2 == 0) j--; + + float ang = j * anglePer; + double xp = Math.cos(ang * Math.PI / 180F) * f10; + double zp = Math.sin(ang * Math.PI / 180F) * f10; + double yo = 0; + + float ut = ang * uPer; + if (i % 2 == 0) { + tessellator1.addVertexWithUV(xp, yo + y0 + y, zp, ut, 1F); + tessellator1.addVertexWithUV(xp, yo + y0, zp, ut, 0); + } else { + tessellator1.addVertexWithUV(xp, yo + y0, zp, ut, 0); + tessellator1.addVertexWithUV(xp, yo + y0 + y, zp, ut, 1F); + } + } + tessellator1.draw(); + GL11.glPopMatrix(); + + GL11.glColor4f(1F, 1F, 1F, 1F - insideVoid); + + OpenGlHelper.glBlendFunc(770, 1, 1, 0); + + // === Sun + GL11.glRotatef(world.getCelestialAngle(partialTicks) * 360.0F, 1.0F, 0.0F, 0.0F); + f10 = 60.0F; + mc.renderEngine.bindTexture(textureSun); + drawObject(tessellator1, f10); + + // === Moon + f10 = 60.0F; + mc.renderEngine.bindTexture(textureMoonPhases); + int k = world.getMoonPhase(); + int l = k % 4; + int i1 = k / 4 % 2; + float f14 = (float) (l + 0) / 4.0F; + float f15 = (float) (i1 + 0) / 2.0F; + float f16 = (float) (l + 1) / 4.0F; + float f17 = (float) (i1 + 1) / 2.0F; + tessellator1.startDrawingQuads(); + tessellator1.addVertexWithUV((double) (-f10), -100.0D, (double) f10, (double) f16, (double) f17); + tessellator1.addVertexWithUV((double) f10, -100.0D, (double) f10, (double) f14, (double) f17); + tessellator1.addVertexWithUV((double) f10, -100.0D, (double) (-f10), (double) f14, (double) f15); + tessellator1.addVertexWithUV((double) (-f10), -100.0D, (double) (-f10), (double) f16, (double) f15); + tessellator1.draw(); + + // === Stars + f6 *= Math.max(0.1F, effCelAng * 2); + float t = (ClientTickHandler.ticksInGame + partialTicks + 2000) * 0.005F; + GL11.glPushMatrix(); + GL11.glDisable(GL11.GL_TEXTURE_2D); + + GL11.glPushMatrix(); + GL11.glRotatef(t * 3, 0F, 1F, 0F); + GL11.glColor4f(1F, 1F, 1F, f6); + GL11.glCallList(starGLCallList); + GL11.glPopMatrix(); + + GL11.glPushMatrix(); + GL11.glRotatef(t, 0F, 1F, 0F); + GL11.glColor4f(0.5F, 1F, 1F, f6); + GL11.glCallList(starGLCallList); + GL11.glPopMatrix(); + + GL11.glPushMatrix(); + GL11.glRotatef(t * 2, 0F, 1F, 0F); + GL11.glColor4f(1F, 0.75F, 0.75F, f6); + GL11.glCallList(starGLCallList); + GL11.glPopMatrix(); + + GL11.glPushMatrix(); + GL11.glRotatef(t * 3, 0F, 0F, 1F); + GL11.glColor4f(1F, 1F, 1F, 0.25F * f6); + GL11.glCallList(starGLCallList); + GL11.glPopMatrix(); + + GL11.glPushMatrix(); + GL11.glRotatef(t, 0F, 0F, 1F); + GL11.glColor4f(0.5F, 1F, 1F, 0.25F * f6); + GL11.glCallList(starGLCallList); + GL11.glPopMatrix(); + + GL11.glPushMatrix(); + GL11.glRotatef(t * 2, 0F, 0F, 1F); + GL11.glColor4f(1F, 0.75F, 0.75F, 0.25F * f6); + GL11.glCallList(starGLCallList); + GL11.glPopMatrix(); + + GL11.glEnable(GL11.GL_TEXTURE_2D); + GL11.glPopMatrix(); + + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + GL11.glDisable(GL11.GL_BLEND); + GL11.glEnable(GL11.GL_ALPHA_TEST); + GL11.glEnable(GL11.GL_FOG); + GL11.glPopMatrix(); + GL11.glDepthMask(true); + } + + private void drawObject(Tessellator tess, float f10) { + tess.startDrawingQuads(); + tess.addVertexWithUV((double) (-f10), 100.0D, (double) (-f10), 0.0D, 0.0D); + tess.addVertexWithUV((double) f10, 100.0D, (double) (-f10), 1.0D, 0.0D); + tess.addVertexWithUV((double) f10, 100.0D, (double) f10, 1.0D, 1.0D); + tess.addVertexWithUV((double) (-f10), 100.0D, (double) f10, 0.0D, 1.0D); + tess.draw(); + } } diff --git a/src/main/java/vazkii/botania/common/Botania.java b/src/main/java/vazkii/botania/common/Botania.java index 8d43e9d713..0366d12e43 100644 --- a/src/main/java/vazkii/botania/common/Botania.java +++ b/src/main/java/vazkii/botania/common/Botania.java @@ -2,21 +2,14 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jan 13, 2014, 6:32:39 PM (GMT)] */ package vazkii.botania.common; -import vazkii.botania.common.core.handler.IMCHandler; -import vazkii.botania.common.core.handler.ManaNetworkHandler; -import vazkii.botania.common.core.proxy.CommonProxy; -import vazkii.botania.common.integration.coloredlights.ILightHelper; -import vazkii.botania.common.integration.coloredlights.LightHelperColored; -import vazkii.botania.common.integration.coloredlights.LightHelperVanilla; -import vazkii.botania.common.lib.LibMisc; import cpw.mods.fml.common.Loader; import cpw.mods.fml.common.Mod; import cpw.mods.fml.common.Mod.EventHandler; @@ -30,74 +23,87 @@ import cpw.mods.fml.common.event.FMLServerAboutToStartEvent; import cpw.mods.fml.common.event.FMLServerStartingEvent; import cpw.mods.fml.common.event.FMLServerStoppingEvent; +import vazkii.botania.common.core.handler.IMCHandler; +import vazkii.botania.common.core.handler.ManaNetworkHandler; +import vazkii.botania.common.core.proxy.CommonProxy; +import vazkii.botania.common.integration.coloredlights.ILightHelper; +import vazkii.botania.common.integration.coloredlights.LightHelperColored; +import vazkii.botania.common.integration.coloredlights.LightHelperVanilla; +import vazkii.botania.common.lib.LibMisc; -@Mod(modid = LibMisc.MOD_ID, name = LibMisc.MOD_NAME, version = LibMisc.VERSION, dependencies = LibMisc.DEPENDENCIES, guiFactory = LibMisc.GUI_FACTORY) +@Mod( + modid = LibMisc.MOD_ID, + name = LibMisc.MOD_NAME, + version = LibMisc.VERSION, + dependencies = LibMisc.DEPENDENCIES, + guiFactory = LibMisc.GUI_FACTORY) public class Botania { - public static boolean gardenOfGlassLoaded = false; - - public static boolean thaumcraftLoaded = false; - public static boolean bcTriggersLoaded = false; - public static boolean bloodMagicLoaded = false; - public static boolean coloredLightsLoaded = false; - public static boolean etFuturumLoaded = false; - public static boolean storageDrawersLoaded = false; - - public static ILightHelper lightHelper; - - @Instance(LibMisc.MOD_ID) - public static Botania instance; - - @SidedProxy(serverSide = LibMisc.PROXY_COMMON, clientSide = LibMisc.PROXY_CLIENT) - public static CommonProxy proxy; - - @EventHandler - public void preInit(FMLPreInitializationEvent event) { - gardenOfGlassLoaded = Loader.isModLoaded("GardenOfGlass"); - - thaumcraftLoaded = Loader.isModLoaded("Thaumcraft"); - bcTriggersLoaded = ModAPIManager.INSTANCE.hasAPI("BuildCraftAPI|statements"); - bloodMagicLoaded = Loader.isModLoaded("AWWayofTime"); // Psh, noob - coloredLightsLoaded = Loader.isModLoaded("easycoloredlights"); - etFuturumLoaded = Loader.isModLoaded("etfuturum"); - storageDrawersLoaded = Loader.isModLoaded("StorageDrawers"); - - lightHelper = coloredLightsLoaded ? new LightHelperColored() : new LightHelperVanilla(); - - proxy.preInit(event); - } - @EventHandler - public void init(FMLInitializationEvent event) { - proxy.init(event); - } - - @EventHandler - public void postInit(FMLPostInitializationEvent event) { - proxy.postInit(event); - } - - @EventHandler - public void serverStarting(FMLServerAboutToStartEvent event) { - proxy.serverAboutToStart(event); - } - - @EventHandler - public void serverStarting(FMLServerStartingEvent event) { - proxy.serverStarting(event); - } - - @EventHandler - public void serverStopping(FMLServerStoppingEvent event) { - ManaNetworkHandler.instance.clear(); - } - - @EventHandler - public void handleIMC(FMLInterModComms.IMCEvent event) { - IMCHandler.processMessages(event.getMessages()); - } - - /*@EventHandler - public void missingMappings(FMLMissingMappingsEvent event) { - AliasHandler.onMissingMappings(event); - }*/ + public static boolean gardenOfGlassLoaded = false; + + public static boolean thaumcraftLoaded = false; + public static boolean bcTriggersLoaded = false; + public static boolean bloodMagicLoaded = false; + public static boolean coloredLightsLoaded = false; + public static boolean etFuturumLoaded = false; + public static boolean storageDrawersLoaded = false; + + public static ILightHelper lightHelper; + + @Instance(LibMisc.MOD_ID) + public static Botania instance; + + @SidedProxy(serverSide = LibMisc.PROXY_COMMON, clientSide = LibMisc.PROXY_CLIENT) + public static CommonProxy proxy; + + @EventHandler + public void preInit(FMLPreInitializationEvent event) { + gardenOfGlassLoaded = Loader.isModLoaded("GardenOfGlass"); + + thaumcraftLoaded = Loader.isModLoaded("Thaumcraft"); + bcTriggersLoaded = ModAPIManager.INSTANCE.hasAPI("BuildCraftAPI|statements"); + bloodMagicLoaded = Loader.isModLoaded("AWWayofTime"); // Psh, noob + coloredLightsLoaded = Loader.isModLoaded("easycoloredlights"); + etFuturumLoaded = Loader.isModLoaded("etfuturum"); + storageDrawersLoaded = Loader.isModLoaded("StorageDrawers"); + + lightHelper = coloredLightsLoaded ? new LightHelperColored() : new LightHelperVanilla(); + + proxy.preInit(event); + } + + @EventHandler + public void init(FMLInitializationEvent event) { + proxy.init(event); + } + + @EventHandler + public void postInit(FMLPostInitializationEvent event) { + proxy.postInit(event); + } + + @EventHandler + public void serverStarting(FMLServerAboutToStartEvent event) { + proxy.serverAboutToStart(event); + } + + @EventHandler + public void serverStarting(FMLServerStartingEvent event) { + proxy.serverStarting(event); + } + + @EventHandler + public void serverStopping(FMLServerStoppingEvent event) { + ManaNetworkHandler.instance.clear(); + } + + @EventHandler + public void handleIMC(FMLInterModComms.IMCEvent event) { + IMCHandler.processMessages(event.getMessages()); + } + + /*@EventHandler + public void missingMappings(FMLMissingMappingsEvent event) { + AliasHandler.onMissingMappings(event); + }*/ } diff --git a/src/main/java/vazkii/botania/common/CustomBotaniaAPI.java b/src/main/java/vazkii/botania/common/CustomBotaniaAPI.java index 0bf1db8bc2..a67d948473 100644 --- a/src/main/java/vazkii/botania/common/CustomBotaniaAPI.java +++ b/src/main/java/vazkii/botania/common/CustomBotaniaAPI.java @@ -1,11 +1,9 @@ package vazkii.botania.common; -import net.minecraft.item.Item; -import vazkii.botania.api.recipe.IFlowerComponent; - import java.util.HashMap; import java.util.Map; -import java.util.Set; +import net.minecraft.item.Item; +import vazkii.botania.api.recipe.IFlowerComponent; public class CustomBotaniaAPI { public static Map extraFlowerComponents = new HashMap(); diff --git a/src/main/java/vazkii/botania/common/achievement/AchievementMod.java b/src/main/java/vazkii/botania/common/achievement/AchievementMod.java index 7da1fa5f2c..359ec44d29 100644 --- a/src/main/java/vazkii/botania/common/achievement/AchievementMod.java +++ b/src/main/java/vazkii/botania/common/achievement/AchievementMod.java @@ -2,17 +2,16 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jan 28, 2015, 4:41:43 PM (GMT)] */ package vazkii.botania.common.achievement; import java.util.ArrayList; import java.util.List; - import net.minecraft.block.Block; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; @@ -21,23 +20,21 @@ public class AchievementMod extends Achievement { - public static List achievements = new ArrayList(); - - public AchievementMod(String name, int x, int y, ItemStack icon, Achievement parent) { - super("achievement.botania:" + name, "botania:" + name, x, y, icon, parent); - achievements.add(this); - registerStat(); + public static List achievements = new ArrayList(); - if(icon.getItem() instanceof IRelic) - ((IRelic) icon.getItem()).setBindAchievement(this); - } + public AchievementMod(String name, int x, int y, ItemStack icon, Achievement parent) { + super("achievement.botania:" + name, "botania:" + name, x, y, icon, parent); + achievements.add(this); + registerStat(); - public AchievementMod(String name, int x, int y, Item icon, Achievement parent) { - this(name, x, y, new ItemStack(icon), parent); - } + if (icon.getItem() instanceof IRelic) ((IRelic) icon.getItem()).setBindAchievement(this); + } - public AchievementMod(String name, int x, int y, Block icon, Achievement parent) { - this(name, x, y, new ItemStack(icon), parent); - } + public AchievementMod(String name, int x, int y, Item icon, Achievement parent) { + this(name, x, y, new ItemStack(icon), parent); + } + public AchievementMod(String name, int x, int y, Block icon, Achievement parent) { + this(name, x, y, new ItemStack(icon), parent); + } } diff --git a/src/main/java/vazkii/botania/common/achievement/AchievementTriggerer.java b/src/main/java/vazkii/botania/common/achievement/AchievementTriggerer.java index 0d67196f9e..36a69ce612 100644 --- a/src/main/java/vazkii/botania/common/achievement/AchievementTriggerer.java +++ b/src/main/java/vazkii/botania/common/achievement/AchievementTriggerer.java @@ -2,39 +2,38 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jan 28, 2015, 5:57:07 PM (GMT)] */ package vazkii.botania.common.achievement; -import net.minecraft.item.ItemStack; -import net.minecraft.stats.Achievement; import cpw.mods.fml.common.eventhandler.SubscribeEvent; import cpw.mods.fml.common.gameevent.PlayerEvent.ItemCraftedEvent; import cpw.mods.fml.common.gameevent.PlayerEvent.ItemPickupEvent; +import net.minecraft.item.ItemStack; +import net.minecraft.stats.Achievement; public final class AchievementTriggerer { - @SubscribeEvent - public void onItemPickedUp(ItemPickupEvent event) { - ItemStack stack = event.pickedUp.getEntityItem(); - if(stack != null && stack.getItem() instanceof IPickupAchievement) { - Achievement achievement = ((IPickupAchievement) stack.getItem()).getAchievementOnPickup(stack, event.player, event.pickedUp); - if(achievement != null) - event.player.addStat(achievement, 1); - } - } - - @SubscribeEvent - public void onItemCrafted(ItemCraftedEvent event) { - if(event.crafting != null && event.crafting.getItem() instanceof ICraftAchievement) { - Achievement achievement = ((ICraftAchievement) event.crafting.getItem()).getAchievementOnCraft(event.crafting, event.player, event.craftMatrix); - if(achievement != null) - event.player.addStat(achievement, 1); - } - } + @SubscribeEvent + public void onItemPickedUp(ItemPickupEvent event) { + ItemStack stack = event.pickedUp.getEntityItem(); + if (stack != null && stack.getItem() instanceof IPickupAchievement) { + Achievement achievement = + ((IPickupAchievement) stack.getItem()).getAchievementOnPickup(stack, event.player, event.pickedUp); + if (achievement != null) event.player.addStat(achievement, 1); + } + } + @SubscribeEvent + public void onItemCrafted(ItemCraftedEvent event) { + if (event.crafting != null && event.crafting.getItem() instanceof ICraftAchievement) { + Achievement achievement = ((ICraftAchievement) event.crafting.getItem()) + .getAchievementOnCraft(event.crafting, event.player, event.craftMatrix); + if (achievement != null) event.player.addStat(achievement, 1); + } + } } diff --git a/src/main/java/vazkii/botania/common/achievement/ICraftAchievement.java b/src/main/java/vazkii/botania/common/achievement/ICraftAchievement.java index 279fb06db5..06b99f1d68 100644 --- a/src/main/java/vazkii/botania/common/achievement/ICraftAchievement.java +++ b/src/main/java/vazkii/botania/common/achievement/ICraftAchievement.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jan 28, 2015, 5:59:07 PM (GMT)] */ package vazkii.botania.common.achievement; @@ -17,6 +17,5 @@ public interface ICraftAchievement { - public Achievement getAchievementOnCraft(ItemStack stack, EntityPlayer player, IInventory matrix); - + public Achievement getAchievementOnCraft(ItemStack stack, EntityPlayer player, IInventory matrix); } diff --git a/src/main/java/vazkii/botania/common/achievement/IPickupAchievement.java b/src/main/java/vazkii/botania/common/achievement/IPickupAchievement.java index 2276c2f1cf..7a14b22981 100644 --- a/src/main/java/vazkii/botania/common/achievement/IPickupAchievement.java +++ b/src/main/java/vazkii/botania/common/achievement/IPickupAchievement.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jan 28, 2015, 5:59:03 PM (GMT)] */ package vazkii.botania.common.achievement; @@ -17,6 +17,5 @@ public interface IPickupAchievement { - public Achievement getAchievementOnPickup(ItemStack stack, EntityPlayer player, EntityItem item); - + public Achievement getAchievementOnPickup(ItemStack stack, EntityPlayer player, EntityItem item); } diff --git a/src/main/java/vazkii/botania/common/achievement/ModAchievements.java b/src/main/java/vazkii/botania/common/achievement/ModAchievements.java index 9db5d62dda..e08509de71 100644 --- a/src/main/java/vazkii/botania/common/achievement/ModAchievements.java +++ b/src/main/java/vazkii/botania/common/achievement/ModAchievements.java @@ -2,14 +2,15 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jan 28, 2015, 4:27:39 PM (GMT)] */ package vazkii.botania.common.achievement; +import cpw.mods.fml.common.FMLCommonHandler; import net.minecraft.init.Items; import net.minecraft.item.ItemStack; import net.minecraft.stats.Achievement; @@ -21,144 +22,217 @@ import vazkii.botania.common.lib.LibAchievementNames; import vazkii.botania.common.lib.LibBlockNames; import vazkii.botania.common.lib.LibMisc; -import cpw.mods.fml.common.FMLCommonHandler; public final class ModAchievements { - public static AchievementPage botaniaPage; - public static int pageIndex; - - public static Achievement flowerPickup; - public static Achievement lexiconUse; - public static Achievement daybloomPickup; - public static Achievement cacophoniumCraft; - public static Achievement manaPoolPickup; - - public static Achievement endoflamePickup; - public static Achievement tinyPotatoPet; - public static Achievement sparkCraft; - public static Achievement baubleWear; - public static Achievement manaCookieEat; - public static Achievement manaweaveArmorCraft; - public static Achievement craftingHaloCraft; - public static Achievement manaCartCraft; - public static Achievement enchanterMake; - public static Achievement runePickup; - - public static Achievement dirtRodCraft; - public static Achievement terraformRodCraft; - public static Achievement manaBlasterShoot; - public static Achievement pollidisiacPickup; - public static Achievement brewPickup; - public static Achievement terrasteelPickup; - - public static Achievement terrasteelWeaponCraft; - public static Achievement elfPortalOpen; - - public static Achievement kekimurusPickup; - public static Achievement heiseiDreamPickup; - public static Achievement bubbellPickup; - public static Achievement luminizerRide; - - public static Achievement enderAirMake; - public static Achievement corporeaCraft; - - public static Achievement gaiaGuardianKill; - - public static Achievement spawnerMoverUse; - public static Achievement tiaraWings; - public static Achievement manaBombIgnite; - public static Achievement dandelifeonPickup; - - public static Achievement signalFlareStun; - public static Achievement l20ShardUse; - public static Achievement gaiaGuardianNoArmor; - public static Achievement rankSSPick; - public static Achievement superCorporeaRequest; - public static Achievement pinkinator; - - public static Achievement relicInfiniteFruit; - public static Achievement relicKingKey; - public static Achievement relicFlugelEye; - public static Achievement relicThorRing; - public static Achievement relicOdinRing; - public static Achievement relicLokiRing; - public static Achievement relicAesirRing; - - public static Achievement nullFlower; - public static Achievement desuGun; - - public static void init() { - flowerPickup = new AchievementMod(LibAchievementNames.FLOWER_PICKUP, 0, 4, new ItemStack(ModBlocks.flower, 1, 6), null); - lexiconUse = new AchievementMod(LibAchievementNames.LEXICON_USE, 1, 5, ModItems.lexicon, flowerPickup); - daybloomPickup = new AchievementMod(LibAchievementNames.DAYBLOOM_PICKUP, 3, 5, ItemBlockSpecialFlower.ofType(LibBlockNames.SUBTILE_DAYBLOOM), lexiconUse); - cacophoniumCraft = new AchievementMod(LibAchievementNames.CACOPHONIUM_CRAFT, -1, 2, ModItems.cacophonium, flowerPickup); - manaPoolPickup = new AchievementMod(LibAchievementNames.MANA_POOL_PICKUP, 3, 2, ModBlocks.pool, daybloomPickup); - - endoflamePickup = new AchievementMod(LibAchievementNames.ENDOFLAME_PICKUP, 2, 0, ItemBlockSpecialFlower.ofType(LibBlockNames.SUBTILE_ENDOFLAME), manaPoolPickup); - tinyPotatoPet = new AchievementMod(LibAchievementNames.TINY_POTATO_PET, 2, -2, ModBlocks.tinyPotato, manaPoolPickup); - sparkCraft = new AchievementMod(LibAchievementNames.SPARK_CRAFT, 4, -2, ModItems.spark, manaPoolPickup); - baubleWear = new AchievementMod(LibAchievementNames.BAUBLE_WEAR, 4, 0, ModItems.manaRing, manaPoolPickup); - manaCookieEat = new AchievementMod(LibAchievementNames.MANA_COOKIE_EAT, 2, -4, ModItems.manaCookie, manaPoolPickup); - manaweaveArmorCraft = new AchievementMod(LibAchievementNames.MANAWEAVE_ARMOR_CRAFT, 4, -4, ModItems.manaweaveChest, manaPoolPickup); - craftingHaloCraft = new AchievementMod(LibAchievementNames.CRAFTING_HALO_CRAFT, 3, -6, ModItems.craftingHalo, manaPoolPickup); - manaCartCraft = new AchievementMod(LibAchievementNames.MANA_CART_CRAFT, 5, 3, ModItems.poolMinecart, manaPoolPickup); - enchanterMake = new AchievementMod(LibAchievementNames.ENCHANTER_MAKE, 1, 2, ModBlocks.enchanter, manaPoolPickup); - runePickup = new AchievementMod(LibAchievementNames.RUNE_PICKUP, 6, 2, ModBlocks.runeAltar, manaPoolPickup); - - dirtRodCraft = new AchievementMod(LibAchievementNames.DIRT_ROD_CRAFT, 8, 3, ModItems.dirtRod, runePickup); - terraformRodCraft = new AchievementMod(LibAchievementNames.TERRAFORM_ROD_CRAFT, 10, 3, ModItems.terraformRod, dirtRodCraft); - manaBlasterShoot = new AchievementMod(LibAchievementNames.MANA_BLASTER_SHOOT, 8, 1, ModItems.manaGun, runePickup); - pollidisiacPickup = new AchievementMod(LibAchievementNames.POLLIDISIAC_PICKUP, 8, 5, ItemBlockSpecialFlower.ofType(LibBlockNames.SUBTILE_POLLIDISIAC), runePickup); - brewPickup = new AchievementMod(LibAchievementNames.BREW_PICKUP, 6, 0, ModBlocks.brewery, runePickup); - terrasteelPickup = new AchievementMod(LibAchievementNames.TERRASTEEL_PICKUP, 6, 9, new ItemStack(ModItems.manaResource, 1, 4), runePickup).setSpecial(); - - terrasteelWeaponCraft = new AchievementMod(LibAchievementNames.TERRASTEEL_WEAPON_CRAFT, 8, 10, ModItems.terraSword, terrasteelPickup); - elfPortalOpen = new AchievementMod(LibAchievementNames.ELF_PORTAL_OPEN, 4, 9, ModBlocks.alfPortal, terrasteelPickup).setSpecial(); - - kekimurusPickup = new AchievementMod(LibAchievementNames.KEKIMURUS_PICKUP, 3, 11, ItemBlockSpecialFlower.ofType(LibBlockNames.SUBTILE_KEKIMURUS), elfPortalOpen); - heiseiDreamPickup = new AchievementMod(LibAchievementNames.HEISEI_DREAM_PICKUP, 5, 11, ItemBlockSpecialFlower.ofType(LibBlockNames.SUBTILE_HEISEI_DREAM), elfPortalOpen); - bubbellPickup = new AchievementMod(LibAchievementNames.BUBBELL_PICKUP, 6, 12, ItemBlockSpecialFlower.ofType(LibBlockNames.SUBTILE_BUBBELL), elfPortalOpen); - enderAirMake = new AchievementMod(LibAchievementNames.ENDER_AIR_MAKE, 4, 14, new ItemStack(ModItems.manaResource, 1, 15), elfPortalOpen); - corporeaCraft = new AchievementMod(LibAchievementNames.CORPOREA_CRAFT, 2, 14, ModBlocks.corporeaFunnel, enderAirMake); - luminizerRide = new AchievementMod(LibAchievementNames.LUMINIZER_RIDE, 6, 14, ModBlocks.lightRelay, enderAirMake); - - gaiaGuardianKill = new AchievementMod(LibAchievementNames.GAIA_GUARDIAN_KILL, 2, 9, new ItemStack(ModItems.manaResource, 1, 5), elfPortalOpen).setSpecial(); - - spawnerMoverUse = new AchievementMod(LibAchievementNames.SPAWNER_MOVER_USE, -1, 10, ModItems.spawnerMover, gaiaGuardianKill); - tiaraWings = new AchievementMod(LibAchievementNames.TIARA_WINGS, -1, 8, ModItems.flightTiara, gaiaGuardianKill); - manaBombIgnite = new AchievementMod(LibAchievementNames.MANA_BOMB_IGNITE, 0, 11, ModBlocks.manaBomb, gaiaGuardianKill); - dandelifeonPickup = new AchievementMod(LibAchievementNames.DANDELIFEON_PICKUP, 0, 7, ItemBlockSpecialFlower.ofType(LibBlockNames.SUBTILE_DANDELIFEON), gaiaGuardianKill); - - signalFlareStun = new AchievementMod(LibAchievementNames.SIGNAL_FLARE_STUN, -3, 1, ModItems.signalFlare, null).setSpecial(); - l20ShardUse = new AchievementMod(LibAchievementNames.L20_SHARD_USE, -5, 3, ModItems.laputaShard, null).setSpecial(); - gaiaGuardianNoArmor = new AchievementMod(LibAchievementNames.GAIA_GUARDIAN_NO_ARMOR, -5, 1, new ItemStack(Items.skull, 1, 3), null).setSpecial(); - rankSSPick = new AchievementMod(LibAchievementNames.RANK_SS_PICK, -3, 3, ModItems.terraPick, null).setSpecial(); - superCorporeaRequest = new AchievementMod(LibAchievementNames.SUPER_CORPOREA_REQUEST, -3, -1, ModBlocks.corporeaIndex, null).setSpecial(); - pinkinator = new AchievementMod(LibAchievementNames.PINKINATOR, -5, -1, ModItems.pinkinator, null).setSpecial(); - - if(ConfigHandler.relicsEnabled) { - relicInfiniteFruit = new AchievementMod(LibAchievementNames.RELIC_INFINITE_FRUIT, -9, 8, ModItems.infiniteFruit, null); - relicKingKey = new AchievementMod(LibAchievementNames.RELIC_KING_KEY, -7, 11, ModItems.kingKey, null); - relicFlugelEye = new AchievementMod(LibAchievementNames.RELIC_FLUGEL_EYE, -5, 8, ModItems.flugelEye, null); - relicThorRing = new AchievementMod(LibAchievementNames.RELIC_THOR_RING, -7, 7, ModItems.thorRing, null); - relicOdinRing = new AchievementMod(LibAchievementNames.RELIC_ODIN_RING, -9, 10, ModItems.odinRing, null); - relicLokiRing = new AchievementMod(LibAchievementNames.RELIC_LOKI_RING, -5, 10, ModItems.lokiRing, null); - relicAesirRing = new AchievementMod(LibAchievementNames.RELIC_AESIR_RING, -7, 9, ModItems.aesirRing, null).setSpecial(); - } - - nullFlower = new AchievementMod(LibAchievementNames.NULL_FLOWER, -8, 0, ModBlocks.specialFlower, null).setSpecial(); - - ItemStack desu = new ItemStack(ModItems.manaGun); - desu.setStackDisplayName("desu gun"); - desuGun = new AchievementMod(LibAchievementNames.DESU_GUN, -8, 2, desu, null).setSpecial(); - - pageIndex = AchievementPage.getAchievementPages().size(); - botaniaPage = new AchievementPage(LibMisc.MOD_NAME, AchievementMod.achievements.toArray(new Achievement[AchievementMod.achievements.size()])); - AchievementPage.registerAchievementPage(botaniaPage); - - FMLCommonHandler.instance().bus().register(new AchievementTriggerer()); - } - + public static AchievementPage botaniaPage; + public static int pageIndex; + + public static Achievement flowerPickup; + public static Achievement lexiconUse; + public static Achievement daybloomPickup; + public static Achievement cacophoniumCraft; + public static Achievement manaPoolPickup; + + public static Achievement endoflamePickup; + public static Achievement tinyPotatoPet; + public static Achievement sparkCraft; + public static Achievement baubleWear; + public static Achievement manaCookieEat; + public static Achievement manaweaveArmorCraft; + public static Achievement craftingHaloCraft; + public static Achievement manaCartCraft; + public static Achievement enchanterMake; + public static Achievement runePickup; + + public static Achievement dirtRodCraft; + public static Achievement terraformRodCraft; + public static Achievement manaBlasterShoot; + public static Achievement pollidisiacPickup; + public static Achievement brewPickup; + public static Achievement terrasteelPickup; + + public static Achievement terrasteelWeaponCraft; + public static Achievement elfPortalOpen; + + public static Achievement kekimurusPickup; + public static Achievement heiseiDreamPickup; + public static Achievement bubbellPickup; + public static Achievement luminizerRide; + + public static Achievement enderAirMake; + public static Achievement corporeaCraft; + + public static Achievement gaiaGuardianKill; + + public static Achievement spawnerMoverUse; + public static Achievement tiaraWings; + public static Achievement manaBombIgnite; + public static Achievement dandelifeonPickup; + + public static Achievement signalFlareStun; + public static Achievement l20ShardUse; + public static Achievement gaiaGuardianNoArmor; + public static Achievement rankSSPick; + public static Achievement superCorporeaRequest; + public static Achievement pinkinator; + + public static Achievement relicInfiniteFruit; + public static Achievement relicKingKey; + public static Achievement relicFlugelEye; + public static Achievement relicThorRing; + public static Achievement relicOdinRing; + public static Achievement relicLokiRing; + public static Achievement relicAesirRing; + + public static Achievement nullFlower; + public static Achievement desuGun; + + public static void init() { + flowerPickup = new AchievementMod( + LibAchievementNames.FLOWER_PICKUP, 0, 4, new ItemStack(ModBlocks.flower, 1, 6), null); + lexiconUse = new AchievementMod(LibAchievementNames.LEXICON_USE, 1, 5, ModItems.lexicon, flowerPickup); + daybloomPickup = new AchievementMod( + LibAchievementNames.DAYBLOOM_PICKUP, + 3, + 5, + ItemBlockSpecialFlower.ofType(LibBlockNames.SUBTILE_DAYBLOOM), + lexiconUse); + cacophoniumCraft = + new AchievementMod(LibAchievementNames.CACOPHONIUM_CRAFT, -1, 2, ModItems.cacophonium, flowerPickup); + manaPoolPickup = new AchievementMod(LibAchievementNames.MANA_POOL_PICKUP, 3, 2, ModBlocks.pool, daybloomPickup); + + endoflamePickup = new AchievementMod( + LibAchievementNames.ENDOFLAME_PICKUP, + 2, + 0, + ItemBlockSpecialFlower.ofType(LibBlockNames.SUBTILE_ENDOFLAME), + manaPoolPickup); + tinyPotatoPet = + new AchievementMod(LibAchievementNames.TINY_POTATO_PET, 2, -2, ModBlocks.tinyPotato, manaPoolPickup); + sparkCraft = new AchievementMod(LibAchievementNames.SPARK_CRAFT, 4, -2, ModItems.spark, manaPoolPickup); + baubleWear = new AchievementMod(LibAchievementNames.BAUBLE_WEAR, 4, 0, ModItems.manaRing, manaPoolPickup); + manaCookieEat = + new AchievementMod(LibAchievementNames.MANA_COOKIE_EAT, 2, -4, ModItems.manaCookie, manaPoolPickup); + manaweaveArmorCraft = new AchievementMod( + LibAchievementNames.MANAWEAVE_ARMOR_CRAFT, 4, -4, ModItems.manaweaveChest, manaPoolPickup); + craftingHaloCraft = new AchievementMod( + LibAchievementNames.CRAFTING_HALO_CRAFT, 3, -6, ModItems.craftingHalo, manaPoolPickup); + manaCartCraft = + new AchievementMod(LibAchievementNames.MANA_CART_CRAFT, 5, 3, ModItems.poolMinecart, manaPoolPickup); + enchanterMake = + new AchievementMod(LibAchievementNames.ENCHANTER_MAKE, 1, 2, ModBlocks.enchanter, manaPoolPickup); + runePickup = new AchievementMod(LibAchievementNames.RUNE_PICKUP, 6, 2, ModBlocks.runeAltar, manaPoolPickup); + + dirtRodCraft = new AchievementMod(LibAchievementNames.DIRT_ROD_CRAFT, 8, 3, ModItems.dirtRod, runePickup); + terraformRodCraft = + new AchievementMod(LibAchievementNames.TERRAFORM_ROD_CRAFT, 10, 3, ModItems.terraformRod, dirtRodCraft); + manaBlasterShoot = + new AchievementMod(LibAchievementNames.MANA_BLASTER_SHOOT, 8, 1, ModItems.manaGun, runePickup); + pollidisiacPickup = new AchievementMod( + LibAchievementNames.POLLIDISIAC_PICKUP, + 8, + 5, + ItemBlockSpecialFlower.ofType(LibBlockNames.SUBTILE_POLLIDISIAC), + runePickup); + brewPickup = new AchievementMod(LibAchievementNames.BREW_PICKUP, 6, 0, ModBlocks.brewery, runePickup); + terrasteelPickup = new AchievementMod( + LibAchievementNames.TERRASTEEL_PICKUP, + 6, + 9, + new ItemStack(ModItems.manaResource, 1, 4), + runePickup) + .setSpecial(); + + terrasteelWeaponCraft = new AchievementMod( + LibAchievementNames.TERRASTEEL_WEAPON_CRAFT, 8, 10, ModItems.terraSword, terrasteelPickup); + elfPortalOpen = new AchievementMod( + LibAchievementNames.ELF_PORTAL_OPEN, 4, 9, ModBlocks.alfPortal, terrasteelPickup) + .setSpecial(); + + kekimurusPickup = new AchievementMod( + LibAchievementNames.KEKIMURUS_PICKUP, + 3, + 11, + ItemBlockSpecialFlower.ofType(LibBlockNames.SUBTILE_KEKIMURUS), + elfPortalOpen); + heiseiDreamPickup = new AchievementMod( + LibAchievementNames.HEISEI_DREAM_PICKUP, + 5, + 11, + ItemBlockSpecialFlower.ofType(LibBlockNames.SUBTILE_HEISEI_DREAM), + elfPortalOpen); + bubbellPickup = new AchievementMod( + LibAchievementNames.BUBBELL_PICKUP, + 6, + 12, + ItemBlockSpecialFlower.ofType(LibBlockNames.SUBTILE_BUBBELL), + elfPortalOpen); + enderAirMake = new AchievementMod( + LibAchievementNames.ENDER_AIR_MAKE, 4, 14, new ItemStack(ModItems.manaResource, 1, 15), elfPortalOpen); + corporeaCraft = + new AchievementMod(LibAchievementNames.CORPOREA_CRAFT, 2, 14, ModBlocks.corporeaFunnel, enderAirMake); + luminizerRide = + new AchievementMod(LibAchievementNames.LUMINIZER_RIDE, 6, 14, ModBlocks.lightRelay, enderAirMake); + + gaiaGuardianKill = new AchievementMod( + LibAchievementNames.GAIA_GUARDIAN_KILL, + 2, + 9, + new ItemStack(ModItems.manaResource, 1, 5), + elfPortalOpen) + .setSpecial(); + + spawnerMoverUse = new AchievementMod( + LibAchievementNames.SPAWNER_MOVER_USE, -1, 10, ModItems.spawnerMover, gaiaGuardianKill); + tiaraWings = new AchievementMod(LibAchievementNames.TIARA_WINGS, -1, 8, ModItems.flightTiara, gaiaGuardianKill); + manaBombIgnite = + new AchievementMod(LibAchievementNames.MANA_BOMB_IGNITE, 0, 11, ModBlocks.manaBomb, gaiaGuardianKill); + dandelifeonPickup = new AchievementMod( + LibAchievementNames.DANDELIFEON_PICKUP, + 0, + 7, + ItemBlockSpecialFlower.ofType(LibBlockNames.SUBTILE_DANDELIFEON), + gaiaGuardianKill); + + signalFlareStun = new AchievementMod(LibAchievementNames.SIGNAL_FLARE_STUN, -3, 1, ModItems.signalFlare, null) + .setSpecial(); + l20ShardUse = + new AchievementMod(LibAchievementNames.L20_SHARD_USE, -5, 3, ModItems.laputaShard, null).setSpecial(); + gaiaGuardianNoArmor = new AchievementMod( + LibAchievementNames.GAIA_GUARDIAN_NO_ARMOR, -5, 1, new ItemStack(Items.skull, 1, 3), null) + .setSpecial(); + rankSSPick = new AchievementMod(LibAchievementNames.RANK_SS_PICK, -3, 3, ModItems.terraPick, null).setSpecial(); + superCorporeaRequest = new AchievementMod( + LibAchievementNames.SUPER_CORPOREA_REQUEST, -3, -1, ModBlocks.corporeaIndex, null) + .setSpecial(); + pinkinator = new AchievementMod(LibAchievementNames.PINKINATOR, -5, -1, ModItems.pinkinator, null).setSpecial(); + + if (ConfigHandler.relicsEnabled) { + relicInfiniteFruit = + new AchievementMod(LibAchievementNames.RELIC_INFINITE_FRUIT, -9, 8, ModItems.infiniteFruit, null); + relicKingKey = new AchievementMod(LibAchievementNames.RELIC_KING_KEY, -7, 11, ModItems.kingKey, null); + relicFlugelEye = new AchievementMod(LibAchievementNames.RELIC_FLUGEL_EYE, -5, 8, ModItems.flugelEye, null); + relicThorRing = new AchievementMod(LibAchievementNames.RELIC_THOR_RING, -7, 7, ModItems.thorRing, null); + relicOdinRing = new AchievementMod(LibAchievementNames.RELIC_ODIN_RING, -9, 10, ModItems.odinRing, null); + relicLokiRing = new AchievementMod(LibAchievementNames.RELIC_LOKI_RING, -5, 10, ModItems.lokiRing, null); + relicAesirRing = new AchievementMod(LibAchievementNames.RELIC_AESIR_RING, -7, 9, ModItems.aesirRing, null) + .setSpecial(); + } + + nullFlower = + new AchievementMod(LibAchievementNames.NULL_FLOWER, -8, 0, ModBlocks.specialFlower, null).setSpecial(); + + ItemStack desu = new ItemStack(ModItems.manaGun); + desu.setStackDisplayName("desu gun"); + desuGun = new AchievementMod(LibAchievementNames.DESU_GUN, -8, 2, desu, null).setSpecial(); + + pageIndex = AchievementPage.getAchievementPages().size(); + botaniaPage = new AchievementPage( + LibMisc.MOD_NAME, + AchievementMod.achievements.toArray(new Achievement[AchievementMod.achievements.size()])); + AchievementPage.registerAchievementPage(botaniaPage); + + FMLCommonHandler.instance().bus().register(new AchievementTriggerer()); + } } - diff --git a/src/main/java/vazkii/botania/common/block/BlockAlfPortal.java b/src/main/java/vazkii/botania/common/block/BlockAlfPortal.java index 2e8245885e..371266cb9e 100644 --- a/src/main/java/vazkii/botania/common/block/BlockAlfPortal.java +++ b/src/main/java/vazkii/botania/common/block/BlockAlfPortal.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jun 9, 2014, 7:17:46 PM (GMT)] */ package vazkii.botania.common.block; @@ -29,49 +29,47 @@ public class BlockAlfPortal extends BlockModContainer implements IWandable, ILexiconable { - IIcon iconOff, iconOn; - public static IIcon portalTex; + IIcon iconOff, iconOn; + public static IIcon portalTex; - public BlockAlfPortal() { - super(Material.wood); - setHardness(10F); - setStepSound(soundTypeWood); - setBlockName(LibBlockNames.ALF_PORTAL); - } + public BlockAlfPortal() { + super(Material.wood); + setHardness(10F); + setStepSound(soundTypeWood); + setBlockName(LibBlockNames.ALF_PORTAL); + } - @Override - public void registerBlockIcons(IIconRegister par1IconRegister) { - iconOff = IconHelper.forBlock(par1IconRegister, this, 0); - iconOn = IconHelper.forBlock(par1IconRegister, this, 1); - portalTex = IconHelper.forBlock(par1IconRegister, this, "Inside"); - } + @Override + public void registerBlockIcons(IIconRegister par1IconRegister) { + iconOff = IconHelper.forBlock(par1IconRegister, this, 0); + iconOn = IconHelper.forBlock(par1IconRegister, this, 1); + portalTex = IconHelper.forBlock(par1IconRegister, this, "Inside"); + } - @Override - public IIcon getIcon(int side, int meta) { - return meta == 0 ? iconOff : iconOn; - } + @Override + public IIcon getIcon(int side, int meta) { + return meta == 0 ? iconOff : iconOn; + } - @Override - public TileEntity createNewTileEntity(World world, int meta) { - return new TileAlfPortal(); - } + @Override + public TileEntity createNewTileEntity(World world, int meta) { + return new TileAlfPortal(); + } - @Override - public LexiconEntry getEntry(World world, int x, int y, int z, EntityPlayer player, ItemStack lexicon) { - return LexiconData.alfhomancyIntro; - } + @Override + public LexiconEntry getEntry(World world, int x, int y, int z, EntityPlayer player, ItemStack lexicon) { + return LexiconData.alfhomancyIntro; + } - @Override - public boolean onUsedByWand(EntityPlayer player, ItemStack stack, World world, int x, int y, int z, int side) { - boolean did = ((TileAlfPortal) world.getTileEntity(x, y, z)).onWanded(); - if(did && player != null) - player.addStat(ModAchievements.elfPortalOpen, 1); - return did; - } - - @Override - public int getLightValue(IBlockAccess world, int x, int y, int z) { - return world.getBlockMetadata(x, y, z) == 0 ? 0 : 15; - } + @Override + public boolean onUsedByWand(EntityPlayer player, ItemStack stack, World world, int x, int y, int z, int side) { + boolean did = ((TileAlfPortal) world.getTileEntity(x, y, z)).onWanded(); + if (did && player != null) player.addStat(ModAchievements.elfPortalOpen, 1); + return did; + } + @Override + public int getLightValue(IBlockAccess world, int x, int y, int z) { + return world.getBlockMetadata(x, y, z) == 0 ? 0 : 15; + } } diff --git a/src/main/java/vazkii/botania/common/block/BlockAltGrass.java b/src/main/java/vazkii/botania/common/block/BlockAltGrass.java index 1f7a5c3daf..63119409a9 100644 --- a/src/main/java/vazkii/botania/common/block/BlockAltGrass.java +++ b/src/main/java/vazkii/botania/common/block/BlockAltGrass.java @@ -2,17 +2,17 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [17/11/2015, 18:33:30 (GMT)] */ package vazkii.botania.common.block; +import cpw.mods.fml.common.registry.GameRegistry; import java.util.List; import java.util.Random; - import net.minecraft.block.Block; import net.minecraft.block.material.Material; import net.minecraft.client.renderer.texture.IIconRegister; @@ -35,118 +35,149 @@ import vazkii.botania.common.item.block.ItemBlockWithMetadataAndName; import vazkii.botania.common.lexicon.LexiconData; import vazkii.botania.common.lib.LibBlockNames; -import cpw.mods.fml.common.registry.GameRegistry; public class BlockAltGrass extends BlockMod implements ILexiconable { - private static final int SUBTYPES = 6; - IIcon[] icons; - - public BlockAltGrass() { - super(Material.grass); - setHardness(0.6F); - setStepSound(soundTypeGrass); - setBlockName(LibBlockNames.ALT_GRASS); - setTickRandomly(true); - } - - @Override - public boolean isToolEffective(String type, int metadata) { - return type.equals("shovel"); - } - - @Override - public Block setBlockName(String par1Str) { - GameRegistry.registerBlock(this, ItemBlockWithMetadataAndName.class, par1Str); - return super.setBlockName(par1Str); - } - - @Override - protected boolean shouldRegisterInNameSet() { - return false; - } - - @Override - public void getSubBlocks(Item item, CreativeTabs tab, List list) { - for(int i = 0; i < 6; i++) - list.add(new ItemStack(item, 1, i)); - } - - @Override - public void registerBlockIcons(IIconRegister par1IconRegister) { - icons = new IIcon[SUBTYPES * 2]; - for(int i = 0; i < icons.length; i++) - icons[i] = IconHelper.forBlock(par1IconRegister, this, i); - } - - @Override - public IIcon getIcon(int side, int meta) { - return side == 0 || meta >= SUBTYPES ? Blocks.dirt.getIcon(side, meta) : side == 1 ? icons[meta * 2] : icons[meta * 2 + 1]; - } - - @Override - public void updateTick(World world, int x, int y, int z, Random rand) { - if(!world.isRemote && world.getBlockLightValue(x, y + 1, z) >= 9) { - int meta = world.getBlockMetadata(x, y, z); - for(int l = 0; l < 4; ++l) { - int i1 = x + rand.nextInt(3) - 1; - int j1 = y + rand.nextInt(5) - 3; - int k1 = z + rand.nextInt(3) - 1; - - world.getBlock(i1, j1 + 1, k1); - - if(world.getBlock(i1, j1, k1) == Blocks.dirt && world.getBlockMetadata(i1, j1, k1) == 0 && world.getBlockLightValue(i1, j1 + 1, k1) >= 4 && world.getBlockLightOpacity(i1, j1 + 1, k1) <= 2) - world.setBlock(i1, j1, k1, this, meta, 1 | 2); - } - } - } - - @Override - public Item getItemDropped(int p_149650_1_, Random p_149650_2_, int p_149650_3_) { - return Blocks.dirt.getItemDropped(0, p_149650_2_, p_149650_3_); - } - - @Override - public ItemStack getPickBlock(MovingObjectPosition target, World world, int x, int y, int z) { - return new ItemStack(this, 1, world.getBlockMetadata(x, y, z)); - } - - @Override - public boolean canSustainPlant(IBlockAccess world, int x, int y, int z, ForgeDirection direction, IPlantable plantable) { - EnumPlantType type = plantable.getPlantType(world, x, y - 1, z); - return type == EnumPlantType.Plains || type == EnumPlantType.Beach; - } - - @Override - public void randomDisplayTick(World world, int x, int y, int z, Random r) { - int meta = world.getBlockMetadata(x, y, z); - switch(meta) { - case 0: // Dry - break; - case 1: // Golden - break; - case 2: // Vivid - break; - case 3: // Scorched - if(r.nextInt(80) == 0) - world.spawnParticle("flame", x + r.nextFloat(), y + 1.1, z + r.nextFloat(), 0, 0, 0); - break; - case 4: // Infused - if(r.nextInt(100) == 0) - Botania.proxy.sparkleFX(world, x + r.nextFloat(), y + 1.05, z + r.nextFloat(), 0F, 1F, 1F, r.nextFloat() * 0.2F + 1F, 5); - break; - case 5: // Mutated - if(r.nextInt(100) == 0) { - if(r.nextInt(100) > 25) - Botania.proxy.sparkleFX(world, x + r.nextFloat(), y + 1.05, z + r.nextFloat(), 1F, 0F, 1F, r.nextFloat() * 0.2F + 1F, 5); - else Botania.proxy.sparkleFX(world, x + r.nextFloat(), y + 1.05, z + r.nextFloat(), 1F, 1F, 0F, r.nextFloat() * 0.2F + 1F, 5); - } - break; - } - } - - @Override - public LexiconEntry getEntry(World world, int x, int y, int z, EntityPlayer player, ItemStack lexicon) { - return LexiconData.grassSeeds; - } + private static final int SUBTYPES = 6; + IIcon[] icons; + + public BlockAltGrass() { + super(Material.grass); + setHardness(0.6F); + setStepSound(soundTypeGrass); + setBlockName(LibBlockNames.ALT_GRASS); + setTickRandomly(true); + } + + @Override + public boolean isToolEffective(String type, int metadata) { + return type.equals("shovel"); + } + + @Override + public Block setBlockName(String par1Str) { + GameRegistry.registerBlock(this, ItemBlockWithMetadataAndName.class, par1Str); + return super.setBlockName(par1Str); + } + + @Override + protected boolean shouldRegisterInNameSet() { + return false; + } + + @Override + public void getSubBlocks(Item item, CreativeTabs tab, List list) { + for (int i = 0; i < 6; i++) list.add(new ItemStack(item, 1, i)); + } + + @Override + public void registerBlockIcons(IIconRegister par1IconRegister) { + icons = new IIcon[SUBTYPES * 2]; + for (int i = 0; i < icons.length; i++) icons[i] = IconHelper.forBlock(par1IconRegister, this, i); + } + + @Override + public IIcon getIcon(int side, int meta) { + return side == 0 || meta >= SUBTYPES + ? Blocks.dirt.getIcon(side, meta) + : side == 1 ? icons[meta * 2] : icons[meta * 2 + 1]; + } + + @Override + public void updateTick(World world, int x, int y, int z, Random rand) { + if (!world.isRemote && world.getBlockLightValue(x, y + 1, z) >= 9) { + int meta = world.getBlockMetadata(x, y, z); + for (int l = 0; l < 4; ++l) { + int i1 = x + rand.nextInt(3) - 1; + int j1 = y + rand.nextInt(5) - 3; + int k1 = z + rand.nextInt(3) - 1; + + world.getBlock(i1, j1 + 1, k1); + + if (world.getBlock(i1, j1, k1) == Blocks.dirt + && world.getBlockMetadata(i1, j1, k1) == 0 + && world.getBlockLightValue(i1, j1 + 1, k1) >= 4 + && world.getBlockLightOpacity(i1, j1 + 1, k1) <= 2) + world.setBlock(i1, j1, k1, this, meta, 1 | 2); + } + } + } + + @Override + public Item getItemDropped(int p_149650_1_, Random p_149650_2_, int p_149650_3_) { + return Blocks.dirt.getItemDropped(0, p_149650_2_, p_149650_3_); + } + + @Override + public ItemStack getPickBlock(MovingObjectPosition target, World world, int x, int y, int z) { + return new ItemStack(this, 1, world.getBlockMetadata(x, y, z)); + } + + @Override + public boolean canSustainPlant( + IBlockAccess world, int x, int y, int z, ForgeDirection direction, IPlantable plantable) { + EnumPlantType type = plantable.getPlantType(world, x, y - 1, z); + return type == EnumPlantType.Plains || type == EnumPlantType.Beach; + } + + @Override + public void randomDisplayTick(World world, int x, int y, int z, Random r) { + int meta = world.getBlockMetadata(x, y, z); + switch (meta) { + case 0: // Dry + break; + case 1: // Golden + break; + case 2: // Vivid + break; + case 3: // Scorched + if (r.nextInt(80) == 0) + world.spawnParticle("flame", x + r.nextFloat(), y + 1.1, z + r.nextFloat(), 0, 0, 0); + break; + case 4: // Infused + if (r.nextInt(100) == 0) + Botania.proxy.sparkleFX( + world, + x + r.nextFloat(), + y + 1.05, + z + r.nextFloat(), + 0F, + 1F, + 1F, + r.nextFloat() * 0.2F + 1F, + 5); + break; + case 5: // Mutated + if (r.nextInt(100) == 0) { + if (r.nextInt(100) > 25) + Botania.proxy.sparkleFX( + world, + x + r.nextFloat(), + y + 1.05, + z + r.nextFloat(), + 1F, + 0F, + 1F, + r.nextFloat() * 0.2F + 1F, + 5); + else + Botania.proxy.sparkleFX( + world, + x + r.nextFloat(), + y + 1.05, + z + r.nextFloat(), + 1F, + 1F, + 0F, + r.nextFloat() * 0.2F + 1F, + 5); + } + break; + } + } + + @Override + public LexiconEntry getEntry(World world, int x, int y, int z, EntityPlayer player, ItemStack lexicon) { + return LexiconData.grassSeeds; + } } diff --git a/src/main/java/vazkii/botania/common/block/BlockAltar.java b/src/main/java/vazkii/botania/common/block/BlockAltar.java index 01abb60f47..5eed53f4a4 100644 --- a/src/main/java/vazkii/botania/common/block/BlockAltar.java +++ b/src/main/java/vazkii/botania/common/block/BlockAltar.java @@ -2,17 +2,17 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jan 21, 2014, 7:48:54 PM (GMT)] */ package vazkii.botania.common.block; +import cpw.mods.fml.common.registry.GameRegistry; import java.util.List; import java.util.Random; - import net.minecraft.block.Block; import net.minecraft.block.material.Material; import net.minecraft.client.renderer.texture.IIconRegister; @@ -46,246 +46,265 @@ import vazkii.botania.common.item.rod.ItemWaterRod; import vazkii.botania.common.lexicon.LexiconData; import vazkii.botania.common.lib.LibBlockNames; -import cpw.mods.fml.common.registry.GameRegistry; public class BlockAltar extends BlockModContainer implements ILexiconable { - Random random; - - protected BlockAltar() { - super(Material.rock); - setHardness(3.5F); - setStepSound(soundTypeStone); - setBlockName(LibBlockNames.ALTAR); - - float f = 1F / 16F * 2F; - setBlockBounds(f, f, f, 1F - f, 1F / 16F * 20F, 1F - f); - - random = new Random(); - } - - @Override - public void registerBlockIcons(IIconRegister par1IconRegister) { - // NO-OP - } - - @Override - protected boolean shouldRegisterInNameSet() { - return false; - } - - @Override - public Block setBlockName(String par1Str) { - GameRegistry.registerBlock(this, ItemBlockWithMetadataAndName.class, par1Str); - return super.setBlockName(par1Str); - } - - @Override - public void getSubBlocks(Item item, CreativeTabs tab, List list) { - for(int i = 0; i < 9; i++) - list.add(new ItemStack(item, 1, i)); - } - - @Override - public void onEntityCollidedWithBlock(World par1World, int par2, int par3, int par4, Entity par5Entity) { - if(par5Entity instanceof EntityItem) { - TileAltar tile = (TileAltar) par1World.getTileEntity(par2, par3, par4); - if(tile.collideEntityItem((EntityItem) par5Entity)) - VanillaPacketDispatcher.dispatchTEToNearbyPlayers(tile); - } - } - - @Override - public int getLightValue(IBlockAccess world, int x, int y, int z) { - TileAltar tile = (TileAltar) world.getTileEntity(x, y, z); - return tile.hasLava ? 15 : 0; - } - - @Override - public boolean onBlockActivated(World par1World, int par2, int par3, int par4, EntityPlayer par5EntityPlayer, int par6, float par7, float par8, float par9) { - ItemStack stack = par5EntityPlayer.getCurrentEquippedItem(); - TileAltar tile = (TileAltar) par1World.getTileEntity(par2, par3, par4); - - if(par5EntityPlayer.isSneaking()) { - for(int i = tile.getSizeInventory() - 1; i >= 0; i--) { - ItemStack stackAt = tile.getStackInSlot(i); - if(stackAt != null) { - ItemStack copy = stackAt.copy(); - if(!par5EntityPlayer.inventory.addItemStackToInventory(copy)) - par5EntityPlayer.dropPlayerItemWithRandomChoice(copy, false); - tile.setInventorySlotContents(i, null); - par1World.func_147453_f(par2, par3, par4, this); - break; - } - } - } else if(tile.isEmpty() && tile.hasWater && stack == null) - tile.trySetLastRecipe(par5EntityPlayer); - else { - if(stack != null && (isValidWaterContainer(stack) || stack.getItem() == ModItems.waterRod && ManaItemHandler.requestManaExact(stack, par5EntityPlayer, ItemWaterRod.COST, false))) { - if(!tile.hasWater) { - if(stack.getItem() == ModItems.waterRod) - ManaItemHandler.requestManaExact(stack, par5EntityPlayer, ItemWaterRod.COST, true); - else if(!par5EntityPlayer.capabilities.isCreativeMode) - par5EntityPlayer.inventory.setInventorySlotContents(par5EntityPlayer.inventory.currentItem, getContainer(stack)); - - tile.setWater(true); - par1World.func_147453_f(par2, par3, par4, this); - } - - return true; - } else if(stack != null && stack.getItem() == Items.lava_bucket) { - if(!par5EntityPlayer.capabilities.isCreativeMode) - par5EntityPlayer.inventory.setInventorySlotContents(par5EntityPlayer.inventory.currentItem, getContainer(stack)); - - tile.setLava(true); - tile.setWater(false); - par1World.func_147453_f(par2, par3, par4, this); - - return true; - } else if(stack != null && stack.getItem() == Items.bucket && (tile.hasWater || tile.hasLava) && !Botania.gardenOfGlassLoaded) { - ItemStack bucket = tile.hasLava ? new ItemStack(Items.lava_bucket) : new ItemStack(Items.water_bucket); - if(stack.stackSize == 1) - par5EntityPlayer.inventory.setInventorySlotContents(par5EntityPlayer.inventory.currentItem, bucket); - else { - if(!par5EntityPlayer.inventory.addItemStackToInventory(bucket)) - par5EntityPlayer.dropPlayerItemWithRandomChoice(bucket, false); - stack.stackSize--; - } - - if(tile.hasLava) - tile.setLava(false); - else tile.setWater(false); - par1World.func_147453_f(par2, par3, par4, this); - - return true; - } - } - - return false; - } - - @Override - public void fillWithRain(World world, int x, int y, int z) { - if(world.rand.nextInt(20) == 1) { - TileEntity tile = world.getTileEntity(x, y, z); - if(tile instanceof TileAltar) { - TileAltar altar = (TileAltar) tile; - if(!altar.hasLava && !altar.hasWater) - altar.setWater(true); - world.func_147453_f(x, y, z, this); - } - } - } - - @Override - public int damageDropped(int meta) { - return meta; - } - - private boolean isValidWaterContainer(ItemStack stack) { - if(stack == null || stack.stackSize != 1) - return false; - if(stack.getItem() == ModItems.waterBowl) - return true; - - if(stack.getItem() instanceof IFluidContainerItem) { - FluidStack fluidStack = ((IFluidContainerItem) stack.getItem()).getFluid(stack); - return fluidStack != null && fluidStack.getFluid() == FluidRegistry.WATER && fluidStack.amount >= FluidContainerRegistry.BUCKET_VOLUME; - } - FluidStack fluidStack = FluidContainerRegistry.getFluidForFilledItem(stack); - return fluidStack != null && fluidStack.getFluid() == FluidRegistry.WATER && fluidStack.amount >= FluidContainerRegistry.BUCKET_VOLUME; - } - - private ItemStack getContainer(ItemStack stack) { - if(stack.getItem() == ModItems.waterBowl) - return new ItemStack(Items.bowl); - - if (stack.getItem().hasContainerItem(stack)) - return stack.getItem().getContainerItem(stack); - else if (stack.getItem() instanceof IFluidContainerItem) { - ((IFluidContainerItem) stack.getItem()).drain(stack, FluidContainerRegistry.BUCKET_VOLUME, true); - return stack; - } - return FluidContainerRegistry.drainFluidContainer(stack); - } - - @Override - public IIcon getIcon(int par1, int par2) { - return par2 == 0 ? Blocks.cobblestone.getIcon(par1, par2) : ModFluffBlocks.biomeStoneA.getIcon(par1, par2 + 7); - } - - @Override - public boolean isOpaqueCube() { - return false; - } - - @Override - public boolean renderAsNormalBlock() { - return false; - } - - @Override - public int getRenderType() { - return LibRenderIDs.idAltar; - } - - @Override - public TileEntity createNewTileEntity(World world, int meta) { - return new TileAltar(); - } - - @Override - public void breakBlock(World par1World, int par2, int par3, int par4, Block par5, int par6) { - TileSimpleInventory inv = (TileSimpleInventory) par1World.getTileEntity(par2, par3, par4); - - if (inv != null) { - for (int j1 = 0; j1 < inv.getSizeInventory(); ++j1) { - ItemStack itemstack = inv.getStackInSlot(j1); - - if (itemstack != null) { - float f = random.nextFloat() * 0.8F + 0.1F; - float f1 = random.nextFloat() * 0.8F + 0.1F; - EntityItem entityitem; - - for (float f2 = random.nextFloat() * 0.8F + 0.1F; itemstack.stackSize > 0; par1World.spawnEntityInWorld(entityitem)) { - int k1 = random.nextInt(21) + 10; - - if (k1 > itemstack.stackSize) - k1 = itemstack.stackSize; - - itemstack.stackSize -= k1; - entityitem = new EntityItem(par1World, par2 + f, par3 + f1, par4 + f2, new ItemStack(itemstack.getItem(), k1, itemstack.getItemDamage())); - float f3 = 0.05F; - entityitem.motionX = (float)random.nextGaussian() * f3; - entityitem.motionY = (float)random.nextGaussian() * f3 + 0.2F; - entityitem.motionZ = (float)random.nextGaussian() * f3; - - if (itemstack.hasTagCompound()) - entityitem.getEntityItem().setTagCompound((NBTTagCompound)itemstack.getTagCompound().copy()); - } - } - } - - par1World.func_147453_f(par2, par3, par4, par5); - } - - super.breakBlock(par1World, par2, par3, par4, par5, par6); - } - - @Override - public boolean hasComparatorInputOverride() { - return true; - } - - @Override - public int getComparatorInputOverride(World par1World, int par2, int par3, int par4, int par5) { - TileAltar altar = (TileAltar) par1World.getTileEntity(par2, par3, par4); - return altar.hasWater ? 15 : 0; - } - - @Override - public LexiconEntry getEntry(World world, int x, int y, int z, EntityPlayer player, ItemStack lexicon) { - return LexiconData.apothecary; - } - + Random random; + + protected BlockAltar() { + super(Material.rock); + setHardness(3.5F); + setStepSound(soundTypeStone); + setBlockName(LibBlockNames.ALTAR); + + float f = 1F / 16F * 2F; + setBlockBounds(f, f, f, 1F - f, 1F / 16F * 20F, 1F - f); + + random = new Random(); + } + + @Override + public void registerBlockIcons(IIconRegister par1IconRegister) { + // NO-OP + } + + @Override + protected boolean shouldRegisterInNameSet() { + return false; + } + + @Override + public Block setBlockName(String par1Str) { + GameRegistry.registerBlock(this, ItemBlockWithMetadataAndName.class, par1Str); + return super.setBlockName(par1Str); + } + + @Override + public void getSubBlocks(Item item, CreativeTabs tab, List list) { + for (int i = 0; i < 9; i++) list.add(new ItemStack(item, 1, i)); + } + + @Override + public void onEntityCollidedWithBlock(World par1World, int par2, int par3, int par4, Entity par5Entity) { + if (par5Entity instanceof EntityItem) { + TileAltar tile = (TileAltar) par1World.getTileEntity(par2, par3, par4); + if (tile.collideEntityItem((EntityItem) par5Entity)) + VanillaPacketDispatcher.dispatchTEToNearbyPlayers(tile); + } + } + + @Override + public int getLightValue(IBlockAccess world, int x, int y, int z) { + TileAltar tile = (TileAltar) world.getTileEntity(x, y, z); + return tile.hasLava ? 15 : 0; + } + + @Override + public boolean onBlockActivated( + World par1World, + int par2, + int par3, + int par4, + EntityPlayer par5EntityPlayer, + int par6, + float par7, + float par8, + float par9) { + ItemStack stack = par5EntityPlayer.getCurrentEquippedItem(); + TileAltar tile = (TileAltar) par1World.getTileEntity(par2, par3, par4); + + if (par5EntityPlayer.isSneaking()) { + for (int i = tile.getSizeInventory() - 1; i >= 0; i--) { + ItemStack stackAt = tile.getStackInSlot(i); + if (stackAt != null) { + ItemStack copy = stackAt.copy(); + if (!par5EntityPlayer.inventory.addItemStackToInventory(copy)) + par5EntityPlayer.dropPlayerItemWithRandomChoice(copy, false); + tile.setInventorySlotContents(i, null); + par1World.func_147453_f(par2, par3, par4, this); + break; + } + } + } else if (tile.isEmpty() && tile.hasWater && stack == null) tile.trySetLastRecipe(par5EntityPlayer); + else { + if (stack != null + && (isValidWaterContainer(stack) + || stack.getItem() == ModItems.waterRod + && ManaItemHandler.requestManaExact( + stack, par5EntityPlayer, ItemWaterRod.COST, false))) { + if (!tile.hasWater) { + if (stack.getItem() == ModItems.waterRod) + ManaItemHandler.requestManaExact(stack, par5EntityPlayer, ItemWaterRod.COST, true); + else if (!par5EntityPlayer.capabilities.isCreativeMode) + par5EntityPlayer.inventory.setInventorySlotContents( + par5EntityPlayer.inventory.currentItem, getContainer(stack)); + + tile.setWater(true); + par1World.func_147453_f(par2, par3, par4, this); + } + + return true; + } else if (stack != null && stack.getItem() == Items.lava_bucket) { + if (!par5EntityPlayer.capabilities.isCreativeMode) + par5EntityPlayer.inventory.setInventorySlotContents( + par5EntityPlayer.inventory.currentItem, getContainer(stack)); + + tile.setLava(true); + tile.setWater(false); + par1World.func_147453_f(par2, par3, par4, this); + + return true; + } else if (stack != null + && stack.getItem() == Items.bucket + && (tile.hasWater || tile.hasLava) + && !Botania.gardenOfGlassLoaded) { + ItemStack bucket = tile.hasLava ? new ItemStack(Items.lava_bucket) : new ItemStack(Items.water_bucket); + if (stack.stackSize == 1) + par5EntityPlayer.inventory.setInventorySlotContents(par5EntityPlayer.inventory.currentItem, bucket); + else { + if (!par5EntityPlayer.inventory.addItemStackToInventory(bucket)) + par5EntityPlayer.dropPlayerItemWithRandomChoice(bucket, false); + stack.stackSize--; + } + + if (tile.hasLava) tile.setLava(false); + else tile.setWater(false); + par1World.func_147453_f(par2, par3, par4, this); + + return true; + } + } + + return false; + } + + @Override + public void fillWithRain(World world, int x, int y, int z) { + if (world.rand.nextInt(20) == 1) { + TileEntity tile = world.getTileEntity(x, y, z); + if (tile instanceof TileAltar) { + TileAltar altar = (TileAltar) tile; + if (!altar.hasLava && !altar.hasWater) altar.setWater(true); + world.func_147453_f(x, y, z, this); + } + } + } + + @Override + public int damageDropped(int meta) { + return meta; + } + + private boolean isValidWaterContainer(ItemStack stack) { + if (stack == null || stack.stackSize != 1) return false; + if (stack.getItem() == ModItems.waterBowl) return true; + + if (stack.getItem() instanceof IFluidContainerItem) { + FluidStack fluidStack = ((IFluidContainerItem) stack.getItem()).getFluid(stack); + return fluidStack != null + && fluidStack.getFluid() == FluidRegistry.WATER + && fluidStack.amount >= FluidContainerRegistry.BUCKET_VOLUME; + } + FluidStack fluidStack = FluidContainerRegistry.getFluidForFilledItem(stack); + return fluidStack != null + && fluidStack.getFluid() == FluidRegistry.WATER + && fluidStack.amount >= FluidContainerRegistry.BUCKET_VOLUME; + } + + private ItemStack getContainer(ItemStack stack) { + if (stack.getItem() == ModItems.waterBowl) return new ItemStack(Items.bowl); + + if (stack.getItem().hasContainerItem(stack)) return stack.getItem().getContainerItem(stack); + else if (stack.getItem() instanceof IFluidContainerItem) { + ((IFluidContainerItem) stack.getItem()).drain(stack, FluidContainerRegistry.BUCKET_VOLUME, true); + return stack; + } + return FluidContainerRegistry.drainFluidContainer(stack); + } + + @Override + public IIcon getIcon(int par1, int par2) { + return par2 == 0 ? Blocks.cobblestone.getIcon(par1, par2) : ModFluffBlocks.biomeStoneA.getIcon(par1, par2 + 7); + } + + @Override + public boolean isOpaqueCube() { + return false; + } + + @Override + public boolean renderAsNormalBlock() { + return false; + } + + @Override + public int getRenderType() { + return LibRenderIDs.idAltar; + } + + @Override + public TileEntity createNewTileEntity(World world, int meta) { + return new TileAltar(); + } + + @Override + public void breakBlock(World par1World, int par2, int par3, int par4, Block par5, int par6) { + TileSimpleInventory inv = (TileSimpleInventory) par1World.getTileEntity(par2, par3, par4); + + if (inv != null) { + for (int j1 = 0; j1 < inv.getSizeInventory(); ++j1) { + ItemStack itemstack = inv.getStackInSlot(j1); + + if (itemstack != null) { + float f = random.nextFloat() * 0.8F + 0.1F; + float f1 = random.nextFloat() * 0.8F + 0.1F; + EntityItem entityitem; + + for (float f2 = random.nextFloat() * 0.8F + 0.1F; + itemstack.stackSize > 0; + par1World.spawnEntityInWorld(entityitem)) { + int k1 = random.nextInt(21) + 10; + + if (k1 > itemstack.stackSize) k1 = itemstack.stackSize; + + itemstack.stackSize -= k1; + entityitem = new EntityItem( + par1World, + par2 + f, + par3 + f1, + par4 + f2, + new ItemStack(itemstack.getItem(), k1, itemstack.getItemDamage())); + float f3 = 0.05F; + entityitem.motionX = (float) random.nextGaussian() * f3; + entityitem.motionY = (float) random.nextGaussian() * f3 + 0.2F; + entityitem.motionZ = (float) random.nextGaussian() * f3; + + if (itemstack.hasTagCompound()) + entityitem.getEntityItem().setTagCompound((NBTTagCompound) + itemstack.getTagCompound().copy()); + } + } + } + + par1World.func_147453_f(par2, par3, par4, par5); + } + + super.breakBlock(par1World, par2, par3, par4, par5, par6); + } + + @Override + public boolean hasComparatorInputOverride() { + return true; + } + + @Override + public int getComparatorInputOverride(World par1World, int par2, int par3, int par4, int par5) { + TileAltar altar = (TileAltar) par1World.getTileEntity(par2, par3, par4); + return altar.hasWater ? 15 : 0; + } + + @Override + public LexiconEntry getEntry(World world, int x, int y, int z, EntityPlayer player, ItemStack lexicon) { + return LexiconData.apothecary; + } } diff --git a/src/main/java/vazkii/botania/common/block/BlockAvatar.java b/src/main/java/vazkii/botania/common/block/BlockAvatar.java index f6eed47566..30576683ba 100644 --- a/src/main/java/vazkii/botania/common/block/BlockAvatar.java +++ b/src/main/java/vazkii/botania/common/block/BlockAvatar.java @@ -2,16 +2,15 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Oct 24, 2015, 3:15:11 PM (GMT)] */ package vazkii.botania.common.block; import java.util.Random; - import net.minecraft.block.Block; import net.minecraft.block.material.Material; import net.minecraft.client.renderer.texture.IIconRegister; @@ -39,140 +38,152 @@ public class BlockAvatar extends BlockModContainer implements ILexiconable { - private static final int[] META_ROTATIONS = new int[] { 2, 5, 3, 4 }; - - Random random; - - protected BlockAvatar() { - super(Material.wood); - setHardness(2.0F); - setStepSound(soundTypeWood); - setBlockName(LibBlockNames.AVATAR); - setBlockBounds(true); - - random = new Random(); - } - - @Override - public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int s, float xs, float ys, float zs) { - TileAvatar avatar = (TileAvatar) world.getTileEntity(x, y, z); - ItemStack stackOnAvatar = avatar.getStackInSlot(0); - ItemStack stackOnPlayer = player.getCurrentEquippedItem(); - if(stackOnAvatar != null) { - ItemStack copyStack = stackOnAvatar.copy(); - avatar.setInventorySlotContents(0, null); - if(!player.inventory.addItemStackToInventory(copyStack)) - player.dropPlayerItemWithRandomChoice(copyStack, true); - return true; - } else if(stackOnPlayer != null && stackOnPlayer.getItem() instanceof IAvatarWieldable) { - ItemStack copyStack = stackOnPlayer.copy(); - avatar.setInventorySlotContents(0, copyStack); - stackOnPlayer.stackSize--; - return true; - } - - return false; - } - - @Override - public void setBlockBoundsBasedOnState(IBlockAccess w, int x, int y, int z) { - setBlockBounds(w.getBlockMetadata(x, y, z) < 4); - } - - public void setBlockBounds(boolean horiz) { - float f = 1F / 16F; - float w = f * 9; - float l = f * 6; - float ws = (1F - w) / 2; - float ls = (1F - l) / 2; - - if(horiz) - setBlockBounds(ws, 0F, ls, 1F - ws, 1F + f, 1F - ls); - else setBlockBounds(ls, 0F, ws, 1F - ls, 1F + f, 1F - ws); - } - - @Override - public void breakBlock(World par1World, int par2, int par3, int par4, Block par5, int par6) { - TileSimpleInventory inv = (TileSimpleInventory) par1World.getTileEntity(par2, par3, par4); - - if (inv != null) { - for (int j1 = 0; j1 < inv.getSizeInventory(); ++j1) { - ItemStack itemstack = inv.getStackInSlot(j1); - - if (itemstack != null) { - float f = random.nextFloat() * 0.8F + 0.1F; - float f1 = random.nextFloat() * 0.8F + 0.1F; - EntityItem entityitem; - - for (float f2 = random.nextFloat() * 0.8F + 0.1F; itemstack.stackSize > 0; par1World.spawnEntityInWorld(entityitem)) { - int k1 = random.nextInt(21) + 10; - - if (k1 > itemstack.stackSize) - k1 = itemstack.stackSize; - - itemstack.stackSize -= k1; - entityitem = new EntityItem(par1World, par2 + f, par3 + f1, par4 + f2, new ItemStack(itemstack.getItem(), k1, itemstack.getItemDamage())); - float f3 = 0.05F; - entityitem.motionX = (float)random.nextGaussian() * f3; - entityitem.motionY = (float)random.nextGaussian() * f3 + 0.2F; - entityitem.motionZ = (float)random.nextGaussian() * f3; - - if (itemstack.hasTagCompound()) - entityitem.getEntityItem().setTagCompound((NBTTagCompound)itemstack.getTagCompound().copy()); - } - } - } - - par1World.func_147453_f(par2, par3, par4, par5); - } - - super.breakBlock(par1World, par2, par3, par4, par5, par6); - } - - @Override - public void onBlockPlacedBy(World p_149689_1_, int p_149689_2_, int p_149689_3_, int p_149689_4_, EntityLivingBase p_149689_5_, ItemStack p_149689_6_) { - int l = MathHelper.floor_double(p_149689_5_.rotationYaw * 4.0F / 360.0F + 0.5D) & 3; - p_149689_1_.setBlockMetadataWithNotify(p_149689_2_, p_149689_3_, p_149689_4_, META_ROTATIONS[l], 2); - } - - @Override - public boolean rotateBlock(World worldObj, int x, int y, int z, ForgeDirection axis) { - return RotationHelper.rotateVanillaBlock(Blocks.furnace, worldObj, x, y, z, axis); - } - - @Override - public void registerBlockIcons(IIconRegister par1IconRegister) { - // NO-OP - } - - @Override - public IIcon getIcon(int side, int meta) { - return ModBlocks.livingwood.getIcon(0, 0); - } - - @Override - public boolean isOpaqueCube() { - return false; - } - - @Override - public boolean renderAsNormalBlock() { - return false; - } - - @Override - public int getRenderType() { - return LibRenderIDs.idAvatar; - } - - @Override - public TileEntity createNewTileEntity(World world, int meta) { - return new TileAvatar(); - } - - @Override - public LexiconEntry getEntry(World world, int x, int y, int z, EntityPlayer player, ItemStack lexicon) { - return LexiconData.avatar; - } - + private static final int[] META_ROTATIONS = new int[] {2, 5, 3, 4}; + + Random random; + + protected BlockAvatar() { + super(Material.wood); + setHardness(2.0F); + setStepSound(soundTypeWood); + setBlockName(LibBlockNames.AVATAR); + setBlockBounds(true); + + random = new Random(); + } + + @Override + public boolean onBlockActivated( + World world, int x, int y, int z, EntityPlayer player, int s, float xs, float ys, float zs) { + TileAvatar avatar = (TileAvatar) world.getTileEntity(x, y, z); + ItemStack stackOnAvatar = avatar.getStackInSlot(0); + ItemStack stackOnPlayer = player.getCurrentEquippedItem(); + if (stackOnAvatar != null) { + ItemStack copyStack = stackOnAvatar.copy(); + avatar.setInventorySlotContents(0, null); + if (!player.inventory.addItemStackToInventory(copyStack)) + player.dropPlayerItemWithRandomChoice(copyStack, true); + return true; + } else if (stackOnPlayer != null && stackOnPlayer.getItem() instanceof IAvatarWieldable) { + ItemStack copyStack = stackOnPlayer.copy(); + avatar.setInventorySlotContents(0, copyStack); + stackOnPlayer.stackSize--; + return true; + } + + return false; + } + + @Override + public void setBlockBoundsBasedOnState(IBlockAccess w, int x, int y, int z) { + setBlockBounds(w.getBlockMetadata(x, y, z) < 4); + } + + public void setBlockBounds(boolean horiz) { + float f = 1F / 16F; + float w = f * 9; + float l = f * 6; + float ws = (1F - w) / 2; + float ls = (1F - l) / 2; + + if (horiz) setBlockBounds(ws, 0F, ls, 1F - ws, 1F + f, 1F - ls); + else setBlockBounds(ls, 0F, ws, 1F - ls, 1F + f, 1F - ws); + } + + @Override + public void breakBlock(World par1World, int par2, int par3, int par4, Block par5, int par6) { + TileSimpleInventory inv = (TileSimpleInventory) par1World.getTileEntity(par2, par3, par4); + + if (inv != null) { + for (int j1 = 0; j1 < inv.getSizeInventory(); ++j1) { + ItemStack itemstack = inv.getStackInSlot(j1); + + if (itemstack != null) { + float f = random.nextFloat() * 0.8F + 0.1F; + float f1 = random.nextFloat() * 0.8F + 0.1F; + EntityItem entityitem; + + for (float f2 = random.nextFloat() * 0.8F + 0.1F; + itemstack.stackSize > 0; + par1World.spawnEntityInWorld(entityitem)) { + int k1 = random.nextInt(21) + 10; + + if (k1 > itemstack.stackSize) k1 = itemstack.stackSize; + + itemstack.stackSize -= k1; + entityitem = new EntityItem( + par1World, + par2 + f, + par3 + f1, + par4 + f2, + new ItemStack(itemstack.getItem(), k1, itemstack.getItemDamage())); + float f3 = 0.05F; + entityitem.motionX = (float) random.nextGaussian() * f3; + entityitem.motionY = (float) random.nextGaussian() * f3 + 0.2F; + entityitem.motionZ = (float) random.nextGaussian() * f3; + + if (itemstack.hasTagCompound()) + entityitem.getEntityItem().setTagCompound((NBTTagCompound) + itemstack.getTagCompound().copy()); + } + } + } + + par1World.func_147453_f(par2, par3, par4, par5); + } + + super.breakBlock(par1World, par2, par3, par4, par5, par6); + } + + @Override + public void onBlockPlacedBy( + World p_149689_1_, + int p_149689_2_, + int p_149689_3_, + int p_149689_4_, + EntityLivingBase p_149689_5_, + ItemStack p_149689_6_) { + int l = MathHelper.floor_double(p_149689_5_.rotationYaw * 4.0F / 360.0F + 0.5D) & 3; + p_149689_1_.setBlockMetadataWithNotify(p_149689_2_, p_149689_3_, p_149689_4_, META_ROTATIONS[l], 2); + } + + @Override + public boolean rotateBlock(World worldObj, int x, int y, int z, ForgeDirection axis) { + return RotationHelper.rotateVanillaBlock(Blocks.furnace, worldObj, x, y, z, axis); + } + + @Override + public void registerBlockIcons(IIconRegister par1IconRegister) { + // NO-OP + } + + @Override + public IIcon getIcon(int side, int meta) { + return ModBlocks.livingwood.getIcon(0, 0); + } + + @Override + public boolean isOpaqueCube() { + return false; + } + + @Override + public boolean renderAsNormalBlock() { + return false; + } + + @Override + public int getRenderType() { + return LibRenderIDs.idAvatar; + } + + @Override + public TileEntity createNewTileEntity(World world, int meta) { + return new TileAvatar(); + } + + @Override + public LexiconEntry getEntry(World world, int x, int y, int z, EntityPlayer player, ItemStack lexicon) { + return LexiconData.avatar; + } } diff --git a/src/main/java/vazkii/botania/common/block/BlockBifrost.java b/src/main/java/vazkii/botania/common/block/BlockBifrost.java index 8f2736bd7c..cf3dbf9c0e 100644 --- a/src/main/java/vazkii/botania/common/block/BlockBifrost.java +++ b/src/main/java/vazkii/botania/common/block/BlockBifrost.java @@ -2,16 +2,18 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jun 20, 2014, 8:23:17 PM (GMT)] */ package vazkii.botania.common.block; +import cpw.mods.fml.common.eventhandler.SubscribeEvent; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; import java.util.Random; - import net.minecraft.block.Block; import net.minecraft.block.material.Material; import net.minecraft.client.renderer.texture.IIconRegister; @@ -31,82 +33,81 @@ import vazkii.botania.common.item.ModItems; import vazkii.botania.common.lexicon.LexiconData; import vazkii.botania.common.lib.LibBlockNames; -import cpw.mods.fml.common.eventhandler.SubscribeEvent; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; public class BlockBifrost extends BlockModContainer implements ILexiconable { - public BlockBifrost() { - super(Material.glass); - setBlockName(LibBlockNames.BIFROST); - setLightOpacity(0); - setLightLevel(1F); - setBlockUnbreakable(); - setStepSound(soundTypeGlass); - MinecraftForge.EVENT_BUS.register(this); - } - - @Override - public boolean registerInCreative() { - return false; - } - - @Override - public boolean isOpaqueCube() { - return false; - } - - @Override - public ItemStack getPickBlock(MovingObjectPosition target, World world, int x, int y, int z) { - return new ItemStack(ModItems.rainbowRod); - } - - public boolean shouldSideBeRendered1(IBlockAccess p_149646_1_, int p_149646_2_, int p_149646_3_, int p_149646_4_, int p_149646_5_) { - Block block = p_149646_1_.getBlock(p_149646_2_, p_149646_3_, p_149646_4_); - - return block == this ? false : super.shouldSideBeRendered(p_149646_1_, p_149646_2_, p_149646_3_, p_149646_4_, p_149646_5_); - } - - @Override - public boolean shouldSideBeRendered(IBlockAccess p_149646_1_, int p_149646_2_, int p_149646_3_, int p_149646_4_, int p_149646_5_) { - return shouldSideBeRendered1(p_149646_1_, p_149646_2_, p_149646_3_, p_149646_4_, 1 - p_149646_5_); - } - - @Override - public int getRenderBlockPass() { - return 1; - } - - @Override - public int quantityDropped(int meta, int fortune, Random random) { - return 0; - } - - @SubscribeEvent - @SideOnly(Side.CLIENT) - public void loadTextures(TextureStitchEvent.Pre event) { - if(event.map.getTextureType() == 0) { - TextureAtlasSprite icon = new InterpolatedIcon("botania:bifrost"); - if(event.map.setTextureEntry("botania:bifrost", icon)) - blockIcon = icon; - } - } - - @Override - @SideOnly(Side.CLIENT) - public void registerBlockIcons(IIconRegister par1IconRegister) { - // NO-OP - } - - @Override - public TileEntity createNewTileEntity(World world, int meta) { - return new TileBifrost(); - } - - @Override - public LexiconEntry getEntry(World world, int x, int y, int z, EntityPlayer player, ItemStack lexicon) { - return LexiconData.rainbowRod; - } - + public BlockBifrost() { + super(Material.glass); + setBlockName(LibBlockNames.BIFROST); + setLightOpacity(0); + setLightLevel(1F); + setBlockUnbreakable(); + setStepSound(soundTypeGlass); + MinecraftForge.EVENT_BUS.register(this); + } + + @Override + public boolean registerInCreative() { + return false; + } + + @Override + public boolean isOpaqueCube() { + return false; + } + + @Override + public ItemStack getPickBlock(MovingObjectPosition target, World world, int x, int y, int z) { + return new ItemStack(ModItems.rainbowRod); + } + + public boolean shouldSideBeRendered1( + IBlockAccess p_149646_1_, int p_149646_2_, int p_149646_3_, int p_149646_4_, int p_149646_5_) { + Block block = p_149646_1_.getBlock(p_149646_2_, p_149646_3_, p_149646_4_); + + return block == this + ? false + : super.shouldSideBeRendered(p_149646_1_, p_149646_2_, p_149646_3_, p_149646_4_, p_149646_5_); + } + + @Override + public boolean shouldSideBeRendered( + IBlockAccess p_149646_1_, int p_149646_2_, int p_149646_3_, int p_149646_4_, int p_149646_5_) { + return shouldSideBeRendered1(p_149646_1_, p_149646_2_, p_149646_3_, p_149646_4_, 1 - p_149646_5_); + } + + @Override + public int getRenderBlockPass() { + return 1; + } + + @Override + public int quantityDropped(int meta, int fortune, Random random) { + return 0; + } + + @SubscribeEvent + @SideOnly(Side.CLIENT) + public void loadTextures(TextureStitchEvent.Pre event) { + if (event.map.getTextureType() == 0) { + TextureAtlasSprite icon = new InterpolatedIcon("botania:bifrost"); + if (event.map.setTextureEntry("botania:bifrost", icon)) blockIcon = icon; + } + } + + @Override + @SideOnly(Side.CLIENT) + public void registerBlockIcons(IIconRegister par1IconRegister) { + // NO-OP + } + + @Override + public TileEntity createNewTileEntity(World world, int meta) { + return new TileBifrost(); + } + + @Override + public LexiconEntry getEntry(World world, int x, int y, int z, EntityPlayer player, ItemStack lexicon) { + return LexiconData.rainbowRod; + } } diff --git a/src/main/java/vazkii/botania/common/block/BlockBifrostPerm.java b/src/main/java/vazkii/botania/common/block/BlockBifrostPerm.java index 49eb550100..d9bb62958d 100644 --- a/src/main/java/vazkii/botania/common/block/BlockBifrostPerm.java +++ b/src/main/java/vazkii/botania/common/block/BlockBifrostPerm.java @@ -2,16 +2,15 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Aug 28, 2015, 10:46:20 PM (GMT)] */ package vazkii.botania.common.block; import java.util.Random; - import net.minecraft.block.Block; import net.minecraft.block.material.Material; import net.minecraft.client.renderer.texture.IIconRegister; @@ -28,56 +27,68 @@ public class BlockBifrostPerm extends BlockMod implements ILexiconable { - public BlockBifrostPerm() { - super(Material.glass); - setBlockName(LibBlockNames.BIFROST_PERM); - setLightOpacity(0); - setHardness(0.3F); - setLightLevel(1F); - setStepSound(soundTypeGlass); - setTickRandomly(true); - } - - @Override - public IIcon getIcon(int side, int meta) { - return ModBlocks.bifrost.getIcon(side, meta); - } + public BlockBifrostPerm() { + super(Material.glass); + setBlockName(LibBlockNames.BIFROST_PERM); + setLightOpacity(0); + setHardness(0.3F); + setLightLevel(1F); + setStepSound(soundTypeGlass); + setTickRandomly(true); + } - @Override - public void registerBlockIcons(IIconRegister par1IconRegister) { - // NO-OP - } + @Override + public IIcon getIcon(int side, int meta) { + return ModBlocks.bifrost.getIcon(side, meta); + } - @Override - public boolean isOpaqueCube() { - return false; - } + @Override + public void registerBlockIcons(IIconRegister par1IconRegister) { + // NO-OP + } - public boolean shouldSideBeRendered1(IBlockAccess p_149646_1_, int p_149646_2_, int p_149646_3_, int p_149646_4_, int p_149646_5_) { - Block block = p_149646_1_.getBlock(p_149646_2_, p_149646_3_, p_149646_4_); + @Override + public boolean isOpaqueCube() { + return false; + } - return block == this ? false : super.shouldSideBeRendered(p_149646_1_, p_149646_2_, p_149646_3_, p_149646_4_, p_149646_5_); - } + public boolean shouldSideBeRendered1( + IBlockAccess p_149646_1_, int p_149646_2_, int p_149646_3_, int p_149646_4_, int p_149646_5_) { + Block block = p_149646_1_.getBlock(p_149646_2_, p_149646_3_, p_149646_4_); - @Override - public boolean shouldSideBeRendered(IBlockAccess p_149646_1_, int p_149646_2_, int p_149646_3_, int p_149646_4_, int p_149646_5_) { - return shouldSideBeRendered1(p_149646_1_, p_149646_2_, p_149646_3_, p_149646_4_, 1 - p_149646_5_); - } + return block == this + ? false + : super.shouldSideBeRendered(p_149646_1_, p_149646_2_, p_149646_3_, p_149646_4_, p_149646_5_); + } - @Override - public void randomDisplayTick(World world, int x, int y, int z, Random rand) { - if(rand.nextBoolean()) - Botania.proxy.sparkleFX(world, x + Math.random(), y + Math.random(), z + Math.random(), (float) Math.random(), (float) Math.random(), (float) Math.random(), 0.45F + 0.2F * (float) Math.random(), 6); - } + @Override + public boolean shouldSideBeRendered( + IBlockAccess p_149646_1_, int p_149646_2_, int p_149646_3_, int p_149646_4_, int p_149646_5_) { + return shouldSideBeRendered1(p_149646_1_, p_149646_2_, p_149646_3_, p_149646_4_, 1 - p_149646_5_); + } - @Override - public int getRenderBlockPass() { - return 1; - } + @Override + public void randomDisplayTick(World world, int x, int y, int z, Random rand) { + if (rand.nextBoolean()) + Botania.proxy.sparkleFX( + world, + x + Math.random(), + y + Math.random(), + z + Math.random(), + (float) Math.random(), + (float) Math.random(), + (float) Math.random(), + 0.45F + 0.2F * (float) Math.random(), + 6); + } - @Override - public LexiconEntry getEntry(World world, int x, int y, int z, EntityPlayer player, ItemStack lexicon) { - return LexiconData.rainbowRod; - } + @Override + public int getRenderBlockPass() { + return 1; + } + @Override + public LexiconEntry getEntry(World world, int x, int y, int z, EntityPlayer player, ItemStack lexicon) { + return LexiconData.rainbowRod; + } } diff --git a/src/main/java/vazkii/botania/common/block/BlockCacophonium.java b/src/main/java/vazkii/botania/common/block/BlockCacophonium.java index d0129c4fae..b231048c41 100644 --- a/src/main/java/vazkii/botania/common/block/BlockCacophonium.java +++ b/src/main/java/vazkii/botania/common/block/BlockCacophonium.java @@ -2,16 +2,15 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Aug 23, 2015, 7:23:26 PM (GMT)] */ package vazkii.botania.common.block; import java.util.ArrayList; - import net.minecraft.block.Block; import net.minecraft.block.material.Material; import net.minecraft.client.renderer.texture.IIconRegister; @@ -27,74 +26,71 @@ public class BlockCacophonium extends BlockModContainer { - IIcon top; - - protected BlockCacophonium() { - super(Material.wood); - setBlockName(LibBlockNames.CACOPHONIUM); - setHardness(0.8F); - } - - @Override - public void registerBlockIcons(IIconRegister reg) { - blockIcon = IconHelper.forBlock(reg, this, 0); - top = IconHelper.forBlock(reg, this, 1); - } - - @Override - public IIcon getIcon(int side, int meta) { - return side == 1 ? blockIcon : top; - } - - @Override - protected boolean canSilkHarvest() { - return false; - } - - @Override - public boolean registerInCreative() { - return false; - } - - @Override - public void onNeighborBlockChange(World world, int x, int y, int z, Block block) { - boolean power = world.isBlockIndirectlyGettingPowered(x, y, z) || world.isBlockIndirectlyGettingPowered(x, y + 1, z); - int meta = world.getBlockMetadata(x, y, z); - boolean powered = (meta & 8) != 0; - - if(power && !powered) { - TileEntity tile = world.getTileEntity(x, y, z); - if(tile != null && tile instanceof TileCacophonium) - ((TileCacophonium) tile).annoyDirewolf(); - world.setBlockMetadataWithNotify(x, y, z, meta | 8, 4); - } else if(!power && powered) - world.setBlockMetadataWithNotify(x, y, z, meta & -9, 4); - } - - @Override - public void onBlockHarvested(World par1World, int par2, int par3, int par4, int par5, EntityPlayer par6EntityPlayer) { - if(!par6EntityPlayer.capabilities.isCreativeMode) - dropBlockAsItem(par1World, par2, par3, par4, par5, 0); - } - - @Override - public ArrayList getDrops(World world, int x, int y, int z, int metadata, int fortune) { - ArrayList stacks = new ArrayList(); - - TileEntity tile = world.getTileEntity(x, y, z); - if(tile != null && tile instanceof TileCacophonium) { - stacks.add(new ItemStack(Blocks.noteblock)); - ItemStack thingy = ((TileCacophonium) tile).stack; - if(thingy != null) - stacks.add(thingy.copy()); - } - - return stacks; - } - - @Override - public TileEntity createNewTileEntity(World world, int meta) { - return new TileCacophonium(); - } - + IIcon top; + + protected BlockCacophonium() { + super(Material.wood); + setBlockName(LibBlockNames.CACOPHONIUM); + setHardness(0.8F); + } + + @Override + public void registerBlockIcons(IIconRegister reg) { + blockIcon = IconHelper.forBlock(reg, this, 0); + top = IconHelper.forBlock(reg, this, 1); + } + + @Override + public IIcon getIcon(int side, int meta) { + return side == 1 ? blockIcon : top; + } + + @Override + protected boolean canSilkHarvest() { + return false; + } + + @Override + public boolean registerInCreative() { + return false; + } + + @Override + public void onNeighborBlockChange(World world, int x, int y, int z, Block block) { + boolean power = + world.isBlockIndirectlyGettingPowered(x, y, z) || world.isBlockIndirectlyGettingPowered(x, y + 1, z); + int meta = world.getBlockMetadata(x, y, z); + boolean powered = (meta & 8) != 0; + + if (power && !powered) { + TileEntity tile = world.getTileEntity(x, y, z); + if (tile != null && tile instanceof TileCacophonium) ((TileCacophonium) tile).annoyDirewolf(); + world.setBlockMetadataWithNotify(x, y, z, meta | 8, 4); + } else if (!power && powered) world.setBlockMetadataWithNotify(x, y, z, meta & -9, 4); + } + + @Override + public void onBlockHarvested( + World par1World, int par2, int par3, int par4, int par5, EntityPlayer par6EntityPlayer) { + if (!par6EntityPlayer.capabilities.isCreativeMode) dropBlockAsItem(par1World, par2, par3, par4, par5, 0); + } + + @Override + public ArrayList getDrops(World world, int x, int y, int z, int metadata, int fortune) { + ArrayList stacks = new ArrayList(); + + TileEntity tile = world.getTileEntity(x, y, z); + if (tile != null && tile instanceof TileCacophonium) { + stacks.add(new ItemStack(Blocks.noteblock)); + ItemStack thingy = ((TileCacophonium) tile).stack; + if (thingy != null) stacks.add(thingy.copy()); + } + + return stacks; + } + + @Override + public TileEntity createNewTileEntity(World world, int meta) { + return new TileCacophonium(); + } } diff --git a/src/main/java/vazkii/botania/common/block/BlockCamo.java b/src/main/java/vazkii/botania/common/block/BlockCamo.java index 968d834921..a3f4b7cee3 100644 --- a/src/main/java/vazkii/botania/common/block/BlockCamo.java +++ b/src/main/java/vazkii/botania/common/block/BlockCamo.java @@ -2,17 +2,18 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jun 7, 2014, 2:20:51 PM (GMT)] */ package vazkii.botania.common.block; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; import java.util.Arrays; import java.util.List; - import net.minecraft.block.Block; import net.minecraft.block.BlockDirectional; import net.minecraft.block.material.Material; @@ -24,124 +25,129 @@ import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; import vazkii.botania.common.block.tile.TileCamo; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; public abstract class BlockCamo extends BlockModContainer { - static List validRenderTypes = Arrays.asList(0, 31, 39); - - protected BlockCamo(Material par2Material) { - super(par2Material); - } - - @Override - public IIcon getIcon(IBlockAccess world, int x, int y, int z, int side) { - TileEntity tile = world.getTileEntity(x, y, z); - int meta = world.getBlockMetadata(x, y, z); - - if(tile instanceof TileCamo) { - TileCamo camo = (TileCamo) tile; - Block block = camo.camo; - if(block != null && isValidBlock(block)) - return block.getIcon(side, camo.camoMeta); - } - - return getIconFromSideAfterCheck(tile, meta, side); - } - - public static boolean isValidBlock(Block block) { - return block.isOpaqueCube() || isValidRenderType(block.getRenderType()); - } - - public static boolean isValidRenderType(int type) { - return validRenderTypes.contains(type); - } - - @Override - public boolean onBlockActivated(World par1World, int par2, int par3, int par4, EntityPlayer par5EntityPlayer, int par6, float par7, float par8, float par9) { - TileEntity tile = par1World.getTileEntity(par2, par3, par4); - - if(tile instanceof TileCamo) { - TileCamo camo = (TileCamo) tile; - ItemStack currentStack = par5EntityPlayer.getCurrentEquippedItem(); - - if(currentStack == null) - currentStack = new ItemStack(Block.getBlockFromName("air"), 1, 0); - - boolean doChange = true; - Block block = null; - checkChange : { - if(currentStack.getItem() != Item.getItemFromBlock(Block.getBlockFromName("air"))) { - if(Item.getIdFromItem(currentStack.getItem()) == 0) { - doChange = false; - break checkChange; - } - - block = Block.getBlockFromItem(currentStack.getItem()); - if(block == null || !isValidBlock(block) || block instanceof BlockCamo || block.getMaterial() == Material.air) - doChange = false; - } - } - - if(doChange && currentStack.getItem() != null) { - int metadata = currentStack.getItemDamage(); - if(block instanceof BlockDirectional) { - switch (par6) { - case 0: - case 1: - break; - case 2: - metadata = metadata & 12 | 2; - break; - case 3: - metadata = metadata & 12; - break; - case 4: - metadata = metadata & 12 | 1; - break; - case 5: - metadata = metadata & 12 | 3; - break; - } - } - camo.camo = Block.getBlockFromItem(currentStack.getItem()); - camo.camoMeta = metadata; - par1World.markBlockForUpdate(par2,par3,par4); - - return true; - } - } - - return false; - } - - @Override - public boolean isOpaqueCube() { - return false; - } - - @Override - public boolean renderAsNormalBlock() { - return false; - } - - @Override - @SideOnly(Side.CLIENT) - public int colorMultiplier(IBlockAccess par1World, int par2, int par3, int par4) { - TileEntity tile = par1World.getTileEntity(par2, par3, par4); - if(tile instanceof TileCamo) { - TileCamo camo = (TileCamo) tile; - Block block = camo.camo; - if(block != null) - return block instanceof BlockCamo ? 0xFFFFFF : block.getRenderColor(camo.camoMeta); - - } - return 0xFFFFFF; - } - - public IIcon getIconFromSideAfterCheck(TileEntity tile, int meta, int side) { - return getIcon(side, meta); - } - -} \ No newline at end of file + static List validRenderTypes = Arrays.asList(0, 31, 39); + + protected BlockCamo(Material par2Material) { + super(par2Material); + } + + @Override + public IIcon getIcon(IBlockAccess world, int x, int y, int z, int side) { + TileEntity tile = world.getTileEntity(x, y, z); + int meta = world.getBlockMetadata(x, y, z); + + if (tile instanceof TileCamo) { + TileCamo camo = (TileCamo) tile; + Block block = camo.camo; + if (block != null && isValidBlock(block)) return block.getIcon(side, camo.camoMeta); + } + + return getIconFromSideAfterCheck(tile, meta, side); + } + + public static boolean isValidBlock(Block block) { + return block.isOpaqueCube() || isValidRenderType(block.getRenderType()); + } + + public static boolean isValidRenderType(int type) { + return validRenderTypes.contains(type); + } + + @Override + public boolean onBlockActivated( + World par1World, + int par2, + int par3, + int par4, + EntityPlayer par5EntityPlayer, + int par6, + float par7, + float par8, + float par9) { + TileEntity tile = par1World.getTileEntity(par2, par3, par4); + + if (tile instanceof TileCamo) { + TileCamo camo = (TileCamo) tile; + ItemStack currentStack = par5EntityPlayer.getCurrentEquippedItem(); + + if (currentStack == null) currentStack = new ItemStack(Block.getBlockFromName("air"), 1, 0); + + boolean doChange = true; + Block block = null; + checkChange: + { + if (currentStack.getItem() != Item.getItemFromBlock(Block.getBlockFromName("air"))) { + if (Item.getIdFromItem(currentStack.getItem()) == 0) { + doChange = false; + break checkChange; + } + + block = Block.getBlockFromItem(currentStack.getItem()); + if (block == null + || !isValidBlock(block) + || block instanceof BlockCamo + || block.getMaterial() == Material.air) doChange = false; + } + } + + if (doChange && currentStack.getItem() != null) { + int metadata = currentStack.getItemDamage(); + if (block instanceof BlockDirectional) { + switch (par6) { + case 0: + case 1: + break; + case 2: + metadata = metadata & 12 | 2; + break; + case 3: + metadata = metadata & 12; + break; + case 4: + metadata = metadata & 12 | 1; + break; + case 5: + metadata = metadata & 12 | 3; + break; + } + } + camo.camo = Block.getBlockFromItem(currentStack.getItem()); + camo.camoMeta = metadata; + par1World.markBlockForUpdate(par2, par3, par4); + + return true; + } + } + + return false; + } + + @Override + public boolean isOpaqueCube() { + return false; + } + + @Override + public boolean renderAsNormalBlock() { + return false; + } + + @Override + @SideOnly(Side.CLIENT) + public int colorMultiplier(IBlockAccess par1World, int par2, int par3, int par4) { + TileEntity tile = par1World.getTileEntity(par2, par3, par4); + if (tile instanceof TileCamo) { + TileCamo camo = (TileCamo) tile; + Block block = camo.camo; + if (block != null) return block instanceof BlockCamo ? 0xFFFFFF : block.getRenderColor(camo.camoMeta); + } + return 0xFFFFFF; + } + + public IIcon getIconFromSideAfterCheck(TileEntity tile, int meta, int side) { + return getIcon(side, meta); + } +} diff --git a/src/main/java/vazkii/botania/common/block/BlockCell.java b/src/main/java/vazkii/botania/common/block/BlockCell.java index b538b2372a..20a243c7ca 100644 --- a/src/main/java/vazkii/botania/common/block/BlockCell.java +++ b/src/main/java/vazkii/botania/common/block/BlockCell.java @@ -2,16 +2,15 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Sep 6, 2015, 4:03:56 PM (GMT)] */ package vazkii.botania.common.block; import java.util.ArrayList; - import net.minecraft.block.material.Material; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; @@ -25,25 +24,24 @@ public class BlockCell extends BlockModContainer implements ILexiconable { - public BlockCell() { - super(Material.gourd); - setBlockName(LibBlockNames.CELL_BLOCK); - setStepSound(soundTypeCloth); - } - - @Override - public ArrayList getDrops(World world, int x, int y, int z, int metadata, int fortune) { - return new ArrayList(); - } - - @Override - public TileEntity createNewTileEntity(World world, int meta) { - return new TileCell(); - } - - @Override - public LexiconEntry getEntry(World world, int x, int y, int z, EntityPlayer player, ItemStack lexicon) { - return LexiconData.dandelifeon; - } - + public BlockCell() { + super(Material.gourd); + setBlockName(LibBlockNames.CELL_BLOCK); + setStepSound(soundTypeCloth); + } + + @Override + public ArrayList getDrops(World world, int x, int y, int z, int metadata, int fortune) { + return new ArrayList(); + } + + @Override + public TileEntity createNewTileEntity(World world, int meta) { + return new TileCell(); + } + + @Override + public LexiconEntry getEntry(World world, int x, int y, int z, EntityPlayer player, ItemStack lexicon) { + return LexiconData.dandelifeon; + } } diff --git a/src/main/java/vazkii/botania/common/block/BlockCocoon.java b/src/main/java/vazkii/botania/common/block/BlockCocoon.java index bcf82a5038..c099e585c5 100644 --- a/src/main/java/vazkii/botania/common/block/BlockCocoon.java +++ b/src/main/java/vazkii/botania/common/block/BlockCocoon.java @@ -2,16 +2,15 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jul 8, 2015, 4:29:01 PM (GMT)] */ package vazkii.botania.common.block; import java.util.ArrayList; - import net.minecraft.block.material.Material; import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.entity.player.EntityPlayer; @@ -30,73 +29,72 @@ public class BlockCocoon extends BlockModContainer implements ILexiconable { - protected BlockCocoon() { - super(Material.cloth); - setHardness(3.0F); - setResistance(50.0F); - setStepSound(soundTypeCloth); - setBlockName(LibBlockNames.COCOON); - float f = 3F / 16F; - float f1 = 14F / 16F; - setBlockBounds(f, 0F, f, 1F - f, f1, 1F - f); - } - - @Override - public void registerBlockIcons(IIconRegister par1IconRegister) { - // NO-OP - } + protected BlockCocoon() { + super(Material.cloth); + setHardness(3.0F); + setResistance(50.0F); + setStepSound(soundTypeCloth); + setBlockName(LibBlockNames.COCOON); + float f = 3F / 16F; + float f1 = 14F / 16F; + setBlockBounds(f, 0F, f, 1F - f, f1, 1F - f); + } - @Override - public IIcon getIcon(int p_149691_1_, int p_149691_2_) { - return Blocks.web.getBlockTextureFromSide(0); - } + @Override + public void registerBlockIcons(IIconRegister par1IconRegister) { + // NO-OP + } - @Override - public boolean renderAsNormalBlock() { - return false; - } + @Override + public IIcon getIcon(int p_149691_1_, int p_149691_2_) { + return Blocks.web.getBlockTextureFromSide(0); + } - @Override - public boolean isOpaqueCube() { - return false; - } + @Override + public boolean renderAsNormalBlock() { + return false; + } - @Override - public int getRenderType() { - return LibRenderIDs.idCocoon; - } + @Override + public boolean isOpaqueCube() { + return false; + } - @Override - public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int s, float xs, float ys, float zs) { - TileCocoon cocoon = (TileCocoon) world.getTileEntity(x, y, z); - ItemStack item = player.getCurrentEquippedItem(); - if(cocoon.emeraldsGiven < TileCocoon.MAX_EMERALDS && item != null && item.getItem() == Items.emerald) { - if(!player.capabilities.isCreativeMode) - item.stackSize--; - cocoon.emeraldsGiven++; - world.playAuxSFX(2005, x, y, z, 6 + world.rand.nextInt(4)); - } - return false; - } + @Override + public int getRenderType() { + return LibRenderIDs.idCocoon; + } - @Override - public ArrayList getDrops(World world, int x, int y, int z, int metadata, int fortune) { - return new ArrayList(); - } + @Override + public boolean onBlockActivated( + World world, int x, int y, int z, EntityPlayer player, int s, float xs, float ys, float zs) { + TileCocoon cocoon = (TileCocoon) world.getTileEntity(x, y, z); + ItemStack item = player.getCurrentEquippedItem(); + if (cocoon.emeraldsGiven < TileCocoon.MAX_EMERALDS && item != null && item.getItem() == Items.emerald) { + if (!player.capabilities.isCreativeMode) item.stackSize--; + cocoon.emeraldsGiven++; + world.playAuxSFX(2005, x, y, z, 6 + world.rand.nextInt(4)); + } + return false; + } - @Override - protected boolean canSilkHarvest() { - return false; - } + @Override + public ArrayList getDrops(World world, int x, int y, int z, int metadata, int fortune) { + return new ArrayList(); + } - @Override - public TileEntity createNewTileEntity(World world, int meta) { - return new TileCocoon(); - } + @Override + protected boolean canSilkHarvest() { + return false; + } - @Override - public LexiconEntry getEntry(World world, int x, int y, int z, EntityPlayer player, ItemStack lexicon) { - return LexiconData.cocoon; - } + @Override + public TileEntity createNewTileEntity(World world, int meta) { + return new TileCocoon(); + } + @Override + public LexiconEntry getEntry(World world, int x, int y, int z, EntityPlayer player, ItemStack lexicon) { + return LexiconData.cocoon; + } } diff --git a/src/main/java/vazkii/botania/common/block/BlockDreamwood.java b/src/main/java/vazkii/botania/common/block/BlockDreamwood.java index 5ed43a1556..d1615bd155 100644 --- a/src/main/java/vazkii/botania/common/block/BlockDreamwood.java +++ b/src/main/java/vazkii/botania/common/block/BlockDreamwood.java @@ -1,5 +1,6 @@ package vazkii.botania.common.block; +import cpw.mods.fml.common.registry.GameRegistry; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; import net.minecraft.world.World; @@ -7,21 +8,20 @@ import vazkii.botania.common.item.block.ItemBlockDreamwood; import vazkii.botania.common.lexicon.LexiconData; import vazkii.botania.common.lib.LibBlockNames; -import cpw.mods.fml.common.registry.GameRegistry; public class BlockDreamwood extends BlockLivingwood { - public BlockDreamwood() { - super(LibBlockNames.DREAM_WOOD); - } + public BlockDreamwood() { + super(LibBlockNames.DREAM_WOOD); + } - @Override - void register(String name) { - GameRegistry.registerBlock(this, ItemBlockDreamwood.class, name); - } + @Override + void register(String name) { + GameRegistry.registerBlock(this, ItemBlockDreamwood.class, name); + } - @Override - public LexiconEntry getEntry(World world, int x, int y, int z, EntityPlayer player, ItemStack lexicon) { - return LexiconData.elvenResources; - } + @Override + public LexiconEntry getEntry(World world, int x, int y, int z, EntityPlayer player, ItemStack lexicon) { + return LexiconData.elvenResources; + } } diff --git a/src/main/java/vazkii/botania/common/block/BlockEnchantedSoil.java b/src/main/java/vazkii/botania/common/block/BlockEnchantedSoil.java index 1c66aca3f7..3f6b5c1373 100644 --- a/src/main/java/vazkii/botania/common/block/BlockEnchantedSoil.java +++ b/src/main/java/vazkii/botania/common/block/BlockEnchantedSoil.java @@ -2,16 +2,18 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jan 26, 2015, 6:08:29 PM (GMT)] */ package vazkii.botania.common.block; +import cpw.mods.fml.common.eventhandler.SubscribeEvent; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; import java.util.Random; - import net.minecraft.block.material.Material; import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.client.renderer.texture.TextureAtlasSprite; @@ -32,71 +34,66 @@ import vazkii.botania.client.render.block.InterpolatedIcon; import vazkii.botania.common.lexicon.LexiconData; import vazkii.botania.common.lib.LibBlockNames; -import cpw.mods.fml.common.eventhandler.SubscribeEvent; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; public class BlockEnchantedSoil extends BlockMod implements ILexiconable { - IIcon iconSide; - - public BlockEnchantedSoil() { - super(Material.grass); - setHardness(0.6F); - setStepSound(soundTypeGrass); - setBlockName(LibBlockNames.ENCHANTED_SOIL); - MinecraftForge.EVENT_BUS.register(this); - } + IIcon iconSide; - @Override - boolean registerInCreative() { - return false; - } + public BlockEnchantedSoil() { + super(Material.grass); + setHardness(0.6F); + setStepSound(soundTypeGrass); + setBlockName(LibBlockNames.ENCHANTED_SOIL); + MinecraftForge.EVENT_BUS.register(this); + } - @Override - @SideOnly(Side.CLIENT) - public void registerBlockIcons(IIconRegister par1IconRegister) { - // NO-OP - } + @Override + boolean registerInCreative() { + return false; + } - @SubscribeEvent - @SideOnly(Side.CLIENT) - public void loadTextures(TextureStitchEvent.Pre event) { - if(event.map.getTextureType() == 0) { - TextureAtlasSprite icon = new InterpolatedIcon("botania:enchantedSoil0"); - if(event.map.setTextureEntry("botania:enchantedSoil0", icon)) - blockIcon = icon; + @Override + @SideOnly(Side.CLIENT) + public void registerBlockIcons(IIconRegister par1IconRegister) { + // NO-OP + } - icon = new InterpolatedIcon("botania:enchantedSoil1"); - if(event.map.setTextureEntry("botania:enchantedSoil1", icon)) - iconSide = icon; - } - } + @SubscribeEvent + @SideOnly(Side.CLIENT) + public void loadTextures(TextureStitchEvent.Pre event) { + if (event.map.getTextureType() == 0) { + TextureAtlasSprite icon = new InterpolatedIcon("botania:enchantedSoil0"); + if (event.map.setTextureEntry("botania:enchantedSoil0", icon)) blockIcon = icon; - @Override - @SideOnly(Side.CLIENT) - public IIcon getIcon(int side, int meta) { - return side == 0 ? Blocks.dirt.getIcon(0, 0) : side == 1 ? blockIcon : iconSide; - } + icon = new InterpolatedIcon("botania:enchantedSoil1"); + if (event.map.setTextureEntry("botania:enchantedSoil1", icon)) iconSide = icon; + } + } - @Override - public Item getItemDropped(int p_149650_1_, Random p_149650_2_, int p_149650_3_) { - return Blocks.dirt.getItemDropped(0, p_149650_2_, p_149650_3_); - } + @Override + @SideOnly(Side.CLIENT) + public IIcon getIcon(int side, int meta) { + return side == 0 ? Blocks.dirt.getIcon(0, 0) : side == 1 ? blockIcon : iconSide; + } - @Override - public boolean canSustainPlant(IBlockAccess world, int x, int y, int z, ForgeDirection direction, IPlantable plantable) { - return plantable.getPlantType(world, x, y - 1, z) == EnumPlantType.Plains; - } + @Override + public Item getItemDropped(int p_149650_1_, Random p_149650_2_, int p_149650_3_) { + return Blocks.dirt.getItemDropped(0, p_149650_2_, p_149650_3_); + } - @Override - protected boolean canSilkHarvest() { - return false; - } + @Override + public boolean canSustainPlant( + IBlockAccess world, int x, int y, int z, ForgeDirection direction, IPlantable plantable) { + return plantable.getPlantType(world, x, y - 1, z) == EnumPlantType.Plains; + } - @Override - public LexiconEntry getEntry(World world, int x, int y, int z, EntityPlayer player, ItemStack lexicon) { - return LexiconData.overgrowthSeed; - } + @Override + protected boolean canSilkHarvest() { + return false; + } + @Override + public LexiconEntry getEntry(World world, int x, int y, int z, EntityPlayer player, ItemStack lexicon) { + return LexiconData.overgrowthSeed; + } } diff --git a/src/main/java/vazkii/botania/common/block/BlockEnderEye.java b/src/main/java/vazkii/botania/common/block/BlockEnderEye.java index 5ea86885ac..7309410485 100644 --- a/src/main/java/vazkii/botania/common/block/BlockEnderEye.java +++ b/src/main/java/vazkii/botania/common/block/BlockEnderEye.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jul 30, 2014, 1:05:07 PM (GMT)] */ package vazkii.botania.common.block; @@ -27,45 +27,44 @@ public class BlockEnderEye extends BlockModContainer implements ILexiconable { - IIcon iconOff, iconOn; + IIcon iconOff, iconOn; - protected BlockEnderEye() { - super(Material.iron); - setHardness(3F); - setResistance(10F); - setStepSound(soundTypeMetal); - setBlockName(LibBlockNames.ENDER_EYE_BLOCK); - } + protected BlockEnderEye() { + super(Material.iron); + setHardness(3F); + setResistance(10F); + setStepSound(soundTypeMetal); + setBlockName(LibBlockNames.ENDER_EYE_BLOCK); + } - @Override - public void registerBlockIcons(IIconRegister par1IconRegister) { - iconOff = IconHelper.forBlock(par1IconRegister, this, 0); - iconOn = IconHelper.forBlock(par1IconRegister, this, 1); - } + @Override + public void registerBlockIcons(IIconRegister par1IconRegister) { + iconOff = IconHelper.forBlock(par1IconRegister, this, 0); + iconOn = IconHelper.forBlock(par1IconRegister, this, 1); + } - @Override - public IIcon getIcon(int side, int meta) { - return meta == 0 ? iconOff : iconOn; - } + @Override + public IIcon getIcon(int side, int meta) { + return meta == 0 ? iconOff : iconOn; + } - @Override - public boolean canProvidePower() { - return true; - } + @Override + public boolean canProvidePower() { + return true; + } - @Override - public int isProvidingWeakPower(IBlockAccess world, int x, int y, int z, int side) { - return world.getBlockMetadata(x, y, z); - } + @Override + public int isProvidingWeakPower(IBlockAccess world, int x, int y, int z, int side) { + return world.getBlockMetadata(x, y, z); + } - @Override - public TileEntity createNewTileEntity(World world, int meta) { - return new TileEnderEye(); - } - - @Override - public LexiconEntry getEntry(World world, int x, int y, int z, EntityPlayer player, ItemStack lexicon) { - return LexiconData.enderEyeBlock; - } + @Override + public TileEntity createNewTileEntity(World world, int meta) { + return new TileEnderEye(); + } + @Override + public LexiconEntry getEntry(World world, int x, int y, int z, EntityPlayer player, ItemStack lexicon) { + return LexiconData.enderEyeBlock; + } } diff --git a/src/main/java/vazkii/botania/common/block/BlockFakeAir.java b/src/main/java/vazkii/botania/common/block/BlockFakeAir.java index e55e112953..1c83c4f4e8 100644 --- a/src/main/java/vazkii/botania/common/block/BlockFakeAir.java +++ b/src/main/java/vazkii/botania/common/block/BlockFakeAir.java @@ -2,17 +2,16 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Apr 10, 2015, 10:22:38 PM (GMT)] */ package vazkii.botania.common.block; import java.util.ArrayList; import java.util.Random; - import net.minecraft.block.Block; import net.minecraft.block.material.Material; import net.minecraft.entity.Entity; @@ -28,87 +27,86 @@ public class BlockFakeAir extends BlockModContainer { - public BlockFakeAir() { - super(Material.air); - setBlockName(LibBlockNames.FAKE_AIR); - setBlockBounds(0, 0, 0, 0, 0, 0); - setTickRandomly(true); - } - - @Override - public void onNeighborBlockChange(World world, int x, int y, int z, Block block) { - if(shouldRemove(world, x, y, z)) - world.scheduleBlockUpdate(x, y, z, this, tickRate(world)); - } - - private boolean shouldRemove(World world, int x, int y, int z) { - return !world.isRemote && world.getTileEntity(x, y, z) == null || !(world.getTileEntity(x, y, z) instanceof TileFakeAir) || !((TileFakeAir) world.getTileEntity(x, y, z)).canStay(); - } - - @Override - public void updateTick(World world, int x, int y, int z, Random rand) { - if(shouldRemove(world, x, y, z)) - world.setBlock(x, y, z, Blocks.water); - } - - @Override - public int tickRate(World p_149738_1_) { - return 4; - } - - @Override - public boolean registerInCreative() { - return false; - } - - @Override - public boolean isBlockNormalCube() { - return false; - } - - @Override - public boolean isOpaqueCube() { - return false; - } - - @Override - public boolean canEntityDestroy(IBlockAccess world, int x, int y, int z, Entity e) { - return false; - } - - @Override - public boolean canCollideCheck(int par1, boolean par2) { - return false; - } - - @Override - public boolean canBeReplacedByLeaves(IBlockAccess world, int x, int y, int z) { - return true; - } - - @Override - public boolean canDropFromExplosion(Explosion par1Explosion) { - return false; - } - - @Override - public ArrayList getDrops(World world, int x, int y, int z, int metadata, int fortune) { - return new ArrayList(); // Empty List - } - - @Override - public AxisAlignedBB getCollisionBoundingBoxFromPool(World par1World, int par2, int par3, int par4) { - return null; - } - - @Override - public boolean isAir(IBlockAccess world, int x, int y, int z) { - return true; - } - - @Override - public TileEntity createNewTileEntity(World world, int meta) { - return new TileFakeAir(); - } - + public BlockFakeAir() { + super(Material.air); + setBlockName(LibBlockNames.FAKE_AIR); + setBlockBounds(0, 0, 0, 0, 0, 0); + setTickRandomly(true); + } + + @Override + public void onNeighborBlockChange(World world, int x, int y, int z, Block block) { + if (shouldRemove(world, x, y, z)) world.scheduleBlockUpdate(x, y, z, this, tickRate(world)); + } + + private boolean shouldRemove(World world, int x, int y, int z) { + return !world.isRemote && world.getTileEntity(x, y, z) == null + || !(world.getTileEntity(x, y, z) instanceof TileFakeAir) + || !((TileFakeAir) world.getTileEntity(x, y, z)).canStay(); + } + + @Override + public void updateTick(World world, int x, int y, int z, Random rand) { + if (shouldRemove(world, x, y, z)) world.setBlock(x, y, z, Blocks.water); + } + + @Override + public int tickRate(World p_149738_1_) { + return 4; + } + + @Override + public boolean registerInCreative() { + return false; + } + + @Override + public boolean isBlockNormalCube() { + return false; + } + + @Override + public boolean isOpaqueCube() { + return false; + } + + @Override + public boolean canEntityDestroy(IBlockAccess world, int x, int y, int z, Entity e) { + return false; + } + + @Override + public boolean canCollideCheck(int par1, boolean par2) { + return false; + } + + @Override + public boolean canBeReplacedByLeaves(IBlockAccess world, int x, int y, int z) { + return true; + } + + @Override + public boolean canDropFromExplosion(Explosion par1Explosion) { + return false; + } + + @Override + public ArrayList getDrops(World world, int x, int y, int z, int metadata, int fortune) { + return new ArrayList(); // Empty List + } + + @Override + public AxisAlignedBB getCollisionBoundingBoxFromPool(World par1World, int par2, int par3, int par4) { + return null; + } + + @Override + public boolean isAir(IBlockAccess world, int x, int y, int z) { + return true; + } + + @Override + public TileEntity createNewTileEntity(World world, int meta) { + return new TileFakeAir(); + } } diff --git a/src/main/java/vazkii/botania/common/block/BlockFelPumpkin.java b/src/main/java/vazkii/botania/common/block/BlockFelPumpkin.java index 9f439a05fc..3a2a3cf985 100644 --- a/src/main/java/vazkii/botania/common/block/BlockFelPumpkin.java +++ b/src/main/java/vazkii/botania/common/block/BlockFelPumpkin.java @@ -2,14 +2,17 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jul 7, 2015, 7:59:10 PM (GMT)] */ package vazkii.botania.common.block; +import cpw.mods.fml.common.eventhandler.SubscribeEvent; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; import net.minecraft.block.material.Material; import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.entity.EntityLivingBase; @@ -29,77 +32,97 @@ import vazkii.botania.client.core.helper.IconHelper; import vazkii.botania.common.lexicon.LexiconData; import vazkii.botania.common.lib.LibBlockNames; -import cpw.mods.fml.common.eventhandler.SubscribeEvent; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; public class BlockFelPumpkin extends BlockMod implements ILexiconable { - private static final String TAG_FEL_SPAWNED = "Botania-FelSpawned"; - - IIcon top, face; + private static final String TAG_FEL_SPAWNED = "Botania-FelSpawned"; - public BlockFelPumpkin() { - super(Material.gourd); - setBlockName(LibBlockNames.FEL_PUMPKIN); - setHardness(1F); - setStepSound(soundTypeWood); - MinecraftForge.EVENT_BUS.register(this); - } + IIcon top, face; - @Override - @SideOnly(Side.CLIENT) - public IIcon getIcon(int p_149691_1_, int p_149691_2_) { - return p_149691_1_ == 1 ? top : p_149691_1_ == 0 ? top : p_149691_2_ == 2 && p_149691_1_ == 2 ? face : p_149691_2_ == 3 && p_149691_1_ == 5 ? face : p_149691_2_ == 0 && p_149691_1_ == 3 ? face : p_149691_2_ == 1 && p_149691_1_ == 4 ? face : blockIcon; - } + public BlockFelPumpkin() { + super(Material.gourd); + setBlockName(LibBlockNames.FEL_PUMPKIN); + setHardness(1F); + setStepSound(soundTypeWood); + MinecraftForge.EVENT_BUS.register(this); + } - @Override - public void onBlockAdded(World p_149726_1_, int p_149726_2_, int p_149726_3_, int p_149726_4_) { - super.onBlockAdded(p_149726_1_, p_149726_2_, p_149726_3_, p_149726_4_); + @Override + @SideOnly(Side.CLIENT) + public IIcon getIcon(int p_149691_1_, int p_149691_2_) { + return p_149691_1_ == 1 + ? top + : p_149691_1_ == 0 + ? top + : p_149691_2_ == 2 && p_149691_1_ == 2 + ? face + : p_149691_2_ == 3 && p_149691_1_ == 5 + ? face + : p_149691_2_ == 0 && p_149691_1_ == 3 + ? face + : p_149691_2_ == 1 && p_149691_1_ == 4 ? face : blockIcon; + } - if(!p_149726_1_.isRemote && p_149726_1_.getBlock(p_149726_2_, p_149726_3_ - 1, p_149726_4_) == Blocks.iron_bars && p_149726_1_.getBlock(p_149726_2_, p_149726_3_ - 2, p_149726_4_) == Blocks.iron_bars) { - p_149726_1_.setBlock(p_149726_2_, p_149726_3_, p_149726_4_, getBlockById(0), 0, 2); - p_149726_1_.setBlock(p_149726_2_, p_149726_3_ - 1, p_149726_4_, getBlockById(0), 0, 2); - p_149726_1_.setBlock(p_149726_2_, p_149726_3_ - 2, p_149726_4_, getBlockById(0), 0, 2); - EntityBlaze blaze = new EntityBlaze(p_149726_1_); - blaze.setLocationAndAngles(p_149726_2_ + 0.5D, p_149726_3_ - 1.95D, p_149726_4_ + 0.5D, 0.0F, 0.0F); - blaze.getEntityData().setBoolean(TAG_FEL_SPAWNED, true); - p_149726_1_.spawnEntityInWorld(blaze); - p_149726_1_.notifyBlockChange(p_149726_2_, p_149726_3_, p_149726_4_, getBlockById(0)); - p_149726_1_.notifyBlockChange(p_149726_2_, p_149726_3_ - 1, p_149726_4_, getBlockById(0)); - p_149726_1_.notifyBlockChange(p_149726_2_, p_149726_3_ - 2, p_149726_4_, getBlockById(0)); - } - } + @Override + public void onBlockAdded(World p_149726_1_, int p_149726_2_, int p_149726_3_, int p_149726_4_) { + super.onBlockAdded(p_149726_1_, p_149726_2_, p_149726_3_, p_149726_4_); - @Override - public void onBlockPlacedBy(World p_149689_1_, int p_149689_2_, int p_149689_3_, int p_149689_4_, EntityLivingBase p_149689_5_, ItemStack p_149689_6_) { - int l = MathHelper.floor_double(p_149689_5_.rotationYaw * 4.0F / 360.0F + 2.5D) & 3; - p_149689_1_.setBlockMetadataWithNotify(p_149689_2_, p_149689_3_, p_149689_4_, l, 2); - } + if (!p_149726_1_.isRemote + && p_149726_1_.getBlock(p_149726_2_, p_149726_3_ - 1, p_149726_4_) == Blocks.iron_bars + && p_149726_1_.getBlock(p_149726_2_, p_149726_3_ - 2, p_149726_4_) == Blocks.iron_bars) { + p_149726_1_.setBlock(p_149726_2_, p_149726_3_, p_149726_4_, getBlockById(0), 0, 2); + p_149726_1_.setBlock(p_149726_2_, p_149726_3_ - 1, p_149726_4_, getBlockById(0), 0, 2); + p_149726_1_.setBlock(p_149726_2_, p_149726_3_ - 2, p_149726_4_, getBlockById(0), 0, 2); + EntityBlaze blaze = new EntityBlaze(p_149726_1_); + blaze.setLocationAndAngles(p_149726_2_ + 0.5D, p_149726_3_ - 1.95D, p_149726_4_ + 0.5D, 0.0F, 0.0F); + blaze.getEntityData().setBoolean(TAG_FEL_SPAWNED, true); + p_149726_1_.spawnEntityInWorld(blaze); + p_149726_1_.notifyBlockChange(p_149726_2_, p_149726_3_, p_149726_4_, getBlockById(0)); + p_149726_1_.notifyBlockChange(p_149726_2_, p_149726_3_ - 1, p_149726_4_, getBlockById(0)); + p_149726_1_.notifyBlockChange(p_149726_2_, p_149726_3_ - 2, p_149726_4_, getBlockById(0)); + } + } - @Override - @SideOnly(Side.CLIENT) - public void registerBlockIcons(IIconRegister p_149651_1_) { - face = IconHelper.forBlock(p_149651_1_, this); - top = Blocks.pumpkin.getIcon(0, 0); - blockIcon = Blocks.pumpkin.getIcon(2, 0); - } + @Override + public void onBlockPlacedBy( + World p_149689_1_, + int p_149689_2_, + int p_149689_3_, + int p_149689_4_, + EntityLivingBase p_149689_5_, + ItemStack p_149689_6_) { + int l = MathHelper.floor_double(p_149689_5_.rotationYaw * 4.0F / 360.0F + 2.5D) & 3; + p_149689_1_.setBlockMetadataWithNotify(p_149689_2_, p_149689_3_, p_149689_4_, l, 2); + } - @SubscribeEvent - public void onDrops(LivingDropsEvent event) { - if(event.entity instanceof EntityBlaze && event.entity.getEntityData().getBoolean(TAG_FEL_SPAWNED)) - if(event.drops.isEmpty()) - event.drops.add(new EntityItem(event.entity.worldObj, event.entity.posX, event.entity.posY, event.entity.posZ, new ItemStack(Items.blaze_powder, 6))); - else for(EntityItem item : event.drops) { - ItemStack stack = item.getEntityItem(); - if(stack.getItem() == Items.blaze_rod) - item.setEntityItemStack(new ItemStack(Items.blaze_powder, stack.stackSize * 10)); - } - } + @Override + @SideOnly(Side.CLIENT) + public void registerBlockIcons(IIconRegister p_149651_1_) { + face = IconHelper.forBlock(p_149651_1_, this); + top = Blocks.pumpkin.getIcon(0, 0); + blockIcon = Blocks.pumpkin.getIcon(2, 0); + } - @Override - public LexiconEntry getEntry(World world, int x, int y, int z, EntityPlayer player, ItemStack lexicon) { - return LexiconData.gardenOfGlass; - } + @SubscribeEvent + public void onDrops(LivingDropsEvent event) { + if (event.entity instanceof EntityBlaze && event.entity.getEntityData().getBoolean(TAG_FEL_SPAWNED)) + if (event.drops.isEmpty()) + event.drops.add(new EntityItem( + event.entity.worldObj, + event.entity.posX, + event.entity.posY, + event.entity.posZ, + new ItemStack(Items.blaze_powder, 6))); + else + for (EntityItem item : event.drops) { + ItemStack stack = item.getEntityItem(); + if (stack.getItem() == Items.blaze_rod) + item.setEntityItemStack(new ItemStack(Items.blaze_powder, stack.stackSize * 10)); + } + } + @Override + public LexiconEntry getEntry(World world, int x, int y, int z, EntityPlayer player, ItemStack lexicon) { + return LexiconData.gardenOfGlass; + } } diff --git a/src/main/java/vazkii/botania/common/block/BlockFloatingSpecialFlower.java b/src/main/java/vazkii/botania/common/block/BlockFloatingSpecialFlower.java index c504304299..6155e0be3b 100644 --- a/src/main/java/vazkii/botania/common/block/BlockFloatingSpecialFlower.java +++ b/src/main/java/vazkii/botania/common/block/BlockFloatingSpecialFlower.java @@ -2,18 +2,18 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Nov 17, 2014, 5:31:53 PM (GMT)] */ package vazkii.botania.common.block; +import cpw.mods.fml.common.registry.GameRegistry; import java.util.ArrayList; import java.util.List; import java.util.Random; - import net.minecraft.client.Minecraft; import net.minecraft.client.gui.ScaledResolution; import net.minecraft.creativetab.CreativeTabs; @@ -41,136 +41,141 @@ import vazkii.botania.common.item.block.ItemBlockFloatingSpecialFlower; import vazkii.botania.common.item.block.ItemBlockSpecialFlower; import vazkii.botania.common.lib.LibBlockNames; -import cpw.mods.fml.common.registry.GameRegistry; -public class BlockFloatingSpecialFlower extends BlockFloatingFlower implements ISpecialFlower, IWandable, ILexiconable, IWandHUD { - - public BlockFloatingSpecialFlower() { - super(LibBlockNames.FLOATING_SPECIAL_FLOWER); - - GameRegistry.addRecipe(new SpecialFloatingFlowerRecipe()); - RecipeSorter.register("botania:floatingSpecialFlower", SpecialFloatingFlowerRecipe.class, Category.SHAPELESS, ""); - } - - @Override - public int getLightValue(IBlockAccess world, int x, int y, int z) { - int currentLight = ((TileSpecialFlower) world.getTileEntity(x, y, z)).getLightValue(); - if(currentLight == -1) - currentLight = originalLight; - return LightHelper.getPackedColor(world.getBlockMetadata(x, y, z), currentLight); - } - - @Override - public boolean hasComparatorInputOverride() { - return true; - } - - @Override - public int getComparatorInputOverride(World world, int x, int y, int z, int side) { - return ((TileSpecialFlower) world.getTileEntity(x, y, z)).getComparatorInputOverride(side); - } - - @Override - public int isProvidingWeakPower(IBlockAccess world, int x, int y, int z, int side) { - return ((TileSpecialFlower) world.getTileEntity(x, y, z)).getPowerLevel(side); - } - - @Override - public int isProvidingStrongPower(IBlockAccess world, int x, int y, int z, int side) { - return isProvidingWeakPower(world, x, y, z, side); - } - - @Override - public boolean canProvidePower() { - return true; - } - - @Override - public void randomDisplayTick(World par1World, int par2, int par3, int par4, Random par5Random) { - // NO-OP - } - - @Override - public void getSubBlocks(Item par1, CreativeTabs par2CreativeTabs, List par3List) { - for(String s : BotaniaAPI.subtilesForCreativeMenu) { - par3List.add(ItemBlockSpecialFlower.ofType(new ItemStack(par1), s)); - if(BotaniaAPI.miniFlowers.containsKey(s)) - par3List.add(ItemBlockSpecialFlower.ofType(new ItemStack(par1), BotaniaAPI.miniFlowers.get(s))); - } - } - - @Override - public ItemStack getPickBlock(MovingObjectPosition target, World world, int x, int y, int z) { - String name = ((TileSpecialFlower) world.getTileEntity(x, y, z)).subTileName; - return ItemBlockSpecialFlower.ofType(new ItemStack(world.getBlock(x, y, z)), name); - } - - @Override - public void onBlockHarvested(World par1World, int par2, int par3, int par4, int par5, EntityPlayer par6EntityPlayer) { - if(!par6EntityPlayer.capabilities.isCreativeMode) { - dropBlockAsItem(par1World, par2, par3, par4, par5, 0); - ((TileSpecialFlower) par1World.getTileEntity(par2, par3, par4)).onBlockHarvested(par1World, par2, par3, par4, par5, par6EntityPlayer); - } - } - - @Override - public ArrayList getDrops(World world, int x, int y, int z, int metadata, int fortune) { - ArrayList list = new ArrayList(); - TileEntity tile = world.getTileEntity(x, y, z); - - if(tile != null) { - String name = ((TileSpecialFlower) tile).subTileName; - list.add(ItemBlockSpecialFlower.ofType(new ItemStack(world.getBlock(x, y, z)), name)); - ((TileSpecialFlower) tile).getDrops(list); - } - - return list; - } - - @Override - public boolean onBlockEventReceived(World par1World, int par2, int par3, int par4, int par5, int par6) { - super.onBlockEventReceived(par1World, par2, par3, par4, par5, par6); - TileEntity tileentity = par1World.getTileEntity(par2, par3, par4); - return tileentity != null ? tileentity.receiveClientEvent(par5, par6) : false; - } - - @Override - public boolean onUsedByWand(EntityPlayer player, ItemStack stack, World world, int x, int y, int z, int side) { - return ((TileSpecialFlower) world.getTileEntity(x, y, z)).onWanded(stack, player); - } - - @Override - public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase entity, ItemStack stack) { - ((TileSpecialFlower) world.getTileEntity(x, y, z)).onBlockPlacedBy(world, x, y, z, entity, stack); - } - - @Override - public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int side, float hitX, float hitY, float hitZ) { - return ((TileSpecialFlower) world.getTileEntity(x, y, z)).onBlockActivated(world, x, y, z, player, side, hitX, hitY, hitZ) || super.onBlockActivated(world, x, y, z, player, side, hitX, hitY, hitZ); - } - - @Override - public void onBlockAdded(World world, int x, int y, int z) { - ((TileSpecialFlower) world.getTileEntity(x, y, z)).onBlockAdded(world, x, y, z); - } - - @Override - public void renderHUD(Minecraft mc, ScaledResolution res, World world, int x, int y, int z) { - ((TileSpecialFlower) world.getTileEntity(x, y, z)).renderHUD(mc, res); - } - - @Override - protected void register(String name) { - GameRegistry.registerBlock(this, ItemBlockFloatingSpecialFlower.class, name); - } - - @Override - public TileEntity createNewTileEntity(World world, int meta) { - return new TileFloatingSpecialFlower(); - } - - @Override - public LexiconEntry getEntry(World world, int x, int y, int z, EntityPlayer player, ItemStack lexicon) { - return ((TileSpecialFlower) world.getTileEntity(x, y, z)).getEntry(); - } +public class BlockFloatingSpecialFlower extends BlockFloatingFlower + implements ISpecialFlower, IWandable, ILexiconable, IWandHUD { + + public BlockFloatingSpecialFlower() { + super(LibBlockNames.FLOATING_SPECIAL_FLOWER); + + GameRegistry.addRecipe(new SpecialFloatingFlowerRecipe()); + RecipeSorter.register( + "botania:floatingSpecialFlower", SpecialFloatingFlowerRecipe.class, Category.SHAPELESS, ""); + } + + @Override + public int getLightValue(IBlockAccess world, int x, int y, int z) { + int currentLight = ((TileSpecialFlower) world.getTileEntity(x, y, z)).getLightValue(); + if (currentLight == -1) currentLight = originalLight; + return LightHelper.getPackedColor(world.getBlockMetadata(x, y, z), currentLight); + } + + @Override + public boolean hasComparatorInputOverride() { + return true; + } + + @Override + public int getComparatorInputOverride(World world, int x, int y, int z, int side) { + return ((TileSpecialFlower) world.getTileEntity(x, y, z)).getComparatorInputOverride(side); + } + + @Override + public int isProvidingWeakPower(IBlockAccess world, int x, int y, int z, int side) { + return ((TileSpecialFlower) world.getTileEntity(x, y, z)).getPowerLevel(side); + } + + @Override + public int isProvidingStrongPower(IBlockAccess world, int x, int y, int z, int side) { + return isProvidingWeakPower(world, x, y, z, side); + } + + @Override + public boolean canProvidePower() { + return true; + } + + @Override + public void randomDisplayTick(World par1World, int par2, int par3, int par4, Random par5Random) { + // NO-OP + } + + @Override + public void getSubBlocks(Item par1, CreativeTabs par2CreativeTabs, List par3List) { + for (String s : BotaniaAPI.subtilesForCreativeMenu) { + par3List.add(ItemBlockSpecialFlower.ofType(new ItemStack(par1), s)); + if (BotaniaAPI.miniFlowers.containsKey(s)) + par3List.add(ItemBlockSpecialFlower.ofType(new ItemStack(par1), BotaniaAPI.miniFlowers.get(s))); + } + } + + @Override + public ItemStack getPickBlock(MovingObjectPosition target, World world, int x, int y, int z) { + String name = ((TileSpecialFlower) world.getTileEntity(x, y, z)).subTileName; + return ItemBlockSpecialFlower.ofType(new ItemStack(world.getBlock(x, y, z)), name); + } + + @Override + public void onBlockHarvested( + World par1World, int par2, int par3, int par4, int par5, EntityPlayer par6EntityPlayer) { + if (!par6EntityPlayer.capabilities.isCreativeMode) { + dropBlockAsItem(par1World, par2, par3, par4, par5, 0); + ((TileSpecialFlower) par1World.getTileEntity(par2, par3, par4)) + .onBlockHarvested(par1World, par2, par3, par4, par5, par6EntityPlayer); + } + } + + @Override + public ArrayList getDrops(World world, int x, int y, int z, int metadata, int fortune) { + ArrayList list = new ArrayList(); + TileEntity tile = world.getTileEntity(x, y, z); + + if (tile != null) { + String name = ((TileSpecialFlower) tile).subTileName; + list.add(ItemBlockSpecialFlower.ofType(new ItemStack(world.getBlock(x, y, z)), name)); + ((TileSpecialFlower) tile).getDrops(list); + } + + return list; + } + + @Override + public boolean onBlockEventReceived(World par1World, int par2, int par3, int par4, int par5, int par6) { + super.onBlockEventReceived(par1World, par2, par3, par4, par5, par6); + TileEntity tileentity = par1World.getTileEntity(par2, par3, par4); + return tileentity != null ? tileentity.receiveClientEvent(par5, par6) : false; + } + + @Override + public boolean onUsedByWand(EntityPlayer player, ItemStack stack, World world, int x, int y, int z, int side) { + return ((TileSpecialFlower) world.getTileEntity(x, y, z)).onWanded(stack, player); + } + + @Override + public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase entity, ItemStack stack) { + ((TileSpecialFlower) world.getTileEntity(x, y, z)).onBlockPlacedBy(world, x, y, z, entity, stack); + } + + @Override + public boolean onBlockActivated( + World world, int x, int y, int z, EntityPlayer player, int side, float hitX, float hitY, float hitZ) { + return ((TileSpecialFlower) world.getTileEntity(x, y, z)) + .onBlockActivated(world, x, y, z, player, side, hitX, hitY, hitZ) + || super.onBlockActivated(world, x, y, z, player, side, hitX, hitY, hitZ); + } + + @Override + public void onBlockAdded(World world, int x, int y, int z) { + ((TileSpecialFlower) world.getTileEntity(x, y, z)).onBlockAdded(world, x, y, z); + } + + @Override + public void renderHUD(Minecraft mc, ScaledResolution res, World world, int x, int y, int z) { + ((TileSpecialFlower) world.getTileEntity(x, y, z)).renderHUD(mc, res); + } + + @Override + protected void register(String name) { + GameRegistry.registerBlock(this, ItemBlockFloatingSpecialFlower.class, name); + } + + @Override + public TileEntity createNewTileEntity(World world, int meta) { + return new TileFloatingSpecialFlower(); + } + + @Override + public LexiconEntry getEntry(World world, int x, int y, int z, EntityPlayer player, ItemStack lexicon) { + return ((TileSpecialFlower) world.getTileEntity(x, y, z)).getEntry(); + } } diff --git a/src/main/java/vazkii/botania/common/block/BlockForestEye.java b/src/main/java/vazkii/botania/common/block/BlockForestEye.java index aa03b96ccf..d7a22739cd 100644 --- a/src/main/java/vazkii/botania/common/block/BlockForestEye.java +++ b/src/main/java/vazkii/botania/common/block/BlockForestEye.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [May 9, 2014, 10:55:17 PM (GMT)] */ package vazkii.botania.common.block; @@ -26,58 +26,56 @@ public class BlockForestEye extends BlockModContainer implements ILexiconable { - IIcon[] icons; + IIcon[] icons; - public BlockForestEye() { - super(Material.iron); - setHardness(5.0F); - setResistance(10.0F); - setStepSound(soundTypeMetal); - setBlockBounds(0.25F, 0.25F, 0.25F, 0.75F, 0.75F, 0.75F); - setBlockName(LibBlockNames.FOREST_EYE); - } + public BlockForestEye() { + super(Material.iron); + setHardness(5.0F); + setResistance(10.0F); + setStepSound(soundTypeMetal); + setBlockBounds(0.25F, 0.25F, 0.25F, 0.75F, 0.75F, 0.75F); + setBlockName(LibBlockNames.FOREST_EYE); + } - @Override - public void registerBlockIcons(IIconRegister par1IconRegister) { - icons = new IIcon[6]; - for(int i = 0; i < icons.length; i++) - icons[i] = IconHelper.forBlock(par1IconRegister, this, i); - } + @Override + public void registerBlockIcons(IIconRegister par1IconRegister) { + icons = new IIcon[6]; + for (int i = 0; i < icons.length; i++) icons[i] = IconHelper.forBlock(par1IconRegister, this, i); + } - @Override - public IIcon getIcon(int par1, int par2) { - return icons[Math.min(icons.length - 1, par1)]; - } + @Override + public IIcon getIcon(int par1, int par2) { + return icons[Math.min(icons.length - 1, par1)]; + } - @Override - public boolean renderAsNormalBlock() { - return false; - } + @Override + public boolean renderAsNormalBlock() { + return false; + } - @Override - public boolean isOpaqueCube() { - return false; - } + @Override + public boolean isOpaqueCube() { + return false; + } - @Override - public boolean hasComparatorInputOverride() { - return true; - } + @Override + public boolean hasComparatorInputOverride() { + return true; + } - @Override - public int getComparatorInputOverride(World par1World, int par2, int par3, int par4, int par5) { - TileForestEye eye = (TileForestEye) par1World.getTileEntity(par2, par3, par4); - return Math.min(15, Math.max(0, eye.entities - 1)); - } + @Override + public int getComparatorInputOverride(World par1World, int par2, int par3, int par4, int par5) { + TileForestEye eye = (TileForestEye) par1World.getTileEntity(par2, par3, par4); + return Math.min(15, Math.max(0, eye.entities - 1)); + } - @Override - public TileEntity createNewTileEntity(World world, int meta) { - return new TileForestEye(); - } - - @Override - public LexiconEntry getEntry(World world, int x, int y, int z, EntityPlayer player, ItemStack lexicon) { - return LexiconData.forestEye; - } + @Override + public TileEntity createNewTileEntity(World world, int meta) { + return new TileForestEye(); + } + @Override + public LexiconEntry getEntry(World world, int x, int y, int z, EntityPlayer player, ItemStack lexicon) { + return LexiconData.forestEye; + } } diff --git a/src/main/java/vazkii/botania/common/block/BlockGaiaHead.java b/src/main/java/vazkii/botania/common/block/BlockGaiaHead.java index 9b49819a9f..82a844a7b8 100644 --- a/src/main/java/vazkii/botania/common/block/BlockGaiaHead.java +++ b/src/main/java/vazkii/botania/common/block/BlockGaiaHead.java @@ -2,17 +2,19 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Sep 23, 2015, 11:44:35 PM (GMT)] */ package vazkii.botania.common.block; +import cpw.mods.fml.common.registry.GameRegistry; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; import java.util.ArrayList; import java.util.Random; - import net.minecraft.block.Block; import net.minecraft.block.BlockSkull; import net.minecraft.client.renderer.texture.IIconRegister; @@ -27,74 +29,71 @@ import vazkii.botania.common.item.ModItems; import vazkii.botania.common.item.block.ItemBlockMod; import vazkii.botania.common.lib.LibBlockNames; -import cpw.mods.fml.common.registry.GameRegistry; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; public class BlockGaiaHead extends BlockSkull { - public BlockGaiaHead() { - setBlockName(LibBlockNames.GAIA_HEAD); - setHardness(1.0F); - } - - @Override - public Block setBlockName(String par1Str) { - GameRegistry.registerBlock(this, ItemBlockMod.class, par1Str); - return super.setBlockName(par1Str); - } - - @Override - @SideOnly(Side.CLIENT) - public Item getItem(World p_149694_1_, int p_149694_2_, int p_149694_3_, int p_149694_4_) { - return ModItems.gaiaHead; - } - - @Override - public void registerBlockIcons(IIconRegister p_149651_1_) { - // NO-OP - } - - @Override - public ArrayList getDrops(World p_149749_1_, int p_149749_2_, int p_149749_3_, int p_149749_4_, int p_149749_6_, int fortune) { - ArrayList ret = new ArrayList(); - - if((p_149749_6_ & 8) == 0) { - ItemStack itemstack = new ItemStack(ModItems.gaiaHead, 1); - TileEntitySkull tileentityskull = (TileEntitySkull)p_149749_1_.getTileEntity(p_149749_2_, p_149749_3_, p_149749_4_); - - if(tileentityskull == null) - return ret; - - ret.add(itemstack); - } - return ret; - } - - @Override - public Item getItemDropped(int p_149650_1_, Random p_149650_2_, int p_149650_3_) { - return ModItems.gaiaHead; - } - - @Override - public int getDamageValue(World p_149643_1_, int p_149643_2_, int p_149643_3_, int p_149643_4_) { - return 0; - } - - @Override - public int damageDropped(int p_149692_1_) { - return 0; - } - - @Override - public TileEntity createNewTileEntity(World p_149915_1_, int p_149915_2_) { - return new TileGaiaHead(); - } - - @Override - @SideOnly(Side.CLIENT) - public IIcon getIcon(int p_149691_1_, int p_149691_2_) { - return Blocks.coal_block.getBlockTextureFromSide(p_149691_1_); - } - + public BlockGaiaHead() { + setBlockName(LibBlockNames.GAIA_HEAD); + setHardness(1.0F); + } + + @Override + public Block setBlockName(String par1Str) { + GameRegistry.registerBlock(this, ItemBlockMod.class, par1Str); + return super.setBlockName(par1Str); + } + + @Override + @SideOnly(Side.CLIENT) + public Item getItem(World p_149694_1_, int p_149694_2_, int p_149694_3_, int p_149694_4_) { + return ModItems.gaiaHead; + } + + @Override + public void registerBlockIcons(IIconRegister p_149651_1_) { + // NO-OP + } + + @Override + public ArrayList getDrops( + World p_149749_1_, int p_149749_2_, int p_149749_3_, int p_149749_4_, int p_149749_6_, int fortune) { + ArrayList ret = new ArrayList(); + + if ((p_149749_6_ & 8) == 0) { + ItemStack itemstack = new ItemStack(ModItems.gaiaHead, 1); + TileEntitySkull tileentityskull = + (TileEntitySkull) p_149749_1_.getTileEntity(p_149749_2_, p_149749_3_, p_149749_4_); + + if (tileentityskull == null) return ret; + + ret.add(itemstack); + } + return ret; + } + + @Override + public Item getItemDropped(int p_149650_1_, Random p_149650_2_, int p_149650_3_) { + return ModItems.gaiaHead; + } + + @Override + public int getDamageValue(World p_149643_1_, int p_149643_2_, int p_149643_3_, int p_149643_4_) { + return 0; + } + + @Override + public int damageDropped(int p_149692_1_) { + return 0; + } + + @Override + public TileEntity createNewTileEntity(World p_149915_1_, int p_149915_2_) { + return new TileGaiaHead(); + } + + @Override + @SideOnly(Side.CLIENT) + public IIcon getIcon(int p_149691_1_, int p_149691_2_) { + return Blocks.coal_block.getBlockTextureFromSide(p_149691_1_); + } } diff --git a/src/main/java/vazkii/botania/common/block/BlockGhostRail.java b/src/main/java/vazkii/botania/common/block/BlockGhostRail.java index 428ec97a5a..ce6f024f6b 100644 --- a/src/main/java/vazkii/botania/common/block/BlockGhostRail.java +++ b/src/main/java/vazkii/botania/common/block/BlockGhostRail.java @@ -2,14 +2,18 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jun 9, 2015, 12:48:18 AM (GMT)] */ package vazkii.botania.common.block; +import cpw.mods.fml.common.eventhandler.SubscribeEvent; +import cpw.mods.fml.common.registry.GameRegistry; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; import net.minecraft.block.Block; import net.minecraft.block.BlockRailBase; import net.minecraft.client.renderer.texture.IIconRegister; @@ -26,68 +30,60 @@ import vazkii.botania.common.item.block.ItemBlockMod; import vazkii.botania.common.lexicon.LexiconData; import vazkii.botania.common.lib.LibBlockNames; -import cpw.mods.fml.common.eventhandler.SubscribeEvent; -import cpw.mods.fml.common.registry.GameRegistry; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; public class BlockGhostRail extends BlockRailBase implements ILexiconable { - private static final String TAG_FLOAT_TICKS = "Botania_FloatTicks"; - - public BlockGhostRail() { - super(true); - setCreativeTab(BotaniaCreativeTab.INSTANCE); - MinecraftForge.EVENT_BUS.register(this); - setBlockName(LibBlockNames.GHOST_RAIL); - } + private static final String TAG_FLOAT_TICKS = "Botania_FloatTicks"; - @Override - public Block setBlockName(String par1Str) { - GameRegistry.registerBlock(this, ItemBlockMod.class, par1Str); - return super.setBlockName(par1Str); - } + public BlockGhostRail() { + super(true); + setCreativeTab(BotaniaCreativeTab.INSTANCE); + MinecraftForge.EVENT_BUS.register(this); + setBlockName(LibBlockNames.GHOST_RAIL); + } - @Override - @SideOnly(Side.CLIENT) - public void registerBlockIcons(IIconRegister par1IconRegister) { - blockIcon = IconHelper.forBlock(par1IconRegister, this); - } + @Override + public Block setBlockName(String par1Str) { + GameRegistry.registerBlock(this, ItemBlockMod.class, par1Str); + return super.setBlockName(par1Str); + } - @SubscribeEvent - public void onMinecartUpdate(MinecartUpdateEvent event) { - int x = MathHelper.floor_double(event.entity.posX); - int y = MathHelper.floor_double(event.entity.posY); - int z = MathHelper.floor_double(event.entity.posZ); - Block block = event.entity.worldObj.getBlock(x, y, z); - boolean air = block.isAir(event.entity.worldObj, x, y, z); - int floatTicks = event.entity.getEntityData().getInteger(TAG_FLOAT_TICKS); + @Override + @SideOnly(Side.CLIENT) + public void registerBlockIcons(IIconRegister par1IconRegister) { + blockIcon = IconHelper.forBlock(par1IconRegister, this); + } - if(block == this) - event.entity.getEntityData().setInteger(TAG_FLOAT_TICKS, 20); - else if(block instanceof BlockRailBase || block == ModBlocks.dreamwood) { - event.entity.getEntityData().setInteger(TAG_FLOAT_TICKS, 0); - if(floatTicks > 0) - event.entity.worldObj.playAuxSFX(2003, x, y, z, 0); - } - floatTicks = event.entity.getEntityData().getInteger(TAG_FLOAT_TICKS); + @SubscribeEvent + public void onMinecartUpdate(MinecartUpdateEvent event) { + int x = MathHelper.floor_double(event.entity.posX); + int y = MathHelper.floor_double(event.entity.posY); + int z = MathHelper.floor_double(event.entity.posZ); + Block block = event.entity.worldObj.getBlock(x, y, z); + boolean air = block.isAir(event.entity.worldObj, x, y, z); + int floatTicks = event.entity.getEntityData().getInteger(TAG_FLOAT_TICKS); - if(floatTicks > 0) { - Block blockBelow = event.entity.worldObj.getBlock(x, y - 1, z); - boolean airBelow = blockBelow.isAir(event.entity.worldObj, x, y - 1, z); - if(air && airBelow || !air && !airBelow) - event.entity.noClip = true; - event.entity.motionY = 0.2; - event.entity.motionX *= 1.4; - event.entity.motionZ *= 1.4; - event.entity.getEntityData().setInteger(TAG_FLOAT_TICKS, floatTicks - 1); - event.entity.worldObj.playAuxSFX(2000, x, y, z, 0); - } else event.entity.noClip = false; - } + if (block == this) event.entity.getEntityData().setInteger(TAG_FLOAT_TICKS, 20); + else if (block instanceof BlockRailBase || block == ModBlocks.dreamwood) { + event.entity.getEntityData().setInteger(TAG_FLOAT_TICKS, 0); + if (floatTicks > 0) event.entity.worldObj.playAuxSFX(2003, x, y, z, 0); + } + floatTicks = event.entity.getEntityData().getInteger(TAG_FLOAT_TICKS); - @Override - public LexiconEntry getEntry(World world, int x, int y, int z, EntityPlayer player, ItemStack lexicon) { - return LexiconData.ghostRail; - } + if (floatTicks > 0) { + Block blockBelow = event.entity.worldObj.getBlock(x, y - 1, z); + boolean airBelow = blockBelow.isAir(event.entity.worldObj, x, y - 1, z); + if (air && airBelow || !air && !airBelow) event.entity.noClip = true; + event.entity.motionY = 0.2; + event.entity.motionX *= 1.4; + event.entity.motionZ *= 1.4; + event.entity.getEntityData().setInteger(TAG_FLOAT_TICKS, floatTicks - 1); + event.entity.worldObj.playAuxSFX(2000, x, y, z, 0); + } else event.entity.noClip = false; + } + @Override + public LexiconEntry getEntry(World world, int x, int y, int z, EntityPlayer player, ItemStack lexicon) { + return LexiconData.ghostRail; + } } diff --git a/src/main/java/vazkii/botania/common/block/BlockHourglass.java b/src/main/java/vazkii/botania/common/block/BlockHourglass.java index 99c51a1d59..d4c16545e1 100644 --- a/src/main/java/vazkii/botania/common/block/BlockHourglass.java +++ b/src/main/java/vazkii/botania/common/block/BlockHourglass.java @@ -2,16 +2,15 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [May 29, 2015, 8:17:08 PM (GMT)] */ package vazkii.botania.common.block; import java.util.Random; - import net.minecraft.block.Block; import net.minecraft.block.material.Material; import net.minecraft.client.Minecraft; @@ -42,166 +41,171 @@ public class BlockHourglass extends BlockModContainer implements IManaTrigger, IWandable, IWandHUD, ILexiconable { - Random random; - - protected BlockHourglass() { - super(Material.iron); - setBlockName(LibBlockNames.HOURGLASS); - setHardness(2.0F); - setStepSound(soundTypeMetal); - - float f = 1F / 16F; - float w = 8F * f; - float d = (1F - w) / 2; - setBlockBounds(d, 0F, d, 1F - d, 1.15F, 1F - d); - - random = new Random(); - } - - @Override - public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int side, float xs, float ys, float zs) { - TileHourglass hourglass = (TileHourglass) world.getTileEntity(x, y, z); - ItemStack hgStack = hourglass.getStackInSlot(0); - ItemStack stack = player.getCurrentEquippedItem(); - if(stack != null && stack.getItem() == ModItems.twigWand) - return false; - - if(hourglass.lock) { - if(!player.worldObj.isRemote) - player.addChatMessage(new ChatComponentTranslation("botaniamisc.hourglassLock")); - return true; - } - - if(hgStack == null && TileHourglass.getStackItemTime(stack) > 0) { - hourglass.setInventorySlotContents(0, stack.copy()); - hourglass.markDirty(); - stack.stackSize = 0; - return true; - } else if(hgStack != null) { - ItemStack copy = hgStack.copy(); - if(!player.inventory.addItemStackToInventory(copy)) - player.dropPlayerItemWithRandomChoice(copy, false); - hourglass.setInventorySlotContents(0, null); - hourglass.markDirty(); - return true; - } - - return false; - } - - @Override - public boolean canProvidePower() { - return true; - } - - @Override - public int isProvidingWeakPower(IBlockAccess world, int x, int y, int z, int side) { - return world.getBlockMetadata(x, y, z) == 0 ? 0 : 15; - } - - @Override - public int tickRate(World world) { - return 4; - } - - @Override - public void updateTick(World world, int x, int y, int z, Random rand) { - world.setBlockMetadataWithNotify(x, y, z, 0, 1 | 2); - } - - @Override - public void breakBlock(World par1World, int par2, int par3, int par4, Block par5, int par6) { - TileSimpleInventory inv = (TileSimpleInventory) par1World.getTileEntity(par2, par3, par4); - - if (inv != null) { - for (int j1 = 0; j1 < inv.getSizeInventory(); ++j1) { - ItemStack itemstack = inv.getStackInSlot(j1); - - if (itemstack != null) { - float f = random.nextFloat() * 0.8F + 0.1F; - float f1 = random.nextFloat() * 0.8F + 0.1F; - EntityItem entityitem; - - for (float f2 = random.nextFloat() * 0.8F + 0.1F; itemstack.stackSize > 0; par1World.spawnEntityInWorld(entityitem)) { - int k1 = random.nextInt(21) + 10; - - if (k1 > itemstack.stackSize) - k1 = itemstack.stackSize; - - itemstack.stackSize -= k1; - entityitem = new EntityItem(par1World, par2 + f, par3 + f1, par4 + f2, new ItemStack(itemstack.getItem(), k1, itemstack.getItemDamage())); - float f3 = 0.05F; - entityitem.motionX = (float)random.nextGaussian() * f3; - entityitem.motionY = (float)random.nextGaussian() * f3 + 0.2F; - entityitem.motionZ = (float)random.nextGaussian() * f3; - - if (itemstack.hasTagCompound()) - entityitem.getEntityItem().setTagCompound((NBTTagCompound)itemstack.getTagCompound().copy()); - } - } - } - - par1World.func_147453_f(par2, par3, par4, par5); - } - - super.breakBlock(par1World, par2, par3, par4, par5, par6); - } - - @Override - public void registerBlockIcons(IIconRegister par1IconRegister) { - // NO-OP - } - - @Override - public IIcon getIcon(int p_149691_1_, int p_149691_2_) { - return ModBlocks.manaGlass.getIcon(0, 0); - } - - @Override - public boolean isOpaqueCube() { - return false; - } - - @Override - public boolean renderAsNormalBlock() { - return false; - } - - @Override - public int getRenderType() { - return LibRenderIDs.idHourglass; - } - - @Override - public TileEntity createNewTileEntity(World world, int meta) { - return new TileHourglass(); - } - - @Override - public void onBurstCollision(IManaBurst burst, World world, int x, int y, int z) { - if(!world.isRemote && !burst.isFake()) { - TileHourglass tile = (TileHourglass) world.getTileEntity(x, y, z); - tile.move = !tile.move; - VanillaPacketDispatcher.dispatchTEToNearbyPlayers(tile); - } - } - - @Override - public boolean onUsedByWand(EntityPlayer player, ItemStack stack, World world, int x, int y, int z, int side) { - TileHourglass tile = (TileHourglass) world.getTileEntity(x, y, z); - tile.lock = !tile.lock; - return false; - } - - @Override - public void renderHUD(Minecraft mc, ScaledResolution res, World world, int x, int y, int z) { - TileHourglass tile = (TileHourglass) world.getTileEntity(x, y, z); - tile.renderHUD(res); - } - - @Override - public LexiconEntry getEntry(World world, int x, int y, int z, EntityPlayer player, ItemStack lexicon) { - return LexiconData.hourglass; - } - + Random random; + + protected BlockHourglass() { + super(Material.iron); + setBlockName(LibBlockNames.HOURGLASS); + setHardness(2.0F); + setStepSound(soundTypeMetal); + + float f = 1F / 16F; + float w = 8F * f; + float d = (1F - w) / 2; + setBlockBounds(d, 0F, d, 1F - d, 1.15F, 1F - d); + + random = new Random(); + } + + @Override + public boolean onBlockActivated( + World world, int x, int y, int z, EntityPlayer player, int side, float xs, float ys, float zs) { + TileHourglass hourglass = (TileHourglass) world.getTileEntity(x, y, z); + ItemStack hgStack = hourglass.getStackInSlot(0); + ItemStack stack = player.getCurrentEquippedItem(); + if (stack != null && stack.getItem() == ModItems.twigWand) return false; + + if (hourglass.lock) { + if (!player.worldObj.isRemote) + player.addChatMessage(new ChatComponentTranslation("botaniamisc.hourglassLock")); + return true; + } + + if (hgStack == null && TileHourglass.getStackItemTime(stack) > 0) { + hourglass.setInventorySlotContents(0, stack.copy()); + hourglass.markDirty(); + stack.stackSize = 0; + return true; + } else if (hgStack != null) { + ItemStack copy = hgStack.copy(); + if (!player.inventory.addItemStackToInventory(copy)) player.dropPlayerItemWithRandomChoice(copy, false); + hourglass.setInventorySlotContents(0, null); + hourglass.markDirty(); + return true; + } + + return false; + } + + @Override + public boolean canProvidePower() { + return true; + } + + @Override + public int isProvidingWeakPower(IBlockAccess world, int x, int y, int z, int side) { + return world.getBlockMetadata(x, y, z) == 0 ? 0 : 15; + } + + @Override + public int tickRate(World world) { + return 4; + } + + @Override + public void updateTick(World world, int x, int y, int z, Random rand) { + world.setBlockMetadataWithNotify(x, y, z, 0, 1 | 2); + } + + @Override + public void breakBlock(World par1World, int par2, int par3, int par4, Block par5, int par6) { + TileSimpleInventory inv = (TileSimpleInventory) par1World.getTileEntity(par2, par3, par4); + + if (inv != null) { + for (int j1 = 0; j1 < inv.getSizeInventory(); ++j1) { + ItemStack itemstack = inv.getStackInSlot(j1); + + if (itemstack != null) { + float f = random.nextFloat() * 0.8F + 0.1F; + float f1 = random.nextFloat() * 0.8F + 0.1F; + EntityItem entityitem; + + for (float f2 = random.nextFloat() * 0.8F + 0.1F; + itemstack.stackSize > 0; + par1World.spawnEntityInWorld(entityitem)) { + int k1 = random.nextInt(21) + 10; + + if (k1 > itemstack.stackSize) k1 = itemstack.stackSize; + + itemstack.stackSize -= k1; + entityitem = new EntityItem( + par1World, + par2 + f, + par3 + f1, + par4 + f2, + new ItemStack(itemstack.getItem(), k1, itemstack.getItemDamage())); + float f3 = 0.05F; + entityitem.motionX = (float) random.nextGaussian() * f3; + entityitem.motionY = (float) random.nextGaussian() * f3 + 0.2F; + entityitem.motionZ = (float) random.nextGaussian() * f3; + + if (itemstack.hasTagCompound()) + entityitem.getEntityItem().setTagCompound((NBTTagCompound) + itemstack.getTagCompound().copy()); + } + } + } + + par1World.func_147453_f(par2, par3, par4, par5); + } + + super.breakBlock(par1World, par2, par3, par4, par5, par6); + } + + @Override + public void registerBlockIcons(IIconRegister par1IconRegister) { + // NO-OP + } + + @Override + public IIcon getIcon(int p_149691_1_, int p_149691_2_) { + return ModBlocks.manaGlass.getIcon(0, 0); + } + + @Override + public boolean isOpaqueCube() { + return false; + } + + @Override + public boolean renderAsNormalBlock() { + return false; + } + + @Override + public int getRenderType() { + return LibRenderIDs.idHourglass; + } + + @Override + public TileEntity createNewTileEntity(World world, int meta) { + return new TileHourglass(); + } + + @Override + public void onBurstCollision(IManaBurst burst, World world, int x, int y, int z) { + if (!world.isRemote && !burst.isFake()) { + TileHourglass tile = (TileHourglass) world.getTileEntity(x, y, z); + tile.move = !tile.move; + VanillaPacketDispatcher.dispatchTEToNearbyPlayers(tile); + } + } + + @Override + public boolean onUsedByWand(EntityPlayer player, ItemStack stack, World world, int x, int y, int z, int side) { + TileHourglass tile = (TileHourglass) world.getTileEntity(x, y, z); + tile.lock = !tile.lock; + return false; + } + + @Override + public void renderHUD(Minecraft mc, ScaledResolution res, World world, int x, int y, int z) { + TileHourglass tile = (TileHourglass) world.getTileEntity(x, y, z); + tile.renderHUD(res); + } + + @Override + public LexiconEntry getEntry(World world, int x, int y, int z, EntityPlayer player, ItemStack lexicon) { + return LexiconData.hourglass; + } } diff --git a/src/main/java/vazkii/botania/common/block/BlockIncensePlate.java b/src/main/java/vazkii/botania/common/block/BlockIncensePlate.java index 1a44465f07..eb471c2dd4 100644 --- a/src/main/java/vazkii/botania/common/block/BlockIncensePlate.java +++ b/src/main/java/vazkii/botania/common/block/BlockIncensePlate.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [May 15, 2015, 4:07:09 PM (GMT)] */ package vazkii.botania.common.block; @@ -34,121 +34,124 @@ public class BlockIncensePlate extends BlockModContainer implements ILexiconable { - private static final int[] META_ROTATIONS = new int[] { 2, 5, 3, 4 }; - - protected BlockIncensePlate() { - super(Material.wood); - setBlockName(LibBlockNames.INCENSE_PLATE); - setHardness(2.0F); - setStepSound(soundTypeWood); - setBlockBounds(true); - } - - @Override - public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int s, float xs, float ys, float zs) { - TileIncensePlate plate = (TileIncensePlate) world.getTileEntity(x, y, z); - ItemStack stack = player.getCurrentEquippedItem(); - ItemStack plateStack = plate.getStackInSlot(0); - boolean did = false; - - if(world.isRemote) - return true; - - if(plateStack == null && plate.isItemValidForSlot(0, stack)) { - plate.setInventorySlotContents(0, stack.copy()); - stack.stackSize--; - did = true; - } else if(plateStack != null && !plate.burning) { - if(stack != null && stack.getItem() == Items.flint_and_steel) { - plate.ignite(); - stack.damageItem(1, player); - did = true; - } else { - ItemStack addStack = plateStack.copy(); - if(!player.inventory.addItemStackToInventory(addStack)) - player.dropPlayerItemWithRandomChoice(addStack, false); - plate.setInventorySlotContents(0, null); - - did = true; - } - } - - if(did) - VanillaPacketDispatcher.dispatchTEToNearbyPlayers(plate); - - return did; - } - - @Override - public void onBlockPlacedBy(World p_149689_1_, int p_149689_2_, int p_149689_3_, int p_149689_4_, EntityLivingBase p_149689_5_, ItemStack p_149689_6_) { - int l = MathHelper.floor_double(p_149689_5_.rotationYaw * 4.0F / 360.0F + 0.5D) & 3; - p_149689_1_.setBlockMetadataWithNotify(p_149689_2_, p_149689_3_, p_149689_4_, META_ROTATIONS[l], 2); - } - - @Override - public boolean hasComparatorInputOverride() { - return true; - } - - @Override - public int getComparatorInputOverride(World world, int x, int y, int z, int side) { - return ((TileIncensePlate) world.getTileEntity(x, y, z)).comparatorOutput; - } - - @Override - public void setBlockBoundsBasedOnState(IBlockAccess w, int x, int y, int z) { - setBlockBounds(w.getBlockMetadata(x, y, z) < 4); - } - - public void setBlockBounds(boolean horiz) { - float f = 1F / 16F; - float w = 12 * f; - float l = 4 * f; - float xs = (1F - w) / 2; - float zs = (1F - l) / 2; - if(horiz) - setBlockBounds(xs, 0F, zs, 1F - xs, f, 1f - zs); - else setBlockBounds(zs, 0F, xs, 1F - zs, f, 1f - xs); - } - - @Override - public boolean rotateBlock(World worldObj, int x, int y, int z, ForgeDirection axis) { - return RotationHelper.rotateVanillaBlock(Blocks.furnace, worldObj, x, y, z, axis); - } - - @Override - public void registerBlockIcons(IIconRegister par1IconRegister) { - // NO-OP - } - - @Override - public IIcon getIcon(int p_149691_1_, int p_149691_2_) { - return ModBlocks.livingwood.getIcon(0, 0); - } - - @Override - public boolean isOpaqueCube() { - return false; - } - - @Override - public boolean renderAsNormalBlock() { - return false; - } - - @Override - public int getRenderType() { - return LibRenderIDs.idIncensePlate; - } - - @Override - public TileEntity createNewTileEntity(World world, int meta) { - return new TileIncensePlate(); - } - - @Override - public LexiconEntry getEntry(World world, int x, int y, int z, EntityPlayer player, ItemStack lexicon) { - return LexiconData.incense; - } - + private static final int[] META_ROTATIONS = new int[] {2, 5, 3, 4}; + + protected BlockIncensePlate() { + super(Material.wood); + setBlockName(LibBlockNames.INCENSE_PLATE); + setHardness(2.0F); + setStepSound(soundTypeWood); + setBlockBounds(true); + } + + @Override + public boolean onBlockActivated( + World world, int x, int y, int z, EntityPlayer player, int s, float xs, float ys, float zs) { + TileIncensePlate plate = (TileIncensePlate) world.getTileEntity(x, y, z); + ItemStack stack = player.getCurrentEquippedItem(); + ItemStack plateStack = plate.getStackInSlot(0); + boolean did = false; + + if (world.isRemote) return true; + + if (plateStack == null && plate.isItemValidForSlot(0, stack)) { + plate.setInventorySlotContents(0, stack.copy()); + stack.stackSize--; + did = true; + } else if (plateStack != null && !plate.burning) { + if (stack != null && stack.getItem() == Items.flint_and_steel) { + plate.ignite(); + stack.damageItem(1, player); + did = true; + } else { + ItemStack addStack = plateStack.copy(); + if (!player.inventory.addItemStackToInventory(addStack)) + player.dropPlayerItemWithRandomChoice(addStack, false); + plate.setInventorySlotContents(0, null); + + did = true; + } + } + + if (did) VanillaPacketDispatcher.dispatchTEToNearbyPlayers(plate); + + return did; + } + + @Override + public void onBlockPlacedBy( + World p_149689_1_, + int p_149689_2_, + int p_149689_3_, + int p_149689_4_, + EntityLivingBase p_149689_5_, + ItemStack p_149689_6_) { + int l = MathHelper.floor_double(p_149689_5_.rotationYaw * 4.0F / 360.0F + 0.5D) & 3; + p_149689_1_.setBlockMetadataWithNotify(p_149689_2_, p_149689_3_, p_149689_4_, META_ROTATIONS[l], 2); + } + + @Override + public boolean hasComparatorInputOverride() { + return true; + } + + @Override + public int getComparatorInputOverride(World world, int x, int y, int z, int side) { + return ((TileIncensePlate) world.getTileEntity(x, y, z)).comparatorOutput; + } + + @Override + public void setBlockBoundsBasedOnState(IBlockAccess w, int x, int y, int z) { + setBlockBounds(w.getBlockMetadata(x, y, z) < 4); + } + + public void setBlockBounds(boolean horiz) { + float f = 1F / 16F; + float w = 12 * f; + float l = 4 * f; + float xs = (1F - w) / 2; + float zs = (1F - l) / 2; + if (horiz) setBlockBounds(xs, 0F, zs, 1F - xs, f, 1f - zs); + else setBlockBounds(zs, 0F, xs, 1F - zs, f, 1f - xs); + } + + @Override + public boolean rotateBlock(World worldObj, int x, int y, int z, ForgeDirection axis) { + return RotationHelper.rotateVanillaBlock(Blocks.furnace, worldObj, x, y, z, axis); + } + + @Override + public void registerBlockIcons(IIconRegister par1IconRegister) { + // NO-OP + } + + @Override + public IIcon getIcon(int p_149691_1_, int p_149691_2_) { + return ModBlocks.livingwood.getIcon(0, 0); + } + + @Override + public boolean isOpaqueCube() { + return false; + } + + @Override + public boolean renderAsNormalBlock() { + return false; + } + + @Override + public int getRenderType() { + return LibRenderIDs.idIncensePlate; + } + + @Override + public TileEntity createNewTileEntity(World world, int meta) { + return new TileIncensePlate(); + } + + @Override + public LexiconEntry getEntry(World world, int x, int y, int z, EntityPlayer player, ItemStack lexicon) { + return LexiconData.incense; + } } diff --git a/src/main/java/vazkii/botania/common/block/BlockLightLauncher.java b/src/main/java/vazkii/botania/common/block/BlockLightLauncher.java index dc0d407fa0..05ddb0d9f9 100644 --- a/src/main/java/vazkii/botania/common/block/BlockLightLauncher.java +++ b/src/main/java/vazkii/botania/common/block/BlockLightLauncher.java @@ -2,17 +2,16 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jul 17, 2015, 4:08:58 PM (GMT)] */ package vazkii.botania.common.block; import java.util.ArrayList; import java.util.List; - import net.minecraft.block.Block; import net.minecraft.block.material.Material; import net.minecraft.entity.Entity; @@ -34,70 +33,68 @@ public class BlockLightLauncher extends BlockMod implements ILexiconable { - public BlockLightLauncher() { - super(Material.wood); - setHardness(2.0F); - setStepSound(soundTypeWood); - setBlockName(LibBlockNames.LIGHT_LAUNCHER); - setBlockBounds(0F, 0F, 0F, 1F, 0.25F, 1F); - } - - @Override - public boolean isOpaqueCube() { - return false; - } + public BlockLightLauncher() { + super(Material.wood); + setHardness(2.0F); + setStepSound(soundTypeWood); + setBlockName(LibBlockNames.LIGHT_LAUNCHER); + setBlockBounds(0F, 0F, 0F, 1F, 0.25F, 1F); + } - @Override - public boolean renderAsNormalBlock() { - return false; - } + @Override + public boolean isOpaqueCube() { + return false; + } - @Override - public boolean getBlocksMovement(IBlockAccess p_149655_1_, int p_149655_2_, int p_149655_3_, int p_149655_4_) { - return false; - } + @Override + public boolean renderAsNormalBlock() { + return false; + } - @Override - public void onNeighborBlockChange(World world, int x, int y, int z, Block block) { - boolean power = world.isBlockIndirectlyGettingPowered(x, y, z) || world.isBlockIndirectlyGettingPowered(x, y + 1, z); - int meta = world.getBlockMetadata(x, y, z); - boolean powered = (meta & 8) != 0; + @Override + public boolean getBlocksMovement(IBlockAccess p_149655_1_, int p_149655_2_, int p_149655_3_, int p_149655_4_) { + return false; + } - if(power && !powered) { - pickUpEntities(world, x, y, z); - world.setBlockMetadataWithNotify(x, y, z, meta | 8, 4); - } else if(!power && powered) - world.setBlockMetadataWithNotify(x, y, z, meta & -9, 4); - } + @Override + public void onNeighborBlockChange(World world, int x, int y, int z, Block block) { + boolean power = + world.isBlockIndirectlyGettingPowered(x, y, z) || world.isBlockIndirectlyGettingPowered(x, y + 1, z); + int meta = world.getBlockMetadata(x, y, z); + boolean powered = (meta & 8) != 0; - public void pickUpEntities(World world, int x, int y, int z) { - List relays = new ArrayList(); - for(ForgeDirection dir : LibMisc.CARDINAL_DIRECTIONS) { - TileEntity tile = world.getTileEntity(x + dir.offsetX, y, z + dir.offsetZ); - if(tile instanceof TileLightRelay) { - TileLightRelay relay = (TileLightRelay) tile; - if(relay.getBinding() != null) - relays.add(relay); - } - } + if (power && !powered) { + pickUpEntities(world, x, y, z); + world.setBlockMetadataWithNotify(x, y, z, meta | 8, 4); + } else if (!power && powered) world.setBlockMetadataWithNotify(x, y, z, meta & -9, 4); + } - if(!relays.isEmpty()) { - AxisAlignedBB aabb = AxisAlignedBB.getBoundingBox(x, y, z, x + 1, y + 1, z + 1); - List entities = world.getEntitiesWithinAABB(EntityLivingBase.class, aabb); - entities.addAll(world.getEntitiesWithinAABB(EntityItem.class, aabb)); + public void pickUpEntities(World world, int x, int y, int z) { + List relays = new ArrayList(); + for (ForgeDirection dir : LibMisc.CARDINAL_DIRECTIONS) { + TileEntity tile = world.getTileEntity(x + dir.offsetX, y, z + dir.offsetZ); + if (tile instanceof TileLightRelay) { + TileLightRelay relay = (TileLightRelay) tile; + if (relay.getBinding() != null) relays.add(relay); + } + } - if(!entities.isEmpty()) { - for(Entity entity : entities) { - TileLightRelay relay = relays.get(world.rand.nextInt(relays.size())); - relay.mountEntity(entity); - } - } - } - } + if (!relays.isEmpty()) { + AxisAlignedBB aabb = AxisAlignedBB.getBoundingBox(x, y, z, x + 1, y + 1, z + 1); + List entities = world.getEntitiesWithinAABB(EntityLivingBase.class, aabb); + entities.addAll(world.getEntitiesWithinAABB(EntityItem.class, aabb)); - @Override - public LexiconEntry getEntry(World world, int x, int y, int z, EntityPlayer player, ItemStack lexicon) { - return LexiconData.luminizerTransport; - } + if (!entities.isEmpty()) { + for (Entity entity : entities) { + TileLightRelay relay = relays.get(world.rand.nextInt(relays.size())); + relay.mountEntity(entity); + } + } + } + } + @Override + public LexiconEntry getEntry(World world, int x, int y, int z, EntityPlayer player, ItemStack lexicon) { + return LexiconData.luminizerTransport; + } } diff --git a/src/main/java/vazkii/botania/common/block/BlockLightRelay.java b/src/main/java/vazkii/botania/common/block/BlockLightRelay.java index 04e0d77c21..ab252016a1 100644 --- a/src/main/java/vazkii/botania/common/block/BlockLightRelay.java +++ b/src/main/java/vazkii/botania/common/block/BlockLightRelay.java @@ -2,17 +2,17 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jul 15, 2015, 8:31:13 PM (GMT)] */ package vazkii.botania.common.block; +import cpw.mods.fml.common.registry.GameRegistry; import java.util.List; import java.util.Random; - import net.minecraft.block.Block; import net.minecraft.block.material.Material; import net.minecraft.client.renderer.texture.IIconRegister; @@ -34,123 +34,122 @@ import vazkii.botania.common.item.block.ItemBlockWithMetadataAndName; import vazkii.botania.common.lexicon.LexiconData; import vazkii.botania.common.lib.LibBlockNames; -import cpw.mods.fml.common.registry.GameRegistry; public class BlockLightRelay extends BlockModContainer implements IWandable, ILexiconable { - public static IIcon invIcon, worldIcon, invIconRed, worldIconRed; - - protected BlockLightRelay() { - super(Material.glass); - float f = 5F / 16F; - setBlockBounds(f, f, f, 1F - f, 1F - f, 1F - f); - setBlockName(LibBlockNames.LIGHT_RELAY); - } - - @Override - public Block setBlockName(String par1Str) { - register(par1Str); - return super.setBlockName(par1Str); - } - - void register(String name) { - GameRegistry.registerBlock(this, ItemBlockWithMetadataAndName.class, name); - } - - @Override - public void getSubBlocks(Item item, CreativeTabs tab, List list) { - for(int i = 0; i < 2; i++) - list.add(new ItemStack(item, 1, i)); - } - - @Override - public int damageDropped(int meta) { - return meta == 0 ? 0 : 1; - } - - @Override - protected boolean shouldRegisterInNameSet() { - return false; - } - - @Override - public boolean getBlocksMovement(IBlockAccess p_149655_1_, int p_149655_2_, int p_149655_3_, int p_149655_4_) { - return false; - } - - @Override - public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int s, float xs, float ys, float zs) { - ((TileLightRelay) world.getTileEntity(x, y, z)).mountEntity(player); - return true; - } - - @Override - public AxisAlignedBB getCollisionBoundingBoxFromPool(World p_149668_1_, int p_149668_2_, int p_149668_3_, int p_149668_4_) { - return null; - } - - @Override - public int tickRate(World p_149738_1_) { - return 2; - } - - @Override - public void updateTick(World world, int x, int y, int z, Random rand) { - world.setBlockMetadataWithNotify(x, y, z, world.getBlockMetadata(x, y, z) & -9, 1 | 2); - } - - @Override - public boolean canProvidePower() { - return true; - } - - @Override - public int isProvidingWeakPower(IBlockAccess world, int x, int y, int z, int s) { - int meta = world.getBlockMetadata(x, y, z); - return (meta & 8) != 0 ? 15 : 0; - } - - @Override - public void registerBlockIcons(IIconRegister par1IconRegister) { - invIcon = IconHelper.forBlock(par1IconRegister, this, 0); - worldIcon = IconHelper.forBlock(par1IconRegister, this, 1); - invIconRed = IconHelper.forBlock(par1IconRegister, this, 2); - worldIconRed = IconHelper.forBlock(par1IconRegister, this, 3); - } - - @Override - public IIcon getIcon(int side, int meta) { - return meta > 0 ? invIconRed : invIcon; - } - - @Override - public boolean renderAsNormalBlock() { - return false; - } - - @Override - public boolean isOpaqueCube() { - return false; - } - - @Override - public int getRenderType() { - return LibRenderIDs.idLightRelay; - } - - @Override - public TileEntity createNewTileEntity(World world, int meta) { - return new TileLightRelay(); - } - - @Override - public boolean onUsedByWand(EntityPlayer player, ItemStack stack, World world, int x, int y, int z, int side) { - return false; - } - - @Override - public LexiconEntry getEntry(World world, int x, int y, int z, EntityPlayer player, ItemStack lexicon) { - return LexiconData.luminizerTransport; - } - + public static IIcon invIcon, worldIcon, invIconRed, worldIconRed; + + protected BlockLightRelay() { + super(Material.glass); + float f = 5F / 16F; + setBlockBounds(f, f, f, 1F - f, 1F - f, 1F - f); + setBlockName(LibBlockNames.LIGHT_RELAY); + } + + @Override + public Block setBlockName(String par1Str) { + register(par1Str); + return super.setBlockName(par1Str); + } + + void register(String name) { + GameRegistry.registerBlock(this, ItemBlockWithMetadataAndName.class, name); + } + + @Override + public void getSubBlocks(Item item, CreativeTabs tab, List list) { + for (int i = 0; i < 2; i++) list.add(new ItemStack(item, 1, i)); + } + + @Override + public int damageDropped(int meta) { + return meta == 0 ? 0 : 1; + } + + @Override + protected boolean shouldRegisterInNameSet() { + return false; + } + + @Override + public boolean getBlocksMovement(IBlockAccess p_149655_1_, int p_149655_2_, int p_149655_3_, int p_149655_4_) { + return false; + } + + @Override + public boolean onBlockActivated( + World world, int x, int y, int z, EntityPlayer player, int s, float xs, float ys, float zs) { + ((TileLightRelay) world.getTileEntity(x, y, z)).mountEntity(player); + return true; + } + + @Override + public AxisAlignedBB getCollisionBoundingBoxFromPool( + World p_149668_1_, int p_149668_2_, int p_149668_3_, int p_149668_4_) { + return null; + } + + @Override + public int tickRate(World p_149738_1_) { + return 2; + } + + @Override + public void updateTick(World world, int x, int y, int z, Random rand) { + world.setBlockMetadataWithNotify(x, y, z, world.getBlockMetadata(x, y, z) & -9, 1 | 2); + } + + @Override + public boolean canProvidePower() { + return true; + } + + @Override + public int isProvidingWeakPower(IBlockAccess world, int x, int y, int z, int s) { + int meta = world.getBlockMetadata(x, y, z); + return (meta & 8) != 0 ? 15 : 0; + } + + @Override + public void registerBlockIcons(IIconRegister par1IconRegister) { + invIcon = IconHelper.forBlock(par1IconRegister, this, 0); + worldIcon = IconHelper.forBlock(par1IconRegister, this, 1); + invIconRed = IconHelper.forBlock(par1IconRegister, this, 2); + worldIconRed = IconHelper.forBlock(par1IconRegister, this, 3); + } + + @Override + public IIcon getIcon(int side, int meta) { + return meta > 0 ? invIconRed : invIcon; + } + + @Override + public boolean renderAsNormalBlock() { + return false; + } + + @Override + public boolean isOpaqueCube() { + return false; + } + + @Override + public int getRenderType() { + return LibRenderIDs.idLightRelay; + } + + @Override + public TileEntity createNewTileEntity(World world, int meta) { + return new TileLightRelay(); + } + + @Override + public boolean onUsedByWand(EntityPlayer player, ItemStack stack, World world, int x, int y, int z, int side) { + return false; + } + + @Override + public LexiconEntry getEntry(World world, int x, int y, int z, EntityPlayer player, ItemStack lexicon) { + return LexiconData.luminizerTransport; + } } diff --git a/src/main/java/vazkii/botania/common/block/BlockLivingrock.java b/src/main/java/vazkii/botania/common/block/BlockLivingrock.java index e0b6e86216..28e8be2091 100644 --- a/src/main/java/vazkii/botania/common/block/BlockLivingrock.java +++ b/src/main/java/vazkii/botania/common/block/BlockLivingrock.java @@ -2,16 +2,16 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jan 25, 2014, 10:03:04 PM (GMT)] */ package vazkii.botania.common.block; +import cpw.mods.fml.common.registry.GameRegistry; import java.util.List; - import net.minecraft.block.Block; import net.minecraft.block.material.Material; import net.minecraft.client.renderer.texture.IIconRegister; @@ -28,65 +28,61 @@ import vazkii.botania.common.item.block.ItemBlockWithMetadataAndName; import vazkii.botania.common.lexicon.LexiconData; import vazkii.botania.common.lib.LibBlockNames; -import cpw.mods.fml.common.registry.GameRegistry; public class BlockLivingrock extends BlockMod implements ILexiconable { - private static final int TYPES = 5; - IIcon[] icons; - - public BlockLivingrock() { - super(Material.rock); - setHardness(2.0F); - setResistance(10.0F); - setStepSound(soundTypeStone); - setBlockName(LibBlockNames.LIVING_ROCK); - } + private static final int TYPES = 5; + IIcon[] icons; - @Override - protected boolean shouldRegisterInNameSet() { - return false; - } + public BlockLivingrock() { + super(Material.rock); + setHardness(2.0F); + setResistance(10.0F); + setStepSound(soundTypeStone); + setBlockName(LibBlockNames.LIVING_ROCK); + } - @Override - public int damageDropped(int par1) { - return par1; - } + @Override + protected boolean shouldRegisterInNameSet() { + return false; + } - @Override - public Block setBlockName(String par1Str) { - GameRegistry.registerBlock(this, ItemBlockWithMetadataAndName.class, par1Str); - return super.setBlockName(par1Str); - } + @Override + public int damageDropped(int par1) { + return par1; + } - @Override - public void getSubBlocks(Item par1, CreativeTabs par2CreativeTabs, List par3List) { - for(int i = 0; i < TYPES; i++) - par3List.add(new ItemStack(par1, 1, i)); - } + @Override + public Block setBlockName(String par1Str) { + GameRegistry.registerBlock(this, ItemBlockWithMetadataAndName.class, par1Str); + return super.setBlockName(par1Str); + } - @Override - public void registerBlockIcons(IIconRegister par1IconRegister) { - icons = new IIcon[TYPES]; - for(int i = 0; i < TYPES; i++) - icons[i] = IconHelper.forBlock(par1IconRegister, this, i); - } + @Override + public void getSubBlocks(Item par1, CreativeTabs par2CreativeTabs, List par3List) { + for (int i = 0; i < TYPES; i++) par3List.add(new ItemStack(par1, 1, i)); + } - @Override - public IIcon getIcon(int par1, int par2) { - return icons[Math.min(TYPES - 1, par2)]; - } + @Override + public void registerBlockIcons(IIconRegister par1IconRegister) { + icons = new IIcon[TYPES]; + for (int i = 0; i < TYPES; i++) icons[i] = IconHelper.forBlock(par1IconRegister, this, i); + } - @Override - public ItemStack getPickBlock(MovingObjectPosition target, World world, int x, int y, int z) { - int meta = world.getBlockMetadata(x, y, z); - return new ItemStack(this, 1, meta); - } + @Override + public IIcon getIcon(int par1, int par2) { + return icons[Math.min(TYPES - 1, par2)]; + } - @Override - public LexiconEntry getEntry(World world, int x, int y, int z, EntityPlayer player, ItemStack lexicon) { - int meta = world.getBlockMetadata(x, y, z); - return meta == 0 ? LexiconData.pureDaisy : LexiconData.decorativeBlocks; - } + @Override + public ItemStack getPickBlock(MovingObjectPosition target, World world, int x, int y, int z) { + int meta = world.getBlockMetadata(x, y, z); + return new ItemStack(this, 1, meta); + } + @Override + public LexiconEntry getEntry(World world, int x, int y, int z, EntityPlayer player, ItemStack lexicon) { + int meta = world.getBlockMetadata(x, y, z); + return meta == 0 ? LexiconData.pureDaisy : LexiconData.decorativeBlocks; + } } diff --git a/src/main/java/vazkii/botania/common/block/BlockLivingwood.java b/src/main/java/vazkii/botania/common/block/BlockLivingwood.java index a9571b6757..740d724af6 100644 --- a/src/main/java/vazkii/botania/common/block/BlockLivingwood.java +++ b/src/main/java/vazkii/botania/common/block/BlockLivingwood.java @@ -2,16 +2,16 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jan 25, 2014, 10:04:25 PM (GMT)] */ package vazkii.botania.common.block; +import cpw.mods.fml.common.registry.GameRegistry; import java.util.List; - import net.minecraft.block.Block; import net.minecraft.block.material.Material; import net.minecraft.client.renderer.texture.IIconRegister; @@ -29,82 +29,78 @@ import vazkii.botania.common.item.block.ItemBlockWithMetadataAndName; import vazkii.botania.common.lexicon.LexiconData; import vazkii.botania.common.lib.LibBlockNames; -import cpw.mods.fml.common.registry.GameRegistry; public class BlockLivingwood extends BlockMod implements ILexiconable { - private static final int TYPES = 6; - IIcon[] icons; - - public BlockLivingwood() { - this(LibBlockNames.LIVING_WOOD); - } - - public BlockLivingwood(String name) { - super(Material.wood); - setHardness(2.0F); - setStepSound(soundTypeWood); - setBlockName(name); - } - - @Override - protected boolean shouldRegisterInNameSet() { - return false; - } - - @Override - public int damageDropped(int par1) { - return par1; - } - - @Override - public Block setBlockName(String par1Str) { - register(par1Str); - return super.setBlockName(par1Str); - } - - void register(String name) { - GameRegistry.registerBlock(this, ItemBlockWithMetadataAndName.class, name); - } - - @Override - public void getSubBlocks(Item par1, CreativeTabs par2CreativeTabs, List par3List) { - for(int i = 0; i < TYPES; i++) - par3List.add(new ItemStack(par1, 1, i)); - } - - @Override - public void registerBlockIcons(IIconRegister par1IconRegister) { - icons = new IIcon[TYPES]; - for(int i = 0; i < TYPES; i++) - icons[i] = IconHelper.forBlock(par1IconRegister, this, i); - } - - @Override - public IIcon getIcon(int par1, int par2) { - return icons[Math.min(TYPES - 1, par2)]; - } - - @Override - public ItemStack getPickBlock(MovingObjectPosition target, World world, int x, int y, int z) { - int meta = world.getBlockMetadata(x, y, z); - return new ItemStack(this, 1, meta); - } - - @Override - public int getLightValue(IBlockAccess world, int x, int y, int z) { - return world.getBlockMetadata(x, y, z) == 5 ? 12 : 0; - } - - @Override - public LexiconEntry getEntry(World world, int x, int y, int z, EntityPlayer player, ItemStack lexicon) { - int meta = world.getBlockMetadata(x, y, z); - return meta == 0 ? LexiconData.pureDaisy : LexiconData.decorativeBlocks; - } - - @Override - public boolean canSustainLeaves(IBlockAccess world, int x, int y, int z) { - return world.getBlockMetadata(x, y, z) == 0; - } - + private static final int TYPES = 6; + IIcon[] icons; + + public BlockLivingwood() { + this(LibBlockNames.LIVING_WOOD); + } + + public BlockLivingwood(String name) { + super(Material.wood); + setHardness(2.0F); + setStepSound(soundTypeWood); + setBlockName(name); + } + + @Override + protected boolean shouldRegisterInNameSet() { + return false; + } + + @Override + public int damageDropped(int par1) { + return par1; + } + + @Override + public Block setBlockName(String par1Str) { + register(par1Str); + return super.setBlockName(par1Str); + } + + void register(String name) { + GameRegistry.registerBlock(this, ItemBlockWithMetadataAndName.class, name); + } + + @Override + public void getSubBlocks(Item par1, CreativeTabs par2CreativeTabs, List par3List) { + for (int i = 0; i < TYPES; i++) par3List.add(new ItemStack(par1, 1, i)); + } + + @Override + public void registerBlockIcons(IIconRegister par1IconRegister) { + icons = new IIcon[TYPES]; + for (int i = 0; i < TYPES; i++) icons[i] = IconHelper.forBlock(par1IconRegister, this, i); + } + + @Override + public IIcon getIcon(int par1, int par2) { + return icons[Math.min(TYPES - 1, par2)]; + } + + @Override + public ItemStack getPickBlock(MovingObjectPosition target, World world, int x, int y, int z) { + int meta = world.getBlockMetadata(x, y, z); + return new ItemStack(this, 1, meta); + } + + @Override + public int getLightValue(IBlockAccess world, int x, int y, int z) { + return world.getBlockMetadata(x, y, z) == 5 ? 12 : 0; + } + + @Override + public LexiconEntry getEntry(World world, int x, int y, int z, EntityPlayer player, ItemStack lexicon) { + int meta = world.getBlockMetadata(x, y, z); + return meta == 0 ? LexiconData.pureDaisy : LexiconData.decorativeBlocks; + } + + @Override + public boolean canSustainLeaves(IBlockAccess world, int x, int y, int z) { + return world.getBlockMetadata(x, y, z) == 0; + } } diff --git a/src/main/java/vazkii/botania/common/block/BlockManaBomb.java b/src/main/java/vazkii/botania/common/block/BlockManaBomb.java index 5154cd7276..536032b65d 100644 --- a/src/main/java/vazkii/botania/common/block/BlockManaBomb.java +++ b/src/main/java/vazkii/botania/common/block/BlockManaBomb.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jul 25, 2015, 12:24:10 AM (GMT)] */ package vazkii.botania.common.block; @@ -28,32 +28,31 @@ public class BlockManaBomb extends BlockMod implements IManaTrigger, ILexiconable, ICraftAchievement { - public BlockManaBomb() { - super(Material.wood); - setHardness(12.0F); - setStepSound(soundTypeWood); - setBlockName(LibBlockNames.MANA_BOMB); - } + public BlockManaBomb() { + super(Material.wood); + setHardness(12.0F); + setStepSound(soundTypeWood); + setBlockName(LibBlockNames.MANA_BOMB); + } - @Override - public void onBurstCollision(IManaBurst burst, World world, int x, int y, int z) { - if(!burst.isFake() && !world.isRemote) { - world.playAuxSFX(2001, x, y, z, getIdFromBlock(this)); - world.setBlockToAir(x, y, z); - EntityManaStorm storm = new EntityManaStorm(world); - storm.setPosition(x + 0.5, y + 0.5, z + 0.5); - world.spawnEntityInWorld(storm); - } - } + @Override + public void onBurstCollision(IManaBurst burst, World world, int x, int y, int z) { + if (!burst.isFake() && !world.isRemote) { + world.playAuxSFX(2001, x, y, z, getIdFromBlock(this)); + world.setBlockToAir(x, y, z); + EntityManaStorm storm = new EntityManaStorm(world); + storm.setPosition(x + 0.5, y + 0.5, z + 0.5); + world.spawnEntityInWorld(storm); + } + } - @Override - public LexiconEntry getEntry(World world, int x, int y, int z, EntityPlayer player, ItemStack lexicon) { - return LexiconData.manaBomb; - } - - @Override - public Achievement getAchievementOnCraft(ItemStack stack, EntityPlayer player, IInventory matrix) { - return ModAchievements.manaBombIgnite; - } + @Override + public LexiconEntry getEntry(World world, int x, int y, int z, EntityPlayer player, ItemStack lexicon) { + return LexiconData.manaBomb; + } + @Override + public Achievement getAchievementOnCraft(ItemStack stack, EntityPlayer player, IInventory matrix) { + return ModAchievements.manaBombIgnite; + } } diff --git a/src/main/java/vazkii/botania/common/block/BlockMod.java b/src/main/java/vazkii/botania/common/block/BlockMod.java index e797d0c8f7..7e26d8ee7e 100644 --- a/src/main/java/vazkii/botania/common/block/BlockMod.java +++ b/src/main/java/vazkii/botania/common/block/BlockMod.java @@ -2,14 +2,17 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jan 14, 2014, 5:31:15 PM (GMT)] */ package vazkii.botania.common.block; +import cpw.mods.fml.common.registry.GameRegistry; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; import net.minecraft.block.Block; import net.minecraft.block.material.Material; import net.minecraft.client.renderer.texture.IIconRegister; @@ -18,46 +21,41 @@ import vazkii.botania.common.core.BotaniaCreativeTab; import vazkii.botania.common.item.block.ItemBlockElven; import vazkii.botania.common.item.block.ItemBlockMod; -import cpw.mods.fml.common.registry.GameRegistry; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; public class BlockMod extends Block { - public int originalLight; - - public BlockMod(Material par2Material) { - super(par2Material); - if(registerInCreative()) - setCreativeTab(BotaniaCreativeTab.INSTANCE); - } - - @Override - public Block setBlockName(String par1Str) { - if(shouldRegisterInNameSet()) - GameRegistry.registerBlock(this, this instanceof IElvenItem ? ItemBlockElven.class : ItemBlockMod.class, par1Str); - return super.setBlockName(par1Str); - } - - protected boolean shouldRegisterInNameSet() { - return true; - } - - @Override - public Block setLightLevel(float p_149715_1_) { - originalLight = (int) (p_149715_1_ * 15); - return super.setLightLevel(p_149715_1_); - } - - @Override - @SideOnly(Side.CLIENT) - public void registerBlockIcons(IIconRegister par1IconRegister) { - blockIcon = IconHelper.forBlock(par1IconRegister, this); - } - - boolean registerInCreative() { - return true; - } - - + public int originalLight; + + public BlockMod(Material par2Material) { + super(par2Material); + if (registerInCreative()) setCreativeTab(BotaniaCreativeTab.INSTANCE); + } + + @Override + public Block setBlockName(String par1Str) { + if (shouldRegisterInNameSet()) + GameRegistry.registerBlock( + this, this instanceof IElvenItem ? ItemBlockElven.class : ItemBlockMod.class, par1Str); + return super.setBlockName(par1Str); + } + + protected boolean shouldRegisterInNameSet() { + return true; + } + + @Override + public Block setLightLevel(float p_149715_1_) { + originalLight = (int) (p_149715_1_ * 15); + return super.setLightLevel(p_149715_1_); + } + + @Override + @SideOnly(Side.CLIENT) + public void registerBlockIcons(IIconRegister par1IconRegister) { + blockIcon = IconHelper.forBlock(par1IconRegister, this); + } + + boolean registerInCreative() { + return true; + } } diff --git a/src/main/java/vazkii/botania/common/block/BlockModContainer.java b/src/main/java/vazkii/botania/common/block/BlockModContainer.java index d1ff8357e7..6de4e257ac 100644 --- a/src/main/java/vazkii/botania/common/block/BlockModContainer.java +++ b/src/main/java/vazkii/botania/common/block/BlockModContainer.java @@ -2,14 +2,17 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jan 14, 2014, 5:32:55 PM (GMT)] */ package vazkii.botania.common.block; +import cpw.mods.fml.common.registry.GameRegistry; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; import net.minecraft.block.Block; import net.minecraft.block.BlockContainer; import net.minecraft.block.material.Material; @@ -19,48 +22,42 @@ import vazkii.botania.client.core.helper.IconHelper; import vazkii.botania.common.core.BotaniaCreativeTab; import vazkii.botania.common.item.block.ItemBlockMod; -import cpw.mods.fml.common.registry.GameRegistry; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; public abstract class BlockModContainer extends BlockContainer { - public int originalLight; - - protected BlockModContainer(Material par2Material) { - super(par2Material); - if(registerInCreative()) - setCreativeTab(BotaniaCreativeTab.INSTANCE); - } - - @Override - public Block setBlockName(String par1Str) { - if(shouldRegisterInNameSet()) - GameRegistry.registerBlock(this, ItemBlockMod.class, par1Str); - return super.setBlockName(par1Str); - } - - protected boolean shouldRegisterInNameSet() { - return true; - } - - @Override - public Block setLightLevel(float p_149715_1_) { - originalLight = (int) (p_149715_1_ * 15); - return super.setLightLevel(p_149715_1_); - } - - @Override - @SideOnly(Side.CLIENT) - public void registerBlockIcons(IIconRegister par1IconRegister) { - blockIcon = IconHelper.forBlock(par1IconRegister, this); - } - - public boolean registerInCreative() { - return true; - } - - @Override - public abstract T createNewTileEntity(World world, int meta); - -} \ No newline at end of file + public int originalLight; + + protected BlockModContainer(Material par2Material) { + super(par2Material); + if (registerInCreative()) setCreativeTab(BotaniaCreativeTab.INSTANCE); + } + + @Override + public Block setBlockName(String par1Str) { + if (shouldRegisterInNameSet()) GameRegistry.registerBlock(this, ItemBlockMod.class, par1Str); + return super.setBlockName(par1Str); + } + + protected boolean shouldRegisterInNameSet() { + return true; + } + + @Override + public Block setLightLevel(float p_149715_1_) { + originalLight = (int) (p_149715_1_ * 15); + return super.setLightLevel(p_149715_1_); + } + + @Override + @SideOnly(Side.CLIENT) + public void registerBlockIcons(IIconRegister par1IconRegister) { + blockIcon = IconHelper.forBlock(par1IconRegister, this); + } + + public boolean registerInCreative() { + return true; + } + + @Override + public abstract T createNewTileEntity(World world, int meta); +} diff --git a/src/main/java/vazkii/botania/common/block/BlockModDoubleFlower.java b/src/main/java/vazkii/botania/common/block/BlockModDoubleFlower.java index bdbe1ae818..32575b2eab 100644 --- a/src/main/java/vazkii/botania/common/block/BlockModDoubleFlower.java +++ b/src/main/java/vazkii/botania/common/block/BlockModDoubleFlower.java @@ -2,18 +2,20 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Mar 22, 2015, 7:46:55 PM (GMT)] */ package vazkii.botania.common.block; +import cpw.mods.fml.common.registry.GameRegistry; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; import java.util.ArrayList; import java.util.List; import java.util.Random; - import net.minecraft.block.Block; import net.minecraft.block.BlockDoublePlant; import net.minecraft.client.renderer.texture.IIconRegister; @@ -41,202 +43,255 @@ import vazkii.botania.common.item.block.ItemBlockWithMetadataAndName; import vazkii.botania.common.lexicon.LexiconData; import vazkii.botania.common.lib.LibBlockNames; -import cpw.mods.fml.common.registry.GameRegistry; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; public class BlockModDoubleFlower extends BlockDoublePlant implements ILexiconable { - private static final int COUNT = 8; - - IIcon[] doublePlantTopIcons, doublePlantBottomIcons; - IIcon[] doublePlantTopIconsAlt, doublePlantBottomIconsAlt; - - final int offset; - - public BlockModDoubleFlower(boolean second) { - offset = second ? 8 : 0; - setBlockName(LibBlockNames.DOUBLE_FLOWER + (second ? 2 : 1)); - setHardness(0F); - setStepSound(soundTypeGrass); - setTickRandomly(false); - setCreativeTab(BotaniaCreativeTab.INSTANCE); - } - - @Override - public Block setBlockName(String par1Str) { - if(!par1Str.equals("doublePlant")) - GameRegistry.registerBlock(this, ItemBlockWithMetadataAndName.class, par1Str); - return super.setBlockName(par1Str); - } - - @Override - public Item getItemDropped(int p_149650_1_, Random p_149650_2_, int p_149650_3_) { - return null; - } - - @Override - public int damageDropped(int p_149692_1_) { - return p_149692_1_ & 7; - } - - @Override - @SideOnly(Side.CLIENT) - public IIcon func_149888_a(boolean top, int index) { - return (ConfigHandler.altFlowerTextures ? top ? doublePlantTopIconsAlt : doublePlantBottomIconsAlt : top ? doublePlantTopIcons : doublePlantBottomIcons)[index & 7]; - } - - @Override - public void func_149889_c(World p_149889_1_, int p_149889_2_, int p_149889_3_, int p_149889_4_, int p_149889_5_, int p_149889_6_) { - p_149889_1_.setBlock(p_149889_2_, p_149889_3_, p_149889_4_, this, p_149889_5_, p_149889_6_); - p_149889_1_.setBlock(p_149889_2_, p_149889_3_ + 1, p_149889_4_, this, p_149889_5_ | 8, p_149889_6_); - } - - @Override - public void onBlockPlacedBy(World p_149689_1_, int p_149689_2_, int p_149689_3_, int p_149689_4_, EntityLivingBase p_149689_5_, ItemStack p_149689_6_) { - p_149689_1_.setBlock(p_149689_2_, p_149689_3_ + 1, p_149689_4_, this, p_149689_6_.getItemDamage() | 8, 2); - } - - @Override - public boolean func_149851_a(World world, int x, int y, int z, boolean fuckifiknow) { - return false; - } - - @Override - public void harvestBlock(World p_149636_1_, EntityPlayer p_149636_2_, int p_149636_3_, int p_149636_4_, int p_149636_5_, int p_149636_6_) { - if(p_149636_1_.isRemote || p_149636_2_.getCurrentEquippedItem() == null || p_149636_2_.getCurrentEquippedItem().getItem() != Items.shears || func_149887_c(p_149636_6_)) - harvestBlockCopy(p_149636_1_, p_149636_2_, p_149636_3_, p_149636_4_, p_149636_5_, p_149636_6_); - } - - // This is how I get around encapsulation - public void harvestBlockCopy(World p_149636_1_, EntityPlayer p_149636_2_, int p_149636_3_, int p_149636_4_, int p_149636_5_, int p_149636_6_) { - p_149636_2_.addStat(StatList.mineBlockStatArray[getIdFromBlock(this)], 1); - p_149636_2_.addExhaustion(0.025F); - - if(this.canSilkHarvest(p_149636_1_, p_149636_2_, p_149636_3_, p_149636_4_, p_149636_5_, p_149636_6_) && EnchantmentHelper.getSilkTouchModifier(p_149636_2_)) { - ArrayList items = new ArrayList(); - ItemStack itemstack = createStackedBlock(p_149636_6_); - - if(itemstack != null) - items.add(itemstack); - - ForgeEventFactory.fireBlockHarvesting(items, p_149636_1_, this, p_149636_3_, p_149636_4_, p_149636_5_, p_149636_6_, 0, 1.0f, true, p_149636_2_); - for(ItemStack is : items) - this.dropBlockAsItem(p_149636_1_, p_149636_3_, p_149636_4_, p_149636_5_, is); - } else { - harvesters.set(p_149636_2_); - int i1 = EnchantmentHelper.getFortuneModifier(p_149636_2_); - this.dropBlockAsItem(p_149636_1_, p_149636_3_, p_149636_4_, p_149636_5_, p_149636_6_, i1); - harvesters.set(null); - } - } - - @Override - public void onBlockHarvested(World p_149681_1_, int p_149681_2_, int p_149681_3_, int p_149681_4_, int p_149681_5_, EntityPlayer p_149681_6_) { - if(func_149887_c(p_149681_5_)) { - if(p_149681_1_.getBlock(p_149681_2_, p_149681_3_ - 1, p_149681_4_) == this) { - if(!p_149681_6_.capabilities.isCreativeMode) { - int i1 = p_149681_1_.getBlockMetadata(p_149681_2_, p_149681_3_ - 1, p_149681_4_); - int j1 = func_149890_d(i1); - - if(j1 != 3 && j1 != 2); - //p_149681_1_.func_147480_a(p_149681_2_, p_149681_3_ - 1, p_149681_4_, true); - else { - /*if (!p_149681_1_.isRemote && p_149681_6_.getCurrentEquippedItem() != null && p_149681_6_.getCurrentEquippedItem().getItem() == Items.shears) + private static final int COUNT = 8; + + IIcon[] doublePlantTopIcons, doublePlantBottomIcons; + IIcon[] doublePlantTopIconsAlt, doublePlantBottomIconsAlt; + + final int offset; + + public BlockModDoubleFlower(boolean second) { + offset = second ? 8 : 0; + setBlockName(LibBlockNames.DOUBLE_FLOWER + (second ? 2 : 1)); + setHardness(0F); + setStepSound(soundTypeGrass); + setTickRandomly(false); + setCreativeTab(BotaniaCreativeTab.INSTANCE); + } + + @Override + public Block setBlockName(String par1Str) { + if (!par1Str.equals("doublePlant")) + GameRegistry.registerBlock(this, ItemBlockWithMetadataAndName.class, par1Str); + return super.setBlockName(par1Str); + } + + @Override + public Item getItemDropped(int p_149650_1_, Random p_149650_2_, int p_149650_3_) { + return null; + } + + @Override + public int damageDropped(int p_149692_1_) { + return p_149692_1_ & 7; + } + + @Override + @SideOnly(Side.CLIENT) + public IIcon func_149888_a(boolean top, int index) { + return (ConfigHandler.altFlowerTextures + ? top ? doublePlantTopIconsAlt : doublePlantBottomIconsAlt + : top ? doublePlantTopIcons : doublePlantBottomIcons) + [index & 7]; + } + + @Override + public void func_149889_c( + World p_149889_1_, int p_149889_2_, int p_149889_3_, int p_149889_4_, int p_149889_5_, int p_149889_6_) { + p_149889_1_.setBlock(p_149889_2_, p_149889_3_, p_149889_4_, this, p_149889_5_, p_149889_6_); + p_149889_1_.setBlock(p_149889_2_, p_149889_3_ + 1, p_149889_4_, this, p_149889_5_ | 8, p_149889_6_); + } + + @Override + public void onBlockPlacedBy( + World p_149689_1_, + int p_149689_2_, + int p_149689_3_, + int p_149689_4_, + EntityLivingBase p_149689_5_, + ItemStack p_149689_6_) { + p_149689_1_.setBlock(p_149689_2_, p_149689_3_ + 1, p_149689_4_, this, p_149689_6_.getItemDamage() | 8, 2); + } + + @Override + public boolean func_149851_a(World world, int x, int y, int z, boolean fuckifiknow) { + return false; + } + + @Override + public void harvestBlock( + World p_149636_1_, + EntityPlayer p_149636_2_, + int p_149636_3_, + int p_149636_4_, + int p_149636_5_, + int p_149636_6_) { + if (p_149636_1_.isRemote + || p_149636_2_.getCurrentEquippedItem() == null + || p_149636_2_.getCurrentEquippedItem().getItem() != Items.shears + || func_149887_c(p_149636_6_)) + harvestBlockCopy(p_149636_1_, p_149636_2_, p_149636_3_, p_149636_4_, p_149636_5_, p_149636_6_); + } + + // This is how I get around encapsulation + public void harvestBlockCopy( + World p_149636_1_, + EntityPlayer p_149636_2_, + int p_149636_3_, + int p_149636_4_, + int p_149636_5_, + int p_149636_6_) { + p_149636_2_.addStat(StatList.mineBlockStatArray[getIdFromBlock(this)], 1); + p_149636_2_.addExhaustion(0.025F); + + if (this.canSilkHarvest(p_149636_1_, p_149636_2_, p_149636_3_, p_149636_4_, p_149636_5_, p_149636_6_) + && EnchantmentHelper.getSilkTouchModifier(p_149636_2_)) { + ArrayList items = new ArrayList(); + ItemStack itemstack = createStackedBlock(p_149636_6_); + + if (itemstack != null) items.add(itemstack); + + ForgeEventFactory.fireBlockHarvesting( + items, + p_149636_1_, + this, + p_149636_3_, + p_149636_4_, + p_149636_5_, + p_149636_6_, + 0, + 1.0f, + true, + p_149636_2_); + for (ItemStack is : items) this.dropBlockAsItem(p_149636_1_, p_149636_3_, p_149636_4_, p_149636_5_, is); + } else { + harvesters.set(p_149636_2_); + int i1 = EnchantmentHelper.getFortuneModifier(p_149636_2_); + this.dropBlockAsItem(p_149636_1_, p_149636_3_, p_149636_4_, p_149636_5_, p_149636_6_, i1); + harvesters.set(null); + } + } + + @Override + public void onBlockHarvested( + World p_149681_1_, + int p_149681_2_, + int p_149681_3_, + int p_149681_4_, + int p_149681_5_, + EntityPlayer p_149681_6_) { + if (func_149887_c(p_149681_5_)) { + if (p_149681_1_.getBlock(p_149681_2_, p_149681_3_ - 1, p_149681_4_) == this) { + if (!p_149681_6_.capabilities.isCreativeMode) { + int i1 = p_149681_1_.getBlockMetadata(p_149681_2_, p_149681_3_ - 1, p_149681_4_); + int j1 = func_149890_d(i1); + + if (j1 != 3 && j1 != 2) + ; + // p_149681_1_.func_147480_a(p_149681_2_, p_149681_3_ - 1, p_149681_4_, true); + else { + /*if (!p_149681_1_.isRemote && p_149681_6_.getCurrentEquippedItem() != null && p_149681_6_.getCurrentEquippedItem().getItem() == Items.shears) { this.func_149886_b(p_149681_1_, p_149681_2_, p_149681_3_, p_149681_4_, i1, p_149681_6_); }*/ - p_149681_1_.setBlockToAir(p_149681_2_, p_149681_3_ - 1, p_149681_4_); - } - } else p_149681_1_.setBlockToAir(p_149681_2_, p_149681_3_ - 1, p_149681_4_); - } - } else if(p_149681_6_.capabilities.isCreativeMode && p_149681_1_.getBlock(p_149681_2_, p_149681_3_ + 1, p_149681_4_) == this) - p_149681_1_.setBlock(p_149681_2_, p_149681_3_ + 1, p_149681_4_, Blocks.air, 0, 2); - - //super.onBlockHarvested(p_149681_1_, p_149681_2_, p_149681_3_, p_149681_4_, p_149681_5_, p_149681_6_); - } - - @Override - public boolean isShearable(ItemStack item, IBlockAccess world, int x, int y, int z) { - return true; - } - - @Override - public ArrayList onSheared(ItemStack item, IBlockAccess world, int x, int y, int z, int fortune) { - ArrayList ret = new ArrayList(); - ret.add(new ItemStack(this, 1, world.getBlockMetadata(x, y, z) & 7)); - return ret; - } - - @Override - public ArrayList getDrops(World world, int x, int y, int z, int meta, int fortune) { - return new ArrayList(); - } - - @Override - public IIcon getIcon(int p_149691_1_, int p_149691_2_) { - boolean top = func_149887_c(p_149691_2_); - return (ConfigHandler.altFlowerTextures ? top ? doublePlantTopIconsAlt : doublePlantBottomIconsAlt : top ? doublePlantTopIcons : doublePlantBottomIcons)[p_149691_2_ & 7]; - } - - @Override - public IIcon getIcon(IBlockAccess world, int x, int y, int z, int side) { - int meta = world.getBlockMetadata(x, y, z); - boolean top = func_149887_c(meta); - if(top) - meta = world.getBlockMetadata(x, y - 1, z); - - return (ConfigHandler.altFlowerTextures ? top ? doublePlantBottomIconsAlt : doublePlantTopIconsAlt : top ? doublePlantBottomIcons : doublePlantTopIcons)[meta & 7]; - } - - @Override - public void registerBlockIcons(IIconRegister register) { - doublePlantTopIcons = new IIcon[COUNT]; - doublePlantBottomIcons = new IIcon[COUNT]; - doublePlantTopIconsAlt = new IIcon[COUNT]; - doublePlantBottomIconsAlt = new IIcon[COUNT]; - for(int i = 0; i < COUNT; i++) { - int off = offset(i); - doublePlantTopIcons[i] = IconHelper.forName(register, "flower" + off + "Tall0"); - doublePlantBottomIcons[i] = IconHelper.forName(register, "flower" + off + "Tall1"); - doublePlantTopIconsAlt[i] = IconHelper.forName(register, "flower" + off + "Tall0", BlockModFlower.ALT_DIR); - doublePlantBottomIconsAlt[i] = IconHelper.forName(register, "flower" + off + "Tall1", BlockModFlower.ALT_DIR); - } - } - - @Override - public int colorMultiplier(IBlockAccess blockAccess, int x, int y, int z) { - return 16777215; - } - - @Override - public void getSubBlocks(Item p_149666_1_, CreativeTabs p_149666_2_, List p_149666_3_) { - for(int i = 0; i < COUNT; ++i) - p_149666_3_.add(new ItemStack(p_149666_1_, 1, i)); - } - - @Override - public int getRenderType() { - return LibRenderIDs.idDoubleFlower; - } - - @Override - public void randomDisplayTick(World par1World, int par2, int par3, int par4, Random par5Random) { - int meta = par1World.getBlockMetadata(par2, par3, par4); - float[] color = EntitySheep.fleeceColorTable[offset(meta & 7)]; - - if(par5Random.nextDouble() < ConfigHandler.flowerParticleFrequency) - Botania.proxy.sparkleFX(par1World, par2 + 0.3 + par5Random.nextFloat() * 0.5, par3 + 0.5 + par5Random.nextFloat() * 0.5, par4 + 0.3 + par5Random.nextFloat() * 0.5, color[0], color[1], color[2], par5Random.nextFloat(), 5); - } - - @Override - public LexiconEntry getEntry(World world, int x, int y, int z, EntityPlayer player, ItemStack lexicon) { - return LexiconData.flowers; - } - - int offset(int meta) { - return meta + offset; - } - + p_149681_1_.setBlockToAir(p_149681_2_, p_149681_3_ - 1, p_149681_4_); + } + } else p_149681_1_.setBlockToAir(p_149681_2_, p_149681_3_ - 1, p_149681_4_); + } + } else if (p_149681_6_.capabilities.isCreativeMode + && p_149681_1_.getBlock(p_149681_2_, p_149681_3_ + 1, p_149681_4_) == this) + p_149681_1_.setBlock(p_149681_2_, p_149681_3_ + 1, p_149681_4_, Blocks.air, 0, 2); + + // super.onBlockHarvested(p_149681_1_, p_149681_2_, p_149681_3_, p_149681_4_, p_149681_5_, p_149681_6_); + } + + @Override + public boolean isShearable(ItemStack item, IBlockAccess world, int x, int y, int z) { + return true; + } + + @Override + public ArrayList onSheared(ItemStack item, IBlockAccess world, int x, int y, int z, int fortune) { + ArrayList ret = new ArrayList(); + ret.add(new ItemStack(this, 1, world.getBlockMetadata(x, y, z) & 7)); + return ret; + } + + @Override + public ArrayList getDrops(World world, int x, int y, int z, int meta, int fortune) { + return new ArrayList(); + } + + @Override + public IIcon getIcon(int p_149691_1_, int p_149691_2_) { + boolean top = func_149887_c(p_149691_2_); + return (ConfigHandler.altFlowerTextures + ? top ? doublePlantTopIconsAlt : doublePlantBottomIconsAlt + : top ? doublePlantTopIcons : doublePlantBottomIcons) + [p_149691_2_ & 7]; + } + + @Override + public IIcon getIcon(IBlockAccess world, int x, int y, int z, int side) { + int meta = world.getBlockMetadata(x, y, z); + boolean top = func_149887_c(meta); + if (top) meta = world.getBlockMetadata(x, y - 1, z); + + return (ConfigHandler.altFlowerTextures + ? top ? doublePlantBottomIconsAlt : doublePlantTopIconsAlt + : top ? doublePlantBottomIcons : doublePlantTopIcons) + [meta & 7]; + } + + @Override + public void registerBlockIcons(IIconRegister register) { + doublePlantTopIcons = new IIcon[COUNT]; + doublePlantBottomIcons = new IIcon[COUNT]; + doublePlantTopIconsAlt = new IIcon[COUNT]; + doublePlantBottomIconsAlt = new IIcon[COUNT]; + for (int i = 0; i < COUNT; i++) { + int off = offset(i); + doublePlantTopIcons[i] = IconHelper.forName(register, "flower" + off + "Tall0"); + doublePlantBottomIcons[i] = IconHelper.forName(register, "flower" + off + "Tall1"); + doublePlantTopIconsAlt[i] = IconHelper.forName(register, "flower" + off + "Tall0", BlockModFlower.ALT_DIR); + doublePlantBottomIconsAlt[i] = + IconHelper.forName(register, "flower" + off + "Tall1", BlockModFlower.ALT_DIR); + } + } + + @Override + public int colorMultiplier(IBlockAccess blockAccess, int x, int y, int z) { + return 16777215; + } + + @Override + public void getSubBlocks(Item p_149666_1_, CreativeTabs p_149666_2_, List p_149666_3_) { + for (int i = 0; i < COUNT; ++i) p_149666_3_.add(new ItemStack(p_149666_1_, 1, i)); + } + + @Override + public int getRenderType() { + return LibRenderIDs.idDoubleFlower; + } + + @Override + public void randomDisplayTick(World par1World, int par2, int par3, int par4, Random par5Random) { + int meta = par1World.getBlockMetadata(par2, par3, par4); + float[] color = EntitySheep.fleeceColorTable[offset(meta & 7)]; + + if (par5Random.nextDouble() < ConfigHandler.flowerParticleFrequency) + Botania.proxy.sparkleFX( + par1World, + par2 + 0.3 + par5Random.nextFloat() * 0.5, + par3 + 0.5 + par5Random.nextFloat() * 0.5, + par4 + 0.3 + par5Random.nextFloat() * 0.5, + color[0], + color[1], + color[2], + par5Random.nextFloat(), + 5); + } + + @Override + public LexiconEntry getEntry(World world, int x, int y, int z, EntityPlayer player, ItemStack lexicon) { + return LexiconData.flowers; + } + + int offset(int meta) { + return meta + offset; + } } diff --git a/src/main/java/vazkii/botania/common/block/BlockModFlower.java b/src/main/java/vazkii/botania/common/block/BlockModFlower.java index 084e217c74..2f3794d85e 100644 --- a/src/main/java/vazkii/botania/common/block/BlockModFlower.java +++ b/src/main/java/vazkii/botania/common/block/BlockModFlower.java @@ -2,17 +2,19 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jan 16, 2014, 5:50:31 PM (GMT)] */ package vazkii.botania.common.block; +import cpw.mods.fml.common.registry.GameRegistry; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; import java.util.List; import java.util.Random; - import net.minecraft.block.Block; import net.minecraft.block.BlockFlower; import net.minecraft.block.IGrowable; @@ -38,122 +40,126 @@ import vazkii.botania.common.item.block.ItemBlockWithMetadataAndName; import vazkii.botania.common.lexicon.LexiconData; import vazkii.botania.common.lib.LibBlockNames; -import cpw.mods.fml.common.registry.GameRegistry; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; public class BlockModFlower extends BlockFlower implements ILexiconable, IPickupAchievement, IGrowable { - public static IIcon[] icons; - public static IIcon[] iconsAlt; - - public int originalLight; - - public static final String ALT_DIR = "alt"; - - protected BlockModFlower() { - this(LibBlockNames.FLOWER); - } - - protected BlockModFlower(String name) { - super(0); - setBlockName(name); - setHardness(0F); - setStepSound(soundTypeGrass); - setBlockBounds(0.3F, 0.0F, 0.3F, 0.8F, 1, 0.8F); - setTickRandomly(false); - setCreativeTab(registerInCreative() ? BotaniaCreativeTab.INSTANCE : null); - } - - public boolean registerInCreative() { - return true; - } - - @Override - public void getSubBlocks(Item par1, CreativeTabs par2CreativeTabs, List par3List) { - for(int i = 0; i < 16; i++) - par3List.add(new ItemStack(par1, 1, i)); - } - - @Override - public Block setBlockName(String par1Str) { - GameRegistry.registerBlock(this, ItemBlockWithMetadataAndName.class, par1Str); - return super.setBlockName(par1Str); - } - - @Override - @SideOnly(Side.CLIENT) - public void registerBlockIcons(IIconRegister par1IconRegister) { - icons = new IIcon[17]; - iconsAlt = new IIcon[17]; - - for(int i = 0; i < icons.length; i++) { - icons[i] = IconHelper.forBlock(par1IconRegister, this, i); - iconsAlt[i] = IconHelper.forBlock(par1IconRegister, this, i, ALT_DIR); - } - } - - @Override - public Block setLightLevel(float p_149715_1_) { - originalLight = (int) (p_149715_1_ * 15); - return super.setLightLevel(p_149715_1_); - } - - @Override - public IIcon getIcon(int par1, int par2) { - return (ConfigHandler.altFlowerTextures ? iconsAlt : icons)[Math.min(icons.length - 1, par2)]; - } - - @Override - public int getRenderType() { - return LibRenderIDs.idSpecialFlower; - } - - @Override - public int damageDropped(int par1) { - return par1; - } - - @Override - public void randomDisplayTick(World par1World, int par2, int par3, int par4, Random par5Random) { - int meta = par1World.getBlockMetadata(par2, par3, par4); - float[] color = EntitySheep.fleeceColorTable[meta]; - - if(par5Random.nextDouble() < ConfigHandler.flowerParticleFrequency) - Botania.proxy.sparkleFX(par1World, par2 + 0.3 + par5Random.nextFloat() * 0.5, par3 + 0.5 + par5Random.nextFloat() * 0.5, par4 + 0.3 + par5Random.nextFloat() * 0.5, color[0], color[1], color[2], par5Random.nextFloat(), 5); - } - - @Override - public LexiconEntry getEntry(World world, int x, int y, int z, EntityPlayer player, ItemStack lexicon) { - return LexiconData.flowers; - } - - @Override - public Achievement getAchievementOnPickup(ItemStack stack, EntityPlayer player, EntityItem item) { - return ModAchievements.flowerPickup; - } - - @Override - public boolean func_149851_a(World world, int x, int y, int z, boolean fuckifiknow) { - return world.isAirBlock(x, y + 1, z); - } - - @Override - public boolean func_149852_a(World world, Random rand, int x, int y, int z) { - return func_149851_a(world, x, y, z, false); - } - - @Override - public void func_149853_b(World world, Random rand, int x, int y, int z) { - int meta = world.getBlockMetadata(x, y, z); - placeDoubleFlower(world, x, y, z, meta, 1 | 2); - } - - public static void placeDoubleFlower(World world, int x, int y, int z, int meta, int flags) { - Block flower = meta >= 8 ? ModBlocks.doubleFlower2 : ModBlocks.doubleFlower1; - int placeMeta = meta & 7; - world.setBlock(x, y, z, flower, placeMeta, flags); - world.setBlock(x, y + 1, z, flower, placeMeta | 8, flags); - } - + public static IIcon[] icons; + public static IIcon[] iconsAlt; + + public int originalLight; + + public static final String ALT_DIR = "alt"; + + protected BlockModFlower() { + this(LibBlockNames.FLOWER); + } + + protected BlockModFlower(String name) { + super(0); + setBlockName(name); + setHardness(0F); + setStepSound(soundTypeGrass); + setBlockBounds(0.3F, 0.0F, 0.3F, 0.8F, 1, 0.8F); + setTickRandomly(false); + setCreativeTab(registerInCreative() ? BotaniaCreativeTab.INSTANCE : null); + } + + public boolean registerInCreative() { + return true; + } + + @Override + public void getSubBlocks(Item par1, CreativeTabs par2CreativeTabs, List par3List) { + for (int i = 0; i < 16; i++) par3List.add(new ItemStack(par1, 1, i)); + } + + @Override + public Block setBlockName(String par1Str) { + GameRegistry.registerBlock(this, ItemBlockWithMetadataAndName.class, par1Str); + return super.setBlockName(par1Str); + } + + @Override + @SideOnly(Side.CLIENT) + public void registerBlockIcons(IIconRegister par1IconRegister) { + icons = new IIcon[17]; + iconsAlt = new IIcon[17]; + + for (int i = 0; i < icons.length; i++) { + icons[i] = IconHelper.forBlock(par1IconRegister, this, i); + iconsAlt[i] = IconHelper.forBlock(par1IconRegister, this, i, ALT_DIR); + } + } + + @Override + public Block setLightLevel(float p_149715_1_) { + originalLight = (int) (p_149715_1_ * 15); + return super.setLightLevel(p_149715_1_); + } + + @Override + public IIcon getIcon(int par1, int par2) { + return (ConfigHandler.altFlowerTextures ? iconsAlt : icons)[Math.min(icons.length - 1, par2)]; + } + + @Override + public int getRenderType() { + return LibRenderIDs.idSpecialFlower; + } + + @Override + public int damageDropped(int par1) { + return par1; + } + + @Override + public void randomDisplayTick(World par1World, int par2, int par3, int par4, Random par5Random) { + int meta = par1World.getBlockMetadata(par2, par3, par4); + float[] color = EntitySheep.fleeceColorTable[meta]; + + if (par5Random.nextDouble() < ConfigHandler.flowerParticleFrequency) + Botania.proxy.sparkleFX( + par1World, + par2 + 0.3 + par5Random.nextFloat() * 0.5, + par3 + 0.5 + par5Random.nextFloat() * 0.5, + par4 + 0.3 + par5Random.nextFloat() * 0.5, + color[0], + color[1], + color[2], + par5Random.nextFloat(), + 5); + } + + @Override + public LexiconEntry getEntry(World world, int x, int y, int z, EntityPlayer player, ItemStack lexicon) { + return LexiconData.flowers; + } + + @Override + public Achievement getAchievementOnPickup(ItemStack stack, EntityPlayer player, EntityItem item) { + return ModAchievements.flowerPickup; + } + + @Override + public boolean func_149851_a(World world, int x, int y, int z, boolean fuckifiknow) { + return world.isAirBlock(x, y + 1, z); + } + + @Override + public boolean func_149852_a(World world, Random rand, int x, int y, int z) { + return func_149851_a(world, x, y, z, false); + } + + @Override + public void func_149853_b(World world, Random rand, int x, int y, int z) { + int meta = world.getBlockMetadata(x, y, z); + placeDoubleFlower(world, x, y, z, meta, 1 | 2); + } + + public static void placeDoubleFlower(World world, int x, int y, int z, int meta, int flags) { + Block flower = meta >= 8 ? ModBlocks.doubleFlower2 : ModBlocks.doubleFlower1; + int placeMeta = meta & 7; + world.setBlock(x, y, z, flower, placeMeta, flags); + world.setBlock(x, y + 1, z, flower, placeMeta | 8, flags); + } } diff --git a/src/main/java/vazkii/botania/common/block/BlockOpenCrate.java b/src/main/java/vazkii/botania/common/block/BlockOpenCrate.java index be6647ce85..d8aebe5a9d 100644 --- a/src/main/java/vazkii/botania/common/block/BlockOpenCrate.java +++ b/src/main/java/vazkii/botania/common/block/BlockOpenCrate.java @@ -2,17 +2,17 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [May 4, 2014, 12:29:56 PM (GMT)] */ package vazkii.botania.common.block; +import cpw.mods.fml.common.registry.GameRegistry; import java.util.List; import java.util.Random; - import net.minecraft.block.Block; import net.minecraft.block.material.Material; import net.minecraft.client.Minecraft; @@ -30,10 +30,8 @@ import net.minecraft.util.IIcon; import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; - import org.lwjgl.opengl.GL11; import org.lwjgl.opengl.GL12; - import vazkii.botania.api.lexicon.ILexiconable; import vazkii.botania.api.lexicon.LexiconEntry; import vazkii.botania.api.wand.IWandHUD; @@ -45,177 +43,179 @@ import vazkii.botania.common.item.block.ItemBlockWithMetadataAndName; import vazkii.botania.common.lexicon.LexiconData; import vazkii.botania.common.lib.LibBlockNames; -import cpw.mods.fml.common.registry.GameRegistry; public class BlockOpenCrate extends BlockModContainer implements ILexiconable, IWandable, IWandHUD { - IIcon iconSide; - IIcon iconBottom; - IIcon iconSideCraft; - IIcon iconBottomCraft; - - IIcon[] sidePatternIcons; - - Random random; - - private static final int SUBTYPES = 2; - - public BlockOpenCrate() { - super(Material.wood); - setHardness(2.0F); - setStepSound(soundTypeWood); - setBlockName(LibBlockNames.OPEN_CRATE); - - random = new Random(); - } - - @Override - protected boolean shouldRegisterInNameSet() { - return false; - } - - @Override - public Block setBlockName(String par1Str) { - GameRegistry.registerBlock(this, ItemBlockWithMetadataAndName.class, par1Str); - return super.setBlockName(par1Str); - } - - @Override - public void getSubBlocks(Item par1, CreativeTabs par2CreativeTabs, List par3List) { - for(int i = 0; i < SUBTYPES; i++) - par3List.add(new ItemStack(par1, 1, i)); - } - - @Override - public int damageDropped(int meta) { - return meta; - } - - - @Override - public boolean hasComparatorInputOverride() { - return true; - } - - @Override - public int getComparatorInputOverride(World par1World, int par2, int par3, int par4, int par5) { - TileOpenCrate crate = (TileOpenCrate) par1World.getTileEntity(par2, par3, par4); - return crate.getSignal(); - } - - @Override - public void breakBlock(World par1World, int par2, int par3, int par4, Block par5, int par6) { - TileSimpleInventory inv = (TileSimpleInventory) par1World.getTileEntity(par2, par3, par4); - - if (inv != null) { - for (int j1 = 0; j1 < inv.getSizeInventory(); ++j1) { - ItemStack itemstack = inv.getStackInSlot(j1); - - if (itemstack != null) { - float f = random.nextFloat() * 0.8F + 0.1F; - float f1 = random.nextFloat() * 0.8F + 0.1F; - EntityItem entityitem; - - for (float f2 = random.nextFloat() * 0.8F + 0.1F; itemstack.stackSize > 0; par1World.spawnEntityInWorld(entityitem)) { - int k1 = random.nextInt(21) + 10; - - if (k1 > itemstack.stackSize) - k1 = itemstack.stackSize; - - itemstack.stackSize -= k1; - entityitem = new EntityItem(par1World, par2 + f, par3 + f1, par4 + f2, new ItemStack(itemstack.getItem(), k1, itemstack.getItemDamage())); - float f3 = 0.05F; - entityitem.motionX = (float)random.nextGaussian() * f3; - entityitem.motionY = (float)random.nextGaussian() * f3 + 0.2F; - entityitem.motionZ = (float)random.nextGaussian() * f3; - - if (itemstack.hasTagCompound()) - entityitem.getEntityItem().setTagCompound((NBTTagCompound)itemstack.getTagCompound().copy()); - } - } - } - - par1World.func_147453_f(par2, par3, par4, par5); - } - - super.breakBlock(par1World, par2, par3, par4, par5, par6); - } - - @Override - public void registerBlockIcons(IIconRegister par1IconRegister) { - iconSide = IconHelper.forBlock(par1IconRegister, this, 0); - iconBottom = IconHelper.forBlock(par1IconRegister, this, 1); - iconSideCraft = IconHelper.forBlock(par1IconRegister, this, 2); - iconBottomCraft = IconHelper.forBlock(par1IconRegister, this, 3); - - sidePatternIcons = new IIcon[TileCraftCrate.PATTERNS.length]; - for(int i = 0; i < sidePatternIcons.length; i++) - sidePatternIcons[i] = IconHelper.forName(par1IconRegister, "ocPattern" + i); - } - - @Override - public IIcon getIcon(int side, int meta) { - return meta == 0 ? side == 0 ? iconBottom : iconSide : side == 0 ? iconBottomCraft : iconSideCraft; - } - - @Override - public IIcon getIcon(IBlockAccess world, int x, int y, int z, int side) { - TileEntity tile = world.getTileEntity(x, y, z); - if(tile != null && tile instanceof TileCraftCrate && ((TileCraftCrate) tile).pattern != -1 && side != 0) - return sidePatternIcons[((TileCraftCrate) tile).pattern]; - - return super.getIcon(world, x, y, z, side); - } - - @Override - public TileEntity createNewTileEntity(World world, int meta) { - return meta == 0 ? new TileOpenCrate() : new TileCraftCrate(); - } - - @Override - public LexiconEntry getEntry(World world, int x, int y, int z, EntityPlayer player, ItemStack lexicon) { - return world.getBlockMetadata(x, y, z) == 0 ? LexiconData.openCrate : LexiconData.craftCrate; - } - - @Override - public boolean onUsedByWand(EntityPlayer player, ItemStack stack, World world, int x, int y, int z, int side) { - TileOpenCrate crate = (TileOpenCrate) world.getTileEntity(x, y, z); - return crate.onWanded(player, stack); - } - - @Override - public void renderHUD(Minecraft mc, ScaledResolution res, World world, int x, int y, int z) { - TileEntity tile = world.getTileEntity(x, y, z); - if(tile instanceof TileCraftCrate) { - TileCraftCrate craft = (TileCraftCrate) tile; - - int width = 52; - int height = 52; - int xc = res.getScaledWidth() / 2 + 20; - int yc = res.getScaledHeight() / 2 - height / 2; - - Gui.drawRect(xc - 6, yc - 6, xc + width + 6, yc + height + 6, 0x22000000); - Gui.drawRect(xc - 4, yc - 4, xc + width + 4, yc + height + 4, 0x22000000); - - for(int i = 0; i < 3; i++) - for(int j = 0; j < 3; j++) { - int index = i * 3 + j; - int xp = xc + j * 18; - int yp = yc + i * 18; - - boolean enabled = true; - if(craft.pattern > -1) - enabled = TileCraftCrate.PATTERNS[craft.pattern][index]; - - Gui.drawRect(xp, yp, xp + 16, yp + 16, enabled ? 0x22FFFFFF : 0x22FF0000); - - ItemStack item = craft.getStackInSlot(index); - net.minecraft.client.renderer.RenderHelper.enableGUIStandardItemLighting(); - GL11.glEnable(GL12.GL_RESCALE_NORMAL); - RenderItem.getInstance().renderItemAndEffectIntoGUI(mc.fontRenderer, mc.renderEngine, item, xp, yp); - net.minecraft.client.renderer.RenderHelper.disableStandardItemLighting(); - } - } - } - + IIcon iconSide; + IIcon iconBottom; + IIcon iconSideCraft; + IIcon iconBottomCraft; + + IIcon[] sidePatternIcons; + + Random random; + + private static final int SUBTYPES = 2; + + public BlockOpenCrate() { + super(Material.wood); + setHardness(2.0F); + setStepSound(soundTypeWood); + setBlockName(LibBlockNames.OPEN_CRATE); + + random = new Random(); + } + + @Override + protected boolean shouldRegisterInNameSet() { + return false; + } + + @Override + public Block setBlockName(String par1Str) { + GameRegistry.registerBlock(this, ItemBlockWithMetadataAndName.class, par1Str); + return super.setBlockName(par1Str); + } + + @Override + public void getSubBlocks(Item par1, CreativeTabs par2CreativeTabs, List par3List) { + for (int i = 0; i < SUBTYPES; i++) par3List.add(new ItemStack(par1, 1, i)); + } + + @Override + public int damageDropped(int meta) { + return meta; + } + + @Override + public boolean hasComparatorInputOverride() { + return true; + } + + @Override + public int getComparatorInputOverride(World par1World, int par2, int par3, int par4, int par5) { + TileOpenCrate crate = (TileOpenCrate) par1World.getTileEntity(par2, par3, par4); + return crate.getSignal(); + } + + @Override + public void breakBlock(World par1World, int par2, int par3, int par4, Block par5, int par6) { + TileSimpleInventory inv = (TileSimpleInventory) par1World.getTileEntity(par2, par3, par4); + + if (inv != null) { + for (int j1 = 0; j1 < inv.getSizeInventory(); ++j1) { + ItemStack itemstack = inv.getStackInSlot(j1); + + if (itemstack != null) { + float f = random.nextFloat() * 0.8F + 0.1F; + float f1 = random.nextFloat() * 0.8F + 0.1F; + EntityItem entityitem; + + for (float f2 = random.nextFloat() * 0.8F + 0.1F; + itemstack.stackSize > 0; + par1World.spawnEntityInWorld(entityitem)) { + int k1 = random.nextInt(21) + 10; + + if (k1 > itemstack.stackSize) k1 = itemstack.stackSize; + + itemstack.stackSize -= k1; + entityitem = new EntityItem( + par1World, + par2 + f, + par3 + f1, + par4 + f2, + new ItemStack(itemstack.getItem(), k1, itemstack.getItemDamage())); + float f3 = 0.05F; + entityitem.motionX = (float) random.nextGaussian() * f3; + entityitem.motionY = (float) random.nextGaussian() * f3 + 0.2F; + entityitem.motionZ = (float) random.nextGaussian() * f3; + + if (itemstack.hasTagCompound()) + entityitem.getEntityItem().setTagCompound((NBTTagCompound) + itemstack.getTagCompound().copy()); + } + } + } + + par1World.func_147453_f(par2, par3, par4, par5); + } + + super.breakBlock(par1World, par2, par3, par4, par5, par6); + } + + @Override + public void registerBlockIcons(IIconRegister par1IconRegister) { + iconSide = IconHelper.forBlock(par1IconRegister, this, 0); + iconBottom = IconHelper.forBlock(par1IconRegister, this, 1); + iconSideCraft = IconHelper.forBlock(par1IconRegister, this, 2); + iconBottomCraft = IconHelper.forBlock(par1IconRegister, this, 3); + + sidePatternIcons = new IIcon[TileCraftCrate.PATTERNS.length]; + for (int i = 0; i < sidePatternIcons.length; i++) + sidePatternIcons[i] = IconHelper.forName(par1IconRegister, "ocPattern" + i); + } + + @Override + public IIcon getIcon(int side, int meta) { + return meta == 0 ? side == 0 ? iconBottom : iconSide : side == 0 ? iconBottomCraft : iconSideCraft; + } + + @Override + public IIcon getIcon(IBlockAccess world, int x, int y, int z, int side) { + TileEntity tile = world.getTileEntity(x, y, z); + if (tile != null && tile instanceof TileCraftCrate && ((TileCraftCrate) tile).pattern != -1 && side != 0) + return sidePatternIcons[((TileCraftCrate) tile).pattern]; + + return super.getIcon(world, x, y, z, side); + } + + @Override + public TileEntity createNewTileEntity(World world, int meta) { + return meta == 0 ? new TileOpenCrate() : new TileCraftCrate(); + } + + @Override + public LexiconEntry getEntry(World world, int x, int y, int z, EntityPlayer player, ItemStack lexicon) { + return world.getBlockMetadata(x, y, z) == 0 ? LexiconData.openCrate : LexiconData.craftCrate; + } + + @Override + public boolean onUsedByWand(EntityPlayer player, ItemStack stack, World world, int x, int y, int z, int side) { + TileOpenCrate crate = (TileOpenCrate) world.getTileEntity(x, y, z); + return crate.onWanded(player, stack); + } + + @Override + public void renderHUD(Minecraft mc, ScaledResolution res, World world, int x, int y, int z) { + TileEntity tile = world.getTileEntity(x, y, z); + if (tile instanceof TileCraftCrate) { + TileCraftCrate craft = (TileCraftCrate) tile; + + int width = 52; + int height = 52; + int xc = res.getScaledWidth() / 2 + 20; + int yc = res.getScaledHeight() / 2 - height / 2; + + Gui.drawRect(xc - 6, yc - 6, xc + width + 6, yc + height + 6, 0x22000000); + Gui.drawRect(xc - 4, yc - 4, xc + width + 4, yc + height + 4, 0x22000000); + + for (int i = 0; i < 3; i++) + for (int j = 0; j < 3; j++) { + int index = i * 3 + j; + int xp = xc + j * 18; + int yp = yc + i * 18; + + boolean enabled = true; + if (craft.pattern > -1) enabled = TileCraftCrate.PATTERNS[craft.pattern][index]; + + Gui.drawRect(xp, yp, xp + 16, yp + 16, enabled ? 0x22FFFFFF : 0x22FF0000); + + ItemStack item = craft.getStackInSlot(index); + net.minecraft.client.renderer.RenderHelper.enableGUIStandardItemLighting(); + GL11.glEnable(GL12.GL_RESCALE_NORMAL); + RenderItem.getInstance().renderItemAndEffectIntoGUI(mc.fontRenderer, mc.renderEngine, item, xp, yp); + net.minecraft.client.renderer.RenderHelper.disableStandardItemLighting(); + } + } + } } diff --git a/src/main/java/vazkii/botania/common/block/BlockPistonRelay.java b/src/main/java/vazkii/botania/common/block/BlockPistonRelay.java index 80dfcdfe41..416bf57a74 100644 --- a/src/main/java/vazkii/botania/common/block/BlockPistonRelay.java +++ b/src/main/java/vazkii/botania/common/block/BlockPistonRelay.java @@ -2,21 +2,25 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Feb 20, 2014, 4:57:36 PM (GMT)] */ package vazkii.botania.common.block; +import cpw.mods.fml.common.FMLCommonHandler; +import cpw.mods.fml.common.eventhandler.SubscribeEvent; +import cpw.mods.fml.common.gameevent.TickEvent; +import cpw.mods.fml.common.gameevent.TickEvent.Phase; +import cpw.mods.fml.common.gameevent.TickEvent.Type; import java.util.ArrayList; import java.util.Collection; import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.Random; - import net.minecraft.block.Block; import net.minecraft.block.material.Material; import net.minecraft.entity.item.EntityItem; @@ -38,244 +42,262 @@ import vazkii.botania.api.wand.IWandable; import vazkii.botania.common.lexicon.LexiconData; import vazkii.botania.common.lib.LibBlockNames; -import cpw.mods.fml.common.FMLCommonHandler; -import cpw.mods.fml.common.eventhandler.SubscribeEvent; -import cpw.mods.fml.common.gameevent.TickEvent; -import cpw.mods.fml.common.gameevent.TickEvent.Phase; -import cpw.mods.fml.common.gameevent.TickEvent.Type; public class BlockPistonRelay extends BlockMod implements IWandable, ILexiconable { - public static Map playerPositions = new HashMap(); - public static Map mappedPositions = new HashMap(); - - static List removeThese = new ArrayList(); - static List checkedCoords = new ArrayList(); - static Map coordsToCheck = new HashMap(); - - public BlockPistonRelay() { - super(Material.gourd); - setBlockName(LibBlockNames.PISTON_RELAY); - setHardness(2F); - setResistance(10F); - setStepSound(soundTypeMetal); - - MinecraftForge.EVENT_BUS.register(this); - FMLCommonHandler.instance().bus().register(this); - } - - @Override - public int quantityDropped(int meta, int fortune, Random random) { - return 0; - } - - @Override - public boolean isOpaqueCube() { - return false; - } - - @Override - public void breakBlock(World par1World, int par2, int par3, int par4, Block par5, int par6) { - mapCoords(par1World.provider.dimensionId, par2, par3, par4, 2); - } - - public static String getCoordsAsString(int world, int x, int y, int z) { - return world + ":" + x + ":" + y + ":" + z; - } - - static void mapCoords(int world, int x, int y, int z, int time) { - String coords = getCoordsAsString(world, x, y, z); - coordsToCheck.put(coords, time); - } - - static void decrCoords(String key) { - int time = getTimeInCoords(key); - - if(time <= 0) - removeThese.add(key); - else coordsToCheck.put(key, time - 1); - } - - static int getTimeInCoords(String key) { - return coordsToCheck.get(key); - } - - static Block getBlockAt(String key) { - MinecraftServer server = MinecraftServer.getServer(); - if(server == null) - return Blocks.air; - - String[] tokens = key.split(":"); - int worldId = Integer.parseInt(tokens[0]), x = Integer.parseInt(tokens[1]), y = Integer.parseInt(tokens[2]), z = Integer.parseInt(tokens[3]); - World world = server.worldServerForDimension(worldId); - return world.getBlock(x, y, z); - } - - static int getBlockMetaAt(String key) { - MinecraftServer server = MinecraftServer.getServer(); - if(server == null) - return 0; - - String[] tokens = key.split(":"); - int worldId = Integer.parseInt(tokens[0]), x = Integer.parseInt(tokens[1]), y = Integer.parseInt(tokens[2]), z = Integer.parseInt(tokens[3]); - World world = server.worldServerForDimension(worldId); - return world.getBlockMetadata(x, y, z); - } - - @Override - public boolean onUsedByWand(EntityPlayer player, ItemStack stack, World world, int x, int y, int z, int side) { - if(player == null) - return false; - - if(!player.isSneaking()) { - playerPositions.put(player.getCommandSenderName(), getCoordsAsString(world.provider.dimensionId, x, y, z)); - world.playSoundEffect(x, y, z, "botania:ding", 0.5F, 1F); - } else { - dropBlockAsItem(world, x, y, z, new ItemStack(this)); - world.setBlockToAir(x, y, z); - if(!world.isRemote) - world.playAuxSFX(2001, x, y , z, Block.getIdFromBlock(this)); - } - - return true; - } - - @SubscribeEvent - public void onWorldLoad(WorldEvent.Load event) { - WorldData.get(event.world); - } - - @SubscribeEvent - public void onWorldUnload(WorldEvent.Unload event) { - WorldData.get(event.world).markDirty(); - } - - public static class WorldData extends WorldSavedData { - - private static final String ID = "PistonRelayPairs"; - - public WorldData(String id) { - super(id); - } - - @Override - public void readFromNBT(NBTTagCompound nbttagcompound) { - mappedPositions.clear(); - - Collection tags = nbttagcompound.func_150296_c(); - for(String key : tags) { - NBTBase tag = nbttagcompound.getTag(key); - if(tag instanceof NBTTagString) { - String value = ((NBTTagString) tag).func_150285_a_(); - - mappedPositions.put(key, value); - } - } - } - - @Override - public void writeToNBT(NBTTagCompound nbttagcompound) { - for(String s : mappedPositions.keySet()) - nbttagcompound.setString(s, mappedPositions.get(s)); - } - - public static WorldData get(World world) { - if(world.mapStorage == null) - return null; - - WorldData data = (WorldData) world.mapStorage.loadData(WorldData.class, ID); - - if (data == null) { - data = new WorldData(ID); - data.markDirty(); - world.mapStorage.setData(ID, data); - } - return data; - } - } - - @SubscribeEvent - public void tickEnd(TickEvent event) { - if(event.type == Type.SERVER && event.phase == Phase.END) { - List coordsToCheckCopy = new ArrayList(coordsToCheck.keySet()); - for(String s : coordsToCheckCopy) { - decrCoords(s); - if(checkedCoords.contains(s)) - continue; - - Block block = getBlockAt(s); - if(block == Blocks.piston_extension) { - int meta = getBlockMetaAt(s); - boolean sticky = (meta & 8) == 8; - ForgeDirection dir = ForgeDirection.getOrientation(meta & ~8); - - MinecraftServer server = MinecraftServer.getServer(); - - if(server != null && getTimeInCoords(s) == 0) { - String newPos; - - { - String[] tokens = s.split(":"); - int worldId = Integer.parseInt(tokens[0]), x = Integer.parseInt(tokens[1]), y = Integer.parseInt(tokens[2]), z = Integer.parseInt(tokens[3]); - World world = server.worldServerForDimension(worldId); - if(world.isAirBlock(x + dir.offsetX, y + dir.offsetY, z + dir.offsetZ)) - world.setBlock(x + dir.offsetX, y + dir.offsetY, z + dir.offsetZ, ModBlocks.pistonRelay); - else if(!world.isRemote) { - ItemStack stack = new ItemStack(ModBlocks.pistonRelay); - world.spawnEntityInWorld(new EntityItem(world, x + dir.offsetX, y + dir.offsetY, z + dir.offsetZ, stack)); - } - checkedCoords.add(s); - newPos = getCoordsAsString(world.provider.dimensionId, x + dir.offsetX, y + dir.offsetY, z + dir.offsetZ); - } - - if(mappedPositions.containsKey(s)) { - String pos = mappedPositions.get(s); - String[] tokens = pos.split(":"); - int worldId = Integer.parseInt(tokens[0]), x = Integer.parseInt(tokens[1]), y = Integer.parseInt(tokens[2]), z = Integer.parseInt(tokens[3]); - World world = server.worldServerForDimension(worldId); - - Block srcBlock = world.getBlock(x, y, z); - int srcMeta = world.getBlockMetadata(x, y, z); - TileEntity tile = world.getTileEntity(x, y, z); - Material mat = srcBlock.getMaterial(); - - if(!sticky && tile == null && mat.getMaterialMobility() == 0 && srcBlock.getBlockHardness(world, x, y, z) != -1 && !srcBlock.isAir(world, x, y, z)) { - Material destMat = world.getBlock(x + dir.offsetX, y + dir.offsetY, z + dir.offsetZ).getMaterial(); - if(world.isAirBlock(x + dir.offsetX, y + dir.offsetY, z + dir.offsetZ) || destMat.isReplaceable()) { - world.setBlock(x, y, z, Blocks.air); - world.setBlock(x + dir.offsetX, y + dir.offsetY, z + dir.offsetZ, srcBlock, srcMeta, 1 | 2); - mappedPositions.put(s, getCoordsAsString(world.provider.dimensionId, x + dir.offsetX, y + dir.offsetY, z + dir.offsetZ)); - } - } - - pos = mappedPositions.get(s); - mappedPositions.remove(s); - mappedPositions.put(newPos, pos); - save(world); - } - } - } - } - } - - // ConcurrentModificationException failsafe - ArrayList remove = new ArrayList(removeThese); - for(String s : remove) { - coordsToCheck.remove(s); - if(checkedCoords.contains(s)) - checkedCoords.remove(s); - } - removeThese.clear(); - } - - public void save(World world) { - WorldData data = WorldData.get(world); - if(data != null) - data.markDirty(); - } - - @Override - public LexiconEntry getEntry(World world, int x, int y, int z, EntityPlayer player, ItemStack lexicon) { - return LexiconData.pistonRelay; - } + public static Map playerPositions = new HashMap(); + public static Map mappedPositions = new HashMap(); + + static List removeThese = new ArrayList(); + static List checkedCoords = new ArrayList(); + static Map coordsToCheck = new HashMap(); + + public BlockPistonRelay() { + super(Material.gourd); + setBlockName(LibBlockNames.PISTON_RELAY); + setHardness(2F); + setResistance(10F); + setStepSound(soundTypeMetal); + + MinecraftForge.EVENT_BUS.register(this); + FMLCommonHandler.instance().bus().register(this); + } + + @Override + public int quantityDropped(int meta, int fortune, Random random) { + return 0; + } + + @Override + public boolean isOpaqueCube() { + return false; + } + + @Override + public void breakBlock(World par1World, int par2, int par3, int par4, Block par5, int par6) { + mapCoords(par1World.provider.dimensionId, par2, par3, par4, 2); + } + + public static String getCoordsAsString(int world, int x, int y, int z) { + return world + ":" + x + ":" + y + ":" + z; + } + + static void mapCoords(int world, int x, int y, int z, int time) { + String coords = getCoordsAsString(world, x, y, z); + coordsToCheck.put(coords, time); + } + + static void decrCoords(String key) { + int time = getTimeInCoords(key); + + if (time <= 0) removeThese.add(key); + else coordsToCheck.put(key, time - 1); + } + + static int getTimeInCoords(String key) { + return coordsToCheck.get(key); + } + + static Block getBlockAt(String key) { + MinecraftServer server = MinecraftServer.getServer(); + if (server == null) return Blocks.air; + + String[] tokens = key.split(":"); + int worldId = Integer.parseInt(tokens[0]), + x = Integer.parseInt(tokens[1]), + y = Integer.parseInt(tokens[2]), + z = Integer.parseInt(tokens[3]); + World world = server.worldServerForDimension(worldId); + return world.getBlock(x, y, z); + } + + static int getBlockMetaAt(String key) { + MinecraftServer server = MinecraftServer.getServer(); + if (server == null) return 0; + + String[] tokens = key.split(":"); + int worldId = Integer.parseInt(tokens[0]), + x = Integer.parseInt(tokens[1]), + y = Integer.parseInt(tokens[2]), + z = Integer.parseInt(tokens[3]); + World world = server.worldServerForDimension(worldId); + return world.getBlockMetadata(x, y, z); + } + + @Override + public boolean onUsedByWand(EntityPlayer player, ItemStack stack, World world, int x, int y, int z, int side) { + if (player == null) return false; + + if (!player.isSneaking()) { + playerPositions.put(player.getCommandSenderName(), getCoordsAsString(world.provider.dimensionId, x, y, z)); + world.playSoundEffect(x, y, z, "botania:ding", 0.5F, 1F); + } else { + dropBlockAsItem(world, x, y, z, new ItemStack(this)); + world.setBlockToAir(x, y, z); + if (!world.isRemote) world.playAuxSFX(2001, x, y, z, Block.getIdFromBlock(this)); + } + + return true; + } + + @SubscribeEvent + public void onWorldLoad(WorldEvent.Load event) { + WorldData.get(event.world); + } + + @SubscribeEvent + public void onWorldUnload(WorldEvent.Unload event) { + WorldData.get(event.world).markDirty(); + } + + public static class WorldData extends WorldSavedData { + + private static final String ID = "PistonRelayPairs"; + + public WorldData(String id) { + super(id); + } + + @Override + public void readFromNBT(NBTTagCompound nbttagcompound) { + mappedPositions.clear(); + + Collection tags = nbttagcompound.func_150296_c(); + for (String key : tags) { + NBTBase tag = nbttagcompound.getTag(key); + if (tag instanceof NBTTagString) { + String value = ((NBTTagString) tag).func_150285_a_(); + + mappedPositions.put(key, value); + } + } + } + + @Override + public void writeToNBT(NBTTagCompound nbttagcompound) { + for (String s : mappedPositions.keySet()) nbttagcompound.setString(s, mappedPositions.get(s)); + } + + public static WorldData get(World world) { + if (world.mapStorage == null) return null; + + WorldData data = (WorldData) world.mapStorage.loadData(WorldData.class, ID); + + if (data == null) { + data = new WorldData(ID); + data.markDirty(); + world.mapStorage.setData(ID, data); + } + return data; + } + } + + @SubscribeEvent + public void tickEnd(TickEvent event) { + if (event.type == Type.SERVER && event.phase == Phase.END) { + List coordsToCheckCopy = new ArrayList(coordsToCheck.keySet()); + for (String s : coordsToCheckCopy) { + decrCoords(s); + if (checkedCoords.contains(s)) continue; + + Block block = getBlockAt(s); + if (block == Blocks.piston_extension) { + int meta = getBlockMetaAt(s); + boolean sticky = (meta & 8) == 8; + ForgeDirection dir = ForgeDirection.getOrientation(meta & ~8); + + MinecraftServer server = MinecraftServer.getServer(); + + if (server != null && getTimeInCoords(s) == 0) { + String newPos; + + { + String[] tokens = s.split(":"); + int worldId = Integer.parseInt(tokens[0]), + x = Integer.parseInt(tokens[1]), + y = Integer.parseInt(tokens[2]), + z = Integer.parseInt(tokens[3]); + World world = server.worldServerForDimension(worldId); + if (world.isAirBlock(x + dir.offsetX, y + dir.offsetY, z + dir.offsetZ)) + world.setBlock( + x + dir.offsetX, y + dir.offsetY, z + dir.offsetZ, ModBlocks.pistonRelay); + else if (!world.isRemote) { + ItemStack stack = new ItemStack(ModBlocks.pistonRelay); + world.spawnEntityInWorld(new EntityItem( + world, x + dir.offsetX, y + dir.offsetY, z + dir.offsetZ, stack)); + } + checkedCoords.add(s); + newPos = getCoordsAsString( + world.provider.dimensionId, x + dir.offsetX, y + dir.offsetY, z + dir.offsetZ); + } + + if (mappedPositions.containsKey(s)) { + String pos = mappedPositions.get(s); + String[] tokens = pos.split(":"); + int worldId = Integer.parseInt(tokens[0]), + x = Integer.parseInt(tokens[1]), + y = Integer.parseInt(tokens[2]), + z = Integer.parseInt(tokens[3]); + World world = server.worldServerForDimension(worldId); + + Block srcBlock = world.getBlock(x, y, z); + int srcMeta = world.getBlockMetadata(x, y, z); + TileEntity tile = world.getTileEntity(x, y, z); + Material mat = srcBlock.getMaterial(); + + if (!sticky + && tile == null + && mat.getMaterialMobility() == 0 + && srcBlock.getBlockHardness(world, x, y, z) != -1 + && !srcBlock.isAir(world, x, y, z)) { + Material destMat = world.getBlock(x + dir.offsetX, y + dir.offsetY, z + dir.offsetZ) + .getMaterial(); + if (world.isAirBlock(x + dir.offsetX, y + dir.offsetY, z + dir.offsetZ) + || destMat.isReplaceable()) { + world.setBlock(x, y, z, Blocks.air); + world.setBlock( + x + dir.offsetX, + y + dir.offsetY, + z + dir.offsetZ, + srcBlock, + srcMeta, + 1 | 2); + mappedPositions.put( + s, + getCoordsAsString( + world.provider.dimensionId, + x + dir.offsetX, + y + dir.offsetY, + z + dir.offsetZ)); + } + } + + pos = mappedPositions.get(s); + mappedPositions.remove(s); + mappedPositions.put(newPos, pos); + save(world); + } + } + } + } + } + + // ConcurrentModificationException failsafe + ArrayList remove = new ArrayList(removeThese); + for (String s : remove) { + coordsToCheck.remove(s); + if (checkedCoords.contains(s)) checkedCoords.remove(s); + } + removeThese.clear(); + } + + public void save(World world) { + WorldData data = WorldData.get(world); + if (data != null) data.markDirty(); + } + + @Override + public LexiconEntry getEntry(World world, int x, int y, int z, EntityPlayer player, ItemStack lexicon) { + return LexiconData.pistonRelay; + } } diff --git a/src/main/java/vazkii/botania/common/block/BlockPlatform.java b/src/main/java/vazkii/botania/common/block/BlockPlatform.java index 75346747fc..22488782b4 100644 --- a/src/main/java/vazkii/botania/common/block/BlockPlatform.java +++ b/src/main/java/vazkii/botania/common/block/BlockPlatform.java @@ -2,16 +2,16 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jun 7, 2014, 2:25:22 PM (GMT)] */ package vazkii.botania.common.block; +import cpw.mods.fml.common.registry.GameRegistry; import java.util.List; - import net.minecraft.block.Block; import net.minecraft.block.material.Material; import net.minecraft.client.renderer.texture.IIconRegister; @@ -32,83 +32,90 @@ import vazkii.botania.common.item.block.ItemBlockWithMetadataAndName; import vazkii.botania.common.lexicon.LexiconData; import vazkii.botania.common.lib.LibBlockNames; -import cpw.mods.fml.common.registry.GameRegistry; public class BlockPlatform extends BlockCamo implements ILexiconable, IWandable { - IIcon[] icons; - private static final int SUBTYPES = 3; - - public BlockPlatform() { - super(Material.wood); - setHardness(2.0F); - setResistance(5.0F); - setStepSound(Block.soundTypeWood); - setBlockName(LibBlockNames.PLATFORM); - } - - @Override - protected boolean shouldRegisterInNameSet() { - return false; - } - - @Override - public int damageDropped(int par1) { - return par1; - } - - @Override - public Block setBlockName(String par1Str) { - GameRegistry.registerBlock(this, ItemBlockWithMetadataAndName.class, par1Str); - return super.setBlockName(par1Str); - } - - @Override - public void getSubBlocks(Item par1, CreativeTabs par2CreativeTabs, List par3List) { - for(int i = 0; i < SUBTYPES; i++) - par3List.add(new ItemStack(par1, 1, i)); - } - - @Override - public void registerBlockIcons(IIconRegister par1IconRegister) { - icons = new IIcon[SUBTYPES]; - for(int i = 0; i < SUBTYPES; i++) - icons[i] = IconHelper.forBlock(par1IconRegister, this, i); - } - - @Override - public IIcon getIcon(int par1, int par2) { - return icons[Math.min(SUBTYPES - 1, par2)]; - } - - @Override - public void addCollisionBoxesToList(World par1World, int par2, int par3, int par4, AxisAlignedBB par5AxisAlignedBB, List par6List, Entity par7Entity) { - int meta = par1World.getBlockMetadata(par2, par3, par4); - if(meta == 2 || meta == 0 && par7Entity != null && par7Entity.posY > par3 + (par7Entity instanceof EntityPlayer ? 2 : 0) && (!(par7Entity instanceof EntityPlayer) || !par7Entity.isSneaking())) - super.addCollisionBoxesToList(par1World, par2, par3, par4, par5AxisAlignedBB, par6List, par7Entity); - } - - @Override - public float getBlockHardness(World par1World, int par2, int par3, int par4) { - int meta = par1World.getBlockMetadata(par2, par3, par4); - return meta == 2 ? -1F : super.getBlockHardness(par1World, par2, par3, par4); - } - - @Override - public TileCamo createNewTileEntity(World world, int meta) { - return new TilePlatform(); - } - - @Override - public LexiconEntry getEntry(World world, int x, int y, int z, EntityPlayer player, ItemStack lexicon) { - int meta = world.getBlockMetadata(x, y, z); - return meta == 0 ? LexiconData.platform : meta == 2 ? null : LexiconData.spectralPlatform; - } - - @Override - public boolean onUsedByWand(EntityPlayer player, ItemStack stack, World world, int x, int y, int z, int side) { - TilePlatform tile = (TilePlatform) world.getTileEntity(x, y, z); - return tile.onWanded(player); - } - -} \ No newline at end of file + IIcon[] icons; + private static final int SUBTYPES = 3; + + public BlockPlatform() { + super(Material.wood); + setHardness(2.0F); + setResistance(5.0F); + setStepSound(Block.soundTypeWood); + setBlockName(LibBlockNames.PLATFORM); + } + + @Override + protected boolean shouldRegisterInNameSet() { + return false; + } + + @Override + public int damageDropped(int par1) { + return par1; + } + + @Override + public Block setBlockName(String par1Str) { + GameRegistry.registerBlock(this, ItemBlockWithMetadataAndName.class, par1Str); + return super.setBlockName(par1Str); + } + + @Override + public void getSubBlocks(Item par1, CreativeTabs par2CreativeTabs, List par3List) { + for (int i = 0; i < SUBTYPES; i++) par3List.add(new ItemStack(par1, 1, i)); + } + + @Override + public void registerBlockIcons(IIconRegister par1IconRegister) { + icons = new IIcon[SUBTYPES]; + for (int i = 0; i < SUBTYPES; i++) icons[i] = IconHelper.forBlock(par1IconRegister, this, i); + } + + @Override + public IIcon getIcon(int par1, int par2) { + return icons[Math.min(SUBTYPES - 1, par2)]; + } + + @Override + public void addCollisionBoxesToList( + World par1World, + int par2, + int par3, + int par4, + AxisAlignedBB par5AxisAlignedBB, + List par6List, + Entity par7Entity) { + int meta = par1World.getBlockMetadata(par2, par3, par4); + if (meta == 2 + || meta == 0 + && par7Entity != null + && par7Entity.posY > par3 + (par7Entity instanceof EntityPlayer ? 2 : 0) + && (!(par7Entity instanceof EntityPlayer) || !par7Entity.isSneaking())) + super.addCollisionBoxesToList(par1World, par2, par3, par4, par5AxisAlignedBB, par6List, par7Entity); + } + + @Override + public float getBlockHardness(World par1World, int par2, int par3, int par4) { + int meta = par1World.getBlockMetadata(par2, par3, par4); + return meta == 2 ? -1F : super.getBlockHardness(par1World, par2, par3, par4); + } + + @Override + public TileCamo createNewTileEntity(World world, int meta) { + return new TilePlatform(); + } + + @Override + public LexiconEntry getEntry(World world, int x, int y, int z, EntityPlayer player, ItemStack lexicon) { + int meta = world.getBlockMetadata(x, y, z); + return meta == 0 ? LexiconData.platform : meta == 2 ? null : LexiconData.spectralPlatform; + } + + @Override + public boolean onUsedByWand(EntityPlayer player, ItemStack stack, World world, int x, int y, int z, int side) { + TilePlatform tile = (TilePlatform) world.getTileEntity(x, y, z); + return tile.onWanded(player); + } +} diff --git a/src/main/java/vazkii/botania/common/block/BlockPylon.java b/src/main/java/vazkii/botania/common/block/BlockPylon.java index c6ed2b1333..a946815935 100644 --- a/src/main/java/vazkii/botania/common/block/BlockPylon.java +++ b/src/main/java/vazkii/botania/common/block/BlockPylon.java @@ -2,16 +2,17 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Feb 18, 2014, 10:13:02 PM (GMT)] */ package vazkii.botania.common.block; +import cpw.mods.fml.common.Optional; +import cpw.mods.fml.common.registry.GameRegistry; import java.util.List; - import net.minecraft.block.Block; import net.minecraft.block.material.Material; import net.minecraft.client.renderer.texture.IIconRegister; @@ -32,86 +33,85 @@ import vazkii.botania.common.item.block.ItemBlockWithMetadataAndName; import vazkii.botania.common.lexicon.LexiconData; import vazkii.botania.common.lib.LibBlockNames; -import cpw.mods.fml.common.Optional; -import cpw.mods.fml.common.registry.GameRegistry; @Optional.Interface(modid = "Thaumcraft", iface = "thaumcraft.api.crafting.IInfusionStabiliser", striprefs = true) public class BlockPylon extends BlockModContainer implements ILexiconable, IInfusionStabiliser { - public BlockPylon() { - super(Material.iron); - setHardness(5.5F); - setStepSound(soundTypeMetal); - setBlockName(LibBlockNames.PYLON); - setLightLevel(0.5F); - - float f = 1F / 16F * 2F; - setBlockBounds(f, 0F, f, 1F - f, 1F / 16F * 21F, 1F - f); - } - @Override - protected boolean shouldRegisterInNameSet() { - return false; - } - - @Override - public Block setBlockName(String par1Str) { - GameRegistry.registerBlock(this, ItemBlockWithMetadataAndName.class, par1Str); - return super.setBlockName(par1Str); - } - - @Override - public void registerBlockIcons(IIconRegister par1IconRegister) { - // NO-OP - } - - @Override - public int damageDropped(int par1) { - return par1; - } - - @Override - public void getSubBlocks(Item par1, CreativeTabs par2, List par3) { - for(int i = 0; i < 3; i++) - par3.add(new ItemStack(par1, 1, i)); - } - - @Override - public IIcon getIcon(int par1, int par2) { - return par2 == 0 ? Blocks.diamond_block.getIcon(0, 0) : ModBlocks.storage.getIcon(0, par2); - } - - @Override - public boolean isOpaqueCube() { - return false; - } - - @Override - public boolean renderAsNormalBlock() { - return false; - } - - @Override - public int getRenderType() { - return LibRenderIDs.idPylon; - } - - @Override - public float getEnchantPowerBonus(World world, int x, int y, int z) { - return world.getBlockMetadata(x, y, z) == 0 ? 8 : 15; - } - - @Override - public TileEntity createNewTileEntity(World world, int meta) { - return new TilePylon(); - } - - @Override - public LexiconEntry getEntry(World world, int x, int y, int z, EntityPlayer player, ItemStack lexicon) { - int meta = world.getBlockMetadata(x, y, z); - return meta == 0 ? LexiconData.pylon : meta == 1 ? LexiconData.alfhomancyIntro : LexiconData.gaiaRitual; - } - @Override - public boolean canStabaliseInfusion(World world, int x, int y, int z) { - return ConfigHandler.enableThaumcraftStablizers; - } + public BlockPylon() { + super(Material.iron); + setHardness(5.5F); + setStepSound(soundTypeMetal); + setBlockName(LibBlockNames.PYLON); + setLightLevel(0.5F); + + float f = 1F / 16F * 2F; + setBlockBounds(f, 0F, f, 1F - f, 1F / 16F * 21F, 1F - f); + } + + @Override + protected boolean shouldRegisterInNameSet() { + return false; + } + + @Override + public Block setBlockName(String par1Str) { + GameRegistry.registerBlock(this, ItemBlockWithMetadataAndName.class, par1Str); + return super.setBlockName(par1Str); + } + + @Override + public void registerBlockIcons(IIconRegister par1IconRegister) { + // NO-OP + } + + @Override + public int damageDropped(int par1) { + return par1; + } + + @Override + public void getSubBlocks(Item par1, CreativeTabs par2, List par3) { + for (int i = 0; i < 3; i++) par3.add(new ItemStack(par1, 1, i)); + } + + @Override + public IIcon getIcon(int par1, int par2) { + return par2 == 0 ? Blocks.diamond_block.getIcon(0, 0) : ModBlocks.storage.getIcon(0, par2); + } + + @Override + public boolean isOpaqueCube() { + return false; + } + + @Override + public boolean renderAsNormalBlock() { + return false; + } + + @Override + public int getRenderType() { + return LibRenderIDs.idPylon; + } + + @Override + public float getEnchantPowerBonus(World world, int x, int y, int z) { + return world.getBlockMetadata(x, y, z) == 0 ? 8 : 15; + } + + @Override + public TileEntity createNewTileEntity(World world, int meta) { + return new TilePylon(); + } + + @Override + public LexiconEntry getEntry(World world, int x, int y, int z, EntityPlayer player, ItemStack lexicon) { + int meta = world.getBlockMetadata(x, y, z); + return meta == 0 ? LexiconData.pylon : meta == 1 ? LexiconData.alfhomancyIntro : LexiconData.gaiaRitual; + } + + @Override + public boolean canStabaliseInfusion(World world, int x, int y, int z) { + return ConfigHandler.enableThaumcraftStablizers; + } } diff --git a/src/main/java/vazkii/botania/common/block/BlockRoot.java b/src/main/java/vazkii/botania/common/block/BlockRoot.java index 4a5810bfe6..6b6570b88e 100644 --- a/src/main/java/vazkii/botania/common/block/BlockRoot.java +++ b/src/main/java/vazkii/botania/common/block/BlockRoot.java @@ -2,16 +2,15 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jul 7, 2015, 4:27:47 PM (GMT)] */ package vazkii.botania.common.block; import java.util.Random; - import net.minecraft.block.material.Material; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.Item; @@ -25,32 +24,30 @@ public class BlockRoot extends BlockMod implements ILexiconable { - public BlockRoot() { - super(Material.plants); - setHardness(1.2F); - setStepSound(soundTypeWood); - setBlockName(LibBlockNames.ROOT); - } - - - @Override - public Item getItemDropped(int p_149650_1_, Random p_149650_2_, int p_149650_3_) { - return ModItems.manaResource; - } - - @Override - public int damageDropped(int p_149692_1_) { - return 20; - } - - @Override - public int quantityDropped(Random r) { - return 2 + r.nextInt(3); - } - - @Override - public LexiconEntry getEntry(World world, int x, int y, int z, EntityPlayer player, ItemStack lexicon) { - return LexiconData.gardenOfGlass; - } - + public BlockRoot() { + super(Material.plants); + setHardness(1.2F); + setStepSound(soundTypeWood); + setBlockName(LibBlockNames.ROOT); + } + + @Override + public Item getItemDropped(int p_149650_1_, Random p_149650_2_, int p_149650_3_) { + return ModItems.manaResource; + } + + @Override + public int damageDropped(int p_149692_1_) { + return 20; + } + + @Override + public int quantityDropped(Random r) { + return 2 + r.nextInt(3); + } + + @Override + public LexiconEntry getEntry(World world, int x, int y, int z, EntityPlayer player, ItemStack lexicon) { + return LexiconData.gardenOfGlass; + } } diff --git a/src/main/java/vazkii/botania/common/block/BlockSolidVines.java b/src/main/java/vazkii/botania/common/block/BlockSolidVines.java index f75af748e1..8b6149a503 100644 --- a/src/main/java/vazkii/botania/common/block/BlockSolidVines.java +++ b/src/main/java/vazkii/botania/common/block/BlockSolidVines.java @@ -2,16 +2,16 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jun 26, 2014, 11:31:51 PM (GMT)] */ package vazkii.botania.common.block; +import cpw.mods.fml.common.registry.GameRegistry; import java.util.Random; - import net.minecraft.block.Block; import net.minecraft.block.BlockVine; import net.minecraft.entity.player.EntityPlayer; @@ -26,48 +26,46 @@ import vazkii.botania.common.item.block.ItemBlockMod; import vazkii.botania.common.lexicon.LexiconData; import vazkii.botania.common.lib.LibBlockNames; -import cpw.mods.fml.common.registry.GameRegistry; public class BlockSolidVines extends BlockVine implements ILexiconable { - public BlockSolidVines() { - setBlockName(LibBlockNames.SOLID_VINE); - setHardness(0.5F); - setStepSound(soundTypeGrass); - setBlockTextureName("vine"); - setCreativeTab(null); - } - - @Override - public AxisAlignedBB getCollisionBoundingBoxFromPool(World w, int x, int y, int z) { - setBlockBoundsBasedOnState(w, x, y, z); - return AxisAlignedBB.getBoundingBox(x + minX, y + minY, z + minZ, x + maxX, y + maxY, z + maxZ); - } + public BlockSolidVines() { + setBlockName(LibBlockNames.SOLID_VINE); + setHardness(0.5F); + setStepSound(soundTypeGrass); + setBlockTextureName("vine"); + setCreativeTab(null); + } - @Override - public void updateTick(World p_149674_1_, int p_149674_2_, int p_149674_3_, int p_149674_4_, Random p_149674_5_) { - // NO-OP - } + @Override + public AxisAlignedBB getCollisionBoundingBoxFromPool(World w, int x, int y, int z) { + setBlockBoundsBasedOnState(w, x, y, z); + return AxisAlignedBB.getBoundingBox(x + minX, y + minY, z + minZ, x + maxX, y + maxY, z + maxZ); + } - @Override - public Block setBlockName(String par1Str) { - GameRegistry.registerBlock(this, ItemBlockMod.class, par1Str); - return super.setBlockName(par1Str); - } + @Override + public void updateTick(World p_149674_1_, int p_149674_2_, int p_149674_3_, int p_149674_4_, Random p_149674_5_) { + // NO-OP + } - @Override - public boolean isShearable(ItemStack item, IBlockAccess world, int x, int y, int z) { - return false; - } + @Override + public Block setBlockName(String par1Str) { + GameRegistry.registerBlock(this, ItemBlockMod.class, par1Str); + return super.setBlockName(par1Str); + } - @Override - public ItemStack getPickBlock(MovingObjectPosition target, World world, int x, int y, int z) { - return new ItemStack(Blocks.vine); - } + @Override + public boolean isShearable(ItemStack item, IBlockAccess world, int x, int y, int z) { + return false; + } - @Override - public LexiconEntry getEntry(World world, int x, int y, int z, EntityPlayer player, ItemStack lexicon) { - return LexiconData.vineBall; - } + @Override + public ItemStack getPickBlock(MovingObjectPosition target, World world, int x, int y, int z) { + return new ItemStack(Blocks.vine); + } + @Override + public LexiconEntry getEntry(World world, int x, int y, int z, EntityPlayer player, ItemStack lexicon) { + return LexiconData.vineBall; + } } diff --git a/src/main/java/vazkii/botania/common/block/BlockSparkChanger.java b/src/main/java/vazkii/botania/common/block/BlockSparkChanger.java index f8a69fe9ff..23203557b9 100644 --- a/src/main/java/vazkii/botania/common/block/BlockSparkChanger.java +++ b/src/main/java/vazkii/botania/common/block/BlockSparkChanger.java @@ -2,16 +2,15 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jun 28, 2015, 10:01:01 PM (GMT)] */ package vazkii.botania.common.block; import java.util.Random; - import net.minecraft.block.Block; import net.minecraft.block.material.Material; import net.minecraft.client.renderer.texture.IIconRegister; @@ -34,147 +33,150 @@ public class BlockSparkChanger extends BlockModContainer implements ILexiconable { - IIcon[] icons; - Random random; - - public BlockSparkChanger() { - super(Material.rock); - setBlockBounds(0F, 0F, 0F, 1F, 3F / 16F, 1F); - setHardness(2.0F); - setResistance(10.0F); - setStepSound(soundTypeStone); - setBlockName(LibBlockNames.SPARK_CHANGER); - - random = new Random(); - } - - @Override - public boolean renderAsNormalBlock() { - return false; - } - - @Override - public boolean isOpaqueCube() { - return false; - } - - @Override - public boolean getBlocksMovement(IBlockAccess p_149655_1_, int p_149655_2_, int p_149655_3_, int p_149655_4_) { - return false; - } - - @Override - public void registerBlockIcons(IIconRegister par1IconRegister) { - icons = new IIcon[3]; - for(int i = 0; i < icons.length; i++) - icons[i] = IconHelper.forBlock(par1IconRegister, this, i); - } - - @Override - public IIcon getIcon(int par1, int par2) { - return icons[Math.min(2, par1)]; - } - - @Override - public void onNeighborBlockChange(World world, int x, int y, int z, Block block) { - boolean power = world.isBlockIndirectlyGettingPowered(x, y, z) || world.isBlockIndirectlyGettingPowered(x, y + 1, z); - int meta = world.getBlockMetadata(x, y, z); - boolean powered = (meta & 8) != 0; - - if(power && !powered) { - ((TileSparkChanger) world.getTileEntity(x, y, z)).doSwap(); - world.setBlockMetadataWithNotify(x, y, z, meta | 8, 4); - } else if(!power && powered) - world.setBlockMetadataWithNotify(x, y, z, meta & -9, 4); - } - - @Override - public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int s, float xs, float ys, float zs) { - TileSparkChanger changer = (TileSparkChanger) world.getTileEntity(x, y, z); - ItemStack cstack = changer.getStackInSlot(0); - ItemStack pstack = player.getCurrentEquippedItem(); - if(cstack != null) { - changer.setInventorySlotContents(0, null); - world.func_147453_f(x, y, z, this); - changer.markDirty(); - if(!player.inventory.addItemStackToInventory(cstack)) - player.dropPlayerItemWithRandomChoice(cstack, false); - return true; - } else if(pstack != null && pstack.getItem() == ModItems.sparkUpgrade) { - changer.setInventorySlotContents(0, pstack.copy().splitStack(1)); - world.func_147453_f(x, y, z, this); - changer.markDirty(); - - pstack.stackSize--; - if(pstack.stackSize == 0) - player.inventory.setInventorySlotContents(player.inventory.currentItem, null); - - return true; - } - - return false; - } - - @Override - public void breakBlock(World par1World, int par2, int par3, int par4, Block par5, int par6) { - TileSimpleInventory inv = (TileSimpleInventory) par1World.getTileEntity(par2, par3, par4); - - if (inv != null) { - for (int j1 = 0; j1 < inv.getSizeInventory(); ++j1) { - ItemStack itemstack = inv.getStackInSlot(j1); - - if (itemstack != null) { - float f = random.nextFloat() * 0.8F + 0.1F; - float f1 = random.nextFloat() * 0.8F + 0.1F; - EntityItem entityitem; - - for (float f2 = random.nextFloat() * 0.8F + 0.1F; itemstack.stackSize > 0; par1World.spawnEntityInWorld(entityitem)) { - int k1 = random.nextInt(21) + 10; - - if (k1 > itemstack.stackSize) - k1 = itemstack.stackSize; - - itemstack.stackSize -= k1; - entityitem = new EntityItem(par1World, par2 + f, par3 + f1, par4 + f2, new ItemStack(itemstack.getItem(), k1, itemstack.getItemDamage())); - float f3 = 0.05F; - entityitem.motionX = (float)random.nextGaussian() * f3; - entityitem.motionY = (float)random.nextGaussian() * f3 + 0.2F; - entityitem.motionZ = (float)random.nextGaussian() * f3; - - if (itemstack.hasTagCompound()) - entityitem.getEntityItem().setTagCompound((NBTTagCompound)itemstack.getTagCompound().copy()); - } - } - } - - par1World.func_147453_f(par2, par3, par4, par5); - } - - super.breakBlock(par1World, par2, par3, par4, par5, par6); - } - - @Override - public boolean hasComparatorInputOverride() { - return true; - } - - @Override - public int getComparatorInputOverride(World world, int x, int y, int z, int s) { - TileSparkChanger changer = (TileSparkChanger) world.getTileEntity(x, y, z); - ItemStack stack = changer.getStackInSlot(0); - if(stack == null) - return 0; - return stack.getItemDamage() + 1; - } - - @Override - public TileEntity createNewTileEntity(World world, int meta) { - return new TileSparkChanger(); - } - - @Override - public LexiconEntry getEntry(World world, int x, int y, int z, EntityPlayer player, ItemStack lexicon) { - return LexiconData.sparkChanger; - } - + IIcon[] icons; + Random random; + + public BlockSparkChanger() { + super(Material.rock); + setBlockBounds(0F, 0F, 0F, 1F, 3F / 16F, 1F); + setHardness(2.0F); + setResistance(10.0F); + setStepSound(soundTypeStone); + setBlockName(LibBlockNames.SPARK_CHANGER); + + random = new Random(); + } + + @Override + public boolean renderAsNormalBlock() { + return false; + } + + @Override + public boolean isOpaqueCube() { + return false; + } + + @Override + public boolean getBlocksMovement(IBlockAccess p_149655_1_, int p_149655_2_, int p_149655_3_, int p_149655_4_) { + return false; + } + + @Override + public void registerBlockIcons(IIconRegister par1IconRegister) { + icons = new IIcon[3]; + for (int i = 0; i < icons.length; i++) icons[i] = IconHelper.forBlock(par1IconRegister, this, i); + } + + @Override + public IIcon getIcon(int par1, int par2) { + return icons[Math.min(2, par1)]; + } + + @Override + public void onNeighborBlockChange(World world, int x, int y, int z, Block block) { + boolean power = + world.isBlockIndirectlyGettingPowered(x, y, z) || world.isBlockIndirectlyGettingPowered(x, y + 1, z); + int meta = world.getBlockMetadata(x, y, z); + boolean powered = (meta & 8) != 0; + + if (power && !powered) { + ((TileSparkChanger) world.getTileEntity(x, y, z)).doSwap(); + world.setBlockMetadataWithNotify(x, y, z, meta | 8, 4); + } else if (!power && powered) world.setBlockMetadataWithNotify(x, y, z, meta & -9, 4); + } + + @Override + public boolean onBlockActivated( + World world, int x, int y, int z, EntityPlayer player, int s, float xs, float ys, float zs) { + TileSparkChanger changer = (TileSparkChanger) world.getTileEntity(x, y, z); + ItemStack cstack = changer.getStackInSlot(0); + ItemStack pstack = player.getCurrentEquippedItem(); + if (cstack != null) { + changer.setInventorySlotContents(0, null); + world.func_147453_f(x, y, z, this); + changer.markDirty(); + if (!player.inventory.addItemStackToInventory(cstack)) player.dropPlayerItemWithRandomChoice(cstack, false); + return true; + } else if (pstack != null && pstack.getItem() == ModItems.sparkUpgrade) { + changer.setInventorySlotContents(0, pstack.copy().splitStack(1)); + world.func_147453_f(x, y, z, this); + changer.markDirty(); + + pstack.stackSize--; + if (pstack.stackSize == 0) player.inventory.setInventorySlotContents(player.inventory.currentItem, null); + + return true; + } + + return false; + } + + @Override + public void breakBlock(World par1World, int par2, int par3, int par4, Block par5, int par6) { + TileSimpleInventory inv = (TileSimpleInventory) par1World.getTileEntity(par2, par3, par4); + + if (inv != null) { + for (int j1 = 0; j1 < inv.getSizeInventory(); ++j1) { + ItemStack itemstack = inv.getStackInSlot(j1); + + if (itemstack != null) { + float f = random.nextFloat() * 0.8F + 0.1F; + float f1 = random.nextFloat() * 0.8F + 0.1F; + EntityItem entityitem; + + for (float f2 = random.nextFloat() * 0.8F + 0.1F; + itemstack.stackSize > 0; + par1World.spawnEntityInWorld(entityitem)) { + int k1 = random.nextInt(21) + 10; + + if (k1 > itemstack.stackSize) k1 = itemstack.stackSize; + + itemstack.stackSize -= k1; + entityitem = new EntityItem( + par1World, + par2 + f, + par3 + f1, + par4 + f2, + new ItemStack(itemstack.getItem(), k1, itemstack.getItemDamage())); + float f3 = 0.05F; + entityitem.motionX = (float) random.nextGaussian() * f3; + entityitem.motionY = (float) random.nextGaussian() * f3 + 0.2F; + entityitem.motionZ = (float) random.nextGaussian() * f3; + + if (itemstack.hasTagCompound()) + entityitem.getEntityItem().setTagCompound((NBTTagCompound) + itemstack.getTagCompound().copy()); + } + } + } + + par1World.func_147453_f(par2, par3, par4, par5); + } + + super.breakBlock(par1World, par2, par3, par4, par5, par6); + } + + @Override + public boolean hasComparatorInputOverride() { + return true; + } + + @Override + public int getComparatorInputOverride(World world, int x, int y, int z, int s) { + TileSparkChanger changer = (TileSparkChanger) world.getTileEntity(x, y, z); + ItemStack stack = changer.getStackInSlot(0); + if (stack == null) return 0; + return stack.getItemDamage() + 1; + } + + @Override + public TileEntity createNewTileEntity(World world, int meta) { + return new TileSparkChanger(); + } + + @Override + public LexiconEntry getEntry(World world, int x, int y, int z, EntityPlayer player, ItemStack lexicon) { + return LexiconData.sparkChanger; + } } diff --git a/src/main/java/vazkii/botania/common/block/BlockSpecialFlower.java b/src/main/java/vazkii/botania/common/block/BlockSpecialFlower.java index e44ac4941d..adacc7614c 100644 --- a/src/main/java/vazkii/botania/common/block/BlockSpecialFlower.java +++ b/src/main/java/vazkii/botania/common/block/BlockSpecialFlower.java @@ -2,20 +2,20 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jan 22, 2014, 7:06:38 PM (GMT)] */ package vazkii.botania.common.block; +import cpw.mods.fml.common.registry.GameRegistry; import java.util.ArrayList; import java.util.Arrays; import java.util.HashMap; import java.util.List; import java.util.Map; - import net.minecraft.block.Block; import net.minecraft.block.BlockFlower; import net.minecraft.block.ITileEntityProvider; @@ -47,231 +47,231 @@ import vazkii.botania.common.item.ModItems; import vazkii.botania.common.item.block.ItemBlockSpecialFlower; import vazkii.botania.common.lib.LibBlockNames; -import cpw.mods.fml.common.registry.GameRegistry; - -public class BlockSpecialFlower extends BlockFlower implements ITileEntityProvider, ISpecialFlower, IWandable, ILexiconable, IWandHUD { - - public static Map icons = new HashMap(); - public static Map iconsAlt = new HashMap(); - - static { - BotaniaAPI.subtilesForCreativeMenu.addAll(Arrays.asList(new String[] { - // Misc - LibBlockNames.SUBTILE_PUREDAISY, - LibBlockNames.SUBTILE_MANASTAR, - - // Generating - LibBlockNames.SUBTILE_DAYBLOOM, - LibBlockNames.SUBTILE_NIGHTSHADE, - LibBlockNames.SUBTILE_ENDOFLAME, - LibBlockNames.SUBTILE_HYDROANGEAS, - LibBlockNames.SUBTILE_THERMALILY, - LibBlockNames.SUBTILE_ARCANE_ROSE, - LibBlockNames.SUBTILE_MUNCHDEW, - LibBlockNames.SUBTILE_ENTROPINNYUM, - LibBlockNames.SUBTILE_KEKIMURUS, - LibBlockNames.SUBTILE_GOURMARYLLIS, - LibBlockNames.SUBTILE_NARSLIMMUS, - LibBlockNames.SUBTILE_SPECTROLUS, - LibBlockNames.SUBTILE_RAFFLOWSIA, - LibBlockNames.SUBTILE_DANDELIFEON, - - // Functional - LibBlockNames.SUBTILE_JADED_AMARANTHUS, - LibBlockNames.SUBTILE_BELLETHORN, - LibBlockNames.SUBTILE_DREADTHORN, - LibBlockNames.SUBTILE_HEISEI_DREAM, - LibBlockNames.SUBTILE_TIGERSEYE, - LibBlockNames.SUBTILE_MARIMORPHOSIS, - LibBlockNames.SUBTILE_ORECHID, - LibBlockNames.SUBTILE_ORECHID_IGNEM, - LibBlockNames.SUBTILE_FALLEN_KANADE, - LibBlockNames.SUBTILE_EXOFLAME, - LibBlockNames.SUBTILE_AGRICARNATION, - LibBlockNames.SUBTILE_HOPPERHOCK, - LibBlockNames.SUBTILE_RANNUNCARPUS, - LibBlockNames.SUBTILE_TANGLEBERRIE, - LibBlockNames.SUBTILE_JIYUULIA, - LibBlockNames.SUBTILE_HYACIDUS, - LibBlockNames.SUBTILE_MEDUMONE, - LibBlockNames.SUBTILE_POLLIDISIAC, - LibBlockNames.SUBTILE_CLAYCONIA, - LibBlockNames.SUBTILE_LOONIUM, - LibBlockNames.SUBTILE_DAFFOMILL, - LibBlockNames.SUBTILE_VINCULOTUS, - LibBlockNames.SUBTILE_SPECTRANTHEMUM, - LibBlockNames.SUBTILE_BUBBELL, - LibBlockNames.SUBTILE_SOLEGNOLIA - })); - } - - protected BlockSpecialFlower() { - super(0); - setBlockName(LibBlockNames.SPECIAL_FLOWER); - setHardness(0.1F); - setStepSound(soundTypeGrass); - setTickRandomly(false); - setCreativeTab(BotaniaCreativeTab.INSTANCE); - setBlockBounds(0.3F, 0.0F, 0.3F, 0.8F, 1, 0.8F); - } - - @Override - public int getLightValue(IBlockAccess world, int x, int y, int z) { - int currentLight = ((TileSpecialFlower) world.getTileEntity(x, y, z)).getLightValue(); - if(currentLight == -1) - currentLight = 0; - return LightHelper.getPackedColor(world.getBlockMetadata(x, y, z), currentLight); - } - - @Override - public boolean hasComparatorInputOverride() { - return true; - } - - @Override - public int getComparatorInputOverride(World world, int x, int y, int z, int side) { - return ((TileSpecialFlower) world.getTileEntity(x, y, z)).getComparatorInputOverride(side); - } - - @Override - public int isProvidingWeakPower(IBlockAccess world, int x, int y, int z, int side) { - return ((TileSpecialFlower) world.getTileEntity(x, y, z)).getPowerLevel(side); - } - - @Override - public int isProvidingStrongPower(IBlockAccess world, int x, int y, int z, int side) { - return isProvidingWeakPower(world, x, y, z, side); - } - - @Override - public boolean canProvidePower() { - return true; - } - - @Override - public int getRenderType() { - return LibRenderIDs.idSpecialFlower; - } - - @Override - public Block setBlockName(String par1Str) { - GameRegistry.registerBlock(this, ItemBlockSpecialFlower.class, par1Str); - return super.setBlockName(par1Str); - } - - @Override - public void getSubBlocks(Item par1, CreativeTabs par2CreativeTabs, List par3List) { - for(String s : BotaniaAPI.subtilesForCreativeMenu) { - par3List.add(ItemBlockSpecialFlower.ofType(s)); - if(BotaniaAPI.miniFlowers.containsKey(s)) - par3List.add(ItemBlockSpecialFlower.ofType(BotaniaAPI.miniFlowers.get(s))); - } - } - - @Override - public void registerBlockIcons(IIconRegister par1IconRegister) { - for(String s : BotaniaAPI.getAllSubTiles()) - if(!s.isEmpty()) - BotaniaAPI.getSignatureForName(s).registerIcons(par1IconRegister); - } - - @Override - public IIcon getIcon(IBlockAccess par1iBlockAccess, int par2, int par3, int par4, int par5) { - return ((TileSpecialFlower) par1iBlockAccess.getTileEntity(par2, par3, par4)).getIcon(); - } - - @Override - public IIcon getIcon(int par1, int par2) { - return BlockModFlower.icons[16]; - } - - @Override - public ItemStack getPickBlock(MovingObjectPosition target, World world, int x, int y, int z) { - String name = ((TileSpecialFlower) world.getTileEntity(x, y, z)).subTileName; - return ItemBlockSpecialFlower.ofType(name); - } - - @Override - protected boolean canPlaceBlockOn(Block block) { - return super.canPlaceBlockOn(block) || block == ModBlocks.redStringRelay || block == Blocks.mycelium; - } - - @Override - public void onBlockHarvested(World par1World, int par2, int par3, int par4, int par5, EntityPlayer par6EntityPlayer) { - if(!par6EntityPlayer.capabilities.isCreativeMode) { - dropBlockAsItem(par1World, par2, par3, par4, par5, 0); - ((TileSpecialFlower) par1World.getTileEntity(par2, par3, par4)).onBlockHarvested(par1World, par2, par3, par4, par5, par6EntityPlayer); - } - } - - @Override - public ArrayList getDrops(World world, int x, int y, int z, int metadata, int fortune) { - ArrayList list = new ArrayList(); - TileEntity tile = world.getTileEntity(x, y, z); - - if(tile != null) { - String name = ((TileSpecialFlower) tile).subTileName; - list.add(ItemBlockSpecialFlower.ofType(name)); - ((TileSpecialFlower) tile).getDrops(list); - } - - return list; - } - - @Override - public boolean onBlockEventReceived(World par1World, int par2, int par3, int par4, int par5, int par6) { - super.onBlockEventReceived(par1World, par2, par3, par4, par5, par6); - TileEntity tileentity = par1World.getTileEntity(par2, par3, par4); - return tileentity != null ? tileentity.receiveClientEvent(par5, par6) : false; - } - - @Override - public TileEntity createNewTileEntity(World world, int meta) { - return new TileSpecialFlower(); - } - - @Override - public LexiconEntry getEntry(World world, int x, int y, int z, EntityPlayer player, ItemStack lexicon) { - return ((TileSpecialFlower) world.getTileEntity(x, y, z)).getEntry(); - } - - @Override - public boolean onUsedByWand(EntityPlayer player, ItemStack stack, World world, int x, int y, int z, int side) { - return ((TileSpecialFlower) world.getTileEntity(x, y, z)).onWanded(stack, player); - } - - @Override - public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase entity, ItemStack stack) { - ((TileSpecialFlower) world.getTileEntity(x, y, z)).onBlockPlacedBy(world, x, y, z, entity, stack); - } - - @Override - public void onBlockAdded(World world, int x, int y, int z) { - ((TileSpecialFlower) world.getTileEntity(x, y, z)).onBlockAdded(world, x, y, z); - } - - @Override - public int colorMultiplier(IBlockAccess world, int x, int y, int z) { - float[] rgb = EntitySheep.fleeceColorTable[world.getBlockMetadata(x, y, z)]; - return ((int) (rgb[0] * 255) << 16) + ((int) (rgb[1] * 255) << 8) + (int) (rgb[2] * 255); - } - - @Override - public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int side, float hitX, float hitY, float hitZ) { - ItemStack stack = player.getCurrentEquippedItem(); - if(stack != null && stack.getItem() == ModItems.dye) { - int newMeta = stack.getItemDamage(); - int oldMeta = world.getBlockMetadata(x, y, z); - if(newMeta != oldMeta) - world.setBlockMetadataWithNotify(x, y, z, newMeta, 1 | 2); - } - - return ((TileSpecialFlower) world.getTileEntity(x, y, z)).onBlockActivated(world, x, y, z, player, side, hitX, hitY, hitZ); - } - - @Override - public void renderHUD(Minecraft mc, ScaledResolution res, World world, int x, int y, int z) { - ((TileSpecialFlower) world.getTileEntity(x, y, z)).renderHUD(mc, res); - } +public class BlockSpecialFlower extends BlockFlower + implements ITileEntityProvider, ISpecialFlower, IWandable, ILexiconable, IWandHUD { + + public static Map icons = new HashMap(); + public static Map iconsAlt = new HashMap(); + + static { + BotaniaAPI.subtilesForCreativeMenu.addAll(Arrays.asList(new String[] { + // Misc + LibBlockNames.SUBTILE_PUREDAISY, + LibBlockNames.SUBTILE_MANASTAR, + + // Generating + LibBlockNames.SUBTILE_DAYBLOOM, + LibBlockNames.SUBTILE_NIGHTSHADE, + LibBlockNames.SUBTILE_ENDOFLAME, + LibBlockNames.SUBTILE_HYDROANGEAS, + LibBlockNames.SUBTILE_THERMALILY, + LibBlockNames.SUBTILE_ARCANE_ROSE, + LibBlockNames.SUBTILE_MUNCHDEW, + LibBlockNames.SUBTILE_ENTROPINNYUM, + LibBlockNames.SUBTILE_KEKIMURUS, + LibBlockNames.SUBTILE_GOURMARYLLIS, + LibBlockNames.SUBTILE_NARSLIMMUS, + LibBlockNames.SUBTILE_SPECTROLUS, + LibBlockNames.SUBTILE_RAFFLOWSIA, + LibBlockNames.SUBTILE_DANDELIFEON, + + // Functional + LibBlockNames.SUBTILE_JADED_AMARANTHUS, + LibBlockNames.SUBTILE_BELLETHORN, + LibBlockNames.SUBTILE_DREADTHORN, + LibBlockNames.SUBTILE_HEISEI_DREAM, + LibBlockNames.SUBTILE_TIGERSEYE, + LibBlockNames.SUBTILE_MARIMORPHOSIS, + LibBlockNames.SUBTILE_ORECHID, + LibBlockNames.SUBTILE_ORECHID_IGNEM, + LibBlockNames.SUBTILE_FALLEN_KANADE, + LibBlockNames.SUBTILE_EXOFLAME, + LibBlockNames.SUBTILE_AGRICARNATION, + LibBlockNames.SUBTILE_HOPPERHOCK, + LibBlockNames.SUBTILE_RANNUNCARPUS, + LibBlockNames.SUBTILE_TANGLEBERRIE, + LibBlockNames.SUBTILE_JIYUULIA, + LibBlockNames.SUBTILE_HYACIDUS, + LibBlockNames.SUBTILE_MEDUMONE, + LibBlockNames.SUBTILE_POLLIDISIAC, + LibBlockNames.SUBTILE_CLAYCONIA, + LibBlockNames.SUBTILE_LOONIUM, + LibBlockNames.SUBTILE_DAFFOMILL, + LibBlockNames.SUBTILE_VINCULOTUS, + LibBlockNames.SUBTILE_SPECTRANTHEMUM, + LibBlockNames.SUBTILE_BUBBELL, + LibBlockNames.SUBTILE_SOLEGNOLIA + })); + } + + protected BlockSpecialFlower() { + super(0); + setBlockName(LibBlockNames.SPECIAL_FLOWER); + setHardness(0.1F); + setStepSound(soundTypeGrass); + setTickRandomly(false); + setCreativeTab(BotaniaCreativeTab.INSTANCE); + setBlockBounds(0.3F, 0.0F, 0.3F, 0.8F, 1, 0.8F); + } + + @Override + public int getLightValue(IBlockAccess world, int x, int y, int z) { + int currentLight = ((TileSpecialFlower) world.getTileEntity(x, y, z)).getLightValue(); + if (currentLight == -1) currentLight = 0; + return LightHelper.getPackedColor(world.getBlockMetadata(x, y, z), currentLight); + } + + @Override + public boolean hasComparatorInputOverride() { + return true; + } + + @Override + public int getComparatorInputOverride(World world, int x, int y, int z, int side) { + return ((TileSpecialFlower) world.getTileEntity(x, y, z)).getComparatorInputOverride(side); + } + + @Override + public int isProvidingWeakPower(IBlockAccess world, int x, int y, int z, int side) { + return ((TileSpecialFlower) world.getTileEntity(x, y, z)).getPowerLevel(side); + } + + @Override + public int isProvidingStrongPower(IBlockAccess world, int x, int y, int z, int side) { + return isProvidingWeakPower(world, x, y, z, side); + } + + @Override + public boolean canProvidePower() { + return true; + } + + @Override + public int getRenderType() { + return LibRenderIDs.idSpecialFlower; + } + + @Override + public Block setBlockName(String par1Str) { + GameRegistry.registerBlock(this, ItemBlockSpecialFlower.class, par1Str); + return super.setBlockName(par1Str); + } + + @Override + public void getSubBlocks(Item par1, CreativeTabs par2CreativeTabs, List par3List) { + for (String s : BotaniaAPI.subtilesForCreativeMenu) { + par3List.add(ItemBlockSpecialFlower.ofType(s)); + if (BotaniaAPI.miniFlowers.containsKey(s)) + par3List.add(ItemBlockSpecialFlower.ofType(BotaniaAPI.miniFlowers.get(s))); + } + } + + @Override + public void registerBlockIcons(IIconRegister par1IconRegister) { + for (String s : BotaniaAPI.getAllSubTiles()) + if (!s.isEmpty()) BotaniaAPI.getSignatureForName(s).registerIcons(par1IconRegister); + } + + @Override + public IIcon getIcon(IBlockAccess par1iBlockAccess, int par2, int par3, int par4, int par5) { + return ((TileSpecialFlower) par1iBlockAccess.getTileEntity(par2, par3, par4)).getIcon(); + } + + @Override + public IIcon getIcon(int par1, int par2) { + return BlockModFlower.icons[16]; + } + + @Override + public ItemStack getPickBlock(MovingObjectPosition target, World world, int x, int y, int z) { + String name = ((TileSpecialFlower) world.getTileEntity(x, y, z)).subTileName; + return ItemBlockSpecialFlower.ofType(name); + } + + @Override + protected boolean canPlaceBlockOn(Block block) { + return super.canPlaceBlockOn(block) || block == ModBlocks.redStringRelay || block == Blocks.mycelium; + } + + @Override + public void onBlockHarvested( + World par1World, int par2, int par3, int par4, int par5, EntityPlayer par6EntityPlayer) { + if (!par6EntityPlayer.capabilities.isCreativeMode) { + dropBlockAsItem(par1World, par2, par3, par4, par5, 0); + ((TileSpecialFlower) par1World.getTileEntity(par2, par3, par4)) + .onBlockHarvested(par1World, par2, par3, par4, par5, par6EntityPlayer); + } + } + + @Override + public ArrayList getDrops(World world, int x, int y, int z, int metadata, int fortune) { + ArrayList list = new ArrayList(); + TileEntity tile = world.getTileEntity(x, y, z); + + if (tile != null) { + String name = ((TileSpecialFlower) tile).subTileName; + list.add(ItemBlockSpecialFlower.ofType(name)); + ((TileSpecialFlower) tile).getDrops(list); + } + + return list; + } + + @Override + public boolean onBlockEventReceived(World par1World, int par2, int par3, int par4, int par5, int par6) { + super.onBlockEventReceived(par1World, par2, par3, par4, par5, par6); + TileEntity tileentity = par1World.getTileEntity(par2, par3, par4); + return tileentity != null ? tileentity.receiveClientEvent(par5, par6) : false; + } + + @Override + public TileEntity createNewTileEntity(World world, int meta) { + return new TileSpecialFlower(); + } + + @Override + public LexiconEntry getEntry(World world, int x, int y, int z, EntityPlayer player, ItemStack lexicon) { + return ((TileSpecialFlower) world.getTileEntity(x, y, z)).getEntry(); + } + + @Override + public boolean onUsedByWand(EntityPlayer player, ItemStack stack, World world, int x, int y, int z, int side) { + return ((TileSpecialFlower) world.getTileEntity(x, y, z)).onWanded(stack, player); + } + + @Override + public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase entity, ItemStack stack) { + ((TileSpecialFlower) world.getTileEntity(x, y, z)).onBlockPlacedBy(world, x, y, z, entity, stack); + } + + @Override + public void onBlockAdded(World world, int x, int y, int z) { + ((TileSpecialFlower) world.getTileEntity(x, y, z)).onBlockAdded(world, x, y, z); + } + + @Override + public int colorMultiplier(IBlockAccess world, int x, int y, int z) { + float[] rgb = EntitySheep.fleeceColorTable[world.getBlockMetadata(x, y, z)]; + return ((int) (rgb[0] * 255) << 16) + ((int) (rgb[1] * 255) << 8) + (int) (rgb[2] * 255); + } + + @Override + public boolean onBlockActivated( + World world, int x, int y, int z, EntityPlayer player, int side, float hitX, float hitY, float hitZ) { + ItemStack stack = player.getCurrentEquippedItem(); + if (stack != null && stack.getItem() == ModItems.dye) { + int newMeta = stack.getItemDamage(); + int oldMeta = world.getBlockMetadata(x, y, z); + if (newMeta != oldMeta) world.setBlockMetadataWithNotify(x, y, z, newMeta, 1 | 2); + } + + return ((TileSpecialFlower) world.getTileEntity(x, y, z)) + .onBlockActivated(world, x, y, z, player, side, hitX, hitY, hitZ); + } + + @Override + public void renderHUD(Minecraft mc, ScaledResolution res, World world, int x, int y, int z) { + ((TileSpecialFlower) world.getTileEntity(x, y, z)).renderHUD(mc, res); + } } diff --git a/src/main/java/vazkii/botania/common/block/BlockStorage.java b/src/main/java/vazkii/botania/common/block/BlockStorage.java index bf35e1173b..743c90c461 100644 --- a/src/main/java/vazkii/botania/common/block/BlockStorage.java +++ b/src/main/java/vazkii/botania/common/block/BlockStorage.java @@ -2,16 +2,18 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [May 14, 2014, 8:37:26 PM (GMT)] */ package vazkii.botania.common.block; +import cpw.mods.fml.common.registry.GameRegistry; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; import java.util.List; - import net.minecraft.block.Block; import net.minecraft.block.material.Material; import net.minecraft.client.renderer.texture.IIconRegister; @@ -28,68 +30,62 @@ import vazkii.botania.common.item.block.ItemBlockStorage; import vazkii.botania.common.lexicon.LexiconData; import vazkii.botania.common.lib.LibBlockNames; -import cpw.mods.fml.common.registry.GameRegistry; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; public class BlockStorage extends BlockMod implements ILexiconable { - private static final int SUBTYPES = 5; - - IIcon[] icons; + private static final int SUBTYPES = 5; - public BlockStorage() { - super(Material.iron); - setHardness(3F); - setResistance(10F); - setStepSound(soundTypeMetal); - setBlockName(LibBlockNames.STORAGE); - } + IIcon[] icons; - @Override - public void getSubBlocks(Item par1, CreativeTabs par2, List par3) { - for(int i = 0; i < SUBTYPES; i++) - par3.add(new ItemStack(par1, 1, i)); - } + public BlockStorage() { + super(Material.iron); + setHardness(3F); + setResistance(10F); + setStepSound(soundTypeMetal); + setBlockName(LibBlockNames.STORAGE); + } - @Override - public Block setBlockName(String par1Str) { - GameRegistry.registerBlock(this, ItemBlockStorage.class, par1Str); - return super.setBlockName(par1Str); - } + @Override + public void getSubBlocks(Item par1, CreativeTabs par2, List par3) { + for (int i = 0; i < SUBTYPES; i++) par3.add(new ItemStack(par1, 1, i)); + } - @Override - public int damageDropped(int meta) { - return meta; - } + @Override + public Block setBlockName(String par1Str) { + GameRegistry.registerBlock(this, ItemBlockStorage.class, par1Str); + return super.setBlockName(par1Str); + } - @Override - protected boolean shouldRegisterInNameSet() { - return false; - } + @Override + public int damageDropped(int meta) { + return meta; + } - @Override - @SideOnly(Side.CLIENT) - public void registerBlockIcons(IIconRegister par1IconRegister) { - icons = new IIcon[SUBTYPES]; - for(int i = 0; i < icons.length; i++) - icons[i] = IconHelper.forBlock(par1IconRegister, this, i); - } + @Override + protected boolean shouldRegisterInNameSet() { + return false; + } - @Override - public IIcon getIcon(int par1, int par2) { - return icons[Math.min(icons.length - 1, par2)]; - } + @Override + @SideOnly(Side.CLIENT) + public void registerBlockIcons(IIconRegister par1IconRegister) { + icons = new IIcon[SUBTYPES]; + for (int i = 0; i < icons.length; i++) icons[i] = IconHelper.forBlock(par1IconRegister, this, i); + } - @Override - public boolean isBeaconBase(IBlockAccess worldObj, int x, int y, int z, int beaconX, int beaconY, int beaconZ) { - return true; - } + @Override + public IIcon getIcon(int par1, int par2) { + return icons[Math.min(icons.length - 1, par2)]; + } - @Override - public LexiconEntry getEntry(World world, int x, int y, int z, EntityPlayer player, ItemStack lexicon) { - int meta = world.getBlockMetadata(x, y, z); - return meta == 0 ? LexiconData.pool : LexiconData.terrasteel; - } + @Override + public boolean isBeaconBase(IBlockAccess worldObj, int x, int y, int z, int beaconX, int beaconY, int beaconZ) { + return true; + } + @Override + public LexiconEntry getEntry(World world, int x, int y, int z, EntityPlayer player, ItemStack lexicon) { + int meta = world.getBlockMetadata(x, y, z); + return meta == 0 ? LexiconData.pool : LexiconData.terrasteel; + } } diff --git a/src/main/java/vazkii/botania/common/block/BlockTeruTeruBozu.java b/src/main/java/vazkii/botania/common/block/BlockTeruTeruBozu.java index 30e15f7177..1a1b7a419f 100644 --- a/src/main/java/vazkii/botania/common/block/BlockTeruTeruBozu.java +++ b/src/main/java/vazkii/botania/common/block/BlockTeruTeruBozu.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Oct 1, 2015, 1:11:26 PM (GMT)] */ package vazkii.botania.common.block; @@ -30,105 +30,102 @@ public class BlockTeruTeruBozu extends BlockModContainer implements ILexiconable { - public BlockTeruTeruBozu() { - super(Material.cloth); - setBlockName(LibBlockNames.TERU_TERU_BOZU); - float f = 0.25F; - setBlockBounds(f, 0.01F, f, 1F - f, 0.99F, 1F - f); - } - - @Override - public void onEntityCollidedWithBlock(World world, int x, int y, int z, Entity e) { - if(!world.isRemote && e instanceof EntityItem) { - EntityItem item = (EntityItem) e; - ItemStack stack = item.getEntityItem(); - if(isSunflower(stack) && removeRain(world)) { - stack.stackSize--; - if(stack.stackSize == 0) - e.setDead(); - } - } - } - - @Override - public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int s, float xs, float ys, float zs) { - ItemStack stack = player.getCurrentEquippedItem(); - if(stack != null && (isSunflower(stack) && removeRain(world) || isBlueOrchid(stack) && startRain(world))) { - if(!player.capabilities.isCreativeMode) - stack.stackSize--; - return true; - } - return false; - } - - public boolean isSunflower(ItemStack stack) { - return stack.getItem() == Item.getItemFromBlock(Blocks.double_plant) && stack.getItemDamage() == 0; - } - - public boolean isBlueOrchid(ItemStack stack) { - return stack.getItem() == Item.getItemFromBlock(Blocks.red_flower) && stack.getItemDamage() == 1; - } - - public boolean removeRain(World world) { - if(world.isRaining()) { - world.getWorldInfo().setRaining(false); - return true; - } - return false; - } - - public boolean startRain(World world) { - if(!world.isRaining()) { - if(world.rand.nextInt(10) == 0) - world.getWorldInfo().setRaining(true); - return true; - } - return false; - } - - @Override - public boolean hasComparatorInputOverride() { - return true; - } - - @Override - public int getComparatorInputOverride(World world, int x, int y, int z, int s) { - return world.isRaining() ? 15 : 0; - } - - @Override - public void registerBlockIcons(IIconRegister par1IconRegister) { - // NO-OP - } - - @Override - public IIcon getIcon(int side, int meta) { - return Blocks.wool.getIcon(0, 0); - } - - @Override - public boolean isOpaqueCube() { - return false; - } - - @Override - public boolean renderAsNormalBlock() { - return false; - } - - @Override - public int getRenderType() { - return LibRenderIDs.idTeruTeruBozu; - } - - @Override - public TileEntity createNewTileEntity(World world, int meta) { - return new TileTeruTeruBozu(); - } - - @Override - public LexiconEntry getEntry(World world, int x, int y, int z, EntityPlayer player, ItemStack lexicon) { - return LexiconData.teruTeruBozu; - } - + public BlockTeruTeruBozu() { + super(Material.cloth); + setBlockName(LibBlockNames.TERU_TERU_BOZU); + float f = 0.25F; + setBlockBounds(f, 0.01F, f, 1F - f, 0.99F, 1F - f); + } + + @Override + public void onEntityCollidedWithBlock(World world, int x, int y, int z, Entity e) { + if (!world.isRemote && e instanceof EntityItem) { + EntityItem item = (EntityItem) e; + ItemStack stack = item.getEntityItem(); + if (isSunflower(stack) && removeRain(world)) { + stack.stackSize--; + if (stack.stackSize == 0) e.setDead(); + } + } + } + + @Override + public boolean onBlockActivated( + World world, int x, int y, int z, EntityPlayer player, int s, float xs, float ys, float zs) { + ItemStack stack = player.getCurrentEquippedItem(); + if (stack != null && (isSunflower(stack) && removeRain(world) || isBlueOrchid(stack) && startRain(world))) { + if (!player.capabilities.isCreativeMode) stack.stackSize--; + return true; + } + return false; + } + + public boolean isSunflower(ItemStack stack) { + return stack.getItem() == Item.getItemFromBlock(Blocks.double_plant) && stack.getItemDamage() == 0; + } + + public boolean isBlueOrchid(ItemStack stack) { + return stack.getItem() == Item.getItemFromBlock(Blocks.red_flower) && stack.getItemDamage() == 1; + } + + public boolean removeRain(World world) { + if (world.isRaining()) { + world.getWorldInfo().setRaining(false); + return true; + } + return false; + } + + public boolean startRain(World world) { + if (!world.isRaining()) { + if (world.rand.nextInt(10) == 0) world.getWorldInfo().setRaining(true); + return true; + } + return false; + } + + @Override + public boolean hasComparatorInputOverride() { + return true; + } + + @Override + public int getComparatorInputOverride(World world, int x, int y, int z, int s) { + return world.isRaining() ? 15 : 0; + } + + @Override + public void registerBlockIcons(IIconRegister par1IconRegister) { + // NO-OP + } + + @Override + public IIcon getIcon(int side, int meta) { + return Blocks.wool.getIcon(0, 0); + } + + @Override + public boolean isOpaqueCube() { + return false; + } + + @Override + public boolean renderAsNormalBlock() { + return false; + } + + @Override + public int getRenderType() { + return LibRenderIDs.idTeruTeruBozu; + } + + @Override + public TileEntity createNewTileEntity(World world, int meta) { + return new TileTeruTeruBozu(); + } + + @Override + public LexiconEntry getEntry(World world, int x, int y, int z, EntityPlayer player, ItemStack lexicon) { + return LexiconData.teruTeruBozu; + } } diff --git a/src/main/java/vazkii/botania/common/block/BlockTinyPlanet.java b/src/main/java/vazkii/botania/common/block/BlockTinyPlanet.java index 6720700cf5..1ea0075494 100644 --- a/src/main/java/vazkii/botania/common/block/BlockTinyPlanet.java +++ b/src/main/java/vazkii/botania/common/block/BlockTinyPlanet.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [May 1, 2014, 3:49:12 PM (GMT)] */ package vazkii.botania.common.block; @@ -23,34 +23,33 @@ public class BlockTinyPlanet extends BlockModContainer implements ILexiconable { - protected BlockTinyPlanet() { - super(Material.rock); - setHardness(20F); - setResistance(100F); - setStepSound(soundTypeStone); - float size = 3F / 16F; - setBlockBounds(size, size, size, 1F - size, 1F - size, 1F - size); - setBlockName(LibBlockNames.TINY_PLANET); - } - - @Override - public boolean renderAsNormalBlock() { - return false; - } - - @Override - public boolean isOpaqueCube() { - return false; - } - - @Override - public TileEntity createNewTileEntity(World world, int meta) { - return new TileTinyPlanet(); - } - - @Override - public LexiconEntry getEntry(World world, int x, int y, int z, EntityPlayer player, ItemStack lexicon) { - return LexiconData.tinyPlanet; - } - + protected BlockTinyPlanet() { + super(Material.rock); + setHardness(20F); + setResistance(100F); + setStepSound(soundTypeStone); + float size = 3F / 16F; + setBlockBounds(size, size, size, 1F - size, 1F - size, 1F - size); + setBlockName(LibBlockNames.TINY_PLANET); + } + + @Override + public boolean renderAsNormalBlock() { + return false; + } + + @Override + public boolean isOpaqueCube() { + return false; + } + + @Override + public TileEntity createNewTileEntity(World world, int meta) { + return new TileTinyPlanet(); + } + + @Override + public LexiconEntry getEntry(World world, int x, int y, int z, EntityPlayer player, ItemStack lexicon) { + return LexiconData.tinyPlanet; + } } diff --git a/src/main/java/vazkii/botania/common/block/ModBlocks.java b/src/main/java/vazkii/botania/common/block/ModBlocks.java index 075722c82e..ff4057c117 100644 --- a/src/main/java/vazkii/botania/common/block/ModBlocks.java +++ b/src/main/java/vazkii/botania/common/block/ModBlocks.java @@ -2,14 +2,16 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jan 14, 2014, 5:17:55 PM (GMT)] */ package vazkii.botania.common.block; +import cpw.mods.fml.common.Loader; +import cpw.mods.fml.common.registry.GameRegistry; import net.minecraft.block.Block; import net.minecraft.block.BlockDispenser; import net.minecraft.init.Blocks; @@ -173,370 +175,371 @@ import vazkii.botania.common.item.ModItems; import vazkii.botania.common.lib.LibBlockNames; import vazkii.botania.common.lib.LibOreDict; -import cpw.mods.fml.common.Loader; -import cpw.mods.fml.common.registry.GameRegistry; public final class ModBlocks { - public static Block flower; - public static Block altar; - public static Block livingrock; - public static Block livingwood; - public static Block specialFlower; - public static Block spreader; - public static Block pool; - public static Block runeAltar; - public static Block unstableBlock; - public static Block pylon; - public static Block pistonRelay; - public static Block distributor; - public static Block manaBeacon; - public static Block manaVoid; - public static Block manaDetector; - public static Block enchanter; - public static Block turntable; - public static Block tinyPlanet; - public static Block alchemyCatalyst; - public static Block openCrate; - public static Block forestEye; - public static Block storage; - public static Block forestDrum; - public static Block shinyFlower; - public static Block platform; - public static Block alfPortal; - public static Block dreamwood; - public static Block conjurationCatalyst; - public static Block bifrost; - public static Block solidVines; - public static Block buriedPetals; - public static Block prismarine; - public static Block seaLamp; - public static Block floatingFlower; - public static Block tinyPotato; - public static Block spawnerClaw; - public static Block reedBlock; - public static Block thatch; - public static Block customBrick; - public static Block enderEye; - public static Block starfield; - public static Block rfGenerator; - public static Block elfGlass; - public static Block brewery; - public static Block manaGlass; - public static Block terraPlate; - public static Block redStringContainer; - public static Block redStringDispenser; - public static Block redStringFertilizer; - public static Block redStringComparator; - public static Block redStringRelay; - public static Block floatingSpecialFlower; - public static Block manaFlame; - public static Block prism; - public static Block dirtPath; - public static Block enchantedSoil; - public static Block petalBlock; - public static Block corporeaIndex; - public static Block corporeaFunnel; - public static Block endStoneBrick; - public static Block mushroom; - public static Block pump; - public static Block doubleFlower1; - public static Block doubleFlower2; - public static Block fakeAir; - public static Block blazeBlock; - public static Block corporeaInterceptor; - public static Block corporeaCrystalCube; - public static Block incensePlate; - public static Block hourglass; - public static Block ghostRail; - public static Block sparkChanger; - public static Block root; - public static Block felPumpkin; - public static Block cocoon; - public static Block lightRelay; - public static Block lightLauncher; - public static Block manaBomb; - public static Block cacophonium; - public static Block bellows; - public static Block bifrostPerm; - public static Block cellBlock; - public static Block redStringInterceptor; - public static Block gaiaHead; - public static Block corporeaRetainer; - public static Block teruTeruBozu; - public static Block shimmerrock; - public static Block shimmerwoodPlanks; - public static Block avatar; - public static Block altGrass; - - public static void init() { - flower = new BlockModFlower(); - altar = new BlockAltar(); - livingrock = new BlockLivingrock(); - livingwood = new BlockLivingwood(); - specialFlower = new BlockSpecialFlower(); - spreader = new BlockSpreader(); - pool = new BlockPool(); - runeAltar = new BlockRuneAltar(); - unstableBlock = new BlockUnstable(); - pylon = new BlockPylon(); - pistonRelay = new BlockPistonRelay(); - distributor = new BlockDistributor(); - manaBeacon = new BlockManaBeacon(); - manaVoid = new BlockManaVoid(); - manaDetector = new BlockManaDetector(); - enchanter = new BlockEnchanter(); - turntable = new BlockTurntable(); - tinyPlanet = new BlockTinyPlanet(); - alchemyCatalyst = new BlockAlchemyCatalyst(); - openCrate = new BlockOpenCrate(); - forestEye = new BlockForestEye(); - storage = new BlockStorage(); - forestDrum = new BlockForestDrum(); - shinyFlower = new BlockShinyFlower(); - platform = new BlockPlatform(); - alfPortal = new BlockAlfPortal(); - dreamwood = new BlockDreamwood(); - conjurationCatalyst = new BlockConjurationCatalyst(); - bifrost = new BlockBifrost(); - solidVines = new BlockSolidVines(); - buriedPetals = new BlockBuriedPetals(); - prismarine = new BlockPrismarine(); - seaLamp = new BlockSeaLamp(); - floatingFlower = new BlockFloatingFlower(); - tinyPotato = new BlockTinyPotato(); - spawnerClaw = new BlockSpawnerClaw(); - reedBlock = new BlockReeds(); - thatch = new BlockThatch(); - customBrick = new BlockCustomBrick(); - enderEye = new BlockEnderEye(); - starfield = new BlockStarfield(); - rfGenerator = new BlockRFGenerator(); - elfGlass = new BlockElfGlass(); - brewery = new BlockBrewery(); - manaGlass = new BlockManaGlass(); - terraPlate = new BlockTerraPlate(); - redStringContainer = new BlockRedStringContainer(); - redStringDispenser = new BlockRedStringDispenser(); - redStringFertilizer = new BlockRedStringFertilizer(); - redStringComparator = new BlockRedStringComparator(); - redStringRelay = new BlockRedStringRelay(); - floatingSpecialFlower = new BlockFloatingSpecialFlower(); - manaFlame = new BlockManaFlame(); - prism = new BlockPrism(); - dirtPath = new BlockDirtPath(); - enchantedSoil = new BlockEnchantedSoil(); - petalBlock = new BlockPetalBlock(); - corporeaIndex = new BlockCorporeaIndex(); - corporeaFunnel = new BlockCorporeaFunnel(); - endStoneBrick = new BlockEndStoneBrick(); - mushroom = new BlockModMushroom(); - pump = new BlockPump(); - doubleFlower1 = new BlockModDoubleFlower(false); - doubleFlower2 = new BlockModDoubleFlower(true); - fakeAir = new BlockFakeAir(); - blazeBlock = new BlockBlaze(); - corporeaInterceptor = new BlockCorporeaInterceptor(); - corporeaCrystalCube = new BlockCorporeaCrystalCube(); - incensePlate = new BlockIncensePlate(); - hourglass = new BlockHourglass(); - ghostRail = new BlockGhostRail(); - sparkChanger = new BlockSparkChanger(); - root = new BlockRoot(); - felPumpkin = new BlockFelPumpkin(); - cocoon = new BlockCocoon(); - lightRelay = new BlockLightRelay(); - lightLauncher = new BlockLightLauncher(); - manaBomb = new BlockManaBomb(); - cacophonium = new BlockCacophonium(); - bellows = new BlockBellows(); - bifrostPerm = new BlockBifrostPerm(); - cellBlock = new BlockCell(); - redStringInterceptor = new BlockRedStringInterceptor(); - gaiaHead = new BlockGaiaHead(); - corporeaRetainer = new BlockCorporeaRetainer(); - teruTeruBozu = new BlockTeruTeruBozu(); - shimmerrock = new BlockShimmerrock(); - shimmerwoodPlanks = new BlockShimmerwoodPlanks(); - avatar = new BlockAvatar(); - altGrass = new BlockAltGrass(); + public static Block flower; + public static Block altar; + public static Block livingrock; + public static Block livingwood; + public static Block specialFlower; + public static Block spreader; + public static Block pool; + public static Block runeAltar; + public static Block unstableBlock; + public static Block pylon; + public static Block pistonRelay; + public static Block distributor; + public static Block manaBeacon; + public static Block manaVoid; + public static Block manaDetector; + public static Block enchanter; + public static Block turntable; + public static Block tinyPlanet; + public static Block alchemyCatalyst; + public static Block openCrate; + public static Block forestEye; + public static Block storage; + public static Block forestDrum; + public static Block shinyFlower; + public static Block platform; + public static Block alfPortal; + public static Block dreamwood; + public static Block conjurationCatalyst; + public static Block bifrost; + public static Block solidVines; + public static Block buriedPetals; + public static Block prismarine; + public static Block seaLamp; + public static Block floatingFlower; + public static Block tinyPotato; + public static Block spawnerClaw; + public static Block reedBlock; + public static Block thatch; + public static Block customBrick; + public static Block enderEye; + public static Block starfield; + public static Block rfGenerator; + public static Block elfGlass; + public static Block brewery; + public static Block manaGlass; + public static Block terraPlate; + public static Block redStringContainer; + public static Block redStringDispenser; + public static Block redStringFertilizer; + public static Block redStringComparator; + public static Block redStringRelay; + public static Block floatingSpecialFlower; + public static Block manaFlame; + public static Block prism; + public static Block dirtPath; + public static Block enchantedSoil; + public static Block petalBlock; + public static Block corporeaIndex; + public static Block corporeaFunnel; + public static Block endStoneBrick; + public static Block mushroom; + public static Block pump; + public static Block doubleFlower1; + public static Block doubleFlower2; + public static Block fakeAir; + public static Block blazeBlock; + public static Block corporeaInterceptor; + public static Block corporeaCrystalCube; + public static Block incensePlate; + public static Block hourglass; + public static Block ghostRail; + public static Block sparkChanger; + public static Block root; + public static Block felPumpkin; + public static Block cocoon; + public static Block lightRelay; + public static Block lightLauncher; + public static Block manaBomb; + public static Block cacophonium; + public static Block bellows; + public static Block bifrostPerm; + public static Block cellBlock; + public static Block redStringInterceptor; + public static Block gaiaHead; + public static Block corporeaRetainer; + public static Block teruTeruBozu; + public static Block shimmerrock; + public static Block shimmerwoodPlanks; + public static Block avatar; + public static Block altGrass; - ModFluffBlocks.init(); + public static void init() { + flower = new BlockModFlower(); + altar = new BlockAltar(); + livingrock = new BlockLivingrock(); + livingwood = new BlockLivingwood(); + specialFlower = new BlockSpecialFlower(); + spreader = new BlockSpreader(); + pool = new BlockPool(); + runeAltar = new BlockRuneAltar(); + unstableBlock = new BlockUnstable(); + pylon = new BlockPylon(); + pistonRelay = new BlockPistonRelay(); + distributor = new BlockDistributor(); + manaBeacon = new BlockManaBeacon(); + manaVoid = new BlockManaVoid(); + manaDetector = new BlockManaDetector(); + enchanter = new BlockEnchanter(); + turntable = new BlockTurntable(); + tinyPlanet = new BlockTinyPlanet(); + alchemyCatalyst = new BlockAlchemyCatalyst(); + openCrate = new BlockOpenCrate(); + forestEye = new BlockForestEye(); + storage = new BlockStorage(); + forestDrum = new BlockForestDrum(); + shinyFlower = new BlockShinyFlower(); + platform = new BlockPlatform(); + alfPortal = new BlockAlfPortal(); + dreamwood = new BlockDreamwood(); + conjurationCatalyst = new BlockConjurationCatalyst(); + bifrost = new BlockBifrost(); + solidVines = new BlockSolidVines(); + buriedPetals = new BlockBuriedPetals(); + prismarine = new BlockPrismarine(); + seaLamp = new BlockSeaLamp(); + floatingFlower = new BlockFloatingFlower(); + tinyPotato = new BlockTinyPotato(); + spawnerClaw = new BlockSpawnerClaw(); + reedBlock = new BlockReeds(); + thatch = new BlockThatch(); + customBrick = new BlockCustomBrick(); + enderEye = new BlockEnderEye(); + starfield = new BlockStarfield(); + rfGenerator = new BlockRFGenerator(); + elfGlass = new BlockElfGlass(); + brewery = new BlockBrewery(); + manaGlass = new BlockManaGlass(); + terraPlate = new BlockTerraPlate(); + redStringContainer = new BlockRedStringContainer(); + redStringDispenser = new BlockRedStringDispenser(); + redStringFertilizer = new BlockRedStringFertilizer(); + redStringComparator = new BlockRedStringComparator(); + redStringRelay = new BlockRedStringRelay(); + floatingSpecialFlower = new BlockFloatingSpecialFlower(); + manaFlame = new BlockManaFlame(); + prism = new BlockPrism(); + dirtPath = new BlockDirtPath(); + enchantedSoil = new BlockEnchantedSoil(); + petalBlock = new BlockPetalBlock(); + corporeaIndex = new BlockCorporeaIndex(); + corporeaFunnel = new BlockCorporeaFunnel(); + endStoneBrick = new BlockEndStoneBrick(); + mushroom = new BlockModMushroom(); + pump = new BlockPump(); + doubleFlower1 = new BlockModDoubleFlower(false); + doubleFlower2 = new BlockModDoubleFlower(true); + fakeAir = new BlockFakeAir(); + blazeBlock = new BlockBlaze(); + corporeaInterceptor = new BlockCorporeaInterceptor(); + corporeaCrystalCube = new BlockCorporeaCrystalCube(); + incensePlate = new BlockIncensePlate(); + hourglass = new BlockHourglass(); + ghostRail = new BlockGhostRail(); + sparkChanger = new BlockSparkChanger(); + root = new BlockRoot(); + felPumpkin = new BlockFelPumpkin(); + cocoon = new BlockCocoon(); + lightRelay = new BlockLightRelay(); + lightLauncher = new BlockLightLauncher(); + manaBomb = new BlockManaBomb(); + cacophonium = new BlockCacophonium(); + bellows = new BlockBellows(); + bifrostPerm = new BlockBifrostPerm(); + cellBlock = new BlockCell(); + redStringInterceptor = new BlockRedStringInterceptor(); + gaiaHead = new BlockGaiaHead(); + corporeaRetainer = new BlockCorporeaRetainer(); + teruTeruBozu = new BlockTeruTeruBozu(); + shimmerrock = new BlockShimmerrock(); + shimmerwoodPlanks = new BlockShimmerwoodPlanks(); + avatar = new BlockAvatar(); + altGrass = new BlockAltGrass(); - for(int i = 0; i < 16; i++) - OreDictionary.registerOre(LibOreDict.FLOWER[i], new ItemStack(flower, 1, i)); + ModFluffBlocks.init(); - OreDictionary.registerOre(LibOreDict.LIVING_ROCK, livingrock); - OreDictionary.registerOre(LibOreDict.LIVING_WOOD, livingwood); - OreDictionary.registerOre(LibOreDict.DREAM_WOOD, dreamwood); + for (int i = 0; i < 16; i++) OreDictionary.registerOre(LibOreDict.FLOWER[i], new ItemStack(flower, 1, i)); - for(int i = 0; i < 8; i++) { - OreDictionary.registerOre(LibOreDict.DOUBLE_FLOWER[i], new ItemStack(doubleFlower1, 1, i)); - OreDictionary.registerOre(LibOreDict.DOUBLE_FLOWER[i + 8], new ItemStack(doubleFlower2, 1, i)); - } + OreDictionary.registerOre(LibOreDict.LIVING_ROCK, livingrock); + OreDictionary.registerOre(LibOreDict.LIVING_WOOD, livingwood); + OreDictionary.registerOre(LibOreDict.DREAM_WOOD, dreamwood); - OreDictionary.registerOre(LibOreDict.PRISMARINE_BLOCK, new ItemStack(prismarine, 1, OreDictionary.WILDCARD_VALUE)); - OreDictionary.registerOre(LibOreDict.BLAZE_BLOCK, blazeBlock); + for (int i = 0; i < 8; i++) { + OreDictionary.registerOre(LibOreDict.DOUBLE_FLOWER[i], new ItemStack(doubleFlower1, 1, i)); + OreDictionary.registerOre(LibOreDict.DOUBLE_FLOWER[i + 8], new ItemStack(doubleFlower2, 1, i)); + } - for(int i = 0; i < 16; i++) - OreDictionary.registerOre(LibOreDict.STONE_18_VARIANTS[i], new ItemStack(ModFluffBlocks.stone, 1, i)); + OreDictionary.registerOre( + LibOreDict.PRISMARINE_BLOCK, new ItemStack(prismarine, 1, OreDictionary.WILDCARD_VALUE)); + OreDictionary.registerOre(LibOreDict.BLAZE_BLOCK, blazeBlock); - // Vanilla OreDict entries - OreDictionary.registerOre("dirt", Blocks.dirt); - OreDictionary.registerOre("grass", Blocks.grass); - OreDictionary.registerOre("sand", Block.getBlockFromName("sand")); - OreDictionary.registerOre("gravel", Block.getBlockFromName("gravel")); - OreDictionary.registerOre("hardenedClay", new ItemStack(Blocks.hardened_clay, 1, OreDictionary.WILDCARD_VALUE)); - OreDictionary.registerOre("snowLayer", Blocks.snow_layer); - OreDictionary.registerOre("mycelium", Blocks.mycelium); - OreDictionary.registerOre("podzol", new ItemStack(Blocks.dirt, 1, 2)); - OreDictionary.registerOre("netherrack", Blocks.netherrack); - OreDictionary.registerOre("soulSand", Blocks.soul_sand); - OreDictionary.registerOre("ice", Blocks.ice); - OreDictionary.registerOre("slabCobblestone", new ItemStack(Blocks.stone_slab, 1, 3)); - OreDictionary.registerOre("chestWood", Blocks.chest); - OreDictionary.registerOre("craftingTableWood", Blocks.crafting_table); + for (int i = 0; i < 16; i++) + OreDictionary.registerOre(LibOreDict.STONE_18_VARIANTS[i], new ItemStack(ModFluffBlocks.stone, 1, i)); - BotaniaAPI.registerPaintableBlock(unstableBlock); - BotaniaAPI.registerPaintableBlock(manaBeacon); + // Vanilla OreDict entries + OreDictionary.registerOre("dirt", Blocks.dirt); + OreDictionary.registerOre("grass", Blocks.grass); + OreDictionary.registerOre("sand", Block.getBlockFromName("sand")); + OreDictionary.registerOre("gravel", Block.getBlockFromName("gravel")); + OreDictionary.registerOre("hardenedClay", new ItemStack(Blocks.hardened_clay, 1, OreDictionary.WILDCARD_VALUE)); + OreDictionary.registerOre("snowLayer", Blocks.snow_layer); + OreDictionary.registerOre("mycelium", Blocks.mycelium); + OreDictionary.registerOre("podzol", new ItemStack(Blocks.dirt, 1, 2)); + OreDictionary.registerOre("netherrack", Blocks.netherrack); + OreDictionary.registerOre("soulSand", Blocks.soul_sand); + OreDictionary.registerOre("ice", Blocks.ice); + OreDictionary.registerOre("slabCobblestone", new ItemStack(Blocks.stone_slab, 1, 3)); + OreDictionary.registerOre("chestWood", Blocks.chest); + OreDictionary.registerOre("craftingTableWood", Blocks.crafting_table); - initTileEntities(); - } + BotaniaAPI.registerPaintableBlock(unstableBlock); + BotaniaAPI.registerPaintableBlock(manaBeacon); - public static void addDispenserBehaviours() { - for(Item seed : BotaniaAPI.seeds.keySet()) - BlockDispenser.dispenseBehaviorRegistry.putObject(seed, new BehaviourSeeds(BotaniaAPI.seeds.get(seed))); - BlockDispenser.dispenseBehaviorRegistry.putObject(ModItems.twigWand, new BehaviourWand()); - BlockDispenser.dispenseBehaviorRegistry.putObject(ModItems.poolMinecart, new BehaviourPoolMinecart()); - } + initTileEntities(); + } - private static void initTileEntities() { - registerTile(TileAltar.class, LibBlockNames.ALTAR); - registerTile(TileSpecialFlower.class, LibBlockNames.SPECIAL_FLOWER); - registerTile(TileSpreader.class, LibBlockNames.SPREADER); - registerTile(TilePool.class, LibBlockNames.POOL); - registerTile(TileRuneAltar.class, LibBlockNames.RUNE_ALTAR); - registerTile(TilePylon.class, LibBlockNames.PYLON); - registerTile(TileDistributor.class, LibBlockNames.DISTRIBUTOR); - registerTile(TileManaBeacon.class, LibBlockNames.MANA_BEACON); - registerTile(TileManaVoid.class, LibBlockNames.MANA_VOID); - registerTile(TileManaDetector.class, LibBlockNames.MANA_DETECTOR); - registerTile(TileEnchanter.class, LibBlockNames.ENCHANTER); - registerTile(TileTurntable.class, LibBlockNames.TURNTABLE); - registerTile(TileTinyPlanet.class, LibBlockNames.TINY_PLANET); - registerTile(TileOpenCrate.class, LibBlockNames.OPEN_CRATE); - registerTile(TileCraftCrate.class, LibBlockNames.CRAFT_CRATE); - registerTile(TileForestEye.class, LibBlockNames.FOREST_EYE); - registerTile(TilePlatform.class, LibBlockNames.PLATFORM); - registerTile(TileAlfPortal.class, LibBlockNames.ALF_PORTAL); - registerTile(TileBifrost.class, LibBlockNames.BIFROST); - registerTile(TileFloatingFlower.class, LibBlockNames.MINI_ISLAND); - registerTile(TileTinyPotato.class, LibBlockNames.TINY_POTATO); - registerTile(TileSpawnerClaw.class, LibBlockNames.SPAWNER_CLAW); - registerTile(TileEnderEye.class, LibBlockNames.ENDER_EYE_BLOCK); - registerTile(TileStarfield.class, LibBlockNames.STARFIELD); - registerTile(TileRFGenerator.class, LibBlockNames.RF_GENERATOR); - registerTile(TileBrewery.class, LibBlockNames.BREWERY); - registerTile(TileTerraPlate.class, LibBlockNames.TERRA_PLATE); - registerTile(TileRedStringContainer.class, LibBlockNames.RED_STRING_CONTAINER); - registerTile(TileRedStringDispenser.class, LibBlockNames.RED_STRING_DISPENSER); - registerTile(TileRedStringFertilizer.class, LibBlockNames.RED_STRING_FERTILIZER); - registerTile(TileRedStringComparator.class, LibBlockNames.RED_STRING_COMPARATOR); - registerTile(TileRedStringRelay.class, LibBlockNames.RED_STRING_RELAY); - registerTile(TileFloatingSpecialFlower.class, LibBlockNames.FLOATING_SPECIAL_FLOWER); - registerTile(TileManaFlame.class, LibBlockNames.MANA_FLAME); - registerTile(TilePrism.class, LibBlockNames.PRISM); - registerTile(TileCorporeaIndex.class, LibBlockNames.CORPOREA_INDEX); - registerTile(TileCorporeaFunnel.class, LibBlockNames.CORPOREA_FUNNEL); - registerTile(TilePump.class, LibBlockNames.PUMP); - registerTile(TileFakeAir.class, LibBlockNames.FAKE_AIR); - registerTile(TileCorporeaInterceptor.class, LibBlockNames.CORPOREA_INTERCEPTOR); - registerTile(TileCorporeaCrystalCube.class, LibBlockNames.CORPOREA_CRYSTAL_CUBE); - registerTile(TileIncensePlate.class, LibBlockNames.INCENSE_PLATE); - registerTile(TileHourglass.class, LibBlockNames.HOURGLASS); - registerTile(TileSparkChanger.class, LibBlockNames.SPARK_CHANGER); - registerTile(TileCocoon.class, LibBlockNames.COCOON); - registerTile(TileLightRelay.class, LibBlockNames.LIGHT_RELAY); - registerTile(TileCacophonium.class, LibBlockNames.CACOPHONIUM); - registerTile(TileBellows.class, LibBlockNames.BELLOWS); - registerTile(TileCell.class, LibBlockNames.CELL_BLOCK); - registerTile(TileRedStringInterceptor.class, LibBlockNames.RED_STRING_INTERCEPTOR); - registerTile(TileGaiaHead.class, LibBlockNames.GAIA_HEAD); - registerTile(TileCorporeaRetainer.class, LibBlockNames.CORPOREA_RETAINER); - registerTile(TileTeruTeruBozu.class, LibBlockNames.TERU_TERU_BOZU); - registerTile(TileAvatar.class, LibBlockNames.AVATAR); + public static void addDispenserBehaviours() { + for (Item seed : BotaniaAPI.seeds.keySet()) + BlockDispenser.dispenseBehaviorRegistry.putObject(seed, new BehaviourSeeds(BotaniaAPI.seeds.get(seed))); + BlockDispenser.dispenseBehaviorRegistry.putObject(ModItems.twigWand, new BehaviourWand()); + BlockDispenser.dispenseBehaviorRegistry.putObject(ModItems.poolMinecart, new BehaviourPoolMinecart()); + } - BotaniaAPI.registerSubTile(LibBlockNames.SUBTILE_PUREDAISY, SubTilePureDaisy.class); - BotaniaAPI.registerSubTile(LibBlockNames.SUBTILE_MANASTAR, SubTileManastar.class); + private static void initTileEntities() { + registerTile(TileAltar.class, LibBlockNames.ALTAR); + registerTile(TileSpecialFlower.class, LibBlockNames.SPECIAL_FLOWER); + registerTile(TileSpreader.class, LibBlockNames.SPREADER); + registerTile(TilePool.class, LibBlockNames.POOL); + registerTile(TileRuneAltar.class, LibBlockNames.RUNE_ALTAR); + registerTile(TilePylon.class, LibBlockNames.PYLON); + registerTile(TileDistributor.class, LibBlockNames.DISTRIBUTOR); + registerTile(TileManaBeacon.class, LibBlockNames.MANA_BEACON); + registerTile(TileManaVoid.class, LibBlockNames.MANA_VOID); + registerTile(TileManaDetector.class, LibBlockNames.MANA_DETECTOR); + registerTile(TileEnchanter.class, LibBlockNames.ENCHANTER); + registerTile(TileTurntable.class, LibBlockNames.TURNTABLE); + registerTile(TileTinyPlanet.class, LibBlockNames.TINY_PLANET); + registerTile(TileOpenCrate.class, LibBlockNames.OPEN_CRATE); + registerTile(TileCraftCrate.class, LibBlockNames.CRAFT_CRATE); + registerTile(TileForestEye.class, LibBlockNames.FOREST_EYE); + registerTile(TilePlatform.class, LibBlockNames.PLATFORM); + registerTile(TileAlfPortal.class, LibBlockNames.ALF_PORTAL); + registerTile(TileBifrost.class, LibBlockNames.BIFROST); + registerTile(TileFloatingFlower.class, LibBlockNames.MINI_ISLAND); + registerTile(TileTinyPotato.class, LibBlockNames.TINY_POTATO); + registerTile(TileSpawnerClaw.class, LibBlockNames.SPAWNER_CLAW); + registerTile(TileEnderEye.class, LibBlockNames.ENDER_EYE_BLOCK); + registerTile(TileStarfield.class, LibBlockNames.STARFIELD); + registerTile(TileRFGenerator.class, LibBlockNames.RF_GENERATOR); + registerTile(TileBrewery.class, LibBlockNames.BREWERY); + registerTile(TileTerraPlate.class, LibBlockNames.TERRA_PLATE); + registerTile(TileRedStringContainer.class, LibBlockNames.RED_STRING_CONTAINER); + registerTile(TileRedStringDispenser.class, LibBlockNames.RED_STRING_DISPENSER); + registerTile(TileRedStringFertilizer.class, LibBlockNames.RED_STRING_FERTILIZER); + registerTile(TileRedStringComparator.class, LibBlockNames.RED_STRING_COMPARATOR); + registerTile(TileRedStringRelay.class, LibBlockNames.RED_STRING_RELAY); + registerTile(TileFloatingSpecialFlower.class, LibBlockNames.FLOATING_SPECIAL_FLOWER); + registerTile(TileManaFlame.class, LibBlockNames.MANA_FLAME); + registerTile(TilePrism.class, LibBlockNames.PRISM); + registerTile(TileCorporeaIndex.class, LibBlockNames.CORPOREA_INDEX); + registerTile(TileCorporeaFunnel.class, LibBlockNames.CORPOREA_FUNNEL); + registerTile(TilePump.class, LibBlockNames.PUMP); + registerTile(TileFakeAir.class, LibBlockNames.FAKE_AIR); + registerTile(TileCorporeaInterceptor.class, LibBlockNames.CORPOREA_INTERCEPTOR); + registerTile(TileCorporeaCrystalCube.class, LibBlockNames.CORPOREA_CRYSTAL_CUBE); + registerTile(TileIncensePlate.class, LibBlockNames.INCENSE_PLATE); + registerTile(TileHourglass.class, LibBlockNames.HOURGLASS); + registerTile(TileSparkChanger.class, LibBlockNames.SPARK_CHANGER); + registerTile(TileCocoon.class, LibBlockNames.COCOON); + registerTile(TileLightRelay.class, LibBlockNames.LIGHT_RELAY); + registerTile(TileCacophonium.class, LibBlockNames.CACOPHONIUM); + registerTile(TileBellows.class, LibBlockNames.BELLOWS); + registerTile(TileCell.class, LibBlockNames.CELL_BLOCK); + registerTile(TileRedStringInterceptor.class, LibBlockNames.RED_STRING_INTERCEPTOR); + registerTile(TileGaiaHead.class, LibBlockNames.GAIA_HEAD); + registerTile(TileCorporeaRetainer.class, LibBlockNames.CORPOREA_RETAINER); + registerTile(TileTeruTeruBozu.class, LibBlockNames.TERU_TERU_BOZU); + registerTile(TileAvatar.class, LibBlockNames.AVATAR); - registerSubTileWithDecor(LibBlockNames.SUBTILE_DAYBLOOM, SubTileDaybloom.class, SubTileDecor.Daybloom.class); - BotaniaAPI.registerSubTile(LibBlockNames.SUBTILE_DAYBLOOM_PRIME, SubTileDaybloom.Prime.class); - BotaniaAPI.registerSubTile(LibBlockNames.SUBTILE_ENDOFLAME, SubTileEndoflame.class); - registerSubTileWithDecor(LibBlockNames.SUBTILE_HYDROANGEAS, SubTileHydroangeas.class, SubTileDecor.Hydroangeas.class); - BotaniaAPI.registerSubTile(LibBlockNames.SUBTILE_THERMALILY, SubTileThermalily.class); - registerSubTileWithDecor(LibBlockNames.SUBTILE_NIGHTSHADE, SubTileNightshade.class, SubTileDecor.Nightshade.class); - BotaniaAPI.registerSubTile(LibBlockNames.SUBTILE_NIGHTSHADE_PRIME, SubTileNightshade.Prime.class); - BotaniaAPI.registerSubTile(LibBlockNames.SUBTILE_ARCANE_ROSE, SubTileArcaneRose.class); - BotaniaAPI.registerSubTile(LibBlockNames.SUBTILE_MUNCHDEW, SubTileMunchdew.class); - BotaniaAPI.registerSubTile(LibBlockNames.SUBTILE_ENTROPINNYUM, SubTileEntropinnyum.class); - BotaniaAPI.registerSubTile(LibBlockNames.SUBTILE_KEKIMURUS, SubTileKekimurus.class); - BotaniaAPI.registerSubTile(LibBlockNames.SUBTILE_GOURMARYLLIS, SubTileGourmaryllis.class); - BotaniaAPI.registerSubTile(LibBlockNames.SUBTILE_NARSLIMMUS, SubTileNarslimmus.class); - BotaniaAPI.registerSubTile(LibBlockNames.SUBTILE_SPECTROLUS, SubTileSpectrolus.class); - BotaniaAPI.registerSubTile(LibBlockNames.SUBTILE_DANDELIFEON, SubTileDandelifeon.class); - BotaniaAPI.registerSubTile(LibBlockNames.SUBTILE_RAFFLOWSIA, SubTileRafflowsia.class); + BotaniaAPI.registerSubTile(LibBlockNames.SUBTILE_PUREDAISY, SubTilePureDaisy.class); + BotaniaAPI.registerSubTile(LibBlockNames.SUBTILE_MANASTAR, SubTileManastar.class); - registerSubTileWithMini(LibBlockNames.SUBTILE_BELLETHORN, SubTileBellethorn.class); - BotaniaAPI.registerSubTile(LibBlockNames.SUBTILE_DREADTHORN, SubTileDreadthorn.class); - BotaniaAPI.registerSubTile(LibBlockNames.SUBTILE_HEISEI_DREAM, SubTileHeiseiDream.class); - BotaniaAPI.registerSubTile(LibBlockNames.SUBTILE_TIGERSEYE, SubTileTigerseye.class); - BotaniaAPI.registerSubTile(LibBlockNames.SUBTILE_JADED_AMARANTHUS, SubTileJadedAmaranthus.class); - BotaniaAPI.registerSubTile(LibBlockNames.SUBTILE_ORECHID, SubTileOrechid.class); - BotaniaAPI.registerSubTile(LibBlockNames.SUBTILE_ORECHID_IGNEM, SubTileOrechidIgnem.class); - BotaniaAPI.registerSubTile(LibBlockNames.SUBTILE_FALLEN_KANADE, SubTileFallenKanade.class); - BotaniaAPI.registerSubTile(LibBlockNames.SUBTILE_EXOFLAME, SubTileExoflame.class); - registerSubTileWithMini(LibBlockNames.SUBTILE_AGRICARNATION, SubTileAgricarnation.class); - registerSubTileWithMini(LibBlockNames.SUBTILE_HOPPERHOCK, SubTileHopperhock.class); - BotaniaAPI.registerSubTile(LibBlockNames.SUBTILE_TANGLEBERRIE, SubTileTangleberrie.class); - BotaniaAPI.registerSubTile(LibBlockNames.SUBTILE_JIYUULIA, SubTileJiyuulia.class); - registerSubTileWithMini(LibBlockNames.SUBTILE_RANNUNCARPUS, SubTileRannuncarpus.class); - BotaniaAPI.registerSubTile(LibBlockNames.SUBTILE_HYACIDUS, SubTileHyacidus.class); - BotaniaAPI.registerSubTile(LibBlockNames.SUBTILE_POLLIDISIAC, SubTilePollidisiac.class); - registerSubTileWithMini(LibBlockNames.SUBTILE_CLAYCONIA, SubTileClayconia.class); - BotaniaAPI.registerSubTile(LibBlockNames.SUBTILE_LOONIUM, SubTileLoonuim.class); - BotaniaAPI.registerSubTile(LibBlockNames.SUBTILE_DAFFOMILL, SubTileDaffomill.class); - BotaniaAPI.registerSubTile(LibBlockNames.SUBTILE_VINCULOTUS, SubTileVinculotus.class); - BotaniaAPI.registerSubTile(LibBlockNames.SUBTILE_SPECTRANTHEMUM, SubTileSpectranthemum.class); - BotaniaAPI.registerSubTile(LibBlockNames.SUBTILE_MEDUMONE, SubTileMedumone.class); - registerSubTileWithMini(LibBlockNames.SUBTILE_MARIMORPHOSIS, SubTileMarimorphosis.class); - registerSubTileWithMini(LibBlockNames.SUBTILE_BUBBELL, SubTileBubbell.class); - registerSubTileWithMini(LibBlockNames.SUBTILE_SOLEGNOLIA, SubTileSolegnolia.class); - } + registerSubTileWithDecor(LibBlockNames.SUBTILE_DAYBLOOM, SubTileDaybloom.class, SubTileDecor.Daybloom.class); + BotaniaAPI.registerSubTile(LibBlockNames.SUBTILE_DAYBLOOM_PRIME, SubTileDaybloom.Prime.class); + BotaniaAPI.registerSubTile(LibBlockNames.SUBTILE_ENDOFLAME, SubTileEndoflame.class); + registerSubTileWithDecor( + LibBlockNames.SUBTILE_HYDROANGEAS, SubTileHydroangeas.class, SubTileDecor.Hydroangeas.class); + BotaniaAPI.registerSubTile(LibBlockNames.SUBTILE_THERMALILY, SubTileThermalily.class); + registerSubTileWithDecor( + LibBlockNames.SUBTILE_NIGHTSHADE, SubTileNightshade.class, SubTileDecor.Nightshade.class); + BotaniaAPI.registerSubTile(LibBlockNames.SUBTILE_NIGHTSHADE_PRIME, SubTileNightshade.Prime.class); + BotaniaAPI.registerSubTile(LibBlockNames.SUBTILE_ARCANE_ROSE, SubTileArcaneRose.class); + BotaniaAPI.registerSubTile(LibBlockNames.SUBTILE_MUNCHDEW, SubTileMunchdew.class); + BotaniaAPI.registerSubTile(LibBlockNames.SUBTILE_ENTROPINNYUM, SubTileEntropinnyum.class); + BotaniaAPI.registerSubTile(LibBlockNames.SUBTILE_KEKIMURUS, SubTileKekimurus.class); + BotaniaAPI.registerSubTile(LibBlockNames.SUBTILE_GOURMARYLLIS, SubTileGourmaryllis.class); + BotaniaAPI.registerSubTile(LibBlockNames.SUBTILE_NARSLIMMUS, SubTileNarslimmus.class); + BotaniaAPI.registerSubTile(LibBlockNames.SUBTILE_SPECTROLUS, SubTileSpectrolus.class); + BotaniaAPI.registerSubTile(LibBlockNames.SUBTILE_DANDELIFEON, SubTileDandelifeon.class); + BotaniaAPI.registerSubTile(LibBlockNames.SUBTILE_RAFFLOWSIA, SubTileRafflowsia.class); - public static void registerMultiparts() { - if(Loader.isModLoaded("ForgeMultipart")) { - try { - Class clazz = Class.forName("vazkii.botania.common.integration.multipart.MultipartHandler"); - clazz.newInstance(); - } catch(Throwable e) {} - } - } + registerSubTileWithMini(LibBlockNames.SUBTILE_BELLETHORN, SubTileBellethorn.class); + BotaniaAPI.registerSubTile(LibBlockNames.SUBTILE_DREADTHORN, SubTileDreadthorn.class); + BotaniaAPI.registerSubTile(LibBlockNames.SUBTILE_HEISEI_DREAM, SubTileHeiseiDream.class); + BotaniaAPI.registerSubTile(LibBlockNames.SUBTILE_TIGERSEYE, SubTileTigerseye.class); + BotaniaAPI.registerSubTile(LibBlockNames.SUBTILE_JADED_AMARANTHUS, SubTileJadedAmaranthus.class); + BotaniaAPI.registerSubTile(LibBlockNames.SUBTILE_ORECHID, SubTileOrechid.class); + BotaniaAPI.registerSubTile(LibBlockNames.SUBTILE_ORECHID_IGNEM, SubTileOrechidIgnem.class); + BotaniaAPI.registerSubTile(LibBlockNames.SUBTILE_FALLEN_KANADE, SubTileFallenKanade.class); + BotaniaAPI.registerSubTile(LibBlockNames.SUBTILE_EXOFLAME, SubTileExoflame.class); + registerSubTileWithMini(LibBlockNames.SUBTILE_AGRICARNATION, SubTileAgricarnation.class); + registerSubTileWithMini(LibBlockNames.SUBTILE_HOPPERHOCK, SubTileHopperhock.class); + BotaniaAPI.registerSubTile(LibBlockNames.SUBTILE_TANGLEBERRIE, SubTileTangleberrie.class); + BotaniaAPI.registerSubTile(LibBlockNames.SUBTILE_JIYUULIA, SubTileJiyuulia.class); + registerSubTileWithMini(LibBlockNames.SUBTILE_RANNUNCARPUS, SubTileRannuncarpus.class); + BotaniaAPI.registerSubTile(LibBlockNames.SUBTILE_HYACIDUS, SubTileHyacidus.class); + BotaniaAPI.registerSubTile(LibBlockNames.SUBTILE_POLLIDISIAC, SubTilePollidisiac.class); + registerSubTileWithMini(LibBlockNames.SUBTILE_CLAYCONIA, SubTileClayconia.class); + BotaniaAPI.registerSubTile(LibBlockNames.SUBTILE_LOONIUM, SubTileLoonuim.class); + BotaniaAPI.registerSubTile(LibBlockNames.SUBTILE_DAFFOMILL, SubTileDaffomill.class); + BotaniaAPI.registerSubTile(LibBlockNames.SUBTILE_VINCULOTUS, SubTileVinculotus.class); + BotaniaAPI.registerSubTile(LibBlockNames.SUBTILE_SPECTRANTHEMUM, SubTileSpectranthemum.class); + BotaniaAPI.registerSubTile(LibBlockNames.SUBTILE_MEDUMONE, SubTileMedumone.class); + registerSubTileWithMini(LibBlockNames.SUBTILE_MARIMORPHOSIS, SubTileMarimorphosis.class); + registerSubTileWithMini(LibBlockNames.SUBTILE_BUBBELL, SubTileBubbell.class); + registerSubTileWithMini(LibBlockNames.SUBTILE_SOLEGNOLIA, SubTileSolegnolia.class); + } - private static void registerSubTileWithMini(String key, Class clazz) { - BotaniaAPI.registerSubTile(key, clazz); + public static void registerMultiparts() { + if (Loader.isModLoaded("ForgeMultipart")) { + try { + Class clazz = Class.forName("vazkii.botania.common.integration.multipart.MultipartHandler"); + clazz.newInstance(); + } catch (Throwable e) { + } + } + } - for(Class innerClazz : clazz.getDeclaredClasses()) - if(innerClazz.getSimpleName().equals("Mini")) - BotaniaAPI.registerMiniSubTile(key + "Chibi", innerClazz, key); - } + private static void registerSubTileWithMini(String key, Class clazz) { + BotaniaAPI.registerSubTile(key, clazz); - private static void registerSubTileWithDecor(String key, Class clazz, Class decor) { - BotaniaAPI.registerSubTile(key, clazz); - BotaniaAPI.registerMiniSubTile(key + "Decor", decor, key); - } + for (Class innerClazz : clazz.getDeclaredClasses()) + if (innerClazz.getSimpleName().equals("Mini")) + BotaniaAPI.registerMiniSubTile(key + "Chibi", innerClazz, key); + } - private static void registerTile(Class clazz, String key) { - GameRegistry.registerTileEntity(clazz, LibResources.PREFIX_MOD + key); - } + private static void registerSubTileWithDecor( + String key, Class clazz, Class decor) { + BotaniaAPI.registerSubTile(key, clazz); + BotaniaAPI.registerMiniSubTile(key + "Decor", decor, key); + } + private static void registerTile(Class clazz, String key) { + GameRegistry.registerTileEntity(clazz, LibResources.PREFIX_MOD + key); + } } diff --git a/src/main/java/vazkii/botania/common/block/ModFluffBlocks.java b/src/main/java/vazkii/botania/common/block/ModFluffBlocks.java index 3c2ea950d3..9ab82ae003 100644 --- a/src/main/java/vazkii/botania/common/block/ModFluffBlocks.java +++ b/src/main/java/vazkii/botania/common/block/ModFluffBlocks.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jan 24, 2015, 2:35:08 PM (GMT)] */ package vazkii.botania.common.block; @@ -79,343 +79,342 @@ public final class ModFluffBlocks { - public static Block livingwoodStairs; - public static Block livingwoodSlab; - public static Block livingwoodSlabFull; - public static Block livingwoodWall; - public static Block livingwoodPlankStairs; - public static Block livingwoodPlankSlab; - public static Block livingwoodPlankSlabFull; - public static Block livingrockStairs; - public static Block livingrockSlab; - public static Block livingrockSlabFull; - public static Block livingrockWall; - public static Block livingrockBrickStairs; - public static Block livingrockBrickSlab; - public static Block livingrockBrickSlabFull; - public static Block dreamwoodStairs; - public static Block dreamwoodSlab; - public static Block dreamwoodSlabFull; - public static Block dreamwoodWall; - public static Block dreamwoodPlankStairs; - public static Block dreamwoodPlankSlab; - public static Block dreamwoodPlankSlabFull; - - public static Block prismarineStairs; - public static Block prismarineSlab; - public static Block prismarineSlabFull; - public static Block prismarineWall; - public static Block prismarineBrickStairs; - public static Block prismarineBrickSlab; - public static Block prismarineBrickSlabFull; - public static Block darkPrismarineStairs; - public static Block darkPrismarineSlab; - public static Block darkPrismarineSlabFull; - - public static Block reedStairs; - public static Block reedSlab; - public static Block reedSlabFull; - public static Block reedWall; - public static Block thatchStairs; - public static Block thatchSlab; - public static Block thatchSlabFull; - - public static Block netherBrickStairs; - public static Block netherBrickSlab; - public static Block netherBrickSlabFull; - public static Block soulBrickStairs; - public static Block soulBrickSlab; - public static Block soulBrickSlabFull; - public static Block snowBrickStairs; - public static Block snowBrickSlab; - public static Block snowBrickSlabFull; - public static Block tileStairs; - public static Block tileSlab; - public static Block tileSlabFull; - - public static Block darkQuartz; - public static Block darkQuartzSlab; - public static Block darkQuartzSlabFull; - public static Block darkQuartzStairs; - public static Block manaQuartz; - public static Block manaQuartzSlab; - public static Block manaQuartzSlabFull; - public static Block manaQuartzStairs; - public static Block blazeQuartz; - public static Block blazeQuartzSlab; - public static Block blazeQuartzSlabFull; - public static Block blazeQuartzStairs; - public static Block lavenderQuartz; - public static Block lavenderQuartzSlab; - public static Block lavenderQuartzSlabFull; - public static Block lavenderQuartzStairs; - public static Block redQuartz; - public static Block redQuartzSlab; - public static Block redQuartzSlabFull; - public static Block redQuartzStairs; - public static Block elfQuartz; - public static Block elfQuartzSlab; - public static Block elfQuartzSlabFull; - public static Block elfQuartzStairs; - public static Block sunnyQuartz; - public static Block sunnyQuartzSlab; - public static Block sunnyQuartzSlabFull; - public static Block sunnyQuartzStairs; - - public static Block dirtPathSlab; - public static Block dirtPathSlabFull; - - public static Block biomeStoneA; - public static Block biomeStoneB; - public static Block stone; - public static Block pavement; - - public static Block[] biomeStoneStairs = new Block[24]; - public static Block[] biomeStoneSlabs = new Block[24]; - public static Block[] biomeStoneFullSlabs = new Block[24]; - public static Block biomeStoneWall; - - public static Block[] stoneStairs = new Block[8]; - public static Block[] stoneSlabs = new Block[8]; - public static Block[] stoneFullSlabs = new Block[8]; - public static Block stoneWall; - - public static Block[] pavementStairs = new Block[BlockPavement.TYPES]; - public static Block[] pavementSlabs = new Block[BlockPavement.TYPES]; - public static Block[] pavementFullSlabs = new Block[BlockPavement.TYPES]; - - public static Block endStoneSlab; - public static Block endStoneSlabFull; - public static Block endStoneStairs; - public static Block enderBrickSlab; - public static Block enderBrickSlabFull; - public static Block enderBrickStairs; - - public static Block shimmerrockSlab; - public static Block shimmerrockSlabFull; - public static Block shimmerrockStairs; - public static Block shimmerwoodPlankSlab; - public static Block shimmerwoodPlankSlabFull; - public static Block shimmerwoodPlankStairs; - - public static Block managlassPane; - public static Block alfglassPane; - public static Block bifrostPane; - - public static void init() { - livingwoodStairs = new BlockLivingwoodStairs(); - livingwoodSlab = new BlockLivingwoodSlab(false); - livingwoodSlabFull = new BlockLivingwoodSlab(true); - livingwoodWall = new BlockLivingwoodWall(); - livingwoodPlankStairs = new BlockLivingwoodPlankStairs(); - livingwoodPlankSlab = new BlockLivingwoodPlankSlab(false); - livingwoodPlankSlabFull = new BlockLivingwoodPlankSlab(true); - livingrockStairs = new BlockLivingrockStairs(); - livingrockSlab = new BlockLivingrockSlab(false); - livingrockSlabFull = new BlockLivingrockSlab(true); - livingrockWall = new BlockLivingrockWall(); - livingrockBrickStairs = new BlockLivingrockBrickStairs(); - livingrockBrickSlab = new BlockLivingrockBrickSlab(false); - livingrockBrickSlabFull = new BlockLivingrockBrickSlab(true); - dreamwoodStairs = new BlockDreamwoodStairs(); - dreamwoodSlab = new BlockDreamwoodSlab(false); - dreamwoodSlabFull = new BlockDreamwoodSlab(true); - dreamwoodWall = new BlockDreamwoodWall(); - dreamwoodPlankStairs = new BlockDreamwoodPlankStairs(); - dreamwoodPlankSlab = new BlockDreamwoodPlankSlab(false); - dreamwoodPlankSlabFull = new BlockDreamwoodPlankSlab(true); - - prismarineStairs = new BlockPrismarineStairs(); - prismarineSlab = new BlockPrismarineSlab(false); - prismarineSlabFull = new BlockPrismarineSlab(true); - prismarineWall = new BlockPrismarineWall(); - prismarineBrickStairs = new BlockPrismarineBrickStairs(); - prismarineBrickSlab = new BlockPrismarineBrickSlab(false); - prismarineBrickSlabFull = new BlockPrismarineBrickSlab(true); - darkPrismarineStairs = new BlockDarkPrismarineStairs(); - darkPrismarineSlab = new BlockDarkPrismarineSlab(false); - darkPrismarineSlabFull = new BlockDarkPrismarineSlab(true); - - reedStairs = new BlockReedStairs(); - reedSlab = new BlockReedSlab(false); - reedSlabFull = new BlockReedSlab(true); - reedWall = new BlockReedWall(); - thatchStairs = new BlockThatchStairs(); - thatchSlab = new BlockThatchSlab(false); - thatchSlabFull = new BlockThatchSlab(true); - - netherBrickStairs = new BlockCustomBrickStairs(); - netherBrickSlab = new BlockCustomBrickSlab(false); - netherBrickSlabFull = new BlockCustomBrickSlab(true); - soulBrickStairs = new BlockSoulBrickStairs(); - soulBrickSlab = new BlockSoulBrickSlab(false); - soulBrickSlabFull = new BlockSoulBrickSlab(true); - snowBrickStairs = new BlockSnowBrickStairs(); - snowBrickSlab = new BlockSnowBrickSlab(false); - snowBrickSlabFull = new BlockSnowBrickSlab(true); - tileStairs = new BlockTileStairs(); - tileSlab = new BlockTileSlab(false); - tileSlabFull = new BlockTileSlab(true); - - biomeStoneA = new BlockBiomeStoneA(); - biomeStoneB = new BlockBiomeStoneB(); - stone = new Block18Stone(); - pavement = new BlockPavement(); - - if(ConfigHandler.darkQuartzEnabled) { - darkQuartz = new BlockSpecialQuartz(LibBlockNames.QUARTZ_DARK); - darkQuartzSlab = new BlockSpecialQuartzSlab(darkQuartz, false); - darkQuartzSlabFull = new BlockSpecialQuartzSlab(darkQuartz, true); - darkQuartzStairs = new BlockSpecialQuartzStairs(darkQuartz); - } - - manaQuartz = new BlockSpecialQuartz(LibBlockNames.QUARTZ_MANA); - manaQuartzSlab = new BlockSpecialQuartzSlab(manaQuartz, false); - manaQuartzSlabFull = new BlockSpecialQuartzSlab(manaQuartz, true); - manaQuartzStairs = new BlockSpecialQuartzStairs(manaQuartz); - blazeQuartz = new BlockSpecialQuartz(LibBlockNames.QUARTZ_BLAZE); - blazeQuartzSlab = new BlockSpecialQuartzSlab(blazeQuartz, false); - blazeQuartzSlabFull = new BlockSpecialQuartzSlab(blazeQuartz, true); - blazeQuartzStairs = new BlockSpecialQuartzStairs(blazeQuartz); - lavenderQuartz = new BlockSpecialQuartz(LibBlockNames.QUARTZ_LAVENDER); - lavenderQuartzSlab = new BlockSpecialQuartzSlab(lavenderQuartz, false); - lavenderQuartzSlabFull = new BlockSpecialQuartzSlab(lavenderQuartz, true); - lavenderQuartzStairs = new BlockSpecialQuartzStairs(lavenderQuartz); - redQuartz = new BlockSpecialQuartz(LibBlockNames.QUARTZ_RED); - redQuartzSlab = new BlockSpecialQuartzSlab(redQuartz, false); - redQuartzSlabFull = new BlockSpecialQuartzSlab(redQuartz, true); - redQuartzStairs = new BlockSpecialQuartzStairs(redQuartz); - elfQuartz = new BlockSpecialQuartz(LibBlockNames.QUARTZ_ELF); - elfQuartzSlab = new BlockSpecialQuartzSlab(elfQuartz, false); - elfQuartzSlabFull = new BlockSpecialQuartzSlab(elfQuartz, true); - elfQuartzStairs = new BlockSpecialQuartzStairs(elfQuartz); - sunnyQuartz = new BlockSpecialQuartz(LibBlockNames.QUARTZ_SUNNY); - sunnyQuartzSlab = new BlockSpecialQuartzSlab(sunnyQuartz, false); - sunnyQuartzSlabFull = new BlockSpecialQuartzSlab(sunnyQuartz, true); - sunnyQuartzStairs = new BlockSpecialQuartzStairs(sunnyQuartz); - - dirtPathSlab = new BlockDirtPathSlab(false); - dirtPathSlabFull = new BlockDirtPathSlab(true); - - for(int i = 0; i < 24; i++) { - int meta = i % 16; - Block block = i < 16 ? biomeStoneA : biomeStoneB; - biomeStoneStairs[i] = new BlockBiomeStoneStairs(block, meta); - biomeStoneSlabs[i] = new BlockBiomeStoneSlab(false, block, meta, i); - biomeStoneFullSlabs[i] = new BlockBiomeStoneSlab(true, block, meta, i); - } - biomeStoneWall = new BlockBiomeStoneWall(); - - for(int i = 0; i < 8; i++) { - int meta = i > 3 ? i + 4 : i; - stoneStairs[i] = new Block18StoneStairs(meta); - stoneSlabs[i] = new Block18StoneSlab(false, meta, i); - stoneFullSlabs[i] = new Block18StoneSlab(true, meta, i); - } - stoneWall = new Block18StoneWall(); - - for(int i = 0; i < pavementStairs.length; i++) { - pavementStairs[i] = new BlockPavementStairs(i); - pavementSlabs[i] = new BlockPavementSlab(false, i, i); - pavementFullSlabs[i] = new BlockPavementSlab(true, i, i); - } - - endStoneSlab = new BlockEndStoneSlab(false); - endStoneSlabFull = new BlockEndStoneSlab(true); - endStoneStairs = new BlockEndStoneStairs(); - enderBrickSlab = new BlockEnderBrickSlab(false); - enderBrickSlabFull = new BlockEnderBrickSlab(true); - enderBrickStairs = new BlockEnderBrickStairs(); - - shimmerrockSlab = new BlockShimmerrockSlab(false); - shimmerrockSlabFull = new BlockShimmerrockSlab(true); - shimmerrockStairs = new BlockShimmerrockStairs(); - shimmerwoodPlankSlab = new BlockShimmerwoodPlankSlab(false); - shimmerwoodPlankSlabFull = new BlockShimmerwoodPlankSlab(true); - shimmerwoodPlankStairs = new BlockShimmerwoodPlankStairs(); - - managlassPane = new BlockManaglassPane(); - alfglassPane = new BlockAlfglassPane(); - bifrostPane = new BlockBifrostPane(); - - if(ConfigHandler.darkQuartzEnabled) { - ((BlockModSlab) darkQuartzSlab).register(); - ((BlockModSlab) darkQuartzSlabFull).register(); - } - ((BlockModSlab) manaQuartzSlab).register(); - ((BlockModSlab) manaQuartzSlabFull).register(); - ((BlockModSlab) blazeQuartzSlab).register(); - ((BlockModSlab) blazeQuartzSlabFull).register(); - ((BlockModSlab) lavenderQuartzSlab).register(); - ((BlockModSlab) lavenderQuartzSlabFull).register(); - ((BlockModSlab) redQuartzSlab).register(); - ((BlockModSlab) redQuartzSlabFull).register(); - ((BlockModSlab) elfQuartzSlab).register(); - ((BlockModSlab) elfQuartzSlabFull).register(); - ((BlockModSlab) sunnyQuartzSlab).register(); - ((BlockModSlab) sunnyQuartzSlabFull).register(); - - ((BlockModSlab) livingwoodSlab).register(); - ((BlockModSlab) livingwoodSlabFull).register(); - ((BlockModSlab) livingwoodPlankSlab).register(); - ((BlockModSlab) livingwoodPlankSlabFull).register(); - ((BlockModSlab) livingrockSlab).register(); - ((BlockModSlab) livingrockSlabFull).register(); - ((BlockModSlab) livingrockBrickSlab).register(); - ((BlockModSlab) livingrockBrickSlabFull).register(); - ((BlockModSlab) dreamwoodSlab).register(); - ((BlockModSlab) dreamwoodSlabFull).register(); - ((BlockModSlab) dreamwoodPlankSlab).register(); - ((BlockModSlab) dreamwoodPlankSlabFull).register(); - - ((BlockModSlab) reedSlab).register(); - ((BlockModSlab) reedSlabFull).register(); - ((BlockModSlab) thatchSlab).register(); - ((BlockModSlab) thatchSlabFull).register(); - - ((BlockModSlab) prismarineSlab).register(); - ((BlockModSlab) prismarineSlabFull).register(); - ((BlockModSlab) prismarineBrickSlab).register(); - ((BlockModSlab) prismarineBrickSlabFull).register(); - ((BlockModSlab) darkPrismarineSlab).register(); - ((BlockModSlab) darkPrismarineSlabFull).register(); - - ((BlockModSlab) netherBrickSlab).register(); - ((BlockModSlab) netherBrickSlabFull).register(); - ((BlockModSlab) soulBrickSlab).register(); - ((BlockModSlab) soulBrickSlabFull).register(); - ((BlockModSlab) snowBrickSlab).register(); - ((BlockModSlab) snowBrickSlabFull).register(); - ((BlockModSlab) tileSlab).register(); - ((BlockModSlab) tileSlabFull).register(); - - ((BlockModSlab) dirtPathSlab).register(); - ((BlockModSlab) dirtPathSlabFull).register(); - - ((BlockModSlab) endStoneSlab).register(); - ((BlockModSlab) endStoneSlabFull).register(); - ((BlockModSlab) enderBrickSlab).register(); - ((BlockModSlab) enderBrickSlabFull).register(); - - ((BlockModSlab) shimmerrockSlab).register(); - ((BlockModSlab) shimmerrockSlabFull).register(); - ((BlockModSlab) shimmerwoodPlankSlab).register(); - ((BlockModSlab) shimmerwoodPlankSlabFull).register(); - - for(int i = 0; i < 24; i++) { - ((BlockModSlab) biomeStoneSlabs[i]).register(); - ((BlockModSlab) biomeStoneFullSlabs[i]).register(); - } - - for(int i = 0; i < 8; i++) { - ((BlockModSlab) stoneSlabs[i]).register(); - ((BlockModSlab) stoneFullSlabs[i]).register(); - } - - for(int i = 0; i < pavementSlabs.length; i++) { - ((BlockModSlab) pavementSlabs[i]).register(); - ((BlockModSlab) pavementFullSlabs[i]).register(); - } - } - + public static Block livingwoodStairs; + public static Block livingwoodSlab; + public static Block livingwoodSlabFull; + public static Block livingwoodWall; + public static Block livingwoodPlankStairs; + public static Block livingwoodPlankSlab; + public static Block livingwoodPlankSlabFull; + public static Block livingrockStairs; + public static Block livingrockSlab; + public static Block livingrockSlabFull; + public static Block livingrockWall; + public static Block livingrockBrickStairs; + public static Block livingrockBrickSlab; + public static Block livingrockBrickSlabFull; + public static Block dreamwoodStairs; + public static Block dreamwoodSlab; + public static Block dreamwoodSlabFull; + public static Block dreamwoodWall; + public static Block dreamwoodPlankStairs; + public static Block dreamwoodPlankSlab; + public static Block dreamwoodPlankSlabFull; + + public static Block prismarineStairs; + public static Block prismarineSlab; + public static Block prismarineSlabFull; + public static Block prismarineWall; + public static Block prismarineBrickStairs; + public static Block prismarineBrickSlab; + public static Block prismarineBrickSlabFull; + public static Block darkPrismarineStairs; + public static Block darkPrismarineSlab; + public static Block darkPrismarineSlabFull; + + public static Block reedStairs; + public static Block reedSlab; + public static Block reedSlabFull; + public static Block reedWall; + public static Block thatchStairs; + public static Block thatchSlab; + public static Block thatchSlabFull; + + public static Block netherBrickStairs; + public static Block netherBrickSlab; + public static Block netherBrickSlabFull; + public static Block soulBrickStairs; + public static Block soulBrickSlab; + public static Block soulBrickSlabFull; + public static Block snowBrickStairs; + public static Block snowBrickSlab; + public static Block snowBrickSlabFull; + public static Block tileStairs; + public static Block tileSlab; + public static Block tileSlabFull; + + public static Block darkQuartz; + public static Block darkQuartzSlab; + public static Block darkQuartzSlabFull; + public static Block darkQuartzStairs; + public static Block manaQuartz; + public static Block manaQuartzSlab; + public static Block manaQuartzSlabFull; + public static Block manaQuartzStairs; + public static Block blazeQuartz; + public static Block blazeQuartzSlab; + public static Block blazeQuartzSlabFull; + public static Block blazeQuartzStairs; + public static Block lavenderQuartz; + public static Block lavenderQuartzSlab; + public static Block lavenderQuartzSlabFull; + public static Block lavenderQuartzStairs; + public static Block redQuartz; + public static Block redQuartzSlab; + public static Block redQuartzSlabFull; + public static Block redQuartzStairs; + public static Block elfQuartz; + public static Block elfQuartzSlab; + public static Block elfQuartzSlabFull; + public static Block elfQuartzStairs; + public static Block sunnyQuartz; + public static Block sunnyQuartzSlab; + public static Block sunnyQuartzSlabFull; + public static Block sunnyQuartzStairs; + + public static Block dirtPathSlab; + public static Block dirtPathSlabFull; + + public static Block biomeStoneA; + public static Block biomeStoneB; + public static Block stone; + public static Block pavement; + + public static Block[] biomeStoneStairs = new Block[24]; + public static Block[] biomeStoneSlabs = new Block[24]; + public static Block[] biomeStoneFullSlabs = new Block[24]; + public static Block biomeStoneWall; + + public static Block[] stoneStairs = new Block[8]; + public static Block[] stoneSlabs = new Block[8]; + public static Block[] stoneFullSlabs = new Block[8]; + public static Block stoneWall; + + public static Block[] pavementStairs = new Block[BlockPavement.TYPES]; + public static Block[] pavementSlabs = new Block[BlockPavement.TYPES]; + public static Block[] pavementFullSlabs = new Block[BlockPavement.TYPES]; + + public static Block endStoneSlab; + public static Block endStoneSlabFull; + public static Block endStoneStairs; + public static Block enderBrickSlab; + public static Block enderBrickSlabFull; + public static Block enderBrickStairs; + + public static Block shimmerrockSlab; + public static Block shimmerrockSlabFull; + public static Block shimmerrockStairs; + public static Block shimmerwoodPlankSlab; + public static Block shimmerwoodPlankSlabFull; + public static Block shimmerwoodPlankStairs; + + public static Block managlassPane; + public static Block alfglassPane; + public static Block bifrostPane; + + public static void init() { + livingwoodStairs = new BlockLivingwoodStairs(); + livingwoodSlab = new BlockLivingwoodSlab(false); + livingwoodSlabFull = new BlockLivingwoodSlab(true); + livingwoodWall = new BlockLivingwoodWall(); + livingwoodPlankStairs = new BlockLivingwoodPlankStairs(); + livingwoodPlankSlab = new BlockLivingwoodPlankSlab(false); + livingwoodPlankSlabFull = new BlockLivingwoodPlankSlab(true); + livingrockStairs = new BlockLivingrockStairs(); + livingrockSlab = new BlockLivingrockSlab(false); + livingrockSlabFull = new BlockLivingrockSlab(true); + livingrockWall = new BlockLivingrockWall(); + livingrockBrickStairs = new BlockLivingrockBrickStairs(); + livingrockBrickSlab = new BlockLivingrockBrickSlab(false); + livingrockBrickSlabFull = new BlockLivingrockBrickSlab(true); + dreamwoodStairs = new BlockDreamwoodStairs(); + dreamwoodSlab = new BlockDreamwoodSlab(false); + dreamwoodSlabFull = new BlockDreamwoodSlab(true); + dreamwoodWall = new BlockDreamwoodWall(); + dreamwoodPlankStairs = new BlockDreamwoodPlankStairs(); + dreamwoodPlankSlab = new BlockDreamwoodPlankSlab(false); + dreamwoodPlankSlabFull = new BlockDreamwoodPlankSlab(true); + + prismarineStairs = new BlockPrismarineStairs(); + prismarineSlab = new BlockPrismarineSlab(false); + prismarineSlabFull = new BlockPrismarineSlab(true); + prismarineWall = new BlockPrismarineWall(); + prismarineBrickStairs = new BlockPrismarineBrickStairs(); + prismarineBrickSlab = new BlockPrismarineBrickSlab(false); + prismarineBrickSlabFull = new BlockPrismarineBrickSlab(true); + darkPrismarineStairs = new BlockDarkPrismarineStairs(); + darkPrismarineSlab = new BlockDarkPrismarineSlab(false); + darkPrismarineSlabFull = new BlockDarkPrismarineSlab(true); + + reedStairs = new BlockReedStairs(); + reedSlab = new BlockReedSlab(false); + reedSlabFull = new BlockReedSlab(true); + reedWall = new BlockReedWall(); + thatchStairs = new BlockThatchStairs(); + thatchSlab = new BlockThatchSlab(false); + thatchSlabFull = new BlockThatchSlab(true); + + netherBrickStairs = new BlockCustomBrickStairs(); + netherBrickSlab = new BlockCustomBrickSlab(false); + netherBrickSlabFull = new BlockCustomBrickSlab(true); + soulBrickStairs = new BlockSoulBrickStairs(); + soulBrickSlab = new BlockSoulBrickSlab(false); + soulBrickSlabFull = new BlockSoulBrickSlab(true); + snowBrickStairs = new BlockSnowBrickStairs(); + snowBrickSlab = new BlockSnowBrickSlab(false); + snowBrickSlabFull = new BlockSnowBrickSlab(true); + tileStairs = new BlockTileStairs(); + tileSlab = new BlockTileSlab(false); + tileSlabFull = new BlockTileSlab(true); + + biomeStoneA = new BlockBiomeStoneA(); + biomeStoneB = new BlockBiomeStoneB(); + stone = new Block18Stone(); + pavement = new BlockPavement(); + + if (ConfigHandler.darkQuartzEnabled) { + darkQuartz = new BlockSpecialQuartz(LibBlockNames.QUARTZ_DARK); + darkQuartzSlab = new BlockSpecialQuartzSlab(darkQuartz, false); + darkQuartzSlabFull = new BlockSpecialQuartzSlab(darkQuartz, true); + darkQuartzStairs = new BlockSpecialQuartzStairs(darkQuartz); + } + + manaQuartz = new BlockSpecialQuartz(LibBlockNames.QUARTZ_MANA); + manaQuartzSlab = new BlockSpecialQuartzSlab(manaQuartz, false); + manaQuartzSlabFull = new BlockSpecialQuartzSlab(manaQuartz, true); + manaQuartzStairs = new BlockSpecialQuartzStairs(manaQuartz); + blazeQuartz = new BlockSpecialQuartz(LibBlockNames.QUARTZ_BLAZE); + blazeQuartzSlab = new BlockSpecialQuartzSlab(blazeQuartz, false); + blazeQuartzSlabFull = new BlockSpecialQuartzSlab(blazeQuartz, true); + blazeQuartzStairs = new BlockSpecialQuartzStairs(blazeQuartz); + lavenderQuartz = new BlockSpecialQuartz(LibBlockNames.QUARTZ_LAVENDER); + lavenderQuartzSlab = new BlockSpecialQuartzSlab(lavenderQuartz, false); + lavenderQuartzSlabFull = new BlockSpecialQuartzSlab(lavenderQuartz, true); + lavenderQuartzStairs = new BlockSpecialQuartzStairs(lavenderQuartz); + redQuartz = new BlockSpecialQuartz(LibBlockNames.QUARTZ_RED); + redQuartzSlab = new BlockSpecialQuartzSlab(redQuartz, false); + redQuartzSlabFull = new BlockSpecialQuartzSlab(redQuartz, true); + redQuartzStairs = new BlockSpecialQuartzStairs(redQuartz); + elfQuartz = new BlockSpecialQuartz(LibBlockNames.QUARTZ_ELF); + elfQuartzSlab = new BlockSpecialQuartzSlab(elfQuartz, false); + elfQuartzSlabFull = new BlockSpecialQuartzSlab(elfQuartz, true); + elfQuartzStairs = new BlockSpecialQuartzStairs(elfQuartz); + sunnyQuartz = new BlockSpecialQuartz(LibBlockNames.QUARTZ_SUNNY); + sunnyQuartzSlab = new BlockSpecialQuartzSlab(sunnyQuartz, false); + sunnyQuartzSlabFull = new BlockSpecialQuartzSlab(sunnyQuartz, true); + sunnyQuartzStairs = new BlockSpecialQuartzStairs(sunnyQuartz); + + dirtPathSlab = new BlockDirtPathSlab(false); + dirtPathSlabFull = new BlockDirtPathSlab(true); + + for (int i = 0; i < 24; i++) { + int meta = i % 16; + Block block = i < 16 ? biomeStoneA : biomeStoneB; + biomeStoneStairs[i] = new BlockBiomeStoneStairs(block, meta); + biomeStoneSlabs[i] = new BlockBiomeStoneSlab(false, block, meta, i); + biomeStoneFullSlabs[i] = new BlockBiomeStoneSlab(true, block, meta, i); + } + biomeStoneWall = new BlockBiomeStoneWall(); + + for (int i = 0; i < 8; i++) { + int meta = i > 3 ? i + 4 : i; + stoneStairs[i] = new Block18StoneStairs(meta); + stoneSlabs[i] = new Block18StoneSlab(false, meta, i); + stoneFullSlabs[i] = new Block18StoneSlab(true, meta, i); + } + stoneWall = new Block18StoneWall(); + + for (int i = 0; i < pavementStairs.length; i++) { + pavementStairs[i] = new BlockPavementStairs(i); + pavementSlabs[i] = new BlockPavementSlab(false, i, i); + pavementFullSlabs[i] = new BlockPavementSlab(true, i, i); + } + + endStoneSlab = new BlockEndStoneSlab(false); + endStoneSlabFull = new BlockEndStoneSlab(true); + endStoneStairs = new BlockEndStoneStairs(); + enderBrickSlab = new BlockEnderBrickSlab(false); + enderBrickSlabFull = new BlockEnderBrickSlab(true); + enderBrickStairs = new BlockEnderBrickStairs(); + + shimmerrockSlab = new BlockShimmerrockSlab(false); + shimmerrockSlabFull = new BlockShimmerrockSlab(true); + shimmerrockStairs = new BlockShimmerrockStairs(); + shimmerwoodPlankSlab = new BlockShimmerwoodPlankSlab(false); + shimmerwoodPlankSlabFull = new BlockShimmerwoodPlankSlab(true); + shimmerwoodPlankStairs = new BlockShimmerwoodPlankStairs(); + + managlassPane = new BlockManaglassPane(); + alfglassPane = new BlockAlfglassPane(); + bifrostPane = new BlockBifrostPane(); + + if (ConfigHandler.darkQuartzEnabled) { + ((BlockModSlab) darkQuartzSlab).register(); + ((BlockModSlab) darkQuartzSlabFull).register(); + } + ((BlockModSlab) manaQuartzSlab).register(); + ((BlockModSlab) manaQuartzSlabFull).register(); + ((BlockModSlab) blazeQuartzSlab).register(); + ((BlockModSlab) blazeQuartzSlabFull).register(); + ((BlockModSlab) lavenderQuartzSlab).register(); + ((BlockModSlab) lavenderQuartzSlabFull).register(); + ((BlockModSlab) redQuartzSlab).register(); + ((BlockModSlab) redQuartzSlabFull).register(); + ((BlockModSlab) elfQuartzSlab).register(); + ((BlockModSlab) elfQuartzSlabFull).register(); + ((BlockModSlab) sunnyQuartzSlab).register(); + ((BlockModSlab) sunnyQuartzSlabFull).register(); + + ((BlockModSlab) livingwoodSlab).register(); + ((BlockModSlab) livingwoodSlabFull).register(); + ((BlockModSlab) livingwoodPlankSlab).register(); + ((BlockModSlab) livingwoodPlankSlabFull).register(); + ((BlockModSlab) livingrockSlab).register(); + ((BlockModSlab) livingrockSlabFull).register(); + ((BlockModSlab) livingrockBrickSlab).register(); + ((BlockModSlab) livingrockBrickSlabFull).register(); + ((BlockModSlab) dreamwoodSlab).register(); + ((BlockModSlab) dreamwoodSlabFull).register(); + ((BlockModSlab) dreamwoodPlankSlab).register(); + ((BlockModSlab) dreamwoodPlankSlabFull).register(); + + ((BlockModSlab) reedSlab).register(); + ((BlockModSlab) reedSlabFull).register(); + ((BlockModSlab) thatchSlab).register(); + ((BlockModSlab) thatchSlabFull).register(); + + ((BlockModSlab) prismarineSlab).register(); + ((BlockModSlab) prismarineSlabFull).register(); + ((BlockModSlab) prismarineBrickSlab).register(); + ((BlockModSlab) prismarineBrickSlabFull).register(); + ((BlockModSlab) darkPrismarineSlab).register(); + ((BlockModSlab) darkPrismarineSlabFull).register(); + + ((BlockModSlab) netherBrickSlab).register(); + ((BlockModSlab) netherBrickSlabFull).register(); + ((BlockModSlab) soulBrickSlab).register(); + ((BlockModSlab) soulBrickSlabFull).register(); + ((BlockModSlab) snowBrickSlab).register(); + ((BlockModSlab) snowBrickSlabFull).register(); + ((BlockModSlab) tileSlab).register(); + ((BlockModSlab) tileSlabFull).register(); + + ((BlockModSlab) dirtPathSlab).register(); + ((BlockModSlab) dirtPathSlabFull).register(); + + ((BlockModSlab) endStoneSlab).register(); + ((BlockModSlab) endStoneSlabFull).register(); + ((BlockModSlab) enderBrickSlab).register(); + ((BlockModSlab) enderBrickSlabFull).register(); + + ((BlockModSlab) shimmerrockSlab).register(); + ((BlockModSlab) shimmerrockSlabFull).register(); + ((BlockModSlab) shimmerwoodPlankSlab).register(); + ((BlockModSlab) shimmerwoodPlankSlabFull).register(); + + for (int i = 0; i < 24; i++) { + ((BlockModSlab) biomeStoneSlabs[i]).register(); + ((BlockModSlab) biomeStoneFullSlabs[i]).register(); + } + + for (int i = 0; i < 8; i++) { + ((BlockModSlab) stoneSlabs[i]).register(); + ((BlockModSlab) stoneFullSlabs[i]).register(); + } + + for (int i = 0; i < pavementSlabs.length; i++) { + ((BlockModSlab) pavementSlabs[i]).register(); + ((BlockModSlab) pavementFullSlabs[i]).register(); + } + } } diff --git a/src/main/java/vazkii/botania/common/block/ModMultiblocks.java b/src/main/java/vazkii/botania/common/block/ModMultiblocks.java index 26e531e5e9..ff02d8d083 100644 --- a/src/main/java/vazkii/botania/common/block/ModMultiblocks.java +++ b/src/main/java/vazkii/botania/common/block/ModMultiblocks.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jun 27, 2015, 3:11:36 PM (GMT)] */ package vazkii.botania.common.block; @@ -18,16 +18,15 @@ public final class ModMultiblocks { - public static MultiblockSet enchanter; - public static MultiblockSet alfPortal; - public static MultiblockSet terrasteelPlate; - public static MultiblockSet gaiaRitual; - - public static void init() { - enchanter = TileEnchanter.makeMultiblockSet(); - alfPortal = TileAlfPortal.makeMultiblockSet(); - terrasteelPlate = TileTerraPlate.makeMultiblockSet(); - gaiaRitual = EntityDoppleganger.makeMultiblockSet(); - } + public static MultiblockSet enchanter; + public static MultiblockSet alfPortal; + public static MultiblockSet terrasteelPlate; + public static MultiblockSet gaiaRitual; + public static void init() { + enchanter = TileEnchanter.makeMultiblockSet(); + alfPortal = TileAlfPortal.makeMultiblockSet(); + terrasteelPlate = TileTerraPlate.makeMultiblockSet(); + gaiaRitual = EntityDoppleganger.makeMultiblockSet(); + } } diff --git a/src/main/java/vazkii/botania/common/block/corporea/BlockCorporeaBase.java b/src/main/java/vazkii/botania/common/block/corporea/BlockCorporeaBase.java index 4be814d28f..bd8b2c61bc 100644 --- a/src/main/java/vazkii/botania/common/block/corporea/BlockCorporeaBase.java +++ b/src/main/java/vazkii/botania/common/block/corporea/BlockCorporeaBase.java @@ -2,16 +2,15 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Feb 15, 2015, 12:23:33 AM (GMT)] */ package vazkii.botania.common.block.corporea; import java.util.Random; - import net.minecraft.block.Block; import net.minecraft.block.material.Material; import net.minecraft.entity.item.EntityItem; @@ -29,56 +28,62 @@ public abstract class BlockCorporeaBase extends BlockModContainer implements ICraftAchievement { - Random random; - - public BlockCorporeaBase(Material material, String name) { - super(material); - setBlockName(name); - - random = new Random(); - } - - @Override - public void breakBlock(World par1World, int par2, int par3, int par4, Block par5, int par6) { - TileSimpleInventory inv = (TileSimpleInventory) par1World.getTileEntity(par2, par3, par4); - - if (inv != null) { - for (int j1 = 0; j1 < inv.getSizeInventory(); ++j1) { - ItemStack itemstack = inv.getStackInSlot(j1); - - if (itemstack != null) { - float f = random.nextFloat() * 0.8F + 0.1F; - float f1 = random.nextFloat() * 0.8F + 0.1F; - EntityItem entityitem; - - for (float f2 = random.nextFloat() * 0.8F + 0.1F; itemstack.stackSize > 0; par1World.spawnEntityInWorld(entityitem)) { - int k1 = random.nextInt(21) + 10; - - if (k1 > itemstack.stackSize) - k1 = itemstack.stackSize; - - itemstack.stackSize -= k1; - entityitem = new EntityItem(par1World, par2 + f, par3 + f1, par4 + f2, new ItemStack(itemstack.getItem(), k1, itemstack.getItemDamage())); - float f3 = 0.05F; - entityitem.motionX = (float)random.nextGaussian() * f3; - entityitem.motionY = (float)random.nextGaussian() * f3 + 0.2F; - entityitem.motionZ = (float)random.nextGaussian() * f3; - - if (itemstack.hasTagCompound()) - entityitem.getEntityItem().setTagCompound((NBTTagCompound)itemstack.getTagCompound().copy()); - } - } - } - - par1World.func_147453_f(par2, par3, par4, par5); - } - - super.breakBlock(par1World, par2, par3, par4, par5, par6); - } - - @Override - public Achievement getAchievementOnCraft(ItemStack stack, EntityPlayer player, IInventory matrix) { - return ModAchievements.corporeaCraft; - } - + Random random; + + public BlockCorporeaBase(Material material, String name) { + super(material); + setBlockName(name); + + random = new Random(); + } + + @Override + public void breakBlock(World par1World, int par2, int par3, int par4, Block par5, int par6) { + TileSimpleInventory inv = (TileSimpleInventory) par1World.getTileEntity(par2, par3, par4); + + if (inv != null) { + for (int j1 = 0; j1 < inv.getSizeInventory(); ++j1) { + ItemStack itemstack = inv.getStackInSlot(j1); + + if (itemstack != null) { + float f = random.nextFloat() * 0.8F + 0.1F; + float f1 = random.nextFloat() * 0.8F + 0.1F; + EntityItem entityitem; + + for (float f2 = random.nextFloat() * 0.8F + 0.1F; + itemstack.stackSize > 0; + par1World.spawnEntityInWorld(entityitem)) { + int k1 = random.nextInt(21) + 10; + + if (k1 > itemstack.stackSize) k1 = itemstack.stackSize; + + itemstack.stackSize -= k1; + entityitem = new EntityItem( + par1World, + par2 + f, + par3 + f1, + par4 + f2, + new ItemStack(itemstack.getItem(), k1, itemstack.getItemDamage())); + float f3 = 0.05F; + entityitem.motionX = (float) random.nextGaussian() * f3; + entityitem.motionY = (float) random.nextGaussian() * f3 + 0.2F; + entityitem.motionZ = (float) random.nextGaussian() * f3; + + if (itemstack.hasTagCompound()) + entityitem.getEntityItem().setTagCompound((NBTTagCompound) + itemstack.getTagCompound().copy()); + } + } + } + + par1World.func_147453_f(par2, par3, par4, par5); + } + + super.breakBlock(par1World, par2, par3, par4, par5, par6); + } + + @Override + public Achievement getAchievementOnCraft(ItemStack stack, EntityPlayer player, IInventory matrix) { + return ModAchievements.corporeaCraft; + } } diff --git a/src/main/java/vazkii/botania/common/block/corporea/BlockCorporeaCrystalCube.java b/src/main/java/vazkii/botania/common/block/corporea/BlockCorporeaCrystalCube.java index c41f79dbd9..801724b1cd 100644 --- a/src/main/java/vazkii/botania/common/block/corporea/BlockCorporeaCrystalCube.java +++ b/src/main/java/vazkii/botania/common/block/corporea/BlockCorporeaCrystalCube.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Apr 30, 2015, 3:56:19 PM (GMT)] */ package vazkii.botania.common.block.corporea; @@ -27,77 +27,77 @@ public class BlockCorporeaCrystalCube extends BlockCorporeaBase implements ILexiconable { - public BlockCorporeaCrystalCube() { - super(Material.iron, LibBlockNames.CORPOREA_CRYSTAL_CUBE); - setHardness(5.5F); - setStepSound(soundTypeMetal); - float f = (1F - 10F / 16F) / 2F; - setBlockBounds(f, 0F, f, 1F - f, 1F, 1F - f); - } - - @Override - public void onBlockClicked(World world, int x, int y, int z, EntityPlayer player) { - if(!world.isRemote) { - TileCorporeaCrystalCube cube = (TileCorporeaCrystalCube) world.getTileEntity(x, y, z); - cube.doRequest(player.isSneaking()); - } - } - - @Override - public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int s, float xs, float ys, float zs) { - ItemStack stack = player.getCurrentEquippedItem(); - - if(stack != null) { - TileCorporeaCrystalCube cube = (TileCorporeaCrystalCube) world.getTileEntity(x, y, z); - cube.setRequestTarget(stack); - return true; - } - return false; - } - - @Override - public boolean isOpaqueCube() { - return false; - } - - @Override - public boolean renderAsNormalBlock() { - return false; - } - - @Override - public int getRenderType() { - return LibRenderIDs.idCorporeaCrystalCybe; - } - - @Override - public void registerBlockIcons(IIconRegister par1IconRegister) { - // NO-OP - } - - @Override - public IIcon getIcon(int side, int meta) { - return ModBlocks.storage.getIcon(0, 2); - } - - @Override - public TileCorporeaBase createNewTileEntity(World world, int meta) { - return new TileCorporeaCrystalCube(); - } - - @Override - public LexiconEntry getEntry(World world, int x, int y, int z, EntityPlayer player, ItemStack lexicon) { - return LexiconData.corporeaCrystalCube; - } - - @Override - public boolean hasComparatorInputOverride() { - return true; - } - - @Override - public int getComparatorInputOverride(World world, int x, int y, int z, int s) { - return ((TileCorporeaCrystalCube) world.getTileEntity(x, y, z)).compValue; - } - + public BlockCorporeaCrystalCube() { + super(Material.iron, LibBlockNames.CORPOREA_CRYSTAL_CUBE); + setHardness(5.5F); + setStepSound(soundTypeMetal); + float f = (1F - 10F / 16F) / 2F; + setBlockBounds(f, 0F, f, 1F - f, 1F, 1F - f); + } + + @Override + public void onBlockClicked(World world, int x, int y, int z, EntityPlayer player) { + if (!world.isRemote) { + TileCorporeaCrystalCube cube = (TileCorporeaCrystalCube) world.getTileEntity(x, y, z); + cube.doRequest(player.isSneaking()); + } + } + + @Override + public boolean onBlockActivated( + World world, int x, int y, int z, EntityPlayer player, int s, float xs, float ys, float zs) { + ItemStack stack = player.getCurrentEquippedItem(); + + if (stack != null) { + TileCorporeaCrystalCube cube = (TileCorporeaCrystalCube) world.getTileEntity(x, y, z); + cube.setRequestTarget(stack); + return true; + } + return false; + } + + @Override + public boolean isOpaqueCube() { + return false; + } + + @Override + public boolean renderAsNormalBlock() { + return false; + } + + @Override + public int getRenderType() { + return LibRenderIDs.idCorporeaCrystalCybe; + } + + @Override + public void registerBlockIcons(IIconRegister par1IconRegister) { + // NO-OP + } + + @Override + public IIcon getIcon(int side, int meta) { + return ModBlocks.storage.getIcon(0, 2); + } + + @Override + public TileCorporeaBase createNewTileEntity(World world, int meta) { + return new TileCorporeaCrystalCube(); + } + + @Override + public LexiconEntry getEntry(World world, int x, int y, int z, EntityPlayer player, ItemStack lexicon) { + return LexiconData.corporeaCrystalCube; + } + + @Override + public boolean hasComparatorInputOverride() { + return true; + } + + @Override + public int getComparatorInputOverride(World world, int x, int y, int z, int s) { + return ((TileCorporeaCrystalCube) world.getTileEntity(x, y, z)).compValue; + } } diff --git a/src/main/java/vazkii/botania/common/block/corporea/BlockCorporeaFunnel.java b/src/main/java/vazkii/botania/common/block/corporea/BlockCorporeaFunnel.java index 0ce2ef19f1..3236994d22 100644 --- a/src/main/java/vazkii/botania/common/block/corporea/BlockCorporeaFunnel.java +++ b/src/main/java/vazkii/botania/common/block/corporea/BlockCorporeaFunnel.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Feb 16, 2015, 2:17:05 PM (GMT)] */ package vazkii.botania.common.block.corporea; @@ -27,46 +27,45 @@ public class BlockCorporeaFunnel extends BlockCorporeaBase implements ILexiconable { - IIcon[] icons; + IIcon[] icons; - public BlockCorporeaFunnel() { - super(Material.iron, LibBlockNames.CORPOREA_FUNNEL); - setHardness(5.5F); - setStepSound(soundTypeMetal); - } + public BlockCorporeaFunnel() { + super(Material.iron, LibBlockNames.CORPOREA_FUNNEL); + setHardness(5.5F); + setStepSound(soundTypeMetal); + } - @Override - public void registerBlockIcons(IIconRegister par1IconRegister) { - icons = new IIcon[2]; - for(int i = 0; i < icons.length; i++) - icons[i] = IconHelper.forBlock(par1IconRegister, this, i); - } + @Override + public void registerBlockIcons(IIconRegister par1IconRegister) { + icons = new IIcon[2]; + for (int i = 0; i < icons.length; i++) icons[i] = IconHelper.forBlock(par1IconRegister, this, i); + } - @Override - public void onNeighborBlockChange(World world, int x, int y, int z, Block block) { - boolean power = world.isBlockIndirectlyGettingPowered(x, y, z) || world.isBlockIndirectlyGettingPowered(x, y + 1, z); - int meta = world.getBlockMetadata(x, y, z); - boolean powered = (meta & 8) != 0; + @Override + public void onNeighborBlockChange(World world, int x, int y, int z, Block block) { + boolean power = + world.isBlockIndirectlyGettingPowered(x, y, z) || world.isBlockIndirectlyGettingPowered(x, y + 1, z); + int meta = world.getBlockMetadata(x, y, z); + boolean powered = (meta & 8) != 0; - if(power && !powered) { - ((TileCorporeaFunnel) world.getTileEntity(x, y, z)).doRequest(); - world.setBlockMetadataWithNotify(x, y, z, meta | 8, 4); - } else if(!power && powered) - world.setBlockMetadataWithNotify(x, y, z, meta & -9, 4); - } + if (power && !powered) { + ((TileCorporeaFunnel) world.getTileEntity(x, y, z)).doRequest(); + world.setBlockMetadataWithNotify(x, y, z, meta | 8, 4); + } else if (!power && powered) world.setBlockMetadataWithNotify(x, y, z, meta & -9, 4); + } - @Override - public IIcon getIcon(int par1, int par2) { - return icons[par1 > 1 ? 1 : 0]; - } + @Override + public IIcon getIcon(int par1, int par2) { + return icons[par1 > 1 ? 1 : 0]; + } - @Override - public TileCorporeaBase createNewTileEntity(World world, int meta) { - return new TileCorporeaFunnel(); - } + @Override + public TileCorporeaBase createNewTileEntity(World world, int meta) { + return new TileCorporeaFunnel(); + } - @Override - public LexiconEntry getEntry(World world, int x, int y, int z, EntityPlayer player, ItemStack lexicon) { - return LexiconData.corporeaFunnel; - } + @Override + public LexiconEntry getEntry(World world, int x, int y, int z, EntityPlayer player, ItemStack lexicon) { + return LexiconData.corporeaFunnel; + } } diff --git a/src/main/java/vazkii/botania/common/block/corporea/BlockCorporeaIndex.java b/src/main/java/vazkii/botania/common/block/corporea/BlockCorporeaIndex.java index f2f604cc5a..29b3473b38 100644 --- a/src/main/java/vazkii/botania/common/block/corporea/BlockCorporeaIndex.java +++ b/src/main/java/vazkii/botania/common/block/corporea/BlockCorporeaIndex.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Feb 15, 2015, 12:49:58 AM (GMT)] */ package vazkii.botania.common.block.corporea; @@ -27,45 +27,44 @@ public class BlockCorporeaIndex extends BlockCorporeaBase implements ILexiconable { - public BlockCorporeaIndex() { - super(Material.iron, LibBlockNames.CORPOREA_INDEX); - setHardness(5.5F); - setStepSound(soundTypeMetal); - } + public BlockCorporeaIndex() { + super(Material.iron, LibBlockNames.CORPOREA_INDEX); + setHardness(5.5F); + setStepSound(soundTypeMetal); + } - @Override - public boolean isOpaqueCube() { - return false; - } + @Override + public boolean isOpaqueCube() { + return false; + } - @Override - public boolean renderAsNormalBlock() { - return false; - } + @Override + public boolean renderAsNormalBlock() { + return false; + } - @Override - public void registerBlockIcons(IIconRegister par1IconRegister) { - // NO-OP - } + @Override + public void registerBlockIcons(IIconRegister par1IconRegister) { + // NO-OP + } - @Override - public IIcon getIcon(int side, int meta) { - return ModBlocks.storage.getIcon(0, 2); - } + @Override + public IIcon getIcon(int side, int meta) { + return ModBlocks.storage.getIcon(0, 2); + } - @Override - public int getRenderType() { - return LibRenderIDs.idCorporeaIndex; - } + @Override + public int getRenderType() { + return LibRenderIDs.idCorporeaIndex; + } - @Override - public TileCorporeaBase createNewTileEntity(World world, int meta) { - return new TileCorporeaIndex(); - } - - @Override - public LexiconEntry getEntry(World world, int x, int y, int z, EntityPlayer player, ItemStack lexicon) { - return LexiconData.corporeaIndex; - } + @Override + public TileCorporeaBase createNewTileEntity(World world, int meta) { + return new TileCorporeaIndex(); + } + @Override + public LexiconEntry getEntry(World world, int x, int y, int z, EntityPlayer player, ItemStack lexicon) { + return LexiconData.corporeaIndex; + } } diff --git a/src/main/java/vazkii/botania/common/block/corporea/BlockCorporeaInterceptor.java b/src/main/java/vazkii/botania/common/block/corporea/BlockCorporeaInterceptor.java index b8c18f0270..09a9aa7460 100644 --- a/src/main/java/vazkii/botania/common/block/corporea/BlockCorporeaInterceptor.java +++ b/src/main/java/vazkii/botania/common/block/corporea/BlockCorporeaInterceptor.java @@ -2,16 +2,15 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Apr 19, 2015, 6:18:03 PM (GMT)] */ package vazkii.botania.common.block.corporea; import java.util.Random; - import net.minecraft.block.material.Material; import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.entity.player.EntityPlayer; @@ -29,54 +28,52 @@ public class BlockCorporeaInterceptor extends BlockCorporeaBase implements ILexiconable { - IIcon[] icons; - - public BlockCorporeaInterceptor() { - super(Material.iron, LibBlockNames.CORPOREA_INTERCEPTOR); - setHardness(5.5F); - setStepSound(soundTypeMetal); - } + IIcon[] icons; - @Override - public void registerBlockIcons(IIconRegister par1IconRegister) { - icons = new IIcon[2]; - for(int i = 0; i < icons.length; i++) - icons[i] = IconHelper.forBlock(par1IconRegister, this, i); - } + public BlockCorporeaInterceptor() { + super(Material.iron, LibBlockNames.CORPOREA_INTERCEPTOR); + setHardness(5.5F); + setStepSound(soundTypeMetal); + } - @Override - public IIcon getIcon(int par1, int par2) { - return icons[par1 > 1 ? 1 : 0]; - } + @Override + public void registerBlockIcons(IIconRegister par1IconRegister) { + icons = new IIcon[2]; + for (int i = 0; i < icons.length; i++) icons[i] = IconHelper.forBlock(par1IconRegister, this, i); + } - @Override - public void updateTick(World world, int x, int y, int z, Random rand) { - world.setBlockMetadataWithNotify(x, y, z, 0, 1 | 2); - } + @Override + public IIcon getIcon(int par1, int par2) { + return icons[par1 > 1 ? 1 : 0]; + } - @Override - public boolean canProvidePower() { - return true; - } + @Override + public void updateTick(World world, int x, int y, int z, Random rand) { + world.setBlockMetadataWithNotify(x, y, z, 0, 1 | 2); + } - @Override - public int isProvidingWeakPower(IBlockAccess world, int x, int y, int z, int side) { - return world.getBlockMetadata(x, y, z) != 0 ? 15 : 0; - } + @Override + public boolean canProvidePower() { + return true; + } - @Override - public int tickRate(World p_149738_1_) { - return 2; - } + @Override + public int isProvidingWeakPower(IBlockAccess world, int x, int y, int z, int side) { + return world.getBlockMetadata(x, y, z) != 0 ? 15 : 0; + } - @Override - public TileCorporeaBase createNewTileEntity(World world, int meta) { - return new TileCorporeaInterceptor(); - } + @Override + public int tickRate(World p_149738_1_) { + return 2; + } - @Override - public LexiconEntry getEntry(World world, int x, int y, int z, EntityPlayer player, ItemStack lexicon) { - return LexiconData.corporeaInterceptor; - } + @Override + public TileCorporeaBase createNewTileEntity(World world, int meta) { + return new TileCorporeaInterceptor(); + } + @Override + public LexiconEntry getEntry(World world, int x, int y, int z, EntityPlayer player, ItemStack lexicon) { + return LexiconData.corporeaInterceptor; + } } diff --git a/src/main/java/vazkii/botania/common/block/corporea/BlockCorporeaRetainer.java b/src/main/java/vazkii/botania/common/block/corporea/BlockCorporeaRetainer.java index 2d804b7146..61ff942393 100644 --- a/src/main/java/vazkii/botania/common/block/corporea/BlockCorporeaRetainer.java +++ b/src/main/java/vazkii/botania/common/block/corporea/BlockCorporeaRetainer.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Sep 28, 2015, 11:53:13 AM (GMT)] */ package vazkii.botania.common.block.corporea; @@ -29,49 +29,48 @@ public class BlockCorporeaRetainer extends BlockModContainer implements ILexiconable, ICraftAchievement { - public BlockCorporeaRetainer() { - super(Material.iron); - setHardness(5.5F); - setStepSound(soundTypeMetal); - setBlockName(LibBlockNames.CORPOREA_RETAINER); - } + public BlockCorporeaRetainer() { + super(Material.iron); + setHardness(5.5F); + setStepSound(soundTypeMetal); + setBlockName(LibBlockNames.CORPOREA_RETAINER); + } - @Override - public void onNeighborBlockChange(World world, int x, int y, int z, Block block) { - boolean power = world.isBlockIndirectlyGettingPowered(x, y, z) || world.isBlockIndirectlyGettingPowered(x, y + 1, z); - int meta = world.getBlockMetadata(x, y, z); - boolean powered = (meta & 8) != 0; + @Override + public void onNeighborBlockChange(World world, int x, int y, int z, Block block) { + boolean power = + world.isBlockIndirectlyGettingPowered(x, y, z) || world.isBlockIndirectlyGettingPowered(x, y + 1, z); + int meta = world.getBlockMetadata(x, y, z); + boolean powered = (meta & 8) != 0; - if(power && !powered) { - ((TileCorporeaRetainer) world.getTileEntity(x, y, z)).fulfilRequest(); - world.setBlockMetadataWithNotify(x, y, z, meta | 8, 4); - } else if(!power && powered) - world.setBlockMetadataWithNotify(x, y, z, meta & -9, 4); - } + if (power && !powered) { + ((TileCorporeaRetainer) world.getTileEntity(x, y, z)).fulfilRequest(); + world.setBlockMetadataWithNotify(x, y, z, meta | 8, 4); + } else if (!power && powered) world.setBlockMetadataWithNotify(x, y, z, meta & -9, 4); + } - @Override - public boolean hasComparatorInputOverride() { - return true; - } + @Override + public boolean hasComparatorInputOverride() { + return true; + } - @Override - public int getComparatorInputOverride(World world, int x, int y, int z, int s) { - return ((TileCorporeaRetainer) world.getTileEntity(x, y, z)).hasPendingRequest() ? 15 : 0; - } + @Override + public int getComparatorInputOverride(World world, int x, int y, int z, int s) { + return ((TileCorporeaRetainer) world.getTileEntity(x, y, z)).hasPendingRequest() ? 15 : 0; + } - @Override - public TileEntity createNewTileEntity(World world, int meta) { - return new TileCorporeaRetainer(); - } + @Override + public TileEntity createNewTileEntity(World world, int meta) { + return new TileCorporeaRetainer(); + } - @Override - public Achievement getAchievementOnCraft(ItemStack stack, EntityPlayer player, IInventory matrix) { - return ModAchievements.corporeaCraft; - } - - @Override - public LexiconEntry getEntry(World world, int x, int y, int z, EntityPlayer player, ItemStack lexicon) { - return LexiconData.corporeaRetainer; - } + @Override + public Achievement getAchievementOnCraft(ItemStack stack, EntityPlayer player, IInventory matrix) { + return ModAchievements.corporeaCraft; + } + @Override + public LexiconEntry getEntry(World world, int x, int y, int z, EntityPlayer player, ItemStack lexicon) { + return LexiconData.corporeaRetainer; + } } diff --git a/src/main/java/vazkii/botania/common/block/decor/Block18Stone.java b/src/main/java/vazkii/botania/common/block/decor/Block18Stone.java index 6614a15d19..e28fcbef5d 100644 --- a/src/main/java/vazkii/botania/common/block/decor/Block18Stone.java +++ b/src/main/java/vazkii/botania/common/block/decor/Block18Stone.java @@ -2,16 +2,16 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Apr 10, 2015, 7:34:31 PM (GMT)] */ package vazkii.botania.common.block.decor; +import cpw.mods.fml.common.registry.GameRegistry; import java.util.List; - import net.minecraft.block.Block; import net.minecraft.block.material.Material; import net.minecraft.client.renderer.texture.IIconRegister; @@ -29,62 +29,58 @@ import vazkii.botania.common.item.block.ItemBlockWithMetadataAndName; import vazkii.botania.common.lexicon.LexiconData; import vazkii.botania.common.lib.LibBlockNames; -import cpw.mods.fml.common.registry.GameRegistry; public class Block18Stone extends BlockMod implements ILexiconable { - private static IIcon[] icons = new IIcon[16]; - - public Block18Stone() { - super(Material.rock); - setHardness(1.5F); - setResistance(10F); - setStepSound(soundTypeStone); - setBlockName(LibBlockNames.STONE); - } + private static IIcon[] icons = new IIcon[16]; - @Override - public void registerBlockIcons(IIconRegister register) { - for(int i = 0; i < 16; i++) - icons[i] = IconHelper.forBlock(register, this, i); - } + public Block18Stone() { + super(Material.rock); + setHardness(1.5F); + setResistance(10F); + setStepSound(soundTypeStone); + setBlockName(LibBlockNames.STONE); + } - @Override - public void getSubBlocks(Item item, CreativeTabs tab, List list) { - for(int i = 0; i < 16; i++) - list.add(new ItemStack(item, 1, i)); - } + @Override + public void registerBlockIcons(IIconRegister register) { + for (int i = 0; i < 16; i++) icons[i] = IconHelper.forBlock(register, this, i); + } - @Override - public IIcon getIcon(int side, int meta) { - return icons[meta]; - } + @Override + public void getSubBlocks(Item item, CreativeTabs tab, List list) { + for (int i = 0; i < 16; i++) list.add(new ItemStack(item, 1, i)); + } - @Override - protected boolean shouldRegisterInNameSet() { - return false; - } + @Override + public IIcon getIcon(int side, int meta) { + return icons[meta]; + } - @Override - public int damageDropped(int par1) { - return par1; - } + @Override + protected boolean shouldRegisterInNameSet() { + return false; + } - @Override - public Block setBlockName(String par1Str) { - GameRegistry.registerBlock(this, ItemBlockWithMetadataAndName.class, par1Str); - return super.setBlockName(par1Str); - } + @Override + public int damageDropped(int par1) { + return par1; + } - @Override - public ItemStack getPickBlock(MovingObjectPosition target, World world, int x, int y, int z) { - int meta = world.getBlockMetadata(x, y, z); - return new ItemStack(this, 1, meta); - } + @Override + public Block setBlockName(String par1Str) { + GameRegistry.registerBlock(this, ItemBlockWithMetadataAndName.class, par1Str); + return super.setBlockName(par1Str); + } - @Override - public LexiconEntry getEntry(World world, int x, int y, int z, EntityPlayer player, ItemStack lexicon) { - return LexiconData.stoneAlchemy; - } + @Override + public ItemStack getPickBlock(MovingObjectPosition target, World world, int x, int y, int z) { + int meta = world.getBlockMetadata(x, y, z); + return new ItemStack(this, 1, meta); + } + @Override + public LexiconEntry getEntry(World world, int x, int y, int z, EntityPlayer player, ItemStack lexicon) { + return LexiconData.stoneAlchemy; + } } diff --git a/src/main/java/vazkii/botania/common/block/decor/BlockBlaze.java b/src/main/java/vazkii/botania/common/block/decor/BlockBlaze.java index a627d1cde4..8c40b9c65c 100644 --- a/src/main/java/vazkii/botania/common/block/decor/BlockBlaze.java +++ b/src/main/java/vazkii/botania/common/block/decor/BlockBlaze.java @@ -2,14 +2,16 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Apr 17, 2015, 7:55:33 PM (GMT)] */ package vazkii.botania.common.block.decor; +import cpw.mods.fml.common.IFuelHandler; +import cpw.mods.fml.common.registry.GameRegistry; import net.minecraft.block.material.Material; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.init.Items; @@ -23,29 +25,29 @@ import vazkii.botania.common.block.BlockMod; import vazkii.botania.common.lexicon.LexiconData; import vazkii.botania.common.lib.LibBlockNames; -import cpw.mods.fml.common.IFuelHandler; -import cpw.mods.fml.common.registry.GameRegistry; public class BlockBlaze extends BlockMod implements ILexiconable, IFuelHandler { - public BlockBlaze() { - super(Material.iron); - setHardness(3F); - setResistance(10F); - setStepSound(soundTypeMetal); - setLightLevel(1F); - setBlockName(LibBlockNames.BLAZE_BLOCK); - GameRegistry.registerFuelHandler(this); - } - - @Override - public LexiconEntry getEntry(World world, int x, int y, int z, EntityPlayer player, ItemStack lexicon) { - return LexiconData.blazeBlock; - } + public BlockBlaze() { + super(Material.iron); + setHardness(3F); + setResistance(10F); + setStepSound(soundTypeMetal); + setLightLevel(1F); + setBlockName(LibBlockNames.BLAZE_BLOCK); + GameRegistry.registerFuelHandler(this); + } - @Override - public int getBurnTime(ItemStack fuel) { - return fuel.getItem() == Item.getItemFromBlock(this) ? TileEntityFurnace.getItemBurnTime(new ItemStack(Items.blaze_rod)) * (Botania.gardenOfGlassLoaded ? 5 : 10) : 0; - } + @Override + public LexiconEntry getEntry(World world, int x, int y, int z, EntityPlayer player, ItemStack lexicon) { + return LexiconData.blazeBlock; + } + @Override + public int getBurnTime(ItemStack fuel) { + return fuel.getItem() == Item.getItemFromBlock(this) + ? TileEntityFurnace.getItemBurnTime(new ItemStack(Items.blaze_rod)) + * (Botania.gardenOfGlassLoaded ? 5 : 10) + : 0; + } } diff --git a/src/main/java/vazkii/botania/common/block/decor/BlockBuriedPetals.java b/src/main/java/vazkii/botania/common/block/decor/BlockBuriedPetals.java index 147a5905dd..4703d19484 100644 --- a/src/main/java/vazkii/botania/common/block/decor/BlockBuriedPetals.java +++ b/src/main/java/vazkii/botania/common/block/decor/BlockBuriedPetals.java @@ -2,16 +2,16 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jun 28, 2014, 6:43:33 PM (GMT)] */ package vazkii.botania.common.block.decor; +import cpw.mods.fml.common.Optional; import java.util.Random; - import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.entity.passive.EntitySheep; import net.minecraft.item.Item; @@ -24,54 +24,62 @@ import vazkii.botania.common.integration.coloredlights.ColoredLightHelper; import vazkii.botania.common.item.ModItems; import vazkii.botania.common.lib.LibBlockNames; -import cpw.mods.fml.common.Optional; public class BlockBuriedPetals extends BlockModFlower { - public BlockBuriedPetals() { - super(LibBlockNames.BURIED_PETALS); - setBlockBounds(0F, 0F, 0F, 1F, 0.1F, 1F); - setLightLevel(0.25F); - } + public BlockBuriedPetals() { + super(LibBlockNames.BURIED_PETALS); + setBlockBounds(0F, 0F, 0F, 1F, 0.1F, 1F); + setLightLevel(0.25F); + } - @Override - @Optional.Method(modid = "easycoloredlights") - public int getLightValue(IBlockAccess world, int x, int y, int z) { - return ColoredLightHelper.getPackedColor(world.getBlockMetadata(x, y, z), originalLight); - } + @Override + @Optional.Method(modid = "easycoloredlights") + public int getLightValue(IBlockAccess world, int x, int y, int z) { + return ColoredLightHelper.getPackedColor(world.getBlockMetadata(x, y, z), originalLight); + } - @Override - public void randomDisplayTick(World par1World, int par2, int par3, int par4, Random par5Random) { - int meta = par1World.getBlockMetadata(par2, par3, par4); - float[] color = EntitySheep.fleeceColorTable[meta]; + @Override + public void randomDisplayTick(World par1World, int par2, int par3, int par4, Random par5Random) { + int meta = par1World.getBlockMetadata(par2, par3, par4); + float[] color = EntitySheep.fleeceColorTable[meta]; - Botania.proxy.setSparkleFXNoClip(true); - Botania.proxy.sparkleFX(par1World, par2 + 0.3 + par5Random.nextFloat() * 0.5, par3 + 0.1 + par5Random.nextFloat() * 0.1, par4 + 0.3 + par5Random.nextFloat() * 0.5, color[0], color[1], color[2], par5Random.nextFloat(), 5); - Botania.proxy.setSparkleFXNoClip(false); - } + Botania.proxy.setSparkleFXNoClip(true); + Botania.proxy.sparkleFX( + par1World, + par2 + 0.3 + par5Random.nextFloat() * 0.5, + par3 + 0.1 + par5Random.nextFloat() * 0.1, + par4 + 0.3 + par5Random.nextFloat() * 0.5, + color[0], + color[1], + color[2], + par5Random.nextFloat(), + 5); + Botania.proxy.setSparkleFXNoClip(false); + } - @Override - public boolean registerInCreative() { - return false; - } + @Override + public boolean registerInCreative() { + return false; + } - @Override - public void registerBlockIcons(IIconRegister par1IconRegister) { - blockIcon = IconHelper.forBlock(par1IconRegister, this); - } + @Override + public void registerBlockIcons(IIconRegister par1IconRegister) { + blockIcon = IconHelper.forBlock(par1IconRegister, this); + } - @Override - public IIcon getIcon(int par1, int par2) { - return blockIcon; - } + @Override + public IIcon getIcon(int par1, int par2) { + return blockIcon; + } - @Override - public Item getItemDropped(int p_149650_1_, Random p_149650_2_, int p_149650_3_) { - return ModItems.petal; - } + @Override + public Item getItemDropped(int p_149650_1_, Random p_149650_2_, int p_149650_3_) { + return ModItems.petal; + } - @Override - public int getRenderType() { - return 0; - } + @Override + public int getRenderType() { + return 0; + } } diff --git a/src/main/java/vazkii/botania/common/block/decor/BlockCustomBrick.java b/src/main/java/vazkii/botania/common/block/decor/BlockCustomBrick.java index 063738508c..7015251bd3 100644 --- a/src/main/java/vazkii/botania/common/block/decor/BlockCustomBrick.java +++ b/src/main/java/vazkii/botania/common/block/decor/BlockCustomBrick.java @@ -2,16 +2,16 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jul 28, 2014, 9:51:48 PM (GMT)] */ package vazkii.botania.common.block.decor; +import cpw.mods.fml.common.registry.GameRegistry; import java.util.List; - import net.minecraft.block.Block; import net.minecraft.block.material.Material; import net.minecraft.client.renderer.texture.IIconRegister; @@ -29,65 +29,61 @@ import vazkii.botania.common.item.block.ItemBlockWithMetadataAndName; import vazkii.botania.common.lexicon.LexiconData; import vazkii.botania.common.lib.LibBlockNames; -import cpw.mods.fml.common.registry.GameRegistry; public class BlockCustomBrick extends BlockMod implements ILexiconable { - private static final int TYPES = 16; - IIcon[] icons; - - public BlockCustomBrick() { - super(Material.rock); - setHardness(2.0F); - setResistance(5.0F); - setStepSound(soundTypeStone); - setBlockName(LibBlockNames.CUSTOM_BRICK); - } + private static final int TYPES = 16; + IIcon[] icons; - @Override - protected boolean shouldRegisterInNameSet() { - return false; - } + public BlockCustomBrick() { + super(Material.rock); + setHardness(2.0F); + setResistance(5.0F); + setStepSound(soundTypeStone); + setBlockName(LibBlockNames.CUSTOM_BRICK); + } - @Override - public int damageDropped(int par1) { - return par1; - } + @Override + protected boolean shouldRegisterInNameSet() { + return false; + } - @Override - public Block setBlockName(String par1Str) { - GameRegistry.registerBlock(this, ItemBlockWithMetadataAndName.class, par1Str); - return super.setBlockName(par1Str); - } + @Override + public int damageDropped(int par1) { + return par1; + } - @Override - public void getSubBlocks(Item par1, CreativeTabs par2CreativeTabs, List par3List) { - for(int i = 0; i < TYPES; i++) - par3List.add(new ItemStack(par1, 1, i)); - } + @Override + public Block setBlockName(String par1Str) { + GameRegistry.registerBlock(this, ItemBlockWithMetadataAndName.class, par1Str); + return super.setBlockName(par1Str); + } - @Override - public void registerBlockIcons(IIconRegister par1IconRegister) { - icons = new IIcon[TYPES]; - for(int i = 0; i < TYPES; i++) - icons[i] = IconHelper.forBlock(par1IconRegister, this, i); - } + @Override + public void getSubBlocks(Item par1, CreativeTabs par2CreativeTabs, List par3List) { + for (int i = 0; i < TYPES; i++) par3List.add(new ItemStack(par1, 1, i)); + } - @Override - public IIcon getIcon(int par1, int par2) { - return icons[Math.min(TYPES - 1, par2)]; - } + @Override + public void registerBlockIcons(IIconRegister par1IconRegister) { + icons = new IIcon[TYPES]; + for (int i = 0; i < TYPES; i++) icons[i] = IconHelper.forBlock(par1IconRegister, this, i); + } - @Override - public ItemStack getPickBlock(MovingObjectPosition target, World world, int x, int y, int z) { - int meta = world.getBlockMetadata(x, y, z); - return new ItemStack(this, 1, meta); - } + @Override + public IIcon getIcon(int par1, int par2) { + return icons[Math.min(TYPES - 1, par2)]; + } - @Override - public LexiconEntry getEntry(World world, int x, int y, int z, EntityPlayer player, ItemStack lexicon) { - int meta = world.getBlockMetadata(x, y, z); - return meta >= 4 ? LexiconData.azulejo : LexiconData.decorativeBlocks; - } + @Override + public ItemStack getPickBlock(MovingObjectPosition target, World world, int x, int y, int z) { + int meta = world.getBlockMetadata(x, y, z); + return new ItemStack(this, 1, meta); + } + @Override + public LexiconEntry getEntry(World world, int x, int y, int z, EntityPlayer player, ItemStack lexicon) { + int meta = world.getBlockMetadata(x, y, z); + return meta >= 4 ? LexiconData.azulejo : LexiconData.decorativeBlocks; + } } diff --git a/src/main/java/vazkii/botania/common/block/decor/BlockDirtPath.java b/src/main/java/vazkii/botania/common/block/decor/BlockDirtPath.java index 500bd4e473..7e7d557644 100644 --- a/src/main/java/vazkii/botania/common/block/decor/BlockDirtPath.java +++ b/src/main/java/vazkii/botania/common/block/decor/BlockDirtPath.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jan 18, 2015, 1:47:03 AM (GMT)] */ package vazkii.botania.common.block.decor; @@ -29,75 +29,72 @@ public class BlockDirtPath extends BlockMod implements ILexiconable { - public BlockDirtPath() { - super(Material.ground); - setBlockBounds(0F, 0F, 0F, 1F, 15F / 16F, 1F); - setLightOpacity(255); - setHardness(0.6F); - setStepSound(soundTypeGravel); - setBlockName(LibBlockNames.DIRT_PATH); - useNeighborBrightness = true; - } + public BlockDirtPath() { + super(Material.ground); + setBlockBounds(0F, 0F, 0F, 1F, 15F / 16F, 1F); + setLightOpacity(255); + setHardness(0.6F); + setStepSound(soundTypeGravel); + setBlockName(LibBlockNames.DIRT_PATH); + useNeighborBrightness = true; + } - @Override - public boolean isToolEffective(String type, int metadata) { - return type.equals("shovel"); - } + @Override + public boolean isToolEffective(String type, int metadata) { + return type.equals("shovel"); + } - @Override - public void onEntityWalking(World world, int x, int y, int z, Entity entity) { - float speed = 2F; - float max = 0.4F; + @Override + public void onEntityWalking(World world, int x, int y, int z, Entity entity) { + float speed = 2F; + float max = 0.4F; - double motionX = Math.abs(entity.motionX); - double motionZ = Math.abs(entity.motionZ); - if(motionX < max) - entity.motionX *= speed; - if(motionZ < max) - entity.motionZ *= speed; - } + double motionX = Math.abs(entity.motionX); + double motionZ = Math.abs(entity.motionZ); + if (motionX < max) entity.motionX *= speed; + if (motionZ < max) entity.motionZ *= speed; + } - @Override - public void setBlockBoundsBasedOnState(IBlockAccess world, int x, int y, int z) { - Block blockAbove = world.getBlock(x, y + 1, z); - if(!blockAbove.isAir(world, x, y + 1, z)) - setBlockBounds(0F, 0F, 0F, 1F, 1, 1F); - else setBlockBounds(0F, 0F, 0F, 1F, 15F / 16F, 1F); - } + @Override + public void setBlockBoundsBasedOnState(IBlockAccess world, int x, int y, int z) { + Block blockAbove = world.getBlock(x, y + 1, z); + if (!blockAbove.isAir(world, x, y + 1, z)) setBlockBounds(0F, 0F, 0F, 1F, 1, 1F); + else setBlockBounds(0F, 0F, 0F, 1F, 15F / 16F, 1F); + } - @Override - public boolean isSideSolid(IBlockAccess world, int x, int y, int z, ForgeDirection side) { - return side == ForgeDirection.DOWN; - } + @Override + public boolean isSideSolid(IBlockAccess world, int x, int y, int z, ForgeDirection side) { + return side == ForgeDirection.DOWN; + } - @Override - public void onNeighborBlockChange(World world, int x, int y, int z, Block block) { - setBlockBoundsBasedOnState(world, x, y, z); - } + @Override + public void onNeighborBlockChange(World world, int x, int y, int z, Block block) { + setBlockBoundsBasedOnState(world, x, y, z); + } - @Override - public AxisAlignedBB getCollisionBoundingBoxFromPool(World world, int x, int y, int z) { - return AxisAlignedBB.getBoundingBox(x, y, z, x + 1, y + 1, z + 1); - } + @Override + public AxisAlignedBB getCollisionBoundingBoxFromPool(World world, int x, int y, int z) { + return AxisAlignedBB.getBoundingBox(x, y, z, x + 1, y + 1, z + 1); + } - @Override - public boolean isOpaqueCube() { - return false; - } + @Override + public boolean isOpaqueCube() { + return false; + } - @Override - public boolean renderAsNormalBlock() { - return false; - } + @Override + public boolean renderAsNormalBlock() { + return false; + } - @Override - public boolean canSustainPlant(IBlockAccess world, int x, int y, int z, ForgeDirection direction, IPlantable plantable) { - return plantable.getPlantType(world, x, y - 1, z) == EnumPlantType.Plains; - } - - @Override - public LexiconEntry getEntry(World world, int x, int y, int z, EntityPlayer player, ItemStack lexicon) { - return LexiconData.dirtPath; - } + @Override + public boolean canSustainPlant( + IBlockAccess world, int x, int y, int z, ForgeDirection direction, IPlantable plantable) { + return plantable.getPlantType(world, x, y - 1, z) == EnumPlantType.Plains; + } + @Override + public LexiconEntry getEntry(World world, int x, int y, int z, EntityPlayer player, ItemStack lexicon) { + return LexiconData.dirtPath; + } } diff --git a/src/main/java/vazkii/botania/common/block/decor/BlockElfGlass.java b/src/main/java/vazkii/botania/common/block/decor/BlockElfGlass.java index f4597f2b93..c2a4887d87 100644 --- a/src/main/java/vazkii/botania/common/block/decor/BlockElfGlass.java +++ b/src/main/java/vazkii/botania/common/block/decor/BlockElfGlass.java @@ -2,16 +2,15 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Sep 8, 2014, 6:40:17 PM (GMT)] */ package vazkii.botania.common.block.decor; import java.util.Random; - import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; @@ -27,35 +26,33 @@ public class BlockElfGlass extends BlockManaGlass implements IElvenItem, ILexiconable { - private static final int ICON_COUNT = 4; - IIcon[] icons; - - public BlockElfGlass() { - super(LibBlockNames.ELF_GLASS); - } - - @Override - public void registerBlockIcons(IIconRegister par1IconRegister) { - icons = new IIcon[ICON_COUNT]; - for(int i = 0; i < ICON_COUNT; i++) - icons[i] = IconHelper.forBlock(par1IconRegister, this, i); - blockIcon = IconHelper.forBlock(par1IconRegister, this); - } - - @Override - public IIcon getIcon(IBlockAccess world, int x, int y, int z, int s) { - int v = (int) Math.floor(new Random(x * 10 ^ y * 20 ^ z * 30).nextInt(ICON_COUNT * 100) / 100.0); - return icons[v]; - } - - @Override - public boolean isElvenItem(ItemStack stack) { - return true; - } - - @Override - public LexiconEntry getEntry(World world, int x, int y, int z, EntityPlayer player, ItemStack lexicon) { - return LexiconData.elvenResources; - } - + private static final int ICON_COUNT = 4; + IIcon[] icons; + + public BlockElfGlass() { + super(LibBlockNames.ELF_GLASS); + } + + @Override + public void registerBlockIcons(IIconRegister par1IconRegister) { + icons = new IIcon[ICON_COUNT]; + for (int i = 0; i < ICON_COUNT; i++) icons[i] = IconHelper.forBlock(par1IconRegister, this, i); + blockIcon = IconHelper.forBlock(par1IconRegister, this); + } + + @Override + public IIcon getIcon(IBlockAccess world, int x, int y, int z, int s) { + int v = (int) Math.floor(new Random(x * 10 ^ y * 20 ^ z * 30).nextInt(ICON_COUNT * 100) / 100.0); + return icons[v]; + } + + @Override + public boolean isElvenItem(ItemStack stack) { + return true; + } + + @Override + public LexiconEntry getEntry(World world, int x, int y, int z, EntityPlayer player, ItemStack lexicon) { + return LexiconData.elvenResources; + } } diff --git a/src/main/java/vazkii/botania/common/block/decor/BlockEndStoneBrick.java b/src/main/java/vazkii/botania/common/block/decor/BlockEndStoneBrick.java index 22b476c676..81120bd591 100644 --- a/src/main/java/vazkii/botania/common/block/decor/BlockEndStoneBrick.java +++ b/src/main/java/vazkii/botania/common/block/decor/BlockEndStoneBrick.java @@ -2,16 +2,16 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Feb 16, 2015, 8:17:12 PM (GMT)] */ package vazkii.botania.common.block.decor; +import cpw.mods.fml.common.registry.GameRegistry; import java.util.List; - import net.minecraft.block.Block; import net.minecraft.block.material.Material; import net.minecraft.client.renderer.texture.IIconRegister; @@ -29,63 +29,60 @@ import vazkii.botania.common.item.block.ItemBlockWithMetadataAndName; import vazkii.botania.common.lexicon.LexiconData; import vazkii.botania.common.lib.LibBlockNames; -import cpw.mods.fml.common.registry.GameRegistry; public class BlockEndStoneBrick extends BlockMod implements ILexiconable { - private static IIcon[] icons = new IIcon[5]; - - public BlockEndStoneBrick() { - super(Material.rock); - setHardness(1.5F); - setResistance(10F); - setStepSound(soundTypeStone); - setBlockName(LibBlockNames.END_STONE_BRICK); - } + private static IIcon[] icons = new IIcon[5]; - @Override - public void registerBlockIcons(IIconRegister register) { - for(int i = 0; i < icons.length; i++) { - icons[i] = IconHelper.forBlock(register, this, i); - } - } + public BlockEndStoneBrick() { + super(Material.rock); + setHardness(1.5F); + setResistance(10F); + setStepSound(soundTypeStone); + setBlockName(LibBlockNames.END_STONE_BRICK); + } - @Override - public void getSubBlocks(Item item, CreativeTabs tab, List list) { - for(int i = 0; i < 4; i++) - list.add(new ItemStack(item, 1, i)); - } + @Override + public void registerBlockIcons(IIconRegister register) { + for (int i = 0; i < icons.length; i++) { + icons[i] = IconHelper.forBlock(register, this, i); + } + } - @Override - public IIcon getIcon(int side, int meta) { - return meta == 3 ? icons[side == 0 || side == 1 ? 4 : 3] : icons[Math.min(icons.length - 1, meta)]; - } + @Override + public void getSubBlocks(Item item, CreativeTabs tab, List list) { + for (int i = 0; i < 4; i++) list.add(new ItemStack(item, 1, i)); + } - @Override - protected boolean shouldRegisterInNameSet() { - return false; - } + @Override + public IIcon getIcon(int side, int meta) { + return meta == 3 ? icons[side == 0 || side == 1 ? 4 : 3] : icons[Math.min(icons.length - 1, meta)]; + } - @Override - public int damageDropped(int par1) { - return par1; - } + @Override + protected boolean shouldRegisterInNameSet() { + return false; + } - @Override - public Block setBlockName(String par1Str) { - GameRegistry.registerBlock(this, ItemBlockWithMetadataAndName.class, par1Str); - return super.setBlockName(par1Str); - } + @Override + public int damageDropped(int par1) { + return par1; + } - @Override - public ItemStack getPickBlock(MovingObjectPosition target, World world, int x, int y, int z) { - int meta = world.getBlockMetadata(x, y, z); - return new ItemStack(this, 1, meta); - } + @Override + public Block setBlockName(String par1Str) { + GameRegistry.registerBlock(this, ItemBlockWithMetadataAndName.class, par1Str); + return super.setBlockName(par1Str); + } - @Override - public LexiconEntry getEntry(World world, int x, int y, int z, EntityPlayer player, ItemStack lexicon) { - return LexiconData.endStoneDecor; - } + @Override + public ItemStack getPickBlock(MovingObjectPosition target, World world, int x, int y, int z) { + int meta = world.getBlockMetadata(x, y, z); + return new ItemStack(this, 1, meta); + } + @Override + public LexiconEntry getEntry(World world, int x, int y, int z, EntityPlayer player, ItemStack lexicon) { + return LexiconData.endStoneDecor; + } } diff --git a/src/main/java/vazkii/botania/common/block/decor/BlockFloatingFlower.java b/src/main/java/vazkii/botania/common/block/decor/BlockFloatingFlower.java index 0d69eae4e5..e6bdd358bc 100644 --- a/src/main/java/vazkii/botania/common/block/decor/BlockFloatingFlower.java +++ b/src/main/java/vazkii/botania/common/block/decor/BlockFloatingFlower.java @@ -2,16 +2,18 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jul 8, 2014, 10:16:53 PM (GMT)] */ package vazkii.botania.common.block.decor; import cpw.mods.fml.common.Optional; import cpw.mods.fml.common.registry.GameRegistry; +import java.util.List; +import java.util.Random; import net.minecraft.block.Block; import net.minecraft.block.material.Material; import net.minecraft.client.renderer.texture.IIconRegister; @@ -42,133 +44,136 @@ import vazkii.botania.common.lexicon.LexiconData; import vazkii.botania.common.lib.LibBlockNames; -import java.util.List; -import java.util.Random; - @Optional.Interface(modid = "Thaumcraft", iface = "thaumcraft.api.crafting.IInfusionStabiliser", striprefs = true) public class BlockFloatingFlower extends BlockModContainer implements ILexiconable, IInfusionStabiliser { - public BlockFloatingFlower() { - this(LibBlockNames.MINI_ISLAND); - } - - public BlockFloatingFlower(String name) { - super(Material.ground); - setBlockName(name); - setHardness(0.5F); - setStepSound(soundTypeGravel); - setLightLevel(1F); - - float f = 0.1F; - setBlockBounds(f, f, f, 1F - f, 1F - f, 1F - f); - } - - @Override - @Optional.Method(modid = "easycoloredlights") - public int getLightValue(IBlockAccess world, int x, int y, int z) { - return ColoredLightHelper.getPackedColor(world.getBlockMetadata(x, y, z), originalLight); - } - - @Override - protected boolean shouldRegisterInNameSet() { - return false; - } - - @Override - public Block setBlockName(String par1Str) { - register(par1Str); - return super.setBlockName(par1Str); - } - - protected void register(String name) { - GameRegistry.registerBlock(this, ItemBlockWithMetadataAndName.class, name); - } - - @Override - public void randomDisplayTick(World par1World, int par2, int par3, int par4, Random par5Random) { - int meta = par1World.getBlockMetadata(par2, par3, par4); - float[] color = EntitySheep.fleeceColorTable[meta]; - - if(par5Random.nextDouble() < ConfigHandler.flowerParticleFrequency) - Botania.proxy.sparkleFX(par1World, par2 + 0.3 + par5Random.nextFloat() * 0.5, par3 + 0.5 + par5Random.nextFloat() * 0.5, par4 + 0.3 + par5Random.nextFloat() * 0.5, color[0], color[1], color[2], par5Random.nextFloat(), 5); - } - - @Override - public void registerBlockIcons(IIconRegister par1IconRegister) { - // NO-OP - } - - @Override - public void getSubBlocks(Item par1, CreativeTabs par2, List par3) { - for(int i = 0; i < 16; i++) - par3.add(new ItemStack(par1, 1, i)); - } - - @Override - public int damageDropped(int par1) { - return par1; - } - - @Override - public boolean isOpaqueCube() { - return false; - } - - @Override - public boolean renderAsNormalBlock() { - return false; - } - - @Override - public IIcon getIcon(int par1, int par2) { - return Blocks.dirt.getIcon(par1, par2); - } - - @Override - public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int side, float hitX, float hitY, float hitZ) { - ItemStack stack = player.getCurrentEquippedItem(); - if(stack != null) { - IFloatingFlower flower = (IFloatingFlower) world.getTileEntity(x, y, z); - IslandType type = null; - if(stack.getItem() == Items.snowball) - type = IslandType.SNOW; - else if(stack.getItem() instanceof IFloatingFlowerVariant) { - IslandType newType = ((IFloatingFlowerVariant) stack.getItem()).getIslandType(stack); - if(newType != null) - type = newType; - } - - if(type != null && type != flower.getIslandType()) { - if(!world.isRemote) { - flower.setIslandType(type); - VanillaPacketDispatcher.dispatchTEToNearbyPlayers(world, x, y, z); - } - - if(!player.capabilities.isCreativeMode) - stack.stackSize--; - return true; - } - } - return false; - } - - @Override - public int getRenderType() { - return LibRenderIDs.idMiniIsland; - } - - @Override - public TileEntity createNewTileEntity(World world, int meta) { - return new TileFloatingFlower(); - } - - @Override - public LexiconEntry getEntry(World world, int x, int y, int z, EntityPlayer player, ItemStack lexicon) { - return LexiconData.shinyFlowers; - } - - @Override - public boolean canStabaliseInfusion(World world, int x, int y, int z) { - return ConfigHandler.enableThaumcraftStablizers; - } + public BlockFloatingFlower() { + this(LibBlockNames.MINI_ISLAND); + } + + public BlockFloatingFlower(String name) { + super(Material.ground); + setBlockName(name); + setHardness(0.5F); + setStepSound(soundTypeGravel); + setLightLevel(1F); + + float f = 0.1F; + setBlockBounds(f, f, f, 1F - f, 1F - f, 1F - f); + } + + @Override + @Optional.Method(modid = "easycoloredlights") + public int getLightValue(IBlockAccess world, int x, int y, int z) { + return ColoredLightHelper.getPackedColor(world.getBlockMetadata(x, y, z), originalLight); + } + + @Override + protected boolean shouldRegisterInNameSet() { + return false; + } + + @Override + public Block setBlockName(String par1Str) { + register(par1Str); + return super.setBlockName(par1Str); + } + + protected void register(String name) { + GameRegistry.registerBlock(this, ItemBlockWithMetadataAndName.class, name); + } + + @Override + public void randomDisplayTick(World par1World, int par2, int par3, int par4, Random par5Random) { + int meta = par1World.getBlockMetadata(par2, par3, par4); + float[] color = EntitySheep.fleeceColorTable[meta]; + + if (par5Random.nextDouble() < ConfigHandler.flowerParticleFrequency) + Botania.proxy.sparkleFX( + par1World, + par2 + 0.3 + par5Random.nextFloat() * 0.5, + par3 + 0.5 + par5Random.nextFloat() * 0.5, + par4 + 0.3 + par5Random.nextFloat() * 0.5, + color[0], + color[1], + color[2], + par5Random.nextFloat(), + 5); + } + + @Override + public void registerBlockIcons(IIconRegister par1IconRegister) { + // NO-OP + } + + @Override + public void getSubBlocks(Item par1, CreativeTabs par2, List par3) { + for (int i = 0; i < 16; i++) par3.add(new ItemStack(par1, 1, i)); + } + + @Override + public int damageDropped(int par1) { + return par1; + } + + @Override + public boolean isOpaqueCube() { + return false; + } + + @Override + public boolean renderAsNormalBlock() { + return false; + } + + @Override + public IIcon getIcon(int par1, int par2) { + return Blocks.dirt.getIcon(par1, par2); + } + + @Override + public boolean onBlockActivated( + World world, int x, int y, int z, EntityPlayer player, int side, float hitX, float hitY, float hitZ) { + ItemStack stack = player.getCurrentEquippedItem(); + if (stack != null) { + IFloatingFlower flower = (IFloatingFlower) world.getTileEntity(x, y, z); + IslandType type = null; + if (stack.getItem() == Items.snowball) type = IslandType.SNOW; + else if (stack.getItem() instanceof IFloatingFlowerVariant) { + IslandType newType = ((IFloatingFlowerVariant) stack.getItem()).getIslandType(stack); + if (newType != null) type = newType; + } + + if (type != null && type != flower.getIslandType()) { + if (!world.isRemote) { + flower.setIslandType(type); + VanillaPacketDispatcher.dispatchTEToNearbyPlayers(world, x, y, z); + } + + if (!player.capabilities.isCreativeMode) stack.stackSize--; + return true; + } + } + return false; + } + + @Override + public int getRenderType() { + return LibRenderIDs.idMiniIsland; + } + + @Override + public TileEntity createNewTileEntity(World world, int meta) { + return new TileFloatingFlower(); + } + + @Override + public LexiconEntry getEntry(World world, int x, int y, int z, EntityPlayer player, ItemStack lexicon) { + return LexiconData.shinyFlowers; + } + + @Override + public boolean canStabaliseInfusion(World world, int x, int y, int z) { + return ConfigHandler.enableThaumcraftStablizers; + } } diff --git a/src/main/java/vazkii/botania/common/block/decor/BlockManaBeacon.java b/src/main/java/vazkii/botania/common/block/decor/BlockManaBeacon.java index 90d3d7a119..0952f2fd9f 100644 --- a/src/main/java/vazkii/botania/common/block/decor/BlockManaBeacon.java +++ b/src/main/java/vazkii/botania/common/block/decor/BlockManaBeacon.java @@ -2,17 +2,17 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Mar 3, 2014, 4:53:59 PM (GMT)] */ package vazkii.botania.common.block.decor; +import cpw.mods.fml.common.registry.GameRegistry; import java.awt.Color; import java.util.List; - import net.minecraft.block.Block; import net.minecraft.block.material.Material; import net.minecraft.client.renderer.texture.IIconRegister; @@ -33,84 +33,81 @@ import vazkii.botania.common.item.block.ItemBlockWithMetadataAndName; import vazkii.botania.common.lexicon.LexiconData; import vazkii.botania.common.lib.LibBlockNames; -import cpw.mods.fml.common.registry.GameRegistry; public class BlockManaBeacon extends BlockModContainer implements ILexiconable { - IIcon[] icons; - - public BlockManaBeacon() { - super(Material.iron); - setHardness(5.0F); - setResistance(10.0F); - setStepSound(soundTypeMetal); - float size = 3F / 16F; - setBlockBounds(size, size, size, 1F - size, 1F - size, 1F - size); - setBlockName(LibBlockNames.MANA_BEACON); - } - - @Override - public void registerBlockIcons(IIconRegister par1IconRegister) { - icons = new IIcon[2]; - for(int i = 0; i < 2; i++) - icons[i] = IconHelper.forBlock(par1IconRegister, this, i); - } - - @Override - public IIcon getIcon(int par1, int par2) { - return icons[par1 == 1 ? 1 : 0]; - } - - @Override - public void getSubBlocks(Item par1, CreativeTabs par2CreativeTabs, List par3List) { - for(int i = 0; i < 16; i++) - par3List.add(new ItemStack(par1, 1, i)); - } - - @Override - public Block setBlockName(String par1Str) { - GameRegistry.registerBlock(this, ItemBlockWithMetadataAndName.class, par1Str); - return super.setBlockName(par1Str); - } - - @Override - protected boolean shouldRegisterInNameSet() { - return false; - } - - @Override - public boolean renderAsNormalBlock() { - return false; - } - - @Override - public boolean isOpaqueCube() { - return false; - } - - @Override - public int damageDropped(int par1) { - return par1; - } - - @Override - public int getRenderColor(int par1) { - float[] color = EntitySheep.fleeceColorTable[par1]; - return new Color(color[0], color[1], color[2]).getRGB(); - } - - @Override - public int colorMultiplier(IBlockAccess par1iBlockAccess, int par2, int par3, int par4) { - return getRenderColor(par1iBlockAccess.getBlockMetadata(par2, par3, par4)); - } - - @Override - public LexiconEntry getEntry(World world, int x, int y, int z, EntityPlayer player, ItemStack lexicon) { - return LexiconData.unstableBlocks; - } - - @Override - public TileEntity createNewTileEntity(World world, int meta) { - return new TileManaBeacon(); - } + IIcon[] icons; + + public BlockManaBeacon() { + super(Material.iron); + setHardness(5.0F); + setResistance(10.0F); + setStepSound(soundTypeMetal); + float size = 3F / 16F; + setBlockBounds(size, size, size, 1F - size, 1F - size, 1F - size); + setBlockName(LibBlockNames.MANA_BEACON); + } + + @Override + public void registerBlockIcons(IIconRegister par1IconRegister) { + icons = new IIcon[2]; + for (int i = 0; i < 2; i++) icons[i] = IconHelper.forBlock(par1IconRegister, this, i); + } + + @Override + public IIcon getIcon(int par1, int par2) { + return icons[par1 == 1 ? 1 : 0]; + } + + @Override + public void getSubBlocks(Item par1, CreativeTabs par2CreativeTabs, List par3List) { + for (int i = 0; i < 16; i++) par3List.add(new ItemStack(par1, 1, i)); + } + + @Override + public Block setBlockName(String par1Str) { + GameRegistry.registerBlock(this, ItemBlockWithMetadataAndName.class, par1Str); + return super.setBlockName(par1Str); + } + + @Override + protected boolean shouldRegisterInNameSet() { + return false; + } + + @Override + public boolean renderAsNormalBlock() { + return false; + } + + @Override + public boolean isOpaqueCube() { + return false; + } + + @Override + public int damageDropped(int par1) { + return par1; + } + + @Override + public int getRenderColor(int par1) { + float[] color = EntitySheep.fleeceColorTable[par1]; + return new Color(color[0], color[1], color[2]).getRGB(); + } + + @Override + public int colorMultiplier(IBlockAccess par1iBlockAccess, int par2, int par3, int par4) { + return getRenderColor(par1iBlockAccess.getBlockMetadata(par2, par3, par4)); + } + + @Override + public LexiconEntry getEntry(World world, int x, int y, int z, EntityPlayer player, ItemStack lexicon) { + return LexiconData.unstableBlocks; + } + + @Override + public TileEntity createNewTileEntity(World world, int meta) { + return new TileManaBeacon(); + } } diff --git a/src/main/java/vazkii/botania/common/block/decor/BlockManaFlame.java b/src/main/java/vazkii/botania/common/block/decor/BlockManaFlame.java index fdf5c95b66..1c0af52a8f 100644 --- a/src/main/java/vazkii/botania/common/block/decor/BlockManaFlame.java +++ b/src/main/java/vazkii/botania/common/block/decor/BlockManaFlame.java @@ -2,16 +2,16 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Dec 21, 2014, 12:28:06 AM (GMT)] */ package vazkii.botania.common.block.decor; +import cpw.mods.fml.common.Optional; import java.util.ArrayList; - import net.minecraft.block.material.Material; import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.entity.player.EntityPlayer; @@ -31,94 +31,94 @@ import vazkii.botania.common.lexicon.LexiconData; import vazkii.botania.common.lib.LibBlockNames; import vazkii.botania.common.world.WorldTypeSkyblock; -import cpw.mods.fml.common.Optional; public class BlockManaFlame extends BlockModContainer implements ILexiconable { - public BlockManaFlame() { - super(Material.cloth); - setBlockName(LibBlockNames.MANA_FLAME); - float f = 0.25F; - setStepSound(soundTypeCloth); - setBlockBounds(f, f, f, 1F - f, 1F - f, 1F - f); - setLightLevel(1F); - } - - @Override - public boolean registerInCreative() { - return false; - } - - @Override - @Optional.Method(modid = "easycoloredlights") - public int getLightValue(IBlockAccess world, int x, int y, int z) { - return ((TileManaFlame) world.getTileEntity(x, y, z)).getLightColor(); - } - - @Override - public void registerBlockIcons(IIconRegister par1IconRegister) { - // NO-OP - } - - @Override - public int getRenderType() { - return -1; - } - - @Override - public boolean isOpaqueCube() { - return false; - } - - @Override - public boolean renderAsNormalBlock() { - return false; - } - - @Override - public boolean getBlocksMovement(IBlockAccess p_149655_1_, int p_149655_2_, int p_149655_3_, int p_149655_4_) { - return true; - } - - @Override - public AxisAlignedBB getCollisionBoundingBoxFromPool(World p_149668_1_, int p_149668_2_, int p_149668_3_, int p_149668_4_) { - return null; - } - - @Override - public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int s, float xs, float ys, float zs) { - if(WorldTypeSkyblock.isWorldSkyblock(world)) { - ItemStack stack = player.getCurrentEquippedItem(); - if(stack != null && stack.getItem() == Item.getItemFromBlock(Blocks.sapling) && !player.inventory.hasItem(ModItems.lexicon)) { - if(!world.isRemote) - stack.stackSize--; - if(!player.inventory.addItemStackToInventory(new ItemStack(ModItems.lexicon))) - player.dropPlayerItemWithRandomChoice(new ItemStack(ModItems.lexicon), false); - return true; - } - - } - return false; - } - - @Override - public IIcon getIcon(int side, int meta) { - return Blocks.fire.getIcon(side, meta); - } - - @Override - public ArrayList getDrops(World world, int x, int y, int z, int metadata, int fortune) { - return new ArrayList(); - } - - @Override - public TileEntity createNewTileEntity(World world, int meta) { - return new TileManaFlame(); - } - - @Override - public LexiconEntry getEntry(World world, int x, int y, int z, EntityPlayer player, ItemStack lexicon) { - return LexiconData.lenses; - } - + public BlockManaFlame() { + super(Material.cloth); + setBlockName(LibBlockNames.MANA_FLAME); + float f = 0.25F; + setStepSound(soundTypeCloth); + setBlockBounds(f, f, f, 1F - f, 1F - f, 1F - f); + setLightLevel(1F); + } + + @Override + public boolean registerInCreative() { + return false; + } + + @Override + @Optional.Method(modid = "easycoloredlights") + public int getLightValue(IBlockAccess world, int x, int y, int z) { + return ((TileManaFlame) world.getTileEntity(x, y, z)).getLightColor(); + } + + @Override + public void registerBlockIcons(IIconRegister par1IconRegister) { + // NO-OP + } + + @Override + public int getRenderType() { + return -1; + } + + @Override + public boolean isOpaqueCube() { + return false; + } + + @Override + public boolean renderAsNormalBlock() { + return false; + } + + @Override + public boolean getBlocksMovement(IBlockAccess p_149655_1_, int p_149655_2_, int p_149655_3_, int p_149655_4_) { + return true; + } + + @Override + public AxisAlignedBB getCollisionBoundingBoxFromPool( + World p_149668_1_, int p_149668_2_, int p_149668_3_, int p_149668_4_) { + return null; + } + + @Override + public boolean onBlockActivated( + World world, int x, int y, int z, EntityPlayer player, int s, float xs, float ys, float zs) { + if (WorldTypeSkyblock.isWorldSkyblock(world)) { + ItemStack stack = player.getCurrentEquippedItem(); + if (stack != null + && stack.getItem() == Item.getItemFromBlock(Blocks.sapling) + && !player.inventory.hasItem(ModItems.lexicon)) { + if (!world.isRemote) stack.stackSize--; + if (!player.inventory.addItemStackToInventory(new ItemStack(ModItems.lexicon))) + player.dropPlayerItemWithRandomChoice(new ItemStack(ModItems.lexicon), false); + return true; + } + } + return false; + } + + @Override + public IIcon getIcon(int side, int meta) { + return Blocks.fire.getIcon(side, meta); + } + + @Override + public ArrayList getDrops(World world, int x, int y, int z, int metadata, int fortune) { + return new ArrayList(); + } + + @Override + public TileEntity createNewTileEntity(World world, int meta) { + return new TileManaFlame(); + } + + @Override + public LexiconEntry getEntry(World world, int x, int y, int z, EntityPlayer player, ItemStack lexicon) { + return LexiconData.lenses; + } } diff --git a/src/main/java/vazkii/botania/common/block/decor/BlockManaGlass.java b/src/main/java/vazkii/botania/common/block/decor/BlockManaGlass.java index b38cc8e33a..8ff8d6f0a0 100644 --- a/src/main/java/vazkii/botania/common/block/decor/BlockManaGlass.java +++ b/src/main/java/vazkii/botania/common/block/decor/BlockManaGlass.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Nov 1, 2014, 6:09:29 PM (GMT)] */ package vazkii.botania.common.block.decor; @@ -24,42 +24,45 @@ public class BlockManaGlass extends BlockMod implements ILexiconable { - public BlockManaGlass() { - this(LibBlockNames.MANA_GLASS); - } + public BlockManaGlass() { + this(LibBlockNames.MANA_GLASS); + } - public BlockManaGlass(String name) { - super(Material.glass); - setHardness(0.3F); - setStepSound(soundTypeGlass); - setLightLevel(1.0F); - setBlockName(name); - } + public BlockManaGlass(String name) { + super(Material.glass); + setHardness(0.3F); + setStepSound(soundTypeGlass); + setLightLevel(1.0F); + setBlockName(name); + } - @Override - public boolean isOpaqueCube() { - return false; - } + @Override + public boolean isOpaqueCube() { + return false; + } - public boolean shouldSideBeRendered1(IBlockAccess p_149646_1_, int p_149646_2_, int p_149646_3_, int p_149646_4_, int p_149646_5_) { - Block block = p_149646_1_.getBlock(p_149646_2_, p_149646_3_, p_149646_4_); + public boolean shouldSideBeRendered1( + IBlockAccess p_149646_1_, int p_149646_2_, int p_149646_3_, int p_149646_4_, int p_149646_5_) { + Block block = p_149646_1_.getBlock(p_149646_2_, p_149646_3_, p_149646_4_); - return block == this ? false : super.shouldSideBeRendered(p_149646_1_, p_149646_2_, p_149646_3_, p_149646_4_, p_149646_5_); - } + return block == this + ? false + : super.shouldSideBeRendered(p_149646_1_, p_149646_2_, p_149646_3_, p_149646_4_, p_149646_5_); + } - @Override - public boolean shouldSideBeRendered(IBlockAccess p_149646_1_, int p_149646_2_, int p_149646_3_, int p_149646_4_, int p_149646_5_) { - return shouldSideBeRendered1(p_149646_1_, p_149646_2_, p_149646_3_, p_149646_4_, 1 - p_149646_5_); - } + @Override + public boolean shouldSideBeRendered( + IBlockAccess p_149646_1_, int p_149646_2_, int p_149646_3_, int p_149646_4_, int p_149646_5_) { + return shouldSideBeRendered1(p_149646_1_, p_149646_2_, p_149646_3_, p_149646_4_, 1 - p_149646_5_); + } - @Override - public int getRenderBlockPass() { - return 1; - } - - @Override - public LexiconEntry getEntry(World world, int x, int y, int z, EntityPlayer player, ItemStack lexicon) { - return LexiconData.pool; - } + @Override + public int getRenderBlockPass() { + return 1; + } + @Override + public LexiconEntry getEntry(World world, int x, int y, int z, EntityPlayer player, ItemStack lexicon) { + return LexiconData.pool; + } } diff --git a/src/main/java/vazkii/botania/common/block/decor/BlockModMushroom.java b/src/main/java/vazkii/botania/common/block/decor/BlockModMushroom.java index e66816ebca..897f1c82d5 100644 --- a/src/main/java/vazkii/botania/common/block/decor/BlockModMushroom.java +++ b/src/main/java/vazkii/botania/common/block/decor/BlockModMushroom.java @@ -2,17 +2,20 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Feb 23, 2015, 4:24:08 PM (GMT)] */ package vazkii.botania.common.block.decor; +import cpw.mods.fml.common.Optional; +import cpw.mods.fml.common.registry.GameRegistry; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; import java.util.List; import java.util.Random; - import net.minecraft.block.Block; import net.minecraft.block.BlockMushroom; import net.minecraft.client.renderer.texture.IIconRegister; @@ -38,117 +41,123 @@ import vazkii.botania.common.item.block.ItemBlockWithMetadataAndName; import vazkii.botania.common.lexicon.LexiconData; import vazkii.botania.common.lib.LibBlockNames; -import cpw.mods.fml.common.Optional; -import cpw.mods.fml.common.registry.GameRegistry; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; @Optional.Interface(modid = "Thaumcraft", iface = "thaumcraft.api.crafting.IInfusionStabiliser", striprefs = true) public class BlockModMushroom extends BlockMushroom implements IInfusionStabiliser, IHornHarvestable, ILexiconable { - public static IIcon[] icons; - public int originalLight; - - public BlockModMushroom() { - setBlockName(LibBlockNames.MUSHROOM); - setLightLevel(0.2F); - setHardness(0F); - setStepSound(soundTypeGrass); - setBlockBounds(0.3F, 0.0F, 0.3F, 0.8F, 1, 0.8F); - setTickRandomly(false); - setCreativeTab(BotaniaCreativeTab.INSTANCE); - } - - @Override - public void updateTick(World p_149674_1_, int p_149674_2_, int p_149674_3_, int p_149674_4_, Random p_149674_5_) { - // NO-OP, to prevent spreading - } - - @Override - public boolean canBlockStay(World p_149718_1_, int p_149718_2_, int p_149718_3_, int p_149718_4_) { - if(p_149718_3_ >= 0 && p_149718_3_ < 256) { - Block block = p_149718_1_.getBlock(p_149718_2_, p_149718_3_ - 1, p_149718_4_); - return block == Blocks.mycelium || block == Blocks.dirt && p_149718_1_.getBlockMetadata(p_149718_2_, p_149718_3_ - 1, p_149718_4_) == 2 || block.canSustainPlant(p_149718_1_, p_149718_2_, p_149718_3_ - 1, p_149718_4_, ForgeDirection.UP, this); - } - - return false; - } - - @Override - public void getSubBlocks(Item par1, CreativeTabs par2CreativeTabs, List par3List) { - for(int i = 0; i < 16; i++) - par3List.add(new ItemStack(par1, 1, i)); - } - - @Override - public Block setBlockName(String par1Str) { - GameRegistry.registerBlock(this, ItemBlockWithMetadataAndName.class, par1Str); - return super.setBlockName(par1Str); - } - - @Override - @SideOnly(Side.CLIENT) - public void registerBlockIcons(IIconRegister par1IconRegister) { - icons = new IIcon[16]; - - for(int i = 0; i < icons.length; i++) - icons[i] = IconHelper.forBlock(par1IconRegister, this, i); - } - - @Override - public Block setLightLevel(float p_149715_1_) { - originalLight = (int) (p_149715_1_ * 15); - return super.setLightLevel(p_149715_1_); - } - - @Override - @Optional.Method(modid = "easycoloredlights") - public int getLightValue(IBlockAccess world, int x, int y, int z) { - return ColoredLightHelper.getPackedColor(world.getBlockMetadata(x, y, z), originalLight); - } - - @Override - public IIcon getIcon(int par1, int par2) { - return icons[par2]; - } - - @Override - public int damageDropped(int par1) { - return par1; - } - - @Override - public void randomDisplayTick(World par1World, int par2, int par3, int par4, Random par5Random) { - int meta = par1World.getBlockMetadata(par2, par3, par4); - float[] color = EntitySheep.fleeceColorTable[meta]; - - if(par5Random.nextDouble() < ConfigHandler.flowerParticleFrequency * 0.25F) - Botania.proxy.sparkleFX(par1World, par2 + 0.3 + par5Random.nextFloat() * 0.5, par3 + 0.5 + par5Random.nextFloat() * 0.5, par4 + 0.3 + par5Random.nextFloat() * 0.5, color[0], color[1], color[2], par5Random.nextFloat(), 5); - } - - @Override - public boolean canStabaliseInfusion(World world, int x, int y, int z) { - return ConfigHandler.enableThaumcraftStablizers; - } - - @Override - public LexiconEntry getEntry(World world, int x, int y, int z, EntityPlayer player, ItemStack lexicon) { - return LexiconData.mushrooms; - } - - @Override - public boolean canHornHarvest(World world, int x, int y, int z, ItemStack stack, EnumHornType hornType) { - return false; - } - - @Override - public boolean hasSpecialHornHarvest(World world, int x, int y, int z, ItemStack stack, EnumHornType hornType) { - return false; - } - - @Override - public void harvestByHorn(World world, int x, int y, int z, ItemStack stack, EnumHornType hornType) { - // NO-OP - } - + public static IIcon[] icons; + public int originalLight; + + public BlockModMushroom() { + setBlockName(LibBlockNames.MUSHROOM); + setLightLevel(0.2F); + setHardness(0F); + setStepSound(soundTypeGrass); + setBlockBounds(0.3F, 0.0F, 0.3F, 0.8F, 1, 0.8F); + setTickRandomly(false); + setCreativeTab(BotaniaCreativeTab.INSTANCE); + } + + @Override + public void updateTick(World p_149674_1_, int p_149674_2_, int p_149674_3_, int p_149674_4_, Random p_149674_5_) { + // NO-OP, to prevent spreading + } + + @Override + public boolean canBlockStay(World p_149718_1_, int p_149718_2_, int p_149718_3_, int p_149718_4_) { + if (p_149718_3_ >= 0 && p_149718_3_ < 256) { + Block block = p_149718_1_.getBlock(p_149718_2_, p_149718_3_ - 1, p_149718_4_); + return block == Blocks.mycelium + || block == Blocks.dirt + && p_149718_1_.getBlockMetadata(p_149718_2_, p_149718_3_ - 1, p_149718_4_) == 2 + || block.canSustainPlant( + p_149718_1_, p_149718_2_, p_149718_3_ - 1, p_149718_4_, ForgeDirection.UP, this); + } + + return false; + } + + @Override + public void getSubBlocks(Item par1, CreativeTabs par2CreativeTabs, List par3List) { + for (int i = 0; i < 16; i++) par3List.add(new ItemStack(par1, 1, i)); + } + + @Override + public Block setBlockName(String par1Str) { + GameRegistry.registerBlock(this, ItemBlockWithMetadataAndName.class, par1Str); + return super.setBlockName(par1Str); + } + + @Override + @SideOnly(Side.CLIENT) + public void registerBlockIcons(IIconRegister par1IconRegister) { + icons = new IIcon[16]; + + for (int i = 0; i < icons.length; i++) icons[i] = IconHelper.forBlock(par1IconRegister, this, i); + } + + @Override + public Block setLightLevel(float p_149715_1_) { + originalLight = (int) (p_149715_1_ * 15); + return super.setLightLevel(p_149715_1_); + } + + @Override + @Optional.Method(modid = "easycoloredlights") + public int getLightValue(IBlockAccess world, int x, int y, int z) { + return ColoredLightHelper.getPackedColor(world.getBlockMetadata(x, y, z), originalLight); + } + + @Override + public IIcon getIcon(int par1, int par2) { + return icons[par2]; + } + + @Override + public int damageDropped(int par1) { + return par1; + } + + @Override + public void randomDisplayTick(World par1World, int par2, int par3, int par4, Random par5Random) { + int meta = par1World.getBlockMetadata(par2, par3, par4); + float[] color = EntitySheep.fleeceColorTable[meta]; + + if (par5Random.nextDouble() < ConfigHandler.flowerParticleFrequency * 0.25F) + Botania.proxy.sparkleFX( + par1World, + par2 + 0.3 + par5Random.nextFloat() * 0.5, + par3 + 0.5 + par5Random.nextFloat() * 0.5, + par4 + 0.3 + par5Random.nextFloat() * 0.5, + color[0], + color[1], + color[2], + par5Random.nextFloat(), + 5); + } + + @Override + public boolean canStabaliseInfusion(World world, int x, int y, int z) { + return ConfigHandler.enableThaumcraftStablizers; + } + + @Override + public LexiconEntry getEntry(World world, int x, int y, int z, EntityPlayer player, ItemStack lexicon) { + return LexiconData.mushrooms; + } + + @Override + public boolean canHornHarvest(World world, int x, int y, int z, ItemStack stack, EnumHornType hornType) { + return false; + } + + @Override + public boolean hasSpecialHornHarvest(World world, int x, int y, int z, ItemStack stack, EnumHornType hornType) { + return false; + } + + @Override + public void harvestByHorn(World world, int x, int y, int z, ItemStack stack, EnumHornType hornType) { + // NO-OP + } } diff --git a/src/main/java/vazkii/botania/common/block/decor/BlockPavement.java b/src/main/java/vazkii/botania/common/block/decor/BlockPavement.java index d13de732de..346e6e635a 100644 --- a/src/main/java/vazkii/botania/common/block/decor/BlockPavement.java +++ b/src/main/java/vazkii/botania/common/block/decor/BlockPavement.java @@ -2,16 +2,18 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Sep 1, 2015, 6:35:06 PM (GMT)] */ package vazkii.botania.common.block.decor; +import cpw.mods.fml.common.registry.GameRegistry; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; import java.util.List; - import net.minecraft.block.Block; import net.minecraft.block.material.Material; import net.minecraft.client.renderer.texture.IIconRegister; @@ -25,62 +27,56 @@ import vazkii.botania.common.block.BlockMod; import vazkii.botania.common.item.block.ItemBlockWithMetadataAndName; import vazkii.botania.common.lib.LibBlockNames; -import cpw.mods.fml.common.registry.GameRegistry; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; public class BlockPavement extends BlockMod { - public static final int TYPES = 6; - IIcon[] icons; - - public BlockPavement() { - super(Material.rock); - setHardness(2.0F); - setResistance(10.0F); - setStepSound(soundTypeStone); - setBlockName(LibBlockNames.PAVEMENT); - } + public static final int TYPES = 6; + IIcon[] icons; - @Override - protected boolean shouldRegisterInNameSet() { - return false; - } + public BlockPavement() { + super(Material.rock); + setHardness(2.0F); + setResistance(10.0F); + setStepSound(soundTypeStone); + setBlockName(LibBlockNames.PAVEMENT); + } - @Override - public int damageDropped(int par1) { - return par1; - } + @Override + protected boolean shouldRegisterInNameSet() { + return false; + } - @Override - public Block setBlockName(String par1Str) { - GameRegistry.registerBlock(this, ItemBlockWithMetadataAndName.class, par1Str); - return super.setBlockName(par1Str); - } + @Override + public int damageDropped(int par1) { + return par1; + } - @Override - public void getSubBlocks(Item par1, CreativeTabs par2CreativeTabs, List par3List) { - for(int i = 0; i < TYPES; i++) - par3List.add(new ItemStack(par1, 1, i)); - } + @Override + public Block setBlockName(String par1Str) { + GameRegistry.registerBlock(this, ItemBlockWithMetadataAndName.class, par1Str); + return super.setBlockName(par1Str); + } - @Override - @SideOnly(Side.CLIENT) - public void registerBlockIcons(IIconRegister par1IconRegister) { - icons = new IIcon[TYPES]; - for(int i = 0; i < TYPES; i++) - icons[i] = IconHelper.forBlock(par1IconRegister, this, i); - } + @Override + public void getSubBlocks(Item par1, CreativeTabs par2CreativeTabs, List par3List) { + for (int i = 0; i < TYPES; i++) par3List.add(new ItemStack(par1, 1, i)); + } - @Override - public IIcon getIcon(int par1, int par2) { - return icons[Math.min(TYPES - 1, par2)]; - } + @Override + @SideOnly(Side.CLIENT) + public void registerBlockIcons(IIconRegister par1IconRegister) { + icons = new IIcon[TYPES]; + for (int i = 0; i < TYPES; i++) icons[i] = IconHelper.forBlock(par1IconRegister, this, i); + } - @Override - public ItemStack getPickBlock(MovingObjectPosition target, World world, int x, int y, int z) { - int meta = world.getBlockMetadata(x, y, z); - return new ItemStack(this, 1, meta); - } + @Override + public IIcon getIcon(int par1, int par2) { + return icons[Math.min(TYPES - 1, par2)]; + } + @Override + public ItemStack getPickBlock(MovingObjectPosition target, World world, int x, int y, int z) { + int meta = world.getBlockMetadata(x, y, z); + return new ItemStack(this, 1, meta); + } } diff --git a/src/main/java/vazkii/botania/common/block/decor/BlockPetalBlock.java b/src/main/java/vazkii/botania/common/block/decor/BlockPetalBlock.java index 1ee7e29821..e7d22a87df 100644 --- a/src/main/java/vazkii/botania/common/block/decor/BlockPetalBlock.java +++ b/src/main/java/vazkii/botania/common/block/decor/BlockPetalBlock.java @@ -2,17 +2,17 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Feb 9, 2015, 5:17:17 PM (GMT)] */ package vazkii.botania.common.block.decor; +import cpw.mods.fml.common.registry.GameRegistry; import java.awt.Color; import java.util.List; - import net.minecraft.block.Block; import net.minecraft.block.material.Material; import net.minecraft.creativetab.CreativeTabs; @@ -28,52 +28,53 @@ import vazkii.botania.common.item.block.ItemBlockWithMetadataAndName; import vazkii.botania.common.lexicon.LexiconData; import vazkii.botania.common.lib.LibBlockNames; -import cpw.mods.fml.common.registry.GameRegistry; public class BlockPetalBlock extends BlockMod implements ILexiconable { - public BlockPetalBlock() { - super(Material.plants); - setHardness(0.4F); - setStepSound(soundTypeGrass); - setBlockName(LibBlockNames.PETAL_BLOCK); - } - - @Override - public void getSubBlocks(Item item, CreativeTabs tab, List list) { - for(int i = 0; i < 16; i++) - list.add(new ItemStack(item, 1, i)); - } + public BlockPetalBlock() { + super(Material.plants); + setHardness(0.4F); + setStepSound(soundTypeGrass); + setBlockName(LibBlockNames.PETAL_BLOCK); + } - @Override - protected boolean shouldRegisterInNameSet() { - return false; - } + @Override + public void getSubBlocks(Item item, CreativeTabs tab, List list) { + for (int i = 0; i < 16; i++) list.add(new ItemStack(item, 1, i)); + } - @Override - public Block setBlockName(String par1Str) { - GameRegistry.registerBlock(this, ItemBlockWithMetadataAndName.class, par1Str); - return super.setBlockName(par1Str); - } + @Override + protected boolean shouldRegisterInNameSet() { + return false; + } - @Override - public int getRenderColor(int meta) { - return new Color(EntitySheep.fleeceColorTable[meta][0], EntitySheep.fleeceColorTable[meta][1], EntitySheep.fleeceColorTable[meta][2]).getRGB(); - } + @Override + public Block setBlockName(String par1Str) { + GameRegistry.registerBlock(this, ItemBlockWithMetadataAndName.class, par1Str); + return super.setBlockName(par1Str); + } - @Override - public int colorMultiplier(IBlockAccess world, int x, int y, int z) { - return getRenderColor(world.getBlockMetadata(x, y, z)); - } + @Override + public int getRenderColor(int meta) { + return new Color( + EntitySheep.fleeceColorTable[meta][0], + EntitySheep.fleeceColorTable[meta][1], + EntitySheep.fleeceColorTable[meta][2]) + .getRGB(); + } - @Override - public int damageDropped(int meta) { - return meta; - } + @Override + public int colorMultiplier(IBlockAccess world, int x, int y, int z) { + return getRenderColor(world.getBlockMetadata(x, y, z)); + } - @Override - public LexiconEntry getEntry(World world, int x, int y, int z, EntityPlayer player, ItemStack lexicon) { - return LexiconData.flowers; - } + @Override + public int damageDropped(int meta) { + return meta; + } + @Override + public LexiconEntry getEntry(World world, int x, int y, int z, EntityPlayer player, ItemStack lexicon) { + return LexiconData.flowers; + } } diff --git a/src/main/java/vazkii/botania/common/block/decor/BlockPrismarine.java b/src/main/java/vazkii/botania/common/block/decor/BlockPrismarine.java index 870ac12e36..794fe28930 100644 --- a/src/main/java/vazkii/botania/common/block/decor/BlockPrismarine.java +++ b/src/main/java/vazkii/botania/common/block/decor/BlockPrismarine.java @@ -2,16 +2,19 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jun 28, 2014, 8:25:39 PM (GMT)] */ package vazkii.botania.common.block.decor; +import cpw.mods.fml.common.eventhandler.SubscribeEvent; +import cpw.mods.fml.common.registry.GameRegistry; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; import java.util.List; - import net.minecraft.block.Block; import net.minecraft.block.material.Material; import net.minecraft.client.renderer.texture.IIconRegister; @@ -33,78 +36,71 @@ import vazkii.botania.common.item.block.ItemBlockWithMetadataAndName; import vazkii.botania.common.lexicon.LexiconData; import vazkii.botania.common.lib.LibBlockNames; -import cpw.mods.fml.common.eventhandler.SubscribeEvent; -import cpw.mods.fml.common.registry.GameRegistry; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; public class BlockPrismarine extends BlockMod implements ILexiconable { - private static final int TYPES = 3; - IIcon[] icons; + private static final int TYPES = 3; + IIcon[] icons; - public BlockPrismarine() { - super(Material.rock); - setHardness(2.0F); - setResistance(10.0F); - setStepSound(soundTypeStone); - setBlockName(LibBlockNames.PRISMARINE); - MinecraftForge.EVENT_BUS.register(this); - } + public BlockPrismarine() { + super(Material.rock); + setHardness(2.0F); + setResistance(10.0F); + setStepSound(soundTypeStone); + setBlockName(LibBlockNames.PRISMARINE); + MinecraftForge.EVENT_BUS.register(this); + } - @Override - protected boolean shouldRegisterInNameSet() { - return false; - } + @Override + protected boolean shouldRegisterInNameSet() { + return false; + } - @Override - public int damageDropped(int par1) { - return par1; - } + @Override + public int damageDropped(int par1) { + return par1; + } - @Override - public Block setBlockName(String par1Str) { - GameRegistry.registerBlock(this, ItemBlockWithMetadataAndName.class, par1Str); - return super.setBlockName(par1Str); - } + @Override + public Block setBlockName(String par1Str) { + GameRegistry.registerBlock(this, ItemBlockWithMetadataAndName.class, par1Str); + return super.setBlockName(par1Str); + } - @Override - public void getSubBlocks(Item par1, CreativeTabs par2CreativeTabs, List par3List) { - for(int i = 0; i < TYPES; i++) - par3List.add(new ItemStack(par1, 1, i)); - } + @Override + public void getSubBlocks(Item par1, CreativeTabs par2CreativeTabs, List par3List) { + for (int i = 0; i < TYPES; i++) par3List.add(new ItemStack(par1, 1, i)); + } - @Override - @SideOnly(Side.CLIENT) - public void registerBlockIcons(IIconRegister par1IconRegister) { - icons = new IIcon[TYPES]; - for(int i = 1; i < TYPES; i++) - icons[i] = IconHelper.forBlock(par1IconRegister, this, i); - } + @Override + @SideOnly(Side.CLIENT) + public void registerBlockIcons(IIconRegister par1IconRegister) { + icons = new IIcon[TYPES]; + for (int i = 1; i < TYPES; i++) icons[i] = IconHelper.forBlock(par1IconRegister, this, i); + } - @SubscribeEvent - @SideOnly(Side.CLIENT) - public void loadTextures(TextureStitchEvent.Pre event) { - if(event.map.getTextureType() == 0) { - TextureAtlasSprite icon = new InterpolatedIcon("botania:prismarine0"); - if(event.map.setTextureEntry("botania:prismarine0", icon)) - icons[0] = icon; - } - } + @SubscribeEvent + @SideOnly(Side.CLIENT) + public void loadTextures(TextureStitchEvent.Pre event) { + if (event.map.getTextureType() == 0) { + TextureAtlasSprite icon = new InterpolatedIcon("botania:prismarine0"); + if (event.map.setTextureEntry("botania:prismarine0", icon)) icons[0] = icon; + } + } - @Override - public IIcon getIcon(int par1, int par2) { - return icons[Math.min(TYPES - 1, par2)]; - } + @Override + public IIcon getIcon(int par1, int par2) { + return icons[Math.min(TYPES - 1, par2)]; + } - @Override - public ItemStack getPickBlock(MovingObjectPosition target, World world, int x, int y, int z) { - int meta = world.getBlockMetadata(x, y, z); - return new ItemStack(this, 1, meta); - } + @Override + public ItemStack getPickBlock(MovingObjectPosition target, World world, int x, int y, int z) { + int meta = world.getBlockMetadata(x, y, z); + return new ItemStack(this, 1, meta); + } - @Override - public LexiconEntry getEntry(World world, int x, int y, int z, EntityPlayer player, ItemStack lexicon) { - return LexiconData.prismarine; - } -} \ No newline at end of file + @Override + public LexiconEntry getEntry(World world, int x, int y, int z, EntityPlayer player, ItemStack lexicon) { + return LexiconData.prismarine; + } +} diff --git a/src/main/java/vazkii/botania/common/block/decor/BlockReeds.java b/src/main/java/vazkii/botania/common/block/decor/BlockReeds.java index 0cfdf2caed..d8519d8c08 100644 --- a/src/main/java/vazkii/botania/common/block/decor/BlockReeds.java +++ b/src/main/java/vazkii/botania/common/block/decor/BlockReeds.java @@ -2,14 +2,17 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jul 28, 2014, 8:02:49 PM (GMT)] */ package vazkii.botania.common.block.decor; +import cpw.mods.fml.common.registry.GameRegistry; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; import net.minecraft.block.Block; import net.minecraft.block.BlockRotatedPillar; import net.minecraft.block.material.Material; @@ -25,49 +28,44 @@ import vazkii.botania.common.item.block.ItemBlockMod; import vazkii.botania.common.lexicon.LexiconData; import vazkii.botania.common.lib.LibBlockNames; -import cpw.mods.fml.common.registry.GameRegistry; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; public class BlockReeds extends BlockRotatedPillar implements ILexiconable { - IIcon topIcon; - - public BlockReeds() { - super(Material.wood); - setHardness(1.0F); - setStepSound(soundTypeWood); - setBlockName(LibBlockNames.REED_BLOCK); - setCreativeTab(BotaniaCreativeTab.INSTANCE); - } - + IIcon topIcon; - @Override - public Block setBlockName(String par1Str) { - GameRegistry.registerBlock(this, ItemBlockMod.class, par1Str); - return super.setBlockName(par1Str); - } + public BlockReeds() { + super(Material.wood); + setHardness(1.0F); + setStepSound(soundTypeWood); + setBlockName(LibBlockNames.REED_BLOCK); + setCreativeTab(BotaniaCreativeTab.INSTANCE); + } - @Override - @SideOnly(Side.CLIENT) - public void registerBlockIcons(IIconRegister par1IconRegister) { - blockIcon = IconHelper.forBlock(par1IconRegister, this, 0); - topIcon = IconHelper.forBlock(par1IconRegister, this, 1); - } + @Override + public Block setBlockName(String par1Str) { + GameRegistry.registerBlock(this, ItemBlockMod.class, par1Str); + return super.setBlockName(par1Str); + } - @Override - public LexiconEntry getEntry(World world, int x, int y, int z, EntityPlayer player, ItemStack lexicon) { - return LexiconData.decorativeBlocks; - } + @Override + @SideOnly(Side.CLIENT) + public void registerBlockIcons(IIconRegister par1IconRegister) { + blockIcon = IconHelper.forBlock(par1IconRegister, this, 0); + topIcon = IconHelper.forBlock(par1IconRegister, this, 1); + } - @Override - protected IIcon getSideIcon(int p_150163_1_) { - return blockIcon; - } + @Override + public LexiconEntry getEntry(World world, int x, int y, int z, EntityPlayer player, ItemStack lexicon) { + return LexiconData.decorativeBlocks; + } - @Override - protected IIcon getTopIcon(int p_150161_1_) { - return topIcon; - } + @Override + protected IIcon getSideIcon(int p_150163_1_) { + return blockIcon; + } + @Override + protected IIcon getTopIcon(int p_150161_1_) { + return topIcon; + } } diff --git a/src/main/java/vazkii/botania/common/block/decor/BlockSeaLamp.java b/src/main/java/vazkii/botania/common/block/decor/BlockSeaLamp.java index 3811350962..5f9b43d0b3 100644 --- a/src/main/java/vazkii/botania/common/block/decor/BlockSeaLamp.java +++ b/src/main/java/vazkii/botania/common/block/decor/BlockSeaLamp.java @@ -2,14 +2,15 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jun 28, 2014, 9:24:43 PM (GMT)] */ package vazkii.botania.common.block.decor; +import cpw.mods.fml.common.Optional; import net.minecraft.block.material.Material; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; @@ -21,29 +22,29 @@ import vazkii.botania.common.integration.coloredlights.ColoredLightHelper; import vazkii.botania.common.lexicon.LexiconData; import vazkii.botania.common.lib.LibBlockNames; -import cpw.mods.fml.common.Optional; public class BlockSeaLamp extends BlockMod implements ILexiconable { - public BlockSeaLamp() { - super(Material.glass); - setHardness(0.3F); - setStepSound(soundTypeGlass); - setLightLevel(1.0F); - setBlockName(LibBlockNames.SEA_LAMP); - } - - int coloredLight = -1; + public BlockSeaLamp() { + super(Material.glass); + setHardness(0.3F); + setStepSound(soundTypeGlass); + setLightLevel(1.0F); + setBlockName(LibBlockNames.SEA_LAMP); + } - @Override - @Optional.Method(modid = "easycoloredlights") - public int getLightValue(IBlockAccess world, int x, int y, int z) { - return coloredLight == -1 ? (coloredLight = ColoredLightHelper.makeRGBLightValue(85, 136, 125, originalLight)) : coloredLight; - } + int coloredLight = -1; - @Override - public LexiconEntry getEntry(World world, int x, int y, int z, EntityPlayer player, ItemStack lexicon) { - return LexiconData.prismarine; - } + @Override + @Optional.Method(modid = "easycoloredlights") + public int getLightValue(IBlockAccess world, int x, int y, int z) { + return coloredLight == -1 + ? (coloredLight = ColoredLightHelper.makeRGBLightValue(85, 136, 125, originalLight)) + : coloredLight; + } + @Override + public LexiconEntry getEntry(World world, int x, int y, int z, EntityPlayer player, ItemStack lexicon) { + return LexiconData.prismarine; + } } diff --git a/src/main/java/vazkii/botania/common/block/decor/BlockShimmerrock.java b/src/main/java/vazkii/botania/common/block/decor/BlockShimmerrock.java index c99f9c53eb..c0c08deae9 100644 --- a/src/main/java/vazkii/botania/common/block/decor/BlockShimmerrock.java +++ b/src/main/java/vazkii/botania/common/block/decor/BlockShimmerrock.java @@ -2,14 +2,17 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Oct 10, 2015, 10:29:22 PM (GMT)] */ package vazkii.botania.common.block.decor; +import cpw.mods.fml.common.eventhandler.SubscribeEvent; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; import net.minecraft.block.material.Material; import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.client.renderer.texture.TextureAtlasSprite; @@ -24,40 +27,35 @@ import vazkii.botania.common.block.BlockMod; import vazkii.botania.common.lexicon.LexiconData; import vazkii.botania.common.lib.LibBlockNames; -import cpw.mods.fml.common.eventhandler.SubscribeEvent; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; public class BlockShimmerrock extends BlockMod implements ILexiconable { - public BlockShimmerrock() { - super(Material.rock); - setHardness(2.0F); - setResistance(10.0F); - setStepSound(soundTypeStone); - setBlockName(LibBlockNames.SHIMMERROCK); - MinecraftForge.EVENT_BUS.register(this); - } - - @SubscribeEvent - @SideOnly(Side.CLIENT) - public void loadTextures(TextureStitchEvent.Pre event) { - if(event.map.getTextureType() == 0) { - TextureAtlasSprite icon = new InterpolatedIcon("botania:shimmerrock"); - if(event.map.setTextureEntry("botania:shimmerrock", icon)) - blockIcon = icon; - } - } + public BlockShimmerrock() { + super(Material.rock); + setHardness(2.0F); + setResistance(10.0F); + setStepSound(soundTypeStone); + setBlockName(LibBlockNames.SHIMMERROCK); + MinecraftForge.EVENT_BUS.register(this); + } - @Override - @SideOnly(Side.CLIENT) - public void registerBlockIcons(IIconRegister par1IconRegister) { - // NO-OP - } + @SubscribeEvent + @SideOnly(Side.CLIENT) + public void loadTextures(TextureStitchEvent.Pre event) { + if (event.map.getTextureType() == 0) { + TextureAtlasSprite icon = new InterpolatedIcon("botania:shimmerrock"); + if (event.map.setTextureEntry("botania:shimmerrock", icon)) blockIcon = icon; + } + } - @Override - public LexiconEntry getEntry(World world, int x, int y, int z, EntityPlayer player, ItemStack lexicon) { - return LexiconData.rainbowRod; - } + @Override + @SideOnly(Side.CLIENT) + public void registerBlockIcons(IIconRegister par1IconRegister) { + // NO-OP + } + @Override + public LexiconEntry getEntry(World world, int x, int y, int z, EntityPlayer player, ItemStack lexicon) { + return LexiconData.rainbowRod; + } } diff --git a/src/main/java/vazkii/botania/common/block/decor/BlockShimmerwoodPlanks.java b/src/main/java/vazkii/botania/common/block/decor/BlockShimmerwoodPlanks.java index 3a45c951d6..40756f755f 100644 --- a/src/main/java/vazkii/botania/common/block/decor/BlockShimmerwoodPlanks.java +++ b/src/main/java/vazkii/botania/common/block/decor/BlockShimmerwoodPlanks.java @@ -2,14 +2,17 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Oct 11, 2015, 3:08:09 PM (GMT)] */ package vazkii.botania.common.block.decor; +import cpw.mods.fml.common.eventhandler.SubscribeEvent; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; import net.minecraft.block.material.Material; import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.client.renderer.texture.TextureAtlasSprite; @@ -24,39 +27,34 @@ import vazkii.botania.common.block.BlockMod; import vazkii.botania.common.lexicon.LexiconData; import vazkii.botania.common.lib.LibBlockNames; -import cpw.mods.fml.common.eventhandler.SubscribeEvent; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; - -public class BlockShimmerwoodPlanks extends BlockMod implements ILexiconable { - public BlockShimmerwoodPlanks() { - super(Material.wood); - setHardness(2.0F); - setStepSound(soundTypeWood); - setBlockName(LibBlockNames.SHIMMERWOOD_PLANKS); - MinecraftForge.EVENT_BUS.register(this); - } +public class BlockShimmerwoodPlanks extends BlockMod implements ILexiconable { - @SubscribeEvent - @SideOnly(Side.CLIENT) - public void loadTextures(TextureStitchEvent.Pre event) { - if(event.map.getTextureType() == 0) { - TextureAtlasSprite icon = new InterpolatedIcon("botania:shimmerwoodPlanks"); - if(event.map.setTextureEntry("botania:shimmerwoodPlanks", icon)) - blockIcon = icon; - } - } + public BlockShimmerwoodPlanks() { + super(Material.wood); + setHardness(2.0F); + setStepSound(soundTypeWood); + setBlockName(LibBlockNames.SHIMMERWOOD_PLANKS); + MinecraftForge.EVENT_BUS.register(this); + } - @Override - @SideOnly(Side.CLIENT) - public void registerBlockIcons(IIconRegister par1IconRegister) { - // NO-OP - } + @SubscribeEvent + @SideOnly(Side.CLIENT) + public void loadTextures(TextureStitchEvent.Pre event) { + if (event.map.getTextureType() == 0) { + TextureAtlasSprite icon = new InterpolatedIcon("botania:shimmerwoodPlanks"); + if (event.map.setTextureEntry("botania:shimmerwoodPlanks", icon)) blockIcon = icon; + } + } - @Override - public LexiconEntry getEntry(World world, int x, int y, int z, EntityPlayer player, ItemStack lexicon) { - return LexiconData.rainbowRod; - } + @Override + @SideOnly(Side.CLIENT) + public void registerBlockIcons(IIconRegister par1IconRegister) { + // NO-OP + } + @Override + public LexiconEntry getEntry(World world, int x, int y, int z, EntityPlayer player, ItemStack lexicon) { + return LexiconData.rainbowRod; + } } diff --git a/src/main/java/vazkii/botania/common/block/decor/BlockShinyFlower.java b/src/main/java/vazkii/botania/common/block/decor/BlockShinyFlower.java index 7ec379792f..d621b992d6 100644 --- a/src/main/java/vazkii/botania/common/block/decor/BlockShinyFlower.java +++ b/src/main/java/vazkii/botania/common/block/decor/BlockShinyFlower.java @@ -2,14 +2,15 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jun 2, 2014, 8:15:49 PM (GMT)] */ package vazkii.botania.common.block.decor; +import cpw.mods.fml.common.Optional; import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; @@ -25,68 +26,66 @@ import vazkii.botania.common.integration.coloredlights.ColoredLightHelper; import vazkii.botania.common.lexicon.LexiconData; import vazkii.botania.common.lib.LibBlockNames; -import cpw.mods.fml.common.Optional; @Optional.Interface(modid = "Thaumcraft", iface = "thaumcraft.api.crafting.IInfusionStabiliser", striprefs = true) public class BlockShinyFlower extends BlockModFlower implements IInfusionStabiliser, IHornHarvestable { - private static IIcon[] icons; - private static IIcon[] iconsAlt; - - public BlockShinyFlower() { - super(LibBlockNames.SHINY_FLOWER); - setLightLevel(1F); - } + private static IIcon[] icons; + private static IIcon[] iconsAlt; - @Override - @Optional.Method(modid = "easycoloredlights") - public int getLightValue(IBlockAccess world, int x, int y, int z) { - return ColoredLightHelper.getPackedColor(world.getBlockMetadata(x, y, z), originalLight); - } + public BlockShinyFlower() { + super(LibBlockNames.SHINY_FLOWER); + setLightLevel(1F); + } - @Override - public void registerBlockIcons(IIconRegister register) { - icons = new IIcon[16]; - iconsAlt = new IIcon[16]; - for(int i = 0; i < 16; i++) { - icons[i] = IconHelper.forName(register, "flowerGlimmering" + i); - iconsAlt[i] = IconHelper.forName(register, "flowerGlimmering" + i, BlockModFlower.ALT_DIR); - } - } + @Override + @Optional.Method(modid = "easycoloredlights") + public int getLightValue(IBlockAccess world, int x, int y, int z) { + return ColoredLightHelper.getPackedColor(world.getBlockMetadata(x, y, z), originalLight); + } - @Override - public IIcon getIcon(int par1, int par2) { - return (ConfigHandler.altFlowerTextures ? iconsAlt : icons)[Math.min(icons.length - 1, par2)]; - } + @Override + public void registerBlockIcons(IIconRegister register) { + icons = new IIcon[16]; + iconsAlt = new IIcon[16]; + for (int i = 0; i < 16; i++) { + icons[i] = IconHelper.forName(register, "flowerGlimmering" + i); + iconsAlt[i] = IconHelper.forName(register, "flowerGlimmering" + i, BlockModFlower.ALT_DIR); + } + } - @Override - public LexiconEntry getEntry(World world, int x, int y, int z, EntityPlayer player, ItemStack lexicon) { - return LexiconData.shinyFlowers; - } + @Override + public IIcon getIcon(int par1, int par2) { + return (ConfigHandler.altFlowerTextures ? iconsAlt : icons)[Math.min(icons.length - 1, par2)]; + } - @Override - public boolean func_149851_a(World world, int x, int y, int z, boolean fuckifiknow) { - return false; - } + @Override + public LexiconEntry getEntry(World world, int x, int y, int z, EntityPlayer player, ItemStack lexicon) { + return LexiconData.shinyFlowers; + } - @Override - public boolean canStabaliseInfusion(World world, int x, int y, int z) { - return ConfigHandler.enableThaumcraftStablizers; - } + @Override + public boolean func_149851_a(World world, int x, int y, int z, boolean fuckifiknow) { + return false; + } - @Override - public boolean canHornHarvest(World world, int x, int y, int z, ItemStack stack, EnumHornType hornType) { - return false; - } + @Override + public boolean canStabaliseInfusion(World world, int x, int y, int z) { + return ConfigHandler.enableThaumcraftStablizers; + } - @Override - public boolean hasSpecialHornHarvest(World world, int x, int y, int z, ItemStack stack, EnumHornType hornType) { - return false; - } + @Override + public boolean canHornHarvest(World world, int x, int y, int z, ItemStack stack, EnumHornType hornType) { + return false; + } - @Override - public void harvestByHorn(World world, int x, int y, int z, ItemStack stack, EnumHornType hornType) { - // NO-OP - } + @Override + public boolean hasSpecialHornHarvest(World world, int x, int y, int z, ItemStack stack, EnumHornType hornType) { + return false; + } + @Override + public void harvestByHorn(World world, int x, int y, int z, ItemStack stack, EnumHornType hornType) { + // NO-OP + } } diff --git a/src/main/java/vazkii/botania/common/block/decor/BlockStarfield.java b/src/main/java/vazkii/botania/common/block/decor/BlockStarfield.java index bbde621f0c..efc33c220c 100644 --- a/src/main/java/vazkii/botania/common/block/decor/BlockStarfield.java +++ b/src/main/java/vazkii/botania/common/block/decor/BlockStarfield.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Aug 7, 2014, 6:36:37 PM (GMT)] */ package vazkii.botania.common.block.decor; @@ -27,48 +27,46 @@ public class BlockStarfield extends BlockModContainer implements ILexiconable { - IIcon[] icons; + IIcon[] icons; - public BlockStarfield() { - super(Material.iron); - setHardness(5F); - setResistance(2000F); - setStepSound(soundTypeMetal); - setBlockName(LibBlockNames.STARFIELD); + public BlockStarfield() { + super(Material.iron); + setHardness(5F); + setResistance(2000F); + setStepSound(soundTypeMetal); + setBlockName(LibBlockNames.STARFIELD); - setBlockBounds(0F, 0F, 0F, 1F, 0.25F, 1F); - } + setBlockBounds(0F, 0F, 0F, 1F, 0.25F, 1F); + } - @Override - public void registerBlockIcons(IIconRegister par1IconRegister) { - icons = new IIcon[3]; - for(int i = 0; i < icons.length; i++) - icons[i] = IconHelper.forBlock(par1IconRegister, this, i); - } + @Override + public void registerBlockIcons(IIconRegister par1IconRegister) { + icons = new IIcon[3]; + for (int i = 0; i < icons.length; i++) icons[i] = IconHelper.forBlock(par1IconRegister, this, i); + } - @Override - public IIcon getIcon(int par1, int par2) { - return icons[Math.min(2, par1)]; - } + @Override + public IIcon getIcon(int par1, int par2) { + return icons[Math.min(2, par1)]; + } - @Override - public boolean renderAsNormalBlock() { - return false; - } + @Override + public boolean renderAsNormalBlock() { + return false; + } - @Override - public boolean isOpaqueCube() { - return false; - } + @Override + public boolean isOpaqueCube() { + return false; + } - @Override - public TileEntity createNewTileEntity(World world, int meta) { - return new TileStarfield(); - } - - @Override - public LexiconEntry getEntry(World world, int x, int y, int z, EntityPlayer player, ItemStack lexicon) { - return LexiconData.starfield; - } + @Override + public TileEntity createNewTileEntity(World world, int meta) { + return new TileStarfield(); + } + @Override + public LexiconEntry getEntry(World world, int x, int y, int z, EntityPlayer player, ItemStack lexicon) { + return LexiconData.starfield; + } } diff --git a/src/main/java/vazkii/botania/common/block/decor/BlockThatch.java b/src/main/java/vazkii/botania/common/block/decor/BlockThatch.java index 2efb259869..ab204fe7b4 100644 --- a/src/main/java/vazkii/botania/common/block/decor/BlockThatch.java +++ b/src/main/java/vazkii/botania/common/block/decor/BlockThatch.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jul 28, 2014, 9:07:00 PM (GMT)] */ package vazkii.botania.common.block.decor; @@ -22,16 +22,15 @@ public class BlockThatch extends BlockMod implements ILexiconable { - public BlockThatch() { - super(Material.grass); - setHardness(1.0F); - setStepSound(soundTypeGrass); - setBlockName(LibBlockNames.THATCH); - } - - @Override - public LexiconEntry getEntry(World world, int x, int y, int z, EntityPlayer player, ItemStack lexicon) { - return LexiconData.decorativeBlocks; - } + public BlockThatch() { + super(Material.grass); + setHardness(1.0F); + setStepSound(soundTypeGrass); + setBlockName(LibBlockNames.THATCH); + } + @Override + public LexiconEntry getEntry(World world, int x, int y, int z, EntityPlayer player, ItemStack lexicon) { + return LexiconData.decorativeBlocks; + } } diff --git a/src/main/java/vazkii/botania/common/block/decor/BlockTinyPotato.java b/src/main/java/vazkii/botania/common/block/decor/BlockTinyPotato.java index 6c3a99b0fa..679aa84beb 100644 --- a/src/main/java/vazkii/botania/common/block/decor/BlockTinyPotato.java +++ b/src/main/java/vazkii/botania/common/block/decor/BlockTinyPotato.java @@ -2,16 +2,16 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jul 18, 2014, 7:58:08 PM (GMT)] */ package vazkii.botania.common.block.decor; +import cpw.mods.fml.common.registry.GameRegistry; import java.util.ArrayList; - import net.minecraft.block.Block; import net.minecraft.block.material.Material; import net.minecraft.client.renderer.texture.IIconRegister; @@ -32,103 +32,118 @@ import vazkii.botania.common.item.block.ItemBlockTinyPotato; import vazkii.botania.common.lexicon.LexiconData; import vazkii.botania.common.lib.LibBlockNames; -import cpw.mods.fml.common.registry.GameRegistry; public class BlockTinyPotato extends BlockModContainer implements ILexiconable { - public BlockTinyPotato() { - super(Material.cloth); - setHardness(0.25F); - setBlockName(LibBlockNames.TINY_POTATO); - float f = 1F / 16F * 6F; - setBlockBounds(f, 0, f, 1F - f, f, 1F - f); - } - - @Override - public Block setBlockName(String par1Str) { - GameRegistry.registerBlock(this, ItemBlockTinyPotato.class, par1Str); - return super.setBlockName(par1Str); - } - - @Override - protected boolean shouldRegisterInNameSet() { - return false; - } - - @Override - public void registerBlockIcons(IIconRegister par1IconRegister) { - // NO-OP - } - - @Override - public IIcon getIcon(int side, int meta) { - return Blocks.hardened_clay.getIcon(0, 0); - } - - @Override - public boolean onBlockActivated(World par1World, int par2, int par3, int par4, EntityPlayer par5EntityPlayer, int par6, float par7, float par8, float par9) { - TileEntity tile = par1World.getTileEntity(par2, par3, par4); - if(tile instanceof TileTinyPotato) { - ((TileTinyPotato) tile).interact(); - par5EntityPlayer.addStat(ModAchievements.tinyPotatoPet, 1); - par1World.spawnParticle("heart", par2 + minX + Math.random() * (maxX - minX), par3 + maxY, par4 + minZ + Math.random() * (maxZ - minZ), 0, 0 ,0); - } - return true; - } - - @Override - public void onBlockPlacedBy(World par1World, int par2, int par3, int par4, EntityLivingBase par5EntityLiving, ItemStack par6ItemStack) { - int l1 = MathHelper.floor_double(par5EntityLiving.rotationYaw * 4.0F / 360.0F + 0.5D) & 3; - - par1World.setBlockMetadataWithNotify(par2, par3, par4, l1, 2); - if (par6ItemStack.hasDisplayName()) - ((TileTinyPotato) par1World.getTileEntity(par2, par3, par4)).name = par6ItemStack.getDisplayName(); - } - - @Override - public void onBlockHarvested(World par1World, int par2, int par3, int par4, int par5, EntityPlayer par6EntityPlayer) { - if(!par6EntityPlayer.capabilities.isCreativeMode) - dropBlockAsItem(par1World, par2, par3, par4, par5, 0); - } - - @Override - public ArrayList getDrops(World world, int x, int y, int z, int metadata, int fortune) { - ArrayList list = new ArrayList(); - TileEntity tile = world.getTileEntity(x, y, z); - - if(tile != null) { - ItemStack stack = new ItemStack(this); - String name = ((TileTinyPotato) tile).name; - if(!name.isEmpty()) - stack.setStackDisplayName(name); - list.add(stack); - } - - return list; - } - - @Override - public boolean isOpaqueCube() { - return false; - } - - @Override - public boolean renderAsNormalBlock() { - return false; - } - - @Override - public int getRenderType() { - return LibRenderIDs.idTinyPotato; - } - - @Override - public TileEntity createNewTileEntity(World world, int meta) { - return new TileTinyPotato(); - } - - @Override - public LexiconEntry getEntry(World world, int x, int y, int z, EntityPlayer player, ItemStack lexicon) { - return LexiconData.tinyPotato; - } + public BlockTinyPotato() { + super(Material.cloth); + setHardness(0.25F); + setBlockName(LibBlockNames.TINY_POTATO); + float f = 1F / 16F * 6F; + setBlockBounds(f, 0, f, 1F - f, f, 1F - f); + } + + @Override + public Block setBlockName(String par1Str) { + GameRegistry.registerBlock(this, ItemBlockTinyPotato.class, par1Str); + return super.setBlockName(par1Str); + } + + @Override + protected boolean shouldRegisterInNameSet() { + return false; + } + + @Override + public void registerBlockIcons(IIconRegister par1IconRegister) { + // NO-OP + } + + @Override + public IIcon getIcon(int side, int meta) { + return Blocks.hardened_clay.getIcon(0, 0); + } + + @Override + public boolean onBlockActivated( + World par1World, + int par2, + int par3, + int par4, + EntityPlayer par5EntityPlayer, + int par6, + float par7, + float par8, + float par9) { + TileEntity tile = par1World.getTileEntity(par2, par3, par4); + if (tile instanceof TileTinyPotato) { + ((TileTinyPotato) tile).interact(); + par5EntityPlayer.addStat(ModAchievements.tinyPotatoPet, 1); + par1World.spawnParticle( + "heart", + par2 + minX + Math.random() * (maxX - minX), + par3 + maxY, + par4 + minZ + Math.random() * (maxZ - minZ), + 0, + 0, + 0); + } + return true; + } + + @Override + public void onBlockPlacedBy( + World par1World, int par2, int par3, int par4, EntityLivingBase par5EntityLiving, ItemStack par6ItemStack) { + int l1 = MathHelper.floor_double(par5EntityLiving.rotationYaw * 4.0F / 360.0F + 0.5D) & 3; + + par1World.setBlockMetadataWithNotify(par2, par3, par4, l1, 2); + if (par6ItemStack.hasDisplayName()) + ((TileTinyPotato) par1World.getTileEntity(par2, par3, par4)).name = par6ItemStack.getDisplayName(); + } + + @Override + public void onBlockHarvested( + World par1World, int par2, int par3, int par4, int par5, EntityPlayer par6EntityPlayer) { + if (!par6EntityPlayer.capabilities.isCreativeMode) dropBlockAsItem(par1World, par2, par3, par4, par5, 0); + } + + @Override + public ArrayList getDrops(World world, int x, int y, int z, int metadata, int fortune) { + ArrayList list = new ArrayList(); + TileEntity tile = world.getTileEntity(x, y, z); + + if (tile != null) { + ItemStack stack = new ItemStack(this); + String name = ((TileTinyPotato) tile).name; + if (!name.isEmpty()) stack.setStackDisplayName(name); + list.add(stack); + } + + return list; + } + + @Override + public boolean isOpaqueCube() { + return false; + } + + @Override + public boolean renderAsNormalBlock() { + return false; + } + + @Override + public int getRenderType() { + return LibRenderIDs.idTinyPotato; + } + + @Override + public TileEntity createNewTileEntity(World world, int meta) { + return new TileTinyPotato(); + } + + @Override + public LexiconEntry getEntry(World world, int x, int y, int z, EntityPlayer player, ItemStack lexicon) { + return LexiconData.tinyPotato; + } } diff --git a/src/main/java/vazkii/botania/common/block/decor/BlockUnstable.java b/src/main/java/vazkii/botania/common/block/decor/BlockUnstable.java index 32bc04b1e1..a04ca7e276 100644 --- a/src/main/java/vazkii/botania/common/block/decor/BlockUnstable.java +++ b/src/main/java/vazkii/botania/common/block/decor/BlockUnstable.java @@ -2,18 +2,18 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Feb 4, 2014, 6:00:44 PM (GMT)] */ package vazkii.botania.common.block.decor; +import cpw.mods.fml.common.registry.GameRegistry; import java.awt.Color; import java.util.List; import java.util.Random; - import net.minecraft.block.Block; import net.minecraft.block.material.Material; import net.minecraft.creativetab.CreativeTabs; @@ -31,76 +31,78 @@ import vazkii.botania.common.item.block.ItemBlockWithMetadataAndName; import vazkii.botania.common.lexicon.LexiconData; import vazkii.botania.common.lib.LibBlockNames; -import cpw.mods.fml.common.registry.GameRegistry; public class BlockUnstable extends BlockMod implements ILexiconable { - public BlockUnstable() { - super(Material.iron); - setHardness(5.0F); - setResistance(10.0F); - setStepSound(soundTypeMetal); - setBlockBounds(0.25F, 0.25F, 0.25F, 0.75F, 0.75F, 0.75F); - setBlockName(LibBlockNames.UNSTABLE_BLOCK); - } - - @Override - public void getSubBlocks(Item par1, CreativeTabs par2CreativeTabs, List par3List) { - for(int i = 0; i < 16; i++) - par3List.add(new ItemStack(par1, 1, i)); - } - - @Override - public Block setBlockName(String par1Str) { - GameRegistry.registerBlock(this, ItemBlockWithMetadataAndName.class, par1Str); - return super.setBlockName(par1Str); - } - - @Override - protected boolean shouldRegisterInNameSet() { - return false; - } - - @Override - public boolean renderAsNormalBlock() { - return false; - } - - @Override - public boolean isOpaqueCube() { - return false; - } - - @Override - public void randomDisplayTick(World par1World, int par2, int par3, int par4, Random par5Random) { - int color = getRenderColor(par1World.getBlockMetadata(par2, par3, par4)); - int colorBright = new Color(color).brighter().getRGB(); - int colorDark = new Color(color).darker().getRGB(); - - Vector3 origVector = new Vector3(par2 + 0.5, par3 + 0.5, par4 + 0.5); - Vector3 endVector = origVector.copy().add(par1World.rand.nextDouble() * 2 - 1, par1World.rand.nextDouble() * 2 - 1, par1World.rand.nextDouble() * 2 - 1); - Botania.proxy.lightningFX(par1World, origVector, endVector, 5F, colorDark, colorBright); - } - - @Override - public int damageDropped(int par1) { - return par1; - } - - @Override - public int getRenderColor(int par1) { - float[] color = EntitySheep.fleeceColorTable[par1]; - return new Color(color[0], color[1], color[2]).getRGB(); - } - - @Override - public int colorMultiplier(IBlockAccess par1iBlockAccess, int par2, int par3, int par4) { - return getRenderColor(par1iBlockAccess.getBlockMetadata(par2, par3, par4)); - } - - @Override - public LexiconEntry getEntry(World world, int x, int y, int z, EntityPlayer player, ItemStack lexicon) { - return LexiconData.unstableBlocks; - } - + public BlockUnstable() { + super(Material.iron); + setHardness(5.0F); + setResistance(10.0F); + setStepSound(soundTypeMetal); + setBlockBounds(0.25F, 0.25F, 0.25F, 0.75F, 0.75F, 0.75F); + setBlockName(LibBlockNames.UNSTABLE_BLOCK); + } + + @Override + public void getSubBlocks(Item par1, CreativeTabs par2CreativeTabs, List par3List) { + for (int i = 0; i < 16; i++) par3List.add(new ItemStack(par1, 1, i)); + } + + @Override + public Block setBlockName(String par1Str) { + GameRegistry.registerBlock(this, ItemBlockWithMetadataAndName.class, par1Str); + return super.setBlockName(par1Str); + } + + @Override + protected boolean shouldRegisterInNameSet() { + return false; + } + + @Override + public boolean renderAsNormalBlock() { + return false; + } + + @Override + public boolean isOpaqueCube() { + return false; + } + + @Override + public void randomDisplayTick(World par1World, int par2, int par3, int par4, Random par5Random) { + int color = getRenderColor(par1World.getBlockMetadata(par2, par3, par4)); + int colorBright = new Color(color).brighter().getRGB(); + int colorDark = new Color(color).darker().getRGB(); + + Vector3 origVector = new Vector3(par2 + 0.5, par3 + 0.5, par4 + 0.5); + Vector3 endVector = origVector + .copy() + .add( + par1World.rand.nextDouble() * 2 - 1, + par1World.rand.nextDouble() * 2 - 1, + par1World.rand.nextDouble() * 2 - 1); + Botania.proxy.lightningFX(par1World, origVector, endVector, 5F, colorDark, colorBright); + } + + @Override + public int damageDropped(int par1) { + return par1; + } + + @Override + public int getRenderColor(int par1) { + float[] color = EntitySheep.fleeceColorTable[par1]; + return new Color(color[0], color[1], color[2]).getRGB(); + } + + @Override + public int colorMultiplier(IBlockAccess par1iBlockAccess, int par2, int par3, int par4) { + return getRenderColor(par1iBlockAccess.getBlockMetadata(par2, par3, par4)); + } + + @Override + public LexiconEntry getEntry(World world, int x, int y, int z, EntityPlayer player, ItemStack lexicon) { + return LexiconData.unstableBlocks; + } } diff --git a/src/main/java/vazkii/botania/common/block/decor/IFloatingFlower.java b/src/main/java/vazkii/botania/common/block/decor/IFloatingFlower.java index 1240b9eaed..6b832ed189 100644 --- a/src/main/java/vazkii/botania/common/block/decor/IFloatingFlower.java +++ b/src/main/java/vazkii/botania/common/block/decor/IFloatingFlower.java @@ -2,73 +2,70 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Nov 17, 2014, 6:05:18 PM (GMT)] */ package vazkii.botania.common.block.decor; +import java.util.HashMap; import net.minecraft.item.ItemStack; import net.minecraft.util.ResourceLocation; import vazkii.botania.client.lib.LibResources; -import java.util.HashMap; - public interface IFloatingFlower { - public ItemStack getDisplayStack(); - - public IslandType getIslandType(); - - public void setIslandType(IslandType type); - - public class IslandType { - private static HashMap registry = new HashMap(); - - public static final IslandType GRASS = new IslandType("GRASS", LibResources.MODEL_MINI_ISLAND); - public static final IslandType PODZOL = new IslandType("PODZOL", LibResources.MODEL_MINI_ISLAND_PODZOL); - public static final IslandType MYCEL = new IslandType("MYCEL", LibResources.MODEL_MINI_ISLAND_MYCEL); - public static final IslandType SNOW = new IslandType("SNOW", LibResources.MODEL_MINI_ISLAND_SNOW); - public static final IslandType DRY = new IslandType("DRY", LibResources.MODEL_MINI_ISLAND_DRY); - public static final IslandType GOLDEN = new IslandType("GOLDEN", LibResources.MODEL_MINI_ISLAND_GOLDEN); - public static final IslandType VIVID = new IslandType("VIVID", LibResources.MODEL_MINI_ISLAND_VIVID); - public static final IslandType SCORCHED = new IslandType("SCORCHED", LibResources.MODEL_MINI_ISLAND_SCORCHED); - public static final IslandType INFUSED = new IslandType("INFUSED", LibResources.MODEL_MINI_ISLAND_INFUSED); - public static final IslandType MUTATED = new IslandType("MUTATED", LibResources.MODEL_MINI_ISLAND_MUTATED); - - public IslandType(String name, String s) { - this(name, new ResourceLocation(s)); - } - - public IslandType(String name, ResourceLocation s) { - if (registry.containsKey(name)) throw new IllegalArgumentException(name+" already registered!"); - this.typeName = name; - res = s; - registry.put(name, this); - } - - private final ResourceLocation res; - public final String typeName; - - public static IslandType ofType(String typeStr) { - IslandType type = registry.get(typeStr); - return type == null ? GRASS : type; - } - - public ResourceLocation getResource() { - return res; - } - - public int getColor() { - return 0xFFFFFF; - } - - public String toString() { - return this.typeName; - } - - } - + public ItemStack getDisplayStack(); + + public IslandType getIslandType(); + + public void setIslandType(IslandType type); + + public class IslandType { + private static HashMap registry = new HashMap(); + + public static final IslandType GRASS = new IslandType("GRASS", LibResources.MODEL_MINI_ISLAND); + public static final IslandType PODZOL = new IslandType("PODZOL", LibResources.MODEL_MINI_ISLAND_PODZOL); + public static final IslandType MYCEL = new IslandType("MYCEL", LibResources.MODEL_MINI_ISLAND_MYCEL); + public static final IslandType SNOW = new IslandType("SNOW", LibResources.MODEL_MINI_ISLAND_SNOW); + public static final IslandType DRY = new IslandType("DRY", LibResources.MODEL_MINI_ISLAND_DRY); + public static final IslandType GOLDEN = new IslandType("GOLDEN", LibResources.MODEL_MINI_ISLAND_GOLDEN); + public static final IslandType VIVID = new IslandType("VIVID", LibResources.MODEL_MINI_ISLAND_VIVID); + public static final IslandType SCORCHED = new IslandType("SCORCHED", LibResources.MODEL_MINI_ISLAND_SCORCHED); + public static final IslandType INFUSED = new IslandType("INFUSED", LibResources.MODEL_MINI_ISLAND_INFUSED); + public static final IslandType MUTATED = new IslandType("MUTATED", LibResources.MODEL_MINI_ISLAND_MUTATED); + + public IslandType(String name, String s) { + this(name, new ResourceLocation(s)); + } + + public IslandType(String name, ResourceLocation s) { + if (registry.containsKey(name)) throw new IllegalArgumentException(name + " already registered!"); + this.typeName = name; + res = s; + registry.put(name, this); + } + + private final ResourceLocation res; + public final String typeName; + + public static IslandType ofType(String typeStr) { + IslandType type = registry.get(typeStr); + return type == null ? GRASS : type; + } + + public ResourceLocation getResource() { + return res; + } + + public int getColor() { + return 0xFFFFFF; + } + + public String toString() { + return this.typeName; + } + } } diff --git a/src/main/java/vazkii/botania/common/block/decor/biomestone/BlockBiomeStone.java b/src/main/java/vazkii/botania/common/block/decor/biomestone/BlockBiomeStone.java index bec9355264..cf4b80f316 100644 --- a/src/main/java/vazkii/botania/common/block/decor/biomestone/BlockBiomeStone.java +++ b/src/main/java/vazkii/botania/common/block/decor/biomestone/BlockBiomeStone.java @@ -2,16 +2,16 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jan 29, 2015, 6:54:20 PM (GMT)] */ package vazkii.botania.common.block.decor.biomestone; +import cpw.mods.fml.common.registry.GameRegistry; import java.util.List; - import net.minecraft.block.Block; import net.minecraft.block.material.Material; import net.minecraft.client.renderer.texture.IIconRegister; @@ -28,65 +28,63 @@ import vazkii.botania.common.block.BlockMod; import vazkii.botania.common.item.block.ItemBlockWithMetadataAndName; import vazkii.botania.common.lexicon.LexiconData; -import cpw.mods.fml.common.registry.GameRegistry; public class BlockBiomeStone extends BlockMod implements ILexiconable { - private static IIcon[] icons = new IIcon[32]; - int iconOffset; + private static IIcon[] icons = new IIcon[32]; + int iconOffset; - public BlockBiomeStone(int iconOffset, String name) { - super(Material.rock); - setHardness(1.5F); - setResistance(10F); - setStepSound(soundTypeStone); - setBlockName(name); - this.iconOffset = iconOffset; - } + public BlockBiomeStone(int iconOffset, String name) { + super(Material.rock); + setHardness(1.5F); + setResistance(10F); + setStepSound(soundTypeStone); + setBlockName(name); + this.iconOffset = iconOffset; + } - @Override - public void registerBlockIcons(IIconRegister register) { - for(int i = 0; i < 16; i++) { - int index = i + iconOffset; - icons[index] = IconHelper.forName(register, "biomeStone" + index); - } - } + @Override + public void registerBlockIcons(IIconRegister register) { + for (int i = 0; i < 16; i++) { + int index = i + iconOffset; + icons[index] = IconHelper.forName(register, "biomeStone" + index); + } + } - @Override - public void getSubBlocks(Item item, CreativeTabs tab, List list) { - for(int i = 0; i < 16; i++) - list.add(new ItemStack(item, 1, i)); - } + @Override + public void getSubBlocks(Item item, CreativeTabs tab, List list) { + for (int i = 0; i < 16; i++) list.add(new ItemStack(item, 1, i)); + } - @Override - public IIcon getIcon(int side, int meta) { - return icons[meta + iconOffset]; - } + @Override + public IIcon getIcon(int side, int meta) { + return icons[meta + iconOffset]; + } - @Override - protected boolean shouldRegisterInNameSet() { - return false; - } + @Override + protected boolean shouldRegisterInNameSet() { + return false; + } - @Override - public int damageDropped(int par1) { - return par1; - } + @Override + public int damageDropped(int par1) { + return par1; + } - @Override - public Block setBlockName(String par1Str) { - GameRegistry.registerBlock(this, ItemBlockWithMetadataAndName.class, par1Str); - return super.setBlockName(par1Str); - } + @Override + public Block setBlockName(String par1Str) { + GameRegistry.registerBlock(this, ItemBlockWithMetadataAndName.class, par1Str); + return super.setBlockName(par1Str); + } - @Override - public ItemStack getPickBlock(MovingObjectPosition target, World world, int x, int y, int z) { - int meta = world.getBlockMetadata(x, y, z); - return new ItemStack(this, 1, meta); - } + @Override + public ItemStack getPickBlock(MovingObjectPosition target, World world, int x, int y, int z) { + int meta = world.getBlockMetadata(x, y, z); + return new ItemStack(this, 1, meta); + } - @Override - public LexiconEntry getEntry(World world, int x, int y, int z, EntityPlayer player, ItemStack lexicon) { - return LexiconData.marimorphosis; - } + @Override + public LexiconEntry getEntry(World world, int x, int y, int z, EntityPlayer player, ItemStack lexicon) { + return LexiconData.marimorphosis; + } } diff --git a/src/main/java/vazkii/botania/common/block/decor/biomestone/BlockBiomeStoneA.java b/src/main/java/vazkii/botania/common/block/decor/biomestone/BlockBiomeStoneA.java index 2a9928204c..60d3b412d7 100644 --- a/src/main/java/vazkii/botania/common/block/decor/biomestone/BlockBiomeStoneA.java +++ b/src/main/java/vazkii/botania/common/block/decor/biomestone/BlockBiomeStoneA.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jan 29, 2015, 7:17:35 PM (GMT)] */ package vazkii.botania.common.block.decor.biomestone; @@ -14,13 +14,12 @@ public class BlockBiomeStoneA extends BlockBiomeStone { - public BlockBiomeStoneA() { - super(0, LibBlockNames.BIOME_STONE_A); - } - - @Override - public int damageDropped(int par1) { - return par1 % 8 + 8; - } + public BlockBiomeStoneA() { + super(0, LibBlockNames.BIOME_STONE_A); + } + @Override + public int damageDropped(int par1) { + return par1 % 8 + 8; + } } diff --git a/src/main/java/vazkii/botania/common/block/decor/biomestone/BlockBiomeStoneB.java b/src/main/java/vazkii/botania/common/block/decor/biomestone/BlockBiomeStoneB.java index 405432fc5f..9033a29fa1 100644 --- a/src/main/java/vazkii/botania/common/block/decor/biomestone/BlockBiomeStoneB.java +++ b/src/main/java/vazkii/botania/common/block/decor/biomestone/BlockBiomeStoneB.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jan 29, 2015, 7:17:41 PM (GMT)] */ package vazkii.botania.common.block.decor.biomestone; @@ -14,8 +14,7 @@ public class BlockBiomeStoneB extends BlockBiomeStone { - public BlockBiomeStoneB() { - super(16, LibBlockNames.BIOME_STONE_B); - } - + public BlockBiomeStoneB() { + super(16, LibBlockNames.BIOME_STONE_B); + } } diff --git a/src/main/java/vazkii/botania/common/block/decor/panes/BlockAlfglassPane.java b/src/main/java/vazkii/botania/common/block/decor/panes/BlockAlfglassPane.java index 081d8e7dad..52815ef8e3 100644 --- a/src/main/java/vazkii/botania/common/block/decor/panes/BlockAlfglassPane.java +++ b/src/main/java/vazkii/botania/common/block/decor/panes/BlockAlfglassPane.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Sep 30, 2015, 10:17:02 PM (GMT)] */ package vazkii.botania.common.block.decor.panes; @@ -14,8 +14,7 @@ public class BlockAlfglassPane extends BlockModPane { - public BlockAlfglassPane() { - super(ModBlocks.elfGlass); - } - + public BlockAlfglassPane() { + super(ModBlocks.elfGlass); + } } diff --git a/src/main/java/vazkii/botania/common/block/decor/panes/BlockBifrostPane.java b/src/main/java/vazkii/botania/common/block/decor/panes/BlockBifrostPane.java index 495e390164..e8300b1279 100644 --- a/src/main/java/vazkii/botania/common/block/decor/panes/BlockBifrostPane.java +++ b/src/main/java/vazkii/botania/common/block/decor/panes/BlockBifrostPane.java @@ -2,45 +2,43 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Sep 30, 2015, 10:18:50 PM (GMT)] */ package vazkii.botania.common.block.decor.panes; +import cpw.mods.fml.common.eventhandler.SubscribeEvent; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.client.renderer.texture.TextureAtlasSprite; import net.minecraftforge.client.event.TextureStitchEvent; import net.minecraftforge.common.MinecraftForge; import vazkii.botania.client.render.block.InterpolatedIcon; import vazkii.botania.common.block.ModBlocks; -import cpw.mods.fml.common.eventhandler.SubscribeEvent; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; public class BlockBifrostPane extends BlockModPane { - public BlockBifrostPane() { - super(ModBlocks.bifrostPerm); - MinecraftForge.EVENT_BUS.register(this); - } - - @SubscribeEvent - @SideOnly(Side.CLIENT) - public void loadTextures(TextureStitchEvent.Pre event) { - if(event.map.getTextureType() == 0) { - TextureAtlasSprite icon = new InterpolatedIcon("botania:bifrostPermPane"); - if(event.map.setTextureEntry("botania:bifrostPermPane", icon)) - iconTop = icon; - } - } + public BlockBifrostPane() { + super(ModBlocks.bifrostPerm); + MinecraftForge.EVENT_BUS.register(this); + } - @Override - @SideOnly(Side.CLIENT) - public void registerBlockIcons(IIconRegister reg) { - // NO-OP - } + @SubscribeEvent + @SideOnly(Side.CLIENT) + public void loadTextures(TextureStitchEvent.Pre event) { + if (event.map.getTextureType() == 0) { + TextureAtlasSprite icon = new InterpolatedIcon("botania:bifrostPermPane"); + if (event.map.setTextureEntry("botania:bifrostPermPane", icon)) iconTop = icon; + } + } + @Override + @SideOnly(Side.CLIENT) + public void registerBlockIcons(IIconRegister reg) { + // NO-OP + } } diff --git a/src/main/java/vazkii/botania/common/block/decor/panes/BlockManaglassPane.java b/src/main/java/vazkii/botania/common/block/decor/panes/BlockManaglassPane.java index d509b38b90..5f97e03cc7 100644 --- a/src/main/java/vazkii/botania/common/block/decor/panes/BlockManaglassPane.java +++ b/src/main/java/vazkii/botania/common/block/decor/panes/BlockManaglassPane.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Sep 30, 2015, 10:16:46 PM (GMT)] */ package vazkii.botania.common.block.decor.panes; @@ -14,8 +14,7 @@ public class BlockManaglassPane extends BlockModPane { - public BlockManaglassPane() { - super(ModBlocks.manaGlass); - } - + public BlockManaglassPane() { + super(ModBlocks.manaGlass); + } } diff --git a/src/main/java/vazkii/botania/common/block/decor/panes/BlockModPane.java b/src/main/java/vazkii/botania/common/block/decor/panes/BlockModPane.java index 206ba158d4..9544071639 100644 --- a/src/main/java/vazkii/botania/common/block/decor/panes/BlockModPane.java +++ b/src/main/java/vazkii/botania/common/block/decor/panes/BlockModPane.java @@ -2,14 +2,17 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Sep 30, 2015, 10:01:17 PM (GMT)] */ package vazkii.botania.common.block.decor.panes; +import cpw.mods.fml.common.registry.GameRegistry; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; import net.minecraft.block.Block; import net.minecraft.block.BlockPane; import net.minecraft.block.material.Material; @@ -21,69 +24,68 @@ import vazkii.botania.common.block.ModBlocks; import vazkii.botania.common.core.BotaniaCreativeTab; import vazkii.botania.common.item.block.ItemBlockMod; -import cpw.mods.fml.common.registry.GameRegistry; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; public class BlockModPane extends BlockPane { - Block source; - public IIcon iconTop; - - public BlockModPane(Block source) { - super("", "", Material.glass, false); - this.source = source; - setBlockName(source.getUnlocalizedName().replaceAll("tile.", "") + "Pane"); - setCreativeTab(BotaniaCreativeTab.INSTANCE); - setHardness(0.3F); - setStepSound(soundTypeGlass); - setLightLevel(1.0F); - useNeighborBrightness = true; - } + Block source; + public IIcon iconTop; - @Override - public Block setBlockName(String par1Str) { - GameRegistry.registerBlock(this, ItemBlockMod.class, par1Str); - return super.setBlockName(par1Str); - } + public BlockModPane(Block source) { + super("", "", Material.glass, false); + this.source = source; + setBlockName(source.getUnlocalizedName().replaceAll("tile.", "") + "Pane"); + setCreativeTab(BotaniaCreativeTab.INSTANCE); + setHardness(0.3F); + setStepSound(soundTypeGlass); + setLightLevel(1.0F); + useNeighborBrightness = true; + } - @Override - @SideOnly(Side.CLIENT) - public void registerBlockIcons(IIconRegister reg) { - iconTop = IconHelper.forBlock(reg, this); - } + @Override + public Block setBlockName(String par1Str) { + GameRegistry.registerBlock(this, ItemBlockMod.class, par1Str); + return super.setBlockName(par1Str); + } - @Override - public boolean shouldSideBeRendered(IBlockAccess iblockaccess, int i, int j, int k, int l) { - return false; - } + @Override + @SideOnly(Side.CLIENT) + public void registerBlockIcons(IIconRegister reg) { + iconTop = IconHelper.forBlock(reg, this); + } - @Override - public int getRenderType() { - return 18; - } + @Override + public boolean shouldSideBeRendered(IBlockAccess iblockaccess, int i, int j, int k, int l) { + return false; + } - @Override - public int getRenderBlockPass() { - return 1; - } + @Override + public int getRenderType() { + return 18; + } - @Override - @SideOnly(Side.CLIENT) - public IIcon func_150097_e() { - return source.getIcon(0, 0); - } + @Override + public int getRenderBlockPass() { + return 1; + } - @Override - @SideOnly(Side.CLIENT) - public IIcon getIcon(int side, int meta) { - return side >= 2 ? iconTop : source.getIcon(side, meta); - } + @Override + @SideOnly(Side.CLIENT) + public IIcon func_150097_e() { + return source.getIcon(0, 0); + } - @Override - public boolean canPaneConnectTo(IBlockAccess world, int x, int y, int z, ForgeDirection dir) { - Block block = world.getBlock(x, y, z); - return block == ModBlocks.elfGlass || block == ModBlocks.manaGlass || block == ModBlocks.bifrostPerm || super.canPaneConnectTo(world, x, y, z, dir); - } + @Override + @SideOnly(Side.CLIENT) + public IIcon getIcon(int side, int meta) { + return side >= 2 ? iconTop : source.getIcon(side, meta); + } + @Override + public boolean canPaneConnectTo(IBlockAccess world, int x, int y, int z, ForgeDirection dir) { + Block block = world.getBlock(x, y, z); + return block == ModBlocks.elfGlass + || block == ModBlocks.manaGlass + || block == ModBlocks.bifrostPerm + || super.canPaneConnectTo(world, x, y, z, dir); + } } diff --git a/src/main/java/vazkii/botania/common/block/decor/quartz/BlockSpecialQuartz.java b/src/main/java/vazkii/botania/common/block/decor/quartz/BlockSpecialQuartz.java index 7773404ad2..560e0b4017 100644 --- a/src/main/java/vazkii/botania/common/block/decor/quartz/BlockSpecialQuartz.java +++ b/src/main/java/vazkii/botania/common/block/decor/quartz/BlockSpecialQuartz.java @@ -2,16 +2,18 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jun 11, 2014, 1:05:32 AM (GMT)] */ package vazkii.botania.common.block.decor.quartz; +import cpw.mods.fml.common.registry.GameRegistry; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; import java.util.List; - import net.minecraft.block.Block; import net.minecraft.block.material.Material; import net.minecraft.client.renderer.texture.IIconRegister; @@ -28,127 +30,130 @@ import vazkii.botania.common.block.ModFluffBlocks; import vazkii.botania.common.item.block.ItemBlockSpecialQuartz; import vazkii.botania.common.lexicon.LexiconData; -import cpw.mods.fml.common.registry.GameRegistry; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; public class BlockSpecialQuartz extends BlockMod implements ILexiconable { - private final String[] iconNames; - public final String type; - private IIcon[] specialQuartzIcons; - private IIcon chiseledSpecialQuartzIcon; - private IIcon pillarSpecialQuartzIcon; - private IIcon specialQuartzTopIcon; - - public BlockSpecialQuartz(String type) { - super(Material.rock); - this.type = type; - iconNames = new String[]{ "block" + type + "Quartz0", "chiseled" + type + "Quartz0", "pillar" + type + "Quartz0", null, null }; - setHardness(0.8F); - setResistance(10F); - setBlockName("quartzType" + type); - } - - @Override - public Block setBlockName(String par1Str) { - GameRegistry.registerBlock(this, ItemBlockSpecialQuartz.class, par1Str); - return super.setBlockName(par1Str); - } - - @Override - protected boolean shouldRegisterInNameSet() { - return false; - } - - public String[] getNames() { - return new String[] { - "tile.botania:block" + type + "Quartz", - "tile.botania:chiseled" + type + "Quartz", - "tile.botania:pillar" + type + "Quartz", - }; - } - - @Override - @SideOnly(Side.CLIENT) - public IIcon getIcon(int par1, int par2) { - if (par2 != 2 && par2 != 3 && par2 != 4) { - if (par1 != 1 && (par1 != 0 || par2 != 1)) { - if (par1 == 0) - return specialQuartzTopIcon; - else { - if (par2 < 0 || par2 >= specialQuartzIcons.length) - par2 = 0; - - return specialQuartzIcons[par2]; - } - } else return par2 == 1 ? chiseledSpecialQuartzIcon : specialQuartzTopIcon; - } else - return par2 == 2 && (par1 == 1 || par1 == 0) ? pillarSpecialQuartzIcon : par2 == 3 && (par1 == 5 || par1 == 4) ? pillarSpecialQuartzIcon : par2 == 4 && (par1 == 2 || par1 == 3) ? pillarSpecialQuartzIcon : specialQuartzIcons[par2]; - } - - @Override - public int onBlockPlaced(World par1World, int par2, int par3, int par4, int par5, float par6, float par7, float par8, int par9) { - if (par9 == 2) { - switch (par5) { - case 0: - case 1: - par9 = 2; - break; - case 2: - case 3: - par9 = 4; - break; - case 4: - case 5: - par9 = 3; - } - } - - return par9; - } - - @Override - public int damageDropped(int par1) { - return par1 != 3 && par1 != 4 ? par1 : 2; - } - - @Override - public ItemStack createStackedBlock(int par1) { - return par1 != 3 && par1 != 4 ? super.createStackedBlock(par1) : new ItemStack(this, 1, 2); - } - - @Override - public int getRenderType() { - return 39; - } - - @Override - @SideOnly(Side.CLIENT) - public void getSubBlocks(Item item, CreativeTabs tab, List par3List) { - par3List.add(new ItemStack(this, 1, 0)); - par3List.add(new ItemStack(this, 1, 1)); - par3List.add(new ItemStack(this, 1, 2)); - } - - @Override - @SideOnly(Side.CLIENT) - public void registerBlockIcons(IIconRegister par1IconRegister) { - specialQuartzIcons = new IIcon[iconNames.length]; - - for (int i = 0; i < specialQuartzIcons.length; ++i) { - if (iconNames[i] == null) - specialQuartzIcons[i] = specialQuartzIcons[i - 1]; - else specialQuartzIcons[i] = IconHelper.forName(par1IconRegister, iconNames[i]); - } - - specialQuartzTopIcon = IconHelper.forName(par1IconRegister, "block" + type + "Quartz1"); - chiseledSpecialQuartzIcon = IconHelper.forName(par1IconRegister, "chiseled" + type + "Quartz1"); - pillarSpecialQuartzIcon = IconHelper.forName(par1IconRegister, "pillar" + type + "Quartz1"); - } - - @Override - public LexiconEntry getEntry(World world, int x, int y, int z, EntityPlayer player, ItemStack lexicon) { - return this == ModFluffBlocks.elfQuartz ? LexiconData.elvenResources : LexiconData.decorativeBlocks; - } + private final String[] iconNames; + public final String type; + private IIcon[] specialQuartzIcons; + private IIcon chiseledSpecialQuartzIcon; + private IIcon pillarSpecialQuartzIcon; + private IIcon specialQuartzTopIcon; + + public BlockSpecialQuartz(String type) { + super(Material.rock); + this.type = type; + iconNames = new String[] { + "block" + type + "Quartz0", "chiseled" + type + "Quartz0", "pillar" + type + "Quartz0", null, null + }; + setHardness(0.8F); + setResistance(10F); + setBlockName("quartzType" + type); + } + + @Override + public Block setBlockName(String par1Str) { + GameRegistry.registerBlock(this, ItemBlockSpecialQuartz.class, par1Str); + return super.setBlockName(par1Str); + } + + @Override + protected boolean shouldRegisterInNameSet() { + return false; + } + + public String[] getNames() { + return new String[] { + "tile.botania:block" + type + "Quartz", + "tile.botania:chiseled" + type + "Quartz", + "tile.botania:pillar" + type + "Quartz", + }; + } + + @Override + @SideOnly(Side.CLIENT) + public IIcon getIcon(int par1, int par2) { + if (par2 != 2 && par2 != 3 && par2 != 4) { + if (par1 != 1 && (par1 != 0 || par2 != 1)) { + if (par1 == 0) return specialQuartzTopIcon; + else { + if (par2 < 0 || par2 >= specialQuartzIcons.length) par2 = 0; + + return specialQuartzIcons[par2]; + } + } else return par2 == 1 ? chiseledSpecialQuartzIcon : specialQuartzTopIcon; + } else + return par2 == 2 && (par1 == 1 || par1 == 0) + ? pillarSpecialQuartzIcon + : par2 == 3 && (par1 == 5 || par1 == 4) + ? pillarSpecialQuartzIcon + : par2 == 4 && (par1 == 2 || par1 == 3) + ? pillarSpecialQuartzIcon + : specialQuartzIcons[par2]; + } + + @Override + public int onBlockPlaced( + World par1World, int par2, int par3, int par4, int par5, float par6, float par7, float par8, int par9) { + if (par9 == 2) { + switch (par5) { + case 0: + case 1: + par9 = 2; + break; + case 2: + case 3: + par9 = 4; + break; + case 4: + case 5: + par9 = 3; + } + } + + return par9; + } + + @Override + public int damageDropped(int par1) { + return par1 != 3 && par1 != 4 ? par1 : 2; + } + + @Override + public ItemStack createStackedBlock(int par1) { + return par1 != 3 && par1 != 4 ? super.createStackedBlock(par1) : new ItemStack(this, 1, 2); + } + + @Override + public int getRenderType() { + return 39; + } + + @Override + @SideOnly(Side.CLIENT) + public void getSubBlocks(Item item, CreativeTabs tab, List par3List) { + par3List.add(new ItemStack(this, 1, 0)); + par3List.add(new ItemStack(this, 1, 1)); + par3List.add(new ItemStack(this, 1, 2)); + } + + @Override + @SideOnly(Side.CLIENT) + public void registerBlockIcons(IIconRegister par1IconRegister) { + specialQuartzIcons = new IIcon[iconNames.length]; + + for (int i = 0; i < specialQuartzIcons.length; ++i) { + if (iconNames[i] == null) specialQuartzIcons[i] = specialQuartzIcons[i - 1]; + else specialQuartzIcons[i] = IconHelper.forName(par1IconRegister, iconNames[i]); + } + + specialQuartzTopIcon = IconHelper.forName(par1IconRegister, "block" + type + "Quartz1"); + chiseledSpecialQuartzIcon = IconHelper.forName(par1IconRegister, "chiseled" + type + "Quartz1"); + pillarSpecialQuartzIcon = IconHelper.forName(par1IconRegister, "pillar" + type + "Quartz1"); + } + + @Override + public LexiconEntry getEntry(World world, int x, int y, int z, EntityPlayer player, ItemStack lexicon) { + return this == ModFluffBlocks.elfQuartz ? LexiconData.elvenResources : LexiconData.decorativeBlocks; + } } diff --git a/src/main/java/vazkii/botania/common/block/decor/quartz/BlockSpecialQuartzSlab.java b/src/main/java/vazkii/botania/common/block/decor/quartz/BlockSpecialQuartzSlab.java index c26bbc8c1d..0890c91838 100644 --- a/src/main/java/vazkii/botania/common/block/decor/quartz/BlockSpecialQuartzSlab.java +++ b/src/main/java/vazkii/botania/common/block/decor/quartz/BlockSpecialQuartzSlab.java @@ -2,16 +2,17 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jun 11, 2014, 1:08:28 AM (GMT)] */ package vazkii.botania.common.block.decor.quartz; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; import java.util.Random; - import net.minecraft.block.Block; import net.minecraft.block.BlockSlab; import net.minecraft.block.material.Material; @@ -26,90 +27,73 @@ import vazkii.botania.common.block.ModFluffBlocks; import vazkii.botania.common.block.decor.slabs.BlockModSlab; import vazkii.botania.common.lexicon.LexiconData; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; public class BlockSpecialQuartzSlab extends BlockModSlab { - Block source; - - public BlockSpecialQuartzSlab(Block source, boolean par2) { - super(par2, Material.rock, "quartzSlab" + ((BlockSpecialQuartz) source).type + (par2 ? "Full" : "Half")); - setHardness(0.8F); - setResistance(10F); - this.source = source; - } - - @Override - public BlockSlab getFullBlock() { - if(source == ModFluffBlocks.darkQuartz) - return (BlockSlab) ModFluffBlocks.darkQuartzSlabFull; - if(source == ModFluffBlocks.manaQuartz) - return (BlockSlab) ModFluffBlocks.manaQuartzSlabFull; - if(source == ModFluffBlocks.blazeQuartz) - return (BlockSlab) ModFluffBlocks.blazeQuartzSlabFull; - if(source == ModFluffBlocks.lavenderQuartz) - return (BlockSlab) ModFluffBlocks.lavenderQuartzSlabFull; - if(source == ModFluffBlocks.redQuartz) - return (BlockSlab) ModFluffBlocks.redQuartzSlabFull; - if(source == ModFluffBlocks.elfQuartz) - return (BlockSlab) ModFluffBlocks.elfQuartzSlabFull; - if(source == ModFluffBlocks.sunnyQuartz) - return (BlockSlab) ModFluffBlocks.sunnyQuartzSlabFull; - - return this; - } - - @Override - public BlockSlab getSingleBlock() { - if(source == ModFluffBlocks.darkQuartz) - return (BlockSlab) ModFluffBlocks.darkQuartzSlab; - if(source == ModFluffBlocks.manaQuartz) - return (BlockSlab) ModFluffBlocks.manaQuartzSlab; - if(source == ModFluffBlocks.blazeQuartz) - return (BlockSlab) ModFluffBlocks.blazeQuartzSlab; - if(source == ModFluffBlocks.lavenderQuartz) - return (BlockSlab) ModFluffBlocks.lavenderQuartzSlab; - if(source == ModFluffBlocks.redQuartz) - return (BlockSlab) ModFluffBlocks.redQuartzSlab; - if(source == ModFluffBlocks.elfQuartz) - return (BlockSlab) ModFluffBlocks.elfQuartzSlab; - if(source == ModFluffBlocks.sunnyQuartz) - return (BlockSlab) ModFluffBlocks.sunnyQuartzSlab; - - return this; - } - - @Override - public ItemStack getPickBlock(MovingObjectPosition target, World world, int x, int y, int z) { - return new ItemStack(getSingleBlock()); - } - - @Override - @SideOnly(Side.CLIENT) - public IIcon getIcon(int par1, int par2) { - return source.getBlockTextureFromSide(par1); - } - - @Override - public Item getItemDropped(int p_149650_1_, Random p_149650_2_, int p_149650_3_) { - return Item.getItemFromBlock(getSingleBlock()); - } - - @Override - public ItemStack createStackedBlock(int par1) { - return new ItemStack(getSingleBlock()); - } - - @Override - @SideOnly(Side.CLIENT) - public void registerBlockIcons(IIconRegister par1IconRegister) { - // NO-OP - } - - @Override - public LexiconEntry getEntry(World world, int x, int y, int z, EntityPlayer player, ItemStack lexicon) { - return this == ModFluffBlocks.elfQuartzSlab ? LexiconData.elvenResources : LexiconData.decorativeBlocks; - } - + Block source; + + public BlockSpecialQuartzSlab(Block source, boolean par2) { + super(par2, Material.rock, "quartzSlab" + ((BlockSpecialQuartz) source).type + (par2 ? "Full" : "Half")); + setHardness(0.8F); + setResistance(10F); + this.source = source; + } + + @Override + public BlockSlab getFullBlock() { + if (source == ModFluffBlocks.darkQuartz) return (BlockSlab) ModFluffBlocks.darkQuartzSlabFull; + if (source == ModFluffBlocks.manaQuartz) return (BlockSlab) ModFluffBlocks.manaQuartzSlabFull; + if (source == ModFluffBlocks.blazeQuartz) return (BlockSlab) ModFluffBlocks.blazeQuartzSlabFull; + if (source == ModFluffBlocks.lavenderQuartz) return (BlockSlab) ModFluffBlocks.lavenderQuartzSlabFull; + if (source == ModFluffBlocks.redQuartz) return (BlockSlab) ModFluffBlocks.redQuartzSlabFull; + if (source == ModFluffBlocks.elfQuartz) return (BlockSlab) ModFluffBlocks.elfQuartzSlabFull; + if (source == ModFluffBlocks.sunnyQuartz) return (BlockSlab) ModFluffBlocks.sunnyQuartzSlabFull; + + return this; + } + + @Override + public BlockSlab getSingleBlock() { + if (source == ModFluffBlocks.darkQuartz) return (BlockSlab) ModFluffBlocks.darkQuartzSlab; + if (source == ModFluffBlocks.manaQuartz) return (BlockSlab) ModFluffBlocks.manaQuartzSlab; + if (source == ModFluffBlocks.blazeQuartz) return (BlockSlab) ModFluffBlocks.blazeQuartzSlab; + if (source == ModFluffBlocks.lavenderQuartz) return (BlockSlab) ModFluffBlocks.lavenderQuartzSlab; + if (source == ModFluffBlocks.redQuartz) return (BlockSlab) ModFluffBlocks.redQuartzSlab; + if (source == ModFluffBlocks.elfQuartz) return (BlockSlab) ModFluffBlocks.elfQuartzSlab; + if (source == ModFluffBlocks.sunnyQuartz) return (BlockSlab) ModFluffBlocks.sunnyQuartzSlab; + + return this; + } + + @Override + public ItemStack getPickBlock(MovingObjectPosition target, World world, int x, int y, int z) { + return new ItemStack(getSingleBlock()); + } + + @Override + @SideOnly(Side.CLIENT) + public IIcon getIcon(int par1, int par2) { + return source.getBlockTextureFromSide(par1); + } + + @Override + public Item getItemDropped(int p_149650_1_, Random p_149650_2_, int p_149650_3_) { + return Item.getItemFromBlock(getSingleBlock()); + } + + @Override + public ItemStack createStackedBlock(int par1) { + return new ItemStack(getSingleBlock()); + } + + @Override + @SideOnly(Side.CLIENT) + public void registerBlockIcons(IIconRegister par1IconRegister) { + // NO-OP + } + + @Override + public LexiconEntry getEntry(World world, int x, int y, int z, EntityPlayer player, ItemStack lexicon) { + return this == ModFluffBlocks.elfQuartzSlab ? LexiconData.elvenResources : LexiconData.decorativeBlocks; + } } diff --git a/src/main/java/vazkii/botania/common/block/decor/quartz/BlockSpecialQuartzStairs.java b/src/main/java/vazkii/botania/common/block/decor/quartz/BlockSpecialQuartzStairs.java index b2494da450..b587ae3c17 100644 --- a/src/main/java/vazkii/botania/common/block/decor/quartz/BlockSpecialQuartzStairs.java +++ b/src/main/java/vazkii/botania/common/block/decor/quartz/BlockSpecialQuartzStairs.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jun 11, 2014, 1:12:50 AM (GMT)] */ package vazkii.botania.common.block.decor.quartz; @@ -21,13 +21,14 @@ public class BlockSpecialQuartzStairs extends BlockModStairs { - public BlockSpecialQuartzStairs(Block source) { - super(source, 0, "quartzStairs" + ((BlockSpecialQuartz) source).type); - } + public BlockSpecialQuartzStairs(Block source) { + super(source, 0, "quartzStairs" + ((BlockSpecialQuartz) source).type); + } - @Override - public LexiconEntry getEntry(World world, int x, int y, int z, EntityPlayer player, ItemStack lexicon) { - return this == ModFluffBlocks.elfQuartzStairs ? LexiconData.elvenResources : super.getEntry(world, x, y, z, player, lexicon); - } - -} \ No newline at end of file + @Override + public LexiconEntry getEntry(World world, int x, int y, int z, EntityPlayer player, ItemStack lexicon) { + return this == ModFluffBlocks.elfQuartzStairs + ? LexiconData.elvenResources + : super.getEntry(world, x, y, z, player, lexicon); + } +} diff --git a/src/main/java/vazkii/botania/common/block/decor/slabs/Block18StoneSlab.java b/src/main/java/vazkii/botania/common/block/decor/slabs/Block18StoneSlab.java index b5ff215d63..b2f0236780 100644 --- a/src/main/java/vazkii/botania/common/block/decor/slabs/Block18StoneSlab.java +++ b/src/main/java/vazkii/botania/common/block/decor/slabs/Block18StoneSlab.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Apr 10, 2015, 7:52:06 PM (GMT)] */ package vazkii.botania.common.block.decor.slabs; @@ -20,28 +20,27 @@ public class Block18StoneSlab extends BlockLivingSlab { - int index; - - public Block18StoneSlab(boolean full, int meta, int index) { - super(full, ModFluffBlocks.stone, meta); - this.index = index; - setHardness(1.5F); - setResistance(10F); - } - - @Override - public BlockSlab getFullBlock() { - return (BlockSlab) ModFluffBlocks.stoneFullSlabs[index]; - } - - @Override - public BlockSlab getSingleBlock() { - return (BlockSlab) ModFluffBlocks.stoneSlabs[index]; - } - - @Override - public LexiconEntry getEntry(World world, int x, int y, int z, EntityPlayer player, ItemStack lexicon) { - return LexiconData.stoneAlchemy; - } - + int index; + + public Block18StoneSlab(boolean full, int meta, int index) { + super(full, ModFluffBlocks.stone, meta); + this.index = index; + setHardness(1.5F); + setResistance(10F); + } + + @Override + public BlockSlab getFullBlock() { + return (BlockSlab) ModFluffBlocks.stoneFullSlabs[index]; + } + + @Override + public BlockSlab getSingleBlock() { + return (BlockSlab) ModFluffBlocks.stoneSlabs[index]; + } + + @Override + public LexiconEntry getEntry(World world, int x, int y, int z, EntityPlayer player, ItemStack lexicon) { + return LexiconData.stoneAlchemy; + } } diff --git a/src/main/java/vazkii/botania/common/block/decor/slabs/BlockBiomeStoneSlab.java b/src/main/java/vazkii/botania/common/block/decor/slabs/BlockBiomeStoneSlab.java index aa20c9def0..aecbb635ba 100644 --- a/src/main/java/vazkii/botania/common/block/decor/slabs/BlockBiomeStoneSlab.java +++ b/src/main/java/vazkii/botania/common/block/decor/slabs/BlockBiomeStoneSlab.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jan 29, 2015, 7:34:16 PM (GMT)] */ package vazkii.botania.common.block.decor.slabs; @@ -21,28 +21,27 @@ public class BlockBiomeStoneSlab extends BlockLivingSlab { - int index; - - public BlockBiomeStoneSlab(boolean full, Block source, int meta, int index) { - super(full, source, meta); - this.index = index; - setHardness(1.5F); - setResistance(10F); - } - - @Override - public BlockSlab getFullBlock() { - return (BlockSlab) ModFluffBlocks.biomeStoneFullSlabs[index]; - } - - @Override - public BlockSlab getSingleBlock() { - return (BlockSlab) ModFluffBlocks.biomeStoneSlabs[index]; - } - - @Override - public LexiconEntry getEntry(World world, int x, int y, int z, EntityPlayer player, ItemStack lexicon) { - return LexiconData.marimorphosis; - } - + int index; + + public BlockBiomeStoneSlab(boolean full, Block source, int meta, int index) { + super(full, source, meta); + this.index = index; + setHardness(1.5F); + setResistance(10F); + } + + @Override + public BlockSlab getFullBlock() { + return (BlockSlab) ModFluffBlocks.biomeStoneFullSlabs[index]; + } + + @Override + public BlockSlab getSingleBlock() { + return (BlockSlab) ModFluffBlocks.biomeStoneSlabs[index]; + } + + @Override + public LexiconEntry getEntry(World world, int x, int y, int z, EntityPlayer player, ItemStack lexicon) { + return LexiconData.marimorphosis; + } } diff --git a/src/main/java/vazkii/botania/common/block/decor/slabs/BlockDirtPathSlab.java b/src/main/java/vazkii/botania/common/block/decor/slabs/BlockDirtPathSlab.java index a91b5bbab0..4a69c3450f 100644 --- a/src/main/java/vazkii/botania/common/block/decor/slabs/BlockDirtPathSlab.java +++ b/src/main/java/vazkii/botania/common/block/decor/slabs/BlockDirtPathSlab.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jan 26, 2015, 10:15:05 PM (GMT)] */ package vazkii.botania.common.block.decor.slabs; @@ -21,24 +21,23 @@ public class BlockDirtPathSlab extends BlockLivingSlab { - public BlockDirtPathSlab(boolean full) { - super(full, ModBlocks.dirtPath, 0); - setHardness(0.6F); - } + public BlockDirtPathSlab(boolean full) { + super(full, ModBlocks.dirtPath, 0); + setHardness(0.6F); + } - @Override - public BlockSlab getFullBlock() { - return (BlockSlab) ModFluffBlocks.dirtPathSlabFull; - } + @Override + public BlockSlab getFullBlock() { + return (BlockSlab) ModFluffBlocks.dirtPathSlabFull; + } - @Override - public BlockSlab getSingleBlock() { - return (BlockSlab) ModFluffBlocks.dirtPathSlab; - } - - @Override - public LexiconEntry getEntry(World world, int x, int y, int z, EntityPlayer player, ItemStack lexicon) { - return LexiconData.dirtPath; - } + @Override + public BlockSlab getSingleBlock() { + return (BlockSlab) ModFluffBlocks.dirtPathSlab; + } + @Override + public LexiconEntry getEntry(World world, int x, int y, int z, EntityPlayer player, ItemStack lexicon) { + return LexiconData.dirtPath; + } } diff --git a/src/main/java/vazkii/botania/common/block/decor/slabs/BlockEndStoneSlab.java b/src/main/java/vazkii/botania/common/block/decor/slabs/BlockEndStoneSlab.java index 4a2a65d9fb..8222e8d2aa 100644 --- a/src/main/java/vazkii/botania/common/block/decor/slabs/BlockEndStoneSlab.java +++ b/src/main/java/vazkii/botania/common/block/decor/slabs/BlockEndStoneSlab.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Feb 16, 2015, 8:45:00 PM (GMT)] */ package vazkii.botania.common.block.decor.slabs; @@ -21,26 +21,25 @@ public class BlockEndStoneSlab extends BlockLivingSlab { - public BlockEndStoneSlab(boolean full) { - super(full, ModBlocks.endStoneBrick, 0); - setHardness(1.5F); - setResistance(10F); - setStepSound(soundTypeStone); - } + public BlockEndStoneSlab(boolean full) { + super(full, ModBlocks.endStoneBrick, 0); + setHardness(1.5F); + setResistance(10F); + setStepSound(soundTypeStone); + } - @Override - public BlockSlab getFullBlock() { - return (BlockSlab) ModFluffBlocks.endStoneSlabFull; - } + @Override + public BlockSlab getFullBlock() { + return (BlockSlab) ModFluffBlocks.endStoneSlabFull; + } - @Override - public BlockSlab getSingleBlock() { - return (BlockSlab) ModFluffBlocks.endStoneSlab; - } - - @Override - public LexiconEntry getEntry(World world, int x, int y, int z, EntityPlayer player, ItemStack lexicon) { - return LexiconData.endStoneDecor; - } + @Override + public BlockSlab getSingleBlock() { + return (BlockSlab) ModFluffBlocks.endStoneSlab; + } + @Override + public LexiconEntry getEntry(World world, int x, int y, int z, EntityPlayer player, ItemStack lexicon) { + return LexiconData.endStoneDecor; + } } diff --git a/src/main/java/vazkii/botania/common/block/decor/slabs/BlockEnderBrickSlab.java b/src/main/java/vazkii/botania/common/block/decor/slabs/BlockEnderBrickSlab.java index ce28c608bf..e68bf44c9a 100644 --- a/src/main/java/vazkii/botania/common/block/decor/slabs/BlockEnderBrickSlab.java +++ b/src/main/java/vazkii/botania/common/block/decor/slabs/BlockEnderBrickSlab.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jul 7, 2015, 10:37:15 PM (GMT)] */ package vazkii.botania.common.block.decor.slabs; @@ -21,26 +21,25 @@ public class BlockEnderBrickSlab extends BlockLivingSlab { - public BlockEnderBrickSlab(boolean full) { - super(full, ModBlocks.endStoneBrick, 2); - setHardness(1.5F); - setResistance(10F); - setStepSound(soundTypeStone); - } + public BlockEnderBrickSlab(boolean full) { + super(full, ModBlocks.endStoneBrick, 2); + setHardness(1.5F); + setResistance(10F); + setStepSound(soundTypeStone); + } - @Override - public BlockSlab getFullBlock() { - return (BlockSlab) ModFluffBlocks.enderBrickSlabFull; - } + @Override + public BlockSlab getFullBlock() { + return (BlockSlab) ModFluffBlocks.enderBrickSlabFull; + } - @Override - public BlockSlab getSingleBlock() { - return (BlockSlab) ModFluffBlocks.enderBrickSlab; - } - - @Override - public LexiconEntry getEntry(World world, int x, int y, int z, EntityPlayer player, ItemStack lexicon) { - return LexiconData.endStoneDecor; - } + @Override + public BlockSlab getSingleBlock() { + return (BlockSlab) ModFluffBlocks.enderBrickSlab; + } + @Override + public LexiconEntry getEntry(World world, int x, int y, int z, EntityPlayer player, ItemStack lexicon) { + return LexiconData.endStoneDecor; + } } diff --git a/src/main/java/vazkii/botania/common/block/decor/slabs/BlockLivingSlab.java b/src/main/java/vazkii/botania/common/block/decor/slabs/BlockLivingSlab.java index 5737748432..ede6e0d48e 100644 --- a/src/main/java/vazkii/botania/common/block/decor/slabs/BlockLivingSlab.java +++ b/src/main/java/vazkii/botania/common/block/decor/slabs/BlockLivingSlab.java @@ -1,26 +1,28 @@ package vazkii.botania.common.block.decor.slabs; -import net.minecraft.block.Block; -import net.minecraft.util.IIcon; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; +import net.minecraft.block.Block; +import net.minecraft.util.IIcon; public abstract class BlockLivingSlab extends BlockModSlab { - Block source; - int meta; - - public BlockLivingSlab(boolean full, Block source, int meta) { - super(full, source.getMaterial(), source.getUnlocalizedName().replaceAll("tile.", "") + meta + "Slab" + (full ? "Full" : "")); - setStepSound(source.stepSound); - this.source = source; - this.meta = meta; - } + Block source; + int meta; - @Override - @SideOnly(Side.CLIENT) - public IIcon getIcon(int par1, int par2) { - return source.getIcon(par1, meta); - } + public BlockLivingSlab(boolean full, Block source, int meta) { + super( + full, + source.getMaterial(), + source.getUnlocalizedName().replaceAll("tile.", "") + meta + "Slab" + (full ? "Full" : "")); + setStepSound(source.stepSound); + this.source = source; + this.meta = meta; + } + @Override + @SideOnly(Side.CLIENT) + public IIcon getIcon(int par1, int par2) { + return source.getIcon(par1, meta); + } } diff --git a/src/main/java/vazkii/botania/common/block/decor/slabs/BlockModSlab.java b/src/main/java/vazkii/botania/common/block/decor/slabs/BlockModSlab.java index d6f502f614..3712e12d8f 100644 --- a/src/main/java/vazkii/botania/common/block/decor/slabs/BlockModSlab.java +++ b/src/main/java/vazkii/botania/common/block/decor/slabs/BlockModSlab.java @@ -1,7 +1,9 @@ package vazkii.botania.common.block.decor.slabs; +import cpw.mods.fml.common.registry.GameRegistry; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; import java.util.Random; - import net.minecraft.block.BlockSlab; import net.minecraft.block.material.Material; import net.minecraft.client.renderer.texture.IIconRegister; @@ -15,66 +17,62 @@ import vazkii.botania.common.core.BotaniaCreativeTab; import vazkii.botania.common.item.block.ItemBlockModSlab; import vazkii.botania.common.lexicon.LexiconData; -import cpw.mods.fml.common.registry.GameRegistry; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; public abstract class BlockModSlab extends BlockSlab implements ILexiconable { - String name; - - public BlockModSlab(boolean full, Material mat, String name) { - super(full, mat); - this.name = name; - setBlockName(name); - if(!full) { - setCreativeTab(BotaniaCreativeTab.INSTANCE); - useNeighborBrightness = true; - } - } - - public abstract BlockSlab getFullBlock(); - - public abstract BlockSlab getSingleBlock(); - - @Override - public ItemStack getPickBlock(MovingObjectPosition target, World world, int x, int y, int z) { - return new ItemStack(getSingleBlock()); - } - - @Override - public Item getItemDropped(int p_149650_1_, Random p_149650_2_, int p_149650_3_) { - return Item.getItemFromBlock(getSingleBlock()); - } - - @Override - public int quantityDropped(int meta, int fortune, Random random) { - return super.quantityDropped(meta, fortune, random); - } - - @Override - public ItemStack createStackedBlock(int par1) { - return new ItemStack(getSingleBlock()); - } - - @Override - @SideOnly(Side.CLIENT) - public void registerBlockIcons(IIconRegister par1IconRegister) { - // NO-OP - } - - public void register() { - GameRegistry.registerBlock(this, ItemBlockModSlab.class, name); - } - - @Override - public String func_150002_b(int i) { - return name; - } - - @Override - public LexiconEntry getEntry(World world, int x, int y, int z, EntityPlayer player, ItemStack lexicon) { - return LexiconData.decorativeBlocks; - } - + String name; + + public BlockModSlab(boolean full, Material mat, String name) { + super(full, mat); + this.name = name; + setBlockName(name); + if (!full) { + setCreativeTab(BotaniaCreativeTab.INSTANCE); + useNeighborBrightness = true; + } + } + + public abstract BlockSlab getFullBlock(); + + public abstract BlockSlab getSingleBlock(); + + @Override + public ItemStack getPickBlock(MovingObjectPosition target, World world, int x, int y, int z) { + return new ItemStack(getSingleBlock()); + } + + @Override + public Item getItemDropped(int p_149650_1_, Random p_149650_2_, int p_149650_3_) { + return Item.getItemFromBlock(getSingleBlock()); + } + + @Override + public int quantityDropped(int meta, int fortune, Random random) { + return super.quantityDropped(meta, fortune, random); + } + + @Override + public ItemStack createStackedBlock(int par1) { + return new ItemStack(getSingleBlock()); + } + + @Override + @SideOnly(Side.CLIENT) + public void registerBlockIcons(IIconRegister par1IconRegister) { + // NO-OP + } + + public void register() { + GameRegistry.registerBlock(this, ItemBlockModSlab.class, name); + } + + @Override + public String func_150002_b(int i) { + return name; + } + + @Override + public LexiconEntry getEntry(World world, int x, int y, int z, EntityPlayer player, ItemStack lexicon) { + return LexiconData.decorativeBlocks; + } } diff --git a/src/main/java/vazkii/botania/common/block/decor/slabs/BlockPavementSlab.java b/src/main/java/vazkii/botania/common/block/decor/slabs/BlockPavementSlab.java index 9e071232f4..df37cac565 100644 --- a/src/main/java/vazkii/botania/common/block/decor/slabs/BlockPavementSlab.java +++ b/src/main/java/vazkii/botania/common/block/decor/slabs/BlockPavementSlab.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Sep 1, 2015, 7:17:45 PM (GMT)] */ package vazkii.botania.common.block.decor.slabs; @@ -20,29 +20,27 @@ public class BlockPavementSlab extends BlockLivingSlab { - int index; - - public BlockPavementSlab(boolean full, int meta, int index) { - super(full, ModFluffBlocks.pavement, meta); - this.index = index; - setHardness(2F); - setResistance(10F); - } - - @Override - public BlockSlab getFullBlock() { - return (BlockSlab) ModFluffBlocks.pavementFullSlabs[index]; - } - - @Override - public BlockSlab getSingleBlock() { - return (BlockSlab) ModFluffBlocks.pavementSlabs[index]; - } - - @Override - public LexiconEntry getEntry(World world, int x, int y, int z, EntityPlayer player, ItemStack lexicon) { - return LexiconData.pavement; - } - - + int index; + + public BlockPavementSlab(boolean full, int meta, int index) { + super(full, ModFluffBlocks.pavement, meta); + this.index = index; + setHardness(2F); + setResistance(10F); + } + + @Override + public BlockSlab getFullBlock() { + return (BlockSlab) ModFluffBlocks.pavementFullSlabs[index]; + } + + @Override + public BlockSlab getSingleBlock() { + return (BlockSlab) ModFluffBlocks.pavementSlabs[index]; + } + + @Override + public LexiconEntry getEntry(World world, int x, int y, int z, EntityPlayer player, ItemStack lexicon) { + return LexiconData.pavement; + } } diff --git a/src/main/java/vazkii/botania/common/block/decor/slabs/BlockReedSlab.java b/src/main/java/vazkii/botania/common/block/decor/slabs/BlockReedSlab.java index 23c955d44e..69c0c99a62 100644 --- a/src/main/java/vazkii/botania/common/block/decor/slabs/BlockReedSlab.java +++ b/src/main/java/vazkii/botania/common/block/decor/slabs/BlockReedSlab.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jul 28, 2014, 8:49:59 PM (GMT)] */ package vazkii.botania.common.block.decor.slabs; @@ -21,26 +21,24 @@ public class BlockReedSlab extends BlockLivingSlab { - public BlockReedSlab(boolean full) { - super(full, ModBlocks.reedBlock, 0); - setHardness(1.0F); - setStepSound(soundTypeWood); - } - - @Override - public BlockSlab getFullBlock() { - return (BlockSlab) ModFluffBlocks.reedSlabFull; - } - - @Override - public BlockSlab getSingleBlock() { - return (BlockSlab) ModFluffBlocks.reedSlab; - } - - @Override - public LexiconEntry getEntry(World world, int x, int y, int z, EntityPlayer player, ItemStack lexicon) { - return LexiconData.decorativeBlocks; - } - - + public BlockReedSlab(boolean full) { + super(full, ModBlocks.reedBlock, 0); + setHardness(1.0F); + setStepSound(soundTypeWood); + } + + @Override + public BlockSlab getFullBlock() { + return (BlockSlab) ModFluffBlocks.reedSlabFull; + } + + @Override + public BlockSlab getSingleBlock() { + return (BlockSlab) ModFluffBlocks.reedSlab; + } + + @Override + public LexiconEntry getEntry(World world, int x, int y, int z, EntityPlayer player, ItemStack lexicon) { + return LexiconData.decorativeBlocks; + } } diff --git a/src/main/java/vazkii/botania/common/block/decor/slabs/BlockThatchSlab.java b/src/main/java/vazkii/botania/common/block/decor/slabs/BlockThatchSlab.java index 228ec633ae..8c88f169c2 100644 --- a/src/main/java/vazkii/botania/common/block/decor/slabs/BlockThatchSlab.java +++ b/src/main/java/vazkii/botania/common/block/decor/slabs/BlockThatchSlab.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jul 28, 2014, 8:49:59 PM (GMT)] */ package vazkii.botania.common.block.decor.slabs; @@ -21,26 +21,24 @@ public class BlockThatchSlab extends BlockLivingSlab { - public BlockThatchSlab(boolean full) { - super(full, ModBlocks.thatch, 0); - setHardness(1.0F); - setStepSound(soundTypeGrass); - } - - @Override - public BlockSlab getFullBlock() { - return (BlockSlab) ModFluffBlocks.thatchSlabFull; - } - - @Override - public BlockSlab getSingleBlock() { - return (BlockSlab) ModFluffBlocks.thatchSlab; - } - - @Override - public LexiconEntry getEntry(World world, int x, int y, int z, EntityPlayer player, ItemStack lexicon) { - return LexiconData.decorativeBlocks; - } - - + public BlockThatchSlab(boolean full) { + super(full, ModBlocks.thatch, 0); + setHardness(1.0F); + setStepSound(soundTypeGrass); + } + + @Override + public BlockSlab getFullBlock() { + return (BlockSlab) ModFluffBlocks.thatchSlabFull; + } + + @Override + public BlockSlab getSingleBlock() { + return (BlockSlab) ModFluffBlocks.thatchSlab; + } + + @Override + public LexiconEntry getEntry(World world, int x, int y, int z, EntityPlayer player, ItemStack lexicon) { + return LexiconData.decorativeBlocks; + } } diff --git a/src/main/java/vazkii/botania/common/block/decor/slabs/bricks/BlockCustomBrickSlab.java b/src/main/java/vazkii/botania/common/block/decor/slabs/bricks/BlockCustomBrickSlab.java index 7c6cde0e1d..2f441f06aa 100644 --- a/src/main/java/vazkii/botania/common/block/decor/slabs/bricks/BlockCustomBrickSlab.java +++ b/src/main/java/vazkii/botania/common/block/decor/slabs/bricks/BlockCustomBrickSlab.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jul 28, 2014, 10:15:41 PM (GMT)] */ package vazkii.botania.common.block.decor.slabs.bricks; @@ -22,30 +22,29 @@ public class BlockCustomBrickSlab extends BlockLivingSlab { - public BlockCustomBrickSlab(boolean full) { - this(full, 0); - } - - public BlockCustomBrickSlab(boolean full, int meta) { - super(full, ModBlocks.customBrick, meta); - setHardness(2.0F); - setResistance(5.0F); - setStepSound(soundTypeStone); - } - - @Override - public BlockSlab getFullBlock() { - return (BlockSlab) ModFluffBlocks.netherBrickSlabFull; - } - - @Override - public BlockSlab getSingleBlock() { - return (BlockSlab) ModFluffBlocks.netherBrickSlab; - } - - @Override - public LexiconEntry getEntry(World world, int x, int y, int z, EntityPlayer player, ItemStack lexicon) { - return LexiconData.decorativeBlocks; - } - -} \ No newline at end of file + public BlockCustomBrickSlab(boolean full) { + this(full, 0); + } + + public BlockCustomBrickSlab(boolean full, int meta) { + super(full, ModBlocks.customBrick, meta); + setHardness(2.0F); + setResistance(5.0F); + setStepSound(soundTypeStone); + } + + @Override + public BlockSlab getFullBlock() { + return (BlockSlab) ModFluffBlocks.netherBrickSlabFull; + } + + @Override + public BlockSlab getSingleBlock() { + return (BlockSlab) ModFluffBlocks.netherBrickSlab; + } + + @Override + public LexiconEntry getEntry(World world, int x, int y, int z, EntityPlayer player, ItemStack lexicon) { + return LexiconData.decorativeBlocks; + } +} diff --git a/src/main/java/vazkii/botania/common/block/decor/slabs/bricks/BlockSnowBrickSlab.java b/src/main/java/vazkii/botania/common/block/decor/slabs/bricks/BlockSnowBrickSlab.java index f827d82070..3d376683a1 100644 --- a/src/main/java/vazkii/botania/common/block/decor/slabs/bricks/BlockSnowBrickSlab.java +++ b/src/main/java/vazkii/botania/common/block/decor/slabs/bricks/BlockSnowBrickSlab.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jul 28, 2014, 11:32:45 PM (GMT)] */ package vazkii.botania.common.block.decor.slabs.bricks; @@ -15,18 +15,17 @@ public class BlockSnowBrickSlab extends BlockCustomBrickSlab { - public BlockSnowBrickSlab(boolean full) { - super(full, 2); - } + public BlockSnowBrickSlab(boolean full) { + super(full, 2); + } - @Override - public BlockSlab getFullBlock() { - return (BlockSlab) ModFluffBlocks.snowBrickSlabFull; - } + @Override + public BlockSlab getFullBlock() { + return (BlockSlab) ModFluffBlocks.snowBrickSlabFull; + } - @Override - public BlockSlab getSingleBlock() { - return (BlockSlab) ModFluffBlocks.snowBrickSlab; - } - -} \ No newline at end of file + @Override + public BlockSlab getSingleBlock() { + return (BlockSlab) ModFluffBlocks.snowBrickSlab; + } +} diff --git a/src/main/java/vazkii/botania/common/block/decor/slabs/bricks/BlockSoulBrickSlab.java b/src/main/java/vazkii/botania/common/block/decor/slabs/bricks/BlockSoulBrickSlab.java index d3afdf03eb..2efbf90731 100644 --- a/src/main/java/vazkii/botania/common/block/decor/slabs/bricks/BlockSoulBrickSlab.java +++ b/src/main/java/vazkii/botania/common/block/decor/slabs/bricks/BlockSoulBrickSlab.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jul 28, 2014, 10:19:46 PM (GMT)] */ package vazkii.botania.common.block.decor.slabs.bricks; @@ -15,18 +15,17 @@ public class BlockSoulBrickSlab extends BlockCustomBrickSlab { - public BlockSoulBrickSlab(boolean full) { - super(full, 1); - } + public BlockSoulBrickSlab(boolean full) { + super(full, 1); + } - @Override - public BlockSlab getFullBlock() { - return (BlockSlab) ModFluffBlocks.soulBrickSlabFull; - } - - @Override - public BlockSlab getSingleBlock() { - return (BlockSlab) ModFluffBlocks.soulBrickSlab; - } + @Override + public BlockSlab getFullBlock() { + return (BlockSlab) ModFluffBlocks.soulBrickSlabFull; + } + @Override + public BlockSlab getSingleBlock() { + return (BlockSlab) ModFluffBlocks.soulBrickSlab; + } } diff --git a/src/main/java/vazkii/botania/common/block/decor/slabs/bricks/BlockTileSlab.java b/src/main/java/vazkii/botania/common/block/decor/slabs/bricks/BlockTileSlab.java index 41ac1e9198..9433a9e042 100644 --- a/src/main/java/vazkii/botania/common/block/decor/slabs/bricks/BlockTileSlab.java +++ b/src/main/java/vazkii/botania/common/block/decor/slabs/bricks/BlockTileSlab.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jul 28, 2014, 11:49:42 PM (GMT)] */ package vazkii.botania.common.block.decor.slabs.bricks; @@ -15,18 +15,17 @@ public class BlockTileSlab extends BlockCustomBrickSlab { - public BlockTileSlab(boolean full) { - super(full, 3); - } + public BlockTileSlab(boolean full) { + super(full, 3); + } - @Override - public BlockSlab getFullBlock() { - return (BlockSlab) ModFluffBlocks.tileSlabFull; - } - - @Override - public BlockSlab getSingleBlock() { - return (BlockSlab) ModFluffBlocks.tileSlab; - } + @Override + public BlockSlab getFullBlock() { + return (BlockSlab) ModFluffBlocks.tileSlabFull; + } + @Override + public BlockSlab getSingleBlock() { + return (BlockSlab) ModFluffBlocks.tileSlab; + } } diff --git a/src/main/java/vazkii/botania/common/block/decor/slabs/living/BlockDreamwoodPlankSlab.java b/src/main/java/vazkii/botania/common/block/decor/slabs/living/BlockDreamwoodPlankSlab.java index 3474f89edd..697c645ba0 100644 --- a/src/main/java/vazkii/botania/common/block/decor/slabs/living/BlockDreamwoodPlankSlab.java +++ b/src/main/java/vazkii/botania/common/block/decor/slabs/living/BlockDreamwoodPlankSlab.java @@ -7,19 +7,18 @@ public class BlockDreamwoodPlankSlab extends BlockLivingSlab { - public BlockDreamwoodPlankSlab(boolean full) { - super(full, ModBlocks.dreamwood, 1); - setHardness(2.0F); - } + public BlockDreamwoodPlankSlab(boolean full) { + super(full, ModBlocks.dreamwood, 1); + setHardness(2.0F); + } - @Override - public BlockSlab getFullBlock() { - return (BlockSlab) ModFluffBlocks.dreamwoodPlankSlabFull; - } - - @Override - public BlockSlab getSingleBlock() { - return (BlockSlab) ModFluffBlocks.dreamwoodPlankSlab; - } + @Override + public BlockSlab getFullBlock() { + return (BlockSlab) ModFluffBlocks.dreamwoodPlankSlabFull; + } + @Override + public BlockSlab getSingleBlock() { + return (BlockSlab) ModFluffBlocks.dreamwoodPlankSlab; + } } diff --git a/src/main/java/vazkii/botania/common/block/decor/slabs/living/BlockDreamwoodSlab.java b/src/main/java/vazkii/botania/common/block/decor/slabs/living/BlockDreamwoodSlab.java index 9531c1eb92..83a1e3ff74 100644 --- a/src/main/java/vazkii/botania/common/block/decor/slabs/living/BlockDreamwoodSlab.java +++ b/src/main/java/vazkii/botania/common/block/decor/slabs/living/BlockDreamwoodSlab.java @@ -7,19 +7,18 @@ public class BlockDreamwoodSlab extends BlockLivingSlab { - public BlockDreamwoodSlab(boolean full) { - super(full, ModBlocks.dreamwood, 0); - setHardness(2.0F); - } + public BlockDreamwoodSlab(boolean full) { + super(full, ModBlocks.dreamwood, 0); + setHardness(2.0F); + } - @Override - public BlockSlab getFullBlock() { - return (BlockSlab) ModFluffBlocks.dreamwoodSlabFull; - } - - @Override - public BlockSlab getSingleBlock() { - return (BlockSlab) ModFluffBlocks.dreamwoodSlab; - } + @Override + public BlockSlab getFullBlock() { + return (BlockSlab) ModFluffBlocks.dreamwoodSlabFull; + } + @Override + public BlockSlab getSingleBlock() { + return (BlockSlab) ModFluffBlocks.dreamwoodSlab; + } } diff --git a/src/main/java/vazkii/botania/common/block/decor/slabs/living/BlockLivingrockBrickSlab.java b/src/main/java/vazkii/botania/common/block/decor/slabs/living/BlockLivingrockBrickSlab.java index f4cc7b46b9..6ce10fe7d8 100644 --- a/src/main/java/vazkii/botania/common/block/decor/slabs/living/BlockLivingrockBrickSlab.java +++ b/src/main/java/vazkii/botania/common/block/decor/slabs/living/BlockLivingrockBrickSlab.java @@ -7,21 +7,20 @@ public class BlockLivingrockBrickSlab extends BlockLivingSlab { - public BlockLivingrockBrickSlab(boolean full) { - super(full, ModBlocks.livingrock, 1); - setHardness(2.0F); - setResistance(10.0F); - setStepSound(soundTypeStone); - } + public BlockLivingrockBrickSlab(boolean full) { + super(full, ModBlocks.livingrock, 1); + setHardness(2.0F); + setResistance(10.0F); + setStepSound(soundTypeStone); + } - @Override - public BlockSlab getFullBlock() { - return (BlockSlab) ModFluffBlocks.livingrockBrickSlabFull; - } - - @Override - public BlockSlab getSingleBlock() { - return (BlockSlab) ModFluffBlocks.livingrockBrickSlab; - } + @Override + public BlockSlab getFullBlock() { + return (BlockSlab) ModFluffBlocks.livingrockBrickSlabFull; + } + @Override + public BlockSlab getSingleBlock() { + return (BlockSlab) ModFluffBlocks.livingrockBrickSlab; + } } diff --git a/src/main/java/vazkii/botania/common/block/decor/slabs/living/BlockLivingrockSlab.java b/src/main/java/vazkii/botania/common/block/decor/slabs/living/BlockLivingrockSlab.java index 4866a67129..6f6c49b8d3 100644 --- a/src/main/java/vazkii/botania/common/block/decor/slabs/living/BlockLivingrockSlab.java +++ b/src/main/java/vazkii/botania/common/block/decor/slabs/living/BlockLivingrockSlab.java @@ -7,21 +7,20 @@ public class BlockLivingrockSlab extends BlockLivingSlab { - public BlockLivingrockSlab(boolean full) { - super(full, ModBlocks.livingrock, 0); - setHardness(2.0F); - setResistance(10.0F); - setStepSound(soundTypeStone); - } + public BlockLivingrockSlab(boolean full) { + super(full, ModBlocks.livingrock, 0); + setHardness(2.0F); + setResistance(10.0F); + setStepSound(soundTypeStone); + } - @Override - public BlockSlab getFullBlock() { - return (BlockSlab) ModFluffBlocks.livingrockSlabFull; - } - - @Override - public BlockSlab getSingleBlock() { - return (BlockSlab) ModFluffBlocks.livingrockSlab; - } + @Override + public BlockSlab getFullBlock() { + return (BlockSlab) ModFluffBlocks.livingrockSlabFull; + } + @Override + public BlockSlab getSingleBlock() { + return (BlockSlab) ModFluffBlocks.livingrockSlab; + } } diff --git a/src/main/java/vazkii/botania/common/block/decor/slabs/living/BlockLivingwoodPlankSlab.java b/src/main/java/vazkii/botania/common/block/decor/slabs/living/BlockLivingwoodPlankSlab.java index 4ecc38374e..74d975dd9a 100644 --- a/src/main/java/vazkii/botania/common/block/decor/slabs/living/BlockLivingwoodPlankSlab.java +++ b/src/main/java/vazkii/botania/common/block/decor/slabs/living/BlockLivingwoodPlankSlab.java @@ -7,19 +7,18 @@ public class BlockLivingwoodPlankSlab extends BlockLivingSlab { - public BlockLivingwoodPlankSlab(boolean full) { - super(full, ModBlocks.livingwood, 1); - setHardness(2.0F); - } + public BlockLivingwoodPlankSlab(boolean full) { + super(full, ModBlocks.livingwood, 1); + setHardness(2.0F); + } - @Override - public BlockSlab getFullBlock() { - return (BlockSlab) ModFluffBlocks.livingwoodPlankSlabFull; - } - - @Override - public BlockSlab getSingleBlock() { - return (BlockSlab) ModFluffBlocks.livingwoodPlankSlab; - } + @Override + public BlockSlab getFullBlock() { + return (BlockSlab) ModFluffBlocks.livingwoodPlankSlabFull; + } + @Override + public BlockSlab getSingleBlock() { + return (BlockSlab) ModFluffBlocks.livingwoodPlankSlab; + } } diff --git a/src/main/java/vazkii/botania/common/block/decor/slabs/living/BlockLivingwoodSlab.java b/src/main/java/vazkii/botania/common/block/decor/slabs/living/BlockLivingwoodSlab.java index 53ea9e7459..41f0266ca4 100644 --- a/src/main/java/vazkii/botania/common/block/decor/slabs/living/BlockLivingwoodSlab.java +++ b/src/main/java/vazkii/botania/common/block/decor/slabs/living/BlockLivingwoodSlab.java @@ -7,19 +7,18 @@ public class BlockLivingwoodSlab extends BlockLivingSlab { - public BlockLivingwoodSlab(boolean full) { - super(full, ModBlocks.livingwood, 0); - setHardness(2.0F); - } + public BlockLivingwoodSlab(boolean full) { + super(full, ModBlocks.livingwood, 0); + setHardness(2.0F); + } - @Override - public BlockSlab getFullBlock() { - return (BlockSlab) ModFluffBlocks.livingwoodSlabFull; - } - - @Override - public BlockSlab getSingleBlock() { - return (BlockSlab) ModFluffBlocks.livingwoodSlab; - } + @Override + public BlockSlab getFullBlock() { + return (BlockSlab) ModFluffBlocks.livingwoodSlabFull; + } + @Override + public BlockSlab getSingleBlock() { + return (BlockSlab) ModFluffBlocks.livingwoodSlab; + } } diff --git a/src/main/java/vazkii/botania/common/block/decor/slabs/living/BlockShimmerrockSlab.java b/src/main/java/vazkii/botania/common/block/decor/slabs/living/BlockShimmerrockSlab.java index 8302a16475..823eb7fa99 100644 --- a/src/main/java/vazkii/botania/common/block/decor/slabs/living/BlockShimmerrockSlab.java +++ b/src/main/java/vazkii/botania/common/block/decor/slabs/living/BlockShimmerrockSlab.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Oct 11, 2015, 3:47:24 PM (GMT)] */ package vazkii.botania.common.block.decor.slabs.living; @@ -17,21 +17,20 @@ public class BlockShimmerrockSlab extends BlockLivingSlab { - public BlockShimmerrockSlab(boolean full) { - super(full, ModBlocks.shimmerrock, 0); - setHardness(2.0F); - setResistance(10.0F); - setStepSound(soundTypeStone); - } + public BlockShimmerrockSlab(boolean full) { + super(full, ModBlocks.shimmerrock, 0); + setHardness(2.0F); + setResistance(10.0F); + setStepSound(soundTypeStone); + } - @Override - public BlockSlab getFullBlock() { - return (BlockSlab) ModFluffBlocks.shimmerrockSlabFull; - } - - @Override - public BlockSlab getSingleBlock() { - return (BlockSlab) ModFluffBlocks.shimmerrockSlab; - } + @Override + public BlockSlab getFullBlock() { + return (BlockSlab) ModFluffBlocks.shimmerrockSlabFull; + } + @Override + public BlockSlab getSingleBlock() { + return (BlockSlab) ModFluffBlocks.shimmerrockSlab; + } } diff --git a/src/main/java/vazkii/botania/common/block/decor/slabs/living/BlockShimmerwoodPlankSlab.java b/src/main/java/vazkii/botania/common/block/decor/slabs/living/BlockShimmerwoodPlankSlab.java index 1f4b2fb09f..d44656380d 100644 --- a/src/main/java/vazkii/botania/common/block/decor/slabs/living/BlockShimmerwoodPlankSlab.java +++ b/src/main/java/vazkii/botania/common/block/decor/slabs/living/BlockShimmerwoodPlankSlab.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Oct 11, 2015, 3:47:47 PM (GMT)] */ package vazkii.botania.common.block.decor.slabs.living; @@ -17,20 +17,20 @@ public class BlockShimmerwoodPlankSlab extends BlockLivingSlab { - public BlockShimmerwoodPlankSlab(boolean full) { - super(full, ModBlocks.shimmerwoodPlanks, 0); - setHardness(2.0F); - setResistance(10.0F); - setStepSound(soundTypeWood); - } + public BlockShimmerwoodPlankSlab(boolean full) { + super(full, ModBlocks.shimmerwoodPlanks, 0); + setHardness(2.0F); + setResistance(10.0F); + setStepSound(soundTypeWood); + } - @Override - public BlockSlab getFullBlock() { - return (BlockSlab) ModFluffBlocks.shimmerwoodPlankSlabFull; - } + @Override + public BlockSlab getFullBlock() { + return (BlockSlab) ModFluffBlocks.shimmerwoodPlankSlabFull; + } - @Override - public BlockSlab getSingleBlock() { - return (BlockSlab) ModFluffBlocks.shimmerwoodPlankSlab; - } + @Override + public BlockSlab getSingleBlock() { + return (BlockSlab) ModFluffBlocks.shimmerwoodPlankSlab; + } } diff --git a/src/main/java/vazkii/botania/common/block/decor/slabs/prismarine/BlockDarkPrismarineSlab.java b/src/main/java/vazkii/botania/common/block/decor/slabs/prismarine/BlockDarkPrismarineSlab.java index 4d11d827ee..7dbf6f0341 100644 --- a/src/main/java/vazkii/botania/common/block/decor/slabs/prismarine/BlockDarkPrismarineSlab.java +++ b/src/main/java/vazkii/botania/common/block/decor/slabs/prismarine/BlockDarkPrismarineSlab.java @@ -5,18 +5,17 @@ public class BlockDarkPrismarineSlab extends BlockPrismarineSlab { - public BlockDarkPrismarineSlab(boolean full) { - super(full, 2); - } + public BlockDarkPrismarineSlab(boolean full) { + super(full, 2); + } - @Override - public BlockSlab getFullBlock() { - return (BlockSlab) ModFluffBlocks.darkPrismarineSlabFull; - } - - @Override - public BlockSlab getSingleBlock() { - return (BlockSlab) ModFluffBlocks.darkPrismarineSlab; - } + @Override + public BlockSlab getFullBlock() { + return (BlockSlab) ModFluffBlocks.darkPrismarineSlabFull; + } + @Override + public BlockSlab getSingleBlock() { + return (BlockSlab) ModFluffBlocks.darkPrismarineSlab; + } } diff --git a/src/main/java/vazkii/botania/common/block/decor/slabs/prismarine/BlockPrismarineBrickSlab.java b/src/main/java/vazkii/botania/common/block/decor/slabs/prismarine/BlockPrismarineBrickSlab.java index 9b7f5fa7a7..43495e35cc 100644 --- a/src/main/java/vazkii/botania/common/block/decor/slabs/prismarine/BlockPrismarineBrickSlab.java +++ b/src/main/java/vazkii/botania/common/block/decor/slabs/prismarine/BlockPrismarineBrickSlab.java @@ -5,18 +5,17 @@ public class BlockPrismarineBrickSlab extends BlockPrismarineSlab { - public BlockPrismarineBrickSlab(boolean full) { - super(full, 1); - } + public BlockPrismarineBrickSlab(boolean full) { + super(full, 1); + } - @Override - public BlockSlab getFullBlock() { - return (BlockSlab) ModFluffBlocks.prismarineBrickSlabFull; - } - - @Override - public BlockSlab getSingleBlock() { - return (BlockSlab) ModFluffBlocks.prismarineBrickSlab; - } + @Override + public BlockSlab getFullBlock() { + return (BlockSlab) ModFluffBlocks.prismarineBrickSlabFull; + } + @Override + public BlockSlab getSingleBlock() { + return (BlockSlab) ModFluffBlocks.prismarineBrickSlab; + } } diff --git a/src/main/java/vazkii/botania/common/block/decor/slabs/prismarine/BlockPrismarineSlab.java b/src/main/java/vazkii/botania/common/block/decor/slabs/prismarine/BlockPrismarineSlab.java index b9e385f032..3afe5a2c49 100644 --- a/src/main/java/vazkii/botania/common/block/decor/slabs/prismarine/BlockPrismarineSlab.java +++ b/src/main/java/vazkii/botania/common/block/decor/slabs/prismarine/BlockPrismarineSlab.java @@ -12,30 +12,29 @@ public class BlockPrismarineSlab extends BlockLivingSlab { - public BlockPrismarineSlab(boolean full) { - this(full, 0); - } - - public BlockPrismarineSlab(boolean full, int meta) { - super(full, ModBlocks.prismarine, meta); - setHardness(2.0F); - setResistance(10.0F); - setStepSound(soundTypeStone); - } - - @Override - public BlockSlab getFullBlock() { - return (BlockSlab) ModFluffBlocks.prismarineSlabFull; - } - - @Override - public BlockSlab getSingleBlock() { - return (BlockSlab) ModFluffBlocks.prismarineSlab; - } - - @Override - public LexiconEntry getEntry(World world, int x, int y, int z, EntityPlayer player, ItemStack lexicon) { - return LexiconData.prismarine; - } - + public BlockPrismarineSlab(boolean full) { + this(full, 0); + } + + public BlockPrismarineSlab(boolean full, int meta) { + super(full, ModBlocks.prismarine, meta); + setHardness(2.0F); + setResistance(10.0F); + setStepSound(soundTypeStone); + } + + @Override + public BlockSlab getFullBlock() { + return (BlockSlab) ModFluffBlocks.prismarineSlabFull; + } + + @Override + public BlockSlab getSingleBlock() { + return (BlockSlab) ModFluffBlocks.prismarineSlab; + } + + @Override + public LexiconEntry getEntry(World world, int x, int y, int z, EntityPlayer player, ItemStack lexicon) { + return LexiconData.prismarine; + } } diff --git a/src/main/java/vazkii/botania/common/block/decor/stairs/Block18StoneStairs.java b/src/main/java/vazkii/botania/common/block/decor/stairs/Block18StoneStairs.java index 3873be4c17..0e1bb4f60c 100644 --- a/src/main/java/vazkii/botania/common/block/decor/stairs/Block18StoneStairs.java +++ b/src/main/java/vazkii/botania/common/block/decor/stairs/Block18StoneStairs.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Apr 10, 2015, 7:51:29 PM (GMT)] */ package vazkii.botania.common.block.decor.stairs; @@ -19,13 +19,12 @@ public class Block18StoneStairs extends BlockLivingStairs { - public Block18StoneStairs(int meta) { - super(ModFluffBlocks.stone, meta); - } - - @Override - public LexiconEntry getEntry(World world, int x, int y, int z, EntityPlayer player, ItemStack lexicon) { - return LexiconData.stoneAlchemy; - } + public Block18StoneStairs(int meta) { + super(ModFluffBlocks.stone, meta); + } + @Override + public LexiconEntry getEntry(World world, int x, int y, int z, EntityPlayer player, ItemStack lexicon) { + return LexiconData.stoneAlchemy; + } } diff --git a/src/main/java/vazkii/botania/common/block/decor/stairs/BlockBiomeStoneStairs.java b/src/main/java/vazkii/botania/common/block/decor/stairs/BlockBiomeStoneStairs.java index 20ff8e624e..2ef630cd25 100644 --- a/src/main/java/vazkii/botania/common/block/decor/stairs/BlockBiomeStoneStairs.java +++ b/src/main/java/vazkii/botania/common/block/decor/stairs/BlockBiomeStoneStairs.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jan 29, 2015, 10:39:38 PM (GMT)] */ package vazkii.botania.common.block.decor.stairs; @@ -19,13 +19,12 @@ public class BlockBiomeStoneStairs extends BlockLivingStairs { - public BlockBiomeStoneStairs(Block source, int meta) { - super(source, meta); - } - - @Override - public LexiconEntry getEntry(World world, int x, int y, int z, EntityPlayer player, ItemStack lexicon) { - return LexiconData.marimorphosis; - } + public BlockBiomeStoneStairs(Block source, int meta) { + super(source, meta); + } + @Override + public LexiconEntry getEntry(World world, int x, int y, int z, EntityPlayer player, ItemStack lexicon) { + return LexiconData.marimorphosis; + } } diff --git a/src/main/java/vazkii/botania/common/block/decor/stairs/BlockEndStoneStairs.java b/src/main/java/vazkii/botania/common/block/decor/stairs/BlockEndStoneStairs.java index a2da6e37b6..f448932e14 100644 --- a/src/main/java/vazkii/botania/common/block/decor/stairs/BlockEndStoneStairs.java +++ b/src/main/java/vazkii/botania/common/block/decor/stairs/BlockEndStoneStairs.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Feb 16, 2015, 8:44:03 PM (GMT)] */ package vazkii.botania.common.block.decor.stairs; @@ -19,13 +19,12 @@ public class BlockEndStoneStairs extends BlockLivingStairs { - public BlockEndStoneStairs() { - super(ModBlocks.endStoneBrick, 0); - } - - @Override - public LexiconEntry getEntry(World world, int x, int y, int z, EntityPlayer player, ItemStack lexicon) { - return LexiconData.endStoneDecor; - } + public BlockEndStoneStairs() { + super(ModBlocks.endStoneBrick, 0); + } + @Override + public LexiconEntry getEntry(World world, int x, int y, int z, EntityPlayer player, ItemStack lexicon) { + return LexiconData.endStoneDecor; + } } diff --git a/src/main/java/vazkii/botania/common/block/decor/stairs/BlockEnderBrickStairs.java b/src/main/java/vazkii/botania/common/block/decor/stairs/BlockEnderBrickStairs.java index fdd23147c1..e9812a1b32 100644 --- a/src/main/java/vazkii/botania/common/block/decor/stairs/BlockEnderBrickStairs.java +++ b/src/main/java/vazkii/botania/common/block/decor/stairs/BlockEnderBrickStairs.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jul 7, 2015, 10:38:15 PM (GMT)] */ package vazkii.botania.common.block.decor.stairs; @@ -19,13 +19,12 @@ public class BlockEnderBrickStairs extends BlockLivingStairs { - public BlockEnderBrickStairs() { - super(ModBlocks.endStoneBrick, 2); - } - - @Override - public LexiconEntry getEntry(World world, int x, int y, int z, EntityPlayer player, ItemStack lexicon) { - return LexiconData.endStoneDecor; - } + public BlockEnderBrickStairs() { + super(ModBlocks.endStoneBrick, 2); + } + @Override + public LexiconEntry getEntry(World world, int x, int y, int z, EntityPlayer player, ItemStack lexicon) { + return LexiconData.endStoneDecor; + } } diff --git a/src/main/java/vazkii/botania/common/block/decor/stairs/BlockLivingStairs.java b/src/main/java/vazkii/botania/common/block/decor/stairs/BlockLivingStairs.java index 2dba633b5f..b30cd96644 100644 --- a/src/main/java/vazkii/botania/common/block/decor/stairs/BlockLivingStairs.java +++ b/src/main/java/vazkii/botania/common/block/decor/stairs/BlockLivingStairs.java @@ -4,8 +4,7 @@ public class BlockLivingStairs extends BlockModStairs { - public BlockLivingStairs(Block source, int meta) { - super(source, meta, source.getUnlocalizedName().replaceAll("tile.", "") + meta + "Stairs"); - } - + public BlockLivingStairs(Block source, int meta) { + super(source, meta, source.getUnlocalizedName().replaceAll("tile.", "") + meta + "Stairs"); + } } diff --git a/src/main/java/vazkii/botania/common/block/decor/stairs/BlockModStairs.java b/src/main/java/vazkii/botania/common/block/decor/stairs/BlockModStairs.java index 82ad317d5f..a30a541318 100644 --- a/src/main/java/vazkii/botania/common/block/decor/stairs/BlockModStairs.java +++ b/src/main/java/vazkii/botania/common/block/decor/stairs/BlockModStairs.java @@ -1,5 +1,6 @@ package vazkii.botania.common.block.decor.stairs; +import cpw.mods.fml.common.registry.GameRegistry; import net.minecraft.block.Block; import net.minecraft.block.BlockStairs; import net.minecraft.entity.player.EntityPlayer; @@ -10,26 +11,24 @@ import vazkii.botania.common.core.BotaniaCreativeTab; import vazkii.botania.common.item.block.ItemBlockMod; import vazkii.botania.common.lexicon.LexiconData; -import cpw.mods.fml.common.registry.GameRegistry; public class BlockModStairs extends BlockStairs implements ILexiconable { - public BlockModStairs(Block source, int meta, String name) { - super(source, meta); - setBlockName(name); - setCreativeTab(BotaniaCreativeTab.INSTANCE); - useNeighborBrightness = true; - } - - @Override - public Block setBlockName(String par1Str) { - GameRegistry.registerBlock(this, ItemBlockMod.class, par1Str); - return super.setBlockName(par1Str); - } + public BlockModStairs(Block source, int meta, String name) { + super(source, meta); + setBlockName(name); + setCreativeTab(BotaniaCreativeTab.INSTANCE); + useNeighborBrightness = true; + } - @Override - public LexiconEntry getEntry(World world, int x, int y, int z, EntityPlayer player, ItemStack lexicon) { - return LexiconData.decorativeBlocks; - } + @Override + public Block setBlockName(String par1Str) { + GameRegistry.registerBlock(this, ItemBlockMod.class, par1Str); + return super.setBlockName(par1Str); + } + @Override + public LexiconEntry getEntry(World world, int x, int y, int z, EntityPlayer player, ItemStack lexicon) { + return LexiconData.decorativeBlocks; + } } diff --git a/src/main/java/vazkii/botania/common/block/decor/stairs/BlockPavementStairs.java b/src/main/java/vazkii/botania/common/block/decor/stairs/BlockPavementStairs.java index fd96247177..26f7c443d4 100644 --- a/src/main/java/vazkii/botania/common/block/decor/stairs/BlockPavementStairs.java +++ b/src/main/java/vazkii/botania/common/block/decor/stairs/BlockPavementStairs.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Sep 1, 2015, 7:16:53 PM (GMT)] */ package vazkii.botania.common.block.decor.stairs; @@ -19,13 +19,12 @@ public class BlockPavementStairs extends BlockLivingStairs { - public BlockPavementStairs(int meta) { - super(ModFluffBlocks.pavement, meta); - } - - @Override - public LexiconEntry getEntry(World world, int x, int y, int z, EntityPlayer player, ItemStack lexicon) { - return LexiconData.pavement; - } + public BlockPavementStairs(int meta) { + super(ModFluffBlocks.pavement, meta); + } + @Override + public LexiconEntry getEntry(World world, int x, int y, int z, EntityPlayer player, ItemStack lexicon) { + return LexiconData.pavement; + } } diff --git a/src/main/java/vazkii/botania/common/block/decor/stairs/BlockReedStairs.java b/src/main/java/vazkii/botania/common/block/decor/stairs/BlockReedStairs.java index c2c0453076..a13857f8c2 100644 --- a/src/main/java/vazkii/botania/common/block/decor/stairs/BlockReedStairs.java +++ b/src/main/java/vazkii/botania/common/block/decor/stairs/BlockReedStairs.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jul 28, 2014, 8:47:52 PM (GMT)] */ package vazkii.botania.common.block.decor.stairs; @@ -19,14 +19,12 @@ public class BlockReedStairs extends BlockLivingStairs { - public BlockReedStairs() { - super(ModBlocks.reedBlock, 0); - } - - @Override - public LexiconEntry getEntry(World world, int x, int y, int z, EntityPlayer player, ItemStack lexicon) { - return LexiconData.decorativeBlocks; - } - + public BlockReedStairs() { + super(ModBlocks.reedBlock, 0); + } + @Override + public LexiconEntry getEntry(World world, int x, int y, int z, EntityPlayer player, ItemStack lexicon) { + return LexiconData.decorativeBlocks; + } } diff --git a/src/main/java/vazkii/botania/common/block/decor/stairs/BlockThatchStairs.java b/src/main/java/vazkii/botania/common/block/decor/stairs/BlockThatchStairs.java index d55162c512..c6ed76fb58 100644 --- a/src/main/java/vazkii/botania/common/block/decor/stairs/BlockThatchStairs.java +++ b/src/main/java/vazkii/botania/common/block/decor/stairs/BlockThatchStairs.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jul 28, 2014, 8:47:52 PM (GMT)] */ package vazkii.botania.common.block.decor.stairs; @@ -19,14 +19,12 @@ public class BlockThatchStairs extends BlockLivingStairs { - public BlockThatchStairs() { - super(ModBlocks.thatch, 0); - } - - @Override - public LexiconEntry getEntry(World world, int x, int y, int z, EntityPlayer player, ItemStack lexicon) { - return LexiconData.decorativeBlocks; - } - + public BlockThatchStairs() { + super(ModBlocks.thatch, 0); + } + @Override + public LexiconEntry getEntry(World world, int x, int y, int z, EntityPlayer player, ItemStack lexicon) { + return LexiconData.decorativeBlocks; + } } diff --git a/src/main/java/vazkii/botania/common/block/decor/stairs/bricks/BlockCustomBrickStairs.java b/src/main/java/vazkii/botania/common/block/decor/stairs/bricks/BlockCustomBrickStairs.java index e49976d2aa..3563eb72b3 100644 --- a/src/main/java/vazkii/botania/common/block/decor/stairs/bricks/BlockCustomBrickStairs.java +++ b/src/main/java/vazkii/botania/common/block/decor/stairs/bricks/BlockCustomBrickStairs.java @@ -10,17 +10,16 @@ public class BlockCustomBrickStairs extends BlockLivingStairs { - public BlockCustomBrickStairs() { - this(0); - } + public BlockCustomBrickStairs() { + this(0); + } - public BlockCustomBrickStairs(int meta) { - super(ModBlocks.customBrick, meta); - } - - @Override - public LexiconEntry getEntry(World world, int x, int y, int z, EntityPlayer player, ItemStack lexicon) { - return LexiconData.decorativeBlocks; - } + public BlockCustomBrickStairs(int meta) { + super(ModBlocks.customBrick, meta); + } + @Override + public LexiconEntry getEntry(World world, int x, int y, int z, EntityPlayer player, ItemStack lexicon) { + return LexiconData.decorativeBlocks; + } } diff --git a/src/main/java/vazkii/botania/common/block/decor/stairs/bricks/BlockSnowBrickStairs.java b/src/main/java/vazkii/botania/common/block/decor/stairs/bricks/BlockSnowBrickStairs.java index de545e4c74..baf8013af6 100644 --- a/src/main/java/vazkii/botania/common/block/decor/stairs/bricks/BlockSnowBrickStairs.java +++ b/src/main/java/vazkii/botania/common/block/decor/stairs/bricks/BlockSnowBrickStairs.java @@ -2,18 +2,17 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jul 28, 2014, 11:28:47 PM (GMT)] */ package vazkii.botania.common.block.decor.stairs.bricks; public class BlockSnowBrickStairs extends BlockCustomBrickStairs { - public BlockSnowBrickStairs() { - super(2); - } - + public BlockSnowBrickStairs() { + super(2); + } } diff --git a/src/main/java/vazkii/botania/common/block/decor/stairs/bricks/BlockSoulBrickStairs.java b/src/main/java/vazkii/botania/common/block/decor/stairs/bricks/BlockSoulBrickStairs.java index 7d031030be..30425e7323 100644 --- a/src/main/java/vazkii/botania/common/block/decor/stairs/bricks/BlockSoulBrickStairs.java +++ b/src/main/java/vazkii/botania/common/block/decor/stairs/bricks/BlockSoulBrickStairs.java @@ -2,18 +2,17 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jul 28, 2014, 10:10:00 PM (GMT)] */ package vazkii.botania.common.block.decor.stairs.bricks; public class BlockSoulBrickStairs extends BlockCustomBrickStairs { - public BlockSoulBrickStairs() { - super(1); - } - + public BlockSoulBrickStairs() { + super(1); + } } diff --git a/src/main/java/vazkii/botania/common/block/decor/stairs/bricks/BlockTileStairs.java b/src/main/java/vazkii/botania/common/block/decor/stairs/bricks/BlockTileStairs.java index 943fe3b393..d559238f8d 100644 --- a/src/main/java/vazkii/botania/common/block/decor/stairs/bricks/BlockTileStairs.java +++ b/src/main/java/vazkii/botania/common/block/decor/stairs/bricks/BlockTileStairs.java @@ -2,18 +2,17 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jul 28, 2014, 10:10:00 PM (GMT)] */ package vazkii.botania.common.block.decor.stairs.bricks; public class BlockTileStairs extends BlockCustomBrickStairs { - public BlockTileStairs() { - super(3); - } - + public BlockTileStairs() { + super(3); + } } diff --git a/src/main/java/vazkii/botania/common/block/decor/stairs/living/BlockDreamwoodPlankStairs.java b/src/main/java/vazkii/botania/common/block/decor/stairs/living/BlockDreamwoodPlankStairs.java index bba59293c0..ed5cfa6cac 100644 --- a/src/main/java/vazkii/botania/common/block/decor/stairs/living/BlockDreamwoodPlankStairs.java +++ b/src/main/java/vazkii/botania/common/block/decor/stairs/living/BlockDreamwoodPlankStairs.java @@ -5,8 +5,7 @@ public class BlockDreamwoodPlankStairs extends BlockLivingStairs { - public BlockDreamwoodPlankStairs() { - super(ModBlocks.dreamwood, 1); - } - + public BlockDreamwoodPlankStairs() { + super(ModBlocks.dreamwood, 1); + } } diff --git a/src/main/java/vazkii/botania/common/block/decor/stairs/living/BlockDreamwoodStairs.java b/src/main/java/vazkii/botania/common/block/decor/stairs/living/BlockDreamwoodStairs.java index 7d87c4a0a7..96d4b2a1f2 100644 --- a/src/main/java/vazkii/botania/common/block/decor/stairs/living/BlockDreamwoodStairs.java +++ b/src/main/java/vazkii/botania/common/block/decor/stairs/living/BlockDreamwoodStairs.java @@ -5,8 +5,7 @@ public class BlockDreamwoodStairs extends BlockLivingStairs { - public BlockDreamwoodStairs() { - super(ModBlocks.dreamwood, 0); - } - + public BlockDreamwoodStairs() { + super(ModBlocks.dreamwood, 0); + } } diff --git a/src/main/java/vazkii/botania/common/block/decor/stairs/living/BlockLivingrockBrickStairs.java b/src/main/java/vazkii/botania/common/block/decor/stairs/living/BlockLivingrockBrickStairs.java index 08618fc798..8117fc359e 100644 --- a/src/main/java/vazkii/botania/common/block/decor/stairs/living/BlockLivingrockBrickStairs.java +++ b/src/main/java/vazkii/botania/common/block/decor/stairs/living/BlockLivingrockBrickStairs.java @@ -5,8 +5,7 @@ public class BlockLivingrockBrickStairs extends BlockLivingStairs { - public BlockLivingrockBrickStairs() { - super(ModBlocks.livingrock, 1); - } - + public BlockLivingrockBrickStairs() { + super(ModBlocks.livingrock, 1); + } } diff --git a/src/main/java/vazkii/botania/common/block/decor/stairs/living/BlockLivingrockStairs.java b/src/main/java/vazkii/botania/common/block/decor/stairs/living/BlockLivingrockStairs.java index a974af4e8e..844bfec5ec 100644 --- a/src/main/java/vazkii/botania/common/block/decor/stairs/living/BlockLivingrockStairs.java +++ b/src/main/java/vazkii/botania/common/block/decor/stairs/living/BlockLivingrockStairs.java @@ -5,8 +5,7 @@ public class BlockLivingrockStairs extends BlockLivingStairs { - public BlockLivingrockStairs() { - super(ModBlocks.livingrock, 0); - } - + public BlockLivingrockStairs() { + super(ModBlocks.livingrock, 0); + } } diff --git a/src/main/java/vazkii/botania/common/block/decor/stairs/living/BlockLivingwoodPlankStairs.java b/src/main/java/vazkii/botania/common/block/decor/stairs/living/BlockLivingwoodPlankStairs.java index 9ffc1a3159..d799371231 100644 --- a/src/main/java/vazkii/botania/common/block/decor/stairs/living/BlockLivingwoodPlankStairs.java +++ b/src/main/java/vazkii/botania/common/block/decor/stairs/living/BlockLivingwoodPlankStairs.java @@ -5,8 +5,7 @@ public class BlockLivingwoodPlankStairs extends BlockLivingStairs { - public BlockLivingwoodPlankStairs() { - super(ModBlocks.livingwood, 1); - } - + public BlockLivingwoodPlankStairs() { + super(ModBlocks.livingwood, 1); + } } diff --git a/src/main/java/vazkii/botania/common/block/decor/stairs/living/BlockLivingwoodStairs.java b/src/main/java/vazkii/botania/common/block/decor/stairs/living/BlockLivingwoodStairs.java index d1dec721f6..5b54b6a7c8 100644 --- a/src/main/java/vazkii/botania/common/block/decor/stairs/living/BlockLivingwoodStairs.java +++ b/src/main/java/vazkii/botania/common/block/decor/stairs/living/BlockLivingwoodStairs.java @@ -5,8 +5,7 @@ public class BlockLivingwoodStairs extends BlockLivingStairs { - public BlockLivingwoodStairs() { - super(ModBlocks.livingwood, 0); - } - + public BlockLivingwoodStairs() { + super(ModBlocks.livingwood, 0); + } } diff --git a/src/main/java/vazkii/botania/common/block/decor/stairs/living/BlockShimmerrockStairs.java b/src/main/java/vazkii/botania/common/block/decor/stairs/living/BlockShimmerrockStairs.java index 34e6cfe2a7..2250590917 100644 --- a/src/main/java/vazkii/botania/common/block/decor/stairs/living/BlockShimmerrockStairs.java +++ b/src/main/java/vazkii/botania/common/block/decor/stairs/living/BlockShimmerrockStairs.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Oct 11, 2015, 3:46:12 PM (GMT)] */ package vazkii.botania.common.block.decor.stairs.living; @@ -15,8 +15,7 @@ public class BlockShimmerrockStairs extends BlockLivingStairs { - public BlockShimmerrockStairs() { - super(ModBlocks.shimmerrock, 0); - } - + public BlockShimmerrockStairs() { + super(ModBlocks.shimmerrock, 0); + } } diff --git a/src/main/java/vazkii/botania/common/block/decor/stairs/living/BlockShimmerwoodPlankStairs.java b/src/main/java/vazkii/botania/common/block/decor/stairs/living/BlockShimmerwoodPlankStairs.java index 5714756e16..05b5065a2c 100644 --- a/src/main/java/vazkii/botania/common/block/decor/stairs/living/BlockShimmerwoodPlankStairs.java +++ b/src/main/java/vazkii/botania/common/block/decor/stairs/living/BlockShimmerwoodPlankStairs.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Oct 11, 2015, 3:45:02 PM (GMT)] */ package vazkii.botania.common.block.decor.stairs.living; @@ -15,8 +15,7 @@ public class BlockShimmerwoodPlankStairs extends BlockLivingStairs { - public BlockShimmerwoodPlankStairs() { - super(ModBlocks.shimmerwoodPlanks, 0); - } - + public BlockShimmerwoodPlankStairs() { + super(ModBlocks.shimmerwoodPlanks, 0); + } } diff --git a/src/main/java/vazkii/botania/common/block/decor/stairs/prismarine/BlockDarkPrismarineStairs.java b/src/main/java/vazkii/botania/common/block/decor/stairs/prismarine/BlockDarkPrismarineStairs.java index 2d3c999633..965fa631de 100644 --- a/src/main/java/vazkii/botania/common/block/decor/stairs/prismarine/BlockDarkPrismarineStairs.java +++ b/src/main/java/vazkii/botania/common/block/decor/stairs/prismarine/BlockDarkPrismarineStairs.java @@ -1,10 +1,8 @@ package vazkii.botania.common.block.decor.stairs.prismarine; - public class BlockDarkPrismarineStairs extends BlockPrismarineStairs { - public BlockDarkPrismarineStairs() { - super(2); - } - + public BlockDarkPrismarineStairs() { + super(2); + } } diff --git a/src/main/java/vazkii/botania/common/block/decor/stairs/prismarine/BlockPrismarineBrickStairs.java b/src/main/java/vazkii/botania/common/block/decor/stairs/prismarine/BlockPrismarineBrickStairs.java index f3d015e469..c49aee6f44 100644 --- a/src/main/java/vazkii/botania/common/block/decor/stairs/prismarine/BlockPrismarineBrickStairs.java +++ b/src/main/java/vazkii/botania/common/block/decor/stairs/prismarine/BlockPrismarineBrickStairs.java @@ -1,10 +1,8 @@ package vazkii.botania.common.block.decor.stairs.prismarine; - public class BlockPrismarineBrickStairs extends BlockPrismarineStairs { - public BlockPrismarineBrickStairs() { - super(1); - } - + public BlockPrismarineBrickStairs() { + super(1); + } } diff --git a/src/main/java/vazkii/botania/common/block/decor/stairs/prismarine/BlockPrismarineStairs.java b/src/main/java/vazkii/botania/common/block/decor/stairs/prismarine/BlockPrismarineStairs.java index 3a823ffd3b..e6fc1262b5 100644 --- a/src/main/java/vazkii/botania/common/block/decor/stairs/prismarine/BlockPrismarineStairs.java +++ b/src/main/java/vazkii/botania/common/block/decor/stairs/prismarine/BlockPrismarineStairs.java @@ -10,17 +10,16 @@ public class BlockPrismarineStairs extends BlockLivingStairs { - public BlockPrismarineStairs() { - this(0); - } + public BlockPrismarineStairs() { + this(0); + } - public BlockPrismarineStairs(int meta) { - super(ModBlocks.prismarine, meta); - } - - @Override - public LexiconEntry getEntry(World world, int x, int y, int z, EntityPlayer player, ItemStack lexicon) { - return LexiconData.prismarine; - } + public BlockPrismarineStairs(int meta) { + super(ModBlocks.prismarine, meta); + } + @Override + public LexiconEntry getEntry(World world, int x, int y, int z, EntityPlayer player, ItemStack lexicon) { + return LexiconData.prismarine; + } } diff --git a/src/main/java/vazkii/botania/common/block/decor/walls/Block18StoneWall.java b/src/main/java/vazkii/botania/common/block/decor/walls/Block18StoneWall.java index 64b30f6956..27f03e7cac 100644 --- a/src/main/java/vazkii/botania/common/block/decor/walls/Block18StoneWall.java +++ b/src/main/java/vazkii/botania/common/block/decor/walls/Block18StoneWall.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jul 18, 2015, 8:41:10 PM (GMT)] */ package vazkii.botania.common.block.decor.walls; @@ -19,15 +19,14 @@ public class Block18StoneWall extends BlockVariantWall { - public Block18StoneWall() { - super(ModFluffBlocks.stone, 4); - setHardness(1.5F); - setResistance(10F); - } - - @Override - public LexiconEntry getEntry(World world, int x, int y, int z, EntityPlayer player, ItemStack lexicon) { - return LexiconData.stoneAlchemy; - } + public Block18StoneWall() { + super(ModFluffBlocks.stone, 4); + setHardness(1.5F); + setResistance(10F); + } + @Override + public LexiconEntry getEntry(World world, int x, int y, int z, EntityPlayer player, ItemStack lexicon) { + return LexiconData.stoneAlchemy; + } } diff --git a/src/main/java/vazkii/botania/common/block/decor/walls/BlockBiomeStoneWall.java b/src/main/java/vazkii/botania/common/block/decor/walls/BlockBiomeStoneWall.java index 3f8a3e037d..50b868f778 100644 --- a/src/main/java/vazkii/botania/common/block/decor/walls/BlockBiomeStoneWall.java +++ b/src/main/java/vazkii/botania/common/block/decor/walls/BlockBiomeStoneWall.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jul 18, 2015, 8:31:47 PM (GMT)] */ package vazkii.botania.common.block.decor.walls; @@ -19,15 +19,14 @@ public class BlockBiomeStoneWall extends BlockVariantWall { - public BlockBiomeStoneWall() { - super(ModFluffBlocks.biomeStoneA, 8, 8); - setHardness(1.5F); - setResistance(10F); - } - - @Override - public LexiconEntry getEntry(World world, int x, int y, int z, EntityPlayer player, ItemStack lexicon) { - return LexiconData.marimorphosis; - } + public BlockBiomeStoneWall() { + super(ModFluffBlocks.biomeStoneA, 8, 8); + setHardness(1.5F); + setResistance(10F); + } + @Override + public LexiconEntry getEntry(World world, int x, int y, int z, EntityPlayer player, ItemStack lexicon) { + return LexiconData.marimorphosis; + } } diff --git a/src/main/java/vazkii/botania/common/block/decor/walls/BlockModWall.java b/src/main/java/vazkii/botania/common/block/decor/walls/BlockModWall.java index b0a3863b7a..7d24cd800f 100644 --- a/src/main/java/vazkii/botania/common/block/decor/walls/BlockModWall.java +++ b/src/main/java/vazkii/botania/common/block/decor/walls/BlockModWall.java @@ -2,16 +2,16 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jul 18, 2015, 8:15:36 PM (GMT)] */ package vazkii.botania.common.block.decor.walls; +import cpw.mods.fml.common.registry.GameRegistry; import java.util.List; - import net.minecraft.block.Block; import net.minecraft.block.BlockWall; import net.minecraft.client.renderer.texture.IIconRegister; @@ -25,53 +25,51 @@ import vazkii.botania.api.lexicon.LexiconEntry; import vazkii.botania.common.item.block.ItemBlockMod; import vazkii.botania.common.lexicon.LexiconData; -import cpw.mods.fml.common.registry.GameRegistry; public class BlockModWall extends BlockWall implements ILexiconable { - Block block; - int meta; - - public BlockModWall(Block block, int meta) { - super(block); - this.block = block; - this.meta = meta; - setBlockName(block.getUnlocalizedName().replaceAll("tile.", "") + meta + "Wall"); - } + Block block; + int meta; - @Override - public boolean canPlaceTorchOnTop(World world, int x, int y, int z) { - return true; - } + public BlockModWall(Block block, int meta) { + super(block); + this.block = block; + this.meta = meta; + setBlockName(block.getUnlocalizedName().replaceAll("tile.", "") + meta + "Wall"); + } - @Override - public Block setBlockName(String par1Str) { - register(par1Str); - return super.setBlockName(par1Str); - } + @Override + public boolean canPlaceTorchOnTop(World world, int x, int y, int z) { + return true; + } - public void register(String name) { - GameRegistry.registerBlock(this, ItemBlockMod.class, name); - } + @Override + public Block setBlockName(String par1Str) { + register(par1Str); + return super.setBlockName(par1Str); + } - @Override - public void getSubBlocks(Item item, CreativeTabs tabs, List list) { - list.add(new ItemStack(item)); - } + public void register(String name) { + GameRegistry.registerBlock(this, ItemBlockMod.class, name); + } - @Override - public IIcon getIcon(int side, int meta) { - return block.getIcon(side, this.meta); - } + @Override + public void getSubBlocks(Item item, CreativeTabs tabs, List list) { + list.add(new ItemStack(item)); + } - @Override - public LexiconEntry getEntry(World world, int x, int y, int z, EntityPlayer player, ItemStack lexicon) { - return LexiconData.decorativeBlocks; - } + @Override + public IIcon getIcon(int side, int meta) { + return block.getIcon(side, this.meta); + } - @Override - public void registerBlockIcons(IIconRegister p_149651_1_) { - // NO-OP - } + @Override + public LexiconEntry getEntry(World world, int x, int y, int z, EntityPlayer player, ItemStack lexicon) { + return LexiconData.decorativeBlocks; + } + @Override + public void registerBlockIcons(IIconRegister p_149651_1_) { + // NO-OP + } } diff --git a/src/main/java/vazkii/botania/common/block/decor/walls/BlockPrismarineWall.java b/src/main/java/vazkii/botania/common/block/decor/walls/BlockPrismarineWall.java index 0c0029950f..b47b2d0ad8 100644 --- a/src/main/java/vazkii/botania/common/block/decor/walls/BlockPrismarineWall.java +++ b/src/main/java/vazkii/botania/common/block/decor/walls/BlockPrismarineWall.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jul 18, 2015, 8:30:00 PM (GMT)] */ package vazkii.botania.common.block.decor.walls; @@ -19,16 +19,15 @@ public class BlockPrismarineWall extends BlockModWall { - public BlockPrismarineWall() { - super(ModBlocks.prismarine, 0); - setHardness(2.0F); - setResistance(10.0F); - setStepSound(soundTypeStone); - } - - @Override - public LexiconEntry getEntry(World world, int x, int y, int z, EntityPlayer player, ItemStack lexicon) { - return LexiconData.prismarine; - } + public BlockPrismarineWall() { + super(ModBlocks.prismarine, 0); + setHardness(2.0F); + setResistance(10.0F); + setStepSound(soundTypeStone); + } + @Override + public LexiconEntry getEntry(World world, int x, int y, int z, EntityPlayer player, ItemStack lexicon) { + return LexiconData.prismarine; + } } diff --git a/src/main/java/vazkii/botania/common/block/decor/walls/BlockReedWall.java b/src/main/java/vazkii/botania/common/block/decor/walls/BlockReedWall.java index 508389fd86..37482c5d57 100644 --- a/src/main/java/vazkii/botania/common/block/decor/walls/BlockReedWall.java +++ b/src/main/java/vazkii/botania/common/block/decor/walls/BlockReedWall.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jul 18, 2015, 8:31:04 PM (GMT)] */ package vazkii.botania.common.block.decor.walls; @@ -14,10 +14,9 @@ public class BlockReedWall extends BlockModWall { - public BlockReedWall() { - super(ModBlocks.reedBlock, 0); - setHardness(1.0F); - setStepSound(soundTypeWood); - } - + public BlockReedWall() { + super(ModBlocks.reedBlock, 0); + setHardness(1.0F); + setStepSound(soundTypeWood); + } } diff --git a/src/main/java/vazkii/botania/common/block/decor/walls/BlockVariantWall.java b/src/main/java/vazkii/botania/common/block/decor/walls/BlockVariantWall.java index 4c457bb441..644920105e 100644 --- a/src/main/java/vazkii/botania/common/block/decor/walls/BlockVariantWall.java +++ b/src/main/java/vazkii/botania/common/block/decor/walls/BlockVariantWall.java @@ -2,54 +2,50 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jul 18, 2015, 8:42:16 PM (GMT)] */ package vazkii.botania.common.block.decor.walls; +import cpw.mods.fml.common.registry.GameRegistry; import java.util.List; - import net.minecraft.block.Block; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.util.IIcon; import vazkii.botania.common.item.block.ItemBlockWithMetadataAndName; -import cpw.mods.fml.common.registry.GameRegistry; public class BlockVariantWall extends BlockModWall { - int metaStates; - int metaShift; - - public BlockVariantWall(Block block, int metaStates, int metaShift) { - super(block, 0); - this.metaStates = metaStates; - this.metaShift = metaShift; - } - - public BlockVariantWall(Block block, int metaStates) { - this(block, metaStates, 0); - } - - @Override - public void register(String name) { - GameRegistry.registerBlock(this, ItemBlockWithMetadataAndName.class, name); - } - - @Override - public void getSubBlocks(Item item, CreativeTabs tabs, List list) { - for(int i = 0; i < metaStates; i++) - list.add(new ItemStack(item, 1, i)); - } - - @Override - public IIcon getIcon(int side, int meta) { - return block.getIcon(side, meta + metaShift); - } - - + int metaStates; + int metaShift; + + public BlockVariantWall(Block block, int metaStates, int metaShift) { + super(block, 0); + this.metaStates = metaStates; + this.metaShift = metaShift; + } + + public BlockVariantWall(Block block, int metaStates) { + this(block, metaStates, 0); + } + + @Override + public void register(String name) { + GameRegistry.registerBlock(this, ItemBlockWithMetadataAndName.class, name); + } + + @Override + public void getSubBlocks(Item item, CreativeTabs tabs, List list) { + for (int i = 0; i < metaStates; i++) list.add(new ItemStack(item, 1, i)); + } + + @Override + public IIcon getIcon(int side, int meta) { + return block.getIcon(side, meta + metaShift); + } } diff --git a/src/main/java/vazkii/botania/common/block/decor/walls/living/BlockDreamwoodWall.java b/src/main/java/vazkii/botania/common/block/decor/walls/living/BlockDreamwoodWall.java index 6006e41a37..c420536f8e 100644 --- a/src/main/java/vazkii/botania/common/block/decor/walls/living/BlockDreamwoodWall.java +++ b/src/main/java/vazkii/botania/common/block/decor/walls/living/BlockDreamwoodWall.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jul 18, 2015, 8:29:16 PM (GMT)] */ package vazkii.botania.common.block.decor.walls.living; @@ -15,10 +15,9 @@ public class BlockDreamwoodWall extends BlockModWall { - public BlockDreamwoodWall() { - super(ModBlocks.dreamwood, 0); - setHardness(2.0F); - setStepSound(soundTypeWood); - } - + public BlockDreamwoodWall() { + super(ModBlocks.dreamwood, 0); + setHardness(2.0F); + setStepSound(soundTypeWood); + } } diff --git a/src/main/java/vazkii/botania/common/block/decor/walls/living/BlockLivingrockWall.java b/src/main/java/vazkii/botania/common/block/decor/walls/living/BlockLivingrockWall.java index 603eebc83d..41a4aaee84 100644 --- a/src/main/java/vazkii/botania/common/block/decor/walls/living/BlockLivingrockWall.java +++ b/src/main/java/vazkii/botania/common/block/decor/walls/living/BlockLivingrockWall.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jul 18, 2015, 8:25:54 PM (GMT)] */ package vazkii.botania.common.block.decor.walls.living; @@ -15,11 +15,10 @@ public class BlockLivingrockWall extends BlockModWall { - public BlockLivingrockWall() { - super(ModBlocks.livingrock, 0); - setHardness(2.0F); - setResistance(10.0F); - setStepSound(soundTypeStone); - } - + public BlockLivingrockWall() { + super(ModBlocks.livingrock, 0); + setHardness(2.0F); + setResistance(10.0F); + setStepSound(soundTypeStone); + } } diff --git a/src/main/java/vazkii/botania/common/block/decor/walls/living/BlockLivingwoodWall.java b/src/main/java/vazkii/botania/common/block/decor/walls/living/BlockLivingwoodWall.java index b958d4ff7c..86149c5c6f 100644 --- a/src/main/java/vazkii/botania/common/block/decor/walls/living/BlockLivingwoodWall.java +++ b/src/main/java/vazkii/botania/common/block/decor/walls/living/BlockLivingwoodWall.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jul 18, 2015, 8:28:06 PM (GMT)] */ package vazkii.botania.common.block.decor.walls.living; @@ -15,10 +15,9 @@ public class BlockLivingwoodWall extends BlockModWall { - public BlockLivingwoodWall() { - super(ModBlocks.livingwood, 0); - setHardness(2.0F); - setStepSound(soundTypeWood); - } - + public BlockLivingwoodWall() { + super(ModBlocks.livingwood, 0); + setHardness(2.0F); + setStepSound(soundTypeWood); + } } diff --git a/src/main/java/vazkii/botania/common/block/dispenser/BehaviourPoolMinecart.java b/src/main/java/vazkii/botania/common/block/dispenser/BehaviourPoolMinecart.java index 5639c93863..e510e45b63 100644 --- a/src/main/java/vazkii/botania/common/block/dispenser/BehaviourPoolMinecart.java +++ b/src/main/java/vazkii/botania/common/block/dispenser/BehaviourPoolMinecart.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Mar 18, 2015, 12:22:58 AM (GMT)] */ package vazkii.botania.common.block.dispenser; @@ -24,41 +24,38 @@ public class BehaviourPoolMinecart extends BehaviorDefaultDispenseItem { - @Override - public ItemStack dispenseStack(IBlockSource p_82487_1_, ItemStack p_82487_2_) { - EnumFacing enumfacing = BlockDispenser.func_149937_b(p_82487_1_.getBlockMetadata()); - World world = p_82487_1_.getWorld(); - double d0 = p_82487_1_.getX() + enumfacing.getFrontOffsetX() * 1.125F; - double d1 = p_82487_1_.getY() + enumfacing.getFrontOffsetY() * 1.125F; - double d2 = p_82487_1_.getZ() + enumfacing.getFrontOffsetZ() * 1.125F; - int i = p_82487_1_.getXInt() + enumfacing.getFrontOffsetX(); - int j = p_82487_1_.getYInt() + enumfacing.getFrontOffsetY(); - int k = p_82487_1_.getZInt() + enumfacing.getFrontOffsetZ(); - Block block = world.getBlock(i, j, k); - double d3; - - if(BlockRailBase.func_150051_a(block)) - d3 = 0.0D; - else { - if(block.getMaterial() != Material.air || !BlockRailBase.func_150051_a(world.getBlock(i, j - 1, k))) - return super.dispenseStack(p_82487_1_, p_82487_2_); - - d3 = -1.0D; - } - - EntityMinecart entityminecart = new EntityPoolMinecart(world, d0, d1 + d3, d2); - - if(p_82487_2_.hasDisplayName()) - entityminecart.setMinecartName(p_82487_2_.getDisplayName()); - - world.spawnEntityInWorld(entityminecart); - p_82487_2_.splitStack(1); - return p_82487_2_; - } - - @Override - protected void playDispenseSound(IBlockSource p_82485_1_) { - p_82485_1_.getWorld().playAuxSFX(1000, p_82485_1_.getXInt(), p_82485_1_.getYInt(), p_82485_1_.getZInt(), 0); - } - + @Override + public ItemStack dispenseStack(IBlockSource p_82487_1_, ItemStack p_82487_2_) { + EnumFacing enumfacing = BlockDispenser.func_149937_b(p_82487_1_.getBlockMetadata()); + World world = p_82487_1_.getWorld(); + double d0 = p_82487_1_.getX() + enumfacing.getFrontOffsetX() * 1.125F; + double d1 = p_82487_1_.getY() + enumfacing.getFrontOffsetY() * 1.125F; + double d2 = p_82487_1_.getZ() + enumfacing.getFrontOffsetZ() * 1.125F; + int i = p_82487_1_.getXInt() + enumfacing.getFrontOffsetX(); + int j = p_82487_1_.getYInt() + enumfacing.getFrontOffsetY(); + int k = p_82487_1_.getZInt() + enumfacing.getFrontOffsetZ(); + Block block = world.getBlock(i, j, k); + double d3; + + if (BlockRailBase.func_150051_a(block)) d3 = 0.0D; + else { + if (block.getMaterial() != Material.air || !BlockRailBase.func_150051_a(world.getBlock(i, j - 1, k))) + return super.dispenseStack(p_82487_1_, p_82487_2_); + + d3 = -1.0D; + } + + EntityMinecart entityminecart = new EntityPoolMinecart(world, d0, d1 + d3, d2); + + if (p_82487_2_.hasDisplayName()) entityminecart.setMinecartName(p_82487_2_.getDisplayName()); + + world.spawnEntityInWorld(entityminecart); + p_82487_2_.splitStack(1); + return p_82487_2_; + } + + @Override + protected void playDispenseSound(IBlockSource p_82485_1_) { + p_82485_1_.getWorld().playAuxSFX(1000, p_82485_1_.getXInt(), p_82485_1_.getYInt(), p_82485_1_.getZInt(), 0); + } } diff --git a/src/main/java/vazkii/botania/common/block/dispenser/BehaviourSeeds.java b/src/main/java/vazkii/botania/common/block/dispenser/BehaviourSeeds.java index bd679c72ba..0d11c56d07 100644 --- a/src/main/java/vazkii/botania/common/block/dispenser/BehaviourSeeds.java +++ b/src/main/java/vazkii/botania/common/block/dispenser/BehaviourSeeds.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [May 16, 2014, 10:36:05 PM (GMT)] */ package vazkii.botania.common.block.dispenser; @@ -20,27 +20,26 @@ public class BehaviourSeeds extends BehaviorDefaultDispenseItem { - Block block; + Block block; - public BehaviourSeeds(Block block) { - this.block = block; - } + public BehaviourSeeds(Block block) { + this.block = block; + } - @Override - public ItemStack dispenseStack(IBlockSource par1IBlockSource, ItemStack par2ItemStack) { - EnumFacing facing = BlockDispenser.func_149937_b(par1IBlockSource.getBlockMetadata()); - int x = par1IBlockSource.getXInt() + facing.getFrontOffsetX(); - int y = par1IBlockSource.getYInt() + facing.getFrontOffsetY(); - int z = par1IBlockSource.getZInt() + facing.getFrontOffsetZ(); - World world = par1IBlockSource.getWorld(); + @Override + public ItemStack dispenseStack(IBlockSource par1IBlockSource, ItemStack par2ItemStack) { + EnumFacing facing = BlockDispenser.func_149937_b(par1IBlockSource.getBlockMetadata()); + int x = par1IBlockSource.getXInt() + facing.getFrontOffsetX(); + int y = par1IBlockSource.getYInt() + facing.getFrontOffsetY(); + int z = par1IBlockSource.getZInt() + facing.getFrontOffsetZ(); + World world = par1IBlockSource.getWorld(); - if(world.getBlock(x, y, z).isAir(world, x, y, z) && block.canBlockStay(world, x, y, z)) { - world.setBlock(x, y, z, block); - par2ItemStack.stackSize--; - return par2ItemStack; - } - - return super.dispenseStack(par1IBlockSource, par2ItemStack); - } + if (world.getBlock(x, y, z).isAir(world, x, y, z) && block.canBlockStay(world, x, y, z)) { + world.setBlock(x, y, z, block); + par2ItemStack.stackSize--; + return par2ItemStack; + } + return super.dispenseStack(par1IBlockSource, par2ItemStack); + } } diff --git a/src/main/java/vazkii/botania/common/block/dispenser/BehaviourWand.java b/src/main/java/vazkii/botania/common/block/dispenser/BehaviourWand.java index b50b971f7f..9ab63ab9c4 100644 --- a/src/main/java/vazkii/botania/common/block/dispenser/BehaviourWand.java +++ b/src/main/java/vazkii/botania/common/block/dispenser/BehaviourWand.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [May 16, 2014, 11:11:31 PM (GMT)] */ package vazkii.botania.common.block.dispenser; @@ -21,20 +21,29 @@ public class BehaviourWand extends BehaviorDefaultDispenseItem { - @Override - protected ItemStack dispenseStack(IBlockSource par1IBlockSource, ItemStack par2ItemStack) { - ForgeDirection facing = ForgeDirection.getOrientation(BlockDispenser.func_149937_b(par1IBlockSource.getBlockMetadata()).ordinal()); - int x = par1IBlockSource.getXInt() + facing.offsetX; - int y = par1IBlockSource.getYInt() + facing.offsetY; - int z = par1IBlockSource.getZInt() + facing.offsetZ; - World world = par1IBlockSource.getWorld(); - Block block = world.getBlock(x, y, z); - if(block instanceof IWandable) { - ((IWandable) block).onUsedByWand(null, par2ItemStack, world, x, y, z, facing.getOpposite().ordinal()); - return par2ItemStack; - } - - return super.dispenseStack(par1IBlockSource, par2ItemStack); - } + @Override + protected ItemStack dispenseStack(IBlockSource par1IBlockSource, ItemStack par2ItemStack) { + ForgeDirection facing = + ForgeDirection.getOrientation(BlockDispenser.func_149937_b(par1IBlockSource.getBlockMetadata()) + .ordinal()); + int x = par1IBlockSource.getXInt() + facing.offsetX; + int y = par1IBlockSource.getYInt() + facing.offsetY; + int z = par1IBlockSource.getZInt() + facing.offsetZ; + World world = par1IBlockSource.getWorld(); + Block block = world.getBlock(x, y, z); + if (block instanceof IWandable) { + ((IWandable) block) + .onUsedByWand( + null, + par2ItemStack, + world, + x, + y, + z, + facing.getOpposite().ordinal()); + return par2ItemStack; + } + return super.dispenseStack(par1IBlockSource, par2ItemStack); + } } diff --git a/src/main/java/vazkii/botania/common/block/mana/BlockAlchemyCatalyst.java b/src/main/java/vazkii/botania/common/block/mana/BlockAlchemyCatalyst.java index 0c60b16357..72d7aeb1c1 100644 --- a/src/main/java/vazkii/botania/common/block/mana/BlockAlchemyCatalyst.java +++ b/src/main/java/vazkii/botania/common/block/mana/BlockAlchemyCatalyst.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [May 2, 2014, 7:18:49 PM (GMT)] */ package vazkii.botania.common.block.mana; @@ -27,40 +27,38 @@ public class BlockAlchemyCatalyst extends BlockMod implements ILexiconable, IPoolOverlayProvider { - IIcon[] icons; + IIcon[] icons; - public BlockAlchemyCatalyst() { - this(LibBlockNames.ALCHEMY_CATALYST); - } + public BlockAlchemyCatalyst() { + this(LibBlockNames.ALCHEMY_CATALYST); + } - public BlockAlchemyCatalyst(String name) { - super(Material.rock); - setHardness(2.0F); - setResistance(10.0F); - setStepSound(Block.soundTypeStone); - setBlockName(name); - } + public BlockAlchemyCatalyst(String name) { + super(Material.rock); + setHardness(2.0F); + setResistance(10.0F); + setStepSound(Block.soundTypeStone); + setBlockName(name); + } - @Override - public void registerBlockIcons(IIconRegister par1IconRegister) { - icons = new IIcon[4]; - for(int i = 0; i < icons.length; i++) - icons[i] = IconHelper.forBlock(par1IconRegister, this, i); - } + @Override + public void registerBlockIcons(IIconRegister par1IconRegister) { + icons = new IIcon[4]; + for (int i = 0; i < icons.length; i++) icons[i] = IconHelper.forBlock(par1IconRegister, this, i); + } - @Override - public IIcon getIcon(int par1, int par2) { - return icons[Math.min(2, par1)]; - } + @Override + public IIcon getIcon(int par1, int par2) { + return icons[Math.min(2, par1)]; + } - @Override - public LexiconEntry getEntry(World world, int x, int y, int z, EntityPlayer player, ItemStack lexicon) { - return LexiconData.alchemy; - } - - @Override - public IIcon getIcon(World world, int x, int y, int z) { - return icons[3]; - } + @Override + public LexiconEntry getEntry(World world, int x, int y, int z, EntityPlayer player, ItemStack lexicon) { + return LexiconData.alchemy; + } + @Override + public IIcon getIcon(World world, int x, int y, int z) { + return icons[3]; + } } diff --git a/src/main/java/vazkii/botania/common/block/mana/BlockBellows.java b/src/main/java/vazkii/botania/common/block/mana/BlockBellows.java index 341061899a..dc60a215cd 100644 --- a/src/main/java/vazkii/botania/common/block/mana/BlockBellows.java +++ b/src/main/java/vazkii/botania/common/block/mana/BlockBellows.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Aug 28, 2015, 5:18:13 PM (GMT)] */ package vazkii.botania.common.block.mana; @@ -31,64 +31,69 @@ public class BlockBellows extends BlockModContainer implements ILexiconable { - private static final int[] META_ROTATIONS = new int[] { 3, 4, 2, 5 }; + private static final int[] META_ROTATIONS = new int[] {3, 4, 2, 5}; - public BlockBellows() { - super(Material.wood); - setHardness(2.0F); - setStepSound(soundTypeWood); - setBlockName(LibBlockNames.BELLOWS); + public BlockBellows() { + super(Material.wood); + setHardness(2.0F); + setStepSound(soundTypeWood); + setBlockName(LibBlockNames.BELLOWS); - float f = (1F - 10 / 16F) / 2F; - setBlockBounds(f, 0F, f, 1F - f, 10F / 16F, 1F - f); - } + float f = (1F - 10 / 16F) / 2F; + setBlockBounds(f, 0F, f, 1F - f, 10F / 16F, 1F - f); + } - @Override - public void onBlockPlacedBy(World p_149689_1_, int p_149689_2_, int p_149689_3_, int p_149689_4_, EntityLivingBase p_149689_5_, ItemStack p_149689_6_) { - int l = MathHelper.floor_double(p_149689_5_.rotationYaw * 4.0F / 360.0F + 0.5D) & 3; - p_149689_1_.setBlockMetadataWithNotify(p_149689_2_, p_149689_3_, p_149689_4_, META_ROTATIONS[l], 2); - } + @Override + public void onBlockPlacedBy( + World p_149689_1_, + int p_149689_2_, + int p_149689_3_, + int p_149689_4_, + EntityLivingBase p_149689_5_, + ItemStack p_149689_6_) { + int l = MathHelper.floor_double(p_149689_5_.rotationYaw * 4.0F / 360.0F + 0.5D) & 3; + p_149689_1_.setBlockMetadataWithNotify(p_149689_2_, p_149689_3_, p_149689_4_, META_ROTATIONS[l], 2); + } - @Override - public void registerBlockIcons(IIconRegister par1IconRegister) { - // NO-OP - } + @Override + public void registerBlockIcons(IIconRegister par1IconRegister) { + // NO-OP + } - @Override - public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int s, float xs, float ys, float zs) { - if(EntityDoppleganger.isTruePlayer(player)) - ((TileBellows) world.getTileEntity(x, y, z)).interact(); - return true; - } + @Override + public boolean onBlockActivated( + World world, int x, int y, int z, EntityPlayer player, int s, float xs, float ys, float zs) { + if (EntityDoppleganger.isTruePlayer(player)) ((TileBellows) world.getTileEntity(x, y, z)).interact(); + return true; + } - @Override - public boolean isOpaqueCube() { - return false; - } + @Override + public boolean isOpaqueCube() { + return false; + } - @Override - public boolean renderAsNormalBlock() { - return false; - } + @Override + public boolean renderAsNormalBlock() { + return false; + } - @Override - public IIcon getIcon(int par1, int par2) { - return ModBlocks.livingwood.getIcon(par1, 0); - } + @Override + public IIcon getIcon(int par1, int par2) { + return ModBlocks.livingwood.getIcon(par1, 0); + } - @Override - public int getRenderType() { - return LibRenderIDs.idBellows; - } + @Override + public int getRenderType() { + return LibRenderIDs.idBellows; + } - @Override - public TileEntity createNewTileEntity(World world, int meta) { - return new TileBellows(); - } - - @Override - public LexiconEntry getEntry(World world, int x, int y, int z, EntityPlayer player, ItemStack lexicon) { - return LexiconData.bellows; - } + @Override + public TileEntity createNewTileEntity(World world, int meta) { + return new TileBellows(); + } + @Override + public LexiconEntry getEntry(World world, int x, int y, int z, EntityPlayer player, ItemStack lexicon) { + return LexiconData.bellows; + } } diff --git a/src/main/java/vazkii/botania/common/block/mana/BlockBrewery.java b/src/main/java/vazkii/botania/common/block/mana/BlockBrewery.java index 1c83b153cb..00a496a5b3 100644 --- a/src/main/java/vazkii/botania/common/block/mana/BlockBrewery.java +++ b/src/main/java/vazkii/botania/common/block/mana/BlockBrewery.java @@ -2,16 +2,15 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Oct 31, 2014, 4:37:29 PM (GMT)] */ package vazkii.botania.common.block.mana; import java.util.Random; - import net.minecraft.block.Block; import net.minecraft.block.material.Material; import net.minecraft.client.Minecraft; @@ -37,132 +36,146 @@ public class BlockBrewery extends BlockModContainer implements ILexiconable, IWandHUD { - Random random; - - public BlockBrewery() { - super(Material.rock); - float f = 6F / 16F; - setBlockBounds(f, 0.05F, f, 1F - f, 0.95F, 1F - f); - setBlockName(LibBlockNames.BREWERY); - setHardness(2.0F); - setResistance(10.0F); - setStepSound(soundTypeStone); - - random = new Random(); - } - - @Override - public IIcon getIcon(int side, int meta) { - return Blocks.cobblestone.getIcon(side, meta); - } - - @Override - public boolean onBlockActivated(World par1World, int par2, int par3, int par4, EntityPlayer par5EntityPlayer, int par6, float par7, float par8, float par9) { - TileBrewery brew = (TileBrewery) par1World.getTileEntity(par2, par3, par4); - - if(par5EntityPlayer.isSneaking()) { - if(brew.recipe == null && par1World.getBlockMetadata(par2, par3, par4) == 0) - for(int i = brew.getSizeInventory() - 1; i >= 0; i--) { - ItemStack stackAt = brew.getStackInSlot(i); - if(stackAt != null) { - ItemStack copy = stackAt.copy(); - if(!par5EntityPlayer.inventory.addItemStackToInventory(copy)) - par5EntityPlayer.dropPlayerItemWithRandomChoice(copy, false); - brew.setInventorySlotContents(i, null); - par1World.func_147453_f(par2, par3, par4, this); - break; - } - } - } else { - ItemStack stack = par5EntityPlayer.getCurrentEquippedItem(); - if(stack != null) - return brew.addItem(par5EntityPlayer, stack); - } - return false; - } - - @Override - public void breakBlock(World par1World, int par2, int par3, int par4, Block par5, int par6) { - TileSimpleInventory inv = (TileSimpleInventory) par1World.getTileEntity(par2, par3, par4); - - if (inv != null) { - for (int j1 = 0; j1 < inv.getSizeInventory(); ++j1) { - ItemStack itemstack = inv.getStackInSlot(j1); - - if (itemstack != null) { - float f = random.nextFloat() * 0.8F + 0.1F; - float f1 = random.nextFloat() * 0.8F + 0.1F; - EntityItem entityitem; - - for (float f2 = random.nextFloat() * 0.8F + 0.1F; itemstack.stackSize > 0; par1World.spawnEntityInWorld(entityitem)) { - int k1 = random.nextInt(21) + 10; - - if (k1 > itemstack.stackSize) - k1 = itemstack.stackSize; - - itemstack.stackSize -= k1; - entityitem = new EntityItem(par1World, par2 + f, par3 + f1, par4 + f2, new ItemStack(itemstack.getItem(), k1, itemstack.getItemDamage())); - float f3 = 0.05F; - entityitem.motionX = (float)random.nextGaussian() * f3; - entityitem.motionY = (float)random.nextGaussian() * f3 + 0.2F; - entityitem.motionZ = (float)random.nextGaussian() * f3; - - if (itemstack.hasTagCompound()) - entityitem.getEntityItem().setTagCompound((NBTTagCompound)itemstack.getTagCompound().copy()); - } - } - } - - par1World.func_147453_f(par2, par3, par4, par5); - } - - super.breakBlock(par1World, par2, par3, par4, par5, par6); - } - - @Override - public boolean hasComparatorInputOverride() { - return true; - } - - @Override - public int getComparatorInputOverride(World par1World, int par2, int par3, int par4, int par5) { - TileBrewery brew = (TileBrewery) par1World.getTileEntity(par2, par3, par4); - return brew.signal; - } - - @Override - public void registerBlockIcons(IIconRegister par1IconRegister) { - // NO-OP - } - - @Override - public int getRenderType() { - return LibRenderIDs.idBrewery; - } - - @Override - public boolean isOpaqueCube() { - return false; - } - - @Override - public boolean renderAsNormalBlock() { - return false; - } - - @Override - public TileEntity createNewTileEntity(World world, int meta) { - return new TileBrewery(); - } - - @Override - public LexiconEntry getEntry(World world, int x, int y, int z, EntityPlayer player, ItemStack lexicon) { - return LexiconData.brewery; - } - - @Override - public void renderHUD(Minecraft mc, ScaledResolution res, World world, int x, int y, int z) { - ((TileBrewery) world.getTileEntity(x, y, z)).renderHUD(mc, res); - } - + Random random; + + public BlockBrewery() { + super(Material.rock); + float f = 6F / 16F; + setBlockBounds(f, 0.05F, f, 1F - f, 0.95F, 1F - f); + setBlockName(LibBlockNames.BREWERY); + setHardness(2.0F); + setResistance(10.0F); + setStepSound(soundTypeStone); + + random = new Random(); + } + + @Override + public IIcon getIcon(int side, int meta) { + return Blocks.cobblestone.getIcon(side, meta); + } + + @Override + public boolean onBlockActivated( + World par1World, + int par2, + int par3, + int par4, + EntityPlayer par5EntityPlayer, + int par6, + float par7, + float par8, + float par9) { + TileBrewery brew = (TileBrewery) par1World.getTileEntity(par2, par3, par4); + + if (par5EntityPlayer.isSneaking()) { + if (brew.recipe == null && par1World.getBlockMetadata(par2, par3, par4) == 0) + for (int i = brew.getSizeInventory() - 1; i >= 0; i--) { + ItemStack stackAt = brew.getStackInSlot(i); + if (stackAt != null) { + ItemStack copy = stackAt.copy(); + if (!par5EntityPlayer.inventory.addItemStackToInventory(copy)) + par5EntityPlayer.dropPlayerItemWithRandomChoice(copy, false); + brew.setInventorySlotContents(i, null); + par1World.func_147453_f(par2, par3, par4, this); + break; + } + } + } else { + ItemStack stack = par5EntityPlayer.getCurrentEquippedItem(); + if (stack != null) return brew.addItem(par5EntityPlayer, stack); + } + return false; + } + + @Override + public void breakBlock(World par1World, int par2, int par3, int par4, Block par5, int par6) { + TileSimpleInventory inv = (TileSimpleInventory) par1World.getTileEntity(par2, par3, par4); + + if (inv != null) { + for (int j1 = 0; j1 < inv.getSizeInventory(); ++j1) { + ItemStack itemstack = inv.getStackInSlot(j1); + + if (itemstack != null) { + float f = random.nextFloat() * 0.8F + 0.1F; + float f1 = random.nextFloat() * 0.8F + 0.1F; + EntityItem entityitem; + + for (float f2 = random.nextFloat() * 0.8F + 0.1F; + itemstack.stackSize > 0; + par1World.spawnEntityInWorld(entityitem)) { + int k1 = random.nextInt(21) + 10; + + if (k1 > itemstack.stackSize) k1 = itemstack.stackSize; + + itemstack.stackSize -= k1; + entityitem = new EntityItem( + par1World, + par2 + f, + par3 + f1, + par4 + f2, + new ItemStack(itemstack.getItem(), k1, itemstack.getItemDamage())); + float f3 = 0.05F; + entityitem.motionX = (float) random.nextGaussian() * f3; + entityitem.motionY = (float) random.nextGaussian() * f3 + 0.2F; + entityitem.motionZ = (float) random.nextGaussian() * f3; + + if (itemstack.hasTagCompound()) + entityitem.getEntityItem().setTagCompound((NBTTagCompound) + itemstack.getTagCompound().copy()); + } + } + } + + par1World.func_147453_f(par2, par3, par4, par5); + } + + super.breakBlock(par1World, par2, par3, par4, par5, par6); + } + + @Override + public boolean hasComparatorInputOverride() { + return true; + } + + @Override + public int getComparatorInputOverride(World par1World, int par2, int par3, int par4, int par5) { + TileBrewery brew = (TileBrewery) par1World.getTileEntity(par2, par3, par4); + return brew.signal; + } + + @Override + public void registerBlockIcons(IIconRegister par1IconRegister) { + // NO-OP + } + + @Override + public int getRenderType() { + return LibRenderIDs.idBrewery; + } + + @Override + public boolean isOpaqueCube() { + return false; + } + + @Override + public boolean renderAsNormalBlock() { + return false; + } + + @Override + public TileEntity createNewTileEntity(World world, int meta) { + return new TileBrewery(); + } + + @Override + public LexiconEntry getEntry(World world, int x, int y, int z, EntityPlayer player, ItemStack lexicon) { + return LexiconData.brewery; + } + + @Override + public void renderHUD(Minecraft mc, ScaledResolution res, World world, int x, int y, int z) { + ((TileBrewery) world.getTileEntity(x, y, z)).renderHUD(mc, res); + } } diff --git a/src/main/java/vazkii/botania/common/block/mana/BlockConjurationCatalyst.java b/src/main/java/vazkii/botania/common/block/mana/BlockConjurationCatalyst.java index 818223a53e..91344f2e27 100644 --- a/src/main/java/vazkii/botania/common/block/mana/BlockConjurationCatalyst.java +++ b/src/main/java/vazkii/botania/common/block/mana/BlockConjurationCatalyst.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jun 20, 2014, 1:27:14 AM (GMT)] */ package vazkii.botania.common.block.mana; @@ -19,12 +19,12 @@ public class BlockConjurationCatalyst extends BlockAlchemyCatalyst { - public BlockConjurationCatalyst() { - super(LibBlockNames.CONJURATION_CATALYST); - } + public BlockConjurationCatalyst() { + super(LibBlockNames.CONJURATION_CATALYST); + } - @Override - public LexiconEntry getEntry(World world, int x, int y, int z, EntityPlayer player, ItemStack lexicon) { - return LexiconData.conjurationCatalyst; - } + @Override + public LexiconEntry getEntry(World world, int x, int y, int z, EntityPlayer player, ItemStack lexicon) { + return LexiconData.conjurationCatalyst; + } } diff --git a/src/main/java/vazkii/botania/common/block/mana/BlockDistributor.java b/src/main/java/vazkii/botania/common/block/mana/BlockDistributor.java index f5b8aba150..ac23c02a7c 100644 --- a/src/main/java/vazkii/botania/common/block/mana/BlockDistributor.java +++ b/src/main/java/vazkii/botania/common/block/mana/BlockDistributor.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Mar 3, 2014, 1:44:29 AM (GMT)] */ package vazkii.botania.common.block.mana; @@ -28,35 +28,34 @@ public class BlockDistributor extends BlockModContainer implements ILexiconable { - IIcon iconSide, iconTop; - - public BlockDistributor() { - super(Material.rock); - setHardness(2.0F); - setResistance(10.0F); - setStepSound(soundTypeStone); - setBlockName(LibBlockNames.DISTRIBUTOR); - } - - @Override - public void registerBlockIcons(IIconRegister par1IconRegister) { - iconTop = IconHelper.forBlock(par1IconRegister, this, 0); - iconSide = IconHelper.forBlock(par1IconRegister, this, 1); - } - - @Override - public IIcon getIcon(int par1, int par2) { - return par1 == 0 ? ModBlocks.livingrock.getIcon(0, 0) : par1 == 1 ? iconTop : iconSide; - } - - @Override - public TileEntity createNewTileEntity(World world, int meta) { - return new TileDistributor(); - } - - @Override - public LexiconEntry getEntry(World world, int x, int y, int z, EntityPlayer player, ItemStack lexicon) { - return LexiconData.distributor; - } - + IIcon iconSide, iconTop; + + public BlockDistributor() { + super(Material.rock); + setHardness(2.0F); + setResistance(10.0F); + setStepSound(soundTypeStone); + setBlockName(LibBlockNames.DISTRIBUTOR); + } + + @Override + public void registerBlockIcons(IIconRegister par1IconRegister) { + iconTop = IconHelper.forBlock(par1IconRegister, this, 0); + iconSide = IconHelper.forBlock(par1IconRegister, this, 1); + } + + @Override + public IIcon getIcon(int par1, int par2) { + return par1 == 0 ? ModBlocks.livingrock.getIcon(0, 0) : par1 == 1 ? iconTop : iconSide; + } + + @Override + public TileEntity createNewTileEntity(World world, int meta) { + return new TileDistributor(); + } + + @Override + public LexiconEntry getEntry(World world, int x, int y, int z, EntityPlayer player, ItemStack lexicon) { + return LexiconData.distributor; + } } diff --git a/src/main/java/vazkii/botania/common/block/mana/BlockEnchanter.java b/src/main/java/vazkii/botania/common/block/mana/BlockEnchanter.java index 2318fc4cb5..cf868cbd61 100644 --- a/src/main/java/vazkii/botania/common/block/mana/BlockEnchanter.java +++ b/src/main/java/vazkii/botania/common/block/mana/BlockEnchanter.java @@ -2,16 +2,15 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Mar 15, 2014, 4:08:26 PM (GMT)] */ package vazkii.botania.common.block.mana; import java.util.Random; - import net.minecraft.block.Block; import net.minecraft.block.material.Material; import net.minecraft.client.Minecraft; @@ -41,119 +40,137 @@ public class BlockEnchanter extends BlockModContainer implements IWandable, ILexiconable, IWandHUD { - Random random; - public static IIcon overlay; - - public BlockEnchanter() { - super(Material.rock); - setHardness(3.0F); - setResistance(5.0F); - setLightLevel(1.0F); - setStepSound(soundTypeStone); - setBlockName(LibBlockNames.ENCHANTER); - - random = new Random(); - } - - @Override - public boolean registerInCreative() { - return false; - } - - @Override - public void registerBlockIcons(IIconRegister par1IconRegister) { - super.registerBlockIcons(par1IconRegister); - overlay = IconHelper.forBlock(par1IconRegister, this, "Overlay"); - } - - @Override - public TileEntity createNewTileEntity(World world, int meta) { - return new TileEnchanter(); - } - - @Override - public Item getItemDropped(int p_149650_1_, Random p_149650_2_, int p_149650_3_) { - return Item.getItemFromBlock(Blocks.lapis_block); - } - - @Override - public boolean isOpaqueCube() { - return false; - } - - @Override - public boolean onBlockActivated(World par1World, int par2, int par3, int par4, EntityPlayer par5EntityPlayer, int par6, float par7, float par8, float par9) { - TileEnchanter enchanter = (TileEnchanter) par1World.getTileEntity(par2, par3, par4); - ItemStack stack = par5EntityPlayer.getCurrentEquippedItem(); - if(stack != null && stack.getItem() == ModItems.twigWand) - return false; - - boolean stackEnchantable = stack != null && stack.getItem() != Items.book && stack.isItemEnchantable() && stack.stackSize == 1 && stack.getItem().getItemEnchantability(stack) > 0; - - if(enchanter.itemToEnchant == null) { - if(stackEnchantable) { - enchanter.itemToEnchant = stack.copy(); - par5EntityPlayer.inventory.setInventorySlotContents(par5EntityPlayer.inventory.currentItem, null); - enchanter.sync(); - } - } else if(enchanter.stage == 0) { - if(par5EntityPlayer.inventory.addItemStackToInventory(enchanter.itemToEnchant.copy())) { - enchanter.itemToEnchant = null; - enchanter.sync(); - } else par5EntityPlayer.addChatMessage(new ChatComponentTranslation("botaniamisc.invFull")); - } - - return true; - } - - @Override - public void breakBlock(World par1World, int par2, int par3, int par4, Block par5, int par6) { - TileEnchanter enchanter = (TileEnchanter) par1World.getTileEntity(par2, par3, par4); - - ItemStack itemstack = enchanter.itemToEnchant; - - if (itemstack != null) { - float f = random.nextFloat() * 0.8F + 0.1F; - float f1 = random.nextFloat() * 0.8F + 0.1F; - EntityItem entityitem; - - for (float f2 = random.nextFloat() * 0.8F + 0.1F; itemstack.stackSize > 0; par1World.spawnEntityInWorld(entityitem)) { - int k1 = random.nextInt(21) + 10; - - if (k1 > itemstack.stackSize) - k1 = itemstack.stackSize; - - itemstack.stackSize -= k1; - entityitem = new EntityItem(par1World, par2 + f, par3 + f1, par4 + f2, new ItemStack(itemstack.getItem(), k1, itemstack.getItemDamage())); - float f3 = 0.05F; - entityitem.motionX = (float)random.nextGaussian() * f3 * 0.5; - entityitem.motionY = (float)random.nextGaussian() * f3 + 0.2F; - entityitem.motionZ = (float)random.nextGaussian() * f3 * 0.5; - - if (itemstack.hasTagCompound()) - entityitem.getEntityItem().setTagCompound((NBTTagCompound)itemstack.getTagCompound().copy()); - } - } - - par1World.func_147453_f(par2, par3, par4, par5); - - super.breakBlock(par1World, par2, par3, par4, par5, par6); - } - - @Override - public boolean onUsedByWand(EntityPlayer player, ItemStack stack, World world, int x, int y, int z, int side) { - ((TileEnchanter) world.getTileEntity(x, y, z)).onWanded(player, stack); - return true; - } - - @Override - public LexiconEntry getEntry(World world, int x, int y, int z, EntityPlayer player, ItemStack lexicon) { - return LexiconData.manaEnchanting; - } - - @Override - public void renderHUD(Minecraft mc, ScaledResolution res, World world, int x, int y, int z) { - ((TileEnchanter) world.getTileEntity(x, y, z)).renderHUD(mc, res); - } - + Random random; + public static IIcon overlay; + + public BlockEnchanter() { + super(Material.rock); + setHardness(3.0F); + setResistance(5.0F); + setLightLevel(1.0F); + setStepSound(soundTypeStone); + setBlockName(LibBlockNames.ENCHANTER); + + random = new Random(); + } + + @Override + public boolean registerInCreative() { + return false; + } + + @Override + public void registerBlockIcons(IIconRegister par1IconRegister) { + super.registerBlockIcons(par1IconRegister); + overlay = IconHelper.forBlock(par1IconRegister, this, "Overlay"); + } + + @Override + public TileEntity createNewTileEntity(World world, int meta) { + return new TileEnchanter(); + } + + @Override + public Item getItemDropped(int p_149650_1_, Random p_149650_2_, int p_149650_3_) { + return Item.getItemFromBlock(Blocks.lapis_block); + } + + @Override + public boolean isOpaqueCube() { + return false; + } + + @Override + public boolean onBlockActivated( + World par1World, + int par2, + int par3, + int par4, + EntityPlayer par5EntityPlayer, + int par6, + float par7, + float par8, + float par9) { + TileEnchanter enchanter = (TileEnchanter) par1World.getTileEntity(par2, par3, par4); + ItemStack stack = par5EntityPlayer.getCurrentEquippedItem(); + if (stack != null && stack.getItem() == ModItems.twigWand) return false; + + boolean stackEnchantable = stack != null + && stack.getItem() != Items.book + && stack.isItemEnchantable() + && stack.stackSize == 1 + && stack.getItem().getItemEnchantability(stack) > 0; + + if (enchanter.itemToEnchant == null) { + if (stackEnchantable) { + enchanter.itemToEnchant = stack.copy(); + par5EntityPlayer.inventory.setInventorySlotContents(par5EntityPlayer.inventory.currentItem, null); + enchanter.sync(); + } + } else if (enchanter.stage == 0) { + if (par5EntityPlayer.inventory.addItemStackToInventory(enchanter.itemToEnchant.copy())) { + enchanter.itemToEnchant = null; + enchanter.sync(); + } else par5EntityPlayer.addChatMessage(new ChatComponentTranslation("botaniamisc.invFull")); + } + + return true; + } + + @Override + public void breakBlock(World par1World, int par2, int par3, int par4, Block par5, int par6) { + TileEnchanter enchanter = (TileEnchanter) par1World.getTileEntity(par2, par3, par4); + + ItemStack itemstack = enchanter.itemToEnchant; + + if (itemstack != null) { + float f = random.nextFloat() * 0.8F + 0.1F; + float f1 = random.nextFloat() * 0.8F + 0.1F; + EntityItem entityitem; + + for (float f2 = random.nextFloat() * 0.8F + 0.1F; + itemstack.stackSize > 0; + par1World.spawnEntityInWorld(entityitem)) { + int k1 = random.nextInt(21) + 10; + + if (k1 > itemstack.stackSize) k1 = itemstack.stackSize; + + itemstack.stackSize -= k1; + entityitem = new EntityItem( + par1World, + par2 + f, + par3 + f1, + par4 + f2, + new ItemStack(itemstack.getItem(), k1, itemstack.getItemDamage())); + float f3 = 0.05F; + entityitem.motionX = (float) random.nextGaussian() * f3 * 0.5; + entityitem.motionY = (float) random.nextGaussian() * f3 + 0.2F; + entityitem.motionZ = (float) random.nextGaussian() * f3 * 0.5; + + if (itemstack.hasTagCompound()) + entityitem.getEntityItem().setTagCompound((NBTTagCompound) + itemstack.getTagCompound().copy()); + } + } + + par1World.func_147453_f(par2, par3, par4, par5); + + super.breakBlock(par1World, par2, par3, par4, par5, par6); + } + + @Override + public boolean onUsedByWand(EntityPlayer player, ItemStack stack, World world, int x, int y, int z, int side) { + ((TileEnchanter) world.getTileEntity(x, y, z)).onWanded(player, stack); + return true; + } + + @Override + public LexiconEntry getEntry(World world, int x, int y, int z, EntityPlayer player, ItemStack lexicon) { + return LexiconData.manaEnchanting; + } + + @Override + public void renderHUD(Minecraft mc, ScaledResolution res, World world, int x, int y, int z) { + ((TileEnchanter) world.getTileEntity(x, y, z)).renderHUD(mc, res); + } } diff --git a/src/main/java/vazkii/botania/common/block/mana/BlockForestDrum.java b/src/main/java/vazkii/botania/common/block/mana/BlockForestDrum.java index 3893d556ca..1e24c6c9cf 100644 --- a/src/main/java/vazkii/botania/common/block/mana/BlockForestDrum.java +++ b/src/main/java/vazkii/botania/common/block/mana/BlockForestDrum.java @@ -2,18 +2,18 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [May 16, 2014, 7:34:37 PM (GMT)] */ package vazkii.botania.common.block.mana; +import cpw.mods.fml.common.registry.GameRegistry; import java.util.ArrayList; import java.util.Collections; import java.util.List; - import net.minecraft.block.Block; import net.minecraft.block.material.Material; import net.minecraft.client.renderer.texture.IIconRegister; @@ -39,147 +39,153 @@ import vazkii.botania.common.item.block.ItemBlockWithMetadataAndName; import vazkii.botania.common.lexicon.LexiconData; import vazkii.botania.common.lib.LibBlockNames; -import cpw.mods.fml.common.registry.GameRegistry; public class BlockForestDrum extends BlockMod implements IManaTrigger, ILexiconable { - IIcon iconBases, iconFaces; - IIcon iconBasesA, iconFacesA; - IIcon iconBasesB, iconFacesB; - - public BlockForestDrum() { - super(Material.wood); - float f = 1F / 16F; - setBlockBounds(f * 3, 0F, f * 3, 1F - f * 3, 1F - f * 2, 1F - f * 3); - - setHardness(2.0F); - setStepSound(soundTypeWood); - setBlockName(LibBlockNames.FOREST_DRUM); - } - - @Override - protected boolean shouldRegisterInNameSet() { - return false; - } - - @Override - public Block setBlockName(String par1Str) { - GameRegistry.registerBlock(this, ItemBlockWithMetadataAndName.class, par1Str); - return super.setBlockName(par1Str); - } - - @Override - public boolean renderAsNormalBlock() { - return false; - } - - @Override - public boolean isOpaqueCube() { - return false; - } - - @Override - public int damageDropped(int meta) { - return meta; - } - - @Override - public void registerBlockIcons(IIconRegister par1IconRegister) { - iconBases = IconHelper.forBlock(par1IconRegister, this, 0); - iconFaces = IconHelper.forBlock(par1IconRegister, this, 1); - iconBasesA = IconHelper.forBlock(par1IconRegister, this, 2); - iconFacesA = IconHelper.forBlock(par1IconRegister, this, 3); - iconBasesB = IconHelper.forBlock(par1IconRegister, this, 4); - iconFacesB = IconHelper.forBlock(par1IconRegister, this, 5); - } - - @Override - public void getSubBlocks(Item item, CreativeTabs tab, List list) { - for(int i = 0; i < 3; i++) - list.add(new ItemStack(item, 1, i)); - } - - @Override - public IIcon getIcon(int side, int meta) { - boolean animal = meta == 1; - boolean tree = meta == 2; - return side < 2 ? animal ? iconBasesA : tree ? iconBasesB : iconBases : animal ? iconFacesA : tree ? iconFacesB : iconFaces; - } - - @Override - public void onBurstCollision(IManaBurst burst, World world, int x, int y, int z) { - if(burst.isFake()) - return; - - if(world.getBlockMetadata(x, y, z) == 0) - ItemGrassHorn.breakGrass(world, null, 0, x, y, z); - else if(world.getBlockMetadata(x, y, z) == 2) - ItemGrassHorn.breakGrass(world, null, 1, x, y, z); - else if(!world.isRemote) { - int range = 10; - List entities = world.getEntitiesWithinAABB(EntityLiving.class, AxisAlignedBB.getBoundingBox(x - range, y - range, z - range, x + range + 1, y + range + 1, z + range + 1)); - List shearables = new ArrayList(); - ItemStack stack = new ItemStack(this, 1, 1); - - for(EntityLiving entity : entities) { - if(entity instanceof IShearable && ((IShearable) entity).isShearable(stack, world, (int) entity.posX, (int) entity.posY, (int) entity.posZ)) { - shearables.add(entity); - } else if(entity instanceof EntityCow) { - List items = world.getEntitiesWithinAABB(EntityItem.class, AxisAlignedBB.getBoundingBox(entity.posX, entity.posY, entity.posZ, entity.posX + entity.width, entity.posY + entity.height, entity.posZ + entity.width)); - for(EntityItem item : items) { - ItemStack itemstack = item.getEntityItem(); - if(itemstack != null && itemstack.getItem() == Items.bucket && !world.isRemote) { - while(itemstack.stackSize > 0) { - EntityItem ent = entity.entityDropItem(new ItemStack(Items.milk_bucket), 1.0F); - ent.motionY += world.rand.nextFloat() * 0.05F; - ent.motionX += (world.rand.nextFloat() - world.rand.nextFloat()) * 0.1F; - ent.motionZ += (world.rand.nextFloat() - world.rand.nextFloat()) * 0.1F; - itemstack.stackSize--; - } - item.setDead(); - } - } - } - } - - Collections.shuffle(shearables); - int sheared = 0; - - for(EntityLiving entity : shearables) { - if(sheared > 4) - break; - - List stacks = ((IShearable) entity).onSheared(stack, world, (int) entity.posX, (int) entity.posY, (int) entity.posZ, 0); - if(stacks != null) - for(ItemStack wool : stacks) { - EntityItem ent = entity.entityDropItem(wool, 1.0F); - ent.motionY += world.rand.nextFloat() * 0.05F; - ent.motionX += (world.rand.nextFloat() - world.rand.nextFloat()) * 0.1F; - ent.motionZ += (world.rand.nextFloat() - world.rand.nextFloat()) * 0.1F; - } - ++sheared; - } - } - - if(!world.isRemote) - for(int i = 0; i < 10; i++) - world.playSoundEffect(x, y, z, "note.bd", 1F, 1F); - else world.spawnParticle("note", x + 0.5, y + 1.2, z + 0.5D, 1.0 / 24.0, 0, 0); - - } - - @Override - public LexiconEntry getEntry(World world, int x, int y, int z, EntityPlayer player, ItemStack lexicon) { - int meta = world.getBlockMetadata(x, y, z); - - switch(meta) { - case 1: - return LexiconData.gatherDrum; - case 2: - return LexiconData.canopyDrum; - default: - return LexiconData.forestDrum; - } - } - + IIcon iconBases, iconFaces; + IIcon iconBasesA, iconFacesA; + IIcon iconBasesB, iconFacesB; + + public BlockForestDrum() { + super(Material.wood); + float f = 1F / 16F; + setBlockBounds(f * 3, 0F, f * 3, 1F - f * 3, 1F - f * 2, 1F - f * 3); + + setHardness(2.0F); + setStepSound(soundTypeWood); + setBlockName(LibBlockNames.FOREST_DRUM); + } + + @Override + protected boolean shouldRegisterInNameSet() { + return false; + } + + @Override + public Block setBlockName(String par1Str) { + GameRegistry.registerBlock(this, ItemBlockWithMetadataAndName.class, par1Str); + return super.setBlockName(par1Str); + } + + @Override + public boolean renderAsNormalBlock() { + return false; + } + + @Override + public boolean isOpaqueCube() { + return false; + } + + @Override + public int damageDropped(int meta) { + return meta; + } + + @Override + public void registerBlockIcons(IIconRegister par1IconRegister) { + iconBases = IconHelper.forBlock(par1IconRegister, this, 0); + iconFaces = IconHelper.forBlock(par1IconRegister, this, 1); + iconBasesA = IconHelper.forBlock(par1IconRegister, this, 2); + iconFacesA = IconHelper.forBlock(par1IconRegister, this, 3); + iconBasesB = IconHelper.forBlock(par1IconRegister, this, 4); + iconFacesB = IconHelper.forBlock(par1IconRegister, this, 5); + } + + @Override + public void getSubBlocks(Item item, CreativeTabs tab, List list) { + for (int i = 0; i < 3; i++) list.add(new ItemStack(item, 1, i)); + } + + @Override + public IIcon getIcon(int side, int meta) { + boolean animal = meta == 1; + boolean tree = meta == 2; + return side < 2 + ? animal ? iconBasesA : tree ? iconBasesB : iconBases + : animal ? iconFacesA : tree ? iconFacesB : iconFaces; + } + + @Override + public void onBurstCollision(IManaBurst burst, World world, int x, int y, int z) { + if (burst.isFake()) return; + + if (world.getBlockMetadata(x, y, z) == 0) ItemGrassHorn.breakGrass(world, null, 0, x, y, z); + else if (world.getBlockMetadata(x, y, z) == 2) ItemGrassHorn.breakGrass(world, null, 1, x, y, z); + else if (!world.isRemote) { + int range = 10; + List entities = world.getEntitiesWithinAABB( + EntityLiving.class, + AxisAlignedBB.getBoundingBox( + x - range, y - range, z - range, x + range + 1, y + range + 1, z + range + 1)); + List shearables = new ArrayList(); + ItemStack stack = new ItemStack(this, 1, 1); + + for (EntityLiving entity : entities) { + if (entity instanceof IShearable + && ((IShearable) entity) + .isShearable(stack, world, (int) entity.posX, (int) entity.posY, (int) entity.posZ)) { + shearables.add(entity); + } else if (entity instanceof EntityCow) { + List items = world.getEntitiesWithinAABB( + EntityItem.class, + AxisAlignedBB.getBoundingBox( + entity.posX, + entity.posY, + entity.posZ, + entity.posX + entity.width, + entity.posY + entity.height, + entity.posZ + entity.width)); + for (EntityItem item : items) { + ItemStack itemstack = item.getEntityItem(); + if (itemstack != null && itemstack.getItem() == Items.bucket && !world.isRemote) { + while (itemstack.stackSize > 0) { + EntityItem ent = entity.entityDropItem(new ItemStack(Items.milk_bucket), 1.0F); + ent.motionY += world.rand.nextFloat() * 0.05F; + ent.motionX += (world.rand.nextFloat() - world.rand.nextFloat()) * 0.1F; + ent.motionZ += (world.rand.nextFloat() - world.rand.nextFloat()) * 0.1F; + itemstack.stackSize--; + } + item.setDead(); + } + } + } + } + + Collections.shuffle(shearables); + int sheared = 0; + + for (EntityLiving entity : shearables) { + if (sheared > 4) break; + + List stacks = ((IShearable) entity) + .onSheared(stack, world, (int) entity.posX, (int) entity.posY, (int) entity.posZ, 0); + if (stacks != null) + for (ItemStack wool : stacks) { + EntityItem ent = entity.entityDropItem(wool, 1.0F); + ent.motionY += world.rand.nextFloat() * 0.05F; + ent.motionX += (world.rand.nextFloat() - world.rand.nextFloat()) * 0.1F; + ent.motionZ += (world.rand.nextFloat() - world.rand.nextFloat()) * 0.1F; + } + ++sheared; + } + } + + if (!world.isRemote) for (int i = 0; i < 10; i++) world.playSoundEffect(x, y, z, "note.bd", 1F, 1F); + else world.spawnParticle("note", x + 0.5, y + 1.2, z + 0.5D, 1.0 / 24.0, 0, 0); + } + + @Override + public LexiconEntry getEntry(World world, int x, int y, int z, EntityPlayer player, ItemStack lexicon) { + int meta = world.getBlockMetadata(x, y, z); + + switch (meta) { + case 1: + return LexiconData.gatherDrum; + case 2: + return LexiconData.canopyDrum; + default: + return LexiconData.forestDrum; + } + } } diff --git a/src/main/java/vazkii/botania/common/block/mana/BlockManaDetector.java b/src/main/java/vazkii/botania/common/block/mana/BlockManaDetector.java index 2487ce7b44..b57c7efa84 100644 --- a/src/main/java/vazkii/botania/common/block/mana/BlockManaDetector.java +++ b/src/main/java/vazkii/botania/common/block/mana/BlockManaDetector.java @@ -2,16 +2,15 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Mar 10, 2014, 7:57:38 PM (GMT)] */ package vazkii.botania.common.block.mana; import java.util.List; - import net.minecraft.block.Block; import net.minecraft.block.material.Material; import net.minecraft.client.renderer.texture.IIconRegister; @@ -34,52 +33,57 @@ public class BlockManaDetector extends BlockModContainer implements ILexiconable { - IIcon[] icons; - - public BlockManaDetector() { - super(Material.rock); - setHardness(2.0F); - setResistance(10.0F); - setStepSound(Block.soundTypeStone); - setBlockName(LibBlockNames.MANA_DETECTOR); - } + IIcon[] icons; - @Override - public void registerBlockIcons(IIconRegister par1IconRegister) { - icons = new IIcon[2]; - for(int i = 0; i < icons.length; i++) - icons[i] = IconHelper.forBlock(par1IconRegister, this, i); - } + public BlockManaDetector() { + super(Material.rock); + setHardness(2.0F); + setResistance(10.0F); + setStepSound(Block.soundTypeStone); + setBlockName(LibBlockNames.MANA_DETECTOR); + } - @Override - public IIcon getIcon(int par1, int par2) { - return icons[Math.min(icons.length - 1, par2)]; - } + @Override + public void registerBlockIcons(IIconRegister par1IconRegister) { + icons = new IIcon[2]; + for (int i = 0; i < icons.length; i++) icons[i] = IconHelper.forBlock(par1IconRegister, this, i); + } - @Override - public boolean canProvidePower() { - return true; - } + @Override + public IIcon getIcon(int par1, int par2) { + return icons[Math.min(icons.length - 1, par2)]; + } - @Override - public int isProvidingWeakPower(IBlockAccess par1iBlockAccess, int par2, int par3, int par4, int par5) { - return par1iBlockAccess.getBlockMetadata(par2, par3, par4) != 0 ? 15 : 0; - } + @Override + public boolean canProvidePower() { + return true; + } - @Override - public void addCollisionBoxesToList(World par1World, int par2, int par3, int par4, AxisAlignedBB par5AxisAlignedBB, List par6List, Entity par7Entity) { - if(par7Entity != null && !(par7Entity instanceof IManaBurst)) - super.addCollisionBoxesToList(par1World, par2, par3, par4, par5AxisAlignedBB, par6List, par7Entity); - } + @Override + public int isProvidingWeakPower(IBlockAccess par1iBlockAccess, int par2, int par3, int par4, int par5) { + return par1iBlockAccess.getBlockMetadata(par2, par3, par4) != 0 ? 15 : 0; + } - @Override - public TileEntity createNewTileEntity(World world, int meta) { - return new TileManaDetector(); - } + @Override + public void addCollisionBoxesToList( + World par1World, + int par2, + int par3, + int par4, + AxisAlignedBB par5AxisAlignedBB, + List par6List, + Entity par7Entity) { + if (par7Entity != null && !(par7Entity instanceof IManaBurst)) + super.addCollisionBoxesToList(par1World, par2, par3, par4, par5AxisAlignedBB, par6List, par7Entity); + } - @Override - public LexiconEntry getEntry(World world, int x, int y, int z, EntityPlayer player, ItemStack lexicon) { - return LexiconData.manaDetector; - } + @Override + public TileEntity createNewTileEntity(World world, int meta) { + return new TileManaDetector(); + } + @Override + public LexiconEntry getEntry(World world, int x, int y, int z, EntityPlayer player, ItemStack lexicon) { + return LexiconData.manaDetector; + } } diff --git a/src/main/java/vazkii/botania/common/block/mana/BlockManaVoid.java b/src/main/java/vazkii/botania/common/block/mana/BlockManaVoid.java index 622375863b..6418185706 100644 --- a/src/main/java/vazkii/botania/common/block/mana/BlockManaVoid.java +++ b/src/main/java/vazkii/botania/common/block/mana/BlockManaVoid.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Mar 5, 2014, 12:55:47 AM (GMT)] */ package vazkii.botania.common.block.mana; @@ -29,35 +29,34 @@ public class BlockManaVoid extends BlockModContainer implements ILexiconable, IPoolOverlayProvider { - IIcon overlay; - - public BlockManaVoid() { - super(Material.rock); - setHardness(2.0F); - setResistance(2000F); - setStepSound(Block.soundTypeStone); - setBlockName(LibBlockNames.MANA_VOID); - } - - @Override - public void registerBlockIcons(IIconRegister par1IconRegister) { - blockIcon = IconHelper.forBlock(par1IconRegister, this, 0); - overlay = IconHelper.forBlock(par1IconRegister, this, 1); - } - - @Override - public TileEntity createNewTileEntity(World world, int id) { - return new TileManaVoid(); - } - - @Override - public LexiconEntry getEntry(World world, int x, int y, int z, EntityPlayer player, ItemStack lexicon) { - return LexiconData.manaVoid; - } - - @Override - public IIcon getIcon(World world, int x, int y, int z) { - return overlay; - } - + IIcon overlay; + + public BlockManaVoid() { + super(Material.rock); + setHardness(2.0F); + setResistance(2000F); + setStepSound(Block.soundTypeStone); + setBlockName(LibBlockNames.MANA_VOID); + } + + @Override + public void registerBlockIcons(IIconRegister par1IconRegister) { + blockIcon = IconHelper.forBlock(par1IconRegister, this, 0); + overlay = IconHelper.forBlock(par1IconRegister, this, 1); + } + + @Override + public TileEntity createNewTileEntity(World world, int id) { + return new TileManaVoid(); + } + + @Override + public LexiconEntry getEntry(World world, int x, int y, int z, EntityPlayer player, ItemStack lexicon) { + return LexiconData.manaVoid; + } + + @Override + public IIcon getIcon(World world, int x, int y, int z) { + return overlay; + } } diff --git a/src/main/java/vazkii/botania/common/block/mana/BlockPool.java b/src/main/java/vazkii/botania/common/block/mana/BlockPool.java index ec1075a37d..4d4a763a21 100644 --- a/src/main/java/vazkii/botania/common/block/mana/BlockPool.java +++ b/src/main/java/vazkii/botania/common/block/mana/BlockPool.java @@ -2,17 +2,17 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jan 26, 2014, 12:22:58 AM (GMT)] */ package vazkii.botania.common.block.mana; +import cpw.mods.fml.common.registry.GameRegistry; import java.util.ArrayList; import java.util.List; - import net.minecraft.block.Block; import net.minecraft.block.material.Material; import net.minecraft.client.Minecraft; @@ -41,7 +41,6 @@ import vazkii.botania.client.core.helper.IconHelper; import vazkii.botania.client.lib.LibRenderIDs; import vazkii.botania.common.achievement.ICraftAchievement; -import vazkii.botania.common.achievement.IPickupAchievement; import vazkii.botania.common.achievement.ModAchievements; import vazkii.botania.common.block.BlockModContainer; import vazkii.botania.common.block.ModBlocks; @@ -49,159 +48,168 @@ import vazkii.botania.common.item.block.ItemBlockPool; import vazkii.botania.common.lexicon.LexiconData; import vazkii.botania.common.lib.LibBlockNames; -import cpw.mods.fml.common.registry.GameRegistry; public class BlockPool extends BlockModContainer implements IWandHUD, IWandable, ILexiconable, ICraftAchievement { - boolean lastFragile = false; - - public static IIcon manaIcon; - - public BlockPool() { - super(Material.rock); - setHardness(2.0F); - setResistance(10.0F); - setStepSound(soundTypeStone); - setBlockName(LibBlockNames.POOL); - setBlockBounds(0F, 0F, 0F, 1F, 0.5F, 1F); - - BotaniaAPI.blacklistBlockFromMagnet(this, Short.MAX_VALUE); - } - - @Override - protected boolean shouldRegisterInNameSet() { - return false; - } - - @Override - public Block setBlockName(String par1Str) { - GameRegistry.registerBlock(this, ItemBlockPool.class, par1Str); - return super.setBlockName(par1Str); - } - - @Override - public void registerBlockIcons(IIconRegister par1IconRegister) { - manaIcon = IconHelper.forName(par1IconRegister, "manaWater"); - } - - @Override - public int damageDropped(int meta) { - return meta; - } - - @Override - public void breakBlock(World par1World, int par2, int par3, int par4, Block par5, int par6) { - TilePool pool = (TilePool) par1World.getTileEntity(par2, par3, par4); - lastFragile = pool.fragile; - super.breakBlock(par1World, par2, par3, par4, par5, par6); - } - - @Override - public ArrayList getDrops(World world, int x, int y, int z, int metadata, int fortune) { - ArrayList drops = new ArrayList(); - - if(!lastFragile) - drops.add(new ItemStack(this, 1, metadata)); - - return drops; - } - - @Override - public void getSubBlocks(Item par1, CreativeTabs par2, List par3) { - par3.add(new ItemStack(par1, 1, 0)); - par3.add(new ItemStack(par1, 1, 2)); - par3.add(new ItemStack(par1, 1, 3)); - par3.add(new ItemStack(par1, 1, 1)); - } - - @Override - public TileEntity createNewTileEntity(World world, int meta) { - return new TilePool(); - } - - @Override - public void onEntityCollidedWithBlock(World par1World, int par2, int par3, int par4, Entity par5Entity) { - if(par5Entity instanceof EntityItem) { - TilePool tile = (TilePool) par1World.getTileEntity(par2, par3, par4); - if(tile.collideEntityItem((EntityItem) par5Entity)) - VanillaPacketDispatcher.dispatchTEToNearbyPlayers(par1World, par2, par3, par4); - } - } - - @Override - public void addCollisionBoxesToList(World p_149743_1_, int p_149743_2_, int p_149743_3_, int p_149743_4_, AxisAlignedBB p_149743_5_, List p_149743_6_, Entity p_149743_7_) { - float f = 1F / 16F; - setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, f, 1.0F); - super.addCollisionBoxesToList(p_149743_1_, p_149743_2_, p_149743_3_, p_149743_4_, p_149743_5_, p_149743_6_, p_149743_7_); - setBlockBounds(0.0F, 0.0F, 0.0F, f, 0.5F, 1.0F); - super.addCollisionBoxesToList(p_149743_1_, p_149743_2_, p_149743_3_, p_149743_4_, p_149743_5_, p_149743_6_, p_149743_7_); - setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 0.5F, f); - super.addCollisionBoxesToList(p_149743_1_, p_149743_2_, p_149743_3_, p_149743_4_, p_149743_5_, p_149743_6_, p_149743_7_); - setBlockBounds(1.0F - f, 0.0F, 0.0F, 1.0F, 0.5F, 1.0F); - super.addCollisionBoxesToList(p_149743_1_, p_149743_2_, p_149743_3_, p_149743_4_, p_149743_5_, p_149743_6_, p_149743_7_); - setBlockBounds(0.0F, 0.0F, 1.0F - f, 1.0F, 0.5F, 1.0F); - super.addCollisionBoxesToList(p_149743_1_, p_149743_2_, p_149743_3_, p_149743_4_, p_149743_5_, p_149743_6_, p_149743_7_); - setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 0.5F, 1.0F); - } - - @Override - public boolean isSideSolid(IBlockAccess world, int x, int y, int z, ForgeDirection side) { - return side == ForgeDirection.DOWN; - } - - @Override - public boolean isOpaqueCube() { - return false; - } - - @Override - public boolean renderAsNormalBlock() { - return false; - } - - @Override - public IIcon getIcon(int par1, int par2) { - return ModBlocks.livingrock.getIcon(par1, 0); - } - - @Override - public int getRenderType() { - return LibRenderIDs.idPool; - } - - @Override - public boolean hasComparatorInputOverride() { - return true; - } - - @Override - public int getComparatorInputOverride(World par1World, int par2, int par3, int par4, int par5) { - TilePool pool = (TilePool) par1World.getTileEntity(par2, par3, par4); - int val = (int) ((double) pool.getCurrentMana() / (double) pool.manaCap * 15.0); - if(pool.getCurrentMana() > 0) - val = Math.max(val, 1); - - return val; - } - - @Override - public void renderHUD(Minecraft mc, ScaledResolution res, World world, int x, int y, int z) { - ((TilePool) world.getTileEntity(x, y, z)).renderHUD(mc, res); - } - - @Override - public boolean onUsedByWand(EntityPlayer player, ItemStack stack, World world, int x, int y, int z, int side) { - ((TilePool) world.getTileEntity(x, y, z)).onWanded(player, stack); - return true; - } - - @Override - public LexiconEntry getEntry(World world, int x, int y, int z, EntityPlayer player, ItemStack lexicon) { - return world.getBlockMetadata(x, y, z) == 3 ? LexiconData.rainbowRod : LexiconData.pool; - } - - @Override - public Achievement getAchievementOnCraft(ItemStack stack, EntityPlayer player, IInventory matrix) { - return ModAchievements.manaPoolPickup; - } + boolean lastFragile = false; + + public static IIcon manaIcon; + + public BlockPool() { + super(Material.rock); + setHardness(2.0F); + setResistance(10.0F); + setStepSound(soundTypeStone); + setBlockName(LibBlockNames.POOL); + setBlockBounds(0F, 0F, 0F, 1F, 0.5F, 1F); + + BotaniaAPI.blacklistBlockFromMagnet(this, Short.MAX_VALUE); + } + + @Override + protected boolean shouldRegisterInNameSet() { + return false; + } + + @Override + public Block setBlockName(String par1Str) { + GameRegistry.registerBlock(this, ItemBlockPool.class, par1Str); + return super.setBlockName(par1Str); + } + + @Override + public void registerBlockIcons(IIconRegister par1IconRegister) { + manaIcon = IconHelper.forName(par1IconRegister, "manaWater"); + } + + @Override + public int damageDropped(int meta) { + return meta; + } + + @Override + public void breakBlock(World par1World, int par2, int par3, int par4, Block par5, int par6) { + TilePool pool = (TilePool) par1World.getTileEntity(par2, par3, par4); + lastFragile = pool.fragile; + super.breakBlock(par1World, par2, par3, par4, par5, par6); + } + + @Override + public ArrayList getDrops(World world, int x, int y, int z, int metadata, int fortune) { + ArrayList drops = new ArrayList(); + + if (!lastFragile) drops.add(new ItemStack(this, 1, metadata)); + + return drops; + } + + @Override + public void getSubBlocks(Item par1, CreativeTabs par2, List par3) { + par3.add(new ItemStack(par1, 1, 0)); + par3.add(new ItemStack(par1, 1, 2)); + par3.add(new ItemStack(par1, 1, 3)); + par3.add(new ItemStack(par1, 1, 1)); + } + + @Override + public TileEntity createNewTileEntity(World world, int meta) { + return new TilePool(); + } + + @Override + public void onEntityCollidedWithBlock(World par1World, int par2, int par3, int par4, Entity par5Entity) { + if (par5Entity instanceof EntityItem) { + TilePool tile = (TilePool) par1World.getTileEntity(par2, par3, par4); + if (tile.collideEntityItem((EntityItem) par5Entity)) + VanillaPacketDispatcher.dispatchTEToNearbyPlayers(par1World, par2, par3, par4); + } + } + + @Override + public void addCollisionBoxesToList( + World p_149743_1_, + int p_149743_2_, + int p_149743_3_, + int p_149743_4_, + AxisAlignedBB p_149743_5_, + List p_149743_6_, + Entity p_149743_7_) { + float f = 1F / 16F; + setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, f, 1.0F); + super.addCollisionBoxesToList( + p_149743_1_, p_149743_2_, p_149743_3_, p_149743_4_, p_149743_5_, p_149743_6_, p_149743_7_); + setBlockBounds(0.0F, 0.0F, 0.0F, f, 0.5F, 1.0F); + super.addCollisionBoxesToList( + p_149743_1_, p_149743_2_, p_149743_3_, p_149743_4_, p_149743_5_, p_149743_6_, p_149743_7_); + setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 0.5F, f); + super.addCollisionBoxesToList( + p_149743_1_, p_149743_2_, p_149743_3_, p_149743_4_, p_149743_5_, p_149743_6_, p_149743_7_); + setBlockBounds(1.0F - f, 0.0F, 0.0F, 1.0F, 0.5F, 1.0F); + super.addCollisionBoxesToList( + p_149743_1_, p_149743_2_, p_149743_3_, p_149743_4_, p_149743_5_, p_149743_6_, p_149743_7_); + setBlockBounds(0.0F, 0.0F, 1.0F - f, 1.0F, 0.5F, 1.0F); + super.addCollisionBoxesToList( + p_149743_1_, p_149743_2_, p_149743_3_, p_149743_4_, p_149743_5_, p_149743_6_, p_149743_7_); + setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 0.5F, 1.0F); + } + + @Override + public boolean isSideSolid(IBlockAccess world, int x, int y, int z, ForgeDirection side) { + return side == ForgeDirection.DOWN; + } + + @Override + public boolean isOpaqueCube() { + return false; + } + + @Override + public boolean renderAsNormalBlock() { + return false; + } + + @Override + public IIcon getIcon(int par1, int par2) { + return ModBlocks.livingrock.getIcon(par1, 0); + } + + @Override + public int getRenderType() { + return LibRenderIDs.idPool; + } + + @Override + public boolean hasComparatorInputOverride() { + return true; + } + + @Override + public int getComparatorInputOverride(World par1World, int par2, int par3, int par4, int par5) { + TilePool pool = (TilePool) par1World.getTileEntity(par2, par3, par4); + int val = (int) ((double) pool.getCurrentMana() / (double) pool.manaCap * 15.0); + if (pool.getCurrentMana() > 0) val = Math.max(val, 1); + + return val; + } + + @Override + public void renderHUD(Minecraft mc, ScaledResolution res, World world, int x, int y, int z) { + ((TilePool) world.getTileEntity(x, y, z)).renderHUD(mc, res); + } + + @Override + public boolean onUsedByWand(EntityPlayer player, ItemStack stack, World world, int x, int y, int z, int side) { + ((TilePool) world.getTileEntity(x, y, z)).onWanded(player, stack); + return true; + } + + @Override + public LexiconEntry getEntry(World world, int x, int y, int z, EntityPlayer player, ItemStack lexicon) { + return world.getBlockMetadata(x, y, z) == 3 ? LexiconData.rainbowRod : LexiconData.pool; + } + + @Override + public Achievement getAchievementOnCraft(ItemStack stack, EntityPlayer player, IInventory matrix) { + return ModAchievements.manaPoolPickup; + } } diff --git a/src/main/java/vazkii/botania/common/block/mana/BlockPrism.java b/src/main/java/vazkii/botania/common/block/mana/BlockPrism.java index 0748d93219..9058f1df99 100644 --- a/src/main/java/vazkii/botania/common/block/mana/BlockPrism.java +++ b/src/main/java/vazkii/botania/common/block/mana/BlockPrism.java @@ -2,16 +2,15 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jan 17, 2015, 7:16:48 PM (GMT)] */ package vazkii.botania.common.block.mana; import java.util.Random; - import net.minecraft.block.Block; import net.minecraft.block.material.Material; import net.minecraft.client.renderer.texture.IIconRegister; @@ -37,155 +36,166 @@ public class BlockPrism extends BlockModContainer implements IManaTrigger, ILexiconable { - Random random; - IIcon[] icons; - - public BlockPrism() { - super(Material.glass); - setHardness(0.3F); - setStepSound(soundTypeGlass); - setLightLevel(1.0F); - setBlockName(LibBlockNames.PRISM); - float f = 0.25F; - setBlockBounds(f, 0F, f, 1F - f, 1F, 1F - f); - - random = new Random(); - } - - @Override - public void registerBlockIcons(IIconRegister par1IconRegister) { - icons = new IIcon[2]; - for(int i = 0; i < icons.length; i++) - icons[i] = IconHelper.forBlock(par1IconRegister, this, i); - } - - @Override - public IIcon getIcon(int side, int meta) { - return side > 1 ? icons[1] : icons[0]; - } - - @Override - public int getRenderBlockPass() { - return 1; - } - - @Override - public AxisAlignedBB getCollisionBoundingBoxFromPool(World p_149668_1_, int p_149668_2_, int p_149668_3_, int p_149668_4_) { - return null; - } - - @Override - public boolean isOpaqueCube() { - return false; - } - - @Override - public boolean renderAsNormalBlock() { - return false; - } - - @Override - public boolean onBlockActivated(World par1World, int par2, int par3, int par4, EntityPlayer par5EntityPlayer, int par6, float par7, float par8, float par9) { - TileEntity tile = par1World.getTileEntity(par2, par3, par4); - if(!(tile instanceof TilePrism)) - return false; - - TilePrism prism = (TilePrism) tile; - ItemStack lens = prism.getStackInSlot(0); - ItemStack heldItem = par5EntityPlayer.getCurrentEquippedItem(); - boolean isHeldItemLens = heldItem != null && heldItem.getItem() instanceof ILens; - int meta = par1World.getBlockMetadata(par2, par3, par4); - - if(lens == null && isHeldItemLens) { - if(!par5EntityPlayer.capabilities.isCreativeMode) - par5EntityPlayer.inventory.setInventorySlotContents(par5EntityPlayer.inventory.currentItem, null); - - prism.setInventorySlotContents(0, heldItem.copy()); - prism.markDirty(); - par1World.setBlockMetadataWithNotify(par2, par3, par4, meta | 1, 1 | 2); - } else if(lens != null) { - ItemStack add = lens.copy(); - if(!par5EntityPlayer.inventory.addItemStackToInventory(add)) - par5EntityPlayer.dropPlayerItemWithRandomChoice(add, false); - prism.setInventorySlotContents(0, null); - prism.markDirty(); - par1World.setBlockMetadataWithNotify(par2, par3, par4, meta & 14, 1 | 2); - } - - return true; - } - - @Override - public void onNeighborBlockChange(World world, int x, int y, int z, Block block) { - boolean power = world.isBlockIndirectlyGettingPowered(x, y, z) || world.isBlockIndirectlyGettingPowered(x, y + 1, z); - int meta = world.getBlockMetadata(x, y, z); - boolean powered = (meta & 8) != 0; - - if(!world.isRemote) { - if(power && !powered) - world.setBlockMetadataWithNotify(x, y, z, meta | 8, 1 | 2); - else if(!power && powered) - world.setBlockMetadataWithNotify(x, y, z, meta & -9, 1 | 2); - } - } - - @Override - public void breakBlock(World par1World, int par2, int par3, int par4, Block par5, int par6) { - TileEntity tile = par1World.getTileEntity(par2, par3, par4); - if(!(tile instanceof TileSimpleInventory)) - return; - - TileSimpleInventory inv = (TileSimpleInventory) tile; - - if (inv != null) { - for (int j1 = 0; j1 < inv.getSizeInventory(); ++j1) { - ItemStack itemstack = inv.getStackInSlot(j1); - - if (itemstack != null) { - float f = random.nextFloat() * 0.8F + 0.1F; - float f1 = random.nextFloat() * 0.8F + 0.1F; - EntityItem entityitem; - - for (float f2 = random.nextFloat() * 0.8F + 0.1F; itemstack.stackSize > 0; par1World.spawnEntityInWorld(entityitem)) { - int k1 = random.nextInt(21) + 10; - - if (k1 > itemstack.stackSize) - k1 = itemstack.stackSize; - - itemstack.stackSize -= k1; - entityitem = new EntityItem(par1World, par2 + f, par3 + f1, par4 + f2, new ItemStack(itemstack.getItem(), k1, itemstack.getItemDamage())); - float f3 = 0.05F; - entityitem.motionX = (float)random.nextGaussian() * f3; - entityitem.motionY = (float)random.nextGaussian() * f3 + 0.2F; - entityitem.motionZ = (float)random.nextGaussian() * f3; - - if (itemstack.hasTagCompound()) - entityitem.getEntityItem().setTagCompound((NBTTagCompound)itemstack.getTagCompound().copy()); - } - } - } - - par1World.func_147453_f(par2, par3, par4, par5); - } - - super.breakBlock(par1World, par2, par3, par4, par5, par6); - } - - @Override - public TileEntity createNewTileEntity(World world, int meta) { - return new TilePrism(); - } - - @Override - public void onBurstCollision(IManaBurst burst, World world, int x, int y, int z) { - TileEntity tile = world.getTileEntity(x, y, z); - if(tile != null && tile instanceof TilePrism) - ((TilePrism) tile).onBurstCollision(burst); - } - - @Override - public LexiconEntry getEntry(World world, int x, int y, int z, EntityPlayer player, ItemStack lexicon) { - return LexiconData.prism; - } - + Random random; + IIcon[] icons; + + public BlockPrism() { + super(Material.glass); + setHardness(0.3F); + setStepSound(soundTypeGlass); + setLightLevel(1.0F); + setBlockName(LibBlockNames.PRISM); + float f = 0.25F; + setBlockBounds(f, 0F, f, 1F - f, 1F, 1F - f); + + random = new Random(); + } + + @Override + public void registerBlockIcons(IIconRegister par1IconRegister) { + icons = new IIcon[2]; + for (int i = 0; i < icons.length; i++) icons[i] = IconHelper.forBlock(par1IconRegister, this, i); + } + + @Override + public IIcon getIcon(int side, int meta) { + return side > 1 ? icons[1] : icons[0]; + } + + @Override + public int getRenderBlockPass() { + return 1; + } + + @Override + public AxisAlignedBB getCollisionBoundingBoxFromPool( + World p_149668_1_, int p_149668_2_, int p_149668_3_, int p_149668_4_) { + return null; + } + + @Override + public boolean isOpaqueCube() { + return false; + } + + @Override + public boolean renderAsNormalBlock() { + return false; + } + + @Override + public boolean onBlockActivated( + World par1World, + int par2, + int par3, + int par4, + EntityPlayer par5EntityPlayer, + int par6, + float par7, + float par8, + float par9) { + TileEntity tile = par1World.getTileEntity(par2, par3, par4); + if (!(tile instanceof TilePrism)) return false; + + TilePrism prism = (TilePrism) tile; + ItemStack lens = prism.getStackInSlot(0); + ItemStack heldItem = par5EntityPlayer.getCurrentEquippedItem(); + boolean isHeldItemLens = heldItem != null && heldItem.getItem() instanceof ILens; + int meta = par1World.getBlockMetadata(par2, par3, par4); + + if (lens == null && isHeldItemLens) { + if (!par5EntityPlayer.capabilities.isCreativeMode) + par5EntityPlayer.inventory.setInventorySlotContents(par5EntityPlayer.inventory.currentItem, null); + + prism.setInventorySlotContents(0, heldItem.copy()); + prism.markDirty(); + par1World.setBlockMetadataWithNotify(par2, par3, par4, meta | 1, 1 | 2); + } else if (lens != null) { + ItemStack add = lens.copy(); + if (!par5EntityPlayer.inventory.addItemStackToInventory(add)) + par5EntityPlayer.dropPlayerItemWithRandomChoice(add, false); + prism.setInventorySlotContents(0, null); + prism.markDirty(); + par1World.setBlockMetadataWithNotify(par2, par3, par4, meta & 14, 1 | 2); + } + + return true; + } + + @Override + public void onNeighborBlockChange(World world, int x, int y, int z, Block block) { + boolean power = + world.isBlockIndirectlyGettingPowered(x, y, z) || world.isBlockIndirectlyGettingPowered(x, y + 1, z); + int meta = world.getBlockMetadata(x, y, z); + boolean powered = (meta & 8) != 0; + + if (!world.isRemote) { + if (power && !powered) world.setBlockMetadataWithNotify(x, y, z, meta | 8, 1 | 2); + else if (!power && powered) world.setBlockMetadataWithNotify(x, y, z, meta & -9, 1 | 2); + } + } + + @Override + public void breakBlock(World par1World, int par2, int par3, int par4, Block par5, int par6) { + TileEntity tile = par1World.getTileEntity(par2, par3, par4); + if (!(tile instanceof TileSimpleInventory)) return; + + TileSimpleInventory inv = (TileSimpleInventory) tile; + + if (inv != null) { + for (int j1 = 0; j1 < inv.getSizeInventory(); ++j1) { + ItemStack itemstack = inv.getStackInSlot(j1); + + if (itemstack != null) { + float f = random.nextFloat() * 0.8F + 0.1F; + float f1 = random.nextFloat() * 0.8F + 0.1F; + EntityItem entityitem; + + for (float f2 = random.nextFloat() * 0.8F + 0.1F; + itemstack.stackSize > 0; + par1World.spawnEntityInWorld(entityitem)) { + int k1 = random.nextInt(21) + 10; + + if (k1 > itemstack.stackSize) k1 = itemstack.stackSize; + + itemstack.stackSize -= k1; + entityitem = new EntityItem( + par1World, + par2 + f, + par3 + f1, + par4 + f2, + new ItemStack(itemstack.getItem(), k1, itemstack.getItemDamage())); + float f3 = 0.05F; + entityitem.motionX = (float) random.nextGaussian() * f3; + entityitem.motionY = (float) random.nextGaussian() * f3 + 0.2F; + entityitem.motionZ = (float) random.nextGaussian() * f3; + + if (itemstack.hasTagCompound()) + entityitem.getEntityItem().setTagCompound((NBTTagCompound) + itemstack.getTagCompound().copy()); + } + } + } + + par1World.func_147453_f(par2, par3, par4, par5); + } + + super.breakBlock(par1World, par2, par3, par4, par5, par6); + } + + @Override + public TileEntity createNewTileEntity(World world, int meta) { + return new TilePrism(); + } + + @Override + public void onBurstCollision(IManaBurst burst, World world, int x, int y, int z) { + TileEntity tile = world.getTileEntity(x, y, z); + if (tile != null && tile instanceof TilePrism) ((TilePrism) tile).onBurstCollision(burst); + } + + @Override + public LexiconEntry getEntry(World world, int x, int y, int z, EntityPlayer player, ItemStack lexicon) { + return LexiconData.prism; + } } diff --git a/src/main/java/vazkii/botania/common/block/mana/BlockPump.java b/src/main/java/vazkii/botania/common/block/mana/BlockPump.java index aa4a4c6e6a..bd0243e013 100644 --- a/src/main/java/vazkii/botania/common/block/mana/BlockPump.java +++ b/src/main/java/vazkii/botania/common/block/mana/BlockPump.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Mar 17, 2015, 9:46:53 PM (GMT)] */ package vazkii.botania.common.block.mana; @@ -34,81 +34,86 @@ public class BlockPump extends BlockModContainer implements ILexiconable { - private static final int[] META_ROTATIONS = new int[] { 2, 5, 3, 4 }; - - public BlockPump() { - super(Material.rock); - setHardness(2.0F); - setResistance(10.0F); - setStepSound(soundTypeStone); - setBlockName(LibBlockNames.PUMP); - setBlockBounds(true); - } - - @Override - public void onBlockPlacedBy(World p_149689_1_, int p_149689_2_, int p_149689_3_, int p_149689_4_, EntityLivingBase p_149689_5_, ItemStack p_149689_6_) { - int l = MathHelper.floor_double(p_149689_5_.rotationYaw * 4.0F / 360.0F + 0.5D) & 3; - p_149689_1_.setBlockMetadataWithNotify(p_149689_2_, p_149689_3_, p_149689_4_, META_ROTATIONS[l], 2); - } - - @Override - public void setBlockBoundsBasedOnState(IBlockAccess w, int x, int y, int z) { - setBlockBounds(w.getBlockMetadata(x, y, z) < 4); - } - - public void setBlockBounds(boolean horiz) { - if(horiz) - setBlockBounds(0.25F, 0F, 0F, 0.75F, 0.5F, 1F); - else setBlockBounds(0F, 0F, 0.25F, 1F, 0.5F, 0.75F); - } - - @Override - public boolean rotateBlock(World worldObj, int x, int y, int z, ForgeDirection axis) { - return RotationHelper.rotateVanillaBlock(Blocks.furnace, worldObj, x, y, z, axis); - } - - @Override - public void registerBlockIcons(IIconRegister par1IconRegister) { - // NO-OP - } - - @Override - public IIcon getIcon(int par1, int par2) { - return ModBlocks.livingrock.getIcon(0, 0); - } - - @Override - public int getRenderType() { - return LibRenderIDs.idPump; - } - - @Override - public boolean isOpaqueCube() { - return false; - } - - @Override - public boolean renderAsNormalBlock() { - return false; - } - - @Override - public boolean hasComparatorInputOverride() { - return true; - } - - @Override - public int getComparatorInputOverride(World world, int x, int y, int z, int side) { - return ((TilePump) world.getTileEntity(x, y, z)).comparator; - } - - @Override - public LexiconEntry getEntry(World world, int x, int y, int z, EntityPlayer player, ItemStack lexicon) { - return LexiconData.poolCart; - } - - @Override - public TileEntity createNewTileEntity(World world, int meta) { - return new TilePump(); - } + private static final int[] META_ROTATIONS = new int[] {2, 5, 3, 4}; + + public BlockPump() { + super(Material.rock); + setHardness(2.0F); + setResistance(10.0F); + setStepSound(soundTypeStone); + setBlockName(LibBlockNames.PUMP); + setBlockBounds(true); + } + + @Override + public void onBlockPlacedBy( + World p_149689_1_, + int p_149689_2_, + int p_149689_3_, + int p_149689_4_, + EntityLivingBase p_149689_5_, + ItemStack p_149689_6_) { + int l = MathHelper.floor_double(p_149689_5_.rotationYaw * 4.0F / 360.0F + 0.5D) & 3; + p_149689_1_.setBlockMetadataWithNotify(p_149689_2_, p_149689_3_, p_149689_4_, META_ROTATIONS[l], 2); + } + + @Override + public void setBlockBoundsBasedOnState(IBlockAccess w, int x, int y, int z) { + setBlockBounds(w.getBlockMetadata(x, y, z) < 4); + } + + public void setBlockBounds(boolean horiz) { + if (horiz) setBlockBounds(0.25F, 0F, 0F, 0.75F, 0.5F, 1F); + else setBlockBounds(0F, 0F, 0.25F, 1F, 0.5F, 0.75F); + } + + @Override + public boolean rotateBlock(World worldObj, int x, int y, int z, ForgeDirection axis) { + return RotationHelper.rotateVanillaBlock(Blocks.furnace, worldObj, x, y, z, axis); + } + + @Override + public void registerBlockIcons(IIconRegister par1IconRegister) { + // NO-OP + } + + @Override + public IIcon getIcon(int par1, int par2) { + return ModBlocks.livingrock.getIcon(0, 0); + } + + @Override + public int getRenderType() { + return LibRenderIDs.idPump; + } + + @Override + public boolean isOpaqueCube() { + return false; + } + + @Override + public boolean renderAsNormalBlock() { + return false; + } + + @Override + public boolean hasComparatorInputOverride() { + return true; + } + + @Override + public int getComparatorInputOverride(World world, int x, int y, int z, int side) { + return ((TilePump) world.getTileEntity(x, y, z)).comparator; + } + + @Override + public LexiconEntry getEntry(World world, int x, int y, int z, EntityPlayer player, ItemStack lexicon) { + return LexiconData.poolCart; + } + + @Override + public TileEntity createNewTileEntity(World world, int meta) { + return new TilePump(); + } } diff --git a/src/main/java/vazkii/botania/common/block/mana/BlockRFGenerator.java b/src/main/java/vazkii/botania/common/block/mana/BlockRFGenerator.java index 79e7e35dbd..3fc94698ab 100644 --- a/src/main/java/vazkii/botania/common/block/mana/BlockRFGenerator.java +++ b/src/main/java/vazkii/botania/common/block/mana/BlockRFGenerator.java @@ -2,14 +2,15 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Aug 29, 2014, 9:51:58 PM (GMT)] */ package vazkii.botania.common.block.mana; +import cpw.mods.fml.common.Optional; import net.minecraft.block.material.Material; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; @@ -22,34 +23,32 @@ import vazkii.botania.common.block.tile.mana.TileRFGenerator; import vazkii.botania.common.lexicon.LexiconData; import vazkii.botania.common.lib.LibBlockNames; -import cpw.mods.fml.common.Optional; public class BlockRFGenerator extends BlockModContainer implements ILexiconable { - public BlockRFGenerator() { - super(Material.rock); - setHardness(2.0F); - setResistance(10.0F); - setStepSound(soundTypeStone); - setBlockName(LibBlockNames.RF_GENERATOR); - } - - @Override - @Optional.Method(modid = "CoFHAPI|energy") - public void onNeighborChange(IBlockAccess world, int x, int y, int z, int tileX, int tileY, int tileZ) { - TileEntity tile = world.getTileEntity(x, y, z); - if(tile != null && tile instanceof TileRFGenerator) - ((TileRFGenerator) tile).onNeighborTileChange(tileX, tileY, tileZ); - } + public BlockRFGenerator() { + super(Material.rock); + setHardness(2.0F); + setResistance(10.0F); + setStepSound(soundTypeStone); + setBlockName(LibBlockNames.RF_GENERATOR); + } - @Override - public TileEntity createNewTileEntity(World world, int meta) { - return new TileRFGenerator(); - } + @Override + @Optional.Method(modid = "CoFHAPI|energy") + public void onNeighborChange(IBlockAccess world, int x, int y, int z, int tileX, int tileY, int tileZ) { + TileEntity tile = world.getTileEntity(x, y, z); + if (tile != null && tile instanceof TileRFGenerator) + ((TileRFGenerator) tile).onNeighborTileChange(tileX, tileY, tileZ); + } - @Override - public LexiconEntry getEntry(World world, int x, int y, int z, EntityPlayer player, ItemStack lexicon) { - return LexiconData.rfGenerator; - } + @Override + public TileEntity createNewTileEntity(World world, int meta) { + return new TileRFGenerator(); + } + @Override + public LexiconEntry getEntry(World world, int x, int y, int z, EntityPlayer player, ItemStack lexicon) { + return LexiconData.rfGenerator; + } } diff --git a/src/main/java/vazkii/botania/common/block/mana/BlockRuneAltar.java b/src/main/java/vazkii/botania/common/block/mana/BlockRuneAltar.java index 23ef4ef8eb..03a159a649 100644 --- a/src/main/java/vazkii/botania/common/block/mana/BlockRuneAltar.java +++ b/src/main/java/vazkii/botania/common/block/mana/BlockRuneAltar.java @@ -2,16 +2,15 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Feb 2, 2014, 2:10:14 PM (GMT)] */ package vazkii.botania.common.block.mana; import java.util.Random; - import net.minecraft.block.Block; import net.minecraft.block.material.Material; import net.minecraft.client.renderer.texture.IIconRegister; @@ -35,132 +34,144 @@ public class BlockRuneAltar extends BlockModContainer implements IWandable, ILexiconable { - Random random; - IIcon[] icons; - - public BlockRuneAltar() { - super(Material.rock); - setBlockBounds(0F, 0F, 0F, 1F, 0.75F, 1F); - setHardness(2.0F); - setResistance(10.0F); - setStepSound(soundTypeStone); - setBlockName(LibBlockNames.RUNE_ALTAR); - - BotaniaAPI.blacklistBlockFromMagnet(this, Short.MAX_VALUE); - - random = new Random(); - } - - @Override - public boolean isOpaqueCube() { - return false; - } - - @Override - public boolean renderAsNormalBlock() { - return false; - } - - @Override - public void registerBlockIcons(IIconRegister par1IconRegister) { - icons = new IIcon[3]; - for(int i = 0; i < icons.length; i++) - icons[i] = IconHelper.forBlock(par1IconRegister, this, i); - } - - @Override - public boolean onBlockActivated(World par1World, int par2, int par3, int par4, EntityPlayer par5EntityPlayer, int par6, float par7, float par8, float par9) { - TileRuneAltar altar = (TileRuneAltar) par1World.getTileEntity(par2, par3, par4); - ItemStack stack = par5EntityPlayer.getCurrentEquippedItem(); - - if(par5EntityPlayer.isSneaking()) { - if(altar.manaToGet == 0) - for(int i = altar.getSizeInventory() - 1; i >= 0; i--) { - ItemStack stackAt = altar.getStackInSlot(i); - if(stackAt != null) { - ItemStack copy = stackAt.copy(); - if(!par5EntityPlayer.inventory.addItemStackToInventory(copy)) - par5EntityPlayer.dropPlayerItemWithRandomChoice(copy, false); - altar.setInventorySlotContents(i, null); - par1World.func_147453_f(par2, par3, par4, this); - break; - } - } - } else if(altar.isEmpty() && stack == null) - altar.trySetLastRecipe(par5EntityPlayer); - else if(stack != null) - return altar.addItem(par5EntityPlayer, stack); - return false; - } - - @Override - public void breakBlock(World par1World, int par2, int par3, int par4, Block par5, int par6) { - TileSimpleInventory inv = (TileSimpleInventory) par1World.getTileEntity(par2, par3, par4); - - if (inv != null) { - for (int j1 = 0; j1 < inv.getSizeInventory(); ++j1) { - ItemStack itemstack = inv.getStackInSlot(j1); - - if (itemstack != null) { - float f = random.nextFloat() * 0.8F + 0.1F; - float f1 = random.nextFloat() * 0.8F + 0.1F; - EntityItem entityitem; - - for (float f2 = random.nextFloat() * 0.8F + 0.1F; itemstack.stackSize > 0; par1World.spawnEntityInWorld(entityitem)) { - int k1 = random.nextInt(21) + 10; - - if (k1 > itemstack.stackSize) - k1 = itemstack.stackSize; - - itemstack.stackSize -= k1; - entityitem = new EntityItem(par1World, par2 + f, par3 + f1, par4 + f2, new ItemStack(itemstack.getItem(), k1, itemstack.getItemDamage())); - float f3 = 0.05F; - entityitem.motionX = (float)random.nextGaussian() * f3; - entityitem.motionY = (float)random.nextGaussian() * f3 + 0.2F; - entityitem.motionZ = (float)random.nextGaussian() * f3; - - if (itemstack.hasTagCompound()) - entityitem.getEntityItem().setTagCompound((NBTTagCompound)itemstack.getTagCompound().copy()); - } - } - } - - par1World.func_147453_f(par2, par3, par4, par5); - } - - super.breakBlock(par1World, par2, par3, par4, par5, par6); - } - - @Override - public IIcon getIcon(int par1, int par2) { - return icons[Math.min(2, par1)]; - } - - @Override - public TileEntity createNewTileEntity(World world, int meta) { - return new TileRuneAltar(); - } - - @Override - public boolean hasComparatorInputOverride() { - return true; - } - - @Override - public int getComparatorInputOverride(World par1World, int par2, int par3, int par4, int par5) { - TileRuneAltar altar = (TileRuneAltar) par1World.getTileEntity(par2, par3, par4); - return altar.signal; - } - - @Override - public boolean onUsedByWand(EntityPlayer player, ItemStack stack, World world, int x, int y, int z, int side) { - ((TileRuneAltar) world.getTileEntity(x, y, z)).onWanded(player, stack); - return true; - } - - @Override - public LexiconEntry getEntry(World world, int x, int y, int z, EntityPlayer player, ItemStack lexicon) { - return LexiconData.runicAltar; - } - + Random random; + IIcon[] icons; + + public BlockRuneAltar() { + super(Material.rock); + setBlockBounds(0F, 0F, 0F, 1F, 0.75F, 1F); + setHardness(2.0F); + setResistance(10.0F); + setStepSound(soundTypeStone); + setBlockName(LibBlockNames.RUNE_ALTAR); + + BotaniaAPI.blacklistBlockFromMagnet(this, Short.MAX_VALUE); + + random = new Random(); + } + + @Override + public boolean isOpaqueCube() { + return false; + } + + @Override + public boolean renderAsNormalBlock() { + return false; + } + + @Override + public void registerBlockIcons(IIconRegister par1IconRegister) { + icons = new IIcon[3]; + for (int i = 0; i < icons.length; i++) icons[i] = IconHelper.forBlock(par1IconRegister, this, i); + } + + @Override + public boolean onBlockActivated( + World par1World, + int par2, + int par3, + int par4, + EntityPlayer par5EntityPlayer, + int par6, + float par7, + float par8, + float par9) { + TileRuneAltar altar = (TileRuneAltar) par1World.getTileEntity(par2, par3, par4); + ItemStack stack = par5EntityPlayer.getCurrentEquippedItem(); + + if (par5EntityPlayer.isSneaking()) { + if (altar.manaToGet == 0) + for (int i = altar.getSizeInventory() - 1; i >= 0; i--) { + ItemStack stackAt = altar.getStackInSlot(i); + if (stackAt != null) { + ItemStack copy = stackAt.copy(); + if (!par5EntityPlayer.inventory.addItemStackToInventory(copy)) + par5EntityPlayer.dropPlayerItemWithRandomChoice(copy, false); + altar.setInventorySlotContents(i, null); + par1World.func_147453_f(par2, par3, par4, this); + break; + } + } + } else if (altar.isEmpty() && stack == null) altar.trySetLastRecipe(par5EntityPlayer); + else if (stack != null) return altar.addItem(par5EntityPlayer, stack); + return false; + } + + @Override + public void breakBlock(World par1World, int par2, int par3, int par4, Block par5, int par6) { + TileSimpleInventory inv = (TileSimpleInventory) par1World.getTileEntity(par2, par3, par4); + + if (inv != null) { + for (int j1 = 0; j1 < inv.getSizeInventory(); ++j1) { + ItemStack itemstack = inv.getStackInSlot(j1); + + if (itemstack != null) { + float f = random.nextFloat() * 0.8F + 0.1F; + float f1 = random.nextFloat() * 0.8F + 0.1F; + EntityItem entityitem; + + for (float f2 = random.nextFloat() * 0.8F + 0.1F; + itemstack.stackSize > 0; + par1World.spawnEntityInWorld(entityitem)) { + int k1 = random.nextInt(21) + 10; + + if (k1 > itemstack.stackSize) k1 = itemstack.stackSize; + + itemstack.stackSize -= k1; + entityitem = new EntityItem( + par1World, + par2 + f, + par3 + f1, + par4 + f2, + new ItemStack(itemstack.getItem(), k1, itemstack.getItemDamage())); + float f3 = 0.05F; + entityitem.motionX = (float) random.nextGaussian() * f3; + entityitem.motionY = (float) random.nextGaussian() * f3 + 0.2F; + entityitem.motionZ = (float) random.nextGaussian() * f3; + + if (itemstack.hasTagCompound()) + entityitem.getEntityItem().setTagCompound((NBTTagCompound) + itemstack.getTagCompound().copy()); + } + } + } + + par1World.func_147453_f(par2, par3, par4, par5); + } + + super.breakBlock(par1World, par2, par3, par4, par5, par6); + } + + @Override + public IIcon getIcon(int par1, int par2) { + return icons[Math.min(2, par1)]; + } + + @Override + public TileEntity createNewTileEntity(World world, int meta) { + return new TileRuneAltar(); + } + + @Override + public boolean hasComparatorInputOverride() { + return true; + } + + @Override + public int getComparatorInputOverride(World par1World, int par2, int par3, int par4, int par5) { + TileRuneAltar altar = (TileRuneAltar) par1World.getTileEntity(par2, par3, par4); + return altar.signal; + } + + @Override + public boolean onUsedByWand(EntityPlayer player, ItemStack stack, World world, int x, int y, int z, int side) { + ((TileRuneAltar) world.getTileEntity(x, y, z)).onWanded(player, stack); + return true; + } + + @Override + public LexiconEntry getEntry(World world, int x, int y, int z, EntityPlayer player, ItemStack lexicon) { + return LexiconData.runicAltar; + } } diff --git a/src/main/java/vazkii/botania/common/block/mana/BlockSpawnerClaw.java b/src/main/java/vazkii/botania/common/block/mana/BlockSpawnerClaw.java index c21a20fb5e..370e3b5706 100644 --- a/src/main/java/vazkii/botania/common/block/mana/BlockSpawnerClaw.java +++ b/src/main/java/vazkii/botania/common/block/mana/BlockSpawnerClaw.java @@ -2,16 +2,15 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jul 23, 2014, 5:28:55 PM (GMT)] */ package vazkii.botania.common.block.mana; import java.util.List; - import net.minecraft.block.material.Material; import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.creativetab.CreativeTabs; @@ -31,50 +30,49 @@ public class BlockSpawnerClaw extends BlockModContainer implements ILexiconable { - public BlockSpawnerClaw() { - super(Material.iron); - setHardness(3.0F); - setBlockName(LibBlockNames.SPAWNER_CLAW); - - float f = 1F / 8F; - float f1 = 1F / 16F; - setBlockBounds(f, 0F, f, 1F - f, f1, 1F - f); - } + public BlockSpawnerClaw() { + super(Material.iron); + setHardness(3.0F); + setBlockName(LibBlockNames.SPAWNER_CLAW); - @Override - public void getSubBlocks(Item item, CreativeTabs tab, List list) { - list.add(new ItemStack(item)); - list.add(new ItemStack(Blocks.mob_spawner)); - } + float f = 1F / 8F; + float f1 = 1F / 16F; + setBlockBounds(f, 0F, f, 1F - f, f1, 1F - f); + } - @Override - public void registerBlockIcons(IIconRegister par1IconRegister) { - //NO-OP - } + @Override + public void getSubBlocks(Item item, CreativeTabs tab, List list) { + list.add(new ItemStack(item)); + list.add(new ItemStack(Blocks.mob_spawner)); + } - @Override - public boolean isOpaqueCube() { - return false; - } + @Override + public void registerBlockIcons(IIconRegister par1IconRegister) { + // NO-OP + } - @Override - public boolean renderAsNormalBlock() { - return false; - } + @Override + public boolean isOpaqueCube() { + return false; + } - @Override - public int getRenderType() { - return LibRenderIDs.idSpawnerClaw; - } + @Override + public boolean renderAsNormalBlock() { + return false; + } - @Override - public TileEntity createNewTileEntity(World world, int meta) { - return new TileSpawnerClaw(); - } + @Override + public int getRenderType() { + return LibRenderIDs.idSpawnerClaw; + } - @Override - public LexiconEntry getEntry(World world, int x, int y, int z, EntityPlayer player, ItemStack lexicon) { - return LexiconData.spawnerClaw; - } + @Override + public TileEntity createNewTileEntity(World world, int meta) { + return new TileSpawnerClaw(); + } + @Override + public LexiconEntry getEntry(World world, int x, int y, int z, EntityPlayer player, ItemStack lexicon) { + return LexiconData.spawnerClaw; + } } diff --git a/src/main/java/vazkii/botania/common/block/mana/BlockSpreader.java b/src/main/java/vazkii/botania/common/block/mana/BlockSpreader.java index 8227d736fc..fb100a33fc 100644 --- a/src/main/java/vazkii/botania/common/block/mana/BlockSpreader.java +++ b/src/main/java/vazkii/botania/common/block/mana/BlockSpreader.java @@ -2,17 +2,17 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jan 25, 2014, 9:38:23 PM (GMT)] */ package vazkii.botania.common.block.mana; +import cpw.mods.fml.common.registry.GameRegistry; import java.util.List; import java.util.Random; - import net.minecraft.block.Block; import net.minecraft.block.BlockPistonBase; import net.minecraft.block.material.Material; @@ -45,209 +45,229 @@ import vazkii.botania.common.item.block.ItemBlockWithMetadataAndName; import vazkii.botania.common.lexicon.LexiconData; import vazkii.botania.common.lib.LibBlockNames; -import cpw.mods.fml.common.registry.GameRegistry; - -public class BlockSpreader extends BlockModContainer implements IWandable, IWandHUD, ILexiconable, IWireframeAABBProvider { - - Random random; - - public BlockSpreader() { - super(Material.wood); - setHardness(2.0F); - setStepSound(soundTypeWood); - setBlockName(LibBlockNames.SPREADER); - - random = new Random(); - } - - @Override - protected boolean shouldRegisterInNameSet() { - return false; - } - - @Override - public Block setBlockName(String par1Str) { - GameRegistry.registerBlock(this, ItemBlockWithMetadataAndName.class, par1Str); - return super.setBlockName(par1Str); - } - - @Override - public void registerBlockIcons(IIconRegister par1IconRegister) { - // NO-OP - } - - @Override - public void getSubBlocks(Item par1, CreativeTabs par2, List par3) { - for(int i = 0; i < 4; i++) - par3.add(new ItemStack(par1, 1, i)); - } - - @Override - public void onBlockPlacedBy(World par1World, int par2, int par3, int par4, EntityLivingBase par5EntityLivingBase, ItemStack par6ItemStack) { - int orientation = BlockPistonBase.determineOrientation(par1World, par2, par3, par4, par5EntityLivingBase); - TileSpreader spreader = (TileSpreader) par1World.getTileEntity(par2, par3, par4); - par1World.setBlockMetadataWithNotify(par2, par3, par4, par6ItemStack.getItemDamage(), 1 | 2); - - switch(orientation) { - case 0: - spreader.rotationY = -90F; - break; - case 1: - spreader.rotationY = 90F; - break; - case 2: - spreader.rotationX = 270F; - break; - case 3: - spreader.rotationX = 90F; - break; - case 4: - break; - default: - spreader.rotationX = 180F; - break; - } - } - - @Override - public int damageDropped(int par1) { - return par1; - } - - @Override - public boolean isOpaqueCube() { - return false; - } - - @Override - public boolean renderAsNormalBlock() { - return false; - } - - @Override - public IIcon getIcon(int par1, int par2) { - return par2 >= 2 ? ModBlocks.dreamwood.getIcon(par1, 0) : ModBlocks.livingwood.getIcon(par1, 0); - } - - @Override - public int getRenderType() { - return LibRenderIDs.idSpreader; - } - - @Override - public boolean onBlockActivated(World par1World, int par2, int par3, int par4, EntityPlayer par5EntityPlayer, int par6, float par7, float par8, float par9) { - TileEntity tile = par1World.getTileEntity(par2, par3, par4); - if(!(tile instanceof TileSpreader)) - return false; - - TileSpreader spreader = (TileSpreader) tile; - ItemStack lens = spreader.getStackInSlot(0); - ItemStack heldItem = par5EntityPlayer.getCurrentEquippedItem(); - boolean isHeldItemLens = heldItem != null && heldItem.getItem() instanceof ILens; - boolean wool = heldItem != null && heldItem.getItem() == Item.getItemFromBlock(Blocks.wool); - - if(heldItem != null) - if(heldItem.getItem() == ModItems.twigWand) - return false; - - if(lens == null && isHeldItemLens) { - if (!par5EntityPlayer.capabilities.isCreativeMode) - par5EntityPlayer.inventory.setInventorySlotContents(par5EntityPlayer.inventory.currentItem, null); - - spreader.setInventorySlotContents(0, heldItem.copy()); - spreader.markDirty(); - } else if(lens != null && !wool) { - ItemStack add = lens.copy(); - if(!par5EntityPlayer.inventory.addItemStackToInventory(add)) - par5EntityPlayer.dropPlayerItemWithRandomChoice(add, false); - spreader.setInventorySlotContents(0, null); - spreader.markDirty(); - } - - if(wool && spreader.paddingColor == -1) { - spreader.paddingColor = heldItem.getItemDamage(); - heldItem.stackSize--; - if(heldItem.stackSize == 0) - par5EntityPlayer.inventory.setInventorySlotContents(par5EntityPlayer.inventory.currentItem, null); - } else if(heldItem == null && spreader.paddingColor != -1 && lens == null) { - ItemStack pad = new ItemStack(Blocks.wool, 1, spreader.paddingColor); - if(!par5EntityPlayer.inventory.addItemStackToInventory(pad)) - par5EntityPlayer.dropPlayerItemWithRandomChoice(pad, false); - spreader.paddingColor = -1; - spreader.markDirty(); - } - - return true; - } - - @Override - public void breakBlock(World par1World, int par2, int par3, int par4, Block par5, int par6) { - TileEntity tile = par1World.getTileEntity(par2, par3, par4); - if(!(tile instanceof TileSpreader)) - return; - - TileSpreader inv = (TileSpreader) tile; - - if (inv != null) { - for (int j1 = 0; j1 < inv.getSizeInventory() + 1; ++j1) { - ItemStack itemstack = j1 >= inv.getSizeInventory() ? inv.paddingColor == -1 ? null : new ItemStack(Blocks.wool, 1, inv.paddingColor) : inv.getStackInSlot(j1); - - if(itemstack != null) { - float f = random.nextFloat() * 0.8F + 0.1F; - float f1 = random.nextFloat() * 0.8F + 0.1F; - EntityItem entityitem; - - for (float f2 = random.nextFloat() * 0.8F + 0.1F; itemstack.stackSize > 0; par1World.spawnEntityInWorld(entityitem)) { - int k1 = random.nextInt(21) + 10; - - if (k1 > itemstack.stackSize) - k1 = itemstack.stackSize; - - itemstack.stackSize -= k1; - entityitem = new EntityItem(par1World, par2 + f, par3 + f1, par4 + f2, new ItemStack(itemstack.getItem(), k1, itemstack.getItemDamage())); - float f3 = 0.05F; - entityitem.motionX = (float)random.nextGaussian() * f3; - entityitem.motionY = (float)random.nextGaussian() * f3 + 0.2F; - entityitem.motionZ = (float)random.nextGaussian() * f3; - - if (itemstack.hasTagCompound()) - entityitem.getEntityItem().setTagCompound((NBTTagCompound)itemstack.getTagCompound().copy()); - } - } - } - - par1World.func_147453_f(par2, par3, par4, par5); - } - - super.breakBlock(par1World, par2, par3, par4, par5, par6); - } - - @Override - public boolean onUsedByWand(EntityPlayer player, ItemStack stack, World world, int x, int y, int z, int side) { - ((TileSpreader) world.getTileEntity(x, y, z)).onWanded(player, stack); - return true; - } - - @Override - public TileEntity createNewTileEntity(World world, int meta) { - return new TileSpreader(); - } - - @Override - public void renderHUD(Minecraft mc, ScaledResolution res, World world, int x, int y, int z) { - ((TileSpreader) world.getTileEntity(x, y, z)).renderHUD(mc, res); - } - - @Override - public LexiconEntry getEntry(World world, int x, int y, int z, EntityPlayer player, ItemStack lexicon) { - int meta = world.getBlockMetadata(x, y, z); - return meta == 0 ? LexiconData.spreader : meta == 1 ? LexiconData.redstoneSpreader : LexiconData.dreamwoodSpreader; - } - - @Override - public AxisAlignedBB getWireframeAABB(World world, int x, int y, int z) { - float f = 1F / 16F; - return AxisAlignedBB.getBoundingBox(x + f, y + f, z + f, x + 1 - f, y + 1 - f, z + 1 - f); - } +public class BlockSpreader extends BlockModContainer + implements IWandable, IWandHUD, ILexiconable, IWireframeAABBProvider { + + Random random; + + public BlockSpreader() { + super(Material.wood); + setHardness(2.0F); + setStepSound(soundTypeWood); + setBlockName(LibBlockNames.SPREADER); + + random = new Random(); + } + + @Override + protected boolean shouldRegisterInNameSet() { + return false; + } + + @Override + public Block setBlockName(String par1Str) { + GameRegistry.registerBlock(this, ItemBlockWithMetadataAndName.class, par1Str); + return super.setBlockName(par1Str); + } + + @Override + public void registerBlockIcons(IIconRegister par1IconRegister) { + // NO-OP + } + + @Override + public void getSubBlocks(Item par1, CreativeTabs par2, List par3) { + for (int i = 0; i < 4; i++) par3.add(new ItemStack(par1, 1, i)); + } + + @Override + public void onBlockPlacedBy( + World par1World, + int par2, + int par3, + int par4, + EntityLivingBase par5EntityLivingBase, + ItemStack par6ItemStack) { + int orientation = BlockPistonBase.determineOrientation(par1World, par2, par3, par4, par5EntityLivingBase); + TileSpreader spreader = (TileSpreader) par1World.getTileEntity(par2, par3, par4); + par1World.setBlockMetadataWithNotify(par2, par3, par4, par6ItemStack.getItemDamage(), 1 | 2); + + switch (orientation) { + case 0: + spreader.rotationY = -90F; + break; + case 1: + spreader.rotationY = 90F; + break; + case 2: + spreader.rotationX = 270F; + break; + case 3: + spreader.rotationX = 90F; + break; + case 4: + break; + default: + spreader.rotationX = 180F; + break; + } + } + + @Override + public int damageDropped(int par1) { + return par1; + } + + @Override + public boolean isOpaqueCube() { + return false; + } + + @Override + public boolean renderAsNormalBlock() { + return false; + } + + @Override + public IIcon getIcon(int par1, int par2) { + return par2 >= 2 ? ModBlocks.dreamwood.getIcon(par1, 0) : ModBlocks.livingwood.getIcon(par1, 0); + } + + @Override + public int getRenderType() { + return LibRenderIDs.idSpreader; + } + + @Override + public boolean onBlockActivated( + World par1World, + int par2, + int par3, + int par4, + EntityPlayer par5EntityPlayer, + int par6, + float par7, + float par8, + float par9) { + TileEntity tile = par1World.getTileEntity(par2, par3, par4); + if (!(tile instanceof TileSpreader)) return false; + + TileSpreader spreader = (TileSpreader) tile; + ItemStack lens = spreader.getStackInSlot(0); + ItemStack heldItem = par5EntityPlayer.getCurrentEquippedItem(); + boolean isHeldItemLens = heldItem != null && heldItem.getItem() instanceof ILens; + boolean wool = heldItem != null && heldItem.getItem() == Item.getItemFromBlock(Blocks.wool); + + if (heldItem != null) if (heldItem.getItem() == ModItems.twigWand) return false; + + if (lens == null && isHeldItemLens) { + if (!par5EntityPlayer.capabilities.isCreativeMode) + par5EntityPlayer.inventory.setInventorySlotContents(par5EntityPlayer.inventory.currentItem, null); + + spreader.setInventorySlotContents(0, heldItem.copy()); + spreader.markDirty(); + } else if (lens != null && !wool) { + ItemStack add = lens.copy(); + if (!par5EntityPlayer.inventory.addItemStackToInventory(add)) + par5EntityPlayer.dropPlayerItemWithRandomChoice(add, false); + spreader.setInventorySlotContents(0, null); + spreader.markDirty(); + } + + if (wool && spreader.paddingColor == -1) { + spreader.paddingColor = heldItem.getItemDamage(); + heldItem.stackSize--; + if (heldItem.stackSize == 0) + par5EntityPlayer.inventory.setInventorySlotContents(par5EntityPlayer.inventory.currentItem, null); + } else if (heldItem == null && spreader.paddingColor != -1 && lens == null) { + ItemStack pad = new ItemStack(Blocks.wool, 1, spreader.paddingColor); + if (!par5EntityPlayer.inventory.addItemStackToInventory(pad)) + par5EntityPlayer.dropPlayerItemWithRandomChoice(pad, false); + spreader.paddingColor = -1; + spreader.markDirty(); + } + + return true; + } + + @Override + public void breakBlock(World par1World, int par2, int par3, int par4, Block par5, int par6) { + TileEntity tile = par1World.getTileEntity(par2, par3, par4); + if (!(tile instanceof TileSpreader)) return; + + TileSpreader inv = (TileSpreader) tile; + + if (inv != null) { + for (int j1 = 0; j1 < inv.getSizeInventory() + 1; ++j1) { + ItemStack itemstack = j1 >= inv.getSizeInventory() + ? inv.paddingColor == -1 ? null : new ItemStack(Blocks.wool, 1, inv.paddingColor) + : inv.getStackInSlot(j1); + + if (itemstack != null) { + float f = random.nextFloat() * 0.8F + 0.1F; + float f1 = random.nextFloat() * 0.8F + 0.1F; + EntityItem entityitem; + + for (float f2 = random.nextFloat() * 0.8F + 0.1F; + itemstack.stackSize > 0; + par1World.spawnEntityInWorld(entityitem)) { + int k1 = random.nextInt(21) + 10; + + if (k1 > itemstack.stackSize) k1 = itemstack.stackSize; + + itemstack.stackSize -= k1; + entityitem = new EntityItem( + par1World, + par2 + f, + par3 + f1, + par4 + f2, + new ItemStack(itemstack.getItem(), k1, itemstack.getItemDamage())); + float f3 = 0.05F; + entityitem.motionX = (float) random.nextGaussian() * f3; + entityitem.motionY = (float) random.nextGaussian() * f3 + 0.2F; + entityitem.motionZ = (float) random.nextGaussian() * f3; + + if (itemstack.hasTagCompound()) + entityitem.getEntityItem().setTagCompound((NBTTagCompound) + itemstack.getTagCompound().copy()); + } + } + } + + par1World.func_147453_f(par2, par3, par4, par5); + } + + super.breakBlock(par1World, par2, par3, par4, par5, par6); + } + + @Override + public boolean onUsedByWand(EntityPlayer player, ItemStack stack, World world, int x, int y, int z, int side) { + ((TileSpreader) world.getTileEntity(x, y, z)).onWanded(player, stack); + return true; + } + + @Override + public TileEntity createNewTileEntity(World world, int meta) { + return new TileSpreader(); + } + + @Override + public void renderHUD(Minecraft mc, ScaledResolution res, World world, int x, int y, int z) { + ((TileSpreader) world.getTileEntity(x, y, z)).renderHUD(mc, res); + } + + @Override + public LexiconEntry getEntry(World world, int x, int y, int z, EntityPlayer player, ItemStack lexicon) { + int meta = world.getBlockMetadata(x, y, z); + return meta == 0 + ? LexiconData.spreader + : meta == 1 ? LexiconData.redstoneSpreader : LexiconData.dreamwoodSpreader; + } + + @Override + public AxisAlignedBB getWireframeAABB(World world, int x, int y, int z) { + float f = 1F / 16F; + return AxisAlignedBB.getBoundingBox(x + f, y + f, z + f, x + 1 - f, y + 1 - f, z + 1 - f); + } } diff --git a/src/main/java/vazkii/botania/common/block/mana/BlockTerraPlate.java b/src/main/java/vazkii/botania/common/block/mana/BlockTerraPlate.java index c5579a6823..a770d7ab98 100644 --- a/src/main/java/vazkii/botania/common/block/mana/BlockTerraPlate.java +++ b/src/main/java/vazkii/botania/common/block/mana/BlockTerraPlate.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Nov 8, 2014, 5:25:12 PM (GMT)] */ package vazkii.botania.common.block.mana; @@ -31,95 +31,92 @@ public class BlockTerraPlate extends BlockModContainer implements ILexiconable { - public static IIcon overlay; - IIcon[] icons; - - public BlockTerraPlate() { - super(Material.iron); - setBlockBounds(0F, 0F, 0F, 1F, 3F / 16F, 1F); - setHardness(3F); - setResistance(10F); - setStepSound(soundTypeMetal); - setBlockName(LibBlockNames.TERRA_PLATE); - - BotaniaAPI.blacklistBlockFromMagnet(this, Short.MAX_VALUE); - } - - @Override - public boolean onBlockActivated(World worldObj, int x, int y, int z, EntityPlayer player, int s, float xs, float ys, float zs) { - ItemStack stack = player.getCurrentEquippedItem(); - if(stack != null && stack.getItem() == ModItems.manaResource && stack.getItemDamage() < 3) { - if(player == null || !player.capabilities.isCreativeMode) { - stack.stackSize--; - if(stack.stackSize == 0 && player != null) - player.inventory.setInventorySlotContents(player.inventory.currentItem, null); - } - - ItemStack target = stack.copy(); - target.stackSize = 1; - EntityItem item = new EntityItem(worldObj, x + 0.5, y + 0.5, z + 0.5, target); - item.delayBeforeCanPickup = 40; - item.motionX = item.motionY = item.motionZ = 0; - if(!worldObj.isRemote) - worldObj.spawnEntityInWorld(item); - - return true; - } - - return false; - } - - @Override - public boolean renderAsNormalBlock() { - return false; - } - - @Override - public boolean isOpaqueCube() { - return false; - } - - @Override - public boolean getBlocksMovement(IBlockAccess p_149655_1_, int p_149655_2_, int p_149655_3_, int p_149655_4_) { - return false; - } - - @Override - public void registerBlockIcons(IIconRegister par1IconRegister) { - icons = new IIcon[3]; - for(int i = 0; i < icons.length; i++) - icons[i] = IconHelper.forBlock(par1IconRegister, this, i); - overlay = IconHelper.forBlock(par1IconRegister, this, "Overlay"); - } - - @Override - public IIcon getIcon(int par1, int par2) { - return icons[Math.min(2, par1)]; - } - - @Override - public TileEntity createNewTileEntity(World world, int meta) { - return new TileTerraPlate(); - } - - @Override - public LexiconEntry getEntry(World world, int x, int y, int z, EntityPlayer player, ItemStack lexicon) { - return LexiconData.terrasteel; - } - - @Override - public boolean hasComparatorInputOverride() { - return true; - } - - @Override - public int getComparatorInputOverride(World par1World, int par2, int par3, int par4, int par5) { - TileTerraPlate plate = (TileTerraPlate) par1World.getTileEntity(par2, par3, par4); - int val = (int) ((double) plate.getCurrentMana() / (double) TileTerraPlate.MAX_MANA * 15.0); - if(plate.getCurrentMana() > 0) - val = Math.max(val, 1); - - return val; - } - + public static IIcon overlay; + IIcon[] icons; + + public BlockTerraPlate() { + super(Material.iron); + setBlockBounds(0F, 0F, 0F, 1F, 3F / 16F, 1F); + setHardness(3F); + setResistance(10F); + setStepSound(soundTypeMetal); + setBlockName(LibBlockNames.TERRA_PLATE); + + BotaniaAPI.blacklistBlockFromMagnet(this, Short.MAX_VALUE); + } + + @Override + public boolean onBlockActivated( + World worldObj, int x, int y, int z, EntityPlayer player, int s, float xs, float ys, float zs) { + ItemStack stack = player.getCurrentEquippedItem(); + if (stack != null && stack.getItem() == ModItems.manaResource && stack.getItemDamage() < 3) { + if (player == null || !player.capabilities.isCreativeMode) { + stack.stackSize--; + if (stack.stackSize == 0 && player != null) + player.inventory.setInventorySlotContents(player.inventory.currentItem, null); + } + + ItemStack target = stack.copy(); + target.stackSize = 1; + EntityItem item = new EntityItem(worldObj, x + 0.5, y + 0.5, z + 0.5, target); + item.delayBeforeCanPickup = 40; + item.motionX = item.motionY = item.motionZ = 0; + if (!worldObj.isRemote) worldObj.spawnEntityInWorld(item); + + return true; + } + + return false; + } + + @Override + public boolean renderAsNormalBlock() { + return false; + } + + @Override + public boolean isOpaqueCube() { + return false; + } + + @Override + public boolean getBlocksMovement(IBlockAccess p_149655_1_, int p_149655_2_, int p_149655_3_, int p_149655_4_) { + return false; + } + + @Override + public void registerBlockIcons(IIconRegister par1IconRegister) { + icons = new IIcon[3]; + for (int i = 0; i < icons.length; i++) icons[i] = IconHelper.forBlock(par1IconRegister, this, i); + overlay = IconHelper.forBlock(par1IconRegister, this, "Overlay"); + } + + @Override + public IIcon getIcon(int par1, int par2) { + return icons[Math.min(2, par1)]; + } + + @Override + public TileEntity createNewTileEntity(World world, int meta) { + return new TileTerraPlate(); + } + + @Override + public LexiconEntry getEntry(World world, int x, int y, int z, EntityPlayer player, ItemStack lexicon) { + return LexiconData.terrasteel; + } + + @Override + public boolean hasComparatorInputOverride() { + return true; + } + + @Override + public int getComparatorInputOverride(World par1World, int par2, int par3, int par4, int par5) { + TileTerraPlate plate = (TileTerraPlate) par1World.getTileEntity(par2, par3, par4); + int val = (int) ((double) plate.getCurrentMana() / (double) TileTerraPlate.MAX_MANA * 15.0); + if (plate.getCurrentMana() > 0) val = Math.max(val, 1); + + return val; + } } diff --git a/src/main/java/vazkii/botania/common/block/mana/BlockTurntable.java b/src/main/java/vazkii/botania/common/block/mana/BlockTurntable.java index ea88ef91c0..efeab06bc9 100644 --- a/src/main/java/vazkii/botania/common/block/mana/BlockTurntable.java +++ b/src/main/java/vazkii/botania/common/block/mana/BlockTurntable.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Mar 16, 2014, 10:08:14 PM (GMT)] */ package vazkii.botania.common.block.mana; @@ -31,46 +31,44 @@ public class BlockTurntable extends BlockModContainer implements IWandable, IWandHUD, ILexiconable { - IIcon[] icons; + IIcon[] icons; - public BlockTurntable() { - super(Material.wood); - setHardness(2.0F); - setStepSound(soundTypeWood); - setBlockName(LibBlockNames.TURNTABLE); - } + public BlockTurntable() { + super(Material.wood); + setHardness(2.0F); + setStepSound(soundTypeWood); + setBlockName(LibBlockNames.TURNTABLE); + } - @Override - public void registerBlockIcons(IIconRegister par1IconRegister) { - icons = new IIcon[2]; - for(int i = 0; i < icons.length; i++) - icons[i] = IconHelper.forBlock(par1IconRegister, this, i); - } + @Override + public void registerBlockIcons(IIconRegister par1IconRegister) { + icons = new IIcon[2]; + for (int i = 0; i < icons.length; i++) icons[i] = IconHelper.forBlock(par1IconRegister, this, i); + } - @Override - public IIcon getIcon(int par1, int par2) { - return par1 == 1 ? icons[0] : icons[1]; - } + @Override + public IIcon getIcon(int par1, int par2) { + return par1 == 1 ? icons[0] : icons[1]; + } - @Override - public TileEntity createNewTileEntity(World world, int meta) { - return new TileTurntable(); - } + @Override + public TileEntity createNewTileEntity(World world, int meta) { + return new TileTurntable(); + } - @Override - public void renderHUD(Minecraft mc, ScaledResolution res, World world, int x, int y, int z) { - ((TileTurntable) world.getTileEntity(x, y, z)).renderHUD(mc, res); - } + @Override + public void renderHUD(Minecraft mc, ScaledResolution res, World world, int x, int y, int z) { + ((TileTurntable) world.getTileEntity(x, y, z)).renderHUD(mc, res); + } - @Override - public boolean onUsedByWand(EntityPlayer player, ItemStack stack, World world, int x, int y, int z, int side) { - ((TileTurntable) world.getTileEntity(x, y, z)).onWanded(player, stack); - return true; - } - - @Override - public LexiconEntry getEntry(World world, int x, int y, int z, EntityPlayer player, ItemStack lexicon) { - return LexiconData.turntable; - } + @Override + public boolean onUsedByWand(EntityPlayer player, ItemStack stack, World world, int x, int y, int z, int side) { + ((TileTurntable) world.getTileEntity(x, y, z)).onWanded(player, stack); + return true; + } + @Override + public LexiconEntry getEntry(World world, int x, int y, int z, EntityPlayer player, ItemStack lexicon) { + return LexiconData.turntable; + } } diff --git a/src/main/java/vazkii/botania/common/block/string/BlockRedString.java b/src/main/java/vazkii/botania/common/block/string/BlockRedString.java index d87199730e..746a18e8f4 100644 --- a/src/main/java/vazkii/botania/common/block/string/BlockRedString.java +++ b/src/main/java/vazkii/botania/common/block/string/BlockRedString.java @@ -2,14 +2,16 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Nov 14, 2014, 4:43:14 PM (GMT)] */ package vazkii.botania.common.block.string; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; import net.minecraft.block.BlockPistonBase; import net.minecraft.block.material.Material; import net.minecraft.client.renderer.texture.IIconRegister; @@ -27,53 +29,56 @@ import vazkii.botania.common.block.BlockModContainer; import vazkii.botania.common.block.tile.string.TileRedString; import vazkii.botania.common.lexicon.LexiconData; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; public abstract class BlockRedString extends BlockModContainer implements ILexiconable { - IIcon senderIcon; - IIcon sideIcon; - - public BlockRedString(String name) { - super(Material.rock); - setHardness(2.0F); - setResistance(10.0F); - setStepSound(soundTypeStone); - setBlockName(name); - } + IIcon senderIcon; + IIcon sideIcon; - @Override - public void onBlockPlacedBy(World par1World, int par2, int par3, int par4, EntityLivingBase par5EntityLivingBase, ItemStack par6ItemStack) { - int orientation = BlockPistonBase.determineOrientation(par1World, par2, par3, par4, par5EntityLivingBase); - par1World.setBlockMetadataWithNotify(par2, par3, par4, orientation, 1 | 2); - } + public BlockRedString(String name) { + super(Material.rock); + setHardness(2.0F); + setResistance(10.0F); + setStepSound(soundTypeStone); + setBlockName(name); + } - @Override - public boolean rotateBlock(World worldObj, int x, int y, int z, ForgeDirection axis) { - return RotationHelper.rotateVanillaBlock(Blocks.piston, worldObj, x, y, z, axis); - } + @Override + public void onBlockPlacedBy( + World par1World, + int par2, + int par3, + int par4, + EntityLivingBase par5EntityLivingBase, + ItemStack par6ItemStack) { + int orientation = BlockPistonBase.determineOrientation(par1World, par2, par3, par4, par5EntityLivingBase); + par1World.setBlockMetadataWithNotify(par2, par3, par4, orientation, 1 | 2); + } - @Override - @SideOnly(Side.CLIENT) - public void registerBlockIcons(IIconRegister par1IconRegister) { - senderIcon = IconHelper.forName(par1IconRegister, "redStringSender"); - sideIcon = registerSideIcon(par1IconRegister); - } + @Override + public boolean rotateBlock(World worldObj, int x, int y, int z, ForgeDirection axis) { + return RotationHelper.rotateVanillaBlock(Blocks.piston, worldObj, x, y, z, axis); + } - @SideOnly(Side.CLIENT) - public IIcon registerSideIcon(IIconRegister register) { - return IconHelper.forBlock(register, this); - } + @Override + @SideOnly(Side.CLIENT) + public void registerBlockIcons(IIconRegister par1IconRegister) { + senderIcon = IconHelper.forName(par1IconRegister, "redStringSender"); + sideIcon = registerSideIcon(par1IconRegister); + } - @Override - public IIcon getIcon(int side, int meta) { - return side == meta ? senderIcon : sideIcon; - } + @SideOnly(Side.CLIENT) + public IIcon registerSideIcon(IIconRegister register) { + return IconHelper.forBlock(register, this); + } - @Override - public LexiconEntry getEntry(World world, int x, int y, int z, EntityPlayer player, ItemStack lexicon) { - return LexiconData.redString; - } + @Override + public IIcon getIcon(int side, int meta) { + return side == meta ? senderIcon : sideIcon; + } + @Override + public LexiconEntry getEntry(World world, int x, int y, int z, EntityPlayer player, ItemStack lexicon) { + return LexiconData.redString; + } } diff --git a/src/main/java/vazkii/botania/common/block/string/BlockRedStringComparator.java b/src/main/java/vazkii/botania/common/block/string/BlockRedStringComparator.java index 02db2de057..7415144db8 100644 --- a/src/main/java/vazkii/botania/common/block/string/BlockRedStringComparator.java +++ b/src/main/java/vazkii/botania/common/block/string/BlockRedStringComparator.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Nov 16, 2014, 10:19:28 PM (GMT)] */ package vazkii.botania.common.block.string; @@ -17,23 +17,22 @@ public class BlockRedStringComparator extends BlockRedString { - public BlockRedStringComparator() { - super(LibBlockNames.RED_STRING_COMPARATOR); - } + public BlockRedStringComparator() { + super(LibBlockNames.RED_STRING_COMPARATOR); + } - @Override - public boolean hasComparatorInputOverride() { - return true; - } + @Override + public boolean hasComparatorInputOverride() { + return true; + } - @Override - public int getComparatorInputOverride(World world, int x, int y, int z, int side) { - return ((TileRedStringComparator) world.getTileEntity(x, y, z)).getComparatorValue(); - } - - @Override - public TileRedString createNewTileEntity(World world, int meta) { - return new TileRedStringComparator(); - } + @Override + public int getComparatorInputOverride(World world, int x, int y, int z, int side) { + return ((TileRedStringComparator) world.getTileEntity(x, y, z)).getComparatorValue(); + } + @Override + public TileRedString createNewTileEntity(World world, int meta) { + return new TileRedStringComparator(); + } } diff --git a/src/main/java/vazkii/botania/common/block/string/BlockRedStringContainer.java b/src/main/java/vazkii/botania/common/block/string/BlockRedStringContainer.java index 3fc3f6cd05..351d7690c9 100644 --- a/src/main/java/vazkii/botania/common/block/string/BlockRedStringContainer.java +++ b/src/main/java/vazkii/botania/common/block/string/BlockRedStringContainer.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Nov 14, 2014, 5:29:56 PM (GMT)] */ package vazkii.botania.common.block.string; @@ -17,13 +17,12 @@ public class BlockRedStringContainer extends BlockRedString { - public BlockRedStringContainer() { - super(LibBlockNames.RED_STRING_CONTAINER); - } - - @Override - public TileRedString createNewTileEntity(World world, int meta) { - return new TileRedStringContainer(); - } + public BlockRedStringContainer() { + super(LibBlockNames.RED_STRING_CONTAINER); + } + @Override + public TileRedString createNewTileEntity(World world, int meta) { + return new TileRedStringContainer(); + } } diff --git a/src/main/java/vazkii/botania/common/block/string/BlockRedStringDispenser.java b/src/main/java/vazkii/botania/common/block/string/BlockRedStringDispenser.java index 9ef22db23a..83badcb59a 100644 --- a/src/main/java/vazkii/botania/common/block/string/BlockRedStringDispenser.java +++ b/src/main/java/vazkii/botania/common/block/string/BlockRedStringDispenser.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Nov 14, 2014, 10:59:20 PM (GMT)] */ package vazkii.botania.common.block.string; @@ -18,26 +18,25 @@ public class BlockRedStringDispenser extends BlockRedString { - public BlockRedStringDispenser() { - super(LibBlockNames.RED_STRING_DISPENSER); - } + public BlockRedStringDispenser() { + super(LibBlockNames.RED_STRING_DISPENSER); + } - @Override - public void onNeighborBlockChange(World world, int x, int y, int z, Block block) { - boolean power = world.isBlockIndirectlyGettingPowered(x, y, z) || world.isBlockIndirectlyGettingPowered(x, y + 1, z); - int meta = world.getBlockMetadata(x, y, z); - boolean powered = (meta & 8) != 0; + @Override + public void onNeighborBlockChange(World world, int x, int y, int z, Block block) { + boolean power = + world.isBlockIndirectlyGettingPowered(x, y, z) || world.isBlockIndirectlyGettingPowered(x, y + 1, z); + int meta = world.getBlockMetadata(x, y, z); + boolean powered = (meta & 8) != 0; - if(power && !powered) { - ((TileRedStringDispenser) world.getTileEntity(x, y, z)).tickDispenser(); - world.setBlockMetadataWithNotify(x, y, z, meta | 8, 4); - } else if(!power && powered) - world.setBlockMetadataWithNotify(x, y, z, meta & -9, 4); - } - - @Override - public TileRedString createNewTileEntity(World world, int meta) { - return new TileRedStringDispenser(); - } + if (power && !powered) { + ((TileRedStringDispenser) world.getTileEntity(x, y, z)).tickDispenser(); + world.setBlockMetadataWithNotify(x, y, z, meta | 8, 4); + } else if (!power && powered) world.setBlockMetadataWithNotify(x, y, z, meta & -9, 4); + } + @Override + public TileRedString createNewTileEntity(World world, int meta) { + return new TileRedStringDispenser(); + } } diff --git a/src/main/java/vazkii/botania/common/block/string/BlockRedStringFertilizer.java b/src/main/java/vazkii/botania/common/block/string/BlockRedStringFertilizer.java index 2483d69e02..d18dac5184 100644 --- a/src/main/java/vazkii/botania/common/block/string/BlockRedStringFertilizer.java +++ b/src/main/java/vazkii/botania/common/block/string/BlockRedStringFertilizer.java @@ -2,16 +2,15 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Nov 16, 2014, 7:10:46 PM (GMT)] */ package vazkii.botania.common.block.string; import java.util.Random; - import net.minecraft.block.IGrowable; import net.minecraft.world.World; import vazkii.botania.common.block.tile.string.TileRedString; @@ -20,28 +19,27 @@ public class BlockRedStringFertilizer extends BlockRedString implements IGrowable { - public BlockRedStringFertilizer() { - super(LibBlockNames.RED_STRING_FERTILIZER); - } - - @Override - public boolean func_149851_a(World world, int x, int y, int z, boolean something) { - return ((TileRedStringFertilizer) world.getTileEntity(x, y, z)).func_149851_a(world, something); - } - - @Override - public boolean func_149852_a(World world, Random rand, int x, int y, int z) { - return ((TileRedStringFertilizer) world.getTileEntity(x, y, z)).func_149852_a(world, rand); - } - - @Override - public void func_149853_b(World world, Random rand, int x, int y, int z) { - ((TileRedStringFertilizer) world.getTileEntity(x, y, z)).func_149853_b(world, rand); - } - - @Override - public TileRedString createNewTileEntity(World world, int meta) { - return new TileRedStringFertilizer(); - } - + public BlockRedStringFertilizer() { + super(LibBlockNames.RED_STRING_FERTILIZER); + } + + @Override + public boolean func_149851_a(World world, int x, int y, int z, boolean something) { + return ((TileRedStringFertilizer) world.getTileEntity(x, y, z)).func_149851_a(world, something); + } + + @Override + public boolean func_149852_a(World world, Random rand, int x, int y, int z) { + return ((TileRedStringFertilizer) world.getTileEntity(x, y, z)).func_149852_a(world, rand); + } + + @Override + public void func_149853_b(World world, Random rand, int x, int y, int z) { + ((TileRedStringFertilizer) world.getTileEntity(x, y, z)).func_149853_b(world, rand); + } + + @Override + public TileRedString createNewTileEntity(World world, int meta) { + return new TileRedStringFertilizer(); + } } diff --git a/src/main/java/vazkii/botania/common/block/string/BlockRedStringInterceptor.java b/src/main/java/vazkii/botania/common/block/string/BlockRedStringInterceptor.java index 6512281e1d..a87f16b3d0 100644 --- a/src/main/java/vazkii/botania/common/block/string/BlockRedStringInterceptor.java +++ b/src/main/java/vazkii/botania/common/block/string/BlockRedStringInterceptor.java @@ -2,16 +2,16 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Sep 21, 2015, 4:56:52 PM (GMT)] */ package vazkii.botania.common.block.string; +import cpw.mods.fml.common.eventhandler.SubscribeEvent; import java.util.Random; - import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; import net.minecraftforge.common.MinecraftForge; @@ -20,44 +20,42 @@ import vazkii.botania.common.block.tile.string.TileRedString; import vazkii.botania.common.block.tile.string.TileRedStringInterceptor; import vazkii.botania.common.lib.LibBlockNames; -import cpw.mods.fml.common.eventhandler.SubscribeEvent; public class BlockRedStringInterceptor extends BlockRedString { - public BlockRedStringInterceptor() { - super(LibBlockNames.RED_STRING_INTERCEPTOR); - MinecraftForge.EVENT_BUS.register(this); - } - - @SubscribeEvent - public void onInteract(PlayerInteractEvent event) { - if(event.action == Action.RIGHT_CLICK_BLOCK) - TileRedStringInterceptor.onInteract(event.entityPlayer, event.world, event.x, event.y, event.z); - } - - @Override - public boolean canProvidePower() { - return true; - } - - @Override - public int isProvidingWeakPower(IBlockAccess world, int x, int y, int z, int side) { - return (world.getBlockMetadata(x, y, z) & 8) == 0 ? 0 : 15; - } - - @Override - public void updateTick(World world, int x, int y, int z, Random update) { - world.setBlockMetadataWithNotify(x, y, z, world.getBlockMetadata(x, y, z) & -9, 1 | 2); - } - - @Override - public int tickRate(World p_149738_1_) { - return 2; - } - - @Override - public TileRedString createNewTileEntity(World world, int meta) { - return new TileRedStringInterceptor(); - } - + public BlockRedStringInterceptor() { + super(LibBlockNames.RED_STRING_INTERCEPTOR); + MinecraftForge.EVENT_BUS.register(this); + } + + @SubscribeEvent + public void onInteract(PlayerInteractEvent event) { + if (event.action == Action.RIGHT_CLICK_BLOCK) + TileRedStringInterceptor.onInteract(event.entityPlayer, event.world, event.x, event.y, event.z); + } + + @Override + public boolean canProvidePower() { + return true; + } + + @Override + public int isProvidingWeakPower(IBlockAccess world, int x, int y, int z, int side) { + return (world.getBlockMetadata(x, y, z) & 8) == 0 ? 0 : 15; + } + + @Override + public void updateTick(World world, int x, int y, int z, Random update) { + world.setBlockMetadataWithNotify(x, y, z, world.getBlockMetadata(x, y, z) & -9, 1 | 2); + } + + @Override + public int tickRate(World p_149738_1_) { + return 2; + } + + @Override + public TileRedString createNewTileEntity(World world, int meta) { + return new TileRedStringInterceptor(); + } } diff --git a/src/main/java/vazkii/botania/common/block/string/BlockRedStringRelay.java b/src/main/java/vazkii/botania/common/block/string/BlockRedStringRelay.java index 0a291ff0e7..eaa77f78bb 100644 --- a/src/main/java/vazkii/botania/common/block/string/BlockRedStringRelay.java +++ b/src/main/java/vazkii/botania/common/block/string/BlockRedStringRelay.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Nov 16, 2014, 10:46:48 PM (GMT)] */ package vazkii.botania.common.block.string; @@ -17,13 +17,12 @@ public class BlockRedStringRelay extends BlockRedString { - public BlockRedStringRelay() { - super(LibBlockNames.RED_STRING_RELAY); - } - - @Override - public TileRedString createNewTileEntity(World world, int meta) { - return new TileRedStringRelay(); - } + public BlockRedStringRelay() { + super(LibBlockNames.RED_STRING_RELAY); + } + @Override + public TileRedString createNewTileEntity(World world, int meta) { + return new TileRedStringRelay(); + } } diff --git a/src/main/java/vazkii/botania/common/block/subtile/SubTileDecor.java b/src/main/java/vazkii/botania/common/block/subtile/SubTileDecor.java index 4eb580e278..60853b8592 100644 --- a/src/main/java/vazkii/botania/common/block/subtile/SubTileDecor.java +++ b/src/main/java/vazkii/botania/common/block/subtile/SubTileDecor.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Sep 28, 2015, 10:17:01 PM (GMT)] */ package vazkii.botania.common.block.subtile; @@ -14,13 +14,14 @@ public class SubTileDecor extends SubTileEntity { - @Override - public boolean canUpdate() { - return false; - } + @Override + public boolean canUpdate() { + return false; + } - public static class Daybloom extends SubTileDecor { } - public static class Nightshade extends SubTileDecor { } - public static class Hydroangeas extends SubTileDecor { } + public static class Daybloom extends SubTileDecor {} + public static class Nightshade extends SubTileDecor {} + + public static class Hydroangeas extends SubTileDecor {} } diff --git a/src/main/java/vazkii/botania/common/block/subtile/SubTileManastar.java b/src/main/java/vazkii/botania/common/block/subtile/SubTileManastar.java index 4c5c45c192..4a90afede0 100644 --- a/src/main/java/vazkii/botania/common/block/subtile/SubTileManastar.java +++ b/src/main/java/vazkii/botania/common/block/subtile/SubTileManastar.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jun 6, 2014, 9:57:19 PM (GMT)] */ package vazkii.botania.common.block.subtile; @@ -21,31 +21,39 @@ public class SubTileManastar extends SubTileEntity { - int manaLastTick = -1; - - @Override - public void onUpdate() { - super.onUpdate(); - - int mana = 0; - for(ForgeDirection dir : LibMisc.CARDINAL_DIRECTIONS) { - TileEntity tile = supertile.getWorldObj().getTileEntity(supertile.xCoord + dir.offsetX, supertile.yCoord, supertile.zCoord + dir.offsetZ); - if(tile instanceof IManaPool) - mana += ((IManaPool) tile).getCurrentMana(); - } - - if(manaLastTick != -1 && mana != manaLastTick && Math.random() > 0.6) { - boolean more = mana > manaLastTick; - Botania.proxy.wispFX(supertile.getWorldObj(), supertile.xCoord + 0.55 + Math.random() * 0.2 - 0.1, supertile.yCoord + 0.75 + Math.random() * 0.2 - 0.1, supertile.zCoord + 0.5, more ? 0.05F : 1F, 0.05F, more ? 1F : 0.05F, (float) Math.random() / 7, (float) -Math.random() / 50); - } - - if(ticksExisted % 60 == 0) - manaLastTick = mana; - } - - @Override - public LexiconEntry getEntry() { - return LexiconData.manastar; - } - + int manaLastTick = -1; + + @Override + public void onUpdate() { + super.onUpdate(); + + int mana = 0; + for (ForgeDirection dir : LibMisc.CARDINAL_DIRECTIONS) { + TileEntity tile = supertile + .getWorldObj() + .getTileEntity(supertile.xCoord + dir.offsetX, supertile.yCoord, supertile.zCoord + dir.offsetZ); + if (tile instanceof IManaPool) mana += ((IManaPool) tile).getCurrentMana(); + } + + if (manaLastTick != -1 && mana != manaLastTick && Math.random() > 0.6) { + boolean more = mana > manaLastTick; + Botania.proxy.wispFX( + supertile.getWorldObj(), + supertile.xCoord + 0.55 + Math.random() * 0.2 - 0.1, + supertile.yCoord + 0.75 + Math.random() * 0.2 - 0.1, + supertile.zCoord + 0.5, + more ? 0.05F : 1F, + 0.05F, + more ? 1F : 0.05F, + (float) Math.random() / 7, + (float) -Math.random() / 50); + } + + if (ticksExisted % 60 == 0) manaLastTick = mana; + } + + @Override + public LexiconEntry getEntry() { + return LexiconData.manastar; + } } diff --git a/src/main/java/vazkii/botania/common/block/subtile/SubTilePureDaisy.java b/src/main/java/vazkii/botania/common/block/subtile/SubTilePureDaisy.java index 0f2b780e35..c17b965dd4 100644 --- a/src/main/java/vazkii/botania/common/block/subtile/SubTilePureDaisy.java +++ b/src/main/java/vazkii/botania/common/block/subtile/SubTilePureDaisy.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jan 28, 2014, 9:09:39 PM (GMT)] */ package vazkii.botania.common.block.subtile; @@ -25,95 +25,109 @@ public class SubTilePureDaisy extends SubTileEntity { - private static final String TAG_POSITION = "position"; - private static final String TAG_TICKS_REMAINING = "ticksRemaining"; - - private static final int TOTAL_TIME = 1200; - private static final int TIME_PER = TOTAL_TIME / 8; - - private static final int[][] POSITIONS = new int[][] { - { -1, 0, -1 }, - { -1, 0, 0 }, - { -1, 0, 1 }, - { 0, 0, 1 }, - { 1, 0, 1 }, - { 1, 0, 0 }, - { 1, 0, -1 }, - { 0, 0, -1 }, - }; - - int positionAt = 0; - int[] ticksRemaining = new int[] { TIME_PER, TIME_PER, TIME_PER, TIME_PER, TIME_PER, TIME_PER, TIME_PER, TIME_PER }; - - @Override - public void onUpdate() { - super.onUpdate(); - - positionAt++; - if(positionAt == POSITIONS.length) - positionAt = 0; - - int[] acoords = POSITIONS[positionAt]; - ChunkCoordinates coords = new ChunkCoordinates(supertile.xCoord + acoords[0], supertile.yCoord + acoords[1], supertile.zCoord + acoords[2]); - World world = supertile.getWorldObj(); - if(!world.isAirBlock(coords.posX, coords.posY, coords.posZ)) { - Block block = world.getBlock(coords.posX, coords.posY, coords.posZ); - int meta = world.getBlockMetadata(coords.posX, coords.posY, coords.posZ); - RecipePureDaisy recipe = null; - for(RecipePureDaisy recipe_ : BotaniaAPI.pureDaisyRecipes) - if(recipe_.matches(world, coords.posX, coords.posY, coords.posZ, this, block, meta)) { - recipe = recipe_; - break; - } - - - if(recipe != null) { - ticksRemaining[positionAt] = ticksRemaining[positionAt] - 1; - - Botania.proxy.sparkleFX(supertile.getWorldObj(), coords.posX + Math.random(), coords.posY + Math.random(), coords.posZ + Math.random(), 1F, 1F, 1F, (float) Math.random(), 5); - - if(ticksRemaining[positionAt] <= 0) { - ticksRemaining[positionAt] = TIME_PER; - - if(recipe.set(world,coords.posX, coords.posY, coords.posZ, this)) { - for(int i = 0; i < 25; i++) { - double x = coords.posX + Math.random(); - double y = coords.posY + Math.random() + 0.5; - double z = coords.posZ + Math.random(); - - Botania.proxy.wispFX(supertile.getWorldObj(), x, y, z, 1F, 1F, 1F, (float) Math.random() / 2F); - } - if(ConfigHandler.blockBreakParticles) - supertile.getWorldObj().playAuxSFX(2001, coords.posX, coords.posY, coords.posZ, Block.getIdFromBlock(recipe.getOutput()) + (recipe.getOutputMeta() << 12)); - } - } - } else ticksRemaining[positionAt] = TIME_PER; - } - } - - @Override - public RadiusDescriptor getRadius() { - return new RadiusDescriptor.Square(toChunkCoordinates(), 1); - } - - @Override - public void readFromPacketNBT(NBTTagCompound cmp) { - positionAt = cmp.getInteger(TAG_POSITION); - - if(supertile.getWorldObj() != null && !supertile.getWorldObj().isRemote) - for(int i = 0; i < ticksRemaining.length; i++) - ticksRemaining[i] = cmp.getInteger(TAG_TICKS_REMAINING + i); - } - - @Override - public void writeToPacketNBT(NBTTagCompound cmp) { - cmp.setInteger(TAG_POSITION, positionAt); - for(int i = 0; i < ticksRemaining.length; i++) - cmp.setInteger(TAG_TICKS_REMAINING + i, ticksRemaining[i]); - } - - @Override - public LexiconEntry getEntry() { - return LexiconData.pureDaisy; - } + private static final String TAG_POSITION = "position"; + private static final String TAG_TICKS_REMAINING = "ticksRemaining"; + + private static final int TOTAL_TIME = 1200; + private static final int TIME_PER = TOTAL_TIME / 8; + + private static final int[][] POSITIONS = new int[][] { + {-1, 0, -1}, + {-1, 0, 0}, + {-1, 0, 1}, + {0, 0, 1}, + {1, 0, 1}, + {1, 0, 0}, + {1, 0, -1}, + {0, 0, -1}, + }; + + int positionAt = 0; + int[] ticksRemaining = new int[] {TIME_PER, TIME_PER, TIME_PER, TIME_PER, TIME_PER, TIME_PER, TIME_PER, TIME_PER}; + + @Override + public void onUpdate() { + super.onUpdate(); + + positionAt++; + if (positionAt == POSITIONS.length) positionAt = 0; + + int[] acoords = POSITIONS[positionAt]; + ChunkCoordinates coords = new ChunkCoordinates( + supertile.xCoord + acoords[0], supertile.yCoord + acoords[1], supertile.zCoord + acoords[2]); + World world = supertile.getWorldObj(); + if (!world.isAirBlock(coords.posX, coords.posY, coords.posZ)) { + Block block = world.getBlock(coords.posX, coords.posY, coords.posZ); + int meta = world.getBlockMetadata(coords.posX, coords.posY, coords.posZ); + RecipePureDaisy recipe = null; + for (RecipePureDaisy recipe_ : BotaniaAPI.pureDaisyRecipes) + if (recipe_.matches(world, coords.posX, coords.posY, coords.posZ, this, block, meta)) { + recipe = recipe_; + break; + } + + if (recipe != null) { + ticksRemaining[positionAt] = ticksRemaining[positionAt] - 1; + + Botania.proxy.sparkleFX( + supertile.getWorldObj(), + coords.posX + Math.random(), + coords.posY + Math.random(), + coords.posZ + Math.random(), + 1F, + 1F, + 1F, + (float) Math.random(), + 5); + + if (ticksRemaining[positionAt] <= 0) { + ticksRemaining[positionAt] = TIME_PER; + + if (recipe.set(world, coords.posX, coords.posY, coords.posZ, this)) { + for (int i = 0; i < 25; i++) { + double x = coords.posX + Math.random(); + double y = coords.posY + Math.random() + 0.5; + double z = coords.posZ + Math.random(); + + Botania.proxy.wispFX( + supertile.getWorldObj(), x, y, z, 1F, 1F, 1F, (float) Math.random() / 2F); + } + if (ConfigHandler.blockBreakParticles) + supertile + .getWorldObj() + .playAuxSFX( + 2001, + coords.posX, + coords.posY, + coords.posZ, + Block.getIdFromBlock(recipe.getOutput()) + (recipe.getOutputMeta() << 12)); + } + } + } else ticksRemaining[positionAt] = TIME_PER; + } + } + + @Override + public RadiusDescriptor getRadius() { + return new RadiusDescriptor.Square(toChunkCoordinates(), 1); + } + + @Override + public void readFromPacketNBT(NBTTagCompound cmp) { + positionAt = cmp.getInteger(TAG_POSITION); + + if (supertile.getWorldObj() != null && !supertile.getWorldObj().isRemote) + for (int i = 0; i < ticksRemaining.length; i++) ticksRemaining[i] = cmp.getInteger(TAG_TICKS_REMAINING + i); + } + + @Override + public void writeToPacketNBT(NBTTagCompound cmp) { + cmp.setInteger(TAG_POSITION, positionAt); + for (int i = 0; i < ticksRemaining.length; i++) cmp.setInteger(TAG_TICKS_REMAINING + i, ticksRemaining[i]); + } + + @Override + public LexiconEntry getEntry() { + return LexiconData.pureDaisy; + } } diff --git a/src/main/java/vazkii/botania/common/block/subtile/functional/SubTileAgricarnation.java b/src/main/java/vazkii/botania/common/block/subtile/functional/SubTileAgricarnation.java index e6392a57ec..7982591bff 100644 --- a/src/main/java/vazkii/botania/common/block/subtile/functional/SubTileAgricarnation.java +++ b/src/main/java/vazkii/botania/common/block/subtile/functional/SubTileAgricarnation.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Mar 19, 2014, 10:16:53 PM (GMT)] */ package vazkii.botania.common.block.subtile.functional; @@ -25,78 +25,100 @@ public class SubTileAgricarnation extends SubTileFunctional { - private static final int RANGE = 5; - private static final int RANGE_MINI = 2; - - @Override - public void onUpdate() { - super.onUpdate(); - - if(ticksExisted % 6 == 0 && redstoneSignal == 0) { - int range = getRange(); - int x = supertile.xCoord + supertile.getWorldObj().rand.nextInt(range * 2 + 1) - range; - int z = supertile.zCoord + supertile.getWorldObj().rand.nextInt(range * 2 + 1) - range; - - for(int i = 4; i > -2; i--) { - int y = supertile.yCoord + i; - - if(supertile.getWorldObj().isAirBlock(x, y, z)) - continue; - - if(isPlant(x, y, z) && mana > 5) { - Block block = supertile.getWorldObj().getBlock(x, y, z); - mana -= 5; - supertile.getWorldObj().scheduleBlockUpdate(x, y, z, block, 1); - if(ConfigHandler.blockBreakParticles) - supertile.getWorldObj().playAuxSFX(2005, x, y, z, 6 + supertile.getWorldObj().rand.nextInt(4)); - supertile.getWorldObj().playSoundEffect(x, y, z, "botania:agricarnation", 0.01F, 0.5F + (float) Math.random() * 0.5F); - - break; - } - } - } - } - - @Override - public boolean acceptsRedstone() { - return true; - } - - boolean isPlant(int x, int y, int z) { - Block block = supertile.getWorldObj().getBlock(x, y, z); - if(block == Blocks.grass || block == Blocks.leaves || block == Blocks.leaves2 || block instanceof BlockBush && !(block instanceof BlockCrops) && !(block instanceof BlockSapling)) - return false; - - Material mat = block.getMaterial(); - return mat != null && (mat == Material.plants || mat == Material.cactus || mat == Material.grass || mat == Material.leaves || mat == Material.gourd) && block instanceof IGrowable && ((IGrowable) block).func_149851_a(supertile.getWorldObj(), x, y, z, supertile.getWorldObj().isRemote); - } - - @Override - public int getColor() { - return 0x8EF828; - } - - @Override - public int getMaxMana() { - return 200; - } - - public int getRange() { - return RANGE; - } - - @Override - public RadiusDescriptor getRadius() { - return new RadiusDescriptor.Square(toChunkCoordinates(), getRange()); - } - - @Override - public LexiconEntry getEntry() { - return LexiconData.agricarnation; - } - - public static class Mini extends SubTileAgricarnation { - @Override public int getRange() { return RANGE_MINI; } - } - + private static final int RANGE = 5; + private static final int RANGE_MINI = 2; + + @Override + public void onUpdate() { + super.onUpdate(); + + if (ticksExisted % 6 == 0 && redstoneSignal == 0) { + int range = getRange(); + int x = supertile.xCoord + supertile.getWorldObj().rand.nextInt(range * 2 + 1) - range; + int z = supertile.zCoord + supertile.getWorldObj().rand.nextInt(range * 2 + 1) - range; + + for (int i = 4; i > -2; i--) { + int y = supertile.yCoord + i; + + if (supertile.getWorldObj().isAirBlock(x, y, z)) continue; + + if (isPlant(x, y, z) && mana > 5) { + Block block = supertile.getWorldObj().getBlock(x, y, z); + mana -= 5; + supertile.getWorldObj().scheduleBlockUpdate(x, y, z, block, 1); + if (ConfigHandler.blockBreakParticles) + supertile + .getWorldObj() + .playAuxSFX( + 2005, + x, + y, + z, + 6 + supertile.getWorldObj().rand.nextInt(4)); + supertile + .getWorldObj() + .playSoundEffect( + x, y, z, "botania:agricarnation", 0.01F, 0.5F + (float) Math.random() * 0.5F); + + break; + } + } + } + } + + @Override + public boolean acceptsRedstone() { + return true; + } + + boolean isPlant(int x, int y, int z) { + Block block = supertile.getWorldObj().getBlock(x, y, z); + if (block == Blocks.grass + || block == Blocks.leaves + || block == Blocks.leaves2 + || block instanceof BlockBush && !(block instanceof BlockCrops) && !(block instanceof BlockSapling)) + return false; + + Material mat = block.getMaterial(); + return mat != null + && (mat == Material.plants + || mat == Material.cactus + || mat == Material.grass + || mat == Material.leaves + || mat == Material.gourd) + && block instanceof IGrowable + && ((IGrowable) block) + .func_149851_a(supertile.getWorldObj(), x, y, z, supertile.getWorldObj().isRemote); + } + + @Override + public int getColor() { + return 0x8EF828; + } + + @Override + public int getMaxMana() { + return 200; + } + + public int getRange() { + return RANGE; + } + + @Override + public RadiusDescriptor getRadius() { + return new RadiusDescriptor.Square(toChunkCoordinates(), getRange()); + } + + @Override + public LexiconEntry getEntry() { + return LexiconData.agricarnation; + } + + public static class Mini extends SubTileAgricarnation { + @Override + public int getRange() { + return RANGE_MINI; + } + } } diff --git a/src/main/java/vazkii/botania/common/block/subtile/functional/SubTileBellethorn.java b/src/main/java/vazkii/botania/common/block/subtile/functional/SubTileBellethorn.java index 52604a8d68..6dfc2874be 100644 --- a/src/main/java/vazkii/botania/common/block/subtile/functional/SubTileBellethorn.java +++ b/src/main/java/vazkii/botania/common/block/subtile/functional/SubTileBellethorn.java @@ -2,16 +2,15 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jan 27, 2014, 2:47:40 PM (GMT)] */ package vazkii.botania.common.block.subtile.functional; import java.util.List; - import net.minecraft.command.IEntitySelector; import net.minecraft.entity.Entity; import net.minecraft.entity.EntityLivingBase; @@ -26,86 +25,94 @@ public class SubTileBellethorn extends SubTileFunctional { - public static final int RANGE = 6; - public static final int RANGE_MINI = 1; - - @Override - public int getColor() { - return 0xBA3421; - } - - @Override - public int getMaxMana() { - return 1000; - } - - @Override - public void onUpdate() { - super.onUpdate(); - - if(redstoneSignal > 0) - return; - - final int manaToUse = getManaCost(); - - if(ticksExisted % 5 == 0) { - int range = getRange(); - List entities = supertile.getWorldObj().getEntitiesWithinAABB(EntityLivingBase.class, AxisAlignedBB.getBoundingBox(supertile.xCoord - range, supertile.yCoord, supertile.zCoord - range, supertile.xCoord + range + 1, supertile.yCoord + 1, supertile.zCoord + range + 1)); - IEntitySelector selector = getSelector(); - - for(EntityLivingBase entity : entities) { - if(!selector.isEntityApplicable(entity)) - continue; - - if(entity.hurtTime == 0 && mana >= manaToUse) { - int dmg = 4; - if(entity instanceof EntityWitch) - dmg = 20; - - entity.attackEntityFrom(DamageSource.magic, dmg); - mana -= manaToUse; - break; - } - } - } - } - - @Override - public boolean acceptsRedstone() { - return true; - } - - public int getManaCost() { - return 24; - } - - public int getRange() { - return RANGE; - } - - public IEntitySelector getSelector() { - return new IEntitySelector() { - - @Override - public boolean isEntityApplicable(Entity entity) { - return !(entity instanceof EntityPlayer); - } - - }; - } - - @Override - public RadiusDescriptor getRadius() { - return new RadiusDescriptor.Square(toChunkCoordinates(), getRange()); - } - - @Override - public LexiconEntry getEntry() { - return LexiconData.bellethorne; - } - - public static class Mini extends SubTileBellethorn { - @Override public int getRange() { return RANGE_MINI; } - } - + public static final int RANGE = 6; + public static final int RANGE_MINI = 1; + + @Override + public int getColor() { + return 0xBA3421; + } + + @Override + public int getMaxMana() { + return 1000; + } + + @Override + public void onUpdate() { + super.onUpdate(); + + if (redstoneSignal > 0) return; + + final int manaToUse = getManaCost(); + + if (ticksExisted % 5 == 0) { + int range = getRange(); + List entities = supertile + .getWorldObj() + .getEntitiesWithinAABB( + EntityLivingBase.class, + AxisAlignedBB.getBoundingBox( + supertile.xCoord - range, + supertile.yCoord, + supertile.zCoord - range, + supertile.xCoord + range + 1, + supertile.yCoord + 1, + supertile.zCoord + range + 1)); + IEntitySelector selector = getSelector(); + + for (EntityLivingBase entity : entities) { + if (!selector.isEntityApplicable(entity)) continue; + + if (entity.hurtTime == 0 && mana >= manaToUse) { + int dmg = 4; + if (entity instanceof EntityWitch) dmg = 20; + + entity.attackEntityFrom(DamageSource.magic, dmg); + mana -= manaToUse; + break; + } + } + } + } + + @Override + public boolean acceptsRedstone() { + return true; + } + + public int getManaCost() { + return 24; + } + + public int getRange() { + return RANGE; + } + + public IEntitySelector getSelector() { + return new IEntitySelector() { + + @Override + public boolean isEntityApplicable(Entity entity) { + return !(entity instanceof EntityPlayer); + } + }; + } + + @Override + public RadiusDescriptor getRadius() { + return new RadiusDescriptor.Square(toChunkCoordinates(), getRange()); + } + + @Override + public LexiconEntry getEntry() { + return LexiconData.bellethorne; + } + + public static class Mini extends SubTileBellethorn { + @Override + public int getRange() { + return RANGE_MINI; + } + } } diff --git a/src/main/java/vazkii/botania/common/block/subtile/functional/SubTileBubbell.java b/src/main/java/vazkii/botania/common/block/subtile/functional/SubTileBubbell.java index 10c62757cd..536b4b484b 100644 --- a/src/main/java/vazkii/botania/common/block/subtile/functional/SubTileBubbell.java +++ b/src/main/java/vazkii/botania/common/block/subtile/functional/SubTileBubbell.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Apr 10, 2015, 10:28:42 PM (GMT)] */ package vazkii.botania.common.block.subtile.functional; @@ -26,88 +26,102 @@ public class SubTileBubbell extends SubTileFunctional { - private static final int RANGE = 12; - private static final int RANGE_MINI = 6; - private static final int COST_PER_TICK = 4; - private static final String TAG_RANGE = "range"; - - int range = 2; - - @Override - public void onUpdate() { - super.onUpdate(); - - if(mana > COST_PER_TICK) { - mana -= COST_PER_TICK; - - if(ticksExisted % 10 == 0 && range < getRange()) - range++; - - for(int i = -range; i < range + 1; i++) - for(int j = -range; j < range + 1; j++) - for(int k = -range; k < range + 1; k++) - if(MathHelper.pointDistanceSpace(i, j, k, 0, 0, 0) < range) { - Block block = supertile.getWorldObj().getBlock(supertile.xCoord + i, supertile.yCoord + j, supertile.zCoord + k); - if(block.getMaterial() == Material.water) { - supertile.getWorldObj().setBlock(supertile.xCoord + i, supertile.yCoord + j, supertile.zCoord + k, ModBlocks.fakeAir, 0, 2); - TileFakeAir air = (TileFakeAir) supertile.getWorldObj().getTileEntity(supertile.xCoord + i, supertile.yCoord + j, supertile.zCoord + k); - air.setFlower(supertile); - } - } - } - } - - public static boolean isValidBubbell(World world, int x, int y, int z) { - TileEntity tile = world.getTileEntity(x, y, z); - if(tile != null && tile instanceof ISubTileContainer) { - ISubTileContainer container = (ISubTileContainer) tile; - if(container.getSubTile() != null && container.getSubTile() instanceof SubTileBubbell) { - SubTileBubbell bubbell = (SubTileBubbell) container.getSubTile(); - return bubbell.mana > COST_PER_TICK; - } - } - - return false; - } - - @Override - public void writeToPacketNBT(NBTTagCompound cmp) { - super.writeToPacketNBT(cmp); - cmp.setInteger(TAG_RANGE, range); - } - - @Override - public void readFromPacketNBT(NBTTagCompound cmp) { - super.readFromPacketNBT(cmp); - range = cmp.getInteger(TAG_RANGE); - } - - @Override - public int getMaxMana() { - return 2000; - } - - @Override - public int getColor() { - return 0x0DCF89; - } - - public int getRange() { - return RANGE; - } - - @Override - public RadiusDescriptor getRadius() { - return new RadiusDescriptor.Circle(toChunkCoordinates(), range); - } - - @Override - public LexiconEntry getEntry() { - return LexiconData.bubbell; - } - - public static class Mini extends SubTileBubbell { - @Override public int getRange() { return RANGE_MINI; } - } - + private static final int RANGE = 12; + private static final int RANGE_MINI = 6; + private static final int COST_PER_TICK = 4; + private static final String TAG_RANGE = "range"; + + int range = 2; + + @Override + public void onUpdate() { + super.onUpdate(); + + if (mana > COST_PER_TICK) { + mana -= COST_PER_TICK; + + if (ticksExisted % 10 == 0 && range < getRange()) range++; + + for (int i = -range; i < range + 1; i++) + for (int j = -range; j < range + 1; j++) + for (int k = -range; k < range + 1; k++) + if (MathHelper.pointDistanceSpace(i, j, k, 0, 0, 0) < range) { + Block block = supertile + .getWorldObj() + .getBlock(supertile.xCoord + i, supertile.yCoord + j, supertile.zCoord + k); + if (block.getMaterial() == Material.water) { + supertile + .getWorldObj() + .setBlock( + supertile.xCoord + i, + supertile.yCoord + j, + supertile.zCoord + k, + ModBlocks.fakeAir, + 0, + 2); + TileFakeAir air = (TileFakeAir) supertile + .getWorldObj() + .getTileEntity( + supertile.xCoord + i, supertile.yCoord + j, supertile.zCoord + k); + air.setFlower(supertile); + } + } + } + } + + public static boolean isValidBubbell(World world, int x, int y, int z) { + TileEntity tile = world.getTileEntity(x, y, z); + if (tile != null && tile instanceof ISubTileContainer) { + ISubTileContainer container = (ISubTileContainer) tile; + if (container.getSubTile() != null && container.getSubTile() instanceof SubTileBubbell) { + SubTileBubbell bubbell = (SubTileBubbell) container.getSubTile(); + return bubbell.mana > COST_PER_TICK; + } + } + + return false; + } + + @Override + public void writeToPacketNBT(NBTTagCompound cmp) { + super.writeToPacketNBT(cmp); + cmp.setInteger(TAG_RANGE, range); + } + + @Override + public void readFromPacketNBT(NBTTagCompound cmp) { + super.readFromPacketNBT(cmp); + range = cmp.getInteger(TAG_RANGE); + } + + @Override + public int getMaxMana() { + return 2000; + } + + @Override + public int getColor() { + return 0x0DCF89; + } + + public int getRange() { + return RANGE; + } + + @Override + public RadiusDescriptor getRadius() { + return new RadiusDescriptor.Circle(toChunkCoordinates(), range); + } + + @Override + public LexiconEntry getEntry() { + return LexiconData.bubbell; + } + + public static class Mini extends SubTileBubbell { + @Override + public int getRange() { + return RANGE_MINI; + } + } } diff --git a/src/main/java/vazkii/botania/common/block/subtile/functional/SubTileClayconia.java b/src/main/java/vazkii/botania/common/block/subtile/functional/SubTileClayconia.java index 11e645f5b0..b284487663 100644 --- a/src/main/java/vazkii/botania/common/block/subtile/functional/SubTileClayconia.java +++ b/src/main/java/vazkii/botania/common/block/subtile/functional/SubTileClayconia.java @@ -2,17 +2,16 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [May 17, 2014, 12:05:37 AM (GMT)] */ package vazkii.botania.common.block.subtile.functional; import java.util.ArrayList; import java.util.List; - import net.minecraft.block.Block; import net.minecraft.entity.item.EntityItem; import net.minecraft.init.Items; @@ -26,84 +25,101 @@ public class SubTileClayconia extends SubTileFunctional { - private static final int COST = 80; - private static final int RANGE = 5; - private static final int RANGE_Y = 3; - - private static final int RANGE_MINI = 2; - private static final int RANGE_Y_MINI = 1; - - @Override - public void onUpdate() { - super.onUpdate(); - - if(!supertile.getWorldObj().isRemote && ticksExisted % 5 == 0) { - if(mana >= COST) { - ChunkCoordinates coords = getCoordsToPut(); - if(coords != null) { - supertile.getWorldObj().setBlockToAir(coords.posX, coords.posY, coords.posZ); - if(ConfigHandler.blockBreakParticles) - supertile.getWorldObj().playAuxSFX(2001, coords.posX, coords.posY, coords.posZ, Block.getIdFromBlock(Block.getBlockFromName("sand"))); - EntityItem item = new EntityItem(supertile.getWorldObj(), coords.posX + 0.5, coords.posY + 0.5, coords.posZ + 0.5, new ItemStack(Items.clay_ball)); - supertile.getWorldObj().spawnEntityInWorld(item); - mana -= COST; - } - } - } - } - - public ChunkCoordinates getCoordsToPut() { - List possibleCoords = new ArrayList(); - - int range = getRange(); - int rangeY = getRangeY(); - - for(int i = -range; i < range + 1; i++) - for(int j = -rangeY; j < rangeY + 1; j++) - for(int k = -range; k < range + 1; k++) { - int x = supertile.xCoord + i; - int y = supertile.yCoord + j; - int z = supertile.zCoord + k; - Block block = supertile.getWorldObj().getBlock(x, y, z); - if(block == Block.getBlockFromName("sand")) - possibleCoords.add(new ChunkCoordinates(x, y, z)); - } - - if(possibleCoords.isEmpty()) - return null; - return possibleCoords.get(supertile.getWorldObj().rand.nextInt(possibleCoords.size())); - } - - @Override - public RadiusDescriptor getRadius() { - return new RadiusDescriptor.Square(toChunkCoordinates(), getRange()); - } - - public int getRange() { - return RANGE; - } - - public int getRangeY() { - return RANGE_Y; - } - - @Override - public int getColor() { - return 0x7B8792; - } - - @Override - public int getMaxMana() { - return 640; - } - - @Override - public LexiconEntry getEntry() { - return LexiconData.clayconia; - } - - public static class Mini extends SubTileClayconia { - @Override public int getRange() { return RANGE_MINI; } - @Override public int getRangeY() { return RANGE_Y_MINI; } - } + private static final int COST = 80; + private static final int RANGE = 5; + private static final int RANGE_Y = 3; + + private static final int RANGE_MINI = 2; + private static final int RANGE_Y_MINI = 1; + + @Override + public void onUpdate() { + super.onUpdate(); + + if (!supertile.getWorldObj().isRemote && ticksExisted % 5 == 0) { + if (mana >= COST) { + ChunkCoordinates coords = getCoordsToPut(); + if (coords != null) { + supertile.getWorldObj().setBlockToAir(coords.posX, coords.posY, coords.posZ); + if (ConfigHandler.blockBreakParticles) + supertile + .getWorldObj() + .playAuxSFX( + 2001, + coords.posX, + coords.posY, + coords.posZ, + Block.getIdFromBlock(Block.getBlockFromName("sand"))); + EntityItem item = new EntityItem( + supertile.getWorldObj(), + coords.posX + 0.5, + coords.posY + 0.5, + coords.posZ + 0.5, + new ItemStack(Items.clay_ball)); + supertile.getWorldObj().spawnEntityInWorld(item); + mana -= COST; + } + } + } + } + + public ChunkCoordinates getCoordsToPut() { + List possibleCoords = new ArrayList(); + + int range = getRange(); + int rangeY = getRangeY(); + + for (int i = -range; i < range + 1; i++) + for (int j = -rangeY; j < rangeY + 1; j++) + for (int k = -range; k < range + 1; k++) { + int x = supertile.xCoord + i; + int y = supertile.yCoord + j; + int z = supertile.zCoord + k; + Block block = supertile.getWorldObj().getBlock(x, y, z); + if (block == Block.getBlockFromName("sand")) possibleCoords.add(new ChunkCoordinates(x, y, z)); + } + + if (possibleCoords.isEmpty()) return null; + return possibleCoords.get(supertile.getWorldObj().rand.nextInt(possibleCoords.size())); + } + + @Override + public RadiusDescriptor getRadius() { + return new RadiusDescriptor.Square(toChunkCoordinates(), getRange()); + } + + public int getRange() { + return RANGE; + } + + public int getRangeY() { + return RANGE_Y; + } + + @Override + public int getColor() { + return 0x7B8792; + } + + @Override + public int getMaxMana() { + return 640; + } + + @Override + public LexiconEntry getEntry() { + return LexiconData.clayconia; + } + + public static class Mini extends SubTileClayconia { + @Override + public int getRange() { + return RANGE_MINI; + } + + @Override + public int getRangeY() { + return RANGE_Y_MINI; + } + } } diff --git a/src/main/java/vazkii/botania/common/block/subtile/functional/SubTileDaffomill.java b/src/main/java/vazkii/botania/common/block/subtile/functional/SubTileDaffomill.java index a4fd3f0b35..b4a3b3f683 100644 --- a/src/main/java/vazkii/botania/common/block/subtile/functional/SubTileDaffomill.java +++ b/src/main/java/vazkii/botania/common/block/subtile/functional/SubTileDaffomill.java @@ -2,16 +2,15 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jun 20, 2014, 11:43:02 PM (GMT)] */ package vazkii.botania.common.block.subtile.functional; import java.util.List; - import net.minecraft.entity.item.EntityItem; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; @@ -26,124 +25,133 @@ public class SubTileDaffomill extends SubTileFunctional { - private static final String TAG_ORIENTATION = "orientation"; - private static final String TAG_WIND_TICKS = "windTicks"; - - int windTicks = 0; - int orientation = 0; - - @Override - public void onUpdate() { - super.onUpdate(); - - ForgeDirection dir = ForgeDirection.getOrientation(orientation + 2); - if(supertile.getWorldObj().rand.nextInt(4) == 0) - Botania.proxy.wispFX(supertile.getWorldObj(), supertile.xCoord + Math.random(), supertile.yCoord + Math.random(), supertile.zCoord + Math.random(), 0.05F, 0.05F, 0.05F, 0.25F + (float) Math.random() * 0.15F, dir.offsetX * 0.1F, dir.offsetY * 0.1F, dir.offsetZ * 0.1F); - - if(windTicks == 0 && mana > 0) { - windTicks = 20; - mana--; - } - - if(windTicks > 0 && redstoneSignal == 0) { - AxisAlignedBB axis = aabbForOrientation(); - - if(axis != null) { - List items = supertile.getWorldObj().getEntitiesWithinAABB(EntityItem.class, axis); - int slowdown = getSlowdownFactor(); - for(EntityItem item : items) - if(!item.isDead && item.age >= slowdown) { - item.motionX += dir.offsetX * 0.05; - item.motionY += dir.offsetY * 0.05; - item.motionZ += dir.offsetZ * 0.05; - } - } - - windTicks--; - } - } - - AxisAlignedBB aabbForOrientation() { - int x = supertile.xCoord; - int y = supertile.yCoord; - int z = supertile.zCoord; - int w = 2; - int h = 3; - int l = 16; - - AxisAlignedBB axis = null; - switch(orientation) { - case 0 : - axis = AxisAlignedBB.getBoundingBox(x - w, y - h, z - l, x + w + 1, y + h, z); - break; - case 1 : - axis = AxisAlignedBB.getBoundingBox(x - w, y - h, z + 1, x + w + 1, y + h, z + l + 1); - break; - case 2 : - axis = AxisAlignedBB.getBoundingBox(x - l, y - h, z - w, x, y + h, z + w + 1); - break; - case 3 : - axis = AxisAlignedBB.getBoundingBox(x + 1, y - h, z - w, x + l + 1, y + h, z + w + 1); - } - return axis; - } - - @Override - public boolean acceptsRedstone() { - return true; - } - - @Override - public boolean onWanded(EntityPlayer player, ItemStack wand) { - if(player == null) - return false; - - if(player.isSneaking()) { - if(!player.worldObj.isRemote) { - orientation = orientation == 3 ? 0 : orientation + 1; - sync(); - } - - return true; - } else return super.onWanded(player, wand); - } - - @Override - public RadiusDescriptor getRadius() { - AxisAlignedBB aabb = aabbForOrientation(); - aabb.minY = supertile.yCoord; - return new RadiusDescriptor.Rectangle(toChunkCoordinates(), aabb); - } - - @Override - public int getColor() { - return 0xD8BA00; - } - - @Override - public int getMaxMana() { - return 100; - } - - @Override - public LexiconEntry getEntry() { - return LexiconData.daffomill; - } - - @Override - public void writeToPacketNBT(NBTTagCompound cmp) { - super.writeToPacketNBT(cmp); - - cmp.setInteger(TAG_ORIENTATION, orientation); - cmp.setInteger(TAG_WIND_TICKS, windTicks); - } - - @Override - public void readFromPacketNBT(NBTTagCompound cmp) { - super.readFromPacketNBT(cmp); - - orientation = cmp.getInteger(TAG_ORIENTATION); - windTicks = cmp.getInteger(TAG_WIND_TICKS); - } - + private static final String TAG_ORIENTATION = "orientation"; + private static final String TAG_WIND_TICKS = "windTicks"; + + int windTicks = 0; + int orientation = 0; + + @Override + public void onUpdate() { + super.onUpdate(); + + ForgeDirection dir = ForgeDirection.getOrientation(orientation + 2); + if (supertile.getWorldObj().rand.nextInt(4) == 0) + Botania.proxy.wispFX( + supertile.getWorldObj(), + supertile.xCoord + Math.random(), + supertile.yCoord + Math.random(), + supertile.zCoord + Math.random(), + 0.05F, + 0.05F, + 0.05F, + 0.25F + (float) Math.random() * 0.15F, + dir.offsetX * 0.1F, + dir.offsetY * 0.1F, + dir.offsetZ * 0.1F); + + if (windTicks == 0 && mana > 0) { + windTicks = 20; + mana--; + } + + if (windTicks > 0 && redstoneSignal == 0) { + AxisAlignedBB axis = aabbForOrientation(); + + if (axis != null) { + List items = supertile.getWorldObj().getEntitiesWithinAABB(EntityItem.class, axis); + int slowdown = getSlowdownFactor(); + for (EntityItem item : items) + if (!item.isDead && item.age >= slowdown) { + item.motionX += dir.offsetX * 0.05; + item.motionY += dir.offsetY * 0.05; + item.motionZ += dir.offsetZ * 0.05; + } + } + + windTicks--; + } + } + + AxisAlignedBB aabbForOrientation() { + int x = supertile.xCoord; + int y = supertile.yCoord; + int z = supertile.zCoord; + int w = 2; + int h = 3; + int l = 16; + + AxisAlignedBB axis = null; + switch (orientation) { + case 0: + axis = AxisAlignedBB.getBoundingBox(x - w, y - h, z - l, x + w + 1, y + h, z); + break; + case 1: + axis = AxisAlignedBB.getBoundingBox(x - w, y - h, z + 1, x + w + 1, y + h, z + l + 1); + break; + case 2: + axis = AxisAlignedBB.getBoundingBox(x - l, y - h, z - w, x, y + h, z + w + 1); + break; + case 3: + axis = AxisAlignedBB.getBoundingBox(x + 1, y - h, z - w, x + l + 1, y + h, z + w + 1); + } + return axis; + } + + @Override + public boolean acceptsRedstone() { + return true; + } + + @Override + public boolean onWanded(EntityPlayer player, ItemStack wand) { + if (player == null) return false; + + if (player.isSneaking()) { + if (!player.worldObj.isRemote) { + orientation = orientation == 3 ? 0 : orientation + 1; + sync(); + } + + return true; + } else return super.onWanded(player, wand); + } + + @Override + public RadiusDescriptor getRadius() { + AxisAlignedBB aabb = aabbForOrientation(); + aabb.minY = supertile.yCoord; + return new RadiusDescriptor.Rectangle(toChunkCoordinates(), aabb); + } + + @Override + public int getColor() { + return 0xD8BA00; + } + + @Override + public int getMaxMana() { + return 100; + } + + @Override + public LexiconEntry getEntry() { + return LexiconData.daffomill; + } + + @Override + public void writeToPacketNBT(NBTTagCompound cmp) { + super.writeToPacketNBT(cmp); + + cmp.setInteger(TAG_ORIENTATION, orientation); + cmp.setInteger(TAG_WIND_TICKS, windTicks); + } + + @Override + public void readFromPacketNBT(NBTTagCompound cmp) { + super.readFromPacketNBT(cmp); + + orientation = cmp.getInteger(TAG_ORIENTATION); + windTicks = cmp.getInteger(TAG_WIND_TICKS); + } } diff --git a/src/main/java/vazkii/botania/common/block/subtile/functional/SubTileDreadthorn.java b/src/main/java/vazkii/botania/common/block/subtile/functional/SubTileDreadthorn.java index 332389f7bc..5537b7f753 100644 --- a/src/main/java/vazkii/botania/common/block/subtile/functional/SubTileDreadthorn.java +++ b/src/main/java/vazkii/botania/common/block/subtile/functional/SubTileDreadthorn.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [May 15, 2014, 4:25:24 PM (GMT)] */ package vazkii.botania.common.block.subtile.functional; @@ -18,31 +18,29 @@ public class SubTileDreadthorn extends SubTileBellethorn { - @Override - public int getColor() { - return 0x260B45; - } - - @Override - public IEntitySelector getSelector() { - return new IEntitySelector() { - - @Override - public boolean isEntityApplicable(Entity var1) { - return var1 instanceof EntityAnimal && ((EntityAnimal) var1).getGrowingAge() == 0; - } - - }; - } - - @Override - public int getManaCost() { - return 30; - } - - @Override - public LexiconEntry getEntry() { - return LexiconData.dreadthorne; - } - + @Override + public int getColor() { + return 0x260B45; + } + + @Override + public IEntitySelector getSelector() { + return new IEntitySelector() { + + @Override + public boolean isEntityApplicable(Entity var1) { + return var1 instanceof EntityAnimal && ((EntityAnimal) var1).getGrowingAge() == 0; + } + }; + } + + @Override + public int getManaCost() { + return 30; + } + + @Override + public LexiconEntry getEntry() { + return LexiconData.dreadthorne; + } } diff --git a/src/main/java/vazkii/botania/common/block/subtile/functional/SubTileExoflame.java b/src/main/java/vazkii/botania/common/block/subtile/functional/SubTileExoflame.java index 4684517eb6..6bf2ed0e12 100644 --- a/src/main/java/vazkii/botania/common/block/subtile/functional/SubTileExoflame.java +++ b/src/main/java/vazkii/botania/common/block/subtile/functional/SubTileExoflame.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Mar 19, 2014, 3:42:32 PM (GMT)] */ package vazkii.botania.common.block.subtile.functional; @@ -25,107 +25,101 @@ public class SubTileExoflame extends SubTileFunctional { - private static final int RANGE = 5; - private static final int RANGE_Y = 2; - - @Override - public void onUpdate() { - super.onUpdate(); - - boolean did = false; - int cost = 300; - - fireFurnaces : { - for(int i = -RANGE; i < RANGE + 1; i++) - for(int j = -RANGE_Y; j < RANGE_Y + 1; j++) - for(int k = -RANGE; k < RANGE + 1; k++) { - int x = supertile.xCoord + i; - int y = supertile.yCoord + j; - int z = supertile.zCoord + k; - - TileEntity tile = supertile.getWorldObj().getTileEntity(x, y, z); - Block block = supertile.getWorldObj().getBlock(x, y, z); - if(tile != null) { - if(tile instanceof TileEntityFurnace && (block == Blocks.furnace || block == Blocks.lit_furnace)) { - TileEntityFurnace furnace = (TileEntityFurnace) tile; - boolean canSmelt = canFurnaceSmelt(furnace); - if(canSmelt && mana > 2) { - if(furnace.furnaceBurnTime < 2) { - if(furnace.furnaceBurnTime == 0) - BlockFurnace.updateFurnaceBlockState(true, supertile.getWorldObj(), x, y, z); - furnace.furnaceBurnTime = 200; - mana = Math.max(0, mana - cost); - } - if(ticksExisted % 2 == 0) - furnace.furnaceCookTime = Math.min(199, furnace.furnaceCookTime + 1); - - did = true; - - if(mana <= 0) - break fireFurnaces; - } - } else if(tile instanceof IExoflameHeatable) { - IExoflameHeatable heatable = (IExoflameHeatable) tile; - - if(heatable.canSmelt() && mana > 2) { - if(heatable.getBurnTime() == 0) { - heatable.boostBurnTime(); - mana = Math.max(0, mana - cost); - } - - if(ticksExisted % 2 == 0) - heatable.boostCookTime(); - - if(mana <= 0) - break fireFurnaces; - } - } - } - } - } - - if(did) - sync(); - } - - public static boolean canFurnaceSmelt(TileEntityFurnace furnace){ - if(furnace.getStackInSlot(0) == null) - return false; - else { - ItemStack itemstack = FurnaceRecipes.smelting().getSmeltingResult(furnace.getStackInSlot(0)); - - if(itemstack == null) - return false; - - if(furnace.getStackInSlot(2) == null) - return true; - - if(!furnace.getStackInSlot(2).isItemEqual(itemstack)) - return false; - - int result = furnace.getStackInSlot(2).stackSize + itemstack.stackSize; - return result <= 64 && result <= itemstack.getMaxStackSize(); - } - } - - @Override - public RadiusDescriptor getRadius() { - return new RadiusDescriptor.Square(toChunkCoordinates(), RANGE); - } - - @Override - public int getMaxMana() { - return 300; - } - - @Override - public int getColor() { - return 0x661600; - } - - @Override - public LexiconEntry getEntry() { - return LexiconData.exoflame; - } - + private static final int RANGE = 5; + private static final int RANGE_Y = 2; + + @Override + public void onUpdate() { + super.onUpdate(); + + boolean did = false; + int cost = 300; + + fireFurnaces: + { + for (int i = -RANGE; i < RANGE + 1; i++) + for (int j = -RANGE_Y; j < RANGE_Y + 1; j++) + for (int k = -RANGE; k < RANGE + 1; k++) { + int x = supertile.xCoord + i; + int y = supertile.yCoord + j; + int z = supertile.zCoord + k; + + TileEntity tile = supertile.getWorldObj().getTileEntity(x, y, z); + Block block = supertile.getWorldObj().getBlock(x, y, z); + if (tile != null) { + if (tile instanceof TileEntityFurnace + && (block == Blocks.furnace || block == Blocks.lit_furnace)) { + TileEntityFurnace furnace = (TileEntityFurnace) tile; + boolean canSmelt = canFurnaceSmelt(furnace); + if (canSmelt && mana > 2) { + if (furnace.furnaceBurnTime < 2) { + if (furnace.furnaceBurnTime == 0) + BlockFurnace.updateFurnaceBlockState( + true, supertile.getWorldObj(), x, y, z); + furnace.furnaceBurnTime = 200; + mana = Math.max(0, mana - cost); + } + if (ticksExisted % 2 == 0) + furnace.furnaceCookTime = Math.min(199, furnace.furnaceCookTime + 1); + + did = true; + + if (mana <= 0) break fireFurnaces; + } + } else if (tile instanceof IExoflameHeatable) { + IExoflameHeatable heatable = (IExoflameHeatable) tile; + + if (heatable.canSmelt() && mana > 2) { + if (heatable.getBurnTime() == 0) { + heatable.boostBurnTime(); + mana = Math.max(0, mana - cost); + } + + if (ticksExisted % 2 == 0) heatable.boostCookTime(); + + if (mana <= 0) break fireFurnaces; + } + } + } + } + } + + if (did) sync(); + } + + public static boolean canFurnaceSmelt(TileEntityFurnace furnace) { + if (furnace.getStackInSlot(0) == null) return false; + else { + ItemStack itemstack = FurnaceRecipes.smelting().getSmeltingResult(furnace.getStackInSlot(0)); + + if (itemstack == null) return false; + + if (furnace.getStackInSlot(2) == null) return true; + + if (!furnace.getStackInSlot(2).isItemEqual(itemstack)) return false; + + int result = furnace.getStackInSlot(2).stackSize + itemstack.stackSize; + return result <= 64 && result <= itemstack.getMaxStackSize(); + } + } + + @Override + public RadiusDescriptor getRadius() { + return new RadiusDescriptor.Square(toChunkCoordinates(), RANGE); + } + + @Override + public int getMaxMana() { + return 300; + } + + @Override + public int getColor() { + return 0x661600; + } + + @Override + public LexiconEntry getEntry() { + return LexiconData.exoflame; + } } diff --git a/src/main/java/vazkii/botania/common/block/subtile/functional/SubTileFallenKanade.java b/src/main/java/vazkii/botania/common/block/subtile/functional/SubTileFallenKanade.java index 45f94df803..bab6d1102a 100644 --- a/src/main/java/vazkii/botania/common/block/subtile/functional/SubTileFallenKanade.java +++ b/src/main/java/vazkii/botania/common/block/subtile/functional/SubTileFallenKanade.java @@ -2,16 +2,15 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Mar 14, 2014, 8:54:11 PM (GMT)] */ package vazkii.botania.common.block.subtile.functional; import java.util.List; - import net.minecraft.entity.player.EntityPlayer; import net.minecraft.potion.Potion; import net.minecraft.potion.PotionEffect; @@ -23,43 +22,52 @@ public class SubTileFallenKanade extends SubTileFunctional { - private static final int RANGE = 2; - - @Override - public void onUpdate() { - super.onUpdate(); + private static final int RANGE = 2; - final int cost = 120; + @Override + public void onUpdate() { + super.onUpdate(); - if(!supertile.getWorldObj().isRemote && supertile.getWorldObj().provider.dimensionId != 1) { - List players = supertile.getWorldObj().getEntitiesWithinAABB(EntityPlayer.class, AxisAlignedBB.getBoundingBox(supertile.xCoord - RANGE, supertile.yCoord - RANGE, supertile.zCoord - RANGE, supertile.xCoord + RANGE + 1, supertile.yCoord + RANGE + 1, supertile.zCoord + RANGE + 1)); - for(EntityPlayer player : players) { - if(player.getActivePotionEffect(Potion.regeneration) == null && mana >= cost ) { - player.addPotionEffect(new PotionEffect(Potion.regeneration.id, 60, 2)); - mana -= cost; - } - } - } - } + final int cost = 120; - @Override - public RadiusDescriptor getRadius() { - return new RadiusDescriptor.Square(toChunkCoordinates(), RANGE); - } + if (!supertile.getWorldObj().isRemote && supertile.getWorldObj().provider.dimensionId != 1) { + List players = supertile + .getWorldObj() + .getEntitiesWithinAABB( + EntityPlayer.class, + AxisAlignedBB.getBoundingBox( + supertile.xCoord - RANGE, + supertile.yCoord - RANGE, + supertile.zCoord - RANGE, + supertile.xCoord + RANGE + 1, + supertile.yCoord + RANGE + 1, + supertile.zCoord + RANGE + 1)); + for (EntityPlayer player : players) { + if (player.getActivePotionEffect(Potion.regeneration) == null && mana >= cost) { + player.addPotionEffect(new PotionEffect(Potion.regeneration.id, 60, 2)); + mana -= cost; + } + } + } + } - @Override - public int getColor() { - return 0xFFFF00; - } + @Override + public RadiusDescriptor getRadius() { + return new RadiusDescriptor.Square(toChunkCoordinates(), RANGE); + } - @Override - public int getMaxMana() { - return 900; - } + @Override + public int getColor() { + return 0xFFFF00; + } - @Override - public LexiconEntry getEntry() { - return LexiconData.fallenKanade; - } + @Override + public int getMaxMana() { + return 900; + } + @Override + public LexiconEntry getEntry() { + return LexiconData.fallenKanade; + } } diff --git a/src/main/java/vazkii/botania/common/block/subtile/functional/SubTileHeiseiDream.java b/src/main/java/vazkii/botania/common/block/subtile/functional/SubTileHeiseiDream.java index 0c66e7fdc5..0129165459 100644 --- a/src/main/java/vazkii/botania/common/block/subtile/functional/SubTileHeiseiDream.java +++ b/src/main/java/vazkii/botania/common/block/subtile/functional/SubTileHeiseiDream.java @@ -2,17 +2,17 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Feb 16, 2014, 12:37:40 AM (GMT)] */ package vazkii.botania.common.block.subtile.functional; +import cpw.mods.fml.relauncher.ReflectionHelper; import java.util.ArrayList; import java.util.List; - import net.minecraft.entity.EntityLiving; import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.ai.EntityAIAttackOnCollide; @@ -25,89 +25,99 @@ import vazkii.botania.api.subtile.SubTileFunctional; import vazkii.botania.common.lexicon.LexiconData; import vazkii.botania.common.lib.LibObfuscation; -import cpw.mods.fml.relauncher.ReflectionHelper; public class SubTileHeiseiDream extends SubTileFunctional { - private static final int RANGE = 5; - - @Override - public void onUpdate() { - super.onUpdate(); - - final int cost = 100; - - List mobs = supertile.getWorldObj().getEntitiesWithinAABB(IMob.class, AxisAlignedBB.getBoundingBox(supertile.xCoord - RANGE, supertile.yCoord - RANGE, supertile.zCoord - RANGE, supertile.xCoord + RANGE + 1, supertile.yCoord + RANGE + 1, supertile.zCoord + RANGE + 1)); - if(mobs.size() > 1 && mana >= cost) - for(IMob mob : mobs) { - if(mob instanceof EntityLiving) { - EntityLiving entity = (EntityLiving) mob; - if(brainwashEntity(entity, mobs)) { - mana -= cost; - sync(); - break; - } - } - } - } - - public static boolean brainwashEntity(EntityLiving entity, List mobs) { - EntityLivingBase target = entity.getAttackTarget(); - boolean did = false; - - if(target == null || !(target instanceof IMob)) { - IMob newTarget; - do newTarget = mobs.get(entity.worldObj.rand.nextInt(mobs.size())); - while(newTarget == entity); - - if(newTarget instanceof EntityLiving) { - List entries = new ArrayList(entity.tasks.taskEntries); - entries.addAll(new ArrayList(entity.targetTasks.taskEntries)); - - for(EntityAITaskEntry entry : entries) - if(entry.action instanceof EntityAINearestAttackableTarget) { - messWithGetTargetAI((EntityAINearestAttackableTarget) entry.action, (EntityLiving) newTarget); - did = true; - } else if(entry.action instanceof EntityAIAttackOnCollide) { - messWithAttackOnCollideAI((EntityAIAttackOnCollide) entry.action); - did = true; - } - - if(did) - entity.setAttackTarget((EntityLiving) newTarget); - } - } - - return did; - } - - private static void messWithGetTargetAI(EntityAINearestAttackableTarget aiEntry, EntityLivingBase target) { - ReflectionHelper.setPrivateValue(EntityAINearestAttackableTarget.class, aiEntry, IMob.class, LibObfuscation.TARGET_CLASS); - ReflectionHelper.setPrivateValue(EntityAINearestAttackableTarget.class, aiEntry, target, LibObfuscation.TARGET_ENTITY); - } - - private static void messWithAttackOnCollideAI(EntityAIAttackOnCollide aiEntry) { - ReflectionHelper.setPrivateValue(EntityAIAttackOnCollide.class, aiEntry, IMob.class, LibObfuscation.CLASS_TARGET); - } - - @Override - public RadiusDescriptor getRadius() { - return new RadiusDescriptor.Square(toChunkCoordinates(), RANGE); - } - - @Override - public int getColor() { - return 0xFF219D; - } - - @Override - public int getMaxMana() { - return 1000; - } - - @Override - public LexiconEntry getEntry() { - return LexiconData.heiseiDream; - } - + private static final int RANGE = 5; + + @Override + public void onUpdate() { + super.onUpdate(); + + final int cost = 100; + + List mobs = supertile + .getWorldObj() + .getEntitiesWithinAABB( + IMob.class, + AxisAlignedBB.getBoundingBox( + supertile.xCoord - RANGE, + supertile.yCoord - RANGE, + supertile.zCoord - RANGE, + supertile.xCoord + RANGE + 1, + supertile.yCoord + RANGE + 1, + supertile.zCoord + RANGE + 1)); + if (mobs.size() > 1 && mana >= cost) + for (IMob mob : mobs) { + if (mob instanceof EntityLiving) { + EntityLiving entity = (EntityLiving) mob; + if (brainwashEntity(entity, mobs)) { + mana -= cost; + sync(); + break; + } + } + } + } + + public static boolean brainwashEntity(EntityLiving entity, List mobs) { + EntityLivingBase target = entity.getAttackTarget(); + boolean did = false; + + if (target == null || !(target instanceof IMob)) { + IMob newTarget; + do newTarget = mobs.get(entity.worldObj.rand.nextInt(mobs.size())); + while (newTarget == entity); + + if (newTarget instanceof EntityLiving) { + List entries = new ArrayList(entity.tasks.taskEntries); + entries.addAll(new ArrayList(entity.targetTasks.taskEntries)); + + for (EntityAITaskEntry entry : entries) + if (entry.action instanceof EntityAINearestAttackableTarget) { + messWithGetTargetAI((EntityAINearestAttackableTarget) entry.action, (EntityLiving) newTarget); + did = true; + } else if (entry.action instanceof EntityAIAttackOnCollide) { + messWithAttackOnCollideAI((EntityAIAttackOnCollide) entry.action); + did = true; + } + + if (did) entity.setAttackTarget((EntityLiving) newTarget); + } + } + + return did; + } + + private static void messWithGetTargetAI(EntityAINearestAttackableTarget aiEntry, EntityLivingBase target) { + ReflectionHelper.setPrivateValue( + EntityAINearestAttackableTarget.class, aiEntry, IMob.class, LibObfuscation.TARGET_CLASS); + ReflectionHelper.setPrivateValue( + EntityAINearestAttackableTarget.class, aiEntry, target, LibObfuscation.TARGET_ENTITY); + } + + private static void messWithAttackOnCollideAI(EntityAIAttackOnCollide aiEntry) { + ReflectionHelper.setPrivateValue( + EntityAIAttackOnCollide.class, aiEntry, IMob.class, LibObfuscation.CLASS_TARGET); + } + + @Override + public RadiusDescriptor getRadius() { + return new RadiusDescriptor.Square(toChunkCoordinates(), RANGE); + } + + @Override + public int getColor() { + return 0xFF219D; + } + + @Override + public int getMaxMana() { + return 1000; + } + + @Override + public LexiconEntry getEntry() { + return LexiconData.heiseiDream; + } } diff --git a/src/main/java/vazkii/botania/common/block/subtile/functional/SubTileHopperhock.java b/src/main/java/vazkii/botania/common/block/subtile/functional/SubTileHopperhock.java index 84aea3c2ca..6ea4e51598 100644 --- a/src/main/java/vazkii/botania/common/block/subtile/functional/SubTileHopperhock.java +++ b/src/main/java/vazkii/botania/common/block/subtile/functional/SubTileHopperhock.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Mar 20, 2014, 5:54:39 PM (GMT)] */ package vazkii.botania.common.block.subtile.functional; @@ -15,7 +15,6 @@ import java.util.List; import java.util.Set; import java.util.WeakHashMap; - import net.minecraft.block.Block; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.ScaledResolution; @@ -30,10 +29,7 @@ import net.minecraft.util.AxisAlignedBB; import net.minecraft.util.StatCollector; import net.minecraftforge.common.util.ForgeDirection; - import org.lwjgl.opengl.GL11; - -import scala.reflect.internal.util.WeakHashSet; import vazkii.botania.api.lexicon.LexiconEntry; import vazkii.botania.api.mana.IManaItem; import vazkii.botania.api.subtile.RadiusDescriptor; @@ -44,236 +40,251 @@ public class SubTileHopperhock extends SubTileFunctional { - private static final String TAG_FILTER_TYPE = "filterType"; - private static final int RANGE_MANA = 10; - private static final int RANGE = 6; - - private static final int RANGE_MANA_MINI = 2; - private static final int RANGE_MINI = 1; - - private static Set particled = Collections.newSetFromMap(new WeakHashMap()); - - int filterType = 0; - - @Override - public void onUpdate() { - super.onUpdate(); - - if(redstoneSignal > 0) - return; - - boolean pulledAny = false; - int range = getRange(); - - int x = supertile.xCoord; - int y = supertile.yCoord; - int z = supertile.zCoord; - - List items = supertile.getWorldObj().getEntitiesWithinAABB(EntityItem.class, AxisAlignedBB.getBoundingBox(x - range, y - range, z - range, x + range + 1, y + range + 1, z + range + 1)); - int slowdown = getSlowdownFactor(); - - for(EntityItem item : items) { - if(item.age < (60 + slowdown) || item.age >= 105 && item.age < 110 || item.isDead) - continue; - - ItemStack stack = item.getEntityItem(); - - IInventory invToPutItemIn = null; - ForgeDirection sideToPutItemIn = ForgeDirection.UNKNOWN; - boolean priorityInv = false; - int amountToPutIn = 0; - - for(ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS) { - int x_ = x + dir.offsetX; - int y_ = y + dir.offsetY; - int z_ = z + dir.offsetZ; - - IInventory inv = InventoryHelper.getInventory(supertile.getWorldObj(), x_, y_, z_); - if(inv != null) { - List filter = getFilterForInventory(inv, x_, y_, z_, true); - boolean canAccept = canAcceptItem(stack, filter, filterType); - int availablePut = supertile.getWorldObj().isRemote ? 1 : InventoryHelper.testInventoryInsertion(inv, stack, dir); - canAccept &= availablePut > 0; - - if(canAccept) { - boolean priority = !filter.isEmpty(); - - setInv : { - if(priorityInv && !priority) - break setInv; - - invToPutItemIn = inv; - priorityInv = priority; - sideToPutItemIn = dir.getOpposite(); - amountToPutIn = availablePut; - } - } - } - } - - if(invToPutItemIn != null && !item.isDead) { - boolean remote = supertile.getWorldObj().isRemote; - if(remote) { - if(!particled.contains(item)) { - SubTileSpectranthemum.spawnExplosionParticles(item, 3); - particled.add(item); - } - } else { - InventoryHelper.insertItemIntoInventory(invToPutItemIn, stack.splitStack(amountToPutIn), sideToPutItemIn, -1); - item.setEntityItemStack(stack); // Just in case someone subclasses EntityItem and changes something important. - invToPutItemIn.markDirty(); - if(item.getEntityItem().stackSize == 0) - item.setDead(); - pulledAny = true; - } - } - } - - if(pulledAny && mana > 1) - mana--; - } - - public boolean canAcceptItem(ItemStack stack, List filter, int filterType) { - if(stack == null) - return false; - - if(filter.isEmpty()) - return true; - - switch(filterType) { - case 0 : { // Accept items in frames only - boolean anyFilter = false; - for(ItemStack filterEntry : filter) { - if(filterEntry == null) - continue; - anyFilter = true; - - boolean itemEqual = stack.getItem() == filterEntry.getItem(); - boolean damageEqual = stack.getItemDamage() == filterEntry.getItemDamage(); - boolean nbtEqual = ItemStack.areItemStackTagsEqual(filterEntry, stack); - - if(itemEqual && damageEqual && nbtEqual) - return true; - - if(!stack.getHasSubtypes() && stack.isItemStackDamageable() && stack.getMaxStackSize() == 1 && itemEqual && nbtEqual) - return true; - - if(stack.getItem() instanceof IManaItem && itemEqual) - return true; - } - - return !anyFilter; - } - case 1 : return !canAcceptItem(stack, filter, 0); // Accept items not in frames only - default : return true; // Accept all items - } - } - - public List getFilterForInventory(IInventory inv, int x, int y, int z, boolean recursiveForDoubleChests) { - List filter = new ArrayList(); - - if(recursiveForDoubleChests) { - TileEntity tileEntity = supertile.getWorldObj().getTileEntity(x, y, z); - Block chest = supertile.getWorldObj().getBlock(x, y, z); - - if(tileEntity instanceof TileEntityChest) - for(ForgeDirection dir : LibMisc.CARDINAL_DIRECTIONS) - if(supertile.getWorldObj().getBlock(x + dir.offsetX, y, z + dir.offsetZ) == chest) { - filter.addAll(getFilterForInventory((IInventory) supertile.getWorldObj().getTileEntity(x + dir.offsetX, y, z + dir.offsetZ), x + dir.offsetX, y, z + dir.offsetZ, false)); - break; - } - } - - final int[] orientationToDir = new int[] { - 3, 4, 2, 5 - }; - - for(ForgeDirection dir : LibMisc.CARDINAL_DIRECTIONS) { - AxisAlignedBB aabb = AxisAlignedBB.getBoundingBox(x + dir.offsetX, y + dir.offsetY, z + dir.offsetZ, x + dir.offsetX + 1, y + dir.offsetY + 1, z + dir.offsetZ + 1); - List frames = supertile.getWorldObj().getEntitiesWithinAABB(EntityItemFrame.class, aabb); - for(EntityItemFrame frame : frames) { - int orientation = frame.hangingDirection; - if(orientationToDir[orientation] == dir.ordinal()) - filter.add(frame.getDisplayedItem()); - } - } - - return filter; - } - - @Override - public boolean acceptsRedstone() { - return true; - } - - @Override - public boolean onWanded(EntityPlayer player, ItemStack wand) { - if(player == null) - return false; - - if(player.isSneaking()) { - filterType = filterType == 2 ? 0 : filterType + 1; - sync(); - - return true; - } - else return super.onWanded(player, wand); - } - - @Override - public RadiusDescriptor getRadius() { - return new RadiusDescriptor.Square(toChunkCoordinates(), getRange()); - } - - public int getRange() { - return mana > 0 ? RANGE_MANA : RANGE; - } - - @Override - public void writeToPacketNBT(NBTTagCompound cmp) { - super.writeToPacketNBT(cmp); - - cmp.setInteger(TAG_FILTER_TYPE, filterType); - } - - @Override - public void readFromPacketNBT(NBTTagCompound cmp) { - super.readFromPacketNBT(cmp); - - filterType = cmp.getInteger(TAG_FILTER_TYPE); - } - - @Override - public void renderHUD(Minecraft mc, ScaledResolution res) { - super.renderHUD(mc, res); - - int color = getColor(); - String filter = StatCollector.translateToLocal("botaniamisc.filter" + filterType); - GL11.glEnable(GL11.GL_BLEND); - GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); - int x = res.getScaledWidth() / 2 - mc.fontRenderer.getStringWidth(filter) / 2; - int y = res.getScaledHeight() / 2 + 30; - - mc.fontRenderer.drawStringWithShadow(filter, x, y, color); - GL11.glDisable(GL11.GL_BLEND); - } - - @Override - public LexiconEntry getEntry() { - return LexiconData.hopperhock; - } - - @Override - public int getMaxMana() { - return 20; - } - - @Override - public int getColor() { - return 0x3F3F3F; - } - - public static class Mini extends SubTileHopperhock { - @Override public int getRange() { return mana > 0 ? RANGE_MANA_MINI : RANGE_MINI; } - } + private static final String TAG_FILTER_TYPE = "filterType"; + private static final int RANGE_MANA = 10; + private static final int RANGE = 6; + + private static final int RANGE_MANA_MINI = 2; + private static final int RANGE_MINI = 1; + + private static Set particled = Collections.newSetFromMap(new WeakHashMap()); + + int filterType = 0; + + @Override + public void onUpdate() { + super.onUpdate(); + + if (redstoneSignal > 0) return; + + boolean pulledAny = false; + int range = getRange(); + + int x = supertile.xCoord; + int y = supertile.yCoord; + int z = supertile.zCoord; + + List items = supertile + .getWorldObj() + .getEntitiesWithinAABB( + EntityItem.class, + AxisAlignedBB.getBoundingBox( + x - range, y - range, z - range, x + range + 1, y + range + 1, z + range + 1)); + int slowdown = getSlowdownFactor(); + + for (EntityItem item : items) { + if (item.age < (60 + slowdown) || item.age >= 105 && item.age < 110 || item.isDead) continue; + + ItemStack stack = item.getEntityItem(); + + IInventory invToPutItemIn = null; + ForgeDirection sideToPutItemIn = ForgeDirection.UNKNOWN; + boolean priorityInv = false; + int amountToPutIn = 0; + + for (ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS) { + int x_ = x + dir.offsetX; + int y_ = y + dir.offsetY; + int z_ = z + dir.offsetZ; + + IInventory inv = InventoryHelper.getInventory(supertile.getWorldObj(), x_, y_, z_); + if (inv != null) { + List filter = getFilterForInventory(inv, x_, y_, z_, true); + boolean canAccept = canAcceptItem(stack, filter, filterType); + int availablePut = supertile.getWorldObj().isRemote + ? 1 + : InventoryHelper.testInventoryInsertion(inv, stack, dir); + canAccept &= availablePut > 0; + + if (canAccept) { + boolean priority = !filter.isEmpty(); + + setInv: + { + if (priorityInv && !priority) break setInv; + + invToPutItemIn = inv; + priorityInv = priority; + sideToPutItemIn = dir.getOpposite(); + amountToPutIn = availablePut; + } + } + } + } + + if (invToPutItemIn != null && !item.isDead) { + boolean remote = supertile.getWorldObj().isRemote; + if (remote) { + if (!particled.contains(item)) { + SubTileSpectranthemum.spawnExplosionParticles(item, 3); + particled.add(item); + } + } else { + InventoryHelper.insertItemIntoInventory( + invToPutItemIn, stack.splitStack(amountToPutIn), sideToPutItemIn, -1); + item.setEntityItemStack( + stack); // Just in case someone subclasses EntityItem and changes something important. + invToPutItemIn.markDirty(); + if (item.getEntityItem().stackSize == 0) item.setDead(); + pulledAny = true; + } + } + } + + if (pulledAny && mana > 1) mana--; + } + + public boolean canAcceptItem(ItemStack stack, List filter, int filterType) { + if (stack == null) return false; + + if (filter.isEmpty()) return true; + + switch (filterType) { + case 0: { // Accept items in frames only + boolean anyFilter = false; + for (ItemStack filterEntry : filter) { + if (filterEntry == null) continue; + anyFilter = true; + + boolean itemEqual = stack.getItem() == filterEntry.getItem(); + boolean damageEqual = stack.getItemDamage() == filterEntry.getItemDamage(); + boolean nbtEqual = ItemStack.areItemStackTagsEqual(filterEntry, stack); + + if (itemEqual && damageEqual && nbtEqual) return true; + + if (!stack.getHasSubtypes() + && stack.isItemStackDamageable() + && stack.getMaxStackSize() == 1 + && itemEqual + && nbtEqual) return true; + + if (stack.getItem() instanceof IManaItem && itemEqual) return true; + } + + return !anyFilter; + } + case 1: + return !canAcceptItem(stack, filter, 0); // Accept items not in frames only + default: + return true; // Accept all items + } + } + + public List getFilterForInventory( + IInventory inv, int x, int y, int z, boolean recursiveForDoubleChests) { + List filter = new ArrayList(); + + if (recursiveForDoubleChests) { + TileEntity tileEntity = supertile.getWorldObj().getTileEntity(x, y, z); + Block chest = supertile.getWorldObj().getBlock(x, y, z); + + if (tileEntity instanceof TileEntityChest) + for (ForgeDirection dir : LibMisc.CARDINAL_DIRECTIONS) + if (supertile.getWorldObj().getBlock(x + dir.offsetX, y, z + dir.offsetZ) == chest) { + filter.addAll(getFilterForInventory( + (IInventory) supertile.getWorldObj().getTileEntity(x + dir.offsetX, y, z + dir.offsetZ), + x + dir.offsetX, + y, + z + dir.offsetZ, + false)); + break; + } + } + + final int[] orientationToDir = new int[] {3, 4, 2, 5}; + + for (ForgeDirection dir : LibMisc.CARDINAL_DIRECTIONS) { + AxisAlignedBB aabb = AxisAlignedBB.getBoundingBox( + x + dir.offsetX, + y + dir.offsetY, + z + dir.offsetZ, + x + dir.offsetX + 1, + y + dir.offsetY + 1, + z + dir.offsetZ + 1); + List frames = supertile.getWorldObj().getEntitiesWithinAABB(EntityItemFrame.class, aabb); + for (EntityItemFrame frame : frames) { + int orientation = frame.hangingDirection; + if (orientationToDir[orientation] == dir.ordinal()) filter.add(frame.getDisplayedItem()); + } + } + + return filter; + } + + @Override + public boolean acceptsRedstone() { + return true; + } + + @Override + public boolean onWanded(EntityPlayer player, ItemStack wand) { + if (player == null) return false; + + if (player.isSneaking()) { + filterType = filterType == 2 ? 0 : filterType + 1; + sync(); + + return true; + } else return super.onWanded(player, wand); + } + + @Override + public RadiusDescriptor getRadius() { + return new RadiusDescriptor.Square(toChunkCoordinates(), getRange()); + } + + public int getRange() { + return mana > 0 ? RANGE_MANA : RANGE; + } + + @Override + public void writeToPacketNBT(NBTTagCompound cmp) { + super.writeToPacketNBT(cmp); + + cmp.setInteger(TAG_FILTER_TYPE, filterType); + } + + @Override + public void readFromPacketNBT(NBTTagCompound cmp) { + super.readFromPacketNBT(cmp); + + filterType = cmp.getInteger(TAG_FILTER_TYPE); + } + + @Override + public void renderHUD(Minecraft mc, ScaledResolution res) { + super.renderHUD(mc, res); + + int color = getColor(); + String filter = StatCollector.translateToLocal("botaniamisc.filter" + filterType); + GL11.glEnable(GL11.GL_BLEND); + GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); + int x = res.getScaledWidth() / 2 - mc.fontRenderer.getStringWidth(filter) / 2; + int y = res.getScaledHeight() / 2 + 30; + + mc.fontRenderer.drawStringWithShadow(filter, x, y, color); + GL11.glDisable(GL11.GL_BLEND); + } + + @Override + public LexiconEntry getEntry() { + return LexiconData.hopperhock; + } + + @Override + public int getMaxMana() { + return 20; + } + + @Override + public int getColor() { + return 0x3F3F3F; + } + + public static class Mini extends SubTileHopperhock { + @Override + public int getRange() { + return mana > 0 ? RANGE_MANA_MINI : RANGE_MINI; + } + } } diff --git a/src/main/java/vazkii/botania/common/block/subtile/functional/SubTileHyacidus.java b/src/main/java/vazkii/botania/common/block/subtile/functional/SubTileHyacidus.java index c658d1d6a5..da02e35d8d 100644 --- a/src/main/java/vazkii/botania/common/block/subtile/functional/SubTileHyacidus.java +++ b/src/main/java/vazkii/botania/common/block/subtile/functional/SubTileHyacidus.java @@ -2,16 +2,15 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [May 15, 2014, 4:47:41 PM (GMT)] */ package vazkii.botania.common.block.subtile.functional; import java.util.List; - import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.EnumCreatureAttribute; import net.minecraft.entity.player.EntityPlayer; @@ -25,49 +24,61 @@ public class SubTileHyacidus extends SubTileFunctional { - private static final int RANGE = 6; - - @Override - public void onUpdate() { - super.onUpdate(); + private static final int RANGE = 6; - if(redstoneSignal > 0) - return; + @Override + public void onUpdate() { + super.onUpdate(); - final int cost = 20; + if (redstoneSignal > 0) return; - List entities = supertile.getWorldObj().getEntitiesWithinAABB(EntityLivingBase.class, AxisAlignedBB.getBoundingBox(supertile.xCoord - RANGE, supertile.yCoord - RANGE, supertile.zCoord - RANGE, supertile.xCoord + RANGE + 1, supertile.yCoord + RANGE + 1, supertile.zCoord + RANGE + 1)); - for(EntityLivingBase entity : entities) { - if(!(entity instanceof EntityPlayer) && entity.getActivePotionEffect(Potion.poison) == null && mana >= cost && !entity.worldObj.isRemote && entity.getCreatureAttribute() != EnumCreatureAttribute.UNDEAD) { - entity.addPotionEffect(new PotionEffect(Potion.poison.id, 60, 0)); - mana -= cost; - } - } - } + final int cost = 20; - @Override - public boolean acceptsRedstone() { - return true; - } + List entities = supertile + .getWorldObj() + .getEntitiesWithinAABB( + EntityLivingBase.class, + AxisAlignedBB.getBoundingBox( + supertile.xCoord - RANGE, + supertile.yCoord - RANGE, + supertile.zCoord - RANGE, + supertile.xCoord + RANGE + 1, + supertile.yCoord + RANGE + 1, + supertile.zCoord + RANGE + 1)); + for (EntityLivingBase entity : entities) { + if (!(entity instanceof EntityPlayer) + && entity.getActivePotionEffect(Potion.poison) == null + && mana >= cost + && !entity.worldObj.isRemote + && entity.getCreatureAttribute() != EnumCreatureAttribute.UNDEAD) { + entity.addPotionEffect(new PotionEffect(Potion.poison.id, 60, 0)); + mana -= cost; + } + } + } - @Override - public int getColor() { - return 0x8B438F; - } + @Override + public boolean acceptsRedstone() { + return true; + } - @Override - public int getMaxMana() { - return 180; - } + @Override + public int getColor() { + return 0x8B438F; + } - @Override - public RadiusDescriptor getRadius() { - return new RadiusDescriptor.Square(toChunkCoordinates(), RANGE); - } + @Override + public int getMaxMana() { + return 180; + } - @Override - public LexiconEntry getEntry() { - return LexiconData.hyacidus; - } + @Override + public RadiusDescriptor getRadius() { + return new RadiusDescriptor.Square(toChunkCoordinates(), RANGE); + } -} \ No newline at end of file + @Override + public LexiconEntry getEntry() { + return LexiconData.hyacidus; + } +} diff --git a/src/main/java/vazkii/botania/common/block/subtile/functional/SubTileJadedAmaranthus.java b/src/main/java/vazkii/botania/common/block/subtile/functional/SubTileJadedAmaranthus.java index 8501cd1796..4422d768cd 100644 --- a/src/main/java/vazkii/botania/common/block/subtile/functional/SubTileJadedAmaranthus.java +++ b/src/main/java/vazkii/botania/common/block/subtile/functional/SubTileJadedAmaranthus.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Mar 3, 2014, 10:31:29 PM (GMT)] */ package vazkii.botania.common.block.subtile.functional; @@ -21,65 +21,69 @@ public class SubTileJadedAmaranthus extends SubTileFunctional { - private static final int COST = 100; - int RANGE = 4; - - @Override - public void onUpdate() { - super.onUpdate(); - - if(redstoneSignal > 0) - return; - - if(mana >= COST && !supertile.getWorldObj().isRemote && ticksExisted % 30 == 0) { - int x = supertile.xCoord - RANGE + supertile.getWorldObj().rand.nextInt(RANGE * 2 + 1); - int y = supertile.yCoord + RANGE; - int z = supertile.zCoord - RANGE + supertile.getWorldObj().rand.nextInt(RANGE * 2 + 1); - - for(int i = 0; i < RANGE * 2; i++) { - Block blockAbove = supertile.getWorldObj().getBlock(x, y + 1, z); - if((supertile.getWorldObj().isAirBlock(x, y + 1, z) || blockAbove.isReplaceable(supertile.getWorldObj(), x, y + 1, z)) && blockAbove.getMaterial() != Material.water && ModBlocks.flower.canPlaceBlockAt(supertile.getWorldObj(), x, y + 1, z)) { - int color = supertile.getWorldObj().rand.nextInt(16); - if(ModBlocks.flower.canBlockStay(supertile.getWorldObj(), x, y + 1, z)) { - if(ConfigHandler.blockBreakParticles) - supertile.getWorldObj().playAuxSFX(2001, x, y + 1, z, Block.getIdFromBlock(ModBlocks.flower) + (color << 12)); - supertile.getWorldObj().setBlock(x, y + 1, z, ModBlocks.flower, color, 1 | 2); - } - - mana -= COST; - sync(); - - break; - } - - y--; - } - } - } - - @Override - public boolean acceptsRedstone() { - return true; - } - - @Override - public int getColor() { - return 0x961283; - } - - @Override - public RadiusDescriptor getRadius() { - return new RadiusDescriptor.Square(toChunkCoordinates(), RANGE); - } - - @Override - public LexiconEntry getEntry() { - return LexiconData.jadedAmaranthus; - } - - @Override - public int getMaxMana() { - return COST; - } - + private static final int COST = 100; + int RANGE = 4; + + @Override + public void onUpdate() { + super.onUpdate(); + + if (redstoneSignal > 0) return; + + if (mana >= COST && !supertile.getWorldObj().isRemote && ticksExisted % 30 == 0) { + int x = supertile.xCoord - RANGE + supertile.getWorldObj().rand.nextInt(RANGE * 2 + 1); + int y = supertile.yCoord + RANGE; + int z = supertile.zCoord - RANGE + supertile.getWorldObj().rand.nextInt(RANGE * 2 + 1); + + for (int i = 0; i < RANGE * 2; i++) { + Block blockAbove = supertile.getWorldObj().getBlock(x, y + 1, z); + if ((supertile.getWorldObj().isAirBlock(x, y + 1, z) + || blockAbove.isReplaceable(supertile.getWorldObj(), x, y + 1, z)) + && blockAbove.getMaterial() != Material.water + && ModBlocks.flower.canPlaceBlockAt(supertile.getWorldObj(), x, y + 1, z)) { + int color = supertile.getWorldObj().rand.nextInt(16); + if (ModBlocks.flower.canBlockStay(supertile.getWorldObj(), x, y + 1, z)) { + if (ConfigHandler.blockBreakParticles) + supertile + .getWorldObj() + .playAuxSFX( + 2001, x, y + 1, z, Block.getIdFromBlock(ModBlocks.flower) + (color << 12)); + supertile.getWorldObj().setBlock(x, y + 1, z, ModBlocks.flower, color, 1 | 2); + } + + mana -= COST; + sync(); + + break; + } + + y--; + } + } + } + + @Override + public boolean acceptsRedstone() { + return true; + } + + @Override + public int getColor() { + return 0x961283; + } + + @Override + public RadiusDescriptor getRadius() { + return new RadiusDescriptor.Square(toChunkCoordinates(), RANGE); + } + + @Override + public LexiconEntry getEntry() { + return LexiconData.jadedAmaranthus; + } + + @Override + public int getMaxMana() { + return COST; + } } diff --git a/src/main/java/vazkii/botania/common/block/subtile/functional/SubTileJiyuulia.java b/src/main/java/vazkii/botania/common/block/subtile/functional/SubTileJiyuulia.java index da2b4a75db..5982a77868 100644 --- a/src/main/java/vazkii/botania/common/block/subtile/functional/SubTileJiyuulia.java +++ b/src/main/java/vazkii/botania/common/block/subtile/functional/SubTileJiyuulia.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Apr 14, 2014, 11:40:51 PM (GMT)] */ package vazkii.botania.common.block.subtile.functional; @@ -15,29 +15,28 @@ public class SubTileJiyuulia extends SubTileTangleberrie { - @Override - double getMaxDistance() { - return 0; - } - - @Override - double getRange() { - return 8; - } - - @Override - float getMotionVelocity() { - return -super.getMotionVelocity() * 2; - } - - @Override - public int getColor() { - return 0xBD9ACA; - } - - @Override - public LexiconEntry getEntry() { - return LexiconData.jiyuulia; - } - + @Override + double getMaxDistance() { + return 0; + } + + @Override + double getRange() { + return 8; + } + + @Override + float getMotionVelocity() { + return -super.getMotionVelocity() * 2; + } + + @Override + public int getColor() { + return 0xBD9ACA; + } + + @Override + public LexiconEntry getEntry() { + return LexiconData.jiyuulia; + } } diff --git a/src/main/java/vazkii/botania/common/block/subtile/functional/SubTileLoonuim.java b/src/main/java/vazkii/botania/common/block/subtile/functional/SubTileLoonuim.java index ce14cfaed5..adc629a048 100644 --- a/src/main/java/vazkii/botania/common/block/subtile/functional/SubTileLoonuim.java +++ b/src/main/java/vazkii/botania/common/block/subtile/functional/SubTileLoonuim.java @@ -2,16 +2,15 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [May 31, 2014, 7:49:43 PM (GMT)] */ package vazkii.botania.common.block.subtile.functional; import java.util.Random; - import net.minecraft.entity.item.EntityItem; import net.minecraft.item.ItemStack; import net.minecraftforge.common.ChestGenHooks; @@ -23,57 +22,60 @@ public class SubTileLoonuim extends SubTileFunctional { - private static final int COST = 35000; - private static final int RANGE = 3; - - @Override - public void onUpdate() { - super.onUpdate(); - if(redstoneSignal == 0 && ticksExisted % 200 == 0 && mana >= COST) { - Random rand = supertile.getWorldObj().rand; + private static final int COST = 35000; + private static final int RANGE = 3; - ItemStack stack; - do { - stack = ChestGenHooks.getOneItem(ChestGenHooks.DUNGEON_CHEST, rand); - } while(stack == null || BotaniaAPI.looniumBlacklist.contains(stack.getItem())); + @Override + public void onUpdate() { + super.onUpdate(); + if (redstoneSignal == 0 && ticksExisted % 200 == 0 && mana >= COST) { + Random rand = supertile.getWorldObj().rand; - int bound = RANGE * 2 + 1; - EntityItem entity = new EntityItem(supertile.getWorldObj(), supertile.xCoord - RANGE + rand.nextInt(bound) , supertile.yCoord + 1, supertile.zCoord - RANGE + rand.nextInt(bound), stack); - entity.motionX = 0; - entity.motionY = 0; - entity.motionZ = 0; + ItemStack stack; + do { + stack = ChestGenHooks.getOneItem(ChestGenHooks.DUNGEON_CHEST, rand); + } while (stack == null || BotaniaAPI.looniumBlacklist.contains(stack.getItem())); - if(!supertile.getWorldObj().isRemote) - supertile.getWorldObj().spawnEntityInWorld(entity); + int bound = RANGE * 2 + 1; + EntityItem entity = new EntityItem( + supertile.getWorldObj(), + supertile.xCoord - RANGE + rand.nextInt(bound), + supertile.yCoord + 1, + supertile.zCoord - RANGE + rand.nextInt(bound), + stack); + entity.motionX = 0; + entity.motionY = 0; + entity.motionZ = 0; - mana -= COST; - sync(); - } - } + if (!supertile.getWorldObj().isRemote) supertile.getWorldObj().spawnEntityInWorld(entity); - @Override - public int getColor() { - return 0x274A00; - } + mana -= COST; + sync(); + } + } - @Override - public LexiconEntry getEntry() { - return LexiconData.loonium; - } + @Override + public int getColor() { + return 0x274A00; + } - @Override - public int getMaxMana() { - return COST; - } + @Override + public LexiconEntry getEntry() { + return LexiconData.loonium; + } - @Override - public boolean acceptsRedstone() { - return true; - } + @Override + public int getMaxMana() { + return COST; + } - @Override - public RadiusDescriptor getRadius() { - return new RadiusDescriptor.Square(toChunkCoordinates(), RANGE); - } + @Override + public boolean acceptsRedstone() { + return true; + } + @Override + public RadiusDescriptor getRadius() { + return new RadiusDescriptor.Square(toChunkCoordinates(), RANGE); + } } diff --git a/src/main/java/vazkii/botania/common/block/subtile/functional/SubTileMarimorphosis.java b/src/main/java/vazkii/botania/common/block/subtile/functional/SubTileMarimorphosis.java index fb2d58a898..937788a9d9 100644 --- a/src/main/java/vazkii/botania/common/block/subtile/functional/SubTileMarimorphosis.java +++ b/src/main/java/vazkii/botania/common/block/subtile/functional/SubTileMarimorphosis.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jan 29, 2015, 8:17:55 PM (GMT)] */ package vazkii.botania.common.block.subtile.functional; @@ -13,7 +13,6 @@ import java.util.ArrayList; import java.util.Arrays; import java.util.List; - import net.minecraft.block.Block; import net.minecraft.init.Blocks; import net.minecraft.item.ItemStack; @@ -29,122 +28,128 @@ public class SubTileMarimorphosis extends SubTileFunctional { - private static final int COST = 12; - private static final int RANGE = 8; - private static final int RANGE_Y = 5; - - private static final int RANGE_MINI = 2; - private static final int RANGE_Y_MINI = 1; - - private static final Type[] TYPES = new Type[] { - Type.FOREST, - Type.PLAINS, - Type.MOUNTAIN, - Type.MUSHROOM, - Type.SWAMP, - Type.SANDY, - Type.COLD, - Type.MESA - }; - - @Override - public void onUpdate() { - super.onUpdate(); - if(redstoneSignal > 0) - return; - - if(!supertile.getWorldObj().isRemote && mana >= COST && ticksExisted % 2 == 0) { - ChunkCoordinates coords = getCoordsToPut(); - if(coords != null) { - ItemStack stack = getStoneToPut(coords); - if(stack != null) { - Block block = Block.getBlockFromItem(stack.getItem()); - int meta = stack.getItemDamage(); - supertile.getWorldObj().setBlock(coords.posX, coords.posY, coords.posZ, block, meta, 1 | 2); - if(ConfigHandler.blockBreakParticles) - supertile.getWorldObj().playAuxSFX(2001, coords.posX, coords.posY, coords.posZ, Block.getIdFromBlock(block) + (meta << 12)); - - mana -= COST; - sync(); - } - } - } - } - - public ItemStack getStoneToPut(ChunkCoordinates coords) { - List types = Arrays.asList(BiomeDictionary.getTypesForBiome(supertile.getWorldObj().getBiomeGenForCoords(coords.posX, coords.posZ))); - - List values = new ArrayList(); - for(int i = 0; i < 8; i++) { - int times = 1; - if(types.contains(TYPES[i])) - times = 12; - - for(int j = 0; j < times; j++) - values.add(i); - } - - return new ItemStack(ModFluffBlocks.biomeStoneA, 1, values.get(supertile.getWorldObj().rand.nextInt(values.size()))); - } - - public ChunkCoordinates getCoordsToPut() { - List possibleCoords = new ArrayList(); - - int range = getRange(); - int rangeY = getRangeY(); - - for(int i = -range; i < range + 1; i++) - for(int j = -rangeY; j < rangeY; j++) - for(int k = -range; k < range + 1; k++) { - int x = supertile.xCoord + i; - int y = supertile.yCoord + j; - int z = supertile.zCoord + k; - Block block = supertile.getWorldObj().getBlock(x, y, z); - if(block != null && block.isReplaceableOreGen(supertile.getWorldObj(), x, y, z, Blocks.stone)) - possibleCoords.add(new ChunkCoordinates(x, y, z)); - } - - if(possibleCoords.isEmpty()) - return null; - return possibleCoords.get(supertile.getWorldObj().rand.nextInt(possibleCoords.size())); - } - - @Override - public RadiusDescriptor getRadius() { - return new RadiusDescriptor.Square(toChunkCoordinates(), getRange()); - } - - public int getRange() { - return RANGE; - } - - public int getRangeY() { - return RANGE_Y; - } - - @Override - public int getColor() { - return 0x769897; - } - - @Override - public boolean acceptsRedstone() { - return true; - } - - @Override - public int getMaxMana() { - return 1000; - } - - @Override - public LexiconEntry getEntry() { - return LexiconData.marimorphosis; - } - - public static class Mini extends SubTileMarimorphosis { - @Override public int getRange() { return RANGE_MINI; } - @Override public int getRangeY() { return RANGE_Y_MINI; } - } - + private static final int COST = 12; + private static final int RANGE = 8; + private static final int RANGE_Y = 5; + + private static final int RANGE_MINI = 2; + private static final int RANGE_Y_MINI = 1; + + private static final Type[] TYPES = new Type[] { + Type.FOREST, Type.PLAINS, Type.MOUNTAIN, Type.MUSHROOM, Type.SWAMP, Type.SANDY, Type.COLD, Type.MESA + }; + + @Override + public void onUpdate() { + super.onUpdate(); + if (redstoneSignal > 0) return; + + if (!supertile.getWorldObj().isRemote && mana >= COST && ticksExisted % 2 == 0) { + ChunkCoordinates coords = getCoordsToPut(); + if (coords != null) { + ItemStack stack = getStoneToPut(coords); + if (stack != null) { + Block block = Block.getBlockFromItem(stack.getItem()); + int meta = stack.getItemDamage(); + supertile.getWorldObj().setBlock(coords.posX, coords.posY, coords.posZ, block, meta, 1 | 2); + if (ConfigHandler.blockBreakParticles) + supertile + .getWorldObj() + .playAuxSFX( + 2001, + coords.posX, + coords.posY, + coords.posZ, + Block.getIdFromBlock(block) + (meta << 12)); + + mana -= COST; + sync(); + } + } + } + } + + public ItemStack getStoneToPut(ChunkCoordinates coords) { + List types = Arrays.asList(BiomeDictionary.getTypesForBiome( + supertile.getWorldObj().getBiomeGenForCoords(coords.posX, coords.posZ))); + + List values = new ArrayList(); + for (int i = 0; i < 8; i++) { + int times = 1; + if (types.contains(TYPES[i])) times = 12; + + for (int j = 0; j < times; j++) values.add(i); + } + + return new ItemStack( + ModFluffBlocks.biomeStoneA, + 1, + values.get(supertile.getWorldObj().rand.nextInt(values.size()))); + } + + public ChunkCoordinates getCoordsToPut() { + List possibleCoords = new ArrayList(); + + int range = getRange(); + int rangeY = getRangeY(); + + for (int i = -range; i < range + 1; i++) + for (int j = -rangeY; j < rangeY; j++) + for (int k = -range; k < range + 1; k++) { + int x = supertile.xCoord + i; + int y = supertile.yCoord + j; + int z = supertile.zCoord + k; + Block block = supertile.getWorldObj().getBlock(x, y, z); + if (block != null && block.isReplaceableOreGen(supertile.getWorldObj(), x, y, z, Blocks.stone)) + possibleCoords.add(new ChunkCoordinates(x, y, z)); + } + + if (possibleCoords.isEmpty()) return null; + return possibleCoords.get(supertile.getWorldObj().rand.nextInt(possibleCoords.size())); + } + + @Override + public RadiusDescriptor getRadius() { + return new RadiusDescriptor.Square(toChunkCoordinates(), getRange()); + } + + public int getRange() { + return RANGE; + } + + public int getRangeY() { + return RANGE_Y; + } + + @Override + public int getColor() { + return 0x769897; + } + + @Override + public boolean acceptsRedstone() { + return true; + } + + @Override + public int getMaxMana() { + return 1000; + } + + @Override + public LexiconEntry getEntry() { + return LexiconData.marimorphosis; + } + + public static class Mini extends SubTileMarimorphosis { + @Override + public int getRange() { + return RANGE_MINI; + } + + @Override + public int getRangeY() { + return RANGE_Y_MINI; + } + } } diff --git a/src/main/java/vazkii/botania/common/block/subtile/functional/SubTileMedumone.java b/src/main/java/vazkii/botania/common/block/subtile/functional/SubTileMedumone.java index ec614af021..e4c8df385b 100644 --- a/src/main/java/vazkii/botania/common/block/subtile/functional/SubTileMedumone.java +++ b/src/main/java/vazkii/botania/common/block/subtile/functional/SubTileMedumone.java @@ -2,16 +2,15 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jan 27, 2015, 7:33:17 PM (GMT)] */ package vazkii.botania.common.block.subtile.functional; import java.util.List; - import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.potion.Potion; @@ -24,48 +23,56 @@ public class SubTileMedumone extends SubTileFunctional { - private static final int RANGE = 6; - - @Override - public void onUpdate() { - super.onUpdate(); + private static final int RANGE = 6; - if(mana > 0) { - List entities = supertile.getWorldObj().getEntitiesWithinAABB(EntityLivingBase.class, AxisAlignedBB.getBoundingBox(supertile.xCoord - RANGE, supertile.yCoord, supertile.zCoord - RANGE, supertile.xCoord + RANGE + 1, supertile.yCoord + 1, supertile.zCoord + RANGE + 1)); + @Override + public void onUpdate() { + super.onUpdate(); - for(EntityLivingBase entity : entities) - if(!(entity instanceof EntityPlayer)) { - entity.addPotionEffect(new PotionEffect(Potion.moveSlowdown.id, 2, 100)); - mana--; - if(mana == 0) - return; - } - } - } + if (mana > 0) { + List entities = supertile + .getWorldObj() + .getEntitiesWithinAABB( + EntityLivingBase.class, + AxisAlignedBB.getBoundingBox( + supertile.xCoord - RANGE, + supertile.yCoord, + supertile.zCoord - RANGE, + supertile.xCoord + RANGE + 1, + supertile.yCoord + 1, + supertile.zCoord + RANGE + 1)); - @Override - public boolean acceptsRedstone() { - return true; - } + for (EntityLivingBase entity : entities) + if (!(entity instanceof EntityPlayer)) { + entity.addPotionEffect(new PotionEffect(Potion.moveSlowdown.id, 2, 100)); + mana--; + if (mana == 0) return; + } + } + } - @Override - public RadiusDescriptor getRadius() { - return new RadiusDescriptor.Square(toChunkCoordinates(), RANGE); - } + @Override + public boolean acceptsRedstone() { + return true; + } - @Override - public int getColor() { - return 0x3D2204; - } + @Override + public RadiusDescriptor getRadius() { + return new RadiusDescriptor.Square(toChunkCoordinates(), RANGE); + } - @Override - public int getMaxMana() { - return 4000; - } + @Override + public int getColor() { + return 0x3D2204; + } - @Override - public LexiconEntry getEntry() { - return LexiconData.medumone; - } + @Override + public int getMaxMana() { + return 4000; + } + @Override + public LexiconEntry getEntry() { + return LexiconData.medumone; + } } diff --git a/src/main/java/vazkii/botania/common/block/subtile/functional/SubTileOrechid.java b/src/main/java/vazkii/botania/common/block/subtile/functional/SubTileOrechid.java index 8a027957b5..d6c2e57aa3 100644 --- a/src/main/java/vazkii/botania/common/block/subtile/functional/SubTileOrechid.java +++ b/src/main/java/vazkii/botania/common/block/subtile/functional/SubTileOrechid.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Mar 11, 2014, 5:40:55 PM (GMT)] */ package vazkii.botania.common.block.subtile.functional; @@ -14,7 +14,6 @@ import java.util.Collection; import java.util.List; import java.util.Map; - import net.minecraft.block.Block; import net.minecraft.init.Blocks; import net.minecraft.item.Item; @@ -32,143 +31,148 @@ public class SubTileOrechid extends SubTileFunctional { - private static final int COST = 17500; - private static final int COST_GOG = 700; - private static final int DELAY = 100; - private static final int DELAY_GOG = 2; - private static final int RANGE = 5; - private static final int RANGE_Y = 3; - - @Override - public void onUpdate() { - super.onUpdate(); - - if(redstoneSignal > 0 || !canOperate()) - return; - - int cost = getCost(); - if(!supertile.getWorldObj().isRemote && mana >= cost && ticksExisted % getDelay() == 0) { - ChunkCoordinates coords = getCoordsToPut(); - if(coords != null) { - ItemStack stack = getOreToPut(); - if(stack != null) { - Block block = Block.getBlockFromItem(stack.getItem()); - int meta = stack.getItemDamage(); - supertile.getWorldObj().setBlock(coords.posX, coords.posY, coords.posZ, block, meta, 1 | 2); - if(ConfigHandler.blockBreakParticles) - supertile.getWorldObj().playAuxSFX(2001, coords.posX, coords.posY, coords.posZ, Block.getIdFromBlock(block) + (meta << 12)); - supertile.getWorldObj().playSoundEffect(supertile.xCoord, supertile.yCoord, supertile.zCoord, "botania:orechid", 2F, 1F); - - mana -= cost; - sync(); - } - } - } - } - - public ItemStack getOreToPut() { - Collection values = new ArrayList(); - Map map = getOreMap(); - for(String s : map.keySet()) - values.add(new StringRandomItem(map.get(s), s)); - - String ore = ((StringRandomItem) WeightedRandom.getRandomItem(supertile.getWorldObj().rand, values)).s; - - List ores = OreDictionary.getOres(ore); - - for(ItemStack stack : ores) { - Item item = stack.getItem(); - String clname = item.getClass().getName(); - - // This poem is dedicated to Greg - // - // Greg. - // I get what you do when - // others say it's a grind. - // But take your TE ores - // and stick them in your behind. - if(clname.startsWith("gregtech") || clname.startsWith("gregapi")) - continue; - - return stack; - } - - return getOreToPut(); - } - - public ChunkCoordinates getCoordsToPut() { - List possibleCoords = new ArrayList(); - - Block source = getSourceBlock(); - for(int i = -RANGE; i < RANGE + 1; i++) - for(int j = -RANGE_Y; j < RANGE_Y; j++) - for(int k = -RANGE; k < RANGE + 1; k++) { - int x = supertile.xCoord + i; - int y = supertile.yCoord + j; - int z = supertile.zCoord + k; - Block block = supertile.getWorldObj().getBlock(x, y, z); - if(block != null && block.isReplaceableOreGen(supertile.getWorldObj(), x, y, z, source)) - possibleCoords.add(new ChunkCoordinates(x, y, z)); - } - - if(possibleCoords.isEmpty()) - return null; - return possibleCoords.get(supertile.getWorldObj().rand.nextInt(possibleCoords.size())); - } - - public boolean canOperate() { - return true; - } - - public Map getOreMap() { - return BotaniaAPI.oreWeights; - } - - public Block getSourceBlock() { - return Blocks.stone; - } - - public int getCost() { - return Botania.gardenOfGlassLoaded ? COST_GOG : COST; - } - - public int getDelay() { - return Botania.gardenOfGlassLoaded ? DELAY_GOG : DELAY; - } - - @Override - public RadiusDescriptor getRadius() { - return new RadiusDescriptor.Square(toChunkCoordinates(), RANGE); - } - - @Override - public boolean acceptsRedstone() { - return true; - } - - @Override - public int getColor() { - return 0x818181; - } - - @Override - public int getMaxMana() { - return getCost(); - } - - @Override - public LexiconEntry getEntry() { - return LexiconData.orechid; - } - - private static class StringRandomItem extends WeightedRandom.Item { - - public String s; - - public StringRandomItem(int par1, String s) { - super(par1); - this.s = s; - } - - } + private static final int COST = 17500; + private static final int COST_GOG = 700; + private static final int DELAY = 100; + private static final int DELAY_GOG = 2; + private static final int RANGE = 5; + private static final int RANGE_Y = 3; + + @Override + public void onUpdate() { + super.onUpdate(); + + if (redstoneSignal > 0 || !canOperate()) return; + + int cost = getCost(); + if (!supertile.getWorldObj().isRemote && mana >= cost && ticksExisted % getDelay() == 0) { + ChunkCoordinates coords = getCoordsToPut(); + if (coords != null) { + ItemStack stack = getOreToPut(); + if (stack != null) { + Block block = Block.getBlockFromItem(stack.getItem()); + int meta = stack.getItemDamage(); + supertile.getWorldObj().setBlock(coords.posX, coords.posY, coords.posZ, block, meta, 1 | 2); + if (ConfigHandler.blockBreakParticles) + supertile + .getWorldObj() + .playAuxSFX( + 2001, + coords.posX, + coords.posY, + coords.posZ, + Block.getIdFromBlock(block) + (meta << 12)); + supertile + .getWorldObj() + .playSoundEffect( + supertile.xCoord, supertile.yCoord, supertile.zCoord, "botania:orechid", 2F, 1F); + + mana -= cost; + sync(); + } + } + } + } + + public ItemStack getOreToPut() { + Collection values = new ArrayList(); + Map map = getOreMap(); + for (String s : map.keySet()) values.add(new StringRandomItem(map.get(s), s)); + + String ore = ((StringRandomItem) WeightedRandom.getRandomItem(supertile.getWorldObj().rand, values)).s; + + List ores = OreDictionary.getOres(ore); + + for (ItemStack stack : ores) { + Item item = stack.getItem(); + String clname = item.getClass().getName(); + + // This poem is dedicated to Greg + // + // Greg. + // I get what you do when + // others say it's a grind. + // But take your TE ores + // and stick them in your behind. + if (clname.startsWith("gregtech") || clname.startsWith("gregapi")) continue; + + return stack; + } + + return getOreToPut(); + } + + public ChunkCoordinates getCoordsToPut() { + List possibleCoords = new ArrayList(); + + Block source = getSourceBlock(); + for (int i = -RANGE; i < RANGE + 1; i++) + for (int j = -RANGE_Y; j < RANGE_Y; j++) + for (int k = -RANGE; k < RANGE + 1; k++) { + int x = supertile.xCoord + i; + int y = supertile.yCoord + j; + int z = supertile.zCoord + k; + Block block = supertile.getWorldObj().getBlock(x, y, z); + if (block != null && block.isReplaceableOreGen(supertile.getWorldObj(), x, y, z, source)) + possibleCoords.add(new ChunkCoordinates(x, y, z)); + } + + if (possibleCoords.isEmpty()) return null; + return possibleCoords.get(supertile.getWorldObj().rand.nextInt(possibleCoords.size())); + } + + public boolean canOperate() { + return true; + } + + public Map getOreMap() { + return BotaniaAPI.oreWeights; + } + + public Block getSourceBlock() { + return Blocks.stone; + } + + public int getCost() { + return Botania.gardenOfGlassLoaded ? COST_GOG : COST; + } + + public int getDelay() { + return Botania.gardenOfGlassLoaded ? DELAY_GOG : DELAY; + } + + @Override + public RadiusDescriptor getRadius() { + return new RadiusDescriptor.Square(toChunkCoordinates(), RANGE); + } + + @Override + public boolean acceptsRedstone() { + return true; + } + + @Override + public int getColor() { + return 0x818181; + } + + @Override + public int getMaxMana() { + return getCost(); + } + + @Override + public LexiconEntry getEntry() { + return LexiconData.orechid; + } + + private static class StringRandomItem extends WeightedRandom.Item { + + public String s; + + public StringRandomItem(int par1, String s) { + super(par1); + this.s = s; + } + } } diff --git a/src/main/java/vazkii/botania/common/block/subtile/functional/SubTileOrechidIgnem.java b/src/main/java/vazkii/botania/common/block/subtile/functional/SubTileOrechidIgnem.java index 0b6a21f0e2..1203285a09 100644 --- a/src/main/java/vazkii/botania/common/block/subtile/functional/SubTileOrechidIgnem.java +++ b/src/main/java/vazkii/botania/common/block/subtile/functional/SubTileOrechidIgnem.java @@ -2,16 +2,15 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Apr 30, 2015, 3:27:20 PM (GMT)] */ package vazkii.botania.common.block.subtile.functional; import java.util.Map; - import net.minecraft.block.Block; import net.minecraft.init.Blocks; import vazkii.botania.api.BotaniaAPI; @@ -20,36 +19,35 @@ public class SubTileOrechidIgnem extends SubTileOrechid { - private static final int COST = 20000; - - @Override - public boolean canOperate() { - return supertile.getWorldObj().provider.isHellWorld; - } - - @Override - public Map getOreMap() { - return BotaniaAPI.oreWeightsNether; - } - - @Override - public Block getSourceBlock() { - return Blocks.netherrack; - } - - @Override - public int getCost() { - return COST; - } - - @Override - public int getColor() { - return 0xAE3030; - } - - @Override - public LexiconEntry getEntry() { - return LexiconData.orechidIgnem; - } - + private static final int COST = 20000; + + @Override + public boolean canOperate() { + return supertile.getWorldObj().provider.isHellWorld; + } + + @Override + public Map getOreMap() { + return BotaniaAPI.oreWeightsNether; + } + + @Override + public Block getSourceBlock() { + return Blocks.netherrack; + } + + @Override + public int getCost() { + return COST; + } + + @Override + public int getColor() { + return 0xAE3030; + } + + @Override + public LexiconEntry getEntry() { + return LexiconData.orechidIgnem; + } } diff --git a/src/main/java/vazkii/botania/common/block/subtile/functional/SubTilePollidisiac.java b/src/main/java/vazkii/botania/common/block/subtile/functional/SubTilePollidisiac.java index 485c81318e..00c024af95 100644 --- a/src/main/java/vazkii/botania/common/block/subtile/functional/SubTilePollidisiac.java +++ b/src/main/java/vazkii/botania/common/block/subtile/functional/SubTilePollidisiac.java @@ -2,16 +2,16 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [May 15, 2014, 5:56:47 PM (GMT)] */ package vazkii.botania.common.block.subtile.functional; +import cpw.mods.fml.relauncher.ReflectionHelper; import java.util.List; - import net.minecraft.entity.item.EntityItem; import net.minecraft.entity.passive.EntityAnimal; import net.minecraft.item.ItemStack; @@ -21,68 +21,84 @@ import vazkii.botania.api.subtile.SubTileFunctional; import vazkii.botania.common.lexicon.LexiconData; import vazkii.botania.common.lib.LibObfuscation; -import cpw.mods.fml.relauncher.ReflectionHelper; public class SubTilePollidisiac extends SubTileFunctional { - private static final int RANGE = 6; + private static final int RANGE = 6; + + @Override + public void onUpdate() { + super.onUpdate(); - @Override - public void onUpdate() { - super.onUpdate(); + if (!supertile.getWorldObj().isRemote) { + int manaCost = 12; - if(!supertile.getWorldObj().isRemote) { - int manaCost = 12; + List items = supertile + .getWorldObj() + .getEntitiesWithinAABB( + EntityItem.class, + AxisAlignedBB.getBoundingBox( + supertile.xCoord - RANGE, + supertile.yCoord, + supertile.zCoord - RANGE, + supertile.xCoord + 1 + RANGE, + supertile.yCoord + 1, + supertile.zCoord + 1 + RANGE)); + List animals = supertile + .getWorldObj() + .getEntitiesWithinAABB( + EntityAnimal.class, + AxisAlignedBB.getBoundingBox( + supertile.xCoord - RANGE, + supertile.yCoord, + supertile.zCoord - RANGE, + supertile.xCoord + 1 + RANGE, + supertile.yCoord + 1, + supertile.zCoord + 1 + RANGE)); + int slowdown = getSlowdownFactor(); - List items = supertile.getWorldObj().getEntitiesWithinAABB(EntityItem.class, AxisAlignedBB.getBoundingBox(supertile.xCoord - RANGE, supertile.yCoord, supertile.zCoord - RANGE, supertile.xCoord + 1 + RANGE, supertile.yCoord + 1, supertile.zCoord + 1 +RANGE)); - List animals = supertile.getWorldObj().getEntitiesWithinAABB(EntityAnimal.class, AxisAlignedBB.getBoundingBox(supertile.xCoord - RANGE, supertile.yCoord, supertile.zCoord - RANGE, supertile.xCoord + 1 +RANGE, supertile.yCoord + 1, supertile.zCoord + 1 +RANGE)); - int slowdown = getSlowdownFactor(); - - for(EntityAnimal animal : animals) { - if(mana < manaCost) - break; + for (EntityAnimal animal : animals) { + if (mana < manaCost) break; - int love = ReflectionHelper.getPrivateValue(EntityAnimal.class, animal, LibObfuscation.IN_LOVE); - if(animal.getGrowingAge() == 0 && love <= 0) { - for(EntityItem item : items) { - if(item.age < (60 + slowdown) || item.isDead) - continue; + int love = ReflectionHelper.getPrivateValue(EntityAnimal.class, animal, LibObfuscation.IN_LOVE); + if (animal.getGrowingAge() == 0 && love <= 0) { + for (EntityItem item : items) { + if (item.age < (60 + slowdown) || item.isDead) continue; - ItemStack stack = item.getEntityItem(); - if(animal.isBreedingItem(stack)) { - stack.stackSize--; - if(stack.stackSize == 0) - item.setDead(); + ItemStack stack = item.getEntityItem(); + if (animal.isBreedingItem(stack)) { + stack.stackSize--; + if (stack.stackSize == 0) item.setDead(); - mana -= manaCost; + mana -= manaCost; - ReflectionHelper.setPrivateValue(EntityAnimal.class, animal, 1200, LibObfuscation.IN_LOVE); - animal.setTarget(null); - supertile.getWorldObj().setEntityState(animal, (byte)18); - } - } - } - } - } - } + ReflectionHelper.setPrivateValue(EntityAnimal.class, animal, 1200, LibObfuscation.IN_LOVE); + animal.setTarget(null); + supertile.getWorldObj().setEntityState(animal, (byte) 18); + } + } + } + } + } + } - @Override - public RadiusDescriptor getRadius() { - return new RadiusDescriptor.Square(toChunkCoordinates(), RANGE); - } + @Override + public RadiusDescriptor getRadius() { + return new RadiusDescriptor.Square(toChunkCoordinates(), RANGE); + } - @Override - public int getMaxMana() { - return 120; - } + @Override + public int getMaxMana() { + return 120; + } - @Override - public int getColor() { - return 0xCF4919; - } + @Override + public int getColor() { + return 0xCF4919; + } - @Override - public LexiconEntry getEntry() { - return LexiconData.pollidisiac; - } + @Override + public LexiconEntry getEntry() { + return LexiconData.pollidisiac; + } } diff --git a/src/main/java/vazkii/botania/common/block/subtile/functional/SubTileRannuncarpus.java b/src/main/java/vazkii/botania/common/block/subtile/functional/SubTileRannuncarpus.java index f890fd7783..ad51505ac1 100644 --- a/src/main/java/vazkii/botania/common/block/subtile/functional/SubTileRannuncarpus.java +++ b/src/main/java/vazkii/botania/common/block/subtile/functional/SubTileRannuncarpus.java @@ -2,17 +2,17 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [May 1, 2014, 6:08:25 PM (GMT)] */ package vazkii.botania.common.block.subtile.functional; +import cpw.mods.fml.relauncher.ReflectionHelper; import java.util.ArrayList; import java.util.List; - import net.minecraft.block.Block; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.ScaledResolution; @@ -29,9 +29,7 @@ import net.minecraft.util.AxisAlignedBB; import net.minecraft.util.ChunkCoordinates; import net.minecraft.world.World; - import org.lwjgl.opengl.GL11; - import vazkii.botania.api.item.IFlowerPlaceable; import vazkii.botania.api.lexicon.LexiconEntry; import vazkii.botania.api.subtile.ISubTileContainer; @@ -43,201 +41,240 @@ import vazkii.botania.common.item.block.ItemBlockSpecialFlower; import vazkii.botania.common.lexicon.LexiconData; import vazkii.botania.common.lib.LibObfuscation; -import cpw.mods.fml.relauncher.ReflectionHelper; public class SubTileRannuncarpus extends SubTileFunctional { - private static final int RANGE = 2; - private static final int RANGE_Y = 3; - private static final int RANGE_PLACE_MANA = 8; - private static final int RANGE_PLACE = 6; - private static final int RANGE_PLACE_Y = 6; - - private static final int RANGE_PLACE_MANA_MINI = 3; - private static final int RANGE_PLACE_MINI = 2; - private static final int RANGE_PLACE_Y_MINI = 2; - - @Override - public void onUpdate() { - super.onUpdate(); - - if(redstoneSignal > 0) - return; - - if(ticksExisted % 10 == 0) { - BlockData filter = getUnderlyingBlock(); - - boolean scanned = false; - List validPositions = new ArrayList(); - - int rangePlace = getRange(); - int rangePlaceY = getRangeY(); - - int x = supertile.xCoord; - int y = supertile.yCoord; - int z = supertile.zCoord; - - List items = supertile.getWorldObj().getEntitiesWithinAABB(EntityItem.class, AxisAlignedBB.getBoundingBox(x - RANGE, y - RANGE_Y, z - RANGE, x + RANGE + 1, y + RANGE_Y, z + RANGE + 1)); - int slowdown = getSlowdownFactor(); - for(EntityItem item : items) { - if(item.age < (60 + slowdown) || item.isDead) - continue; - - ItemStack stack = item.getEntityItem(); - Item stackItem = stack.getItem(); - if(stackItem instanceof ItemBlock || stackItem instanceof ItemReed || stackItem instanceof ItemRedstone || stackItem instanceof IFlowerPlaceable) { - if(!scanned) { - for(int i = -rangePlace; i < rangePlace + 1; i++) - for(int j = -rangePlaceY; j < rangePlaceY + 1; j++) - for(int l = -rangePlace; l < rangePlace + 1; l++) { - int xp = x + i; - int yp = y + j; - int zp = z + l; - Block blockAbove = supertile.getWorldObj().getBlock(xp, yp + 1, zp); - - if(filter.equals(supertile.getWorldObj(), xp, yp, zp) && (blockAbove.isAir(supertile.getWorldObj(), xp, yp + 1, zp) || blockAbove.isReplaceable(supertile.getWorldObj(), xp, yp + 1, zp))) - validPositions.add(new ChunkCoordinates(xp, yp + 1, zp)); - } - - scanned = true; - } - - - if(!validPositions.isEmpty() && !supertile.getWorldObj().isRemote) { - ChunkCoordinates coords = validPositions.get(supertile.getWorldObj().rand.nextInt(validPositions.size())); - - Block blockToPlace = null; - if(stackItem instanceof IFlowerPlaceable) - blockToPlace = ((IFlowerPlaceable) stackItem).getBlockToPlaceByFlower(stack, this, coords.posX, coords.posY, coords.posZ); - if(stackItem instanceof ItemBlock) - blockToPlace = ((ItemBlock) stackItem).field_150939_a; - else if(stackItem instanceof ItemReed) - blockToPlace = ReflectionHelper.getPrivateValue(ItemReed.class, (ItemReed) stackItem, LibObfuscation.REED_ITEM); - else if(stackItem instanceof ItemRedstone) - blockToPlace = Blocks.redstone_wire; - - if(blockToPlace != null) { - if(blockToPlace.canPlaceBlockAt(supertile.getWorldObj(), coords.posX, coords.posY, coords.posZ)) { - supertile.getWorldObj().setBlock(coords.posX, coords.posY, coords.posZ, blockToPlace, stack.getItemDamage(), 1 | 2); - if(ConfigHandler.blockBreakParticles) - supertile.getWorldObj().playAuxSFX(2001, coords.posX, coords.posY, coords.posZ, Block.getIdFromBlock(blockToPlace) + (stack.getItemDamage() << 12)); - validPositions.remove(coords); - - TileEntity tile = supertile.getWorldObj().getTileEntity(coords.posX, coords.posY, coords.posZ); - if(tile != null && tile instanceof ISubTileContainer) { - ISubTileContainer container = (ISubTileContainer) tile; - String subtileName = ItemBlockSpecialFlower.getType(stack); - container.setSubTile(subtileName); - SubTileEntity subtile = container.getSubTile(); - subtile.onBlockPlacedBy(supertile.getWorldObj(), coords.posX, coords.posY, coords.posZ, null, stack); - } - - if(stackItem instanceof IFlowerPlaceable) - ((IFlowerPlaceable) stackItem).onBlockPlacedByFlower(stack, this, coords.posX, coords.posY, coords.posZ); - - if(!supertile.getWorldObj().isRemote) { - stack.stackSize--; - if(stack.stackSize == 0) - item.setDead(); - } - - if(mana > 1) - mana--; - return; - } - } - } - } - } - } - } - - public BlockData getUnderlyingBlock() { - return new BlockData(supertile.getWorldObj(), supertile.xCoord, supertile.yCoord - (supertile instanceof IFloatingFlower ? 1 : 2), supertile.zCoord); - } - - @Override - public boolean acceptsRedstone() { - return true; - } - - @Override - public void renderHUD(Minecraft mc, ScaledResolution res) { - super.renderHUD(mc, res); - - BlockData filter = getUnderlyingBlock(); - ItemStack recieverStack = new ItemStack(Item.getItemFromBlock(filter.block), 1, filter.meta); - int color = getColor(); - - GL11.glEnable(GL11.GL_BLEND); - GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); - if(recieverStack != null && recieverStack.getItem() != null) { - String stackName = recieverStack.getDisplayName(); - int width = 16 + mc.fontRenderer.getStringWidth(stackName) / 2; - int x = res.getScaledWidth() / 2 - width; - int y = res.getScaledHeight() / 2 + 30; - - mc.fontRenderer.drawStringWithShadow(stackName, x + 20, y + 5, color); - RenderHelper.enableGUIStandardItemLighting(); - RenderItem.getInstance().renderItemAndEffectIntoGUI(mc.fontRenderer, mc.renderEngine, recieverStack, x, y); - RenderHelper.disableStandardItemLighting(); - } - - GL11.glDisable(GL11.GL_LIGHTING); - GL11.glDisable(GL11.GL_BLEND); - } - - @Override - public RadiusDescriptor getRadius() { - return new RadiusDescriptor.Square(toChunkCoordinates(), getRange()); - } - - public int getRange() { - return mana > 0 ? RANGE_PLACE_MANA : RANGE_PLACE; - } - - public int getRangeY() { - return RANGE_PLACE_Y; - } - - @Override - public int getMaxMana() { - return 20; - } - - @Override - public int getColor() { - return 0xFFB27F; - } - - @Override - public LexiconEntry getEntry() { - return LexiconData.rannuncarpus; - } - - public static class Mini extends SubTileRannuncarpus { - @Override public int getRange() { return mana > 0 ? RANGE_PLACE_MANA_MINI : RANGE_PLACE_MINI; } - @Override public int getRangeY() { return RANGE_PLACE_Y_MINI; } - } - - static class BlockData { - - Block block; - int meta; - - public BlockData(World world, int x, int y, int z) { - block = world.getBlock(x, y, z); - meta = world.getBlockMetadata(x, y, z); - } - - public boolean equals(BlockData data) { - return block == data.block && meta == data.meta; - } - - public boolean equals(World world, int x, int y, int z) { - return equals(new BlockData(world, x, y, z)); - } - - } - + private static final int RANGE = 2; + private static final int RANGE_Y = 3; + private static final int RANGE_PLACE_MANA = 8; + private static final int RANGE_PLACE = 6; + private static final int RANGE_PLACE_Y = 6; + + private static final int RANGE_PLACE_MANA_MINI = 3; + private static final int RANGE_PLACE_MINI = 2; + private static final int RANGE_PLACE_Y_MINI = 2; + + @Override + public void onUpdate() { + super.onUpdate(); + + if (redstoneSignal > 0) return; + + if (ticksExisted % 10 == 0) { + BlockData filter = getUnderlyingBlock(); + + boolean scanned = false; + List validPositions = new ArrayList(); + + int rangePlace = getRange(); + int rangePlaceY = getRangeY(); + + int x = supertile.xCoord; + int y = supertile.yCoord; + int z = supertile.zCoord; + + List items = supertile + .getWorldObj() + .getEntitiesWithinAABB( + EntityItem.class, + AxisAlignedBB.getBoundingBox( + x - RANGE, y - RANGE_Y, z - RANGE, x + RANGE + 1, y + RANGE_Y, z + RANGE + 1)); + int slowdown = getSlowdownFactor(); + for (EntityItem item : items) { + if (item.age < (60 + slowdown) || item.isDead) continue; + + ItemStack stack = item.getEntityItem(); + Item stackItem = stack.getItem(); + if (stackItem instanceof ItemBlock + || stackItem instanceof ItemReed + || stackItem instanceof ItemRedstone + || stackItem instanceof IFlowerPlaceable) { + if (!scanned) { + for (int i = -rangePlace; i < rangePlace + 1; i++) + for (int j = -rangePlaceY; j < rangePlaceY + 1; j++) + for (int l = -rangePlace; l < rangePlace + 1; l++) { + int xp = x + i; + int yp = y + j; + int zp = z + l; + Block blockAbove = supertile.getWorldObj().getBlock(xp, yp + 1, zp); + + if (filter.equals(supertile.getWorldObj(), xp, yp, zp) + && (blockAbove.isAir(supertile.getWorldObj(), xp, yp + 1, zp) + || blockAbove.isReplaceable( + supertile.getWorldObj(), xp, yp + 1, zp))) + validPositions.add(new ChunkCoordinates(xp, yp + 1, zp)); + } + + scanned = true; + } + + if (!validPositions.isEmpty() && !supertile.getWorldObj().isRemote) { + ChunkCoordinates coords = + validPositions.get(supertile.getWorldObj().rand.nextInt(validPositions.size())); + + Block blockToPlace = null; + if (stackItem instanceof IFlowerPlaceable) + blockToPlace = ((IFlowerPlaceable) stackItem) + .getBlockToPlaceByFlower(stack, this, coords.posX, coords.posY, coords.posZ); + if (stackItem instanceof ItemBlock) blockToPlace = ((ItemBlock) stackItem).field_150939_a; + else if (stackItem instanceof ItemReed) + blockToPlace = ReflectionHelper.getPrivateValue( + ItemReed.class, (ItemReed) stackItem, LibObfuscation.REED_ITEM); + else if (stackItem instanceof ItemRedstone) blockToPlace = Blocks.redstone_wire; + + if (blockToPlace != null) { + if (blockToPlace.canPlaceBlockAt( + supertile.getWorldObj(), coords.posX, coords.posY, coords.posZ)) { + supertile + .getWorldObj() + .setBlock( + coords.posX, + coords.posY, + coords.posZ, + blockToPlace, + stack.getItemDamage(), + 1 | 2); + if (ConfigHandler.blockBreakParticles) + supertile + .getWorldObj() + .playAuxSFX( + 2001, + coords.posX, + coords.posY, + coords.posZ, + Block.getIdFromBlock(blockToPlace) + (stack.getItemDamage() << 12)); + validPositions.remove(coords); + + TileEntity tile = + supertile.getWorldObj().getTileEntity(coords.posX, coords.posY, coords.posZ); + if (tile != null && tile instanceof ISubTileContainer) { + ISubTileContainer container = (ISubTileContainer) tile; + String subtileName = ItemBlockSpecialFlower.getType(stack); + container.setSubTile(subtileName); + SubTileEntity subtile = container.getSubTile(); + subtile.onBlockPlacedBy( + supertile.getWorldObj(), + coords.posX, + coords.posY, + coords.posZ, + null, + stack); + } + + if (stackItem instanceof IFlowerPlaceable) + ((IFlowerPlaceable) stackItem) + .onBlockPlacedByFlower(stack, this, coords.posX, coords.posY, coords.posZ); + + if (!supertile.getWorldObj().isRemote) { + stack.stackSize--; + if (stack.stackSize == 0) item.setDead(); + } + + if (mana > 1) mana--; + return; + } + } + } + } + } + } + } + + public BlockData getUnderlyingBlock() { + return new BlockData( + supertile.getWorldObj(), + supertile.xCoord, + supertile.yCoord - (supertile instanceof IFloatingFlower ? 1 : 2), + supertile.zCoord); + } + + @Override + public boolean acceptsRedstone() { + return true; + } + + @Override + public void renderHUD(Minecraft mc, ScaledResolution res) { + super.renderHUD(mc, res); + + BlockData filter = getUnderlyingBlock(); + ItemStack recieverStack = new ItemStack(Item.getItemFromBlock(filter.block), 1, filter.meta); + int color = getColor(); + + GL11.glEnable(GL11.GL_BLEND); + GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); + if (recieverStack != null && recieverStack.getItem() != null) { + String stackName = recieverStack.getDisplayName(); + int width = 16 + mc.fontRenderer.getStringWidth(stackName) / 2; + int x = res.getScaledWidth() / 2 - width; + int y = res.getScaledHeight() / 2 + 30; + + mc.fontRenderer.drawStringWithShadow(stackName, x + 20, y + 5, color); + RenderHelper.enableGUIStandardItemLighting(); + RenderItem.getInstance().renderItemAndEffectIntoGUI(mc.fontRenderer, mc.renderEngine, recieverStack, x, y); + RenderHelper.disableStandardItemLighting(); + } + + GL11.glDisable(GL11.GL_LIGHTING); + GL11.glDisable(GL11.GL_BLEND); + } + + @Override + public RadiusDescriptor getRadius() { + return new RadiusDescriptor.Square(toChunkCoordinates(), getRange()); + } + + public int getRange() { + return mana > 0 ? RANGE_PLACE_MANA : RANGE_PLACE; + } + + public int getRangeY() { + return RANGE_PLACE_Y; + } + + @Override + public int getMaxMana() { + return 20; + } + + @Override + public int getColor() { + return 0xFFB27F; + } + + @Override + public LexiconEntry getEntry() { + return LexiconData.rannuncarpus; + } + + public static class Mini extends SubTileRannuncarpus { + @Override + public int getRange() { + return mana > 0 ? RANGE_PLACE_MANA_MINI : RANGE_PLACE_MINI; + } + + @Override + public int getRangeY() { + return RANGE_PLACE_Y_MINI; + } + } + + static class BlockData { + + Block block; + int meta; + + public BlockData(World world, int x, int y, int z) { + block = world.getBlock(x, y, z); + meta = world.getBlockMetadata(x, y, z); + } + + public boolean equals(BlockData data) { + return block == data.block && meta == data.meta; + } + + public boolean equals(World world, int x, int y, int z) { + return equals(new BlockData(world, x, y, z)); + } + } } diff --git a/src/main/java/vazkii/botania/common/block/subtile/functional/SubTileSolegnolia.java b/src/main/java/vazkii/botania/common/block/subtile/functional/SubTileSolegnolia.java index 9ad426e520..ee5b10d846 100644 --- a/src/main/java/vazkii/botania/common/block/subtile/functional/SubTileSolegnolia.java +++ b/src/main/java/vazkii/botania/common/block/subtile/functional/SubTileSolegnolia.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Apr 11, 2015, 4:53:35 PM (GMT)] */ package vazkii.botania.common.block.subtile.functional; @@ -13,7 +13,6 @@ import java.util.Collections; import java.util.Set; import java.util.WeakHashMap; - import net.minecraft.entity.Entity; import vazkii.botania.api.lexicon.LexiconEntry; import vazkii.botania.api.subtile.RadiusDescriptor; @@ -23,67 +22,79 @@ public class SubTileSolegnolia extends SubTileFunctional { - private static final double RANGE = 5; - private static final double RANGE_MINI = 1; - - public static Set existingFlowers = Collections.newSetFromMap(new WeakHashMap()); - private static boolean registered = false; - - @Override - public void onUpdate() { - super.onUpdate(); - - if(!existingFlowers.contains(this)) { - existingFlowers.add(this); - if(!registered) - registered = true; - } - } - - @Override - public boolean acceptsRedstone() { - return true; - } - - public static boolean hasSolegnoliaAround(Entity e) { - for(SubTileSolegnolia flower : existingFlowers) { - if(flower.redstoneSignal > 0 || flower.supertile.getWorldObj() != e.worldObj || flower.supertile.getWorldObj().getTileEntity(flower.supertile.xCoord, flower.supertile.yCoord, flower.supertile.zCoord) != flower.supertile) - continue; - - double range = flower.getRange(); - if(MathHelper.pointDistanceSpace(e.posX, e.posY, e.posZ, flower.supertile.xCoord + 0.5, flower.supertile.yCoord + 0.5, flower.supertile.zCoord + 0.5) <= range) - return true; - } - - return false; - } - - @Override - public int getMaxMana() { - return 1; - } - - @Override - public int getColor() { - return 0xC99C4D; - } - - public double getRange() { - return RANGE; - } - - @Override - public RadiusDescriptor getRadius() { - return new RadiusDescriptor.Circle(toChunkCoordinates(), getRange()); - } - - @Override - public LexiconEntry getEntry() { - return LexiconData.solegnolia; - } - - public static class Mini extends SubTileSolegnolia { - @Override public double getRange() { return RANGE_MINI; } - } - + private static final double RANGE = 5; + private static final double RANGE_MINI = 1; + + public static Set existingFlowers = Collections.newSetFromMap(new WeakHashMap()); + private static boolean registered = false; + + @Override + public void onUpdate() { + super.onUpdate(); + + if (!existingFlowers.contains(this)) { + existingFlowers.add(this); + if (!registered) registered = true; + } + } + + @Override + public boolean acceptsRedstone() { + return true; + } + + public static boolean hasSolegnoliaAround(Entity e) { + for (SubTileSolegnolia flower : existingFlowers) { + if (flower.redstoneSignal > 0 + || flower.supertile.getWorldObj() != e.worldObj + || flower.supertile + .getWorldObj() + .getTileEntity( + flower.supertile.xCoord, flower.supertile.yCoord, flower.supertile.zCoord) + != flower.supertile) continue; + + double range = flower.getRange(); + if (MathHelper.pointDistanceSpace( + e.posX, + e.posY, + e.posZ, + flower.supertile.xCoord + 0.5, + flower.supertile.yCoord + 0.5, + flower.supertile.zCoord + 0.5) + <= range) return true; + } + + return false; + } + + @Override + public int getMaxMana() { + return 1; + } + + @Override + public int getColor() { + return 0xC99C4D; + } + + public double getRange() { + return RANGE; + } + + @Override + public RadiusDescriptor getRadius() { + return new RadiusDescriptor.Circle(toChunkCoordinates(), getRange()); + } + + @Override + public LexiconEntry getEntry() { + return LexiconData.solegnolia; + } + + public static class Mini extends SubTileSolegnolia { + @Override + public double getRange() { + return RANGE_MINI; + } + } } diff --git a/src/main/java/vazkii/botania/common/block/subtile/functional/SubTileSpectranthemum.java b/src/main/java/vazkii/botania/common/block/subtile/functional/SubTileSpectranthemum.java index d896964901..4445ea98ee 100644 --- a/src/main/java/vazkii/botania/common/block/subtile/functional/SubTileSpectranthemum.java +++ b/src/main/java/vazkii/botania/common/block/subtile/functional/SubTileSpectranthemum.java @@ -2,16 +2,17 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jan 27, 2015, 4:06:58 PM (GMT)] */ package vazkii.botania.common.block.subtile.functional; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; import java.util.List; - import net.minecraft.client.Minecraft; import net.minecraft.entity.item.EntityItem; import net.minecraft.entity.player.EntityPlayer; @@ -26,138 +27,152 @@ import vazkii.botania.api.subtile.SubTileFunctional; import vazkii.botania.common.core.helper.MathHelper; import vazkii.botania.common.lexicon.LexiconData; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; public class SubTileSpectranthemum extends SubTileFunctional { - private static final String TAG_BIND_X = "bindX"; - private static final String TAG_BIND_Y = "bindY"; - private static final String TAG_BIND_Z = "bindZ"; - - private static final int COST = 24; - private static final int RANGE = 2; - private static final int BIND_RANGE = 12; - - private static final String TAG_TELEPORTED = "Botania_TPd"; - - int bindX, bindY = -1, bindZ; - - @Override - public void onUpdate() { - super.onUpdate(); - - if(redstoneSignal == 0 && supertile.getWorldObj().blockExists(bindX, bindY, bindZ)) { - int x = supertile.xCoord; - int y = supertile.yCoord; - int z = supertile.zCoord; - - boolean did = false; - List items = supertile.getWorldObj().getEntitiesWithinAABB(EntityItem.class, AxisAlignedBB.getBoundingBox(x - RANGE, y - RANGE, z - RANGE, x + RANGE + 1, y + RANGE, z + RANGE + 1)); - int slowdown = getSlowdownFactor(); - - for(EntityItem item : items) { - if(item.age < (60 + slowdown) || item.isDead || item.getEntityData().getBoolean(TAG_TELEPORTED)) - continue; - - ItemStack stack = item.getEntityItem(); - if(stack != null) { - Item sitem = stack.getItem(); - if(sitem instanceof IManaItem) - continue; - - int cost = stack.stackSize * COST; - if(mana >= cost) { - spawnExplosionParticles(item, 10); - item.setPosition(bindX + 0.5, bindY + 1.5, bindZ + 0.5); - item.getEntityData().setBoolean(TAG_TELEPORTED, true); - item.motionX = item.motionY = item.motionZ = 0; - spawnExplosionParticles(item, 10); - if(!supertile.getWorldObj().isRemote) { - mana -= cost; - did = true; - } - } - } - } - - if(did) - sync(); - } - } - - public static void spawnExplosionParticles(EntityItem item, int p) { - for(int i = 0; i < p; i++) { - double m = 0.01; - double d0 = item.worldObj.rand.nextGaussian() * m; - double d1 = item.worldObj.rand.nextGaussian() * m; - double d2 = item.worldObj.rand.nextGaussian() * m; - double d3 = 10.0D; - item.worldObj.spawnParticle("explode", item.posX + item.worldObj.rand.nextFloat() * item.width * 2.0F - item.width - d0 * d3, item.posY + item.worldObj.rand.nextFloat() * item.height - d1 * d3, item.posZ + item.worldObj.rand.nextFloat() * item.width * 2.0F - item.width - d2 * d3, d0, d1, d2); - } - } - - @Override - public RadiusDescriptor getRadius() { - return new RadiusDescriptor.Square(toChunkCoordinates(), RANGE); - } - - @Override - public void writeToPacketNBT(NBTTagCompound cmp) { - super.writeToPacketNBT(cmp); - cmp.setInteger(TAG_BIND_X, bindX); - cmp.setInteger(TAG_BIND_Y, bindY); - cmp.setInteger(TAG_BIND_Z, bindZ); - } - - @Override - public void readFromPacketNBT(NBTTagCompound cmp) { - super.readFromPacketNBT(cmp); - bindX = cmp.getInteger(TAG_BIND_X); - bindY = cmp.getInteger(TAG_BIND_Y); - bindZ = cmp.getInteger(TAG_BIND_Z); - } - - @Override - public boolean acceptsRedstone() { - return true; - } - - @Override - public int getColor() { - return 0x98BCFF; - } - - @Override - public int getMaxMana() { - return 16000; - } - - @Override - public boolean bindTo(EntityPlayer player, ItemStack wand, int x, int y, int z, int side) { - boolean bound = super.bindTo(player, wand, x, y, z, side); - - if(!bound && (x != bindX || y != bindY || z != bindZ) && MathHelper.pointDistanceSpace(x, y, z, supertile.xCoord, supertile.yCoord, supertile.zCoord) <= BIND_RANGE && (x != supertile.xCoord || y != supertile.yCoord || z != supertile.zCoord)) { - bindX = x; - bindY = y; - bindZ = z; - sync(); - - return true; - } - - return bound; - } - - @Override - @SideOnly(Side.CLIENT) - public ChunkCoordinates getBinding() { - return Minecraft.getMinecraft().thePlayer.isSneaking() && bindY != -1 ? new ChunkCoordinates(bindX, bindY, bindZ) : super.getBinding(); - } - - @Override - public LexiconEntry getEntry() { - return LexiconData.spectranthemum; - } - + private static final String TAG_BIND_X = "bindX"; + private static final String TAG_BIND_Y = "bindY"; + private static final String TAG_BIND_Z = "bindZ"; + + private static final int COST = 24; + private static final int RANGE = 2; + private static final int BIND_RANGE = 12; + + private static final String TAG_TELEPORTED = "Botania_TPd"; + + int bindX, bindY = -1, bindZ; + + @Override + public void onUpdate() { + super.onUpdate(); + + if (redstoneSignal == 0 && supertile.getWorldObj().blockExists(bindX, bindY, bindZ)) { + int x = supertile.xCoord; + int y = supertile.yCoord; + int z = supertile.zCoord; + + boolean did = false; + List items = supertile + .getWorldObj() + .getEntitiesWithinAABB( + EntityItem.class, + AxisAlignedBB.getBoundingBox( + x - RANGE, y - RANGE, z - RANGE, x + RANGE + 1, y + RANGE, z + RANGE + 1)); + int slowdown = getSlowdownFactor(); + + for (EntityItem item : items) { + if (item.age < (60 + slowdown) + || item.isDead + || item.getEntityData().getBoolean(TAG_TELEPORTED)) continue; + + ItemStack stack = item.getEntityItem(); + if (stack != null) { + Item sitem = stack.getItem(); + if (sitem instanceof IManaItem) continue; + + int cost = stack.stackSize * COST; + if (mana >= cost) { + spawnExplosionParticles(item, 10); + item.setPosition(bindX + 0.5, bindY + 1.5, bindZ + 0.5); + item.getEntityData().setBoolean(TAG_TELEPORTED, true); + item.motionX = item.motionY = item.motionZ = 0; + spawnExplosionParticles(item, 10); + if (!supertile.getWorldObj().isRemote) { + mana -= cost; + did = true; + } + } + } + } + + if (did) sync(); + } + } + + public static void spawnExplosionParticles(EntityItem item, int p) { + for (int i = 0; i < p; i++) { + double m = 0.01; + double d0 = item.worldObj.rand.nextGaussian() * m; + double d1 = item.worldObj.rand.nextGaussian() * m; + double d2 = item.worldObj.rand.nextGaussian() * m; + double d3 = 10.0D; + item.worldObj.spawnParticle( + "explode", + item.posX + item.worldObj.rand.nextFloat() * item.width * 2.0F - item.width - d0 * d3, + item.posY + item.worldObj.rand.nextFloat() * item.height - d1 * d3, + item.posZ + item.worldObj.rand.nextFloat() * item.width * 2.0F - item.width - d2 * d3, + d0, + d1, + d2); + } + } + + @Override + public RadiusDescriptor getRadius() { + return new RadiusDescriptor.Square(toChunkCoordinates(), RANGE); + } + + @Override + public void writeToPacketNBT(NBTTagCompound cmp) { + super.writeToPacketNBT(cmp); + cmp.setInteger(TAG_BIND_X, bindX); + cmp.setInteger(TAG_BIND_Y, bindY); + cmp.setInteger(TAG_BIND_Z, bindZ); + } + + @Override + public void readFromPacketNBT(NBTTagCompound cmp) { + super.readFromPacketNBT(cmp); + bindX = cmp.getInteger(TAG_BIND_X); + bindY = cmp.getInteger(TAG_BIND_Y); + bindZ = cmp.getInteger(TAG_BIND_Z); + } + + @Override + public boolean acceptsRedstone() { + return true; + } + + @Override + public int getColor() { + return 0x98BCFF; + } + + @Override + public int getMaxMana() { + return 16000; + } + + @Override + public boolean bindTo(EntityPlayer player, ItemStack wand, int x, int y, int z, int side) { + boolean bound = super.bindTo(player, wand, x, y, z, side); + + if (!bound + && (x != bindX || y != bindY || z != bindZ) + && MathHelper.pointDistanceSpace(x, y, z, supertile.xCoord, supertile.yCoord, supertile.zCoord) + <= BIND_RANGE + && (x != supertile.xCoord || y != supertile.yCoord || z != supertile.zCoord)) { + bindX = x; + bindY = y; + bindZ = z; + sync(); + + return true; + } + + return bound; + } + + @Override + @SideOnly(Side.CLIENT) + public ChunkCoordinates getBinding() { + return Minecraft.getMinecraft().thePlayer.isSneaking() && bindY != -1 + ? new ChunkCoordinates(bindX, bindY, bindZ) + : super.getBinding(); + } + + @Override + public LexiconEntry getEntry() { + return LexiconData.spectranthemum; + } } diff --git a/src/main/java/vazkii/botania/common/block/subtile/functional/SubTileTangleberrie.java b/src/main/java/vazkii/botania/common/block/subtile/functional/SubTileTangleberrie.java index 7959ee403c..ead09ea5a7 100644 --- a/src/main/java/vazkii/botania/common/block/subtile/functional/SubTileTangleberrie.java +++ b/src/main/java/vazkii/botania/common/block/subtile/functional/SubTileTangleberrie.java @@ -2,16 +2,15 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Apr 14, 2014, 11:40:59 PM (GMT)] */ package vazkii.botania.common.block.subtile.functional; import java.util.List; - import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.boss.IBossDisplayData; import net.minecraft.entity.player.EntityPlayer; @@ -26,75 +25,84 @@ public class SubTileTangleberrie extends SubTileFunctional { - @Override - public void onUpdate() { - super.onUpdate(); - - if(mana > 0) { - double x1 = supertile.xCoord + 0.5; - double y1 = supertile.yCoord + 0.5; - double z1 = supertile.zCoord + 0.5; - - double maxDist = getMaxDistance(); - double range = getRange(); - - AxisAlignedBB boundingBox = AxisAlignedBB.getBoundingBox(x1 - range, y1 - range, z1 - range, x1 + range + 1, y1 + range + 1, z1 + range + 1); - List entities = supertile.getWorldObj().getEntitiesWithinAABB(EntityLivingBase.class, boundingBox); - - for(EntityLivingBase entity : entities) { - if(entity instanceof EntityPlayer || entity instanceof IBossDisplayData) - continue; - - double x2 = entity.posX; - double y2 = entity.posY; - double z2 = entity.posZ; - - float distance = MathHelper.pointDistanceSpace(x1, y1, z1, x2, y2, z2); - - if(distance > maxDist && distance < range) { - MathHelper.setEntityMotionFromVector(entity, new Vector3(x1, y1, z1), getMotionVelocity()); - if(supertile.getWorldObj().rand.nextInt(3) == 0) - Botania.proxy.sparkleFX(supertile.getWorldObj(), x2 + Math.random() * entity.width, y2 + Math.random() * entity.height, z2 + Math.random() * entity.width, 0.5F, 0.5F, 0.5F, 1F, 3); - } - } - - if(ticksExisted % 4 == 0) { - mana--; - sync(); - } - } - } - - double getMaxDistance() { - return 6; - } - - double getRange() { - return 7; - } - - float getMotionVelocity() { - return 0.05F; - } - - @Override - public RadiusDescriptor getRadius() { - return new RadiusDescriptor.Circle(toChunkCoordinates(), getRange()); - } - - @Override - public int getColor() { - return 0x4B797C; - } - - @Override - public int getMaxMana() { - return 20; - } - - @Override - public LexiconEntry getEntry() { - return LexiconData.tangleberrie; - } - + @Override + public void onUpdate() { + super.onUpdate(); + + if (mana > 0) { + double x1 = supertile.xCoord + 0.5; + double y1 = supertile.yCoord + 0.5; + double z1 = supertile.zCoord + 0.5; + + double maxDist = getMaxDistance(); + double range = getRange(); + + AxisAlignedBB boundingBox = AxisAlignedBB.getBoundingBox( + x1 - range, y1 - range, z1 - range, x1 + range + 1, y1 + range + 1, z1 + range + 1); + List entities = + supertile.getWorldObj().getEntitiesWithinAABB(EntityLivingBase.class, boundingBox); + + for (EntityLivingBase entity : entities) { + if (entity instanceof EntityPlayer || entity instanceof IBossDisplayData) continue; + + double x2 = entity.posX; + double y2 = entity.posY; + double z2 = entity.posZ; + + float distance = MathHelper.pointDistanceSpace(x1, y1, z1, x2, y2, z2); + + if (distance > maxDist && distance < range) { + MathHelper.setEntityMotionFromVector(entity, new Vector3(x1, y1, z1), getMotionVelocity()); + if (supertile.getWorldObj().rand.nextInt(3) == 0) + Botania.proxy.sparkleFX( + supertile.getWorldObj(), + x2 + Math.random() * entity.width, + y2 + Math.random() * entity.height, + z2 + Math.random() * entity.width, + 0.5F, + 0.5F, + 0.5F, + 1F, + 3); + } + } + + if (ticksExisted % 4 == 0) { + mana--; + sync(); + } + } + } + + double getMaxDistance() { + return 6; + } + + double getRange() { + return 7; + } + + float getMotionVelocity() { + return 0.05F; + } + + @Override + public RadiusDescriptor getRadius() { + return new RadiusDescriptor.Circle(toChunkCoordinates(), getRange()); + } + + @Override + public int getColor() { + return 0x4B797C; + } + + @Override + public int getMaxMana() { + return 20; + } + + @Override + public LexiconEntry getEntry() { + return LexiconData.tangleberrie; + } } diff --git a/src/main/java/vazkii/botania/common/block/subtile/functional/SubTileTigerseye.java b/src/main/java/vazkii/botania/common/block/subtile/functional/SubTileTigerseye.java index 07b01ed5fc..ade74af8d2 100644 --- a/src/main/java/vazkii/botania/common/block/subtile/functional/SubTileTigerseye.java +++ b/src/main/java/vazkii/botania/common/block/subtile/functional/SubTileTigerseye.java @@ -2,17 +2,17 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Feb 16, 2014, 3:36:26 PM (GMT)] */ package vazkii.botania.common.block.subtile.functional; +import cpw.mods.fml.relauncher.ReflectionHelper; import java.util.ArrayList; import java.util.List; - import net.minecraft.entity.EntityLiving; import net.minecraft.entity.ai.EntityAIAvoidEntity; import net.minecraft.entity.ai.EntityAINearestAttackableTarget; @@ -27,80 +27,97 @@ import vazkii.botania.api.subtile.SubTileFunctional; import vazkii.botania.common.lexicon.LexiconData; import vazkii.botania.common.lib.LibObfuscation; -import cpw.mods.fml.relauncher.ReflectionHelper; public class SubTileTigerseye extends SubTileFunctional { - private static final int RANGE = 10; - private static final int RANGE_Y = 4; - - @Override - public void onUpdate() { - super.onUpdate(); - final int cost = 70; - - boolean shouldAfffect = mana >= cost; - - List entities = supertile.getWorldObj().getEntitiesWithinAABB(EntityLiving.class, AxisAlignedBB.getBoundingBox(supertile.xCoord - RANGE, supertile.yCoord - RANGE_Y, supertile.zCoord - RANGE, supertile.xCoord + RANGE + 1, supertile.yCoord + RANGE_Y + 1, supertile.zCoord + RANGE + 1)); - - for(EntityLiving entity : entities) { - List entries = new ArrayList(entity.tasks.taskEntries); - entries.addAll(new ArrayList(entity.targetTasks.taskEntries)); - - boolean avoidsOcelots = false; - if(shouldAfffect) - for(EntityAITaskEntry entry : entries) { - if(entry.action instanceof EntityAIAvoidEntity) - avoidsOcelots = messWithRunAwayAI((EntityAIAvoidEntity) entry.action) || avoidsOcelots; - - if(entry.action instanceof EntityAINearestAttackableTarget) - messWithGetTargetAI((EntityAINearestAttackableTarget) entry.action); - } - - if(entity instanceof EntityCreeper) { - ReflectionHelper.setPrivateValue(EntityCreeper.class, (EntityCreeper) entity, 2, LibObfuscation.TIME_SINCE_IGNITED); - entity.setAttackTarget(null); - } - - if(avoidsOcelots) { - mana -= cost; - sync(); - shouldAfffect = false; - } - } - } - - private boolean messWithRunAwayAI(EntityAIAvoidEntity aiEntry) { - if(ReflectionHelper.getPrivateValue(EntityAIAvoidEntity.class, aiEntry, LibObfuscation.TARGET_ENTITY_CLASS) == EntityOcelot.class) { - ReflectionHelper.setPrivateValue(EntityAIAvoidEntity.class, aiEntry, EntityPlayer.class, LibObfuscation.TARGET_ENTITY_CLASS); - return true; - } - return false; - } - - private void messWithGetTargetAI(EntityAINearestAttackableTarget aiEntry) { - if(ReflectionHelper.getPrivateValue(EntityAINearestAttackableTarget.class, aiEntry, LibObfuscation.TARGET_CLASS) == EntityPlayer.class) - ReflectionHelper.setPrivateValue(EntityAINearestAttackableTarget.class, aiEntry, EntityEnderCrystal.class, LibObfuscation.TARGET_CLASS); // Something random that won't be around - } - - @Override - public RadiusDescriptor getRadius() { - return new RadiusDescriptor.Square(toChunkCoordinates(), RANGE); - } - - @Override - public int getColor() { - return 0xB1A618; - } - - @Override - public int getMaxMana() { - return 1000; - } - - @Override - public LexiconEntry getEntry() { - return LexiconData.tigerseye; - } - + private static final int RANGE = 10; + private static final int RANGE_Y = 4; + + @Override + public void onUpdate() { + super.onUpdate(); + final int cost = 70; + + boolean shouldAfffect = mana >= cost; + + List entities = supertile + .getWorldObj() + .getEntitiesWithinAABB( + EntityLiving.class, + AxisAlignedBB.getBoundingBox( + supertile.xCoord - RANGE, + supertile.yCoord - RANGE_Y, + supertile.zCoord - RANGE, + supertile.xCoord + RANGE + 1, + supertile.yCoord + RANGE_Y + 1, + supertile.zCoord + RANGE + 1)); + + for (EntityLiving entity : entities) { + List entries = new ArrayList(entity.tasks.taskEntries); + entries.addAll(new ArrayList(entity.targetTasks.taskEntries)); + + boolean avoidsOcelots = false; + if (shouldAfffect) + for (EntityAITaskEntry entry : entries) { + if (entry.action instanceof EntityAIAvoidEntity) + avoidsOcelots = messWithRunAwayAI((EntityAIAvoidEntity) entry.action) || avoidsOcelots; + + if (entry.action instanceof EntityAINearestAttackableTarget) + messWithGetTargetAI((EntityAINearestAttackableTarget) entry.action); + } + + if (entity instanceof EntityCreeper) { + ReflectionHelper.setPrivateValue( + EntityCreeper.class, (EntityCreeper) entity, 2, LibObfuscation.TIME_SINCE_IGNITED); + entity.setAttackTarget(null); + } + + if (avoidsOcelots) { + mana -= cost; + sync(); + shouldAfffect = false; + } + } + } + + private boolean messWithRunAwayAI(EntityAIAvoidEntity aiEntry) { + if (ReflectionHelper.getPrivateValue(EntityAIAvoidEntity.class, aiEntry, LibObfuscation.TARGET_ENTITY_CLASS) + == EntityOcelot.class) { + ReflectionHelper.setPrivateValue( + EntityAIAvoidEntity.class, aiEntry, EntityPlayer.class, LibObfuscation.TARGET_ENTITY_CLASS); + return true; + } + return false; + } + + private void messWithGetTargetAI(EntityAINearestAttackableTarget aiEntry) { + if (ReflectionHelper.getPrivateValue( + EntityAINearestAttackableTarget.class, aiEntry, LibObfuscation.TARGET_CLASS) + == EntityPlayer.class) + ReflectionHelper.setPrivateValue( + EntityAINearestAttackableTarget.class, + aiEntry, + EntityEnderCrystal.class, + LibObfuscation.TARGET_CLASS); // Something random that won't be around + } + + @Override + public RadiusDescriptor getRadius() { + return new RadiusDescriptor.Square(toChunkCoordinates(), RANGE); + } + + @Override + public int getColor() { + return 0xB1A618; + } + + @Override + public int getMaxMana() { + return 1000; + } + + @Override + public LexiconEntry getEntry() { + return LexiconData.tigerseye; + } } diff --git a/src/main/java/vazkii/botania/common/block/subtile/functional/SubTileVinculotus.java b/src/main/java/vazkii/botania/common/block/subtile/functional/SubTileVinculotus.java index 74110d252b..07a3f1cb5d 100644 --- a/src/main/java/vazkii/botania/common/block/subtile/functional/SubTileVinculotus.java +++ b/src/main/java/vazkii/botania/common/block/subtile/functional/SubTileVinculotus.java @@ -2,20 +2,20 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jul 15, 2014, 4:30:08 PM (GMT)] */ package vazkii.botania.common.block.subtile.functional; +import cpw.mods.fml.common.eventhandler.SubscribeEvent; import java.util.ArrayList; import java.util.Collections; import java.util.List; import java.util.Set; import java.util.WeakHashMap; - import net.minecraft.entity.monster.EntityEnderman; import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.event.entity.living.EnderTeleportEvent; @@ -24,91 +24,96 @@ import vazkii.botania.api.subtile.SubTileFunctional; import vazkii.botania.common.core.helper.MathHelper; import vazkii.botania.common.lexicon.LexiconData; -import cpw.mods.fml.common.eventhandler.SubscribeEvent; public class SubTileVinculotus extends SubTileFunctional { - public static Set existingFlowers = Collections.newSetFromMap(new WeakHashMap()); - private static boolean registered = false; - private static final int RANGE = 64; - - @Override - public void onUpdate() { - super.onUpdate(); - - if(!existingFlowers.contains(this)) { - existingFlowers.add(this); - if(!registered) { - MinecraftForge.EVENT_BUS.register(new EndermanIntercepter()); - registered = true; - } - } - } - - @Override - public RadiusDescriptor getRadius() { - return new RadiusDescriptor.Circle(toChunkCoordinates(), RANGE); - } - - @Override - public boolean acceptsRedstone() { - return true; - } - - @Override - public int getColor() { - return 0x0A6051; - } - - @Override - public int getMaxMana() { - return 500; - } - - @Override - public LexiconEntry getEntry() { - return LexiconData.vinculotus; - } - - public static class EndermanIntercepter { - - @SubscribeEvent - public void onEndermanTeleport(EnderTeleportEvent event) { - if(event.entity.worldObj.isRemote) - return; - - int cost = 50; - - if(event.entity instanceof EntityEnderman) { - List possibleFlowers = new ArrayList(); - for(SubTileVinculotus flower : existingFlowers) { - if(flower.redstoneSignal > 0 || flower.mana <= cost || flower.supertile.getWorldObj() != event.entity.worldObj || flower.supertile.getWorldObj().getTileEntity(flower.supertile.xCoord, flower.supertile.yCoord, flower.supertile.zCoord) != flower.supertile) - continue; - - double x = flower.supertile.xCoord + 0.5; - double y = flower.supertile.yCoord + 1.5; - double z = flower.supertile.zCoord + 0.5; - - if(MathHelper.pointDistanceSpace(x, y, z, event.targetX, event.targetY, event.targetZ) < RANGE) - possibleFlowers.add(flower); - } - - if(!possibleFlowers.isEmpty()) { - SubTileVinculotus flower = possibleFlowers.get(event.entity.worldObj.rand.nextInt(possibleFlowers.size())); - - double x = flower.supertile.xCoord + 0.5; - double y = flower.supertile.yCoord + 1.5; - double z = flower.supertile.zCoord + 0.5; - - event.targetX = x + Math.random() * 3 - 1; - event.targetY = y; - event.targetZ = z + Math.random() * 3 - 1; - flower.mana -= cost; - flower.sync(); - } - } - } - - } - + public static Set existingFlowers = Collections.newSetFromMap(new WeakHashMap()); + private static boolean registered = false; + private static final int RANGE = 64; + + @Override + public void onUpdate() { + super.onUpdate(); + + if (!existingFlowers.contains(this)) { + existingFlowers.add(this); + if (!registered) { + MinecraftForge.EVENT_BUS.register(new EndermanIntercepter()); + registered = true; + } + } + } + + @Override + public RadiusDescriptor getRadius() { + return new RadiusDescriptor.Circle(toChunkCoordinates(), RANGE); + } + + @Override + public boolean acceptsRedstone() { + return true; + } + + @Override + public int getColor() { + return 0x0A6051; + } + + @Override + public int getMaxMana() { + return 500; + } + + @Override + public LexiconEntry getEntry() { + return LexiconData.vinculotus; + } + + public static class EndermanIntercepter { + + @SubscribeEvent + public void onEndermanTeleport(EnderTeleportEvent event) { + if (event.entity.worldObj.isRemote) return; + + int cost = 50; + + if (event.entity instanceof EntityEnderman) { + List possibleFlowers = new ArrayList(); + for (SubTileVinculotus flower : existingFlowers) { + if (flower.redstoneSignal > 0 + || flower.mana <= cost + || flower.supertile.getWorldObj() != event.entity.worldObj + || flower.supertile + .getWorldObj() + .getTileEntity( + flower.supertile.xCoord, + flower.supertile.yCoord, + flower.supertile.zCoord) + != flower.supertile) continue; + + double x = flower.supertile.xCoord + 0.5; + double y = flower.supertile.yCoord + 1.5; + double z = flower.supertile.zCoord + 0.5; + + if (MathHelper.pointDistanceSpace(x, y, z, event.targetX, event.targetY, event.targetZ) < RANGE) + possibleFlowers.add(flower); + } + + if (!possibleFlowers.isEmpty()) { + SubTileVinculotus flower = + possibleFlowers.get(event.entity.worldObj.rand.nextInt(possibleFlowers.size())); + + double x = flower.supertile.xCoord + 0.5; + double y = flower.supertile.yCoord + 1.5; + double z = flower.supertile.zCoord + 0.5; + + event.targetX = x + Math.random() * 3 - 1; + event.targetY = y; + event.targetZ = z + Math.random() * 3 - 1; + flower.mana -= cost; + flower.sync(); + } + } + } + } } diff --git a/src/main/java/vazkii/botania/common/block/subtile/generating/SubTileArcaneRose.java b/src/main/java/vazkii/botania/common/block/subtile/generating/SubTileArcaneRose.java index 08b5701c29..4e844fa2b6 100644 --- a/src/main/java/vazkii/botania/common/block/subtile/generating/SubTileArcaneRose.java +++ b/src/main/java/vazkii/botania/common/block/subtile/generating/SubTileArcaneRose.java @@ -2,16 +2,15 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Mar 18, 2014, 8:45:25 PM (GMT)] */ package vazkii.botania.common.block.subtile.generating; import java.util.List; - import net.minecraft.entity.player.EntityPlayer; import net.minecraft.util.AxisAlignedBB; import vazkii.botania.api.lexicon.LexiconEntry; @@ -22,42 +21,50 @@ public class SubTileArcaneRose extends SubTileGenerating { - private static final int RANGE = 1; - - @Override - public void onUpdate() { - super.onUpdate(); + private static final int RANGE = 1; - if(mana >= getMaxMana()) - return; + @Override + public void onUpdate() { + super.onUpdate(); - List players = supertile.getWorldObj().getEntitiesWithinAABB(EntityPlayer.class, AxisAlignedBB.getBoundingBox(supertile.xCoord - RANGE, supertile.yCoord, supertile.zCoord - RANGE, supertile.xCoord + RANGE + 1, supertile.yCoord + 1, supertile.zCoord + RANGE + 1)); - for(EntityPlayer player : players) - if(ExperienceHelper.getPlayerXP(player) >= 1 && player.onGround) { - ExperienceHelper.drainPlayerXP(player, 1); - mana += 50; - return; - } - } + if (mana >= getMaxMana()) return; - @Override - public RadiusDescriptor getRadius() { - return new RadiusDescriptor.Square(toChunkCoordinates(), RANGE); - } + List players = supertile + .getWorldObj() + .getEntitiesWithinAABB( + EntityPlayer.class, + AxisAlignedBB.getBoundingBox( + supertile.xCoord - RANGE, + supertile.yCoord, + supertile.zCoord - RANGE, + supertile.xCoord + RANGE + 1, + supertile.yCoord + 1, + supertile.zCoord + RANGE + 1)); + for (EntityPlayer player : players) + if (ExperienceHelper.getPlayerXP(player) >= 1 && player.onGround) { + ExperienceHelper.drainPlayerXP(player, 1); + mana += 50; + return; + } + } - @Override - public int getColor() { - return 0xFF8EF8; - } + @Override + public RadiusDescriptor getRadius() { + return new RadiusDescriptor.Square(toChunkCoordinates(), RANGE); + } - @Override - public int getMaxMana() { - return 6000; - } + @Override + public int getColor() { + return 0xFF8EF8; + } - @Override - public LexiconEntry getEntry() { - return LexiconData.arcaneRose; - } + @Override + public int getMaxMana() { + return 6000; + } + @Override + public LexiconEntry getEntry() { + return LexiconData.arcaneRose; + } } diff --git a/src/main/java/vazkii/botania/common/block/subtile/generating/SubTileDandelifeon.java b/src/main/java/vazkii/botania/common/block/subtile/generating/SubTileDandelifeon.java index a6adf90b3a..b325c5346a 100644 --- a/src/main/java/vazkii/botania/common/block/subtile/generating/SubTileDandelifeon.java +++ b/src/main/java/vazkii/botania/common/block/subtile/generating/SubTileDandelifeon.java @@ -2,17 +2,16 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Sep 6, 2015, 3:46:10 PM (GMT)] */ package vazkii.botania.common.block.subtile.generating; import java.util.ArrayList; import java.util.List; - import net.minecraft.block.Block; import net.minecraft.tileentity.TileEntity; import net.minecraft.world.World; @@ -25,185 +24,175 @@ public class SubTileDandelifeon extends SubTileGenerating { - private static final int RANGE = 12; - private static final int SPEED = 10; - private static final int MAX_GENERATIONS = 60; - private static final int MANA_PER_GEN = 150; - - private static final int[][] ADJACENT_BLOCKS = new int[][] { - { -1, -1 }, - { -1, +0 }, - { -1, +1 }, - { +0, +1 }, - { +1, +1 }, - { +1, +0 }, - { +1, -1 }, - { +0, -1 } - }; - - @Override - public void onUpdate() { - super.onUpdate(); - - if(!supertile.getWorldObj().isRemote && redstoneSignal > 0 && ticksExisted % SPEED == 0) - runSimulation(); - } - - void runSimulation() { - int[][] table = getCellTable(); - List changes = new ArrayList(); - new ArrayList(); - boolean wipe = false; - - for(int i = 0; i < table.length; i++) - for(int j = 0; j < table[0].length; j++) { - int gen = table[i][j]; - int adj = getAdjCells(table, i, j); - - int newVal = gen; - if(adj < 2 || adj > 3) - newVal = -1; - else { - if(adj == 3 && gen == -1) - newVal = getSpawnCellGeneration(table, i, j); - else if(gen > -1) - newVal = gen + 1; - } - - int xdist = Math.abs(i - RANGE); - int zdist = Math.abs(j - RANGE); - int allowDist = 1; - if(xdist <= allowDist && zdist <= allowDist && newVal > -1) { - gen = newVal; - newVal = gen == 1 ? -1 : -2; - } - - if(newVal != gen) { - changes.add(new int[] { i, j, newVal, gen }); - if(newVal == -2) - wipe = true; - } - } - - int x = supertile.xCoord; - int y = supertile.yCoord; - int z = supertile.zCoord; - - for(int[] change : changes) { - int px = x - RANGE + change[0]; - int pz = z - RANGE + change[1]; - int val = change[2]; - if(val != -2 && wipe) - val = -1; - - int old = change[3]; - - setBlockForGeneration(px, y, pz, val, old); - } - } - - int[][] getCellTable() { - int diam = RANGE * 2 + 1; - int[][] table = new int[diam][diam]; - - int x = supertile.xCoord; - int y = supertile.yCoord; - int z = supertile.zCoord; - - for(int i = 0; i < diam; i++) - for(int j = 0; j < diam; j++) { - int px = x - RANGE + i; - int pz = z - RANGE + j; - table[i][j] = getCellGeneration(px, y, pz); - } - - return table; - } - - int getCellGeneration(int x, int y, int z) { - TileEntity tile = supertile.getWorldObj().getTileEntity(x, y, z); - if(tile instanceof TileCell) - return ((TileCell) tile).isSameFlower(supertile) ? ((TileCell) tile).getGeneration() : 0; - - return -1; - } - - int getAdjCells(int[][] table, int x, int z) { - int count = 0; - for(int[] shift : ADJACENT_BLOCKS) { - int xp = x + shift[0]; - int zp = z + shift[1]; - if(!isOffBounds(table, xp, zp)) { - int gen = table[xp][zp]; - if(gen >= 0) - count++; - } - } - - return count; - } - - int getSpawnCellGeneration(int[][] table, int x, int z) { - int max = -1; - for(int[] shift : ADJACENT_BLOCKS) { - int xp = x + shift[0]; - int zp = z + shift[1]; - if(!isOffBounds(table, xp, zp)) { - int gen = table[xp][zp]; - if(gen > max) - max = gen; - } - } - - return max == -1 ? -1 : max + 1; - } - - boolean isOffBounds(int[][] table, int x, int z) { - return x < 0 || z < 0 || x >= table.length || z >= table[0].length; - } - - void setBlockForGeneration(int x, int y, int z, int gen, int prevGen) { - World world = supertile.getWorldObj(); - Block blockAt = world.getBlock(x, y, z); - TileEntity tile = world.getTileEntity(x, y, z); - if(gen == -2) { - int val = prevGen * MANA_PER_GEN; - mana = Math.min(getMaxMana(), mana + val); - //world.setBlockToAir(x, y, z); - } else if(blockAt == ModBlocks.cellBlock) { - if(gen < 0 || gen > MAX_GENERATIONS) - world.setBlockToAir(x, y, z); - else ((TileCell) tile).setGeneration(supertile, gen); - } else if(gen >= 0 && blockAt.isAir(supertile.getWorldObj(), x, y, z)) { - world.setBlock(x, y, z, ModBlocks.cellBlock); - tile = world.getTileEntity(x, y, z); - ((TileCell) tile).setGeneration(supertile, gen); - } - } - - @Override - public boolean acceptsRedstone() { - return true; - } - - @Override - public RadiusDescriptor getRadius() { - return new RadiusDescriptor.Square(toChunkCoordinates(), RANGE); - } - - @Override - public int getMaxMana() { - return 50000; - } - - @Override - public int getColor() { - return 0x9c0a7e; - } - - @Override - public LexiconEntry getEntry() { - return LexiconData.dandelifeon; - } - + private static final int RANGE = 12; + private static final int SPEED = 10; + private static final int MAX_GENERATIONS = 60; + private static final int MANA_PER_GEN = 150; + + private static final int[][] ADJACENT_BLOCKS = new int[][] { + {-1, -1}, + {-1, +0}, + {-1, +1}, + {+0, +1}, + {+1, +1}, + {+1, +0}, + {+1, -1}, + {+0, -1} + }; + + @Override + public void onUpdate() { + super.onUpdate(); + + if (!supertile.getWorldObj().isRemote && redstoneSignal > 0 && ticksExisted % SPEED == 0) runSimulation(); + } + + void runSimulation() { + int[][] table = getCellTable(); + List changes = new ArrayList(); + new ArrayList(); + boolean wipe = false; + + for (int i = 0; i < table.length; i++) + for (int j = 0; j < table[0].length; j++) { + int gen = table[i][j]; + int adj = getAdjCells(table, i, j); + + int newVal = gen; + if (adj < 2 || adj > 3) newVal = -1; + else { + if (adj == 3 && gen == -1) newVal = getSpawnCellGeneration(table, i, j); + else if (gen > -1) newVal = gen + 1; + } + + int xdist = Math.abs(i - RANGE); + int zdist = Math.abs(j - RANGE); + int allowDist = 1; + if (xdist <= allowDist && zdist <= allowDist && newVal > -1) { + gen = newVal; + newVal = gen == 1 ? -1 : -2; + } + + if (newVal != gen) { + changes.add(new int[] {i, j, newVal, gen}); + if (newVal == -2) wipe = true; + } + } + + int x = supertile.xCoord; + int y = supertile.yCoord; + int z = supertile.zCoord; + + for (int[] change : changes) { + int px = x - RANGE + change[0]; + int pz = z - RANGE + change[1]; + int val = change[2]; + if (val != -2 && wipe) val = -1; + + int old = change[3]; + + setBlockForGeneration(px, y, pz, val, old); + } + } + + int[][] getCellTable() { + int diam = RANGE * 2 + 1; + int[][] table = new int[diam][diam]; + + int x = supertile.xCoord; + int y = supertile.yCoord; + int z = supertile.zCoord; + + for (int i = 0; i < diam; i++) + for (int j = 0; j < diam; j++) { + int px = x - RANGE + i; + int pz = z - RANGE + j; + table[i][j] = getCellGeneration(px, y, pz); + } + + return table; + } + + int getCellGeneration(int x, int y, int z) { + TileEntity tile = supertile.getWorldObj().getTileEntity(x, y, z); + if (tile instanceof TileCell) + return ((TileCell) tile).isSameFlower(supertile) ? ((TileCell) tile).getGeneration() : 0; + + return -1; + } + + int getAdjCells(int[][] table, int x, int z) { + int count = 0; + for (int[] shift : ADJACENT_BLOCKS) { + int xp = x + shift[0]; + int zp = z + shift[1]; + if (!isOffBounds(table, xp, zp)) { + int gen = table[xp][zp]; + if (gen >= 0) count++; + } + } + + return count; + } + + int getSpawnCellGeneration(int[][] table, int x, int z) { + int max = -1; + for (int[] shift : ADJACENT_BLOCKS) { + int xp = x + shift[0]; + int zp = z + shift[1]; + if (!isOffBounds(table, xp, zp)) { + int gen = table[xp][zp]; + if (gen > max) max = gen; + } + } + + return max == -1 ? -1 : max + 1; + } + + boolean isOffBounds(int[][] table, int x, int z) { + return x < 0 || z < 0 || x >= table.length || z >= table[0].length; + } + + void setBlockForGeneration(int x, int y, int z, int gen, int prevGen) { + World world = supertile.getWorldObj(); + Block blockAt = world.getBlock(x, y, z); + TileEntity tile = world.getTileEntity(x, y, z); + if (gen == -2) { + int val = prevGen * MANA_PER_GEN; + mana = Math.min(getMaxMana(), mana + val); + // world.setBlockToAir(x, y, z); + } else if (blockAt == ModBlocks.cellBlock) { + if (gen < 0 || gen > MAX_GENERATIONS) world.setBlockToAir(x, y, z); + else ((TileCell) tile).setGeneration(supertile, gen); + } else if (gen >= 0 && blockAt.isAir(supertile.getWorldObj(), x, y, z)) { + world.setBlock(x, y, z, ModBlocks.cellBlock); + tile = world.getTileEntity(x, y, z); + ((TileCell) tile).setGeneration(supertile, gen); + } + } + + @Override + public boolean acceptsRedstone() { + return true; + } + + @Override + public RadiusDescriptor getRadius() { + return new RadiusDescriptor.Square(toChunkCoordinates(), RANGE); + } + + @Override + public int getMaxMana() { + return 50000; + } + + @Override + public int getColor() { + return 0x9c0a7e; + } + + @Override + public LexiconEntry getEntry() { + return LexiconData.dandelifeon; + } } diff --git a/src/main/java/vazkii/botania/common/block/subtile/generating/SubTileDaybloom.java b/src/main/java/vazkii/botania/common/block/subtile/generating/SubTileDaybloom.java index aa9723c093..c6a5d4a359 100644 --- a/src/main/java/vazkii/botania/common/block/subtile/generating/SubTileDaybloom.java +++ b/src/main/java/vazkii/botania/common/block/subtile/generating/SubTileDaybloom.java @@ -2,16 +2,15 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jan 25, 2014, 3:09:35 PM (GMT)] */ package vazkii.botania.common.block.subtile.generating; import java.util.ArrayList; - import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import vazkii.botania.api.lexicon.LexiconEntry; @@ -21,109 +20,119 @@ @PassiveFlower public class SubTileDaybloom extends SubTilePassiveGenerating { - private static final String TAG_PRIME_POSITION_X = "primePositionX"; - private static final String TAG_PRIME_POSITION_Y = "primePositionY"; - private static final String TAG_PRIME_POSITION_Z = "primePositionZ"; - private static final String TAG_SAVED_POSITION = "savedPosition"; - - int primePositionX, primePositionY, primePositionZ; - boolean savedPosition; - - @Override - public int getColor() { - return 0xFFFF00; - } - - @Override - public void onUpdate() { - super.onUpdate(); - - if(isPrime() && (!savedPosition || primePositionX != supertile.xCoord || primePositionY != supertile.yCoord || primePositionZ != supertile.zCoord)) - supertile.getWorldObj().setBlockToAir(supertile.xCoord, supertile.yCoord, supertile.zCoord); - } - - public void setPrimusPosition() { - primePositionX = supertile.xCoord; - primePositionY = supertile.yCoord; - primePositionZ = supertile.zCoord; - - savedPosition = true; - } - - @Override - public ArrayList getDrops(ArrayList list) { - if(isPrime()) - list.clear(); - - return super.getDrops(list); - } - - @Override - public boolean canGeneratePassively() { - boolean rain = supertile.getWorldObj().getWorldChunkManager().getBiomeGenAt(supertile.xCoord, supertile.zCoord).getIntRainfall() > 0 && (supertile.getWorldObj().isRaining() || supertile.getWorldObj().isThundering()); - return supertile.getWorldObj().isDaytime() && !rain && supertile.getWorldObj().canBlockSeeTheSky(supertile.xCoord, supertile.yCoord + 1, supertile.zCoord); - } - - @Override - public int getDelayBetweenPassiveGeneration() { - return isPrime() ? 10 : 12; - } - - @Override - public void writeToPacketNBT(NBTTagCompound cmp) { - super.writeToPacketNBT(cmp); - - if(isPrime()) { - cmp.setInteger(TAG_PRIME_POSITION_X, primePositionX); - cmp.setInteger(TAG_PRIME_POSITION_Y, primePositionY); - cmp.setInteger(TAG_PRIME_POSITION_Z, primePositionZ); - cmp.setBoolean(TAG_SAVED_POSITION, savedPosition); - } - } - - @Override - public void readFromPacketNBT(NBTTagCompound cmp) { - super.readFromPacketNBT(cmp); - - if(isPrime()) { - primePositionX = cmp.getInteger(TAG_PRIME_POSITION_X); - primePositionY = cmp.getInteger(TAG_PRIME_POSITION_Y); - primePositionZ = cmp.getInteger(TAG_PRIME_POSITION_Z); - savedPosition = cmp.getBoolean(TAG_SAVED_POSITION); - } - } - - @Override - public boolean shouldSyncPassiveGeneration() { - return true; - } - - @Override - public boolean isPassiveFlower() { - return !isPrime(); - } - - @Override - public LexiconEntry getEntry() { - return LexiconData.daybloom; - } - - public boolean isPrime() { - return false; - } - - public static class Prime extends SubTileDaybloom { - - @Override - public boolean isPrime() { - return true; - } - - @Override - public LexiconEntry getEntry() { - return LexiconData.primusLoci; - } - - } - + private static final String TAG_PRIME_POSITION_X = "primePositionX"; + private static final String TAG_PRIME_POSITION_Y = "primePositionY"; + private static final String TAG_PRIME_POSITION_Z = "primePositionZ"; + private static final String TAG_SAVED_POSITION = "savedPosition"; + + int primePositionX, primePositionY, primePositionZ; + boolean savedPosition; + + @Override + public int getColor() { + return 0xFFFF00; + } + + @Override + public void onUpdate() { + super.onUpdate(); + + if (isPrime() + && (!savedPosition + || primePositionX != supertile.xCoord + || primePositionY != supertile.yCoord + || primePositionZ != supertile.zCoord)) + supertile.getWorldObj().setBlockToAir(supertile.xCoord, supertile.yCoord, supertile.zCoord); + } + + public void setPrimusPosition() { + primePositionX = supertile.xCoord; + primePositionY = supertile.yCoord; + primePositionZ = supertile.zCoord; + + savedPosition = true; + } + + @Override + public ArrayList getDrops(ArrayList list) { + if (isPrime()) list.clear(); + + return super.getDrops(list); + } + + @Override + public boolean canGeneratePassively() { + boolean rain = supertile + .getWorldObj() + .getWorldChunkManager() + .getBiomeGenAt(supertile.xCoord, supertile.zCoord) + .getIntRainfall() + > 0 + && (supertile.getWorldObj().isRaining() + || supertile.getWorldObj().isThundering()); + return supertile.getWorldObj().isDaytime() + && !rain + && supertile.getWorldObj().canBlockSeeTheSky(supertile.xCoord, supertile.yCoord + 1, supertile.zCoord); + } + + @Override + public int getDelayBetweenPassiveGeneration() { + return isPrime() ? 10 : 12; + } + + @Override + public void writeToPacketNBT(NBTTagCompound cmp) { + super.writeToPacketNBT(cmp); + + if (isPrime()) { + cmp.setInteger(TAG_PRIME_POSITION_X, primePositionX); + cmp.setInteger(TAG_PRIME_POSITION_Y, primePositionY); + cmp.setInteger(TAG_PRIME_POSITION_Z, primePositionZ); + cmp.setBoolean(TAG_SAVED_POSITION, savedPosition); + } + } + + @Override + public void readFromPacketNBT(NBTTagCompound cmp) { + super.readFromPacketNBT(cmp); + + if (isPrime()) { + primePositionX = cmp.getInteger(TAG_PRIME_POSITION_X); + primePositionY = cmp.getInteger(TAG_PRIME_POSITION_Y); + primePositionZ = cmp.getInteger(TAG_PRIME_POSITION_Z); + savedPosition = cmp.getBoolean(TAG_SAVED_POSITION); + } + } + + @Override + public boolean shouldSyncPassiveGeneration() { + return true; + } + + @Override + public boolean isPassiveFlower() { + return !isPrime(); + } + + @Override + public LexiconEntry getEntry() { + return LexiconData.daybloom; + } + + public boolean isPrime() { + return false; + } + + public static class Prime extends SubTileDaybloom { + + @Override + public boolean isPrime() { + return true; + } + + @Override + public LexiconEntry getEntry() { + return LexiconData.primusLoci; + } + } } diff --git a/src/main/java/vazkii/botania/common/block/subtile/generating/SubTileEndoflame.java b/src/main/java/vazkii/botania/common/block/subtile/generating/SubTileEndoflame.java index 9210b93e64..21cd2bef4b 100644 --- a/src/main/java/vazkii/botania/common/block/subtile/generating/SubTileEndoflame.java +++ b/src/main/java/vazkii/botania/common/block/subtile/generating/SubTileEndoflame.java @@ -2,16 +2,15 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Feb 15, 2014, 9:47:56 PM (GMT)] */ package vazkii.botania.common.block.subtile.generating; import java.util.List; - import net.minecraft.entity.item.EntityItem; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; @@ -21,118 +20,143 @@ import vazkii.botania.api.lexicon.LexiconEntry; import vazkii.botania.api.subtile.RadiusDescriptor; import vazkii.botania.api.subtile.SubTileGenerating; -import vazkii.botania.common.Botania; import vazkii.botania.common.block.ModBlocks; import vazkii.botania.common.lexicon.LexiconData; public class SubTileEndoflame extends SubTileGenerating { - private static final String TAG_BURN_TIME = "burnTime"; - private static final int FUEL_CAP = 32000; - private static final int RANGE = 3; - - int burnTime = 0; - - @Override - public void onUpdate() { - super.onUpdate(); - - if(linkedCollector != null) { - if(burnTime == 0) { - if(mana < getMaxMana()) { - boolean didSomething = false; - - int slowdown = getSlowdownFactor(); - - List items = supertile.getWorldObj().getEntitiesWithinAABB(EntityItem.class, AxisAlignedBB.getBoundingBox(supertile.xCoord - RANGE, supertile.yCoord - RANGE, supertile.zCoord - RANGE, supertile.xCoord + RANGE + 1, supertile.yCoord + RANGE + 1, supertile.zCoord + RANGE + 1)); - for(EntityItem item : items) { - if(item.age >= (59 + slowdown) && !item.isDead) { - ItemStack stack = item.getEntityItem(); - if(stack.getItem().hasContainerItem(stack)) - continue; - - int burnTime = stack == null || stack.getItem() == Item.getItemFromBlock(ModBlocks.spreader) ? 0 : TileEntityFurnace.getItemBurnTime(stack); - if(burnTime > 0 && stack.stackSize > 0) { - this.burnTime = Math.min(FUEL_CAP, burnTime) / 2; - - if(!supertile.getWorldObj().isRemote) { - stack.stackSize--; - supertile.getWorldObj().playSoundEffect(supertile.xCoord, supertile.yCoord, supertile.zCoord, "botania:endoflame", 0.2F, 1F); - - if(stack.stackSize == 0) - item.setDead(); - - didSomething = true; - } else { - item.worldObj.spawnParticle("largesmoke", item.posX, item.posY + 0.1, item.posZ, 0.0D, 0.0D, 0.0D); - item.worldObj.spawnParticle("flame", item.posX, item.posY, item.posZ, 0.0D, 0.0D, 0.0D); - } - - - break; - } - } - } - - if(didSomething) - sync(); - } - } else { - if(supertile.getWorldObj().rand.nextInt(10) == 0) - supertile.getWorldObj().spawnParticle("flame", supertile.xCoord + 0.4 + Math.random() * 0.2, supertile.yCoord + 0.65, supertile.zCoord + 0.4 + Math.random() * 0.2, 0.0D, 0.0D, 0.0D); - - burnTime--; - } - } - } - - @Override - public int getMaxMana() { - return 300; - } - - @Override - public int getValueForPassiveGeneration() { - return 3; - } - - @Override - public int getColor() { - return 0x785000; - } - - @Override - public RadiusDescriptor getRadius() { - return new RadiusDescriptor.Square(toChunkCoordinates(), RANGE); - } - - @Override - public LexiconEntry getEntry() { - return LexiconData.endoflame; - } - - @Override - public void writeToPacketNBT(NBTTagCompound cmp) { - super.writeToPacketNBT(cmp); - - cmp.setInteger(TAG_BURN_TIME, burnTime); - } - - @Override - public void readFromPacketNBT(NBTTagCompound cmp) { - super.readFromPacketNBT(cmp); - - burnTime = cmp.getInteger(TAG_BURN_TIME); - } - - @Override - public boolean canGeneratePassively() { - return burnTime > 0; - } - - @Override - public int getDelayBetweenPassiveGeneration() { - return 2; - } - + private static final String TAG_BURN_TIME = "burnTime"; + private static final int FUEL_CAP = 32000; + private static final int RANGE = 3; + + int burnTime = 0; + + @Override + public void onUpdate() { + super.onUpdate(); + + if (linkedCollector != null) { + if (burnTime == 0) { + if (mana < getMaxMana()) { + boolean didSomething = false; + + int slowdown = getSlowdownFactor(); + + List items = supertile + .getWorldObj() + .getEntitiesWithinAABB( + EntityItem.class, + AxisAlignedBB.getBoundingBox( + supertile.xCoord - RANGE, + supertile.yCoord - RANGE, + supertile.zCoord - RANGE, + supertile.xCoord + RANGE + 1, + supertile.yCoord + RANGE + 1, + supertile.zCoord + RANGE + 1)); + for (EntityItem item : items) { + if (item.age >= (59 + slowdown) && !item.isDead) { + ItemStack stack = item.getEntityItem(); + if (stack.getItem().hasContainerItem(stack)) continue; + + int burnTime = stack == null || stack.getItem() == Item.getItemFromBlock(ModBlocks.spreader) + ? 0 + : TileEntityFurnace.getItemBurnTime(stack); + if (burnTime > 0 && stack.stackSize > 0) { + this.burnTime = Math.min(FUEL_CAP, burnTime) / 2; + + if (!supertile.getWorldObj().isRemote) { + stack.stackSize--; + supertile + .getWorldObj() + .playSoundEffect( + supertile.xCoord, + supertile.yCoord, + supertile.zCoord, + "botania:endoflame", + 0.2F, + 1F); + + if (stack.stackSize == 0) item.setDead(); + + didSomething = true; + } else { + item.worldObj.spawnParticle( + "largesmoke", item.posX, item.posY + 0.1, item.posZ, 0.0D, 0.0D, 0.0D); + item.worldObj.spawnParticle( + "flame", item.posX, item.posY, item.posZ, 0.0D, 0.0D, 0.0D); + } + + break; + } + } + } + + if (didSomething) sync(); + } + } else { + if (supertile.getWorldObj().rand.nextInt(10) == 0) + supertile + .getWorldObj() + .spawnParticle( + "flame", + supertile.xCoord + 0.4 + Math.random() * 0.2, + supertile.yCoord + 0.65, + supertile.zCoord + 0.4 + Math.random() * 0.2, + 0.0D, + 0.0D, + 0.0D); + + burnTime--; + } + } + } + + @Override + public int getMaxMana() { + return 300; + } + + @Override + public int getValueForPassiveGeneration() { + return 3; + } + + @Override + public int getColor() { + return 0x785000; + } + + @Override + public RadiusDescriptor getRadius() { + return new RadiusDescriptor.Square(toChunkCoordinates(), RANGE); + } + + @Override + public LexiconEntry getEntry() { + return LexiconData.endoflame; + } + + @Override + public void writeToPacketNBT(NBTTagCompound cmp) { + super.writeToPacketNBT(cmp); + + cmp.setInteger(TAG_BURN_TIME, burnTime); + } + + @Override + public void readFromPacketNBT(NBTTagCompound cmp) { + super.readFromPacketNBT(cmp); + + burnTime = cmp.getInteger(TAG_BURN_TIME); + } + + @Override + public boolean canGeneratePassively() { + return burnTime > 0; + } + + @Override + public int getDelayBetweenPassiveGeneration() { + return 2; + } } diff --git a/src/main/java/vazkii/botania/common/block/subtile/generating/SubTileEntropinnyum.java b/src/main/java/vazkii/botania/common/block/subtile/generating/SubTileEntropinnyum.java index 37e81be647..32e2fbfd00 100644 --- a/src/main/java/vazkii/botania/common/block/subtile/generating/SubTileEntropinnyum.java +++ b/src/main/java/vazkii/botania/common/block/subtile/generating/SubTileEntropinnyum.java @@ -2,16 +2,15 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jun 7, 2014, 10:59:44 PM (GMT)] */ package vazkii.botania.common.block.subtile.generating; import java.util.List; - import net.minecraft.entity.item.EntityTNTPrimed; import net.minecraft.util.AxisAlignedBB; import net.minecraft.util.MathHelper; @@ -23,51 +22,97 @@ public class SubTileEntropinnyum extends SubTileGenerating { - private static final int RANGE = 12; - - @Override - public void onUpdate() { - super.onUpdate(); + private static final int RANGE = 12; - if(mana == 0) { - List tnts = supertile.getWorldObj().getEntitiesWithinAABB(EntityTNTPrimed.class, AxisAlignedBB.getBoundingBox(supertile.xCoord - RANGE, supertile.yCoord - RANGE, supertile.zCoord - RANGE, supertile.xCoord + RANGE + 1, supertile.yCoord + RANGE + 1, supertile.zCoord + RANGE + 1)); - for(EntityTNTPrimed tnt : tnts) { - if(tnt.fuse == 1 && !tnt.isDead && !supertile.getWorldObj().getBlock(MathHelper.floor_double(tnt.posX), MathHelper.floor_double(tnt.posY), MathHelper.floor_double(tnt.posZ)).getMaterial().isLiquid()) { - if(!supertile.getWorldObj().isRemote) { - tnt.setDead(); - mana += getMaxMana(); - supertile.getWorldObj().playSoundEffect(tnt.posX, tnt.posY, tnt.posZ, "random.explode", 0.2F, (1F + (supertile.getWorldObj().rand.nextFloat() - supertile.getWorldObj().rand.nextFloat()) * 0.2F) * 0.7F); - sync(); - } + @Override + public void onUpdate() { + super.onUpdate(); - for(int i = 0; i < 50; i++) - Botania.proxy.sparkleFX(tnt.worldObj, tnt.posX + Math.random() * 4 - 2, tnt.posY + Math.random() * 4 - 2, tnt.posZ + Math.random() * 4 - 2, 1F, (float) Math.random() * 0.25F, (float) Math.random() * 0.25F, (float) (Math.random() * 0.65F + 1.25F), 12); + if (mana == 0) { + List tnts = supertile + .getWorldObj() + .getEntitiesWithinAABB( + EntityTNTPrimed.class, + AxisAlignedBB.getBoundingBox( + supertile.xCoord - RANGE, + supertile.yCoord - RANGE, + supertile.zCoord - RANGE, + supertile.xCoord + RANGE + 1, + supertile.yCoord + RANGE + 1, + supertile.zCoord + RANGE + 1)); + for (EntityTNTPrimed tnt : tnts) { + if (tnt.fuse == 1 + && !tnt.isDead + && !supertile + .getWorldObj() + .getBlock( + MathHelper.floor_double(tnt.posX), + MathHelper.floor_double(tnt.posY), + MathHelper.floor_double(tnt.posZ)) + .getMaterial() + .isLiquid()) { + if (!supertile.getWorldObj().isRemote) { + tnt.setDead(); + mana += getMaxMana(); + supertile + .getWorldObj() + .playSoundEffect( + tnt.posX, + tnt.posY, + tnt.posZ, + "random.explode", + 0.2F, + (1F + + (supertile + .getWorldObj() + .rand + .nextFloat() + - supertile + .getWorldObj() + .rand + .nextFloat()) + * 0.2F) + * 0.7F); + sync(); + } - supertile.getWorldObj().spawnParticle("hugeexplosion", tnt.posX, tnt.posY, tnt.posZ, 1D, 0D, 0D); - return; - } - } - } - } + for (int i = 0; i < 50; i++) + Botania.proxy.sparkleFX( + tnt.worldObj, + tnt.posX + Math.random() * 4 - 2, + tnt.posY + Math.random() * 4 - 2, + tnt.posZ + Math.random() * 4 - 2, + 1F, + (float) Math.random() * 0.25F, + (float) Math.random() * 0.25F, + (float) (Math.random() * 0.65F + 1.25F), + 12); - @Override - public int getColor() { - return 0xcb0000; - } + supertile.getWorldObj().spawnParticle("hugeexplosion", tnt.posX, tnt.posY, tnt.posZ, 1D, 0D, 0D); + return; + } + } + } + } - @Override - public int getMaxMana() { - return 6500; - } + @Override + public int getColor() { + return 0xcb0000; + } - @Override - public RadiusDescriptor getRadius() { - return new RadiusDescriptor.Square(toChunkCoordinates(), RANGE); - }; + @Override + public int getMaxMana() { + return 6500; + } - @Override - public LexiconEntry getEntry() { - return LexiconData.entropinnyum; - } + @Override + public RadiusDescriptor getRadius() { + return new RadiusDescriptor.Square(toChunkCoordinates(), RANGE); + } + ; + @Override + public LexiconEntry getEntry() { + return LexiconData.entropinnyum; + } } diff --git a/src/main/java/vazkii/botania/common/block/subtile/generating/SubTileGourmaryllis.java b/src/main/java/vazkii/botania/common/block/subtile/generating/SubTileGourmaryllis.java index 5109539e70..90e3d137ec 100644 --- a/src/main/java/vazkii/botania/common/block/subtile/generating/SubTileGourmaryllis.java +++ b/src/main/java/vazkii/botania/common/block/subtile/generating/SubTileGourmaryllis.java @@ -2,16 +2,15 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jul 26, 2014, 1:42:17 PM (GMT)] */ package vazkii.botania.common.block.subtile.generating; import java.util.List; - import net.minecraft.entity.item.EntityItem; import net.minecraft.item.Item; import net.minecraft.item.ItemFood; @@ -25,86 +24,109 @@ public class SubTileGourmaryllis extends SubTileGenerating { - private static final String TAG_COOLDOWN = "cooldown"; - private static final int RANGE = 1; - - int cooldown = 0; - int storedMana = 0; - - @Override - public void onUpdate() { - super.onUpdate(); - - if(cooldown > 0) - cooldown--; - if(cooldown == 0 && !supertile.getWorldObj().isRemote) { - mana = Math.min(getMaxMana(), mana + storedMana); - storedMana = 0; - sync(); - } - - int slowdown = getSlowdownFactor(); - - boolean remote = supertile.getWorldObj().isRemote; - List items = supertile.getWorldObj().getEntitiesWithinAABB(EntityItem.class, AxisAlignedBB.getBoundingBox(supertile.xCoord - RANGE, supertile.yCoord - RANGE, supertile.zCoord - RANGE, supertile.xCoord + RANGE + 1, supertile.yCoord + RANGE + 1, supertile.zCoord + RANGE + 1)); - for(EntityItem item : items) { - ItemStack stack = item.getEntityItem(); - if(stack != null && stack.getItem() instanceof ItemFood && !item.isDead && item.age >= slowdown) { - if(cooldown == 0) { - if(!remote) { - int val = ((ItemFood) stack.getItem()).func_150905_g(stack); - storedMana = val * val * 64; - cooldown = val * 10; - supertile.getWorldObj().playSoundEffect(supertile.xCoord, supertile.yCoord, supertile.zCoord, "random.eat", 0.2F, 0.5F + (float) Math.random() * 0.5F); - sync(); - } else - for(int i = 0; i < 10; i++) { - float m = 0.2F; - float mx = (float) (Math.random() - 0.5) * m; - float my = (float) (Math.random() - 0.5) * m; - float mz = (float) (Math.random() - 0.5) * m; - supertile.getWorldObj().spawnParticle("iconcrack_" + Item.getIdFromItem(stack.getItem()), item.posX, item.posY, item.posZ, mx, my, mz); - } - - } - - if(!remote) - item.setDead(); - } - } - } - - @Override - public void writeToPacketNBT(NBTTagCompound cmp) { - super.writeToPacketNBT(cmp); - cmp.setInteger(TAG_COOLDOWN, cooldown); - cmp.setInteger(TAG_COOLDOWN, cooldown); - } - - @Override - public void readFromPacketNBT(NBTTagCompound cmp) { - super.readFromPacketNBT(cmp); - cooldown = cmp.getInteger(TAG_COOLDOWN); - } - - @Override - public RadiusDescriptor getRadius() { - return new RadiusDescriptor.Square(toChunkCoordinates(), RANGE); - } - - @Override - public int getMaxMana() { - return 8000; - } - - @Override - public int getColor() { - return 0xD3D604; - } - - @Override - public LexiconEntry getEntry() { - return LexiconData.gourmaryllis; - } - + private static final String TAG_COOLDOWN = "cooldown"; + private static final int RANGE = 1; + + int cooldown = 0; + int storedMana = 0; + + @Override + public void onUpdate() { + super.onUpdate(); + + if (cooldown > 0) cooldown--; + if (cooldown == 0 && !supertile.getWorldObj().isRemote) { + mana = Math.min(getMaxMana(), mana + storedMana); + storedMana = 0; + sync(); + } + + int slowdown = getSlowdownFactor(); + + boolean remote = supertile.getWorldObj().isRemote; + List items = supertile + .getWorldObj() + .getEntitiesWithinAABB( + EntityItem.class, + AxisAlignedBB.getBoundingBox( + supertile.xCoord - RANGE, + supertile.yCoord - RANGE, + supertile.zCoord - RANGE, + supertile.xCoord + RANGE + 1, + supertile.yCoord + RANGE + 1, + supertile.zCoord + RANGE + 1)); + for (EntityItem item : items) { + ItemStack stack = item.getEntityItem(); + if (stack != null && stack.getItem() instanceof ItemFood && !item.isDead && item.age >= slowdown) { + if (cooldown == 0) { + if (!remote) { + int val = ((ItemFood) stack.getItem()).func_150905_g(stack); + storedMana = val * val * 64; + cooldown = val * 10; + supertile + .getWorldObj() + .playSoundEffect( + supertile.xCoord, + supertile.yCoord, + supertile.zCoord, + "random.eat", + 0.2F, + 0.5F + (float) Math.random() * 0.5F); + sync(); + } else + for (int i = 0; i < 10; i++) { + float m = 0.2F; + float mx = (float) (Math.random() - 0.5) * m; + float my = (float) (Math.random() - 0.5) * m; + float mz = (float) (Math.random() - 0.5) * m; + supertile + .getWorldObj() + .spawnParticle( + "iconcrack_" + Item.getIdFromItem(stack.getItem()), + item.posX, + item.posY, + item.posZ, + mx, + my, + mz); + } + } + + if (!remote) item.setDead(); + } + } + } + + @Override + public void writeToPacketNBT(NBTTagCompound cmp) { + super.writeToPacketNBT(cmp); + cmp.setInteger(TAG_COOLDOWN, cooldown); + cmp.setInteger(TAG_COOLDOWN, cooldown); + } + + @Override + public void readFromPacketNBT(NBTTagCompound cmp) { + super.readFromPacketNBT(cmp); + cooldown = cmp.getInteger(TAG_COOLDOWN); + } + + @Override + public RadiusDescriptor getRadius() { + return new RadiusDescriptor.Square(toChunkCoordinates(), RANGE); + } + + @Override + public int getMaxMana() { + return 8000; + } + + @Override + public int getColor() { + return 0xD3D604; + } + + @Override + public LexiconEntry getEntry() { + return LexiconData.gourmaryllis; + } } diff --git a/src/main/java/vazkii/botania/common/block/subtile/generating/SubTileHydroangeas.java b/src/main/java/vazkii/botania/common/block/subtile/generating/SubTileHydroangeas.java index 7bb064c870..f10afb77fe 100644 --- a/src/main/java/vazkii/botania/common/block/subtile/generating/SubTileHydroangeas.java +++ b/src/main/java/vazkii/botania/common/block/subtile/generating/SubTileHydroangeas.java @@ -13,7 +13,6 @@ import java.util.Arrays; import java.util.Collections; import java.util.List; - import net.minecraft.block.Block; import net.minecraft.block.material.Material; import net.minecraft.entity.EntityLivingBase; @@ -32,155 +31,197 @@ @PassiveFlower public class SubTileHydroangeas extends SubTilePassiveGenerating { - private static final String TAG_BURN_TIME = "burnTime"; - private static final String TAG_COOLDOWN = "cooldown"; - - private static final int[][] OFFSETS = { { 0, 1 }, { 0, -1 }, { 1, 0 }, { -1, 0 }, { -1, 1 }, { -1, -1 }, { 1, 1 }, { 1, -1 } }; - - int burnTime, cooldown; - - @Override - public void onUpdate() { - super.onUpdate(); - - if(cooldown > 0) { - cooldown--; - for(int i = 0; i < 3; i++) - Botania.proxy.wispFX(supertile.getWorldObj(), supertile.xCoord + 0.5 + Math.random() * 0.2 - 0.1, supertile.yCoord + 0.5 + Math.random() * 0.2 - 0.1, supertile.zCoord + 0.5 + Math.random() * 0.2 - 0.1, 0.1F, 0.1F, 0.1F, (float) Math.random() / 6, (float) -Math.random() / 30); - } - - if(burnTime == 0) { - if(mana < getMaxMana() && !supertile.getWorldObj().isRemote) { - List offsets = Arrays.asList(OFFSETS); - Collections.shuffle(offsets); - - for(int[] offsetArray : offsets) { - int[] positions = { - supertile.xCoord + offsetArray[0], - supertile.zCoord + offsetArray[1] - }; - - Material search = getMaterialToSearchFor(); - if(supertile.getWorldObj().getBlock(positions[0], supertile.yCoord, positions[1]).getMaterial() == search && (getBlockToSearchBelow() == null || supertile.getWorldObj().getBlock(positions[0], supertile.yCoord - 1, positions[1]) == getBlockToSearchBelow()) && supertile.getWorldObj().getBlockMetadata(positions[0], supertile.yCoord, positions[1]) == 0) { - if(search != Material.water) - supertile.getWorldObj().setBlockToAir(positions[0], supertile.yCoord, positions[1]); - else { - int waterAround = 0; - for(ForgeDirection dir : LibMisc.CARDINAL_DIRECTIONS) - if(supertile.getWorldObj().getBlock(positions[0] + dir.offsetX, supertile.yCoord, positions[1] + dir.offsetZ).getMaterial() == search) - waterAround++; - - if(waterAround < 2) - supertile.getWorldObj().setBlockToAir(positions[0], supertile.yCoord, positions[1]); - } - - if(cooldown == 0) - burnTime += getBurnTime(); - else cooldown = getCooldown(); - - sync(); - playSound(); - break; - } - } - } - } else { - if(supertile.getWorldObj().rand.nextInt(8) == 0) - doBurnParticles(); - burnTime--; - if(burnTime == 0) { - cooldown = getCooldown(); - sync(); - } - } - } - - public void doBurnParticles() { - Botania.proxy.wispFX(supertile.getWorldObj(), supertile.xCoord + 0.55 + Math.random() * 0.2 - 0.1, supertile.yCoord + 0.55 + Math.random() * 0.2 - 0.1, supertile.zCoord + 0.5, 0.05F, 0.05F, 0.7F, (float) Math.random() / 6, (float) -Math.random() / 60); - } - - public Material getMaterialToSearchFor() { - return Material.water; - } - - public Block getBlockToSearchBelow() { - return null; - } - - public void playSound() { - supertile.getWorldObj().playSoundEffect(supertile.xCoord, supertile.yCoord, supertile.zCoord, "random.drink", 0.01F, 0.5F + (float) Math.random() * 0.5F); - } - - public int getBurnTime() { - return 40; - } - - @Override - public RadiusDescriptor getRadius() { - return new RadiusDescriptor.Square(toChunkCoordinates(), 1); - } - - @Override - public int getMaxMana() { - return 150; - } - - @Override - public int getColor() { - return 0x532FE0; - } - - @Override - public LexiconEntry getEntry() { - return LexiconData.hydroangeas; - } - - @Override - public void writeToPacketNBT(NBTTagCompound cmp) { - super.writeToPacketNBT(cmp); - - cmp.setInteger(TAG_BURN_TIME, burnTime); - cmp.setInteger(TAG_COOLDOWN, cooldown); - } - - @Override - public void readFromPacketNBT(NBTTagCompound cmp) { - super.readFromPacketNBT(cmp); - - burnTime = cmp.getInteger(TAG_BURN_TIME); - cooldown = cmp.getInteger(TAG_COOLDOWN); - } - - @Override - public void populateDropStackNBTs(List drops) { - super.populateDropStackNBTs(drops); - int cooldown = this.cooldown; - if(burnTime > 0) - cooldown = getCooldown(); - - if(cooldown > 0) - ItemNBTHelper.setInt(drops.get(0), TAG_COOLDOWN, getCooldown()); - } - - @Override - public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase entity, ItemStack stack) { - super.onBlockPlacedBy(world, x, y, z, entity, stack); - cooldown = ItemNBTHelper.getInt(stack, TAG_COOLDOWN, 0); - } - - @Override - public boolean canGeneratePassively() { - return burnTime > 0; - } - - @Override - public int getDelayBetweenPassiveGeneration() { - boolean rain = supertile.getWorldObj().getWorldChunkManager().getBiomeGenAt(supertile.xCoord, supertile.zCoord).getIntRainfall() > 0 && (supertile.getWorldObj().isRaining() || supertile.getWorldObj().isThundering()); - return rain ? 1 : 2; - } - - public int getCooldown() { - return 0; - } - + private static final String TAG_BURN_TIME = "burnTime"; + private static final String TAG_COOLDOWN = "cooldown"; + + private static final int[][] OFFSETS = {{0, 1}, {0, -1}, {1, 0}, {-1, 0}, {-1, 1}, {-1, -1}, {1, 1}, {1, -1}}; + + int burnTime, cooldown; + + @Override + public void onUpdate() { + super.onUpdate(); + + if (cooldown > 0) { + cooldown--; + for (int i = 0; i < 3; i++) + Botania.proxy.wispFX( + supertile.getWorldObj(), + supertile.xCoord + 0.5 + Math.random() * 0.2 - 0.1, + supertile.yCoord + 0.5 + Math.random() * 0.2 - 0.1, + supertile.zCoord + 0.5 + Math.random() * 0.2 - 0.1, + 0.1F, + 0.1F, + 0.1F, + (float) Math.random() / 6, + (float) -Math.random() / 30); + } + + if (burnTime == 0) { + if (mana < getMaxMana() && !supertile.getWorldObj().isRemote) { + List offsets = Arrays.asList(OFFSETS); + Collections.shuffle(offsets); + + for (int[] offsetArray : offsets) { + int[] positions = {supertile.xCoord + offsetArray[0], supertile.zCoord + offsetArray[1]}; + + Material search = getMaterialToSearchFor(); + if (supertile + .getWorldObj() + .getBlock(positions[0], supertile.yCoord, positions[1]) + .getMaterial() + == search + && (getBlockToSearchBelow() == null + || supertile + .getWorldObj() + .getBlock(positions[0], supertile.yCoord - 1, positions[1]) + == getBlockToSearchBelow()) + && supertile.getWorldObj().getBlockMetadata(positions[0], supertile.yCoord, positions[1]) + == 0) { + if (search != Material.water) + supertile.getWorldObj().setBlockToAir(positions[0], supertile.yCoord, positions[1]); + else { + int waterAround = 0; + for (ForgeDirection dir : LibMisc.CARDINAL_DIRECTIONS) + if (supertile + .getWorldObj() + .getBlock( + positions[0] + dir.offsetX, + supertile.yCoord, + positions[1] + dir.offsetZ) + .getMaterial() + == search) waterAround++; + + if (waterAround < 2) + supertile.getWorldObj().setBlockToAir(positions[0], supertile.yCoord, positions[1]); + } + + if (cooldown == 0) burnTime += getBurnTime(); + else cooldown = getCooldown(); + + sync(); + playSound(); + break; + } + } + } + } else { + if (supertile.getWorldObj().rand.nextInt(8) == 0) doBurnParticles(); + burnTime--; + if (burnTime == 0) { + cooldown = getCooldown(); + sync(); + } + } + } + + public void doBurnParticles() { + Botania.proxy.wispFX( + supertile.getWorldObj(), + supertile.xCoord + 0.55 + Math.random() * 0.2 - 0.1, + supertile.yCoord + 0.55 + Math.random() * 0.2 - 0.1, + supertile.zCoord + 0.5, + 0.05F, + 0.05F, + 0.7F, + (float) Math.random() / 6, + (float) -Math.random() / 60); + } + + public Material getMaterialToSearchFor() { + return Material.water; + } + + public Block getBlockToSearchBelow() { + return null; + } + + public void playSound() { + supertile + .getWorldObj() + .playSoundEffect( + supertile.xCoord, + supertile.yCoord, + supertile.zCoord, + "random.drink", + 0.01F, + 0.5F + (float) Math.random() * 0.5F); + } + + public int getBurnTime() { + return 40; + } + + @Override + public RadiusDescriptor getRadius() { + return new RadiusDescriptor.Square(toChunkCoordinates(), 1); + } + + @Override + public int getMaxMana() { + return 150; + } + + @Override + public int getColor() { + return 0x532FE0; + } + + @Override + public LexiconEntry getEntry() { + return LexiconData.hydroangeas; + } + + @Override + public void writeToPacketNBT(NBTTagCompound cmp) { + super.writeToPacketNBT(cmp); + + cmp.setInteger(TAG_BURN_TIME, burnTime); + cmp.setInteger(TAG_COOLDOWN, cooldown); + } + + @Override + public void readFromPacketNBT(NBTTagCompound cmp) { + super.readFromPacketNBT(cmp); + + burnTime = cmp.getInteger(TAG_BURN_TIME); + cooldown = cmp.getInteger(TAG_COOLDOWN); + } + + @Override + public void populateDropStackNBTs(List drops) { + super.populateDropStackNBTs(drops); + int cooldown = this.cooldown; + if (burnTime > 0) cooldown = getCooldown(); + + if (cooldown > 0) ItemNBTHelper.setInt(drops.get(0), TAG_COOLDOWN, getCooldown()); + } + + @Override + public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase entity, ItemStack stack) { + super.onBlockPlacedBy(world, x, y, z, entity, stack); + cooldown = ItemNBTHelper.getInt(stack, TAG_COOLDOWN, 0); + } + + @Override + public boolean canGeneratePassively() { + return burnTime > 0; + } + + @Override + public int getDelayBetweenPassiveGeneration() { + boolean rain = supertile + .getWorldObj() + .getWorldChunkManager() + .getBiomeGenAt(supertile.xCoord, supertile.zCoord) + .getIntRainfall() + > 0 + && (supertile.getWorldObj().isRaining() + || supertile.getWorldObj().isThundering()); + return rain ? 1 : 2; + } + + public int getCooldown() { + return 0; + } } diff --git a/src/main/java/vazkii/botania/common/block/subtile/generating/SubTileKekimurus.java b/src/main/java/vazkii/botania/common/block/subtile/generating/SubTileKekimurus.java index cbb2a15e1c..9eeb5dc68b 100644 --- a/src/main/java/vazkii/botania/common/block/subtile/generating/SubTileKekimurus.java +++ b/src/main/java/vazkii/botania/common/block/subtile/generating/SubTileKekimurus.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jun 8, 2014, 6:26:37 PM (GMT)] */ package vazkii.botania.common.block.subtile.generating; @@ -19,56 +19,64 @@ public class SubTileKekimurus extends SubTileGenerating { - private static final int RANGE = 5; + private static final int RANGE = 5; - @Override - public void onUpdate() { - super.onUpdate(); + @Override + public void onUpdate() { + super.onUpdate(); - int mana = 1800; + int mana = 1800; - if(getMaxMana() - this.mana >= mana && !supertile.getWorldObj().isRemote && ticksExisted % 80 == 0) { - for(int i = 0; i < RANGE * 2 + 1; i++) - for(int j = 0; j < RANGE * 2 + 1; j++) - for(int k = 0; k < RANGE * 2 + 1; k++) { - int x = supertile.xCoord + i - RANGE; - int y = supertile.yCoord + j - RANGE; - int z = supertile.zCoord + k - RANGE; - Block block = supertile.getWorldObj().getBlock(x, y, z); - if(block instanceof BlockCake) { - int meta = supertile.getWorldObj().getBlockMetadata(x, y, z) + 1; - if(meta == 6) - supertile.getWorldObj().setBlockToAir(x, y, z); - else supertile.getWorldObj().setBlockMetadataWithNotify(x, y, z, meta, 1 | 2); + if (getMaxMana() - this.mana >= mana && !supertile.getWorldObj().isRemote && ticksExisted % 80 == 0) { + for (int i = 0; i < RANGE * 2 + 1; i++) + for (int j = 0; j < RANGE * 2 + 1; j++) + for (int k = 0; k < RANGE * 2 + 1; k++) { + int x = supertile.xCoord + i - RANGE; + int y = supertile.yCoord + j - RANGE; + int z = supertile.zCoord + k - RANGE; + Block block = supertile.getWorldObj().getBlock(x, y, z); + if (block instanceof BlockCake) { + int meta = supertile.getWorldObj().getBlockMetadata(x, y, z) + 1; + if (meta == 6) supertile.getWorldObj().setBlockToAir(x, y, z); + else supertile.getWorldObj().setBlockMetadataWithNotify(x, y, z, meta, 1 | 2); - supertile.getWorldObj().playAuxSFX(2001, x, y, z, Block.getIdFromBlock(block) + (meta << 12)); - supertile.getWorldObj().playSoundEffect(supertile.xCoord, supertile.yCoord, supertile.zCoord, "random.eat", 1F, 0.5F + (float) Math.random() * 0.5F); - this.mana += mana; - sync(); - return; - } - } - } - } + supertile + .getWorldObj() + .playAuxSFX(2001, x, y, z, Block.getIdFromBlock(block) + (meta << 12)); + supertile + .getWorldObj() + .playSoundEffect( + supertile.xCoord, + supertile.yCoord, + supertile.zCoord, + "random.eat", + 1F, + 0.5F + (float) Math.random() * 0.5F); + this.mana += mana; + sync(); + return; + } + } + } + } - @Override - public RadiusDescriptor getRadius() { - return new RadiusDescriptor.Square(toChunkCoordinates(), RANGE); - } + @Override + public RadiusDescriptor getRadius() { + return new RadiusDescriptor.Square(toChunkCoordinates(), RANGE); + } - @Override - public LexiconEntry getEntry() { - return LexiconData.kekimurus; - } + @Override + public LexiconEntry getEntry() { + return LexiconData.kekimurus; + } - @Override - public int getColor() { - return 0x935D28; - } - - @Override - public int getMaxMana() { - return 9001; - } + @Override + public int getColor() { + return 0x935D28; + } + @Override + public int getMaxMana() { + return 9001; + } } diff --git a/src/main/java/vazkii/botania/common/block/subtile/generating/SubTileMunchdew.java b/src/main/java/vazkii/botania/common/block/subtile/generating/SubTileMunchdew.java index 0b7a66f58f..85a14a3637 100644 --- a/src/main/java/vazkii/botania/common/block/subtile/generating/SubTileMunchdew.java +++ b/src/main/java/vazkii/botania/common/block/subtile/generating/SubTileMunchdew.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [May 15, 2014, 7:25:47 PM (GMT)] */ package vazkii.botania.common.block.subtile.generating; @@ -13,7 +13,6 @@ import java.util.ArrayList; import java.util.Collections; import java.util.List; - import net.minecraft.block.Block; import net.minecraft.block.material.Material; import net.minecraft.entity.EntityLivingBase; @@ -31,124 +30,136 @@ public class SubTileMunchdew extends SubTileGenerating { - private static final String TAG_COOLDOWN = "cooldown"; - private static final String TAG_ATE_ONCE = "ateOnce"; - - private static final int RANGE = 8; - private static final int RANGE_Y = 16; - - boolean ateOnce = false; - int ticksWithoutEating = -1; - int cooldown = 0; - - @Override - public void onUpdate() { - super.onUpdate(); - - if(cooldown > 0) { - cooldown--; - ticksWithoutEating = 0; - return; - } - - int manaPerLeaf = 160; - eatLeaves : { - if(getMaxMana() - mana >= manaPerLeaf && !supertile.getWorldObj().isRemote && ticksExisted % 4 == 0) { - List coords = new ArrayList(); - int x = supertile.xCoord; - int y = supertile.yCoord; - int z = supertile.zCoord; - - for(int i = -RANGE; i < RANGE + 1; i++) - for(int j = 0; j < RANGE_Y; j++) - for(int k = -RANGE; k < RANGE + 1; k++) { - int xp = x + i; - int yp = y + j; - int zp = z + k; - Block block = supertile.getWorldObj().getBlock(xp, yp, zp); - if(block.getMaterial() == Material.leaves) { - boolean exposed = false; - for(ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS) - if(supertile.getWorldObj().getBlock(xp + dir.offsetX, yp + dir.offsetY, zp + dir.offsetZ).isAir(supertile.getWorldObj(), xp + dir.offsetX, yp + dir.offsetY, zp + dir.offsetZ)) { - exposed = true; - break; - } - - if(exposed) - coords.add(new ChunkCoordinates(xp, yp, zp)); - } - } - - if(coords.isEmpty()) - break eatLeaves; - - Collections.shuffle(coords); - ChunkCoordinates breakCoords = coords.get(0); - Block block = supertile.getWorldObj().getBlock(breakCoords.posX, breakCoords.posY, breakCoords.posZ); - int meta = supertile.getWorldObj().getBlockMetadata(breakCoords.posX, breakCoords.posY, breakCoords.posZ); - supertile.getWorldObj().setBlockToAir(breakCoords.posX, breakCoords.posY, breakCoords.posZ); - ticksWithoutEating = 0; - ateOnce = true; - if(ConfigHandler.blockBreakParticles) - supertile.getWorldObj().playAuxSFX(2001, breakCoords.posX, breakCoords.posY, breakCoords.posZ, Block.getIdFromBlock(block) + (meta << 12)); - mana += manaPerLeaf; - } - } - - if(ateOnce) { - ticksWithoutEating++; - if(ticksWithoutEating >= 5) - cooldown = 1600; - } - } - - @Override - public RadiusDescriptor getRadius() { - return new RadiusDescriptor.Square(toChunkCoordinates(), RANGE); - } - - @Override - public void writeToPacketNBT(NBTTagCompound cmp) { - super.writeToPacketNBT(cmp); - - cmp.setInteger(TAG_COOLDOWN, cooldown); - cmp.setBoolean(TAG_ATE_ONCE, ateOnce); - } - - @Override - public void readFromPacketNBT(NBTTagCompound cmp) { - super.readFromPacketNBT(cmp); - - cooldown = cmp.getInteger(TAG_COOLDOWN); - ateOnce = cmp.getBoolean(TAG_ATE_ONCE); - } - - @Override - public ArrayList getDrops(ArrayList list) { - ArrayList drops = super.getDrops(list); - if(cooldown > 0) - ItemNBTHelper.setInt(drops.get(0), TAG_COOLDOWN, cooldown); - return drops; - } - - @Override - public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase entity, ItemStack stack) { - super.onBlockPlacedBy(world, x, y, z, entity, stack); - cooldown = ItemNBTHelper.getInt(stack, TAG_COOLDOWN, 0); - } - - @Override - public int getColor() { - return 0x79C42F; - } - - @Override - public int getMaxMana() { - return 10000; - } - - @Override - public LexiconEntry getEntry() { - return LexiconData.munchdew; - } + private static final String TAG_COOLDOWN = "cooldown"; + private static final String TAG_ATE_ONCE = "ateOnce"; + + private static final int RANGE = 8; + private static final int RANGE_Y = 16; + + boolean ateOnce = false; + int ticksWithoutEating = -1; + int cooldown = 0; + + @Override + public void onUpdate() { + super.onUpdate(); + + if (cooldown > 0) { + cooldown--; + ticksWithoutEating = 0; + return; + } + + int manaPerLeaf = 160; + eatLeaves: + { + if (getMaxMana() - mana >= manaPerLeaf && !supertile.getWorldObj().isRemote && ticksExisted % 4 == 0) { + List coords = new ArrayList(); + int x = supertile.xCoord; + int y = supertile.yCoord; + int z = supertile.zCoord; + + for (int i = -RANGE; i < RANGE + 1; i++) + for (int j = 0; j < RANGE_Y; j++) + for (int k = -RANGE; k < RANGE + 1; k++) { + int xp = x + i; + int yp = y + j; + int zp = z + k; + Block block = supertile.getWorldObj().getBlock(xp, yp, zp); + if (block.getMaterial() == Material.leaves) { + boolean exposed = false; + for (ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS) + if (supertile + .getWorldObj() + .getBlock(xp + dir.offsetX, yp + dir.offsetY, zp + dir.offsetZ) + .isAir( + supertile.getWorldObj(), + xp + dir.offsetX, + yp + dir.offsetY, + zp + dir.offsetZ)) { + exposed = true; + break; + } + + if (exposed) coords.add(new ChunkCoordinates(xp, yp, zp)); + } + } + + if (coords.isEmpty()) break eatLeaves; + + Collections.shuffle(coords); + ChunkCoordinates breakCoords = coords.get(0); + Block block = supertile.getWorldObj().getBlock(breakCoords.posX, breakCoords.posY, breakCoords.posZ); + int meta = + supertile.getWorldObj().getBlockMetadata(breakCoords.posX, breakCoords.posY, breakCoords.posZ); + supertile.getWorldObj().setBlockToAir(breakCoords.posX, breakCoords.posY, breakCoords.posZ); + ticksWithoutEating = 0; + ateOnce = true; + if (ConfigHandler.blockBreakParticles) + supertile + .getWorldObj() + .playAuxSFX( + 2001, + breakCoords.posX, + breakCoords.posY, + breakCoords.posZ, + Block.getIdFromBlock(block) + (meta << 12)); + mana += manaPerLeaf; + } + } + + if (ateOnce) { + ticksWithoutEating++; + if (ticksWithoutEating >= 5) cooldown = 1600; + } + } + + @Override + public RadiusDescriptor getRadius() { + return new RadiusDescriptor.Square(toChunkCoordinates(), RANGE); + } + + @Override + public void writeToPacketNBT(NBTTagCompound cmp) { + super.writeToPacketNBT(cmp); + + cmp.setInteger(TAG_COOLDOWN, cooldown); + cmp.setBoolean(TAG_ATE_ONCE, ateOnce); + } + + @Override + public void readFromPacketNBT(NBTTagCompound cmp) { + super.readFromPacketNBT(cmp); + + cooldown = cmp.getInteger(TAG_COOLDOWN); + ateOnce = cmp.getBoolean(TAG_ATE_ONCE); + } + + @Override + public ArrayList getDrops(ArrayList list) { + ArrayList drops = super.getDrops(list); + if (cooldown > 0) ItemNBTHelper.setInt(drops.get(0), TAG_COOLDOWN, cooldown); + return drops; + } + + @Override + public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase entity, ItemStack stack) { + super.onBlockPlacedBy(world, x, y, z, entity, stack); + cooldown = ItemNBTHelper.getInt(stack, TAG_COOLDOWN, 0); + } + + @Override + public int getColor() { + return 0x79C42F; + } + + @Override + public int getMaxMana() { + return 10000; + } + + @Override + public LexiconEntry getEntry() { + return LexiconData.munchdew; + } } diff --git a/src/main/java/vazkii/botania/common/block/subtile/generating/SubTileNarslimmus.java b/src/main/java/vazkii/botania/common/block/subtile/generating/SubTileNarslimmus.java index 875fbb094b..0c2ae6d96b 100644 --- a/src/main/java/vazkii/botania/common/block/subtile/generating/SubTileNarslimmus.java +++ b/src/main/java/vazkii/botania/common/block/subtile/generating/SubTileNarslimmus.java @@ -2,16 +2,17 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jan 29, 2015, 10:43:54 PM (GMT)] */ package vazkii.botania.common.block.subtile.generating; +import cpw.mods.fml.common.eventhandler.Event.Result; +import cpw.mods.fml.common.eventhandler.SubscribeEvent; import java.util.List; - import net.minecraft.entity.monster.EntitySlime; import net.minecraft.util.AxisAlignedBB; import net.minecraft.util.MathHelper; @@ -22,80 +23,98 @@ import vazkii.botania.api.subtile.RadiusDescriptor; import vazkii.botania.api.subtile.SubTileGenerating; import vazkii.botania.common.lexicon.LexiconData; -import cpw.mods.fml.common.eventhandler.Event.Result; -import cpw.mods.fml.common.eventhandler.SubscribeEvent; public class SubTileNarslimmus extends SubTileGenerating { - public static final String TAG_WORLD_SPAWNED = "Botania:WorldSpawned"; - - private static final int RANGE = 2; - - @Override - public void onUpdate() { - super.onUpdate(); - - if(ticksExisted % 5 == 0) { - List slimes = supertile.getWorldObj().getEntitiesWithinAABB(EntitySlime.class, AxisAlignedBB.getBoundingBox(supertile.xCoord - RANGE, supertile.yCoord - RANGE, supertile.zCoord - RANGE, supertile.xCoord + RANGE + 1, supertile.yCoord + RANGE, supertile.zCoord + RANGE + 1)); - for(EntitySlime slime : slimes) { - if(slime.getEntityData().getBoolean(TAG_WORLD_SPAWNED) && !slime.isDead) { - int size = slime.getSlimeSize(); - int mul = (int) Math.pow(2, size); - int mana = 820 * mul; - if(!slime.worldObj.isRemote) { - slime.setDead(); - slime.worldObj.playSoundAtEntity(slime, "mob.slime." + (size > 1 ? "big" : "small"), 1F, 0.02F); - this.mana = Math.min(getMaxMana(), this.mana + mana); - sync(); - } - - for (int j = 0; j < mul * 8; ++j) { - float f = slime.worldObj.rand.nextFloat() * (float)Math.PI * 2.0F; - float f1 = slime.worldObj.rand.nextFloat() * 0.5F + 0.5F; - float f2 = MathHelper.sin(f) * size * 0.5F * f1; - float f3 = MathHelper.cos(f) * size * 0.5F * f1; - float f4 = slime.worldObj.rand.nextFloat() * size * 0.5F * f1; - slime.worldObj.spawnParticle("slime", slime.posX + f2, slime.boundingBox.minY + f4, slime.posZ + f3, 0.0D, 0.0D, 0.0D); - } - break; - } - } - } - } - - @Override - public RadiusDescriptor getRadius() { - return new RadiusDescriptor.Square(toChunkCoordinates(), RANGE); - } - - @Override - public int getMaxMana() { - return 8000; - } - - @Override - public int getColor() { - return 0x71C373; - } - - @Override - public LexiconEntry getEntry() { - return LexiconData.narslimmus; - } - - public static class SpawnIntercepter { - - @SubscribeEvent - public void onSpawn(LivingSpawnEvent.CheckSpawn event) { - if(event.entityLiving instanceof EntitySlime && event.getResult() != Result.DENY && isSlimeChunk(event.entityLiving.worldObj, MathHelper.floor_double(event.x), MathHelper.floor_double(event.z))) - event.entityLiving.getEntityData().setBoolean(TAG_WORLD_SPAWNED, true); - } - - public static boolean isSlimeChunk(World world, int x, int z) { - Chunk chunk = world.getChunkFromBlockCoords(x, z); - return chunk.getRandomWithSeed(987234911L).nextInt(10) == 0; - } - - } - + public static final String TAG_WORLD_SPAWNED = "Botania:WorldSpawned"; + + private static final int RANGE = 2; + + @Override + public void onUpdate() { + super.onUpdate(); + + if (ticksExisted % 5 == 0) { + List slimes = supertile + .getWorldObj() + .getEntitiesWithinAABB( + EntitySlime.class, + AxisAlignedBB.getBoundingBox( + supertile.xCoord - RANGE, + supertile.yCoord - RANGE, + supertile.zCoord - RANGE, + supertile.xCoord + RANGE + 1, + supertile.yCoord + RANGE, + supertile.zCoord + RANGE + 1)); + for (EntitySlime slime : slimes) { + if (slime.getEntityData().getBoolean(TAG_WORLD_SPAWNED) && !slime.isDead) { + int size = slime.getSlimeSize(); + int mul = (int) Math.pow(2, size); + int mana = 820 * mul; + if (!slime.worldObj.isRemote) { + slime.setDead(); + slime.worldObj.playSoundAtEntity(slime, "mob.slime." + (size > 1 ? "big" : "small"), 1F, 0.02F); + this.mana = Math.min(getMaxMana(), this.mana + mana); + sync(); + } + + for (int j = 0; j < mul * 8; ++j) { + float f = slime.worldObj.rand.nextFloat() * (float) Math.PI * 2.0F; + float f1 = slime.worldObj.rand.nextFloat() * 0.5F + 0.5F; + float f2 = MathHelper.sin(f) * size * 0.5F * f1; + float f3 = MathHelper.cos(f) * size * 0.5F * f1; + float f4 = slime.worldObj.rand.nextFloat() * size * 0.5F * f1; + slime.worldObj.spawnParticle( + "slime", + slime.posX + f2, + slime.boundingBox.minY + f4, + slime.posZ + f3, + 0.0D, + 0.0D, + 0.0D); + } + break; + } + } + } + } + + @Override + public RadiusDescriptor getRadius() { + return new RadiusDescriptor.Square(toChunkCoordinates(), RANGE); + } + + @Override + public int getMaxMana() { + return 8000; + } + + @Override + public int getColor() { + return 0x71C373; + } + + @Override + public LexiconEntry getEntry() { + return LexiconData.narslimmus; + } + + public static class SpawnIntercepter { + + @SubscribeEvent + public void onSpawn(LivingSpawnEvent.CheckSpawn event) { + if (event.entityLiving instanceof EntitySlime + && event.getResult() != Result.DENY + && isSlimeChunk( + event.entityLiving.worldObj, + MathHelper.floor_double(event.x), + MathHelper.floor_double(event.z))) + event.entityLiving.getEntityData().setBoolean(TAG_WORLD_SPAWNED, true); + } + + public static boolean isSlimeChunk(World world, int x, int z) { + Chunk chunk = world.getChunkFromBlockCoords(x, z); + return chunk.getRandomWithSeed(987234911L).nextInt(10) == 0; + } + } } diff --git a/src/main/java/vazkii/botania/common/block/subtile/generating/SubTileNightshade.java b/src/main/java/vazkii/botania/common/block/subtile/generating/SubTileNightshade.java index 4ad851412f..97d641aa00 100644 --- a/src/main/java/vazkii/botania/common/block/subtile/generating/SubTileNightshade.java +++ b/src/main/java/vazkii/botania/common/block/subtile/generating/SubTileNightshade.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Mar 16, 2014, 11:15:42 PM (GMT)] */ package vazkii.botania.common.block.subtile.generating; @@ -17,38 +17,36 @@ @PassiveFlower public class SubTileNightshade extends SubTileDaybloom { - @Override - public int getDelayBetweenPassiveGeneration() { - return super.getDelayBetweenPassiveGeneration(); - } - - @Override - public boolean canGeneratePassively() { - return !super.canGeneratePassively() && !supertile.getWorldObj().isDaytime(); - } - - @Override - public int getColor() { - return 0x3D2A90; - } - - @Override - public LexiconEntry getEntry() { - return LexiconData.nightshade; - } - - public static class Prime extends SubTileNightshade { - - @Override - public boolean isPrime() { - return true; - } - - @Override - public LexiconEntry getEntry() { - return LexiconData.primusLoci; - } - - } - + @Override + public int getDelayBetweenPassiveGeneration() { + return super.getDelayBetweenPassiveGeneration(); + } + + @Override + public boolean canGeneratePassively() { + return !super.canGeneratePassively() && !supertile.getWorldObj().isDaytime(); + } + + @Override + public int getColor() { + return 0x3D2A90; + } + + @Override + public LexiconEntry getEntry() { + return LexiconData.nightshade; + } + + public static class Prime extends SubTileNightshade { + + @Override + public boolean isPrime() { + return true; + } + + @Override + public LexiconEntry getEntry() { + return LexiconData.primusLoci; + } + } } diff --git a/src/main/java/vazkii/botania/common/block/subtile/generating/SubTilePassiveGenerating.java b/src/main/java/vazkii/botania/common/block/subtile/generating/SubTilePassiveGenerating.java index be40920793..93a17e173a 100644 --- a/src/main/java/vazkii/botania/common/block/subtile/generating/SubTilePassiveGenerating.java +++ b/src/main/java/vazkii/botania/common/block/subtile/generating/SubTilePassiveGenerating.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Mar 16, 2015, 6:03:16 PM (GMT)] */ package vazkii.botania.common.block.subtile.generating; @@ -14,9 +14,8 @@ public class SubTilePassiveGenerating extends SubTileGenerating { - @Override - public boolean isPassiveFlower() { - return true; - } - + @Override + public boolean isPassiveFlower() { + return true; + } } diff --git a/src/main/java/vazkii/botania/common/block/subtile/generating/SubTileRafflowsia.java b/src/main/java/vazkii/botania/common/block/subtile/generating/SubTileRafflowsia.java index 07a42d947c..37788de889 100644 --- a/src/main/java/vazkii/botania/common/block/subtile/generating/SubTileRafflowsia.java +++ b/src/main/java/vazkii/botania/common/block/subtile/generating/SubTileRafflowsia.java @@ -2,16 +2,15 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Oct 11, 2015, 5:05:05 PM (GMT)] */ package vazkii.botania.common.block.subtile.generating; import java.util.List; - import net.minecraft.block.Block; import net.minecraft.entity.EntityLivingBase; import net.minecraft.item.ItemStack; @@ -28,108 +27,108 @@ public class SubTileRafflowsia extends SubTileGenerating { - private static final String TAG_LAST_FLOWER = "lastFlower"; - private static final String TAG_LAST_FLOWER_TIMES = "lastFlowerTimes"; - - String lastFlower; - int lastFlowerTimes; - - private static final int RANGE = 5; - - @Override - public void onUpdate() { - super.onUpdate(); - - int mana = 2100; - - if(getMaxMana() - this.mana >= mana && !supertile.getWorldObj().isRemote && ticksExisted % 40 == 0) { - for(int i = 0; i < RANGE * 2 + 1; i++) - for(int j = 0; j < RANGE * 2 + 1; j++) - for(int k = 0; k < RANGE * 2 + 1; k++) { - int x = supertile.xCoord + i - RANGE; - int y = supertile.yCoord + j - RANGE; - int z = supertile.zCoord + k - RANGE; - Block block = supertile.getWorldObj().getBlock(x, y, z); - TileEntity tile = supertile.getWorldObj().getTileEntity(x, y, z); - if(tile instanceof ISubTileContainer) { - SubTileEntity stile = ((ISubTileContainer) tile).getSubTile(); - String name = stile.getUnlocalizedName(); - - if(stile instanceof SubTileGenerating && ((SubTileGenerating) stile).isPassiveFlower()) { - boolean last = name.equals(lastFlower); - if(last) - lastFlowerTimes++; - else { - lastFlower = name; - lastFlowerTimes = 1; - } - - float mod = 1F / lastFlowerTimes; - - int meta = supertile.getWorldObj().getBlockMetadata(x, y, z) + 1; - supertile.getWorldObj().setBlockToAir(x, y, z); - - supertile.getWorldObj().playAuxSFX(2001, x, y, z, Block.getIdFromBlock(block) + (meta << 12)); - this.mana += mana * mod; - sync(); - return; - } - } - } - } - } - - @Override - public void writeToPacketNBT(NBTTagCompound cmp) { - super.writeToPacketNBT(cmp); - - cmp.setString(TAG_LAST_FLOWER, lastFlower); - cmp.setInteger(TAG_LAST_FLOWER_TIMES, lastFlowerTimes); - } - - @Override - public void readFromPacketNBT(NBTTagCompound cmp) { - super.readFromPacketNBT(cmp); - - lastFlower = cmp.getString(TAG_LAST_FLOWER); - lastFlowerTimes = cmp.getInteger(TAG_LAST_FLOWER_TIMES); - } - - @Override - public void populateDropStackNBTs(List drops) { - super.populateDropStackNBTs(drops); - - ItemStack stack = drops.get(0); - ItemNBTHelper.setString(stack, TAG_LAST_FLOWER, lastFlower); - ItemNBTHelper.setInt(stack, TAG_LAST_FLOWER_TIMES, lastFlowerTimes); - } - - @Override - public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase entity, ItemStack stack) { - super.onBlockPlacedBy(world, x, y, z, entity, stack); - - lastFlower = ItemNBTHelper.getString(stack, TAG_LAST_FLOWER, ""); - lastFlowerTimes = ItemNBTHelper.getInt(stack, TAG_LAST_FLOWER_TIMES, 0); - } - - @Override - public RadiusDescriptor getRadius() { - return new RadiusDescriptor.Square(toChunkCoordinates(), RANGE); - } - - @Override - public int getColor() { - return 0x502C76; - } - - @Override - public int getMaxMana() { - return 9000; - } - - @Override - public LexiconEntry getEntry() { - return LexiconData.rafflowsia; - } - + private static final String TAG_LAST_FLOWER = "lastFlower"; + private static final String TAG_LAST_FLOWER_TIMES = "lastFlowerTimes"; + + String lastFlower; + int lastFlowerTimes; + + private static final int RANGE = 5; + + @Override + public void onUpdate() { + super.onUpdate(); + + int mana = 2100; + + if (getMaxMana() - this.mana >= mana && !supertile.getWorldObj().isRemote && ticksExisted % 40 == 0) { + for (int i = 0; i < RANGE * 2 + 1; i++) + for (int j = 0; j < RANGE * 2 + 1; j++) + for (int k = 0; k < RANGE * 2 + 1; k++) { + int x = supertile.xCoord + i - RANGE; + int y = supertile.yCoord + j - RANGE; + int z = supertile.zCoord + k - RANGE; + Block block = supertile.getWorldObj().getBlock(x, y, z); + TileEntity tile = supertile.getWorldObj().getTileEntity(x, y, z); + if (tile instanceof ISubTileContainer) { + SubTileEntity stile = ((ISubTileContainer) tile).getSubTile(); + String name = stile.getUnlocalizedName(); + + if (stile instanceof SubTileGenerating && ((SubTileGenerating) stile).isPassiveFlower()) { + boolean last = name.equals(lastFlower); + if (last) lastFlowerTimes++; + else { + lastFlower = name; + lastFlowerTimes = 1; + } + + float mod = 1F / lastFlowerTimes; + + int meta = supertile.getWorldObj().getBlockMetadata(x, y, z) + 1; + supertile.getWorldObj().setBlockToAir(x, y, z); + + supertile + .getWorldObj() + .playAuxSFX(2001, x, y, z, Block.getIdFromBlock(block) + (meta << 12)); + this.mana += mana * mod; + sync(); + return; + } + } + } + } + } + + @Override + public void writeToPacketNBT(NBTTagCompound cmp) { + super.writeToPacketNBT(cmp); + + cmp.setString(TAG_LAST_FLOWER, lastFlower); + cmp.setInteger(TAG_LAST_FLOWER_TIMES, lastFlowerTimes); + } + + @Override + public void readFromPacketNBT(NBTTagCompound cmp) { + super.readFromPacketNBT(cmp); + + lastFlower = cmp.getString(TAG_LAST_FLOWER); + lastFlowerTimes = cmp.getInteger(TAG_LAST_FLOWER_TIMES); + } + + @Override + public void populateDropStackNBTs(List drops) { + super.populateDropStackNBTs(drops); + + ItemStack stack = drops.get(0); + ItemNBTHelper.setString(stack, TAG_LAST_FLOWER, lastFlower); + ItemNBTHelper.setInt(stack, TAG_LAST_FLOWER_TIMES, lastFlowerTimes); + } + + @Override + public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase entity, ItemStack stack) { + super.onBlockPlacedBy(world, x, y, z, entity, stack); + + lastFlower = ItemNBTHelper.getString(stack, TAG_LAST_FLOWER, ""); + lastFlowerTimes = ItemNBTHelper.getInt(stack, TAG_LAST_FLOWER_TIMES, 0); + } + + @Override + public RadiusDescriptor getRadius() { + return new RadiusDescriptor.Square(toChunkCoordinates(), RANGE); + } + + @Override + public int getColor() { + return 0x502C76; + } + + @Override + public int getMaxMana() { + return 9000; + } + + @Override + public LexiconEntry getEntry() { + return LexiconData.rafflowsia; + } } diff --git a/src/main/java/vazkii/botania/common/block/subtile/generating/SubTileSpectrolus.java b/src/main/java/vazkii/botania/common/block/subtile/generating/SubTileSpectrolus.java index 1bfeb03edb..76c7574656 100644 --- a/src/main/java/vazkii/botania/common/block/subtile/generating/SubTileSpectrolus.java +++ b/src/main/java/vazkii/botania/common/block/subtile/generating/SubTileSpectrolus.java @@ -2,17 +2,16 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jan 30, 2015, 1:37:26 PM (GMT)] */ package vazkii.botania.common.block.subtile.generating; import java.awt.Color; import java.util.List; - import net.minecraft.client.Minecraft; import net.minecraft.client.gui.ScaledResolution; import net.minecraft.client.renderer.RenderHelper; @@ -23,9 +22,7 @@ import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.util.AxisAlignedBB; - import org.lwjgl.opengl.GL11; - import vazkii.botania.api.lexicon.LexiconEntry; import vazkii.botania.api.subtile.RadiusDescriptor; import vazkii.botania.api.subtile.SubTileGenerating; @@ -33,102 +30,119 @@ public class SubTileSpectrolus extends SubTileGenerating { - private static final String TAG_NEXT_COLOR = "nextColor"; - - private static final int RANGE = 1; - - int nextColor; - - @Override - public void onUpdate() { - super.onUpdate(); - - boolean remote = supertile.getWorldObj().isRemote; - Item wool = Item.getItemFromBlock(Blocks.wool); - List items = supertile.getWorldObj().getEntitiesWithinAABB(EntityItem.class, AxisAlignedBB.getBoundingBox(supertile.xCoord - RANGE, supertile.yCoord - RANGE, supertile.zCoord - RANGE, supertile.xCoord + RANGE + 1, supertile.yCoord + RANGE + 1, supertile.zCoord + RANGE + 1)); - int slowdown = getSlowdownFactor(); - - for(EntityItem item : items) { - ItemStack stack = item.getEntityItem(); - if(stack != null && stack.getItem() == wool && !item.isDead && item.age >= slowdown) { - int meta = stack.getItemDamage(); - if(meta == nextColor) { - if(!remote) { - mana = Math.min(getMaxMana(), mana + 300); - nextColor = nextColor == 15 ? 0 : nextColor + 1; - sync(); - } - - for(int i = 0; i < 10; i++) { - float m = 0.2F; - float mx = (float) (Math.random() - 0.5) * m; - float my = (float) (Math.random() - 0.5) * m; - float mz = (float) (Math.random() - 0.5) * m; - supertile.getWorldObj().spawnParticle("blockcrack_" + Item.getIdFromItem(stack.getItem()) + "_" + meta, item.posX, item.posY, item.posZ, mx, my, mz); - } - } - - if(!remote) - item.setDead(); - } - } - } - - @Override - public RadiusDescriptor getRadius() { - return new RadiusDescriptor.Square(toChunkCoordinates(), RANGE); - } - - @Override - public int getMaxMana() { - return 8000; - } - - @Override - public int getColor() { - return Color.HSBtoRGB(ticksExisted / 100F, 1F, 1F); - } - - @Override - public LexiconEntry getEntry() { - return LexiconData.spectrolus; - } - - @Override - public void renderHUD(Minecraft mc, ScaledResolution res) { - super.renderHUD(mc, res); - - ItemStack stack = new ItemStack(Blocks.wool, 1, nextColor); - int color = getColor(); - - GL11.glEnable(GL11.GL_BLEND); - GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); - if(stack != null && stack.getItem() != null) { - String stackName = stack.getDisplayName(); - int width = 16 + mc.fontRenderer.getStringWidth(stackName) / 2; - int x = res.getScaledWidth() / 2 - width; - int y = res.getScaledHeight() / 2 + 30; - - mc.fontRenderer.drawStringWithShadow(stackName, x + 20, y + 5, color); - RenderHelper.enableGUIStandardItemLighting(); - RenderItem.getInstance().renderItemAndEffectIntoGUI(mc.fontRenderer, mc.renderEngine, stack, x, y); - RenderHelper.disableStandardItemLighting(); - } - - GL11.glDisable(GL11.GL_LIGHTING); - GL11.glDisable(GL11.GL_BLEND); - } - - @Override - public void writeToPacketNBT(NBTTagCompound cmp) { - super.writeToPacketNBT(cmp); - cmp.setInteger(TAG_NEXT_COLOR, nextColor); - } - - @Override - public void readFromPacketNBT(NBTTagCompound cmp) { - super.readFromPacketNBT(cmp); - nextColor = cmp.getInteger(TAG_NEXT_COLOR); - } - + private static final String TAG_NEXT_COLOR = "nextColor"; + + private static final int RANGE = 1; + + int nextColor; + + @Override + public void onUpdate() { + super.onUpdate(); + + boolean remote = supertile.getWorldObj().isRemote; + Item wool = Item.getItemFromBlock(Blocks.wool); + List items = supertile + .getWorldObj() + .getEntitiesWithinAABB( + EntityItem.class, + AxisAlignedBB.getBoundingBox( + supertile.xCoord - RANGE, + supertile.yCoord - RANGE, + supertile.zCoord - RANGE, + supertile.xCoord + RANGE + 1, + supertile.yCoord + RANGE + 1, + supertile.zCoord + RANGE + 1)); + int slowdown = getSlowdownFactor(); + + for (EntityItem item : items) { + ItemStack stack = item.getEntityItem(); + if (stack != null && stack.getItem() == wool && !item.isDead && item.age >= slowdown) { + int meta = stack.getItemDamage(); + if (meta == nextColor) { + if (!remote) { + mana = Math.min(getMaxMana(), mana + 300); + nextColor = nextColor == 15 ? 0 : nextColor + 1; + sync(); + } + + for (int i = 0; i < 10; i++) { + float m = 0.2F; + float mx = (float) (Math.random() - 0.5) * m; + float my = (float) (Math.random() - 0.5) * m; + float mz = (float) (Math.random() - 0.5) * m; + supertile + .getWorldObj() + .spawnParticle( + "blockcrack_" + Item.getIdFromItem(stack.getItem()) + "_" + meta, + item.posX, + item.posY, + item.posZ, + mx, + my, + mz); + } + } + + if (!remote) item.setDead(); + } + } + } + + @Override + public RadiusDescriptor getRadius() { + return new RadiusDescriptor.Square(toChunkCoordinates(), RANGE); + } + + @Override + public int getMaxMana() { + return 8000; + } + + @Override + public int getColor() { + return Color.HSBtoRGB(ticksExisted / 100F, 1F, 1F); + } + + @Override + public LexiconEntry getEntry() { + return LexiconData.spectrolus; + } + + @Override + public void renderHUD(Minecraft mc, ScaledResolution res) { + super.renderHUD(mc, res); + + ItemStack stack = new ItemStack(Blocks.wool, 1, nextColor); + int color = getColor(); + + GL11.glEnable(GL11.GL_BLEND); + GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); + if (stack != null && stack.getItem() != null) { + String stackName = stack.getDisplayName(); + int width = 16 + mc.fontRenderer.getStringWidth(stackName) / 2; + int x = res.getScaledWidth() / 2 - width; + int y = res.getScaledHeight() / 2 + 30; + + mc.fontRenderer.drawStringWithShadow(stackName, x + 20, y + 5, color); + RenderHelper.enableGUIStandardItemLighting(); + RenderItem.getInstance().renderItemAndEffectIntoGUI(mc.fontRenderer, mc.renderEngine, stack, x, y); + RenderHelper.disableStandardItemLighting(); + } + + GL11.glDisable(GL11.GL_LIGHTING); + GL11.glDisable(GL11.GL_BLEND); + } + + @Override + public void writeToPacketNBT(NBTTagCompound cmp) { + super.writeToPacketNBT(cmp); + cmp.setInteger(TAG_NEXT_COLOR, nextColor); + } + + @Override + public void readFromPacketNBT(NBTTagCompound cmp) { + super.readFromPacketNBT(cmp); + nextColor = cmp.getInteger(TAG_NEXT_COLOR); + } } diff --git a/src/main/java/vazkii/botania/common/block/subtile/generating/SubTileThermalily.java b/src/main/java/vazkii/botania/common/block/subtile/generating/SubTileThermalily.java index 13e0fb1c8c..937f5c98c4 100644 --- a/src/main/java/vazkii/botania/common/block/subtile/generating/SubTileThermalily.java +++ b/src/main/java/vazkii/botania/common/block/subtile/generating/SubTileThermalily.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Mar 10, 2014, 9:44:02 PM (GMT)] */ package vazkii.botania.common.block.subtile.generating; @@ -17,59 +17,69 @@ public class SubTileThermalily extends SubTileHydroangeas { - @Override - public int getColor(){ - return 0xD03C00; - } + @Override + public int getColor() { + return 0xD03C00; + } - @Override - public LexiconEntry getEntry() { - return LexiconData.thermalily; - } + @Override + public LexiconEntry getEntry() { + return LexiconData.thermalily; + } - @Override - public void doBurnParticles() { - Botania.proxy.wispFX(supertile.getWorldObj(), supertile.xCoord + 0.55 + Math.random() * 0.2 - 0.1, supertile.yCoord + 0.9 + Math.random() * 0.2 - 0.1, supertile.zCoord + 0.5, 0.7F, 0.05F, 0.05F, (float) Math.random() / 6, (float) -Math.random() / 60); - } + @Override + public void doBurnParticles() { + Botania.proxy.wispFX( + supertile.getWorldObj(), + supertile.xCoord + 0.55 + Math.random() * 0.2 - 0.1, + supertile.yCoord + 0.9 + Math.random() * 0.2 - 0.1, + supertile.zCoord + 0.5, + 0.7F, + 0.05F, + 0.05F, + (float) Math.random() / 6, + (float) -Math.random() / 60); + } - @Override - public boolean isPassiveFlower() { - return false; - } + @Override + public boolean isPassiveFlower() { + return false; + } - @Override - public Material getMaterialToSearchFor() { - return Material.lava; - } + @Override + public Material getMaterialToSearchFor() { + return Material.lava; + } - @Override - public void playSound() { - supertile.getWorldObj().playSoundEffect(supertile.xCoord, supertile.yCoord, supertile.zCoord, "botania:thermalily", 0.2F, 1F); - } + @Override + public void playSound() { + supertile + .getWorldObj() + .playSoundEffect(supertile.xCoord, supertile.yCoord, supertile.zCoord, "botania:thermalily", 0.2F, 1F); + } - @Override - public int getDelayBetweenPassiveGeneration() { - return 1; - } + @Override + public int getDelayBetweenPassiveGeneration() { + return 1; + } - @Override - public int getBurnTime() { - return 900; - } + @Override + public int getBurnTime() { + return 900; + } - @Override - public int getValueForPassiveGeneration() { - return 20; - } + @Override + public int getValueForPassiveGeneration() { + return 20; + } - @Override - public int getMaxMana() { - return 500; - } - - @Override - public int getCooldown() { - return 6000; - } + @Override + public int getMaxMana() { + return 500; + } + @Override + public int getCooldown() { + return 6000; + } } diff --git a/src/main/java/vazkii/botania/common/block/tile/TileAlfPortal.java b/src/main/java/vazkii/botania/common/block/tile/TileAlfPortal.java index d3d475ee79..59a6f4f1ec 100644 --- a/src/main/java/vazkii/botania/common/block/tile/TileAlfPortal.java +++ b/src/main/java/vazkii/botania/common/block/tile/TileAlfPortal.java @@ -2,17 +2,17 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jun 9, 2014, 8:51:55 PM (GMT)] */ package vazkii.botania.common.block.tile; +import com.google.common.base.Function; import java.util.ArrayList; import java.util.List; - import net.minecraft.block.Block; import net.minecraft.entity.item.EntityItem; import net.minecraft.init.Blocks; @@ -35,345 +35,323 @@ import vazkii.botania.common.item.ItemLexicon; import vazkii.botania.common.lexicon.LexiconData; -import com.google.common.base.Function; - public class TileAlfPortal extends TileMod { - private static final int[][] LIVINGWOOD_POSITIONS = { - { -1, 0, 0}, { 1, 0, 0}, { -2, 1, 0}, { 2, 1, 0}, { -2, 3, 0}, { 2, 3, 0}, { -1, 4, 0}, { 1, 4, 0} - }; - - private static final int[][] GLIMMERING_LIVINGWOOD_POSITIONS = { - { -2, 2, 0 }, { 2, 2, 0 }, { 0, 4, 0 } - }; - - private static final int[][] PYLON_POSITIONS = { - { -3, 1, 3 }, { 3, 1, 3 } - }; - - private static final int[][] POOL_POSITIONS = { - { -3, 0, 3 }, { 3, 0, 3 } - }; - - private static final int[][] AIR_POSITIONS = { - { -1, 1, 0 }, { 0, 1, 0 }, { 1, 1, 0 }, { -1, 2, 0 }, { 0, 2, 0 }, { 1, 2, 0 }, { -1, 3, 0 }, { 0, 3, 0 }, { 1, 3, 0 } - }; - - private static final String TAG_TICKS_OPEN = "ticksOpen"; - private static final String TAG_TICKS_SINCE_LAST_ITEM = "ticksSinceLastItem"; - private static final String TAG_STACK_COUNT = "stackCount"; - private static final String TAG_STACK = "portalStack"; - private static final String TAG_PORTAL_FLAG = "_elvenPortal"; - - List stacksIn = new ArrayList(); - - public int ticksOpen = 0; - int ticksSinceLastItem = 0; - private boolean closeNow = false; - private boolean hasUnloadedParts = false; - - private static final Function CONVERTER_X_Z = new Function() { - @Override - public int[] apply(int[] input) { - return new int[] { input[2], input[1], input[0] }; - } - }; - - private static final Function CONVERTER_X_Z_FP = new Function() { - @Override - public double[] apply(double[] input) { - return new double[] { input[2], input[1], input[0] }; - } - }; - - private static final Function CONVERTER_Z_SWAP = new Function() { - @Override - public int[] apply(int[] input) { - return new int[] { input[0], input[1], -input[2] }; - } - }; - - public static MultiblockSet makeMultiblockSet() { - Multiblock mb = new Multiblock(); - - for(int[] l : LIVINGWOOD_POSITIONS) - mb.addComponent(l[0], l[1] + 1, l[2], ModBlocks.livingwood, 0); - for(int[] g : GLIMMERING_LIVINGWOOD_POSITIONS) - mb.addComponent(g[0], g[1] + 1, g[2], ModBlocks.livingwood, 5); - for(int[] p : PYLON_POSITIONS) - mb.addComponent(-p[0], p[1] + 1, -p[2], ModBlocks.pylon, 1); - for(int[] p : POOL_POSITIONS) - mb.addComponent(-p[0], p[1] + 1, -p[2], ModBlocks.pool, 0); - - mb.addComponent(0, 1, 0, ModBlocks.alfPortal, 0); - mb.setRenderOffset(0, -1, 0); - - return mb.makeSet(); - } - - @Override - public void updateEntity() { - int meta = getBlockMetadata(); - if(meta == 0) { - ticksOpen = 0; - return; - } - int newMeta = getValidMetadata(); - - if(!hasUnloadedParts) { - ticksOpen++; - - AxisAlignedBB aabb = getPortalAABB(); - boolean open = ticksOpen > 60; - ElvenPortalUpdateEvent event = new ElvenPortalUpdateEvent(this, aabb, open, stacksIn); - MinecraftForge.EVENT_BUS.post(event); - - if(ticksOpen > 60) { - ticksSinceLastItem++; - if(ConfigHandler.elfPortalParticlesEnabled) - blockParticle(meta); - - List items = worldObj.getEntitiesWithinAABB(EntityItem.class, aabb); - if(!worldObj.isRemote) - for(EntityItem item : items) { - if(item.isDead) - continue; - - ItemStack stack = item.getEntityItem(); - if(stack != null && (!(stack.getItem() instanceof IElvenItem) || !((IElvenItem) stack.getItem()).isElvenItem(stack)) && !item.getEntityData().hasKey(TAG_PORTAL_FLAG)) { - item.setDead(); - addItem(stack); - ticksSinceLastItem = 0; - } - } - - if(ticksSinceLastItem >= 4) { - if(!worldObj.isRemote) - resolveRecipes(); - } - } - } else closeNow = false; - - if(closeNow) { - worldObj.setBlockMetadataWithNotify(xCoord, yCoord, zCoord, 0, 1 | 2); - for(int i = 0; i < 36; i++) - blockParticle(meta); - closeNow = false; - } else if(newMeta != meta) { - if(newMeta == 0) - for(int i = 0; i < 36; i++) - blockParticle(meta); - worldObj.setBlockMetadataWithNotify(xCoord, yCoord, zCoord, newMeta, 1 | 2); - } - - hasUnloadedParts = false; - } - - private void blockParticle(int meta) { - int i = worldObj.rand.nextInt(AIR_POSITIONS.length); - double[] pos = new double[] { - AIR_POSITIONS[i][0] + 0.5F, AIR_POSITIONS[i][1] + 0.5F, AIR_POSITIONS[i][2] + 0.5F - }; - if(meta == 2) - pos = CONVERTER_X_Z_FP.apply(pos); - - float motionMul = 0.2F; - Botania.proxy.wispFX(getWorldObj(), xCoord + pos[0], yCoord + pos[1], zCoord + pos[2], (float) (Math.random() * 0.25F), (float) (Math.random() * 0.5F + 0.5F), (float) (Math.random() * 0.25F), (float) (Math.random() * 0.15F + 0.1F), (float) (Math.random() - 0.5F) * motionMul, (float) (Math.random() - 0.5F) * motionMul, (float) (Math.random() - 0.5F) * motionMul); - } - - public boolean onWanded() { - int meta = getBlockMetadata(); - if(meta == 0) { - int newMeta = getValidMetadata(); - if(newMeta != 0) { - worldObj.setBlockMetadataWithNotify(xCoord, yCoord, zCoord, newMeta, 1 | 2); - return true; - } - } - - return false; - } - - AxisAlignedBB getPortalAABB() { - AxisAlignedBB aabb = AxisAlignedBB.getBoundingBox(xCoord - 1, yCoord + 1, zCoord, xCoord + 2, yCoord + 4, zCoord + 1); - if(getBlockMetadata() == 2) - aabb = AxisAlignedBB.getBoundingBox(xCoord, yCoord + 1, zCoord - 1, xCoord + 1, yCoord + 4, zCoord + 2); - - return aabb; - } - - void addItem(ItemStack stack) { - int size = stack.stackSize; - stack.stackSize = 1; - for(int i = 0; i < size; i++) - stacksIn.add(stack.copy()); - } - - void resolveRecipes() { - int i = 0; - for(ItemStack stack : stacksIn) { - if(stack != null && stack.getItem() instanceof ILexicon) { - ((ILexicon) stack.getItem()).unlockKnowledge(stack, BotaniaAPI.elvenKnowledge); - ItemLexicon.setForcedPage(stack, LexiconData.elvenMessage.getUnlocalizedName()); - spawnItem(stack); - stacksIn.remove(i); - return; - } - i++; - } - - for(RecipeElvenTrade recipe : BotaniaAPI.elvenTradeRecipes) { - if(recipe.matches(stacksIn, false)) { - recipe.matches(stacksIn, true); - spawnItem(recipe.getOutput().copy()); - break; - } - } - } - - void spawnItem(ItemStack stack) { - EntityItem item = new EntityItem(worldObj, xCoord + 0.5, yCoord + 1.5, zCoord + 0.5, stack); - item.getEntityData().setBoolean(TAG_PORTAL_FLAG, true); - worldObj.spawnEntityInWorld(item); - ticksSinceLastItem = 0; - } - - @Override - public void writeToNBT(NBTTagCompound cmp) { - super.writeToNBT(cmp); - - cmp.setInteger(TAG_STACK_COUNT, stacksIn.size()); - int i = 0; - for(ItemStack stack : stacksIn) { - NBTTagCompound stackcmp = new NBTTagCompound(); - stack.writeToNBT(stackcmp); - cmp.setTag(TAG_STACK + i, stackcmp); - i++; - } - } - - @Override - public void readFromNBT(NBTTagCompound cmp) { - super.readFromNBT(cmp); - - int count = cmp.getInteger(TAG_STACK_COUNT); - stacksIn.clear(); - for(int i = 0; i < count; i++) { - NBTTagCompound stackcmp = cmp.getCompoundTag(TAG_STACK + i); - ItemStack stack = ItemStack.loadItemStackFromNBT(stackcmp); - stacksIn.add(stack); - } - } - - @Override - public void writeCustomNBT(NBTTagCompound cmp) { - cmp.setInteger(TAG_TICKS_OPEN, ticksOpen); - cmp.setInteger(TAG_TICKS_SINCE_LAST_ITEM, ticksSinceLastItem); - } - - @Override - public void readCustomNBT(NBTTagCompound cmp) { - ticksOpen = cmp.getInteger(TAG_TICKS_OPEN); - ticksSinceLastItem = cmp.getInteger(TAG_TICKS_SINCE_LAST_ITEM); - } - - private int getValidMetadata() { - if(checkConverter(null)) - return 1; - - if(checkConverter(CONVERTER_X_Z)) - return 2; - - return 0; - } - - private boolean checkConverter(Function baseConverter) { - return checkMultipleConverters(baseConverter) || checkMultipleConverters(CONVERTER_Z_SWAP, baseConverter); - } - - private boolean checkMultipleConverters(Function... converters) { - if(!check2DArray(AIR_POSITIONS, Blocks.air, -1, converters)) - return false; - if(!check2DArray(LIVINGWOOD_POSITIONS, ModBlocks.livingwood, 0, converters)) - return false; - if(!check2DArray(GLIMMERING_LIVINGWOOD_POSITIONS, ModBlocks.livingwood, 5, converters)) - return false; - if(!check2DArray(PYLON_POSITIONS, ModBlocks.pylon, 1, converters)) - return false; - if(!check2DArray(POOL_POSITIONS, ModBlocks.pool, -1, converters)) - return false; - - lightPylons(converters); - return true; - } - - private void lightPylons(Function... converters) { - if(ticksOpen < 50) - return; - - int cost = ticksOpen == 50 ? 75000 : 2; - - for(int[] pos : PYLON_POSITIONS) { - for(Function f : converters) - if(f != null) - pos = f.apply(pos); - - TileEntity tile = worldObj.getTileEntity(xCoord + pos[0], yCoord + pos[1], zCoord + pos[2]); - if(tile instanceof TilePylon) { - TilePylon pylon = (TilePylon) tile; - pylon.activated = true; - pylon.centerX = xCoord; - pylon.centerY = yCoord; - pylon.centerZ = zCoord; - } - - tile = worldObj.getTileEntity(xCoord + pos[0], yCoord + pos[1] - 1, zCoord + pos[2]); - if(tile instanceof TilePool) { - TilePool pool = (TilePool) tile; - if(pool.getCurrentMana() < cost) - closeNow = true; - else if(!worldObj.isRemote) - pool.recieveMana(-cost); - } - } - } - - private boolean check2DArray(int[][] positions, Block block, int meta, Function... converters) { - for(int[] pos : positions) { - for(Function f : converters) - if(f != null) - pos = f.apply(pos); - - if(!checkPosition(pos, block, meta)) - return false; - } - - return true; - } - - private boolean checkPosition(int[] pos, Block block, int meta) { - int x = xCoord + pos[0]; - int y = yCoord + pos[1]; - int z = zCoord + pos[2]; - if(!worldObj.blockExists(x, y, z)) { - hasUnloadedParts = true; - return true; // Don't fuck everything up if there's a chunk unload - } - - Block blockat = worldObj.getBlock(x, y, z); - if(block == Blocks.air ? blockat.isAir(worldObj, x, y, z) : blockat == block) { - if(meta == -1) - return true; - - int metaat = worldObj.getBlockMetadata(x, y, z); - return meta == metaat; - } - - return false; - } - - @Override - public AxisAlignedBB getRenderBoundingBox() { - return INFINITE_EXTENT_AABB; - } + private static final int[][] LIVINGWOOD_POSITIONS = { + {-1, 0, 0}, {1, 0, 0}, {-2, 1, 0}, {2, 1, 0}, {-2, 3, 0}, {2, 3, 0}, {-1, 4, 0}, {1, 4, 0} + }; + + private static final int[][] GLIMMERING_LIVINGWOOD_POSITIONS = {{-2, 2, 0}, {2, 2, 0}, {0, 4, 0}}; + + private static final int[][] PYLON_POSITIONS = {{-3, 1, 3}, {3, 1, 3}}; + + private static final int[][] POOL_POSITIONS = {{-3, 0, 3}, {3, 0, 3}}; + + private static final int[][] AIR_POSITIONS = { + {-1, 1, 0}, {0, 1, 0}, {1, 1, 0}, {-1, 2, 0}, {0, 2, 0}, {1, 2, 0}, {-1, 3, 0}, {0, 3, 0}, {1, 3, 0} + }; + + private static final String TAG_TICKS_OPEN = "ticksOpen"; + private static final String TAG_TICKS_SINCE_LAST_ITEM = "ticksSinceLastItem"; + private static final String TAG_STACK_COUNT = "stackCount"; + private static final String TAG_STACK = "portalStack"; + private static final String TAG_PORTAL_FLAG = "_elvenPortal"; + + List stacksIn = new ArrayList(); + + public int ticksOpen = 0; + int ticksSinceLastItem = 0; + private boolean closeNow = false; + private boolean hasUnloadedParts = false; + + private static final Function CONVERTER_X_Z = new Function() { + @Override + public int[] apply(int[] input) { + return new int[] {input[2], input[1], input[0]}; + } + }; + + private static final Function CONVERTER_X_Z_FP = new Function() { + @Override + public double[] apply(double[] input) { + return new double[] {input[2], input[1], input[0]}; + } + }; + + private static final Function CONVERTER_Z_SWAP = new Function() { + @Override + public int[] apply(int[] input) { + return new int[] {input[0], input[1], -input[2]}; + } + }; + + public static MultiblockSet makeMultiblockSet() { + Multiblock mb = new Multiblock(); + + for (int[] l : LIVINGWOOD_POSITIONS) mb.addComponent(l[0], l[1] + 1, l[2], ModBlocks.livingwood, 0); + for (int[] g : GLIMMERING_LIVINGWOOD_POSITIONS) mb.addComponent(g[0], g[1] + 1, g[2], ModBlocks.livingwood, 5); + for (int[] p : PYLON_POSITIONS) mb.addComponent(-p[0], p[1] + 1, -p[2], ModBlocks.pylon, 1); + for (int[] p : POOL_POSITIONS) mb.addComponent(-p[0], p[1] + 1, -p[2], ModBlocks.pool, 0); + + mb.addComponent(0, 1, 0, ModBlocks.alfPortal, 0); + mb.setRenderOffset(0, -1, 0); + + return mb.makeSet(); + } + + @Override + public void updateEntity() { + int meta = getBlockMetadata(); + if (meta == 0) { + ticksOpen = 0; + return; + } + int newMeta = getValidMetadata(); + + if (!hasUnloadedParts) { + ticksOpen++; + + AxisAlignedBB aabb = getPortalAABB(); + boolean open = ticksOpen > 60; + ElvenPortalUpdateEvent event = new ElvenPortalUpdateEvent(this, aabb, open, stacksIn); + MinecraftForge.EVENT_BUS.post(event); + + if (ticksOpen > 60) { + ticksSinceLastItem++; + if (ConfigHandler.elfPortalParticlesEnabled) blockParticle(meta); + + List items = worldObj.getEntitiesWithinAABB(EntityItem.class, aabb); + if (!worldObj.isRemote) + for (EntityItem item : items) { + if (item.isDead) continue; + + ItemStack stack = item.getEntityItem(); + if (stack != null + && (!(stack.getItem() instanceof IElvenItem) + || !((IElvenItem) stack.getItem()).isElvenItem(stack)) + && !item.getEntityData().hasKey(TAG_PORTAL_FLAG)) { + item.setDead(); + addItem(stack); + ticksSinceLastItem = 0; + } + } + + if (ticksSinceLastItem >= 4) { + if (!worldObj.isRemote) resolveRecipes(); + } + } + } else closeNow = false; + + if (closeNow) { + worldObj.setBlockMetadataWithNotify(xCoord, yCoord, zCoord, 0, 1 | 2); + for (int i = 0; i < 36; i++) blockParticle(meta); + closeNow = false; + } else if (newMeta != meta) { + if (newMeta == 0) for (int i = 0; i < 36; i++) blockParticle(meta); + worldObj.setBlockMetadataWithNotify(xCoord, yCoord, zCoord, newMeta, 1 | 2); + } + + hasUnloadedParts = false; + } + + private void blockParticle(int meta) { + int i = worldObj.rand.nextInt(AIR_POSITIONS.length); + double[] pos = + new double[] {AIR_POSITIONS[i][0] + 0.5F, AIR_POSITIONS[i][1] + 0.5F, AIR_POSITIONS[i][2] + 0.5F}; + if (meta == 2) pos = CONVERTER_X_Z_FP.apply(pos); + + float motionMul = 0.2F; + Botania.proxy.wispFX( + getWorldObj(), + xCoord + pos[0], + yCoord + pos[1], + zCoord + pos[2], + (float) (Math.random() * 0.25F), + (float) (Math.random() * 0.5F + 0.5F), + (float) (Math.random() * 0.25F), + (float) (Math.random() * 0.15F + 0.1F), + (float) (Math.random() - 0.5F) * motionMul, + (float) (Math.random() - 0.5F) * motionMul, + (float) (Math.random() - 0.5F) * motionMul); + } + + public boolean onWanded() { + int meta = getBlockMetadata(); + if (meta == 0) { + int newMeta = getValidMetadata(); + if (newMeta != 0) { + worldObj.setBlockMetadataWithNotify(xCoord, yCoord, zCoord, newMeta, 1 | 2); + return true; + } + } + + return false; + } + + AxisAlignedBB getPortalAABB() { + AxisAlignedBB aabb = + AxisAlignedBB.getBoundingBox(xCoord - 1, yCoord + 1, zCoord, xCoord + 2, yCoord + 4, zCoord + 1); + if (getBlockMetadata() == 2) + aabb = AxisAlignedBB.getBoundingBox(xCoord, yCoord + 1, zCoord - 1, xCoord + 1, yCoord + 4, zCoord + 2); + + return aabb; + } + + void addItem(ItemStack stack) { + int size = stack.stackSize; + stack.stackSize = 1; + for (int i = 0; i < size; i++) stacksIn.add(stack.copy()); + } + + void resolveRecipes() { + int i = 0; + for (ItemStack stack : stacksIn) { + if (stack != null && stack.getItem() instanceof ILexicon) { + ((ILexicon) stack.getItem()).unlockKnowledge(stack, BotaniaAPI.elvenKnowledge); + ItemLexicon.setForcedPage(stack, LexiconData.elvenMessage.getUnlocalizedName()); + spawnItem(stack); + stacksIn.remove(i); + return; + } + i++; + } + + for (RecipeElvenTrade recipe : BotaniaAPI.elvenTradeRecipes) { + if (recipe.matches(stacksIn, false)) { + recipe.matches(stacksIn, true); + spawnItem(recipe.getOutput().copy()); + break; + } + } + } + + void spawnItem(ItemStack stack) { + EntityItem item = new EntityItem(worldObj, xCoord + 0.5, yCoord + 1.5, zCoord + 0.5, stack); + item.getEntityData().setBoolean(TAG_PORTAL_FLAG, true); + worldObj.spawnEntityInWorld(item); + ticksSinceLastItem = 0; + } + + @Override + public void writeToNBT(NBTTagCompound cmp) { + super.writeToNBT(cmp); + + cmp.setInteger(TAG_STACK_COUNT, stacksIn.size()); + int i = 0; + for (ItemStack stack : stacksIn) { + NBTTagCompound stackcmp = new NBTTagCompound(); + stack.writeToNBT(stackcmp); + cmp.setTag(TAG_STACK + i, stackcmp); + i++; + } + } + + @Override + public void readFromNBT(NBTTagCompound cmp) { + super.readFromNBT(cmp); + + int count = cmp.getInteger(TAG_STACK_COUNT); + stacksIn.clear(); + for (int i = 0; i < count; i++) { + NBTTagCompound stackcmp = cmp.getCompoundTag(TAG_STACK + i); + ItemStack stack = ItemStack.loadItemStackFromNBT(stackcmp); + stacksIn.add(stack); + } + } + + @Override + public void writeCustomNBT(NBTTagCompound cmp) { + cmp.setInteger(TAG_TICKS_OPEN, ticksOpen); + cmp.setInteger(TAG_TICKS_SINCE_LAST_ITEM, ticksSinceLastItem); + } + + @Override + public void readCustomNBT(NBTTagCompound cmp) { + ticksOpen = cmp.getInteger(TAG_TICKS_OPEN); + ticksSinceLastItem = cmp.getInteger(TAG_TICKS_SINCE_LAST_ITEM); + } + + private int getValidMetadata() { + if (checkConverter(null)) return 1; + + if (checkConverter(CONVERTER_X_Z)) return 2; + + return 0; + } + + private boolean checkConverter(Function baseConverter) { + return checkMultipleConverters(baseConverter) || checkMultipleConverters(CONVERTER_Z_SWAP, baseConverter); + } + + private boolean checkMultipleConverters(Function... converters) { + if (!check2DArray(AIR_POSITIONS, Blocks.air, -1, converters)) return false; + if (!check2DArray(LIVINGWOOD_POSITIONS, ModBlocks.livingwood, 0, converters)) return false; + if (!check2DArray(GLIMMERING_LIVINGWOOD_POSITIONS, ModBlocks.livingwood, 5, converters)) return false; + if (!check2DArray(PYLON_POSITIONS, ModBlocks.pylon, 1, converters)) return false; + if (!check2DArray(POOL_POSITIONS, ModBlocks.pool, -1, converters)) return false; + + lightPylons(converters); + return true; + } + + private void lightPylons(Function... converters) { + if (ticksOpen < 50) return; + + int cost = ticksOpen == 50 ? 75000 : 2; + + for (int[] pos : PYLON_POSITIONS) { + for (Function f : converters) if (f != null) pos = f.apply(pos); + + TileEntity tile = worldObj.getTileEntity(xCoord + pos[0], yCoord + pos[1], zCoord + pos[2]); + if (tile instanceof TilePylon) { + TilePylon pylon = (TilePylon) tile; + pylon.activated = true; + pylon.centerX = xCoord; + pylon.centerY = yCoord; + pylon.centerZ = zCoord; + } + + tile = worldObj.getTileEntity(xCoord + pos[0], yCoord + pos[1] - 1, zCoord + pos[2]); + if (tile instanceof TilePool) { + TilePool pool = (TilePool) tile; + if (pool.getCurrentMana() < cost) closeNow = true; + else if (!worldObj.isRemote) pool.recieveMana(-cost); + } + } + } + + private boolean check2DArray(int[][] positions, Block block, int meta, Function... converters) { + for (int[] pos : positions) { + for (Function f : converters) if (f != null) pos = f.apply(pos); + + if (!checkPosition(pos, block, meta)) return false; + } + + return true; + } + + private boolean checkPosition(int[] pos, Block block, int meta) { + int x = xCoord + pos[0]; + int y = yCoord + pos[1]; + int z = zCoord + pos[2]; + if (!worldObj.blockExists(x, y, z)) { + hasUnloadedParts = true; + return true; // Don't fuck everything up if there's a chunk unload + } + + Block blockat = worldObj.getBlock(x, y, z); + if (block == Blocks.air ? blockat.isAir(worldObj, x, y, z) : blockat == block) { + if (meta == -1) return true; + + int metaat = worldObj.getBlockMetadata(x, y, z); + return meta == metaat; + } + + return false; + } + + @Override + public AxisAlignedBB getRenderBoundingBox() { + return INFINITE_EXTENT_AABB; + } } diff --git a/src/main/java/vazkii/botania/common/block/tile/TileAltar.java b/src/main/java/vazkii/botania/common/block/tile/TileAltar.java index 483e490217..2ea60ae122 100644 --- a/src/main/java/vazkii/botania/common/block/tile/TileAltar.java +++ b/src/main/java/vazkii/botania/common/block/tile/TileAltar.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jan 21, 2014, 7:51:36 PM (GMT)] */ package vazkii.botania.common.block.tile; @@ -14,7 +14,6 @@ import java.util.ArrayList; import java.util.List; import java.util.regex.Pattern; - import net.minecraft.client.Minecraft; import net.minecraft.client.gui.ScaledResolution; import net.minecraft.client.renderer.entity.RenderItem; @@ -30,9 +29,7 @@ import net.minecraft.nbt.NBTTagCompound; import net.minecraft.util.AxisAlignedBB; import net.minecraft.util.StatCollector; - import org.lwjgl.opengl.GL11; - import vazkii.botania.api.BotaniaAPI; import vazkii.botania.api.internal.VanillaPacketDispatcher; import vazkii.botania.api.item.IPetalApothecary; @@ -46,354 +43,383 @@ public class TileAltar extends TileSimpleInventory implements ISidedInventory, IPetalApothecary { - private static final Pattern SEED_PATTERN = Pattern.compile("(?:(?:(?:[A-Z-_.:]|^)seed)|(?:(?:[a-z-_.:]|^)Seed))(?:[sA-Z-_.:]|$)"); - - public static final String TAG_HAS_WATER = "hasWater"; - public static final String TAG_HAS_LAVA = "hasLava"; - public static final String TAG_IS_MOSSY = "isMossy"; - - public boolean hasWater = false; - public boolean hasLava = false; - - public boolean isMossy = false; - - List lastRecipe = null; - int recipeKeepTicks = 0; - - public boolean collideEntityItem(EntityItem item) { - ItemStack stack = item.getEntityItem(); - if(stack == null || item.isDead) - return false; - - if(!isMossy && getBlockMetadata() == 0) { - if(stack.getItem() == Item.getItemFromBlock(Blocks.vine) && !worldObj.isRemote) { - isMossy = true; - worldObj.func_147453_f(xCoord, yCoord, zCoord, worldObj.getBlock(xCoord, yCoord, zCoord)); - stack.stackSize--; - if(stack.stackSize == 0) - item.setDead(); - VanillaPacketDispatcher.dispatchTEToNearbyPlayers(worldObj, xCoord, yCoord, zCoord); - } - } - - if(!hasWater() && !hasLava()) { - if(stack.getItem() == Items.water_bucket && !worldObj.isRemote) { - setWater(true); - worldObj.func_147453_f(xCoord, yCoord, zCoord, worldObj.getBlock(xCoord, yCoord, zCoord)); - stack.func_150996_a(Items.bucket); // Set item - } else if(stack.getItem() == Items.lava_bucket && !worldObj.isRemote) { - setLava(true); - worldObj.func_147453_f(xCoord, yCoord, zCoord, worldObj.getBlock(xCoord, yCoord, zCoord)); - stack.func_150996_a(Items.bucket); // Set item - } else return false; - } - - if(hasLava()) { - item.setFire(100); - return true; - } - - boolean didChange = false; - - if(canGoInAltar(stack, this)) { - if(getStackInSlot(getSizeInventory() - 1) != null) - return false; - - if(!worldObj.isRemote) { - stack.stackSize--; - if(stack.stackSize == 0) - item.setDead(); - - for(int i = 0; i < getSizeInventory(); i++) - if(getStackInSlot(i) == null) { - ItemStack stackToPut = stack.copy(); - stackToPut.stackSize = 1; - setInventorySlotContents(i, stackToPut); - didChange = true; - worldObj.playSoundAtEntity(item, "game.neutral.swim.splash", 0.1F, 1F); - break; - } - } - } else if(stack.getItem() != null && SEED_PATTERN.matcher(stack.getItem().getUnlocalizedName(stack)).find()) { - for(RecipePetals recipe : BotaniaAPI.petalRecipes) { - if(recipe.matches(this)) { - saveLastRecipe(); - - if(!worldObj.isRemote) { - for(int i = 0; i < getSizeInventory(); i++) - setInventorySlotContents(i, null); - - stack.stackSize--; - if(stack.stackSize == 0) - item.setDead(); - - ItemStack output = recipe.getOutput().copy(); - EntityItem outputItem = new EntityItem(worldObj, xCoord + 0.5, yCoord + 1.5, zCoord + 0.5, output); - worldObj.spawnEntityInWorld(outputItem); - - setWater(false); - worldObj.func_147453_f(xCoord, yCoord, zCoord, worldObj.getBlock(xCoord, yCoord, zCoord)); - } - - craftingFanciness(); - didChange = true; - - break; - } - } - } - - return didChange; - } - - private IFlowerComponent getFlowerComponent(ItemStack stack) { - IFlowerComponent component = CustomBotaniaAPI.extraFlowerComponents.get(stack.getItem()); - if (component == null) { - if (stack.getItem() instanceof IFlowerComponent) { - component = (IFlowerComponent) stack.getItem(); - } - } - return component; - } - - private boolean canGoInAltar(ItemStack stack, TileAltar reference) { - IFlowerComponent component = getFlowerComponent(stack); - return component != null && component.canFit(stack, reference); - } - - public void saveLastRecipe() { - lastRecipe = new ArrayList(); - for(int i = 0; i < getSizeInventory(); i++) { - ItemStack stack = getStackInSlot(i); - if(stack == null) - break; - lastRecipe.add(stack.copy()); - } - recipeKeepTicks = 400; - } - - public void trySetLastRecipe(EntityPlayer player) { - tryToSetLastRecipe(player, this, lastRecipe); - if(!isEmpty()) - VanillaPacketDispatcher.dispatchTEToNearbyPlayers(worldObj, xCoord, yCoord, zCoord); - } - - public static void tryToSetLastRecipe(EntityPlayer player, IInventory inv, List lastRecipe) { - if(lastRecipe == null || lastRecipe.isEmpty() || player.worldObj.isRemote) - return; - - int index = 0; - boolean didAny = false; - for(ItemStack stack : lastRecipe) { - if(stack == null) - continue; - - for(int i = 0; i < player.inventory.getSizeInventory(); i++) { - ItemStack pstack = player.inventory.getStackInSlot(i); - if(pstack != null && pstack.isItemEqual(stack) && ItemStack.areItemStackTagsEqual(stack, pstack)) { - pstack.stackSize--; - if(pstack.stackSize == 0) - player.inventory.setInventorySlotContents(i, null); - - ItemStack stackToPut = pstack.copy(); - stackToPut.stackSize = 1; - inv.setInventorySlotContents(index, stackToPut); - didAny = true; - index++; - break; - } - } - } - - if(didAny) { - if(inv instanceof TileAltar) - player.worldObj.playSoundAtEntity(player, "game.neutral.swim.splash", 0.1F, 1F); - if(player instanceof EntityPlayerMP) { - EntityPlayerMP mp = (EntityPlayerMP) player; - mp.inventoryContainer.detectAndSendChanges(); - } - } - } - - public void craftingFanciness() { - worldObj.playSoundEffect(xCoord, yCoord, zCoord, "botania:altarCraft", 1F, 1F); - for(int i = 0; i < 25; i++) { - float red = (float) Math.random(); - float green = (float) Math.random(); - float blue = (float) Math.random(); - Botania.proxy.sparkleFX(worldObj, xCoord + 0.5 + Math.random() * 0.4 - 0.2, yCoord + 1, zCoord + 0.5 + Math.random() * 0.4 - 0.2, red, green, blue, (float) Math.random(), 10); - } - } - - public boolean isEmpty() { - for(int i = 0; i < getSizeInventory(); i++) - if(getStackInSlot(i) != null) - return false; - - return true; - } - - @Override - public void updateEntity() { - List items = worldObj.getEntitiesWithinAABB(EntityItem.class, AxisAlignedBB.getBoundingBox(xCoord, yCoord + 1D / 16D * 20D, zCoord, xCoord + 1, yCoord + 1D / 16D * 21D, zCoord + 1)); - - boolean didChange = false; - - for(EntityItem item : items) - didChange = collideEntityItem(item) || didChange; - - if(didChange) - VanillaPacketDispatcher.dispatchTEToNearbyPlayers(worldObj, xCoord, yCoord, zCoord); - - for(int i = 0; i < getSizeInventory(); i++) { - ItemStack stackAt = getStackInSlot(i); - if(stackAt == null) - break; - - if(Math.random() >= 0.97) { - Color color = new Color(getFlowerComponent(stackAt).getParticleColor(stackAt)); - float red = color.getRed() / 255F; - float green = color.getGreen() / 255F; - float blue = color.getBlue() / 255F; - if(Math.random() >= 0.75F) - worldObj.playSoundEffect(xCoord + 0.5, yCoord + 0.5, zCoord + 0.5, "game.neutral.swim.splash", 0.1F, 10F); - Botania.proxy.sparkleFX(worldObj, xCoord + 0.5 + Math.random() * 0.4 - 0.2, yCoord + 1, zCoord + 0.5 + Math.random() * 0.4 - 0.2, red, green, blue, (float) Math.random(), 10); - } - } - - if(hasLava()) { - isMossy = false; - worldObj.spawnParticle("smoke", xCoord + 0.5 + Math.random() * 0.4 - 0.2, yCoord + 1, zCoord + 0.5 + Math.random() * 0.4 - 0.2, 0, 0.05, 0); - if(Math.random() > 0.9) - worldObj.spawnParticle("lava", xCoord + 0.5 + Math.random() * 0.4 - 0.2, yCoord + 1, zCoord + 0.5 + Math.random() * 0.4 - 0.2, 0, 0.01, 0); - } - - if(recipeKeepTicks > 0) - --recipeKeepTicks; - else lastRecipe = null; - } - - @Override - public void writeCustomNBT(NBTTagCompound cmp) { - super.writeCustomNBT(cmp); - - cmp.setBoolean(TAG_HAS_WATER, hasWater()); - cmp.setBoolean(TAG_HAS_LAVA, hasLava()); - cmp.setBoolean(TAG_IS_MOSSY, isMossy); - } - - @Override - public void readCustomNBT(NBTTagCompound cmp) { - super.readCustomNBT(cmp); - - hasWater = cmp.getBoolean(TAG_HAS_WATER); - hasLava = cmp.getBoolean(TAG_HAS_LAVA); - isMossy = cmp.getBoolean(TAG_IS_MOSSY); - } - - @Override - public String getInventoryName() { - return LibBlockNames.ALTAR; - } - - @Override - public int getSizeInventory() { - return 16; - } - - @Override - public int getInventoryStackLimit() { - return 1; - } - - @Override - public boolean isItemValidForSlot(int i, ItemStack itemstack) { - return false; - } - - @Override - public int[] getAccessibleSlotsFromSide(int var1) { - return new int[0]; - } - - @Override - public boolean canInsertItem(int i, ItemStack itemstack, int j) { - return false; - } - - @Override - public boolean canExtractItem(int i, ItemStack itemstack, int j) { - return false; - } - - @Override - public void setWater(boolean water) { - hasWater = water; - VanillaPacketDispatcher.dispatchTEToNearbyPlayers(worldObj, xCoord, yCoord, zCoord); - } - - public void setLava(boolean lava) { - hasLava = lava; - VanillaPacketDispatcher.dispatchTEToNearbyPlayers(worldObj, xCoord, yCoord, zCoord); - } - - @Override - public boolean hasWater() { - return hasWater; - } - - public boolean hasLava() { - return hasLava; - } - - public void renderHUD(Minecraft mc, ScaledResolution res) { - int xc = res.getScaledWidth() / 2; - int yc = res.getScaledHeight() / 2; - - float angle = -90; - int radius = 24; - int amt = 0; - for(int i = 0; i < getSizeInventory(); i++) { - if(getStackInSlot(i) == null) - break; - amt++; - } - - if(amt > 0) { - float anglePer = 360F / amt; - - for(RecipePetals recipe : BotaniaAPI.petalRecipes) - if(recipe.matches(this)) { - GL11.glColor4f(1F, 1F, 1F, 1F); - mc.renderEngine.bindTexture(HUDHandler.manaBar); - RenderHelper.drawTexturedModalRect(xc + radius + 9, yc - 8, 0, 0, 8, 22, 15); - - ItemStack stack = recipe.getOutput(); - - net.minecraft.client.renderer.RenderHelper.enableGUIStandardItemLighting(); - RenderItem.getInstance().renderItemIntoGUI(mc.fontRenderer, mc.renderEngine, stack, xc + radius + 32, yc - 8); - RenderItem.getInstance().renderItemIntoGUI(mc.fontRenderer, mc.renderEngine, new ItemStack(Items.wheat_seeds), xc + radius + 16, yc + 6); - net.minecraft.client.renderer.RenderHelper.disableStandardItemLighting(); - mc.fontRenderer.drawStringWithShadow("+", xc + radius + 14, yc + 10, 0xFFFFFF); - } - - net.minecraft.client.renderer.RenderHelper.enableGUIStandardItemLighting(); - for(int i = 0; i < amt; i++) { - double xPos = xc + Math.cos(angle * Math.PI / 180D) * radius - 8; - double yPos = yc + Math.sin(angle * Math.PI / 180D) * radius - 8; - GL11.glTranslated(xPos, yPos, 0); - RenderItem.getInstance().renderItemIntoGUI(mc.fontRenderer, mc.renderEngine, getStackInSlot(i), 0, 0); - GL11.glTranslated(-xPos, -yPos, 0); - - angle += anglePer; - } - net.minecraft.client.renderer.RenderHelper.disableStandardItemLighting(); - } else if(recipeKeepTicks > 0 && hasWater) { - String s = StatCollector.translateToLocal("botaniamisc.altarRefill0"); - mc.fontRenderer.drawStringWithShadow(s, xc - mc.fontRenderer.getStringWidth(s) / 2, yc + 10, 0xFFFFFF); - s = StatCollector.translateToLocal("botaniamisc.altarRefill1"); - mc.fontRenderer.drawStringWithShadow(s, xc - mc.fontRenderer.getStringWidth(s) / 2, yc + 20, 0xFFFFFF); - } - } - + private static final Pattern SEED_PATTERN = + Pattern.compile("(?:(?:(?:[A-Z-_.:]|^)seed)|(?:(?:[a-z-_.:]|^)Seed))(?:[sA-Z-_.:]|$)"); + + public static final String TAG_HAS_WATER = "hasWater"; + public static final String TAG_HAS_LAVA = "hasLava"; + public static final String TAG_IS_MOSSY = "isMossy"; + + public boolean hasWater = false; + public boolean hasLava = false; + + public boolean isMossy = false; + + List lastRecipe = null; + int recipeKeepTicks = 0; + + public boolean collideEntityItem(EntityItem item) { + ItemStack stack = item.getEntityItem(); + if (stack == null || item.isDead) return false; + + if (!isMossy && getBlockMetadata() == 0) { + if (stack.getItem() == Item.getItemFromBlock(Blocks.vine) && !worldObj.isRemote) { + isMossy = true; + worldObj.func_147453_f(xCoord, yCoord, zCoord, worldObj.getBlock(xCoord, yCoord, zCoord)); + stack.stackSize--; + if (stack.stackSize == 0) item.setDead(); + VanillaPacketDispatcher.dispatchTEToNearbyPlayers(worldObj, xCoord, yCoord, zCoord); + } + } + + if (!hasWater() && !hasLava()) { + if (stack.getItem() == Items.water_bucket && !worldObj.isRemote) { + setWater(true); + worldObj.func_147453_f(xCoord, yCoord, zCoord, worldObj.getBlock(xCoord, yCoord, zCoord)); + stack.func_150996_a(Items.bucket); // Set item + } else if (stack.getItem() == Items.lava_bucket && !worldObj.isRemote) { + setLava(true); + worldObj.func_147453_f(xCoord, yCoord, zCoord, worldObj.getBlock(xCoord, yCoord, zCoord)); + stack.func_150996_a(Items.bucket); // Set item + } else return false; + } + + if (hasLava()) { + item.setFire(100); + return true; + } + + boolean didChange = false; + + if (canGoInAltar(stack, this)) { + if (getStackInSlot(getSizeInventory() - 1) != null) return false; + + if (!worldObj.isRemote) { + stack.stackSize--; + if (stack.stackSize == 0) item.setDead(); + + for (int i = 0; i < getSizeInventory(); i++) + if (getStackInSlot(i) == null) { + ItemStack stackToPut = stack.copy(); + stackToPut.stackSize = 1; + setInventorySlotContents(i, stackToPut); + didChange = true; + worldObj.playSoundAtEntity(item, "game.neutral.swim.splash", 0.1F, 1F); + break; + } + } + } else if (stack.getItem() != null + && SEED_PATTERN + .matcher(stack.getItem().getUnlocalizedName(stack)) + .find()) { + for (RecipePetals recipe : BotaniaAPI.petalRecipes) { + if (recipe.matches(this)) { + saveLastRecipe(); + + if (!worldObj.isRemote) { + for (int i = 0; i < getSizeInventory(); i++) setInventorySlotContents(i, null); + + stack.stackSize--; + if (stack.stackSize == 0) item.setDead(); + + ItemStack output = recipe.getOutput().copy(); + EntityItem outputItem = + new EntityItem(worldObj, xCoord + 0.5, yCoord + 1.5, zCoord + 0.5, output); + worldObj.spawnEntityInWorld(outputItem); + + setWater(false); + worldObj.func_147453_f(xCoord, yCoord, zCoord, worldObj.getBlock(xCoord, yCoord, zCoord)); + } + + craftingFanciness(); + didChange = true; + + break; + } + } + } + + return didChange; + } + + private IFlowerComponent getFlowerComponent(ItemStack stack) { + IFlowerComponent component = CustomBotaniaAPI.extraFlowerComponents.get(stack.getItem()); + if (component == null) { + if (stack.getItem() instanceof IFlowerComponent) { + component = (IFlowerComponent) stack.getItem(); + } + } + return component; + } + + private boolean canGoInAltar(ItemStack stack, TileAltar reference) { + IFlowerComponent component = getFlowerComponent(stack); + return component != null && component.canFit(stack, reference); + } + + public void saveLastRecipe() { + lastRecipe = new ArrayList(); + for (int i = 0; i < getSizeInventory(); i++) { + ItemStack stack = getStackInSlot(i); + if (stack == null) break; + lastRecipe.add(stack.copy()); + } + recipeKeepTicks = 400; + } + + public void trySetLastRecipe(EntityPlayer player) { + tryToSetLastRecipe(player, this, lastRecipe); + if (!isEmpty()) VanillaPacketDispatcher.dispatchTEToNearbyPlayers(worldObj, xCoord, yCoord, zCoord); + } + + public static void tryToSetLastRecipe(EntityPlayer player, IInventory inv, List lastRecipe) { + if (lastRecipe == null || lastRecipe.isEmpty() || player.worldObj.isRemote) return; + + int index = 0; + boolean didAny = false; + for (ItemStack stack : lastRecipe) { + if (stack == null) continue; + + for (int i = 0; i < player.inventory.getSizeInventory(); i++) { + ItemStack pstack = player.inventory.getStackInSlot(i); + if (pstack != null && pstack.isItemEqual(stack) && ItemStack.areItemStackTagsEqual(stack, pstack)) { + pstack.stackSize--; + if (pstack.stackSize == 0) player.inventory.setInventorySlotContents(i, null); + + ItemStack stackToPut = pstack.copy(); + stackToPut.stackSize = 1; + inv.setInventorySlotContents(index, stackToPut); + didAny = true; + index++; + break; + } + } + } + + if (didAny) { + if (inv instanceof TileAltar) + player.worldObj.playSoundAtEntity(player, "game.neutral.swim.splash", 0.1F, 1F); + if (player instanceof EntityPlayerMP) { + EntityPlayerMP mp = (EntityPlayerMP) player; + mp.inventoryContainer.detectAndSendChanges(); + } + } + } + + public void craftingFanciness() { + worldObj.playSoundEffect(xCoord, yCoord, zCoord, "botania:altarCraft", 1F, 1F); + for (int i = 0; i < 25; i++) { + float red = (float) Math.random(); + float green = (float) Math.random(); + float blue = (float) Math.random(); + Botania.proxy.sparkleFX( + worldObj, + xCoord + 0.5 + Math.random() * 0.4 - 0.2, + yCoord + 1, + zCoord + 0.5 + Math.random() * 0.4 - 0.2, + red, + green, + blue, + (float) Math.random(), + 10); + } + } + + public boolean isEmpty() { + for (int i = 0; i < getSizeInventory(); i++) if (getStackInSlot(i) != null) return false; + + return true; + } + + @Override + public void updateEntity() { + List items = worldObj.getEntitiesWithinAABB( + EntityItem.class, + AxisAlignedBB.getBoundingBox( + xCoord, yCoord + 1D / 16D * 20D, zCoord, xCoord + 1, yCoord + 1D / 16D * 21D, zCoord + 1)); + + boolean didChange = false; + + for (EntityItem item : items) didChange = collideEntityItem(item) || didChange; + + if (didChange) VanillaPacketDispatcher.dispatchTEToNearbyPlayers(worldObj, xCoord, yCoord, zCoord); + + for (int i = 0; i < getSizeInventory(); i++) { + ItemStack stackAt = getStackInSlot(i); + if (stackAt == null) break; + + if (Math.random() >= 0.97) { + Color color = new Color(getFlowerComponent(stackAt).getParticleColor(stackAt)); + float red = color.getRed() / 255F; + float green = color.getGreen() / 255F; + float blue = color.getBlue() / 255F; + if (Math.random() >= 0.75F) + worldObj.playSoundEffect( + xCoord + 0.5, yCoord + 0.5, zCoord + 0.5, "game.neutral.swim.splash", 0.1F, 10F); + Botania.proxy.sparkleFX( + worldObj, + xCoord + 0.5 + Math.random() * 0.4 - 0.2, + yCoord + 1, + zCoord + 0.5 + Math.random() * 0.4 - 0.2, + red, + green, + blue, + (float) Math.random(), + 10); + } + } + + if (hasLava()) { + isMossy = false; + worldObj.spawnParticle( + "smoke", + xCoord + 0.5 + Math.random() * 0.4 - 0.2, + yCoord + 1, + zCoord + 0.5 + Math.random() * 0.4 - 0.2, + 0, + 0.05, + 0); + if (Math.random() > 0.9) + worldObj.spawnParticle( + "lava", + xCoord + 0.5 + Math.random() * 0.4 - 0.2, + yCoord + 1, + zCoord + 0.5 + Math.random() * 0.4 - 0.2, + 0, + 0.01, + 0); + } + + if (recipeKeepTicks > 0) --recipeKeepTicks; + else lastRecipe = null; + } + + @Override + public void writeCustomNBT(NBTTagCompound cmp) { + super.writeCustomNBT(cmp); + + cmp.setBoolean(TAG_HAS_WATER, hasWater()); + cmp.setBoolean(TAG_HAS_LAVA, hasLava()); + cmp.setBoolean(TAG_IS_MOSSY, isMossy); + } + + @Override + public void readCustomNBT(NBTTagCompound cmp) { + super.readCustomNBT(cmp); + + hasWater = cmp.getBoolean(TAG_HAS_WATER); + hasLava = cmp.getBoolean(TAG_HAS_LAVA); + isMossy = cmp.getBoolean(TAG_IS_MOSSY); + } + + @Override + public String getInventoryName() { + return LibBlockNames.ALTAR; + } + + @Override + public int getSizeInventory() { + return 16; + } + + @Override + public int getInventoryStackLimit() { + return 1; + } + + @Override + public boolean isItemValidForSlot(int i, ItemStack itemstack) { + return false; + } + + @Override + public int[] getAccessibleSlotsFromSide(int var1) { + return new int[0]; + } + + @Override + public boolean canInsertItem(int i, ItemStack itemstack, int j) { + return false; + } + + @Override + public boolean canExtractItem(int i, ItemStack itemstack, int j) { + return false; + } + + @Override + public void setWater(boolean water) { + hasWater = water; + VanillaPacketDispatcher.dispatchTEToNearbyPlayers(worldObj, xCoord, yCoord, zCoord); + } + + public void setLava(boolean lava) { + hasLava = lava; + VanillaPacketDispatcher.dispatchTEToNearbyPlayers(worldObj, xCoord, yCoord, zCoord); + } + + @Override + public boolean hasWater() { + return hasWater; + } + + public boolean hasLava() { + return hasLava; + } + + public void renderHUD(Minecraft mc, ScaledResolution res) { + int xc = res.getScaledWidth() / 2; + int yc = res.getScaledHeight() / 2; + + float angle = -90; + int radius = 24; + int amt = 0; + for (int i = 0; i < getSizeInventory(); i++) { + if (getStackInSlot(i) == null) break; + amt++; + } + + if (amt > 0) { + float anglePer = 360F / amt; + + for (RecipePetals recipe : BotaniaAPI.petalRecipes) + if (recipe.matches(this)) { + GL11.glColor4f(1F, 1F, 1F, 1F); + mc.renderEngine.bindTexture(HUDHandler.manaBar); + RenderHelper.drawTexturedModalRect(xc + radius + 9, yc - 8, 0, 0, 8, 22, 15); + + ItemStack stack = recipe.getOutput(); + + net.minecraft.client.renderer.RenderHelper.enableGUIStandardItemLighting(); + RenderItem.getInstance() + .renderItemIntoGUI(mc.fontRenderer, mc.renderEngine, stack, xc + radius + 32, yc - 8); + RenderItem.getInstance() + .renderItemIntoGUI( + mc.fontRenderer, + mc.renderEngine, + new ItemStack(Items.wheat_seeds), + xc + radius + 16, + yc + 6); + net.minecraft.client.renderer.RenderHelper.disableStandardItemLighting(); + mc.fontRenderer.drawStringWithShadow("+", xc + radius + 14, yc + 10, 0xFFFFFF); + } + + net.minecraft.client.renderer.RenderHelper.enableGUIStandardItemLighting(); + for (int i = 0; i < amt; i++) { + double xPos = xc + Math.cos(angle * Math.PI / 180D) * radius - 8; + double yPos = yc + Math.sin(angle * Math.PI / 180D) * radius - 8; + GL11.glTranslated(xPos, yPos, 0); + RenderItem.getInstance().renderItemIntoGUI(mc.fontRenderer, mc.renderEngine, getStackInSlot(i), 0, 0); + GL11.glTranslated(-xPos, -yPos, 0); + + angle += anglePer; + } + net.minecraft.client.renderer.RenderHelper.disableStandardItemLighting(); + } else if (recipeKeepTicks > 0 && hasWater) { + String s = StatCollector.translateToLocal("botaniamisc.altarRefill0"); + mc.fontRenderer.drawStringWithShadow(s, xc - mc.fontRenderer.getStringWidth(s) / 2, yc + 10, 0xFFFFFF); + s = StatCollector.translateToLocal("botaniamisc.altarRefill1"); + mc.fontRenderer.drawStringWithShadow(s, xc - mc.fontRenderer.getStringWidth(s) / 2, yc + 20, 0xFFFFFF); + } + } } diff --git a/src/main/java/vazkii/botania/common/block/tile/TileAvatar.java b/src/main/java/vazkii/botania/common/block/tile/TileAvatar.java index 1e0e62b28c..3898d900ef 100644 --- a/src/main/java/vazkii/botania/common/block/tile/TileAvatar.java +++ b/src/main/java/vazkii/botania/common/block/tile/TileAvatar.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Oct 24, 2015, 3:17:44 PM (GMT)] */ package vazkii.botania.common.block.tile; @@ -20,118 +20,117 @@ public class TileAvatar extends TileSimpleInventory implements IAvatarTile, ISidedInventory { - private static final int MAX_MANA = 6400; - - private static final String TAG_ENABLED = "enabled"; - private static final String TAG_TICKS_ELAPSED = "ticksElapsed"; - private static final String TAG_MANA = "ticksElapsed"; - - boolean enabled; - int ticksElapsed; - int mana; - - @Override - public void updateEntity() { - super.updateEntity(); - - enabled = true; - for(ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS) { - int redstoneSide = worldObj.getIndirectPowerLevelTo(xCoord + dir.offsetX, yCoord + dir.offsetY, zCoord + dir.offsetZ, dir.ordinal()); - if(redstoneSide > 0) { - enabled = false; - break; - } - } - - ItemStack stack = getStackInSlot(0); - if(stack != null && stack.getItem() instanceof IAvatarWieldable) { - IAvatarWieldable wieldable = (IAvatarWieldable) stack.getItem(); - wieldable.onAvatarUpdate(this, stack); - } - - if(enabled) - ticksElapsed++; - } - - @Override - public void writeCustomNBT(NBTTagCompound par1nbtTagCompound) { - super.writeCustomNBT(par1nbtTagCompound); - par1nbtTagCompound.setBoolean(TAG_ENABLED, enabled); - par1nbtTagCompound.setInteger(TAG_TICKS_ELAPSED, ticksElapsed); - par1nbtTagCompound.setInteger(TAG_MANA, mana); - } - - @Override - public void readCustomNBT(NBTTagCompound par1nbtTagCompound) { - super.readCustomNBT(par1nbtTagCompound); - enabled = par1nbtTagCompound.getBoolean(TAG_ENABLED); - ticksElapsed = par1nbtTagCompound.getInteger(TAG_TICKS_ELAPSED); - mana = par1nbtTagCompound.getInteger(TAG_MANA); - } - - @Override - public int getSizeInventory() { - return 1; - } - - @Override - public int getInventoryStackLimit() { - return 1; - } - - @Override - public boolean isItemValidForSlot(int i, ItemStack itemstack) { - return itemstack != null && itemstack.getItem() instanceof IAvatarTile; - } - - @Override - public int[] getAccessibleSlotsFromSide(int p_94128_1_) { - return new int[0]; - } - - @Override - public boolean canInsertItem(int p_102007_1_, ItemStack p_102007_2_, int p_102007_3_) { - return false; - } - - @Override - public boolean canExtractItem(int p_102008_1_, ItemStack p_102008_2_, int p_102008_3_) { - return false; - } - - @Override - public String getInventoryName() { - return LibBlockNames.AVATAR; - } - - @Override - public boolean isFull() { - return mana >= MAX_MANA; - } - - @Override - public void recieveMana(int mana) { - this.mana = Math.min(MAX_MANA, this.mana + mana); - } - - @Override - public boolean canRecieveManaFromBursts() { - return getStackInSlot(0) != null; - } - - @Override - public int getCurrentMana() { - return mana; - } - - @Override - public int getElapsedFunctionalTicks() { - return ticksElapsed; - } - - @Override - public boolean isEnabled() { - return enabled; - } - + private static final int MAX_MANA = 6400; + + private static final String TAG_ENABLED = "enabled"; + private static final String TAG_TICKS_ELAPSED = "ticksElapsed"; + private static final String TAG_MANA = "ticksElapsed"; + + boolean enabled; + int ticksElapsed; + int mana; + + @Override + public void updateEntity() { + super.updateEntity(); + + enabled = true; + for (ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS) { + int redstoneSide = worldObj.getIndirectPowerLevelTo( + xCoord + dir.offsetX, yCoord + dir.offsetY, zCoord + dir.offsetZ, dir.ordinal()); + if (redstoneSide > 0) { + enabled = false; + break; + } + } + + ItemStack stack = getStackInSlot(0); + if (stack != null && stack.getItem() instanceof IAvatarWieldable) { + IAvatarWieldable wieldable = (IAvatarWieldable) stack.getItem(); + wieldable.onAvatarUpdate(this, stack); + } + + if (enabled) ticksElapsed++; + } + + @Override + public void writeCustomNBT(NBTTagCompound par1nbtTagCompound) { + super.writeCustomNBT(par1nbtTagCompound); + par1nbtTagCompound.setBoolean(TAG_ENABLED, enabled); + par1nbtTagCompound.setInteger(TAG_TICKS_ELAPSED, ticksElapsed); + par1nbtTagCompound.setInteger(TAG_MANA, mana); + } + + @Override + public void readCustomNBT(NBTTagCompound par1nbtTagCompound) { + super.readCustomNBT(par1nbtTagCompound); + enabled = par1nbtTagCompound.getBoolean(TAG_ENABLED); + ticksElapsed = par1nbtTagCompound.getInteger(TAG_TICKS_ELAPSED); + mana = par1nbtTagCompound.getInteger(TAG_MANA); + } + + @Override + public int getSizeInventory() { + return 1; + } + + @Override + public int getInventoryStackLimit() { + return 1; + } + + @Override + public boolean isItemValidForSlot(int i, ItemStack itemstack) { + return itemstack != null && itemstack.getItem() instanceof IAvatarTile; + } + + @Override + public int[] getAccessibleSlotsFromSide(int p_94128_1_) { + return new int[0]; + } + + @Override + public boolean canInsertItem(int p_102007_1_, ItemStack p_102007_2_, int p_102007_3_) { + return false; + } + + @Override + public boolean canExtractItem(int p_102008_1_, ItemStack p_102008_2_, int p_102008_3_) { + return false; + } + + @Override + public String getInventoryName() { + return LibBlockNames.AVATAR; + } + + @Override + public boolean isFull() { + return mana >= MAX_MANA; + } + + @Override + public void recieveMana(int mana) { + this.mana = Math.min(MAX_MANA, this.mana + mana); + } + + @Override + public boolean canRecieveManaFromBursts() { + return getStackInSlot(0) != null; + } + + @Override + public int getCurrentMana() { + return mana; + } + + @Override + public int getElapsedFunctionalTicks() { + return ticksElapsed; + } + + @Override + public boolean isEnabled() { + return enabled; + } } diff --git a/src/main/java/vazkii/botania/common/block/tile/TileBifrost.java b/src/main/java/vazkii/botania/common/block/tile/TileBifrost.java index acefc2ffd3..272289b42e 100644 --- a/src/main/java/vazkii/botania/common/block/tile/TileBifrost.java +++ b/src/main/java/vazkii/botania/common/block/tile/TileBifrost.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jun 20, 2014, 8:35:27 PM (GMT)] */ package vazkii.botania.common.block.tile; @@ -15,30 +15,38 @@ public class TileBifrost extends TileMod { - private static final String TAG_TICKS = "ticks"; - - public int ticks = 0; - - @Override - public void updateEntity() { - if(!worldObj.isRemote) { - if(ticks <= 0) { - worldObj.setBlockToAir(xCoord, yCoord, zCoord); - } else ticks--; - } else if(Math.random() < 0.1) - Botania.proxy.sparkleFX(worldObj, xCoord + Math.random(), yCoord + Math.random(), zCoord + Math.random(), (float) Math.random(), (float) Math.random(), (float) Math.random(), 0.45F + 0.2F * (float) Math.random(), 6); - } - - @Override - public void writeToNBT(NBTTagCompound par1nbtTagCompound) { - super.writeToNBT(par1nbtTagCompound); - par1nbtTagCompound.setInteger(TAG_TICKS, ticks); - } - - @Override - public void readFromNBT(NBTTagCompound par1nbtTagCompound) { - super.readFromNBT(par1nbtTagCompound); - ticks = par1nbtTagCompound.getInteger(TAG_TICKS); - } - + private static final String TAG_TICKS = "ticks"; + + public int ticks = 0; + + @Override + public void updateEntity() { + if (!worldObj.isRemote) { + if (ticks <= 0) { + worldObj.setBlockToAir(xCoord, yCoord, zCoord); + } else ticks--; + } else if (Math.random() < 0.1) + Botania.proxy.sparkleFX( + worldObj, + xCoord + Math.random(), + yCoord + Math.random(), + zCoord + Math.random(), + (float) Math.random(), + (float) Math.random(), + (float) Math.random(), + 0.45F + 0.2F * (float) Math.random(), + 6); + } + + @Override + public void writeToNBT(NBTTagCompound par1nbtTagCompound) { + super.writeToNBT(par1nbtTagCompound); + par1nbtTagCompound.setInteger(TAG_TICKS, ticks); + } + + @Override + public void readFromNBT(NBTTagCompound par1nbtTagCompound) { + super.readFromNBT(par1nbtTagCompound); + ticks = par1nbtTagCompound.getInteger(TAG_TICKS); + } } diff --git a/src/main/java/vazkii/botania/common/block/tile/TileBrewery.java b/src/main/java/vazkii/botania/common/block/tile/TileBrewery.java index 2a4961a9cf..c4436c7651 100644 --- a/src/main/java/vazkii/botania/common/block/tile/TileBrewery.java +++ b/src/main/java/vazkii/botania/common/block/tile/TileBrewery.java @@ -2,17 +2,16 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Oct 31, 2014, 4:42:36 PM (GMT)] */ package vazkii.botania.common.block.tile; import java.awt.Color; import java.util.List; - import net.minecraft.client.Minecraft; import net.minecraft.client.gui.ScaledResolution; import net.minecraft.entity.item.EntityItem; @@ -34,229 +33,270 @@ // This is mostly copypasta from TileRuneAltar public class TileBrewery extends TileSimpleInventory implements ISidedInventory, IManaReceiver { - private static final String TAG_MANA = "mana"; - - public RecipeBrew recipe; - int mana = 0; - int manaLastTick = 0; - public int signal = 0; - - public boolean addItem(EntityPlayer player, ItemStack stack) { - if(recipe != null || stack == null || stack.getItem() instanceof IBrewItem && ((IBrewItem) stack.getItem()).getBrew(stack) != null && ((IBrewItem) stack.getItem()).getBrew(stack) != BotaniaAPI.fallbackBrew || getStackInSlot(0) == null != stack.getItem() instanceof IBrewContainer) - return false; - - boolean did = false; - - for(int i = 0; i < getSizeInventory(); i++) - if(getStackInSlot(i) == null) { - did = true; - ItemStack stackToAdd = stack.copy(); - stackToAdd.stackSize = 1; - setInventorySlotContents(i, stackToAdd); - - if(player == null || !player.capabilities.isCreativeMode) { - stack.stackSize--; - if(stack.stackSize == 0 && player != null) - player.inventory.setInventorySlotContents(player.inventory.currentItem, null); - } - - break; - } - - if(did) { - VanillaPacketDispatcher.dispatchTEToNearbyPlayers(worldObj, xCoord, yCoord, zCoord); - for(RecipeBrew recipe : BotaniaAPI.brewRecipes) - if(recipe.matches(this) && recipe.getOutput(getStackInSlot(0)) != null) { - this.recipe = recipe; - worldObj.setBlockMetadataWithNotify(xCoord, yCoord, zCoord, 1, 1 | 2); - } - } - - return true; - } - - @Override - public void updateEntity() { - super.updateEntity(); - - if(mana > 0 && recipe == null) { - for(RecipeBrew recipe : BotaniaAPI.brewRecipes) - if(recipe.matches(this)) { - this.recipe = recipe; - worldObj.setBlockMetadataWithNotify(xCoord, yCoord, zCoord, 1, 1 | 2); - } - - if(recipe == null) - mana = 0; - } - - // Update every tick. - recieveMana(0); - - if(!worldObj.isRemote && recipe == null) { - List items = worldObj.getEntitiesWithinAABB(EntityItem.class, AxisAlignedBB.getBoundingBox(xCoord, yCoord, zCoord, xCoord + 1, yCoord + 1, zCoord + 1)); - for(EntityItem item : items) - if(!item.isDead && item.getEntityItem() != null) { - ItemStack stack = item.getEntityItem(); - if(addItem(null, stack) && stack.stackSize == 0) - item.setDead(); - } - } - - if(recipe != null) { - if(!recipe.matches(this)) { - recipe = null; - worldObj.setBlockMetadataWithNotify(xCoord, yCoord, zCoord, 0, 1 | 2); - } - - if(recipe != null) { - if(mana != manaLastTick) { - Color color = new Color(recipe.getBrew().getColor(getStackInSlot(0))); - float r = color.getRed() / 255F; - float g = color.getGreen() / 255F; - float b = color.getBlue() / 255F; - for(int i = 0; i < 5; i++) { - Botania.proxy.wispFX(worldObj, xCoord + 0.7 - Math.random() * 0.4, yCoord + 0.9 - Math.random() * 0.2, zCoord + 0.7 - Math.random() * 0.4, r, g, b, 0.1F + (float) Math.random() * 0.05F, 0.03F - (float) Math.random() * 0.06F, 0.03F + (float) Math.random() * 0.015F, 0.03F - (float) Math.random() * 0.06F); - for(int j = 0; j < 2; j++) - Botania.proxy.wispFX(worldObj, xCoord + 0.7 - Math.random() * 0.4, yCoord + 0.9 - Math.random() * 0.2, zCoord + 0.7 - Math.random() * 0.4, 0.2F, 0.2F, 0.2F, 0.1F + (float) Math.random() * 0.2F, 0.03F - (float) Math.random() * 0.06F, 0.03F + (float) Math.random() * 0.015F, 0.03F - (float) Math.random() * 0.06F); - } - } - - if(mana >= getManaCost() && !worldObj.isRemote) { - int mana = getManaCost(); - recieveMana(-mana); - if(!worldObj.isRemote) { - ItemStack output = recipe.getOutput(getStackInSlot(0)); - EntityItem outputItem = new EntityItem(worldObj, xCoord + 0.5, yCoord + 1.5, zCoord + 0.5, output); - worldObj.spawnEntityInWorld(outputItem); - } - - for(int i = 0; i < getSizeInventory(); i++) - setInventorySlotContents(i, null); - - craftingFanciness(); - } - } - } - - int newSignal = 0; - if(recipe != null) - newSignal++; - - if(newSignal != signal) { - signal = newSignal; - worldObj.func_147453_f(xCoord, yCoord, zCoord, worldObj.getBlock(xCoord, yCoord, zCoord)); - } - - manaLastTick = mana; - } - - public int getManaCost() { - ItemStack stack = getStackInSlot(0); - if(recipe == null || stack == null || !(stack.getItem() instanceof IBrewContainer)) - return 0; - IBrewContainer container = (IBrewContainer) stack.getItem(); - return container.getManaCost(recipe.getBrew(), stack); - } - - public void craftingFanciness() { - worldObj.playSoundEffect(xCoord, yCoord, zCoord, "botania:potionCreate", 1F, 1.5F + (float) Math.random() * 0.25F); - for(int i = 0; i < 25; i++) { - Color color = new Color(recipe.getBrew().getColor(getStackInSlot(0))); - float r = color.getRed() / 255F; - float g = color.getGreen() / 255F; - float b = color.getBlue() / 255F; - Botania.proxy.sparkleFX(worldObj, xCoord + 0.5 + Math.random() * 0.4 - 0.2, yCoord + 1, zCoord + 0.5 + Math.random() * 0.4 - 0.2, r, g, b, (float) Math.random() * 2F + 0.5F, 10); - for(int j = 0; j < 2; j++) - Botania.proxy.wispFX(worldObj, xCoord + 0.7 - Math.random() * 0.4, yCoord + 0.9 - Math.random() * 0.2, zCoord + 0.7 - Math.random() * 0.4, 0.2F, 0.2F, 0.2F, 0.1F + (float) Math.random() * 0.2F, 0.05F - (float) Math.random() * 0.1F, 0.05F + (float) Math.random() * 0.03F, 0.05F - (float) Math.random() * 0.1F); - } - } - - @Override - public void writeCustomNBT(NBTTagCompound par1nbtTagCompound) { - super.writeCustomNBT(par1nbtTagCompound); - - par1nbtTagCompound.setInteger(TAG_MANA, mana); - } - - @Override - public void readCustomNBT(NBTTagCompound par1nbtTagCompound) { - super.readCustomNBT(par1nbtTagCompound); - - mana = par1nbtTagCompound.getInteger(TAG_MANA); - } - - @Override - public int getSizeInventory() { - return 7; - } - - @Override - public AxisAlignedBB getRenderBoundingBox() { - return INFINITE_EXTENT_AABB; - } - - @Override - public String getInventoryName() { - return LibBlockNames.RUNE_ALTAR; - } - - @Override - public int getInventoryStackLimit() { - return 1; - } - - @Override - public int[] getAccessibleSlotsFromSide(int var1) { - int accessibleSlot = -1; - for(int i = 0; i < getSizeInventory(); i++) - if(getStackInSlot(i) != null) - accessibleSlot = i; - - return accessibleSlot == -1 ? new int[0] : new int[] { accessibleSlot }; - } - - @Override - public boolean canInsertItem(int i, ItemStack itemstack, int j) { - return true; - } - - @Override - public boolean canExtractItem(int i, ItemStack itemstack, int j) { - return mana == 0; - } - - @Override - public int getCurrentMana() { - return mana; - } - - @Override - public boolean isFull() { - return mana >= getManaCost(); - } - - @Override - public void recieveMana(int mana) { - this.mana = Math.min(this.mana + mana, getManaCost()); - } - - @Override - public boolean canRecieveManaFromBursts() { - return !isFull(); - } - - public void renderHUD(Minecraft mc, ScaledResolution res) { - int manaToGet = getManaCost(); - if(manaToGet > 0) { - int x = res.getScaledWidth() / 2 + 20; - int y = res.getScaledHeight() / 2 - 8; - - if(recipe == null) - return; - - RenderHelper.renderProgressPie(x, y, (float) mana / (float) manaToGet, recipe.getOutput(getStackInSlot(0))); - } - } - + private static final String TAG_MANA = "mana"; + + public RecipeBrew recipe; + int mana = 0; + int manaLastTick = 0; + public int signal = 0; + + public boolean addItem(EntityPlayer player, ItemStack stack) { + if (recipe != null + || stack == null + || stack.getItem() instanceof IBrewItem + && ((IBrewItem) stack.getItem()).getBrew(stack) != null + && ((IBrewItem) stack.getItem()).getBrew(stack) != BotaniaAPI.fallbackBrew + || getStackInSlot(0) == null != stack.getItem() instanceof IBrewContainer) return false; + + boolean did = false; + + for (int i = 0; i < getSizeInventory(); i++) + if (getStackInSlot(i) == null) { + did = true; + ItemStack stackToAdd = stack.copy(); + stackToAdd.stackSize = 1; + setInventorySlotContents(i, stackToAdd); + + if (player == null || !player.capabilities.isCreativeMode) { + stack.stackSize--; + if (stack.stackSize == 0 && player != null) + player.inventory.setInventorySlotContents(player.inventory.currentItem, null); + } + + break; + } + + if (did) { + VanillaPacketDispatcher.dispatchTEToNearbyPlayers(worldObj, xCoord, yCoord, zCoord); + for (RecipeBrew recipe : BotaniaAPI.brewRecipes) + if (recipe.matches(this) && recipe.getOutput(getStackInSlot(0)) != null) { + this.recipe = recipe; + worldObj.setBlockMetadataWithNotify(xCoord, yCoord, zCoord, 1, 1 | 2); + } + } + + return true; + } + + @Override + public void updateEntity() { + super.updateEntity(); + + if (mana > 0 && recipe == null) { + for (RecipeBrew recipe : BotaniaAPI.brewRecipes) + if (recipe.matches(this)) { + this.recipe = recipe; + worldObj.setBlockMetadataWithNotify(xCoord, yCoord, zCoord, 1, 1 | 2); + } + + if (recipe == null) mana = 0; + } + + // Update every tick. + recieveMana(0); + + if (!worldObj.isRemote && recipe == null) { + List items = worldObj.getEntitiesWithinAABB( + EntityItem.class, + AxisAlignedBB.getBoundingBox(xCoord, yCoord, zCoord, xCoord + 1, yCoord + 1, zCoord + 1)); + for (EntityItem item : items) + if (!item.isDead && item.getEntityItem() != null) { + ItemStack stack = item.getEntityItem(); + if (addItem(null, stack) && stack.stackSize == 0) item.setDead(); + } + } + + if (recipe != null) { + if (!recipe.matches(this)) { + recipe = null; + worldObj.setBlockMetadataWithNotify(xCoord, yCoord, zCoord, 0, 1 | 2); + } + + if (recipe != null) { + if (mana != manaLastTick) { + Color color = new Color(recipe.getBrew().getColor(getStackInSlot(0))); + float r = color.getRed() / 255F; + float g = color.getGreen() / 255F; + float b = color.getBlue() / 255F; + for (int i = 0; i < 5; i++) { + Botania.proxy.wispFX( + worldObj, + xCoord + 0.7 - Math.random() * 0.4, + yCoord + 0.9 - Math.random() * 0.2, + zCoord + 0.7 - Math.random() * 0.4, + r, + g, + b, + 0.1F + (float) Math.random() * 0.05F, + 0.03F - (float) Math.random() * 0.06F, + 0.03F + (float) Math.random() * 0.015F, + 0.03F - (float) Math.random() * 0.06F); + for (int j = 0; j < 2; j++) + Botania.proxy.wispFX( + worldObj, + xCoord + 0.7 - Math.random() * 0.4, + yCoord + 0.9 - Math.random() * 0.2, + zCoord + 0.7 - Math.random() * 0.4, + 0.2F, + 0.2F, + 0.2F, + 0.1F + (float) Math.random() * 0.2F, + 0.03F - (float) Math.random() * 0.06F, + 0.03F + (float) Math.random() * 0.015F, + 0.03F - (float) Math.random() * 0.06F); + } + } + + if (mana >= getManaCost() && !worldObj.isRemote) { + int mana = getManaCost(); + recieveMana(-mana); + if (!worldObj.isRemote) { + ItemStack output = recipe.getOutput(getStackInSlot(0)); + EntityItem outputItem = + new EntityItem(worldObj, xCoord + 0.5, yCoord + 1.5, zCoord + 0.5, output); + worldObj.spawnEntityInWorld(outputItem); + } + + for (int i = 0; i < getSizeInventory(); i++) setInventorySlotContents(i, null); + + craftingFanciness(); + } + } + } + + int newSignal = 0; + if (recipe != null) newSignal++; + + if (newSignal != signal) { + signal = newSignal; + worldObj.func_147453_f(xCoord, yCoord, zCoord, worldObj.getBlock(xCoord, yCoord, zCoord)); + } + + manaLastTick = mana; + } + + public int getManaCost() { + ItemStack stack = getStackInSlot(0); + if (recipe == null || stack == null || !(stack.getItem() instanceof IBrewContainer)) return 0; + IBrewContainer container = (IBrewContainer) stack.getItem(); + return container.getManaCost(recipe.getBrew(), stack); + } + + public void craftingFanciness() { + worldObj.playSoundEffect( + xCoord, yCoord, zCoord, "botania:potionCreate", 1F, 1.5F + (float) Math.random() * 0.25F); + for (int i = 0; i < 25; i++) { + Color color = new Color(recipe.getBrew().getColor(getStackInSlot(0))); + float r = color.getRed() / 255F; + float g = color.getGreen() / 255F; + float b = color.getBlue() / 255F; + Botania.proxy.sparkleFX( + worldObj, + xCoord + 0.5 + Math.random() * 0.4 - 0.2, + yCoord + 1, + zCoord + 0.5 + Math.random() * 0.4 - 0.2, + r, + g, + b, + (float) Math.random() * 2F + 0.5F, + 10); + for (int j = 0; j < 2; j++) + Botania.proxy.wispFX( + worldObj, + xCoord + 0.7 - Math.random() * 0.4, + yCoord + 0.9 - Math.random() * 0.2, + zCoord + 0.7 - Math.random() * 0.4, + 0.2F, + 0.2F, + 0.2F, + 0.1F + (float) Math.random() * 0.2F, + 0.05F - (float) Math.random() * 0.1F, + 0.05F + (float) Math.random() * 0.03F, + 0.05F - (float) Math.random() * 0.1F); + } + } + + @Override + public void writeCustomNBT(NBTTagCompound par1nbtTagCompound) { + super.writeCustomNBT(par1nbtTagCompound); + + par1nbtTagCompound.setInteger(TAG_MANA, mana); + } + + @Override + public void readCustomNBT(NBTTagCompound par1nbtTagCompound) { + super.readCustomNBT(par1nbtTagCompound); + + mana = par1nbtTagCompound.getInteger(TAG_MANA); + } + + @Override + public int getSizeInventory() { + return 7; + } + + @Override + public AxisAlignedBB getRenderBoundingBox() { + return INFINITE_EXTENT_AABB; + } + + @Override + public String getInventoryName() { + return LibBlockNames.RUNE_ALTAR; + } + + @Override + public int getInventoryStackLimit() { + return 1; + } + + @Override + public int[] getAccessibleSlotsFromSide(int var1) { + int accessibleSlot = -1; + for (int i = 0; i < getSizeInventory(); i++) if (getStackInSlot(i) != null) accessibleSlot = i; + + return accessibleSlot == -1 ? new int[0] : new int[] {accessibleSlot}; + } + + @Override + public boolean canInsertItem(int i, ItemStack itemstack, int j) { + return true; + } + + @Override + public boolean canExtractItem(int i, ItemStack itemstack, int j) { + return mana == 0; + } + + @Override + public int getCurrentMana() { + return mana; + } + + @Override + public boolean isFull() { + return mana >= getManaCost(); + } + + @Override + public void recieveMana(int mana) { + this.mana = Math.min(this.mana + mana, getManaCost()); + } + + @Override + public boolean canRecieveManaFromBursts() { + return !isFull(); + } + + public void renderHUD(Minecraft mc, ScaledResolution res) { + int manaToGet = getManaCost(); + if (manaToGet > 0) { + int x = res.getScaledWidth() / 2 + 20; + int y = res.getScaledHeight() / 2 - 8; + + if (recipe == null) return; + + RenderHelper.renderProgressPie(x, y, (float) mana / (float) manaToGet, recipe.getOutput(getStackInSlot(0))); + } + } } diff --git a/src/main/java/vazkii/botania/common/block/tile/TileCacophonium.java b/src/main/java/vazkii/botania/common/block/tile/TileCacophonium.java index a1dc474ebf..b3c5f6cad3 100644 --- a/src/main/java/vazkii/botania/common/block/tile/TileCacophonium.java +++ b/src/main/java/vazkii/botania/common/block/tile/TileCacophonium.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Aug 23, 2015, 7:25:38 PM (GMT)] */ package vazkii.botania.common.block.tile; @@ -16,30 +16,28 @@ public class TileCacophonium extends TileMod { - private static final String TAG_STACK = "stack"; + private static final String TAG_STACK = "stack"; - public ItemStack stack; + public ItemStack stack; - public void annoyDirewolf() { - ItemCacophonium.playSound(worldObj, stack, xCoord, yCoord, zCoord, 1F); - } + public void annoyDirewolf() { + ItemCacophonium.playSound(worldObj, stack, xCoord, yCoord, zCoord, 1F); + } - @Override - public void writeCustomNBT(NBTTagCompound cmp) { - super.writeCustomNBT(cmp); + @Override + public void writeCustomNBT(NBTTagCompound cmp) { + super.writeCustomNBT(cmp); - NBTTagCompound cmp1 = new NBTTagCompound(); - if(stack != null) - stack.writeToNBT(cmp1); - cmp.setTag(TAG_STACK, cmp1); - } + NBTTagCompound cmp1 = new NBTTagCompound(); + if (stack != null) stack.writeToNBT(cmp1); + cmp.setTag(TAG_STACK, cmp1); + } - @Override - public void readCustomNBT(NBTTagCompound cmp) { - super.readCustomNBT(cmp); - - NBTTagCompound cmp1 = cmp.getCompoundTag(TAG_STACK); - stack = ItemStack.loadItemStackFromNBT(cmp1); - } + @Override + public void readCustomNBT(NBTTagCompound cmp) { + super.readCustomNBT(cmp); + NBTTagCompound cmp1 = cmp.getCompoundTag(TAG_STACK); + stack = ItemStack.loadItemStackFromNBT(cmp1); + } } diff --git a/src/main/java/vazkii/botania/common/block/tile/TileCamo.java b/src/main/java/vazkii/botania/common/block/tile/TileCamo.java index e96e0e3751..257cacd11f 100644 --- a/src/main/java/vazkii/botania/common/block/tile/TileCamo.java +++ b/src/main/java/vazkii/botania/common/block/tile/TileCamo.java @@ -2,15 +2,14 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jun 7, 2014, 2:21:28 PM (GMT)] */ package vazkii.botania.common.block.tile; - import net.minecraft.block.Block; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.network.NetworkManager; @@ -18,34 +17,34 @@ public class TileCamo extends TileMod { - private static final String TAG_CAMO = "camo"; - private static final String TAG_CAMO_META = "camoMeta"; - - public Block camo; - public int camoMeta; - - @Override - public boolean canUpdate() { - return false; - } - - @Override - public void writeCustomNBT(NBTTagCompound cmp) { - if(camo != null) { - cmp.setString(TAG_CAMO, Block.blockRegistry.getNameForObject(camo)); - cmp.setInteger(TAG_CAMO_META, camoMeta); - } - } - - @Override - public void readCustomNBT(NBTTagCompound cmp) { - camo = Block.getBlockFromName(cmp.getString(TAG_CAMO)); - camoMeta = cmp.getInteger(TAG_CAMO_META); - } - - @Override - public void onDataPacket(NetworkManager manager, S35PacketUpdateTileEntity packet) { - super.onDataPacket(manager, packet); - worldObj.markBlockRangeForRenderUpdate(xCoord,yCoord,zCoord,xCoord,yCoord,zCoord); - } + private static final String TAG_CAMO = "camo"; + private static final String TAG_CAMO_META = "camoMeta"; + + public Block camo; + public int camoMeta; + + @Override + public boolean canUpdate() { + return false; + } + + @Override + public void writeCustomNBT(NBTTagCompound cmp) { + if (camo != null) { + cmp.setString(TAG_CAMO, Block.blockRegistry.getNameForObject(camo)); + cmp.setInteger(TAG_CAMO_META, camoMeta); + } + } + + @Override + public void readCustomNBT(NBTTagCompound cmp) { + camo = Block.getBlockFromName(cmp.getString(TAG_CAMO)); + camoMeta = cmp.getInteger(TAG_CAMO_META); + } + + @Override + public void onDataPacket(NetworkManager manager, S35PacketUpdateTileEntity packet) { + super.onDataPacket(manager, packet); + worldObj.markBlockRangeForRenderUpdate(xCoord, yCoord, zCoord, xCoord, yCoord, zCoord); + } } diff --git a/src/main/java/vazkii/botania/common/block/tile/TileCell.java b/src/main/java/vazkii/botania/common/block/tile/TileCell.java index ed5f734418..856f53bba6 100644 --- a/src/main/java/vazkii/botania/common/block/tile/TileCell.java +++ b/src/main/java/vazkii/botania/common/block/tile/TileCell.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Sep 6, 2015, 4:07:16 PM (GMT)] */ package vazkii.botania.common.block.tile; @@ -16,77 +16,76 @@ public class TileCell extends TileMod { - private static final String TAG_GENERATION = "generation"; - private static final String TAG_TICKED = "ticked"; - private static final String TAG_FLOWER_X = "flowerX"; - private static final String TAG_FLOWER_Y = "flowerY"; - private static final String TAG_FLOWER_Z = "flowerZ"; - private static final String TAG_VALID_X = "validX"; - private static final String TAG_VALID_Y = "validY"; - private static final String TAG_VALID_Z = "validZ"; + private static final String TAG_GENERATION = "generation"; + private static final String TAG_TICKED = "ticked"; + private static final String TAG_FLOWER_X = "flowerX"; + private static final String TAG_FLOWER_Y = "flowerY"; + private static final String TAG_FLOWER_Z = "flowerZ"; + private static final String TAG_VALID_X = "validX"; + private static final String TAG_VALID_Y = "validY"; + private static final String TAG_VALID_Z = "validZ"; - private int generation; - private boolean ticked; - private ChunkCoordinates flowerCoords = new ChunkCoordinates(); - private ChunkCoordinates validCoords = new ChunkCoordinates(); + private int generation; + private boolean ticked; + private ChunkCoordinates flowerCoords = new ChunkCoordinates(); + private ChunkCoordinates validCoords = new ChunkCoordinates(); - @Override - public boolean canUpdate() { - return false; - } + @Override + public boolean canUpdate() { + return false; + } - public void setGeneration(TileEntity flower, int gen) { - generation = gen; - if(!ticked) { - flowerCoords.posX = flower.xCoord; - flowerCoords.posY = flower.yCoord; - flowerCoords.posZ = flower.zCoord; - validCoords.posX = xCoord; - validCoords.posY = yCoord; - validCoords.posZ = zCoord; - ticked = true; - } else if(!matchCoords(validCoords, this) || !matchCoords(flowerCoords, flower)) - worldObj.setBlockToAir(xCoord, yCoord, zCoord); - } + public void setGeneration(TileEntity flower, int gen) { + generation = gen; + if (!ticked) { + flowerCoords.posX = flower.xCoord; + flowerCoords.posY = flower.yCoord; + flowerCoords.posZ = flower.zCoord; + validCoords.posX = xCoord; + validCoords.posY = yCoord; + validCoords.posZ = zCoord; + ticked = true; + } else if (!matchCoords(validCoords, this) || !matchCoords(flowerCoords, flower)) + worldObj.setBlockToAir(xCoord, yCoord, zCoord); + } - public boolean isSameFlower(TileEntity flower) { - return matchCoords(validCoords, this) && matchCoords(flowerCoords, flower); - } + public boolean isSameFlower(TileEntity flower) { + return matchCoords(validCoords, this) && matchCoords(flowerCoords, flower); + } - private boolean matchCoords(ChunkCoordinates coords, TileEntity tile) { - return coords.posX == tile.xCoord && coords.posY == tile.yCoord && coords.posZ == tile.zCoord; - } + private boolean matchCoords(ChunkCoordinates coords, TileEntity tile) { + return coords.posX == tile.xCoord && coords.posY == tile.yCoord && coords.posZ == tile.zCoord; + } - public int getGeneration() { - return generation; - } + public int getGeneration() { + return generation; + } - @Override - public void writeCustomNBT(NBTTagCompound cmp) { - cmp.setInteger(TAG_GENERATION, generation); - cmp.setBoolean(TAG_TICKED, ticked); - if(ticked) { - cmp.setInteger(TAG_FLOWER_X, flowerCoords.posX); - cmp.setInteger(TAG_FLOWER_Y, flowerCoords.posY); - cmp.setInteger(TAG_FLOWER_Z, flowerCoords.posZ); - cmp.setInteger(TAG_VALID_X, validCoords.posX); - cmp.setInteger(TAG_VALID_Y, validCoords.posY); - cmp.setInteger(TAG_VALID_Z, validCoords.posZ); - } - } - - @Override - public void readCustomNBT(NBTTagCompound cmp) { - generation = cmp.getInteger(TAG_GENERATION); - ticked = cmp.getBoolean(TAG_TICKED); - if(ticked) { - flowerCoords.posX = cmp.getInteger(TAG_FLOWER_X); - flowerCoords.posY = cmp.getInteger(TAG_FLOWER_Y); - flowerCoords.posZ = cmp.getInteger(TAG_FLOWER_Z); - validCoords.posX = cmp.getInteger(TAG_VALID_X); - validCoords.posY = cmp.getInteger(TAG_VALID_Y); - validCoords.posZ = cmp.getInteger(TAG_VALID_Z); - } - } + @Override + public void writeCustomNBT(NBTTagCompound cmp) { + cmp.setInteger(TAG_GENERATION, generation); + cmp.setBoolean(TAG_TICKED, ticked); + if (ticked) { + cmp.setInteger(TAG_FLOWER_X, flowerCoords.posX); + cmp.setInteger(TAG_FLOWER_Y, flowerCoords.posY); + cmp.setInteger(TAG_FLOWER_Z, flowerCoords.posZ); + cmp.setInteger(TAG_VALID_X, validCoords.posX); + cmp.setInteger(TAG_VALID_Y, validCoords.posY); + cmp.setInteger(TAG_VALID_Z, validCoords.posZ); + } + } + @Override + public void readCustomNBT(NBTTagCompound cmp) { + generation = cmp.getInteger(TAG_GENERATION); + ticked = cmp.getBoolean(TAG_TICKED); + if (ticked) { + flowerCoords.posX = cmp.getInteger(TAG_FLOWER_X); + flowerCoords.posY = cmp.getInteger(TAG_FLOWER_Y); + flowerCoords.posZ = cmp.getInteger(TAG_FLOWER_Z); + validCoords.posX = cmp.getInteger(TAG_VALID_X); + validCoords.posY = cmp.getInteger(TAG_VALID_Y); + validCoords.posZ = cmp.getInteger(TAG_VALID_Z); + } + } } diff --git a/src/main/java/vazkii/botania/common/block/tile/TileCocoon.java b/src/main/java/vazkii/botania/common/block/tile/TileCocoon.java index 1dd09aed97..c068570bcd 100644 --- a/src/main/java/vazkii/botania/common/block/tile/TileCocoon.java +++ b/src/main/java/vazkii/botania/common/block/tile/TileCocoon.java @@ -2,14 +2,15 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jul 8, 2015, 4:32:34 PM (GMT)] */ package vazkii.botania.common.block.tile; +import cpw.mods.fml.common.registry.VillagerRegistry; import net.minecraft.block.Block; import net.minecraft.entity.EntityAgeable; import net.minecraft.entity.passive.EntityChicken; @@ -22,94 +23,90 @@ import net.minecraft.entity.passive.EntityVillager; import net.minecraft.entity.passive.EntityWolf; import net.minecraft.nbt.NBTTagCompound; -import cpw.mods.fml.common.registry.VillagerRegistry; public class TileCocoon extends TileMod { - private static final String TAG_TIME_PASSED = "timePassed"; - private static final String TAG_EMERALDS_GIVEN = "emeraldsGiven"; - - public static final int TOTAL_TIME = 2400; - public static final int MAX_EMERALDS = 20; + private static final String TAG_TIME_PASSED = "timePassed"; + private static final String TAG_EMERALDS_GIVEN = "emeraldsGiven"; - public int timePassed; - public int emeraldsGiven; + public static final int TOTAL_TIME = 2400; + public static final int MAX_EMERALDS = 20; - @Override - public void updateEntity() { - timePassed++; - if(timePassed >= TOTAL_TIME) - hatch(); - } + public int timePassed; + public int emeraldsGiven; - public void hatch() { - if(!worldObj.isRemote) { - worldObj.playAuxSFX(2001, xCoord, yCoord, zCoord, Block.getIdFromBlock(getBlockType())); - worldObj.setBlockToAir(xCoord, yCoord, zCoord); + @Override + public void updateEntity() { + timePassed++; + if (timePassed >= TOTAL_TIME) hatch(); + } - EntityAgeable entity = null; + public void hatch() { + if (!worldObj.isRemote) { + worldObj.playAuxSFX(2001, xCoord, yCoord, zCoord, Block.getIdFromBlock(getBlockType())); + worldObj.setBlockToAir(xCoord, yCoord, zCoord); - float villagerChance = Math.min(1F, (float) emeraldsGiven / (float) MAX_EMERALDS); + EntityAgeable entity = null; - if(Math.random() < villagerChance) { - EntityVillager villager = new EntityVillager(worldObj); - VillagerRegistry.applyRandomTrade(villager, worldObj.rand); - entity = villager; - } else { - float specialChance = 0.05F; - if(Math.random() < specialChance) { - int entityType = worldObj.rand.nextInt(3); - switch(entityType) { - case 0: - entity = new EntityHorse(worldObj); - break; - case 1: - entity = new EntityWolf(worldObj); - break; - case 2: - entity = new EntityOcelot(worldObj); - break; - } - } else { - int entityType = worldObj.rand.nextInt(4); - switch(entityType) { - case 0: - entity = new EntitySheep(worldObj); - break; - case 1: - if(Math.random() < 0.01) - entity = new EntityMooshroom(worldObj); - else entity = new EntityCow(worldObj); - break; - case 2: - entity = new EntityPig(worldObj); - break; - case 3: - entity = new EntityChicken(worldObj); - break; - } - } - } + float villagerChance = Math.min(1F, (float) emeraldsGiven / (float) MAX_EMERALDS); - if(entity != null) { - entity.setPosition(xCoord + 0.5, yCoord + 0.5, zCoord + 0.5); - entity.setGrowingAge(-24000); - worldObj.spawnEntityInWorld(entity); - entity.spawnExplosionParticle(); - } - } - } + if (Math.random() < villagerChance) { + EntityVillager villager = new EntityVillager(worldObj); + VillagerRegistry.applyRandomTrade(villager, worldObj.rand); + entity = villager; + } else { + float specialChance = 0.05F; + if (Math.random() < specialChance) { + int entityType = worldObj.rand.nextInt(3); + switch (entityType) { + case 0: + entity = new EntityHorse(worldObj); + break; + case 1: + entity = new EntityWolf(worldObj); + break; + case 2: + entity = new EntityOcelot(worldObj); + break; + } + } else { + int entityType = worldObj.rand.nextInt(4); + switch (entityType) { + case 0: + entity = new EntitySheep(worldObj); + break; + case 1: + if (Math.random() < 0.01) entity = new EntityMooshroom(worldObj); + else entity = new EntityCow(worldObj); + break; + case 2: + entity = new EntityPig(worldObj); + break; + case 3: + entity = new EntityChicken(worldObj); + break; + } + } + } - @Override - public void writeCustomNBT(NBTTagCompound cmp) { - cmp.setInteger(TAG_TIME_PASSED, timePassed); - cmp.setInteger(TAG_EMERALDS_GIVEN, emeraldsGiven); - } + if (entity != null) { + entity.setPosition(xCoord + 0.5, yCoord + 0.5, zCoord + 0.5); + entity.setGrowingAge(-24000); + worldObj.spawnEntityInWorld(entity); + entity.spawnExplosionParticle(); + } + } + } - @Override - public void readCustomNBT(NBTTagCompound cmp) { - timePassed = cmp.getInteger(TAG_TIME_PASSED); - emeraldsGiven = cmp.getInteger(TAG_EMERALDS_GIVEN); - } + @Override + public void writeCustomNBT(NBTTagCompound cmp) { + cmp.setInteger(TAG_TIME_PASSED, timePassed); + cmp.setInteger(TAG_EMERALDS_GIVEN, emeraldsGiven); + } + @Override + public void readCustomNBT(NBTTagCompound cmp) { + timePassed = cmp.getInteger(TAG_TIME_PASSED); + emeraldsGiven = cmp.getInteger(TAG_EMERALDS_GIVEN); + } } diff --git a/src/main/java/vazkii/botania/common/block/tile/TileCraftCrate.java b/src/main/java/vazkii/botania/common/block/tile/TileCraftCrate.java index 49def343f4..17253660d8 100644 --- a/src/main/java/vazkii/botania/common/block/tile/TileCraftCrate.java +++ b/src/main/java/vazkii/botania/common/block/tile/TileCraftCrate.java @@ -2,16 +2,15 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jul 26, 2014, 4:50:20 PM (GMT)] */ package vazkii.botania.common.block.tile; import java.util.List; - import net.minecraft.entity.player.EntityPlayer; import net.minecraft.inventory.Container; import net.minecraft.inventory.InventoryCrafting; @@ -26,178 +25,181 @@ public class TileCraftCrate extends TileOpenCrate { - public static final boolean[][] PATTERNS = new boolean[][] { - { - true, false, false, - false, false, false, - false, false, false - }, { - true, true, false, - true, true, false, - false, false, false - }, { - true, false, false, - true, false, false, - false, false, false - }, { - true, true, false, - false, false, false, - false, false, false - }, { - true, false, false, - true, false, false, - true, false, false - }, { - true, true, true, - false, false, false, - false, false, false - }, { - true, true, false, - true, true, false, - true, true, false - }, { - true, true, true, - true, true, true, - false, false, false - }, { - true, true, true, - true, false, true, - true, true, true - } - }; - - private static final String TAG_PATTERN = "pattern"; - - public int pattern = -1; - int signal = 0; - - @Override - public int getSizeInventory() { - return 10; - } - - @Override - public int getInventoryStackLimit() { - return 1; - } - - @Override - public boolean isItemValidForSlot(int i, ItemStack itemstack) { - return i != 9 && !isLocked(i); - } - - public boolean isLocked(int slot) { - return pattern != -1 && !PATTERNS[pattern][slot]; - } - - @Override - public void updateEntity() { - if(!worldObj.isRemote && (craft(true) && canEject() || isFull())) - ejectAll(); - - int newSignal = 0; - for(; newSignal < 9; newSignal++) // dis for loop be derpy - if(!isLocked(newSignal) && getStackInSlot(newSignal) == null) - break; - - if(newSignal != signal) { - signal = newSignal; - worldObj.func_147453_f(xCoord, yCoord, zCoord, worldObj.getBlock(xCoord, yCoord, zCoord)); - } - } - - boolean craft(boolean fullCheck) { - if(fullCheck && !isFull()) - return false; - - InventoryCrafting craft = new InventoryCrafting(new Container() { - @Override - public boolean canInteractWith(EntityPlayer p_75145_1_) { - return false; - } - }, 3, 3); - for(int i = 0; i < 9; i++) { - ItemStack stack = getStackInSlot(i); - - if(stack == null || isLocked(i) || stack.getItem() == ModItems.manaResource && stack.getItemDamage() == 11) - continue; - - craft.setInventorySlotContents(i, stack.copy()); - } - - List recipes = CraftingManager.getInstance().getRecipeList(); - for(IRecipe recipe : recipes) - if(recipe.matches(craft, worldObj)) { - setInventorySlotContents(9, recipe.getCraftingResult(craft)); - - for(int i = 0; i < 9; i++) { - ItemStack stack = getStackInSlot(i); - if(stack == null) - continue; - - ItemStack container = stack.getItem().getContainerItem(stack); - setInventorySlotContents(i, container); - } - return true; - } - - return false; - } - - boolean isFull() { - for(int i = 0; i < 9; i++) - if(!isLocked(i) && getStackInSlot(i) == null) - return false; - - return true; - } - - void ejectAll() { - for(int i = 0; i < getSizeInventory(); ++i) { - ItemStack stack = getStackInSlot(i); - if(stack != null) - eject(stack, false); - setInventorySlotContents(i, null); - markDirty(); - } - } - - @Override - public void writeCustomNBT(NBTTagCompound par1nbtTagCompound) { - super.writeCustomNBT(par1nbtTagCompound); - par1nbtTagCompound.setInteger(TAG_PATTERN, pattern); - } - - @Override - public void readCustomNBT(NBTTagCompound par1nbtTagCompound) { - super.readCustomNBT(par1nbtTagCompound); - pattern = par1nbtTagCompound.getInteger(TAG_PATTERN); - } - - @Override - public boolean onWanded(EntityPlayer player, ItemStack stack) { - craft(false); - ejectAll(); - return true; - } - - @Override - public void markDirty() { - super.markDirty(); - VanillaPacketDispatcher.dispatchTEToNearbyPlayers(this); - } - - @Override - public int getSignal() { - return signal; - } - - @Override - public void onDataPacket(NetworkManager manager, S35PacketUpdateTileEntity packet) { - int lastPattern = pattern; - super.onDataPacket(manager, packet); - if(pattern != lastPattern) - worldObj.markBlockRangeForRenderUpdate(xCoord,yCoord,zCoord,xCoord,yCoord,zCoord); - } - + public static final boolean[][] PATTERNS = new boolean[][] { + { + true, false, false, + false, false, false, + false, false, false + }, + { + true, true, false, + true, true, false, + false, false, false + }, + { + true, false, false, + true, false, false, + false, false, false + }, + { + true, true, false, + false, false, false, + false, false, false + }, + { + true, false, false, + true, false, false, + true, false, false + }, + { + true, true, true, + false, false, false, + false, false, false + }, + { + true, true, false, + true, true, false, + true, true, false + }, + { + true, true, true, + true, true, true, + false, false, false + }, + { + true, true, true, + true, false, true, + true, true, true + } + }; + + private static final String TAG_PATTERN = "pattern"; + + public int pattern = -1; + int signal = 0; + + @Override + public int getSizeInventory() { + return 10; + } + + @Override + public int getInventoryStackLimit() { + return 1; + } + + @Override + public boolean isItemValidForSlot(int i, ItemStack itemstack) { + return i != 9 && !isLocked(i); + } + + public boolean isLocked(int slot) { + return pattern != -1 && !PATTERNS[pattern][slot]; + } + + @Override + public void updateEntity() { + if (!worldObj.isRemote && (craft(true) && canEject() || isFull())) ejectAll(); + + int newSignal = 0; + for (; newSignal < 9; newSignal++) // dis for loop be derpy + if (!isLocked(newSignal) && getStackInSlot(newSignal) == null) break; + + if (newSignal != signal) { + signal = newSignal; + worldObj.func_147453_f(xCoord, yCoord, zCoord, worldObj.getBlock(xCoord, yCoord, zCoord)); + } + } + + boolean craft(boolean fullCheck) { + if (fullCheck && !isFull()) return false; + + InventoryCrafting craft = new InventoryCrafting( + new Container() { + @Override + public boolean canInteractWith(EntityPlayer p_75145_1_) { + return false; + } + }, + 3, + 3); + for (int i = 0; i < 9; i++) { + ItemStack stack = getStackInSlot(i); + + if (stack == null || isLocked(i) || stack.getItem() == ModItems.manaResource && stack.getItemDamage() == 11) + continue; + + craft.setInventorySlotContents(i, stack.copy()); + } + + List recipes = CraftingManager.getInstance().getRecipeList(); + for (IRecipe recipe : recipes) + if (recipe.matches(craft, worldObj)) { + setInventorySlotContents(9, recipe.getCraftingResult(craft)); + + for (int i = 0; i < 9; i++) { + ItemStack stack = getStackInSlot(i); + if (stack == null) continue; + + ItemStack container = stack.getItem().getContainerItem(stack); + setInventorySlotContents(i, container); + } + return true; + } + + return false; + } + + boolean isFull() { + for (int i = 0; i < 9; i++) if (!isLocked(i) && getStackInSlot(i) == null) return false; + + return true; + } + + void ejectAll() { + for (int i = 0; i < getSizeInventory(); ++i) { + ItemStack stack = getStackInSlot(i); + if (stack != null) eject(stack, false); + setInventorySlotContents(i, null); + markDirty(); + } + } + + @Override + public void writeCustomNBT(NBTTagCompound par1nbtTagCompound) { + super.writeCustomNBT(par1nbtTagCompound); + par1nbtTagCompound.setInteger(TAG_PATTERN, pattern); + } + + @Override + public void readCustomNBT(NBTTagCompound par1nbtTagCompound) { + super.readCustomNBT(par1nbtTagCompound); + pattern = par1nbtTagCompound.getInteger(TAG_PATTERN); + } + + @Override + public boolean onWanded(EntityPlayer player, ItemStack stack) { + craft(false); + ejectAll(); + return true; + } + + @Override + public void markDirty() { + super.markDirty(); + VanillaPacketDispatcher.dispatchTEToNearbyPlayers(this); + } + + @Override + public int getSignal() { + return signal; + } + + @Override + public void onDataPacket(NetworkManager manager, S35PacketUpdateTileEntity packet) { + int lastPattern = pattern; + super.onDataPacket(manager, packet); + if (pattern != lastPattern) + worldObj.markBlockRangeForRenderUpdate(xCoord, yCoord, zCoord, xCoord, yCoord, zCoord); + } } diff --git a/src/main/java/vazkii/botania/common/block/tile/TileEnchanter.java b/src/main/java/vazkii/botania/common/block/tile/TileEnchanter.java index e615e22679..533a84034c 100644 --- a/src/main/java/vazkii/botania/common/block/tile/TileEnchanter.java +++ b/src/main/java/vazkii/botania/common/block/tile/TileEnchanter.java @@ -2,17 +2,16 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Mar 15, 2014, 4:57:52 PM (GMT)] */ package vazkii.botania.common.block.tile; import java.util.ArrayList; import java.util.List; - import net.minecraft.client.Minecraft; import net.minecraft.client.gui.ScaledResolution; import net.minecraft.enchantment.Enchantment; @@ -44,389 +43,417 @@ public class TileEnchanter extends TileMod implements ISparkAttachable { - private static final String TAG_STAGE = "stage"; - private static final String TAG_STAGE_TICKS = "stageTicks"; - private static final String TAG_STAGE_3_END_TICKS = "stage3EndTicks"; - private static final String TAG_MANA_REQUIRED = "manaRequired"; - private static final String TAG_MANA = "mana"; - private static final String TAG_ITEM = "item"; - private static final String TAG_ENCHANTS = "enchantsToApply"; - - public int stage = 0; - public int stageTicks = 0; - - public int stage3EndTicks = 0; - - int manaRequired = -1; - int mana = 0; - - public ItemStack itemToEnchant = null; - List enchants = new ArrayList(); - - private static final int[][] OBSIDIAN_LOCATIONS = new int[][] { - { 0, -1, 0 }, - { 0, -1, 1 }, { 0, -1, -1 }, { 1, -1, 0 }, { -1, -1, 0 }, - { 0, -1, 2 }, { -1, -1, 2 }, { 1, -1, 2 }, - { 0, -1, -2 }, { -1, -1, -2 }, { 1, -1, -2 }, - { 2, -1, 0 }, { 2, -1, 1 }, { 2, -1, -1 }, - { -2, -1, 0 }, { -2, -1, 1 }, { -2, -1, -1 } - }; - - private static final int[][][] PYLON_LOCATIONS = new int[][][] { - { { -5, 1, 0 }, { 5, 1, 0 }, { -4, 1, 3 }, { 4, 1, 3 }, { -4, 1, -3 }, { 4, 1, -3 } }, - { { 0, 1, -5 }, { 0, 1, 5 }, { 3, 1, -4 }, { 3, 1, 4 }, { -3, 1, -4 }, { -3, 1, 4 } } - }; - - private static final int[][] FLOWER_LOCATIONS = new int[][] { - { -1, 0, -1 }, { 1, 0, -1 }, { -1, 0, 1 }, { 1, 0, 1 } - }; - - public static MultiblockSet makeMultiblockSet() { - Multiblock mb = new Multiblock(); - - for(int[] o : OBSIDIAN_LOCATIONS) - mb.addComponent(o[0], o[1] + 1, o[2], Blocks.obsidian, 0); - for(int[] p : PYLON_LOCATIONS[0]) { - mb.addComponent(p[0], p[1] + 1, p[2], ModBlocks.pylon, 0); - mb.addComponent(new FlowerComponent(new ChunkCoordinates(p[0], p[1], p[2]), ModBlocks.flower)); - } - for(int[] f : FLOWER_LOCATIONS) - mb.addComponent(new FlowerComponent(new ChunkCoordinates(f[0], f[1] + 1, f[2]), ModBlocks.flower)); - - mb.addComponent(0, 1, 0, Blocks.lapis_block, 0); - - return mb.makeSet(); - } - - public void onWanded(EntityPlayer player, ItemStack wand) { - if(stage != 0 || itemToEnchant == null || !itemToEnchant.isItemEnchantable()) - return; - - List items = worldObj.getEntitiesWithinAABB(EntityItem.class, AxisAlignedBB.getBoundingBox(xCoord - 2, yCoord, zCoord - 2, xCoord + 3, yCoord + 1, zCoord + 3)); - int count = items.size(); - - if(count > 0 && !worldObj.isRemote) { - for(EntityItem entity : items) { - ItemStack item = entity.getEntityItem(); - if(item.getItem() == Items.enchanted_book) { - NBTTagList enchants = Items.enchanted_book.func_92110_g(item); - if(enchants != null && enchants.tagCount() > 0) { - NBTTagCompound enchant = enchants.getCompoundTagAt(0); - short id = enchant.getShort("id"); - if(isEnchantmentValid(id)) { - advanceStage(); - return; - } - } - } - } - } - } - - @Override - public void updateEntity() { - if(getBlockMetadata() < PYLON_LOCATIONS.length) - for(int[] pylon : PYLON_LOCATIONS[getBlockMetadata()]) { - TileEntity tile = worldObj.getTileEntity(xCoord + pylon[0], yCoord + pylon[1], zCoord + pylon[2]); - if(tile != null && tile instanceof TilePylon) - ((TilePylon) tile).activated = false; - } - - if(!canEnchanterExist(worldObj, xCoord, yCoord, zCoord, getBlockMetadata())) { - - worldObj.setBlock(xCoord, yCoord, zCoord, Blocks.lapis_block, 0, 1 | 2); - for(int i = 0; i < 50; i++) { - float red = (float) Math.random(); - float green = (float) Math.random(); - float blue = (float) Math.random(); - Botania.proxy.wispFX(worldObj, xCoord + 0.5, yCoord + 0.5, zCoord + 0.5, red, green, blue, (float) Math.random() * 0.15F + 0.15F, (float) (Math.random() - 0.5F) * 0.25F, (float) (Math.random() - 0.5F) * 0.25F, (float) (Math.random() - 0.5F) * 0.25F); - } - worldObj.playSoundEffect(xCoord, yCoord, zCoord, "botania:enchanterBlock", 0.5F, 10F); - } - - switch(stage) { - case 1 : { // Get books - if(stageTicks % 20 == 0) { - List items = worldObj.getEntitiesWithinAABB(EntityItem.class, AxisAlignedBB.getBoundingBox(xCoord - 2, yCoord, zCoord - 2, xCoord + 3, yCoord + 1, zCoord + 3)); - int count = items.size(); - boolean addedEnch = false; - - if(count > 0 && !worldObj.isRemote) { - for(EntityItem entity : items) { - ItemStack item = entity.getEntityItem(); - if(item.getItem() == Items.enchanted_book) { - NBTTagList enchants = Items.enchanted_book.func_92110_g(item); - if(enchants != null && enchants.tagCount() > 0) { - NBTTagCompound enchant = enchants.getCompoundTagAt(0); - short enchantId = enchant.getShort("id"); - short enchantLvl = enchant.getShort("lvl"); - if(!hasEnchantAlready(enchantId) && isEnchantmentValid(enchantId)) { - this.enchants.add(new EnchantmentData(enchantId, enchantLvl)); - worldObj.playSoundEffect(xCoord, yCoord, zCoord, "botania:ding", 1F, 1F); - addedEnch = true; - break; - } - } - } - } - } - - if(!addedEnch) { - if(enchants.isEmpty()) - stage = 0; - else advanceStage(); - } - } - break; - } - case 2 : { // Get Mana - for(int[] pylon : PYLON_LOCATIONS[getBlockMetadata()]) { - TilePylon pylonTile = (TilePylon) worldObj.getTileEntity(xCoord + pylon[0], yCoord + pylon[1], zCoord + pylon[2]); - if(pylonTile != null) { - pylonTile.activated = true; - pylonTile.centerX = xCoord; - pylonTile.centerY = yCoord; - pylonTile.centerZ = zCoord; - } - } - - if(manaRequired == -1) { - manaRequired = 0; - for(EnchantmentData data : enchants) { - Enchantment ench = Enchantment.enchantmentsList[data.enchant]; - manaRequired += (int) (5000F * ((15 - Math.min(15, ench.getWeight())) * 1.05F) * ((3F + data.level * data.level) * 0.25F) * (0.9F + enchants.size() * 0.05F)); - } - } else if(mana >= manaRequired) { - manaRequired = 0; - for(int[] pylon : PYLON_LOCATIONS[getBlockMetadata()]) - ((TilePylon) worldObj.getTileEntity(xCoord + pylon[0], yCoord + pylon[1], zCoord + pylon[2])).activated = false; - - advanceStage(); - } else { - ISparkEntity spark = getAttachedSpark(); - if(spark != null) { - List sparkEntities = SparkHelper.getSparksAround(worldObj, xCoord + 0.5, yCoord + 0.5, zCoord + 0.5); - for(ISparkEntity otherSpark : sparkEntities) { - if(spark == otherSpark) - continue; - - if(otherSpark.getAttachedTile() != null && otherSpark.getAttachedTile() instanceof IManaPool) - otherSpark.registerTransfer(spark); - } - } - } - - break; - } - case 3 : { // Enchant - if(stageTicks >= 100) { - for(EnchantmentData data : enchants) - if(EnchantmentHelper.getEnchantmentLevel(data.enchant, itemToEnchant) == 0) - itemToEnchant.addEnchantment(Enchantment.enchantmentsList[data.enchant], data.level); - - enchants.clear(); - manaRequired = -1; - mana = 0; - - craftingFanciness(); - advanceStage(); - } - break; - } - case 4 : { // Reset - if(stageTicks >= 20) - advanceStage(); - - break; - } - } - - if(stage != 0) - stageTicks++; - } - - public void advanceStage() { - stage++; - - if(stage == 4) - stage3EndTicks = stageTicks; - else if(stage == 5) { - stage = 0; - stage3EndTicks = 0; - } - - stageTicks = 0; - sync(); - } - - public void craftingFanciness() { - worldObj.playSoundEffect(xCoord, yCoord, zCoord, "botania:enchanterEnchant", 1F, 1F); - for(int i = 0; i < 25; i++) { - float red = (float) Math.random(); - float green = (float) Math.random(); - float blue = (float) Math.random(); - Botania.proxy.sparkleFX(worldObj, xCoord + 0.5 + Math.random() * 0.4 - 0.2, yCoord + 1, zCoord + 0.5 + Math.random() * 0.4 - 0.2, red, green, blue, (float) Math.random(), 10); - } - } - - @Override - public AxisAlignedBB getRenderBoundingBox() { - return INFINITE_EXTENT_AABB; - } - - @Override - public int getCurrentMana() { - return mana; - } - - @Override - public boolean isFull() { - return mana >= manaRequired; - } - - @Override - public void recieveMana(int mana) { - this.mana = Math.min(manaRequired, this.mana + mana); - } - - @Override - public boolean canRecieveManaFromBursts() { - return manaRequired > 0; - } - - public void sync() { - VanillaPacketDispatcher.dispatchTEToNearbyPlayers(worldObj, xCoord, yCoord, zCoord); - } - - @Override - public void writeCustomNBT(NBTTagCompound cmp) { - cmp.setInteger(TAG_MANA, mana); - cmp.setInteger(TAG_MANA_REQUIRED, manaRequired); - cmp.setInteger(TAG_STAGE, stage); - cmp.setInteger(TAG_STAGE_TICKS, stageTicks); - cmp.setInteger(TAG_STAGE_3_END_TICKS, stage3EndTicks); - - NBTTagCompound itemCmp = new NBTTagCompound(); - if(itemToEnchant != null) - itemToEnchant.writeToNBT(itemCmp); - cmp.setTag(TAG_ITEM, itemCmp); - - String enchStr = ""; - for(EnchantmentData data : enchants) - enchStr = enchStr + data.enchant + ":" + data.level + ","; - cmp.setString(TAG_ENCHANTS, enchStr.isEmpty() ? enchStr : enchStr.substring(0, enchStr.length() - 1)); - } - - @Override - public void readCustomNBT(NBTTagCompound cmp) { - mana = cmp.getInteger(TAG_MANA); - manaRequired = cmp.getInteger(TAG_MANA_REQUIRED); - stage = cmp.getInteger(TAG_STAGE); - stageTicks = cmp.getInteger(TAG_STAGE_TICKS); - stage3EndTicks = cmp.getInteger(TAG_STAGE_3_END_TICKS); - - NBTTagCompound itemCmp = cmp.getCompoundTag(TAG_ITEM); - itemToEnchant = ItemStack.loadItemStackFromNBT(itemCmp); - - enchants.clear(); - String enchStr = cmp.getString(TAG_ENCHANTS); - if(!enchStr.isEmpty()) { - String[] enchTokens = enchStr.split(","); - for(String token : enchTokens) { - String[] entryTokens = token.split(":"); - int id = Integer.parseInt(entryTokens[0]); - int lvl = Integer.parseInt(entryTokens[1]); - enchants.add(new EnchantmentData(id, lvl)); - } - } - } - - private boolean hasEnchantAlready(int enchant) { - for(EnchantmentData data : enchants) - if(data.enchant == enchant) - return true; - - return false; - } - - public boolean isEnchantmentValid(short id) { - Enchantment ench = Enchantment.enchantmentsList[id]; - if(!ench.canApply(itemToEnchant) || !ench.type.canEnchantItem(itemToEnchant.getItem())) - return false; - - for(EnchantmentData data : enchants) { - Enchantment otherEnch = Enchantment.enchantmentsList[data.enchant]; - if(!otherEnch.canApplyTogether(ench) || !ench.canApplyTogether(otherEnch)) - return false; - } - - return true; - } - - public static boolean canEnchanterExist(World world, int x, int y, int z, int meta) { - for(int[] obsidian : OBSIDIAN_LOCATIONS) - if(world.getBlock(obsidian[0] + x, obsidian[1] + y, obsidian[2] + z) != Blocks.obsidian) - return false; - - for(int[] pylon : PYLON_LOCATIONS[meta]) - if(world.getBlock(pylon[0] + x, pylon[1] + y, pylon[2] + z) != ModBlocks.pylon || !BotaniaAPI.internalHandler.isBotaniaFlower(world, pylon[0] + x, pylon[1] + y - 1, pylon[2] + z)) - return false; - - for(int[] flower : FLOWER_LOCATIONS) - if(!BotaniaAPI.internalHandler.isBotaniaFlower(world, flower[0] + x, flower[1] + y, flower[2] + z)) - return false; - - return true; - } - - @Override - public boolean canAttachSpark(ItemStack stack) { - return true; - } - - @Override - public void attachSpark(ISparkEntity entity) { - // NO-OP - } - - @Override - public ISparkEntity getAttachedSpark() { - List sparks = worldObj.getEntitiesWithinAABB(ISparkEntity.class, AxisAlignedBB.getBoundingBox(xCoord, yCoord + 1, zCoord, xCoord + 1, yCoord + 2, zCoord + 1)); - if(sparks.size() == 1) { - Entity e = (Entity) sparks.get(0); - return (ISparkEntity) e; - } - - return null; - } - - @Override - public boolean areIncomingTranfersDone() { - return stage == 3; - } - - @Override - public int getAvailableSpaceForMana() { - return Math.max(0, manaRequired - getCurrentMana()); - } - - public void renderHUD(Minecraft mc, ScaledResolution res) { - if(manaRequired > 0 && itemToEnchant != null) { - int x = res.getScaledWidth() / 2 + 20; - int y = res.getScaledHeight() / 2 - 8; - - RenderHelper.renderProgressPie(x, y, (float) mana / (float) manaRequired, itemToEnchant); - } - } - - private static class EnchantmentData { - - public int enchant, level; - - public EnchantmentData(int enchant, int level) { - this.enchant = enchant; - this.level = level; - } - } - + private static final String TAG_STAGE = "stage"; + private static final String TAG_STAGE_TICKS = "stageTicks"; + private static final String TAG_STAGE_3_END_TICKS = "stage3EndTicks"; + private static final String TAG_MANA_REQUIRED = "manaRequired"; + private static final String TAG_MANA = "mana"; + private static final String TAG_ITEM = "item"; + private static final String TAG_ENCHANTS = "enchantsToApply"; + + public int stage = 0; + public int stageTicks = 0; + + public int stage3EndTicks = 0; + + int manaRequired = -1; + int mana = 0; + + public ItemStack itemToEnchant = null; + List enchants = new ArrayList(); + + private static final int[][] OBSIDIAN_LOCATIONS = new int[][] { + {0, -1, 0}, + {0, -1, 1}, + {0, -1, -1}, + {1, -1, 0}, + {-1, -1, 0}, + {0, -1, 2}, + {-1, -1, 2}, + {1, -1, 2}, + {0, -1, -2}, + {-1, -1, -2}, + {1, -1, -2}, + {2, -1, 0}, + {2, -1, 1}, + {2, -1, -1}, + {-2, -1, 0}, + {-2, -1, 1}, + {-2, -1, -1} + }; + + private static final int[][][] PYLON_LOCATIONS = new int[][][] { + {{-5, 1, 0}, {5, 1, 0}, {-4, 1, 3}, {4, 1, 3}, {-4, 1, -3}, {4, 1, -3}}, + {{0, 1, -5}, {0, 1, 5}, {3, 1, -4}, {3, 1, 4}, {-3, 1, -4}, {-3, 1, 4}} + }; + + private static final int[][] FLOWER_LOCATIONS = new int[][] {{-1, 0, -1}, {1, 0, -1}, {-1, 0, 1}, {1, 0, 1}}; + + public static MultiblockSet makeMultiblockSet() { + Multiblock mb = new Multiblock(); + + for (int[] o : OBSIDIAN_LOCATIONS) mb.addComponent(o[0], o[1] + 1, o[2], Blocks.obsidian, 0); + for (int[] p : PYLON_LOCATIONS[0]) { + mb.addComponent(p[0], p[1] + 1, p[2], ModBlocks.pylon, 0); + mb.addComponent(new FlowerComponent(new ChunkCoordinates(p[0], p[1], p[2]), ModBlocks.flower)); + } + for (int[] f : FLOWER_LOCATIONS) + mb.addComponent(new FlowerComponent(new ChunkCoordinates(f[0], f[1] + 1, f[2]), ModBlocks.flower)); + + mb.addComponent(0, 1, 0, Blocks.lapis_block, 0); + + return mb.makeSet(); + } + + public void onWanded(EntityPlayer player, ItemStack wand) { + if (stage != 0 || itemToEnchant == null || !itemToEnchant.isItemEnchantable()) return; + + List items = worldObj.getEntitiesWithinAABB( + EntityItem.class, + AxisAlignedBB.getBoundingBox(xCoord - 2, yCoord, zCoord - 2, xCoord + 3, yCoord + 1, zCoord + 3)); + int count = items.size(); + + if (count > 0 && !worldObj.isRemote) { + for (EntityItem entity : items) { + ItemStack item = entity.getEntityItem(); + if (item.getItem() == Items.enchanted_book) { + NBTTagList enchants = Items.enchanted_book.func_92110_g(item); + if (enchants != null && enchants.tagCount() > 0) { + NBTTagCompound enchant = enchants.getCompoundTagAt(0); + short id = enchant.getShort("id"); + if (isEnchantmentValid(id)) { + advanceStage(); + return; + } + } + } + } + } + } + + @Override + public void updateEntity() { + if (getBlockMetadata() < PYLON_LOCATIONS.length) + for (int[] pylon : PYLON_LOCATIONS[getBlockMetadata()]) { + TileEntity tile = worldObj.getTileEntity(xCoord + pylon[0], yCoord + pylon[1], zCoord + pylon[2]); + if (tile != null && tile instanceof TilePylon) ((TilePylon) tile).activated = false; + } + + if (!canEnchanterExist(worldObj, xCoord, yCoord, zCoord, getBlockMetadata())) { + + worldObj.setBlock(xCoord, yCoord, zCoord, Blocks.lapis_block, 0, 1 | 2); + for (int i = 0; i < 50; i++) { + float red = (float) Math.random(); + float green = (float) Math.random(); + float blue = (float) Math.random(); + Botania.proxy.wispFX( + worldObj, + xCoord + 0.5, + yCoord + 0.5, + zCoord + 0.5, + red, + green, + blue, + (float) Math.random() * 0.15F + 0.15F, + (float) (Math.random() - 0.5F) * 0.25F, + (float) (Math.random() - 0.5F) * 0.25F, + (float) (Math.random() - 0.5F) * 0.25F); + } + worldObj.playSoundEffect(xCoord, yCoord, zCoord, "botania:enchanterBlock", 0.5F, 10F); + } + + switch (stage) { + case 1: { // Get books + if (stageTicks % 20 == 0) { + List items = worldObj.getEntitiesWithinAABB( + EntityItem.class, + AxisAlignedBB.getBoundingBox( + xCoord - 2, yCoord, zCoord - 2, xCoord + 3, yCoord + 1, zCoord + 3)); + int count = items.size(); + boolean addedEnch = false; + + if (count > 0 && !worldObj.isRemote) { + for (EntityItem entity : items) { + ItemStack item = entity.getEntityItem(); + if (item.getItem() == Items.enchanted_book) { + NBTTagList enchants = Items.enchanted_book.func_92110_g(item); + if (enchants != null && enchants.tagCount() > 0) { + NBTTagCompound enchant = enchants.getCompoundTagAt(0); + short enchantId = enchant.getShort("id"); + short enchantLvl = enchant.getShort("lvl"); + if (!hasEnchantAlready(enchantId) && isEnchantmentValid(enchantId)) { + this.enchants.add(new EnchantmentData(enchantId, enchantLvl)); + worldObj.playSoundEffect(xCoord, yCoord, zCoord, "botania:ding", 1F, 1F); + addedEnch = true; + break; + } + } + } + } + } + + if (!addedEnch) { + if (enchants.isEmpty()) stage = 0; + else advanceStage(); + } + } + break; + } + case 2: { // Get Mana + for (int[] pylon : PYLON_LOCATIONS[getBlockMetadata()]) { + TilePylon pylonTile = + (TilePylon) worldObj.getTileEntity(xCoord + pylon[0], yCoord + pylon[1], zCoord + pylon[2]); + if (pylonTile != null) { + pylonTile.activated = true; + pylonTile.centerX = xCoord; + pylonTile.centerY = yCoord; + pylonTile.centerZ = zCoord; + } + } + + if (manaRequired == -1) { + manaRequired = 0; + for (EnchantmentData data : enchants) { + Enchantment ench = Enchantment.enchantmentsList[data.enchant]; + manaRequired += (int) (5000F + * ((15 - Math.min(15, ench.getWeight())) * 1.05F) + * ((3F + data.level * data.level) * 0.25F) + * (0.9F + enchants.size() * 0.05F)); + } + } else if (mana >= manaRequired) { + manaRequired = 0; + for (int[] pylon : PYLON_LOCATIONS[getBlockMetadata()]) + ((TilePylon) worldObj.getTileEntity(xCoord + pylon[0], yCoord + pylon[1], zCoord + pylon[2])) + .activated = false; + + advanceStage(); + } else { + ISparkEntity spark = getAttachedSpark(); + if (spark != null) { + List sparkEntities = + SparkHelper.getSparksAround(worldObj, xCoord + 0.5, yCoord + 0.5, zCoord + 0.5); + for (ISparkEntity otherSpark : sparkEntities) { + if (spark == otherSpark) continue; + + if (otherSpark.getAttachedTile() != null + && otherSpark.getAttachedTile() instanceof IManaPool) + otherSpark.registerTransfer(spark); + } + } + } + + break; + } + case 3: { // Enchant + if (stageTicks >= 100) { + for (EnchantmentData data : enchants) + if (EnchantmentHelper.getEnchantmentLevel(data.enchant, itemToEnchant) == 0) + itemToEnchant.addEnchantment(Enchantment.enchantmentsList[data.enchant], data.level); + + enchants.clear(); + manaRequired = -1; + mana = 0; + + craftingFanciness(); + advanceStage(); + } + break; + } + case 4: { // Reset + if (stageTicks >= 20) advanceStage(); + + break; + } + } + + if (stage != 0) stageTicks++; + } + + public void advanceStage() { + stage++; + + if (stage == 4) stage3EndTicks = stageTicks; + else if (stage == 5) { + stage = 0; + stage3EndTicks = 0; + } + + stageTicks = 0; + sync(); + } + + public void craftingFanciness() { + worldObj.playSoundEffect(xCoord, yCoord, zCoord, "botania:enchanterEnchant", 1F, 1F); + for (int i = 0; i < 25; i++) { + float red = (float) Math.random(); + float green = (float) Math.random(); + float blue = (float) Math.random(); + Botania.proxy.sparkleFX( + worldObj, + xCoord + 0.5 + Math.random() * 0.4 - 0.2, + yCoord + 1, + zCoord + 0.5 + Math.random() * 0.4 - 0.2, + red, + green, + blue, + (float) Math.random(), + 10); + } + } + + @Override + public AxisAlignedBB getRenderBoundingBox() { + return INFINITE_EXTENT_AABB; + } + + @Override + public int getCurrentMana() { + return mana; + } + + @Override + public boolean isFull() { + return mana >= manaRequired; + } + + @Override + public void recieveMana(int mana) { + this.mana = Math.min(manaRequired, this.mana + mana); + } + + @Override + public boolean canRecieveManaFromBursts() { + return manaRequired > 0; + } + + public void sync() { + VanillaPacketDispatcher.dispatchTEToNearbyPlayers(worldObj, xCoord, yCoord, zCoord); + } + + @Override + public void writeCustomNBT(NBTTagCompound cmp) { + cmp.setInteger(TAG_MANA, mana); + cmp.setInteger(TAG_MANA_REQUIRED, manaRequired); + cmp.setInteger(TAG_STAGE, stage); + cmp.setInteger(TAG_STAGE_TICKS, stageTicks); + cmp.setInteger(TAG_STAGE_3_END_TICKS, stage3EndTicks); + + NBTTagCompound itemCmp = new NBTTagCompound(); + if (itemToEnchant != null) itemToEnchant.writeToNBT(itemCmp); + cmp.setTag(TAG_ITEM, itemCmp); + + String enchStr = ""; + for (EnchantmentData data : enchants) enchStr = enchStr + data.enchant + ":" + data.level + ","; + cmp.setString(TAG_ENCHANTS, enchStr.isEmpty() ? enchStr : enchStr.substring(0, enchStr.length() - 1)); + } + + @Override + public void readCustomNBT(NBTTagCompound cmp) { + mana = cmp.getInteger(TAG_MANA); + manaRequired = cmp.getInteger(TAG_MANA_REQUIRED); + stage = cmp.getInteger(TAG_STAGE); + stageTicks = cmp.getInteger(TAG_STAGE_TICKS); + stage3EndTicks = cmp.getInteger(TAG_STAGE_3_END_TICKS); + + NBTTagCompound itemCmp = cmp.getCompoundTag(TAG_ITEM); + itemToEnchant = ItemStack.loadItemStackFromNBT(itemCmp); + + enchants.clear(); + String enchStr = cmp.getString(TAG_ENCHANTS); + if (!enchStr.isEmpty()) { + String[] enchTokens = enchStr.split(","); + for (String token : enchTokens) { + String[] entryTokens = token.split(":"); + int id = Integer.parseInt(entryTokens[0]); + int lvl = Integer.parseInt(entryTokens[1]); + enchants.add(new EnchantmentData(id, lvl)); + } + } + } + + private boolean hasEnchantAlready(int enchant) { + for (EnchantmentData data : enchants) if (data.enchant == enchant) return true; + + return false; + } + + public boolean isEnchantmentValid(short id) { + Enchantment ench = Enchantment.enchantmentsList[id]; + if (!ench.canApply(itemToEnchant) || !ench.type.canEnchantItem(itemToEnchant.getItem())) return false; + + for (EnchantmentData data : enchants) { + Enchantment otherEnch = Enchantment.enchantmentsList[data.enchant]; + if (!otherEnch.canApplyTogether(ench) || !ench.canApplyTogether(otherEnch)) return false; + } + + return true; + } + + public static boolean canEnchanterExist(World world, int x, int y, int z, int meta) { + for (int[] obsidian : OBSIDIAN_LOCATIONS) + if (world.getBlock(obsidian[0] + x, obsidian[1] + y, obsidian[2] + z) != Blocks.obsidian) return false; + + for (int[] pylon : PYLON_LOCATIONS[meta]) + if (world.getBlock(pylon[0] + x, pylon[1] + y, pylon[2] + z) != ModBlocks.pylon + || !BotaniaAPI.internalHandler.isBotaniaFlower(world, pylon[0] + x, pylon[1] + y - 1, pylon[2] + z)) + return false; + + for (int[] flower : FLOWER_LOCATIONS) + if (!BotaniaAPI.internalHandler.isBotaniaFlower(world, flower[0] + x, flower[1] + y, flower[2] + z)) + return false; + + return true; + } + + @Override + public boolean canAttachSpark(ItemStack stack) { + return true; + } + + @Override + public void attachSpark(ISparkEntity entity) { + // NO-OP + } + + @Override + public ISparkEntity getAttachedSpark() { + List sparks = worldObj.getEntitiesWithinAABB( + ISparkEntity.class, + AxisAlignedBB.getBoundingBox(xCoord, yCoord + 1, zCoord, xCoord + 1, yCoord + 2, zCoord + 1)); + if (sparks.size() == 1) { + Entity e = (Entity) sparks.get(0); + return (ISparkEntity) e; + } + + return null; + } + + @Override + public boolean areIncomingTranfersDone() { + return stage == 3; + } + + @Override + public int getAvailableSpaceForMana() { + return Math.max(0, manaRequired - getCurrentMana()); + } + + public void renderHUD(Minecraft mc, ScaledResolution res) { + if (manaRequired > 0 && itemToEnchant != null) { + int x = res.getScaledWidth() / 2 + 20; + int y = res.getScaledHeight() / 2 - 8; + + RenderHelper.renderProgressPie(x, y, (float) mana / (float) manaRequired, itemToEnchant); + } + } + + private static class EnchantmentData { + + public int enchant, level; + + public EnchantmentData(int enchant, int level) { + this.enchant = enchant; + this.level = level; + } + } } diff --git a/src/main/java/vazkii/botania/common/block/tile/TileEnderEye.java b/src/main/java/vazkii/botania/common/block/tile/TileEnderEye.java index 99be1db8b3..17c303b0dc 100644 --- a/src/main/java/vazkii/botania/common/block/tile/TileEnderEye.java +++ b/src/main/java/vazkii/botania/common/block/tile/TileEnderEye.java @@ -2,16 +2,15 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jul 30, 2014, 1:10:34 PM (GMT)] */ package vazkii.botania.common.block.tile; import java.util.List; - import net.minecraft.entity.player.EntityPlayer; import net.minecraft.init.Blocks; import net.minecraft.item.Item; @@ -22,36 +21,42 @@ public class TileEnderEye extends TileMod { - @Override - public void updateEntity() { - int meta = getBlockMetadata(); - int range = 80; - List players = worldObj.getEntitiesWithinAABB(EntityPlayer.class, AxisAlignedBB.getBoundingBox(xCoord - range, yCoord - range, zCoord - range, xCoord + range, yCoord + range, zCoord + range)); - - boolean looking = false; - for(EntityPlayer player : players) { - ItemStack helm = player.getCurrentArmor(3); - if(helm != null && helm.getItem() == Item.getItemFromBlock(Blocks.pumpkin)) - continue; - - MovingObjectPosition pos = ToolCommons.raytraceFromEntity(worldObj, player, true, 64); - if(pos != null && pos.blockX == xCoord && pos.blockY == yCoord && pos.blockZ == zCoord) { - looking = true; - break; - } - } - - int newMeta = looking ? 15 : 0; - if(newMeta != meta && !worldObj.isRemote) - worldObj.setBlockMetadataWithNotify(xCoord, yCoord, zCoord, newMeta, 1 | 2); - - if(looking) { - double x = xCoord - 0.1 + Math.random() * 1.2; - double y = yCoord - 0.1 + Math.random() * 1.2; - double z = zCoord - 0.1 + Math.random() * 1.2; - - worldObj.spawnParticle("reddust", x, y, z, 1, 0, 0); - } - } - + @Override + public void updateEntity() { + int meta = getBlockMetadata(); + int range = 80; + List players = worldObj.getEntitiesWithinAABB( + EntityPlayer.class, + AxisAlignedBB.getBoundingBox( + xCoord - range, + yCoord - range, + zCoord - range, + xCoord + range, + yCoord + range, + zCoord + range)); + + boolean looking = false; + for (EntityPlayer player : players) { + ItemStack helm = player.getCurrentArmor(3); + if (helm != null && helm.getItem() == Item.getItemFromBlock(Blocks.pumpkin)) continue; + + MovingObjectPosition pos = ToolCommons.raytraceFromEntity(worldObj, player, true, 64); + if (pos != null && pos.blockX == xCoord && pos.blockY == yCoord && pos.blockZ == zCoord) { + looking = true; + break; + } + } + + int newMeta = looking ? 15 : 0; + if (newMeta != meta && !worldObj.isRemote) + worldObj.setBlockMetadataWithNotify(xCoord, yCoord, zCoord, newMeta, 1 | 2); + + if (looking) { + double x = xCoord - 0.1 + Math.random() * 1.2; + double y = yCoord - 0.1 + Math.random() * 1.2; + double z = zCoord - 0.1 + Math.random() * 1.2; + + worldObj.spawnParticle("reddust", x, y, z, 1, 0, 0); + } + } } diff --git a/src/main/java/vazkii/botania/common/block/tile/TileFakeAir.java b/src/main/java/vazkii/botania/common/block/tile/TileFakeAir.java index cc82c96195..e6fff737d9 100644 --- a/src/main/java/vazkii/botania/common/block/tile/TileFakeAir.java +++ b/src/main/java/vazkii/botania/common/block/tile/TileFakeAir.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Apr 10, 2015, 10:24:48 PM (GMT)] */ package vazkii.botania.common.block.tile; @@ -16,41 +16,40 @@ public class TileFakeAir extends TileMod { - private static final String TAG_FLOWER_X = "flowerX"; - private static final String TAG_FLOWER_Y = "flowerY"; - private static final String TAG_FLOWER_Z = "flowerZ"; - - int flowerX, flowerY, flowerZ; - - @Override - public boolean canUpdate() { - return false; - } - - public void setFlower(TileEntity tile) { - flowerX = tile.xCoord; - flowerY = tile.yCoord; - flowerZ = tile.zCoord; - } - - public boolean canStay() { - return SubTileBubbell.isValidBubbell(worldObj, flowerX, flowerY, flowerZ); - } - - @Override - public void writeToNBT(NBTTagCompound par1nbtTagCompound) { - super.writeToNBT(par1nbtTagCompound); - par1nbtTagCompound.setInteger(TAG_FLOWER_X, flowerX); - par1nbtTagCompound.setInteger(TAG_FLOWER_Y, flowerY); - par1nbtTagCompound.setInteger(TAG_FLOWER_Z, flowerZ); - } - - @Override - public void readFromNBT(NBTTagCompound par1nbtTagCompound) { - super.readFromNBT(par1nbtTagCompound); - flowerX = par1nbtTagCompound.getInteger(TAG_FLOWER_X); - flowerY = par1nbtTagCompound.getInteger(TAG_FLOWER_Y); - flowerZ = par1nbtTagCompound.getInteger(TAG_FLOWER_Z); - } - + private static final String TAG_FLOWER_X = "flowerX"; + private static final String TAG_FLOWER_Y = "flowerY"; + private static final String TAG_FLOWER_Z = "flowerZ"; + + int flowerX, flowerY, flowerZ; + + @Override + public boolean canUpdate() { + return false; + } + + public void setFlower(TileEntity tile) { + flowerX = tile.xCoord; + flowerY = tile.yCoord; + flowerZ = tile.zCoord; + } + + public boolean canStay() { + return SubTileBubbell.isValidBubbell(worldObj, flowerX, flowerY, flowerZ); + } + + @Override + public void writeToNBT(NBTTagCompound par1nbtTagCompound) { + super.writeToNBT(par1nbtTagCompound); + par1nbtTagCompound.setInteger(TAG_FLOWER_X, flowerX); + par1nbtTagCompound.setInteger(TAG_FLOWER_Y, flowerY); + par1nbtTagCompound.setInteger(TAG_FLOWER_Z, flowerZ); + } + + @Override + public void readFromNBT(NBTTagCompound par1nbtTagCompound) { + super.readFromNBT(par1nbtTagCompound); + flowerX = par1nbtTagCompound.getInteger(TAG_FLOWER_X); + flowerY = par1nbtTagCompound.getInteger(TAG_FLOWER_Y); + flowerZ = par1nbtTagCompound.getInteger(TAG_FLOWER_Z); + } } diff --git a/src/main/java/vazkii/botania/common/block/tile/TileFloatingFlower.java b/src/main/java/vazkii/botania/common/block/tile/TileFloatingFlower.java index 03f4c4b696..1299b26de5 100644 --- a/src/main/java/vazkii/botania/common/block/tile/TileFloatingFlower.java +++ b/src/main/java/vazkii/botania/common/block/tile/TileFloatingFlower.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jul 8, 2014, 10:17:28 PM (GMT)] */ package vazkii.botania.common.block.tile; @@ -17,44 +17,43 @@ public class TileFloatingFlower extends TileMod implements IFloatingFlower { - public static final String TAG_ISLAND_TYPE = "islandType"; - public static ItemStack forcedStack = null; - IslandType type = IslandType.GRASS; - - @Override - public ItemStack getDisplayStack() { - if(forcedStack != null) { - ItemStack retStack = forcedStack; - forcedStack = null; - return retStack; - } - - return new ItemStack(ModBlocks.shinyFlower, 1, getBlockMetadata()); - } - - @Override - public boolean canUpdate() { - return false; - } - - @Override - public IslandType getIslandType() { - return type; - } - - @Override - public void setIslandType(IslandType type) { - this.type = type; - } - - @Override - public void writeCustomNBT(NBTTagCompound cmp) { - cmp.setString(TAG_ISLAND_TYPE, type.toString()); - } - - @Override - public void readCustomNBT(NBTTagCompound cmp) { - type = IslandType.ofType(cmp.getString(TAG_ISLAND_TYPE)); - } - + public static final String TAG_ISLAND_TYPE = "islandType"; + public static ItemStack forcedStack = null; + IslandType type = IslandType.GRASS; + + @Override + public ItemStack getDisplayStack() { + if (forcedStack != null) { + ItemStack retStack = forcedStack; + forcedStack = null; + return retStack; + } + + return new ItemStack(ModBlocks.shinyFlower, 1, getBlockMetadata()); + } + + @Override + public boolean canUpdate() { + return false; + } + + @Override + public IslandType getIslandType() { + return type; + } + + @Override + public void setIslandType(IslandType type) { + this.type = type; + } + + @Override + public void writeCustomNBT(NBTTagCompound cmp) { + cmp.setString(TAG_ISLAND_TYPE, type.toString()); + } + + @Override + public void readCustomNBT(NBTTagCompound cmp) { + type = IslandType.ofType(cmp.getString(TAG_ISLAND_TYPE)); + } } diff --git a/src/main/java/vazkii/botania/common/block/tile/TileFloatingSpecialFlower.java b/src/main/java/vazkii/botania/common/block/tile/TileFloatingSpecialFlower.java index 9e6fce1680..cd219e527e 100644 --- a/src/main/java/vazkii/botania/common/block/tile/TileFloatingSpecialFlower.java +++ b/src/main/java/vazkii/botania/common/block/tile/TileFloatingSpecialFlower.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Nov 17, 2014, 5:41:58 PM (GMT)] */ package vazkii.botania.common.block.tile; @@ -17,49 +17,46 @@ public class TileFloatingSpecialFlower extends TileSpecialFlower implements IFloatingFlower { - public static final String TAG_ISLAND_TYPE = "islandType"; - IslandType type = IslandType.GRASS; - - @Override - public boolean isOnSpecialSoil() { - return false; - } - - @Override - public ItemStack getDisplayStack() { - return ItemBlockSpecialFlower.ofType(subTileName); - } - - @Override - public IslandType getIslandType() { - return type; - } - - @Override - public void setIslandType(IslandType type) { - this.type = type; - } - - @Override - public void writeCustomNBT(NBTTagCompound cmp) { - super.writeCustomNBT(cmp); - cmp.setString(TAG_ISLAND_TYPE, type.toString()); - } - - @Override - public void readCustomNBT(NBTTagCompound cmp) { - super.readCustomNBT(cmp); - type = IslandType.ofType(cmp.getString(TAG_ISLAND_TYPE)); - } - - @Override - public int getSlowdownFactor() { - IslandType type = getIslandType(); - if (type == IslandType.MYCEL) - return SLOWDOWN_FACTOR_MYCEL; - else if (type == IslandType.PODZOL) - return SLOWDOWN_FACTOR_PODZOL; - return 0; - } - + public static final String TAG_ISLAND_TYPE = "islandType"; + IslandType type = IslandType.GRASS; + + @Override + public boolean isOnSpecialSoil() { + return false; + } + + @Override + public ItemStack getDisplayStack() { + return ItemBlockSpecialFlower.ofType(subTileName); + } + + @Override + public IslandType getIslandType() { + return type; + } + + @Override + public void setIslandType(IslandType type) { + this.type = type; + } + + @Override + public void writeCustomNBT(NBTTagCompound cmp) { + super.writeCustomNBT(cmp); + cmp.setString(TAG_ISLAND_TYPE, type.toString()); + } + + @Override + public void readCustomNBT(NBTTagCompound cmp) { + super.readCustomNBT(cmp); + type = IslandType.ofType(cmp.getString(TAG_ISLAND_TYPE)); + } + + @Override + public int getSlowdownFactor() { + IslandType type = getIslandType(); + if (type == IslandType.MYCEL) return SLOWDOWN_FACTOR_MYCEL; + else if (type == IslandType.PODZOL) return SLOWDOWN_FACTOR_PODZOL; + return 0; + } } diff --git a/src/main/java/vazkii/botania/common/block/tile/TileForestEye.java b/src/main/java/vazkii/botania/common/block/tile/TileForestEye.java index 9f0e63c8f5..49d5aa57df 100644 --- a/src/main/java/vazkii/botania/common/block/tile/TileForestEye.java +++ b/src/main/java/vazkii/botania/common/block/tile/TileForestEye.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [May 10, 2014, 5:50:01 PM (GMT)] */ package vazkii.botania.common.block.tile; @@ -15,16 +15,24 @@ public class TileForestEye extends TileMod { - public int entities = 0; - - @Override - public void updateEntity() { - int range = 6; - int entityCount = worldObj.getEntitiesWithinAABB(EntityAnimal.class, AxisAlignedBB.getBoundingBox(xCoord - range, yCoord - range, zCoord - range, xCoord + range + 1, yCoord + range + 1, zCoord + range + 1)).size(); - if(entityCount != entities) { - entities = entityCount; - worldObj.func_147453_f(xCoord, yCoord, zCoord, worldObj.getBlock(xCoord, yCoord, zCoord)); - } - } + public int entities = 0; + @Override + public void updateEntity() { + int range = 6; + int entityCount = worldObj.getEntitiesWithinAABB( + EntityAnimal.class, + AxisAlignedBB.getBoundingBox( + xCoord - range, + yCoord - range, + zCoord - range, + xCoord + range + 1, + yCoord + range + 1, + zCoord + range + 1)) + .size(); + if (entityCount != entities) { + entities = entityCount; + worldObj.func_147453_f(xCoord, yCoord, zCoord, worldObj.getBlock(xCoord, yCoord, zCoord)); + } + } } diff --git a/src/main/java/vazkii/botania/common/block/tile/TileGaiaHead.java b/src/main/java/vazkii/botania/common/block/tile/TileGaiaHead.java index 6d705d90a8..a665ed76cd 100644 --- a/src/main/java/vazkii/botania/common/block/tile/TileGaiaHead.java +++ b/src/main/java/vazkii/botania/common/block/tile/TileGaiaHead.java @@ -2,16 +2,14 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Sep 23, 2015, 11:47:40 PM (GMT)] */ package vazkii.botania.common.block.tile; import net.minecraft.tileentity.TileEntitySkull; -public class TileGaiaHead extends TileEntitySkull { - -} +public class TileGaiaHead extends TileEntitySkull {} diff --git a/src/main/java/vazkii/botania/common/block/tile/TileHourglass.java b/src/main/java/vazkii/botania/common/block/tile/TileHourglass.java index f182076216..78c7c0a0a1 100644 --- a/src/main/java/vazkii/botania/common/block/tile/TileHourglass.java +++ b/src/main/java/vazkii/botania/common/block/tile/TileHourglass.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [May 29, 2015, 8:21:17 PM (GMT)] */ package vazkii.botania.common.block.tile; @@ -20,158 +20,145 @@ import net.minecraft.nbt.NBTTagCompound; import net.minecraft.util.StatCollector; import net.minecraft.util.StringUtils; - import org.lwjgl.opengl.GL11; import org.lwjgl.opengl.GL12; - import vazkii.botania.api.internal.VanillaPacketDispatcher; import vazkii.botania.common.lib.LibBlockNames; public class TileHourglass extends TileSimpleInventory { - private static final String TAG_TIME = "time"; - private static final String TAG_TIME_FRACTION = "timeFraction"; - private static final String TAG_FLIP = "flip"; - private static final String TAG_FLIP_TICKS = "flipTicks"; - private static final String TAG_LOCK = "lock"; - private static final String TAG_MOVE = "move"; - - int time = 0; - public float timeFraction = 0F; - public boolean flip = false; - public int flipTicks = 0; - public boolean lock = false; - public boolean move = true; - - @Override - public void updateEntity() { - super.updateEntity(); - - int totalTime = getTotalTime(); - if(totalTime > 0) { - if(move) - time++; - if(time >= totalTime) { - time = 0; - flip = !flip; - flipTicks = 4; - worldObj.setBlockMetadataWithNotify(xCoord, yCoord, zCoord, 1, 1 | 2); - worldObj.scheduleBlockUpdate(xCoord, yCoord, zCoord, getBlockType(), getBlockType().tickRate(worldObj)); - } - timeFraction = (float) time / (float) totalTime; - } else { - time = 0; - timeFraction = 0F; - } - - if(flipTicks > 0) - flipTicks--; - } - - public int getTotalTime() { - ItemStack stack = getStackInSlot(0); - if(stack == null) - return 0; - - return getStackItemTime(stack) * stack.stackSize; - } - - public static int getStackItemTime(ItemStack stack) { - if(stack == null) - return 0; - if(stack.getItem() == Item.getItemFromBlock(Blocks.sand)) - return stack.getItemDamage() == 1 ? 200 : 20; - if(stack.getItem() == Item.getItemFromBlock(Blocks.soul_sand)) - return 1200; - return 0; - } - - public int getColor() { - ItemStack stack = getStackInSlot(0); - if(stack == null) - return 0; - if(stack.getItem() == Item.getItemFromBlock(Blocks.sand)) - return stack.getItemDamage() == 1 ? 0xE95800 : 0xFFEC49; - if(stack.getItem() == Item.getItemFromBlock(Blocks.soul_sand)) - return 0x5A412f; - return 0; - } - - @Override - public boolean isItemValidForSlot(int i, ItemStack itemstack) { - if(itemstack == null) - return false; - Item item = itemstack.getItem(); - return item == Item.getItemFromBlock(Blocks.sand) || item == Item.getItemFromBlock(Blocks.soul_sand); - } - - @Override - public void writeCustomNBT(NBTTagCompound par1nbtTagCompound) { - super.writeCustomNBT(par1nbtTagCompound); - par1nbtTagCompound.setInteger(TAG_TIME, time); - par1nbtTagCompound.setFloat(TAG_TIME_FRACTION, timeFraction); - par1nbtTagCompound.setBoolean(TAG_FLIP, flip); - par1nbtTagCompound.setInteger(TAG_FLIP_TICKS, flipTicks); - par1nbtTagCompound.setBoolean(TAG_MOVE, move); - par1nbtTagCompound.setBoolean(TAG_LOCK, lock); - } - - @Override - public void readCustomNBT(NBTTagCompound par1nbtTagCompound) { - super.readCustomNBT(par1nbtTagCompound); - time = par1nbtTagCompound.getInteger(TAG_TIME); - timeFraction = par1nbtTagCompound.getFloat(TAG_TIME_FRACTION); - flip = par1nbtTagCompound.getBoolean(TAG_FLIP); - flipTicks = par1nbtTagCompound.getInteger(TAG_FLIP_TICKS); - move = par1nbtTagCompound.getBoolean(TAG_MOVE); - lock = par1nbtTagCompound.getBoolean(TAG_LOCK); - } - - @Override - public int getSizeInventory() { - return 1; - } - - @Override - public void markDirty() { - super.markDirty(); - time = 0; - timeFraction = 0F; - VanillaPacketDispatcher.dispatchTEToNearbyPlayers(this); - } - - public void renderHUD(ScaledResolution res) { - Minecraft mc = Minecraft.getMinecraft(); - int x = res.getScaledWidth() / 2 + 10; - int y = res.getScaledHeight() / 2 - 10; - - ItemStack stack = getStackInSlot(0); - if(stack != null) { - RenderHelper.enableGUIStandardItemLighting(); - GL11.glEnable(GL12.GL_RESCALE_NORMAL); - RenderItem.getInstance().renderItemIntoGUI(mc.fontRenderer, mc.renderEngine, stack, x, y); - RenderItem.getInstance().renderItemOverlayIntoGUI(mc.fontRenderer, mc.renderEngine, stack, x, y); - GL11.glDisable(GL12.GL_RESCALE_NORMAL); - RenderHelper.disableStandardItemLighting(); - - int time = getTotalTime(); - String timeStr = StringUtils.ticksToElapsedTime(time); - mc.fontRenderer.drawStringWithShadow(timeStr, x + 20, y, getColor()); - - String status = ""; - if(lock) - status = "locked"; - if(!move) - status = status.isEmpty() ? "stopped" : "lockedStopped"; - if(!status.isEmpty()) - mc.fontRenderer.drawStringWithShadow(StatCollector.translateToLocal("botaniamisc." + status), x + 20, y + 12, getColor()); - } - - } - - @Override - public String getInventoryName() { - return LibBlockNames.HOURGLASS; - } - + private static final String TAG_TIME = "time"; + private static final String TAG_TIME_FRACTION = "timeFraction"; + private static final String TAG_FLIP = "flip"; + private static final String TAG_FLIP_TICKS = "flipTicks"; + private static final String TAG_LOCK = "lock"; + private static final String TAG_MOVE = "move"; + + int time = 0; + public float timeFraction = 0F; + public boolean flip = false; + public int flipTicks = 0; + public boolean lock = false; + public boolean move = true; + + @Override + public void updateEntity() { + super.updateEntity(); + + int totalTime = getTotalTime(); + if (totalTime > 0) { + if (move) time++; + if (time >= totalTime) { + time = 0; + flip = !flip; + flipTicks = 4; + worldObj.setBlockMetadataWithNotify(xCoord, yCoord, zCoord, 1, 1 | 2); + worldObj.scheduleBlockUpdate( + xCoord, yCoord, zCoord, getBlockType(), getBlockType().tickRate(worldObj)); + } + timeFraction = (float) time / (float) totalTime; + } else { + time = 0; + timeFraction = 0F; + } + + if (flipTicks > 0) flipTicks--; + } + + public int getTotalTime() { + ItemStack stack = getStackInSlot(0); + if (stack == null) return 0; + + return getStackItemTime(stack) * stack.stackSize; + } + + public static int getStackItemTime(ItemStack stack) { + if (stack == null) return 0; + if (stack.getItem() == Item.getItemFromBlock(Blocks.sand)) return stack.getItemDamage() == 1 ? 200 : 20; + if (stack.getItem() == Item.getItemFromBlock(Blocks.soul_sand)) return 1200; + return 0; + } + + public int getColor() { + ItemStack stack = getStackInSlot(0); + if (stack == null) return 0; + if (stack.getItem() == Item.getItemFromBlock(Blocks.sand)) + return stack.getItemDamage() == 1 ? 0xE95800 : 0xFFEC49; + if (stack.getItem() == Item.getItemFromBlock(Blocks.soul_sand)) return 0x5A412f; + return 0; + } + + @Override + public boolean isItemValidForSlot(int i, ItemStack itemstack) { + if (itemstack == null) return false; + Item item = itemstack.getItem(); + return item == Item.getItemFromBlock(Blocks.sand) || item == Item.getItemFromBlock(Blocks.soul_sand); + } + + @Override + public void writeCustomNBT(NBTTagCompound par1nbtTagCompound) { + super.writeCustomNBT(par1nbtTagCompound); + par1nbtTagCompound.setInteger(TAG_TIME, time); + par1nbtTagCompound.setFloat(TAG_TIME_FRACTION, timeFraction); + par1nbtTagCompound.setBoolean(TAG_FLIP, flip); + par1nbtTagCompound.setInteger(TAG_FLIP_TICKS, flipTicks); + par1nbtTagCompound.setBoolean(TAG_MOVE, move); + par1nbtTagCompound.setBoolean(TAG_LOCK, lock); + } + + @Override + public void readCustomNBT(NBTTagCompound par1nbtTagCompound) { + super.readCustomNBT(par1nbtTagCompound); + time = par1nbtTagCompound.getInteger(TAG_TIME); + timeFraction = par1nbtTagCompound.getFloat(TAG_TIME_FRACTION); + flip = par1nbtTagCompound.getBoolean(TAG_FLIP); + flipTicks = par1nbtTagCompound.getInteger(TAG_FLIP_TICKS); + move = par1nbtTagCompound.getBoolean(TAG_MOVE); + lock = par1nbtTagCompound.getBoolean(TAG_LOCK); + } + + @Override + public int getSizeInventory() { + return 1; + } + + @Override + public void markDirty() { + super.markDirty(); + time = 0; + timeFraction = 0F; + VanillaPacketDispatcher.dispatchTEToNearbyPlayers(this); + } + + public void renderHUD(ScaledResolution res) { + Minecraft mc = Minecraft.getMinecraft(); + int x = res.getScaledWidth() / 2 + 10; + int y = res.getScaledHeight() / 2 - 10; + + ItemStack stack = getStackInSlot(0); + if (stack != null) { + RenderHelper.enableGUIStandardItemLighting(); + GL11.glEnable(GL12.GL_RESCALE_NORMAL); + RenderItem.getInstance().renderItemIntoGUI(mc.fontRenderer, mc.renderEngine, stack, x, y); + RenderItem.getInstance().renderItemOverlayIntoGUI(mc.fontRenderer, mc.renderEngine, stack, x, y); + GL11.glDisable(GL12.GL_RESCALE_NORMAL); + RenderHelper.disableStandardItemLighting(); + + int time = getTotalTime(); + String timeStr = StringUtils.ticksToElapsedTime(time); + mc.fontRenderer.drawStringWithShadow(timeStr, x + 20, y, getColor()); + + String status = ""; + if (lock) status = "locked"; + if (!move) status = status.isEmpty() ? "stopped" : "lockedStopped"; + if (!status.isEmpty()) + mc.fontRenderer.drawStringWithShadow( + StatCollector.translateToLocal("botaniamisc." + status), x + 20, y + 12, getColor()); + } + } + + @Override + public String getInventoryName() { + return LibBlockNames.HOURGLASS; + } } diff --git a/src/main/java/vazkii/botania/common/block/tile/TileIncensePlate.java b/src/main/java/vazkii/botania/common/block/tile/TileIncensePlate.java index 133ad72ad5..33303703e6 100644 --- a/src/main/java/vazkii/botania/common/block/tile/TileIncensePlate.java +++ b/src/main/java/vazkii/botania/common/block/tile/TileIncensePlate.java @@ -2,17 +2,16 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [May 15, 2015, 4:09:07 PM (GMT)] */ package vazkii.botania.common.block.tile; import java.awt.Color; import java.util.List; - import net.minecraft.entity.player.EntityPlayer; import net.minecraft.inventory.ISidedInventory; import net.minecraft.item.ItemStack; @@ -30,124 +29,153 @@ public class TileIncensePlate extends TileSimpleInventory implements ISidedInventory { - private static final String TAG_TIME_LEFT = "timeLeft"; - private static final String TAG_BURNING = "burning"; - private static final int RANGE = 32; - - public int timeLeft = 0; - public boolean burning = false; - - public int comparatorOutput = 0; - - @Override - public void updateEntity() { - ItemStack stack = getStackInSlot(0); - if(stack != null && burning) { - Brew brew = ((ItemIncenseStick) ModItems.incenseStick).getBrew(stack); - PotionEffect effect = brew.getPotionEffects(stack).get(0); - if(timeLeft > 0) { - timeLeft--; - if(!worldObj.isRemote) { - List players = worldObj.getEntitiesWithinAABB(EntityPlayer.class, AxisAlignedBB.getBoundingBox(xCoord + 0.5 - RANGE, yCoord + 0.5 - RANGE, zCoord + 0.5 - RANGE, xCoord + 0.5 + RANGE, yCoord + 0.5 + RANGE, zCoord + 0.5 + RANGE)); - for(EntityPlayer player : players) { - PotionEffect currentEffect = player.getActivePotionEffect(Potion.potionTypes[effect.getPotionID()]); - boolean nightVision = effect.getPotionID() == Potion.nightVision.id; - if(currentEffect == null || currentEffect.getDuration() < (nightVision ? 205 : 3)) { - PotionEffect applyEffect = new PotionEffect(effect.getPotionID(), nightVision ? 285 : 80, effect.getAmplifier(), true); - player.addPotionEffect(applyEffect); - } - } - - if(worldObj.rand.nextInt(20) == 0) - worldObj.playSoundEffect(xCoord + 0.5, yCoord + 0.1, zCoord + 0.5, "fire.fire", 0.1F, 1F); - } else { - double x = xCoord + 0.5; - double y = yCoord + 0.5; - double z = zCoord + 0.5; - Color color = new Color(brew.getColor(stack)); - float r = color.getRed() / 255F; - float g = color.getGreen() / 255F; - float b = color.getBlue() / 255F; - Botania.proxy.wispFX(worldObj, x - (Math.random() - 0.5) * 0.2, y - (Math.random() - 0.5) * 0.2, z - (Math.random() - 0.5) * 0.2, r, g, b, 0.05F + (float) Math.random() * 0.02F, 0.005F - (float) Math.random() * 0.01F, 0.01F + (float) Math.random() * 0.005F, 0.005F - (float) Math.random() * 0.01F); - Botania.proxy.wispFX(worldObj, x - (Math.random() - 0.5) * 0.2, y - (Math.random() - 0.5) * 0.2, z - (Math.random() - 0.5) * 0.2, 0.2F, 0.2F, 0.2F, 0.05F + (float) Math.random() * 0.02F, 0.005F - (float) Math.random() * 0.01F, 0.01F + (float) Math.random() * 0.001F, 0.005F - (float) Math.random() * 0.01F); - } - } else { - setInventorySlotContents(0, null); - burning = false; - VanillaPacketDispatcher.dispatchTEToNearbyPlayers(this); - } - } else timeLeft = 0; - - int newComparator = 0; - if(stack != null) - newComparator = 1; - if(burning) - newComparator = 2; - if(comparatorOutput != newComparator) { - comparatorOutput = newComparator; - worldObj.func_147453_f(xCoord, yCoord, zCoord, worldObj.getBlock(xCoord, yCoord, zCoord)); - } - } - - public void ignite() { - ItemStack stack = getStackInSlot(0); - if(stack == null || burning) - return; - - burning = true; - Brew brew = ((ItemIncenseStick) ModItems.incenseStick).getBrew(stack); - timeLeft = brew.getPotionEffects(stack).get(0).getDuration() * ItemIncenseStick.TIME_MULTIPLIER; - } - - @Override - public int getSizeInventory() { - return 1; - } - - @Override - public String getInventoryName() { - return LibBlockNames.INCENSE_PLATE; - } - - @Override - public void writeCustomNBT(NBTTagCompound par1nbtTagCompound) { - super.writeCustomNBT(par1nbtTagCompound); - par1nbtTagCompound.setInteger(TAG_TIME_LEFT, timeLeft); - par1nbtTagCompound.setBoolean(TAG_BURNING, burning); - } - - @Override - public void readCustomNBT(NBTTagCompound par1nbtTagCompound) { - super.readCustomNBT(par1nbtTagCompound); - timeLeft = par1nbtTagCompound.getInteger(TAG_TIME_LEFT); - burning = par1nbtTagCompound.getBoolean(TAG_BURNING); - } - - @Override - public boolean isItemValidForSlot(int i, ItemStack itemstack) { - return itemstack != null && itemstack.getItem() == ModItems.incenseStick && ((ItemIncenseStick) ModItems.incenseStick).getBrew(itemstack) != BotaniaAPI.fallbackBrew; - } - - @Override - public int[] getAccessibleSlotsFromSide(int side) { - return new int[] { 0 }; - } - - @Override - public boolean canInsertItem(int slot, ItemStack stack, int side) { - return isItemValidForSlot(slot, stack); - } - - @Override - public boolean canExtractItem(int p_102008_1_, ItemStack p_102008_2_, int p_102008_3_) { - return false; - } - - @Override - public void markDirty() { - super.markDirty(); - if(!worldObj.isRemote) - VanillaPacketDispatcher.dispatchTEToNearbyPlayers(this); - } - + private static final String TAG_TIME_LEFT = "timeLeft"; + private static final String TAG_BURNING = "burning"; + private static final int RANGE = 32; + + public int timeLeft = 0; + public boolean burning = false; + + public int comparatorOutput = 0; + + @Override + public void updateEntity() { + ItemStack stack = getStackInSlot(0); + if (stack != null && burning) { + Brew brew = ((ItemIncenseStick) ModItems.incenseStick).getBrew(stack); + PotionEffect effect = brew.getPotionEffects(stack).get(0); + if (timeLeft > 0) { + timeLeft--; + if (!worldObj.isRemote) { + List players = worldObj.getEntitiesWithinAABB( + EntityPlayer.class, + AxisAlignedBB.getBoundingBox( + xCoord + 0.5 - RANGE, + yCoord + 0.5 - RANGE, + zCoord + 0.5 - RANGE, + xCoord + 0.5 + RANGE, + yCoord + 0.5 + RANGE, + zCoord + 0.5 + RANGE)); + for (EntityPlayer player : players) { + PotionEffect currentEffect = + player.getActivePotionEffect(Potion.potionTypes[effect.getPotionID()]); + boolean nightVision = effect.getPotionID() == Potion.nightVision.id; + if (currentEffect == null || currentEffect.getDuration() < (nightVision ? 205 : 3)) { + PotionEffect applyEffect = new PotionEffect( + effect.getPotionID(), nightVision ? 285 : 80, effect.getAmplifier(), true); + player.addPotionEffect(applyEffect); + } + } + + if (worldObj.rand.nextInt(20) == 0) + worldObj.playSoundEffect(xCoord + 0.5, yCoord + 0.1, zCoord + 0.5, "fire.fire", 0.1F, 1F); + } else { + double x = xCoord + 0.5; + double y = yCoord + 0.5; + double z = zCoord + 0.5; + Color color = new Color(brew.getColor(stack)); + float r = color.getRed() / 255F; + float g = color.getGreen() / 255F; + float b = color.getBlue() / 255F; + Botania.proxy.wispFX( + worldObj, + x - (Math.random() - 0.5) * 0.2, + y - (Math.random() - 0.5) * 0.2, + z - (Math.random() - 0.5) * 0.2, + r, + g, + b, + 0.05F + (float) Math.random() * 0.02F, + 0.005F - (float) Math.random() * 0.01F, + 0.01F + (float) Math.random() * 0.005F, + 0.005F - (float) Math.random() * 0.01F); + Botania.proxy.wispFX( + worldObj, + x - (Math.random() - 0.5) * 0.2, + y - (Math.random() - 0.5) * 0.2, + z - (Math.random() - 0.5) * 0.2, + 0.2F, + 0.2F, + 0.2F, + 0.05F + (float) Math.random() * 0.02F, + 0.005F - (float) Math.random() * 0.01F, + 0.01F + (float) Math.random() * 0.001F, + 0.005F - (float) Math.random() * 0.01F); + } + } else { + setInventorySlotContents(0, null); + burning = false; + VanillaPacketDispatcher.dispatchTEToNearbyPlayers(this); + } + } else timeLeft = 0; + + int newComparator = 0; + if (stack != null) newComparator = 1; + if (burning) newComparator = 2; + if (comparatorOutput != newComparator) { + comparatorOutput = newComparator; + worldObj.func_147453_f(xCoord, yCoord, zCoord, worldObj.getBlock(xCoord, yCoord, zCoord)); + } + } + + public void ignite() { + ItemStack stack = getStackInSlot(0); + if (stack == null || burning) return; + + burning = true; + Brew brew = ((ItemIncenseStick) ModItems.incenseStick).getBrew(stack); + timeLeft = brew.getPotionEffects(stack).get(0).getDuration() * ItemIncenseStick.TIME_MULTIPLIER; + } + + @Override + public int getSizeInventory() { + return 1; + } + + @Override + public String getInventoryName() { + return LibBlockNames.INCENSE_PLATE; + } + + @Override + public void writeCustomNBT(NBTTagCompound par1nbtTagCompound) { + super.writeCustomNBT(par1nbtTagCompound); + par1nbtTagCompound.setInteger(TAG_TIME_LEFT, timeLeft); + par1nbtTagCompound.setBoolean(TAG_BURNING, burning); + } + + @Override + public void readCustomNBT(NBTTagCompound par1nbtTagCompound) { + super.readCustomNBT(par1nbtTagCompound); + timeLeft = par1nbtTagCompound.getInteger(TAG_TIME_LEFT); + burning = par1nbtTagCompound.getBoolean(TAG_BURNING); + } + + @Override + public boolean isItemValidForSlot(int i, ItemStack itemstack) { + return itemstack != null + && itemstack.getItem() == ModItems.incenseStick + && ((ItemIncenseStick) ModItems.incenseStick).getBrew(itemstack) != BotaniaAPI.fallbackBrew; + } + + @Override + public int[] getAccessibleSlotsFromSide(int side) { + return new int[] {0}; + } + + @Override + public boolean canInsertItem(int slot, ItemStack stack, int side) { + return isItemValidForSlot(slot, stack); + } + + @Override + public boolean canExtractItem(int p_102008_1_, ItemStack p_102008_2_, int p_102008_3_) { + return false; + } + + @Override + public void markDirty() { + super.markDirty(); + if (!worldObj.isRemote) VanillaPacketDispatcher.dispatchTEToNearbyPlayers(this); + } } diff --git a/src/main/java/vazkii/botania/common/block/tile/TileLightRelay.java b/src/main/java/vazkii/botania/common/block/tile/TileLightRelay.java index 063526503e..3bc6be2024 100644 --- a/src/main/java/vazkii/botania/common/block/tile/TileLightRelay.java +++ b/src/main/java/vazkii/botania/common/block/tile/TileLightRelay.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jul 15, 2015, 8:32:04 PM (GMT)] */ package vazkii.botania.common.block.tile; @@ -13,7 +13,6 @@ import java.awt.Color; import java.util.ArrayList; import java.util.List; - import net.minecraft.block.Block; import net.minecraft.entity.Entity; import net.minecraft.entity.item.EntityEnderPearl; @@ -35,271 +34,305 @@ public class TileLightRelay extends TileMod implements IWandBindable { - private static final int MAX_DIST = 20; - - private static final String TAG_BIND_X = "bindX"; - private static final String TAG_BIND_Y = "bindY"; - private static final String TAG_BIND_Z = "bindZ"; - - int bindX, bindY = -1, bindZ; - int ticksElapsed = 0; - - public void mountEntity(Entity e) { - if(e.ridingEntity != null || worldObj.isRemote || bindY == -1 || !isValidBinding()) - return; - - EntityPlayerMover mover = new EntityPlayerMover(worldObj, xCoord, yCoord, zCoord, bindX, bindY, bindZ); - worldObj.spawnEntityInWorld(mover); - e.mountEntity(mover); - if(!(e instanceof EntityItem)) { - worldObj.playSoundAtEntity(mover, "botania:lightRelay", 0.2F, (float) Math.random() * 0.3F + 0.7F); - if(e instanceof EntityPlayer) - ((EntityPlayer) e).addStat(ModAchievements.luminizerRide, 1); - } - } - - @Override - public void updateEntity() { - ticksElapsed++; - - if(bindY > -1 && isValidBinding()) { - Vector3 vec = getMovementVector(); - - double dist = 0.1; - int size = (int) (vec.mag() / dist); - int count = 10; - int start = ticksElapsed % size; - - Vector3 vecMag = vec.copy().normalize().multiply(dist); - Vector3 vecTip = vecMag.copy().multiply(start).add(xCoord + 0.5, yCoord + 0.5, zCoord + 0.5); - - double radPer = Math.PI / 16.0; - float mul = 0.5F; - float mulPer = 0.4F; - float maxMul = 2; - for(int i = start; i < start + count; i++) { - mul = Math.min(maxMul, mul + mulPer); - double rad = radPer * (i + ticksElapsed * 0.4); - Vector3 vecRot = vecMag.copy().crossProduct(Vector3.one).multiply(mul).rotate(rad, vecMag).add(vecTip); - Botania.proxy.wispFX(worldObj, vecRot.x, vecRot.y, vecRot.z, 0.4F, 0.4F, 1F, 0.1F, (float) -vecMag.x, (float) -vecMag.y, (float) -vecMag.z, 1F); - vecTip.add(vecMag); - } - - ChunkCoordinates endpoint = getEndpoint(); - if(endpoint != null && !worldObj.isRemote) { - float range = 0.5F; - List enderPearls = worldObj.getEntitiesWithinAABB(EntityEnderPearl.class, AxisAlignedBB.getBoundingBox(xCoord - range, yCoord - range, zCoord - range, xCoord + 1 + range, yCoord + 1 + range, zCoord + 1 + range)); - for(EntityEnderPearl pearl : enderPearls) { - pearl.posX = endpoint.posX + pearl.posX - xCoord; - pearl.posY = endpoint.posY + pearl.posY - yCoord; - pearl.posZ = endpoint.posZ + pearl.posZ - zCoord; - } - } - } - } - - public boolean isValidBinding() { - Block block = worldObj.getBlock(bindX, bindY, bindZ); - return block == ModBlocks.lightRelay; - } - - public ChunkCoordinates getEndpoint() { - List pointsPassed = new ArrayList(); - TileLightRelay relay = this; - ChunkCoordinates lastCoords = null; - - // Doing while(true) gives an unreachable code error - boolean run = true; - while(run) { - if(pointsPassed.contains(relay)) - return null; // Circular path - pointsPassed.add(relay); - - ChunkCoordinates coords = relay.getBinding(); - if(coords == null) - return lastCoords; - - TileEntity tile = worldObj.getTileEntity(coords.posX, coords.posY, coords.posZ); - if(tile != null && tile instanceof TileLightRelay) - relay = (TileLightRelay) tile; - else return lastCoords; - - lastCoords = coords; - } - - return null; - } - - public Vector3 getMovementVector() { - return new Vector3(bindX - xCoord, bindY - yCoord, bindZ - zCoord); - } - - @Override - public ChunkCoordinates getBinding() { - return bindY == -1 ? null : new ChunkCoordinates(bindX, bindY, bindZ); - } - - @Override - public boolean canSelect(EntityPlayer player, ItemStack wand, int x, int y, int z, int side) { - return true; - } - - @Override - public boolean bindTo(EntityPlayer player, ItemStack wand, int x, int y, int z, int side) { - if(player.worldObj.getBlock(x, y, z) != ModBlocks.lightRelay || MathHelper.pointDistanceSpace(x, y, z, xCoord, yCoord, zCoord) > MAX_DIST) - return false; - - bindX = x; - bindY = y; - bindZ = z; - return true; - } - - @Override - public void readCustomNBT(NBTTagCompound cmp) { - bindX = cmp.getInteger(TAG_BIND_X); - bindY = cmp.getInteger(TAG_BIND_Y); - bindZ = cmp.getInteger(TAG_BIND_Z); - } - - @Override - public void writeCustomNBT(NBTTagCompound cmp) { - cmp.setInteger(TAG_BIND_X, bindX); - cmp.setInteger(TAG_BIND_Y, bindY); - cmp.setInteger(TAG_BIND_Z, bindZ); - } - - public static class EntityPlayerMover extends Entity { - - private static final String TAG_EXIT_X = "exitX"; - private static final String TAG_EXIT_Y = "exitY"; - private static final String TAG_EXIT_Z = "exitZ"; - - public EntityPlayerMover(World world) { - super(world); - } - - public EntityPlayerMover(World world, int x, int y, int z, int exitX, int exitY, int exitZ) { - this(world); - setPosition(x + 0.5, y + 0.5, z + 0.5); - setExit(exitX, exitY, exitZ); - } - - @Override - protected void entityInit() { - setSize(0F, 0F); - noClip = true; - - dataWatcher.addObject(20, 0); - dataWatcher.addObject(21, 0); - dataWatcher.addObject(22, 0); - dataWatcher.setObjectWatched(20); - dataWatcher.setObjectWatched(21); - dataWatcher.setObjectWatched(22); - } - - @Override - public void onUpdate() { - super.onUpdate(); - - if(riddenByEntity == null && !worldObj.isRemote) { - setDead(); - return; - } - - boolean isItem = riddenByEntity instanceof EntityItem; - if(!isItem && ticksExisted % 30 == 0) - worldObj.playSoundAtEntity(this, "botania:lightRelay", 0.05F, (float) Math.random() * 0.3F + 0.7F); - - int exitX = getExitX(); - int exitY = getExitY(); - int exitZ = getExitZ(); - - int x = net.minecraft.util.MathHelper.floor_double(posX); - int y = net.minecraft.util.MathHelper.floor_double(posY); - int z = net.minecraft.util.MathHelper.floor_double(posZ); - if(x == exitX && y == exitY && z == exitZ) { - TileEntity tile = worldObj.getTileEntity(x, y, z); - if(tile != null && tile instanceof TileLightRelay) { - int meta = worldObj.getBlockMetadata(x, y, z); - if(meta > 0) { - worldObj.setBlockMetadataWithNotify(x, y, z, meta | 8, 1 | 2); - worldObj.scheduleBlockUpdate(x, y, z, tile.getBlockType(), tile.getBlockType().tickRate(worldObj)); - } - - TileLightRelay relay = (TileLightRelay) tile; - ChunkCoordinates bind = relay.getBinding(); - if(bind != null && relay.isValidBinding()) { - setExit(bind.posX, bind.posY, bind.posZ); - return; - } - } - - posY += 1.5; - setDead(); - } else { - Vector3 thisVec = Vector3.fromEntity(this); - Vector3 motVec = thisVec.negate().add(exitX + 0.5, exitY + 0.5, exitZ + 0.5).normalize().multiply(0.5); - - Color color; - - int count = 4; - for(int i = 0; i < count; i++) { - color = Color.getHSBColor(ticksExisted / 36F + 1F / count * i, 1F, 1F); - double rad = Math.PI * 2.0 / count * i + ticksExisted / Math.PI; - double cos = Math.cos(rad); - double sin = Math.sin(rad); - double s = 0.4; - - Botania.proxy.sparkleFX(worldObj, posX + cos * s, posY - 0.5, posZ + sin * s, color.getRed() / 255F, color.getGreen() / 255F, color.getBlue() / 255F, 1.2F, 10); - } - - posX += motVec.x; - posY += motVec.y; - posZ += motVec.z; - } - } - - @Override - public boolean shouldRiderSit() { - return false; - } - - @Override - public boolean attackEntityFrom(DamageSource p_70097_1_, float p_70097_2_) { - return false; - } - - @Override - protected void readEntityFromNBT(NBTTagCompound cmp) { - setExit(cmp.getInteger(TAG_EXIT_X), cmp.getInteger(TAG_EXIT_Y), cmp.getInteger(TAG_EXIT_Z)); - } - - @Override - protected void writeEntityToNBT(NBTTagCompound cmp) { - cmp.setInteger(TAG_EXIT_X, getExitX()); - cmp.setInteger(TAG_EXIT_Y, getExitY()); - cmp.setInteger(TAG_EXIT_Z, getExitZ()); - } - - public int getExitX() { - return dataWatcher.getWatchableObjectInt(20); - } - - public int getExitY() { - return dataWatcher.getWatchableObjectInt(21); - } - - public int getExitZ() { - return dataWatcher.getWatchableObjectInt(22); - } - - public void setExit(int x, int y, int z) { - dataWatcher.updateObject(20, x); - dataWatcher.updateObject(21, y); - dataWatcher.updateObject(22, z); - } - - } - + private static final int MAX_DIST = 20; + + private static final String TAG_BIND_X = "bindX"; + private static final String TAG_BIND_Y = "bindY"; + private static final String TAG_BIND_Z = "bindZ"; + + int bindX, bindY = -1, bindZ; + int ticksElapsed = 0; + + public void mountEntity(Entity e) { + if (e.ridingEntity != null || worldObj.isRemote || bindY == -1 || !isValidBinding()) return; + + EntityPlayerMover mover = new EntityPlayerMover(worldObj, xCoord, yCoord, zCoord, bindX, bindY, bindZ); + worldObj.spawnEntityInWorld(mover); + e.mountEntity(mover); + if (!(e instanceof EntityItem)) { + worldObj.playSoundAtEntity(mover, "botania:lightRelay", 0.2F, (float) Math.random() * 0.3F + 0.7F); + if (e instanceof EntityPlayer) ((EntityPlayer) e).addStat(ModAchievements.luminizerRide, 1); + } + } + + @Override + public void updateEntity() { + ticksElapsed++; + + if (bindY > -1 && isValidBinding()) { + Vector3 vec = getMovementVector(); + + double dist = 0.1; + int size = (int) (vec.mag() / dist); + int count = 10; + int start = ticksElapsed % size; + + Vector3 vecMag = vec.copy().normalize().multiply(dist); + Vector3 vecTip = vecMag.copy().multiply(start).add(xCoord + 0.5, yCoord + 0.5, zCoord + 0.5); + + double radPer = Math.PI / 16.0; + float mul = 0.5F; + float mulPer = 0.4F; + float maxMul = 2; + for (int i = start; i < start + count; i++) { + mul = Math.min(maxMul, mul + mulPer); + double rad = radPer * (i + ticksElapsed * 0.4); + Vector3 vecRot = vecMag.copy() + .crossProduct(Vector3.one) + .multiply(mul) + .rotate(rad, vecMag) + .add(vecTip); + Botania.proxy.wispFX( + worldObj, + vecRot.x, + vecRot.y, + vecRot.z, + 0.4F, + 0.4F, + 1F, + 0.1F, + (float) -vecMag.x, + (float) -vecMag.y, + (float) -vecMag.z, + 1F); + vecTip.add(vecMag); + } + + ChunkCoordinates endpoint = getEndpoint(); + if (endpoint != null && !worldObj.isRemote) { + float range = 0.5F; + List enderPearls = worldObj.getEntitiesWithinAABB( + EntityEnderPearl.class, + AxisAlignedBB.getBoundingBox( + xCoord - range, + yCoord - range, + zCoord - range, + xCoord + 1 + range, + yCoord + 1 + range, + zCoord + 1 + range)); + for (EntityEnderPearl pearl : enderPearls) { + pearl.posX = endpoint.posX + pearl.posX - xCoord; + pearl.posY = endpoint.posY + pearl.posY - yCoord; + pearl.posZ = endpoint.posZ + pearl.posZ - zCoord; + } + } + } + } + + public boolean isValidBinding() { + Block block = worldObj.getBlock(bindX, bindY, bindZ); + return block == ModBlocks.lightRelay; + } + + public ChunkCoordinates getEndpoint() { + List pointsPassed = new ArrayList(); + TileLightRelay relay = this; + ChunkCoordinates lastCoords = null; + + // Doing while(true) gives an unreachable code error + boolean run = true; + while (run) { + if (pointsPassed.contains(relay)) return null; // Circular path + pointsPassed.add(relay); + + ChunkCoordinates coords = relay.getBinding(); + if (coords == null) return lastCoords; + + TileEntity tile = worldObj.getTileEntity(coords.posX, coords.posY, coords.posZ); + if (tile != null && tile instanceof TileLightRelay) relay = (TileLightRelay) tile; + else return lastCoords; + + lastCoords = coords; + } + + return null; + } + + public Vector3 getMovementVector() { + return new Vector3(bindX - xCoord, bindY - yCoord, bindZ - zCoord); + } + + @Override + public ChunkCoordinates getBinding() { + return bindY == -1 ? null : new ChunkCoordinates(bindX, bindY, bindZ); + } + + @Override + public boolean canSelect(EntityPlayer player, ItemStack wand, int x, int y, int z, int side) { + return true; + } + + @Override + public boolean bindTo(EntityPlayer player, ItemStack wand, int x, int y, int z, int side) { + if (player.worldObj.getBlock(x, y, z) != ModBlocks.lightRelay + || MathHelper.pointDistanceSpace(x, y, z, xCoord, yCoord, zCoord) > MAX_DIST) return false; + + bindX = x; + bindY = y; + bindZ = z; + return true; + } + + @Override + public void readCustomNBT(NBTTagCompound cmp) { + bindX = cmp.getInteger(TAG_BIND_X); + bindY = cmp.getInteger(TAG_BIND_Y); + bindZ = cmp.getInteger(TAG_BIND_Z); + } + + @Override + public void writeCustomNBT(NBTTagCompound cmp) { + cmp.setInteger(TAG_BIND_X, bindX); + cmp.setInteger(TAG_BIND_Y, bindY); + cmp.setInteger(TAG_BIND_Z, bindZ); + } + + public static class EntityPlayerMover extends Entity { + + private static final String TAG_EXIT_X = "exitX"; + private static final String TAG_EXIT_Y = "exitY"; + private static final String TAG_EXIT_Z = "exitZ"; + + public EntityPlayerMover(World world) { + super(world); + } + + public EntityPlayerMover(World world, int x, int y, int z, int exitX, int exitY, int exitZ) { + this(world); + setPosition(x + 0.5, y + 0.5, z + 0.5); + setExit(exitX, exitY, exitZ); + } + + @Override + protected void entityInit() { + setSize(0F, 0F); + noClip = true; + + dataWatcher.addObject(20, 0); + dataWatcher.addObject(21, 0); + dataWatcher.addObject(22, 0); + dataWatcher.setObjectWatched(20); + dataWatcher.setObjectWatched(21); + dataWatcher.setObjectWatched(22); + } + + @Override + public void onUpdate() { + super.onUpdate(); + + if (riddenByEntity == null && !worldObj.isRemote) { + setDead(); + return; + } + + boolean isItem = riddenByEntity instanceof EntityItem; + if (!isItem && ticksExisted % 30 == 0) + worldObj.playSoundAtEntity(this, "botania:lightRelay", 0.05F, (float) Math.random() * 0.3F + 0.7F); + + int exitX = getExitX(); + int exitY = getExitY(); + int exitZ = getExitZ(); + + int x = net.minecraft.util.MathHelper.floor_double(posX); + int y = net.minecraft.util.MathHelper.floor_double(posY); + int z = net.minecraft.util.MathHelper.floor_double(posZ); + if (x == exitX && y == exitY && z == exitZ) { + TileEntity tile = worldObj.getTileEntity(x, y, z); + if (tile != null && tile instanceof TileLightRelay) { + int meta = worldObj.getBlockMetadata(x, y, z); + if (meta > 0) { + worldObj.setBlockMetadataWithNotify(x, y, z, meta | 8, 1 | 2); + worldObj.scheduleBlockUpdate( + x, + y, + z, + tile.getBlockType(), + tile.getBlockType().tickRate(worldObj)); + } + + TileLightRelay relay = (TileLightRelay) tile; + ChunkCoordinates bind = relay.getBinding(); + if (bind != null && relay.isValidBinding()) { + setExit(bind.posX, bind.posY, bind.posZ); + return; + } + } + + posY += 1.5; + setDead(); + } else { + Vector3 thisVec = Vector3.fromEntity(this); + Vector3 motVec = thisVec.negate() + .add(exitX + 0.5, exitY + 0.5, exitZ + 0.5) + .normalize() + .multiply(0.5); + + Color color; + + int count = 4; + for (int i = 0; i < count; i++) { + color = Color.getHSBColor(ticksExisted / 36F + 1F / count * i, 1F, 1F); + double rad = Math.PI * 2.0 / count * i + ticksExisted / Math.PI; + double cos = Math.cos(rad); + double sin = Math.sin(rad); + double s = 0.4; + + Botania.proxy.sparkleFX( + worldObj, + posX + cos * s, + posY - 0.5, + posZ + sin * s, + color.getRed() / 255F, + color.getGreen() / 255F, + color.getBlue() / 255F, + 1.2F, + 10); + } + + posX += motVec.x; + posY += motVec.y; + posZ += motVec.z; + } + } + + @Override + public boolean shouldRiderSit() { + return false; + } + + @Override + public boolean attackEntityFrom(DamageSource p_70097_1_, float p_70097_2_) { + return false; + } + + @Override + protected void readEntityFromNBT(NBTTagCompound cmp) { + setExit(cmp.getInteger(TAG_EXIT_X), cmp.getInteger(TAG_EXIT_Y), cmp.getInteger(TAG_EXIT_Z)); + } + + @Override + protected void writeEntityToNBT(NBTTagCompound cmp) { + cmp.setInteger(TAG_EXIT_X, getExitX()); + cmp.setInteger(TAG_EXIT_Y, getExitY()); + cmp.setInteger(TAG_EXIT_Z, getExitZ()); + } + + public int getExitX() { + return dataWatcher.getWatchableObjectInt(20); + } + + public int getExitY() { + return dataWatcher.getWatchableObjectInt(21); + } + + public int getExitZ() { + return dataWatcher.getWatchableObjectInt(22); + } + + public void setExit(int x, int y, int z) { + dataWatcher.updateObject(20, x); + dataWatcher.updateObject(21, y); + dataWatcher.updateObject(22, z); + } + } } diff --git a/src/main/java/vazkii/botania/common/block/tile/TileManaBeacon.java b/src/main/java/vazkii/botania/common/block/tile/TileManaBeacon.java index d4d0936d81..a84c46fa1e 100644 --- a/src/main/java/vazkii/botania/common/block/tile/TileManaBeacon.java +++ b/src/main/java/vazkii/botania/common/block/tile/TileManaBeacon.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Mar 3, 2014, 5:09:30 PM (GMT)] */ package vazkii.botania.common.block.tile; @@ -16,24 +16,46 @@ public class TileManaBeacon extends TileMod { - @Override - public void updateEntity() { - boolean redstone = false; - for(ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS) { - int redstoneSide = worldObj.getIndirectPowerLevelTo(xCoord + dir.offsetX, yCoord + dir.offsetY, zCoord + dir.offsetZ, dir.ordinal()); - if(redstoneSide > 0) - redstone = true; - } + @Override + public void updateEntity() { + boolean redstone = false; + for (ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS) { + int redstoneSide = worldObj.getIndirectPowerLevelTo( + xCoord + dir.offsetX, yCoord + dir.offsetY, zCoord + dir.offsetZ, dir.ordinal()); + if (redstoneSide > 0) redstone = true; + } - if(!redstone) { - float[] color = EntitySheep.fleeceColorTable[worldObj.getBlockMetadata(xCoord, yCoord, zCoord)]; + if (!redstone) { + float[] color = EntitySheep.fleeceColorTable[worldObj.getBlockMetadata(xCoord, yCoord, zCoord)]; - Botania.proxy.setWispFXDistanceLimit(false); - Botania.proxy.wispFX(worldObj, xCoord + 0.5, yCoord + 0.5, zCoord + 0.5, color[0], color[1], color[2], (float) Math.random() * 5 + 1F, (float) (Math.random() - 0.5F), 10F * (float) Math.sqrt(256F / (256F - yCoord)), (float) (Math.random() - 0.5F)); + Botania.proxy.setWispFXDistanceLimit(false); + Botania.proxy.wispFX( + worldObj, + xCoord + 0.5, + yCoord + 0.5, + zCoord + 0.5, + color[0], + color[1], + color[2], + (float) Math.random() * 5 + 1F, + (float) (Math.random() - 0.5F), + 10F * (float) Math.sqrt(256F / (256F - yCoord)), + (float) (Math.random() - 0.5F)); - for(int i = 0; i < 2; i++) - Botania.proxy.wispFX(worldObj, xCoord + 0.5, 256, zCoord + 0.5, color[0], color[1], color[2], (float) Math.random() * 15 + 8F, (float) (Math.random() - 0.5F) * 8F, 0F, (float) (Math.random() - 0.5F) * 8F); - Botania.proxy.setWispFXDistanceLimit(true); - } - } + for (int i = 0; i < 2; i++) + Botania.proxy.wispFX( + worldObj, + xCoord + 0.5, + 256, + zCoord + 0.5, + color[0], + color[1], + color[2], + (float) Math.random() * 15 + 8F, + (float) (Math.random() - 0.5F) * 8F, + 0F, + (float) (Math.random() - 0.5F) * 8F); + Botania.proxy.setWispFXDistanceLimit(true); + } + } } diff --git a/src/main/java/vazkii/botania/common/block/tile/TileManaFlame.java b/src/main/java/vazkii/botania/common/block/tile/TileManaFlame.java index a1815d3ba8..70749e3de7 100644 --- a/src/main/java/vazkii/botania/common/block/tile/TileManaFlame.java +++ b/src/main/java/vazkii/botania/common/block/tile/TileManaFlame.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Dec 21, 2014, 12:33:12 AM (GMT)] */ package vazkii.botania.common.block.tile; @@ -16,63 +16,62 @@ public class TileManaFlame extends TileMod { - private static final String TAG_COLOR = "color"; + private static final String TAG_COLOR = "color"; - int color = 0x20FF20; + int color = 0x20FF20; - int lightColor = -1; + int lightColor = -1; - public void setColor(int color) { - this.color = color; - } + public void setColor(int color) { + this.color = color; + } - public int getColor() { - return color; - } + public int getColor() { + return color; + } - @Override - public void updateEntity() { - float c = 0.3F; + @Override + public void updateEntity() { + float c = 0.3F; - if(Math.random() < c) { - float v = 0.1F; + if (Math.random() < c) { + float v = 0.1F; - float r = (float) (color >> 16 & 0xFF) / 0xFF + (float) (Math.random() - 0.5) * v; - float g = (float) (color >> 8 & 0xFF) / 0xFF + (float) (Math.random() - 0.5) * v; - float b = (float) (color & 0xFF) / 0xFF + (float) (Math.random() - 0.5) * v; + float r = (float) (color >> 16 & 0xFF) / 0xFF + (float) (Math.random() - 0.5) * v; + float g = (float) (color >> 8 & 0xFF) / 0xFF + (float) (Math.random() - 0.5) * v; + float b = (float) (color & 0xFF) / 0xFF + (float) (Math.random() - 0.5) * v; - float w = 0.15F; - float h = 0.05F; - double x = xCoord + 0.5 + (Math.random() - 0.5) * w; - double y = yCoord + 0.25 + (Math.random() - 0.5) * h; - double z = zCoord + 0.5 + (Math.random() - 0.5) * w; + float w = 0.15F; + float h = 0.05F; + double x = xCoord + 0.5 + (Math.random() - 0.5) * w; + double y = yCoord + 0.25 + (Math.random() - 0.5) * h; + double z = zCoord + 0.5 + (Math.random() - 0.5) * w; - float s = 0.2F + (float) Math.random() * 0.1F; - float m = 0.03F + (float) Math.random() * 0.015F; + float s = 0.2F + (float) Math.random() * 0.1F; + float m = 0.03F + (float) Math.random() * 0.015F; - Botania.proxy.wispFX(worldObj, x, y, z, r, g, b, s, -m); - } - } + Botania.proxy.wispFX(worldObj, x, y, z, r, g, b, s, -m); + } + } - public int getLightColor() { - if(lightColor == -1) { - float r = (float) (color >> 16 & 0xFF) / 0xFF; - float g = (float) (color >> 8 & 0xFF) / 0xFF; - float b = (float) (color & 0xFF) / 0xFF; - lightColor = ColoredLightHelper.makeRGBLightValue(r, g, b, 1F); - } + public int getLightColor() { + if (lightColor == -1) { + float r = (float) (color >> 16 & 0xFF) / 0xFF; + float g = (float) (color >> 8 & 0xFF) / 0xFF; + float b = (float) (color & 0xFF) / 0xFF; + lightColor = ColoredLightHelper.makeRGBLightValue(r, g, b, 1F); + } - return lightColor; - } + return lightColor; + } - @Override - public void writeCustomNBT(NBTTagCompound cmp) { - cmp.setInteger(TAG_COLOR, color); - } - - @Override - public void readCustomNBT(NBTTagCompound cmp) { - color = cmp.getInteger(TAG_COLOR); - } + @Override + public void writeCustomNBT(NBTTagCompound cmp) { + cmp.setInteger(TAG_COLOR, color); + } + @Override + public void readCustomNBT(NBTTagCompound cmp) { + color = cmp.getInteger(TAG_COLOR); + } } diff --git a/src/main/java/vazkii/botania/common/block/tile/TileMod.java b/src/main/java/vazkii/botania/common/block/tile/TileMod.java index b1deaf4837..877656521a 100644 --- a/src/main/java/vazkii/botania/common/block/tile/TileMod.java +++ b/src/main/java/vazkii/botania/common/block/tile/TileMod.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jan 21, 2014, 9:18:28 PM (GMT)] */ package vazkii.botania.common.block.tile; @@ -18,39 +18,38 @@ public class TileMod extends TileEntity { - @Override - public void writeToNBT(NBTTagCompound par1nbtTagCompound) { - super.writeToNBT(par1nbtTagCompound); + @Override + public void writeToNBT(NBTTagCompound par1nbtTagCompound) { + super.writeToNBT(par1nbtTagCompound); - writeCustomNBT(par1nbtTagCompound); - } + writeCustomNBT(par1nbtTagCompound); + } - @Override - public void readFromNBT(NBTTagCompound par1nbtTagCompound) { - super.readFromNBT(par1nbtTagCompound); + @Override + public void readFromNBT(NBTTagCompound par1nbtTagCompound) { + super.readFromNBT(par1nbtTagCompound); - readCustomNBT(par1nbtTagCompound); - } + readCustomNBT(par1nbtTagCompound); + } - public void writeCustomNBT(NBTTagCompound cmp) { - // NO-OP - } + public void writeCustomNBT(NBTTagCompound cmp) { + // NO-OP + } - public void readCustomNBT(NBTTagCompound cmp) { - // NO-OP - } + public void readCustomNBT(NBTTagCompound cmp) { + // NO-OP + } - @Override - public Packet getDescriptionPacket() { - NBTTagCompound nbttagcompound = new NBTTagCompound(); - writeCustomNBT(nbttagcompound); - return new S35PacketUpdateTileEntity(xCoord, yCoord, zCoord, -999, nbttagcompound); - } - - @Override - public void onDataPacket(NetworkManager net, S35PacketUpdateTileEntity packet) { - super.onDataPacket(net, packet); - readCustomNBT(packet.func_148857_g()); - } + @Override + public Packet getDescriptionPacket() { + NBTTagCompound nbttagcompound = new NBTTagCompound(); + writeCustomNBT(nbttagcompound); + return new S35PacketUpdateTileEntity(xCoord, yCoord, zCoord, -999, nbttagcompound); + } + @Override + public void onDataPacket(NetworkManager net, S35PacketUpdateTileEntity packet) { + super.onDataPacket(net, packet); + readCustomNBT(packet.func_148857_g()); + } } diff --git a/src/main/java/vazkii/botania/common/block/tile/TileOpenCrate.java b/src/main/java/vazkii/botania/common/block/tile/TileOpenCrate.java index 33f12dc652..c76e1e5967 100644 --- a/src/main/java/vazkii/botania/common/block/tile/TileOpenCrate.java +++ b/src/main/java/vazkii/botania/common/block/tile/TileOpenCrate.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [May 4, 2014, 12:51:05 PM (GMT)] */ package vazkii.botania.common.block.tile; @@ -19,58 +19,57 @@ public class TileOpenCrate extends TileSimpleInventory { - @Override - public int getSizeInventory() { - return 1; - } + @Override + public int getSizeInventory() { + return 1; + } - @Override - public String getInventoryName() { - return LibBlockNames.OPEN_CRATE; - } + @Override + public String getInventoryName() { + return LibBlockNames.OPEN_CRATE; + } - @Override - public void updateEntity() { - boolean redstone = false; - for(ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS) { - int redstoneSide = worldObj.getIndirectPowerLevelTo(xCoord + dir.offsetX, yCoord + dir.offsetY, zCoord + dir.offsetZ, dir.ordinal()); - if(redstoneSide > 0) { - redstone = true; - break; - } - } + @Override + public void updateEntity() { + boolean redstone = false; + for (ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS) { + int redstoneSide = worldObj.getIndirectPowerLevelTo( + xCoord + dir.offsetX, yCoord + dir.offsetY, zCoord + dir.offsetZ, dir.ordinal()); + if (redstoneSide > 0) { + redstone = true; + break; + } + } - if(canEject()) { - ItemStack stack = getStackInSlot(0); - if(stack != null) - eject(stack, redstone); - } - } + if (canEject()) { + ItemStack stack = getStackInSlot(0); + if (stack != null) eject(stack, redstone); + } + } - public boolean canEject() { - Block blockBelow = worldObj.getBlock(xCoord, yCoord - 1, zCoord); - return blockBelow.isAir(worldObj, xCoord, yCoord - 1, zCoord) || blockBelow.getCollisionBoundingBoxFromPool(worldObj, xCoord, yCoord - 1, zCoord) == null; - } + public boolean canEject() { + Block blockBelow = worldObj.getBlock(xCoord, yCoord - 1, zCoord); + return blockBelow.isAir(worldObj, xCoord, yCoord - 1, zCoord) + || blockBelow.getCollisionBoundingBoxFromPool(worldObj, xCoord, yCoord - 1, zCoord) == null; + } - public void eject(ItemStack stack, boolean redstone) { - EntityItem item = new EntityItem(worldObj, xCoord + 0.5, yCoord - 0.5, zCoord + 0.5, stack); - item.motionX = 0; - item.motionY = 0; - item.motionZ = 0; + public void eject(ItemStack stack, boolean redstone) { + EntityItem item = new EntityItem(worldObj, xCoord + 0.5, yCoord - 0.5, zCoord + 0.5, stack); + item.motionX = 0; + item.motionY = 0; + item.motionZ = 0; - if(redstone) - item.age = -200; + if (redstone) item.age = -200; - setInventorySlotContents(0, null); - if(!worldObj.isRemote) - worldObj.spawnEntityInWorld(item); - } + setInventorySlotContents(0, null); + if (!worldObj.isRemote) worldObj.spawnEntityInWorld(item); + } - public boolean onWanded(EntityPlayer player, ItemStack stack) { - return false; - } + public boolean onWanded(EntityPlayer player, ItemStack stack) { + return false; + } - public int getSignal() { - return 0; - } + public int getSignal() { + return 0; + } } diff --git a/src/main/java/vazkii/botania/common/block/tile/TilePlatform.java b/src/main/java/vazkii/botania/common/block/tile/TilePlatform.java index 416ca3eb23..48dd96552e 100644 --- a/src/main/java/vazkii/botania/common/block/tile/TilePlatform.java +++ b/src/main/java/vazkii/botania/common/block/tile/TilePlatform.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jun 7, 2014, 2:24:51 PM (GMT)] */ package vazkii.botania.common.block.tile; @@ -17,45 +17,42 @@ public class TilePlatform extends TileCamo implements IManaCollisionGhost { - @Override - public boolean isGhost() { - return true; - } - - public boolean onWanded(EntityPlayer player) { - if(player != null) { - if(camo == null || player.isSneaking()) - swapSelfAndPass(this, true); - else swapSurroudings(this, false); - return true; - } - - return false; - } - - void swapSelfAndPass(TilePlatform tile, boolean empty) { - swap(tile, empty); - swapSurroudings(tile, empty); - } - - void swapSurroudings(TilePlatform tile, boolean empty) { - for(ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS) { - int x = tile.xCoord + dir.offsetX; - int y = tile.yCoord + dir.offsetY; - int z = tile.zCoord + dir.offsetZ; - TileEntity tileAt = worldObj.getTileEntity(x, y, z); - if(tileAt != null && tileAt instanceof TilePlatform) { - TilePlatform platform = (TilePlatform) tileAt; - if(empty ? platform.camo != null : platform.camo == null) - swapSelfAndPass(platform, empty); - } - } - } - - void swap(TilePlatform tile, boolean empty) { - tile.camo = empty ? null : camo; - tile.camoMeta = empty ? 0 : camoMeta; - worldObj.markBlockForUpdate(tile.xCoord, tile.yCoord, tile.zCoord); - } - + @Override + public boolean isGhost() { + return true; + } + + public boolean onWanded(EntityPlayer player) { + if (player != null) { + if (camo == null || player.isSneaking()) swapSelfAndPass(this, true); + else swapSurroudings(this, false); + return true; + } + + return false; + } + + void swapSelfAndPass(TilePlatform tile, boolean empty) { + swap(tile, empty); + swapSurroudings(tile, empty); + } + + void swapSurroudings(TilePlatform tile, boolean empty) { + for (ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS) { + int x = tile.xCoord + dir.offsetX; + int y = tile.yCoord + dir.offsetY; + int z = tile.zCoord + dir.offsetZ; + TileEntity tileAt = worldObj.getTileEntity(x, y, z); + if (tileAt != null && tileAt instanceof TilePlatform) { + TilePlatform platform = (TilePlatform) tileAt; + if (empty ? platform.camo != null : platform.camo == null) swapSelfAndPass(platform, empty); + } + } + } + + void swap(TilePlatform tile, boolean empty) { + tile.camo = empty ? null : camo; + tile.camoMeta = empty ? 0 : camoMeta; + worldObj.markBlockForUpdate(tile.xCoord, tile.yCoord, tile.zCoord); + } } diff --git a/src/main/java/vazkii/botania/common/block/tile/TilePylon.java b/src/main/java/vazkii/botania/common/block/tile/TilePylon.java index a3b89b029d..ac6c3f3d5d 100644 --- a/src/main/java/vazkii/botania/common/block/tile/TilePylon.java +++ b/src/main/java/vazkii/botania/common/block/tile/TilePylon.java @@ -2,16 +2,15 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Feb 18, 2014, 10:15:50 PM (GMT)] */ package vazkii.botania.common.block.tile; import java.util.Random; - import net.minecraft.block.Block; import net.minecraft.entity.passive.EntitySheep; import net.minecraft.tileentity.TileEntity; @@ -22,68 +21,135 @@ public class TilePylon extends TileEntity { - boolean activated = false; - int centerX, centerY, centerZ; - int ticks = 0; - - - - @Override - public void updateEntity() { - ++ticks; - int meta = getBlockMetadata(); - - if(activated && worldObj.isRemote) { - if(worldObj.getBlock(centerX, centerY, centerZ) != getBlockForMeta() || meta != 0 && worldObj.getBlockMetadata(centerX, centerY, centerZ) == 0) { - activated = false; - return; - } - - Vector3 centerBlock = new Vector3(centerX + 0.5, centerY + 0.75 + (Math.random() - 0.5 * 0.25), centerZ + 0.5); - - if(meta == 1) { - if(ConfigHandler.elfPortalParticlesEnabled) { - double worldTime = ticks; - worldTime += new Random(xCoord ^ yCoord ^ zCoord).nextInt(1000); - worldTime /= 5; - - float r = 0.75F + (float) Math.random() * 0.05F; - double x = xCoord + 0.5 + Math.cos(worldTime) * r; - double z = zCoord + 0.5 + Math.sin(worldTime) * r; - - Vector3 ourCoords = new Vector3(x, yCoord + 0.25, z); - centerBlock.sub(new Vector3(0, 0.5, 0)); - Vector3 movementVector = centerBlock.sub(ourCoords).normalize().multiply(0.2); - - Botania.proxy.wispFX(worldObj, x, yCoord + 0.25, z, (float) Math.random() * 0.25F, 0.75F + (float) Math.random() * 0.25F, (float) Math.random() * 0.25F, 0.25F + (float) Math.random() * 0.1F, -0.075F - (float) Math.random() * 0.015F); - if(worldObj.rand.nextInt(3) == 0) - Botania.proxy.wispFX(worldObj, x, yCoord + 0.25, z, (float) Math.random() * 0.25F, 0.75F + (float) Math.random() * 0.25F, (float) Math.random() * 0.25F, 0.25F + (float) Math.random() * 0.1F, (float) movementVector.x, (float) movementVector.y, (float) movementVector.z); - } - } else { - Vector3 ourCoords = Vector3.fromTileEntityCenter(this).add(0, 1 + (Math.random() - 0.5 * 0.25), 0); - Vector3 movementVector = centerBlock.sub(ourCoords).normalize().multiply(0.2); - - Block block = worldObj.getBlock(xCoord, yCoord - 1, zCoord); - if(block == ModBlocks.flower || block == ModBlocks.shinyFlower) { - int fmeta = worldObj.getBlockMetadata(xCoord, yCoord - 1, zCoord); - float[] color = EntitySheep.fleeceColorTable[fmeta]; - - if(worldObj.rand.nextInt(4) == 0) - Botania.proxy.sparkleFX(worldObj, centerBlock.x + (Math.random() - 0.5) * 0.5, centerBlock.y, centerBlock.z + (Math.random() - 0.5) * 0.5, color[0], color[1], color[2], (float) Math.random(), 8); - - Botania.proxy.wispFX(worldObj, xCoord + 0.5 + (Math.random() - 0.5) * 0.25, yCoord - 0.5, zCoord + 0.5 + (Math.random() - 0.5) * 0.25, color[0], color[1], color[2], (float) Math.random() / 3F, -0.04F); - Botania.proxy.wispFX(worldObj, xCoord + 0.5 + (Math.random() - 0.5) * 0.125, yCoord + 1.5, zCoord + 0.5 + (Math.random() - 0.5) * 0.125, color[0], color[1], color[2], (float) Math.random() / 5F, -0.001F); - Botania.proxy.wispFX(worldObj, xCoord + 0.5 + (Math.random() - 0.5) * 0.25, yCoord + 1.5, zCoord + 0.5 + (Math.random() - 0.5) * 0.25, color[0], color[1], color[2], (float) Math.random() / 8F, (float) movementVector.x, (float) movementVector.y, (float) movementVector.z); - } - } - } - - if(worldObj.rand.nextBoolean() && worldObj.isRemote) - Botania.proxy.sparkleFX(worldObj, xCoord + Math.random(), yCoord + Math.random() * 1.5, zCoord + Math.random(), meta == 2 ? 1F : 0.5F, meta == 1 ? 1F : 0.5F, meta == 1 ? 0.5F : 1F, (float) Math.random(), 2); - } - - private Block getBlockForMeta() { - return getBlockMetadata() == 0 ? ModBlocks.enchanter : ModBlocks.alfPortal; - } - -} \ No newline at end of file + boolean activated = false; + int centerX, centerY, centerZ; + int ticks = 0; + + @Override + public void updateEntity() { + ++ticks; + int meta = getBlockMetadata(); + + if (activated && worldObj.isRemote) { + if (worldObj.getBlock(centerX, centerY, centerZ) != getBlockForMeta() + || meta != 0 && worldObj.getBlockMetadata(centerX, centerY, centerZ) == 0) { + activated = false; + return; + } + + Vector3 centerBlock = + new Vector3(centerX + 0.5, centerY + 0.75 + (Math.random() - 0.5 * 0.25), centerZ + 0.5); + + if (meta == 1) { + if (ConfigHandler.elfPortalParticlesEnabled) { + double worldTime = ticks; + worldTime += new Random(xCoord ^ yCoord ^ zCoord).nextInt(1000); + worldTime /= 5; + + float r = 0.75F + (float) Math.random() * 0.05F; + double x = xCoord + 0.5 + Math.cos(worldTime) * r; + double z = zCoord + 0.5 + Math.sin(worldTime) * r; + + Vector3 ourCoords = new Vector3(x, yCoord + 0.25, z); + centerBlock.sub(new Vector3(0, 0.5, 0)); + Vector3 movementVector = + centerBlock.sub(ourCoords).normalize().multiply(0.2); + + Botania.proxy.wispFX( + worldObj, + x, + yCoord + 0.25, + z, + (float) Math.random() * 0.25F, + 0.75F + (float) Math.random() * 0.25F, + (float) Math.random() * 0.25F, + 0.25F + (float) Math.random() * 0.1F, + -0.075F - (float) Math.random() * 0.015F); + if (worldObj.rand.nextInt(3) == 0) + Botania.proxy.wispFX( + worldObj, + x, + yCoord + 0.25, + z, + (float) Math.random() * 0.25F, + 0.75F + (float) Math.random() * 0.25F, + (float) Math.random() * 0.25F, + 0.25F + (float) Math.random() * 0.1F, + (float) movementVector.x, + (float) movementVector.y, + (float) movementVector.z); + } + } else { + Vector3 ourCoords = Vector3.fromTileEntityCenter(this).add(0, 1 + (Math.random() - 0.5 * 0.25), 0); + Vector3 movementVector = centerBlock.sub(ourCoords).normalize().multiply(0.2); + + Block block = worldObj.getBlock(xCoord, yCoord - 1, zCoord); + if (block == ModBlocks.flower || block == ModBlocks.shinyFlower) { + int fmeta = worldObj.getBlockMetadata(xCoord, yCoord - 1, zCoord); + float[] color = EntitySheep.fleeceColorTable[fmeta]; + + if (worldObj.rand.nextInt(4) == 0) + Botania.proxy.sparkleFX( + worldObj, + centerBlock.x + (Math.random() - 0.5) * 0.5, + centerBlock.y, + centerBlock.z + (Math.random() - 0.5) * 0.5, + color[0], + color[1], + color[2], + (float) Math.random(), + 8); + + Botania.proxy.wispFX( + worldObj, + xCoord + 0.5 + (Math.random() - 0.5) * 0.25, + yCoord - 0.5, + zCoord + 0.5 + (Math.random() - 0.5) * 0.25, + color[0], + color[1], + color[2], + (float) Math.random() / 3F, + -0.04F); + Botania.proxy.wispFX( + worldObj, + xCoord + 0.5 + (Math.random() - 0.5) * 0.125, + yCoord + 1.5, + zCoord + 0.5 + (Math.random() - 0.5) * 0.125, + color[0], + color[1], + color[2], + (float) Math.random() / 5F, + -0.001F); + Botania.proxy.wispFX( + worldObj, + xCoord + 0.5 + (Math.random() - 0.5) * 0.25, + yCoord + 1.5, + zCoord + 0.5 + (Math.random() - 0.5) * 0.25, + color[0], + color[1], + color[2], + (float) Math.random() / 8F, + (float) movementVector.x, + (float) movementVector.y, + (float) movementVector.z); + } + } + } + + if (worldObj.rand.nextBoolean() && worldObj.isRemote) + Botania.proxy.sparkleFX( + worldObj, + xCoord + Math.random(), + yCoord + Math.random() * 1.5, + zCoord + Math.random(), + meta == 2 ? 1F : 0.5F, + meta == 1 ? 1F : 0.5F, + meta == 1 ? 0.5F : 1F, + (float) Math.random(), + 2); + } + + private Block getBlockForMeta() { + return getBlockMetadata() == 0 ? ModBlocks.enchanter : ModBlocks.alfPortal; + } +} diff --git a/src/main/java/vazkii/botania/common/block/tile/TileRuneAltar.java b/src/main/java/vazkii/botania/common/block/tile/TileRuneAltar.java index 0ac4be2be4..e65726b4d8 100644 --- a/src/main/java/vazkii/botania/common/block/tile/TileRuneAltar.java +++ b/src/main/java/vazkii/botania/common/block/tile/TileRuneAltar.java @@ -2,17 +2,16 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Feb 2, 2014, 6:31:19 PM (GMT)] */ package vazkii.botania.common.block.tile; import java.util.ArrayList; import java.util.List; - import net.minecraft.client.Minecraft; import net.minecraft.client.gui.ScaledResolution; import net.minecraft.client.renderer.entity.RenderItem; @@ -24,10 +23,8 @@ import net.minecraft.nbt.NBTTagCompound; import net.minecraft.util.AxisAlignedBB; import net.minecraft.util.StatCollector; - import org.lwjgl.opengl.GL11; import org.lwjgl.opengl.GL12; - import vazkii.botania.api.BotaniaAPI; import vazkii.botania.api.internal.VanillaPacketDispatcher; import vazkii.botania.api.mana.IManaReceiver; @@ -42,378 +39,399 @@ public class TileRuneAltar extends TileSimpleInventory implements ISidedInventory, IManaReceiver { - private static final String TAG_MANA = "mana"; - private static final String TAG_MANA_TO_GET = "manaToGet"; - - RecipeRuneAltar currentRecipe; - - public int manaToGet = 0; - int mana = 0; - int cooldown = 0; - public int signal = 0; - - List lastRecipe = null; - int recipeKeepTicks = 0; - - public boolean addItem(EntityPlayer player, ItemStack stack) { - if(cooldown > 0 || stack.getItem() == ModItems.twigWand || stack.getItem() == ModItems.lexicon) - return false; - - if(stack.getItem() == Item.getItemFromBlock(ModBlocks.livingrock) && stack.getItemDamage() == 0) { - if(player == null || !player.capabilities.isCreativeMode) { - stack.stackSize--; - if(stack.stackSize == 0 && player != null) - player.inventory.setInventorySlotContents(player.inventory.currentItem, null); - } - - EntityItem item = new EntityItem(worldObj, xCoord + 0.5, yCoord + 1, zCoord + 0.5, new ItemStack(ModBlocks.livingrock)); - item.delayBeforeCanPickup = 40; - item.motionX = item.motionY = item.motionZ = 0; - if(!worldObj.isRemote) - worldObj.spawnEntityInWorld(item); - - return true; - } - - if(manaToGet != 0) - return false; - - boolean did = false; - - for(int i = 0; i < getSizeInventory(); i++) - if(getStackInSlot(i) == null) { - did = true; - ItemStack stackToAdd = stack.copy(); - stackToAdd.stackSize = 1; - setInventorySlotContents(i, stackToAdd); - - if(player == null || !player.capabilities.isCreativeMode) { - stack.stackSize--; - if(stack.stackSize == 0 && player != null) - player.inventory.setInventorySlotContents(player.inventory.currentItem, null); - } - - break; - } - - if(did) - VanillaPacketDispatcher.dispatchTEToNearbyPlayers(worldObj, xCoord, yCoord, zCoord); - - return true; - } - - @Override - public void updateEntity() { - super.updateEntity(); - - // Update every tick. - recieveMana(0); - - if(!worldObj.isRemote && manaToGet == 0) { - List items = worldObj.getEntitiesWithinAABB(EntityItem.class, AxisAlignedBB.getBoundingBox(xCoord, yCoord, zCoord, xCoord + 1, yCoord + 1, zCoord + 1)); - for(EntityItem item : items) - if(!item.isDead && item.getEntityItem() != null && item.getEntityItem().getItem() != Item.getItemFromBlock(ModBlocks.livingrock)) { - ItemStack stack = item.getEntityItem(); - if(addItem(null, stack) && stack.stackSize == 0) - item.setDead(); - } - } - - - if(worldObj.isRemote && manaToGet > 0 && mana >= manaToGet) { - if(worldObj.rand.nextInt(20) == 0) { - Vector3 vec = Vector3.fromTileEntityCenter(this); - Vector3 endVec = vec.copy().add(0, 2.5, 0); - Botania.proxy.lightningFX(worldObj, vec, endVec, 2F, 0x00948B, 0x00E4D7); - } - } - - if(cooldown > 0) { - cooldown--; - Botania.proxy.wispFX(getWorldObj(), xCoord + Math.random(), yCoord + 0.8, zCoord + Math.random(), 0.2F, 0.2F, 0.2F, 0.2F, -0.025F); - } - - int newSignal = 0; - if(manaToGet > 0) { - newSignal++; - if(mana >= manaToGet) - newSignal++; - } - - if(newSignal != signal) { - signal = newSignal; - worldObj.func_147453_f(xCoord, yCoord, zCoord, worldObj.getBlock(xCoord, yCoord, zCoord)); - } - - if(recipeKeepTicks > 0) - --recipeKeepTicks; - else lastRecipe = null; - - updateRecipe(); - } - - public void updateRecipe() { - int manaToGet = this.manaToGet; - - getMana : { - if(currentRecipe != null) - this.manaToGet = currentRecipe.getManaUsage(); - else { - for(RecipeRuneAltar recipe : BotaniaAPI.runeAltarRecipes) - if(recipe.matches(this)) { - this.manaToGet = recipe.getManaUsage(); - break getMana; - } - this.manaToGet = 0; - } - } - - if(manaToGet != this.manaToGet) { - worldObj.playSoundEffect(xCoord, yCoord, zCoord, "botania:runeAltarStart", 1F, 1F); - VanillaPacketDispatcher.dispatchTEToNearbyPlayers(worldObj, xCoord, yCoord, zCoord); - } - } - - public void saveLastRecipe() { - lastRecipe = new ArrayList(); - for(int i = 0; i < getSizeInventory(); i++) { - ItemStack stack = getStackInSlot(i); - if(stack == null) - break; - lastRecipe.add(stack.copy()); - } - recipeKeepTicks = 400; - } - - public void trySetLastRecipe(EntityPlayer player) { - TileAltar.tryToSetLastRecipe(player, this, lastRecipe); - if(!isEmpty()) - VanillaPacketDispatcher.dispatchTEToNearbyPlayers(worldObj, xCoord, yCoord, zCoord); - } - - public boolean hasValidRecipe() { - for(RecipeRuneAltar recipe : BotaniaAPI.runeAltarRecipes) - if(recipe.matches(this)) - return true; - - return false; - } - - public void onWanded(EntityPlayer player, ItemStack wand) { - RecipeRuneAltar recipe = null; - - if(currentRecipe != null) - recipe = currentRecipe; - else for(RecipeRuneAltar recipe_ : BotaniaAPI.runeAltarRecipes) { - if(recipe_.matches(this)) { - recipe = recipe_; - break; - } - } - - if(manaToGet > 0 && mana >= manaToGet) { - List items = worldObj.getEntitiesWithinAABB(EntityItem.class, AxisAlignedBB.getBoundingBox(xCoord, yCoord, zCoord, xCoord + 1, yCoord + 1, zCoord + 1)); - EntityItem livingrock = null; - for(EntityItem item : items) - if(!item.isDead && item.getEntityItem() != null && item.getEntityItem().getItem() == Item.getItemFromBlock(ModBlocks.livingrock)) { - livingrock = item; - break; - } - - if(livingrock != null) { - int mana = recipe.getManaUsage(); - recieveMana(-mana); - if(!worldObj.isRemote) { - ItemStack output = recipe.getOutput().copy(); - EntityItem outputItem = new EntityItem(worldObj, xCoord + 0.5, yCoord + 1.5, zCoord + 0.5, output); - worldObj.spawnEntityInWorld(outputItem); - currentRecipe = null; - cooldown = 60; - } - - saveLastRecipe(); - if(!worldObj.isRemote) { - for(int i = 0; i < getSizeInventory(); i++) { - ItemStack stack = getStackInSlot(i); - if(stack != null) { - if(stack.getItem() == ModItems.rune && (player == null || !player.capabilities.isCreativeMode)) { - EntityItem outputItem = new EntityItem(worldObj, xCoord + 0.5, yCoord + 1.5, zCoord + 0.5, stack.copy()); - worldObj.spawnEntityInWorld(outputItem); - } - - setInventorySlotContents(i, null); - } - } - - ItemStack livingrockItem = livingrock.getEntityItem(); - livingrockItem.stackSize--; - if(livingrockItem.stackSize == 0) - livingrock.setDead(); - } - - craftingFanciness(); - } - } - } - - public void craftingFanciness() { - worldObj.playSoundEffect(xCoord, yCoord, zCoord, "botania:runeAltarCraft", 1F, 1F); - for(int i = 0; i < 25; i++) { - float red = (float) Math.random(); - float green = (float) Math.random(); - float blue = (float) Math.random(); - Botania.proxy.sparkleFX(worldObj, xCoord + 0.5 + Math.random() * 0.4 - 0.2, yCoord + 1, zCoord + 0.5 + Math.random() * 0.4 - 0.2, red, green, blue, (float) Math.random(), 10); - } - } - - public boolean isEmpty() { - for(int i = 0; i < getSizeInventory(); i++) - if(getStackInSlot(i) != null) - return false; - - return true; - } - - @Override - public void writeCustomNBT(NBTTagCompound par1nbtTagCompound) { - super.writeCustomNBT(par1nbtTagCompound); - - par1nbtTagCompound.setInteger(TAG_MANA, mana); - par1nbtTagCompound.setInteger(TAG_MANA_TO_GET, manaToGet); - } - - @Override - public void readCustomNBT(NBTTagCompound par1nbtTagCompound) { - super.readCustomNBT(par1nbtTagCompound); - - mana = par1nbtTagCompound.getInteger(TAG_MANA); - manaToGet = par1nbtTagCompound.getInteger(TAG_MANA_TO_GET); - } - - @Override - public int getSizeInventory() { - return 16; - } - - @Override - public AxisAlignedBB getRenderBoundingBox() { - return INFINITE_EXTENT_AABB; - } - - @Override - public String getInventoryName() { - return LibBlockNames.RUNE_ALTAR; - } - - @Override - public int getInventoryStackLimit() { - return 1; - } - - @Override - public int[] getAccessibleSlotsFromSide(int var1) { - int accessibleSlot = -1; - for(int i = 0; i < getSizeInventory(); i++) - if(getStackInSlot(i) != null) - accessibleSlot = i; - - return accessibleSlot == -1 ? new int[0] : new int[] { accessibleSlot }; - } - - @Override - public boolean canInsertItem(int i, ItemStack itemstack, int j) { - return true; - } - - @Override - public boolean canExtractItem(int i, ItemStack itemstack, int j) { - return mana == 0; - } - - @Override - public int getCurrentMana() { - return mana; - } - - @Override - public boolean isFull() { - return mana >= manaToGet; - } - - @Override - public void recieveMana(int mana) { - this.mana = Math.min(this.mana + mana, manaToGet); - } - - @Override - public boolean canRecieveManaFromBursts() { - return !isFull(); - } - - public void renderHUD(Minecraft mc, ScaledResolution res) { - int xc = res.getScaledWidth() / 2; - int yc = res.getScaledHeight() / 2; - - float angle = -90; - int radius = 24; - int amt = 0; - for(int i = 0; i < getSizeInventory(); i++) { - if(getStackInSlot(i) == null) - break; - amt++; - } - - if(amt > 0) { - float anglePer = 360F / amt; - for(RecipeRuneAltar recipe : BotaniaAPI.runeAltarRecipes) - if(recipe.matches(this)) { - GL11.glEnable(GL11.GL_BLEND); - GL11.glEnable(GL12.GL_RESCALE_NORMAL); - GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); - - recipe.getOutput(); - float progress = (float) mana / (float) manaToGet; - - mc.renderEngine.bindTexture(HUDHandler.manaBar); - GL11.glColor4f(1F, 1F, 1F, 1F); - RenderHelper.drawTexturedModalRect(xc + radius + 9, yc - 8, 0, progress == 1F ? 0 : 22, 8, 22, 15); - - net.minecraft.client.renderer.RenderHelper.enableGUIStandardItemLighting(); - if(progress == 1F) { - RenderItem.getInstance().renderItemIntoGUI(mc.fontRenderer, mc.renderEngine, new ItemStack(ModBlocks.livingrock), xc + radius + 16, yc + 8); - GL11.glTranslatef(0F, 0F, 100F); - RenderItem.getInstance().renderItemIntoGUI(mc.fontRenderer, mc.renderEngine, new ItemStack(ModItems.twigWand), xc + radius + 24, yc + 8); - GL11.glTranslatef(0F, 0F, -100F); - } - - RenderHelper.renderProgressPie(xc + radius + 32, yc - 8, progress, recipe.getOutput()); - net.minecraft.client.renderer.RenderHelper.disableStandardItemLighting(); - - if(progress == 1F) - mc.fontRenderer.drawStringWithShadow("+", xc + radius + 14, yc + 12, 0xFFFFFF); - } - - net.minecraft.client.renderer.RenderHelper.enableGUIStandardItemLighting(); - for(int i = 0; i < amt; i++) { - double xPos = xc + Math.cos(angle * Math.PI / 180D) * radius - 8; - double yPos = yc + Math.sin(angle * Math.PI / 180D) * radius - 8; - GL11.glTranslated(xPos, yPos, 0); - RenderItem.getInstance().renderItemIntoGUI(mc.fontRenderer, mc.renderEngine, getStackInSlot(i), 0, 0); - GL11.glTranslated(-xPos, -yPos, 0); - - angle += anglePer; - } - net.minecraft.client.renderer.RenderHelper.disableStandardItemLighting(); - } else if(recipeKeepTicks > 0) { - String s = StatCollector.translateToLocal("botaniamisc.altarRefill0"); - mc.fontRenderer.drawStringWithShadow(s, xc - mc.fontRenderer.getStringWidth(s) / 2, yc + 10, 0xFFFFFF); - s = StatCollector.translateToLocal("botaniamisc.altarRefill1"); - mc.fontRenderer.drawStringWithShadow(s, xc - mc.fontRenderer.getStringWidth(s) / 2, yc + 20, 0xFFFFFF); - } - } - - public int getTargetMana() { - return manaToGet; - } - + private static final String TAG_MANA = "mana"; + private static final String TAG_MANA_TO_GET = "manaToGet"; + + RecipeRuneAltar currentRecipe; + + public int manaToGet = 0; + int mana = 0; + int cooldown = 0; + public int signal = 0; + + List lastRecipe = null; + int recipeKeepTicks = 0; + + public boolean addItem(EntityPlayer player, ItemStack stack) { + if (cooldown > 0 || stack.getItem() == ModItems.twigWand || stack.getItem() == ModItems.lexicon) return false; + + if (stack.getItem() == Item.getItemFromBlock(ModBlocks.livingrock) && stack.getItemDamage() == 0) { + if (player == null || !player.capabilities.isCreativeMode) { + stack.stackSize--; + if (stack.stackSize == 0 && player != null) + player.inventory.setInventorySlotContents(player.inventory.currentItem, null); + } + + EntityItem item = new EntityItem( + worldObj, xCoord + 0.5, yCoord + 1, zCoord + 0.5, new ItemStack(ModBlocks.livingrock)); + item.delayBeforeCanPickup = 40; + item.motionX = item.motionY = item.motionZ = 0; + if (!worldObj.isRemote) worldObj.spawnEntityInWorld(item); + + return true; + } + + if (manaToGet != 0) return false; + + boolean did = false; + + for (int i = 0; i < getSizeInventory(); i++) + if (getStackInSlot(i) == null) { + did = true; + ItemStack stackToAdd = stack.copy(); + stackToAdd.stackSize = 1; + setInventorySlotContents(i, stackToAdd); + + if (player == null || !player.capabilities.isCreativeMode) { + stack.stackSize--; + if (stack.stackSize == 0 && player != null) + player.inventory.setInventorySlotContents(player.inventory.currentItem, null); + } + + break; + } + + if (did) VanillaPacketDispatcher.dispatchTEToNearbyPlayers(worldObj, xCoord, yCoord, zCoord); + + return true; + } + + @Override + public void updateEntity() { + super.updateEntity(); + + // Update every tick. + recieveMana(0); + + if (!worldObj.isRemote && manaToGet == 0) { + List items = worldObj.getEntitiesWithinAABB( + EntityItem.class, + AxisAlignedBB.getBoundingBox(xCoord, yCoord, zCoord, xCoord + 1, yCoord + 1, zCoord + 1)); + for (EntityItem item : items) + if (!item.isDead + && item.getEntityItem() != null + && item.getEntityItem().getItem() != Item.getItemFromBlock(ModBlocks.livingrock)) { + ItemStack stack = item.getEntityItem(); + if (addItem(null, stack) && stack.stackSize == 0) item.setDead(); + } + } + + if (worldObj.isRemote && manaToGet > 0 && mana >= manaToGet) { + if (worldObj.rand.nextInt(20) == 0) { + Vector3 vec = Vector3.fromTileEntityCenter(this); + Vector3 endVec = vec.copy().add(0, 2.5, 0); + Botania.proxy.lightningFX(worldObj, vec, endVec, 2F, 0x00948B, 0x00E4D7); + } + } + + if (cooldown > 0) { + cooldown--; + Botania.proxy.wispFX( + getWorldObj(), + xCoord + Math.random(), + yCoord + 0.8, + zCoord + Math.random(), + 0.2F, + 0.2F, + 0.2F, + 0.2F, + -0.025F); + } + + int newSignal = 0; + if (manaToGet > 0) { + newSignal++; + if (mana >= manaToGet) newSignal++; + } + + if (newSignal != signal) { + signal = newSignal; + worldObj.func_147453_f(xCoord, yCoord, zCoord, worldObj.getBlock(xCoord, yCoord, zCoord)); + } + + if (recipeKeepTicks > 0) --recipeKeepTicks; + else lastRecipe = null; + + updateRecipe(); + } + + public void updateRecipe() { + int manaToGet = this.manaToGet; + + getMana: + { + if (currentRecipe != null) this.manaToGet = currentRecipe.getManaUsage(); + else { + for (RecipeRuneAltar recipe : BotaniaAPI.runeAltarRecipes) + if (recipe.matches(this)) { + this.manaToGet = recipe.getManaUsage(); + break getMana; + } + this.manaToGet = 0; + } + } + + if (manaToGet != this.manaToGet) { + worldObj.playSoundEffect(xCoord, yCoord, zCoord, "botania:runeAltarStart", 1F, 1F); + VanillaPacketDispatcher.dispatchTEToNearbyPlayers(worldObj, xCoord, yCoord, zCoord); + } + } + + public void saveLastRecipe() { + lastRecipe = new ArrayList(); + for (int i = 0; i < getSizeInventory(); i++) { + ItemStack stack = getStackInSlot(i); + if (stack == null) break; + lastRecipe.add(stack.copy()); + } + recipeKeepTicks = 400; + } + + public void trySetLastRecipe(EntityPlayer player) { + TileAltar.tryToSetLastRecipe(player, this, lastRecipe); + if (!isEmpty()) VanillaPacketDispatcher.dispatchTEToNearbyPlayers(worldObj, xCoord, yCoord, zCoord); + } + + public boolean hasValidRecipe() { + for (RecipeRuneAltar recipe : BotaniaAPI.runeAltarRecipes) if (recipe.matches(this)) return true; + + return false; + } + + public void onWanded(EntityPlayer player, ItemStack wand) { + RecipeRuneAltar recipe = null; + + if (currentRecipe != null) recipe = currentRecipe; + else + for (RecipeRuneAltar recipe_ : BotaniaAPI.runeAltarRecipes) { + if (recipe_.matches(this)) { + recipe = recipe_; + break; + } + } + + if (manaToGet > 0 && mana >= manaToGet) { + List items = worldObj.getEntitiesWithinAABB( + EntityItem.class, + AxisAlignedBB.getBoundingBox(xCoord, yCoord, zCoord, xCoord + 1, yCoord + 1, zCoord + 1)); + EntityItem livingrock = null; + for (EntityItem item : items) + if (!item.isDead + && item.getEntityItem() != null + && item.getEntityItem().getItem() == Item.getItemFromBlock(ModBlocks.livingrock)) { + livingrock = item; + break; + } + + if (livingrock != null) { + int mana = recipe.getManaUsage(); + recieveMana(-mana); + if (!worldObj.isRemote) { + ItemStack output = recipe.getOutput().copy(); + EntityItem outputItem = new EntityItem(worldObj, xCoord + 0.5, yCoord + 1.5, zCoord + 0.5, output); + worldObj.spawnEntityInWorld(outputItem); + currentRecipe = null; + cooldown = 60; + } + + saveLastRecipe(); + if (!worldObj.isRemote) { + for (int i = 0; i < getSizeInventory(); i++) { + ItemStack stack = getStackInSlot(i); + if (stack != null) { + if (stack.getItem() == ModItems.rune + && (player == null || !player.capabilities.isCreativeMode)) { + EntityItem outputItem = new EntityItem( + worldObj, xCoord + 0.5, yCoord + 1.5, zCoord + 0.5, stack.copy()); + worldObj.spawnEntityInWorld(outputItem); + } + + setInventorySlotContents(i, null); + } + } + + ItemStack livingrockItem = livingrock.getEntityItem(); + livingrockItem.stackSize--; + if (livingrockItem.stackSize == 0) livingrock.setDead(); + } + + craftingFanciness(); + } + } + } + + public void craftingFanciness() { + worldObj.playSoundEffect(xCoord, yCoord, zCoord, "botania:runeAltarCraft", 1F, 1F); + for (int i = 0; i < 25; i++) { + float red = (float) Math.random(); + float green = (float) Math.random(); + float blue = (float) Math.random(); + Botania.proxy.sparkleFX( + worldObj, + xCoord + 0.5 + Math.random() * 0.4 - 0.2, + yCoord + 1, + zCoord + 0.5 + Math.random() * 0.4 - 0.2, + red, + green, + blue, + (float) Math.random(), + 10); + } + } + + public boolean isEmpty() { + for (int i = 0; i < getSizeInventory(); i++) if (getStackInSlot(i) != null) return false; + + return true; + } + + @Override + public void writeCustomNBT(NBTTagCompound par1nbtTagCompound) { + super.writeCustomNBT(par1nbtTagCompound); + + par1nbtTagCompound.setInteger(TAG_MANA, mana); + par1nbtTagCompound.setInteger(TAG_MANA_TO_GET, manaToGet); + } + + @Override + public void readCustomNBT(NBTTagCompound par1nbtTagCompound) { + super.readCustomNBT(par1nbtTagCompound); + + mana = par1nbtTagCompound.getInteger(TAG_MANA); + manaToGet = par1nbtTagCompound.getInteger(TAG_MANA_TO_GET); + } + + @Override + public int getSizeInventory() { + return 16; + } + + @Override + public AxisAlignedBB getRenderBoundingBox() { + return INFINITE_EXTENT_AABB; + } + + @Override + public String getInventoryName() { + return LibBlockNames.RUNE_ALTAR; + } + + @Override + public int getInventoryStackLimit() { + return 1; + } + + @Override + public int[] getAccessibleSlotsFromSide(int var1) { + int accessibleSlot = -1; + for (int i = 0; i < getSizeInventory(); i++) if (getStackInSlot(i) != null) accessibleSlot = i; + + return accessibleSlot == -1 ? new int[0] : new int[] {accessibleSlot}; + } + + @Override + public boolean canInsertItem(int i, ItemStack itemstack, int j) { + return true; + } + + @Override + public boolean canExtractItem(int i, ItemStack itemstack, int j) { + return mana == 0; + } + + @Override + public int getCurrentMana() { + return mana; + } + + @Override + public boolean isFull() { + return mana >= manaToGet; + } + + @Override + public void recieveMana(int mana) { + this.mana = Math.min(this.mana + mana, manaToGet); + } + + @Override + public boolean canRecieveManaFromBursts() { + return !isFull(); + } + + public void renderHUD(Minecraft mc, ScaledResolution res) { + int xc = res.getScaledWidth() / 2; + int yc = res.getScaledHeight() / 2; + + float angle = -90; + int radius = 24; + int amt = 0; + for (int i = 0; i < getSizeInventory(); i++) { + if (getStackInSlot(i) == null) break; + amt++; + } + + if (amt > 0) { + float anglePer = 360F / amt; + for (RecipeRuneAltar recipe : BotaniaAPI.runeAltarRecipes) + if (recipe.matches(this)) { + GL11.glEnable(GL11.GL_BLEND); + GL11.glEnable(GL12.GL_RESCALE_NORMAL); + GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); + + recipe.getOutput(); + float progress = (float) mana / (float) manaToGet; + + mc.renderEngine.bindTexture(HUDHandler.manaBar); + GL11.glColor4f(1F, 1F, 1F, 1F); + RenderHelper.drawTexturedModalRect(xc + radius + 9, yc - 8, 0, progress == 1F ? 0 : 22, 8, 22, 15); + + net.minecraft.client.renderer.RenderHelper.enableGUIStandardItemLighting(); + if (progress == 1F) { + RenderItem.getInstance() + .renderItemIntoGUI( + mc.fontRenderer, + mc.renderEngine, + new ItemStack(ModBlocks.livingrock), + xc + radius + 16, + yc + 8); + GL11.glTranslatef(0F, 0F, 100F); + RenderItem.getInstance() + .renderItemIntoGUI( + mc.fontRenderer, + mc.renderEngine, + new ItemStack(ModItems.twigWand), + xc + radius + 24, + yc + 8); + GL11.glTranslatef(0F, 0F, -100F); + } + + RenderHelper.renderProgressPie(xc + radius + 32, yc - 8, progress, recipe.getOutput()); + net.minecraft.client.renderer.RenderHelper.disableStandardItemLighting(); + + if (progress == 1F) mc.fontRenderer.drawStringWithShadow("+", xc + radius + 14, yc + 12, 0xFFFFFF); + } + + net.minecraft.client.renderer.RenderHelper.enableGUIStandardItemLighting(); + for (int i = 0; i < amt; i++) { + double xPos = xc + Math.cos(angle * Math.PI / 180D) * radius - 8; + double yPos = yc + Math.sin(angle * Math.PI / 180D) * radius - 8; + GL11.glTranslated(xPos, yPos, 0); + RenderItem.getInstance().renderItemIntoGUI(mc.fontRenderer, mc.renderEngine, getStackInSlot(i), 0, 0); + GL11.glTranslated(-xPos, -yPos, 0); + + angle += anglePer; + } + net.minecraft.client.renderer.RenderHelper.disableStandardItemLighting(); + } else if (recipeKeepTicks > 0) { + String s = StatCollector.translateToLocal("botaniamisc.altarRefill0"); + mc.fontRenderer.drawStringWithShadow(s, xc - mc.fontRenderer.getStringWidth(s) / 2, yc + 10, 0xFFFFFF); + s = StatCollector.translateToLocal("botaniamisc.altarRefill1"); + mc.fontRenderer.drawStringWithShadow(s, xc - mc.fontRenderer.getStringWidth(s) / 2, yc + 20, 0xFFFFFF); + } + } + + public int getTargetMana() { + return manaToGet; + } } diff --git a/src/main/java/vazkii/botania/common/block/tile/TileSimpleInventory.java b/src/main/java/vazkii/botania/common/block/tile/TileSimpleInventory.java index 15a9f41442..1ac479223c 100644 --- a/src/main/java/vazkii/botania/common/block/tile/TileSimpleInventory.java +++ b/src/main/java/vazkii/botania/common/block/tile/TileSimpleInventory.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jan 21, 2014, 9:56:24 PM (GMT)] */ package vazkii.botania.common.block.tile; @@ -18,98 +18,98 @@ public abstract class TileSimpleInventory extends TileMod implements IInventory { - ItemStack[] inventorySlots = new ItemStack[getSizeInventory()]; - - @Override - public void readCustomNBT(NBTTagCompound par1NBTTagCompound) { - NBTTagList var2 = par1NBTTagCompound.getTagList("Items", 10); - inventorySlots = new ItemStack[getSizeInventory()]; - for (int var3 = 0; var3 < var2.tagCount(); ++var3) { - NBTTagCompound var4 = var2.getCompoundTagAt(var3); - byte var5 = var4.getByte("Slot"); - if (var5 >= 0 && var5 < inventorySlots.length) - inventorySlots[var5] = ItemStack.loadItemStackFromNBT(var4); - } - } - - @Override - public void writeCustomNBT(NBTTagCompound par1NBTTagCompound) { - NBTTagList var2 = new NBTTagList(); - for (int var3 = 0; var3 < inventorySlots.length; ++var3) { - if (inventorySlots[var3] != null) { - NBTTagCompound var4 = new NBTTagCompound(); - var4.setByte("Slot", (byte)var3); - inventorySlots[var3].writeToNBT(var4); - var2.appendTag(var4); - } - } - par1NBTTagCompound.setTag("Items", var2); - } - - @Override - public ItemStack getStackInSlot(int i) { - return inventorySlots[i]; - } - - @Override - public ItemStack decrStackSize(int i, int j) { - if (inventorySlots[i] != null) { - ItemStack stackAt; - - if (inventorySlots[i].stackSize <= j) { - stackAt = inventorySlots[i]; - inventorySlots[i] = null; - return stackAt; - } else { - stackAt = inventorySlots[i].splitStack(j); - - if (inventorySlots[i].stackSize == 0) - inventorySlots[i] = null; - - return stackAt; - } - } - - return null; - } - - @Override - public ItemStack getStackInSlotOnClosing(int i) { - return getStackInSlot(i); - } - - @Override - public void setInventorySlotContents(int i, ItemStack itemstack) { - inventorySlots[i] = itemstack; - } - - @Override - public int getInventoryStackLimit() { - return 64; - } - - @Override - public boolean isUseableByPlayer(EntityPlayer entityplayer) { - return worldObj.getTileEntity(xCoord, yCoord, zCoord) != this ? false : entityplayer.getDistanceSq(xCoord + 0.5D, yCoord + 0.5D, zCoord + 0.5D) <= 64; - } - - @Override - public boolean isItemValidForSlot(int i, ItemStack itemstack) { - return true; - } - - @Override - public boolean hasCustomInventoryName() { - return false; - } - - @Override - public void openInventory() { - // NO-OP - } - - @Override - public void closeInventory() { - // NO-OP - } + ItemStack[] inventorySlots = new ItemStack[getSizeInventory()]; + + @Override + public void readCustomNBT(NBTTagCompound par1NBTTagCompound) { + NBTTagList var2 = par1NBTTagCompound.getTagList("Items", 10); + inventorySlots = new ItemStack[getSizeInventory()]; + for (int var3 = 0; var3 < var2.tagCount(); ++var3) { + NBTTagCompound var4 = var2.getCompoundTagAt(var3); + byte var5 = var4.getByte("Slot"); + if (var5 >= 0 && var5 < inventorySlots.length) inventorySlots[var5] = ItemStack.loadItemStackFromNBT(var4); + } + } + + @Override + public void writeCustomNBT(NBTTagCompound par1NBTTagCompound) { + NBTTagList var2 = new NBTTagList(); + for (int var3 = 0; var3 < inventorySlots.length; ++var3) { + if (inventorySlots[var3] != null) { + NBTTagCompound var4 = new NBTTagCompound(); + var4.setByte("Slot", (byte) var3); + inventorySlots[var3].writeToNBT(var4); + var2.appendTag(var4); + } + } + par1NBTTagCompound.setTag("Items", var2); + } + + @Override + public ItemStack getStackInSlot(int i) { + return inventorySlots[i]; + } + + @Override + public ItemStack decrStackSize(int i, int j) { + if (inventorySlots[i] != null) { + ItemStack stackAt; + + if (inventorySlots[i].stackSize <= j) { + stackAt = inventorySlots[i]; + inventorySlots[i] = null; + return stackAt; + } else { + stackAt = inventorySlots[i].splitStack(j); + + if (inventorySlots[i].stackSize == 0) inventorySlots[i] = null; + + return stackAt; + } + } + + return null; + } + + @Override + public ItemStack getStackInSlotOnClosing(int i) { + return getStackInSlot(i); + } + + @Override + public void setInventorySlotContents(int i, ItemStack itemstack) { + inventorySlots[i] = itemstack; + } + + @Override + public int getInventoryStackLimit() { + return 64; + } + + @Override + public boolean isUseableByPlayer(EntityPlayer entityplayer) { + return worldObj.getTileEntity(xCoord, yCoord, zCoord) != this + ? false + : entityplayer.getDistanceSq(xCoord + 0.5D, yCoord + 0.5D, zCoord + 0.5D) <= 64; + } + + @Override + public boolean isItemValidForSlot(int i, ItemStack itemstack) { + return true; + } + + @Override + public boolean hasCustomInventoryName() { + return false; + } + + @Override + public void openInventory() { + // NO-OP + } + + @Override + public void closeInventory() { + // NO-OP + } } diff --git a/src/main/java/vazkii/botania/common/block/tile/TileSparkChanger.java b/src/main/java/vazkii/botania/common/block/tile/TileSparkChanger.java index 8b37e9c676..dd1b5ddc94 100644 --- a/src/main/java/vazkii/botania/common/block/tile/TileSparkChanger.java +++ b/src/main/java/vazkii/botania/common/block/tile/TileSparkChanger.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jun 28, 2015, 10:02:11 PM (GMT)] */ package vazkii.botania.common.block.tile; @@ -13,7 +13,6 @@ import java.util.ArrayList; import java.util.Collection; import java.util.List; - import net.minecraft.item.ItemStack; import net.minecraft.tileentity.TileEntity; import net.minecraftforge.common.util.ForgeDirection; @@ -26,66 +25,62 @@ public class TileSparkChanger extends TileSimpleInventory { - public void doSwap() { - if(worldObj.isRemote) - return; - - ItemStack changeStack = getStackInSlot(0); - List attachables = new ArrayList(); - for(ForgeDirection dir : LibMisc.CARDINAL_DIRECTIONS) { - TileEntity tile = worldObj.getTileEntity(xCoord + dir.offsetX, yCoord, zCoord + dir.offsetZ); - if(tile != null && tile instanceof ISparkAttachable) { - ISparkAttachable attach = (ISparkAttachable) tile; - ISparkEntity spark = attach.getAttachedSpark(); - if(spark != null) { - int upg = spark.getUpgrade(); - int newUpg = changeStack == null ? 0 : changeStack.getItemDamage() + 1; - if(upg != newUpg) - attachables.add(attach); - } - } - } + public void doSwap() { + if (worldObj.isRemote) return; - if(attachables.size() > 0) { - ISparkAttachable attach = attachables.get(worldObj.rand.nextInt(attachables.size())); - ISparkEntity spark = attach.getAttachedSpark(); - int upg = spark.getUpgrade(); - ItemStack sparkStack = upg == 0 ? null : new ItemStack(ModItems.sparkUpgrade, 1, upg - 1); - int newUpg = changeStack == null ? 0 : changeStack.getItemDamage() + 1; - spark.setUpgrade(newUpg); - Collection transfers = spark.getTransfers(); - if(transfers != null) - transfers.clear(); - setInventorySlotContents(0, sparkStack); - worldObj.func_147453_f(xCoord, yCoord, zCoord, worldObj.getBlock(xCoord, yCoord, zCoord)); - markDirty(); - } - } + ItemStack changeStack = getStackInSlot(0); + List attachables = new ArrayList(); + for (ForgeDirection dir : LibMisc.CARDINAL_DIRECTIONS) { + TileEntity tile = worldObj.getTileEntity(xCoord + dir.offsetX, yCoord, zCoord + dir.offsetZ); + if (tile != null && tile instanceof ISparkAttachable) { + ISparkAttachable attach = (ISparkAttachable) tile; + ISparkEntity spark = attach.getAttachedSpark(); + if (spark != null) { + int upg = spark.getUpgrade(); + int newUpg = changeStack == null ? 0 : changeStack.getItemDamage() + 1; + if (upg != newUpg) attachables.add(attach); + } + } + } - @Override - public int getSizeInventory() { - return 1; - } + if (attachables.size() > 0) { + ISparkAttachable attach = attachables.get(worldObj.rand.nextInt(attachables.size())); + ISparkEntity spark = attach.getAttachedSpark(); + int upg = spark.getUpgrade(); + ItemStack sparkStack = upg == 0 ? null : new ItemStack(ModItems.sparkUpgrade, 1, upg - 1); + int newUpg = changeStack == null ? 0 : changeStack.getItemDamage() + 1; + spark.setUpgrade(newUpg); + Collection transfers = spark.getTransfers(); + if (transfers != null) transfers.clear(); + setInventorySlotContents(0, sparkStack); + worldObj.func_147453_f(xCoord, yCoord, zCoord, worldObj.getBlock(xCoord, yCoord, zCoord)); + markDirty(); + } + } - @Override - public boolean isItemValidForSlot(int i, ItemStack itemstack) { - return itemstack != null && itemstack.getItem() == ModItems.sparkUpgrade; - } + @Override + public int getSizeInventory() { + return 1; + } - @Override - public int getInventoryStackLimit() { - return 1; - } + @Override + public boolean isItemValidForSlot(int i, ItemStack itemstack) { + return itemstack != null && itemstack.getItem() == ModItems.sparkUpgrade; + } - @Override - public void markDirty() { - super.markDirty(); - VanillaPacketDispatcher.dispatchTEToNearbyPlayers(this); - } + @Override + public int getInventoryStackLimit() { + return 1; + } - @Override - public String getInventoryName() { - return LibBlockNames.SPARK_CHANGER; - } + @Override + public void markDirty() { + super.markDirty(); + VanillaPacketDispatcher.dispatchTEToNearbyPlayers(this); + } + @Override + public String getInventoryName() { + return LibBlockNames.SPARK_CHANGER; + } } diff --git a/src/main/java/vazkii/botania/common/block/tile/TileSpawnerClaw.java b/src/main/java/vazkii/botania/common/block/tile/TileSpawnerClaw.java index 81e97bb4e9..9edb884c8e 100644 --- a/src/main/java/vazkii/botania/common/block/tile/TileSpawnerClaw.java +++ b/src/main/java/vazkii/botania/common/block/tile/TileSpawnerClaw.java @@ -2,16 +2,16 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jul 23, 2014, 5:32:11 PM (GMT)] */ package vazkii.botania.common.block.tile; +import cpw.mods.fml.relauncher.ReflectionHelper; import java.util.List; - import net.minecraft.entity.Entity; import net.minecraft.entity.EntityList; import net.minecraft.entity.EntityLiving; @@ -24,131 +24,159 @@ import vazkii.botania.api.mana.IManaReceiver; import vazkii.botania.common.Botania; import vazkii.botania.common.lib.LibObfuscation; -import cpw.mods.fml.relauncher.ReflectionHelper; public class TileSpawnerClaw extends TileMod implements IManaReceiver { - private static final String TAG_MANA = "mana"; - - int mana = 0; - - @Override - public void updateEntity() { - TileEntity tileBelow = worldObj.getTileEntity(xCoord, yCoord - 1, zCoord); - if(mana >= 5 && tileBelow instanceof TileEntityMobSpawner) { - TileEntityMobSpawner spawner = (TileEntityMobSpawner) tileBelow; - MobSpawnerBaseLogic logic = spawner.func_145881_a(); - - if(!logic.isActivated()) { - if(!worldObj.isRemote) - mana -= 6; - - if(logic.getSpawnerWorld().isRemote) { - if(logic.spawnDelay > 0) - --logic.spawnDelay; - - if(Math.random() > 0.5) - Botania.proxy.wispFX(worldObj, xCoord + 0.3 + Math.random() * 0.5, yCoord - 0.3 + Math.random() * 0.25, zCoord + Math.random(), 0.6F - (float) Math.random() * 0.3F, 0.1F, 0.6F - (float) Math.random() * 0.3F, (float) Math.random() / 3F, -0.025F - 0.005F * (float) Math.random(), 2F); - - logic.field_98284_d = logic.field_98287_c; - logic.field_98287_c = (logic.field_98287_c + 1000.0F / (logic.spawnDelay + 200.0F)) % 360.0D; - } else if(logic.spawnDelay == -1) - resetTimer(logic); - - if(logic.spawnDelay > 0) { - --logic.spawnDelay; - return; - } - - boolean flag = false; - - int spawnCount = ReflectionHelper.getPrivateValue(MobSpawnerBaseLogic.class, logic, LibObfuscation.SPAWN_COUNT); - int spawnRange = ReflectionHelper.getPrivateValue(MobSpawnerBaseLogic.class, logic, LibObfuscation.SPAWN_RANGE); - int maxNearbyEntities = ReflectionHelper.getPrivateValue(MobSpawnerBaseLogic.class, logic, LibObfuscation.MAX_NEARBY_ENTITIES); - - for(int i = 0; i < spawnCount; ++i) { - Entity entity = EntityList.createEntityByName(logic.getEntityNameToSpawn(), logic.getSpawnerWorld()); - - if (entity == null) - return; - - int j = logic.getSpawnerWorld().getEntitiesWithinAABB(entity.getClass(), AxisAlignedBB.getBoundingBox(logic.getSpawnerX(), logic.getSpawnerY(), logic.getSpawnerZ(), logic.getSpawnerX() + 1, logic.getSpawnerY() + 1, logic.getSpawnerZ() + 1).expand(spawnRange * 2, 4.0D, spawnRange * 2)).size(); - - if (j >= maxNearbyEntities) { - resetTimer(logic); - return; - } - - double d2 = logic.getSpawnerX() + (logic.getSpawnerWorld().rand.nextDouble() - logic.getSpawnerWorld().rand.nextDouble()) * spawnRange; - double d3 = logic.getSpawnerY() + logic.getSpawnerWorld().rand.nextInt(3) - 1; - double d4 = logic.getSpawnerZ() + (logic.getSpawnerWorld().rand.nextDouble() - logic.getSpawnerWorld().rand.nextDouble()) * spawnRange; - EntityLiving entityliving = entity instanceof EntityLiving ? (EntityLiving)entity : null; - entity.setLocationAndAngles(d2, d3, d4, logic.getSpawnerWorld().rand.nextFloat() * 360.0F, 0.0F); - - if(entityliving == null || entityliving.getCanSpawnHere()) { - if(!worldObj.isRemote) - logic.func_98265_a(entity); - logic.getSpawnerWorld().playAuxSFX(2004, logic.getSpawnerX(), logic.getSpawnerY(), logic.getSpawnerZ(), 0); - - if (entityliving != null) - entityliving.spawnExplosionParticle(); - - flag = true; - } - } - - if (flag) - resetTimer(logic); - } - } - } - - private void resetTimer(MobSpawnerBaseLogic logic) { - int maxSpawnDelay = ReflectionHelper.getPrivateValue(MobSpawnerBaseLogic.class, logic, LibObfuscation.MAX_SPAWN_DELAY); - int minSpawnDelay = ReflectionHelper.getPrivateValue(MobSpawnerBaseLogic.class, logic, LibObfuscation.MIN_SPAWN_DELAY); - List potentialEntitySpawns = ReflectionHelper.getPrivateValue(MobSpawnerBaseLogic.class, logic, LibObfuscation.POTENTIAL_ENTITY_SPAWNS); - - if(maxSpawnDelay <= minSpawnDelay) - logic.spawnDelay = minSpawnDelay; - else { - int i = maxSpawnDelay - minSpawnDelay; - logic.spawnDelay = minSpawnDelay + logic.getSpawnerWorld().rand.nextInt(i); - } - - if(potentialEntitySpawns != null && potentialEntitySpawns.size() > 0) - logic.setRandomEntity((MobSpawnerBaseLogic.WeightedRandomMinecart)WeightedRandom.getRandomItem(logic.getSpawnerWorld().rand, potentialEntitySpawns)); - - logic.func_98267_a(1); - } - - @Override - public void writeCustomNBT(NBTTagCompound cmp) { - cmp.setInteger(TAG_MANA, mana); - } - - @Override - public void readCustomNBT(NBTTagCompound cmp) { - mana = cmp.getInteger(TAG_MANA); - } - - @Override - public int getCurrentMana() { - return mana; - } - - @Override - public boolean isFull() { - return mana >= 160; - } - - @Override - public void recieveMana(int mana) { - this.mana = Math.min(160, this.mana + mana); - } - - @Override - public boolean canRecieveManaFromBursts() { - return true; - } - + private static final String TAG_MANA = "mana"; + + int mana = 0; + + @Override + public void updateEntity() { + TileEntity tileBelow = worldObj.getTileEntity(xCoord, yCoord - 1, zCoord); + if (mana >= 5 && tileBelow instanceof TileEntityMobSpawner) { + TileEntityMobSpawner spawner = (TileEntityMobSpawner) tileBelow; + MobSpawnerBaseLogic logic = spawner.func_145881_a(); + + if (!logic.isActivated()) { + if (!worldObj.isRemote) mana -= 6; + + if (logic.getSpawnerWorld().isRemote) { + if (logic.spawnDelay > 0) --logic.spawnDelay; + + if (Math.random() > 0.5) + Botania.proxy.wispFX( + worldObj, + xCoord + 0.3 + Math.random() * 0.5, + yCoord - 0.3 + Math.random() * 0.25, + zCoord + Math.random(), + 0.6F - (float) Math.random() * 0.3F, + 0.1F, + 0.6F - (float) Math.random() * 0.3F, + (float) Math.random() / 3F, + -0.025F - 0.005F * (float) Math.random(), + 2F); + + logic.field_98284_d = logic.field_98287_c; + logic.field_98287_c = (logic.field_98287_c + 1000.0F / (logic.spawnDelay + 200.0F)) % 360.0D; + } else if (logic.spawnDelay == -1) resetTimer(logic); + + if (logic.spawnDelay > 0) { + --logic.spawnDelay; + return; + } + + boolean flag = false; + + int spawnCount = + ReflectionHelper.getPrivateValue(MobSpawnerBaseLogic.class, logic, LibObfuscation.SPAWN_COUNT); + int spawnRange = + ReflectionHelper.getPrivateValue(MobSpawnerBaseLogic.class, logic, LibObfuscation.SPAWN_RANGE); + int maxNearbyEntities = ReflectionHelper.getPrivateValue( + MobSpawnerBaseLogic.class, logic, LibObfuscation.MAX_NEARBY_ENTITIES); + + for (int i = 0; i < spawnCount; ++i) { + Entity entity = + EntityList.createEntityByName(logic.getEntityNameToSpawn(), logic.getSpawnerWorld()); + + if (entity == null) return; + + int j = logic.getSpawnerWorld() + .getEntitiesWithinAABB( + entity.getClass(), + AxisAlignedBB.getBoundingBox( + logic.getSpawnerX(), + logic.getSpawnerY(), + logic.getSpawnerZ(), + logic.getSpawnerX() + 1, + logic.getSpawnerY() + 1, + logic.getSpawnerZ() + 1) + .expand(spawnRange * 2, 4.0D, spawnRange * 2)) + .size(); + + if (j >= maxNearbyEntities) { + resetTimer(logic); + return; + } + + double d2 = logic.getSpawnerX() + + (logic.getSpawnerWorld().rand.nextDouble() + - logic.getSpawnerWorld().rand.nextDouble()) + * spawnRange; + double d3 = + logic.getSpawnerY() + logic.getSpawnerWorld().rand.nextInt(3) - 1; + double d4 = logic.getSpawnerZ() + + (logic.getSpawnerWorld().rand.nextDouble() + - logic.getSpawnerWorld().rand.nextDouble()) + * spawnRange; + EntityLiving entityliving = entity instanceof EntityLiving ? (EntityLiving) entity : null; + entity.setLocationAndAngles( + d2, d3, d4, logic.getSpawnerWorld().rand.nextFloat() * 360.0F, 0.0F); + + if (entityliving == null || entityliving.getCanSpawnHere()) { + if (!worldObj.isRemote) logic.func_98265_a(entity); + logic.getSpawnerWorld() + .playAuxSFX(2004, logic.getSpawnerX(), logic.getSpawnerY(), logic.getSpawnerZ(), 0); + + if (entityliving != null) entityliving.spawnExplosionParticle(); + + flag = true; + } + } + + if (flag) resetTimer(logic); + } + } + } + + private void resetTimer(MobSpawnerBaseLogic logic) { + int maxSpawnDelay = + ReflectionHelper.getPrivateValue(MobSpawnerBaseLogic.class, logic, LibObfuscation.MAX_SPAWN_DELAY); + int minSpawnDelay = + ReflectionHelper.getPrivateValue(MobSpawnerBaseLogic.class, logic, LibObfuscation.MIN_SPAWN_DELAY); + List potentialEntitySpawns = ReflectionHelper.getPrivateValue( + MobSpawnerBaseLogic.class, logic, LibObfuscation.POTENTIAL_ENTITY_SPAWNS); + + if (maxSpawnDelay <= minSpawnDelay) logic.spawnDelay = minSpawnDelay; + else { + int i = maxSpawnDelay - minSpawnDelay; + logic.spawnDelay = minSpawnDelay + logic.getSpawnerWorld().rand.nextInt(i); + } + + if (potentialEntitySpawns != null && potentialEntitySpawns.size() > 0) + logic.setRandomEntity((MobSpawnerBaseLogic.WeightedRandomMinecart) + WeightedRandom.getRandomItem(logic.getSpawnerWorld().rand, potentialEntitySpawns)); + + logic.func_98267_a(1); + } + + @Override + public void writeCustomNBT(NBTTagCompound cmp) { + cmp.setInteger(TAG_MANA, mana); + } + + @Override + public void readCustomNBT(NBTTagCompound cmp) { + mana = cmp.getInteger(TAG_MANA); + } + + @Override + public int getCurrentMana() { + return mana; + } + + @Override + public boolean isFull() { + return mana >= 160; + } + + @Override + public void recieveMana(int mana) { + this.mana = Math.min(160, this.mana + mana); + } + + @Override + public boolean canRecieveManaFromBursts() { + return true; + } } diff --git a/src/main/java/vazkii/botania/common/block/tile/TileSpecialFlower.java b/src/main/java/vazkii/botania/common/block/tile/TileSpecialFlower.java index 34dbfb26ff..48901d31aa 100644 --- a/src/main/java/vazkii/botania/common/block/tile/TileSpecialFlower.java +++ b/src/main/java/vazkii/botania/common/block/tile/TileSpecialFlower.java @@ -2,16 +2,15 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jan 22, 2014, 7:21:51 PM (GMT)] */ package vazkii.botania.common.block.tile; import java.util.ArrayList; - import net.minecraft.block.Block; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.ScaledResolution; @@ -34,205 +33,192 @@ public class TileSpecialFlower extends TileMod implements IWandBindable, ISubTileSlowableContainer { - private static final String TAG_SUBTILE_NAME = "subTileName"; - private static final String TAG_SUBTILE_CMP = "subTileCmp"; - - public String subTileName = ""; - SubTileEntity subTile; - - @Override - public SubTileEntity getSubTile() { - return subTile; - } - - @Override - public void setSubTile(String name) { - subTileName = name; - provideSubTile(subTileName); - } - - public void setSubTile(SubTileEntity tile) { - subTile = tile; - subTile.setSupertile(this); - } - - private void provideSubTile(String name) { - subTileName = name; - - Class tileClass = BotaniaAPI.getSubTileMapping(name); - try { - SubTileEntity tile = tileClass.newInstance(); - setSubTile(tile); - } catch (Exception e) { - e.printStackTrace(); - } - } - - @Override - public void updateEntity() { - if(subTile != null) { - TileEntity tileBelow = worldObj.getTileEntity(xCoord, yCoord - 1, zCoord); - if(tileBelow instanceof TileRedStringRelay) { - ChunkCoordinates coords = ((TileRedStringRelay) tileBelow).getBinding(); - if(coords != null) { - int currX = xCoord; - int currY = yCoord; - int currZ = zCoord; - xCoord = coords.posX; - yCoord = coords.posY; - zCoord = coords.posZ; - subTile.onUpdate(); - xCoord = currX; - yCoord = currY; - zCoord = currZ; - - return; - } - } - - boolean special = isOnSpecialSoil(); - if(special) { - subTile.overgrowth = true; - if(subTile.isOvergrowthAffected()) { - subTile.onUpdate(); - subTile.overgrowthBoost = true; - } - } - subTile.onUpdate(); - subTile.overgrowth = false; - subTile.overgrowthBoost = false; - } - } - - public boolean isOnSpecialSoil() { - return worldObj.getBlock(xCoord, yCoord - 1, zCoord) == ModBlocks.enchantedSoil; - } - - @Override - public boolean canUpdate() { - return subTile == null || subTile.canUpdate(); - } - - @Override - public void writeCustomNBT(NBTTagCompound cmp) { - super.writeCustomNBT(cmp); - - cmp.setString(TAG_SUBTILE_NAME, subTileName); - NBTTagCompound subCmp = new NBTTagCompound(); - cmp.setTag(TAG_SUBTILE_CMP, subCmp); - - if(subTile != null) - subTile.writeToPacketNBTInternal(subCmp); - } - - @Override - public void readCustomNBT(NBTTagCompound cmp) { - super.readCustomNBT(cmp); - - subTileName = cmp.getString(TAG_SUBTILE_NAME); - NBTTagCompound subCmp = cmp.getCompoundTag(TAG_SUBTILE_CMP); - - if(subTile == null || !BotaniaAPI.getSubTileStringMapping(subTile.getClass()).equals(subTileName)) - provideSubTile(subTileName); - - if(subTile != null) - subTile.readFromPacketNBTInternal(subCmp); - } - - public IIcon getIcon() { - return subTile == null ? Blocks.red_flower.getIcon(0, 0) : subTile.getIcon(); - } - - public LexiconEntry getEntry() { - return subTile == null ? null : subTile.getEntry(); - } - - public boolean onWanded(ItemStack wand, EntityPlayer player) { - return subTile == null ? false : subTile.onWanded(player, wand); - } - - public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase entity, ItemStack stack) { - if (subTile != null) - subTile.onBlockPlacedBy(world, x, y, z, entity, stack); - } - - public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int side, float hitX, float hitY, float hitZ) { - return subTile == null ? false : subTile.onBlockActivated(world, x, y, z, player, side, hitX, hitY, hitZ); - } - - public void onBlockAdded(World world, int x, int y, int z) { - if (subTile != null) - subTile.onBlockAdded(world, x, y, z); - } - - public void onBlockHarvested(World world, int x, int y, int z, int side, EntityPlayer player) { - if (subTile != null) - subTile.onBlockHarvested(world, x, y, z, side, player); - } - - public ArrayList getDrops(ArrayList list) { - if (subTile != null) - subTile.getDrops(list); - - return list; - } - - public void renderHUD(Minecraft mc, ScaledResolution res) { - if(subTile != null) - subTile.renderHUD(mc, res); - } - - @Override - public ChunkCoordinates getBinding() { - if(subTile == null) - return null; - return subTile.getBinding(); - } - - @Override - public boolean canSelect(EntityPlayer player, ItemStack wand, int x, int y, int z, int side) { - if(subTile == null) - return false; - return subTile.canSelect(player, wand, x, y, z, side); - } - - @Override - public boolean bindTo(EntityPlayer player, ItemStack wand, int x, int y, int z, int side) { - if(subTile == null) - return false; - return subTile.bindTo(player, wand, x, y, z, side); - } - - public int getLightValue() { - if(subTile == null) - return -1; - return subTile.getLightValue(); - } - - public int getComparatorInputOverride(int side) { - if(subTile == null) - return 0; - return subTile.getComparatorInputOverride(side); - } - - public int getPowerLevel(int side) { - if(subTile == null) - return 0; - return subTile.getPowerLevel(side); - } - - @Override - public int getSlowdownFactor() { - Block below = worldObj.getBlock(xCoord, yCoord - 1, zCoord); - if(below == Blocks.mycelium) - return SLOWDOWN_FACTOR_MYCEL; - - if(below == Blocks.dirt) { - int meta = worldObj.getBlockMetadata(xCoord, yCoord - 1, zCoord); - if(meta == 2) - return SLOWDOWN_FACTOR_PODZOL; - } - - return 0; - } + private static final String TAG_SUBTILE_NAME = "subTileName"; + private static final String TAG_SUBTILE_CMP = "subTileCmp"; + + public String subTileName = ""; + SubTileEntity subTile; + + @Override + public SubTileEntity getSubTile() { + return subTile; + } + + @Override + public void setSubTile(String name) { + subTileName = name; + provideSubTile(subTileName); + } + + public void setSubTile(SubTileEntity tile) { + subTile = tile; + subTile.setSupertile(this); + } + + private void provideSubTile(String name) { + subTileName = name; + + Class tileClass = BotaniaAPI.getSubTileMapping(name); + try { + SubTileEntity tile = tileClass.newInstance(); + setSubTile(tile); + } catch (Exception e) { + e.printStackTrace(); + } + } + + @Override + public void updateEntity() { + if (subTile != null) { + TileEntity tileBelow = worldObj.getTileEntity(xCoord, yCoord - 1, zCoord); + if (tileBelow instanceof TileRedStringRelay) { + ChunkCoordinates coords = ((TileRedStringRelay) tileBelow).getBinding(); + if (coords != null) { + int currX = xCoord; + int currY = yCoord; + int currZ = zCoord; + xCoord = coords.posX; + yCoord = coords.posY; + zCoord = coords.posZ; + subTile.onUpdate(); + xCoord = currX; + yCoord = currY; + zCoord = currZ; + + return; + } + } + + boolean special = isOnSpecialSoil(); + if (special) { + subTile.overgrowth = true; + if (subTile.isOvergrowthAffected()) { + subTile.onUpdate(); + subTile.overgrowthBoost = true; + } + } + subTile.onUpdate(); + subTile.overgrowth = false; + subTile.overgrowthBoost = false; + } + } + + public boolean isOnSpecialSoil() { + return worldObj.getBlock(xCoord, yCoord - 1, zCoord) == ModBlocks.enchantedSoil; + } + + @Override + public boolean canUpdate() { + return subTile == null || subTile.canUpdate(); + } + + @Override + public void writeCustomNBT(NBTTagCompound cmp) { + super.writeCustomNBT(cmp); + + cmp.setString(TAG_SUBTILE_NAME, subTileName); + NBTTagCompound subCmp = new NBTTagCompound(); + cmp.setTag(TAG_SUBTILE_CMP, subCmp); + + if (subTile != null) subTile.writeToPacketNBTInternal(subCmp); + } + + @Override + public void readCustomNBT(NBTTagCompound cmp) { + super.readCustomNBT(cmp); + + subTileName = cmp.getString(TAG_SUBTILE_NAME); + NBTTagCompound subCmp = cmp.getCompoundTag(TAG_SUBTILE_CMP); + + if (subTile == null + || !BotaniaAPI.getSubTileStringMapping(subTile.getClass()).equals(subTileName)) + provideSubTile(subTileName); + + if (subTile != null) subTile.readFromPacketNBTInternal(subCmp); + } + + public IIcon getIcon() { + return subTile == null ? Blocks.red_flower.getIcon(0, 0) : subTile.getIcon(); + } + + public LexiconEntry getEntry() { + return subTile == null ? null : subTile.getEntry(); + } + + public boolean onWanded(ItemStack wand, EntityPlayer player) { + return subTile == null ? false : subTile.onWanded(player, wand); + } + + public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase entity, ItemStack stack) { + if (subTile != null) subTile.onBlockPlacedBy(world, x, y, z, entity, stack); + } + + public boolean onBlockActivated( + World world, int x, int y, int z, EntityPlayer player, int side, float hitX, float hitY, float hitZ) { + return subTile == null ? false : subTile.onBlockActivated(world, x, y, z, player, side, hitX, hitY, hitZ); + } + + public void onBlockAdded(World world, int x, int y, int z) { + if (subTile != null) subTile.onBlockAdded(world, x, y, z); + } + + public void onBlockHarvested(World world, int x, int y, int z, int side, EntityPlayer player) { + if (subTile != null) subTile.onBlockHarvested(world, x, y, z, side, player); + } + + public ArrayList getDrops(ArrayList list) { + if (subTile != null) subTile.getDrops(list); + + return list; + } + + public void renderHUD(Minecraft mc, ScaledResolution res) { + if (subTile != null) subTile.renderHUD(mc, res); + } + + @Override + public ChunkCoordinates getBinding() { + if (subTile == null) return null; + return subTile.getBinding(); + } + + @Override + public boolean canSelect(EntityPlayer player, ItemStack wand, int x, int y, int z, int side) { + if (subTile == null) return false; + return subTile.canSelect(player, wand, x, y, z, side); + } + + @Override + public boolean bindTo(EntityPlayer player, ItemStack wand, int x, int y, int z, int side) { + if (subTile == null) return false; + return subTile.bindTo(player, wand, x, y, z, side); + } + + public int getLightValue() { + if (subTile == null) return -1; + return subTile.getLightValue(); + } + + public int getComparatorInputOverride(int side) { + if (subTile == null) return 0; + return subTile.getComparatorInputOverride(side); + } + + public int getPowerLevel(int side) { + if (subTile == null) return 0; + return subTile.getPowerLevel(side); + } + + @Override + public int getSlowdownFactor() { + Block below = worldObj.getBlock(xCoord, yCoord - 1, zCoord); + if (below == Blocks.mycelium) return SLOWDOWN_FACTOR_MYCEL; + + if (below == Blocks.dirt) { + int meta = worldObj.getBlockMetadata(xCoord, yCoord - 1, zCoord); + if (meta == 2) return SLOWDOWN_FACTOR_PODZOL; + } + + return 0; + } } diff --git a/src/main/java/vazkii/botania/common/block/tile/TileSpiritShrine.java b/src/main/java/vazkii/botania/common/block/tile/TileSpiritShrine.java index 1925fad265..2ef90f7d3e 100644 --- a/src/main/java/vazkii/botania/common/block/tile/TileSpiritShrine.java +++ b/src/main/java/vazkii/botania/common/block/tile/TileSpiritShrine.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Apr 1, 2014, 1:55:57 PM (GMT)] */ package vazkii.botania.common.block.tile; @@ -14,49 +14,80 @@ public class TileSpiritShrine extends TileMod { - int ticks; - - @Override - public void updateEntity() { - if(worldObj.isRemote) { - if(ticks >= 40) { - float[][] colors = new float[][] { - { 0F, 0.25F, 1F }, - { 1F, 0F, 0.2F }, - { 0F, 1F, 0.25F }, - { 1F, 1F, 0.25F }, - { 1F, 0.25F, 1F }, - { 0.25F, 1F, 1F } - }; - - int totalSpiritCount = 6; - double tickIncrement = 360D / totalSpiritCount; - - int liftTicks = 40 * (totalSpiritCount + 1); - int existTicks = liftTicks * 2; - int lowerTicks = existTicks + liftTicks; - - if(ticks < lowerTicks) { - int speed = 5; - double wticks = ticks * speed - tickIncrement; - double r = Math.sin((ticks >= liftTicks ? (ticks - liftTicks) * speed - tickIncrement : -tickIncrement) * Math.PI / 180 * 0.75) + 1 * 1.25 + 0.5; - double g = Math.sin(wticks * Math.PI / 180 * 0.55); - - for(int i = 0; i < totalSpiritCount; i++) { - double x = xCoord + Math.sin(wticks * Math.PI / 180) * r + 0.5; - double y = yCoord + (ticks > existTicks ? 40 - (double) (ticks - existTicks) : Math.min(80 + 40 * i, ticks) - 40 * (i + 1)) * 0.1; - double z = zCoord + Math.cos(wticks * Math.PI / 180) * r + 0.5; - - wticks += tickIncrement; - float[] colorsfx = colors[i >= colors.length ? 0 : i]; - Botania.proxy.wispFX(worldObj, x, y, z, colorsfx[0], colorsfx[1], colorsfx[2], 0.85F, (float)g * 0.05F, 0.25F); - Botania.proxy.wispFX(worldObj, x, y, z, colorsfx[0], colorsfx[1], colorsfx[2], (float) Math.random() * 0.1F + 0.1F, (float) (Math.random() - 0.5) * 0.05F, (float) (Math.random() - 0.5) * 0.05F, (float) (Math.random() - 0.5) * 0.05F, 0.9F); - } - } - } - - ++ticks; - } - } + int ticks; + @Override + public void updateEntity() { + if (worldObj.isRemote) { + if (ticks >= 40) { + float[][] colors = new float[][] { + {0F, 0.25F, 1F}, + {1F, 0F, 0.2F}, + {0F, 1F, 0.25F}, + {1F, 1F, 0.25F}, + {1F, 0.25F, 1F}, + {0.25F, 1F, 1F} + }; + + int totalSpiritCount = 6; + double tickIncrement = 360D / totalSpiritCount; + + int liftTicks = 40 * (totalSpiritCount + 1); + int existTicks = liftTicks * 2; + int lowerTicks = existTicks + liftTicks; + + if (ticks < lowerTicks) { + int speed = 5; + double wticks = ticks * speed - tickIncrement; + double r = + Math.sin((ticks >= liftTicks ? (ticks - liftTicks) * speed - tickIncrement : -tickIncrement) + * Math.PI + / 180 + * 0.75) + + 1 * 1.25 + + 0.5; + double g = Math.sin(wticks * Math.PI / 180 * 0.55); + + for (int i = 0; i < totalSpiritCount; i++) { + double x = xCoord + Math.sin(wticks * Math.PI / 180) * r + 0.5; + double y = yCoord + + (ticks > existTicks + ? 40 - (double) (ticks - existTicks) + : Math.min(80 + 40 * i, ticks) - 40 * (i + 1)) + * 0.1; + double z = zCoord + Math.cos(wticks * Math.PI / 180) * r + 0.5; + + wticks += tickIncrement; + float[] colorsfx = colors[i >= colors.length ? 0 : i]; + Botania.proxy.wispFX( + worldObj, + x, + y, + z, + colorsfx[0], + colorsfx[1], + colorsfx[2], + 0.85F, + (float) g * 0.05F, + 0.25F); + Botania.proxy.wispFX( + worldObj, + x, + y, + z, + colorsfx[0], + colorsfx[1], + colorsfx[2], + (float) Math.random() * 0.1F + 0.1F, + (float) (Math.random() - 0.5) * 0.05F, + (float) (Math.random() - 0.5) * 0.05F, + (float) (Math.random() - 0.5) * 0.05F, + 0.9F); + } + } + } + + ++ticks; + } + } } diff --git a/src/main/java/vazkii/botania/common/block/tile/TileStarfield.java b/src/main/java/vazkii/botania/common/block/tile/TileStarfield.java index 06eeaa350b..9492724d4f 100644 --- a/src/main/java/vazkii/botania/common/block/tile/TileStarfield.java +++ b/src/main/java/vazkii/botania/common/block/tile/TileStarfield.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Aug 7, 2014, 6:42:33 PM (GMT)] */ package vazkii.botania.common.block.tile; @@ -14,38 +14,37 @@ public class TileStarfield extends TileMod { - @Override - public void updateEntity() { - int meta = getBlockMetadata(); - if(!worldObj.isRemote) { - int newMeta = worldObj.isDaytime() ? 0 : 1; - if(newMeta != meta) { - worldObj.setBlockMetadataWithNotify(xCoord, yCoord, zCoord, newMeta, 1 | 2); - meta = newMeta; - } - } - - if(meta == 1) { - double radius = 512; - int iter = 2; - for(int i = 0; i < iter; i++) { - double x = xCoord + 0.5 + (Math.random() - 0.5) * radius; - double y = yCoord + 256; - double z = zCoord + 0.5 + (Math.random() - 0.5) * radius; - - float w = 0.6F; - float c = 1F - w; - - float r = w + (float) Math.random() * c; - float g = w + (float) Math.random() * c; - float b = w + (float) Math.random() * c; - - float s = 20F + (float) Math.random() * 20F; - int m = 50; - - Botania.proxy.sparkleFX(worldObj, x, y, z, r, g, b, s, m); - } - } - } - + @Override + public void updateEntity() { + int meta = getBlockMetadata(); + if (!worldObj.isRemote) { + int newMeta = worldObj.isDaytime() ? 0 : 1; + if (newMeta != meta) { + worldObj.setBlockMetadataWithNotify(xCoord, yCoord, zCoord, newMeta, 1 | 2); + meta = newMeta; + } + } + + if (meta == 1) { + double radius = 512; + int iter = 2; + for (int i = 0; i < iter; i++) { + double x = xCoord + 0.5 + (Math.random() - 0.5) * radius; + double y = yCoord + 256; + double z = zCoord + 0.5 + (Math.random() - 0.5) * radius; + + float w = 0.6F; + float c = 1F - w; + + float r = w + (float) Math.random() * c; + float g = w + (float) Math.random() * c; + float b = w + (float) Math.random() * c; + + float s = 20F + (float) Math.random() * 20F; + int m = 50; + + Botania.proxy.sparkleFX(worldObj, x, y, z, r, g, b, s, m); + } + } + } } diff --git a/src/main/java/vazkii/botania/common/block/tile/TileTerraPlate.java b/src/main/java/vazkii/botania/common/block/tile/TileTerraPlate.java index f59d61d6d4..6dcc8ac9bd 100644 --- a/src/main/java/vazkii/botania/common/block/tile/TileTerraPlate.java +++ b/src/main/java/vazkii/botania/common/block/tile/TileTerraPlate.java @@ -2,16 +2,15 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Nov 8, 2014, 5:25:32 PM (GMT)] */ package vazkii.botania.common.block.tile; import java.util.List; - import net.minecraft.block.Block; import net.minecraft.entity.Entity; import net.minecraft.entity.item.EntityItem; @@ -33,212 +32,229 @@ public class TileTerraPlate extends TileMod implements ISparkAttachable { - public static final int MAX_MANA = TilePool.MAX_MANA / 2; - private static final int[][] LAPIS_BLOCKS = { - { 1, 0, }, { -1, 0 }, { 0, 1 }, { 0, -1 } - }; - - private static final int[][] LIVINGROCK_BLOCKS = { - { 0, 0 }, { 1, 1 }, { 1, -1 }, { -1, 1 }, { -1, -1 } - }; - - private static final String TAG_MANA = "mana"; - - int mana; - - public static MultiblockSet makeMultiblockSet() { - Multiblock mb = new Multiblock(); - - for(int[] l : LAPIS_BLOCKS) - mb.addComponent(l[0], 0, l[1], Blocks.lapis_block, 0); - for(int[] l : LIVINGROCK_BLOCKS) - mb.addComponent(l[0], 0, l[1], ModBlocks.livingrock, 0); - - mb.addComponent(0, 1, 0, ModBlocks.terraPlate, 0); - mb.setRenderOffset(0, 1, 0); - - return mb.makeSet(); - } - - @Override - public void updateEntity() { - boolean removeMana = true; - - if(hasValidPlatform()) { - List items = getItems(); - if(areItemsValid(items)) { - removeMana = false; - ISparkEntity spark = getAttachedSpark(); - if(spark != null) { - List sparkEntities = SparkHelper.getSparksAround(worldObj, xCoord + 0.5, yCoord + 0.5, zCoord + 0.5); - for(ISparkEntity otherSpark : sparkEntities) { - if(spark == otherSpark) - continue; - - if(otherSpark.getAttachedTile() != null && otherSpark.getAttachedTile() instanceof IManaPool) - otherSpark.registerTransfer(spark); - } - } - if(mana > 0) - doParticles(); - - if(mana >= MAX_MANA && !worldObj.isRemote) { - EntityItem item = items.get(0); - for(EntityItem otherItem : items) - if(otherItem != item) - otherItem.setDead(); - else item.setEntityItemStack(new ItemStack(ModItems.manaResource, 1, 4)); - item.worldObj.playSoundAtEntity(item, "botania:terrasteelCraft", 1F, 1F); - mana = 0; - worldObj.func_147453_f(xCoord, yCoord, zCoord, worldObj.getBlock(xCoord, yCoord, zCoord)); - VanillaPacketDispatcher.dispatchTEToNearbyPlayers(worldObj, xCoord, yCoord, zCoord); - } - } - } - - if(removeMana) - recieveMana(-1000); - } - - void doParticles() { - if(worldObj.isRemote) { - int ticks = (int) (100.0 * ((double) getCurrentMana() / (double) MAX_MANA)); - - int totalSpiritCount = 3; - double tickIncrement = 360D / totalSpiritCount; - - int speed = 5; - double wticks = ticks * speed - tickIncrement; - - double r = Math.sin((ticks - 100) / 10D) * 2; - double g = Math.sin(wticks * Math.PI / 180 * 0.55); - - for(int i = 0; i < totalSpiritCount; i++) { - double x = xCoord + Math.sin(wticks * Math.PI / 180) * r + 0.5; - double y = yCoord + 0.25 + Math.abs(r) * 0.7; - double z = zCoord + Math.cos(wticks * Math.PI / 180) * r + 0.5; - - wticks += tickIncrement; - float[] colorsfx = new float[] { - 0F, (float) ticks / (float) 100, 1F - (float) ticks / (float) 100 - }; - Botania.proxy.wispFX(worldObj, x, y, z, colorsfx[0], colorsfx[1], colorsfx[2], 0.85F, (float)g * 0.05F, 0.25F); - Botania.proxy.wispFX(worldObj, x, y, z, colorsfx[0], colorsfx[1], colorsfx[2], (float) Math.random() * 0.1F + 0.1F, (float) (Math.random() - 0.5) * 0.05F, (float) (Math.random() - 0.5) * 0.05F, (float) (Math.random() - 0.5) * 0.05F, 0.9F); - - if(ticks == 100) - for(int j = 0; j < 15; j++) - Botania.proxy.wispFX(worldObj, xCoord + 0.5, yCoord + 0.5, zCoord + 0.5, colorsfx[0], colorsfx[1], colorsfx[2], (float) Math.random() * 0.15F + 0.15F, (float) (Math.random() - 0.5F) * 0.125F, (float) (Math.random() - 0.5F) * 0.125F, (float) (Math.random() - 0.5F) * 0.125F); - } - } - } - - List getItems() { - return worldObj.getEntitiesWithinAABB(EntityItem.class, AxisAlignedBB.getBoundingBox(xCoord, yCoord, zCoord, xCoord + 1, yCoord + 1, zCoord + 1)); - } - - boolean areItemsValid(List items) { - if(items.size() != 3) - return false; - - ItemStack ingot = null; - ItemStack pearl = null; - ItemStack diamond = null; - for(EntityItem item : items) { - ItemStack stack = item.getEntityItem(); - if(stack.getItem() != ModItems.manaResource || stack.stackSize != 1) - return false; - - int meta = stack.getItemDamage(); - if(meta == 0) - ingot = stack; - else if(meta == 1) - pearl = stack; - else if(meta == 2) - diamond = stack; - else return false; - } - - return ingot != null && pearl != null && diamond != null; - } - - boolean hasValidPlatform() { - return checkAll(LAPIS_BLOCKS, Blocks.lapis_block) && checkAll(LIVINGROCK_BLOCKS, ModBlocks.livingrock); - } - - boolean checkAll(int[][] positions, Block block) { - for (int[] position : positions) { - int[] positions_ = position; - if(!checkPlatform(positions_[0], positions_[1], block)) - return false; - } - - return true; - } - - boolean checkPlatform(int xOff, int zOff, Block block) { - return worldObj.getBlock(xCoord + xOff, yCoord - 1, zOff + zCoord) == block; - } - - @Override - public void writeCustomNBT(NBTTagCompound cmp) { - cmp.setInteger(TAG_MANA, mana); - } - - @Override - public void readCustomNBT(NBTTagCompound cmp) { - mana = cmp.getInteger(TAG_MANA); - } - - @Override - public int getCurrentMana() { - return mana; - } - - @Override - public boolean isFull() { - return mana >= MAX_MANA; - } - - @Override - public void recieveMana(int mana) { - this.mana = Math.max(0, Math.min(MAX_MANA, this.mana + mana)); - worldObj.func_147453_f(xCoord, yCoord, zCoord, worldObj.getBlock(xCoord, yCoord, zCoord)); - } - - @Override - public boolean canRecieveManaFromBursts() { - return areItemsValid(getItems()); - } - - @Override - public boolean canAttachSpark(ItemStack stack) { - return true; - } - - @Override - public void attachSpark(ISparkEntity entity) { - // NO-OP - } - - @Override - public ISparkEntity getAttachedSpark() { - List sparks = worldObj.getEntitiesWithinAABB(ISparkEntity.class, AxisAlignedBB.getBoundingBox(xCoord, yCoord + 1, zCoord, xCoord + 1, yCoord + 2, zCoord + 1)); - if(sparks.size() == 1) { - Entity e = (Entity) sparks.get(0); - return (ISparkEntity) e; - } - - return null; - } - - @Override - public boolean areIncomingTranfersDone() { - return !areItemsValid(getItems()); - } - - @Override - public int getAvailableSpaceForMana() { - return Math.max(0, MAX_MANA - getCurrentMana()); - } - + public static final int MAX_MANA = TilePool.MAX_MANA / 2; + private static final int[][] LAPIS_BLOCKS = { + { + 1, 0, + }, + {-1, 0}, + {0, 1}, + {0, -1} + }; + + private static final int[][] LIVINGROCK_BLOCKS = {{0, 0}, {1, 1}, {1, -1}, {-1, 1}, {-1, -1}}; + + private static final String TAG_MANA = "mana"; + + int mana; + + public static MultiblockSet makeMultiblockSet() { + Multiblock mb = new Multiblock(); + + for (int[] l : LAPIS_BLOCKS) mb.addComponent(l[0], 0, l[1], Blocks.lapis_block, 0); + for (int[] l : LIVINGROCK_BLOCKS) mb.addComponent(l[0], 0, l[1], ModBlocks.livingrock, 0); + + mb.addComponent(0, 1, 0, ModBlocks.terraPlate, 0); + mb.setRenderOffset(0, 1, 0); + + return mb.makeSet(); + } + + @Override + public void updateEntity() { + boolean removeMana = true; + + if (hasValidPlatform()) { + List items = getItems(); + if (areItemsValid(items)) { + removeMana = false; + ISparkEntity spark = getAttachedSpark(); + if (spark != null) { + List sparkEntities = + SparkHelper.getSparksAround(worldObj, xCoord + 0.5, yCoord + 0.5, zCoord + 0.5); + for (ISparkEntity otherSpark : sparkEntities) { + if (spark == otherSpark) continue; + + if (otherSpark.getAttachedTile() != null && otherSpark.getAttachedTile() instanceof IManaPool) + otherSpark.registerTransfer(spark); + } + } + if (mana > 0) doParticles(); + + if (mana >= MAX_MANA && !worldObj.isRemote) { + EntityItem item = items.get(0); + for (EntityItem otherItem : items) + if (otherItem != item) otherItem.setDead(); + else item.setEntityItemStack(new ItemStack(ModItems.manaResource, 1, 4)); + item.worldObj.playSoundAtEntity(item, "botania:terrasteelCraft", 1F, 1F); + mana = 0; + worldObj.func_147453_f(xCoord, yCoord, zCoord, worldObj.getBlock(xCoord, yCoord, zCoord)); + VanillaPacketDispatcher.dispatchTEToNearbyPlayers(worldObj, xCoord, yCoord, zCoord); + } + } + } + + if (removeMana) recieveMana(-1000); + } + + void doParticles() { + if (worldObj.isRemote) { + int ticks = (int) (100.0 * ((double) getCurrentMana() / (double) MAX_MANA)); + + int totalSpiritCount = 3; + double tickIncrement = 360D / totalSpiritCount; + + int speed = 5; + double wticks = ticks * speed - tickIncrement; + + double r = Math.sin((ticks - 100) / 10D) * 2; + double g = Math.sin(wticks * Math.PI / 180 * 0.55); + + for (int i = 0; i < totalSpiritCount; i++) { + double x = xCoord + Math.sin(wticks * Math.PI / 180) * r + 0.5; + double y = yCoord + 0.25 + Math.abs(r) * 0.7; + double z = zCoord + Math.cos(wticks * Math.PI / 180) * r + 0.5; + + wticks += tickIncrement; + float[] colorsfx = new float[] {0F, (float) ticks / (float) 100, 1F - (float) ticks / (float) 100}; + Botania.proxy.wispFX( + worldObj, x, y, z, colorsfx[0], colorsfx[1], colorsfx[2], 0.85F, (float) g * 0.05F, 0.25F); + Botania.proxy.wispFX( + worldObj, + x, + y, + z, + colorsfx[0], + colorsfx[1], + colorsfx[2], + (float) Math.random() * 0.1F + 0.1F, + (float) (Math.random() - 0.5) * 0.05F, + (float) (Math.random() - 0.5) * 0.05F, + (float) (Math.random() - 0.5) * 0.05F, + 0.9F); + + if (ticks == 100) + for (int j = 0; j < 15; j++) + Botania.proxy.wispFX( + worldObj, + xCoord + 0.5, + yCoord + 0.5, + zCoord + 0.5, + colorsfx[0], + colorsfx[1], + colorsfx[2], + (float) Math.random() * 0.15F + 0.15F, + (float) (Math.random() - 0.5F) * 0.125F, + (float) (Math.random() - 0.5F) * 0.125F, + (float) (Math.random() - 0.5F) * 0.125F); + } + } + } + + List getItems() { + return worldObj.getEntitiesWithinAABB( + EntityItem.class, + AxisAlignedBB.getBoundingBox(xCoord, yCoord, zCoord, xCoord + 1, yCoord + 1, zCoord + 1)); + } + + boolean areItemsValid(List items) { + if (items.size() != 3) return false; + + ItemStack ingot = null; + ItemStack pearl = null; + ItemStack diamond = null; + for (EntityItem item : items) { + ItemStack stack = item.getEntityItem(); + if (stack.getItem() != ModItems.manaResource || stack.stackSize != 1) return false; + + int meta = stack.getItemDamage(); + if (meta == 0) ingot = stack; + else if (meta == 1) pearl = stack; + else if (meta == 2) diamond = stack; + else return false; + } + + return ingot != null && pearl != null && diamond != null; + } + + boolean hasValidPlatform() { + return checkAll(LAPIS_BLOCKS, Blocks.lapis_block) && checkAll(LIVINGROCK_BLOCKS, ModBlocks.livingrock); + } + + boolean checkAll(int[][] positions, Block block) { + for (int[] position : positions) { + int[] positions_ = position; + if (!checkPlatform(positions_[0], positions_[1], block)) return false; + } + + return true; + } + + boolean checkPlatform(int xOff, int zOff, Block block) { + return worldObj.getBlock(xCoord + xOff, yCoord - 1, zOff + zCoord) == block; + } + + @Override + public void writeCustomNBT(NBTTagCompound cmp) { + cmp.setInteger(TAG_MANA, mana); + } + + @Override + public void readCustomNBT(NBTTagCompound cmp) { + mana = cmp.getInteger(TAG_MANA); + } + + @Override + public int getCurrentMana() { + return mana; + } + + @Override + public boolean isFull() { + return mana >= MAX_MANA; + } + + @Override + public void recieveMana(int mana) { + this.mana = Math.max(0, Math.min(MAX_MANA, this.mana + mana)); + worldObj.func_147453_f(xCoord, yCoord, zCoord, worldObj.getBlock(xCoord, yCoord, zCoord)); + } + + @Override + public boolean canRecieveManaFromBursts() { + return areItemsValid(getItems()); + } + + @Override + public boolean canAttachSpark(ItemStack stack) { + return true; + } + + @Override + public void attachSpark(ISparkEntity entity) { + // NO-OP + } + + @Override + public ISparkEntity getAttachedSpark() { + List sparks = worldObj.getEntitiesWithinAABB( + ISparkEntity.class, + AxisAlignedBB.getBoundingBox(xCoord, yCoord + 1, zCoord, xCoord + 1, yCoord + 2, zCoord + 1)); + if (sparks.size() == 1) { + Entity e = (Entity) sparks.get(0); + return (ISparkEntity) e; + } + + return null; + } + + @Override + public boolean areIncomingTranfersDone() { + return !areItemsValid(getItems()); + } + + @Override + public int getAvailableSpaceForMana() { + return Math.max(0, MAX_MANA - getCurrentMana()); + } } diff --git a/src/main/java/vazkii/botania/common/block/tile/TileTeruTeruBozu.java b/src/main/java/vazkii/botania/common/block/tile/TileTeruTeruBozu.java index 21e8fd2d0c..6aff9faff0 100644 --- a/src/main/java/vazkii/botania/common/block/tile/TileTeruTeruBozu.java +++ b/src/main/java/vazkii/botania/common/block/tile/TileTeruTeruBozu.java @@ -2,27 +2,26 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Oct 1, 2015, 1:11:44 PM (GMT)] */ package vazkii.botania.common.block.tile; public class TileTeruTeruBozu extends TileMod { - public boolean wasRaining = false; + public boolean wasRaining = false; - @Override - public void updateEntity() { - boolean isRaining = worldObj.isRaining(); - if(isRaining && worldObj.rand.nextInt(9600) == 0) - worldObj.getWorldInfo().setRaining(false); - - if(wasRaining != isRaining) - worldObj.func_147453_f(xCoord, yCoord, zCoord, worldObj.getBlock(xCoord, yCoord, zCoord)); - wasRaining = isRaining; - } + @Override + public void updateEntity() { + boolean isRaining = worldObj.isRaining(); + if (isRaining && worldObj.rand.nextInt(9600) == 0) + worldObj.getWorldInfo().setRaining(false); + if (wasRaining != isRaining) + worldObj.func_147453_f(xCoord, yCoord, zCoord, worldObj.getBlock(xCoord, yCoord, zCoord)); + wasRaining = isRaining; + } } diff --git a/src/main/java/vazkii/botania/common/block/tile/TileTinyPlanet.java b/src/main/java/vazkii/botania/common/block/tile/TileTinyPlanet.java index c7c14bc8b3..dfc286d924 100644 --- a/src/main/java/vazkii/botania/common/block/tile/TileTinyPlanet.java +++ b/src/main/java/vazkii/botania/common/block/tile/TileTinyPlanet.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [May 1, 2014, 3:49:53 PM (GMT)] */ package vazkii.botania.common.block.tile; @@ -15,14 +15,13 @@ public class TileTinyPlanet extends TileMod implements IManaCollisionGhost { - @Override - public void updateEntity() { - ItemTinyPlanet.applyEffect(worldObj, xCoord + 0.5, yCoord + 0.5, zCoord + 0.5); - } - - @Override - public boolean isGhost() { - return true; - } + @Override + public void updateEntity() { + ItemTinyPlanet.applyEffect(worldObj, xCoord + 0.5, yCoord + 0.5, zCoord + 0.5); + } + @Override + public boolean isGhost() { + return true; + } } diff --git a/src/main/java/vazkii/botania/common/block/tile/TileTinyPotato.java b/src/main/java/vazkii/botania/common/block/tile/TileTinyPotato.java index bc3f60e320..5d889c7435 100644 --- a/src/main/java/vazkii/botania/common/block/tile/TileTinyPotato.java +++ b/src/main/java/vazkii/botania/common/block/tile/TileTinyPotato.java @@ -2,56 +2,51 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jul 18, 2014, 8:05:08 PM (GMT)] */ package vazkii.botania.common.block.tile; import net.minecraft.nbt.NBTTagCompound; - public class TileTinyPotato extends TileMod { - private static final String TAG_NAME = "name"; - - public int jumpTicks = 0; - public String name = ""; - public int nextDoIt = 0; - - public void interact() { - jump(); - if(name.equalsIgnoreCase("shia labeouf") && !worldObj.isRemote && nextDoIt == 0) { - nextDoIt = 40; - worldObj.playSoundEffect(xCoord, yCoord, zCoord, "botania:doit", 1F, 1F); - } - } - - public void jump() { - if(jumpTicks == 0) - jumpTicks = 20; - } - - @Override - public void updateEntity() { - if(worldObj.rand.nextInt(100) == 0) - jump(); - - if(jumpTicks > 0) - jumpTicks--; - if(nextDoIt > 0) - nextDoIt--; - } - - @Override - public void writeCustomNBT(NBTTagCompound cmp) { - cmp.setString(TAG_NAME, name); - } - - @Override - public void readCustomNBT(NBTTagCompound cmp) { - name = cmp.getString(TAG_NAME); - } + private static final String TAG_NAME = "name"; + + public int jumpTicks = 0; + public String name = ""; + public int nextDoIt = 0; + + public void interact() { + jump(); + if (name.equalsIgnoreCase("shia labeouf") && !worldObj.isRemote && nextDoIt == 0) { + nextDoIt = 40; + worldObj.playSoundEffect(xCoord, yCoord, zCoord, "botania:doit", 1F, 1F); + } + } + + public void jump() { + if (jumpTicks == 0) jumpTicks = 20; + } + + @Override + public void updateEntity() { + if (worldObj.rand.nextInt(100) == 0) jump(); + + if (jumpTicks > 0) jumpTicks--; + if (nextDoIt > 0) nextDoIt--; + } + + @Override + public void writeCustomNBT(NBTTagCompound cmp) { + cmp.setString(TAG_NAME, name); + } + + @Override + public void readCustomNBT(NBTTagCompound cmp) { + name = cmp.getString(TAG_NAME); + } } diff --git a/src/main/java/vazkii/botania/common/block/tile/corporea/TileCorporeaBase.java b/src/main/java/vazkii/botania/common/block/tile/corporea/TileCorporeaBase.java index d3af0ac8e3..e55bd444d6 100644 --- a/src/main/java/vazkii/botania/common/block/tile/corporea/TileCorporeaBase.java +++ b/src/main/java/vazkii/botania/common/block/tile/corporea/TileCorporeaBase.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Feb 15, 2015, 12:25:19 AM (GMT)] */ package vazkii.botania.common.block.tile.corporea; @@ -16,8 +16,7 @@ public abstract class TileCorporeaBase extends TileSimpleInventory { - public ICorporeaSpark getSpark() { - return CorporeaHelper.getSparkForBlock(worldObj, xCoord, yCoord, zCoord); - } - + public ICorporeaSpark getSpark() { + return CorporeaHelper.getSparkForBlock(worldObj, xCoord, yCoord, zCoord); + } } diff --git a/src/main/java/vazkii/botania/common/block/tile/corporea/TileCorporeaCrystalCube.java b/src/main/java/vazkii/botania/common/block/tile/corporea/TileCorporeaCrystalCube.java index 0c8b71c2ea..a67aa16fab 100644 --- a/src/main/java/vazkii/botania/common/block/tile/corporea/TileCorporeaCrystalCube.java +++ b/src/main/java/vazkii/botania/common/block/tile/corporea/TileCorporeaCrystalCube.java @@ -2,16 +2,15 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Apr 30, 2015, 3:57:57 PM (GMT)] */ package vazkii.botania.common.block.tile.corporea; import java.util.List; - import net.minecraft.entity.item.EntityItem; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; @@ -23,137 +22,127 @@ public class TileCorporeaCrystalCube extends TileCorporeaBase implements ICorporeaRequestor { - private static final String TAG_REQUEST_TARGET = "requestTarget"; - private static final String TAG_ITEM_COUNT = "itemCount"; - - private static final double LOG_2 = Math.log(2); - - ItemStack requestTarget; - int itemCount = 0; - int ticks = 0; - public int compValue = 0; - - @Override - public void updateEntity() { - ++ticks; - if(ticks % 20 == 0) - updateCount(); - } - - public void setRequestTarget(ItemStack stack) { - if(stack != null) { - ItemStack copy = stack.copy(); - copy.stackSize = 1; - requestTarget = copy; - updateCount(); - if(!worldObj.isRemote) - VanillaPacketDispatcher.dispatchTEToNearbyPlayers(this); - } - - } - - public ItemStack getRequestTarget() { - return requestTarget; - } - - public int getItemCount() { - return itemCount; - } - - public void doRequest(boolean fullStack) { - if(worldObj.isRemote) - return; - - ICorporeaSpark spark = getSpark(); - if(spark != null && spark.getMaster() != null && requestTarget != null) { - int count = fullStack ? requestTarget.getMaxStackSize() : 1; - doCorporeaRequest(requestTarget, count, spark); - } - } - - private void updateCount() { - if(worldObj.isRemote) - return; - - int oldCount = itemCount; - itemCount = 0; - ICorporeaSpark spark = getSpark(); - if(spark != null && spark.getMaster() != null && requestTarget != null) { - List stacks = CorporeaHelper.requestItem(requestTarget, -1, spark, true, false); - for(ItemStack stack : stacks) - itemCount += stack.stackSize; - } - - if(itemCount != oldCount) { - VanillaPacketDispatcher.dispatchTEToNearbyPlayers(this); - onUpdateCount(); - } - } - - private void onUpdateCount() { - compValue = getComparatorValue(); - worldObj.func_147453_f(xCoord, yCoord, zCoord, worldObj.getBlock(xCoord, yCoord, zCoord)); - } - - @Override - public void writeCustomNBT(NBTTagCompound par1nbtTagCompound) { - super.writeCustomNBT(par1nbtTagCompound); - NBTTagCompound cmp = new NBTTagCompound(); - if(requestTarget != null) - requestTarget.writeToNBT(cmp); - par1nbtTagCompound.setTag(TAG_REQUEST_TARGET, cmp); - par1nbtTagCompound.setInteger(TAG_ITEM_COUNT, itemCount); - } - - @Override - public void readCustomNBT(NBTTagCompound par1nbtTagCompound) { - super.readCustomNBT(par1nbtTagCompound); - NBTTagCompound cmp = par1nbtTagCompound.getCompoundTag(TAG_REQUEST_TARGET); - requestTarget = ItemStack.loadItemStackFromNBT(cmp); - itemCount = par1nbtTagCompound.getInteger(TAG_ITEM_COUNT); - } - - @Override - public int getSizeInventory() { - return 1; - } - - public int getComparatorValue() { - if(itemCount == 0) - return 0; - return Math.min(15, (int) Math.floor(Math.log(itemCount) / LOG_2) + 1); - } - - @Override - public boolean isItemValidForSlot(int i, ItemStack itemstack) { - return false; - } - - @Override - public String getInventoryName() { - return LibBlockNames.CORPOREA_CRYSTAL_CUBE; - } - - @Override - public void doCorporeaRequest(Object request, int count, ICorporeaSpark spark) { - if(!(request instanceof ItemStack)) - return; - - List stacks = CorporeaHelper.requestItem(request, count, spark, true, true); - spark.onItemsRequested(stacks); - boolean did = false; - for(ItemStack reqStack : stacks) - if(requestTarget != null) { - EntityItem item = new EntityItem(worldObj, xCoord + 0.5, yCoord + 1.5, zCoord + 0.5, reqStack); - worldObj.spawnEntityInWorld(item); - itemCount -= reqStack.stackSize; - did = true; - } - - if(did) { - VanillaPacketDispatcher.dispatchTEToNearbyPlayers(this); - onUpdateCount(); - } - } - + private static final String TAG_REQUEST_TARGET = "requestTarget"; + private static final String TAG_ITEM_COUNT = "itemCount"; + + private static final double LOG_2 = Math.log(2); + + ItemStack requestTarget; + int itemCount = 0; + int ticks = 0; + public int compValue = 0; + + @Override + public void updateEntity() { + ++ticks; + if (ticks % 20 == 0) updateCount(); + } + + public void setRequestTarget(ItemStack stack) { + if (stack != null) { + ItemStack copy = stack.copy(); + copy.stackSize = 1; + requestTarget = copy; + updateCount(); + if (!worldObj.isRemote) VanillaPacketDispatcher.dispatchTEToNearbyPlayers(this); + } + } + + public ItemStack getRequestTarget() { + return requestTarget; + } + + public int getItemCount() { + return itemCount; + } + + public void doRequest(boolean fullStack) { + if (worldObj.isRemote) return; + + ICorporeaSpark spark = getSpark(); + if (spark != null && spark.getMaster() != null && requestTarget != null) { + int count = fullStack ? requestTarget.getMaxStackSize() : 1; + doCorporeaRequest(requestTarget, count, spark); + } + } + + private void updateCount() { + if (worldObj.isRemote) return; + + int oldCount = itemCount; + itemCount = 0; + ICorporeaSpark spark = getSpark(); + if (spark != null && spark.getMaster() != null && requestTarget != null) { + List stacks = CorporeaHelper.requestItem(requestTarget, -1, spark, true, false); + for (ItemStack stack : stacks) itemCount += stack.stackSize; + } + + if (itemCount != oldCount) { + VanillaPacketDispatcher.dispatchTEToNearbyPlayers(this); + onUpdateCount(); + } + } + + private void onUpdateCount() { + compValue = getComparatorValue(); + worldObj.func_147453_f(xCoord, yCoord, zCoord, worldObj.getBlock(xCoord, yCoord, zCoord)); + } + + @Override + public void writeCustomNBT(NBTTagCompound par1nbtTagCompound) { + super.writeCustomNBT(par1nbtTagCompound); + NBTTagCompound cmp = new NBTTagCompound(); + if (requestTarget != null) requestTarget.writeToNBT(cmp); + par1nbtTagCompound.setTag(TAG_REQUEST_TARGET, cmp); + par1nbtTagCompound.setInteger(TAG_ITEM_COUNT, itemCount); + } + + @Override + public void readCustomNBT(NBTTagCompound par1nbtTagCompound) { + super.readCustomNBT(par1nbtTagCompound); + NBTTagCompound cmp = par1nbtTagCompound.getCompoundTag(TAG_REQUEST_TARGET); + requestTarget = ItemStack.loadItemStackFromNBT(cmp); + itemCount = par1nbtTagCompound.getInteger(TAG_ITEM_COUNT); + } + + @Override + public int getSizeInventory() { + return 1; + } + + public int getComparatorValue() { + if (itemCount == 0) return 0; + return Math.min(15, (int) Math.floor(Math.log(itemCount) / LOG_2) + 1); + } + + @Override + public boolean isItemValidForSlot(int i, ItemStack itemstack) { + return false; + } + + @Override + public String getInventoryName() { + return LibBlockNames.CORPOREA_CRYSTAL_CUBE; + } + + @Override + public void doCorporeaRequest(Object request, int count, ICorporeaSpark spark) { + if (!(request instanceof ItemStack)) return; + + List stacks = CorporeaHelper.requestItem(request, count, spark, true, true); + spark.onItemsRequested(stacks); + boolean did = false; + for (ItemStack reqStack : stacks) + if (requestTarget != null) { + EntityItem item = new EntityItem(worldObj, xCoord + 0.5, yCoord + 1.5, zCoord + 0.5, reqStack); + worldObj.spawnEntityInWorld(item); + itemCount -= reqStack.stackSize; + did = true; + } + + if (did) { + VanillaPacketDispatcher.dispatchTEToNearbyPlayers(this); + onUpdateCount(); + } + } } diff --git a/src/main/java/vazkii/botania/common/block/tile/corporea/TileCorporeaFunnel.java b/src/main/java/vazkii/botania/common/block/tile/corporea/TileCorporeaFunnel.java index 5692517383..e1cd4e898e 100644 --- a/src/main/java/vazkii/botania/common/block/tile/corporea/TileCorporeaFunnel.java +++ b/src/main/java/vazkii/botania/common/block/tile/corporea/TileCorporeaFunnel.java @@ -2,17 +2,16 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Feb 16, 2015, 2:18:30 PM (GMT)] */ package vazkii.botania.common.block.tile.corporea; import java.util.ArrayList; import java.util.List; - import net.minecraft.entity.item.EntityItem; import net.minecraft.entity.item.EntityItemFrame; import net.minecraft.inventory.IInventory; @@ -28,82 +27,86 @@ public class TileCorporeaFunnel extends TileCorporeaBase implements ICorporeaRequestor { - public void doRequest() { - ICorporeaSpark spark = getSpark(); - if(spark != null && spark.getMaster() != null) { - List filter = getFilter(); - if(!filter.isEmpty()) { - ItemStack stack = filter.get(worldObj.rand.nextInt(filter.size())); - - if(stack != null) - doCorporeaRequest(stack, stack.stackSize, spark); - } - } - } - - public List getFilter() { - List filter = new ArrayList(); - - final int[] orientationToDir = new int[] { - 3, 4, 2, 5 - }; - final int[] rotationToStackSize = new int[] { - 1, 16, 32, 64 - }; - - for(ForgeDirection dir : LibMisc.CARDINAL_DIRECTIONS) { - List frames = worldObj.getEntitiesWithinAABB(EntityItemFrame.class, AxisAlignedBB.getBoundingBox(xCoord + dir.offsetX, yCoord + dir.offsetY, zCoord + dir.offsetZ, xCoord + dir.offsetX + 1, yCoord + dir.offsetY + 1, zCoord + dir.offsetZ + 1)); - for(EntityItemFrame frame : frames) { - int orientation = frame.hangingDirection; - if(orientationToDir[orientation] == dir.ordinal()) { - ItemStack stack = frame.getDisplayedItem(); - if(stack != null) { - ItemStack copy = stack.copy(); - copy.stackSize = rotationToStackSize[frame.getRotation()]; - filter.add(copy); - } - } - } - } - - return filter; - } - - @Override - public boolean isItemValidForSlot(int i, ItemStack itemstack) { - return false; - } - - @Override - public int getSizeInventory() { - return 1; - } - - @Override - public String getInventoryName() { - return LibBlockNames.CORPOREA_FUNNEL; - } - - @Override - public void doCorporeaRequest(Object request, int count, ICorporeaSpark spark) { - if(!(request instanceof ItemStack)) - return; - - IInventory inv = InventoryHelper.getInventory(worldObj, xCoord, yCoord - 1, zCoord); - if(inv == null || inv instanceof TileCorporeaFunnel) - inv = InventoryHelper.getInventory(worldObj, xCoord, yCoord - 2, zCoord); - - List stacks = CorporeaHelper.requestItem(request, count, spark, true, true); - spark.onItemsRequested(stacks); - for(ItemStack reqStack : stacks) - if(request != null) { - if(inv != null && !(inv instanceof TileCorporeaFunnel) && reqStack.stackSize == InventoryHelper.testInventoryInsertion(inv, reqStack, ForgeDirection.UP)) - InventoryHelper.insertItemIntoInventory(inv, reqStack); - else { - EntityItem item = new EntityItem(worldObj, xCoord + 0.5, yCoord + 1.5, zCoord + 0.5, reqStack); - worldObj.spawnEntityInWorld(item); - } - } - } - + public void doRequest() { + ICorporeaSpark spark = getSpark(); + if (spark != null && spark.getMaster() != null) { + List filter = getFilter(); + if (!filter.isEmpty()) { + ItemStack stack = filter.get(worldObj.rand.nextInt(filter.size())); + + if (stack != null) doCorporeaRequest(stack, stack.stackSize, spark); + } + } + } + + public List getFilter() { + List filter = new ArrayList(); + + final int[] orientationToDir = new int[] {3, 4, 2, 5}; + final int[] rotationToStackSize = new int[] {1, 16, 32, 64}; + + for (ForgeDirection dir : LibMisc.CARDINAL_DIRECTIONS) { + List frames = worldObj.getEntitiesWithinAABB( + EntityItemFrame.class, + AxisAlignedBB.getBoundingBox( + xCoord + dir.offsetX, + yCoord + dir.offsetY, + zCoord + dir.offsetZ, + xCoord + dir.offsetX + 1, + yCoord + dir.offsetY + 1, + zCoord + dir.offsetZ + 1)); + for (EntityItemFrame frame : frames) { + int orientation = frame.hangingDirection; + if (orientationToDir[orientation] == dir.ordinal()) { + ItemStack stack = frame.getDisplayedItem(); + if (stack != null) { + ItemStack copy = stack.copy(); + copy.stackSize = rotationToStackSize[frame.getRotation()]; + filter.add(copy); + } + } + } + } + + return filter; + } + + @Override + public boolean isItemValidForSlot(int i, ItemStack itemstack) { + return false; + } + + @Override + public int getSizeInventory() { + return 1; + } + + @Override + public String getInventoryName() { + return LibBlockNames.CORPOREA_FUNNEL; + } + + @Override + public void doCorporeaRequest(Object request, int count, ICorporeaSpark spark) { + if (!(request instanceof ItemStack)) return; + + IInventory inv = InventoryHelper.getInventory(worldObj, xCoord, yCoord - 1, zCoord); + if (inv == null || inv instanceof TileCorporeaFunnel) + inv = InventoryHelper.getInventory(worldObj, xCoord, yCoord - 2, zCoord); + + List stacks = CorporeaHelper.requestItem(request, count, spark, true, true); + spark.onItemsRequested(stacks); + for (ItemStack reqStack : stacks) + if (request != null) { + if (inv != null + && !(inv instanceof TileCorporeaFunnel) + && reqStack.stackSize + == InventoryHelper.testInventoryInsertion(inv, reqStack, ForgeDirection.UP)) + InventoryHelper.insertItemIntoInventory(inv, reqStack); + else { + EntityItem item = new EntityItem(worldObj, xCoord + 0.5, yCoord + 1.5, zCoord + 0.5, reqStack); + worldObj.spawnEntityInWorld(item); + } + } + } } diff --git a/src/main/java/vazkii/botania/common/block/tile/corporea/TileCorporeaIndex.java b/src/main/java/vazkii/botania/common/block/tile/corporea/TileCorporeaIndex.java index 11875e1f07..25470db207 100644 --- a/src/main/java/vazkii/botania/common/block/tile/corporea/TileCorporeaIndex.java +++ b/src/main/java/vazkii/botania/common/block/tile/corporea/TileCorporeaIndex.java @@ -2,14 +2,18 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Feb 15, 2015, 12:42:29 AM (GMT)] */ package vazkii.botania.common.block.tile.corporea; +import cpw.mods.fml.common.eventhandler.EventPriority; +import cpw.mods.fml.common.eventhandler.SubscribeEvent; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; import java.util.ArrayList; import java.util.Collections; import java.util.LinkedHashMap; @@ -19,7 +23,6 @@ import java.util.WeakHashMap; import java.util.regex.Matcher; import java.util.regex.Pattern; - import net.minecraft.client.Minecraft; import net.minecraft.entity.item.EntityItem; import net.minecraft.entity.player.EntityPlayer; @@ -29,9 +32,7 @@ import net.minecraft.util.ChatStyle; import net.minecraft.util.EnumChatFormatting; import net.minecraftforge.event.ServerChatEvent; - import org.apache.commons.lang3.text.WordUtils; - import vazkii.botania.api.corporea.CorporeaHelper; import vazkii.botania.api.corporea.ICorporeaAutoCompleteController; import vazkii.botania.api.corporea.ICorporeaRequestor; @@ -39,274 +40,370 @@ import vazkii.botania.common.achievement.ModAchievements; import vazkii.botania.common.core.helper.MathHelper; import vazkii.botania.common.lib.LibBlockNames; -import cpw.mods.fml.common.eventhandler.EventPriority; -import cpw.mods.fml.common.eventhandler.SubscribeEvent; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; public class TileCorporeaIndex extends TileCorporeaBase implements ICorporeaRequestor { - public static final double RADIUS = 2.5; - - private static InputHandler input; - public static final Set indexes = Collections.newSetFromMap(new WeakHashMap()); - - private static final Map patterns = new LinkedHashMap(); - - /** - * (name) = Item name, or "this" for the name of the item in your hand - * (n), (n1), (n2), etc = Numbers - * [text] = Optional - * = Either a or b - */ - static { - // (name) = 1 - addPattern("(.+)", new IRegexStacker() { - @Override public int getCount(Matcher m) { return 1; } - @Override public String getName(Matcher m) { return m.group(1); } - }); - - // [a][n] (name) = 1 - addPattern("a??n?? (.+)", new IRegexStacker() { - @Override public int getCount(Matcher m) { return 1; } - @Override public String getName(Matcher m) { return m.group(1); } - }); - - //(n)[x][ of] (name) = n - addPattern("(\\d+)x?(?: of)? (.+)", new IRegexStacker() { - @Override public int getCount(Matcher m) { return i(m, 1); } - @Override public String getName(Matcher m) { return m.group(2); } - }); - - // [a ]stack[ of] (name) = 64 - addPattern("(?:a )?stack(?: of)? (.+)", new IRegexStacker() { - @Override public int getCount(Matcher m) { return 64; } - @Override public String getName(Matcher m) { return m.group(1); } - }); - - // (n)[x] stack[s][ of] (name) = n * 64 - addPattern("(\\d+)x?? stacks?(?: of)? (.+)", new IRegexStacker() { - @Override public int getCount(Matcher m) { return 64 * i(m, 1); } - @Override public String getName(Matcher m) { return m.group(2); } - }); - - // [a ]stack (n)[x][ of] (name) = 64 + n - addPattern("(?:a )?stack (?:(?:and)|(?:\\+)) (\\d+)(?: of)? (.+)", new IRegexStacker() { - @Override public int getCount(Matcher m) { return 64 + i(m, 1); } - @Override public String getName(Matcher m) { return m.group(2); } - }); - - // (n1)[x] stack[s] (n2)[x][ of] (name) = n1 * 64 + n2 - addPattern("(\\d+)x?? stacks? (?:(?:and)|(?:\\+)) (\\d+)x?(?: of)? (.+)", new IRegexStacker() { - @Override public int getCount(Matcher m) { return 64 * i(m, 1) + i(m, 2); } - @Override public String getName(Matcher m) { return m.group(3); } - }); - - // [a ]half [of ][a ]stack[ of] (name) = 32 - addPattern("(?:a )?half (?:of )?(?:a )?stack(?: of)? (.+)", new IRegexStacker() { - @Override public int getCount(Matcher m) { return 32; } - @Override public String getName(Matcher m) { return m.group(1); } - }); - - // [a ]quarter [of ][a ]stack[ of] (name) = 16 - addPattern("(?:a )?quarter (?:of )?(?:a )?stack(?: of)? (.+)", new IRegexStacker() { - @Override public int getCount(Matcher m) { return 16; } - @Override public String getName(Matcher m) { return m.group(1); } - }); - - // [a ]dozen[ of] (name) = 12 - addPattern("(?:a )?dozen(?: of)? (.+)", new IRegexStacker() { - @Override public int getCount(Matcher m) { return 12; } - @Override public String getName(Matcher m) { return m.group(1); } - }); - - // (n)[x] dozen[s][ of] (name) = n * 12 - addPattern("(\\d+)x?? dozens?(?: of)? (.+)", new IRegexStacker() { - @Override public int getCount(Matcher m) { return 12 * i(m, 1); } - @Override public String getName(Matcher m) { return m.group(2); } - }); - - // [ ](name) = 2147483647 - addPattern("(?:all|every) (?:(?:of|the) )?(.+)", new IRegexStacker() { - @Override public int getCount(Matcher m) { return Integer.MAX_VALUE; } - @Override public String getName(Matcher m) { return m.group(1); } - }); - - // [the ]answer to life[,] the universe and everything [of ](name) = 42 - addPattern("(?:the )?answer to life,? the universe and everything (?:of )?(.+)", new IRegexStacker() { - @Override public int getCount(Matcher m) { return 42; } - @Override public String getName(Matcher m) { return m.group(1); } - }); - - // (name) = 0 (display only) - addPattern("(?:count|show|display|tell) (.+)", new IRegexStacker() { - @Override public int getCount(Matcher m) { return 0; } - @Override public String getName(Matcher m) { return m.group(1); } - }); - } - - public int ticks = 0; - public int ticksWithCloseby = 0; - public float closeby = 0F; - public boolean hasCloseby; - - @Override - public void updateEntity() { - super.updateEntity(); - - double x = xCoord + 0.5; - double y = yCoord + 0.5; - double z = zCoord + 0.5; - - List players = worldObj.getEntitiesWithinAABB(EntityPlayer.class, AxisAlignedBB.getBoundingBox(x - RADIUS, y - RADIUS, z - RADIUS, x + RADIUS, y + RADIUS, z + RADIUS)); - hasCloseby = false; - for(EntityPlayer player : players) - if(isInRangeOfIndex(player, this)) { - hasCloseby = true; - break; - } - - float step = 0.2F; - ticks++; - if(hasCloseby) { - ticksWithCloseby++; - if(closeby < 1F) - closeby += step; - } else if(closeby > 0F) - closeby -= step; - - if(!isInvalid() && !indexes.contains(this)) - indexes.add(this); - } - - @Override - public void invalidate() { - super.invalidate(); - indexes.remove(this); - } - - @Override - public void onChunkUnload() { - super.onChunkUnload(); - indexes.remove(this); - } - - @Override - public int getSizeInventory() { - return 0; - } - - @Override - public String getInventoryName() { - return LibBlockNames.CORPOREA_INDEX; - } - - @Override - public void doCorporeaRequest(Object request, int count, ICorporeaSpark spark) { - if(!(request instanceof String)) - return; - - List stacks = CorporeaHelper.requestItem((String) request, count, spark, true); - spark.onItemsRequested(stacks); - for(ItemStack stack : stacks) - if(stack != null) { - EntityItem item = new EntityItem(worldObj, xCoord + 0.5, yCoord + 1.5, zCoord + 0.5, stack); - worldObj.spawnEntityInWorld(item); - } - } - - public static boolean isInRangeOfIndex(EntityPlayer player, TileCorporeaIndex index) { - return player.worldObj.provider.dimensionId == index.worldObj.provider.dimensionId && MathHelper.pointDistancePlane(index.xCoord + 0.5, index.zCoord + 0.5, player.posX, player.posZ) < RADIUS && Math.abs(index.yCoord + 0.5 - player.posY + (player.worldObj.isRemote ? 0 : 1.6)) < 5; - } - - public static void addPattern(String pattern, IRegexStacker stacker) { - patterns.put(Pattern.compile(pattern), stacker); - } - - public static int i(Matcher m, int g) { - try { - int i = Math.abs(Integer.parseInt(m.group(g))); - return i; - } catch(NumberFormatException e) { - return 0; - } - } - - public static InputHandler getInputHandler() { - if(input == null) - input = new InputHandler(); - return input; - } - - public static final class InputHandler implements ICorporeaAutoCompleteController { - - public InputHandler() { - CorporeaHelper.registerAutoCompleteController(this); - } - - @SubscribeEvent(priority = EventPriority.HIGHEST) - public void onChatMessage(ServerChatEvent event) { - List nearbyIndexes = getNearbyIndexes(event.player); - if(!nearbyIndexes.isEmpty()) { - String msg = event.message.toLowerCase().trim(); - for(TileCorporeaIndex index : nearbyIndexes) { - if(index.worldObj.isRemote) - continue; - - ICorporeaSpark spark = index.getSpark(); - if(spark != null) { - String name = ""; - int count = 0; - for(Pattern pattern : patterns.keySet()) { - Matcher matcher = pattern.matcher(msg); - if(matcher.matches()) { - IRegexStacker stacker = patterns.get(pattern); - count = stacker.getCount(matcher); - name = stacker.getName(matcher).toLowerCase().trim(); - pattern.toString(); - } - } - - if(name.equals("this")) { - ItemStack stack = event.player.getCurrentEquippedItem(); - if(stack != null) - name = stack.getDisplayName().toLowerCase().trim(); - } - - index.doCorporeaRequest(name, count, spark); - - event.player.addChatMessage(new ChatComponentTranslation("botaniamisc.requestMsg", count, WordUtils.capitalizeFully(name), CorporeaHelper.lastRequestMatches, CorporeaHelper.lastRequestExtractions).setChatStyle(new ChatStyle().setColor(EnumChatFormatting.LIGHT_PURPLE))); - if(CorporeaHelper.lastRequestExtractions >= 50000) - event.player.addStat(ModAchievements.superCorporeaRequest, 1); - } - } - - event.setCanceled(true); - } - } - - public static List getNearbyIndexes(EntityPlayer player) { - List indexList = new ArrayList(); - for(TileCorporeaIndex index : indexes) - if(isInRangeOfIndex(player, index) && index.worldObj.isRemote == player.worldObj.isRemote) - indexList.add(index); - return indexList; - } - - @Override - @SideOnly(Side.CLIENT) - public boolean shouldAutoComplete() { - return !getNearbyIndexes(Minecraft.getMinecraft().thePlayer).isEmpty(); - } - - } - - public static interface IRegexStacker { - - public int getCount(Matcher m); - - public String getName(Matcher m); - - } - + public static final double RADIUS = 2.5; + + private static InputHandler input; + public static final Set indexes = Collections.newSetFromMap(new WeakHashMap()); + + private static final Map patterns = new LinkedHashMap(); + + /** + * (name) = Item name, or "this" for the name of the item in your hand + * (n), (n1), (n2), etc = Numbers + * [text] = Optional + * = Either a or b + */ + static { + // (name) = 1 + addPattern("(.+)", new IRegexStacker() { + @Override + public int getCount(Matcher m) { + return 1; + } + + @Override + public String getName(Matcher m) { + return m.group(1); + } + }); + + // [a][n] (name) = 1 + addPattern("a??n?? (.+)", new IRegexStacker() { + @Override + public int getCount(Matcher m) { + return 1; + } + + @Override + public String getName(Matcher m) { + return m.group(1); + } + }); + + // (n)[x][ of] (name) = n + addPattern("(\\d+)x?(?: of)? (.+)", new IRegexStacker() { + @Override + public int getCount(Matcher m) { + return i(m, 1); + } + + @Override + public String getName(Matcher m) { + return m.group(2); + } + }); + + // [a ]stack[ of] (name) = 64 + addPattern("(?:a )?stack(?: of)? (.+)", new IRegexStacker() { + @Override + public int getCount(Matcher m) { + return 64; + } + + @Override + public String getName(Matcher m) { + return m.group(1); + } + }); + + // (n)[x] stack[s][ of] (name) = n * 64 + addPattern("(\\d+)x?? stacks?(?: of)? (.+)", new IRegexStacker() { + @Override + public int getCount(Matcher m) { + return 64 * i(m, 1); + } + + @Override + public String getName(Matcher m) { + return m.group(2); + } + }); + + // [a ]stack (n)[x][ of] (name) = 64 + n + addPattern("(?:a )?stack (?:(?:and)|(?:\\+)) (\\d+)(?: of)? (.+)", new IRegexStacker() { + @Override + public int getCount(Matcher m) { + return 64 + i(m, 1); + } + + @Override + public String getName(Matcher m) { + return m.group(2); + } + }); + + // (n1)[x] stack[s] (n2)[x][ of] (name) = n1 * 64 + n2 + addPattern("(\\d+)x?? stacks? (?:(?:and)|(?:\\+)) (\\d+)x?(?: of)? (.+)", new IRegexStacker() { + @Override + public int getCount(Matcher m) { + return 64 * i(m, 1) + i(m, 2); + } + + @Override + public String getName(Matcher m) { + return m.group(3); + } + }); + + // [a ]half [of ][a ]stack[ of] (name) = 32 + addPattern("(?:a )?half (?:of )?(?:a )?stack(?: of)? (.+)", new IRegexStacker() { + @Override + public int getCount(Matcher m) { + return 32; + } + + @Override + public String getName(Matcher m) { + return m.group(1); + } + }); + + // [a ]quarter [of ][a ]stack[ of] (name) = 16 + addPattern("(?:a )?quarter (?:of )?(?:a )?stack(?: of)? (.+)", new IRegexStacker() { + @Override + public int getCount(Matcher m) { + return 16; + } + + @Override + public String getName(Matcher m) { + return m.group(1); + } + }); + + // [a ]dozen[ of] (name) = 12 + addPattern("(?:a )?dozen(?: of)? (.+)", new IRegexStacker() { + @Override + public int getCount(Matcher m) { + return 12; + } + + @Override + public String getName(Matcher m) { + return m.group(1); + } + }); + + // (n)[x] dozen[s][ of] (name) = n * 12 + addPattern("(\\d+)x?? dozens?(?: of)? (.+)", new IRegexStacker() { + @Override + public int getCount(Matcher m) { + return 12 * i(m, 1); + } + + @Override + public String getName(Matcher m) { + return m.group(2); + } + }); + + // [ ](name) = 2147483647 + addPattern("(?:all|every) (?:(?:of|the) )?(.+)", new IRegexStacker() { + @Override + public int getCount(Matcher m) { + return Integer.MAX_VALUE; + } + + @Override + public String getName(Matcher m) { + return m.group(1); + } + }); + + // [the ]answer to life[,] the universe and everything [of ](name) = 42 + addPattern("(?:the )?answer to life,? the universe and everything (?:of )?(.+)", new IRegexStacker() { + @Override + public int getCount(Matcher m) { + return 42; + } + + @Override + public String getName(Matcher m) { + return m.group(1); + } + }); + + // (name) = 0 (display only) + addPattern("(?:count|show|display|tell) (.+)", new IRegexStacker() { + @Override + public int getCount(Matcher m) { + return 0; + } + + @Override + public String getName(Matcher m) { + return m.group(1); + } + }); + } + + public int ticks = 0; + public int ticksWithCloseby = 0; + public float closeby = 0F; + public boolean hasCloseby; + + @Override + public void updateEntity() { + super.updateEntity(); + + double x = xCoord + 0.5; + double y = yCoord + 0.5; + double z = zCoord + 0.5; + + List players = worldObj.getEntitiesWithinAABB( + EntityPlayer.class, + AxisAlignedBB.getBoundingBox(x - RADIUS, y - RADIUS, z - RADIUS, x + RADIUS, y + RADIUS, z + RADIUS)); + hasCloseby = false; + for (EntityPlayer player : players) + if (isInRangeOfIndex(player, this)) { + hasCloseby = true; + break; + } + + float step = 0.2F; + ticks++; + if (hasCloseby) { + ticksWithCloseby++; + if (closeby < 1F) closeby += step; + } else if (closeby > 0F) closeby -= step; + + if (!isInvalid() && !indexes.contains(this)) indexes.add(this); + } + + @Override + public void invalidate() { + super.invalidate(); + indexes.remove(this); + } + + @Override + public void onChunkUnload() { + super.onChunkUnload(); + indexes.remove(this); + } + + @Override + public int getSizeInventory() { + return 0; + } + + @Override + public String getInventoryName() { + return LibBlockNames.CORPOREA_INDEX; + } + + @Override + public void doCorporeaRequest(Object request, int count, ICorporeaSpark spark) { + if (!(request instanceof String)) return; + + List stacks = CorporeaHelper.requestItem((String) request, count, spark, true); + spark.onItemsRequested(stacks); + for (ItemStack stack : stacks) + if (stack != null) { + EntityItem item = new EntityItem(worldObj, xCoord + 0.5, yCoord + 1.5, zCoord + 0.5, stack); + worldObj.spawnEntityInWorld(item); + } + } + + public static boolean isInRangeOfIndex(EntityPlayer player, TileCorporeaIndex index) { + return player.worldObj.provider.dimensionId == index.worldObj.provider.dimensionId + && MathHelper.pointDistancePlane(index.xCoord + 0.5, index.zCoord + 0.5, player.posX, player.posZ) + < RADIUS + && Math.abs(index.yCoord + 0.5 - player.posY + (player.worldObj.isRemote ? 0 : 1.6)) < 5; + } + + public static void addPattern(String pattern, IRegexStacker stacker) { + patterns.put(Pattern.compile(pattern), stacker); + } + + public static int i(Matcher m, int g) { + try { + int i = Math.abs(Integer.parseInt(m.group(g))); + return i; + } catch (NumberFormatException e) { + return 0; + } + } + + public static InputHandler getInputHandler() { + if (input == null) input = new InputHandler(); + return input; + } + + public static final class InputHandler implements ICorporeaAutoCompleteController { + + public InputHandler() { + CorporeaHelper.registerAutoCompleteController(this); + } + + @SubscribeEvent(priority = EventPriority.HIGHEST) + public void onChatMessage(ServerChatEvent event) { + List nearbyIndexes = getNearbyIndexes(event.player); + if (!nearbyIndexes.isEmpty()) { + String msg = event.message.toLowerCase().trim(); + for (TileCorporeaIndex index : nearbyIndexes) { + if (index.worldObj.isRemote) continue; + + ICorporeaSpark spark = index.getSpark(); + if (spark != null) { + String name = ""; + int count = 0; + for (Pattern pattern : patterns.keySet()) { + Matcher matcher = pattern.matcher(msg); + if (matcher.matches()) { + IRegexStacker stacker = patterns.get(pattern); + count = stacker.getCount(matcher); + name = stacker.getName(matcher).toLowerCase().trim(); + pattern.toString(); + } + } + + if (name.equals("this")) { + ItemStack stack = event.player.getCurrentEquippedItem(); + if (stack != null) + name = stack.getDisplayName().toLowerCase().trim(); + } + + index.doCorporeaRequest(name, count, spark); + + event.player.addChatMessage(new ChatComponentTranslation( + "botaniamisc.requestMsg", + count, + WordUtils.capitalizeFully(name), + CorporeaHelper.lastRequestMatches, + CorporeaHelper.lastRequestExtractions) + .setChatStyle(new ChatStyle().setColor(EnumChatFormatting.LIGHT_PURPLE))); + if (CorporeaHelper.lastRequestExtractions >= 50000) + event.player.addStat(ModAchievements.superCorporeaRequest, 1); + } + } + + event.setCanceled(true); + } + } + + public static List getNearbyIndexes(EntityPlayer player) { + List indexList = new ArrayList(); + for (TileCorporeaIndex index : indexes) + if (isInRangeOfIndex(player, index) && index.worldObj.isRemote == player.worldObj.isRemote) + indexList.add(index); + return indexList; + } + + @Override + @SideOnly(Side.CLIENT) + public boolean shouldAutoComplete() { + return !getNearbyIndexes(Minecraft.getMinecraft().thePlayer).isEmpty(); + } + } + + public static interface IRegexStacker { + + public int getCount(Matcher m); + + public String getName(Matcher m); + } } diff --git a/src/main/java/vazkii/botania/common/block/tile/corporea/TileCorporeaInterceptor.java b/src/main/java/vazkii/botania/common/block/tile/corporea/TileCorporeaInterceptor.java index bfc5734c90..28d91f0aed 100644 --- a/src/main/java/vazkii/botania/common/block/tile/corporea/TileCorporeaInterceptor.java +++ b/src/main/java/vazkii/botania/common/block/tile/corporea/TileCorporeaInterceptor.java @@ -2,17 +2,16 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Apr 19, 2015, 6:21:08 PM (GMT)] */ package vazkii.botania.common.block.tile.corporea; import java.util.ArrayList; import java.util.List; - import net.minecraft.entity.item.EntityItemFrame; import net.minecraft.inventory.IInventory; import net.minecraft.item.ItemStack; @@ -27,83 +26,99 @@ public class TileCorporeaInterceptor extends TileCorporeaBase implements ICorporeaInterceptor { - @Override - public boolean isItemValidForSlot(int i, ItemStack itemstack) { - return false; - } - - @Override - public int getSizeInventory() { - return 1; - } - - @Override - public String getInventoryName() { - return LibBlockNames.CORPOREA_INTERCEPTOR; - } - - @Override - public void interceptRequest(Object request, int count, ICorporeaSpark spark, ICorporeaSpark source, List stacks, List inventories, boolean doit) { - // NO-OP - } - - @Override - public void interceptRequestLast(Object request, int count, ICorporeaSpark spark, ICorporeaSpark source, List stacks, List inventories, boolean doit) { - List filter = getFilter(); - for(ItemStack stack : filter) - if(requestMatches(request, stack)) { - int missing = count; - for(ItemStack stack_ : stacks) - missing -= stack_.stackSize; - - if(missing > 0 && getBlockMetadata() == 0) { - worldObj.setBlockMetadataWithNotify(xCoord, yCoord, zCoord, 1, 1 | 2); - worldObj.scheduleBlockUpdate(xCoord, yCoord, zCoord, getBlockType(), 2); - - TileEntity requestor = (TileEntity) source.getInventory(); - for(ForgeDirection dir : LibMisc.CARDINAL_DIRECTIONS) { - TileEntity tile = worldObj.getTileEntity(xCoord + dir.offsetX, yCoord, zCoord + dir.offsetZ); - if(tile != null && tile instanceof TileCorporeaRetainer) - ((TileCorporeaRetainer) tile).setPendingRequest(requestor.xCoord, requestor.yCoord, requestor.zCoord, request, count); - } - - return; - } - } - - } - - public boolean requestMatches(Object request, ItemStack filter) { - if(filter == null) - return false; - - if(request instanceof ItemStack) { - ItemStack stack = (ItemStack) request; - return stack != null && stack.isItemEqual(filter) && ItemStack.areItemStackTagsEqual(filter, stack); - } - - String name = (String) request; - return CorporeaHelper.stacksMatch(filter, name); - } - - public List getFilter() { - List filter = new ArrayList(); - - final int[] orientationToDir = new int[] { - 3, 4, 2, 5 - }; - - for(ForgeDirection dir : LibMisc.CARDINAL_DIRECTIONS) { - List frames = worldObj.getEntitiesWithinAABB(EntityItemFrame.class, AxisAlignedBB.getBoundingBox(xCoord + dir.offsetX, yCoord + dir.offsetY, zCoord + dir.offsetZ, xCoord + dir.offsetX + 1, yCoord + dir.offsetY + 1, zCoord + dir.offsetZ + 1)); - for(EntityItemFrame frame : frames) { - int orientation = frame.hangingDirection; - if(orientationToDir[orientation] == dir.ordinal()) - filter.add(frame.getDisplayedItem()); - } - } - - return filter; - } - - + @Override + public boolean isItemValidForSlot(int i, ItemStack itemstack) { + return false; + } + + @Override + public int getSizeInventory() { + return 1; + } + + @Override + public String getInventoryName() { + return LibBlockNames.CORPOREA_INTERCEPTOR; + } + + @Override + public void interceptRequest( + Object request, + int count, + ICorporeaSpark spark, + ICorporeaSpark source, + List stacks, + List inventories, + boolean doit) { + // NO-OP + } + + @Override + public void interceptRequestLast( + Object request, + int count, + ICorporeaSpark spark, + ICorporeaSpark source, + List stacks, + List inventories, + boolean doit) { + List filter = getFilter(); + for (ItemStack stack : filter) + if (requestMatches(request, stack)) { + int missing = count; + for (ItemStack stack_ : stacks) missing -= stack_.stackSize; + + if (missing > 0 && getBlockMetadata() == 0) { + worldObj.setBlockMetadataWithNotify(xCoord, yCoord, zCoord, 1, 1 | 2); + worldObj.scheduleBlockUpdate(xCoord, yCoord, zCoord, getBlockType(), 2); + + TileEntity requestor = (TileEntity) source.getInventory(); + for (ForgeDirection dir : LibMisc.CARDINAL_DIRECTIONS) { + TileEntity tile = worldObj.getTileEntity(xCoord + dir.offsetX, yCoord, zCoord + dir.offsetZ); + if (tile != null && tile instanceof TileCorporeaRetainer) + ((TileCorporeaRetainer) tile) + .setPendingRequest( + requestor.xCoord, requestor.yCoord, requestor.zCoord, request, count); + } + + return; + } + } + } + + public boolean requestMatches(Object request, ItemStack filter) { + if (filter == null) return false; + + if (request instanceof ItemStack) { + ItemStack stack = (ItemStack) request; + return stack != null && stack.isItemEqual(filter) && ItemStack.areItemStackTagsEqual(filter, stack); + } + + String name = (String) request; + return CorporeaHelper.stacksMatch(filter, name); + } + + public List getFilter() { + List filter = new ArrayList(); + + final int[] orientationToDir = new int[] {3, 4, 2, 5}; + + for (ForgeDirection dir : LibMisc.CARDINAL_DIRECTIONS) { + List frames = worldObj.getEntitiesWithinAABB( + EntityItemFrame.class, + AxisAlignedBB.getBoundingBox( + xCoord + dir.offsetX, + yCoord + dir.offsetY, + zCoord + dir.offsetZ, + xCoord + dir.offsetX + 1, + yCoord + dir.offsetY + 1, + zCoord + dir.offsetZ + 1)); + for (EntityItemFrame frame : frames) { + int orientation = frame.hangingDirection; + if (orientationToDir[orientation] == dir.ordinal()) filter.add(frame.getDisplayedItem()); + } + } + + return filter; + } } diff --git a/src/main/java/vazkii/botania/common/block/tile/corporea/TileCorporeaRetainer.java b/src/main/java/vazkii/botania/common/block/tile/corporea/TileCorporeaRetainer.java index 841981fad3..ccb6a597ae 100644 --- a/src/main/java/vazkii/botania/common/block/tile/corporea/TileCorporeaRetainer.java +++ b/src/main/java/vazkii/botania/common/block/tile/corporea/TileCorporeaRetainer.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Sep 28, 2015, 11:55:56 AM (GMT)] */ package vazkii.botania.common.block.tile.corporea; @@ -20,106 +20,104 @@ public class TileCorporeaRetainer extends TileMod { - private static final String TAG_PENDING_REQUEST = "pendingRequest"; - private static final String TAG_REQUEST_X = "requestX"; - private static final String TAG_REQUEST_Y = "requestY"; - private static final String TAG_REQUEST_Z = "requestZ"; - private static final String TAG_REQUEST_TYPE = "requestType"; - private static final String TAG_REQUEST_CONTENTS = "requestContents"; - private static final String TAG_REQUEST_STACK = "requestStack"; - private static final String TAG_REQUEST_COUNT = "requestCount"; - - private static final int REQUEST_NULL = 0; - private static final int REQUEST_ITEMSTACK = 1; - private static final int REQUEST_STRING = 2; - - boolean pendingRequest = false; - int requestX, requestY, requestZ; - Object request; - int requestCount; - - public void setPendingRequest(int x, int y, int z, Object request, int requestCount) { - if(pendingRequest) - return; - - requestX = x; - requestY = y; - requestZ = z; - this.request = request; - this.requestCount = requestCount; - pendingRequest = true; - worldObj.func_147453_f(xCoord, yCoord, zCoord, worldObj.getBlock(xCoord, yCoord, zCoord)); - } - - public boolean hasPendingRequest() { - return pendingRequest; - } - - public void fulfilRequest() { - if(!hasPendingRequest()) - return; - - ICorporeaSpark spark = CorporeaHelper.getSparkForBlock(worldObj, requestX, requestY, requestZ); - if(spark != null) { - IInventory inv = spark.getInventory(); - if(inv != null && inv instanceof ICorporeaRequestor) { - ICorporeaRequestor requestor = (ICorporeaRequestor) inv; - requestor.doCorporeaRequest(request, requestCount, spark); - pendingRequest = false; - worldObj.func_147453_f(xCoord, yCoord, zCoord, worldObj.getBlock(xCoord, yCoord, zCoord)); - } - } - } - - @Override - public void writeCustomNBT(NBTTagCompound cmp) { - super.writeCustomNBT(cmp); - - cmp.setBoolean(TAG_PENDING_REQUEST, pendingRequest); - cmp.setInteger(TAG_REQUEST_X, requestX); - cmp.setInteger(TAG_REQUEST_Y, requestY); - cmp.setInteger(TAG_REQUEST_Z, requestZ); - - int reqType = REQUEST_NULL; - if(request != null) - reqType = request instanceof String ? REQUEST_STRING : REQUEST_ITEMSTACK; - cmp.setInteger(TAG_REQUEST_TYPE, reqType); - - switch (reqType) { - case REQUEST_STRING: - cmp.setString(TAG_REQUEST_CONTENTS, (String) request); - break; - case REQUEST_ITEMSTACK: - NBTTagCompound cmp1 = new NBTTagCompound(); - ((ItemStack) request).writeToNBT(cmp1); - cmp.setTag(TAG_REQUEST_STACK, cmp1); - break; - default: break; - } - cmp.setInteger(TAG_REQUEST_COUNT, requestCount); - } - - @Override - public void readCustomNBT(NBTTagCompound cmp) { - super.readCustomNBT(cmp); - - pendingRequest = cmp.getBoolean(TAG_PENDING_REQUEST); - requestX = cmp.getInteger(TAG_REQUEST_X); - requestY = cmp.getInteger(TAG_REQUEST_Y); - requestZ = cmp.getInteger(TAG_REQUEST_Z); - - int reqType = cmp.getInteger(TAG_REQUEST_TYPE); - switch (reqType) { - case REQUEST_STRING: - request = cmp.getString(TAG_REQUEST_CONTENTS); - break; - case REQUEST_ITEMSTACK: - NBTTagCompound cmp1 = cmp.getCompoundTag(TAG_REQUEST_STACK); - request = ItemStack.loadItemStackFromNBT(cmp1); - break; - default: break; - } - requestCount = cmp.getInteger(TAG_REQUEST_COUNT); - } - + private static final String TAG_PENDING_REQUEST = "pendingRequest"; + private static final String TAG_REQUEST_X = "requestX"; + private static final String TAG_REQUEST_Y = "requestY"; + private static final String TAG_REQUEST_Z = "requestZ"; + private static final String TAG_REQUEST_TYPE = "requestType"; + private static final String TAG_REQUEST_CONTENTS = "requestContents"; + private static final String TAG_REQUEST_STACK = "requestStack"; + private static final String TAG_REQUEST_COUNT = "requestCount"; + + private static final int REQUEST_NULL = 0; + private static final int REQUEST_ITEMSTACK = 1; + private static final int REQUEST_STRING = 2; + + boolean pendingRequest = false; + int requestX, requestY, requestZ; + Object request; + int requestCount; + + public void setPendingRequest(int x, int y, int z, Object request, int requestCount) { + if (pendingRequest) return; + + requestX = x; + requestY = y; + requestZ = z; + this.request = request; + this.requestCount = requestCount; + pendingRequest = true; + worldObj.func_147453_f(xCoord, yCoord, zCoord, worldObj.getBlock(xCoord, yCoord, zCoord)); + } + + public boolean hasPendingRequest() { + return pendingRequest; + } + + public void fulfilRequest() { + if (!hasPendingRequest()) return; + + ICorporeaSpark spark = CorporeaHelper.getSparkForBlock(worldObj, requestX, requestY, requestZ); + if (spark != null) { + IInventory inv = spark.getInventory(); + if (inv != null && inv instanceof ICorporeaRequestor) { + ICorporeaRequestor requestor = (ICorporeaRequestor) inv; + requestor.doCorporeaRequest(request, requestCount, spark); + pendingRequest = false; + worldObj.func_147453_f(xCoord, yCoord, zCoord, worldObj.getBlock(xCoord, yCoord, zCoord)); + } + } + } + + @Override + public void writeCustomNBT(NBTTagCompound cmp) { + super.writeCustomNBT(cmp); + + cmp.setBoolean(TAG_PENDING_REQUEST, pendingRequest); + cmp.setInteger(TAG_REQUEST_X, requestX); + cmp.setInteger(TAG_REQUEST_Y, requestY); + cmp.setInteger(TAG_REQUEST_Z, requestZ); + + int reqType = REQUEST_NULL; + if (request != null) reqType = request instanceof String ? REQUEST_STRING : REQUEST_ITEMSTACK; + cmp.setInteger(TAG_REQUEST_TYPE, reqType); + + switch (reqType) { + case REQUEST_STRING: + cmp.setString(TAG_REQUEST_CONTENTS, (String) request); + break; + case REQUEST_ITEMSTACK: + NBTTagCompound cmp1 = new NBTTagCompound(); + ((ItemStack) request).writeToNBT(cmp1); + cmp.setTag(TAG_REQUEST_STACK, cmp1); + break; + default: + break; + } + cmp.setInteger(TAG_REQUEST_COUNT, requestCount); + } + + @Override + public void readCustomNBT(NBTTagCompound cmp) { + super.readCustomNBT(cmp); + + pendingRequest = cmp.getBoolean(TAG_PENDING_REQUEST); + requestX = cmp.getInteger(TAG_REQUEST_X); + requestY = cmp.getInteger(TAG_REQUEST_Y); + requestZ = cmp.getInteger(TAG_REQUEST_Z); + + int reqType = cmp.getInteger(TAG_REQUEST_TYPE); + switch (reqType) { + case REQUEST_STRING: + request = cmp.getString(TAG_REQUEST_CONTENTS); + break; + case REQUEST_ITEMSTACK: + NBTTagCompound cmp1 = cmp.getCompoundTag(TAG_REQUEST_STACK); + request = ItemStack.loadItemStackFromNBT(cmp1); + break; + default: + break; + } + requestCount = cmp.getInteger(TAG_REQUEST_COUNT); + } } diff --git a/src/main/java/vazkii/botania/common/block/tile/mana/TileBellows.java b/src/main/java/vazkii/botania/common/block/tile/mana/TileBellows.java index 11dfaa35fc..ecb0eaf24d 100644 --- a/src/main/java/vazkii/botania/common/block/tile/mana/TileBellows.java +++ b/src/main/java/vazkii/botania/common/block/tile/mana/TileBellows.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Aug 28, 2015, 5:27:43 PM (GMT)] */ package vazkii.botania.common.block.tile.mana; @@ -21,119 +21,113 @@ public class TileBellows extends TileMod { - private static final String TAG_ACTIVE = "active"; - - public float movePos; - public boolean active = false; - public float moving = 0F; - - public void interact() { - if(moving == 0F) - setActive(true); - } - - @Override - public void updateEntity() { - boolean disable = true; - TileEntity tile = getLinkedTile(); - if(!active && tile instanceof TilePool) { - TilePool pool = (TilePool) tile; - boolean transfer = pool.isDoingTransfer; - if(transfer) { - if(!active && pool.ticksDoingTransfer >= getBlockMetadata() * 2 - 2) - setActive(true); - disable = false; - } - } - - float max = 0.9F; - float min = 0F; - - float incr = max / 20F; - - if(movePos < max && active && moving >= 0F) { - if(moving == 0F) - worldObj.playSoundEffect(xCoord + 0.5, yCoord + 0.5, zCoord + 0.5, "botania:bellows", 0.1F, 3F); - - if(tile instanceof TileEntityFurnace) { - TileEntityFurnace furnace = (TileEntityFurnace) tile; - if(SubTileExoflame.canFurnaceSmelt(furnace)) { - furnace.furnaceCookTime = Math.min(199, furnace.furnaceCookTime + 20); - furnace.furnaceBurnTime = Math.max(0, furnace.furnaceBurnTime - 10); - } - - if(furnace.getBlockType() == Blocks.lit_furnace) { - // Copypasta from BlockFurnace - int x = furnace.xCoord; - int y = furnace.yCoord; - int z = furnace.zCoord; - int l = worldObj.getBlockMetadata(x, y, z); - float f = x + 0.5F; - float f1 = y + 0.0F + worldObj.rand.nextFloat() * 6.0F / 16.0F; - float f2 = z + 0.5F; - float f3 = 0.52F; - float f4 = worldObj.rand.nextFloat() * 0.6F - 0.3F; - - if(l == 4) { - worldObj.spawnParticle("smoke", f - f3, f1, f2 + f4, 0.0D, 0.0D, 0.0D); - worldObj.spawnParticle("flame", f - f3, f1, f2 + f4, 0.0D, 0.0D, 0.0D); - } else if(l == 5) { - worldObj.spawnParticle("smoke", f + f3, f1, f2 + f4, 0.0D, 0.0D, 0.0D); - worldObj.spawnParticle("flame", f + f3, f1, f2 + f4, 0.0D, 0.0D, 0.0D); - } else if(l == 2) { - worldObj.spawnParticle("smoke", f + f4, f1, f2 - f3, 0.0D, 0.0D, 0.0D); - worldObj.spawnParticle("flame", f + f4, f1, f2 - f3, 0.0D, 0.0D, 0.0D); - } else if(l == 3) { - worldObj.spawnParticle("smoke", f + f4, f1, f2 + f3, 0.0D, 0.0D, 0.0D); - worldObj.spawnParticle("flame", f + f4, f1, f2 + f3, 0.0D, 0.0D, 0.0D); - } - } - } - - movePos += incr * 3; - moving = incr * 3; - if(movePos >= max) { - movePos = Math.min(max, movePos); - moving = 0F; - if(disable) - setActive(false); - } - } else if(movePos > min) { - movePos -= incr; - moving = -incr; - if(movePos <= min) { - movePos = Math.max(min, movePos); - moving = 0F; - } - } - - super.updateEntity(); - } - - public TileEntity getLinkedTile() { - int meta = getBlockMetadata(); - ForgeDirection dir = ForgeDirection.getOrientation(meta); - return worldObj.getTileEntity(xCoord + dir.offsetX, yCoord, zCoord + dir.offsetZ); - } - - @Override - public void writeCustomNBT(NBTTagCompound cmp) { - cmp.setBoolean(TAG_ACTIVE, active); - } - - @Override - public void readCustomNBT(NBTTagCompound cmp) { - active = cmp.getBoolean(TAG_ACTIVE); - } - - public void setActive(boolean active) { - if(!worldObj.isRemote) { - boolean diff = this.active != active; - this.active = active; - if(diff) - VanillaPacketDispatcher.dispatchTEToNearbyPlayers(worldObj, xCoord, yCoord, zCoord); - } - } - - + private static final String TAG_ACTIVE = "active"; + + public float movePos; + public boolean active = false; + public float moving = 0F; + + public void interact() { + if (moving == 0F) setActive(true); + } + + @Override + public void updateEntity() { + boolean disable = true; + TileEntity tile = getLinkedTile(); + if (!active && tile instanceof TilePool) { + TilePool pool = (TilePool) tile; + boolean transfer = pool.isDoingTransfer; + if (transfer) { + if (!active && pool.ticksDoingTransfer >= getBlockMetadata() * 2 - 2) setActive(true); + disable = false; + } + } + + float max = 0.9F; + float min = 0F; + + float incr = max / 20F; + + if (movePos < max && active && moving >= 0F) { + if (moving == 0F) + worldObj.playSoundEffect(xCoord + 0.5, yCoord + 0.5, zCoord + 0.5, "botania:bellows", 0.1F, 3F); + + if (tile instanceof TileEntityFurnace) { + TileEntityFurnace furnace = (TileEntityFurnace) tile; + if (SubTileExoflame.canFurnaceSmelt(furnace)) { + furnace.furnaceCookTime = Math.min(199, furnace.furnaceCookTime + 20); + furnace.furnaceBurnTime = Math.max(0, furnace.furnaceBurnTime - 10); + } + + if (furnace.getBlockType() == Blocks.lit_furnace) { + // Copypasta from BlockFurnace + int x = furnace.xCoord; + int y = furnace.yCoord; + int z = furnace.zCoord; + int l = worldObj.getBlockMetadata(x, y, z); + float f = x + 0.5F; + float f1 = y + 0.0F + worldObj.rand.nextFloat() * 6.0F / 16.0F; + float f2 = z + 0.5F; + float f3 = 0.52F; + float f4 = worldObj.rand.nextFloat() * 0.6F - 0.3F; + + if (l == 4) { + worldObj.spawnParticle("smoke", f - f3, f1, f2 + f4, 0.0D, 0.0D, 0.0D); + worldObj.spawnParticle("flame", f - f3, f1, f2 + f4, 0.0D, 0.0D, 0.0D); + } else if (l == 5) { + worldObj.spawnParticle("smoke", f + f3, f1, f2 + f4, 0.0D, 0.0D, 0.0D); + worldObj.spawnParticle("flame", f + f3, f1, f2 + f4, 0.0D, 0.0D, 0.0D); + } else if (l == 2) { + worldObj.spawnParticle("smoke", f + f4, f1, f2 - f3, 0.0D, 0.0D, 0.0D); + worldObj.spawnParticle("flame", f + f4, f1, f2 - f3, 0.0D, 0.0D, 0.0D); + } else if (l == 3) { + worldObj.spawnParticle("smoke", f + f4, f1, f2 + f3, 0.0D, 0.0D, 0.0D); + worldObj.spawnParticle("flame", f + f4, f1, f2 + f3, 0.0D, 0.0D, 0.0D); + } + } + } + + movePos += incr * 3; + moving = incr * 3; + if (movePos >= max) { + movePos = Math.min(max, movePos); + moving = 0F; + if (disable) setActive(false); + } + } else if (movePos > min) { + movePos -= incr; + moving = -incr; + if (movePos <= min) { + movePos = Math.max(min, movePos); + moving = 0F; + } + } + + super.updateEntity(); + } + + public TileEntity getLinkedTile() { + int meta = getBlockMetadata(); + ForgeDirection dir = ForgeDirection.getOrientation(meta); + return worldObj.getTileEntity(xCoord + dir.offsetX, yCoord, zCoord + dir.offsetZ); + } + + @Override + public void writeCustomNBT(NBTTagCompound cmp) { + cmp.setBoolean(TAG_ACTIVE, active); + } + + @Override + public void readCustomNBT(NBTTagCompound cmp) { + active = cmp.getBoolean(TAG_ACTIVE); + } + + public void setActive(boolean active) { + if (!worldObj.isRemote) { + boolean diff = this.active != active; + this.active = active; + if (diff) VanillaPacketDispatcher.dispatchTEToNearbyPlayers(worldObj, xCoord, yCoord, zCoord); + } + } } diff --git a/src/main/java/vazkii/botania/common/block/tile/mana/TileDistributor.java b/src/main/java/vazkii/botania/common/block/tile/mana/TileDistributor.java index e0aa3d60fd..f174a9afee 100644 --- a/src/main/java/vazkii/botania/common/block/tile/mana/TileDistributor.java +++ b/src/main/java/vazkii/botania/common/block/tile/mana/TileDistributor.java @@ -2,17 +2,16 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Mar 3, 2014, 1:51:34 AM (GMT)] */ package vazkii.botania.common.block.tile.mana; import java.util.ArrayList; import java.util.List; - import net.minecraft.tileentity.TileEntity; import net.minecraftforge.common.util.ForgeDirection; import vazkii.botania.api.internal.VanillaPacketDispatcher; @@ -23,46 +22,45 @@ public class TileDistributor extends TileMod implements IManaReceiver { - List validPools = new ArrayList(); + List validPools = new ArrayList(); - @Override - public void updateEntity() { - validPools.clear(); - for(ForgeDirection dir : LibMisc.CARDINAL_DIRECTIONS) { - TileEntity tileAt = worldObj.getTileEntity(xCoord + dir.offsetX, yCoord, zCoord + dir.offsetZ); - if(tileAt != null && tileAt instanceof IManaPool) { - IManaReceiver receiver = (IManaReceiver) tileAt; - if(!receiver.isFull()) - validPools.add(receiver); - } - } - } + @Override + public void updateEntity() { + validPools.clear(); + for (ForgeDirection dir : LibMisc.CARDINAL_DIRECTIONS) { + TileEntity tileAt = worldObj.getTileEntity(xCoord + dir.offsetX, yCoord, zCoord + dir.offsetZ); + if (tileAt != null && tileAt instanceof IManaPool) { + IManaReceiver receiver = (IManaReceiver) tileAt; + if (!receiver.isFull()) validPools.add(receiver); + } + } + } - @Override - public int getCurrentMana() { - return 0; - } + @Override + public int getCurrentMana() { + return 0; + } - @Override - public boolean isFull() { - return validPools.isEmpty(); - } + @Override + public boolean isFull() { + return validPools.isEmpty(); + } - @Override - public void recieveMana(int mana) { - int tiles = validPools.size(); - if(tiles != 0) { - int manaForEach = mana / tiles; - for(IManaReceiver pool : validPools) { - pool.recieveMana(manaForEach); - TileEntity tile = (TileEntity) pool; - VanillaPacketDispatcher.dispatchTEToNearbyPlayers(worldObj, tile.xCoord, tile.yCoord, tile.zCoord); - } - } - } + @Override + public void recieveMana(int mana) { + int tiles = validPools.size(); + if (tiles != 0) { + int manaForEach = mana / tiles; + for (IManaReceiver pool : validPools) { + pool.recieveMana(manaForEach); + TileEntity tile = (TileEntity) pool; + VanillaPacketDispatcher.dispatchTEToNearbyPlayers(worldObj, tile.xCoord, tile.yCoord, tile.zCoord); + } + } + } - @Override - public boolean canRecieveManaFromBursts() { - return !isFull(); - } + @Override + public boolean canRecieveManaFromBursts() { + return !isFull(); + } } diff --git a/src/main/java/vazkii/botania/common/block/tile/mana/TileManaDetector.java b/src/main/java/vazkii/botania/common/block/tile/mana/TileManaDetector.java index 90bd75db12..c2066e5cfd 100644 --- a/src/main/java/vazkii/botania/common/block/tile/mana/TileManaDetector.java +++ b/src/main/java/vazkii/botania/common/block/tile/mana/TileManaDetector.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Mar 10, 2014, 7:55:12 PM (GMT)] */ package vazkii.botania.common.block.tile.mana; @@ -18,23 +18,37 @@ public class TileManaDetector extends TileMod implements IManaCollisionGhost { - @Override - public void updateEntity() { - if(!worldObj.isRemote) { - int meta = getBlockMetadata(); - int expectedMeta = worldObj.getEntitiesWithinAABB(IManaBurst.class, AxisAlignedBB.getBoundingBox(xCoord, yCoord, zCoord, xCoord + 1, yCoord + 1, zCoord + 1)).size() != 0 ? 1 : 0; - if(meta != expectedMeta) - worldObj.setBlockMetadataWithNotify(xCoord, yCoord, zCoord, expectedMeta, 1 | 2); + @Override + public void updateEntity() { + if (!worldObj.isRemote) { + int meta = getBlockMetadata(); + int expectedMeta = worldObj.getEntitiesWithinAABB( + IManaBurst.class, + AxisAlignedBB.getBoundingBox( + xCoord, yCoord, zCoord, xCoord + 1, yCoord + 1, zCoord + 1)) + .size() + != 0 + ? 1 + : 0; + if (meta != expectedMeta) worldObj.setBlockMetadataWithNotify(xCoord, yCoord, zCoord, expectedMeta, 1 | 2); - if(expectedMeta == 1) - for(int i = 0; i < 4; i++) - Botania.proxy.sparkleFX(getWorldObj(), xCoord + Math.random(), yCoord + Math.random(), zCoord + Math.random(), 1F, 0.2F, 0.2F, 0.7F + 0.5F * (float) Math.random(), 5); - } - } - - @Override - public boolean isGhost() { - return true; - } + if (expectedMeta == 1) + for (int i = 0; i < 4; i++) + Botania.proxy.sparkleFX( + getWorldObj(), + xCoord + Math.random(), + yCoord + Math.random(), + zCoord + Math.random(), + 1F, + 0.2F, + 0.2F, + 0.7F + 0.5F * (float) Math.random(), + 5); + } + } + @Override + public boolean isGhost() { + return true; + } } diff --git a/src/main/java/vazkii/botania/common/block/tile/mana/TileManaVoid.java b/src/main/java/vazkii/botania/common/block/tile/mana/TileManaVoid.java index d4b240ed08..a4f524cbcf 100644 --- a/src/main/java/vazkii/botania/common/block/tile/mana/TileManaVoid.java +++ b/src/main/java/vazkii/botania/common/block/tile/mana/TileManaVoid.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Mar 5, 2014, 12:59:27 AM (GMT)] */ package vazkii.botania.common.block.tile.mana; @@ -16,31 +16,39 @@ public class TileManaVoid extends TileMod implements IClientManaHandler { - @Override - public boolean canUpdate() { - return false; - } - - @Override - public int getCurrentMana() { - return 0; - } - - @Override - public boolean isFull() { - return false; - } - - @Override - public void recieveMana(int mana) { - if(mana > 0) - for(int i = 0; i < 10; i++) - Botania.proxy.sparkleFX(getWorldObj(), xCoord + Math.random(), yCoord + Math.random(), zCoord + Math.random(), 0.2F, 0.2F, 0.2F, 0.7F + 0.5F * (float) Math.random(), 5); - } - - @Override - public boolean canRecieveManaFromBursts() { - return true; - } - + @Override + public boolean canUpdate() { + return false; + } + + @Override + public int getCurrentMana() { + return 0; + } + + @Override + public boolean isFull() { + return false; + } + + @Override + public void recieveMana(int mana) { + if (mana > 0) + for (int i = 0; i < 10; i++) + Botania.proxy.sparkleFX( + getWorldObj(), + xCoord + Math.random(), + yCoord + Math.random(), + zCoord + Math.random(), + 0.2F, + 0.2F, + 0.2F, + 0.7F + 0.5F * (float) Math.random(), + 5); + } + + @Override + public boolean canRecieveManaFromBursts() { + return true; + } } diff --git a/src/main/java/vazkii/botania/common/block/tile/mana/TilePool.java b/src/main/java/vazkii/botania/common/block/tile/mana/TilePool.java index f6252385b7..777f53f5bc 100644 --- a/src/main/java/vazkii/botania/common/block/tile/mana/TilePool.java +++ b/src/main/java/vazkii/botania/common/block/tile/mana/TilePool.java @@ -2,17 +2,16 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jan 26, 2014, 12:23:55 AM (GMT)] */ package vazkii.botania.common.block.tile.mana; import java.awt.Color; import java.util.List; - import net.minecraft.block.Block; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.ScaledResolution; @@ -28,9 +27,7 @@ import net.minecraft.util.AxisAlignedBB; import net.minecraft.util.StatCollector; import net.minecraftforge.common.util.ForgeDirection; - import org.lwjgl.opengl.GL11; - import vazkii.botania.api.BotaniaAPI; import vazkii.botania.api.internal.VanillaPacketDispatcher; import vazkii.botania.api.item.IDyablePool; @@ -57,381 +54,404 @@ import vazkii.botania.common.item.ModItems; import vazkii.botania.common.lib.LibMisc; -public class TilePool extends TileMod implements IManaPool, IDyablePool, IKeyLocked, ISparkAttachable, IThrottledPacket { - - public static final int MAX_MANA = 1000000; - public static final int MAX_MANA_DILLUTED = 10000; - - private static final String TAG_MANA = "mana"; - private static final String TAG_KNOWN_MANA = "knownMana"; - private static final String TAG_OUTPUTTING = "outputting"; - private static final String TAG_COLOR = "color"; - private static final String TAG_MANA_CAP = "manaCap"; - private static final String TAG_CAN_ACCEPT = "canAccept"; - private static final String TAG_CAN_SPARE = "canSpare"; - private static final String TAG_FRAGILE = "fragile"; - private static final String TAG_INPUT_KEY = "inputKey"; - private static final String TAG_OUTPUT_KEY = "outputKey"; - - boolean outputting = false; - public boolean alchemy = false; - public boolean conjuration = false; - boolean catalystsRegistered = false; - - public int color = 0; - int mana; - int knownMana = -1; - - public int manaCap = -1; - int soundTicks = 0; - boolean canAccept = true; - boolean canSpare = true; - public boolean fragile = false; - public boolean isDoingTransfer = false; - public int ticksDoingTransfer = 0; - - String inputKey = ""; - String outputKey = ""; - - int ticks = 0; - boolean sendPacket = false; - - @Override - public boolean isFull() { - Block blockBelow = worldObj.getBlock(xCoord, yCoord - 1, zCoord); - return blockBelow != ModBlocks.manaVoid && getCurrentMana() >= manaCap; - } - - @Override - public void recieveMana(int mana) { - this.mana = Math.max(0, Math.min(getCurrentMana() + mana, manaCap)); - worldObj.func_147453_f(xCoord, yCoord, zCoord, worldObj.getBlock(xCoord, yCoord, zCoord)); - markDispatchable(); - } - - @Override - public void invalidate() { - super.invalidate(); - ManaNetworkEvent.removePool(this); - } - - @Override - public void onChunkUnload() { - super.onChunkUnload(); - invalidate(); - } - - public boolean collideEntityItem(EntityItem item) { - if(item.isDead) - return false; - - boolean didChange = false; - ItemStack stack = item.getEntityItem(); - if(stack == null) - return false; - - if(stack.getItem() instanceof IManaDissolvable) { - ((IManaDissolvable) stack.getItem()).onDissolveTick(this, stack, item); - if(stack.stackSize == 0) - item.setDead(); - } - - if(item.age > 100 && item.age < 130 || !catalystsRegistered) - return false; - - for(RecipeManaInfusion recipe : BotaniaAPI.manaInfusionRecipes) { - if(recipe.matches(stack) && (!recipe.isAlchemy() || alchemy) && (!recipe.isConjuration() || conjuration)) { - int mana = recipe.getManaToConsume(); - if(getCurrentMana() >= mana) { - recieveMana(-mana); - - if(!worldObj.isRemote) { - stack.stackSize--; - if(stack.stackSize == 0) - item.setDead(); - - ItemStack output = recipe.getOutput().copy(); - EntityItem outputItem = new EntityItem(worldObj, xCoord + 0.5, yCoord + 1.5, zCoord + 0.5, output); - outputItem.age = 105; - worldObj.spawnEntityInWorld(outputItem); - } - - craftingFanciness(); - didChange = true; - } - - break; - } - } - - return didChange; - } - - public void craftingFanciness() { - if(soundTicks == 0) { - worldObj.playSoundEffect(xCoord, yCoord, zCoord, "botania:manaPoolCraft", 0.4F, 4F); - soundTicks = 6; - } - - for(int i = 0; i < 25; i++) { - float red = (float) Math.random(); - float green = (float) Math.random(); - float blue = (float) Math.random(); - Botania.proxy.sparkleFX(worldObj, xCoord + 0.5 + Math.random() * 0.4 - 0.2, yCoord + 1, zCoord + 0.5 + Math.random() * 0.4 - 0.2, red, green, blue, (float) Math.random(), 10); - } - } - - @Override - public void updateEntity() { - boolean wasDoingTransfer = isDoingTransfer; - isDoingTransfer = false; - if(manaCap == -1) - manaCap = getBlockMetadata() == 2 ? MAX_MANA_DILLUTED : MAX_MANA; - - if(!ManaNetworkHandler.instance.isPoolIn(this) && !isInvalid()) - ManaNetworkEvent.addPool(this); - - if(soundTicks > 0) - soundTicks--; - - if(worldObj.isRemote) { - double particleChance = 1F - (double) getCurrentMana() / (double) manaCap * 0.1; - Color color = new Color(0x00C6FF); - if(Math.random() > particleChance) - Botania.proxy.wispFX(worldObj, xCoord + 0.3 + Math.random() * 0.5, yCoord + 0.6 + Math.random() * 0.25, zCoord + Math.random(), color.getRed() / 255F, color.getGreen() / 255F, color.getBlue() / 255F, (float) Math.random() / 3F, (float) -Math.random() / 25F, 2F); - } - - if(sendPacket && ticks % 10 == 0) { - VanillaPacketDispatcher.dispatchTEToNearbyPlayers(this); - sendPacket = false; - } - - alchemy = worldObj.getBlock(xCoord, yCoord - 1, zCoord) == ModBlocks.alchemyCatalyst; - conjuration = worldObj.getBlock(xCoord, yCoord - 1, zCoord) == ModBlocks.conjurationCatalyst; - catalystsRegistered = true; - - List items = worldObj.getEntitiesWithinAABB(EntityItem.class, AxisAlignedBB.getBoundingBox(xCoord, yCoord, zCoord, xCoord + 1, yCoord + 1, zCoord + 1)); - for(EntityItem item : items) { - if(item.isDead) - continue; - - ItemStack stack = item.getEntityItem(); - if(stack != null && stack.getItem() instanceof IManaItem) { - IManaItem mana = (IManaItem) stack.getItem(); - if(outputting && mana.canReceiveManaFromPool(stack, this) || !outputting && mana.canExportManaToPool(stack, this)) { - boolean didSomething = false; - - int bellowCount = 0; - if(outputting) - for(ForgeDirection dir : LibMisc.CARDINAL_DIRECTIONS) { - TileEntity tile = worldObj.getTileEntity(xCoord + dir.offsetX, yCoord, zCoord + dir.offsetZ); - if(tile != null && tile instanceof TileBellows && ((TileBellows) tile).getLinkedTile() == this) - bellowCount++; - } - int transfRate = 1000 * (bellowCount + 1); - - if(outputting) { - if(canSpare) { - if(getCurrentMana() > 0 && mana.getMana(stack) < mana.getMaxMana(stack)) - didSomething = true; - - int manaVal = Math.min(transfRate, Math.min(getCurrentMana(), mana.getMaxMana(stack) - mana.getMana(stack))); - if(!worldObj.isRemote) - mana.addMana(stack, manaVal); - recieveMana(-manaVal); - } - } else { - if(canAccept) { - if(mana.getMana(stack) > 0 && !isFull()) - didSomething = true; - - int manaVal = Math.min(transfRate, Math.min(manaCap - getCurrentMana(), mana.getMana(stack))); - if(!worldObj.isRemote) - mana.addMana(stack, -manaVal); - recieveMana(manaVal); - } - } - - if(didSomething) { - if(worldObj.isRemote && ConfigHandler.chargingAnimationEnabled && worldObj.rand.nextInt(20) == 0) { - Vector3 itemVec = Vector3.fromTileEntity(this).add(0.5, 0.5 + Math.random() * 0.3, 0.5); - Vector3 tileVec = Vector3.fromTileEntity(this).add(0.2 + Math.random() * 0.6, 0, 0.2 + Math.random() * 0.6); - LightningHandler.spawnLightningBolt(worldObj, outputting ? tileVec : itemVec, outputting ? itemVec : tileVec, 80, worldObj.rand.nextLong(), 0x4400799c, 0x4400C6FF); - } - isDoingTransfer = outputting; - } - } - } - } - - if(isDoingTransfer) - ticksDoingTransfer++; - else { - ticksDoingTransfer = 0; - if(wasDoingTransfer) - VanillaPacketDispatcher.dispatchTEToNearbyPlayers(this); - } - - ticks++; - } - - @Override - public void writeCustomNBT(NBTTagCompound cmp) { - cmp.setInteger(TAG_MANA, mana); - cmp.setBoolean(TAG_OUTPUTTING, outputting); - cmp.setInteger(TAG_COLOR, color); - - cmp.setInteger(TAG_MANA_CAP, manaCap); - cmp.setBoolean(TAG_CAN_ACCEPT, canAccept); - cmp.setBoolean(TAG_CAN_SPARE, canSpare); - cmp.setBoolean(TAG_FRAGILE, fragile); - - cmp.setString(TAG_INPUT_KEY, inputKey); - cmp.setString(TAG_OUTPUT_KEY, outputKey); - } - - @Override - public void readCustomNBT(NBTTagCompound cmp) { - mana = cmp.getInteger(TAG_MANA); - outputting = cmp.getBoolean(TAG_OUTPUTTING); - color = cmp.getInteger(TAG_COLOR); - - if(cmp.hasKey(TAG_MANA_CAP)) - manaCap = cmp.getInteger(TAG_MANA_CAP); - if(cmp.hasKey(TAG_CAN_ACCEPT)) - canAccept = cmp.getBoolean(TAG_CAN_ACCEPT); - if(cmp.hasKey(TAG_CAN_SPARE)) - canSpare = cmp.getBoolean(TAG_CAN_SPARE); - fragile = cmp.getBoolean(TAG_FRAGILE); - - if(cmp.hasKey(TAG_INPUT_KEY)) - inputKey = cmp.getString(TAG_INPUT_KEY); - if(cmp.hasKey(TAG_OUTPUT_KEY)) - inputKey = cmp.getString(TAG_OUTPUT_KEY); - - if(cmp.hasKey(TAG_KNOWN_MANA)) - knownMana = cmp.getInteger(TAG_KNOWN_MANA); - } - - public void onWanded(EntityPlayer player, ItemStack wand) { - if(player == null) - return; - - if(player.isSneaking()) { - outputting = !outputting; - VanillaPacketDispatcher.dispatchTEToNearbyPlayers(worldObj, xCoord, yCoord, zCoord); - } - - if(!worldObj.isRemote) { - NBTTagCompound nbttagcompound = new NBTTagCompound(); - writeCustomNBT(nbttagcompound); - nbttagcompound.setInteger(TAG_KNOWN_MANA, getCurrentMana()); - if(player instanceof EntityPlayerMP) - ((EntityPlayerMP) player).playerNetServerHandler.sendPacket(new S35PacketUpdateTileEntity(xCoord, yCoord, zCoord, -999, nbttagcompound)); - } - - worldObj.playSoundAtEntity(player, "botania:ding", 0.11F, 1F); - } - - public void renderHUD(Minecraft mc, ScaledResolution res) { - ItemStack pool = new ItemStack(ModBlocks.pool, 1, getBlockMetadata()); - String name = StatCollector.translateToLocal(pool.getUnlocalizedName().replaceAll("tile.", "tile." + LibResources.PREFIX_MOD) + ".name"); - int color = 0x4444FF; - HUDHandler.drawSimpleManaHUD(color, knownMana, manaCap, name, res); - - int x = res.getScaledWidth() / 2 - 11; - int y = res.getScaledHeight() / 2 + 30; - - int u = outputting ? 22 : 0; - int v = 38; - - GL11.glEnable(GL11.GL_BLEND); - GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); - - mc.renderEngine.bindTexture(HUDHandler.manaBar); - RenderHelper.drawTexturedModalRect(x, y, 0, u, v, 22, 15); - GL11.glColor4f(1F, 1F, 1F, 1F); - - ItemStack tablet = new ItemStack(ModItems.manaTablet); - ItemManaTablet.setStackCreative(tablet); - - net.minecraft.client.renderer.RenderHelper.enableGUIStandardItemLighting(); - RenderItem.getInstance().renderItemAndEffectIntoGUI(mc.fontRenderer, mc.renderEngine, tablet, x - 20, y); - RenderItem.getInstance().renderItemAndEffectIntoGUI(mc.fontRenderer, mc.renderEngine, pool, x + 26, y); - net.minecraft.client.renderer.RenderHelper.disableStandardItemLighting(); - - GL11.glDisable(GL11.GL_LIGHTING); - GL11.glDisable(GL11.GL_BLEND); - } - - @Override - public boolean canRecieveManaFromBursts() { - return true; - } - - @Override - public boolean isOutputtingPower() { - return outputting; - } - - @Override - public int getCurrentMana() { - return worldObj != null && getBlockMetadata() == 1 ? MAX_MANA : mana; - } - - @Override - public String getInputKey() { - return inputKey; - } - - @Override - public String getOutputKey() { - return outputKey; - } - - @Override - public boolean canAttachSpark(ItemStack stack) { - return true; - } - - @Override - public void attachSpark(ISparkEntity entity) { - // NO-OP - } - - @Override - public ISparkEntity getAttachedSpark() { - List sparks = worldObj.getEntitiesWithinAABB(ISparkEntity.class, AxisAlignedBB.getBoundingBox(xCoord, yCoord + 1, zCoord, xCoord + 1, yCoord + 2, zCoord + 1)); - if(sparks.size() == 1) { - Entity e = (Entity) sparks.get(0); - return (ISparkEntity) e; - } - - return null; - } - - @Override - public boolean areIncomingTranfersDone() { - return false; - } - - @Override - public int getAvailableSpaceForMana() { - return Math.max(0, manaCap - getCurrentMana()); - } - - @Override - public int getColor() { - return color; - } - - @Override - public void setColor(int color) { - this.color = color; - } - - @Override - public void markDispatchable() { - sendPacket = true; - } +public class TilePool extends TileMod + implements IManaPool, IDyablePool, IKeyLocked, ISparkAttachable, IThrottledPacket { + + public static final int MAX_MANA = 1000000; + public static final int MAX_MANA_DILLUTED = 10000; + + private static final String TAG_MANA = "mana"; + private static final String TAG_KNOWN_MANA = "knownMana"; + private static final String TAG_OUTPUTTING = "outputting"; + private static final String TAG_COLOR = "color"; + private static final String TAG_MANA_CAP = "manaCap"; + private static final String TAG_CAN_ACCEPT = "canAccept"; + private static final String TAG_CAN_SPARE = "canSpare"; + private static final String TAG_FRAGILE = "fragile"; + private static final String TAG_INPUT_KEY = "inputKey"; + private static final String TAG_OUTPUT_KEY = "outputKey"; + + boolean outputting = false; + public boolean alchemy = false; + public boolean conjuration = false; + boolean catalystsRegistered = false; + + public int color = 0; + int mana; + int knownMana = -1; + + public int manaCap = -1; + int soundTicks = 0; + boolean canAccept = true; + boolean canSpare = true; + public boolean fragile = false; + public boolean isDoingTransfer = false; + public int ticksDoingTransfer = 0; + + String inputKey = ""; + String outputKey = ""; + + int ticks = 0; + boolean sendPacket = false; + + @Override + public boolean isFull() { + Block blockBelow = worldObj.getBlock(xCoord, yCoord - 1, zCoord); + return blockBelow != ModBlocks.manaVoid && getCurrentMana() >= manaCap; + } + + @Override + public void recieveMana(int mana) { + this.mana = Math.max(0, Math.min(getCurrentMana() + mana, manaCap)); + worldObj.func_147453_f(xCoord, yCoord, zCoord, worldObj.getBlock(xCoord, yCoord, zCoord)); + markDispatchable(); + } + + @Override + public void invalidate() { + super.invalidate(); + ManaNetworkEvent.removePool(this); + } + + @Override + public void onChunkUnload() { + super.onChunkUnload(); + invalidate(); + } + + public boolean collideEntityItem(EntityItem item) { + if (item.isDead) return false; + + boolean didChange = false; + ItemStack stack = item.getEntityItem(); + if (stack == null) return false; + + if (stack.getItem() instanceof IManaDissolvable) { + ((IManaDissolvable) stack.getItem()).onDissolveTick(this, stack, item); + if (stack.stackSize == 0) item.setDead(); + } + + if (item.age > 100 && item.age < 130 || !catalystsRegistered) return false; + + for (RecipeManaInfusion recipe : BotaniaAPI.manaInfusionRecipes) { + if (recipe.matches(stack) && (!recipe.isAlchemy() || alchemy) && (!recipe.isConjuration() || conjuration)) { + int mana = recipe.getManaToConsume(); + if (getCurrentMana() >= mana) { + recieveMana(-mana); + + if (!worldObj.isRemote) { + stack.stackSize--; + if (stack.stackSize == 0) item.setDead(); + + ItemStack output = recipe.getOutput().copy(); + EntityItem outputItem = + new EntityItem(worldObj, xCoord + 0.5, yCoord + 1.5, zCoord + 0.5, output); + outputItem.age = 105; + worldObj.spawnEntityInWorld(outputItem); + } + + craftingFanciness(); + didChange = true; + } + + break; + } + } + + return didChange; + } + + public void craftingFanciness() { + if (soundTicks == 0) { + worldObj.playSoundEffect(xCoord, yCoord, zCoord, "botania:manaPoolCraft", 0.4F, 4F); + soundTicks = 6; + } + + for (int i = 0; i < 25; i++) { + float red = (float) Math.random(); + float green = (float) Math.random(); + float blue = (float) Math.random(); + Botania.proxy.sparkleFX( + worldObj, + xCoord + 0.5 + Math.random() * 0.4 - 0.2, + yCoord + 1, + zCoord + 0.5 + Math.random() * 0.4 - 0.2, + red, + green, + blue, + (float) Math.random(), + 10); + } + } + + @Override + public void updateEntity() { + boolean wasDoingTransfer = isDoingTransfer; + isDoingTransfer = false; + if (manaCap == -1) manaCap = getBlockMetadata() == 2 ? MAX_MANA_DILLUTED : MAX_MANA; + + if (!ManaNetworkHandler.instance.isPoolIn(this) && !isInvalid()) ManaNetworkEvent.addPool(this); + + if (soundTicks > 0) soundTicks--; + + if (worldObj.isRemote) { + double particleChance = 1F - (double) getCurrentMana() / (double) manaCap * 0.1; + Color color = new Color(0x00C6FF); + if (Math.random() > particleChance) + Botania.proxy.wispFX( + worldObj, + xCoord + 0.3 + Math.random() * 0.5, + yCoord + 0.6 + Math.random() * 0.25, + zCoord + Math.random(), + color.getRed() / 255F, + color.getGreen() / 255F, + color.getBlue() / 255F, + (float) Math.random() / 3F, + (float) -Math.random() / 25F, + 2F); + } + + if (sendPacket && ticks % 10 == 0) { + VanillaPacketDispatcher.dispatchTEToNearbyPlayers(this); + sendPacket = false; + } + + alchemy = worldObj.getBlock(xCoord, yCoord - 1, zCoord) == ModBlocks.alchemyCatalyst; + conjuration = worldObj.getBlock(xCoord, yCoord - 1, zCoord) == ModBlocks.conjurationCatalyst; + catalystsRegistered = true; + + List items = worldObj.getEntitiesWithinAABB( + EntityItem.class, + AxisAlignedBB.getBoundingBox(xCoord, yCoord, zCoord, xCoord + 1, yCoord + 1, zCoord + 1)); + for (EntityItem item : items) { + if (item.isDead) continue; + + ItemStack stack = item.getEntityItem(); + if (stack != null && stack.getItem() instanceof IManaItem) { + IManaItem mana = (IManaItem) stack.getItem(); + if (outputting && mana.canReceiveManaFromPool(stack, this) + || !outputting && mana.canExportManaToPool(stack, this)) { + boolean didSomething = false; + + int bellowCount = 0; + if (outputting) + for (ForgeDirection dir : LibMisc.CARDINAL_DIRECTIONS) { + TileEntity tile = + worldObj.getTileEntity(xCoord + dir.offsetX, yCoord, zCoord + dir.offsetZ); + if (tile != null + && tile instanceof TileBellows + && ((TileBellows) tile).getLinkedTile() == this) bellowCount++; + } + int transfRate = 1000 * (bellowCount + 1); + + if (outputting) { + if (canSpare) { + if (getCurrentMana() > 0 && mana.getMana(stack) < mana.getMaxMana(stack)) + didSomething = true; + + int manaVal = Math.min( + transfRate, + Math.min(getCurrentMana(), mana.getMaxMana(stack) - mana.getMana(stack))); + if (!worldObj.isRemote) mana.addMana(stack, manaVal); + recieveMana(-manaVal); + } + } else { + if (canAccept) { + if (mana.getMana(stack) > 0 && !isFull()) didSomething = true; + + int manaVal = + Math.min(transfRate, Math.min(manaCap - getCurrentMana(), mana.getMana(stack))); + if (!worldObj.isRemote) mana.addMana(stack, -manaVal); + recieveMana(manaVal); + } + } + + if (didSomething) { + if (worldObj.isRemote + && ConfigHandler.chargingAnimationEnabled + && worldObj.rand.nextInt(20) == 0) { + Vector3 itemVec = Vector3.fromTileEntity(this).add(0.5, 0.5 + Math.random() * 0.3, 0.5); + Vector3 tileVec = Vector3.fromTileEntity(this) + .add(0.2 + Math.random() * 0.6, 0, 0.2 + Math.random() * 0.6); + LightningHandler.spawnLightningBolt( + worldObj, + outputting ? tileVec : itemVec, + outputting ? itemVec : tileVec, + 80, + worldObj.rand.nextLong(), + 0x4400799c, + 0x4400C6FF); + } + isDoingTransfer = outputting; + } + } + } + } + + if (isDoingTransfer) ticksDoingTransfer++; + else { + ticksDoingTransfer = 0; + if (wasDoingTransfer) VanillaPacketDispatcher.dispatchTEToNearbyPlayers(this); + } + + ticks++; + } + + @Override + public void writeCustomNBT(NBTTagCompound cmp) { + cmp.setInteger(TAG_MANA, mana); + cmp.setBoolean(TAG_OUTPUTTING, outputting); + cmp.setInteger(TAG_COLOR, color); + + cmp.setInteger(TAG_MANA_CAP, manaCap); + cmp.setBoolean(TAG_CAN_ACCEPT, canAccept); + cmp.setBoolean(TAG_CAN_SPARE, canSpare); + cmp.setBoolean(TAG_FRAGILE, fragile); + + cmp.setString(TAG_INPUT_KEY, inputKey); + cmp.setString(TAG_OUTPUT_KEY, outputKey); + } + + @Override + public void readCustomNBT(NBTTagCompound cmp) { + mana = cmp.getInteger(TAG_MANA); + outputting = cmp.getBoolean(TAG_OUTPUTTING); + color = cmp.getInteger(TAG_COLOR); + + if (cmp.hasKey(TAG_MANA_CAP)) manaCap = cmp.getInteger(TAG_MANA_CAP); + if (cmp.hasKey(TAG_CAN_ACCEPT)) canAccept = cmp.getBoolean(TAG_CAN_ACCEPT); + if (cmp.hasKey(TAG_CAN_SPARE)) canSpare = cmp.getBoolean(TAG_CAN_SPARE); + fragile = cmp.getBoolean(TAG_FRAGILE); + + if (cmp.hasKey(TAG_INPUT_KEY)) inputKey = cmp.getString(TAG_INPUT_KEY); + if (cmp.hasKey(TAG_OUTPUT_KEY)) inputKey = cmp.getString(TAG_OUTPUT_KEY); + + if (cmp.hasKey(TAG_KNOWN_MANA)) knownMana = cmp.getInteger(TAG_KNOWN_MANA); + } + + public void onWanded(EntityPlayer player, ItemStack wand) { + if (player == null) return; + + if (player.isSneaking()) { + outputting = !outputting; + VanillaPacketDispatcher.dispatchTEToNearbyPlayers(worldObj, xCoord, yCoord, zCoord); + } + + if (!worldObj.isRemote) { + NBTTagCompound nbttagcompound = new NBTTagCompound(); + writeCustomNBT(nbttagcompound); + nbttagcompound.setInteger(TAG_KNOWN_MANA, getCurrentMana()); + if (player instanceof EntityPlayerMP) + ((EntityPlayerMP) player) + .playerNetServerHandler.sendPacket( + new S35PacketUpdateTileEntity(xCoord, yCoord, zCoord, -999, nbttagcompound)); + } + + worldObj.playSoundAtEntity(player, "botania:ding", 0.11F, 1F); + } + + public void renderHUD(Minecraft mc, ScaledResolution res) { + ItemStack pool = new ItemStack(ModBlocks.pool, 1, getBlockMetadata()); + String name = StatCollector.translateToLocal( + pool.getUnlocalizedName().replaceAll("tile.", "tile." + LibResources.PREFIX_MOD) + ".name"); + int color = 0x4444FF; + HUDHandler.drawSimpleManaHUD(color, knownMana, manaCap, name, res); + + int x = res.getScaledWidth() / 2 - 11; + int y = res.getScaledHeight() / 2 + 30; + + int u = outputting ? 22 : 0; + int v = 38; + + GL11.glEnable(GL11.GL_BLEND); + GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); + + mc.renderEngine.bindTexture(HUDHandler.manaBar); + RenderHelper.drawTexturedModalRect(x, y, 0, u, v, 22, 15); + GL11.glColor4f(1F, 1F, 1F, 1F); + + ItemStack tablet = new ItemStack(ModItems.manaTablet); + ItemManaTablet.setStackCreative(tablet); + + net.minecraft.client.renderer.RenderHelper.enableGUIStandardItemLighting(); + RenderItem.getInstance().renderItemAndEffectIntoGUI(mc.fontRenderer, mc.renderEngine, tablet, x - 20, y); + RenderItem.getInstance().renderItemAndEffectIntoGUI(mc.fontRenderer, mc.renderEngine, pool, x + 26, y); + net.minecraft.client.renderer.RenderHelper.disableStandardItemLighting(); + + GL11.glDisable(GL11.GL_LIGHTING); + GL11.glDisable(GL11.GL_BLEND); + } + + @Override + public boolean canRecieveManaFromBursts() { + return true; + } + + @Override + public boolean isOutputtingPower() { + return outputting; + } + + @Override + public int getCurrentMana() { + return worldObj != null && getBlockMetadata() == 1 ? MAX_MANA : mana; + } + + @Override + public String getInputKey() { + return inputKey; + } + + @Override + public String getOutputKey() { + return outputKey; + } + + @Override + public boolean canAttachSpark(ItemStack stack) { + return true; + } + + @Override + public void attachSpark(ISparkEntity entity) { + // NO-OP + } + + @Override + public ISparkEntity getAttachedSpark() { + List sparks = worldObj.getEntitiesWithinAABB( + ISparkEntity.class, + AxisAlignedBB.getBoundingBox(xCoord, yCoord + 1, zCoord, xCoord + 1, yCoord + 2, zCoord + 1)); + if (sparks.size() == 1) { + Entity e = (Entity) sparks.get(0); + return (ISparkEntity) e; + } + + return null; + } + + @Override + public boolean areIncomingTranfersDone() { + return false; + } + + @Override + public int getAvailableSpaceForMana() { + return Math.max(0, manaCap - getCurrentMana()); + } + + @Override + public int getColor() { + return color; + } + + @Override + public void setColor(int color) { + this.color = color; + } + + @Override + public void markDispatchable() { + sendPacket = true; + } } diff --git a/src/main/java/vazkii/botania/common/block/tile/mana/TilePrism.java b/src/main/java/vazkii/botania/common/block/tile/mana/TilePrism.java index 974315976d..d9d31cbfb8 100644 --- a/src/main/java/vazkii/botania/common/block/tile/mana/TilePrism.java +++ b/src/main/java/vazkii/botania/common/block/tile/mana/TilePrism.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jan 17, 2015, 7:27:04 PM (GMT)] */ package vazkii.botania.common.block.tile.mana; @@ -23,60 +23,71 @@ public class TilePrism extends TileSimpleInventory implements IManaCollisionGhost, ISidedInventory { - public void onBurstCollision(IManaBurst burst) { - ItemStack lens = getStackInSlot(0); - boolean active = (getBlockMetadata() & 8) == 0; - boolean valid = lens != null && lens.getItem() instanceof ILens && (!(lens.getItem() instanceof ITinyPlanetExcempt) || ((ITinyPlanetExcempt) lens.getItem()).shouldPull(lens)); + public void onBurstCollision(IManaBurst burst) { + ItemStack lens = getStackInSlot(0); + boolean active = (getBlockMetadata() & 8) == 0; + boolean valid = lens != null + && lens.getItem() instanceof ILens + && (!(lens.getItem() instanceof ITinyPlanetExcempt) + || ((ITinyPlanetExcempt) lens.getItem()).shouldPull(lens)); - if(active) { - burst.setSourceLens(valid ? lens.copy() : null); - burst.setColor(0xFFFFFF); - burst.setGravity(0F); + if (active) { + burst.setSourceLens(valid ? lens.copy() : null); + burst.setColor(0xFFFFFF); + burst.setGravity(0F); - if(valid) { - Entity burstEntity = (Entity) burst; - BurstProperties properties = new BurstProperties(burst.getStartingMana(), burst.getMinManaLoss(), burst.getManaLossPerTick(), burst.getGravity(), 1F, burst.getColor()); + if (valid) { + Entity burstEntity = (Entity) burst; + BurstProperties properties = new BurstProperties( + burst.getStartingMana(), + burst.getMinManaLoss(), + burst.getManaLossPerTick(), + burst.getGravity(), + 1F, + burst.getColor()); - ((ILens) lens.getItem()).apply(lens, properties); + ((ILens) lens.getItem()).apply(lens, properties); - burst.setColor(properties.color); - burst.setStartingMana(properties.maxMana); - burst.setMinManaLoss(properties.ticksBeforeManaLoss); - burst.setManaLossPerTick(properties.manaLossPerTick); - burst.setGravity(properties.gravity); - burst.setMotion(burstEntity.motionX * properties.motionModifier, burstEntity.motionY * properties.motionModifier,burstEntity.motionZ * properties.motionModifier); - } - } - } + burst.setColor(properties.color); + burst.setStartingMana(properties.maxMana); + burst.setMinManaLoss(properties.ticksBeforeManaLoss); + burst.setManaLossPerTick(properties.manaLossPerTick); + burst.setGravity(properties.gravity); + burst.setMotion( + burstEntity.motionX * properties.motionModifier, + burstEntity.motionY * properties.motionModifier, + burstEntity.motionZ * properties.motionModifier); + } + } + } - @Override - public boolean isGhost() { - return true; - } + @Override + public boolean isGhost() { + return true; + } - @Override - public int getSizeInventory() { - return 1; - } + @Override + public int getSizeInventory() { + return 1; + } - @Override - public String getInventoryName() { - return LibBlockNames.PRISM; - } + @Override + public String getInventoryName() { + return LibBlockNames.PRISM; + } - @Override - public int[] getAccessibleSlotsFromSide(int p_94128_1_) { - return new int[] { 0 }; - } + @Override + public int[] getAccessibleSlotsFromSide(int p_94128_1_) { + return new int[] {0}; + } - @Override - public boolean canInsertItem(int p_102007_1_, ItemStack p_102007_2_, int p_102007_3_) { - return p_102007_2_.getItem() instanceof ILens; - } - - @Override - public boolean canExtractItem(int p_102008_1_, ItemStack p_102008_2_, int p_102008_3_) { - return true; - } + @Override + public boolean canInsertItem(int p_102007_1_, ItemStack p_102007_2_, int p_102007_3_) { + return p_102007_2_.getItem() instanceof ILens; + } + @Override + public boolean canExtractItem(int p_102008_1_, ItemStack p_102008_2_, int p_102008_3_) { + return true; + } } diff --git a/src/main/java/vazkii/botania/common/block/tile/mana/TilePump.java b/src/main/java/vazkii/botania/common/block/tile/mana/TilePump.java index e5adc8b708..16febbd8aa 100644 --- a/src/main/java/vazkii/botania/common/block/tile/mana/TilePump.java +++ b/src/main/java/vazkii/botania/common/block/tile/mana/TilePump.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Mar 18, 2015, 3:16:57 PM (GMT)] */ package vazkii.botania.common.block.tile.mana; @@ -17,86 +17,83 @@ public class TilePump extends TileMod { - private static final String TAG_ACTIVE = "active"; - - public float innerRingPos; - public boolean active = false; - public boolean hasCart = false; - public boolean hasCartOnTop = false; - public float moving = 0F; - - public int comparator; - public boolean hasRedstone = false; - int lastComparator = 0; - - @Override - public void updateEntity() { - hasRedstone = false; - for(ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS) { - int redstoneSide = worldObj.getIndirectPowerLevelTo(xCoord + dir.offsetX, yCoord + dir.offsetY, zCoord + dir.offsetZ, dir.ordinal()); - if(redstoneSide > 0) { - hasRedstone = true; - break; - } - } - - float max = 8F; - float min = 0F; - - float incr = max / 10F; - - if(innerRingPos < max && active && moving >= 0F) { - innerRingPos += incr; - moving = incr; - if(innerRingPos >= max) { - innerRingPos = Math.min(max, innerRingPos); - moving = 0F; - for(int x = 0; x < 2; x++) - worldObj.spawnParticle("explode", xCoord + Math.random(), yCoord + Math.random(), zCoord + Math.random(), 0, 0, 0); - } - } else if(innerRingPos > min) { - innerRingPos -= incr * 2; - moving = -incr * 2; - if(innerRingPos <= min) { - innerRingPos = Math.max(min, innerRingPos); - moving = 0F; - } - } - - if(!hasCartOnTop) - comparator = 0; - if(!hasCart && active) - setActive(false); - if(active && hasRedstone) - setActive(false); - - hasCart = false; - hasCartOnTop = false; - - if(comparator != lastComparator) - worldObj.func_147453_f(xCoord, yCoord, zCoord, worldObj.getBlock(xCoord, yCoord, zCoord)); - lastComparator = comparator; - - super.updateEntity(); - } - - @Override - public void writeCustomNBT(NBTTagCompound cmp) { - cmp.setBoolean(TAG_ACTIVE, active); - } - - @Override - public void readCustomNBT(NBTTagCompound cmp) { - active = cmp.getBoolean(TAG_ACTIVE); - } - - public void setActive(boolean active) { - if(!worldObj.isRemote) { - boolean diff = this.active != active; - this.active = active; - if(diff) - VanillaPacketDispatcher.dispatchTEToNearbyPlayers(worldObj, xCoord, yCoord, zCoord); - } - } - + private static final String TAG_ACTIVE = "active"; + + public float innerRingPos; + public boolean active = false; + public boolean hasCart = false; + public boolean hasCartOnTop = false; + public float moving = 0F; + + public int comparator; + public boolean hasRedstone = false; + int lastComparator = 0; + + @Override + public void updateEntity() { + hasRedstone = false; + for (ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS) { + int redstoneSide = worldObj.getIndirectPowerLevelTo( + xCoord + dir.offsetX, yCoord + dir.offsetY, zCoord + dir.offsetZ, dir.ordinal()); + if (redstoneSide > 0) { + hasRedstone = true; + break; + } + } + + float max = 8F; + float min = 0F; + + float incr = max / 10F; + + if (innerRingPos < max && active && moving >= 0F) { + innerRingPos += incr; + moving = incr; + if (innerRingPos >= max) { + innerRingPos = Math.min(max, innerRingPos); + moving = 0F; + for (int x = 0; x < 2; x++) + worldObj.spawnParticle( + "explode", xCoord + Math.random(), yCoord + Math.random(), zCoord + Math.random(), 0, 0, 0); + } + } else if (innerRingPos > min) { + innerRingPos -= incr * 2; + moving = -incr * 2; + if (innerRingPos <= min) { + innerRingPos = Math.max(min, innerRingPos); + moving = 0F; + } + } + + if (!hasCartOnTop) comparator = 0; + if (!hasCart && active) setActive(false); + if (active && hasRedstone) setActive(false); + + hasCart = false; + hasCartOnTop = false; + + if (comparator != lastComparator) + worldObj.func_147453_f(xCoord, yCoord, zCoord, worldObj.getBlock(xCoord, yCoord, zCoord)); + lastComparator = comparator; + + super.updateEntity(); + } + + @Override + public void writeCustomNBT(NBTTagCompound cmp) { + cmp.setBoolean(TAG_ACTIVE, active); + } + + @Override + public void readCustomNBT(NBTTagCompound cmp) { + active = cmp.getBoolean(TAG_ACTIVE); + } + + public void setActive(boolean active) { + if (!worldObj.isRemote) { + boolean diff = this.active != active; + this.active = active; + if (diff) VanillaPacketDispatcher.dispatchTEToNearbyPlayers(worldObj, xCoord, yCoord, zCoord); + } + } } diff --git a/src/main/java/vazkii/botania/common/block/tile/mana/TileRFGenerator.java b/src/main/java/vazkii/botania/common/block/tile/mana/TileRFGenerator.java index 59e76677f1..42c6f78baa 100644 --- a/src/main/java/vazkii/botania/common/block/tile/mana/TileRFGenerator.java +++ b/src/main/java/vazkii/botania/common/block/tile/mana/TileRFGenerator.java @@ -2,150 +2,138 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Aug 29, 2014, 10:01:32 PM (GMT)] */ package vazkii.botania.common.block.tile.mana; +import cofh.api.energy.IEnergyConnection; +import cofh.api.energy.IEnergyReceiver; +import cpw.mods.fml.common.Optional; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.tileentity.TileEntity; import net.minecraftforge.common.util.ForgeDirection; import vazkii.botania.api.mana.IManaReceiver; import vazkii.botania.common.block.tile.TileMod; -import cofh.api.energy.IEnergyConnection; -import cofh.api.energy.IEnergyReceiver; -import cpw.mods.fml.common.Optional; @Optional.Interface(iface = "cofh.api.energy.IEnergyConnection", modid = "CoFHAPI|energy") public class TileRFGenerator extends TileMod implements IManaReceiver, IEnergyConnection { - private static final int CONVERSION_RATE = 10; - private static final int MAX_MANA = 1280 * CONVERSION_RATE; - - private static final String TAG_MANA = "mana"; - - int mana = 0; - - // Thanks to skyboy for help with this cuz I'm a noob with RF - private IEnergyReceiver[] receiverCache; - private boolean deadCache; - - @Override - @Optional.Method(modid = "CoFHAPI|energy") - public void validate() { - super.validate(); - deadCache = true; - receiverCache = null; - } - - @Override - @Optional.Method(modid = "CoFHAPI|energy") - public void updateEntity() { - super.updateEntity(); - if(!worldObj.isRemote) { - if(deadCache) - reCache(); - - int transfer = Math.min(mana, 160 * CONVERSION_RATE); - mana -= transfer; - mana += transmitEnergy(transfer); - } - } - - @Optional.Method(modid = "CoFHAPI|energy") - protected final int transmitEnergy(int energy) { - if(receiverCache != null) - for(int i = receiverCache.length; i-- > 0;) { - IEnergyReceiver tile = receiverCache[i]; - if(tile == null) - continue; - - ForgeDirection from = ForgeDirection.VALID_DIRECTIONS[i]; - if(tile.receiveEnergy(from, energy, true) > 0) - energy -= tile.receiveEnergy(from, energy, false); - - if(energy <= 0) - return 0; - } - - return energy; - } - - @Optional.Method(modid = "CoFHAPI|energy") - private void reCache() { - if(deadCache) { - for(ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS) - onNeighborTileChange(xCoord + dir.offsetX, yCoord + dir.offsetY, zCoord + dir.offsetZ); - deadCache = false; - } - } - - @Optional.Method(modid = "CoFHAPI|energy") - public void onNeighborTileChange(int x, int y, int z) { - TileEntity tile = worldObj.getTileEntity(x, y, z); - - if(x < xCoord) - addCache(tile, 5); - else if(x > xCoord) - addCache(tile, 4); - else if(z < zCoord) - addCache(tile, 3); - else if(z > zCoord) - addCache(tile, 2); - else if(y < yCoord) - addCache(tile, 1); - else if(y > yCoord) - addCache(tile, 0); - } - - @Optional.Method(modid = "CoFHAPI|energy") - private void addCache(TileEntity tile, int side) { - if(receiverCache != null) - receiverCache[side] = null; - - if(tile instanceof IEnergyReceiver && ((IEnergyReceiver)tile).canConnectEnergy(ForgeDirection.VALID_DIRECTIONS[side])) { - if(receiverCache == null) - receiverCache = new IEnergyReceiver[6]; - receiverCache[side] = (IEnergyReceiver)tile; - } - } - - @Override - public int getCurrentMana() { - return mana / CONVERSION_RATE; - } - - @Override - public boolean isFull() { - return mana >= MAX_MANA; - } - - @Override - public void recieveMana(int mana) { - this.mana = Math.min(MAX_MANA, this.mana + mana * CONVERSION_RATE); - } - - @Override - public boolean canRecieveManaFromBursts() { - return true; - } - - @Override - public void writeCustomNBT(NBTTagCompound cmp) { - cmp.setInteger(TAG_MANA, mana); - } - - @Override - public void readCustomNBT(NBTTagCompound cmp) { - mana = cmp.getInteger(TAG_MANA); - } - - @Override - public boolean canConnectEnergy(ForgeDirection from) { - return true; - } - + private static final int CONVERSION_RATE = 10; + private static final int MAX_MANA = 1280 * CONVERSION_RATE; + + private static final String TAG_MANA = "mana"; + + int mana = 0; + + // Thanks to skyboy for help with this cuz I'm a noob with RF + private IEnergyReceiver[] receiverCache; + private boolean deadCache; + + @Override + @Optional.Method(modid = "CoFHAPI|energy") + public void validate() { + super.validate(); + deadCache = true; + receiverCache = null; + } + + @Override + @Optional.Method(modid = "CoFHAPI|energy") + public void updateEntity() { + super.updateEntity(); + if (!worldObj.isRemote) { + if (deadCache) reCache(); + + int transfer = Math.min(mana, 160 * CONVERSION_RATE); + mana -= transfer; + mana += transmitEnergy(transfer); + } + } + + @Optional.Method(modid = "CoFHAPI|energy") + protected final int transmitEnergy(int energy) { + if (receiverCache != null) + for (int i = receiverCache.length; i-- > 0; ) { + IEnergyReceiver tile = receiverCache[i]; + if (tile == null) continue; + + ForgeDirection from = ForgeDirection.VALID_DIRECTIONS[i]; + if (tile.receiveEnergy(from, energy, true) > 0) energy -= tile.receiveEnergy(from, energy, false); + + if (energy <= 0) return 0; + } + + return energy; + } + + @Optional.Method(modid = "CoFHAPI|energy") + private void reCache() { + if (deadCache) { + for (ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS) + onNeighborTileChange(xCoord + dir.offsetX, yCoord + dir.offsetY, zCoord + dir.offsetZ); + deadCache = false; + } + } + + @Optional.Method(modid = "CoFHAPI|energy") + public void onNeighborTileChange(int x, int y, int z) { + TileEntity tile = worldObj.getTileEntity(x, y, z); + + if (x < xCoord) addCache(tile, 5); + else if (x > xCoord) addCache(tile, 4); + else if (z < zCoord) addCache(tile, 3); + else if (z > zCoord) addCache(tile, 2); + else if (y < yCoord) addCache(tile, 1); + else if (y > yCoord) addCache(tile, 0); + } + + @Optional.Method(modid = "CoFHAPI|energy") + private void addCache(TileEntity tile, int side) { + if (receiverCache != null) receiverCache[side] = null; + + if (tile instanceof IEnergyReceiver + && ((IEnergyReceiver) tile).canConnectEnergy(ForgeDirection.VALID_DIRECTIONS[side])) { + if (receiverCache == null) receiverCache = new IEnergyReceiver[6]; + receiverCache[side] = (IEnergyReceiver) tile; + } + } + + @Override + public int getCurrentMana() { + return mana / CONVERSION_RATE; + } + + @Override + public boolean isFull() { + return mana >= MAX_MANA; + } + + @Override + public void recieveMana(int mana) { + this.mana = Math.min(MAX_MANA, this.mana + mana * CONVERSION_RATE); + } + + @Override + public boolean canRecieveManaFromBursts() { + return true; + } + + @Override + public void writeCustomNBT(NBTTagCompound cmp) { + cmp.setInteger(TAG_MANA, mana); + } + + @Override + public void readCustomNBT(NBTTagCompound cmp) { + mana = cmp.getInteger(TAG_MANA); + } + + @Override + public boolean canConnectEnergy(ForgeDirection from) { + return true; + } } diff --git a/src/main/java/vazkii/botania/common/block/tile/mana/TileSpreader.java b/src/main/java/vazkii/botania/common/block/tile/mana/TileSpreader.java index dff35de37b..d7465b4191 100644 --- a/src/main/java/vazkii/botania/common/block/tile/mana/TileSpreader.java +++ b/src/main/java/vazkii/botania/common/block/tile/mana/TileSpreader.java @@ -2,17 +2,16 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jan 25, 2014, 9:40:57 PM (GMT)] */ package vazkii.botania.common.block.tile.mana; import java.util.List; import java.util.UUID; - import net.minecraft.client.Minecraft; import net.minecraft.client.gui.ScaledResolution; import net.minecraft.client.renderer.RenderHelper; @@ -32,9 +31,7 @@ import net.minecraft.util.Vec3; import net.minecraft.world.World; import net.minecraftforge.common.util.ForgeDirection; - import org.lwjgl.opengl.GL11; - import vazkii.botania.api.internal.IManaBurst; import vazkii.botania.api.internal.VanillaPacketDispatcher; import vazkii.botania.api.mana.BurstProperties; @@ -61,705 +58,713 @@ import vazkii.botania.common.entity.EntityManaBurst.PositionProperties; import vazkii.botania.common.lib.LibBlockNames; -public class TileSpreader extends TileSimpleInventory implements IManaCollector, IWandBindable, IKeyLocked, IThrottledPacket, IManaSpreader, IRedirectable { - - private static final int MAX_MANA = 1000; - private static final int ULTRA_MAX_MANA = 6400; - private static final int TICKS_ALLOWED_WITHOUT_PINGBACK = 20; - private static final double PINGBACK_EXPIRED_SEARCH_DISTANCE = 0.5; - - private static final String TAG_HAS_IDENTITY = "hasIdentity"; - private static final String TAG_UUID_MOST = "uuidMost"; - private static final String TAG_UUID_LEAST = "uuidLeast"; - private static final String TAG_MANA = "mana"; - private static final String TAG_KNOWN_MANA = "knownMana"; - private static final String TAG_REQUEST_UPDATE = "requestUpdate"; - private static final String TAG_ROTATION_X = "rotationX"; - private static final String TAG_ROTATION_Y = "rotationY"; - private static final String TAG_PADDING_COLOR = "paddingColor"; - private static final String TAG_CAN_SHOOT_BURST = "canShootBurst"; - private static final String TAG_PINGBACK_TICKS = "pingbackTicks"; - private static final String TAG_LAST_PINGBACK_X = "lastPingbackX"; - private static final String TAG_LAST_PINGBACK_Y = "lastPingbackY"; - private static final String TAG_LAST_PINGBACK_Z = "lastPingbackZ"; - - private static final String TAG_FORCE_CLIENT_BINDING_X = "forceClientBindingX"; - private static final String TAG_FORCE_CLIENT_BINDING_Y = "forceClientBindingY"; - private static final String TAG_FORCE_CLIENT_BINDING_Z = "forceClientBindingZ"; - - // Map Maker Tags - - private static final String TAG_INPUT_KEY = "inputKey"; - private static final String TAG_OUTPUT_KEY = "outputKey"; - - private static final String TAG_MAPMAKER_OVERRIDE = "mapmakerOverrideEnabled"; - private static final String TAG_FORCED_COLOR = "mmForcedColor"; - private static final String TAG_FORCED_MANA_PAYLOAD = "mmForcedManaPayload"; - private static final String TAG_FORCED_TICKS_BEFORE_MANA_LOSS = "mmForcedTicksBeforeManaLoss"; - private static final String TAG_FORCED_MANA_LOSS_PER_TICK = "mmForcedManaLossPerTick"; - private static final String TAG_FORCED_GRAVITY = "mmForcedGravity"; - private static final String TAG_FORCED_VELOCITY_MULTIPLIER = "mmForcedVelocityMultiplier"; - - boolean mapmakerOverride = false; - int mmForcedColor = 0x20FF20; - int mmForcedManaPayload = 160; - int mmForcedTicksBeforeManaLoss = 60; - float mmForcedManaLossPerTick = 4F; - float mmForcedGravity = 0F; - float mmForcedVelocityMultiplier = 1F; - - String inputKey = ""; - String outputKey = ""; - - // End Map Maker Tags - - public static boolean staticRedstone = false; - public static boolean staticDreamwood = false; - public static boolean staticUltra = false; - - UUID identity; - - int mana; - int knownMana = -1; - public float rotationX, rotationY; - public int paddingColor = -1; - - boolean requestsClientUpdate = false; - boolean hasReceivedInitialPacket = false; - - IManaReceiver receiver = null; - IManaReceiver receiverLastTick = null; - - boolean redstoneLastTick = true; - public boolean canShootBurst = true; - public int lastBurstDeathTick = -1; - public int burstParticleTick = 0; - - public int pingbackTicks = 0; - public double lastPingbackX = 0; - public double lastPingbackY = -1; - public double lastPingbackZ = 0; - - List lastTentativeBurst; - boolean invalidTentativeBurst = false; - - @Override - public boolean isFull() { - return mana >= getMaxMana(); - } - - @Override - public void recieveMana(int mana) { - this.mana = Math.min(this.mana + mana, getMaxMana()); - } - - @Override - public void invalidate() { - super.invalidate(); - ManaNetworkEvent.removeCollector(this); - } - - @Override - public void onChunkUnload() { - super.onChunkUnload(); - invalidate(); - } - - @Override - public void updateEntity() { - boolean inNetwork = ManaNetworkHandler.instance.isCollectorIn(this); - boolean wasInNetwork = inNetwork; - if(!inNetwork && !isInvalid()) { - ManaNetworkEvent.addCollector(this); - inNetwork = true; - } - - boolean redstone = false; - - for(ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS) { - TileEntity tileAt = worldObj.getTileEntity(xCoord + dir.offsetX, yCoord + dir.offsetY, zCoord + dir.offsetZ); - if(tileAt instanceof IManaPool) { - IManaPool pool = (IManaPool) tileAt; - if(wasInNetwork && (pool != receiver || isRedstone())) { - if(pool instanceof IKeyLocked && !((IKeyLocked) pool).getOutputKey().equals(getInputKey())) - continue; - - int manaInPool = pool.getCurrentMana(); - if(manaInPool > 0 && !isFull()) { - int manaMissing = getMaxMana() - mana; - int manaToRemove = Math.min(manaInPool, manaMissing); - pool.recieveMana(-manaToRemove); - recieveMana(manaToRemove); - } - } - } - - int redstoneSide = worldObj.getIndirectPowerLevelTo(xCoord + dir.offsetX, yCoord + dir.offsetY, zCoord + dir.offsetZ, dir.ordinal()); - if(redstoneSide > 0) - redstone = true; - } - - if(needsNewBurstSimulation()) - checkForReceiver(); - - if(!canShootBurst) - if(pingbackTicks <= 0) { - double x = lastPingbackX; - double y = lastPingbackY; - double z = lastPingbackZ; - AxisAlignedBB aabb = AxisAlignedBB.getBoundingBox(x, y, z, x, y, z).expand(PINGBACK_EXPIRED_SEARCH_DISTANCE, PINGBACK_EXPIRED_SEARCH_DISTANCE, PINGBACK_EXPIRED_SEARCH_DISTANCE); - List bursts = worldObj.getEntitiesWithinAABB(IManaBurst.class, aabb); - IManaBurst found = null; - UUID identity = getIdentifier(); - for(IManaBurst burst : bursts) - if(burst != null && identity.equals(burst.getShooterUIID())) { - found = burst; - break; - } - - if(found != null) - found.ping(); - else setCanShoot(true); - } else pingbackTicks--; - - boolean shouldShoot = !redstone; - - boolean isredstone = isRedstone(); - if(isredstone) - shouldShoot = redstone && !redstoneLastTick; - - if(shouldShoot && receiver != null && receiver instanceof IKeyLocked) - shouldShoot = ((IKeyLocked) receiver).getInputKey().equals(getOutputKey()); - - ItemStack lens = getStackInSlot(0); - ILensControl control = getLensController(lens); - if(control != null) { - if(isredstone) { - if(shouldShoot) - control.onControlledSpreaderPulse(lens, this, redstone); - } else control.onControlledSpreaderTick(lens, this, redstone); - - shouldShoot &= control.allowBurstShooting(lens, this, redstone); - } - - if(shouldShoot) - tryShootBurst(); - - if(receiverLastTick != receiver && !worldObj.isRemote) { - requestsClientUpdate = true; - VanillaPacketDispatcher.dispatchTEToNearbyPlayers(worldObj, xCoord, yCoord, zCoord); - } - - redstoneLastTick = redstone; - receiverLastTick = receiver; - } - - @Override - public void writeCustomNBT(NBTTagCompound cmp) { - super.writeCustomNBT(cmp); - - UUID identity = getIdentifier(); - cmp.setBoolean(TAG_HAS_IDENTITY, true); - cmp.setLong(TAG_UUID_MOST, identity.getMostSignificantBits()); - cmp.setLong(TAG_UUID_LEAST, identity.getLeastSignificantBits()); - - cmp.setInteger(TAG_MANA, mana); - cmp.setFloat(TAG_ROTATION_X, rotationX); - cmp.setFloat(TAG_ROTATION_Y, rotationY); - cmp.setBoolean(TAG_REQUEST_UPDATE, requestsClientUpdate); - cmp.setInteger(TAG_PADDING_COLOR, paddingColor); - cmp.setBoolean(TAG_CAN_SHOOT_BURST, canShootBurst); - - cmp.setInteger(TAG_PINGBACK_TICKS, pingbackTicks); - cmp.setDouble(TAG_LAST_PINGBACK_X, lastPingbackX); - cmp.setDouble(TAG_LAST_PINGBACK_Y, lastPingbackY); - cmp.setDouble(TAG_LAST_PINGBACK_Z, lastPingbackZ); - - cmp.setString(TAG_INPUT_KEY, inputKey); - cmp.setString(TAG_OUTPUT_KEY, outputKey); - - cmp.setInteger(TAG_FORCE_CLIENT_BINDING_X, receiver == null ? 0 : ((TileEntity) receiver).xCoord); - cmp.setInteger(TAG_FORCE_CLIENT_BINDING_Y, receiver == null ? -1 : ((TileEntity) receiver).yCoord); - cmp.setInteger(TAG_FORCE_CLIENT_BINDING_Z, receiver == null ? 0 : ((TileEntity) receiver).zCoord); - - cmp.setBoolean(TAG_MAPMAKER_OVERRIDE, mapmakerOverride); - cmp.setInteger(TAG_FORCED_COLOR, mmForcedColor); - cmp.setInteger(TAG_FORCED_MANA_PAYLOAD, mmForcedManaPayload); - cmp.setInteger(TAG_FORCED_TICKS_BEFORE_MANA_LOSS, mmForcedTicksBeforeManaLoss); - cmp.setFloat(TAG_FORCED_MANA_LOSS_PER_TICK, mmForcedManaLossPerTick); - cmp.setFloat(TAG_FORCED_GRAVITY, mmForcedGravity); - cmp.setFloat(TAG_FORCED_VELOCITY_MULTIPLIER, mmForcedVelocityMultiplier); - - requestsClientUpdate = false; - } - - @Override - public void readCustomNBT(NBTTagCompound cmp) { - super.readCustomNBT(cmp); - - if(cmp.getBoolean(TAG_HAS_IDENTITY)) { - long most = cmp.getLong(TAG_UUID_MOST); - long least = cmp.getLong(TAG_UUID_LEAST); - UUID identity = getIdentifierUnsafe(); - if(identity == null || most != identity.getMostSignificantBits() || least != identity.getLeastSignificantBits()) - identity = new UUID(most, least); - } else getIdentifier(); - - mana = cmp.getInteger(TAG_MANA); - rotationX = cmp.getFloat(TAG_ROTATION_X); - rotationY = cmp.getFloat(TAG_ROTATION_Y); - requestsClientUpdate = cmp.getBoolean(TAG_REQUEST_UPDATE); - - if(cmp.hasKey(TAG_INPUT_KEY)) - inputKey = cmp.getString(TAG_INPUT_KEY); - if(cmp.hasKey(TAG_OUTPUT_KEY)) - inputKey = cmp.getString(TAG_OUTPUT_KEY); - - mapmakerOverride = cmp.getBoolean(TAG_MAPMAKER_OVERRIDE); - mmForcedColor = cmp.getInteger(TAG_FORCED_COLOR); - mmForcedManaPayload = cmp.getInteger(TAG_FORCED_MANA_PAYLOAD); - mmForcedTicksBeforeManaLoss = cmp.getInteger(TAG_FORCED_TICKS_BEFORE_MANA_LOSS); - mmForcedManaLossPerTick = cmp.getFloat(TAG_FORCED_MANA_LOSS_PER_TICK); - mmForcedGravity = cmp.getFloat(TAG_FORCED_GRAVITY); - mmForcedVelocityMultiplier = cmp.getFloat(TAG_FORCED_VELOCITY_MULTIPLIER); - - if(cmp.hasKey(TAG_KNOWN_MANA)) - knownMana = cmp.getInteger(TAG_KNOWN_MANA); - if(cmp.hasKey(TAG_PADDING_COLOR)) - paddingColor = cmp.getInteger(TAG_PADDING_COLOR); - if(cmp.hasKey(TAG_CAN_SHOOT_BURST)) - canShootBurst = cmp.getBoolean(TAG_CAN_SHOOT_BURST); - - pingbackTicks = cmp.getInteger(TAG_PINGBACK_TICKS); - lastPingbackX = cmp.getDouble(TAG_LAST_PINGBACK_X); - lastPingbackY = cmp.getDouble(TAG_LAST_PINGBACK_Y); - lastPingbackZ = cmp.getDouble(TAG_LAST_PINGBACK_Z); - - if(requestsClientUpdate && worldObj != null) { - int x = cmp.getInteger(TAG_FORCE_CLIENT_BINDING_X); - int y = cmp.getInteger(TAG_FORCE_CLIENT_BINDING_Y); - int z = cmp.getInteger(TAG_FORCE_CLIENT_BINDING_Z); - if(y != -1) { - TileEntity tile = worldObj.getTileEntity(x, y, z); - if(tile instanceof IManaReceiver) - receiver = (IManaReceiver) tile; - else receiver = null; - } else receiver = null; - } - - if(worldObj != null && worldObj.isRemote) - hasReceivedInitialPacket = true; - } - - @Override - public boolean canRecieveManaFromBursts() { - return true; - } - - @Override - public int getCurrentMana() { - return mana; - } - - public void onWanded(EntityPlayer player, ItemStack wand) { - if(player == null) - return; - - if(!player.isSneaking()) { - if(!worldObj.isRemote) { - NBTTagCompound nbttagcompound = new NBTTagCompound(); - writeCustomNBT(nbttagcompound); - nbttagcompound.setInteger(TAG_KNOWN_MANA, mana); - if(player instanceof EntityPlayerMP) - ((EntityPlayerMP) player).playerNetServerHandler.sendPacket(new S35PacketUpdateTileEntity(xCoord, yCoord, zCoord, -999, nbttagcompound)); - } - worldObj.playSoundAtEntity(player, "botania:ding", 0.1F, 1F); - } else { - MovingObjectPosition pos = raytraceFromEntity(worldObj, player, true, 5); - if(pos != null && pos.hitVec != null && !worldObj.isRemote) { - double x = pos.hitVec.xCoord - xCoord - 0.5; - double y = pos.hitVec.yCoord - yCoord - 0.5; - double z = pos.hitVec.zCoord - zCoord - 0.5; - - if(pos.sideHit != 0 && pos.sideHit != 1) { - Vector3 clickVector = new Vector3(x, 0, z); - Vector3 relative = new Vector3(-0.5, 0, 0); - double angle = Math.acos(clickVector.dotProduct(relative) / (relative.mag() * clickVector.mag())) * 180D / Math.PI; - - rotationX = (float) angle + 180F; - if(clickVector.z < 0) - rotationX = 360 - rotationX; - } - - double angle = y * 180; - rotationY = -(float) angle; - - checkForReceiver(); - requestsClientUpdate = true; - VanillaPacketDispatcher.dispatchTEToNearbyPlayers(worldObj, xCoord, yCoord, zCoord); - } - } - } - - private boolean needsNewBurstSimulation() { - if(worldObj.isRemote && !hasReceivedInitialPacket) - return false; - - if(lastTentativeBurst == null) - return true; - - for(PositionProperties props : lastTentativeBurst) - if(!props.contentsEqual(worldObj)) { - invalidTentativeBurst = props.invalid; - return !invalidTentativeBurst; - } - - return false; - } - - public void tryShootBurst() { - if((receiver != null || isRedstone()) && !invalidTentativeBurst) { - if(canShootBurst && (isRedstone() || receiver.canRecieveManaFromBursts() && !receiver.isFull())) { - EntityManaBurst burst = getBurst(false); - if(burst != null) { - if(!worldObj.isRemote) { - mana -= burst.getStartingMana(); - burst.setShooterUUID(getIdentifier()); - worldObj.spawnEntityInWorld(burst); - burst.ping(); - if(!ConfigHandler.silentSpreaders) - worldObj.playSoundEffect(xCoord, yCoord, zCoord, "botania:spreaderFire", 0.05F * (paddingColor != -1 ? 0.2F : 1F), 0.7F + 0.3F * (float) Math.random()); - } - } - } - } - } - - public boolean isRedstone() { - return worldObj == null ? staticRedstone : getBlockMetadata() == 1; - } - - public boolean isDreamwood() { - return worldObj == null ? staticDreamwood : getBlockMetadata() == 2 || getBlockMetadata() == 3; - } - - public boolean isULTRA_SPREADER() { - return worldObj == null ? staticUltra : getBlockMetadata() == 3; - } - - public void checkForReceiver() { - ItemStack stack = getStackInSlot(0); - ILensControl control = getLensController(stack); - if(control != null && !control.allowBurstShooting(stack, this, false)) - return; - - EntityManaBurst fakeBurst = getBurst(true); - fakeBurst.setScanBeam(); - TileEntity receiver = fakeBurst.getCollidedTile(true); - - if(receiver != null && receiver instanceof IManaReceiver) - this.receiver = (IManaReceiver) receiver; - else this.receiver = null; - lastTentativeBurst = fakeBurst.propsList; - } - - public EntityManaBurst getBurst(boolean fake) { - EntityManaBurst burst = new EntityManaBurst(this, fake); - - boolean dreamwood = isDreamwood(); - boolean ultra = isULTRA_SPREADER(); - int maxMana = ultra ? 640 : dreamwood ? 240 : 160; - int color = isRedstone() ? 0xFF2020 : dreamwood ? 0xFF45C4 : 0x20FF20; - int ticksBeforeManaLoss = ultra ? 120 : dreamwood ? 80 : 60; - float manaLossPerTick = ultra ? 20F : 4F; - float motionModifier = ultra ? 2F : dreamwood ? 1.25F : 1F; - float gravity = 0F; - BurstProperties props = new BurstProperties(maxMana, ticksBeforeManaLoss, manaLossPerTick, gravity, motionModifier, color); - - ItemStack lens = getStackInSlot(0); - if(lens != null && lens.getItem() instanceof ILensEffect) - ((ILensEffect) lens.getItem()).apply(lens, props); - - burst.setSourceLens(lens); - if(getCurrentMana() >= props.maxMana || fake) { - if(mapmakerOverride) { - burst.setColor(mmForcedColor); - burst.setMana(mmForcedManaPayload); - burst.setStartingMana(mmForcedManaPayload); - burst.setMinManaLoss(mmForcedTicksBeforeManaLoss); - burst.setManaLossPerTick(mmForcedManaLossPerTick); - burst.setGravity(mmForcedGravity); - burst.setMotion(burst.motionX * mmForcedVelocityMultiplier, burst.motionY * mmForcedVelocityMultiplier, burst.motionZ * mmForcedVelocityMultiplier); - } else { - burst.setColor(props.color); - burst.setMana(props.maxMana); - burst.setStartingMana(props.maxMana); - burst.setMinManaLoss(props.ticksBeforeManaLoss); - burst.setManaLossPerTick(props.manaLossPerTick); - burst.setGravity(props.gravity); - burst.setMotion(burst.motionX * props.motionModifier, burst.motionY * props.motionModifier, burst.motionZ * props.motionModifier); - } - - return burst; - } - return null; - } - - public ILensControl getLensController(ItemStack stack) { - if(stack != null && stack.getItem() instanceof ILensControl) { - ILensControl control = (ILensControl) stack.getItem(); - if(control.isControlLens(stack)) - return control; - } - - return null; - } - - public static MovingObjectPosition raytraceFromEntity(World world, Entity player, boolean par3, double range) { - float f = 1.0F; - float f1 = player.prevRotationPitch + (player.rotationPitch - player.prevRotationPitch) * f; - float f2 = player.prevRotationYaw + (player.rotationYaw - player.prevRotationYaw) * f; - double d0 = player.prevPosX + (player.posX - player.prevPosX) * f; - double d1 = player.prevPosY + (player.posY - player.prevPosY) * f; - if (!world.isRemote && player instanceof EntityPlayer) - d1 += 1.62D; - double d2 = player.prevPosZ + (player.posZ - player.prevPosZ) * f; - Vec3 vec3 = Vec3.createVectorHelper(d0, d1, d2); - float f3 = MathHelper.cos(-f2 * 0.017453292F - (float) Math.PI); - float f4 = MathHelper.sin(-f2 * 0.017453292F - (float) Math.PI); - float f5 = -MathHelper.cos(-f1 * 0.017453292F); - float f6 = MathHelper.sin(-f1 * 0.017453292F); - float f7 = f4 * f5; - float f8 = f3 * f5; - double d3 = range; - if (player instanceof EntityPlayerMP) - d3 = ((EntityPlayerMP) player).theItemInWorldManager.getBlockReachDistance(); - Vec3 vec31 = vec3.addVector(f7 * d3, f6 * d3, f8 * d3); - return world.func_147447_a(vec3, vec31, par3, !par3, par3); - } - - public void renderHUD(Minecraft mc, ScaledResolution res) { - String name = StatCollector.translateToLocal(new ItemStack(ModBlocks.spreader, 1, getBlockMetadata()).getUnlocalizedName().replaceAll("tile.", "tile." + LibResources.PREFIX_MOD) + ".name"); - int color = isRedstone() ? 0xFF0000 : isDreamwood() ? 0xFF00AE : 0x00FF00; - HUDHandler.drawSimpleManaHUD(color, knownMana, getMaxMana(), name, res); - - ItemStack lens = getStackInSlot(0); - if(lens != null) { - GL11.glEnable(GL11.GL_BLEND); - GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); - String lensName = lens.getDisplayName(); - int width = 16 + mc.fontRenderer.getStringWidth(lensName) / 2; - int x = res.getScaledWidth() / 2 - width; - int y = res.getScaledHeight() / 2 + 50; - - mc.fontRenderer.drawStringWithShadow(lensName, x + 20, y + 5, color); - RenderHelper.enableGUIStandardItemLighting(); - RenderItem.getInstance().renderItemAndEffectIntoGUI(mc.fontRenderer, mc.renderEngine, lens, x, y); - RenderHelper.disableStandardItemLighting(); - GL11.glDisable(GL11.GL_LIGHTING); - GL11.glDisable(GL11.GL_BLEND); - } - - if(receiver != null) { - TileEntity receiverTile = (TileEntity) receiver; - ItemStack recieverStack = new ItemStack(worldObj.getBlock(receiverTile.xCoord, receiverTile.yCoord, receiverTile.zCoord), 1, receiverTile.getBlockMetadata()); - GL11.glEnable(GL11.GL_BLEND); - GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); - if(recieverStack != null && recieverStack.getItem() != null) { - String stackName = recieverStack.getDisplayName(); - int width = 16 + mc.fontRenderer.getStringWidth(stackName) / 2; - int x = res.getScaledWidth() / 2 - width; - int y = res.getScaledHeight() / 2 + 30; - - mc.fontRenderer.drawStringWithShadow(stackName, x + 20, y + 5, color); - RenderHelper.enableGUIStandardItemLighting(); - RenderItem.getInstance().renderItemAndEffectIntoGUI(mc.fontRenderer, mc.renderEngine, recieverStack, x, y); - RenderHelper.disableStandardItemLighting(); - } - - GL11.glDisable(GL11.GL_LIGHTING); - GL11.glDisable(GL11.GL_BLEND); - } - - GL11.glColor4f(1F, 1F, 1F, 1F); - } - - @Override - public void onClientDisplayTick() { - if(worldObj != null) { - EntityManaBurst burst = getBurst(true); - burst.getCollidedTile(false); - } - } - - @Override - public float getManaYieldMultiplier(IManaBurst burst) { - return burst.getMana() < 16 ? 0F : 0.95F; - } - - @Override - public int getSizeInventory() { - return 1; - } - - @Override - public String getInventoryName() { - return LibBlockNames.SPREADER; - } - - @Override - public int getInventoryStackLimit() { - return 1; - } - - @Override - public boolean isItemValidForSlot(int i, ItemStack itemstack) { - return itemstack.getItem() instanceof ILens; - } - - @Override - public void markDirty() { - checkForReceiver(); - VanillaPacketDispatcher.dispatchTEToNearbyPlayers(worldObj, xCoord, yCoord, zCoord); - } - - @Override - public ChunkCoordinates getBinding() { - if(receiver == null) - return null; - - TileEntity tile = (TileEntity) receiver; - return new ChunkCoordinates(tile.xCoord, tile.yCoord, tile.zCoord); - } - - @Override - public int getMaxMana() { - return isULTRA_SPREADER() ? ULTRA_MAX_MANA : MAX_MANA; - } - - @Override - public String getInputKey() { - return inputKey; - } - - @Override - public String getOutputKey() { - return outputKey; - } - - @Override - public boolean canSelect(EntityPlayer player, ItemStack wand, int x, int y, int z, int side) { - return true; - } - - @Override - public boolean bindTo(EntityPlayer player, ItemStack wand, int x, int y, int z, int side) { - Vector3 thisVec = Vector3.fromTileEntityCenter(this); - Vector3 blockVec = new Vector3(x + 0.5, y + 0.5, z + 0.5); - - AxisAlignedBB axis = player.worldObj.getBlock(x, y, z).getCollisionBoundingBoxFromPool(player.worldObj, x, y, z); - if(axis == null) - axis = AxisAlignedBB.getBoundingBox(x, y, z, x + 1, y + 1, z + 1); - - if(!blockVec.isInside(axis)) - blockVec = new Vector3(axis.minX + (axis.maxX - axis.minX) / 2, axis.minY + (axis.maxY - axis.minY) / 2, axis.minZ + (axis.maxZ - axis.minZ) / 2); - - Vector3 diffVec = blockVec.copy().sub(thisVec); - Vector3 diffVec2D = new Vector3(diffVec.x, diffVec.z, 0); - Vector3 rotVec = new Vector3(0, 1, 0); - double angle = rotVec.angle(diffVec2D) / Math.PI * 180.0; - - if(blockVec.x < thisVec.x) - angle = -angle; - - rotationX = (float) angle + 90; - - rotVec = new Vector3(diffVec.x, 0, diffVec.z); - angle = diffVec.angle(rotVec) * 180F / Math.PI; - if(blockVec.y < thisVec.y) - angle = -angle; - rotationY = (float) angle; - - checkForReceiver(); - return true; - } - - @Override - public void markDispatchable() { - // NO-OP - } - - @Override - public float getRotationX() { - return rotationX; - } - - @Override - public float getRotationY() { - return rotationY; - } - - @Override - public void setRotationX(float rot) { - rotationX = rot; - } - - @Override - public void setRotationY(float rot) { - rotationY = rot; - } - - @Override - public void commitRedirection() { - checkForReceiver(); - } - - @Override - public void setCanShoot(boolean canShoot) { - canShootBurst = canShoot; - } - - @Override - public int getBurstParticleTick() { - return burstParticleTick; - } - - @Override - public void setBurstParticleTick(int i) { - burstParticleTick = i; - } - - @Override - public int getLastBurstDeathTick() { - return lastBurstDeathTick; - } - - @Override - public void setLastBurstDeathTick(int i) { - lastBurstDeathTick = i; - } - - @Override - public void pingback(IManaBurst burst, UUID expectedIdentity) { - if(getIdentifier().equals(expectedIdentity)) { - pingbackTicks = TICKS_ALLOWED_WITHOUT_PINGBACK; - Entity e = (Entity) burst; - lastPingbackX = e.posX; - lastPingbackY = e.posY; - lastPingbackZ = e.posZ; - setCanShoot(false); - } - } - - @Override - public UUID getIdentifier() { - if(identity == null) - identity = UUID.randomUUID(); - return identity; - } - - public UUID getIdentifierUnsafe() { - return identity; - } - +public class TileSpreader extends TileSimpleInventory + implements IManaCollector, IWandBindable, IKeyLocked, IThrottledPacket, IManaSpreader, IRedirectable { + + private static final int MAX_MANA = 1000; + private static final int ULTRA_MAX_MANA = 6400; + private static final int TICKS_ALLOWED_WITHOUT_PINGBACK = 20; + private static final double PINGBACK_EXPIRED_SEARCH_DISTANCE = 0.5; + + private static final String TAG_HAS_IDENTITY = "hasIdentity"; + private static final String TAG_UUID_MOST = "uuidMost"; + private static final String TAG_UUID_LEAST = "uuidLeast"; + private static final String TAG_MANA = "mana"; + private static final String TAG_KNOWN_MANA = "knownMana"; + private static final String TAG_REQUEST_UPDATE = "requestUpdate"; + private static final String TAG_ROTATION_X = "rotationX"; + private static final String TAG_ROTATION_Y = "rotationY"; + private static final String TAG_PADDING_COLOR = "paddingColor"; + private static final String TAG_CAN_SHOOT_BURST = "canShootBurst"; + private static final String TAG_PINGBACK_TICKS = "pingbackTicks"; + private static final String TAG_LAST_PINGBACK_X = "lastPingbackX"; + private static final String TAG_LAST_PINGBACK_Y = "lastPingbackY"; + private static final String TAG_LAST_PINGBACK_Z = "lastPingbackZ"; + + private static final String TAG_FORCE_CLIENT_BINDING_X = "forceClientBindingX"; + private static final String TAG_FORCE_CLIENT_BINDING_Y = "forceClientBindingY"; + private static final String TAG_FORCE_CLIENT_BINDING_Z = "forceClientBindingZ"; + + // Map Maker Tags + + private static final String TAG_INPUT_KEY = "inputKey"; + private static final String TAG_OUTPUT_KEY = "outputKey"; + + private static final String TAG_MAPMAKER_OVERRIDE = "mapmakerOverrideEnabled"; + private static final String TAG_FORCED_COLOR = "mmForcedColor"; + private static final String TAG_FORCED_MANA_PAYLOAD = "mmForcedManaPayload"; + private static final String TAG_FORCED_TICKS_BEFORE_MANA_LOSS = "mmForcedTicksBeforeManaLoss"; + private static final String TAG_FORCED_MANA_LOSS_PER_TICK = "mmForcedManaLossPerTick"; + private static final String TAG_FORCED_GRAVITY = "mmForcedGravity"; + private static final String TAG_FORCED_VELOCITY_MULTIPLIER = "mmForcedVelocityMultiplier"; + + boolean mapmakerOverride = false; + int mmForcedColor = 0x20FF20; + int mmForcedManaPayload = 160; + int mmForcedTicksBeforeManaLoss = 60; + float mmForcedManaLossPerTick = 4F; + float mmForcedGravity = 0F; + float mmForcedVelocityMultiplier = 1F; + + String inputKey = ""; + String outputKey = ""; + + // End Map Maker Tags + + public static boolean staticRedstone = false; + public static boolean staticDreamwood = false; + public static boolean staticUltra = false; + + UUID identity; + + int mana; + int knownMana = -1; + public float rotationX, rotationY; + public int paddingColor = -1; + + boolean requestsClientUpdate = false; + boolean hasReceivedInitialPacket = false; + + IManaReceiver receiver = null; + IManaReceiver receiverLastTick = null; + + boolean redstoneLastTick = true; + public boolean canShootBurst = true; + public int lastBurstDeathTick = -1; + public int burstParticleTick = 0; + + public int pingbackTicks = 0; + public double lastPingbackX = 0; + public double lastPingbackY = -1; + public double lastPingbackZ = 0; + + List lastTentativeBurst; + boolean invalidTentativeBurst = false; + + @Override + public boolean isFull() { + return mana >= getMaxMana(); + } + + @Override + public void recieveMana(int mana) { + this.mana = Math.min(this.mana + mana, getMaxMana()); + } + + @Override + public void invalidate() { + super.invalidate(); + ManaNetworkEvent.removeCollector(this); + } + + @Override + public void onChunkUnload() { + super.onChunkUnload(); + invalidate(); + } + + @Override + public void updateEntity() { + boolean inNetwork = ManaNetworkHandler.instance.isCollectorIn(this); + boolean wasInNetwork = inNetwork; + if (!inNetwork && !isInvalid()) { + ManaNetworkEvent.addCollector(this); + inNetwork = true; + } + + boolean redstone = false; + + for (ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS) { + TileEntity tileAt = + worldObj.getTileEntity(xCoord + dir.offsetX, yCoord + dir.offsetY, zCoord + dir.offsetZ); + if (tileAt instanceof IManaPool) { + IManaPool pool = (IManaPool) tileAt; + if (wasInNetwork && (pool != receiver || isRedstone())) { + if (pool instanceof IKeyLocked + && !((IKeyLocked) pool).getOutputKey().equals(getInputKey())) continue; + + int manaInPool = pool.getCurrentMana(); + if (manaInPool > 0 && !isFull()) { + int manaMissing = getMaxMana() - mana; + int manaToRemove = Math.min(manaInPool, manaMissing); + pool.recieveMana(-manaToRemove); + recieveMana(manaToRemove); + } + } + } + + int redstoneSide = worldObj.getIndirectPowerLevelTo( + xCoord + dir.offsetX, yCoord + dir.offsetY, zCoord + dir.offsetZ, dir.ordinal()); + if (redstoneSide > 0) redstone = true; + } + + if (needsNewBurstSimulation()) checkForReceiver(); + + if (!canShootBurst) + if (pingbackTicks <= 0) { + double x = lastPingbackX; + double y = lastPingbackY; + double z = lastPingbackZ; + AxisAlignedBB aabb = AxisAlignedBB.getBoundingBox(x, y, z, x, y, z) + .expand( + PINGBACK_EXPIRED_SEARCH_DISTANCE, + PINGBACK_EXPIRED_SEARCH_DISTANCE, + PINGBACK_EXPIRED_SEARCH_DISTANCE); + List bursts = worldObj.getEntitiesWithinAABB(IManaBurst.class, aabb); + IManaBurst found = null; + UUID identity = getIdentifier(); + for (IManaBurst burst : bursts) + if (burst != null && identity.equals(burst.getShooterUIID())) { + found = burst; + break; + } + + if (found != null) found.ping(); + else setCanShoot(true); + } else pingbackTicks--; + + boolean shouldShoot = !redstone; + + boolean isredstone = isRedstone(); + if (isredstone) shouldShoot = redstone && !redstoneLastTick; + + if (shouldShoot && receiver != null && receiver instanceof IKeyLocked) + shouldShoot = ((IKeyLocked) receiver).getInputKey().equals(getOutputKey()); + + ItemStack lens = getStackInSlot(0); + ILensControl control = getLensController(lens); + if (control != null) { + if (isredstone) { + if (shouldShoot) control.onControlledSpreaderPulse(lens, this, redstone); + } else control.onControlledSpreaderTick(lens, this, redstone); + + shouldShoot &= control.allowBurstShooting(lens, this, redstone); + } + + if (shouldShoot) tryShootBurst(); + + if (receiverLastTick != receiver && !worldObj.isRemote) { + requestsClientUpdate = true; + VanillaPacketDispatcher.dispatchTEToNearbyPlayers(worldObj, xCoord, yCoord, zCoord); + } + + redstoneLastTick = redstone; + receiverLastTick = receiver; + } + + @Override + public void writeCustomNBT(NBTTagCompound cmp) { + super.writeCustomNBT(cmp); + + UUID identity = getIdentifier(); + cmp.setBoolean(TAG_HAS_IDENTITY, true); + cmp.setLong(TAG_UUID_MOST, identity.getMostSignificantBits()); + cmp.setLong(TAG_UUID_LEAST, identity.getLeastSignificantBits()); + + cmp.setInteger(TAG_MANA, mana); + cmp.setFloat(TAG_ROTATION_X, rotationX); + cmp.setFloat(TAG_ROTATION_Y, rotationY); + cmp.setBoolean(TAG_REQUEST_UPDATE, requestsClientUpdate); + cmp.setInteger(TAG_PADDING_COLOR, paddingColor); + cmp.setBoolean(TAG_CAN_SHOOT_BURST, canShootBurst); + + cmp.setInteger(TAG_PINGBACK_TICKS, pingbackTicks); + cmp.setDouble(TAG_LAST_PINGBACK_X, lastPingbackX); + cmp.setDouble(TAG_LAST_PINGBACK_Y, lastPingbackY); + cmp.setDouble(TAG_LAST_PINGBACK_Z, lastPingbackZ); + + cmp.setString(TAG_INPUT_KEY, inputKey); + cmp.setString(TAG_OUTPUT_KEY, outputKey); + + cmp.setInteger(TAG_FORCE_CLIENT_BINDING_X, receiver == null ? 0 : ((TileEntity) receiver).xCoord); + cmp.setInteger(TAG_FORCE_CLIENT_BINDING_Y, receiver == null ? -1 : ((TileEntity) receiver).yCoord); + cmp.setInteger(TAG_FORCE_CLIENT_BINDING_Z, receiver == null ? 0 : ((TileEntity) receiver).zCoord); + + cmp.setBoolean(TAG_MAPMAKER_OVERRIDE, mapmakerOverride); + cmp.setInteger(TAG_FORCED_COLOR, mmForcedColor); + cmp.setInteger(TAG_FORCED_MANA_PAYLOAD, mmForcedManaPayload); + cmp.setInteger(TAG_FORCED_TICKS_BEFORE_MANA_LOSS, mmForcedTicksBeforeManaLoss); + cmp.setFloat(TAG_FORCED_MANA_LOSS_PER_TICK, mmForcedManaLossPerTick); + cmp.setFloat(TAG_FORCED_GRAVITY, mmForcedGravity); + cmp.setFloat(TAG_FORCED_VELOCITY_MULTIPLIER, mmForcedVelocityMultiplier); + + requestsClientUpdate = false; + } + + @Override + public void readCustomNBT(NBTTagCompound cmp) { + super.readCustomNBT(cmp); + + if (cmp.getBoolean(TAG_HAS_IDENTITY)) { + long most = cmp.getLong(TAG_UUID_MOST); + long least = cmp.getLong(TAG_UUID_LEAST); + UUID identity = getIdentifierUnsafe(); + if (identity == null + || most != identity.getMostSignificantBits() + || least != identity.getLeastSignificantBits()) identity = new UUID(most, least); + } else getIdentifier(); + + mana = cmp.getInteger(TAG_MANA); + rotationX = cmp.getFloat(TAG_ROTATION_X); + rotationY = cmp.getFloat(TAG_ROTATION_Y); + requestsClientUpdate = cmp.getBoolean(TAG_REQUEST_UPDATE); + + if (cmp.hasKey(TAG_INPUT_KEY)) inputKey = cmp.getString(TAG_INPUT_KEY); + if (cmp.hasKey(TAG_OUTPUT_KEY)) inputKey = cmp.getString(TAG_OUTPUT_KEY); + + mapmakerOverride = cmp.getBoolean(TAG_MAPMAKER_OVERRIDE); + mmForcedColor = cmp.getInteger(TAG_FORCED_COLOR); + mmForcedManaPayload = cmp.getInteger(TAG_FORCED_MANA_PAYLOAD); + mmForcedTicksBeforeManaLoss = cmp.getInteger(TAG_FORCED_TICKS_BEFORE_MANA_LOSS); + mmForcedManaLossPerTick = cmp.getFloat(TAG_FORCED_MANA_LOSS_PER_TICK); + mmForcedGravity = cmp.getFloat(TAG_FORCED_GRAVITY); + mmForcedVelocityMultiplier = cmp.getFloat(TAG_FORCED_VELOCITY_MULTIPLIER); + + if (cmp.hasKey(TAG_KNOWN_MANA)) knownMana = cmp.getInteger(TAG_KNOWN_MANA); + if (cmp.hasKey(TAG_PADDING_COLOR)) paddingColor = cmp.getInteger(TAG_PADDING_COLOR); + if (cmp.hasKey(TAG_CAN_SHOOT_BURST)) canShootBurst = cmp.getBoolean(TAG_CAN_SHOOT_BURST); + + pingbackTicks = cmp.getInteger(TAG_PINGBACK_TICKS); + lastPingbackX = cmp.getDouble(TAG_LAST_PINGBACK_X); + lastPingbackY = cmp.getDouble(TAG_LAST_PINGBACK_Y); + lastPingbackZ = cmp.getDouble(TAG_LAST_PINGBACK_Z); + + if (requestsClientUpdate && worldObj != null) { + int x = cmp.getInteger(TAG_FORCE_CLIENT_BINDING_X); + int y = cmp.getInteger(TAG_FORCE_CLIENT_BINDING_Y); + int z = cmp.getInteger(TAG_FORCE_CLIENT_BINDING_Z); + if (y != -1) { + TileEntity tile = worldObj.getTileEntity(x, y, z); + if (tile instanceof IManaReceiver) receiver = (IManaReceiver) tile; + else receiver = null; + } else receiver = null; + } + + if (worldObj != null && worldObj.isRemote) hasReceivedInitialPacket = true; + } + + @Override + public boolean canRecieveManaFromBursts() { + return true; + } + + @Override + public int getCurrentMana() { + return mana; + } + + public void onWanded(EntityPlayer player, ItemStack wand) { + if (player == null) return; + + if (!player.isSneaking()) { + if (!worldObj.isRemote) { + NBTTagCompound nbttagcompound = new NBTTagCompound(); + writeCustomNBT(nbttagcompound); + nbttagcompound.setInteger(TAG_KNOWN_MANA, mana); + if (player instanceof EntityPlayerMP) + ((EntityPlayerMP) player) + .playerNetServerHandler.sendPacket( + new S35PacketUpdateTileEntity(xCoord, yCoord, zCoord, -999, nbttagcompound)); + } + worldObj.playSoundAtEntity(player, "botania:ding", 0.1F, 1F); + } else { + MovingObjectPosition pos = raytraceFromEntity(worldObj, player, true, 5); + if (pos != null && pos.hitVec != null && !worldObj.isRemote) { + double x = pos.hitVec.xCoord - xCoord - 0.5; + double y = pos.hitVec.yCoord - yCoord - 0.5; + double z = pos.hitVec.zCoord - zCoord - 0.5; + + if (pos.sideHit != 0 && pos.sideHit != 1) { + Vector3 clickVector = new Vector3(x, 0, z); + Vector3 relative = new Vector3(-0.5, 0, 0); + double angle = Math.acos(clickVector.dotProduct(relative) / (relative.mag() * clickVector.mag())) + * 180D + / Math.PI; + + rotationX = (float) angle + 180F; + if (clickVector.z < 0) rotationX = 360 - rotationX; + } + + double angle = y * 180; + rotationY = -(float) angle; + + checkForReceiver(); + requestsClientUpdate = true; + VanillaPacketDispatcher.dispatchTEToNearbyPlayers(worldObj, xCoord, yCoord, zCoord); + } + } + } + + private boolean needsNewBurstSimulation() { + if (worldObj.isRemote && !hasReceivedInitialPacket) return false; + + if (lastTentativeBurst == null) return true; + + for (PositionProperties props : lastTentativeBurst) + if (!props.contentsEqual(worldObj)) { + invalidTentativeBurst = props.invalid; + return !invalidTentativeBurst; + } + + return false; + } + + public void tryShootBurst() { + if ((receiver != null || isRedstone()) && !invalidTentativeBurst) { + if (canShootBurst && (isRedstone() || receiver.canRecieveManaFromBursts() && !receiver.isFull())) { + EntityManaBurst burst = getBurst(false); + if (burst != null) { + if (!worldObj.isRemote) { + mana -= burst.getStartingMana(); + burst.setShooterUUID(getIdentifier()); + worldObj.spawnEntityInWorld(burst); + burst.ping(); + if (!ConfigHandler.silentSpreaders) + worldObj.playSoundEffect( + xCoord, + yCoord, + zCoord, + "botania:spreaderFire", + 0.05F * (paddingColor != -1 ? 0.2F : 1F), + 0.7F + 0.3F * (float) Math.random()); + } + } + } + } + } + + public boolean isRedstone() { + return worldObj == null ? staticRedstone : getBlockMetadata() == 1; + } + + public boolean isDreamwood() { + return worldObj == null ? staticDreamwood : getBlockMetadata() == 2 || getBlockMetadata() == 3; + } + + public boolean isULTRA_SPREADER() { + return worldObj == null ? staticUltra : getBlockMetadata() == 3; + } + + public void checkForReceiver() { + ItemStack stack = getStackInSlot(0); + ILensControl control = getLensController(stack); + if (control != null && !control.allowBurstShooting(stack, this, false)) return; + + EntityManaBurst fakeBurst = getBurst(true); + fakeBurst.setScanBeam(); + TileEntity receiver = fakeBurst.getCollidedTile(true); + + if (receiver != null && receiver instanceof IManaReceiver) this.receiver = (IManaReceiver) receiver; + else this.receiver = null; + lastTentativeBurst = fakeBurst.propsList; + } + + public EntityManaBurst getBurst(boolean fake) { + EntityManaBurst burst = new EntityManaBurst(this, fake); + + boolean dreamwood = isDreamwood(); + boolean ultra = isULTRA_SPREADER(); + int maxMana = ultra ? 640 : dreamwood ? 240 : 160; + int color = isRedstone() ? 0xFF2020 : dreamwood ? 0xFF45C4 : 0x20FF20; + int ticksBeforeManaLoss = ultra ? 120 : dreamwood ? 80 : 60; + float manaLossPerTick = ultra ? 20F : 4F; + float motionModifier = ultra ? 2F : dreamwood ? 1.25F : 1F; + float gravity = 0F; + BurstProperties props = + new BurstProperties(maxMana, ticksBeforeManaLoss, manaLossPerTick, gravity, motionModifier, color); + + ItemStack lens = getStackInSlot(0); + if (lens != null && lens.getItem() instanceof ILensEffect) ((ILensEffect) lens.getItem()).apply(lens, props); + + burst.setSourceLens(lens); + if (getCurrentMana() >= props.maxMana || fake) { + if (mapmakerOverride) { + burst.setColor(mmForcedColor); + burst.setMana(mmForcedManaPayload); + burst.setStartingMana(mmForcedManaPayload); + burst.setMinManaLoss(mmForcedTicksBeforeManaLoss); + burst.setManaLossPerTick(mmForcedManaLossPerTick); + burst.setGravity(mmForcedGravity); + burst.setMotion( + burst.motionX * mmForcedVelocityMultiplier, + burst.motionY * mmForcedVelocityMultiplier, + burst.motionZ * mmForcedVelocityMultiplier); + } else { + burst.setColor(props.color); + burst.setMana(props.maxMana); + burst.setStartingMana(props.maxMana); + burst.setMinManaLoss(props.ticksBeforeManaLoss); + burst.setManaLossPerTick(props.manaLossPerTick); + burst.setGravity(props.gravity); + burst.setMotion( + burst.motionX * props.motionModifier, + burst.motionY * props.motionModifier, + burst.motionZ * props.motionModifier); + } + + return burst; + } + return null; + } + + public ILensControl getLensController(ItemStack stack) { + if (stack != null && stack.getItem() instanceof ILensControl) { + ILensControl control = (ILensControl) stack.getItem(); + if (control.isControlLens(stack)) return control; + } + + return null; + } + + public static MovingObjectPosition raytraceFromEntity(World world, Entity player, boolean par3, double range) { + float f = 1.0F; + float f1 = player.prevRotationPitch + (player.rotationPitch - player.prevRotationPitch) * f; + float f2 = player.prevRotationYaw + (player.rotationYaw - player.prevRotationYaw) * f; + double d0 = player.prevPosX + (player.posX - player.prevPosX) * f; + double d1 = player.prevPosY + (player.posY - player.prevPosY) * f; + if (!world.isRemote && player instanceof EntityPlayer) d1 += 1.62D; + double d2 = player.prevPosZ + (player.posZ - player.prevPosZ) * f; + Vec3 vec3 = Vec3.createVectorHelper(d0, d1, d2); + float f3 = MathHelper.cos(-f2 * 0.017453292F - (float) Math.PI); + float f4 = MathHelper.sin(-f2 * 0.017453292F - (float) Math.PI); + float f5 = -MathHelper.cos(-f1 * 0.017453292F); + float f6 = MathHelper.sin(-f1 * 0.017453292F); + float f7 = f4 * f5; + float f8 = f3 * f5; + double d3 = range; + if (player instanceof EntityPlayerMP) + d3 = ((EntityPlayerMP) player).theItemInWorldManager.getBlockReachDistance(); + Vec3 vec31 = vec3.addVector(f7 * d3, f6 * d3, f8 * d3); + return world.func_147447_a(vec3, vec31, par3, !par3, par3); + } + + public void renderHUD(Minecraft mc, ScaledResolution res) { + String name = StatCollector.translateToLocal(new ItemStack(ModBlocks.spreader, 1, getBlockMetadata()) + .getUnlocalizedName() + .replaceAll("tile.", "tile." + LibResources.PREFIX_MOD) + + ".name"); + int color = isRedstone() ? 0xFF0000 : isDreamwood() ? 0xFF00AE : 0x00FF00; + HUDHandler.drawSimpleManaHUD(color, knownMana, getMaxMana(), name, res); + + ItemStack lens = getStackInSlot(0); + if (lens != null) { + GL11.glEnable(GL11.GL_BLEND); + GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); + String lensName = lens.getDisplayName(); + int width = 16 + mc.fontRenderer.getStringWidth(lensName) / 2; + int x = res.getScaledWidth() / 2 - width; + int y = res.getScaledHeight() / 2 + 50; + + mc.fontRenderer.drawStringWithShadow(lensName, x + 20, y + 5, color); + RenderHelper.enableGUIStandardItemLighting(); + RenderItem.getInstance().renderItemAndEffectIntoGUI(mc.fontRenderer, mc.renderEngine, lens, x, y); + RenderHelper.disableStandardItemLighting(); + GL11.glDisable(GL11.GL_LIGHTING); + GL11.glDisable(GL11.GL_BLEND); + } + + if (receiver != null) { + TileEntity receiverTile = (TileEntity) receiver; + ItemStack recieverStack = new ItemStack( + worldObj.getBlock(receiverTile.xCoord, receiverTile.yCoord, receiverTile.zCoord), + 1, + receiverTile.getBlockMetadata()); + GL11.glEnable(GL11.GL_BLEND); + GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); + if (recieverStack != null && recieverStack.getItem() != null) { + String stackName = recieverStack.getDisplayName(); + int width = 16 + mc.fontRenderer.getStringWidth(stackName) / 2; + int x = res.getScaledWidth() / 2 - width; + int y = res.getScaledHeight() / 2 + 30; + + mc.fontRenderer.drawStringWithShadow(stackName, x + 20, y + 5, color); + RenderHelper.enableGUIStandardItemLighting(); + RenderItem.getInstance() + .renderItemAndEffectIntoGUI(mc.fontRenderer, mc.renderEngine, recieverStack, x, y); + RenderHelper.disableStandardItemLighting(); + } + + GL11.glDisable(GL11.GL_LIGHTING); + GL11.glDisable(GL11.GL_BLEND); + } + + GL11.glColor4f(1F, 1F, 1F, 1F); + } + + @Override + public void onClientDisplayTick() { + if (worldObj != null) { + EntityManaBurst burst = getBurst(true); + burst.getCollidedTile(false); + } + } + + @Override + public float getManaYieldMultiplier(IManaBurst burst) { + return burst.getMana() < 16 ? 0F : 0.95F; + } + + @Override + public int getSizeInventory() { + return 1; + } + + @Override + public String getInventoryName() { + return LibBlockNames.SPREADER; + } + + @Override + public int getInventoryStackLimit() { + return 1; + } + + @Override + public boolean isItemValidForSlot(int i, ItemStack itemstack) { + return itemstack.getItem() instanceof ILens; + } + + @Override + public void markDirty() { + checkForReceiver(); + VanillaPacketDispatcher.dispatchTEToNearbyPlayers(worldObj, xCoord, yCoord, zCoord); + } + + @Override + public ChunkCoordinates getBinding() { + if (receiver == null) return null; + + TileEntity tile = (TileEntity) receiver; + return new ChunkCoordinates(tile.xCoord, tile.yCoord, tile.zCoord); + } + + @Override + public int getMaxMana() { + return isULTRA_SPREADER() ? ULTRA_MAX_MANA : MAX_MANA; + } + + @Override + public String getInputKey() { + return inputKey; + } + + @Override + public String getOutputKey() { + return outputKey; + } + + @Override + public boolean canSelect(EntityPlayer player, ItemStack wand, int x, int y, int z, int side) { + return true; + } + + @Override + public boolean bindTo(EntityPlayer player, ItemStack wand, int x, int y, int z, int side) { + Vector3 thisVec = Vector3.fromTileEntityCenter(this); + Vector3 blockVec = new Vector3(x + 0.5, y + 0.5, z + 0.5); + + AxisAlignedBB axis = + player.worldObj.getBlock(x, y, z).getCollisionBoundingBoxFromPool(player.worldObj, x, y, z); + if (axis == null) axis = AxisAlignedBB.getBoundingBox(x, y, z, x + 1, y + 1, z + 1); + + if (!blockVec.isInside(axis)) + blockVec = new Vector3( + axis.minX + (axis.maxX - axis.minX) / 2, + axis.minY + (axis.maxY - axis.minY) / 2, + axis.minZ + (axis.maxZ - axis.minZ) / 2); + + Vector3 diffVec = blockVec.copy().sub(thisVec); + Vector3 diffVec2D = new Vector3(diffVec.x, diffVec.z, 0); + Vector3 rotVec = new Vector3(0, 1, 0); + double angle = rotVec.angle(diffVec2D) / Math.PI * 180.0; + + if (blockVec.x < thisVec.x) angle = -angle; + + rotationX = (float) angle + 90; + + rotVec = new Vector3(diffVec.x, 0, diffVec.z); + angle = diffVec.angle(rotVec) * 180F / Math.PI; + if (blockVec.y < thisVec.y) angle = -angle; + rotationY = (float) angle; + + checkForReceiver(); + return true; + } + + @Override + public void markDispatchable() { + // NO-OP + } + + @Override + public float getRotationX() { + return rotationX; + } + + @Override + public float getRotationY() { + return rotationY; + } + + @Override + public void setRotationX(float rot) { + rotationX = rot; + } + + @Override + public void setRotationY(float rot) { + rotationY = rot; + } + + @Override + public void commitRedirection() { + checkForReceiver(); + } + + @Override + public void setCanShoot(boolean canShoot) { + canShootBurst = canShoot; + } + + @Override + public int getBurstParticleTick() { + return burstParticleTick; + } + + @Override + public void setBurstParticleTick(int i) { + burstParticleTick = i; + } + + @Override + public int getLastBurstDeathTick() { + return lastBurstDeathTick; + } + + @Override + public void setLastBurstDeathTick(int i) { + lastBurstDeathTick = i; + } + + @Override + public void pingback(IManaBurst burst, UUID expectedIdentity) { + if (getIdentifier().equals(expectedIdentity)) { + pingbackTicks = TICKS_ALLOWED_WITHOUT_PINGBACK; + Entity e = (Entity) burst; + lastPingbackX = e.posX; + lastPingbackY = e.posY; + lastPingbackZ = e.posZ; + setCanShoot(false); + } + } + + @Override + public UUID getIdentifier() { + if (identity == null) identity = UUID.randomUUID(); + return identity; + } + + public UUID getIdentifierUnsafe() { + return identity; + } } diff --git a/src/main/java/vazkii/botania/common/block/tile/mana/TileTurntable.java b/src/main/java/vazkii/botania/common/block/tile/mana/TileTurntable.java index 23a0b14265..6ab7cc5a18 100644 --- a/src/main/java/vazkii/botania/common/block/tile/mana/TileTurntable.java +++ b/src/main/java/vazkii/botania/common/block/tile/mana/TileTurntable.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Mar 16, 2014, 10:15:05 PM (GMT)] */ package vazkii.botania.common.block.tile.mana; @@ -18,78 +18,71 @@ import net.minecraft.tileentity.TileEntity; import net.minecraft.util.EnumChatFormatting; import net.minecraftforge.common.util.ForgeDirection; - import org.lwjgl.opengl.GL11; - import vazkii.botania.api.internal.VanillaPacketDispatcher; import vazkii.botania.common.block.tile.TileMod; public class TileTurntable extends TileMod { - private static final String TAG_SPEED = "speed"; - private static final String TAG_BACKWARDS = "backwards"; - - int speed = 1; - boolean backwards = false; - - @Override - public void updateEntity() { - boolean redstone = false; - - for(ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS) { - int redstoneSide = worldObj.getIndirectPowerLevelTo(xCoord + dir.offsetX, yCoord + dir.offsetY, zCoord + dir.offsetZ, dir.ordinal()); - if(redstoneSide > 0) - redstone = true; - } - - if(!redstone) { - TileEntity tile = worldObj.getTileEntity(xCoord, yCoord + 1, zCoord); - if(tile instanceof TileSpreader) { - TileSpreader spreader = (TileSpreader) tile; - spreader.rotationX += speed * (backwards ? -1 : 1); - if(spreader.rotationX >= 360F) - spreader.rotationX -= 360F; - spreader.checkForReceiver(); - } - } - } - - @Override - public void writeCustomNBT(NBTTagCompound cmp) { - cmp.setInteger(TAG_SPEED, speed); - cmp.setBoolean(TAG_BACKWARDS, backwards); - } - - @Override - public void readCustomNBT(NBTTagCompound cmp) { - speed = cmp.getInteger(TAG_SPEED); - backwards = cmp.getBoolean(TAG_BACKWARDS); - } - - public void onWanded(EntityPlayer player, ItemStack wand) { - if(player == null) - return; - - if(player.isSneaking()) - backwards = !backwards; - else speed = speed == 6 ? 1 : speed + 1; - VanillaPacketDispatcher.dispatchTEToNearbyPlayers(worldObj, xCoord, yCoord, zCoord); - } - - public void renderHUD(Minecraft mc, ScaledResolution res) { - int color = 0xAA006600; - - char motion = backwards ? '<' : '>'; - String speed = EnumChatFormatting.BOLD + ""; - for(int i = 0; i < this.speed; i++) - speed = speed + motion; - - int x = res.getScaledWidth() / 2 - mc.fontRenderer.getStringWidth(speed) / 2; - int y = res.getScaledHeight() / 2 - 15; - GL11.glEnable(GL11.GL_BLEND); - GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); - mc.fontRenderer.drawStringWithShadow(speed, x, y, color); - GL11.glDisable(GL11.GL_BLEND); - } - + private static final String TAG_SPEED = "speed"; + private static final String TAG_BACKWARDS = "backwards"; + + int speed = 1; + boolean backwards = false; + + @Override + public void updateEntity() { + boolean redstone = false; + + for (ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS) { + int redstoneSide = worldObj.getIndirectPowerLevelTo( + xCoord + dir.offsetX, yCoord + dir.offsetY, zCoord + dir.offsetZ, dir.ordinal()); + if (redstoneSide > 0) redstone = true; + } + + if (!redstone) { + TileEntity tile = worldObj.getTileEntity(xCoord, yCoord + 1, zCoord); + if (tile instanceof TileSpreader) { + TileSpreader spreader = (TileSpreader) tile; + spreader.rotationX += speed * (backwards ? -1 : 1); + if (spreader.rotationX >= 360F) spreader.rotationX -= 360F; + spreader.checkForReceiver(); + } + } + } + + @Override + public void writeCustomNBT(NBTTagCompound cmp) { + cmp.setInteger(TAG_SPEED, speed); + cmp.setBoolean(TAG_BACKWARDS, backwards); + } + + @Override + public void readCustomNBT(NBTTagCompound cmp) { + speed = cmp.getInteger(TAG_SPEED); + backwards = cmp.getBoolean(TAG_BACKWARDS); + } + + public void onWanded(EntityPlayer player, ItemStack wand) { + if (player == null) return; + + if (player.isSneaking()) backwards = !backwards; + else speed = speed == 6 ? 1 : speed + 1; + VanillaPacketDispatcher.dispatchTEToNearbyPlayers(worldObj, xCoord, yCoord, zCoord); + } + + public void renderHUD(Minecraft mc, ScaledResolution res) { + int color = 0xAA006600; + + char motion = backwards ? '<' : '>'; + String speed = EnumChatFormatting.BOLD + ""; + for (int i = 0; i < this.speed; i++) speed = speed + motion; + + int x = res.getScaledWidth() / 2 - mc.fontRenderer.getStringWidth(speed) / 2; + int y = res.getScaledHeight() / 2 - 15; + GL11.glEnable(GL11.GL_BLEND); + GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); + mc.fontRenderer.drawStringWithShadow(speed, x, y, color); + GL11.glDisable(GL11.GL_BLEND); + } } diff --git a/src/main/java/vazkii/botania/common/block/tile/string/TileRedString.java b/src/main/java/vazkii/botania/common/block/tile/string/TileRedString.java index 2d386a6e1e..226ce38c96 100644 --- a/src/main/java/vazkii/botania/common/block/tile/string/TileRedString.java +++ b/src/main/java/vazkii/botania/common/block/tile/string/TileRedString.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Nov 14, 2014, 5:04:22 PM (GMT)] */ package vazkii.botania.common.block.tile.string; @@ -21,74 +21,71 @@ public abstract class TileRedString extends TileMod implements ITileBound { - private ChunkCoordinates binding; - - @Override - public void updateEntity() { - ForgeDirection dir = getOrientation(); - int x = xCoord; - int y = yCoord; - int z = zCoord; - int range = getRange(); - ChunkCoordinates currBinding = getBinding(); - setBinding(null); - - for(int i = 0; i < range; i++) { - x += dir.offsetX; - y += dir.offsetY; - z += dir.offsetZ; - if(worldObj.isAirBlock(x, y, z)) - continue; - - TileEntity tile = worldObj.getTileEntity(x, y, z); - if(tile instanceof TileRedString) - continue; - - if(acceptBlock(x, y, z)) { - setBinding(new ChunkCoordinates(x, y, z)); - if(currBinding == null || currBinding.posX != x || currBinding.posY != y || currBinding.posZ != z) - onBound(x, y, z); - break; - } - } - } - - public int getRange() { - return 8; - } - - public abstract boolean acceptBlock(int x, int y, int z); - - public void onBound(int x, int y, int z) { - // NO-OP - } - - @Override - public AxisAlignedBB getRenderBoundingBox() { - return INFINITE_EXTENT_AABB; - } - - @Override - public ChunkCoordinates getBinding() { - return binding; - } - - public void setBinding(ChunkCoordinates binding) { - this.binding = binding; - } - - public ForgeDirection getOrientation() { - return ForgeDirection.getOrientation(getBlockMetadata()); - } - - public TileEntity getTileAtBinding() { - ChunkCoordinates binding = getBinding(); - return binding == null ? null : worldObj.getTileEntity(binding.posX, binding.posY, binding.posZ); - } - - public Block getBlockAtBinding() { - ChunkCoordinates binding = getBinding(); - return binding == null ? Blocks.air : worldObj.getBlock(binding.posX, binding.posY, binding.posZ); - } - + private ChunkCoordinates binding; + + @Override + public void updateEntity() { + ForgeDirection dir = getOrientation(); + int x = xCoord; + int y = yCoord; + int z = zCoord; + int range = getRange(); + ChunkCoordinates currBinding = getBinding(); + setBinding(null); + + for (int i = 0; i < range; i++) { + x += dir.offsetX; + y += dir.offsetY; + z += dir.offsetZ; + if (worldObj.isAirBlock(x, y, z)) continue; + + TileEntity tile = worldObj.getTileEntity(x, y, z); + if (tile instanceof TileRedString) continue; + + if (acceptBlock(x, y, z)) { + setBinding(new ChunkCoordinates(x, y, z)); + if (currBinding == null || currBinding.posX != x || currBinding.posY != y || currBinding.posZ != z) + onBound(x, y, z); + break; + } + } + } + + public int getRange() { + return 8; + } + + public abstract boolean acceptBlock(int x, int y, int z); + + public void onBound(int x, int y, int z) { + // NO-OP + } + + @Override + public AxisAlignedBB getRenderBoundingBox() { + return INFINITE_EXTENT_AABB; + } + + @Override + public ChunkCoordinates getBinding() { + return binding; + } + + public void setBinding(ChunkCoordinates binding) { + this.binding = binding; + } + + public ForgeDirection getOrientation() { + return ForgeDirection.getOrientation(getBlockMetadata()); + } + + public TileEntity getTileAtBinding() { + ChunkCoordinates binding = getBinding(); + return binding == null ? null : worldObj.getTileEntity(binding.posX, binding.posY, binding.posZ); + } + + public Block getBlockAtBinding() { + ChunkCoordinates binding = getBinding(); + return binding == null ? Blocks.air : worldObj.getBlock(binding.posX, binding.posY, binding.posZ); + } } diff --git a/src/main/java/vazkii/botania/common/block/tile/string/TileRedStringComparator.java b/src/main/java/vazkii/botania/common/block/tile/string/TileRedStringComparator.java index ca519437eb..3434f9aa60 100644 --- a/src/main/java/vazkii/botania/common/block/tile/string/TileRedStringComparator.java +++ b/src/main/java/vazkii/botania/common/block/tile/string/TileRedStringComparator.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Nov 16, 2014, 10:22:01 PM (GMT)] */ package vazkii.botania.common.block.tile.string; @@ -16,34 +16,38 @@ public class TileRedStringComparator extends TileRedString { - int comparatorValue = 0; - - @Override - public void updateEntity() { - super.updateEntity(); - - ChunkCoordinates binding = getBinding(); - ForgeDirection dir = getOrientation(); - Block block = getBlockAtBinding(); - int origVal = comparatorValue; - - if(block.hasComparatorInputOverride()) { - int val = block.getComparatorInputOverride(worldObj, binding.posX, binding.posY, binding.posZ, dir.getOpposite().ordinal()); - comparatorValue = val; - } else comparatorValue = 0; - - if(origVal != comparatorValue) - worldObj.func_147453_f(xCoord, yCoord, zCoord, worldObj.getBlock(xCoord, yCoord, zCoord)); - } - - public int getComparatorValue() { - return comparatorValue; - } - - @Override - public boolean acceptBlock(int x, int y, int z) { - Block block = worldObj.getBlock(x, y, z); - return block.hasComparatorInputOverride(); - } - + int comparatorValue = 0; + + @Override + public void updateEntity() { + super.updateEntity(); + + ChunkCoordinates binding = getBinding(); + ForgeDirection dir = getOrientation(); + Block block = getBlockAtBinding(); + int origVal = comparatorValue; + + if (block.hasComparatorInputOverride()) { + int val = block.getComparatorInputOverride( + worldObj, + binding.posX, + binding.posY, + binding.posZ, + dir.getOpposite().ordinal()); + comparatorValue = val; + } else comparatorValue = 0; + + if (origVal != comparatorValue) + worldObj.func_147453_f(xCoord, yCoord, zCoord, worldObj.getBlock(xCoord, yCoord, zCoord)); + } + + public int getComparatorValue() { + return comparatorValue; + } + + @Override + public boolean acceptBlock(int x, int y, int z) { + Block block = worldObj.getBlock(x, y, z); + return block.hasComparatorInputOverride(); + } } diff --git a/src/main/java/vazkii/botania/common/block/tile/string/TileRedStringContainer.java b/src/main/java/vazkii/botania/common/block/tile/string/TileRedStringContainer.java index 6759394fb9..4066fddd29 100644 --- a/src/main/java/vazkii/botania/common/block/tile/string/TileRedStringContainer.java +++ b/src/main/java/vazkii/botania/common/block/tile/string/TileRedStringContainer.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Nov 14, 2014, 5:26:39 PM (GMT)] */ package vazkii.botania.common.block.tile.string; @@ -20,132 +20,126 @@ public class TileRedStringContainer extends TileRedString implements ISidedInventory { - @Override - public boolean acceptBlock(int x, int y, int z) { - TileEntity tile = worldObj.getTileEntity(x, y, z); - if(tile != null && tile instanceof IInventory) { - IInventory inv = (IInventory) tile; - if(inv instanceof ISidedInventory) { - ISidedInventory sidedInv = (ISidedInventory) inv; - for(int i = 0; i < 6; i++) - if(sidedInv.getAccessibleSlotsFromSide(i).length != 0) - return true; - return false; - } - - return true; - } - - return false; - } - - @Override - public int getSizeInventory() { - IInventory inv = getInventory(); - return inv != null ? inv.getSizeInventory() : 0; - } - - @Override - public ItemStack getStackInSlot(int slot) { - IInventory inv = getInventory(); - return inv != null ? inv.getStackInSlot(slot) : null; - } - - @Override - public ItemStack decrStackSize(int slot, int count) { - IInventory inv = getInventory(); - return inv != null ? inv.decrStackSize(slot, count) : null; - } - - @Override - public ItemStack getStackInSlotOnClosing(int slot) { - IInventory inv = getInventory(); - return inv != null ? inv.getStackInSlotOnClosing(slot) : null; - } - - @Override - public void setInventorySlotContents(int slot, ItemStack stack) { - IInventory inv = getInventory(); - if(inv != null) - inv.setInventorySlotContents(slot, stack); - } - - @Override - public String getInventoryName() { - IInventory inv = getInventory(); - return inv != null ? inv.getInventoryName() : LibBlockNames.RED_STRING_CONTAINER; - } - - @Override - public boolean hasCustomInventoryName() { - IInventory inv = getInventory(); - return inv != null ? inv.hasCustomInventoryName() : false; - } - - @Override - public int getInventoryStackLimit() { - IInventory inv = getInventory(); - return inv != null ? inv.getInventoryStackLimit() : 0; - } - - @Override - public boolean isUseableByPlayer(EntityPlayer player) { - IInventory inv = getInventory(); - return inv != null ? inv.isUseableByPlayer(player) : false; - } - - @Override - public void openInventory() { - IInventory inv = getInventory(); - if(inv != null) - inv.openInventory(); - } - - @Override - public void closeInventory() { - IInventory inv = getInventory(); - if(inv != null) - inv.closeInventory(); - } - - @Override - public boolean isItemValidForSlot(int slot, ItemStack stack) { - IInventory inv = getInventory(); - return inv != null ? inv.isItemValidForSlot(slot, stack) : false; - } - - @Override - public int[] getAccessibleSlotsFromSide(int side) { - IInventory inv = getInventory(); - return inv instanceof ISidedInventory ? ((ISidedInventory) inv).getAccessibleSlotsFromSide(side) : inv instanceof IInventory ? InventoryHelper.buildSlotsForLinearInventory(inv) : new int[0]; - } - - @Override - public boolean canInsertItem(int slot, ItemStack stack, int side) { - IInventory inv = getInventory(); - return inv instanceof ISidedInventory ? ((ISidedInventory) inv).canInsertItem(slot, stack, side) : true; - } - - @Override - public boolean canExtractItem(int slot, ItemStack stack, int side) { - IInventory inv = getInventory(); - return inv instanceof ISidedInventory ? ((ISidedInventory) inv).canExtractItem(slot, stack, side) : true; - } - - @Override - public void markDirty() { - super.markDirty(); - TileEntity tile = getTileAtBinding(); - if(tile != null) - tile.markDirty(); - } - - IInventory getInventory() { - TileEntity tile = getTileAtBinding(); - if(tile == null || !(tile instanceof IInventory)) - return null; - - return InventoryHelper.getInventory((IInventory) tile); - } - + @Override + public boolean acceptBlock(int x, int y, int z) { + TileEntity tile = worldObj.getTileEntity(x, y, z); + if (tile != null && tile instanceof IInventory) { + IInventory inv = (IInventory) tile; + if (inv instanceof ISidedInventory) { + ISidedInventory sidedInv = (ISidedInventory) inv; + for (int i = 0; i < 6; i++) if (sidedInv.getAccessibleSlotsFromSide(i).length != 0) return true; + return false; + } + + return true; + } + + return false; + } + + @Override + public int getSizeInventory() { + IInventory inv = getInventory(); + return inv != null ? inv.getSizeInventory() : 0; + } + + @Override + public ItemStack getStackInSlot(int slot) { + IInventory inv = getInventory(); + return inv != null ? inv.getStackInSlot(slot) : null; + } + + @Override + public ItemStack decrStackSize(int slot, int count) { + IInventory inv = getInventory(); + return inv != null ? inv.decrStackSize(slot, count) : null; + } + + @Override + public ItemStack getStackInSlotOnClosing(int slot) { + IInventory inv = getInventory(); + return inv != null ? inv.getStackInSlotOnClosing(slot) : null; + } + + @Override + public void setInventorySlotContents(int slot, ItemStack stack) { + IInventory inv = getInventory(); + if (inv != null) inv.setInventorySlotContents(slot, stack); + } + + @Override + public String getInventoryName() { + IInventory inv = getInventory(); + return inv != null ? inv.getInventoryName() : LibBlockNames.RED_STRING_CONTAINER; + } + + @Override + public boolean hasCustomInventoryName() { + IInventory inv = getInventory(); + return inv != null ? inv.hasCustomInventoryName() : false; + } + + @Override + public int getInventoryStackLimit() { + IInventory inv = getInventory(); + return inv != null ? inv.getInventoryStackLimit() : 0; + } + + @Override + public boolean isUseableByPlayer(EntityPlayer player) { + IInventory inv = getInventory(); + return inv != null ? inv.isUseableByPlayer(player) : false; + } + + @Override + public void openInventory() { + IInventory inv = getInventory(); + if (inv != null) inv.openInventory(); + } + + @Override + public void closeInventory() { + IInventory inv = getInventory(); + if (inv != null) inv.closeInventory(); + } + + @Override + public boolean isItemValidForSlot(int slot, ItemStack stack) { + IInventory inv = getInventory(); + return inv != null ? inv.isItemValidForSlot(slot, stack) : false; + } + + @Override + public int[] getAccessibleSlotsFromSide(int side) { + IInventory inv = getInventory(); + return inv instanceof ISidedInventory + ? ((ISidedInventory) inv).getAccessibleSlotsFromSide(side) + : inv instanceof IInventory ? InventoryHelper.buildSlotsForLinearInventory(inv) : new int[0]; + } + + @Override + public boolean canInsertItem(int slot, ItemStack stack, int side) { + IInventory inv = getInventory(); + return inv instanceof ISidedInventory ? ((ISidedInventory) inv).canInsertItem(slot, stack, side) : true; + } + + @Override + public boolean canExtractItem(int slot, ItemStack stack, int side) { + IInventory inv = getInventory(); + return inv instanceof ISidedInventory ? ((ISidedInventory) inv).canExtractItem(slot, stack, side) : true; + } + + @Override + public void markDirty() { + super.markDirty(); + TileEntity tile = getTileAtBinding(); + if (tile != null) tile.markDirty(); + } + + IInventory getInventory() { + TileEntity tile = getTileAtBinding(); + if (tile == null || !(tile instanceof IInventory)) return null; + + return InventoryHelper.getInventory((IInventory) tile); + } } diff --git a/src/main/java/vazkii/botania/common/block/tile/string/TileRedStringDispenser.java b/src/main/java/vazkii/botania/common/block/tile/string/TileRedStringDispenser.java index 6d1b5875df..9ec0011974 100644 --- a/src/main/java/vazkii/botania/common/block/tile/string/TileRedStringDispenser.java +++ b/src/main/java/vazkii/botania/common/block/tile/string/TileRedStringDispenser.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Nov 14, 2014, 11:00:16 PM (GMT)] */ package vazkii.botania.common.block.tile.string; @@ -16,19 +16,23 @@ public class TileRedStringDispenser extends TileRedStringContainer { - @Override - public boolean acceptBlock(int x, int y, int z) { - TileEntity tile = worldObj.getTileEntity(x, y, z); - return tile != null && tile instanceof TileEntityDispenser; - } - - public void tickDispenser() { - ChunkCoordinates bind = getBinding(); - if(bind != null) { - TileEntity tile = worldObj.getTileEntity(bind.posX, bind.posY, bind.posZ); - if(tile instanceof TileEntityDispenser) - worldObj.scheduleBlockUpdate(bind.posX, bind.posY, bind.posZ, tile.getBlockType(), tile.getBlockType().tickRate(worldObj)); - } - } + @Override + public boolean acceptBlock(int x, int y, int z) { + TileEntity tile = worldObj.getTileEntity(x, y, z); + return tile != null && tile instanceof TileEntityDispenser; + } + public void tickDispenser() { + ChunkCoordinates bind = getBinding(); + if (bind != null) { + TileEntity tile = worldObj.getTileEntity(bind.posX, bind.posY, bind.posZ); + if (tile instanceof TileEntityDispenser) + worldObj.scheduleBlockUpdate( + bind.posX, + bind.posY, + bind.posZ, + tile.getBlockType(), + tile.getBlockType().tickRate(worldObj)); + } + } } diff --git a/src/main/java/vazkii/botania/common/block/tile/string/TileRedStringFertilizer.java b/src/main/java/vazkii/botania/common/block/tile/string/TileRedStringFertilizer.java index 463a37805b..b47d9402fe 100644 --- a/src/main/java/vazkii/botania/common/block/tile/string/TileRedStringFertilizer.java +++ b/src/main/java/vazkii/botania/common/block/tile/string/TileRedStringFertilizer.java @@ -2,16 +2,15 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Nov 16, 2014, 7:17:16 PM (GMT)] */ package vazkii.botania.common.block.tile.string; import java.util.Random; - import net.minecraft.block.Block; import net.minecraft.block.IGrowable; import net.minecraft.util.ChunkCoordinates; @@ -19,29 +18,32 @@ public class TileRedStringFertilizer extends TileRedString { - public boolean func_149851_a(World p_149851_1_, boolean p_149851_5_) { - ChunkCoordinates binding = getBinding(); - Block block = getBlockAtBinding(); - - return block instanceof IGrowable ? ((IGrowable) block).func_149851_a(p_149851_1_, binding.posX, binding.posY, binding.posZ, p_149851_5_) : false; - } - - public boolean func_149852_a(World p_149852_1_, Random p_149852_2_) { - ChunkCoordinates binding = getBinding(); - Block block = getBlockAtBinding(); - return block instanceof IGrowable ? ((IGrowable) block).func_149852_a(p_149852_1_, p_149852_2_, binding.posX, binding.posY, binding.posZ) : false; - } - - public void func_149853_b(World p_149853_1_, Random p_149853_2_) { - ChunkCoordinates binding = getBinding(); - Block block = getBlockAtBinding(); - if(block instanceof IGrowable) - ((IGrowable) block).func_149853_b(p_149853_1_, p_149853_2_, binding.posX, binding.posY, binding.posZ); - } - - @Override - public boolean acceptBlock(int x, int y, int z) { - return worldObj.getBlock(x, y, z) instanceof IGrowable; - } - + public boolean func_149851_a(World p_149851_1_, boolean p_149851_5_) { + ChunkCoordinates binding = getBinding(); + Block block = getBlockAtBinding(); + + return block instanceof IGrowable + ? ((IGrowable) block).func_149851_a(p_149851_1_, binding.posX, binding.posY, binding.posZ, p_149851_5_) + : false; + } + + public boolean func_149852_a(World p_149852_1_, Random p_149852_2_) { + ChunkCoordinates binding = getBinding(); + Block block = getBlockAtBinding(); + return block instanceof IGrowable + ? ((IGrowable) block).func_149852_a(p_149852_1_, p_149852_2_, binding.posX, binding.posY, binding.posZ) + : false; + } + + public void func_149853_b(World p_149853_1_, Random p_149853_2_) { + ChunkCoordinates binding = getBinding(); + Block block = getBlockAtBinding(); + if (block instanceof IGrowable) + ((IGrowable) block).func_149853_b(p_149853_1_, p_149853_2_, binding.posX, binding.posY, binding.posZ); + } + + @Override + public boolean acceptBlock(int x, int y, int z) { + return worldObj.getBlock(x, y, z) instanceof IGrowable; + } } diff --git a/src/main/java/vazkii/botania/common/block/tile/string/TileRedStringInterceptor.java b/src/main/java/vazkii/botania/common/block/tile/string/TileRedStringInterceptor.java index 39d0c375b0..061ba7fe47 100644 --- a/src/main/java/vazkii/botania/common/block/tile/string/TileRedStringInterceptor.java +++ b/src/main/java/vazkii/botania/common/block/tile/string/TileRedStringInterceptor.java @@ -2,17 +2,16 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Sep 21, 2015, 4:58:20 PM (GMT)] */ package vazkii.botania.common.block.tile.string; import java.util.ArrayList; import java.util.List; - import net.minecraft.block.Block; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.util.ChunkCoordinates; @@ -20,59 +19,57 @@ public class TileRedStringInterceptor extends TileRedString { - public static List interceptors = new ArrayList(); + public static List interceptors = new ArrayList(); - @Override - public void updateEntity() { - super.updateEntity(); + @Override + public void updateEntity() { + super.updateEntity(); - if(!interceptors.contains(this)) - interceptors.add(this); - } + if (!interceptors.contains(this)) interceptors.add(this); + } - @Override - public boolean acceptBlock(int x, int y, int z) { - return worldObj.getTileEntity(x, y, z) != null; - } + @Override + public boolean acceptBlock(int x, int y, int z) { + return worldObj.getTileEntity(x, y, z) != null; + } - public boolean removeFromList() { - return !tileEntityInvalid && worldObj.getTileEntity(xCoord, yCoord, zCoord) == this; - } + public boolean removeFromList() { + return !tileEntityInvalid && worldObj.getTileEntity(xCoord, yCoord, zCoord) == this; + } - public static void onInteract(EntityPlayer player, World world, int x, int y, int z) { - List remove = new ArrayList(); - boolean did = false; + public static void onInteract(EntityPlayer player, World world, int x, int y, int z) { + List remove = new ArrayList(); + boolean did = false; - // CMEs are amazing - List interceptorsCopy = new ArrayList(interceptors); - - for(TileRedStringInterceptor inter : interceptorsCopy) { - if(!inter.removeFromList()) { - remove.add(inter); - continue; - } + // CMEs are amazing + List interceptorsCopy = new ArrayList(interceptors); - if(inter.worldObj == world) { - ChunkCoordinates coords = inter.getBinding(); - if(coords != null && coords.posX == x && coords.posY == y && coords.posZ == z) { - if(!world.isRemote) { - Block block = inter.getBlockType(); - int meta = inter.getBlockMetadata(); - world.setBlockMetadataWithNotify(inter.xCoord, inter.yCoord, inter.zCoord, meta | 8, 1 | 2); - world.scheduleBlockUpdate(inter.xCoord, inter.yCoord, inter.zCoord, block, block.tickRate(world)); - } + for (TileRedStringInterceptor inter : interceptorsCopy) { + if (!inter.removeFromList()) { + remove.add(inter); + continue; + } - did = true; - } - } - } + if (inter.worldObj == world) { + ChunkCoordinates coords = inter.getBinding(); + if (coords != null && coords.posX == x && coords.posY == y && coords.posZ == z) { + if (!world.isRemote) { + Block block = inter.getBlockType(); + int meta = inter.getBlockMetadata(); + world.setBlockMetadataWithNotify(inter.xCoord, inter.yCoord, inter.zCoord, meta | 8, 1 | 2); + world.scheduleBlockUpdate( + inter.xCoord, inter.yCoord, inter.zCoord, block, block.tickRate(world)); + } - interceptors.removeAll(remove); - if(did) { - if(world.isRemote) - player.swingItem(); - else world.playSoundEffect(x + 0.5, y + 0.5, z + 0.5, "random.click", 0.3F, 0.6F); - } - } + did = true; + } + } + } + interceptors.removeAll(remove); + if (did) { + if (world.isRemote) player.swingItem(); + else world.playSoundEffect(x + 0.5, y + 0.5, z + 0.5, "random.click", 0.3F, 0.6F); + } + } } diff --git a/src/main/java/vazkii/botania/common/block/tile/string/TileRedStringRelay.java b/src/main/java/vazkii/botania/common/block/tile/string/TileRedStringRelay.java index 825deabf7d..56b498cf57 100644 --- a/src/main/java/vazkii/botania/common/block/tile/string/TileRedStringRelay.java +++ b/src/main/java/vazkii/botania/common/block/tile/string/TileRedStringRelay.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Nov 16, 2014, 10:52:21 PM (GMT)] */ package vazkii.botania.common.block.tile.string; @@ -19,14 +19,13 @@ public class TileRedStringRelay extends TileRedString { - @Override - public boolean acceptBlock(int x, int y, int z) { - if(x == xCoord && y == yCoord + 1 && z == zCoord) - return false; - - Block block = worldObj.getBlock(x, y, z); - TileEntity tile = worldObj.getTileEntity(x, y, z); - return (block instanceof BlockFlower || block instanceof BlockMushroom || block instanceof BlockDoublePlant) && (tile == null || !(tile instanceof ISubTileContainer)); - } + @Override + public boolean acceptBlock(int x, int y, int z) { + if (x == xCoord && y == yCoord + 1 && z == zCoord) return false; + Block block = worldObj.getBlock(x, y, z); + TileEntity tile = worldObj.getTileEntity(x, y, z); + return (block instanceof BlockFlower || block instanceof BlockMushroom || block instanceof BlockDoublePlant) + && (tile == null || !(tile instanceof ISubTileContainer)); + } } diff --git a/src/main/java/vazkii/botania/common/brew/BrewMod.java b/src/main/java/vazkii/botania/common/brew/BrewMod.java index 765c957c1b..d257fc7485 100644 --- a/src/main/java/vazkii/botania/common/brew/BrewMod.java +++ b/src/main/java/vazkii/botania/common/brew/BrewMod.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Nov 1, 2014, 7:02:29 PM (GMT)] */ package vazkii.botania.common.brew; @@ -16,14 +16,13 @@ public class BrewMod extends Brew { - public BrewMod(String key, int color, int cost, PotionEffect... effects) { - super(key, key, color, cost, effects); - BotaniaAPI.registerBrew(this); - } - - @Override - public String getUnlocalizedName() { - return "botania.brew." + super.getUnlocalizedName(); - } + public BrewMod(String key, int color, int cost, PotionEffect... effects) { + super(key, key, color, cost, effects); + BotaniaAPI.registerBrew(this); + } + @Override + public String getUnlocalizedName() { + return "botania.brew." + super.getUnlocalizedName(); + } } diff --git a/src/main/java/vazkii/botania/common/brew/BrewModPotion.java b/src/main/java/vazkii/botania/common/brew/BrewModPotion.java index 3ec9f03bf6..fc7c6e9e21 100644 --- a/src/main/java/vazkii/botania/common/brew/BrewModPotion.java +++ b/src/main/java/vazkii/botania/common/brew/BrewModPotion.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Nov 2, 2014, 10:37:12 PM (GMT)] */ package vazkii.botania.common.brew; @@ -15,8 +15,7 @@ public class BrewModPotion extends BrewMod { - public BrewModPotion(String key, int cost, PotionEffect... effects) { - super(key, Potion.potionTypes[effects[0].getPotionID()].getLiquidColor(), cost, effects); - } - + public BrewModPotion(String key, int cost, PotionEffect... effects) { + super(key, Potion.potionTypes[effects[0].getPotionID()].getLiquidColor(), cost, effects); + } } diff --git a/src/main/java/vazkii/botania/common/brew/ModBrews.java b/src/main/java/vazkii/botania/common/brew/ModBrews.java index b30edbfc6b..5f7d7e3787 100644 --- a/src/main/java/vazkii/botania/common/brew/ModBrews.java +++ b/src/main/java/vazkii/botania/common/brew/ModBrews.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Nov 1, 2014, 7:00:33 PM (GMT)] */ package vazkii.botania.common.brew; @@ -17,63 +17,85 @@ public class ModBrews { - public static Brew speed; - public static Brew strength; - public static Brew haste; - public static Brew healing; - public static Brew jumpBoost; - public static Brew regen; - public static Brew regenWeak; - public static Brew resistance; - public static Brew fireResistance; - public static Brew waterBreathing; - public static Brew invisibility; - public static Brew nightVision; - public static Brew absorption; + public static Brew speed; + public static Brew strength; + public static Brew haste; + public static Brew healing; + public static Brew jumpBoost; + public static Brew regen; + public static Brew regenWeak; + public static Brew resistance; + public static Brew fireResistance; + public static Brew waterBreathing; + public static Brew invisibility; + public static Brew nightVision; + public static Brew absorption; - public static Brew allure; - public static Brew soulCross; - public static Brew featherfeet; - public static Brew emptiness; - public static Brew bloodthirst; - public static Brew overload; - public static Brew clear; + public static Brew allure; + public static Brew soulCross; + public static Brew featherfeet; + public static Brew emptiness; + public static Brew bloodthirst; + public static Brew overload; + public static Brew clear; - public static Brew warpWard; + public static Brew warpWard; - public static void init() { - speed = new BrewMod(LibBrewNames.SPEED, 0x59B7FF, 4000, new PotionEffect(Potion.moveSpeed.id, 1800, 1)); - strength = new BrewMod(LibBrewNames.STRENGTH, 0xEE3F3F, 4000, new PotionEffect(Potion.damageBoost.id, 1800, 1)); - haste = new BrewMod(LibBrewNames.HASTE, 0xF4A432, 4000, new PotionEffect(Potion.digSpeed.id, 1800, 1)); - healing = new BrewMod(LibBrewNames.HEALING, 0xFF5ECC, 6000, new PotionEffect(Potion.heal.id, 1, 1)); - jumpBoost = new BrewMod(LibBrewNames.JUMP_BOOST, 0x32F46D, 4000, new PotionEffect(Potion.jump.id, 1800, 1)); - regen = new BrewMod(LibBrewNames.REGEN, 0xFD6488, 7000, new PotionEffect(Potion.regeneration.id, 500, 1)); - regenWeak = new BrewMod(LibBrewNames.REGEN_WEAK, 0xFD6488, 9000, new PotionEffect(Potion.regeneration.id, 2400, 0)); - resistance = new BrewMod(LibBrewNames.RESISTANCE, 0xB44E17, 4000, new PotionEffect(Potion.resistance.id, 1800, 1)); - fireResistance = new BrewMod(LibBrewNames.FIRE_RESISTANCE, 0xF86900, 4000, new PotionEffect(Potion.fireResistance.id, 9600, 0)); - waterBreathing = new BrewMod(LibBrewNames.WATER_BREATHING, 0x84A7CF, 4000, new PotionEffect(Potion.waterBreathing.id, 9600, 0)); - invisibility = new BrewMod(LibBrewNames.INVISIBILITY, 0xAEAEAE, 8000, new PotionEffect(Potion.invisibility.id, 9600, 0)); - nightVision = new BrewMod(LibBrewNames.NIGHT_VISION, 0x7C4BEB, 4000, new PotionEffect(Potion.nightVision.id, 9600, 0)); - absorption = new BrewMod(LibBrewNames.ABSORPTION, 0xF2EB23, 7000, new PotionEffect(Potion.field_76444_x.id, 1800, 3)).setNotBloodPendantInfusable().setNotIncenseInfusable(); + public static void init() { + speed = new BrewMod(LibBrewNames.SPEED, 0x59B7FF, 4000, new PotionEffect(Potion.moveSpeed.id, 1800, 1)); + strength = new BrewMod(LibBrewNames.STRENGTH, 0xEE3F3F, 4000, new PotionEffect(Potion.damageBoost.id, 1800, 1)); + haste = new BrewMod(LibBrewNames.HASTE, 0xF4A432, 4000, new PotionEffect(Potion.digSpeed.id, 1800, 1)); + healing = new BrewMod(LibBrewNames.HEALING, 0xFF5ECC, 6000, new PotionEffect(Potion.heal.id, 1, 1)); + jumpBoost = new BrewMod(LibBrewNames.JUMP_BOOST, 0x32F46D, 4000, new PotionEffect(Potion.jump.id, 1800, 1)); + regen = new BrewMod(LibBrewNames.REGEN, 0xFD6488, 7000, new PotionEffect(Potion.regeneration.id, 500, 1)); + regenWeak = + new BrewMod(LibBrewNames.REGEN_WEAK, 0xFD6488, 9000, new PotionEffect(Potion.regeneration.id, 2400, 0)); + resistance = + new BrewMod(LibBrewNames.RESISTANCE, 0xB44E17, 4000, new PotionEffect(Potion.resistance.id, 1800, 1)); + fireResistance = new BrewMod( + LibBrewNames.FIRE_RESISTANCE, 0xF86900, 4000, new PotionEffect(Potion.fireResistance.id, 9600, 0)); + waterBreathing = new BrewMod( + LibBrewNames.WATER_BREATHING, 0x84A7CF, 4000, new PotionEffect(Potion.waterBreathing.id, 9600, 0)); + invisibility = new BrewMod( + LibBrewNames.INVISIBILITY, 0xAEAEAE, 8000, new PotionEffect(Potion.invisibility.id, 9600, 0)); + nightVision = new BrewMod( + LibBrewNames.NIGHT_VISION, 0x7C4BEB, 4000, new PotionEffect(Potion.nightVision.id, 9600, 0)); + absorption = new BrewMod( + LibBrewNames.ABSORPTION, 0xF2EB23, 7000, new PotionEffect(Potion.field_76444_x.id, 1800, 3)) + .setNotBloodPendantInfusable() + .setNotIncenseInfusable(); - overload = new BrewMod(LibBrewNames.OVERLOAD, 0x232323, 12000, new PotionEffect(Potion.damageBoost.id, 1800, 3), new PotionEffect(Potion.moveSpeed.id, 1800, 2), new PotionEffect(Potion.weakness.id, 3600, 2), new PotionEffect(Potion.hunger.id, 200, 2)); - soulCross = new BrewModPotion(LibBrewNames.SOUL_CROSS, 10000, new PotionEffect(ModPotions.soulCross.id, 1800, 0)); - featherfeet = new BrewModPotion(LibBrewNames.FEATHER_FEET, 7000, new PotionEffect(ModPotions.featherfeet.id, 1800, 0)); - emptiness = new BrewModPotion(LibBrewNames.EMPTINESS, 30000, new PotionEffect(ModPotions.emptiness.id, 7200, 0)); - bloodthirst = new BrewModPotion(LibBrewNames.BLOODTHIRST, 20000, new PotionEffect(ModPotions.bloodthrst.id, 7200, 0)); - allure = new BrewModPotion(LibBrewNames.ALLURE, 2000, new PotionEffect(ModPotions.allure.id, 4800, 0)); - clear = new BrewModPotion(LibBrewNames.CLEAR, 4000, new PotionEffect(ModPotions.clear.id, 0, 0)); - } + overload = new BrewMod( + LibBrewNames.OVERLOAD, + 0x232323, + 12000, + new PotionEffect(Potion.damageBoost.id, 1800, 3), + new PotionEffect(Potion.moveSpeed.id, 1800, 2), + new PotionEffect(Potion.weakness.id, 3600, 2), + new PotionEffect(Potion.hunger.id, 200, 2)); + soulCross = + new BrewModPotion(LibBrewNames.SOUL_CROSS, 10000, new PotionEffect(ModPotions.soulCross.id, 1800, 0)); + featherfeet = new BrewModPotion( + LibBrewNames.FEATHER_FEET, 7000, new PotionEffect(ModPotions.featherfeet.id, 1800, 0)); + emptiness = + new BrewModPotion(LibBrewNames.EMPTINESS, 30000, new PotionEffect(ModPotions.emptiness.id, 7200, 0)); + bloodthirst = + new BrewModPotion(LibBrewNames.BLOODTHIRST, 20000, new PotionEffect(ModPotions.bloodthrst.id, 7200, 0)); + allure = new BrewModPotion(LibBrewNames.ALLURE, 2000, new PotionEffect(ModPotions.allure.id, 4800, 0)); + clear = new BrewModPotion(LibBrewNames.CLEAR, 4000, new PotionEffect(ModPotions.clear.id, 0, 0)); + } - public static void initTC() { - Potion warpWardPotion = null; - for(Potion potion : Potion.potionTypes) - if(potion != null && potion.getName().equals("potion.warpward")) { - warpWardPotion = potion; - break; - } + public static void initTC() { + Potion warpWardPotion = null; + for (Potion potion : Potion.potionTypes) + if (potion != null && potion.getName().equals("potion.warpward")) { + warpWardPotion = potion; + break; + } - if(warpWardPotion != null) - warpWard = new BrewMod(LibBrewNames.WARP_WARD, 0xFBBDFF, 25000, new PotionEffect(warpWardPotion.id, 12000, 0)).setNotBloodPendantInfusable(); - } + if (warpWardPotion != null) + warpWard = new BrewMod( + LibBrewNames.WARP_WARD, 0xFBBDFF, 25000, new PotionEffect(warpWardPotion.id, 12000, 0)) + .setNotBloodPendantInfusable(); + } } diff --git a/src/main/java/vazkii/botania/common/brew/ModPotions.java b/src/main/java/vazkii/botania/common/brew/ModPotions.java index f6cbffe312..d66fef8a18 100644 --- a/src/main/java/vazkii/botania/common/brew/ModPotions.java +++ b/src/main/java/vazkii/botania/common/brew/ModPotions.java @@ -2,17 +2,16 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Nov 1, 2014, 7:00:29 PM (GMT)] */ package vazkii.botania.common.brew; import java.lang.reflect.Field; import java.lang.reflect.Modifier; - import net.minecraft.potion.Potion; import vazkii.botania.common.brew.potion.PotionAllure; import vazkii.botania.common.brew.potion.PotionBloodthirst; @@ -23,46 +22,44 @@ public class ModPotions { - public static Potion soulCross; - public static Potion featherfeet; - public static Potion emptiness; - public static Potion bloodthrst; - public static Potion allure; - public static Potion clear; - - public static void init() { - if(Potion.potionTypes.length < 256) - extendPotionArray(); + public static Potion soulCross; + public static Potion featherfeet; + public static Potion emptiness; + public static Potion bloodthrst; + public static Potion allure; + public static Potion clear; - soulCross = new PotionSoulCross(); - featherfeet = new PotionFeatherfeet(); - emptiness = new PotionEmptiness(); - bloodthrst = new PotionBloodthirst(); - allure = new PotionAllure(); - clear = new PotionClear(); - } + public static void init() { + if (Potion.potionTypes.length < 256) extendPotionArray(); - private static void extendPotionArray() { - Potion[] potionTypes = null; + soulCross = new PotionSoulCross(); + featherfeet = new PotionFeatherfeet(); + emptiness = new PotionEmptiness(); + bloodthrst = new PotionBloodthirst(); + allure = new PotionAllure(); + clear = new PotionClear(); + } - for (Field f : Potion.class.getDeclaredFields()) { - f.setAccessible(true); - try { - if (f.getName().equals("potionTypes") || f.getName().equals("field_76425_a")) { - Field modfield = Field.class.getDeclaredField("modifiers"); - modfield.setAccessible(true); - modfield.setInt(f, f.getModifiers() & ~Modifier.FINAL); + private static void extendPotionArray() { + Potion[] potionTypes = null; - potionTypes = (Potion[])f.get(null); - final Potion[] newPotionTypes = new Potion[256]; - System.arraycopy(potionTypes, 0, newPotionTypes, 0, potionTypes.length); - f.set(null, newPotionTypes); - } - } catch (Exception e) { - System.err.println("Severe error, please report this to the mod author:"); - System.err.println(e); - } - } - } + for (Field f : Potion.class.getDeclaredFields()) { + f.setAccessible(true); + try { + if (f.getName().equals("potionTypes") || f.getName().equals("field_76425_a")) { + Field modfield = Field.class.getDeclaredField("modifiers"); + modfield.setAccessible(true); + modfield.setInt(f, f.getModifiers() & ~Modifier.FINAL); + potionTypes = (Potion[]) f.get(null); + final Potion[] newPotionTypes = new Potion[256]; + System.arraycopy(potionTypes, 0, newPotionTypes, 0, potionTypes.length); + f.set(null, newPotionTypes); + } + } catch (Exception e) { + System.err.println("Severe error, please report this to the mod author:"); + System.err.println(e); + } + } + } } diff --git a/src/main/java/vazkii/botania/common/brew/potion/PotionAllure.java b/src/main/java/vazkii/botania/common/brew/potion/PotionAllure.java index 4f856911e6..e1c59b0152 100644 --- a/src/main/java/vazkii/botania/common/brew/potion/PotionAllure.java +++ b/src/main/java/vazkii/botania/common/brew/potion/PotionAllure.java @@ -2,14 +2,15 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Nov 3, 2014, 12:15:09 AM (GMT)] */ package vazkii.botania.common.brew.potion; +import cpw.mods.fml.common.eventhandler.SubscribeEvent; import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.projectile.EntityFishHook; @@ -17,23 +18,20 @@ import net.minecraftforge.event.entity.living.LivingEvent.LivingUpdateEvent; import vazkii.botania.common.core.handler.ConfigHandler; import vazkii.botania.common.lib.LibPotionNames; -import cpw.mods.fml.common.eventhandler.SubscribeEvent; public class PotionAllure extends PotionMod { - public PotionAllure() { - super(ConfigHandler.potionIDAllure, LibPotionNames.ALLURE, false, 0x0034E4, 5); - MinecraftForge.EVENT_BUS.register(this); - } - - @SubscribeEvent - public void onEntityUpdate(LivingUpdateEvent event) { - EntityLivingBase e = event.entityLiving; - if(e instanceof EntityPlayer && hasEffect(e)) { - EntityFishHook hook = ((EntityPlayer) e).fishEntity; - if(hook != null) - hook.onUpdate(); - } - } + public PotionAllure() { + super(ConfigHandler.potionIDAllure, LibPotionNames.ALLURE, false, 0x0034E4, 5); + MinecraftForge.EVENT_BUS.register(this); + } + @SubscribeEvent + public void onEntityUpdate(LivingUpdateEvent event) { + EntityLivingBase e = event.entityLiving; + if (e instanceof EntityPlayer && hasEffect(e)) { + EntityFishHook hook = ((EntityPlayer) e).fishEntity; + if (hook != null) hook.onUpdate(); + } + } } diff --git a/src/main/java/vazkii/botania/common/brew/potion/PotionBloodthirst.java b/src/main/java/vazkii/botania/common/brew/potion/PotionBloodthirst.java index 44eadad2b9..d71167f582 100644 --- a/src/main/java/vazkii/botania/common/brew/potion/PotionBloodthirst.java +++ b/src/main/java/vazkii/botania/common/brew/potion/PotionBloodthirst.java @@ -2,16 +2,17 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Nov 3, 2014, 12:13:09 AM (GMT)] */ package vazkii.botania.common.brew.potion; +import cpw.mods.fml.common.eventhandler.Event.Result; +import cpw.mods.fml.common.eventhandler.SubscribeEvent; import java.util.List; - import net.minecraft.entity.monster.IMob; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.util.AxisAlignedBB; @@ -20,28 +21,33 @@ import vazkii.botania.common.brew.ModPotions; import vazkii.botania.common.core.handler.ConfigHandler; import vazkii.botania.common.lib.LibPotionNames; -import cpw.mods.fml.common.eventhandler.Event.Result; -import cpw.mods.fml.common.eventhandler.SubscribeEvent; public class PotionBloodthirst extends PotionMod { - private static final int RANGE = 64; - - public PotionBloodthirst() { - super(ConfigHandler.potionIDBloodthirst, LibPotionNames.BLOODTHIRST, false, 0xC30000, 3); - MinecraftForge.EVENT_BUS.register(this); - } + private static final int RANGE = 64; - @SubscribeEvent - public void onSpawn(LivingSpawnEvent.CheckSpawn event) { - if(event.getResult() != Result.ALLOW && event.entityLiving instanceof IMob) { - List players = event.world.getEntitiesWithinAABB(EntityPlayer.class, AxisAlignedBB.getBoundingBox(event.x - RANGE, event.y - RANGE, event.z - RANGE, event.x + RANGE, event.y + RANGE, event.z + RANGE)); - for(EntityPlayer player : players) - if(hasEffect(player) && !hasEffect(player, ModPotions.emptiness)) { - event.setResult(Result.ALLOW); - return; - } - } - } + public PotionBloodthirst() { + super(ConfigHandler.potionIDBloodthirst, LibPotionNames.BLOODTHIRST, false, 0xC30000, 3); + MinecraftForge.EVENT_BUS.register(this); + } + @SubscribeEvent + public void onSpawn(LivingSpawnEvent.CheckSpawn event) { + if (event.getResult() != Result.ALLOW && event.entityLiving instanceof IMob) { + List players = event.world.getEntitiesWithinAABB( + EntityPlayer.class, + AxisAlignedBB.getBoundingBox( + event.x - RANGE, + event.y - RANGE, + event.z - RANGE, + event.x + RANGE, + event.y + RANGE, + event.z + RANGE)); + for (EntityPlayer player : players) + if (hasEffect(player) && !hasEffect(player, ModPotions.emptiness)) { + event.setResult(Result.ALLOW); + return; + } + } + } } diff --git a/src/main/java/vazkii/botania/common/brew/potion/PotionClear.java b/src/main/java/vazkii/botania/common/brew/potion/PotionClear.java index 26e76aa3fb..3c9198a04d 100644 --- a/src/main/java/vazkii/botania/common/brew/potion/PotionClear.java +++ b/src/main/java/vazkii/botania/common/brew/potion/PotionClear.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jul 25, 2015, 6:08:52 PM (GMT)] */ package vazkii.botania.common.brew.potion; @@ -18,18 +18,17 @@ public class PotionClear extends PotionMod { - public PotionClear() { - super(ConfigHandler.potionIDClear, LibPotionNames.CLEAR, false, 0xFFFFFF, 0); - } + public PotionClear() { + super(ConfigHandler.potionIDClear, LibPotionNames.CLEAR, false, 0xFFFFFF, 0); + } - @Override - public boolean isInstant() { - return true; - } - - @Override - public void affectEntity(EntityLivingBase e, EntityLivingBase e1, int t, double d) { - e1.curePotionEffects(new ItemStack(Items.milk_bucket)); - } + @Override + public boolean isInstant() { + return true; + } + @Override + public void affectEntity(EntityLivingBase e, EntityLivingBase e1, int t, double d) { + e1.curePotionEffects(new ItemStack(Items.milk_bucket)); + } } diff --git a/src/main/java/vazkii/botania/common/brew/potion/PotionEmptiness.java b/src/main/java/vazkii/botania/common/brew/potion/PotionEmptiness.java index 6d2b77ea0c..95541fd074 100644 --- a/src/main/java/vazkii/botania/common/brew/potion/PotionEmptiness.java +++ b/src/main/java/vazkii/botania/common/brew/potion/PotionEmptiness.java @@ -2,16 +2,17 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Nov 3, 2014, 12:12:36 AM (GMT)] */ package vazkii.botania.common.brew.potion; +import cpw.mods.fml.common.eventhandler.Event.Result; +import cpw.mods.fml.common.eventhandler.SubscribeEvent; import java.util.List; - import net.minecraft.entity.monster.IMob; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.util.AxisAlignedBB; @@ -19,28 +20,33 @@ import net.minecraftforge.event.entity.living.LivingSpawnEvent; import vazkii.botania.common.core.handler.ConfigHandler; import vazkii.botania.common.lib.LibPotionNames; -import cpw.mods.fml.common.eventhandler.Event.Result; -import cpw.mods.fml.common.eventhandler.SubscribeEvent; public class PotionEmptiness extends PotionMod { - private static final int RANGE = 128; - - public PotionEmptiness() { - super(ConfigHandler.potionIDEmptiness, LibPotionNames.EMPTINESS, false, 0xFACFFF, 2); - MinecraftForge.EVENT_BUS.register(this); - } + private static final int RANGE = 128; - @SubscribeEvent - public void onSpawn(LivingSpawnEvent.CheckSpawn event) { - if(event.getResult() != Result.ALLOW && event.entityLiving instanceof IMob) { - List players = event.world.getEntitiesWithinAABB(EntityPlayer.class, AxisAlignedBB.getBoundingBox(event.x - RANGE, event.y - RANGE, event.z - RANGE, event.x + RANGE, event.y + RANGE, event.z + RANGE)); - for(EntityPlayer player : players) - if(hasEffect(player)) { - event.setResult(Result.DENY); - return; - } - } - } + public PotionEmptiness() { + super(ConfigHandler.potionIDEmptiness, LibPotionNames.EMPTINESS, false, 0xFACFFF, 2); + MinecraftForge.EVENT_BUS.register(this); + } + @SubscribeEvent + public void onSpawn(LivingSpawnEvent.CheckSpawn event) { + if (event.getResult() != Result.ALLOW && event.entityLiving instanceof IMob) { + List players = event.world.getEntitiesWithinAABB( + EntityPlayer.class, + AxisAlignedBB.getBoundingBox( + event.x - RANGE, + event.y - RANGE, + event.z - RANGE, + event.x + RANGE, + event.y + RANGE, + event.z + RANGE)); + for (EntityPlayer player : players) + if (hasEffect(player)) { + event.setResult(Result.DENY); + return; + } + } + } } diff --git a/src/main/java/vazkii/botania/common/brew/potion/PotionFeatherfeet.java b/src/main/java/vazkii/botania/common/brew/potion/PotionFeatherfeet.java index 0a3fff1248..098c4f13af 100644 --- a/src/main/java/vazkii/botania/common/brew/potion/PotionFeatherfeet.java +++ b/src/main/java/vazkii/botania/common/brew/potion/PotionFeatherfeet.java @@ -2,33 +2,31 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Nov 3, 2014, 12:12:04 AM (GMT)] */ package vazkii.botania.common.brew.potion; +import cpw.mods.fml.common.eventhandler.SubscribeEvent; import net.minecraft.entity.EntityLivingBase; import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.event.entity.living.LivingEvent.LivingUpdateEvent; import vazkii.botania.common.core.handler.ConfigHandler; import vazkii.botania.common.lib.LibPotionNames; -import cpw.mods.fml.common.eventhandler.SubscribeEvent; public class PotionFeatherfeet extends PotionMod { - public PotionFeatherfeet() { - super(ConfigHandler.potionIDFeatherfeet, LibPotionNames.FEATHER_FEET, false, 0x26ADFF, 1); - MinecraftForge.EVENT_BUS.register(this); - } - - @SubscribeEvent - public void onEntityUpdate(LivingUpdateEvent event) { - EntityLivingBase e = event.entityLiving; - if(hasEffect(e)) - e.fallDistance = 2.5F; - } + public PotionFeatherfeet() { + super(ConfigHandler.potionIDFeatherfeet, LibPotionNames.FEATHER_FEET, false, 0x26ADFF, 1); + MinecraftForge.EVENT_BUS.register(this); + } + @SubscribeEvent + public void onEntityUpdate(LivingUpdateEvent event) { + EntityLivingBase e = event.entityLiving; + if (hasEffect(e)) e.fallDistance = 2.5F; + } } diff --git a/src/main/java/vazkii/botania/common/brew/potion/PotionMod.java b/src/main/java/vazkii/botania/common/brew/potion/PotionMod.java index 1cf8dcfe2f..90457010d0 100644 --- a/src/main/java/vazkii/botania/common/brew/potion/PotionMod.java +++ b/src/main/java/vazkii/botania/common/brew/potion/PotionMod.java @@ -2,46 +2,45 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Nov 2, 2014, 10:12:45 PM (GMT)] */ package vazkii.botania.common.brew.potion; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; import net.minecraft.client.Minecraft; import net.minecraft.entity.EntityLivingBase; import net.minecraft.potion.Potion; import net.minecraft.util.ResourceLocation; import vazkii.botania.client.lib.LibResources; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; public class PotionMod extends Potion { - private static final ResourceLocation resource = new ResourceLocation(LibResources.GUI_POTIONS); - - public PotionMod(int id, String name, boolean badEffect, int color, int iconIndex) { - super(id, badEffect, color); - setPotionName("botania.potion." + name); - setIconIndex(iconIndex % 8, iconIndex / 8); - } + private static final ResourceLocation resource = new ResourceLocation(LibResources.GUI_POTIONS); - @Override - @SideOnly(Side.CLIENT) - public int getStatusIconIndex() { - Minecraft.getMinecraft().renderEngine.bindTexture(resource); + public PotionMod(int id, String name, boolean badEffect, int color, int iconIndex) { + super(id, badEffect, color); + setPotionName("botania.potion." + name); + setIconIndex(iconIndex % 8, iconIndex / 8); + } - return super.getStatusIconIndex(); - } + @Override + @SideOnly(Side.CLIENT) + public int getStatusIconIndex() { + Minecraft.getMinecraft().renderEngine.bindTexture(resource); - public boolean hasEffect(EntityLivingBase entity) { - return hasEffect(entity, this); - } + return super.getStatusIconIndex(); + } - public boolean hasEffect(EntityLivingBase entity, Potion potion) { - return entity.getActivePotionEffect(potion) != null; - } + public boolean hasEffect(EntityLivingBase entity) { + return hasEffect(entity, this); + } + public boolean hasEffect(EntityLivingBase entity, Potion potion) { + return entity.getActivePotionEffect(potion) != null; + } } diff --git a/src/main/java/vazkii/botania/common/brew/potion/PotionSoulCross.java b/src/main/java/vazkii/botania/common/brew/potion/PotionSoulCross.java index 8498a68001..b1e8fac734 100644 --- a/src/main/java/vazkii/botania/common/brew/potion/PotionSoulCross.java +++ b/src/main/java/vazkii/botania/common/brew/potion/PotionSoulCross.java @@ -2,37 +2,35 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Nov 2, 2014, 10:31:48 PM (GMT)] */ package vazkii.botania.common.brew.potion; +import cpw.mods.fml.common.eventhandler.SubscribeEvent; import net.minecraft.entity.Entity; import net.minecraft.entity.EntityLivingBase; import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.event.entity.living.LivingDeathEvent; import vazkii.botania.common.core.handler.ConfigHandler; import vazkii.botania.common.lib.LibPotionNames; -import cpw.mods.fml.common.eventhandler.SubscribeEvent; public class PotionSoulCross extends PotionMod { - public PotionSoulCross() { - super(ConfigHandler.potionIDSoulCross, LibPotionNames.SOUL_CROSS, false, 0x47453d, 0); - MinecraftForge.EVENT_BUS.register(this); - } - - @SubscribeEvent - public void onEntityKill(LivingDeathEvent event) { - Entity e = event.source.getEntity(); - if(e != null && e instanceof EntityLivingBase) { - EntityLivingBase living = (EntityLivingBase) e; - if(hasEffect(living)) - living.heal(event.entityLiving.getMaxHealth() / 20); - } - } + public PotionSoulCross() { + super(ConfigHandler.potionIDSoulCross, LibPotionNames.SOUL_CROSS, false, 0x47453d, 0); + MinecraftForge.EVENT_BUS.register(this); + } + @SubscribeEvent + public void onEntityKill(LivingDeathEvent event) { + Entity e = event.source.getEntity(); + if (e != null && e instanceof EntityLivingBase) { + EntityLivingBase living = (EntityLivingBase) e; + if (hasEffect(living)) living.heal(event.entityLiving.getMaxHealth() / 20); + } + } } diff --git a/src/main/java/vazkii/botania/common/core/BotaniaCreativeTab.java b/src/main/java/vazkii/botania/common/core/BotaniaCreativeTab.java index 7e7bdfee77..1830125278 100644 --- a/src/main/java/vazkii/botania/common/core/BotaniaCreativeTab.java +++ b/src/main/java/vazkii/botania/common/core/BotaniaCreativeTab.java @@ -2,16 +2,15 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jan 14, 2014, 5:20:53 PM (GMT)] */ package vazkii.botania.common.core; import java.util.List; - import net.minecraft.block.Block; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.init.Blocks; @@ -27,403 +26,392 @@ public final class BotaniaCreativeTab extends CreativeTabs { - public static BotaniaCreativeTab INSTANCE = new BotaniaCreativeTab(); - List list; - - public BotaniaCreativeTab() { - super(LibMisc.MOD_ID); - setNoTitle(); - setBackgroundImageName(LibResources.GUI_CREATIVE); - } - - @Override - public ItemStack getIconItemStack() { - return new ItemStack(ModItems.lexicon); - } - - @Override - public Item getTabIconItem() { - return getIconItemStack().getItem(); - } - - @Override - public boolean hasSearchBar() { - return true; - } - - @Override - public void displayAllReleventItems(List list) { - this.list = list; - - addItem(ModItems.lexicon); - - addBlock(ModBlocks.flower); - addBlock(ModBlocks.specialFlower); - addItem(ModItems.petal); - addItem(ModItems.pestleAndMortar); - addItem(ModItems.dye); - addItem(ModItems.fertilizer); - addItem(ModItems.flowerBag); - addItem(ModItems.blackLotus); - addItem(ModItems.twigWand); - addItem(ModItems.obedienceStick); - addItem(ModItems.manaResource); - addBlock(ModBlocks.storage); - addItem(ModItems.manaCookie); - addItem(ModItems.rune); - - addBlock(ModBlocks.avatar); - addItem(ModItems.dirtRod); - addItem(ModItems.skyDirtRod); - addItem(ModItems.cobbleRod); - addItem(ModItems.terraformRod); - addItem(ModItems.laputaShard); - addItem(ModItems.grassHorn); - addItem(ModItems.waterRod); - addItem(ModItems.openBucket); - addItem(ModItems.rainbowRod); - addBlock(ModBlocks.bifrostPerm); - addBlock(ModFluffBlocks.bifrostPane); - addBlock(ModBlocks.shimmerrock); - addBlock(ModBlocks.shimmerwoodPlanks); - addItem(ModItems.tornadoRod); - addItem(ModItems.fireRod); - addItem(ModItems.smeltRod); - addItem(ModItems.exchangeRod); - addItem(ModItems.diviningRod); - addItem(ModItems.gravityRod); - addItem(ModItems.missileRod); - addItem(ModItems.virus); - addItem(ModItems.slingshot); - addItem(ModItems.vineBall); - addItem(ModItems.regenIvy); - addItem(ModItems.keepIvy); - addItem(ModItems.worldSeed); - addItem(ModItems.overgrowthSeed); - addBlock(ModBlocks.enchantedSoil); - addItem(ModItems.grassSeeds); - addBlock(ModBlocks.altGrass); - if(Botania.thaumcraftLoaded) - addItem(ModItems.manaInkwell); - addBlock(ModBlocks.forestDrum); - addBlock(ModBlocks.forestEye); - addBlock(ModBlocks.enderEye); - addItem(ModItems.enderHand); - addItem(ModItems.spellCloth); - addItem(ModItems.craftingHalo); - addItem(ModItems.autocraftingHalo); - addItem(ModItems.spawnerMover); - addBlock(ModBlocks.spawnerClaw); - addBlock(ModBlocks.cocoon); - addBlock(ModBlocks.teruTeruBozu); - addItem(ModItems.slimeBottle); - addItem(ModItems.sextant); - addItem(ModItems.blackHoleTalisman); - - if(Botania.gardenOfGlassLoaded) { - addBlock(ModBlocks.root); - addItem(ModItems.waterBowl); - } - - addBlock(ModBlocks.livingrock); - addBlock(ModBlocks.livingwood); - addBlock(ModBlocks.openCrate); - addItem(ModItems.craftPattern); - addBlock(ModBlocks.platform); - addBlock(ModBlocks.alfPortal); - addBlock(ModBlocks.altar); - addBlock(ModBlocks.runeAltar); - addBlock(ModBlocks.terraPlate); - addBlock(ModBlocks.brewery); - addItem(ModItems.vial); - addItem(ModItems.brewVial); - addItem(ModItems.brewFlask); - addBlock(ModBlocks.incensePlate); - addItem(ModItems.incenseStick); - addItem(ModItems.bloodPendant); - addBlock(ModBlocks.felPumpkin); - addBlock(ModBlocks.pylon); - addBlock(ModBlocks.pistonRelay); - addBlock(ModBlocks.hourglass); - - addBlock(ModBlocks.redStringContainer); - addBlock(ModBlocks.redStringDispenser); - addBlock(ModBlocks.redStringFertilizer); - addBlock(ModBlocks.redStringComparator); - addBlock(ModBlocks.redStringRelay); - addBlock(ModBlocks.redStringInterceptor); - - addBlock(ModBlocks.tinyPotato); - addBlock(ModBlocks.starfield); - - addBlock(ModBlocks.dreamwood); - addBlock(ModBlocks.manaGlass); - addBlock(ModFluffBlocks.managlassPane); - addBlock(ModBlocks.elfGlass); - addBlock(ModFluffBlocks.alfglassPane); - - addItem(ModItems.glassPick); - addItem(ModItems.manasteelPick); - addItem(ModItems.manasteelShovel); - addItem(ModItems.manasteelAxe); - addItem(ModItems.manasteelShears); - addItem(ModItems.manasteelSword); - addItem(ModItems.enderDagger); - addItem(ModItems.livingwoodBow); - addItem(ModItems.manasteelHelm); - if(Botania.thaumcraftLoaded) - addItem(ModItems.manasteelHelmRevealing); - addItem(ModItems.manasteelChest); - addItem(ModItems.manasteelLegs); - addItem(ModItems.manasteelBoots); - addItem(ModItems.manaweaveHelm); - addItem(ModItems.manaweaveChest); - addItem(ModItems.manaweaveLegs); - addItem(ModItems.manaweaveBoots); - addItem(ModItems.elementiumPick); - addItem(ModItems.elementiumShovel); - addItem(ModItems.elementiumAxe); - addItem(ModItems.elementiumShears); - addItem(ModItems.elementiumSword); - addItem(ModItems.starSword); - addItem(ModItems.thunderSword); - addItem(ModItems.crystalBow); - addItem(ModItems.elementiumHelm); - if(Botania.thaumcraftLoaded) - addItem(ModItems.elementiumHelmRevealing); - addItem(ModItems.elementiumChest); - addItem(ModItems.elementiumLegs); - addItem(ModItems.elementiumBoots); - addItem(ModItems.terraSword); - addItem(ModItems.thornChakram); - addItem(ModItems.terraPick); - addItem(ModItems.terraAxe); - addItem(ModItems.temperanceStone); - addItem(ModItems.terrasteelHelm); - if(Botania.thaumcraftLoaded) - addItem(ModItems.terrasteelHelmRevealing); - addItem(ModItems.terrasteelChest); - addItem(ModItems.terrasteelLegs); - addItem(ModItems.terrasteelBoots); - addItem(ModItems.phantomInk); - addItem(ModItems.cacophonium); - addItem(ModItems.recordGaia1); - addItem(ModItems.recordGaia2); - addItem(ModItems.ancientWill); - addItem(ModItems.pinkinator); - addItem(ModItems.gaiaHead); - if(ConfigHandler.relicsEnabled) { - addItem(ModItems.dice); - addItem(ModItems.infiniteFruit); - addItem(ModItems.kingKey); - addItem(ModItems.flugelEye); - addItem(ModItems.thorRing); - addItem(ModItems.odinRing); - addItem(ModItems.lokiRing); - addItem(ModItems.aesirRing); - } - - addItem(ModItems.baubleBox); - addItem(ModItems.tinyPlanet); - addBlock(ModBlocks.tinyPlanet); - addItem(ModItems.manaRing); - addItem(ModItems.auraRing); - addItem(ModItems.manaRingGreater); - addItem(ModItems.auraRingGreater); - addItem(ModItems.waterRing); - addItem(ModItems.miningRing); - addItem(ModItems.magnetRing); - addItem(ModItems.magnetRingGreater); - addItem(ModItems.swapRing); - addItem(ModItems.reachRing); - addItem(ModItems.pixieRing); - addItem(ModItems.travelBelt); - addItem(ModItems.superTravelBelt); - addItem(ModItems.speedUpBelt); - addItem(ModItems.knockbackBelt); - addItem(ModItems.itemFinder); - addItem(ModItems.monocle); - addItem(ModItems.icePendant); - addItem(ModItems.lavaPendant); - addItem(ModItems.superLavaPendant); - addItem(ModItems.holyCloak); - addItem(ModItems.unholyCloak); - addItem(ModItems.goldLaurel); - addItem(ModItems.divaCharm); - addItem(ModItems.flightTiara); - - addItem(ModItems.manaTablet); - addItem(ModItems.manaMirror); - addItem(ModItems.manaBottle); - addBlock(ModBlocks.pool); - addBlock(ModBlocks.alchemyCatalyst); - addBlock(ModBlocks.conjurationCatalyst); - addBlock(ModBlocks.distributor); - addBlock(ModBlocks.manaVoid); - addBlock(ModBlocks.bellows); - addBlock(ModBlocks.manaDetector); - addBlock(ModBlocks.manaBomb); - addBlock(ModBlocks.ghostRail); - addItem(ModItems.poolMinecart); - addBlock(ModBlocks.pump); - addBlock(ModBlocks.rfGenerator); - addBlock(ModBlocks.spreader); - addBlock(ModBlocks.turntable); - addBlock(ModBlocks.prism); - addItem(ModItems.lens); - addItem(ModItems.manaGun); - addItem(ModItems.clip); - addItem(ModItems.spark); - addItem(ModItems.sparkUpgrade); - addBlock(ModBlocks.sparkChanger); - addItem(ModItems.corporeaSpark); - addBlock(ModBlocks.corporeaIndex); - addBlock(ModBlocks.corporeaFunnel); - addBlock(ModBlocks.corporeaInterceptor); - addBlock(ModBlocks.corporeaRetainer); - addBlock(ModBlocks.corporeaCrystalCube); - addBlock(ModBlocks.lightRelay); - addBlock(ModBlocks.lightLauncher); - addBlock(ModBlocks.cellBlock); - - // FLUFF - - addBlock(ModBlocks.doubleFlower1); - addBlock(ModBlocks.doubleFlower2); - addBlock(ModBlocks.shinyFlower); - addBlock(ModBlocks.floatingFlower); - addBlock(ModBlocks.floatingSpecialFlower); - addBlock(ModBlocks.petalBlock); - addBlock(ModBlocks.mushroom); - addBlock(ModBlocks.unstableBlock); - addBlock(ModBlocks.manaBeacon); - addItem(ModItems.signalFlare); - - addStack(new ItemStack(Blocks.dirt, 1, 1)); - addBlock(ModBlocks.dirtPath); - addBlock(ModFluffBlocks.dirtPathSlab); - - addBlock(ModBlocks.prismarine); - addBlock(ModBlocks.seaLamp); - addBlock(ModFluffBlocks.prismarineStairs); - addBlock(ModFluffBlocks.prismarineSlab); - addBlock(ModFluffBlocks.prismarineWall); - addBlock(ModFluffBlocks.prismarineBrickStairs); - addBlock(ModFluffBlocks.prismarineBrickSlab); - addBlock(ModFluffBlocks.darkPrismarineStairs); - addBlock(ModFluffBlocks.darkPrismarineSlab); - - addBlock(ModBlocks.blazeBlock); - - addBlock(ModBlocks.reedBlock); - addBlock(ModFluffBlocks.reedStairs); - addBlock(ModFluffBlocks.reedSlab); - addBlock(ModFluffBlocks.reedWall); - addBlock(ModBlocks.thatch); - addBlock(ModFluffBlocks.thatchStairs); - addBlock(ModFluffBlocks.thatchSlab); - - addBlock(ModBlocks.customBrick); - addBlock(ModFluffBlocks.netherBrickStairs); - addBlock(ModFluffBlocks.netherBrickSlab); - addBlock(ModFluffBlocks.soulBrickStairs); - addBlock(ModFluffBlocks.soulBrickSlab); - addBlock(ModFluffBlocks.snowBrickStairs); - addBlock(ModFluffBlocks.snowBrickSlab); - addBlock(ModFluffBlocks.tileStairs); - addBlock(ModFluffBlocks.tileSlab); - - addBlock(ModFluffBlocks.livingwoodStairs); - addBlock(ModFluffBlocks.livingwoodSlab); - addBlock(ModFluffBlocks.livingwoodWall); - addBlock(ModFluffBlocks.livingwoodPlankStairs); - addBlock(ModFluffBlocks.livingwoodPlankSlab); - addBlock(ModFluffBlocks.livingrockStairs); - addBlock(ModFluffBlocks.livingrockSlab); - addBlock(ModFluffBlocks.livingrockWall); - addBlock(ModFluffBlocks.livingrockBrickStairs); - addBlock(ModFluffBlocks.livingrockBrickSlab); - addBlock(ModFluffBlocks.dreamwoodStairs); - addBlock(ModFluffBlocks.dreamwoodSlab); - addBlock(ModFluffBlocks.dreamwoodWall); - addBlock(ModFluffBlocks.dreamwoodPlankStairs); - addBlock(ModFluffBlocks.dreamwoodPlankSlab); - addBlock(ModFluffBlocks.shimmerwoodPlankStairs); - addBlock(ModFluffBlocks.shimmerwoodPlankSlab); - addBlock(ModFluffBlocks.shimmerrockStairs); - addBlock(ModFluffBlocks.shimmerrockSlab); - - addItem(ModItems.quartz); - if(ConfigHandler.darkQuartzEnabled) { - addBlock(ModFluffBlocks.darkQuartz); - addBlock(ModFluffBlocks.darkQuartzSlab); - addBlock(ModFluffBlocks.darkQuartzStairs); - } - - addBlock(ModFluffBlocks.manaQuartz); - addBlock(ModFluffBlocks.manaQuartzSlab); - addBlock(ModFluffBlocks.manaQuartzStairs); - addBlock(ModFluffBlocks.blazeQuartz); - addBlock(ModFluffBlocks.blazeQuartzSlab); - addBlock(ModFluffBlocks.blazeQuartzStairs); - addBlock(ModFluffBlocks.lavenderQuartz); - addBlock(ModFluffBlocks.lavenderQuartzSlab); - addBlock(ModFluffBlocks.lavenderQuartzStairs); - addBlock(ModFluffBlocks.redQuartz); - addBlock(ModFluffBlocks.redQuartzSlab); - addBlock(ModFluffBlocks.redQuartzStairs); - addBlock(ModFluffBlocks.elfQuartz); - addBlock(ModFluffBlocks.elfQuartzSlab); - addBlock(ModFluffBlocks.elfQuartzStairs); - addBlock(ModFluffBlocks.sunnyQuartz); - addBlock(ModFluffBlocks.sunnyQuartzSlab); - addBlock(ModFluffBlocks.sunnyQuartzStairs); - - if(ConfigHandler.stones18Enabled) { - addBlock(ModFluffBlocks.stone); - for(int i = 0; i < 8; i++) - addBlock(ModFluffBlocks.stoneStairs[i]); - for(int i = 0; i < 8; i++) - addBlock(ModFluffBlocks.stoneSlabs[i]); - addBlock(ModFluffBlocks.stoneWall); - } - - addBlock(ModFluffBlocks.biomeStoneA); - addBlock(ModFluffBlocks.biomeStoneB); - for(int i = 0; i < 24; i++) - addBlock(ModFluffBlocks.biomeStoneStairs[i]); - for(int i = 0; i < 24; i++) - addBlock(ModFluffBlocks.biomeStoneSlabs[i]); - addBlock(ModFluffBlocks.biomeStoneWall); - - addBlock(ModFluffBlocks.pavement); - for (Block pavementStair : ModFluffBlocks.pavementStairs) - addBlock(pavementStair); - for (Block pavementSlab : ModFluffBlocks.pavementSlabs) - addBlock(pavementSlab); - - if(ConfigHandler.enderStuff19Enabled) { - addBlock(ModBlocks.endStoneBrick); - addBlock(ModFluffBlocks.endStoneSlab); - addBlock(ModFluffBlocks.endStoneStairs); - addBlock(ModFluffBlocks.enderBrickSlab); - addBlock(ModFluffBlocks.enderBrickStairs); - } - - addItem(ModItems.cosmetic); - } - - private void addItem(Item item) { - item.getSubItems(item, this, list); - } - - private void addBlock(Block block) { - ItemStack stack = new ItemStack(block); - block.getSubBlocks(stack.getItem(), this, list); - } - - private void addStack(ItemStack stack) { - list.add(stack); - } - -} \ No newline at end of file + public static BotaniaCreativeTab INSTANCE = new BotaniaCreativeTab(); + List list; + + public BotaniaCreativeTab() { + super(LibMisc.MOD_ID); + setNoTitle(); + setBackgroundImageName(LibResources.GUI_CREATIVE); + } + + @Override + public ItemStack getIconItemStack() { + return new ItemStack(ModItems.lexicon); + } + + @Override + public Item getTabIconItem() { + return getIconItemStack().getItem(); + } + + @Override + public boolean hasSearchBar() { + return true; + } + + @Override + public void displayAllReleventItems(List list) { + this.list = list; + + addItem(ModItems.lexicon); + + addBlock(ModBlocks.flower); + addBlock(ModBlocks.specialFlower); + addItem(ModItems.petal); + addItem(ModItems.pestleAndMortar); + addItem(ModItems.dye); + addItem(ModItems.fertilizer); + addItem(ModItems.flowerBag); + addItem(ModItems.blackLotus); + addItem(ModItems.twigWand); + addItem(ModItems.obedienceStick); + addItem(ModItems.manaResource); + addBlock(ModBlocks.storage); + addItem(ModItems.manaCookie); + addItem(ModItems.rune); + + addBlock(ModBlocks.avatar); + addItem(ModItems.dirtRod); + addItem(ModItems.skyDirtRod); + addItem(ModItems.cobbleRod); + addItem(ModItems.terraformRod); + addItem(ModItems.laputaShard); + addItem(ModItems.grassHorn); + addItem(ModItems.waterRod); + addItem(ModItems.openBucket); + addItem(ModItems.rainbowRod); + addBlock(ModBlocks.bifrostPerm); + addBlock(ModFluffBlocks.bifrostPane); + addBlock(ModBlocks.shimmerrock); + addBlock(ModBlocks.shimmerwoodPlanks); + addItem(ModItems.tornadoRod); + addItem(ModItems.fireRod); + addItem(ModItems.smeltRod); + addItem(ModItems.exchangeRod); + addItem(ModItems.diviningRod); + addItem(ModItems.gravityRod); + addItem(ModItems.missileRod); + addItem(ModItems.virus); + addItem(ModItems.slingshot); + addItem(ModItems.vineBall); + addItem(ModItems.regenIvy); + addItem(ModItems.keepIvy); + addItem(ModItems.worldSeed); + addItem(ModItems.overgrowthSeed); + addBlock(ModBlocks.enchantedSoil); + addItem(ModItems.grassSeeds); + addBlock(ModBlocks.altGrass); + if (Botania.thaumcraftLoaded) addItem(ModItems.manaInkwell); + addBlock(ModBlocks.forestDrum); + addBlock(ModBlocks.forestEye); + addBlock(ModBlocks.enderEye); + addItem(ModItems.enderHand); + addItem(ModItems.spellCloth); + addItem(ModItems.craftingHalo); + addItem(ModItems.autocraftingHalo); + addItem(ModItems.spawnerMover); + addBlock(ModBlocks.spawnerClaw); + addBlock(ModBlocks.cocoon); + addBlock(ModBlocks.teruTeruBozu); + addItem(ModItems.slimeBottle); + addItem(ModItems.sextant); + addItem(ModItems.blackHoleTalisman); + + if (Botania.gardenOfGlassLoaded) { + addBlock(ModBlocks.root); + addItem(ModItems.waterBowl); + } + + addBlock(ModBlocks.livingrock); + addBlock(ModBlocks.livingwood); + addBlock(ModBlocks.openCrate); + addItem(ModItems.craftPattern); + addBlock(ModBlocks.platform); + addBlock(ModBlocks.alfPortal); + addBlock(ModBlocks.altar); + addBlock(ModBlocks.runeAltar); + addBlock(ModBlocks.terraPlate); + addBlock(ModBlocks.brewery); + addItem(ModItems.vial); + addItem(ModItems.brewVial); + addItem(ModItems.brewFlask); + addBlock(ModBlocks.incensePlate); + addItem(ModItems.incenseStick); + addItem(ModItems.bloodPendant); + addBlock(ModBlocks.felPumpkin); + addBlock(ModBlocks.pylon); + addBlock(ModBlocks.pistonRelay); + addBlock(ModBlocks.hourglass); + + addBlock(ModBlocks.redStringContainer); + addBlock(ModBlocks.redStringDispenser); + addBlock(ModBlocks.redStringFertilizer); + addBlock(ModBlocks.redStringComparator); + addBlock(ModBlocks.redStringRelay); + addBlock(ModBlocks.redStringInterceptor); + + addBlock(ModBlocks.tinyPotato); + addBlock(ModBlocks.starfield); + + addBlock(ModBlocks.dreamwood); + addBlock(ModBlocks.manaGlass); + addBlock(ModFluffBlocks.managlassPane); + addBlock(ModBlocks.elfGlass); + addBlock(ModFluffBlocks.alfglassPane); + + addItem(ModItems.glassPick); + addItem(ModItems.manasteelPick); + addItem(ModItems.manasteelShovel); + addItem(ModItems.manasteelAxe); + addItem(ModItems.manasteelShears); + addItem(ModItems.manasteelSword); + addItem(ModItems.enderDagger); + addItem(ModItems.livingwoodBow); + addItem(ModItems.manasteelHelm); + if (Botania.thaumcraftLoaded) addItem(ModItems.manasteelHelmRevealing); + addItem(ModItems.manasteelChest); + addItem(ModItems.manasteelLegs); + addItem(ModItems.manasteelBoots); + addItem(ModItems.manaweaveHelm); + addItem(ModItems.manaweaveChest); + addItem(ModItems.manaweaveLegs); + addItem(ModItems.manaweaveBoots); + addItem(ModItems.elementiumPick); + addItem(ModItems.elementiumShovel); + addItem(ModItems.elementiumAxe); + addItem(ModItems.elementiumShears); + addItem(ModItems.elementiumSword); + addItem(ModItems.starSword); + addItem(ModItems.thunderSword); + addItem(ModItems.crystalBow); + addItem(ModItems.elementiumHelm); + if (Botania.thaumcraftLoaded) addItem(ModItems.elementiumHelmRevealing); + addItem(ModItems.elementiumChest); + addItem(ModItems.elementiumLegs); + addItem(ModItems.elementiumBoots); + addItem(ModItems.terraSword); + addItem(ModItems.thornChakram); + addItem(ModItems.terraPick); + addItem(ModItems.terraAxe); + addItem(ModItems.temperanceStone); + addItem(ModItems.terrasteelHelm); + if (Botania.thaumcraftLoaded) addItem(ModItems.terrasteelHelmRevealing); + addItem(ModItems.terrasteelChest); + addItem(ModItems.terrasteelLegs); + addItem(ModItems.terrasteelBoots); + addItem(ModItems.phantomInk); + addItem(ModItems.cacophonium); + addItem(ModItems.recordGaia1); + addItem(ModItems.recordGaia2); + addItem(ModItems.ancientWill); + addItem(ModItems.pinkinator); + addItem(ModItems.gaiaHead); + if (ConfigHandler.relicsEnabled) { + addItem(ModItems.dice); + addItem(ModItems.infiniteFruit); + addItem(ModItems.kingKey); + addItem(ModItems.flugelEye); + addItem(ModItems.thorRing); + addItem(ModItems.odinRing); + addItem(ModItems.lokiRing); + addItem(ModItems.aesirRing); + } + + addItem(ModItems.baubleBox); + addItem(ModItems.tinyPlanet); + addBlock(ModBlocks.tinyPlanet); + addItem(ModItems.manaRing); + addItem(ModItems.auraRing); + addItem(ModItems.manaRingGreater); + addItem(ModItems.auraRingGreater); + addItem(ModItems.waterRing); + addItem(ModItems.miningRing); + addItem(ModItems.magnetRing); + addItem(ModItems.magnetRingGreater); + addItem(ModItems.swapRing); + addItem(ModItems.reachRing); + addItem(ModItems.pixieRing); + addItem(ModItems.travelBelt); + addItem(ModItems.superTravelBelt); + addItem(ModItems.speedUpBelt); + addItem(ModItems.knockbackBelt); + addItem(ModItems.itemFinder); + addItem(ModItems.monocle); + addItem(ModItems.icePendant); + addItem(ModItems.lavaPendant); + addItem(ModItems.superLavaPendant); + addItem(ModItems.holyCloak); + addItem(ModItems.unholyCloak); + addItem(ModItems.goldLaurel); + addItem(ModItems.divaCharm); + addItem(ModItems.flightTiara); + + addItem(ModItems.manaTablet); + addItem(ModItems.manaMirror); + addItem(ModItems.manaBottle); + addBlock(ModBlocks.pool); + addBlock(ModBlocks.alchemyCatalyst); + addBlock(ModBlocks.conjurationCatalyst); + addBlock(ModBlocks.distributor); + addBlock(ModBlocks.manaVoid); + addBlock(ModBlocks.bellows); + addBlock(ModBlocks.manaDetector); + addBlock(ModBlocks.manaBomb); + addBlock(ModBlocks.ghostRail); + addItem(ModItems.poolMinecart); + addBlock(ModBlocks.pump); + addBlock(ModBlocks.rfGenerator); + addBlock(ModBlocks.spreader); + addBlock(ModBlocks.turntable); + addBlock(ModBlocks.prism); + addItem(ModItems.lens); + addItem(ModItems.manaGun); + addItem(ModItems.clip); + addItem(ModItems.spark); + addItem(ModItems.sparkUpgrade); + addBlock(ModBlocks.sparkChanger); + addItem(ModItems.corporeaSpark); + addBlock(ModBlocks.corporeaIndex); + addBlock(ModBlocks.corporeaFunnel); + addBlock(ModBlocks.corporeaInterceptor); + addBlock(ModBlocks.corporeaRetainer); + addBlock(ModBlocks.corporeaCrystalCube); + addBlock(ModBlocks.lightRelay); + addBlock(ModBlocks.lightLauncher); + addBlock(ModBlocks.cellBlock); + + // FLUFF + + addBlock(ModBlocks.doubleFlower1); + addBlock(ModBlocks.doubleFlower2); + addBlock(ModBlocks.shinyFlower); + addBlock(ModBlocks.floatingFlower); + addBlock(ModBlocks.floatingSpecialFlower); + addBlock(ModBlocks.petalBlock); + addBlock(ModBlocks.mushroom); + addBlock(ModBlocks.unstableBlock); + addBlock(ModBlocks.manaBeacon); + addItem(ModItems.signalFlare); + + addStack(new ItemStack(Blocks.dirt, 1, 1)); + addBlock(ModBlocks.dirtPath); + addBlock(ModFluffBlocks.dirtPathSlab); + + addBlock(ModBlocks.prismarine); + addBlock(ModBlocks.seaLamp); + addBlock(ModFluffBlocks.prismarineStairs); + addBlock(ModFluffBlocks.prismarineSlab); + addBlock(ModFluffBlocks.prismarineWall); + addBlock(ModFluffBlocks.prismarineBrickStairs); + addBlock(ModFluffBlocks.prismarineBrickSlab); + addBlock(ModFluffBlocks.darkPrismarineStairs); + addBlock(ModFluffBlocks.darkPrismarineSlab); + + addBlock(ModBlocks.blazeBlock); + + addBlock(ModBlocks.reedBlock); + addBlock(ModFluffBlocks.reedStairs); + addBlock(ModFluffBlocks.reedSlab); + addBlock(ModFluffBlocks.reedWall); + addBlock(ModBlocks.thatch); + addBlock(ModFluffBlocks.thatchStairs); + addBlock(ModFluffBlocks.thatchSlab); + + addBlock(ModBlocks.customBrick); + addBlock(ModFluffBlocks.netherBrickStairs); + addBlock(ModFluffBlocks.netherBrickSlab); + addBlock(ModFluffBlocks.soulBrickStairs); + addBlock(ModFluffBlocks.soulBrickSlab); + addBlock(ModFluffBlocks.snowBrickStairs); + addBlock(ModFluffBlocks.snowBrickSlab); + addBlock(ModFluffBlocks.tileStairs); + addBlock(ModFluffBlocks.tileSlab); + + addBlock(ModFluffBlocks.livingwoodStairs); + addBlock(ModFluffBlocks.livingwoodSlab); + addBlock(ModFluffBlocks.livingwoodWall); + addBlock(ModFluffBlocks.livingwoodPlankStairs); + addBlock(ModFluffBlocks.livingwoodPlankSlab); + addBlock(ModFluffBlocks.livingrockStairs); + addBlock(ModFluffBlocks.livingrockSlab); + addBlock(ModFluffBlocks.livingrockWall); + addBlock(ModFluffBlocks.livingrockBrickStairs); + addBlock(ModFluffBlocks.livingrockBrickSlab); + addBlock(ModFluffBlocks.dreamwoodStairs); + addBlock(ModFluffBlocks.dreamwoodSlab); + addBlock(ModFluffBlocks.dreamwoodWall); + addBlock(ModFluffBlocks.dreamwoodPlankStairs); + addBlock(ModFluffBlocks.dreamwoodPlankSlab); + addBlock(ModFluffBlocks.shimmerwoodPlankStairs); + addBlock(ModFluffBlocks.shimmerwoodPlankSlab); + addBlock(ModFluffBlocks.shimmerrockStairs); + addBlock(ModFluffBlocks.shimmerrockSlab); + + addItem(ModItems.quartz); + if (ConfigHandler.darkQuartzEnabled) { + addBlock(ModFluffBlocks.darkQuartz); + addBlock(ModFluffBlocks.darkQuartzSlab); + addBlock(ModFluffBlocks.darkQuartzStairs); + } + + addBlock(ModFluffBlocks.manaQuartz); + addBlock(ModFluffBlocks.manaQuartzSlab); + addBlock(ModFluffBlocks.manaQuartzStairs); + addBlock(ModFluffBlocks.blazeQuartz); + addBlock(ModFluffBlocks.blazeQuartzSlab); + addBlock(ModFluffBlocks.blazeQuartzStairs); + addBlock(ModFluffBlocks.lavenderQuartz); + addBlock(ModFluffBlocks.lavenderQuartzSlab); + addBlock(ModFluffBlocks.lavenderQuartzStairs); + addBlock(ModFluffBlocks.redQuartz); + addBlock(ModFluffBlocks.redQuartzSlab); + addBlock(ModFluffBlocks.redQuartzStairs); + addBlock(ModFluffBlocks.elfQuartz); + addBlock(ModFluffBlocks.elfQuartzSlab); + addBlock(ModFluffBlocks.elfQuartzStairs); + addBlock(ModFluffBlocks.sunnyQuartz); + addBlock(ModFluffBlocks.sunnyQuartzSlab); + addBlock(ModFluffBlocks.sunnyQuartzStairs); + + if (ConfigHandler.stones18Enabled) { + addBlock(ModFluffBlocks.stone); + for (int i = 0; i < 8; i++) addBlock(ModFluffBlocks.stoneStairs[i]); + for (int i = 0; i < 8; i++) addBlock(ModFluffBlocks.stoneSlabs[i]); + addBlock(ModFluffBlocks.stoneWall); + } + + addBlock(ModFluffBlocks.biomeStoneA); + addBlock(ModFluffBlocks.biomeStoneB); + for (int i = 0; i < 24; i++) addBlock(ModFluffBlocks.biomeStoneStairs[i]); + for (int i = 0; i < 24; i++) addBlock(ModFluffBlocks.biomeStoneSlabs[i]); + addBlock(ModFluffBlocks.biomeStoneWall); + + addBlock(ModFluffBlocks.pavement); + for (Block pavementStair : ModFluffBlocks.pavementStairs) addBlock(pavementStair); + for (Block pavementSlab : ModFluffBlocks.pavementSlabs) addBlock(pavementSlab); + + if (ConfigHandler.enderStuff19Enabled) { + addBlock(ModBlocks.endStoneBrick); + addBlock(ModFluffBlocks.endStoneSlab); + addBlock(ModFluffBlocks.endStoneStairs); + addBlock(ModFluffBlocks.enderBrickSlab); + addBlock(ModFluffBlocks.enderBrickStairs); + } + + addItem(ModItems.cosmetic); + } + + private void addItem(Item item) { + item.getSubItems(item, this, list); + } + + private void addBlock(Block block) { + ItemStack stack = new ItemStack(block); + block.getSubBlocks(stack.getItem(), this, list); + } + + private void addStack(ItemStack stack) { + list.add(stack); + } +} diff --git a/src/main/java/vazkii/botania/common/core/command/CommandOpen.java b/src/main/java/vazkii/botania/common/core/command/CommandOpen.java index 6e6b3b2bc4..5038170bc4 100644 --- a/src/main/java/vazkii/botania/common/core/command/CommandOpen.java +++ b/src/main/java/vazkii/botania/common/core/command/CommandOpen.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Sep 23, 2014, 9:50:14 PM (GMT)] */ package vazkii.botania.common.core.command; @@ -21,37 +21,37 @@ public class CommandOpen extends CommandBase { - @Override - public String getCommandName() { - return "botania-open"; - } - - @Override - public String getCommandUsage(ICommandSender p_71518_1_) { - return ""; - } - - @Override - public void processCommand(ICommandSender sender, String[] args) { - if(sender instanceof EntityPlayer) { - EntityPlayer player = (EntityPlayer) sender; - ItemStack stack = player.getCurrentEquippedItem(); - if(stack != null && stack.getItem() instanceof ItemLexicon) { - ItemLexicon.setForcedPage(stack, args[0]); - ItemLexicon.setQueueTicks(stack, 5); - } else sender.addChatMessage(new ChatComponentTranslation("botaniamisc.noLexicon").setChatStyle(new ChatStyle().setColor(EnumChatFormatting.RED))); - } - } - - - @Override - public int getRequiredPermissionLevel() { - return 0; - } - - @Override - public boolean canCommandSenderUseCommand(ICommandSender p_71519_1_) { - return p_71519_1_ instanceof EntityPlayer; - } - + @Override + public String getCommandName() { + return "botania-open"; + } + + @Override + public String getCommandUsage(ICommandSender p_71518_1_) { + return ""; + } + + @Override + public void processCommand(ICommandSender sender, String[] args) { + if (sender instanceof EntityPlayer) { + EntityPlayer player = (EntityPlayer) sender; + ItemStack stack = player.getCurrentEquippedItem(); + if (stack != null && stack.getItem() instanceof ItemLexicon) { + ItemLexicon.setForcedPage(stack, args[0]); + ItemLexicon.setQueueTicks(stack, 5); + } else + sender.addChatMessage(new ChatComponentTranslation("botaniamisc.noLexicon") + .setChatStyle(new ChatStyle().setColor(EnumChatFormatting.RED))); + } + } + + @Override + public int getRequiredPermissionLevel() { + return 0; + } + + @Override + public boolean canCommandSenderUseCommand(ICommandSender p_71519_1_) { + return p_71519_1_ instanceof EntityPlayer; + } } diff --git a/src/main/java/vazkii/botania/common/core/command/CommandShare.java b/src/main/java/vazkii/botania/common/core/command/CommandShare.java index ef90019662..7d30e79d25 100644 --- a/src/main/java/vazkii/botania/common/core/command/CommandShare.java +++ b/src/main/java/vazkii/botania/common/core/command/CommandShare.java @@ -19,35 +19,34 @@ public class CommandShare extends CommandBase { - @Override - public String getCommandName() { - return "botania-share"; - } - - @Override - public String getCommandUsage(ICommandSender p_71518_1_) { - return ""; - } - - @Override - public void processCommand(ICommandSender sender, String[] args) { - String json = StatCollector.translateToLocal("botaniamisc.shareMsg"); - json = json.replaceAll("%name%", sender.getCommandSenderName()); - json = json.replaceAll("%entry%", args[0]); - json = json.replaceAll("%entryname%", StatCollector.translateToLocal(args[0])); - - IChatComponent component = IChatComponent.Serializer.func_150699_a(json); - MinecraftServer.getServer().getConfigurationManager().sendChatMsg(component); - } - - - @Override - public int getRequiredPermissionLevel() { - return 0; - } - - @Override - public boolean canCommandSenderUseCommand(ICommandSender p_71519_1_) { - return p_71519_1_ instanceof EntityPlayer; - } + @Override + public String getCommandName() { + return "botania-share"; + } + + @Override + public String getCommandUsage(ICommandSender p_71518_1_) { + return ""; + } + + @Override + public void processCommand(ICommandSender sender, String[] args) { + String json = StatCollector.translateToLocal("botaniamisc.shareMsg"); + json = json.replaceAll("%name%", sender.getCommandSenderName()); + json = json.replaceAll("%entry%", args[0]); + json = json.replaceAll("%entryname%", StatCollector.translateToLocal(args[0])); + + IChatComponent component = IChatComponent.Serializer.func_150699_a(json); + MinecraftServer.getServer().getConfigurationManager().sendChatMsg(component); + } + + @Override + public int getRequiredPermissionLevel() { + return 0; + } + + @Override + public boolean canCommandSenderUseCommand(ICommandSender p_71519_1_) { + return p_71519_1_ instanceof EntityPlayer; + } } diff --git a/src/main/java/vazkii/botania/common/core/command/CommandSkyblockSpread.java b/src/main/java/vazkii/botania/common/core/command/CommandSkyblockSpread.java index 3be7ca0743..ea6d61f6b7 100644 --- a/src/main/java/vazkii/botania/common/core/command/CommandSkyblockSpread.java +++ b/src/main/java/vazkii/botania/common/core/command/CommandSkyblockSpread.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jul 17, 2015, 5:13:06 PM (GMT)] */ package vazkii.botania.common.core.command; @@ -21,48 +21,45 @@ public class CommandSkyblockSpread extends CommandBase { - @Override - public String getCommandName() { - return "botania-skyblock-spread"; - } + @Override + public String getCommandName() { + return "botania-skyblock-spread"; + } - @Override - public String getCommandUsage(ICommandSender p_71518_1_) { - return " []"; - } + @Override + public String getCommandUsage(ICommandSender p_71518_1_) { + return " []"; + } - @Override - public int getRequiredPermissionLevel() { - return 2; - } + @Override + public int getRequiredPermissionLevel() { + return 2; + } - @Override - public void processCommand(ICommandSender sender, String[] args) { - int maxAllowed = 1000000; - int minAllowed = 250; - int minDist = 100; + @Override + public void processCommand(ICommandSender sender, String[] args) { + int maxAllowed = 1000000; + int minAllowed = 250; + int minDist = 100; - int maxrange = 200000; - if(args.length == 2) - maxrange = parseInt(sender, args[1]); + int maxrange = 200000; + if (args.length == 2) maxrange = parseInt(sender, args[1]); - if(maxrange > maxAllowed) - throw new CommandException("botaniamisc.skyblockRangeTooHigh"); - if(maxrange < minAllowed) - throw new CommandException(StatCollector.translateToLocal("botaniamisc.skyblockRangeTooLow")); + if (maxrange > maxAllowed) throw new CommandException("botaniamisc.skyblockRangeTooHigh"); + if (maxrange < minAllowed) + throw new CommandException(StatCollector.translateToLocal("botaniamisc.skyblockRangeTooLow")); - EntityPlayer player = getPlayer(sender, args[0]); - if(player != null) { - ChunkCoordinates spawn = player.worldObj.getSpawnPoint(); - int x, z; + EntityPlayer player = getPlayer(sender, args[0]); + if (player != null) { + ChunkCoordinates spawn = player.worldObj.getSpawnPoint(); + int x, z; - do { - x = player.worldObj.rand.nextInt(maxrange) - maxrange / 2 + spawn.posX; - z = player.worldObj.rand.nextInt(maxrange) - maxrange / 2 + spawn.posZ; - } while(MathHelper.pointDistancePlane(x, z, spawn.posX, spawn.posZ) < minDist); - - SkyblockWorldEvents.spawnPlayer(player, x, spawn.posY, z, true); - } - } + do { + x = player.worldObj.rand.nextInt(maxrange) - maxrange / 2 + spawn.posX; + z = player.worldObj.rand.nextInt(maxrange) - maxrange / 2 + spawn.posZ; + } while (MathHelper.pointDistancePlane(x, z, spawn.posX, spawn.posZ) < minDist); + SkyblockWorldEvents.spawnPlayer(player, x, spawn.posY, z, true); + } + } } diff --git a/src/main/java/vazkii/botania/common/core/handler/AliasHandler.java b/src/main/java/vazkii/botania/common/core/handler/AliasHandler.java index aad356ac81..cfb7d3e53e 100644 --- a/src/main/java/vazkii/botania/common/core/handler/AliasHandler.java +++ b/src/main/java/vazkii/botania/common/core/handler/AliasHandler.java @@ -2,63 +2,57 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [May 16, 2014, 6:24:12 PM (GMT)] */ package vazkii.botania.common.core.handler; +import cpw.mods.fml.common.event.FMLMissingMappingsEvent; +import cpw.mods.fml.common.event.FMLMissingMappingsEvent.MissingMapping; +import cpw.mods.fml.common.registry.GameRegistry.Type; import java.util.List; - import net.minecraft.block.Block; import net.minecraft.item.Item; import vazkii.botania.client.lib.LibResources; -import cpw.mods.fml.common.event.FMLMissingMappingsEvent; -import cpw.mods.fml.common.event.FMLMissingMappingsEvent.MissingMapping; -import cpw.mods.fml.common.registry.GameRegistry.Type; public final class AliasHandler { - public static void onMissingMappings(FMLMissingMappingsEvent event) { - List mappings = event.get(); - for(MissingMapping mapping : mappings) { - String name = mapping.name.substring(LibResources.PREFIX_MOD.length() * 2); - - if(mapping.type == Type.ITEM) - remapItem(mapping, getItem(name)); - else remapBlock(mapping, getBlock(name)); - } - } - - private static void remapItem(MissingMapping mapping, Item item) { - if(item != null) - mapping.remap(item); - } - - private static void remapBlock(MissingMapping mapping, Block block) { - if(block != null) - mapping.remap(block); - } - - private static Item getItem(String name) { - for(Object o : Item.itemRegistry.getKeys()) { - Item i = (Item) Item.itemRegistry.getObject(o); - if(i.getUnlocalizedName().substring("item.".length()).equals(name)) - return i; - } - - return null; - } - - private static Block getBlock(String name) { - for(Object o : Block.blockRegistry.getKeys()) { - Block b = (Block) Block.blockRegistry.getObject(o); - if(b.getUnlocalizedName().substring("tile.".length()).equals(name)) - return b; - } - - return null; - } + public static void onMissingMappings(FMLMissingMappingsEvent event) { + List mappings = event.get(); + for (MissingMapping mapping : mappings) { + String name = mapping.name.substring(LibResources.PREFIX_MOD.length() * 2); + + if (mapping.type == Type.ITEM) remapItem(mapping, getItem(name)); + else remapBlock(mapping, getBlock(name)); + } + } + + private static void remapItem(MissingMapping mapping, Item item) { + if (item != null) mapping.remap(item); + } + + private static void remapBlock(MissingMapping mapping, Block block) { + if (block != null) mapping.remap(block); + } + + private static Item getItem(String name) { + for (Object o : Item.itemRegistry.getKeys()) { + Item i = (Item) Item.itemRegistry.getObject(o); + if (i.getUnlocalizedName().substring("item.".length()).equals(name)) return i; + } + + return null; + } + + private static Block getBlock(String name) { + for (Object o : Block.blockRegistry.getKeys()) { + Block b = (Block) Block.blockRegistry.getObject(o); + if (b.getUnlocalizedName().substring("tile.".length()).equals(name)) return b; + } + + return null; + } } diff --git a/src/main/java/vazkii/botania/common/core/handler/BiomeDecorationHandler.java b/src/main/java/vazkii/botania/common/core/handler/BiomeDecorationHandler.java index af6a76ac69..be9cc23fc5 100644 --- a/src/main/java/vazkii/botania/common/core/handler/BiomeDecorationHandler.java +++ b/src/main/java/vazkii/botania/common/core/handler/BiomeDecorationHandler.java @@ -2,14 +2,18 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jan 19, 2014, 10:16:49 PM (GMT)] */ package vazkii.botania.common.core.handler; +import cpw.mods.fml.common.eventhandler.Event.Result; +import cpw.mods.fml.common.eventhandler.EventPriority; +import cpw.mods.fml.common.eventhandler.SubscribeEvent; +import java.util.Arrays; import net.minecraftforge.event.terraingen.DecorateBiomeEvent; import net.minecraftforge.event.terraingen.DecorateBiomeEvent.Decorate.EventType; import vazkii.botania.api.item.IFlowerlessBiome; @@ -19,93 +23,92 @@ import vazkii.botania.common.block.subtile.generating.SubTileDaybloom; import vazkii.botania.common.block.tile.TileSpecialFlower; import vazkii.botania.common.lib.LibBlockNames; -import cpw.mods.fml.common.eventhandler.Event.Result; -import cpw.mods.fml.common.eventhandler.EventPriority; -import cpw.mods.fml.common.eventhandler.SubscribeEvent; - -import java.util.Arrays; public class BiomeDecorationHandler { - @SubscribeEvent(priority = EventPriority.LOWEST) - public void onWorldDecoration(DecorateBiomeEvent.Decorate event) { - if((event.getResult() == Result.ALLOW || event.getResult() == Result.DEFAULT) && event.type == EventType.FLOWERS) { - boolean flowers = true; - if(event.world.provider instanceof IFlowerlessWorld) - flowers = ((IFlowerlessWorld) event.world.provider).generateFlowers(event.world); - else if(event.world.getBiomeGenForCoords(event.chunkX, event.chunkZ) instanceof IFlowerlessBiome) - flowers = ((IFlowerlessBiome) event.world.getBiomeGenForCoords(event.chunkX, event.chunkZ)).canGenerateFlowers(event.world, event.chunkX, event.chunkZ); + @SubscribeEvent(priority = EventPriority.LOWEST) + public void onWorldDecoration(DecorateBiomeEvent.Decorate event) { + if ((event.getResult() == Result.ALLOW || event.getResult() == Result.DEFAULT) + && event.type == EventType.FLOWERS) { + boolean flowers = true; + if (event.world.provider instanceof IFlowerlessWorld) + flowers = ((IFlowerlessWorld) event.world.provider).generateFlowers(event.world); + else if (event.world.getBiomeGenForCoords(event.chunkX, event.chunkZ) instanceof IFlowerlessBiome) + flowers = ((IFlowerlessBiome) event.world.getBiomeGenForCoords(event.chunkX, event.chunkZ)) + .canGenerateFlowers(event.world, event.chunkX, event.chunkZ); - if(!flowers) - return; + if (!flowers) return; - if (ConfigHandler.flowerDimensionWhitelist.length == 0 - || Arrays.stream(ConfigHandler.flowerDimensionWhitelist).anyMatch( - d -> d == event.world.provider.dimensionId - )) { - if (Arrays.stream(ConfigHandler.flowerDimensionBlacklist).noneMatch( - d -> d == event.world.provider.dimensionId - )) { - generateFlowers(event); - } - } + if (ConfigHandler.flowerDimensionWhitelist.length == 0 + || Arrays.stream(ConfigHandler.flowerDimensionWhitelist) + .anyMatch(d -> d == event.world.provider.dimensionId)) { + if (Arrays.stream(ConfigHandler.flowerDimensionBlacklist) + .noneMatch(d -> d == event.world.provider.dimensionId)) { + generateFlowers(event); + } + } - if (ConfigHandler.mushroomDimensionWhitelist.length == 0 - || Arrays.stream(ConfigHandler.mushroomDimensionWhitelist).anyMatch( - d -> d == event.world.provider.dimensionId - )) { - if (Arrays.stream(ConfigHandler.mushroomDimensionBlacklist).noneMatch( - d -> d == event.world.provider.dimensionId - )) { - generateMushrooms(event); - } - } - } - } + if (ConfigHandler.mushroomDimensionWhitelist.length == 0 + || Arrays.stream(ConfigHandler.mushroomDimensionWhitelist) + .anyMatch(d -> d == event.world.provider.dimensionId)) { + if (Arrays.stream(ConfigHandler.mushroomDimensionBlacklist) + .noneMatch(d -> d == event.world.provider.dimensionId)) { + generateMushrooms(event); + } + } + } + } - private void generateFlowers(DecorateBiomeEvent.Decorate event) { - int dist = Math.min(8, Math.max(1, ConfigHandler.flowerPatchSize)); - for(int i = 0; i < ConfigHandler.flowerQuantity; i++) { - if(event.rand.nextInt(ConfigHandler.flowerPatchChance) == 0) { - int x = event.chunkX + event.rand.nextInt(16) + 8; - int z = event.chunkZ + event.rand.nextInt(16) + 8; - int y = event.world.getTopSolidOrLiquidBlock(x, z); + private void generateFlowers(DecorateBiomeEvent.Decorate event) { + int dist = Math.min(8, Math.max(1, ConfigHandler.flowerPatchSize)); + for (int i = 0; i < ConfigHandler.flowerQuantity; i++) { + if (event.rand.nextInt(ConfigHandler.flowerPatchChance) == 0) { + int x = event.chunkX + event.rand.nextInt(16) + 8; + int z = event.chunkZ + event.rand.nextInt(16) + 8; + int y = event.world.getTopSolidOrLiquidBlock(x, z); - int color = event.rand.nextInt(16); - boolean primus = event.rand.nextInt(380) == 0; + int color = event.rand.nextInt(16); + boolean primus = event.rand.nextInt(380) == 0; - for(int j = 0; j < ConfigHandler.flowerDensity * ConfigHandler.flowerPatchChance; j++) { - int x1 = x + event.rand.nextInt(dist * 2) - dist; - int y1 = y + event.rand.nextInt(4) - event.rand.nextInt(4); - int z1 = z + event.rand.nextInt(dist * 2) - dist; + for (int j = 0; j < ConfigHandler.flowerDensity * ConfigHandler.flowerPatchChance; j++) { + int x1 = x + event.rand.nextInt(dist * 2) - dist; + int y1 = y + event.rand.nextInt(4) - event.rand.nextInt(4); + int z1 = z + event.rand.nextInt(dist * 2) - dist; - if(event.world.isAirBlock(x1, y1, z1) && (!event.world.provider.hasNoSky || y1 < 127) && ModBlocks.flower.canBlockStay(event.world, x1, y1, z1)) { - if(primus) { - event.world.setBlock(x1, y1, z1, ModBlocks.specialFlower, 0, 2); - TileSpecialFlower flower = (TileSpecialFlower) event.world.getTileEntity(x1, y1, z1); - flower.setSubTile(event.rand.nextBoolean() ? LibBlockNames.SUBTILE_NIGHTSHADE_PRIME : LibBlockNames.SUBTILE_DAYBLOOM_PRIME); - SubTileDaybloom subtile = (SubTileDaybloom) flower.getSubTile(); - subtile.setPrimusPosition(); - } else { - event.world.setBlock(x1, y1, z1, ModBlocks.flower, color, 2); - if(event.rand.nextDouble() < ConfigHandler.flowerTallChance && ((BlockModFlower) ModBlocks.flower).func_149851_a(event.world, x1, y1, z1, false)) - BlockModFlower.placeDoubleFlower(event.world, x1, y1, z1, color, 0); - } - } - } - } - } - } + if (event.world.isAirBlock(x1, y1, z1) + && (!event.world.provider.hasNoSky || y1 < 127) + && ModBlocks.flower.canBlockStay(event.world, x1, y1, z1)) { + if (primus) { + event.world.setBlock(x1, y1, z1, ModBlocks.specialFlower, 0, 2); + TileSpecialFlower flower = (TileSpecialFlower) event.world.getTileEntity(x1, y1, z1); + flower.setSubTile( + event.rand.nextBoolean() + ? LibBlockNames.SUBTILE_NIGHTSHADE_PRIME + : LibBlockNames.SUBTILE_DAYBLOOM_PRIME); + SubTileDaybloom subtile = (SubTileDaybloom) flower.getSubTile(); + subtile.setPrimusPosition(); + } else { + event.world.setBlock(x1, y1, z1, ModBlocks.flower, color, 2); + if (event.rand.nextDouble() < ConfigHandler.flowerTallChance + && ((BlockModFlower) ModBlocks.flower) + .func_149851_a(event.world, x1, y1, z1, false)) + BlockModFlower.placeDoubleFlower(event.world, x1, y1, z1, color, 0); + } + } + } + } + } + } - private void generateMushrooms(DecorateBiomeEvent.Decorate event) { - for(int i = 0; i < ConfigHandler.mushroomQuantity; i++) { - int x = event.chunkX + event.rand.nextInt(16) + 8; - int z = event.chunkZ + event.rand.nextInt(16) + 8; - int y = event.rand.nextInt(26) + 4; + private void generateMushrooms(DecorateBiomeEvent.Decorate event) { + for (int i = 0; i < ConfigHandler.mushroomQuantity; i++) { + int x = event.chunkX + event.rand.nextInt(16) + 8; + int z = event.chunkZ + event.rand.nextInt(16) + 8; + int y = event.rand.nextInt(26) + 4; - int color = event.rand.nextInt(16); - if(event.world.isAirBlock(x, y, z) && ModBlocks.mushroom.canBlockStay(event.world, x, y, z)) - event.world.setBlock(x, y, z, ModBlocks.mushroom, color, 2); - } - } -} \ No newline at end of file + int color = event.rand.nextInt(16); + if (event.world.isAirBlock(x, y, z) && ModBlocks.mushroom.canBlockStay(event.world, x, y, z)) + event.world.setBlock(x, y, z, ModBlocks.mushroom, color, 2); + } + } +} diff --git a/src/main/java/vazkii/botania/common/core/handler/ChestGenHandler.java b/src/main/java/vazkii/botania/common/core/handler/ChestGenHandler.java index b5b1315d9a..6fab64744e 100644 --- a/src/main/java/vazkii/botania/common/core/handler/ChestGenHandler.java +++ b/src/main/java/vazkii/botania/common/core/handler/ChestGenHandler.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jul 15, 2014, 3:17:00 PM (GMT)] */ package vazkii.botania.common.core.handler; @@ -17,38 +17,37 @@ public final class ChestGenHandler { - public static void init() { - String c = ChestGenHooks.BONUS_CHEST; - ChestGenHooks.addItem(c, new WeightedRandomChestContent(new ItemStack(ModItems.lexicon), 1, 1, 7)); - ChestGenHooks.addItem(c, new WeightedRandomChestContent(new ItemStack(ModItems.blackLotus), 1, 1, 1)); - - c = ChestGenHooks.STRONGHOLD_CORRIDOR; - ChestGenHooks.addItem(c, new WeightedRandomChestContent(new ItemStack(ModItems.manaResource, 1, 1), 1, 1, 8)); - ChestGenHooks.addItem(c, new WeightedRandomChestContent(new ItemStack(ModItems.manaResource, 1, 1), 1, 3, 2)); - ChestGenHooks.addItem(c, new WeightedRandomChestContent(new ItemStack(ModItems.blackLotus), 1, 1, 6)); - ChestGenHooks.addItem(c, new WeightedRandomChestContent(new ItemStack(ModItems.overgrowthSeed), 1, 1, 2)); - - c = ChestGenHooks.DUNGEON_CHEST; - ChestGenHooks.addItem(c, new WeightedRandomChestContent(new ItemStack(ModItems.manaResource, 1, 0), 1, 5, 9)); - ChestGenHooks.addItem(c, new WeightedRandomChestContent(new ItemStack(ModItems.lexicon), 1, 1, 6)); - ChestGenHooks.addItem(c, new WeightedRandomChestContent(new ItemStack(ModItems.manaBottle), 1, 1, 5)); - ChestGenHooks.addItem(c, new WeightedRandomChestContent(new ItemStack(ModItems.blackLotus), 1, 1, 6)); - ChestGenHooks.addItem(c, new WeightedRandomChestContent(new ItemStack(ModItems.overgrowthSeed), 1, 1, 2)); - - c = ChestGenHooks.PYRAMID_DESERT_CHEST; - ChestGenHooks.addItem(c, new WeightedRandomChestContent(new ItemStack(ModItems.blackLotus), 1, 1, 6)); - ChestGenHooks.addItem(c, new WeightedRandomChestContent(new ItemStack(ModItems.overgrowthSeed), 1, 1, 2)); - - c = ChestGenHooks.MINESHAFT_CORRIDOR; - ChestGenHooks.addItem(c, new WeightedRandomChestContent(new ItemStack(ModItems.blackLotus), 1, 1, 6)); - ChestGenHooks.addItem(c, new WeightedRandomChestContent(new ItemStack(ModItems.overgrowthSeed), 1, 1, 2)); - - c = ChestGenHooks.PYRAMID_JUNGLE_CHEST; - ChestGenHooks.addItem(c, new WeightedRandomChestContent(new ItemStack(ModItems.blackLotus), 1, 1, 6)); - ChestGenHooks.addItem(c, new WeightedRandomChestContent(new ItemStack(ModItems.overgrowthSeed), 1, 1, 2)); - - c = ChestGenHooks.VILLAGE_BLACKSMITH; - ChestGenHooks.addItem(c, new WeightedRandomChestContent(new ItemStack(ModItems.blackLotus), 1, 1, 6)); - } - + public static void init() { + String c = ChestGenHooks.BONUS_CHEST; + ChestGenHooks.addItem(c, new WeightedRandomChestContent(new ItemStack(ModItems.lexicon), 1, 1, 7)); + ChestGenHooks.addItem(c, new WeightedRandomChestContent(new ItemStack(ModItems.blackLotus), 1, 1, 1)); + + c = ChestGenHooks.STRONGHOLD_CORRIDOR; + ChestGenHooks.addItem(c, new WeightedRandomChestContent(new ItemStack(ModItems.manaResource, 1, 1), 1, 1, 8)); + ChestGenHooks.addItem(c, new WeightedRandomChestContent(new ItemStack(ModItems.manaResource, 1, 1), 1, 3, 2)); + ChestGenHooks.addItem(c, new WeightedRandomChestContent(new ItemStack(ModItems.blackLotus), 1, 1, 6)); + ChestGenHooks.addItem(c, new WeightedRandomChestContent(new ItemStack(ModItems.overgrowthSeed), 1, 1, 2)); + + c = ChestGenHooks.DUNGEON_CHEST; + ChestGenHooks.addItem(c, new WeightedRandomChestContent(new ItemStack(ModItems.manaResource, 1, 0), 1, 5, 9)); + ChestGenHooks.addItem(c, new WeightedRandomChestContent(new ItemStack(ModItems.lexicon), 1, 1, 6)); + ChestGenHooks.addItem(c, new WeightedRandomChestContent(new ItemStack(ModItems.manaBottle), 1, 1, 5)); + ChestGenHooks.addItem(c, new WeightedRandomChestContent(new ItemStack(ModItems.blackLotus), 1, 1, 6)); + ChestGenHooks.addItem(c, new WeightedRandomChestContent(new ItemStack(ModItems.overgrowthSeed), 1, 1, 2)); + + c = ChestGenHooks.PYRAMID_DESERT_CHEST; + ChestGenHooks.addItem(c, new WeightedRandomChestContent(new ItemStack(ModItems.blackLotus), 1, 1, 6)); + ChestGenHooks.addItem(c, new WeightedRandomChestContent(new ItemStack(ModItems.overgrowthSeed), 1, 1, 2)); + + c = ChestGenHooks.MINESHAFT_CORRIDOR; + ChestGenHooks.addItem(c, new WeightedRandomChestContent(new ItemStack(ModItems.blackLotus), 1, 1, 6)); + ChestGenHooks.addItem(c, new WeightedRandomChestContent(new ItemStack(ModItems.overgrowthSeed), 1, 1, 2)); + + c = ChestGenHooks.PYRAMID_JUNGLE_CHEST; + ChestGenHooks.addItem(c, new WeightedRandomChestContent(new ItemStack(ModItems.blackLotus), 1, 1, 6)); + ChestGenHooks.addItem(c, new WeightedRandomChestContent(new ItemStack(ModItems.overgrowthSeed), 1, 1, 2)); + + c = ChestGenHooks.VILLAGE_BLACKSMITH; + ChestGenHooks.addItem(c, new WeightedRandomChestContent(new ItemStack(ModItems.blackLotus), 1, 1, 6)); + } } diff --git a/src/main/java/vazkii/botania/common/core/handler/CommonTickHandler.java b/src/main/java/vazkii/botania/common/core/handler/CommonTickHandler.java index 5ebadc9691..96818ff975 100644 --- a/src/main/java/vazkii/botania/common/core/handler/CommonTickHandler.java +++ b/src/main/java/vazkii/botania/common/core/handler/CommonTickHandler.java @@ -2,50 +2,49 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Apr 14, 2014, 5:10:16 PM (GMT)] */ package vazkii.botania.common.core.handler; -import vazkii.botania.api.corporea.CorporeaHelper; import cpw.mods.fml.common.eventhandler.SubscribeEvent; import cpw.mods.fml.common.gameevent.TickEvent.ClientTickEvent; import cpw.mods.fml.common.gameevent.TickEvent.Phase; import cpw.mods.fml.common.gameevent.TickEvent.WorldTickEvent; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; +import vazkii.botania.api.corporea.CorporeaHelper; public final class CommonTickHandler { - @SubscribeEvent - public void onTick(WorldTickEvent event) { - if(event.phase == Phase.END) { - /*List entities = new ArrayList(event.world.loadedEntityList); - for(Entity entity : entities) - if(entity instanceof EntityItem) - TerrasteelCraftingHandler.onEntityUpdate((EntityItem) entity);*/ - - CorporeaHelper.clearCache(); - } - } + @SubscribeEvent + public void onTick(WorldTickEvent event) { + if (event.phase == Phase.END) { + /*List entities = new ArrayList(event.world.loadedEntityList); + for(Entity entity : entities) + if(entity instanceof EntityItem) + TerrasteelCraftingHandler.onEntityUpdate((EntityItem) entity);*/ - @SideOnly(Side.CLIENT) - @SubscribeEvent - public void onTick(ClientTickEvent event) { - if(event.phase == Phase.END) { - /*World world = Minecraft.getMinecraft().theWorld; - if(world != null) { - List entities = new ArrayList(world.loadedEntityList); - for(Entity entity : entities) - if(entity instanceof EntityItem) - TerrasteelCraftingHandler.onEntityUpdate((EntityItem) entity); - }*/ + CorporeaHelper.clearCache(); + } + } - CorporeaHelper.clearCache(); - } - } + @SideOnly(Side.CLIENT) + @SubscribeEvent + public void onTick(ClientTickEvent event) { + if (event.phase == Phase.END) { + /*World world = Minecraft.getMinecraft().theWorld; + if(world != null) { + List entities = new ArrayList(world.loadedEntityList); + for(Entity entity : entities) + if(entity instanceof EntityItem) + TerrasteelCraftingHandler.onEntityUpdate((EntityItem) entity); + }*/ + CorporeaHelper.clearCache(); + } + } } diff --git a/src/main/java/vazkii/botania/common/core/handler/ConfigHandler.java b/src/main/java/vazkii/botania/common/core/handler/ConfigHandler.java index ef734af58f..404f30fc88 100644 --- a/src/main/java/vazkii/botania/common/core/handler/ConfigHandler.java +++ b/src/main/java/vazkii/botania/common/core/handler/ConfigHandler.java @@ -2,20 +2,23 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jan 13, 2014, 9:01:32 PM (GMT)] */ package vazkii.botania.common.core.handler; +import cpw.mods.fml.client.event.ConfigChangedEvent; +import cpw.mods.fml.common.FMLCommonHandler; +import cpw.mods.fml.common.Loader; +import cpw.mods.fml.common.eventhandler.SubscribeEvent; import java.io.File; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; - import net.minecraft.entity.player.EntityPlayer; import net.minecraft.potion.Potion; import net.minecraft.util.ChatComponentText; @@ -24,491 +27,502 @@ import net.minecraft.util.EnumChatFormatting; import net.minecraftforge.common.config.Configuration; import net.minecraftforge.common.config.Property; -import vazkii.botania.common.Botania; import vazkii.botania.common.lib.LibMisc; import vazkii.botania.common.lib.LibPotionNames; -import cpw.mods.fml.client.event.ConfigChangedEvent; -import cpw.mods.fml.common.FMLCommonHandler; -import cpw.mods.fml.common.Loader; -import cpw.mods.fml.common.eventhandler.SubscribeEvent; public final class ConfigHandler { - public static Configuration config; - public static ConfigAdaptor adaptor; - - private static final String CATEGORY_POTIONS = "potions"; - - public static int hardcorePassiveGeneration = 72000; - - public static boolean useAdaptativeConfig = true; - - public static boolean enableDefaultRecipes = false; - - public static boolean useShaders = true; - public static boolean lexiconRotatingItems = true; - public static boolean lexiconJustifiedText = false; - public static boolean subtlePowerSystem = false; - public static boolean staticWandBeam = false; - public static boolean boundBlockWireframe = true; - public static boolean lexicon3dModel = true; - public static boolean oldPylonModel = false; - public static double flowerParticleFrequency = 0.75F; - public static boolean blockBreakParticles = true; - public static boolean blockBreakParticlesTool = true; - public static boolean elfPortalParticlesEnabled = true; - public static boolean chargingAnimationEnabled = true; - public static boolean useVanillaParticleLimiter = true; - public static boolean silentSpreaders = false; - public static boolean renderBaubles = true; - public static boolean enableSeasonalFeatures = true; - public static boolean useShiftForQuickLookup = false; - public static boolean enableArmorModels = true; - public static boolean enableFancySkybox = true; - public static boolean enableFancySkyboxInNormalWorlds = false; - - public static int manaBarHeight = 29; - public static int flightBarHeight = 49; - public static int flightBarBreathHeight = 59; - public static int glSecondaryTextureUnit = 7; - - public static boolean altFlowerTextures = false; - public static boolean matrixMode = false; - public static boolean referencesEnabled = true; - - public static int spreaderPositionShift = 1; - public static boolean flowerForceCheck = true; - public static boolean enderPickpocketEnabled = true; - - public static boolean fallenKanadeEnabled = true; - public static boolean darkQuartzEnabled = true; - public static boolean enchanterEnabled = true; - public static boolean fluxfieldEnabled = true; - public static boolean relicsEnabled = true; - public static boolean stones18Enabled = true; - public static boolean ringOfOdinFireResist = true; - public static boolean enderStuff19Enabled = true; - public static boolean invertMagnetRing = false; - public static boolean enableThaumcraftStablizers = true; - - public static int harvestLevelWeight = 2; - public static int harvestLevelBore = 3; - - public static int flowerQuantity = 0; - public static int flowerDensity = 2; - public static int flowerPatchSize = 6; - public static int flowerPatchChance = 16; - public static double flowerTallChance = 0.05; - public static int mushroomQuantity = 40; - - public static int[] flowerDimensionWhitelist = new int[]{}; - public static int[] flowerDimensionBlacklist = new int[]{}; - public static int[] mushroomDimensionWhitelist = new int[]{}; - public static int[] mushroomDimensionBlacklist = new int[]{}; - - private static boolean verifiedPotionArray = false; - private static int potionArrayLimit = 0; - - public static int potionIDSoulCross = 91; - public static int potionIDFeatherfeet = 92; - public static int potionIDEmptiness = 93; - public static int potionIDBloodthirst = 94; - public static int potionIDAllure = 95; - public static int potionIDClear = 96; - - public static void loadConfig(File configFile) { - config = new Configuration(configFile); - - config.load(); - load(); - - FMLCommonHandler.instance().bus().register(new ChangeListener()); - } - - public static void load() { - String desc; + public static Configuration config; + public static ConfigAdaptor adaptor; + + private static final String CATEGORY_POTIONS = "potions"; + + public static int hardcorePassiveGeneration = 72000; + + public static boolean useAdaptativeConfig = true; + + public static boolean enableDefaultRecipes = false; + + public static boolean useShaders = true; + public static boolean lexiconRotatingItems = true; + public static boolean lexiconJustifiedText = false; + public static boolean subtlePowerSystem = false; + public static boolean staticWandBeam = false; + public static boolean boundBlockWireframe = true; + public static boolean lexicon3dModel = true; + public static boolean oldPylonModel = false; + public static double flowerParticleFrequency = 0.75F; + public static boolean blockBreakParticles = true; + public static boolean blockBreakParticlesTool = true; + public static boolean elfPortalParticlesEnabled = true; + public static boolean chargingAnimationEnabled = true; + public static boolean useVanillaParticleLimiter = true; + public static boolean silentSpreaders = false; + public static boolean renderBaubles = true; + public static boolean enableSeasonalFeatures = true; + public static boolean useShiftForQuickLookup = false; + public static boolean enableArmorModels = true; + public static boolean enableFancySkybox = true; + public static boolean enableFancySkyboxInNormalWorlds = false; + + public static int manaBarHeight = 29; + public static int flightBarHeight = 49; + public static int flightBarBreathHeight = 59; + public static int glSecondaryTextureUnit = 7; + + public static boolean altFlowerTextures = false; + public static boolean matrixMode = false; + public static boolean referencesEnabled = true; + + public static int spreaderPositionShift = 1; + public static boolean flowerForceCheck = true; + public static boolean enderPickpocketEnabled = true; + + public static boolean fallenKanadeEnabled = true; + public static boolean darkQuartzEnabled = true; + public static boolean enchanterEnabled = true; + public static boolean fluxfieldEnabled = true; + public static boolean relicsEnabled = true; + public static boolean stones18Enabled = true; + public static boolean ringOfOdinFireResist = true; + public static boolean enderStuff19Enabled = true; + public static boolean invertMagnetRing = false; + public static boolean enableThaumcraftStablizers = true; + + public static int harvestLevelWeight = 2; + public static int harvestLevelBore = 3; + + public static int flowerQuantity = 0; + public static int flowerDensity = 2; + public static int flowerPatchSize = 6; + public static int flowerPatchChance = 16; + public static double flowerTallChance = 0.05; + public static int mushroomQuantity = 40; + + public static int[] flowerDimensionWhitelist = new int[] {}; + public static int[] flowerDimensionBlacklist = new int[] {}; + public static int[] mushroomDimensionWhitelist = new int[] {}; + public static int[] mushroomDimensionBlacklist = new int[] {}; + + private static boolean verifiedPotionArray = false; + private static int potionArrayLimit = 0; + + public static int potionIDSoulCross = 91; + public static int potionIDFeatherfeet = 92; + public static int potionIDEmptiness = 93; + public static int potionIDBloodthirst = 94; + public static int potionIDAllure = 95; + public static int potionIDClear = 96; + + public static void loadConfig(File configFile) { + config = new Configuration(configFile); + + config.load(); + load(); + + FMLCommonHandler.instance().bus().register(new ChangeListener()); + } + + public static void load() { + String desc; + + desc = + "Set this to false to disable the Adaptative Config. Adaptative Config changes any default config values from old versions to the new defaults to make sure you aren't missing out on changes because of old configs. It will not touch any values that were changed manually."; + useAdaptativeConfig = loadPropBool("adaptativeConfig.enabled", desc, useAdaptativeConfig); + adaptor = new ConfigAdaptor(useAdaptativeConfig); + + desc = "Set this to false to disable the use of shaders for some of the mod's renders."; + useShaders = loadPropBool("shaders.enabled", desc, useShaders); + + desc = "Set this to false to disable the rotating items in the petal and rune entries in the Lexica Botania."; + lexiconRotatingItems = loadPropBool("lexicon.enable.rotatingItems", desc, lexiconRotatingItems); + + desc = "Set this to true to enable justified text in the Lexica Botania's text pages."; + lexiconJustifiedText = loadPropBool("lexicon.enable.justifiedText", desc, lexiconJustifiedText); + + desc = + "Set this to true to set the power system's particles to be a lot more subtle. Good for low-end systems, if the particles are causing lag."; + subtlePowerSystem = loadPropBool("powerSystem.subtle", desc, subtlePowerSystem); + + desc = + "Set this to true to use a static wand beam that shows every single position of the burst, similar to the way it used to work on old Botania versions. Warning: Disabled by default because it may be laggy."; + staticWandBeam = loadPropBool("wandBeam.static", desc, staticWandBeam); + + desc = + "Set this to false to disable the wireframe when looking a block bound to something (spreaders, flowers, etc)."; + boundBlockWireframe = loadPropBool("boundBlock.wireframe.enabled", desc, boundBlockWireframe); + + desc = "Set this to false to disable the animated 3D render for the Lexica Botania."; + lexicon3dModel = loadPropBool("lexicon.render.3D", desc, lexicon3dModel); + + desc = "Set this to true to use the old (non-.obj, pre beta18) pylon model"; + oldPylonModel = loadPropBool("pylonModel.old", desc, oldPylonModel); + + desc = "The frequency in which particles spawn from normal (worldgen) mystical flowers"; + flowerParticleFrequency = loadPropDouble("flowerParticles.frequency", desc, flowerParticleFrequency); + + desc = "Set this to false to remove the block breaking particles from the flowers and other items in the mod."; + blockBreakParticles = loadPropBool("blockBreakingParticles.enabled", desc, blockBreakParticles); + + desc = + "Set this to false to remove the block breaking particles from the Mana Shatterer, as there can be a good amount in higher levels."; + blockBreakParticlesTool = loadPropBool("blockBreakingParticlesTool.enabled", desc, blockBreakParticlesTool); + + desc = "Set this to false to disable the particles in the elven portal."; + elfPortalParticlesEnabled = loadPropBool("elfPortal.particles.enabled", desc, elfPortalParticlesEnabled); + + desc = "Set this to false to disable the animation when an item is charging on top of a mana pool."; + chargingAnimationEnabled = loadPropBool("chargeAnimation.enabled", desc, chargingAnimationEnabled); + + desc = + "Set this to false to always display all particles regardless of the \"Particles\" setting in the Vanilla options menu."; + useVanillaParticleLimiter = loadPropBool("vanillaParticleConfig.enabled", desc, useVanillaParticleLimiter); + + desc = "Set this to true to disable the mana spreader shooting sound."; + silentSpreaders = loadPropBool("manaSpreaders.silent", desc, silentSpreaders); + + desc = "Set this to false to disable rendering of baubles in the player."; + renderBaubles = loadPropBool("baubleRender.enabled", desc, renderBaubles); + + desc = "Set this to false to disable seasonal features, such as halloween and christmas."; + enableSeasonalFeatures = loadPropBool("seasonalFeatures.enabled", desc, enableSeasonalFeatures); + + desc = "Set this to true to use Shift instead of Ctrl for the inventory lexica botania quick lookup feature."; + useShiftForQuickLookup = loadPropBool("quickLookup.useShift", desc, useShiftForQuickLookup); + + desc = "Set this to false to disable custom armor models."; + enableArmorModels = loadPropBool("armorModels.enable", desc, enableArmorModels); + + desc = "Set this to false to disable the fancy skybox in Garden of Glass."; + enableFancySkybox = loadPropBool("fancySkybox.enable", desc, enableFancySkybox); + + desc = + "Set this to true to enable the fancy skybox in non Garden of Glass worlds. (Does not require Garden of Glass loaded to use, needs 'fancySkybox.enable' to be true as well)"; + enableFancySkyboxInNormalWorlds = + loadPropBool("fancySkybox.normalWorlds", desc, enableFancySkyboxInNormalWorlds); + + desc = + "The height of the mana display bar in above the XP bar. You can change this if you have a mod that changes where the XP bar is."; + manaBarHeight = loadPropInt("manaBar.height", desc, manaBarHeight); + + desc = + "The height of the Flugel Tiara flight bar. You can change this if you have a mod that adds a bar in that spot."; + flightBarHeight = loadPropInt("flightBar.height", desc, flightBarHeight); + + desc = + "The height of the Flugel Tiara flight bar if your breath bar is shown. You can change this if you have a mod that adds a bar in that spot."; + flightBarBreathHeight = loadPropInt("flightBarBreath.height", desc, flightBarBreathHeight); + + desc = + "The GL Texture Unit to use for the secondary sampler passed in to the Lexica Botania's category button shader. DO NOT TOUCH THIS IF YOU DON'T KNOW WHAT YOU'RE DOING"; + glSecondaryTextureUnit = loadPropInt("shaders.secondaryUnit", desc, glSecondaryTextureUnit); + + desc = + "Set this to true to use alternate flower textures by Futureazoo, not all flowers are textured. http://redd.it/2b3o3f"; + altFlowerTextures = loadPropBool("flowerTextures.alt", desc, altFlowerTextures); + + desc = "Set this to true if you are the chosen one. For lovers of glitch art and just general mad people."; + matrixMode = loadPropBool("matrixMode.enabled", desc, matrixMode); + + desc = "Set this to false to disable the references in the flower tooltips. (You monster D:)"; + referencesEnabled = loadPropBool("references.enabled", desc, referencesEnabled); + + desc = + "Do not ever touch this value if not asked to. Possible symptoms of doing so include your head turning backwards, the appearance of Titans near the walls or you being trapped in a game of Sword Art Online."; + spreaderPositionShift = loadPropInt("spreader.posShift", desc, spreaderPositionShift); + + desc = + "Turn this off ONLY IF you're on an extremely large world with an exaggerated count of Mana Spreaders/Mana Pools and are experiencing TPS lag. This toggles whether flowers are strict with their checking for connecting to pools/spreaders or just check whenever possible."; + flowerForceCheck = loadPropBool("flower.forceCheck", desc, flowerForceCheck); + + desc = "Set to false to disable the ability for the Hand of Ender to pickpocket other players' ender chests."; + enderPickpocketEnabled = loadPropBool("enderPickpocket.enabled", desc, enderPickpocketEnabled); + + desc = + "Set this to false to disable the Fallen Kanade flower (gives Regeneration). This config option is here for those using Blood Magic. Note: Turning this off will not remove ones already in the world, it'll simply prevent the crafting."; + fallenKanadeEnabled = loadPropBool("fallenKanade.enabled", desc, fallenKanadeEnabled); + + desc = + "Set this to false to disable the Smokey Quartz blocks. This config option is here for those using Thaumic Tinkerer"; + darkQuartzEnabled = loadPropBool("darkQuartz.enabled", desc, darkQuartzEnabled); + + desc = + "Set this to false to disable the Mana Enchanter. Since some people find it OP or something. This only disables the entry and creation. Old ones that are already in the world will stay."; + enchanterEnabled = loadPropBool("manaEnchanter.enabled", desc, enchanterEnabled); + + desc = + "Set this to false to disable the Mana Fluxfield (generates RF from mana). This only disables the entry and creation. Old ones that are already in the world will stay."; + fluxfieldEnabled = loadPropBool("manaFluxfield.enabled", desc, fluxfieldEnabled); + + desc = + "Set this to false to disable the Relic System. This only disables the entries, drops and achievements. Old ones that are already in the world will stay."; + relicsEnabled = loadPropBool("relics.enabled", desc, relicsEnabled); + + desc = + "Set this to false to disable the 1.8 Stones available as mana alchemy recipes. This only disables the recipes and entries. Old ones that are already in the world will stay."; + stones18Enabled = loadPropBool("18stones.enabled", desc, stones18Enabled); + + desc = + "Set this to false to make the Ring of Odin not apply fire resistance. Mostly for people who use Witchery transformations."; + ringOfOdinFireResist = loadPropBool("ringOfOdin.fireResist", desc, ringOfOdinFireResist); + + desc = + "Set this to false to disable the 1.9 Ender features available as recipes. This only disables the recipes and entries. Old ones that are already in the world will stay."; + enderStuff19Enabled = loadPropBool("19enderStuff.enabled", desc, enderStuff19Enabled); + + desc = "Set this to true to invert the Ring of Magnetization's controls (from shift to stop to shift to work)"; + invertMagnetRing = loadPropBool("magnetRing.invert", desc, invertMagnetRing); + + desc = "Set this to false to disable Thaumcraft Infusion Stabilizing in botania blocks"; + enableThaumcraftStablizers = loadPropBool("thaumraftStabilizers.enabled", desc, enableThaumcraftStablizers); + + desc = "The harvest level of the Mana Lens: Weight. 3 is diamond level. Defaults to 2 (iron level)"; + harvestLevelWeight = loadPropInt("harvestLevel.weightLens", desc, harvestLevelWeight); + + desc = "The harvest level of the Mana Lens: Bore. 3 is diamond level. Defaults to 3"; + harvestLevelBore = loadPropInt("harvestLevel.boreLens", desc, harvestLevelBore); + + desc = + "The quantity of Botania flower patches to generate in the world, defaults to 2, the lower the number the less patches generate."; + flowerQuantity = loadPropInt("worldgen.flower.quantity", desc, flowerQuantity); + + desc = + "The amount of time it takes a Passive flower to decay and turn into a dead bush. Defaults to 72000, 60 minutes. Setting this to -1 disables the feature altogether."; + hardcorePassiveGeneration = loadPropInt("passiveDecay.time", desc, hardcorePassiveGeneration); + + desc = + "The density of each Botania flower patch generated, defaults to 2, the lower the number, the less each patch will have."; + adaptor.addMappingInt(0, "worldgen.flower.density", 16); + adaptor.addMappingInt(238, "worldgen.flower.density", 2); + flowerDensity = loadPropInt("worldgen.flower.density", desc, flowerDensity); + + desc = + "The size of each Botania flower patch, defaults to 6. The larger this is the farther the each patch can spread"; + flowerPatchSize = loadPropInt("worldgen.flower.patchSize", desc, flowerPatchSize); + + desc = + "The inverse chance for a Botania flower patch to be generated, defaults to 16. The higher this value is the less patches will exist and the more flower each will have."; + adaptor.addMappingInt(0, "worldgen.flower.patchChance", 4); + adaptor.addMappingInt(238, "worldgen.flower.patchChance", 16); + flowerPatchChance = loadPropInt("worldgen.flower.patchChance", desc, flowerPatchChance); + + desc = + "The chance for a Botania flower generated in a patch to be a tall flower. 0.1 is 10%, 1 is 100%. Defaults to 0.05"; + adaptor.addMappingDouble(0, "worldgen.flower.tallChance", 0.1); + adaptor.addMappingDouble(238, "worldgen.flower.tallChance", 0.05); + flowerTallChance = loadPropDouble("worldgen.flower.tallChance", desc, flowerTallChance); + + desc = + "The quantity of Botania mushrooms to generate underground, in the world, defaults to 40, the lower the number the less patches generate."; + mushroomQuantity = loadPropInt("worldgen.mushroom.quantity", desc, mushroomQuantity); - desc = "Set this to false to disable the Adaptative Config. Adaptative Config changes any default config values from old versions to the new defaults to make sure you aren't missing out on changes because of old configs. It will not touch any values that were changed manually."; - useAdaptativeConfig = loadPropBool("adaptativeConfig.enabled", desc, useAdaptativeConfig); - adaptor = new ConfigAdaptor(useAdaptativeConfig); + desc = "Enables all built-in recipes. This can be false for expert modpacks that wish to supply their own."; + enableDefaultRecipes = loadPropBool("recipes.enabled", desc, enableDefaultRecipes); - desc = "Set this to false to disable the use of shaders for some of the mod's renders."; - useShaders = loadPropBool("shaders.enabled", desc, useShaders); - - desc = "Set this to false to disable the rotating items in the petal and rune entries in the Lexica Botania."; - lexiconRotatingItems = loadPropBool("lexicon.enable.rotatingItems", desc, lexiconRotatingItems); - - desc = "Set this to true to enable justified text in the Lexica Botania's text pages."; - lexiconJustifiedText = loadPropBool("lexicon.enable.justifiedText", desc, lexiconJustifiedText); - - desc = "Set this to true to set the power system's particles to be a lot more subtle. Good for low-end systems, if the particles are causing lag."; - subtlePowerSystem = loadPropBool("powerSystem.subtle", desc, subtlePowerSystem); - - desc = "Set this to true to use a static wand beam that shows every single position of the burst, similar to the way it used to work on old Botania versions. Warning: Disabled by default because it may be laggy."; - staticWandBeam = loadPropBool("wandBeam.static", desc, staticWandBeam); - - desc = "Set this to false to disable the wireframe when looking a block bound to something (spreaders, flowers, etc)."; - boundBlockWireframe = loadPropBool("boundBlock.wireframe.enabled", desc, boundBlockWireframe); - - desc = "Set this to false to disable the animated 3D render for the Lexica Botania."; - lexicon3dModel = loadPropBool("lexicon.render.3D", desc, lexicon3dModel); + desc = "Whitelist of which dimension generates Botania flowers. Empty means any dimension can."; + flowerDimensionWhitelist = + loadPropIntArray("worldgen.flower.dimensionWhitelist", desc, flowerDimensionWhitelist); - desc = "Set this to true to use the old (non-.obj, pre beta18) pylon model"; - oldPylonModel = loadPropBool("pylonModel.old", desc, oldPylonModel); + desc = "Blacklist of which dimension generates Botania flowers."; + flowerDimensionBlacklist = + loadPropIntArray("worldgen.flower.dimensionBlacklist", desc, flowerDimensionBlacklist); - desc = "The frequency in which particles spawn from normal (worldgen) mystical flowers"; - flowerParticleFrequency = loadPropDouble("flowerParticles.frequency", desc, flowerParticleFrequency); + desc = "Whitelist of which dimension generates Botania mushrooms. Empty means any dimension can."; + mushroomDimensionWhitelist = + loadPropIntArray("worldgen.mushroom.dimensionWhitelist", desc, mushroomDimensionWhitelist); - desc = "Set this to false to remove the block breaking particles from the flowers and other items in the mod."; - blockBreakParticles = loadPropBool("blockBreakingParticles.enabled", desc, blockBreakParticles); + desc = "Blacklist of which dimension generates Botania mushrooms."; + mushroomDimensionBlacklist = + loadPropIntArray("worldgen.mushroom.dimensionBlacklist", desc, mushroomDimensionBlacklist); - desc = "Set this to false to remove the block breaking particles from the Mana Shatterer, as there can be a good amount in higher levels."; - blockBreakParticlesTool = loadPropBool("blockBreakingParticlesTool.enabled", desc, blockBreakParticlesTool); + potionIDSoulCross = loadPropPotionId(LibPotionNames.SOUL_CROSS, potionIDSoulCross); + potionIDFeatherfeet = loadPropPotionId(LibPotionNames.FEATHER_FEET, potionIDFeatherfeet); + potionIDEmptiness = loadPropPotionId(LibPotionNames.EMPTINESS, potionIDEmptiness); + potionIDBloodthirst = loadPropPotionId(LibPotionNames.BLOODTHIRST, potionIDBloodthirst); + potionIDAllure = loadPropPotionId(LibPotionNames.ALLURE, potionIDAllure); + potionIDClear = loadPropPotionId(LibPotionNames.CLEAR, potionIDClear); - desc = "Set this to false to disable the particles in the elven portal."; - elfPortalParticlesEnabled = loadPropBool("elfPortal.particles.enabled", desc, elfPortalParticlesEnabled); + if (config.hasChanged()) config.save(); + } - desc = "Set this to false to disable the animation when an item is charging on top of a mana pool."; - chargingAnimationEnabled = loadPropBool("chargeAnimation.enabled", desc, chargingAnimationEnabled); + public static void loadPostInit() { + SheddingHandler.loadFromConfig(config); - desc = "Set this to false to always display all particles regardless of the \"Particles\" setting in the Vanilla options menu."; - useVanillaParticleLimiter = loadPropBool("vanillaParticleConfig.enabled", desc, useVanillaParticleLimiter); + if (config.hasChanged()) config.save(); + } - desc = "Set this to true to disable the mana spreader shooting sound."; - silentSpreaders = loadPropBool("manaSpreaders.silent", desc, silentSpreaders); + public static int loadPropInt(String propName, String desc, int default_) { + Property prop = config.get(Configuration.CATEGORY_GENERAL, propName, default_); + prop.comment = desc; - desc = "Set this to false to disable rendering of baubles in the player."; - renderBaubles = loadPropBool("baubleRender.enabled", desc, renderBaubles); + if (adaptor != null) adaptor.adaptPropertyInt(prop, prop.getInt(default_)); - desc = "Set this to false to disable seasonal features, such as halloween and christmas."; - enableSeasonalFeatures = loadPropBool("seasonalFeatures.enabled", desc, enableSeasonalFeatures); + return prop.getInt(default_); + } - desc = "Set this to true to use Shift instead of Ctrl for the inventory lexica botania quick lookup feature."; - useShiftForQuickLookup = loadPropBool("quickLookup.useShift", desc, useShiftForQuickLookup); + public static double loadPropDouble(String propName, String desc, double default_) { + Property prop = config.get(Configuration.CATEGORY_GENERAL, propName, default_); + prop.comment = desc; - desc = "Set this to false to disable custom armor models."; - enableArmorModels = loadPropBool("armorModels.enable", desc, enableArmorModels); + if (adaptor != null) adaptor.adaptPropertyDouble(prop, prop.getDouble(default_)); - desc = "Set this to false to disable the fancy skybox in Garden of Glass."; - enableFancySkybox = loadPropBool("fancySkybox.enable", desc, enableFancySkybox); - - desc = "Set this to true to enable the fancy skybox in non Garden of Glass worlds. (Does not require Garden of Glass loaded to use, needs 'fancySkybox.enable' to be true as well)"; - enableFancySkyboxInNormalWorlds = loadPropBool("fancySkybox.normalWorlds", desc, enableFancySkyboxInNormalWorlds); - - desc = "The height of the mana display bar in above the XP bar. You can change this if you have a mod that changes where the XP bar is."; - manaBarHeight = loadPropInt("manaBar.height", desc, manaBarHeight); + return prop.getDouble(default_); + } - desc = "The height of the Flugel Tiara flight bar. You can change this if you have a mod that adds a bar in that spot."; - flightBarHeight = loadPropInt("flightBar.height", desc, flightBarHeight); + public static boolean loadPropBool(String propName, String desc, boolean default_) { + Property prop = config.get(Configuration.CATEGORY_GENERAL, propName, default_); + prop.comment = desc; - desc = "The height of the Flugel Tiara flight bar if your breath bar is shown. You can change this if you have a mod that adds a bar in that spot."; - flightBarBreathHeight = loadPropInt("flightBarBreath.height", desc, flightBarBreathHeight); - - desc = "The GL Texture Unit to use for the secondary sampler passed in to the Lexica Botania's category button shader. DO NOT TOUCH THIS IF YOU DON'T KNOW WHAT YOU'RE DOING"; - glSecondaryTextureUnit = loadPropInt("shaders.secondaryUnit", desc, glSecondaryTextureUnit); + if (adaptor != null) adaptor.adaptPropertyBool(prop, prop.getBoolean(default_)); - desc = "Set this to true to use alternate flower textures by Futureazoo, not all flowers are textured. http://redd.it/2b3o3f"; - altFlowerTextures = loadPropBool("flowerTextures.alt", desc, altFlowerTextures); + return prop.getBoolean(default_); + } - desc = "Set this to true if you are the chosen one. For lovers of glitch art and just general mad people."; - matrixMode = loadPropBool("matrixMode.enabled", desc, matrixMode); + public static int[] loadPropIntArray(String propName, String desc, int[] intArray) { + Property prop = config.get(Configuration.CATEGORY_GENERAL, propName, intArray); + prop.comment = desc; - desc = "Set this to false to disable the references in the flower tooltips. (You monster D:)"; - referencesEnabled = loadPropBool("references.enabled", desc, referencesEnabled); + if (adaptor != null) adaptor.adaptPropertyIntArray(prop, prop.getIntList()); - desc = "Do not ever touch this value if not asked to. Possible symptoms of doing so include your head turning backwards, the appearance of Titans near the walls or you being trapped in a game of Sword Art Online."; - spreaderPositionShift = loadPropInt("spreader.posShift", desc, spreaderPositionShift); + return prop.getIntList(); + } - desc = "Turn this off ONLY IF you're on an extremely large world with an exaggerated count of Mana Spreaders/Mana Pools and are experiencing TPS lag. This toggles whether flowers are strict with their checking for connecting to pools/spreaders or just check whenever possible."; - flowerForceCheck = loadPropBool("flower.forceCheck", desc, flowerForceCheck); + public static int loadPropPotionId(String propName, int default_) { + if (!verifiedPotionArray) verifyPotionArray(); - desc = "Set to false to disable the ability for the Hand of Ender to pickpocket other players' ender chests."; - enderPickpocketEnabled = loadPropBool("enderPickpocket.enabled", desc, enderPickpocketEnabled); + Property prop = config.get(CATEGORY_POTIONS, propName, default_); + int val = prop.getInt(default_); + if (val > potionArrayLimit) { + val = default_; + prop.set(default_); + } - desc = "Set this to false to disable the Fallen Kanade flower (gives Regeneration). This config option is here for those using Blood Magic. Note: Turning this off will not remove ones already in the world, it'll simply prevent the crafting."; - fallenKanadeEnabled = loadPropBool("fallenKanade.enabled", desc, fallenKanadeEnabled); + return val; + } - desc = "Set this to false to disable the Smokey Quartz blocks. This config option is here for those using Thaumic Tinkerer"; - darkQuartzEnabled = loadPropBool("darkQuartz.enabled", desc, darkQuartzEnabled); + private static void verifyPotionArray() { + if (Loader.isModLoaded("DragonAPI")) potionArrayLimit = Potion.potionTypes.length; + else if (Loader.isModLoaded("hodgepodge")) potionArrayLimit = 255; + else potionArrayLimit = 127; - desc = "Set this to false to disable the Mana Enchanter. Since some people find it OP or something. This only disables the entry and creation. Old ones that are already in the world will stay."; - enchanterEnabled = loadPropBool("manaEnchanter.enabled", desc, enchanterEnabled); + verifiedPotionArray = true; + } - desc = "Set this to false to disable the Mana Fluxfield (generates RF from mana). This only disables the entry and creation. Old ones that are already in the world will stay."; - fluxfieldEnabled = loadPropBool("manaFluxfield.enabled", desc, fluxfieldEnabled); + public static class ConfigAdaptor { - desc = "Set this to false to disable the Relic System. This only disables the entries, drops and achievements. Old ones that are already in the world will stay."; - relicsEnabled = loadPropBool("relics.enabled", desc, relicsEnabled); + private boolean enabled; - desc = "Set this to false to disable the 1.8 Stones available as mana alchemy recipes. This only disables the recipes and entries. Old ones that are already in the world will stay."; - stones18Enabled = loadPropBool("18stones.enabled", desc, stones18Enabled); + private Map> adaptableValues = new HashMap(); + private List changes = new ArrayList(); - desc = "Set this to false to make the Ring of Odin not apply fire resistance. Mostly for people who use Witchery transformations."; - ringOfOdinFireResist = loadPropBool("ringOfOdin.fireResist", desc, ringOfOdinFireResist); + public ConfigAdaptor(boolean enabled) { + this.enabled = enabled; + } - desc = "Set this to false to disable the 1.9 Ender features available as recipes. This only disables the recipes and entries. Old ones that are already in the world will stay."; - enderStuff19Enabled = loadPropBool("19enderStuff.enabled", desc, enderStuff19Enabled); + public void adaptProperty(Property prop, T val) { + if (!enabled) return; - desc = "Set this to true to invert the Ring of Magnetization's controls (from shift to stop to shift to work)"; - invertMagnetRing = loadPropBool("magnetRing.invert", desc, invertMagnetRing); + String name = prop.getName(); - desc = "Set this to false to disable Thaumcraft Infusion Stabilizing in botania blocks"; - enableThaumcraftStablizers = loadPropBool("thaumraftStabilizers.enabled", desc, enableThaumcraftStablizers); - - desc = "The harvest level of the Mana Lens: Weight. 3 is diamond level. Defaults to 2 (iron level)"; - harvestLevelWeight = loadPropInt("harvestLevel.weightLens", desc, harvestLevelWeight); + if (!adaptableValues.containsKey(name)) return; - desc = "The harvest level of the Mana Lens: Bore. 3 is diamond level. Defaults to 3"; - harvestLevelBore = loadPropInt("harvestLevel.boreLens", desc, harvestLevelBore); - - desc = "The quantity of Botania flower patches to generate in the world, defaults to 2, the lower the number the less patches generate."; - flowerQuantity = loadPropInt("worldgen.flower.quantity", desc, flowerQuantity); + AdaptableValue bestValue = null; + for (AdaptableValue value : adaptableValues.get(name)) { + if (bestValue == null || value.version > bestValue.version) bestValue = value; + } - desc = "The amount of time it takes a Passive flower to decay and turn into a dead bush. Defaults to 72000, 60 minutes. Setting this to -1 disables the feature altogether."; - hardcorePassiveGeneration = loadPropInt("passiveDecay.time", desc, hardcorePassiveGeneration); - - desc = "The density of each Botania flower patch generated, defaults to 2, the lower the number, the less each patch will have."; - adaptor.addMappingInt(0, "worldgen.flower.density", 16); - adaptor.addMappingInt(238, "worldgen.flower.density", 2); - flowerDensity = loadPropInt("worldgen.flower.density", desc, flowerDensity); + if (bestValue != null) { + T expected = bestValue.value; + T def = (T) prop.getDefault(); - desc = "The size of each Botania flower patch, defaults to 6. The larger this is the farther the each patch can spread"; - flowerPatchSize = loadPropInt("worldgen.flower.patchSize", desc, flowerPatchSize); + if (areEqualNumbers(val, expected) && !areEqualNumbers(val, def)) { + prop.setValue(def.toString()); + changes.add(" " + prop.getName() + ": " + val + " -> " + def); + } + } + } - desc = "The inverse chance for a Botania flower patch to be generated, defaults to 16. The higher this value is the less patches will exist and the more flower each will have."; - adaptor.addMappingInt(0, "worldgen.flower.patchChance", 4); - adaptor.addMappingInt(238, "worldgen.flower.patchChance", 16); - flowerPatchChance = loadPropInt("worldgen.flower.patchChance", desc, flowerPatchChance); + public void addMapping(int version, String key, T val) { + if (!enabled) return; - desc = "The chance for a Botania flower generated in a patch to be a tall flower. 0.1 is 10%, 1 is 100%. Defaults to 0.05"; - adaptor.addMappingDouble(0, "worldgen.flower.tallChance", 0.1); - adaptor.addMappingDouble(238, "worldgen.flower.tallChance", 0.05); - flowerTallChance = loadPropDouble("worldgen.flower.tallChance", desc, flowerTallChance); + AdaptableValue adapt = new AdaptableValue(version, val); + if (!adaptableValues.containsKey(key)) { + ArrayList list = new ArrayList(); + adaptableValues.put(key, list); + } - desc = "The quantity of Botania mushrooms to generate underground, in the world, defaults to 40, the lower the number the less patches generate."; - mushroomQuantity = loadPropInt("worldgen.mushroom.quantity", desc, mushroomQuantity); + List list = adaptableValues.get(key); + list.add(adapt); + } - desc = "Enables all built-in recipes. This can be false for expert modpacks that wish to supply their own."; - enableDefaultRecipes = loadPropBool("recipes.enabled", desc, enableDefaultRecipes); + public boolean areEqualNumbers(Object v1, Object v2) { + double epsilon = 1.0E-6; + float v1f = ((Number) v1).floatValue(); + float v2f; - desc = "Whitelist of which dimension generates Botania flowers. Empty means any dimension can."; - flowerDimensionWhitelist = loadPropIntArray("worldgen.flower.dimensionWhitelist", desc, flowerDimensionWhitelist); + if (v2 instanceof String) v2f = Float.parseFloat((String) v2); + else v2f = ((Number) v2).floatValue(); - desc = "Blacklist of which dimension generates Botania flowers."; - flowerDimensionBlacklist = loadPropIntArray("worldgen.flower.dimensionBlacklist", desc, flowerDimensionBlacklist); + return Math.abs(v1f - v2f) < epsilon; + } - desc = "Whitelist of which dimension generates Botania mushrooms. Empty means any dimension can."; - mushroomDimensionWhitelist = loadPropIntArray("worldgen.mushroom.dimensionWhitelist", desc, mushroomDimensionWhitelist); + public void tellChanges(EntityPlayer player) { + if (changes.size() == 0) return; - desc = "Blacklist of which dimension generates Botania mushrooms."; - mushroomDimensionBlacklist = loadPropIntArray("worldgen.mushroom.dimensionBlacklist", desc, mushroomDimensionBlacklist); + player.addChatComponentMessage(new ChatComponentTranslation("botaniamisc.adaptativeConfigChanges") + .setChatStyle(new ChatStyle().setColor(EnumChatFormatting.GOLD))); + for (String change : changes) + player.addChatMessage(new ChatComponentText(change) + .setChatStyle(new ChatStyle().setColor(EnumChatFormatting.LIGHT_PURPLE))); + } - potionIDSoulCross = loadPropPotionId(LibPotionNames.SOUL_CROSS, potionIDSoulCross); - potionIDFeatherfeet = loadPropPotionId(LibPotionNames.FEATHER_FEET, potionIDFeatherfeet); - potionIDEmptiness = loadPropPotionId(LibPotionNames.EMPTINESS, potionIDEmptiness); - potionIDBloodthirst = loadPropPotionId(LibPotionNames.BLOODTHIRST, potionIDBloodthirst); - potionIDAllure = loadPropPotionId(LibPotionNames.ALLURE, potionIDAllure); - potionIDClear = loadPropPotionId(LibPotionNames.CLEAR, potionIDClear); + public void addMappingInt(int version, String key, int val) { + this.addMapping(version, key, val); + } - if(config.hasChanged()) - config.save(); - } + public void addMappingDouble(int version, String key, double val) { + this.addMapping(version, key, val); + } - public static void loadPostInit() { - SheddingHandler.loadFromConfig(config); + public void addMappingBool(int version, String key, boolean val) { + this.addMapping(version, key, val); + } - if(config.hasChanged()) - config.save(); - } + public void adaptPropertyInt(Property prop, int val) { + this.adaptProperty(prop, val); + } - public static int loadPropInt(String propName, String desc, int default_) { - Property prop = config.get(Configuration.CATEGORY_GENERAL, propName, default_); - prop.comment = desc; + public void adaptPropertyDouble(Property prop, double val) { + this.adaptProperty(prop, val); + } - if(adaptor != null) - adaptor.adaptPropertyInt(prop, prop.getInt(default_)); + public void adaptPropertyBool(Property prop, boolean val) { + this.adaptProperty(prop, val); + } - return prop.getInt(default_); - } + public void adaptPropertyIntArray(Property prop, int[] val) { + this.adaptProperty(prop, val); + } - public static double loadPropDouble(String propName, String desc, double default_) { - Property prop = config.get(Configuration.CATEGORY_GENERAL, propName, default_); - prop.comment = desc; + public static class AdaptableValue { - if(adaptor != null) - adaptor.adaptPropertyDouble(prop, prop.getDouble(default_)); - - return prop.getDouble(default_); - } - - public static boolean loadPropBool(String propName, String desc, boolean default_) { - Property prop = config.get(Configuration.CATEGORY_GENERAL, propName, default_); - prop.comment = desc; - - if(adaptor != null) - adaptor.adaptPropertyBool(prop, prop.getBoolean(default_)); - - return prop.getBoolean(default_); - } - - public static int[] loadPropIntArray(String propName, String desc, int[] intArray) { - Property prop = config.get(Configuration.CATEGORY_GENERAL, propName, intArray); - prop.comment = desc; - - if(adaptor != null) - adaptor.adaptPropertyIntArray(prop, prop.getIntList()); - - return prop.getIntList(); - } - - public static int loadPropPotionId(String propName, int default_) { - if(!verifiedPotionArray) - verifyPotionArray(); - - Property prop = config.get(CATEGORY_POTIONS, propName, default_); - int val = prop.getInt(default_); - if(val > potionArrayLimit) { - val = default_; - prop.set(default_); - } - - return val; - } - - private static void verifyPotionArray() { - if(Loader.isModLoaded("DragonAPI")) - potionArrayLimit = Potion.potionTypes.length; - else if(Loader.isModLoaded("hodgepodge")) - potionArrayLimit = 255; - else - potionArrayLimit = 127; - - verifiedPotionArray = true; - } - - public static class ConfigAdaptor { + public final int version; + public final T value; + public final Class valueType; - private boolean enabled; - - private Map> adaptableValues = new HashMap(); - private List changes = new ArrayList(); - - public ConfigAdaptor(boolean enabled) { - this.enabled = enabled; - } - - public void adaptProperty(Property prop, T val) { - if(!enabled) - return; - - String name = prop.getName(); - - if(!adaptableValues.containsKey(name)) - return; - - AdaptableValue bestValue = null; - for(AdaptableValue value : adaptableValues.get(name)) { - if(bestValue == null || value.version > bestValue.version) - bestValue = value; - } - - if(bestValue != null) { - T expected = bestValue.value; - T def = (T) prop.getDefault(); - - if(areEqualNumbers(val, expected) && !areEqualNumbers(val, def)) { - prop.setValue(def.toString()); - changes.add(" " + prop.getName() + ": " + val + " -> " + def); - } - } - } - - public void addMapping(int version, String key, T val) { - if(!enabled) - return; - - AdaptableValue adapt = new AdaptableValue(version, val); - if(!adaptableValues.containsKey(key)) { - ArrayList list = new ArrayList(); - adaptableValues.put(key, list); - } - - List list = adaptableValues.get(key); - list.add(adapt); - } - - public boolean areEqualNumbers(Object v1, Object v2) { - double epsilon = 1.0E-6; - float v1f = ((Number) v1).floatValue(); - float v2f; - - if(v2 instanceof String) - v2f = Float.parseFloat((String) v2); - else v2f = ((Number) v2).floatValue(); - - return Math.abs(v1f - v2f) < epsilon; - } - - public void tellChanges(EntityPlayer player) { - if(changes.size() == 0) - return; - - player.addChatComponentMessage(new ChatComponentTranslation("botaniamisc.adaptativeConfigChanges").setChatStyle(new ChatStyle().setColor(EnumChatFormatting.GOLD))); - for(String change : changes) - player.addChatMessage(new ChatComponentText(change).setChatStyle(new ChatStyle().setColor(EnumChatFormatting.LIGHT_PURPLE))); - } - - public void addMappingInt(int version, String key, int val) { - this.addMapping(version, key, val); - } - - public void addMappingDouble(int version, String key, double val) { - this.addMapping(version, key, val); - } - - public void addMappingBool(int version, String key, boolean val) { - this.addMapping(version, key, val); - } - - public void adaptPropertyInt(Property prop, int val) { - this.adaptProperty(prop, val); - } - - public void adaptPropertyDouble(Property prop, double val) { - this.adaptProperty(prop, val); - } - - public void adaptPropertyBool(Property prop, boolean val) { - this.adaptProperty(prop, val); - } - - public void adaptPropertyIntArray(Property prop, int[] val) { - this.adaptProperty(prop, val); - } - - public static class AdaptableValue { - - public final int version; - public final T value; - public final Class valueType; - - public AdaptableValue(int version, T value) { - this.version = version; - this.value = value; - valueType = (Class) value.getClass(); - } - - } - - } - - public static class ChangeListener { - - @SubscribeEvent - public void onConfigChanged(ConfigChangedEvent.OnConfigChangedEvent eventArgs) { - if(eventArgs.modID.equals(LibMisc.MOD_ID)) - load(); - } - - } + public AdaptableValue(int version, T value) { + this.version = version; + this.value = value; + valueType = (Class) value.getClass(); + } + } + } + + public static class ChangeListener { + + @SubscribeEvent + public void onConfigChanged(ConfigChangedEvent.OnConfigChangedEvent eventArgs) { + if (eventArgs.modID.equals(LibMisc.MOD_ID)) load(); + } + } } diff --git a/src/main/java/vazkii/botania/common/core/handler/IMCHandler.java b/src/main/java/vazkii/botania/common/core/handler/IMCHandler.java index a12ad98f9f..cd7769b92c 100644 --- a/src/main/java/vazkii/botania/common/core/handler/IMCHandler.java +++ b/src/main/java/vazkii/botania/common/core/handler/IMCHandler.java @@ -1,24 +1,24 @@ package vazkii.botania.common.core.handler; +import com.google.common.collect.ImmutableList; +import cpw.mods.fml.common.event.FMLInterModComms.IMCMessage; import java.util.Iterator; - import vazkii.botania.common.item.equipment.bauble.ItemMagnetRing; import vazkii.botania.common.lib.LibMisc; -import com.google.common.collect.ImmutableList; - -import cpw.mods.fml.common.event.FMLInterModComms.IMCMessage; - public final class IMCHandler { - public static void processMessages(ImmutableList messageList) { - Iterator iterator = messageList.iterator(); - while(iterator.hasNext()) { - IMCMessage message = iterator.next(); - if(message != null && message.key != null && message.key.equals(LibMisc.BLACKLIST_ITEM) && message.isStringMessage()) { - String value = message.getStringValue(); - ItemMagnetRing.addItemToBlackList(value); - } - } - } + public static void processMessages(ImmutableList messageList) { + Iterator iterator = messageList.iterator(); + while (iterator.hasNext()) { + IMCMessage message = iterator.next(); + if (message != null + && message.key != null + && message.key.equals(LibMisc.BLACKLIST_ITEM) + && message.isStringMessage()) { + String value = message.getStringValue(); + ItemMagnetRing.addItemToBlackList(value); + } + } + } } diff --git a/src/main/java/vazkii/botania/common/core/handler/InternalMethodHandler.java b/src/main/java/vazkii/botania/common/core/handler/InternalMethodHandler.java index d157b494ff..9197fa06e3 100644 --- a/src/main/java/vazkii/botania/common/core/handler/InternalMethodHandler.java +++ b/src/main/java/vazkii/botania/common/core/handler/InternalMethodHandler.java @@ -2,17 +2,21 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jan 14, 2014, 6:44:59 PM (GMT)] */ package vazkii.botania.common.core.handler; +import baubles.common.lib.PlayerHandler; +import baubles.common.network.PacketHandler; +import baubles.common.network.PacketSyncBauble; +import buildcraft.api.transport.IPipeTile; +import cpw.mods.fml.common.Optional; import java.util.ArrayList; import java.util.List; - import net.minecraft.block.Block; import net.minecraft.client.gui.ScaledResolution; import net.minecraft.client.renderer.texture.IIconRegister; @@ -68,227 +72,231 @@ import vazkii.botania.common.lexicon.page.PagePetalRecipe; import vazkii.botania.common.lexicon.page.PageRuneRecipe; import vazkii.botania.common.lexicon.page.PageText; -import baubles.common.lib.PlayerHandler; -import baubles.common.network.PacketHandler; -import baubles.common.network.PacketSyncBauble; -import buildcraft.api.transport.IPipeTile; -import cpw.mods.fml.common.Optional; public class InternalMethodHandler extends DummyMethodHandler { - @Override - public LexiconPage textPage(String key) { - return new PageText(key); - } - - @Override - public LexiconPage elfPaperTextPage(String key) { - return new PageLoreText(key); - } - - @Override - public LexiconPage imagePage(String key, String resource) { - return new PageImage(key, resource); - } - - @Override - public LexiconPage craftingRecipesPage(String key, List recipes) { - return new PageCraftingRecipe(key, recipes); - } - - @Override - public LexiconPage craftingRecipePage(String key, IRecipe recipe) { - return new PageCraftingRecipe(key, recipe); - } - - @Override - public IIcon getSubTileIconForName(String name) { - IIcon icon = (ConfigHandler.altFlowerTextures ? BlockSpecialFlower.iconsAlt : BlockSpecialFlower.icons).get(name); - return icon == null ? Blocks.red_flower.getIcon(0, 0) : icon; - } - - @Override - public void registerBasicSignatureIcons(String name, IIconRegister register) { - IIcon normal = IconHelper.forName(register, name); - IIcon alt = IconHelper.forName(register, BlockModFlower.ALT_DIR + "/" + name); - BlockSpecialFlower.icons.put(name, normal); - BlockSpecialFlower.iconsAlt.put(name, alt == null ? normal : alt); - } - - @Override - public LexiconPage petalRecipesPage(String key, List recipes) { - return new PagePetalRecipe(key, recipes); - } - - @Override - public LexiconPage petalRecipePage(String key, RecipePetals recipe) { - return new PagePetalRecipe(key, recipe); - } - - @Override - public LexiconPage runeRecipesPage(String key, List recipes) { - return new PageRuneRecipe(key, recipes); - } - - @Override - public LexiconPage runeRecipePage(String key, RecipeRuneAltar recipe) { - return new PageRuneRecipe(key, recipe); - } - - @Override - public LexiconPage manaInfusionRecipesPage(String key, List recipes) { - return new PageManaInfusionRecipe(key, recipes); - } - - @Override - public LexiconPage manaInfusionRecipePage(String key, RecipeManaInfusion recipe) { - return new PageManaInfusionRecipe(key, recipe); - } - - @Override - public LexiconPage elvenTradePage(String key, List recipes) { - return new PageElvenRecipe(key, recipes); - } - - @Override - public LexiconPage elvenTradesPage(String key, RecipeElvenTrade recipe) { - return new PageElvenRecipe(key, recipe); - } - - @Override - public LexiconPage brewPage(String key, String bottomText, RecipeBrew recipe) { - return new PageBrew(recipe, key, bottomText); - } - - @Override - public LexiconPage multiblockPage(String key, MultiblockSet mb) { - return new PageMultiblock(key, mb); - } - - @Override - public ItemStack getSubTileAsStack(String subTile) { - return ItemBlockSpecialFlower.ofType(subTile); - } - - @Override - public ItemStack getSubTileAsFloatingFlowerStack(String subTile) { - return ItemBlockSpecialFlower.ofType(new ItemStack(ModBlocks.floatingSpecialFlower), subTile); - } - - @Override - public String getStackSubTileKey(ItemStack stack) { - return ItemBlockSpecialFlower.getType(stack); - } - - @Override - public IManaNetwork getManaNetworkInstance() { - return ManaNetworkHandler.instance; - } - - @Override - public IInventory getBaublesInventory(EntityPlayer player) { - return PlayerHandler.getPlayerBaubles(player); - } - - @Override - public void drawSimpleManaHUD(int color, int mana, int maxMana, String name, ScaledResolution res) { - HUDHandler.drawSimpleManaHUD(color, mana, maxMana, name, res); - } - - @Override - public void drawComplexManaHUD(int color, int mana, int maxMana, String name, ScaledResolution res, ItemStack bindDisplay, boolean properlyBound) { - HUDHandler.drawComplexManaHUD(color, mana, maxMana, name, res, bindDisplay, properlyBound); - } - - @Override - public ItemStack getBindDisplayForFlowerType(SubTileEntity e) { - return e instanceof SubTileGenerating ? new ItemStack(ModBlocks.spreader) : e instanceof SubTileFunctional ? new ItemStack(ModBlocks.pool) : new ItemStack(ModItems.twigWand); - } - - @Override - public void renderLexiconText(int x, int y, int width, int height, String unlocalizedText) { - PageText.renderText(x, y, width, height, unlocalizedText); - } - - @Override - public void sparkleFX(World world, double x, double y, double z, float r, float g, float b, float size, int m) { - Botania.proxy.sparkleFX(world, x, y, z, r, g, b, size, m); - } - - @Override - public ResourceLocation getDefaultBossBarTexture() { - return BossBarHandler.defaultBossBar; - } - - @Override - public void setBossStatus(IBotaniaBoss status) { - BossBarHandler.setCurrentBoss(status); - } - - @Override - public boolean shouldForceCheck() { - return ConfigHandler.flowerForceCheck; - } - - @Override - public int getPassiveFlowerDecay() { - return ConfigHandler.hardcorePassiveGeneration; - } - - @Override - @Optional.Method(modid = "BuildCraft|Transport") - public boolean isBuildcraftPipe(TileEntity tile) { - return tile instanceof IPipeTile; - } - - @Override - public void breakOnAllCursors(EntityPlayer player, Item item, ItemStack stack, int x, int y, int z, int side) { - ItemLokiRing.breakOnAllCursors(player, item, stack, x, y, z, side); - } - - @Override - public boolean hasSolegnoliaAround(Entity e) { - return SubTileSolegnolia.hasSolegnoliaAround(e); - } - - @Override - public long getWorldElapsedTicks() { - return Botania.proxy.getWorldElapsedTicks(); - } - - @Override - public boolean isBotaniaFlower(World world, int x, int y, int z) { - Block block = world.getBlock(x, y, z); - return block == ModBlocks.flower || block == ModBlocks.shinyFlower || block == ModBlocks.specialFlower; - } - - @Override - public void sendBaubleUpdatePacket(EntityPlayer player, int slot) { - if(player instanceof EntityPlayerMP) - PacketHandler.INSTANCE.sendTo(new PacketSyncBauble(player, slot), (EntityPlayerMP) player); - } - - - @Override - public List wrapInventory(List inventories) { - ArrayList arrayList = new ArrayList(); - for(IInventory inv : inventories) { - ICorporeaSpark spark = CorporeaHelper.getSparkForInventory(inv); - IWrappedInventory wrapped = null; - // try StorageDrawers integration - if(Botania.storageDrawersLoaded) { - wrapped = WrappedStorageDrawers.wrap(inv, spark); - } - // try DeepStorageUnit - if(wrapped == null) { - wrapped = WrappedDeepStorage.wrap(inv, spark); - } - // last chance - this will always work - if(wrapped == null) { - wrapped = WrappedIInventory.wrap(inv, spark); - } - arrayList.add(wrapped); - } - return arrayList; - } + @Override + public LexiconPage textPage(String key) { + return new PageText(key); + } + + @Override + public LexiconPage elfPaperTextPage(String key) { + return new PageLoreText(key); + } + + @Override + public LexiconPage imagePage(String key, String resource) { + return new PageImage(key, resource); + } + + @Override + public LexiconPage craftingRecipesPage(String key, List recipes) { + return new PageCraftingRecipe(key, recipes); + } + + @Override + public LexiconPage craftingRecipePage(String key, IRecipe recipe) { + return new PageCraftingRecipe(key, recipe); + } + + @Override + public IIcon getSubTileIconForName(String name) { + IIcon icon = + (ConfigHandler.altFlowerTextures ? BlockSpecialFlower.iconsAlt : BlockSpecialFlower.icons).get(name); + return icon == null ? Blocks.red_flower.getIcon(0, 0) : icon; + } + + @Override + public void registerBasicSignatureIcons(String name, IIconRegister register) { + IIcon normal = IconHelper.forName(register, name); + IIcon alt = IconHelper.forName(register, BlockModFlower.ALT_DIR + "/" + name); + BlockSpecialFlower.icons.put(name, normal); + BlockSpecialFlower.iconsAlt.put(name, alt == null ? normal : alt); + } + + @Override + public LexiconPage petalRecipesPage(String key, List recipes) { + return new PagePetalRecipe(key, recipes); + } + + @Override + public LexiconPage petalRecipePage(String key, RecipePetals recipe) { + return new PagePetalRecipe(key, recipe); + } + + @Override + public LexiconPage runeRecipesPage(String key, List recipes) { + return new PageRuneRecipe(key, recipes); + } + + @Override + public LexiconPage runeRecipePage(String key, RecipeRuneAltar recipe) { + return new PageRuneRecipe(key, recipe); + } + + @Override + public LexiconPage manaInfusionRecipesPage(String key, List recipes) { + return new PageManaInfusionRecipe(key, recipes); + } + + @Override + public LexiconPage manaInfusionRecipePage(String key, RecipeManaInfusion recipe) { + return new PageManaInfusionRecipe(key, recipe); + } + + @Override + public LexiconPage elvenTradePage(String key, List recipes) { + return new PageElvenRecipe(key, recipes); + } + + @Override + public LexiconPage elvenTradesPage(String key, RecipeElvenTrade recipe) { + return new PageElvenRecipe(key, recipe); + } + + @Override + public LexiconPage brewPage(String key, String bottomText, RecipeBrew recipe) { + return new PageBrew(recipe, key, bottomText); + } + + @Override + public LexiconPage multiblockPage(String key, MultiblockSet mb) { + return new PageMultiblock(key, mb); + } + + @Override + public ItemStack getSubTileAsStack(String subTile) { + return ItemBlockSpecialFlower.ofType(subTile); + } + + @Override + public ItemStack getSubTileAsFloatingFlowerStack(String subTile) { + return ItemBlockSpecialFlower.ofType(new ItemStack(ModBlocks.floatingSpecialFlower), subTile); + } + + @Override + public String getStackSubTileKey(ItemStack stack) { + return ItemBlockSpecialFlower.getType(stack); + } + + @Override + public IManaNetwork getManaNetworkInstance() { + return ManaNetworkHandler.instance; + } + + @Override + public IInventory getBaublesInventory(EntityPlayer player) { + return PlayerHandler.getPlayerBaubles(player); + } + + @Override + public void drawSimpleManaHUD(int color, int mana, int maxMana, String name, ScaledResolution res) { + HUDHandler.drawSimpleManaHUD(color, mana, maxMana, name, res); + } + + @Override + public void drawComplexManaHUD( + int color, + int mana, + int maxMana, + String name, + ScaledResolution res, + ItemStack bindDisplay, + boolean properlyBound) { + HUDHandler.drawComplexManaHUD(color, mana, maxMana, name, res, bindDisplay, properlyBound); + } + + @Override + public ItemStack getBindDisplayForFlowerType(SubTileEntity e) { + return e instanceof SubTileGenerating + ? new ItemStack(ModBlocks.spreader) + : e instanceof SubTileFunctional ? new ItemStack(ModBlocks.pool) : new ItemStack(ModItems.twigWand); + } + + @Override + public void renderLexiconText(int x, int y, int width, int height, String unlocalizedText) { + PageText.renderText(x, y, width, height, unlocalizedText); + } + + @Override + public void sparkleFX(World world, double x, double y, double z, float r, float g, float b, float size, int m) { + Botania.proxy.sparkleFX(world, x, y, z, r, g, b, size, m); + } + + @Override + public ResourceLocation getDefaultBossBarTexture() { + return BossBarHandler.defaultBossBar; + } + + @Override + public void setBossStatus(IBotaniaBoss status) { + BossBarHandler.setCurrentBoss(status); + } + + @Override + public boolean shouldForceCheck() { + return ConfigHandler.flowerForceCheck; + } + + @Override + public int getPassiveFlowerDecay() { + return ConfigHandler.hardcorePassiveGeneration; + } + + @Override + @Optional.Method(modid = "BuildCraft|Transport") + public boolean isBuildcraftPipe(TileEntity tile) { + return tile instanceof IPipeTile; + } + + @Override + public void breakOnAllCursors(EntityPlayer player, Item item, ItemStack stack, int x, int y, int z, int side) { + ItemLokiRing.breakOnAllCursors(player, item, stack, x, y, z, side); + } + + @Override + public boolean hasSolegnoliaAround(Entity e) { + return SubTileSolegnolia.hasSolegnoliaAround(e); + } + + @Override + public long getWorldElapsedTicks() { + return Botania.proxy.getWorldElapsedTicks(); + } + + @Override + public boolean isBotaniaFlower(World world, int x, int y, int z) { + Block block = world.getBlock(x, y, z); + return block == ModBlocks.flower || block == ModBlocks.shinyFlower || block == ModBlocks.specialFlower; + } + + @Override + public void sendBaubleUpdatePacket(EntityPlayer player, int slot) { + if (player instanceof EntityPlayerMP) + PacketHandler.INSTANCE.sendTo(new PacketSyncBauble(player, slot), (EntityPlayerMP) player); + } + + @Override + public List wrapInventory(List inventories) { + ArrayList arrayList = new ArrayList(); + for (IInventory inv : inventories) { + ICorporeaSpark spark = CorporeaHelper.getSparkForInventory(inv); + IWrappedInventory wrapped = null; + // try StorageDrawers integration + if (Botania.storageDrawersLoaded) { + wrapped = WrappedStorageDrawers.wrap(inv, spark); + } + // try DeepStorageUnit + if (wrapped == null) { + wrapped = WrappedDeepStorage.wrap(inv, spark); + } + // last chance - this will always work + if (wrapped == null) { + wrapped = WrappedIInventory.wrap(inv, spark); + } + arrayList.add(wrapped); + } + return arrayList; + } } diff --git a/src/main/java/vazkii/botania/common/core/handler/ManaNetworkHandler.java b/src/main/java/vazkii/botania/common/core/handler/ManaNetworkHandler.java index 54608e1c45..9f9f3afb09 100644 --- a/src/main/java/vazkii/botania/common/core/handler/ManaNetworkHandler.java +++ b/src/main/java/vazkii/botania/common/core/handler/ManaNetworkHandler.java @@ -2,19 +2,19 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jan 22, 2014, 5:35:10 PM (GMT)] */ package vazkii.botania.common.core.handler; +import cpw.mods.fml.common.eventhandler.SubscribeEvent; import java.util.ArrayList; import java.util.List; import java.util.Map; import java.util.WeakHashMap; - import net.minecraft.tileentity.TileEntity; import net.minecraft.util.ChunkCoordinates; import net.minecraft.world.World; @@ -24,130 +24,116 @@ import vazkii.botania.api.mana.ManaNetworkEvent.ManaBlockType; import vazkii.botania.api.mana.TileSignature; import vazkii.botania.common.core.helper.MathHelper; -import cpw.mods.fml.common.eventhandler.SubscribeEvent; public final class ManaNetworkHandler implements IManaNetwork { - public static final ManaNetworkHandler instance = new ManaNetworkHandler(); - - public WeakHashMap> manaPools = new WeakHashMap(); - public WeakHashMap> manaCollectors = new WeakHashMap(); - - @SubscribeEvent - public void onNetworkEvent(ManaNetworkEvent event) { - Map> map = event.type == ManaBlockType.COLLECTOR ? manaCollectors : manaPools; - if(event.action == Action.ADD) - add(map, event.tile); - else remove(map, event.tile); - } - - @Override - public void clear() { - manaPools.clear(); - manaCollectors.clear(); - } - - @Override - public TileEntity getClosestPool(ChunkCoordinates pos, World world, int limit) { - if(manaPools.containsKey(world)) - return getClosest(manaPools.get(world), pos, world.isRemote, limit); - return null; - } - - @Override - public TileEntity getClosestCollector(ChunkCoordinates pos, World world, int limit) { - if(manaCollectors.containsKey(world)) - return getClosest(manaCollectors.get(world), pos, world.isRemote, limit); - return null; - } - - public boolean isCollectorIn(TileEntity tile) { - return isIn(tile, manaCollectors); - } - - public boolean isPoolIn(TileEntity tile) { - return isIn(tile, manaPools); - } - - private synchronized boolean isIn(TileEntity tile, Map> map) { - List list = map.get(tile.getWorldObj()); - if(list == null) - return false; - - for(TileSignature sig : list) - if(sig.tile == tile) - return true; - - return false; - } - - private synchronized TileEntity getClosest(List tiles, ChunkCoordinates pos, boolean remoteCheck, int limit) { - float closest = Float.MAX_VALUE; - TileEntity closestTile = null; - - for(TileSignature sig : tiles) { - if(sig.remoteWorld != remoteCheck) - continue; - - TileEntity tile = sig.tile; - if(tile.isInvalid()) - continue; - float distance = MathHelper.pointDistanceSpace(tile.xCoord, tile.yCoord, tile.zCoord, pos.posX, pos.posY, pos.posZ); - if(distance > limit) - continue; - - if(distance < closest) { - closest = distance; - closestTile = tile; - } - } - - return closestTile; - } - - private synchronized void remove(Map> map, TileEntity tile) { - World world = tile.getWorldObj(); - - if(!map.containsKey(world)) - return; - - List sigs = map.get(world); - for(TileSignature sig : sigs) - if(sig.tile.equals(tile)) { - sigs.remove(sig); - break; - } - } - - private synchronized void add(Map> map, TileEntity tile) { - World world = tile.getWorldObj(); - - List tiles; - if(!map.containsKey(world)) - map.put(world, new ArrayList()); - - tiles = map.get(world); - - if(!tiles.contains(tile)) - tiles.add(new TileSignature(tile, tile.getWorldObj().isRemote)); - } - - @Override - public List getAllCollectorsInWorld(World world) { - return getAllInWorld(manaCollectors, world); - } - - @Override - public List getAllPoolsInWorld(World world) { - return getAllInWorld(manaPools, world); - } - - private List getAllInWorld(Map> map, World world) { - if(!map.containsKey(world)) - return new ArrayList(); - - return map.get(world); - } + public static final ManaNetworkHandler instance = new ManaNetworkHandler(); + + public WeakHashMap> manaPools = new WeakHashMap(); + public WeakHashMap> manaCollectors = new WeakHashMap(); + + @SubscribeEvent + public void onNetworkEvent(ManaNetworkEvent event) { + Map> map = event.type == ManaBlockType.COLLECTOR ? manaCollectors : manaPools; + if (event.action == Action.ADD) add(map, event.tile); + else remove(map, event.tile); + } + + @Override + public void clear() { + manaPools.clear(); + manaCollectors.clear(); + } + + @Override + public TileEntity getClosestPool(ChunkCoordinates pos, World world, int limit) { + if (manaPools.containsKey(world)) return getClosest(manaPools.get(world), pos, world.isRemote, limit); + return null; + } + + @Override + public TileEntity getClosestCollector(ChunkCoordinates pos, World world, int limit) { + if (manaCollectors.containsKey(world)) return getClosest(manaCollectors.get(world), pos, world.isRemote, limit); + return null; + } + + public boolean isCollectorIn(TileEntity tile) { + return isIn(tile, manaCollectors); + } + + public boolean isPoolIn(TileEntity tile) { + return isIn(tile, manaPools); + } + + private synchronized boolean isIn(TileEntity tile, Map> map) { + List list = map.get(tile.getWorldObj()); + if (list == null) return false; + + for (TileSignature sig : list) if (sig.tile == tile) return true; + + return false; + } + + private synchronized TileEntity getClosest( + List tiles, ChunkCoordinates pos, boolean remoteCheck, int limit) { + float closest = Float.MAX_VALUE; + TileEntity closestTile = null; + + for (TileSignature sig : tiles) { + if (sig.remoteWorld != remoteCheck) continue; + + TileEntity tile = sig.tile; + if (tile.isInvalid()) continue; + float distance = + MathHelper.pointDistanceSpace(tile.xCoord, tile.yCoord, tile.zCoord, pos.posX, pos.posY, pos.posZ); + if (distance > limit) continue; + + if (distance < closest) { + closest = distance; + closestTile = tile; + } + } + + return closestTile; + } + + private synchronized void remove(Map> map, TileEntity tile) { + World world = tile.getWorldObj(); + + if (!map.containsKey(world)) return; + + List sigs = map.get(world); + for (TileSignature sig : sigs) + if (sig.tile.equals(tile)) { + sigs.remove(sig); + break; + } + } + + private synchronized void add(Map> map, TileEntity tile) { + World world = tile.getWorldObj(); + + List tiles; + if (!map.containsKey(world)) map.put(world, new ArrayList()); + + tiles = map.get(world); + + if (!tiles.contains(tile)) tiles.add(new TileSignature(tile, tile.getWorldObj().isRemote)); + } + @Override + public List getAllCollectorsInWorld(World world) { + return getAllInWorld(manaCollectors, world); + } + @Override + public List getAllPoolsInWorld(World world) { + return getAllInWorld(manaPools, world); + } + + private List getAllInWorld(Map> map, World world) { + if (!map.containsKey(world)) return new ArrayList(); + + return map.get(world); + } } diff --git a/src/main/java/vazkii/botania/common/core/handler/PixieHandler.java b/src/main/java/vazkii/botania/common/core/handler/PixieHandler.java index bccd71985e..08cb5495ce 100644 --- a/src/main/java/vazkii/botania/common/core/handler/PixieHandler.java +++ b/src/main/java/vazkii/botania/common/core/handler/PixieHandler.java @@ -1,5 +1,8 @@ package vazkii.botania.common.core.handler; +import baubles.common.container.InventoryBaubles; +import baubles.common.lib.PlayerHandler; +import cpw.mods.fml.common.eventhandler.SubscribeEvent; import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.Item; @@ -11,59 +14,51 @@ import vazkii.botania.common.entity.EntityPixie; import vazkii.botania.common.item.ModItems; import vazkii.botania.common.item.equipment.armor.elementium.ItemElementiumHelm; -import baubles.common.container.InventoryBaubles; -import baubles.common.lib.PlayerHandler; -import cpw.mods.fml.common.eventhandler.SubscribeEvent; public class PixieHandler { - @SubscribeEvent - public void onDamageTaken(LivingHurtEvent event) { - if(!event.entityLiving.worldObj.isRemote && event.entityLiving instanceof EntityPlayer && event.source.getEntity() != null && event.source.getEntity() instanceof EntityLivingBase) { - EntityPlayer player = (EntityPlayer) event.entityLiving; - ItemStack stack = player.getCurrentEquippedItem(); - - float chance = getChance(stack); - for (ItemStack element : player.inventory.armorInventory) - chance += getChance(element); + @SubscribeEvent + public void onDamageTaken(LivingHurtEvent event) { + if (!event.entityLiving.worldObj.isRemote + && event.entityLiving instanceof EntityPlayer + && event.source.getEntity() != null + && event.source.getEntity() instanceof EntityLivingBase) { + EntityPlayer player = (EntityPlayer) event.entityLiving; + ItemStack stack = player.getCurrentEquippedItem(); - InventoryBaubles baubles = PlayerHandler.getPlayerBaubles(player); - for(int i = 0; i < baubles.getSizeInventory(); i++) - chance += getChance(baubles.getStackInSlot(i)); + float chance = getChance(stack); + for (ItemStack element : player.inventory.armorInventory) chance += getChance(element); - if(Math.random() < chance) { - EntityPixie pixie = new EntityPixie(player.worldObj); - pixie.setPosition(player.posX, player.posY + 2, player.posZ); + InventoryBaubles baubles = PlayerHandler.getPlayerBaubles(player); + for (int i = 0; i < baubles.getSizeInventory(); i++) chance += getChance(baubles.getStackInSlot(i)); - if(((ItemElementiumHelm) ModItems.elementiumHelm).hasArmorSet(player)) { - int[] potions = new int[] { - Potion.blindness.id, - Potion.wither.id, - Potion.moveSlowdown.id, - Potion.weakness.id - }; - pixie.setApplyPotionEffect(new PotionEffect(potions[event.entity.worldObj.rand.nextInt(potions.length)], 40, 0)); - } + if (Math.random() < chance) { + EntityPixie pixie = new EntityPixie(player.worldObj); + pixie.setPosition(player.posX, player.posY + 2, player.posZ); - float dmg = 4; - if(stack != null && stack.getItem() == ModItems.elementiumSword) - dmg += 2; + if (((ItemElementiumHelm) ModItems.elementiumHelm).hasArmorSet(player)) { + int[] potions = + new int[] {Potion.blindness.id, Potion.wither.id, Potion.moveSlowdown.id, Potion.weakness.id + }; + pixie.setApplyPotionEffect( + new PotionEffect(potions[event.entity.worldObj.rand.nextInt(potions.length)], 40, 0)); + } - pixie.setProps((EntityLivingBase) event.source.getEntity(), player, 0, dmg); - player.worldObj.spawnEntityInWorld(pixie); - } - } - } + float dmg = 4; + if (stack != null && stack.getItem() == ModItems.elementiumSword) dmg += 2; - float getChance(ItemStack stack) { - if(stack == null) - return 0F; + pixie.setProps((EntityLivingBase) event.source.getEntity(), player, 0, dmg); + player.worldObj.spawnEntityInWorld(pixie); + } + } + } - Item item = stack.getItem(); - if(item instanceof IPixieSpawner) - return ((IPixieSpawner) item).getPixieChance(stack); + float getChance(ItemStack stack) { + if (stack == null) return 0F; - return 0F; - } + Item item = stack.getItem(); + if (item instanceof IPixieSpawner) return ((IPixieSpawner) item).getPixieChance(stack); + return 0F; + } } diff --git a/src/main/java/vazkii/botania/common/core/handler/SheddingHandler.java b/src/main/java/vazkii/botania/common/core/handler/SheddingHandler.java index aef3cbdd61..6dc6a19d65 100644 --- a/src/main/java/vazkii/botania/common/core/handler/SheddingHandler.java +++ b/src/main/java/vazkii/botania/common/core/handler/SheddingHandler.java @@ -2,17 +2,17 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jul 4, 2014, 10:38:50 PM (GMT)] */ package vazkii.botania.common.core.handler; +import cpw.mods.fml.common.eventhandler.SubscribeEvent; import java.util.ArrayList; import java.util.Map.Entry; - import net.minecraft.entity.Entity; import net.minecraft.entity.EntityList; import net.minecraft.entity.EntityLiving; @@ -32,125 +32,129 @@ import net.minecraftforge.event.entity.living.LivingEvent.LivingUpdateEvent; import vazkii.botania.common.lexicon.LexiconData; import vazkii.botania.common.lexicon.page.PageShedding; -import cpw.mods.fml.common.eventhandler.SubscribeEvent; public final class SheddingHandler { - public static ArrayList patterns = new ArrayList(); - public static ArrayList defaultPatterns = new ArrayList(); - - @SubscribeEvent - public void onLivingUpdate(LivingUpdateEvent event) { - if(event.entity.worldObj.isRemote) - return; - - ShedPattern pattern = getShedPattern(event.entity); - - if(pattern != null) { - if(event.entity.worldObj.rand.nextInt(pattern.getRate()) == 0) - event.entity.entityDropItem(pattern.getItemStack(), 0.0F); - } - } - - public static ShedPattern getShedPattern(Entity entity) { - for(ShedPattern pattern : patterns) - if(pattern.EntityClass.isInstance(entity)) - return pattern; - - return null; - } - - public static boolean hasShedding() { - return patterns.size() > 0; - } - - public static void addToLexicon() { - if(!hasShedding()) - return; - - int i = 1; - for(ShedPattern pattern : patterns) { - PageShedding page = new PageShedding(String.valueOf(i), (String)EntityList.classToStringMapping.get(pattern.EntityClass), pattern.lexiconSize, pattern.getItemStack()); - LexiconData.shedding.addPage(page); - } - } - - public static void loadFromConfig(Configuration config) { - defaultPatterns.add(new ShedPattern(EntityChicken.class, new ItemStack(Items.feather), 26000, 20)); - defaultPatterns.add(new ShedPattern(EntitySquid.class, new ItemStack(Items.dye), 18000, 20)); - defaultPatterns.add(new ShedPattern(EntityVillager.class, new ItemStack(Items.emerald), 226000, 40)); - defaultPatterns.add(new ShedPattern(EntitySpider.class, new ItemStack(Items.string), 12000, 40)); - defaultPatterns.add(new ShedPattern(EntityBlaze.class, new ItemStack(Items.blaze_powder), 8000, 40)); - defaultPatterns.add(new ShedPattern(EntityGhast.class, new ItemStack(Items.ghast_tear), 9001, 30)); - defaultPatterns.add(new ShedPattern(EntitySkeleton.class, new ItemStack(Items.bone), 36000, 40)); - defaultPatterns.add(new ShedPattern(EntitySlime.class, new ItemStack(Items.slime_ball), 21000, 40)); - - ArrayList defaultNames = new ArrayList(); - - for(ShedPattern pattern : defaultPatterns) { - loadFromConfig(config, pattern.getEntityString(), pattern); - defaultNames.add(pattern.getEntityString()); - } - - for(Object o : EntityList.stringToClassMapping.entrySet()) { - Entry entry = (Entry) o; - - if(EntityLiving.class.isAssignableFrom(entry.getValue())) { - String name = entry.getKey(); - if(!defaultNames.contains(name)) - loadFromConfig(config, name, null); - } - } - } - - public static void loadFromConfig(Configuration config, String key, ShedPattern defaultPattern) { - String itemName = ""; - int metadata = 0; - int rate = -1; - int lexiconSize = 40; - - if(defaultPattern != null) { - itemName = Item.itemRegistry.getNameForObject(defaultPattern.getItemStack().getItem()); - metadata = defaultPattern.getItemStack().getItemDamage(); - rate = defaultPattern.rate; - lexiconSize = defaultPattern.lexiconSize; - } - - Property prop = config.get("Shedding", key + ".item", itemName); - prop.comment = "Configuration of Shedding for "+key; - itemName = prop.getString(); - rate = config.get("Shedding", key + ".rate", rate).getInt(); - metadata = config.get("Shedding", key + ".metadata", metadata).getInt(); - lexiconSize = config.get("Shedding", key + ".lexiconDisplaySize", lexiconSize).getInt(); - - if(itemName != null && !itemName.isEmpty() && rate != -1) - patterns.add(new ShedPattern((Class) EntityList.stringToClassMapping.get(key), new ItemStack((Item) Item.itemRegistry.getObject(itemName), 1, metadata), rate, lexiconSize)); - } - - public static class ShedPattern { - - Class EntityClass; - ItemStack itemStack; - int rate; - int lexiconSize; - - public ShedPattern(Class EntityClass, ItemStack itemStack, int rate, int lexiconSize) { - this.EntityClass = EntityClass; - this.itemStack = itemStack; - this.rate = rate; - this.lexiconSize = lexiconSize; - } - public ItemStack getItemStack() { - return itemStack.copy(); - } - - public int getRate() { - return rate; - } - - public String getEntityString() { - return (String) EntityList.classToStringMapping.get(EntityClass); - } - } - + public static ArrayList patterns = new ArrayList(); + public static ArrayList defaultPatterns = new ArrayList(); + + @SubscribeEvent + public void onLivingUpdate(LivingUpdateEvent event) { + if (event.entity.worldObj.isRemote) return; + + ShedPattern pattern = getShedPattern(event.entity); + + if (pattern != null) { + if (event.entity.worldObj.rand.nextInt(pattern.getRate()) == 0) + event.entity.entityDropItem(pattern.getItemStack(), 0.0F); + } + } + + public static ShedPattern getShedPattern(Entity entity) { + for (ShedPattern pattern : patterns) if (pattern.EntityClass.isInstance(entity)) return pattern; + + return null; + } + + public static boolean hasShedding() { + return patterns.size() > 0; + } + + public static void addToLexicon() { + if (!hasShedding()) return; + + int i = 1; + for (ShedPattern pattern : patterns) { + PageShedding page = new PageShedding( + String.valueOf(i), + (String) EntityList.classToStringMapping.get(pattern.EntityClass), + pattern.lexiconSize, + pattern.getItemStack()); + LexiconData.shedding.addPage(page); + } + } + + public static void loadFromConfig(Configuration config) { + defaultPatterns.add(new ShedPattern(EntityChicken.class, new ItemStack(Items.feather), 26000, 20)); + defaultPatterns.add(new ShedPattern(EntitySquid.class, new ItemStack(Items.dye), 18000, 20)); + defaultPatterns.add(new ShedPattern(EntityVillager.class, new ItemStack(Items.emerald), 226000, 40)); + defaultPatterns.add(new ShedPattern(EntitySpider.class, new ItemStack(Items.string), 12000, 40)); + defaultPatterns.add(new ShedPattern(EntityBlaze.class, new ItemStack(Items.blaze_powder), 8000, 40)); + defaultPatterns.add(new ShedPattern(EntityGhast.class, new ItemStack(Items.ghast_tear), 9001, 30)); + defaultPatterns.add(new ShedPattern(EntitySkeleton.class, new ItemStack(Items.bone), 36000, 40)); + defaultPatterns.add(new ShedPattern(EntitySlime.class, new ItemStack(Items.slime_ball), 21000, 40)); + + ArrayList defaultNames = new ArrayList(); + + for (ShedPattern pattern : defaultPatterns) { + loadFromConfig(config, pattern.getEntityString(), pattern); + defaultNames.add(pattern.getEntityString()); + } + + for (Object o : EntityList.stringToClassMapping.entrySet()) { + Entry entry = (Entry) o; + + if (EntityLiving.class.isAssignableFrom(entry.getValue())) { + String name = entry.getKey(); + if (!defaultNames.contains(name)) loadFromConfig(config, name, null); + } + } + } + + public static void loadFromConfig(Configuration config, String key, ShedPattern defaultPattern) { + String itemName = ""; + int metadata = 0; + int rate = -1; + int lexiconSize = 40; + + if (defaultPattern != null) { + itemName = Item.itemRegistry.getNameForObject( + defaultPattern.getItemStack().getItem()); + metadata = defaultPattern.getItemStack().getItemDamage(); + rate = defaultPattern.rate; + lexiconSize = defaultPattern.lexiconSize; + } + + Property prop = config.get("Shedding", key + ".item", itemName); + prop.comment = "Configuration of Shedding for " + key; + itemName = prop.getString(); + rate = config.get("Shedding", key + ".rate", rate).getInt(); + metadata = config.get("Shedding", key + ".metadata", metadata).getInt(); + lexiconSize = + config.get("Shedding", key + ".lexiconDisplaySize", lexiconSize).getInt(); + + if (itemName != null && !itemName.isEmpty() && rate != -1) + patterns.add(new ShedPattern( + (Class) EntityList.stringToClassMapping.get(key), + new ItemStack((Item) Item.itemRegistry.getObject(itemName), 1, metadata), + rate, + lexiconSize)); + } + + public static class ShedPattern { + + Class EntityClass; + ItemStack itemStack; + int rate; + int lexiconSize; + + public ShedPattern(Class EntityClass, ItemStack itemStack, int rate, int lexiconSize) { + this.EntityClass = EntityClass; + this.itemStack = itemStack; + this.rate = rate; + this.lexiconSize = lexiconSize; + } + + public ItemStack getItemStack() { + return itemStack.copy(); + } + + public int getRate() { + return rate; + } + + public String getEntityString() { + return (String) EntityList.classToStringMapping.get(EntityClass); + } + } } diff --git a/src/main/java/vazkii/botania/common/core/handler/SpawnerChangingHandler.java b/src/main/java/vazkii/botania/common/core/handler/SpawnerChangingHandler.java index 338bcaa744..0ea91ec0ce 100644 --- a/src/main/java/vazkii/botania/common/core/handler/SpawnerChangingHandler.java +++ b/src/main/java/vazkii/botania/common/core/handler/SpawnerChangingHandler.java @@ -2,14 +2,15 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jul 30, 2014, 12:37:24 PM (GMT)] */ package vazkii.botania.common.core.handler; +import cpw.mods.fml.common.eventhandler.SubscribeEvent; import net.minecraft.entity.EntityList; import net.minecraft.init.Items; import net.minecraft.item.ItemStack; @@ -17,27 +18,28 @@ import net.minecraft.tileentity.TileEntityMobSpawner; import net.minecraftforge.event.entity.player.PlayerInteractEvent; import net.minecraftforge.event.entity.player.PlayerInteractEvent.Action; -import cpw.mods.fml.common.eventhandler.SubscribeEvent; public final class SpawnerChangingHandler { - @SubscribeEvent - public void onInteract(PlayerInteractEvent event) { - if(event.entityPlayer == null || event.entityPlayer.capabilities == null || event.world == null) - return; // Cauldron breaks stuff - - if(event.entityPlayer.capabilities.isCreativeMode && !event.world.isRemote && event.action == Action.RIGHT_CLICK_BLOCK && !event.entityPlayer.isSneaking()) { - ItemStack stack = event.entityPlayer.getCurrentEquippedItem(); - if(stack != null && stack.getItem() == Items.spawn_egg) { - TileEntity tile = event.world.getTileEntity(event.x, event.y, event.z); - if(tile instanceof TileEntityMobSpawner) { - TileEntityMobSpawner spawner = (TileEntityMobSpawner) tile; - spawner.func_145881_a().setEntityName(EntityList.getStringFromID(stack.getItemDamage())); - event.world.markBlockForUpdate(event.x, event.y, event.z); - event.setCanceled(true); - } - } - } - } + @SubscribeEvent + public void onInteract(PlayerInteractEvent event) { + if (event.entityPlayer == null || event.entityPlayer.capabilities == null || event.world == null) + return; // Cauldron breaks stuff + if (event.entityPlayer.capabilities.isCreativeMode + && !event.world.isRemote + && event.action == Action.RIGHT_CLICK_BLOCK + && !event.entityPlayer.isSneaking()) { + ItemStack stack = event.entityPlayer.getCurrentEquippedItem(); + if (stack != null && stack.getItem() == Items.spawn_egg) { + TileEntity tile = event.world.getTileEntity(event.x, event.y, event.z); + if (tile instanceof TileEntityMobSpawner) { + TileEntityMobSpawner spawner = (TileEntityMobSpawner) tile; + spawner.func_145881_a().setEntityName(EntityList.getStringFromID(stack.getItemDamage())); + event.world.markBlockForUpdate(event.x, event.y, event.z); + event.setCanceled(true); + } + } + } + } } diff --git a/src/main/java/vazkii/botania/common/core/handler/TerrasteelCraftingHandler.java b/src/main/java/vazkii/botania/common/core/handler/TerrasteelCraftingHandler.java index 59150bbccd..dd80d39eeb 100644 --- a/src/main/java/vazkii/botania/common/core/handler/TerrasteelCraftingHandler.java +++ b/src/main/java/vazkii/botania/common/core/handler/TerrasteelCraftingHandler.java @@ -2,16 +2,15 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Apr 14, 2014, 4:30:40 PM (GMT)] */ package vazkii.botania.common.core.handler; import java.util.List; - import net.minecraft.entity.item.EntityItem; import net.minecraft.init.Blocks; import net.minecraft.item.ItemStack; @@ -28,161 +27,177 @@ // This is legacy code and is no longer used. Check out TileTerraPlate instead. public final class TerrasteelCraftingHandler { - private static final String TAG_TIME = "Botania-CraftingTime"; - private static final int TIME = 100; - private static final int MANA_PER_TICK = (int) (TilePool.MAX_MANA / 2 / TIME * 0.9); - - public static void onEntityUpdate(EntityItem item) { - ItemStack stack = item.getEntityItem(); - if(stack != null && stack.getItem() == ModItems.manaResource && stack.getItemDamage() == 0) { - int time = validateCraftingItem(item); - - if(time != -1) { - doParticles(item, time); - if(time == TIME) - item.worldObj.playSoundAtEntity(item, "botania:terrasteelCraft", 1F, 1F); - - getManaFromPools : { - int x = MathHelper.floor_double(item.posX); - int y = MathHelper.floor_double(item.posY); - int z = MathHelper.floor_double(item.posZ); - - int range = 12; - - for(int i = -range; i < range + 1; i++) - for(int j = -range; j < range + 1; j++) - for(int k = - range; k < range + 1; k++) { - TileEntity tile = item.worldObj.getTileEntity(x + i, y + j, z + k); - - if(tile instanceof IManaPool) { - IManaPool pool = (IManaPool) tile; - - if(!item.worldObj.isRemote && pool.getCurrentMana() >= MANA_PER_TICK) { - pool.recieveMana(-MANA_PER_TICK); - item.worldObj.markBlockForUpdate(tile.xCoord, tile.yCoord, tile.zCoord); - incrementCraftingTime(item, time); - break getManaFromPools; - } - } - } - } - } - } - } - - static int validateCraftingItem(EntityItem item) { - ItemStack estack = item.getEntityItem(); - if(estack.stackSize != 1) - return -1; - - int x = MathHelper.floor_double(item.posX); - int y = MathHelper.floor_double(item.posY); - int z = MathHelper.floor_double(item.posZ); - - if(item.worldObj.getBlock(x, y - 1, z) != Blocks.beacon) - return -1; - - TileEntityBeacon beacon = (TileEntityBeacon) item.worldObj.getTileEntity(x, y - 1, z); - if(beacon.getLevels() <= 0) - return -1; - - List items = item.worldObj.getEntitiesWithinAABB(EntityItem.class, AxisAlignedBB.getBoundingBox(x, y, z, x + 1, y + 1, z + 1)); - - EntityItem diamond = null; - EntityItem pearl = null; - - for(EntityItem otherItem : items) { - if(otherItem == item) - continue; - - ItemStack stack = otherItem.getEntityItem(); - if(stack.getItem() == ModItems.manaResource && stack.stackSize == 1) { - int meta = stack.getItemDamage(); - if(meta == 1) { - if(pearl == null) { - pearl = otherItem; - continue; - } else return -1; - } else if(meta == 2) { - if(diamond == null) { - diamond = otherItem; - continue; - } else return -1; - } else return -1; - } else return -1; - } - - if(diamond != null && pearl != null) { - int time = getTimeInCrafting(item); - if(time > 0) { - diamond.delayBeforeCanPickup = 1; - diamond.age = 0; - pearl.delayBeforeCanPickup = 1; - pearl.age = 0; - item.delayBeforeCanPickup = 1; - item.age = 0; - } - - return time; - } - return -1; - } - - static int getTimeInCrafting(EntityItem item) { - ItemStack stack = item.getEntityItem(); - return ItemNBTHelper.getInt(stack, TAG_TIME, 0); - } - - static void doParticles(EntityItem item, int ticks) { - if(item.worldObj.isRemote) { - int totalSpiritCount = 3; - double tickIncrement = 360D / totalSpiritCount; - - int speed = 5; - double wticks = ticks * speed - tickIncrement; - - double r = Math.sin((ticks - TIME) / 10D) * 2; - double g = Math.sin(wticks * Math.PI / 180 * 0.55); - - for(int i = 0; i < totalSpiritCount; i++) { - double x = (int) item.posX + Math.sin(wticks * Math.PI / 180) * r + 0.5; - double y = (int) item.posY + 0.25; - double z = (int) item.posZ + Math.cos(wticks * Math.PI / 180) * r + 0.5; - - wticks += tickIncrement; - float[] colorsfx = new float[] { - 0F, (float) ticks / (float) TIME, 1F - (float) ticks / (float) TIME - }; - Botania.proxy.wispFX(item.worldObj, x, y, z, colorsfx[0], colorsfx[1], colorsfx[2], 0.85F, (float)g * 0.05F, 0.25F); - Botania.proxy.wispFX(item.worldObj, x, y, z, colorsfx[0], colorsfx[1], colorsfx[2], (float) Math.random() * 0.1F + 0.1F, (float) (Math.random() - 0.5) * 0.05F, (float) (Math.random() - 0.5) * 0.05F, (float) (Math.random() - 0.5) * 0.05F, 0.9F); - - if(ticks == TIME) - for(int j = 0; j < 15; j++) - Botania.proxy.wispFX(item.worldObj, item.posX, item.posY, item.posZ, colorsfx[0], colorsfx[1], colorsfx[2], (float) Math.random() * 0.15F + 0.15F, (float) (Math.random() - 0.5F) * 0.125F, (float) (Math.random() - 0.5F) * 0.125F, (float) (Math.random() - 0.5F) * 0.125F); - } - } - } - - static void incrementCraftingTime(EntityItem item, int time) { - if(time >= TIME) - finalizeCraftingRecipe(item); - - else { - ItemStack stack = item.getEntityItem(); - ItemNBTHelper.setInt(stack, TAG_TIME, time + 1); - } - } - - static void finalizeCraftingRecipe(EntityItem item) { - int x = MathHelper.floor_double(item.posX); - int y = MathHelper.floor_double(item.posY); - int z = MathHelper.floor_double(item.posZ); - - List items = item.worldObj.getEntitiesWithinAABB(EntityItem.class, AxisAlignedBB.getBoundingBox(x, y, z, x + 1, y + 1, z + 1)); - for(EntityItem otherItem : items) - if(otherItem != item) - otherItem.setDead(); - else item.setEntityItemStack(new ItemStack(ModItems.manaResource, 1, 4)); - } - + private static final String TAG_TIME = "Botania-CraftingTime"; + private static final int TIME = 100; + private static final int MANA_PER_TICK = (int) (TilePool.MAX_MANA / 2 / TIME * 0.9); + + public static void onEntityUpdate(EntityItem item) { + ItemStack stack = item.getEntityItem(); + if (stack != null && stack.getItem() == ModItems.manaResource && stack.getItemDamage() == 0) { + int time = validateCraftingItem(item); + + if (time != -1) { + doParticles(item, time); + if (time == TIME) item.worldObj.playSoundAtEntity(item, "botania:terrasteelCraft", 1F, 1F); + + getManaFromPools: + { + int x = MathHelper.floor_double(item.posX); + int y = MathHelper.floor_double(item.posY); + int z = MathHelper.floor_double(item.posZ); + + int range = 12; + + for (int i = -range; i < range + 1; i++) + for (int j = -range; j < range + 1; j++) + for (int k = -range; k < range + 1; k++) { + TileEntity tile = item.worldObj.getTileEntity(x + i, y + j, z + k); + + if (tile instanceof IManaPool) { + IManaPool pool = (IManaPool) tile; + + if (!item.worldObj.isRemote && pool.getCurrentMana() >= MANA_PER_TICK) { + pool.recieveMana(-MANA_PER_TICK); + item.worldObj.markBlockForUpdate(tile.xCoord, tile.yCoord, tile.zCoord); + incrementCraftingTime(item, time); + break getManaFromPools; + } + } + } + } + } + } + } + + static int validateCraftingItem(EntityItem item) { + ItemStack estack = item.getEntityItem(); + if (estack.stackSize != 1) return -1; + + int x = MathHelper.floor_double(item.posX); + int y = MathHelper.floor_double(item.posY); + int z = MathHelper.floor_double(item.posZ); + + if (item.worldObj.getBlock(x, y - 1, z) != Blocks.beacon) return -1; + + TileEntityBeacon beacon = (TileEntityBeacon) item.worldObj.getTileEntity(x, y - 1, z); + if (beacon.getLevels() <= 0) return -1; + + List items = item.worldObj.getEntitiesWithinAABB( + EntityItem.class, AxisAlignedBB.getBoundingBox(x, y, z, x + 1, y + 1, z + 1)); + + EntityItem diamond = null; + EntityItem pearl = null; + + for (EntityItem otherItem : items) { + if (otherItem == item) continue; + + ItemStack stack = otherItem.getEntityItem(); + if (stack.getItem() == ModItems.manaResource && stack.stackSize == 1) { + int meta = stack.getItemDamage(); + if (meta == 1) { + if (pearl == null) { + pearl = otherItem; + continue; + } else return -1; + } else if (meta == 2) { + if (diamond == null) { + diamond = otherItem; + continue; + } else return -1; + } else return -1; + } else return -1; + } + + if (diamond != null && pearl != null) { + int time = getTimeInCrafting(item); + if (time > 0) { + diamond.delayBeforeCanPickup = 1; + diamond.age = 0; + pearl.delayBeforeCanPickup = 1; + pearl.age = 0; + item.delayBeforeCanPickup = 1; + item.age = 0; + } + + return time; + } + return -1; + } + + static int getTimeInCrafting(EntityItem item) { + ItemStack stack = item.getEntityItem(); + return ItemNBTHelper.getInt(stack, TAG_TIME, 0); + } + + static void doParticles(EntityItem item, int ticks) { + if (item.worldObj.isRemote) { + int totalSpiritCount = 3; + double tickIncrement = 360D / totalSpiritCount; + + int speed = 5; + double wticks = ticks * speed - tickIncrement; + + double r = Math.sin((ticks - TIME) / 10D) * 2; + double g = Math.sin(wticks * Math.PI / 180 * 0.55); + + for (int i = 0; i < totalSpiritCount; i++) { + double x = (int) item.posX + Math.sin(wticks * Math.PI / 180) * r + 0.5; + double y = (int) item.posY + 0.25; + double z = (int) item.posZ + Math.cos(wticks * Math.PI / 180) * r + 0.5; + + wticks += tickIncrement; + float[] colorsfx = new float[] {0F, (float) ticks / (float) TIME, 1F - (float) ticks / (float) TIME}; + Botania.proxy.wispFX( + item.worldObj, x, y, z, colorsfx[0], colorsfx[1], colorsfx[2], 0.85F, (float) g * 0.05F, 0.25F); + Botania.proxy.wispFX( + item.worldObj, + x, + y, + z, + colorsfx[0], + colorsfx[1], + colorsfx[2], + (float) Math.random() * 0.1F + 0.1F, + (float) (Math.random() - 0.5) * 0.05F, + (float) (Math.random() - 0.5) * 0.05F, + (float) (Math.random() - 0.5) * 0.05F, + 0.9F); + + if (ticks == TIME) + for (int j = 0; j < 15; j++) + Botania.proxy.wispFX( + item.worldObj, + item.posX, + item.posY, + item.posZ, + colorsfx[0], + colorsfx[1], + colorsfx[2], + (float) Math.random() * 0.15F + 0.15F, + (float) (Math.random() - 0.5F) * 0.125F, + (float) (Math.random() - 0.5F) * 0.125F, + (float) (Math.random() - 0.5F) * 0.125F); + } + } + } + + static void incrementCraftingTime(EntityItem item, int time) { + if (time >= TIME) finalizeCraftingRecipe(item); + else { + ItemStack stack = item.getEntityItem(); + ItemNBTHelper.setInt(stack, TAG_TIME, time + 1); + } + } + + static void finalizeCraftingRecipe(EntityItem item) { + int x = MathHelper.floor_double(item.posX); + int y = MathHelper.floor_double(item.posY); + int z = MathHelper.floor_double(item.posZ); + + List items = item.worldObj.getEntitiesWithinAABB( + EntityItem.class, AxisAlignedBB.getBoundingBox(x, y, z, x + 1, y + 1, z + 1)); + for (EntityItem otherItem : items) + if (otherItem != item) otherItem.setDead(); + else item.setEntityItemStack(new ItemStack(ModItems.manaResource, 1, 4)); + } } diff --git a/src/main/java/vazkii/botania/common/core/helper/ExperienceHelper.java b/src/main/java/vazkii/botania/common/core/helper/ExperienceHelper.java index 7e04748a98..ed07861c5d 100644 --- a/src/main/java/vazkii/botania/common/core/helper/ExperienceHelper.java +++ b/src/main/java/vazkii/botania/common/core/helper/ExperienceHelper.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [? (GMT)] */ package vazkii.botania.common.core.helper; @@ -15,40 +15,35 @@ // From OpenBlocksLib: https://github.com/OpenMods/OpenModsLib public class ExperienceHelper { - public static int getPlayerXP(EntityPlayer player) { - return (int)(getExperienceForLevel(player.experienceLevel) + player.experience * player.xpBarCap()); - } - - public static void drainPlayerXP(EntityPlayer player, int amount) { - addPlayerXP(player, -amount); - } - - public static void addPlayerXP(EntityPlayer player, int amount) { - int experience = getPlayerXP(player) + amount; - player.experienceTotal = experience; - player.experienceLevel = getLevelForExperience(experience); - int expForLevel = getExperienceForLevel(player.experienceLevel); - player.experience = (float)(experience - expForLevel) / (float)player.xpBarCap(); - } - - public static int getExperienceForLevel(int level) { - if (level == 0) - return 0; - - if (level > 0 && level < 16) - return level * 17; - else if (level > 15 && level < 31) - return (int) (1.5 * level * level - 29.5 * level + 360); - else - return (int) (3.5 * level * level - 151.5 * level + 2220); - } - - public static int getLevelForExperience(int experience) { - int i = 0; - while (getExperienceForLevel(i) <= experience) { - i++; - } - return i - 1; - } - + public static int getPlayerXP(EntityPlayer player) { + return (int) (getExperienceForLevel(player.experienceLevel) + player.experience * player.xpBarCap()); + } + + public static void drainPlayerXP(EntityPlayer player, int amount) { + addPlayerXP(player, -amount); + } + + public static void addPlayerXP(EntityPlayer player, int amount) { + int experience = getPlayerXP(player) + amount; + player.experienceTotal = experience; + player.experienceLevel = getLevelForExperience(experience); + int expForLevel = getExperienceForLevel(player.experienceLevel); + player.experience = (float) (experience - expForLevel) / (float) player.xpBarCap(); + } + + public static int getExperienceForLevel(int level) { + if (level == 0) return 0; + + if (level > 0 && level < 16) return level * 17; + else if (level > 15 && level < 31) return (int) (1.5 * level * level - 29.5 * level + 360); + else return (int) (3.5 * level * level - 151.5 * level + 2220); + } + + public static int getLevelForExperience(int experience) { + int i = 0; + while (getExperienceForLevel(i) <= experience) { + i++; + } + return i - 1; + } } diff --git a/src/main/java/vazkii/botania/common/core/helper/InventoryHelper.java b/src/main/java/vazkii/botania/common/core/helper/InventoryHelper.java index d553eda949..24e94f78ed 100644 --- a/src/main/java/vazkii/botania/common/core/helper/InventoryHelper.java +++ b/src/main/java/vazkii/botania/common/core/helper/InventoryHelper.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [? (GMT)] */ package vazkii.botania.common.core.helper; @@ -14,7 +14,6 @@ import java.util.HashSet; import java.util.List; import java.util.Set; - import net.minecraft.block.Block; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.inventory.IInventory; @@ -29,335 +28,337 @@ import net.minecraft.world.World; import net.minecraftforge.common.util.ForgeDirection; -//From OpenBlocksLib: https://github.com/OpenMods/OpenModsLib +// From OpenBlocksLib: https://github.com/OpenMods/OpenModsLib public class InventoryHelper { - public static void tryInsertStack(IInventory targetInventory, int slot, ItemStack stack, boolean canMerge) { - if(targetInventory.isItemValidForSlot(slot, stack)) { - ItemStack targetStack = targetInventory.getStackInSlot(slot); - if(targetStack == null) { - int space = targetInventory.getInventoryStackLimit(); - int mergeAmount = Math.min(space, stack.stackSize); - - ItemStack copy = stack.copy(); - copy.stackSize = mergeAmount; - targetInventory.setInventorySlotContents(slot, copy); - stack.stackSize -= mergeAmount; - } else if(canMerge) { - if(targetInventory.isItemValidForSlot(slot, stack) && areMergeCandidates(stack, targetStack)) { - int space = Math.min(targetInventory.getInventoryStackLimit(), targetStack.getMaxStackSize()) - targetStack.stackSize; - int mergeAmount = Math.min(space, stack.stackSize); - - ItemStack copy = targetStack.copy(); - copy.stackSize += mergeAmount; - targetInventory.setInventorySlotContents(slot, copy); - stack.stackSize -= mergeAmount; - } - } - } - } - - protected static boolean areMergeCandidates(ItemStack source, ItemStack target) { - return source.isItemEqual(target) && ItemStack.areItemStackTagsEqual(source, target) && target.stackSize < target.getMaxStackSize(); - } - - public static void insertItemIntoInventory(IInventory inventory, ItemStack stack) { - insertItemIntoInventory(inventory, stack, ForgeDirection.UNKNOWN, -1); - } - - public static void insertItemIntoInventory(IInventory inventory, ItemStack stack, ForgeDirection side, int intoSlot) { - insertItemIntoInventory(inventory, stack, side, intoSlot, true); - } - - public static void insertItemIntoInventory(IInventory inventory, ItemStack stack, ForgeDirection side, int intoSlot, boolean doMove) { - insertItemIntoInventory(inventory, stack, side, intoSlot, doMove, true); - } - - public static void insertItemIntoInventory(IInventory inventory, ItemStack stack, ForgeDirection side, int intoSlot, boolean doMove, boolean canStack) { - if(stack == null) return; - - IInventory targetInventory = inventory; - - if(!doMove) { - targetInventory = new GenericInventory("temporary.inventory", false, targetInventory.getSizeInventory()); - ((GenericInventory)targetInventory).copyFrom(inventory); - } - - int i = 0; - int[] attemptSlots; - - if(inventory instanceof ISidedInventory && side != ForgeDirection.UNKNOWN) { - attemptSlots = ((ISidedInventory)inventory).getAccessibleSlotsFromSide(side.ordinal()); - if(attemptSlots == null) - attemptSlots = new int[0]; - } else { - attemptSlots = new int[inventory.getSizeInventory()]; - for(int a = 0; a < inventory.getSizeInventory(); a++) - attemptSlots[a] = a; - } - if(intoSlot > -1) { - Set x = new HashSet(); - for(int attemptedSlot : attemptSlots) - x.add(attemptedSlot); - - if(x.contains(intoSlot)) - attemptSlots = new int[] { intoSlot }; - else attemptSlots = new int[0]; - } - while(stack.stackSize > 0 && i < attemptSlots.length) { - if(side != ForgeDirection.UNKNOWN && inventory instanceof ISidedInventory) - if(!((ISidedInventory)inventory).canInsertItem(attemptSlots[i], stack, side.ordinal())) { - i++; - continue; - } - - tryInsertStack(targetInventory, attemptSlots[i], stack, canStack); - i++; - } - } - - public static int testInventoryInsertion(IInventory inventory, ItemStack item, ForgeDirection side) { - if(item == null || item.stackSize == 0) - return 0; - item = item.copy(); - - if(inventory == null) - return 0; - - inventory.getSizeInventory(); - - int itemSizeCounter = item.stackSize; - int[] availableSlots; - - if(inventory instanceof ISidedInventory) - availableSlots = ((ISidedInventory) inventory).getAccessibleSlotsFromSide(side.ordinal()); - else { - availableSlots = buildSlotsForLinearInventory(inventory); - } - - for(int i : availableSlots) { - if(itemSizeCounter <= 0) - break; - - if (!inventory.isItemValidForSlot(i, item)) - continue; - - if(side != ForgeDirection.UNKNOWN && inventory instanceof ISidedInventory) - if(!((ISidedInventory)inventory).canInsertItem(i, item, side.ordinal())) - continue; - - ItemStack inventorySlot = inventory.getStackInSlot(i); - if(inventorySlot == null) - itemSizeCounter -= Math.min(Math.min(itemSizeCounter, inventory.getInventoryStackLimit()), item.getMaxStackSize()); - else if(areMergeCandidates(item, inventorySlot)) { - int space = Math.min(inventory.getInventoryStackLimit(), inventorySlot.getMaxStackSize()) - inventorySlot.stackSize; - itemSizeCounter -= Math.min(itemSizeCounter, space); - } - } - - if(itemSizeCounter != item.stackSize) { - itemSizeCounter = Math.max(itemSizeCounter, 0); - return item.stackSize - itemSizeCounter; - } - - return 0; - } - - public static IInventory getInventory(World world, int x, int y, int z) { - TileEntity tileEntity = world.getTileEntity(x, y, z); - if(tileEntity instanceof TileEntityChest) { - Block chestBlock = world.getBlock(x, y, z); - if(world.getBlock(x - 1, y, z) == chestBlock) - return new InventoryLargeChest("Large chest", (IInventory)world.getTileEntity(x - 1, y, z), (IInventory)tileEntity); - if(world.getBlock(x + 1, y, z) == chestBlock) - return new InventoryLargeChest("Large chest", (IInventory)tileEntity, (IInventory)world.getTileEntity(x + 1, y, z)); - if(world.getBlock(x, y, z - 1) == chestBlock) - return new InventoryLargeChest("Large chest", (IInventory)world.getTileEntity(x, y, z - 1), (IInventory)tileEntity); - if(world.getBlock(x, y, z + 1) == chestBlock) - return new InventoryLargeChest("Large chest", (IInventory)tileEntity, (IInventory)world.getTileEntity(x, y, z + 1)); - } - return tileEntity instanceof IInventory ? (IInventory)tileEntity : null; - } - - public static IInventory getInventory(World world, int x, int y, int z, ForgeDirection direction) { - if(direction != null && direction != ForgeDirection.UNKNOWN) { - x += direction.offsetX; - y += direction.offsetY; - z += direction.offsetZ; - } - return getInventory(world, x, y, z); - - } - - public static IInventory getInventory(IInventory inventory) { - if(inventory instanceof TileEntityChest) { - TileEntity te = (TileEntity)inventory; - return getInventory(te.getWorldObj(), te.xCoord, te.yCoord, te.zCoord); - } - return inventory; - } - - public static int[] buildSlotsForLinearInventory(IInventory inv) { - int[] slots = new int[inv.getSizeInventory()]; - for (int i = 0; i < slots.length; i++) - slots[i] = i; - - return slots; - } - - public static class GenericInventory implements IInventory { - - protected String inventoryTitle; - protected int slotsCount; - protected ItemStack[] inventoryContents; - protected boolean isInvNameLocalized; - - public GenericInventory(String name, boolean isInvNameLocalized, int size) { - this.isInvNameLocalized = isInvNameLocalized; - slotsCount = size; - inventoryTitle = name; - inventoryContents = new ItemStack[size]; - } - - @Override - public ItemStack decrStackSize(int par1, int par2) { - if(inventoryContents[par1] != null) { - ItemStack itemstack; - - if(inventoryContents[par1].stackSize <= par2) { - itemstack = inventoryContents[par1]; - inventoryContents[par1] = null; - return itemstack; - } - - itemstack = inventoryContents[par1].splitStack(par2); - if(inventoryContents[par1].stackSize == 0) - inventoryContents[par1] = null; - - return itemstack; - } - return null; - } - - @Override - public int getInventoryStackLimit() { - return 64; - } - - @Override - public int getSizeInventory() { - return slotsCount; - } - - @Override - public ItemStack getStackInSlot(int i) { - return inventoryContents[i]; - } - - public ItemStack getStackInSlot(Enum i) { - return getStackInSlot(i.ordinal()); - } - - @Override - public ItemStack getStackInSlotOnClosing(int i) { - if(i >= inventoryContents.length) - return null; - - if(inventoryContents[i] != null) { - ItemStack itemstack = inventoryContents[i]; - inventoryContents[i] = null; - return itemstack; - } - - return null; - } - - public boolean isItem(int slot, Item item) { - return inventoryContents[slot] != null && inventoryContents[slot].getItem() == item; - } - - @Override - public boolean isItemValidForSlot(int i, ItemStack itemstack) { - return true; - } - - @Override - public boolean isUseableByPlayer(EntityPlayer entityplayer) { - return true; - } - - public void clearAndSetSlotCount(int amount) { - slotsCount = amount; - inventoryContents = new ItemStack[amount]; - } - - public void readFromNBT(NBTTagCompound tag) { - if(tag.hasKey("size")) - slotsCount = tag.getInteger("size"); - - NBTTagList nbttaglist = tag.getTagList("Items", 10); - inventoryContents = new ItemStack[slotsCount]; - for(int i = 0; i < nbttaglist.tagCount(); i++) { - NBTTagCompound stacktag = nbttaglist.getCompoundTagAt(i); - int j = stacktag.getByte("Slot"); - if(j >= 0 && j < inventoryContents.length) - inventoryContents[j] = ItemStack.loadItemStackFromNBT(stacktag); - } - } - - @Override - public void setInventorySlotContents(int i, ItemStack itemstack) { - inventoryContents[i] = itemstack; - - if(itemstack != null && itemstack.stackSize > getInventoryStackLimit()) - itemstack.stackSize = getInventoryStackLimit(); - } - - public void writeToNBT(NBTTagCompound tag) { - tag.setInteger("size", getSizeInventory()); - NBTTagList nbttaglist = new NBTTagList(); - for(int i = 0; i < inventoryContents.length; i++) { - if(inventoryContents[i] != null) { - NBTTagCompound stacktag = new NBTTagCompound(); - stacktag.setByte("Slot", (byte)i); - inventoryContents[i].writeToNBT(stacktag); - nbttaglist.appendTag(stacktag); - } - } - tag.setTag("Items", nbttaglist); - } - - public void copyFrom(IInventory inventory) { - for(int i = 0; i < inventory.getSizeInventory(); i++) - if(i < getSizeInventory()) { - ItemStack stack = inventory.getStackInSlot(i); - if(stack != null) - setInventorySlotContents(i, stack.copy()); - else setInventorySlotContents(i, null); - } - } - - public List contents() { - return Arrays.asList(inventoryContents); - } - - @Override - public String getInventoryName() { - return null; - } - - @Override - public boolean hasCustomInventoryName() { - return false; - } - - @Override - public void markDirty() { } - - @Override - public void openInventory() { } - - @Override - public void closeInventory() { } - } + public static void tryInsertStack(IInventory targetInventory, int slot, ItemStack stack, boolean canMerge) { + if (targetInventory.isItemValidForSlot(slot, stack)) { + ItemStack targetStack = targetInventory.getStackInSlot(slot); + if (targetStack == null) { + int space = targetInventory.getInventoryStackLimit(); + int mergeAmount = Math.min(space, stack.stackSize); + + ItemStack copy = stack.copy(); + copy.stackSize = mergeAmount; + targetInventory.setInventorySlotContents(slot, copy); + stack.stackSize -= mergeAmount; + } else if (canMerge) { + if (targetInventory.isItemValidForSlot(slot, stack) && areMergeCandidates(stack, targetStack)) { + int space = Math.min(targetInventory.getInventoryStackLimit(), targetStack.getMaxStackSize()) + - targetStack.stackSize; + int mergeAmount = Math.min(space, stack.stackSize); + + ItemStack copy = targetStack.copy(); + copy.stackSize += mergeAmount; + targetInventory.setInventorySlotContents(slot, copy); + stack.stackSize -= mergeAmount; + } + } + } + } + + protected static boolean areMergeCandidates(ItemStack source, ItemStack target) { + return source.isItemEqual(target) + && ItemStack.areItemStackTagsEqual(source, target) + && target.stackSize < target.getMaxStackSize(); + } + + public static void insertItemIntoInventory(IInventory inventory, ItemStack stack) { + insertItemIntoInventory(inventory, stack, ForgeDirection.UNKNOWN, -1); + } + + public static void insertItemIntoInventory( + IInventory inventory, ItemStack stack, ForgeDirection side, int intoSlot) { + insertItemIntoInventory(inventory, stack, side, intoSlot, true); + } + + public static void insertItemIntoInventory( + IInventory inventory, ItemStack stack, ForgeDirection side, int intoSlot, boolean doMove) { + insertItemIntoInventory(inventory, stack, side, intoSlot, doMove, true); + } + + public static void insertItemIntoInventory( + IInventory inventory, + ItemStack stack, + ForgeDirection side, + int intoSlot, + boolean doMove, + boolean canStack) { + if (stack == null) return; + + IInventory targetInventory = inventory; + + if (!doMove) { + targetInventory = new GenericInventory("temporary.inventory", false, targetInventory.getSizeInventory()); + ((GenericInventory) targetInventory).copyFrom(inventory); + } + + int i = 0; + int[] attemptSlots; + + if (inventory instanceof ISidedInventory && side != ForgeDirection.UNKNOWN) { + attemptSlots = ((ISidedInventory) inventory).getAccessibleSlotsFromSide(side.ordinal()); + if (attemptSlots == null) attemptSlots = new int[0]; + } else { + attemptSlots = new int[inventory.getSizeInventory()]; + for (int a = 0; a < inventory.getSizeInventory(); a++) attemptSlots[a] = a; + } + if (intoSlot > -1) { + Set x = new HashSet(); + for (int attemptedSlot : attemptSlots) x.add(attemptedSlot); + + if (x.contains(intoSlot)) attemptSlots = new int[] {intoSlot}; + else attemptSlots = new int[0]; + } + while (stack.stackSize > 0 && i < attemptSlots.length) { + if (side != ForgeDirection.UNKNOWN && inventory instanceof ISidedInventory) + if (!((ISidedInventory) inventory).canInsertItem(attemptSlots[i], stack, side.ordinal())) { + i++; + continue; + } + + tryInsertStack(targetInventory, attemptSlots[i], stack, canStack); + i++; + } + } + + public static int testInventoryInsertion(IInventory inventory, ItemStack item, ForgeDirection side) { + if (item == null || item.stackSize == 0) return 0; + item = item.copy(); + + if (inventory == null) return 0; + + inventory.getSizeInventory(); + + int itemSizeCounter = item.stackSize; + int[] availableSlots; + + if (inventory instanceof ISidedInventory) + availableSlots = ((ISidedInventory) inventory).getAccessibleSlotsFromSide(side.ordinal()); + else { + availableSlots = buildSlotsForLinearInventory(inventory); + } + + for (int i : availableSlots) { + if (itemSizeCounter <= 0) break; + + if (!inventory.isItemValidForSlot(i, item)) continue; + + if (side != ForgeDirection.UNKNOWN && inventory instanceof ISidedInventory) + if (!((ISidedInventory) inventory).canInsertItem(i, item, side.ordinal())) continue; + + ItemStack inventorySlot = inventory.getStackInSlot(i); + if (inventorySlot == null) + itemSizeCounter -= + Math.min(Math.min(itemSizeCounter, inventory.getInventoryStackLimit()), item.getMaxStackSize()); + else if (areMergeCandidates(item, inventorySlot)) { + int space = Math.min(inventory.getInventoryStackLimit(), inventorySlot.getMaxStackSize()) + - inventorySlot.stackSize; + itemSizeCounter -= Math.min(itemSizeCounter, space); + } + } + + if (itemSizeCounter != item.stackSize) { + itemSizeCounter = Math.max(itemSizeCounter, 0); + return item.stackSize - itemSizeCounter; + } + + return 0; + } + + public static IInventory getInventory(World world, int x, int y, int z) { + TileEntity tileEntity = world.getTileEntity(x, y, z); + if (tileEntity instanceof TileEntityChest) { + Block chestBlock = world.getBlock(x, y, z); + if (world.getBlock(x - 1, y, z) == chestBlock) + return new InventoryLargeChest( + "Large chest", (IInventory) world.getTileEntity(x - 1, y, z), (IInventory) tileEntity); + if (world.getBlock(x + 1, y, z) == chestBlock) + return new InventoryLargeChest( + "Large chest", (IInventory) tileEntity, (IInventory) world.getTileEntity(x + 1, y, z)); + if (world.getBlock(x, y, z - 1) == chestBlock) + return new InventoryLargeChest( + "Large chest", (IInventory) world.getTileEntity(x, y, z - 1), (IInventory) tileEntity); + if (world.getBlock(x, y, z + 1) == chestBlock) + return new InventoryLargeChest( + "Large chest", (IInventory) tileEntity, (IInventory) world.getTileEntity(x, y, z + 1)); + } + return tileEntity instanceof IInventory ? (IInventory) tileEntity : null; + } + + public static IInventory getInventory(World world, int x, int y, int z, ForgeDirection direction) { + if (direction != null && direction != ForgeDirection.UNKNOWN) { + x += direction.offsetX; + y += direction.offsetY; + z += direction.offsetZ; + } + return getInventory(world, x, y, z); + } + + public static IInventory getInventory(IInventory inventory) { + if (inventory instanceof TileEntityChest) { + TileEntity te = (TileEntity) inventory; + return getInventory(te.getWorldObj(), te.xCoord, te.yCoord, te.zCoord); + } + return inventory; + } + + public static int[] buildSlotsForLinearInventory(IInventory inv) { + int[] slots = new int[inv.getSizeInventory()]; + for (int i = 0; i < slots.length; i++) slots[i] = i; + + return slots; + } + + public static class GenericInventory implements IInventory { + + protected String inventoryTitle; + protected int slotsCount; + protected ItemStack[] inventoryContents; + protected boolean isInvNameLocalized; + + public GenericInventory(String name, boolean isInvNameLocalized, int size) { + this.isInvNameLocalized = isInvNameLocalized; + slotsCount = size; + inventoryTitle = name; + inventoryContents = new ItemStack[size]; + } + + @Override + public ItemStack decrStackSize(int par1, int par2) { + if (inventoryContents[par1] != null) { + ItemStack itemstack; + + if (inventoryContents[par1].stackSize <= par2) { + itemstack = inventoryContents[par1]; + inventoryContents[par1] = null; + return itemstack; + } + + itemstack = inventoryContents[par1].splitStack(par2); + if (inventoryContents[par1].stackSize == 0) inventoryContents[par1] = null; + + return itemstack; + } + return null; + } + + @Override + public int getInventoryStackLimit() { + return 64; + } + + @Override + public int getSizeInventory() { + return slotsCount; + } + + @Override + public ItemStack getStackInSlot(int i) { + return inventoryContents[i]; + } + + public ItemStack getStackInSlot(Enum i) { + return getStackInSlot(i.ordinal()); + } + + @Override + public ItemStack getStackInSlotOnClosing(int i) { + if (i >= inventoryContents.length) return null; + + if (inventoryContents[i] != null) { + ItemStack itemstack = inventoryContents[i]; + inventoryContents[i] = null; + return itemstack; + } + + return null; + } + + public boolean isItem(int slot, Item item) { + return inventoryContents[slot] != null && inventoryContents[slot].getItem() == item; + } + + @Override + public boolean isItemValidForSlot(int i, ItemStack itemstack) { + return true; + } + + @Override + public boolean isUseableByPlayer(EntityPlayer entityplayer) { + return true; + } + + public void clearAndSetSlotCount(int amount) { + slotsCount = amount; + inventoryContents = new ItemStack[amount]; + } + + public void readFromNBT(NBTTagCompound tag) { + if (tag.hasKey("size")) slotsCount = tag.getInteger("size"); + + NBTTagList nbttaglist = tag.getTagList("Items", 10); + inventoryContents = new ItemStack[slotsCount]; + for (int i = 0; i < nbttaglist.tagCount(); i++) { + NBTTagCompound stacktag = nbttaglist.getCompoundTagAt(i); + int j = stacktag.getByte("Slot"); + if (j >= 0 && j < inventoryContents.length) + inventoryContents[j] = ItemStack.loadItemStackFromNBT(stacktag); + } + } + + @Override + public void setInventorySlotContents(int i, ItemStack itemstack) { + inventoryContents[i] = itemstack; + + if (itemstack != null && itemstack.stackSize > getInventoryStackLimit()) + itemstack.stackSize = getInventoryStackLimit(); + } + + public void writeToNBT(NBTTagCompound tag) { + tag.setInteger("size", getSizeInventory()); + NBTTagList nbttaglist = new NBTTagList(); + for (int i = 0; i < inventoryContents.length; i++) { + if (inventoryContents[i] != null) { + NBTTagCompound stacktag = new NBTTagCompound(); + stacktag.setByte("Slot", (byte) i); + inventoryContents[i].writeToNBT(stacktag); + nbttaglist.appendTag(stacktag); + } + } + tag.setTag("Items", nbttaglist); + } + + public void copyFrom(IInventory inventory) { + for (int i = 0; i < inventory.getSizeInventory(); i++) + if (i < getSizeInventory()) { + ItemStack stack = inventory.getStackInSlot(i); + if (stack != null) setInventorySlotContents(i, stack.copy()); + else setInventorySlotContents(i, null); + } + } + + public List contents() { + return Arrays.asList(inventoryContents); + } + + @Override + public String getInventoryName() { + return null; + } + + @Override + public boolean hasCustomInventoryName() { + return false; + } + + @Override + public void markDirty() {} + + @Override + public void openInventory() {} + + @Override + public void closeInventory() {} + } } diff --git a/src/main/java/vazkii/botania/common/core/helper/ItemNBTHelper.java b/src/main/java/vazkii/botania/common/core/helper/ItemNBTHelper.java index 5a0f33421a..8ae9bf477c 100644 --- a/src/main/java/vazkii/botania/common/core/helper/ItemNBTHelper.java +++ b/src/main/java/vazkii/botania/common/core/helper/ItemNBTHelper.java @@ -14,229 +14,226 @@ package vazkii.botania.common.core.helper; import codechicken.nei.PositionedStack; +import java.util.Collection; +import java.util.Set; +import javax.annotation.Nullable; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTBase; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagList; import net.minecraftforge.oredict.OreDictionary; -import javax.annotation.Nullable; -import java.util.Collection; -import java.util.Set; - public final class ItemNBTHelper { - /** Checks if an ItemStack has a Tag Compound **/ - public static boolean detectNBT(ItemStack stack) { - return stack.hasTagCompound(); - } - - /** Tries to initialize an NBT Tag Compound in an ItemStack, - * this will not do anything if the stack already has a tag - * compound **/ - public static void initNBT(ItemStack stack) { - if(!detectNBT(stack)) - injectNBT(stack, new NBTTagCompound()); - } - - /** Injects an NBT Tag Compound to an ItemStack, no checks - * are made previously **/ - public static void injectNBT(ItemStack stack, NBTTagCompound nbt) { - stack.setTagCompound(nbt); - } - - /** Gets the NBTTagCompound in an ItemStack. Tries to init it - * previously in case there isn't one present **/ - public static NBTTagCompound getNBT(ItemStack stack) { - initNBT(stack); - return stack.getTagCompound(); - } - - // SETTERS /////////////////////////////////////////////////////////////////// - - public static void setBoolean(ItemStack stack, String tag, boolean b) { - getNBT(stack).setBoolean(tag, b); - } - - public static void setByte(ItemStack stack, String tag, byte b) { - getNBT(stack).setByte(tag, b); - } - - public static void setShort(ItemStack stack, String tag, short s) { - getNBT(stack).setShort(tag, s); - } - - public static void setInt(ItemStack stack, String tag, int i) { - getNBT(stack).setInteger(tag, i); - } - - public static void setLong(ItemStack stack, String tag, long l) { - getNBT(stack).setLong(tag, l); - } - - public static void setFloat(ItemStack stack, String tag, float f) { - getNBT(stack).setFloat(tag, f); - } - - public static void setDouble(ItemStack stack, String tag, double d) { - getNBT(stack).setDouble(tag, d); - } - - public static void setCompound(ItemStack stack, String tag, NBTTagCompound cmp) { - if(!tag.equalsIgnoreCase("ench")) // not override the enchantments - getNBT(stack).setTag(tag, cmp); - } - - public static void setString(ItemStack stack, String tag, String s) { - getNBT(stack).setString(tag, s); - } - - public static void setList(ItemStack stack, String tag, NBTTagList list) { - getNBT(stack).setTag(tag, list); - } - - // GETTERS /////////////////////////////////////////////////////////////////// - - public static boolean verifyExistance(ItemStack stack, String tag) { - return stack != null && getNBT(stack).hasKey(tag); - } - - public static boolean getBoolean(ItemStack stack, String tag, boolean defaultExpected) { - return verifyExistance(stack, tag) ? getNBT(stack).getBoolean(tag) : defaultExpected; - } - - public static byte getByte(ItemStack stack, String tag, byte defaultExpected) { - return verifyExistance(stack, tag) ? getNBT(stack).getByte(tag) : defaultExpected; - } - - public static short getShort(ItemStack stack, String tag, short defaultExpected) { - return verifyExistance(stack, tag) ? getNBT(stack).getShort(tag) : defaultExpected; - } - - public static int getInt(ItemStack stack, String tag, int defaultExpected) { - return verifyExistance(stack, tag) ? getNBT(stack).getInteger(tag) : defaultExpected; - } - - public static long getLong(ItemStack stack, String tag, long defaultExpected) { - return verifyExistance(stack, tag) ? getNBT(stack).getLong(tag) : defaultExpected; - } - - public static float getFloat(ItemStack stack, String tag, float defaultExpected) { - return verifyExistance(stack, tag) ? getNBT(stack).getFloat(tag) : defaultExpected; - } - - public static double getDouble(ItemStack stack, String tag, double defaultExpected) { - return verifyExistance(stack, tag) ? getNBT(stack).getDouble(tag) : defaultExpected; - } - - /** If nullifyOnFail is true it'll return null if it doesn't find any - * compounds, otherwise it'll return a new one. **/ - public static NBTTagCompound getCompound(ItemStack stack, String tag, boolean nullifyOnFail) { - return verifyExistance(stack, tag) ? getNBT(stack).getCompoundTag(tag) : nullifyOnFail ? null : new NBTTagCompound(); - } - - public static String getString(ItemStack stack, String tag, String defaultExpected) { - return verifyExistance(stack, tag) ? getNBT(stack).getString(tag) : defaultExpected; - } - - public static NBTTagList getList(ItemStack stack, String tag, int objtype, boolean nullifyOnFail) { - return verifyExistance(stack, tag) ? getNBT(stack).getTagList(tag, objtype) : nullifyOnFail ? null : new NBTTagList(); - } - - // Utils /////////////////////////////////////////////////////////////////// - - /** - * NBT-friendly version of {@link codechicken.nei.NEIServerUtils#areStacksSameType(ItemStack, ItemStack)} - * @param stack1 The {@link ItemStack} being compared. - * @param stack2 The {@link ItemStack} to compare to. - * @return whether the two items are the same in terms of itemID, damage and NBT. - */ - public static boolean areStacksSameTypeWithNBT(ItemStack stack1, ItemStack stack2) { - return stack1 != null && stack2 != null && - stack1.getItem() == stack2.getItem() && - (!stack2.getHasSubtypes() || stack2.getItemDamage() == stack1.getItemDamage()) && - matchTag(stack1.getTagCompound(), stack2.getTagCompound()); - } - - /** - * NBT-friendly version of {@link codechicken.nei.NEIServerUtils#areStacksSameTypeCrafting(ItemStack, ItemStack)} - * @param stack1 The {@link ItemStack} being compared. - * @param stack2 The {@link ItemStack} to compare to. - * @return whether the two items are the same from the perspective of a crafting inventory. - */ - public static boolean areStacksSameTypeCraftingWithNBT(ItemStack stack1, ItemStack stack2) { - return stack1 != null && stack2 != null && - stack1.getItem() == stack2.getItem() && - ( - stack1.getItemDamage() == stack2.getItemDamage() || - stack1.getItemDamage() == OreDictionary.WILDCARD_VALUE || - stack2.getItemDamage() == OreDictionary.WILDCARD_VALUE || - stack1.getItem().isDamageable() - ) && - matchTag(stack1.getTagCompound(), stack2.getTagCompound()); - } - - /** - * Returns true if the `target` tag contains all of the tags and values present in the `template` tag. Recurses into - * compound tags and matches all template keys and values; recurses into list tags and matches the template against - * the first elements of target. Empty lists and compounds in the template will match target lists and compounds of - * any size. - */ - public static boolean matchTag(@Nullable NBTBase template, @Nullable NBTBase target) { - if (template instanceof NBTTagCompound && target instanceof NBTTagCompound) { - return matchTagCompound((NBTTagCompound) template, (NBTTagCompound) target); - } else if (template instanceof NBTTagList && target instanceof NBTTagList) { - return matchTagList((NBTTagList) template, (NBTTagList) target); - } else { - return template == null || (target != null && target.equals(template)); - } - } - - private static boolean matchTagCompound(NBTTagCompound template, NBTTagCompound target) { - if (template.tagMap.size() > target.tagMap.size()) return false; - - //noinspection unchecked - for (String key : (Set) template.func_150296_c()) { - if (!matchTag(template.getTag(key), target.getTag(key))) return false; - } - - return true; - } - - private static boolean matchTagList(NBTTagList template, NBTTagList target) { - if (template.tagCount() > target.tagCount()) return false; - - for (int i = 0; i < template.tagCount(); i++) { - if (!matchTag(get(template, i), get(target, i))) return false; - } - - return true; - } - - private static NBTBase get(NBTTagList tag, int idx) - { - return idx >= 0 && idx < tag.tagList.size() ? (NBTBase)tag.tagList.get(idx) : null; - } - - /** - * NBT-friendly version of {@link codechicken.nei.recipe.TemplateRecipeHandler.CachedRecipe#contains(Collection, ItemStack)} - */ - public static boolean cachedRecipeContainsWithNBT(Collection ingredients, ItemStack ingredient) { - for (PositionedStack stack : ingredients) - if (positionedStackContainsWithNBT(stack, ingredient)) - return true; - - return false; - } - - /** - * NBT-friendly version of {@link codechicken.nei.PositionedStack#contains(ItemStack)} - */ - public static boolean positionedStackContainsWithNBT(PositionedStack stack, ItemStack ingredient) { - for(ItemStack item : stack.items) - if(areStacksSameTypeCraftingWithNBT(item, ingredient)) - return true; - - return false; - } + /** Checks if an ItemStack has a Tag Compound **/ + public static boolean detectNBT(ItemStack stack) { + return stack.hasTagCompound(); + } + + /** Tries to initialize an NBT Tag Compound in an ItemStack, + * this will not do anything if the stack already has a tag + * compound **/ + public static void initNBT(ItemStack stack) { + if (!detectNBT(stack)) injectNBT(stack, new NBTTagCompound()); + } + + /** Injects an NBT Tag Compound to an ItemStack, no checks + * are made previously **/ + public static void injectNBT(ItemStack stack, NBTTagCompound nbt) { + stack.setTagCompound(nbt); + } + + /** Gets the NBTTagCompound in an ItemStack. Tries to init it + * previously in case there isn't one present **/ + public static NBTTagCompound getNBT(ItemStack stack) { + initNBT(stack); + return stack.getTagCompound(); + } + + // SETTERS /////////////////////////////////////////////////////////////////// + + public static void setBoolean(ItemStack stack, String tag, boolean b) { + getNBT(stack).setBoolean(tag, b); + } + + public static void setByte(ItemStack stack, String tag, byte b) { + getNBT(stack).setByte(tag, b); + } + + public static void setShort(ItemStack stack, String tag, short s) { + getNBT(stack).setShort(tag, s); + } + + public static void setInt(ItemStack stack, String tag, int i) { + getNBT(stack).setInteger(tag, i); + } + + public static void setLong(ItemStack stack, String tag, long l) { + getNBT(stack).setLong(tag, l); + } + + public static void setFloat(ItemStack stack, String tag, float f) { + getNBT(stack).setFloat(tag, f); + } + + public static void setDouble(ItemStack stack, String tag, double d) { + getNBT(stack).setDouble(tag, d); + } + + public static void setCompound(ItemStack stack, String tag, NBTTagCompound cmp) { + if (!tag.equalsIgnoreCase("ench")) // not override the enchantments + getNBT(stack).setTag(tag, cmp); + } + + public static void setString(ItemStack stack, String tag, String s) { + getNBT(stack).setString(tag, s); + } + + public static void setList(ItemStack stack, String tag, NBTTagList list) { + getNBT(stack).setTag(tag, list); + } + + // GETTERS /////////////////////////////////////////////////////////////////// + + public static boolean verifyExistance(ItemStack stack, String tag) { + return stack != null && getNBT(stack).hasKey(tag); + } + + public static boolean getBoolean(ItemStack stack, String tag, boolean defaultExpected) { + return verifyExistance(stack, tag) ? getNBT(stack).getBoolean(tag) : defaultExpected; + } + + public static byte getByte(ItemStack stack, String tag, byte defaultExpected) { + return verifyExistance(stack, tag) ? getNBT(stack).getByte(tag) : defaultExpected; + } + + public static short getShort(ItemStack stack, String tag, short defaultExpected) { + return verifyExistance(stack, tag) ? getNBT(stack).getShort(tag) : defaultExpected; + } + + public static int getInt(ItemStack stack, String tag, int defaultExpected) { + return verifyExistance(stack, tag) ? getNBT(stack).getInteger(tag) : defaultExpected; + } + + public static long getLong(ItemStack stack, String tag, long defaultExpected) { + return verifyExistance(stack, tag) ? getNBT(stack).getLong(tag) : defaultExpected; + } + + public static float getFloat(ItemStack stack, String tag, float defaultExpected) { + return verifyExistance(stack, tag) ? getNBT(stack).getFloat(tag) : defaultExpected; + } + + public static double getDouble(ItemStack stack, String tag, double defaultExpected) { + return verifyExistance(stack, tag) ? getNBT(stack).getDouble(tag) : defaultExpected; + } + + /** If nullifyOnFail is true it'll return null if it doesn't find any + * compounds, otherwise it'll return a new one. **/ + public static NBTTagCompound getCompound(ItemStack stack, String tag, boolean nullifyOnFail) { + return verifyExistance(stack, tag) + ? getNBT(stack).getCompoundTag(tag) + : nullifyOnFail ? null : new NBTTagCompound(); + } + + public static String getString(ItemStack stack, String tag, String defaultExpected) { + return verifyExistance(stack, tag) ? getNBT(stack).getString(tag) : defaultExpected; + } + + public static NBTTagList getList(ItemStack stack, String tag, int objtype, boolean nullifyOnFail) { + return verifyExistance(stack, tag) + ? getNBT(stack).getTagList(tag, objtype) + : nullifyOnFail ? null : new NBTTagList(); + } + + // Utils /////////////////////////////////////////////////////////////////// + + /** + * NBT-friendly version of {@link codechicken.nei.NEIServerUtils#areStacksSameType(ItemStack, ItemStack)} + * @param stack1 The {@link ItemStack} being compared. + * @param stack2 The {@link ItemStack} to compare to. + * @return whether the two items are the same in terms of itemID, damage and NBT. + */ + public static boolean areStacksSameTypeWithNBT(ItemStack stack1, ItemStack stack2) { + return stack1 != null + && stack2 != null + && stack1.getItem() == stack2.getItem() + && (!stack2.getHasSubtypes() || stack2.getItemDamage() == stack1.getItemDamage()) + && matchTag(stack1.getTagCompound(), stack2.getTagCompound()); + } + + /** + * NBT-friendly version of {@link codechicken.nei.NEIServerUtils#areStacksSameTypeCrafting(ItemStack, ItemStack)} + * @param stack1 The {@link ItemStack} being compared. + * @param stack2 The {@link ItemStack} to compare to. + * @return whether the two items are the same from the perspective of a crafting inventory. + */ + public static boolean areStacksSameTypeCraftingWithNBT(ItemStack stack1, ItemStack stack2) { + return stack1 != null + && stack2 != null + && stack1.getItem() == stack2.getItem() + && (stack1.getItemDamage() == stack2.getItemDamage() + || stack1.getItemDamage() == OreDictionary.WILDCARD_VALUE + || stack2.getItemDamage() == OreDictionary.WILDCARD_VALUE + || stack1.getItem().isDamageable()) + && matchTag(stack1.getTagCompound(), stack2.getTagCompound()); + } + + /** + * Returns true if the `target` tag contains all of the tags and values present in the `template` tag. Recurses into + * compound tags and matches all template keys and values; recurses into list tags and matches the template against + * the first elements of target. Empty lists and compounds in the template will match target lists and compounds of + * any size. + */ + public static boolean matchTag(@Nullable NBTBase template, @Nullable NBTBase target) { + if (template instanceof NBTTagCompound && target instanceof NBTTagCompound) { + return matchTagCompound((NBTTagCompound) template, (NBTTagCompound) target); + } else if (template instanceof NBTTagList && target instanceof NBTTagList) { + return matchTagList((NBTTagList) template, (NBTTagList) target); + } else { + return template == null || (target != null && target.equals(template)); + } + } + + private static boolean matchTagCompound(NBTTagCompound template, NBTTagCompound target) { + if (template.tagMap.size() > target.tagMap.size()) return false; + + //noinspection unchecked + for (String key : (Set) template.func_150296_c()) { + if (!matchTag(template.getTag(key), target.getTag(key))) return false; + } + + return true; + } + + private static boolean matchTagList(NBTTagList template, NBTTagList target) { + if (template.tagCount() > target.tagCount()) return false; + + for (int i = 0; i < template.tagCount(); i++) { + if (!matchTag(get(template, i), get(target, i))) return false; + } + + return true; + } + + private static NBTBase get(NBTTagList tag, int idx) { + return idx >= 0 && idx < tag.tagList.size() ? (NBTBase) tag.tagList.get(idx) : null; + } + + /** + * NBT-friendly version of {@link codechicken.nei.recipe.TemplateRecipeHandler.CachedRecipe#contains(Collection, ItemStack)} + */ + public static boolean cachedRecipeContainsWithNBT(Collection ingredients, ItemStack ingredient) { + for (PositionedStack stack : ingredients) if (positionedStackContainsWithNBT(stack, ingredient)) return true; + + return false; + } + + /** + * NBT-friendly version of {@link codechicken.nei.PositionedStack#contains(ItemStack)} + */ + public static boolean positionedStackContainsWithNBT(PositionedStack stack, ItemStack ingredient) { + for (ItemStack item : stack.items) if (areStacksSameTypeCraftingWithNBT(item, ingredient)) return true; + + return false; + } } diff --git a/src/main/java/vazkii/botania/common/core/helper/MathHelper.java b/src/main/java/vazkii/botania/common/core/helper/MathHelper.java index e31af70427..01101a2c9e 100644 --- a/src/main/java/vazkii/botania/common/core/helper/MathHelper.java +++ b/src/main/java/vazkii/botania/common/core/helper/MathHelper.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jan 22, 2014, 5:49:50 PM (GMT)] */ package vazkii.botania.common.core.helper; @@ -15,30 +15,30 @@ public final class MathHelper { - public static float pointDistanceSpace(double x1, double y1, double z1, double x2, double y2, double z2) { - return (float) Math.sqrt(Math.pow(x1 - x2, 2) + Math.pow(y1 - y2, 2) + Math.pow(z1 - z2, 2)); - } + public static float pointDistanceSpace(double x1, double y1, double z1, double x2, double y2, double z2) { + return (float) Math.sqrt(Math.pow(x1 - x2, 2) + Math.pow(y1 - y2, 2) + Math.pow(z1 - z2, 2)); + } - // Backwards compatibility - public static float pointDistancePlane(double x1, double y1, double x2, double y2) { - return VanillaPacketDispatcher.pointDistancePlane(x1, y1, x2, y2); - } + // Backwards compatibility + public static float pointDistancePlane(double x1, double y1, double x2, double y2) { + return VanillaPacketDispatcher.pointDistancePlane(x1, y1, x2, y2); + } - public static void setEntityMotionFromVector(Entity entity, Vector3 originalPosVector, float modifier) { - Vector3 entityVector = Vector3.fromEntityCenter(entity); - Vector3 finalVector = originalPosVector.copy().subtract(entityVector); + public static void setEntityMotionFromVector(Entity entity, Vector3 originalPosVector, float modifier) { + Vector3 entityVector = Vector3.fromEntityCenter(entity); + Vector3 finalVector = originalPosVector.copy().subtract(entityVector); - if(finalVector.mag() > 1) - finalVector.normalize(); + if (finalVector.mag() > 1) finalVector.normalize(); - entity.motionX = finalVector.x * modifier; - entity.motionY = finalVector.y * modifier; - entity.motionZ = finalVector.z * modifier; - } + entity.motionX = finalVector.x * modifier; + entity.motionY = finalVector.y * modifier; + entity.motionZ = finalVector.z * modifier; + } - private static final String[] ORDINAL_SUFFIXES = new String[]{ "th", "st", "nd", "rd", "th", "th", "th", "th", "th", "th" }; - public static String numberToOrdinal(int i) { - return i % 100 == 11 || i % 100 == 12 || i % 100 == 13 ? i + "th" : i + ORDINAL_SUFFIXES[i % 10]; - } + private static final String[] ORDINAL_SUFFIXES = + new String[] {"th", "st", "nd", "rd", "th", "th", "th", "th", "th", "th"}; + public static String numberToOrdinal(int i) { + return i % 100 == 11 || i % 100 == 12 || i % 100 == 13 ? i + "th" : i + ORDINAL_SUFFIXES[i % 10]; + } } diff --git a/src/main/java/vazkii/botania/common/core/helper/ObfuscationHelper.java b/src/main/java/vazkii/botania/common/core/helper/ObfuscationHelper.java index 8bc4782b0a..17c5ef9dd3 100644 --- a/src/main/java/vazkii/botania/common/core/helper/ObfuscationHelper.java +++ b/src/main/java/vazkii/botania/common/core/helper/ObfuscationHelper.java @@ -2,22 +2,22 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jan 17, 2014, 4:52:37 PM (GMT)] */ package vazkii.botania.common.core.helper; +import cpw.mods.fml.relauncher.ReflectionHelper; import net.minecraft.client.particle.EffectRenderer; import net.minecraft.util.ResourceLocation; import vazkii.botania.common.lib.LibObfuscation; -import cpw.mods.fml.relauncher.ReflectionHelper; public class ObfuscationHelper { - public static ResourceLocation getParticleTexture() { - return ReflectionHelper.getPrivateValue(EffectRenderer.class, null, LibObfuscation.PARTICLE_TEXTURES); - } + public static ResourceLocation getParticleTexture() { + return ReflectionHelper.getPrivateValue(EffectRenderer.class, null, LibObfuscation.PARTICLE_TEXTURES); + } } diff --git a/src/main/java/vazkii/botania/common/core/helper/Quat.java b/src/main/java/vazkii/botania/common/core/helper/Quat.java index c3268e4707..7ab949c562 100644 --- a/src/main/java/vazkii/botania/common/core/helper/Quat.java +++ b/src/main/java/vazkii/botania/common/core/helper/Quat.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [? (GMT)] */ package vazkii.botania.common.core.helper; @@ -15,107 +15,107 @@ public class Quat { - public double x; - public double y; - public double z; - public double s; - - public Quat() { - s = 1.0D; - x = 0.0D; - y = 0.0D; - z = 0.0D; - } - - public Quat(Quat quat) { - x = quat.x; - y = quat.y; - z = quat.z; - s = quat.s; - } - - public Quat(double d, double d1, double d2, double d3) { - x = d1; - y = d2; - z = d3; - s = d; - } - - public void set(Quat quat) { - x = quat.x; - y = quat.y; - z = quat.z; - s = quat.s; - } - - public static Quat aroundAxis(double ax, double ay, double az, double angle) { - angle *= 0.5D; - double d4 = Math.sin(angle); - return new Quat(Math.cos(angle), ax * d4, ay * d4, az * d4); - } - - public void multiply(Quat quat) { - double d = s * quat.s - x * quat.x - y * quat.y - z * quat.z; - double d1 = s * quat.x + x * quat.s - y * quat.z + z * quat.y; - double d2 = s * quat.y + x * quat.z + y * quat.s - z * quat.x; - double d3 = s * quat.z - x * quat.y + y * quat.x + z * quat.s; - s = d; - x = d1; - y = d2; - z = d3; - } - - public void rightMultiply(Quat quat) { - double d = s * quat.s - x * quat.x - y * quat.y - z * quat.z; - double d1 = s * quat.x + x * quat.s + y * quat.z - z * quat.y; - double d2 = s * quat.y - x * quat.z + y * quat.s + z * quat.x; - double d3 = s * quat.z + x * quat.y - y * quat.x + z * quat.s; - s = d; - x = d1; - y = d2; - z = d3; - } - - public double mag() { - return Math.sqrt(x * x + y * y + z * z + s * s); - } - - public void normalize() { - double d = mag(); - if (d == 0.0D) { - return; - } else { - d = 1.0D / d; - x *= d; - y *= d; - z *= d; - s *= d; - return; - } - } - - public void rotate(Vector3 vec) { - double d = -x * vec.x - y * vec.y - z * vec.z; - double d1 = s * vec.x + y * vec.z - z * vec.y; - double d2 = s * vec.y - x * vec.z + z * vec.x; - double d3 = s * vec.z + x * vec.y - y * vec.x; - vec.x = d1 * s - d * x - d2 * z + d3 * y; - vec.y = d2 * s - d * y + d1 * z - d3 * x; - vec.z = d3 * s - d * z - d1 * y + d2 * x; - } - - @Override - public String toString() { - StringBuilder stringbuilder = new StringBuilder(); - Formatter formatter = new Formatter(stringbuilder, Locale.US); - formatter.format("Quaternion:\n", new Object[0]); - formatter.format(" < %f %f %f %f >\n", Double.valueOf(s), Double.valueOf(x), Double.valueOf(y), Double.valueOf(z)); - formatter.close(); - return stringbuilder.toString(); - } - - public static Quat aroundAxis(Vector3 axis, double angle) { - return aroundAxis(axis.x, axis.y, axis.z, angle); - } - -} \ No newline at end of file + public double x; + public double y; + public double z; + public double s; + + public Quat() { + s = 1.0D; + x = 0.0D; + y = 0.0D; + z = 0.0D; + } + + public Quat(Quat quat) { + x = quat.x; + y = quat.y; + z = quat.z; + s = quat.s; + } + + public Quat(double d, double d1, double d2, double d3) { + x = d1; + y = d2; + z = d3; + s = d; + } + + public void set(Quat quat) { + x = quat.x; + y = quat.y; + z = quat.z; + s = quat.s; + } + + public static Quat aroundAxis(double ax, double ay, double az, double angle) { + angle *= 0.5D; + double d4 = Math.sin(angle); + return new Quat(Math.cos(angle), ax * d4, ay * d4, az * d4); + } + + public void multiply(Quat quat) { + double d = s * quat.s - x * quat.x - y * quat.y - z * quat.z; + double d1 = s * quat.x + x * quat.s - y * quat.z + z * quat.y; + double d2 = s * quat.y + x * quat.z + y * quat.s - z * quat.x; + double d3 = s * quat.z - x * quat.y + y * quat.x + z * quat.s; + s = d; + x = d1; + y = d2; + z = d3; + } + + public void rightMultiply(Quat quat) { + double d = s * quat.s - x * quat.x - y * quat.y - z * quat.z; + double d1 = s * quat.x + x * quat.s + y * quat.z - z * quat.y; + double d2 = s * quat.y - x * quat.z + y * quat.s + z * quat.x; + double d3 = s * quat.z + x * quat.y - y * quat.x + z * quat.s; + s = d; + x = d1; + y = d2; + z = d3; + } + + public double mag() { + return Math.sqrt(x * x + y * y + z * z + s * s); + } + + public void normalize() { + double d = mag(); + if (d == 0.0D) { + return; + } else { + d = 1.0D / d; + x *= d; + y *= d; + z *= d; + s *= d; + return; + } + } + + public void rotate(Vector3 vec) { + double d = -x * vec.x - y * vec.y - z * vec.z; + double d1 = s * vec.x + y * vec.z - z * vec.y; + double d2 = s * vec.y - x * vec.z + z * vec.x; + double d3 = s * vec.z + x * vec.y - y * vec.x; + vec.x = d1 * s - d * x - d2 * z + d3 * y; + vec.y = d2 * s - d * y + d1 * z - d3 * x; + vec.z = d3 * s - d * z - d1 * y + d2 * x; + } + + @Override + public String toString() { + StringBuilder stringbuilder = new StringBuilder(); + Formatter formatter = new Formatter(stringbuilder, Locale.US); + formatter.format("Quaternion:\n", new Object[0]); + formatter.format( + " < %f %f %f %f >\n", Double.valueOf(s), Double.valueOf(x), Double.valueOf(y), Double.valueOf(z)); + formatter.close(); + return stringbuilder.toString(); + } + + public static Quat aroundAxis(Vector3 axis, double angle) { + return aroundAxis(axis.x, axis.y, axis.z, angle); + } +} diff --git a/src/main/java/vazkii/botania/common/core/helper/Vector3.java b/src/main/java/vazkii/botania/common/core/helper/Vector3.java index 02c47ba543..0cb0306538 100644 --- a/src/main/java/vazkii/botania/common/core/helper/Vector3.java +++ b/src/main/java/vazkii/botania/common/core/helper/Vector3.java @@ -2,302 +2,293 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [? (GMT)] */ package vazkii.botania.common.core.helper; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; import java.math.BigDecimal; import java.math.MathContext; import java.math.RoundingMode; - import net.minecraft.entity.Entity; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.AxisAlignedBB; import net.minecraft.util.Vec3; - import org.lwjgl.opengl.GL11; import org.lwjgl.util.vector.Vector3f; import org.lwjgl.util.vector.Vector4f; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; - -public class Vector3 -{ - public static Vector3 zero = new Vector3(); - public static Vector3 one = new Vector3(1, 1, 1); - public static Vector3 center = new Vector3(0.5, 0.5, 0.5); - - public double x; - public double y; - public double z; - - public Vector3() { - } - - public Vector3(double d, double d1, double d2) { - x = d; - y = d1; - z = d2; - } - - public Vector3(Vector3 vec) { - x = vec.x; - y = vec.y; - z = vec.z; - } - - public Vector3(Vec3 vec) { - x = vec.xCoord; - y = vec.yCoord; - z = vec.zCoord; - } - - public Vector3 copy() { - return new Vector3(this); - } - - public static Vector3 fromEntity(Entity e) { - return new Vector3(e.posX, e.posY, e.posZ); - } - - public static Vector3 fromEntityCenter(Entity e) { - return new Vector3(e.posX, e.posY - e.yOffset + e.height / 2, e.posZ); - } - - public static Vector3 fromTileEntity(TileEntity e) { - return new Vector3(e.xCoord, e.yCoord, e.zCoord); - } - - public static Vector3 fromTileEntityCenter(TileEntity e) { - return new Vector3(e.xCoord + 0.5, e.yCoord + 0.5, e.zCoord + 0.5); - } - - public Vector3 set(double d, double d1, double d2) { - x = d; - y = d1; - z = d2; - return this; - } - - public Vector3 set(Vector3 vec) { - x = vec.x; - y = vec.y; - z = vec.z; - return this; - } - - public double dotProduct(Vector3 vec) { - double d = vec.x * x + vec.y * y + vec.z * z; - - if(d > 1 && d < 1.00001) - d = 1; - else if(d < -1 && d > -1.00001) - d = -1; - return d; - } - - public double dotProduct(double d, double d1, double d2) { - return d * x + d1 * y + d2 * z; - } - - public Vector3 crossProduct(Vector3 vec) { - double d = y * vec.z - z * vec.y; - double d1 = z * vec.x - x * vec.z; - double d2 = x * vec.y - y * vec.x; - x = d; - y = d1; - z = d2; - return this; - } - - public Vector3 add(double d, double d1, double d2) { - x += d; - y += d1; - z += d2; - return this; - } - - public Vector3 add(Vector3 vec) { - x += vec.x; - y += vec.y; - z += vec.z; - return this; - } - - public Vector3 add(double d) { - return add(d, d, d); - } - - public Vector3 sub(Vector3 vec) { - return subtract(vec); - } - - public Vector3 subtract(Vector3 vec) { - x -= vec.x; - y -= vec.y; - z -= vec.z; - return this; - } - - public Vector3 negate(Vector3 vec) { - x = -x; - y = -y; - z = -z; - return this; - } - - public Vector3 multiply(double d) { - x *= d; - y *= d; - z *= d; - return this; - } - - public Vector3 multiply(Vector3 f) { - x *= f.x; - y *= f.y; - z *= f.z; - return this; - } - - public Vector3 multiply(double fx, double fy, double fz) { - x *= fx; - y *= fy; - z *= fz; - return this; - } - - public double mag() { - return Math.sqrt(x * x + y * y + z * z); - } - - public double magSquared() { - return x * x + y * y + z * z; - } - - public Vector3 normalize() { - double d = mag(); - if(d != 0) - multiply(1 / d); - - return this; - } - - @Override - public String toString() { - MathContext cont = new MathContext(4, RoundingMode.HALF_UP); - return "Vector3(" + new BigDecimal(x, cont) + ", " +new BigDecimal(y, cont) + ", " + new BigDecimal(z, cont) + ")"; - } - - public Vector3 perpendicular() { - if(z == 0) - return zCrossProduct(); - return xCrossProduct(); - } - - public Vector3 xCrossProduct() { - double d = z; - double d1 = -y; - x = 0; - y = d; - z = d1; - return this; - } - - public Vector3 zCrossProduct() { - double d = y; - - double d1 = -x; - x = d; - y = d1; - z = 0; - return this; - } - - public Vector3 yCrossProduct() { - double d = -z; - double d1 = x; - x = d; - y = 0; - z = d1; - return this; - } - - public Vec3 toVec3D() { - return Vec3.createVectorHelper(x, y, z); - } - - public double angle(Vector3 vec) { - return Math.acos(copy().normalize().dotProduct(vec.copy().normalize())); - } - - public boolean isInside(AxisAlignedBB aabb) { - return x >= aabb.minX && y >= aabb.maxY && z >= aabb.minZ && x < aabb.maxX && y < aabb.maxY && z < aabb.maxZ; - } - - public boolean isZero() { - return x == 0 && y == 0 && z == 0; - } - - public boolean isAxial() { - return x == 0 ? y == 0 || z == 0 : y == 0 && z == 0; - } - - @SideOnly(Side.CLIENT) - public Vector3f vector3f() { - return new Vector3f((float)x, (float)y, (float)z); - } - - @SideOnly(Side.CLIENT) - public Vector4f vector4f() { - return new Vector4f((float)x, (float)y, (float)z, 1); - } - - @SideOnly(Side.CLIENT) - public void glVertex() { - GL11.glVertex3d(x, y, z); - } - - public Vector3 negate() { - x = -x; - y = -y; - z = -z; - return this; - } - - public double scalarProject(Vector3 b) { - double l = b.mag(); - return l == 0 ? 0 : dotProduct(b)/l; - } - - public Vector3 project(Vector3 b) { - double l = b.magSquared(); - if(l == 0) { - set(0, 0, 0); - return this; - } - - double m = dotProduct(b)/l; - set(b).multiply(m); - return this; - } - - public Vector3 rotate(double angle, Vector3 axis) { - Quat.aroundAxis(axis.copy().normalize(), angle).rotate(this); - return this; - } - - @Override - public boolean equals(Object o) { - if(!(o instanceof Vector3)) - return false; - - Vector3 v = (Vector3)o; - return x == v.x && y == v.y && z == v.z; - } -} \ No newline at end of file +public class Vector3 { + public static Vector3 zero = new Vector3(); + public static Vector3 one = new Vector3(1, 1, 1); + public static Vector3 center = new Vector3(0.5, 0.5, 0.5); + + public double x; + public double y; + public double z; + + public Vector3() {} + + public Vector3(double d, double d1, double d2) { + x = d; + y = d1; + z = d2; + } + + public Vector3(Vector3 vec) { + x = vec.x; + y = vec.y; + z = vec.z; + } + + public Vector3(Vec3 vec) { + x = vec.xCoord; + y = vec.yCoord; + z = vec.zCoord; + } + + public Vector3 copy() { + return new Vector3(this); + } + + public static Vector3 fromEntity(Entity e) { + return new Vector3(e.posX, e.posY, e.posZ); + } + + public static Vector3 fromEntityCenter(Entity e) { + return new Vector3(e.posX, e.posY - e.yOffset + e.height / 2, e.posZ); + } + + public static Vector3 fromTileEntity(TileEntity e) { + return new Vector3(e.xCoord, e.yCoord, e.zCoord); + } + + public static Vector3 fromTileEntityCenter(TileEntity e) { + return new Vector3(e.xCoord + 0.5, e.yCoord + 0.5, e.zCoord + 0.5); + } + + public Vector3 set(double d, double d1, double d2) { + x = d; + y = d1; + z = d2; + return this; + } + + public Vector3 set(Vector3 vec) { + x = vec.x; + y = vec.y; + z = vec.z; + return this; + } + + public double dotProduct(Vector3 vec) { + double d = vec.x * x + vec.y * y + vec.z * z; + + if (d > 1 && d < 1.00001) d = 1; + else if (d < -1 && d > -1.00001) d = -1; + return d; + } + + public double dotProduct(double d, double d1, double d2) { + return d * x + d1 * y + d2 * z; + } + + public Vector3 crossProduct(Vector3 vec) { + double d = y * vec.z - z * vec.y; + double d1 = z * vec.x - x * vec.z; + double d2 = x * vec.y - y * vec.x; + x = d; + y = d1; + z = d2; + return this; + } + + public Vector3 add(double d, double d1, double d2) { + x += d; + y += d1; + z += d2; + return this; + } + + public Vector3 add(Vector3 vec) { + x += vec.x; + y += vec.y; + z += vec.z; + return this; + } + + public Vector3 add(double d) { + return add(d, d, d); + } + + public Vector3 sub(Vector3 vec) { + return subtract(vec); + } + + public Vector3 subtract(Vector3 vec) { + x -= vec.x; + y -= vec.y; + z -= vec.z; + return this; + } + + public Vector3 negate(Vector3 vec) { + x = -x; + y = -y; + z = -z; + return this; + } + + public Vector3 multiply(double d) { + x *= d; + y *= d; + z *= d; + return this; + } + + public Vector3 multiply(Vector3 f) { + x *= f.x; + y *= f.y; + z *= f.z; + return this; + } + + public Vector3 multiply(double fx, double fy, double fz) { + x *= fx; + y *= fy; + z *= fz; + return this; + } + + public double mag() { + return Math.sqrt(x * x + y * y + z * z); + } + + public double magSquared() { + return x * x + y * y + z * z; + } + + public Vector3 normalize() { + double d = mag(); + if (d != 0) multiply(1 / d); + + return this; + } + + @Override + public String toString() { + MathContext cont = new MathContext(4, RoundingMode.HALF_UP); + return "Vector3(" + new BigDecimal(x, cont) + ", " + new BigDecimal(y, cont) + ", " + new BigDecimal(z, cont) + + ")"; + } + + public Vector3 perpendicular() { + if (z == 0) return zCrossProduct(); + return xCrossProduct(); + } + + public Vector3 xCrossProduct() { + double d = z; + double d1 = -y; + x = 0; + y = d; + z = d1; + return this; + } + + public Vector3 zCrossProduct() { + double d = y; + + double d1 = -x; + x = d; + y = d1; + z = 0; + return this; + } + + public Vector3 yCrossProduct() { + double d = -z; + double d1 = x; + x = d; + y = 0; + z = d1; + return this; + } + + public Vec3 toVec3D() { + return Vec3.createVectorHelper(x, y, z); + } + + public double angle(Vector3 vec) { + return Math.acos(copy().normalize().dotProduct(vec.copy().normalize())); + } + + public boolean isInside(AxisAlignedBB aabb) { + return x >= aabb.minX && y >= aabb.maxY && z >= aabb.minZ && x < aabb.maxX && y < aabb.maxY && z < aabb.maxZ; + } + + public boolean isZero() { + return x == 0 && y == 0 && z == 0; + } + + public boolean isAxial() { + return x == 0 ? y == 0 || z == 0 : y == 0 && z == 0; + } + + @SideOnly(Side.CLIENT) + public Vector3f vector3f() { + return new Vector3f((float) x, (float) y, (float) z); + } + + @SideOnly(Side.CLIENT) + public Vector4f vector4f() { + return new Vector4f((float) x, (float) y, (float) z, 1); + } + + @SideOnly(Side.CLIENT) + public void glVertex() { + GL11.glVertex3d(x, y, z); + } + + public Vector3 negate() { + x = -x; + y = -y; + z = -z; + return this; + } + + public double scalarProject(Vector3 b) { + double l = b.mag(); + return l == 0 ? 0 : dotProduct(b) / l; + } + + public Vector3 project(Vector3 b) { + double l = b.magSquared(); + if (l == 0) { + set(0, 0, 0); + return this; + } + + double m = dotProduct(b) / l; + set(b).multiply(m); + return this; + } + + public Vector3 rotate(double angle, Vector3 axis) { + Quat.aroundAxis(axis.copy().normalize(), angle).rotate(this); + return this; + } + + @Override + public boolean equals(Object o) { + if (!(o instanceof Vector3)) return false; + + Vector3 v = (Vector3) o; + return x == v.x && y == v.y && z == v.z; + } +} diff --git a/src/main/java/vazkii/botania/common/core/proxy/CommonProxy.java b/src/main/java/vazkii/botania/common/core/proxy/CommonProxy.java index e441a92b52..d11ceccf08 100644 --- a/src/main/java/vazkii/botania/common/core/proxy/CommonProxy.java +++ b/src/main/java/vazkii/botania/common/core/proxy/CommonProxy.java @@ -10,6 +10,15 @@ */ package vazkii.botania.common.core.proxy; +import cpw.mods.fml.common.FMLCommonHandler; +import cpw.mods.fml.common.FMLLog; +import cpw.mods.fml.common.event.FMLInitializationEvent; +import cpw.mods.fml.common.event.FMLInterModComms; +import cpw.mods.fml.common.event.FMLPostInitializationEvent; +import cpw.mods.fml.common.event.FMLPreInitializationEvent; +import cpw.mods.fml.common.event.FMLServerAboutToStartEvent; +import cpw.mods.fml.common.event.FMLServerStartingEvent; +import cpw.mods.fml.common.network.NetworkRegistry; import net.minecraft.block.Block; import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.boss.EntityDragon; @@ -26,9 +35,7 @@ import net.minecraft.util.StatCollector; import net.minecraft.world.World; import net.minecraftforge.common.MinecraftForge; - import org.apache.logging.log4j.Level; - import vazkii.botania.api.BotaniaAPI; import vazkii.botania.api.lexicon.ITwoNamedPage; import vazkii.botania.api.lexicon.LexiconEntry; @@ -81,248 +88,280 @@ import vazkii.botania.common.network.GuiHandler; import vazkii.botania.common.world.SkyblockWorldEvents; import vazkii.botania.common.world.WorldTypeSkyblock; -import cpw.mods.fml.common.FMLCommonHandler; -import cpw.mods.fml.common.FMLLog; -import cpw.mods.fml.common.event.FMLInitializationEvent; -import cpw.mods.fml.common.event.FMLInterModComms; -import cpw.mods.fml.common.event.FMLPostInitializationEvent; -import cpw.mods.fml.common.event.FMLPreInitializationEvent; -import cpw.mods.fml.common.event.FMLServerAboutToStartEvent; -import cpw.mods.fml.common.event.FMLServerStartingEvent; -import cpw.mods.fml.common.network.NetworkRegistry; public class CommonProxy { - public void preInit(FMLPreInitializationEvent event) { - BotaniaAPI.internalHandler = new InternalMethodHandler(); - - ConfigHandler.loadConfig(event.getSuggestedConfigurationFile()); - - ModBlocks.init(); - ModItems.init(); - ModEntities.init(); - ModPotions.init(); - ModBrews.init(); - - ModCraftingRecipes.init(); - ModPetalRecipes.init(); - ModPureDaisyRecipes.init(); - ModRuneRecipes.init(); - ModManaAlchemyRecipes.init(); - ModManaConjurationRecipes.init(); - ModManaInfusionRecipes.init(); - ModElvenTradeRecipes.init(); - ModBrewRecipes.init(); - ModAchievements.init(); - ModMultiblocks.init(); - - if(Botania.etFuturumLoaded) - ModBanners.init(); - - ChestGenHandler.init(); - - if(Botania.gardenOfGlassLoaded) - new WorldTypeSkyblock(); - - LexiconData.preInit(); - } - - public void init(FMLInitializationEvent event) { - NetworkRegistry.INSTANCE.registerGuiHandler(Botania.instance, new GuiHandler()); - - MinecraftForge.TERRAIN_GEN_BUS.register(new BiomeDecorationHandler()); - MinecraftForge.EVENT_BUS.register(ManaNetworkHandler.instance); - MinecraftForge.EVENT_BUS.register(new PixieHandler()); - MinecraftForge.EVENT_BUS.register(new SheddingHandler()); - MinecraftForge.EVENT_BUS.register(new SpawnerChangingHandler()); - MinecraftForge.EVENT_BUS.register(new SubTileNarslimmus.SpawnIntercepter()); - MinecraftForge.EVENT_BUS.register(TileCorporeaIndex.getInputHandler()); - - if(Botania.gardenOfGlassLoaded) - MinecraftForge.EVENT_BUS.register(new SkyblockWorldEvents()); - - FMLCommonHandler.instance().bus().register(new CommonTickHandler()); - - FMLInterModComms.sendMessage("ProjectE", "interdictionblacklist", EntityManaBurst.class.getCanonicalName()); - - if(Botania.bcTriggersLoaded) - new StatementAPIPlugin(); - - LexiconData.init(); - } - - public void postInit(FMLPostInitializationEvent event) { - if(Botania.thaumcraftLoaded) { - ModBrews.initTC(); - ModBrewRecipes.initTC(); - } - - ModBlocks.addDispenserBehaviours(); - ModBlocks.registerMultiparts(); - ConfigHandler.loadPostInit(); - LexiconData.postInit(); - - registerNEIStuff(); - - int words = 0; - for(LexiconEntry entry : BotaniaAPI.getAllEntries()) - for(LexiconPage page : entry.pages) { - words += countWords(page.getUnlocalizedName()); - if(page instanceof ITwoNamedPage) - words += countWords(((ITwoNamedPage) page).getSecondUnlocalizedName()); - } - FMLLog.log(Level.INFO, "[Botania] The Lexica Botania has %d words.", words); - - registerDefaultEntityBlacklist(); - } - - private int countWords(String s) { - String s1 = StatCollector.translateToLocal(s); - return s1.split(" ").length; - } - - private void registerDefaultEntityBlacklist() { - // Vanilla - BotaniaAPI.blacklistEntityFromGravityRod(EntityDragon.class); - BotaniaAPI.blacklistEntityFromGravityRod(EntityDragonPart.class); - BotaniaAPI.blacklistEntityFromGravityRod(EntityWither.class); - BotaniaAPI.blacklistEntityFromGravityRod(EntityItemFrame.class); - BotaniaAPI.blacklistEntityFromGravityRod(EntityEnderCrystal.class); - BotaniaAPI.blacklistEntityFromGravityRod(EntityPainting.class); - - // Botania - BotaniaAPI.blacklistEntityFromGravityRod(EntityCorporeaSpark.class); - BotaniaAPI.blacklistEntityFromGravityRod(EntityDoppleganger.class); - BotaniaAPI.blacklistEntityFromGravityRod(EntityFlameRing.class); - BotaniaAPI.blacklistEntityFromGravityRod(EntityMagicLandmine.class); - BotaniaAPI.blacklistEntityFromGravityRod(EntityMagicMissile.class); - BotaniaAPI.blacklistEntityFromGravityRod(EntityManaBurst.class); - BotaniaAPI.blacklistEntityFromGravityRod(EntityPinkWither.class); - BotaniaAPI.blacklistEntityFromGravityRod(EntitySignalFlare.class); - BotaniaAPI.blacklistEntityFromGravityRod(EntitySpark.class); - BotaniaAPI.blacklistEntityFromGravityRod(EntityPlayerMover.class); - } - - // Overriding the internal method handler will break everything as it changes regularly. - // So just don't be a moron and don't override it. Thanks. - public void serverAboutToStart(FMLServerAboutToStartEvent event) { - String clname = BotaniaAPI.internalHandler.getClass().getName(); - String expect = "vazkii.botania.common.core.handler.InternalMethodHandler"; - if(!clname.equals(expect)) { - new IllegalAccessError("The Botania API internal method handler has been overriden. " - + "This will cause crashes and compatibility issues, and that's why it's marked as" - + " \"Do not Override\". Whoever had the brilliant idea of overriding it needs to go" - + " back to elementary school and learn to read. (Expected classname: " + expect + ", Actual classname: " + clname + ")").printStackTrace(); - FMLCommonHandler.instance().exitJava(1, true); - } - } - - public void serverStarting(FMLServerStartingEvent event) { - event.registerServerCommand(new CommandShare()); - event.registerServerCommand(new CommandOpen()); - if(Botania.gardenOfGlassLoaded) - event.registerServerCommand(new CommandSkyblockSpread()); - } - - public void registerNEIStuff() { - // NO-OP - } - - public void setEntryToOpen(LexiconEntry entry) { - // NO-OP - } - - public void setToTutorialIfFirstLaunch() { - // NO-OP - } - - public void setLexiconStack(ItemStack stack) { - // NO-OP - } - - public boolean isTheClientPlayer(EntityLivingBase entity) { - return false; - } - - public boolean isClientPlayerWearingMonocle() { - return false; - } - - public void setExtraReach(EntityLivingBase entity, float reach) { - if(entity instanceof EntityPlayerMP) - ((EntityPlayerMP) entity).theItemInWorldManager.setBlockReachDistance(Math.max(5, ((EntityPlayerMP) entity).theItemInWorldManager.getBlockReachDistance() + reach)); - } - - public boolean openWikiPage(World world, Block block, MovingObjectPosition pos) { - return false; - } - - public void playRecordClientSided(World world, int x, int y, int z, ItemRecord record) { - // NO-OP - } - - public void setMultiblock(World world, int x, int y, int z, double radius, Block block) { - // NO-OP - } - - public void removeSextantMultiblock() { - // NO-OP - } - - public long getWorldElapsedTicks() { - return MinecraftServer.getServer().worldServers[0].getTotalWorldTime(); - } - - public void setSparkleFXNoClip(boolean noclip) { - // NO-OP - } - - public void setSparkleFXCorrupt(boolean corrupt) { - // NO-OP - } - - public void sparkleFX(World world, double x, double y, double z, float r, float g, float b, float size, int m) { - sparkleFX(world, x, y, z, r, g, b, size, m, false); - } - - public void sparkleFX(World world, double x, double y, double z, float r, float g, float b, float size, int m, boolean fake) { - // NO-OP - } - - public void setWispFXDistanceLimit(boolean limit) { - // NO-OP - } - - public void setWispFXDepthTest(boolean depth) { - // NO-OP - } - - public void wispFX(World world, double x, double y, double z, float r, float g, float b, float size) { - wispFX(world, x, y, z, r, g, b, size, 0F); - } - - public void wispFX(World world, double x, double y, double z, float r, float g, float b, float size, float gravity) { - wispFX(world, x, y, z, r, g, b, size, gravity, 1F); - } - - public void wispFX(World world, double x, double y, double z, float r, float g, float b, float size, float gravity, float maxAgeMul) { - wispFX(world, x, y, z, r, g, b, size, 0, -gravity, 0, maxAgeMul); - } - - public void wispFX(World world, double x, double y, double z, float r, float g, float b, float size, float motionx, float motiony, float motionz) { - wispFX(world, x, y, z, r, g, b, size, motionx, motiony, motionz, 1F); - } - - public void wispFX(World world, double x, double y, double z, float r, float g, float b, float size, float motionx, float motiony, float motionz, float maxAgeMul) { - // NO-OP - } - - public void lightningFX(World world, Vector3 vectorStart, Vector3 vectorEnd, float ticksPerMeter, int colorOuter, int colorInner) { - lightningFX(world, vectorStart, vectorEnd, ticksPerMeter, System.nanoTime(), colorOuter, colorInner); - } - - public void lightningFX(World world, Vector3 vectorStart, Vector3 vectorEnd, float ticksPerMeter, long seed, int colorOuter, int colorInner) { - // NO-OP - } - + public void preInit(FMLPreInitializationEvent event) { + BotaniaAPI.internalHandler = new InternalMethodHandler(); + + ConfigHandler.loadConfig(event.getSuggestedConfigurationFile()); + + ModBlocks.init(); + ModItems.init(); + ModEntities.init(); + ModPotions.init(); + ModBrews.init(); + + ModCraftingRecipes.init(); + ModPetalRecipes.init(); + ModPureDaisyRecipes.init(); + ModRuneRecipes.init(); + ModManaAlchemyRecipes.init(); + ModManaConjurationRecipes.init(); + ModManaInfusionRecipes.init(); + ModElvenTradeRecipes.init(); + ModBrewRecipes.init(); + ModAchievements.init(); + ModMultiblocks.init(); + + if (Botania.etFuturumLoaded) ModBanners.init(); + + ChestGenHandler.init(); + + if (Botania.gardenOfGlassLoaded) new WorldTypeSkyblock(); + + LexiconData.preInit(); + } + + public void init(FMLInitializationEvent event) { + NetworkRegistry.INSTANCE.registerGuiHandler(Botania.instance, new GuiHandler()); + + MinecraftForge.TERRAIN_GEN_BUS.register(new BiomeDecorationHandler()); + MinecraftForge.EVENT_BUS.register(ManaNetworkHandler.instance); + MinecraftForge.EVENT_BUS.register(new PixieHandler()); + MinecraftForge.EVENT_BUS.register(new SheddingHandler()); + MinecraftForge.EVENT_BUS.register(new SpawnerChangingHandler()); + MinecraftForge.EVENT_BUS.register(new SubTileNarslimmus.SpawnIntercepter()); + MinecraftForge.EVENT_BUS.register(TileCorporeaIndex.getInputHandler()); + + if (Botania.gardenOfGlassLoaded) MinecraftForge.EVENT_BUS.register(new SkyblockWorldEvents()); + + FMLCommonHandler.instance().bus().register(new CommonTickHandler()); + + FMLInterModComms.sendMessage("ProjectE", "interdictionblacklist", EntityManaBurst.class.getCanonicalName()); + + if (Botania.bcTriggersLoaded) new StatementAPIPlugin(); + + LexiconData.init(); + } + + public void postInit(FMLPostInitializationEvent event) { + if (Botania.thaumcraftLoaded) { + ModBrews.initTC(); + ModBrewRecipes.initTC(); + } + + ModBlocks.addDispenserBehaviours(); + ModBlocks.registerMultiparts(); + ConfigHandler.loadPostInit(); + LexiconData.postInit(); + + registerNEIStuff(); + + int words = 0; + for (LexiconEntry entry : BotaniaAPI.getAllEntries()) + for (LexiconPage page : entry.pages) { + words += countWords(page.getUnlocalizedName()); + if (page instanceof ITwoNamedPage) + words += countWords(((ITwoNamedPage) page).getSecondUnlocalizedName()); + } + FMLLog.log(Level.INFO, "[Botania] The Lexica Botania has %d words.", words); + + registerDefaultEntityBlacklist(); + } + + private int countWords(String s) { + String s1 = StatCollector.translateToLocal(s); + return s1.split(" ").length; + } + + private void registerDefaultEntityBlacklist() { + // Vanilla + BotaniaAPI.blacklistEntityFromGravityRod(EntityDragon.class); + BotaniaAPI.blacklistEntityFromGravityRod(EntityDragonPart.class); + BotaniaAPI.blacklistEntityFromGravityRod(EntityWither.class); + BotaniaAPI.blacklistEntityFromGravityRod(EntityItemFrame.class); + BotaniaAPI.blacklistEntityFromGravityRod(EntityEnderCrystal.class); + BotaniaAPI.blacklistEntityFromGravityRod(EntityPainting.class); + + // Botania + BotaniaAPI.blacklistEntityFromGravityRod(EntityCorporeaSpark.class); + BotaniaAPI.blacklistEntityFromGravityRod(EntityDoppleganger.class); + BotaniaAPI.blacklistEntityFromGravityRod(EntityFlameRing.class); + BotaniaAPI.blacklistEntityFromGravityRod(EntityMagicLandmine.class); + BotaniaAPI.blacklistEntityFromGravityRod(EntityMagicMissile.class); + BotaniaAPI.blacklistEntityFromGravityRod(EntityManaBurst.class); + BotaniaAPI.blacklistEntityFromGravityRod(EntityPinkWither.class); + BotaniaAPI.blacklistEntityFromGravityRod(EntitySignalFlare.class); + BotaniaAPI.blacklistEntityFromGravityRod(EntitySpark.class); + BotaniaAPI.blacklistEntityFromGravityRod(EntityPlayerMover.class); + } + + // Overriding the internal method handler will break everything as it changes regularly. + // So just don't be a moron and don't override it. Thanks. + public void serverAboutToStart(FMLServerAboutToStartEvent event) { + String clname = BotaniaAPI.internalHandler.getClass().getName(); + String expect = "vazkii.botania.common.core.handler.InternalMethodHandler"; + if (!clname.equals(expect)) { + new IllegalAccessError("The Botania API internal method handler has been overriden. " + + "This will cause crashes and compatibility issues, and that's why it's marked as" + + " \"Do not Override\". Whoever had the brilliant idea of overriding it needs to go" + + " back to elementary school and learn to read. (Expected classname: " + expect + + ", Actual classname: " + clname + ")") + .printStackTrace(); + FMLCommonHandler.instance().exitJava(1, true); + } + } + + public void serverStarting(FMLServerStartingEvent event) { + event.registerServerCommand(new CommandShare()); + event.registerServerCommand(new CommandOpen()); + if (Botania.gardenOfGlassLoaded) event.registerServerCommand(new CommandSkyblockSpread()); + } + + public void registerNEIStuff() { + // NO-OP + } + + public void setEntryToOpen(LexiconEntry entry) { + // NO-OP + } + + public void setToTutorialIfFirstLaunch() { + // NO-OP + } + + public void setLexiconStack(ItemStack stack) { + // NO-OP + } + + public boolean isTheClientPlayer(EntityLivingBase entity) { + return false; + } + + public boolean isClientPlayerWearingMonocle() { + return false; + } + + public void setExtraReach(EntityLivingBase entity, float reach) { + if (entity instanceof EntityPlayerMP) + ((EntityPlayerMP) entity) + .theItemInWorldManager.setBlockReachDistance(Math.max( + 5, ((EntityPlayerMP) entity).theItemInWorldManager.getBlockReachDistance() + reach)); + } + + public boolean openWikiPage(World world, Block block, MovingObjectPosition pos) { + return false; + } + + public void playRecordClientSided(World world, int x, int y, int z, ItemRecord record) { + // NO-OP + } + + public void setMultiblock(World world, int x, int y, int z, double radius, Block block) { + // NO-OP + } + + public void removeSextantMultiblock() { + // NO-OP + } + + public long getWorldElapsedTicks() { + return MinecraftServer.getServer().worldServers[0].getTotalWorldTime(); + } + + public void setSparkleFXNoClip(boolean noclip) { + // NO-OP + } + + public void setSparkleFXCorrupt(boolean corrupt) { + // NO-OP + } + + public void sparkleFX(World world, double x, double y, double z, float r, float g, float b, float size, int m) { + sparkleFX(world, x, y, z, r, g, b, size, m, false); + } + + public void sparkleFX( + World world, double x, double y, double z, float r, float g, float b, float size, int m, boolean fake) { + // NO-OP + } + + public void setWispFXDistanceLimit(boolean limit) { + // NO-OP + } + + public void setWispFXDepthTest(boolean depth) { + // NO-OP + } + + public void wispFX(World world, double x, double y, double z, float r, float g, float b, float size) { + wispFX(world, x, y, z, r, g, b, size, 0F); + } + + public void wispFX( + World world, double x, double y, double z, float r, float g, float b, float size, float gravity) { + wispFX(world, x, y, z, r, g, b, size, gravity, 1F); + } + + public void wispFX( + World world, + double x, + double y, + double z, + float r, + float g, + float b, + float size, + float gravity, + float maxAgeMul) { + wispFX(world, x, y, z, r, g, b, size, 0, -gravity, 0, maxAgeMul); + } + + public void wispFX( + World world, + double x, + double y, + double z, + float r, + float g, + float b, + float size, + float motionx, + float motiony, + float motionz) { + wispFX(world, x, y, z, r, g, b, size, motionx, motiony, motionz, 1F); + } + + public void wispFX( + World world, + double x, + double y, + double z, + float r, + float g, + float b, + float size, + float motionx, + float motiony, + float motionz, + float maxAgeMul) { + // NO-OP + } + + public void lightningFX( + World world, Vector3 vectorStart, Vector3 vectorEnd, float ticksPerMeter, int colorOuter, int colorInner) { + lightningFX(world, vectorStart, vectorEnd, ticksPerMeter, System.nanoTime(), colorOuter, colorInner); + } + + public void lightningFX( + World world, + Vector3 vectorStart, + Vector3 vectorEnd, + float ticksPerMeter, + long seed, + int colorOuter, + int colorInner) { + // NO-OP + } } diff --git a/src/main/java/vazkii/botania/common/crafting/ModBrewRecipes.java b/src/main/java/vazkii/botania/common/crafting/ModBrewRecipes.java index 866ffa3366..6fdf12e04c 100644 --- a/src/main/java/vazkii/botania/common/crafting/ModBrewRecipes.java +++ b/src/main/java/vazkii/botania/common/crafting/ModBrewRecipes.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Nov 1, 2014, 9:15:15 PM (GMT)] */ package vazkii.botania.common.crafting; @@ -22,62 +22,158 @@ public class ModBrewRecipes { - public static RecipeBrew speedBrew; - public static RecipeBrew strengthBrew; - public static RecipeBrew hasteBrew; - public static RecipeBrew healingBrew; - public static RecipeBrew jumpBoostBrew; - public static RecipeBrew regenerationBrew; - public static RecipeBrew weakRegenerationBrew; - public static RecipeBrew resistanceBrew; - public static RecipeBrew fireResistanceBrew; - public static RecipeBrew waterBreathingBrew; - public static RecipeBrew invisibilityBrew; - public static RecipeBrew nightVisionBrew; - public static RecipeBrew absorptionBrew; + public static RecipeBrew speedBrew; + public static RecipeBrew strengthBrew; + public static RecipeBrew hasteBrew; + public static RecipeBrew healingBrew; + public static RecipeBrew jumpBoostBrew; + public static RecipeBrew regenerationBrew; + public static RecipeBrew weakRegenerationBrew; + public static RecipeBrew resistanceBrew; + public static RecipeBrew fireResistanceBrew; + public static RecipeBrew waterBreathingBrew; + public static RecipeBrew invisibilityBrew; + public static RecipeBrew nightVisionBrew; + public static RecipeBrew absorptionBrew; - public static RecipeBrew overloadBrew; - public static RecipeBrew soulCrossBrew; - public static RecipeBrew featherFeetBrew; - public static RecipeBrew emptinessBrew; - public static RecipeBrew bloodthirstBrew; - public static RecipeBrew allureBrew; - public static RecipeBrew clearBrew; + public static RecipeBrew overloadBrew; + public static RecipeBrew soulCrossBrew; + public static RecipeBrew featherFeetBrew; + public static RecipeBrew emptinessBrew; + public static RecipeBrew bloodthirstBrew; + public static RecipeBrew allureBrew; + public static RecipeBrew clearBrew; - public static RecipeBrew warpWardBrew; + public static RecipeBrew warpWardBrew; - public static void init() { - if (!ConfigHandler.enableDefaultRecipes) return; + public static void init() { + if (!ConfigHandler.enableDefaultRecipes) return; - speedBrew = BotaniaAPI.registerBrewRecipe(ModBrews.speed, new ItemStack(Items.nether_wart), new ItemStack(Items.sugar), new ItemStack(Items.redstone)); - strengthBrew = BotaniaAPI.registerBrewRecipe(ModBrews.strength, new ItemStack(Items.nether_wart), new ItemStack(Items.blaze_powder), new ItemStack(Items.glowstone_dust)); - hasteBrew = BotaniaAPI.registerBrewRecipe(ModBrews.haste, new ItemStack(Items.nether_wart), new ItemStack(Items.sugar), new ItemStack(Items.gold_nugget)); - healingBrew = BotaniaAPI.registerBrewRecipe(ModBrews.healing, new ItemStack(Items.nether_wart), new ItemStack(Items.speckled_melon), new ItemStack(Items.potato)); - jumpBoostBrew = BotaniaAPI.registerBrewRecipe(ModBrews.jumpBoost, new ItemStack(Items.nether_wart), new ItemStack(Items.feather), new ItemStack(Items.carrot)); - regenerationBrew = BotaniaAPI.registerBrewRecipe(ModBrews.regen, new ItemStack(Items.nether_wart), new ItemStack(Items.ghast_tear), new ItemStack(Items.glowstone_dust)); - weakRegenerationBrew = BotaniaAPI.registerBrewRecipe(ModBrews.regenWeak, new ItemStack(Items.nether_wart), new ItemStack(Items.ghast_tear), new ItemStack(Items.redstone)); - resistanceBrew = BotaniaAPI.registerBrewRecipe(ModBrews.resistance, new ItemStack(Items.nether_wart), new ItemStack(Items.iron_ingot), new ItemStack(Items.leather)); - fireResistanceBrew = BotaniaAPI.registerBrewRecipe(ModBrews.fireResistance, new ItemStack(Items.nether_wart), new ItemStack(Items.magma_cream), new ItemStack(Blocks.netherrack)); - waterBreathingBrew = BotaniaAPI.registerBrewRecipe(ModBrews.waterBreathing, new ItemStack(Items.nether_wart), new ItemStack(ModItems.manaResource, 1, 10), new ItemStack(Items.glowstone_dust)); - invisibilityBrew = BotaniaAPI.registerBrewRecipe(ModBrews.invisibility, new ItemStack(Items.nether_wart), new ItemStack(Items.snowball), new ItemStack(Items.glowstone_dust)); - nightVisionBrew = BotaniaAPI.registerBrewRecipe(ModBrews.nightVision, new ItemStack(Items.nether_wart), new ItemStack(Items.spider_eye), new ItemStack(Items.golden_carrot)); - absorptionBrew = BotaniaAPI.registerBrewRecipe(ModBrews.absorption, new ItemStack(Items.nether_wart), new ItemStack(Items.golden_apple), new ItemStack(Items.potato)); + speedBrew = BotaniaAPI.registerBrewRecipe( + ModBrews.speed, + new ItemStack(Items.nether_wart), + new ItemStack(Items.sugar), + new ItemStack(Items.redstone)); + strengthBrew = BotaniaAPI.registerBrewRecipe( + ModBrews.strength, + new ItemStack(Items.nether_wart), + new ItemStack(Items.blaze_powder), + new ItemStack(Items.glowstone_dust)); + hasteBrew = BotaniaAPI.registerBrewRecipe( + ModBrews.haste, + new ItemStack(Items.nether_wart), + new ItemStack(Items.sugar), + new ItemStack(Items.gold_nugget)); + healingBrew = BotaniaAPI.registerBrewRecipe( + ModBrews.healing, + new ItemStack(Items.nether_wart), + new ItemStack(Items.speckled_melon), + new ItemStack(Items.potato)); + jumpBoostBrew = BotaniaAPI.registerBrewRecipe( + ModBrews.jumpBoost, + new ItemStack(Items.nether_wart), + new ItemStack(Items.feather), + new ItemStack(Items.carrot)); + regenerationBrew = BotaniaAPI.registerBrewRecipe( + ModBrews.regen, + new ItemStack(Items.nether_wart), + new ItemStack(Items.ghast_tear), + new ItemStack(Items.glowstone_dust)); + weakRegenerationBrew = BotaniaAPI.registerBrewRecipe( + ModBrews.regenWeak, + new ItemStack(Items.nether_wart), + new ItemStack(Items.ghast_tear), + new ItemStack(Items.redstone)); + resistanceBrew = BotaniaAPI.registerBrewRecipe( + ModBrews.resistance, + new ItemStack(Items.nether_wart), + new ItemStack(Items.iron_ingot), + new ItemStack(Items.leather)); + fireResistanceBrew = BotaniaAPI.registerBrewRecipe( + ModBrews.fireResistance, + new ItemStack(Items.nether_wart), + new ItemStack(Items.magma_cream), + new ItemStack(Blocks.netherrack)); + waterBreathingBrew = BotaniaAPI.registerBrewRecipe( + ModBrews.waterBreathing, + new ItemStack(Items.nether_wart), + new ItemStack(ModItems.manaResource, 1, 10), + new ItemStack(Items.glowstone_dust)); + invisibilityBrew = BotaniaAPI.registerBrewRecipe( + ModBrews.invisibility, + new ItemStack(Items.nether_wart), + new ItemStack(Items.snowball), + new ItemStack(Items.glowstone_dust)); + nightVisionBrew = BotaniaAPI.registerBrewRecipe( + ModBrews.nightVision, + new ItemStack(Items.nether_wart), + new ItemStack(Items.spider_eye), + new ItemStack(Items.golden_carrot)); + absorptionBrew = BotaniaAPI.registerBrewRecipe( + ModBrews.absorption, + new ItemStack(Items.nether_wart), + new ItemStack(Items.golden_apple), + new ItemStack(Items.potato)); - overloadBrew = BotaniaAPI.registerBrewRecipe(ModBrews.overload, new ItemStack(Items.nether_wart), new ItemStack(Items.blaze_powder), new ItemStack(Items.sugar), new ItemStack(Items.glowstone_dust), new ItemStack(ModItems.manaResource), new ItemStack(Items.spider_eye)); - soulCrossBrew = BotaniaAPI.registerBrewRecipe(ModBrews.soulCross, new ItemStack(Items.nether_wart), new ItemStack(Blocks.soul_sand), new ItemStack(Items.paper), new ItemStack(Items.apple), new ItemStack(Items.bone)); - featherFeetBrew = BotaniaAPI.registerBrewRecipe(ModBrews.featherfeet, new ItemStack(Items.nether_wart), new ItemStack(Items.feather), new ItemStack(Items.leather), new ItemStack(Blocks.wool, 1, -1)); - emptinessBrew = BotaniaAPI.registerBrewRecipe(ModBrews.emptiness, new ItemStack(Items.nether_wart), new ItemStack(Items.gunpowder), new ItemStack(Items.rotten_flesh), new ItemStack(Items.bone), new ItemStack(Items.string), new ItemStack(Items.ender_pearl)); - bloodthirstBrew = BotaniaAPI.registerBrewRecipe(ModBrews.bloodthirst, new ItemStack(Items.nether_wart), new ItemStack(Items.fermented_spider_eye), new ItemStack(Items.dye, 1, 4), new ItemStack(Items.fire_charge), new ItemStack(Items.iron_ingot)); - allureBrew = BotaniaAPI.registerBrewRecipe(ModBrews.allure, new ItemStack(Items.nether_wart), new ItemStack(Items.fish), new ItemStack(Items.quartz), new ItemStack(Items.golden_carrot)); - clearBrew = BotaniaAPI.registerBrewRecipe(ModBrews.clear, new ItemStack(Items.nether_wart), new ItemStack(Items.quartz), new ItemStack(Items.emerald), new ItemStack(Items.melon)); - } - - public static void initTC() { - Item resource = (Item) Item.itemRegistry.getObject("Thaumcraft:ItemResource"); - Item bathSalts = (Item) Item.itemRegistry.getObject("Thaumcraft:ItemBathSalts"); - - warpWardBrew = BotaniaAPI.registerBrewRecipe(ModBrews.warpWard, new ItemStack(Items.nether_wart), new ItemStack(resource, 1, 14), new ItemStack(bathSalts), new ItemStack(resource, 1, 6)); - } + overloadBrew = BotaniaAPI.registerBrewRecipe( + ModBrews.overload, + new ItemStack(Items.nether_wart), + new ItemStack(Items.blaze_powder), + new ItemStack(Items.sugar), + new ItemStack(Items.glowstone_dust), + new ItemStack(ModItems.manaResource), + new ItemStack(Items.spider_eye)); + soulCrossBrew = BotaniaAPI.registerBrewRecipe( + ModBrews.soulCross, + new ItemStack(Items.nether_wart), + new ItemStack(Blocks.soul_sand), + new ItemStack(Items.paper), + new ItemStack(Items.apple), + new ItemStack(Items.bone)); + featherFeetBrew = BotaniaAPI.registerBrewRecipe( + ModBrews.featherfeet, + new ItemStack(Items.nether_wart), + new ItemStack(Items.feather), + new ItemStack(Items.leather), + new ItemStack(Blocks.wool, 1, -1)); + emptinessBrew = BotaniaAPI.registerBrewRecipe( + ModBrews.emptiness, + new ItemStack(Items.nether_wart), + new ItemStack(Items.gunpowder), + new ItemStack(Items.rotten_flesh), + new ItemStack(Items.bone), + new ItemStack(Items.string), + new ItemStack(Items.ender_pearl)); + bloodthirstBrew = BotaniaAPI.registerBrewRecipe( + ModBrews.bloodthirst, + new ItemStack(Items.nether_wart), + new ItemStack(Items.fermented_spider_eye), + new ItemStack(Items.dye, 1, 4), + new ItemStack(Items.fire_charge), + new ItemStack(Items.iron_ingot)); + allureBrew = BotaniaAPI.registerBrewRecipe( + ModBrews.allure, + new ItemStack(Items.nether_wart), + new ItemStack(Items.fish), + new ItemStack(Items.quartz), + new ItemStack(Items.golden_carrot)); + clearBrew = BotaniaAPI.registerBrewRecipe( + ModBrews.clear, + new ItemStack(Items.nether_wart), + new ItemStack(Items.quartz), + new ItemStack(Items.emerald), + new ItemStack(Items.melon)); + } + public static void initTC() { + Item resource = (Item) Item.itemRegistry.getObject("Thaumcraft:ItemResource"); + Item bathSalts = (Item) Item.itemRegistry.getObject("Thaumcraft:ItemBathSalts"); + warpWardBrew = BotaniaAPI.registerBrewRecipe( + ModBrews.warpWard, + new ItemStack(Items.nether_wart), + new ItemStack(resource, 1, 14), + new ItemStack(bathSalts), + new ItemStack(resource, 1, 6)); + } } diff --git a/src/main/java/vazkii/botania/common/crafting/ModCraftingRecipes.java b/src/main/java/vazkii/botania/common/crafting/ModCraftingRecipes.java index 1737229cee..33001ca516 100644 --- a/src/main/java/vazkii/botania/common/crafting/ModCraftingRecipes.java +++ b/src/main/java/vazkii/botania/common/crafting/ModCraftingRecipes.java @@ -2,18 +2,19 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jan 19, 2014, 3:54:48 PM (GMT)] */ package vazkii.botania.common.crafting; +import cpw.mods.fml.common.FMLLog; +import cpw.mods.fml.common.registry.GameRegistry; import java.util.ArrayList; import java.util.Arrays; import java.util.List; - import net.minecraft.block.Block; import net.minecraft.init.Blocks; import net.minecraft.init.Items; @@ -24,9 +25,7 @@ import net.minecraftforge.oredict.OreDictionary; import net.minecraftforge.oredict.ShapedOreRecipe; import net.minecraftforge.oredict.ShapelessOreRecipe; - import org.apache.logging.log4j.Level; - import vazkii.botania.api.BotaniaAPI; import vazkii.botania.common.Botania; import vazkii.botania.common.block.ModBlocks; @@ -37,2320 +36,3524 @@ import vazkii.botania.common.item.ItemTwigWand; import vazkii.botania.common.item.ModItems; import vazkii.botania.common.lib.LibOreDict; -import cpw.mods.fml.common.FMLLog; -import cpw.mods.fml.common.registry.GameRegistry; public final class ModCraftingRecipes { - public static IRecipe recipeLexicon; - public static List recipesPetals; - public static List recipesDyes; - public static List recipesPetalBlocks; - public static IRecipe recipePestleAndMortar; - public static List recipesTwigWand; - public static List recipesApothecary; - public static List recipesSpreader; - public static List recipesManaLens; - public static IRecipe recipePool; - public static IRecipe recipePoolDiluted; - public static IRecipe recipePoolFabulous; - public static List recipesRuneAltar; - public static IRecipe recipeLensVelocity; - public static IRecipe recipeLensPotency; - public static IRecipe recipeLensResistance; - public static IRecipe recipeLensEfficiency; - public static IRecipe recipeLensBounce; - public static IRecipe recipeLensGravity; - public static IRecipe recipeLensBore; - public static IRecipe recipeLensDamaging; - public static IRecipe recipeLensPhantom; - public static IRecipe recipeLensMagnet; - public static IRecipe recipeLensExplosive; - public static List recipesUnstableBlocks; - public static IRecipe recipePylon; - public static IRecipe recipeDistributor; - public static IRecipe recipeLivingrockDecor1; - public static IRecipe recipeLivingrockDecor2; - public static IRecipe recipeLivingrockDecor3; - public static IRecipe recipeLivingrockDecor4; - public static IRecipe recipeLivingwoodDecor1; - public static IRecipe recipeLivingwoodDecor2; - public static IRecipe recipeLivingwoodDecor3; - public static IRecipe recipeLivingwoodDecor4; - public static IRecipe recipeLivingwoodDecor5; - public static List recipesManaBeacons; - public static List recipesSignalFlares; - public static IRecipe recipeManaVoid; - public static List recipesManaTablet; - public static IRecipe recipeManaDetector; - public static IRecipe recipeManaBlaster; - public static IRecipe recipeTurntable; - public static IRecipe recipeFertilizerPowder; - public static IRecipe recipeFerilizerDye; - public static IRecipe recipeLivingwoodTwig; - public static IRecipe recipeDirtRod; - public static IRecipe recipeTerraformRod; - public static IRecipe recipeRedstoneSpreader; - public static IRecipe recipeManaMirror; - public static IRecipe recipeManasteelHelm; - public static IRecipe recipeManasteelChest; - public static IRecipe recipeManasteelLegs; - public static IRecipe recipeManasteelBoots; - public static IRecipe recipeManasteelPick; - public static IRecipe recipeManasteelShovel; - public static IRecipe recipeManasteelAxe; - public static IRecipe recipeManasteelShears; - public static IRecipe recipeManasteelSword; - public static IRecipe recipeGrassHorn; - public static IRecipe recipeTerrasteelHelm; - public static IRecipe recipeTerrasteelChest; - public static IRecipe recipeTerrasteelLegs; - public static IRecipe recipeTerrasteelBoots; - public static IRecipe recipeTerraSword; - public static IRecipe recipeTinyPlanet; - public static IRecipe recipeManaRing; - public static IRecipe recipeAuraRing; - public static IRecipe recipeGreaterManaRing; - public static IRecipe recipeGreaterAuraRing; - public static IRecipe recipeTravelBelt; - public static IRecipe recipeKnocbackBelt; - public static IRecipe recipeIcePendant; - public static IRecipe recipeFirePendant; - public static IRecipe recipeGoldenLaurel; - public static IRecipe recipeTinyPlanetBlock; - public static IRecipe recipeAlchemyCatalyst; - public static IRecipe recipeOpenCrate; - public static IRecipe recipeForestEye; - public static IRecipe recipeRedstoneRoot; - public static IRecipe recipeForestDrum; - public static IRecipe recipeWaterRing; - public static IRecipe recipeMiningRing; - public static IRecipe recipeMagnetRing; - public static IRecipe recipeTerraPick; - public static IRecipe recipeDivaCharm; - public static IRecipe recipeFlightTiara; - public static List recipesShinyFlowers; - public static IRecipe recipePlatform; - public static IRecipe recipeEnderDagger; - public static IRecipe recipeDarkQuartz; - public static IRecipe recipeBlazeQuartz; - public static List recipesLavenderQuartz; - public static IRecipe recipeRedQuartz; - public static IRecipe recipeSunnyQuartz; - public static IRecipe recipeAlfPortal; - public static IRecipe recipeNaturaPylon; - public static IRecipe recipeWaterRod; - public static IRecipe recipeElementiumHelm; - public static IRecipe recipeElementiumChest; - public static IRecipe recipeElementiumLegs; - public static IRecipe recipeElementiumBoots; - public static IRecipe recipeElementiumPick; - public static IRecipe recipeElementiumShovel; - public static IRecipe recipeElementiumAxe; - public static IRecipe recipeElementiumShears; - public static IRecipe recipeElementiumSword; - public static IRecipe recipeOpenBucket; - public static IRecipe recipeConjurationCatalyst; - public static IRecipe recipeSpawnerMover; - public static IRecipe recipePixieRing; - public static IRecipe recipeSuperTravelBelt; - public static IRecipe recipeRainbowRod; - public static IRecipe recipeSpectralPlatform; - public static List recipesDreamwoodSpreader; - public static IRecipe recipeTornadoRod; - public static IRecipe recipeFireRod; - public static IRecipe recipeVineBall; - public static IRecipe recipeSlingshot; - public static IRecipe recipeMossStone; - public static IRecipe recipePrismarine; - public static IRecipe recipePrismarineBrick; - public static IRecipe recipeDarkPrismarine; - public static IRecipe recipeSeaLamp; - public static IRecipe recipeLensInfluence; - public static IRecipe recipeLensWeight; - public static IRecipe recipeLensPaint; - public static IRecipe recipeLensWarp; - public static IRecipe recipeLensRedirect; - public static IRecipe recipeLensFirework; - public static IRecipe recipeLensFlare; - public static List recipesMiniIsland; - public static IRecipe recipeGaiaPylon; - public static IRecipe recipeGatherDrum; - public static IRecipe recipeLensFire; - public static IRecipe recipeLensPiston; - public static List recipesLaputaShard; - public static List recipesLaputaShardUpgrade; - public static IRecipe recipeVirusZombie; - public static IRecipe recipeVirusSkeleton; - public static IRecipe recipeReachRing; - public static IRecipe recipeSkyDirtRod; - public static IRecipe recipeSpawnerClaw; - public static IRecipe recipeCraftCrate; - public static IRecipe recipePlaceholder; - public static IRecipe recipeReedBlock; - public static IRecipe recipeThatch; - public static IRecipe recipeNetherBrick; - public static IRecipe recipeSoulBrick; - public static IRecipe recipeSnowBrick; - public static IRecipe recipeRoofTile; - public static IRecipe recipeAzulejo; - public static List recipesAzulejoCycling; - public static IRecipe recipeEnderEyeBlock; - public static IRecipe recipeItemFinder; - public static IRecipe recipeSuperLavaPendant; - public static IRecipe recipeEnderHand; - public static IRecipe recipeGlassPick; - public static IRecipe recipeStarfield; - public static List recipesSpark; - public static List recipesSparkUpgrades; - public static IRecipe recipeLeafHorn; - public static IRecipe recipeDiviningRod; - public static List recipesWings; - public static IRecipe recipeRFGenerator; - public static IRecipe recipeGravityRod; - public static IRecipe recipeRegenIvy; - public static IRecipe recipeUltraSpreader; - public static IRecipe recipeHelmetOfRevealing; - public static IRecipe recipeVial; - public static IRecipe recipeFlask; - public static IRecipe recipeBrewery; - public static IRecipe recipeBloodPendant; - public static IRecipe recipeTerraPlate; - public static IRecipe recipeRedString; - public static IRecipe recipeRedStringContainer; - public static IRecipe recipeRedStringDispenser; - public static IRecipe recipeRedStringFertilizer; - public static IRecipe recipeRedStringComparator; - public static IRecipe recipeRedStringRelay; - public static IRecipe recipeRedStringInterceptor; - public static IRecipe recipeMissileRod; - public static IRecipe recipeHolyCloak; - public static IRecipe recipeUnholyCloak; - public static IRecipe recipeCraftingHalo; - public static List recipesLensFlash; - public static IRecipe recipePrism; - public static IRecipe recipeDirtPath; - public static IRecipe recipeDreamwoodTwig; - public static IRecipe recipeMonocle; - public static IRecipe recipeClip; - public static IRecipe recipeCobbleRod; - public static IRecipe recipeSmeltRod; - public static IRecipe recipeWorldSeed; - public static IRecipe recipeSpellCloth; - public static IRecipe recipeThornChakram; - public static IRecipe recipeDirtPathSlab; - public static List recipesPatterns; - public static IRecipe recipeGaiaIngot; - public static IRecipe recipeCorporeaSpark; - public static IRecipe recipeMasterCorporeaSpark; - public static IRecipe recipeCorporeaIndex; - public static IRecipe recipeCorporeaFunnel; - public static IRecipe recipeCorporeaInterceptor; - public static IRecipe recipeEndStoneBricks; - public static IRecipe recipeEndStoneChiseledBricks; - public static IRecipe recipeEnderBricks; - public static IRecipe recipePillarEnderBricks; - public static IRecipe recipeLivingwoodBow; - public static IRecipe recipeCrystalBow; - public static List recipesCosmeticItems; - public static List recipesMushrooms; - public static IRecipe recipeSwapRing; - public static IRecipe recipeSnowHorn; - public static IRecipe recipeFlowerBag; - public static IRecipe recipePhantomInk; - public static IRecipe recipePoolCart; - public static IRecipe recipePump; - public static List recipesPetalsDouble; - public static IRecipe recipeKeepIvy; - public static IRecipe recipeBlackHoleTalisman; - public static List recipe18StonePolish; - public static List recipe18StoneBrick; - public static List recipe18StoneChisel; - public static IRecipe recipeBlazeBlock; - public static List recipesAltarMeta; - public static IRecipe recipeCorporeaCrystalCube; - public static IRecipe recipeTemperanceStone; - public static IRecipe recipeIncenseStick; - public static IRecipe recipeIncensePlate; - public static IRecipe recipeTerraAxe; - public static IRecipe recipeHourglass; - public static IRecipe recipeGhostRail; - public static IRecipe recipeCanopyDrum; - public static IRecipe recipeSparkChanger; - public static IRecipe recipeCocoon; - public static IRecipe recipeLuminizer; - public static IRecipe recipeDetectorLuminizer; - public static IRecipe recipeLuminizerLauncher; - public static IRecipe recipeObedienceStick; - public static IRecipe recipeCacophonium; - public static IRecipe recipeManaBomb; - public static IRecipe recipeCobweb; - public static IRecipe recipeSlimeBottle; - public static IRecipe recipeStarSword; - public static IRecipe recipeExchangeRod; - public static IRecipe recipeGreaterMagnetRing; - public static IRecipe recipeFireChakram; - public static IRecipe recipeThunderSword; - public static IRecipe recipeBellows; - public static IRecipe recipeManaweaveCloth; - public static IRecipe recipeManaweaveHelm; - public static IRecipe recipeManaweaveChest; - public static IRecipe recipeManaweaveLegs; - public static IRecipe recipeManaweaveBoots; - public static IRecipe recipeBifrost; - public static IRecipe recipeShimmerrock; - public static IRecipe recipeShimmerwoodPlanks; - public static IRecipe recipeAutocraftingHalo; - public static List recipesPavement; - public static IRecipe recipeCellBlock; - public static IRecipe recipeCorporeaRetainer; - public static IRecipe recipeTeruTeruBozu; - public static IRecipe recipeAvatar; - public static IRecipe recipeSextant; - public static List recipesAltGrassSeeds; - public static IRecipe recipeSpeedUpBelt; - public static IRecipe recipeBaubleCase; - - // Garden of Glass - public static IRecipe recipeRootToSapling; - public static IRecipe recipeRootToFertilizer; - public static IRecipe recipePebbleCobblestone; - public static IRecipe recipeMagmaToSlimeball; - public static IRecipe recipeFelPumpkin; - public static IRecipe recipeEndPortal; - - public static void init() { - if (!ConfigHandler.enableDefaultRecipes) return; - - int recipeListSize = CraftingManager.getInstance().getRecipeList().size(); - - // Lexicon Recipe - addShapelessOreDictRecipe(new ItemStack(ModItems.lexicon), "treeSapling", Items.book); - recipeLexicon = BotaniaAPI.getLatestAddedRecipe(); - - // Petal/Dye Recipes - for(int i = 0; i < 16; i++) - addShapelessOreDictRecipe(new ItemStack(ModItems.petal, 2, i), LibOreDict.FLOWER[i]); - recipesPetals = BotaniaAPI.getLatestAddedRecipes(16); - - for(int i = 0; i < 16; i++) - addShapelessOreDictRecipe(new ItemStack(ModItems.dye, 1, i), LibOreDict.PETAL[i], LibOreDict.PESTLE_AND_MORTAR); - recipesDyes = BotaniaAPI.getLatestAddedRecipes(16); - - // Petal Block Recipes - for(int i = 0; i < 16; i++) - addOreDictRecipe(new ItemStack(ModBlocks.petalBlock, 1, i), - "PPP", "PPP", "PPP", // PPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPP - 'P', LibOreDict.PETAL[i]); - recipesPetalBlocks = BotaniaAPI.getLatestAddedRecipes(16); - - // Pestle and Mortar Recipe - addOreDictRecipe(new ItemStack(ModItems.pestleAndMortar), - " S", "W ", "B ", - 'S', "stickWood", - 'W', "plankWood", - 'B', Items.bowl); - recipePestleAndMortar = BotaniaAPI.getLatestAddedRecipe(); - - // Wand of the Forest Recipes - for(int i = 0; i < 16; i++) - for(int j = 0; j < 16; j++) { - addOreDictRecipe(ItemTwigWand.forColors(i, j), - " AS", " SB", "S ", - 'A', LibOreDict.PETAL[i], - 'B', LibOreDict.PETAL[j], - 'S', LibOreDict.LIVINGWOOD_TWIG); - } - recipesTwigWand = BotaniaAPI.getLatestAddedRecipes(256); - - // Petal Apothecary Recipes - for(int i = 0; i < 16; i++) - addOreDictRecipe(new ItemStack(ModBlocks.altar), - "SPS", " C ", "CCC", - 'S', "slabCobblestone", - 'P', LibOreDict.PETAL[i], - 'C', "cobblestone"); - recipesApothecary = BotaniaAPI.getLatestAddedRecipes(16); - - // Mana Spreader Recipes - for(int i = 0; i < 16; i++) - addOreDictRecipe(new ItemStack(ModBlocks.spreader), - "WWW", "GP ", "WWW", - 'W', LibOreDict.LIVING_WOOD, - 'P', LibOreDict.PETAL[i], - 'G', Botania.gardenOfGlassLoaded ? LibOreDict.LIVING_WOOD : "ingotGold"); - recipesSpreader = BotaniaAPI.getLatestAddedRecipes(16); - - // Mana Lens Recipe - addOreDictRecipe(new ItemStack(ModItems.lens), - " S ", "SGS", " S ", - 'S', LibOreDict.MANA_STEEL, - 'G', "paneGlassColorless"); - addOreDictRecipe(new ItemStack(ModItems.lens), - " S ", "SGS", " S ", - 'S', LibOreDict.MANA_STEEL, - 'G', "blockGlassColorless"); - recipesManaLens = BotaniaAPI.getLatestAddedRecipes(2); - - // Mana Pool Recipe - addOreDictRecipe(new ItemStack(ModBlocks.pool), - "R R", "RRR", - 'R', LibOreDict.LIVING_ROCK); - recipePool = BotaniaAPI.getLatestAddedRecipe(); - - // Diluted Mana Pool Recipe - addOreDictRecipe(new ItemStack(ModBlocks.pool, 1, 2), - "R R", "RRR", - 'R', new ItemStack(ModFluffBlocks.livingrockSlab)); - recipePoolDiluted = BotaniaAPI.getLatestAddedRecipe(); - - // Fabulous Mana Pool Recipe - addOreDictRecipe(new ItemStack(ModBlocks.pool, 1, 3), - "R R", "RRR", - 'R', new ItemStack(ModBlocks.shimmerrock)); - recipePoolFabulous = BotaniaAPI.getLatestAddedRecipe(); - - // Runic Altar Recipe - addOreDictRecipe(new ItemStack(ModBlocks.runeAltar), - "SSS", "SPS", - 'S', LibOreDict.LIVING_ROCK, - 'P', LibOreDict.MANA_PEARL); - addOreDictRecipe(new ItemStack(ModBlocks.runeAltar), - "SSS", "SDS", - 'S', LibOreDict.LIVING_ROCK, - 'D', LibOreDict.MANA_DIAMOND); - recipesRuneAltar = BotaniaAPI.getLatestAddedRecipes(2); - - // Lens Recipes - addShapelessOreDictRecipe(new ItemStack(ModItems.lens, 1, 1), new ItemStack(ModItems.lens), LibOreDict.RUNE[3]); - recipeLensVelocity = BotaniaAPI.getLatestAddedRecipe(); - - addShapelessOreDictRecipe(new ItemStack(ModItems.lens, 1, 2), new ItemStack(ModItems.lens), LibOreDict.RUNE[1]); - recipeLensPotency = BotaniaAPI.getLatestAddedRecipe(); - - addShapelessOreDictRecipe(new ItemStack(ModItems.lens, 1, 3), new ItemStack(ModItems.lens), LibOreDict.RUNE[2]); - recipeLensResistance = BotaniaAPI.getLatestAddedRecipe(); - - addShapelessOreDictRecipe(new ItemStack(ModItems.lens, 1, 4), new ItemStack(ModItems.lens), LibOreDict.RUNE[0]); - recipeLensEfficiency = BotaniaAPI.getLatestAddedRecipe(); - - addShapelessOreDictRecipe(new ItemStack(ModItems.lens, 1, 5), new ItemStack(ModItems.lens), LibOreDict.RUNE[5]); - recipeLensBounce = BotaniaAPI.getLatestAddedRecipe(); - - addShapelessOreDictRecipe(new ItemStack(ModItems.lens, 1, 6), new ItemStack(ModItems.lens), LibOreDict.RUNE[7]); - recipeLensGravity = BotaniaAPI.getLatestAddedRecipe(); - - addOreDictRecipe(new ItemStack(ModItems.lens, 1, 7), - " P ", "ALA", " R ", - 'P', new ItemStack(Blocks.piston), - 'R', "dustRedstone", - 'A', "gemLapis", - 'L', new ItemStack(ModItems.lens)); - recipeLensBore = BotaniaAPI.getLatestAddedRecipe(); - - addShapelessOreDictRecipe(new ItemStack(ModItems.lens, 1, 8), new ItemStack(ModItems.lens), LibOreDict.RUNE[13]); - recipeLensDamaging = BotaniaAPI.getLatestAddedRecipe(); - - addShapelessOreDictRecipe(new ItemStack(ModItems.lens, 1, 9), new ItemStack(ModItems.lens), new ItemStack(ModBlocks.platform)); - recipeLensPhantom = BotaniaAPI.getLatestAddedRecipe(); - - addShapelessOreDictRecipe(new ItemStack(ModItems.lens, 1, 10), new ItemStack(ModItems.lens), "ingotIron", "ingotGold"); - recipeLensMagnet = BotaniaAPI.getLatestAddedRecipe(); - - addShapelessOreDictRecipe(new ItemStack(ModItems.lens, 1, 11), new ItemStack(ModItems.lens), LibOreDict.RUNE[14]); - recipeLensExplosive = BotaniaAPI.getLatestAddedRecipe(); - - // Unstable Block Recipes - for(int i = 0; i < 16; i++) - addOreDictRecipe(new ItemStack(ModBlocks.unstableBlock, 2, i), - "OPO", "PMP", "OPO", - 'O', new ItemStack(Blocks.obsidian), - 'P', LibOreDict.PETAL[i], - 'M', new ItemStack(Items.ender_pearl)); - recipesUnstableBlocks = BotaniaAPI.getLatestAddedRecipes(16); - - // Mana Pylon Recipe - addOreDictRecipe(new ItemStack(ModBlocks.pylon), - " G ", "MDM", " G ", - 'G', "ingotGold", - 'M', LibOreDict.MANA_STEEL, - 'D', LibOreDict.MANA_DIAMOND); - recipePylon = BotaniaAPI.getLatestAddedRecipe(); - - // Mana Distributor - addOreDictRecipe(new ItemStack(ModBlocks.distributor), - "RRR", "S S", "RRR", - 'R', LibOreDict.LIVING_ROCK, - 'S', LibOreDict.MANA_STEEL); - recipeDistributor = BotaniaAPI.getLatestAddedRecipe(); - - // Livingrock Decorative Blocks - addOreDictRecipe(new ItemStack(ModBlocks.livingrock, 4, 1), - "RR", "RR", - 'R', LibOreDict.LIVING_ROCK); - recipeLivingrockDecor1 = BotaniaAPI.getLatestAddedRecipe(); - addShapelessOreDictRecipe(new ItemStack(ModBlocks.livingrock, 1, 2), new ItemStack(ModBlocks.livingrock, 1, 1), new ItemStack(Items.wheat_seeds)); - recipeLivingrockDecor2 = BotaniaAPI.getLatestAddedRecipe(); - addShapelessOreDictRecipe(new ItemStack(ModBlocks.livingrock, 2, 3), new ItemStack(ModBlocks.livingrock, 1, 1), "cobblestone"); - recipeLivingrockDecor3 = BotaniaAPI.getLatestAddedRecipe(); - addOreDictRecipe(new ItemStack(ModBlocks.livingrock, 4, 4), - "RR", "RR", - 'R', new ItemStack(ModBlocks.livingrock, 1, 1)); - recipeLivingrockDecor4 = BotaniaAPI.getLatestAddedRecipe(); - - // Livingwood Decorative Blocks - addShapelessOreDictRecipe(new ItemStack(ModBlocks.livingwood, 4, 1), LibOreDict.LIVING_WOOD); - recipeLivingwoodDecor1 = BotaniaAPI.getLatestAddedRecipe(); - addShapelessOreDictRecipe(new ItemStack(ModBlocks.livingwood, 1, 2), new ItemStack(ModBlocks.livingwood, 1, 1), new ItemStack(Items.wheat_seeds)); - recipeLivingwoodDecor2 = BotaniaAPI.getLatestAddedRecipe(); - addOreDictRecipe(new ItemStack(ModBlocks.livingwood, 4, 3), - "WW", "WW", - 'W', new ItemStack(ModBlocks.livingwood, 1, 1)); - recipeLivingwoodDecor3 = BotaniaAPI.getLatestAddedRecipe(); - addOreDictRecipe(new ItemStack(ModBlocks.livingwood, 4, 4), - " W ", "W W", " W ", - 'W', new ItemStack(ModBlocks.livingwood, 1, 1)); - recipeLivingwoodDecor4 = BotaniaAPI.getLatestAddedRecipe(); - addShapelessOreDictRecipe(new ItemStack(ModBlocks.livingwood, 1, 5), LibOreDict.LIVING_WOOD, "dustGlowstone"); - recipeLivingwoodDecor5 = BotaniaAPI.getLatestAddedRecipe(); - - // Dreamwood Decorative Blocks - addShapelessOreDictRecipe(new ItemStack(ModBlocks.dreamwood, 4, 1), LibOreDict.DREAM_WOOD); - addShapelessOreDictRecipe(new ItemStack(ModBlocks.dreamwood, 1, 2), new ItemStack(ModBlocks.dreamwood, 1, 1), new ItemStack(Items.wheat_seeds)); - addOreDictRecipe(new ItemStack(ModBlocks.dreamwood, 4, 3), - "WW", "WW", - 'W', new ItemStack(ModBlocks.dreamwood, 1, 1)); - addOreDictRecipe(new ItemStack(ModBlocks.dreamwood, 4, 4), - " W ", "W W", " W ", - 'W', new ItemStack(ModBlocks.dreamwood, 1, 1)); - addShapelessOreDictRecipe(new ItemStack(ModBlocks.dreamwood, 1, 5), LibOreDict.DREAM_WOOD, "dustGlowstone"); - - // Mana Beacon Recipe - for(int i = 0; i < 16; i++) - addOreDictRecipe(new ItemStack(ModBlocks.manaBeacon, 1, i), - " B ", "BPB", " B ", - 'B', new ItemStack(ModBlocks.unstableBlock, 1, i), - 'P', LibOreDict.MANA_PEARL); - recipesManaBeacons = BotaniaAPI.getLatestAddedRecipes(16); - - // Signal Flare Recipe - for(int i = 0; i < 16; i++) - addOreDictRecipe(ItemSignalFlare.forColor(i), - "I ", " B", "W ", - 'B', new ItemStack(ModBlocks.manaBeacon, 1, i), - 'I', "ingotIron", - 'W', LibOreDict.LIVING_WOOD); - recipesSignalFlares = BotaniaAPI.getLatestAddedRecipes(16); - - // Mana Void Recipe - addOreDictRecipe(new ItemStack(ModBlocks.manaVoid), - "SSS", "O O", "SSS", - 'S', LibOreDict.LIVING_ROCK, - 'O', new ItemStack(Blocks.obsidian)); - recipeManaVoid = BotaniaAPI.getLatestAddedRecipe(); - - // Mana Tablet Recipe - addOreDictRecipe(new ItemStack(ModItems.manaTablet, 1, 10000), - "SSS", "SPS", "SSS", - 'S', LibOreDict.LIVING_ROCK, - 'P', LibOreDict.MANA_PEARL); - addOreDictRecipe(new ItemStack(ModItems.manaTablet, 1, 10000), - "SSS", "SDS", "SSS", - 'S', LibOreDict.LIVING_ROCK, - 'D', LibOreDict.MANA_DIAMOND); - recipesManaTablet = BotaniaAPI.getLatestAddedRecipes(2); - - // Mana Detector Recipe - addOreDictRecipe(new ItemStack(ModBlocks.manaDetector), - "RSR", "SCS", "RSR", - 'R', "dustRedstone", - 'C', new ItemStack(Items.comparator), - 'S', LibOreDict.LIVING_ROCK); - recipeManaDetector = BotaniaAPI.getLatestAddedRecipe(); - - // Mana Blaster Recipe - addOreDictRecipe(new ItemStack(ModItems.manaGun), - "SMD", " WT", " W", - 'S', new ItemStack(ModBlocks.spreader, 1, 1), - 'M', LibOreDict.RUNE[8], - 'D', LibOreDict.MANA_DIAMOND, - 'T', new ItemStack(Blocks.tnt), - 'W', LibOreDict.LIVING_WOOD); - recipeManaBlaster = BotaniaAPI.getLatestAddedRecipe(); - - // Spreader Turntable Recipe - addOreDictRecipe(new ItemStack(ModBlocks.turntable), - "WWW", "WPW", "WWW", - 'W', LibOreDict.LIVING_WOOD, - 'P', Blocks.sticky_piston); - recipeTurntable = BotaniaAPI.getLatestAddedRecipe(); - - // Fertilizer Recipes - GameRegistry.addShapelessRecipe(new ItemStack(ModItems.fertilizer, Botania.gardenOfGlassLoaded ? 3 : 1), new ItemStack(Items.dye, 1, 15), new ItemStack(ModItems.dye, 1, Short.MAX_VALUE), new ItemStack(ModItems.dye, 1, Short.MAX_VALUE), new ItemStack(ModItems.dye, 1, Short.MAX_VALUE), new ItemStack(ModItems.dye, 1, Short.MAX_VALUE)); - recipeFertilizerPowder = BotaniaAPI.getLatestAddedRecipe(); - GameRegistry.addShapelessRecipe(new ItemStack(ModItems.fertilizer), new ItemStack(Items.dye, 1, 15), new ItemStack(Items.dye, 1, 11), new ItemStack(Items.dye, 1, 11), new ItemStack(Items.dye, 1, 1), new ItemStack(Items.dye, 1, 1)); - recipeFerilizerDye = BotaniaAPI.getLatestAddedRecipe(); - - // Livingwood Twig Recipe - addOreDictRecipe(new ItemStack(ModItems.manaResource, 1, 3), - "W", "W", - 'W', LibOreDict.LIVING_WOOD); - recipeLivingwoodTwig = BotaniaAPI.getLatestAddedRecipe(); - - // Rod of the Lands Recipe - addOreDictRecipe(new ItemStack(ModItems.dirtRod), - " D", " T ", "E ", - 'D', new ItemStack(Blocks.dirt), - 'T', LibOreDict.LIVINGWOOD_TWIG, - 'E', LibOreDict.RUNE[2]); - recipeDirtRod = BotaniaAPI.getLatestAddedRecipe(); - - // Terra Firma Rod Recipe - addOreDictRecipe(new ItemStack(ModItems.terraformRod), - " WT", "ARS", "GM ", - 'T', LibOreDict.TERRA_STEEL, - 'R', new ItemStack(ModItems.dirtRod), - 'G', new ItemStack(ModItems.grassSeeds), - 'W', LibOreDict.RUNE[7], - 'S', LibOreDict.RUNE[4], - 'M', LibOreDict.RUNE[5], - 'A', LibOreDict.RUNE[6]); - recipeTerraformRod = BotaniaAPI.getLatestAddedRecipe(); - - // Redstone Mana Spreader Recipe - GameRegistry.addRecipe(new ShapelessOreRecipe(new ItemStack(ModBlocks.spreader, 1, 1), - new ItemStack(ModBlocks.spreader), "dustRedstone")); - recipeRedstoneSpreader = BotaniaAPI.getLatestAddedRecipe(); - - // Mana Miror Recipe - addOreDictRecipe(new ItemStack(ModItems.manaMirror), - " PR", " SI", "T ", - 'P', LibOreDict.MANA_PEARL, - 'R', LibOreDict.LIVING_ROCK, - 'S', LibOreDict.LIVINGWOOD_TWIG, - 'I', LibOreDict.TERRA_STEEL, - 'T', new ItemStack(ModItems.manaTablet, 1, Short.MAX_VALUE)); - recipeManaMirror = BotaniaAPI.getLatestAddedRecipe(); - - // Mana Armor & Tools Recipes - addOreDictRecipe(new ItemStack(ModItems.manasteelHelm), - "SSS", "S S", - 'S', LibOreDict.MANA_STEEL); - recipeManasteelHelm = BotaniaAPI.getLatestAddedRecipe(); - addOreDictRecipe(new ItemStack(ModItems.manasteelChest), - "S S", "SSS", "SSS", - 'S', LibOreDict.MANA_STEEL); - recipeManasteelChest = BotaniaAPI.getLatestAddedRecipe(); - addOreDictRecipe(new ItemStack(ModItems.manasteelLegs), - "SSS", "S S", "S S", - 'S', LibOreDict.MANA_STEEL); - recipeManasteelLegs = BotaniaAPI.getLatestAddedRecipe(); - addOreDictRecipe(new ItemStack(ModItems.manasteelBoots), - "S S", "S S", - 'S', LibOreDict.MANA_STEEL); - recipeManasteelBoots = BotaniaAPI.getLatestAddedRecipe(); - addOreDictRecipe(new ItemStack(ModItems.manasteelPick), - "SSS", " T ", " T ", - 'S', LibOreDict.MANA_STEEL, - 'T', LibOreDict.LIVINGWOOD_TWIG); - recipeManasteelPick = BotaniaAPI.getLatestAddedRecipe(); - addOreDictRecipe(new ItemStack(ModItems.manasteelShovel), - "S", "T", "T", - 'S', LibOreDict.MANA_STEEL, - 'T', LibOreDict.LIVINGWOOD_TWIG); - recipeManasteelShovel = BotaniaAPI.getLatestAddedRecipe(); - addOreDictRecipe(new ItemStack(ModItems.manasteelAxe), - "SS", "TS", "T ", - 'S', LibOreDict.MANA_STEEL, - 'T', LibOreDict.LIVINGWOOD_TWIG); - recipeManasteelAxe = BotaniaAPI.getLatestAddedRecipe(); - addOreDictRecipe(new ItemStack(ModItems.manasteelSword), - "S", "S", "T", - 'S', LibOreDict.MANA_STEEL, - 'T', LibOreDict.LIVINGWOOD_TWIG); - recipeManasteelSword = BotaniaAPI.getLatestAddedRecipe(); - addOreDictRecipe(new ItemStack(ModItems.manasteelShears), - "S ", " S", - 'S', LibOreDict.MANA_STEEL); - recipeManasteelShears = BotaniaAPI.getLatestAddedRecipe(); - - // Horn of the Wild Recipe - addOreDictRecipe(new ItemStack(ModItems.grassHorn), - " W ", "WSW", "WW ", - 'W', LibOreDict.LIVING_WOOD, - 'S', new ItemStack(ModItems.grassSeeds)); - recipeGrassHorn = BotaniaAPI.getLatestAddedRecipe(); - - // Terrasteel Armor Recipes - addOreDictRecipe(new ItemStack(ModItems.terrasteelHelmRevealing), - "TRT", "SAS", " S ", - 'T', LibOreDict.LIVINGWOOD_TWIG, - 'S', LibOreDict.TERRA_STEEL, - 'R', LibOreDict.RUNE[4], - 'A', new ItemStack(ModItems.manasteelHelmRevealing)); - addOreDictRecipe(new ItemStack(ModItems.terrasteelHelm), - "TRT", "SAS", " S ", - 'T', LibOreDict.LIVINGWOOD_TWIG, - 'S', LibOreDict.TERRA_STEEL, - 'R', LibOreDict.RUNE[4], - 'A', new ItemStack(ModItems.manasteelHelm)); - recipeTerrasteelHelm = BotaniaAPI.getLatestAddedRecipe(); - addOreDictRecipe(new ItemStack(ModItems.terrasteelChest), - "TRT", "SAS", " S ", - 'T', LibOreDict.LIVINGWOOD_TWIG, - 'S', LibOreDict.TERRA_STEEL, - 'R', LibOreDict.RUNE[5], - 'A', new ItemStack(ModItems.manasteelChest)); - recipeTerrasteelChest = BotaniaAPI.getLatestAddedRecipe(); - addOreDictRecipe(new ItemStack(ModItems.terrasteelLegs), - "TRT", "SAS", " S ", - 'T', LibOreDict.LIVINGWOOD_TWIG, - 'S', LibOreDict.TERRA_STEEL, - 'R', LibOreDict.RUNE[6], - 'A', new ItemStack(ModItems.manasteelLegs)); - recipeTerrasteelLegs = BotaniaAPI.getLatestAddedRecipe(); - addOreDictRecipe(new ItemStack(ModItems.terrasteelBoots), - "TRT", "SAS", " S ", - 'T', LibOreDict.LIVINGWOOD_TWIG, - 'S', LibOreDict.TERRA_STEEL, - 'R', LibOreDict.RUNE[7], - 'A', new ItemStack(ModItems.manasteelBoots)); - recipeTerrasteelBoots = BotaniaAPI.getLatestAddedRecipe(); - - // Terra Blade Recipe - addOreDictRecipe(new ItemStack(ModItems.terraSword), - "I", "I", "S", - 'I', LibOreDict.TERRA_STEEL, - 'S', LibOreDict.LIVINGWOOD_TWIG); - recipeTerraSword = BotaniaAPI.getLatestAddedRecipe(); - - // Tiny Planet Recipe - addOreDictRecipe(new ItemStack(ModItems.tinyPlanet), - "LSL", "SPS", "LSL", - 'S', "stone", - 'L', LibOreDict.LIVING_ROCK, - 'P', LibOreDict.MANA_PEARL); - recipeTinyPlanet = BotaniaAPI.getLatestAddedRecipe(); - - // Mana Band Recipe - addOreDictRecipe(new ItemStack(ModItems.manaRing), - "TI ", "I I", " I ", - 'T', new ItemStack(ModItems.manaTablet, 1, Short.MAX_VALUE), - 'I', LibOreDict.MANA_STEEL); - recipeManaRing = BotaniaAPI.getLatestAddedRecipe(); - - // Aura Band Recipe - addOreDictRecipe(new ItemStack(ModItems.auraRing), - "RI ", "I I", " I ", - 'R', LibOreDict.RUNE[8], - 'I', LibOreDict.MANA_STEEL); - recipeAuraRing = BotaniaAPI.getLatestAddedRecipe(); - - // Greater Mana Band Recipe - addShapelessOreDictRecipe(new ItemStack(ModItems.manaRingGreater), LibOreDict.TERRA_STEEL, new ItemStack(ModItems.manaRing)); - recipeGreaterManaRing = BotaniaAPI.getLatestAddedRecipe(); - - // Greater Aura Band Recipe - addShapelessOreDictRecipe(new ItemStack(ModItems.auraRingGreater), LibOreDict.TERRA_STEEL, new ItemStack(ModItems.auraRing)); - recipeGreaterAuraRing = BotaniaAPI.getLatestAddedRecipe(); - - // Soujourner's Belt Recipe - addOreDictRecipe(new ItemStack(ModItems.travelBelt), - "EL ", "L L", "SLA", - 'E', LibOreDict.RUNE[2], - 'A', LibOreDict.RUNE[3], - 'S', LibOreDict.MANA_STEEL, - 'L', new ItemStack(Items.leather)); - recipeTravelBelt = BotaniaAPI.getLatestAddedRecipe(); - - // Tectonic Girdle Recipe - addOreDictRecipe(new ItemStack(ModItems.knockbackBelt), - "AL ", "L L", "SLE", - 'E', LibOreDict.RUNE[2], - 'A', LibOreDict.RUNE[1], - 'S', LibOreDict.MANA_STEEL, - 'L', new ItemStack(Items.leather)); - recipeKnocbackBelt = BotaniaAPI.getLatestAddedRecipe(); - - // Snowflake Pendant Recipe - addOreDictRecipe(new ItemStack(ModItems.icePendant), - "WS ", "S S", "MSR", - 'S', new ItemStack(Items.string), - 'M', LibOreDict.MANA_STEEL, - 'R', LibOreDict.RUNE[0], - 'W', LibOreDict.RUNE[7]); - recipeIcePendant = BotaniaAPI.getLatestAddedRecipe(); - - // Pyroclast Pendant Recipe - addOreDictRecipe(new ItemStack(ModItems.lavaPendant), - "MS ", "S S", "DSF", - 'S', new ItemStack(Items.string), - 'D', LibOreDict.MANA_STEEL, - 'M', LibOreDict.RUNE[5], - 'F', LibOreDict.RUNE[1]); - recipeFirePendant = BotaniaAPI.getLatestAddedRecipe(); - - // Golden Laurel Crown Recipe - addOreDictRecipe(new ItemStack(ModItems.goldLaurel), - "G G", "LEL", "LLL", - 'G', "ingotGold", - 'L', "treeLeaves", - 'E', LibOreDict.LIFE_ESSENCE); - recipeGoldenLaurel = BotaniaAPI.getLatestAddedRecipe(); - - // Tiny Planet Block Recipe - addOreDictRecipe(new ItemStack(ModBlocks.tinyPlanet), - "SSS", "SPS", "SSS", - 'S', "stone", - 'P', ModItems.tinyPlanet); - recipeTinyPlanetBlock = BotaniaAPI.getLatestAddedRecipe(); - - // Alchemy Catalyst Recipe - addOreDictRecipe(new ItemStack(ModBlocks.alchemyCatalyst), - "SGS", "BPB", "SGS", - 'S', LibOreDict.LIVING_ROCK, - 'G', "ingotGold", - 'B', new ItemStack(Items.brewing_stand), - 'P', LibOreDict.MANA_PEARL); - recipeAlchemyCatalyst = BotaniaAPI.getLatestAddedRecipe(); - - // Open Crate Recipe - GameRegistry.addRecipe(new ItemStack(ModBlocks.openCrate), - "WWW", "W W", "W W", - 'W', new ItemStack(ModBlocks.livingwood, 1, 1)); - recipeOpenCrate = BotaniaAPI.getLatestAddedRecipe(); - - // Eye of the Ancients Recipe - addOreDictRecipe(new ItemStack(ModBlocks.forestEye), - "MSM", "SES", "MSM", - 'M', LibOreDict.MANA_STEEL, - 'S', LibOreDict.LIVING_ROCK, - 'E', new ItemStack(Items.ender_eye)); - recipeForestEye = BotaniaAPI.getLatestAddedRecipe(); - - // Redstone Root Recipe - GameRegistry.addRecipe(new ShapelessOreRecipe(new ItemStack(ModItems.manaResource, 1, 6), "dustRedstone", new ItemStack(Blocks.tallgrass, 1, 1))); - recipeRedstoneRoot = BotaniaAPI.getLatestAddedRecipe(); - - // Drum of the Wild Recipe - addOreDictRecipe(new ItemStack(ModBlocks.forestDrum), - "WLW", "WHW", "WLW", - 'W', LibOreDict.LIVING_WOOD, - 'L', new ItemStack(Items.leather), - 'H', new ItemStack(ModItems.grassHorn)); - recipeForestDrum = BotaniaAPI.getLatestAddedRecipe(); - - // Ring of Chordata Recipe - addOreDictRecipe(new ItemStack(ModItems.waterRing), - "WMP", "M M", "SM ", - 'W', LibOreDict.RUNE[0], - 'M', LibOreDict.MANA_STEEL, - 'P', new ItemStack(Items.fish, 1, 3), - 'S', new ItemStack(Items.fish, 1, 1)); - recipeWaterRing = BotaniaAPI.getLatestAddedRecipe(); - - // Ring of the Mantle Recipe - addOreDictRecipe(new ItemStack(ModItems.miningRing), - "EMP", "M M", " M ", - 'E', LibOreDict.RUNE[2], - 'M', LibOreDict.MANA_STEEL, - 'P', new ItemStack(Items.golden_pickaxe)); - recipeMiningRing = BotaniaAPI.getLatestAddedRecipe(); - - // Ring of Magnetization Recipe - addOreDictRecipe(new ItemStack(ModItems.magnetRing), - "LM ", "M M", " M ", - 'L', new ItemStack(ModItems.lens, 1, 10), - 'M', LibOreDict.MANA_STEEL); - recipeMagnetRing = BotaniaAPI.getLatestAddedRecipe(); - - // Terra Shatterer Recipe - addOreDictRecipe(new ItemStack(ModItems.terraPick), - "ITI", "ILI", " L ", - 'T', new ItemStack(ModItems.manaTablet, 1, Short.MAX_VALUE), - 'I', LibOreDict.TERRA_STEEL, - 'L', LibOreDict.LIVINGWOOD_TWIG); - recipeTerraPick = BotaniaAPI.getLatestAddedRecipe(); - - // Charm of the Diva Recipe - addOreDictRecipe(new ItemStack(ModItems.divaCharm), - "LGP", " HG", " GL", - 'L', LibOreDict.LIFE_ESSENCE, - 'G', "ingotGold", - 'H', LibOreDict.RUNE[15], - 'P', new ItemStack(ModItems.tinyPlanet)); - recipeDivaCharm = BotaniaAPI.getLatestAddedRecipe(); - - // Flugel Tiara Recipe - addOreDictRecipe(new ItemStack(ModItems.flightTiara), - "LLL", "ILI", "FEF", - 'L', LibOreDict.LIFE_ESSENCE, - 'I', LibOreDict.ELEMENTIUM, - 'F', new ItemStack(Items.feather), - 'E', LibOreDict.ENDER_AIR_BOTTLE); - recipeFlightTiara = BotaniaAPI.getLatestAddedRecipe(); - - // Glimmering Flowers Recipes - for(int i = 0; i < 16; i++) - addShapelessOreDictRecipe(new ItemStack(ModBlocks.shinyFlower, 1, i), "dustGlowstone", "dustGlowstone", LibOreDict.FLOWER[i]); - recipesShinyFlowers = BotaniaAPI.getLatestAddedRecipes(16); - - // Abstruse Platform Recipe - addOreDictRecipe(new ItemStack(ModBlocks.platform, 2), - "343", "0P0", - '0', new ItemStack(ModBlocks.livingwood, 1, 0), - '3', new ItemStack(ModBlocks.livingwood, 1, 3), - '4', new ItemStack(ModBlocks.livingwood, 1, 4), - 'P', LibOreDict.MANA_PEARL); - recipePlatform = BotaniaAPI.getLatestAddedRecipe(); - - // Soulscribe Recipe - addOreDictRecipe(new ItemStack(ModItems.enderDagger), - "P", "S", "T", - 'P', LibOreDict.MANA_PEARL, - 'S', LibOreDict.MANA_STEEL, - 'T', LibOreDict.LIVINGWOOD_TWIG); - recipeEnderDagger = BotaniaAPI.getLatestAddedRecipe(); - - // Quartz Recipes - if(ConfigHandler.darkQuartzEnabled) - recipeDarkQuartz = addQuartzRecipes(0, Items.coal, ModFluffBlocks.darkQuartz, ModFluffBlocks.darkQuartzStairs, ModFluffBlocks.darkQuartzSlab); - addQuartzRecipes(1, null, ModFluffBlocks.manaQuartz, ModFluffBlocks.manaQuartzStairs, ModFluffBlocks.manaQuartzSlab); - recipeBlazeQuartz = addQuartzRecipes(2, Items.blaze_powder, ModFluffBlocks.blazeQuartz, ModFluffBlocks.blazeQuartzStairs, ModFluffBlocks.blazeQuartzSlab); - - GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(ModItems.quartz, 8, 3), - "QQQ", "QCQ", "QQQ", - 'Q', "gemQuartz", - 'C', new ItemStack(Blocks.red_flower, 1, 2))); - GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(ModItems.quartz, 8, 3), - "QQQ", "QCQ", "QQQ", - 'Q', "gemQuartz", - 'C', new ItemStack(Blocks.red_flower, 1, 7))); - GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(ModItems.quartz, 8, 3), - "QQQ", "QCQ", "QQQ", - 'Q', "gemQuartz", - 'C', new ItemStack(Blocks.double_plant, 1, 1))); - GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(ModItems.quartz, 8, 3), - "QQQ", "QCQ", "QQQ", - 'Q', "gemQuartz", - 'C', new ItemStack(Blocks.double_plant, 1, 5))); - recipesLavenderQuartz = BotaniaAPI.getLatestAddedRecipes(4); - addQuartzRecipes(3, null, ModFluffBlocks.lavenderQuartz, ModFluffBlocks.lavenderQuartzStairs, ModFluffBlocks.lavenderQuartzSlab); - - recipeRedQuartz = addQuartzRecipes(4, Items.redstone, ModFluffBlocks.redQuartz, ModFluffBlocks.redQuartzStairs, ModFluffBlocks.redQuartzSlab); - addQuartzRecipes(5, null, ModFluffBlocks.elfQuartz, ModFluffBlocks.elfQuartzStairs, ModFluffBlocks.elfQuartzSlab); - - recipeSunnyQuartz = addQuartzRecipes(6, Item.getItemFromBlock(Blocks.double_plant), ModFluffBlocks.sunnyQuartz, ModFluffBlocks.sunnyQuartzStairs, ModFluffBlocks.sunnyQuartzSlab); - - // Alfheim Portal Recipe - addOreDictRecipe(new ItemStack(ModBlocks.alfPortal), - "WTW", "WTW", "WTW", - 'W', LibOreDict.LIVING_WOOD, - 'T', LibOreDict.TERRASTEEL_NUGGET); - recipeAlfPortal = BotaniaAPI.getLatestAddedRecipe(); - - // Natura Pylon Recipe - addOreDictRecipe(new ItemStack(ModBlocks.pylon, 1, 1), - " T ", "TPT", " E ", - 'T', LibOreDict.TERRASTEEL_NUGGET, - 'P', new ItemStack(ModBlocks.pylon), - 'E', new ItemStack(Items.ender_eye)); - recipeNaturaPylon = BotaniaAPI.getLatestAddedRecipe(); - - // Rod of the Seas Recipe - addOreDictRecipe(new ItemStack(ModItems.waterRod), - " B", " T ", "R ", - 'B', new ItemStack(Items.potionitem), - 'T', LibOreDict.LIVINGWOOD_TWIG, - 'R', LibOreDict.RUNE[0]); - recipeWaterRod = BotaniaAPI.getLatestAddedRecipe(); - - // Elementium Armor & Tools Recipes - addOreDictRecipe(new ItemStack(ModItems.elementiumHelm), - "SSS", "S S", - 'S', LibOreDict.ELEMENTIUM); - recipeElementiumHelm = BotaniaAPI.getLatestAddedRecipe(); - addOreDictRecipe(new ItemStack(ModItems.elementiumChest), - "S S", "SSS", "SSS", - 'S', LibOreDict.ELEMENTIUM); - recipeElementiumChest = BotaniaAPI.getLatestAddedRecipe(); - addOreDictRecipe(new ItemStack(ModItems.elementiumLegs), - "SSS", "S S", "S S", - 'S', LibOreDict.ELEMENTIUM); - recipeElementiumLegs = BotaniaAPI.getLatestAddedRecipe(); - addOreDictRecipe(new ItemStack(ModItems.elementiumBoots), - "S S", "S S", - 'S', LibOreDict.ELEMENTIUM); - recipeElementiumBoots = BotaniaAPI.getLatestAddedRecipe(); - addOreDictRecipe(new ItemStack(ModItems.elementiumPick), - "SSS", " T ", " T ", - 'S', LibOreDict.ELEMENTIUM, - 'T', LibOreDict.DREAMWOOD_TWIG); - recipeElementiumPick = BotaniaAPI.getLatestAddedRecipe(); - addOreDictRecipe(new ItemStack(ModItems.elementiumShovel), - "S", "T", "T", - 'S', LibOreDict.ELEMENTIUM, - 'T', LibOreDict.DREAMWOOD_TWIG); - recipeElementiumShovel = BotaniaAPI.getLatestAddedRecipe(); - addOreDictRecipe(new ItemStack(ModItems.elementiumAxe), - "SS", "TS", "T ", - 'S', LibOreDict.ELEMENTIUM, - 'T', LibOreDict.DREAMWOOD_TWIG); - recipeElementiumAxe = BotaniaAPI.getLatestAddedRecipe(); - addOreDictRecipe(new ItemStack(ModItems.elementiumSword), - "S", "S", "T", - 'S', LibOreDict.ELEMENTIUM, - 'T', LibOreDict.DREAMWOOD_TWIG); - recipeElementiumSword = BotaniaAPI.getLatestAddedRecipe(); - addOreDictRecipe(new ItemStack(ModItems.elementiumShears), - "S ", " S", - 'S', LibOreDict.ELEMENTIUM); - recipeElementiumShears = BotaniaAPI.getLatestAddedRecipe(); - - // Extrapolated Bucket Recipe - addOreDictRecipe(new ItemStack(ModItems.openBucket), - "E E", " E ", - 'E', LibOreDict.ELEMENTIUM); - recipeOpenBucket = BotaniaAPI.getLatestAddedRecipe(); - - // Conjuration Catalyst Recipe - addOreDictRecipe(new ItemStack(ModBlocks.conjurationCatalyst), - "SBS", "GPG", "SGS", - 'S', LibOreDict.LIVING_ROCK, - 'G', LibOreDict.ELEMENTIUM, - 'B',LibOreDict.PIXIE_DUST, - 'P', new ItemStack(ModBlocks.alchemyCatalyst)); - recipeConjurationCatalyst = BotaniaAPI.getLatestAddedRecipe(); - - // Life Aggregator Recipe - addOreDictRecipe(new ItemStack(ModItems.spawnerMover), - "EIE", "ADA", "EIE", - 'E', LibOreDict.LIFE_ESSENCE, - 'I', LibOreDict.ELEMENTIUM, - 'A', LibOreDict.ENDER_AIR_BOTTLE, - 'D', LibOreDict.DRAGONSTONE); - recipeSpawnerMover = BotaniaAPI.getLatestAddedRecipe(); - - // Great Fairy Ring Recipe - addOreDictRecipe(new ItemStack(ModItems.pixieRing), - "DE ", "E E", " E ", - 'D', LibOreDict.PIXIE_DUST, - 'E', LibOreDict.ELEMENTIUM); - recipePixieRing = BotaniaAPI.getLatestAddedRecipe(); - - // Globetrotter's Sash Recipe - addOreDictRecipe(new ItemStack(ModItems.superTravelBelt), - "E ", " S ", "L E", - 'E', LibOreDict.ELEMENTIUM, - 'L', LibOreDict.LIFE_ESSENCE, - 'S', new ItemStack(ModItems.travelBelt)); - recipeSuperTravelBelt = BotaniaAPI.getLatestAddedRecipe(); - - // Rod of Bifrost Recipe - addOreDictRecipe(new ItemStack(ModItems.rainbowRod), - " PD", " EP", "E ", - 'P', LibOreDict.PIXIE_DUST, - 'E', LibOreDict.ELEMENTIUM, - 'D', LibOreDict.DRAGONSTONE); - recipeRainbowRod = BotaniaAPI.getLatestAddedRecipe(); - - // Spectral Platform Recipe - addOreDictRecipe(new ItemStack(ModBlocks.platform, 2, 1), - "343", "0D0", - '0', new ItemStack(ModBlocks.dreamwood, 1, 0), - '3', new ItemStack(ModBlocks.dreamwood, 1, 3), - '4', new ItemStack(ModBlocks.dreamwood, 1, 4), - 'D', LibOreDict.PIXIE_DUST); - recipeSpectralPlatform = BotaniaAPI.getLatestAddedRecipe(); - - // Elven Mana Spreader Recipes - for(int i = 0; i < 16; i++) - addOreDictRecipe(new ItemStack(ModBlocks.spreader, 1, 2), - "WWW", "EP ", "WWW", - 'W', LibOreDict.DREAM_WOOD, - 'P', LibOreDict.PETAL[i], - 'E', LibOreDict.ELEMENTIUM); - recipesDreamwoodSpreader = BotaniaAPI.getLatestAddedRecipes(16); - - // Rod of the Skies Recipe - addOreDictRecipe(new ItemStack(ModItems.tornadoRod), - " F", " T ", "R ", - 'F', new ItemStack(Items.feather), - 'T', LibOreDict.LIVINGWOOD_TWIG, - 'R', LibOreDict.RUNE[3]); - recipeTornadoRod = BotaniaAPI.getLatestAddedRecipe(); - - // Rod of the Hells Recipe - addOreDictRecipe(new ItemStack(ModItems.fireRod), - " F", " T ", "R ", - 'F', new ItemStack(Items.blaze_powder), - 'T', LibOreDict.LIVINGWOOD_TWIG, - 'R', LibOreDict.RUNE[1]); - recipeFireRod = BotaniaAPI.getLatestAddedRecipe(); - - // Vine Ball Recipe - addOreDictRecipe(new ItemStack(ModItems.vineBall), - "VVV", "VVV", "VVV", - 'V', new ItemStack(Blocks.vine)); - recipeVineBall = BotaniaAPI.getLatestAddedRecipe(); - - // Livingwood Slingshot Recipe - addOreDictRecipe(new ItemStack(ModItems.slingshot), - " TA", " TT", "T ", - 'T', LibOreDict.LIVINGWOOD_TWIG, - 'A', LibOreDict.RUNE[3]); - recipeSlingshot = BotaniaAPI.getLatestAddedRecipe(); - - // Moss Stone Recipe - addShapelessOreDictRecipe(new ItemStack(Blocks.mossy_cobblestone), "cobblestone", new ItemStack(ModItems.vineBall)); - recipeMossStone = BotaniaAPI.getLatestAddedRecipe(); - - // Prismarine Recipe - addOreDictRecipe(new ItemStack(ModBlocks.prismarine, 1, 0), - " S ", "SBS", " S ", - 'S', LibOreDict.PRISMARINE_SHARD, - 'B', "cobblestone"); - recipePrismarine = BotaniaAPI.getLatestAddedRecipe(); - - // Prismarine Brick Recipe - addOreDictRecipe(new ItemStack(ModBlocks.prismarine, 1, 1), - " S ", "SBS", " S ", - 'S', LibOreDict.PRISMARINE_SHARD, - 'B', new ItemStack(Blocks.stonebrick)); - recipePrismarineBrick = BotaniaAPI.getLatestAddedRecipe(); - - // Dark Prismarine Recipe - addOreDictRecipe(new ItemStack(ModBlocks.prismarine, 1, 2), - " S ", "SBS", " S ", - 'S', LibOreDict.PRISMARINE_SHARD, - 'B', new ItemStack(Blocks.nether_brick)); - recipeDarkPrismarine = BotaniaAPI.getLatestAddedRecipe(); - - // Sea Lantern Recipe - addOreDictRecipe(new ItemStack(ModBlocks.seaLamp), - " S ", "SBS", " S ", - 'S', LibOreDict.PRISMARINE_SHARD, - 'B', "glowstone"); - recipeSeaLamp = BotaniaAPI.getLatestAddedRecipe(); - - // Influence Lens Recipe - addOreDictRecipe(new ItemStack(ModItems.lens, 1, 12), - "PRP", "PLP", "PPP", - 'P', LibOreDict.PRISMARINE_SHARD, - 'R', LibOreDict.RUNE[3], - 'L', new ItemStack(ModItems.lens)); - recipeLensInfluence = BotaniaAPI.getLatestAddedRecipe(); - - // Weight Lens Recipe - addOreDictRecipe(new ItemStack(ModItems.lens, 1, 13), - "PPP", "PLP", "PRP", - 'P', LibOreDict.PRISMARINE_SHARD, - 'R', LibOreDict.RUNE[0], - 'L', new ItemStack(ModItems.lens)); - recipeLensWeight = BotaniaAPI.getLatestAddedRecipe(); - - // Paintslinger Lens Recipe - addOreDictRecipe(new ItemStack(ModItems.lens, 1, 14), - " E ", "WLW", " E ", - 'E', LibOreDict.ELEMENTIUM, - 'W', new ItemStack(Blocks.wool, 1, Short.MAX_VALUE), - 'L', new ItemStack(ModItems.lens)); - recipeLensPaint = BotaniaAPI.getLatestAddedRecipe(); - - // Warp Lens Recipe - addShapelessOreDictRecipe(new ItemStack(ModItems.lens, 1, 18), new ItemStack(ModItems.lens), LibOreDict.PIXIE_DUST); - recipeLensWarp = BotaniaAPI.getLatestAddedRecipe(); - - // Redirective Lens Recipe - addShapelessOreDictRecipe(new ItemStack(ModItems.lens, 1, 19), new ItemStack(ModItems.lens), LibOreDict.LIVING_WOOD, LibOreDict.ELEMENTIUM); - recipeLensRedirect = BotaniaAPI.getLatestAddedRecipe(); - - // Celebratory Lens Recipe - addShapelessOreDictRecipe(new ItemStack(ModItems.lens, 1, 20), new ItemStack(ModItems.lens), new ItemStack(Items.fireworks), LibOreDict.ELEMENTIUM); - recipeLensFirework = BotaniaAPI.getLatestAddedRecipe(); - - // Flare Lens Recipe - addShapelessOreDictRecipe(new ItemStack(ModItems.lens, 1, 21), new ItemStack(ModItems.lens), new ItemStack(ModBlocks.elfGlass), LibOreDict.ELEMENTIUM); - recipeLensFlare = BotaniaAPI.getLatestAddedRecipe(); - - // Mini Island Recipes - for(int i = 0; i < 16; i++) - GameRegistry.addRecipe(new ItemStack(ModBlocks.floatingFlower, 1, i), - "F", "S", "D", - 'F', new ItemStack(ModBlocks.shinyFlower, 1, i), - 'S', new ItemStack(ModItems.grassSeeds), - 'D', new ItemStack(Blocks.dirt)); - recipesMiniIsland = BotaniaAPI.getLatestAddedRecipes(16); - - // Gaia Pylon Recipe - addOreDictRecipe(new ItemStack(ModBlocks.pylon, 1, 2), - " D ", "EPE", " D ", - 'D', LibOreDict.PIXIE_DUST, - 'E', LibOreDict.ELEMENTIUM, - 'P', new ItemStack(ModBlocks.pylon)); - recipeGaiaPylon = BotaniaAPI.getLatestAddedRecipe(); - - // Drum of the Gathering Recipe - addOreDictRecipe(new ItemStack(ModBlocks.forestDrum, 1, 1), - "WLW", "WEW", "WLW", - 'W', LibOreDict.DREAM_WOOD, - 'L', new ItemStack(Items.leather), - 'E', LibOreDict.ELEMENTIUM); - recipeGatherDrum = BotaniaAPI.getLatestAddedRecipe(); - - // Mana Lens: Kindle Recipe - addShapelessOreDictRecipe(new ItemStack(ModItems.lens, 1, 15), new ItemStack(ModItems.lens), new ItemStack(Items.fire_charge)); - recipeLensFire = BotaniaAPI.getLatestAddedRecipe(); - - // Mana Lens: Piston Recipe - addShapelessOreDictRecipe(new ItemStack(ModItems.lens, 1, 16), new ItemStack(ModItems.lens), new ItemStack(ModBlocks.pistonRelay)); - recipeLensPiston = BotaniaAPI.getLatestAddedRecipe(); - - // Shard of Laputa Recipe - for(int i = 0; i < 16; i++) - addOreDictRecipe(new ItemStack(ModItems.laputaShard), - "SFS", "PDP", "ASE", - 'S', LibOreDict.LIFE_ESSENCE, - 'D', LibOreDict.DRAGONSTONE, - 'F', new ItemStack(ModBlocks.floatingFlower, 1, i), - 'P', LibOreDict.PRISMARINE_SHARD, - 'A', LibOreDict.RUNE[3], - 'E', LibOreDict.RUNE[2]); - recipesLaputaShard = BotaniaAPI.getLatestAddedRecipes(16); - - for(int i = 1; i < 20; i++) - addShapelessOreDictRecipe(new ItemStack(ModItems.laputaShard, 1, i), LibOreDict.LIFE_ESSENCE,new ItemStack(ModItems.laputaShard, 1, i - 1)); - recipesLaputaShardUpgrade = BotaniaAPI.getLatestAddedRecipes(19); - - // Necrodermal Virus Recipe - addShapelessOreDictRecipe(new ItemStack(ModItems.virus), LibOreDict.PIXIE_DUST, new ItemStack(ModItems.vineBall), new ItemStack(Items.magma_cream), new ItemStack(Items.fermented_spider_eye), new ItemStack(Items.ender_eye), new ItemStack(Items.skull, 1, 2)); - recipeVirusZombie = BotaniaAPI.getLatestAddedRecipe(); - - // Nullodermal Virus Recipe - addShapelessOreDictRecipe(new ItemStack(ModItems.virus, 1, 1), LibOreDict.PIXIE_DUST, new ItemStack(ModItems.vineBall), new ItemStack(Items.magma_cream), new ItemStack(Items.fermented_spider_eye), new ItemStack(Items.ender_eye), new ItemStack(Items.skull)); - recipeVirusSkeleton = BotaniaAPI.getLatestAddedRecipe(); - - // Ring of Far Reach Recipe - addOreDictRecipe(new ItemStack(ModItems.reachRing), - "RE ", "E E", " E ", - 'R', LibOreDict.RUNE[15], - 'E', LibOreDict.ELEMENTIUM); - recipeReachRing = BotaniaAPI.getLatestAddedRecipe(); - - // Rod of the Highlands Recipe - addShapelessOreDictRecipe(new ItemStack(ModItems.skyDirtRod), new ItemStack(ModItems.dirtRod), LibOreDict.PIXIE_DUST, LibOreDict.RUNE[3]); - recipeSkyDirtRod = BotaniaAPI.getLatestAddedRecipe(); - - // Life Imbuer Recipe - addOreDictRecipe(new ItemStack(ModBlocks.spawnerClaw), - "BSB", "PMP", "PEP", - 'B', new ItemStack(Items.blaze_rod), - 'S', LibOreDict.ELEMENTIUM, - 'P', new ItemStack(ModBlocks.prismarine, 1, 2), - 'M', new ItemStack(ModBlocks.storage), - 'E', LibOreDict.ENDER_AIR_BOTTLE); - recipeSpawnerClaw = BotaniaAPI.getLatestAddedRecipe(); - - // Crafty Crate Recipe - GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(ModBlocks.openCrate, 1, 1), - "WCW", "W W", "W W", - 'C', "craftingTableWood", - 'W', new ItemStack(ModBlocks.dreamwood, 1, 1))); - recipeCraftCrate = BotaniaAPI.getLatestAddedRecipe(); - - // Crafting Placeholder Recipe - addShapelessOreDictRecipe(new ItemStack(ModItems.manaResource, 32, 11), "craftingTableWood", LibOreDict.LIVING_ROCK); - recipePlaceholder = BotaniaAPI.getLatestAddedRecipe(); - - // Reed Block Recipe - GameRegistry.addRecipe(new ItemStack(ModBlocks.reedBlock), - "rrr", "rrr", "rrr", - 'r', new ItemStack(Items.reeds)); - recipeReedBlock = BotaniaAPI.getLatestAddedRecipe(); - - // Thatch Recipe - GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(ModBlocks.thatch), - "ww", "ww", - 'w', "cropWheat")); - recipeThatch = BotaniaAPI.getLatestAddedRecipe(); - - // Nether Brick Recipe - GameRegistry.addRecipe(new ItemStack(ModBlocks.customBrick, 4, 0), - " B ", "BSB", " B ", - 'B', new ItemStack(Blocks.netherrack), - 'S', new ItemStack(Blocks.stonebrick)); - recipeNetherBrick = BotaniaAPI.getLatestAddedRecipe(); - - // Soul Brick Recipe - GameRegistry.addRecipe(new ItemStack(ModBlocks.customBrick, 4, 1), - " B ", "BSB", " B ", - 'B', new ItemStack(Blocks.soul_sand), - 'S', new ItemStack(Blocks.stonebrick)); - recipeSoulBrick = BotaniaAPI.getLatestAddedRecipe(); - - // Snow Brick Recipe - GameRegistry.addRecipe(new ItemStack(ModBlocks.customBrick, 4, 2), - " B ", "BSB", " B ", - 'B', new ItemStack(Blocks.snow), - 'S', new ItemStack(Blocks.stonebrick)); - recipeSnowBrick = BotaniaAPI.getLatestAddedRecipe(); - - // Roof Tile Recipe - GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(ModBlocks.customBrick, 4, 3), - "BB", "BB", "BB", - 'B', "ingotBrick")); - recipeRoofTile = BotaniaAPI.getLatestAddedRecipe(); - - // Azulejo Recipe - GameRegistry.addRecipe(new ShapelessOreRecipe(new ItemStack(ModBlocks.customBrick, 1, 4), "gemLapis", "blockQuartz")); - recipeAzulejo = BotaniaAPI.getLatestAddedRecipe(); - - // Azulejo Cycling Recipes - for(int i = 0; i < 12; i++) - GameRegistry.addShapelessRecipe(new ItemStack(ModBlocks.customBrick, 1, 4 + (i == 11 ? 0 : i + 1)), new ItemStack(ModBlocks.customBrick, 1, 4 + i)); - recipesAzulejoCycling = BotaniaAPI.getLatestAddedRecipes(12); - - // Ender Overseer Recipe - GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(ModBlocks.enderEye), - "RER", "EOE", "RER", - 'R', "dustRedstone", - 'E', new ItemStack(Items.ender_eye), - 'O', new ItemStack(Blocks.obsidian))); - recipeEnderEyeBlock = BotaniaAPI.getLatestAddedRecipe(); - - // The Spectator Recipe - addOreDictRecipe(new ItemStack(ModItems.itemFinder), - " I ", "IYI", "IEI", - 'I', "ingotIron", - 'Y', new ItemStack(Items.ender_eye), - 'E', "gemEmerald"); - recipeItemFinder = BotaniaAPI.getLatestAddedRecipe(); - - // Crimson Pendant Recipe - addOreDictRecipe(new ItemStack(ModItems.superLavaPendant), - "BBB", "BPB", "NGN", - 'B', new ItemStack(Items.blaze_rod), - 'P', new ItemStack(ModItems.lavaPendant), - 'N', new ItemStack(Blocks.nether_brick), - 'G', LibOreDict.LIFE_ESSENCE); - recipeSuperLavaPendant = BotaniaAPI.getLatestAddedRecipe(); - - // Hand of Ender Recipe - addOreDictRecipe(new ItemStack(ModItems.enderHand), - "PLO", "LEL", "OL ", - 'P', LibOreDict.MANA_PEARL, - 'L', new ItemStack(Items.leather), - 'E', new ItemStack(Blocks.ender_chest), - 'O', new ItemStack(Blocks.obsidian)); - recipeEnderHand = BotaniaAPI.getLatestAddedRecipe(); - - // Vitreous Pickaxe Recipe - addOreDictRecipe(new ItemStack(ModItems.glassPick), - "GIG", " T ", " T ", - 'G', "blockGlassColorless", - 'I', LibOreDict.MANA_STEEL, - 'T', LibOreDict.LIVINGWOOD_TWIG); - recipeGlassPick = BotaniaAPI.getLatestAddedRecipe(); - - // Starfield Creator Recipe - addOreDictRecipe(new ItemStack(ModBlocks.starfield), - "EPE", "EOE", - 'E', LibOreDict.ELEMENTIUM, - 'P', LibOreDict.PIXIE_DUST, - 'O', new ItemStack(Blocks.obsidian)); - recipeStarfield = BotaniaAPI.getLatestAddedRecipe(); - - // Spark Recipe - for(int i = 0; i < 16; i++) - addOreDictRecipe(new ItemStack(ModItems.spark), - " P ", "BNB", " P ", - 'B', new ItemStack(Items.blaze_powder), - 'P', LibOreDict.PETAL[i], - 'N', "nuggetGold"); - recipesSpark = BotaniaAPI.getLatestAddedRecipes(16); - - // Spark Augment Recipes - for(int i = 0; i < 4; i++) - addShapelessOreDictRecipe(new ItemStack(ModItems.sparkUpgrade, 1, i), - LibOreDict.PIXIE_DUST, LibOreDict.MANA_STEEL, LibOreDict.RUNE[i]); - recipesSparkUpgrades = BotaniaAPI.getLatestAddedRecipes(4); - - // Horn of the Canopy Recipe - addShapelessOreDictRecipe(new ItemStack(ModItems.grassHorn, 1, 1), new ItemStack(ModItems.grassHorn), "treeLeaves"); - recipeLeafHorn = BotaniaAPI.getLatestAddedRecipe(); - - // Rod of Divining Recipe - addOreDictRecipe(new ItemStack(ModItems.diviningRod), - " TD", " TT", "T ", - 'T', LibOreDict.LIVINGWOOD_TWIG, - 'D', LibOreDict.MANA_DIAMOND); - recipeDiviningRod = BotaniaAPI.getLatestAddedRecipe(); - - // Rod of the Black Mesa Recipe - addOreDictRecipe(new ItemStack(ModItems.gravityRod), - " TD", " WT", "T ", - 'T', LibOreDict.DREAMWOOD_TWIG, - 'W', "cropWheat", - 'D', LibOreDict.DRAGONSTONE); - recipeGravityRod = BotaniaAPI.getLatestAddedRecipe(); - - // Timeless Ivy Recipe - addShapelessOreDictRecipe(new ItemStack(ModItems.regenIvy), new ItemStack(Blocks.vine), LibOreDict.LIFE_ESSENCE, LibOreDict.ELEMENTIUM); - recipeRegenIvy = BotaniaAPI.getLatestAddedRecipe(); - - // Gaia Mana Spreader Recipe - addOreDictRecipe(new ItemStack(ModBlocks.spreader, 1, 3), - "ESD", - 'E', LibOreDict.LIFE_ESSENCE, - 'S', new ItemStack(ModBlocks.spreader, 1, 2), - 'D', LibOreDict.DRAGONSTONE); - recipeUltraSpreader = BotaniaAPI.getLatestAddedRecipe(); - - // Wing Recipes - GameRegistry.addRecipe(new ShapelessOreRecipe(new ItemStack(ModItems.flightTiara, 1, 1), new ItemStack(ModItems.flightTiara, 1, Short.MAX_VALUE), "gemQuartz")); - for(int i = 0; i < 7; i++) - GameRegistry.addRecipe(new ShapelessOreRecipe(new ItemStack(ModItems.flightTiara, 1, 2 + i), new ItemStack(ModItems.flightTiara, 1, Short.MAX_VALUE), LibOreDict.QUARTZ[i])); - recipesWings = BotaniaAPI.getLatestAddedRecipes(8); - - // Mana Fluxfield Recipe - if(ConfigHandler.fluxfieldEnabled) { - addOreDictRecipe(new ItemStack(ModBlocks.rfGenerator), - "SRS", "RMR", "SRS", - 'S', LibOreDict.LIVING_ROCK, - 'M', LibOreDict.MANA_STEEL, - 'R', "blockRedstone"); - recipeRFGenerator = BotaniaAPI.getLatestAddedRecipe(); - } - - // Vial Recipe - GameRegistry.addRecipe(new ItemStack(ModItems.vial, 3, 0), - "G G", " G ", - 'G', new ItemStack(ModBlocks.manaGlass)); - recipeVial = BotaniaAPI.getLatestAddedRecipe(); - - // Flask Recipe - GameRegistry.addRecipe(new ItemStack(ModItems.vial, 3, 1), - "G G", " G ", - 'G', new ItemStack(ModBlocks.elfGlass)); - recipeFlask = BotaniaAPI.getLatestAddedRecipe(); - - // Botanical Brewery Recipe - addOreDictRecipe(new ItemStack(ModBlocks.brewery), - "RSR", "RAR", "RMR", - 'R', LibOreDict.LIVING_ROCK, - 'S', new ItemStack(Items.brewing_stand), - 'A', LibOreDict.RUNE[8], - 'M', new ItemStack(ModBlocks.storage)); - recipeBrewery = BotaniaAPI.getLatestAddedRecipe(); - - // Tainted Blood Pendant Recipe - addOreDictRecipe(new ItemStack(ModItems.bloodPendant), - " P ", "PGP", "DP ", - 'P', LibOreDict.PRISMARINE_SHARD, - 'G', new ItemStack(Items.ghast_tear), - 'D', LibOreDict.MANA_DIAMOND); - recipeBloodPendant = BotaniaAPI.getLatestAddedRecipe(); - - // Terrestrial Agglomeration Plate Recipe - addOreDictRecipe(new ItemStack(ModBlocks.terraPlate), - "LLL", "0M1", "283", - 'L', "blockLapis", - 'M', new ItemStack(ModBlocks.storage), - '0', LibOreDict.RUNE[0], - '1', LibOreDict.RUNE[1], - '2', LibOreDict.RUNE[2], - '3', LibOreDict.RUNE[3], - '8', LibOreDict.RUNE[8]); - recipeTerraPlate = BotaniaAPI.getLatestAddedRecipe(); - - // Red String Recipe - addShapelessOreDictRecipe(new ItemStack(ModItems.manaResource, 1, 12), new ItemStack(Items.string), "blockRedstone", LibOreDict.PIXIE_DUST, LibOreDict.ENDER_AIR_BOTTLE); - recipeRedString = BotaniaAPI.getLatestAddedRecipe(); - // Are you in a pinch? - addShapelessOreDictRecipe(new ItemStack(ModItems.manaResource, 1, 12), new ItemStack(Items.string), "blockRedstone", LibOreDict.PIXIE_DUST, LibOreDict.ENDER_AIR_BOTTLE, new ItemStack(Blocks.pumpkin)); - - // Red String Container Recipe - addOreDictRecipe(new ItemStack(ModBlocks.redStringContainer), - "RRR", "RCS", "RRR", - 'R', LibOreDict.LIVING_ROCK, - 'S', LibOreDict.RED_STRING, - 'C', "chestWood"); - recipeRedStringContainer = BotaniaAPI.getLatestAddedRecipe(); - - // Red String Dispenser Recipe - addOreDictRecipe(new ItemStack(ModBlocks.redStringDispenser), - "RRR", "RDS", "RRR", - 'R', LibOreDict.LIVING_ROCK, - 'S', LibOreDict.RED_STRING, - 'D', new ItemStack(Blocks.dispenser)); - recipeRedStringDispenser = BotaniaAPI.getLatestAddedRecipe(); - - // Red String Fertilizer Recipe - addOreDictRecipe(new ItemStack(ModBlocks.redStringFertilizer), - "RRR", "RBS", "RRR", - 'R', LibOreDict.LIVING_ROCK, - 'S', LibOreDict.RED_STRING, - 'B', new ItemStack(ModItems.fertilizer)); - recipeRedStringFertilizer = BotaniaAPI.getLatestAddedRecipe(); - - // Red String Comparator Recipe - addOreDictRecipe(new ItemStack(ModBlocks.redStringComparator), - "RRR", "RCS", "RRR", - 'R', LibOreDict.LIVING_ROCK, - 'S', LibOreDict.RED_STRING, - 'C', new ItemStack(Items.comparator)); - recipeRedStringComparator = BotaniaAPI.getLatestAddedRecipe(); - - // Red String Spoofer Recipe - addOreDictRecipe(new ItemStack(ModBlocks.redStringRelay), - "RRR", "RMS", "RRR", - 'R', LibOreDict.LIVING_ROCK, - 'S', LibOreDict.RED_STRING, - 'M', new ItemStack(ModBlocks.spreader)); - recipeRedStringRelay = BotaniaAPI.getLatestAddedRecipe(); - - // Red String Interceptor Recipe - addOreDictRecipe(new ItemStack(ModBlocks.redStringInterceptor), - "RRR", "RMS", "RRR", - 'R', LibOreDict.LIVING_ROCK, - 'S', LibOreDict.RED_STRING, - 'M', new ItemStack(Blocks.stone_button)); - recipeRedStringInterceptor = BotaniaAPI.getLatestAddedRecipe(); - - // Rod of the Arcane Barrage Recipe - addOreDictRecipe(new ItemStack(ModItems.missileRod), - "GDD", " TD", "T G", - 'G', LibOreDict.LIFE_ESSENCE, - 'D', LibOreDict.DRAGONSTONE, - 'T', LibOreDict.DREAMWOOD_TWIG); - recipeMissileRod = BotaniaAPI.getLatestAddedRecipe(); - - // Cloak of Virtue Recipe - addOreDictRecipe(new ItemStack(ModItems.holyCloak), - "WWW", "GWG", "GSG", - 'W', new ItemStack(Blocks.wool), - 'G', "dustGlowstone", - 'S', LibOreDict.LIFE_ESSENCE); - recipeHolyCloak = BotaniaAPI.getLatestAddedRecipe(); - - // Cloak of Sin Recipe - addOreDictRecipe(new ItemStack(ModItems.unholyCloak), - "WWW", "RWR", "RSR", - 'W', new ItemStack(Blocks.wool, 1, 15), - 'R', "dustRedstone", - 'S', LibOreDict.LIFE_ESSENCE); - recipeUnholyCloak = BotaniaAPI.getLatestAddedRecipe(); - - // Assembly Halo Recipe - addOreDictRecipe(new ItemStack(ModItems.craftingHalo), - " P ", "ICI", " I ", - 'P', LibOreDict.MANA_PEARL, - 'I', LibOreDict.MANA_STEEL, - 'C', "craftingTableWood"); - recipeCraftingHalo = BotaniaAPI.getLatestAddedRecipe(); - - // Mana Lens: Flash Recipe - GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(ModItems.lens, 1, 17), - "GFG", "FLF", "GFG", - 'G', "glowstone", - 'F', new ItemStack(Items.fire_charge), - 'L', new ItemStack(ModItems.lens))); - GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(ModItems.lens, 1, 17), - "FGF", "GLG", "FGF", - 'G', "glowstone", - 'F', new ItemStack(Items.fire_charge), - 'L', new ItemStack(ModItems.lens))); - recipesLensFlash = BotaniaAPI.getLatestAddedRecipes(2); - - // Mana Prism Recipe - addOreDictRecipe(new ItemStack(ModBlocks.prism), - "GPG", "GSG", "GPG", - 'G', "blockGlassColorless", - 'P', LibOreDict.PRISMARINE_SHARD, - 'S', new ItemStack(ModBlocks.platform, 1, 1)); - recipePrism = BotaniaAPI.getLatestAddedRecipe(); - - // Trodden Dirt Recipe - GameRegistry.addRecipe(new ShapelessOreRecipe(new ItemStack(ModBlocks.dirtPath, 4), new ItemStack(Blocks.dirt, 1, 1), new ItemStack(Blocks.dirt, 1, 1), new ItemStack(Blocks.dirt, 1, 1), "sand")); - recipeDirtPath = BotaniaAPI.getLatestAddedRecipe(); - - // Dreamwood Twig Recipe - addOreDictRecipe(new ItemStack(ModItems.manaResource, 1, 13), - "W", "W", - 'W', LibOreDict.DREAM_WOOD); - recipeDreamwoodTwig = BotaniaAPI.getLatestAddedRecipe(); - - // Manaseer Monocle Recipe - addOreDictRecipe(new ItemStack(ModItems.monocle), - "GN", "IN", " N", - 'G', new ItemStack(ModBlocks.manaGlass), - 'I', LibOreDict.MANA_STEEL, - 'N', new ItemStack(Items.gold_nugget)); - recipeMonocle = BotaniaAPI.getLatestAddedRecipe(); - - // Lens Clip Recipe - addOreDictRecipe(new ItemStack(ModItems.clip), - " D ", "D D", "DD ", - 'D', LibOreDict.DREAM_WOOD); - recipeClip = BotaniaAPI.getLatestAddedRecipe(); - - // Rod of the Depths Recipe - addOreDictRecipe(new ItemStack(ModItems.cobbleRod), - " FC", " TW", "T ", - 'F', LibOreDict.RUNE[1], - 'W', LibOreDict.RUNE[0], - 'T', LibOreDict.LIVINGWOOD_TWIG, - 'C', "cobblestone"); - recipeCobbleRod = BotaniaAPI.getLatestAddedRecipe(); - - // Rod of the Molten Core Recipe - addOreDictRecipe(new ItemStack(ModItems.smeltRod), - " BF", " TB", "T ", - 'B', new ItemStack(Items.blaze_rod), - 'F', LibOreDict.RUNE[1], - 'T', LibOreDict.LIVINGWOOD_TWIG); - recipeSmeltRod = BotaniaAPI.getLatestAddedRecipe(); - - // World Seed Recipe - addOreDictRecipe(new ItemStack(ModItems.worldSeed, 4), - "G", "S", "D", - 'G', new ItemStack(Blocks.grass), - 'S', new ItemStack(Items.wheat_seeds), - 'D', LibOreDict.DRAGONSTONE); - recipeWorldSeed = BotaniaAPI.getLatestAddedRecipe(); - - // Spellbinding Cloth Recipe - addOreDictRecipe(new ItemStack(ModItems.spellCloth), - " C ", "CPC", " C ", - 'C', LibOreDict.MANAWEAVE_CLOTH, - 'P', LibOreDict.MANA_PEARL); - recipeSpellCloth = BotaniaAPI.getLatestAddedRecipe(); - - // Thorn Chakram Recipe - addOreDictRecipe(new ItemStack(ModItems.thornChakram, 2), - "VVV", "VTV", "VVV", - 'V', new ItemStack(Blocks.vine), - 'T', LibOreDict.TERRA_STEEL); - recipeThornChakram = BotaniaAPI.getLatestAddedRecipe(); - - // Trodden Dirt Slab - GameRegistry.addRecipe(new ItemStack(ModFluffBlocks.dirtPathSlab, 6), - "DDD", - 'D', new ItemStack(ModBlocks.dirtPath)); - recipeDirtPathSlab = BotaniaAPI.getLatestAddedRecipe(); - - // Pattern Recipes - { - int count = TileCraftCrate.PATTERNS.length; - List recipeObjects = Arrays.asList(new Object[] { - 'R', "dustRedstone", - 'P', LibOreDict.PLACEHOLDER - }); - - for(int i = 0; i < count; i++) { - List recipe = new ArrayList(); - for(int j = 0; j < 3; j++) { - String s = ""; - for(int k = 0; k < 3; k++) - s += TileCraftCrate.PATTERNS[i][j * 3 + k] ? "R" : "P"; - recipe.add(s); - } - recipe.addAll(recipeObjects); - - addOreDictRecipe(new ItemStack(ModItems.craftPattern, 1, i), recipe.toArray(new Object[recipe.size()])); - } - - recipesPatterns = BotaniaAPI.getLatestAddedRecipes(count); - } - - // Gaia Spirit Ingot Recipe - addOreDictRecipe(new ItemStack(ModItems.manaResource, 1, 14), - " S ", "SIS", " S ", - 'S', LibOreDict.LIFE_ESSENCE, - 'I', LibOreDict.TERRA_STEEL); - recipeGaiaIngot = BotaniaAPI.getLatestAddedRecipe(); - - // Corporea Spark Recipe - addShapelessOreDictRecipe(new ItemStack(ModItems.corporeaSpark), new ItemStack(ModItems.spark), LibOreDict.PIXIE_DUST, LibOreDict.ENDER_AIR_BOTTLE); - recipeCorporeaSpark = BotaniaAPI.getLatestAddedRecipe(); - - // Master Corporea Spark Recipe - addShapelessOreDictRecipe(new ItemStack(ModItems.corporeaSpark, 1, 1), new ItemStack(ModItems.corporeaSpark), LibOreDict.DRAGONSTONE); - recipeMasterCorporeaSpark = BotaniaAPI.getLatestAddedRecipe(); - - // Corporea Index Recipe - addOreDictRecipe(new ItemStack(ModBlocks.corporeaIndex), - "AOA", "OSO", "DOD", - 'A', LibOreDict.ENDER_AIR_BOTTLE, - 'O', new ItemStack(Blocks.obsidian), - 'S', new ItemStack(ModItems.corporeaSpark), - 'D', LibOreDict.DRAGONSTONE); - recipeCorporeaIndex = BotaniaAPI.getLatestAddedRecipe(); - - // Corporea Funnel Recipe - addShapelessOreDictRecipe(new ItemStack(ModBlocks.corporeaFunnel), new ItemStack(Blocks.dropper), new ItemStack(ModItems.corporeaSpark)); - recipeCorporeaFunnel = BotaniaAPI.getLatestAddedRecipe(); - - // Corporea Interceptor Recipe - addShapelessOreDictRecipe(new ItemStack(ModBlocks.corporeaInterceptor), "blockRedstone", new ItemStack(ModItems.corporeaSpark)); - recipeCorporeaInterceptor = BotaniaAPI.getLatestAddedRecipe(); - - // End Stone Brick Recipes - if(ConfigHandler.enderStuff19Enabled) { - GameRegistry.addRecipe(new ItemStack(ModBlocks.endStoneBrick, 4), - "SS", "SS", - 'S', new ItemStack(Blocks.end_stone)); - recipeEndStoneBricks = BotaniaAPI.getLatestAddedRecipe(); - - GameRegistry.addRecipe(new ItemStack(ModBlocks.endStoneBrick, 1, 1), - "S", "S", - 'S', new ItemStack(ModFluffBlocks.endStoneSlab)); - recipeEndStoneChiseledBricks = BotaniaAPI.getLatestAddedRecipe(); - - GameRegistry.addRecipe(new ItemStack(ModBlocks.endStoneBrick, 4, 2), - " B ", "BPB", " B ", - 'B', new ItemStack(ModBlocks.endStoneBrick), - 'P', new ItemStack(Items.ender_pearl)); - recipeEnderBricks = BotaniaAPI.getLatestAddedRecipe(); - - GameRegistry.addRecipe(new ItemStack(ModBlocks.endStoneBrick, 2, 3), - "B", "B", - 'B', new ItemStack(ModBlocks.endStoneBrick, 1, 2)); - recipePillarEnderBricks = BotaniaAPI.getLatestAddedRecipe(); - } - - // Livingwood Bow Recipe - addOreDictRecipe(new ItemStack(ModItems.livingwoodBow), - " TS", "T S", " TS", - 'T', LibOreDict.LIVINGWOOD_TWIG, - 'S', LibOreDict.MANA_STRING); - recipeLivingwoodBow = BotaniaAPI.getLatestAddedRecipe(); - - // Crystal Bow Recipe - addOreDictRecipe(new ItemStack(ModItems.crystalBow), - " DS", "T S", " DS", - 'T', LibOreDict.LIVINGWOOD_TWIG, - 'D', LibOreDict.DRAGONSTONE, - 'S', LibOreDict.MANA_STRING); - recipeCrystalBow = BotaniaAPI.getLatestAddedRecipe(); - - // Cosmetic Items Recipes - for(int i = 0; i < 32; i++) - addOreDictRecipe(new ItemStack(ModItems.cosmetic, 1, i), - "PPP", "PSP", "PPP", - 'P', new ItemStack(i < 16 ? ModItems.petal : ModItems.dye, 1, i % 16), - 'S', LibOreDict.MANA_STRING); - recipesCosmeticItems = BotaniaAPI.getLatestAddedRecipes(32); - - // Shimmering Mushroom Recipes - for(int i = 0; i < 16; i++) { - GameRegistry.addShapelessRecipe(new ItemStack(ModBlocks.mushroom, 1, i), new ItemStack(Blocks.red_mushroom), new ItemStack(ModItems.dye, 1, i)); - GameRegistry.addShapelessRecipe(new ItemStack(ModBlocks.mushroom, 1, i), new ItemStack(Blocks.brown_mushroom), new ItemStack(ModItems.dye, 1, i)); - } - recipesMushrooms = BotaniaAPI.getLatestAddedRecipes(32); - GameRegistry.addShapelessRecipe(new ItemStack(Items.mushroom_stew), new ItemStack(ModBlocks.mushroom, 1, Short.MAX_VALUE), new ItemStack(ModBlocks.mushroom, 1, Short.MAX_VALUE), new ItemStack(Items.bowl)); - - // Ring of Correction Recipe - addOreDictRecipe(new ItemStack(ModItems.swapRing), - "CM ", "M M", " M ", - 'C', new ItemStack(Blocks.clay), - 'M', LibOreDict.MANA_STEEL); - recipeSwapRing = BotaniaAPI.getLatestAddedRecipe(); - - // Horn of the Covering Recipe - addShapelessOreDictRecipe(new ItemStack(ModItems.grassHorn, 1, 2), new ItemStack(ModItems.grassHorn), new ItemStack(Items.snowball)); - recipeSnowHorn = BotaniaAPI.getLatestAddedRecipe(); - - // Flower Pouch Recipe - GameRegistry.addShapedRecipe(new ItemStack(ModItems.flowerBag), - "WPW", "W W", " W ", - 'P', new ItemStack(ModItems.petal, 1, Short.MAX_VALUE), - 'W', new ItemStack(Blocks.wool, 1, Short.MAX_VALUE)); - recipeFlowerBag = BotaniaAPI.getLatestAddedRecipe(); - - // Phantom Ink Recipe - addShapelessOreDictRecipe(new ItemStack(ModItems.phantomInk, 4), LibOreDict.MANA_PEARL, "dye", "blockGlass", new ItemStack(Items.glass_bottle), new ItemStack(Items.glass_bottle), new ItemStack(Items.glass_bottle), new ItemStack(Items.glass_bottle)); - recipePhantomInk = BotaniaAPI.getLatestAddedRecipe(); - - // Minecart with Mana Pool Recipe - GameRegistry.addShapelessRecipe(new ItemStack(ModItems.poolMinecart), new ItemStack(Items.minecart), new ItemStack(ModBlocks.pool)); - recipePoolCart = BotaniaAPI.getLatestAddedRecipe(); - - // Mana Pump Recipe - addOreDictRecipe(new ItemStack(ModBlocks.pump), - "SSS", "IBI", "SSS", - 'S', LibOreDict.LIVING_ROCK, - 'I', LibOreDict.MANA_STEEL, - 'B', new ItemStack(Items.bucket)); - recipePump = BotaniaAPI.getLatestAddedRecipe(); - - // Double Petal Recipes - for(int i = 0; i < 16; i++) - addShapelessOreDictRecipe(new ItemStack(ModItems.petal, 4, i), LibOreDict.DOUBLE_FLOWER[i]); - recipesPetalsDouble = BotaniaAPI.getLatestAddedRecipes(16); - - // Resolute Ivy Recipe - addShapelessOreDictRecipe(new ItemStack(ModItems.keepIvy), LibOreDict.PIXIE_DUST, new ItemStack(Blocks.vine), LibOreDict.ENDER_AIR_BOTTLE); - recipeKeepIvy = BotaniaAPI.getLatestAddedRecipe(); - - // Black Hole Talisman Recipe - addOreDictRecipe(new ItemStack(ModItems.blackHoleTalisman), - " G ", "EAE", " E ", - 'G', LibOreDict.LIFE_ESSENCE, - 'E', LibOreDict.ELEMENTIUM, - 'A', LibOreDict.ENDER_AIR_BOTTLE); - recipeBlackHoleTalisman = BotaniaAPI.getLatestAddedRecipe(); - - // 1.8 Stone Recipes - recipe18StonePolish = new ArrayList(); - recipe18StoneBrick = new ArrayList(); - recipe18StoneChisel = new ArrayList(); - for(int i = 0; i < 4; i++) { - addOreDictRecipe(new ItemStack(ModFluffBlocks.stone, 8, i + 4), - "SSS", "S S", "SSS", - 'S', LibOreDict.STONE_18_VARIANTS[i]); - recipe18StonePolish.add(BotaniaAPI.getLatestAddedRecipe()); - - addOreDictRecipe(new ItemStack(ModFluffBlocks.stone, 4, i + 8), - "SS", "SS", - 'S', LibOreDict.STONE_18_VARIANTS[i]); - recipe18StoneBrick.add(BotaniaAPI.getLatestAddedRecipe()); - - addOreDictRecipe(new ItemStack(ModFluffBlocks.stone, 1, i + 12), - "S", "S", - 'S', new ItemStack(ModFluffBlocks.stoneSlabs[i + 4], 1, 0)); - recipe18StoneChisel.add(BotaniaAPI.getLatestAddedRecipe()); - } - - // Blaze Light Recipe - addOreDictRecipe(new ItemStack(ModBlocks.blazeBlock), - "BBB", "BBB", "BBB", - 'B', Botania.gardenOfGlassLoaded ? "powderBlaze" : "rodBlaze"); - recipeBlazeBlock = BotaniaAPI.getLatestAddedRecipe(); - addShapelessOreDictRecipe(new ItemStack(Botania.gardenOfGlassLoaded ? Items.blaze_powder : Items.blaze_rod, 9), LibOreDict.BLAZE_BLOCK); - - // Metamorphic Petal Apothecary Recipes - for(int i = 0; i < 8; i++) - GameRegistry.addRecipe(new ItemStack(ModBlocks.altar, 1, i + 1), - "SSS", "SAS", "SSS", - 'S', new ItemStack(ModFluffBlocks.biomeStoneA, 1, i + 8), - 'A', new ItemStack(ModBlocks.altar)); - recipesAltarMeta = BotaniaAPI.getLatestAddedRecipes(8); - - // Corporea Crystal Cube Recipe - addOreDictRecipe(new ItemStack(ModBlocks.corporeaCrystalCube), - "C", "G", "W", - 'C', new ItemStack(ModItems.corporeaSpark), - 'G', new ItemStack(ModBlocks.elfGlass), - 'W', LibOreDict.DREAM_WOOD); - recipeCorporeaCrystalCube = BotaniaAPI.getLatestAddedRecipe(); - - // Stone of Temperance Recipe - addOreDictRecipe(new ItemStack(ModItems.temperanceStone), - " S ", "SRS", " S ", - 'S', "stone", - 'R', LibOreDict.RUNE[2]); - recipeTemperanceStone = BotaniaAPI.getLatestAddedRecipe(); - - // Incense Stick Recipe - addOreDictRecipe(new ItemStack(ModItems.incenseStick), - " G", " B ", "T ", - 'G', new ItemStack(Items.ghast_tear), - 'B', new ItemStack(Items.blaze_powder), - 'T', LibOreDict.LIVINGWOOD_TWIG); - recipeIncenseStick = BotaniaAPI.getLatestAddedRecipe(); - - // Incense Plate Recipe - addOreDictRecipe(new ItemStack(ModBlocks.incensePlate), - "WSS", - 'W', LibOreDict.LIVING_WOOD, - 'S', new ItemStack(ModFluffBlocks.livingwoodSlab)); - recipeIncensePlate = BotaniaAPI.getLatestAddedRecipe(); - - // Terra Truncator Recipe - addOreDictRecipe(new ItemStack(ModItems.terraAxe), - "TTG", "TST", " S ", - 'T', LibOreDict.TERRA_STEEL, - 'G', "glowstone", - 'S', LibOreDict.LIVINGWOOD_TWIG); - recipeTerraAxe = BotaniaAPI.getLatestAddedRecipe(); - - // Hovering Hourglass Recipe - addOreDictRecipe(new ItemStack(ModBlocks.hourglass), - "GMG", "RSR", "GMG", - 'G', "ingotGold", - 'M', new ItemStack(ModBlocks.manaGlass), - 'R', "dustRedstone", - 'S', LibOreDict.MANA_STEEL); - recipeHourglass = BotaniaAPI.getLatestAddedRecipe(); - - // Spectral Rail Recipe - GameRegistry.addShapelessRecipe(new ItemStack(ModBlocks.ghostRail), new ItemStack(Blocks.rail), new ItemStack(ModBlocks.platform, 1, 1)); - recipeGhostRail = BotaniaAPI.getLatestAddedRecipe(); - - // Drum of the Canopy Recipe - addOreDictRecipe(new ItemStack(ModBlocks.forestDrum, 1, 2), - "WLW", "WHW", "WLW", - 'W', LibOreDict.LIVING_WOOD, - 'L', new ItemStack(Items.leather), - 'H', new ItemStack(ModItems.grassHorn, 1, 1)); - recipeCanopyDrum = BotaniaAPI.getLatestAddedRecipe(); - - // Spark Changer Recipe - addOreDictRecipe(new ItemStack(ModBlocks.sparkChanger), - "ESE", "SRS", - 'S', LibOreDict.LIVING_ROCK, - 'E', LibOreDict.ELEMENTIUM, - 'R', "dustRedstone"); - recipeSparkChanger = BotaniaAPI.getLatestAddedRecipe(); - - // Cocoon of Caprice Recipe - if(Botania.gardenOfGlassLoaded) - addOreDictRecipe(new ItemStack(ModBlocks.cocoon), - "SSS", "SFS", "SIS", - 'S', new ItemStack(Items.string), - 'F', new ItemStack(ModBlocks.felPumpkin), - 'I', LibOreDict.MANA_STEEL); - else addOreDictRecipe(new ItemStack(ModBlocks.cocoon), - "SSS", "SPS", "SDS", - 'S', new ItemStack(Items.string), - 'P', LibOreDict.PIXIE_DUST, - 'D', LibOreDict.DRAGONSTONE); - recipeCocoon = BotaniaAPI.getLatestAddedRecipe(); - - // Fel Pumpkin - GameRegistry.addRecipe(new ItemStack(ModBlocks.felPumpkin), - " S ", "BPF", " G ", - 'S', new ItemStack(Items.string), - 'B', new ItemStack(Items.bone), - 'P', new ItemStack(Blocks.pumpkin), - 'F', new ItemStack(Items.rotten_flesh), - 'G', new ItemStack(Items.gunpowder)); - recipeFelPumpkin = BotaniaAPI.getLatestAddedRecipe(); - - // Luminizer Recipe - addShapelessOreDictRecipe(new ItemStack(ModBlocks.lightRelay), LibOreDict.RED_STRING, LibOreDict.DRAGONSTONE, "dustGlowstone", "dustGlowstone"); - recipeLuminizer = BotaniaAPI.getLatestAddedRecipe(); - - // Detector Luminizer Recipe - addShapelessOreDictRecipe(new ItemStack(ModBlocks.lightRelay, 1, 1), new ItemStack(ModBlocks.lightRelay), "dustRedstone"); - recipeDetectorLuminizer = BotaniaAPI.getLatestAddedRecipe(); - - // Luminizer Launcher Recipe - addOreDictRecipe(new ItemStack(ModBlocks.lightLauncher), - "DDD", "DLD", - 'D', LibOreDict.DREAM_WOOD, - 'L', new ItemStack(ModBlocks.lightRelay)); - recipeLuminizerLauncher = BotaniaAPI.getLatestAddedRecipe(); - - // Floral Obedience Stick Recipe - addOreDictRecipe(new ItemStack(ModItems.obedienceStick), - " M", " T ", "T ", - 'M', LibOreDict.MANA_STEEL, - 'T', LibOreDict.LIVINGWOOD_TWIG); - recipeObedienceStick = BotaniaAPI.getLatestAddedRecipe(); - - // Cacophonium Recipe - if(OreDictionary.getOres("ingotBrass").isEmpty()) - addOreDictRecipe(new ItemStack(ModItems.cacophonium), - " G ", "GNG", "GG ", - 'G', "ingotGold", - 'N', new ItemStack(Blocks.noteblock)); - else addOreDictRecipe(new ItemStack(ModItems.cacophonium), - " G ", "GNG", "GG ", - 'G', "ingotBrass", - 'N', new ItemStack(Blocks.noteblock)); - recipeCacophonium = BotaniaAPI.getLatestAddedRecipe(); - - // Manastorm Charge Recipe - addOreDictRecipe(new ItemStack(ModBlocks.manaBomb), - "LTL", "TGT", "LTL", - 'L', LibOreDict.LIVING_WOOD, - 'T', new ItemStack(Blocks.tnt), - 'G', LibOreDict.LIFE_ESSENCE); - recipeManaBomb = BotaniaAPI.getLatestAddedRecipe(); - - // Cobweb Recipe - addOreDictRecipe(new ItemStack(Blocks.web), - "S S", " M ", "S S", - 'S', new ItemStack(Items.string), - 'M', LibOreDict.MANA_STRING); - recipeCobweb = BotaniaAPI.getLatestAddedRecipe(); - - // Slime in a Bottle Recipe - addOreDictRecipe(new ItemStack(ModItems.slimeBottle), - "EGE", "ESE", " E ", - 'E', LibOreDict.ELEMENTIUM, - 'G', new ItemStack(ModBlocks.elfGlass), - 'S', "slimeball"); - recipeSlimeBottle = BotaniaAPI.getLatestAddedRecipe(); - - // Starcaller Recipe - addOreDictRecipe(new ItemStack(ModItems.starSword), - " I", "AD ", "TA ", - 'I', LibOreDict.ELEMENTIUM, - 'D', LibOreDict.DRAGONSTONE, - 'A', LibOreDict.ENDER_AIR_BOTTLE, - 'T', new ItemStack(ModItems.terraSword)); - recipeStarSword = BotaniaAPI.getLatestAddedRecipe(); - - // Rod of the Shifting Crust Recipe - addOreDictRecipe(new ItemStack(ModItems.exchangeRod), - " SR", " TS", "T ", - 'T', LibOreDict.LIVINGWOOD_TWIG, - 'S', "stone", - 'R', LibOreDict.RUNE[12]); - recipeExchangeRod = BotaniaAPI.getLatestAddedRecipe(); - - // Greater Ring of Magnetization Recipe - addShapelessOreDictRecipe(new ItemStack(ModItems.magnetRingGreater), LibOreDict.TERRA_STEEL, new ItemStack(ModItems.magnetRing)); - recipeGreaterMagnetRing = BotaniaAPI.getLatestAddedRecipe(); - - // Flare Chakram Recipe - addOreDictRecipe(new ItemStack(ModItems.thornChakram, 2, 1), - "BBB", "CPC", "BBB", - 'B', new ItemStack(Items.blaze_powder), - 'P', LibOreDict.PIXIE_DUST, - 'C', new ItemStack(ModItems.thornChakram)); - recipeFireChakram = BotaniaAPI.getLatestAddedRecipe(); - - // Thundercaller Recipe - addOreDictRecipe(new ItemStack(ModItems.thunderSword), - " I", "AD ", "TA ", - 'I', LibOreDict.ELEMENTIUM, - 'D', LibOreDict.MANA_DIAMOND, - 'A', LibOreDict.ENDER_AIR_BOTTLE, - 'T', new ItemStack(ModItems.terraSword)); - recipeThunderSword = BotaniaAPI.getLatestAddedRecipe(); - - // Manatide Bellows Recipe - addOreDictRecipe(new ItemStack(ModBlocks.bellows), - "SSS", "RL ", "SSS", - 'S', new ItemStack(ModFluffBlocks.livingwoodSlab), - 'R', LibOreDict.RUNE[3], - 'L', new ItemStack(Items.leather)); - recipeBellows = BotaniaAPI.getLatestAddedRecipe(); - - // Manaweave Cloth Recipe - addOreDictRecipe(new ItemStack(ModItems.manaResource, 1, 22), - "SS", "SS", - 'S', LibOreDict.MANA_STRING); - recipeManaweaveCloth = BotaniaAPI.getLatestAddedRecipe(); - - // Manaweave Armor Recipes - addOreDictRecipe(new ItemStack(ModItems.manaweaveHelm), - "SSS", "S S", - 'S', LibOreDict.MANAWEAVE_CLOTH); - recipeManaweaveHelm = BotaniaAPI.getLatestAddedRecipe(); - addOreDictRecipe(new ItemStack(ModItems.manaweaveChest), - "S S", "SSS", "SSS", - 'S', LibOreDict.MANAWEAVE_CLOTH); - recipeManaweaveChest = BotaniaAPI.getLatestAddedRecipe(); - addOreDictRecipe(new ItemStack(ModItems.manaweaveLegs), - "SSS", "S S", "S S", - 'S', LibOreDict.MANAWEAVE_CLOTH); - recipeManaweaveLegs = BotaniaAPI.getLatestAddedRecipe(); - addOreDictRecipe(new ItemStack(ModItems.manaweaveBoots), - "S S", "S S", - 'S', LibOreDict.MANAWEAVE_CLOTH); - recipeManaweaveBoots = BotaniaAPI.getLatestAddedRecipe(); - - // Bifrost Blocks Recipe - addShapelessOreDictRecipe(new ItemStack(ModBlocks.bifrostPerm), new ItemStack(ModItems.rainbowRod), new ItemStack(ModBlocks.elfGlass)); - recipeBifrost = BotaniaAPI.getLatestAddedRecipe(); - addShapelessOreDictRecipe(new ItemStack(ModBlocks.shimmerrock), LibOreDict.LIVING_ROCK, new ItemStack(ModBlocks.bifrostPerm)); - recipeShimmerrock = BotaniaAPI.getLatestAddedRecipe(); - addShapelessOreDictRecipe(new ItemStack(ModBlocks.shimmerwoodPlanks), new ItemStack(ModBlocks.dreamwood, 1, 1), new ItemStack(ModBlocks.bifrostPerm)); - recipeShimmerwoodPlanks = BotaniaAPI.getLatestAddedRecipe(); - - // Manufactory Halo Recipe - addShapelessOreDictRecipe(new ItemStack(ModItems.autocraftingHalo), new ItemStack(ModItems.craftingHalo), LibOreDict.MANA_DIAMOND); - recipeAutocraftingHalo = BotaniaAPI.getLatestAddedRecipe(); - - // Pavement Recipes - addShapelessOreDictRecipe(new ItemStack(ModFluffBlocks.pavement, 3, 0), LibOreDict.LIVING_ROCK, "cobblestone", "gravel"); - addShapelessOreDictRecipe(new ItemStack(ModFluffBlocks.pavement, 3, 1), LibOreDict.LIVING_ROCK, "cobblestone", "gravel", new ItemStack(Items.coal)); - addShapelessOreDictRecipe(new ItemStack(ModFluffBlocks.pavement, 3, 2), LibOreDict.LIVING_ROCK, "cobblestone", "gravel", new ItemStack(Items.dye, 1, 4)); - addShapelessOreDictRecipe(new ItemStack(ModFluffBlocks.pavement, 3, 3), LibOreDict.LIVING_ROCK, "cobblestone", "gravel", new ItemStack(Items.redstone)); - addShapelessOreDictRecipe(new ItemStack(ModFluffBlocks.pavement, 3, 4), LibOreDict.LIVING_ROCK, "cobblestone", "gravel", new ItemStack(Items.wheat)); - addShapelessOreDictRecipe(new ItemStack(ModFluffBlocks.pavement, 3, 5), LibOreDict.LIVING_ROCK, "cobblestone", "gravel", new ItemStack(Items.slime_ball)); - recipesPavement = BotaniaAPI.getLatestAddedRecipes(6); - - // Cellular Block Recipe - GameRegistry.addShapelessRecipe(new ItemStack(ModBlocks.cellBlock, 3), new ItemStack(Blocks.cactus), new ItemStack(Blocks.cactus), new ItemStack(Blocks.cactus), new ItemStack(Blocks.cactus), new ItemStack(Items.carrot), new ItemStack(Items.potato)); - recipeCellBlock = BotaniaAPI.getLatestAddedRecipe(); - - // Corporea Retainer Recipe - addShapelessOreDictRecipe(new ItemStack(ModBlocks.corporeaRetainer), new ItemStack(Blocks.chest), new ItemStack(ModItems.corporeaSpark)); - recipeCorporeaRetainer = BotaniaAPI.getLatestAddedRecipe(); - - // Teru Teru Bozu Recipe - addOreDictRecipe(new ItemStack(ModBlocks.teruTeruBozu), - "C", "C", "S", - 'C', LibOreDict.MANAWEAVE_CLOTH, - 'S', new ItemStack(Blocks.double_plant)); - recipeTeruTeruBozu = BotaniaAPI.getLatestAddedRecipe(); - - // Livingwood Avatar Recipe - addOreDictRecipe(new ItemStack(ModBlocks.avatar), - " W ", "WDW", "W W", - 'W', LibOreDict.LIVING_WOOD, - 'D', LibOreDict.MANA_DIAMOND); - recipeAvatar = BotaniaAPI.getLatestAddedRecipe(); - - // Worldshaper's Sextant Recipe - addOreDictRecipe(new ItemStack(ModItems.sextant), - " TI", " TT", "III", - 'T', LibOreDict.LIVINGWOOD_TWIG, - 'I', LibOreDict.MANA_STEEL); - recipeSextant = BotaniaAPI.getLatestAddedRecipe(); - - // Alternate Pasture Seed Recipes - GameRegistry.addShapelessRecipe(new ItemStack(ModItems.grassSeeds, 1, 3), new ItemStack(ModItems.grassSeeds), new ItemStack(Blocks.deadbush)); - GameRegistry.addShapelessRecipe(new ItemStack(ModItems.grassSeeds, 1, 4), new ItemStack(ModItems.grassSeeds), new ItemStack(Items.wheat)); - GameRegistry.addShapelessRecipe(new ItemStack(ModItems.grassSeeds, 1, 5), new ItemStack(ModItems.grassSeeds), new ItemStack(Items.dye, 1, 2)); - GameRegistry.addShapelessRecipe(new ItemStack(ModItems.grassSeeds, 1, 6), new ItemStack(ModItems.grassSeeds), new ItemStack(Items.blaze_powder)); - GameRegistry.addShapelessRecipe(new ItemStack(ModItems.grassSeeds, 1, 7), new ItemStack(ModItems.grassSeeds), new ItemStack(ModItems.manaResource, 1, 10)); - GameRegistry.addShapelessRecipe(new ItemStack(ModItems.grassSeeds, 1, 8), new ItemStack(ModItems.grassSeeds), new ItemStack(Items.spider_eye)); - recipesAltGrassSeeds = BotaniaAPI.getLatestAddedRecipes(6); - - // Planestrider's Sash Recipe - GameRegistry.addRecipe(new ItemStack(ModItems.speedUpBelt), - " M ", "PBP", " S ", - 'M', new ItemStack(Items.filled_map, 1, Short.MAX_VALUE), - 'P', new ItemStack(ModItems.grassSeeds), - 'B', new ItemStack(ModItems.travelBelt), - 'S', new ItemStack(Items.sugar)); - recipeSpeedUpBelt = BotaniaAPI.getLatestAddedRecipe(); - - // Bauble Case Recipe - addOreDictRecipe(new ItemStack(ModItems.baubleBox), - " M ", "MCG", " M ", - 'M', LibOreDict.MANA_STEEL, - 'C', new ItemStack(Blocks.chest), - 'G', "ingotGold"); - recipeBaubleCase = BotaniaAPI.getLatestAddedRecipe(); - - /////////////////////////////////////////////////////////////////////////////////////////////////////////// - - // Storage Block/Nugget Recipes - addOreDictRecipe(new ItemStack(ModBlocks.storage, 1, 0), - "III", "III", "III", - 'I', LibOreDict.MANA_STEEL); - addOreDictRecipe(new ItemStack(ModBlocks.storage, 1, 1), - "III", "III", "III", - 'I', LibOreDict.TERRA_STEEL); - addOreDictRecipe(new ItemStack(ModBlocks.storage, 1, 2), - "III", "III", "III", - 'I', LibOreDict.ELEMENTIUM); - addOreDictRecipe(new ItemStack(ModBlocks.storage, 1, 3), - "III", "III", "III", - 'I', LibOreDict.MANA_DIAMOND); - addOreDictRecipe(new ItemStack(ModBlocks.storage, 1, 4), - "III", "III", "III", - 'I', LibOreDict.DRAGONSTONE); - GameRegistry.addShapelessRecipe(new ItemStack(ModItems.manaResource, 9, 0), new ItemStack(ModBlocks.storage, 1, 0)); - GameRegistry.addShapelessRecipe(new ItemStack(ModItems.manaResource, 9, 4), new ItemStack(ModBlocks.storage, 1, 1)); - GameRegistry.addShapelessRecipe(new ItemStack(ModItems.manaResource, 9, 7), new ItemStack(ModBlocks.storage, 1, 2)); - GameRegistry.addShapelessRecipe(new ItemStack(ModItems.manaResource, 9, 2), new ItemStack(ModBlocks.storage, 1, 3)); - GameRegistry.addShapelessRecipe(new ItemStack(ModItems.manaResource, 9, 9), new ItemStack(ModBlocks.storage, 1, 4)); - - addOreDictRecipe(new ItemStack(ModItems.manaResource, 1, 0), - "III", "III", "III", - 'I', LibOreDict.MANASTEEL_NUGGET); - addOreDictRecipe(new ItemStack(ModItems.manaResource, 1, 4), - "III", "III", "III", - 'I', LibOreDict.TERRASTEEL_NUGGET); - addOreDictRecipe(new ItemStack(ModItems.manaResource, 1, 7), - "III", "III", "III", - 'I', LibOreDict.ELEMENTIUM_NUGGET); - addShapelessOreDictRecipe(new ItemStack(ModItems.manaResource, 9, 17), LibOreDict.MANA_STEEL); - addShapelessOreDictRecipe(new ItemStack(ModItems.manaResource, 9, 18), LibOreDict.TERRA_STEEL); - addShapelessOreDictRecipe(new ItemStack(ModItems.manaResource, 9, 19), LibOreDict.ELEMENTIUM); - - // Revealing Helmet Recipes - if(Botania.thaumcraftLoaded) { - Item goggles = (Item) Item.itemRegistry.getObject("Thaumcraft:ItemGoggles"); - GameRegistry.addShapelessRecipe(new ItemStack(ModItems.manasteelHelmRevealing), new ItemStack(ModItems.manasteelHelm), goggles); - recipeHelmetOfRevealing = BotaniaAPI.getLatestAddedRecipe(); //We want manasteel to show in the Lexicon - GameRegistry.addShapelessRecipe(new ItemStack(ModItems.terrasteelHelmRevealing), new ItemStack(ModItems.terrasteelHelm), goggles); - GameRegistry.addShapelessRecipe(new ItemStack(ModItems.elementiumHelmRevealing), new ItemStack(ModItems.elementiumHelm), goggles); - } - - // Slab & Stair Recipes - addStairsAndSlabs(ModBlocks.livingwood, 0, ModFluffBlocks.livingwoodStairs, ModFluffBlocks.livingwoodSlab); - addStairsAndSlabs(ModBlocks.livingwood, 1, ModFluffBlocks.livingwoodPlankStairs, ModFluffBlocks.livingwoodPlankSlab); - addStairsAndSlabs(ModBlocks.livingrock, 0, ModFluffBlocks.livingrockStairs, ModFluffBlocks.livingrockSlab); - addStairsAndSlabs(ModBlocks.livingrock, 1, ModFluffBlocks.livingrockBrickStairs, ModFluffBlocks.livingrockBrickSlab); - addStairsAndSlabs(ModBlocks.dreamwood, 0, ModFluffBlocks.dreamwoodStairs, ModFluffBlocks.dreamwoodSlab); - addStairsAndSlabs(ModBlocks.dreamwood, 1, ModFluffBlocks.dreamwoodPlankStairs, ModFluffBlocks.dreamwoodPlankSlab); - addStairsAndSlabs(ModBlocks.prismarine, 0, ModFluffBlocks.prismarineStairs, ModFluffBlocks.prismarineSlab); - addStairsAndSlabs(ModBlocks.prismarine, 1, ModFluffBlocks.prismarineBrickStairs, ModFluffBlocks.prismarineBrickSlab); - addStairsAndSlabs(ModBlocks.prismarine, 2, ModFluffBlocks.darkPrismarineStairs, ModFluffBlocks.darkPrismarineSlab); - addStairsAndSlabs(ModBlocks.reedBlock, 0, ModFluffBlocks.reedStairs, ModFluffBlocks.reedSlab); - addStairsAndSlabs(ModBlocks.thatch, 0, ModFluffBlocks.thatchStairs, ModFluffBlocks.thatchSlab); - addStairsAndSlabs(ModBlocks.customBrick, 0, ModFluffBlocks.netherBrickStairs, ModFluffBlocks.netherBrickSlab); - addStairsAndSlabs(ModBlocks.customBrick, 1, ModFluffBlocks.soulBrickStairs, ModFluffBlocks.soulBrickSlab); - addStairsAndSlabs(ModBlocks.customBrick, 2, ModFluffBlocks.snowBrickStairs, ModFluffBlocks.snowBrickSlab); - addStairsAndSlabs(ModBlocks.customBrick, 3, ModFluffBlocks.tileStairs, ModFluffBlocks.tileSlab); - addStairsAndSlabs(ModBlocks.endStoneBrick, 0, ModFluffBlocks.endStoneStairs, ModFluffBlocks.endStoneSlab); - addStairsAndSlabs(ModBlocks.shimmerrock, 0, ModFluffBlocks.shimmerrockStairs, ModFluffBlocks.shimmerrockSlab); - addStairsAndSlabs(ModBlocks.shimmerwoodPlanks, 0, ModFluffBlocks.shimmerwoodPlankStairs, ModFluffBlocks.shimmerwoodPlankSlab); - - // Wall Recipes - addWall(ModBlocks.livingrock, 0, ModFluffBlocks.livingrockWall, 0); - addWall(ModBlocks.livingwood, 0, ModFluffBlocks.livingwoodWall, 0); - addWall(ModBlocks.dreamwood, 0, ModFluffBlocks.dreamwoodWall, 0); - addWall(ModBlocks.prismarine, 0, ModFluffBlocks.prismarineWall, 0); - addWall(ModBlocks.reedBlock, 0, ModFluffBlocks.reedWall, 0); - for(int i = 0; i < 8; i++) - addWall(ModFluffBlocks.biomeStoneA, i + 8, ModFluffBlocks.biomeStoneWall, i); - for(int i = 0; i < 4; i++) - addWall(ModFluffBlocks.stone, i, ModFluffBlocks.stoneWall, i); - - // Pane Recipes - addPane(ModBlocks.manaGlass, ModFluffBlocks.managlassPane); - addPane(ModBlocks.elfGlass, ModFluffBlocks.alfglassPane); - addPane(ModBlocks.bifrostPerm, ModFluffBlocks.bifrostPane); - - // Biome Stone Recipes - for(int i = 0; i < 8; i++) { - GameRegistry.addSmelting(new ItemStack(ModFluffBlocks.biomeStoneA, 1, i + 8), new ItemStack(ModFluffBlocks.biomeStoneA, 1, i), 0.1F); - GameRegistry.addRecipe(new ItemStack(ModFluffBlocks.biomeStoneB, 4, i), "SS", "SS", 'S', new ItemStack(ModFluffBlocks.biomeStoneA, 1, i)); - GameRegistry.addRecipe(new ItemStack(ModFluffBlocks.biomeStoneB, 1, i + 8), "S", "S", 'S', new ItemStack(ModFluffBlocks.biomeStoneSlabs[i + 16])); - addStairsAndSlabs(ModFluffBlocks.biomeStoneA, i, ModFluffBlocks.biomeStoneStairs[i], ModFluffBlocks.biomeStoneSlabs[i]); - addStairsAndSlabs(ModFluffBlocks.biomeStoneA, i + 8, ModFluffBlocks.biomeStoneStairs[i + 8], ModFluffBlocks.biomeStoneSlabs[i + 8]); - addStairsAndSlabs(ModFluffBlocks.biomeStoneB, i, ModFluffBlocks.biomeStoneStairs[i + 16], ModFluffBlocks.biomeStoneSlabs[i + 16]); - } - - // 1.8 Block Stone Stairs & Slabs - for(int i = 0; i < 4; i++) { - addOreDictRecipe(new ItemStack(ModFluffBlocks.stoneSlabs[i], 6), - "QQQ", - 'Q', LibOreDict.STONE_18_VARIANTS[i]); - addOreDictRecipe(new ItemStack(ModFluffBlocks.stoneStairs[i], 4), - " Q", " QQ", "QQQ", - 'Q', LibOreDict.STONE_18_VARIANTS[i]); - addOreDictRecipe(new ItemStack(ModFluffBlocks.stoneStairs[i], 4), - "Q ", "QQ ", "QQQ", - 'Q', LibOreDict.STONE_18_VARIANTS[i]); - addOreDictRecipe(new ItemStack(ModFluffBlocks.stone, 1, i), - "Q", "Q", - 'Q', new ItemStack(ModFluffBlocks.stoneSlabs[i])); - - addOreDictRecipe(new ItemStack(ModFluffBlocks.stoneSlabs[i + 4], 6), - "QQQ", - 'Q', LibOreDict.STONE_18_VARIANTS[i + 8]); - addOreDictRecipe(new ItemStack(ModFluffBlocks.stoneStairs[i + 4], 4), - " Q", " QQ", "QQQ", - 'Q', LibOreDict.STONE_18_VARIANTS[i + 8]); - addOreDictRecipe(new ItemStack(ModFluffBlocks.stoneStairs[i + 4], 4), - "Q ", "QQ ", "QQQ", - 'Q', LibOreDict.STONE_18_VARIANTS[i + 8]); - addOreDictRecipe(new ItemStack(ModFluffBlocks.stone, 1, i + 8), //VERY VERY - "Q", "Q", //BIG BIG - 'Q', new ItemStack(ModFluffBlocks.stoneSlabs[i + 4])); //PROBLEM PROBLEM - } - - // Pavement Stairsm & Stairs - for(int i = 0; i < ModFluffBlocks.pavementStairs.length; i++) - addStairsAndSlabs(ModFluffBlocks.pavement, i, ModFluffBlocks.pavementStairs[i], ModFluffBlocks.pavementSlabs[i]); - - // Misc Recipes - GameRegistry.addShapelessRecipe(new ItemStack(Items.reeds, 9, 0), new ItemStack(ModBlocks.reedBlock)); - GameRegistry.addShapelessRecipe(new ItemStack(Items.wheat, 4, 0), new ItemStack(ModBlocks.thatch)); - - if(Botania.gardenOfGlassLoaded) - initGardenOfGlass(); - - int newRecipeListSize = CraftingManager.getInstance().getRecipeList().size(); - FMLLog.log(Level.INFO, "[Botania] Registered %d recipes.", newRecipeListSize - recipeListSize); - } - - private static void initGardenOfGlass() { - // Root to Sapling - addShapelessOreDictRecipe(new ItemStack(Blocks.sapling), LibOreDict.ROOT, LibOreDict.ROOT, LibOreDict.ROOT, LibOreDict.ROOT); - recipeRootToSapling = BotaniaAPI.getLatestAddedRecipe(); - - // Root to Fertilizer - addShapelessOreDictRecipe(new ItemStack(ModItems.fertilizer), LibOreDict.ROOT); - recipeRootToFertilizer = BotaniaAPI.getLatestAddedRecipe(); - - // Pebble to Cobble - addShapelessOreDictRecipe(new ItemStack(Blocks.cobblestone), LibOreDict.PEBBLE, LibOreDict.PEBBLE, LibOreDict.PEBBLE, LibOreDict.PEBBLE); - recipePebbleCobblestone = BotaniaAPI.getLatestAddedRecipe(); - - // Magma Pearl to Slimeball - addShapelessOreDictRecipe(new ItemStack(Items.slime_ball), new ItemStack(Items.magma_cream), new ItemStack(Items.water_bucket)); - recipeMagmaToSlimeball = BotaniaAPI.getLatestAddedRecipe(); - - // Ender Portal - addOreDictRecipe(new ItemStack(Blocks.end_portal_frame), - "OGO", - 'O', new ItemStack(Blocks.obsidian), - 'G', LibOreDict.LIFE_ESSENCE); - recipeEndPortal = BotaniaAPI.getLatestAddedRecipe(); - } - - private static void addStairsAndSlabs(Block block, int meta, Block stairs, Block slab) { - GameRegistry.addRecipe(new ItemStack(slab, 6), - "QQQ", - 'Q', new ItemStack(block, 1, meta)); - GameRegistry.addRecipe(new ItemStack(stairs, 4), - " Q", " QQ", "QQQ", - 'Q', new ItemStack(block, 1, meta)); - GameRegistry.addRecipe(new ItemStack(stairs, 4), - "Q ", "QQ ", "QQQ", - 'Q', new ItemStack(block, 1, meta)); - GameRegistry.addRecipe(new ItemStack(block, 1, meta), - "Q", "Q", - 'Q', new ItemStack(slab)); - } - - private static void addWall(Block block, int blockMeta, Block wall, int wallMeta) { - GameRegistry.addRecipe(new ItemStack(wall, 6, wallMeta), - "BBB", "BBB", - 'B', new ItemStack(block, 1, blockMeta)); - } - - private static void addPane(Block block, Block pane) { - GameRegistry.addRecipe(new ItemStack(pane, 16), - "BBB", "BBB", - 'B', new ItemStack(block, 1)); - } - - private static IRecipe addQuartzRecipes(int meta, Item req, Block block, Block stairs, Block slab) { - GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(block), - "QQ", "QQ", - 'Q', LibOreDict.QUARTZ[meta])); - GameRegistry.addRecipe(new ItemStack(block, 2, 2), - "Q", "Q", - 'Q', block); - GameRegistry.addRecipe(new ItemStack(block, 1, 1), - "Q", "Q", - 'Q', slab); - addStairsAndSlabs(block, 0, stairs, slab); - - if(req != null) { - if(req == Items.coal) - GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(ModItems.quartz, 8, meta), - "QQQ", "QCQ", "QQQ", - 'Q', "gemQuartz", - 'C', new ItemStack(req, 1, 1))); - GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(ModItems.quartz, 8, meta), - "QQQ", "QCQ", "QQQ", - 'Q', "gemQuartz", - 'C', req)); - return BotaniaAPI.getLatestAddedRecipe(); - } - return null; - } - - private static void addOreDictRecipe(ItemStack output, Object... recipe) { - CraftingManager.getInstance().getRecipeList().add(new ShapedOreRecipe(output, recipe)); - } - - private static void addShapelessOreDictRecipe(ItemStack output, Object... recipe) { - CraftingManager.getInstance().getRecipeList().add(new ShapelessOreRecipe(output, recipe)); - } + public static IRecipe recipeLexicon; + public static List recipesPetals; + public static List recipesDyes; + public static List recipesPetalBlocks; + public static IRecipe recipePestleAndMortar; + public static List recipesTwigWand; + public static List recipesApothecary; + public static List recipesSpreader; + public static List recipesManaLens; + public static IRecipe recipePool; + public static IRecipe recipePoolDiluted; + public static IRecipe recipePoolFabulous; + public static List recipesRuneAltar; + public static IRecipe recipeLensVelocity; + public static IRecipe recipeLensPotency; + public static IRecipe recipeLensResistance; + public static IRecipe recipeLensEfficiency; + public static IRecipe recipeLensBounce; + public static IRecipe recipeLensGravity; + public static IRecipe recipeLensBore; + public static IRecipe recipeLensDamaging; + public static IRecipe recipeLensPhantom; + public static IRecipe recipeLensMagnet; + public static IRecipe recipeLensExplosive; + public static List recipesUnstableBlocks; + public static IRecipe recipePylon; + public static IRecipe recipeDistributor; + public static IRecipe recipeLivingrockDecor1; + public static IRecipe recipeLivingrockDecor2; + public static IRecipe recipeLivingrockDecor3; + public static IRecipe recipeLivingrockDecor4; + public static IRecipe recipeLivingwoodDecor1; + public static IRecipe recipeLivingwoodDecor2; + public static IRecipe recipeLivingwoodDecor3; + public static IRecipe recipeLivingwoodDecor4; + public static IRecipe recipeLivingwoodDecor5; + public static List recipesManaBeacons; + public static List recipesSignalFlares; + public static IRecipe recipeManaVoid; + public static List recipesManaTablet; + public static IRecipe recipeManaDetector; + public static IRecipe recipeManaBlaster; + public static IRecipe recipeTurntable; + public static IRecipe recipeFertilizerPowder; + public static IRecipe recipeFerilizerDye; + public static IRecipe recipeLivingwoodTwig; + public static IRecipe recipeDirtRod; + public static IRecipe recipeTerraformRod; + public static IRecipe recipeRedstoneSpreader; + public static IRecipe recipeManaMirror; + public static IRecipe recipeManasteelHelm; + public static IRecipe recipeManasteelChest; + public static IRecipe recipeManasteelLegs; + public static IRecipe recipeManasteelBoots; + public static IRecipe recipeManasteelPick; + public static IRecipe recipeManasteelShovel; + public static IRecipe recipeManasteelAxe; + public static IRecipe recipeManasteelShears; + public static IRecipe recipeManasteelSword; + public static IRecipe recipeGrassHorn; + public static IRecipe recipeTerrasteelHelm; + public static IRecipe recipeTerrasteelChest; + public static IRecipe recipeTerrasteelLegs; + public static IRecipe recipeTerrasteelBoots; + public static IRecipe recipeTerraSword; + public static IRecipe recipeTinyPlanet; + public static IRecipe recipeManaRing; + public static IRecipe recipeAuraRing; + public static IRecipe recipeGreaterManaRing; + public static IRecipe recipeGreaterAuraRing; + public static IRecipe recipeTravelBelt; + public static IRecipe recipeKnocbackBelt; + public static IRecipe recipeIcePendant; + public static IRecipe recipeFirePendant; + public static IRecipe recipeGoldenLaurel; + public static IRecipe recipeTinyPlanetBlock; + public static IRecipe recipeAlchemyCatalyst; + public static IRecipe recipeOpenCrate; + public static IRecipe recipeForestEye; + public static IRecipe recipeRedstoneRoot; + public static IRecipe recipeForestDrum; + public static IRecipe recipeWaterRing; + public static IRecipe recipeMiningRing; + public static IRecipe recipeMagnetRing; + public static IRecipe recipeTerraPick; + public static IRecipe recipeDivaCharm; + public static IRecipe recipeFlightTiara; + public static List recipesShinyFlowers; + public static IRecipe recipePlatform; + public static IRecipe recipeEnderDagger; + public static IRecipe recipeDarkQuartz; + public static IRecipe recipeBlazeQuartz; + public static List recipesLavenderQuartz; + public static IRecipe recipeRedQuartz; + public static IRecipe recipeSunnyQuartz; + public static IRecipe recipeAlfPortal; + public static IRecipe recipeNaturaPylon; + public static IRecipe recipeWaterRod; + public static IRecipe recipeElementiumHelm; + public static IRecipe recipeElementiumChest; + public static IRecipe recipeElementiumLegs; + public static IRecipe recipeElementiumBoots; + public static IRecipe recipeElementiumPick; + public static IRecipe recipeElementiumShovel; + public static IRecipe recipeElementiumAxe; + public static IRecipe recipeElementiumShears; + public static IRecipe recipeElementiumSword; + public static IRecipe recipeOpenBucket; + public static IRecipe recipeConjurationCatalyst; + public static IRecipe recipeSpawnerMover; + public static IRecipe recipePixieRing; + public static IRecipe recipeSuperTravelBelt; + public static IRecipe recipeRainbowRod; + public static IRecipe recipeSpectralPlatform; + public static List recipesDreamwoodSpreader; + public static IRecipe recipeTornadoRod; + public static IRecipe recipeFireRod; + public static IRecipe recipeVineBall; + public static IRecipe recipeSlingshot; + public static IRecipe recipeMossStone; + public static IRecipe recipePrismarine; + public static IRecipe recipePrismarineBrick; + public static IRecipe recipeDarkPrismarine; + public static IRecipe recipeSeaLamp; + public static IRecipe recipeLensInfluence; + public static IRecipe recipeLensWeight; + public static IRecipe recipeLensPaint; + public static IRecipe recipeLensWarp; + public static IRecipe recipeLensRedirect; + public static IRecipe recipeLensFirework; + public static IRecipe recipeLensFlare; + public static List recipesMiniIsland; + public static IRecipe recipeGaiaPylon; + public static IRecipe recipeGatherDrum; + public static IRecipe recipeLensFire; + public static IRecipe recipeLensPiston; + public static List recipesLaputaShard; + public static List recipesLaputaShardUpgrade; + public static IRecipe recipeVirusZombie; + public static IRecipe recipeVirusSkeleton; + public static IRecipe recipeReachRing; + public static IRecipe recipeSkyDirtRod; + public static IRecipe recipeSpawnerClaw; + public static IRecipe recipeCraftCrate; + public static IRecipe recipePlaceholder; + public static IRecipe recipeReedBlock; + public static IRecipe recipeThatch; + public static IRecipe recipeNetherBrick; + public static IRecipe recipeSoulBrick; + public static IRecipe recipeSnowBrick; + public static IRecipe recipeRoofTile; + public static IRecipe recipeAzulejo; + public static List recipesAzulejoCycling; + public static IRecipe recipeEnderEyeBlock; + public static IRecipe recipeItemFinder; + public static IRecipe recipeSuperLavaPendant; + public static IRecipe recipeEnderHand; + public static IRecipe recipeGlassPick; + public static IRecipe recipeStarfield; + public static List recipesSpark; + public static List recipesSparkUpgrades; + public static IRecipe recipeLeafHorn; + public static IRecipe recipeDiviningRod; + public static List recipesWings; + public static IRecipe recipeRFGenerator; + public static IRecipe recipeGravityRod; + public static IRecipe recipeRegenIvy; + public static IRecipe recipeUltraSpreader; + public static IRecipe recipeHelmetOfRevealing; + public static IRecipe recipeVial; + public static IRecipe recipeFlask; + public static IRecipe recipeBrewery; + public static IRecipe recipeBloodPendant; + public static IRecipe recipeTerraPlate; + public static IRecipe recipeRedString; + public static IRecipe recipeRedStringContainer; + public static IRecipe recipeRedStringDispenser; + public static IRecipe recipeRedStringFertilizer; + public static IRecipe recipeRedStringComparator; + public static IRecipe recipeRedStringRelay; + public static IRecipe recipeRedStringInterceptor; + public static IRecipe recipeMissileRod; + public static IRecipe recipeHolyCloak; + public static IRecipe recipeUnholyCloak; + public static IRecipe recipeCraftingHalo; + public static List recipesLensFlash; + public static IRecipe recipePrism; + public static IRecipe recipeDirtPath; + public static IRecipe recipeDreamwoodTwig; + public static IRecipe recipeMonocle; + public static IRecipe recipeClip; + public static IRecipe recipeCobbleRod; + public static IRecipe recipeSmeltRod; + public static IRecipe recipeWorldSeed; + public static IRecipe recipeSpellCloth; + public static IRecipe recipeThornChakram; + public static IRecipe recipeDirtPathSlab; + public static List recipesPatterns; + public static IRecipe recipeGaiaIngot; + public static IRecipe recipeCorporeaSpark; + public static IRecipe recipeMasterCorporeaSpark; + public static IRecipe recipeCorporeaIndex; + public static IRecipe recipeCorporeaFunnel; + public static IRecipe recipeCorporeaInterceptor; + public static IRecipe recipeEndStoneBricks; + public static IRecipe recipeEndStoneChiseledBricks; + public static IRecipe recipeEnderBricks; + public static IRecipe recipePillarEnderBricks; + public static IRecipe recipeLivingwoodBow; + public static IRecipe recipeCrystalBow; + public static List recipesCosmeticItems; + public static List recipesMushrooms; + public static IRecipe recipeSwapRing; + public static IRecipe recipeSnowHorn; + public static IRecipe recipeFlowerBag; + public static IRecipe recipePhantomInk; + public static IRecipe recipePoolCart; + public static IRecipe recipePump; + public static List recipesPetalsDouble; + public static IRecipe recipeKeepIvy; + public static IRecipe recipeBlackHoleTalisman; + public static List recipe18StonePolish; + public static List recipe18StoneBrick; + public static List recipe18StoneChisel; + public static IRecipe recipeBlazeBlock; + public static List recipesAltarMeta; + public static IRecipe recipeCorporeaCrystalCube; + public static IRecipe recipeTemperanceStone; + public static IRecipe recipeIncenseStick; + public static IRecipe recipeIncensePlate; + public static IRecipe recipeTerraAxe; + public static IRecipe recipeHourglass; + public static IRecipe recipeGhostRail; + public static IRecipe recipeCanopyDrum; + public static IRecipe recipeSparkChanger; + public static IRecipe recipeCocoon; + public static IRecipe recipeLuminizer; + public static IRecipe recipeDetectorLuminizer; + public static IRecipe recipeLuminizerLauncher; + public static IRecipe recipeObedienceStick; + public static IRecipe recipeCacophonium; + public static IRecipe recipeManaBomb; + public static IRecipe recipeCobweb; + public static IRecipe recipeSlimeBottle; + public static IRecipe recipeStarSword; + public static IRecipe recipeExchangeRod; + public static IRecipe recipeGreaterMagnetRing; + public static IRecipe recipeFireChakram; + public static IRecipe recipeThunderSword; + public static IRecipe recipeBellows; + public static IRecipe recipeManaweaveCloth; + public static IRecipe recipeManaweaveHelm; + public static IRecipe recipeManaweaveChest; + public static IRecipe recipeManaweaveLegs; + public static IRecipe recipeManaweaveBoots; + public static IRecipe recipeBifrost; + public static IRecipe recipeShimmerrock; + public static IRecipe recipeShimmerwoodPlanks; + public static IRecipe recipeAutocraftingHalo; + public static List recipesPavement; + public static IRecipe recipeCellBlock; + public static IRecipe recipeCorporeaRetainer; + public static IRecipe recipeTeruTeruBozu; + public static IRecipe recipeAvatar; + public static IRecipe recipeSextant; + public static List recipesAltGrassSeeds; + public static IRecipe recipeSpeedUpBelt; + public static IRecipe recipeBaubleCase; + + // Garden of Glass + public static IRecipe recipeRootToSapling; + public static IRecipe recipeRootToFertilizer; + public static IRecipe recipePebbleCobblestone; + public static IRecipe recipeMagmaToSlimeball; + public static IRecipe recipeFelPumpkin; + public static IRecipe recipeEndPortal; + + public static void init() { + if (!ConfigHandler.enableDefaultRecipes) return; + + int recipeListSize = CraftingManager.getInstance().getRecipeList().size(); + + // Lexicon Recipe + addShapelessOreDictRecipe(new ItemStack(ModItems.lexicon), "treeSapling", Items.book); + recipeLexicon = BotaniaAPI.getLatestAddedRecipe(); + + // Petal/Dye Recipes + for (int i = 0; i < 16; i++) + addShapelessOreDictRecipe(new ItemStack(ModItems.petal, 2, i), LibOreDict.FLOWER[i]); + recipesPetals = BotaniaAPI.getLatestAddedRecipes(16); + + for (int i = 0; i < 16; i++) + addShapelessOreDictRecipe( + new ItemStack(ModItems.dye, 1, i), LibOreDict.PETAL[i], LibOreDict.PESTLE_AND_MORTAR); + recipesDyes = BotaniaAPI.getLatestAddedRecipes(16); + + // Petal Block Recipes + for (int i = 0; i < 16; i++) + addOreDictRecipe( + new ItemStack(ModBlocks.petalBlock, 1, i), + "PPP", + "PPP", + "PPP", // PPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPP + 'P', + LibOreDict.PETAL[i]); + recipesPetalBlocks = BotaniaAPI.getLatestAddedRecipes(16); + + // Pestle and Mortar Recipe + addOreDictRecipe( + new ItemStack(ModItems.pestleAndMortar), + " S", + "W ", + "B ", + 'S', + "stickWood", + 'W', + "plankWood", + 'B', + Items.bowl); + recipePestleAndMortar = BotaniaAPI.getLatestAddedRecipe(); + + // Wand of the Forest Recipes + for (int i = 0; i < 16; i++) + for (int j = 0; j < 16; j++) { + addOreDictRecipe( + ItemTwigWand.forColors(i, j), + " AS", + " SB", + "S ", + 'A', + LibOreDict.PETAL[i], + 'B', + LibOreDict.PETAL[j], + 'S', + LibOreDict.LIVINGWOOD_TWIG); + } + recipesTwigWand = BotaniaAPI.getLatestAddedRecipes(256); + + // Petal Apothecary Recipes + for (int i = 0; i < 16; i++) + addOreDictRecipe( + new ItemStack(ModBlocks.altar), + "SPS", + " C ", + "CCC", + 'S', + "slabCobblestone", + 'P', + LibOreDict.PETAL[i], + 'C', + "cobblestone"); + recipesApothecary = BotaniaAPI.getLatestAddedRecipes(16); + + // Mana Spreader Recipes + for (int i = 0; i < 16; i++) + addOreDictRecipe( + new ItemStack(ModBlocks.spreader), + "WWW", + "GP ", + "WWW", + 'W', + LibOreDict.LIVING_WOOD, + 'P', + LibOreDict.PETAL[i], + 'G', + Botania.gardenOfGlassLoaded ? LibOreDict.LIVING_WOOD : "ingotGold"); + recipesSpreader = BotaniaAPI.getLatestAddedRecipes(16); + + // Mana Lens Recipe + addOreDictRecipe( + new ItemStack(ModItems.lens), + " S ", + "SGS", + " S ", + 'S', + LibOreDict.MANA_STEEL, + 'G', + "paneGlassColorless"); + addOreDictRecipe( + new ItemStack(ModItems.lens), + " S ", + "SGS", + " S ", + 'S', + LibOreDict.MANA_STEEL, + 'G', + "blockGlassColorless"); + recipesManaLens = BotaniaAPI.getLatestAddedRecipes(2); + + // Mana Pool Recipe + addOreDictRecipe(new ItemStack(ModBlocks.pool), "R R", "RRR", 'R', LibOreDict.LIVING_ROCK); + recipePool = BotaniaAPI.getLatestAddedRecipe(); + + // Diluted Mana Pool Recipe + addOreDictRecipe( + new ItemStack(ModBlocks.pool, 1, 2), "R R", "RRR", 'R', new ItemStack(ModFluffBlocks.livingrockSlab)); + recipePoolDiluted = BotaniaAPI.getLatestAddedRecipe(); + + // Fabulous Mana Pool Recipe + addOreDictRecipe(new ItemStack(ModBlocks.pool, 1, 3), "R R", "RRR", 'R', new ItemStack(ModBlocks.shimmerrock)); + recipePoolFabulous = BotaniaAPI.getLatestAddedRecipe(); + + // Runic Altar Recipe + addOreDictRecipe( + new ItemStack(ModBlocks.runeAltar), + "SSS", + "SPS", + 'S', + LibOreDict.LIVING_ROCK, + 'P', + LibOreDict.MANA_PEARL); + addOreDictRecipe( + new ItemStack(ModBlocks.runeAltar), + "SSS", + "SDS", + 'S', + LibOreDict.LIVING_ROCK, + 'D', + LibOreDict.MANA_DIAMOND); + recipesRuneAltar = BotaniaAPI.getLatestAddedRecipes(2); + + // Lens Recipes + addShapelessOreDictRecipe(new ItemStack(ModItems.lens, 1, 1), new ItemStack(ModItems.lens), LibOreDict.RUNE[3]); + recipeLensVelocity = BotaniaAPI.getLatestAddedRecipe(); + + addShapelessOreDictRecipe(new ItemStack(ModItems.lens, 1, 2), new ItemStack(ModItems.lens), LibOreDict.RUNE[1]); + recipeLensPotency = BotaniaAPI.getLatestAddedRecipe(); + + addShapelessOreDictRecipe(new ItemStack(ModItems.lens, 1, 3), new ItemStack(ModItems.lens), LibOreDict.RUNE[2]); + recipeLensResistance = BotaniaAPI.getLatestAddedRecipe(); + + addShapelessOreDictRecipe(new ItemStack(ModItems.lens, 1, 4), new ItemStack(ModItems.lens), LibOreDict.RUNE[0]); + recipeLensEfficiency = BotaniaAPI.getLatestAddedRecipe(); + + addShapelessOreDictRecipe(new ItemStack(ModItems.lens, 1, 5), new ItemStack(ModItems.lens), LibOreDict.RUNE[5]); + recipeLensBounce = BotaniaAPI.getLatestAddedRecipe(); + + addShapelessOreDictRecipe(new ItemStack(ModItems.lens, 1, 6), new ItemStack(ModItems.lens), LibOreDict.RUNE[7]); + recipeLensGravity = BotaniaAPI.getLatestAddedRecipe(); + + addOreDictRecipe( + new ItemStack(ModItems.lens, 1, 7), + " P ", + "ALA", + " R ", + 'P', + new ItemStack(Blocks.piston), + 'R', + "dustRedstone", + 'A', + "gemLapis", + 'L', + new ItemStack(ModItems.lens)); + recipeLensBore = BotaniaAPI.getLatestAddedRecipe(); + + addShapelessOreDictRecipe( + new ItemStack(ModItems.lens, 1, 8), new ItemStack(ModItems.lens), LibOreDict.RUNE[13]); + recipeLensDamaging = BotaniaAPI.getLatestAddedRecipe(); + + addShapelessOreDictRecipe( + new ItemStack(ModItems.lens, 1, 9), new ItemStack(ModItems.lens), new ItemStack(ModBlocks.platform)); + recipeLensPhantom = BotaniaAPI.getLatestAddedRecipe(); + + addShapelessOreDictRecipe( + new ItemStack(ModItems.lens, 1, 10), new ItemStack(ModItems.lens), "ingotIron", "ingotGold"); + recipeLensMagnet = BotaniaAPI.getLatestAddedRecipe(); + + addShapelessOreDictRecipe( + new ItemStack(ModItems.lens, 1, 11), new ItemStack(ModItems.lens), LibOreDict.RUNE[14]); + recipeLensExplosive = BotaniaAPI.getLatestAddedRecipe(); + + // Unstable Block Recipes + for (int i = 0; i < 16; i++) + addOreDictRecipe( + new ItemStack(ModBlocks.unstableBlock, 2, i), + "OPO", + "PMP", + "OPO", + 'O', + new ItemStack(Blocks.obsidian), + 'P', + LibOreDict.PETAL[i], + 'M', + new ItemStack(Items.ender_pearl)); + recipesUnstableBlocks = BotaniaAPI.getLatestAddedRecipes(16); + + // Mana Pylon Recipe + addOreDictRecipe( + new ItemStack(ModBlocks.pylon), + " G ", + "MDM", + " G ", + 'G', + "ingotGold", + 'M', + LibOreDict.MANA_STEEL, + 'D', + LibOreDict.MANA_DIAMOND); + recipePylon = BotaniaAPI.getLatestAddedRecipe(); + + // Mana Distributor + addOreDictRecipe( + new ItemStack(ModBlocks.distributor), + "RRR", + "S S", + "RRR", + 'R', + LibOreDict.LIVING_ROCK, + 'S', + LibOreDict.MANA_STEEL); + recipeDistributor = BotaniaAPI.getLatestAddedRecipe(); + + // Livingrock Decorative Blocks + addOreDictRecipe(new ItemStack(ModBlocks.livingrock, 4, 1), "RR", "RR", 'R', LibOreDict.LIVING_ROCK); + recipeLivingrockDecor1 = BotaniaAPI.getLatestAddedRecipe(); + addShapelessOreDictRecipe( + new ItemStack(ModBlocks.livingrock, 1, 2), + new ItemStack(ModBlocks.livingrock, 1, 1), + new ItemStack(Items.wheat_seeds)); + recipeLivingrockDecor2 = BotaniaAPI.getLatestAddedRecipe(); + addShapelessOreDictRecipe( + new ItemStack(ModBlocks.livingrock, 2, 3), new ItemStack(ModBlocks.livingrock, 1, 1), "cobblestone"); + recipeLivingrockDecor3 = BotaniaAPI.getLatestAddedRecipe(); + addOreDictRecipe( + new ItemStack(ModBlocks.livingrock, 4, 4), "RR", "RR", 'R', new ItemStack(ModBlocks.livingrock, 1, 1)); + recipeLivingrockDecor4 = BotaniaAPI.getLatestAddedRecipe(); + + // Livingwood Decorative Blocks + addShapelessOreDictRecipe(new ItemStack(ModBlocks.livingwood, 4, 1), LibOreDict.LIVING_WOOD); + recipeLivingwoodDecor1 = BotaniaAPI.getLatestAddedRecipe(); + addShapelessOreDictRecipe( + new ItemStack(ModBlocks.livingwood, 1, 2), + new ItemStack(ModBlocks.livingwood, 1, 1), + new ItemStack(Items.wheat_seeds)); + recipeLivingwoodDecor2 = BotaniaAPI.getLatestAddedRecipe(); + addOreDictRecipe( + new ItemStack(ModBlocks.livingwood, 4, 3), "WW", "WW", 'W', new ItemStack(ModBlocks.livingwood, 1, 1)); + recipeLivingwoodDecor3 = BotaniaAPI.getLatestAddedRecipe(); + addOreDictRecipe( + new ItemStack(ModBlocks.livingwood, 4, 4), + " W ", + "W W", + " W ", + 'W', + new ItemStack(ModBlocks.livingwood, 1, 1)); + recipeLivingwoodDecor4 = BotaniaAPI.getLatestAddedRecipe(); + addShapelessOreDictRecipe(new ItemStack(ModBlocks.livingwood, 1, 5), LibOreDict.LIVING_WOOD, "dustGlowstone"); + recipeLivingwoodDecor5 = BotaniaAPI.getLatestAddedRecipe(); + + // Dreamwood Decorative Blocks + addShapelessOreDictRecipe(new ItemStack(ModBlocks.dreamwood, 4, 1), LibOreDict.DREAM_WOOD); + addShapelessOreDictRecipe( + new ItemStack(ModBlocks.dreamwood, 1, 2), + new ItemStack(ModBlocks.dreamwood, 1, 1), + new ItemStack(Items.wheat_seeds)); + addOreDictRecipe( + new ItemStack(ModBlocks.dreamwood, 4, 3), "WW", "WW", 'W', new ItemStack(ModBlocks.dreamwood, 1, 1)); + addOreDictRecipe( + new ItemStack(ModBlocks.dreamwood, 4, 4), + " W ", + "W W", + " W ", + 'W', + new ItemStack(ModBlocks.dreamwood, 1, 1)); + addShapelessOreDictRecipe(new ItemStack(ModBlocks.dreamwood, 1, 5), LibOreDict.DREAM_WOOD, "dustGlowstone"); + + // Mana Beacon Recipe + for (int i = 0; i < 16; i++) + addOreDictRecipe( + new ItemStack(ModBlocks.manaBeacon, 1, i), + " B ", + "BPB", + " B ", + 'B', + new ItemStack(ModBlocks.unstableBlock, 1, i), + 'P', + LibOreDict.MANA_PEARL); + recipesManaBeacons = BotaniaAPI.getLatestAddedRecipes(16); + + // Signal Flare Recipe + for (int i = 0; i < 16; i++) + addOreDictRecipe( + ItemSignalFlare.forColor(i), + "I ", + " B", + "W ", + 'B', + new ItemStack(ModBlocks.manaBeacon, 1, i), + 'I', + "ingotIron", + 'W', + LibOreDict.LIVING_WOOD); + recipesSignalFlares = BotaniaAPI.getLatestAddedRecipes(16); + + // Mana Void Recipe + addOreDictRecipe( + new ItemStack(ModBlocks.manaVoid), + "SSS", + "O O", + "SSS", + 'S', + LibOreDict.LIVING_ROCK, + 'O', + new ItemStack(Blocks.obsidian)); + recipeManaVoid = BotaniaAPI.getLatestAddedRecipe(); + + // Mana Tablet Recipe + addOreDictRecipe( + new ItemStack(ModItems.manaTablet, 1, 10000), + "SSS", + "SPS", + "SSS", + 'S', + LibOreDict.LIVING_ROCK, + 'P', + LibOreDict.MANA_PEARL); + addOreDictRecipe( + new ItemStack(ModItems.manaTablet, 1, 10000), + "SSS", + "SDS", + "SSS", + 'S', + LibOreDict.LIVING_ROCK, + 'D', + LibOreDict.MANA_DIAMOND); + recipesManaTablet = BotaniaAPI.getLatestAddedRecipes(2); + + // Mana Detector Recipe + addOreDictRecipe( + new ItemStack(ModBlocks.manaDetector), + "RSR", + "SCS", + "RSR", + 'R', + "dustRedstone", + 'C', + new ItemStack(Items.comparator), + 'S', + LibOreDict.LIVING_ROCK); + recipeManaDetector = BotaniaAPI.getLatestAddedRecipe(); + + // Mana Blaster Recipe + addOreDictRecipe( + new ItemStack(ModItems.manaGun), + "SMD", + " WT", + " W", + 'S', + new ItemStack(ModBlocks.spreader, 1, 1), + 'M', + LibOreDict.RUNE[8], + 'D', + LibOreDict.MANA_DIAMOND, + 'T', + new ItemStack(Blocks.tnt), + 'W', + LibOreDict.LIVING_WOOD); + recipeManaBlaster = BotaniaAPI.getLatestAddedRecipe(); + + // Spreader Turntable Recipe + addOreDictRecipe( + new ItemStack(ModBlocks.turntable), + "WWW", + "WPW", + "WWW", + 'W', + LibOreDict.LIVING_WOOD, + 'P', + Blocks.sticky_piston); + recipeTurntable = BotaniaAPI.getLatestAddedRecipe(); + + // Fertilizer Recipes + GameRegistry.addShapelessRecipe( + new ItemStack(ModItems.fertilizer, Botania.gardenOfGlassLoaded ? 3 : 1), + new ItemStack(Items.dye, 1, 15), + new ItemStack(ModItems.dye, 1, Short.MAX_VALUE), + new ItemStack(ModItems.dye, 1, Short.MAX_VALUE), + new ItemStack(ModItems.dye, 1, Short.MAX_VALUE), + new ItemStack(ModItems.dye, 1, Short.MAX_VALUE)); + recipeFertilizerPowder = BotaniaAPI.getLatestAddedRecipe(); + GameRegistry.addShapelessRecipe( + new ItemStack(ModItems.fertilizer), + new ItemStack(Items.dye, 1, 15), + new ItemStack(Items.dye, 1, 11), + new ItemStack(Items.dye, 1, 11), + new ItemStack(Items.dye, 1, 1), + new ItemStack(Items.dye, 1, 1)); + recipeFerilizerDye = BotaniaAPI.getLatestAddedRecipe(); + + // Livingwood Twig Recipe + addOreDictRecipe(new ItemStack(ModItems.manaResource, 1, 3), "W", "W", 'W', LibOreDict.LIVING_WOOD); + recipeLivingwoodTwig = BotaniaAPI.getLatestAddedRecipe(); + + // Rod of the Lands Recipe + addOreDictRecipe( + new ItemStack(ModItems.dirtRod), + " D", + " T ", + "E ", + 'D', + new ItemStack(Blocks.dirt), + 'T', + LibOreDict.LIVINGWOOD_TWIG, + 'E', + LibOreDict.RUNE[2]); + recipeDirtRod = BotaniaAPI.getLatestAddedRecipe(); + + // Terra Firma Rod Recipe + addOreDictRecipe( + new ItemStack(ModItems.terraformRod), + " WT", + "ARS", + "GM ", + 'T', + LibOreDict.TERRA_STEEL, + 'R', + new ItemStack(ModItems.dirtRod), + 'G', + new ItemStack(ModItems.grassSeeds), + 'W', + LibOreDict.RUNE[7], + 'S', + LibOreDict.RUNE[4], + 'M', + LibOreDict.RUNE[5], + 'A', + LibOreDict.RUNE[6]); + recipeTerraformRod = BotaniaAPI.getLatestAddedRecipe(); + + // Redstone Mana Spreader Recipe + GameRegistry.addRecipe(new ShapelessOreRecipe( + new ItemStack(ModBlocks.spreader, 1, 1), new ItemStack(ModBlocks.spreader), "dustRedstone")); + recipeRedstoneSpreader = BotaniaAPI.getLatestAddedRecipe(); + + // Mana Miror Recipe + addOreDictRecipe( + new ItemStack(ModItems.manaMirror), + " PR", + " SI", + "T ", + 'P', + LibOreDict.MANA_PEARL, + 'R', + LibOreDict.LIVING_ROCK, + 'S', + LibOreDict.LIVINGWOOD_TWIG, + 'I', + LibOreDict.TERRA_STEEL, + 'T', + new ItemStack(ModItems.manaTablet, 1, Short.MAX_VALUE)); + recipeManaMirror = BotaniaAPI.getLatestAddedRecipe(); + + // Mana Armor & Tools Recipes + addOreDictRecipe(new ItemStack(ModItems.manasteelHelm), "SSS", "S S", 'S', LibOreDict.MANA_STEEL); + recipeManasteelHelm = BotaniaAPI.getLatestAddedRecipe(); + addOreDictRecipe(new ItemStack(ModItems.manasteelChest), "S S", "SSS", "SSS", 'S', LibOreDict.MANA_STEEL); + recipeManasteelChest = BotaniaAPI.getLatestAddedRecipe(); + addOreDictRecipe(new ItemStack(ModItems.manasteelLegs), "SSS", "S S", "S S", 'S', LibOreDict.MANA_STEEL); + recipeManasteelLegs = BotaniaAPI.getLatestAddedRecipe(); + addOreDictRecipe(new ItemStack(ModItems.manasteelBoots), "S S", "S S", 'S', LibOreDict.MANA_STEEL); + recipeManasteelBoots = BotaniaAPI.getLatestAddedRecipe(); + addOreDictRecipe( + new ItemStack(ModItems.manasteelPick), + "SSS", + " T ", + " T ", + 'S', + LibOreDict.MANA_STEEL, + 'T', + LibOreDict.LIVINGWOOD_TWIG); + recipeManasteelPick = BotaniaAPI.getLatestAddedRecipe(); + addOreDictRecipe( + new ItemStack(ModItems.manasteelShovel), + "S", + "T", + "T", + 'S', + LibOreDict.MANA_STEEL, + 'T', + LibOreDict.LIVINGWOOD_TWIG); + recipeManasteelShovel = BotaniaAPI.getLatestAddedRecipe(); + addOreDictRecipe( + new ItemStack(ModItems.manasteelAxe), + "SS", + "TS", + "T ", + 'S', + LibOreDict.MANA_STEEL, + 'T', + LibOreDict.LIVINGWOOD_TWIG); + recipeManasteelAxe = BotaniaAPI.getLatestAddedRecipe(); + addOreDictRecipe( + new ItemStack(ModItems.manasteelSword), + "S", + "S", + "T", + 'S', + LibOreDict.MANA_STEEL, + 'T', + LibOreDict.LIVINGWOOD_TWIG); + recipeManasteelSword = BotaniaAPI.getLatestAddedRecipe(); + addOreDictRecipe(new ItemStack(ModItems.manasteelShears), "S ", " S", 'S', LibOreDict.MANA_STEEL); + recipeManasteelShears = BotaniaAPI.getLatestAddedRecipe(); + + // Horn of the Wild Recipe + addOreDictRecipe( + new ItemStack(ModItems.grassHorn), + " W ", + "WSW", + "WW ", + 'W', + LibOreDict.LIVING_WOOD, + 'S', + new ItemStack(ModItems.grassSeeds)); + recipeGrassHorn = BotaniaAPI.getLatestAddedRecipe(); + + // Terrasteel Armor Recipes + addOreDictRecipe( + new ItemStack(ModItems.terrasteelHelmRevealing), + "TRT", + "SAS", + " S ", + 'T', + LibOreDict.LIVINGWOOD_TWIG, + 'S', + LibOreDict.TERRA_STEEL, + 'R', + LibOreDict.RUNE[4], + 'A', + new ItemStack(ModItems.manasteelHelmRevealing)); + addOreDictRecipe( + new ItemStack(ModItems.terrasteelHelm), + "TRT", + "SAS", + " S ", + 'T', + LibOreDict.LIVINGWOOD_TWIG, + 'S', + LibOreDict.TERRA_STEEL, + 'R', + LibOreDict.RUNE[4], + 'A', + new ItemStack(ModItems.manasteelHelm)); + recipeTerrasteelHelm = BotaniaAPI.getLatestAddedRecipe(); + addOreDictRecipe( + new ItemStack(ModItems.terrasteelChest), + "TRT", + "SAS", + " S ", + 'T', + LibOreDict.LIVINGWOOD_TWIG, + 'S', + LibOreDict.TERRA_STEEL, + 'R', + LibOreDict.RUNE[5], + 'A', + new ItemStack(ModItems.manasteelChest)); + recipeTerrasteelChest = BotaniaAPI.getLatestAddedRecipe(); + addOreDictRecipe( + new ItemStack(ModItems.terrasteelLegs), + "TRT", + "SAS", + " S ", + 'T', + LibOreDict.LIVINGWOOD_TWIG, + 'S', + LibOreDict.TERRA_STEEL, + 'R', + LibOreDict.RUNE[6], + 'A', + new ItemStack(ModItems.manasteelLegs)); + recipeTerrasteelLegs = BotaniaAPI.getLatestAddedRecipe(); + addOreDictRecipe( + new ItemStack(ModItems.terrasteelBoots), + "TRT", + "SAS", + " S ", + 'T', + LibOreDict.LIVINGWOOD_TWIG, + 'S', + LibOreDict.TERRA_STEEL, + 'R', + LibOreDict.RUNE[7], + 'A', + new ItemStack(ModItems.manasteelBoots)); + recipeTerrasteelBoots = BotaniaAPI.getLatestAddedRecipe(); + + // Terra Blade Recipe + addOreDictRecipe( + new ItemStack(ModItems.terraSword), + "I", + "I", + "S", + 'I', + LibOreDict.TERRA_STEEL, + 'S', + LibOreDict.LIVINGWOOD_TWIG); + recipeTerraSword = BotaniaAPI.getLatestAddedRecipe(); + + // Tiny Planet Recipe + addOreDictRecipe( + new ItemStack(ModItems.tinyPlanet), + "LSL", + "SPS", + "LSL", + 'S', + "stone", + 'L', + LibOreDict.LIVING_ROCK, + 'P', + LibOreDict.MANA_PEARL); + recipeTinyPlanet = BotaniaAPI.getLatestAddedRecipe(); + + // Mana Band Recipe + addOreDictRecipe( + new ItemStack(ModItems.manaRing), + "TI ", + "I I", + " I ", + 'T', + new ItemStack(ModItems.manaTablet, 1, Short.MAX_VALUE), + 'I', + LibOreDict.MANA_STEEL); + recipeManaRing = BotaniaAPI.getLatestAddedRecipe(); + + // Aura Band Recipe + addOreDictRecipe( + new ItemStack(ModItems.auraRing), + "RI ", + "I I", + " I ", + 'R', + LibOreDict.RUNE[8], + 'I', + LibOreDict.MANA_STEEL); + recipeAuraRing = BotaniaAPI.getLatestAddedRecipe(); + + // Greater Mana Band Recipe + addShapelessOreDictRecipe( + new ItemStack(ModItems.manaRingGreater), LibOreDict.TERRA_STEEL, new ItemStack(ModItems.manaRing)); + recipeGreaterManaRing = BotaniaAPI.getLatestAddedRecipe(); + + // Greater Aura Band Recipe + addShapelessOreDictRecipe( + new ItemStack(ModItems.auraRingGreater), LibOreDict.TERRA_STEEL, new ItemStack(ModItems.auraRing)); + recipeGreaterAuraRing = BotaniaAPI.getLatestAddedRecipe(); + + // Soujourner's Belt Recipe + addOreDictRecipe( + new ItemStack(ModItems.travelBelt), + "EL ", + "L L", + "SLA", + 'E', + LibOreDict.RUNE[2], + 'A', + LibOreDict.RUNE[3], + 'S', + LibOreDict.MANA_STEEL, + 'L', + new ItemStack(Items.leather)); + recipeTravelBelt = BotaniaAPI.getLatestAddedRecipe(); + + // Tectonic Girdle Recipe + addOreDictRecipe( + new ItemStack(ModItems.knockbackBelt), + "AL ", + "L L", + "SLE", + 'E', + LibOreDict.RUNE[2], + 'A', + LibOreDict.RUNE[1], + 'S', + LibOreDict.MANA_STEEL, + 'L', + new ItemStack(Items.leather)); + recipeKnocbackBelt = BotaniaAPI.getLatestAddedRecipe(); + + // Snowflake Pendant Recipe + addOreDictRecipe( + new ItemStack(ModItems.icePendant), + "WS ", + "S S", + "MSR", + 'S', + new ItemStack(Items.string), + 'M', + LibOreDict.MANA_STEEL, + 'R', + LibOreDict.RUNE[0], + 'W', + LibOreDict.RUNE[7]); + recipeIcePendant = BotaniaAPI.getLatestAddedRecipe(); + + // Pyroclast Pendant Recipe + addOreDictRecipe( + new ItemStack(ModItems.lavaPendant), + "MS ", + "S S", + "DSF", + 'S', + new ItemStack(Items.string), + 'D', + LibOreDict.MANA_STEEL, + 'M', + LibOreDict.RUNE[5], + 'F', + LibOreDict.RUNE[1]); + recipeFirePendant = BotaniaAPI.getLatestAddedRecipe(); + + // Golden Laurel Crown Recipe + addOreDictRecipe( + new ItemStack(ModItems.goldLaurel), + "G G", + "LEL", + "LLL", + 'G', + "ingotGold", + 'L', + "treeLeaves", + 'E', + LibOreDict.LIFE_ESSENCE); + recipeGoldenLaurel = BotaniaAPI.getLatestAddedRecipe(); + + // Tiny Planet Block Recipe + addOreDictRecipe( + new ItemStack(ModBlocks.tinyPlanet), "SSS", "SPS", "SSS", 'S', "stone", 'P', ModItems.tinyPlanet); + recipeTinyPlanetBlock = BotaniaAPI.getLatestAddedRecipe(); + + // Alchemy Catalyst Recipe + addOreDictRecipe( + new ItemStack(ModBlocks.alchemyCatalyst), + "SGS", + "BPB", + "SGS", + 'S', + LibOreDict.LIVING_ROCK, + 'G', + "ingotGold", + 'B', + new ItemStack(Items.brewing_stand), + 'P', + LibOreDict.MANA_PEARL); + recipeAlchemyCatalyst = BotaniaAPI.getLatestAddedRecipe(); + + // Open Crate Recipe + GameRegistry.addRecipe( + new ItemStack(ModBlocks.openCrate), + "WWW", + "W W", + "W W", + 'W', + new ItemStack(ModBlocks.livingwood, 1, 1)); + recipeOpenCrate = BotaniaAPI.getLatestAddedRecipe(); + + // Eye of the Ancients Recipe + addOreDictRecipe( + new ItemStack(ModBlocks.forestEye), + "MSM", + "SES", + "MSM", + 'M', + LibOreDict.MANA_STEEL, + 'S', + LibOreDict.LIVING_ROCK, + 'E', + new ItemStack(Items.ender_eye)); + recipeForestEye = BotaniaAPI.getLatestAddedRecipe(); + + // Redstone Root Recipe + GameRegistry.addRecipe(new ShapelessOreRecipe( + new ItemStack(ModItems.manaResource, 1, 6), "dustRedstone", new ItemStack(Blocks.tallgrass, 1, 1))); + recipeRedstoneRoot = BotaniaAPI.getLatestAddedRecipe(); + + // Drum of the Wild Recipe + addOreDictRecipe( + new ItemStack(ModBlocks.forestDrum), + "WLW", + "WHW", + "WLW", + 'W', + LibOreDict.LIVING_WOOD, + 'L', + new ItemStack(Items.leather), + 'H', + new ItemStack(ModItems.grassHorn)); + recipeForestDrum = BotaniaAPI.getLatestAddedRecipe(); + + // Ring of Chordata Recipe + addOreDictRecipe( + new ItemStack(ModItems.waterRing), + "WMP", + "M M", + "SM ", + 'W', + LibOreDict.RUNE[0], + 'M', + LibOreDict.MANA_STEEL, + 'P', + new ItemStack(Items.fish, 1, 3), + 'S', + new ItemStack(Items.fish, 1, 1)); + recipeWaterRing = BotaniaAPI.getLatestAddedRecipe(); + + // Ring of the Mantle Recipe + addOreDictRecipe( + new ItemStack(ModItems.miningRing), + "EMP", + "M M", + " M ", + 'E', + LibOreDict.RUNE[2], + 'M', + LibOreDict.MANA_STEEL, + 'P', + new ItemStack(Items.golden_pickaxe)); + recipeMiningRing = BotaniaAPI.getLatestAddedRecipe(); + + // Ring of Magnetization Recipe + addOreDictRecipe( + new ItemStack(ModItems.magnetRing), + "LM ", + "M M", + " M ", + 'L', + new ItemStack(ModItems.lens, 1, 10), + 'M', + LibOreDict.MANA_STEEL); + recipeMagnetRing = BotaniaAPI.getLatestAddedRecipe(); + + // Terra Shatterer Recipe + addOreDictRecipe( + new ItemStack(ModItems.terraPick), + "ITI", + "ILI", + " L ", + 'T', + new ItemStack(ModItems.manaTablet, 1, Short.MAX_VALUE), + 'I', + LibOreDict.TERRA_STEEL, + 'L', + LibOreDict.LIVINGWOOD_TWIG); + recipeTerraPick = BotaniaAPI.getLatestAddedRecipe(); + + // Charm of the Diva Recipe + addOreDictRecipe( + new ItemStack(ModItems.divaCharm), + "LGP", + " HG", + " GL", + 'L', + LibOreDict.LIFE_ESSENCE, + 'G', + "ingotGold", + 'H', + LibOreDict.RUNE[15], + 'P', + new ItemStack(ModItems.tinyPlanet)); + recipeDivaCharm = BotaniaAPI.getLatestAddedRecipe(); + + // Flugel Tiara Recipe + addOreDictRecipe( + new ItemStack(ModItems.flightTiara), + "LLL", + "ILI", + "FEF", + 'L', + LibOreDict.LIFE_ESSENCE, + 'I', + LibOreDict.ELEMENTIUM, + 'F', + new ItemStack(Items.feather), + 'E', + LibOreDict.ENDER_AIR_BOTTLE); + recipeFlightTiara = BotaniaAPI.getLatestAddedRecipe(); + + // Glimmering Flowers Recipes + for (int i = 0; i < 16; i++) + addShapelessOreDictRecipe( + new ItemStack(ModBlocks.shinyFlower, 1, i), "dustGlowstone", "dustGlowstone", LibOreDict.FLOWER[i]); + recipesShinyFlowers = BotaniaAPI.getLatestAddedRecipes(16); + + // Abstruse Platform Recipe + addOreDictRecipe( + new ItemStack(ModBlocks.platform, 2), + "343", + "0P0", + '0', + new ItemStack(ModBlocks.livingwood, 1, 0), + '3', + new ItemStack(ModBlocks.livingwood, 1, 3), + '4', + new ItemStack(ModBlocks.livingwood, 1, 4), + 'P', + LibOreDict.MANA_PEARL); + recipePlatform = BotaniaAPI.getLatestAddedRecipe(); + + // Soulscribe Recipe + addOreDictRecipe( + new ItemStack(ModItems.enderDagger), + "P", + "S", + "T", + 'P', + LibOreDict.MANA_PEARL, + 'S', + LibOreDict.MANA_STEEL, + 'T', + LibOreDict.LIVINGWOOD_TWIG); + recipeEnderDagger = BotaniaAPI.getLatestAddedRecipe(); + + // Quartz Recipes + if (ConfigHandler.darkQuartzEnabled) + recipeDarkQuartz = addQuartzRecipes( + 0, + Items.coal, + ModFluffBlocks.darkQuartz, + ModFluffBlocks.darkQuartzStairs, + ModFluffBlocks.darkQuartzSlab); + addQuartzRecipes( + 1, null, ModFluffBlocks.manaQuartz, ModFluffBlocks.manaQuartzStairs, ModFluffBlocks.manaQuartzSlab); + recipeBlazeQuartz = addQuartzRecipes( + 2, + Items.blaze_powder, + ModFluffBlocks.blazeQuartz, + ModFluffBlocks.blazeQuartzStairs, + ModFluffBlocks.blazeQuartzSlab); + + GameRegistry.addRecipe(new ShapedOreRecipe( + new ItemStack(ModItems.quartz, 8, 3), + "QQQ", + "QCQ", + "QQQ", + 'Q', + "gemQuartz", + 'C', + new ItemStack(Blocks.red_flower, 1, 2))); + GameRegistry.addRecipe(new ShapedOreRecipe( + new ItemStack(ModItems.quartz, 8, 3), + "QQQ", + "QCQ", + "QQQ", + 'Q', + "gemQuartz", + 'C', + new ItemStack(Blocks.red_flower, 1, 7))); + GameRegistry.addRecipe(new ShapedOreRecipe( + new ItemStack(ModItems.quartz, 8, 3), + "QQQ", + "QCQ", + "QQQ", + 'Q', + "gemQuartz", + 'C', + new ItemStack(Blocks.double_plant, 1, 1))); + GameRegistry.addRecipe(new ShapedOreRecipe( + new ItemStack(ModItems.quartz, 8, 3), + "QQQ", + "QCQ", + "QQQ", + 'Q', + "gemQuartz", + 'C', + new ItemStack(Blocks.double_plant, 1, 5))); + recipesLavenderQuartz = BotaniaAPI.getLatestAddedRecipes(4); + addQuartzRecipes( + 3, + null, + ModFluffBlocks.lavenderQuartz, + ModFluffBlocks.lavenderQuartzStairs, + ModFluffBlocks.lavenderQuartzSlab); + + recipeRedQuartz = addQuartzRecipes( + 4, + Items.redstone, + ModFluffBlocks.redQuartz, + ModFluffBlocks.redQuartzStairs, + ModFluffBlocks.redQuartzSlab); + addQuartzRecipes( + 5, null, ModFluffBlocks.elfQuartz, ModFluffBlocks.elfQuartzStairs, ModFluffBlocks.elfQuartzSlab); + + recipeSunnyQuartz = addQuartzRecipes( + 6, + Item.getItemFromBlock(Blocks.double_plant), + ModFluffBlocks.sunnyQuartz, + ModFluffBlocks.sunnyQuartzStairs, + ModFluffBlocks.sunnyQuartzSlab); + + // Alfheim Portal Recipe + addOreDictRecipe( + new ItemStack(ModBlocks.alfPortal), + "WTW", + "WTW", + "WTW", + 'W', + LibOreDict.LIVING_WOOD, + 'T', + LibOreDict.TERRASTEEL_NUGGET); + recipeAlfPortal = BotaniaAPI.getLatestAddedRecipe(); + + // Natura Pylon Recipe + addOreDictRecipe( + new ItemStack(ModBlocks.pylon, 1, 1), + " T ", + "TPT", + " E ", + 'T', + LibOreDict.TERRASTEEL_NUGGET, + 'P', + new ItemStack(ModBlocks.pylon), + 'E', + new ItemStack(Items.ender_eye)); + recipeNaturaPylon = BotaniaAPI.getLatestAddedRecipe(); + + // Rod of the Seas Recipe + addOreDictRecipe( + new ItemStack(ModItems.waterRod), + " B", + " T ", + "R ", + 'B', + new ItemStack(Items.potionitem), + 'T', + LibOreDict.LIVINGWOOD_TWIG, + 'R', + LibOreDict.RUNE[0]); + recipeWaterRod = BotaniaAPI.getLatestAddedRecipe(); + + // Elementium Armor & Tools Recipes + addOreDictRecipe(new ItemStack(ModItems.elementiumHelm), "SSS", "S S", 'S', LibOreDict.ELEMENTIUM); + recipeElementiumHelm = BotaniaAPI.getLatestAddedRecipe(); + addOreDictRecipe(new ItemStack(ModItems.elementiumChest), "S S", "SSS", "SSS", 'S', LibOreDict.ELEMENTIUM); + recipeElementiumChest = BotaniaAPI.getLatestAddedRecipe(); + addOreDictRecipe(new ItemStack(ModItems.elementiumLegs), "SSS", "S S", "S S", 'S', LibOreDict.ELEMENTIUM); + recipeElementiumLegs = BotaniaAPI.getLatestAddedRecipe(); + addOreDictRecipe(new ItemStack(ModItems.elementiumBoots), "S S", "S S", 'S', LibOreDict.ELEMENTIUM); + recipeElementiumBoots = BotaniaAPI.getLatestAddedRecipe(); + addOreDictRecipe( + new ItemStack(ModItems.elementiumPick), + "SSS", + " T ", + " T ", + 'S', + LibOreDict.ELEMENTIUM, + 'T', + LibOreDict.DREAMWOOD_TWIG); + recipeElementiumPick = BotaniaAPI.getLatestAddedRecipe(); + addOreDictRecipe( + new ItemStack(ModItems.elementiumShovel), + "S", + "T", + "T", + 'S', + LibOreDict.ELEMENTIUM, + 'T', + LibOreDict.DREAMWOOD_TWIG); + recipeElementiumShovel = BotaniaAPI.getLatestAddedRecipe(); + addOreDictRecipe( + new ItemStack(ModItems.elementiumAxe), + "SS", + "TS", + "T ", + 'S', + LibOreDict.ELEMENTIUM, + 'T', + LibOreDict.DREAMWOOD_TWIG); + recipeElementiumAxe = BotaniaAPI.getLatestAddedRecipe(); + addOreDictRecipe( + new ItemStack(ModItems.elementiumSword), + "S", + "S", + "T", + 'S', + LibOreDict.ELEMENTIUM, + 'T', + LibOreDict.DREAMWOOD_TWIG); + recipeElementiumSword = BotaniaAPI.getLatestAddedRecipe(); + addOreDictRecipe(new ItemStack(ModItems.elementiumShears), "S ", " S", 'S', LibOreDict.ELEMENTIUM); + recipeElementiumShears = BotaniaAPI.getLatestAddedRecipe(); + + // Extrapolated Bucket Recipe + addOreDictRecipe(new ItemStack(ModItems.openBucket), "E E", " E ", 'E', LibOreDict.ELEMENTIUM); + recipeOpenBucket = BotaniaAPI.getLatestAddedRecipe(); + + // Conjuration Catalyst Recipe + addOreDictRecipe( + new ItemStack(ModBlocks.conjurationCatalyst), + "SBS", + "GPG", + "SGS", + 'S', + LibOreDict.LIVING_ROCK, + 'G', + LibOreDict.ELEMENTIUM, + 'B', + LibOreDict.PIXIE_DUST, + 'P', + new ItemStack(ModBlocks.alchemyCatalyst)); + recipeConjurationCatalyst = BotaniaAPI.getLatestAddedRecipe(); + + // Life Aggregator Recipe + addOreDictRecipe( + new ItemStack(ModItems.spawnerMover), + "EIE", + "ADA", + "EIE", + 'E', + LibOreDict.LIFE_ESSENCE, + 'I', + LibOreDict.ELEMENTIUM, + 'A', + LibOreDict.ENDER_AIR_BOTTLE, + 'D', + LibOreDict.DRAGONSTONE); + recipeSpawnerMover = BotaniaAPI.getLatestAddedRecipe(); + + // Great Fairy Ring Recipe + addOreDictRecipe( + new ItemStack(ModItems.pixieRing), + "DE ", + "E E", + " E ", + 'D', + LibOreDict.PIXIE_DUST, + 'E', + LibOreDict.ELEMENTIUM); + recipePixieRing = BotaniaAPI.getLatestAddedRecipe(); + + // Globetrotter's Sash Recipe + addOreDictRecipe( + new ItemStack(ModItems.superTravelBelt), + "E ", + " S ", + "L E", + 'E', + LibOreDict.ELEMENTIUM, + 'L', + LibOreDict.LIFE_ESSENCE, + 'S', + new ItemStack(ModItems.travelBelt)); + recipeSuperTravelBelt = BotaniaAPI.getLatestAddedRecipe(); + + // Rod of Bifrost Recipe + addOreDictRecipe( + new ItemStack(ModItems.rainbowRod), + " PD", + " EP", + "E ", + 'P', + LibOreDict.PIXIE_DUST, + 'E', + LibOreDict.ELEMENTIUM, + 'D', + LibOreDict.DRAGONSTONE); + recipeRainbowRod = BotaniaAPI.getLatestAddedRecipe(); + + // Spectral Platform Recipe + addOreDictRecipe( + new ItemStack(ModBlocks.platform, 2, 1), + "343", + "0D0", + '0', + new ItemStack(ModBlocks.dreamwood, 1, 0), + '3', + new ItemStack(ModBlocks.dreamwood, 1, 3), + '4', + new ItemStack(ModBlocks.dreamwood, 1, 4), + 'D', + LibOreDict.PIXIE_DUST); + recipeSpectralPlatform = BotaniaAPI.getLatestAddedRecipe(); + + // Elven Mana Spreader Recipes + for (int i = 0; i < 16; i++) + addOreDictRecipe( + new ItemStack(ModBlocks.spreader, 1, 2), + "WWW", + "EP ", + "WWW", + 'W', + LibOreDict.DREAM_WOOD, + 'P', + LibOreDict.PETAL[i], + 'E', + LibOreDict.ELEMENTIUM); + recipesDreamwoodSpreader = BotaniaAPI.getLatestAddedRecipes(16); + + // Rod of the Skies Recipe + addOreDictRecipe( + new ItemStack(ModItems.tornadoRod), + " F", + " T ", + "R ", + 'F', + new ItemStack(Items.feather), + 'T', + LibOreDict.LIVINGWOOD_TWIG, + 'R', + LibOreDict.RUNE[3]); + recipeTornadoRod = BotaniaAPI.getLatestAddedRecipe(); + + // Rod of the Hells Recipe + addOreDictRecipe( + new ItemStack(ModItems.fireRod), + " F", + " T ", + "R ", + 'F', + new ItemStack(Items.blaze_powder), + 'T', + LibOreDict.LIVINGWOOD_TWIG, + 'R', + LibOreDict.RUNE[1]); + recipeFireRod = BotaniaAPI.getLatestAddedRecipe(); + + // Vine Ball Recipe + addOreDictRecipe(new ItemStack(ModItems.vineBall), "VVV", "VVV", "VVV", 'V', new ItemStack(Blocks.vine)); + recipeVineBall = BotaniaAPI.getLatestAddedRecipe(); + + // Livingwood Slingshot Recipe + addOreDictRecipe( + new ItemStack(ModItems.slingshot), + " TA", + " TT", + "T ", + 'T', + LibOreDict.LIVINGWOOD_TWIG, + 'A', + LibOreDict.RUNE[3]); + recipeSlingshot = BotaniaAPI.getLatestAddedRecipe(); + + // Moss Stone Recipe + addShapelessOreDictRecipe( + new ItemStack(Blocks.mossy_cobblestone), "cobblestone", new ItemStack(ModItems.vineBall)); + recipeMossStone = BotaniaAPI.getLatestAddedRecipe(); + + // Prismarine Recipe + addOreDictRecipe( + new ItemStack(ModBlocks.prismarine, 1, 0), + " S ", + "SBS", + " S ", + 'S', + LibOreDict.PRISMARINE_SHARD, + 'B', + "cobblestone"); + recipePrismarine = BotaniaAPI.getLatestAddedRecipe(); + + // Prismarine Brick Recipe + addOreDictRecipe( + new ItemStack(ModBlocks.prismarine, 1, 1), + " S ", + "SBS", + " S ", + 'S', + LibOreDict.PRISMARINE_SHARD, + 'B', + new ItemStack(Blocks.stonebrick)); + recipePrismarineBrick = BotaniaAPI.getLatestAddedRecipe(); + + // Dark Prismarine Recipe + addOreDictRecipe( + new ItemStack(ModBlocks.prismarine, 1, 2), + " S ", + "SBS", + " S ", + 'S', + LibOreDict.PRISMARINE_SHARD, + 'B', + new ItemStack(Blocks.nether_brick)); + recipeDarkPrismarine = BotaniaAPI.getLatestAddedRecipe(); + + // Sea Lantern Recipe + addOreDictRecipe( + new ItemStack(ModBlocks.seaLamp), + " S ", + "SBS", + " S ", + 'S', + LibOreDict.PRISMARINE_SHARD, + 'B', + "glowstone"); + recipeSeaLamp = BotaniaAPI.getLatestAddedRecipe(); + + // Influence Lens Recipe + addOreDictRecipe( + new ItemStack(ModItems.lens, 1, 12), + "PRP", + "PLP", + "PPP", + 'P', + LibOreDict.PRISMARINE_SHARD, + 'R', + LibOreDict.RUNE[3], + 'L', + new ItemStack(ModItems.lens)); + recipeLensInfluence = BotaniaAPI.getLatestAddedRecipe(); + + // Weight Lens Recipe + addOreDictRecipe( + new ItemStack(ModItems.lens, 1, 13), + "PPP", + "PLP", + "PRP", + 'P', + LibOreDict.PRISMARINE_SHARD, + 'R', + LibOreDict.RUNE[0], + 'L', + new ItemStack(ModItems.lens)); + recipeLensWeight = BotaniaAPI.getLatestAddedRecipe(); + + // Paintslinger Lens Recipe + addOreDictRecipe( + new ItemStack(ModItems.lens, 1, 14), + " E ", + "WLW", + " E ", + 'E', + LibOreDict.ELEMENTIUM, + 'W', + new ItemStack(Blocks.wool, 1, Short.MAX_VALUE), + 'L', + new ItemStack(ModItems.lens)); + recipeLensPaint = BotaniaAPI.getLatestAddedRecipe(); + + // Warp Lens Recipe + addShapelessOreDictRecipe( + new ItemStack(ModItems.lens, 1, 18), new ItemStack(ModItems.lens), LibOreDict.PIXIE_DUST); + recipeLensWarp = BotaniaAPI.getLatestAddedRecipe(); + + // Redirective Lens Recipe + addShapelessOreDictRecipe( + new ItemStack(ModItems.lens, 1, 19), + new ItemStack(ModItems.lens), + LibOreDict.LIVING_WOOD, + LibOreDict.ELEMENTIUM); + recipeLensRedirect = BotaniaAPI.getLatestAddedRecipe(); + + // Celebratory Lens Recipe + addShapelessOreDictRecipe( + new ItemStack(ModItems.lens, 1, 20), + new ItemStack(ModItems.lens), + new ItemStack(Items.fireworks), + LibOreDict.ELEMENTIUM); + recipeLensFirework = BotaniaAPI.getLatestAddedRecipe(); + + // Flare Lens Recipe + addShapelessOreDictRecipe( + new ItemStack(ModItems.lens, 1, 21), + new ItemStack(ModItems.lens), + new ItemStack(ModBlocks.elfGlass), + LibOreDict.ELEMENTIUM); + recipeLensFlare = BotaniaAPI.getLatestAddedRecipe(); + + // Mini Island Recipes + for (int i = 0; i < 16; i++) + GameRegistry.addRecipe( + new ItemStack(ModBlocks.floatingFlower, 1, i), + "F", + "S", + "D", + 'F', + new ItemStack(ModBlocks.shinyFlower, 1, i), + 'S', + new ItemStack(ModItems.grassSeeds), + 'D', + new ItemStack(Blocks.dirt)); + recipesMiniIsland = BotaniaAPI.getLatestAddedRecipes(16); + + // Gaia Pylon Recipe + addOreDictRecipe( + new ItemStack(ModBlocks.pylon, 1, 2), + " D ", + "EPE", + " D ", + 'D', + LibOreDict.PIXIE_DUST, + 'E', + LibOreDict.ELEMENTIUM, + 'P', + new ItemStack(ModBlocks.pylon)); + recipeGaiaPylon = BotaniaAPI.getLatestAddedRecipe(); + + // Drum of the Gathering Recipe + addOreDictRecipe( + new ItemStack(ModBlocks.forestDrum, 1, 1), + "WLW", + "WEW", + "WLW", + 'W', + LibOreDict.DREAM_WOOD, + 'L', + new ItemStack(Items.leather), + 'E', + LibOreDict.ELEMENTIUM); + recipeGatherDrum = BotaniaAPI.getLatestAddedRecipe(); + + // Mana Lens: Kindle Recipe + addShapelessOreDictRecipe( + new ItemStack(ModItems.lens, 1, 15), new ItemStack(ModItems.lens), new ItemStack(Items.fire_charge)); + recipeLensFire = BotaniaAPI.getLatestAddedRecipe(); + + // Mana Lens: Piston Recipe + addShapelessOreDictRecipe( + new ItemStack(ModItems.lens, 1, 16), + new ItemStack(ModItems.lens), + new ItemStack(ModBlocks.pistonRelay)); + recipeLensPiston = BotaniaAPI.getLatestAddedRecipe(); + + // Shard of Laputa Recipe + for (int i = 0; i < 16; i++) + addOreDictRecipe( + new ItemStack(ModItems.laputaShard), + "SFS", + "PDP", + "ASE", + 'S', + LibOreDict.LIFE_ESSENCE, + 'D', + LibOreDict.DRAGONSTONE, + 'F', + new ItemStack(ModBlocks.floatingFlower, 1, i), + 'P', + LibOreDict.PRISMARINE_SHARD, + 'A', + LibOreDict.RUNE[3], + 'E', + LibOreDict.RUNE[2]); + recipesLaputaShard = BotaniaAPI.getLatestAddedRecipes(16); + + for (int i = 1; i < 20; i++) + addShapelessOreDictRecipe( + new ItemStack(ModItems.laputaShard, 1, i), + LibOreDict.LIFE_ESSENCE, + new ItemStack(ModItems.laputaShard, 1, i - 1)); + recipesLaputaShardUpgrade = BotaniaAPI.getLatestAddedRecipes(19); + + // Necrodermal Virus Recipe + addShapelessOreDictRecipe( + new ItemStack(ModItems.virus), + LibOreDict.PIXIE_DUST, + new ItemStack(ModItems.vineBall), + new ItemStack(Items.magma_cream), + new ItemStack(Items.fermented_spider_eye), + new ItemStack(Items.ender_eye), + new ItemStack(Items.skull, 1, 2)); + recipeVirusZombie = BotaniaAPI.getLatestAddedRecipe(); + + // Nullodermal Virus Recipe + addShapelessOreDictRecipe( + new ItemStack(ModItems.virus, 1, 1), + LibOreDict.PIXIE_DUST, + new ItemStack(ModItems.vineBall), + new ItemStack(Items.magma_cream), + new ItemStack(Items.fermented_spider_eye), + new ItemStack(Items.ender_eye), + new ItemStack(Items.skull)); + recipeVirusSkeleton = BotaniaAPI.getLatestAddedRecipe(); + + // Ring of Far Reach Recipe + addOreDictRecipe( + new ItemStack(ModItems.reachRing), + "RE ", + "E E", + " E ", + 'R', + LibOreDict.RUNE[15], + 'E', + LibOreDict.ELEMENTIUM); + recipeReachRing = BotaniaAPI.getLatestAddedRecipe(); + + // Rod of the Highlands Recipe + addShapelessOreDictRecipe( + new ItemStack(ModItems.skyDirtRod), + new ItemStack(ModItems.dirtRod), + LibOreDict.PIXIE_DUST, + LibOreDict.RUNE[3]); + recipeSkyDirtRod = BotaniaAPI.getLatestAddedRecipe(); + + // Life Imbuer Recipe + addOreDictRecipe( + new ItemStack(ModBlocks.spawnerClaw), + "BSB", + "PMP", + "PEP", + 'B', + new ItemStack(Items.blaze_rod), + 'S', + LibOreDict.ELEMENTIUM, + 'P', + new ItemStack(ModBlocks.prismarine, 1, 2), + 'M', + new ItemStack(ModBlocks.storage), + 'E', + LibOreDict.ENDER_AIR_BOTTLE); + recipeSpawnerClaw = BotaniaAPI.getLatestAddedRecipe(); + + // Crafty Crate Recipe + GameRegistry.addRecipe(new ShapedOreRecipe( + new ItemStack(ModBlocks.openCrate, 1, 1), + "WCW", + "W W", + "W W", + 'C', + "craftingTableWood", + 'W', + new ItemStack(ModBlocks.dreamwood, 1, 1))); + recipeCraftCrate = BotaniaAPI.getLatestAddedRecipe(); + + // Crafting Placeholder Recipe + addShapelessOreDictRecipe( + new ItemStack(ModItems.manaResource, 32, 11), "craftingTableWood", LibOreDict.LIVING_ROCK); + recipePlaceholder = BotaniaAPI.getLatestAddedRecipe(); + + // Reed Block Recipe + GameRegistry.addRecipe( + new ItemStack(ModBlocks.reedBlock), "rrr", "rrr", "rrr", 'r', new ItemStack(Items.reeds)); + recipeReedBlock = BotaniaAPI.getLatestAddedRecipe(); + + // Thatch Recipe + GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(ModBlocks.thatch), "ww", "ww", 'w', "cropWheat")); + recipeThatch = BotaniaAPI.getLatestAddedRecipe(); + + // Nether Brick Recipe + GameRegistry.addRecipe( + new ItemStack(ModBlocks.customBrick, 4, 0), + " B ", + "BSB", + " B ", + 'B', + new ItemStack(Blocks.netherrack), + 'S', + new ItemStack(Blocks.stonebrick)); + recipeNetherBrick = BotaniaAPI.getLatestAddedRecipe(); + + // Soul Brick Recipe + GameRegistry.addRecipe( + new ItemStack(ModBlocks.customBrick, 4, 1), + " B ", + "BSB", + " B ", + 'B', + new ItemStack(Blocks.soul_sand), + 'S', + new ItemStack(Blocks.stonebrick)); + recipeSoulBrick = BotaniaAPI.getLatestAddedRecipe(); + + // Snow Brick Recipe + GameRegistry.addRecipe( + new ItemStack(ModBlocks.customBrick, 4, 2), + " B ", + "BSB", + " B ", + 'B', + new ItemStack(Blocks.snow), + 'S', + new ItemStack(Blocks.stonebrick)); + recipeSnowBrick = BotaniaAPI.getLatestAddedRecipe(); + + // Roof Tile Recipe + GameRegistry.addRecipe( + new ShapedOreRecipe(new ItemStack(ModBlocks.customBrick, 4, 3), "BB", "BB", "BB", 'B', "ingotBrick")); + recipeRoofTile = BotaniaAPI.getLatestAddedRecipe(); + + // Azulejo Recipe + GameRegistry.addRecipe( + new ShapelessOreRecipe(new ItemStack(ModBlocks.customBrick, 1, 4), "gemLapis", "blockQuartz")); + recipeAzulejo = BotaniaAPI.getLatestAddedRecipe(); + + // Azulejo Cycling Recipes + for (int i = 0; i < 12; i++) + GameRegistry.addShapelessRecipe( + new ItemStack(ModBlocks.customBrick, 1, 4 + (i == 11 ? 0 : i + 1)), + new ItemStack(ModBlocks.customBrick, 1, 4 + i)); + recipesAzulejoCycling = BotaniaAPI.getLatestAddedRecipes(12); + + // Ender Overseer Recipe + GameRegistry.addRecipe(new ShapedOreRecipe( + new ItemStack(ModBlocks.enderEye), + "RER", + "EOE", + "RER", + 'R', + "dustRedstone", + 'E', + new ItemStack(Items.ender_eye), + 'O', + new ItemStack(Blocks.obsidian))); + recipeEnderEyeBlock = BotaniaAPI.getLatestAddedRecipe(); + + // The Spectator Recipe + addOreDictRecipe( + new ItemStack(ModItems.itemFinder), + " I ", + "IYI", + "IEI", + 'I', + "ingotIron", + 'Y', + new ItemStack(Items.ender_eye), + 'E', + "gemEmerald"); + recipeItemFinder = BotaniaAPI.getLatestAddedRecipe(); + + // Crimson Pendant Recipe + addOreDictRecipe( + new ItemStack(ModItems.superLavaPendant), + "BBB", + "BPB", + "NGN", + 'B', + new ItemStack(Items.blaze_rod), + 'P', + new ItemStack(ModItems.lavaPendant), + 'N', + new ItemStack(Blocks.nether_brick), + 'G', + LibOreDict.LIFE_ESSENCE); + recipeSuperLavaPendant = BotaniaAPI.getLatestAddedRecipe(); + + // Hand of Ender Recipe + addOreDictRecipe( + new ItemStack(ModItems.enderHand), + "PLO", + "LEL", + "OL ", + 'P', + LibOreDict.MANA_PEARL, + 'L', + new ItemStack(Items.leather), + 'E', + new ItemStack(Blocks.ender_chest), + 'O', + new ItemStack(Blocks.obsidian)); + recipeEnderHand = BotaniaAPI.getLatestAddedRecipe(); + + // Vitreous Pickaxe Recipe + addOreDictRecipe( + new ItemStack(ModItems.glassPick), + "GIG", + " T ", + " T ", + 'G', + "blockGlassColorless", + 'I', + LibOreDict.MANA_STEEL, + 'T', + LibOreDict.LIVINGWOOD_TWIG); + recipeGlassPick = BotaniaAPI.getLatestAddedRecipe(); + + // Starfield Creator Recipe + addOreDictRecipe( + new ItemStack(ModBlocks.starfield), + "EPE", + "EOE", + 'E', + LibOreDict.ELEMENTIUM, + 'P', + LibOreDict.PIXIE_DUST, + 'O', + new ItemStack(Blocks.obsidian)); + recipeStarfield = BotaniaAPI.getLatestAddedRecipe(); + + // Spark Recipe + for (int i = 0; i < 16; i++) + addOreDictRecipe( + new ItemStack(ModItems.spark), + " P ", + "BNB", + " P ", + 'B', + new ItemStack(Items.blaze_powder), + 'P', + LibOreDict.PETAL[i], + 'N', + "nuggetGold"); + recipesSpark = BotaniaAPI.getLatestAddedRecipes(16); + + // Spark Augment Recipes + for (int i = 0; i < 4; i++) + addShapelessOreDictRecipe( + new ItemStack(ModItems.sparkUpgrade, 1, i), + LibOreDict.PIXIE_DUST, + LibOreDict.MANA_STEEL, + LibOreDict.RUNE[i]); + recipesSparkUpgrades = BotaniaAPI.getLatestAddedRecipes(4); + + // Horn of the Canopy Recipe + addShapelessOreDictRecipe( + new ItemStack(ModItems.grassHorn, 1, 1), new ItemStack(ModItems.grassHorn), "treeLeaves"); + recipeLeafHorn = BotaniaAPI.getLatestAddedRecipe(); + + // Rod of Divining Recipe + addOreDictRecipe( + new ItemStack(ModItems.diviningRod), + " TD", + " TT", + "T ", + 'T', + LibOreDict.LIVINGWOOD_TWIG, + 'D', + LibOreDict.MANA_DIAMOND); + recipeDiviningRod = BotaniaAPI.getLatestAddedRecipe(); + + // Rod of the Black Mesa Recipe + addOreDictRecipe( + new ItemStack(ModItems.gravityRod), + " TD", + " WT", + "T ", + 'T', + LibOreDict.DREAMWOOD_TWIG, + 'W', + "cropWheat", + 'D', + LibOreDict.DRAGONSTONE); + recipeGravityRod = BotaniaAPI.getLatestAddedRecipe(); + + // Timeless Ivy Recipe + addShapelessOreDictRecipe( + new ItemStack(ModItems.regenIvy), + new ItemStack(Blocks.vine), + LibOreDict.LIFE_ESSENCE, + LibOreDict.ELEMENTIUM); + recipeRegenIvy = BotaniaAPI.getLatestAddedRecipe(); + + // Gaia Mana Spreader Recipe + addOreDictRecipe( + new ItemStack(ModBlocks.spreader, 1, 3), + "ESD", + 'E', + LibOreDict.LIFE_ESSENCE, + 'S', + new ItemStack(ModBlocks.spreader, 1, 2), + 'D', + LibOreDict.DRAGONSTONE); + recipeUltraSpreader = BotaniaAPI.getLatestAddedRecipe(); + + // Wing Recipes + GameRegistry.addRecipe(new ShapelessOreRecipe( + new ItemStack(ModItems.flightTiara, 1, 1), + new ItemStack(ModItems.flightTiara, 1, Short.MAX_VALUE), + "gemQuartz")); + for (int i = 0; i < 7; i++) + GameRegistry.addRecipe(new ShapelessOreRecipe( + new ItemStack(ModItems.flightTiara, 1, 2 + i), + new ItemStack(ModItems.flightTiara, 1, Short.MAX_VALUE), + LibOreDict.QUARTZ[i])); + recipesWings = BotaniaAPI.getLatestAddedRecipes(8); + + // Mana Fluxfield Recipe + if (ConfigHandler.fluxfieldEnabled) { + addOreDictRecipe( + new ItemStack(ModBlocks.rfGenerator), + "SRS", + "RMR", + "SRS", + 'S', + LibOreDict.LIVING_ROCK, + 'M', + LibOreDict.MANA_STEEL, + 'R', + "blockRedstone"); + recipeRFGenerator = BotaniaAPI.getLatestAddedRecipe(); + } + + // Vial Recipe + GameRegistry.addRecipe( + new ItemStack(ModItems.vial, 3, 0), "G G", " G ", 'G', new ItemStack(ModBlocks.manaGlass)); + recipeVial = BotaniaAPI.getLatestAddedRecipe(); + + // Flask Recipe + GameRegistry.addRecipe( + new ItemStack(ModItems.vial, 3, 1), "G G", " G ", 'G', new ItemStack(ModBlocks.elfGlass)); + recipeFlask = BotaniaAPI.getLatestAddedRecipe(); + + // Botanical Brewery Recipe + addOreDictRecipe( + new ItemStack(ModBlocks.brewery), + "RSR", + "RAR", + "RMR", + 'R', + LibOreDict.LIVING_ROCK, + 'S', + new ItemStack(Items.brewing_stand), + 'A', + LibOreDict.RUNE[8], + 'M', + new ItemStack(ModBlocks.storage)); + recipeBrewery = BotaniaAPI.getLatestAddedRecipe(); + + // Tainted Blood Pendant Recipe + addOreDictRecipe( + new ItemStack(ModItems.bloodPendant), + " P ", + "PGP", + "DP ", + 'P', + LibOreDict.PRISMARINE_SHARD, + 'G', + new ItemStack(Items.ghast_tear), + 'D', + LibOreDict.MANA_DIAMOND); + recipeBloodPendant = BotaniaAPI.getLatestAddedRecipe(); + + // Terrestrial Agglomeration Plate Recipe + addOreDictRecipe( + new ItemStack(ModBlocks.terraPlate), + "LLL", + "0M1", + "283", + 'L', + "blockLapis", + 'M', + new ItemStack(ModBlocks.storage), + '0', + LibOreDict.RUNE[0], + '1', + LibOreDict.RUNE[1], + '2', + LibOreDict.RUNE[2], + '3', + LibOreDict.RUNE[3], + '8', + LibOreDict.RUNE[8]); + recipeTerraPlate = BotaniaAPI.getLatestAddedRecipe(); + + // Red String Recipe + addShapelessOreDictRecipe( + new ItemStack(ModItems.manaResource, 1, 12), + new ItemStack(Items.string), + "blockRedstone", + LibOreDict.PIXIE_DUST, + LibOreDict.ENDER_AIR_BOTTLE); + recipeRedString = BotaniaAPI.getLatestAddedRecipe(); + // Are you in a pinch? + addShapelessOreDictRecipe( + new ItemStack(ModItems.manaResource, 1, 12), + new ItemStack(Items.string), + "blockRedstone", + LibOreDict.PIXIE_DUST, + LibOreDict.ENDER_AIR_BOTTLE, + new ItemStack(Blocks.pumpkin)); + + // Red String Container Recipe + addOreDictRecipe( + new ItemStack(ModBlocks.redStringContainer), + "RRR", + "RCS", + "RRR", + 'R', + LibOreDict.LIVING_ROCK, + 'S', + LibOreDict.RED_STRING, + 'C', + "chestWood"); + recipeRedStringContainer = BotaniaAPI.getLatestAddedRecipe(); + + // Red String Dispenser Recipe + addOreDictRecipe( + new ItemStack(ModBlocks.redStringDispenser), + "RRR", + "RDS", + "RRR", + 'R', + LibOreDict.LIVING_ROCK, + 'S', + LibOreDict.RED_STRING, + 'D', + new ItemStack(Blocks.dispenser)); + recipeRedStringDispenser = BotaniaAPI.getLatestAddedRecipe(); + + // Red String Fertilizer Recipe + addOreDictRecipe( + new ItemStack(ModBlocks.redStringFertilizer), + "RRR", + "RBS", + "RRR", + 'R', + LibOreDict.LIVING_ROCK, + 'S', + LibOreDict.RED_STRING, + 'B', + new ItemStack(ModItems.fertilizer)); + recipeRedStringFertilizer = BotaniaAPI.getLatestAddedRecipe(); + + // Red String Comparator Recipe + addOreDictRecipe( + new ItemStack(ModBlocks.redStringComparator), + "RRR", + "RCS", + "RRR", + 'R', + LibOreDict.LIVING_ROCK, + 'S', + LibOreDict.RED_STRING, + 'C', + new ItemStack(Items.comparator)); + recipeRedStringComparator = BotaniaAPI.getLatestAddedRecipe(); + + // Red String Spoofer Recipe + addOreDictRecipe( + new ItemStack(ModBlocks.redStringRelay), + "RRR", + "RMS", + "RRR", + 'R', + LibOreDict.LIVING_ROCK, + 'S', + LibOreDict.RED_STRING, + 'M', + new ItemStack(ModBlocks.spreader)); + recipeRedStringRelay = BotaniaAPI.getLatestAddedRecipe(); + + // Red String Interceptor Recipe + addOreDictRecipe( + new ItemStack(ModBlocks.redStringInterceptor), + "RRR", + "RMS", + "RRR", + 'R', + LibOreDict.LIVING_ROCK, + 'S', + LibOreDict.RED_STRING, + 'M', + new ItemStack(Blocks.stone_button)); + recipeRedStringInterceptor = BotaniaAPI.getLatestAddedRecipe(); + + // Rod of the Arcane Barrage Recipe + addOreDictRecipe( + new ItemStack(ModItems.missileRod), + "GDD", + " TD", + "T G", + 'G', + LibOreDict.LIFE_ESSENCE, + 'D', + LibOreDict.DRAGONSTONE, + 'T', + LibOreDict.DREAMWOOD_TWIG); + recipeMissileRod = BotaniaAPI.getLatestAddedRecipe(); + + // Cloak of Virtue Recipe + addOreDictRecipe( + new ItemStack(ModItems.holyCloak), + "WWW", + "GWG", + "GSG", + 'W', + new ItemStack(Blocks.wool), + 'G', + "dustGlowstone", + 'S', + LibOreDict.LIFE_ESSENCE); + recipeHolyCloak = BotaniaAPI.getLatestAddedRecipe(); + + // Cloak of Sin Recipe + addOreDictRecipe( + new ItemStack(ModItems.unholyCloak), + "WWW", + "RWR", + "RSR", + 'W', + new ItemStack(Blocks.wool, 1, 15), + 'R', + "dustRedstone", + 'S', + LibOreDict.LIFE_ESSENCE); + recipeUnholyCloak = BotaniaAPI.getLatestAddedRecipe(); + + // Assembly Halo Recipe + addOreDictRecipe( + new ItemStack(ModItems.craftingHalo), + " P ", + "ICI", + " I ", + 'P', + LibOreDict.MANA_PEARL, + 'I', + LibOreDict.MANA_STEEL, + 'C', + "craftingTableWood"); + recipeCraftingHalo = BotaniaAPI.getLatestAddedRecipe(); + + // Mana Lens: Flash Recipe + GameRegistry.addRecipe(new ShapedOreRecipe( + new ItemStack(ModItems.lens, 1, 17), + "GFG", + "FLF", + "GFG", + 'G', + "glowstone", + 'F', + new ItemStack(Items.fire_charge), + 'L', + new ItemStack(ModItems.lens))); + GameRegistry.addRecipe(new ShapedOreRecipe( + new ItemStack(ModItems.lens, 1, 17), + "FGF", + "GLG", + "FGF", + 'G', + "glowstone", + 'F', + new ItemStack(Items.fire_charge), + 'L', + new ItemStack(ModItems.lens))); + recipesLensFlash = BotaniaAPI.getLatestAddedRecipes(2); + + // Mana Prism Recipe + addOreDictRecipe( + new ItemStack(ModBlocks.prism), + "GPG", + "GSG", + "GPG", + 'G', + "blockGlassColorless", + 'P', + LibOreDict.PRISMARINE_SHARD, + 'S', + new ItemStack(ModBlocks.platform, 1, 1)); + recipePrism = BotaniaAPI.getLatestAddedRecipe(); + + // Trodden Dirt Recipe + GameRegistry.addRecipe(new ShapelessOreRecipe( + new ItemStack(ModBlocks.dirtPath, 4), + new ItemStack(Blocks.dirt, 1, 1), + new ItemStack(Blocks.dirt, 1, 1), + new ItemStack(Blocks.dirt, 1, 1), + "sand")); + recipeDirtPath = BotaniaAPI.getLatestAddedRecipe(); + + // Dreamwood Twig Recipe + addOreDictRecipe(new ItemStack(ModItems.manaResource, 1, 13), "W", "W", 'W', LibOreDict.DREAM_WOOD); + recipeDreamwoodTwig = BotaniaAPI.getLatestAddedRecipe(); + + // Manaseer Monocle Recipe + addOreDictRecipe( + new ItemStack(ModItems.monocle), + "GN", + "IN", + " N", + 'G', + new ItemStack(ModBlocks.manaGlass), + 'I', + LibOreDict.MANA_STEEL, + 'N', + new ItemStack(Items.gold_nugget)); + recipeMonocle = BotaniaAPI.getLatestAddedRecipe(); + + // Lens Clip Recipe + addOreDictRecipe(new ItemStack(ModItems.clip), " D ", "D D", "DD ", 'D', LibOreDict.DREAM_WOOD); + recipeClip = BotaniaAPI.getLatestAddedRecipe(); + + // Rod of the Depths Recipe + addOreDictRecipe( + new ItemStack(ModItems.cobbleRod), + " FC", + " TW", + "T ", + 'F', + LibOreDict.RUNE[1], + 'W', + LibOreDict.RUNE[0], + 'T', + LibOreDict.LIVINGWOOD_TWIG, + 'C', + "cobblestone"); + recipeCobbleRod = BotaniaAPI.getLatestAddedRecipe(); + + // Rod of the Molten Core Recipe + addOreDictRecipe( + new ItemStack(ModItems.smeltRod), + " BF", + " TB", + "T ", + 'B', + new ItemStack(Items.blaze_rod), + 'F', + LibOreDict.RUNE[1], + 'T', + LibOreDict.LIVINGWOOD_TWIG); + recipeSmeltRod = BotaniaAPI.getLatestAddedRecipe(); + + // World Seed Recipe + addOreDictRecipe( + new ItemStack(ModItems.worldSeed, 4), + "G", + "S", + "D", + 'G', + new ItemStack(Blocks.grass), + 'S', + new ItemStack(Items.wheat_seeds), + 'D', + LibOreDict.DRAGONSTONE); + recipeWorldSeed = BotaniaAPI.getLatestAddedRecipe(); + + // Spellbinding Cloth Recipe + addOreDictRecipe( + new ItemStack(ModItems.spellCloth), + " C ", + "CPC", + " C ", + 'C', + LibOreDict.MANAWEAVE_CLOTH, + 'P', + LibOreDict.MANA_PEARL); + recipeSpellCloth = BotaniaAPI.getLatestAddedRecipe(); + + // Thorn Chakram Recipe + addOreDictRecipe( + new ItemStack(ModItems.thornChakram, 2), + "VVV", + "VTV", + "VVV", + 'V', + new ItemStack(Blocks.vine), + 'T', + LibOreDict.TERRA_STEEL); + recipeThornChakram = BotaniaAPI.getLatestAddedRecipe(); + + // Trodden Dirt Slab + GameRegistry.addRecipe( + new ItemStack(ModFluffBlocks.dirtPathSlab, 6), "DDD", 'D', new ItemStack(ModBlocks.dirtPath)); + recipeDirtPathSlab = BotaniaAPI.getLatestAddedRecipe(); + + // Pattern Recipes + { + int count = TileCraftCrate.PATTERNS.length; + List recipeObjects = Arrays.asList(new Object[] {'R', "dustRedstone", 'P', LibOreDict.PLACEHOLDER}); + + for (int i = 0; i < count; i++) { + List recipe = new ArrayList(); + for (int j = 0; j < 3; j++) { + String s = ""; + for (int k = 0; k < 3; k++) s += TileCraftCrate.PATTERNS[i][j * 3 + k] ? "R" : "P"; + recipe.add(s); + } + recipe.addAll(recipeObjects); + + addOreDictRecipe(new ItemStack(ModItems.craftPattern, 1, i), recipe.toArray(new Object[recipe.size()])); + } + + recipesPatterns = BotaniaAPI.getLatestAddedRecipes(count); + } + + // Gaia Spirit Ingot Recipe + addOreDictRecipe( + new ItemStack(ModItems.manaResource, 1, 14), + " S ", + "SIS", + " S ", + 'S', + LibOreDict.LIFE_ESSENCE, + 'I', + LibOreDict.TERRA_STEEL); + recipeGaiaIngot = BotaniaAPI.getLatestAddedRecipe(); + + // Corporea Spark Recipe + addShapelessOreDictRecipe( + new ItemStack(ModItems.corporeaSpark), + new ItemStack(ModItems.spark), + LibOreDict.PIXIE_DUST, + LibOreDict.ENDER_AIR_BOTTLE); + recipeCorporeaSpark = BotaniaAPI.getLatestAddedRecipe(); + + // Master Corporea Spark Recipe + addShapelessOreDictRecipe( + new ItemStack(ModItems.corporeaSpark, 1, 1), + new ItemStack(ModItems.corporeaSpark), + LibOreDict.DRAGONSTONE); + recipeMasterCorporeaSpark = BotaniaAPI.getLatestAddedRecipe(); + + // Corporea Index Recipe + addOreDictRecipe( + new ItemStack(ModBlocks.corporeaIndex), + "AOA", + "OSO", + "DOD", + 'A', + LibOreDict.ENDER_AIR_BOTTLE, + 'O', + new ItemStack(Blocks.obsidian), + 'S', + new ItemStack(ModItems.corporeaSpark), + 'D', + LibOreDict.DRAGONSTONE); + recipeCorporeaIndex = BotaniaAPI.getLatestAddedRecipe(); + + // Corporea Funnel Recipe + addShapelessOreDictRecipe( + new ItemStack(ModBlocks.corporeaFunnel), + new ItemStack(Blocks.dropper), + new ItemStack(ModItems.corporeaSpark)); + recipeCorporeaFunnel = BotaniaAPI.getLatestAddedRecipe(); + + // Corporea Interceptor Recipe + addShapelessOreDictRecipe( + new ItemStack(ModBlocks.corporeaInterceptor), "blockRedstone", new ItemStack(ModItems.corporeaSpark)); + recipeCorporeaInterceptor = BotaniaAPI.getLatestAddedRecipe(); + + // End Stone Brick Recipes + if (ConfigHandler.enderStuff19Enabled) { + GameRegistry.addRecipe( + new ItemStack(ModBlocks.endStoneBrick, 4), "SS", "SS", 'S', new ItemStack(Blocks.end_stone)); + recipeEndStoneBricks = BotaniaAPI.getLatestAddedRecipe(); + + GameRegistry.addRecipe( + new ItemStack(ModBlocks.endStoneBrick, 1, 1), + "S", + "S", + 'S', + new ItemStack(ModFluffBlocks.endStoneSlab)); + recipeEndStoneChiseledBricks = BotaniaAPI.getLatestAddedRecipe(); + + GameRegistry.addRecipe( + new ItemStack(ModBlocks.endStoneBrick, 4, 2), + " B ", + "BPB", + " B ", + 'B', + new ItemStack(ModBlocks.endStoneBrick), + 'P', + new ItemStack(Items.ender_pearl)); + recipeEnderBricks = BotaniaAPI.getLatestAddedRecipe(); + + GameRegistry.addRecipe( + new ItemStack(ModBlocks.endStoneBrick, 2, 3), + "B", + "B", + 'B', + new ItemStack(ModBlocks.endStoneBrick, 1, 2)); + recipePillarEnderBricks = BotaniaAPI.getLatestAddedRecipe(); + } + + // Livingwood Bow Recipe + addOreDictRecipe( + new ItemStack(ModItems.livingwoodBow), + " TS", + "T S", + " TS", + 'T', + LibOreDict.LIVINGWOOD_TWIG, + 'S', + LibOreDict.MANA_STRING); + recipeLivingwoodBow = BotaniaAPI.getLatestAddedRecipe(); + + // Crystal Bow Recipe + addOreDictRecipe( + new ItemStack(ModItems.crystalBow), + " DS", + "T S", + " DS", + 'T', + LibOreDict.LIVINGWOOD_TWIG, + 'D', + LibOreDict.DRAGONSTONE, + 'S', + LibOreDict.MANA_STRING); + recipeCrystalBow = BotaniaAPI.getLatestAddedRecipe(); + + // Cosmetic Items Recipes + for (int i = 0; i < 32; i++) + addOreDictRecipe( + new ItemStack(ModItems.cosmetic, 1, i), + "PPP", + "PSP", + "PPP", + 'P', + new ItemStack(i < 16 ? ModItems.petal : ModItems.dye, 1, i % 16), + 'S', + LibOreDict.MANA_STRING); + recipesCosmeticItems = BotaniaAPI.getLatestAddedRecipes(32); + + // Shimmering Mushroom Recipes + for (int i = 0; i < 16; i++) { + GameRegistry.addShapelessRecipe( + new ItemStack(ModBlocks.mushroom, 1, i), + new ItemStack(Blocks.red_mushroom), + new ItemStack(ModItems.dye, 1, i)); + GameRegistry.addShapelessRecipe( + new ItemStack(ModBlocks.mushroom, 1, i), + new ItemStack(Blocks.brown_mushroom), + new ItemStack(ModItems.dye, 1, i)); + } + recipesMushrooms = BotaniaAPI.getLatestAddedRecipes(32); + GameRegistry.addShapelessRecipe( + new ItemStack(Items.mushroom_stew), + new ItemStack(ModBlocks.mushroom, 1, Short.MAX_VALUE), + new ItemStack(ModBlocks.mushroom, 1, Short.MAX_VALUE), + new ItemStack(Items.bowl)); + + // Ring of Correction Recipe + addOreDictRecipe( + new ItemStack(ModItems.swapRing), + "CM ", + "M M", + " M ", + 'C', + new ItemStack(Blocks.clay), + 'M', + LibOreDict.MANA_STEEL); + recipeSwapRing = BotaniaAPI.getLatestAddedRecipe(); + + // Horn of the Covering Recipe + addShapelessOreDictRecipe( + new ItemStack(ModItems.grassHorn, 1, 2), + new ItemStack(ModItems.grassHorn), + new ItemStack(Items.snowball)); + recipeSnowHorn = BotaniaAPI.getLatestAddedRecipe(); + + // Flower Pouch Recipe + GameRegistry.addShapedRecipe( + new ItemStack(ModItems.flowerBag), + "WPW", + "W W", + " W ", + 'P', + new ItemStack(ModItems.petal, 1, Short.MAX_VALUE), + 'W', + new ItemStack(Blocks.wool, 1, Short.MAX_VALUE)); + recipeFlowerBag = BotaniaAPI.getLatestAddedRecipe(); + + // Phantom Ink Recipe + addShapelessOreDictRecipe( + new ItemStack(ModItems.phantomInk, 4), + LibOreDict.MANA_PEARL, + "dye", + "blockGlass", + new ItemStack(Items.glass_bottle), + new ItemStack(Items.glass_bottle), + new ItemStack(Items.glass_bottle), + new ItemStack(Items.glass_bottle)); + recipePhantomInk = BotaniaAPI.getLatestAddedRecipe(); + + // Minecart with Mana Pool Recipe + GameRegistry.addShapelessRecipe( + new ItemStack(ModItems.poolMinecart), new ItemStack(Items.minecart), new ItemStack(ModBlocks.pool)); + recipePoolCart = BotaniaAPI.getLatestAddedRecipe(); + + // Mana Pump Recipe + addOreDictRecipe( + new ItemStack(ModBlocks.pump), + "SSS", + "IBI", + "SSS", + 'S', + LibOreDict.LIVING_ROCK, + 'I', + LibOreDict.MANA_STEEL, + 'B', + new ItemStack(Items.bucket)); + recipePump = BotaniaAPI.getLatestAddedRecipe(); + + // Double Petal Recipes + for (int i = 0; i < 16; i++) + addShapelessOreDictRecipe(new ItemStack(ModItems.petal, 4, i), LibOreDict.DOUBLE_FLOWER[i]); + recipesPetalsDouble = BotaniaAPI.getLatestAddedRecipes(16); + + // Resolute Ivy Recipe + addShapelessOreDictRecipe( + new ItemStack(ModItems.keepIvy), + LibOreDict.PIXIE_DUST, + new ItemStack(Blocks.vine), + LibOreDict.ENDER_AIR_BOTTLE); + recipeKeepIvy = BotaniaAPI.getLatestAddedRecipe(); + + // Black Hole Talisman Recipe + addOreDictRecipe( + new ItemStack(ModItems.blackHoleTalisman), + " G ", + "EAE", + " E ", + 'G', + LibOreDict.LIFE_ESSENCE, + 'E', + LibOreDict.ELEMENTIUM, + 'A', + LibOreDict.ENDER_AIR_BOTTLE); + recipeBlackHoleTalisman = BotaniaAPI.getLatestAddedRecipe(); + + // 1.8 Stone Recipes + recipe18StonePolish = new ArrayList(); + recipe18StoneBrick = new ArrayList(); + recipe18StoneChisel = new ArrayList(); + for (int i = 0; i < 4; i++) { + addOreDictRecipe( + new ItemStack(ModFluffBlocks.stone, 8, i + 4), + "SSS", + "S S", + "SSS", + 'S', + LibOreDict.STONE_18_VARIANTS[i]); + recipe18StonePolish.add(BotaniaAPI.getLatestAddedRecipe()); + + addOreDictRecipe( + new ItemStack(ModFluffBlocks.stone, 4, i + 8), "SS", "SS", 'S', LibOreDict.STONE_18_VARIANTS[i]); + recipe18StoneBrick.add(BotaniaAPI.getLatestAddedRecipe()); + + addOreDictRecipe( + new ItemStack(ModFluffBlocks.stone, 1, i + 12), + "S", + "S", + 'S', + new ItemStack(ModFluffBlocks.stoneSlabs[i + 4], 1, 0)); + recipe18StoneChisel.add(BotaniaAPI.getLatestAddedRecipe()); + } + + // Blaze Light Recipe + addOreDictRecipe( + new ItemStack(ModBlocks.blazeBlock), + "BBB", + "BBB", + "BBB", + 'B', + Botania.gardenOfGlassLoaded ? "powderBlaze" : "rodBlaze"); + recipeBlazeBlock = BotaniaAPI.getLatestAddedRecipe(); + addShapelessOreDictRecipe( + new ItemStack(Botania.gardenOfGlassLoaded ? Items.blaze_powder : Items.blaze_rod, 9), + LibOreDict.BLAZE_BLOCK); + + // Metamorphic Petal Apothecary Recipes + for (int i = 0; i < 8; i++) + GameRegistry.addRecipe( + new ItemStack(ModBlocks.altar, 1, i + 1), + "SSS", + "SAS", + "SSS", + 'S', + new ItemStack(ModFluffBlocks.biomeStoneA, 1, i + 8), + 'A', + new ItemStack(ModBlocks.altar)); + recipesAltarMeta = BotaniaAPI.getLatestAddedRecipes(8); + + // Corporea Crystal Cube Recipe + addOreDictRecipe( + new ItemStack(ModBlocks.corporeaCrystalCube), + "C", + "G", + "W", + 'C', + new ItemStack(ModItems.corporeaSpark), + 'G', + new ItemStack(ModBlocks.elfGlass), + 'W', + LibOreDict.DREAM_WOOD); + recipeCorporeaCrystalCube = BotaniaAPI.getLatestAddedRecipe(); + + // Stone of Temperance Recipe + addOreDictRecipe( + new ItemStack(ModItems.temperanceStone), " S ", "SRS", " S ", 'S', "stone", 'R', LibOreDict.RUNE[2]); + recipeTemperanceStone = BotaniaAPI.getLatestAddedRecipe(); + + // Incense Stick Recipe + addOreDictRecipe( + new ItemStack(ModItems.incenseStick), + " G", + " B ", + "T ", + 'G', + new ItemStack(Items.ghast_tear), + 'B', + new ItemStack(Items.blaze_powder), + 'T', + LibOreDict.LIVINGWOOD_TWIG); + recipeIncenseStick = BotaniaAPI.getLatestAddedRecipe(); + + // Incense Plate Recipe + addOreDictRecipe( + new ItemStack(ModBlocks.incensePlate), + "WSS", + 'W', + LibOreDict.LIVING_WOOD, + 'S', + new ItemStack(ModFluffBlocks.livingwoodSlab)); + recipeIncensePlate = BotaniaAPI.getLatestAddedRecipe(); + + // Terra Truncator Recipe + addOreDictRecipe( + new ItemStack(ModItems.terraAxe), + "TTG", + "TST", + " S ", + 'T', + LibOreDict.TERRA_STEEL, + 'G', + "glowstone", + 'S', + LibOreDict.LIVINGWOOD_TWIG); + recipeTerraAxe = BotaniaAPI.getLatestAddedRecipe(); + + // Hovering Hourglass Recipe + addOreDictRecipe( + new ItemStack(ModBlocks.hourglass), + "GMG", + "RSR", + "GMG", + 'G', + "ingotGold", + 'M', + new ItemStack(ModBlocks.manaGlass), + 'R', + "dustRedstone", + 'S', + LibOreDict.MANA_STEEL); + recipeHourglass = BotaniaAPI.getLatestAddedRecipe(); + + // Spectral Rail Recipe + GameRegistry.addShapelessRecipe( + new ItemStack(ModBlocks.ghostRail), + new ItemStack(Blocks.rail), + new ItemStack(ModBlocks.platform, 1, 1)); + recipeGhostRail = BotaniaAPI.getLatestAddedRecipe(); + + // Drum of the Canopy Recipe + addOreDictRecipe( + new ItemStack(ModBlocks.forestDrum, 1, 2), + "WLW", + "WHW", + "WLW", + 'W', + LibOreDict.LIVING_WOOD, + 'L', + new ItemStack(Items.leather), + 'H', + new ItemStack(ModItems.grassHorn, 1, 1)); + recipeCanopyDrum = BotaniaAPI.getLatestAddedRecipe(); + + // Spark Changer Recipe + addOreDictRecipe( + new ItemStack(ModBlocks.sparkChanger), + "ESE", + "SRS", + 'S', + LibOreDict.LIVING_ROCK, + 'E', + LibOreDict.ELEMENTIUM, + 'R', + "dustRedstone"); + recipeSparkChanger = BotaniaAPI.getLatestAddedRecipe(); + + // Cocoon of Caprice Recipe + if (Botania.gardenOfGlassLoaded) + addOreDictRecipe( + new ItemStack(ModBlocks.cocoon), + "SSS", + "SFS", + "SIS", + 'S', + new ItemStack(Items.string), + 'F', + new ItemStack(ModBlocks.felPumpkin), + 'I', + LibOreDict.MANA_STEEL); + else + addOreDictRecipe( + new ItemStack(ModBlocks.cocoon), + "SSS", + "SPS", + "SDS", + 'S', + new ItemStack(Items.string), + 'P', + LibOreDict.PIXIE_DUST, + 'D', + LibOreDict.DRAGONSTONE); + recipeCocoon = BotaniaAPI.getLatestAddedRecipe(); + + // Fel Pumpkin + GameRegistry.addRecipe( + new ItemStack(ModBlocks.felPumpkin), + " S ", + "BPF", + " G ", + 'S', + new ItemStack(Items.string), + 'B', + new ItemStack(Items.bone), + 'P', + new ItemStack(Blocks.pumpkin), + 'F', + new ItemStack(Items.rotten_flesh), + 'G', + new ItemStack(Items.gunpowder)); + recipeFelPumpkin = BotaniaAPI.getLatestAddedRecipe(); + + // Luminizer Recipe + addShapelessOreDictRecipe( + new ItemStack(ModBlocks.lightRelay), + LibOreDict.RED_STRING, + LibOreDict.DRAGONSTONE, + "dustGlowstone", + "dustGlowstone"); + recipeLuminizer = BotaniaAPI.getLatestAddedRecipe(); + + // Detector Luminizer Recipe + addShapelessOreDictRecipe( + new ItemStack(ModBlocks.lightRelay, 1, 1), new ItemStack(ModBlocks.lightRelay), "dustRedstone"); + recipeDetectorLuminizer = BotaniaAPI.getLatestAddedRecipe(); + + // Luminizer Launcher Recipe + addOreDictRecipe( + new ItemStack(ModBlocks.lightLauncher), + "DDD", + "DLD", + 'D', + LibOreDict.DREAM_WOOD, + 'L', + new ItemStack(ModBlocks.lightRelay)); + recipeLuminizerLauncher = BotaniaAPI.getLatestAddedRecipe(); + + // Floral Obedience Stick Recipe + addOreDictRecipe( + new ItemStack(ModItems.obedienceStick), + " M", + " T ", + "T ", + 'M', + LibOreDict.MANA_STEEL, + 'T', + LibOreDict.LIVINGWOOD_TWIG); + recipeObedienceStick = BotaniaAPI.getLatestAddedRecipe(); + + // Cacophonium Recipe + if (OreDictionary.getOres("ingotBrass").isEmpty()) + addOreDictRecipe( + new ItemStack(ModItems.cacophonium), + " G ", + "GNG", + "GG ", + 'G', + "ingotGold", + 'N', + new ItemStack(Blocks.noteblock)); + else + addOreDictRecipe( + new ItemStack(ModItems.cacophonium), + " G ", + "GNG", + "GG ", + 'G', + "ingotBrass", + 'N', + new ItemStack(Blocks.noteblock)); + recipeCacophonium = BotaniaAPI.getLatestAddedRecipe(); + + // Manastorm Charge Recipe + addOreDictRecipe( + new ItemStack(ModBlocks.manaBomb), + "LTL", + "TGT", + "LTL", + 'L', + LibOreDict.LIVING_WOOD, + 'T', + new ItemStack(Blocks.tnt), + 'G', + LibOreDict.LIFE_ESSENCE); + recipeManaBomb = BotaniaAPI.getLatestAddedRecipe(); + + // Cobweb Recipe + addOreDictRecipe( + new ItemStack(Blocks.web), + "S S", + " M ", + "S S", + 'S', + new ItemStack(Items.string), + 'M', + LibOreDict.MANA_STRING); + recipeCobweb = BotaniaAPI.getLatestAddedRecipe(); + + // Slime in a Bottle Recipe + addOreDictRecipe( + new ItemStack(ModItems.slimeBottle), + "EGE", + "ESE", + " E ", + 'E', + LibOreDict.ELEMENTIUM, + 'G', + new ItemStack(ModBlocks.elfGlass), + 'S', + "slimeball"); + recipeSlimeBottle = BotaniaAPI.getLatestAddedRecipe(); + + // Starcaller Recipe + addOreDictRecipe( + new ItemStack(ModItems.starSword), + " I", + "AD ", + "TA ", + 'I', + LibOreDict.ELEMENTIUM, + 'D', + LibOreDict.DRAGONSTONE, + 'A', + LibOreDict.ENDER_AIR_BOTTLE, + 'T', + new ItemStack(ModItems.terraSword)); + recipeStarSword = BotaniaAPI.getLatestAddedRecipe(); + + // Rod of the Shifting Crust Recipe + addOreDictRecipe( + new ItemStack(ModItems.exchangeRod), + " SR", + " TS", + "T ", + 'T', + LibOreDict.LIVINGWOOD_TWIG, + 'S', + "stone", + 'R', + LibOreDict.RUNE[12]); + recipeExchangeRod = BotaniaAPI.getLatestAddedRecipe(); + + // Greater Ring of Magnetization Recipe + addShapelessOreDictRecipe( + new ItemStack(ModItems.magnetRingGreater), LibOreDict.TERRA_STEEL, new ItemStack(ModItems.magnetRing)); + recipeGreaterMagnetRing = BotaniaAPI.getLatestAddedRecipe(); + + // Flare Chakram Recipe + addOreDictRecipe( + new ItemStack(ModItems.thornChakram, 2, 1), + "BBB", + "CPC", + "BBB", + 'B', + new ItemStack(Items.blaze_powder), + 'P', + LibOreDict.PIXIE_DUST, + 'C', + new ItemStack(ModItems.thornChakram)); + recipeFireChakram = BotaniaAPI.getLatestAddedRecipe(); + + // Thundercaller Recipe + addOreDictRecipe( + new ItemStack(ModItems.thunderSword), + " I", + "AD ", + "TA ", + 'I', + LibOreDict.ELEMENTIUM, + 'D', + LibOreDict.MANA_DIAMOND, + 'A', + LibOreDict.ENDER_AIR_BOTTLE, + 'T', + new ItemStack(ModItems.terraSword)); + recipeThunderSword = BotaniaAPI.getLatestAddedRecipe(); + + // Manatide Bellows Recipe + addOreDictRecipe( + new ItemStack(ModBlocks.bellows), + "SSS", + "RL ", + "SSS", + 'S', + new ItemStack(ModFluffBlocks.livingwoodSlab), + 'R', + LibOreDict.RUNE[3], + 'L', + new ItemStack(Items.leather)); + recipeBellows = BotaniaAPI.getLatestAddedRecipe(); + + // Manaweave Cloth Recipe + addOreDictRecipe(new ItemStack(ModItems.manaResource, 1, 22), "SS", "SS", 'S', LibOreDict.MANA_STRING); + recipeManaweaveCloth = BotaniaAPI.getLatestAddedRecipe(); + + // Manaweave Armor Recipes + addOreDictRecipe(new ItemStack(ModItems.manaweaveHelm), "SSS", "S S", 'S', LibOreDict.MANAWEAVE_CLOTH); + recipeManaweaveHelm = BotaniaAPI.getLatestAddedRecipe(); + addOreDictRecipe(new ItemStack(ModItems.manaweaveChest), "S S", "SSS", "SSS", 'S', LibOreDict.MANAWEAVE_CLOTH); + recipeManaweaveChest = BotaniaAPI.getLatestAddedRecipe(); + addOreDictRecipe(new ItemStack(ModItems.manaweaveLegs), "SSS", "S S", "S S", 'S', LibOreDict.MANAWEAVE_CLOTH); + recipeManaweaveLegs = BotaniaAPI.getLatestAddedRecipe(); + addOreDictRecipe(new ItemStack(ModItems.manaweaveBoots), "S S", "S S", 'S', LibOreDict.MANAWEAVE_CLOTH); + recipeManaweaveBoots = BotaniaAPI.getLatestAddedRecipe(); + + // Bifrost Blocks Recipe + addShapelessOreDictRecipe( + new ItemStack(ModBlocks.bifrostPerm), + new ItemStack(ModItems.rainbowRod), + new ItemStack(ModBlocks.elfGlass)); + recipeBifrost = BotaniaAPI.getLatestAddedRecipe(); + addShapelessOreDictRecipe( + new ItemStack(ModBlocks.shimmerrock), LibOreDict.LIVING_ROCK, new ItemStack(ModBlocks.bifrostPerm)); + recipeShimmerrock = BotaniaAPI.getLatestAddedRecipe(); + addShapelessOreDictRecipe( + new ItemStack(ModBlocks.shimmerwoodPlanks), + new ItemStack(ModBlocks.dreamwood, 1, 1), + new ItemStack(ModBlocks.bifrostPerm)); + recipeShimmerwoodPlanks = BotaniaAPI.getLatestAddedRecipe(); + + // Manufactory Halo Recipe + addShapelessOreDictRecipe( + new ItemStack(ModItems.autocraftingHalo), + new ItemStack(ModItems.craftingHalo), + LibOreDict.MANA_DIAMOND); + recipeAutocraftingHalo = BotaniaAPI.getLatestAddedRecipe(); + + // Pavement Recipes + addShapelessOreDictRecipe( + new ItemStack(ModFluffBlocks.pavement, 3, 0), LibOreDict.LIVING_ROCK, "cobblestone", "gravel"); + addShapelessOreDictRecipe( + new ItemStack(ModFluffBlocks.pavement, 3, 1), + LibOreDict.LIVING_ROCK, + "cobblestone", + "gravel", + new ItemStack(Items.coal)); + addShapelessOreDictRecipe( + new ItemStack(ModFluffBlocks.pavement, 3, 2), + LibOreDict.LIVING_ROCK, + "cobblestone", + "gravel", + new ItemStack(Items.dye, 1, 4)); + addShapelessOreDictRecipe( + new ItemStack(ModFluffBlocks.pavement, 3, 3), + LibOreDict.LIVING_ROCK, + "cobblestone", + "gravel", + new ItemStack(Items.redstone)); + addShapelessOreDictRecipe( + new ItemStack(ModFluffBlocks.pavement, 3, 4), + LibOreDict.LIVING_ROCK, + "cobblestone", + "gravel", + new ItemStack(Items.wheat)); + addShapelessOreDictRecipe( + new ItemStack(ModFluffBlocks.pavement, 3, 5), + LibOreDict.LIVING_ROCK, + "cobblestone", + "gravel", + new ItemStack(Items.slime_ball)); + recipesPavement = BotaniaAPI.getLatestAddedRecipes(6); + + // Cellular Block Recipe + GameRegistry.addShapelessRecipe( + new ItemStack(ModBlocks.cellBlock, 3), + new ItemStack(Blocks.cactus), + new ItemStack(Blocks.cactus), + new ItemStack(Blocks.cactus), + new ItemStack(Blocks.cactus), + new ItemStack(Items.carrot), + new ItemStack(Items.potato)); + recipeCellBlock = BotaniaAPI.getLatestAddedRecipe(); + + // Corporea Retainer Recipe + addShapelessOreDictRecipe( + new ItemStack(ModBlocks.corporeaRetainer), + new ItemStack(Blocks.chest), + new ItemStack(ModItems.corporeaSpark)); + recipeCorporeaRetainer = BotaniaAPI.getLatestAddedRecipe(); + + // Teru Teru Bozu Recipe + addOreDictRecipe( + new ItemStack(ModBlocks.teruTeruBozu), + "C", + "C", + "S", + 'C', + LibOreDict.MANAWEAVE_CLOTH, + 'S', + new ItemStack(Blocks.double_plant)); + recipeTeruTeruBozu = BotaniaAPI.getLatestAddedRecipe(); + + // Livingwood Avatar Recipe + addOreDictRecipe( + new ItemStack(ModBlocks.avatar), + " W ", + "WDW", + "W W", + 'W', + LibOreDict.LIVING_WOOD, + 'D', + LibOreDict.MANA_DIAMOND); + recipeAvatar = BotaniaAPI.getLatestAddedRecipe(); + + // Worldshaper's Sextant Recipe + addOreDictRecipe( + new ItemStack(ModItems.sextant), + " TI", + " TT", + "III", + 'T', + LibOreDict.LIVINGWOOD_TWIG, + 'I', + LibOreDict.MANA_STEEL); + recipeSextant = BotaniaAPI.getLatestAddedRecipe(); + + // Alternate Pasture Seed Recipes + GameRegistry.addShapelessRecipe( + new ItemStack(ModItems.grassSeeds, 1, 3), + new ItemStack(ModItems.grassSeeds), + new ItemStack(Blocks.deadbush)); + GameRegistry.addShapelessRecipe( + new ItemStack(ModItems.grassSeeds, 1, 4), + new ItemStack(ModItems.grassSeeds), + new ItemStack(Items.wheat)); + GameRegistry.addShapelessRecipe( + new ItemStack(ModItems.grassSeeds, 1, 5), + new ItemStack(ModItems.grassSeeds), + new ItemStack(Items.dye, 1, 2)); + GameRegistry.addShapelessRecipe( + new ItemStack(ModItems.grassSeeds, 1, 6), + new ItemStack(ModItems.grassSeeds), + new ItemStack(Items.blaze_powder)); + GameRegistry.addShapelessRecipe( + new ItemStack(ModItems.grassSeeds, 1, 7), + new ItemStack(ModItems.grassSeeds), + new ItemStack(ModItems.manaResource, 1, 10)); + GameRegistry.addShapelessRecipe( + new ItemStack(ModItems.grassSeeds, 1, 8), + new ItemStack(ModItems.grassSeeds), + new ItemStack(Items.spider_eye)); + recipesAltGrassSeeds = BotaniaAPI.getLatestAddedRecipes(6); + + // Planestrider's Sash Recipe + GameRegistry.addRecipe( + new ItemStack(ModItems.speedUpBelt), + " M ", + "PBP", + " S ", + 'M', + new ItemStack(Items.filled_map, 1, Short.MAX_VALUE), + 'P', + new ItemStack(ModItems.grassSeeds), + 'B', + new ItemStack(ModItems.travelBelt), + 'S', + new ItemStack(Items.sugar)); + recipeSpeedUpBelt = BotaniaAPI.getLatestAddedRecipe(); + + // Bauble Case Recipe + addOreDictRecipe( + new ItemStack(ModItems.baubleBox), + " M ", + "MCG", + " M ", + 'M', + LibOreDict.MANA_STEEL, + 'C', + new ItemStack(Blocks.chest), + 'G', + "ingotGold"); + recipeBaubleCase = BotaniaAPI.getLatestAddedRecipe(); + + /////////////////////////////////////////////////////////////////////////////////////////////////////////// + + // Storage Block/Nugget Recipes + addOreDictRecipe(new ItemStack(ModBlocks.storage, 1, 0), "III", "III", "III", 'I', LibOreDict.MANA_STEEL); + addOreDictRecipe(new ItemStack(ModBlocks.storage, 1, 1), "III", "III", "III", 'I', LibOreDict.TERRA_STEEL); + addOreDictRecipe(new ItemStack(ModBlocks.storage, 1, 2), "III", "III", "III", 'I', LibOreDict.ELEMENTIUM); + addOreDictRecipe(new ItemStack(ModBlocks.storage, 1, 3), "III", "III", "III", 'I', LibOreDict.MANA_DIAMOND); + addOreDictRecipe(new ItemStack(ModBlocks.storage, 1, 4), "III", "III", "III", 'I', LibOreDict.DRAGONSTONE); + GameRegistry.addShapelessRecipe( + new ItemStack(ModItems.manaResource, 9, 0), new ItemStack(ModBlocks.storage, 1, 0)); + GameRegistry.addShapelessRecipe( + new ItemStack(ModItems.manaResource, 9, 4), new ItemStack(ModBlocks.storage, 1, 1)); + GameRegistry.addShapelessRecipe( + new ItemStack(ModItems.manaResource, 9, 7), new ItemStack(ModBlocks.storage, 1, 2)); + GameRegistry.addShapelessRecipe( + new ItemStack(ModItems.manaResource, 9, 2), new ItemStack(ModBlocks.storage, 1, 3)); + GameRegistry.addShapelessRecipe( + new ItemStack(ModItems.manaResource, 9, 9), new ItemStack(ModBlocks.storage, 1, 4)); + + addOreDictRecipe( + new ItemStack(ModItems.manaResource, 1, 0), "III", "III", "III", 'I', LibOreDict.MANASTEEL_NUGGET); + addOreDictRecipe( + new ItemStack(ModItems.manaResource, 1, 4), "III", "III", "III", 'I', LibOreDict.TERRASTEEL_NUGGET); + addOreDictRecipe( + new ItemStack(ModItems.manaResource, 1, 7), "III", "III", "III", 'I', LibOreDict.ELEMENTIUM_NUGGET); + addShapelessOreDictRecipe(new ItemStack(ModItems.manaResource, 9, 17), LibOreDict.MANA_STEEL); + addShapelessOreDictRecipe(new ItemStack(ModItems.manaResource, 9, 18), LibOreDict.TERRA_STEEL); + addShapelessOreDictRecipe(new ItemStack(ModItems.manaResource, 9, 19), LibOreDict.ELEMENTIUM); + + // Revealing Helmet Recipes + if (Botania.thaumcraftLoaded) { + Item goggles = (Item) Item.itemRegistry.getObject("Thaumcraft:ItemGoggles"); + GameRegistry.addShapelessRecipe( + new ItemStack(ModItems.manasteelHelmRevealing), new ItemStack(ModItems.manasteelHelm), goggles); + recipeHelmetOfRevealing = BotaniaAPI.getLatestAddedRecipe(); // We want manasteel to show in the Lexicon + GameRegistry.addShapelessRecipe( + new ItemStack(ModItems.terrasteelHelmRevealing), new ItemStack(ModItems.terrasteelHelm), goggles); + GameRegistry.addShapelessRecipe( + new ItemStack(ModItems.elementiumHelmRevealing), new ItemStack(ModItems.elementiumHelm), goggles); + } + + // Slab & Stair Recipes + addStairsAndSlabs(ModBlocks.livingwood, 0, ModFluffBlocks.livingwoodStairs, ModFluffBlocks.livingwoodSlab); + addStairsAndSlabs( + ModBlocks.livingwood, 1, ModFluffBlocks.livingwoodPlankStairs, ModFluffBlocks.livingwoodPlankSlab); + addStairsAndSlabs(ModBlocks.livingrock, 0, ModFluffBlocks.livingrockStairs, ModFluffBlocks.livingrockSlab); + addStairsAndSlabs( + ModBlocks.livingrock, 1, ModFluffBlocks.livingrockBrickStairs, ModFluffBlocks.livingrockBrickSlab); + addStairsAndSlabs(ModBlocks.dreamwood, 0, ModFluffBlocks.dreamwoodStairs, ModFluffBlocks.dreamwoodSlab); + addStairsAndSlabs( + ModBlocks.dreamwood, 1, ModFluffBlocks.dreamwoodPlankStairs, ModFluffBlocks.dreamwoodPlankSlab); + addStairsAndSlabs(ModBlocks.prismarine, 0, ModFluffBlocks.prismarineStairs, ModFluffBlocks.prismarineSlab); + addStairsAndSlabs( + ModBlocks.prismarine, 1, ModFluffBlocks.prismarineBrickStairs, ModFluffBlocks.prismarineBrickSlab); + addStairsAndSlabs( + ModBlocks.prismarine, 2, ModFluffBlocks.darkPrismarineStairs, ModFluffBlocks.darkPrismarineSlab); + addStairsAndSlabs(ModBlocks.reedBlock, 0, ModFluffBlocks.reedStairs, ModFluffBlocks.reedSlab); + addStairsAndSlabs(ModBlocks.thatch, 0, ModFluffBlocks.thatchStairs, ModFluffBlocks.thatchSlab); + addStairsAndSlabs(ModBlocks.customBrick, 0, ModFluffBlocks.netherBrickStairs, ModFluffBlocks.netherBrickSlab); + addStairsAndSlabs(ModBlocks.customBrick, 1, ModFluffBlocks.soulBrickStairs, ModFluffBlocks.soulBrickSlab); + addStairsAndSlabs(ModBlocks.customBrick, 2, ModFluffBlocks.snowBrickStairs, ModFluffBlocks.snowBrickSlab); + addStairsAndSlabs(ModBlocks.customBrick, 3, ModFluffBlocks.tileStairs, ModFluffBlocks.tileSlab); + addStairsAndSlabs(ModBlocks.endStoneBrick, 0, ModFluffBlocks.endStoneStairs, ModFluffBlocks.endStoneSlab); + addStairsAndSlabs(ModBlocks.shimmerrock, 0, ModFluffBlocks.shimmerrockStairs, ModFluffBlocks.shimmerrockSlab); + addStairsAndSlabs( + ModBlocks.shimmerwoodPlanks, + 0, + ModFluffBlocks.shimmerwoodPlankStairs, + ModFluffBlocks.shimmerwoodPlankSlab); + + // Wall Recipes + addWall(ModBlocks.livingrock, 0, ModFluffBlocks.livingrockWall, 0); + addWall(ModBlocks.livingwood, 0, ModFluffBlocks.livingwoodWall, 0); + addWall(ModBlocks.dreamwood, 0, ModFluffBlocks.dreamwoodWall, 0); + addWall(ModBlocks.prismarine, 0, ModFluffBlocks.prismarineWall, 0); + addWall(ModBlocks.reedBlock, 0, ModFluffBlocks.reedWall, 0); + for (int i = 0; i < 8; i++) addWall(ModFluffBlocks.biomeStoneA, i + 8, ModFluffBlocks.biomeStoneWall, i); + for (int i = 0; i < 4; i++) addWall(ModFluffBlocks.stone, i, ModFluffBlocks.stoneWall, i); + + // Pane Recipes + addPane(ModBlocks.manaGlass, ModFluffBlocks.managlassPane); + addPane(ModBlocks.elfGlass, ModFluffBlocks.alfglassPane); + addPane(ModBlocks.bifrostPerm, ModFluffBlocks.bifrostPane); + + // Biome Stone Recipes + for (int i = 0; i < 8; i++) { + GameRegistry.addSmelting( + new ItemStack(ModFluffBlocks.biomeStoneA, 1, i + 8), + new ItemStack(ModFluffBlocks.biomeStoneA, 1, i), + 0.1F); + GameRegistry.addRecipe( + new ItemStack(ModFluffBlocks.biomeStoneB, 4, i), + "SS", + "SS", + 'S', + new ItemStack(ModFluffBlocks.biomeStoneA, 1, i)); + GameRegistry.addRecipe( + new ItemStack(ModFluffBlocks.biomeStoneB, 1, i + 8), + "S", + "S", + 'S', + new ItemStack(ModFluffBlocks.biomeStoneSlabs[i + 16])); + addStairsAndSlabs( + ModFluffBlocks.biomeStoneA, + i, + ModFluffBlocks.biomeStoneStairs[i], + ModFluffBlocks.biomeStoneSlabs[i]); + addStairsAndSlabs( + ModFluffBlocks.biomeStoneA, + i + 8, + ModFluffBlocks.biomeStoneStairs[i + 8], + ModFluffBlocks.biomeStoneSlabs[i + 8]); + addStairsAndSlabs( + ModFluffBlocks.biomeStoneB, + i, + ModFluffBlocks.biomeStoneStairs[i + 16], + ModFluffBlocks.biomeStoneSlabs[i + 16]); + } + + // 1.8 Block Stone Stairs & Slabs + for (int i = 0; i < 4; i++) { + addOreDictRecipe( + new ItemStack(ModFluffBlocks.stoneSlabs[i], 6), "QQQ", 'Q', LibOreDict.STONE_18_VARIANTS[i]); + addOreDictRecipe( + new ItemStack(ModFluffBlocks.stoneStairs[i], 4), + " Q", + " QQ", + "QQQ", + 'Q', + LibOreDict.STONE_18_VARIANTS[i]); + addOreDictRecipe( + new ItemStack(ModFluffBlocks.stoneStairs[i], 4), + "Q ", + "QQ ", + "QQQ", + 'Q', + LibOreDict.STONE_18_VARIANTS[i]); + addOreDictRecipe( + new ItemStack(ModFluffBlocks.stone, 1, i), + "Q", + "Q", + 'Q', + new ItemStack(ModFluffBlocks.stoneSlabs[i])); + + addOreDictRecipe( + new ItemStack(ModFluffBlocks.stoneSlabs[i + 4], 6), + "QQQ", + 'Q', + LibOreDict.STONE_18_VARIANTS[i + 8]); + addOreDictRecipe( + new ItemStack(ModFluffBlocks.stoneStairs[i + 4], 4), + " Q", + " QQ", + "QQQ", + 'Q', + LibOreDict.STONE_18_VARIANTS[i + 8]); + addOreDictRecipe( + new ItemStack(ModFluffBlocks.stoneStairs[i + 4], 4), + "Q ", + "QQ ", + "QQQ", + 'Q', + LibOreDict.STONE_18_VARIANTS[i + 8]); + addOreDictRecipe( + new ItemStack(ModFluffBlocks.stone, 1, i + 8), // VERY VERY + "Q", + "Q", // BIG BIG + 'Q', + new ItemStack(ModFluffBlocks.stoneSlabs[i + 4])); // PROBLEM PROBLEM + } + + // Pavement Stairsm & Stairs + for (int i = 0; i < ModFluffBlocks.pavementStairs.length; i++) + addStairsAndSlabs( + ModFluffBlocks.pavement, i, ModFluffBlocks.pavementStairs[i], ModFluffBlocks.pavementSlabs[i]); + + // Misc Recipes + GameRegistry.addShapelessRecipe(new ItemStack(Items.reeds, 9, 0), new ItemStack(ModBlocks.reedBlock)); + GameRegistry.addShapelessRecipe(new ItemStack(Items.wheat, 4, 0), new ItemStack(ModBlocks.thatch)); + + if (Botania.gardenOfGlassLoaded) initGardenOfGlass(); + + int newRecipeListSize = CraftingManager.getInstance().getRecipeList().size(); + FMLLog.log(Level.INFO, "[Botania] Registered %d recipes.", newRecipeListSize - recipeListSize); + } + + private static void initGardenOfGlass() { + // Root to Sapling + addShapelessOreDictRecipe( + new ItemStack(Blocks.sapling), LibOreDict.ROOT, LibOreDict.ROOT, LibOreDict.ROOT, LibOreDict.ROOT); + recipeRootToSapling = BotaniaAPI.getLatestAddedRecipe(); + + // Root to Fertilizer + addShapelessOreDictRecipe(new ItemStack(ModItems.fertilizer), LibOreDict.ROOT); + recipeRootToFertilizer = BotaniaAPI.getLatestAddedRecipe(); + + // Pebble to Cobble + addShapelessOreDictRecipe( + new ItemStack(Blocks.cobblestone), + LibOreDict.PEBBLE, + LibOreDict.PEBBLE, + LibOreDict.PEBBLE, + LibOreDict.PEBBLE); + recipePebbleCobblestone = BotaniaAPI.getLatestAddedRecipe(); + + // Magma Pearl to Slimeball + addShapelessOreDictRecipe( + new ItemStack(Items.slime_ball), new ItemStack(Items.magma_cream), new ItemStack(Items.water_bucket)); + recipeMagmaToSlimeball = BotaniaAPI.getLatestAddedRecipe(); + + // Ender Portal + addOreDictRecipe( + new ItemStack(Blocks.end_portal_frame), + "OGO", + 'O', + new ItemStack(Blocks.obsidian), + 'G', + LibOreDict.LIFE_ESSENCE); + recipeEndPortal = BotaniaAPI.getLatestAddedRecipe(); + } + + private static void addStairsAndSlabs(Block block, int meta, Block stairs, Block slab) { + GameRegistry.addRecipe(new ItemStack(slab, 6), "QQQ", 'Q', new ItemStack(block, 1, meta)); + GameRegistry.addRecipe(new ItemStack(stairs, 4), " Q", " QQ", "QQQ", 'Q', new ItemStack(block, 1, meta)); + GameRegistry.addRecipe(new ItemStack(stairs, 4), "Q ", "QQ ", "QQQ", 'Q', new ItemStack(block, 1, meta)); + GameRegistry.addRecipe(new ItemStack(block, 1, meta), "Q", "Q", 'Q', new ItemStack(slab)); + } + + private static void addWall(Block block, int blockMeta, Block wall, int wallMeta) { + GameRegistry.addRecipe(new ItemStack(wall, 6, wallMeta), "BBB", "BBB", 'B', new ItemStack(block, 1, blockMeta)); + } + + private static void addPane(Block block, Block pane) { + GameRegistry.addRecipe(new ItemStack(pane, 16), "BBB", "BBB", 'B', new ItemStack(block, 1)); + } + + private static IRecipe addQuartzRecipes(int meta, Item req, Block block, Block stairs, Block slab) { + GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(block), "QQ", "QQ", 'Q', LibOreDict.QUARTZ[meta])); + GameRegistry.addRecipe(new ItemStack(block, 2, 2), "Q", "Q", 'Q', block); + GameRegistry.addRecipe(new ItemStack(block, 1, 1), "Q", "Q", 'Q', slab); + addStairsAndSlabs(block, 0, stairs, slab); + + if (req != null) { + if (req == Items.coal) + GameRegistry.addRecipe(new ShapedOreRecipe( + new ItemStack(ModItems.quartz, 8, meta), + "QQQ", + "QCQ", + "QQQ", + 'Q', + "gemQuartz", + 'C', + new ItemStack(req, 1, 1))); + GameRegistry.addRecipe(new ShapedOreRecipe( + new ItemStack(ModItems.quartz, 8, meta), "QQQ", "QCQ", "QQQ", 'Q', "gemQuartz", 'C', req)); + return BotaniaAPI.getLatestAddedRecipe(); + } + return null; + } + + private static void addOreDictRecipe(ItemStack output, Object... recipe) { + CraftingManager.getInstance().getRecipeList().add(new ShapedOreRecipe(output, recipe)); + } + + private static void addShapelessOreDictRecipe(ItemStack output, Object... recipe) { + CraftingManager.getInstance().getRecipeList().add(new ShapelessOreRecipe(output, recipe)); + } } diff --git a/src/main/java/vazkii/botania/common/crafting/ModElvenTradeRecipes.java b/src/main/java/vazkii/botania/common/crafting/ModElvenTradeRecipes.java index c5dbb2c22d..d839153f5d 100644 --- a/src/main/java/vazkii/botania/common/crafting/ModElvenTradeRecipes.java +++ b/src/main/java/vazkii/botania/common/crafting/ModElvenTradeRecipes.java @@ -2,7 +2,6 @@ import java.util.ArrayList; import java.util.List; - import net.minecraft.init.Blocks; import net.minecraft.init.Items; import net.minecraft.item.ItemStack; @@ -15,35 +14,44 @@ public class ModElvenTradeRecipes { - public static RecipeElvenTrade dreamwoodRecipe; - public static List elementiumRecipes; - public static RecipeElvenTrade pixieDustRecipe; - public static List dragonstoneRecipes; - public static RecipeElvenTrade elvenQuartzRecipe; - public static RecipeElvenTrade alfglassRecipe; - - public static void init() { - if (!ConfigHandler.enableDefaultRecipes) return; - - dreamwoodRecipe = BotaniaAPI.registerElvenTradeRecipe(new ItemStack(ModBlocks.dreamwood), LibOreDict.LIVING_WOOD); - - elementiumRecipes = new ArrayList(); - elementiumRecipes.add(BotaniaAPI.registerElvenTradeRecipe(new ItemStack(ModItems.manaResource, 1, 7), LibOreDict.MANA_STEEL, LibOreDict.MANA_STEEL)); - elementiumRecipes.add(BotaniaAPI.registerElvenTradeRecipe(new ItemStack(ModBlocks.storage, 1, 2), new ItemStack(ModBlocks.storage), new ItemStack(ModBlocks.storage))); - - pixieDustRecipe = BotaniaAPI.registerElvenTradeRecipe(new ItemStack(ModItems.manaResource, 1, 8), LibOreDict.MANA_PEARL); - dragonstoneRecipes = new ArrayList(); - dragonstoneRecipes.add(BotaniaAPI.registerElvenTradeRecipe(new ItemStack(ModItems.manaResource, 1, 9), LibOreDict.MANA_DIAMOND)); - dragonstoneRecipes.add(BotaniaAPI.registerElvenTradeRecipe(new ItemStack(ModBlocks.storage, 1, 4), new ItemStack(ModBlocks.storage, 1, 3))); - - elvenQuartzRecipe = BotaniaAPI.registerElvenTradeRecipe(new ItemStack(ModItems.quartz, 1, 5), new ItemStack(Items.quartz)); - alfglassRecipe = BotaniaAPI.registerElvenTradeRecipe(new ItemStack(ModBlocks.elfGlass), new ItemStack(ModBlocks.manaGlass)); - - BotaniaAPI.registerElvenTradeRecipe(new ItemStack(Items.iron_ingot), new ItemStack(Items.iron_ingot)); - BotaniaAPI.registerElvenTradeRecipe(new ItemStack(Blocks.iron_block), new ItemStack(Blocks.iron_block)); - BotaniaAPI.registerElvenTradeRecipe(new ItemStack(Items.ender_pearl), new ItemStack(Items.ender_pearl)); - BotaniaAPI.registerElvenTradeRecipe(new ItemStack(Items.diamond), new ItemStack(Items.diamond)); - BotaniaAPI.registerElvenTradeRecipe(new ItemStack(Blocks.diamond_block), new ItemStack(Blocks.diamond_block)); - } - + public static RecipeElvenTrade dreamwoodRecipe; + public static List elementiumRecipes; + public static RecipeElvenTrade pixieDustRecipe; + public static List dragonstoneRecipes; + public static RecipeElvenTrade elvenQuartzRecipe; + public static RecipeElvenTrade alfglassRecipe; + + public static void init() { + if (!ConfigHandler.enableDefaultRecipes) return; + + dreamwoodRecipe = + BotaniaAPI.registerElvenTradeRecipe(new ItemStack(ModBlocks.dreamwood), LibOreDict.LIVING_WOOD); + + elementiumRecipes = new ArrayList(); + elementiumRecipes.add(BotaniaAPI.registerElvenTradeRecipe( + new ItemStack(ModItems.manaResource, 1, 7), LibOreDict.MANA_STEEL, LibOreDict.MANA_STEEL)); + elementiumRecipes.add(BotaniaAPI.registerElvenTradeRecipe( + new ItemStack(ModBlocks.storage, 1, 2), + new ItemStack(ModBlocks.storage), + new ItemStack(ModBlocks.storage))); + + pixieDustRecipe = + BotaniaAPI.registerElvenTradeRecipe(new ItemStack(ModItems.manaResource, 1, 8), LibOreDict.MANA_PEARL); + dragonstoneRecipes = new ArrayList(); + dragonstoneRecipes.add(BotaniaAPI.registerElvenTradeRecipe( + new ItemStack(ModItems.manaResource, 1, 9), LibOreDict.MANA_DIAMOND)); + dragonstoneRecipes.add(BotaniaAPI.registerElvenTradeRecipe( + new ItemStack(ModBlocks.storage, 1, 4), new ItemStack(ModBlocks.storage, 1, 3))); + + elvenQuartzRecipe = + BotaniaAPI.registerElvenTradeRecipe(new ItemStack(ModItems.quartz, 1, 5), new ItemStack(Items.quartz)); + alfglassRecipe = BotaniaAPI.registerElvenTradeRecipe( + new ItemStack(ModBlocks.elfGlass), new ItemStack(ModBlocks.manaGlass)); + + BotaniaAPI.registerElvenTradeRecipe(new ItemStack(Items.iron_ingot), new ItemStack(Items.iron_ingot)); + BotaniaAPI.registerElvenTradeRecipe(new ItemStack(Blocks.iron_block), new ItemStack(Blocks.iron_block)); + BotaniaAPI.registerElvenTradeRecipe(new ItemStack(Items.ender_pearl), new ItemStack(Items.ender_pearl)); + BotaniaAPI.registerElvenTradeRecipe(new ItemStack(Items.diamond), new ItemStack(Items.diamond)); + BotaniaAPI.registerElvenTradeRecipe(new ItemStack(Blocks.diamond_block), new ItemStack(Blocks.diamond_block)); + } } diff --git a/src/main/java/vazkii/botania/common/crafting/ModManaAlchemyRecipes.java b/src/main/java/vazkii/botania/common/crafting/ModManaAlchemyRecipes.java index f2e9617a5f..7eb8384e5d 100644 --- a/src/main/java/vazkii/botania/common/crafting/ModManaAlchemyRecipes.java +++ b/src/main/java/vazkii/botania/common/crafting/ModManaAlchemyRecipes.java @@ -2,17 +2,16 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [May 2, 2014, 7:50:07 PM (GMT)] */ package vazkii.botania.common.crafting; import java.util.ArrayList; import java.util.List; - import net.minecraft.block.Block; import net.minecraft.init.Blocks; import net.minecraft.init.Items; @@ -25,140 +24,211 @@ public final class ModManaAlchemyRecipes { - public static RecipeManaInfusion leatherRecipe; - public static List woodRecipes; - public static List saplingRecipes; - public static RecipeManaInfusion glowstoneDustRecipe; - public static List quartzRecipes; - public static RecipeManaInfusion chiseledBrickRecipe; - public static RecipeManaInfusion iceRecipe; - public static List swampFolliageRecipes; - public static List fishRecipes; - public static List cropRecipes; - public static RecipeManaInfusion potatoRecipe; - public static RecipeManaInfusion netherWartRecipe; - public static List gunpowderAndFlintRecipes; - public static RecipeManaInfusion nameTagRecipe; - public static List stringRecipes; - public static List slimeballCactusRecipes; - public static RecipeManaInfusion enderPearlRecipe; - public static List redstoneToGlowstoneRecipes; - public static RecipeManaInfusion sandRecipe; - public static RecipeManaInfusion redSandRecipe; - public static List clayBreakdownRecipes; - public static RecipeManaInfusion coarseDirtRecipe; - public static RecipeManaInfusion prismarineRecipe; - public static List stoneRecipes; - public static List tallgrassRecipes; - public static List flowersRecipes; - - public static void init() { - if (!ConfigHandler.enableDefaultRecipes) return; - - leatherRecipe = BotaniaAPI.registerManaAlchemyRecipe(new ItemStack(Items.leather), new ItemStack(Items.rotten_flesh), 600); - - woodRecipes = new ArrayList(); - woodRecipes.add(BotaniaAPI.registerManaAlchemyRecipe(new ItemStack(Blocks.log, 1, 0), new ItemStack(Blocks.log2, 1, 1), 40)); - woodRecipes.add(BotaniaAPI.registerManaAlchemyRecipe(new ItemStack(Blocks.log, 1, 1), new ItemStack(Blocks.log, 1, 0), 40)); - woodRecipes.add(BotaniaAPI.registerManaAlchemyRecipe(new ItemStack(Blocks.log, 1, 2), new ItemStack(Blocks.log, 1, 1), 40)); - woodRecipes.add(BotaniaAPI.registerManaAlchemyRecipe(new ItemStack(Blocks.log, 1, 3), new ItemStack(Blocks.log, 1, 2), 40)); - woodRecipes.add(BotaniaAPI.registerManaAlchemyRecipe(new ItemStack(Blocks.log2, 1, 0), new ItemStack(Blocks.log, 1, 3), 40)); - woodRecipes.add(BotaniaAPI.registerManaAlchemyRecipe(new ItemStack(Blocks.log2, 1, 1), new ItemStack(Blocks.log2, 1, 0), 40)); - - saplingRecipes = new ArrayList(); - for(int i = 0; i < 6; i++) - saplingRecipes.add(BotaniaAPI.registerManaAlchemyRecipe(new ItemStack(Blocks.sapling, 1, i == 5 ? 0 : i + 1), new ItemStack(Blocks.sapling, 1, i), 120)); - - glowstoneDustRecipe = BotaniaAPI.registerManaAlchemyRecipe(new ItemStack(Items.glowstone_dust, 4), new ItemStack(Blocks.glowstone), 25); - quartzRecipes = new ArrayList(); - quartzRecipes.add(BotaniaAPI.registerManaAlchemyRecipe(new ItemStack(Items.quartz, 4), new ItemStack(Blocks.quartz_block, 1, Short.MAX_VALUE), 25)); - if(ConfigHandler.darkQuartzEnabled) - quartzRecipes.add(BotaniaAPI.registerManaAlchemyRecipe(new ItemStack(ModItems.quartz, 4, 0), new ItemStack(ModFluffBlocks.darkQuartz, 1, Short.MAX_VALUE), 25)); - quartzRecipes.add(BotaniaAPI.registerManaAlchemyRecipe(new ItemStack(ModItems.quartz, 4, 1), new ItemStack(ModFluffBlocks.manaQuartz, 1, Short.MAX_VALUE), 25)); - quartzRecipes.add(BotaniaAPI.registerManaAlchemyRecipe(new ItemStack(ModItems.quartz, 4, 2), new ItemStack(ModFluffBlocks.blazeQuartz, 1, Short.MAX_VALUE), 25)); - quartzRecipes.add(BotaniaAPI.registerManaAlchemyRecipe(new ItemStack(ModItems.quartz, 4, 3), new ItemStack(ModFluffBlocks.lavenderQuartz, 1, Short.MAX_VALUE), 25)); - quartzRecipes.add(BotaniaAPI.registerManaAlchemyRecipe(new ItemStack(ModItems.quartz, 4, 4), new ItemStack(ModFluffBlocks.redQuartz, 1, Short.MAX_VALUE), 25)); - quartzRecipes.add(BotaniaAPI.registerManaAlchemyRecipe(new ItemStack(ModItems.quartz, 4, 5), new ItemStack(ModFluffBlocks.elfQuartz, 1, Short.MAX_VALUE), 25)); - - chiseledBrickRecipe = BotaniaAPI.registerManaAlchemyRecipe(new ItemStack(Blocks.stonebrick, 1, 3), new ItemStack(Blocks.stonebrick), 150); - iceRecipe = BotaniaAPI.registerManaAlchemyRecipe(new ItemStack(Blocks.ice), new ItemStack(Blocks.snow), 2250); - - swampFolliageRecipes = new ArrayList(); - swampFolliageRecipes.add(BotaniaAPI.registerManaAlchemyRecipe(new ItemStack(Blocks.waterlily), new ItemStack(Blocks.vine), 320)); - swampFolliageRecipes.add(BotaniaAPI.registerManaAlchemyRecipe(new ItemStack(Blocks.vine), new ItemStack(Blocks.waterlily), 320)); - - fishRecipes = new ArrayList(); - for(int i = 0; i < 4; i++) - fishRecipes.add(BotaniaAPI.registerManaAlchemyRecipe(new ItemStack(Items.fish, 1, i == 3 ? 0 : i + 1), new ItemStack(Items.fish, 1, i), 200)); - - cropRecipes = new ArrayList(); - cropRecipes.add(BotaniaAPI.registerManaAlchemyRecipe(new ItemStack(Items.wheat_seeds), new ItemStack(Items.dye, 1, 3), 6000)); - cropRecipes.add(BotaniaAPI.registerManaAlchemyRecipe(new ItemStack(Items.potato), new ItemStack(Items.wheat), 6000)); - cropRecipes.add(BotaniaAPI.registerManaAlchemyRecipe(new ItemStack(Items.carrot), new ItemStack(Items.potato), 6000)); - cropRecipes.add(BotaniaAPI.registerManaAlchemyRecipe(new ItemStack(Items.melon_seeds), new ItemStack(Items.carrot), 6000)); - cropRecipes.add(BotaniaAPI.registerManaAlchemyRecipe(new ItemStack(Items.pumpkin_seeds), new ItemStack(Items.melon_seeds), 6000)); - cropRecipes.add(BotaniaAPI.registerManaAlchemyRecipe(new ItemStack(Items.dye, 1, 3), new ItemStack(Items.pumpkin_seeds), 6000)); - - potatoRecipe = BotaniaAPI.registerManaAlchemyRecipe(new ItemStack(Items.potato), new ItemStack(Items.poisonous_potato), 1200); - netherWartRecipe = BotaniaAPI.registerManaAlchemyRecipe(new ItemStack(Items.nether_wart), new ItemStack(Items.blaze_rod), 4000); - - gunpowderAndFlintRecipes = new ArrayList(); - gunpowderAndFlintRecipes.add(BotaniaAPI.registerManaAlchemyRecipe(new ItemStack(Items.flint), new ItemStack(Items.gunpowder), 200)); - gunpowderAndFlintRecipes.add(BotaniaAPI.registerManaAlchemyRecipe(new ItemStack(Items.gunpowder), new ItemStack(Items.flint), 4000)); - - nameTagRecipe = BotaniaAPI.registerManaAlchemyRecipe(new ItemStack(Items.name_tag), new ItemStack(Items.writable_book), 16000); - - stringRecipes = new ArrayList(); - for(int i = 0; i < 16; i++) - stringRecipes.add(BotaniaAPI.registerManaAlchemyRecipe(new ItemStack(Items.string, 3), new ItemStack(Blocks.wool, 1, i), 100)); - - slimeballCactusRecipes = new ArrayList(); - slimeballCactusRecipes.add(BotaniaAPI.registerManaAlchemyRecipe(new ItemStack(Items.slime_ball), new ItemStack(Blocks.cactus), 1200)); - slimeballCactusRecipes.add(BotaniaAPI.registerManaAlchemyRecipe(new ItemStack(Blocks.cactus), new ItemStack(Items.slime_ball), 1200)); - - enderPearlRecipe = BotaniaAPI.registerManaAlchemyRecipe(new ItemStack(Items.ender_pearl), new ItemStack(Items.ghast_tear), 28000); - - redstoneToGlowstoneRecipes = new ArrayList(); - redstoneToGlowstoneRecipes.add(BotaniaAPI.registerManaAlchemyRecipe(new ItemStack(Items.redstone), new ItemStack(Items.glowstone_dust), 300)); - redstoneToGlowstoneRecipes.add(BotaniaAPI.registerManaAlchemyRecipe(new ItemStack(Items.glowstone_dust), new ItemStack(Items.redstone), 300)); - - sandRecipe = BotaniaAPI.registerManaAlchemyRecipe(new ItemStack(Block.getBlockFromName("sand")), new ItemStack(Blocks.cobblestone), 50); - redSandRecipe = BotaniaAPI.registerManaAlchemyRecipe(new ItemStack(Block.getBlockFromName("sand"), 1, 1), new ItemStack(Blocks.hardened_clay), 50); - - clayBreakdownRecipes = new ArrayList(); - clayBreakdownRecipes.add(BotaniaAPI.registerManaAlchemyRecipe(new ItemStack(Items.clay_ball, 4), new ItemStack(Blocks.clay), 25)); - clayBreakdownRecipes.add(BotaniaAPI.registerManaAlchemyRecipe(new ItemStack(Items.brick, 4), new ItemStack(Blocks.brick_block), 25)); - - coarseDirtRecipe = BotaniaAPI.registerManaAlchemyRecipe(new ItemStack(Blocks.dirt, 1, 1), new ItemStack(Blocks.dirt), 120); - - prismarineRecipe = BotaniaAPI.registerManaAlchemyRecipe(new ItemStack(ModItems.manaResource, 1, 10), new ItemStack(Items.quartz), 200); - - if(ConfigHandler.stones18Enabled) { - stoneRecipes = new ArrayList(); - stoneRecipes.add(BotaniaAPI.registerManaAlchemyRecipe(new ItemStack(ModFluffBlocks.stone), "stone", 200)); - for(int i = 0; i < 4; i++) - stoneRecipes.add(BotaniaAPI.registerManaAlchemyRecipe(new ItemStack(ModFluffBlocks.stone, 1, i), new ItemStack(ModFluffBlocks.stone, 1, i == 0 ? 3 : i - 1), 200)); - } - - tallgrassRecipes = new ArrayList(); - tallgrassRecipes.add(BotaniaAPI.registerManaAlchemyRecipe(new ItemStack(Blocks.deadbush), new ItemStack(Blocks.tallgrass, 1, 2), 500)); - tallgrassRecipes.add(BotaniaAPI.registerManaAlchemyRecipe(new ItemStack(Blocks.tallgrass, 1, 1), new ItemStack(Blocks.deadbush), 500)); - tallgrassRecipes.add(BotaniaAPI.registerManaAlchemyRecipe(new ItemStack(Blocks.tallgrass, 1, 2), new ItemStack(Blocks.tallgrass, 1, 1), 500)); - - flowersRecipes = new ArrayList(); - flowersRecipes.add(BotaniaAPI.registerManaAlchemyRecipe(new ItemStack(Blocks.red_flower), new ItemStack(Blocks.yellow_flower), 400)); - flowersRecipes.add(BotaniaAPI.registerManaAlchemyRecipe(new ItemStack(Blocks.red_flower, 1, 1), new ItemStack(Blocks.red_flower), 400)); - flowersRecipes.add(BotaniaAPI.registerManaAlchemyRecipe(new ItemStack(Blocks.red_flower, 1, 2), new ItemStack(Blocks.red_flower, 1, 1), 400)); - flowersRecipes.add(BotaniaAPI.registerManaAlchemyRecipe(new ItemStack(Blocks.red_flower, 1, 3), new ItemStack(Blocks.red_flower, 1, 2), 400)); - flowersRecipes.add(BotaniaAPI.registerManaAlchemyRecipe(new ItemStack(Blocks.red_flower, 1, 4), new ItemStack(Blocks.red_flower, 1, 3), 400)); - flowersRecipes.add(BotaniaAPI.registerManaAlchemyRecipe(new ItemStack(Blocks.red_flower, 1, 5), new ItemStack(Blocks.red_flower, 1, 4), 400)); - flowersRecipes.add(BotaniaAPI.registerManaAlchemyRecipe(new ItemStack(Blocks.red_flower, 1, 6), new ItemStack(Blocks.red_flower, 1, 5), 400)); - flowersRecipes.add(BotaniaAPI.registerManaAlchemyRecipe(new ItemStack(Blocks.red_flower, 1, 7), new ItemStack(Blocks.red_flower, 1, 6), 400)); - flowersRecipes.add(BotaniaAPI.registerManaAlchemyRecipe(new ItemStack(Blocks.red_flower, 1, 8), new ItemStack(Blocks.red_flower, 1, 7), 400)); - flowersRecipes.add(BotaniaAPI.registerManaAlchemyRecipe(new ItemStack(Blocks.double_plant), new ItemStack(Blocks.red_flower, 1, 8), 400)); - flowersRecipes.add(BotaniaAPI.registerManaAlchemyRecipe(new ItemStack(Blocks.double_plant, 1, 1), new ItemStack(Blocks.double_plant), 400)); - flowersRecipes.add(BotaniaAPI.registerManaAlchemyRecipe(new ItemStack(Blocks.double_plant, 1, 4), new ItemStack(Blocks.double_plant, 1, 1), 400)); - flowersRecipes.add(BotaniaAPI.registerManaAlchemyRecipe(new ItemStack(Blocks.double_plant, 1, 5), new ItemStack(Blocks.double_plant, 1, 4), 400)); - flowersRecipes.add(BotaniaAPI.registerManaAlchemyRecipe(new ItemStack(Blocks.yellow_flower), new ItemStack(Blocks.double_plant, 1, 5), 400)); - } + public static RecipeManaInfusion leatherRecipe; + public static List woodRecipes; + public static List saplingRecipes; + public static RecipeManaInfusion glowstoneDustRecipe; + public static List quartzRecipes; + public static RecipeManaInfusion chiseledBrickRecipe; + public static RecipeManaInfusion iceRecipe; + public static List swampFolliageRecipes; + public static List fishRecipes; + public static List cropRecipes; + public static RecipeManaInfusion potatoRecipe; + public static RecipeManaInfusion netherWartRecipe; + public static List gunpowderAndFlintRecipes; + public static RecipeManaInfusion nameTagRecipe; + public static List stringRecipes; + public static List slimeballCactusRecipes; + public static RecipeManaInfusion enderPearlRecipe; + public static List redstoneToGlowstoneRecipes; + public static RecipeManaInfusion sandRecipe; + public static RecipeManaInfusion redSandRecipe; + public static List clayBreakdownRecipes; + public static RecipeManaInfusion coarseDirtRecipe; + public static RecipeManaInfusion prismarineRecipe; + public static List stoneRecipes; + public static List tallgrassRecipes; + public static List flowersRecipes; + + public static void init() { + if (!ConfigHandler.enableDefaultRecipes) return; + + leatherRecipe = BotaniaAPI.registerManaAlchemyRecipe( + new ItemStack(Items.leather), new ItemStack(Items.rotten_flesh), 600); + + woodRecipes = new ArrayList(); + woodRecipes.add(BotaniaAPI.registerManaAlchemyRecipe( + new ItemStack(Blocks.log, 1, 0), new ItemStack(Blocks.log2, 1, 1), 40)); + woodRecipes.add(BotaniaAPI.registerManaAlchemyRecipe( + new ItemStack(Blocks.log, 1, 1), new ItemStack(Blocks.log, 1, 0), 40)); + woodRecipes.add(BotaniaAPI.registerManaAlchemyRecipe( + new ItemStack(Blocks.log, 1, 2), new ItemStack(Blocks.log, 1, 1), 40)); + woodRecipes.add(BotaniaAPI.registerManaAlchemyRecipe( + new ItemStack(Blocks.log, 1, 3), new ItemStack(Blocks.log, 1, 2), 40)); + woodRecipes.add(BotaniaAPI.registerManaAlchemyRecipe( + new ItemStack(Blocks.log2, 1, 0), new ItemStack(Blocks.log, 1, 3), 40)); + woodRecipes.add(BotaniaAPI.registerManaAlchemyRecipe( + new ItemStack(Blocks.log2, 1, 1), new ItemStack(Blocks.log2, 1, 0), 40)); + + saplingRecipes = new ArrayList(); + for (int i = 0; i < 6; i++) + saplingRecipes.add(BotaniaAPI.registerManaAlchemyRecipe( + new ItemStack(Blocks.sapling, 1, i == 5 ? 0 : i + 1), new ItemStack(Blocks.sapling, 1, i), 120)); + + glowstoneDustRecipe = BotaniaAPI.registerManaAlchemyRecipe( + new ItemStack(Items.glowstone_dust, 4), new ItemStack(Blocks.glowstone), 25); + quartzRecipes = new ArrayList(); + quartzRecipes.add(BotaniaAPI.registerManaAlchemyRecipe( + new ItemStack(Items.quartz, 4), new ItemStack(Blocks.quartz_block, 1, Short.MAX_VALUE), 25)); + if (ConfigHandler.darkQuartzEnabled) + quartzRecipes.add(BotaniaAPI.registerManaAlchemyRecipe( + new ItemStack(ModItems.quartz, 4, 0), + new ItemStack(ModFluffBlocks.darkQuartz, 1, Short.MAX_VALUE), + 25)); + quartzRecipes.add(BotaniaAPI.registerManaAlchemyRecipe( + new ItemStack(ModItems.quartz, 4, 1), + new ItemStack(ModFluffBlocks.manaQuartz, 1, Short.MAX_VALUE), + 25)); + quartzRecipes.add(BotaniaAPI.registerManaAlchemyRecipe( + new ItemStack(ModItems.quartz, 4, 2), + new ItemStack(ModFluffBlocks.blazeQuartz, 1, Short.MAX_VALUE), + 25)); + quartzRecipes.add(BotaniaAPI.registerManaAlchemyRecipe( + new ItemStack(ModItems.quartz, 4, 3), + new ItemStack(ModFluffBlocks.lavenderQuartz, 1, Short.MAX_VALUE), + 25)); + quartzRecipes.add(BotaniaAPI.registerManaAlchemyRecipe( + new ItemStack(ModItems.quartz, 4, 4), new ItemStack(ModFluffBlocks.redQuartz, 1, Short.MAX_VALUE), 25)); + quartzRecipes.add(BotaniaAPI.registerManaAlchemyRecipe( + new ItemStack(ModItems.quartz, 4, 5), new ItemStack(ModFluffBlocks.elfQuartz, 1, Short.MAX_VALUE), 25)); + + chiseledBrickRecipe = BotaniaAPI.registerManaAlchemyRecipe( + new ItemStack(Blocks.stonebrick, 1, 3), new ItemStack(Blocks.stonebrick), 150); + iceRecipe = BotaniaAPI.registerManaAlchemyRecipe(new ItemStack(Blocks.ice), new ItemStack(Blocks.snow), 2250); + + swampFolliageRecipes = new ArrayList(); + swampFolliageRecipes.add( + BotaniaAPI.registerManaAlchemyRecipe(new ItemStack(Blocks.waterlily), new ItemStack(Blocks.vine), 320)); + swampFolliageRecipes.add( + BotaniaAPI.registerManaAlchemyRecipe(new ItemStack(Blocks.vine), new ItemStack(Blocks.waterlily), 320)); + + fishRecipes = new ArrayList(); + for (int i = 0; i < 4; i++) + fishRecipes.add(BotaniaAPI.registerManaAlchemyRecipe( + new ItemStack(Items.fish, 1, i == 3 ? 0 : i + 1), new ItemStack(Items.fish, 1, i), 200)); + + cropRecipes = new ArrayList(); + cropRecipes.add(BotaniaAPI.registerManaAlchemyRecipe( + new ItemStack(Items.wheat_seeds), new ItemStack(Items.dye, 1, 3), 6000)); + cropRecipes.add( + BotaniaAPI.registerManaAlchemyRecipe(new ItemStack(Items.potato), new ItemStack(Items.wheat), 6000)); + cropRecipes.add( + BotaniaAPI.registerManaAlchemyRecipe(new ItemStack(Items.carrot), new ItemStack(Items.potato), 6000)); + cropRecipes.add(BotaniaAPI.registerManaAlchemyRecipe( + new ItemStack(Items.melon_seeds), new ItemStack(Items.carrot), 6000)); + cropRecipes.add(BotaniaAPI.registerManaAlchemyRecipe( + new ItemStack(Items.pumpkin_seeds), new ItemStack(Items.melon_seeds), 6000)); + cropRecipes.add(BotaniaAPI.registerManaAlchemyRecipe( + new ItemStack(Items.dye, 1, 3), new ItemStack(Items.pumpkin_seeds), 6000)); + + potatoRecipe = BotaniaAPI.registerManaAlchemyRecipe( + new ItemStack(Items.potato), new ItemStack(Items.poisonous_potato), 1200); + netherWartRecipe = BotaniaAPI.registerManaAlchemyRecipe( + new ItemStack(Items.nether_wart), new ItemStack(Items.blaze_rod), 4000); + + gunpowderAndFlintRecipes = new ArrayList(); + gunpowderAndFlintRecipes.add( + BotaniaAPI.registerManaAlchemyRecipe(new ItemStack(Items.flint), new ItemStack(Items.gunpowder), 200)); + gunpowderAndFlintRecipes.add( + BotaniaAPI.registerManaAlchemyRecipe(new ItemStack(Items.gunpowder), new ItemStack(Items.flint), 4000)); + + nameTagRecipe = BotaniaAPI.registerManaAlchemyRecipe( + new ItemStack(Items.name_tag), new ItemStack(Items.writable_book), 16000); + + stringRecipes = new ArrayList(); + for (int i = 0; i < 16; i++) + stringRecipes.add(BotaniaAPI.registerManaAlchemyRecipe( + new ItemStack(Items.string, 3), new ItemStack(Blocks.wool, 1, i), 100)); + + slimeballCactusRecipes = new ArrayList(); + slimeballCactusRecipes.add(BotaniaAPI.registerManaAlchemyRecipe( + new ItemStack(Items.slime_ball), new ItemStack(Blocks.cactus), 1200)); + slimeballCactusRecipes.add(BotaniaAPI.registerManaAlchemyRecipe( + new ItemStack(Blocks.cactus), new ItemStack(Items.slime_ball), 1200)); + + enderPearlRecipe = BotaniaAPI.registerManaAlchemyRecipe( + new ItemStack(Items.ender_pearl), new ItemStack(Items.ghast_tear), 28000); + + redstoneToGlowstoneRecipes = new ArrayList(); + redstoneToGlowstoneRecipes.add(BotaniaAPI.registerManaAlchemyRecipe( + new ItemStack(Items.redstone), new ItemStack(Items.glowstone_dust), 300)); + redstoneToGlowstoneRecipes.add(BotaniaAPI.registerManaAlchemyRecipe( + new ItemStack(Items.glowstone_dust), new ItemStack(Items.redstone), 300)); + + sandRecipe = BotaniaAPI.registerManaAlchemyRecipe( + new ItemStack(Block.getBlockFromName("sand")), new ItemStack(Blocks.cobblestone), 50); + redSandRecipe = BotaniaAPI.registerManaAlchemyRecipe( + new ItemStack(Block.getBlockFromName("sand"), 1, 1), new ItemStack(Blocks.hardened_clay), 50); + + clayBreakdownRecipes = new ArrayList(); + clayBreakdownRecipes.add(BotaniaAPI.registerManaAlchemyRecipe( + new ItemStack(Items.clay_ball, 4), new ItemStack(Blocks.clay), 25)); + clayBreakdownRecipes.add(BotaniaAPI.registerManaAlchemyRecipe( + new ItemStack(Items.brick, 4), new ItemStack(Blocks.brick_block), 25)); + + coarseDirtRecipe = + BotaniaAPI.registerManaAlchemyRecipe(new ItemStack(Blocks.dirt, 1, 1), new ItemStack(Blocks.dirt), 120); + + prismarineRecipe = BotaniaAPI.registerManaAlchemyRecipe( + new ItemStack(ModItems.manaResource, 1, 10), new ItemStack(Items.quartz), 200); + + if (ConfigHandler.stones18Enabled) { + stoneRecipes = new ArrayList(); + stoneRecipes.add(BotaniaAPI.registerManaAlchemyRecipe(new ItemStack(ModFluffBlocks.stone), "stone", 200)); + for (int i = 0; i < 4; i++) + stoneRecipes.add(BotaniaAPI.registerManaAlchemyRecipe( + new ItemStack(ModFluffBlocks.stone, 1, i), + new ItemStack(ModFluffBlocks.stone, 1, i == 0 ? 3 : i - 1), + 200)); + } + + tallgrassRecipes = new ArrayList(); + tallgrassRecipes.add(BotaniaAPI.registerManaAlchemyRecipe( + new ItemStack(Blocks.deadbush), new ItemStack(Blocks.tallgrass, 1, 2), 500)); + tallgrassRecipes.add(BotaniaAPI.registerManaAlchemyRecipe( + new ItemStack(Blocks.tallgrass, 1, 1), new ItemStack(Blocks.deadbush), 500)); + tallgrassRecipes.add(BotaniaAPI.registerManaAlchemyRecipe( + new ItemStack(Blocks.tallgrass, 1, 2), new ItemStack(Blocks.tallgrass, 1, 1), 500)); + + flowersRecipes = new ArrayList(); + flowersRecipes.add(BotaniaAPI.registerManaAlchemyRecipe( + new ItemStack(Blocks.red_flower), new ItemStack(Blocks.yellow_flower), 400)); + flowersRecipes.add(BotaniaAPI.registerManaAlchemyRecipe( + new ItemStack(Blocks.red_flower, 1, 1), new ItemStack(Blocks.red_flower), 400)); + flowersRecipes.add(BotaniaAPI.registerManaAlchemyRecipe( + new ItemStack(Blocks.red_flower, 1, 2), new ItemStack(Blocks.red_flower, 1, 1), 400)); + flowersRecipes.add(BotaniaAPI.registerManaAlchemyRecipe( + new ItemStack(Blocks.red_flower, 1, 3), new ItemStack(Blocks.red_flower, 1, 2), 400)); + flowersRecipes.add(BotaniaAPI.registerManaAlchemyRecipe( + new ItemStack(Blocks.red_flower, 1, 4), new ItemStack(Blocks.red_flower, 1, 3), 400)); + flowersRecipes.add(BotaniaAPI.registerManaAlchemyRecipe( + new ItemStack(Blocks.red_flower, 1, 5), new ItemStack(Blocks.red_flower, 1, 4), 400)); + flowersRecipes.add(BotaniaAPI.registerManaAlchemyRecipe( + new ItemStack(Blocks.red_flower, 1, 6), new ItemStack(Blocks.red_flower, 1, 5), 400)); + flowersRecipes.add(BotaniaAPI.registerManaAlchemyRecipe( + new ItemStack(Blocks.red_flower, 1, 7), new ItemStack(Blocks.red_flower, 1, 6), 400)); + flowersRecipes.add(BotaniaAPI.registerManaAlchemyRecipe( + new ItemStack(Blocks.red_flower, 1, 8), new ItemStack(Blocks.red_flower, 1, 7), 400)); + flowersRecipes.add(BotaniaAPI.registerManaAlchemyRecipe( + new ItemStack(Blocks.double_plant), new ItemStack(Blocks.red_flower, 1, 8), 400)); + flowersRecipes.add(BotaniaAPI.registerManaAlchemyRecipe( + new ItemStack(Blocks.double_plant, 1, 1), new ItemStack(Blocks.double_plant), 400)); + flowersRecipes.add(BotaniaAPI.registerManaAlchemyRecipe( + new ItemStack(Blocks.double_plant, 1, 4), new ItemStack(Blocks.double_plant, 1, 1), 400)); + flowersRecipes.add(BotaniaAPI.registerManaAlchemyRecipe( + new ItemStack(Blocks.double_plant, 1, 5), new ItemStack(Blocks.double_plant, 1, 4), 400)); + flowersRecipes.add(BotaniaAPI.registerManaAlchemyRecipe( + new ItemStack(Blocks.yellow_flower), new ItemStack(Blocks.double_plant, 1, 5), 400)); + } } diff --git a/src/main/java/vazkii/botania/common/crafting/ModManaConjurationRecipes.java b/src/main/java/vazkii/botania/common/crafting/ModManaConjurationRecipes.java index a25c4ac665..6d6d3aa4b4 100644 --- a/src/main/java/vazkii/botania/common/crafting/ModManaConjurationRecipes.java +++ b/src/main/java/vazkii/botania/common/crafting/ModManaConjurationRecipes.java @@ -2,17 +2,16 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jun 20, 2014, 3:57:02 PM (GMT)] */ package vazkii.botania.common.crafting; import java.util.ArrayList; import java.util.List; - import net.minecraft.block.Block; import net.minecraft.init.Blocks; import net.minecraft.init.Items; @@ -23,36 +22,48 @@ public class ModManaConjurationRecipes { - public static RecipeManaInfusion redstoneRecipe; - public static RecipeManaInfusion glowstoneRecipe; - public static RecipeManaInfusion quartzRecipe; - public static RecipeManaInfusion coalRecipe; - public static RecipeManaInfusion snowballRecipe; - public static RecipeManaInfusion netherrackRecipe; - public static RecipeManaInfusion soulSandRecipe; - public static RecipeManaInfusion gravelRecipe; - public static List leavesRecipes; - public static RecipeManaInfusion grassRecipe; - - public static void init() { - if (!ConfigHandler.enableDefaultRecipes) return; + public static RecipeManaInfusion redstoneRecipe; + public static RecipeManaInfusion glowstoneRecipe; + public static RecipeManaInfusion quartzRecipe; + public static RecipeManaInfusion coalRecipe; + public static RecipeManaInfusion snowballRecipe; + public static RecipeManaInfusion netherrackRecipe; + public static RecipeManaInfusion soulSandRecipe; + public static RecipeManaInfusion gravelRecipe; + public static List leavesRecipes; + public static RecipeManaInfusion grassRecipe; - redstoneRecipe = BotaniaAPI.registerManaConjurationRecipe(new ItemStack(Items.redstone, 2), new ItemStack(Items.redstone), 5000); - glowstoneRecipe = BotaniaAPI.registerManaConjurationRecipe(new ItemStack(Items.glowstone_dust, 2), new ItemStack(Items.glowstone_dust), 5000); - quartzRecipe = BotaniaAPI.registerManaConjurationRecipe(new ItemStack(Items.quartz, 2), new ItemStack(Items.quartz), 2500); - coalRecipe = BotaniaAPI.registerManaConjurationRecipe(new ItemStack(Items.coal, 2), new ItemStack(Items.coal), 2100); - snowballRecipe = BotaniaAPI.registerManaConjurationRecipe(new ItemStack(Items.snowball, 2), new ItemStack(Items.snowball), 200); - netherrackRecipe = BotaniaAPI.registerManaConjurationRecipe(new ItemStack(Blocks.netherrack, 2), new ItemStack(Blocks.netherrack), 200); - soulSandRecipe = BotaniaAPI.registerManaConjurationRecipe(new ItemStack(Blocks.soul_sand, 2), new ItemStack(Blocks.soul_sand), 1500); - gravelRecipe = BotaniaAPI.registerManaConjurationRecipe(new ItemStack(Block.getBlockFromName("gravel"), 2), new ItemStack(Block.getBlockFromName("gravel")), 720); + public static void init() { + if (!ConfigHandler.enableDefaultRecipes) return; - leavesRecipes = new ArrayList(); - for(int i = 0; i < 4; i++) - leavesRecipes.add(BotaniaAPI.registerManaConjurationRecipe(new ItemStack(Blocks.leaves, 2, i), new ItemStack(Blocks.leaves, 1, i), 2000)); - for(int i = 0; i < 2; i++) - leavesRecipes.add(BotaniaAPI.registerManaConjurationRecipe(new ItemStack(Blocks.leaves2, 2, i), new ItemStack(Blocks.leaves2, 1, i), 2000)); + redstoneRecipe = BotaniaAPI.registerManaConjurationRecipe( + new ItemStack(Items.redstone, 2), new ItemStack(Items.redstone), 5000); + glowstoneRecipe = BotaniaAPI.registerManaConjurationRecipe( + new ItemStack(Items.glowstone_dust, 2), new ItemStack(Items.glowstone_dust), 5000); + quartzRecipe = BotaniaAPI.registerManaConjurationRecipe( + new ItemStack(Items.quartz, 2), new ItemStack(Items.quartz), 2500); + coalRecipe = + BotaniaAPI.registerManaConjurationRecipe(new ItemStack(Items.coal, 2), new ItemStack(Items.coal), 2100); + snowballRecipe = BotaniaAPI.registerManaConjurationRecipe( + new ItemStack(Items.snowball, 2), new ItemStack(Items.snowball), 200); + netherrackRecipe = BotaniaAPI.registerManaConjurationRecipe( + new ItemStack(Blocks.netherrack, 2), new ItemStack(Blocks.netherrack), 200); + soulSandRecipe = BotaniaAPI.registerManaConjurationRecipe( + new ItemStack(Blocks.soul_sand, 2), new ItemStack(Blocks.soul_sand), 1500); + gravelRecipe = BotaniaAPI.registerManaConjurationRecipe( + new ItemStack(Block.getBlockFromName("gravel"), 2), + new ItemStack(Block.getBlockFromName("gravel")), + 720); - grassRecipe = BotaniaAPI.registerManaConjurationRecipe(new ItemStack(Blocks.tallgrass, 2, 1), new ItemStack(Blocks.tallgrass, 1, 1), 800); - } + leavesRecipes = new ArrayList(); + for (int i = 0; i < 4; i++) + leavesRecipes.add(BotaniaAPI.registerManaConjurationRecipe( + new ItemStack(Blocks.leaves, 2, i), new ItemStack(Blocks.leaves, 1, i), 2000)); + for (int i = 0; i < 2; i++) + leavesRecipes.add(BotaniaAPI.registerManaConjurationRecipe( + new ItemStack(Blocks.leaves2, 2, i), new ItemStack(Blocks.leaves2, 1, i), 2000)); + grassRecipe = BotaniaAPI.registerManaConjurationRecipe( + new ItemStack(Blocks.tallgrass, 2, 1), new ItemStack(Blocks.tallgrass, 1, 1), 800); + } } diff --git a/src/main/java/vazkii/botania/common/crafting/ModManaInfusionRecipes.java b/src/main/java/vazkii/botania/common/crafting/ModManaInfusionRecipes.java index 1fecfb04e8..ae4af2f045 100644 --- a/src/main/java/vazkii/botania/common/crafting/ModManaInfusionRecipes.java +++ b/src/main/java/vazkii/botania/common/crafting/ModManaInfusionRecipes.java @@ -2,17 +2,16 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jan 30, 2014, 6:10:48 PM (GMT)] */ package vazkii.botania.common.crafting; import java.util.ArrayList; import java.util.List; - import net.minecraft.init.Blocks; import net.minecraft.init.Items; import net.minecraft.item.Item; @@ -26,68 +25,92 @@ public final class ModManaInfusionRecipes { - public static List manasteelRecipes; - public static RecipeManaInfusion manaPearlRecipe; - public static List manaDiamondRecipes; - public static List manaPowderRecipes; - public static RecipeManaInfusion pistonRelayRecipe; - public static RecipeManaInfusion manaCookieRecipe; - public static RecipeManaInfusion grassSeedsRecipe; - public static RecipeManaInfusion podzolSeedsRecipe; - public static List mycelSeedsRecipes; - public static RecipeManaInfusion manaQuartzRecipe; - public static RecipeManaInfusion tinyPotatoRecipe; - public static RecipeManaInfusion manaInkwellRecipe; - public static RecipeManaInfusion managlassRecipe; - public static RecipeManaInfusion manaStringRecipe; - - public static RecipeManaInfusion sugarCaneRecipe; - - public static void init() { - if (!ConfigHandler.enableDefaultRecipes) return; - - manasteelRecipes = new ArrayList(); - manasteelRecipes.add(BotaniaAPI.registerManaInfusionRecipe(new ItemStack(ModItems.manaResource, 1, 0), "ingotIron", 3000)); - manasteelRecipes.add(BotaniaAPI.registerManaInfusionRecipe(new ItemStack(ModBlocks.storage, 1, 0), new ItemStack(Blocks.iron_block), 27000)); - - manaPearlRecipe = BotaniaAPI.registerManaInfusionRecipe(new ItemStack(ModItems.manaResource, 1, 1), new ItemStack(Items.ender_pearl), 6000); - - manaDiamondRecipes = new ArrayList(); - manaDiamondRecipes.add(BotaniaAPI.registerManaInfusionRecipe(new ItemStack(ModItems.manaResource, 1, 2), "gemDiamond", 10000)); - manaDiamondRecipes.add(BotaniaAPI.registerManaInfusionRecipe(new ItemStack(ModBlocks.storage, 1, 3), new ItemStack(Blocks.diamond_block), 90000)); - - manaPowderRecipes = new ArrayList(); - manaPowderRecipes.add(BotaniaAPI.registerManaInfusionRecipe(new ItemStack(ModItems.manaResource, 1, 23), new ItemStack(Items.gunpowder), 500)); - manaPowderRecipes.add(BotaniaAPI.registerManaInfusionRecipe(new ItemStack(ModItems.manaResource, 1, 23), new ItemStack(Items.redstone), 500)); - manaPowderRecipes.add(BotaniaAPI.registerManaInfusionRecipe(new ItemStack(ModItems.manaResource, 1, 23), new ItemStack(Items.glowstone_dust), 500)); - manaPowderRecipes.add(BotaniaAPI.registerManaInfusionRecipe(new ItemStack(ModItems.manaResource, 1, 23), new ItemStack(Items.sugar), 500)); - for(int i = 0; i < 16; i++) - manaPowderRecipes.add(BotaniaAPI.registerManaInfusionRecipe(new ItemStack(ModItems.manaResource, 1, 23), new ItemStack(ModItems.dye, 1, i), 400)); - - pistonRelayRecipe = BotaniaAPI.registerManaInfusionRecipe(new ItemStack(ModBlocks.pistonRelay), new ItemStack(Blocks.piston), 15000); - manaCookieRecipe = BotaniaAPI.registerManaInfusionRecipe(new ItemStack(ModItems.manaCookie), new ItemStack(Items.cookie), 20000); - grassSeedsRecipe = BotaniaAPI.registerManaInfusionRecipe(new ItemStack(ModItems.grassSeeds), new ItemStack(Blocks.tallgrass, 1, 1), 2500); - podzolSeedsRecipe = BotaniaAPI.registerManaInfusionRecipe(new ItemStack(ModItems.grassSeeds, 1, 1), new ItemStack(Blocks.deadbush), 2500); - - mycelSeedsRecipes = new ArrayList(); - mycelSeedsRecipes.add(BotaniaAPI.registerManaInfusionRecipe(new ItemStack(ModItems.grassSeeds, 1, 2), new ItemStack(Blocks.red_mushroom), 6500)); - mycelSeedsRecipes.add(BotaniaAPI.registerManaInfusionRecipe(new ItemStack(ModItems.grassSeeds, 1, 2), new ItemStack(Blocks.brown_mushroom), 6500)); - - manaQuartzRecipe = BotaniaAPI.registerManaInfusionRecipe(new ItemStack(ModItems.quartz, 1, 1), new ItemStack(Items.quartz), 250); - tinyPotatoRecipe = BotaniaAPI.registerManaInfusionRecipe(new ItemStack(ModBlocks.tinyPotato), new ItemStack(Items.potato), 1337); - - if(Botania.thaumcraftLoaded) { - Item inkwell = (Item) Item.itemRegistry.getObject("Thaumcraft:ItemInkwell"); - manaInkwellRecipe = BotaniaAPI.registerManaInfusionRecipe(new ItemStack(ModItems.manaInkwell, 1, ModItems.manaInkwell.getMaxDamage()), new ItemStack(inkwell), 35000); - } - - managlassRecipe = BotaniaAPI.registerManaInfusionRecipe(new ItemStack(ModBlocks.manaGlass), new ItemStack(Blocks.glass), 150); - manaStringRecipe = BotaniaAPI.registerManaInfusionRecipe(new ItemStack(ModItems.manaResource, 1, 16), new ItemStack(Items.string), 5000); - - if(Botania.gardenOfGlassLoaded) - sugarCaneRecipe = BotaniaAPI.registerManaInfusionRecipe(new ItemStack(Items.reeds), new ItemStack(Blocks.hay_block), 2000); - - BotaniaAPI.registerManaInfusionRecipe(new ItemStack(ModItems.manaBottle), new ItemStack(Items.glass_bottle), 5000); - } - + public static List manasteelRecipes; + public static RecipeManaInfusion manaPearlRecipe; + public static List manaDiamondRecipes; + public static List manaPowderRecipes; + public static RecipeManaInfusion pistonRelayRecipe; + public static RecipeManaInfusion manaCookieRecipe; + public static RecipeManaInfusion grassSeedsRecipe; + public static RecipeManaInfusion podzolSeedsRecipe; + public static List mycelSeedsRecipes; + public static RecipeManaInfusion manaQuartzRecipe; + public static RecipeManaInfusion tinyPotatoRecipe; + public static RecipeManaInfusion manaInkwellRecipe; + public static RecipeManaInfusion managlassRecipe; + public static RecipeManaInfusion manaStringRecipe; + + public static RecipeManaInfusion sugarCaneRecipe; + + public static void init() { + if (!ConfigHandler.enableDefaultRecipes) return; + + manasteelRecipes = new ArrayList(); + manasteelRecipes.add( + BotaniaAPI.registerManaInfusionRecipe(new ItemStack(ModItems.manaResource, 1, 0), "ingotIron", 3000)); + manasteelRecipes.add(BotaniaAPI.registerManaInfusionRecipe( + new ItemStack(ModBlocks.storage, 1, 0), new ItemStack(Blocks.iron_block), 27000)); + + manaPearlRecipe = BotaniaAPI.registerManaInfusionRecipe( + new ItemStack(ModItems.manaResource, 1, 1), new ItemStack(Items.ender_pearl), 6000); + + manaDiamondRecipes = new ArrayList(); + manaDiamondRecipes.add( + BotaniaAPI.registerManaInfusionRecipe(new ItemStack(ModItems.manaResource, 1, 2), "gemDiamond", 10000)); + manaDiamondRecipes.add(BotaniaAPI.registerManaInfusionRecipe( + new ItemStack(ModBlocks.storage, 1, 3), new ItemStack(Blocks.diamond_block), 90000)); + + manaPowderRecipes = new ArrayList(); + manaPowderRecipes.add(BotaniaAPI.registerManaInfusionRecipe( + new ItemStack(ModItems.manaResource, 1, 23), new ItemStack(Items.gunpowder), 500)); + manaPowderRecipes.add(BotaniaAPI.registerManaInfusionRecipe( + new ItemStack(ModItems.manaResource, 1, 23), new ItemStack(Items.redstone), 500)); + manaPowderRecipes.add(BotaniaAPI.registerManaInfusionRecipe( + new ItemStack(ModItems.manaResource, 1, 23), new ItemStack(Items.glowstone_dust), 500)); + manaPowderRecipes.add(BotaniaAPI.registerManaInfusionRecipe( + new ItemStack(ModItems.manaResource, 1, 23), new ItemStack(Items.sugar), 500)); + for (int i = 0; i < 16; i++) + manaPowderRecipes.add(BotaniaAPI.registerManaInfusionRecipe( + new ItemStack(ModItems.manaResource, 1, 23), new ItemStack(ModItems.dye, 1, i), 400)); + + pistonRelayRecipe = BotaniaAPI.registerManaInfusionRecipe( + new ItemStack(ModBlocks.pistonRelay), new ItemStack(Blocks.piston), 15000); + manaCookieRecipe = BotaniaAPI.registerManaInfusionRecipe( + new ItemStack(ModItems.manaCookie), new ItemStack(Items.cookie), 20000); + grassSeedsRecipe = BotaniaAPI.registerManaInfusionRecipe( + new ItemStack(ModItems.grassSeeds), new ItemStack(Blocks.tallgrass, 1, 1), 2500); + podzolSeedsRecipe = BotaniaAPI.registerManaInfusionRecipe( + new ItemStack(ModItems.grassSeeds, 1, 1), new ItemStack(Blocks.deadbush), 2500); + + mycelSeedsRecipes = new ArrayList(); + mycelSeedsRecipes.add(BotaniaAPI.registerManaInfusionRecipe( + new ItemStack(ModItems.grassSeeds, 1, 2), new ItemStack(Blocks.red_mushroom), 6500)); + mycelSeedsRecipes.add(BotaniaAPI.registerManaInfusionRecipe( + new ItemStack(ModItems.grassSeeds, 1, 2), new ItemStack(Blocks.brown_mushroom), 6500)); + + manaQuartzRecipe = BotaniaAPI.registerManaInfusionRecipe( + new ItemStack(ModItems.quartz, 1, 1), new ItemStack(Items.quartz), 250); + tinyPotatoRecipe = BotaniaAPI.registerManaInfusionRecipe( + new ItemStack(ModBlocks.tinyPotato), new ItemStack(Items.potato), 1337); + + if (Botania.thaumcraftLoaded) { + Item inkwell = (Item) Item.itemRegistry.getObject("Thaumcraft:ItemInkwell"); + manaInkwellRecipe = BotaniaAPI.registerManaInfusionRecipe( + new ItemStack(ModItems.manaInkwell, 1, ModItems.manaInkwell.getMaxDamage()), + new ItemStack(inkwell), + 35000); + } + + managlassRecipe = BotaniaAPI.registerManaInfusionRecipe( + new ItemStack(ModBlocks.manaGlass), new ItemStack(Blocks.glass), 150); + manaStringRecipe = BotaniaAPI.registerManaInfusionRecipe( + new ItemStack(ModItems.manaResource, 1, 16), new ItemStack(Items.string), 5000); + + if (Botania.gardenOfGlassLoaded) + sugarCaneRecipe = BotaniaAPI.registerManaInfusionRecipe( + new ItemStack(Items.reeds), new ItemStack(Blocks.hay_block), 2000); + + BotaniaAPI.registerManaInfusionRecipe( + new ItemStack(ModItems.manaBottle), new ItemStack(Items.glass_bottle), 5000); + } } diff --git a/src/main/java/vazkii/botania/common/crafting/ModPetalRecipes.java b/src/main/java/vazkii/botania/common/crafting/ModPetalRecipes.java index f1cb020709..c85008f369 100644 --- a/src/main/java/vazkii/botania/common/crafting/ModPetalRecipes.java +++ b/src/main/java/vazkii/botania/common/crafting/ModPetalRecipes.java @@ -2,16 +2,15 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jan 22], 2014], 2:22:21 PM (GMT)] */ package vazkii.botania.common.crafting; import java.util.Arrays; - import net.minecraft.init.Items; import net.minecraft.item.ItemStack; import vazkii.botania.api.BotaniaAPI; @@ -25,113 +24,437 @@ public final class ModPetalRecipes { - public static final String white = LibOreDict.PETAL[0], orange = LibOreDict.PETAL[1], magenta = LibOreDict.PETAL[2], lightBlue = LibOreDict.PETAL[3], yellow = LibOreDict.PETAL[4], lime = LibOreDict.PETAL[5], pink = LibOreDict.PETAL[6], gray = LibOreDict.PETAL[7], lightGray = LibOreDict.PETAL[8], cyan = LibOreDict.PETAL[9], purple = LibOreDict.PETAL[10], blue = LibOreDict.PETAL[11], brown = LibOreDict.PETAL[12], green = LibOreDict.PETAL[13], red = LibOreDict.PETAL[14], black = LibOreDict.PETAL[15]; - public static final String runeWater = LibOreDict.RUNE[0], runeFire = LibOreDict.RUNE[1], runeEarth = LibOreDict.RUNE[2], runeAir = LibOreDict.RUNE[3], runeSpring = LibOreDict.RUNE[4], runeSummer = LibOreDict.RUNE[5], runeAutumn = LibOreDict.RUNE[6], runeWinter = LibOreDict.RUNE[7], runeMana = LibOreDict.RUNE[8], runeLust = LibOreDict.RUNE[9], runeGluttony = LibOreDict.RUNE[10], runeGreed = LibOreDict.RUNE[11], runeSloth = LibOreDict.RUNE[12], runeWrath = LibOreDict.RUNE[13], runeEnvy = LibOreDict.RUNE[14], runePride = LibOreDict.RUNE[15]; - public static final String redstoneRoot = LibOreDict.REDSTONE_ROOT; - public static final String pixieDust = LibOreDict.PIXIE_DUST; - public static final String gaiaSpirit = LibOreDict.LIFE_ESSENCE; - public static final String manaPowder = LibOreDict.MANA_POWDER; + public static final String white = LibOreDict.PETAL[0], + orange = LibOreDict.PETAL[1], + magenta = LibOreDict.PETAL[2], + lightBlue = LibOreDict.PETAL[3], + yellow = LibOreDict.PETAL[4], + lime = LibOreDict.PETAL[5], + pink = LibOreDict.PETAL[6], + gray = LibOreDict.PETAL[7], + lightGray = LibOreDict.PETAL[8], + cyan = LibOreDict.PETAL[9], + purple = LibOreDict.PETAL[10], + blue = LibOreDict.PETAL[11], + brown = LibOreDict.PETAL[12], + green = LibOreDict.PETAL[13], + red = LibOreDict.PETAL[14], + black = LibOreDict.PETAL[15]; + public static final String runeWater = LibOreDict.RUNE[0], + runeFire = LibOreDict.RUNE[1], + runeEarth = LibOreDict.RUNE[2], + runeAir = LibOreDict.RUNE[3], + runeSpring = LibOreDict.RUNE[4], + runeSummer = LibOreDict.RUNE[5], + runeAutumn = LibOreDict.RUNE[6], + runeWinter = LibOreDict.RUNE[7], + runeMana = LibOreDict.RUNE[8], + runeLust = LibOreDict.RUNE[9], + runeGluttony = LibOreDict.RUNE[10], + runeGreed = LibOreDict.RUNE[11], + runeSloth = LibOreDict.RUNE[12], + runeWrath = LibOreDict.RUNE[13], + runeEnvy = LibOreDict.RUNE[14], + runePride = LibOreDict.RUNE[15]; + public static final String redstoneRoot = LibOreDict.REDSTONE_ROOT; + public static final String pixieDust = LibOreDict.PIXIE_DUST; + public static final String gaiaSpirit = LibOreDict.LIFE_ESSENCE; + public static final String manaPowder = LibOreDict.MANA_POWDER; - public static RecipePetals pureDaisyRecipe; - public static RecipePetals manastarRecipe; + public static RecipePetals pureDaisyRecipe; + public static RecipePetals manastarRecipe; - public static RecipePetals daybloomRecipe; - public static RecipePetals nightshadeRecipe; - public static RecipePetals endoflameRecipe; - public static RecipePetals hydroangeasRecipe; - public static RecipePetals thermalilyRecipe; - public static RecipePetals arcaneRoseRecipe; - public static RecipePetals munchdewRecipe; - public static RecipePetals entropinnyumRecipe; - public static RecipePetals kekimurusRecipe; - public static RecipePetals gourmaryllisRecipe; - public static RecipePetals narslimmusRecipe; - public static RecipePetals spectrolusRecipe; - public static RecipePetals rafflowsiaRecipe; - public static RecipePetals dandelifeonRecipe; + public static RecipePetals daybloomRecipe; + public static RecipePetals nightshadeRecipe; + public static RecipePetals endoflameRecipe; + public static RecipePetals hydroangeasRecipe; + public static RecipePetals thermalilyRecipe; + public static RecipePetals arcaneRoseRecipe; + public static RecipePetals munchdewRecipe; + public static RecipePetals entropinnyumRecipe; + public static RecipePetals kekimurusRecipe; + public static RecipePetals gourmaryllisRecipe; + public static RecipePetals narslimmusRecipe; + public static RecipePetals spectrolusRecipe; + public static RecipePetals rafflowsiaRecipe; + public static RecipePetals dandelifeonRecipe; - public static RecipePetals jadedAmaranthusRecipe; - public static RecipePetals bellethorneRecipe; - public static RecipePetals dreadthorneRecipe; - public static RecipePetals heiseiDreamRecipe; - public static RecipePetals tigerseyeRecipe; - public static RecipePetals orechidRecipe; - public static RecipePetals orechidIgnemRecipe; - public static RecipePetals fallenKanadeRecipe; - public static RecipePetals exoflameRecipe; - public static RecipePetals agricarnationRecipe; - public static RecipePetals hopperhockRecipe; - public static RecipePetals tangleberrieRecipe; - public static RecipePetals jiyuuliaRecipe; - public static RecipePetals rannuncarpusRecipe; - public static RecipePetals hyacidusRecipe; - public static RecipePetals pollidisiacRecipe; - public static RecipePetals clayconiaRecipe; - public static RecipePetals looniumRecipe; - public static RecipePetals daffomillRecipe; - public static RecipePetals vinculotusRecipe; - public static RecipePetals spectranthemumRecipe; - public static RecipePetals medumoneRecipe; - public static RecipePetals marimorphosisRecipe; - public static RecipePetals bubbellRecipe; - public static RecipePetals solegnoliaRecipe; + public static RecipePetals jadedAmaranthusRecipe; + public static RecipePetals bellethorneRecipe; + public static RecipePetals dreadthorneRecipe; + public static RecipePetals heiseiDreamRecipe; + public static RecipePetals tigerseyeRecipe; + public static RecipePetals orechidRecipe; + public static RecipePetals orechidIgnemRecipe; + public static RecipePetals fallenKanadeRecipe; + public static RecipePetals exoflameRecipe; + public static RecipePetals agricarnationRecipe; + public static RecipePetals hopperhockRecipe; + public static RecipePetals tangleberrieRecipe; + public static RecipePetals jiyuuliaRecipe; + public static RecipePetals rannuncarpusRecipe; + public static RecipePetals hyacidusRecipe; + public static RecipePetals pollidisiacRecipe; + public static RecipePetals clayconiaRecipe; + public static RecipePetals looniumRecipe; + public static RecipePetals daffomillRecipe; + public static RecipePetals vinculotusRecipe; + public static RecipePetals spectranthemumRecipe; + public static RecipePetals medumoneRecipe; + public static RecipePetals marimorphosisRecipe; + public static RecipePetals bubbellRecipe; + public static RecipePetals solegnoliaRecipe; - public static void init() { - if (!ConfigHandler.enableDefaultRecipes) return; + public static void init() { + if (!ConfigHandler.enableDefaultRecipes) return; - pureDaisyRecipe = BotaniaAPI.registerPetalRecipe(ItemBlockSpecialFlower.ofType(LibBlockNames.SUBTILE_PUREDAISY), white, white, white, white); - manastarRecipe = BotaniaAPI.registerPetalRecipe(ItemBlockSpecialFlower.ofType(LibBlockNames.SUBTILE_MANASTAR), lightBlue, green, red, cyan); + pureDaisyRecipe = BotaniaAPI.registerPetalRecipe( + ItemBlockSpecialFlower.ofType(LibBlockNames.SUBTILE_PUREDAISY), white, white, white, white); + manastarRecipe = BotaniaAPI.registerPetalRecipe( + ItemBlockSpecialFlower.ofType(LibBlockNames.SUBTILE_MANASTAR), lightBlue, green, red, cyan); - daybloomRecipe = BotaniaAPI.registerPetalRecipe(ItemBlockSpecialFlower.ofType(LibBlockNames.SUBTILE_DAYBLOOM), yellow, yellow, orange, lightBlue); - nightshadeRecipe = BotaniaAPI.registerPetalRecipe(ItemBlockSpecialFlower.ofType(LibBlockNames.SUBTILE_NIGHTSHADE), black, black, purple, gray); - endoflameRecipe = BotaniaAPI.registerPetalRecipe(ItemBlockSpecialFlower.ofType(LibBlockNames.SUBTILE_ENDOFLAME), brown, brown, red, lightGray, manaPowder); - hydroangeasRecipe = BotaniaAPI.registerPetalRecipe(ItemBlockSpecialFlower.ofType(LibBlockNames.SUBTILE_HYDROANGEAS), blue, blue, cyan, cyan, manaPowder); - thermalilyRecipe = BotaniaAPI.registerPetalRecipe(ItemBlockSpecialFlower.ofType(LibBlockNames.SUBTILE_THERMALILY), red, orange, orange, runeEarth, runeFire); - arcaneRoseRecipe = BotaniaAPI.registerPetalRecipe(ItemBlockSpecialFlower.ofType(LibBlockNames.SUBTILE_ARCANE_ROSE), pink, pink, purple, purple, lime, runeMana); - munchdewRecipe = BotaniaAPI.registerPetalRecipe(ItemBlockSpecialFlower.ofType(LibBlockNames.SUBTILE_MUNCHDEW), lime, lime, red, red, green, runeGluttony); - entropinnyumRecipe = BotaniaAPI.registerPetalRecipe(ItemBlockSpecialFlower.ofType(LibBlockNames.SUBTILE_ENTROPINNYUM), red, red, gray, gray, white, white, runeWrath, runeFire); - kekimurusRecipe = BotaniaAPI.registerPetalRecipe(ItemBlockSpecialFlower.ofType(LibBlockNames.SUBTILE_KEKIMURUS), white, white, orange, orange, brown, brown,runeGluttony, pixieDust); - gourmaryllisRecipe = BotaniaAPI.registerPetalRecipe(ItemBlockSpecialFlower.ofType(LibBlockNames.SUBTILE_GOURMARYLLIS), lightGray, lightGray, yellow, yellow, red, runeFire, runeSummer); - narslimmusRecipe = BotaniaAPI.registerPetalRecipe(ItemBlockSpecialFlower.ofType(LibBlockNames.SUBTILE_NARSLIMMUS), lime, lime, green, green, black, runeSummer, runeWater); - spectrolusRecipe = BotaniaAPI.registerPetalRecipe(ItemBlockSpecialFlower.ofType(LibBlockNames.SUBTILE_SPECTROLUS), red, red, green, green, blue, blue, white, white, runeWinter, runeAir, pixieDust); - rafflowsiaRecipe = BotaniaAPI.registerPetalRecipe(ItemBlockSpecialFlower.ofType(LibBlockNames.SUBTILE_RAFFLOWSIA), purple, purple, green, green, black, runeEarth, runePride, pixieDust); - dandelifeonRecipe = BotaniaAPI.registerPetalRecipe(ItemBlockSpecialFlower.ofType(LibBlockNames.SUBTILE_DANDELIFEON), purple, purple, lime, green, runeWater, runeFire, runeEarth, runeAir, gaiaSpirit); + daybloomRecipe = BotaniaAPI.registerPetalRecipe( + ItemBlockSpecialFlower.ofType(LibBlockNames.SUBTILE_DAYBLOOM), yellow, yellow, orange, lightBlue); + nightshadeRecipe = BotaniaAPI.registerPetalRecipe( + ItemBlockSpecialFlower.ofType(LibBlockNames.SUBTILE_NIGHTSHADE), black, black, purple, gray); + endoflameRecipe = BotaniaAPI.registerPetalRecipe( + ItemBlockSpecialFlower.ofType(LibBlockNames.SUBTILE_ENDOFLAME), + brown, + brown, + red, + lightGray, + manaPowder); + hydroangeasRecipe = BotaniaAPI.registerPetalRecipe( + ItemBlockSpecialFlower.ofType(LibBlockNames.SUBTILE_HYDROANGEAS), blue, blue, cyan, cyan, manaPowder); + thermalilyRecipe = BotaniaAPI.registerPetalRecipe( + ItemBlockSpecialFlower.ofType(LibBlockNames.SUBTILE_THERMALILY), + red, + orange, + orange, + runeEarth, + runeFire); + arcaneRoseRecipe = BotaniaAPI.registerPetalRecipe( + ItemBlockSpecialFlower.ofType(LibBlockNames.SUBTILE_ARCANE_ROSE), + pink, + pink, + purple, + purple, + lime, + runeMana); + munchdewRecipe = BotaniaAPI.registerPetalRecipe( + ItemBlockSpecialFlower.ofType(LibBlockNames.SUBTILE_MUNCHDEW), + lime, + lime, + red, + red, + green, + runeGluttony); + entropinnyumRecipe = BotaniaAPI.registerPetalRecipe( + ItemBlockSpecialFlower.ofType(LibBlockNames.SUBTILE_ENTROPINNYUM), + red, + red, + gray, + gray, + white, + white, + runeWrath, + runeFire); + kekimurusRecipe = BotaniaAPI.registerPetalRecipe( + ItemBlockSpecialFlower.ofType(LibBlockNames.SUBTILE_KEKIMURUS), + white, + white, + orange, + orange, + brown, + brown, + runeGluttony, + pixieDust); + gourmaryllisRecipe = BotaniaAPI.registerPetalRecipe( + ItemBlockSpecialFlower.ofType(LibBlockNames.SUBTILE_GOURMARYLLIS), + lightGray, + lightGray, + yellow, + yellow, + red, + runeFire, + runeSummer); + narslimmusRecipe = BotaniaAPI.registerPetalRecipe( + ItemBlockSpecialFlower.ofType(LibBlockNames.SUBTILE_NARSLIMMUS), + lime, + lime, + green, + green, + black, + runeSummer, + runeWater); + spectrolusRecipe = BotaniaAPI.registerPetalRecipe( + ItemBlockSpecialFlower.ofType(LibBlockNames.SUBTILE_SPECTROLUS), + red, + red, + green, + green, + blue, + blue, + white, + white, + runeWinter, + runeAir, + pixieDust); + rafflowsiaRecipe = BotaniaAPI.registerPetalRecipe( + ItemBlockSpecialFlower.ofType(LibBlockNames.SUBTILE_RAFFLOWSIA), + purple, + purple, + green, + green, + black, + runeEarth, + runePride, + pixieDust); + dandelifeonRecipe = BotaniaAPI.registerPetalRecipe( + ItemBlockSpecialFlower.ofType(LibBlockNames.SUBTILE_DANDELIFEON), + purple, + purple, + lime, + green, + runeWater, + runeFire, + runeEarth, + runeAir, + gaiaSpirit); - jadedAmaranthusRecipe = BotaniaAPI.registerPetalRecipe(ItemBlockSpecialFlower.ofType(LibBlockNames.SUBTILE_JADED_AMARANTHUS), purple, lime, green, runeSpring, redstoneRoot); - bellethorneRecipe = BotaniaAPI.registerPetalRecipe(ItemBlockSpecialFlower.ofType(LibBlockNames.SUBTILE_BELLETHORN), red, red, red, cyan, cyan, redstoneRoot); - dreadthorneRecipe = BotaniaAPI.registerPetalRecipe(ItemBlockSpecialFlower.ofType(LibBlockNames.SUBTILE_DREADTHORN), black, black, black, cyan, cyan, redstoneRoot); - heiseiDreamRecipe = BotaniaAPI.registerPetalRecipe(ItemBlockSpecialFlower.ofType(LibBlockNames.SUBTILE_HEISEI_DREAM), magenta, magenta, purple, pink, runeWrath, pixieDust); - tigerseyeRecipe = BotaniaAPI.registerPetalRecipe(ItemBlockSpecialFlower.ofType(LibBlockNames.SUBTILE_TIGERSEYE), yellow, brown, orange, lime, runeAutumn); + jadedAmaranthusRecipe = BotaniaAPI.registerPetalRecipe( + ItemBlockSpecialFlower.ofType(LibBlockNames.SUBTILE_JADED_AMARANTHUS), + purple, + lime, + green, + runeSpring, + redstoneRoot); + bellethorneRecipe = BotaniaAPI.registerPetalRecipe( + ItemBlockSpecialFlower.ofType(LibBlockNames.SUBTILE_BELLETHORN), + red, + red, + red, + cyan, + cyan, + redstoneRoot); + dreadthorneRecipe = BotaniaAPI.registerPetalRecipe( + ItemBlockSpecialFlower.ofType(LibBlockNames.SUBTILE_DREADTHORN), + black, + black, + black, + cyan, + cyan, + redstoneRoot); + heiseiDreamRecipe = BotaniaAPI.registerPetalRecipe( + ItemBlockSpecialFlower.ofType(LibBlockNames.SUBTILE_HEISEI_DREAM), + magenta, + magenta, + purple, + pink, + runeWrath, + pixieDust); + tigerseyeRecipe = BotaniaAPI.registerPetalRecipe( + ItemBlockSpecialFlower.ofType(LibBlockNames.SUBTILE_TIGERSEYE), + yellow, + brown, + orange, + lime, + runeAutumn); - if(Botania.gardenOfGlassLoaded) - orechidRecipe = BotaniaAPI.registerPetalRecipe(ItemBlockSpecialFlower.ofType(LibBlockNames.SUBTILE_ORECHID), gray, gray, yellow, yellow, green, green, red, red); - else orechidRecipe = BotaniaAPI.registerPetalRecipe(ItemBlockSpecialFlower.ofType(LibBlockNames.SUBTILE_ORECHID), gray, gray, yellow, green, red, runePride, runeGreed, redstoneRoot, pixieDust); + if (Botania.gardenOfGlassLoaded) + orechidRecipe = BotaniaAPI.registerPetalRecipe( + ItemBlockSpecialFlower.ofType(LibBlockNames.SUBTILE_ORECHID), + gray, + gray, + yellow, + yellow, + green, + green, + red, + red); + else + orechidRecipe = BotaniaAPI.registerPetalRecipe( + ItemBlockSpecialFlower.ofType(LibBlockNames.SUBTILE_ORECHID), + gray, + gray, + yellow, + green, + red, + runePride, + runeGreed, + redstoneRoot, + pixieDust); - orechidIgnemRecipe = BotaniaAPI.registerPetalRecipe(ItemBlockSpecialFlower.ofType(LibBlockNames.SUBTILE_ORECHID_IGNEM), red, red, white, white, pink, runePride, runeGreed, redstoneRoot, pixieDust); - if(ConfigHandler.fallenKanadeEnabled) - fallenKanadeRecipe = BotaniaAPI.registerPetalRecipe(ItemBlockSpecialFlower.ofType(LibBlockNames.SUBTILE_FALLEN_KANADE), white, white, yellow, yellow, orange, runeSpring); - exoflameRecipe = BotaniaAPI.registerPetalRecipe(ItemBlockSpecialFlower.ofType(LibBlockNames.SUBTILE_EXOFLAME), red, red, gray, lightGray, runeFire, runeSummer); - agricarnationRecipe = BotaniaAPI.registerPetalRecipe(ItemBlockSpecialFlower.ofType(LibBlockNames.SUBTILE_AGRICARNATION), lime, lime, green, yellow, runeSpring, redstoneRoot); - hopperhockRecipe = BotaniaAPI.registerPetalRecipe(ItemBlockSpecialFlower.ofType(LibBlockNames.SUBTILE_HOPPERHOCK), gray, gray, lightGray, lightGray, runeAir, redstoneRoot); - tangleberrieRecipe = BotaniaAPI.registerPetalRecipe(ItemBlockSpecialFlower.ofType(LibBlockNames.SUBTILE_TANGLEBERRIE), cyan, cyan, gray, lightGray, runeAir, runeEarth); - jiyuuliaRecipe = BotaniaAPI.registerPetalRecipe(ItemBlockSpecialFlower.ofType(LibBlockNames.SUBTILE_JIYUULIA), pink, pink, purple, lightGray, runeWater, runeAir); - rannuncarpusRecipe = BotaniaAPI.registerPetalRecipe(ItemBlockSpecialFlower.ofType(LibBlockNames.SUBTILE_RANNUNCARPUS), orange, orange, yellow, runeEarth, redstoneRoot); - hyacidusRecipe = BotaniaAPI.registerPetalRecipe(ItemBlockSpecialFlower.ofType(LibBlockNames.SUBTILE_HYACIDUS), purple, purple, magenta, magenta, green, runeWater, runeAutumn, redstoneRoot); - pollidisiacRecipe = BotaniaAPI.registerPetalRecipe(ItemBlockSpecialFlower.ofType(LibBlockNames.SUBTILE_POLLIDISIAC), red, red, pink, pink, orange, runeLust, runeFire); - clayconiaRecipe = BotaniaAPI.registerPetalRecipe(ItemBlockSpecialFlower.ofType(LibBlockNames.SUBTILE_CLAYCONIA), lightGray, lightGray, gray, cyan, runeEarth); - looniumRecipe = BotaniaAPI.registerPetalRecipe(ItemBlockSpecialFlower.ofType(LibBlockNames.SUBTILE_LOONIUM), green, green, green, green, gray, runeSloth, runeGluttony, runeEnvy, redstoneRoot, pixieDust); - daffomillRecipe = BotaniaAPI.registerPetalRecipe(ItemBlockSpecialFlower.ofType(LibBlockNames.SUBTILE_DAFFOMILL), white, white, brown, yellow, runeAir, redstoneRoot); - vinculotusRecipe = BotaniaAPI.registerPetalRecipe(ItemBlockSpecialFlower.ofType(LibBlockNames.SUBTILE_VINCULOTUS), black, black, purple, purple, green, runeWater, runeSloth, runeLust, redstoneRoot); - spectranthemumRecipe = BotaniaAPI.registerPetalRecipe(ItemBlockSpecialFlower.ofType(LibBlockNames.SUBTILE_SPECTRANTHEMUM), white, white, lightGray, lightGray, cyan, runeEnvy, runeWater, redstoneRoot, pixieDust); - medumoneRecipe = BotaniaAPI.registerPetalRecipe(ItemBlockSpecialFlower.ofType(LibBlockNames.SUBTILE_MEDUMONE), brown, brown, gray, gray, runeEarth, redstoneRoot); - marimorphosisRecipe = BotaniaAPI.registerPetalRecipe(ItemBlockSpecialFlower.ofType(LibBlockNames.SUBTILE_MARIMORPHOSIS), gray, yellow, green, red, runeEarth, runeFire, redstoneRoot); - bubbellRecipe = BotaniaAPI.registerPetalRecipe(ItemBlockSpecialFlower.ofType(LibBlockNames.SUBTILE_BUBBELL), cyan, cyan, lightBlue, lightBlue, blue, blue, runeWater, runeSummer, pixieDust); - solegnoliaRecipe = BotaniaAPI.registerPetalRecipe(ItemBlockSpecialFlower.ofType(LibBlockNames.SUBTILE_SOLEGNOLIA), brown, brown, red, blue, redstoneRoot); + orechidIgnemRecipe = BotaniaAPI.registerPetalRecipe( + ItemBlockSpecialFlower.ofType(LibBlockNames.SUBTILE_ORECHID_IGNEM), + red, + red, + white, + white, + pink, + runePride, + runeGreed, + redstoneRoot, + pixieDust); + if (ConfigHandler.fallenKanadeEnabled) + fallenKanadeRecipe = BotaniaAPI.registerPetalRecipe( + ItemBlockSpecialFlower.ofType(LibBlockNames.SUBTILE_FALLEN_KANADE), + white, + white, + yellow, + yellow, + orange, + runeSpring); + exoflameRecipe = BotaniaAPI.registerPetalRecipe( + ItemBlockSpecialFlower.ofType(LibBlockNames.SUBTILE_EXOFLAME), + red, + red, + gray, + lightGray, + runeFire, + runeSummer); + agricarnationRecipe = BotaniaAPI.registerPetalRecipe( + ItemBlockSpecialFlower.ofType(LibBlockNames.SUBTILE_AGRICARNATION), + lime, + lime, + green, + yellow, + runeSpring, + redstoneRoot); + hopperhockRecipe = BotaniaAPI.registerPetalRecipe( + ItemBlockSpecialFlower.ofType(LibBlockNames.SUBTILE_HOPPERHOCK), + gray, + gray, + lightGray, + lightGray, + runeAir, + redstoneRoot); + tangleberrieRecipe = BotaniaAPI.registerPetalRecipe( + ItemBlockSpecialFlower.ofType(LibBlockNames.SUBTILE_TANGLEBERRIE), + cyan, + cyan, + gray, + lightGray, + runeAir, + runeEarth); + jiyuuliaRecipe = BotaniaAPI.registerPetalRecipe( + ItemBlockSpecialFlower.ofType(LibBlockNames.SUBTILE_JIYUULIA), + pink, + pink, + purple, + lightGray, + runeWater, + runeAir); + rannuncarpusRecipe = BotaniaAPI.registerPetalRecipe( + ItemBlockSpecialFlower.ofType(LibBlockNames.SUBTILE_RANNUNCARPUS), + orange, + orange, + yellow, + runeEarth, + redstoneRoot); + hyacidusRecipe = BotaniaAPI.registerPetalRecipe( + ItemBlockSpecialFlower.ofType(LibBlockNames.SUBTILE_HYACIDUS), + purple, + purple, + magenta, + magenta, + green, + runeWater, + runeAutumn, + redstoneRoot); + pollidisiacRecipe = BotaniaAPI.registerPetalRecipe( + ItemBlockSpecialFlower.ofType(LibBlockNames.SUBTILE_POLLIDISIAC), + red, + red, + pink, + pink, + orange, + runeLust, + runeFire); + clayconiaRecipe = BotaniaAPI.registerPetalRecipe( + ItemBlockSpecialFlower.ofType(LibBlockNames.SUBTILE_CLAYCONIA), + lightGray, + lightGray, + gray, + cyan, + runeEarth); + looniumRecipe = BotaniaAPI.registerPetalRecipe( + ItemBlockSpecialFlower.ofType(LibBlockNames.SUBTILE_LOONIUM), + green, + green, + green, + green, + gray, + runeSloth, + runeGluttony, + runeEnvy, + redstoneRoot, + pixieDust); + daffomillRecipe = BotaniaAPI.registerPetalRecipe( + ItemBlockSpecialFlower.ofType(LibBlockNames.SUBTILE_DAFFOMILL), + white, + white, + brown, + yellow, + runeAir, + redstoneRoot); + vinculotusRecipe = BotaniaAPI.registerPetalRecipe( + ItemBlockSpecialFlower.ofType(LibBlockNames.SUBTILE_VINCULOTUS), + black, + black, + purple, + purple, + green, + runeWater, + runeSloth, + runeLust, + redstoneRoot); + spectranthemumRecipe = BotaniaAPI.registerPetalRecipe( + ItemBlockSpecialFlower.ofType(LibBlockNames.SUBTILE_SPECTRANTHEMUM), + white, + white, + lightGray, + lightGray, + cyan, + runeEnvy, + runeWater, + redstoneRoot, + pixieDust); + medumoneRecipe = BotaniaAPI.registerPetalRecipe( + ItemBlockSpecialFlower.ofType(LibBlockNames.SUBTILE_MEDUMONE), + brown, + brown, + gray, + gray, + runeEarth, + redstoneRoot); + marimorphosisRecipe = BotaniaAPI.registerPetalRecipe( + ItemBlockSpecialFlower.ofType(LibBlockNames.SUBTILE_MARIMORPHOSIS), + gray, + yellow, + green, + red, + runeEarth, + runeFire, + redstoneRoot); + bubbellRecipe = BotaniaAPI.registerPetalRecipe( + ItemBlockSpecialFlower.ofType(LibBlockNames.SUBTILE_BUBBELL), + cyan, + cyan, + lightBlue, + lightBlue, + blue, + blue, + runeWater, + runeSummer, + pixieDust); + solegnoliaRecipe = BotaniaAPI.registerPetalRecipe( + ItemBlockSpecialFlower.ofType(LibBlockNames.SUBTILE_SOLEGNOLIA), brown, brown, red, blue, redstoneRoot); - ItemStack stack = new ItemStack(Items.skull, 1, 3); - ItemNBTHelper.setString(stack, "SkullOwner", "Vazkii"); - Object[] inputs = new Object[16]; - Arrays.fill(inputs, pink); - BotaniaAPI.registerPetalRecipe(stack, inputs); - } + ItemStack stack = new ItemStack(Items.skull, 1, 3); + ItemNBTHelper.setString(stack, "SkullOwner", "Vazkii"); + Object[] inputs = new Object[16]; + Arrays.fill(inputs, pink); + BotaniaAPI.registerPetalRecipe(stack, inputs); + } } diff --git a/src/main/java/vazkii/botania/common/crafting/ModPureDaisyRecipes.java b/src/main/java/vazkii/botania/common/crafting/ModPureDaisyRecipes.java index 3c39ed963e..4d21bb61da 100644 --- a/src/main/java/vazkii/botania/common/crafting/ModPureDaisyRecipes.java +++ b/src/main/java/vazkii/botania/common/crafting/ModPureDaisyRecipes.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Apr 17, 2015, 5:18:06 PM (GMT)] */ package vazkii.botania.common.crafting; @@ -18,17 +18,16 @@ public final class ModPureDaisyRecipes { - public static void init() { - if (!ConfigHandler.enableDefaultRecipes) return; + public static void init() { + if (!ConfigHandler.enableDefaultRecipes) return; - BotaniaAPI.registerPureDaisyRecipe("stone", ModBlocks.livingrock, 0); - BotaniaAPI.registerPureDaisyRecipe("logWood", ModBlocks.livingwood, 0); - - BotaniaAPI.registerPureDaisyRecipe("netherrack", Blocks.cobblestone, 0); - BotaniaAPI.registerPureDaisyRecipe("soulSand", Blocks.sand, 0); - BotaniaAPI.registerPureDaisyRecipe("ice", Blocks.packed_ice, 0); - BotaniaAPI.registerPureDaisyRecipe(LibOreDict.BLAZE_BLOCK, Blocks.obsidian, 0); - BotaniaAPI.registerPureDaisyRecipe(Blocks.water, Blocks.snow, 0); - } + BotaniaAPI.registerPureDaisyRecipe("stone", ModBlocks.livingrock, 0); + BotaniaAPI.registerPureDaisyRecipe("logWood", ModBlocks.livingwood, 0); + BotaniaAPI.registerPureDaisyRecipe("netherrack", Blocks.cobblestone, 0); + BotaniaAPI.registerPureDaisyRecipe("soulSand", Blocks.sand, 0); + BotaniaAPI.registerPureDaisyRecipe("ice", Blocks.packed_ice, 0); + BotaniaAPI.registerPureDaisyRecipe(LibOreDict.BLAZE_BLOCK, Blocks.obsidian, 0); + BotaniaAPI.registerPureDaisyRecipe(Blocks.water, Blocks.snow, 0); + } } diff --git a/src/main/java/vazkii/botania/common/crafting/ModRuneRecipes.java b/src/main/java/vazkii/botania/common/crafting/ModRuneRecipes.java index 11510020e5..15c60e23d3 100644 --- a/src/main/java/vazkii/botania/common/crafting/ModRuneRecipes.java +++ b/src/main/java/vazkii/botania/common/crafting/ModRuneRecipes.java @@ -2,17 +2,16 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Feb 6, 2014, 5:59:28 PM (GMT)] */ package vazkii.botania.common.crafting; import java.util.ArrayList; import java.util.List; - import net.minecraft.block.Block; import net.minecraft.init.Blocks; import net.minecraft.init.Items; @@ -26,62 +25,186 @@ public final class ModRuneRecipes { - public static RecipeRuneAltar recipeWaterRune; - public static RecipeRuneAltar recipeFireRune; - public static List recipesEarthRune; - public static List recipesAirRune; - public static RecipeRuneAltar recipeSpringRune; - public static RecipeRuneAltar recipeSummerRune; - public static RecipeRuneAltar recipeAutumnRune; - public static List recipesWinterRune; - public static RecipeRuneAltar recipeManaRune; - public static RecipeRuneAltar recipeLustRune; - public static RecipeRuneAltar recipeGluttonyRune; - public static RecipeRuneAltar recipeGreedRune; - public static RecipeRuneAltar recipeSlothRune; - public static RecipeRuneAltar recipeWrathRune; - public static RecipeRuneAltar recipeEnvyRune; - public static RecipeRuneAltar recipePrideRune; + public static RecipeRuneAltar recipeWaterRune; + public static RecipeRuneAltar recipeFireRune; + public static List recipesEarthRune; + public static List recipesAirRune; + public static RecipeRuneAltar recipeSpringRune; + public static RecipeRuneAltar recipeSummerRune; + public static RecipeRuneAltar recipeAutumnRune; + public static List recipesWinterRune; + public static RecipeRuneAltar recipeManaRune; + public static RecipeRuneAltar recipeLustRune; + public static RecipeRuneAltar recipeGluttonyRune; + public static RecipeRuneAltar recipeGreedRune; + public static RecipeRuneAltar recipeSlothRune; + public static RecipeRuneAltar recipeWrathRune; + public static RecipeRuneAltar recipeEnvyRune; + public static RecipeRuneAltar recipePrideRune; - public static RecipeRuneAltar recipeHead; + public static RecipeRuneAltar recipeHead; - public static void init() { - if (!ConfigHandler.enableDefaultRecipes) return; + public static void init() { + if (!ConfigHandler.enableDefaultRecipes) return; - final int costTier1 = 5200; - final int costTier2 = 8000; - final int costTier3 = 12000; + final int costTier1 = 5200; + final int costTier2 = 8000; + final int costTier3 = 12000; - recipeWaterRune = BotaniaAPI.registerRuneAltarRecipe(new ItemStack(ModItems.rune, 2, 0), costTier1, LibOreDict.MANA_POWDER, LibOreDict.MANA_STEEL, new ItemStack(Items.dye, 1, 15), new ItemStack(Items.reeds), new ItemStack(Items.fishing_rod)); - recipeFireRune = BotaniaAPI.registerRuneAltarRecipe(new ItemStack(ModItems.rune, 2, 1), costTier1, LibOreDict.MANA_POWDER, LibOreDict.MANA_STEEL, new ItemStack(Items.netherbrick), new ItemStack(Items.gunpowder), new ItemStack(Items.nether_wart)); + recipeWaterRune = BotaniaAPI.registerRuneAltarRecipe( + new ItemStack(ModItems.rune, 2, 0), + costTier1, + LibOreDict.MANA_POWDER, + LibOreDict.MANA_STEEL, + new ItemStack(Items.dye, 1, 15), + new ItemStack(Items.reeds), + new ItemStack(Items.fishing_rod)); + recipeFireRune = BotaniaAPI.registerRuneAltarRecipe( + new ItemStack(ModItems.rune, 2, 1), + costTier1, + LibOreDict.MANA_POWDER, + LibOreDict.MANA_STEEL, + new ItemStack(Items.netherbrick), + new ItemStack(Items.gunpowder), + new ItemStack(Items.nether_wart)); - recipesEarthRune = new ArrayList(); - recipesEarthRune.add(BotaniaAPI.registerRuneAltarRecipe(new ItemStack(ModItems.rune, 2, 2), costTier1, LibOreDict.MANA_POWDER, LibOreDict.MANA_STEEL, "stone", new ItemStack(Blocks.coal_block), new ItemStack(Blocks.brown_mushroom))); - recipesEarthRune.add(BotaniaAPI.registerRuneAltarRecipe(new ItemStack(ModItems.rune, 2, 2), costTier1, LibOreDict.MANA_POWDER, LibOreDict.MANA_STEEL, "stone", new ItemStack(Blocks.coal_block), new ItemStack(Blocks.red_mushroom))); + recipesEarthRune = new ArrayList(); + recipesEarthRune.add(BotaniaAPI.registerRuneAltarRecipe( + new ItemStack(ModItems.rune, 2, 2), + costTier1, + LibOreDict.MANA_POWDER, + LibOreDict.MANA_STEEL, + "stone", + new ItemStack(Blocks.coal_block), + new ItemStack(Blocks.brown_mushroom))); + recipesEarthRune.add(BotaniaAPI.registerRuneAltarRecipe( + new ItemStack(ModItems.rune, 2, 2), + costTier1, + LibOreDict.MANA_POWDER, + LibOreDict.MANA_STEEL, + "stone", + new ItemStack(Blocks.coal_block), + new ItemStack(Blocks.red_mushroom))); - recipesAirRune = new ArrayList(); - for(int i = 0; i < 16; i++) - recipesAirRune.add(BotaniaAPI.registerRuneAltarRecipe(new ItemStack(ModItems.rune, 2, 3), costTier1, LibOreDict.MANA_POWDER, LibOreDict.MANA_STEEL, new ItemStack(Blocks.carpet, 1, i), new ItemStack(Items.feather), new ItemStack(Items.string))); + recipesAirRune = new ArrayList(); + for (int i = 0; i < 16; i++) + recipesAirRune.add(BotaniaAPI.registerRuneAltarRecipe( + new ItemStack(ModItems.rune, 2, 3), + costTier1, + LibOreDict.MANA_POWDER, + LibOreDict.MANA_STEEL, + new ItemStack(Blocks.carpet, 1, i), + new ItemStack(Items.feather), + new ItemStack(Items.string))); - recipeSpringRune = BotaniaAPI.registerRuneAltarRecipe(new ItemStack(ModItems.rune, 1, 4), costTier2, LibOreDict.RUNE[0], LibOreDict.RUNE[1], "treeSapling", "treeSapling", "treeSapling", new ItemStack(Items.wheat)); - recipeSummerRune = BotaniaAPI.registerRuneAltarRecipe(new ItemStack(ModItems.rune, 1, 5), costTier2, LibOreDict.RUNE[2], LibOreDict.RUNE[3], new ItemStack(Block.getBlockFromName("sand")), new ItemStack(Block.getBlockFromName("sand")), new ItemStack(Items.slime_ball), new ItemStack(Items.melon)); - recipeAutumnRune = BotaniaAPI.registerRuneAltarRecipe(new ItemStack(ModItems.rune, 1, 6), costTier2, LibOreDict.RUNE[1], LibOreDict.RUNE[3], "treeLeaves", "treeLeaves", "treeLeaves", new ItemStack(Items.spider_eye)); + recipeSpringRune = BotaniaAPI.registerRuneAltarRecipe( + new ItemStack(ModItems.rune, 1, 4), + costTier2, + LibOreDict.RUNE[0], + LibOreDict.RUNE[1], + "treeSapling", + "treeSapling", + "treeSapling", + new ItemStack(Items.wheat)); + recipeSummerRune = BotaniaAPI.registerRuneAltarRecipe( + new ItemStack(ModItems.rune, 1, 5), + costTier2, + LibOreDict.RUNE[2], + LibOreDict.RUNE[3], + new ItemStack(Block.getBlockFromName("sand")), + new ItemStack(Block.getBlockFromName("sand")), + new ItemStack(Items.slime_ball), + new ItemStack(Items.melon)); + recipeAutumnRune = BotaniaAPI.registerRuneAltarRecipe( + new ItemStack(ModItems.rune, 1, 6), + costTier2, + LibOreDict.RUNE[1], + LibOreDict.RUNE[3], + "treeLeaves", + "treeLeaves", + "treeLeaves", + new ItemStack(Items.spider_eye)); - recipesWinterRune = new ArrayList(); - for(int i = 0; i < 16; i++) - recipesWinterRune.add(BotaniaAPI.registerRuneAltarRecipe(new ItemStack(ModItems.rune, 1, 7), costTier2, LibOreDict.RUNE[0], LibOreDict.RUNE[2], new ItemStack(Blocks.snow), new ItemStack(Blocks.snow), new ItemStack(Blocks.wool, 1, i), new ItemStack(Items.cake))); + recipesWinterRune = new ArrayList(); + for (int i = 0; i < 16; i++) + recipesWinterRune.add(BotaniaAPI.registerRuneAltarRecipe( + new ItemStack(ModItems.rune, 1, 7), + costTier2, + LibOreDict.RUNE[0], + LibOreDict.RUNE[2], + new ItemStack(Blocks.snow), + new ItemStack(Blocks.snow), + new ItemStack(Blocks.wool, 1, i), + new ItemStack(Items.cake))); - recipeManaRune = BotaniaAPI.registerRuneAltarRecipe(new ItemStack(ModItems.rune, 1, 8), costTier2, LibOreDict.MANA_STEEL, LibOreDict.MANA_STEEL, LibOreDict.MANA_STEEL, LibOreDict.MANA_STEEL, LibOreDict.MANA_STEEL, LibOreDict.MANA_PEARL); + recipeManaRune = BotaniaAPI.registerRuneAltarRecipe( + new ItemStack(ModItems.rune, 1, 8), + costTier2, + LibOreDict.MANA_STEEL, + LibOreDict.MANA_STEEL, + LibOreDict.MANA_STEEL, + LibOreDict.MANA_STEEL, + LibOreDict.MANA_STEEL, + LibOreDict.MANA_PEARL); - recipeLustRune = BotaniaAPI.registerRuneAltarRecipe(new ItemStack(ModItems.rune, 1, 9), costTier3, LibOreDict.MANA_DIAMOND, LibOreDict.MANA_DIAMOND, LibOreDict.RUNE[5], LibOreDict.RUNE[3]); - recipeGluttonyRune = BotaniaAPI.registerRuneAltarRecipe(new ItemStack(ModItems.rune, 1, 10), costTier3, LibOreDict.MANA_DIAMOND, LibOreDict.MANA_DIAMOND, LibOreDict.RUNE[7], LibOreDict.RUNE[1]); - recipeGreedRune = BotaniaAPI.registerRuneAltarRecipe(new ItemStack(ModItems.rune, 1, 11), costTier3, LibOreDict.MANA_DIAMOND, LibOreDict.MANA_DIAMOND, LibOreDict.RUNE[4], LibOreDict.RUNE[0]); - recipeSlothRune = BotaniaAPI.registerRuneAltarRecipe(new ItemStack(ModItems.rune, 1, 12), costTier3, LibOreDict.MANA_DIAMOND, LibOreDict.MANA_DIAMOND, LibOreDict.RUNE[6], LibOreDict.RUNE[3]); - recipeWrathRune = BotaniaAPI.registerRuneAltarRecipe(new ItemStack(ModItems.rune, 1, 13), costTier3, LibOreDict.MANA_DIAMOND, LibOreDict.MANA_DIAMOND, LibOreDict.RUNE[7], LibOreDict.RUNE[2]); - recipeEnvyRune = BotaniaAPI.registerRuneAltarRecipe(new ItemStack(ModItems.rune, 1, 14), costTier3, LibOreDict.MANA_DIAMOND, LibOreDict.MANA_DIAMOND, LibOreDict.RUNE[7], LibOreDict.RUNE[0]); - recipePrideRune = BotaniaAPI.registerRuneAltarRecipe(new ItemStack(ModItems.rune, 1, 15), costTier3, LibOreDict.MANA_DIAMOND, LibOreDict.MANA_DIAMOND, LibOreDict.RUNE[5], LibOreDict.RUNE[1]); + recipeLustRune = BotaniaAPI.registerRuneAltarRecipe( + new ItemStack(ModItems.rune, 1, 9), + costTier3, + LibOreDict.MANA_DIAMOND, + LibOreDict.MANA_DIAMOND, + LibOreDict.RUNE[5], + LibOreDict.RUNE[3]); + recipeGluttonyRune = BotaniaAPI.registerRuneAltarRecipe( + new ItemStack(ModItems.rune, 1, 10), + costTier3, + LibOreDict.MANA_DIAMOND, + LibOreDict.MANA_DIAMOND, + LibOreDict.RUNE[7], + LibOreDict.RUNE[1]); + recipeGreedRune = BotaniaAPI.registerRuneAltarRecipe( + new ItemStack(ModItems.rune, 1, 11), + costTier3, + LibOreDict.MANA_DIAMOND, + LibOreDict.MANA_DIAMOND, + LibOreDict.RUNE[4], + LibOreDict.RUNE[0]); + recipeSlothRune = BotaniaAPI.registerRuneAltarRecipe( + new ItemStack(ModItems.rune, 1, 12), + costTier3, + LibOreDict.MANA_DIAMOND, + LibOreDict.MANA_DIAMOND, + LibOreDict.RUNE[6], + LibOreDict.RUNE[3]); + recipeWrathRune = BotaniaAPI.registerRuneAltarRecipe( + new ItemStack(ModItems.rune, 1, 13), + costTier3, + LibOreDict.MANA_DIAMOND, + LibOreDict.MANA_DIAMOND, + LibOreDict.RUNE[7], + LibOreDict.RUNE[2]); + recipeEnvyRune = BotaniaAPI.registerRuneAltarRecipe( + new ItemStack(ModItems.rune, 1, 14), + costTier3, + LibOreDict.MANA_DIAMOND, + LibOreDict.MANA_DIAMOND, + LibOreDict.RUNE[7], + LibOreDict.RUNE[0]); + recipePrideRune = BotaniaAPI.registerRuneAltarRecipe( + new ItemStack(ModItems.rune, 1, 15), + costTier3, + LibOreDict.MANA_DIAMOND, + LibOreDict.MANA_DIAMOND, + LibOreDict.RUNE[5], + LibOreDict.RUNE[1]); - recipeHead = new HeadRecipe(new ItemStack(Items.skull, 1, 3), 22500, new ItemStack(Items.skull), LibOreDict.PIXIE_DUST, LibOreDict.PRISMARINE_SHARD, new ItemStack(Items.name_tag), new ItemStack(Items.golden_apple)); - BotaniaAPI.runeAltarRecipes.add(recipeHead); - } + recipeHead = new HeadRecipe( + new ItemStack(Items.skull, 1, 3), + 22500, + new ItemStack(Items.skull), + LibOreDict.PIXIE_DUST, + LibOreDict.PRISMARINE_SHARD, + new ItemStack(Items.name_tag), + new ItemStack(Items.golden_apple)); + BotaniaAPI.runeAltarRecipes.add(recipeHead); + } } diff --git a/src/main/java/vazkii/botania/common/crafting/recipe/AesirRingRecipe.java b/src/main/java/vazkii/botania/common/crafting/recipe/AesirRingRecipe.java index 5f784a6856..9013451375 100644 --- a/src/main/java/vazkii/botania/common/crafting/recipe/AesirRingRecipe.java +++ b/src/main/java/vazkii/botania/common/crafting/recipe/AesirRingRecipe.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Mar 31, 2015, 10:39:58 PM (GMT)] */ package vazkii.botania.common.crafting.recipe; @@ -19,58 +19,52 @@ public class AesirRingRecipe implements IRecipe { - @Override - public boolean matches(InventoryCrafting var1, World var2) { - boolean foundThorRing = false; - boolean foundOdinRing = false; - boolean foundLokiRing = false; + @Override + public boolean matches(InventoryCrafting var1, World var2) { + boolean foundThorRing = false; + boolean foundOdinRing = false; + boolean foundLokiRing = false; - for(int i = 0; i < var1.getSizeInventory(); i++) { - ItemStack stack = var1.getStackInSlot(i); - if(stack != null) { - if(stack.getItem() == ModItems.thorRing && !foundThorRing) - foundThorRing = true; - else if(stack.getItem() == ModItems.odinRing && !foundOdinRing) - foundOdinRing = true; - else if(stack.getItem() == ModItems.lokiRing && !foundLokiRing) - foundLokiRing = true; - else return false; // Found an invalid item, breaking the recipe - } - } + for (int i = 0; i < var1.getSizeInventory(); i++) { + ItemStack stack = var1.getStackInSlot(i); + if (stack != null) { + if (stack.getItem() == ModItems.thorRing && !foundThorRing) foundThorRing = true; + else if (stack.getItem() == ModItems.odinRing && !foundOdinRing) foundOdinRing = true; + else if (stack.getItem() == ModItems.lokiRing && !foundLokiRing) foundLokiRing = true; + else return false; // Found an invalid item, breaking the recipe + } + } - return foundThorRing && foundOdinRing && foundLokiRing; - } + return foundThorRing && foundOdinRing && foundLokiRing; + } - @Override - public ItemStack getCraftingResult(InventoryCrafting var1) { - String soulbind = null; + @Override + public ItemStack getCraftingResult(InventoryCrafting var1) { + String soulbind = null; - for(int i = 0; i < var1.getSizeInventory(); i++) { - ItemStack stack = var1.getStackInSlot(i); - if(stack != null) { - if(stack.getItem() instanceof IRelic) { - String bind = ((IRelic) stack.getItem()).getSoulbindUsername(stack); - if(soulbind == null) - soulbind = bind; - else if(!soulbind.equals(bind)) - return null; - } else return null; - } - } + for (int i = 0; i < var1.getSizeInventory(); i++) { + ItemStack stack = var1.getStackInSlot(i); + if (stack != null) { + if (stack.getItem() instanceof IRelic) { + String bind = ((IRelic) stack.getItem()).getSoulbindUsername(stack); + if (soulbind == null) soulbind = bind; + else if (!soulbind.equals(bind)) return null; + } else return null; + } + } - ItemStack stack = new ItemStack(ModItems.aesirRing); - ((IRelic) ModItems.aesirRing).bindToUsername(soulbind, stack); - return stack; - } + ItemStack stack = new ItemStack(ModItems.aesirRing); + ((IRelic) ModItems.aesirRing).bindToUsername(soulbind, stack); + return stack; + } - @Override - public int getRecipeSize() { - return 10; - } - - @Override - public ItemStack getRecipeOutput() { - return null; - } + @Override + public int getRecipeSize() { + return 10; + } + @Override + public ItemStack getRecipeOutput() { + return null; + } } diff --git a/src/main/java/vazkii/botania/common/crafting/recipe/AncientWillRecipe.java b/src/main/java/vazkii/botania/common/crafting/recipe/AncientWillRecipe.java index 15a972168e..017cdaa40f 100644 --- a/src/main/java/vazkii/botania/common/crafting/recipe/AncientWillRecipe.java +++ b/src/main/java/vazkii/botania/common/crafting/recipe/AncientWillRecipe.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jan 30, 2015, 11:24:08 PM (GMT)] */ package vazkii.botania.common.crafting.recipe; @@ -19,58 +19,53 @@ public class AncientWillRecipe implements IRecipe { - @Override - public boolean matches(InventoryCrafting var1, World var2) { - boolean foundWill = false; - boolean foundItem = false; + @Override + public boolean matches(InventoryCrafting var1, World var2) { + boolean foundWill = false; + boolean foundItem = false; - for(int i = 0; i < var1.getSizeInventory(); i++) { - ItemStack stack = var1.getStackInSlot(i); - if(stack != null) { - if(stack.getItem() == ModItems.ancientWill && !foundWill) - foundWill = true; - else if(!foundItem) { - if(stack.getItem() instanceof IAncientWillContainer) - foundItem = true; - else return false; - } - } - } + for (int i = 0; i < var1.getSizeInventory(); i++) { + ItemStack stack = var1.getStackInSlot(i); + if (stack != null) { + if (stack.getItem() == ModItems.ancientWill && !foundWill) foundWill = true; + else if (!foundItem) { + if (stack.getItem() instanceof IAncientWillContainer) foundItem = true; + else return false; + } + } + } - return foundWill && foundItem; - } + return foundWill && foundItem; + } - @Override - public ItemStack getCraftingResult(InventoryCrafting var1) { - ItemStack item = null; - int will = -1; + @Override + public ItemStack getCraftingResult(InventoryCrafting var1) { + ItemStack item = null; + int will = -1; - for(int i = 0; i < var1.getSizeInventory(); i++) { - ItemStack stack = var1.getStackInSlot(i); - if(stack != null) { - if(stack.getItem() instanceof IAncientWillContainer && item == null) - item = stack; - else will = stack.getItemDamage(); - } - } + for (int i = 0; i < var1.getSizeInventory(); i++) { + ItemStack stack = var1.getStackInSlot(i); + if (stack != null) { + if (stack.getItem() instanceof IAncientWillContainer && item == null) item = stack; + else will = stack.getItemDamage(); + } + } - IAncientWillContainer container = (IAncientWillContainer) item.getItem(); - if(container.hasAncientWill(item, will)) - return null; + IAncientWillContainer container = (IAncientWillContainer) item.getItem(); + if (container.hasAncientWill(item, will)) return null; - ItemStack copy = item.copy(); - container.addAncientWill(copy, will); - return copy; - } + ItemStack copy = item.copy(); + container.addAncientWill(copy, will); + return copy; + } - @Override - public int getRecipeSize() { - return 10; - } - - @Override - public ItemStack getRecipeOutput() { - return null; - } + @Override + public int getRecipeSize() { + return 10; + } + @Override + public ItemStack getRecipeOutput() { + return null; + } } diff --git a/src/main/java/vazkii/botania/common/crafting/recipe/BlackHoleTalismanExtractRecipe.java b/src/main/java/vazkii/botania/common/crafting/recipe/BlackHoleTalismanExtractRecipe.java index 294001effd..6510aaa0ee 100644 --- a/src/main/java/vazkii/botania/common/crafting/recipe/BlackHoleTalismanExtractRecipe.java +++ b/src/main/java/vazkii/botania/common/crafting/recipe/BlackHoleTalismanExtractRecipe.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Apr 9, 2015, 7:48:00 PM (GMT)] */ package vazkii.botania.common.crafting.recipe; @@ -20,50 +20,47 @@ public class BlackHoleTalismanExtractRecipe implements IRecipe { - @Override - public boolean matches(InventoryCrafting var1, World var2) { - boolean foundTalisman = false; + @Override + public boolean matches(InventoryCrafting var1, World var2) { + boolean foundTalisman = false; - for(int i = 0; i < var1.getSizeInventory(); i++) { - ItemStack stack = var1.getStackInSlot(i); - if(stack != null) { - if(stack.getItem() == ModItems.blackHoleTalisman && !foundTalisman) - foundTalisman = true; - else return false; - } - } + for (int i = 0; i < var1.getSizeInventory(); i++) { + ItemStack stack = var1.getStackInSlot(i); + if (stack != null) { + if (stack.getItem() == ModItems.blackHoleTalisman && !foundTalisman) foundTalisman = true; + else return false; + } + } - return foundTalisman; - } + return foundTalisman; + } - @Override - public ItemStack getCraftingResult(InventoryCrafting var1) { - ItemStack talisman = null; + @Override + public ItemStack getCraftingResult(InventoryCrafting var1) { + ItemStack talisman = null; - for(int i = 0; i < var1.getSizeInventory(); i++) { - ItemStack stack = var1.getStackInSlot(i); - if(stack != null) - talisman = stack; - } + for (int i = 0; i < var1.getSizeInventory(); i++) { + ItemStack stack = var1.getStackInSlot(i); + if (stack != null) talisman = stack; + } - int count = ItemBlackHoleTalisman.getBlockCount(talisman); - if(count > 0) { - Block block = ItemBlackHoleTalisman.getBlock(talisman); - int meta = ItemBlackHoleTalisman.getBlockMeta(talisman); - return new ItemStack(block, Math.min(64, count), meta); - } + int count = ItemBlackHoleTalisman.getBlockCount(talisman); + if (count > 0) { + Block block = ItemBlackHoleTalisman.getBlock(talisman); + int meta = ItemBlackHoleTalisman.getBlockMeta(talisman); + return new ItemStack(block, Math.min(64, count), meta); + } - return null; - } + return null; + } - @Override - public int getRecipeSize() { - return 10; - } - - @Override - public ItemStack getRecipeOutput() { - return null; - } + @Override + public int getRecipeSize() { + return 10; + } + @Override + public ItemStack getRecipeOutput() { + return null; + } } diff --git a/src/main/java/vazkii/botania/common/crafting/recipe/CompositeLensRecipe.java b/src/main/java/vazkii/botania/common/crafting/recipe/CompositeLensRecipe.java index 7fc42916bd..a223846a5e 100644 --- a/src/main/java/vazkii/botania/common/crafting/recipe/CompositeLensRecipe.java +++ b/src/main/java/vazkii/botania/common/crafting/recipe/CompositeLensRecipe.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Mar 17, 2014, 8:30:41 PM (GMT)] */ package vazkii.botania.common.crafting.recipe; @@ -21,64 +21,63 @@ public class CompositeLensRecipe implements IRecipe { - @Override - public boolean matches(InventoryCrafting var1, World var2) { - boolean foundLens = false; - boolean foundSecondLens = false; - boolean foundSlimeball = false; + @Override + public boolean matches(InventoryCrafting var1, World var2) { + boolean foundLens = false; + boolean foundSecondLens = false; + boolean foundSlimeball = false; - for(int i = 0; i < var1.getSizeInventory(); i++) { - ItemStack stack = var1.getStackInSlot(i); - if(stack != null) { - if(stack.getItem() instanceof ICompositableLens && !foundSecondLens) { - if(foundLens) - foundSecondLens = true; - else foundLens = true; - } else if(stack.getItem() == Items.slime_ball) - foundSlimeball = true; - else return false; // Found an invalid item, breaking the recipe - } - } + for (int i = 0; i < var1.getSizeInventory(); i++) { + ItemStack stack = var1.getStackInSlot(i); + if (stack != null) { + if (stack.getItem() instanceof ICompositableLens && !foundSecondLens) { + if (foundLens) foundSecondLens = true; + else foundLens = true; + } else if (stack.getItem() == Items.slime_ball) foundSlimeball = true; + else return false; // Found an invalid item, breaking the recipe + } + } - return foundSecondLens && foundSlimeball; - } + return foundSecondLens && foundSlimeball; + } - @Override - public ItemStack getCraftingResult(InventoryCrafting var1) { - ItemStack lens = null; - ItemStack secondLens = null; + @Override + public ItemStack getCraftingResult(InventoryCrafting var1) { + ItemStack lens = null; + ItemStack secondLens = null; - for(int i = 0; i < var1.getSizeInventory(); i++) { - ItemStack stack = var1.getStackInSlot(i); - if(stack != null) { - if(stack.getItem() instanceof ICompositableLens) - if(lens == null) - lens = stack; - else secondLens = stack; - } - } + for (int i = 0; i < var1.getSizeInventory(); i++) { + ItemStack stack = var1.getStackInSlot(i); + if (stack != null) { + if (stack.getItem() instanceof ICompositableLens) + if (lens == null) lens = stack; + else secondLens = stack; + } + } - if(lens.getItem() instanceof ICompositableLens) { - ICompositableLens lensItem = (ICompositableLens) lens.getItem(); - if(secondLens == null || !lensItem.canCombineLenses(lens, secondLens) || lensItem.getCompositeLens(lens) != null || lensItem.getCompositeLens(secondLens) != null) - return null; + if (lens.getItem() instanceof ICompositableLens) { + ICompositableLens lensItem = (ICompositableLens) lens.getItem(); + if (secondLens == null + || !lensItem.canCombineLenses(lens, secondLens) + || lensItem.getCompositeLens(lens) != null + || lensItem.getCompositeLens(secondLens) != null) return null; - ItemStack lensCopy = lens.copy(); - ((ItemLens) ModItems.lens).setCompositeLens(lensCopy, secondLens); + ItemStack lensCopy = lens.copy(); + ((ItemLens) ModItems.lens).setCompositeLens(lensCopy, secondLens); - return lensCopy; - } + return lensCopy; + } - return null; - } + return null; + } - @Override - public int getRecipeSize() { - return 10; - } + @Override + public int getRecipeSize() { + return 10; + } - @Override - public ItemStack getRecipeOutput() { - return null; - } -} \ No newline at end of file + @Override + public ItemStack getRecipeOutput() { + return null; + } +} diff --git a/src/main/java/vazkii/botania/common/crafting/recipe/CosmeticAttachRecipe.java b/src/main/java/vazkii/botania/common/crafting/recipe/CosmeticAttachRecipe.java index 3803e08b12..e02c2a7e64 100644 --- a/src/main/java/vazkii/botania/common/crafting/recipe/CosmeticAttachRecipe.java +++ b/src/main/java/vazkii/botania/common/crafting/recipe/CosmeticAttachRecipe.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Feb 22, 2015, 8:49:53 PM (GMT)] */ package vazkii.botania.common.crafting.recipe; @@ -19,57 +19,56 @@ public class CosmeticAttachRecipe implements IRecipe { - @Override - public boolean matches(InventoryCrafting var1, World var2) { - boolean foundCosmetic = false; - boolean foundAttachable = false; + @Override + public boolean matches(InventoryCrafting var1, World var2) { + boolean foundCosmetic = false; + boolean foundAttachable = false; - for(int i = 0; i < var1.getSizeInventory(); i++) { - ItemStack stack = var1.getStackInSlot(i); - if(stack != null) { - if(stack.getItem() instanceof ICosmeticBauble && !foundCosmetic) - foundCosmetic = true; - else if(!foundAttachable) { - if(stack.getItem() instanceof ICosmeticAttachable && !(stack.getItem() instanceof ICosmeticBauble) && ((ICosmeticAttachable) stack.getItem()).getCosmeticItem(stack) == null) - foundAttachable = true; - else return false; - } - } - } + for (int i = 0; i < var1.getSizeInventory(); i++) { + ItemStack stack = var1.getStackInSlot(i); + if (stack != null) { + if (stack.getItem() instanceof ICosmeticBauble && !foundCosmetic) foundCosmetic = true; + else if (!foundAttachable) { + if (stack.getItem() instanceof ICosmeticAttachable + && !(stack.getItem() instanceof ICosmeticBauble) + && ((ICosmeticAttachable) stack.getItem()).getCosmeticItem(stack) == null) + foundAttachable = true; + else return false; + } + } + } - return foundCosmetic && foundAttachable; - } + return foundCosmetic && foundAttachable; + } - @Override - public ItemStack getCraftingResult(InventoryCrafting var1) { - ItemStack cosmeticItem = null; - ItemStack attachableItem = null; + @Override + public ItemStack getCraftingResult(InventoryCrafting var1) { + ItemStack cosmeticItem = null; + ItemStack attachableItem = null; - for(int i = 0; i < var1.getSizeInventory(); i++) { - ItemStack stack = var1.getStackInSlot(i); - if(stack != null) { - if(stack.getItem() instanceof ICosmeticBauble && cosmeticItem == null) - cosmeticItem = stack; - else attachableItem = stack; - } - } + for (int i = 0; i < var1.getSizeInventory(); i++) { + ItemStack stack = var1.getStackInSlot(i); + if (stack != null) { + if (stack.getItem() instanceof ICosmeticBauble && cosmeticItem == null) cosmeticItem = stack; + else attachableItem = stack; + } + } - ICosmeticAttachable attachable = (ICosmeticAttachable) attachableItem.getItem(); - if(attachable.getCosmeticItem(attachableItem) != null) - return null; + ICosmeticAttachable attachable = (ICosmeticAttachable) attachableItem.getItem(); + if (attachable.getCosmeticItem(attachableItem) != null) return null; - ItemStack copy = attachableItem.copy(); - attachable.setCosmeticItem(copy, cosmeticItem); - return copy; - } + ItemStack copy = attachableItem.copy(); + attachable.setCosmeticItem(copy, cosmeticItem); + return copy; + } - @Override - public int getRecipeSize() { - return 10; - } + @Override + public int getRecipeSize() { + return 10; + } - @Override - public ItemStack getRecipeOutput() { - return null; - } + @Override + public ItemStack getRecipeOutput() { + return null; + } } diff --git a/src/main/java/vazkii/botania/common/crafting/recipe/CosmeticRemoveRecipe.java b/src/main/java/vazkii/botania/common/crafting/recipe/CosmeticRemoveRecipe.java index af26d305f8..8b0cc9c2eb 100644 --- a/src/main/java/vazkii/botania/common/crafting/recipe/CosmeticRemoveRecipe.java +++ b/src/main/java/vazkii/botania/common/crafting/recipe/CosmeticRemoveRecipe.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Feb 22, 2015, 8:55:03 PM (GMT)] */ package vazkii.botania.common.crafting.recipe; @@ -19,49 +19,48 @@ public class CosmeticRemoveRecipe implements IRecipe { - @Override - public boolean matches(InventoryCrafting var1, World var2) { - boolean foundAttachable = false; + @Override + public boolean matches(InventoryCrafting var1, World var2) { + boolean foundAttachable = false; - for(int i = 0; i < var1.getSizeInventory(); i++) { - ItemStack stack = var1.getStackInSlot(i); - if(stack != null) { - if(stack.getItem() instanceof ICosmeticAttachable && !(stack.getItem() instanceof ICosmeticBauble) && ((ICosmeticAttachable) stack.getItem()).getCosmeticItem(stack) != null) - foundAttachable = true; - else return false; - } - } + for (int i = 0; i < var1.getSizeInventory(); i++) { + ItemStack stack = var1.getStackInSlot(i); + if (stack != null) { + if (stack.getItem() instanceof ICosmeticAttachable + && !(stack.getItem() instanceof ICosmeticBauble) + && ((ICosmeticAttachable) stack.getItem()).getCosmeticItem(stack) != null) + foundAttachable = true; + else return false; + } + } - return foundAttachable; - } + return foundAttachable; + } - @Override - public ItemStack getCraftingResult(InventoryCrafting var1) { - ItemStack attachableItem = null; + @Override + public ItemStack getCraftingResult(InventoryCrafting var1) { + ItemStack attachableItem = null; - for(int i = 0; i < var1.getSizeInventory(); i++) { - ItemStack stack = var1.getStackInSlot(i); - if(stack != null) - attachableItem = stack; - } + for (int i = 0; i < var1.getSizeInventory(); i++) { + ItemStack stack = var1.getStackInSlot(i); + if (stack != null) attachableItem = stack; + } - ICosmeticAttachable attachable = (ICosmeticAttachable) attachableItem.getItem(); - if(attachable.getCosmeticItem(attachableItem) == null) - return null; + ICosmeticAttachable attachable = (ICosmeticAttachable) attachableItem.getItem(); + if (attachable.getCosmeticItem(attachableItem) == null) return null; - ItemStack copy = attachableItem.copy(); - attachable.setCosmeticItem(copy, null); - return copy; - } + ItemStack copy = attachableItem.copy(); + attachable.setCosmeticItem(copy, null); + return copy; + } - @Override - public int getRecipeSize() { - return 10; - } - - @Override - public ItemStack getRecipeOutput() { - return null; - } + @Override + public int getRecipeSize() { + return 10; + } + @Override + public ItemStack getRecipeOutput() { + return null; + } } diff --git a/src/main/java/vazkii/botania/common/crafting/recipe/HeadRecipe.java b/src/main/java/vazkii/botania/common/crafting/recipe/HeadRecipe.java index 5472e75ad9..09bf1eca0b 100644 --- a/src/main/java/vazkii/botania/common/crafting/recipe/HeadRecipe.java +++ b/src/main/java/vazkii/botania/common/crafting/recipe/HeadRecipe.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jul 23, 2014, 3:02:17 PM (GMT)] */ package vazkii.botania.common.crafting.recipe; @@ -19,39 +19,35 @@ public class HeadRecipe extends RecipeRuneAltar { - String name = ""; - - public HeadRecipe(ItemStack output, int mana, Object... inputs) { - super(output, mana, inputs); - } - - @Override - public boolean matches(IInventory inv) { - boolean matches = super.matches(inv); - - if(matches) { - for(int i = 0; i < inv.getSizeInventory(); i++) { - ItemStack stack = inv.getStackInSlot(i); - if(stack == null) - break; - - if(stack.getItem() == Items.name_tag) { - name = stack.getDisplayName(); - if(name.equals(StatCollector.translateToLocal("item.nameTag.name"))) - return false; - } - } - } - - return matches; - } - - @Override - public ItemStack getOutput() { - ItemStack stack = new ItemStack(Items.skull, 1, 3); - if(!name.isEmpty()) - ItemNBTHelper.setString(stack, "SkullOwner", name); - return stack; - } - + String name = ""; + + public HeadRecipe(ItemStack output, int mana, Object... inputs) { + super(output, mana, inputs); + } + + @Override + public boolean matches(IInventory inv) { + boolean matches = super.matches(inv); + + if (matches) { + for (int i = 0; i < inv.getSizeInventory(); i++) { + ItemStack stack = inv.getStackInSlot(i); + if (stack == null) break; + + if (stack.getItem() == Items.name_tag) { + name = stack.getDisplayName(); + if (name.equals(StatCollector.translateToLocal("item.nameTag.name"))) return false; + } + } + } + + return matches; + } + + @Override + public ItemStack getOutput() { + ItemStack stack = new ItemStack(Items.skull, 1, 3); + if (!name.isEmpty()) ItemNBTHelper.setString(stack, "SkullOwner", name); + return stack; + } } diff --git a/src/main/java/vazkii/botania/common/crafting/recipe/HelmRevealingRecipe.java b/src/main/java/vazkii/botania/common/crafting/recipe/HelmRevealingRecipe.java index 0ac847be8f..952568878f 100644 --- a/src/main/java/vazkii/botania/common/crafting/recipe/HelmRevealingRecipe.java +++ b/src/main/java/vazkii/botania/common/crafting/recipe/HelmRevealingRecipe.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [May 6, 2015, 9:45:56 PM (GMT)] */ package vazkii.botania.common.crafting.recipe; @@ -21,83 +21,75 @@ public class HelmRevealingRecipe implements IRecipe { - @Override - public boolean matches(InventoryCrafting var1, World var2) { - Item goggles = (Item) Item.itemRegistry.getObject("Thaumcraft:ItemGoggles"); - if(goggles == null) - return false; // NO TC loaded - - boolean foundGoggles = false; - boolean foundHelm = false; - for(int i = 0; i < var1.getSizeInventory(); i++) { - ItemStack stack = var1.getStackInSlot(i); - if(stack != null) { - if(checkHelm(stack)) - foundHelm = true; - else if(stack.getItem() == goggles) - foundGoggles = true; - else return false; // Found an invalid item, breaking the recipe - } - } - return foundGoggles && foundHelm; - } - - @Override - public ItemStack getCraftingResult(InventoryCrafting var1) { - ItemStack helm = null; - - for(int i = 0; i < var1.getSizeInventory(); i++) { - ItemStack stack = var1.getStackInSlot(i); - if(stack != null && checkHelm(stack)) - helm = stack; - } - - if(helm == null) - return null; - - ItemStack helmCopy = helm.copy(); - Item helmItem = helmCopy.getItem(); - - ItemStack newHelm; - - if(helmItem == ModItems.manasteelHelm) - newHelm = new ItemStack(ModItems.manasteelHelmRevealing); - else if(helmItem == ModItems.terrasteelHelm) - newHelm = new ItemStack(ModItems.terrasteelHelmRevealing); - else if(helmItem == ModItems.elementiumHelm) - newHelm = new ItemStack(ModItems.elementiumHelmRevealing); - else return null; - - //Copy Ancient Wills - for(int i = 0; i < 6; i++) - if(ItemNBTHelper.getBoolean(helmCopy, "AncientWill" + i, false)) - ItemNBTHelper.setBoolean(newHelm, "AncientWill" + i, true); - - //Copy Enchantments - NBTTagList enchList = ItemNBTHelper.getList(helmCopy, "ench", 10, true); - if(enchList != null) - ItemNBTHelper.setList(newHelm, "ench", enchList); - - //Copy Runic Hardening - byte runicHardening = ItemNBTHelper.getByte(helmCopy, "RS.HARDEN", (byte)0); - ItemNBTHelper.setByte(newHelm, "RS.HARDEN", runicHardening); - - return newHelm; - } - - @Override - public int getRecipeSize() { - return 10; - } - - @Override - public ItemStack getRecipeOutput() { - return new ItemStack(ModItems.manasteelHelmRevealing); - } - - private boolean checkHelm(ItemStack helmStack) { - Item helmItem = helmStack.getItem(); - return helmItem == ModItems.manasteelHelm || helmItem == ModItems.terrasteelHelm || helmItem == ModItems.elementiumHelm; - } - -} \ No newline at end of file + @Override + public boolean matches(InventoryCrafting var1, World var2) { + Item goggles = (Item) Item.itemRegistry.getObject("Thaumcraft:ItemGoggles"); + if (goggles == null) return false; // NO TC loaded + + boolean foundGoggles = false; + boolean foundHelm = false; + for (int i = 0; i < var1.getSizeInventory(); i++) { + ItemStack stack = var1.getStackInSlot(i); + if (stack != null) { + if (checkHelm(stack)) foundHelm = true; + else if (stack.getItem() == goggles) foundGoggles = true; + else return false; // Found an invalid item, breaking the recipe + } + } + return foundGoggles && foundHelm; + } + + @Override + public ItemStack getCraftingResult(InventoryCrafting var1) { + ItemStack helm = null; + + for (int i = 0; i < var1.getSizeInventory(); i++) { + ItemStack stack = var1.getStackInSlot(i); + if (stack != null && checkHelm(stack)) helm = stack; + } + + if (helm == null) return null; + + ItemStack helmCopy = helm.copy(); + Item helmItem = helmCopy.getItem(); + + ItemStack newHelm; + + if (helmItem == ModItems.manasteelHelm) newHelm = new ItemStack(ModItems.manasteelHelmRevealing); + else if (helmItem == ModItems.terrasteelHelm) newHelm = new ItemStack(ModItems.terrasteelHelmRevealing); + else if (helmItem == ModItems.elementiumHelm) newHelm = new ItemStack(ModItems.elementiumHelmRevealing); + else return null; + + // Copy Ancient Wills + for (int i = 0; i < 6; i++) + if (ItemNBTHelper.getBoolean(helmCopy, "AncientWill" + i, false)) + ItemNBTHelper.setBoolean(newHelm, "AncientWill" + i, true); + + // Copy Enchantments + NBTTagList enchList = ItemNBTHelper.getList(helmCopy, "ench", 10, true); + if (enchList != null) ItemNBTHelper.setList(newHelm, "ench", enchList); + + // Copy Runic Hardening + byte runicHardening = ItemNBTHelper.getByte(helmCopy, "RS.HARDEN", (byte) 0); + ItemNBTHelper.setByte(newHelm, "RS.HARDEN", runicHardening); + + return newHelm; + } + + @Override + public int getRecipeSize() { + return 10; + } + + @Override + public ItemStack getRecipeOutput() { + return new ItemStack(ModItems.manasteelHelmRevealing); + } + + private boolean checkHelm(ItemStack helmStack) { + Item helmItem = helmStack.getItem(); + return helmItem == ModItems.manasteelHelm + || helmItem == ModItems.terrasteelHelm + || helmItem == ModItems.elementiumHelm; + } +} diff --git a/src/main/java/vazkii/botania/common/crafting/recipe/KeepIvyRecipe.java b/src/main/java/vazkii/botania/common/crafting/recipe/KeepIvyRecipe.java index 6b60ef83be..592fc1ea31 100644 --- a/src/main/java/vazkii/botania/common/crafting/recipe/KeepIvyRecipe.java +++ b/src/main/java/vazkii/botania/common/crafting/recipe/KeepIvyRecipe.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Mar 31, 2015, 9:23:22 PM (GMT)] */ package vazkii.botania.common.crafting.recipe; @@ -20,49 +20,48 @@ public class KeepIvyRecipe implements IRecipe { - @Override - public boolean matches(InventoryCrafting var1, World var2) { - boolean foundIvy = false; - boolean foundItem = false; + @Override + public boolean matches(InventoryCrafting var1, World var2) { + boolean foundIvy = false; + boolean foundItem = false; - for(int i = 0; i < var1.getSizeInventory(); i++) { - ItemStack stack = var1.getStackInSlot(i); - if(stack != null) { - if(stack.getItem() == ModItems.keepIvy) - foundIvy = true; - else if(!foundItem && !(ItemNBTHelper.detectNBT(stack) && ItemNBTHelper.getBoolean(stack, ItemKeepIvy.TAG_KEEP, false)) && !stack.getItem().hasContainerItem(stack)) - foundItem = true; - else return false; - } - } + for (int i = 0; i < var1.getSizeInventory(); i++) { + ItemStack stack = var1.getStackInSlot(i); + if (stack != null) { + if (stack.getItem() == ModItems.keepIvy) foundIvy = true; + else if (!foundItem + && !(ItemNBTHelper.detectNBT(stack) + && ItemNBTHelper.getBoolean(stack, ItemKeepIvy.TAG_KEEP, false)) + && !stack.getItem().hasContainerItem(stack)) foundItem = true; + else return false; + } + } - return foundIvy && foundItem; - } + return foundIvy && foundItem; + } - @Override - public ItemStack getCraftingResult(InventoryCrafting var1) { - ItemStack item = null; + @Override + public ItemStack getCraftingResult(InventoryCrafting var1) { + ItemStack item = null; - for(int i = 0; i < var1.getSizeInventory(); i++) { - ItemStack stack = var1.getStackInSlot(i); - if(stack != null && stack.getItem() != ModItems.keepIvy) - item = stack; - } + for (int i = 0; i < var1.getSizeInventory(); i++) { + ItemStack stack = var1.getStackInSlot(i); + if (stack != null && stack.getItem() != ModItems.keepIvy) item = stack; + } - ItemStack copy = item.copy(); - ItemNBTHelper.setBoolean(copy, ItemKeepIvy.TAG_KEEP, true); - copy.stackSize = 1; - return copy; - } + ItemStack copy = item.copy(); + ItemNBTHelper.setBoolean(copy, ItemKeepIvy.TAG_KEEP, true); + copy.stackSize = 1; + return copy; + } - @Override - public int getRecipeSize() { - return 10; - } - - @Override - public ItemStack getRecipeOutput() { - return null; - } + @Override + public int getRecipeSize() { + return 10; + } + @Override + public ItemStack getRecipeOutput() { + return null; + } } diff --git a/src/main/java/vazkii/botania/common/crafting/recipe/LensDyeingRecipe.java b/src/main/java/vazkii/botania/common/crafting/recipe/LensDyeingRecipe.java index 4f1fab8f91..0bb5c28882 100644 --- a/src/main/java/vazkii/botania/common/crafting/recipe/LensDyeingRecipe.java +++ b/src/main/java/vazkii/botania/common/crafting/recipe/LensDyeingRecipe.java @@ -2,17 +2,16 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jan 23, 2015, 4:10:24 PM (GMT)] */ package vazkii.botania.common.crafting.recipe; import java.util.Arrays; import java.util.List; - import net.minecraft.inventory.InventoryCrafting; import net.minecraft.item.ItemStack; import net.minecraft.item.crafting.IRecipe; @@ -24,77 +23,89 @@ public class LensDyeingRecipe implements IRecipe { - private static final List DYES = Arrays.asList(new String[] { - "dyeWhite", "dyeOrange", "dyeMagenta", "dyeLightBlue", "dyeYellow", "dyeLime", "dyePink", "dyeGray", "dyeLightGray", "dyeCyan", "dyePurple", "dyeBlue", "dyeBrown", "dyeGreen", "dyeRed", "dyeBlack", LibOreDict.MANA_PEARL - }); - - @Override - public boolean matches(InventoryCrafting var1, World var2) { - boolean foundLens = false; - boolean foundDye = false; - - for(int i = 0; i < var1.getSizeInventory(); i++) { - ItemStack stack = var1.getStackInSlot(i); - if(stack != null) { - if(stack.getItem() instanceof ILens && !foundLens) - foundLens = true; - else if(!foundDye) { - int color = getStackColor(stack); - if(color > -1) - foundDye = true; - else return false; - } - else return false;//This means we have an additional item in the recipe after the lens and dye - } - } - - return foundLens && foundDye; - } - - @Override - public ItemStack getCraftingResult(InventoryCrafting var1) { - ItemStack lens = null; - int color = -1; - - for(int i = 0; i < var1.getSizeInventory(); i++) { - ItemStack stack = var1.getStackInSlot(i); - if(stack != null) { - if(stack.getItem() instanceof ILens && lens == null) - lens = stack; - else color = getStackColor(stack);//We can assume if its not a lens its a dye because we checked it in matches() - } - } - - if(lens.getItem() instanceof ILens) { - lens.getItem(); - ItemStack lensCopy = lens.copy(); - ItemLens.setLensColor(lensCopy, color); - - return lensCopy; - } - - return null; - } - - @Override - public int getRecipeSize() { - return 10; - } - - @Override - public ItemStack getRecipeOutput() { - return null; - } - - int getStackColor(ItemStack stack) { - int[] ids = OreDictionary.getOreIDs(stack); - for(int i : ids) { - int index = DYES.indexOf(OreDictionary.getOreName(i)); - if(index >= 0) - return index; - } - - return -1; - } - + private static final List DYES = Arrays.asList(new String[] { + "dyeWhite", + "dyeOrange", + "dyeMagenta", + "dyeLightBlue", + "dyeYellow", + "dyeLime", + "dyePink", + "dyeGray", + "dyeLightGray", + "dyeCyan", + "dyePurple", + "dyeBlue", + "dyeBrown", + "dyeGreen", + "dyeRed", + "dyeBlack", + LibOreDict.MANA_PEARL + }); + + @Override + public boolean matches(InventoryCrafting var1, World var2) { + boolean foundLens = false; + boolean foundDye = false; + + for (int i = 0; i < var1.getSizeInventory(); i++) { + ItemStack stack = var1.getStackInSlot(i); + if (stack != null) { + if (stack.getItem() instanceof ILens && !foundLens) foundLens = true; + else if (!foundDye) { + int color = getStackColor(stack); + if (color > -1) foundDye = true; + else return false; + } else return false; // This means we have an additional item in the recipe after the lens and dye + } + } + + return foundLens && foundDye; + } + + @Override + public ItemStack getCraftingResult(InventoryCrafting var1) { + ItemStack lens = null; + int color = -1; + + for (int i = 0; i < var1.getSizeInventory(); i++) { + ItemStack stack = var1.getStackInSlot(i); + if (stack != null) { + if (stack.getItem() instanceof ILens && lens == null) lens = stack; + else + color = getStackColor( + stack); // We can assume if its not a lens its a dye because we checked it in matches() + } + } + + if (lens.getItem() instanceof ILens) { + lens.getItem(); + ItemStack lensCopy = lens.copy(); + ItemLens.setLensColor(lensCopy, color); + + return lensCopy; + } + + return null; + } + + @Override + public int getRecipeSize() { + return 10; + } + + @Override + public ItemStack getRecipeOutput() { + return null; + } + + int getStackColor(ItemStack stack) { + int[] ids = OreDictionary.getOreIDs(stack); + for (int i : ids) { + int index = DYES.indexOf(OreDictionary.getOreName(i)); + if (index >= 0) return index; + } + + return -1; + } } diff --git a/src/main/java/vazkii/botania/common/crafting/recipe/ManaGunClipRecipe.java b/src/main/java/vazkii/botania/common/crafting/recipe/ManaGunClipRecipe.java index 7403daaf81..5fa7b8f080 100644 --- a/src/main/java/vazkii/botania/common/crafting/recipe/ManaGunClipRecipe.java +++ b/src/main/java/vazkii/botania/common/crafting/recipe/ManaGunClipRecipe.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jan 24, 2015, 8:37:33 PM (GMT)] */ package vazkii.botania.common.crafting.recipe; @@ -17,59 +17,51 @@ import vazkii.botania.common.item.ItemManaGun; import vazkii.botania.common.item.ModItems; -public class ManaGunClipRecipe implements IRecipe { +public class ManaGunClipRecipe implements IRecipe { - @Override - public boolean matches(InventoryCrafting var1, World var2) { - boolean foundGun = false; - boolean foundClip = false; + @Override + public boolean matches(InventoryCrafting var1, World var2) { + boolean foundGun = false; + boolean foundClip = false; - for(int i = 0; i < var1.getSizeInventory(); i++) { - ItemStack stack = var1.getStackInSlot(i); - if(stack != null) { - if(stack.getItem() instanceof ItemManaGun && !ItemManaGun.hasClip(stack)) - foundGun = true; + for (int i = 0; i < var1.getSizeInventory(); i++) { + ItemStack stack = var1.getStackInSlot(i); + if (stack != null) { + if (stack.getItem() instanceof ItemManaGun && !ItemManaGun.hasClip(stack)) foundGun = true; + else if (stack.getItem() == ModItems.clip) foundClip = true; + else return false; // Found an invalid item, breaking the recipe + } + } - else if(stack.getItem() == ModItems.clip) - foundClip = true; + return foundGun && foundClip; + } - else return false; // Found an invalid item, breaking the recipe - } - } + @Override + public ItemStack getCraftingResult(InventoryCrafting var1) { + ItemStack gun = null; - return foundGun && foundClip; - } + for (int i = 0; i < var1.getSizeInventory(); i++) { + ItemStack stack = var1.getStackInSlot(i); + if (stack != null && stack.getItem() instanceof ItemManaGun) gun = stack; + } - @Override - public ItemStack getCraftingResult(InventoryCrafting var1) { - ItemStack gun = null; + if (gun == null) return null; - for(int i = 0; i < var1.getSizeInventory(); i++) { - ItemStack stack = var1.getStackInSlot(i); - if(stack != null && stack.getItem() instanceof ItemManaGun) - gun = stack; - } - - if(gun == null) - return null; - - ItemStack lens = ItemManaGun.getLens(gun); - ItemManaGun.setLens(gun, null); - ItemStack gunCopy = gun.copy(); - ItemManaGun.setClip(gunCopy, true); - ItemManaGun.setLensAtPos(gunCopy, lens, 0); - return gunCopy; - } - - @Override - public int getRecipeSize() { - return 10; - } - - @Override - public ItemStack getRecipeOutput() { - return null; - } + ItemStack lens = ItemManaGun.getLens(gun); + ItemManaGun.setLens(gun, null); + ItemStack gunCopy = gun.copy(); + ItemManaGun.setClip(gunCopy, true); + ItemManaGun.setLensAtPos(gunCopy, lens, 0); + return gunCopy; + } + @Override + public int getRecipeSize() { + return 10; + } + @Override + public ItemStack getRecipeOutput() { + return null; + } } diff --git a/src/main/java/vazkii/botania/common/crafting/recipe/ManaGunLensRecipe.java b/src/main/java/vazkii/botania/common/crafting/recipe/ManaGunLensRecipe.java index 38b6a15f2b..f4a15cc7bb 100644 --- a/src/main/java/vazkii/botania/common/crafting/recipe/ManaGunLensRecipe.java +++ b/src/main/java/vazkii/botania/common/crafting/recipe/ManaGunLensRecipe.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Mar 13, 2014, 8:01:14 PM (GMT)] */ package vazkii.botania.common.crafting.recipe; @@ -20,63 +20,54 @@ public class ManaGunLensRecipe implements IRecipe { - @Override - public boolean matches(InventoryCrafting var1, World var2) { - boolean foundLens = false; - boolean foundGun = false; - - for(int i = 0; i < var1.getSizeInventory(); i++) { - ItemStack stack = var1.getStackInSlot(i); - if(stack != null) { - if(stack.getItem() instanceof ItemManaGun && ItemManaGun.getLens(stack) == null) - foundGun = true; - - else if(stack.getItem() instanceof ILens) { - if(!(stack.getItem() instanceof ILensControl) || !((ILensControl) stack.getItem()).isControlLens(stack)) - foundLens = true; - else return false; - } - - else return false; // Found an invalid item, breaking the recipe - } - } - - return foundLens && foundGun; - } - - @Override - public ItemStack getCraftingResult(InventoryCrafting var1) { - ItemStack lens = null; - ItemStack gun = null; - - for(int i = 0; i < var1.getSizeInventory(); i++) { - ItemStack stack = var1.getStackInSlot(i); - if(stack != null) { - if(stack.getItem() instanceof ItemManaGun) - gun = stack; - else if(stack.getItem() instanceof ILens) - lens = stack; - } - } - - if(lens == null || gun == null) - return null; - - ItemStack gunCopy = gun.copy(); - ItemManaGun.setLens(gunCopy, lens); - - return gunCopy; - } - - - @Override - public int getRecipeSize() { - return 10; - } - - @Override - public ItemStack getRecipeOutput() { - return null; - } - + @Override + public boolean matches(InventoryCrafting var1, World var2) { + boolean foundLens = false; + boolean foundGun = false; + + for (int i = 0; i < var1.getSizeInventory(); i++) { + ItemStack stack = var1.getStackInSlot(i); + if (stack != null) { + if (stack.getItem() instanceof ItemManaGun && ItemManaGun.getLens(stack) == null) foundGun = true; + else if (stack.getItem() instanceof ILens) { + if (!(stack.getItem() instanceof ILensControl) + || !((ILensControl) stack.getItem()).isControlLens(stack)) foundLens = true; + else return false; + } else return false; // Found an invalid item, breaking the recipe + } + } + + return foundLens && foundGun; + } + + @Override + public ItemStack getCraftingResult(InventoryCrafting var1) { + ItemStack lens = null; + ItemStack gun = null; + + for (int i = 0; i < var1.getSizeInventory(); i++) { + ItemStack stack = var1.getStackInSlot(i); + if (stack != null) { + if (stack.getItem() instanceof ItemManaGun) gun = stack; + else if (stack.getItem() instanceof ILens) lens = stack; + } + } + + if (lens == null || gun == null) return null; + + ItemStack gunCopy = gun.copy(); + ItemManaGun.setLens(gunCopy, lens); + + return gunCopy; + } + + @Override + public int getRecipeSize() { + return 10; + } + + @Override + public ItemStack getRecipeOutput() { + return null; + } } diff --git a/src/main/java/vazkii/botania/common/crafting/recipe/ManaGunRemoveLensRecipe.java b/src/main/java/vazkii/botania/common/crafting/recipe/ManaGunRemoveLensRecipe.java index b926d525d1..4d011ebed1 100644 --- a/src/main/java/vazkii/botania/common/crafting/recipe/ManaGunRemoveLensRecipe.java +++ b/src/main/java/vazkii/botania/common/crafting/recipe/ManaGunRemoveLensRecipe.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Oct 6, 2014, 5:56:24 PM (GMT)] */ package vazkii.botania.common.crafting.recipe; @@ -18,49 +18,45 @@ public class ManaGunRemoveLensRecipe implements IRecipe { - @Override - public boolean matches(InventoryCrafting var1, World var2) { - boolean foundGun = false; - - for(int i = 0; i < var1.getSizeInventory(); i++) { - ItemStack stack = var1.getStackInSlot(i); - if(stack != null) { - if(stack.getItem() instanceof ItemManaGun && ItemManaGun.getLens(stack) != null) - foundGun = true; - - else return false; // Found an invalid item, breaking the recipe - } - } - - return foundGun; - } - - @Override - public ItemStack getCraftingResult(InventoryCrafting var1) { - ItemStack gun = null; - - for(int i = 0; i < var1.getSizeInventory(); i++) { - ItemStack stack = var1.getStackInSlot(i); - if(stack != null) { - if(stack.getItem() instanceof ItemManaGun) - gun = stack; - } - } - - ItemStack gunCopy = gun.copy(); - ItemManaGun.setLens(gunCopy, null); - - return gunCopy; - } - - @Override - public int getRecipeSize() { - return 10; - } - - @Override - public ItemStack getRecipeOutput() { - return null; - } - + @Override + public boolean matches(InventoryCrafting var1, World var2) { + boolean foundGun = false; + + for (int i = 0; i < var1.getSizeInventory(); i++) { + ItemStack stack = var1.getStackInSlot(i); + if (stack != null) { + if (stack.getItem() instanceof ItemManaGun && ItemManaGun.getLens(stack) != null) foundGun = true; + else return false; // Found an invalid item, breaking the recipe + } + } + + return foundGun; + } + + @Override + public ItemStack getCraftingResult(InventoryCrafting var1) { + ItemStack gun = null; + + for (int i = 0; i < var1.getSizeInventory(); i++) { + ItemStack stack = var1.getStackInSlot(i); + if (stack != null) { + if (stack.getItem() instanceof ItemManaGun) gun = stack; + } + } + + ItemStack gunCopy = gun.copy(); + ItemManaGun.setLens(gunCopy, null); + + return gunCopy; + } + + @Override + public int getRecipeSize() { + return 10; + } + + @Override + public ItemStack getRecipeOutput() { + return null; + } } diff --git a/src/main/java/vazkii/botania/common/crafting/recipe/PhantomInkRecipe.java b/src/main/java/vazkii/botania/common/crafting/recipe/PhantomInkRecipe.java index fd510dffeb..2f4b740307 100644 --- a/src/main/java/vazkii/botania/common/crafting/recipe/PhantomInkRecipe.java +++ b/src/main/java/vazkii/botania/common/crafting/recipe/PhantomInkRecipe.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Mar 17, 2015, 5:21:07 PM (GMT)] */ package vazkii.botania.common.crafting.recipe; @@ -19,51 +19,48 @@ public class PhantomInkRecipe implements IRecipe { - @Override - public boolean matches(InventoryCrafting var1, World var2) { - boolean foundInk = false; - boolean foundItem = false; + @Override + public boolean matches(InventoryCrafting var1, World var2) { + boolean foundInk = false; + boolean foundItem = false; - for(int i = 0; i < var1.getSizeInventory(); i++) { - ItemStack stack = var1.getStackInSlot(i); - if(stack != null) { - if(stack.getItem() == ModItems.phantomInk && !foundInk) - foundInk = true; - else if(!foundItem) { - if(stack.getItem() instanceof IPhantomInkable && stack.getItem().getContainerItem(stack) == null) - foundItem = true; - else return false; - } else return false; - } - } + for (int i = 0; i < var1.getSizeInventory(); i++) { + ItemStack stack = var1.getStackInSlot(i); + if (stack != null) { + if (stack.getItem() == ModItems.phantomInk && !foundInk) foundInk = true; + else if (!foundItem) { + if (stack.getItem() instanceof IPhantomInkable + && stack.getItem().getContainerItem(stack) == null) foundItem = true; + else return false; + } else return false; + } + } - return foundInk && foundItem; - } + return foundInk && foundItem; + } - @Override - public ItemStack getCraftingResult(InventoryCrafting var1) { - ItemStack item = null; + @Override + public ItemStack getCraftingResult(InventoryCrafting var1) { + ItemStack item = null; - for(int i = 0; i < var1.getSizeInventory(); i++) { - ItemStack stack = var1.getStackInSlot(i); - if(stack != null && stack.getItem() instanceof IPhantomInkable && item == null) - item = stack; - } + for (int i = 0; i < var1.getSizeInventory(); i++) { + ItemStack stack = var1.getStackInSlot(i); + if (stack != null && stack.getItem() instanceof IPhantomInkable && item == null) item = stack; + } - IPhantomInkable inkable = (IPhantomInkable) item.getItem(); - ItemStack copy = item.copy(); - inkable.setPhantomInk(copy, !inkable.hasPhantomInk(item)); - return copy; - } + IPhantomInkable inkable = (IPhantomInkable) item.getItem(); + ItemStack copy = item.copy(); + inkable.setPhantomInk(copy, !inkable.hasPhantomInk(item)); + return copy; + } - @Override - public int getRecipeSize() { - return 10; - } - - @Override - public ItemStack getRecipeOutput() { - return null; - } + @Override + public int getRecipeSize() { + return 10; + } + @Override + public ItemStack getRecipeOutput() { + return null; + } } diff --git a/src/main/java/vazkii/botania/common/crafting/recipe/RegenIvyRecipe.java b/src/main/java/vazkii/botania/common/crafting/recipe/RegenIvyRecipe.java index 3f763b36f7..3925943000 100644 --- a/src/main/java/vazkii/botania/common/crafting/recipe/RegenIvyRecipe.java +++ b/src/main/java/vazkii/botania/common/crafting/recipe/RegenIvyRecipe.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Sep 3, 2014, 6:54:18 PM (GMT)] */ package vazkii.botania.common.crafting.recipe; @@ -21,65 +21,57 @@ public class RegenIvyRecipe implements IRecipe { - @Override - public boolean matches(InventoryCrafting var1, World var2) { - ItemStack tool = null; - boolean foundIvy = false; - int materialsFound = 0; - for(int i = 0; i < var1.getSizeInventory(); i++) { - ItemStack stack = var1.getStackInSlot(i); - if(stack != null) { - Item item = stack.getItem(); - if(item.isRepairable() && !(ItemNBTHelper.detectNBT(stack) && ItemNBTHelper.getBoolean(stack, ItemRegenIvy.TAG_REGEN, false))) - tool = stack; + @Override + public boolean matches(InventoryCrafting var1, World var2) { + ItemStack tool = null; + boolean foundIvy = false; + int materialsFound = 0; + for (int i = 0; i < var1.getSizeInventory(); i++) { + ItemStack stack = var1.getStackInSlot(i); + if (stack != null) { + Item item = stack.getItem(); + if (item.isRepairable() + && !(ItemNBTHelper.detectNBT(stack) + && ItemNBTHelper.getBoolean(stack, ItemRegenIvy.TAG_REGEN, false))) tool = stack; + else if (item == ModItems.regenIvy) foundIvy = true; + } + } + for (int i = 0; i < var1.getSizeInventory(); i++) { + ItemStack stack = var1.getStackInSlot(i); + if (stack != null) { + Item item = stack.getItem(); - else if(item == ModItems.regenIvy) - foundIvy = true; + if (tool != null && tool.getItem().getIsRepairable(tool, stack)) materialsFound++; + else if (stack != tool && item != ModItems.regenIvy) return false; + } + } - } - } - for(int i = 0; i < var1.getSizeInventory(); i++) { - ItemStack stack = var1.getStackInSlot(i); - if(stack != null) { - Item item = stack.getItem(); + return tool != null && foundIvy && materialsFound == 3; + } - if(tool != null && tool.getItem().getIsRepairable(tool, stack)) - materialsFound++; + @Override + public ItemStack getCraftingResult(InventoryCrafting var1) { + ItemStack tool = null; - else if(stack != tool && item != ModItems.regenIvy) - return false; - } - } + for (int i = 0; i < var1.getSizeInventory(); i++) { + ItemStack stack = var1.getStackInSlot(i); + if (stack != null && stack.getItem().isDamageable()) tool = stack; + } - return tool != null && foundIvy && materialsFound == 3; - } + if (tool == null) return null; - @Override - public ItemStack getCraftingResult(InventoryCrafting var1) { - ItemStack tool = null; + ItemStack toolCopy = tool.copy(); + ItemNBTHelper.setBoolean(toolCopy, ItemRegenIvy.TAG_REGEN, true); + return toolCopy; + } - for(int i = 0; i < var1.getSizeInventory(); i++) { - ItemStack stack = var1.getStackInSlot(i); - if(stack != null && stack.getItem().isDamageable()) - tool = stack; - } - - if(tool == null) - return null; - - ItemStack toolCopy = tool.copy(); - ItemNBTHelper.setBoolean(toolCopy, ItemRegenIvy.TAG_REGEN, true); - return toolCopy; - } - - @Override - public int getRecipeSize() { - return 10; - } - - @Override - public ItemStack getRecipeOutput() { - return null; - } + @Override + public int getRecipeSize() { + return 10; + } + @Override + public ItemStack getRecipeOutput() { + return null; + } } diff --git a/src/main/java/vazkii/botania/common/crafting/recipe/SpecialFloatingFlowerRecipe.java b/src/main/java/vazkii/botania/common/crafting/recipe/SpecialFloatingFlowerRecipe.java index 2958c526cc..3bdcc3e8b9 100644 --- a/src/main/java/vazkii/botania/common/crafting/recipe/SpecialFloatingFlowerRecipe.java +++ b/src/main/java/vazkii/botania/common/crafting/recipe/SpecialFloatingFlowerRecipe.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Nov 17, 2014, 6:34:36 PM (GMT)] */ package vazkii.botania.common.crafting.recipe; @@ -20,51 +20,46 @@ public class SpecialFloatingFlowerRecipe implements IRecipe { - @Override - public boolean matches(InventoryCrafting var1, World var2) { - boolean foundFloatingFlower = false; - boolean foundSpecialFlower = false; + @Override + public boolean matches(InventoryCrafting var1, World var2) { + boolean foundFloatingFlower = false; + boolean foundSpecialFlower = false; - for(int i = 0; i < var1.getSizeInventory(); i++) { - ItemStack stack = var1.getStackInSlot(i); - if(stack != null) { - if(stack.getItem() == Item.getItemFromBlock(ModBlocks.floatingFlower)) - foundFloatingFlower = true; + for (int i = 0; i < var1.getSizeInventory(); i++) { + ItemStack stack = var1.getStackInSlot(i); + if (stack != null) { + if (stack.getItem() == Item.getItemFromBlock(ModBlocks.floatingFlower)) foundFloatingFlower = true; + else if (stack.getItem() == Item.getItemFromBlock(ModBlocks.specialFlower)) foundSpecialFlower = true; + else return false; // Found an invalid item, breaking the recipe + } + } - else if(stack.getItem() == Item.getItemFromBlock(ModBlocks.specialFlower)) - foundSpecialFlower = true; + return foundFloatingFlower && foundSpecialFlower; + } - else return false; // Found an invalid item, breaking the recipe - } - } + @Override + public ItemStack getCraftingResult(InventoryCrafting var1) { + ItemStack specialFlower = null; - return foundFloatingFlower && foundSpecialFlower; - } + for (int i = 0; i < var1.getSizeInventory(); i++) { + ItemStack stack = var1.getStackInSlot(i); + if (stack != null && stack.getItem() == Item.getItemFromBlock(ModBlocks.specialFlower)) + specialFlower = stack; + } - @Override - public ItemStack getCraftingResult(InventoryCrafting var1) { - ItemStack specialFlower = null; + if (specialFlower == null) return null; - for(int i = 0; i < var1.getSizeInventory(); i++) { - ItemStack stack = var1.getStackInSlot(i); - if(stack != null && stack.getItem() == Item.getItemFromBlock(ModBlocks.specialFlower)) - specialFlower = stack; - } + return ItemBlockSpecialFlower.ofType( + new ItemStack(ModBlocks.floatingSpecialFlower), ItemBlockSpecialFlower.getType(specialFlower)); + } - if(specialFlower == null) - return null; - - return ItemBlockSpecialFlower.ofType(new ItemStack(ModBlocks.floatingSpecialFlower), ItemBlockSpecialFlower.getType(specialFlower)); - } - - @Override - public int getRecipeSize() { - return 10; - } - - @Override - public ItemStack getRecipeOutput() { - return null; - } + @Override + public int getRecipeSize() { + return 10; + } + @Override + public ItemStack getRecipeOutput() { + return null; + } } diff --git a/src/main/java/vazkii/botania/common/crafting/recipe/SpellClothRecipe.java b/src/main/java/vazkii/botania/common/crafting/recipe/SpellClothRecipe.java index f0aeb8f23e..c65fc16057 100644 --- a/src/main/java/vazkii/botania/common/crafting/recipe/SpellClothRecipe.java +++ b/src/main/java/vazkii/botania/common/crafting/recipe/SpellClothRecipe.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jan 25, 2015, 6:16:13 PM (GMT)] */ package vazkii.botania.common.crafting.recipe; @@ -19,56 +19,50 @@ public class SpellClothRecipe implements IRecipe { - @Override - public boolean matches(InventoryCrafting var1, World var2) { - boolean foundCloth = false; - boolean foundEnchanted = false; + @Override + public boolean matches(InventoryCrafting var1, World var2) { + boolean foundCloth = false; + boolean foundEnchanted = false; - for(int i = 0; i < var1.getSizeInventory(); i++) { - ItemStack stack = var1.getStackInSlot(i); - if(stack != null) { - if(stack.isItemEnchanted() && !foundEnchanted) - foundEnchanted = true; + for (int i = 0; i < var1.getSizeInventory(); i++) { + ItemStack stack = var1.getStackInSlot(i); + if (stack != null) { + if (stack.isItemEnchanted() && !foundEnchanted) foundEnchanted = true; + else if (stack.getItem() == ModItems.spellCloth && !foundCloth) foundCloth = true; + else return false; // Found an invalid item, breaking the recipe + } + } - else if(stack.getItem() == ModItems.spellCloth && !foundCloth) - foundCloth = true; + return foundCloth && foundEnchanted; + } - else return false; // Found an invalid item, breaking the recipe - } - } + @Override + public ItemStack getCraftingResult(InventoryCrafting var1) { + ItemStack stackToDisenchant = null; + for (int i = 0; i < var1.getSizeInventory(); i++) { + ItemStack stack = var1.getStackInSlot(i); + if (stack != null && stack.isItemEnchanted()) { + stackToDisenchant = stack.copy(); + break; + } + } - return foundCloth && foundEnchanted; - } + if (stackToDisenchant == null) return null; - @Override - public ItemStack getCraftingResult(InventoryCrafting var1) { - ItemStack stackToDisenchant = null; - for(int i = 0; i < var1.getSizeInventory(); i++) { - ItemStack stack = var1.getStackInSlot(i); - if(stack != null && stack.isItemEnchanted()) { - stackToDisenchant = stack.copy(); - break; - } - } + NBTTagCompound cmp = (NBTTagCompound) stackToDisenchant.getTagCompound().copy(); + cmp.removeTag("ench"); // Remove enchantments + stackToDisenchant.setTagCompound(cmp); - if(stackToDisenchant == null) - return null; + return stackToDisenchant; + } - NBTTagCompound cmp = (NBTTagCompound) stackToDisenchant.getTagCompound().copy(); - cmp.removeTag("ench"); // Remove enchantments - stackToDisenchant.setTagCompound(cmp); - - return stackToDisenchant; - } - - @Override - public int getRecipeSize() { - return 10; - } - - @Override - public ItemStack getRecipeOutput() { - return null; - } + @Override + public int getRecipeSize() { + return 10; + } + @Override + public ItemStack getRecipeOutput() { + return null; + } } diff --git a/src/main/java/vazkii/botania/common/crafting/recipe/TerraPickTippingRecipe.java b/src/main/java/vazkii/botania/common/crafting/recipe/TerraPickTippingRecipe.java index 733367684d..d13deb8454 100644 --- a/src/main/java/vazkii/botania/common/crafting/recipe/TerraPickTippingRecipe.java +++ b/src/main/java/vazkii/botania/common/crafting/recipe/TerraPickTippingRecipe.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Aug 22, 2014, 7:45:56 PM (GMT)] */ package vazkii.botania.common.crafting.recipe; @@ -19,53 +19,46 @@ public class TerraPickTippingRecipe implements IRecipe { - @Override - public boolean matches(InventoryCrafting var1, World var2) { - boolean foundTerraPick = false; - boolean foundElementiumPick = false; + @Override + public boolean matches(InventoryCrafting var1, World var2) { + boolean foundTerraPick = false; + boolean foundElementiumPick = false; - for(int i = 0; i < var1.getSizeInventory(); i++) { - ItemStack stack = var1.getStackInSlot(i); - if(stack != null) { - if(stack.getItem() instanceof ItemTerraPick && !ItemTerraPick.isTipped(stack)) - foundTerraPick = true; + for (int i = 0; i < var1.getSizeInventory(); i++) { + ItemStack stack = var1.getStackInSlot(i); + if (stack != null) { + if (stack.getItem() instanceof ItemTerraPick && !ItemTerraPick.isTipped(stack)) foundTerraPick = true; + else if (stack.getItem() == ModItems.elementiumPick) foundElementiumPick = true; + else return false; // Found an invalid item, breaking the recipe + } + } - else if(stack.getItem() == ModItems.elementiumPick) - foundElementiumPick = true; + return foundTerraPick && foundElementiumPick; + } - else return false; // Found an invalid item, breaking the recipe - } - } + @Override + public ItemStack getCraftingResult(InventoryCrafting var1) { + ItemStack terraPick = null; - return foundTerraPick && foundElementiumPick; - } + for (int i = 0; i < var1.getSizeInventory(); i++) { + ItemStack stack = var1.getStackInSlot(i); + if (stack != null && stack.getItem() instanceof ItemTerraPick) terraPick = stack; + } - @Override - public ItemStack getCraftingResult(InventoryCrafting var1) { - ItemStack terraPick = null; + if (terraPick == null) return null; - for(int i = 0; i < var1.getSizeInventory(); i++) { - ItemStack stack = var1.getStackInSlot(i); - if(stack != null && stack.getItem() instanceof ItemTerraPick) - terraPick = stack; - } + ItemStack terraPickCopy = terraPick.copy(); + ItemTerraPick.setTipped(terraPickCopy); + return terraPickCopy; + } - if(terraPick == null) - return null; - - ItemStack terraPickCopy = terraPick.copy(); - ItemTerraPick.setTipped(terraPickCopy); - return terraPickCopy; - } - - @Override - public int getRecipeSize() { - return 10; - } - - @Override - public ItemStack getRecipeOutput() { - return null; - } + @Override + public int getRecipeSize() { + return 10; + } + @Override + public ItemStack getRecipeOutput() { + return null; + } } diff --git a/src/main/java/vazkii/botania/common/entity/EntityBabylonWeapon.java b/src/main/java/vazkii/botania/common/entity/EntityBabylonWeapon.java index 5dd088788b..97f1c880a9 100644 --- a/src/main/java/vazkii/botania/common/entity/EntityBabylonWeapon.java +++ b/src/main/java/vazkii/botania/common/entity/EntityBabylonWeapon.java @@ -2,16 +2,15 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Aug 16, 2015, 3:56:14 PM (GMT)] */ package vazkii.botania.common.entity; import java.util.List; - import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; @@ -28,206 +27,203 @@ public class EntityBabylonWeapon extends EntityThrowableCopy { - private static final String TAG_CHARGING = "charging"; - private static final String TAG_VARIETY = "variety"; - private static final String TAG_CHARGE_TICKS = "chargeTicks"; - private static final String TAG_LIVE_TICKS = "liveTicks"; - private static final String TAG_DELAY = "delay"; - private static final String TAG_ROTATION = "rotation"; - - public EntityBabylonWeapon(World world) { - super(world); - } - - public EntityBabylonWeapon(World world, EntityLivingBase thrower) { - super(world, thrower); - } - - @Override - protected void entityInit() { - setSize(0F, 0F); - - dataWatcher.addObject(20, (byte) 0); - dataWatcher.addObject(21, 0); - dataWatcher.addObject(22, 0); - dataWatcher.addObject(23, 0); - dataWatcher.addObject(24, 0); - dataWatcher.addObject(25, 0F); - - dataWatcher.setObjectWatched(20); - dataWatcher.setObjectWatched(21); - dataWatcher.setObjectWatched(22); - dataWatcher.setObjectWatched(23); - dataWatcher.setObjectWatched(24); - dataWatcher.setObjectWatched(25); - } - - @Override - public void onUpdate() { - EntityLivingBase thrower = getThrower(); - if(!worldObj.isRemote && (thrower == null || !(thrower instanceof EntityPlayer) || thrower.isDead)) { - setDead(); - return; - } - EntityPlayer player = (EntityPlayer) thrower; - boolean charging = isCharging(); - if(!worldObj.isRemote) { - ItemStack stack = player == null ? null : player.getCurrentEquippedItem(); - boolean newCharging = stack != null && stack.getItem() == ModItems.kingKey && ItemKingKey.isCharging(stack); - if(charging != newCharging) { - setCharging(newCharging); - charging = newCharging; - } - } - - double x = motionX; - double y = motionY; - double z = motionZ; - - int liveTime = getLiveTicks(); - int delay = getDelay(); - charging &= liveTime == 0; - - if(charging) { - motionX = 0; - motionY = 0; - motionZ = 0; - - int chargeTime = getChargeTicks(); - setChargeTicks(chargeTime + 1); - - if(worldObj.rand.nextInt(20) == 0) - worldObj.playSoundAtEntity(this, "botania:babylonSpawn", 0.1F, 1F + worldObj.rand.nextFloat() * 3F); - } else { - if(liveTime < delay) { - motionX = 0; - motionY = 0; - motionZ = 0; - } else if (liveTime == delay && player != null) { - Vector3 playerLook = null; - MovingObjectPosition lookat = ToolCommons.raytraceFromEntity(worldObj, player, true, 64); - if(lookat == null) - playerLook = new Vector3(player.getLookVec()).multiply(64).add(Vector3.fromEntity(player)); - else playerLook = new Vector3(lookat.blockX + 0.5, lookat.blockY + 0.5, lookat.blockZ + 0.5); - - Vector3 thisVec = Vector3.fromEntityCenter(this); - Vector3 motionVec = playerLook.sub(thisVec).normalize().multiply(2); - - x = motionVec.x; - y = motionVec.y; - z = motionVec.z; - worldObj.playSoundAtEntity(this, "botania:babylonAttack", 2F, 0.1F + worldObj.rand.nextFloat() * 3F); - } - setLiveTicks(liveTime + 1); - - if(!worldObj.isRemote) { - AxisAlignedBB axis = AxisAlignedBB.getBoundingBox(posX, posY, posZ, lastTickPosX, lastTickPosY, lastTickPosZ).expand(2, 2, 2); - List entities = worldObj.getEntitiesWithinAABB(EntityLivingBase.class, axis); - for(EntityLivingBase living : entities) { - if(living == thrower) - continue; - - if(living.hurtTime == 0) { - if(player != null) - living.attackEntityFrom(DamageSource.causePlayerDamage(player), 20); - else living.attackEntityFrom(DamageSource.generic, 20); - onImpact(new MovingObjectPosition(living)); - return; - } - } - } - } - - super.onUpdate(); - - motionX = x; - motionY = y; - motionZ = z; - - if(liveTime > delay) - Botania.proxy.wispFX(worldObj, posX, posY, posZ, 1F, 1F, 0F, 0.3F, 0F); - - if(liveTime > 200 + delay) - setDead(); - } - - @Override - protected void onImpact(MovingObjectPosition pos) { - EntityLivingBase thrower = getThrower(); - if(pos.entityHit == null || pos.entityHit != thrower) { - worldObj.createExplosion(this, posX, posY, posZ, 3F, false); - setDead(); - } - } - - @Override - public void writeEntityToNBT(NBTTagCompound cmp) { - super.writeEntityToNBT(cmp); - cmp.setBoolean(TAG_CHARGING, isCharging()); - cmp.setInteger(TAG_VARIETY, getVariety()); - cmp.setInteger(TAG_CHARGE_TICKS, getChargeTicks()); - cmp.setInteger(TAG_LIVE_TICKS, getLiveTicks()); - cmp.setInteger(TAG_DELAY, getDelay()); - cmp.setFloat(TAG_ROTATION, getRotation()); - } - - @Override - public void readEntityFromNBT(NBTTagCompound cmp) { - super.readEntityFromNBT(cmp); - setCharging(cmp.getBoolean(TAG_CHARGING)); - setVariety(cmp.getInteger(TAG_VARIETY)); - setChargeTicks(cmp.getInteger(TAG_CHARGE_TICKS)); - setLiveTicks(cmp.getInteger(TAG_LIVE_TICKS)); - setDelay(cmp.getInteger(TAG_DELAY)); - setRotation(cmp.getFloat(TAG_ROTATION)); - } - - public boolean isCharging() { - return dataWatcher.getWatchableObjectByte(20) == 1; - } - - public void setCharging(boolean charging) { - dataWatcher.updateObject(20, (byte) (charging ? 1 : 0)); - } - - public int getVariety() { - return dataWatcher.getWatchableObjectInt(21); - } - - public void setVariety(int var) { - dataWatcher.updateObject(21, var); - } - - public int getChargeTicks() { - return dataWatcher.getWatchableObjectInt(22); - } - - public void setChargeTicks(int ticks) { - dataWatcher.updateObject(22, ticks); - } - - public int getLiveTicks() { - return dataWatcher.getWatchableObjectInt(23); - } - - public void setLiveTicks(int ticks) { - dataWatcher.updateObject(23, ticks); - } - - public int getDelay() { - return dataWatcher.getWatchableObjectInt(24); - } - - public void setDelay(int delay) { - dataWatcher.updateObject(24, delay); - } - - public float getRotation() { - return dataWatcher.getWatchableObjectFloat(25); - } - - public void setRotation(float rot) { - dataWatcher.updateObject(25, rot); - } - + private static final String TAG_CHARGING = "charging"; + private static final String TAG_VARIETY = "variety"; + private static final String TAG_CHARGE_TICKS = "chargeTicks"; + private static final String TAG_LIVE_TICKS = "liveTicks"; + private static final String TAG_DELAY = "delay"; + private static final String TAG_ROTATION = "rotation"; + + public EntityBabylonWeapon(World world) { + super(world); + } + + public EntityBabylonWeapon(World world, EntityLivingBase thrower) { + super(world, thrower); + } + + @Override + protected void entityInit() { + setSize(0F, 0F); + + dataWatcher.addObject(20, (byte) 0); + dataWatcher.addObject(21, 0); + dataWatcher.addObject(22, 0); + dataWatcher.addObject(23, 0); + dataWatcher.addObject(24, 0); + dataWatcher.addObject(25, 0F); + + dataWatcher.setObjectWatched(20); + dataWatcher.setObjectWatched(21); + dataWatcher.setObjectWatched(22); + dataWatcher.setObjectWatched(23); + dataWatcher.setObjectWatched(24); + dataWatcher.setObjectWatched(25); + } + + @Override + public void onUpdate() { + EntityLivingBase thrower = getThrower(); + if (!worldObj.isRemote && (thrower == null || !(thrower instanceof EntityPlayer) || thrower.isDead)) { + setDead(); + return; + } + EntityPlayer player = (EntityPlayer) thrower; + boolean charging = isCharging(); + if (!worldObj.isRemote) { + ItemStack stack = player == null ? null : player.getCurrentEquippedItem(); + boolean newCharging = stack != null && stack.getItem() == ModItems.kingKey && ItemKingKey.isCharging(stack); + if (charging != newCharging) { + setCharging(newCharging); + charging = newCharging; + } + } + + double x = motionX; + double y = motionY; + double z = motionZ; + + int liveTime = getLiveTicks(); + int delay = getDelay(); + charging &= liveTime == 0; + + if (charging) { + motionX = 0; + motionY = 0; + motionZ = 0; + + int chargeTime = getChargeTicks(); + setChargeTicks(chargeTime + 1); + + if (worldObj.rand.nextInt(20) == 0) + worldObj.playSoundAtEntity(this, "botania:babylonSpawn", 0.1F, 1F + worldObj.rand.nextFloat() * 3F); + } else { + if (liveTime < delay) { + motionX = 0; + motionY = 0; + motionZ = 0; + } else if (liveTime == delay && player != null) { + Vector3 playerLook = null; + MovingObjectPosition lookat = ToolCommons.raytraceFromEntity(worldObj, player, true, 64); + if (lookat == null) + playerLook = new Vector3(player.getLookVec()).multiply(64).add(Vector3.fromEntity(player)); + else playerLook = new Vector3(lookat.blockX + 0.5, lookat.blockY + 0.5, lookat.blockZ + 0.5); + + Vector3 thisVec = Vector3.fromEntityCenter(this); + Vector3 motionVec = playerLook.sub(thisVec).normalize().multiply(2); + + x = motionVec.x; + y = motionVec.y; + z = motionVec.z; + worldObj.playSoundAtEntity(this, "botania:babylonAttack", 2F, 0.1F + worldObj.rand.nextFloat() * 3F); + } + setLiveTicks(liveTime + 1); + + if (!worldObj.isRemote) { + AxisAlignedBB axis = AxisAlignedBB.getBoundingBox( + posX, posY, posZ, lastTickPosX, lastTickPosY, lastTickPosZ) + .expand(2, 2, 2); + List entities = worldObj.getEntitiesWithinAABB(EntityLivingBase.class, axis); + for (EntityLivingBase living : entities) { + if (living == thrower) continue; + + if (living.hurtTime == 0) { + if (player != null) living.attackEntityFrom(DamageSource.causePlayerDamage(player), 20); + else living.attackEntityFrom(DamageSource.generic, 20); + onImpact(new MovingObjectPosition(living)); + return; + } + } + } + } + + super.onUpdate(); + + motionX = x; + motionY = y; + motionZ = z; + + if (liveTime > delay) Botania.proxy.wispFX(worldObj, posX, posY, posZ, 1F, 1F, 0F, 0.3F, 0F); + + if (liveTime > 200 + delay) setDead(); + } + + @Override + protected void onImpact(MovingObjectPosition pos) { + EntityLivingBase thrower = getThrower(); + if (pos.entityHit == null || pos.entityHit != thrower) { + worldObj.createExplosion(this, posX, posY, posZ, 3F, false); + setDead(); + } + } + + @Override + public void writeEntityToNBT(NBTTagCompound cmp) { + super.writeEntityToNBT(cmp); + cmp.setBoolean(TAG_CHARGING, isCharging()); + cmp.setInteger(TAG_VARIETY, getVariety()); + cmp.setInteger(TAG_CHARGE_TICKS, getChargeTicks()); + cmp.setInteger(TAG_LIVE_TICKS, getLiveTicks()); + cmp.setInteger(TAG_DELAY, getDelay()); + cmp.setFloat(TAG_ROTATION, getRotation()); + } + + @Override + public void readEntityFromNBT(NBTTagCompound cmp) { + super.readEntityFromNBT(cmp); + setCharging(cmp.getBoolean(TAG_CHARGING)); + setVariety(cmp.getInteger(TAG_VARIETY)); + setChargeTicks(cmp.getInteger(TAG_CHARGE_TICKS)); + setLiveTicks(cmp.getInteger(TAG_LIVE_TICKS)); + setDelay(cmp.getInteger(TAG_DELAY)); + setRotation(cmp.getFloat(TAG_ROTATION)); + } + + public boolean isCharging() { + return dataWatcher.getWatchableObjectByte(20) == 1; + } + + public void setCharging(boolean charging) { + dataWatcher.updateObject(20, (byte) (charging ? 1 : 0)); + } + + public int getVariety() { + return dataWatcher.getWatchableObjectInt(21); + } + + public void setVariety(int var) { + dataWatcher.updateObject(21, var); + } + + public int getChargeTicks() { + return dataWatcher.getWatchableObjectInt(22); + } + + public void setChargeTicks(int ticks) { + dataWatcher.updateObject(22, ticks); + } + + public int getLiveTicks() { + return dataWatcher.getWatchableObjectInt(23); + } + + public void setLiveTicks(int ticks) { + dataWatcher.updateObject(23, ticks); + } + + public int getDelay() { + return dataWatcher.getWatchableObjectInt(24); + } + + public void setDelay(int delay) { + dataWatcher.updateObject(24, delay); + } + + public float getRotation() { + return dataWatcher.getWatchableObjectFloat(25); + } + + public void setRotation(float rot) { + dataWatcher.updateObject(25, rot); + } } diff --git a/src/main/java/vazkii/botania/common/entity/EntityCorporeaSpark.java b/src/main/java/vazkii/botania/common/entity/EntityCorporeaSpark.java index 62f89441be..3c80075335 100644 --- a/src/main/java/vazkii/botania/common/entity/EntityCorporeaSpark.java +++ b/src/main/java/vazkii/botania/common/entity/EntityCorporeaSpark.java @@ -2,17 +2,16 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Feb 13, 2015, 10:52:40 PM (GMT)] */ package vazkii.botania.common.entity; import java.util.ArrayList; import java.util.List; - import net.minecraft.entity.Entity; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.init.Blocks; @@ -28,285 +27,280 @@ public class EntityCorporeaSpark extends Entity implements ICorporeaSpark { - private static final int SCAN_RANGE = 8; - - private static final String TAG_MASTER = "master"; - private static final String TAG_NETWORK = "network"; - private static final String TAG_INVIS = "invis"; - - ICorporeaSpark master; - List connections = new ArrayList(); - List connectionsClient = new ArrayList(); - List relatives = new ArrayList(); - boolean firstUpdateClient = true; - boolean firstUpdateServer = true; - - public EntityCorporeaSpark(World world) { - super(world); - isImmuneToFire = true; - } - - @Override - protected void entityInit() { - setSize(0.1F, 0.5F); - dataWatcher.addObject(EntitySpark.INVISIBILITY_DATA_WATCHER_KEY, 0); - dataWatcher.addObject(28, 0); - dataWatcher.addObject(29, 0); - dataWatcher.addObject(30, 0); - dataWatcher.addObject(31, new ItemStack(Blocks.stone, 0, 0)); - - dataWatcher.setObjectWatched(EntitySpark.INVISIBILITY_DATA_WATCHER_KEY); - dataWatcher.setObjectWatched(28); - dataWatcher.setObjectWatched(29); - dataWatcher.setObjectWatched(30); - dataWatcher.setObjectWatched(31); - } - - @Override - public boolean canBeCollidedWith() { - return true; - } - - @Override - public void onUpdate() { - super.onUpdate(); - IInventory inv = getInventory(); - if(inv == null) { - if(!worldObj.isRemote) - setDead(); - return; - } - - if(isMaster()) - master = this; - - if(worldObj.isRemote ? firstUpdateClient : firstUpdateServer) { - if(isMaster()) - restartNetwork(); - else findNetwork(); - - if(worldObj.isRemote) - firstUpdateClient = false; - else firstUpdateServer = false; - } - - if(master != null && (((Entity) master).isDead || master.getNetwork() != getNetwork())) - master = null; - - int displayTicks = getItemDisplayTicks(); - if(displayTicks > 0) - setItemDisplayTicks(displayTicks - 1); - else if(displayTicks < 0) - setItemDisplayTicks(displayTicks + 1); - } - - @Override - public void setDead() { - super.setDead(); - if(!worldObj.isRemote) - entityDropItem(new ItemStack(ModItems.corporeaSpark, 1, isMaster() ? 1 : 0), 0F); - connections.remove(this); - connectionsClient.remove(this); - restartNetwork(); - } - - @Override - public void registerConnections(ICorporeaSpark master, ICorporeaSpark referrer, List connections) { - List sparks = getNearbySparks(); - relatives.clear(); - for(ICorporeaSpark spark : sparks) { - if(spark == null || connections.contains(spark) || spark.getNetwork() != getNetwork() || spark.isMaster() || ((Entity) spark).isDead) - continue; - - connections.add(spark); - relatives.add(spark); - spark.registerConnections(master, this, connections); - } - - this.master = master; - if(worldObj.isRemote) - connectionsClient = connections; - else this.connections = connections; - } - - List getNearbySparks() { - return worldObj.getEntitiesWithinAABB(ICorporeaSpark.class, AxisAlignedBB.getBoundingBox(posX - SCAN_RANGE, posY - SCAN_RANGE, posZ - SCAN_RANGE, posX + SCAN_RANGE, posY + SCAN_RANGE, posZ + SCAN_RANGE)); - } - - void restartNetwork() { - if(worldObj.isRemote) - connectionsClient = new ArrayList(); - else connections = new ArrayList(); - relatives = new ArrayList(); - - if(master != null) { - ICorporeaSpark oldMaster = master; - master = null; - - oldMaster.registerConnections(oldMaster, this, new ArrayList()); - } - } - - void findNetwork() { - List sparks = getNearbySparks(); - if(sparks.size() > 0) { - for(ICorporeaSpark spark : sparks) - if(spark.getNetwork() == getNetwork() && !((Entity) spark).isDead) { - ICorporeaSpark master = spark.getMaster(); - if(master != null) { - this.master = master; - restartNetwork(); - - break; - } - } - } - } - - void displayRelatives(ArrayList checked, ICorporeaSpark spark) { - if(spark == null) - return; - - List sparks = spark.getRelatives(); - if(sparks.isEmpty()) - EntitySpark.particleBeam((Entity) spark, (Entity) spark.getMaster()); - else for(ICorporeaSpark endSpark : sparks) { - if(!checked.contains(endSpark)) { - EntitySpark.particleBeam((Entity) spark, (Entity) endSpark); - checked.add(endSpark); - displayRelatives(checked, endSpark); - } - } - } - - @Override - public IInventory getInventory() { - int x = MathHelper.floor_double(posX); - int y = MathHelper.floor_double(posY - 1); - int z = MathHelper.floor_double(posZ); - return InventoryHelper.getInventory(worldObj, x, y, z); - } - - @Override - public List getConnections() { - return worldObj.isRemote ? connectionsClient : connections; - } - - @Override - public List getRelatives() { - return relatives; - } - - @Override - public void onItemExtracted(ItemStack stack) { - setItemDisplayTicks(10); - setDisplayedItem(stack); - } - - @Override - public void onItemsRequested(List stacks) { - if(!stacks.isEmpty()) { - setItemDisplayTicks(-10); - setDisplayedItem(stacks.get(0)); - } - } - - @Override - public ICorporeaSpark getMaster() { - return master; - } - - public void setMaster(boolean master) { - dataWatcher.updateObject(28, master ? 1 : 0); - } - - @Override - public boolean isMaster() { - return dataWatcher.getWatchableObjectInt(28) == 1; - } - - public void setNetwork(int network) { - dataWatcher.updateObject(29, network); - } - - @Override - public int getNetwork() { - return dataWatcher.getWatchableObjectInt(29); - } - - public int getItemDisplayTicks() { - return dataWatcher.getWatchableObjectInt(30); - } - - public void setItemDisplayTicks(int ticks) { - dataWatcher.updateObject(30, ticks); - } - - public ItemStack getDisplayedItem() { - return dataWatcher.getWatchableObjectItemStack(31); - } - - public void setDisplayedItem(ItemStack stack) { - dataWatcher.updateObject(31, stack); - } - - @Override - public boolean interactFirst(EntityPlayer player) { - ItemStack stack = player.getCurrentEquippedItem(); - if(stack != null) { - if(stack.getItem() == ModItems.twigWand) { - if(player.isSneaking()) { - setDead(); - if(isMaster()) - restartNetwork(); - if(player.worldObj.isRemote) - player.swingItem(); - return true; - } else { - displayRelatives(new ArrayList(), master); - return true; - } - } else if(stack.getItem() == ModItems.dye) { - int color = stack.getItemDamage(); - if(color != getNetwork()) { - setNetwork(color); - - if(master != null) - restartNetwork(); - else findNetwork(); - - stack.stackSize--; - if(player.worldObj.isRemote) - player.swingItem(); - } - } - } - - return doPhantomInk(stack); - } - - public boolean doPhantomInk(ItemStack stack) { - if(stack != null && stack.getItem() == ModItems.phantomInk && !worldObj.isRemote) { - int invis = dataWatcher.getWatchableObjectInt(EntitySpark.INVISIBILITY_DATA_WATCHER_KEY); - dataWatcher.updateObject(EntitySpark.INVISIBILITY_DATA_WATCHER_KEY, ~invis & 1); - return true; - } - - return false; - } - - @Override - protected void readEntityFromNBT(NBTTagCompound cmp) { - setMaster(cmp.getBoolean(TAG_MASTER)); - setNetwork(cmp.getInteger(TAG_NETWORK)); - dataWatcher.updateObject(EntitySpark.INVISIBILITY_DATA_WATCHER_KEY, cmp.getInteger(TAG_INVIS)); - } - - @Override - protected void writeEntityToNBT(NBTTagCompound cmp) { - cmp.setBoolean(TAG_MASTER, isMaster()); - cmp.setInteger(TAG_NETWORK, getNetwork()); - cmp.setInteger(TAG_INVIS, dataWatcher.getWatchableObjectInt(EntitySpark.INVISIBILITY_DATA_WATCHER_KEY)); - } - + private static final int SCAN_RANGE = 8; + + private static final String TAG_MASTER = "master"; + private static final String TAG_NETWORK = "network"; + private static final String TAG_INVIS = "invis"; + + ICorporeaSpark master; + List connections = new ArrayList(); + List connectionsClient = new ArrayList(); + List relatives = new ArrayList(); + boolean firstUpdateClient = true; + boolean firstUpdateServer = true; + + public EntityCorporeaSpark(World world) { + super(world); + isImmuneToFire = true; + } + + @Override + protected void entityInit() { + setSize(0.1F, 0.5F); + dataWatcher.addObject(EntitySpark.INVISIBILITY_DATA_WATCHER_KEY, 0); + dataWatcher.addObject(28, 0); + dataWatcher.addObject(29, 0); + dataWatcher.addObject(30, 0); + dataWatcher.addObject(31, new ItemStack(Blocks.stone, 0, 0)); + + dataWatcher.setObjectWatched(EntitySpark.INVISIBILITY_DATA_WATCHER_KEY); + dataWatcher.setObjectWatched(28); + dataWatcher.setObjectWatched(29); + dataWatcher.setObjectWatched(30); + dataWatcher.setObjectWatched(31); + } + + @Override + public boolean canBeCollidedWith() { + return true; + } + + @Override + public void onUpdate() { + super.onUpdate(); + IInventory inv = getInventory(); + if (inv == null) { + if (!worldObj.isRemote) setDead(); + return; + } + + if (isMaster()) master = this; + + if (worldObj.isRemote ? firstUpdateClient : firstUpdateServer) { + if (isMaster()) restartNetwork(); + else findNetwork(); + + if (worldObj.isRemote) firstUpdateClient = false; + else firstUpdateServer = false; + } + + if (master != null && (((Entity) master).isDead || master.getNetwork() != getNetwork())) master = null; + + int displayTicks = getItemDisplayTicks(); + if (displayTicks > 0) setItemDisplayTicks(displayTicks - 1); + else if (displayTicks < 0) setItemDisplayTicks(displayTicks + 1); + } + + @Override + public void setDead() { + super.setDead(); + if (!worldObj.isRemote) entityDropItem(new ItemStack(ModItems.corporeaSpark, 1, isMaster() ? 1 : 0), 0F); + connections.remove(this); + connectionsClient.remove(this); + restartNetwork(); + } + + @Override + public void registerConnections(ICorporeaSpark master, ICorporeaSpark referrer, List connections) { + List sparks = getNearbySparks(); + relatives.clear(); + for (ICorporeaSpark spark : sparks) { + if (spark == null + || connections.contains(spark) + || spark.getNetwork() != getNetwork() + || spark.isMaster() + || ((Entity) spark).isDead) continue; + + connections.add(spark); + relatives.add(spark); + spark.registerConnections(master, this, connections); + } + + this.master = master; + if (worldObj.isRemote) connectionsClient = connections; + else this.connections = connections; + } + + List getNearbySparks() { + return worldObj.getEntitiesWithinAABB( + ICorporeaSpark.class, + AxisAlignedBB.getBoundingBox( + posX - SCAN_RANGE, + posY - SCAN_RANGE, + posZ - SCAN_RANGE, + posX + SCAN_RANGE, + posY + SCAN_RANGE, + posZ + SCAN_RANGE)); + } + + void restartNetwork() { + if (worldObj.isRemote) connectionsClient = new ArrayList(); + else connections = new ArrayList(); + relatives = new ArrayList(); + + if (master != null) { + ICorporeaSpark oldMaster = master; + master = null; + + oldMaster.registerConnections(oldMaster, this, new ArrayList()); + } + } + + void findNetwork() { + List sparks = getNearbySparks(); + if (sparks.size() > 0) { + for (ICorporeaSpark spark : sparks) + if (spark.getNetwork() == getNetwork() && !((Entity) spark).isDead) { + ICorporeaSpark master = spark.getMaster(); + if (master != null) { + this.master = master; + restartNetwork(); + + break; + } + } + } + } + + void displayRelatives(ArrayList checked, ICorporeaSpark spark) { + if (spark == null) return; + + List sparks = spark.getRelatives(); + if (sparks.isEmpty()) EntitySpark.particleBeam((Entity) spark, (Entity) spark.getMaster()); + else + for (ICorporeaSpark endSpark : sparks) { + if (!checked.contains(endSpark)) { + EntitySpark.particleBeam((Entity) spark, (Entity) endSpark); + checked.add(endSpark); + displayRelatives(checked, endSpark); + } + } + } + + @Override + public IInventory getInventory() { + int x = MathHelper.floor_double(posX); + int y = MathHelper.floor_double(posY - 1); + int z = MathHelper.floor_double(posZ); + return InventoryHelper.getInventory(worldObj, x, y, z); + } + + @Override + public List getConnections() { + return worldObj.isRemote ? connectionsClient : connections; + } + + @Override + public List getRelatives() { + return relatives; + } + + @Override + public void onItemExtracted(ItemStack stack) { + setItemDisplayTicks(10); + setDisplayedItem(stack); + } + + @Override + public void onItemsRequested(List stacks) { + if (!stacks.isEmpty()) { + setItemDisplayTicks(-10); + setDisplayedItem(stacks.get(0)); + } + } + + @Override + public ICorporeaSpark getMaster() { + return master; + } + + public void setMaster(boolean master) { + dataWatcher.updateObject(28, master ? 1 : 0); + } + + @Override + public boolean isMaster() { + return dataWatcher.getWatchableObjectInt(28) == 1; + } + + public void setNetwork(int network) { + dataWatcher.updateObject(29, network); + } + + @Override + public int getNetwork() { + return dataWatcher.getWatchableObjectInt(29); + } + + public int getItemDisplayTicks() { + return dataWatcher.getWatchableObjectInt(30); + } + + public void setItemDisplayTicks(int ticks) { + dataWatcher.updateObject(30, ticks); + } + + public ItemStack getDisplayedItem() { + return dataWatcher.getWatchableObjectItemStack(31); + } + + public void setDisplayedItem(ItemStack stack) { + dataWatcher.updateObject(31, stack); + } + + @Override + public boolean interactFirst(EntityPlayer player) { + ItemStack stack = player.getCurrentEquippedItem(); + if (stack != null) { + if (stack.getItem() == ModItems.twigWand) { + if (player.isSneaking()) { + setDead(); + if (isMaster()) restartNetwork(); + if (player.worldObj.isRemote) player.swingItem(); + return true; + } else { + displayRelatives(new ArrayList(), master); + return true; + } + } else if (stack.getItem() == ModItems.dye) { + int color = stack.getItemDamage(); + if (color != getNetwork()) { + setNetwork(color); + + if (master != null) restartNetwork(); + else findNetwork(); + + stack.stackSize--; + if (player.worldObj.isRemote) player.swingItem(); + } + } + } + + return doPhantomInk(stack); + } + + public boolean doPhantomInk(ItemStack stack) { + if (stack != null && stack.getItem() == ModItems.phantomInk && !worldObj.isRemote) { + int invis = dataWatcher.getWatchableObjectInt(EntitySpark.INVISIBILITY_DATA_WATCHER_KEY); + dataWatcher.updateObject(EntitySpark.INVISIBILITY_DATA_WATCHER_KEY, ~invis & 1); + return true; + } + + return false; + } + + @Override + protected void readEntityFromNBT(NBTTagCompound cmp) { + setMaster(cmp.getBoolean(TAG_MASTER)); + setNetwork(cmp.getInteger(TAG_NETWORK)); + dataWatcher.updateObject(EntitySpark.INVISIBILITY_DATA_WATCHER_KEY, cmp.getInteger(TAG_INVIS)); + } + + @Override + protected void writeEntityToNBT(NBTTagCompound cmp) { + cmp.setBoolean(TAG_MASTER, isMaster()); + cmp.setInteger(TAG_NETWORK, getNetwork()); + cmp.setInteger(TAG_INVIS, dataWatcher.getWatchableObjectInt(EntitySpark.INVISIBILITY_DATA_WATCHER_KEY)); + } } diff --git a/src/main/java/vazkii/botania/common/entity/EntityDoppleganger.java b/src/main/java/vazkii/botania/common/entity/EntityDoppleganger.java index fcf87b3400..6eae7a0ca8 100644 --- a/src/main/java/vazkii/botania/common/entity/EntityDoppleganger.java +++ b/src/main/java/vazkii/botania/common/entity/EntityDoppleganger.java @@ -2,21 +2,23 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jul 12, 2014, 3:47:45 PM (GMT)] */ package vazkii.botania.common.entity; +import cpw.mods.fml.relauncher.ReflectionHelper; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; import java.awt.Rectangle; import java.util.ArrayList; import java.util.Arrays; import java.util.Collection; import java.util.List; import java.util.regex.Pattern; - import net.minecraft.block.Block; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.ScaledResolution; @@ -54,11 +56,9 @@ import net.minecraft.world.EnumDifficulty; import net.minecraft.world.World; import net.minecraftforge.common.util.FakePlayer; - import org.lwjgl.opengl.ARBShaderObjects; import org.lwjgl.opengl.GL11; import org.lwjgl.opengl.GL12; - import vazkii.botania.api.boss.IBotaniaBossWithShader; import vazkii.botania.api.internal.ShaderCallback; import vazkii.botania.api.lexicon.multiblock.Multiblock; @@ -74,891 +74,958 @@ import vazkii.botania.common.item.ModItems; import vazkii.botania.common.item.relic.ItemRelic; import vazkii.botania.common.lib.LibObfuscation; -import cpw.mods.fml.relauncher.ReflectionHelper; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; public class EntityDoppleganger extends EntityCreature implements IBotaniaBossWithShader { - public static final int SPAWN_TICKS = 160; - private static final float RANGE = 12F; - private static final float MAX_HP = 800F; - - public static final int MOB_SPAWN_START_TICKS = 20; - public static final int MOB_SPAWN_END_TICKS = 80; - public static final int MOB_SPAWN_BASE_TICKS = 800; - public static final int MOB_SPAWN_TICKS = MOB_SPAWN_BASE_TICKS + MOB_SPAWN_START_TICKS + MOB_SPAWN_END_TICKS; - public static final int MOB_SPAWN_WAVES = 10; - public static final int MOB_SPAWN_WAVE_TIME = MOB_SPAWN_BASE_TICKS / MOB_SPAWN_WAVES; - - private static final String TAG_INVUL_TIME = "invulTime"; - private static final String TAG_AGGRO = "aggro"; - private static final String TAG_SOURCE_X = "sourceX"; - private static final String TAG_SOURCE_Y = "sourceY"; - private static final String TAG_SOURCE_Z = "sourcesZ"; - private static final String TAG_MOB_SPAWN_TICKS = "mobSpawnTicks"; - private static final String TAG_HARD_MODE = "hardMode"; - private static final String TAG_PLAYER_COUNT = "playerCount"; - - private static final int[][] PYLON_LOCATIONS = new int[][] { - { 4, 1, 4 }, - { 4, 1, -4 }, - { -4, 1, 4 }, - { -4, 1, -4 } - }; - - private static final List CHEATY_BLOCKS = Arrays.asList(new String[] { - "OpenBlocks:beartrap", - "ThaumicTinkerer:magnet" - }); - - boolean spawnLandmines = false; - boolean spawnPixies = false; - boolean anyWithArmor = false; - - List playersWhoAttacked = new ArrayList(); - - private static boolean isPlayingMusic = false; - - public EntityDoppleganger(World par1World) { - super(par1World); - setSize(0.6F, 1.8F); - getNavigator().setCanSwim(true); - tasks.addTask(0, new EntityAISwimming(this)); - tasks.addTask(1, new EntityAIWatchClosest(this, EntityPlayer.class, Float.MAX_VALUE)); - isImmuneToFire = true; - experienceValue = 825; - } - - public static MultiblockSet makeMultiblockSet() { - Multiblock mb = new Multiblock(); - - for(int[] p : PYLON_LOCATIONS) - mb.addComponent(p[0], p[1] + 1, p[2], ModBlocks.pylon, 2); - - for(int i = 0; i < 3; i++) - for(int j = 0; j < 3; j++) - mb.addComponent(new BeaconComponent(new ChunkCoordinates(i - 1, 0, j - 1))); - - mb.addComponent(new BeaconBeamComponent(new ChunkCoordinates(0, 1, 0))); - mb.setRenderOffset(0, -1, 0); - - return mb.makeSet(); - } - - public static boolean spawn(EntityPlayer player, ItemStack par1ItemStack, World par3World, int par4, int par5, int par6, boolean hard) { - if(par3World.getTileEntity(par4, par5, par6) instanceof TileEntityBeacon && isTruePlayer(player)) { - if(par3World.difficultySetting == EnumDifficulty.PEACEFUL) { - if(!par3World.isRemote) - player.addChatMessage(new ChatComponentTranslation("botaniamisc.peacefulNoob").setChatStyle(new ChatStyle().setColor(EnumChatFormatting.RED))); - return false; - } - - for(int[] coords : PYLON_LOCATIONS) { - int x = par4 + coords[0]; - int y = par5 + coords[1]; - int z = par6 + coords[2]; - - Block blockat = par3World.getBlock(x, y, z); - int meta = par3World.getBlockMetadata(x, y, z); - if(blockat != ModBlocks.pylon || meta != 2) { - if(!par3World.isRemote) - player.addChatMessage(new ChatComponentTranslation("botaniamisc.needsCatalysts").setChatStyle(new ChatStyle().setColor(EnumChatFormatting.RED))); - return false; - } - } - - if(!hasProperArena(par3World, par4, par5, par6)) { - for(int i = 0; i < 360; i += 8) { - float r = 1F; - float g = 0F; - float b = 1F; - float rad = i * (float) Math.PI / 180F; - double x = par4 + 0.5 - Math.cos(rad) * RANGE; - double y = par5 + 0.5; - double z = par6 + 0.5 - Math.sin(rad) * RANGE; - - Botania.proxy.sparkleFX(par3World, x, y, z, r, g, b, 5F, 120); - } - - if(!par3World.isRemote) - player.addChatMessage(new ChatComponentTranslation("botaniamisc.badArena").setChatStyle(new ChatStyle().setColor(EnumChatFormatting.RED))); - return false; - } - - par1ItemStack.stackSize--; - - if(par3World.isRemote) - return true; - - EntityDoppleganger e = new EntityDoppleganger(par3World); - e.setPosition(par4 + 0.5, par5 + 3, par6 + 0.5); - e.setInvulTime(SPAWN_TICKS); - e.setHealth(1F); - e.setSource(par4, par5, par6); - e.setMobSpawnTicks(MOB_SPAWN_TICKS); - e.setHardMode(hard); - - List players = e.getPlayersAround(); - int playerCount = 0; - for(EntityPlayer p : players) - if(isTruePlayer(p)) - playerCount++; - - e.setPlayerCount(playerCount); - e.getAttributeMap().getAttributeInstance(SharedMonsterAttributes.maxHealth).setBaseValue(MAX_HP * playerCount); - - par3World.playSoundAtEntity(e, "mob.enderdragon.growl", 10F, 0.1F); - par3World.spawnEntityInWorld(e); - return true; - } - - return false; - } - - private static boolean hasProperArena(World world, int sx, int sy, int sz) { - int heightCheck = 3; - int heightMin = 2; - int range = (int) Math.ceil(RANGE); - for(int i = -range; i < range + 1; i++) - for(int j = -range; j < range + 1; j++) { - if(Math.abs(i) == 4 && Math.abs(j) == 4 || vazkii.botania.common.core.helper.MathHelper.pointDistancePlane(i, j, 0, 0) > RANGE) - continue; // Ignore pylons and out of circle - - int x = sx + i; - int z = sz + j; - int air = 0; - - yCheck: { - for(int k = heightCheck + heightMin + 1; k >= -heightCheck; k--) { - int y = sy + k; - boolean isAir = world.getBlock(x, y, z).getCollisionBoundingBoxFromPool(world, x, y, z) == null; - if(isAir) - air++; - else { - if(k > heightCheck) - continue; - else if(air > 2) - break yCheck; - air = 0; - } - } - - return false; - } - } - - return true; - } - - @Override - protected boolean isAIEnabled() { - return true; - } - - @Override - protected void entityInit() { - super.entityInit(); - dataWatcher.addObject(20, 0); // Invul Time - dataWatcher.addObject(21, (byte) 0); // Aggro - dataWatcher.addObject(22, 0); // TP Delay - dataWatcher.addObject(23, 0); // Source X - dataWatcher.addObject(24, 0); // Source Y - dataWatcher.addObject(25, 0); // Source Z - dataWatcher.addObject(26, 0); // Ticks spawning mobs - dataWatcher.addObject(27, (byte) 0); // Hard Mode - dataWatcher.addObject(28, 0); // Player count - } - - public int getInvulTime() { - return dataWatcher.getWatchableObjectInt(20); - } - - public boolean isAggored() { - return dataWatcher.getWatchableObjectByte(21) == 1; - } - - public int getTPDelay() { - return dataWatcher.getWatchableObjectInt(22); - } - - public ChunkCoordinates getSource() { - int x = dataWatcher.getWatchableObjectInt(23); - int y = dataWatcher.getWatchableObjectInt(24); - int z = dataWatcher.getWatchableObjectInt(25); - return new ChunkCoordinates(x, y, z); - } - - public int getMobSpawnTicks() { - return dataWatcher.getWatchableObjectInt(26); - } - - public boolean isHardMode() { - return dataWatcher.getWatchableObjectByte(27) == 1; - } - - public int getPlayerCount() { - return dataWatcher.getWatchableObjectInt(28); - } - - public void setInvulTime(int time) { - dataWatcher.updateObject(20, time); - } - - public void setAggroed(boolean aggored) { - dataWatcher.updateObject(21, (byte) (aggored ? 1 : 0)); - } - - public void setTPDelay(int delay) { - dataWatcher.updateObject(22, delay); - } - - public void setSource(int x, int y, int z) { - dataWatcher.updateObject(23, x); - dataWatcher.updateObject(24, y); - dataWatcher.updateObject(25, z); - } - - public void setMobSpawnTicks(int ticks) { - dataWatcher.updateObject(26, ticks); - } - - public void setHardMode(boolean hardMode) { - dataWatcher.updateObject(27, (byte) (hardMode ? 1 : 0)); - } - - public void setPlayerCount(int count) { - dataWatcher.updateObject(28, count); - } - - @Override - public void writeEntityToNBT(NBTTagCompound par1nbtTagCompound) { - super.writeEntityToNBT(par1nbtTagCompound); - par1nbtTagCompound.setInteger(TAG_INVUL_TIME, getInvulTime()); - par1nbtTagCompound.setBoolean(TAG_AGGRO, isAggored()); - par1nbtTagCompound.setInteger(TAG_MOB_SPAWN_TICKS, getMobSpawnTicks()); - - ChunkCoordinates source = getSource(); - par1nbtTagCompound.setInteger(TAG_SOURCE_X, source.posX); - par1nbtTagCompound.setInteger(TAG_SOURCE_Y, source.posY); - par1nbtTagCompound.setInteger(TAG_SOURCE_Z, source.posZ); - - par1nbtTagCompound.setBoolean(TAG_HARD_MODE, isHardMode()); - par1nbtTagCompound.setInteger(TAG_PLAYER_COUNT, getPlayerCount()); - } - - @Override - public void readEntityFromNBT(NBTTagCompound par1nbtTagCompound) { - super.readEntityFromNBT(par1nbtTagCompound); - setInvulTime(par1nbtTagCompound.getInteger(TAG_INVUL_TIME)); - setAggroed(par1nbtTagCompound.getBoolean(TAG_AGGRO)); - setMobSpawnTicks(par1nbtTagCompound.getInteger(TAG_MOB_SPAWN_TICKS)); - - int x = par1nbtTagCompound.getInteger(TAG_SOURCE_X); - int y = par1nbtTagCompound.getInteger(TAG_SOURCE_Y); - int z = par1nbtTagCompound.getInteger(TAG_SOURCE_Z); - setSource(x, y, z); - - setHardMode(par1nbtTagCompound.getBoolean(TAG_HARD_MODE)); - if(par1nbtTagCompound.hasKey(TAG_PLAYER_COUNT)) - setPlayerCount(par1nbtTagCompound.getInteger(TAG_PLAYER_COUNT)); - else setPlayerCount(1); - } - - @Override - public boolean attackEntityFrom(DamageSource par1DamageSource, float par2) { - Entity e = par1DamageSource.getEntity(); - if((par1DamageSource.damageType.equals("player") || e instanceof EntityPixie) && e != null && isTruePlayer(e) && getInvulTime() == 0) { - EntityPlayer player = (EntityPlayer) e; - if(!playersWhoAttacked.contains(player.getCommandSenderName())) - playersWhoAttacked.add(player.getCommandSenderName()); - - float dmg = par2; - boolean crit = false; - if(e instanceof EntityPlayer) { - EntityPlayer p = (EntityPlayer) e; - crit = p.fallDistance > 0.0F && !p.onGround && !p.isOnLadder() && !p.isInWater() && !p.isPotionActive(Potion.blindness) && p.ridingEntity == null; - } - - int cap = crit ? 60 : 40; - return super.attackEntityFrom(par1DamageSource, Math.min(cap, dmg) * (isHardMode() ? 0.6F : 1F)); - } - return false; - } - - private static final Pattern FAKE_PLAYER_PATTERN = Pattern.compile("^(?:\\[.*\\])|(?:ComputerCraft)$"); - public static boolean isTruePlayer(Entity e) { - if(!(e instanceof EntityPlayer)) - return false; - - EntityPlayer player = (EntityPlayer) e; - - String name = player.getCommandSenderName(); - return !(player instanceof FakePlayer || FAKE_PLAYER_PATTERN.matcher(name).matches()); - } - - @Override - protected void damageEntity(DamageSource par1DamageSource, float par2) { - super.damageEntity(par1DamageSource, par2); - - Entity attacker = par1DamageSource.getEntity(); - if(attacker != null) { - Vector3 thisVector = Vector3.fromEntityCenter(this); - Vector3 playerVector = Vector3.fromEntityCenter(attacker); - Vector3 motionVector = thisVector.copy().sub(playerVector).copy().normalize().multiply(0.75); - - if(getHealth() > 0) { - motionX = -motionVector.x; - motionY = 0.5; - motionZ = -motionVector.z; - setTPDelay(4); - spawnPixies = isAggored(); - } - - setAggroed(true); - } - } - - @Override - public void onDeath(DamageSource p_70645_1_) { - super.onDeath(p_70645_1_); - EntityLivingBase entitylivingbase = func_94060_bK(); - if(entitylivingbase instanceof EntityPlayer) { - ((EntityPlayer) entitylivingbase).addStat(ModAchievements.gaiaGuardianKill, 1); - if(!anyWithArmor) - ((EntityPlayer) entitylivingbase).addStat(ModAchievements.gaiaGuardianNoArmor, 1); - } - - worldObj.playSoundAtEntity(this, "random.explode", 20F, (1F + (worldObj.rand.nextFloat() - worldObj.rand.nextFloat()) * 0.2F) * 0.7F); - worldObj.spawnParticle("hugeexplosion", posX, posY, posZ, 1D, 0D, 0D); - } - - @Override - protected void applyEntityAttributes() { - super.applyEntityAttributes(); - getEntityAttribute(SharedMonsterAttributes.movementSpeed).setBaseValue(0.4); - getEntityAttribute(SharedMonsterAttributes.maxHealth).setBaseValue(MAX_HP); - getEntityAttribute(SharedMonsterAttributes.knockbackResistance).setBaseValue(1.0); - } - - @Override - protected boolean canDespawn() { - return false; - } - - @Override - protected void dropFewItems(boolean par1, int par2) { - if(par1) { - for(int pl = 0; pl < playersWhoAttacked.size(); pl++) { - boolean hard = isHardMode(); - entityDropItem(new ItemStack(ModItems.manaResource, pl == 0 ? hard ? 16 : 8 : hard ? 10 : 6, 5), 1F); - boolean droppedRecord = false; - - if(hard) { - entityDropItem(new ItemStack(ModItems.ancientWill, 1, rand.nextInt(6)), 1F); - if(ConfigHandler.relicsEnabled) { - ItemStack dice = new ItemStack(ModItems.dice); - ItemRelic.bindToUsernameS(playersWhoAttacked.get(pl), dice); - entityDropItem(dice, 1F); - } - - if(Math.random() < 0.25) - entityDropItem(new ItemStack(ModItems.overgrowthSeed, rand.nextInt(3) + 1), 1F); - if(Math.random() < 0.5) { - boolean voidLotus = Math.random() < 0.3F; - entityDropItem(new ItemStack(ModItems.blackLotus, voidLotus ? 1 : rand.nextInt(3) + 1, voidLotus ? 1 : 0), 1F); - } - if(Math.random() < 0.9) - entityDropItem(new ItemStack(ModItems.manaResource, 16 + rand.nextInt(12)), 1F); - if(Math.random() < 0.7) - entityDropItem(new ItemStack(ModItems.manaResource, 8 + rand.nextInt(6), 1), 1F); - if(Math.random() < 0.5) - entityDropItem(new ItemStack(ModItems.manaResource, 4 + rand.nextInt(3), 2), 1F); - - int runes = rand.nextInt(6) + 1; - for(int i = 0; i < runes; i++) - if(Math.random() < 0.3) - entityDropItem(new ItemStack(ModItems.rune, 2 + rand.nextInt(3), rand.nextInt(16)), 1F); - - if(Math.random() < 0.2) - entityDropItem(new ItemStack(ModItems.pinkinator), 1F); - if(Math.random() < 0.3) { - int i = Item.getIdFromItem(Items.record_13); - int j = Item.getIdFromItem(Items.record_wait); - int k = i + rand.nextInt(j - i + 1); - entityDropItem(new ItemStack(Item.getItemById(k)), 1F); - droppedRecord = true; - } - } - - if(!droppedRecord && Math.random() < 0.2) - entityDropItem(new ItemStack(hard ? ModItems.recordGaia2 : ModItems.recordGaia1), 1F); - } - } - } - - @Override - public void setDead() { - ChunkCoordinates source = getSource(); - Botania.proxy.playRecordClientSided(worldObj, source.posX, source.posY, source.posZ, null); - isPlayingMusic = false; - super.setDead(); - } - - public List getPlayersAround() { - ChunkCoordinates source = getSource(); - float range = 15F; - List players = worldObj.getEntitiesWithinAABB(EntityPlayer.class, AxisAlignedBB.getBoundingBox(source.posX + 0.5 - range, source.posY + 0.5 - range, source.posZ + 0.5 - range, source.posX + 0.5 + range, source.posY + 0.5 + range, source.posZ + 0.5 + range)); - return players; - } - - @Override - public void onLivingUpdate() { - super.onLivingUpdate(); - - if(ridingEntity != null) { - if(ridingEntity.riddenByEntity != null) - ridingEntity.riddenByEntity = null; - ridingEntity = null; - } - - boolean peaceful = worldObj.difficultySetting == EnumDifficulty.PEACEFUL; - if(!worldObj.isRemote && peaceful) - setDead(); - - if(!worldObj.isRemote) { - int radius = 1; - int posXInt = MathHelper.floor_double(posX); - int posYInt = MathHelper.floor_double(posY); - int posZInt = MathHelper.floor_double(posZ); - for(int i = -radius; i < radius + 1; i++) - for(int j = -radius; j < radius + 1; j++) - for(int k = -radius; k < radius + 1; k++) { - int xp = posXInt + i; - int yp = posYInt + j; - int zp = posZInt + k; - if(isCheatyBlock(worldObj, xp, yp, zp)) { - Block block = worldObj.getBlock(xp, yp, zp); - List items = block.getDrops(worldObj, xp, yp, zp, 0, 0); - for(ItemStack stack : items) { - if(ConfigHandler.blockBreakParticles) - worldObj.playAuxSFX(2001, xp, yp, zp, Block.getIdFromBlock(block) + (worldObj.getBlockMetadata(xp, yp, zp) << 12)); - worldObj.spawnEntityInWorld(new EntityItem(worldObj, xp + 0.5, yp + 0.5, zp + 0.5, stack)); - } - worldObj.setBlockToAir(xp, yp, zp); - } - } - } - - ChunkCoordinates source = getSource(); - boolean hard = isHardMode(); - float range = RANGE + 3F; - List players = getPlayersAround(); - int playerCount = getPlayerCount(); - - if(worldObj.isRemote && !isPlayingMusic && !isDead && !players.isEmpty()) { - Botania.proxy.playRecordClientSided(worldObj, source.posX, source.posY, source.posZ, (ItemRecord) (hard ? ModItems.recordGaia2 : ModItems.recordGaia1)); - isPlayingMusic = true; - } - - range = RANGE; - for(int i = 0; i < 360; i += 8) { - float r = 0.6F; - float g = 0F; - float b = 0.2F; - float m = 0.15F; - float mv = 0.35F; - - float rad = i * (float) Math.PI / 180F; - double x = source.posX + 0.5 - Math.cos(rad) * range; - double y = source.posY + 0.5; - double z = source.posZ + 0.5 - Math.sin(rad) * range; - - Botania.proxy.wispFX(worldObj, x, y, z, r, g, b, 0.5F, (float) (Math.random() - 0.5F) * m, (float) (Math.random() - 0.5F) * mv, (float) (Math.random() - 0.5F) * m); - } - - if(players.isEmpty() && !worldObj.playerEntities.isEmpty()) - setDead(); - else { - for(EntityPlayer player : players) { - if(player.inventory.armorInventory[0] != null || player.inventory.armorInventory[1] != null || player.inventory.armorInventory[2] != null || player.inventory.armorInventory[3] != null) - anyWithArmor = true; - - List remove = new ArrayList(); - Collection active = player.getActivePotionEffects(); - for(PotionEffect effect : active) - if(effect.getDuration() < 200 && effect.getIsAmbient() && !ReflectionHelper.getPrivateValue(Potion.class, Potion.potionTypes[effect.getPotionID()], LibObfuscation.IS_BAD_EFFECT)) - remove.add(effect); - - active.removeAll(remove); - - player.capabilities.isFlying = player.capabilities.isFlying && player.capabilities.isCreativeMode; - - if(vazkii.botania.common.core.helper.MathHelper.pointDistanceSpace(player.posX, player.posY, player.posZ, source.posX + 0.5, source.posY + 0.5, source.posZ + 0.5) >= range) { - Vector3 sourceVector = new Vector3(source.posX + 0.5, source.posY + 0.5, source.posZ + 0.5); - Vector3 playerVector = Vector3.fromEntityCenter(player); - Vector3 motion = sourceVector.copy().sub(playerVector).copy().normalize(); - - player.motionX = motion.x; - player.motionY = 0.2; - player.motionZ = motion.z; - } - } - } - - if(isDead) - return; - - int invul = getInvulTime(); - int mobTicks = getMobSpawnTicks(); - boolean spawnMissiles = hard && ticksExisted % 15 < 4; - - if(invul > 10) { - Vector3 pos = Vector3.fromEntityCenter(this).subtract(new Vector3(0, 0.2, 0)); - for(int i = 0; i < PYLON_LOCATIONS.length; i++) { - int[] arr = PYLON_LOCATIONS[i]; - int x = arr[0]; - int y = arr[1]; - int z = arr[2]; - - Vector3 pylonPos = new Vector3(source.posX + x, source.posY + y, source.posZ + z); - double worldTime = ticksExisted; - worldTime /= 5; - - float rad = 0.75F + (float) Math.random() * 0.05F; - double xp = pylonPos.x + 0.5 + Math.cos(worldTime) * rad; - double zp = pylonPos.z + 0.5 + Math.sin(worldTime) * rad; - - Vector3 partPos = new Vector3(xp, pylonPos.y, zp); - Vector3 mot = pos.copy().sub(partPos).multiply(0.04); - - float r = 0.7F + (float) Math.random() * 0.3F; - float g = (float) Math.random() * 0.3F; - float b = 0.7F + (float) Math.random() * 0.3F; - - Botania.proxy.wispFX(worldObj, partPos.x, partPos.y, partPos.z, r, g, b, 0.25F + (float) Math.random() * 0.1F, -0.075F - (float) Math.random() * 0.015F); - Botania.proxy.wispFX(worldObj, partPos.x, partPos.y, partPos.z, r, g, b, 0.4F, (float) mot.x, (float) mot.y, (float) mot.z); - } - } - - if(invul > 0 && mobTicks == MOB_SPAWN_TICKS) { - if(invul < SPAWN_TICKS) { - if(invul > SPAWN_TICKS / 2 && worldObj.rand.nextInt(SPAWN_TICKS - invul + 1) == 0) - for(int i = 0; i < 2; i++) - spawnExplosionParticle(); - } - - if(!worldObj.isRemote) { - setHealth(getHealth() + (getMaxHealth() - 1F) / SPAWN_TICKS); - setInvulTime(invul - 1); - } - motionY = 0; - } else { - if(isAggored()) { - boolean dying = getHealth() / getMaxHealth() < 0.2; - if(dying && mobTicks > 0) { - motionX = 0; - motionY = 0; - motionZ = 0; - - int reverseTicks = MOB_SPAWN_TICKS - mobTicks; - if(reverseTicks < MOB_SPAWN_START_TICKS) { - motionY = 0.2; - setInvulTime(invul + 1); - } - - if(reverseTicks > MOB_SPAWN_START_TICKS * 2 && mobTicks > MOB_SPAWN_END_TICKS && mobTicks % MOB_SPAWN_WAVE_TIME == 0 && !worldObj.isRemote) { - for(int pl = 0; pl < playerCount; pl++) - for(int i = 0; i < 3 + worldObj.rand.nextInt(2); i++) { - EntityLiving entity = null; - switch(worldObj.rand.nextInt(2)) { - case 0 : { - entity = new EntityZombie(worldObj); - if(worldObj.rand.nextInt(hard ? 3 : 12) == 0) - entity = new EntityWitch(worldObj); - - break; - } - case 1 : { - entity = new EntitySkeleton(worldObj); - ((EntitySkeleton) entity).setCurrentItemOrArmor(0, new ItemStack(Items.bow)); - if(worldObj.rand.nextInt(8) == 0) { - ((EntitySkeleton) entity).setSkeletonType(1); - ((EntitySkeleton) entity).setCurrentItemOrArmor(0, new ItemStack(hard ? ModItems.elementiumSword : Items.stone_sword)); - } - break; - } - case 3 : { - if(!players.isEmpty()) - for(int j = 0; j < 1 + worldObj.rand.nextInt(hard ? 8 : 5); j++) { - EntityPixie pixie = new EntityPixie(worldObj); - pixie.setProps(players.get(rand.nextInt(players.size())), this, 1, 8); - pixie.setPosition(posX + width / 2, posY + 2, posZ + width / 2); - worldObj.spawnEntityInWorld(pixie); - } - } - } - - if(entity != null) { - range = 6F; - entity.setPosition(posX + 0.5 + Math.random() * range - range / 2, posY - 1, posZ + 0.5 + Math.random() * range - range / 2); - worldObj.spawnEntityInWorld(entity); - } - } - - if(hard && ticksExisted % 3 < 2) { - for(int i = 0; i < playerCount; i++) - spawnMissile(); - spawnMissiles = false; - } - } - - setMobSpawnTicks(mobTicks - 1); - setTPDelay(10); - } else if(getTPDelay() > 0 && !worldObj.isRemote) { - if(invul > 0) - setInvulTime(invul - 1); - - setTPDelay(getTPDelay() - 1); - if(getTPDelay() == 0 && getHealth() > 0) { - int tries = 0; - while(!teleportRandomly() && tries < 50) - tries++; - if(tries >= 50) - teleportTo(source.posX + 0.5, source.posY + 1.6, source.posZ + 0.5); - - if(spawnLandmines) { - int count = dying && hard ? 7 : 6; - for(int i = 0; i < count; i++) { - int x = source.posX - 10 + rand.nextInt(20); - int z = source.posZ - 10 + rand.nextInt(20); - int y = worldObj.getTopSolidOrLiquidBlock(x, z); - - EntityMagicLandmine landmine = new EntityMagicLandmine(worldObj); - landmine.setPosition(x + 0.5, y, z + 0.5); - landmine.summoner = this; - worldObj.spawnEntityInWorld(landmine); - } - - } - - if(!players.isEmpty()) - for(int pl = 0; pl < playerCount; pl++) - for(int i = 0; i < (spawnPixies ? worldObj.rand.nextInt(hard ? 6 : 3) : 1); i++) { - EntityPixie pixie = new EntityPixie(worldObj); - pixie.setProps(players.get(rand.nextInt(players.size())), this, 1, 8); - pixie.setPosition(posX + width / 2, posY + 2, posZ + width / 2); - worldObj.spawnEntityInWorld(pixie); - } - - setTPDelay(hard ? (dying ? 35 : 45) : (dying ? 40 : 60)); - spawnLandmines = true; - spawnPixies = false; - } - } - - if(spawnMissiles) - spawnMissile(); - } else { - range = 3F; - players = worldObj.getEntitiesWithinAABB(EntityPlayer.class, AxisAlignedBB.getBoundingBox(posX - range, posY - range, posZ - range, posX + range, posY + range, posZ + range)); - if(!players.isEmpty()) - damageEntity(DamageSource.causePlayerDamage(players.get(0)), 0); - } - } - } - - void spawnMissile() { - if(!worldObj.isRemote) { - EntityMagicMissile missile = new EntityMagicMissile(this, true); - missile.setPosition(posX + (Math.random() - 0.5 * 0.1), posY + 2.4 + (Math.random() - 0.5 * 0.1), posZ + (Math.random() - 0.5 * 0.1)); - if(missile.getTarget()) { - worldObj.playSoundAtEntity(this, "botania:missile", 0.6F, 0.8F + (float) Math.random() * 0.2F); - worldObj.spawnEntityInWorld(missile); - } - } - } - - public static boolean isCheatyBlock(World world, int x, int y, int z) { - Block block = world.getBlock(x, y, z); - String name = Block.blockRegistry.getNameForObject(block); - return CHEATY_BLOCKS.contains(name); - } - - // EntityEnderman code below ============================================================================ - - protected boolean teleportRandomly() { - double d0 = posX + (rand.nextDouble() - 0.5D) * 64.0D; - double d1 = posY + (rand.nextInt(64) - 32); - double d2 = posZ + (rand.nextDouble() - 0.5D) * 64.0D; - return teleportTo(d0, d1, d2); - } - - protected boolean teleportTo(double par1, double par3, double par5) { - double d3 = posX; - double d4 = posY; - double d5 = posZ; - posX = par1; - posY = par3; - posZ = par5; - boolean flag = false; - int i = MathHelper.floor_double(posX); - int j = MathHelper.floor_double(posY); - int k = MathHelper.floor_double(posZ); - - if(worldObj.blockExists(i, j, k)) { - boolean flag1 = false; - - while(!flag1 && j > 0) { - Block block = worldObj.getBlock(i, j - 1, k); - - if(block.getMaterial().blocksMovement()) - flag1 = true; - else { - --posY; - --j; - } - } - - if(flag1) { - setPosition(posX, posY, posZ); - - if(worldObj.getCollidingBoundingBoxes(this, boundingBox).isEmpty() && !worldObj.isAnyLiquid(boundingBox)) - flag = true; - - // Prevent out of bounds teleporting - ChunkCoordinates source = getSource(); - if(vazkii.botania.common.core.helper.MathHelper.pointDistanceSpace(posX, posY, posZ, source.posX, source.posY, source.posZ) > 12) - flag = false; - } - } - - if (!flag) { - setPosition(d3, d4, d5); - return false; - } else { - short short1 = 128; - - for(int l = 0; l < short1; ++l) { - double d6 = l / (short1 - 1.0D); - float f = (rand.nextFloat() - 0.5F) * 0.2F; - float f1 = (rand.nextFloat() - 0.5F) * 0.2F; - float f2 = (rand.nextFloat() - 0.5F) * 0.2F; - double d7 = d3 + (posX - d3) * d6 + (rand.nextDouble() - 0.5D) * width * 2.0D; - double d8 = d4 + (posY - d4) * d6 + rand.nextDouble() * height; - double d9 = d5 + (posZ - d5) * d6 + (rand.nextDouble() - 0.5D) * width * 2.0D; - worldObj.spawnParticle("portal", d7, d8, d9, f, f1, f2); - } - - worldObj.playSoundEffect(d3, d4, d5, "mob.endermen.portal", 1.0F, 1.0F); - playSound("mob.endermen.portal", 1.0F, 1.0F); - return true; - } - } - - @Override - @SideOnly(Side.CLIENT) - public ResourceLocation getBossBarTexture() { - return BossBarHandler.defaultBossBar; - } - - @SideOnly(Side.CLIENT) - private static Rectangle barRect; - @SideOnly(Side.CLIENT) - private static Rectangle hpBarRect; - - @Override - @SideOnly(Side.CLIENT) - public Rectangle getBossBarTextureRect() { - if(barRect == null) - barRect = new Rectangle(0, 0, 185, 15); - return barRect; - } - - @Override - @SideOnly(Side.CLIENT) - public Rectangle getBossBarHPTextureRect() { - if(hpBarRect == null) - hpBarRect = new Rectangle(0, barRect.y + barRect.height, 181, 7); - return hpBarRect; - } - - @Override - @SideOnly(Side.CLIENT) - public void bossBarRenderCallback(ScaledResolution res, int x, int y) { - GL11.glPushMatrix(); - int px = x + 160; - int py = y + 12; - - Minecraft mc = Minecraft.getMinecraft(); - ItemStack stack = new ItemStack(Items.skull, 1, 3); - mc.renderEngine.bindTexture(TextureMap.locationItemsTexture); - net.minecraft.client.renderer.RenderHelper.enableGUIStandardItemLighting(); - GL11.glEnable(GL12.GL_RESCALE_NORMAL); - RenderItem.getInstance().renderItemIntoGUI(mc.fontRenderer, mc.renderEngine, stack, px, py); - net.minecraft.client.renderer.RenderHelper.disableStandardItemLighting(); - - boolean unicode = mc.fontRenderer.getUnicodeFlag(); - mc.fontRenderer.setUnicodeFlag(true); - mc.fontRenderer.drawStringWithShadow("" + getPlayerCount(), px + 15, py + 4, 0xFFFFFF); - mc.fontRenderer.setUnicodeFlag(unicode); - GL11.glPopMatrix(); - } - - @Override - @SideOnly(Side.CLIENT) - public int getBossBarShaderProgram(boolean background) { - return background ? 0 : ShaderHelper.dopplegangerBar; - } - - @SideOnly(Side.CLIENT) - private ShaderCallback shaderCallback; - - @Override - @SideOnly(Side.CLIENT) - public ShaderCallback getBossBarShaderCallback(boolean background, int shader) { - if(shaderCallback == null) - shaderCallback = new ShaderCallback() { - - @Override - public void call(int shader) { - int grainIntensityUniform = ARBShaderObjects.glGetUniformLocationARB(shader, "grainIntensity"); - int hpFractUniform = ARBShaderObjects.glGetUniformLocationARB(shader, "hpFract"); - - float time = getInvulTime(); - float grainIntensity = time > 20 ? 1F : Math.max(isHardMode() ? 0.5F : 0F, time / 20F); - - ARBShaderObjects.glUniform1fARB(grainIntensityUniform, grainIntensity); - ARBShaderObjects.glUniform1fARB(hpFractUniform, getHealth() / getMaxHealth()); - } - - }; - - return background ? null : shaderCallback; - } - - public static class BeaconComponent extends MultiblockComponent { - - public BeaconComponent(ChunkCoordinates relPos) { - super(relPos, Blocks.iron_block, 0); - } - - @Override - public boolean matches(World world, int x, int y, int z) { - return world.getBlock(x, y, z).isBeaconBase(world, x, y, z, x - relPos.posX, y - relPos.posY, z - relPos.posZ); - }; - - } - - public static class BeaconBeamComponent extends MultiblockComponent { - - public BeaconBeamComponent(ChunkCoordinates relPos) { - super(relPos, Blocks.beacon, 0); - } - - @Override - public boolean matches(World world, int x, int y, int z) { - return world.getTileEntity(x, y, z) instanceof TileEntityBeacon; - } - } + public static final int SPAWN_TICKS = 160; + private static final float RANGE = 12F; + private static final float MAX_HP = 800F; + + public static final int MOB_SPAWN_START_TICKS = 20; + public static final int MOB_SPAWN_END_TICKS = 80; + public static final int MOB_SPAWN_BASE_TICKS = 800; + public static final int MOB_SPAWN_TICKS = MOB_SPAWN_BASE_TICKS + MOB_SPAWN_START_TICKS + MOB_SPAWN_END_TICKS; + public static final int MOB_SPAWN_WAVES = 10; + public static final int MOB_SPAWN_WAVE_TIME = MOB_SPAWN_BASE_TICKS / MOB_SPAWN_WAVES; + + private static final String TAG_INVUL_TIME = "invulTime"; + private static final String TAG_AGGRO = "aggro"; + private static final String TAG_SOURCE_X = "sourceX"; + private static final String TAG_SOURCE_Y = "sourceY"; + private static final String TAG_SOURCE_Z = "sourcesZ"; + private static final String TAG_MOB_SPAWN_TICKS = "mobSpawnTicks"; + private static final String TAG_HARD_MODE = "hardMode"; + private static final String TAG_PLAYER_COUNT = "playerCount"; + + private static final int[][] PYLON_LOCATIONS = new int[][] { + {4, 1, 4}, + {4, 1, -4}, + {-4, 1, 4}, + {-4, 1, -4} + }; + + private static final List CHEATY_BLOCKS = + Arrays.asList(new String[] {"OpenBlocks:beartrap", "ThaumicTinkerer:magnet"}); + + boolean spawnLandmines = false; + boolean spawnPixies = false; + boolean anyWithArmor = false; + + List playersWhoAttacked = new ArrayList(); + + private static boolean isPlayingMusic = false; + + public EntityDoppleganger(World par1World) { + super(par1World); + setSize(0.6F, 1.8F); + getNavigator().setCanSwim(true); + tasks.addTask(0, new EntityAISwimming(this)); + tasks.addTask(1, new EntityAIWatchClosest(this, EntityPlayer.class, Float.MAX_VALUE)); + isImmuneToFire = true; + experienceValue = 825; + } + + public static MultiblockSet makeMultiblockSet() { + Multiblock mb = new Multiblock(); + + for (int[] p : PYLON_LOCATIONS) mb.addComponent(p[0], p[1] + 1, p[2], ModBlocks.pylon, 2); + + for (int i = 0; i < 3; i++) + for (int j = 0; j < 3; j++) mb.addComponent(new BeaconComponent(new ChunkCoordinates(i - 1, 0, j - 1))); + + mb.addComponent(new BeaconBeamComponent(new ChunkCoordinates(0, 1, 0))); + mb.setRenderOffset(0, -1, 0); + + return mb.makeSet(); + } + + public static boolean spawn( + EntityPlayer player, ItemStack par1ItemStack, World par3World, int par4, int par5, int par6, boolean hard) { + if (par3World.getTileEntity(par4, par5, par6) instanceof TileEntityBeacon && isTruePlayer(player)) { + if (par3World.difficultySetting == EnumDifficulty.PEACEFUL) { + if (!par3World.isRemote) + player.addChatMessage(new ChatComponentTranslation("botaniamisc.peacefulNoob") + .setChatStyle(new ChatStyle().setColor(EnumChatFormatting.RED))); + return false; + } + + for (int[] coords : PYLON_LOCATIONS) { + int x = par4 + coords[0]; + int y = par5 + coords[1]; + int z = par6 + coords[2]; + + Block blockat = par3World.getBlock(x, y, z); + int meta = par3World.getBlockMetadata(x, y, z); + if (blockat != ModBlocks.pylon || meta != 2) { + if (!par3World.isRemote) + player.addChatMessage(new ChatComponentTranslation("botaniamisc.needsCatalysts") + .setChatStyle(new ChatStyle().setColor(EnumChatFormatting.RED))); + return false; + } + } + + if (!hasProperArena(par3World, par4, par5, par6)) { + for (int i = 0; i < 360; i += 8) { + float r = 1F; + float g = 0F; + float b = 1F; + float rad = i * (float) Math.PI / 180F; + double x = par4 + 0.5 - Math.cos(rad) * RANGE; + double y = par5 + 0.5; + double z = par6 + 0.5 - Math.sin(rad) * RANGE; + + Botania.proxy.sparkleFX(par3World, x, y, z, r, g, b, 5F, 120); + } + + if (!par3World.isRemote) + player.addChatMessage(new ChatComponentTranslation("botaniamisc.badArena") + .setChatStyle(new ChatStyle().setColor(EnumChatFormatting.RED))); + return false; + } + + par1ItemStack.stackSize--; + + if (par3World.isRemote) return true; + + EntityDoppleganger e = new EntityDoppleganger(par3World); + e.setPosition(par4 + 0.5, par5 + 3, par6 + 0.5); + e.setInvulTime(SPAWN_TICKS); + e.setHealth(1F); + e.setSource(par4, par5, par6); + e.setMobSpawnTicks(MOB_SPAWN_TICKS); + e.setHardMode(hard); + + List players = e.getPlayersAround(); + int playerCount = 0; + for (EntityPlayer p : players) if (isTruePlayer(p)) playerCount++; + + e.setPlayerCount(playerCount); + e.getAttributeMap() + .getAttributeInstance(SharedMonsterAttributes.maxHealth) + .setBaseValue(MAX_HP * playerCount); + + par3World.playSoundAtEntity(e, "mob.enderdragon.growl", 10F, 0.1F); + par3World.spawnEntityInWorld(e); + return true; + } + + return false; + } + + private static boolean hasProperArena(World world, int sx, int sy, int sz) { + int heightCheck = 3; + int heightMin = 2; + int range = (int) Math.ceil(RANGE); + for (int i = -range; i < range + 1; i++) + for (int j = -range; j < range + 1; j++) { + if (Math.abs(i) == 4 && Math.abs(j) == 4 + || vazkii.botania.common.core.helper.MathHelper.pointDistancePlane(i, j, 0, 0) > RANGE) + continue; // Ignore pylons and out of circle + + int x = sx + i; + int z = sz + j; + int air = 0; + + yCheck: + { + for (int k = heightCheck + heightMin + 1; k >= -heightCheck; k--) { + int y = sy + k; + boolean isAir = world.getBlock(x, y, z).getCollisionBoundingBoxFromPool(world, x, y, z) == null; + if (isAir) air++; + else { + if (k > heightCheck) continue; + else if (air > 2) break yCheck; + air = 0; + } + } + + return false; + } + } + + return true; + } + + @Override + protected boolean isAIEnabled() { + return true; + } + + @Override + protected void entityInit() { + super.entityInit(); + dataWatcher.addObject(20, 0); // Invul Time + dataWatcher.addObject(21, (byte) 0); // Aggro + dataWatcher.addObject(22, 0); // TP Delay + dataWatcher.addObject(23, 0); // Source X + dataWatcher.addObject(24, 0); // Source Y + dataWatcher.addObject(25, 0); // Source Z + dataWatcher.addObject(26, 0); // Ticks spawning mobs + dataWatcher.addObject(27, (byte) 0); // Hard Mode + dataWatcher.addObject(28, 0); // Player count + } + + public int getInvulTime() { + return dataWatcher.getWatchableObjectInt(20); + } + + public boolean isAggored() { + return dataWatcher.getWatchableObjectByte(21) == 1; + } + + public int getTPDelay() { + return dataWatcher.getWatchableObjectInt(22); + } + + public ChunkCoordinates getSource() { + int x = dataWatcher.getWatchableObjectInt(23); + int y = dataWatcher.getWatchableObjectInt(24); + int z = dataWatcher.getWatchableObjectInt(25); + return new ChunkCoordinates(x, y, z); + } + + public int getMobSpawnTicks() { + return dataWatcher.getWatchableObjectInt(26); + } + + public boolean isHardMode() { + return dataWatcher.getWatchableObjectByte(27) == 1; + } + + public int getPlayerCount() { + return dataWatcher.getWatchableObjectInt(28); + } + + public void setInvulTime(int time) { + dataWatcher.updateObject(20, time); + } + + public void setAggroed(boolean aggored) { + dataWatcher.updateObject(21, (byte) (aggored ? 1 : 0)); + } + + public void setTPDelay(int delay) { + dataWatcher.updateObject(22, delay); + } + + public void setSource(int x, int y, int z) { + dataWatcher.updateObject(23, x); + dataWatcher.updateObject(24, y); + dataWatcher.updateObject(25, z); + } + + public void setMobSpawnTicks(int ticks) { + dataWatcher.updateObject(26, ticks); + } + + public void setHardMode(boolean hardMode) { + dataWatcher.updateObject(27, (byte) (hardMode ? 1 : 0)); + } + + public void setPlayerCount(int count) { + dataWatcher.updateObject(28, count); + } + + @Override + public void writeEntityToNBT(NBTTagCompound par1nbtTagCompound) { + super.writeEntityToNBT(par1nbtTagCompound); + par1nbtTagCompound.setInteger(TAG_INVUL_TIME, getInvulTime()); + par1nbtTagCompound.setBoolean(TAG_AGGRO, isAggored()); + par1nbtTagCompound.setInteger(TAG_MOB_SPAWN_TICKS, getMobSpawnTicks()); + + ChunkCoordinates source = getSource(); + par1nbtTagCompound.setInteger(TAG_SOURCE_X, source.posX); + par1nbtTagCompound.setInteger(TAG_SOURCE_Y, source.posY); + par1nbtTagCompound.setInteger(TAG_SOURCE_Z, source.posZ); + + par1nbtTagCompound.setBoolean(TAG_HARD_MODE, isHardMode()); + par1nbtTagCompound.setInteger(TAG_PLAYER_COUNT, getPlayerCount()); + } + + @Override + public void readEntityFromNBT(NBTTagCompound par1nbtTagCompound) { + super.readEntityFromNBT(par1nbtTagCompound); + setInvulTime(par1nbtTagCompound.getInteger(TAG_INVUL_TIME)); + setAggroed(par1nbtTagCompound.getBoolean(TAG_AGGRO)); + setMobSpawnTicks(par1nbtTagCompound.getInteger(TAG_MOB_SPAWN_TICKS)); + + int x = par1nbtTagCompound.getInteger(TAG_SOURCE_X); + int y = par1nbtTagCompound.getInteger(TAG_SOURCE_Y); + int z = par1nbtTagCompound.getInteger(TAG_SOURCE_Z); + setSource(x, y, z); + + setHardMode(par1nbtTagCompound.getBoolean(TAG_HARD_MODE)); + if (par1nbtTagCompound.hasKey(TAG_PLAYER_COUNT)) + setPlayerCount(par1nbtTagCompound.getInteger(TAG_PLAYER_COUNT)); + else setPlayerCount(1); + } + + @Override + public boolean attackEntityFrom(DamageSource par1DamageSource, float par2) { + Entity e = par1DamageSource.getEntity(); + if ((par1DamageSource.damageType.equals("player") || e instanceof EntityPixie) + && e != null + && isTruePlayer(e) + && getInvulTime() == 0) { + EntityPlayer player = (EntityPlayer) e; + if (!playersWhoAttacked.contains(player.getCommandSenderName())) + playersWhoAttacked.add(player.getCommandSenderName()); + + float dmg = par2; + boolean crit = false; + if (e instanceof EntityPlayer) { + EntityPlayer p = (EntityPlayer) e; + crit = p.fallDistance > 0.0F + && !p.onGround + && !p.isOnLadder() + && !p.isInWater() + && !p.isPotionActive(Potion.blindness) + && p.ridingEntity == null; + } + + int cap = crit ? 60 : 40; + return super.attackEntityFrom(par1DamageSource, Math.min(cap, dmg) * (isHardMode() ? 0.6F : 1F)); + } + return false; + } + + private static final Pattern FAKE_PLAYER_PATTERN = Pattern.compile("^(?:\\[.*\\])|(?:ComputerCraft)$"); + + public static boolean isTruePlayer(Entity e) { + if (!(e instanceof EntityPlayer)) return false; + + EntityPlayer player = (EntityPlayer) e; + + String name = player.getCommandSenderName(); + return !(player instanceof FakePlayer + || FAKE_PLAYER_PATTERN.matcher(name).matches()); + } + + @Override + protected void damageEntity(DamageSource par1DamageSource, float par2) { + super.damageEntity(par1DamageSource, par2); + + Entity attacker = par1DamageSource.getEntity(); + if (attacker != null) { + Vector3 thisVector = Vector3.fromEntityCenter(this); + Vector3 playerVector = Vector3.fromEntityCenter(attacker); + Vector3 motionVector = + thisVector.copy().sub(playerVector).copy().normalize().multiply(0.75); + + if (getHealth() > 0) { + motionX = -motionVector.x; + motionY = 0.5; + motionZ = -motionVector.z; + setTPDelay(4); + spawnPixies = isAggored(); + } + + setAggroed(true); + } + } + + @Override + public void onDeath(DamageSource p_70645_1_) { + super.onDeath(p_70645_1_); + EntityLivingBase entitylivingbase = func_94060_bK(); + if (entitylivingbase instanceof EntityPlayer) { + ((EntityPlayer) entitylivingbase).addStat(ModAchievements.gaiaGuardianKill, 1); + if (!anyWithArmor) ((EntityPlayer) entitylivingbase).addStat(ModAchievements.gaiaGuardianNoArmor, 1); + } + + worldObj.playSoundAtEntity( + this, + "random.explode", + 20F, + (1F + (worldObj.rand.nextFloat() - worldObj.rand.nextFloat()) * 0.2F) * 0.7F); + worldObj.spawnParticle("hugeexplosion", posX, posY, posZ, 1D, 0D, 0D); + } + + @Override + protected void applyEntityAttributes() { + super.applyEntityAttributes(); + getEntityAttribute(SharedMonsterAttributes.movementSpeed).setBaseValue(0.4); + getEntityAttribute(SharedMonsterAttributes.maxHealth).setBaseValue(MAX_HP); + getEntityAttribute(SharedMonsterAttributes.knockbackResistance).setBaseValue(1.0); + } + + @Override + protected boolean canDespawn() { + return false; + } + + @Override + protected void dropFewItems(boolean par1, int par2) { + if (par1) { + for (int pl = 0; pl < playersWhoAttacked.size(); pl++) { + boolean hard = isHardMode(); + entityDropItem(new ItemStack(ModItems.manaResource, pl == 0 ? hard ? 16 : 8 : hard ? 10 : 6, 5), 1F); + boolean droppedRecord = false; + + if (hard) { + entityDropItem(new ItemStack(ModItems.ancientWill, 1, rand.nextInt(6)), 1F); + if (ConfigHandler.relicsEnabled) { + ItemStack dice = new ItemStack(ModItems.dice); + ItemRelic.bindToUsernameS(playersWhoAttacked.get(pl), dice); + entityDropItem(dice, 1F); + } + + if (Math.random() < 0.25) + entityDropItem(new ItemStack(ModItems.overgrowthSeed, rand.nextInt(3) + 1), 1F); + if (Math.random() < 0.5) { + boolean voidLotus = Math.random() < 0.3F; + entityDropItem( + new ItemStack( + ModItems.blackLotus, voidLotus ? 1 : rand.nextInt(3) + 1, voidLotus ? 1 : 0), + 1F); + } + if (Math.random() < 0.9) + entityDropItem(new ItemStack(ModItems.manaResource, 16 + rand.nextInt(12)), 1F); + if (Math.random() < 0.7) + entityDropItem(new ItemStack(ModItems.manaResource, 8 + rand.nextInt(6), 1), 1F); + if (Math.random() < 0.5) + entityDropItem(new ItemStack(ModItems.manaResource, 4 + rand.nextInt(3), 2), 1F); + + int runes = rand.nextInt(6) + 1; + for (int i = 0; i < runes; i++) + if (Math.random() < 0.3) + entityDropItem(new ItemStack(ModItems.rune, 2 + rand.nextInt(3), rand.nextInt(16)), 1F); + + if (Math.random() < 0.2) entityDropItem(new ItemStack(ModItems.pinkinator), 1F); + if (Math.random() < 0.3) { + int i = Item.getIdFromItem(Items.record_13); + int j = Item.getIdFromItem(Items.record_wait); + int k = i + rand.nextInt(j - i + 1); + entityDropItem(new ItemStack(Item.getItemById(k)), 1F); + droppedRecord = true; + } + } + + if (!droppedRecord && Math.random() < 0.2) + entityDropItem(new ItemStack(hard ? ModItems.recordGaia2 : ModItems.recordGaia1), 1F); + } + } + } + + @Override + public void setDead() { + ChunkCoordinates source = getSource(); + Botania.proxy.playRecordClientSided(worldObj, source.posX, source.posY, source.posZ, null); + isPlayingMusic = false; + super.setDead(); + } + + public List getPlayersAround() { + ChunkCoordinates source = getSource(); + float range = 15F; + List players = worldObj.getEntitiesWithinAABB( + EntityPlayer.class, + AxisAlignedBB.getBoundingBox( + source.posX + 0.5 - range, + source.posY + 0.5 - range, + source.posZ + 0.5 - range, + source.posX + 0.5 + range, + source.posY + 0.5 + range, + source.posZ + 0.5 + range)); + return players; + } + + @Override + public void onLivingUpdate() { + super.onLivingUpdate(); + + if (ridingEntity != null) { + if (ridingEntity.riddenByEntity != null) ridingEntity.riddenByEntity = null; + ridingEntity = null; + } + + boolean peaceful = worldObj.difficultySetting == EnumDifficulty.PEACEFUL; + if (!worldObj.isRemote && peaceful) setDead(); + + if (!worldObj.isRemote) { + int radius = 1; + int posXInt = MathHelper.floor_double(posX); + int posYInt = MathHelper.floor_double(posY); + int posZInt = MathHelper.floor_double(posZ); + for (int i = -radius; i < radius + 1; i++) + for (int j = -radius; j < radius + 1; j++) + for (int k = -radius; k < radius + 1; k++) { + int xp = posXInt + i; + int yp = posYInt + j; + int zp = posZInt + k; + if (isCheatyBlock(worldObj, xp, yp, zp)) { + Block block = worldObj.getBlock(xp, yp, zp); + List items = block.getDrops(worldObj, xp, yp, zp, 0, 0); + for (ItemStack stack : items) { + if (ConfigHandler.blockBreakParticles) + worldObj.playAuxSFX( + 2001, + xp, + yp, + zp, + Block.getIdFromBlock(block) + + (worldObj.getBlockMetadata(xp, yp, zp) << 12)); + worldObj.spawnEntityInWorld( + new EntityItem(worldObj, xp + 0.5, yp + 0.5, zp + 0.5, stack)); + } + worldObj.setBlockToAir(xp, yp, zp); + } + } + } + + ChunkCoordinates source = getSource(); + boolean hard = isHardMode(); + float range = RANGE + 3F; + List players = getPlayersAround(); + int playerCount = getPlayerCount(); + + if (worldObj.isRemote && !isPlayingMusic && !isDead && !players.isEmpty()) { + Botania.proxy.playRecordClientSided(worldObj, source.posX, source.posY, source.posZ, (ItemRecord) + (hard ? ModItems.recordGaia2 : ModItems.recordGaia1)); + isPlayingMusic = true; + } + + range = RANGE; + for (int i = 0; i < 360; i += 8) { + float r = 0.6F; + float g = 0F; + float b = 0.2F; + float m = 0.15F; + float mv = 0.35F; + + float rad = i * (float) Math.PI / 180F; + double x = source.posX + 0.5 - Math.cos(rad) * range; + double y = source.posY + 0.5; + double z = source.posZ + 0.5 - Math.sin(rad) * range; + + Botania.proxy.wispFX( + worldObj, + x, + y, + z, + r, + g, + b, + 0.5F, + (float) (Math.random() - 0.5F) * m, + (float) (Math.random() - 0.5F) * mv, + (float) (Math.random() - 0.5F) * m); + } + + if (players.isEmpty() && !worldObj.playerEntities.isEmpty()) setDead(); + else { + for (EntityPlayer player : players) { + if (player.inventory.armorInventory[0] != null + || player.inventory.armorInventory[1] != null + || player.inventory.armorInventory[2] != null + || player.inventory.armorInventory[3] != null) anyWithArmor = true; + + List remove = new ArrayList(); + Collection active = player.getActivePotionEffects(); + for (PotionEffect effect : active) + if (effect.getDuration() < 200 + && effect.getIsAmbient() + && !ReflectionHelper.getPrivateValue( + Potion.class, + Potion.potionTypes[effect.getPotionID()], + LibObfuscation.IS_BAD_EFFECT)) remove.add(effect); + + active.removeAll(remove); + + player.capabilities.isFlying = player.capabilities.isFlying && player.capabilities.isCreativeMode; + + if (vazkii.botania.common.core.helper.MathHelper.pointDistanceSpace( + player.posX, + player.posY, + player.posZ, + source.posX + 0.5, + source.posY + 0.5, + source.posZ + 0.5) + >= range) { + Vector3 sourceVector = new Vector3(source.posX + 0.5, source.posY + 0.5, source.posZ + 0.5); + Vector3 playerVector = Vector3.fromEntityCenter(player); + Vector3 motion = + sourceVector.copy().sub(playerVector).copy().normalize(); + + player.motionX = motion.x; + player.motionY = 0.2; + player.motionZ = motion.z; + } + } + } + + if (isDead) return; + + int invul = getInvulTime(); + int mobTicks = getMobSpawnTicks(); + boolean spawnMissiles = hard && ticksExisted % 15 < 4; + + if (invul > 10) { + Vector3 pos = Vector3.fromEntityCenter(this).subtract(new Vector3(0, 0.2, 0)); + for (int i = 0; i < PYLON_LOCATIONS.length; i++) { + int[] arr = PYLON_LOCATIONS[i]; + int x = arr[0]; + int y = arr[1]; + int z = arr[2]; + + Vector3 pylonPos = new Vector3(source.posX + x, source.posY + y, source.posZ + z); + double worldTime = ticksExisted; + worldTime /= 5; + + float rad = 0.75F + (float) Math.random() * 0.05F; + double xp = pylonPos.x + 0.5 + Math.cos(worldTime) * rad; + double zp = pylonPos.z + 0.5 + Math.sin(worldTime) * rad; + + Vector3 partPos = new Vector3(xp, pylonPos.y, zp); + Vector3 mot = pos.copy().sub(partPos).multiply(0.04); + + float r = 0.7F + (float) Math.random() * 0.3F; + float g = (float) Math.random() * 0.3F; + float b = 0.7F + (float) Math.random() * 0.3F; + + Botania.proxy.wispFX( + worldObj, + partPos.x, + partPos.y, + partPos.z, + r, + g, + b, + 0.25F + (float) Math.random() * 0.1F, + -0.075F - (float) Math.random() * 0.015F); + Botania.proxy.wispFX( + worldObj, partPos.x, partPos.y, partPos.z, r, g, b, 0.4F, (float) mot.x, (float) mot.y, (float) + mot.z); + } + } + + if (invul > 0 && mobTicks == MOB_SPAWN_TICKS) { + if (invul < SPAWN_TICKS) { + if (invul > SPAWN_TICKS / 2 && worldObj.rand.nextInt(SPAWN_TICKS - invul + 1) == 0) + for (int i = 0; i < 2; i++) spawnExplosionParticle(); + } + + if (!worldObj.isRemote) { + setHealth(getHealth() + (getMaxHealth() - 1F) / SPAWN_TICKS); + setInvulTime(invul - 1); + } + motionY = 0; + } else { + if (isAggored()) { + boolean dying = getHealth() / getMaxHealth() < 0.2; + if (dying && mobTicks > 0) { + motionX = 0; + motionY = 0; + motionZ = 0; + + int reverseTicks = MOB_SPAWN_TICKS - mobTicks; + if (reverseTicks < MOB_SPAWN_START_TICKS) { + motionY = 0.2; + setInvulTime(invul + 1); + } + + if (reverseTicks > MOB_SPAWN_START_TICKS * 2 + && mobTicks > MOB_SPAWN_END_TICKS + && mobTicks % MOB_SPAWN_WAVE_TIME == 0 + && !worldObj.isRemote) { + for (int pl = 0; pl < playerCount; pl++) + for (int i = 0; i < 3 + worldObj.rand.nextInt(2); i++) { + EntityLiving entity = null; + switch (worldObj.rand.nextInt(2)) { + case 0: { + entity = new EntityZombie(worldObj); + if (worldObj.rand.nextInt(hard ? 3 : 12) == 0) + entity = new EntityWitch(worldObj); + + break; + } + case 1: { + entity = new EntitySkeleton(worldObj); + ((EntitySkeleton) entity).setCurrentItemOrArmor(0, new ItemStack(Items.bow)); + if (worldObj.rand.nextInt(8) == 0) { + ((EntitySkeleton) entity).setSkeletonType(1); + ((EntitySkeleton) entity) + .setCurrentItemOrArmor( + 0, + new ItemStack( + hard + ? ModItems.elementiumSword + : Items.stone_sword)); + } + break; + } + case 3: { + if (!players.isEmpty()) + for (int j = 0; j < 1 + worldObj.rand.nextInt(hard ? 8 : 5); j++) { + EntityPixie pixie = new EntityPixie(worldObj); + pixie.setProps(players.get(rand.nextInt(players.size())), this, 1, 8); + pixie.setPosition(posX + width / 2, posY + 2, posZ + width / 2); + worldObj.spawnEntityInWorld(pixie); + } + } + } + + if (entity != null) { + range = 6F; + entity.setPosition( + posX + 0.5 + Math.random() * range - range / 2, + posY - 1, + posZ + 0.5 + Math.random() * range - range / 2); + worldObj.spawnEntityInWorld(entity); + } + } + + if (hard && ticksExisted % 3 < 2) { + for (int i = 0; i < playerCount; i++) spawnMissile(); + spawnMissiles = false; + } + } + + setMobSpawnTicks(mobTicks - 1); + setTPDelay(10); + } else if (getTPDelay() > 0 && !worldObj.isRemote) { + if (invul > 0) setInvulTime(invul - 1); + + setTPDelay(getTPDelay() - 1); + if (getTPDelay() == 0 && getHealth() > 0) { + int tries = 0; + while (!teleportRandomly() && tries < 50) tries++; + if (tries >= 50) teleportTo(source.posX + 0.5, source.posY + 1.6, source.posZ + 0.5); + + if (spawnLandmines) { + int count = dying && hard ? 7 : 6; + for (int i = 0; i < count; i++) { + int x = source.posX - 10 + rand.nextInt(20); + int z = source.posZ - 10 + rand.nextInt(20); + int y = worldObj.getTopSolidOrLiquidBlock(x, z); + + EntityMagicLandmine landmine = new EntityMagicLandmine(worldObj); + landmine.setPosition(x + 0.5, y, z + 0.5); + landmine.summoner = this; + worldObj.spawnEntityInWorld(landmine); + } + } + + if (!players.isEmpty()) + for (int pl = 0; pl < playerCount; pl++) + for (int i = 0; i < (spawnPixies ? worldObj.rand.nextInt(hard ? 6 : 3) : 1); i++) { + EntityPixie pixie = new EntityPixie(worldObj); + pixie.setProps(players.get(rand.nextInt(players.size())), this, 1, 8); + pixie.setPosition(posX + width / 2, posY + 2, posZ + width / 2); + worldObj.spawnEntityInWorld(pixie); + } + + setTPDelay(hard ? (dying ? 35 : 45) : (dying ? 40 : 60)); + spawnLandmines = true; + spawnPixies = false; + } + } + + if (spawnMissiles) spawnMissile(); + } else { + range = 3F; + players = worldObj.getEntitiesWithinAABB( + EntityPlayer.class, + AxisAlignedBB.getBoundingBox( + posX - range, posY - range, posZ - range, posX + range, posY + range, posZ + range)); + if (!players.isEmpty()) damageEntity(DamageSource.causePlayerDamage(players.get(0)), 0); + } + } + } + + void spawnMissile() { + if (!worldObj.isRemote) { + EntityMagicMissile missile = new EntityMagicMissile(this, true); + missile.setPosition( + posX + (Math.random() - 0.5 * 0.1), + posY + 2.4 + (Math.random() - 0.5 * 0.1), + posZ + (Math.random() - 0.5 * 0.1)); + if (missile.getTarget()) { + worldObj.playSoundAtEntity(this, "botania:missile", 0.6F, 0.8F + (float) Math.random() * 0.2F); + worldObj.spawnEntityInWorld(missile); + } + } + } + + public static boolean isCheatyBlock(World world, int x, int y, int z) { + Block block = world.getBlock(x, y, z); + String name = Block.blockRegistry.getNameForObject(block); + return CHEATY_BLOCKS.contains(name); + } + + // EntityEnderman code below ============================================================================ + + protected boolean teleportRandomly() { + double d0 = posX + (rand.nextDouble() - 0.5D) * 64.0D; + double d1 = posY + (rand.nextInt(64) - 32); + double d2 = posZ + (rand.nextDouble() - 0.5D) * 64.0D; + return teleportTo(d0, d1, d2); + } + + protected boolean teleportTo(double par1, double par3, double par5) { + double d3 = posX; + double d4 = posY; + double d5 = posZ; + posX = par1; + posY = par3; + posZ = par5; + boolean flag = false; + int i = MathHelper.floor_double(posX); + int j = MathHelper.floor_double(posY); + int k = MathHelper.floor_double(posZ); + + if (worldObj.blockExists(i, j, k)) { + boolean flag1 = false; + + while (!flag1 && j > 0) { + Block block = worldObj.getBlock(i, j - 1, k); + + if (block.getMaterial().blocksMovement()) flag1 = true; + else { + --posY; + --j; + } + } + + if (flag1) { + setPosition(posX, posY, posZ); + + if (worldObj.getCollidingBoundingBoxes(this, boundingBox).isEmpty() + && !worldObj.isAnyLiquid(boundingBox)) flag = true; + + // Prevent out of bounds teleporting + ChunkCoordinates source = getSource(); + if (vazkii.botania.common.core.helper.MathHelper.pointDistanceSpace( + posX, posY, posZ, source.posX, source.posY, source.posZ) + > 12) flag = false; + } + } + + if (!flag) { + setPosition(d3, d4, d5); + return false; + } else { + short short1 = 128; + + for (int l = 0; l < short1; ++l) { + double d6 = l / (short1 - 1.0D); + float f = (rand.nextFloat() - 0.5F) * 0.2F; + float f1 = (rand.nextFloat() - 0.5F) * 0.2F; + float f2 = (rand.nextFloat() - 0.5F) * 0.2F; + double d7 = d3 + (posX - d3) * d6 + (rand.nextDouble() - 0.5D) * width * 2.0D; + double d8 = d4 + (posY - d4) * d6 + rand.nextDouble() * height; + double d9 = d5 + (posZ - d5) * d6 + (rand.nextDouble() - 0.5D) * width * 2.0D; + worldObj.spawnParticle("portal", d7, d8, d9, f, f1, f2); + } + + worldObj.playSoundEffect(d3, d4, d5, "mob.endermen.portal", 1.0F, 1.0F); + playSound("mob.endermen.portal", 1.0F, 1.0F); + return true; + } + } + + @Override + @SideOnly(Side.CLIENT) + public ResourceLocation getBossBarTexture() { + return BossBarHandler.defaultBossBar; + } + + @SideOnly(Side.CLIENT) + private static Rectangle barRect; + + @SideOnly(Side.CLIENT) + private static Rectangle hpBarRect; + + @Override + @SideOnly(Side.CLIENT) + public Rectangle getBossBarTextureRect() { + if (barRect == null) barRect = new Rectangle(0, 0, 185, 15); + return barRect; + } + + @Override + @SideOnly(Side.CLIENT) + public Rectangle getBossBarHPTextureRect() { + if (hpBarRect == null) hpBarRect = new Rectangle(0, barRect.y + barRect.height, 181, 7); + return hpBarRect; + } + + @Override + @SideOnly(Side.CLIENT) + public void bossBarRenderCallback(ScaledResolution res, int x, int y) { + GL11.glPushMatrix(); + int px = x + 160; + int py = y + 12; + + Minecraft mc = Minecraft.getMinecraft(); + ItemStack stack = new ItemStack(Items.skull, 1, 3); + mc.renderEngine.bindTexture(TextureMap.locationItemsTexture); + net.minecraft.client.renderer.RenderHelper.enableGUIStandardItemLighting(); + GL11.glEnable(GL12.GL_RESCALE_NORMAL); + RenderItem.getInstance().renderItemIntoGUI(mc.fontRenderer, mc.renderEngine, stack, px, py); + net.minecraft.client.renderer.RenderHelper.disableStandardItemLighting(); + + boolean unicode = mc.fontRenderer.getUnicodeFlag(); + mc.fontRenderer.setUnicodeFlag(true); + mc.fontRenderer.drawStringWithShadow("" + getPlayerCount(), px + 15, py + 4, 0xFFFFFF); + mc.fontRenderer.setUnicodeFlag(unicode); + GL11.glPopMatrix(); + } + + @Override + @SideOnly(Side.CLIENT) + public int getBossBarShaderProgram(boolean background) { + return background ? 0 : ShaderHelper.dopplegangerBar; + } + + @SideOnly(Side.CLIENT) + private ShaderCallback shaderCallback; + + @Override + @SideOnly(Side.CLIENT) + public ShaderCallback getBossBarShaderCallback(boolean background, int shader) { + if (shaderCallback == null) + shaderCallback = new ShaderCallback() { + + @Override + public void call(int shader) { + int grainIntensityUniform = ARBShaderObjects.glGetUniformLocationARB(shader, "grainIntensity"); + int hpFractUniform = ARBShaderObjects.glGetUniformLocationARB(shader, "hpFract"); + + float time = getInvulTime(); + float grainIntensity = time > 20 ? 1F : Math.max(isHardMode() ? 0.5F : 0F, time / 20F); + + ARBShaderObjects.glUniform1fARB(grainIntensityUniform, grainIntensity); + ARBShaderObjects.glUniform1fARB(hpFractUniform, getHealth() / getMaxHealth()); + } + }; + + return background ? null : shaderCallback; + } + + public static class BeaconComponent extends MultiblockComponent { + + public BeaconComponent(ChunkCoordinates relPos) { + super(relPos, Blocks.iron_block, 0); + } + + @Override + public boolean matches(World world, int x, int y, int z) { + return world.getBlock(x, y, z) + .isBeaconBase(world, x, y, z, x - relPos.posX, y - relPos.posY, z - relPos.posZ); + } + ; + } + + public static class BeaconBeamComponent extends MultiblockComponent { + + public BeaconBeamComponent(ChunkCoordinates relPos) { + super(relPos, Blocks.beacon, 0); + } + + @Override + public boolean matches(World world, int x, int y, int z) { + return world.getTileEntity(x, y, z) instanceof TileEntityBeacon; + } + } } diff --git a/src/main/java/vazkii/botania/common/entity/EntityEnderAirBottle.java b/src/main/java/vazkii/botania/common/entity/EntityEnderAirBottle.java index 0a470bc235..73d37f66bf 100644 --- a/src/main/java/vazkii/botania/common/entity/EntityEnderAirBottle.java +++ b/src/main/java/vazkii/botania/common/entity/EntityEnderAirBottle.java @@ -2,17 +2,16 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Feb 16, 2015, 5:15:31 PM (GMT)] */ package vazkii.botania.common.entity; import java.util.ArrayList; import java.util.List; - import net.minecraft.block.Block; import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.projectile.EntityThrowable; @@ -23,54 +22,54 @@ public class EntityEnderAirBottle extends EntityThrowable { - public EntityEnderAirBottle(World world) { - super(world); - } - - public EntityEnderAirBottle(World world, EntityLivingBase entity) { - super(world, entity); - } + public EntityEnderAirBottle(World world) { + super(world); + } - @Override - protected void onImpact(MovingObjectPosition pos) { - if(pos.entityHit == null && !worldObj.isRemote) { - List coordsList = getCoordsToPut(pos.blockX, pos.blockY, pos.blockZ); - worldObj.playAuxSFX(2002, (int)Math.round(posX), (int)Math.round(posY), (int)Math.round(posZ), 8); + public EntityEnderAirBottle(World world, EntityLivingBase entity) { + super(world, entity); + } - for(ChunkCoordinates coords : coordsList) { - worldObj.setBlock(coords.posX, coords.posY, coords.posZ, Blocks.end_stone); - if(Math.random() < 0.1) - worldObj.playAuxSFX(2001, coords.posX, coords.posY, coords.posZ, Block.getIdFromBlock(Blocks.end_stone)); - } - setDead(); - } - } + @Override + protected void onImpact(MovingObjectPosition pos) { + if (pos.entityHit == null && !worldObj.isRemote) { + List coordsList = getCoordsToPut(pos.blockX, pos.blockY, pos.blockZ); + worldObj.playAuxSFX(2002, (int) Math.round(posX), (int) Math.round(posY), (int) Math.round(posZ), 8); - public List getCoordsToPut(int xCoord, int yCoord, int zCoord) { - List possibleCoords = new ArrayList(); - List selectedCoords = new ArrayList(); - int range = 4; - int rangeY = 4; + for (ChunkCoordinates coords : coordsList) { + worldObj.setBlock(coords.posX, coords.posY, coords.posZ, Blocks.end_stone); + if (Math.random() < 0.1) + worldObj.playAuxSFX( + 2001, coords.posX, coords.posY, coords.posZ, Block.getIdFromBlock(Blocks.end_stone)); + } + setDead(); + } + } - for(int i = -range; i < range + 1; i++) - for(int j = -rangeY; j < rangeY; j++) - for(int k = -range; k < range + 1; k++) { - int x = xCoord + i; - int y = yCoord + j; - int z = zCoord + k; - Block block = worldObj.getBlock(x, y, z); - if(block != null && block.isReplaceableOreGen(worldObj, x, y, z, Blocks.stone)) - possibleCoords.add(new ChunkCoordinates(x, y, z)); - } + public List getCoordsToPut(int xCoord, int yCoord, int zCoord) { + List possibleCoords = new ArrayList(); + List selectedCoords = new ArrayList(); + int range = 4; + int rangeY = 4; - int count = 64; - while(!possibleCoords.isEmpty() && count > 0) { - ChunkCoordinates coords = possibleCoords.get(worldObj.rand.nextInt(possibleCoords.size())); - possibleCoords.remove(coords); - selectedCoords.add(coords); - count--; - } - return selectedCoords; - } + for (int i = -range; i < range + 1; i++) + for (int j = -rangeY; j < rangeY; j++) + for (int k = -range; k < range + 1; k++) { + int x = xCoord + i; + int y = yCoord + j; + int z = zCoord + k; + Block block = worldObj.getBlock(x, y, z); + if (block != null && block.isReplaceableOreGen(worldObj, x, y, z, Blocks.stone)) + possibleCoords.add(new ChunkCoordinates(x, y, z)); + } + int count = 64; + while (!possibleCoords.isEmpty() && count > 0) { + ChunkCoordinates coords = possibleCoords.get(worldObj.rand.nextInt(possibleCoords.size())); + possibleCoords.remove(coords); + selectedCoords.add(coords); + count--; + } + return selectedCoords; + } } diff --git a/src/main/java/vazkii/botania/common/entity/EntityFallingStar.java b/src/main/java/vazkii/botania/common/entity/EntityFallingStar.java index 82d1f4c0b5..da48cdd5ca 100644 --- a/src/main/java/vazkii/botania/common/entity/EntityFallingStar.java +++ b/src/main/java/vazkii/botania/common/entity/EntityFallingStar.java @@ -2,16 +2,15 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Aug 17, 2015, 4:19:52 PM (GMT)] */ package vazkii.botania.common.entity; import java.util.List; - import net.minecraft.block.Block; import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.player.EntityPlayer; @@ -24,62 +23,66 @@ public class EntityFallingStar extends EntityThrowableCopy { - public EntityFallingStar(World world) { - super(world); - setSize(0F, 0F); - } - - public EntityFallingStar(World world, EntityLivingBase e) { - super(world, e); - setSize(0F, 0F); - } + public EntityFallingStar(World world) { + super(world); + setSize(0F, 0F); + } - @Override - public void onUpdate() { - super.onUpdate(); + public EntityFallingStar(World world, EntityLivingBase e) { + super(world, e); + setSize(0F, 0F); + } - float dist = 1.5F; - for(int i = 0; i < 10; i++) { - float xs = (float) (Math.random() - 0.5) * dist; - float ys = (float) (Math.random() - 0.5) * dist; - float zs = (float) (Math.random() - 0.5) * dist; - Botania.proxy.sparkleFX(worldObj, posX + xs, posY + ys, posZ + zs, 1F, 0.4F, 1F, 2F, 6); - } + @Override + public void onUpdate() { + super.onUpdate(); - EntityLivingBase thrower = getThrower(); - if(!worldObj.isRemote && thrower != null) { - AxisAlignedBB axis = AxisAlignedBB.getBoundingBox(posX, posY, posZ, lastTickPosX, lastTickPosY, lastTickPosZ).expand(2, 2, 2); - List entities = worldObj.getEntitiesWithinAABB(EntityLivingBase.class, axis); - for(EntityLivingBase living : entities) { - if(living == thrower) - continue; + float dist = 1.5F; + for (int i = 0; i < 10; i++) { + float xs = (float) (Math.random() - 0.5) * dist; + float ys = (float) (Math.random() - 0.5) * dist; + float zs = (float) (Math.random() - 0.5) * dist; + Botania.proxy.sparkleFX(worldObj, posX + xs, posY + ys, posZ + zs, 1F, 0.4F, 1F, 2F, 6); + } - if(living.hurtTime == 0) { - onImpact(new MovingObjectPosition(living)); - return; - } - } - } + EntityLivingBase thrower = getThrower(); + if (!worldObj.isRemote && thrower != null) { + AxisAlignedBB axis = AxisAlignedBB.getBoundingBox( + posX, posY, posZ, lastTickPosX, lastTickPosY, lastTickPosZ) + .expand(2, 2, 2); + List entities = worldObj.getEntitiesWithinAABB(EntityLivingBase.class, axis); + for (EntityLivingBase living : entities) { + if (living == thrower) continue; - if(ticksExisted > 200) - setDead(); - } + if (living.hurtTime == 0) { + onImpact(new MovingObjectPosition(living)); + return; + } + } + } - @Override - protected void onImpact(MovingObjectPosition pos) { - EntityLivingBase thrower = getThrower(); - if(pos.entityHit != null && thrower != null && pos.entityHit != thrower && !pos.entityHit.isDead) { - if(thrower instanceof EntityPlayer) - pos.entityHit.attackEntityFrom(DamageSource.causePlayerDamage((EntityPlayer) thrower), 10); - else pos.entityHit.attackEntityFrom(DamageSource.generic, 10); - } + if (ticksExisted > 200) setDead(); + } - Block block = worldObj.getBlock(pos.blockX, pos.blockY, pos.blockZ); - if(ConfigHandler.blockBreakParticles && !block.isAir(worldObj, pos.blockX, pos.blockY, pos.blockZ)) - worldObj.playAuxSFX(2001, pos.blockX, pos.blockY, pos.blockZ, Block.getIdFromBlock(block) + (worldObj.getBlockMetadata(pos.blockX, pos.blockY, pos.blockZ) << 12)); + @Override + protected void onImpact(MovingObjectPosition pos) { + EntityLivingBase thrower = getThrower(); + if (pos.entityHit != null && thrower != null && pos.entityHit != thrower && !pos.entityHit.isDead) { + if (thrower instanceof EntityPlayer) + pos.entityHit.attackEntityFrom(DamageSource.causePlayerDamage((EntityPlayer) thrower), 10); + else pos.entityHit.attackEntityFrom(DamageSource.generic, 10); + } - setDead(); - } + Block block = worldObj.getBlock(pos.blockX, pos.blockY, pos.blockZ); + if (ConfigHandler.blockBreakParticles && !block.isAir(worldObj, pos.blockX, pos.blockY, pos.blockZ)) + worldObj.playAuxSFX( + 2001, + pos.blockX, + pos.blockY, + pos.blockZ, + Block.getIdFromBlock(block) + + (worldObj.getBlockMetadata(pos.blockX, pos.blockY, pos.blockZ) << 12)); + setDead(); + } } - diff --git a/src/main/java/vazkii/botania/common/entity/EntityFlameRing.java b/src/main/java/vazkii/botania/common/entity/EntityFlameRing.java index b77f34f00a..e5350cc306 100644 --- a/src/main/java/vazkii/botania/common/entity/EntityFlameRing.java +++ b/src/main/java/vazkii/botania/common/entity/EntityFlameRing.java @@ -2,17 +2,15 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jun 26, 2014, 12:31:10 AM (GMT)] */ package vazkii.botania.common.entity; - import java.util.List; - import net.minecraft.entity.Entity; import net.minecraft.entity.EntityLivingBase; import net.minecraft.nbt.NBTTagCompound; @@ -22,86 +20,100 @@ import vazkii.botania.common.Botania; import vazkii.botania.common.core.helper.MathHelper; - public class EntityFlameRing extends Entity { - public EntityFlameRing(World world) { - super(world); - } - - @Override - protected void entityInit() { - setSize(0F, 0F); - } - - @Override - public void onEntityUpdate() { - super.onEntityUpdate(); - - float radius = 5F; - float renderRadius = (float) (radius - Math.random()); - - for(int i = 0; i < Math.min(90, ticksExisted); i++) { - float a = i; - if(a % 2 == 0) - a = 45 + a; - - if(worldObj.rand.nextInt(ticksExisted < 90 ? 8 : 20) == 0) { - float rad = (float) (a * 4 * Math.PI / 180F); - double x = Math.cos(rad) * renderRadius; - double z = Math.sin(rad) * renderRadius; - - Botania.proxy.wispFX(worldObj, posX + x, posY - 0.2, posZ + z, 1F, (float) Math.random() * 0.25F, (float) Math.random() * 0.25F, 0.65F + (float) Math.random() * 0.45F, (float) (Math.random() - 0.5F) * 0.15F, 0.055F + (float) Math.random() * 0.025F, (float) (Math.random() - 0.5F) * 0.15F); - - float gs = (float) Math.random() * 0.15F; - float smokeRadius = (float) (renderRadius - Math.random() * renderRadius * 0.9); - x = Math.cos(rad) * smokeRadius; - z = Math.sin(rad) * smokeRadius; - Botania.proxy.wispFX(worldObj, posX + x, posY - 0.2, posZ + z, gs, gs, gs, 0.65F + (float) Math.random() * 0.45F, -0.155F - (float) Math.random() * 0.025F); - } - } - - if(worldObj.rand.nextInt(20) == 0) - worldObj.playSoundAtEntity(this, "fire.fire", 1F, 1F); - - if(worldObj.isRemote) - return; - - if(ticksExisted >= 300) { - setDead(); - return; - } - - if(ticksExisted > 45) { - AxisAlignedBB boundingBox = AxisAlignedBB.getBoundingBox(posX, posY, posZ, posX, posY, posZ).expand(radius, radius, radius); - List entities = worldObj.getEntitiesWithinAABB(EntityLivingBase.class, boundingBox); - - if(entities.isEmpty()) - return; - - for(EntityLivingBase entity : entities) { - if(entity == null || MathHelper.pointDistancePlane(posX, posY, entity.posX, entity.posY) > radius) - continue; - - entity.setFire(4); - } - } - } - - @Override - public boolean attackEntityFrom(DamageSource par1DamageSource, float par2) { - return false; - } - - - @Override - protected void readEntityFromNBT(NBTTagCompound var1) { - // NO-OP - } - - - @Override - protected void writeEntityToNBT(NBTTagCompound var1) { - // NO-OP - } -} \ No newline at end of file + public EntityFlameRing(World world) { + super(world); + } + + @Override + protected void entityInit() { + setSize(0F, 0F); + } + + @Override + public void onEntityUpdate() { + super.onEntityUpdate(); + + float radius = 5F; + float renderRadius = (float) (radius - Math.random()); + + for (int i = 0; i < Math.min(90, ticksExisted); i++) { + float a = i; + if (a % 2 == 0) a = 45 + a; + + if (worldObj.rand.nextInt(ticksExisted < 90 ? 8 : 20) == 0) { + float rad = (float) (a * 4 * Math.PI / 180F); + double x = Math.cos(rad) * renderRadius; + double z = Math.sin(rad) * renderRadius; + + Botania.proxy.wispFX( + worldObj, + posX + x, + posY - 0.2, + posZ + z, + 1F, + (float) Math.random() * 0.25F, + (float) Math.random() * 0.25F, + 0.65F + (float) Math.random() * 0.45F, + (float) (Math.random() - 0.5F) * 0.15F, + 0.055F + (float) Math.random() * 0.025F, + (float) (Math.random() - 0.5F) * 0.15F); + + float gs = (float) Math.random() * 0.15F; + float smokeRadius = (float) (renderRadius - Math.random() * renderRadius * 0.9); + x = Math.cos(rad) * smokeRadius; + z = Math.sin(rad) * smokeRadius; + Botania.proxy.wispFX( + worldObj, + posX + x, + posY - 0.2, + posZ + z, + gs, + gs, + gs, + 0.65F + (float) Math.random() * 0.45F, + -0.155F - (float) Math.random() * 0.025F); + } + } + + if (worldObj.rand.nextInt(20) == 0) worldObj.playSoundAtEntity(this, "fire.fire", 1F, 1F); + + if (worldObj.isRemote) return; + + if (ticksExisted >= 300) { + setDead(); + return; + } + + if (ticksExisted > 45) { + AxisAlignedBB boundingBox = AxisAlignedBB.getBoundingBox(posX, posY, posZ, posX, posY, posZ) + .expand(radius, radius, radius); + List entities = worldObj.getEntitiesWithinAABB(EntityLivingBase.class, boundingBox); + + if (entities.isEmpty()) return; + + for (EntityLivingBase entity : entities) { + if (entity == null || MathHelper.pointDistancePlane(posX, posY, entity.posX, entity.posY) > radius) + continue; + + entity.setFire(4); + } + } + } + + @Override + public boolean attackEntityFrom(DamageSource par1DamageSource, float par2) { + return false; + } + + @Override + protected void readEntityFromNBT(NBTTagCompound var1) { + // NO-OP + } + + @Override + protected void writeEntityToNBT(NBTTagCompound var1) { + // NO-OP + } +} diff --git a/src/main/java/vazkii/botania/common/entity/EntityFlyingCreature.java b/src/main/java/vazkii/botania/common/entity/EntityFlyingCreature.java index b9c27de8c4..d20d9d9965 100644 --- a/src/main/java/vazkii/botania/common/entity/EntityFlyingCreature.java +++ b/src/main/java/vazkii/botania/common/entity/EntityFlyingCreature.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [? (GMT)] */ package vazkii.botania.common.entity; @@ -17,73 +17,78 @@ public class EntityFlyingCreature extends EntityAmbientCreature { - public EntityFlyingCreature(World par1World) { - super(par1World); - } + public EntityFlyingCreature(World par1World) { + super(par1World); + } - @Override - protected void fall(float par1) { - // NO-OP - } + @Override + protected void fall(float par1) { + // NO-OP + } - @Override - protected void updateFallState(double par1, boolean par3) { - // NO-OP - } + @Override + protected void updateFallState(double par1, boolean par3) { + // NO-OP + } - @Override - public void moveEntityWithHeading(float par1, float par2) { - if(isInWater()) { - moveFlying(par1, par2, 0.02F); - moveEntity(motionX, motionY, motionZ); - motionX *= 0.800000011920929D; - motionY *= 0.800000011920929D; - motionZ *= 0.800000011920929D; - } else if(handleLavaMovement()) { - moveFlying(par1, par2, 0.02F); - moveEntity(motionX, motionY, motionZ); - motionX *= 0.5D; - motionY *= 0.5D; - motionZ *= 0.5D; - } else { - float f2 = 0.91F; + @Override + public void moveEntityWithHeading(float par1, float par2) { + if (isInWater()) { + moveFlying(par1, par2, 0.02F); + moveEntity(motionX, motionY, motionZ); + motionX *= 0.800000011920929D; + motionY *= 0.800000011920929D; + motionZ *= 0.800000011920929D; + } else if (handleLavaMovement()) { + moveFlying(par1, par2, 0.02F); + moveEntity(motionX, motionY, motionZ); + motionX *= 0.5D; + motionY *= 0.5D; + motionZ *= 0.5D; + } else { + float f2 = 0.91F; - if (onGround) { - f2 = 0.54600006F; - Block block = worldObj.getBlock(MathHelper.floor_double(posX), MathHelper.floor_double(boundingBox.minY) - 1, MathHelper.floor_double(posZ)); - f2 = block.slipperiness * 0.91F; - } + if (onGround) { + f2 = 0.54600006F; + Block block = worldObj.getBlock( + MathHelper.floor_double(posX), + MathHelper.floor_double(boundingBox.minY) - 1, + MathHelper.floor_double(posZ)); + f2 = block.slipperiness * 0.91F; + } - float f3 = 0.16277136F / (f2 * f2 * f2); - moveFlying(par1, par2, onGround ? 0.1F * f3 : 0.02F); - f2 = 0.91F; + float f3 = 0.16277136F / (f2 * f2 * f2); + moveFlying(par1, par2, onGround ? 0.1F * f3 : 0.02F); + f2 = 0.91F; - if (onGround) { - f2 = 0.54600006F; - Block block = worldObj.getBlock(MathHelper.floor_double(posX), MathHelper.floor_double(boundingBox.minY) - 1, MathHelper.floor_double(posZ)); - f2 = block.slipperiness * 0.91F; - } + if (onGround) { + f2 = 0.54600006F; + Block block = worldObj.getBlock( + MathHelper.floor_double(posX), + MathHelper.floor_double(boundingBox.minY) - 1, + MathHelper.floor_double(posZ)); + f2 = block.slipperiness * 0.91F; + } - moveEntity(motionX, motionY, motionZ); - motionX *= f2; - motionY *= f2; - motionZ *= f2; - } + moveEntity(motionX, motionY, motionZ); + motionX *= f2; + motionY *= f2; + motionZ *= f2; + } - prevLimbSwingAmount = limbSwingAmount; - double d0 = posX - prevPosX; - double d1 = posZ - prevPosZ; - float f4 = MathHelper.sqrt_double(d0 * d0 + d1 * d1) * 4.0F; + prevLimbSwingAmount = limbSwingAmount; + double d0 = posX - prevPosX; + double d1 = posZ - prevPosZ; + float f4 = MathHelper.sqrt_double(d0 * d0 + d1 * d1) * 4.0F; - if(f4 > 1.0F) - f4 = 1.0F; + if (f4 > 1.0F) f4 = 1.0F; - limbSwingAmount += (f4 - limbSwingAmount) * 0.4F; - limbSwing += limbSwingAmount; - } + limbSwingAmount += (f4 - limbSwingAmount) * 0.4F; + limbSwing += limbSwingAmount; + } - @Override - public boolean isOnLadder() { - return false; - } -} \ No newline at end of file + @Override + public boolean isOnLadder() { + return false; + } +} diff --git a/src/main/java/vazkii/botania/common/entity/EntityMagicLandmine.java b/src/main/java/vazkii/botania/common/entity/EntityMagicLandmine.java index 8d56c4336a..ab6304449a 100644 --- a/src/main/java/vazkii/botania/common/entity/EntityMagicLandmine.java +++ b/src/main/java/vazkii/botania/common/entity/EntityMagicLandmine.java @@ -2,16 +2,15 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jul 12, 2014, 7:59:00 PM (GMT)] */ package vazkii.botania.common.entity; import java.util.List; - import net.minecraft.entity.Entity; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.nbt.NBTTagCompound; @@ -24,63 +23,84 @@ public class EntityMagicLandmine extends Entity { - public EntityDoppleganger summoner; - - public EntityMagicLandmine(World par1World) { - super(par1World); - setSize(0F, 0F); - } - - @Override - public void onUpdate() { - motionX = 0; - motionY = 0; - motionZ = 0; - super.onUpdate(); - - float range = 2.5F; - - float r = 0.2F; - float g = 0F; - float b = 0.2F; - - //Botania.proxy.wispFX(worldObj, posX, posY, posZ, r, g, b, 0.6F, -0.2F, 1); - for(int i = 0; i < 6; i++) - Botania.proxy.wispFX(worldObj, posX - range + Math.random() * range * 2, posY, posZ - range + Math.random() * range * 2, r, g, b, 0.4F, -0.015F, 1); - - if(ticksExisted >= 55) { - worldObj.playSoundEffect(posX, posY, posZ, "botania:gaiaTrap", 0.3F, 1F); - - float m = 0.35F; - g = 0.4F; - for(int i = 0; i < 25; i++) - Botania.proxy.wispFX(worldObj, posX, posY + 1, posZ, r, g, b, 0.5F, (float) (Math.random() - 0.5F) * m, (float) (Math.random() - 0.5F) * m, (float) (Math.random() - 0.5F) * m); - - if(!worldObj.isRemote) { - List players = worldObj.getEntitiesWithinAABB(EntityPlayer.class, AxisAlignedBB.getBoundingBox(posX - range, posY - range, posZ - range, posX + range, posY + range, posZ + range)); - for(EntityPlayer player : players) { - player.attackEntityFrom(summoner == null ? DamageSource.generic : DamageSource.causeMobDamage(summoner), 10); - player.addPotionEffect(new PotionEffect(Potion.blindness.id, 25, 0)); - PotionEffect wither = new PotionEffect(Potion.wither.id, 70, 3); - wither.getCurativeItems().clear(); - player.addPotionEffect(wither); - } - } - - setDead(); - } - } - - @Override - protected void entityInit() { - } - - @Override - protected void readEntityFromNBT(NBTTagCompound var1) { - } - - @Override - protected void writeEntityToNBT(NBTTagCompound var1) { - } - + public EntityDoppleganger summoner; + + public EntityMagicLandmine(World par1World) { + super(par1World); + setSize(0F, 0F); + } + + @Override + public void onUpdate() { + motionX = 0; + motionY = 0; + motionZ = 0; + super.onUpdate(); + + float range = 2.5F; + + float r = 0.2F; + float g = 0F; + float b = 0.2F; + + // Botania.proxy.wispFX(worldObj, posX, posY, posZ, r, g, b, 0.6F, -0.2F, 1); + for (int i = 0; i < 6; i++) + Botania.proxy.wispFX( + worldObj, + posX - range + Math.random() * range * 2, + posY, + posZ - range + Math.random() * range * 2, + r, + g, + b, + 0.4F, + -0.015F, + 1); + + if (ticksExisted >= 55) { + worldObj.playSoundEffect(posX, posY, posZ, "botania:gaiaTrap", 0.3F, 1F); + + float m = 0.35F; + g = 0.4F; + for (int i = 0; i < 25; i++) + Botania.proxy.wispFX( + worldObj, + posX, + posY + 1, + posZ, + r, + g, + b, + 0.5F, + (float) (Math.random() - 0.5F) * m, + (float) (Math.random() - 0.5F) * m, + (float) (Math.random() - 0.5F) * m); + + if (!worldObj.isRemote) { + List players = worldObj.getEntitiesWithinAABB( + EntityPlayer.class, + AxisAlignedBB.getBoundingBox( + posX - range, posY - range, posZ - range, posX + range, posY + range, posZ + range)); + for (EntityPlayer player : players) { + player.attackEntityFrom( + summoner == null ? DamageSource.generic : DamageSource.causeMobDamage(summoner), 10); + player.addPotionEffect(new PotionEffect(Potion.blindness.id, 25, 0)); + PotionEffect wither = new PotionEffect(Potion.wither.id, 70, 3); + wither.getCurativeItems().clear(); + player.addPotionEffect(wither); + } + } + + setDead(); + } + } + + @Override + protected void entityInit() {} + + @Override + protected void readEntityFromNBT(NBTTagCompound var1) {} + + @Override + protected void writeEntityToNBT(NBTTagCompound var1) {} } diff --git a/src/main/java/vazkii/botania/common/entity/EntityMagicMissile.java b/src/main/java/vazkii/botania/common/entity/EntityMagicMissile.java index 88fda7c892..a232768b25 100644 --- a/src/main/java/vazkii/botania/common/entity/EntityMagicMissile.java +++ b/src/main/java/vazkii/botania/common/entity/EntityMagicMissile.java @@ -2,16 +2,16 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Nov 24, 2014, 5:58:22 PM (GMT)] */ package vazkii.botania.common.entity; +import cpw.mods.fml.relauncher.ReflectionHelper; import java.util.List; - import net.minecraft.block.Block; import net.minecraft.block.BlockBush; import net.minecraft.block.BlockLeaves; @@ -28,162 +28,176 @@ import vazkii.botania.common.Botania; import vazkii.botania.common.core.helper.Vector3; import vazkii.botania.common.lib.LibObfuscation; -import cpw.mods.fml.relauncher.ReflectionHelper; public class EntityMagicMissile extends EntityThrowable { - private static final String TAG_TIME = "time"; - - double lockX, lockY = -1, lockZ; - int time = 0; - - public EntityMagicMissile(World world) { - super(world); - setSize(0F, 0F); - } - - public EntityMagicMissile(EntityLivingBase thrower, boolean evil) { - this(thrower.worldObj); - ReflectionHelper.setPrivateValue(EntityThrowable.class, this, thrower, LibObfuscation.THROWER); - setEvil(evil); - } - - @Override - protected void entityInit() { - dataWatcher.addObject(25, (byte) 0); - dataWatcher.addObject(26, 0); - } - - public void setEvil(boolean evil) { - dataWatcher.updateObject(25, (byte) (evil ? 1 : 0)); - } - - public boolean isEvil() { - return dataWatcher.getWatchableObjectByte(25) == 1; - } - - public void setTarget(EntityLivingBase e) { - dataWatcher.updateObject(26, e == null ? -1 : e.getEntityId()); - } - - public EntityLivingBase getTargetEntity() { - int id = dataWatcher.getWatchableObjectInt(26); - Entity e = worldObj.getEntityByID(id); - if(e != null && e instanceof EntityLivingBase) - return (EntityLivingBase) e; - - return null; - } - - @Override - public void onUpdate() { - double lastTickPosX = this.lastTickPosX; - double lastTickPosY = this.lastTickPosY; - double lastTickPosZ = this.lastTickPosZ; - - super.onUpdate(); - - if(!worldObj.isRemote && (!getTarget() || time > 40)) { - setDead(); - return; - } - - boolean evil = isEvil(); - Vector3 thisVec = Vector3.fromEntityCenter(this); - Vector3 oldPos = new Vector3(lastTickPosX, lastTickPosY, lastTickPosZ); - Vector3 diff = thisVec.copy().sub(oldPos); - Vector3 step = diff.copy().normalize().multiply(0.05); - int steps = (int) (diff.mag() / step.mag()); - Vector3 particlePos = oldPos.copy(); - - Botania.proxy.setSparkleFXCorrupt(evil); - for(int i = 0; i < steps; i++) { - Botania.proxy.sparkleFX(worldObj, particlePos.x, particlePos.y, particlePos.z, 1F, evil ? 0F : 0.4F, 1F, 0.8F, 2); - if(worldObj.rand.nextInt(steps) <= 1) - Botania.proxy.sparkleFX(worldObj, particlePos.x + (Math.random() - 0.5) * 0.4, particlePos.y + (Math.random() - 0.5) * 0.4, particlePos.z + (Math.random() - 0.5) * 0.4, 1F, evil ? 0F : 0.4F, 1F, 0.8F, 2); - - particlePos.add(step); - } - Botania.proxy.setSparkleFXCorrupt(false); - - EntityLivingBase target = getTargetEntity(); - if(target != null) { - if(lockY == -1) { - lockX = target.posX; - lockY = target.posY; - lockZ = target.posZ; - } - - Vector3 targetVec = evil ? new Vector3(lockX, lockY, lockZ) : Vector3.fromEntityCenter(target); - Vector3 diffVec = targetVec.copy().sub(thisVec); - Vector3 motionVec = diffVec.copy().normalize().multiply(evil ? 0.5 : 0.6); - motionX = motionVec.x; - motionY = motionVec.y; - if(time < 10) - motionY = Math.abs(motionY); - motionZ = motionVec.z; - - List targetList = worldObj.getEntitiesWithinAABB(EntityLivingBase.class, AxisAlignedBB.getBoundingBox(posX - 0.5, posY - 0.5, posZ - 0.5, posX + 0.5, posY + 0.5, posZ + 0.5)); - if(targetList.contains(target) && target != null) { - EntityLivingBase thrower = getThrower(); - if(thrower != null) { - EntityPlayer player = thrower instanceof EntityPlayer ? (EntityPlayer) thrower : null; - target.attackEntityFrom(player == null ? DamageSource.causeMobDamage(thrower) : DamageSource.causePlayerDamage(player), evil ? 12 : 7); - } else target.attackEntityFrom(DamageSource.generic, evil ? 12 : 7); - - setDead(); - } - - if(evil && diffVec.mag() < 1) - setDead(); - } - - time++; - } - - @Override - public void writeEntityToNBT(NBTTagCompound cmp) { - super.writeEntityToNBT(cmp); - cmp.setInteger(TAG_TIME, time); - } - - @Override - public void readEntityFromNBT(NBTTagCompound cmp) { - super.readEntityFromNBT(cmp); - time = cmp.getInteger(TAG_TIME); - } - - - public boolean getTarget() { - EntityLivingBase target = getTargetEntity(); - if(target != null && target.getHealth() > 0 && !target.isDead && worldObj.loadedEntityList.contains(target)) - return true; - if(target != null) - setTarget(null); - - double range = 12; - List entities = worldObj.getEntitiesWithinAABB(isEvil() ? EntityPlayer.class : IMob.class, AxisAlignedBB.getBoundingBox(posX - range, posY - range, posZ - range, posX + range, posY + range, posZ + range)); - while(entities.size() > 0) { - Entity e = (Entity) entities.get(worldObj.rand.nextInt(entities.size())); - if(!(e instanceof EntityLivingBase) || e.isDead) { // Just in case... - entities.remove(e); - continue; - } - - target = (EntityLivingBase) e; - setTarget(target); - break; - } - - return target != null; - } - - @Override - protected void onImpact(MovingObjectPosition pos) { - Block block = worldObj.getBlock(pos.blockX, pos.blockY, pos.blockZ); - - if(!(block instanceof BlockBush) && !(block instanceof BlockLeaves) && (pos.entityHit == null || getTargetEntity() == pos.entityHit)) - setDead(); - } - + private static final String TAG_TIME = "time"; + + double lockX, lockY = -1, lockZ; + int time = 0; + + public EntityMagicMissile(World world) { + super(world); + setSize(0F, 0F); + } + + public EntityMagicMissile(EntityLivingBase thrower, boolean evil) { + this(thrower.worldObj); + ReflectionHelper.setPrivateValue(EntityThrowable.class, this, thrower, LibObfuscation.THROWER); + setEvil(evil); + } + + @Override + protected void entityInit() { + dataWatcher.addObject(25, (byte) 0); + dataWatcher.addObject(26, 0); + } + + public void setEvil(boolean evil) { + dataWatcher.updateObject(25, (byte) (evil ? 1 : 0)); + } + + public boolean isEvil() { + return dataWatcher.getWatchableObjectByte(25) == 1; + } + + public void setTarget(EntityLivingBase e) { + dataWatcher.updateObject(26, e == null ? -1 : e.getEntityId()); + } + + public EntityLivingBase getTargetEntity() { + int id = dataWatcher.getWatchableObjectInt(26); + Entity e = worldObj.getEntityByID(id); + if (e != null && e instanceof EntityLivingBase) return (EntityLivingBase) e; + + return null; + } + + @Override + public void onUpdate() { + double lastTickPosX = this.lastTickPosX; + double lastTickPosY = this.lastTickPosY; + double lastTickPosZ = this.lastTickPosZ; + + super.onUpdate(); + + if (!worldObj.isRemote && (!getTarget() || time > 40)) { + setDead(); + return; + } + + boolean evil = isEvil(); + Vector3 thisVec = Vector3.fromEntityCenter(this); + Vector3 oldPos = new Vector3(lastTickPosX, lastTickPosY, lastTickPosZ); + Vector3 diff = thisVec.copy().sub(oldPos); + Vector3 step = diff.copy().normalize().multiply(0.05); + int steps = (int) (diff.mag() / step.mag()); + Vector3 particlePos = oldPos.copy(); + + Botania.proxy.setSparkleFXCorrupt(evil); + for (int i = 0; i < steps; i++) { + Botania.proxy.sparkleFX( + worldObj, particlePos.x, particlePos.y, particlePos.z, 1F, evil ? 0F : 0.4F, 1F, 0.8F, 2); + if (worldObj.rand.nextInt(steps) <= 1) + Botania.proxy.sparkleFX( + worldObj, + particlePos.x + (Math.random() - 0.5) * 0.4, + particlePos.y + (Math.random() - 0.5) * 0.4, + particlePos.z + (Math.random() - 0.5) * 0.4, + 1F, + evil ? 0F : 0.4F, + 1F, + 0.8F, + 2); + + particlePos.add(step); + } + Botania.proxy.setSparkleFXCorrupt(false); + + EntityLivingBase target = getTargetEntity(); + if (target != null) { + if (lockY == -1) { + lockX = target.posX; + lockY = target.posY; + lockZ = target.posZ; + } + + Vector3 targetVec = evil ? new Vector3(lockX, lockY, lockZ) : Vector3.fromEntityCenter(target); + Vector3 diffVec = targetVec.copy().sub(thisVec); + Vector3 motionVec = diffVec.copy().normalize().multiply(evil ? 0.5 : 0.6); + motionX = motionVec.x; + motionY = motionVec.y; + if (time < 10) motionY = Math.abs(motionY); + motionZ = motionVec.z; + + List targetList = worldObj.getEntitiesWithinAABB( + EntityLivingBase.class, + AxisAlignedBB.getBoundingBox( + posX - 0.5, posY - 0.5, posZ - 0.5, posX + 0.5, posY + 0.5, posZ + 0.5)); + if (targetList.contains(target) && target != null) { + EntityLivingBase thrower = getThrower(); + if (thrower != null) { + EntityPlayer player = thrower instanceof EntityPlayer ? (EntityPlayer) thrower : null; + target.attackEntityFrom( + player == null + ? DamageSource.causeMobDamage(thrower) + : DamageSource.causePlayerDamage(player), + evil ? 12 : 7); + } else target.attackEntityFrom(DamageSource.generic, evil ? 12 : 7); + + setDead(); + } + + if (evil && diffVec.mag() < 1) setDead(); + } + + time++; + } + + @Override + public void writeEntityToNBT(NBTTagCompound cmp) { + super.writeEntityToNBT(cmp); + cmp.setInteger(TAG_TIME, time); + } + + @Override + public void readEntityFromNBT(NBTTagCompound cmp) { + super.readEntityFromNBT(cmp); + time = cmp.getInteger(TAG_TIME); + } + + public boolean getTarget() { + EntityLivingBase target = getTargetEntity(); + if (target != null && target.getHealth() > 0 && !target.isDead && worldObj.loadedEntityList.contains(target)) + return true; + if (target != null) setTarget(null); + + double range = 12; + List entities = worldObj.getEntitiesWithinAABB( + isEvil() ? EntityPlayer.class : IMob.class, + AxisAlignedBB.getBoundingBox( + posX - range, posY - range, posZ - range, posX + range, posY + range, posZ + range)); + while (entities.size() > 0) { + Entity e = (Entity) entities.get(worldObj.rand.nextInt(entities.size())); + if (!(e instanceof EntityLivingBase) || e.isDead) { // Just in case... + entities.remove(e); + continue; + } + + target = (EntityLivingBase) e; + setTarget(target); + break; + } + + return target != null; + } + + @Override + protected void onImpact(MovingObjectPosition pos) { + Block block = worldObj.getBlock(pos.blockX, pos.blockY, pos.blockZ); + + if (!(block instanceof BlockBush) + && !(block instanceof BlockLeaves) + && (pos.entityHit == null || getTargetEntity() == pos.entityHit)) setDead(); + } } diff --git a/src/main/java/vazkii/botania/common/entity/EntityManaBurst.java b/src/main/java/vazkii/botania/common/entity/EntityManaBurst.java index c51478a19b..b05119e940 100644 --- a/src/main/java/vazkii/botania/common/entity/EntityManaBurst.java +++ b/src/main/java/vazkii/botania/common/entity/EntityManaBurst.java @@ -2,20 +2,21 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jan 26, 2014, 5:09:12 PM (GMT)] */ package vazkii.botania.common.entity; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; import java.awt.Color; import java.util.ArrayList; import java.util.List; import java.util.Random; import java.util.UUID; - import net.minecraft.block.Block; import net.minecraft.block.BlockBush; import net.minecraft.block.BlockLeaves; @@ -49,846 +50,914 @@ import vazkii.botania.common.core.handler.ConfigHandler; import vazkii.botania.common.core.helper.Vector3; import vazkii.botania.common.item.equipment.bauble.ItemTinyPlanet; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; public class EntityManaBurst extends EntityThrowable implements IManaBurst { - private static final String TAG_TICKS_EXISTED = "ticksExisted"; - private static final String TAG_COLOR = "color"; - private static final String TAG_MANA = "mana"; - private static final String TAG_STARTING_MANA = "startingMana"; - private static final String TAG_MIN_MANA_LOSS = "minManaLoss"; - private static final String TAG_TICK_MANA_LOSS = "manaLossTick"; - private static final String TAG_SPREADER_X = "spreaderX"; - private static final String TAG_SPREADER_Y = "spreaderY"; - private static final String TAG_SPREADER_Z = "spreaderZ"; - private static final String TAG_GRAVITY = "gravity"; - private static final String TAG_LENS_STACK = "lensStack"; - private static final String TAG_LAST_MOTION_X = "lastMotionX"; - private static final String TAG_LAST_MOTION_Y = "lastMotionY"; - private static final String TAG_LAST_MOTION_Z = "lastMotionZ"; - private static final String TAG_HAS_SHOOTER = "hasShooter"; - private static final String TAG_SHOOTER_UUID_MOST = "shooterUUIDMost"; - private static final String TAG_SHOOTER_UUID_LEAST = "shooterUUIDLeast"; - - boolean fake = false; - - final int dataWatcherEntries = 10; - final int dataWatcherStart = 32 - dataWatcherEntries; - - List alreadyCollidedAt = new ArrayList(); - - boolean fullManaLastTick = true; - - UUID shooterIdentity = null; - int _ticksExisted = 0; - boolean scanBeam = false; - public List propsList = new ArrayList(); - - public EntityManaBurst(World world) { - super(world); - setSize(0F, 0F); - for(int i = 0; i < dataWatcherEntries; i++) { - int j = dataWatcherStart + i; - if(i == 4 || i == 5) - dataWatcher.addObject(j, 0F); - else if(i == 9) - dataWatcher.addObject(j, new ItemStack(Blocks.stone, 0, 0)); - else dataWatcher.addObject(j, 0); - - dataWatcher.setObjectWatched(j); - } - } - - public EntityManaBurst(IManaSpreader spreader, boolean fake) { - this(((TileEntity)spreader).getWorldObj()); - - TileEntity tile = (TileEntity) spreader; - - this.fake = fake; - - setBurstSourceCoords(tile.xCoord, tile.yCoord, tile.zCoord); - setLocationAndAngles(tile.xCoord + 0.5, tile.yCoord + 0.5, tile.zCoord + 0.5, 0, 0); - rotationYaw = -(spreader.getRotationX() + 90F); - rotationPitch = spreader.getRotationY(); - - float f = 0.4F; - double mx = MathHelper.sin(rotationYaw / 180.0F * (float) Math.PI) * MathHelper.cos(rotationPitch / 180.0F * (float) Math.PI) * f / 2D; - double mz = -(MathHelper.cos(rotationYaw / 180.0F * (float) Math.PI) * MathHelper.cos(rotationPitch / 180.0F * (float) Math.PI) * f) / 2D; - double my = MathHelper.sin((rotationPitch + func_70183_g()) / 180.0F * (float) Math.PI) * f / 2D; - setMotion(mx, my, mz); - } - - public EntityManaBurst(EntityPlayer player) { - this(player.worldObj); - - setBurstSourceCoords(0, -1, 0); - setLocationAndAngles(player.posX, player.posY + player.getEyeHeight(), player.posZ, player.rotationYaw + 180, -player.rotationPitch); - - posX -= MathHelper.cos((rotationYaw + 180) / 180.0F * (float) Math.PI) * 0.16F; - posY -= 0.10000000149011612D; - posZ -= MathHelper.sin((rotationYaw + 180) / 180.0F * (float) Math.PI) * 0.16F; - - setPosition(posX, posY, posZ); - yOffset = 0.0F; - float f = 0.4F; - double mx = MathHelper.sin(rotationYaw / 180.0F * (float) Math.PI) * MathHelper.cos(rotationPitch / 180.0F * (float) Math.PI) * f / 2D; - double mz = -(MathHelper.cos(rotationYaw / 180.0F * (float) Math.PI) * MathHelper.cos(rotationPitch / 180.0F * (float) Math.PI) * f) / 2D; - double my = MathHelper.sin((rotationPitch + func_70183_g()) / 180.0F * (float) Math.PI) * f / 2D; - setMotion(mx, my, mz); - } - - float accumulatedManaLoss = 0; - - private int ticksInAir; - - // Hacked code copied from super.onUpdate, to use Vector3 rather than the world vector pool - public void superUpdate() { - lastTickPosX = posX; - lastTickPosY = posY; - lastTickPosZ = posZ; - onEntityUpdate(); - - if(throwableShake > 0) - --throwableShake; - - Vec3 vec3 = new Vector3(posX, posY, posZ).toVec3D(); - Vec3 vec31 = new Vector3(posX + motionX, posY + motionY, posZ + motionZ).toVec3D(); - MovingObjectPosition movingobjectposition = clip(vec3, vec31); - - if(movingobjectposition != null) - vec31 = new Vector3(movingobjectposition.hitVec.xCoord, movingobjectposition.hitVec.yCoord, movingobjectposition.hitVec.zCoord).toVec3D(); - - if(!worldObj.isRemote) { - Entity entity = null; - List list = worldObj.getEntitiesWithinAABBExcludingEntity(this, boundingBox.addCoord(motionX, motionY, motionZ).expand(1.0D, 1.0D, 1.0D)); - double d0 = 0.0D; - EntityLivingBase entitylivingbase = getThrower(); - - for(int j = 0; j < list.size(); ++j) { - Entity entity1 = (Entity) list.get(j); - - if(entity1.canBeCollidedWith() && (entity1 != entitylivingbase || ticksInAir >= 5)) { - float f = 0.3F; - AxisAlignedBB axisalignedbb = entity1.boundingBox.expand(f, f, f); - MovingObjectPosition movingobjectposition1 = axisalignedbb.calculateIntercept(vec3, vec31); - - if(movingobjectposition1 != null) { - double d1 = vec3.distanceTo(movingobjectposition1.hitVec); - - if (d1 < d0 || d0 == 0.0D) { - entity = entity1; - d0 = d1; - } - } - } - } - - if(entity != null) - movingobjectposition = new MovingObjectPosition(entity); - } - - if(movingobjectposition != null) - onImpact(movingobjectposition); - - posX += motionX; - posY += motionY; - posZ += motionZ; - float f1 = MathHelper.sqrt_double(motionX * motionX + motionZ * motionZ); - rotationYaw = (float)(Math.atan2(motionX, motionZ) * 180.0D / Math.PI); - - for(rotationPitch = (float)(Math.atan2(motionY, f1) * 180.0D / Math.PI); rotationPitch - prevRotationPitch < -180.0F; prevRotationPitch -= 360.0F); - - while(rotationPitch - prevRotationPitch >= 180.0F) - prevRotationPitch += 360.0F; - - while(rotationYaw - prevRotationYaw < -180.0F) - prevRotationYaw -= 360.0F; - - while(rotationYaw - prevRotationYaw >= 180.0F) - prevRotationYaw += 360.0F; - - rotationPitch = prevRotationPitch + (rotationPitch - prevRotationPitch) * 0.2F; - rotationYaw = prevRotationYaw + (rotationYaw - prevRotationYaw) * 0.2F; - float f3 = getGravityVelocity(); - - motionY -= f3; - setPosition(posX, posY, posZ); - } - - public MovingObjectPosition clip(Vec3 par1Vec3, Vec3 par2Vec3) { - boolean par3 = false; - boolean par4 = false; - if (!Double.isNaN(par1Vec3.xCoord) && !Double.isNaN(par1Vec3.yCoord) && !Double.isNaN(par1Vec3.zCoord)) { - if (!Double.isNaN(par2Vec3.xCoord) && !Double.isNaN(par2Vec3.yCoord) && !Double.isNaN(par2Vec3.zCoord)) { - int i = MathHelper.floor_double(par2Vec3.xCoord); - int j = MathHelper.floor_double(par2Vec3.yCoord); - int k = MathHelper.floor_double(par2Vec3.zCoord); - int l = MathHelper.floor_double(par1Vec3.xCoord); - int i1 = MathHelper.floor_double(par1Vec3.yCoord); - int j1 = MathHelper.floor_double(par1Vec3.zCoord); - Block block = worldObj.getBlock(l, i1, j1); - int l1 = worldObj.getBlockMetadata(l, i1, j1); - - if (block != null && (!par4 || block == null || block.getCollisionBoundingBoxFromPool(worldObj, l, i1, j1) != null) && block != Blocks.air && block.canCollideCheck(l1, par3)) { - MovingObjectPosition movingobjectposition = block.collisionRayTrace(worldObj, l, i1, j1, par1Vec3, par2Vec3); - - if (movingobjectposition != null) - return movingobjectposition; - } - - int k1 = 200; - - while (k1-- >= 0) { - if (Double.isNaN(par1Vec3.xCoord) || Double.isNaN(par1Vec3.yCoord) || Double.isNaN(par1Vec3.zCoord)) - return null; - - if (l == i && i1 == j && j1 == k) - return null; - - boolean flag2 = true; - boolean flag3 = true; - boolean flag4 = true; - double d0 = 999.0D; - double d1 = 999.0D; - double d2 = 999.0D; - - if (i > l) - d0 = l + 1.0D; - else if (i < l) - d0 = l + 0.0D; - else flag2 = false; - - if (j > i1) - d1 = i1 + 1.0D; - else if (j < i1) - d1 = i1 + 0.0D; - else flag3 = false; - - if (k > j1) - d2 = j1 + 1.0D; - else if (k < j1) - d2 = j1 + 0.0D; - else flag4 = false; - - double d3 = 999.0D; - double d4 = 999.0D; - double d5 = 999.0D; - double d6 = par2Vec3.xCoord - par1Vec3.xCoord; - double d7 = par2Vec3.yCoord - par1Vec3.yCoord; - double d8 = par2Vec3.zCoord - par1Vec3.zCoord; - - if (flag2) - d3 = (d0 - par1Vec3.xCoord) / d6; - - if (flag3) - d4 = (d1 - par1Vec3.yCoord) / d7; - - if (flag4) - d5 = (d2 - par1Vec3.zCoord) / d8; - - byte b0; - - if (d3 < d4 && d3 < d5) { - if (i > l) - b0 = 4; - else b0 = 5; - - par1Vec3.xCoord = d0; - par1Vec3.yCoord += d7 * d3; - par1Vec3.zCoord += d8 * d3; - } else if (d4 < d5) { - if (j > i1) - b0 = 0; - else b0 = 1; - - par1Vec3.xCoord += d6 * d4; - par1Vec3.yCoord = d1; - par1Vec3.zCoord += d8 * d4; - } else { - if (k > j1) - b0 = 2; - else b0 = 3; - - par1Vec3.xCoord += d6 * d5; - par1Vec3.yCoord += d7 * d5; - par1Vec3.zCoord = d2; - } - - Vec3 vec32 = new Vector3(par1Vec3.xCoord, par1Vec3.yCoord, par1Vec3.zCoord).toVec3D(); - l = (int)(vec32.xCoord = MathHelper.floor_double(par1Vec3.xCoord)); - - if (b0 == 5) { - --l; - ++vec32.xCoord; - } - - i1 = (int)(vec32.yCoord = MathHelper.floor_double(par1Vec3.yCoord)); - - if (b0 == 1) { - --i1; - ++vec32.yCoord; - } - - j1 = (int)(vec32.zCoord = MathHelper.floor_double(par1Vec3.zCoord)); - - if (b0 == 3) { - --j1; - ++vec32.zCoord; - } - - Block block1 = worldObj.getBlock(l, i1, j1); - int j2 = worldObj.getBlockMetadata(l, i1, j1); - - if ((!par4 || block1 == null || block1.getCollisionBoundingBoxFromPool(worldObj, l, i1, j1) != null) && block1 != Blocks.air && block1.canCollideCheck(j2, par3)) { - MovingObjectPosition movingobjectposition1 = block1.collisionRayTrace(worldObj, l, i1, j1, par1Vec3, par2Vec3); - - if (movingobjectposition1 != null) - return movingobjectposition1; - } - } - - return null; - } - else return null; - } else return null; - } - - @Override - public void onUpdate() { - setTicksExisted(getTicksExisted() + 1); - superUpdate(); - - if(!fake && !isDead) - ping(); - - ILensEffect lens = getLensInstance(); - if(lens != null) - lens.updateBurst(this, getSourceLens()); - - int mana = getMana(); - if(getTicksExisted() >= getMinManaLoss()) { - accumulatedManaLoss += getManaLossPerTick(); - int loss = (int) accumulatedManaLoss; - setMana(mana - loss); - accumulatedManaLoss -= loss; - - if(getMana() <= 0) - setDead(); - } - - particles(); - - setMotion(motionX, motionY, motionZ); - - fullManaLastTick = getMana() == getStartingMana(); - - if(scanBeam) { - PositionProperties props = new PositionProperties(this); - if(propsList.isEmpty()) - propsList.add(props); - else { - PositionProperties lastProps = propsList.get(propsList.size() - 1); - if(!props.coordsEqual(lastProps)) - propsList.add(props); - } - } - } - - @Override - @SideOnly(Side.CLIENT) - public void setPositionAndRotation2(double p_70056_1_, double p_70056_3_, double p_70056_5_, float p_70056_7_, float p_70056_8_, int p_70056_9_) { - setPosition(p_70056_1_, p_70056_3_, p_70056_5_); - setRotation(p_70056_7_, p_70056_8_); - } - - @Override - public boolean handleWaterMovement() { - return false; - } - - public TileEntity collidedTile = null; - public boolean noParticles = false; - - public TileEntity getCollidedTile(boolean noParticles) { - this.noParticles = noParticles; - - while(!isDead) - onUpdate(); - - if(fake) - incrementFakeParticleTick(); - - return collidedTile; - } - - @Override - public void writeEntityToNBT(NBTTagCompound par1nbtTagCompound) { - super.writeEntityToNBT(par1nbtTagCompound); - par1nbtTagCompound.setInteger(TAG_TICKS_EXISTED, getTicksExisted()); - par1nbtTagCompound.setInteger(TAG_COLOR, getColor()); - par1nbtTagCompound.setInteger(TAG_MANA, getMana()); - par1nbtTagCompound.setInteger(TAG_STARTING_MANA, getStartingMana()); - par1nbtTagCompound.setInteger(TAG_MIN_MANA_LOSS, getMinManaLoss()); - par1nbtTagCompound.setFloat(TAG_TICK_MANA_LOSS, getManaLossPerTick()); - par1nbtTagCompound.setFloat(TAG_GRAVITY, getGravity()); - - ItemStack stack = getSourceLens(); - NBTTagCompound lensCmp = new NBTTagCompound(); - if(stack != null) - stack.writeToNBT(lensCmp); - par1nbtTagCompound.setTag(TAG_LENS_STACK, lensCmp); - - ChunkCoordinates coords = getBurstSourceChunkCoordinates(); - par1nbtTagCompound.setInteger(TAG_SPREADER_X, coords.posX); - par1nbtTagCompound.setInteger(TAG_SPREADER_Y, coords.posY); - par1nbtTagCompound.setInteger(TAG_SPREADER_Z, coords.posZ); - - par1nbtTagCompound.setDouble(TAG_LAST_MOTION_X, motionX); - par1nbtTagCompound.setDouble(TAG_LAST_MOTION_Y, motionY); - par1nbtTagCompound.setDouble(TAG_LAST_MOTION_Z, motionZ); - - UUID identity = getShooterUIID(); - boolean hasShooter = identity != null; - par1nbtTagCompound.setBoolean(TAG_HAS_SHOOTER, hasShooter); - if(hasShooter) { - par1nbtTagCompound.setLong(TAG_SHOOTER_UUID_MOST, identity.getMostSignificantBits()); - par1nbtTagCompound.setLong(TAG_SHOOTER_UUID_LEAST, identity.getLeastSignificantBits()); - } - } - - @Override - public void readEntityFromNBT(NBTTagCompound par1nbtTagCompound) { - super.readEntityFromNBT(par1nbtTagCompound); - setTicksExisted(par1nbtTagCompound.getInteger(TAG_TICKS_EXISTED)); - setColor(par1nbtTagCompound.getInteger(TAG_COLOR)); - setMana(par1nbtTagCompound.getInteger(TAG_MANA)); - setStartingMana(par1nbtTagCompound.getInteger(TAG_STARTING_MANA)); - setMinManaLoss(par1nbtTagCompound.getInteger(TAG_MIN_MANA_LOSS)); - setManaLossPerTick(par1nbtTagCompound.getFloat(TAG_TICK_MANA_LOSS)); - setGravity(par1nbtTagCompound.getFloat(TAG_GRAVITY)); - - NBTTagCompound lensCmp = par1nbtTagCompound.getCompoundTag(TAG_LENS_STACK); - ItemStack stack = ItemStack.loadItemStackFromNBT(lensCmp); - if(stack != null) - setSourceLens(stack); - else setSourceLens(new ItemStack(Blocks.stone, 0, 0)); - - int x = par1nbtTagCompound.getInteger(TAG_SPREADER_X); - int y = par1nbtTagCompound.getInteger(TAG_SPREADER_Y); - int z = par1nbtTagCompound.getInteger(TAG_SPREADER_Z); - - setBurstSourceCoords(x, y, z); - - double lastMotionX = par1nbtTagCompound.getDouble(TAG_LAST_MOTION_X); - double lastMotionY = par1nbtTagCompound.getDouble(TAG_LAST_MOTION_Y); - double lastMotionZ = par1nbtTagCompound.getDouble(TAG_LAST_MOTION_Z); - - setMotion(lastMotionX, lastMotionY, lastMotionZ); - - boolean hasShooter = par1nbtTagCompound.getBoolean(TAG_HAS_SHOOTER); - if(hasShooter) { - long most = par1nbtTagCompound.getLong(TAG_SHOOTER_UUID_MOST); - long least = par1nbtTagCompound.getLong(TAG_SHOOTER_UUID_LEAST); - UUID identity = getShooterUIID(); - if(identity == null || most != identity.getMostSignificantBits() || least != identity.getLeastSignificantBits()) - shooterIdentity = new UUID(most, least); - } - } - - public void particles() { - if(isDead || !worldObj.isRemote) - return; - - ILensEffect lens = getLensInstance(); - if(lens != null && !lens.doParticles(this, getSourceLens())) - return; - - Color color = new Color(getColor()); - float r = color.getRed() / 255F; - float g = color.getGreen() / 255F; - float b = color.getBlue() / 255F; - - int mana = getMana(); - int maxMana = getStartingMana(); - float osize = (float) mana / (float) maxMana; - float size = osize; - - if(fake) { - if(getMana() == getStartingMana()) - size = 2F; - else if(fullManaLastTick) - size = 4F; - - if(!noParticles && shouldDoFakeParticles()) - Botania.proxy.sparkleFX(worldObj, posX, posY, posZ, r, g, b, 0.4F * size, 1, true); - } else { - boolean monocle = Botania.proxy.isClientPlayerWearingMonocle(); - if(monocle) - Botania.proxy.setWispFXDepthTest(false); - - if(ConfigHandler.subtlePowerSystem) - Botania.proxy.wispFX(worldObj, posX, posY, posZ, r, g, b, 0.1F * size, (float) (Math.random() - 0.5F) * 0.02F, (float) (Math.random() - 0.5F) * 0.02F, (float) (Math.random() - 0.5F) * 0.01F); - else { - float or = r; - float og = g; - float ob = b; - - double savedPosX = posX; - double savedPosY = posY; - double savedPosZ = posZ; - - Vector3 currentPos = Vector3.fromEntity(this); - Vector3 oldPos = new Vector3(prevPosX, prevPosY, prevPosZ); - Vector3 diffVec = oldPos.copy().sub(currentPos); - Vector3 diffVecNorm = diffVec.copy().normalize(); - - double distance = 0.095; - - do { - r = or + ((float) Math.random() - 0.5F) * 0.25F; - g = og + ((float) Math.random() - 0.5F) * 0.25F; - b = ob + ((float) Math.random() - 0.5F) * 0.25F; - size = osize + ((float) Math.random() - 0.5F) * 0.065F + (float) Math.sin(new Random(entityUniqueID.getMostSignificantBits()).nextInt(9001)) * 0.4F; - Botania.proxy.wispFX(worldObj, posX, posY, posZ, r, g, b, 0.2F * size, (float) -motionX * 0.01F, (float) -motionY * 0.01F, (float) -motionZ * 0.01F); - - posX += diffVecNorm.x * distance; - posY += diffVecNorm.y * distance; - posZ += diffVecNorm.z * distance; - - currentPos = Vector3.fromEntity(this); - diffVec = oldPos.copy().sub(currentPos); - if(getEntityData().hasKey(ItemTinyPlanet.TAG_ORBIT)) - break; - } while(Math.abs(diffVec.mag()) > distance); - - Botania.proxy.wispFX(worldObj, posX, posY, posZ, r, g, b, 0.1F * size, (float) (Math.random() - 0.5F) * 0.06F, (float) (Math.random() - 0.5F) * 0.06F, (float) (Math.random() - 0.5F) * 0.06F); - - posX = savedPosX; - posY = savedPosY; - posZ = savedPosZ; - } - - if(monocle) - Botania.proxy.setWispFXDepthTest(true); - } - } - - @Override - protected void onImpact(MovingObjectPosition movingobjectposition) { - boolean collided = false; - boolean dead = false; - - if(movingobjectposition.entityHit == null) { - TileEntity tile = worldObj.getTileEntity(movingobjectposition.blockX, movingobjectposition.blockY, movingobjectposition.blockZ); - Block block = worldObj.getBlock(movingobjectposition.blockX, movingobjectposition.blockY, movingobjectposition.blockZ); - - if(tile instanceof IManaCollisionGhost && ((IManaCollisionGhost) tile).isGhost() && !(block instanceof IManaTrigger) || block instanceof BlockBush || block instanceof BlockLeaves) - return; - - if(BotaniaAPI.internalHandler.isBuildcraftPipe(tile)) - return; - - ChunkCoordinates coords = getBurstSourceChunkCoordinates(); - if(tile != null && (tile.xCoord != coords.posX || tile.yCoord != coords.posY || tile.zCoord != coords.posZ)) - collidedTile = tile; - - if(tile == null || tile.xCoord != coords.posX || tile.yCoord != coords.posY || tile.zCoord != coords.posZ) { - if(!fake && !noParticles && (!worldObj.isRemote || tile instanceof IClientManaHandler) && tile != null && tile instanceof IManaReceiver && ((IManaReceiver) tile).canRecieveManaFromBursts()) - onRecieverImpact((IManaReceiver) tile, tile.xCoord, tile.yCoord, tile.zCoord); - - if(block instanceof IManaTrigger) - ((IManaTrigger) block).onBurstCollision(this, worldObj, movingobjectposition.blockX, movingobjectposition.blockY, movingobjectposition.blockZ); - - boolean ghost = tile instanceof IManaCollisionGhost; - dead = !ghost; - if(ghost) - return; - } - - collided = true; - } - - ILensEffect lens = getLensInstance(); - if(lens != null) - dead = lens.collideBurst(this, movingobjectposition, collidedTile != null && collidedTile instanceof IManaReceiver && ((IManaReceiver) collidedTile).canRecieveManaFromBursts(), dead, getSourceLens()); - - if(collided && !hasAlreadyCollidedAt(movingobjectposition.blockX, movingobjectposition.blockY, movingobjectposition.blockZ)) - alreadyCollidedAt.add(getCollisionLocString(movingobjectposition.blockX, movingobjectposition.blockY, movingobjectposition.blockZ)); - - if(dead && !isDead) { - if(!fake) { - Color color = new Color(getColor()); - float r = color.getRed() / 255F; - float g = color.getGreen() / 255F; - float b = color.getBlue() / 255F; - - int mana = getMana(); - int maxMana = getStartingMana(); - float size = (float) mana / (float) maxMana; - - if(!ConfigHandler.subtlePowerSystem) - for(int i = 0; i < 4; i++) - Botania.proxy.wispFX(worldObj, posX, posY, posZ, r, g, b, 0.15F * size, (float) (Math.random() - 0.5F) * 0.04F, (float) (Math.random() - 0.5F) * 0.04F, (float) (Math.random() - 0.5F) * 0.04F); - Botania.proxy.sparkleFX(worldObj, (float) posX, (float) posY, (float) posZ, r, g, b, 4, 2); - } - - setDead(); - } - } - - protected void onRecieverImpact(IManaReceiver tile, int x, int y, int z) { - int mana = getMana(); - if(tile instanceof IManaCollector) - mana *= ((IManaCollector) tile).getManaYieldMultiplier(this); - - tile.recieveMana(mana); - if(tile instanceof IThrottledPacket) - ((IThrottledPacket) tile).markDispatchable(); - else VanillaPacketDispatcher.dispatchTEToNearbyPlayers(worldObj, x, y, z); - } - - @Override - public void setDead() { - super.setDead(); - - if(!fake) { - TileEntity tile = getShooter(); - if(tile != null && tile instanceof IManaSpreader) - ((IManaSpreader) tile).setCanShoot(true); - } else setDeathTicksForFakeParticle(); - } - - public TileEntity getShooter() { - ChunkCoordinates coords = getBurstSourceChunkCoordinates(); - TileEntity tile = worldObj.getTileEntity(coords.posX, coords.posY, coords.posZ); - return tile; - } - - @Override - protected float getGravityVelocity() { - return getGravity(); - } - - @Override - public boolean isFake() { - return fake; - } - - @Override - public void setFake(boolean fake) { - this.fake = fake; - } - - public void setScanBeam() { - scanBeam = true; - } - - @Override - public int getColor() { - return dataWatcher.getWatchableObjectInt(dataWatcherStart); - } - - @Override - public void setColor(int color) { - dataWatcher.updateObject(dataWatcherStart, color); - } - - @Override - public int getMana() { - return dataWatcher.getWatchableObjectInt(dataWatcherStart + 1); - } - - @Override - public void setMana(int mana) { - dataWatcher.updateObject(dataWatcherStart + 1, mana); - } - - @Override - public int getStartingMana() { - return dataWatcher.getWatchableObjectInt(dataWatcherStart + 2); - } - - @Override - public void setStartingMana(int mana) { - dataWatcher.updateObject(dataWatcherStart + 2, mana); - } - - @Override - public int getMinManaLoss() { - return dataWatcher.getWatchableObjectInt(dataWatcherStart + 3); - } - - @Override - public void setMinManaLoss(int minManaLoss) { - dataWatcher.updateObject(dataWatcherStart + 3, minManaLoss); - } - - @Override - public float getManaLossPerTick() { - return dataWatcher.getWatchableObjectFloat(dataWatcherStart + 4); - } - - @Override - public void setManaLossPerTick(float mana) { - dataWatcher.updateObject(dataWatcherStart + 4, mana); - } - - @Override - public float getGravity() { - return dataWatcher.getWatchableObjectFloat(dataWatcherStart + 5); - } - - @Override - public void setGravity(float gravity) { - dataWatcher.updateObject(dataWatcherStart + 5, gravity); - } - - final int coordsStart = dataWatcherStart + 6; - - @Override - public ChunkCoordinates getBurstSourceChunkCoordinates() { - int x = dataWatcher.getWatchableObjectInt(coordsStart); - int y = dataWatcher.getWatchableObjectInt(coordsStart + 1); - int z = dataWatcher.getWatchableObjectInt(coordsStart + 2); - - return new ChunkCoordinates(x, y, z); - } - - @Override - public void setBurstSourceCoords(int x, int y, int z) { - dataWatcher.updateObject(coordsStart, x); - dataWatcher.updateObject(coordsStart + 1, y); - dataWatcher.updateObject(coordsStart + 2, z); - } - - @Override - public ItemStack getSourceLens() { - return dataWatcher.getWatchableObjectItemStack(dataWatcherStart + 9); - } - - @Override - public void setSourceLens(ItemStack lens) { - dataWatcher.updateObject(dataWatcherStart + 9, lens == null ? new ItemStack(Blocks.stone, 0, 0) : lens); - } - - @Override - public int getTicksExisted() { - return _ticksExisted; - } - - public void setTicksExisted(int ticks) { - _ticksExisted = ticks; - } - - public ILensEffect getLensInstance() { - ItemStack lens = getSourceLens(); - if(lens != null && lens.getItem() instanceof ILensEffect) - return (ILensEffect) lens.getItem(); - - return null; - } - - final int motionStart = dataWatcherStart + 10; - - @Override - public void setMotion(double x, double y, double z) { - motionX = x; - motionY = y; - motionZ = z; - } - - @Override - public boolean hasAlreadyCollidedAt(int x, int y, int z) { - return alreadyCollidedAt.contains(getCollisionLocString(x, y, z)); - } - - @Override - public void setCollidedAt(int x, int y, int z) { - if(!hasAlreadyCollidedAt(x, y, z)) - alreadyCollidedAt.add(getCollisionLocString(x, y, z)); - } - - private String getCollisionLocString(int x, int y, int z) { - return x + ":" + y + ":" + z; - } - - @Override - public void setShooterUUID(UUID uuid) { - shooterIdentity = uuid; - } - - @Override - public UUID getShooterUIID() { - return shooterIdentity; - } - - @Override - public void ping() { - TileEntity tile = getShooter(); - if(tile != null && tile instanceof IPingable) - ((IPingable) tile).pingback(this, getShooterUIID()); - } - - public boolean shouldDoFakeParticles() { - if(ConfigHandler.staticWandBeam) - return true; - - TileEntity tile = getShooter(); - if(tile != null && tile instanceof IManaSpreader) - return getMana() != getStartingMana() && fullManaLastTick || Math.abs(((IManaSpreader) tile).getBurstParticleTick() - getTicksExisted()) < 4; - return false; - } - - public void incrementFakeParticleTick() { - TileEntity tile = getShooter(); - if(tile != null && tile instanceof IManaSpreader) { - IManaSpreader spreader = (IManaSpreader) tile; - spreader.setBurstParticleTick(spreader.getBurstParticleTick()+2); - if(spreader.getLastBurstDeathTick() != -1 && spreader.getBurstParticleTick() > spreader.getLastBurstDeathTick()) - spreader.setBurstParticleTick(0); - } - } - - public void setDeathTicksForFakeParticle() { - ChunkCoordinates coords = getBurstSourceChunkCoordinates(); - TileEntity tile = worldObj.getTileEntity(coords.posX, coords.posY, coords.posZ); - if(tile != null && tile instanceof IManaSpreader) - ((IManaSpreader) tile).setLastBurstDeathTick(getTicksExisted()); - } - - public static class PositionProperties { - - public final ChunkCoordinates coords; - public final Block block; - public final int meta; - - public boolean invalid = false; - - public PositionProperties(Entity entity) { - int x = MathHelper.floor_double(entity.posX); - int y = MathHelper.floor_double(entity.posY); - int z = MathHelper.floor_double(entity.posZ); - coords = new ChunkCoordinates(x, y, z); - block = entity.worldObj.getBlock(x, y, z); - meta = entity.worldObj.getBlockMetadata(x, y, z); - } - - public boolean coordsEqual(PositionProperties props) { - return coords.equals(props.coords); - } - - public boolean contentsEqual(World world) { - if(!world.blockExists(coords.posX, coords.posY, coords.posZ)) { - invalid = true; - return false; - } - - Block block = world.getBlock(coords.posX , coords.posY, coords.posZ); - int meta = world.getBlockMetadata(coords.posX, coords.posY, coords.posZ); - return block == this.block && meta == this.meta; - } - } - + private static final String TAG_TICKS_EXISTED = "ticksExisted"; + private static final String TAG_COLOR = "color"; + private static final String TAG_MANA = "mana"; + private static final String TAG_STARTING_MANA = "startingMana"; + private static final String TAG_MIN_MANA_LOSS = "minManaLoss"; + private static final String TAG_TICK_MANA_LOSS = "manaLossTick"; + private static final String TAG_SPREADER_X = "spreaderX"; + private static final String TAG_SPREADER_Y = "spreaderY"; + private static final String TAG_SPREADER_Z = "spreaderZ"; + private static final String TAG_GRAVITY = "gravity"; + private static final String TAG_LENS_STACK = "lensStack"; + private static final String TAG_LAST_MOTION_X = "lastMotionX"; + private static final String TAG_LAST_MOTION_Y = "lastMotionY"; + private static final String TAG_LAST_MOTION_Z = "lastMotionZ"; + private static final String TAG_HAS_SHOOTER = "hasShooter"; + private static final String TAG_SHOOTER_UUID_MOST = "shooterUUIDMost"; + private static final String TAG_SHOOTER_UUID_LEAST = "shooterUUIDLeast"; + + boolean fake = false; + + final int dataWatcherEntries = 10; + final int dataWatcherStart = 32 - dataWatcherEntries; + + List alreadyCollidedAt = new ArrayList(); + + boolean fullManaLastTick = true; + + UUID shooterIdentity = null; + int _ticksExisted = 0; + boolean scanBeam = false; + public List propsList = new ArrayList(); + + public EntityManaBurst(World world) { + super(world); + setSize(0F, 0F); + for (int i = 0; i < dataWatcherEntries; i++) { + int j = dataWatcherStart + i; + if (i == 4 || i == 5) dataWatcher.addObject(j, 0F); + else if (i == 9) dataWatcher.addObject(j, new ItemStack(Blocks.stone, 0, 0)); + else dataWatcher.addObject(j, 0); + + dataWatcher.setObjectWatched(j); + } + } + + public EntityManaBurst(IManaSpreader spreader, boolean fake) { + this(((TileEntity) spreader).getWorldObj()); + + TileEntity tile = (TileEntity) spreader; + + this.fake = fake; + + setBurstSourceCoords(tile.xCoord, tile.yCoord, tile.zCoord); + setLocationAndAngles(tile.xCoord + 0.5, tile.yCoord + 0.5, tile.zCoord + 0.5, 0, 0); + rotationYaw = -(spreader.getRotationX() + 90F); + rotationPitch = spreader.getRotationY(); + + float f = 0.4F; + double mx = MathHelper.sin(rotationYaw / 180.0F * (float) Math.PI) + * MathHelper.cos(rotationPitch / 180.0F * (float) Math.PI) + * f + / 2D; + double mz = -(MathHelper.cos(rotationYaw / 180.0F * (float) Math.PI) + * MathHelper.cos(rotationPitch / 180.0F * (float) Math.PI) + * f) + / 2D; + double my = MathHelper.sin((rotationPitch + func_70183_g()) / 180.0F * (float) Math.PI) * f / 2D; + setMotion(mx, my, mz); + } + + public EntityManaBurst(EntityPlayer player) { + this(player.worldObj); + + setBurstSourceCoords(0, -1, 0); + setLocationAndAngles( + player.posX, + player.posY + player.getEyeHeight(), + player.posZ, + player.rotationYaw + 180, + -player.rotationPitch); + + posX -= MathHelper.cos((rotationYaw + 180) / 180.0F * (float) Math.PI) * 0.16F; + posY -= 0.10000000149011612D; + posZ -= MathHelper.sin((rotationYaw + 180) / 180.0F * (float) Math.PI) * 0.16F; + + setPosition(posX, posY, posZ); + yOffset = 0.0F; + float f = 0.4F; + double mx = MathHelper.sin(rotationYaw / 180.0F * (float) Math.PI) + * MathHelper.cos(rotationPitch / 180.0F * (float) Math.PI) + * f + / 2D; + double mz = -(MathHelper.cos(rotationYaw / 180.0F * (float) Math.PI) + * MathHelper.cos(rotationPitch / 180.0F * (float) Math.PI) + * f) + / 2D; + double my = MathHelper.sin((rotationPitch + func_70183_g()) / 180.0F * (float) Math.PI) * f / 2D; + setMotion(mx, my, mz); + } + + float accumulatedManaLoss = 0; + + private int ticksInAir; + + // Hacked code copied from super.onUpdate, to use Vector3 rather than the world vector pool + public void superUpdate() { + lastTickPosX = posX; + lastTickPosY = posY; + lastTickPosZ = posZ; + onEntityUpdate(); + + if (throwableShake > 0) --throwableShake; + + Vec3 vec3 = new Vector3(posX, posY, posZ).toVec3D(); + Vec3 vec31 = new Vector3(posX + motionX, posY + motionY, posZ + motionZ).toVec3D(); + MovingObjectPosition movingobjectposition = clip(vec3, vec31); + + if (movingobjectposition != null) + vec31 = new Vector3( + movingobjectposition.hitVec.xCoord, + movingobjectposition.hitVec.yCoord, + movingobjectposition.hitVec.zCoord) + .toVec3D(); + + if (!worldObj.isRemote) { + Entity entity = null; + List list = worldObj.getEntitiesWithinAABBExcludingEntity( + this, boundingBox.addCoord(motionX, motionY, motionZ).expand(1.0D, 1.0D, 1.0D)); + double d0 = 0.0D; + EntityLivingBase entitylivingbase = getThrower(); + + for (int j = 0; j < list.size(); ++j) { + Entity entity1 = (Entity) list.get(j); + + if (entity1.canBeCollidedWith() && (entity1 != entitylivingbase || ticksInAir >= 5)) { + float f = 0.3F; + AxisAlignedBB axisalignedbb = entity1.boundingBox.expand(f, f, f); + MovingObjectPosition movingobjectposition1 = axisalignedbb.calculateIntercept(vec3, vec31); + + if (movingobjectposition1 != null) { + double d1 = vec3.distanceTo(movingobjectposition1.hitVec); + + if (d1 < d0 || d0 == 0.0D) { + entity = entity1; + d0 = d1; + } + } + } + } + + if (entity != null) movingobjectposition = new MovingObjectPosition(entity); + } + + if (movingobjectposition != null) onImpact(movingobjectposition); + + posX += motionX; + posY += motionY; + posZ += motionZ; + float f1 = MathHelper.sqrt_double(motionX * motionX + motionZ * motionZ); + rotationYaw = (float) (Math.atan2(motionX, motionZ) * 180.0D / Math.PI); + + for (rotationPitch = (float) (Math.atan2(motionY, f1) * 180.0D / Math.PI); + rotationPitch - prevRotationPitch < -180.0F; + prevRotationPitch -= 360.0F) + ; + + while (rotationPitch - prevRotationPitch >= 180.0F) prevRotationPitch += 360.0F; + + while (rotationYaw - prevRotationYaw < -180.0F) prevRotationYaw -= 360.0F; + + while (rotationYaw - prevRotationYaw >= 180.0F) prevRotationYaw += 360.0F; + + rotationPitch = prevRotationPitch + (rotationPitch - prevRotationPitch) * 0.2F; + rotationYaw = prevRotationYaw + (rotationYaw - prevRotationYaw) * 0.2F; + float f3 = getGravityVelocity(); + + motionY -= f3; + setPosition(posX, posY, posZ); + } + + public MovingObjectPosition clip(Vec3 par1Vec3, Vec3 par2Vec3) { + boolean par3 = false; + boolean par4 = false; + if (!Double.isNaN(par1Vec3.xCoord) && !Double.isNaN(par1Vec3.yCoord) && !Double.isNaN(par1Vec3.zCoord)) { + if (!Double.isNaN(par2Vec3.xCoord) && !Double.isNaN(par2Vec3.yCoord) && !Double.isNaN(par2Vec3.zCoord)) { + int i = MathHelper.floor_double(par2Vec3.xCoord); + int j = MathHelper.floor_double(par2Vec3.yCoord); + int k = MathHelper.floor_double(par2Vec3.zCoord); + int l = MathHelper.floor_double(par1Vec3.xCoord); + int i1 = MathHelper.floor_double(par1Vec3.yCoord); + int j1 = MathHelper.floor_double(par1Vec3.zCoord); + Block block = worldObj.getBlock(l, i1, j1); + int l1 = worldObj.getBlockMetadata(l, i1, j1); + + if (block != null + && (!par4 + || block == null + || block.getCollisionBoundingBoxFromPool(worldObj, l, i1, j1) != null) + && block != Blocks.air + && block.canCollideCheck(l1, par3)) { + MovingObjectPosition movingobjectposition = + block.collisionRayTrace(worldObj, l, i1, j1, par1Vec3, par2Vec3); + + if (movingobjectposition != null) return movingobjectposition; + } + + int k1 = 200; + + while (k1-- >= 0) { + if (Double.isNaN(par1Vec3.xCoord) || Double.isNaN(par1Vec3.yCoord) || Double.isNaN(par1Vec3.zCoord)) + return null; + + if (l == i && i1 == j && j1 == k) return null; + + boolean flag2 = true; + boolean flag3 = true; + boolean flag4 = true; + double d0 = 999.0D; + double d1 = 999.0D; + double d2 = 999.0D; + + if (i > l) d0 = l + 1.0D; + else if (i < l) d0 = l + 0.0D; + else flag2 = false; + + if (j > i1) d1 = i1 + 1.0D; + else if (j < i1) d1 = i1 + 0.0D; + else flag3 = false; + + if (k > j1) d2 = j1 + 1.0D; + else if (k < j1) d2 = j1 + 0.0D; + else flag4 = false; + + double d3 = 999.0D; + double d4 = 999.0D; + double d5 = 999.0D; + double d6 = par2Vec3.xCoord - par1Vec3.xCoord; + double d7 = par2Vec3.yCoord - par1Vec3.yCoord; + double d8 = par2Vec3.zCoord - par1Vec3.zCoord; + + if (flag2) d3 = (d0 - par1Vec3.xCoord) / d6; + + if (flag3) d4 = (d1 - par1Vec3.yCoord) / d7; + + if (flag4) d5 = (d2 - par1Vec3.zCoord) / d8; + + byte b0; + + if (d3 < d4 && d3 < d5) { + if (i > l) b0 = 4; + else b0 = 5; + + par1Vec3.xCoord = d0; + par1Vec3.yCoord += d7 * d3; + par1Vec3.zCoord += d8 * d3; + } else if (d4 < d5) { + if (j > i1) b0 = 0; + else b0 = 1; + + par1Vec3.xCoord += d6 * d4; + par1Vec3.yCoord = d1; + par1Vec3.zCoord += d8 * d4; + } else { + if (k > j1) b0 = 2; + else b0 = 3; + + par1Vec3.xCoord += d6 * d5; + par1Vec3.yCoord += d7 * d5; + par1Vec3.zCoord = d2; + } + + Vec3 vec32 = new Vector3(par1Vec3.xCoord, par1Vec3.yCoord, par1Vec3.zCoord).toVec3D(); + l = (int) (vec32.xCoord = MathHelper.floor_double(par1Vec3.xCoord)); + + if (b0 == 5) { + --l; + ++vec32.xCoord; + } + + i1 = (int) (vec32.yCoord = MathHelper.floor_double(par1Vec3.yCoord)); + + if (b0 == 1) { + --i1; + ++vec32.yCoord; + } + + j1 = (int) (vec32.zCoord = MathHelper.floor_double(par1Vec3.zCoord)); + + if (b0 == 3) { + --j1; + ++vec32.zCoord; + } + + Block block1 = worldObj.getBlock(l, i1, j1); + int j2 = worldObj.getBlockMetadata(l, i1, j1); + + if ((!par4 || block1 == null || block1.getCollisionBoundingBoxFromPool(worldObj, l, i1, j1) != null) + && block1 != Blocks.air + && block1.canCollideCheck(j2, par3)) { + MovingObjectPosition movingobjectposition1 = + block1.collisionRayTrace(worldObj, l, i1, j1, par1Vec3, par2Vec3); + + if (movingobjectposition1 != null) return movingobjectposition1; + } + } + + return null; + } else return null; + } else return null; + } + + @Override + public void onUpdate() { + setTicksExisted(getTicksExisted() + 1); + superUpdate(); + + if (!fake && !isDead) ping(); + + ILensEffect lens = getLensInstance(); + if (lens != null) lens.updateBurst(this, getSourceLens()); + + int mana = getMana(); + if (getTicksExisted() >= getMinManaLoss()) { + accumulatedManaLoss += getManaLossPerTick(); + int loss = (int) accumulatedManaLoss; + setMana(mana - loss); + accumulatedManaLoss -= loss; + + if (getMana() <= 0) setDead(); + } + + particles(); + + setMotion(motionX, motionY, motionZ); + + fullManaLastTick = getMana() == getStartingMana(); + + if (scanBeam) { + PositionProperties props = new PositionProperties(this); + if (propsList.isEmpty()) propsList.add(props); + else { + PositionProperties lastProps = propsList.get(propsList.size() - 1); + if (!props.coordsEqual(lastProps)) propsList.add(props); + } + } + } + + @Override + @SideOnly(Side.CLIENT) + public void setPositionAndRotation2( + double p_70056_1_, + double p_70056_3_, + double p_70056_5_, + float p_70056_7_, + float p_70056_8_, + int p_70056_9_) { + setPosition(p_70056_1_, p_70056_3_, p_70056_5_); + setRotation(p_70056_7_, p_70056_8_); + } + + @Override + public boolean handleWaterMovement() { + return false; + } + + public TileEntity collidedTile = null; + public boolean noParticles = false; + + public TileEntity getCollidedTile(boolean noParticles) { + this.noParticles = noParticles; + + while (!isDead) onUpdate(); + + if (fake) incrementFakeParticleTick(); + + return collidedTile; + } + + @Override + public void writeEntityToNBT(NBTTagCompound par1nbtTagCompound) { + super.writeEntityToNBT(par1nbtTagCompound); + par1nbtTagCompound.setInteger(TAG_TICKS_EXISTED, getTicksExisted()); + par1nbtTagCompound.setInteger(TAG_COLOR, getColor()); + par1nbtTagCompound.setInteger(TAG_MANA, getMana()); + par1nbtTagCompound.setInteger(TAG_STARTING_MANA, getStartingMana()); + par1nbtTagCompound.setInteger(TAG_MIN_MANA_LOSS, getMinManaLoss()); + par1nbtTagCompound.setFloat(TAG_TICK_MANA_LOSS, getManaLossPerTick()); + par1nbtTagCompound.setFloat(TAG_GRAVITY, getGravity()); + + ItemStack stack = getSourceLens(); + NBTTagCompound lensCmp = new NBTTagCompound(); + if (stack != null) stack.writeToNBT(lensCmp); + par1nbtTagCompound.setTag(TAG_LENS_STACK, lensCmp); + + ChunkCoordinates coords = getBurstSourceChunkCoordinates(); + par1nbtTagCompound.setInteger(TAG_SPREADER_X, coords.posX); + par1nbtTagCompound.setInteger(TAG_SPREADER_Y, coords.posY); + par1nbtTagCompound.setInteger(TAG_SPREADER_Z, coords.posZ); + + par1nbtTagCompound.setDouble(TAG_LAST_MOTION_X, motionX); + par1nbtTagCompound.setDouble(TAG_LAST_MOTION_Y, motionY); + par1nbtTagCompound.setDouble(TAG_LAST_MOTION_Z, motionZ); + + UUID identity = getShooterUIID(); + boolean hasShooter = identity != null; + par1nbtTagCompound.setBoolean(TAG_HAS_SHOOTER, hasShooter); + if (hasShooter) { + par1nbtTagCompound.setLong(TAG_SHOOTER_UUID_MOST, identity.getMostSignificantBits()); + par1nbtTagCompound.setLong(TAG_SHOOTER_UUID_LEAST, identity.getLeastSignificantBits()); + } + } + + @Override + public void readEntityFromNBT(NBTTagCompound par1nbtTagCompound) { + super.readEntityFromNBT(par1nbtTagCompound); + setTicksExisted(par1nbtTagCompound.getInteger(TAG_TICKS_EXISTED)); + setColor(par1nbtTagCompound.getInteger(TAG_COLOR)); + setMana(par1nbtTagCompound.getInteger(TAG_MANA)); + setStartingMana(par1nbtTagCompound.getInteger(TAG_STARTING_MANA)); + setMinManaLoss(par1nbtTagCompound.getInteger(TAG_MIN_MANA_LOSS)); + setManaLossPerTick(par1nbtTagCompound.getFloat(TAG_TICK_MANA_LOSS)); + setGravity(par1nbtTagCompound.getFloat(TAG_GRAVITY)); + + NBTTagCompound lensCmp = par1nbtTagCompound.getCompoundTag(TAG_LENS_STACK); + ItemStack stack = ItemStack.loadItemStackFromNBT(lensCmp); + if (stack != null) setSourceLens(stack); + else setSourceLens(new ItemStack(Blocks.stone, 0, 0)); + + int x = par1nbtTagCompound.getInteger(TAG_SPREADER_X); + int y = par1nbtTagCompound.getInteger(TAG_SPREADER_Y); + int z = par1nbtTagCompound.getInteger(TAG_SPREADER_Z); + + setBurstSourceCoords(x, y, z); + + double lastMotionX = par1nbtTagCompound.getDouble(TAG_LAST_MOTION_X); + double lastMotionY = par1nbtTagCompound.getDouble(TAG_LAST_MOTION_Y); + double lastMotionZ = par1nbtTagCompound.getDouble(TAG_LAST_MOTION_Z); + + setMotion(lastMotionX, lastMotionY, lastMotionZ); + + boolean hasShooter = par1nbtTagCompound.getBoolean(TAG_HAS_SHOOTER); + if (hasShooter) { + long most = par1nbtTagCompound.getLong(TAG_SHOOTER_UUID_MOST); + long least = par1nbtTagCompound.getLong(TAG_SHOOTER_UUID_LEAST); + UUID identity = getShooterUIID(); + if (identity == null + || most != identity.getMostSignificantBits() + || least != identity.getLeastSignificantBits()) shooterIdentity = new UUID(most, least); + } + } + + public void particles() { + if (isDead || !worldObj.isRemote) return; + + ILensEffect lens = getLensInstance(); + if (lens != null && !lens.doParticles(this, getSourceLens())) return; + + Color color = new Color(getColor()); + float r = color.getRed() / 255F; + float g = color.getGreen() / 255F; + float b = color.getBlue() / 255F; + + int mana = getMana(); + int maxMana = getStartingMana(); + float osize = (float) mana / (float) maxMana; + float size = osize; + + if (fake) { + if (getMana() == getStartingMana()) size = 2F; + else if (fullManaLastTick) size = 4F; + + if (!noParticles && shouldDoFakeParticles()) + Botania.proxy.sparkleFX(worldObj, posX, posY, posZ, r, g, b, 0.4F * size, 1, true); + } else { + boolean monocle = Botania.proxy.isClientPlayerWearingMonocle(); + if (monocle) Botania.proxy.setWispFXDepthTest(false); + + if (ConfigHandler.subtlePowerSystem) + Botania.proxy.wispFX( + worldObj, + posX, + posY, + posZ, + r, + g, + b, + 0.1F * size, + (float) (Math.random() - 0.5F) * 0.02F, + (float) (Math.random() - 0.5F) * 0.02F, + (float) (Math.random() - 0.5F) * 0.01F); + else { + float or = r; + float og = g; + float ob = b; + + double savedPosX = posX; + double savedPosY = posY; + double savedPosZ = posZ; + + Vector3 currentPos = Vector3.fromEntity(this); + Vector3 oldPos = new Vector3(prevPosX, prevPosY, prevPosZ); + Vector3 diffVec = oldPos.copy().sub(currentPos); + Vector3 diffVecNorm = diffVec.copy().normalize(); + + double distance = 0.095; + + do { + r = or + ((float) Math.random() - 0.5F) * 0.25F; + g = og + ((float) Math.random() - 0.5F) * 0.25F; + b = ob + ((float) Math.random() - 0.5F) * 0.25F; + size = osize + + ((float) Math.random() - 0.5F) * 0.065F + + (float) Math.sin(new Random(entityUniqueID.getMostSignificantBits()).nextInt(9001)) + * 0.4F; + Botania.proxy.wispFX( + worldObj, + posX, + posY, + posZ, + r, + g, + b, + 0.2F * size, + (float) -motionX * 0.01F, + (float) -motionY * 0.01F, + (float) -motionZ * 0.01F); + + posX += diffVecNorm.x * distance; + posY += diffVecNorm.y * distance; + posZ += diffVecNorm.z * distance; + + currentPos = Vector3.fromEntity(this); + diffVec = oldPos.copy().sub(currentPos); + if (getEntityData().hasKey(ItemTinyPlanet.TAG_ORBIT)) break; + } while (Math.abs(diffVec.mag()) > distance); + + Botania.proxy.wispFX( + worldObj, + posX, + posY, + posZ, + r, + g, + b, + 0.1F * size, + (float) (Math.random() - 0.5F) * 0.06F, + (float) (Math.random() - 0.5F) * 0.06F, + (float) (Math.random() - 0.5F) * 0.06F); + + posX = savedPosX; + posY = savedPosY; + posZ = savedPosZ; + } + + if (monocle) Botania.proxy.setWispFXDepthTest(true); + } + } + + @Override + protected void onImpact(MovingObjectPosition movingobjectposition) { + boolean collided = false; + boolean dead = false; + + if (movingobjectposition.entityHit == null) { + TileEntity tile = worldObj.getTileEntity( + movingobjectposition.blockX, movingobjectposition.blockY, movingobjectposition.blockZ); + Block block = worldObj.getBlock( + movingobjectposition.blockX, movingobjectposition.blockY, movingobjectposition.blockZ); + + if (tile instanceof IManaCollisionGhost + && ((IManaCollisionGhost) tile).isGhost() + && !(block instanceof IManaTrigger) + || block instanceof BlockBush + || block instanceof BlockLeaves) return; + + if (BotaniaAPI.internalHandler.isBuildcraftPipe(tile)) return; + + ChunkCoordinates coords = getBurstSourceChunkCoordinates(); + if (tile != null + && (tile.xCoord != coords.posX || tile.yCoord != coords.posY || tile.zCoord != coords.posZ)) + collidedTile = tile; + + if (tile == null + || tile.xCoord != coords.posX + || tile.yCoord != coords.posY + || tile.zCoord != coords.posZ) { + if (!fake + && !noParticles + && (!worldObj.isRemote || tile instanceof IClientManaHandler) + && tile != null + && tile instanceof IManaReceiver + && ((IManaReceiver) tile).canRecieveManaFromBursts()) + onRecieverImpact((IManaReceiver) tile, tile.xCoord, tile.yCoord, tile.zCoord); + + if (block instanceof IManaTrigger) + ((IManaTrigger) block) + .onBurstCollision( + this, + worldObj, + movingobjectposition.blockX, + movingobjectposition.blockY, + movingobjectposition.blockZ); + + boolean ghost = tile instanceof IManaCollisionGhost; + dead = !ghost; + if (ghost) return; + } + + collided = true; + } + + ILensEffect lens = getLensInstance(); + if (lens != null) + dead = lens.collideBurst( + this, + movingobjectposition, + collidedTile != null + && collidedTile instanceof IManaReceiver + && ((IManaReceiver) collidedTile).canRecieveManaFromBursts(), + dead, + getSourceLens()); + + if (collided + && !hasAlreadyCollidedAt( + movingobjectposition.blockX, movingobjectposition.blockY, movingobjectposition.blockZ)) + alreadyCollidedAt.add(getCollisionLocString( + movingobjectposition.blockX, movingobjectposition.blockY, movingobjectposition.blockZ)); + + if (dead && !isDead) { + if (!fake) { + Color color = new Color(getColor()); + float r = color.getRed() / 255F; + float g = color.getGreen() / 255F; + float b = color.getBlue() / 255F; + + int mana = getMana(); + int maxMana = getStartingMana(); + float size = (float) mana / (float) maxMana; + + if (!ConfigHandler.subtlePowerSystem) + for (int i = 0; i < 4; i++) + Botania.proxy.wispFX( + worldObj, + posX, + posY, + posZ, + r, + g, + b, + 0.15F * size, + (float) (Math.random() - 0.5F) * 0.04F, + (float) (Math.random() - 0.5F) * 0.04F, + (float) (Math.random() - 0.5F) * 0.04F); + Botania.proxy.sparkleFX(worldObj, (float) posX, (float) posY, (float) posZ, r, g, b, 4, 2); + } + + setDead(); + } + } + + protected void onRecieverImpact(IManaReceiver tile, int x, int y, int z) { + int mana = getMana(); + if (tile instanceof IManaCollector) mana *= ((IManaCollector) tile).getManaYieldMultiplier(this); + + tile.recieveMana(mana); + if (tile instanceof IThrottledPacket) ((IThrottledPacket) tile).markDispatchable(); + else VanillaPacketDispatcher.dispatchTEToNearbyPlayers(worldObj, x, y, z); + } + + @Override + public void setDead() { + super.setDead(); + + if (!fake) { + TileEntity tile = getShooter(); + if (tile != null && tile instanceof IManaSpreader) ((IManaSpreader) tile).setCanShoot(true); + } else setDeathTicksForFakeParticle(); + } + + public TileEntity getShooter() { + ChunkCoordinates coords = getBurstSourceChunkCoordinates(); + TileEntity tile = worldObj.getTileEntity(coords.posX, coords.posY, coords.posZ); + return tile; + } + + @Override + protected float getGravityVelocity() { + return getGravity(); + } + + @Override + public boolean isFake() { + return fake; + } + + @Override + public void setFake(boolean fake) { + this.fake = fake; + } + + public void setScanBeam() { + scanBeam = true; + } + + @Override + public int getColor() { + return dataWatcher.getWatchableObjectInt(dataWatcherStart); + } + + @Override + public void setColor(int color) { + dataWatcher.updateObject(dataWatcherStart, color); + } + + @Override + public int getMana() { + return dataWatcher.getWatchableObjectInt(dataWatcherStart + 1); + } + + @Override + public void setMana(int mana) { + dataWatcher.updateObject(dataWatcherStart + 1, mana); + } + + @Override + public int getStartingMana() { + return dataWatcher.getWatchableObjectInt(dataWatcherStart + 2); + } + + @Override + public void setStartingMana(int mana) { + dataWatcher.updateObject(dataWatcherStart + 2, mana); + } + + @Override + public int getMinManaLoss() { + return dataWatcher.getWatchableObjectInt(dataWatcherStart + 3); + } + + @Override + public void setMinManaLoss(int minManaLoss) { + dataWatcher.updateObject(dataWatcherStart + 3, minManaLoss); + } + + @Override + public float getManaLossPerTick() { + return dataWatcher.getWatchableObjectFloat(dataWatcherStart + 4); + } + + @Override + public void setManaLossPerTick(float mana) { + dataWatcher.updateObject(dataWatcherStart + 4, mana); + } + + @Override + public float getGravity() { + return dataWatcher.getWatchableObjectFloat(dataWatcherStart + 5); + } + + @Override + public void setGravity(float gravity) { + dataWatcher.updateObject(dataWatcherStart + 5, gravity); + } + + final int coordsStart = dataWatcherStart + 6; + + @Override + public ChunkCoordinates getBurstSourceChunkCoordinates() { + int x = dataWatcher.getWatchableObjectInt(coordsStart); + int y = dataWatcher.getWatchableObjectInt(coordsStart + 1); + int z = dataWatcher.getWatchableObjectInt(coordsStart + 2); + + return new ChunkCoordinates(x, y, z); + } + + @Override + public void setBurstSourceCoords(int x, int y, int z) { + dataWatcher.updateObject(coordsStart, x); + dataWatcher.updateObject(coordsStart + 1, y); + dataWatcher.updateObject(coordsStart + 2, z); + } + + @Override + public ItemStack getSourceLens() { + return dataWatcher.getWatchableObjectItemStack(dataWatcherStart + 9); + } + + @Override + public void setSourceLens(ItemStack lens) { + dataWatcher.updateObject(dataWatcherStart + 9, lens == null ? new ItemStack(Blocks.stone, 0, 0) : lens); + } + + @Override + public int getTicksExisted() { + return _ticksExisted; + } + + public void setTicksExisted(int ticks) { + _ticksExisted = ticks; + } + + public ILensEffect getLensInstance() { + ItemStack lens = getSourceLens(); + if (lens != null && lens.getItem() instanceof ILensEffect) return (ILensEffect) lens.getItem(); + + return null; + } + + final int motionStart = dataWatcherStart + 10; + + @Override + public void setMotion(double x, double y, double z) { + motionX = x; + motionY = y; + motionZ = z; + } + + @Override + public boolean hasAlreadyCollidedAt(int x, int y, int z) { + return alreadyCollidedAt.contains(getCollisionLocString(x, y, z)); + } + + @Override + public void setCollidedAt(int x, int y, int z) { + if (!hasAlreadyCollidedAt(x, y, z)) alreadyCollidedAt.add(getCollisionLocString(x, y, z)); + } + + private String getCollisionLocString(int x, int y, int z) { + return x + ":" + y + ":" + z; + } + + @Override + public void setShooterUUID(UUID uuid) { + shooterIdentity = uuid; + } + + @Override + public UUID getShooterUIID() { + return shooterIdentity; + } + + @Override + public void ping() { + TileEntity tile = getShooter(); + if (tile != null && tile instanceof IPingable) ((IPingable) tile).pingback(this, getShooterUIID()); + } + + public boolean shouldDoFakeParticles() { + if (ConfigHandler.staticWandBeam) return true; + + TileEntity tile = getShooter(); + if (tile != null && tile instanceof IManaSpreader) + return getMana() != getStartingMana() && fullManaLastTick + || Math.abs(((IManaSpreader) tile).getBurstParticleTick() - getTicksExisted()) < 4; + return false; + } + + public void incrementFakeParticleTick() { + TileEntity tile = getShooter(); + if (tile != null && tile instanceof IManaSpreader) { + IManaSpreader spreader = (IManaSpreader) tile; + spreader.setBurstParticleTick(spreader.getBurstParticleTick() + 2); + if (spreader.getLastBurstDeathTick() != -1 + && spreader.getBurstParticleTick() > spreader.getLastBurstDeathTick()) + spreader.setBurstParticleTick(0); + } + } + + public void setDeathTicksForFakeParticle() { + ChunkCoordinates coords = getBurstSourceChunkCoordinates(); + TileEntity tile = worldObj.getTileEntity(coords.posX, coords.posY, coords.posZ); + if (tile != null && tile instanceof IManaSpreader) + ((IManaSpreader) tile).setLastBurstDeathTick(getTicksExisted()); + } + + public static class PositionProperties { + + public final ChunkCoordinates coords; + public final Block block; + public final int meta; + + public boolean invalid = false; + + public PositionProperties(Entity entity) { + int x = MathHelper.floor_double(entity.posX); + int y = MathHelper.floor_double(entity.posY); + int z = MathHelper.floor_double(entity.posZ); + coords = new ChunkCoordinates(x, y, z); + block = entity.worldObj.getBlock(x, y, z); + meta = entity.worldObj.getBlockMetadata(x, y, z); + } + + public boolean coordsEqual(PositionProperties props) { + return coords.equals(props.coords); + } + + public boolean contentsEqual(World world) { + if (!world.blockExists(coords.posX, coords.posY, coords.posZ)) { + invalid = true; + return false; + } + + Block block = world.getBlock(coords.posX, coords.posY, coords.posZ); + int meta = world.getBlockMetadata(coords.posX, coords.posY, coords.posZ); + return block == this.block && meta == this.meta; + } + } } diff --git a/src/main/java/vazkii/botania/common/entity/EntityManaStorm.java b/src/main/java/vazkii/botania/common/entity/EntityManaStorm.java index 4343aad6cf..47a7153f5a 100644 --- a/src/main/java/vazkii/botania/common/entity/EntityManaStorm.java +++ b/src/main/java/vazkii/botania/common/entity/EntityManaStorm.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jul 25, 2015, 12:35:51 AM (GMT)] */ package vazkii.botania.common.entity; @@ -20,79 +20,79 @@ public class EntityManaStorm extends Entity { - private static final String TAG_TIME = "time"; - private static final String TAG_BURSTS_FIRED = "burstsFired"; - private static final String TAG_DEATH_TIME = "deathTime"; - - public static final int TOTAL_BURSTS = 250; - public static final int DEATH_TIME = 200; - - public int liveTime; - public int burstsFired; - public int deathTime; - - public EntityManaStorm(World p_i1582_1_) { - super(p_i1582_1_); - } - - @Override - protected void entityInit() { - // NO-OP - } - - @Override - public void onUpdate() { - super.onUpdate(); - liveTime++; - - int diffTime = Math.max(1, 30 - (int) (liveTime / 45f)); - if(burstsFired < TOTAL_BURSTS && liveTime % diffTime == 0) { - if(!worldObj.isRemote) - spawnBurst(); - burstsFired++; - } - - if(burstsFired >= TOTAL_BURSTS) { - deathTime++; - if(deathTime >= DEATH_TIME) { - setDead(); - worldObj.newExplosion(this, posX, posY, posZ, 8F, true, true); - } - } - } - - public void spawnBurst() { - EntityManaBurst burst = new EntityManaBurst(worldObj); - burst.setPosition(posX, posY, posZ); - - float motionModifier = 0.5F; - burst.setColor(0x20FF20); - burst.setMana(120); - burst.setStartingMana(340); - burst.setMinManaLoss(50); - burst.setManaLossPerTick(1F); - burst.setGravity(0F); - - ItemStack lens = new ItemStack(ModItems.lens, 1, ItemLens.STORM); - burst.setSourceLens(lens); - - Vector3 motion = new Vector3(Math.random() - 0.5, Math.random() - 0.5, Math.random() - 0.5).normalize().multiply(motionModifier); - burst.setMotion(motion.x, motion.y, motion.z); - worldObj.spawnEntityInWorld(burst); - } - - @Override - protected void readEntityFromNBT(NBTTagCompound cmp) { - liveTime = cmp.getInteger(TAG_TIME); - burstsFired = cmp.getInteger(TAG_BURSTS_FIRED); - deathTime = cmp.getInteger(TAG_DEATH_TIME); - } - - @Override - protected void writeEntityToNBT(NBTTagCompound cmp) { - cmp.setInteger(TAG_TIME, liveTime); - cmp.setInteger(TAG_BURSTS_FIRED, burstsFired); - cmp.setInteger(TAG_DEATH_TIME, deathTime); - } - + private static final String TAG_TIME = "time"; + private static final String TAG_BURSTS_FIRED = "burstsFired"; + private static final String TAG_DEATH_TIME = "deathTime"; + + public static final int TOTAL_BURSTS = 250; + public static final int DEATH_TIME = 200; + + public int liveTime; + public int burstsFired; + public int deathTime; + + public EntityManaStorm(World p_i1582_1_) { + super(p_i1582_1_); + } + + @Override + protected void entityInit() { + // NO-OP + } + + @Override + public void onUpdate() { + super.onUpdate(); + liveTime++; + + int diffTime = Math.max(1, 30 - (int) (liveTime / 45f)); + if (burstsFired < TOTAL_BURSTS && liveTime % diffTime == 0) { + if (!worldObj.isRemote) spawnBurst(); + burstsFired++; + } + + if (burstsFired >= TOTAL_BURSTS) { + deathTime++; + if (deathTime >= DEATH_TIME) { + setDead(); + worldObj.newExplosion(this, posX, posY, posZ, 8F, true, true); + } + } + } + + public void spawnBurst() { + EntityManaBurst burst = new EntityManaBurst(worldObj); + burst.setPosition(posX, posY, posZ); + + float motionModifier = 0.5F; + burst.setColor(0x20FF20); + burst.setMana(120); + burst.setStartingMana(340); + burst.setMinManaLoss(50); + burst.setManaLossPerTick(1F); + burst.setGravity(0F); + + ItemStack lens = new ItemStack(ModItems.lens, 1, ItemLens.STORM); + burst.setSourceLens(lens); + + Vector3 motion = new Vector3(Math.random() - 0.5, Math.random() - 0.5, Math.random() - 0.5) + .normalize() + .multiply(motionModifier); + burst.setMotion(motion.x, motion.y, motion.z); + worldObj.spawnEntityInWorld(burst); + } + + @Override + protected void readEntityFromNBT(NBTTagCompound cmp) { + liveTime = cmp.getInteger(TAG_TIME); + burstsFired = cmp.getInteger(TAG_BURSTS_FIRED); + deathTime = cmp.getInteger(TAG_DEATH_TIME); + } + + @Override + protected void writeEntityToNBT(NBTTagCompound cmp) { + cmp.setInteger(TAG_TIME, liveTime); + cmp.setInteger(TAG_BURSTS_FIRED, burstsFired); + cmp.setInteger(TAG_DEATH_TIME, deathTime); + } } diff --git a/src/main/java/vazkii/botania/common/entity/EntityPinkWither.java b/src/main/java/vazkii/botania/common/entity/EntityPinkWither.java index 8d050076eb..3baa2e4763 100644 --- a/src/main/java/vazkii/botania/common/entity/EntityPinkWither.java +++ b/src/main/java/vazkii/botania/common/entity/EntityPinkWither.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Mar 25, 2015, 5:49:28 PM (GMT)] */ package vazkii.botania.common.entity; @@ -19,89 +19,87 @@ public class EntityPinkWither extends EntityWither { - public EntityPinkWither(World p_i1701_1_) { - super(p_i1701_1_); - } + public EntityPinkWither(World p_i1701_1_) { + super(p_i1701_1_); + } - @Override - public void onLivingUpdate() { - super.onLivingUpdate(); + @Override + public void onLivingUpdate() { + super.onLivingUpdate(); - if(Math.random() < 0.1) - for(int j = 0; j < 3; ++j) { - double d10 = func_82214_u(j); - double d2 = func_82208_v(j); - double d4 = func_82213_w(j); - worldObj.spawnParticle("heart", d10 + rand.nextGaussian() * 0.30000001192092896D, d2 + rand.nextGaussian() * 0.30000001192092896D, d4 + rand.nextGaussian() * 0.30000001192092896D, 0.0D, 0.0D, 0.0D); - } - } + if (Math.random() < 0.1) + for (int j = 0; j < 3; ++j) { + double d10 = func_82214_u(j); + double d2 = func_82208_v(j); + double d4 = func_82213_w(j); + worldObj.spawnParticle( + "heart", + d10 + rand.nextGaussian() * 0.30000001192092896D, + d2 + rand.nextGaussian() * 0.30000001192092896D, + d4 + rand.nextGaussian() * 0.30000001192092896D, + 0.0D, + 0.0D, + 0.0D); + } + } - @Override - public void setAttackTarget(EntityLivingBase p_70624_1_) { - // NO-OP - } + @Override + public void setAttackTarget(EntityLivingBase p_70624_1_) { + // NO-OP + } - @Override - protected void attackEntity(Entity p_70785_1_, float p_70785_2_) { - // NO-OP - } + @Override + protected void attackEntity(Entity p_70785_1_, float p_70785_2_) { + // NO-OP + } - @Override - public boolean attackEntityAsMob(Entity p_70652_1_) { - return false; - } + @Override + public boolean attackEntityAsMob(Entity p_70652_1_) { + return false; + } - @Override - protected boolean interact(EntityPlayer player) { - if(!player.isSneaking()) { - player.mountEntity(this); - return true; - } - return false; - } + @Override + protected boolean interact(EntityPlayer player) { + if (!player.isSneaking()) { + player.mountEntity(this); + return true; + } + return false; + } - @Override - protected boolean isAIEnabled() { - return false; - } + @Override + protected boolean isAIEnabled() { + return false; + } - @Override - protected void dropFewItems(boolean p_70628_1_, int p_70628_2_) { - // NO-OP - } + @Override + protected void dropFewItems(boolean p_70628_1_, int p_70628_2_) { + // NO-OP + } - // COPYPASTA + // COPYPASTA - private double func_82214_u(int p_82214_1_) - { - if (p_82214_1_ <= 0) - { - return posX; - } - else - { - float f = (renderYawOffset + 180 * (p_82214_1_ - 1)) / 180.0F * (float)Math.PI; - float f1 = MathHelper.cos(f); - return posX + f1 * 1.3D; - } - } + private double func_82214_u(int p_82214_1_) { + if (p_82214_1_ <= 0) { + return posX; + } else { + float f = (renderYawOffset + 180 * (p_82214_1_ - 1)) / 180.0F * (float) Math.PI; + float f1 = MathHelper.cos(f); + return posX + f1 * 1.3D; + } + } - private double func_82208_v(int p_82208_1_) - { - return p_82208_1_ <= 0 ? posY + 3.0D : posY + 2.2D; - } + private double func_82208_v(int p_82208_1_) { + return p_82208_1_ <= 0 ? posY + 3.0D : posY + 2.2D; + } - private double func_82213_w(int p_82213_1_) - { - if (p_82213_1_ <= 0) - { - return posZ; - } - else - { - float f = (renderYawOffset + 180 * (p_82213_1_ - 1)) / 180.0F * (float)Math.PI; - float f1 = MathHelper.sin(f); - return posZ + f1 * 1.3D; - } - } + private double func_82213_w(int p_82213_1_) { + if (p_82213_1_ <= 0) { + return posZ; + } else { + float f = (renderYawOffset + 180 * (p_82213_1_ - 1)) / 180.0F * (float) Math.PI; + float f1 = MathHelper.sin(f); + return posZ + f1 * 1.3D; + } + } } diff --git a/src/main/java/vazkii/botania/common/entity/EntityPixie.java b/src/main/java/vazkii/botania/common/entity/EntityPixie.java index 870a13f720..850b4b0243 100644 --- a/src/main/java/vazkii/botania/common/entity/EntityPixie.java +++ b/src/main/java/vazkii/botania/common/entity/EntityPixie.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [? (GMT)] */ package vazkii.botania.common.entity; @@ -20,111 +20,126 @@ public class EntityPixie extends EntityFlyingCreature { - EntityLivingBase summoner = null; - float damage = 0; - PotionEffect effect = null; - - public EntityPixie(World world) { - super(world); - setSize(1.0F, 1.0F); - } - - @Override - protected void entityInit() { - super.entityInit(); - dataWatcher.addObject(20, 0); - } - - @Override - protected void applyEntityAttributes() { - super.applyEntityAttributes(); - getEntityAttribute(SharedMonsterAttributes.maxHealth).setBaseValue(2.0); - } - - public void setType(int type) { - dataWatcher.updateObject(20, type); - } - - public int getType() { - return dataWatcher.getWatchableObjectInt(20); - } - - public void setProps(EntityLivingBase target, EntityLivingBase summoner, int type, float damage) { - setAttackTarget(target); - this.summoner = summoner; - this.damage = damage; - setType(type); - } - - public void setApplyPotionEffect(PotionEffect effect) { - this.effect = effect; - } - - @Override - protected void updateEntityActionState() { - EntityLivingBase target = getAttackTarget(); - if(target != null) { - double d0 = target.posX + target.width / 2 - posX; - double d1 = target.posY + target.height / 2 - posY; - double d2 = target.posZ + target.width / 2 - posZ; - double d3 = d0 * d0 + d1 * d1 + d2 * d2; - - float mod = 0.45F; - if(getType() == 1) - mod = 0.1F; - - motionX += d0 / d3 * mod; - motionY += d1 / d3 * mod; - motionZ += d2 / d3 * mod; - - if(Math.sqrt(d3) < 1F) { - if(summoner != null) { - if(summoner instanceof EntityPlayer) - target.attackEntityFrom(DamageSource.causePlayerDamage((EntityPlayer) summoner), damage); - else { - target.attackEntityFrom(DamageSource.causeMobDamage(summoner), damage); - } - } else target.attackEntityFrom(DamageSource.causeMobDamage(this), damage); - if(effect != null && !(target instanceof EntityPlayer)) - target.addPotionEffect(effect); - die(); - } - } - - renderYawOffset = rotationYaw = -((float)Math.atan2(motionX, motionZ)) * 180.0F / (float)Math.PI; - } - - @Override - public boolean attackEntityFrom(DamageSource par1DamageSource, float par2) { - if(getType() == 0 && par1DamageSource.getEntity() != summoner || getType() == 1 && par1DamageSource.getEntity() instanceof EntityPlayer) - return super.attackEntityFrom(par1DamageSource, par2); - return false; - } - - @Override - public void onEntityUpdate() { - super.onEntityUpdate(); - - if(getAttackTarget() == null || ticksExisted > 200) - die(); - - boolean dark = getType() == 1; - if(worldObj.isRemote) - for(int i = 0; i < 4; i++) - Botania.proxy.sparkleFX(worldObj, posX + (Math.random() - 0.5) * 0.25, posY + 0.5 + (Math.random() - 0.5) * 0.25, posZ + (Math.random() - 0.5) * 0.25, dark ? 0.1F : 1F, dark ? 0.025F : 0.25F, dark ? 0.09F : 0.9F, 0.1F + (float) Math.random() * 0.25F, 12); - } - - public void die() { - setDead(); - - if(worldObj.isRemote && getType() == 0) - for(int i = 0; i < 12; i++) - Botania.proxy.sparkleFX(worldObj, posX + (Math.random() - 0.5) * 0.25, posY + 0.5 + (Math.random() - 0.5) * 0.25, posZ + (Math.random() - 0.5) * 0.25, 1F, 0.25F, 0.9F, 1F + (float) Math.random() * 0.25F, 5); - } - - @Override - protected boolean canDespawn() { - return false; - } - -} \ No newline at end of file + EntityLivingBase summoner = null; + float damage = 0; + PotionEffect effect = null; + + public EntityPixie(World world) { + super(world); + setSize(1.0F, 1.0F); + } + + @Override + protected void entityInit() { + super.entityInit(); + dataWatcher.addObject(20, 0); + } + + @Override + protected void applyEntityAttributes() { + super.applyEntityAttributes(); + getEntityAttribute(SharedMonsterAttributes.maxHealth).setBaseValue(2.0); + } + + public void setType(int type) { + dataWatcher.updateObject(20, type); + } + + public int getType() { + return dataWatcher.getWatchableObjectInt(20); + } + + public void setProps(EntityLivingBase target, EntityLivingBase summoner, int type, float damage) { + setAttackTarget(target); + this.summoner = summoner; + this.damage = damage; + setType(type); + } + + public void setApplyPotionEffect(PotionEffect effect) { + this.effect = effect; + } + + @Override + protected void updateEntityActionState() { + EntityLivingBase target = getAttackTarget(); + if (target != null) { + double d0 = target.posX + target.width / 2 - posX; + double d1 = target.posY + target.height / 2 - posY; + double d2 = target.posZ + target.width / 2 - posZ; + double d3 = d0 * d0 + d1 * d1 + d2 * d2; + + float mod = 0.45F; + if (getType() == 1) mod = 0.1F; + + motionX += d0 / d3 * mod; + motionY += d1 / d3 * mod; + motionZ += d2 / d3 * mod; + + if (Math.sqrt(d3) < 1F) { + if (summoner != null) { + if (summoner instanceof EntityPlayer) + target.attackEntityFrom(DamageSource.causePlayerDamage((EntityPlayer) summoner), damage); + else { + target.attackEntityFrom(DamageSource.causeMobDamage(summoner), damage); + } + } else target.attackEntityFrom(DamageSource.causeMobDamage(this), damage); + if (effect != null && !(target instanceof EntityPlayer)) target.addPotionEffect(effect); + die(); + } + } + + renderYawOffset = rotationYaw = -((float) Math.atan2(motionX, motionZ)) * 180.0F / (float) Math.PI; + } + + @Override + public boolean attackEntityFrom(DamageSource par1DamageSource, float par2) { + if (getType() == 0 && par1DamageSource.getEntity() != summoner + || getType() == 1 && par1DamageSource.getEntity() instanceof EntityPlayer) + return super.attackEntityFrom(par1DamageSource, par2); + return false; + } + + @Override + public void onEntityUpdate() { + super.onEntityUpdate(); + + if (getAttackTarget() == null || ticksExisted > 200) die(); + + boolean dark = getType() == 1; + if (worldObj.isRemote) + for (int i = 0; i < 4; i++) + Botania.proxy.sparkleFX( + worldObj, + posX + (Math.random() - 0.5) * 0.25, + posY + 0.5 + (Math.random() - 0.5) * 0.25, + posZ + (Math.random() - 0.5) * 0.25, + dark ? 0.1F : 1F, + dark ? 0.025F : 0.25F, + dark ? 0.09F : 0.9F, + 0.1F + (float) Math.random() * 0.25F, + 12); + } + + public void die() { + setDead(); + + if (worldObj.isRemote && getType() == 0) + for (int i = 0; i < 12; i++) + Botania.proxy.sparkleFX( + worldObj, + posX + (Math.random() - 0.5) * 0.25, + posY + 0.5 + (Math.random() - 0.5) * 0.25, + posZ + (Math.random() - 0.5) * 0.25, + 1F, + 0.25F, + 0.9F, + 1F + (float) Math.random() * 0.25F, + 5); + } + + @Override + protected boolean canDespawn() { + return false; + } +} diff --git a/src/main/java/vazkii/botania/common/entity/EntityPoolMinecart.java b/src/main/java/vazkii/botania/common/entity/EntityPoolMinecart.java index 1c5c260d8c..a3107a256a 100644 --- a/src/main/java/vazkii/botania/common/entity/EntityPoolMinecart.java +++ b/src/main/java/vazkii/botania/common/entity/EntityPoolMinecart.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Mar 17, 2015, 6:36:43 PM (GMT)] */ package vazkii.botania.common.entity; @@ -29,130 +29,127 @@ public class EntityPoolMinecart extends EntityMinecart { - private static final int TRANSFER_RATE = 10000; - private static final String TAG_MANA = "mana"; - - public EntityPoolMinecart(World p_i1712_1_) { - super(p_i1712_1_); - } - - public EntityPoolMinecart(World p_i1715_1_, double p_i1715_2_, double p_i1715_4_, double p_i1715_6_) { - super(p_i1715_1_, p_i1715_2_, p_i1715_4_, p_i1715_6_); - } - - @Override - protected void entityInit() { - super.entityInit(); - dataWatcher.addObject(16, 0); - } - - @Override - public Block func_145817_o() { - return ModBlocks.pool; - } - - @Override - public ItemStack getCartItem() { - return new ItemStack(ModItems.poolMinecart); - } - - @Override - public int getMinecartType() { - return 0; - } - - @Override - public void killMinecart(DamageSource p_94095_1_) { - super.killMinecart(p_94095_1_); - func_145778_a(Item.getItemFromBlock(ModBlocks.pool), 1, 0.0F); - } - - @Override - public int getDefaultDisplayTileOffset() { - return 8; - } - - @Override - public void moveMinecartOnRail(int x, int y, int z, double par4) { - super.moveMinecartOnRail(x, y, z, par4); - - for(ForgeDirection dir : LibMisc.CARDINAL_DIRECTIONS) { - int xp = x + dir.offsetX; - int zp = z + dir.offsetZ; - Block block = worldObj.getBlock(xp, y, zp); - if(block == ModBlocks.pump) { - int xp_ = xp + dir.offsetX; - int zp_ = zp + dir.offsetZ; - int meta = worldObj.getBlockMetadata(xp, y, zp); - TileEntity tile = worldObj.getTileEntity(xp_, y, zp_); - TileEntity tile_ = worldObj.getTileEntity(xp, y, zp); - TilePump pump = (TilePump) tile_; - - if(tile != null && tile instanceof IManaPool && !pump.hasRedstone) { - IManaPool pool = (IManaPool) tile; - ForgeDirection pumpDir = ForgeDirection.getOrientation(meta); - boolean did = false; - boolean can = false; - - if(pumpDir == dir) { // Pool -> Cart - can = true; - int cartMana = getMana(); - int poolMana = pool.getCurrentMana(); - int transfer = Math.min(TRANSFER_RATE, poolMana); - int actualTransfer = Math.min(TilePool.MAX_MANA - cartMana, transfer); - if(actualTransfer > 0) { - pool.recieveMana(-transfer); - setMana(cartMana + actualTransfer); - did = true; - } - } else if(pumpDir == dir.getOpposite()) { // Cart -> Pool - can = true; - if(!pool.isFull()) { - int cartMana = getMana(); - int transfer = Math.min(TRANSFER_RATE, cartMana); - if(transfer > 0) { - pool.recieveMana(transfer); - setMana(cartMana - transfer); - did = true; - } - } - } - - if(did) { - VanillaPacketDispatcher.dispatchTEToNearbyPlayers(worldObj, xp_, y, zp_); - pump.hasCart = true; - if(!pump.active) - pump.setActive(true); - } - - if(can) { - pump.hasCartOnTop = true; - pump.comparator = (int) ((double) getMana() / (double) TilePool.MAX_MANA * 15); - } - - } - } - } - } - - @Override - protected void writeEntityToNBT(NBTTagCompound p_70014_1_) { - super.writeEntityToNBT(p_70014_1_); - p_70014_1_.setInteger(TAG_MANA, getMana()); - } - - @Override - protected void readEntityFromNBT(NBTTagCompound p_70037_1_) { - super.readEntityFromNBT(p_70037_1_); - setMana(p_70037_1_.getInteger(TAG_MANA)); - } - - public int getMana() { - return dataWatcher.getWatchableObjectInt(16); - } - - public void setMana(int mana) { - dataWatcher.updateObject(16, mana); - } - + private static final int TRANSFER_RATE = 10000; + private static final String TAG_MANA = "mana"; + + public EntityPoolMinecart(World p_i1712_1_) { + super(p_i1712_1_); + } + + public EntityPoolMinecart(World p_i1715_1_, double p_i1715_2_, double p_i1715_4_, double p_i1715_6_) { + super(p_i1715_1_, p_i1715_2_, p_i1715_4_, p_i1715_6_); + } + + @Override + protected void entityInit() { + super.entityInit(); + dataWatcher.addObject(16, 0); + } + + @Override + public Block func_145817_o() { + return ModBlocks.pool; + } + + @Override + public ItemStack getCartItem() { + return new ItemStack(ModItems.poolMinecart); + } + + @Override + public int getMinecartType() { + return 0; + } + + @Override + public void killMinecart(DamageSource p_94095_1_) { + super.killMinecart(p_94095_1_); + func_145778_a(Item.getItemFromBlock(ModBlocks.pool), 1, 0.0F); + } + + @Override + public int getDefaultDisplayTileOffset() { + return 8; + } + + @Override + public void moveMinecartOnRail(int x, int y, int z, double par4) { + super.moveMinecartOnRail(x, y, z, par4); + + for (ForgeDirection dir : LibMisc.CARDINAL_DIRECTIONS) { + int xp = x + dir.offsetX; + int zp = z + dir.offsetZ; + Block block = worldObj.getBlock(xp, y, zp); + if (block == ModBlocks.pump) { + int xp_ = xp + dir.offsetX; + int zp_ = zp + dir.offsetZ; + int meta = worldObj.getBlockMetadata(xp, y, zp); + TileEntity tile = worldObj.getTileEntity(xp_, y, zp_); + TileEntity tile_ = worldObj.getTileEntity(xp, y, zp); + TilePump pump = (TilePump) tile_; + + if (tile != null && tile instanceof IManaPool && !pump.hasRedstone) { + IManaPool pool = (IManaPool) tile; + ForgeDirection pumpDir = ForgeDirection.getOrientation(meta); + boolean did = false; + boolean can = false; + + if (pumpDir == dir) { // Pool -> Cart + can = true; + int cartMana = getMana(); + int poolMana = pool.getCurrentMana(); + int transfer = Math.min(TRANSFER_RATE, poolMana); + int actualTransfer = Math.min(TilePool.MAX_MANA - cartMana, transfer); + if (actualTransfer > 0) { + pool.recieveMana(-transfer); + setMana(cartMana + actualTransfer); + did = true; + } + } else if (pumpDir == dir.getOpposite()) { // Cart -> Pool + can = true; + if (!pool.isFull()) { + int cartMana = getMana(); + int transfer = Math.min(TRANSFER_RATE, cartMana); + if (transfer > 0) { + pool.recieveMana(transfer); + setMana(cartMana - transfer); + did = true; + } + } + } + + if (did) { + VanillaPacketDispatcher.dispatchTEToNearbyPlayers(worldObj, xp_, y, zp_); + pump.hasCart = true; + if (!pump.active) pump.setActive(true); + } + + if (can) { + pump.hasCartOnTop = true; + pump.comparator = (int) ((double) getMana() / (double) TilePool.MAX_MANA * 15); + } + } + } + } + } + + @Override + protected void writeEntityToNBT(NBTTagCompound p_70014_1_) { + super.writeEntityToNBT(p_70014_1_); + p_70014_1_.setInteger(TAG_MANA, getMana()); + } + + @Override + protected void readEntityFromNBT(NBTTagCompound p_70037_1_) { + super.readEntityFromNBT(p_70037_1_); + setMana(p_70037_1_.getInteger(TAG_MANA)); + } + + public int getMana() { + return dataWatcher.getWatchableObjectInt(16); + } + + public void setMana(int mana) { + dataWatcher.updateObject(16, mana); + } } diff --git a/src/main/java/vazkii/botania/common/entity/EntitySignalFlare.java b/src/main/java/vazkii/botania/common/entity/EntitySignalFlare.java index bcecb6ffbf..00d34a04ef 100644 --- a/src/main/java/vazkii/botania/common/entity/EntitySignalFlare.java +++ b/src/main/java/vazkii/botania/common/entity/EntitySignalFlare.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Mar 3, 2014, 7:10:32 PM (GMT)] */ package vazkii.botania.common.entity; @@ -18,61 +18,80 @@ public class EntitySignalFlare extends Entity { - private static final String COLOR_TAG = "color"; + private static final String COLOR_TAG = "color"; - public EntitySignalFlare(World par1World) { - super(par1World); - setSize(0F, 0F); - dataWatcher.addObject(30, 0); - dataWatcher.setObjectWatched(30); - } + public EntitySignalFlare(World par1World) { + super(par1World); + setSize(0F, 0F); + dataWatcher.addObject(30, 0); + dataWatcher.setObjectWatched(30); + } - @Override - protected void entityInit() { - // NO-OP - } + @Override + protected void entityInit() { + // NO-OP + } - @Override - public void onEntityUpdate() { - super.onEntityUpdate(); - if(ticksExisted++ >= 100) - setDead(); + @Override + public void onEntityUpdate() { + super.onEntityUpdate(); + if (ticksExisted++ >= 100) setDead(); - if(!isDead) { - if(ticksExisted % 10 == 0) - playSound("creeper.primed", 1F, 1F); + if (!isDead) { + if (ticksExisted % 10 == 0) playSound("creeper.primed", 1F, 1F); - int color = getColor(); - if(color < 16 && color >= 0) { - float[] colorArray = EntitySheep.fleeceColorTable[color]; + int color = getColor(); + if (color < 16 && color >= 0) { + float[] colorArray = EntitySheep.fleeceColorTable[color]; - Botania.proxy.setWispFXDistanceLimit(false); - for(int i = 0; i < 3; i++) - Botania.proxy.wispFX(worldObj, posX, posY, posZ + 0.5, colorArray[0], colorArray[1], colorArray[2], (float) Math.random() * 5 + 1F, (float) (Math.random() - 0.5F), 10F * (float) Math.sqrt(256F / (256F - (float) posY)), (float) (Math.random() - 0.5F)); + Botania.proxy.setWispFXDistanceLimit(false); + for (int i = 0; i < 3; i++) + Botania.proxy.wispFX( + worldObj, + posX, + posY, + posZ + 0.5, + colorArray[0], + colorArray[1], + colorArray[2], + (float) Math.random() * 5 + 1F, + (float) (Math.random() - 0.5F), + 10F * (float) Math.sqrt(256F / (256F - (float) posY)), + (float) (Math.random() - 0.5F)); - for(int i = 0; i < 4; i++) - Botania.proxy.wispFX(worldObj, posX + 0.5, 256, posZ + 0.5, colorArray[0], colorArray[1], colorArray[2], (float) Math.random() * 15 + 8F, (float) (Math.random() - 0.5F) * 8F, 0F, (float) (Math.random() - 0.5F) * 8F); - Botania.proxy.setWispFXDistanceLimit(true); - } - } - } + for (int i = 0; i < 4; i++) + Botania.proxy.wispFX( + worldObj, + posX + 0.5, + 256, + posZ + 0.5, + colorArray[0], + colorArray[1], + colorArray[2], + (float) Math.random() * 15 + 8F, + (float) (Math.random() - 0.5F) * 8F, + 0F, + (float) (Math.random() - 0.5F) * 8F); + Botania.proxy.setWispFXDistanceLimit(true); + } + } + } - @Override - protected void readEntityFromNBT(NBTTagCompound nbttagcompound) { - setColor(nbttagcompound.getInteger(COLOR_TAG)); - } + @Override + protected void readEntityFromNBT(NBTTagCompound nbttagcompound) { + setColor(nbttagcompound.getInteger(COLOR_TAG)); + } - @Override - protected void writeEntityToNBT(NBTTagCompound nbttagcompound) { - nbttagcompound.setInteger(COLOR_TAG, getColor()); - } + @Override + protected void writeEntityToNBT(NBTTagCompound nbttagcompound) { + nbttagcompound.setInteger(COLOR_TAG, getColor()); + } - public void setColor(int color) { - dataWatcher.updateObject(30, color); - } - - public int getColor() { - return dataWatcher.getWatchableObjectInt(30); - } + public void setColor(int color) { + dataWatcher.updateObject(30, color); + } + public int getColor() { + return dataWatcher.getWatchableObjectInt(30); + } } diff --git a/src/main/java/vazkii/botania/common/entity/EntitySpark.java b/src/main/java/vazkii/botania/common/entity/EntitySpark.java index e89206d3e7..add6d91d35 100644 --- a/src/main/java/vazkii/botania/common/entity/EntitySpark.java +++ b/src/main/java/vazkii/botania/common/entity/EntitySpark.java @@ -2,14 +2,15 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Aug 21, 2014, 5:43:44 PM (GMT)] */ package vazkii.botania.common.entity; +import baubles.common.lib.PlayerHandler; import java.awt.Color; import java.util.ArrayList; import java.util.Arrays; @@ -20,7 +21,6 @@ import java.util.Map; import java.util.Set; import java.util.WeakHashMap; - import net.minecraft.entity.Entity; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; @@ -36,348 +36,339 @@ import vazkii.botania.common.Botania; import vazkii.botania.common.core.helper.Vector3; import vazkii.botania.common.item.ModItems; -import baubles.common.lib.PlayerHandler; public class EntitySpark extends Entity implements ISparkEntity { - private static final int TRANSFER_RATE = 1000; - private static final String TAG_UPGRADE = "upgrade"; - private static final String TAG_INVIS = "invis"; - public static final int INVISIBILITY_DATA_WATCHER_KEY = 27; - - Set transfers = Collections.newSetFromMap(new WeakHashMap()); - - int removeTransferants = 2; - boolean firstTick = false; - - public EntitySpark(World world) { - super(world); - isImmuneToFire = true; - } - - @Override - protected void entityInit() { - setSize(0.1F, 0.5F); - dataWatcher.addObject(INVISIBILITY_DATA_WATCHER_KEY, 0); - dataWatcher.addObject(28, 0); - dataWatcher.setObjectWatched(INVISIBILITY_DATA_WATCHER_KEY); - dataWatcher.setObjectWatched(28); - } - - @Override - public void onUpdate() { - super.onUpdate(); - - ISparkAttachable tile = getAttachedTile(); - if(tile == null) { - if(!worldObj.isRemote) - setDead(); - return; - } - - boolean first = worldObj.isRemote && !firstTick; - int upgrade = getUpgrade(); - List allSparks = null; - if(first || upgrade == 2 || upgrade == 3) - allSparks = SparkHelper.getSparksAround(worldObj, posX, posY, posZ); - - if(first) - first = true; - - Collection transfers = getTransfers(); - - - if(upgrade != 0) { - switch(upgrade) { - case 1 : { // Dispersive - List players = SparkHelper.getEntitiesAround(EntityPlayer.class, worldObj, posX, posY, posZ); - - Map> receivingPlayers = new HashMap(); - - ItemStack input = new ItemStack(ModItems.spark); - for(EntityPlayer player : players) { - List stacks = new ArrayList(); - stacks.addAll(Arrays.asList(player.inventory.mainInventory)); - stacks.addAll(Arrays.asList(player.inventory.armorInventory)); - stacks.addAll(Arrays.asList(PlayerHandler.getPlayerBaubles(player).stackList)); - - for(ItemStack stack : stacks) { - if(stack == null || !(stack.getItem() instanceof IManaItem)) - continue; - - IManaItem manaItem = (IManaItem) stack.getItem(); - if(manaItem.canReceiveManaFromItem(stack, input)) { - Map receivingStacks; - boolean add = false; - if(!receivingPlayers.containsKey(player)) { - add = true; - receivingStacks = new HashMap(); - } else receivingStacks = receivingPlayers.get(player); - - int recv = Math.min(getAttachedTile().getCurrentMana(), Math.min(TRANSFER_RATE, manaItem.getMaxMana(stack) - manaItem.getMana(stack))); - if(recv > 0) { - receivingStacks.put(stack, recv); - if(add) - receivingPlayers.put(player, receivingStacks); - } - } - } - } - - if(!receivingPlayers.isEmpty()) { - List keys = new ArrayList(receivingPlayers.keySet()); - Collections.shuffle(keys); - EntityPlayer player = keys.iterator().next(); - - Map items = receivingPlayers.get(player); - ItemStack stack = items.keySet().iterator().next(); - int cost = items.get(stack); - int manaToPut = Math.min(getAttachedTile().getCurrentMana(), cost); - ((IManaItem) stack.getItem()).addMana(stack, manaToPut); - getAttachedTile().recieveMana(-manaToPut); - particlesTowards(player); - } - - break; - } - case 2 : { // Dominant - List validSparks = new ArrayList(); - for(ISparkEntity spark : allSparks) { - if(spark == this) - continue; - - int upgrade_ = spark.getUpgrade(); - if(upgrade_ == 0 && spark.getAttachedTile() instanceof IManaPool) - validSparks.add(spark); - } - if(validSparks.size() > 0) - validSparks.get(worldObj.rand.nextInt(validSparks.size())).registerTransfer(this); - - break; - } - case 3 : { // Recessive - for(ISparkEntity spark : allSparks) { - if(spark == this) - continue; - - int upgrade_ = spark.getUpgrade(); - if(upgrade_ != 2 && upgrade_ != 3 && upgrade_ != 4) - transfers.add(spark); - } - break; - } - } - } - - if(!transfers.isEmpty()) { - int manaTotal = Math.min(TRANSFER_RATE * transfers.size(), tile.getCurrentMana()); - int manaForEach = manaTotal / transfers.size(); - int manaSpent = 0; - - if(manaForEach > transfers.size()) { - for(ISparkEntity spark : transfers) { - if(spark.getAttachedTile() == null || spark.getAttachedTile().isFull() || spark.areIncomingTransfersDone()) { - manaTotal -= manaForEach; - continue; - } - - ISparkAttachable attached = spark.getAttachedTile(); - int spend = Math.min(attached.getAvailableSpaceForMana(), manaForEach); - attached.recieveMana(spend); - manaSpent += spend; - - particlesTowards((Entity) spark); - } - tile.recieveMana(-manaSpent); - } - } - - if(removeTransferants > 0) - removeTransferants--; - getTransfers(); - } - - void particlesTowards(Entity e) { - Vector3 thisVec = Vector3.fromEntityCenter(this).add(0, 0, 0); - Vector3 receiverVec = Vector3.fromEntityCenter(e).add(0, 0, 0); - - double rc = 0.45; - thisVec.add((Math.random() - 0.5) * rc, (Math.random() - 0.5) * rc, (Math.random() - 0.5) * rc); - receiverVec.add((Math.random() - 0.5) * rc, (Math.random() - 0.5) * rc, (Math.random() - 0.5) * rc); - - Vector3 motion = receiverVec.copy().sub(thisVec); - motion.multiply(0.04F); - float r = 0.4F + 0.3F * (float) Math.random(); - float g = 0.4F + 0.3F * (float) Math.random(); - float b = 0.4F + 0.3F * (float) Math.random(); - float size = 0.125F + 0.125F * (float) Math.random(); - - Botania.proxy.wispFX(worldObj, thisVec.x, thisVec.y, thisVec.z, r, g, b, size, (float) motion.x, (float) motion.y, (float) motion.z); - } - - public static void particleBeam(Entity e1, Entity e2) { - if(e1 == null || e2 == null) - return; - - Vector3 orig = new Vector3(e1.posX , e1.posY + 0.25, e1.posZ); - Vector3 end = new Vector3(e2.posX, e2.posY + 0.25, e2.posZ); - Vector3 diff = end.copy().sub(orig); - Vector3 movement = diff.copy().normalize().multiply(0.1); - int iters = (int) (diff.mag() / movement.mag()); - float huePer = 1F / iters; - float hueSum = (float) Math.random(); - - Vector3 currentPos = orig.copy(); - for(int i = 0; i < iters; i++) { - float hue = i * huePer + hueSum; - Color color = Color.getHSBColor(hue, 1F, 1F); - float r = Math.min(1F, color.getRed() / 255F + 0.4F); - float g = Math.min(1F, color.getGreen() / 255F + 0.4F); - float b = Math.min(1F, color.getBlue() / 255F + 0.4F); - - Botania.proxy.setSparkleFXNoClip(true); - Botania.proxy.sparkleFX(e1.worldObj, currentPos.x, currentPos.y, currentPos.z, r, g, b, 1F, 12); - Botania.proxy.setSparkleFXNoClip(false); - currentPos.add(movement); - } - } - - @Override - public boolean canBeCollidedWith() { - return true; - } - - @Override - public boolean interactFirst(EntityPlayer player) { - ItemStack stack = player.getCurrentEquippedItem(); - if(stack != null) { - int upgrade = getUpgrade(); - if(stack.getItem() == ModItems.twigWand) { - if(player.isSneaking()) { - if(upgrade > 0) { - if(!worldObj.isRemote) - entityDropItem(new ItemStack(ModItems.sparkUpgrade, 1, upgrade - 1), 0F); - setUpgrade(0); - - transfers.clear(); - removeTransferants = 2; - } else setDead(); - if(player.worldObj.isRemote) - player.swingItem(); - return true; - } else { - List allSparks = SparkHelper.getSparksAround(worldObj, posX, posY, posZ); - for(ISparkEntity spark : allSparks) - particleBeam(this, (Entity) spark); - return true; - } - } else if(stack.getItem() == ModItems.sparkUpgrade && upgrade == 0) { - int newUpgrade = stack.getItemDamage() + 1; - setUpgrade(newUpgrade); - stack.stackSize--; - if(player.worldObj.isRemote) - player.swingItem(); - return true; - } - } - - return doPhantomInk(stack); - } - - public boolean doPhantomInk(ItemStack stack) { - if(stack != null && stack.getItem() == ModItems.phantomInk && !worldObj.isRemote) { - int invis = dataWatcher.getWatchableObjectInt(INVISIBILITY_DATA_WATCHER_KEY); - dataWatcher.updateObject(INVISIBILITY_DATA_WATCHER_KEY, ~invis & 1); - return true; - } - - return false; - } - - @Override - protected void readEntityFromNBT(NBTTagCompound cmp) { - setUpgrade(cmp.getInteger(TAG_UPGRADE)); - dataWatcher.updateObject(INVISIBILITY_DATA_WATCHER_KEY, cmp.getInteger(TAG_INVIS)); - } - - @Override - protected void writeEntityToNBT(NBTTagCompound cmp) { - cmp.setInteger(TAG_UPGRADE, getUpgrade()); - cmp.setInteger(TAG_INVIS, dataWatcher.getWatchableObjectInt(INVISIBILITY_DATA_WATCHER_KEY)); - } - - @Override - public void setDead() { - super.setDead(); - if(!worldObj.isRemote) { - int upgrade = getUpgrade(); - entityDropItem(new ItemStack(ModItems.spark), 0F); - if(upgrade > 0) - entityDropItem(new ItemStack(ModItems.sparkUpgrade, 1, upgrade - 1), 0F); - } - } - - @Override - public ISparkAttachable getAttachedTile() { - int x = MathHelper.floor_double(posX); - int y = MathHelper.floor_double(posY) - 1; - int z = MathHelper.floor_double(posZ); - TileEntity tile = worldObj.getTileEntity(x, y, z); - if(tile != null && tile instanceof ISparkAttachable) - return (ISparkAttachable) tile; - - return null; - } - - - @Override - public Collection getTransfers() { - Collection removals = new ArrayList(); - - for(ISparkEntity e : transfers) { - ISparkEntity spark = e; - int upgr = getUpgrade(); - int supgr = spark.getUpgrade(); - ISparkAttachable atile = spark.getAttachedTile(); - - if(!(spark != this && !spark.areIncomingTransfersDone() && atile != null && !atile.isFull() && (upgr == 0 && supgr == 2 || upgr == 3 && (supgr == 0 || supgr == 1) || !(atile instanceof IManaPool)))) - removals.add(e); - } - - if(!removals.isEmpty()) - transfers.removeAll(removals); - - return transfers; - } - - private boolean hasTransfer(ISparkEntity entity) { - return transfers.contains(entity); - } - - @Override - public void registerTransfer(ISparkEntity entity) { - if(hasTransfer(entity)) - return; - transfers.add(entity); - } - - @Override - public int getUpgrade() { - return dataWatcher.getWatchableObjectInt(28); - } - - @Override - public void setUpgrade(int upgrade) { - dataWatcher.updateObject(28, upgrade); - } - - @Override - public boolean areIncomingTransfersDone() { - ISparkAttachable tile = getAttachedTile(); - if(tile instanceof IManaPool) - return removeTransferants > 0; - - return tile != null && tile.areIncomingTranfersDone(); - } - + private static final int TRANSFER_RATE = 1000; + private static final String TAG_UPGRADE = "upgrade"; + private static final String TAG_INVIS = "invis"; + public static final int INVISIBILITY_DATA_WATCHER_KEY = 27; + + Set transfers = Collections.newSetFromMap(new WeakHashMap()); + + int removeTransferants = 2; + boolean firstTick = false; + + public EntitySpark(World world) { + super(world); + isImmuneToFire = true; + } + + @Override + protected void entityInit() { + setSize(0.1F, 0.5F); + dataWatcher.addObject(INVISIBILITY_DATA_WATCHER_KEY, 0); + dataWatcher.addObject(28, 0); + dataWatcher.setObjectWatched(INVISIBILITY_DATA_WATCHER_KEY); + dataWatcher.setObjectWatched(28); + } + + @Override + public void onUpdate() { + super.onUpdate(); + + ISparkAttachable tile = getAttachedTile(); + if (tile == null) { + if (!worldObj.isRemote) setDead(); + return; + } + + boolean first = worldObj.isRemote && !firstTick; + int upgrade = getUpgrade(); + List allSparks = null; + if (first || upgrade == 2 || upgrade == 3) allSparks = SparkHelper.getSparksAround(worldObj, posX, posY, posZ); + + if (first) first = true; + + Collection transfers = getTransfers(); + + if (upgrade != 0) { + switch (upgrade) { + case 1: { // Dispersive + List players = + SparkHelper.getEntitiesAround(EntityPlayer.class, worldObj, posX, posY, posZ); + + Map> receivingPlayers = new HashMap(); + + ItemStack input = new ItemStack(ModItems.spark); + for (EntityPlayer player : players) { + List stacks = new ArrayList(); + stacks.addAll(Arrays.asList(player.inventory.mainInventory)); + stacks.addAll(Arrays.asList(player.inventory.armorInventory)); + stacks.addAll(Arrays.asList(PlayerHandler.getPlayerBaubles(player).stackList)); + + for (ItemStack stack : stacks) { + if (stack == null || !(stack.getItem() instanceof IManaItem)) continue; + + IManaItem manaItem = (IManaItem) stack.getItem(); + if (manaItem.canReceiveManaFromItem(stack, input)) { + Map receivingStacks; + boolean add = false; + if (!receivingPlayers.containsKey(player)) { + add = true; + receivingStacks = new HashMap(); + } else receivingStacks = receivingPlayers.get(player); + + int recv = Math.min( + getAttachedTile().getCurrentMana(), + Math.min(TRANSFER_RATE, manaItem.getMaxMana(stack) - manaItem.getMana(stack))); + if (recv > 0) { + receivingStacks.put(stack, recv); + if (add) receivingPlayers.put(player, receivingStacks); + } + } + } + } + + if (!receivingPlayers.isEmpty()) { + List keys = new ArrayList(receivingPlayers.keySet()); + Collections.shuffle(keys); + EntityPlayer player = keys.iterator().next(); + + Map items = receivingPlayers.get(player); + ItemStack stack = items.keySet().iterator().next(); + int cost = items.get(stack); + int manaToPut = Math.min(getAttachedTile().getCurrentMana(), cost); + ((IManaItem) stack.getItem()).addMana(stack, manaToPut); + getAttachedTile().recieveMana(-manaToPut); + particlesTowards(player); + } + + break; + } + case 2: { // Dominant + List validSparks = new ArrayList(); + for (ISparkEntity spark : allSparks) { + if (spark == this) continue; + + int upgrade_ = spark.getUpgrade(); + if (upgrade_ == 0 && spark.getAttachedTile() instanceof IManaPool) validSparks.add(spark); + } + if (validSparks.size() > 0) + validSparks + .get(worldObj.rand.nextInt(validSparks.size())) + .registerTransfer(this); + + break; + } + case 3: { // Recessive + for (ISparkEntity spark : allSparks) { + if (spark == this) continue; + + int upgrade_ = spark.getUpgrade(); + if (upgrade_ != 2 && upgrade_ != 3 && upgrade_ != 4) transfers.add(spark); + } + break; + } + } + } + + if (!transfers.isEmpty()) { + int manaTotal = Math.min(TRANSFER_RATE * transfers.size(), tile.getCurrentMana()); + int manaForEach = manaTotal / transfers.size(); + int manaSpent = 0; + + if (manaForEach > transfers.size()) { + for (ISparkEntity spark : transfers) { + if (spark.getAttachedTile() == null + || spark.getAttachedTile().isFull() + || spark.areIncomingTransfersDone()) { + manaTotal -= manaForEach; + continue; + } + + ISparkAttachable attached = spark.getAttachedTile(); + int spend = Math.min(attached.getAvailableSpaceForMana(), manaForEach); + attached.recieveMana(spend); + manaSpent += spend; + + particlesTowards((Entity) spark); + } + tile.recieveMana(-manaSpent); + } + } + + if (removeTransferants > 0) removeTransferants--; + getTransfers(); + } + + void particlesTowards(Entity e) { + Vector3 thisVec = Vector3.fromEntityCenter(this).add(0, 0, 0); + Vector3 receiverVec = Vector3.fromEntityCenter(e).add(0, 0, 0); + + double rc = 0.45; + thisVec.add((Math.random() - 0.5) * rc, (Math.random() - 0.5) * rc, (Math.random() - 0.5) * rc); + receiverVec.add((Math.random() - 0.5) * rc, (Math.random() - 0.5) * rc, (Math.random() - 0.5) * rc); + + Vector3 motion = receiverVec.copy().sub(thisVec); + motion.multiply(0.04F); + float r = 0.4F + 0.3F * (float) Math.random(); + float g = 0.4F + 0.3F * (float) Math.random(); + float b = 0.4F + 0.3F * (float) Math.random(); + float size = 0.125F + 0.125F * (float) Math.random(); + + Botania.proxy.wispFX( + worldObj, thisVec.x, thisVec.y, thisVec.z, r, g, b, size, (float) motion.x, (float) motion.y, (float) + motion.z); + } + + public static void particleBeam(Entity e1, Entity e2) { + if (e1 == null || e2 == null) return; + + Vector3 orig = new Vector3(e1.posX, e1.posY + 0.25, e1.posZ); + Vector3 end = new Vector3(e2.posX, e2.posY + 0.25, e2.posZ); + Vector3 diff = end.copy().sub(orig); + Vector3 movement = diff.copy().normalize().multiply(0.1); + int iters = (int) (diff.mag() / movement.mag()); + float huePer = 1F / iters; + float hueSum = (float) Math.random(); + + Vector3 currentPos = orig.copy(); + for (int i = 0; i < iters; i++) { + float hue = i * huePer + hueSum; + Color color = Color.getHSBColor(hue, 1F, 1F); + float r = Math.min(1F, color.getRed() / 255F + 0.4F); + float g = Math.min(1F, color.getGreen() / 255F + 0.4F); + float b = Math.min(1F, color.getBlue() / 255F + 0.4F); + + Botania.proxy.setSparkleFXNoClip(true); + Botania.proxy.sparkleFX(e1.worldObj, currentPos.x, currentPos.y, currentPos.z, r, g, b, 1F, 12); + Botania.proxy.setSparkleFXNoClip(false); + currentPos.add(movement); + } + } + + @Override + public boolean canBeCollidedWith() { + return true; + } + + @Override + public boolean interactFirst(EntityPlayer player) { + ItemStack stack = player.getCurrentEquippedItem(); + if (stack != null) { + int upgrade = getUpgrade(); + if (stack.getItem() == ModItems.twigWand) { + if (player.isSneaking()) { + if (upgrade > 0) { + if (!worldObj.isRemote) + entityDropItem(new ItemStack(ModItems.sparkUpgrade, 1, upgrade - 1), 0F); + setUpgrade(0); + + transfers.clear(); + removeTransferants = 2; + } else setDead(); + if (player.worldObj.isRemote) player.swingItem(); + return true; + } else { + List allSparks = SparkHelper.getSparksAround(worldObj, posX, posY, posZ); + for (ISparkEntity spark : allSparks) particleBeam(this, (Entity) spark); + return true; + } + } else if (stack.getItem() == ModItems.sparkUpgrade && upgrade == 0) { + int newUpgrade = stack.getItemDamage() + 1; + setUpgrade(newUpgrade); + stack.stackSize--; + if (player.worldObj.isRemote) player.swingItem(); + return true; + } + } + + return doPhantomInk(stack); + } + + public boolean doPhantomInk(ItemStack stack) { + if (stack != null && stack.getItem() == ModItems.phantomInk && !worldObj.isRemote) { + int invis = dataWatcher.getWatchableObjectInt(INVISIBILITY_DATA_WATCHER_KEY); + dataWatcher.updateObject(INVISIBILITY_DATA_WATCHER_KEY, ~invis & 1); + return true; + } + + return false; + } + + @Override + protected void readEntityFromNBT(NBTTagCompound cmp) { + setUpgrade(cmp.getInteger(TAG_UPGRADE)); + dataWatcher.updateObject(INVISIBILITY_DATA_WATCHER_KEY, cmp.getInteger(TAG_INVIS)); + } + + @Override + protected void writeEntityToNBT(NBTTagCompound cmp) { + cmp.setInteger(TAG_UPGRADE, getUpgrade()); + cmp.setInteger(TAG_INVIS, dataWatcher.getWatchableObjectInt(INVISIBILITY_DATA_WATCHER_KEY)); + } + + @Override + public void setDead() { + super.setDead(); + if (!worldObj.isRemote) { + int upgrade = getUpgrade(); + entityDropItem(new ItemStack(ModItems.spark), 0F); + if (upgrade > 0) entityDropItem(new ItemStack(ModItems.sparkUpgrade, 1, upgrade - 1), 0F); + } + } + + @Override + public ISparkAttachable getAttachedTile() { + int x = MathHelper.floor_double(posX); + int y = MathHelper.floor_double(posY) - 1; + int z = MathHelper.floor_double(posZ); + TileEntity tile = worldObj.getTileEntity(x, y, z); + if (tile != null && tile instanceof ISparkAttachable) return (ISparkAttachable) tile; + + return null; + } + + @Override + public Collection getTransfers() { + Collection removals = new ArrayList(); + + for (ISparkEntity e : transfers) { + ISparkEntity spark = e; + int upgr = getUpgrade(); + int supgr = spark.getUpgrade(); + ISparkAttachable atile = spark.getAttachedTile(); + + if (!(spark != this + && !spark.areIncomingTransfersDone() + && atile != null + && !atile.isFull() + && (upgr == 0 && supgr == 2 + || upgr == 3 && (supgr == 0 || supgr == 1) + || !(atile instanceof IManaPool)))) removals.add(e); + } + + if (!removals.isEmpty()) transfers.removeAll(removals); + + return transfers; + } + + private boolean hasTransfer(ISparkEntity entity) { + return transfers.contains(entity); + } + + @Override + public void registerTransfer(ISparkEntity entity) { + if (hasTransfer(entity)) return; + transfers.add(entity); + } + + @Override + public int getUpgrade() { + return dataWatcher.getWatchableObjectInt(28); + } + + @Override + public void setUpgrade(int upgrade) { + dataWatcher.updateObject(28, upgrade); + } + + @Override + public boolean areIncomingTransfersDone() { + ISparkAttachable tile = getAttachedTile(); + if (tile instanceof IManaPool) return removeTransferants > 0; + + return tile != null && tile.areIncomingTranfersDone(); + } } diff --git a/src/main/java/vazkii/botania/common/entity/EntityThornChakram.java b/src/main/java/vazkii/botania/common/entity/EntityThornChakram.java index 5fea972290..c6d432f4fd 100644 --- a/src/main/java/vazkii/botania/common/entity/EntityThornChakram.java +++ b/src/main/java/vazkii/botania/common/entity/EntityThornChakram.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jan 25, 2015, 6:47:35 PM (GMT)] */ package vazkii.botania.common.entity; @@ -30,134 +30,148 @@ public class EntityThornChakram extends EntityThrowable { - private static final int MAX_BOUNCES = 16; - boolean bounced = false; - - public EntityThornChakram(World world) { - super(world); - } - - public EntityThornChakram(World world, EntityLivingBase e) { - super(world, e); - } - - @Override - protected void entityInit() { - dataWatcher.addObject(30, 0); - dataWatcher.addObject(31, (byte) 0); - - dataWatcher.setObjectWatched(30); - dataWatcher.setObjectWatched(31); - } - - @Override - public void onUpdate() { - double mx = motionX; - double my = motionY; - double mz = motionZ; - - super.onUpdate(); - - if(isFire()) { - double r = 0.1; - double m = 0.1; - for(int i = 0; i < 3; i++) - worldObj.spawnParticle("flame", posX + r * (Math.random() - 0.5), posY + r * (Math.random() - 0.5), posZ + r * (Math.random() - 0.5), m * (Math.random() - 0.5), m * (Math.random() - 0.5), m * (Math.random() - 0.5)); - } - - int bounces = getTimesBounced(); - if(bounces >= MAX_BOUNCES || ticksExisted > 60) { - EntityLivingBase thrower = getThrower(); - noClip = true; - if(thrower == null) - dropAndKill(); - else { - Vector3 motion = Vector3.fromEntityCenter(thrower).sub(Vector3.fromEntityCenter(this)).normalize(); - motionX = motion.x; - motionY = motion.y; - motionZ = motion.z; - if(MathHelper.pointDistanceSpace(posX, posY, posZ, thrower.posX, thrower.posY, thrower.posZ) < 1) - if(!(thrower instanceof EntityPlayer && (((EntityPlayer) thrower).capabilities.isCreativeMode || ((EntityPlayer) thrower).inventory.addItemStackToInventory(getItemStack())))) - dropAndKill(); - else if(!worldObj.isRemote) - setDead(); - } - } else { - if(!bounced) { - motionX = mx; - motionY = my; - motionZ = mz; - } - bounced = false; - } - } - - private void dropAndKill() { - if(!worldObj.isRemote) { - ItemStack stack = getItemStack(); - EntityItem item = new EntityItem(worldObj, posX, posY, posZ, stack); - worldObj.spawnEntityInWorld(item); - setDead(); - } - } - - private ItemStack getItemStack() { - return new ItemStack(ModItems.thornChakram, 1, isFire() ? 1 : 0); - } - - @Override - protected void onImpact(MovingObjectPosition pos) { - if(noClip) - return; - - Block block = worldObj.getBlock(pos.blockX, pos.blockY, pos.blockZ); - worldObj.getTileEntity(pos.blockX, pos.blockY, pos.blockZ); - if(block instanceof BlockBush || block instanceof BlockLeaves) - return; - - boolean fire = isFire(); - EntityLivingBase thrower = getThrower(); - if(pos.entityHit != null && pos.entityHit instanceof EntityLivingBase && pos.entityHit != thrower) { - ((EntityLivingBase) pos.entityHit).attackEntityFrom(thrower != null ? thrower instanceof EntityPlayer ? DamageSource.causePlayerDamage((EntityPlayer) thrower) : DamageSource.causeMobDamage(thrower) : DamageSource.generic, 12); - if(fire) - ((EntityLivingBase) pos.entityHit).setFire(5); - else if(worldObj.rand.nextInt(3) == 0) - ((EntityLivingBase) pos.entityHit).addPotionEffect(new PotionEffect(Potion.poison.id, 60, 0)); - } else { - int bounces = getTimesBounced(); - if(bounces < MAX_BOUNCES) { - Vector3 currentMovementVec = new Vector3(motionX, motionY, motionZ); - ForgeDirection dir = ForgeDirection.getOrientation(pos.sideHit); - Vector3 normalVector = new Vector3(dir.offsetX, dir.offsetY, dir.offsetZ).normalize(); - Vector3 movementVec = normalVector.multiply(-2 * currentMovementVec.dotProduct(normalVector)).add(currentMovementVec); - - motionX = movementVec.x; - motionY = movementVec.y; - motionZ = movementVec.z; - bounced = true; - } - } - } - - @Override - protected float getGravityVelocity() { - return 0F; - } - - public int getTimesBounced() { - return dataWatcher.getWatchableObjectInt(30); - } - - public void setTimesBounced(int times) { - dataWatcher.updateObject(30, times); - } - - public boolean isFire() { - return dataWatcher.getWatchableObjectByte(31) != 0; - } - - public void setFire(boolean fire) { - dataWatcher.updateObject(31, (byte) (fire ? 1 : 0)); - } - + private static final int MAX_BOUNCES = 16; + boolean bounced = false; + + public EntityThornChakram(World world) { + super(world); + } + + public EntityThornChakram(World world, EntityLivingBase e) { + super(world, e); + } + + @Override + protected void entityInit() { + dataWatcher.addObject(30, 0); + dataWatcher.addObject(31, (byte) 0); + + dataWatcher.setObjectWatched(30); + dataWatcher.setObjectWatched(31); + } + + @Override + public void onUpdate() { + double mx = motionX; + double my = motionY; + double mz = motionZ; + + super.onUpdate(); + + if (isFire()) { + double r = 0.1; + double m = 0.1; + for (int i = 0; i < 3; i++) + worldObj.spawnParticle( + "flame", + posX + r * (Math.random() - 0.5), + posY + r * (Math.random() - 0.5), + posZ + r * (Math.random() - 0.5), + m * (Math.random() - 0.5), + m * (Math.random() - 0.5), + m * (Math.random() - 0.5)); + } + + int bounces = getTimesBounced(); + if (bounces >= MAX_BOUNCES || ticksExisted > 60) { + EntityLivingBase thrower = getThrower(); + noClip = true; + if (thrower == null) dropAndKill(); + else { + Vector3 motion = Vector3.fromEntityCenter(thrower) + .sub(Vector3.fromEntityCenter(this)) + .normalize(); + motionX = motion.x; + motionY = motion.y; + motionZ = motion.z; + if (MathHelper.pointDistanceSpace(posX, posY, posZ, thrower.posX, thrower.posY, thrower.posZ) < 1) + if (!(thrower instanceof EntityPlayer + && (((EntityPlayer) thrower).capabilities.isCreativeMode + || ((EntityPlayer) thrower).inventory.addItemStackToInventory(getItemStack())))) + dropAndKill(); + else if (!worldObj.isRemote) setDead(); + } + } else { + if (!bounced) { + motionX = mx; + motionY = my; + motionZ = mz; + } + bounced = false; + } + } + + private void dropAndKill() { + if (!worldObj.isRemote) { + ItemStack stack = getItemStack(); + EntityItem item = new EntityItem(worldObj, posX, posY, posZ, stack); + worldObj.spawnEntityInWorld(item); + setDead(); + } + } + + private ItemStack getItemStack() { + return new ItemStack(ModItems.thornChakram, 1, isFire() ? 1 : 0); + } + + @Override + protected void onImpact(MovingObjectPosition pos) { + if (noClip) return; + + Block block = worldObj.getBlock(pos.blockX, pos.blockY, pos.blockZ); + worldObj.getTileEntity(pos.blockX, pos.blockY, pos.blockZ); + if (block instanceof BlockBush || block instanceof BlockLeaves) return; + + boolean fire = isFire(); + EntityLivingBase thrower = getThrower(); + if (pos.entityHit != null && pos.entityHit instanceof EntityLivingBase && pos.entityHit != thrower) { + ((EntityLivingBase) pos.entityHit) + .attackEntityFrom( + thrower != null + ? thrower instanceof EntityPlayer + ? DamageSource.causePlayerDamage((EntityPlayer) thrower) + : DamageSource.causeMobDamage(thrower) + : DamageSource.generic, + 12); + if (fire) ((EntityLivingBase) pos.entityHit).setFire(5); + else if (worldObj.rand.nextInt(3) == 0) + ((EntityLivingBase) pos.entityHit).addPotionEffect(new PotionEffect(Potion.poison.id, 60, 0)); + } else { + int bounces = getTimesBounced(); + if (bounces < MAX_BOUNCES) { + Vector3 currentMovementVec = new Vector3(motionX, motionY, motionZ); + ForgeDirection dir = ForgeDirection.getOrientation(pos.sideHit); + Vector3 normalVector = new Vector3(dir.offsetX, dir.offsetY, dir.offsetZ).normalize(); + Vector3 movementVec = normalVector + .multiply(-2 * currentMovementVec.dotProduct(normalVector)) + .add(currentMovementVec); + + motionX = movementVec.x; + motionY = movementVec.y; + motionZ = movementVec.z; + bounced = true; + } + } + } + + @Override + protected float getGravityVelocity() { + return 0F; + } + + public int getTimesBounced() { + return dataWatcher.getWatchableObjectInt(30); + } + + public void setTimesBounced(int times) { + dataWatcher.updateObject(30, times); + } + + public boolean isFire() { + return dataWatcher.getWatchableObjectByte(31) != 0; + } + + public void setFire(boolean fire) { + dataWatcher.updateObject(31, (byte) (fire ? 1 : 0)); + } } diff --git a/src/main/java/vazkii/botania/common/entity/EntityThrowableCopy.java b/src/main/java/vazkii/botania/common/entity/EntityThrowableCopy.java index 38202c607a..4b98d5a800 100644 --- a/src/main/java/vazkii/botania/common/entity/EntityThrowableCopy.java +++ b/src/main/java/vazkii/botania/common/entity/EntityThrowableCopy.java @@ -2,16 +2,17 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Aug 16, 2015, 4:01:43 PM (GMT)] */ package vazkii.botania.common.entity; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; import java.util.List; - import net.minecraft.block.Block; import net.minecraft.entity.Entity; import net.minecraft.entity.EntityLivingBase; @@ -24,345 +25,332 @@ import net.minecraft.util.MovingObjectPosition; import net.minecraft.util.Vec3; import net.minecraft.world.World; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; // A copy of the vanilla EntityThrowable class // Doing this because if I didn't do this it'd be an EntityThrowable // And we all know how much mods like deflecting EntityThrowables public abstract class EntityThrowableCopy extends Entity implements IProjectile { - private int field_145788_c = -1; - private int field_145786_d = -1; - private int field_145787_e = -1; - private Block field_145785_f; - protected boolean inGround; - public int throwableShake; - /** The entity that threw this throwable item. */ - private EntityLivingBase thrower; - private String throwerName; - private int ticksInGround; - private int ticksInAir; - public EntityThrowableCopy(World p_i1776_1_) - { - super(p_i1776_1_); - setSize(0.25F, 0.25F); - } - - @Override - protected void entityInit() {} - - /** - * Checks if the entity is in range to render by using the past in distance and comparing it to its average edge - * length * 64 * renderDistanceWeight Args: distance - */ - @Override - @SideOnly(Side.CLIENT) - public boolean isInRangeToRenderDist(double p_70112_1_) - { - double d1 = boundingBox.getAverageEdgeLength() * 4.0D; - d1 *= 64.0D; - return p_70112_1_ < d1 * d1; - } - - public EntityThrowableCopy(World p_i1777_1_, EntityLivingBase p_i1777_2_) - { - super(p_i1777_1_); - thrower = p_i1777_2_; - setSize(0.25F, 0.25F); - setLocationAndAngles(p_i1777_2_.posX, p_i1777_2_.posY + p_i1777_2_.getEyeHeight(), p_i1777_2_.posZ, p_i1777_2_.rotationYaw, p_i1777_2_.rotationPitch); - posX -= MathHelper.cos(rotationYaw / 180.0F * (float)Math.PI) * 0.16F; - posY -= 0.10000000149011612D; - posZ -= MathHelper.sin(rotationYaw / 180.0F * (float)Math.PI) * 0.16F; - setPosition(posX, posY, posZ); - yOffset = 0.0F; - float f = 0.4F; - motionX = -MathHelper.sin(rotationYaw / 180.0F * (float)Math.PI) * MathHelper.cos(rotationPitch / 180.0F * (float)Math.PI) * f; - motionZ = MathHelper.cos(rotationYaw / 180.0F * (float)Math.PI) * MathHelper.cos(rotationPitch / 180.0F * (float)Math.PI) * f; - motionY = -MathHelper.sin((rotationPitch + func_70183_g()) / 180.0F * (float)Math.PI) * f; - setThrowableHeading(motionX, motionY, motionZ, func_70182_d(), 1.0F); - } - - public EntityThrowableCopy(World p_i1778_1_, double p_i1778_2_, double p_i1778_4_, double p_i1778_6_) - { - super(p_i1778_1_); - ticksInGround = 0; - setSize(0.25F, 0.25F); - setPosition(p_i1778_2_, p_i1778_4_, p_i1778_6_); - yOffset = 0.0F; - } - - protected float func_70182_d() - { - return 1.5F; - } - - protected float func_70183_g() - { - return 0.0F; - } - - /** - * Similar to setArrowHeading, it's point the throwable entity to a x, y, z direction. - */ - @Override - public void setThrowableHeading(double p_70186_1_, double p_70186_3_, double p_70186_5_, float p_70186_7_, float p_70186_8_) - { - float f2 = MathHelper.sqrt_double(p_70186_1_ * p_70186_1_ + p_70186_3_ * p_70186_3_ + p_70186_5_ * p_70186_5_); - p_70186_1_ /= f2; - p_70186_3_ /= f2; - p_70186_5_ /= f2; - p_70186_1_ += rand.nextGaussian() * 0.007499999832361937D * p_70186_8_; - p_70186_3_ += rand.nextGaussian() * 0.007499999832361937D * p_70186_8_; - p_70186_5_ += rand.nextGaussian() * 0.007499999832361937D * p_70186_8_; - p_70186_1_ *= p_70186_7_; - p_70186_3_ *= p_70186_7_; - p_70186_5_ *= p_70186_7_; - motionX = p_70186_1_; - motionY = p_70186_3_; - motionZ = p_70186_5_; - float f3 = MathHelper.sqrt_double(p_70186_1_ * p_70186_1_ + p_70186_5_ * p_70186_5_); - prevRotationYaw = rotationYaw = (float)(Math.atan2(p_70186_1_, p_70186_5_) * 180.0D / Math.PI); - prevRotationPitch = rotationPitch = (float)(Math.atan2(p_70186_3_, f3) * 180.0D / Math.PI); - ticksInGround = 0; - } - - /** - * Sets the velocity to the args. Args: x, y, z - */ - @Override - @SideOnly(Side.CLIENT) - public void setVelocity(double p_70016_1_, double p_70016_3_, double p_70016_5_) - { - motionX = p_70016_1_; - motionY = p_70016_3_; - motionZ = p_70016_5_; - - if (prevRotationPitch == 0.0F && prevRotationYaw == 0.0F) - { - float f = MathHelper.sqrt_double(p_70016_1_ * p_70016_1_ + p_70016_5_ * p_70016_5_); - prevRotationYaw = rotationYaw = (float)(Math.atan2(p_70016_1_, p_70016_5_) * 180.0D / Math.PI); - prevRotationPitch = rotationPitch = (float)(Math.atan2(p_70016_3_, f) * 180.0D / Math.PI); - } - } - - /** - * Called to update the entity's position/logic. - */ - @Override - public void onUpdate() - { - lastTickPosX = posX; - lastTickPosY = posY; - lastTickPosZ = posZ; - super.onUpdate(); - - if (throwableShake > 0) - { - --throwableShake; - } - - if (inGround) - { - if (worldObj.getBlock(field_145788_c, field_145786_d, field_145787_e) == field_145785_f) - { - ++ticksInGround; - - if (ticksInGround == 1200) - { - setDead(); - } - - return; - } - - inGround = false; - motionX *= rand.nextFloat() * 0.2F; - motionY *= rand.nextFloat() * 0.2F; - motionZ *= rand.nextFloat() * 0.2F; - ticksInGround = 0; - ticksInAir = 0; - } - else - { - ++ticksInAir; - } - - Vec3 vec3 = Vec3.createVectorHelper(posX, posY, posZ); - Vec3 vec31 = Vec3.createVectorHelper(posX + motionX, posY + motionY, posZ + motionZ); - MovingObjectPosition movingobjectposition = worldObj.rayTraceBlocks(vec3, vec31); - vec3 = Vec3.createVectorHelper(posX, posY, posZ); - vec31 = Vec3.createVectorHelper(posX + motionX, posY + motionY, posZ + motionZ); - - if (movingobjectposition != null) - { - vec31 = Vec3.createVectorHelper(movingobjectposition.hitVec.xCoord, movingobjectposition.hitVec.yCoord, movingobjectposition.hitVec.zCoord); - } - - if (!worldObj.isRemote) - { - Entity entity = null; - List list = worldObj.getEntitiesWithinAABBExcludingEntity(this, boundingBox.addCoord(motionX, motionY, motionZ).expand(1.0D, 1.0D, 1.0D)); - double d0 = 0.0D; - EntityLivingBase entitylivingbase = getThrower(); - - for (int j = 0; j < list.size(); ++j) - { - Entity entity1 = (Entity)list.get(j); - - if (entity1.canBeCollidedWith() && (entity1 != entitylivingbase || ticksInAir >= 5)) - { - float f = 0.3F; - AxisAlignedBB axisalignedbb = entity1.boundingBox.expand(f, f, f); - MovingObjectPosition movingobjectposition1 = axisalignedbb.calculateIntercept(vec3, vec31); - - if (movingobjectposition1 != null) - { - double d1 = vec3.distanceTo(movingobjectposition1.hitVec); - - if (d1 < d0 || d0 == 0.0D) - { - entity = entity1; - d0 = d1; - } - } - } - } - - if (entity != null) - { - movingobjectposition = new MovingObjectPosition(entity); - } - } - - if (movingobjectposition != null) - { - if (movingobjectposition.typeOfHit == MovingObjectPosition.MovingObjectType.BLOCK && worldObj.getBlock(movingobjectposition.blockX, movingobjectposition.blockY, movingobjectposition.blockZ) == Blocks.portal) - { - setInPortal(); - } - else - { - onImpact(movingobjectposition); - } - } - - posX += motionX; - posY += motionY; - posZ += motionZ; - float f1 = MathHelper.sqrt_double(motionX * motionX + motionZ * motionZ); - rotationYaw = (float)(Math.atan2(motionX, motionZ) * 180.0D / Math.PI); - - for (rotationPitch = (float)(Math.atan2(motionY, f1) * 180.0D / Math.PI); rotationPitch - prevRotationPitch < -180.0F; prevRotationPitch -= 360.0F) - { - ; - } - - while (rotationPitch - prevRotationPitch >= 180.0F) - { - prevRotationPitch += 360.0F; - } - - while (rotationYaw - prevRotationYaw < -180.0F) - { - prevRotationYaw -= 360.0F; - } - - while (rotationYaw - prevRotationYaw >= 180.0F) - { - prevRotationYaw += 360.0F; - } - - rotationPitch = prevRotationPitch + (rotationPitch - prevRotationPitch) * 0.2F; - rotationYaw = prevRotationYaw + (rotationYaw - prevRotationYaw) * 0.2F; - float f2 = 0.99F; - float f3 = getGravityVelocity(); - - if (isInWater()) - { - for (int i = 0; i < 4; ++i) - { - float f4 = 0.25F; - worldObj.spawnParticle("bubble", posX - motionX * f4, posY - motionY * f4, posZ - motionZ * f4, motionX, motionY, motionZ); - } - - f2 = 0.8F; - } - - motionX *= f2; - motionY *= f2; - motionZ *= f2; - motionY -= f3; - setPosition(posX, posY, posZ); - } - - /** - * Gets the amount of gravity to apply to the thrown entity with each tick. - */ - protected float getGravityVelocity() - { - return 0.03F; - } - - /** - * Called when this EntityThrowable hits a block or entity. - */ - protected abstract void onImpact(MovingObjectPosition p_70184_1_); - - /** - * (abstract) Protected helper method to write subclass entity data to NBT. - */ - @Override - public void writeEntityToNBT(NBTTagCompound p_70014_1_) - { - p_70014_1_.setShort("xTile", (short)field_145788_c); - p_70014_1_.setShort("yTile", (short)field_145786_d); - p_70014_1_.setShort("zTile", (short)field_145787_e); - p_70014_1_.setByte("inTile", (byte)Block.getIdFromBlock(field_145785_f)); - p_70014_1_.setByte("shake", (byte)throwableShake); - p_70014_1_.setByte("inGround", (byte)(inGround ? 1 : 0)); - - if ((throwerName == null || throwerName.length() == 0) && thrower != null && thrower instanceof EntityPlayer) - { - throwerName = thrower.getCommandSenderName(); - } - - p_70014_1_.setString("ownerName", throwerName == null ? "" : throwerName); - } - - /** - * (abstract) Protected helper method to read subclass entity data from NBT. - */ - @Override - public void readEntityFromNBT(NBTTagCompound p_70037_1_) - { - field_145788_c = p_70037_1_.getShort("xTile"); - field_145786_d = p_70037_1_.getShort("yTile"); - field_145787_e = p_70037_1_.getShort("zTile"); - field_145785_f = Block.getBlockById(p_70037_1_.getByte("inTile") & 255); - throwableShake = p_70037_1_.getByte("shake") & 255; - inGround = p_70037_1_.getByte("inGround") == 1; - throwerName = p_70037_1_.getString("ownerName"); - - if (throwerName != null && throwerName.length() == 0) - { - throwerName = null; - } - } - - @Override - @SideOnly(Side.CLIENT) - public float getShadowSize() - { - return 0.0F; - } - - public EntityLivingBase getThrower() - { - if (thrower == null && throwerName != null && throwerName.length() > 0) - { - thrower = worldObj.getPlayerEntityByName(throwerName); - } - - return thrower; - } -} \ No newline at end of file + private int field_145788_c = -1; + private int field_145786_d = -1; + private int field_145787_e = -1; + private Block field_145785_f; + protected boolean inGround; + public int throwableShake; + /** The entity that threw this throwable item. */ + private EntityLivingBase thrower; + + private String throwerName; + private int ticksInGround; + private int ticksInAir; + + public EntityThrowableCopy(World p_i1776_1_) { + super(p_i1776_1_); + setSize(0.25F, 0.25F); + } + + @Override + protected void entityInit() {} + + /** + * Checks if the entity is in range to render by using the past in distance and comparing it to its average edge + * length * 64 * renderDistanceWeight Args: distance + */ + @Override + @SideOnly(Side.CLIENT) + public boolean isInRangeToRenderDist(double p_70112_1_) { + double d1 = boundingBox.getAverageEdgeLength() * 4.0D; + d1 *= 64.0D; + return p_70112_1_ < d1 * d1; + } + + public EntityThrowableCopy(World p_i1777_1_, EntityLivingBase p_i1777_2_) { + super(p_i1777_1_); + thrower = p_i1777_2_; + setSize(0.25F, 0.25F); + setLocationAndAngles( + p_i1777_2_.posX, + p_i1777_2_.posY + p_i1777_2_.getEyeHeight(), + p_i1777_2_.posZ, + p_i1777_2_.rotationYaw, + p_i1777_2_.rotationPitch); + posX -= MathHelper.cos(rotationYaw / 180.0F * (float) Math.PI) * 0.16F; + posY -= 0.10000000149011612D; + posZ -= MathHelper.sin(rotationYaw / 180.0F * (float) Math.PI) * 0.16F; + setPosition(posX, posY, posZ); + yOffset = 0.0F; + float f = 0.4F; + motionX = -MathHelper.sin(rotationYaw / 180.0F * (float) Math.PI) + * MathHelper.cos(rotationPitch / 180.0F * (float) Math.PI) + * f; + motionZ = MathHelper.cos(rotationYaw / 180.0F * (float) Math.PI) + * MathHelper.cos(rotationPitch / 180.0F * (float) Math.PI) + * f; + motionY = -MathHelper.sin((rotationPitch + func_70183_g()) / 180.0F * (float) Math.PI) * f; + setThrowableHeading(motionX, motionY, motionZ, func_70182_d(), 1.0F); + } + + public EntityThrowableCopy(World p_i1778_1_, double p_i1778_2_, double p_i1778_4_, double p_i1778_6_) { + super(p_i1778_1_); + ticksInGround = 0; + setSize(0.25F, 0.25F); + setPosition(p_i1778_2_, p_i1778_4_, p_i1778_6_); + yOffset = 0.0F; + } + + protected float func_70182_d() { + return 1.5F; + } + + protected float func_70183_g() { + return 0.0F; + } + + /** + * Similar to setArrowHeading, it's point the throwable entity to a x, y, z direction. + */ + @Override + public void setThrowableHeading( + double p_70186_1_, double p_70186_3_, double p_70186_5_, float p_70186_7_, float p_70186_8_) { + float f2 = MathHelper.sqrt_double(p_70186_1_ * p_70186_1_ + p_70186_3_ * p_70186_3_ + p_70186_5_ * p_70186_5_); + p_70186_1_ /= f2; + p_70186_3_ /= f2; + p_70186_5_ /= f2; + p_70186_1_ += rand.nextGaussian() * 0.007499999832361937D * p_70186_8_; + p_70186_3_ += rand.nextGaussian() * 0.007499999832361937D * p_70186_8_; + p_70186_5_ += rand.nextGaussian() * 0.007499999832361937D * p_70186_8_; + p_70186_1_ *= p_70186_7_; + p_70186_3_ *= p_70186_7_; + p_70186_5_ *= p_70186_7_; + motionX = p_70186_1_; + motionY = p_70186_3_; + motionZ = p_70186_5_; + float f3 = MathHelper.sqrt_double(p_70186_1_ * p_70186_1_ + p_70186_5_ * p_70186_5_); + prevRotationYaw = rotationYaw = (float) (Math.atan2(p_70186_1_, p_70186_5_) * 180.0D / Math.PI); + prevRotationPitch = rotationPitch = (float) (Math.atan2(p_70186_3_, f3) * 180.0D / Math.PI); + ticksInGround = 0; + } + + /** + * Sets the velocity to the args. Args: x, y, z + */ + @Override + @SideOnly(Side.CLIENT) + public void setVelocity(double p_70016_1_, double p_70016_3_, double p_70016_5_) { + motionX = p_70016_1_; + motionY = p_70016_3_; + motionZ = p_70016_5_; + + if (prevRotationPitch == 0.0F && prevRotationYaw == 0.0F) { + float f = MathHelper.sqrt_double(p_70016_1_ * p_70016_1_ + p_70016_5_ * p_70016_5_); + prevRotationYaw = rotationYaw = (float) (Math.atan2(p_70016_1_, p_70016_5_) * 180.0D / Math.PI); + prevRotationPitch = rotationPitch = (float) (Math.atan2(p_70016_3_, f) * 180.0D / Math.PI); + } + } + + /** + * Called to update the entity's position/logic. + */ + @Override + public void onUpdate() { + lastTickPosX = posX; + lastTickPosY = posY; + lastTickPosZ = posZ; + super.onUpdate(); + + if (throwableShake > 0) { + --throwableShake; + } + + if (inGround) { + if (worldObj.getBlock(field_145788_c, field_145786_d, field_145787_e) == field_145785_f) { + ++ticksInGround; + + if (ticksInGround == 1200) { + setDead(); + } + + return; + } + + inGround = false; + motionX *= rand.nextFloat() * 0.2F; + motionY *= rand.nextFloat() * 0.2F; + motionZ *= rand.nextFloat() * 0.2F; + ticksInGround = 0; + ticksInAir = 0; + } else { + ++ticksInAir; + } + + Vec3 vec3 = Vec3.createVectorHelper(posX, posY, posZ); + Vec3 vec31 = Vec3.createVectorHelper(posX + motionX, posY + motionY, posZ + motionZ); + MovingObjectPosition movingobjectposition = worldObj.rayTraceBlocks(vec3, vec31); + vec3 = Vec3.createVectorHelper(posX, posY, posZ); + vec31 = Vec3.createVectorHelper(posX + motionX, posY + motionY, posZ + motionZ); + + if (movingobjectposition != null) { + vec31 = Vec3.createVectorHelper( + movingobjectposition.hitVec.xCoord, + movingobjectposition.hitVec.yCoord, + movingobjectposition.hitVec.zCoord); + } + + if (!worldObj.isRemote) { + Entity entity = null; + List list = worldObj.getEntitiesWithinAABBExcludingEntity( + this, boundingBox.addCoord(motionX, motionY, motionZ).expand(1.0D, 1.0D, 1.0D)); + double d0 = 0.0D; + EntityLivingBase entitylivingbase = getThrower(); + + for (int j = 0; j < list.size(); ++j) { + Entity entity1 = (Entity) list.get(j); + + if (entity1.canBeCollidedWith() && (entity1 != entitylivingbase || ticksInAir >= 5)) { + float f = 0.3F; + AxisAlignedBB axisalignedbb = entity1.boundingBox.expand(f, f, f); + MovingObjectPosition movingobjectposition1 = axisalignedbb.calculateIntercept(vec3, vec31); + + if (movingobjectposition1 != null) { + double d1 = vec3.distanceTo(movingobjectposition1.hitVec); + + if (d1 < d0 || d0 == 0.0D) { + entity = entity1; + d0 = d1; + } + } + } + } + + if (entity != null) { + movingobjectposition = new MovingObjectPosition(entity); + } + } + + if (movingobjectposition != null) { + if (movingobjectposition.typeOfHit == MovingObjectPosition.MovingObjectType.BLOCK + && worldObj.getBlock( + movingobjectposition.blockX, + movingobjectposition.blockY, + movingobjectposition.blockZ) + == Blocks.portal) { + setInPortal(); + } else { + onImpact(movingobjectposition); + } + } + + posX += motionX; + posY += motionY; + posZ += motionZ; + float f1 = MathHelper.sqrt_double(motionX * motionX + motionZ * motionZ); + rotationYaw = (float) (Math.atan2(motionX, motionZ) * 180.0D / Math.PI); + + for (rotationPitch = (float) (Math.atan2(motionY, f1) * 180.0D / Math.PI); + rotationPitch - prevRotationPitch < -180.0F; + prevRotationPitch -= 360.0F) { + ; + } + + while (rotationPitch - prevRotationPitch >= 180.0F) { + prevRotationPitch += 360.0F; + } + + while (rotationYaw - prevRotationYaw < -180.0F) { + prevRotationYaw -= 360.0F; + } + + while (rotationYaw - prevRotationYaw >= 180.0F) { + prevRotationYaw += 360.0F; + } + + rotationPitch = prevRotationPitch + (rotationPitch - prevRotationPitch) * 0.2F; + rotationYaw = prevRotationYaw + (rotationYaw - prevRotationYaw) * 0.2F; + float f2 = 0.99F; + float f3 = getGravityVelocity(); + + if (isInWater()) { + for (int i = 0; i < 4; ++i) { + float f4 = 0.25F; + worldObj.spawnParticle( + "bubble", + posX - motionX * f4, + posY - motionY * f4, + posZ - motionZ * f4, + motionX, + motionY, + motionZ); + } + + f2 = 0.8F; + } + + motionX *= f2; + motionY *= f2; + motionZ *= f2; + motionY -= f3; + setPosition(posX, posY, posZ); + } + + /** + * Gets the amount of gravity to apply to the thrown entity with each tick. + */ + protected float getGravityVelocity() { + return 0.03F; + } + + /** + * Called when this EntityThrowable hits a block or entity. + */ + protected abstract void onImpact(MovingObjectPosition p_70184_1_); + + /** + * (abstract) Protected helper method to write subclass entity data to NBT. + */ + @Override + public void writeEntityToNBT(NBTTagCompound p_70014_1_) { + p_70014_1_.setShort("xTile", (short) field_145788_c); + p_70014_1_.setShort("yTile", (short) field_145786_d); + p_70014_1_.setShort("zTile", (short) field_145787_e); + p_70014_1_.setByte("inTile", (byte) Block.getIdFromBlock(field_145785_f)); + p_70014_1_.setByte("shake", (byte) throwableShake); + p_70014_1_.setByte("inGround", (byte) (inGround ? 1 : 0)); + + if ((throwerName == null || throwerName.length() == 0) && thrower != null && thrower instanceof EntityPlayer) { + throwerName = thrower.getCommandSenderName(); + } + + p_70014_1_.setString("ownerName", throwerName == null ? "" : throwerName); + } + + /** + * (abstract) Protected helper method to read subclass entity data from NBT. + */ + @Override + public void readEntityFromNBT(NBTTagCompound p_70037_1_) { + field_145788_c = p_70037_1_.getShort("xTile"); + field_145786_d = p_70037_1_.getShort("yTile"); + field_145787_e = p_70037_1_.getShort("zTile"); + field_145785_f = Block.getBlockById(p_70037_1_.getByte("inTile") & 255); + throwableShake = p_70037_1_.getByte("shake") & 255; + inGround = p_70037_1_.getByte("inGround") == 1; + throwerName = p_70037_1_.getString("ownerName"); + + if (throwerName != null && throwerName.length() == 0) { + throwerName = null; + } + } + + @Override + @SideOnly(Side.CLIENT) + public float getShadowSize() { + return 0.0F; + } + + public EntityLivingBase getThrower() { + if (thrower == null && throwerName != null && throwerName.length() > 0) { + thrower = worldObj.getPlayerEntityByName(throwerName); + } + + return thrower; + } +} diff --git a/src/main/java/vazkii/botania/common/entity/EntityThrownItem.java b/src/main/java/vazkii/botania/common/entity/EntityThrownItem.java index dff1c91c69..44df684c31 100644 --- a/src/main/java/vazkii/botania/common/entity/EntityThrownItem.java +++ b/src/main/java/vazkii/botania/common/entity/EntityThrownItem.java @@ -2,16 +2,15 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [? (GMT)] */ package vazkii.botania.common.entity; import java.util.List; - import net.minecraft.entity.Entity; import net.minecraft.entity.item.EntityItem; import net.minecraft.entity.player.EntityPlayer; @@ -25,121 +24,112 @@ public class EntityThrownItem extends EntityItem { - public EntityThrownItem(World par1World) { - super(par1World); - } - - public EntityThrownItem(World p_i1710_1_, double p_i1710_2_, - double p_i1710_4_, double p_i1710_6_, EntityItem item) { - super(p_i1710_1_, p_i1710_2_, p_i1710_4_, p_i1710_6_, item.getEntityItem()); - - delayBeforeCanPickup = item.delayBeforeCanPickup; - motionX = item.motionX; - motionY = item.motionY; - motionZ = item.motionZ; - } - - @Override - public boolean isEntityInvulnerable() { - return true; - } - - @Override - public void onUpdate() { - super.onUpdate(); - Vec3 vec3 = Vec3.createVectorHelper(posX, posY, posZ); - Vec3 vec31 = Vec3.createVectorHelper(posX + motionX, posY + motionY, posZ + motionZ); - - MovingObjectPosition movingobjectposition = worldObj.rayTraceBlocks(vec3, vec31); - - - if (!worldObj.isRemote) - { - Entity entity = null; - List list = worldObj.getEntitiesWithinAABBExcludingEntity(this, boundingBox.addCoord(motionX*2, motionY*2, motionZ*2).expand(2.0D, 2.0D, 2.0D)); - double d0 = 0.0D; - - for (int j = 0; j < list.size(); ++j) - { - Entity entity1 = (Entity)list.get(j); - - if (entity1.canBeCollidedWith() && (!(entity1 instanceof EntityPlayer) || delayBeforeCanPickup == 0)) - { - float f = 1.0F; - AxisAlignedBB axisalignedbb = entity1.boundingBox.expand(f, f, f); - MovingObjectPosition movingobjectposition1 = axisalignedbb.calculateIntercept(vec3, vec31); - - if (movingobjectposition1 != null) - { - double d1 = vec3.distanceTo(movingobjectposition1.hitVec); - - if (d1 < d0 || d0 == 0.0D) - { - entity = entity1; - d0 = d1; - } - } - } - } - - if (entity != null) - { - movingobjectposition = new MovingObjectPosition(entity); - } - } - - if (movingobjectposition != null) - { - if (movingobjectposition.typeOfHit == MovingObjectPosition.MovingObjectType.BLOCK && worldObj.getBlock(movingobjectposition.blockX, movingobjectposition.blockY, movingobjectposition.blockZ) == Blocks.portal) - { - setInPortal(); - } - else - { - if (movingobjectposition.entityHit != null) { - movingobjectposition.entityHit.attackEntityFrom(DamageSource.magic, 2.0F); - if (!worldObj.isRemote) { - Entity item = getEntityItem().getItem().createEntity(worldObj, this, getEntityItem()); - if (item == null) { - item = new EntityItem(worldObj, posX, posY, posZ, getEntityItem()); - worldObj.spawnEntityInWorld(item); - item.motionX = motionX*0.25F; - item.motionY = motionY*0.25F; - item.motionZ = motionZ*0.25F; - - } - else - { - item.motionX = motionX*0.25F; - item.motionY = motionY*0.25F; - item.motionZ = motionZ*0.25F; - } - } - setDead(); - - } - } - } - - Vector3 vec3m = new Vector3(motionX, motionY, motionZ); - if (vec3m.mag() < 1.0F) { - if (!worldObj.isRemote) { - Entity item = getEntityItem().getItem().createEntity(worldObj, this, getEntityItem()); - if (item == null) { - item = new EntityItem(worldObj, posX, posY, posZ, getEntityItem()); - worldObj.spawnEntityInWorld(item); - item.motionX = motionX; - item.motionY = motionY; - item.motionZ = motionZ; - } - else - { - item.motionX = motionX; - item.motionY = motionY; - item.motionZ = motionZ; - } - } - setDead(); - } - } + public EntityThrownItem(World par1World) { + super(par1World); + } + + public EntityThrownItem( + World p_i1710_1_, double p_i1710_2_, double p_i1710_4_, double p_i1710_6_, EntityItem item) { + super(p_i1710_1_, p_i1710_2_, p_i1710_4_, p_i1710_6_, item.getEntityItem()); + + delayBeforeCanPickup = item.delayBeforeCanPickup; + motionX = item.motionX; + motionY = item.motionY; + motionZ = item.motionZ; + } + + @Override + public boolean isEntityInvulnerable() { + return true; + } + + @Override + public void onUpdate() { + super.onUpdate(); + Vec3 vec3 = Vec3.createVectorHelper(posX, posY, posZ); + Vec3 vec31 = Vec3.createVectorHelper(posX + motionX, posY + motionY, posZ + motionZ); + + MovingObjectPosition movingobjectposition = worldObj.rayTraceBlocks(vec3, vec31); + + if (!worldObj.isRemote) { + Entity entity = null; + List list = worldObj.getEntitiesWithinAABBExcludingEntity( + this, + boundingBox.addCoord(motionX * 2, motionY * 2, motionZ * 2).expand(2.0D, 2.0D, 2.0D)); + double d0 = 0.0D; + + for (int j = 0; j < list.size(); ++j) { + Entity entity1 = (Entity) list.get(j); + + if (entity1.canBeCollidedWith() && (!(entity1 instanceof EntityPlayer) || delayBeforeCanPickup == 0)) { + float f = 1.0F; + AxisAlignedBB axisalignedbb = entity1.boundingBox.expand(f, f, f); + MovingObjectPosition movingobjectposition1 = axisalignedbb.calculateIntercept(vec3, vec31); + + if (movingobjectposition1 != null) { + double d1 = vec3.distanceTo(movingobjectposition1.hitVec); + + if (d1 < d0 || d0 == 0.0D) { + entity = entity1; + d0 = d1; + } + } + } + } + + if (entity != null) { + movingobjectposition = new MovingObjectPosition(entity); + } + } + + if (movingobjectposition != null) { + if (movingobjectposition.typeOfHit == MovingObjectPosition.MovingObjectType.BLOCK + && worldObj.getBlock( + movingobjectposition.blockX, + movingobjectposition.blockY, + movingobjectposition.blockZ) + == Blocks.portal) { + setInPortal(); + } else { + if (movingobjectposition.entityHit != null) { + movingobjectposition.entityHit.attackEntityFrom(DamageSource.magic, 2.0F); + if (!worldObj.isRemote) { + Entity item = getEntityItem().getItem().createEntity(worldObj, this, getEntityItem()); + if (item == null) { + item = new EntityItem(worldObj, posX, posY, posZ, getEntityItem()); + worldObj.spawnEntityInWorld(item); + item.motionX = motionX * 0.25F; + item.motionY = motionY * 0.25F; + item.motionZ = motionZ * 0.25F; + + } else { + item.motionX = motionX * 0.25F; + item.motionY = motionY * 0.25F; + item.motionZ = motionZ * 0.25F; + } + } + setDead(); + } + } + } + + Vector3 vec3m = new Vector3(motionX, motionY, motionZ); + if (vec3m.mag() < 1.0F) { + if (!worldObj.isRemote) { + Entity item = getEntityItem().getItem().createEntity(worldObj, this, getEntityItem()); + if (item == null) { + item = new EntityItem(worldObj, posX, posY, posZ, getEntityItem()); + worldObj.spawnEntityInWorld(item); + item.motionX = motionX; + item.motionY = motionY; + item.motionZ = motionZ; + } else { + item.motionX = motionX; + item.motionY = motionY; + item.motionZ = motionZ; + } + } + setDead(); + } + } } diff --git a/src/main/java/vazkii/botania/common/entity/EntityVineBall.java b/src/main/java/vazkii/botania/common/entity/EntityVineBall.java index cfeadd7231..75a307aadc 100644 --- a/src/main/java/vazkii/botania/common/entity/EntityVineBall.java +++ b/src/main/java/vazkii/botania/common/entity/EntityVineBall.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jun 26, 2014, 7:32:16 PM (GMT)] */ package vazkii.botania.common.entity; @@ -20,49 +20,50 @@ public class EntityVineBall extends EntityThrowable { - public EntityVineBall(World par1World) { - super(par1World); - dataWatcher.addObject(30, 0F); - dataWatcher.setObjectWatched(30); - } + public EntityVineBall(World par1World) { + super(par1World); + dataWatcher.addObject(30, 0F); + dataWatcher.setObjectWatched(30); + } - public EntityVineBall(EntityPlayer player, boolean gravity) { - super(player.worldObj, player); - dataWatcher.addObject(30, gravity ? 0.03F : 0F); - dataWatcher.setObjectWatched(30); - } + public EntityVineBall(EntityPlayer player, boolean gravity) { + super(player.worldObj, player); + dataWatcher.addObject(30, gravity ? 0.03F : 0F); + dataWatcher.setObjectWatched(30); + } - @Override - protected void onImpact(MovingObjectPosition var1) { - if(var1 != null) { - int meta = var1.sideHit; - int[] metaPlace = new int[] { - 1, 4, 8, 2 - }; + @Override + protected void onImpact(MovingObjectPosition var1) { + if (var1 != null) { + int meta = var1.sideHit; + int[] metaPlace = new int[] {1, 4, 8, 2}; - if(meta > 1 && meta < 6) { - ForgeDirection dir = ForgeDirection.getOrientation(meta); - int x = var1.blockX + dir.offsetX; - int y = var1.blockY + dir.offsetY; - int z = var1.blockZ + dir.offsetZ; - while(y > 0) { - Block block = worldObj.getBlock(x, y, z); - if(block.isAir(worldObj, x, y, z)) { - worldObj.setBlock(x, y, z, ModBlocks.solidVines, metaPlace[meta - 2], 1 | 2); - worldObj.playAuxSFX(2001, x, y, z, Block.getIdFromBlock(ModBlocks.solidVines) + (metaPlace[meta - 2] << 12)); - y--; - } else break; - } - } + if (meta > 1 && meta < 6) { + ForgeDirection dir = ForgeDirection.getOrientation(meta); + int x = var1.blockX + dir.offsetX; + int y = var1.blockY + dir.offsetY; + int z = var1.blockZ + dir.offsetZ; + while (y > 0) { + Block block = worldObj.getBlock(x, y, z); + if (block.isAir(worldObj, x, y, z)) { + worldObj.setBlock(x, y, z, ModBlocks.solidVines, metaPlace[meta - 2], 1 | 2); + worldObj.playAuxSFX( + 2001, + x, + y, + z, + Block.getIdFromBlock(ModBlocks.solidVines) + (metaPlace[meta - 2] << 12)); + y--; + } else break; + } + } + } - } - - setDead(); - } - - @Override - protected float getGravityVelocity() { - return dataWatcher.getWatchableObjectFloat(30); - } + setDead(); + } + @Override + protected float getGravityVelocity() { + return dataWatcher.getWatchableObjectFloat(30); + } } diff --git a/src/main/java/vazkii/botania/common/entity/ModEntities.java b/src/main/java/vazkii/botania/common/entity/ModEntities.java index ad4625bc8b..43ecd498d3 100644 --- a/src/main/java/vazkii/botania/common/entity/ModEntities.java +++ b/src/main/java/vazkii/botania/common/entity/ModEntities.java @@ -2,43 +2,60 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jan 26, 2014, 4:11:03 PM (GMT)] */ package vazkii.botania.common.entity; +import cpw.mods.fml.common.registry.EntityRegistry; import vazkii.botania.common.Botania; import vazkii.botania.common.block.tile.TileLightRelay.EntityPlayerMover; import vazkii.botania.common.lib.LibEntityNames; -import cpw.mods.fml.common.registry.EntityRegistry; public final class ModEntities { - public static void init() { - int id = 0; - - EntityRegistry.registerModEntity(EntityManaBurst.class, LibEntityNames.MANA_BURST, id++, Botania.instance, 64, 10, true); - EntityRegistry.registerModEntity(EntitySignalFlare.class, LibEntityNames.SIGNAL_FLARE, id++, Botania.instance, 2048, 10, false); - EntityRegistry.registerModEntity(EntityPixie.class, LibEntityNames.PIXIE, id++, Botania.instance, 16, 3, true); - EntityRegistry.registerModEntity(EntityFlameRing.class, LibEntityNames.FLAME_RING, id++, Botania.instance, 32, 40, false); - EntityRegistry.registerModEntity(EntityVineBall.class, LibEntityNames.VINE_BALL, id++, Botania.instance, 64, 10, true); - EntityRegistry.registerModEntity(EntityDoppleganger.class, LibEntityNames.DOPPLEGANGER, id++, Botania.instance, 128, 3, true); - EntityRegistry.registerModEntity(EntityMagicLandmine.class, LibEntityNames.MAGIC_LANDMINE, id++, Botania.instance, 128, 40, false); - EntityRegistry.registerModEntity(EntitySpark.class, LibEntityNames.SPARK, id++, Botania.instance, 64, 10, false); - EntityRegistry.registerModEntity(EntityThrownItem.class, LibEntityNames.THROWN_ITEM, id++, Botania.instance, 64, 20, true); - EntityRegistry.registerModEntity(EntityMagicMissile.class, LibEntityNames.MAGIC_MISSILE, id++, Botania.instance, 64, 2, true); - EntityRegistry.registerModEntity(EntityThornChakram.class, LibEntityNames.THORN_CHAKRAM, id++, Botania.instance, 64, 10, true); - EntityRegistry.registerModEntity(EntityCorporeaSpark.class, LibEntityNames.CORPOREA_SPARK, id++, Botania.instance, 64, 10, false); - EntityRegistry.registerModEntity(EntityEnderAirBottle.class, LibEntityNames.ENDER_AIR_BOTTLE, id++, Botania.instance, 64, 10, true); - EntityRegistry.registerModEntity(EntityPoolMinecart.class, LibEntityNames.POOL_MINECART, id++, Botania.instance, 80, 3, true); - EntityRegistry.registerModEntity(EntityPinkWither.class, LibEntityNames.PINK_WITHER, id++, Botania.instance, 80, 3, false); - EntityRegistry.registerModEntity(EntityPlayerMover.class, LibEntityNames.PLAYER_MOVER, id++, Botania.instance, 40, 3, true); - EntityRegistry.registerModEntity(EntityManaStorm.class, LibEntityNames.MANA_STORM, id++, Botania.instance, 64, 10, false); - EntityRegistry.registerModEntity(EntityBabylonWeapon.class, LibEntityNames.BABYLON_WEAPON, id++, Botania.instance, 64, 10, true); - EntityRegistry.registerModEntity(EntityFallingStar.class, LibEntityNames.FALLING_STAR, id++, Botania.instance, 64, 10, true); - } + public static void init() { + int id = 0; + EntityRegistry.registerModEntity( + EntityManaBurst.class, LibEntityNames.MANA_BURST, id++, Botania.instance, 64, 10, true); + EntityRegistry.registerModEntity( + EntitySignalFlare.class, LibEntityNames.SIGNAL_FLARE, id++, Botania.instance, 2048, 10, false); + EntityRegistry.registerModEntity(EntityPixie.class, LibEntityNames.PIXIE, id++, Botania.instance, 16, 3, true); + EntityRegistry.registerModEntity( + EntityFlameRing.class, LibEntityNames.FLAME_RING, id++, Botania.instance, 32, 40, false); + EntityRegistry.registerModEntity( + EntityVineBall.class, LibEntityNames.VINE_BALL, id++, Botania.instance, 64, 10, true); + EntityRegistry.registerModEntity( + EntityDoppleganger.class, LibEntityNames.DOPPLEGANGER, id++, Botania.instance, 128, 3, true); + EntityRegistry.registerModEntity( + EntityMagicLandmine.class, LibEntityNames.MAGIC_LANDMINE, id++, Botania.instance, 128, 40, false); + EntityRegistry.registerModEntity( + EntitySpark.class, LibEntityNames.SPARK, id++, Botania.instance, 64, 10, false); + EntityRegistry.registerModEntity( + EntityThrownItem.class, LibEntityNames.THROWN_ITEM, id++, Botania.instance, 64, 20, true); + EntityRegistry.registerModEntity( + EntityMagicMissile.class, LibEntityNames.MAGIC_MISSILE, id++, Botania.instance, 64, 2, true); + EntityRegistry.registerModEntity( + EntityThornChakram.class, LibEntityNames.THORN_CHAKRAM, id++, Botania.instance, 64, 10, true); + EntityRegistry.registerModEntity( + EntityCorporeaSpark.class, LibEntityNames.CORPOREA_SPARK, id++, Botania.instance, 64, 10, false); + EntityRegistry.registerModEntity( + EntityEnderAirBottle.class, LibEntityNames.ENDER_AIR_BOTTLE, id++, Botania.instance, 64, 10, true); + EntityRegistry.registerModEntity( + EntityPoolMinecart.class, LibEntityNames.POOL_MINECART, id++, Botania.instance, 80, 3, true); + EntityRegistry.registerModEntity( + EntityPinkWither.class, LibEntityNames.PINK_WITHER, id++, Botania.instance, 80, 3, false); + EntityRegistry.registerModEntity( + EntityPlayerMover.class, LibEntityNames.PLAYER_MOVER, id++, Botania.instance, 40, 3, true); + EntityRegistry.registerModEntity( + EntityManaStorm.class, LibEntityNames.MANA_STORM, id++, Botania.instance, 64, 10, false); + EntityRegistry.registerModEntity( + EntityBabylonWeapon.class, LibEntityNames.BABYLON_WEAPON, id++, Botania.instance, 64, 10, true); + EntityRegistry.registerModEntity( + EntityFallingStar.class, LibEntityNames.FALLING_STAR, id++, Botania.instance, 64, 10, true); + } } diff --git a/src/main/java/vazkii/botania/common/integration/buildcraft/StatementAPIPlugin.java b/src/main/java/vazkii/botania/common/integration/buildcraft/StatementAPIPlugin.java index 49b424d97a..5c0c69871e 100644 --- a/src/main/java/vazkii/botania/common/integration/buildcraft/StatementAPIPlugin.java +++ b/src/main/java/vazkii/botania/common/integration/buildcraft/StatementAPIPlugin.java @@ -1,63 +1,62 @@ package vazkii.botania.common.integration.buildcraft; +import buildcraft.api.statements.IStatementContainer; +import buildcraft.api.statements.ITriggerExternal; +import buildcraft.api.statements.ITriggerInternal; +import buildcraft.api.statements.ITriggerProvider; +import buildcraft.api.statements.StatementManager; import java.util.ArrayList; import java.util.Collection; - import net.minecraft.tileentity.TileEntity; import net.minecraftforge.common.util.ForgeDirection; import vazkii.botania.api.mana.IManaBlock; import vazkii.botania.api.mana.IManaReceiver; import vazkii.botania.common.block.tile.TileRuneAltar; -import buildcraft.api.statements.IStatementContainer; -import buildcraft.api.statements.ITriggerExternal; -import buildcraft.api.statements.ITriggerInternal; -import buildcraft.api.statements.ITriggerProvider; -import buildcraft.api.statements.StatementManager; public class StatementAPIPlugin implements ITriggerProvider { - public static final ITriggerExternal triggerManaEmpty = new TriggerManaLevel(TriggerManaLevel.State.EMPTY); - public static final ITriggerExternal triggerManaContains = new TriggerManaLevel(TriggerManaLevel.State.CONTAINS); - public static final ITriggerExternal triggerManaSpace = new TriggerManaLevel(TriggerManaLevel.State.SPACE); - public static final ITriggerExternal triggerManaFull = new TriggerManaLevel(TriggerManaLevel.State.FULL); - public static final ITriggerInternal triggerManaDetector = new TriggerManaDetector(); - - public static final ITriggerExternal triggerRuneAltarCanCraft = new TriggerRuneAltarCanCraft(); - - public StatementAPIPlugin() { - StatementManager.registerStatement(triggerManaEmpty); - StatementManager.registerStatement(triggerManaContains); - StatementManager.registerStatement(triggerManaSpace); - StatementManager.registerStatement(triggerManaFull); - StatementManager.registerStatement(triggerManaDetector); - - StatementManager.registerStatement(triggerRuneAltarCanCraft); - - StatementManager.registerTriggerProvider(this); - } - - @Override - public Collection getInternalTriggers(IStatementContainer container) { - ArrayList list = new ArrayList(); - list.add(triggerManaDetector); - return list; - } - - @Override - public Collection getExternalTriggers(ForgeDirection side, TileEntity tile) { - ArrayList list = new ArrayList(); - - if (tile instanceof IManaBlock) { - list.add(triggerManaEmpty); - list.add(triggerManaContains); - if (tile instanceof IManaReceiver) { - list.add(triggerManaSpace); - list.add(triggerManaFull); - } - } - - if (tile instanceof TileRuneAltar) list.add(triggerRuneAltarCanCraft); - - return list; - } + public static final ITriggerExternal triggerManaEmpty = new TriggerManaLevel(TriggerManaLevel.State.EMPTY); + public static final ITriggerExternal triggerManaContains = new TriggerManaLevel(TriggerManaLevel.State.CONTAINS); + public static final ITriggerExternal triggerManaSpace = new TriggerManaLevel(TriggerManaLevel.State.SPACE); + public static final ITriggerExternal triggerManaFull = new TriggerManaLevel(TriggerManaLevel.State.FULL); + public static final ITriggerInternal triggerManaDetector = new TriggerManaDetector(); + + public static final ITriggerExternal triggerRuneAltarCanCraft = new TriggerRuneAltarCanCraft(); + + public StatementAPIPlugin() { + StatementManager.registerStatement(triggerManaEmpty); + StatementManager.registerStatement(triggerManaContains); + StatementManager.registerStatement(triggerManaSpace); + StatementManager.registerStatement(triggerManaFull); + StatementManager.registerStatement(triggerManaDetector); + + StatementManager.registerStatement(triggerRuneAltarCanCraft); + + StatementManager.registerTriggerProvider(this); + } + + @Override + public Collection getInternalTriggers(IStatementContainer container) { + ArrayList list = new ArrayList(); + list.add(triggerManaDetector); + return list; + } + + @Override + public Collection getExternalTriggers(ForgeDirection side, TileEntity tile) { + ArrayList list = new ArrayList(); + + if (tile instanceof IManaBlock) { + list.add(triggerManaEmpty); + list.add(triggerManaContains); + if (tile instanceof IManaReceiver) { + list.add(triggerManaSpace); + list.add(triggerManaFull); + } + } + + if (tile instanceof TileRuneAltar) list.add(triggerRuneAltarCanCraft); + + return list; + } } diff --git a/src/main/java/vazkii/botania/common/integration/buildcraft/StatementBase.java b/src/main/java/vazkii/botania/common/integration/buildcraft/StatementBase.java index cbf7993572..e6a463ee01 100644 --- a/src/main/java/vazkii/botania/common/integration/buildcraft/StatementBase.java +++ b/src/main/java/vazkii/botania/common/integration/buildcraft/StatementBase.java @@ -1,34 +1,34 @@ package vazkii.botania.common.integration.buildcraft; -import net.minecraft.util.IIcon; import buildcraft.api.statements.IStatement; import buildcraft.api.statements.IStatementParameter; +import net.minecraft.util.IIcon; public abstract class StatementBase implements IStatement { - protected IIcon icon; + protected IIcon icon; - @Override - public IIcon getIcon() { - return icon; - } + @Override + public IIcon getIcon() { + return icon; + } - @Override - public int maxParameters() { - return 0; - } + @Override + public int maxParameters() { + return 0; + } - @Override - public int minParameters() { - return 0; - } + @Override + public int minParameters() { + return 0; + } - @Override - public IStatementParameter createParameter(int index) { - return null; - } + @Override + public IStatementParameter createParameter(int index) { + return null; + } - @Override - public IStatement rotateLeft() { - return this; - } + @Override + public IStatement rotateLeft() { + return this; + } } diff --git a/src/main/java/vazkii/botania/common/integration/buildcraft/TriggerManaDetector.java b/src/main/java/vazkii/botania/common/integration/buildcraft/TriggerManaDetector.java index 4210c9da8e..138c7eaf4b 100644 --- a/src/main/java/vazkii/botania/common/integration/buildcraft/TriggerManaDetector.java +++ b/src/main/java/vazkii/botania/common/integration/buildcraft/TriggerManaDetector.java @@ -1,5 +1,8 @@ package vazkii.botania.common.integration.buildcraft; +import buildcraft.api.statements.IStatementContainer; +import buildcraft.api.statements.IStatementParameter; +import buildcraft.api.statements.ITriggerInternal; import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.util.AxisAlignedBB; import net.minecraft.util.StatCollector; @@ -8,38 +11,47 @@ import vazkii.botania.client.core.helper.IconHelper; import vazkii.botania.common.Botania; import vazkii.botania.common.lib.LibTriggerNames; -import buildcraft.api.statements.IStatementContainer; -import buildcraft.api.statements.IStatementParameter; -import buildcraft.api.statements.ITriggerInternal; public class TriggerManaDetector extends StatementBase implements ITriggerInternal { - @Override - public String getUniqueTag() { - return "botania:manaDetector"; - } - - @Override - public void registerIcons(IIconRegister iconRegister) { - icon = IconHelper.forName(iconRegister, "triggers/manaDetector"); - } - - @Override - public String getDescription() { - return StatCollector.translateToLocal(LibTriggerNames.TRIGGER_MANA_DETECTOR); - } - - @Override - public boolean isTriggerActive(IStatementContainer source, IStatementParameter[] parameters) { - World world = source.getTile().getWorldObj(); - int x = source.getTile().xCoord, y = source.getTile().yCoord, z = source.getTile().zCoord; - - boolean output = world.getEntitiesWithinAABB(IManaBurst.class, AxisAlignedBB.getBoundingBox(x, y, z, x + 1, y + 1, z + 1)).size() != 0; - - if(output) for(int i = 0; i < 4; i++) - Botania.proxy.sparkleFX(world, x + Math.random(), y + Math.random(), z + Math.random(), 1F, 0.2F, 0.2F, 0.7F + 0.5F * (float) Math.random(), 5); - - return output; - } - + @Override + public String getUniqueTag() { + return "botania:manaDetector"; + } + + @Override + public void registerIcons(IIconRegister iconRegister) { + icon = IconHelper.forName(iconRegister, "triggers/manaDetector"); + } + + @Override + public String getDescription() { + return StatCollector.translateToLocal(LibTriggerNames.TRIGGER_MANA_DETECTOR); + } + + @Override + public boolean isTriggerActive(IStatementContainer source, IStatementParameter[] parameters) { + World world = source.getTile().getWorldObj(); + int x = source.getTile().xCoord, y = source.getTile().yCoord, z = source.getTile().zCoord; + + boolean output = world.getEntitiesWithinAABB( + IManaBurst.class, AxisAlignedBB.getBoundingBox(x, y, z, x + 1, y + 1, z + 1)) + .size() + != 0; + + if (output) + for (int i = 0; i < 4; i++) + Botania.proxy.sparkleFX( + world, + x + Math.random(), + y + Math.random(), + z + Math.random(), + 1F, + 0.2F, + 0.2F, + 0.7F + 0.5F * (float) Math.random(), + 5); + + return output; + } } diff --git a/src/main/java/vazkii/botania/common/integration/buildcraft/TriggerManaLevel.java b/src/main/java/vazkii/botania/common/integration/buildcraft/TriggerManaLevel.java index f655d56aff..2e14aa26a1 100644 --- a/src/main/java/vazkii/botania/common/integration/buildcraft/TriggerManaLevel.java +++ b/src/main/java/vazkii/botania/common/integration/buildcraft/TriggerManaLevel.java @@ -1,60 +1,60 @@ package vazkii.botania.common.integration.buildcraft; +import buildcraft.api.statements.IStatementContainer; +import buildcraft.api.statements.IStatementParameter; +import buildcraft.api.statements.ITriggerExternal; import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.StatCollector; import net.minecraftforge.common.util.ForgeDirection; - import org.apache.commons.lang3.text.WordUtils; - import vazkii.botania.api.mana.IManaBlock; import vazkii.botania.api.mana.IManaReceiver; import vazkii.botania.client.core.helper.IconHelper; import vazkii.botania.common.lib.LibTriggerNames; -import buildcraft.api.statements.IStatementContainer; -import buildcraft.api.statements.IStatementParameter; -import buildcraft.api.statements.ITriggerExternal; public class TriggerManaLevel extends StatementBase implements ITriggerExternal { - public enum State { - EMPTY, - CONTAINS, - SPACE, - FULL - }; - - private State state; - - public TriggerManaLevel(State state) { - this.state = state; - } - - @Override - public String getUniqueTag() { - return "botania:mana" + state.name(); - } - - @Override - public void registerIcons(IIconRegister iconRegister) { - icon = IconHelper.forName(iconRegister, "triggers/mana" + WordUtils.capitalizeFully(state.name())); - } - - @Override - public String getDescription() { - return StatCollector.translateToLocal(LibTriggerNames.TRIGGER_MANA_PREFIX + WordUtils.capitalizeFully(state.name())); - } - - @Override - public boolean isTriggerActive(TileEntity target, ForgeDirection side, IStatementContainer source, IStatementParameter[] parameters) { - if(target instanceof IManaBlock) { - if(state == State.EMPTY) return ((IManaBlock) target).getCurrentMana() == 0; - else if(state == State.CONTAINS) return ((IManaBlock) target).getCurrentMana() > 0; - else if(target instanceof IManaReceiver) { - if(state == State.SPACE) return !((IManaReceiver) target).isFull(); - else if(state == State.FULL) return ((IManaReceiver) target).isFull(); - } - } - - return false; - } + public enum State { + EMPTY, + CONTAINS, + SPACE, + FULL + }; + + private State state; + + public TriggerManaLevel(State state) { + this.state = state; + } + + @Override + public String getUniqueTag() { + return "botania:mana" + state.name(); + } + + @Override + public void registerIcons(IIconRegister iconRegister) { + icon = IconHelper.forName(iconRegister, "triggers/mana" + WordUtils.capitalizeFully(state.name())); + } + + @Override + public String getDescription() { + return StatCollector.translateToLocal( + LibTriggerNames.TRIGGER_MANA_PREFIX + WordUtils.capitalizeFully(state.name())); + } + + @Override + public boolean isTriggerActive( + TileEntity target, ForgeDirection side, IStatementContainer source, IStatementParameter[] parameters) { + if (target instanceof IManaBlock) { + if (state == State.EMPTY) return ((IManaBlock) target).getCurrentMana() == 0; + else if (state == State.CONTAINS) return ((IManaBlock) target).getCurrentMana() > 0; + else if (target instanceof IManaReceiver) { + if (state == State.SPACE) return !((IManaReceiver) target).isFull(); + else if (state == State.FULL) return ((IManaReceiver) target).isFull(); + } + } + + return false; + } } diff --git a/src/main/java/vazkii/botania/common/integration/buildcraft/TriggerRuneAltarCanCraft.java b/src/main/java/vazkii/botania/common/integration/buildcraft/TriggerRuneAltarCanCraft.java index cbad8aa769..fe2ddfb20a 100644 --- a/src/main/java/vazkii/botania/common/integration/buildcraft/TriggerRuneAltarCanCraft.java +++ b/src/main/java/vazkii/botania/common/integration/buildcraft/TriggerRuneAltarCanCraft.java @@ -1,5 +1,8 @@ package vazkii.botania.common.integration.buildcraft; +import buildcraft.api.statements.IStatementContainer; +import buildcraft.api.statements.IStatementParameter; +import buildcraft.api.statements.ITriggerExternal; import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.StatCollector; @@ -7,31 +10,28 @@ import vazkii.botania.client.core.helper.IconHelper; import vazkii.botania.common.block.tile.TileRuneAltar; import vazkii.botania.common.lib.LibTriggerNames; -import buildcraft.api.statements.IStatementContainer; -import buildcraft.api.statements.IStatementParameter; -import buildcraft.api.statements.ITriggerExternal; public class TriggerRuneAltarCanCraft extends StatementBase implements ITriggerExternal { - @Override - public String getUniqueTag() { - return "botania:runeAltarCanCraft"; - } - - @Override - public void registerIcons(IIconRegister iconRegister) { - icon = IconHelper.forName(iconRegister, "triggers/runeAltarCanCraft"); - } + @Override + public String getUniqueTag() { + return "botania:runeAltarCanCraft"; + } - @Override - public String getDescription() { - return StatCollector.translateToLocal(LibTriggerNames.TRIGGER_RUNE_ALTAR_CAN_CRAFT); - } + @Override + public void registerIcons(IIconRegister iconRegister) { + icon = IconHelper.forName(iconRegister, "triggers/runeAltarCanCraft"); + } - @Override - public boolean isTriggerActive(TileEntity target, ForgeDirection side, IStatementContainer source, IStatementParameter[] parameters) { - if(target instanceof TileRuneAltar) return ((TileRuneAltar) target).hasValidRecipe(); - return false; - } + @Override + public String getDescription() { + return StatCollector.translateToLocal(LibTriggerNames.TRIGGER_RUNE_ALTAR_CAN_CRAFT); + } + @Override + public boolean isTriggerActive( + TileEntity target, ForgeDirection side, IStatementContainer source, IStatementParameter[] parameters) { + if (target instanceof TileRuneAltar) return ((TileRuneAltar) target).hasValidRecipe(); + return false; + } } diff --git a/src/main/java/vazkii/botania/common/integration/coloredlights/ColoredLightHelper.java b/src/main/java/vazkii/botania/common/integration/coloredlights/ColoredLightHelper.java index 46786e3694..d17457dc6d 100644 --- a/src/main/java/vazkii/botania/common/integration/coloredlights/ColoredLightHelper.java +++ b/src/main/java/vazkii/botania/common/integration/coloredlights/ColoredLightHelper.java @@ -2,67 +2,58 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Dec 26, 2014, 7:26:31 PM (GMT)] */ package vazkii.botania.common.integration.coloredlights; - /* * This class is presentto help with the Colored Lights mod without needing to package * the API or hold a dependency, please understand. */ public class ColoredLightHelper { - // Begin API Copypasta - // https://github.com/CptSpaceToaster/CptsModdingLight/blob/1.7.2/src/main/java/coloredlightscore/src/api/CLApi.java - - public static int r[] = new int[] { 0, 15, 0, 8, 0, 10, 0, 10, 5, 15, 8, 15, 0, 15, 15, 15 }; - public static int g[] = new int[] { 0, 0, 15, 3, 0, 0, 15, 10, 5, 10, 15, 15, 8, 0, 12, 15 }; - public static int b[] = new int[] { 0, 0, 0, 0, 15, 15, 15, 10, 5, 13, 0, 0, 15, 15, 10, 15 }; + // Begin API Copypasta + // https://github.com/CptSpaceToaster/CptsModdingLight/blob/1.7.2/src/main/java/coloredlightscore/src/api/CLApi.java - public static int makeRGBLightValue(float r, float g, float b, float currentLightValue) { - // Clamp color channels - if (r < 0.0f) - r = 0.0f; - else if (r > 1.0f) - r = 1.0f; + public static int r[] = new int[] {0, 15, 0, 8, 0, 10, 0, 10, 5, 15, 8, 15, 0, 15, 15, 15}; + public static int g[] = new int[] {0, 0, 15, 3, 0, 0, 15, 10, 5, 10, 15, 15, 8, 0, 12, 15}; + public static int b[] = new int[] {0, 0, 0, 0, 15, 15, 15, 10, 5, 13, 0, 0, 15, 15, 10, 15}; - if (g < 0.0f) - g = 0.0f; - else if (g > 1.0f) - g = 1.0f; + public static int makeRGBLightValue(float r, float g, float b, float currentLightValue) { + // Clamp color channels + if (r < 0.0f) r = 0.0f; + else if (r > 1.0f) r = 1.0f; - if (b < 0.0f) - b = 0.0f; - else if (b > 1.0f) - b = 1.0f; + if (g < 0.0f) g = 0.0f; + else if (g > 1.0f) g = 1.0f; - int brightness = (int) (currentLightValue * 15.0f); - brightness &= 0xf; + if (b < 0.0f) b = 0.0f; + else if (b > 1.0f) b = 1.0f; - return brightness | ((int) (15.0F * b) << 15) + ((int) (15.0F * g) << 10) + ((int) (15.0F * r) << 5); - } + int brightness = (int) (currentLightValue * 15.0f); + brightness &= 0xf; - // End API Copypasta + return brightness | ((int) (15.0F * b) << 15) + ((int) (15.0F * g) << 10) + ((int) (15.0F * r) << 5); + } - private static int packedColors[][] = null; + // End API Copypasta - public static int getPackedColor(int meta, int light) { - if(packedColors == null) - initPackedColors(); + private static int packedColors[][] = null; - return packedColors[meta][light]; - } + public static int getPackedColor(int meta, int light) { + if (packedColors == null) initPackedColors(); - private static void initPackedColors() { - packedColors = new int[16][16]; - for(int i = 0; i < 16; i++) - for(int j = 0; j < 16; j++) - packedColors[i][j] = makeRGBLightValue(r[15 - i], g[15 - i], b[15 - i], j / 16F); - } + return packedColors[meta][light]; + } + private static void initPackedColors() { + packedColors = new int[16][16]; + for (int i = 0; i < 16; i++) + for (int j = 0; j < 16; j++) + packedColors[i][j] = makeRGBLightValue(r[15 - i], g[15 - i], b[15 - i], j / 16F); + } } diff --git a/src/main/java/vazkii/botania/common/integration/coloredlights/ILightHelper.java b/src/main/java/vazkii/botania/common/integration/coloredlights/ILightHelper.java index e813b51324..adc9f14521 100644 --- a/src/main/java/vazkii/botania/common/integration/coloredlights/ILightHelper.java +++ b/src/main/java/vazkii/botania/common/integration/coloredlights/ILightHelper.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [May 16, 2015, 8:30:41 PM (GMT)] */ package vazkii.botania.common.integration.coloredlights; @@ -16,6 +16,7 @@ */ public interface ILightHelper { - public int makeRGBLightValue(float r, float g, float b, int currentLightValue); - public int getPackedColor(int meta, int light); + public int makeRGBLightValue(float r, float g, float b, int currentLightValue); + + public int getPackedColor(int meta, int light); } diff --git a/src/main/java/vazkii/botania/common/integration/coloredlights/LightHelper.java b/src/main/java/vazkii/botania/common/integration/coloredlights/LightHelper.java index a2788419ee..1adaf91f7e 100644 --- a/src/main/java/vazkii/botania/common/integration/coloredlights/LightHelper.java +++ b/src/main/java/vazkii/botania/common/integration/coloredlights/LightHelper.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [May 16, 2015, 8:30:41 PM (GMT)] */ package vazkii.botania.common.integration.coloredlights; @@ -17,11 +17,11 @@ */ public class LightHelper { - public static int makeRGBLightValue(float r, float g, float b, float currentLightValue) { - return Botania.lightHelper.makeRGBLightValue(r, g, b, (int) currentLightValue); - } + public static int makeRGBLightValue(float r, float g, float b, float currentLightValue) { + return Botania.lightHelper.makeRGBLightValue(r, g, b, (int) currentLightValue); + } - public static int getPackedColor(int meta, int light) { - return Botania.lightHelper.getPackedColor(meta, light); - } + public static int getPackedColor(int meta, int light) { + return Botania.lightHelper.getPackedColor(meta, light); + } } diff --git a/src/main/java/vazkii/botania/common/integration/coloredlights/LightHelperColored.java b/src/main/java/vazkii/botania/common/integration/coloredlights/LightHelperColored.java index 9b9f4580c7..81731056ac 100644 --- a/src/main/java/vazkii/botania/common/integration/coloredlights/LightHelperColored.java +++ b/src/main/java/vazkii/botania/common/integration/coloredlights/LightHelperColored.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [May 16, 2015, 8:30:41 PM (GMT)] */ package vazkii.botania.common.integration.coloredlights; @@ -15,14 +15,13 @@ */ public class LightHelperColored implements ILightHelper { - @Override - public int makeRGBLightValue(float r, float g, float b, int currentLightValue) { - return ColoredLightHelper.makeRGBLightValue(r, g, b, currentLightValue); - } - - @Override - public int getPackedColor(int meta, int light) { - return ColoredLightHelper.getPackedColor(meta, light); - } + @Override + public int makeRGBLightValue(float r, float g, float b, int currentLightValue) { + return ColoredLightHelper.makeRGBLightValue(r, g, b, currentLightValue); + } + @Override + public int getPackedColor(int meta, int light) { + return ColoredLightHelper.getPackedColor(meta, light); + } } diff --git a/src/main/java/vazkii/botania/common/integration/coloredlights/LightHelperVanilla.java b/src/main/java/vazkii/botania/common/integration/coloredlights/LightHelperVanilla.java index 441d0dd578..89baa25ef4 100644 --- a/src/main/java/vazkii/botania/common/integration/coloredlights/LightHelperVanilla.java +++ b/src/main/java/vazkii/botania/common/integration/coloredlights/LightHelperVanilla.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [May 16, 2015, 8:30:41 PM (GMT)] */ package vazkii.botania.common.integration.coloredlights; @@ -15,14 +15,13 @@ */ public class LightHelperVanilla implements ILightHelper { - @Override - public int makeRGBLightValue(float r, float g, float b, int currentLightValue) { - return currentLightValue; - } - - @Override - public int getPackedColor(int meta, int light) { - return light; - } + @Override + public int makeRGBLightValue(float r, float g, float b, int currentLightValue) { + return currentLightValue; + } + @Override + public int getPackedColor(int meta, int light) { + return light; + } } diff --git a/src/main/java/vazkii/botania/common/integration/corporea/WrappedDeepStorage.java b/src/main/java/vazkii/botania/common/integration/corporea/WrappedDeepStorage.java index b15b3097fe..5980a690e5 100644 --- a/src/main/java/vazkii/botania/common/integration/corporea/WrappedDeepStorage.java +++ b/src/main/java/vazkii/botania/common/integration/corporea/WrappedDeepStorage.java @@ -2,21 +2,19 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * */ package vazkii.botania.common.integration.corporea; +import cpw.mods.fml.common.FMLLog; import java.util.ArrayList; import java.util.List; - -import org.apache.logging.log4j.Level; - -import cpw.mods.fml.common.FMLLog; import net.minecraft.inventory.IInventory; import net.minecraft.item.ItemStack; +import org.apache.logging.log4j.Level; import powercrystals.minefactoryreloaded.api.IDeepStorageUnit; import vazkii.botania.api.corporea.CorporeaRequest; import vazkii.botania.api.corporea.ICorporeaSpark; @@ -28,109 +26,107 @@ */ public class WrappedDeepStorage extends WrappedInventoryBase { - private static boolean checkedInterface = false; - private static boolean deepStoragePresent = false; - - private IDeepStorageUnit inv; - - private WrappedDeepStorage(IDeepStorageUnit inv, ICorporeaSpark spark) { - this.inv = inv; - this.spark = spark; - } - - @Override - public IInventory getWrappedObject() { - return (IInventory) inv; - } - - @Override - public List countItems(CorporeaRequest request) { - return iterateOverStacks(request, false); - } - - @Override - public List extractItems(CorporeaRequest request) { - return iterateOverStacks(request, true); - } - - private List iterateOverStacks(CorporeaRequest request, boolean doit) { - List stacks = new ArrayList(); - boolean removedAny = false; - - ItemStack prototype = inv.getStoredItemType(); - if(prototype == null) { - // for the case of barrel without contents set - return stacks; - } - int storedCount = prototype.stackSize; - - // WARNING: this code is very similar in all implementations of - // IWrappedInventory - keep it synch - // this code is also near duplicate to WrappedStorageDrawers - keep it - // synchronized - if(isMatchingItemStack(request.matcher, request.checkNBT, prototype)) { - int rem = Math.min(storedCount, request.count == -1 ? storedCount : request.count); - - if(rem > 0) { - ItemStack copy = prototype.copy(); - copy.stackSize = rem; - if(doit) { - stacks.addAll(breakDownBigStack(copy)); - } else { - stacks.add(copy); - } - } - - request.foundItems += storedCount; - request.extractedItems += rem; - - if(doit && rem > 0) { - decreaseStoredCount(inv, rem); - - removedAny = true; - if(spark != null) - spark.onItemExtracted(prototype); - } - if(request.count != -1) - request.count -= rem; - } - if(removedAny) { - // inv.markDirtyIfNeeded(); - } - return stacks; - } - - private void decreaseStoredCount(IDeepStorageUnit inventory, int rem) { - inventory.setStoredItemCount(inventory.getStoredItemType().stackSize - rem); - } - - /** - * Creates {@link WrappedDeepStorage} if specified inv can be wrapped. - * - * @return wrapped inventory or null if it has incompatible type. - */ - public static IWrappedInventory wrap(IInventory inv, ICorporeaSpark spark) { - if(!isDeepStorageNeeded()) { - return null; - } - return inv instanceof IDeepStorageUnit ? new WrappedDeepStorage((IDeepStorageUnit) inv, spark) : null; - } - - /** - * This method checks for presence of Deep Storage API in the pack - if some - * other mod provides IDeepStorageUnit, support for Deep Storage will be - * used. This way we don't have to ship IDeepStorageUnit in Botania jar. - */ - private static boolean isDeepStorageNeeded() { - if(!checkedInterface) { - try { - deepStoragePresent = (Class.forName("powercrystals.minefactoryreloaded.api.IDeepStorageUnit") != null); - } catch (ClassNotFoundException e) { - deepStoragePresent = false; - } - checkedInterface = true; - FMLLog.log(Level.INFO, "[Botania] Corporea support for Deep Storage: %b", deepStoragePresent); - } - return deepStoragePresent; - } + private static boolean checkedInterface = false; + private static boolean deepStoragePresent = false; + + private IDeepStorageUnit inv; + + private WrappedDeepStorage(IDeepStorageUnit inv, ICorporeaSpark spark) { + this.inv = inv; + this.spark = spark; + } + + @Override + public IInventory getWrappedObject() { + return (IInventory) inv; + } + + @Override + public List countItems(CorporeaRequest request) { + return iterateOverStacks(request, false); + } + + @Override + public List extractItems(CorporeaRequest request) { + return iterateOverStacks(request, true); + } + + private List iterateOverStacks(CorporeaRequest request, boolean doit) { + List stacks = new ArrayList(); + boolean removedAny = false; + + ItemStack prototype = inv.getStoredItemType(); + if (prototype == null) { + // for the case of barrel without contents set + return stacks; + } + int storedCount = prototype.stackSize; + + // WARNING: this code is very similar in all implementations of + // IWrappedInventory - keep it synch + // this code is also near duplicate to WrappedStorageDrawers - keep it + // synchronized + if (isMatchingItemStack(request.matcher, request.checkNBT, prototype)) { + int rem = Math.min(storedCount, request.count == -1 ? storedCount : request.count); + + if (rem > 0) { + ItemStack copy = prototype.copy(); + copy.stackSize = rem; + if (doit) { + stacks.addAll(breakDownBigStack(copy)); + } else { + stacks.add(copy); + } + } + + request.foundItems += storedCount; + request.extractedItems += rem; + + if (doit && rem > 0) { + decreaseStoredCount(inv, rem); + + removedAny = true; + if (spark != null) spark.onItemExtracted(prototype); + } + if (request.count != -1) request.count -= rem; + } + if (removedAny) { + // inv.markDirtyIfNeeded(); + } + return stacks; + } + + private void decreaseStoredCount(IDeepStorageUnit inventory, int rem) { + inventory.setStoredItemCount(inventory.getStoredItemType().stackSize - rem); + } + + /** + * Creates {@link WrappedDeepStorage} if specified inv can be wrapped. + * + * @return wrapped inventory or null if it has incompatible type. + */ + public static IWrappedInventory wrap(IInventory inv, ICorporeaSpark spark) { + if (!isDeepStorageNeeded()) { + return null; + } + return inv instanceof IDeepStorageUnit ? new WrappedDeepStorage((IDeepStorageUnit) inv, spark) : null; + } + + /** + * This method checks for presence of Deep Storage API in the pack - if some + * other mod provides IDeepStorageUnit, support for Deep Storage will be + * used. This way we don't have to ship IDeepStorageUnit in Botania jar. + */ + private static boolean isDeepStorageNeeded() { + if (!checkedInterface) { + try { + deepStoragePresent = (Class.forName("powercrystals.minefactoryreloaded.api.IDeepStorageUnit") != null); + } catch (ClassNotFoundException e) { + deepStoragePresent = false; + } + checkedInterface = true; + FMLLog.log(Level.INFO, "[Botania] Corporea support for Deep Storage: %b", deepStoragePresent); + } + return deepStoragePresent; + } } diff --git a/src/main/java/vazkii/botania/common/integration/corporea/WrappedIInventory.java b/src/main/java/vazkii/botania/common/integration/corporea/WrappedIInventory.java index 837df4b9cf..8da375f34b 100644 --- a/src/main/java/vazkii/botania/common/integration/corporea/WrappedIInventory.java +++ b/src/main/java/vazkii/botania/common/integration/corporea/WrappedIInventory.java @@ -2,16 +2,15 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * */ package vazkii.botania.common.integration.corporea; import java.util.ArrayList; import java.util.List; - import net.minecraft.inventory.IInventory; import net.minecraft.item.ItemStack; import vazkii.botania.api.corporea.CorporeaHelper; @@ -19,74 +18,69 @@ import vazkii.botania.api.corporea.ICorporeaSpark; import vazkii.botania.api.corporea.IWrappedInventory; -public class WrappedIInventory extends WrappedInventoryBase{ - - private IInventory inv; - - private WrappedIInventory(IInventory inv, ICorporeaSpark spark) { - this.inv = inv; - this.spark = spark; - } - - @Override - public IInventory getWrappedObject() { - return inv; - } - - @Override - public List countItems(CorporeaRequest request) { - return iterateOverSlots(request, false); - } - - @Override - public List extractItems(CorporeaRequest request) { - return iterateOverSlots(request, true); - } - - private List iterateOverSlots(CorporeaRequest request, boolean doit) { - List stacks = new ArrayList(); - - boolean removedAny = false; - for (int i = inv.getSizeInventory() - 1; i >= 0; i--) { - if(!CorporeaHelper.isValidSlot(inv, i)) - continue; - - ItemStack stackAt = inv.getStackInSlot(i); - // WARNING: this code is very similar in all implementations of - // IWrappedInventory - keep it synch - if(isMatchingItemStack(request.matcher, request.checkNBT, stackAt)) { - int rem = Math.min(stackAt.stackSize, request.count == -1 ? stackAt.stackSize : request.count); - - if(rem > 0) { - ItemStack copy = stackAt.copy(); - if(rem < copy.stackSize) - copy.stackSize = rem; - stacks.add(copy); - } - - request.foundItems += stackAt.stackSize; - request.extractedItems += rem; - - if(doit && rem > 0) { - inv.decrStackSize(i, rem); - removedAny = true; - if(spark != null) - spark.onItemExtracted(stackAt); - } - if(request.count != -1) - request.count -= rem; - } - } - - if(removedAny) { - inv.markDirty(); - } - - return stacks; - } - - public static IWrappedInventory wrap(IInventory inv, ICorporeaSpark spark) { - return new WrappedIInventory(inv, spark); - } - +public class WrappedIInventory extends WrappedInventoryBase { + + private IInventory inv; + + private WrappedIInventory(IInventory inv, ICorporeaSpark spark) { + this.inv = inv; + this.spark = spark; + } + + @Override + public IInventory getWrappedObject() { + return inv; + } + + @Override + public List countItems(CorporeaRequest request) { + return iterateOverSlots(request, false); + } + + @Override + public List extractItems(CorporeaRequest request) { + return iterateOverSlots(request, true); + } + + private List iterateOverSlots(CorporeaRequest request, boolean doit) { + List stacks = new ArrayList(); + + boolean removedAny = false; + for (int i = inv.getSizeInventory() - 1; i >= 0; i--) { + if (!CorporeaHelper.isValidSlot(inv, i)) continue; + + ItemStack stackAt = inv.getStackInSlot(i); + // WARNING: this code is very similar in all implementations of + // IWrappedInventory - keep it synch + if (isMatchingItemStack(request.matcher, request.checkNBT, stackAt)) { + int rem = Math.min(stackAt.stackSize, request.count == -1 ? stackAt.stackSize : request.count); + + if (rem > 0) { + ItemStack copy = stackAt.copy(); + if (rem < copy.stackSize) copy.stackSize = rem; + stacks.add(copy); + } + + request.foundItems += stackAt.stackSize; + request.extractedItems += rem; + + if (doit && rem > 0) { + inv.decrStackSize(i, rem); + removedAny = true; + if (spark != null) spark.onItemExtracted(stackAt); + } + if (request.count != -1) request.count -= rem; + } + } + + if (removedAny) { + inv.markDirty(); + } + + return stacks; + } + + public static IWrappedInventory wrap(IInventory inv, ICorporeaSpark spark) { + return new WrappedIInventory(inv, spark); + } } diff --git a/src/main/java/vazkii/botania/common/integration/corporea/WrappedInventoryBase.java b/src/main/java/vazkii/botania/common/integration/corporea/WrappedInventoryBase.java index 9ff62e35ea..34230b80c1 100644 --- a/src/main/java/vazkii/botania/common/integration/corporea/WrappedInventoryBase.java +++ b/src/main/java/vazkii/botania/common/integration/corporea/WrappedInventoryBase.java @@ -2,17 +2,16 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * */ package vazkii.botania.common.integration.corporea; import java.util.ArrayList; import java.util.Collection; import java.util.List; - import net.minecraft.item.ItemStack; import vazkii.botania.api.corporea.CorporeaHelper; import vazkii.botania.api.corporea.ICorporeaSpark; @@ -20,33 +19,34 @@ public abstract class WrappedInventoryBase implements IWrappedInventory { - protected ICorporeaSpark spark; - - @Override - public ICorporeaSpark getSpark() { - return spark; - } - - protected boolean isMatchingItemStack(Object matcher, boolean checkNBT, ItemStack stackAt) { - return matcher instanceof ItemStack ? CorporeaHelper.stacksMatch((ItemStack) matcher, stackAt, checkNBT) - : matcher instanceof String ? CorporeaHelper.stacksMatch(stackAt, (String) matcher) : false; - } - - protected Collection breakDownBigStack(ItemStack stack) { - List stacks = new ArrayList(); - int additionalStacks = stack.stackSize / stack.getMaxStackSize(); - int lastStackSize = stack.stackSize % stack.getMaxStackSize(); - if(additionalStacks > 0) { - ItemStack fullStack = stack.copy(); - fullStack.stackSize = stack.getMaxStackSize(); - for (int i = 0; i < additionalStacks; i++) { - stacks.add(fullStack.copy()); - } - } - ItemStack lastStack = stack.copy(); - lastStack.stackSize = lastStackSize; - stacks.add(lastStack); - - return stacks; - } + protected ICorporeaSpark spark; + + @Override + public ICorporeaSpark getSpark() { + return spark; + } + + protected boolean isMatchingItemStack(Object matcher, boolean checkNBT, ItemStack stackAt) { + return matcher instanceof ItemStack + ? CorporeaHelper.stacksMatch((ItemStack) matcher, stackAt, checkNBT) + : matcher instanceof String ? CorporeaHelper.stacksMatch(stackAt, (String) matcher) : false; + } + + protected Collection breakDownBigStack(ItemStack stack) { + List stacks = new ArrayList(); + int additionalStacks = stack.stackSize / stack.getMaxStackSize(); + int lastStackSize = stack.stackSize % stack.getMaxStackSize(); + if (additionalStacks > 0) { + ItemStack fullStack = stack.copy(); + fullStack.stackSize = stack.getMaxStackSize(); + for (int i = 0; i < additionalStacks; i++) { + stacks.add(fullStack.copy()); + } + } + ItemStack lastStack = stack.copy(); + lastStack.stackSize = lastStackSize; + stacks.add(lastStack); + + return stacks; + } } diff --git a/src/main/java/vazkii/botania/common/integration/corporea/WrappedStorageDrawers.java b/src/main/java/vazkii/botania/common/integration/corporea/WrappedStorageDrawers.java index 2ee27ce9cb..617155b77b 100644 --- a/src/main/java/vazkii/botania/common/integration/corporea/WrappedStorageDrawers.java +++ b/src/main/java/vazkii/botania/common/integration/corporea/WrappedStorageDrawers.java @@ -2,19 +2,17 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * */ package vazkii.botania.common.integration.corporea; -import java.util.ArrayList; -import java.util.List; - import com.jaquadro.minecraft.storagedrawers.api.storage.IDrawer; import com.jaquadro.minecraft.storagedrawers.api.storage.IDrawerGroup; - +import java.util.ArrayList; +import java.util.List; import net.minecraft.inventory.IInventory; import net.minecraft.item.ItemStack; import vazkii.botania.api.corporea.CorporeaRequest; @@ -27,87 +25,85 @@ */ public class WrappedStorageDrawers extends WrappedInventoryBase { - private IDrawerGroup inv; - - private WrappedStorageDrawers(IDrawerGroup inv, ICorporeaSpark spark) { - this.inv = inv; - this.spark = spark; - } - - @Override - public IInventory getWrappedObject() { - return (IInventory) inv; - } - - @Override - public List countItems(CorporeaRequest request) { - return iterateOverStacks(request, false); - } - - @Override - public List extractItems(CorporeaRequest request) { - return iterateOverStacks(request, true); - } - - private List iterateOverStacks(CorporeaRequest request, boolean doit) { - List stacks = new ArrayList(); - boolean removedAny = false; - - for(int i = 0; i < inv.getDrawerCount(); i++) { - IDrawer drawer = inv.getDrawer(i); - if(drawer == null) { - continue; - } - ItemStack prototype = drawer.getStoredItemPrototype(); - int storedCount = drawer.getStoredItemCount(); - - // WARNING: this code is very similar in all implementations of - // IWrappedInventory - keep it synch - // also this code is near duplicate to WrappedDeepStorage - keep it - // synchronized - if(isMatchingItemStack(request.matcher, request.checkNBT, prototype)) { - int rem = Math.min(storedCount, request.count == -1 ? storedCount : request.count); - - if(rem > 0) { - ItemStack copy = prototype.copy(); - copy.stackSize = rem; - if(doit) { - stacks.addAll(breakDownBigStack(copy)); - } else { - stacks.add(copy); - } - } - - request.foundItems += storedCount; - request.extractedItems += rem; - - if(doit && rem > 0) { - decreaseStoredCount(drawer, rem); - - removedAny = true; - if(spark != null) - spark.onItemExtracted(prototype); - } - if(request.count != -1) - request.count -= rem; - } - } - if(removedAny) { - inv.markDirtyIfNeeded(); - } - return stacks; - } - - private void decreaseStoredCount(IDrawer drawer, int rem) { - drawer.setStoredItemCount(drawer.getStoredItemCount() - rem); - } - - /** - * Creates {@link WrappedStorageDrawers} if specified inv can be wrapped. - * - * @return wrapped inventory or null if it has incompatible type. - */ - public static IWrappedInventory wrap(IInventory inv, ICorporeaSpark spark) { - return inv instanceof IDrawerGroup ? new WrappedStorageDrawers((IDrawerGroup) inv, spark) : null; - } + private IDrawerGroup inv; + + private WrappedStorageDrawers(IDrawerGroup inv, ICorporeaSpark spark) { + this.inv = inv; + this.spark = spark; + } + + @Override + public IInventory getWrappedObject() { + return (IInventory) inv; + } + + @Override + public List countItems(CorporeaRequest request) { + return iterateOverStacks(request, false); + } + + @Override + public List extractItems(CorporeaRequest request) { + return iterateOverStacks(request, true); + } + + private List iterateOverStacks(CorporeaRequest request, boolean doit) { + List stacks = new ArrayList(); + boolean removedAny = false; + + for (int i = 0; i < inv.getDrawerCount(); i++) { + IDrawer drawer = inv.getDrawer(i); + if (drawer == null) { + continue; + } + ItemStack prototype = drawer.getStoredItemPrototype(); + int storedCount = drawer.getStoredItemCount(); + + // WARNING: this code is very similar in all implementations of + // IWrappedInventory - keep it synch + // also this code is near duplicate to WrappedDeepStorage - keep it + // synchronized + if (isMatchingItemStack(request.matcher, request.checkNBT, prototype)) { + int rem = Math.min(storedCount, request.count == -1 ? storedCount : request.count); + + if (rem > 0) { + ItemStack copy = prototype.copy(); + copy.stackSize = rem; + if (doit) { + stacks.addAll(breakDownBigStack(copy)); + } else { + stacks.add(copy); + } + } + + request.foundItems += storedCount; + request.extractedItems += rem; + + if (doit && rem > 0) { + decreaseStoredCount(drawer, rem); + + removedAny = true; + if (spark != null) spark.onItemExtracted(prototype); + } + if (request.count != -1) request.count -= rem; + } + } + if (removedAny) { + inv.markDirtyIfNeeded(); + } + return stacks; + } + + private void decreaseStoredCount(IDrawer drawer, int rem) { + drawer.setStoredItemCount(drawer.getStoredItemCount() - rem); + } + + /** + * Creates {@link WrappedStorageDrawers} if specified inv can be wrapped. + * + * @return wrapped inventory or null if it has incompatible type. + */ + public static IWrappedInventory wrap(IInventory inv, ICorporeaSpark spark) { + return inv instanceof IDrawerGroup ? new WrappedStorageDrawers((IDrawerGroup) inv, spark) : null; + } } diff --git a/src/main/java/vazkii/botania/common/integration/etfuturum/ModBanners.java b/src/main/java/vazkii/botania/common/integration/etfuturum/ModBanners.java index 8b140b780b..d78cd6c2ff 100644 --- a/src/main/java/vazkii/botania/common/integration/etfuturum/ModBanners.java +++ b/src/main/java/vazkii/botania/common/integration/etfuturum/ModBanners.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Aug 25, 2015, 7:11:35 PM (GMT)] */ package vazkii.botania.common.integration.etfuturum; @@ -18,34 +18,38 @@ public final class ModBanners { - public static void init() { - try { - Class> clazz = (Class>) Class.forName("ganymedes01.etfuturum.tileentities.TileEntityBanner$EnumBannerPattern"); - addPattern(clazz, "flower", "flr", new ItemStack(ModItems.manaResource, 1, 3)); - addPattern(clazz, "lexicon", "lex", new ItemStack(ModItems.lexicon)); - addPattern(clazz, "logo", "lgo", new ItemStack(ModItems.manaResource, 1, 4)); - addPattern(clazz, "sapling", "spl", new ItemStack(ModItems.manaResource, 1, 13)); - addPattern(clazz, "tiny_potato", "tpt", new ItemStack(ModBlocks.tinyPotato)); + public static void init() { + try { + Class> clazz = (Class>) + Class.forName("ganymedes01.etfuturum.tileentities.TileEntityBanner$EnumBannerPattern"); + addPattern(clazz, "flower", "flr", new ItemStack(ModItems.manaResource, 1, 3)); + addPattern(clazz, "lexicon", "lex", new ItemStack(ModItems.lexicon)); + addPattern(clazz, "logo", "lgo", new ItemStack(ModItems.manaResource, 1, 4)); + addPattern(clazz, "sapling", "spl", new ItemStack(ModItems.manaResource, 1, 13)); + addPattern(clazz, "tiny_potato", "tpt", new ItemStack(ModBlocks.tinyPotato)); - addPattern(clazz, "spark_dispersive", "sds", new ItemStack(ModItems.sparkUpgrade, 1, 0)); - addPattern(clazz, "spark_dominant", "sdm", new ItemStack(ModItems.sparkUpgrade, 1, 1)); - addPattern(clazz, "spark_recessive", "src", new ItemStack(ModItems.sparkUpgrade, 1, 2)); - addPattern(clazz, "spark_isolated", "sis", new ItemStack(ModItems.sparkUpgrade, 1, 3)); + addPattern(clazz, "spark_dispersive", "sds", new ItemStack(ModItems.sparkUpgrade, 1, 0)); + addPattern(clazz, "spark_dominant", "sdm", new ItemStack(ModItems.sparkUpgrade, 1, 1)); + addPattern(clazz, "spark_recessive", "src", new ItemStack(ModItems.sparkUpgrade, 1, 2)); + addPattern(clazz, "spark_isolated", "sis", new ItemStack(ModItems.sparkUpgrade, 1, 3)); - addPattern(clazz, "fish", "fis", new ItemStack(Items.fish)); - addPattern(clazz, "axe", "axe", new ItemStack(Items.iron_axe)); - addPattern(clazz, "hoe", "hoe", new ItemStack(Items.iron_hoe)); - addPattern(clazz, "pickaxe", "pik", new ItemStack(Items.iron_pickaxe)); - addPattern(clazz, "shovel", "shv", new ItemStack(Items.iron_shovel)); - addPattern(clazz, "sword", "srd", new ItemStack(Items.iron_sword)); - } catch (ClassNotFoundException e) { - // Looks like we don't have EtFuturum around, let's not do any of this nonsense then - } - } + addPattern(clazz, "fish", "fis", new ItemStack(Items.fish)); + addPattern(clazz, "axe", "axe", new ItemStack(Items.iron_axe)); + addPattern(clazz, "hoe", "hoe", new ItemStack(Items.iron_hoe)); + addPattern(clazz, "pickaxe", "pik", new ItemStack(Items.iron_pickaxe)); + addPattern(clazz, "shovel", "shv", new ItemStack(Items.iron_shovel)); + addPattern(clazz, "sword", "srd", new ItemStack(Items.iron_sword)); + } catch (ClassNotFoundException e) { + // Looks like we don't have EtFuturum around, let's not do any of this nonsense then + } + } - public static void addPattern(Class> clazz, String name, String id, ItemStack craftingItem) { - name = "botania_" + name; - id = "bt_" + id; - EnumHelper.addEnum(clazz, name.toUpperCase(), new Class[] { String.class, String.class, ItemStack.class }, new Object[] { name, id, craftingItem }); - } + public static void addPattern(Class> clazz, String name, String id, ItemStack craftingItem) { + name = "botania_" + name; + id = "bt_" + id; + EnumHelper.addEnum( + clazz, name.toUpperCase(), new Class[] {String.class, String.class, ItemStack.class}, new Object[] { + name, id, craftingItem + }); + } } diff --git a/src/main/java/vazkii/botania/common/integration/multipart/MultipartHandler.java b/src/main/java/vazkii/botania/common/integration/multipart/MultipartHandler.java index de6ef54c6f..b249b021d1 100644 --- a/src/main/java/vazkii/botania/common/integration/multipart/MultipartHandler.java +++ b/src/main/java/vazkii/botania/common/integration/multipart/MultipartHandler.java @@ -2,70 +2,65 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Sep 1, 2015, 5:32:15 PM (GMT)] */ package vazkii.botania.common.integration.multipart; -import java.util.ArrayList; -import java.util.List; - +import codechicken.microblock.BlockMicroMaterial; +import codechicken.microblock.MicroMaterialRegistry; import net.minecraft.block.Block; -import net.minecraft.item.Item; -import net.minecraft.item.ItemStack; import vazkii.botania.common.block.ModBlocks; import vazkii.botania.common.block.ModFluffBlocks; -import codechicken.microblock.BlockMicroMaterial; -import codechicken.microblock.MicroMaterialRegistry; public class MultipartHandler { - public MultipartHandler() { - registerMultiparts(ModBlocks.livingrock, 0, 4); - registerMultiparts(ModBlocks.livingwood, 0, 5); - registerMultiparts(ModBlocks.storage, 0, 4); - registerMultiparts(ModBlocks.dreamwood, 0, 4); - registerMultiparts(ModBlocks.prismarine, 0, 2); - registerMultiparts(ModBlocks.seaLamp); - registerMultiparts(ModBlocks.reedBlock); - registerMultiparts(ModBlocks.thatch); - registerMultiparts(ModBlocks.customBrick, 0, 15); - registerMultiparts(ModBlocks.elfGlass); - registerMultiparts(ModBlocks.manaGlass); - registerMultiparts(ModBlocks.endStoneBrick, 0, 3); - registerMultiparts(ModBlocks.blazeBlock); - registerMultiparts(ModBlocks.bifrostPerm); - registerMultiparts(ModBlocks.shimmerrock); - registerMultiparts(ModBlocks.shimmerwoodPlanks); - - registerMultiparts(ModFluffBlocks.darkQuartz, 0, 2); - registerMultiparts(ModFluffBlocks.manaQuartz, 0, 2); - registerMultiparts(ModFluffBlocks.blazeQuartz, 0, 2); - registerMultiparts(ModFluffBlocks.lavenderQuartz, 0, 2); - registerMultiparts(ModFluffBlocks.redQuartz, 0, 2); - registerMultiparts(ModFluffBlocks.elfQuartz, 0, 2); - registerMultiparts(ModFluffBlocks.sunnyQuartz, 0, 2); - registerMultiparts(ModFluffBlocks.biomeStoneA, 0, 15); - registerMultiparts(ModFluffBlocks.biomeStoneB, 0, 15); - registerMultiparts(ModFluffBlocks.stone, 0, 15); - registerMultiparts(ModFluffBlocks.pavement, 0, 5); - } + public MultipartHandler() { + registerMultiparts(ModBlocks.livingrock, 0, 4); + registerMultiparts(ModBlocks.livingwood, 0, 5); + registerMultiparts(ModBlocks.storage, 0, 4); + registerMultiparts(ModBlocks.dreamwood, 0, 4); + registerMultiparts(ModBlocks.prismarine, 0, 2); + registerMultiparts(ModBlocks.seaLamp); + registerMultiparts(ModBlocks.reedBlock); + registerMultiparts(ModBlocks.thatch); + registerMultiparts(ModBlocks.customBrick, 0, 15); + registerMultiparts(ModBlocks.elfGlass); + registerMultiparts(ModBlocks.manaGlass); + registerMultiparts(ModBlocks.endStoneBrick, 0, 3); + registerMultiparts(ModBlocks.blazeBlock); + registerMultiparts(ModBlocks.bifrostPerm); + registerMultiparts(ModBlocks.shimmerrock); + registerMultiparts(ModBlocks.shimmerwoodPlanks); - private static void registerMultiparts(Block block) { - registerMultiparts(block, 0); - } + registerMultiparts(ModFluffBlocks.darkQuartz, 0, 2); + registerMultiparts(ModFluffBlocks.manaQuartz, 0, 2); + registerMultiparts(ModFluffBlocks.blazeQuartz, 0, 2); + registerMultiparts(ModFluffBlocks.lavenderQuartz, 0, 2); + registerMultiparts(ModFluffBlocks.redQuartz, 0, 2); + registerMultiparts(ModFluffBlocks.elfQuartz, 0, 2); + registerMultiparts(ModFluffBlocks.sunnyQuartz, 0, 2); + registerMultiparts(ModFluffBlocks.biomeStoneA, 0, 15); + registerMultiparts(ModFluffBlocks.biomeStoneB, 0, 15); + registerMultiparts(ModFluffBlocks.stone, 0, 15); + registerMultiparts(ModFluffBlocks.pavement, 0, 5); + } - private static void registerMultiparts(Block block, int meta) { - MicroMaterialRegistry.registerMaterial(new BlockMicroMaterial(block, meta), block.getUnlocalizedName() + (meta == 0 ? "" : "_" + meta)); - } + private static void registerMultiparts(Block block) { + registerMultiparts(block, 0); + } - private static void registerMultiparts(Block block, int metamin, int metamax) { - for (int i = metamin; i <= metamax; i++) { - registerMultiparts(block, i); - } - } + private static void registerMultiparts(Block block, int meta) { + MicroMaterialRegistry.registerMaterial( + new BlockMicroMaterial(block, meta), block.getUnlocalizedName() + (meta == 0 ? "" : "_" + meta)); + } + private static void registerMultiparts(Block block, int metamin, int metamax) { + for (int i = metamin; i <= metamax; i++) { + registerMultiparts(block, i); + } + } } diff --git a/src/main/java/vazkii/botania/common/item/Item16Colors.java b/src/main/java/vazkii/botania/common/item/Item16Colors.java index 5abafdc6cd..b572d56cd8 100644 --- a/src/main/java/vazkii/botania/common/item/Item16Colors.java +++ b/src/main/java/vazkii/botania/common/item/Item16Colors.java @@ -2,17 +2,16 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jan 19, 2014, 4:09:57 PM (GMT)] */ package vazkii.botania.common.item; import java.awt.Color; import java.util.List; - import net.minecraft.creativetab.CreativeTabs; import net.minecraft.entity.passive.EntitySheep; import net.minecraft.item.Item; @@ -20,34 +19,31 @@ public class Item16Colors extends ItemMod { - public Item16Colors(String name) { - super(); - setHasSubtypes(true); - setUnlocalizedName(name); - } - - @Override - public int getColorFromItemStack(ItemStack par1ItemStack, int par2) { - if(par1ItemStack.getItemDamage() >= EntitySheep.fleeceColorTable.length) - return 0xFFFFFF; - - float[] color = EntitySheep.fleeceColorTable[par1ItemStack.getItemDamage()]; - return new Color(color[0], color[1], color[2]).getRGB(); - } - - @Override - public void getSubItems(Item item, CreativeTabs par2CreativeTabs, List par3List) { - for(int i = 0; i < 16; i++) - par3List.add(new ItemStack(item, 1, i)); - } - - @Override - public String getUnlocalizedName(ItemStack par1ItemStack) { - return getUnlocalizedNameLazy(par1ItemStack) + par1ItemStack.getItemDamage(); - } - - String getUnlocalizedNameLazy(ItemStack par1ItemStack) { - return super.getUnlocalizedName(par1ItemStack); - } - + public Item16Colors(String name) { + super(); + setHasSubtypes(true); + setUnlocalizedName(name); + } + + @Override + public int getColorFromItemStack(ItemStack par1ItemStack, int par2) { + if (par1ItemStack.getItemDamage() >= EntitySheep.fleeceColorTable.length) return 0xFFFFFF; + + float[] color = EntitySheep.fleeceColorTable[par1ItemStack.getItemDamage()]; + return new Color(color[0], color[1], color[2]).getRGB(); + } + + @Override + public void getSubItems(Item item, CreativeTabs par2CreativeTabs, List par3List) { + for (int i = 0; i < 16; i++) par3List.add(new ItemStack(item, 1, i)); + } + + @Override + public String getUnlocalizedName(ItemStack par1ItemStack) { + return getUnlocalizedNameLazy(par1ItemStack) + par1ItemStack.getItemDamage(); + } + + String getUnlocalizedNameLazy(ItemStack par1ItemStack) { + return super.getUnlocalizedName(par1ItemStack); + } } diff --git a/src/main/java/vazkii/botania/common/item/ItemAncientWill.java b/src/main/java/vazkii/botania/common/item/ItemAncientWill.java index 5001267dfe..f855acc71f 100644 --- a/src/main/java/vazkii/botania/common/item/ItemAncientWill.java +++ b/src/main/java/vazkii/botania/common/item/ItemAncientWill.java @@ -2,16 +2,16 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jan 30, 2015, 10:59:45 PM (GMT)] */ package vazkii.botania.common.item; +import cpw.mods.fml.common.registry.GameRegistry; import java.util.List; - import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.entity.player.EntityPlayer; @@ -24,55 +24,51 @@ import vazkii.botania.client.core.helper.IconHelper; import vazkii.botania.common.crafting.recipe.AncientWillRecipe; import vazkii.botania.common.lib.LibItemNames; -import cpw.mods.fml.common.registry.GameRegistry; public class ItemAncientWill extends ItemMod { - private static final int SUBTYPES = 6; - - IIcon[] icons; - - public ItemAncientWill() { - setUnlocalizedName(LibItemNames.ANCIENT_WILL); - setHasSubtypes(true); - setMaxStackSize(1); + private static final int SUBTYPES = 6; - GameRegistry.addRecipe(new AncientWillRecipe()); - RecipeSorter.register("botania:ancientWill", AncientWillRecipe.class, Category.SHAPELESS, ""); - } + IIcon[] icons; - @Override - public void getSubItems(Item item, CreativeTabs tab, List list) { - for(int i = 0; i < SUBTYPES; i++) - list.add(new ItemStack(item, 1, i)); - } + public ItemAncientWill() { + setUnlocalizedName(LibItemNames.ANCIENT_WILL); + setHasSubtypes(true); + setMaxStackSize(1); - @Override - public void registerIcons(IIconRegister par1IconRegister) { - icons = new IIcon[SUBTYPES]; - for(int i = 0; i < icons.length; i++) - icons[i] = IconHelper.forItem(par1IconRegister, this, i); - } + GameRegistry.addRecipe(new AncientWillRecipe()); + RecipeSorter.register("botania:ancientWill", AncientWillRecipe.class, Category.SHAPELESS, ""); + } - @Override - public IIcon getIconFromDamage(int dmg) { - return icons[Math.min(icons.length - 1, dmg)]; - } + @Override + public void getSubItems(Item item, CreativeTabs tab, List list) { + for (int i = 0; i < SUBTYPES; i++) list.add(new ItemStack(item, 1, i)); + } - @Override - public void addInformation(ItemStack stack, EntityPlayer player, List list, boolean adv) { - addStringToTooltip(StatCollector.translateToLocal("botaniamisc.craftToAddWill"), list); - addStringToTooltip(StatCollector.translateToLocal("botania.armorset.will" + stack.getItemDamage() + ".shortDesc"), list); - } + @Override + public void registerIcons(IIconRegister par1IconRegister) { + icons = new IIcon[SUBTYPES]; + for (int i = 0; i < icons.length; i++) icons[i] = IconHelper.forItem(par1IconRegister, this, i); + } - public void addStringToTooltip(String s, List tooltip) { - tooltip.add(s.replaceAll("&", "\u00a7")); - } + @Override + public IIcon getIconFromDamage(int dmg) { + return icons[Math.min(icons.length - 1, dmg)]; + } - @Override - public String getUnlocalizedName(ItemStack par1ItemStack) { - return super.getUnlocalizedName(par1ItemStack) + par1ItemStack.getItemDamage(); - } + @Override + public void addInformation(ItemStack stack, EntityPlayer player, List list, boolean adv) { + addStringToTooltip(StatCollector.translateToLocal("botaniamisc.craftToAddWill"), list); + addStringToTooltip( + StatCollector.translateToLocal("botania.armorset.will" + stack.getItemDamage() + ".shortDesc"), list); + } + public void addStringToTooltip(String s, List tooltip) { + tooltip.add(s.replaceAll("&", "\u00a7")); + } + @Override + public String getUnlocalizedName(ItemStack par1ItemStack) { + return super.getUnlocalizedName(par1ItemStack) + par1ItemStack.getItemDamage(); + } } diff --git a/src/main/java/vazkii/botania/common/item/ItemAutocraftingHalo.java b/src/main/java/vazkii/botania/common/item/ItemAutocraftingHalo.java index abafbe8c7e..6da14d3b94 100644 --- a/src/main/java/vazkii/botania/common/item/ItemAutocraftingHalo.java +++ b/src/main/java/vazkii/botania/common/item/ItemAutocraftingHalo.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Sep 1, 2015, 2:23:26 AM (GMT)] */ package vazkii.botania.common.item; @@ -21,28 +21,26 @@ public class ItemAutocraftingHalo extends ItemCraftingHalo { - private static final ResourceLocation glowTexture = new ResourceLocation(LibResources.MISC_GLOW_CYAN); + private static final ResourceLocation glowTexture = new ResourceLocation(LibResources.MISC_GLOW_CYAN); - public ItemAutocraftingHalo() { - super(LibItemNames.AUTOCRAFTING_HALO); - } + public ItemAutocraftingHalo() { + super(LibItemNames.AUTOCRAFTING_HALO); + } - @Override - public void onUpdate(ItemStack stack, World world, Entity entity, int pos, boolean equipped) { - super.onUpdate(stack, world, entity, pos, equipped); + @Override + public void onUpdate(ItemStack stack, World world, Entity entity, int pos, boolean equipped) { + super.onUpdate(stack, world, entity, pos, equipped); - if(entity instanceof EntityPlayer && !equipped) { - EntityPlayer player = (EntityPlayer) entity; - IInventory inv = getFakeInv(player); + if (entity instanceof EntityPlayer && !equipped) { + EntityPlayer player = (EntityPlayer) entity; + IInventory inv = getFakeInv(player); - for(int i = 1; i < SEGMENTS; i++) - tryCraft(player, stack, i, false, inv, false); - } - } - - @Override - public ResourceLocation getGlowResource() { - return glowTexture; - } + for (int i = 1; i < SEGMENTS; i++) tryCraft(player, stack, i, false, inv, false); + } + } + @Override + public ResourceLocation getGlowResource() { + return glowTexture; + } } diff --git a/src/main/java/vazkii/botania/common/item/ItemBaubleBox.java b/src/main/java/vazkii/botania/common/item/ItemBaubleBox.java index 925627a2a5..21bf39189d 100644 --- a/src/main/java/vazkii/botania/common/item/ItemBaubleBox.java +++ b/src/main/java/vazkii/botania/common/item/ItemBaubleBox.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [25/11/2015, 19:46:11 (GMT)] */ package vazkii.botania.common.item; @@ -22,45 +22,42 @@ public class ItemBaubleBox extends ItemMod { - private static final String TAG_ITEMS = "InvItems"; - private static final String TAG_SLOT = "Slot"; - - public ItemBaubleBox() { - setUnlocalizedName(LibItemNames.BAUBLE_BOX); - setMaxStackSize(1); - } - - @Override - public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer player) { - player.openGui(Botania.instance, LibGuiIDs.BAUBLE_BOX, world, 0, 0, 0); - return stack; - } - - - public static ItemStack[] loadStacks(ItemStack stack) { - NBTTagList var2 = ItemNBTHelper.getList(stack, TAG_ITEMS, 10, false); - ItemStack[] inventorySlots = new ItemStack[36]; - for(int var3 = 0; var3 < var2.tagCount(); ++var3) { - NBTTagCompound var4 = var2.getCompoundTagAt(var3); - byte var5 = var4.getByte(TAG_SLOT); - if(var5 >= 0 && var5 < inventorySlots.length) - inventorySlots[var5] = ItemStack.loadItemStackFromNBT(var4); - } - - return inventorySlots; - } - - public static void setStacks(ItemStack stack, ItemStack[] inventorySlots) { - NBTTagList var2 = new NBTTagList(); - for(int var3 = 0; var3 < inventorySlots.length; ++var3) - if(inventorySlots[var3] != null) { - NBTTagCompound var4 = new NBTTagCompound(); - var4.setByte(TAG_SLOT, (byte)var3); - inventorySlots[var3].writeToNBT(var4); - var2.appendTag(var4); - } - - ItemNBTHelper.setList(stack, TAG_ITEMS, var2); - } - + private static final String TAG_ITEMS = "InvItems"; + private static final String TAG_SLOT = "Slot"; + + public ItemBaubleBox() { + setUnlocalizedName(LibItemNames.BAUBLE_BOX); + setMaxStackSize(1); + } + + @Override + public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer player) { + player.openGui(Botania.instance, LibGuiIDs.BAUBLE_BOX, world, 0, 0, 0); + return stack; + } + + public static ItemStack[] loadStacks(ItemStack stack) { + NBTTagList var2 = ItemNBTHelper.getList(stack, TAG_ITEMS, 10, false); + ItemStack[] inventorySlots = new ItemStack[36]; + for (int var3 = 0; var3 < var2.tagCount(); ++var3) { + NBTTagCompound var4 = var2.getCompoundTagAt(var3); + byte var5 = var4.getByte(TAG_SLOT); + if (var5 >= 0 && var5 < inventorySlots.length) inventorySlots[var5] = ItemStack.loadItemStackFromNBT(var4); + } + + return inventorySlots; + } + + public static void setStacks(ItemStack stack, ItemStack[] inventorySlots) { + NBTTagList var2 = new NBTTagList(); + for (int var3 = 0; var3 < inventorySlots.length; ++var3) + if (inventorySlots[var3] != null) { + NBTTagCompound var4 = new NBTTagCompound(); + var4.setByte(TAG_SLOT, (byte) var3); + inventorySlots[var3].writeToNBT(var4); + var2.appendTag(var4); + } + + ItemNBTHelper.setList(stack, TAG_ITEMS, var2); + } } diff --git a/src/main/java/vazkii/botania/common/item/ItemBlackHoleTalisman.java b/src/main/java/vazkii/botania/common/item/ItemBlackHoleTalisman.java index 98cd2cd1ca..4375ab255c 100644 --- a/src/main/java/vazkii/botania/common/item/ItemBlackHoleTalisman.java +++ b/src/main/java/vazkii/botania/common/item/ItemBlackHoleTalisman.java @@ -2,17 +2,19 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Mar 31, 2015, 11:04:12 PM (GMT)] */ package vazkii.botania.common.item; +import cpw.mods.fml.common.registry.GameRegistry; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; import java.util.Arrays; import java.util.List; - import net.minecraft.block.Block; import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.entity.Entity; @@ -39,285 +41,314 @@ import vazkii.botania.common.core.helper.ItemNBTHelper; import vazkii.botania.common.crafting.recipe.BlackHoleTalismanExtractRecipe; import vazkii.botania.common.lib.LibItemNames; -import cpw.mods.fml.common.registry.GameRegistry; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; public class ItemBlackHoleTalisman extends ItemMod implements IBlockProvider { - private static final String TAG_BLOCK_NAME = "blockName"; - private static final String TAG_BLOCK_META = "blockMeta"; - private static final String TAG_BLOCK_COUNT = "blockCount"; - - IIcon enabledIcon; - - public ItemBlackHoleTalisman() { - setUnlocalizedName(LibItemNames.BLACK_HOLE_TALISMAN); - setMaxStackSize(1); - setHasSubtypes(true); - - GameRegistry.addRecipe(new BlackHoleTalismanExtractRecipe()); - RecipeSorter.register("botania:blackHoleTalismanExtract", BlackHoleTalismanExtractRecipe.class, Category.SHAPELESS, ""); - } - - @Override - public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer) { - if(getBlock(par1ItemStack) != Blocks.air && par3EntityPlayer.isSneaking()) { - int dmg = par1ItemStack.getItemDamage(); - par1ItemStack.setItemDamage(~dmg & 1); - par2World.playSoundAtEntity(par3EntityPlayer, "random.orb", 0.3F, 0.1F); - } - - return par1ItemStack; - } - - @Override - public boolean onItemUse(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, World par3World, int par4, int par5, int par6, int par7, float par8, float par9, float par10) { - Block block = par3World.getBlock(par4, par5, par6); - int meta = par3World.getBlockMetadata(par4, par5, par6); - boolean set = setBlock(par1ItemStack, block, meta); - - if(!set) { - Block bBlock = getBlock(par1ItemStack); - int bmeta = getBlockMeta(par1ItemStack); - - TileEntity tile = par3World.getTileEntity(par4, par5, par6); - if(tile != null && tile instanceof IInventory) { - IInventory inv = (IInventory) tile; - int[] slots = inv instanceof ISidedInventory ? ((ISidedInventory) inv).getAccessibleSlotsFromSide(par7) : InventoryHelper.buildSlotsForLinearInventory(inv); - for(int slot : slots) { - ItemStack stackInSlot = inv.getStackInSlot(slot); - if(stackInSlot == null) { - ItemStack stack = new ItemStack(bBlock, 1, bmeta); - int maxSize = stack.getMaxStackSize(); - stack.stackSize = remove(par1ItemStack, maxSize); - if(stack.stackSize != 0) { - if(inv.isItemValidForSlot(slot, stack) && (!(inv instanceof ISidedInventory) || ((ISidedInventory) inv).canInsertItem(slot, stack, par7))) { - inv.setInventorySlotContents(slot, stack); - inv.markDirty(); - set = true; - } - } - } else if(stackInSlot.getItem() == Item.getItemFromBlock(bBlock) && stackInSlot.getItemDamage() == bmeta) { - int maxSize = stackInSlot.getMaxStackSize(); - int missing = maxSize - stackInSlot.stackSize; - if(inv.isItemValidForSlot(slot, stackInSlot) && (!(inv instanceof ISidedInventory) || ((ISidedInventory) inv).canInsertItem(slot, stackInSlot, par7))) { - stackInSlot.stackSize += remove(par1ItemStack, missing); - inv.markDirty(); - set = true; - } - } - } - } else { - ForgeDirection dir = ForgeDirection.getOrientation(par7); - int entities = par3World.getEntitiesWithinAABB(EntityLivingBase.class, AxisAlignedBB.getBoundingBox(par4 + dir.offsetX, par5 + dir.offsetY, par6 + dir.offsetZ, par4 + dir.offsetX + 1, par5 + dir.offsetY + 1, par6 + dir.offsetZ + 1)).size(); - - if(entities == 0) { - int remove = par2EntityPlayer.capabilities.isCreativeMode ? 1 : remove(par1ItemStack, 1); - if(remove > 0) { - ItemStack stack = new ItemStack(bBlock, 1, bmeta); - ItemsRemainingRenderHandler.set(stack, getBlockCount(par1ItemStack)); - - Item.getItemFromBlock(bBlock).onItemUse(stack, par2EntityPlayer, par3World, par4, par5, par6, par7, par8, par9, par10); - set = true; - } - } - } - } - - par2EntityPlayer.setCurrentItemOrArmor(0, par1ItemStack); - return set; - } - - @Override - public void onUpdate(ItemStack itemstack, World p_77663_2_, Entity entity, int p_77663_4_, boolean p_77663_5_) { - Block block = getBlock(itemstack); - if(!entity.worldObj.isRemote && itemstack.getItemDamage() == 1 && block != Blocks.air && entity instanceof EntityPlayer) { - EntityPlayer player = (EntityPlayer) entity; - int meta = getBlockMeta(itemstack); - - int highest = -1; - int[] counts = new int[player.inventory.getSizeInventory() - player.inventory.armorInventory.length]; - Arrays.fill(counts, 0); - - for(int i = 0; i < counts.length; i++) { - ItemStack stack = player.inventory.getStackInSlot(i); - if(stack == null) { - continue; - } - - if(Item.getItemFromBlock(block) == stack.getItem() && stack.getItemDamage() == meta) { - counts[i] = stack.stackSize; - if(highest == -1) - highest = i; - else highest = counts[i] > counts[highest] && highest > 8 ? i : highest; - } - } - - if(highest == -1) { - /*ItemStack heldItem = player.inventory.getItemStack(); - if(hasFreeSlot && (heldItem == null || Item.getItemFromBlock(block) == heldItem.getItem() || heldItem.getItemDamage() != meta)) { - ItemStack stack = new ItemStack(block, remove(itemstack, 64), meta); - if(stack.stackSize != 0) - player.inventory.addItemStackToInventory(stack); - }*/ - // Used to keep one stack, disabled for now - } else { - for(int i = 0; i < counts.length; i++) { - int count = counts[i]; - - // highest is used to keep one stack, disabled for now - if(/*i == highest || */count == 0) - continue; - - add(itemstack, count); - player.inventory.setInventorySlotContents(i, null); - } - - /*int countInHighest = counts[highest]; - int maxSize = new ItemStack(block, 1, meta).getMaxStackSize(); - if(countInHighest < maxSize) { - int missing = maxSize - countInHighest; - ItemStack stackInHighest = player.inventory.getStackInSlot(highest); - stackInHighest.stackSize += remove(itemstack, missing); - }*/ - // Used to keep one stack, disabled for now - } - } - } - - @Override - public String getItemStackDisplayName(ItemStack par1ItemStack) { - Block block = getBlock(par1ItemStack); - int meta = getBlockMeta(par1ItemStack); - ItemStack stack = new ItemStack(block, 1, meta); - - return super.getItemStackDisplayName(par1ItemStack) + (stack == null || stack.getItem() == null ? "" : " (" + EnumChatFormatting.GREEN + stack.getDisplayName() + EnumChatFormatting.RESET + ")"); - } - - @Override - public ItemStack getContainerItem(ItemStack itemStack) { - int count = getBlockCount(itemStack); - if(count == 0) - return null; - - int extract = Math.min(64, count); - ItemStack copy = itemStack.copy(); - remove(copy, extract); - - int dmg = copy.getItemDamage(); - if(dmg == 1) - copy.setItemDamage(0); - - return copy; - } - - @Override - public boolean hasContainerItem(ItemStack stack) { - return getContainerItem(stack) != null; - } - - @Override - public boolean doesContainerItemLeaveCraftingGrid(ItemStack p_77630_1_) { - return false; - } - - private boolean setBlock(ItemStack stack, Block block, int meta) { - if(getBlock(stack) == Blocks.air || getBlockCount(stack) == 0) { - ItemNBTHelper.setString(stack, TAG_BLOCK_NAME, Block.blockRegistry.getNameForObject(block)); - ItemNBTHelper.setInt(stack, TAG_BLOCK_META, meta); - return true; - } - return false; - } - - private void add(ItemStack stack, int count) { - int current = getBlockCount(stack); - setCount(stack, current + count); - } - - @Override - @SideOnly(Side.CLIENT) - public void registerIcons(IIconRegister par1IconRegister) { - itemIcon = IconHelper.forItem(par1IconRegister, this, 0); - enabledIcon = IconHelper.forItem(par1IconRegister, this, 1); - } - - @Override - @SideOnly(Side.CLIENT) - public IIcon getIconFromDamage(int par1) { - return par1 == 1 ? enabledIcon : itemIcon; - } - - @Override - @SideOnly(Side.CLIENT) - public void addInformation(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, List par3List, boolean par4) { - Block block = getBlock(par1ItemStack); - if(block != null && block != Blocks.air) { - int count = getBlockCount(par1ItemStack); - par3List.add(count + " " + StatCollector.translateToLocal(new ItemStack(block, 1, getBlockMeta(par1ItemStack)).getUnlocalizedName() + ".name")); - } - - if(par1ItemStack.getItemDamage() == 1) - addStringToTooltip(StatCollector.translateToLocal("botaniamisc.active"), par3List); - else addStringToTooltip(StatCollector.translateToLocal("botaniamisc.inactive"), par3List); - } - - void addStringToTooltip(String s, List tooltip) { - tooltip.add(s.replaceAll("&", "\u00a7")); - } - - private static void setCount(ItemStack stack, int count) { - ItemNBTHelper.setInt(stack, TAG_BLOCK_COUNT, count); - } - - public static int remove(ItemStack stack, int count) { - int current = getBlockCount(stack); - setCount(stack, Math.max(current - count, 0)); - - return Math.min(current, count); - } - - public static String getBlockName(ItemStack stack) { - return ItemNBTHelper.getString(stack, TAG_BLOCK_NAME, ""); - } - - public static Block getBlock(ItemStack stack) { - Block block = Block.getBlockFromName(getBlockName(stack)); - return block; - } - - public static int getBlockMeta(ItemStack stack) { - return ItemNBTHelper.getInt(stack, TAG_BLOCK_META, 0); - } - - public static int getBlockCount(ItemStack stack) { - return ItemNBTHelper.getInt(stack, TAG_BLOCK_COUNT, 0); - } - - @Override - public boolean provideBlock(EntityPlayer player, ItemStack requestor, ItemStack stack, Block block, int meta, boolean doit) { - Block stored = getBlock(stack); - int storedMeta = getBlockMeta(stack); - if(stored == block && storedMeta == meta) { - int count = getBlockCount(stack); - if(count > 0) { - if(doit) - setCount(stack, count - 1); - return true; - } - } - - return false; - } - - @Override - public int getBlockCount(EntityPlayer player, ItemStack requestor, ItemStack stack, Block block, int meta) { - Block stored = getBlock(stack); - int storedMeta = getBlockMeta(stack); - if(stored == block && storedMeta == meta) - return getBlockCount(stack); - return 0; - } - + private static final String TAG_BLOCK_NAME = "blockName"; + private static final String TAG_BLOCK_META = "blockMeta"; + private static final String TAG_BLOCK_COUNT = "blockCount"; + + IIcon enabledIcon; + + public ItemBlackHoleTalisman() { + setUnlocalizedName(LibItemNames.BLACK_HOLE_TALISMAN); + setMaxStackSize(1); + setHasSubtypes(true); + + GameRegistry.addRecipe(new BlackHoleTalismanExtractRecipe()); + RecipeSorter.register( + "botania:blackHoleTalismanExtract", BlackHoleTalismanExtractRecipe.class, Category.SHAPELESS, ""); + } + + @Override + public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer) { + if (getBlock(par1ItemStack) != Blocks.air && par3EntityPlayer.isSneaking()) { + int dmg = par1ItemStack.getItemDamage(); + par1ItemStack.setItemDamage(~dmg & 1); + par2World.playSoundAtEntity(par3EntityPlayer, "random.orb", 0.3F, 0.1F); + } + + return par1ItemStack; + } + + @Override + public boolean onItemUse( + ItemStack par1ItemStack, + EntityPlayer par2EntityPlayer, + World par3World, + int par4, + int par5, + int par6, + int par7, + float par8, + float par9, + float par10) { + Block block = par3World.getBlock(par4, par5, par6); + int meta = par3World.getBlockMetadata(par4, par5, par6); + boolean set = setBlock(par1ItemStack, block, meta); + + if (!set) { + Block bBlock = getBlock(par1ItemStack); + int bmeta = getBlockMeta(par1ItemStack); + + TileEntity tile = par3World.getTileEntity(par4, par5, par6); + if (tile != null && tile instanceof IInventory) { + IInventory inv = (IInventory) tile; + int[] slots = inv instanceof ISidedInventory + ? ((ISidedInventory) inv).getAccessibleSlotsFromSide(par7) + : InventoryHelper.buildSlotsForLinearInventory(inv); + for (int slot : slots) { + ItemStack stackInSlot = inv.getStackInSlot(slot); + if (stackInSlot == null) { + ItemStack stack = new ItemStack(bBlock, 1, bmeta); + int maxSize = stack.getMaxStackSize(); + stack.stackSize = remove(par1ItemStack, maxSize); + if (stack.stackSize != 0) { + if (inv.isItemValidForSlot(slot, stack) + && (!(inv instanceof ISidedInventory) + || ((ISidedInventory) inv).canInsertItem(slot, stack, par7))) { + inv.setInventorySlotContents(slot, stack); + inv.markDirty(); + set = true; + } + } + } else if (stackInSlot.getItem() == Item.getItemFromBlock(bBlock) + && stackInSlot.getItemDamage() == bmeta) { + int maxSize = stackInSlot.getMaxStackSize(); + int missing = maxSize - stackInSlot.stackSize; + if (inv.isItemValidForSlot(slot, stackInSlot) + && (!(inv instanceof ISidedInventory) + || ((ISidedInventory) inv).canInsertItem(slot, stackInSlot, par7))) { + stackInSlot.stackSize += remove(par1ItemStack, missing); + inv.markDirty(); + set = true; + } + } + } + } else { + ForgeDirection dir = ForgeDirection.getOrientation(par7); + int entities = par3World + .getEntitiesWithinAABB( + EntityLivingBase.class, + AxisAlignedBB.getBoundingBox( + par4 + dir.offsetX, + par5 + dir.offsetY, + par6 + dir.offsetZ, + par4 + dir.offsetX + 1, + par5 + dir.offsetY + 1, + par6 + dir.offsetZ + 1)) + .size(); + + if (entities == 0) { + int remove = par2EntityPlayer.capabilities.isCreativeMode ? 1 : remove(par1ItemStack, 1); + if (remove > 0) { + ItemStack stack = new ItemStack(bBlock, 1, bmeta); + ItemsRemainingRenderHandler.set(stack, getBlockCount(par1ItemStack)); + + Item.getItemFromBlock(bBlock) + .onItemUse( + stack, par2EntityPlayer, par3World, par4, par5, par6, par7, par8, par9, par10); + set = true; + } + } + } + } + + par2EntityPlayer.setCurrentItemOrArmor(0, par1ItemStack); + return set; + } + + @Override + public void onUpdate(ItemStack itemstack, World p_77663_2_, Entity entity, int p_77663_4_, boolean p_77663_5_) { + Block block = getBlock(itemstack); + if (!entity.worldObj.isRemote + && itemstack.getItemDamage() == 1 + && block != Blocks.air + && entity instanceof EntityPlayer) { + EntityPlayer player = (EntityPlayer) entity; + int meta = getBlockMeta(itemstack); + + int highest = -1; + int[] counts = new int[player.inventory.getSizeInventory() - player.inventory.armorInventory.length]; + Arrays.fill(counts, 0); + + for (int i = 0; i < counts.length; i++) { + ItemStack stack = player.inventory.getStackInSlot(i); + if (stack == null) { + continue; + } + + if (Item.getItemFromBlock(block) == stack.getItem() && stack.getItemDamage() == meta) { + counts[i] = stack.stackSize; + if (highest == -1) highest = i; + else highest = counts[i] > counts[highest] && highest > 8 ? i : highest; + } + } + + if (highest == -1) { + /*ItemStack heldItem = player.inventory.getItemStack(); + if(hasFreeSlot && (heldItem == null || Item.getItemFromBlock(block) == heldItem.getItem() || heldItem.getItemDamage() != meta)) { + ItemStack stack = new ItemStack(block, remove(itemstack, 64), meta); + if(stack.stackSize != 0) + player.inventory.addItemStackToInventory(stack); + }*/ + // Used to keep one stack, disabled for now + } else { + for (int i = 0; i < counts.length; i++) { + int count = counts[i]; + + // highest is used to keep one stack, disabled for now + if (/*i == highest || */ count == 0) continue; + + add(itemstack, count); + player.inventory.setInventorySlotContents(i, null); + } + + /*int countInHighest = counts[highest]; + int maxSize = new ItemStack(block, 1, meta).getMaxStackSize(); + if(countInHighest < maxSize) { + int missing = maxSize - countInHighest; + ItemStack stackInHighest = player.inventory.getStackInSlot(highest); + stackInHighest.stackSize += remove(itemstack, missing); + }*/ + // Used to keep one stack, disabled for now + } + } + } + + @Override + public String getItemStackDisplayName(ItemStack par1ItemStack) { + Block block = getBlock(par1ItemStack); + int meta = getBlockMeta(par1ItemStack); + ItemStack stack = new ItemStack(block, 1, meta); + + return super.getItemStackDisplayName(par1ItemStack) + + (stack == null || stack.getItem() == null + ? "" + : " (" + EnumChatFormatting.GREEN + stack.getDisplayName() + EnumChatFormatting.RESET + ")"); + } + + @Override + public ItemStack getContainerItem(ItemStack itemStack) { + int count = getBlockCount(itemStack); + if (count == 0) return null; + + int extract = Math.min(64, count); + ItemStack copy = itemStack.copy(); + remove(copy, extract); + + int dmg = copy.getItemDamage(); + if (dmg == 1) copy.setItemDamage(0); + + return copy; + } + + @Override + public boolean hasContainerItem(ItemStack stack) { + return getContainerItem(stack) != null; + } + + @Override + public boolean doesContainerItemLeaveCraftingGrid(ItemStack p_77630_1_) { + return false; + } + + private boolean setBlock(ItemStack stack, Block block, int meta) { + if (getBlock(stack) == Blocks.air || getBlockCount(stack) == 0) { + ItemNBTHelper.setString(stack, TAG_BLOCK_NAME, Block.blockRegistry.getNameForObject(block)); + ItemNBTHelper.setInt(stack, TAG_BLOCK_META, meta); + return true; + } + return false; + } + + private void add(ItemStack stack, int count) { + int current = getBlockCount(stack); + setCount(stack, current + count); + } + + @Override + @SideOnly(Side.CLIENT) + public void registerIcons(IIconRegister par1IconRegister) { + itemIcon = IconHelper.forItem(par1IconRegister, this, 0); + enabledIcon = IconHelper.forItem(par1IconRegister, this, 1); + } + + @Override + @SideOnly(Side.CLIENT) + public IIcon getIconFromDamage(int par1) { + return par1 == 1 ? enabledIcon : itemIcon; + } + + @Override + @SideOnly(Side.CLIENT) + public void addInformation(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, List par3List, boolean par4) { + Block block = getBlock(par1ItemStack); + if (block != null && block != Blocks.air) { + int count = getBlockCount(par1ItemStack); + par3List.add(count + " " + + StatCollector.translateToLocal( + new ItemStack(block, 1, getBlockMeta(par1ItemStack)).getUnlocalizedName() + ".name")); + } + + if (par1ItemStack.getItemDamage() == 1) + addStringToTooltip(StatCollector.translateToLocal("botaniamisc.active"), par3List); + else addStringToTooltip(StatCollector.translateToLocal("botaniamisc.inactive"), par3List); + } + + void addStringToTooltip(String s, List tooltip) { + tooltip.add(s.replaceAll("&", "\u00a7")); + } + + private static void setCount(ItemStack stack, int count) { + ItemNBTHelper.setInt(stack, TAG_BLOCK_COUNT, count); + } + + public static int remove(ItemStack stack, int count) { + int current = getBlockCount(stack); + setCount(stack, Math.max(current - count, 0)); + + return Math.min(current, count); + } + + public static String getBlockName(ItemStack stack) { + return ItemNBTHelper.getString(stack, TAG_BLOCK_NAME, ""); + } + + public static Block getBlock(ItemStack stack) { + Block block = Block.getBlockFromName(getBlockName(stack)); + return block; + } + + public static int getBlockMeta(ItemStack stack) { + return ItemNBTHelper.getInt(stack, TAG_BLOCK_META, 0); + } + + public static int getBlockCount(ItemStack stack) { + return ItemNBTHelper.getInt(stack, TAG_BLOCK_COUNT, 0); + } + + @Override + public boolean provideBlock( + EntityPlayer player, ItemStack requestor, ItemStack stack, Block block, int meta, boolean doit) { + Block stored = getBlock(stack); + int storedMeta = getBlockMeta(stack); + if (stored == block && storedMeta == meta) { + int count = getBlockCount(stack); + if (count > 0) { + if (doit) setCount(stack, count - 1); + return true; + } + } + + return false; + } + + @Override + public int getBlockCount(EntityPlayer player, ItemStack requestor, ItemStack stack, Block block, int meta) { + Block stored = getBlock(stack); + int storedMeta = getBlockMeta(stack); + if (stored == block && storedMeta == meta) return getBlockCount(stack); + return 0; + } } diff --git a/src/main/java/vazkii/botania/common/item/ItemBlackLotus.java b/src/main/java/vazkii/botania/common/item/ItemBlackLotus.java index 69002fd3dd..fcebed6c3f 100644 --- a/src/main/java/vazkii/botania/common/item/ItemBlackLotus.java +++ b/src/main/java/vazkii/botania/common/item/ItemBlackLotus.java @@ -2,16 +2,15 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jan 18, 2015, 12:17:10 AM (GMT)] */ package vazkii.botania.common.item; import java.util.List; - import net.minecraft.creativetab.CreativeTabs; import net.minecraft.entity.item.EntityItem; import net.minecraft.entity.player.EntityPlayer; @@ -27,63 +26,60 @@ public class ItemBlackLotus extends ItemMod implements IManaDissolvable { - private static final int MANA_PER = 8000; - private static final int MANA_PER_T2 = 100000; - - public ItemBlackLotus() { - setUnlocalizedName(LibItemNames.BLACK_LOTUS); - setHasSubtypes(true); - } - - @Override - public void getSubItems(Item item, CreativeTabs tab, List list) { - for(int i = 0; i < 2; i++) - list.add(new ItemStack(item, 1, i)); - } - - @Override - public boolean hasEffect(ItemStack par1ItemStack, int pass) { - return par1ItemStack.getItemDamage() > 0; - } - - @Override - public String getUnlocalizedName(ItemStack par1ItemStack) { - return super.getUnlocalizedName(par1ItemStack) + par1ItemStack.getItemDamage(); - } - - @Override - public void onDissolveTick(IManaPool pool, ItemStack stack, EntityItem item) { - if(pool.isFull() || pool.getCurrentMana() == 0) - return; - - TileEntity tile = (TileEntity) pool; - boolean t2 = stack.getItemDamage() > 0; - - if(!item.worldObj.isRemote) { - pool.recieveMana(t2 ? MANA_PER_T2 : MANA_PER); - stack.stackSize--; - VanillaPacketDispatcher.dispatchTEToNearbyPlayers(item.worldObj, tile.xCoord, tile.yCoord, tile.zCoord); - } - - for(int i = 0; i < 50; i++) { - float r = (float) Math.random() * 0.25F; - float g = 0F; - float b = (float) Math.random() * 0.25F; - float s = 0.45F * (float) Math.random() * 0.25F; - - float m = 0.045F; - float mx = ((float) Math.random() - 0.5F) * m; - float my = (float) Math.random() * m; - float mz = ((float) Math.random() - 0.5F) * m; - - Botania.proxy.wispFX(item.worldObj, item.posX, tile.yCoord + 0.5F, item.posZ, r, g, b, s, mx, my, mz); - } - item.worldObj.playSoundAtEntity(item, "botania:blackLotus", 0.5F, t2 ? 0.1F : 1F); - } - - @Override - public void addInformation(ItemStack stack, EntityPlayer player, List list, boolean adv) { - list.add(StatCollector.translateToLocal("botaniamisc.lotusDesc")); - } - + private static final int MANA_PER = 8000; + private static final int MANA_PER_T2 = 100000; + + public ItemBlackLotus() { + setUnlocalizedName(LibItemNames.BLACK_LOTUS); + setHasSubtypes(true); + } + + @Override + public void getSubItems(Item item, CreativeTabs tab, List list) { + for (int i = 0; i < 2; i++) list.add(new ItemStack(item, 1, i)); + } + + @Override + public boolean hasEffect(ItemStack par1ItemStack, int pass) { + return par1ItemStack.getItemDamage() > 0; + } + + @Override + public String getUnlocalizedName(ItemStack par1ItemStack) { + return super.getUnlocalizedName(par1ItemStack) + par1ItemStack.getItemDamage(); + } + + @Override + public void onDissolveTick(IManaPool pool, ItemStack stack, EntityItem item) { + if (pool.isFull() || pool.getCurrentMana() == 0) return; + + TileEntity tile = (TileEntity) pool; + boolean t2 = stack.getItemDamage() > 0; + + if (!item.worldObj.isRemote) { + pool.recieveMana(t2 ? MANA_PER_T2 : MANA_PER); + stack.stackSize--; + VanillaPacketDispatcher.dispatchTEToNearbyPlayers(item.worldObj, tile.xCoord, tile.yCoord, tile.zCoord); + } + + for (int i = 0; i < 50; i++) { + float r = (float) Math.random() * 0.25F; + float g = 0F; + float b = (float) Math.random() * 0.25F; + float s = 0.45F * (float) Math.random() * 0.25F; + + float m = 0.045F; + float mx = ((float) Math.random() - 0.5F) * m; + float my = (float) Math.random() * m; + float mz = ((float) Math.random() - 0.5F) * m; + + Botania.proxy.wispFX(item.worldObj, item.posX, tile.yCoord + 0.5F, item.posZ, r, g, b, s, mx, my, mz); + } + item.worldObj.playSoundAtEntity(item, "botania:blackLotus", 0.5F, t2 ? 0.1F : 1F); + } + + @Override + public void addInformation(ItemStack stack, EntityPlayer player, List list, boolean adv) { + list.add(StatCollector.translateToLocal("botaniamisc.lotusDesc")); + } } diff --git a/src/main/java/vazkii/botania/common/item/ItemBottledMana.java b/src/main/java/vazkii/botania/common/item/ItemBottledMana.java index a2bec1876a..d82f9e7310 100644 --- a/src/main/java/vazkii/botania/common/item/ItemBottledMana.java +++ b/src/main/java/vazkii/botania/common/item/ItemBottledMana.java @@ -2,17 +2,16 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jun 27, 2014, 2:41:19 AM (GMT)] */ package vazkii.botania.common.item; import java.util.List; import java.util.Random; - import net.minecraft.block.Block; import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.entity.Entity; @@ -40,211 +39,223 @@ public class ItemBottledMana extends ItemMod { - IIcon[] icons; - private static final String TAG_SEED = "randomSeed"; - - public ItemBottledMana() { - setUnlocalizedName(LibItemNames.MANA_BOTTLE); - setMaxStackSize(1); - setMaxDamage(6); - } - - public void effect(EntityPlayer player, int id) { - switch(id) { - case 0 : { // Random motion - player.motionX = (Math.random() - 0.5) * 3; - player.motionZ = (Math.random() - 0.5) * 3; - break; - } - case 1 : { // Water - if(!player.worldObj.isRemote && !player.worldObj.provider.isHellWorld) - player.worldObj.setBlock(MathHelper.floor_double(player.posX), MathHelper.floor_double(player.posY), MathHelper.floor_double(player.posZ), Blocks.flowing_water); - break; - } - case 2 : { // Set on Fire - if(!player.worldObj.isRemote) - player.setFire(4); - break; - } - case 3 : { // Mini Explosion - if(!player.worldObj.isRemote) - player.worldObj.createExplosion(null, player.posX, player.posY, player.posZ, 0.25F, false); - break; - } - case 4 : { // Mega Jump - if(!player.worldObj.provider.isHellWorld) { - if(!player.worldObj.isRemote) - player.addPotionEffect(new PotionEffect(Potion.resistance.id, 300, 5)); - player.motionY = 6; - } - - break; - } - case 5 : { // Randomly set HP - if(!player.worldObj.isRemote) - player.setHealth(player.worldObj.rand.nextInt(19) + 1); - break; - } - case 6 : { // Lots O' Hearts - if(!player.worldObj.isRemote) - player.addPotionEffect(new PotionEffect(Potion.field_76444_x.id, 20 * 60 * 2, 9)); - break; - } - case 7 : { // All your inventory is belong to us - if(!player.worldObj.isRemote) - for(int i = 0; i < player.inventory.getSizeInventory(); i++) - if(i != player.inventory.currentItem) { - ItemStack stackAt = player.inventory.getStackInSlot(i); - if(stackAt != null) - player.dropPlayerItemWithRandomChoice(stackAt, true); - player.inventory.setInventorySlotContents(i, null); - } - - break; - } - case 8 : { // Break your neck - player.rotationPitch = (float) Math.random() * 360F; - player.rotationYaw = (float) Math.random() * 180F; - - break; - } - case 9 : { // Highest Possible - int x = MathHelper.floor_double(player.posX); - MathHelper.floor_double(player.posY); - int z = MathHelper.floor_double(player.posZ); - for(int i = 256; i > 0; i--) { - Block block = player.worldObj.getBlock(x, i, z); - if(!block.isAir(player.worldObj, x, i, z)) { - if(player instanceof EntityPlayerMP) { - EntityPlayerMP mp = (EntityPlayerMP) player; - mp.playerNetServerHandler.setPlayerLocation(player.posX, i + 1.6, player.posZ, player.rotationYaw, player.rotationPitch); - } - break; - } - } - - break; - } - case 10 : { // HYPERSPEEEEEED - if(!player.worldObj.isRemote) - player.addPotionEffect(new PotionEffect(Potion.moveSpeed.id, 60, 200)); - break; - } - case 11 : { // Night Vision - if(!player.worldObj.isRemote) - player.addPotionEffect(new PotionEffect(Potion.nightVision.id, 6000, 0)); - break; - } - case 12 : { // Flare - if(!player.worldObj.isRemote) { - EntitySignalFlare flare = new EntitySignalFlare(player.worldObj); - flare.setPosition(player.posX, player.posY, player.posZ); - flare.setColor(player.worldObj.rand.nextInt(16)); - player.worldObj.playSoundAtEntity(player, "random.explode", 40F, (1.0F + (player.worldObj.rand.nextFloat() - player.worldObj.rand.nextFloat()) * 0.2F) * 0.7F); - - player.worldObj.spawnEntityInWorld(flare); - - int range = 5; - List entities = player.worldObj.getEntitiesWithinAABB(EntityLivingBase.class, AxisAlignedBB.getBoundingBox(player.posX - range, player.posY - range, player.posZ - range, player.posX + range, player.posY + range, player.posZ + range)); - for(EntityLivingBase entity : entities) - if(entity != player && (!(entity instanceof EntityPlayer) || MinecraftServer.getServer() == null || MinecraftServer.getServer().isPVPEnabled())) - entity.addPotionEffect(new PotionEffect(Potion.moveSlowdown.id, 50, 5)); - } - - break; - } - case 13 : { // Pixie Friend - if(!player.worldObj.isRemote) { - EntityPixie pixie = new EntityPixie(player.worldObj); - pixie.setPosition(player.posX, player.posY + 1.5, player.posZ); - player.worldObj.spawnEntityInWorld(pixie); - } - break; - } - case 14 : { // Nausea + Blindness :3 - if(!player.worldObj.isRemote) { - player.addPotionEffect(new PotionEffect(Potion.confusion.id, 160, 3)); - player.addPotionEffect(new PotionEffect(Potion.blindness.id, 160, 0)); - } - - break; - } - case 15 : { // Drop own Head - if(!player.worldObj.isRemote) { - player.attackEntityFrom(DamageSource.magic, player.getHealth() - 1); - ItemStack stack = new ItemStack(Items.skull, 1, 3); - ItemNBTHelper.setString(stack, "SkullOwner", player.getCommandSenderName()); - player.dropPlayerItemWithRandomChoice(stack, true); - } - break; - } - } - } - - @Override - public void onUpdate(ItemStack par1ItemStack, World par2World, Entity par3Entity, int par4, boolean par5) { - getSeed(par1ItemStack); - } - - public void randomEffect(EntityPlayer player, ItemStack stack) { - effect(player, new Random(getSeed(stack)).nextInt(16)); - } - - long getSeed(ItemStack stack) { - long seed = ItemNBTHelper.getLong(stack, TAG_SEED, -1); - if(seed == -1) - return randomSeed(stack); - return seed; - } - - long randomSeed(ItemStack stack) { - long seed = Math.abs(itemRand.nextLong()); - ItemNBTHelper.setLong(stack, TAG_SEED, seed); - return seed; - } - - @Override - public void addInformation(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, List par3List, boolean par4) { - par3List.add(StatCollector.translateToLocal("botaniamisc.bottleTooltip")); - } - - @Override - public void registerIcons(IIconRegister par1IconRegister) { - icons = new IIcon[6]; - for(int i = 0; i < icons.length; i++) - icons[i] = IconHelper.forItem(par1IconRegister, this, i); - } - - @Override - public IIcon getIconFromDamage(int par1) { - return icons[Math.min(icons.length - 1, par1)]; - } - - @Override - public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer) { - par3EntityPlayer.setItemInUse(par1ItemStack, getMaxItemUseDuration(par1ItemStack)); - return par1ItemStack; - } - - @Override - public ItemStack onEaten(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer) { - randomEffect(par3EntityPlayer, par1ItemStack); - par1ItemStack.setItemDamage(par1ItemStack.getItemDamage() + 1); - randomSeed(par1ItemStack); - - if(par1ItemStack.getItemDamage() == 6) - return new ItemStack(Items.glass_bottle); - return par1ItemStack; - } - - @Override - public int getMaxItemUseDuration(ItemStack par1ItemStack) { - return 20; - } - - @Override - public EnumAction getItemUseAction(ItemStack par1ItemStack) { - return EnumAction.drink; - } + IIcon[] icons; + private static final String TAG_SEED = "randomSeed"; + + public ItemBottledMana() { + setUnlocalizedName(LibItemNames.MANA_BOTTLE); + setMaxStackSize(1); + setMaxDamage(6); + } + + public void effect(EntityPlayer player, int id) { + switch (id) { + case 0: { // Random motion + player.motionX = (Math.random() - 0.5) * 3; + player.motionZ = (Math.random() - 0.5) * 3; + break; + } + case 1: { // Water + if (!player.worldObj.isRemote && !player.worldObj.provider.isHellWorld) + player.worldObj.setBlock( + MathHelper.floor_double(player.posX), + MathHelper.floor_double(player.posY), + MathHelper.floor_double(player.posZ), + Blocks.flowing_water); + break; + } + case 2: { // Set on Fire + if (!player.worldObj.isRemote) player.setFire(4); + break; + } + case 3: { // Mini Explosion + if (!player.worldObj.isRemote) + player.worldObj.createExplosion(null, player.posX, player.posY, player.posZ, 0.25F, false); + break; + } + case 4: { // Mega Jump + if (!player.worldObj.provider.isHellWorld) { + if (!player.worldObj.isRemote) + player.addPotionEffect(new PotionEffect(Potion.resistance.id, 300, 5)); + player.motionY = 6; + } + + break; + } + case 5: { // Randomly set HP + if (!player.worldObj.isRemote) player.setHealth(player.worldObj.rand.nextInt(19) + 1); + break; + } + case 6: { // Lots O' Hearts + if (!player.worldObj.isRemote) + player.addPotionEffect(new PotionEffect(Potion.field_76444_x.id, 20 * 60 * 2, 9)); + break; + } + case 7: { // All your inventory is belong to us + if (!player.worldObj.isRemote) + for (int i = 0; i < player.inventory.getSizeInventory(); i++) + if (i != player.inventory.currentItem) { + ItemStack stackAt = player.inventory.getStackInSlot(i); + if (stackAt != null) player.dropPlayerItemWithRandomChoice(stackAt, true); + player.inventory.setInventorySlotContents(i, null); + } + + break; + } + case 8: { // Break your neck + player.rotationPitch = (float) Math.random() * 360F; + player.rotationYaw = (float) Math.random() * 180F; + + break; + } + case 9: { // Highest Possible + int x = MathHelper.floor_double(player.posX); + MathHelper.floor_double(player.posY); + int z = MathHelper.floor_double(player.posZ); + for (int i = 256; i > 0; i--) { + Block block = player.worldObj.getBlock(x, i, z); + if (!block.isAir(player.worldObj, x, i, z)) { + if (player instanceof EntityPlayerMP) { + EntityPlayerMP mp = (EntityPlayerMP) player; + mp.playerNetServerHandler.setPlayerLocation( + player.posX, i + 1.6, player.posZ, player.rotationYaw, player.rotationPitch); + } + break; + } + } + + break; + } + case 10: { // HYPERSPEEEEEED + if (!player.worldObj.isRemote) player.addPotionEffect(new PotionEffect(Potion.moveSpeed.id, 60, 200)); + break; + } + case 11: { // Night Vision + if (!player.worldObj.isRemote) player.addPotionEffect(new PotionEffect(Potion.nightVision.id, 6000, 0)); + break; + } + case 12: { // Flare + if (!player.worldObj.isRemote) { + EntitySignalFlare flare = new EntitySignalFlare(player.worldObj); + flare.setPosition(player.posX, player.posY, player.posZ); + flare.setColor(player.worldObj.rand.nextInt(16)); + player.worldObj.playSoundAtEntity( + player, + "random.explode", + 40F, + (1.0F + (player.worldObj.rand.nextFloat() - player.worldObj.rand.nextFloat()) * 0.2F) + * 0.7F); + + player.worldObj.spawnEntityInWorld(flare); + + int range = 5; + List entities = player.worldObj.getEntitiesWithinAABB( + EntityLivingBase.class, + AxisAlignedBB.getBoundingBox( + player.posX - range, + player.posY - range, + player.posZ - range, + player.posX + range, + player.posY + range, + player.posZ + range)); + for (EntityLivingBase entity : entities) + if (entity != player + && (!(entity instanceof EntityPlayer) + || MinecraftServer.getServer() == null + || MinecraftServer.getServer().isPVPEnabled())) + entity.addPotionEffect(new PotionEffect(Potion.moveSlowdown.id, 50, 5)); + } + + break; + } + case 13: { // Pixie Friend + if (!player.worldObj.isRemote) { + EntityPixie pixie = new EntityPixie(player.worldObj); + pixie.setPosition(player.posX, player.posY + 1.5, player.posZ); + player.worldObj.spawnEntityInWorld(pixie); + } + break; + } + case 14: { // Nausea + Blindness :3 + if (!player.worldObj.isRemote) { + player.addPotionEffect(new PotionEffect(Potion.confusion.id, 160, 3)); + player.addPotionEffect(new PotionEffect(Potion.blindness.id, 160, 0)); + } + + break; + } + case 15: { // Drop own Head + if (!player.worldObj.isRemote) { + player.attackEntityFrom(DamageSource.magic, player.getHealth() - 1); + ItemStack stack = new ItemStack(Items.skull, 1, 3); + ItemNBTHelper.setString(stack, "SkullOwner", player.getCommandSenderName()); + player.dropPlayerItemWithRandomChoice(stack, true); + } + break; + } + } + } + + @Override + public void onUpdate(ItemStack par1ItemStack, World par2World, Entity par3Entity, int par4, boolean par5) { + getSeed(par1ItemStack); + } + + public void randomEffect(EntityPlayer player, ItemStack stack) { + effect(player, new Random(getSeed(stack)).nextInt(16)); + } + + long getSeed(ItemStack stack) { + long seed = ItemNBTHelper.getLong(stack, TAG_SEED, -1); + if (seed == -1) return randomSeed(stack); + return seed; + } + + long randomSeed(ItemStack stack) { + long seed = Math.abs(itemRand.nextLong()); + ItemNBTHelper.setLong(stack, TAG_SEED, seed); + return seed; + } + + @Override + public void addInformation(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, List par3List, boolean par4) { + par3List.add(StatCollector.translateToLocal("botaniamisc.bottleTooltip")); + } + + @Override + public void registerIcons(IIconRegister par1IconRegister) { + icons = new IIcon[6]; + for (int i = 0; i < icons.length; i++) icons[i] = IconHelper.forItem(par1IconRegister, this, i); + } + + @Override + public IIcon getIconFromDamage(int par1) { + return icons[Math.min(icons.length - 1, par1)]; + } + + @Override + public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer) { + par3EntityPlayer.setItemInUse(par1ItemStack, getMaxItemUseDuration(par1ItemStack)); + return par1ItemStack; + } + + @Override + public ItemStack onEaten(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer) { + randomEffect(par3EntityPlayer, par1ItemStack); + par1ItemStack.setItemDamage(par1ItemStack.getItemDamage() + 1); + randomSeed(par1ItemStack); + + if (par1ItemStack.getItemDamage() == 6) return new ItemStack(Items.glass_bottle); + return par1ItemStack; + } + + @Override + public int getMaxItemUseDuration(ItemStack par1ItemStack) { + return 20; + } + @Override + public EnumAction getItemUseAction(ItemStack par1ItemStack) { + return EnumAction.drink; + } } diff --git a/src/main/java/vazkii/botania/common/item/ItemCacophonium.java b/src/main/java/vazkii/botania/common/item/ItemCacophonium.java index e5c52b05e2..b509825ed1 100644 --- a/src/main/java/vazkii/botania/common/item/ItemCacophonium.java +++ b/src/main/java/vazkii/botania/common/item/ItemCacophonium.java @@ -2,16 +2,16 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jul 20, 2015, 9:53:57 PM (GMT)] */ package vazkii.botania.common.item; +import cpw.mods.fml.relauncher.ReflectionHelper; import java.util.List; - import net.minecraft.block.Block; import net.minecraft.entity.EntityList; import net.minecraft.entity.EntityLiving; @@ -33,127 +33,138 @@ import vazkii.botania.common.core.helper.ItemNBTHelper; import vazkii.botania.common.lib.LibItemNames; import vazkii.botania.common.lib.LibObfuscation; -import cpw.mods.fml.relauncher.ReflectionHelper; public class ItemCacophonium extends ItemMod implements ICraftAchievement { - private static final String TAG_SOUND = "sound"; - private static final String TAG_SOUND_NAME = "soundName"; - private static final String TAG_HAS_SOUND = "hasSound"; - - public ItemCacophonium() { - setMaxStackSize(1); - setUnlocalizedName(LibItemNames.CACOPHONIUM); - } - - @Override - public boolean itemInteractionForEntity(ItemStack stack, EntityPlayer player, EntityLivingBase entity) { - if(entity instanceof EntityLiving) { - EntityLiving living = (EntityLiving) entity; - String sound = null; - try { - if(living instanceof EntityCreeper) - sound = "creeper.primed"; - else if(living instanceof EntitySlime) - sound = "mob.slime." + (((EntitySlime) living).getSlimeSize() > 1 ? "big" : "small"); - else sound = (String) ReflectionHelper.findMethod(EntityLiving.class, living, LibObfuscation.GET_LIVING_SOUND).invoke(living); - - if(sound != null) { - String s = EntityList.getEntityString(entity); - if(s == null) - s = "generic"; - - ItemNBTHelper.setString(stack, TAG_SOUND, sound); - ItemNBTHelper.setString(stack, TAG_SOUND_NAME, "entity." + s + ".name"); - ItemNBTHelper.setBoolean(stack, TAG_HAS_SOUND, true); - player.inventory.setInventorySlotContents(player.inventory.currentItem, stack.copy()); - - if(player.worldObj.isRemote) - player.swingItem(); - - return true; - } - } catch (Exception e) { - e.printStackTrace(); - } - } - - return false; - } - - @Override - public boolean onItemUse(ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int s, float xs, float ys, float zs) { - boolean can = isDOIT(stack); - if(!can) { - String sound = ItemNBTHelper.getString(stack, TAG_SOUND, ""); - isDOIT(stack); - if(sound != null && !sound.isEmpty()) - can = true; - } - - if(can) { - Block block = world.getBlock(x, y, z); - if(block == Blocks.noteblock) { - world.setBlock(x, y, z, ModBlocks.cacophonium); - ((TileCacophonium) world.getTileEntity(x, y, z)).stack = stack.copy(); - stack.stackSize--; - return true; - } - } - - return false; - } - - @Override - public void addInformation(ItemStack stack, EntityPlayer player, List list, boolean adv) { - if(isDOIT(stack)) - list.add(StatCollector.translateToLocal("botaniamisc.justDoIt")); - else if(ItemNBTHelper.getBoolean(stack, TAG_HAS_SOUND, false)) - list.add(StatCollector.translateToLocal(ItemNBTHelper.getString(stack, TAG_SOUND_NAME, ""))); - } - - @Override - public EnumAction getItemUseAction(ItemStack par1ItemStack) { - return EnumAction.block; - } - - @Override - public int getMaxItemUseDuration(ItemStack par1ItemStack) { - return 72000; - } - - @Override - public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer) { - if(ItemNBTHelper.getBoolean(par1ItemStack, TAG_HAS_SOUND, false) || isDOIT(par1ItemStack)) - par3EntityPlayer.setItemInUse(par1ItemStack, 72000); - return par1ItemStack; - } - - @Override - public void onUsingTick(ItemStack stack, EntityPlayer player, int count) { - if(count % (isDOIT(stack) ? 20 : 6) == 0) - playSound(player.worldObj, stack, player.posX, player.posY, player.posZ, 0.9F); - } - - public static void playSound(World world, ItemStack stack, double x, double y, double z, float volume) { - if(stack == null) - return; - - String sound = ItemNBTHelper.getString(stack, TAG_SOUND, ""); - boolean doit = isDOIT(stack); - if(doit) - sound = "botania:doit"; - - if(sound != null && !sound.isEmpty()) - world.playSoundEffect(x, y, z, sound, volume, doit ? 1F : (world.rand.nextFloat() - world.rand.nextFloat()) * 0.2F + 1.0F); - } - - private static boolean isDOIT(ItemStack stack) { - return stack != null && stack.getDisplayName().equalsIgnoreCase("shia labeouf"); - } - - @Override - public Achievement getAchievementOnCraft(ItemStack stack, EntityPlayer player, IInventory matrix) { - return ModAchievements.cacophoniumCraft; - } + private static final String TAG_SOUND = "sound"; + private static final String TAG_SOUND_NAME = "soundName"; + private static final String TAG_HAS_SOUND = "hasSound"; + + public ItemCacophonium() { + setMaxStackSize(1); + setUnlocalizedName(LibItemNames.CACOPHONIUM); + } + + @Override + public boolean itemInteractionForEntity(ItemStack stack, EntityPlayer player, EntityLivingBase entity) { + if (entity instanceof EntityLiving) { + EntityLiving living = (EntityLiving) entity; + String sound = null; + try { + if (living instanceof EntityCreeper) sound = "creeper.primed"; + else if (living instanceof EntitySlime) + sound = "mob.slime." + (((EntitySlime) living).getSlimeSize() > 1 ? "big" : "small"); + else + sound = (String) + ReflectionHelper.findMethod(EntityLiving.class, living, LibObfuscation.GET_LIVING_SOUND) + .invoke(living); + + if (sound != null) { + String s = EntityList.getEntityString(entity); + if (s == null) s = "generic"; + + ItemNBTHelper.setString(stack, TAG_SOUND, sound); + ItemNBTHelper.setString(stack, TAG_SOUND_NAME, "entity." + s + ".name"); + ItemNBTHelper.setBoolean(stack, TAG_HAS_SOUND, true); + player.inventory.setInventorySlotContents(player.inventory.currentItem, stack.copy()); + + if (player.worldObj.isRemote) player.swingItem(); + + return true; + } + } catch (Exception e) { + e.printStackTrace(); + } + } + + return false; + } + + @Override + public boolean onItemUse( + ItemStack stack, + EntityPlayer player, + World world, + int x, + int y, + int z, + int s, + float xs, + float ys, + float zs) { + boolean can = isDOIT(stack); + if (!can) { + String sound = ItemNBTHelper.getString(stack, TAG_SOUND, ""); + isDOIT(stack); + if (sound != null && !sound.isEmpty()) can = true; + } + + if (can) { + Block block = world.getBlock(x, y, z); + if (block == Blocks.noteblock) { + world.setBlock(x, y, z, ModBlocks.cacophonium); + ((TileCacophonium) world.getTileEntity(x, y, z)).stack = stack.copy(); + stack.stackSize--; + return true; + } + } + + return false; + } + + @Override + public void addInformation(ItemStack stack, EntityPlayer player, List list, boolean adv) { + if (isDOIT(stack)) list.add(StatCollector.translateToLocal("botaniamisc.justDoIt")); + else if (ItemNBTHelper.getBoolean(stack, TAG_HAS_SOUND, false)) + list.add(StatCollector.translateToLocal(ItemNBTHelper.getString(stack, TAG_SOUND_NAME, ""))); + } + + @Override + public EnumAction getItemUseAction(ItemStack par1ItemStack) { + return EnumAction.block; + } + + @Override + public int getMaxItemUseDuration(ItemStack par1ItemStack) { + return 72000; + } + + @Override + public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer) { + if (ItemNBTHelper.getBoolean(par1ItemStack, TAG_HAS_SOUND, false) || isDOIT(par1ItemStack)) + par3EntityPlayer.setItemInUse(par1ItemStack, 72000); + return par1ItemStack; + } + + @Override + public void onUsingTick(ItemStack stack, EntityPlayer player, int count) { + if (count % (isDOIT(stack) ? 20 : 6) == 0) + playSound(player.worldObj, stack, player.posX, player.posY, player.posZ, 0.9F); + } + + public static void playSound(World world, ItemStack stack, double x, double y, double z, float volume) { + if (stack == null) return; + + String sound = ItemNBTHelper.getString(stack, TAG_SOUND, ""); + boolean doit = isDOIT(stack); + if (doit) sound = "botania:doit"; + + if (sound != null && !sound.isEmpty()) + world.playSoundEffect( + x, + y, + z, + sound, + volume, + doit ? 1F : (world.rand.nextFloat() - world.rand.nextFloat()) * 0.2F + 1.0F); + } + + private static boolean isDOIT(ItemStack stack) { + return stack != null && stack.getDisplayName().equalsIgnoreCase("shia labeouf"); + } + + @Override + public Achievement getAchievementOnCraft(ItemStack stack, EntityPlayer player, IInventory matrix) { + return ModAchievements.cacophoniumCraft; + } } diff --git a/src/main/java/vazkii/botania/common/item/ItemClip.java b/src/main/java/vazkii/botania/common/item/ItemClip.java index 6f3ac2b502..bab097e8fc 100644 --- a/src/main/java/vazkii/botania/common/item/ItemClip.java +++ b/src/main/java/vazkii/botania/common/item/ItemClip.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jan 24, 2015, 7:56:38 PM (GMT)] */ package vazkii.botania.common.item; @@ -14,9 +14,8 @@ public class ItemClip extends ItemMod { - public ItemClip() { - setMaxStackSize(1); - setUnlocalizedName(LibItemNames.CLIP); - } - + public ItemClip() { + setMaxStackSize(1); + setUnlocalizedName(LibItemNames.CLIP); + } } diff --git a/src/main/java/vazkii/botania/common/item/ItemCorporeaSpark.java b/src/main/java/vazkii/botania/common/item/ItemCorporeaSpark.java index 2efd3a7e76..221123793c 100644 --- a/src/main/java/vazkii/botania/common/item/ItemCorporeaSpark.java +++ b/src/main/java/vazkii/botania/common/item/ItemCorporeaSpark.java @@ -2,16 +2,15 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Feb 13, 2015, 10:25:32 PM (GMT)] */ package vazkii.botania.common.item; import java.util.List; - import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.entity.player.EntityPlayer; @@ -28,54 +27,61 @@ public class ItemCorporeaSpark extends ItemMod { - public static IIcon invIcon, worldIcon, invIconMaster, worldIconMaster, iconColorStar; - - public ItemCorporeaSpark() { - setUnlocalizedName(LibItemNames.CORPOREA_SPARK); - setHasSubtypes(true); - } + public static IIcon invIcon, worldIcon, invIconMaster, worldIconMaster, iconColorStar; - @Override - public void getSubItems(Item item, CreativeTabs tab, List list) { - for(int i = 0; i < 2; i++) - list.add(new ItemStack(item, 1, i)); - } + public ItemCorporeaSpark() { + setUnlocalizedName(LibItemNames.CORPOREA_SPARK); + setHasSubtypes(true); + } - @Override - public boolean onItemUse(ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int side, float xv, float yv, float zv) { - TileEntity tile = world.getTileEntity(x, y, z); - if(tile instanceof IInventory && !CorporeaHelper.doesBlockHaveSpark(world, x, y, z)) { - stack.stackSize--; - if(!world.isRemote) { - EntityCorporeaSpark spark = new EntityCorporeaSpark(world); - if(stack.getItemDamage() == 1) - spark.setMaster(true); - spark.setPosition(x + 0.5, y + 1.5, z + 0.5); - world.spawnEntityInWorld(spark); - world.markBlockForUpdate(x, y, z); - } - return true; - } - return false; - } + @Override + public void getSubItems(Item item, CreativeTabs tab, List list) { + for (int i = 0; i < 2; i++) list.add(new ItemStack(item, 1, i)); + } - @Override - public void registerIcons(IIconRegister par1IconRegister) { - invIcon = IconHelper.forItem(par1IconRegister, this, 0); - worldIcon = IconHelper.forItem(par1IconRegister, this, 1); - invIconMaster = IconHelper.forItem(par1IconRegister, this, 2); - worldIconMaster = IconHelper.forItem(par1IconRegister, this, 3); - iconColorStar = IconHelper.forItem(par1IconRegister, this, "Star"); - } + @Override + public boolean onItemUse( + ItemStack stack, + EntityPlayer player, + World world, + int x, + int y, + int z, + int side, + float xv, + float yv, + float zv) { + TileEntity tile = world.getTileEntity(x, y, z); + if (tile instanceof IInventory && !CorporeaHelper.doesBlockHaveSpark(world, x, y, z)) { + stack.stackSize--; + if (!world.isRemote) { + EntityCorporeaSpark spark = new EntityCorporeaSpark(world); + if (stack.getItemDamage() == 1) spark.setMaster(true); + spark.setPosition(x + 0.5, y + 1.5, z + 0.5); + world.spawnEntityInWorld(spark); + world.markBlockForUpdate(x, y, z); + } + return true; + } + return false; + } - @Override - public String getUnlocalizedName(ItemStack par1ItemStack) { - return super.getUnlocalizedName(par1ItemStack) + par1ItemStack.getItemDamage(); - } + @Override + public void registerIcons(IIconRegister par1IconRegister) { + invIcon = IconHelper.forItem(par1IconRegister, this, 0); + worldIcon = IconHelper.forItem(par1IconRegister, this, 1); + invIconMaster = IconHelper.forItem(par1IconRegister, this, 2); + worldIconMaster = IconHelper.forItem(par1IconRegister, this, 3); + iconColorStar = IconHelper.forItem(par1IconRegister, this, "Star"); + } - @Override - public IIcon getIconFromDamage(int meta) { - return meta == 0 ? invIcon : invIconMaster; - } + @Override + public String getUnlocalizedName(ItemStack par1ItemStack) { + return super.getUnlocalizedName(par1ItemStack) + par1ItemStack.getItemDamage(); + } + @Override + public IIcon getIconFromDamage(int meta) { + return meta == 0 ? invIcon : invIconMaster; + } } diff --git a/src/main/java/vazkii/botania/common/item/ItemCraftPattern.java b/src/main/java/vazkii/botania/common/item/ItemCraftPattern.java index d799748f6f..55bd5e93a7 100644 --- a/src/main/java/vazkii/botania/common/item/ItemCraftPattern.java +++ b/src/main/java/vazkii/botania/common/item/ItemCraftPattern.java @@ -2,16 +2,15 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jan 28, 2015, 2:59:06 PM (GMT)] */ package vazkii.botania.common.item; import java.util.List; - import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.entity.player.EntityPlayer; @@ -26,46 +25,44 @@ public class ItemCraftPattern extends ItemMod { - IIcon[] icons; - - public ItemCraftPattern() { - setHasSubtypes(true); - setUnlocalizedName(LibItemNames.CRAFT_PATTERN); - setMaxStackSize(1); - } + IIcon[] icons; - @Override - public boolean onItemUse(ItemStack stack, EntityPlayer p, World world, int x, int y, int z, int s, float xs, float ys, float zs) { - TileEntity tile = world.getTileEntity(x, y, z); - if(tile != null && tile instanceof TileCraftCrate && !world.isRemote) { - TileCraftCrate crate = (TileCraftCrate) tile; - crate.pattern = stack.getItemDamage(); - world.markBlockForUpdate(x, y, z); - } - return false; - } + public ItemCraftPattern() { + setHasSubtypes(true); + setUnlocalizedName(LibItemNames.CRAFT_PATTERN); + setMaxStackSize(1); + } - @Override - public void getSubItems(Item item, CreativeTabs tab, List list) { - for(int i = 0; i < TileCraftCrate.PATTERNS.length; i++) - list.add(new ItemStack(item, 1, i)); - } + @Override + public boolean onItemUse( + ItemStack stack, EntityPlayer p, World world, int x, int y, int z, int s, float xs, float ys, float zs) { + TileEntity tile = world.getTileEntity(x, y, z); + if (tile != null && tile instanceof TileCraftCrate && !world.isRemote) { + TileCraftCrate crate = (TileCraftCrate) tile; + crate.pattern = stack.getItemDamage(); + world.markBlockForUpdate(x, y, z); + } + return false; + } - @Override - public void registerIcons(IIconRegister par1IconRegister) { - icons = new IIcon[TileCraftCrate.PATTERNS.length]; - for(int i = 0; i < icons.length; i++) - icons[i] = IconHelper.forItem(par1IconRegister, this, i); - } + @Override + public void getSubItems(Item item, CreativeTabs tab, List list) { + for (int i = 0; i < TileCraftCrate.PATTERNS.length; i++) list.add(new ItemStack(item, 1, i)); + } - @Override - public IIcon getIconFromDamage(int dmg) { - return icons[Math.min(icons.length - 1, dmg)]; - } + @Override + public void registerIcons(IIconRegister par1IconRegister) { + icons = new IIcon[TileCraftCrate.PATTERNS.length]; + for (int i = 0; i < icons.length; i++) icons[i] = IconHelper.forItem(par1IconRegister, this, i); + } - @Override - public String getUnlocalizedName(ItemStack par1ItemStack) { - return super.getUnlocalizedName(par1ItemStack) + par1ItemStack.getItemDamage(); - } + @Override + public IIcon getIconFromDamage(int dmg) { + return icons[Math.min(icons.length - 1, dmg)]; + } + @Override + public String getUnlocalizedName(ItemStack par1ItemStack) { + return super.getUnlocalizedName(par1ItemStack) + par1ItemStack.getItemDamage(); + } } diff --git a/src/main/java/vazkii/botania/common/item/ItemCraftingHalo.java b/src/main/java/vazkii/botania/common/item/ItemCraftingHalo.java index d393f213a3..ea0a9c6d2e 100644 --- a/src/main/java/vazkii/botania/common/item/ItemCraftingHalo.java +++ b/src/main/java/vazkii/botania/common/item/ItemCraftingHalo.java @@ -2,16 +2,20 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Dec 15, 2014, 3:53:30 PM (GMT)] */ package vazkii.botania.common.item; +import cpw.mods.fml.common.FMLCommonHandler; +import cpw.mods.fml.common.eventhandler.SubscribeEvent; +import cpw.mods.fml.common.gameevent.PlayerEvent.ItemCraftedEvent; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; import java.awt.Color; - import net.minecraft.block.Block; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.Gui; @@ -44,10 +48,8 @@ import net.minecraftforge.client.event.RenderWorldLastEvent; import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.common.util.ForgeDirection; - import org.lwjgl.opengl.GL11; import org.lwjgl.opengl.GL12; - import vazkii.botania.client.core.handler.ClientTickHandler; import vazkii.botania.client.gui.crafting.InventoryCraftingHalo; import vazkii.botania.client.lib.LibResources; @@ -60,547 +62,562 @@ import vazkii.botania.common.core.helper.Vector3; import vazkii.botania.common.lib.LibGuiIDs; import vazkii.botania.common.lib.LibItemNames; -import cpw.mods.fml.common.FMLCommonHandler; -import cpw.mods.fml.common.eventhandler.SubscribeEvent; -import cpw.mods.fml.common.gameevent.PlayerEvent.ItemCraftedEvent; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; public class ItemCraftingHalo extends ItemMod implements ICraftAchievement { - private static final ResourceLocation glowTexture = new ResourceLocation(LibResources.MISC_GLOW_GREEN); - private static final ItemStack craftingTable = new ItemStack(Blocks.crafting_table); - - public static final int SEGMENTS = 12; - - private static final String TAG_LAST_CRAFTING = "lastCrafting"; - private static final String TAG_STORED_RECIPE_PREFIX = "storedRecipe"; - private static final String TAG_ITEM_PREFIX = "item"; - private static final String TAG_EQUIPPED = "equipped"; - private static final String TAG_ROTATION_BASE = "rotationBase"; - - public ItemCraftingHalo() { - this(LibItemNames.CRAFTING_HALO); - MinecraftForge.EVENT_BUS.register(this); - FMLCommonHandler.instance().bus().register(this); - } - - public ItemCraftingHalo(String name) { - setUnlocalizedName(name); - setMaxStackSize(1); - } - - @Override - public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer player) { - int segment = getSegmentLookedAt(stack, player); - ItemStack itemForPos = getItemForSlot(stack, segment); - - if(segment == 0) - player.openGui(Botania.instance, LibGuiIDs.CRAFTING_HALO, world, 0, 0, 0); - else { - if(itemForPos == null) - assignRecipe(stack, itemForPos, segment); - else tryCraft(player, stack, segment, true, getFakeInv(player), true); - } - - return stack; - } - - public static IInventory getFakeInv(EntityPlayer player) { - GenericInventory tempInv = new GenericInventory("temp", false, player.inventory.getSizeInventory() - 4); - tempInv.copyFrom(player.inventory); - return tempInv; - } - - @Override - public void onUpdate(ItemStack stack, World world, Entity entity, int pos, boolean equipped) { - boolean eqLastTick = wasEquipped(stack); - if(eqLastTick != equipped) - setEquipped(stack, equipped); - - if(!equipped && entity instanceof EntityLivingBase) { - int angles = 360; - int segAngles = angles / SEGMENTS; - float shift = segAngles / 2; - setRotationBase(stack, getCheckingAngle((EntityLivingBase) entity) - shift); - } - } - - void tryCraft(EntityPlayer player, ItemStack stack, int slot, boolean particles, IInventory inv, boolean validate) { - ItemStack itemForPos = getItemForSlot(stack, slot); - if(itemForPos == null) - return; - - ItemStack[] recipe = getCraftingItems(stack, slot); - if(validate) - recipe = validateRecipe(player, stack, recipe, slot); - - if(canCraft(player, recipe, inv)) - doCraft(player, recipe, particles); - } - - private static ItemStack[] validateRecipe(EntityPlayer player, ItemStack stack, ItemStack[] recipe, int slot) { - InventoryCrafting fakeInv = new InventoryCrafting(new ContainerWorkbench(player.inventory, player.worldObj, 0, 0, 0), 3, 3); - for(int i = 0; i < 9; i++) - fakeInv.setInventorySlotContents(i, recipe[i]); - - ItemStack result = CraftingManager.getInstance().findMatchingRecipe(fakeInv, player.worldObj); - if(result == null) { - assignRecipe(stack, recipe[9], slot); - return null; - } - - if(!result.isItemEqual(recipe[9]) || result.stackSize != recipe[9].stackSize || !ItemStack.areItemStackTagsEqual(recipe[9], result)) { - assignRecipe(stack, recipe[9], slot); - return null; - } - - return recipe; - } - - private static boolean canCraft(EntityPlayer player, ItemStack[] recipe, IInventory inv) { - if(recipe == null) - return false; - - if(recipe[9].stackSize != InventoryHelper.testInventoryInsertion(inv, recipe[9], ForgeDirection.UNKNOWN)) - return false; - - return consumeRecipeIngredients(recipe, inv, null); - } - - private static void doCraft(EntityPlayer player, ItemStack[] recipe, boolean particles) { - consumeRecipeIngredients(recipe, player.inventory, player); - if(!player.inventory.addItemStackToInventory(recipe[9])) - player.dropPlayerItemWithRandomChoice(recipe[9], false); - - if(!particles) - return; - - Vec3 lookVec3 = player.getLookVec(); - Vector3 centerVector = Vector3.fromEntityCenter(player).add(lookVec3.xCoord * 3, 1.3, lookVec3.zCoord * 3); - float m = 0.1F; - for(int i = 0; i < 4; i++) - Botania.proxy.wispFX(player.worldObj, centerVector.x, centerVector.y, centerVector.z, 1F, 0F, 1F, 0.2F + 0.2F * (float) Math.random(), ((float) Math.random() - 0.5F) * m, ((float) Math.random() - 0.5F) * m, ((float) Math.random() - 0.5F) * m); - } - - private static boolean consumeRecipeIngredients(ItemStack[] recipe, IInventory inv, EntityPlayer player) { - for(int i = 0; i < 9; i++) { - ItemStack ingredient = recipe[i]; - if(ingredient != null && !consumeFromInventory(ingredient, inv, player)) - return false; - } - - return true; - } - - private static boolean consumeFromInventory(ItemStack stack, IInventory inv, EntityPlayer player) { - for(int i = 0; i < inv.getSizeInventory(); i++) { - ItemStack stackAt = inv.getStackInSlot(i); - if(stackAt != null && stack.isItemEqual(stackAt) && ItemStack.areItemStackTagsEqual(stack, stackAt)) { - boolean consume = true; - - ItemStack container = stackAt.getItem().getContainerItem(stackAt); - if(container != null) { - if(container == stackAt) - consume = false; - else { - InventoryHelper.insertItemIntoInventory(inv, container); - if(container.stackSize != 0 && player != null) - player.dropPlayerItemWithRandomChoice(container, false); - } - } - - if(consume) { - stackAt.stackSize--; - if(stackAt.stackSize == 0) - inv.setInventorySlotContents(i, null); - } - - return true; - } - } - - return false; - } - - @Override - public boolean onEntitySwing(EntityLivingBase player, ItemStack stack) { - int segment = getSegmentLookedAt(stack, player); - if(segment == 0) - return false; - - ItemStack itemForPos = getItemForSlot(stack, segment); - - if(itemForPos != null && player.isSneaking()) { - assignRecipe(stack, itemForPos, segment); - return true; - } - - return false; - } - - private static int getSegmentLookedAt(ItemStack stack, EntityLivingBase player) { - getRotationBase(stack); - float yaw = getCheckingAngle(player, getRotationBase(stack)); - - int angles = 360; - int segAngles = angles / SEGMENTS; - for(int seg = 0; seg < SEGMENTS; seg++) { - float calcAngle = (float) seg * segAngles; - if(yaw >= calcAngle && yaw < calcAngle + segAngles) - return seg; - } - return -1; - } - - private static float getCheckingAngle(EntityLivingBase player) { - return getCheckingAngle(player, 0F); - } - - // Screw the way minecraft handles rotation - // Really... - private static float getCheckingAngle(EntityLivingBase player, float base) { - float yaw = MathHelper.wrapAngleTo180_float(player.rotationYaw) + 90F; - int angles = 360; - int segAngles = angles / SEGMENTS; - float shift = segAngles / 2; - - if(yaw < 0) - yaw = 180F + (180F + yaw); - yaw -= 360F - base; - float angle = 360F - yaw + shift; - - if(angle < 0) - angle = 360F + angle; - - return angle; - } - - public static ItemStack getItemForSlot(ItemStack stack, int slot) { - if(slot == 0) - return craftingTable; - else if(slot >= SEGMENTS) - return null; - else { - NBTTagCompound cmp = getStoredRecipeCompound(stack, slot); - - if(cmp != null) { - ItemStack cmpStack = getLastCraftingItem(cmp, 9); - return cmpStack; - } else return null; - } - } - - public static void assignRecipe(ItemStack stack, ItemStack itemForPos, int pos) { - if(itemForPos != null) - ItemNBTHelper.setCompound(stack, TAG_STORED_RECIPE_PREFIX + pos, new NBTTagCompound()); - else - ItemNBTHelper.setCompound(stack, TAG_STORED_RECIPE_PREFIX + pos, getLastCraftingCompound(stack, false)); - } - - @SubscribeEvent - public void onItemCrafted(ItemCraftedEvent event) { - if(!(event.craftMatrix instanceof InventoryCraftingHalo)) - return; - - for(int i = 0; i < event.player.inventory.getSizeInventory(); i++) { - ItemStack stack = event.player.inventory.getStackInSlot(i); - if(stack != null && stack.getItem() instanceof ItemCraftingHalo) - saveRecipeToStack(event, stack); - } - } - - private void saveRecipeToStack(ItemCraftedEvent event, ItemStack stack) { - NBTTagCompound cmp = new NBTTagCompound(); - NBTTagCompound cmp1 = new NBTTagCompound(); - - ItemStack result = CraftingManager.getInstance().findMatchingRecipe((InventoryCrafting) event.craftMatrix, event.player.worldObj); - if(result != null) { - result.writeToNBT(cmp1); - cmp.setTag(TAG_ITEM_PREFIX + 9, cmp1); - - for(int i = 0; i < 9; i++) { - cmp1 = new NBTTagCompound(); - ItemStack stackSlot = event.craftMatrix.getStackInSlot(i); - - if(stackSlot != null) { - ItemStack writeStack = stackSlot.copy(); - writeStack.stackSize = 1; - writeStack.writeToNBT(cmp1); - } - cmp.setTag(TAG_ITEM_PREFIX + i, cmp1); - } - } - - ItemNBTHelper.setCompound(stack, TAG_LAST_CRAFTING, cmp); - } - - public static ItemStack[] getLastCraftingItems(ItemStack stack) { - return getCraftingItems(stack, SEGMENTS); - } - - public static ItemStack[] getCraftingItems(ItemStack stack, int slot) { - ItemStack[] stackArray = new ItemStack[10]; - - NBTTagCompound cmp = getStoredRecipeCompound(stack, slot); - if(cmp != null) - for(int i = 0; i < stackArray.length; i++) - stackArray[i] = getLastCraftingItem(cmp, i); - - return stackArray; - } - - public static NBTTagCompound getLastCraftingCompound(ItemStack stack, boolean nullify) { - return ItemNBTHelper.getCompound(stack, TAG_LAST_CRAFTING, nullify); - } - - public static NBTTagCompound getStoredRecipeCompound(ItemStack stack, int slot) { - return slot == SEGMENTS ? getLastCraftingCompound(stack, true) : ItemNBTHelper.getCompound(stack, TAG_STORED_RECIPE_PREFIX + slot, true); - } - - public static ItemStack getLastCraftingItem(ItemStack stack, int pos) { - return getLastCraftingItem(getLastCraftingCompound(stack, true), pos); - } - - public static ItemStack getLastCraftingItem(NBTTagCompound cmp, int pos) { - if(cmp == null) - return null; - - NBTTagCompound cmp1 = cmp.getCompoundTag(TAG_ITEM_PREFIX + pos); - if(cmp1 == null) - return null; - - return ItemStack.loadItemStackFromNBT(cmp1); - } - - public static boolean wasEquipped(ItemStack stack) { - return ItemNBTHelper.getBoolean(stack, TAG_EQUIPPED, false); - } - - public static void setEquipped(ItemStack stack, boolean equipped) { - ItemNBTHelper.setBoolean(stack, TAG_EQUIPPED, equipped); - } - - public static float getRotationBase(ItemStack stack) { - return ItemNBTHelper.getFloat(stack, TAG_ROTATION_BASE, 0F); - } - - public static void setRotationBase(ItemStack stack, float rotation) { - ItemNBTHelper.setFloat(stack, TAG_ROTATION_BASE, rotation); - } - - @SideOnly(Side.CLIENT) - @SubscribeEvent - public void onRenderWorldLast(RenderWorldLastEvent event) { - EntityPlayer player = Minecraft.getMinecraft().thePlayer; - ItemStack stack = player.getCurrentEquippedItem(); - if(stack != null && stack.getItem() instanceof ItemCraftingHalo) - render(stack, player, event.partialTicks); - } - - @SideOnly(Side.CLIENT) - public void render(ItemStack stack, EntityPlayer player, float partialTicks) { - Minecraft mc = Minecraft.getMinecraft(); - Tessellator tess = Tessellator.instance; - Tessellator.renderingWorldRenderer = false; - - GL11.glPushMatrix(); - GL11.glEnable(GL11.GL_BLEND); - GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); - float alpha = ((float) Math.sin((ClientTickHandler.ticksInGame + partialTicks) * 0.2F) * 0.5F + 0.5F) * 0.4F + 0.3F; - - double posX = player.prevPosX + (player.posX - player.prevPosX) * partialTicks; - double posY = player.prevPosY + (player.posY - player.prevPosY) * partialTicks; - double posZ = player.prevPosZ + (player.posZ - player.prevPosZ) * partialTicks; - - GL11.glTranslated(posX - RenderManager.renderPosX, posY - RenderManager.renderPosY, posZ - RenderManager.renderPosZ); - - - float base = getRotationBase(stack); - int angles = 360; - int segAngles = angles / SEGMENTS; - float shift = base - segAngles / 2; - - float u = 1F; - float v = 0.25F; - - float s = 3F; - float m = 0.8F; - float y = v * s * 2; - float y0 = 0; - - int segmentLookedAt = getSegmentLookedAt(stack, player); - - for(int seg = 0; seg < SEGMENTS; seg++) { - boolean inside = false; - float rotationAngle = (seg + 0.5F) * segAngles + shift; - GL11.glPushMatrix(); - GL11.glRotatef(rotationAngle, 0F, 1F, 0F); - GL11.glTranslatef(s * m, -0.75F, 0F); - - if(segmentLookedAt == seg) - inside = true; - - ItemStack slotStack = getItemForSlot(stack, seg); - if(slotStack != null) { - mc.renderEngine.bindTexture(slotStack.getItem() instanceof ItemBlock ? TextureMap.locationBlocksTexture : TextureMap.locationItemsTexture); - - if(slotStack.getItem() instanceof ItemBlock && RenderBlocks.renderItemIn3d(Block.getBlockFromItem(slotStack.getItem()).getRenderType())) { - float scale = seg == 0 ? 0.75F : 0.6F; - GL11.glScalef(scale, scale, scale); - GL11.glRotatef(180F, 0F, 1F, 0F); - GL11.glTranslatef(seg == 0 ? 0.5F : 0F, seg == 0 ? -0.1F : 0.6F, 0F); - - RenderBlocks.getInstance().renderBlockAsItem(Block.getBlockFromItem(slotStack.getItem()), slotStack.getItemDamage(), 1F); - } else { - GL11.glScalef(0.75F, 0.75F, 0.75F); - GL11.glTranslatef(0F, 0F, 0.5F); - GL11.glRotatef(90F, 0F, 1F, 0F); - int renderPass = 0; - do { - IIcon icon = slotStack.getItem().getIcon(slotStack, renderPass); - if(icon != null) { - Color color = new Color(slotStack.getItem().getColorFromItemStack(slotStack, renderPass)); - GL11.glColor3ub((byte) color.getRed(), (byte) color.getGreen(), (byte) color.getBlue()); - float f = icon.getMinU(); - float f1 = icon.getMaxU(); - float f2 = icon.getMinV(); - float f3 = icon.getMaxV(); - ItemRenderer.renderItemIn2D(Tessellator.instance, f1, f2, f, f3, icon.getIconWidth(), icon.getIconHeight(), 1F / 16F); - GL11.glColor3f(1F, 1F, 1F); - } - renderPass++; - } while(renderPass < slotStack.getItem().getRenderPasses(slotStack.getItemDamage())); - } - } - GL11.glPopMatrix(); - - GL11.glPushMatrix(); - GL11.glRotatef(180F, 1F, 0F, 0F); - float a = alpha; - if(inside) { - a += 0.3F; - y0 = -y; - } - - if(seg % 2 == 0) - GL11.glColor4f(0.6F, 0.6F, 0.6F, a); - else GL11.glColor4f(1F, 1F, 1F, a); - - GL11.glDisable(GL11.GL_CULL_FACE); - ItemCraftingHalo item = (ItemCraftingHalo) stack.getItem(); - mc.renderEngine.bindTexture(item.getGlowResource()); - tess.startDrawingQuads(); - for(int i = 0; i < segAngles; i++) { - float ang = i + seg * segAngles + shift; - double xp = Math.cos(ang * Math.PI / 180F) * s; - double zp = Math.sin(ang * Math.PI / 180F) * s; - - tess.addVertexWithUV(xp * m, y, zp * m, u, v); - tess.addVertexWithUV(xp, y0, zp, u, 0); - - xp = Math.cos((ang + 1) * Math.PI / 180F) * s; - zp = Math.sin((ang + 1) * Math.PI / 180F) * s; - - tess.addVertexWithUV(xp, y0, zp, 0, 0); - tess.addVertexWithUV(xp * m, y, zp * m, 0, v); - } - y0 = 0; - tess.draw(); - GL11.glEnable(GL11.GL_CULL_FACE); - GL11.glPopMatrix(); - } - GL11.glPopMatrix(); - } - - @SideOnly(Side.CLIENT) - public ResourceLocation getGlowResource() { - return glowTexture; - } - - @SideOnly(Side.CLIENT) - public static void renderHUD(ScaledResolution resolution, EntityPlayer player, ItemStack stack) { - Minecraft mc = Minecraft.getMinecraft(); - int slot = getSegmentLookedAt(stack, player); - GL11.glEnable(GL11.GL_BLEND); - GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); - - if(slot == 0) { - String name = craftingTable.getDisplayName(); - int l = mc.fontRenderer.getStringWidth(name); - int x = resolution.getScaledWidth() / 2 - l / 2; - int y = resolution.getScaledHeight() / 2 - 65; - - Gui.drawRect(x - 6, y - 6, x + l + 6, y + 37, 0x22000000); - Gui.drawRect(x - 4, y - 4, x + l + 4, y + 35, 0x22000000); - net.minecraft.client.renderer.RenderHelper.enableGUIStandardItemLighting(); - GL11.glEnable(GL12.GL_RESCALE_NORMAL); - RenderItem.getInstance().renderItemAndEffectIntoGUI(mc.fontRenderer, mc.renderEngine, craftingTable, resolution.getScaledWidth() / 2 - 8, resolution.getScaledHeight() / 2 - 52); - net.minecraft.client.renderer.RenderHelper.disableStandardItemLighting(); - - mc.fontRenderer.drawStringWithShadow(name, x, y, 0xFFFFFF); - } else { - ItemStack[] recipe = getCraftingItems(stack, slot); - String label = StatCollector.translateToLocal("botaniamisc.unsetRecipe"); - boolean setRecipe = false; - - if(recipe[9] == null) - recipe = getCraftingItems(stack, SEGMENTS); - else { - label = recipe[9].getDisplayName(); - setRecipe = true; - } - - renderRecipe(resolution, label, recipe, player, setRecipe); - } - } - - @SideOnly(Side.CLIENT) - public static void renderRecipe(ScaledResolution resolution, String label, ItemStack[] recipe, EntityPlayer player, boolean setRecipe) { - Minecraft mc = Minecraft.getMinecraft(); - - if(recipe[9] != null) { - int x = resolution.getScaledWidth() / 2 - 45; - int y = resolution.getScaledHeight() / 2 - 90; - - Gui.drawRect(x - 6, y - 6, x + 90 + 6, y + 60, 0x22000000); - Gui.drawRect(x - 4, y - 4, x + 90 + 4, y + 58, 0x22000000); - - Gui.drawRect(x + 66, y + 14, x + 92, y + 40, 0x22000000); - Gui.drawRect(x - 2, y - 2, x + 56, y + 56, 0x22000000); - - net.minecraft.client.renderer.RenderHelper.enableGUIStandardItemLighting(); - GL11.glEnable(GL12.GL_RESCALE_NORMAL); - for(int i = 0; i < 9; i++) { - ItemStack stack = recipe[i]; - if(stack != null) { - int xpos = x + i % 3 * 18; - int ypos = y + i / 3 * 18; - Gui.drawRect(xpos, ypos, xpos + 16, ypos + 16, 0x22000000); - - RenderItem.getInstance().renderItemAndEffectIntoGUI(mc.fontRenderer, mc.renderEngine, stack, xpos, ypos); - } - } - - RenderItem.getInstance().renderItemAndEffectIntoGUI(mc.fontRenderer, mc.renderEngine, recipe[9], x + 72, y + 18); - RenderItem.getInstance().renderItemOverlayIntoGUI(mc.fontRenderer, mc.renderEngine, recipe[9], x + 72, y + 18); - - net.minecraft.client.renderer.RenderHelper.disableStandardItemLighting(); - } - - int yoff = 110; - if(setRecipe && !canCraft(player, recipe, getFakeInv(player))) { - String warning = EnumChatFormatting.RED + StatCollector.translateToLocal("botaniamisc.cantCraft"); - mc.fontRenderer.drawStringWithShadow(warning, resolution.getScaledWidth() / 2 - mc.fontRenderer.getStringWidth(warning) / 2, resolution.getScaledHeight() / 2 - yoff, 0xFFFFFF); - yoff += 12; - } - - mc.fontRenderer.drawStringWithShadow(label, resolution.getScaledWidth() / 2 - mc.fontRenderer.getStringWidth(label) / 2, resolution.getScaledHeight() / 2 - yoff, 0xFFFFFF); - } - - @Override - public Achievement getAchievementOnCraft(ItemStack stack, EntityPlayer player, IInventory matrix) { - return ModAchievements.craftingHaloCraft; - } - + private static final ResourceLocation glowTexture = new ResourceLocation(LibResources.MISC_GLOW_GREEN); + private static final ItemStack craftingTable = new ItemStack(Blocks.crafting_table); + + public static final int SEGMENTS = 12; + + private static final String TAG_LAST_CRAFTING = "lastCrafting"; + private static final String TAG_STORED_RECIPE_PREFIX = "storedRecipe"; + private static final String TAG_ITEM_PREFIX = "item"; + private static final String TAG_EQUIPPED = "equipped"; + private static final String TAG_ROTATION_BASE = "rotationBase"; + + public ItemCraftingHalo() { + this(LibItemNames.CRAFTING_HALO); + MinecraftForge.EVENT_BUS.register(this); + FMLCommonHandler.instance().bus().register(this); + } + + public ItemCraftingHalo(String name) { + setUnlocalizedName(name); + setMaxStackSize(1); + } + + @Override + public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer player) { + int segment = getSegmentLookedAt(stack, player); + ItemStack itemForPos = getItemForSlot(stack, segment); + + if (segment == 0) player.openGui(Botania.instance, LibGuiIDs.CRAFTING_HALO, world, 0, 0, 0); + else { + if (itemForPos == null) assignRecipe(stack, itemForPos, segment); + else tryCraft(player, stack, segment, true, getFakeInv(player), true); + } + + return stack; + } + + public static IInventory getFakeInv(EntityPlayer player) { + GenericInventory tempInv = new GenericInventory("temp", false, player.inventory.getSizeInventory() - 4); + tempInv.copyFrom(player.inventory); + return tempInv; + } + + @Override + public void onUpdate(ItemStack stack, World world, Entity entity, int pos, boolean equipped) { + boolean eqLastTick = wasEquipped(stack); + if (eqLastTick != equipped) setEquipped(stack, equipped); + + if (!equipped && entity instanceof EntityLivingBase) { + int angles = 360; + int segAngles = angles / SEGMENTS; + float shift = segAngles / 2; + setRotationBase(stack, getCheckingAngle((EntityLivingBase) entity) - shift); + } + } + + void tryCraft(EntityPlayer player, ItemStack stack, int slot, boolean particles, IInventory inv, boolean validate) { + ItemStack itemForPos = getItemForSlot(stack, slot); + if (itemForPos == null) return; + + ItemStack[] recipe = getCraftingItems(stack, slot); + if (validate) recipe = validateRecipe(player, stack, recipe, slot); + + if (canCraft(player, recipe, inv)) doCraft(player, recipe, particles); + } + + private static ItemStack[] validateRecipe(EntityPlayer player, ItemStack stack, ItemStack[] recipe, int slot) { + InventoryCrafting fakeInv = + new InventoryCrafting(new ContainerWorkbench(player.inventory, player.worldObj, 0, 0, 0), 3, 3); + for (int i = 0; i < 9; i++) fakeInv.setInventorySlotContents(i, recipe[i]); + + ItemStack result = CraftingManager.getInstance().findMatchingRecipe(fakeInv, player.worldObj); + if (result == null) { + assignRecipe(stack, recipe[9], slot); + return null; + } + + if (!result.isItemEqual(recipe[9]) + || result.stackSize != recipe[9].stackSize + || !ItemStack.areItemStackTagsEqual(recipe[9], result)) { + assignRecipe(stack, recipe[9], slot); + return null; + } + + return recipe; + } + + private static boolean canCraft(EntityPlayer player, ItemStack[] recipe, IInventory inv) { + if (recipe == null) return false; + + if (recipe[9].stackSize != InventoryHelper.testInventoryInsertion(inv, recipe[9], ForgeDirection.UNKNOWN)) + return false; + + return consumeRecipeIngredients(recipe, inv, null); + } + + private static void doCraft(EntityPlayer player, ItemStack[] recipe, boolean particles) { + consumeRecipeIngredients(recipe, player.inventory, player); + if (!player.inventory.addItemStackToInventory(recipe[9])) + player.dropPlayerItemWithRandomChoice(recipe[9], false); + + if (!particles) return; + + Vec3 lookVec3 = player.getLookVec(); + Vector3 centerVector = Vector3.fromEntityCenter(player).add(lookVec3.xCoord * 3, 1.3, lookVec3.zCoord * 3); + float m = 0.1F; + for (int i = 0; i < 4; i++) + Botania.proxy.wispFX( + player.worldObj, + centerVector.x, + centerVector.y, + centerVector.z, + 1F, + 0F, + 1F, + 0.2F + 0.2F * (float) Math.random(), + ((float) Math.random() - 0.5F) * m, + ((float) Math.random() - 0.5F) * m, + ((float) Math.random() - 0.5F) * m); + } + + private static boolean consumeRecipeIngredients(ItemStack[] recipe, IInventory inv, EntityPlayer player) { + for (int i = 0; i < 9; i++) { + ItemStack ingredient = recipe[i]; + if (ingredient != null && !consumeFromInventory(ingredient, inv, player)) return false; + } + + return true; + } + + private static boolean consumeFromInventory(ItemStack stack, IInventory inv, EntityPlayer player) { + for (int i = 0; i < inv.getSizeInventory(); i++) { + ItemStack stackAt = inv.getStackInSlot(i); + if (stackAt != null && stack.isItemEqual(stackAt) && ItemStack.areItemStackTagsEqual(stack, stackAt)) { + boolean consume = true; + + ItemStack container = stackAt.getItem().getContainerItem(stackAt); + if (container != null) { + if (container == stackAt) consume = false; + else { + InventoryHelper.insertItemIntoInventory(inv, container); + if (container.stackSize != 0 && player != null) + player.dropPlayerItemWithRandomChoice(container, false); + } + } + + if (consume) { + stackAt.stackSize--; + if (stackAt.stackSize == 0) inv.setInventorySlotContents(i, null); + } + + return true; + } + } + + return false; + } + + @Override + public boolean onEntitySwing(EntityLivingBase player, ItemStack stack) { + int segment = getSegmentLookedAt(stack, player); + if (segment == 0) return false; + + ItemStack itemForPos = getItemForSlot(stack, segment); + + if (itemForPos != null && player.isSneaking()) { + assignRecipe(stack, itemForPos, segment); + return true; + } + + return false; + } + + private static int getSegmentLookedAt(ItemStack stack, EntityLivingBase player) { + getRotationBase(stack); + float yaw = getCheckingAngle(player, getRotationBase(stack)); + + int angles = 360; + int segAngles = angles / SEGMENTS; + for (int seg = 0; seg < SEGMENTS; seg++) { + float calcAngle = (float) seg * segAngles; + if (yaw >= calcAngle && yaw < calcAngle + segAngles) return seg; + } + return -1; + } + + private static float getCheckingAngle(EntityLivingBase player) { + return getCheckingAngle(player, 0F); + } + + // Screw the way minecraft handles rotation + // Really... + private static float getCheckingAngle(EntityLivingBase player, float base) { + float yaw = MathHelper.wrapAngleTo180_float(player.rotationYaw) + 90F; + int angles = 360; + int segAngles = angles / SEGMENTS; + float shift = segAngles / 2; + + if (yaw < 0) yaw = 180F + (180F + yaw); + yaw -= 360F - base; + float angle = 360F - yaw + shift; + + if (angle < 0) angle = 360F + angle; + + return angle; + } + + public static ItemStack getItemForSlot(ItemStack stack, int slot) { + if (slot == 0) return craftingTable; + else if (slot >= SEGMENTS) return null; + else { + NBTTagCompound cmp = getStoredRecipeCompound(stack, slot); + + if (cmp != null) { + ItemStack cmpStack = getLastCraftingItem(cmp, 9); + return cmpStack; + } else return null; + } + } + + public static void assignRecipe(ItemStack stack, ItemStack itemForPos, int pos) { + if (itemForPos != null) ItemNBTHelper.setCompound(stack, TAG_STORED_RECIPE_PREFIX + pos, new NBTTagCompound()); + else ItemNBTHelper.setCompound(stack, TAG_STORED_RECIPE_PREFIX + pos, getLastCraftingCompound(stack, false)); + } + + @SubscribeEvent + public void onItemCrafted(ItemCraftedEvent event) { + if (!(event.craftMatrix instanceof InventoryCraftingHalo)) return; + + for (int i = 0; i < event.player.inventory.getSizeInventory(); i++) { + ItemStack stack = event.player.inventory.getStackInSlot(i); + if (stack != null && stack.getItem() instanceof ItemCraftingHalo) saveRecipeToStack(event, stack); + } + } + + private void saveRecipeToStack(ItemCraftedEvent event, ItemStack stack) { + NBTTagCompound cmp = new NBTTagCompound(); + NBTTagCompound cmp1 = new NBTTagCompound(); + + ItemStack result = CraftingManager.getInstance() + .findMatchingRecipe((InventoryCrafting) event.craftMatrix, event.player.worldObj); + if (result != null) { + result.writeToNBT(cmp1); + cmp.setTag(TAG_ITEM_PREFIX + 9, cmp1); + + for (int i = 0; i < 9; i++) { + cmp1 = new NBTTagCompound(); + ItemStack stackSlot = event.craftMatrix.getStackInSlot(i); + + if (stackSlot != null) { + ItemStack writeStack = stackSlot.copy(); + writeStack.stackSize = 1; + writeStack.writeToNBT(cmp1); + } + cmp.setTag(TAG_ITEM_PREFIX + i, cmp1); + } + } + + ItemNBTHelper.setCompound(stack, TAG_LAST_CRAFTING, cmp); + } + + public static ItemStack[] getLastCraftingItems(ItemStack stack) { + return getCraftingItems(stack, SEGMENTS); + } + + public static ItemStack[] getCraftingItems(ItemStack stack, int slot) { + ItemStack[] stackArray = new ItemStack[10]; + + NBTTagCompound cmp = getStoredRecipeCompound(stack, slot); + if (cmp != null) for (int i = 0; i < stackArray.length; i++) stackArray[i] = getLastCraftingItem(cmp, i); + + return stackArray; + } + + public static NBTTagCompound getLastCraftingCompound(ItemStack stack, boolean nullify) { + return ItemNBTHelper.getCompound(stack, TAG_LAST_CRAFTING, nullify); + } + + public static NBTTagCompound getStoredRecipeCompound(ItemStack stack, int slot) { + return slot == SEGMENTS + ? getLastCraftingCompound(stack, true) + : ItemNBTHelper.getCompound(stack, TAG_STORED_RECIPE_PREFIX + slot, true); + } + + public static ItemStack getLastCraftingItem(ItemStack stack, int pos) { + return getLastCraftingItem(getLastCraftingCompound(stack, true), pos); + } + + public static ItemStack getLastCraftingItem(NBTTagCompound cmp, int pos) { + if (cmp == null) return null; + + NBTTagCompound cmp1 = cmp.getCompoundTag(TAG_ITEM_PREFIX + pos); + if (cmp1 == null) return null; + + return ItemStack.loadItemStackFromNBT(cmp1); + } + + public static boolean wasEquipped(ItemStack stack) { + return ItemNBTHelper.getBoolean(stack, TAG_EQUIPPED, false); + } + + public static void setEquipped(ItemStack stack, boolean equipped) { + ItemNBTHelper.setBoolean(stack, TAG_EQUIPPED, equipped); + } + + public static float getRotationBase(ItemStack stack) { + return ItemNBTHelper.getFloat(stack, TAG_ROTATION_BASE, 0F); + } + + public static void setRotationBase(ItemStack stack, float rotation) { + ItemNBTHelper.setFloat(stack, TAG_ROTATION_BASE, rotation); + } + + @SideOnly(Side.CLIENT) + @SubscribeEvent + public void onRenderWorldLast(RenderWorldLastEvent event) { + EntityPlayer player = Minecraft.getMinecraft().thePlayer; + ItemStack stack = player.getCurrentEquippedItem(); + if (stack != null && stack.getItem() instanceof ItemCraftingHalo) render(stack, player, event.partialTicks); + } + + @SideOnly(Side.CLIENT) + public void render(ItemStack stack, EntityPlayer player, float partialTicks) { + Minecraft mc = Minecraft.getMinecraft(); + Tessellator tess = Tessellator.instance; + Tessellator.renderingWorldRenderer = false; + + GL11.glPushMatrix(); + GL11.glEnable(GL11.GL_BLEND); + GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); + float alpha = + ((float) Math.sin((ClientTickHandler.ticksInGame + partialTicks) * 0.2F) * 0.5F + 0.5F) * 0.4F + 0.3F; + + double posX = player.prevPosX + (player.posX - player.prevPosX) * partialTicks; + double posY = player.prevPosY + (player.posY - player.prevPosY) * partialTicks; + double posZ = player.prevPosZ + (player.posZ - player.prevPosZ) * partialTicks; + + GL11.glTranslated( + posX - RenderManager.renderPosX, posY - RenderManager.renderPosY, posZ - RenderManager.renderPosZ); + + float base = getRotationBase(stack); + int angles = 360; + int segAngles = angles / SEGMENTS; + float shift = base - segAngles / 2; + + float u = 1F; + float v = 0.25F; + + float s = 3F; + float m = 0.8F; + float y = v * s * 2; + float y0 = 0; + + int segmentLookedAt = getSegmentLookedAt(stack, player); + + for (int seg = 0; seg < SEGMENTS; seg++) { + boolean inside = false; + float rotationAngle = (seg + 0.5F) * segAngles + shift; + GL11.glPushMatrix(); + GL11.glRotatef(rotationAngle, 0F, 1F, 0F); + GL11.glTranslatef(s * m, -0.75F, 0F); + + if (segmentLookedAt == seg) inside = true; + + ItemStack slotStack = getItemForSlot(stack, seg); + if (slotStack != null) { + mc.renderEngine.bindTexture( + slotStack.getItem() instanceof ItemBlock + ? TextureMap.locationBlocksTexture + : TextureMap.locationItemsTexture); + + if (slotStack.getItem() instanceof ItemBlock + && RenderBlocks.renderItemIn3d( + Block.getBlockFromItem(slotStack.getItem()).getRenderType())) { + float scale = seg == 0 ? 0.75F : 0.6F; + GL11.glScalef(scale, scale, scale); + GL11.glRotatef(180F, 0F, 1F, 0F); + GL11.glTranslatef(seg == 0 ? 0.5F : 0F, seg == 0 ? -0.1F : 0.6F, 0F); + + RenderBlocks.getInstance() + .renderBlockAsItem( + Block.getBlockFromItem(slotStack.getItem()), slotStack.getItemDamage(), 1F); + } else { + GL11.glScalef(0.75F, 0.75F, 0.75F); + GL11.glTranslatef(0F, 0F, 0.5F); + GL11.glRotatef(90F, 0F, 1F, 0F); + int renderPass = 0; + do { + IIcon icon = slotStack.getItem().getIcon(slotStack, renderPass); + if (icon != null) { + Color color = new Color(slotStack.getItem().getColorFromItemStack(slotStack, renderPass)); + GL11.glColor3ub((byte) color.getRed(), (byte) color.getGreen(), (byte) color.getBlue()); + float f = icon.getMinU(); + float f1 = icon.getMaxU(); + float f2 = icon.getMinV(); + float f3 = icon.getMaxV(); + ItemRenderer.renderItemIn2D( + Tessellator.instance, + f1, + f2, + f, + f3, + icon.getIconWidth(), + icon.getIconHeight(), + 1F / 16F); + GL11.glColor3f(1F, 1F, 1F); + } + renderPass++; + } while (renderPass < slotStack.getItem().getRenderPasses(slotStack.getItemDamage())); + } + } + GL11.glPopMatrix(); + + GL11.glPushMatrix(); + GL11.glRotatef(180F, 1F, 0F, 0F); + float a = alpha; + if (inside) { + a += 0.3F; + y0 = -y; + } + + if (seg % 2 == 0) GL11.glColor4f(0.6F, 0.6F, 0.6F, a); + else GL11.glColor4f(1F, 1F, 1F, a); + + GL11.glDisable(GL11.GL_CULL_FACE); + ItemCraftingHalo item = (ItemCraftingHalo) stack.getItem(); + mc.renderEngine.bindTexture(item.getGlowResource()); + tess.startDrawingQuads(); + for (int i = 0; i < segAngles; i++) { + float ang = i + seg * segAngles + shift; + double xp = Math.cos(ang * Math.PI / 180F) * s; + double zp = Math.sin(ang * Math.PI / 180F) * s; + + tess.addVertexWithUV(xp * m, y, zp * m, u, v); + tess.addVertexWithUV(xp, y0, zp, u, 0); + + xp = Math.cos((ang + 1) * Math.PI / 180F) * s; + zp = Math.sin((ang + 1) * Math.PI / 180F) * s; + + tess.addVertexWithUV(xp, y0, zp, 0, 0); + tess.addVertexWithUV(xp * m, y, zp * m, 0, v); + } + y0 = 0; + tess.draw(); + GL11.glEnable(GL11.GL_CULL_FACE); + GL11.glPopMatrix(); + } + GL11.glPopMatrix(); + } + + @SideOnly(Side.CLIENT) + public ResourceLocation getGlowResource() { + return glowTexture; + } + + @SideOnly(Side.CLIENT) + public static void renderHUD(ScaledResolution resolution, EntityPlayer player, ItemStack stack) { + Minecraft mc = Minecraft.getMinecraft(); + int slot = getSegmentLookedAt(stack, player); + GL11.glEnable(GL11.GL_BLEND); + GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); + + if (slot == 0) { + String name = craftingTable.getDisplayName(); + int l = mc.fontRenderer.getStringWidth(name); + int x = resolution.getScaledWidth() / 2 - l / 2; + int y = resolution.getScaledHeight() / 2 - 65; + + Gui.drawRect(x - 6, y - 6, x + l + 6, y + 37, 0x22000000); + Gui.drawRect(x - 4, y - 4, x + l + 4, y + 35, 0x22000000); + net.minecraft.client.renderer.RenderHelper.enableGUIStandardItemLighting(); + GL11.glEnable(GL12.GL_RESCALE_NORMAL); + RenderItem.getInstance() + .renderItemAndEffectIntoGUI( + mc.fontRenderer, + mc.renderEngine, + craftingTable, + resolution.getScaledWidth() / 2 - 8, + resolution.getScaledHeight() / 2 - 52); + net.minecraft.client.renderer.RenderHelper.disableStandardItemLighting(); + + mc.fontRenderer.drawStringWithShadow(name, x, y, 0xFFFFFF); + } else { + ItemStack[] recipe = getCraftingItems(stack, slot); + String label = StatCollector.translateToLocal("botaniamisc.unsetRecipe"); + boolean setRecipe = false; + + if (recipe[9] == null) recipe = getCraftingItems(stack, SEGMENTS); + else { + label = recipe[9].getDisplayName(); + setRecipe = true; + } + + renderRecipe(resolution, label, recipe, player, setRecipe); + } + } + + @SideOnly(Side.CLIENT) + public static void renderRecipe( + ScaledResolution resolution, String label, ItemStack[] recipe, EntityPlayer player, boolean setRecipe) { + Minecraft mc = Minecraft.getMinecraft(); + + if (recipe[9] != null) { + int x = resolution.getScaledWidth() / 2 - 45; + int y = resolution.getScaledHeight() / 2 - 90; + + Gui.drawRect(x - 6, y - 6, x + 90 + 6, y + 60, 0x22000000); + Gui.drawRect(x - 4, y - 4, x + 90 + 4, y + 58, 0x22000000); + + Gui.drawRect(x + 66, y + 14, x + 92, y + 40, 0x22000000); + Gui.drawRect(x - 2, y - 2, x + 56, y + 56, 0x22000000); + + net.minecraft.client.renderer.RenderHelper.enableGUIStandardItemLighting(); + GL11.glEnable(GL12.GL_RESCALE_NORMAL); + for (int i = 0; i < 9; i++) { + ItemStack stack = recipe[i]; + if (stack != null) { + int xpos = x + i % 3 * 18; + int ypos = y + i / 3 * 18; + Gui.drawRect(xpos, ypos, xpos + 16, ypos + 16, 0x22000000); + + RenderItem.getInstance() + .renderItemAndEffectIntoGUI(mc.fontRenderer, mc.renderEngine, stack, xpos, ypos); + } + } + + RenderItem.getInstance() + .renderItemAndEffectIntoGUI(mc.fontRenderer, mc.renderEngine, recipe[9], x + 72, y + 18); + RenderItem.getInstance() + .renderItemOverlayIntoGUI(mc.fontRenderer, mc.renderEngine, recipe[9], x + 72, y + 18); + + net.minecraft.client.renderer.RenderHelper.disableStandardItemLighting(); + } + + int yoff = 110; + if (setRecipe && !canCraft(player, recipe, getFakeInv(player))) { + String warning = EnumChatFormatting.RED + StatCollector.translateToLocal("botaniamisc.cantCraft"); + mc.fontRenderer.drawStringWithShadow( + warning, + resolution.getScaledWidth() / 2 - mc.fontRenderer.getStringWidth(warning) / 2, + resolution.getScaledHeight() / 2 - yoff, + 0xFFFFFF); + yoff += 12; + } + + mc.fontRenderer.drawStringWithShadow( + label, + resolution.getScaledWidth() / 2 - mc.fontRenderer.getStringWidth(label) / 2, + resolution.getScaledHeight() / 2 - yoff, + 0xFFFFFF); + } + + @Override + public Achievement getAchievementOnCraft(ItemStack stack, EntityPlayer player, IInventory matrix) { + return ModAchievements.craftingHaloCraft; + } } diff --git a/src/main/java/vazkii/botania/common/item/ItemEnderHand.java b/src/main/java/vazkii/botania/common/item/ItemEnderHand.java index f6ef375a56..fe44cfc3f6 100644 --- a/src/main/java/vazkii/botania/common/item/ItemEnderHand.java +++ b/src/main/java/vazkii/botania/common/item/ItemEnderHand.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jul 31, 2014, 7:19:26 PM (GMT)] */ package vazkii.botania.common.item; @@ -24,69 +24,71 @@ public class ItemEnderHand extends ItemMod implements IManaUsingItem, IBlockProvider { - private static final int COST_PROVIDE = 5; - private static final int COST_SELF = 250; - private static final int COST_OTHER = 5000; + private static final int COST_PROVIDE = 5; + private static final int COST_SELF = 250; + private static final int COST_OTHER = 5000; - public ItemEnderHand() { - setMaxStackSize(1); - setUnlocalizedName(LibItemNames.ENDER_HAND); - } + public ItemEnderHand() { + setMaxStackSize(1); + setUnlocalizedName(LibItemNames.ENDER_HAND); + } - @Override - public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer player) { - if(ManaItemHandler.requestManaExact(stack, player, COST_SELF, false)) { - player.displayGUIChest(player.getInventoryEnderChest()); - ManaItemHandler.requestManaExact(stack, player, COST_SELF, true); - world.playSoundAtEntity(player, "mob.endermen.portal", 1F, 1F); - } - return stack; - } + @Override + public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer player) { + if (ManaItemHandler.requestManaExact(stack, player, COST_SELF, false)) { + player.displayGUIChest(player.getInventoryEnderChest()); + ManaItemHandler.requestManaExact(stack, player, COST_SELF, true); + world.playSoundAtEntity(player, "mob.endermen.portal", 1F, 1F); + } + return stack; + } - @Override - public boolean itemInteractionForEntity(ItemStack stack, EntityPlayer iplayer, EntityLivingBase entity) { - if(ConfigHandler.enderPickpocketEnabled && entity instanceof EntityPlayer && ManaItemHandler.requestManaExact(stack, iplayer, COST_OTHER, false)) { - iplayer.displayGUIChest(((EntityPlayer) entity).getInventoryEnderChest()); - ManaItemHandler.requestManaExact(stack, iplayer, COST_OTHER, true); - iplayer.worldObj.playSoundAtEntity(iplayer, "mob.endermen.portal", 1F, 1F); - return true; - } + @Override + public boolean itemInteractionForEntity(ItemStack stack, EntityPlayer iplayer, EntityLivingBase entity) { + if (ConfigHandler.enderPickpocketEnabled + && entity instanceof EntityPlayer + && ManaItemHandler.requestManaExact(stack, iplayer, COST_OTHER, false)) { + iplayer.displayGUIChest(((EntityPlayer) entity).getInventoryEnderChest()); + ManaItemHandler.requestManaExact(stack, iplayer, COST_OTHER, true); + iplayer.worldObj.playSoundAtEntity(iplayer, "mob.endermen.portal", 1F, 1F); + return true; + } - return false; - } + return false; + } - @Override - public boolean usesMana(ItemStack stack) { - return true; - } + @Override + public boolean usesMana(ItemStack stack) { + return true; + } - @Override - public boolean provideBlock(EntityPlayer player, ItemStack requestor, ItemStack stack, Block block, int meta, boolean doit) { - if(requestor != null && requestor.getItem() == this) - return false; + @Override + public boolean provideBlock( + EntityPlayer player, ItemStack requestor, ItemStack stack, Block block, int meta, boolean doit) { + if (requestor != null && requestor.getItem() == this) return false; - ItemStack istack = ItemExchangeRod.removeFromInventory(player, player.getInventoryEnderChest(), stack, block, meta, false); - if(istack != null) { - boolean mana = ManaItemHandler.requestManaExact(stack, player, COST_PROVIDE, false); - if(mana) { - if(doit) { - ManaItemHandler.requestManaExact(stack, player, COST_PROVIDE, true); - ItemExchangeRod.removeFromInventory(player, player.getInventoryEnderChest(), stack, block, meta, true); - } + ItemStack istack = + ItemExchangeRod.removeFromInventory(player, player.getInventoryEnderChest(), stack, block, meta, false); + if (istack != null) { + boolean mana = ManaItemHandler.requestManaExact(stack, player, COST_PROVIDE, false); + if (mana) { + if (doit) { + ManaItemHandler.requestManaExact(stack, player, COST_PROVIDE, true); + ItemExchangeRod.removeFromInventory( + player, player.getInventoryEnderChest(), stack, block, meta, true); + } - return true; - } - } + return true; + } + } - return false; - } + return false; + } - @Override - public int getBlockCount(EntityPlayer player, ItemStack requestor, ItemStack stack, Block block, int meta) { - if(requestor != null && requestor.getItem() == this) - return 0; - - return ItemExchangeRod.getInventoryItemCount(player, player.getInventoryEnderChest(), stack, block, meta); - } + @Override + public int getBlockCount(EntityPlayer player, ItemStack requestor, ItemStack stack, Block block, int meta) { + if (requestor != null && requestor.getItem() == this) return 0; + return ItemExchangeRod.getInventoryItemCount(player, player.getInventoryEnderChest(), stack, block, meta); + } } diff --git a/src/main/java/vazkii/botania/common/item/ItemFertilizer.java b/src/main/java/vazkii/botania/common/item/ItemFertilizer.java index 6940d2d046..5501210e03 100644 --- a/src/main/java/vazkii/botania/common/item/ItemFertilizer.java +++ b/src/main/java/vazkii/botania/common/item/ItemFertilizer.java @@ -2,17 +2,16 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Mar 29, 2014, 10:41:52 PM (GMT)] */ package vazkii.botania.common.item; import java.util.ArrayList; import java.util.List; - import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; import net.minecraft.util.ChunkCoordinates; @@ -23,47 +22,69 @@ public class ItemFertilizer extends ItemMod { - public ItemFertilizer() { - super(); - setUnlocalizedName(LibItemNames.FERTILIZER); - } + public ItemFertilizer() { + super(); + setUnlocalizedName(LibItemNames.FERTILIZER); + } - @Override - public boolean onItemUse(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, World par3World, int par4, int par5, int par6, int par7, float par8, float par9, float par10) { - final int range = 3; - if(!par3World.isRemote) { - List validCoords = new ArrayList(); + @Override + public boolean onItemUse( + ItemStack par1ItemStack, + EntityPlayer par2EntityPlayer, + World par3World, + int par4, + int par5, + int par6, + int par7, + float par8, + float par9, + float par10) { + final int range = 3; + if (!par3World.isRemote) { + List validCoords = new ArrayList(); - for(int i = -range - 1; i < range; i++) - for(int j = -range - 1; j < range; j++) { - for(int k = 2; k >= -2; k--) { - int x = par4 + i + 1; - int y = par5 + k + 1; - int z = par6 + j + 1; - if(par3World.isAirBlock(x, y, z) && (!par3World.provider.hasNoSky || y < 255) && ModBlocks.flower.canBlockStay(par3World, x, y, z)) - validCoords.add(new ChunkCoordinates(x, y, z)); - } - } + for (int i = -range - 1; i < range; i++) + for (int j = -range - 1; j < range; j++) { + for (int k = 2; k >= -2; k--) { + int x = par4 + i + 1; + int y = par5 + k + 1; + int z = par6 + j + 1; + if (par3World.isAirBlock(x, y, z) + && (!par3World.provider.hasNoSky || y < 255) + && ModBlocks.flower.canBlockStay(par3World, x, y, z)) + validCoords.add(new ChunkCoordinates(x, y, z)); + } + } - int flowerCount = Math.min(validCoords.size(), par3World.rand.nextBoolean() ? 3 : 4); - for(int i = 0; i < flowerCount; i++) { - ChunkCoordinates coords = validCoords.get(par3World.rand.nextInt(validCoords.size())); - validCoords.remove(coords); - par3World.setBlock(coords.posX, coords.posY, coords.posZ, ModBlocks.flower, par3World.rand.nextInt(16), 1 | 2); - } - par1ItemStack.stackSize--; - } else { - for(int i = 0; i < 15; i++) { - double x = par4 - range + par3World.rand.nextInt(range * 2 + 1) + Math.random(); - double y = par5 + 1; - double z = par6 - range + par3World.rand.nextInt(range * 2 + 1) + Math.random(); - float red = (float) Math.random(); - float green = (float) Math.random(); - float blue = (float) Math.random(); - Botania.proxy.wispFX(par3World, x, y, z, red, green, blue, 0.15F + (float) Math.random() * 0.25F, -(float) Math.random() * 0.1F - 0.05F); - } - } + int flowerCount = Math.min(validCoords.size(), par3World.rand.nextBoolean() ? 3 : 4); + for (int i = 0; i < flowerCount; i++) { + ChunkCoordinates coords = validCoords.get(par3World.rand.nextInt(validCoords.size())); + validCoords.remove(coords); + par3World.setBlock( + coords.posX, coords.posY, coords.posZ, ModBlocks.flower, par3World.rand.nextInt(16), 1 | 2); + } + par1ItemStack.stackSize--; + } else { + for (int i = 0; i < 15; i++) { + double x = par4 - range + par3World.rand.nextInt(range * 2 + 1) + Math.random(); + double y = par5 + 1; + double z = par6 - range + par3World.rand.nextInt(range * 2 + 1) + Math.random(); + float red = (float) Math.random(); + float green = (float) Math.random(); + float blue = (float) Math.random(); + Botania.proxy.wispFX( + par3World, + x, + y, + z, + red, + green, + blue, + 0.15F + (float) Math.random() * 0.25F, + -(float) Math.random() * 0.1F - 0.05F); + } + } - return true; - } + return true; + } } diff --git a/src/main/java/vazkii/botania/common/item/ItemFlowerBag.java b/src/main/java/vazkii/botania/common/item/ItemFlowerBag.java index a57e00bfbb..1fee5adac4 100644 --- a/src/main/java/vazkii/botania/common/item/ItemFlowerBag.java +++ b/src/main/java/vazkii/botania/common/item/ItemFlowerBag.java @@ -2,14 +2,15 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Mar 16, 2015, 6:43:33 PM (GMT)] */ package vazkii.botania.common.item; +import cpw.mods.fml.common.eventhandler.SubscribeEvent; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.inventory.IInventory; import net.minecraft.item.Item; @@ -28,132 +29,134 @@ import vazkii.botania.common.core.helper.ItemNBTHelper; import vazkii.botania.common.lib.LibGuiIDs; import vazkii.botania.common.lib.LibItemNames; -import cpw.mods.fml.common.eventhandler.SubscribeEvent; public class ItemFlowerBag extends ItemMod { - private static final String TAG_ITEMS = "InvItems"; - private static final String TAG_SLOT = "Slot"; - - public ItemFlowerBag() { - setUnlocalizedName(LibItemNames.FLOWER_BAG); - setMaxStackSize(1); - MinecraftForge.EVENT_BUS.register(this); - } - - @SubscribeEvent - public void onPickupItem(EntityItemPickupEvent event) { - ItemStack stack = event.item.getEntityItem(); - if(stack.getItem() == Item.getItemFromBlock(ModBlocks.flower) && stack.stackSize > 0) { - int color = stack.getItemDamage(); - if(color > 15) - return; - - for(int i = 0; i < event.entityPlayer.inventory.getSizeInventory(); i++) { - if(i == event.entityPlayer.inventory.currentItem) - continue; // prevent item deletion - - ItemStack invStack = event.entityPlayer.inventory.getStackInSlot(i); - if(invStack != null && invStack.getItem() == this) { - ItemStack[] bagInv = loadStacks(invStack); - ItemStack stackAt = bagInv[color]; - boolean didChange = false; - if(stackAt == null) { - bagInv[color] = stack.copy(); - stack.stackSize = 0; - didChange = true; - } else { - int stackAtSize = stackAt.stackSize; - int stackSize = stack.stackSize; - int spare = 64 - stackAtSize; - int pass = Math.min(spare, stackSize); - if(pass > 0) { - stackAt.stackSize += pass; - stack.stackSize -= pass; - didChange = true; - } - } - - if(didChange) - setStacks(invStack, bagInv); - } - - if(stack.stackSize == 0) - return; - } - } - } - - @Override - public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer player) { - player.openGui(Botania.instance, LibGuiIDs.FLOWER_BAG, world, 0, 0, 0); - return stack; - } - - @Override - public boolean onItemUse(ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int s, float xs, float ys, float zs) { - TileEntity tile = world.getTileEntity(x, y, z); - if(tile != null && tile instanceof IInventory) { - if(!world.isRemote) { - ForgeDirection side = ForgeDirection.getOrientation(s); - IInventory inv = (IInventory) tile; - ItemStack[] stacks = loadStacks(stack); - ItemStack[] newStacks = new ItemStack[stacks.length]; - boolean putAny = false; - - int i = 0; - for(ItemStack petal : stacks) { - if(petal != null) { - int count = InventoryHelper.testInventoryInsertion(inv, petal, side); - InventoryHelper.insertItemIntoInventory(inv, petal, side, -1); - - ItemStack newPetal = petal.copy(); - if(newPetal.stackSize == 0) - newPetal = null; - - newStacks[i] = newPetal; - putAny |= count > 0; - } - - i++; - } - - setStacks(stack, newStacks); - if(putAny && inv instanceof TileEntityChest) { - inv = InventoryHelper.getInventory(inv); - player.displayGUIChest(inv); - } - } - - return true; - } - return false; - } - - public static ItemStack[] loadStacks(ItemStack stack) { - NBTTagList var2 = ItemNBTHelper.getList(stack, TAG_ITEMS, 10, false); - ItemStack[] inventorySlots = new ItemStack[16]; - for(int var3 = 0; var3 < var2.tagCount(); ++var3) { - NBTTagCompound var4 = var2.getCompoundTagAt(var3); - byte var5 = var4.getByte(TAG_SLOT); - if(var5 >= 0 && var5 < inventorySlots.length) - inventorySlots[var5] = ItemStack.loadItemStackFromNBT(var4); - } - - return inventorySlots; - } - - public static void setStacks(ItemStack stack, ItemStack[] inventorySlots) { - NBTTagList var2 = new NBTTagList(); - for(int var3 = 0; var3 < inventorySlots.length; ++var3) - if(inventorySlots[var3] != null) { - NBTTagCompound var4 = new NBTTagCompound(); - var4.setByte(TAG_SLOT, (byte)var3); - inventorySlots[var3].writeToNBT(var4); - var2.appendTag(var4); - } - - ItemNBTHelper.setList(stack, TAG_ITEMS, var2); - } - + private static final String TAG_ITEMS = "InvItems"; + private static final String TAG_SLOT = "Slot"; + + public ItemFlowerBag() { + setUnlocalizedName(LibItemNames.FLOWER_BAG); + setMaxStackSize(1); + MinecraftForge.EVENT_BUS.register(this); + } + + @SubscribeEvent + public void onPickupItem(EntityItemPickupEvent event) { + ItemStack stack = event.item.getEntityItem(); + if (stack.getItem() == Item.getItemFromBlock(ModBlocks.flower) && stack.stackSize > 0) { + int color = stack.getItemDamage(); + if (color > 15) return; + + for (int i = 0; i < event.entityPlayer.inventory.getSizeInventory(); i++) { + if (i == event.entityPlayer.inventory.currentItem) continue; // prevent item deletion + + ItemStack invStack = event.entityPlayer.inventory.getStackInSlot(i); + if (invStack != null && invStack.getItem() == this) { + ItemStack[] bagInv = loadStacks(invStack); + ItemStack stackAt = bagInv[color]; + boolean didChange = false; + if (stackAt == null) { + bagInv[color] = stack.copy(); + stack.stackSize = 0; + didChange = true; + } else { + int stackAtSize = stackAt.stackSize; + int stackSize = stack.stackSize; + int spare = 64 - stackAtSize; + int pass = Math.min(spare, stackSize); + if (pass > 0) { + stackAt.stackSize += pass; + stack.stackSize -= pass; + didChange = true; + } + } + + if (didChange) setStacks(invStack, bagInv); + } + + if (stack.stackSize == 0) return; + } + } + } + + @Override + public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer player) { + player.openGui(Botania.instance, LibGuiIDs.FLOWER_BAG, world, 0, 0, 0); + return stack; + } + + @Override + public boolean onItemUse( + ItemStack stack, + EntityPlayer player, + World world, + int x, + int y, + int z, + int s, + float xs, + float ys, + float zs) { + TileEntity tile = world.getTileEntity(x, y, z); + if (tile != null && tile instanceof IInventory) { + if (!world.isRemote) { + ForgeDirection side = ForgeDirection.getOrientation(s); + IInventory inv = (IInventory) tile; + ItemStack[] stacks = loadStacks(stack); + ItemStack[] newStacks = new ItemStack[stacks.length]; + boolean putAny = false; + + int i = 0; + for (ItemStack petal : stacks) { + if (petal != null) { + int count = InventoryHelper.testInventoryInsertion(inv, petal, side); + InventoryHelper.insertItemIntoInventory(inv, petal, side, -1); + + ItemStack newPetal = petal.copy(); + if (newPetal.stackSize == 0) newPetal = null; + + newStacks[i] = newPetal; + putAny |= count > 0; + } + + i++; + } + + setStacks(stack, newStacks); + if (putAny && inv instanceof TileEntityChest) { + inv = InventoryHelper.getInventory(inv); + player.displayGUIChest(inv); + } + } + + return true; + } + return false; + } + + public static ItemStack[] loadStacks(ItemStack stack) { + NBTTagList var2 = ItemNBTHelper.getList(stack, TAG_ITEMS, 10, false); + ItemStack[] inventorySlots = new ItemStack[16]; + for (int var3 = 0; var3 < var2.tagCount(); ++var3) { + NBTTagCompound var4 = var2.getCompoundTagAt(var3); + byte var5 = var4.getByte(TAG_SLOT); + if (var5 >= 0 && var5 < inventorySlots.length) inventorySlots[var5] = ItemStack.loadItemStackFromNBT(var4); + } + + return inventorySlots; + } + + public static void setStacks(ItemStack stack, ItemStack[] inventorySlots) { + NBTTagList var2 = new NBTTagList(); + for (int var3 = 0; var3 < inventorySlots.length; ++var3) + if (inventorySlots[var3] != null) { + NBTTagCompound var4 = new NBTTagCompound(); + var4.setByte(TAG_SLOT, (byte) var3); + inventorySlots[var3].writeToNBT(var4); + var2.appendTag(var4); + } + + ItemNBTHelper.setList(stack, TAG_ITEMS, var2); + } } diff --git a/src/main/java/vazkii/botania/common/item/ItemGaiaHead.java b/src/main/java/vazkii/botania/common/item/ItemGaiaHead.java index ec8205310f..41de83f119 100644 --- a/src/main/java/vazkii/botania/common/item/ItemGaiaHead.java +++ b/src/main/java/vazkii/botania/common/item/ItemGaiaHead.java @@ -24,72 +24,88 @@ public class ItemGaiaHead extends ItemMod { - public ItemGaiaHead() { - setUnlocalizedName(LibItemNames.GAIA_HEAD); - } - - // I couldn't deal with it. - @Override - public boolean onItemUse(ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int side, float sideX, float sideY, float sideZ) { - // The side of the wall the head is being used on. - ForgeDirection sideDir = ForgeDirection.getOrientation(side); - - // If we can replace the block we're clicking on, then we'll go ahead - // and replace it (eg, snow). - if (world.getBlock(x, y, z).isReplaceable(world, x, y, z) && sideDir != ForgeDirection.DOWN) { - sideDir = ForgeDirection.UP; - y--; - } - - // Skulls can't be placed on the bottom side of a block. - if (sideDir == ForgeDirection.DOWN) - return false; - - // If the side we're trying to place the skull on isn't solid, then - // we can't place it either. - if (!world.isSideSolid(x, y, z, sideDir)) - return false; - - // Figure out where the skull actually goes based on the side we're placing it against. - switch(sideDir) { - case UP: y++; break; // If we're placing it on the top, then the skull goes 1 block above. - case NORTH: z--; break; // Placing it on the north side (Z- axis). - case SOUTH: z++; break; // Placing it on the south side (Z+ axis). - case WEST: x--; break; // Placing it on the west side (X- axis). - case EAST: x++; break; // Placing it on the east side (X+ axis). - default: return false; // Oops, this shouldn't happen. - } - - // We can't place blocks as a measly client. - if(world.isRemote) - return true; - - // If the skull says no, who are we to argue? - if (!ModBlocks.gaiaHead.canPlaceBlockOnSide(world, x, y, z, side)) - return false; - - // Gaia head, instead of skull - world.setBlock(x, y, z, ModBlocks.gaiaHead, sideDir.ordinal(), 2); - int headAngle = 0; - - // If we place the skull on top of a block, we should also make it - // face the player by rotating it. - if (sideDir == ForgeDirection.UP) - headAngle = MathHelper.floor_double(player.rotationYaw * 16.0F / 360.0F + 0.5D) & 15; - - // Update the skull's orientation if it lets us. - TileEntity tileentity = world.getTileEntity(x, y, z); - - if (tileentity != null && tileentity instanceof TileEntitySkull) { - ((TileEntitySkull) tileentity).func_145903_a(headAngle); - ((BlockSkull) Blocks.skull).func_149965_a(world, x, y, z, (TileEntitySkull) tileentity); - } - - // Remove a head from the stack. - --stack.stackSize; - - // Call it a success and leave. - return true; - } - + public ItemGaiaHead() { + setUnlocalizedName(LibItemNames.GAIA_HEAD); + } + + // I couldn't deal with it. + @Override + public boolean onItemUse( + ItemStack stack, + EntityPlayer player, + World world, + int x, + int y, + int z, + int side, + float sideX, + float sideY, + float sideZ) { + // The side of the wall the head is being used on. + ForgeDirection sideDir = ForgeDirection.getOrientation(side); + + // If we can replace the block we're clicking on, then we'll go ahead + // and replace it (eg, snow). + if (world.getBlock(x, y, z).isReplaceable(world, x, y, z) && sideDir != ForgeDirection.DOWN) { + sideDir = ForgeDirection.UP; + y--; + } + + // Skulls can't be placed on the bottom side of a block. + if (sideDir == ForgeDirection.DOWN) return false; + + // If the side we're trying to place the skull on isn't solid, then + // we can't place it either. + if (!world.isSideSolid(x, y, z, sideDir)) return false; + + // Figure out where the skull actually goes based on the side we're placing it against. + switch (sideDir) { + case UP: + y++; + break; // If we're placing it on the top, then the skull goes 1 block above. + case NORTH: + z--; + break; // Placing it on the north side (Z- axis). + case SOUTH: + z++; + break; // Placing it on the south side (Z+ axis). + case WEST: + x--; + break; // Placing it on the west side (X- axis). + case EAST: + x++; + break; // Placing it on the east side (X+ axis). + default: + return false; // Oops, this shouldn't happen. + } + + // We can't place blocks as a measly client. + if (world.isRemote) return true; + + // If the skull says no, who are we to argue? + if (!ModBlocks.gaiaHead.canPlaceBlockOnSide(world, x, y, z, side)) return false; + + // Gaia head, instead of skull + world.setBlock(x, y, z, ModBlocks.gaiaHead, sideDir.ordinal(), 2); + int headAngle = 0; + + // If we place the skull on top of a block, we should also make it + // face the player by rotating it. + if (sideDir == ForgeDirection.UP) + headAngle = MathHelper.floor_double(player.rotationYaw * 16.0F / 360.0F + 0.5D) & 15; + + // Update the skull's orientation if it lets us. + TileEntity tileentity = world.getTileEntity(x, y, z); + + if (tileentity != null && tileentity instanceof TileEntitySkull) { + ((TileEntitySkull) tileentity).func_145903_a(headAngle); + ((BlockSkull) Blocks.skull).func_149965_a(world, x, y, z, (TileEntitySkull) tileentity); + } + + // Remove a head from the stack. + --stack.stackSize; + + // Call it a success and leave. + return true; + } } diff --git a/src/main/java/vazkii/botania/common/item/ItemGrassHorn.java b/src/main/java/vazkii/botania/common/item/ItemGrassHorn.java index dec75518f9..f56edf2e8a 100644 --- a/src/main/java/vazkii/botania/common/item/ItemGrassHorn.java +++ b/src/main/java/vazkii/botania/common/item/ItemGrassHorn.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Apr 11, 2014, 2:57:30 PM (GMT)] */ package vazkii.botania.common.item; @@ -14,7 +14,6 @@ import java.util.Collections; import java.util.List; import java.util.Random; - import net.minecraft.block.Block; import net.minecraft.block.BlockBush; import net.minecraft.client.renderer.texture.IIconRegister; @@ -38,124 +37,142 @@ public class ItemGrassHorn extends ItemMod { - private static final int SUBTYPES = 3; - IIcon[] icons; - IIcon vuvuzelaIcon; - - public ItemGrassHorn() { - super(); - setMaxStackSize(1); - setUnlocalizedName(LibItemNames.GRASS_HORN); - setHasSubtypes(true); - } - - @Override - public void getSubItems(Item item, CreativeTabs tab, List list) { - for(int i = 0; i < SUBTYPES; i++) - list.add(new ItemStack(item, 1, i)); - } - - @Override - public void registerIcons(IIconRegister par1IconRegister) { - icons = new IIcon[SUBTYPES]; - for(int i = 0; i < icons.length; i++) - icons[i] = IconHelper.forItem(par1IconRegister, this, i); - vuvuzelaIcon = IconHelper.forName(par1IconRegister, "vuvuzela"); - } - - @Override - public IIcon getIconIndex(ItemStack par1ItemStack) { - return par1ItemStack.getDisplayName().toLowerCase().contains("vuvuzela") ? vuvuzelaIcon : super.getIconIndex(par1ItemStack); - } - - @Override - public IIcon getIcon(ItemStack stack, int pass) { - return getIconIndex(stack); - } - - @Override - public IIcon getIconFromDamage(int par1) { - return icons[Math.min(icons.length - 1, par1)]; - } - - @Override - public String getUnlocalizedName(ItemStack par1ItemStack) { - return getUnlocalizedNameLazy(par1ItemStack) + par1ItemStack.getItemDamage(); - } - - String getUnlocalizedNameLazy(ItemStack par1ItemStack) { - return super.getUnlocalizedName(par1ItemStack); - } - - @Override - public EnumAction getItemUseAction(ItemStack par1ItemStack) { - return EnumAction.bow; - } - - @Override - public int getMaxItemUseDuration(ItemStack par1ItemStack) { - return 72000; - } - - @Override - public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer) { - par3EntityPlayer.setItemInUse(par1ItemStack, getMaxItemUseDuration(par1ItemStack)); - return par1ItemStack; - } - - @Override - public void onUsingTick(ItemStack stack, EntityPlayer player, int time) { - if(time != getMaxItemUseDuration(stack) && time % 5 == 0) - breakGrass(player.worldObj, stack, stack.getItemDamage(), (int) player.posX, (int) player.posY, (int) player.posZ); - - if(!player.worldObj.isRemote) - player.worldObj.playSoundAtEntity(player, "note.bassattack", 1F, 0.001F); - } - - public static void breakGrass(World world, ItemStack stack, int stackDmg, int srcx, int srcy, int srcz) { - EnumHornType type = EnumHornType.getTypeForMeta(stackDmg); - Random rand = new Random(srcx ^ srcy ^ srcz); - int range = 12 - stackDmg * 3; - int rangeY = 3 + stackDmg * 4; - List coords = new ArrayList(); - - for(int i = -range; i < range + 1; i++) - for(int j = -range; j < range + 1; j++) - for(int k = -rangeY; k < rangeY + 1; k++) { - int x = srcx + i; - int y = srcy + k; - int z = srcz + j; - - Block block = world.getBlock(x, y, z); - if(block instanceof IHornHarvestable ? ((IHornHarvestable) block).canHornHarvest(world, x, y, z, stack, type) : stackDmg == 0 && block instanceof BlockBush && !(block instanceof ISpecialFlower) && (!(block instanceof IGrassHornExcempt) || ((IGrassHornExcempt) block).canUproot(world, x, y, z)) || stackDmg == 1 && block.isLeaves(world, x, y, z) || stackDmg == 2 && block == Blocks.snow_layer) - coords.add(new ChunkCoordinates(x, y, z)); - } - - Collections.shuffle(coords, rand); - - int count = Math.min(coords.size(), 32 + stackDmg * 16); - for(int i = 0; i < count; i++) { - ChunkCoordinates currCoords = coords.get(i); - List items = new ArrayList(); - Block block = world.getBlock(currCoords.posX, currCoords.posY, currCoords.posZ); - int meta = world.getBlockMetadata(currCoords.posX, currCoords.posY, currCoords.posZ); - items.addAll(block.getDrops(world, currCoords.posX, currCoords.posY, currCoords.posZ, meta, 0)); - - if(block instanceof IHornHarvestable && ((IHornHarvestable) block).hasSpecialHornHarvest(world, currCoords.posX, currCoords.posY, currCoords.posZ, stack, type)) - ((IHornHarvestable) block).harvestByHorn(world, currCoords.posX, currCoords.posY, currCoords.posZ, stack, type); - else if(!world.isRemote) { - world.setBlockToAir(currCoords.posX, currCoords.posY, currCoords.posZ); - if(ConfigHandler.blockBreakParticles) - world.playAuxSFX(2001, currCoords.posX, currCoords.posY, currCoords.posZ, Block.getIdFromBlock(block) + (meta << 12)); - - for(ItemStack stack_ : items) - world.spawnEntityInWorld(new EntityItem(world, currCoords.posX + 0.5, currCoords.posY + 0.5, currCoords.posZ + 0.5, stack_)); - } - } - } - - @Override - public boolean isFull3D() { - return true; - } + private static final int SUBTYPES = 3; + IIcon[] icons; + IIcon vuvuzelaIcon; + + public ItemGrassHorn() { + super(); + setMaxStackSize(1); + setUnlocalizedName(LibItemNames.GRASS_HORN); + setHasSubtypes(true); + } + + @Override + public void getSubItems(Item item, CreativeTabs tab, List list) { + for (int i = 0; i < SUBTYPES; i++) list.add(new ItemStack(item, 1, i)); + } + + @Override + public void registerIcons(IIconRegister par1IconRegister) { + icons = new IIcon[SUBTYPES]; + for (int i = 0; i < icons.length; i++) icons[i] = IconHelper.forItem(par1IconRegister, this, i); + vuvuzelaIcon = IconHelper.forName(par1IconRegister, "vuvuzela"); + } + + @Override + public IIcon getIconIndex(ItemStack par1ItemStack) { + return par1ItemStack.getDisplayName().toLowerCase().contains("vuvuzela") + ? vuvuzelaIcon + : super.getIconIndex(par1ItemStack); + } + + @Override + public IIcon getIcon(ItemStack stack, int pass) { + return getIconIndex(stack); + } + + @Override + public IIcon getIconFromDamage(int par1) { + return icons[Math.min(icons.length - 1, par1)]; + } + + @Override + public String getUnlocalizedName(ItemStack par1ItemStack) { + return getUnlocalizedNameLazy(par1ItemStack) + par1ItemStack.getItemDamage(); + } + + String getUnlocalizedNameLazy(ItemStack par1ItemStack) { + return super.getUnlocalizedName(par1ItemStack); + } + + @Override + public EnumAction getItemUseAction(ItemStack par1ItemStack) { + return EnumAction.bow; + } + + @Override + public int getMaxItemUseDuration(ItemStack par1ItemStack) { + return 72000; + } + + @Override + public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer) { + par3EntityPlayer.setItemInUse(par1ItemStack, getMaxItemUseDuration(par1ItemStack)); + return par1ItemStack; + } + + @Override + public void onUsingTick(ItemStack stack, EntityPlayer player, int time) { + if (time != getMaxItemUseDuration(stack) && time % 5 == 0) + breakGrass(player.worldObj, stack, stack.getItemDamage(), (int) player.posX, (int) player.posY, (int) + player.posZ); + + if (!player.worldObj.isRemote) player.worldObj.playSoundAtEntity(player, "note.bassattack", 1F, 0.001F); + } + + public static void breakGrass(World world, ItemStack stack, int stackDmg, int srcx, int srcy, int srcz) { + EnumHornType type = EnumHornType.getTypeForMeta(stackDmg); + Random rand = new Random(srcx ^ srcy ^ srcz); + int range = 12 - stackDmg * 3; + int rangeY = 3 + stackDmg * 4; + List coords = new ArrayList(); + + for (int i = -range; i < range + 1; i++) + for (int j = -range; j < range + 1; j++) + for (int k = -rangeY; k < rangeY + 1; k++) { + int x = srcx + i; + int y = srcy + k; + int z = srcz + j; + + Block block = world.getBlock(x, y, z); + if (block instanceof IHornHarvestable + ? ((IHornHarvestable) block).canHornHarvest(world, x, y, z, stack, type) + : stackDmg == 0 + && block instanceof BlockBush + && !(block instanceof ISpecialFlower) + && (!(block instanceof IGrassHornExcempt) + || ((IGrassHornExcempt) block).canUproot(world, x, y, z)) + || stackDmg == 1 && block.isLeaves(world, x, y, z) + || stackDmg == 2 && block == Blocks.snow_layer) + coords.add(new ChunkCoordinates(x, y, z)); + } + + Collections.shuffle(coords, rand); + + int count = Math.min(coords.size(), 32 + stackDmg * 16); + for (int i = 0; i < count; i++) { + ChunkCoordinates currCoords = coords.get(i); + List items = new ArrayList(); + Block block = world.getBlock(currCoords.posX, currCoords.posY, currCoords.posZ); + int meta = world.getBlockMetadata(currCoords.posX, currCoords.posY, currCoords.posZ); + items.addAll(block.getDrops(world, currCoords.posX, currCoords.posY, currCoords.posZ, meta, 0)); + + if (block instanceof IHornHarvestable + && ((IHornHarvestable) block) + .hasSpecialHornHarvest( + world, currCoords.posX, currCoords.posY, currCoords.posZ, stack, type)) + ((IHornHarvestable) block) + .harvestByHorn(world, currCoords.posX, currCoords.posY, currCoords.posZ, stack, type); + else if (!world.isRemote) { + world.setBlockToAir(currCoords.posX, currCoords.posY, currCoords.posZ); + if (ConfigHandler.blockBreakParticles) + world.playAuxSFX( + 2001, + currCoords.posX, + currCoords.posY, + currCoords.posZ, + Block.getIdFromBlock(block) + (meta << 12)); + + for (ItemStack stack_ : items) + world.spawnEntityInWorld(new EntityItem( + world, currCoords.posX + 0.5, currCoords.posY + 0.5, currCoords.posZ + 0.5, stack_)); + } + } + } + + @Override + public boolean isFull3D() { + return true; + } } diff --git a/src/main/java/vazkii/botania/common/item/ItemGrassSeeds.java b/src/main/java/vazkii/botania/common/item/ItemGrassSeeds.java index b63033154d..3ad3289cbd 100644 --- a/src/main/java/vazkii/botania/common/item/ItemGrassSeeds.java +++ b/src/main/java/vazkii/botania/common/item/ItemGrassSeeds.java @@ -2,14 +2,20 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Apr 9, 2014, 5:11:34 PM (GMT)] */ package vazkii.botania.common.item; +import cpw.mods.fml.common.FMLCommonHandler; +import cpw.mods.fml.common.eventhandler.SubscribeEvent; +import cpw.mods.fml.common.gameevent.TickEvent; +import cpw.mods.fml.common.gameevent.TickEvent.Phase; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; import java.util.ArrayList; import java.util.HashMap; import java.util.HashSet; @@ -18,7 +24,6 @@ import java.util.Map; import java.util.Random; import java.util.Set; - import net.minecraft.block.Block; import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.creativetab.CreativeTabs; @@ -34,344 +39,361 @@ import vazkii.botania.common.block.ModBlocks; import vazkii.botania.common.block.decor.IFloatingFlower.IslandType; import vazkii.botania.common.lib.LibItemNames; -import cpw.mods.fml.common.FMLCommonHandler; -import cpw.mods.fml.common.eventhandler.SubscribeEvent; -import cpw.mods.fml.common.gameevent.TickEvent; -import cpw.mods.fml.common.gameevent.TickEvent.Phase; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; public class ItemGrassSeeds extends ItemMod implements IFloatingFlowerVariant { - /** - * Represents a map of dimension IDs to a set of all block swappers - * active in that dimension. - */ - private static Map> blockSwappers = new HashMap>(); - - private static final IslandType[] ISLAND_TYPES = { - IslandType.GRASS, IslandType.PODZOL, IslandType.MYCEL, - IslandType.DRY, IslandType.GOLDEN, IslandType.VIVID, - IslandType.SCORCHED, IslandType.INFUSED, IslandType.MUTATED - }; - - private static final int SUBTYPES = 9; - IIcon[] icons; - - public ItemGrassSeeds() { - super(); - setUnlocalizedName(LibItemNames.GRASS_SEEDS); - setHasSubtypes(true); - FMLCommonHandler.instance().bus().register(this); - } - - @Override - public void getSubItems(Item par1, CreativeTabs par2, List par3) { - for(int i = 0; i < SUBTYPES; i++) - par3.add(new ItemStack(par1, 1, i)); - } - - @Override - @SideOnly(Side.CLIENT) - public void registerIcons(IIconRegister par1IconRegister) { - icons = new IIcon[SUBTYPES]; - for(int i = 0; i < SUBTYPES; i++) - icons[i] = IconHelper.forItem(par1IconRegister, this, i); - } - - @Override - @SideOnly(Side.CLIENT) - public IIcon getIconFromDamage(int par1) { - return icons[Math.min(icons.length - 1, par1)]; - } - - @Override - public String getUnlocalizedName(ItemStack stack) { - return super.getUnlocalizedName() + stack.getItemDamage(); - } - - @Override - public boolean onItemUse(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, World par3World, int par4, int par5, int par6, int par7, float par8, float par9, float par10) { - Block block = par3World.getBlock(par4, par5, par6); - int bmeta = par3World.getBlockMetadata(par4, par5, par6); - - if((block == Blocks.dirt || block == Blocks.grass && par1ItemStack.getItemDamage() != 0) && bmeta == 0) { - int meta = par1ItemStack.getItemDamage(); - - BlockSwapper swapper = addBlockSwapper(par3World, par4, par5, par6, meta); - par3World.setBlock(par4, par5, par6, swapper.blockToSet, swapper.metaToSet, 1 | 2); - for(int i = 0; i < 50; i++) { - double x = (Math.random() - 0.5) * 3; - double y = Math.random() - 0.5 + 1; - double z = (Math.random() - 0.5) * 3; - - float r = 0F; - float g = 0.4F; - float b = 0F; - switch(meta) { - case 1: { - r = 0.5F; - g = 0.37F; - b = 0F; - break; - } - case 2: { - r = 0.27F; - g = 0F; - b = 0.33F; - break; - } - case 3: { - r = 0.4F; - g = 0.5F; - b = 0.05F; - break; - } - case 4: { - r = 0.75F; - g = 0.7F; - b = 0F; - break; - } - case 5: { - r = 0F; - g = 0.5F; - b = 0.1F; - break; - } - case 6: { - r = 0.75F; - g = 0F; - b = 0F; - break; - } - case 7: { - r = 0F; - g = 0.55F; - b = 0.55F; - break; - } - case 8: { - r = 0.4F; - g = 0.1F; - b = 0.4F; - break; - } - } - - float velMul = 0.025F; - - Botania.proxy.wispFX(par3World, par4 + 0.5 + x, par5 + 0.5 + y, par6 + 0.5 + z, r, g, b, (float) Math.random() * 0.15F + 0.15F, (float) -x * velMul, (float) -y * velMul, (float) -z * velMul); - } - - par1ItemStack.stackSize--; - } - - return true; - } - - @SubscribeEvent - public void onTickEnd(TickEvent.WorldTickEvent event) { - // Block swapper updates should only occur on the server - if(event.world.isRemote) - return; - - if(event.phase == Phase.END) { - int dim = event.world.provider.dimensionId; - if(blockSwappers.containsKey(dim)) { - Set swappers = blockSwappers.get(dim); - - Iterator iter = swappers.iterator(); - - while(iter.hasNext()) { - BlockSwapper next = iter.next(); - if(next == null || !next.tick()) - iter.remove(); - } - } - } - } - - /** - * Adds a grass seed block swapper to the world at the provided positiona - * and with the provided meta (which designates the type of the grass - * being spread). - * - * Block swappers are only actually created on the server, so a client - * calling this method will recieve a marker block swapper which contains - * the provided information but is not ticked. - * @param world The world the swapper will be in. - * @param x The x-position of the swapper. - * @param y The y-position of the swapper. - * @param z The z-position of the swapper. - * @param meta The meta value representing the type of block being swapped. - * @return The created block swapper. - */ - private static BlockSwapper addBlockSwapper(World world, int x, int y, int z, int meta) { - BlockSwapper swapper = swapperFromMeta(world, x, y, z, meta); - - // Block swappers are only registered on the server - if(world.isRemote) - return swapper; - - // If a set for the dimension doesn't exist, create it. - int dim = world.provider.dimensionId; - if(!blockSwappers.containsKey(dim)) - blockSwappers.put(dim, new HashSet()); - - // Add the block swapper - blockSwappers.get(dim).add(swapper); - - return swapper; - } - - private static BlockSwapper swapperFromMeta(World world, int x, int y, int z, int meta) { - switch(meta) { - case 1 : return new BlockSwapper(world, new ChunkCoordinates(x, y, z), Blocks.dirt, 2); - case 2 : return new BlockSwapper(world, new ChunkCoordinates(x, y, z), Blocks.mycelium, 0); - case 3 : return new BlockSwapper(world, new ChunkCoordinates(x, y, z), ModBlocks.altGrass, 0); - case 4 : return new BlockSwapper(world, new ChunkCoordinates(x, y, z), ModBlocks.altGrass, 1); - case 5 : return new BlockSwapper(world, new ChunkCoordinates(x, y, z), ModBlocks.altGrass, 2); - case 6 : return new BlockSwapper(world, new ChunkCoordinates(x, y, z), ModBlocks.altGrass, 3); - case 7 : return new BlockSwapper(world, new ChunkCoordinates(x, y, z), ModBlocks.altGrass, 4); - case 8 : return new BlockSwapper(world, new ChunkCoordinates(x, y, z), ModBlocks.altGrass, 5); - default : return new BlockSwapper(world, new ChunkCoordinates(x, y, z), Blocks.grass, 0); - } - } - - /** - * A block swapper for the Pasture Seeds, which swaps dirt and grass blocks - * centered around a provided point to a provided block/metadata. - */ - private static class BlockSwapper { - - /** - * The range of the block swapper, in blocks. - */ - public static final int RANGE = 3; - - /** - * The range around which a block can spread in a single tick. - */ - public static final int TICK_RANGE = 1; - - private final World world; - private final Random rand; - private final Block blockToSet; - private final int metaToSet; - - private ChunkCoordinates startCoords; - private int ticksExisted = 0; - - /** - * Constructs a new block swapper with the provided world, starting - * coordinates, target block, and target metadata. - * @param world The world to swap blocks in. - * @param coords The central coordinates to swap blocks around. - * @param block The target block to swap dirt and grass to. - * @param meta The metadata of the target block to swap dirt and grass to. - */ - public BlockSwapper(World world, ChunkCoordinates coords, Block block, int meta) { - this.world = world; - this.blockToSet = block; - this.metaToSet = meta; - this.rand = new Random(coords.posX ^ coords.posY ^ coords.posZ); - this.startCoords = coords; - } - - /** - * Ticks this block swapper, allowing it to make an action during - * this game tick. This method should return "false" when the swapper - * has finished operation and should be removed from the world. - * @return true if the swapper should continue to exist, false if it - * should be removed. - */ - public boolean tick() { - ++ticksExisted; - - // Go through all blocks in the specified RANGE, and then - // try and spread around that block if it is our target block already - for(int i = -RANGE; i <= RANGE; i++) { - for(int j = -RANGE; j <= RANGE; j++) { - int x = startCoords.posX + i; - int y = startCoords.posY; - int z = startCoords.posZ + j; - Block block = world.getBlock(x, y, z); - int meta = world.getBlockMetadata(x, y, z); - - if(block == blockToSet && meta == metaToSet) { - // Only make changes every 20 ticks - if(ticksExisted % 20 != 0) continue; - - tickBlock(x, y, z); - } - } - } - - // This swapper should exist for 80 ticks - return ticksExisted < 80; - } - - /** - * Tick a specific block position, finding the valid blocks - * immediately adjacent to it and then replacing one at random. - * @param x The x-coordinate to use. - * @param y The y-coordinate to use. - * @param z The z-coordinate to use. - */ - public void tickBlock(int x, int y, int z) { - List validCoords = new ArrayList(); - - // Go around this block and aggregate valid blocks. - for(int xOffset = -TICK_RANGE; xOffset <= TICK_RANGE; xOffset++) { - for(int zOffset = -TICK_RANGE; zOffset <= TICK_RANGE; zOffset++) { - // Skip the current block - if(xOffset == 0 && zOffset == 0) continue; - - if(isValidSwapPosition(x + xOffset, y, z + zOffset)) - validCoords.add(new ChunkCoordinates(x + xOffset, y, z + zOffset)); - } - } - - // If we can make changes, and have at least 1 block to swap, - // then swap a random block from the valid blocks we could swap. - if(!validCoords.isEmpty() && !world.isRemote) { - ChunkCoordinates toSwap = validCoords.get(rand.nextInt(validCoords.size())); - - world.setBlock(toSwap.posX, toSwap.posY, toSwap.posZ, blockToSet, metaToSet, 1 | 2); - } - } - - /** - * Determines if a given position is a valid location to spread to, which - * means that the block must be either dirt or grass (with meta 0), - * and have a block above it which does not block grass growth. - * @param x The x-coordinate to check. - * @param y The y-coordinate to check. - * @param z The z-coordinate to check. - * @return True if the position is valid to swap, false otherwise. - */ - public boolean isValidSwapPosition(int x, int y, int z) { - Block block = world.getBlock(x, y, z); - int meta = world.getBlockMetadata(x, y, z); - - Block aboveBlock = world.getBlock(x, y + 1, z); - - // Valid blocks to spread to are either dirt or grass, and do not - // have blocks which block grass growth. - - // See http://minecraft.gamepedia.com/Grass_Block - // The major rule is that a block which reduces light - // levels by 2 or more blocks grass growth. - - return (block == Blocks.dirt || block == Blocks.grass) - && (meta == 0) - && (aboveBlock.getLightOpacity(world, x, y, z) <= 1); - } - } - - public IslandType getIslandType(ItemStack stack) { - return ISLAND_TYPES[Math.min(stack.getItemDamage(), ISLAND_TYPES.length - 1)]; - } - + /** + * Represents a map of dimension IDs to a set of all block swappers + * active in that dimension. + */ + private static Map> blockSwappers = new HashMap>(); + + private static final IslandType[] ISLAND_TYPES = { + IslandType.GRASS, IslandType.PODZOL, IslandType.MYCEL, + IslandType.DRY, IslandType.GOLDEN, IslandType.VIVID, + IslandType.SCORCHED, IslandType.INFUSED, IslandType.MUTATED + }; + + private static final int SUBTYPES = 9; + IIcon[] icons; + + public ItemGrassSeeds() { + super(); + setUnlocalizedName(LibItemNames.GRASS_SEEDS); + setHasSubtypes(true); + FMLCommonHandler.instance().bus().register(this); + } + + @Override + public void getSubItems(Item par1, CreativeTabs par2, List par3) { + for (int i = 0; i < SUBTYPES; i++) par3.add(new ItemStack(par1, 1, i)); + } + + @Override + @SideOnly(Side.CLIENT) + public void registerIcons(IIconRegister par1IconRegister) { + icons = new IIcon[SUBTYPES]; + for (int i = 0; i < SUBTYPES; i++) icons[i] = IconHelper.forItem(par1IconRegister, this, i); + } + + @Override + @SideOnly(Side.CLIENT) + public IIcon getIconFromDamage(int par1) { + return icons[Math.min(icons.length - 1, par1)]; + } + + @Override + public String getUnlocalizedName(ItemStack stack) { + return super.getUnlocalizedName() + stack.getItemDamage(); + } + + @Override + public boolean onItemUse( + ItemStack par1ItemStack, + EntityPlayer par2EntityPlayer, + World par3World, + int par4, + int par5, + int par6, + int par7, + float par8, + float par9, + float par10) { + Block block = par3World.getBlock(par4, par5, par6); + int bmeta = par3World.getBlockMetadata(par4, par5, par6); + + if ((block == Blocks.dirt || block == Blocks.grass && par1ItemStack.getItemDamage() != 0) && bmeta == 0) { + int meta = par1ItemStack.getItemDamage(); + + BlockSwapper swapper = addBlockSwapper(par3World, par4, par5, par6, meta); + par3World.setBlock(par4, par5, par6, swapper.blockToSet, swapper.metaToSet, 1 | 2); + for (int i = 0; i < 50; i++) { + double x = (Math.random() - 0.5) * 3; + double y = Math.random() - 0.5 + 1; + double z = (Math.random() - 0.5) * 3; + + float r = 0F; + float g = 0.4F; + float b = 0F; + switch (meta) { + case 1: { + r = 0.5F; + g = 0.37F; + b = 0F; + break; + } + case 2: { + r = 0.27F; + g = 0F; + b = 0.33F; + break; + } + case 3: { + r = 0.4F; + g = 0.5F; + b = 0.05F; + break; + } + case 4: { + r = 0.75F; + g = 0.7F; + b = 0F; + break; + } + case 5: { + r = 0F; + g = 0.5F; + b = 0.1F; + break; + } + case 6: { + r = 0.75F; + g = 0F; + b = 0F; + break; + } + case 7: { + r = 0F; + g = 0.55F; + b = 0.55F; + break; + } + case 8: { + r = 0.4F; + g = 0.1F; + b = 0.4F; + break; + } + } + + float velMul = 0.025F; + + Botania.proxy.wispFX( + par3World, + par4 + 0.5 + x, + par5 + 0.5 + y, + par6 + 0.5 + z, + r, + g, + b, + (float) Math.random() * 0.15F + 0.15F, + (float) -x * velMul, + (float) -y * velMul, + (float) -z * velMul); + } + + par1ItemStack.stackSize--; + } + + return true; + } + + @SubscribeEvent + public void onTickEnd(TickEvent.WorldTickEvent event) { + // Block swapper updates should only occur on the server + if (event.world.isRemote) return; + + if (event.phase == Phase.END) { + int dim = event.world.provider.dimensionId; + if (blockSwappers.containsKey(dim)) { + Set swappers = blockSwappers.get(dim); + + Iterator iter = swappers.iterator(); + + while (iter.hasNext()) { + BlockSwapper next = iter.next(); + if (next == null || !next.tick()) iter.remove(); + } + } + } + } + + /** + * Adds a grass seed block swapper to the world at the provided positiona + * and with the provided meta (which designates the type of the grass + * being spread). + * + * Block swappers are only actually created on the server, so a client + * calling this method will recieve a marker block swapper which contains + * the provided information but is not ticked. + * @param world The world the swapper will be in. + * @param x The x-position of the swapper. + * @param y The y-position of the swapper. + * @param z The z-position of the swapper. + * @param meta The meta value representing the type of block being swapped. + * @return The created block swapper. + */ + private static BlockSwapper addBlockSwapper(World world, int x, int y, int z, int meta) { + BlockSwapper swapper = swapperFromMeta(world, x, y, z, meta); + + // Block swappers are only registered on the server + if (world.isRemote) return swapper; + + // If a set for the dimension doesn't exist, create it. + int dim = world.provider.dimensionId; + if (!blockSwappers.containsKey(dim)) blockSwappers.put(dim, new HashSet()); + + // Add the block swapper + blockSwappers.get(dim).add(swapper); + + return swapper; + } + + private static BlockSwapper swapperFromMeta(World world, int x, int y, int z, int meta) { + switch (meta) { + case 1: + return new BlockSwapper(world, new ChunkCoordinates(x, y, z), Blocks.dirt, 2); + case 2: + return new BlockSwapper(world, new ChunkCoordinates(x, y, z), Blocks.mycelium, 0); + case 3: + return new BlockSwapper(world, new ChunkCoordinates(x, y, z), ModBlocks.altGrass, 0); + case 4: + return new BlockSwapper(world, new ChunkCoordinates(x, y, z), ModBlocks.altGrass, 1); + case 5: + return new BlockSwapper(world, new ChunkCoordinates(x, y, z), ModBlocks.altGrass, 2); + case 6: + return new BlockSwapper(world, new ChunkCoordinates(x, y, z), ModBlocks.altGrass, 3); + case 7: + return new BlockSwapper(world, new ChunkCoordinates(x, y, z), ModBlocks.altGrass, 4); + case 8: + return new BlockSwapper(world, new ChunkCoordinates(x, y, z), ModBlocks.altGrass, 5); + default: + return new BlockSwapper(world, new ChunkCoordinates(x, y, z), Blocks.grass, 0); + } + } + + /** + * A block swapper for the Pasture Seeds, which swaps dirt and grass blocks + * centered around a provided point to a provided block/metadata. + */ + private static class BlockSwapper { + + /** + * The range of the block swapper, in blocks. + */ + public static final int RANGE = 3; + + /** + * The range around which a block can spread in a single tick. + */ + public static final int TICK_RANGE = 1; + + private final World world; + private final Random rand; + private final Block blockToSet; + private final int metaToSet; + + private ChunkCoordinates startCoords; + private int ticksExisted = 0; + + /** + * Constructs a new block swapper with the provided world, starting + * coordinates, target block, and target metadata. + * @param world The world to swap blocks in. + * @param coords The central coordinates to swap blocks around. + * @param block The target block to swap dirt and grass to. + * @param meta The metadata of the target block to swap dirt and grass to. + */ + public BlockSwapper(World world, ChunkCoordinates coords, Block block, int meta) { + this.world = world; + this.blockToSet = block; + this.metaToSet = meta; + this.rand = new Random(coords.posX ^ coords.posY ^ coords.posZ); + this.startCoords = coords; + } + + /** + * Ticks this block swapper, allowing it to make an action during + * this game tick. This method should return "false" when the swapper + * has finished operation and should be removed from the world. + * @return true if the swapper should continue to exist, false if it + * should be removed. + */ + public boolean tick() { + ++ticksExisted; + + // Go through all blocks in the specified RANGE, and then + // try and spread around that block if it is our target block already + for (int i = -RANGE; i <= RANGE; i++) { + for (int j = -RANGE; j <= RANGE; j++) { + int x = startCoords.posX + i; + int y = startCoords.posY; + int z = startCoords.posZ + j; + Block block = world.getBlock(x, y, z); + int meta = world.getBlockMetadata(x, y, z); + + if (block == blockToSet && meta == metaToSet) { + // Only make changes every 20 ticks + if (ticksExisted % 20 != 0) continue; + + tickBlock(x, y, z); + } + } + } + + // This swapper should exist for 80 ticks + return ticksExisted < 80; + } + + /** + * Tick a specific block position, finding the valid blocks + * immediately adjacent to it and then replacing one at random. + * @param x The x-coordinate to use. + * @param y The y-coordinate to use. + * @param z The z-coordinate to use. + */ + public void tickBlock(int x, int y, int z) { + List validCoords = new ArrayList(); + + // Go around this block and aggregate valid blocks. + for (int xOffset = -TICK_RANGE; xOffset <= TICK_RANGE; xOffset++) { + for (int zOffset = -TICK_RANGE; zOffset <= TICK_RANGE; zOffset++) { + // Skip the current block + if (xOffset == 0 && zOffset == 0) continue; + + if (isValidSwapPosition(x + xOffset, y, z + zOffset)) + validCoords.add(new ChunkCoordinates(x + xOffset, y, z + zOffset)); + } + } + + // If we can make changes, and have at least 1 block to swap, + // then swap a random block from the valid blocks we could swap. + if (!validCoords.isEmpty() && !world.isRemote) { + ChunkCoordinates toSwap = validCoords.get(rand.nextInt(validCoords.size())); + + world.setBlock(toSwap.posX, toSwap.posY, toSwap.posZ, blockToSet, metaToSet, 1 | 2); + } + } + + /** + * Determines if a given position is a valid location to spread to, which + * means that the block must be either dirt or grass (with meta 0), + * and have a block above it which does not block grass growth. + * @param x The x-coordinate to check. + * @param y The y-coordinate to check. + * @param z The z-coordinate to check. + * @return True if the position is valid to swap, false otherwise. + */ + public boolean isValidSwapPosition(int x, int y, int z) { + Block block = world.getBlock(x, y, z); + int meta = world.getBlockMetadata(x, y, z); + + Block aboveBlock = world.getBlock(x, y + 1, z); + + // Valid blocks to spread to are either dirt or grass, and do not + // have blocks which block grass growth. + + // See http://minecraft.gamepedia.com/Grass_Block + // The major rule is that a block which reduces light + // levels by 2 or more blocks grass growth. + + return (block == Blocks.dirt || block == Blocks.grass) + && (meta == 0) + && (aboveBlock.getLightOpacity(world, x, y, z) <= 1); + } + } + + public IslandType getIslandType(ItemStack stack) { + return ISLAND_TYPES[Math.min(stack.getItemDamage(), ISLAND_TYPES.length - 1)]; + } } diff --git a/src/main/java/vazkii/botania/common/item/ItemKeepIvy.java b/src/main/java/vazkii/botania/common/item/ItemKeepIvy.java index 663dd323a0..b48bbe2fcd 100644 --- a/src/main/java/vazkii/botania/common/item/ItemKeepIvy.java +++ b/src/main/java/vazkii/botania/common/item/ItemKeepIvy.java @@ -2,17 +2,20 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Mar 31, 2015, 9:11:23 PM (GMT)] */ package vazkii.botania.common.item; +import cpw.mods.fml.common.FMLCommonHandler; +import cpw.mods.fml.common.eventhandler.SubscribeEvent; +import cpw.mods.fml.common.gameevent.PlayerEvent.PlayerRespawnEvent; +import cpw.mods.fml.common.registry.GameRegistry; import java.util.ArrayList; import java.util.List; - import net.minecraft.entity.item.EntityItem; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; @@ -24,81 +27,75 @@ import vazkii.botania.common.core.helper.ItemNBTHelper; import vazkii.botania.common.crafting.recipe.KeepIvyRecipe; import vazkii.botania.common.lib.LibItemNames; -import cpw.mods.fml.common.FMLCommonHandler; -import cpw.mods.fml.common.eventhandler.SubscribeEvent; -import cpw.mods.fml.common.gameevent.PlayerEvent.PlayerRespawnEvent; -import cpw.mods.fml.common.registry.GameRegistry; public class ItemKeepIvy extends ItemMod { - public static final String TAG_KEEP = "Botania_keepIvy"; - - private static final String TAG_PLAYER_KEPT_DROPS = "Botania_playerKeptDrops"; - private static final String TAG_DROP_COUNT = "dropCount"; - private static final String TAG_DROP_PREFIX = "dropPrefix"; - - public ItemKeepIvy() { - setUnlocalizedName(LibItemNames.KEEP_IVY); - GameRegistry.addRecipe(new KeepIvyRecipe()); - RecipeSorter.register("botania:keepIvy", KeepIvyRecipe.class, Category.SHAPELESS, ""); - MinecraftForge.EVENT_BUS.register(this); - FMLCommonHandler.instance().bus().register(this); - } - - @SubscribeEvent - public void onPlayerDrops(PlayerDropsEvent event) { - List keeps = new ArrayList(); - for(EntityItem item : event.drops) { - ItemStack stack = item.getEntityItem(); - if(stack != null && ItemNBTHelper.detectNBT(stack) && ItemNBTHelper.getBoolean(stack, TAG_KEEP, false)) - keeps.add(item); - } - - if(keeps.size() > 0) { - event.drops.removeAll(keeps); - - - NBTTagCompound cmp = new NBTTagCompound(); - cmp.setInteger(TAG_DROP_COUNT, keeps.size()); - - int i = 0; - for(EntityItem keep : keeps) { - ItemStack stack = keep.getEntityItem(); - NBTTagCompound cmp1 = new NBTTagCompound(); - stack.writeToNBT(cmp1); - cmp.setTag(TAG_DROP_PREFIX + i, cmp1); - i++; - } - - NBTTagCompound data = event.entityPlayer.getEntityData(); - if(!data.hasKey(EntityPlayer.PERSISTED_NBT_TAG)) - data.setTag(EntityPlayer.PERSISTED_NBT_TAG, new NBTTagCompound()); - - NBTTagCompound persist = data.getCompoundTag(EntityPlayer.PERSISTED_NBT_TAG); - persist.setTag(TAG_PLAYER_KEPT_DROPS, cmp); - } - } - - @SubscribeEvent - public void onPlayerRespawn(PlayerRespawnEvent event) { - NBTTagCompound data = event.player.getEntityData(); - if(data.hasKey(EntityPlayer.PERSISTED_NBT_TAG)) { - NBTTagCompound cmp = data.getCompoundTag(EntityPlayer.PERSISTED_NBT_TAG); - NBTTagCompound cmp1 = cmp.getCompoundTag(TAG_PLAYER_KEPT_DROPS); - - int count = cmp1.getInteger(TAG_DROP_COUNT); - for(int i = 0; i < count; i++) { - NBTTagCompound cmp2 = cmp1.getCompoundTag(TAG_DROP_PREFIX + i); - ItemStack stack = ItemStack.loadItemStackFromNBT(cmp2); - if(stack != null) { - ItemStack copy = stack.copy(); - ItemNBTHelper.setBoolean(copy, TAG_KEEP, false); - event.player.inventory.addItemStackToInventory(copy); - } - } - - cmp.setTag(TAG_PLAYER_KEPT_DROPS, new NBTTagCompound()); - } - } - + public static final String TAG_KEEP = "Botania_keepIvy"; + + private static final String TAG_PLAYER_KEPT_DROPS = "Botania_playerKeptDrops"; + private static final String TAG_DROP_COUNT = "dropCount"; + private static final String TAG_DROP_PREFIX = "dropPrefix"; + + public ItemKeepIvy() { + setUnlocalizedName(LibItemNames.KEEP_IVY); + GameRegistry.addRecipe(new KeepIvyRecipe()); + RecipeSorter.register("botania:keepIvy", KeepIvyRecipe.class, Category.SHAPELESS, ""); + MinecraftForge.EVENT_BUS.register(this); + FMLCommonHandler.instance().bus().register(this); + } + + @SubscribeEvent + public void onPlayerDrops(PlayerDropsEvent event) { + List keeps = new ArrayList(); + for (EntityItem item : event.drops) { + ItemStack stack = item.getEntityItem(); + if (stack != null && ItemNBTHelper.detectNBT(stack) && ItemNBTHelper.getBoolean(stack, TAG_KEEP, false)) + keeps.add(item); + } + + if (keeps.size() > 0) { + event.drops.removeAll(keeps); + + NBTTagCompound cmp = new NBTTagCompound(); + cmp.setInteger(TAG_DROP_COUNT, keeps.size()); + + int i = 0; + for (EntityItem keep : keeps) { + ItemStack stack = keep.getEntityItem(); + NBTTagCompound cmp1 = new NBTTagCompound(); + stack.writeToNBT(cmp1); + cmp.setTag(TAG_DROP_PREFIX + i, cmp1); + i++; + } + + NBTTagCompound data = event.entityPlayer.getEntityData(); + if (!data.hasKey(EntityPlayer.PERSISTED_NBT_TAG)) + data.setTag(EntityPlayer.PERSISTED_NBT_TAG, new NBTTagCompound()); + + NBTTagCompound persist = data.getCompoundTag(EntityPlayer.PERSISTED_NBT_TAG); + persist.setTag(TAG_PLAYER_KEPT_DROPS, cmp); + } + } + + @SubscribeEvent + public void onPlayerRespawn(PlayerRespawnEvent event) { + NBTTagCompound data = event.player.getEntityData(); + if (data.hasKey(EntityPlayer.PERSISTED_NBT_TAG)) { + NBTTagCompound cmp = data.getCompoundTag(EntityPlayer.PERSISTED_NBT_TAG); + NBTTagCompound cmp1 = cmp.getCompoundTag(TAG_PLAYER_KEPT_DROPS); + + int count = cmp1.getInteger(TAG_DROP_COUNT); + for (int i = 0; i < count; i++) { + NBTTagCompound cmp2 = cmp1.getCompoundTag(TAG_DROP_PREFIX + i); + ItemStack stack = ItemStack.loadItemStackFromNBT(cmp2); + if (stack != null) { + ItemStack copy = stack.copy(); + ItemNBTHelper.setBoolean(copy, TAG_KEEP, false); + event.player.inventory.addItemStackToInventory(copy); + } + } + + cmp.setTag(TAG_PLAYER_KEPT_DROPS, new NBTTagCompound()); + } + } } diff --git a/src/main/java/vazkii/botania/common/item/ItemLaputaShard.java b/src/main/java/vazkii/botania/common/item/ItemLaputaShard.java index fa7504baf2..0b11999fc8 100644 --- a/src/main/java/vazkii/botania/common/item/ItemLaputaShard.java +++ b/src/main/java/vazkii/botania/common/item/ItemLaputaShard.java @@ -2,16 +2,15 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jul 19, 2014, 10:46:14 PM (GMT)] */ package vazkii.botania.common.item; import java.util.List; - import net.minecraft.block.Block; import net.minecraft.block.BlockFalling; import net.minecraft.creativetab.CreativeTabs; @@ -37,233 +36,258 @@ public class ItemLaputaShard extends ItemMod implements ILensEffect, ITinyPlanetExcempt { - private static final String TAG_BLOCK = "_block"; - private static final String TAG_META = "_meta"; - private static final String TAG_TILE = "_tile"; - private static final String TAG_X = "_x"; - private static final String TAG_Y = "_y"; - private static final String TAG_Y_START = "_yStart"; - private static final String TAG_Z = "_z"; - private static final String TAG_POINTY = "_pointy"; - private static final String TAG_HEIGHTSCALE = "_heightscale"; - private static final String TAG_ITERATION_I = "iterationI"; - private static final String TAG_ITERATION_J = "iterationJ"; - private static final String TAG_ITERATION_K = "iterationK"; - - private static final int BASE_RANGE = 14; - private static final int BASE_OFFSET = 42; - - public ItemLaputaShard() { - setUnlocalizedName(LibItemNames.LAPUTA_SHARD); - setHasSubtypes(true); - } - - @Override - public void getSubItems(Item item, CreativeTabs tab, List list) { - super.getSubItems(item, tab, list); - for(int i = 0; i < 4; i++) - list.add(new ItemStack(item, 1, (i + 1) * 5 - 1)); - } - - @Override - public void addInformation(ItemStack stack, EntityPlayer player, List list, boolean adv) { - list.add(String.format(StatCollector.translateToLocal("botaniamisc.shardLevel"), StatCollector.translateToLocal("botania.roman" + (stack.getItemDamage() + 1)))); - } - - @Override - public boolean onItemUse(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, World par3World, int par4, int par5, int par6, int par7, float par8, float par9, float par10) { - if(par5 < 160 && !par3World.provider.isHellWorld) { - par3World.playSound(par4 + 0.5D, par5 + 0.5D, par6 + 0.5D, "botania:laputaStart", 1.0F + par3World.rand.nextFloat(), par3World.rand.nextFloat() * 0.7F + 1.3F, false); - spawnBurstFirst(par3World, par4, par5, par6, par1ItemStack); - par1ItemStack.stackSize--; - if(par1ItemStack.getItemDamage() == 19) - par2EntityPlayer.addStat(ModAchievements.l20ShardUse, 1); - } - - return true; - } - - public void spawnBurstFirst(World world, int srcx, int srcy, int srcz, ItemStack lens) { - int range = BASE_RANGE + lens.getItemDamage(); - boolean pointy = world.rand.nextDouble() < 0.25; - double heightscale = (world.rand.nextDouble() + 0.5) * ((double)BASE_RANGE / (double)range); - spawnBurst(world, srcx, srcy, srcz, lens, pointy, heightscale); - } - - public void spawnBurst(World world, int srcx, int srcy, int srcz, ItemStack lens) { - boolean pointy = ItemNBTHelper.getBoolean(lens, TAG_POINTY, false); - double heightscale = ItemNBTHelper.getDouble(lens, TAG_HEIGHTSCALE, 1); - - spawnBurst(world, srcx, srcy, srcz, lens, pointy, heightscale); - } - - public void spawnBurst(World world, int srcx, int srcy, int srcz, ItemStack lens, boolean pointy, double heightscale) { - int range = BASE_RANGE + lens.getItemDamage(); - - int i = ItemNBTHelper.getInt(lens, TAG_ITERATION_I, 0); - int j = ItemNBTHelper.getInt(lens, TAG_ITERATION_J, BASE_OFFSET - BASE_RANGE / 2); - int k = ItemNBTHelper.getInt(lens, TAG_ITERATION_K, 0); - - if(j <= -BASE_RANGE * 2) - j = BASE_OFFSET - BASE_RANGE / 2; - if(k >= range * 2 + 1) - k = 0; - - if(!world.isRemote) { - for(; i < range * 2 + 1; i++) { - for(; j > -BASE_RANGE * 2; j--) { - for(; k < range * 2 + 1; k++) { - int x = srcx - range + i; - int y = srcy - BASE_RANGE + j; - int z = srcz - range + k; - - if(inRange(x, y, z, srcx, srcy, srcz, range, heightscale, pointy)) { - Block block = world.getBlock(x, y, z); - if(!block.isAir(world, x, y, z) && !block.isReplaceable(world, x, y, z) && !(block instanceof BlockFalling) && (!(block instanceof ILaputaImmobile) || ((ILaputaImmobile) block).canMove(world, x, y, z)) && block.getBlockHardness(world, x, y, z) != -1) { - int id = Block.getIdFromBlock(block); - int meta = world.getBlockMetadata(x, y, z); - TileEntity tile = world.getTileEntity(x, y, z); - - if(tile != null) { - TileEntity newTile = block.createTileEntity(world, meta); - world.setTileEntity(x, y, z, newTile); - } - world.setBlockToAir(x, y, z); - world.playAuxSFX(2001, x, y, z, id + (meta << 12)); - - ItemStack copyLens = new ItemStack(this, 1, lens.getItemDamage()); - ItemNBTHelper.setInt(copyLens, TAG_BLOCK, id); - ItemNBTHelper.setInt(copyLens, TAG_META, meta); - NBTTagCompound cmp = new NBTTagCompound(); - if(tile != null) - tile.writeToNBT(cmp); - ItemNBTHelper.setCompound(copyLens, TAG_TILE, cmp); - ItemNBTHelper.setInt(copyLens, TAG_X, srcx); - ItemNBTHelper.setInt(copyLens, TAG_Y, srcy); - ItemNBTHelper.setInt(copyLens, TAG_Y_START, y); - ItemNBTHelper.setInt(copyLens, TAG_Z, srcz); - ItemNBTHelper.setBoolean(copyLens, TAG_POINTY, pointy); - ItemNBTHelper.setDouble(copyLens, TAG_HEIGHTSCALE, heightscale); - ItemNBTHelper.setInt(copyLens, TAG_ITERATION_I, i); - ItemNBTHelper.setInt(copyLens, TAG_ITERATION_J, j); - ItemNBTHelper.setInt(copyLens, TAG_ITERATION_K, k); - - EntityManaBurst burst = getBurst(world, x, y, z, copyLens); - world.spawnEntityInWorld(burst); - return; - } - } - } - k = 0; - } - j = BASE_OFFSET - BASE_RANGE / 2; - } - } - } - - private boolean inRange(int x, int y, int z, int srcx, int srcy, int srcz, int range, double heightscale, boolean pointy) { - if(y >= srcy) - return MathHelper.pointDistanceSpace(x, 0, z, srcx, 0, srcz) < range; - else if(!pointy) - return MathHelper.pointDistanceSpace(x, y / heightscale, z, srcx, srcy / heightscale, srcz) < range; - else return MathHelper.pointDistanceSpace(x, 0, z, srcx, 0, srcz) < range - (srcy - y) / heightscale; - } - - public EntityManaBurst getBurst(World world, int x, int y, int z, ItemStack stack) { - EntityManaBurst burst = new EntityManaBurst(world); - burst.posX = x + 0.5; - burst.posY = y + 0.5; - burst.posZ = z + 0.5; - - burst.setColor(0x00EAFF); - burst.setMana(1); - burst.setStartingMana(1); - burst.setMinManaLoss(0); - burst.setManaLossPerTick(0F); - burst.setGravity(0F); - burst.setMotion(0, 0.5, 0); - - burst.setSourceLens(stack); - return burst; - } - - @Override - public void apply(ItemStack stack, BurstProperties props) { - // NO-OP - } - - @Override - public boolean collideBurst(IManaBurst burst, MovingObjectPosition pos, boolean isManaBlock, boolean dead, ItemStack stack) { - return false; - } - - @Override - public void updateBurst(IManaBurst burst, ItemStack stack) { - double speed = 0.35; - int targetDistance = BASE_OFFSET; - EntityThrowable entity = (EntityThrowable) burst; - if(!entity.worldObj.isRemote) { - entity.motionX = 0; - entity.motionY = speed; - entity.motionZ = 0; - - final int spawnTicks = 2; - final int placeTicks = net.minecraft.util.MathHelper.floor_double(targetDistance / speed); - - ItemStack lens = burst.getSourceLens(); - - if(burst.getTicksExisted() == spawnTicks) { - int x = ItemNBTHelper.getInt(lens, TAG_X, 0); - int y = ItemNBTHelper.getInt(lens, TAG_Y, -1); - int z = ItemNBTHelper.getInt(lens, TAG_Z, 0); - - if(y != -1) - spawnBurst(entity.worldObj, x, y, z, lens); - } else if(burst.getTicksExisted() == placeTicks) { - int x = net.minecraft.util.MathHelper.floor_double(entity.posX); - int y = ItemNBTHelper.getInt(lens, TAG_Y_START, -1) + targetDistance; - int z = net.minecraft.util.MathHelper.floor_double(entity.posZ); - - if(entity.worldObj.isAirBlock(x, y, z)) { - int id = ItemNBTHelper.getInt(lens, TAG_BLOCK, 0); - Block block = Block.getBlockById(id); - int meta = ItemNBTHelper.getInt(lens, TAG_META, 0); - - TileEntity tile = null; - NBTTagCompound tilecmp = ItemNBTHelper.getCompound(lens, TAG_TILE, false); - if(tilecmp.hasKey("id")) - tile = TileEntity.createAndLoadEntity(tilecmp); - - entity.worldObj.setBlock(x, y, z, block, meta, 1 | 2); - entity.worldObj.playAuxSFX(2001, x, y, z, id + (meta << 12)); - if(tile != null) { - tile.xCoord = x; - tile.yCoord = y; - tile.zCoord = z; - entity.worldObj.setTileEntity(x, y, z, tile); - } - } - - entity.setDead(); - } - } - } - - @Override - public boolean doParticles(IManaBurst burst, ItemStack stack) { - EntityThrowable entity = (EntityThrowable) burst; - ItemStack lens = burst.getSourceLens(); - int id = ItemNBTHelper.getInt(lens, TAG_BLOCK, 0); - Block.getBlockById(id); - int meta = ItemNBTHelper.getInt(lens, TAG_META, 0); - entity.worldObj.spawnParticle("blockcrack_" + id + "_" + meta, entity.posX, entity.posY, entity.posZ, entity.motionX, entity.motionY, entity.motionZ); - - return true; - } - - @Override - public boolean shouldPull(ItemStack stack) { - return false; - } - + private static final String TAG_BLOCK = "_block"; + private static final String TAG_META = "_meta"; + private static final String TAG_TILE = "_tile"; + private static final String TAG_X = "_x"; + private static final String TAG_Y = "_y"; + private static final String TAG_Y_START = "_yStart"; + private static final String TAG_Z = "_z"; + private static final String TAG_POINTY = "_pointy"; + private static final String TAG_HEIGHTSCALE = "_heightscale"; + private static final String TAG_ITERATION_I = "iterationI"; + private static final String TAG_ITERATION_J = "iterationJ"; + private static final String TAG_ITERATION_K = "iterationK"; + + private static final int BASE_RANGE = 14; + private static final int BASE_OFFSET = 42; + + public ItemLaputaShard() { + setUnlocalizedName(LibItemNames.LAPUTA_SHARD); + setHasSubtypes(true); + } + + @Override + public void getSubItems(Item item, CreativeTabs tab, List list) { + super.getSubItems(item, tab, list); + for (int i = 0; i < 4; i++) list.add(new ItemStack(item, 1, (i + 1) * 5 - 1)); + } + + @Override + public void addInformation(ItemStack stack, EntityPlayer player, List list, boolean adv) { + list.add(String.format( + StatCollector.translateToLocal("botaniamisc.shardLevel"), + StatCollector.translateToLocal("botania.roman" + (stack.getItemDamage() + 1)))); + } + + @Override + public boolean onItemUse( + ItemStack par1ItemStack, + EntityPlayer par2EntityPlayer, + World par3World, + int par4, + int par5, + int par6, + int par7, + float par8, + float par9, + float par10) { + if (par5 < 160 && !par3World.provider.isHellWorld) { + par3World.playSound( + par4 + 0.5D, + par5 + 0.5D, + par6 + 0.5D, + "botania:laputaStart", + 1.0F + par3World.rand.nextFloat(), + par3World.rand.nextFloat() * 0.7F + 1.3F, + false); + spawnBurstFirst(par3World, par4, par5, par6, par1ItemStack); + par1ItemStack.stackSize--; + if (par1ItemStack.getItemDamage() == 19) par2EntityPlayer.addStat(ModAchievements.l20ShardUse, 1); + } + + return true; + } + + public void spawnBurstFirst(World world, int srcx, int srcy, int srcz, ItemStack lens) { + int range = BASE_RANGE + lens.getItemDamage(); + boolean pointy = world.rand.nextDouble() < 0.25; + double heightscale = (world.rand.nextDouble() + 0.5) * ((double) BASE_RANGE / (double) range); + spawnBurst(world, srcx, srcy, srcz, lens, pointy, heightscale); + } + + public void spawnBurst(World world, int srcx, int srcy, int srcz, ItemStack lens) { + boolean pointy = ItemNBTHelper.getBoolean(lens, TAG_POINTY, false); + double heightscale = ItemNBTHelper.getDouble(lens, TAG_HEIGHTSCALE, 1); + + spawnBurst(world, srcx, srcy, srcz, lens, pointy, heightscale); + } + + public void spawnBurst( + World world, int srcx, int srcy, int srcz, ItemStack lens, boolean pointy, double heightscale) { + int range = BASE_RANGE + lens.getItemDamage(); + + int i = ItemNBTHelper.getInt(lens, TAG_ITERATION_I, 0); + int j = ItemNBTHelper.getInt(lens, TAG_ITERATION_J, BASE_OFFSET - BASE_RANGE / 2); + int k = ItemNBTHelper.getInt(lens, TAG_ITERATION_K, 0); + + if (j <= -BASE_RANGE * 2) j = BASE_OFFSET - BASE_RANGE / 2; + if (k >= range * 2 + 1) k = 0; + + if (!world.isRemote) { + for (; i < range * 2 + 1; i++) { + for (; j > -BASE_RANGE * 2; j--) { + for (; k < range * 2 + 1; k++) { + int x = srcx - range + i; + int y = srcy - BASE_RANGE + j; + int z = srcz - range + k; + + if (inRange(x, y, z, srcx, srcy, srcz, range, heightscale, pointy)) { + Block block = world.getBlock(x, y, z); + if (!block.isAir(world, x, y, z) + && !block.isReplaceable(world, x, y, z) + && !(block instanceof BlockFalling) + && (!(block instanceof ILaputaImmobile) + || ((ILaputaImmobile) block).canMove(world, x, y, z)) + && block.getBlockHardness(world, x, y, z) != -1) { + int id = Block.getIdFromBlock(block); + int meta = world.getBlockMetadata(x, y, z); + TileEntity tile = world.getTileEntity(x, y, z); + + if (tile != null) { + TileEntity newTile = block.createTileEntity(world, meta); + world.setTileEntity(x, y, z, newTile); + } + world.setBlockToAir(x, y, z); + world.playAuxSFX(2001, x, y, z, id + (meta << 12)); + + ItemStack copyLens = new ItemStack(this, 1, lens.getItemDamage()); + ItemNBTHelper.setInt(copyLens, TAG_BLOCK, id); + ItemNBTHelper.setInt(copyLens, TAG_META, meta); + NBTTagCompound cmp = new NBTTagCompound(); + if (tile != null) tile.writeToNBT(cmp); + ItemNBTHelper.setCompound(copyLens, TAG_TILE, cmp); + ItemNBTHelper.setInt(copyLens, TAG_X, srcx); + ItemNBTHelper.setInt(copyLens, TAG_Y, srcy); + ItemNBTHelper.setInt(copyLens, TAG_Y_START, y); + ItemNBTHelper.setInt(copyLens, TAG_Z, srcz); + ItemNBTHelper.setBoolean(copyLens, TAG_POINTY, pointy); + ItemNBTHelper.setDouble(copyLens, TAG_HEIGHTSCALE, heightscale); + ItemNBTHelper.setInt(copyLens, TAG_ITERATION_I, i); + ItemNBTHelper.setInt(copyLens, TAG_ITERATION_J, j); + ItemNBTHelper.setInt(copyLens, TAG_ITERATION_K, k); + + EntityManaBurst burst = getBurst(world, x, y, z, copyLens); + world.spawnEntityInWorld(burst); + return; + } + } + } + k = 0; + } + j = BASE_OFFSET - BASE_RANGE / 2; + } + } + } + + private boolean inRange( + int x, int y, int z, int srcx, int srcy, int srcz, int range, double heightscale, boolean pointy) { + if (y >= srcy) return MathHelper.pointDistanceSpace(x, 0, z, srcx, 0, srcz) < range; + else if (!pointy) + return MathHelper.pointDistanceSpace(x, y / heightscale, z, srcx, srcy / heightscale, srcz) < range; + else return MathHelper.pointDistanceSpace(x, 0, z, srcx, 0, srcz) < range - (srcy - y) / heightscale; + } + + public EntityManaBurst getBurst(World world, int x, int y, int z, ItemStack stack) { + EntityManaBurst burst = new EntityManaBurst(world); + burst.posX = x + 0.5; + burst.posY = y + 0.5; + burst.posZ = z + 0.5; + + burst.setColor(0x00EAFF); + burst.setMana(1); + burst.setStartingMana(1); + burst.setMinManaLoss(0); + burst.setManaLossPerTick(0F); + burst.setGravity(0F); + burst.setMotion(0, 0.5, 0); + + burst.setSourceLens(stack); + return burst; + } + + @Override + public void apply(ItemStack stack, BurstProperties props) { + // NO-OP + } + + @Override + public boolean collideBurst( + IManaBurst burst, MovingObjectPosition pos, boolean isManaBlock, boolean dead, ItemStack stack) { + return false; + } + + @Override + public void updateBurst(IManaBurst burst, ItemStack stack) { + double speed = 0.35; + int targetDistance = BASE_OFFSET; + EntityThrowable entity = (EntityThrowable) burst; + if (!entity.worldObj.isRemote) { + entity.motionX = 0; + entity.motionY = speed; + entity.motionZ = 0; + + final int spawnTicks = 2; + final int placeTicks = net.minecraft.util.MathHelper.floor_double(targetDistance / speed); + + ItemStack lens = burst.getSourceLens(); + + if (burst.getTicksExisted() == spawnTicks) { + int x = ItemNBTHelper.getInt(lens, TAG_X, 0); + int y = ItemNBTHelper.getInt(lens, TAG_Y, -1); + int z = ItemNBTHelper.getInt(lens, TAG_Z, 0); + + if (y != -1) spawnBurst(entity.worldObj, x, y, z, lens); + } else if (burst.getTicksExisted() == placeTicks) { + int x = net.minecraft.util.MathHelper.floor_double(entity.posX); + int y = ItemNBTHelper.getInt(lens, TAG_Y_START, -1) + targetDistance; + int z = net.minecraft.util.MathHelper.floor_double(entity.posZ); + + if (entity.worldObj.isAirBlock(x, y, z)) { + int id = ItemNBTHelper.getInt(lens, TAG_BLOCK, 0); + Block block = Block.getBlockById(id); + int meta = ItemNBTHelper.getInt(lens, TAG_META, 0); + + TileEntity tile = null; + NBTTagCompound tilecmp = ItemNBTHelper.getCompound(lens, TAG_TILE, false); + if (tilecmp.hasKey("id")) tile = TileEntity.createAndLoadEntity(tilecmp); + + entity.worldObj.setBlock(x, y, z, block, meta, 1 | 2); + entity.worldObj.playAuxSFX(2001, x, y, z, id + (meta << 12)); + if (tile != null) { + tile.xCoord = x; + tile.yCoord = y; + tile.zCoord = z; + entity.worldObj.setTileEntity(x, y, z, tile); + } + } + + entity.setDead(); + } + } + } + + @Override + public boolean doParticles(IManaBurst burst, ItemStack stack) { + EntityThrowable entity = (EntityThrowable) burst; + ItemStack lens = burst.getSourceLens(); + int id = ItemNBTHelper.getInt(lens, TAG_BLOCK, 0); + Block.getBlockById(id); + int meta = ItemNBTHelper.getInt(lens, TAG_META, 0); + entity.worldObj.spawnParticle( + "blockcrack_" + id + "_" + meta, + entity.posX, + entity.posY, + entity.posZ, + entity.motionX, + entity.motionY, + entity.motionZ); + + return true; + } + + @Override + public boolean shouldPull(ItemStack stack) { + return false; + } } diff --git a/src/main/java/vazkii/botania/common/item/ItemLexicon.java b/src/main/java/vazkii/botania/common/item/ItemLexicon.java index a2a442868c..f8245e6d88 100644 --- a/src/main/java/vazkii/botania/common/item/ItemLexicon.java +++ b/src/main/java/vazkii/botania/common/item/ItemLexicon.java @@ -12,7 +12,6 @@ import java.util.ArrayList; import java.util.List; - import net.minecraft.block.Block; import net.minecraft.client.gui.GuiScreen; import net.minecraft.creativetab.CreativeTabs; @@ -37,187 +36,197 @@ import vazkii.botania.common.Botania; import vazkii.botania.common.achievement.ModAchievements; import vazkii.botania.common.core.helper.ItemNBTHelper; -import vazkii.botania.common.core.helper.MathHelper; import vazkii.botania.common.item.relic.ItemDice; import vazkii.botania.common.lib.LibGuiIDs; import vazkii.botania.common.lib.LibItemNames; -import vazkii.botania.common.lib.LibMisc; public class ItemLexicon extends ItemMod implements ILexicon, IElvenItem { - private static final String TAG_KNOWLEDGE_PREFIX = "knowledge."; - private static final String TAG_FORCED_MESSAGE = "forcedMessage"; - private static final String TAG_QUEUE_TICKS = "queueTicks"; - boolean skipSound = false; - - public ItemLexicon() { - super(); - setMaxStackSize(1); - setUnlocalizedName(LibItemNames.LEXICON); - } - - @Override - public boolean onItemUse(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, World par3World, int par4, int par5, int par6, int par7, float par8, float par9, float par10) { - if(par2EntityPlayer.isSneaking()) { - Block block = par3World.getBlock(par4, par5, par6); - - if(block != null) { - if(block instanceof ILexiconable) { - LexiconEntry entry = ((ILexiconable) block).getEntry(par3World, par4, par5, par6, par2EntityPlayer, par1ItemStack); - if(entry != null && isKnowledgeUnlocked(par1ItemStack, entry.getKnowledgeType())) { - Botania.proxy.setEntryToOpen(entry); - Botania.proxy.setLexiconStack(par1ItemStack); - - openBook(par2EntityPlayer, par1ItemStack, par3World, false); - return true; - } - } else if(par3World.isRemote) { - MovingObjectPosition pos = new MovingObjectPosition(par4, par5, par6, par7, Vec3.createVectorHelper(par8, par9, par10)); - return Botania.proxy.openWikiPage(par3World, block, pos); - } - } - } - - return false; - } - - @Override - public void getSubItems(Item item, CreativeTabs tab, List list) { - list.add(new ItemStack(item)); - ItemStack creative = new ItemStack(item); - for(String s : BotaniaAPI.knowledgeTypes.keySet()) { - KnowledgeType type = BotaniaAPI.knowledgeTypes.get(s); - unlockKnowledge(creative, type); - } - list.add(creative); - } - - @Override - public void addInformation(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, List par3List, boolean par4) { - if(GuiScreen.isShiftKeyDown()) { - String edition = EnumChatFormatting.GOLD + String.format(StatCollector.translateToLocal("botaniamisc.edition"), getEdition()); - if(!edition.isEmpty()) - par3List.add(edition); - - List typesKnown = new ArrayList(); - for(String s : BotaniaAPI.knowledgeTypes.keySet()) { - KnowledgeType type = BotaniaAPI.knowledgeTypes.get(s); - if(isKnowledgeUnlocked(par1ItemStack, type)) - typesKnown.add(type); - } - - String format = typesKnown.size() == 1 ? "botaniamisc.knowledgeTypesSingular" : "botaniamisc.knowledgeTypesPlural"; - addStringToTooltip(String.format(StatCollector.translateToLocal(format), typesKnown.size()), par3List); - - for(KnowledgeType type : typesKnown) - addStringToTooltip(" \u2022 " + StatCollector.translateToLocal(type.getUnlocalizedName()), par3List); - - } else addStringToTooltip(StatCollector.translateToLocal("botaniamisc.shiftinfo"), par3List); - } - - private void addStringToTooltip(String s, List tooltip) { - tooltip.add(s.replaceAll("&", "\u00a7")); - } - - public static String getEdition() { - return "GTNH"; - } - - @Override - public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer) { - String force = getForcedPage(par1ItemStack); - if(force != null && !force.isEmpty()) { - LexiconEntry entry = getEntryFromForce(par1ItemStack); - if(entry != null) - Botania.proxy.setEntryToOpen(entry); - else par3EntityPlayer.addChatMessage(new ChatComponentTranslation("botaniamisc.cantOpen").setChatStyle(new ChatStyle().setColor(EnumChatFormatting.RED))); - setForcedPage(par1ItemStack, ""); - } - - openBook(par3EntityPlayer, par1ItemStack, par2World, skipSound); - skipSound = false; - - return par1ItemStack; - } - - public static void openBook(EntityPlayer player, ItemStack stack, World world, boolean skipSound) { - ILexicon l = (ILexicon) stack.getItem(); - - Botania.proxy.setToTutorialIfFirstLaunch(); - - if(!l.isKnowledgeUnlocked(stack, BotaniaAPI.relicKnowledge) && l.isKnowledgeUnlocked(stack, BotaniaAPI.elvenKnowledge)) - for(ItemStack rstack : ItemDice.relicStacks) { - Item item = rstack.getItem(); - if(player.inventory.hasItem(item)) { - l.unlockKnowledge(stack, BotaniaAPI.relicKnowledge); - break; - } - } - - Botania.proxy.setLexiconStack(stack); - player.addStat(ModAchievements.lexiconUse, 1); - player.openGui(Botania.instance, LibGuiIDs.LEXICON, world, 0, 0, 0); - if(!world.isRemote && !skipSound) - world.playSoundAtEntity(player, "botania:lexiconOpen", 0.5F, 1F); - } - - @Override - public void onUpdate(ItemStack stack, World world, Entity entity, int idk, boolean something) { - int ticks = getQueueTicks(stack); - if(ticks > 0 && entity instanceof EntityPlayer) { - skipSound = ticks < 5; - if(ticks == 1) - onItemRightClick(stack, world, (EntityPlayer) entity); - - setQueueTicks(stack, ticks - 1); - } - } - - @Override - public EnumRarity getRarity(ItemStack par1ItemStack) { - return EnumRarity.uncommon; - } - - @Override - public boolean isKnowledgeUnlocked(ItemStack stack, KnowledgeType knowledge) { - return knowledge.autoUnlock || ItemNBTHelper.getBoolean(stack, TAG_KNOWLEDGE_PREFIX + knowledge.id, false); - } - - @Override - public void unlockKnowledge(ItemStack stack, KnowledgeType knowledge) { - ItemNBTHelper.setBoolean(stack, TAG_KNOWLEDGE_PREFIX + knowledge.id, true); - } - - public static void setForcedPage(ItemStack stack, String forced) { - ItemNBTHelper.setString(stack, TAG_FORCED_MESSAGE, forced); - } - - public static String getForcedPage(ItemStack stack) { - return ItemNBTHelper.getString(stack, TAG_FORCED_MESSAGE, ""); - } - - private static LexiconEntry getEntryFromForce(ItemStack stack) { - String force = getForcedPage(stack); - - for(LexiconEntry entry : BotaniaAPI.getAllEntries()) - if(entry.getUnlocalizedName().equals(force)) - if(entry != null && ((ItemLexicon) stack.getItem()).isKnowledgeUnlocked(stack, entry.getKnowledgeType())) - return entry; - - return null; - } - - public static int getQueueTicks(ItemStack stack) { - return ItemNBTHelper.getInt(stack, TAG_QUEUE_TICKS, 0); - } - - public static void setQueueTicks(ItemStack stack, int ticks) { - ItemNBTHelper.setInt(stack, TAG_QUEUE_TICKS, ticks); - } - - @Override - public boolean isElvenItem(ItemStack stack) { - return isKnowledgeUnlocked(stack, BotaniaAPI.elvenKnowledge); - } - + private static final String TAG_KNOWLEDGE_PREFIX = "knowledge."; + private static final String TAG_FORCED_MESSAGE = "forcedMessage"; + private static final String TAG_QUEUE_TICKS = "queueTicks"; + boolean skipSound = false; + + public ItemLexicon() { + super(); + setMaxStackSize(1); + setUnlocalizedName(LibItemNames.LEXICON); + } + + @Override + public boolean onItemUse( + ItemStack par1ItemStack, + EntityPlayer par2EntityPlayer, + World par3World, + int par4, + int par5, + int par6, + int par7, + float par8, + float par9, + float par10) { + if (par2EntityPlayer.isSneaking()) { + Block block = par3World.getBlock(par4, par5, par6); + + if (block != null) { + if (block instanceof ILexiconable) { + LexiconEntry entry = ((ILexiconable) block) + .getEntry(par3World, par4, par5, par6, par2EntityPlayer, par1ItemStack); + if (entry != null && isKnowledgeUnlocked(par1ItemStack, entry.getKnowledgeType())) { + Botania.proxy.setEntryToOpen(entry); + Botania.proxy.setLexiconStack(par1ItemStack); + + openBook(par2EntityPlayer, par1ItemStack, par3World, false); + return true; + } + } else if (par3World.isRemote) { + MovingObjectPosition pos = new MovingObjectPosition( + par4, par5, par6, par7, Vec3.createVectorHelper(par8, par9, par10)); + return Botania.proxy.openWikiPage(par3World, block, pos); + } + } + } + + return false; + } + + @Override + public void getSubItems(Item item, CreativeTabs tab, List list) { + list.add(new ItemStack(item)); + ItemStack creative = new ItemStack(item); + for (String s : BotaniaAPI.knowledgeTypes.keySet()) { + KnowledgeType type = BotaniaAPI.knowledgeTypes.get(s); + unlockKnowledge(creative, type); + } + list.add(creative); + } + + @Override + public void addInformation(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, List par3List, boolean par4) { + if (GuiScreen.isShiftKeyDown()) { + String edition = EnumChatFormatting.GOLD + + String.format(StatCollector.translateToLocal("botaniamisc.edition"), getEdition()); + if (!edition.isEmpty()) par3List.add(edition); + + List typesKnown = new ArrayList(); + for (String s : BotaniaAPI.knowledgeTypes.keySet()) { + KnowledgeType type = BotaniaAPI.knowledgeTypes.get(s); + if (isKnowledgeUnlocked(par1ItemStack, type)) typesKnown.add(type); + } + + String format = + typesKnown.size() == 1 ? "botaniamisc.knowledgeTypesSingular" : "botaniamisc.knowledgeTypesPlural"; + addStringToTooltip(String.format(StatCollector.translateToLocal(format), typesKnown.size()), par3List); + + for (KnowledgeType type : typesKnown) + addStringToTooltip(" \u2022 " + StatCollector.translateToLocal(type.getUnlocalizedName()), par3List); + + } else addStringToTooltip(StatCollector.translateToLocal("botaniamisc.shiftinfo"), par3List); + } + + private void addStringToTooltip(String s, List tooltip) { + tooltip.add(s.replaceAll("&", "\u00a7")); + } + + public static String getEdition() { + return "GTNH"; + } + + @Override + public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer) { + String force = getForcedPage(par1ItemStack); + if (force != null && !force.isEmpty()) { + LexiconEntry entry = getEntryFromForce(par1ItemStack); + if (entry != null) Botania.proxy.setEntryToOpen(entry); + else + par3EntityPlayer.addChatMessage(new ChatComponentTranslation("botaniamisc.cantOpen") + .setChatStyle(new ChatStyle().setColor(EnumChatFormatting.RED))); + setForcedPage(par1ItemStack, ""); + } + + openBook(par3EntityPlayer, par1ItemStack, par2World, skipSound); + skipSound = false; + + return par1ItemStack; + } + + public static void openBook(EntityPlayer player, ItemStack stack, World world, boolean skipSound) { + ILexicon l = (ILexicon) stack.getItem(); + + Botania.proxy.setToTutorialIfFirstLaunch(); + + if (!l.isKnowledgeUnlocked(stack, BotaniaAPI.relicKnowledge) + && l.isKnowledgeUnlocked(stack, BotaniaAPI.elvenKnowledge)) + for (ItemStack rstack : ItemDice.relicStacks) { + Item item = rstack.getItem(); + if (player.inventory.hasItem(item)) { + l.unlockKnowledge(stack, BotaniaAPI.relicKnowledge); + break; + } + } + + Botania.proxy.setLexiconStack(stack); + player.addStat(ModAchievements.lexiconUse, 1); + player.openGui(Botania.instance, LibGuiIDs.LEXICON, world, 0, 0, 0); + if (!world.isRemote && !skipSound) world.playSoundAtEntity(player, "botania:lexiconOpen", 0.5F, 1F); + } + + @Override + public void onUpdate(ItemStack stack, World world, Entity entity, int idk, boolean something) { + int ticks = getQueueTicks(stack); + if (ticks > 0 && entity instanceof EntityPlayer) { + skipSound = ticks < 5; + if (ticks == 1) onItemRightClick(stack, world, (EntityPlayer) entity); + + setQueueTicks(stack, ticks - 1); + } + } + + @Override + public EnumRarity getRarity(ItemStack par1ItemStack) { + return EnumRarity.uncommon; + } + + @Override + public boolean isKnowledgeUnlocked(ItemStack stack, KnowledgeType knowledge) { + return knowledge.autoUnlock || ItemNBTHelper.getBoolean(stack, TAG_KNOWLEDGE_PREFIX + knowledge.id, false); + } + + @Override + public void unlockKnowledge(ItemStack stack, KnowledgeType knowledge) { + ItemNBTHelper.setBoolean(stack, TAG_KNOWLEDGE_PREFIX + knowledge.id, true); + } + + public static void setForcedPage(ItemStack stack, String forced) { + ItemNBTHelper.setString(stack, TAG_FORCED_MESSAGE, forced); + } + + public static String getForcedPage(ItemStack stack) { + return ItemNBTHelper.getString(stack, TAG_FORCED_MESSAGE, ""); + } + + private static LexiconEntry getEntryFromForce(ItemStack stack) { + String force = getForcedPage(stack); + + for (LexiconEntry entry : BotaniaAPI.getAllEntries()) + if (entry.getUnlocalizedName().equals(force)) + if (entry != null + && ((ItemLexicon) stack.getItem()).isKnowledgeUnlocked(stack, entry.getKnowledgeType())) + return entry; + + return null; + } + + public static int getQueueTicks(ItemStack stack) { + return ItemNBTHelper.getInt(stack, TAG_QUEUE_TICKS, 0); + } + + public static void setQueueTicks(ItemStack stack, int ticks) { + ItemNBTHelper.setInt(stack, TAG_QUEUE_TICKS, ticks); + } + + @Override + public boolean isElvenItem(ItemStack stack) { + return isKnowledgeUnlocked(stack, BotaniaAPI.elvenKnowledge); + } } diff --git a/src/main/java/vazkii/botania/common/item/ItemManaCookie.java b/src/main/java/vazkii/botania/common/item/ItemManaCookie.java index 04aa146209..21d3c155d1 100644 --- a/src/main/java/vazkii/botania/common/item/ItemManaCookie.java +++ b/src/main/java/vazkii/botania/common/item/ItemManaCookie.java @@ -2,14 +2,17 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Mar 21, 2014, 8:44:35 PM (GMT)] */ package vazkii.botania.common.item; +import cpw.mods.fml.common.registry.GameRegistry; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.Item; @@ -23,53 +26,52 @@ import vazkii.botania.common.achievement.ModAchievements; import vazkii.botania.common.core.BotaniaCreativeTab; import vazkii.botania.common.lib.LibItemNames; -import cpw.mods.fml.common.registry.GameRegistry; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; public class ItemManaCookie extends ItemFood { - private IIcon totalBiscuitIcon; - - public ItemManaCookie() { - super(0, 0.1F, false); - setPotionEffect(Potion.field_76443_y.id, 1, 0, 1F); - setCreativeTab(BotaniaCreativeTab.INSTANCE); - setUnlocalizedName(LibItemNames.MANA_COOKIE); - } + private IIcon totalBiscuitIcon; - @Override - protected void onFoodEaten(ItemStack p_77849_1_, World p_77849_2_, EntityPlayer p_77849_3_) { - super.onFoodEaten(p_77849_1_, p_77849_2_, p_77849_3_); - p_77849_3_.addStat(ModAchievements.manaCookieEat, 1); - } + public ItemManaCookie() { + super(0, 0.1F, false); + setPotionEffect(Potion.field_76443_y.id, 1, 0, 1F); + setCreativeTab(BotaniaCreativeTab.INSTANCE); + setUnlocalizedName(LibItemNames.MANA_COOKIE); + } - @Override - public Item setUnlocalizedName(String par1Str) { - GameRegistry.registerItem(this, par1Str); - return super.setUnlocalizedName(par1Str); - } + @Override + protected void onFoodEaten(ItemStack p_77849_1_, World p_77849_2_, EntityPlayer p_77849_3_) { + super.onFoodEaten(p_77849_1_, p_77849_2_, p_77849_3_); + p_77849_3_.addStat(ModAchievements.manaCookieEat, 1); + } - @Override - public String getUnlocalizedNameInefficiently(ItemStack par1ItemStack) { - return super.getUnlocalizedNameInefficiently(par1ItemStack).replaceAll("item.", "item." + LibResources.PREFIX_MOD); - } + @Override + public Item setUnlocalizedName(String par1Str) { + GameRegistry.registerItem(this, par1Str); + return super.setUnlocalizedName(par1Str); + } - @Override - public IIcon getIcon(ItemStack stack, int pass) { - return getIconIndex(stack); - } + @Override + public String getUnlocalizedNameInefficiently(ItemStack par1ItemStack) { + return super.getUnlocalizedNameInefficiently(par1ItemStack) + .replaceAll("item.", "item." + LibResources.PREFIX_MOD); + } - @Override - public IIcon getIconIndex(ItemStack stack) { - return stack.getDisplayName().toLowerCase().equals("totalbiscuit") ? totalBiscuitIcon : super.getIconIndex(stack); - } + @Override + public IIcon getIcon(ItemStack stack, int pass) { + return getIconIndex(stack); + } - @Override - @SideOnly(Side.CLIENT) - public void registerIcons(IIconRegister par1IconRegister) { - itemIcon = IconHelper.forItem(par1IconRegister, this); - totalBiscuitIcon = IconHelper.forName(par1IconRegister, "totalBiscuit"); - } + @Override + public IIcon getIconIndex(ItemStack stack) { + return stack.getDisplayName().toLowerCase().equals("totalbiscuit") + ? totalBiscuitIcon + : super.getIconIndex(stack); + } + @Override + @SideOnly(Side.CLIENT) + public void registerIcons(IIconRegister par1IconRegister) { + itemIcon = IconHelper.forItem(par1IconRegister, this); + totalBiscuitIcon = IconHelper.forName(par1IconRegister, "totalBiscuit"); + } } diff --git a/src/main/java/vazkii/botania/common/item/ItemManaGun.java b/src/main/java/vazkii/botania/common/item/ItemManaGun.java index 30a8c2ef37..e7006db1e0 100644 --- a/src/main/java/vazkii/botania/common/item/ItemManaGun.java +++ b/src/main/java/vazkii/botania/common/item/ItemManaGun.java @@ -2,17 +2,19 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Mar 13, 2014, 4:30:27 PM (GMT)] */ package vazkii.botania.common.item; +import cpw.mods.fml.common.registry.GameRegistry; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; import java.awt.Color; import java.util.List; - import net.minecraft.client.Minecraft; import net.minecraft.client.gui.GuiScreen; import net.minecraft.client.renderer.texture.IIconRegister; @@ -42,306 +44,307 @@ import vazkii.botania.common.crafting.recipe.ManaGunRemoveLensRecipe; import vazkii.botania.common.entity.EntityManaBurst; import vazkii.botania.common.lib.LibItemNames; -import cpw.mods.fml.common.registry.GameRegistry; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; public class ItemManaGun extends ItemMod implements IManaUsingItem { - private static final String TAG_LENS = "lens"; - private static final String TAG_CLIP = "clip"; - private static final String TAG_CLIP_POS = "clipPos"; - - private static final int CLIP_SLOTS = 6; - private static final int COOLDOWN = 30; - - IIcon[] icons; - - public ItemManaGun() { - super(); - setMaxDamage(COOLDOWN); - setMaxStackSize(1); - setNoRepair(); - setUnlocalizedName(LibItemNames.MANA_GUN); - - GameRegistry.addRecipe(new ManaGunLensRecipe()); - GameRegistry.addRecipe(new ManaGunRemoveLensRecipe()); - GameRegistry.addRecipe(new ManaGunClipRecipe()); - RecipeSorter.register("botania:manaGunLens", ManaGunLensRecipe.class, Category.SHAPELESS, ""); - RecipeSorter.register("botania:manaGunRemoveLens", ManaGunRemoveLensRecipe.class, Category.SHAPELESS, ""); - RecipeSorter.register("botania:manaGunClip", ManaGunClipRecipe.class, Category.SHAPELESS, ""); - } - - @Override - public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer) { - int effCd = COOLDOWN; - PotionEffect effect = par3EntityPlayer.getActivePotionEffect(Potion.digSpeed); - if(effect != null) - effCd -= (effect.getAmplifier() + 1) * 8; - - if(par3EntityPlayer.isSneaking() && hasClip(par1ItemStack)) { - rotatePos(par1ItemStack); - par2World.playSoundAtEntity(par3EntityPlayer, "random.click", 0.6F, (1.0F + (par2World.rand.nextFloat() - par2World.rand.nextFloat()) * 0.2F) * 0.7F); - if(par2World.isRemote) - par3EntityPlayer.swingItem(); - ItemStack lens = getLens(par1ItemStack); - ItemsRemainingRenderHandler.set(lens, -2); - par1ItemStack.setItemDamage(effCd); - } else if(par1ItemStack.getItemDamage() == 0) { - EntityManaBurst burst = getBurst(par3EntityPlayer, par1ItemStack, true); - if(burst != null && ManaItemHandler.requestManaExact(par1ItemStack, par3EntityPlayer, burst.getMana(), true)) { - if(!par2World.isRemote) { - par2World.playSoundAtEntity(par3EntityPlayer, "botania:manaBlaster", 0.6F, 1F); - par3EntityPlayer.addStat(ModAchievements.manaBlasterShoot, 1); - if(isSugoiKawaiiDesuNe(par1ItemStack)) - par3EntityPlayer.addStat(ModAchievements.desuGun, 1); - par2World.spawnEntityInWorld(burst); - } else { - par3EntityPlayer.swingItem(); - par3EntityPlayer.motionX -= burst.motionX * 0.1; - par3EntityPlayer.motionY -= burst.motionY * 0.3; - par3EntityPlayer.motionZ -= burst.motionZ * 0.1; - } - par1ItemStack.setItemDamage(effCd); - } else if(!par2World.isRemote) - par2World.playSoundAtEntity(par3EntityPlayer, "random.click", 0.6F, (1.0F + (par2World.rand.nextFloat() - par2World.rand.nextFloat()) * 0.2F) * 0.7F); - } - - return par1ItemStack; - } - - @Override - public void registerIcons(IIconRegister par1IconRegister) { - int states = 3; - icons = new IIcon[states * 2]; - - for(int i = 0; i < states; i++) { - icons[i] = IconHelper.forItem(par1IconRegister, this, i); - icons[states + i] = IconHelper.forName(par1IconRegister, "desuGun" + i); - } - } - - @Override - public boolean requiresMultipleRenderPasses() { - return true; - } - - @Override - public IIcon getIcon(ItemStack stack, int pass) { - boolean desu = isSugoiKawaiiDesuNe(stack); - int index = pass; - if(index == 0 && hasClip(stack)) - index = 2; - - return icons[Math.min(2, index) + (desu ? 3 : 0)]; - } - - // ASADA-SAN ASADA-SAN ASADA-SAN ASADA-SAN ASADA-SAN ASADA-SAN ASADA-SAN ASADA-SAN - // ASADA-SAN ASADA-SAN ASADA-SAN ASADA-SAN ASADA-SAN ASADA-SAN ASADA-SAN ASADA-SAN - // ASADA-SAN ASADA-SAN ASADA-SAN ASADA-SAN ASADA-SAN ASADA-SAN ASADA-SAN ASADA-SAN - // ASADA-SAN ASADA-SAN ASADA-SAN ASADA-SAN ASADA-SAN ASADA-SAN ASADA-SAN ASADA-SAN - // ASADA-SAN ASADA-SAN ASADA-SAN ASADA-SAN ASADA-SAN ASADA-SAN ASADA-SAN ASADA-SAN - // ASADA-SAN ASADA-SAN ASADA-SAN ASADA-SAN ASADA-SAN ASADA-SAN ASADA-SAN ASADA-SAN - // ASADA-SAN ASADA-SAN ASADA-SAN ASADA-SAN ASADA-SAN ASADA-SAN ASADA-SAN ASADA-SAN - // ASADA-SAN ASADA-SAN ASADA-SAN ASADA-SAN ASADA-SAN ASADA-SAN ASADA-SAN ASADA-SAN - // ASADA-SAN ASADA-SAN ASADA-SAN ASADA-SAN ASADA-SAN ASADA-SAN ASADA-SAN ASADA-SAN - // ASADA-SAN ASADA-SAN ASADA-SAN ASADA-SAN ASADA-SAN ASADA-SAN ASADA-SAN ASADA-SAN - // ASADA-SAN ASADA-SAN ASADA-SAN ASADA-SAN ASADA-SAN ASADA-SAN ASADA-SAN ASADA-SAN - // ASADA-SAN ASADA-SAN ASADA-SAN ASADA-SAN ASADA-SAN ASADA-SAN ASADA-SAN ASADA-SAN - // ASADA-SAN ASADA-SAN ASADA-SAN ASADA-SAN ASADA-SAN ASADA-SAN ASADA-SAN ASADA-SAN - // ASADA-SAN ASADA-SAN ASADA-SAN ASADA-SAN ASADA-SAN ASADA-SAN ASADA-SAN ASADA-SAN - private boolean isSugoiKawaiiDesuNe(ItemStack stack) { - return stack.getDisplayName().equalsIgnoreCase("desu gun"); - } - - @Override - @SideOnly(Side.CLIENT) - public int getColorFromItemStack(ItemStack par1ItemStack, int par2) { - if(par2 == 0) - return 0xFFFFFF; - - EntityManaBurst burst = getBurst(Minecraft.getMinecraft().thePlayer, par1ItemStack, false); - Color color = new Color(burst == null ? 0x20FF20 : burst.getColor()); - - float mul = (float) (Math.sin((double) ClientTickHandler.ticksInGame / 5) * 0.15F); - int c = (int) (255 * mul); - - return new Color(Math.max(0, Math.min(255, color.getRed() + c)), Math.max(0, Math.min(255, color.getGreen() + c)), Math.max(0, Math.min(255, color.getBlue() + c))).getRGB(); - } - - @Override - public boolean hasContainerItem(ItemStack stack) { - return getLens(stack) != null; - } - - @Override - public ItemStack getContainerItem(ItemStack itemStack) { - return getLens(itemStack); - } - - @Override - public boolean doesContainerItemLeaveCraftingGrid(ItemStack p_77630_1_) { - return false; - } - - public EntityManaBurst getBurst(EntityPlayer player, ItemStack stack, boolean request) { - EntityManaBurst burst = new EntityManaBurst(player); - - int maxMana = 120; - int color = 0x20FF20; - int ticksBeforeManaLoss = 60; - float manaLossPerTick = 4F; - float motionModifier = 5F; - float gravity = 0F; - BurstProperties props = new BurstProperties(maxMana, ticksBeforeManaLoss, manaLossPerTick, gravity, motionModifier, color); - - ItemStack lens = getLens(stack); - if(lens != null) - ((ILens) lens.getItem()).apply(lens, props); - - - burst.setSourceLens(lens); - if(!request || ManaItemHandler.requestManaExact(stack, player, props.maxMana, false)) { - burst.setColor(props.color); - burst.setMana(props.maxMana); - burst.setStartingMana(props.maxMana); - burst.setMinManaLoss(props.ticksBeforeManaLoss); - burst.setManaLossPerTick(props.manaLossPerTick); - burst.setGravity(props.gravity); - burst.setMotion(burst.motionX * props.motionModifier, burst.motionY * props.motionModifier, burst.motionZ * props.motionModifier); - - return burst; - } - return null; - } - - @Override - public void addInformation(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, List par3List, boolean par4) { - boolean clip = hasClip(par1ItemStack); - if(clip && !GuiScreen.isShiftKeyDown()) { - addStringToTooltip(StatCollector.translateToLocal("botaniamisc.shiftinfo"), par3List); - return; - } - - ItemStack lens = getLens(par1ItemStack); - if(lens != null) { - List tooltip = lens.getTooltip(par2EntityPlayer, false); - if(tooltip.size() > 1) - par3List.addAll(tooltip.subList(1, tooltip.size())); - } - - if(clip) { - int pos = getClipPos(par1ItemStack); - addStringToTooltip(StatCollector.translateToLocal("botaniamisc.hasClip"), par3List); - for(int i = 0; i < CLIP_SLOTS; i++) { - String name = ""; - EnumChatFormatting formatting = i == pos ? EnumChatFormatting.GREEN : EnumChatFormatting.GRAY; - ItemStack lensAt = getLensAtPos(par1ItemStack, i); - if(lensAt == null) - name = StatCollector.translateToLocal("botaniamisc.clipEmpty"); - else name = lensAt.getDisplayName(); - addStringToTooltip(formatting + " - " + name, par3List); - } - } - } - - private void addStringToTooltip(String s, List tooltip) { - tooltip.add(s.replaceAll("&", "\u00a7")); - } - - @Override - public String getItemStackDisplayName(ItemStack par1ItemStack) { - ItemStack lens = getLens(par1ItemStack); - return super.getItemStackDisplayName(par1ItemStack) + (lens == null ? "" : " (" + EnumChatFormatting.GREEN + lens.getDisplayName() + EnumChatFormatting.RESET + ")"); - } - - public static boolean hasClip(ItemStack stack) { - return ItemNBTHelper.getBoolean(stack, TAG_CLIP, false); - } - - public static void setClip(ItemStack stack, boolean clip) { - ItemNBTHelper.setBoolean(stack, TAG_CLIP, clip); - } - - public static int getClipPos(ItemStack stack) { - return ItemNBTHelper.getInt(stack, TAG_CLIP_POS, 0); - } - - public static void setClipPos(ItemStack stack, int pos) { - ItemNBTHelper.setInt(stack, TAG_CLIP_POS, pos); - } - - public static void rotatePos(ItemStack stack) { - int currPos = getClipPos(stack); - boolean acceptEmpty = getLensAtPos(stack, currPos) != null; - int[] slots = new int[CLIP_SLOTS - 1]; - - int index = 0; - for(int i = currPos + 1; i < CLIP_SLOTS; i++, index++) - slots[index] = i; - for(int i = 0; i < currPos; i++, index++) - slots[index] = i; - - for(int i : slots) { - ItemStack lensAt = getLensAtPos(stack, i); - if(acceptEmpty || lensAt != null) { - setClipPos(stack, i); - return; - } - } - } - - public static ItemStack getLensAtPos(ItemStack stack, int pos) { - NBTTagCompound cmp = ItemNBTHelper.getCompound(stack, TAG_LENS + pos, true); - if(cmp != null) { - ItemStack lens = ItemStack.loadItemStackFromNBT(cmp); - return lens; - } - return null; - } - - public static void setLensAtPos(ItemStack stack, ItemStack lens, int pos) { - NBTTagCompound cmp = new NBTTagCompound(); - if(lens != null) - lens.writeToNBT(cmp); - ItemNBTHelper.setCompound(stack, TAG_LENS + pos, cmp); - } - - public static void setLens(ItemStack stack, ItemStack lens) { - if(hasClip(stack)) - setLensAtPos(stack, lens, getClipPos(stack)); - - NBTTagCompound cmp = new NBTTagCompound(); - if(lens != null) - lens.writeToNBT(cmp); - ItemNBTHelper.setCompound(stack, TAG_LENS, cmp); - } - - public static ItemStack getLens(ItemStack stack) { - if(hasClip(stack)) - return getLensAtPos(stack, getClipPos(stack)); - - NBTTagCompound cmp = ItemNBTHelper.getCompound(stack, TAG_LENS, true); - if(cmp != null) { - ItemStack lens = ItemStack.loadItemStackFromNBT(cmp); - return lens; - } - return null; - } - - @Override - public boolean isFull3D() { - return true; - } - - @Override - public void onUpdate(ItemStack par1ItemStack, World par2World, Entity par3Entity, int par4, boolean par5) { - if(par1ItemStack.isItemDamaged()) - par1ItemStack.setItemDamage(par1ItemStack.getItemDamage() - 1); - } - - @Override - public boolean usesMana(ItemStack stack) { - return true; - } + private static final String TAG_LENS = "lens"; + private static final String TAG_CLIP = "clip"; + private static final String TAG_CLIP_POS = "clipPos"; + + private static final int CLIP_SLOTS = 6; + private static final int COOLDOWN = 30; + + IIcon[] icons; + + public ItemManaGun() { + super(); + setMaxDamage(COOLDOWN); + setMaxStackSize(1); + setNoRepair(); + setUnlocalizedName(LibItemNames.MANA_GUN); + + GameRegistry.addRecipe(new ManaGunLensRecipe()); + GameRegistry.addRecipe(new ManaGunRemoveLensRecipe()); + GameRegistry.addRecipe(new ManaGunClipRecipe()); + RecipeSorter.register("botania:manaGunLens", ManaGunLensRecipe.class, Category.SHAPELESS, ""); + RecipeSorter.register("botania:manaGunRemoveLens", ManaGunRemoveLensRecipe.class, Category.SHAPELESS, ""); + RecipeSorter.register("botania:manaGunClip", ManaGunClipRecipe.class, Category.SHAPELESS, ""); + } + + @Override + public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer) { + int effCd = COOLDOWN; + PotionEffect effect = par3EntityPlayer.getActivePotionEffect(Potion.digSpeed); + if (effect != null) effCd -= (effect.getAmplifier() + 1) * 8; + + if (par3EntityPlayer.isSneaking() && hasClip(par1ItemStack)) { + rotatePos(par1ItemStack); + par2World.playSoundAtEntity( + par3EntityPlayer, + "random.click", + 0.6F, + (1.0F + (par2World.rand.nextFloat() - par2World.rand.nextFloat()) * 0.2F) * 0.7F); + if (par2World.isRemote) par3EntityPlayer.swingItem(); + ItemStack lens = getLens(par1ItemStack); + ItemsRemainingRenderHandler.set(lens, -2); + par1ItemStack.setItemDamage(effCd); + } else if (par1ItemStack.getItemDamage() == 0) { + EntityManaBurst burst = getBurst(par3EntityPlayer, par1ItemStack, true); + if (burst != null + && ManaItemHandler.requestManaExact(par1ItemStack, par3EntityPlayer, burst.getMana(), true)) { + if (!par2World.isRemote) { + par2World.playSoundAtEntity(par3EntityPlayer, "botania:manaBlaster", 0.6F, 1F); + par3EntityPlayer.addStat(ModAchievements.manaBlasterShoot, 1); + if (isSugoiKawaiiDesuNe(par1ItemStack)) par3EntityPlayer.addStat(ModAchievements.desuGun, 1); + par2World.spawnEntityInWorld(burst); + } else { + par3EntityPlayer.swingItem(); + par3EntityPlayer.motionX -= burst.motionX * 0.1; + par3EntityPlayer.motionY -= burst.motionY * 0.3; + par3EntityPlayer.motionZ -= burst.motionZ * 0.1; + } + par1ItemStack.setItemDamage(effCd); + } else if (!par2World.isRemote) + par2World.playSoundAtEntity( + par3EntityPlayer, + "random.click", + 0.6F, + (1.0F + (par2World.rand.nextFloat() - par2World.rand.nextFloat()) * 0.2F) * 0.7F); + } + + return par1ItemStack; + } + + @Override + public void registerIcons(IIconRegister par1IconRegister) { + int states = 3; + icons = new IIcon[states * 2]; + + for (int i = 0; i < states; i++) { + icons[i] = IconHelper.forItem(par1IconRegister, this, i); + icons[states + i] = IconHelper.forName(par1IconRegister, "desuGun" + i); + } + } + + @Override + public boolean requiresMultipleRenderPasses() { + return true; + } + + @Override + public IIcon getIcon(ItemStack stack, int pass) { + boolean desu = isSugoiKawaiiDesuNe(stack); + int index = pass; + if (index == 0 && hasClip(stack)) index = 2; + + return icons[Math.min(2, index) + (desu ? 3 : 0)]; + } + + // ASADA-SAN ASADA-SAN ASADA-SAN ASADA-SAN ASADA-SAN ASADA-SAN ASADA-SAN ASADA-SAN + // ASADA-SAN ASADA-SAN ASADA-SAN ASADA-SAN ASADA-SAN ASADA-SAN ASADA-SAN ASADA-SAN + // ASADA-SAN ASADA-SAN ASADA-SAN ASADA-SAN ASADA-SAN ASADA-SAN ASADA-SAN ASADA-SAN + // ASADA-SAN ASADA-SAN ASADA-SAN ASADA-SAN ASADA-SAN ASADA-SAN ASADA-SAN ASADA-SAN + // ASADA-SAN ASADA-SAN ASADA-SAN ASADA-SAN ASADA-SAN ASADA-SAN ASADA-SAN ASADA-SAN + // ASADA-SAN ASADA-SAN ASADA-SAN ASADA-SAN ASADA-SAN ASADA-SAN ASADA-SAN ASADA-SAN + // ASADA-SAN ASADA-SAN ASADA-SAN ASADA-SAN ASADA-SAN ASADA-SAN ASADA-SAN ASADA-SAN + // ASADA-SAN ASADA-SAN ASADA-SAN ASADA-SAN ASADA-SAN ASADA-SAN ASADA-SAN ASADA-SAN + // ASADA-SAN ASADA-SAN ASADA-SAN ASADA-SAN ASADA-SAN ASADA-SAN ASADA-SAN ASADA-SAN + // ASADA-SAN ASADA-SAN ASADA-SAN ASADA-SAN ASADA-SAN ASADA-SAN ASADA-SAN ASADA-SAN + // ASADA-SAN ASADA-SAN ASADA-SAN ASADA-SAN ASADA-SAN ASADA-SAN ASADA-SAN ASADA-SAN + // ASADA-SAN ASADA-SAN ASADA-SAN ASADA-SAN ASADA-SAN ASADA-SAN ASADA-SAN ASADA-SAN + // ASADA-SAN ASADA-SAN ASADA-SAN ASADA-SAN ASADA-SAN ASADA-SAN ASADA-SAN ASADA-SAN + // ASADA-SAN ASADA-SAN ASADA-SAN ASADA-SAN ASADA-SAN ASADA-SAN ASADA-SAN ASADA-SAN + private boolean isSugoiKawaiiDesuNe(ItemStack stack) { + return stack.getDisplayName().equalsIgnoreCase("desu gun"); + } + + @Override + @SideOnly(Side.CLIENT) + public int getColorFromItemStack(ItemStack par1ItemStack, int par2) { + if (par2 == 0) return 0xFFFFFF; + + EntityManaBurst burst = getBurst(Minecraft.getMinecraft().thePlayer, par1ItemStack, false); + Color color = new Color(burst == null ? 0x20FF20 : burst.getColor()); + + float mul = (float) (Math.sin((double) ClientTickHandler.ticksInGame / 5) * 0.15F); + int c = (int) (255 * mul); + + return new Color( + Math.max(0, Math.min(255, color.getRed() + c)), + Math.max(0, Math.min(255, color.getGreen() + c)), + Math.max(0, Math.min(255, color.getBlue() + c))) + .getRGB(); + } + + @Override + public boolean hasContainerItem(ItemStack stack) { + return getLens(stack) != null; + } + + @Override + public ItemStack getContainerItem(ItemStack itemStack) { + return getLens(itemStack); + } + + @Override + public boolean doesContainerItemLeaveCraftingGrid(ItemStack p_77630_1_) { + return false; + } + + public EntityManaBurst getBurst(EntityPlayer player, ItemStack stack, boolean request) { + EntityManaBurst burst = new EntityManaBurst(player); + + int maxMana = 120; + int color = 0x20FF20; + int ticksBeforeManaLoss = 60; + float manaLossPerTick = 4F; + float motionModifier = 5F; + float gravity = 0F; + BurstProperties props = + new BurstProperties(maxMana, ticksBeforeManaLoss, manaLossPerTick, gravity, motionModifier, color); + + ItemStack lens = getLens(stack); + if (lens != null) ((ILens) lens.getItem()).apply(lens, props); + + burst.setSourceLens(lens); + if (!request || ManaItemHandler.requestManaExact(stack, player, props.maxMana, false)) { + burst.setColor(props.color); + burst.setMana(props.maxMana); + burst.setStartingMana(props.maxMana); + burst.setMinManaLoss(props.ticksBeforeManaLoss); + burst.setManaLossPerTick(props.manaLossPerTick); + burst.setGravity(props.gravity); + burst.setMotion( + burst.motionX * props.motionModifier, + burst.motionY * props.motionModifier, + burst.motionZ * props.motionModifier); + + return burst; + } + return null; + } + + @Override + public void addInformation(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, List par3List, boolean par4) { + boolean clip = hasClip(par1ItemStack); + if (clip && !GuiScreen.isShiftKeyDown()) { + addStringToTooltip(StatCollector.translateToLocal("botaniamisc.shiftinfo"), par3List); + return; + } + + ItemStack lens = getLens(par1ItemStack); + if (lens != null) { + List tooltip = lens.getTooltip(par2EntityPlayer, false); + if (tooltip.size() > 1) par3List.addAll(tooltip.subList(1, tooltip.size())); + } + + if (clip) { + int pos = getClipPos(par1ItemStack); + addStringToTooltip(StatCollector.translateToLocal("botaniamisc.hasClip"), par3List); + for (int i = 0; i < CLIP_SLOTS; i++) { + String name = ""; + EnumChatFormatting formatting = i == pos ? EnumChatFormatting.GREEN : EnumChatFormatting.GRAY; + ItemStack lensAt = getLensAtPos(par1ItemStack, i); + if (lensAt == null) name = StatCollector.translateToLocal("botaniamisc.clipEmpty"); + else name = lensAt.getDisplayName(); + addStringToTooltip(formatting + " - " + name, par3List); + } + } + } + + private void addStringToTooltip(String s, List tooltip) { + tooltip.add(s.replaceAll("&", "\u00a7")); + } + + @Override + public String getItemStackDisplayName(ItemStack par1ItemStack) { + ItemStack lens = getLens(par1ItemStack); + return super.getItemStackDisplayName(par1ItemStack) + + (lens == null + ? "" + : " (" + EnumChatFormatting.GREEN + lens.getDisplayName() + EnumChatFormatting.RESET + ")"); + } + + public static boolean hasClip(ItemStack stack) { + return ItemNBTHelper.getBoolean(stack, TAG_CLIP, false); + } + + public static void setClip(ItemStack stack, boolean clip) { + ItemNBTHelper.setBoolean(stack, TAG_CLIP, clip); + } + + public static int getClipPos(ItemStack stack) { + return ItemNBTHelper.getInt(stack, TAG_CLIP_POS, 0); + } + + public static void setClipPos(ItemStack stack, int pos) { + ItemNBTHelper.setInt(stack, TAG_CLIP_POS, pos); + } + + public static void rotatePos(ItemStack stack) { + int currPos = getClipPos(stack); + boolean acceptEmpty = getLensAtPos(stack, currPos) != null; + int[] slots = new int[CLIP_SLOTS - 1]; + + int index = 0; + for (int i = currPos + 1; i < CLIP_SLOTS; i++, index++) slots[index] = i; + for (int i = 0; i < currPos; i++, index++) slots[index] = i; + + for (int i : slots) { + ItemStack lensAt = getLensAtPos(stack, i); + if (acceptEmpty || lensAt != null) { + setClipPos(stack, i); + return; + } + } + } + + public static ItemStack getLensAtPos(ItemStack stack, int pos) { + NBTTagCompound cmp = ItemNBTHelper.getCompound(stack, TAG_LENS + pos, true); + if (cmp != null) { + ItemStack lens = ItemStack.loadItemStackFromNBT(cmp); + return lens; + } + return null; + } + + public static void setLensAtPos(ItemStack stack, ItemStack lens, int pos) { + NBTTagCompound cmp = new NBTTagCompound(); + if (lens != null) lens.writeToNBT(cmp); + ItemNBTHelper.setCompound(stack, TAG_LENS + pos, cmp); + } + + public static void setLens(ItemStack stack, ItemStack lens) { + if (hasClip(stack)) setLensAtPos(stack, lens, getClipPos(stack)); + + NBTTagCompound cmp = new NBTTagCompound(); + if (lens != null) lens.writeToNBT(cmp); + ItemNBTHelper.setCompound(stack, TAG_LENS, cmp); + } + + public static ItemStack getLens(ItemStack stack) { + if (hasClip(stack)) return getLensAtPos(stack, getClipPos(stack)); + + NBTTagCompound cmp = ItemNBTHelper.getCompound(stack, TAG_LENS, true); + if (cmp != null) { + ItemStack lens = ItemStack.loadItemStackFromNBT(cmp); + return lens; + } + return null; + } + + @Override + public boolean isFull3D() { + return true; + } + + @Override + public void onUpdate(ItemStack par1ItemStack, World par2World, Entity par3Entity, int par4, boolean par5) { + if (par1ItemStack.isItemDamaged()) par1ItemStack.setItemDamage(par1ItemStack.getItemDamage() - 1); + } + + @Override + public boolean usesMana(ItemStack stack) { + return true; + } } diff --git a/src/main/java/vazkii/botania/common/item/ItemManaMirror.java b/src/main/java/vazkii/botania/common/item/ItemManaMirror.java index 27d99c709b..6490fb5ace 100644 --- a/src/main/java/vazkii/botania/common/item/ItemManaMirror.java +++ b/src/main/java/vazkii/botania/common/item/ItemManaMirror.java @@ -2,16 +2,15 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Apr 13, 2014, 5:39:24 PM (GMT)] */ package vazkii.botania.common.item; import java.awt.Color; - import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.entity.Entity; import net.minecraft.entity.player.EntityPlayer; @@ -32,246 +31,248 @@ public class ItemManaMirror extends ItemMod implements IManaItem, ICoordBoundItem, IManaTooltipDisplay { - IIcon[] icons; - - private static final String TAG_MANA = "mana"; - private static final String TAG_MANA_BACKLOG = "manaBacklog"; - - private static final String TAG_POS_X = "posX"; - private static final String TAG_POS_Y = "posY"; - private static final String TAG_POS_Z = "posZ"; - private static final String TAG_DIM = "dim"; - - private static final DummyPool fallbackPool = new DummyPool(); - - public ItemManaMirror() { - super(); - setMaxStackSize(1); - setMaxDamage(1000); - setUnlocalizedName(LibItemNames.MANA_MIRROR); - setNoRepair(); - } - - @Override - public int getColorFromItemStack(ItemStack par1ItemStack, int par2) { - float mana = getMana(par1ItemStack); - return par2 == 1 ? Color.HSBtoRGB(0.528F, mana / TilePool.MAX_MANA, 1F) : 0xFFFFFF; - } - - @Override - public int getDamage(ItemStack stack) { - float mana = getMana(stack); - return 1000 - (int) (mana / TilePool.MAX_MANA * 1000); - } - - @Override - public int getDisplayDamage(ItemStack stack) { - return getDamage(stack); - } - - @Override - public void registerIcons(IIconRegister par1IconRegister) { - icons = new IIcon[2]; - for(int i = 0; i < icons.length; i++) - icons[i] = IconHelper.forItem(par1IconRegister, this, i); - } - - @Override - public IIcon getIcon(ItemStack stack, int pass) { - return icons[Math.min(1, pass)]; - } - - @Override - public boolean isFull3D() { - return true; - } - - @Override - public void onUpdate(ItemStack par1ItemStack, World par2World, Entity par3Entity, int par4, boolean par5) { - if(par2World.isRemote) - return; - - IManaPool pool = getManaPool(par1ItemStack); - if(!(pool instanceof DummyPool)) { - if(pool == null) - setMana(par1ItemStack, 0); - else { - pool.recieveMana(getManaBacklog(par1ItemStack)); - setManaBacklog(par1ItemStack, 0); - setMana(par1ItemStack, pool.getCurrentMana()); - } - } - } - - @Override - public boolean onItemUse(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, World par3World, int par4, int par5, int par6, int par7, float par8, float par9, float par10) { - if(par2EntityPlayer.isSneaking() && !par3World.isRemote) { - TileEntity tile = par3World.getTileEntity(par4, par5, par6); - if(tile != null && tile instanceof IManaPool) { - bindPool(par1ItemStack, tile); - par3World.playSoundAtEntity(par2EntityPlayer, "botania:ding", 1F, 1F); - return true; - } - } - - return false; - } - - @Override - public boolean requiresMultipleRenderPasses() { - return true; - } - - /*public int getMana(ItemStack stack) { - IManaPool pool = getManaPool(stack); - return pool == null ? 0 : pool.getCurrentMana(); - }*/ - - @Override - public int getMana(ItemStack stack) { - return ItemNBTHelper.getInt(stack, TAG_MANA, 0); - } - - public void setMana(ItemStack stack, int mana) { - ItemNBTHelper.setInt(stack, TAG_MANA, Math.max(0, mana)); - } - - public int getManaBacklog(ItemStack stack) { - return ItemNBTHelper.getInt(stack, TAG_MANA_BACKLOG, 0); - } - - public void setManaBacklog(ItemStack stack, int backlog) { - ItemNBTHelper.setInt(stack, TAG_MANA_BACKLOG, backlog); - } - - @Override - public int getMaxMana(ItemStack stack) { - return TilePool.MAX_MANA; - } - - @Override - public void addMana(ItemStack stack, int mana) { - setMana(stack, getMana(stack) + mana); - setManaBacklog(stack, getManaBacklog(stack) + mana); - } - - /*public void addMana(ItemStack stack, int mana) { - IManaPool pool = getManaPool(stack); - if(pool != null) { - pool.recieveMana(mana); - TileEntity tile = (TileEntity) pool; - tile.getWorldObj().func_147453_f(tile.xCoord, tile.yCoord, tile.zCoord, tile.getWorldObj().getBlock(tile.xCoord, tile.yCoord, tile.zCoord)); - } - }*/ - - public void bindPool(ItemStack stack, TileEntity pool) { - ItemNBTHelper.setInt(stack, TAG_POS_X, pool == null ? 0 : pool.xCoord); - ItemNBTHelper.setInt(stack, TAG_POS_Y, pool == null ? -1 : pool.yCoord); - ItemNBTHelper.setInt(stack, TAG_POS_Z, pool == null ? 0 : pool.zCoord); - ItemNBTHelper.setInt(stack, TAG_DIM, pool == null ? 0 : pool.getWorldObj().provider.dimensionId); - } - - public ChunkCoordinates getPoolCoords(ItemStack stack) { - int x = ItemNBTHelper.getInt(stack, TAG_POS_X, 0); - int y = ItemNBTHelper.getInt(stack, TAG_POS_Y, -1); - int z = ItemNBTHelper.getInt(stack, TAG_POS_Z, 0); - return new ChunkCoordinates(x, y, z); - } - - public int getDimension(ItemStack stack) { - return ItemNBTHelper.getInt(stack, TAG_DIM, 0); - } - - public IManaPool getManaPool(ItemStack stack) { - MinecraftServer server = MinecraftServer.getServer(); - if(server == null) - return fallbackPool; - - ChunkCoordinates coords = getPoolCoords(stack); - if(coords.posY == -1) - return null; - - int dim = getDimension(stack); - World world = null; - for(World w : server.worldServers) - if(w.provider.dimensionId == dim) { - world = w; - break; - } - - if(world != null) { - TileEntity tile = world.getTileEntity(coords.posX, coords.posY, coords.posZ); - if(tile != null && tile instanceof IManaPool) - return (IManaPool) tile; - } - - return null; - } - - @Override - public boolean canReceiveManaFromPool(ItemStack stack, TileEntity pool) { - return false; - } - - @Override - public boolean canReceiveManaFromItem(ItemStack stack, ItemStack otherStack) { - return false; - } - - @Override - public boolean canExportManaToPool(ItemStack stack, TileEntity pool) { - return false; - } - - @Override - public boolean canExportManaToItem(ItemStack stack, ItemStack otherStack) { - return true; - } - - private static class DummyPool implements IManaPool { - - @Override - public boolean isFull() { - return false; - } - - @Override - public void recieveMana(int mana) { - // NO-OP - } - - @Override - public boolean canRecieveManaFromBursts() { - return false; - } - - @Override - public int getCurrentMana() { - return 0; - } - - @Override - public boolean isOutputtingPower() { - return false; - } - - } - - @Override - public boolean isNoExport(ItemStack stack) { - return false; - } - - @Override - public ChunkCoordinates getBinding(ItemStack stack) { - IManaPool pool = getManaPool(stack); - - return pool == null || pool instanceof DummyPool ? null : getPoolCoords(stack); - } - - @Override - public float getManaFractionForDisplay(ItemStack stack) { - return (float) getMana(stack) / (float) getMaxMana(stack); - } - + IIcon[] icons; + + private static final String TAG_MANA = "mana"; + private static final String TAG_MANA_BACKLOG = "manaBacklog"; + + private static final String TAG_POS_X = "posX"; + private static final String TAG_POS_Y = "posY"; + private static final String TAG_POS_Z = "posZ"; + private static final String TAG_DIM = "dim"; + + private static final DummyPool fallbackPool = new DummyPool(); + + public ItemManaMirror() { + super(); + setMaxStackSize(1); + setMaxDamage(1000); + setUnlocalizedName(LibItemNames.MANA_MIRROR); + setNoRepair(); + } + + @Override + public int getColorFromItemStack(ItemStack par1ItemStack, int par2) { + float mana = getMana(par1ItemStack); + return par2 == 1 ? Color.HSBtoRGB(0.528F, mana / TilePool.MAX_MANA, 1F) : 0xFFFFFF; + } + + @Override + public int getDamage(ItemStack stack) { + float mana = getMana(stack); + return 1000 - (int) (mana / TilePool.MAX_MANA * 1000); + } + + @Override + public int getDisplayDamage(ItemStack stack) { + return getDamage(stack); + } + + @Override + public void registerIcons(IIconRegister par1IconRegister) { + icons = new IIcon[2]; + for (int i = 0; i < icons.length; i++) icons[i] = IconHelper.forItem(par1IconRegister, this, i); + } + + @Override + public IIcon getIcon(ItemStack stack, int pass) { + return icons[Math.min(1, pass)]; + } + + @Override + public boolean isFull3D() { + return true; + } + + @Override + public void onUpdate(ItemStack par1ItemStack, World par2World, Entity par3Entity, int par4, boolean par5) { + if (par2World.isRemote) return; + + IManaPool pool = getManaPool(par1ItemStack); + if (!(pool instanceof DummyPool)) { + if (pool == null) setMana(par1ItemStack, 0); + else { + pool.recieveMana(getManaBacklog(par1ItemStack)); + setManaBacklog(par1ItemStack, 0); + setMana(par1ItemStack, pool.getCurrentMana()); + } + } + } + + @Override + public boolean onItemUse( + ItemStack par1ItemStack, + EntityPlayer par2EntityPlayer, + World par3World, + int par4, + int par5, + int par6, + int par7, + float par8, + float par9, + float par10) { + if (par2EntityPlayer.isSneaking() && !par3World.isRemote) { + TileEntity tile = par3World.getTileEntity(par4, par5, par6); + if (tile != null && tile instanceof IManaPool) { + bindPool(par1ItemStack, tile); + par3World.playSoundAtEntity(par2EntityPlayer, "botania:ding", 1F, 1F); + return true; + } + } + + return false; + } + + @Override + public boolean requiresMultipleRenderPasses() { + return true; + } + + /*public int getMana(ItemStack stack) { + IManaPool pool = getManaPool(stack); + return pool == null ? 0 : pool.getCurrentMana(); + }*/ + + @Override + public int getMana(ItemStack stack) { + return ItemNBTHelper.getInt(stack, TAG_MANA, 0); + } + + public void setMana(ItemStack stack, int mana) { + ItemNBTHelper.setInt(stack, TAG_MANA, Math.max(0, mana)); + } + + public int getManaBacklog(ItemStack stack) { + return ItemNBTHelper.getInt(stack, TAG_MANA_BACKLOG, 0); + } + + public void setManaBacklog(ItemStack stack, int backlog) { + ItemNBTHelper.setInt(stack, TAG_MANA_BACKLOG, backlog); + } + + @Override + public int getMaxMana(ItemStack stack) { + return TilePool.MAX_MANA; + } + + @Override + public void addMana(ItemStack stack, int mana) { + setMana(stack, getMana(stack) + mana); + setManaBacklog(stack, getManaBacklog(stack) + mana); + } + + /*public void addMana(ItemStack stack, int mana) { + IManaPool pool = getManaPool(stack); + if(pool != null) { + pool.recieveMana(mana); + TileEntity tile = (TileEntity) pool; + tile.getWorldObj().func_147453_f(tile.xCoord, tile.yCoord, tile.zCoord, tile.getWorldObj().getBlock(tile.xCoord, tile.yCoord, tile.zCoord)); + } + }*/ + + public void bindPool(ItemStack stack, TileEntity pool) { + ItemNBTHelper.setInt(stack, TAG_POS_X, pool == null ? 0 : pool.xCoord); + ItemNBTHelper.setInt(stack, TAG_POS_Y, pool == null ? -1 : pool.yCoord); + ItemNBTHelper.setInt(stack, TAG_POS_Z, pool == null ? 0 : pool.zCoord); + ItemNBTHelper.setInt(stack, TAG_DIM, pool == null ? 0 : pool.getWorldObj().provider.dimensionId); + } + + public ChunkCoordinates getPoolCoords(ItemStack stack) { + int x = ItemNBTHelper.getInt(stack, TAG_POS_X, 0); + int y = ItemNBTHelper.getInt(stack, TAG_POS_Y, -1); + int z = ItemNBTHelper.getInt(stack, TAG_POS_Z, 0); + return new ChunkCoordinates(x, y, z); + } + + public int getDimension(ItemStack stack) { + return ItemNBTHelper.getInt(stack, TAG_DIM, 0); + } + + public IManaPool getManaPool(ItemStack stack) { + MinecraftServer server = MinecraftServer.getServer(); + if (server == null) return fallbackPool; + + ChunkCoordinates coords = getPoolCoords(stack); + if (coords.posY == -1) return null; + + int dim = getDimension(stack); + World world = null; + for (World w : server.worldServers) + if (w.provider.dimensionId == dim) { + world = w; + break; + } + + if (world != null) { + TileEntity tile = world.getTileEntity(coords.posX, coords.posY, coords.posZ); + if (tile != null && tile instanceof IManaPool) return (IManaPool) tile; + } + + return null; + } + + @Override + public boolean canReceiveManaFromPool(ItemStack stack, TileEntity pool) { + return false; + } + + @Override + public boolean canReceiveManaFromItem(ItemStack stack, ItemStack otherStack) { + return false; + } + + @Override + public boolean canExportManaToPool(ItemStack stack, TileEntity pool) { + return false; + } + + @Override + public boolean canExportManaToItem(ItemStack stack, ItemStack otherStack) { + return true; + } + + private static class DummyPool implements IManaPool { + + @Override + public boolean isFull() { + return false; + } + + @Override + public void recieveMana(int mana) { + // NO-OP + } + + @Override + public boolean canRecieveManaFromBursts() { + return false; + } + + @Override + public int getCurrentMana() { + return 0; + } + + @Override + public boolean isOutputtingPower() { + return false; + } + } + + @Override + public boolean isNoExport(ItemStack stack) { + return false; + } + + @Override + public ChunkCoordinates getBinding(ItemStack stack) { + IManaPool pool = getManaPool(stack); + + return pool == null || pool instanceof DummyPool ? null : getPoolCoords(stack); + } + + @Override + public float getManaFractionForDisplay(ItemStack stack) { + return (float) getMana(stack) / (float) getMaxMana(stack); + } } diff --git a/src/main/java/vazkii/botania/common/item/ItemManaTablet.java b/src/main/java/vazkii/botania/common/item/ItemManaTablet.java index f66cab2a8d..af8be9962e 100644 --- a/src/main/java/vazkii/botania/common/item/ItemManaTablet.java +++ b/src/main/java/vazkii/botania/common/item/ItemManaTablet.java @@ -2,17 +2,16 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Mar 7, 2014, 7:06:20 PM (GMT)] */ package vazkii.botania.common.item; import java.awt.Color; import java.util.List; - import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.entity.player.EntityPlayer; @@ -31,157 +30,152 @@ public class ItemManaTablet extends ItemMod implements IManaItem, ICreativeManaProvider, IManaTooltipDisplay { - IIcon[] icons; - - private static final int MAX_MANA = 500000; - - private static final String TAG_MANA = "mana"; - private static final String TAG_CREATIVE = "creative"; - private static final String TAG_ONE_USE = "oneUse"; - - public ItemManaTablet() { - super(); - setMaxStackSize(1); - setMaxDamage(1000); - setUnlocalizedName(LibItemNames.MANA_TABLET); - setNoRepair(); - } - - @Override - public void getSubItems(Item par1, CreativeTabs par2CreativeTabs, List par3List) { - // Empty tablet - par3List.add(new ItemStack(par1, 1)); - - // Full tablet - ItemStack fullPower = new ItemStack(par1, 1); - setMana(fullPower, MAX_MANA); - par3List.add(fullPower); - - // Creative Tablet - ItemStack creative = new ItemStack(par1, 1); - setMana(creative, MAX_MANA); - setStackCreative(creative); - par3List.add(creative); - } - - @Override - public int getColorFromItemStack(ItemStack par1ItemStack, int par2) { - float mana = getMana(par1ItemStack); - return par2 == 1 ? Color.HSBtoRGB(0.528F, mana / MAX_MANA, 1F) : 0xFFFFFF; - } - - @Override - public int getDamage(ItemStack stack) { - // Compatibility shim, so tablets from previous versions of botania - // stack right in barrels and so forth - if(super.getDamage(stack) != 0) - super.setDamage(stack, 0); - - return 0; - } - - @Override - public void registerIcons(IIconRegister par1IconRegister) { - icons = new IIcon[2]; - for(int i = 0; i < icons.length; i++) - icons[i] = IconHelper.forItem(par1IconRegister, this, i); - } - - @Override - public IIcon getIcon(ItemStack stack, int pass) { - return icons[Math.min(1, pass)]; - } - - @Override - public void addInformation(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, List par3List, boolean par4) { - if(isStackCreative(par1ItemStack)) - par3List.add(StatCollector.translateToLocal("botaniamisc.creative")); - } - - @Override - public boolean requiresMultipleRenderPasses() { - return true; - } - - @Override - public int getEntityLifespan(ItemStack itemStack, World world) { - return Integer.MAX_VALUE; - } - - public static void setMana(ItemStack stack, int mana) { - ItemNBTHelper.setInt(stack, TAG_MANA, mana); - } - - public static void setStackCreative(ItemStack stack) { - ItemNBTHelper.setBoolean(stack, TAG_CREATIVE, true); - } - - public static boolean isStackCreative(ItemStack stack) { - return ItemNBTHelper.getBoolean(stack, TAG_CREATIVE, false); - } - - @Override - public int getMana(ItemStack stack) { - return ItemNBTHelper.getInt(stack, TAG_MANA, 0); - } - - @Override - public int getMaxMana(ItemStack stack) { - return isStackCreative(stack) ? MAX_MANA + 1000 : MAX_MANA; - } - - @Override - public void addMana(ItemStack stack, int mana) { - if(!isStackCreative(stack)) - setMana(stack, Math.min(getMana(stack) + mana, MAX_MANA)); - } - - @Override - public boolean canReceiveManaFromPool(ItemStack stack, TileEntity pool) { - return !ItemNBTHelper.getBoolean(stack, TAG_ONE_USE, false); - } - - @Override - public boolean canReceiveManaFromItem(ItemStack stack, ItemStack otherStack) { - return !isCreative(stack); - } - - @Override - public boolean canExportManaToPool(ItemStack stack, TileEntity pool) { - return true; - } - - @Override - public boolean canExportManaToItem(ItemStack stack, ItemStack otherStack) { - return true; - } - - @Override - public boolean isNoExport(ItemStack stack) { - return false; - } - - @Override - public boolean isCreative(ItemStack stack) { - return isStackCreative(stack); - } - - @Override - public float getManaFractionForDisplay(ItemStack stack) { - return (float) getMana(stack) / (float) getMaxMana(stack); - } - - - @Override - public boolean showDurabilityBar(ItemStack stack) { - // If the stack is not creative, show the durability bar. - return !isStackCreative(stack); - } - - @Override - public double getDurabilityForDisplay(ItemStack stack) { - // I believe Forge has their durability values swapped, hence the (1.0 -). - // This will probably be fixed soon. - return 1.0 - getManaFractionForDisplay(stack); - } + IIcon[] icons; + + private static final int MAX_MANA = 500000; + + private static final String TAG_MANA = "mana"; + private static final String TAG_CREATIVE = "creative"; + private static final String TAG_ONE_USE = "oneUse"; + + public ItemManaTablet() { + super(); + setMaxStackSize(1); + setMaxDamage(1000); + setUnlocalizedName(LibItemNames.MANA_TABLET); + setNoRepair(); + } + + @Override + public void getSubItems(Item par1, CreativeTabs par2CreativeTabs, List par3List) { + // Empty tablet + par3List.add(new ItemStack(par1, 1)); + + // Full tablet + ItemStack fullPower = new ItemStack(par1, 1); + setMana(fullPower, MAX_MANA); + par3List.add(fullPower); + + // Creative Tablet + ItemStack creative = new ItemStack(par1, 1); + setMana(creative, MAX_MANA); + setStackCreative(creative); + par3List.add(creative); + } + + @Override + public int getColorFromItemStack(ItemStack par1ItemStack, int par2) { + float mana = getMana(par1ItemStack); + return par2 == 1 ? Color.HSBtoRGB(0.528F, mana / MAX_MANA, 1F) : 0xFFFFFF; + } + + @Override + public int getDamage(ItemStack stack) { + // Compatibility shim, so tablets from previous versions of botania + // stack right in barrels and so forth + if (super.getDamage(stack) != 0) super.setDamage(stack, 0); + + return 0; + } + + @Override + public void registerIcons(IIconRegister par1IconRegister) { + icons = new IIcon[2]; + for (int i = 0; i < icons.length; i++) icons[i] = IconHelper.forItem(par1IconRegister, this, i); + } + + @Override + public IIcon getIcon(ItemStack stack, int pass) { + return icons[Math.min(1, pass)]; + } + + @Override + public void addInformation(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, List par3List, boolean par4) { + if (isStackCreative(par1ItemStack)) par3List.add(StatCollector.translateToLocal("botaniamisc.creative")); + } + + @Override + public boolean requiresMultipleRenderPasses() { + return true; + } + + @Override + public int getEntityLifespan(ItemStack itemStack, World world) { + return Integer.MAX_VALUE; + } + + public static void setMana(ItemStack stack, int mana) { + ItemNBTHelper.setInt(stack, TAG_MANA, mana); + } + + public static void setStackCreative(ItemStack stack) { + ItemNBTHelper.setBoolean(stack, TAG_CREATIVE, true); + } + + public static boolean isStackCreative(ItemStack stack) { + return ItemNBTHelper.getBoolean(stack, TAG_CREATIVE, false); + } + + @Override + public int getMana(ItemStack stack) { + return ItemNBTHelper.getInt(stack, TAG_MANA, 0); + } + + @Override + public int getMaxMana(ItemStack stack) { + return isStackCreative(stack) ? MAX_MANA + 1000 : MAX_MANA; + } + + @Override + public void addMana(ItemStack stack, int mana) { + if (!isStackCreative(stack)) setMana(stack, Math.min(getMana(stack) + mana, MAX_MANA)); + } + + @Override + public boolean canReceiveManaFromPool(ItemStack stack, TileEntity pool) { + return !ItemNBTHelper.getBoolean(stack, TAG_ONE_USE, false); + } + + @Override + public boolean canReceiveManaFromItem(ItemStack stack, ItemStack otherStack) { + return !isCreative(stack); + } + + @Override + public boolean canExportManaToPool(ItemStack stack, TileEntity pool) { + return true; + } + + @Override + public boolean canExportManaToItem(ItemStack stack, ItemStack otherStack) { + return true; + } + + @Override + public boolean isNoExport(ItemStack stack) { + return false; + } + + @Override + public boolean isCreative(ItemStack stack) { + return isStackCreative(stack); + } + + @Override + public float getManaFractionForDisplay(ItemStack stack) { + return (float) getMana(stack) / (float) getMaxMana(stack); + } + + @Override + public boolean showDurabilityBar(ItemStack stack) { + // If the stack is not creative, show the durability bar. + return !isStackCreative(stack); + } + + @Override + public double getDurabilityForDisplay(ItemStack stack) { + // I believe Forge has their durability values swapped, hence the (1.0 -). + // This will probably be fixed soon. + return 1.0 - getManaFractionForDisplay(stack); + } } diff --git a/src/main/java/vazkii/botania/common/item/ItemMod.java b/src/main/java/vazkii/botania/common/item/ItemMod.java index 4e20174df1..41868acf79 100644 --- a/src/main/java/vazkii/botania/common/item/ItemMod.java +++ b/src/main/java/vazkii/botania/common/item/ItemMod.java @@ -2,45 +2,46 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jan 14, 2014, 5:30:18 PM (GMT)] */ package vazkii.botania.common.item; +import cpw.mods.fml.common.registry.GameRegistry; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import vazkii.botania.client.core.helper.IconHelper; import vazkii.botania.client.lib.LibResources; import vazkii.botania.common.core.BotaniaCreativeTab; -import cpw.mods.fml.common.registry.GameRegistry; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; public class ItemMod extends Item { - public ItemMod() { - super(); - setCreativeTab(BotaniaCreativeTab.INSTANCE); - } + public ItemMod() { + super(); + setCreativeTab(BotaniaCreativeTab.INSTANCE); + } - @Override - public Item setUnlocalizedName(String par1Str) { - GameRegistry.registerItem(this, par1Str); - return super.setUnlocalizedName(par1Str); - } + @Override + public Item setUnlocalizedName(String par1Str) { + GameRegistry.registerItem(this, par1Str); + return super.setUnlocalizedName(par1Str); + } - @Override - public String getUnlocalizedNameInefficiently(ItemStack par1ItemStack) { - return super.getUnlocalizedNameInefficiently(par1ItemStack).replaceAll("item\\.", "item." + LibResources.PREFIX_MOD); - } + @Override + public String getUnlocalizedNameInefficiently(ItemStack par1ItemStack) { + return super.getUnlocalizedNameInefficiently(par1ItemStack) + .replaceAll("item\\.", "item." + LibResources.PREFIX_MOD); + } - @Override - @SideOnly(Side.CLIENT) - public void registerIcons(IIconRegister par1IconRegister) { - itemIcon = IconHelper.forItem(par1IconRegister, this); - } -} \ No newline at end of file + @Override + @SideOnly(Side.CLIENT) + public void registerIcons(IIconRegister par1IconRegister) { + itemIcon = IconHelper.forItem(par1IconRegister, this); + } +} diff --git a/src/main/java/vazkii/botania/common/item/ItemObedienceStick.java b/src/main/java/vazkii/botania/common/item/ItemObedienceStick.java index acce895e6b..43b0570006 100644 --- a/src/main/java/vazkii/botania/common/item/ItemObedienceStick.java +++ b/src/main/java/vazkii/botania/common/item/ItemObedienceStick.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jul 20, 2015, 7:26:14 PM (GMT)] */ package vazkii.botania.common.item; @@ -26,74 +26,78 @@ public class ItemObedienceStick extends ItemMod { - public ItemObedienceStick() { - setMaxStackSize(1); - setUnlocalizedName(LibItemNames.OBEDIENCE_STICK); - } - - @Override - public boolean onItemUse(ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int s, float xs, float ys, float zs) { - TileEntity tileAt = world.getTileEntity(x, y, z); - if(tileAt != null && (tileAt instanceof IManaPool || tileAt instanceof IManaCollector)) { - boolean pool = tileAt instanceof IManaPool; - Actuator act = pool ? Actuator.functionalActuator : Actuator.generatingActuator; - int range = pool ? SubTileFunctional.RANGE : SubTileGenerating.RANGE; - - for(int i = -range; i < range + 1; i++) - for(int j = -range; j < range + 1; j++) - for(int k = -range; k < range + 1; k++) { - int xp = x + i; - int yp = y + j; - int zp = z + k; - if(MathHelper.pointDistanceSpace(xp, yp, zp, x, y, z) > range) - continue; - - TileEntity tile = world.getTileEntity(xp, yp, zp); - if(tile instanceof ISubTileContainer) { - SubTileEntity subtile = ((ISubTileContainer) tile).getSubTile(); - if(act.actuate(subtile, tileAt)) { - Vector3 orig = new Vector3(xp + 0.5, yp + 0.5, zp + 0.5); - Vector3 end = new Vector3(x + 0.5, y + 0.5, z + 0.5); - ItemTwigWand.doParticleBeam(world, orig, end); - } - } - } - - if(player.worldObj.isRemote) - player.swingItem(); - } - return false; - } - - public static abstract class Actuator { - public static final Actuator generatingActuator = new Actuator() { - - @Override - public boolean actuate(SubTileEntity flower, TileEntity tile) { - if(flower instanceof SubTileGenerating) { - ((SubTileGenerating) flower).linkToForcefully(tile); - return true; - } - return false; - } - - }; - - public static final Actuator functionalActuator = new Actuator() { - - @Override - public boolean actuate(SubTileEntity flower, TileEntity tile) { - if(flower instanceof SubTileFunctional) { - ((SubTileFunctional) flower).linkToForcefully(tile); - return true; - } - return false; - } - - }; - - public abstract boolean actuate(SubTileEntity flower, TileEntity tile); - - } - + public ItemObedienceStick() { + setMaxStackSize(1); + setUnlocalizedName(LibItemNames.OBEDIENCE_STICK); + } + + @Override + public boolean onItemUse( + ItemStack stack, + EntityPlayer player, + World world, + int x, + int y, + int z, + int s, + float xs, + float ys, + float zs) { + TileEntity tileAt = world.getTileEntity(x, y, z); + if (tileAt != null && (tileAt instanceof IManaPool || tileAt instanceof IManaCollector)) { + boolean pool = tileAt instanceof IManaPool; + Actuator act = pool ? Actuator.functionalActuator : Actuator.generatingActuator; + int range = pool ? SubTileFunctional.RANGE : SubTileGenerating.RANGE; + + for (int i = -range; i < range + 1; i++) + for (int j = -range; j < range + 1; j++) + for (int k = -range; k < range + 1; k++) { + int xp = x + i; + int yp = y + j; + int zp = z + k; + if (MathHelper.pointDistanceSpace(xp, yp, zp, x, y, z) > range) continue; + + TileEntity tile = world.getTileEntity(xp, yp, zp); + if (tile instanceof ISubTileContainer) { + SubTileEntity subtile = ((ISubTileContainer) tile).getSubTile(); + if (act.actuate(subtile, tileAt)) { + Vector3 orig = new Vector3(xp + 0.5, yp + 0.5, zp + 0.5); + Vector3 end = new Vector3(x + 0.5, y + 0.5, z + 0.5); + ItemTwigWand.doParticleBeam(world, orig, end); + } + } + } + + if (player.worldObj.isRemote) player.swingItem(); + } + return false; + } + + public abstract static class Actuator { + public static final Actuator generatingActuator = new Actuator() { + + @Override + public boolean actuate(SubTileEntity flower, TileEntity tile) { + if (flower instanceof SubTileGenerating) { + ((SubTileGenerating) flower).linkToForcefully(tile); + return true; + } + return false; + } + }; + + public static final Actuator functionalActuator = new Actuator() { + + @Override + public boolean actuate(SubTileEntity flower, TileEntity tile) { + if (flower instanceof SubTileFunctional) { + ((SubTileFunctional) flower).linkToForcefully(tile); + return true; + } + return false; + } + }; + + public abstract boolean actuate(SubTileEntity flower, TileEntity tile); + } } diff --git a/src/main/java/vazkii/botania/common/item/ItemOpenBucket.java b/src/main/java/vazkii/botania/common/item/ItemOpenBucket.java index 8acc06d907..75474346f8 100644 --- a/src/main/java/vazkii/botania/common/item/ItemOpenBucket.java +++ b/src/main/java/vazkii/botania/common/item/ItemOpenBucket.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jun 20, 2014, 12:12:58 AM (GMT)] */ package vazkii.botania.common.item; @@ -15,49 +15,47 @@ import net.minecraft.item.ItemStack; import net.minecraft.util.MovingObjectPosition; import net.minecraft.world.World; -import vazkii.botania.common.block.subtile.functional.SubTileSpectranthemum; import vazkii.botania.common.lib.LibItemNames; public class ItemOpenBucket extends ItemMod { - public ItemOpenBucket() { - setMaxStackSize(1); - setUnlocalizedName(LibItemNames.OPEN_BUCKET); - } - - @Override - public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer) { - MovingObjectPosition movingobjectposition = getMovingObjectPositionFromPlayer(par2World, par3EntityPlayer, true); - - if(movingobjectposition == null) - return par1ItemStack; - else { - if(movingobjectposition.typeOfHit == MovingObjectPosition.MovingObjectType.BLOCK) { - int i = movingobjectposition.blockX; - int j = movingobjectposition.blockY; - int k = movingobjectposition.blockZ; - - if(!par2World.canMineBlock(par3EntityPlayer, i, j, k)) - return par1ItemStack; - - if(!par3EntityPlayer.canPlayerEdit(i, j, k, movingobjectposition.sideHit, par1ItemStack)) - return par1ItemStack; - - Material material = par2World.getBlock(i, j, k).getMaterial(); - int l = par2World.getBlockMetadata(i, j, k); - - if((material == Material.lava || material == Material.water) && l == 0) { - par2World.setBlockToAir(i, j, k); - - for(int x = 0; x < 5; x++) - par2World.spawnParticle("explode", i + Math.random(), j + Math.random(), k + Math.random(), 0, 0, 0); - - return par1ItemStack; - } - } - - return par1ItemStack; - } - } + public ItemOpenBucket() { + setMaxStackSize(1); + setUnlocalizedName(LibItemNames.OPEN_BUCKET); + } + @Override + public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer) { + MovingObjectPosition movingobjectposition = + getMovingObjectPositionFromPlayer(par2World, par3EntityPlayer, true); + + if (movingobjectposition == null) return par1ItemStack; + else { + if (movingobjectposition.typeOfHit == MovingObjectPosition.MovingObjectType.BLOCK) { + int i = movingobjectposition.blockX; + int j = movingobjectposition.blockY; + int k = movingobjectposition.blockZ; + + if (!par2World.canMineBlock(par3EntityPlayer, i, j, k)) return par1ItemStack; + + if (!par3EntityPlayer.canPlayerEdit(i, j, k, movingobjectposition.sideHit, par1ItemStack)) + return par1ItemStack; + + Material material = par2World.getBlock(i, j, k).getMaterial(); + int l = par2World.getBlockMetadata(i, j, k); + + if ((material == Material.lava || material == Material.water) && l == 0) { + par2World.setBlockToAir(i, j, k); + + for (int x = 0; x < 5; x++) + par2World.spawnParticle( + "explode", i + Math.random(), j + Math.random(), k + Math.random(), 0, 0, 0); + + return par1ItemStack; + } + } + + return par1ItemStack; + } + } } diff --git a/src/main/java/vazkii/botania/common/item/ItemOvergrowthSeed.java b/src/main/java/vazkii/botania/common/item/ItemOvergrowthSeed.java index fd9c25a08c..e5975274f5 100644 --- a/src/main/java/vazkii/botania/common/item/ItemOvergrowthSeed.java +++ b/src/main/java/vazkii/botania/common/item/ItemOvergrowthSeed.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jan 26, 2015, 5:59:21 PM (GMT)] */ package vazkii.botania.common.item; @@ -20,26 +20,35 @@ public class ItemOvergrowthSeed extends ItemMod { - public ItemOvergrowthSeed() { - setUnlocalizedName(LibItemNames.OVERGROWTH_SEED); - } + public ItemOvergrowthSeed() { + setUnlocalizedName(LibItemNames.OVERGROWTH_SEED); + } - @Override - public boolean onItemUse(ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int s, float xs, float ys, float zs) { - Block block = world.getBlock(x, y, z); - ItemStack blockStack = new ItemStack(block); - int[] ids = OreDictionary.getOreIDs(blockStack); - for(int i : ids) { - String name = OreDictionary.getOreName(i); - if(name.equals("grass")) { - world.playAuxSFX(2001, x, y, z, Block.getIdFromBlock(block)); - world.setBlock(x, y, z, ModBlocks.enchantedSoil); - stack.stackSize--; - - return true; - } - } - return false; - } + @Override + public boolean onItemUse( + ItemStack stack, + EntityPlayer player, + World world, + int x, + int y, + int z, + int s, + float xs, + float ys, + float zs) { + Block block = world.getBlock(x, y, z); + ItemStack blockStack = new ItemStack(block); + int[] ids = OreDictionary.getOreIDs(blockStack); + for (int i : ids) { + String name = OreDictionary.getOreName(i); + if (name.equals("grass")) { + world.playAuxSFX(2001, x, y, z, Block.getIdFromBlock(block)); + world.setBlock(x, y, z, ModBlocks.enchantedSoil); + stack.stackSize--; + return true; + } + } + return false; + } } diff --git a/src/main/java/vazkii/botania/common/item/ItemPhantomInk.java b/src/main/java/vazkii/botania/common/item/ItemPhantomInk.java index c3a90547b0..eff12a9530 100644 --- a/src/main/java/vazkii/botania/common/item/ItemPhantomInk.java +++ b/src/main/java/vazkii/botania/common/item/ItemPhantomInk.java @@ -2,26 +2,25 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Mar 17, 2015, 4:46:36 PM (GMT)] */ package vazkii.botania.common.item; +import cpw.mods.fml.common.registry.GameRegistry; import net.minecraftforge.oredict.RecipeSorter; import net.minecraftforge.oredict.RecipeSorter.Category; import vazkii.botania.common.crafting.recipe.PhantomInkRecipe; import vazkii.botania.common.lib.LibItemNames; -import cpw.mods.fml.common.registry.GameRegistry; public class ItemPhantomInk extends ItemMod { - public ItemPhantomInk() { - setUnlocalizedName(LibItemNames.PHANTOM_INK); - GameRegistry.addRecipe(new PhantomInkRecipe()); - RecipeSorter.register("botania:phantomInk", PhantomInkRecipe.class, Category.SHAPELESS, ""); - } - + public ItemPhantomInk() { + setUnlocalizedName(LibItemNames.PHANTOM_INK); + GameRegistry.addRecipe(new PhantomInkRecipe()); + RecipeSorter.register("botania:phantomInk", PhantomInkRecipe.class, Category.SHAPELESS, ""); + } } diff --git a/src/main/java/vazkii/botania/common/item/ItemPinkinator.java b/src/main/java/vazkii/botania/common/item/ItemPinkinator.java index d684432db1..e6bf2536c4 100644 --- a/src/main/java/vazkii/botania/common/item/ItemPinkinator.java +++ b/src/main/java/vazkii/botania/common/item/ItemPinkinator.java @@ -2,16 +2,15 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Mar 25, 2015, 6:03:28 PM (GMT)] */ package vazkii.botania.common.item; import java.util.List; - import net.minecraft.entity.boss.EntityWither; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; @@ -24,38 +23,50 @@ public class ItemPinkinator extends ItemMod { - public ItemPinkinator() { - setUnlocalizedName(LibItemNames.PINKINATOR); - setMaxStackSize(1); - setFull3D(); - } - - @Override - public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer player) { - int range = 16; - List withers = world.getEntitiesWithinAABB(EntityWither.class, AxisAlignedBB.getBoundingBox(player.posX - range, player.posY - range, player.posZ - range, player.posX + range, player.posY + range, player.posZ + range)); - for(EntityWither wither : withers) - if(!wither.isDead && !(wither instanceof EntityPinkWither)) { - if(!world.isRemote) { - wither.setDead(); - EntityPinkWither pink = new EntityPinkWither(world); - pink.setLocationAndAngles(wither.posX, wither.posY, wither.posZ, wither.rotationYaw, wither.rotationPitch); - world.spawnEntityInWorld(pink); - world.playSoundAtEntity(wither, "random.explode", 4F, (1F + (world.rand.nextFloat() - world.rand.nextFloat()) * 0.2F) * 0.7F); - } - player.addStat(ModAchievements.pinkinator, 1); + public ItemPinkinator() { + setUnlocalizedName(LibItemNames.PINKINATOR); + setMaxStackSize(1); + setFull3D(); + } - world.spawnParticle("hugeexplosion", wither.posX, wither.posY, wither.posZ, 1D, 0D, 0D); - stack.stackSize--; - return stack; - } + @Override + public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer player) { + int range = 16; + List withers = world.getEntitiesWithinAABB( + EntityWither.class, + AxisAlignedBB.getBoundingBox( + player.posX - range, + player.posY - range, + player.posZ - range, + player.posX + range, + player.posY + range, + player.posZ + range)); + for (EntityWither wither : withers) + if (!wither.isDead && !(wither instanceof EntityPinkWither)) { + if (!world.isRemote) { + wither.setDead(); + EntityPinkWither pink = new EntityPinkWither(world); + pink.setLocationAndAngles( + wither.posX, wither.posY, wither.posZ, wither.rotationYaw, wither.rotationPitch); + world.spawnEntityInWorld(pink); + world.playSoundAtEntity( + wither, + "random.explode", + 4F, + (1F + (world.rand.nextFloat() - world.rand.nextFloat()) * 0.2F) * 0.7F); + } + player.addStat(ModAchievements.pinkinator, 1); - return stack; - } + world.spawnParticle("hugeexplosion", wither.posX, wither.posY, wither.posZ, 1D, 0D, 0D); + stack.stackSize--; + return stack; + } - @Override - public void addInformation(ItemStack p_77624_1_, EntityPlayer p_77624_2_, List p_77624_3_, boolean p_77624_4_) { - p_77624_3_.add(StatCollector.translateToLocal("botaniamisc.pinkinatorDesc")); - } + return stack; + } + @Override + public void addInformation(ItemStack p_77624_1_, EntityPlayer p_77624_2_, List p_77624_3_, boolean p_77624_4_) { + p_77624_3_.add(StatCollector.translateToLocal("botaniamisc.pinkinatorDesc")); + } } diff --git a/src/main/java/vazkii/botania/common/item/ItemPoolMinecart.java b/src/main/java/vazkii/botania/common/item/ItemPoolMinecart.java index 248d72917c..43f6409934 100644 --- a/src/main/java/vazkii/botania/common/item/ItemPoolMinecart.java +++ b/src/main/java/vazkii/botania/common/item/ItemPoolMinecart.java @@ -2,14 +2,16 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Mar 17, 2015, 6:48:29 PM (GMT)] */ package vazkii.botania.common.item; +import com.mojang.authlib.GameProfile; +import cpw.mods.fml.common.Optional; import mods.railcraft.api.core.items.IMinecartItem; import net.minecraft.block.BlockRailBase; import net.minecraft.entity.item.EntityMinecart; @@ -23,61 +25,64 @@ import vazkii.botania.common.entity.EntityPoolMinecart; import vazkii.botania.common.lib.LibItemNames; -import com.mojang.authlib.GameProfile; - -import cpw.mods.fml.common.Optional; - @Optional.Interface(modid = "Railcraft", iface = "mods.railcraft.api.core.items.IMinecartItem", striprefs = true) public class ItemPoolMinecart extends ItemMod implements ICraftAchievement, IMinecartItem { - public ItemPoolMinecart() { - setMaxStackSize(1); - setUnlocalizedName(LibItemNames.POOL_MINECART); - } - - @Override - public boolean onItemUse(ItemStack p_77648_1_, EntityPlayer p_77648_2_, World p_77648_3_, int p_77648_4_, int p_77648_5_, int p_77648_6_, int p_77648_7_, float p_77648_8_, float p_77648_9_, float p_77648_10_) { - if(BlockRailBase.func_150051_a(p_77648_3_.getBlock(p_77648_4_, p_77648_5_, p_77648_6_))) { - if(!p_77648_3_.isRemote) { - EntityMinecart entityminecart = new EntityPoolMinecart(p_77648_3_, p_77648_4_ + 0.5, p_77648_5_ + 0.5, p_77648_6_ + 0.5); - - if(p_77648_1_.hasDisplayName()) - entityminecart.setMinecartName(p_77648_1_.getDisplayName()); - - p_77648_3_.spawnEntityInWorld(entityminecart); - } - - --p_77648_1_.stackSize; - return true; - } - - return false; - } - - @Override - public Achievement getAchievementOnCraft(ItemStack stack, EntityPlayer player, IInventory matrix) { - return ModAchievements.manaCartCraft; - } - - @Override - public boolean canBePlacedByNonPlayer(ItemStack cart) { - return true; - } - - @Override - public EntityMinecart placeCart(GameProfile owner, ItemStack cart, World world, int i, int j, int k) { - if(BlockRailBase.func_150051_a(world.getBlock(i, j, k))) { - if(!world.isRemote) { - EntityMinecart entityminecart = new EntityPoolMinecart(world, i + 0.5,j + 0.5, k + 0.5); - - if(cart.hasDisplayName()) - entityminecart.setMinecartName(cart.getDisplayName()); - - if(world.spawnEntityInWorld(entityminecart)) - return entityminecart; - } - } - return null; - } - + public ItemPoolMinecart() { + setMaxStackSize(1); + setUnlocalizedName(LibItemNames.POOL_MINECART); + } + + @Override + public boolean onItemUse( + ItemStack p_77648_1_, + EntityPlayer p_77648_2_, + World p_77648_3_, + int p_77648_4_, + int p_77648_5_, + int p_77648_6_, + int p_77648_7_, + float p_77648_8_, + float p_77648_9_, + float p_77648_10_) { + if (BlockRailBase.func_150051_a(p_77648_3_.getBlock(p_77648_4_, p_77648_5_, p_77648_6_))) { + if (!p_77648_3_.isRemote) { + EntityMinecart entityminecart = + new EntityPoolMinecart(p_77648_3_, p_77648_4_ + 0.5, p_77648_5_ + 0.5, p_77648_6_ + 0.5); + + if (p_77648_1_.hasDisplayName()) entityminecart.setMinecartName(p_77648_1_.getDisplayName()); + + p_77648_3_.spawnEntityInWorld(entityminecart); + } + + --p_77648_1_.stackSize; + return true; + } + + return false; + } + + @Override + public Achievement getAchievementOnCraft(ItemStack stack, EntityPlayer player, IInventory matrix) { + return ModAchievements.manaCartCraft; + } + + @Override + public boolean canBePlacedByNonPlayer(ItemStack cart) { + return true; + } + + @Override + public EntityMinecart placeCart(GameProfile owner, ItemStack cart, World world, int i, int j, int k) { + if (BlockRailBase.func_150051_a(world.getBlock(i, j, k))) { + if (!world.isRemote) { + EntityMinecart entityminecart = new EntityPoolMinecart(world, i + 0.5, j + 0.5, k + 0.5); + + if (cart.hasDisplayName()) entityminecart.setMinecartName(cart.getDisplayName()); + + if (world.spawnEntityInWorld(entityminecart)) return entityminecart; + } + } + return null; + } } diff --git a/src/main/java/vazkii/botania/common/item/ItemRegenIvy.java b/src/main/java/vazkii/botania/common/item/ItemRegenIvy.java index 20d7254304..2a0f8091b6 100644 --- a/src/main/java/vazkii/botania/common/item/ItemRegenIvy.java +++ b/src/main/java/vazkii/botania/common/item/ItemRegenIvy.java @@ -2,14 +2,20 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Sep 3, 2014, 6:31:10 PM (GMT)] */ package vazkii.botania.common.item; +import cpw.mods.fml.common.FMLCommonHandler; +import cpw.mods.fml.common.eventhandler.EventPriority; +import cpw.mods.fml.common.eventhandler.SubscribeEvent; +import cpw.mods.fml.common.gameevent.TickEvent.Phase; +import cpw.mods.fml.common.gameevent.TickEvent.PlayerTickEvent; +import cpw.mods.fml.common.registry.GameRegistry; import net.minecraft.item.ItemStack; import net.minecraftforge.oredict.RecipeSorter; import net.minecraftforge.oredict.RecipeSorter.Category; @@ -17,32 +23,30 @@ import vazkii.botania.common.core.helper.ItemNBTHelper; import vazkii.botania.common.crafting.recipe.RegenIvyRecipe; import vazkii.botania.common.lib.LibItemNames; -import cpw.mods.fml.common.FMLCommonHandler; -import cpw.mods.fml.common.eventhandler.EventPriority; -import cpw.mods.fml.common.eventhandler.SubscribeEvent; -import cpw.mods.fml.common.gameevent.TickEvent.Phase; -import cpw.mods.fml.common.gameevent.TickEvent.PlayerTickEvent; -import cpw.mods.fml.common.registry.GameRegistry; public class ItemRegenIvy extends ItemMod { - public static final String TAG_REGEN = "Botania_regenIvy"; - private static final int MANA_PER_DAMAGE = 200; + public static final String TAG_REGEN = "Botania_regenIvy"; + private static final int MANA_PER_DAMAGE = 200; - public ItemRegenIvy() { - setUnlocalizedName(LibItemNames.REGEN_IVY); - GameRegistry.addRecipe(new RegenIvyRecipe()); - RecipeSorter.register("botania:regenIvy", RegenIvyRecipe.class, Category.SHAPELESS, ""); - FMLCommonHandler.instance().bus().register(this); - } + public ItemRegenIvy() { + setUnlocalizedName(LibItemNames.REGEN_IVY); + GameRegistry.addRecipe(new RegenIvyRecipe()); + RecipeSorter.register("botania:regenIvy", RegenIvyRecipe.class, Category.SHAPELESS, ""); + FMLCommonHandler.instance().bus().register(this); + } - @SubscribeEvent(priority = EventPriority.LOWEST) - public void onTick(PlayerTickEvent event) { - if(event.phase == Phase.END && !event.player.worldObj.isRemote) - for(int i = 0; i < event.player.inventory.getSizeInventory(); i++) { - ItemStack stack = event.player.inventory.getStackInSlot(i); - if(stack != null && ItemNBTHelper.detectNBT(stack) && ItemNBTHelper.getBoolean(stack, TAG_REGEN, false) && stack.getItemDamage() > 0 && ManaItemHandler.requestManaExact(stack, event.player, MANA_PER_DAMAGE, true)) - stack.setItemDamage(stack.getItemDamage() - 1); - } - } + @SubscribeEvent(priority = EventPriority.LOWEST) + public void onTick(PlayerTickEvent event) { + if (event.phase == Phase.END && !event.player.worldObj.isRemote) + for (int i = 0; i < event.player.inventory.getSizeInventory(); i++) { + ItemStack stack = event.player.inventory.getStackInSlot(i); + if (stack != null + && ItemNBTHelper.detectNBT(stack) + && ItemNBTHelper.getBoolean(stack, TAG_REGEN, false) + && stack.getItemDamage() > 0 + && ManaItemHandler.requestManaExact(stack, event.player, MANA_PER_DAMAGE, true)) + stack.setItemDamage(stack.getItemDamage() - 1); + } + } } diff --git a/src/main/java/vazkii/botania/common/item/ItemSextant.java b/src/main/java/vazkii/botania/common/item/ItemSextant.java index fff78921f6..14ec92f04a 100644 --- a/src/main/java/vazkii/botania/common/item/ItemSextant.java +++ b/src/main/java/vazkii/botania/common/item/ItemSextant.java @@ -2,14 +2,16 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [01/11/2015, 18:25:54 (GMT)] */ package vazkii.botania.common.item; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.FontRenderer; import net.minecraft.client.gui.ScaledResolution; @@ -19,9 +21,7 @@ import net.minecraft.item.ItemStack; import net.minecraft.util.MovingObjectPosition; import net.minecraft.world.World; - import org.lwjgl.opengl.GL11; - import vazkii.botania.api.lexicon.multiblock.Multiblock; import vazkii.botania.common.Botania; import vazkii.botania.common.core.helper.ItemNBTHelper; @@ -29,145 +29,139 @@ import vazkii.botania.common.core.helper.Vector3; import vazkii.botania.common.item.equipment.tool.ToolCommons; import vazkii.botania.common.lib.LibItemNames; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; public class ItemSextant extends ItemMod { - private static final String TAG_SOURCE_X = "sourceX"; - private static final String TAG_SOURCE_Y = "sourceY"; - private static final String TAG_SOURCE_Z = "sourceZ"; - - public ItemSextant() { - setUnlocalizedName(LibItemNames.SEXTANT); - setMaxStackSize(1); - } - - @Override - public EnumAction getItemUseAction(ItemStack par1ItemStack) { - return EnumAction.bow; - } - - @Override - public int getMaxItemUseDuration(ItemStack par1ItemStack) { - return 72000; - } - - @Override - public void onUsingTick(ItemStack stack, EntityPlayer player, int count) { - if(getMaxItemUseDuration(stack) - count < 10) - return; - - int x = ItemNBTHelper.getInt(stack, TAG_SOURCE_X, 0); - int y = ItemNBTHelper.getInt(stack, TAG_SOURCE_Y, -1); - int z = ItemNBTHelper.getInt(stack, TAG_SOURCE_Z, 0); - if(y != -1) { - World world = player.worldObj; - Vector3 source = new Vector3(x, y, z); - - double radius = calculateRadius(stack, player); - - if(count % 10 == 0) - for(int i = 0; i < 360; i++) { - float radian = (float) (i * Math.PI / 180); - double xp = x + Math.cos(radian) * radius; - double zp = z + Math.sin(radian) * radius; - Botania.proxy.wispFX(world, xp + 0.5, source.y + 1, zp + 0.5, 0F, 1F, 1F, 0.3F, -0.01F); - } - } - } - - @Override - public void onPlayerStoppedUsing(ItemStack stack, World world, EntityPlayer player, int time) { - double radius = calculateRadius(stack, player); - if(radius > 1) { - int x = ItemNBTHelper.getInt(stack, TAG_SOURCE_X, 0); - int y = ItemNBTHelper.getInt(stack, TAG_SOURCE_Y, -1); - int z = ItemNBTHelper.getInt(stack, TAG_SOURCE_Z, 0); - if(y != -1) - Botania.proxy.setMultiblock(world, x, y, z, radius, Blocks.cobblestone); - } - } - - @Override - public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer) { - Botania.proxy.removeSextantMultiblock(); - - if(!par3EntityPlayer.isSneaking()) { - MovingObjectPosition pos = ToolCommons.raytraceFromEntity(par2World, par3EntityPlayer, false, 128); - if(pos != null && pos.entityHit == null) { - if(!par2World.isRemote) { - ItemNBTHelper.setInt(par1ItemStack, TAG_SOURCE_X, pos.blockX); - ItemNBTHelper.setInt(par1ItemStack, TAG_SOURCE_Y, pos.blockY); - ItemNBTHelper.setInt(par1ItemStack, TAG_SOURCE_Z, pos.blockZ); - } - } else ItemNBTHelper.setInt(par1ItemStack, TAG_SOURCE_Y, -1); - - par3EntityPlayer.setItemInUse(par1ItemStack, getMaxItemUseDuration(par1ItemStack)); - } - - return par1ItemStack; - } - - public static double calculateRadius(ItemStack stack, EntityPlayer player) { - int x = ItemNBTHelper.getInt(stack, TAG_SOURCE_X, 0); - int y = ItemNBTHelper.getInt(stack, TAG_SOURCE_Y, -1); - int z = ItemNBTHelper.getInt(stack, TAG_SOURCE_Z, 0); - World world = player.worldObj; - Vector3 source = new Vector3(x, y, z); - Botania.proxy.wispFX(world, source.x + 0.5, source.y + 1, source.z + 0.5, 1F, 0F, 0F, 0.2F, -0.1F); - - Vector3 centerVec = Vector3.fromEntityCenter(player); - Vector3 diffVec = source.copy().subtract(centerVec); - Vector3 lookVec = new Vector3(player.getLookVec()); - double mul = diffVec.y / lookVec.y; - lookVec.multiply(mul).add(centerVec); - - lookVec.x = net.minecraft.util.MathHelper.floor_double(lookVec.x); - lookVec.z = net.minecraft.util.MathHelper.floor_double(lookVec.z); - - return MathHelper.pointDistancePlane(source.x, source.z, lookVec.x, lookVec.z); - } - - @SideOnly(Side.CLIENT) - public static void renderHUD(ScaledResolution resolution, EntityPlayer player, ItemStack stack) { - ItemStack onUse = player.getItemInUse(); - int time = player.getItemInUseCount(); - - if(onUse == stack && stack.getItem().getMaxItemUseDuration(stack) - time >= 10) { - double radius = calculateRadius(stack, player); - FontRenderer font = Minecraft.getMinecraft().fontRenderer; - int x = resolution.getScaledWidth() / 2 + 30; - int y = resolution.getScaledHeight() / 2; - - String s = "" + (int) radius; - font.drawStringWithShadow(s, x - font.getStringWidth(s) / 2, y - 4, 0xFFFFFF); - - if(radius > 0) { - radius += 4; - GL11.glDisable(GL11.GL_TEXTURE_2D); - GL11.glLineWidth(3F); - GL11.glBegin(GL11.GL_LINE_STRIP); - GL11.glColor4f(0F, 1F, 1F, 1F); - for(int i = 0; i < 361; i++) { - float radian = (float) (i * Math.PI / 180); - double xp = x + Math.cos(radian) * radius; - double yp = y + Math.sin(radian) * radius; - GL11.glVertex2d(xp, yp); - } - GL11.glEnd(); - GL11.glEnable(GL11.GL_TEXTURE_2D); - } - } - } - - public static class MultiblockSextant extends Multiblock { - - @Override - public Multiblock[] createRotations() { - return new Multiblock[] { this }; - } - - } - + private static final String TAG_SOURCE_X = "sourceX"; + private static final String TAG_SOURCE_Y = "sourceY"; + private static final String TAG_SOURCE_Z = "sourceZ"; + + public ItemSextant() { + setUnlocalizedName(LibItemNames.SEXTANT); + setMaxStackSize(1); + } + + @Override + public EnumAction getItemUseAction(ItemStack par1ItemStack) { + return EnumAction.bow; + } + + @Override + public int getMaxItemUseDuration(ItemStack par1ItemStack) { + return 72000; + } + + @Override + public void onUsingTick(ItemStack stack, EntityPlayer player, int count) { + if (getMaxItemUseDuration(stack) - count < 10) return; + + int x = ItemNBTHelper.getInt(stack, TAG_SOURCE_X, 0); + int y = ItemNBTHelper.getInt(stack, TAG_SOURCE_Y, -1); + int z = ItemNBTHelper.getInt(stack, TAG_SOURCE_Z, 0); + if (y != -1) { + World world = player.worldObj; + Vector3 source = new Vector3(x, y, z); + + double radius = calculateRadius(stack, player); + + if (count % 10 == 0) + for (int i = 0; i < 360; i++) { + float radian = (float) (i * Math.PI / 180); + double xp = x + Math.cos(radian) * radius; + double zp = z + Math.sin(radian) * radius; + Botania.proxy.wispFX(world, xp + 0.5, source.y + 1, zp + 0.5, 0F, 1F, 1F, 0.3F, -0.01F); + } + } + } + + @Override + public void onPlayerStoppedUsing(ItemStack stack, World world, EntityPlayer player, int time) { + double radius = calculateRadius(stack, player); + if (radius > 1) { + int x = ItemNBTHelper.getInt(stack, TAG_SOURCE_X, 0); + int y = ItemNBTHelper.getInt(stack, TAG_SOURCE_Y, -1); + int z = ItemNBTHelper.getInt(stack, TAG_SOURCE_Z, 0); + if (y != -1) Botania.proxy.setMultiblock(world, x, y, z, radius, Blocks.cobblestone); + } + } + + @Override + public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer) { + Botania.proxy.removeSextantMultiblock(); + + if (!par3EntityPlayer.isSneaking()) { + MovingObjectPosition pos = ToolCommons.raytraceFromEntity(par2World, par3EntityPlayer, false, 128); + if (pos != null && pos.entityHit == null) { + if (!par2World.isRemote) { + ItemNBTHelper.setInt(par1ItemStack, TAG_SOURCE_X, pos.blockX); + ItemNBTHelper.setInt(par1ItemStack, TAG_SOURCE_Y, pos.blockY); + ItemNBTHelper.setInt(par1ItemStack, TAG_SOURCE_Z, pos.blockZ); + } + } else ItemNBTHelper.setInt(par1ItemStack, TAG_SOURCE_Y, -1); + + par3EntityPlayer.setItemInUse(par1ItemStack, getMaxItemUseDuration(par1ItemStack)); + } + + return par1ItemStack; + } + + public static double calculateRadius(ItemStack stack, EntityPlayer player) { + int x = ItemNBTHelper.getInt(stack, TAG_SOURCE_X, 0); + int y = ItemNBTHelper.getInt(stack, TAG_SOURCE_Y, -1); + int z = ItemNBTHelper.getInt(stack, TAG_SOURCE_Z, 0); + World world = player.worldObj; + Vector3 source = new Vector3(x, y, z); + Botania.proxy.wispFX(world, source.x + 0.5, source.y + 1, source.z + 0.5, 1F, 0F, 0F, 0.2F, -0.1F); + + Vector3 centerVec = Vector3.fromEntityCenter(player); + Vector3 diffVec = source.copy().subtract(centerVec); + Vector3 lookVec = new Vector3(player.getLookVec()); + double mul = diffVec.y / lookVec.y; + lookVec.multiply(mul).add(centerVec); + + lookVec.x = net.minecraft.util.MathHelper.floor_double(lookVec.x); + lookVec.z = net.minecraft.util.MathHelper.floor_double(lookVec.z); + + return MathHelper.pointDistancePlane(source.x, source.z, lookVec.x, lookVec.z); + } + + @SideOnly(Side.CLIENT) + public static void renderHUD(ScaledResolution resolution, EntityPlayer player, ItemStack stack) { + ItemStack onUse = player.getItemInUse(); + int time = player.getItemInUseCount(); + + if (onUse == stack && stack.getItem().getMaxItemUseDuration(stack) - time >= 10) { + double radius = calculateRadius(stack, player); + FontRenderer font = Minecraft.getMinecraft().fontRenderer; + int x = resolution.getScaledWidth() / 2 + 30; + int y = resolution.getScaledHeight() / 2; + + String s = "" + (int) radius; + font.drawStringWithShadow(s, x - font.getStringWidth(s) / 2, y - 4, 0xFFFFFF); + + if (radius > 0) { + radius += 4; + GL11.glDisable(GL11.GL_TEXTURE_2D); + GL11.glLineWidth(3F); + GL11.glBegin(GL11.GL_LINE_STRIP); + GL11.glColor4f(0F, 1F, 1F, 1F); + for (int i = 0; i < 361; i++) { + float radian = (float) (i * Math.PI / 180); + double xp = x + Math.cos(radian) * radius; + double yp = y + Math.sin(radian) * radius; + GL11.glVertex2d(xp, yp); + } + GL11.glEnd(); + GL11.glEnable(GL11.GL_TEXTURE_2D); + } + } + } + + public static class MultiblockSextant extends Multiblock { + + @Override + public Multiblock[] createRotations() { + return new Multiblock[] {this}; + } + } } diff --git a/src/main/java/vazkii/botania/common/item/ItemSignalFlare.java b/src/main/java/vazkii/botania/common/item/ItemSignalFlare.java index c7a86d197b..2ee9dbabe5 100644 --- a/src/main/java/vazkii/botania/common/item/ItemSignalFlare.java +++ b/src/main/java/vazkii/botania/common/item/ItemSignalFlare.java @@ -2,17 +2,16 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Mar 3, 2014, 6:49:15 PM (GMT)] */ package vazkii.botania.common.item; import java.awt.Color; import java.util.List; - import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.entity.Entity; @@ -36,110 +35,120 @@ public class ItemSignalFlare extends ItemMod { - IIcon[] icons; - - private static final String TAG_COLOR = "color"; - - public ItemSignalFlare() { - super(); - setMaxStackSize(1); - setNoRepair(); - setMaxDamage(200); - setUnlocalizedName(LibItemNames.SIGNAL_FLARE); - } - - @Override - public boolean isFull3D() { - return true; - } - - @Override - public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer) { - if(par1ItemStack.getItemDamage() == 0) { - if(par2World.isRemote) - par3EntityPlayer.swingItem(); - else { - EntitySignalFlare flare = new EntitySignalFlare(par2World); - flare.setPosition(par3EntityPlayer.posX, par3EntityPlayer.posY, par3EntityPlayer.posZ); - flare.setColor(getColor(par1ItemStack)); - par2World.playSoundAtEntity(par3EntityPlayer, "random.explode", 40F, (1.0F + (par2World.rand.nextFloat() - par2World.rand.nextFloat()) * 0.2F) * 0.7F); - - par2World.spawnEntityInWorld(flare); - - int stunned = 0; - int range = 5; - List entities = par2World.getEntitiesWithinAABB(EntityLivingBase.class, AxisAlignedBB.getBoundingBox(par3EntityPlayer.posX - range, par3EntityPlayer.posY - range, par3EntityPlayer.posZ - range, par3EntityPlayer.posX + range, par3EntityPlayer.posY + range, par3EntityPlayer.posZ + range)); - for(EntityLivingBase entity : entities) - if(entity != par3EntityPlayer && (!(entity instanceof EntityPlayer) || MinecraftServer.getServer() == null || MinecraftServer.getServer().isPVPEnabled())) { - entity.addPotionEffect(new PotionEffect(Potion.moveSlowdown.id, 50, 5)); - stunned++; - } - - if(stunned >= 100) - par3EntityPlayer.addStat(ModAchievements.signalFlareStun, 1); - } - par1ItemStack.damageItem(200, par3EntityPlayer); - } - - return par1ItemStack; - } - - @Override - public void onUpdate(ItemStack par1ItemStack, World par2World, Entity par3Entity, int par4, boolean par5) { - if(par1ItemStack.isItemDamaged()) - par1ItemStack.setItemDamage(par1ItemStack.getItemDamage() - 1); - } - - @Override - public void registerIcons(IIconRegister par1IconRegister) { - icons = new IIcon[2]; - for(int i = 0; i < icons.length; i++) - icons[i] = IconHelper.forItem(par1IconRegister, this, i); - } - - @Override - public IIcon getIcon(ItemStack stack, int pass) { - return icons[Math.min(1, pass)]; - } - - @Override - public int getColorFromItemStack(ItemStack par1ItemStack, int par2) { - if(par2 == 0) - return 0xFFFFFF; - - int colorv = getColor(par1ItemStack); - if(colorv >= EntitySheep.fleeceColorTable.length || colorv < 0) - return 0xFFFFFF; - - float[] color = EntitySheep.fleeceColorTable[getColor(par1ItemStack)]; - return new Color(color[0], color[1], color[2]).getRGB(); - } - - @Override - public void getSubItems(Item par1, CreativeTabs par2CreativeTabs, List par3List) { - for(int i = 0; i < 16; i++) - par3List.add(forColor(i)); - } - - @Override - public boolean requiresMultipleRenderPasses() { - return true; - } - - @Override - public void addInformation(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, List par3List, boolean par4) { - int storedColor = getColor(par1ItemStack); - par3List.add(String.format(StatCollector.translateToLocal("botaniamisc.flareColor"), StatCollector.translateToLocal("botania.color" + storedColor))); - } - - public static ItemStack forColor(int color) { - ItemStack stack = new ItemStack(ModItems.signalFlare); - ItemNBTHelper.setInt(stack, TAG_COLOR, color); - - return stack; - } - - public static int getColor(ItemStack stack) { - return ItemNBTHelper.getInt(stack, TAG_COLOR, 0xFFFFFF); - } -} \ No newline at end of file + IIcon[] icons; + + private static final String TAG_COLOR = "color"; + + public ItemSignalFlare() { + super(); + setMaxStackSize(1); + setNoRepair(); + setMaxDamage(200); + setUnlocalizedName(LibItemNames.SIGNAL_FLARE); + } + + @Override + public boolean isFull3D() { + return true; + } + + @Override + public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer) { + if (par1ItemStack.getItemDamage() == 0) { + if (par2World.isRemote) par3EntityPlayer.swingItem(); + else { + EntitySignalFlare flare = new EntitySignalFlare(par2World); + flare.setPosition(par3EntityPlayer.posX, par3EntityPlayer.posY, par3EntityPlayer.posZ); + flare.setColor(getColor(par1ItemStack)); + par2World.playSoundAtEntity( + par3EntityPlayer, + "random.explode", + 40F, + (1.0F + (par2World.rand.nextFloat() - par2World.rand.nextFloat()) * 0.2F) * 0.7F); + + par2World.spawnEntityInWorld(flare); + + int stunned = 0; + int range = 5; + List entities = par2World.getEntitiesWithinAABB( + EntityLivingBase.class, + AxisAlignedBB.getBoundingBox( + par3EntityPlayer.posX - range, + par3EntityPlayer.posY - range, + par3EntityPlayer.posZ - range, + par3EntityPlayer.posX + range, + par3EntityPlayer.posY + range, + par3EntityPlayer.posZ + range)); + for (EntityLivingBase entity : entities) + if (entity != par3EntityPlayer + && (!(entity instanceof EntityPlayer) + || MinecraftServer.getServer() == null + || MinecraftServer.getServer().isPVPEnabled())) { + entity.addPotionEffect(new PotionEffect(Potion.moveSlowdown.id, 50, 5)); + stunned++; + } + + if (stunned >= 100) par3EntityPlayer.addStat(ModAchievements.signalFlareStun, 1); + } + par1ItemStack.damageItem(200, par3EntityPlayer); + } + + return par1ItemStack; + } + + @Override + public void onUpdate(ItemStack par1ItemStack, World par2World, Entity par3Entity, int par4, boolean par5) { + if (par1ItemStack.isItemDamaged()) par1ItemStack.setItemDamage(par1ItemStack.getItemDamage() - 1); + } + + @Override + public void registerIcons(IIconRegister par1IconRegister) { + icons = new IIcon[2]; + for (int i = 0; i < icons.length; i++) icons[i] = IconHelper.forItem(par1IconRegister, this, i); + } + + @Override + public IIcon getIcon(ItemStack stack, int pass) { + return icons[Math.min(1, pass)]; + } + + @Override + public int getColorFromItemStack(ItemStack par1ItemStack, int par2) { + if (par2 == 0) return 0xFFFFFF; + + int colorv = getColor(par1ItemStack); + if (colorv >= EntitySheep.fleeceColorTable.length || colorv < 0) return 0xFFFFFF; + + float[] color = EntitySheep.fleeceColorTable[getColor(par1ItemStack)]; + return new Color(color[0], color[1], color[2]).getRGB(); + } + + @Override + public void getSubItems(Item par1, CreativeTabs par2CreativeTabs, List par3List) { + for (int i = 0; i < 16; i++) par3List.add(forColor(i)); + } + + @Override + public boolean requiresMultipleRenderPasses() { + return true; + } + + @Override + public void addInformation(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, List par3List, boolean par4) { + int storedColor = getColor(par1ItemStack); + par3List.add(String.format( + StatCollector.translateToLocal("botaniamisc.flareColor"), + StatCollector.translateToLocal("botania.color" + storedColor))); + } + + public static ItemStack forColor(int color) { + ItemStack stack = new ItemStack(ModItems.signalFlare); + ItemNBTHelper.setInt(stack, TAG_COLOR, color); + + return stack; + } + + public static int getColor(ItemStack stack) { + return ItemNBTHelper.getInt(stack, TAG_COLOR, 0xFFFFFF); + } +} diff --git a/src/main/java/vazkii/botania/common/item/ItemSlimeBottle.java b/src/main/java/vazkii/botania/common/item/ItemSlimeBottle.java index 3a9b374205..29295e84af 100644 --- a/src/main/java/vazkii/botania/common/item/ItemSlimeBottle.java +++ b/src/main/java/vazkii/botania/common/item/ItemSlimeBottle.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Aug 17, 2015, 1:32:58 AM (GMT)] */ package vazkii.botania.common.item; @@ -22,36 +22,34 @@ public class ItemSlimeBottle extends ItemMod { - IIcon activeIcon; - - public ItemSlimeBottle() { - setUnlocalizedName(LibItemNames.SLIME_BOTTLE); - setMaxStackSize(1); - setHasSubtypes(true); - } - - @Override - public void registerIcons(IIconRegister par1IconRegister) { - itemIcon = IconHelper.forItem(par1IconRegister, this, 0); - activeIcon = IconHelper.forItem(par1IconRegister, this, 1); - } - - @Override - public IIcon getIconFromDamage(int dmg) { - return dmg == 0 ? itemIcon : activeIcon; - } - - @Override - public void onUpdate(ItemStack stack, World world, Entity entity, int something, boolean somethingelse) { - if(!world.isRemote) { - int x = MathHelper.floor_double(entity.posX); - int z = MathHelper.floor_double(entity.posZ); - boolean slime = SubTileNarslimmus.SpawnIntercepter.isSlimeChunk(world, x, z); - int meta = stack.getItemDamage(); - int newMeta = slime ? 1 : 0; - if(meta != newMeta) - stack.setItemDamage(newMeta); - } - } - + IIcon activeIcon; + + public ItemSlimeBottle() { + setUnlocalizedName(LibItemNames.SLIME_BOTTLE); + setMaxStackSize(1); + setHasSubtypes(true); + } + + @Override + public void registerIcons(IIconRegister par1IconRegister) { + itemIcon = IconHelper.forItem(par1IconRegister, this, 0); + activeIcon = IconHelper.forItem(par1IconRegister, this, 1); + } + + @Override + public IIcon getIconFromDamage(int dmg) { + return dmg == 0 ? itemIcon : activeIcon; + } + + @Override + public void onUpdate(ItemStack stack, World world, Entity entity, int something, boolean somethingelse) { + if (!world.isRemote) { + int x = MathHelper.floor_double(entity.posX); + int z = MathHelper.floor_double(entity.posZ); + boolean slime = SubTileNarslimmus.SpawnIntercepter.isSlimeChunk(world, x, z); + int meta = stack.getItemDamage(); + int newMeta = slime ? 1 : 0; + if (meta != newMeta) stack.setItemDamage(newMeta); + } + } } diff --git a/src/main/java/vazkii/botania/common/item/ItemSlingshot.java b/src/main/java/vazkii/botania/common/item/ItemSlingshot.java index cd52a80f49..baf49afd67 100644 --- a/src/main/java/vazkii/botania/common/item/ItemSlingshot.java +++ b/src/main/java/vazkii/botania/common/item/ItemSlingshot.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jun 27, 2014, 12:38:58 AM (GMT)] */ package vazkii.botania.common.item; @@ -19,56 +19,55 @@ public class ItemSlingshot extends ItemMod { - public ItemSlingshot() { - setMaxStackSize(1); - setUnlocalizedName(LibItemNames.SLINGSHOT); - } + public ItemSlingshot() { + setMaxStackSize(1); + setUnlocalizedName(LibItemNames.SLINGSHOT); + } - @Override - public void onPlayerStoppedUsing(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer, int par4) { - int j = getMaxItemUseDuration(par1ItemStack) - par4; + @Override + public void onPlayerStoppedUsing( + ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer, int par4) { + int j = getMaxItemUseDuration(par1ItemStack) - par4; - if(par3EntityPlayer.capabilities.isCreativeMode || par3EntityPlayer.inventory.hasItem(ModItems.vineBall)) { - float f = j / 20.0F; - f = (f * f + f * 2.0F) / 3.0F; + if (par3EntityPlayer.capabilities.isCreativeMode || par3EntityPlayer.inventory.hasItem(ModItems.vineBall)) { + float f = j / 20.0F; + f = (f * f + f * 2.0F) / 3.0F; - if(f < 1F) - return; + if (f < 1F) return; - if(!par3EntityPlayer.capabilities.isCreativeMode) - par3EntityPlayer.inventory.consumeInventoryItem(ModItems.vineBall); + if (!par3EntityPlayer.capabilities.isCreativeMode) + par3EntityPlayer.inventory.consumeInventoryItem(ModItems.vineBall); - if(!par2World.isRemote) { - EntityVineBall ball = new EntityVineBall(par3EntityPlayer, false); - ball.motionX *= 1.6; - ball.motionY *= 1.6; - ball.motionZ *= 1.6; - par2World.spawnEntityInWorld(ball); - } - } - } + if (!par2World.isRemote) { + EntityVineBall ball = new EntityVineBall(par3EntityPlayer, false); + ball.motionX *= 1.6; + ball.motionY *= 1.6; + ball.motionZ *= 1.6; + par2World.spawnEntityInWorld(ball); + } + } + } - @Override - public ItemStack onEaten(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer) { - return par1ItemStack; - } + @Override + public ItemStack onEaten(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer) { + return par1ItemStack; + } - @Override - public int getMaxItemUseDuration(ItemStack par1ItemStack) { - return 72000; - } + @Override + public int getMaxItemUseDuration(ItemStack par1ItemStack) { + return 72000; + } - @Override - public EnumAction getItemUseAction(ItemStack par1ItemStack) { - return EnumAction.bow; - } + @Override + public EnumAction getItemUseAction(ItemStack par1ItemStack) { + return EnumAction.bow; + } - @Override - public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer) { - if(par3EntityPlayer.capabilities.isCreativeMode || par3EntityPlayer.inventory.hasItem(ModItems.vineBall)) - par3EntityPlayer.setItemInUse(par1ItemStack, getMaxItemUseDuration(par1ItemStack)); - - return par1ItemStack; - } + @Override + public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer) { + if (par3EntityPlayer.capabilities.isCreativeMode || par3EntityPlayer.inventory.hasItem(ModItems.vineBall)) + par3EntityPlayer.setItemInUse(par1ItemStack, getMaxItemUseDuration(par1ItemStack)); + return par1ItemStack; + } } diff --git a/src/main/java/vazkii/botania/common/item/ItemSpark.java b/src/main/java/vazkii/botania/common/item/ItemSpark.java index c017efc98a..fd35fdcb56 100644 --- a/src/main/java/vazkii/botania/common/item/ItemSpark.java +++ b/src/main/java/vazkii/botania/common/item/ItemSpark.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Aug 21, 2014, 5:24:55 PM (GMT)] */ package vazkii.botania.common.item; @@ -29,46 +29,55 @@ public class ItemSpark extends ItemMod implements ICraftAchievement, IManaGivingItem { - public static IIcon invIcon, worldIcon; + public static IIcon invIcon, worldIcon; - public ItemSpark() { - setUnlocalizedName(LibItemNames.SPARK); - } + public ItemSpark() { + setUnlocalizedName(LibItemNames.SPARK); + } - @Override - public boolean onItemUse(ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int side, float xv, float yv, float zv) { - TileEntity tile = world.getTileEntity(x, y, z); - if(tile instanceof ISparkAttachable) { - ISparkAttachable attach = (ISparkAttachable) tile; - if(attach.canAttachSpark(stack) && attach.getAttachedSpark() == null) { - stack.stackSize--; - if(!world.isRemote) { - EntitySpark spark = new EntitySpark(world); - spark.setPosition(x + 0.5, y + 1.5, z + 0.5); - world.spawnEntityInWorld(spark); - attach.attachSpark(spark); - VanillaPacketDispatcher.dispatchTEToNearbyPlayers(world, x, y, z); - } - return true; - } - } - return false; - } + @Override + public boolean onItemUse( + ItemStack stack, + EntityPlayer player, + World world, + int x, + int y, + int z, + int side, + float xv, + float yv, + float zv) { + TileEntity tile = world.getTileEntity(x, y, z); + if (tile instanceof ISparkAttachable) { + ISparkAttachable attach = (ISparkAttachable) tile; + if (attach.canAttachSpark(stack) && attach.getAttachedSpark() == null) { + stack.stackSize--; + if (!world.isRemote) { + EntitySpark spark = new EntitySpark(world); + spark.setPosition(x + 0.5, y + 1.5, z + 0.5); + world.spawnEntityInWorld(spark); + attach.attachSpark(spark); + VanillaPacketDispatcher.dispatchTEToNearbyPlayers(world, x, y, z); + } + return true; + } + } + return false; + } - @Override - public void registerIcons(IIconRegister par1IconRegister) { - invIcon = IconHelper.forItem(par1IconRegister, this, 0); - worldIcon = IconHelper.forItem(par1IconRegister, this, 1); - } + @Override + public void registerIcons(IIconRegister par1IconRegister) { + invIcon = IconHelper.forItem(par1IconRegister, this, 0); + worldIcon = IconHelper.forItem(par1IconRegister, this, 1); + } - @Override - public IIcon getIconFromDamage(int p_77617_1_) { - return invIcon; - } - - @Override - public Achievement getAchievementOnCraft(ItemStack stack, EntityPlayer player, IInventory matrix) { - return ModAchievements.sparkCraft; - } + @Override + public IIcon getIconFromDamage(int p_77617_1_) { + return invIcon; + } + @Override + public Achievement getAchievementOnCraft(ItemStack stack, EntityPlayer player, IInventory matrix) { + return ModAchievements.sparkCraft; + } } diff --git a/src/main/java/vazkii/botania/common/item/ItemSparkUpgrade.java b/src/main/java/vazkii/botania/common/item/ItemSparkUpgrade.java index 20b3f1e810..336a4f709c 100644 --- a/src/main/java/vazkii/botania/common/item/ItemSparkUpgrade.java +++ b/src/main/java/vazkii/botania/common/item/ItemSparkUpgrade.java @@ -2,16 +2,15 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Aug 21, 2014, 5:32:06 PM (GMT)] */ package vazkii.botania.common.item; import java.util.List; - import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.item.Item; @@ -22,43 +21,42 @@ public class ItemSparkUpgrade extends ItemMod { - private static final int VARIANTS = 4; - - public static IIcon[] worldIcons; - IIcon[] invIcons; - - public ItemSparkUpgrade() { - setUnlocalizedName(LibItemNames.SPARK_UPGRADE); - setHasSubtypes(true); - } - - @Override - public void registerIcons(IIconRegister par1IconRegister) { - worldIcons = new IIcon[VARIANTS]; - invIcons = new IIcon[VARIANTS]; - for(int i = 0; i < VARIANTS; i++) { - worldIcons[i] = IconHelper.forItem(par1IconRegister, this, "L" + i); - invIcons[i] = IconHelper.forItem(par1IconRegister, this, i); - } - } - - @Override - public IIcon getIconFromDamage(int meta) { - return invIcons[Math.min(invIcons.length - 1, meta)]; - } - - @Override - public void getSubItems(Item item, CreativeTabs tab, List list) { - for(int i = 0; i < VARIANTS; i++) - list.add(new ItemStack(item, 1, i)); - } - - @Override - public String getUnlocalizedName(ItemStack par1ItemStack) { - return getUnlocalizedNameLazy(par1ItemStack) + par1ItemStack.getItemDamage(); - } - - String getUnlocalizedNameLazy(ItemStack par1ItemStack) { - return super.getUnlocalizedName(par1ItemStack); - } + private static final int VARIANTS = 4; + + public static IIcon[] worldIcons; + IIcon[] invIcons; + + public ItemSparkUpgrade() { + setUnlocalizedName(LibItemNames.SPARK_UPGRADE); + setHasSubtypes(true); + } + + @Override + public void registerIcons(IIconRegister par1IconRegister) { + worldIcons = new IIcon[VARIANTS]; + invIcons = new IIcon[VARIANTS]; + for (int i = 0; i < VARIANTS; i++) { + worldIcons[i] = IconHelper.forItem(par1IconRegister, this, "L" + i); + invIcons[i] = IconHelper.forItem(par1IconRegister, this, i); + } + } + + @Override + public IIcon getIconFromDamage(int meta) { + return invIcons[Math.min(invIcons.length - 1, meta)]; + } + + @Override + public void getSubItems(Item item, CreativeTabs tab, List list) { + for (int i = 0; i < VARIANTS; i++) list.add(new ItemStack(item, 1, i)); + } + + @Override + public String getUnlocalizedName(ItemStack par1ItemStack) { + return getUnlocalizedNameLazy(par1ItemStack) + par1ItemStack.getItemDamage(); + } + + String getUnlocalizedNameLazy(ItemStack par1ItemStack) { + return super.getUnlocalizedName(par1ItemStack); + } } diff --git a/src/main/java/vazkii/botania/common/item/ItemSpawnerMover.java b/src/main/java/vazkii/botania/common/item/ItemSpawnerMover.java index 981d009a40..dfefb6f7be 100644 --- a/src/main/java/vazkii/botania/common/item/ItemSpawnerMover.java +++ b/src/main/java/vazkii/botania/common/item/ItemSpawnerMover.java @@ -2,16 +2,15 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [? (GMT)] */ package vazkii.botania.common.item; import java.util.List; - import net.minecraft.block.Block; import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.entity.Entity; @@ -31,174 +30,222 @@ public class ItemSpawnerMover extends ItemMod { - public static final String TAG_SPAWNER = "spawner"; - private static final String TAG_PLACE_DELAY = "placeDelay"; - - IIcon iconNormal, iconSpawner; - - public ItemSpawnerMover() { - setUnlocalizedName(LibItemNames.SPAWNER_MOVER); - setMaxStackSize(1); - } - - @Override - public void registerIcons(IIconRegister par1IconRegister) { - iconNormal = IconHelper.forItem(par1IconRegister, this, 0); - iconSpawner = IconHelper.forItem(par1IconRegister, this, 1); - } - - @Override - public IIcon getIcon(ItemStack stack, int pass) { - return getIconIndex(stack); - } - - @Override - public IIcon getIconIndex(ItemStack par1ItemStack) { - return hasData(par1ItemStack) ? iconSpawner : iconNormal; - } - - public static NBTTagCompound getSpawnerTag(ItemStack stack) { - NBTTagCompound tag = stack.getTagCompound(); - if(tag != null) { - if(tag.hasKey(TAG_SPAWNER)) - return tag.getCompoundTag(TAG_SPAWNER); - if(tag.hasKey("EntityId")) - return tag; - } - - return null; - } - - private static String getEntityId(ItemStack stack) { - NBTTagCompound tag = getSpawnerTag(stack); - if(tag != null) - return tag.getString("EntityId"); - - return null; - } - - public static boolean hasData(ItemStack stack) { - return getEntityId(stack) != null; - } - - private static int getDelay(ItemStack stack) { - NBTTagCompound tag = stack.getTagCompound(); - if(tag != null) - return tag.getInteger(TAG_PLACE_DELAY); - - return 0; - } - - @Override - public void addInformation(ItemStack stack, EntityPlayer player, List infoList, boolean advancedTooltips) { - String id = getEntityId(stack); - if (id != null) - infoList.add(StatCollector.translateToLocal("entity." + id + ".name")); - } - - @Override - public void onUpdate(ItemStack stack, World world, Entity entity, int par4, boolean par5) { - NBTTagCompound tag = stack.getTagCompound(); - if(tag != null && tag.hasKey(TAG_PLACE_DELAY) && tag.getInteger(TAG_PLACE_DELAY) > 0) - tag.setInteger(TAG_PLACE_DELAY, tag.getInteger(TAG_PLACE_DELAY) - 1); - } - - @Override - public boolean onItemUse(ItemStack itemstack, EntityPlayer player, World world, int x, int y, int z, int side, float xOffset, float yOffset, float zOffset) { - if(getEntityId(itemstack) == null) { - if(world.getBlock(x, y, z).equals(Blocks.mob_spawner)) { - TileEntity te = world.getTileEntity(x, y, z); - NBTTagCompound tag = new NBTTagCompound(); - tag.setTag(TAG_SPAWNER, new NBTTagCompound()); - te.writeToNBT(tag.getCompoundTag(TAG_SPAWNER)); - tag.setInteger(TAG_PLACE_DELAY, 20); - itemstack.setTagCompound(tag); - world.setBlockToAir(x, y, z); - player.renderBrokenItemStack(itemstack); - for(int i = 0; i < 50; i++) { - float red = (float) Math.random(); - float green = (float) Math.random(); - float blue = (float) Math.random(); - Botania.proxy.wispFX(world, x + 0.5, y + 0.5, z + 0.5, red, green, blue, (float) Math.random() * 0.1F + 0.05F, (float) (Math.random() - 0.5F) * 0.15F, (float) (Math.random() - 0.5F) * 0.15F, (float) (Math.random() - 0.5F) * 0.15F); - } - return true; - } else return false; - } else { - if(getDelay(itemstack) <= 0 && placeBlock(itemstack, player, world, x, y, z, side, xOffset, yOffset, zOffset)) - return true; - return false; - } - } - - private boolean placeBlock(ItemStack itemstack, EntityPlayer player, World world, int x, int y, int z, int side, float xOffset, float yOffset, float zOffset) { - Block block = world.getBlock(x, y, z); - - if(block == Blocks.snow_layer) - side = 1; - else if(block != Blocks.vine && block != Blocks.tallgrass && block != Blocks.deadbush && !block.isReplaceable(world, x, y, z)) { - switch (side) { - case 0: - --y; - break; - case 1: - ++y; - break; - case 2: - --z; - break; - case 3: - ++z; - break; - case 4: - --x; - break; - case 5: - ++x; - break; - } - } - - if(itemstack.stackSize == 0) - return false; - else if(!player.canPlayerEdit(x, y, z, side, itemstack)) - return false; - else if(y == 255 && block.getMaterial().isSolid()) - return false; - else if(world.canPlaceEntityOnSide(Blocks.mob_spawner, x, y, z, false, side, player, itemstack)) { - int meta = block.onBlockPlaced(world, x, y, z, side, xOffset, yOffset, zOffset, 0); - - if(placeBlockAt(itemstack, player, world, x, y, z, side, xOffset, yOffset, zOffset, meta)) { - world.playSoundEffect(x + 0.5F, y + 0.5F, z + 0.5F, block.stepSound.func_150496_b(), (block.stepSound.getVolume() + 1.0F) / 2.0F, block.stepSound.getPitch() * 0.8F); - player.renderBrokenItemStack(itemstack); - player.addStat(ModAchievements.spawnerMoverUse, 1); - for(int i = 0; i < 100; i++) - Botania.proxy.sparkleFX(world, x + Math.random(), y + Math.random(), z + Math.random(), (float) Math.random(), (float) Math.random(), (float) Math.random(), 0.45F + 0.2F * (float) Math.random(), 6); - - --itemstack.stackSize; - } - - return true; - } - else return false; - } - - private boolean placeBlockAt(ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int side, float hitX, float hitY, float hitZ, int metadata) { - if (!world.setBlock(x, y, z, Blocks.mob_spawner, metadata, 3)) - return false; - - Block block = world.getBlock(x, y, z); - if(block.equals(Blocks.mob_spawner)) { - TileEntity te = world.getTileEntity(x, y, z); - NBTTagCompound tag = stack.getTagCompound(); - if (tag.hasKey(TAG_SPAWNER)) - tag = tag.getCompoundTag(TAG_SPAWNER); - tag.setInteger("x", x); - tag.setInteger("y", y); - tag.setInteger("z", z); - te.readFromNBT(tag); - VanillaPacketDispatcher.dispatchTEToNearbyPlayers(world, x, y, z); - } - - return true; - } + public static final String TAG_SPAWNER = "spawner"; + private static final String TAG_PLACE_DELAY = "placeDelay"; + + IIcon iconNormal, iconSpawner; + + public ItemSpawnerMover() { + setUnlocalizedName(LibItemNames.SPAWNER_MOVER); + setMaxStackSize(1); + } + + @Override + public void registerIcons(IIconRegister par1IconRegister) { + iconNormal = IconHelper.forItem(par1IconRegister, this, 0); + iconSpawner = IconHelper.forItem(par1IconRegister, this, 1); + } + + @Override + public IIcon getIcon(ItemStack stack, int pass) { + return getIconIndex(stack); + } + + @Override + public IIcon getIconIndex(ItemStack par1ItemStack) { + return hasData(par1ItemStack) ? iconSpawner : iconNormal; + } + + public static NBTTagCompound getSpawnerTag(ItemStack stack) { + NBTTagCompound tag = stack.getTagCompound(); + if (tag != null) { + if (tag.hasKey(TAG_SPAWNER)) return tag.getCompoundTag(TAG_SPAWNER); + if (tag.hasKey("EntityId")) return tag; + } + + return null; + } + + private static String getEntityId(ItemStack stack) { + NBTTagCompound tag = getSpawnerTag(stack); + if (tag != null) return tag.getString("EntityId"); + + return null; + } + + public static boolean hasData(ItemStack stack) { + return getEntityId(stack) != null; + } + + private static int getDelay(ItemStack stack) { + NBTTagCompound tag = stack.getTagCompound(); + if (tag != null) return tag.getInteger(TAG_PLACE_DELAY); + + return 0; + } + + @Override + public void addInformation(ItemStack stack, EntityPlayer player, List infoList, boolean advancedTooltips) { + String id = getEntityId(stack); + if (id != null) infoList.add(StatCollector.translateToLocal("entity." + id + ".name")); + } + + @Override + public void onUpdate(ItemStack stack, World world, Entity entity, int par4, boolean par5) { + NBTTagCompound tag = stack.getTagCompound(); + if (tag != null && tag.hasKey(TAG_PLACE_DELAY) && tag.getInteger(TAG_PLACE_DELAY) > 0) + tag.setInteger(TAG_PLACE_DELAY, tag.getInteger(TAG_PLACE_DELAY) - 1); + } + + @Override + public boolean onItemUse( + ItemStack itemstack, + EntityPlayer player, + World world, + int x, + int y, + int z, + int side, + float xOffset, + float yOffset, + float zOffset) { + if (getEntityId(itemstack) == null) { + if (world.getBlock(x, y, z).equals(Blocks.mob_spawner)) { + TileEntity te = world.getTileEntity(x, y, z); + NBTTagCompound tag = new NBTTagCompound(); + tag.setTag(TAG_SPAWNER, new NBTTagCompound()); + te.writeToNBT(tag.getCompoundTag(TAG_SPAWNER)); + tag.setInteger(TAG_PLACE_DELAY, 20); + itemstack.setTagCompound(tag); + world.setBlockToAir(x, y, z); + player.renderBrokenItemStack(itemstack); + for (int i = 0; i < 50; i++) { + float red = (float) Math.random(); + float green = (float) Math.random(); + float blue = (float) Math.random(); + Botania.proxy.wispFX( + world, + x + 0.5, + y + 0.5, + z + 0.5, + red, + green, + blue, + (float) Math.random() * 0.1F + 0.05F, + (float) (Math.random() - 0.5F) * 0.15F, + (float) (Math.random() - 0.5F) * 0.15F, + (float) (Math.random() - 0.5F) * 0.15F); + } + return true; + } else return false; + } else { + if (getDelay(itemstack) <= 0 + && placeBlock(itemstack, player, world, x, y, z, side, xOffset, yOffset, zOffset)) return true; + return false; + } + } + + private boolean placeBlock( + ItemStack itemstack, + EntityPlayer player, + World world, + int x, + int y, + int z, + int side, + float xOffset, + float yOffset, + float zOffset) { + Block block = world.getBlock(x, y, z); + + if (block == Blocks.snow_layer) side = 1; + else if (block != Blocks.vine + && block != Blocks.tallgrass + && block != Blocks.deadbush + && !block.isReplaceable(world, x, y, z)) { + switch (side) { + case 0: + --y; + break; + case 1: + ++y; + break; + case 2: + --z; + break; + case 3: + ++z; + break; + case 4: + --x; + break; + case 5: + ++x; + break; + } + } + + if (itemstack.stackSize == 0) return false; + else if (!player.canPlayerEdit(x, y, z, side, itemstack)) return false; + else if (y == 255 && block.getMaterial().isSolid()) return false; + else if (world.canPlaceEntityOnSide(Blocks.mob_spawner, x, y, z, false, side, player, itemstack)) { + int meta = block.onBlockPlaced(world, x, y, z, side, xOffset, yOffset, zOffset, 0); + + if (placeBlockAt(itemstack, player, world, x, y, z, side, xOffset, yOffset, zOffset, meta)) { + world.playSoundEffect( + x + 0.5F, + y + 0.5F, + z + 0.5F, + block.stepSound.func_150496_b(), + (block.stepSound.getVolume() + 1.0F) / 2.0F, + block.stepSound.getPitch() * 0.8F); + player.renderBrokenItemStack(itemstack); + player.addStat(ModAchievements.spawnerMoverUse, 1); + for (int i = 0; i < 100; i++) + Botania.proxy.sparkleFX( + world, + x + Math.random(), + y + Math.random(), + z + Math.random(), + (float) Math.random(), + (float) Math.random(), + (float) Math.random(), + 0.45F + 0.2F * (float) Math.random(), + 6); + + --itemstack.stackSize; + } + + return true; + } else return false; + } + + private boolean placeBlockAt( + ItemStack stack, + EntityPlayer player, + World world, + int x, + int y, + int z, + int side, + float hitX, + float hitY, + float hitZ, + int metadata) { + if (!world.setBlock(x, y, z, Blocks.mob_spawner, metadata, 3)) return false; + + Block block = world.getBlock(x, y, z); + if (block.equals(Blocks.mob_spawner)) { + TileEntity te = world.getTileEntity(x, y, z); + NBTTagCompound tag = stack.getTagCompound(); + if (tag.hasKey(TAG_SPAWNER)) tag = tag.getCompoundTag(TAG_SPAWNER); + tag.setInteger("x", x); + tag.setInteger("y", y); + tag.setInteger("z", z); + te.readFromNBT(tag); + VanillaPacketDispatcher.dispatchTEToNearbyPlayers(world, x, y, z); + } + + return true; + } } diff --git a/src/main/java/vazkii/botania/common/item/ItemSpellCloth.java b/src/main/java/vazkii/botania/common/item/ItemSpellCloth.java index d8782f5d54..08b3ca7897 100644 --- a/src/main/java/vazkii/botania/common/item/ItemSpellCloth.java +++ b/src/main/java/vazkii/botania/common/item/ItemSpellCloth.java @@ -2,58 +2,61 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jan 25, 2015, 6:14:13 PM (GMT)] */ package vazkii.botania.common.item; +import cpw.mods.fml.common.registry.GameRegistry; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; import java.awt.Color; - import net.minecraft.item.ItemStack; import net.minecraftforge.oredict.RecipeSorter; import net.minecraftforge.oredict.RecipeSorter.Category; import vazkii.botania.common.crafting.recipe.SpellClothRecipe; import vazkii.botania.common.lib.LibItemNames; -import cpw.mods.fml.common.registry.GameRegistry; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; public class ItemSpellCloth extends ItemMod { - public ItemSpellCloth() { - setMaxDamage(35); - setMaxStackSize(1); - setNoRepair(); - setUnlocalizedName(LibItemNames.SPELL_CLOTH); - - GameRegistry.addRecipe(new SpellClothRecipe()); - RecipeSorter.register("botania:spellCloth", SpellClothRecipe.class, Category.SHAPELESS, ""); - } - - @Override - @SideOnly(Side.CLIENT) - public int getColorFromItemStack(ItemStack par1ItemStack, int par2) { - return Color.HSBtoRGB(0.55F, ((float) par1ItemStack.getMaxDamage() - (float) par1ItemStack.getItemDamage()) / par1ItemStack.getMaxDamage() * 0.5F, 1F); - } - - @Override - public boolean hasContainerItem() { - return true; - } - - @Override - public ItemStack getContainerItem(ItemStack itemStack) { - ItemStack stack = itemStack.copy(); - stack.setItemDamage(stack.getItemDamage() + 1); - return stack; - } - - @Override - public boolean doesContainerItemLeaveCraftingGrid(ItemStack par1ItemStack) { - return false; - } - + public ItemSpellCloth() { + setMaxDamage(35); + setMaxStackSize(1); + setNoRepair(); + setUnlocalizedName(LibItemNames.SPELL_CLOTH); + + GameRegistry.addRecipe(new SpellClothRecipe()); + RecipeSorter.register("botania:spellCloth", SpellClothRecipe.class, Category.SHAPELESS, ""); + } + + @Override + @SideOnly(Side.CLIENT) + public int getColorFromItemStack(ItemStack par1ItemStack, int par2) { + return Color.HSBtoRGB( + 0.55F, + ((float) par1ItemStack.getMaxDamage() - (float) par1ItemStack.getItemDamage()) + / par1ItemStack.getMaxDamage() + * 0.5F, + 1F); + } + + @Override + public boolean hasContainerItem() { + return true; + } + + @Override + public ItemStack getContainerItem(ItemStack itemStack) { + ItemStack stack = itemStack.copy(); + stack.setItemDamage(stack.getItemDamage() + 1); + return stack; + } + + @Override + public boolean doesContainerItemLeaveCraftingGrid(ItemStack par1ItemStack) { + return false; + } } diff --git a/src/main/java/vazkii/botania/common/item/ItemTemperanceStone.java b/src/main/java/vazkii/botania/common/item/ItemTemperanceStone.java index 371d5a089a..09a919690e 100644 --- a/src/main/java/vazkii/botania/common/item/ItemTemperanceStone.java +++ b/src/main/java/vazkii/botania/common/item/ItemTemperanceStone.java @@ -2,16 +2,17 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [May 12, 2015, 5:56:45 PM (GMT)] */ package vazkii.botania.common.item; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; import java.util.List; - import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.inventory.IInventory; @@ -21,62 +22,58 @@ import net.minecraft.world.World; import vazkii.botania.client.core.helper.IconHelper; import vazkii.botania.common.lib.LibItemNames; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; public class ItemTemperanceStone extends ItemMod { - IIcon enabledIcon; - - public ItemTemperanceStone() { - setUnlocalizedName(LibItemNames.TEMPERANCE_STONE); - setMaxStackSize(1); - setHasSubtypes(true); - } + IIcon enabledIcon; - @Override - public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer) { - int dmg = par1ItemStack.getItemDamage(); - par1ItemStack.setItemDamage(~dmg & 1); - par2World.playSoundAtEntity(par3EntityPlayer, "random.orb", 0.3F, 0.1F); + public ItemTemperanceStone() { + setUnlocalizedName(LibItemNames.TEMPERANCE_STONE); + setMaxStackSize(1); + setHasSubtypes(true); + } - return par1ItemStack; - } + @Override + public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer) { + int dmg = par1ItemStack.getItemDamage(); + par1ItemStack.setItemDamage(~dmg & 1); + par2World.playSoundAtEntity(par3EntityPlayer, "random.orb", 0.3F, 0.1F); - @Override - @SideOnly(Side.CLIENT) - public void registerIcons(IIconRegister par1IconRegister) { - itemIcon = IconHelper.forItem(par1IconRegister, this, 0); - enabledIcon = IconHelper.forItem(par1IconRegister, this, 1); - } + return par1ItemStack; + } - @Override - @SideOnly(Side.CLIENT) - public IIcon getIconFromDamage(int par1) { - return par1 == 1 ? enabledIcon : itemIcon; - } + @Override + @SideOnly(Side.CLIENT) + public void registerIcons(IIconRegister par1IconRegister) { + itemIcon = IconHelper.forItem(par1IconRegister, this, 0); + enabledIcon = IconHelper.forItem(par1IconRegister, this, 1); + } - @Override - @SideOnly(Side.CLIENT) - public void addInformation(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, List par3List, boolean par4) { - if(par1ItemStack.getItemDamage() == 1) - addStringToTooltip(StatCollector.translateToLocal("botaniamisc.active"), par3List); - else addStringToTooltip(StatCollector.translateToLocal("botaniamisc.inactive"), par3List); - } + @Override + @SideOnly(Side.CLIENT) + public IIcon getIconFromDamage(int par1) { + return par1 == 1 ? enabledIcon : itemIcon; + } - void addStringToTooltip(String s, List tooltip) { - tooltip.add(s.replaceAll("&", "\u00a7")); - } + @Override + @SideOnly(Side.CLIENT) + public void addInformation(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, List par3List, boolean par4) { + if (par1ItemStack.getItemDamage() == 1) + addStringToTooltip(StatCollector.translateToLocal("botaniamisc.active"), par3List); + else addStringToTooltip(StatCollector.translateToLocal("botaniamisc.inactive"), par3List); + } - public static boolean hasTemperanceActive(EntityPlayer player) { - IInventory inv = player.inventory; - for(int i = 0; i < inv.getSizeInventory(); i++) { - ItemStack stack = inv.getStackInSlot(i); - if(stack != null && stack.getItem() == ModItems.temperanceStone && stack.getItemDamage() == 1) - return true; - } + void addStringToTooltip(String s, List tooltip) { + tooltip.add(s.replaceAll("&", "\u00a7")); + } - return false; - } + public static boolean hasTemperanceActive(EntityPlayer player) { + IInventory inv = player.inventory; + for (int i = 0; i < inv.getSizeInventory(); i++) { + ItemStack stack = inv.getStackInSlot(i); + if (stack != null && stack.getItem() == ModItems.temperanceStone && stack.getItemDamage() == 1) return true; + } + return false; + } } diff --git a/src/main/java/vazkii/botania/common/item/ItemThornChakram.java b/src/main/java/vazkii/botania/common/item/ItemThornChakram.java index 1d790d9ae0..6bcd670851 100644 --- a/src/main/java/vazkii/botania/common/item/ItemThornChakram.java +++ b/src/main/java/vazkii/botania/common/item/ItemThornChakram.java @@ -2,15 +2,15 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jan 25, 2015, 6:42:47 PM (GMT)] */ package vazkii.botania.common.item; -import java.util.List; +import java.util.List; import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.entity.player.EntityPlayer; @@ -28,55 +28,52 @@ public class ItemThornChakram extends ItemMod implements ICraftAchievement { - IIcon iconFire; - - public ItemThornChakram() { - setUnlocalizedName(LibItemNames.THORN_CHAKRAM); - setMaxStackSize(6); - setHasSubtypes(true); - } - - @Override - public void getSubItems(Item item, CreativeTabs tab, List list) { - for(int i = 0; i < 2; i++) - list.add(new ItemStack(item, 1, i)); - } + IIcon iconFire; - @Override - public void registerIcons(IIconRegister par1IconRegister) { - itemIcon = IconHelper.forItem(par1IconRegister, this, 0); - iconFire = IconHelper.forItem(par1IconRegister, this, 1); - } + public ItemThornChakram() { + setUnlocalizedName(LibItemNames.THORN_CHAKRAM); + setMaxStackSize(6); + setHasSubtypes(true); + } - @Override - public IIcon getIconFromDamage(int dmg) { - return dmg == 0 ? itemIcon : iconFire; - } + @Override + public void getSubItems(Item item, CreativeTabs tab, List list) { + for (int i = 0; i < 2; i++) list.add(new ItemStack(item, 1, i)); + } - @Override - public String getUnlocalizedName(ItemStack stack) { - return super.getUnlocalizedName() + stack.getItemDamage(); - } + @Override + public void registerIcons(IIconRegister par1IconRegister) { + itemIcon = IconHelper.forItem(par1IconRegister, this, 0); + iconFire = IconHelper.forItem(par1IconRegister, this, 1); + } - @Override - public ItemStack onItemRightClick(ItemStack p_77659_1_, World p_77659_2_, EntityPlayer p_77659_3_) { - --p_77659_1_.stackSize; + @Override + public IIcon getIconFromDamage(int dmg) { + return dmg == 0 ? itemIcon : iconFire; + } - p_77659_2_.playSoundAtEntity(p_77659_3_, "random.bow", 0.5F, 0.4F / (itemRand.nextFloat() * 0.4F + 0.8F)); + @Override + public String getUnlocalizedName(ItemStack stack) { + return super.getUnlocalizedName() + stack.getItemDamage(); + } - if(!p_77659_2_.isRemote) { - EntityThornChakram c = new EntityThornChakram(p_77659_2_, p_77659_3_); - c.setFire(p_77659_1_.getItemDamage() != 0); - p_77659_2_.spawnEntityInWorld(c); - } + @Override + public ItemStack onItemRightClick(ItemStack p_77659_1_, World p_77659_2_, EntityPlayer p_77659_3_) { + --p_77659_1_.stackSize; + p_77659_2_.playSoundAtEntity(p_77659_3_, "random.bow", 0.5F, 0.4F / (itemRand.nextFloat() * 0.4F + 0.8F)); - return p_77659_1_; - } + if (!p_77659_2_.isRemote) { + EntityThornChakram c = new EntityThornChakram(p_77659_2_, p_77659_3_); + c.setFire(p_77659_1_.getItemDamage() != 0); + p_77659_2_.spawnEntityInWorld(c); + } - @Override - public Achievement getAchievementOnCraft(ItemStack stack, EntityPlayer player, IInventory matrix) { - return ModAchievements.terrasteelWeaponCraft; - } + return p_77659_1_; + } + @Override + public Achievement getAchievementOnCraft(ItemStack stack, EntityPlayer player, IInventory matrix) { + return ModAchievements.terrasteelWeaponCraft; + } } diff --git a/src/main/java/vazkii/botania/common/item/ItemTwigWand.java b/src/main/java/vazkii/botania/common/item/ItemTwigWand.java index de32dd143c..bb62a0005f 100644 --- a/src/main/java/vazkii/botania/common/item/ItemTwigWand.java +++ b/src/main/java/vazkii/botania/common/item/ItemTwigWand.java @@ -2,17 +2,16 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jan 20, 2014, 7:42:46 PM (GMT)] */ package vazkii.botania.common.item; import java.awt.Color; import java.util.List; - import net.minecraft.block.Block; import net.minecraft.client.Minecraft; import net.minecraft.client.renderer.texture.IIconRegister; @@ -49,266 +48,282 @@ public class ItemTwigWand extends Item16Colors implements ICoordBoundItem { - IIcon[] icons; - - private static final String TAG_COLOR1 = "color1"; - private static final String TAG_COLOR2 = "color2"; - private static final String TAG_BOUND_TILE_X = "boundTileX"; - private static final String TAG_BOUND_TILE_Y = "boundTileY"; - private static final String TAG_BOUND_TILE_Z = "boundTileZ"; - private static final String TAG_BIND_MODE = "bindMode"; - - public ItemTwigWand() { - super(LibItemNames.TWIG_WAND); - setMaxStackSize(1); - } - - @Override - public boolean onItemUse(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, World par3World, int par4, int par5, int par6, int par7, float par8, float par9, float par10) { - Block block = par3World.getBlock(par4, par5, par6); - ChunkCoordinates boundTile = getBoundTile(par1ItemStack); - - if(boundTile.posY != -1 && par2EntityPlayer.isSneaking() && (boundTile.posX != par4 || boundTile.posY != par5 || boundTile.posZ != par6)) { - TileEntity tile = par3World.getTileEntity(boundTile.posX, boundTile.posY, boundTile.posZ); - if(tile instanceof IWandBindable) { - if(((IWandBindable) tile).bindTo(par2EntityPlayer, par1ItemStack, par4, par5, par6, par7)) { - Vector3 orig = new Vector3(boundTile.posX + 0.5, boundTile.posY + 0.5, boundTile.posZ + 0.5); - Vector3 end = new Vector3(par4 + 0.5, par5 + 0.5, par6 + 0.5); - doParticleBeam(par3World, orig, end); - - VanillaPacketDispatcher.dispatchTEToNearbyPlayers(par3World, boundTile.posX, boundTile.posY, boundTile.posZ); - setBoundTile(par1ItemStack, 0, -1, 0); - } - - return true; - } else setBoundTile(par1ItemStack, 0, -1, 0); - } else if(par2EntityPlayer.isSneaking()) { - block.rotateBlock(par3World, par4, par5, par6, ForgeDirection.getOrientation(par7)); - if(par3World.isRemote) - par2EntityPlayer.swingItem(); - } - - if(block == Blocks.lapis_block && ConfigHandler.enchanterEnabled) { - int meta = -1; - if(TileEnchanter.canEnchanterExist(par3World, par4, par5, par6, 0)) - meta = 0; - else if(TileEnchanter.canEnchanterExist(par3World, par4, par5, par6, 1)) - meta = 1; - - if(meta != -1 && !par3World.isRemote) { - par3World.setBlock(par4, par5, par6, ModBlocks.enchanter, meta, 1 | 2); - par2EntityPlayer.addStat(ModAchievements.enchanterMake, 1); - par3World.playSoundEffect(par4, par5, par6, "botania:enchanterBlock", 0.5F, 0.6F); - for(int i = 0; i < 50; i++) { - float red = (float) Math.random(); - float green = (float) Math.random(); - float blue = (float) Math.random(); - - double x = (Math.random() - 0.5) * 6; - double y = (Math.random() - 0.5) * 6; - double z = (Math.random() - 0.5) * 6; - - float velMul = 0.07F; - - Botania.proxy.wispFX(par3World, par4 + 0.5 + x, par5 + 0.5 + y, par6 + 0.5 + z, red, green, blue, (float) Math.random() * 0.15F + 0.15F, (float) -x * velMul, (float) -y * velMul, (float) -z * velMul); - } - } - } else if(block instanceof IWandable) { - TileEntity tile = par3World.getTileEntity(par4, par5, par6); - boolean bindable = tile instanceof IWandBindable; - - boolean wanded = false; - if(getBindMode(par1ItemStack) && bindable && par2EntityPlayer.isSneaking() && ((IWandBindable) tile).canSelect(par2EntityPlayer, par1ItemStack, par4, par5, par6, par7)) { - if(boundTile.posX == par4 && boundTile.posY == par5 && boundTile.posZ == par6) - setBoundTile(par1ItemStack, 0, -1, 0); - else setBoundTile(par1ItemStack, par4, par5, par6); - - if(par3World.isRemote) - par2EntityPlayer.swingItem(); - par3World.playSoundAtEntity(par2EntityPlayer, "botania:ding", 0.1F, 1F); - - wanded = true; - } else { - wanded = ((IWandable) block).onUsedByWand(par2EntityPlayer, par1ItemStack, par3World, par4, par5, par6, par7); - if(wanded && par3World.isRemote) - par2EntityPlayer.swingItem(); - } - - return wanded; - } else if(BlockPistonRelay.playerPositions.containsKey(par2EntityPlayer.getCommandSenderName()) && !par3World.isRemote) { - String bindPos = BlockPistonRelay.playerPositions.get(par2EntityPlayer.getCommandSenderName()); - String currentPos = BlockPistonRelay.getCoordsAsString(par3World.provider.dimensionId, par4, par5, par6); - - BlockPistonRelay.playerPositions.remove(par2EntityPlayer.getCommandSenderName()); - BlockPistonRelay.mappedPositions.put(bindPos, currentPos); - BlockPistonRelay.WorldData.get(par3World).markDirty(); - - par3World.playSoundAtEntity(par2EntityPlayer, "botania:ding", 1F, 1F); - } - - return false; - } - - public static void doParticleBeam(World world, Vector3 orig, Vector3 end) { - if(!world.isRemote) - return; - - Vector3 diff = end.copy().sub(orig); - Vector3 movement = diff.copy().normalize().multiply(0.05); - int iters = (int) (diff.mag() / movement.mag()); - float huePer = 1F / iters; - float hueSum = (float) Math.random(); - - Vector3 currentPos = orig.copy(); - for(int i = 0; i < iters; i++) { - float hue = i * huePer + hueSum; - Color color = Color.getHSBColor(hue, 1F, 1F); - float r = color.getRed() / 255F; - float g = color.getGreen() / 255F; - float b = color.getBlue() / 255F; - - Botania.proxy.setSparkleFXNoClip(true); - Botania.proxy.sparkleFX(world, currentPos.x, currentPos.y, currentPos.z, r, g, b, 0.5F, 4); - Botania.proxy.setSparkleFXNoClip(false); - currentPos.add(movement); - } - } - - @Override - public void onUpdate(ItemStack par1ItemStack, World par2World, Entity par3Entity, int par4, boolean par5) { - ChunkCoordinates coords = getBoundTile(par1ItemStack); - TileEntity tile = par2World.getTileEntity(coords.posX, coords.posY, coords.posZ); - if(tile == null || !(tile instanceof IWandBindable)) - setBoundTile(par1ItemStack, 0, -1, 0); - } - - @Override - public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer player) { - if(!world.isRemote && player.isSneaking()) { - setBindMode(stack, !getBindMode(stack)); - world.playSoundAtEntity(player, "botania:ding", 0.1F, 1F); - } - - return stack; - } - - @Override - public boolean isFull3D() { - return true; - } - - @Override - public void registerIcons(IIconRegister par1IconRegister) { - icons = new IIcon[4]; - for(int i = 0; i < icons.length; i++) - icons[i] = IconHelper.forItem(par1IconRegister, this, i); - } - - @Override - public IIcon getIcon(ItemStack stack, int pass) { - if(pass == 3 && !getBindMode(stack)) - pass = 0; - - return icons[Math.min(icons.length - 1, pass)]; - } - - @Override - public int getColorFromItemStack(ItemStack par1ItemStack, int par2) { - if(par2 == 0 || par2 == 3) - return 0xFFFFFF; - - float[] color = EntitySheep.fleeceColorTable[par2 == 1 ? getColor1(par1ItemStack) : getColor2(par1ItemStack)]; - return new Color(color[0], color[1], color[2]).getRGB(); - } - - @Override - public boolean requiresMultipleRenderPasses() { - return true; - } - - @Override - public int getRenderPasses(int metadata) { - return 4; - } - - @Override - public void getSubItems(Item par1, CreativeTabs par2CreativeTabs, List par3List) { - for(int i = 0; i < 16; i++) - par3List.add(forColors(i, i)); - } - - @Override - public String getUnlocalizedName(ItemStack par1ItemStack) { - return getUnlocalizedNameLazy(par1ItemStack); - } - - @Override - public void addInformation(ItemStack stack, EntityPlayer p, List list, boolean adv) { - list.add(StatCollector.translateToLocal(getModeString(stack))); - } - - @Override - public EnumRarity getRarity(ItemStack par1ItemStack) { - return EnumRarity.rare; - } - - public static ItemStack forColors(int color1, int color2) { - ItemStack stack = new ItemStack(ModItems.twigWand); - ItemNBTHelper.setInt(stack, TAG_COLOR1, color1); - ItemNBTHelper.setInt(stack, TAG_COLOR2, color2); - - return stack; - } - - public static int getColor1(ItemStack stack) { - return ItemNBTHelper.getInt(stack, TAG_COLOR1, 0); - } - - public static int getColor2(ItemStack stack) { - return ItemNBTHelper.getInt(stack, TAG_COLOR2, 0); - } - - public static void setBoundTile(ItemStack stack, int x, int y, int z) { - ItemNBTHelper.setInt(stack, TAG_BOUND_TILE_X, x); - ItemNBTHelper.setInt(stack, TAG_BOUND_TILE_Y, y); - ItemNBTHelper.setInt(stack, TAG_BOUND_TILE_Z, z); - } - - public static ChunkCoordinates getBoundTile(ItemStack stack) { - int x = ItemNBTHelper.getInt(stack, TAG_BOUND_TILE_X, 0); - int y = ItemNBTHelper.getInt(stack, TAG_BOUND_TILE_Y, -1); - int z = ItemNBTHelper.getInt(stack, TAG_BOUND_TILE_Z, 0); - return new ChunkCoordinates(x, y, z); - } - - public static boolean getBindMode(ItemStack stack) { - return ItemNBTHelper.getBoolean(stack, TAG_BIND_MODE, true); - } - - public static void setBindMode(ItemStack stack, boolean bindMode) { - ItemNBTHelper.setBoolean(stack, TAG_BIND_MODE, bindMode); - } - - public static String getModeString(ItemStack stack) { - return "botaniamisc.wandMode." + (getBindMode(stack) ? "bind" : "function"); - } - - @Override - public ChunkCoordinates getBinding(ItemStack stack) { - ChunkCoordinates bound = getBoundTile(stack); - if(bound.posY != -1) - return bound; - - MovingObjectPosition pos = Minecraft.getMinecraft().objectMouseOver; - if(pos != null) { - TileEntity tile = Minecraft.getMinecraft().theWorld.getTileEntity(pos.blockX, pos.blockY, pos.blockZ); - if(tile != null && tile instanceof ITileBound) { - ChunkCoordinates coords = ((ITileBound) tile).getBinding(); - return coords; - } - } - - return null; - } - + IIcon[] icons; + + private static final String TAG_COLOR1 = "color1"; + private static final String TAG_COLOR2 = "color2"; + private static final String TAG_BOUND_TILE_X = "boundTileX"; + private static final String TAG_BOUND_TILE_Y = "boundTileY"; + private static final String TAG_BOUND_TILE_Z = "boundTileZ"; + private static final String TAG_BIND_MODE = "bindMode"; + + public ItemTwigWand() { + super(LibItemNames.TWIG_WAND); + setMaxStackSize(1); + } + + @Override + public boolean onItemUse( + ItemStack par1ItemStack, + EntityPlayer par2EntityPlayer, + World par3World, + int par4, + int par5, + int par6, + int par7, + float par8, + float par9, + float par10) { + Block block = par3World.getBlock(par4, par5, par6); + ChunkCoordinates boundTile = getBoundTile(par1ItemStack); + + if (boundTile.posY != -1 + && par2EntityPlayer.isSneaking() + && (boundTile.posX != par4 || boundTile.posY != par5 || boundTile.posZ != par6)) { + TileEntity tile = par3World.getTileEntity(boundTile.posX, boundTile.posY, boundTile.posZ); + if (tile instanceof IWandBindable) { + if (((IWandBindable) tile).bindTo(par2EntityPlayer, par1ItemStack, par4, par5, par6, par7)) { + Vector3 orig = new Vector3(boundTile.posX + 0.5, boundTile.posY + 0.5, boundTile.posZ + 0.5); + Vector3 end = new Vector3(par4 + 0.5, par5 + 0.5, par6 + 0.5); + doParticleBeam(par3World, orig, end); + + VanillaPacketDispatcher.dispatchTEToNearbyPlayers( + par3World, boundTile.posX, boundTile.posY, boundTile.posZ); + setBoundTile(par1ItemStack, 0, -1, 0); + } + + return true; + } else setBoundTile(par1ItemStack, 0, -1, 0); + } else if (par2EntityPlayer.isSneaking()) { + block.rotateBlock(par3World, par4, par5, par6, ForgeDirection.getOrientation(par7)); + if (par3World.isRemote) par2EntityPlayer.swingItem(); + } + + if (block == Blocks.lapis_block && ConfigHandler.enchanterEnabled) { + int meta = -1; + if (TileEnchanter.canEnchanterExist(par3World, par4, par5, par6, 0)) meta = 0; + else if (TileEnchanter.canEnchanterExist(par3World, par4, par5, par6, 1)) meta = 1; + + if (meta != -1 && !par3World.isRemote) { + par3World.setBlock(par4, par5, par6, ModBlocks.enchanter, meta, 1 | 2); + par2EntityPlayer.addStat(ModAchievements.enchanterMake, 1); + par3World.playSoundEffect(par4, par5, par6, "botania:enchanterBlock", 0.5F, 0.6F); + for (int i = 0; i < 50; i++) { + float red = (float) Math.random(); + float green = (float) Math.random(); + float blue = (float) Math.random(); + + double x = (Math.random() - 0.5) * 6; + double y = (Math.random() - 0.5) * 6; + double z = (Math.random() - 0.5) * 6; + + float velMul = 0.07F; + + Botania.proxy.wispFX( + par3World, + par4 + 0.5 + x, + par5 + 0.5 + y, + par6 + 0.5 + z, + red, + green, + blue, + (float) Math.random() * 0.15F + 0.15F, + (float) -x * velMul, + (float) -y * velMul, + (float) -z * velMul); + } + } + } else if (block instanceof IWandable) { + TileEntity tile = par3World.getTileEntity(par4, par5, par6); + boolean bindable = tile instanceof IWandBindable; + + boolean wanded = false; + if (getBindMode(par1ItemStack) + && bindable + && par2EntityPlayer.isSneaking() + && ((IWandBindable) tile).canSelect(par2EntityPlayer, par1ItemStack, par4, par5, par6, par7)) { + if (boundTile.posX == par4 && boundTile.posY == par5 && boundTile.posZ == par6) + setBoundTile(par1ItemStack, 0, -1, 0); + else setBoundTile(par1ItemStack, par4, par5, par6); + + if (par3World.isRemote) par2EntityPlayer.swingItem(); + par3World.playSoundAtEntity(par2EntityPlayer, "botania:ding", 0.1F, 1F); + + wanded = true; + } else { + wanded = ((IWandable) block) + .onUsedByWand(par2EntityPlayer, par1ItemStack, par3World, par4, par5, par6, par7); + if (wanded && par3World.isRemote) par2EntityPlayer.swingItem(); + } + + return wanded; + } else if (BlockPistonRelay.playerPositions.containsKey(par2EntityPlayer.getCommandSenderName()) + && !par3World.isRemote) { + String bindPos = BlockPistonRelay.playerPositions.get(par2EntityPlayer.getCommandSenderName()); + String currentPos = BlockPistonRelay.getCoordsAsString(par3World.provider.dimensionId, par4, par5, par6); + + BlockPistonRelay.playerPositions.remove(par2EntityPlayer.getCommandSenderName()); + BlockPistonRelay.mappedPositions.put(bindPos, currentPos); + BlockPistonRelay.WorldData.get(par3World).markDirty(); + + par3World.playSoundAtEntity(par2EntityPlayer, "botania:ding", 1F, 1F); + } + + return false; + } + + public static void doParticleBeam(World world, Vector3 orig, Vector3 end) { + if (!world.isRemote) return; + + Vector3 diff = end.copy().sub(orig); + Vector3 movement = diff.copy().normalize().multiply(0.05); + int iters = (int) (diff.mag() / movement.mag()); + float huePer = 1F / iters; + float hueSum = (float) Math.random(); + + Vector3 currentPos = orig.copy(); + for (int i = 0; i < iters; i++) { + float hue = i * huePer + hueSum; + Color color = Color.getHSBColor(hue, 1F, 1F); + float r = color.getRed() / 255F; + float g = color.getGreen() / 255F; + float b = color.getBlue() / 255F; + + Botania.proxy.setSparkleFXNoClip(true); + Botania.proxy.sparkleFX(world, currentPos.x, currentPos.y, currentPos.z, r, g, b, 0.5F, 4); + Botania.proxy.setSparkleFXNoClip(false); + currentPos.add(movement); + } + } + + @Override + public void onUpdate(ItemStack par1ItemStack, World par2World, Entity par3Entity, int par4, boolean par5) { + ChunkCoordinates coords = getBoundTile(par1ItemStack); + TileEntity tile = par2World.getTileEntity(coords.posX, coords.posY, coords.posZ); + if (tile == null || !(tile instanceof IWandBindable)) setBoundTile(par1ItemStack, 0, -1, 0); + } + + @Override + public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer player) { + if (!world.isRemote && player.isSneaking()) { + setBindMode(stack, !getBindMode(stack)); + world.playSoundAtEntity(player, "botania:ding", 0.1F, 1F); + } + + return stack; + } + + @Override + public boolean isFull3D() { + return true; + } + + @Override + public void registerIcons(IIconRegister par1IconRegister) { + icons = new IIcon[4]; + for (int i = 0; i < icons.length; i++) icons[i] = IconHelper.forItem(par1IconRegister, this, i); + } + + @Override + public IIcon getIcon(ItemStack stack, int pass) { + if (pass == 3 && !getBindMode(stack)) pass = 0; + + return icons[Math.min(icons.length - 1, pass)]; + } + + @Override + public int getColorFromItemStack(ItemStack par1ItemStack, int par2) { + if (par2 == 0 || par2 == 3) return 0xFFFFFF; + + float[] color = EntitySheep.fleeceColorTable[par2 == 1 ? getColor1(par1ItemStack) : getColor2(par1ItemStack)]; + return new Color(color[0], color[1], color[2]).getRGB(); + } + + @Override + public boolean requiresMultipleRenderPasses() { + return true; + } + + @Override + public int getRenderPasses(int metadata) { + return 4; + } + + @Override + public void getSubItems(Item par1, CreativeTabs par2CreativeTabs, List par3List) { + for (int i = 0; i < 16; i++) par3List.add(forColors(i, i)); + } + + @Override + public String getUnlocalizedName(ItemStack par1ItemStack) { + return getUnlocalizedNameLazy(par1ItemStack); + } + + @Override + public void addInformation(ItemStack stack, EntityPlayer p, List list, boolean adv) { + list.add(StatCollector.translateToLocal(getModeString(stack))); + } + + @Override + public EnumRarity getRarity(ItemStack par1ItemStack) { + return EnumRarity.rare; + } + + public static ItemStack forColors(int color1, int color2) { + ItemStack stack = new ItemStack(ModItems.twigWand); + ItemNBTHelper.setInt(stack, TAG_COLOR1, color1); + ItemNBTHelper.setInt(stack, TAG_COLOR2, color2); + + return stack; + } + + public static int getColor1(ItemStack stack) { + return ItemNBTHelper.getInt(stack, TAG_COLOR1, 0); + } + + public static int getColor2(ItemStack stack) { + return ItemNBTHelper.getInt(stack, TAG_COLOR2, 0); + } + + public static void setBoundTile(ItemStack stack, int x, int y, int z) { + ItemNBTHelper.setInt(stack, TAG_BOUND_TILE_X, x); + ItemNBTHelper.setInt(stack, TAG_BOUND_TILE_Y, y); + ItemNBTHelper.setInt(stack, TAG_BOUND_TILE_Z, z); + } + + public static ChunkCoordinates getBoundTile(ItemStack stack) { + int x = ItemNBTHelper.getInt(stack, TAG_BOUND_TILE_X, 0); + int y = ItemNBTHelper.getInt(stack, TAG_BOUND_TILE_Y, -1); + int z = ItemNBTHelper.getInt(stack, TAG_BOUND_TILE_Z, 0); + return new ChunkCoordinates(x, y, z); + } + + public static boolean getBindMode(ItemStack stack) { + return ItemNBTHelper.getBoolean(stack, TAG_BIND_MODE, true); + } + + public static void setBindMode(ItemStack stack, boolean bindMode) { + ItemNBTHelper.setBoolean(stack, TAG_BIND_MODE, bindMode); + } + + public static String getModeString(ItemStack stack) { + return "botaniamisc.wandMode." + (getBindMode(stack) ? "bind" : "function"); + } + + @Override + public ChunkCoordinates getBinding(ItemStack stack) { + ChunkCoordinates bound = getBoundTile(stack); + if (bound.posY != -1) return bound; + + MovingObjectPosition pos = Minecraft.getMinecraft().objectMouseOver; + if (pos != null) { + TileEntity tile = Minecraft.getMinecraft().theWorld.getTileEntity(pos.blockX, pos.blockY, pos.blockZ); + if (tile != null && tile instanceof ITileBound) { + ChunkCoordinates coords = ((ITileBound) tile).getBinding(); + return coords; + } + } + + return null; + } } diff --git a/src/main/java/vazkii/botania/common/item/ItemVineBall.java b/src/main/java/vazkii/botania/common/item/ItemVineBall.java index 0c871586e6..f2bf6c4685 100644 --- a/src/main/java/vazkii/botania/common/item/ItemVineBall.java +++ b/src/main/java/vazkii/botania/common/item/ItemVineBall.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jun 26, 2014, 7:50:37 PM (GMT)] */ package vazkii.botania.common.item; @@ -18,21 +18,19 @@ public class ItemVineBall extends ItemMod { - public ItemVineBall() { - setUnlocalizedName(LibItemNames.VINE_BALL); - } + public ItemVineBall() { + setUnlocalizedName(LibItemNames.VINE_BALL); + } - @Override - public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer) { - if(!par3EntityPlayer.capabilities.isCreativeMode) - --par1ItemStack.stackSize; + @Override + public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer) { + if (!par3EntityPlayer.capabilities.isCreativeMode) --par1ItemStack.stackSize; - par2World.playSoundAtEntity(par3EntityPlayer, "random.bow", 0.5F, 0.4F / (par2World.rand.nextFloat() * 0.4F + 0.8F)); + par2World.playSoundAtEntity( + par3EntityPlayer, "random.bow", 0.5F, 0.4F / (par2World.rand.nextFloat() * 0.4F + 0.8F)); - if(!par2World.isRemote) - par2World.spawnEntityInWorld(new EntityVineBall(par3EntityPlayer, true)); - - return par1ItemStack; - } + if (!par2World.isRemote) par2World.spawnEntityInWorld(new EntityVineBall(par3EntityPlayer, true)); + return par1ItemStack; + } } diff --git a/src/main/java/vazkii/botania/common/item/ItemVirus.java b/src/main/java/vazkii/botania/common/item/ItemVirus.java index 1ccca7d495..85b71c5b91 100644 --- a/src/main/java/vazkii/botania/common/item/ItemVirus.java +++ b/src/main/java/vazkii/botania/common/item/ItemVirus.java @@ -2,16 +2,19 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jul 21, 2014, 4:46:17 PM (GMT)] */ package vazkii.botania.common.item; +import cpw.mods.fml.common.eventhandler.SubscribeEvent; +import cpw.mods.fml.relauncher.ReflectionHelper; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; import java.util.List; - import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.entity.EntityLivingBase; @@ -31,86 +34,91 @@ import vazkii.botania.client.core.helper.IconHelper; import vazkii.botania.common.lib.LibItemNames; import vazkii.botania.common.lib.LibObfuscation; -import cpw.mods.fml.common.eventhandler.SubscribeEvent; -import cpw.mods.fml.relauncher.ReflectionHelper; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; public class ItemVirus extends ItemMod { - IIcon[] icons; - - private static final int SUBTYPES = 2; - - public ItemVirus() { - setUnlocalizedName(LibItemNames.VIRUS); - setHasSubtypes(true); - MinecraftForge.EVENT_BUS.register(this); - } - - @Override - public boolean itemInteractionForEntity(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, EntityLivingBase par3EntityLivingBase) { - if(par3EntityLivingBase instanceof EntityHorse) { - EntityHorse horse = (EntityHorse) par3EntityLivingBase; - if(horse.getHorseType() != 3 && horse.getHorseType() != 4 && horse.isTame()) { - horse.setHorseType(3 + par1ItemStack.getItemDamage()); - BaseAttributeMap attributes = horse.getAttributeMap(); - IAttributeInstance movementSpeed = attributes.getAttributeInstance(SharedMonsterAttributes.movementSpeed); - IAttributeInstance health = attributes.getAttributeInstance(SharedMonsterAttributes.maxHealth); - health.applyModifier(new AttributeModifier("Ermergerd Virus D:", health.getBaseValue(), 0)); - movementSpeed.applyModifier(new AttributeModifier("Ermergerd Virus D:", movementSpeed.getBaseValue(), 0)); - IAttributeInstance jumpHeight = attributes.getAttributeInstance(ReflectionHelper.getPrivateValue(EntityHorse.class, null, LibObfuscation.HORSE_JUMP_STRENGTH)); - jumpHeight.applyModifier(new AttributeModifier("Ermergerd Virus D:", jumpHeight.getBaseValue() * 0.5, 0)); - par2EntityPlayer.worldObj.playSound(par3EntityLivingBase.posX + 0.5D, par3EntityLivingBase.posY + 0.5D, par3EntityLivingBase.posZ + 0.5D, "mob.zombie.remedy", 1.0F + par3EntityLivingBase.worldObj.rand.nextFloat(), par3EntityLivingBase.worldObj.rand.nextFloat() * 0.7F + 1.3F, false); - - par1ItemStack.stackSize--; - return true; - } - } - return false; - } - - @SubscribeEvent - public void onLivingHurt(LivingHurtEvent event) { - EntityLivingBase entity = event.entityLiving; - if(entity.ridingEntity != null && entity.ridingEntity instanceof EntityLivingBase) - entity = (EntityLivingBase) entity.ridingEntity; - - if(entity instanceof EntityHorse && event.source == DamageSource.fall) { - EntityHorse horse = (EntityHorse) entity; - if((horse.getHorseType() == 3 || horse.getHorseType() == 4) && horse.isTame()) - event.setCanceled(true); - } - } - - @Override - @SideOnly(Side.CLIENT) - public void getSubItems(Item item, CreativeTabs tab, List list) { - for(int i = 0; i < SUBTYPES; i++) - list.add(new ItemStack(item, 1, i)); - } - - @Override - @SideOnly(Side.CLIENT) - public IIcon getIconFromDamage(int par1) { - return icons[Math.min(icons.length - 1, par1)]; - } - - @Override - public String getUnlocalizedName(ItemStack par1ItemStack) { - return getUnlocalizedNameLazy(par1ItemStack) + par1ItemStack.getItemDamage(); - } - - String getUnlocalizedNameLazy(ItemStack par1ItemStack) { - return super.getUnlocalizedName(par1ItemStack); - } - - @Override - @SideOnly(Side.CLIENT) - public void registerIcons(IIconRegister par1IconRegister) { - icons = new IIcon[SUBTYPES]; - for(int i = 0; i < SUBTYPES; i++) - icons[i] = IconHelper.forItem(par1IconRegister, this, i); - } - + IIcon[] icons; + + private static final int SUBTYPES = 2; + + public ItemVirus() { + setUnlocalizedName(LibItemNames.VIRUS); + setHasSubtypes(true); + MinecraftForge.EVENT_BUS.register(this); + } + + @Override + public boolean itemInteractionForEntity( + ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, EntityLivingBase par3EntityLivingBase) { + if (par3EntityLivingBase instanceof EntityHorse) { + EntityHorse horse = (EntityHorse) par3EntityLivingBase; + if (horse.getHorseType() != 3 && horse.getHorseType() != 4 && horse.isTame()) { + horse.setHorseType(3 + par1ItemStack.getItemDamage()); + BaseAttributeMap attributes = horse.getAttributeMap(); + IAttributeInstance movementSpeed = + attributes.getAttributeInstance(SharedMonsterAttributes.movementSpeed); + IAttributeInstance health = attributes.getAttributeInstance(SharedMonsterAttributes.maxHealth); + health.applyModifier(new AttributeModifier("Ermergerd Virus D:", health.getBaseValue(), 0)); + movementSpeed.applyModifier( + new AttributeModifier("Ermergerd Virus D:", movementSpeed.getBaseValue(), 0)); + IAttributeInstance jumpHeight = + attributes.getAttributeInstance(ReflectionHelper.getPrivateValue( + EntityHorse.class, null, LibObfuscation.HORSE_JUMP_STRENGTH)); + jumpHeight.applyModifier( + new AttributeModifier("Ermergerd Virus D:", jumpHeight.getBaseValue() * 0.5, 0)); + par2EntityPlayer.worldObj.playSound( + par3EntityLivingBase.posX + 0.5D, + par3EntityLivingBase.posY + 0.5D, + par3EntityLivingBase.posZ + 0.5D, + "mob.zombie.remedy", + 1.0F + par3EntityLivingBase.worldObj.rand.nextFloat(), + par3EntityLivingBase.worldObj.rand.nextFloat() * 0.7F + 1.3F, + false); + + par1ItemStack.stackSize--; + return true; + } + } + return false; + } + + @SubscribeEvent + public void onLivingHurt(LivingHurtEvent event) { + EntityLivingBase entity = event.entityLiving; + if (entity.ridingEntity != null && entity.ridingEntity instanceof EntityLivingBase) + entity = (EntityLivingBase) entity.ridingEntity; + + if (entity instanceof EntityHorse && event.source == DamageSource.fall) { + EntityHorse horse = (EntityHorse) entity; + if ((horse.getHorseType() == 3 || horse.getHorseType() == 4) && horse.isTame()) event.setCanceled(true); + } + } + + @Override + @SideOnly(Side.CLIENT) + public void getSubItems(Item item, CreativeTabs tab, List list) { + for (int i = 0; i < SUBTYPES; i++) list.add(new ItemStack(item, 1, i)); + } + + @Override + @SideOnly(Side.CLIENT) + public IIcon getIconFromDamage(int par1) { + return icons[Math.min(icons.length - 1, par1)]; + } + + @Override + public String getUnlocalizedName(ItemStack par1ItemStack) { + return getUnlocalizedNameLazy(par1ItemStack) + par1ItemStack.getItemDamage(); + } + + String getUnlocalizedNameLazy(ItemStack par1ItemStack) { + return super.getUnlocalizedName(par1ItemStack); + } + + @Override + @SideOnly(Side.CLIENT) + public void registerIcons(IIconRegister par1IconRegister) { + icons = new IIcon[SUBTYPES]; + for (int i = 0; i < SUBTYPES; i++) icons[i] = IconHelper.forItem(par1IconRegister, this, i); + } } diff --git a/src/main/java/vazkii/botania/common/item/ItemWaterBowl.java b/src/main/java/vazkii/botania/common/item/ItemWaterBowl.java index a873f5258e..bcd109934a 100644 --- a/src/main/java/vazkii/botania/common/item/ItemWaterBowl.java +++ b/src/main/java/vazkii/botania/common/item/ItemWaterBowl.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jul 8, 2015, 9:07:35 PM (GMT)] */ package vazkii.botania.common.item; @@ -14,9 +14,8 @@ public class ItemWaterBowl extends ItemMod { - public ItemWaterBowl() { - setMaxStackSize(1); - setUnlocalizedName(LibItemNames.WATER_BOWL); - } - + public ItemWaterBowl() { + setMaxStackSize(1); + setUnlocalizedName(LibItemNames.WATER_BOWL); + } } diff --git a/src/main/java/vazkii/botania/common/item/ItemWorldSeed.java b/src/main/java/vazkii/botania/common/item/ItemWorldSeed.java index 9d1fc7f545..6d0f3aa3ee 100644 --- a/src/main/java/vazkii/botania/common/item/ItemWorldSeed.java +++ b/src/main/java/vazkii/botania/common/item/ItemWorldSeed.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jan 25, 2015, 12:27:31 AM (GMT)] */ package vazkii.botania.common.item; @@ -20,30 +20,40 @@ public class ItemWorldSeed extends ItemMod { - public ItemWorldSeed() { - setUnlocalizedName(LibItemNames.WORLD_SEED); - } - - @Override - public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer player) { - ChunkCoordinates coords = world.getSpawnPoint(); - - if(MathHelper.pointDistanceSpace(coords.posX + 0.5, coords.posY + 0.5, coords.posZ + 0.5, player.posX, player.posY, player.posZ) > 24) { - player.rotationPitch = 0F; - player.rotationYaw = 0F; - player.setPositionAndUpdate(coords.posX + 0.5, coords.posY + 1.6, coords.posZ + 0.5); - - while(!world.getCollidingBoundingBoxes(player, player.boundingBox).isEmpty()) - player.setPositionAndUpdate(player.posX, player.posY + 1, player.posZ); - - world.playSoundAtEntity(player, "mob.endermen.portal", 1F, 1F); - for(int i = 0; i < 50; i++) - Botania.proxy.sparkleFX(world, player.posX + Math.random() * player.width, player.posY - 1.6 + Math.random() * player.height, player.posZ + Math.random() * player.width, 0.25F, 1F, 0.25F, 1F, 10); - - stack.stackSize--; - } - - return stack; - } - + public ItemWorldSeed() { + setUnlocalizedName(LibItemNames.WORLD_SEED); + } + + @Override + public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer player) { + ChunkCoordinates coords = world.getSpawnPoint(); + + if (MathHelper.pointDistanceSpace( + coords.posX + 0.5, coords.posY + 0.5, coords.posZ + 0.5, player.posX, player.posY, player.posZ) + > 24) { + player.rotationPitch = 0F; + player.rotationYaw = 0F; + player.setPositionAndUpdate(coords.posX + 0.5, coords.posY + 1.6, coords.posZ + 0.5); + + while (!world.getCollidingBoundingBoxes(player, player.boundingBox).isEmpty()) + player.setPositionAndUpdate(player.posX, player.posY + 1, player.posZ); + + world.playSoundAtEntity(player, "mob.endermen.portal", 1F, 1F); + for (int i = 0; i < 50; i++) + Botania.proxy.sparkleFX( + world, + player.posX + Math.random() * player.width, + player.posY - 1.6 + Math.random() * player.height, + player.posZ + Math.random() * player.width, + 0.25F, + 1F, + 0.25F, + 1F, + 10); + + stack.stackSize--; + } + + return stack; + } } diff --git a/src/main/java/vazkii/botania/common/item/ModItems.java b/src/main/java/vazkii/botania/common/item/ModItems.java index d029d5a931..ea65f58b30 100644 --- a/src/main/java/vazkii/botania/common/item/ModItems.java +++ b/src/main/java/vazkii/botania/common/item/ModItems.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jan 14, 2014, 5:17:47 PM (GMT)] */ package vazkii.botania.common.item; @@ -120,350 +120,348 @@ public final class ModItems { - public static Item lexicon; - public static Item petal; - public static Item dye; - public static Item pestleAndMortar; - public static Item twigWand; - public static Item manaResource; - public static Item lens; - public static Item rune; - public static Item signalFlare; - public static Item manaTablet; - public static Item manaGun; - public static Item manaCookie; - public static Item fertilizer; - public static Item grassSeeds; - public static Item dirtRod; - public static Item terraformRod; - public static Item grassHorn; - public static Item manaMirror; - public static Item manasteelHelm; - public static Item manasteelHelmRevealing; - public static Item manasteelChest; - public static Item manasteelLegs; - public static Item manasteelBoots; - public static Item manasteelPick; - public static Item manasteelShovel; - public static Item manasteelAxe; - public static Item manasteelSword; - public static Item manasteelShears; - public static Item terrasteelHelm; - public static Item terrasteelHelmRevealing; - public static Item terrasteelChest; - public static Item terrasteelLegs; - public static Item terrasteelBoots; - public static Item terraSword; - public static Item tinyPlanet; - public static Item manaRing; - public static Item auraRing; - public static Item manaRingGreater; - public static Item auraRingGreater; - public static Item travelBelt; - public static Item knockbackBelt; - public static Item icePendant; - public static Item lavaPendant; - public static Item goldLaurel; - public static Item magnetRing; - public static Item waterRing; - public static Item miningRing; - public static Item terraPick; - public static Item divaCharm; - public static Item flightTiara; - public static Item enderDagger; - public static Item quartz; - public static Item waterRod; - public static Item elementiumHelm; - public static Item elementiumHelmRevealing; - public static Item elementiumChest; - public static Item elementiumLegs; - public static Item elementiumBoots; - public static Item elementiumPick; - public static Item elementiumShovel; - public static Item elementiumAxe; - public static Item elementiumSword; - public static Item elementiumShears; - public static Item openBucket; - public static Item spawnerMover; - public static Item pixieRing; - public static Item superTravelBelt; - public static Item rainbowRod; - public static Item tornadoRod; - public static Item fireRod; - public static Item vineBall; - public static Item slingshot; - public static Item manaBottle; - public static Item laputaShard; - public static Item virus; - public static Item reachRing; - public static Item skyDirtRod; - public static Item itemFinder; - public static Item superLavaPendant; - public static Item enderHand; - public static Item glassPick; - public static Item spark; - public static Item sparkUpgrade; - public static Item diviningRod; - public static Item gravityRod; - public static Item regenIvy; - public static Item manaInkwell; - public static Item vial; - public static Item brewVial; - public static Item brewFlask; - public static Item bloodPendant; - public static Item missileRod; - public static Item holyCloak; - public static Item unholyCloak; - public static Item craftingHalo; - public static Item blackLotus; - public static Item monocle; - public static Item clip; - public static Item cobbleRod; - public static Item smeltRod; - public static Item worldSeed; - public static Item spellCloth; - public static Item thornChakram; - public static Item overgrowthSeed; - public static Item craftPattern; - public static Item ancientWill; - public static Item corporeaSpark; - public static Item livingwoodBow; - public static Item crystalBow; - public static Item cosmetic; - public static Item swapRing; - public static Item flowerBag; - public static Item phantomInk; - public static Item poolMinecart; - public static Item pinkinator; - public static Item infiniteFruit; - public static Item kingKey; - public static Item flugelEye; - public static Item thorRing; - public static Item odinRing; - public static Item lokiRing; - public static Item aesirRing; - public static Item dice; - public static Item keepIvy; - public static Item blackHoleTalisman; - public static Item recordGaia1; - public static Item recordGaia2; - public static Item temperanceStone; - public static Item incenseStick; - public static Item terraAxe; - public static Item waterBowl; - public static Item obedienceStick; - public static Item cacophonium; - public static Item slimeBottle; - public static Item starSword; - public static Item exchangeRod; - public static Item magnetRingGreater; - public static Item thunderSword; - public static Item manaweaveHelm; - public static Item manaweaveChest; - public static Item manaweaveLegs; - public static Item manaweaveBoots; - public static Item autocraftingHalo; - public static Item gaiaHead; - public static Item sextant; - public static Item speedUpBelt; - public static Item baubleBox; + public static Item lexicon; + public static Item petal; + public static Item dye; + public static Item pestleAndMortar; + public static Item twigWand; + public static Item manaResource; + public static Item lens; + public static Item rune; + public static Item signalFlare; + public static Item manaTablet; + public static Item manaGun; + public static Item manaCookie; + public static Item fertilizer; + public static Item grassSeeds; + public static Item dirtRod; + public static Item terraformRod; + public static Item grassHorn; + public static Item manaMirror; + public static Item manasteelHelm; + public static Item manasteelHelmRevealing; + public static Item manasteelChest; + public static Item manasteelLegs; + public static Item manasteelBoots; + public static Item manasteelPick; + public static Item manasteelShovel; + public static Item manasteelAxe; + public static Item manasteelSword; + public static Item manasteelShears; + public static Item terrasteelHelm; + public static Item terrasteelHelmRevealing; + public static Item terrasteelChest; + public static Item terrasteelLegs; + public static Item terrasteelBoots; + public static Item terraSword; + public static Item tinyPlanet; + public static Item manaRing; + public static Item auraRing; + public static Item manaRingGreater; + public static Item auraRingGreater; + public static Item travelBelt; + public static Item knockbackBelt; + public static Item icePendant; + public static Item lavaPendant; + public static Item goldLaurel; + public static Item magnetRing; + public static Item waterRing; + public static Item miningRing; + public static Item terraPick; + public static Item divaCharm; + public static Item flightTiara; + public static Item enderDagger; + public static Item quartz; + public static Item waterRod; + public static Item elementiumHelm; + public static Item elementiumHelmRevealing; + public static Item elementiumChest; + public static Item elementiumLegs; + public static Item elementiumBoots; + public static Item elementiumPick; + public static Item elementiumShovel; + public static Item elementiumAxe; + public static Item elementiumSword; + public static Item elementiumShears; + public static Item openBucket; + public static Item spawnerMover; + public static Item pixieRing; + public static Item superTravelBelt; + public static Item rainbowRod; + public static Item tornadoRod; + public static Item fireRod; + public static Item vineBall; + public static Item slingshot; + public static Item manaBottle; + public static Item laputaShard; + public static Item virus; + public static Item reachRing; + public static Item skyDirtRod; + public static Item itemFinder; + public static Item superLavaPendant; + public static Item enderHand; + public static Item glassPick; + public static Item spark; + public static Item sparkUpgrade; + public static Item diviningRod; + public static Item gravityRod; + public static Item regenIvy; + public static Item manaInkwell; + public static Item vial; + public static Item brewVial; + public static Item brewFlask; + public static Item bloodPendant; + public static Item missileRod; + public static Item holyCloak; + public static Item unholyCloak; + public static Item craftingHalo; + public static Item blackLotus; + public static Item monocle; + public static Item clip; + public static Item cobbleRod; + public static Item smeltRod; + public static Item worldSeed; + public static Item spellCloth; + public static Item thornChakram; + public static Item overgrowthSeed; + public static Item craftPattern; + public static Item ancientWill; + public static Item corporeaSpark; + public static Item livingwoodBow; + public static Item crystalBow; + public static Item cosmetic; + public static Item swapRing; + public static Item flowerBag; + public static Item phantomInk; + public static Item poolMinecart; + public static Item pinkinator; + public static Item infiniteFruit; + public static Item kingKey; + public static Item flugelEye; + public static Item thorRing; + public static Item odinRing; + public static Item lokiRing; + public static Item aesirRing; + public static Item dice; + public static Item keepIvy; + public static Item blackHoleTalisman; + public static Item recordGaia1; + public static Item recordGaia2; + public static Item temperanceStone; + public static Item incenseStick; + public static Item terraAxe; + public static Item waterBowl; + public static Item obedienceStick; + public static Item cacophonium; + public static Item slimeBottle; + public static Item starSword; + public static Item exchangeRod; + public static Item magnetRingGreater; + public static Item thunderSword; + public static Item manaweaveHelm; + public static Item manaweaveChest; + public static Item manaweaveLegs; + public static Item manaweaveBoots; + public static Item autocraftingHalo; + public static Item gaiaHead; + public static Item sextant; + public static Item speedUpBelt; + public static Item baubleBox; - public static void init() { - lexicon = new ItemLexicon(); - petal = new ItemPetal(); - dye = new ItemDye(); - pestleAndMortar = new ItemPestleAndMortar(); - twigWand = new ItemTwigWand(); - manaResource = new ItemManaResource(); - lens = new ItemLens(); - rune = new ItemRune(); - signalFlare = new ItemSignalFlare(); - manaTablet = new ItemManaTablet(); - manaGun = new ItemManaGun(); - manaCookie = new ItemManaCookie(); - fertilizer = new ItemFertilizer(); - grassSeeds = new ItemGrassSeeds(); - dirtRod = new ItemDirtRod(); - terraformRod = new ItemTerraformRod(); - grassHorn = new ItemGrassHorn(); - manaMirror = new ItemManaMirror(); - manasteelHelm = new ItemManasteelHelm(); - manasteelHelmRevealing = new ItemManasteelHelmRevealing(); - manasteelChest = new ItemManasteelChest(); - manasteelLegs = new ItemManasteelLegs(); - manasteelBoots = new ItemManasteelBoots(); - manasteelPick = new ItemManasteelPick(); - manasteelShovel = new ItemManasteelShovel(); - manasteelAxe = new ItemManasteelAxe(); - manasteelSword = new ItemManasteelSword(); - manasteelShears = new ItemManasteelShears(); - terrasteelHelm = new ItemTerrasteelHelm(); - terrasteelHelmRevealing = new ItemTerrasteelHelmRevealing(); - terrasteelChest = new ItemTerrasteelChest(); - terrasteelLegs = new ItemTerrasteelLegs(); - terrasteelBoots = new ItemTerrasteelBoots(); - terraSword = new ItemTerraSword(); - tinyPlanet = new ItemTinyPlanet(); - manaRing = new ItemManaRing(); - auraRing = new ItemAuraRing(); - manaRingGreater = new ItemGreaterManaRing(); - auraRingGreater = new ItemGreaterAuraRing(); - travelBelt = new ItemTravelBelt(); - knockbackBelt = new ItemKnockbackBelt(); - icePendant = new ItemIcePendant(); - lavaPendant = new ItemLavaPendant(); - goldLaurel = new ItemGoldenLaurel(); - magnetRing = new ItemMagnetRing(); - waterRing = new ItemWaterRing(); - miningRing = new ItemMiningRing(); - terraPick = new ItemTerraPick(); - divaCharm = new ItemDivaCharm(); - flightTiara = new ItemFlightTiara(); - enderDagger = new ItemEnderDagger(); - quartz = new ItemQuartz(); - waterRod = new ItemWaterRod(); - elementiumHelm = new ItemElementiumHelm(); - elementiumHelmRevealing = new ItemElementiumHelmRevealing(); - elementiumChest = new ItemElementiumChest(); - elementiumLegs = new ItemElementiumLegs(); - elementiumBoots = new ItemElementiumBoots(); - elementiumPick = new ItemElementiumPick(); - elementiumShovel = new ItemElementiumShovel(); - elementiumAxe = new ItemElementiumAxe(); - elementiumSword = new ItemElementiumSword(); - elementiumShears = new ItemElementiumShears(); - openBucket = new ItemOpenBucket(); - spawnerMover = new ItemSpawnerMover(); - pixieRing = new ItemPixieRing(); - superTravelBelt = new ItemSuperTravelBelt(); - rainbowRod = new ItemRainbowRod(); - tornadoRod = new ItemTornadoRod(); - fireRod = new ItemFireRod(); - vineBall = new ItemVineBall(); - slingshot = new ItemSlingshot(); - manaBottle = new ItemBottledMana(); - laputaShard = new ItemLaputaShard(); - virus = new ItemVirus(); - reachRing = new ItemReachRing(); - skyDirtRod = new ItemSkyDirtRod(); - itemFinder = new ItemItemFinder(); - superLavaPendant = new ItemSuperLavaPendant(); - enderHand = new ItemEnderHand(); - glassPick = new ItemGlassPick(); - spark = new ItemSpark(); - sparkUpgrade = new ItemSparkUpgrade(); - diviningRod = new ItemDiviningRod(); - gravityRod = new ItemGravityRod(); - regenIvy = new ItemRegenIvy(); - manaInkwell = new ItemManaInkwell(); - vial = new ItemVial(); - brewVial = new ItemBrewVial(); - brewFlask = new ItemBrewFlask(); - bloodPendant = new ItemBloodPendant(); - missileRod = new ItemMissileRod(); - holyCloak = new ItemHolyCloak(); - unholyCloak = new ItemUnholyCloak(); - craftingHalo = new ItemCraftingHalo(); - blackLotus = new ItemBlackLotus(); - monocle = new ItemMonocle(); - clip = new ItemClip(); - cobbleRod = new ItemCobbleRod(); - smeltRod = new ItemSmeltRod(); - worldSeed = new ItemWorldSeed(); - spellCloth = new ItemSpellCloth(); - thornChakram = new ItemThornChakram(); - overgrowthSeed = new ItemOvergrowthSeed(); - craftPattern = new ItemCraftPattern(); - ancientWill = new ItemAncientWill(); - corporeaSpark = new ItemCorporeaSpark(); - livingwoodBow = new ItemLivingwoodBow(); - crystalBow = new ItemCrystalBow(); - cosmetic = new ItemBaubleCosmetic(); - swapRing = new ItemSwapRing(); - flowerBag = new ItemFlowerBag(); - phantomInk = new ItemPhantomInk(); - poolMinecart = new ItemPoolMinecart(); - pinkinator = new ItemPinkinator(); - infiniteFruit = new ItemInfiniteFruit(); - kingKey = new ItemKingKey(); - flugelEye = new ItemFlugelEye(); - thorRing = new ItemThorRing(); - odinRing = new ItemOdinRing(); - lokiRing = new ItemLokiRing(); - aesirRing = new ItemAesirRing(); - dice = new ItemDice(); - keepIvy = new ItemKeepIvy(); - blackHoleTalisman = new ItemBlackHoleTalisman(); - recordGaia1 = new ItemRecordGaia1(); - recordGaia2 = new ItemRecordGaia2(); - temperanceStone = new ItemTemperanceStone(); - incenseStick = new ItemIncenseStick(); - terraAxe = new ItemTerraAxe(); - waterBowl = new ItemWaterBowl(); - obedienceStick = new ItemObedienceStick(); - cacophonium = new ItemCacophonium(); - slimeBottle = new ItemSlimeBottle(); - starSword = new ItemStarSword(); - exchangeRod = new ItemExchangeRod(); - magnetRingGreater = new ItemGreaterMagnetRing(); - thunderSword = new ItemThunderSword(); - manaweaveHelm = new ItemManaweaveHelm(); - manaweaveLegs = new ItemManaweaveLegs(); - manaweaveChest = new ItemManaweaveChest(); - manaweaveBoots = new ItemManaweaveBoots(); - autocraftingHalo = new ItemAutocraftingHalo(); - gaiaHead = new ItemGaiaHead(); - sextant = new ItemSextant(); - speedUpBelt = new ItemSpeedUpBelt(); - baubleBox = new ItemBaubleBox(); + public static void init() { + lexicon = new ItemLexicon(); + petal = new ItemPetal(); + dye = new ItemDye(); + pestleAndMortar = new ItemPestleAndMortar(); + twigWand = new ItemTwigWand(); + manaResource = new ItemManaResource(); + lens = new ItemLens(); + rune = new ItemRune(); + signalFlare = new ItemSignalFlare(); + manaTablet = new ItemManaTablet(); + manaGun = new ItemManaGun(); + manaCookie = new ItemManaCookie(); + fertilizer = new ItemFertilizer(); + grassSeeds = new ItemGrassSeeds(); + dirtRod = new ItemDirtRod(); + terraformRod = new ItemTerraformRod(); + grassHorn = new ItemGrassHorn(); + manaMirror = new ItemManaMirror(); + manasteelHelm = new ItemManasteelHelm(); + manasteelHelmRevealing = new ItemManasteelHelmRevealing(); + manasteelChest = new ItemManasteelChest(); + manasteelLegs = new ItemManasteelLegs(); + manasteelBoots = new ItemManasteelBoots(); + manasteelPick = new ItemManasteelPick(); + manasteelShovel = new ItemManasteelShovel(); + manasteelAxe = new ItemManasteelAxe(); + manasteelSword = new ItemManasteelSword(); + manasteelShears = new ItemManasteelShears(); + terrasteelHelm = new ItemTerrasteelHelm(); + terrasteelHelmRevealing = new ItemTerrasteelHelmRevealing(); + terrasteelChest = new ItemTerrasteelChest(); + terrasteelLegs = new ItemTerrasteelLegs(); + terrasteelBoots = new ItemTerrasteelBoots(); + terraSword = new ItemTerraSword(); + tinyPlanet = new ItemTinyPlanet(); + manaRing = new ItemManaRing(); + auraRing = new ItemAuraRing(); + manaRingGreater = new ItemGreaterManaRing(); + auraRingGreater = new ItemGreaterAuraRing(); + travelBelt = new ItemTravelBelt(); + knockbackBelt = new ItemKnockbackBelt(); + icePendant = new ItemIcePendant(); + lavaPendant = new ItemLavaPendant(); + goldLaurel = new ItemGoldenLaurel(); + magnetRing = new ItemMagnetRing(); + waterRing = new ItemWaterRing(); + miningRing = new ItemMiningRing(); + terraPick = new ItemTerraPick(); + divaCharm = new ItemDivaCharm(); + flightTiara = new ItemFlightTiara(); + enderDagger = new ItemEnderDagger(); + quartz = new ItemQuartz(); + waterRod = new ItemWaterRod(); + elementiumHelm = new ItemElementiumHelm(); + elementiumHelmRevealing = new ItemElementiumHelmRevealing(); + elementiumChest = new ItemElementiumChest(); + elementiumLegs = new ItemElementiumLegs(); + elementiumBoots = new ItemElementiumBoots(); + elementiumPick = new ItemElementiumPick(); + elementiumShovel = new ItemElementiumShovel(); + elementiumAxe = new ItemElementiumAxe(); + elementiumSword = new ItemElementiumSword(); + elementiumShears = new ItemElementiumShears(); + openBucket = new ItemOpenBucket(); + spawnerMover = new ItemSpawnerMover(); + pixieRing = new ItemPixieRing(); + superTravelBelt = new ItemSuperTravelBelt(); + rainbowRod = new ItemRainbowRod(); + tornadoRod = new ItemTornadoRod(); + fireRod = new ItemFireRod(); + vineBall = new ItemVineBall(); + slingshot = new ItemSlingshot(); + manaBottle = new ItemBottledMana(); + laputaShard = new ItemLaputaShard(); + virus = new ItemVirus(); + reachRing = new ItemReachRing(); + skyDirtRod = new ItemSkyDirtRod(); + itemFinder = new ItemItemFinder(); + superLavaPendant = new ItemSuperLavaPendant(); + enderHand = new ItemEnderHand(); + glassPick = new ItemGlassPick(); + spark = new ItemSpark(); + sparkUpgrade = new ItemSparkUpgrade(); + diviningRod = new ItemDiviningRod(); + gravityRod = new ItemGravityRod(); + regenIvy = new ItemRegenIvy(); + manaInkwell = new ItemManaInkwell(); + vial = new ItemVial(); + brewVial = new ItemBrewVial(); + brewFlask = new ItemBrewFlask(); + bloodPendant = new ItemBloodPendant(); + missileRod = new ItemMissileRod(); + holyCloak = new ItemHolyCloak(); + unholyCloak = new ItemUnholyCloak(); + craftingHalo = new ItemCraftingHalo(); + blackLotus = new ItemBlackLotus(); + monocle = new ItemMonocle(); + clip = new ItemClip(); + cobbleRod = new ItemCobbleRod(); + smeltRod = new ItemSmeltRod(); + worldSeed = new ItemWorldSeed(); + spellCloth = new ItemSpellCloth(); + thornChakram = new ItemThornChakram(); + overgrowthSeed = new ItemOvergrowthSeed(); + craftPattern = new ItemCraftPattern(); + ancientWill = new ItemAncientWill(); + corporeaSpark = new ItemCorporeaSpark(); + livingwoodBow = new ItemLivingwoodBow(); + crystalBow = new ItemCrystalBow(); + cosmetic = new ItemBaubleCosmetic(); + swapRing = new ItemSwapRing(); + flowerBag = new ItemFlowerBag(); + phantomInk = new ItemPhantomInk(); + poolMinecart = new ItemPoolMinecart(); + pinkinator = new ItemPinkinator(); + infiniteFruit = new ItemInfiniteFruit(); + kingKey = new ItemKingKey(); + flugelEye = new ItemFlugelEye(); + thorRing = new ItemThorRing(); + odinRing = new ItemOdinRing(); + lokiRing = new ItemLokiRing(); + aesirRing = new ItemAesirRing(); + dice = new ItemDice(); + keepIvy = new ItemKeepIvy(); + blackHoleTalisman = new ItemBlackHoleTalisman(); + recordGaia1 = new ItemRecordGaia1(); + recordGaia2 = new ItemRecordGaia2(); + temperanceStone = new ItemTemperanceStone(); + incenseStick = new ItemIncenseStick(); + terraAxe = new ItemTerraAxe(); + waterBowl = new ItemWaterBowl(); + obedienceStick = new ItemObedienceStick(); + cacophonium = new ItemCacophonium(); + slimeBottle = new ItemSlimeBottle(); + starSword = new ItemStarSword(); + exchangeRod = new ItemExchangeRod(); + magnetRingGreater = new ItemGreaterMagnetRing(); + thunderSword = new ItemThunderSword(); + manaweaveHelm = new ItemManaweaveHelm(); + manaweaveLegs = new ItemManaweaveLegs(); + manaweaveChest = new ItemManaweaveChest(); + manaweaveBoots = new ItemManaweaveBoots(); + autocraftingHalo = new ItemAutocraftingHalo(); + gaiaHead = new ItemGaiaHead(); + sextant = new ItemSextant(); + speedUpBelt = new ItemSpeedUpBelt(); + baubleBox = new ItemBaubleBox(); - OreDictionary.registerOre(LibOreDict.LEXICON, lexicon); - for(int i = 0; i < 16; i++) { - OreDictionary.registerOre(LibOreDict.PETAL[i], new ItemStack(petal, 1, i)); - OreDictionary.registerOre(LibOreDict.DYE[i], new ItemStack(dye, 1, i)); - OreDictionary.registerOre(LibOreDict.RUNE[i], new ItemStack(rune, 1, i)); - } - for(int i = 0; i < 7; i++) - OreDictionary.registerOre(LibOreDict.QUARTZ[i], new ItemStack(quartz, 1, i)); + OreDictionary.registerOre(LibOreDict.LEXICON, lexicon); + for (int i = 0; i < 16; i++) { + OreDictionary.registerOre(LibOreDict.PETAL[i], new ItemStack(petal, 1, i)); + OreDictionary.registerOre(LibOreDict.DYE[i], new ItemStack(dye, 1, i)); + OreDictionary.registerOre(LibOreDict.RUNE[i], new ItemStack(rune, 1, i)); + } + for (int i = 0; i < 7; i++) OreDictionary.registerOre(LibOreDict.QUARTZ[i], new ItemStack(quartz, 1, i)); - OreDictionary.registerOre(LibOreDict.PESTLE_AND_MORTAR, pestleAndMortar); - OreDictionary.registerOre(LibOreDict.MANA_STEEL, new ItemStack(manaResource, 1, 0)); - OreDictionary.registerOre(LibOreDict.MANA_PEARL, new ItemStack(manaResource, 1, 1)); - OreDictionary.registerOre(LibOreDict.MANA_DIAMOND, new ItemStack(manaResource, 1, 2)); - OreDictionary.registerOre(LibOreDict.LIVINGWOOD_TWIG, new ItemStack(manaResource, 1, 3)); - OreDictionary.registerOre(LibOreDict.TERRA_STEEL, new ItemStack(manaResource, 1, 4)); - OreDictionary.registerOre(LibOreDict.LIFE_ESSENCE, new ItemStack(manaResource, 1, 5)); - OreDictionary.registerOre(LibOreDict.REDSTONE_ROOT, new ItemStack(manaResource, 1, 6)); - OreDictionary.registerOre(LibOreDict.ELEMENTIUM, new ItemStack(manaResource, 1, 7)); - OreDictionary.registerOre(LibOreDict.PIXIE_DUST, new ItemStack(manaResource, 1, 8)); - OreDictionary.registerOre(LibOreDict.DRAGONSTONE, new ItemStack(manaResource, 1, 9)); - OreDictionary.registerOre(LibOreDict.PRISMARINE_SHARD, new ItemStack(manaResource, 1, 10)); - OreDictionary.registerOre(LibOreDict.PLACEHOLDER, new ItemStack(manaResource, 1, 11)); - OreDictionary.registerOre(LibOreDict.RED_STRING, new ItemStack(manaResource, 1, 12)); - OreDictionary.registerOre(LibOreDict.DREAMWOOD_TWIG, new ItemStack(manaResource, 1, 13)); - OreDictionary.registerOre(LibOreDict.GAIA_INGOT, new ItemStack(manaResource, 1, 14)); - OreDictionary.registerOre(LibOreDict.ENDER_AIR_BOTTLE, new ItemStack(manaResource, 1, 15)); - OreDictionary.registerOre(LibOreDict.MANA_STRING, new ItemStack(manaResource, 1, 16)); - OreDictionary.registerOre(LibOreDict.MANASTEEL_NUGGET, new ItemStack(manaResource, 1, 17)); - OreDictionary.registerOre(LibOreDict.TERRASTEEL_NUGGET, new ItemStack(manaResource, 1, 18)); - OreDictionary.registerOre(LibOreDict.ELEMENTIUM_NUGGET, new ItemStack(manaResource, 1, 19)); - OreDictionary.registerOre(LibOreDict.ROOT, new ItemStack(manaResource, 1, 20)); - OreDictionary.registerOre(LibOreDict.PEBBLE, new ItemStack(manaResource, 1, 21)); - OreDictionary.registerOre(LibOreDict.MANAWEAVE_CLOTH, new ItemStack(manaResource, 1, 22)); - OreDictionary.registerOre(LibOreDict.MANA_POWDER, new ItemStack(manaResource, 1, 23)); + OreDictionary.registerOre(LibOreDict.PESTLE_AND_MORTAR, pestleAndMortar); + OreDictionary.registerOre(LibOreDict.MANA_STEEL, new ItemStack(manaResource, 1, 0)); + OreDictionary.registerOre(LibOreDict.MANA_PEARL, new ItemStack(manaResource, 1, 1)); + OreDictionary.registerOre(LibOreDict.MANA_DIAMOND, new ItemStack(manaResource, 1, 2)); + OreDictionary.registerOre(LibOreDict.LIVINGWOOD_TWIG, new ItemStack(manaResource, 1, 3)); + OreDictionary.registerOre(LibOreDict.TERRA_STEEL, new ItemStack(manaResource, 1, 4)); + OreDictionary.registerOre(LibOreDict.LIFE_ESSENCE, new ItemStack(manaResource, 1, 5)); + OreDictionary.registerOre(LibOreDict.REDSTONE_ROOT, new ItemStack(manaResource, 1, 6)); + OreDictionary.registerOre(LibOreDict.ELEMENTIUM, new ItemStack(manaResource, 1, 7)); + OreDictionary.registerOre(LibOreDict.PIXIE_DUST, new ItemStack(manaResource, 1, 8)); + OreDictionary.registerOre(LibOreDict.DRAGONSTONE, new ItemStack(manaResource, 1, 9)); + OreDictionary.registerOre(LibOreDict.PRISMARINE_SHARD, new ItemStack(manaResource, 1, 10)); + OreDictionary.registerOre(LibOreDict.PLACEHOLDER, new ItemStack(manaResource, 1, 11)); + OreDictionary.registerOre(LibOreDict.RED_STRING, new ItemStack(manaResource, 1, 12)); + OreDictionary.registerOre(LibOreDict.DREAMWOOD_TWIG, new ItemStack(manaResource, 1, 13)); + OreDictionary.registerOre(LibOreDict.GAIA_INGOT, new ItemStack(manaResource, 1, 14)); + OreDictionary.registerOre(LibOreDict.ENDER_AIR_BOTTLE, new ItemStack(manaResource, 1, 15)); + OreDictionary.registerOre(LibOreDict.MANA_STRING, new ItemStack(manaResource, 1, 16)); + OreDictionary.registerOre(LibOreDict.MANASTEEL_NUGGET, new ItemStack(manaResource, 1, 17)); + OreDictionary.registerOre(LibOreDict.TERRASTEEL_NUGGET, new ItemStack(manaResource, 1, 18)); + OreDictionary.registerOre(LibOreDict.ELEMENTIUM_NUGGET, new ItemStack(manaResource, 1, 19)); + OreDictionary.registerOre(LibOreDict.ROOT, new ItemStack(manaResource, 1, 20)); + OreDictionary.registerOre(LibOreDict.PEBBLE, new ItemStack(manaResource, 1, 21)); + OreDictionary.registerOre(LibOreDict.MANAWEAVE_CLOTH, new ItemStack(manaResource, 1, 22)); + OreDictionary.registerOre(LibOreDict.MANA_POWDER, new ItemStack(manaResource, 1, 23)); - OreDictionary.registerOre(LibOreDict.VIAL, new ItemStack(vial, 1, 0)); - OreDictionary.registerOre(LibOreDict.FLASK, new ItemStack(vial, 1, 1)); + OreDictionary.registerOre(LibOreDict.VIAL, new ItemStack(vial, 1, 0)); + OreDictionary.registerOre(LibOreDict.FLASK, new ItemStack(vial, 1, 1)); - BotaniaAPI.blackListItemFromLoonium(lexicon); - BotaniaAPI.blackListItemFromLoonium(overgrowthSeed); - BotaniaAPI.blackListItemFromLoonium(blackLotus); - int min = Item.getIdFromItem(Items.record_13); - int max = Item.getIdFromItem(Items.record_wait); - for(int i = min; i <= max; i++) - BotaniaAPI.blackListItemFromLoonium(Item.getItemById(i)); + BotaniaAPI.blackListItemFromLoonium(lexicon); + BotaniaAPI.blackListItemFromLoonium(overgrowthSeed); + BotaniaAPI.blackListItemFromLoonium(blackLotus); + int min = Item.getIdFromItem(Items.record_13); + int max = Item.getIdFromItem(Items.record_wait); + for (int i = min; i <= max; i++) BotaniaAPI.blackListItemFromLoonium(Item.getItemById(i)); - OreDictionary.registerOre("rodBlaze", Items.blaze_rod); - OreDictionary.registerOre("powderBlaze", Items.blaze_powder); - } + OreDictionary.registerOre("rodBlaze", Items.blaze_rod); + OreDictionary.registerOre("powderBlaze", Items.blaze_powder); + } } diff --git a/src/main/java/vazkii/botania/common/item/block/IRarityBlock.java b/src/main/java/vazkii/botania/common/item/block/IRarityBlock.java index d404d084d3..1ce1dc3fee 100644 --- a/src/main/java/vazkii/botania/common/item/block/IRarityBlock.java +++ b/src/main/java/vazkii/botania/common/item/block/IRarityBlock.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Mar 31, 2015, 9:00:38 PM (GMT)] */ package vazkii.botania.common.item.block; @@ -15,6 +15,5 @@ public interface IRarityBlock { - public EnumRarity getRarity(ItemStack stack); - + public EnumRarity getRarity(ItemStack stack); } diff --git a/src/main/java/vazkii/botania/common/item/block/ItemBlockDreamwood.java b/src/main/java/vazkii/botania/common/item/block/ItemBlockDreamwood.java index eec1ada5e0..6cdde35e1b 100644 --- a/src/main/java/vazkii/botania/common/item/block/ItemBlockDreamwood.java +++ b/src/main/java/vazkii/botania/common/item/block/ItemBlockDreamwood.java @@ -6,13 +6,12 @@ public class ItemBlockDreamwood extends ItemBlockWithMetadataAndName implements IElvenItem { - public ItemBlockDreamwood(Block block) { - super(block); - } - - @Override - public boolean isElvenItem(ItemStack stack) { - return true; - } + public ItemBlockDreamwood(Block block) { + super(block); + } + @Override + public boolean isElvenItem(ItemStack stack) { + return true; + } } diff --git a/src/main/java/vazkii/botania/common/item/block/ItemBlockElven.java b/src/main/java/vazkii/botania/common/item/block/ItemBlockElven.java index 8fad997dda..ab8ac722d3 100644 --- a/src/main/java/vazkii/botania/common/item/block/ItemBlockElven.java +++ b/src/main/java/vazkii/botania/common/item/block/ItemBlockElven.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Sep 9, 2014, 5:02:06 PM (GMT)] */ package vazkii.botania.common.item.block; @@ -16,13 +16,12 @@ public class ItemBlockElven extends ItemBlockMod implements IElvenItem { - public ItemBlockElven(Block block) { - super(block); - } - - @Override - public boolean isElvenItem(ItemStack stack) { - return ((IElvenItem) field_150939_a).isElvenItem(stack); - } + public ItemBlockElven(Block block) { + super(block); + } + @Override + public boolean isElvenItem(ItemStack stack) { + return ((IElvenItem) field_150939_a).isElvenItem(stack); + } } diff --git a/src/main/java/vazkii/botania/common/item/block/ItemBlockFloatingSpecialFlower.java b/src/main/java/vazkii/botania/common/item/block/ItemBlockFloatingSpecialFlower.java index f6ef345a2b..8b2d9ccb78 100644 --- a/src/main/java/vazkii/botania/common/item/block/ItemBlockFloatingSpecialFlower.java +++ b/src/main/java/vazkii/botania/common/item/block/ItemBlockFloatingSpecialFlower.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Nov 17, 2014, 5:39:08 PM (GMT)] */ package vazkii.botania.common.item.block; @@ -16,14 +16,15 @@ public class ItemBlockFloatingSpecialFlower extends ItemBlockSpecialFlower { - public ItemBlockFloatingSpecialFlower(Block block1) { - super(block1); - } - - @Override - public String getItemStackDisplayName(ItemStack stack) { - String flowerName = getUnlocalizedName(stack) + ".name"; - return String.format(StatCollector.translateToLocal("botaniamisc.floatingPrefix"), StatCollector.translateToLocal(flowerName)); - } + public ItemBlockFloatingSpecialFlower(Block block1) { + super(block1); + } + @Override + public String getItemStackDisplayName(ItemStack stack) { + String flowerName = getUnlocalizedName(stack) + ".name"; + return String.format( + StatCollector.translateToLocal("botaniamisc.floatingPrefix"), + StatCollector.translateToLocal(flowerName)); + } } diff --git a/src/main/java/vazkii/botania/common/item/block/ItemBlockMod.java b/src/main/java/vazkii/botania/common/item/block/ItemBlockMod.java index a3491afb0a..6a790a6bc6 100644 --- a/src/main/java/vazkii/botania/common/item/block/ItemBlockMod.java +++ b/src/main/java/vazkii/botania/common/item/block/ItemBlockMod.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [May 16, 2014, 7:00:36 PM (GMT)] */ package vazkii.botania.common.item.block; @@ -23,27 +23,30 @@ public class ItemBlockMod extends ItemBlock implements IPickupAchievement, ICraftAchievement { - public ItemBlockMod(Block block) { - super(block); - } - - @Override - public String getUnlocalizedNameInefficiently(ItemStack par1ItemStack) { - return getUnlocalizedNameInefficiently_(par1ItemStack).replaceAll("tile.", "tile." + LibResources.PREFIX_MOD); - } - - public String getUnlocalizedNameInefficiently_(ItemStack stack) { - return super.getUnlocalizedNameInefficiently(stack); - } - - @Override - public Achievement getAchievementOnCraft(ItemStack stack, EntityPlayer player, IInventory matrix) { - return field_150939_a instanceof ICraftAchievement ? ((ICraftAchievement) field_150939_a).getAchievementOnCraft(stack, player, matrix) : null; - } - - @Override - public Achievement getAchievementOnPickup(ItemStack stack, EntityPlayer player, EntityItem item) { - return field_150939_a instanceof IPickupAchievement ? ((IPickupAchievement) field_150939_a).getAchievementOnPickup(stack, player, item) : null; - } - + public ItemBlockMod(Block block) { + super(block); + } + + @Override + public String getUnlocalizedNameInefficiently(ItemStack par1ItemStack) { + return getUnlocalizedNameInefficiently_(par1ItemStack).replaceAll("tile.", "tile." + LibResources.PREFIX_MOD); + } + + public String getUnlocalizedNameInefficiently_(ItemStack stack) { + return super.getUnlocalizedNameInefficiently(stack); + } + + @Override + public Achievement getAchievementOnCraft(ItemStack stack, EntityPlayer player, IInventory matrix) { + return field_150939_a instanceof ICraftAchievement + ? ((ICraftAchievement) field_150939_a).getAchievementOnCraft(stack, player, matrix) + : null; + } + + @Override + public Achievement getAchievementOnPickup(ItemStack stack, EntityPlayer player, EntityItem item) { + return field_150939_a instanceof IPickupAchievement + ? ((IPickupAchievement) field_150939_a).getAchievementOnPickup(stack, player, item) + : null; + } } diff --git a/src/main/java/vazkii/botania/common/item/block/ItemBlockModSlab.java b/src/main/java/vazkii/botania/common/item/block/ItemBlockModSlab.java index 0883b4a592..a483eb1247 100644 --- a/src/main/java/vazkii/botania/common/item/block/ItemBlockModSlab.java +++ b/src/main/java/vazkii/botania/common/item/block/ItemBlockModSlab.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jun 11, 2014, 1:16:59 AM (GMT)] */ package vazkii.botania.common.item.block; @@ -17,13 +17,12 @@ public class ItemBlockModSlab extends ItemSlab { - public ItemBlockModSlab(Block par1) { - super(par1, ((BlockModSlab)par1).getSingleBlock(), ((BlockModSlab)par1).getFullBlock(), false); - } - - @Override - public String getUnlocalizedName(ItemStack par1ItemStack) { - return field_150939_a.getUnlocalizedName().replaceAll("tile.", "tile.botania:"); - } + public ItemBlockModSlab(Block par1) { + super(par1, ((BlockModSlab) par1).getSingleBlock(), ((BlockModSlab) par1).getFullBlock(), false); + } + @Override + public String getUnlocalizedName(ItemStack par1ItemStack) { + return field_150939_a.getUnlocalizedName().replaceAll("tile.", "tile.botania:"); + } } diff --git a/src/main/java/vazkii/botania/common/item/block/ItemBlockPool.java b/src/main/java/vazkii/botania/common/item/block/ItemBlockPool.java index 7c399f9625..7a19970b2e 100644 --- a/src/main/java/vazkii/botania/common/item/block/ItemBlockPool.java +++ b/src/main/java/vazkii/botania/common/item/block/ItemBlockPool.java @@ -2,16 +2,15 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Apr 27, 2014, 8:32:52 PM (GMT)] */ package vazkii.botania.common.item.block; import java.util.List; - import net.minecraft.block.Block; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; @@ -19,15 +18,13 @@ public class ItemBlockPool extends ItemBlockWithMetadataAndName { - public ItemBlockPool(Block par2Block) { - super(par2Block); - } - - @Override - public void addInformation(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, List par3List, boolean par4) { - if(par1ItemStack.getItemDamage() == 1) - for(int i = 0; i < 2; i++) - par3List.add(StatCollector.translateToLocal("botaniamisc.creativePool" + i)); - } + public ItemBlockPool(Block par2Block) { + super(par2Block); + } + @Override + public void addInformation(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, List par3List, boolean par4) { + if (par1ItemStack.getItemDamage() == 1) + for (int i = 0; i < 2; i++) par3List.add(StatCollector.translateToLocal("botaniamisc.creativePool" + i)); + } } diff --git a/src/main/java/vazkii/botania/common/item/block/ItemBlockSpecialFlower.java b/src/main/java/vazkii/botania/common/item/block/ItemBlockSpecialFlower.java index 7c3074bfc5..79d557c17e 100644 --- a/src/main/java/vazkii/botania/common/item/block/ItemBlockSpecialFlower.java +++ b/src/main/java/vazkii/botania/common/item/block/ItemBlockSpecialFlower.java @@ -2,16 +2,15 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jan 25, 2014, 2:04:15 PM (GMT)] */ package vazkii.botania.common.item.block; import java.util.List; - import net.minecraft.block.Block; import net.minecraft.entity.item.EntityItem; import net.minecraft.entity.player.EntityPlayer; @@ -36,107 +35,105 @@ public class ItemBlockSpecialFlower extends ItemBlockMod implements IRecipeKeyProvider { - public ItemBlockSpecialFlower(Block block1) { - super(block1); - } - - @Override - public IIcon getIconIndex(ItemStack stack) { - return BotaniaAPI.getSignatureForName(getType(stack)).getIconForStack(stack); - } - - @Override - public IIcon getIcon(ItemStack stack, int pass) { - return getIconIndex(stack); - } - - @Override - public boolean placeBlockAt(ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int side, float hitX, float hitY, float hitZ, int metadata) { - boolean placed = super.placeBlockAt(stack, player, world, x, y, z, side, hitX, hitY, hitZ, metadata); - if(placed) { - String type = getType(stack); - TileEntity te = world.getTileEntity(x, y, z); - if(te instanceof TileSpecialFlower) { - TileSpecialFlower tile = (TileSpecialFlower) te; - tile.setSubTile(type); - tile.onBlockAdded(world, x, y, z); - tile.onBlockPlacedBy(world, x, y, z, player, stack); - if(!world.isRemote) - world.markBlockForUpdate(x, y, z); - } - } - - return placed; - } - - @Override - public String getUnlocalizedName(ItemStack stack) { - return BotaniaAPI.getSignatureForName(getType(stack)).getUnlocalizedNameForStack(stack); - } - - @Override - public String getUnlocalizedNameInefficiently(ItemStack par1ItemStack) { - return getUnlocalizedNameInefficiently_(par1ItemStack); - } - - @Override - public void addInformation(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, List par3List, boolean par4) { - String type = getType(par1ItemStack); - SubTileSignature sig = BotaniaAPI.getSignatureForName(type); - - sig.addTooltip(par1ItemStack, par2EntityPlayer, par3List); - - if(ConfigHandler.referencesEnabled) { - String refUnlocalized = sig.getUnlocalizedLoreTextForStack(par1ItemStack); - String refLocalized = StatCollector.translateToLocal(refUnlocalized); - if(!refLocalized.equals(refUnlocalized)) - par3List.add(EnumChatFormatting.ITALIC + refLocalized); - } - - String mod = BotaniaAPI.subTileMods.get(type); - if(!mod.equals(LibMisc.MOD_ID)) - par3List.add(EnumChatFormatting.ITALIC + "[" + mod + "]"); - } - - public static String getType(ItemStack stack) { - return ItemNBTHelper.detectNBT(stack) ? ItemNBTHelper.getString(stack, SubTileEntity.TAG_TYPE, "") : ""; - } - - public static ItemStack ofType(String type) { - return ofType(new ItemStack(ModBlocks.specialFlower), type); - } - - public static ItemStack ofType(ItemStack stack, String type) { - ItemNBTHelper.setString(stack, SubTileEntity.TAG_TYPE, type); - return stack; - } - - @Override - public String getKey(ItemStack stack) { - return "flower." + getType(stack); - } - - @Override - public Achievement getAchievementOnPickup(ItemStack stack, EntityPlayer player, EntityItem item) { - String type = getType(stack); - if(type.equals(LibBlockNames.SUBTILE_DAYBLOOM)) - return ModAchievements.daybloomPickup; - else if(type.equals(LibBlockNames.SUBTILE_ENDOFLAME)) - return ModAchievements.endoflamePickup; - else if(type.equals(LibBlockNames.SUBTILE_KEKIMURUS)) - return ModAchievements.kekimurusPickup; - else if(type.equals(LibBlockNames.SUBTILE_HEISEI_DREAM)) - return ModAchievements.heiseiDreamPickup; - else if(type.equals(LibBlockNames.SUBTILE_POLLIDISIAC)) - return ModAchievements.pollidisiacPickup; - else if(type.equals(LibBlockNames.SUBTILE_BUBBELL)) - return ModAchievements.bubbellPickup; - else if(type.equals(LibBlockNames.SUBTILE_DANDELIFEON)) - return ModAchievements.dandelifeonPickup; - else if(type.equals("")) - return ModAchievements.nullFlower; - return null; - } - + public ItemBlockSpecialFlower(Block block1) { + super(block1); + } + + @Override + public IIcon getIconIndex(ItemStack stack) { + return BotaniaAPI.getSignatureForName(getType(stack)).getIconForStack(stack); + } + + @Override + public IIcon getIcon(ItemStack stack, int pass) { + return getIconIndex(stack); + } + + @Override + public boolean placeBlockAt( + ItemStack stack, + EntityPlayer player, + World world, + int x, + int y, + int z, + int side, + float hitX, + float hitY, + float hitZ, + int metadata) { + boolean placed = super.placeBlockAt(stack, player, world, x, y, z, side, hitX, hitY, hitZ, metadata); + if (placed) { + String type = getType(stack); + TileEntity te = world.getTileEntity(x, y, z); + if (te instanceof TileSpecialFlower) { + TileSpecialFlower tile = (TileSpecialFlower) te; + tile.setSubTile(type); + tile.onBlockAdded(world, x, y, z); + tile.onBlockPlacedBy(world, x, y, z, player, stack); + if (!world.isRemote) world.markBlockForUpdate(x, y, z); + } + } + + return placed; + } + + @Override + public String getUnlocalizedName(ItemStack stack) { + return BotaniaAPI.getSignatureForName(getType(stack)).getUnlocalizedNameForStack(stack); + } + + @Override + public String getUnlocalizedNameInefficiently(ItemStack par1ItemStack) { + return getUnlocalizedNameInefficiently_(par1ItemStack); + } + + @Override + public void addInformation(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, List par3List, boolean par4) { + String type = getType(par1ItemStack); + SubTileSignature sig = BotaniaAPI.getSignatureForName(type); + + sig.addTooltip(par1ItemStack, par2EntityPlayer, par3List); + + if (ConfigHandler.referencesEnabled) { + String refUnlocalized = sig.getUnlocalizedLoreTextForStack(par1ItemStack); + String refLocalized = StatCollector.translateToLocal(refUnlocalized); + if (!refLocalized.equals(refUnlocalized)) par3List.add(EnumChatFormatting.ITALIC + refLocalized); + } + + String mod = BotaniaAPI.subTileMods.get(type); + if (!mod.equals(LibMisc.MOD_ID)) par3List.add(EnumChatFormatting.ITALIC + "[" + mod + "]"); + } + + public static String getType(ItemStack stack) { + return ItemNBTHelper.detectNBT(stack) ? ItemNBTHelper.getString(stack, SubTileEntity.TAG_TYPE, "") : ""; + } + + public static ItemStack ofType(String type) { + return ofType(new ItemStack(ModBlocks.specialFlower), type); + } + + public static ItemStack ofType(ItemStack stack, String type) { + ItemNBTHelper.setString(stack, SubTileEntity.TAG_TYPE, type); + return stack; + } + + @Override + public String getKey(ItemStack stack) { + return "flower." + getType(stack); + } + + @Override + public Achievement getAchievementOnPickup(ItemStack stack, EntityPlayer player, EntityItem item) { + String type = getType(stack); + if (type.equals(LibBlockNames.SUBTILE_DAYBLOOM)) return ModAchievements.daybloomPickup; + else if (type.equals(LibBlockNames.SUBTILE_ENDOFLAME)) return ModAchievements.endoflamePickup; + else if (type.equals(LibBlockNames.SUBTILE_KEKIMURUS)) return ModAchievements.kekimurusPickup; + else if (type.equals(LibBlockNames.SUBTILE_HEISEI_DREAM)) return ModAchievements.heiseiDreamPickup; + else if (type.equals(LibBlockNames.SUBTILE_POLLIDISIAC)) return ModAchievements.pollidisiacPickup; + else if (type.equals(LibBlockNames.SUBTILE_BUBBELL)) return ModAchievements.bubbellPickup; + else if (type.equals(LibBlockNames.SUBTILE_DANDELIFEON)) return ModAchievements.dandelifeonPickup; + else if (type.equals("")) return ModAchievements.nullFlower; + return null; + } } - diff --git a/src/main/java/vazkii/botania/common/item/block/ItemBlockSpecialQuartz.java b/src/main/java/vazkii/botania/common/item/block/ItemBlockSpecialQuartz.java index 7f104d0cf8..1832ef626c 100644 --- a/src/main/java/vazkii/botania/common/item/block/ItemBlockSpecialQuartz.java +++ b/src/main/java/vazkii/botania/common/item/block/ItemBlockSpecialQuartz.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jun 11, 2014, 1:13:36 AM (GMT)] */ package vazkii.botania.common.item.block; @@ -17,12 +17,14 @@ public class ItemBlockSpecialQuartz extends ItemMultiTexture { - public ItemBlockSpecialQuartz(Block par1) { - super(par1, par1, new String[]{ "" }); - } + public ItemBlockSpecialQuartz(Block par1) { + super(par1, par1, new String[] {""}); + } - @Override - public String getUnlocalizedName(ItemStack par1ItemStack) { - return par1ItemStack.getItemDamage() >= 3 ? "" : ((BlockSpecialQuartz) field_150939_a).getNames()[par1ItemStack.getItemDamage()]; - } -} \ No newline at end of file + @Override + public String getUnlocalizedName(ItemStack par1ItemStack) { + return par1ItemStack.getItemDamage() >= 3 + ? "" + : ((BlockSpecialQuartz) field_150939_a).getNames()[par1ItemStack.getItemDamage()]; + } +} diff --git a/src/main/java/vazkii/botania/common/item/block/ItemBlockStorage.java b/src/main/java/vazkii/botania/common/item/block/ItemBlockStorage.java index 1b196bd36e..2d5ecaa339 100644 --- a/src/main/java/vazkii/botania/common/item/block/ItemBlockStorage.java +++ b/src/main/java/vazkii/botania/common/item/block/ItemBlockStorage.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jun 22, 2014, 1:04:55 AM (GMT)] */ package vazkii.botania.common.item.block; @@ -16,12 +16,12 @@ public class ItemBlockStorage extends ItemBlockWithMetadataAndName implements IElvenItem { - public ItemBlockStorage(Block block) { - super(block); - } + public ItemBlockStorage(Block block) { + super(block); + } - @Override - public boolean isElvenItem(ItemStack stack) { - return stack.getItemDamage() == 2; - } + @Override + public boolean isElvenItem(ItemStack stack) { + return stack.getItemDamage() == 2; + } } diff --git a/src/main/java/vazkii/botania/common/item/block/ItemBlockTinyPotato.java b/src/main/java/vazkii/botania/common/item/block/ItemBlockTinyPotato.java index 0484dc766c..3cab84459e 100644 --- a/src/main/java/vazkii/botania/common/item/block/ItemBlockTinyPotato.java +++ b/src/main/java/vazkii/botania/common/item/block/ItemBlockTinyPotato.java @@ -2,17 +2,16 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jan 27, 2015, 3:44:10 PM (GMT)] */ package vazkii.botania.common.item.block; import java.util.Arrays; import java.util.List; - import net.minecraft.block.Block; import net.minecraft.entity.Entity; import net.minecraft.entity.player.EntityPlayer; @@ -24,46 +23,49 @@ public class ItemBlockTinyPotato extends ItemBlockMod { - private static final List TYPOS = Arrays.asList(new String[] { - "vaskii", "vazki", "voskii", "vazkkii", "vazkki", "vazzki", "vaskki", "vozkii", "vazkil", "vaskil", "vazkill", "vaskill", "vaski" - }); - - private static final String NOT_MY_NAME[] = { - "Six letter word just to get me along", - "It's a intricacy and I'm coding on my mod and I,", - "I keep fixin', and keepin' it together", - "People around gotta find something to play now", - "Holding back, every mod's the same", - "Don't wanna be a loser", - "Listen to me, oh no, I don't break anything at all", - "But with nothing to consider they forget my name", - "'ame, 'ame, 'ame", - "They call me Vaskii", - "They call me Vazki", - "They call me Voskii", - "They call me Vazkki", - "That's not my name", - "That's not my name", - "That's not my name", - "That's not my name" - }; + private static final List TYPOS = Arrays.asList(new String[] { + "vaskii", "vazki", "voskii", "vazkkii", "vazkki", "vazzki", "vaskki", "vozkii", "vazkil", "vaskil", "vazkill", + "vaskill", "vaski" + }); - private static final String TAG_TICKS = "notMyNameTicks"; + private static final String NOT_MY_NAME[] = { + "Six letter word just to get me along", + "It's a intricacy and I'm coding on my mod and I,", + "I keep fixin', and keepin' it together", + "People around gotta find something to play now", + "Holding back, every mod's the same", + "Don't wanna be a loser", + "Listen to me, oh no, I don't break anything at all", + "But with nothing to consider they forget my name", + "'ame, 'ame, 'ame", + "They call me Vaskii", + "They call me Vazki", + "They call me Voskii", + "They call me Vazkki", + "That's not my name", + "That's not my name", + "That's not my name", + "That's not my name" + }; - public ItemBlockTinyPotato(Block block) { - super(block); - } + private static final String TAG_TICKS = "notMyNameTicks"; - @Override - public void onUpdate(ItemStack stack, World world, Entity e, int t, boolean idunno) { - if(!world.isRemote && e instanceof EntityPlayer && e.ticksExisted % 30 == 0 && TYPOS.contains(stack.getDisplayName().toLowerCase())) { - EntityPlayer player = (EntityPlayer) e; - int ticks = ItemNBTHelper.getInt(stack, TAG_TICKS, 0); - if(ticks < NOT_MY_NAME.length) { - player.addChatMessage(new ChatComponentText(EnumChatFormatting.RED + NOT_MY_NAME[ticks])); - ItemNBTHelper.setInt(stack, TAG_TICKS, ticks + 1); - } - } - } + public ItemBlockTinyPotato(Block block) { + super(block); + } + @Override + public void onUpdate(ItemStack stack, World world, Entity e, int t, boolean idunno) { + if (!world.isRemote + && e instanceof EntityPlayer + && e.ticksExisted % 30 == 0 + && TYPOS.contains(stack.getDisplayName().toLowerCase())) { + EntityPlayer player = (EntityPlayer) e; + int ticks = ItemNBTHelper.getInt(stack, TAG_TICKS, 0); + if (ticks < NOT_MY_NAME.length) { + player.addChatMessage(new ChatComponentText(EnumChatFormatting.RED + NOT_MY_NAME[ticks])); + ItemNBTHelper.setInt(stack, TAG_TICKS, ticks + 1); + } + } + } } diff --git a/src/main/java/vazkii/botania/common/item/block/ItemBlockWithMetadataAndName.java b/src/main/java/vazkii/botania/common/item/block/ItemBlockWithMetadataAndName.java index e9bad65fdf..85980cf7a9 100644 --- a/src/main/java/vazkii/botania/common/item/block/ItemBlockWithMetadataAndName.java +++ b/src/main/java/vazkii/botania/common/item/block/ItemBlockWithMetadataAndName.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jan 16, 2014, 5:54:06 PM (GMT)] */ package vazkii.botania.common.item.block; @@ -21,30 +21,35 @@ import vazkii.botania.common.achievement.ICraftAchievement; import vazkii.botania.common.achievement.IPickupAchievement; -public class ItemBlockWithMetadataAndName extends ItemBlockWithMetadata implements IPickupAchievement, ICraftAchievement { - - public ItemBlockWithMetadataAndName(Block par2Block) { - super(par2Block, par2Block); - } - - @Override - public String getUnlocalizedNameInefficiently(ItemStack par1ItemStack) { - return super.getUnlocalizedNameInefficiently(par1ItemStack).replaceAll("tile.", "tile." + LibResources.PREFIX_MOD); - } - - @Override - public String getUnlocalizedName(ItemStack par1ItemStack) { - return super.getUnlocalizedName(par1ItemStack) + par1ItemStack.getItemDamage(); - } - - @Override - public Achievement getAchievementOnCraft(ItemStack stack, EntityPlayer player, IInventory matrix) { - return field_150939_a instanceof ICraftAchievement ? ((ICraftAchievement) field_150939_a).getAchievementOnCraft(stack, player, matrix) : null; - } - - @Override - public Achievement getAchievementOnPickup(ItemStack stack, EntityPlayer player, EntityItem item) { - return field_150939_a instanceof IPickupAchievement ? ((IPickupAchievement) field_150939_a).getAchievementOnPickup(stack, player, item) : null; - } - +public class ItemBlockWithMetadataAndName extends ItemBlockWithMetadata + implements IPickupAchievement, ICraftAchievement { + + public ItemBlockWithMetadataAndName(Block par2Block) { + super(par2Block, par2Block); + } + + @Override + public String getUnlocalizedNameInefficiently(ItemStack par1ItemStack) { + return super.getUnlocalizedNameInefficiently(par1ItemStack) + .replaceAll("tile.", "tile." + LibResources.PREFIX_MOD); + } + + @Override + public String getUnlocalizedName(ItemStack par1ItemStack) { + return super.getUnlocalizedName(par1ItemStack) + par1ItemStack.getItemDamage(); + } + + @Override + public Achievement getAchievementOnCraft(ItemStack stack, EntityPlayer player, IInventory matrix) { + return field_150939_a instanceof ICraftAchievement + ? ((ICraftAchievement) field_150939_a).getAchievementOnCraft(stack, player, matrix) + : null; + } + + @Override + public Achievement getAchievementOnPickup(ItemStack stack, EntityPlayer player, EntityItem item) { + return field_150939_a instanceof IPickupAchievement + ? ((IPickupAchievement) field_150939_a).getAchievementOnPickup(stack, player, item) + : null; + } } diff --git a/src/main/java/vazkii/botania/common/item/brew/ItemBrewBase.java b/src/main/java/vazkii/botania/common/item/brew/ItemBrewBase.java index 8c565500e2..edd2fa4cb8 100644 --- a/src/main/java/vazkii/botania/common/item/brew/ItemBrewBase.java +++ b/src/main/java/vazkii/botania/common/item/brew/ItemBrewBase.java @@ -2,17 +2,16 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Nov 1, 2014, 5:45:58 PM (GMT)] */ package vazkii.botania.common.item.brew; import java.awt.Color; import java.util.List; - import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.entity.item.EntityItem; @@ -39,159 +38,162 @@ public abstract class ItemBrewBase extends ItemMod implements IBrewItem, IPickupAchievement { - private static final String TAG_BREW_KEY = "brewKey"; - private static final String TAG_SWIGS_LEFT = "swigsLeft"; - - String name; - String texName; - int swigs; - int drinkSpeed; - ItemStack baseItem; - - IIcon[] icons; - - public ItemBrewBase(String name, String texName, int swigs, int drinkSpeed, ItemStack baseItem) { - this.name = name; - this.texName = texName; - this.swigs = swigs; - this.drinkSpeed = drinkSpeed; - this.baseItem = baseItem; - setMaxStackSize(1); - setMaxDamage(swigs); - setUnlocalizedName(name); - setNoRepair(); - } - - @Override - public int getMaxItemUseDuration(ItemStack p_77626_1_) { - return drinkSpeed; - } - - @Override - public EnumAction getItemUseAction(ItemStack p_77661_1_) { - return EnumAction.drink; - } - - @Override - public ItemStack onItemRightClick(ItemStack p_77659_1_, World p_77659_2_, EntityPlayer p_77659_3_) { - p_77659_3_.setItemInUse(p_77659_1_, getMaxItemUseDuration(p_77659_1_)); - return p_77659_1_; - } - - @Override - public ItemStack onEaten(ItemStack stack, World world, EntityPlayer player) { - if(!world.isRemote) { - for(PotionEffect effect : getBrew(stack).getPotionEffects(stack)) { - PotionEffect newEffect = new PotionEffect(effect.getPotionID(), effect.getDuration(), effect.getAmplifier(), true); - Potion potion = Potion.potionTypes[newEffect.getPotionID()]; - if(potion.isInstant()) - potion.affectEntity(player, player, newEffect.getAmplifier(), 1F); - else player.addPotionEffect(newEffect); - } - - if(world.rand.nextBoolean()) - world.playSoundAtEntity(player, "random.burp", 1F, 1F); - - int swigs = getSwigsLeft(stack); - if(!player.capabilities.isCreativeMode) { - if(swigs == 1) { - ItemStack copy = baseItem.copy(); - if(!player.inventory.addItemStackToInventory(copy)) - return baseItem.copy(); - return null; - } - - - setSwigsLeft(stack, swigs - 1); - } - } - - return stack; - } - - @Override - public void getSubItems(Item item, CreativeTabs tab, List list) { - for(String s : BotaniaAPI.brewMap.keySet()) { - ItemStack stack = new ItemStack(item); - setBrew(stack, s); - list.add(stack); - } - } - - @Override - public void registerIcons(IIconRegister par1IconRegister) { - itemIcon = IconHelper.forName(par1IconRegister, texName + "0"); - - icons = new IIcon[swigs]; - for(int i = 0; i < swigs; i++) - icons[i] = IconHelper.forName(par1IconRegister, texName + "1_" + i); - } - - @Override - public boolean requiresMultipleRenderPasses() { - return true; - } - - @Override - public IIcon getIcon(ItemStack stack, int pass) { - return pass == 0 ? itemIcon : icons[Math.max(0, Math.min(icons.length - 1, swigs - getSwigsLeft(stack)))]; - } - - @Override - public int getColorFromItemStack(ItemStack stack, int pass) { - if(pass == 0) - return 0xFFFFFF; - - Color color = new Color(getBrew(stack).getColor(stack)); - int add = (int) (Math.sin(ClientTickHandler.ticksInGame * 0.1) * 16); - - int r = Math.max(0, Math.min(255, color.getRed() + add)); - int g = Math.max(0, Math.min(255, color.getGreen() + add)); - int b = Math.max(0, Math.min(255, color.getBlue() + add)); - - return r << 16 | g << 8 | b; - } - - @Override - public String getItemStackDisplayName(ItemStack stack) { - return String.format(StatCollector.translateToLocal(getUnlocalizedNameInefficiently(stack) + ".name"), StatCollector.translateToLocal(getBrew(stack).getUnlocalizedName(stack)), EnumChatFormatting.BOLD + "" + getSwigsLeft(stack) + EnumChatFormatting.RESET); - } - - @Override - public void addInformation(ItemStack stack, EntityPlayer player, List list, boolean adv) { - Brew brew = getBrew(stack); - for(PotionEffect effect : brew.getPotionEffects(stack)) { - Potion potion = Potion.potionTypes[effect.getPotionID()]; - EnumChatFormatting format = potion.isBadEffect() ? EnumChatFormatting.RED : EnumChatFormatting.GRAY; - list.add(format + StatCollector.translateToLocal(effect.getEffectName()) + (effect.getAmplifier() == 0 ? "" : " " + StatCollector.translateToLocal("botania.roman" + (effect.getAmplifier() + 1))) + EnumChatFormatting.GRAY + (potion.isInstant() ? "" : " (" + Potion.getDurationString(effect) + ")")); - } - } - - @Override - public Brew getBrew(ItemStack stack) { - String key = ItemNBTHelper.getString(stack, TAG_BREW_KEY, ""); - return BotaniaAPI.getBrewFromKey(key); - } - - public static void setBrew(ItemStack stack, Brew brew) { - setBrew(stack, (brew == null ? BotaniaAPI.fallbackBrew : brew).getKey()); - } - - public static void setBrew(ItemStack stack, String brew) { - ItemNBTHelper.setString(stack, TAG_BREW_KEY, brew); - } - - public int getSwigsLeft(ItemStack stack) { - return ItemNBTHelper.getInt(stack, TAG_SWIGS_LEFT, swigs); - } - - public void setSwigsLeft(ItemStack stack, int swigs) { - ItemNBTHelper.setInt(stack, TAG_SWIGS_LEFT, swigs); - } - - @Override - public Achievement getAchievementOnPickup(ItemStack stack, EntityPlayer player, EntityItem item) { - return ModAchievements.brewPickup; - } - + private static final String TAG_BREW_KEY = "brewKey"; + private static final String TAG_SWIGS_LEFT = "swigsLeft"; + + String name; + String texName; + int swigs; + int drinkSpeed; + ItemStack baseItem; + + IIcon[] icons; + + public ItemBrewBase(String name, String texName, int swigs, int drinkSpeed, ItemStack baseItem) { + this.name = name; + this.texName = texName; + this.swigs = swigs; + this.drinkSpeed = drinkSpeed; + this.baseItem = baseItem; + setMaxStackSize(1); + setMaxDamage(swigs); + setUnlocalizedName(name); + setNoRepair(); + } + + @Override + public int getMaxItemUseDuration(ItemStack p_77626_1_) { + return drinkSpeed; + } + + @Override + public EnumAction getItemUseAction(ItemStack p_77661_1_) { + return EnumAction.drink; + } + + @Override + public ItemStack onItemRightClick(ItemStack p_77659_1_, World p_77659_2_, EntityPlayer p_77659_3_) { + p_77659_3_.setItemInUse(p_77659_1_, getMaxItemUseDuration(p_77659_1_)); + return p_77659_1_; + } + + @Override + public ItemStack onEaten(ItemStack stack, World world, EntityPlayer player) { + if (!world.isRemote) { + for (PotionEffect effect : getBrew(stack).getPotionEffects(stack)) { + PotionEffect newEffect = + new PotionEffect(effect.getPotionID(), effect.getDuration(), effect.getAmplifier(), true); + Potion potion = Potion.potionTypes[newEffect.getPotionID()]; + if (potion.isInstant()) potion.affectEntity(player, player, newEffect.getAmplifier(), 1F); + else player.addPotionEffect(newEffect); + } + + if (world.rand.nextBoolean()) world.playSoundAtEntity(player, "random.burp", 1F, 1F); + + int swigs = getSwigsLeft(stack); + if (!player.capabilities.isCreativeMode) { + if (swigs == 1) { + ItemStack copy = baseItem.copy(); + if (!player.inventory.addItemStackToInventory(copy)) return baseItem.copy(); + return null; + } + + setSwigsLeft(stack, swigs - 1); + } + } + + return stack; + } + + @Override + public void getSubItems(Item item, CreativeTabs tab, List list) { + for (String s : BotaniaAPI.brewMap.keySet()) { + ItemStack stack = new ItemStack(item); + setBrew(stack, s); + list.add(stack); + } + } + + @Override + public void registerIcons(IIconRegister par1IconRegister) { + itemIcon = IconHelper.forName(par1IconRegister, texName + "0"); + + icons = new IIcon[swigs]; + for (int i = 0; i < swigs; i++) icons[i] = IconHelper.forName(par1IconRegister, texName + "1_" + i); + } + + @Override + public boolean requiresMultipleRenderPasses() { + return true; + } + + @Override + public IIcon getIcon(ItemStack stack, int pass) { + return pass == 0 ? itemIcon : icons[Math.max(0, Math.min(icons.length - 1, swigs - getSwigsLeft(stack)))]; + } + + @Override + public int getColorFromItemStack(ItemStack stack, int pass) { + if (pass == 0) return 0xFFFFFF; + + Color color = new Color(getBrew(stack).getColor(stack)); + int add = (int) (Math.sin(ClientTickHandler.ticksInGame * 0.1) * 16); + + int r = Math.max(0, Math.min(255, color.getRed() + add)); + int g = Math.max(0, Math.min(255, color.getGreen() + add)); + int b = Math.max(0, Math.min(255, color.getBlue() + add)); + + return r << 16 | g << 8 | b; + } + + @Override + public String getItemStackDisplayName(ItemStack stack) { + return String.format( + StatCollector.translateToLocal(getUnlocalizedNameInefficiently(stack) + ".name"), + StatCollector.translateToLocal(getBrew(stack).getUnlocalizedName(stack)), + EnumChatFormatting.BOLD + "" + getSwigsLeft(stack) + EnumChatFormatting.RESET); + } + + @Override + public void addInformation(ItemStack stack, EntityPlayer player, List list, boolean adv) { + Brew brew = getBrew(stack); + for (PotionEffect effect : brew.getPotionEffects(stack)) { + Potion potion = Potion.potionTypes[effect.getPotionID()]; + EnumChatFormatting format = potion.isBadEffect() ? EnumChatFormatting.RED : EnumChatFormatting.GRAY; + list.add(format + + StatCollector.translateToLocal(effect.getEffectName()) + + (effect.getAmplifier() == 0 + ? "" + : " " + StatCollector.translateToLocal("botania.roman" + (effect.getAmplifier() + 1))) + + EnumChatFormatting.GRAY + + (potion.isInstant() ? "" : " (" + Potion.getDurationString(effect) + ")")); + } + } + + @Override + public Brew getBrew(ItemStack stack) { + String key = ItemNBTHelper.getString(stack, TAG_BREW_KEY, ""); + return BotaniaAPI.getBrewFromKey(key); + } + + public static void setBrew(ItemStack stack, Brew brew) { + setBrew(stack, (brew == null ? BotaniaAPI.fallbackBrew : brew).getKey()); + } + + public static void setBrew(ItemStack stack, String brew) { + ItemNBTHelper.setString(stack, TAG_BREW_KEY, brew); + } + + public int getSwigsLeft(ItemStack stack) { + return ItemNBTHelper.getInt(stack, TAG_SWIGS_LEFT, swigs); + } + + public void setSwigsLeft(ItemStack stack, int swigs) { + ItemNBTHelper.setInt(stack, TAG_SWIGS_LEFT, swigs); + } + + @Override + public Achievement getAchievementOnPickup(ItemStack stack, EntityPlayer player, EntityItem item) { + return ModAchievements.brewPickup; + } } diff --git a/src/main/java/vazkii/botania/common/item/brew/ItemBrewFlask.java b/src/main/java/vazkii/botania/common/item/brew/ItemBrewFlask.java index 5bded703a0..3062d07416 100644 --- a/src/main/java/vazkii/botania/common/item/brew/ItemBrewFlask.java +++ b/src/main/java/vazkii/botania/common/item/brew/ItemBrewFlask.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Nov 1, 2014, 7:34:30 PM (GMT)] */ package vazkii.botania.common.item.brew; @@ -16,8 +16,7 @@ public class ItemBrewFlask extends ItemBrewBase { - public ItemBrewFlask() { - super(LibItemNames.BREW_FLASK, LibItemNames.FLASK, 6, 24, new ItemStack(ModItems.vial, 1, 1)); - } - + public ItemBrewFlask() { + super(LibItemNames.BREW_FLASK, LibItemNames.FLASK, 6, 24, new ItemStack(ModItems.vial, 1, 1)); + } } diff --git a/src/main/java/vazkii/botania/common/item/brew/ItemBrewVial.java b/src/main/java/vazkii/botania/common/item/brew/ItemBrewVial.java index 6ebfeeec37..1eb8fbb31d 100644 --- a/src/main/java/vazkii/botania/common/item/brew/ItemBrewVial.java +++ b/src/main/java/vazkii/botania/common/item/brew/ItemBrewVial.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Nov 1, 2014, 7:33:24 PM (GMT)] */ package vazkii.botania.common.item.brew; @@ -16,8 +16,7 @@ public class ItemBrewVial extends ItemBrewBase { - public ItemBrewVial() { - super(LibItemNames.BREW_VIAL, LibItemNames.VIAL, 4, 32, new ItemStack(ModItems.vial)); - } - + public ItemBrewVial() { + super(LibItemNames.BREW_VIAL, LibItemNames.VIAL, 4, 32, new ItemStack(ModItems.vial)); + } } diff --git a/src/main/java/vazkii/botania/common/item/brew/ItemIncenseStick.java b/src/main/java/vazkii/botania/common/item/brew/ItemIncenseStick.java index 42c1eafd35..4fd2382f38 100644 --- a/src/main/java/vazkii/botania/common/item/brew/ItemIncenseStick.java +++ b/src/main/java/vazkii/botania/common/item/brew/ItemIncenseStick.java @@ -2,17 +2,16 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [May 15, 2015, 3:13:43 PM (GMT)] */ package vazkii.botania.common.item.brew; import java.awt.Color; import java.util.List; - import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.entity.player.EntityPlayer; @@ -35,109 +34,122 @@ public class ItemIncenseStick extends ItemMod implements IBrewItem, IBrewContainer { - private static final String TAG_BREW_KEY = "brewKey"; - public static final int TIME_MULTIPLIER = 60; - - IIcon[] icons; - - public ItemIncenseStick() { - setUnlocalizedName(LibItemNames.INCENSE_STICK); - setMaxStackSize(1); - } - - @Override - public void getSubItems(Item item, CreativeTabs tab, List list) { - super.getSubItems(item, tab, list); - for(String s : BotaniaAPI.brewMap.keySet()) { - ItemStack brewStack = getItemForBrew(BotaniaAPI.brewMap.get(s), new ItemStack(this)); - if(brewStack != null) - list.add(brewStack); - } - } - - @Override - public void registerIcons(IIconRegister par1IconRegister) { - icons = new IIcon[2]; - for(int i = 0; i < icons.length; i++) - icons[i] = IconHelper.forItem(par1IconRegister, this, i); - } - - @Override - public boolean requiresMultipleRenderPasses() { - return true; - } - - @Override - public IIcon getIcon(ItemStack stack, int pass) { - return icons[pass]; - } - - @Override - public int getColorFromItemStack(ItemStack stack, int pass) { - if(pass == 0) - return 0xFFFFFF; - - Brew brew = getBrew(stack); - if(brew == BotaniaAPI.fallbackBrew) - return 0x989898; - - Color color = new Color(brew.getColor(stack)); - int add = (int) (Math.sin(ClientTickHandler.ticksInGame * 0.2) * 24); - - int r = Math.max(0, Math.min(255, color.getRed() + add)); - int g = Math.max(0, Math.min(255, color.getGreen() + add)); - int b = Math.max(0, Math.min(255, color.getBlue() + add)); - - return r << 16 | g << 8 | b; - } - - @Override - public void addInformation(ItemStack stack, EntityPlayer player, List list, boolean adv) { - Brew brew = getBrew(stack); - if(brew == BotaniaAPI.fallbackBrew) { - addStringToTooltip(EnumChatFormatting.LIGHT_PURPLE + StatCollector.translateToLocal("botaniamisc.notInfused"), list); - return; - } - - addStringToTooltip(EnumChatFormatting.LIGHT_PURPLE + String.format(StatCollector.translateToLocal("botaniamisc.brewOf"), StatCollector.translateToLocal(brew.getUnlocalizedName(stack))), list); - for(PotionEffect effect : brew.getPotionEffects(stack)) { - Potion potion = Potion.potionTypes[effect.getPotionID()]; - EnumChatFormatting format = potion.isBadEffect() ? EnumChatFormatting.RED : EnumChatFormatting.GRAY; - PotionEffect longEffect = new PotionEffect(effect.getPotionID(), effect.getDuration() * TIME_MULTIPLIER, effect.getAmplifier(), false); - addStringToTooltip(" " + format + StatCollector.translateToLocal(effect.getEffectName()) + (effect.getAmplifier() == 0 ? "" : " " + StatCollector.translateToLocal("botania.roman" + (effect.getAmplifier() + 1))) + EnumChatFormatting.GRAY + (potion.isInstant() ? "" : " (" + Potion.getDurationString(longEffect) + ")"), list); - } - } - - void addStringToTooltip(String s, List tooltip) { - tooltip.add(s.replaceAll("&", "\u00a7")); - } - - @Override - public Brew getBrew(ItemStack stack) { - String key = ItemNBTHelper.getString(stack, TAG_BREW_KEY, ""); - return BotaniaAPI.getBrewFromKey(key); - } - - public static void setBrew(ItemStack stack, Brew brew) { - setBrew(stack, brew.getKey()); - } - - public static void setBrew(ItemStack stack, String brew) { - ItemNBTHelper.setString(stack, TAG_BREW_KEY, brew); - } - - @Override - public ItemStack getItemForBrew(Brew brew, ItemStack stack) { - if(!brew.canInfuseIncense() || brew.getPotionEffects(stack).size() != 1 || Potion.potionTypes[brew.getPotionEffects(stack).get(0).getPotionID()].isInstant()) - return null; - - ItemStack brewStack = new ItemStack(this); - setBrew(brewStack, brew); - return brewStack; - } - - @Override - public int getManaCost(Brew brew, ItemStack stack) { - return brew.getManaCost() * 10; - } + private static final String TAG_BREW_KEY = "brewKey"; + public static final int TIME_MULTIPLIER = 60; + + IIcon[] icons; + + public ItemIncenseStick() { + setUnlocalizedName(LibItemNames.INCENSE_STICK); + setMaxStackSize(1); + } + + @Override + public void getSubItems(Item item, CreativeTabs tab, List list) { + super.getSubItems(item, tab, list); + for (String s : BotaniaAPI.brewMap.keySet()) { + ItemStack brewStack = getItemForBrew(BotaniaAPI.brewMap.get(s), new ItemStack(this)); + if (brewStack != null) list.add(brewStack); + } + } + + @Override + public void registerIcons(IIconRegister par1IconRegister) { + icons = new IIcon[2]; + for (int i = 0; i < icons.length; i++) icons[i] = IconHelper.forItem(par1IconRegister, this, i); + } + + @Override + public boolean requiresMultipleRenderPasses() { + return true; + } + + @Override + public IIcon getIcon(ItemStack stack, int pass) { + return icons[pass]; + } + + @Override + public int getColorFromItemStack(ItemStack stack, int pass) { + if (pass == 0) return 0xFFFFFF; + + Brew brew = getBrew(stack); + if (brew == BotaniaAPI.fallbackBrew) return 0x989898; + + Color color = new Color(brew.getColor(stack)); + int add = (int) (Math.sin(ClientTickHandler.ticksInGame * 0.2) * 24); + + int r = Math.max(0, Math.min(255, color.getRed() + add)); + int g = Math.max(0, Math.min(255, color.getGreen() + add)); + int b = Math.max(0, Math.min(255, color.getBlue() + add)); + + return r << 16 | g << 8 | b; + } + + @Override + public void addInformation(ItemStack stack, EntityPlayer player, List list, boolean adv) { + Brew brew = getBrew(stack); + if (brew == BotaniaAPI.fallbackBrew) { + addStringToTooltip( + EnumChatFormatting.LIGHT_PURPLE + StatCollector.translateToLocal("botaniamisc.notInfused"), list); + return; + } + + addStringToTooltip( + EnumChatFormatting.LIGHT_PURPLE + + String.format( + StatCollector.translateToLocal("botaniamisc.brewOf"), + StatCollector.translateToLocal(brew.getUnlocalizedName(stack))), + list); + for (PotionEffect effect : brew.getPotionEffects(stack)) { + Potion potion = Potion.potionTypes[effect.getPotionID()]; + EnumChatFormatting format = potion.isBadEffect() ? EnumChatFormatting.RED : EnumChatFormatting.GRAY; + PotionEffect longEffect = new PotionEffect( + effect.getPotionID(), effect.getDuration() * TIME_MULTIPLIER, effect.getAmplifier(), false); + addStringToTooltip( + " " + format + StatCollector.translateToLocal(effect.getEffectName()) + + (effect.getAmplifier() == 0 + ? "" + : " " + + StatCollector.translateToLocal( + "botania.roman" + (effect.getAmplifier() + 1))) + + EnumChatFormatting.GRAY + + (potion.isInstant() ? "" : " (" + Potion.getDurationString(longEffect) + ")"), + list); + } + } + + void addStringToTooltip(String s, List tooltip) { + tooltip.add(s.replaceAll("&", "\u00a7")); + } + + @Override + public Brew getBrew(ItemStack stack) { + String key = ItemNBTHelper.getString(stack, TAG_BREW_KEY, ""); + return BotaniaAPI.getBrewFromKey(key); + } + + public static void setBrew(ItemStack stack, Brew brew) { + setBrew(stack, brew.getKey()); + } + + public static void setBrew(ItemStack stack, String brew) { + ItemNBTHelper.setString(stack, TAG_BREW_KEY, brew); + } + + @Override + public ItemStack getItemForBrew(Brew brew, ItemStack stack) { + if (!brew.canInfuseIncense() + || brew.getPotionEffects(stack).size() != 1 + || Potion.potionTypes[brew.getPotionEffects(stack).get(0).getPotionID()].isInstant()) return null; + + ItemStack brewStack = new ItemStack(this); + setBrew(brewStack, brew); + return brewStack; + } + + @Override + public int getManaCost(Brew brew, ItemStack stack) { + return brew.getManaCost() * 10; + } } diff --git a/src/main/java/vazkii/botania/common/item/brew/ItemVial.java b/src/main/java/vazkii/botania/common/item/brew/ItemVial.java index 81e3aed7a4..3f9ae09f3b 100644 --- a/src/main/java/vazkii/botania/common/item/brew/ItemVial.java +++ b/src/main/java/vazkii/botania/common/item/brew/ItemVial.java @@ -2,16 +2,15 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Nov 1, 2014, 5:45:50 PM (GMT)] */ package vazkii.botania.common.item.brew; import java.util.List; - import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.item.Item; @@ -26,49 +25,47 @@ public class ItemVial extends ItemMod implements IBrewContainer { - public static IIcon flaskIcon, vialIcon; - - public ItemVial() { - this(LibItemNames.VIAL); - } + public static IIcon flaskIcon, vialIcon; - public ItemVial(String name) { - setHasSubtypes(true); - setUnlocalizedName(name); - } + public ItemVial() { + this(LibItemNames.VIAL); + } - @Override - public void registerIcons(IIconRegister par1IconRegister) { - vialIcon = IconHelper.forName(par1IconRegister, LibItemNames.VIAL + "0"); - flaskIcon = IconHelper.forName(par1IconRegister, LibItemNames.FLASK + "0"); - } + public ItemVial(String name) { + setHasSubtypes(true); + setUnlocalizedName(name); + } - @Override - public IIcon getIconFromDamage(int i) { - return i == 0 ? vialIcon : flaskIcon; - } + @Override + public void registerIcons(IIconRegister par1IconRegister) { + vialIcon = IconHelper.forName(par1IconRegister, LibItemNames.VIAL + "0"); + flaskIcon = IconHelper.forName(par1IconRegister, LibItemNames.FLASK + "0"); + } - @Override - public void getSubItems(Item item, CreativeTabs tab, List list) { - for(int i = 0; i < 2; i++) - list.add(new ItemStack(item, 1, i)); - } + @Override + public IIcon getIconFromDamage(int i) { + return i == 0 ? vialIcon : flaskIcon; + } - @Override - public String getUnlocalizedName(ItemStack par1ItemStack) { - return super.getUnlocalizedName(par1ItemStack) + par1ItemStack.getItemDamage(); - } + @Override + public void getSubItems(Item item, CreativeTabs tab, List list) { + for (int i = 0; i < 2; i++) list.add(new ItemStack(item, 1, i)); + } - @Override - public ItemStack getItemForBrew(Brew brew, ItemStack stack) { - ItemStack brewStack = new ItemStack(stack.getItemDamage() == 1 ? ModItems.brewFlask : ModItems.brewVial); - ItemBrewBase.setBrew(brewStack, brew); - return brewStack; - } + @Override + public String getUnlocalizedName(ItemStack par1ItemStack) { + return super.getUnlocalizedName(par1ItemStack) + par1ItemStack.getItemDamage(); + } - @Override - public int getManaCost(Brew brew, ItemStack stack) { - return brew.getManaCost() * (stack.getItemDamage() + 1); - } + @Override + public ItemStack getItemForBrew(Brew brew, ItemStack stack) { + ItemStack brewStack = new ItemStack(stack.getItemDamage() == 1 ? ModItems.brewFlask : ModItems.brewVial); + ItemBrewBase.setBrew(brewStack, brew); + return brewStack; + } + @Override + public int getManaCost(Brew brew, ItemStack stack) { + return brew.getManaCost() * (stack.getItemDamage() + 1); + } } diff --git a/src/main/java/vazkii/botania/common/item/equipment/armor/elementium/ItemElementiumArmor.java b/src/main/java/vazkii/botania/common/item/equipment/armor/elementium/ItemElementiumArmor.java index 96980869cc..ece410df6b 100644 --- a/src/main/java/vazkii/botania/common/item/equipment/armor/elementium/ItemElementiumArmor.java +++ b/src/main/java/vazkii/botania/common/item/equipment/armor/elementium/ItemElementiumArmor.java @@ -1,7 +1,8 @@ package vazkii.botania.common.item.equipment.armor.elementium; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; import java.util.List; - import net.minecraft.client.model.ModelBiped; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; @@ -13,72 +14,77 @@ import vazkii.botania.common.core.handler.ConfigHandler; import vazkii.botania.common.item.ModItems; import vazkii.botania.common.item.equipment.armor.manasteel.ItemManasteelArmor; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; public abstract class ItemElementiumArmor extends ItemManasteelArmor implements IPixieSpawner { - public ItemElementiumArmor(int type, String name) { - super(type, name, BotaniaAPI.elementiumArmorMaterial); - } - - @Override - @SideOnly(Side.CLIENT) - public ModelBiped provideArmorModelForSlot(ItemStack stack, int slot) { - models[slot] = new ModelArmorElementium(slot); - return models[slot]; - } - - @Override - public String getArmorTextureAfterInk(ItemStack stack, int slot) { - return ConfigHandler.enableArmorModels ? LibResources.MODEL_ELEMENTIUM_NEW : slot == 2 ? LibResources.MODEL_ELEMENTIUM_1 : LibResources.MODEL_ELEMENTIUM_0; - } - - @Override - public boolean getIsRepairable(ItemStack par1ItemStack, ItemStack par2ItemStack) { - return par2ItemStack.getItem() == ModItems.manaResource && par2ItemStack.getItemDamage() == 7 ? true : super.getIsRepairable(par1ItemStack, par2ItemStack); - } - - static ItemStack[] armorset; - - @Override - public ItemStack[] getArmorSetStacks() { - if(armorset == null) - armorset = new ItemStack[] { - new ItemStack(ModItems.elementiumHelm), - new ItemStack(ModItems.elementiumChest), - new ItemStack(ModItems.elementiumLegs), - new ItemStack(ModItems.elementiumBoots) - }; - - return armorset; - } - - @Override - public boolean hasArmorSetItem(EntityPlayer player, int i) { - ItemStack stack = player.inventory.armorInventory[3 - i]; - if(stack == null) - return false; - - switch(i) { - case 0: return stack.getItem() == ModItems.elementiumHelm || stack.getItem() == ModItems.elementiumHelmRevealing; - case 1: return stack.getItem() == ModItems.elementiumChest; - case 2: return stack.getItem() == ModItems.elementiumLegs; - case 3: return stack.getItem() == ModItems.elementiumBoots; - } - - return false; - } - - @Override - public String getArmorSetName() { - return StatCollector.translateToLocal("botania.armorset.elementium.name"); - } - - @Override - public void addArmorSetDescription(ItemStack stack, List list) { - super.addArmorSetDescription(stack, list); - addStringToTooltip(StatCollector.translateToLocal("botania.armorset.elementium.desc"), list); - } - + public ItemElementiumArmor(int type, String name) { + super(type, name, BotaniaAPI.elementiumArmorMaterial); + } + + @Override + @SideOnly(Side.CLIENT) + public ModelBiped provideArmorModelForSlot(ItemStack stack, int slot) { + models[slot] = new ModelArmorElementium(slot); + return models[slot]; + } + + @Override + public String getArmorTextureAfterInk(ItemStack stack, int slot) { + return ConfigHandler.enableArmorModels + ? LibResources.MODEL_ELEMENTIUM_NEW + : slot == 2 ? LibResources.MODEL_ELEMENTIUM_1 : LibResources.MODEL_ELEMENTIUM_0; + } + + @Override + public boolean getIsRepairable(ItemStack par1ItemStack, ItemStack par2ItemStack) { + return par2ItemStack.getItem() == ModItems.manaResource && par2ItemStack.getItemDamage() == 7 + ? true + : super.getIsRepairable(par1ItemStack, par2ItemStack); + } + + static ItemStack[] armorset; + + @Override + public ItemStack[] getArmorSetStacks() { + if (armorset == null) + armorset = new ItemStack[] { + new ItemStack(ModItems.elementiumHelm), + new ItemStack(ModItems.elementiumChest), + new ItemStack(ModItems.elementiumLegs), + new ItemStack(ModItems.elementiumBoots) + }; + + return armorset; + } + + @Override + public boolean hasArmorSetItem(EntityPlayer player, int i) { + ItemStack stack = player.inventory.armorInventory[3 - i]; + if (stack == null) return false; + + switch (i) { + case 0: + return stack.getItem() == ModItems.elementiumHelm + || stack.getItem() == ModItems.elementiumHelmRevealing; + case 1: + return stack.getItem() == ModItems.elementiumChest; + case 2: + return stack.getItem() == ModItems.elementiumLegs; + case 3: + return stack.getItem() == ModItems.elementiumBoots; + } + + return false; + } + + @Override + public String getArmorSetName() { + return StatCollector.translateToLocal("botania.armorset.elementium.name"); + } + + @Override + public void addArmorSetDescription(ItemStack stack, List list) { + super.addArmorSetDescription(stack, list); + addStringToTooltip(StatCollector.translateToLocal("botania.armorset.elementium.desc"), list); + } } diff --git a/src/main/java/vazkii/botania/common/item/equipment/armor/elementium/ItemElementiumBoots.java b/src/main/java/vazkii/botania/common/item/equipment/armor/elementium/ItemElementiumBoots.java index d37f6b7edd..073d2ecb92 100644 --- a/src/main/java/vazkii/botania/common/item/equipment/armor/elementium/ItemElementiumBoots.java +++ b/src/main/java/vazkii/botania/common/item/equipment/armor/elementium/ItemElementiumBoots.java @@ -5,13 +5,12 @@ public class ItemElementiumBoots extends ItemElementiumArmor { - public ItemElementiumBoots() { - super(3, LibItemNames.ELEMENTIUM_BOOTS); - } - - @Override - public float getPixieChance(ItemStack stack) { - return 0.09F; - } + public ItemElementiumBoots() { + super(3, LibItemNames.ELEMENTIUM_BOOTS); + } + @Override + public float getPixieChance(ItemStack stack) { + return 0.09F; + } } diff --git a/src/main/java/vazkii/botania/common/item/equipment/armor/elementium/ItemElementiumChest.java b/src/main/java/vazkii/botania/common/item/equipment/armor/elementium/ItemElementiumChest.java index 2994a3ca2c..ccd426fe61 100644 --- a/src/main/java/vazkii/botania/common/item/equipment/armor/elementium/ItemElementiumChest.java +++ b/src/main/java/vazkii/botania/common/item/equipment/armor/elementium/ItemElementiumChest.java @@ -5,13 +5,12 @@ public class ItemElementiumChest extends ItemElementiumArmor { - public ItemElementiumChest() { - super(1, LibItemNames.ELEMENTIUM_CHEST); - } - - @Override - public float getPixieChance(ItemStack stack) { - return 0.17F; - } + public ItemElementiumChest() { + super(1, LibItemNames.ELEMENTIUM_CHEST); + } + @Override + public float getPixieChance(ItemStack stack) { + return 0.17F; + } } diff --git a/src/main/java/vazkii/botania/common/item/equipment/armor/elementium/ItemElementiumHelm.java b/src/main/java/vazkii/botania/common/item/equipment/armor/elementium/ItemElementiumHelm.java index ef357ddb8c..88e10db0f6 100644 --- a/src/main/java/vazkii/botania/common/item/equipment/armor/elementium/ItemElementiumHelm.java +++ b/src/main/java/vazkii/botania/common/item/equipment/armor/elementium/ItemElementiumHelm.java @@ -7,22 +7,21 @@ public class ItemElementiumHelm extends ItemElementiumArmor implements IManaDiscountArmor { - public ItemElementiumHelm() { - this(LibItemNames.ELEMENTIUM_HELM); - } + public ItemElementiumHelm() { + this(LibItemNames.ELEMENTIUM_HELM); + } - public ItemElementiumHelm(String name) { - super(0, name); - } + public ItemElementiumHelm(String name) { + super(0, name); + } - @Override - public float getPixieChance(ItemStack stack) { - return 0.11F; - } - - @Override - public float getDiscount(ItemStack stack, int slot, EntityPlayer player) { - return hasArmorSet(player) ? 0.1F : 0F; - } + @Override + public float getPixieChance(ItemStack stack) { + return 0.11F; + } + @Override + public float getDiscount(ItemStack stack, int slot, EntityPlayer player) { + return hasArmorSet(player) ? 0.1F : 0F; + } } diff --git a/src/main/java/vazkii/botania/common/item/equipment/armor/elementium/ItemElementiumLegs.java b/src/main/java/vazkii/botania/common/item/equipment/armor/elementium/ItemElementiumLegs.java index d221f4e7f5..0513b5cff5 100644 --- a/src/main/java/vazkii/botania/common/item/equipment/armor/elementium/ItemElementiumLegs.java +++ b/src/main/java/vazkii/botania/common/item/equipment/armor/elementium/ItemElementiumLegs.java @@ -5,13 +5,12 @@ public class ItemElementiumLegs extends ItemElementiumArmor { - public ItemElementiumLegs() { - super(2, LibItemNames.ELEMENTIUM_LEGS); - } - - @Override - public float getPixieChance(ItemStack stack) { - return 0.15F; - } + public ItemElementiumLegs() { + super(2, LibItemNames.ELEMENTIUM_LEGS); + } + @Override + public float getPixieChance(ItemStack stack) { + return 0.15F; + } } diff --git a/src/main/java/vazkii/botania/common/item/equipment/armor/manasteel/ItemManasteelArmor.java b/src/main/java/vazkii/botania/common/item/equipment/armor/manasteel/ItemManasteelArmor.java index b73a63f8e3..26b13021d8 100644 --- a/src/main/java/vazkii/botania/common/item/equipment/armor/manasteel/ItemManasteelArmor.java +++ b/src/main/java/vazkii/botania/common/item/equipment/armor/manasteel/ItemManasteelArmor.java @@ -2,16 +2,19 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Apr 13, 2014, 6:38:21 PM (GMT)] */ package vazkii.botania.common.item.equipment.armor.manasteel; +import cpw.mods.fml.common.Optional; +import cpw.mods.fml.common.registry.GameRegistry; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; import java.util.List; - import net.minecraft.client.gui.GuiScreen; import net.minecraft.client.model.ModelBiped; import net.minecraft.client.renderer.texture.IIconRegister; @@ -39,214 +42,219 @@ import vazkii.botania.common.core.helper.ItemNBTHelper; import vazkii.botania.common.item.ModItems; import vazkii.botania.common.item.equipment.tool.ToolCommons; -import cpw.mods.fml.common.Optional; -import cpw.mods.fml.common.registry.GameRegistry; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; @Optional.Interface(modid = "Thaumcraft", iface = "thaumcraft.api.IRunicArmor") -public class ItemManasteelArmor extends ItemArmor implements ISpecialArmor, IManaUsingItem, IPhantomInkable, IRunicArmor { - - private static final int MANA_PER_DAMAGE = 70; - - private static final String TAG_PHANTOM_INK = "phantomInk"; - - protected ModelBiped[] models = null; - public int type; - - public ItemManasteelArmor(int type, String name) { - this(type, name, BotaniaAPI.manasteelArmorMaterial); - } - - public ItemManasteelArmor(int type, String name, ArmorMaterial mat) { - super(mat, 0, type); - this.type = type; - setCreativeTab(BotaniaCreativeTab.INSTANCE); - setUnlocalizedName(name); - } - - @Override - public Item setUnlocalizedName(String par1Str) { - GameRegistry.registerItem(this, par1Str); - return super.setUnlocalizedName(par1Str); - } - - @Override - public String getUnlocalizedNameInefficiently(ItemStack par1ItemStack) { - return super.getUnlocalizedNameInefficiently(par1ItemStack).replaceAll("item.", "item." + LibResources.PREFIX_MOD); - } - - @Override - @SideOnly(Side.CLIENT) - public void registerIcons(IIconRegister par1IconRegister) { - itemIcon = IconHelper.forItem(par1IconRegister, this); - } - - @Override - public ArmorProperties getProperties(EntityLivingBase player, ItemStack armor, DamageSource source, double damage, int slot) { - if(source.isUnblockable()) - return new ArmorProperties(0, 0, 0); - return new ArmorProperties(0, damageReduceAmount / 25D, armor.getMaxDamage() + 1 - armor.getItemDamage()); - } - - @Override - public int getArmorDisplay(EntityPlayer player, ItemStack armor, int slot) { - return damageReduceAmount; - } - - @Override - public void onUpdate(ItemStack stack, World world, Entity player, int par4, boolean par5) { - if(player instanceof EntityPlayer) - onArmorTick(world, (EntityPlayer) player, stack); - } - - @Override - public void onArmorTick(World world, EntityPlayer player, ItemStack stack) { - if(!world.isRemote && stack.getItemDamage() > 0 && ManaItemHandler.requestManaExact(stack, player, MANA_PER_DAMAGE * 2, true)) - stack.setItemDamage(stack.getItemDamage() - 1); - } - - @Override - public void damageArmor(EntityLivingBase entity, ItemStack stack, DamageSource source, int damage, int slot) { - ToolCommons.damageItem(stack, damage, entity, MANA_PER_DAMAGE); - } - - @Override - public final String getArmorTexture(ItemStack stack, Entity entity, int slot, String type) { - return hasPhantomInk(stack) ? LibResources.MODEL_INVISIBLE_ARMOR : getArmorTextureAfterInk(stack, slot); - } - - public String getArmorTextureAfterInk(ItemStack stack, int slot) { - return ConfigHandler.enableArmorModels ? LibResources.MODEL_MANASTEEL_NEW : slot == 2 ? LibResources.MODEL_MANASTEEL_1 : LibResources.MODEL_MANASTEEL_0; - } - - @Override - @SideOnly(Side.CLIENT) - public ModelBiped getArmorModel(EntityLivingBase entityLiving, ItemStack itemStack, int armorSlot) { - if(ConfigHandler.enableArmorModels) { - ModelBiped model = getArmorModelForSlot(entityLiving, itemStack, armorSlot); - if(model == null) - model = provideArmorModelForSlot(itemStack, armorSlot); - - if(model != null) - return model; - } - - return super.getArmorModel(entityLiving, itemStack, armorSlot); - } - - @SideOnly(Side.CLIENT) - public ModelBiped getArmorModelForSlot(EntityLivingBase entity, ItemStack stack, int slot) { - if(models == null) - models = new ModelBiped[4]; - - return models[slot]; - } - - @SideOnly(Side.CLIENT) - public ModelBiped provideArmorModelForSlot(ItemStack stack, int slot) { - models[slot] = new ModelArmorManasteel(slot); - return models[slot]; - } - - @Override - public boolean getIsRepairable(ItemStack par1ItemStack, ItemStack par2ItemStack) { - return par2ItemStack.getItem() == ModItems.manaResource && par2ItemStack.getItemDamage() == 0 ? true : super.getIsRepairable(par1ItemStack, par2ItemStack); - } - - @Override - public boolean usesMana(ItemStack stack) { - return true; - } - - @Override - public void addInformation(ItemStack stack, EntityPlayer player, List list, boolean adv) { - if(GuiScreen.isShiftKeyDown()) - addInformationAfterShift(stack, player, list, adv); - else addStringToTooltip(StatCollector.translateToLocal("botaniamisc.shiftinfo"), list); - } - - public void addInformationAfterShift(ItemStack stack, EntityPlayer player, List list, boolean adv) { - addStringToTooltip(getArmorSetTitle(player), list); - addArmorSetDescription(stack, list); - ItemStack[] stacks = getArmorSetStacks(); - for(int i = 0; i < stacks.length; i++) - addStringToTooltip((hasArmorSetItem(player, i) ? EnumChatFormatting.GREEN : "") + " - " + stacks[i].getDisplayName(), list); - if(hasPhantomInk(stack)) - addStringToTooltip(StatCollector.translateToLocal("botaniamisc.hasPhantomInk"), list); - } - - public void addStringToTooltip(String s, List tooltip) { - tooltip.add(s.replaceAll("&", "\u00a7")); - } - - static ItemStack[] armorset; - - public ItemStack[] getArmorSetStacks() { - if(armorset == null) - armorset = new ItemStack[] { - new ItemStack(ModItems.manasteelHelm), - new ItemStack(ModItems.manasteelChest), - new ItemStack(ModItems.manasteelLegs), - new ItemStack(ModItems.manasteelBoots) - }; - - return armorset; - } - - public boolean hasArmorSet(EntityPlayer player) { - return hasArmorSetItem(player, 0) && hasArmorSetItem(player, 1) && hasArmorSetItem(player, 2) && hasArmorSetItem(player, 3); - } - - public boolean hasArmorSetItem(EntityPlayer player, int i) { - ItemStack stack = player.inventory.armorInventory[3 - i]; - if(stack == null) - return false; - - switch(i) { - case 0: return stack.getItem() == ModItems.manasteelHelm || stack.getItem() == ModItems.manasteelHelmRevealing; - case 1: return stack.getItem() == ModItems.manasteelChest; - case 2: return stack.getItem() == ModItems.manasteelLegs; - case 3: return stack.getItem() == ModItems.manasteelBoots; - } - - return false; - } - - public int getSetPiecesEquipped(EntityPlayer player) { - int pieces = 0; - for(int i = 0; i < 4; i++) - if(hasArmorSetItem(player, i)) - pieces++; - - return pieces; - } - - public String getArmorSetName() { - return StatCollector.translateToLocal("botania.armorset.manasteel.name"); - } - - public String getArmorSetTitle(EntityPlayer player) { - return StatCollector.translateToLocal("botaniamisc.armorset") + " " + getArmorSetName() + " (" + getSetPiecesEquipped(player) + "/" + getArmorSetStacks().length + ")"; - } - - public void addArmorSetDescription(ItemStack stack, List list) { - addStringToTooltip(StatCollector.translateToLocal("botania.armorset.manasteel.desc"), list); - } - - @Override - public boolean hasPhantomInk(ItemStack stack) { - return ItemNBTHelper.getBoolean(stack, TAG_PHANTOM_INK, false); - } - - @Override - public void setPhantomInk(ItemStack stack, boolean ink) { - ItemNBTHelper.setBoolean(stack, TAG_PHANTOM_INK, ink); - } - - @Override - @Optional.Method(modid = "Thaumcraft") - public int getRunicCharge(ItemStack itemstack) { - return 0; - } +public class ItemManasteelArmor extends ItemArmor + implements ISpecialArmor, IManaUsingItem, IPhantomInkable, IRunicArmor { + + private static final int MANA_PER_DAMAGE = 70; + + private static final String TAG_PHANTOM_INK = "phantomInk"; + + protected ModelBiped[] models = null; + public int type; + + public ItemManasteelArmor(int type, String name) { + this(type, name, BotaniaAPI.manasteelArmorMaterial); + } + + public ItemManasteelArmor(int type, String name, ArmorMaterial mat) { + super(mat, 0, type); + this.type = type; + setCreativeTab(BotaniaCreativeTab.INSTANCE); + setUnlocalizedName(name); + } + + @Override + public Item setUnlocalizedName(String par1Str) { + GameRegistry.registerItem(this, par1Str); + return super.setUnlocalizedName(par1Str); + } + + @Override + public String getUnlocalizedNameInefficiently(ItemStack par1ItemStack) { + return super.getUnlocalizedNameInefficiently(par1ItemStack) + .replaceAll("item.", "item." + LibResources.PREFIX_MOD); + } + + @Override + @SideOnly(Side.CLIENT) + public void registerIcons(IIconRegister par1IconRegister) { + itemIcon = IconHelper.forItem(par1IconRegister, this); + } + + @Override + public ArmorProperties getProperties( + EntityLivingBase player, ItemStack armor, DamageSource source, double damage, int slot) { + if (source.isUnblockable()) return new ArmorProperties(0, 0, 0); + return new ArmorProperties(0, damageReduceAmount / 25D, armor.getMaxDamage() + 1 - armor.getItemDamage()); + } + + @Override + public int getArmorDisplay(EntityPlayer player, ItemStack armor, int slot) { + return damageReduceAmount; + } + + @Override + public void onUpdate(ItemStack stack, World world, Entity player, int par4, boolean par5) { + if (player instanceof EntityPlayer) onArmorTick(world, (EntityPlayer) player, stack); + } + + @Override + public void onArmorTick(World world, EntityPlayer player, ItemStack stack) { + if (!world.isRemote + && stack.getItemDamage() > 0 + && ManaItemHandler.requestManaExact(stack, player, MANA_PER_DAMAGE * 2, true)) + stack.setItemDamage(stack.getItemDamage() - 1); + } + + @Override + public void damageArmor(EntityLivingBase entity, ItemStack stack, DamageSource source, int damage, int slot) { + ToolCommons.damageItem(stack, damage, entity, MANA_PER_DAMAGE); + } + + @Override + public final String getArmorTexture(ItemStack stack, Entity entity, int slot, String type) { + return hasPhantomInk(stack) ? LibResources.MODEL_INVISIBLE_ARMOR : getArmorTextureAfterInk(stack, slot); + } + + public String getArmorTextureAfterInk(ItemStack stack, int slot) { + return ConfigHandler.enableArmorModels + ? LibResources.MODEL_MANASTEEL_NEW + : slot == 2 ? LibResources.MODEL_MANASTEEL_1 : LibResources.MODEL_MANASTEEL_0; + } + + @Override + @SideOnly(Side.CLIENT) + public ModelBiped getArmorModel(EntityLivingBase entityLiving, ItemStack itemStack, int armorSlot) { + if (ConfigHandler.enableArmorModels) { + ModelBiped model = getArmorModelForSlot(entityLiving, itemStack, armorSlot); + if (model == null) model = provideArmorModelForSlot(itemStack, armorSlot); + + if (model != null) return model; + } + + return super.getArmorModel(entityLiving, itemStack, armorSlot); + } + + @SideOnly(Side.CLIENT) + public ModelBiped getArmorModelForSlot(EntityLivingBase entity, ItemStack stack, int slot) { + if (models == null) models = new ModelBiped[4]; + + return models[slot]; + } + + @SideOnly(Side.CLIENT) + public ModelBiped provideArmorModelForSlot(ItemStack stack, int slot) { + models[slot] = new ModelArmorManasteel(slot); + return models[slot]; + } + + @Override + public boolean getIsRepairable(ItemStack par1ItemStack, ItemStack par2ItemStack) { + return par2ItemStack.getItem() == ModItems.manaResource && par2ItemStack.getItemDamage() == 0 + ? true + : super.getIsRepairable(par1ItemStack, par2ItemStack); + } + + @Override + public boolean usesMana(ItemStack stack) { + return true; + } + + @Override + public void addInformation(ItemStack stack, EntityPlayer player, List list, boolean adv) { + if (GuiScreen.isShiftKeyDown()) addInformationAfterShift(stack, player, list, adv); + else addStringToTooltip(StatCollector.translateToLocal("botaniamisc.shiftinfo"), list); + } + + public void addInformationAfterShift(ItemStack stack, EntityPlayer player, List list, boolean adv) { + addStringToTooltip(getArmorSetTitle(player), list); + addArmorSetDescription(stack, list); + ItemStack[] stacks = getArmorSetStacks(); + for (int i = 0; i < stacks.length; i++) + addStringToTooltip( + (hasArmorSetItem(player, i) ? EnumChatFormatting.GREEN : "") + " - " + stacks[i].getDisplayName(), + list); + if (hasPhantomInk(stack)) addStringToTooltip(StatCollector.translateToLocal("botaniamisc.hasPhantomInk"), list); + } + + public void addStringToTooltip(String s, List tooltip) { + tooltip.add(s.replaceAll("&", "\u00a7")); + } + + static ItemStack[] armorset; + + public ItemStack[] getArmorSetStacks() { + if (armorset == null) + armorset = new ItemStack[] { + new ItemStack(ModItems.manasteelHelm), + new ItemStack(ModItems.manasteelChest), + new ItemStack(ModItems.manasteelLegs), + new ItemStack(ModItems.manasteelBoots) + }; + + return armorset; + } + + public boolean hasArmorSet(EntityPlayer player) { + return hasArmorSetItem(player, 0) + && hasArmorSetItem(player, 1) + && hasArmorSetItem(player, 2) + && hasArmorSetItem(player, 3); + } + + public boolean hasArmorSetItem(EntityPlayer player, int i) { + ItemStack stack = player.inventory.armorInventory[3 - i]; + if (stack == null) return false; + + switch (i) { + case 0: + return stack.getItem() == ModItems.manasteelHelm || stack.getItem() == ModItems.manasteelHelmRevealing; + case 1: + return stack.getItem() == ModItems.manasteelChest; + case 2: + return stack.getItem() == ModItems.manasteelLegs; + case 3: + return stack.getItem() == ModItems.manasteelBoots; + } + + return false; + } + + public int getSetPiecesEquipped(EntityPlayer player) { + int pieces = 0; + for (int i = 0; i < 4; i++) if (hasArmorSetItem(player, i)) pieces++; + + return pieces; + } + + public String getArmorSetName() { + return StatCollector.translateToLocal("botania.armorset.manasteel.name"); + } + + public String getArmorSetTitle(EntityPlayer player) { + return StatCollector.translateToLocal("botaniamisc.armorset") + " " + getArmorSetName() + " (" + + getSetPiecesEquipped(player) + "/" + getArmorSetStacks().length + ")"; + } + + public void addArmorSetDescription(ItemStack stack, List list) { + addStringToTooltip(StatCollector.translateToLocal("botania.armorset.manasteel.desc"), list); + } + + @Override + public boolean hasPhantomInk(ItemStack stack) { + return ItemNBTHelper.getBoolean(stack, TAG_PHANTOM_INK, false); + } + + @Override + public void setPhantomInk(ItemStack stack, boolean ink) { + ItemNBTHelper.setBoolean(stack, TAG_PHANTOM_INK, ink); + } + + @Override + @Optional.Method(modid = "Thaumcraft") + public int getRunicCharge(ItemStack itemstack) { + return 0; + } } diff --git a/src/main/java/vazkii/botania/common/item/equipment/armor/manasteel/ItemManasteelBoots.java b/src/main/java/vazkii/botania/common/item/equipment/armor/manasteel/ItemManasteelBoots.java index 3711be8e82..9c5ac006ba 100644 --- a/src/main/java/vazkii/botania/common/item/equipment/armor/manasteel/ItemManasteelBoots.java +++ b/src/main/java/vazkii/botania/common/item/equipment/armor/manasteel/ItemManasteelBoots.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Apr 13, 2014, 10:24:08 PM (GMT)] */ package vazkii.botania.common.item.equipment.armor.manasteel; @@ -14,8 +14,7 @@ public class ItemManasteelBoots extends ItemManasteelArmor { - public ItemManasteelBoots() { - super(3, LibItemNames.MANASTEEL_BOOTS); - } - + public ItemManasteelBoots() { + super(3, LibItemNames.MANASTEEL_BOOTS); + } } diff --git a/src/main/java/vazkii/botania/common/item/equipment/armor/manasteel/ItemManasteelChest.java b/src/main/java/vazkii/botania/common/item/equipment/armor/manasteel/ItemManasteelChest.java index 000ef254f4..9879ed798a 100644 --- a/src/main/java/vazkii/botania/common/item/equipment/armor/manasteel/ItemManasteelChest.java +++ b/src/main/java/vazkii/botania/common/item/equipment/armor/manasteel/ItemManasteelChest.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Apr 13, 2014, 10:22:57 PM (GMT)] */ package vazkii.botania.common.item.equipment.armor.manasteel; @@ -14,8 +14,7 @@ public class ItemManasteelChest extends ItemManasteelArmor { - public ItemManasteelChest() { - super(1, LibItemNames.MANASTEEL_CHEST); - } - + public ItemManasteelChest() { + super(1, LibItemNames.MANASTEEL_CHEST); + } } diff --git a/src/main/java/vazkii/botania/common/item/equipment/armor/manasteel/ItemManasteelHelm.java b/src/main/java/vazkii/botania/common/item/equipment/armor/manasteel/ItemManasteelHelm.java index e06815638d..2fecec9c6b 100644 --- a/src/main/java/vazkii/botania/common/item/equipment/armor/manasteel/ItemManasteelHelm.java +++ b/src/main/java/vazkii/botania/common/item/equipment/armor/manasteel/ItemManasteelHelm.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Apr 13, 2014, 10:22:24 PM (GMT)] */ package vazkii.botania.common.item.equipment.armor.manasteel; @@ -17,17 +17,16 @@ public class ItemManasteelHelm extends ItemManasteelArmor implements IManaDiscountArmor { - public ItemManasteelHelm() { - this(LibItemNames.MANASTEEL_HELM); - } + public ItemManasteelHelm() { + this(LibItemNames.MANASTEEL_HELM); + } - public ItemManasteelHelm(String name) { - super(0, name); - } - - @Override - public float getDiscount(ItemStack stack, int slot, EntityPlayer player) { - return hasArmorSet(player) ? 0.1F : 0F; - } + public ItemManasteelHelm(String name) { + super(0, name); + } + @Override + public float getDiscount(ItemStack stack, int slot, EntityPlayer player) { + return hasArmorSet(player) ? 0.1F : 0F; + } } diff --git a/src/main/java/vazkii/botania/common/item/equipment/armor/manasteel/ItemManasteelLegs.java b/src/main/java/vazkii/botania/common/item/equipment/armor/manasteel/ItemManasteelLegs.java index 0538d979de..3737ff9253 100644 --- a/src/main/java/vazkii/botania/common/item/equipment/armor/manasteel/ItemManasteelLegs.java +++ b/src/main/java/vazkii/botania/common/item/equipment/armor/manasteel/ItemManasteelLegs.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Apr 13, 2014, 10:23:28 PM (GMT)] */ package vazkii.botania.common.item.equipment.armor.manasteel; @@ -14,8 +14,7 @@ public class ItemManasteelLegs extends ItemManasteelArmor { - public ItemManasteelLegs() { - super(2, LibItemNames.MANASTEEL_LEGS); - } - + public ItemManasteelLegs() { + super(2, LibItemNames.MANASTEEL_LEGS); + } } diff --git a/src/main/java/vazkii/botania/common/item/equipment/armor/manaweave/ItemManaweaveArmor.java b/src/main/java/vazkii/botania/common/item/equipment/armor/manaweave/ItemManaweaveArmor.java index 97fec9a4da..09cd9448c0 100644 --- a/src/main/java/vazkii/botania/common/item/equipment/armor/manaweave/ItemManaweaveArmor.java +++ b/src/main/java/vazkii/botania/common/item/equipment/armor/manaweave/ItemManaweaveArmor.java @@ -2,16 +2,17 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Aug 28, 2015, 8:30:19 PM (GMT)] */ package vazkii.botania.common.item.equipment.armor.manaweave; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; import java.util.List; - import net.minecraft.client.model.ModelBiped; import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.entity.player.EntityPlayer; @@ -30,109 +31,114 @@ import vazkii.botania.common.core.handler.ConfigHandler; import vazkii.botania.common.item.ModItems; import vazkii.botania.common.item.equipment.armor.manasteel.ItemManasteelArmor; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; public class ItemManaweaveArmor extends ItemManasteelArmor implements ICraftAchievement { - IIcon iconChristmas; - - public ItemManaweaveArmor(int type, String name) { - super(type, name, BotaniaAPI.manaweaveArmorMaterial); - } - - @Override - @SideOnly(Side.CLIENT) - public ModelBiped provideArmorModelForSlot(ItemStack stack, int slot) { - models[slot] = new ModelArmorManaweave(slot); - return models[slot]; - } - - @Override - public void registerIcons(IIconRegister par1IconRegister) { - super.registerIcons(par1IconRegister); - iconChristmas = IconHelper.forItem(par1IconRegister, this, "Holiday"); - } - - @Override - public String getArmorTextureAfterInk(ItemStack stack, int slot) { - return ConfigHandler.enableArmorModels ? (ClientProxy.jingleTheBells ? LibResources.MODEL_MANAWEAVE_NEW_HOLIDAY : LibResources.MODEL_MANAWEAVE_NEW) : slot == 2 ? LibResources.MODEL_MANAWEAVE_1 : LibResources.MODEL_MANAWEAVE_0; - } - - @Override - public IIcon getIconFromDamage(int dmg) { - return ClientProxy.jingleTheBells ? iconChristmas : super.getIconFromDamage(dmg); - } - - @Override - @SideOnly(Side.CLIENT) - public String getUnlocalizedName(ItemStack p_77667_1_) { - String name = super.getUnlocalizedName(p_77667_1_); - if(ClientProxy.jingleTheBells) - name = name.replaceAll("manaweave", "santaweave"); - return name; - } - - @Override - public boolean getIsRepairable(ItemStack par1ItemStack, ItemStack par2ItemStack) { - return par2ItemStack.getItem() == ModItems.manaResource && par2ItemStack.getItemDamage() == 22 ? true : super.getIsRepairable(par1ItemStack, par2ItemStack); - } - - static ItemStack[] armorset; - - @Override - public ItemStack[] getArmorSetStacks() { - if(armorset == null) - armorset = new ItemStack[] { - new ItemStack(ModItems.manaweaveHelm), - new ItemStack(ModItems.manaweaveChest), - new ItemStack(ModItems.manaweaveLegs), - new ItemStack(ModItems.manaweaveBoots) - }; - - return armorset; - } - - @Override - public boolean hasArmorSetItem(EntityPlayer player, int i) { - ItemStack stack = player.inventory.armorInventory[3 - i]; - if(stack == null) - return false; - - switch(i) { - case 0: return stack.getItem() == ModItems.manaweaveHelm; - case 1: return stack.getItem() == ModItems.manaweaveChest; - case 2: return stack.getItem() == ModItems.manaweaveLegs; - case 3: return stack.getItem() == ModItems.manaweaveBoots; - } - - return false; - } - - @Override - public String getArmorSetName() { - return StatCollector.translateToLocal("botania.armorset.manaweave.name"); - } - - @Override - public void addInformationAfterShift(ItemStack stack, EntityPlayer player, List list, boolean adv) { - if(ClientProxy.jingleTheBells) { - addStringToTooltip(StatCollector.translateToLocal("botaniamisc.santaweaveInfo"), list); - addStringToTooltip("", list); - } - - super.addInformationAfterShift(stack, player, list, adv); - } - - @Override - public void addArmorSetDescription(ItemStack stack, List list) { - addStringToTooltip(StatCollector.translateToLocal("botania.armorset.manaweave.desc0"), list); - addStringToTooltip(StatCollector.translateToLocal("botania.armorset.manaweave.desc1"), list); - } - - @Override - public Achievement getAchievementOnCraft(ItemStack stack, EntityPlayer player, IInventory matrix) { - return ModAchievements.manaweaveArmorCraft; - } + IIcon iconChristmas; + + public ItemManaweaveArmor(int type, String name) { + super(type, name, BotaniaAPI.manaweaveArmorMaterial); + } + + @Override + @SideOnly(Side.CLIENT) + public ModelBiped provideArmorModelForSlot(ItemStack stack, int slot) { + models[slot] = new ModelArmorManaweave(slot); + return models[slot]; + } + + @Override + public void registerIcons(IIconRegister par1IconRegister) { + super.registerIcons(par1IconRegister); + iconChristmas = IconHelper.forItem(par1IconRegister, this, "Holiday"); + } + + @Override + public String getArmorTextureAfterInk(ItemStack stack, int slot) { + return ConfigHandler.enableArmorModels + ? (ClientProxy.jingleTheBells + ? LibResources.MODEL_MANAWEAVE_NEW_HOLIDAY + : LibResources.MODEL_MANAWEAVE_NEW) + : slot == 2 ? LibResources.MODEL_MANAWEAVE_1 : LibResources.MODEL_MANAWEAVE_0; + } + + @Override + public IIcon getIconFromDamage(int dmg) { + return ClientProxy.jingleTheBells ? iconChristmas : super.getIconFromDamage(dmg); + } + + @Override + @SideOnly(Side.CLIENT) + public String getUnlocalizedName(ItemStack p_77667_1_) { + String name = super.getUnlocalizedName(p_77667_1_); + if (ClientProxy.jingleTheBells) name = name.replaceAll("manaweave", "santaweave"); + return name; + } + + @Override + public boolean getIsRepairable(ItemStack par1ItemStack, ItemStack par2ItemStack) { + return par2ItemStack.getItem() == ModItems.manaResource && par2ItemStack.getItemDamage() == 22 + ? true + : super.getIsRepairable(par1ItemStack, par2ItemStack); + } + + static ItemStack[] armorset; + + @Override + public ItemStack[] getArmorSetStacks() { + if (armorset == null) + armorset = new ItemStack[] { + new ItemStack(ModItems.manaweaveHelm), + new ItemStack(ModItems.manaweaveChest), + new ItemStack(ModItems.manaweaveLegs), + new ItemStack(ModItems.manaweaveBoots) + }; + + return armorset; + } + + @Override + public boolean hasArmorSetItem(EntityPlayer player, int i) { + ItemStack stack = player.inventory.armorInventory[3 - i]; + if (stack == null) return false; + + switch (i) { + case 0: + return stack.getItem() == ModItems.manaweaveHelm; + case 1: + return stack.getItem() == ModItems.manaweaveChest; + case 2: + return stack.getItem() == ModItems.manaweaveLegs; + case 3: + return stack.getItem() == ModItems.manaweaveBoots; + } + + return false; + } + + @Override + public String getArmorSetName() { + return StatCollector.translateToLocal("botania.armorset.manaweave.name"); + } + + @Override + public void addInformationAfterShift(ItemStack stack, EntityPlayer player, List list, boolean adv) { + if (ClientProxy.jingleTheBells) { + addStringToTooltip(StatCollector.translateToLocal("botaniamisc.santaweaveInfo"), list); + addStringToTooltip("", list); + } + + super.addInformationAfterShift(stack, player, list, adv); + } + + @Override + public void addArmorSetDescription(ItemStack stack, List list) { + addStringToTooltip(StatCollector.translateToLocal("botania.armorset.manaweave.desc0"), list); + addStringToTooltip(StatCollector.translateToLocal("botania.armorset.manaweave.desc1"), list); + } + @Override + public Achievement getAchievementOnCraft(ItemStack stack, EntityPlayer player, IInventory matrix) { + return ModAchievements.manaweaveArmorCraft; + } } diff --git a/src/main/java/vazkii/botania/common/item/equipment/armor/manaweave/ItemManaweaveBoots.java b/src/main/java/vazkii/botania/common/item/equipment/armor/manaweave/ItemManaweaveBoots.java index 35d18e0ebc..ddc59b60ec 100644 --- a/src/main/java/vazkii/botania/common/item/equipment/armor/manaweave/ItemManaweaveBoots.java +++ b/src/main/java/vazkii/botania/common/item/equipment/armor/manaweave/ItemManaweaveBoots.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Aug 28, 2015, 8:48:58 PM (GMT)] */ package vazkii.botania.common.item.equipment.armor.manaweave; @@ -14,8 +14,7 @@ public class ItemManaweaveBoots extends ItemManaweaveArmor { - public ItemManaweaveBoots() { - super(3, LibItemNames.MANAWEAVE_BOOTS); - } - + public ItemManaweaveBoots() { + super(3, LibItemNames.MANAWEAVE_BOOTS); + } } diff --git a/src/main/java/vazkii/botania/common/item/equipment/armor/manaweave/ItemManaweaveChest.java b/src/main/java/vazkii/botania/common/item/equipment/armor/manaweave/ItemManaweaveChest.java index 98f4391f20..2bd0e22a70 100644 --- a/src/main/java/vazkii/botania/common/item/equipment/armor/manaweave/ItemManaweaveChest.java +++ b/src/main/java/vazkii/botania/common/item/equipment/armor/manaweave/ItemManaweaveChest.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Aug 28, 2015, 8:48:17 PM (GMT)] */ package vazkii.botania.common.item.equipment.armor.manaweave; @@ -14,9 +14,7 @@ public class ItemManaweaveChest extends ItemManaweaveArmor { - public ItemManaweaveChest() { - super(1, LibItemNames.MANAWEAVE_CHEST); - } - - + public ItemManaweaveChest() { + super(1, LibItemNames.MANAWEAVE_CHEST); + } } diff --git a/src/main/java/vazkii/botania/common/item/equipment/armor/manaweave/ItemManaweaveHelm.java b/src/main/java/vazkii/botania/common/item/equipment/armor/manaweave/ItemManaweaveHelm.java index 06ab5cd4a3..e81c807381 100644 --- a/src/main/java/vazkii/botania/common/item/equipment/armor/manaweave/ItemManaweaveHelm.java +++ b/src/main/java/vazkii/botania/common/item/equipment/armor/manaweave/ItemManaweaveHelm.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Aug 28, 2015, 8:47:04 PM (GMT)] */ package vazkii.botania.common.item.equipment.armor.manaweave; @@ -23,31 +23,32 @@ public class ItemManaweaveHelm extends ItemManaweaveArmor implements IManaDiscountArmor, IManaProficiencyArmor { - private static final int MANA_PER_DAMAGE = 30; - - public ItemManaweaveHelm() { - super(0, LibItemNames.MANAWEAVE_HELM); - } - - @Override - public float getDiscount(ItemStack stack, int slot, EntityPlayer player) { - return hasArmorSet(player) ? 0.35F : 0F; - } - - @Override - public boolean shouldGiveProficiency(ItemStack stack, int slot, EntityPlayer player) { - return hasArmorSet(player); - } - - @Override - public void onArmorTick(World world, EntityPlayer player, ItemStack stack) { - if(!world.isRemote && stack.getItemDamage() > 0 && ManaItemHandler.requestManaExact(stack, player, MANA_PER_DAMAGE * 2, true)) - stack.setItemDamage(stack.getItemDamage() - 1); - } - - @Override - public void damageArmor(EntityLivingBase entity, ItemStack stack, DamageSource source, int damage, int slot) { - ToolCommons.damageItem(stack, damage, entity, MANA_PER_DAMAGE); - } - + private static final int MANA_PER_DAMAGE = 30; + + public ItemManaweaveHelm() { + super(0, LibItemNames.MANAWEAVE_HELM); + } + + @Override + public float getDiscount(ItemStack stack, int slot, EntityPlayer player) { + return hasArmorSet(player) ? 0.35F : 0F; + } + + @Override + public boolean shouldGiveProficiency(ItemStack stack, int slot, EntityPlayer player) { + return hasArmorSet(player); + } + + @Override + public void onArmorTick(World world, EntityPlayer player, ItemStack stack) { + if (!world.isRemote + && stack.getItemDamage() > 0 + && ManaItemHandler.requestManaExact(stack, player, MANA_PER_DAMAGE * 2, true)) + stack.setItemDamage(stack.getItemDamage() - 1); + } + + @Override + public void damageArmor(EntityLivingBase entity, ItemStack stack, DamageSource source, int damage, int slot) { + ToolCommons.damageItem(stack, damage, entity, MANA_PER_DAMAGE); + } } diff --git a/src/main/java/vazkii/botania/common/item/equipment/armor/manaweave/ItemManaweaveLegs.java b/src/main/java/vazkii/botania/common/item/equipment/armor/manaweave/ItemManaweaveLegs.java index 63d61d161f..78bb20c78f 100644 --- a/src/main/java/vazkii/botania/common/item/equipment/armor/manaweave/ItemManaweaveLegs.java +++ b/src/main/java/vazkii/botania/common/item/equipment/armor/manaweave/ItemManaweaveLegs.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Aug 28, 2015, 8:48:36 PM (GMT)] */ package vazkii.botania.common.item.equipment.armor.manaweave; @@ -14,8 +14,7 @@ public class ItemManaweaveLegs extends ItemManaweaveArmor { - public ItemManaweaveLegs() { - super(2, LibItemNames.MANAWEAVE_LEGS); - } - + public ItemManaweaveLegs() { + super(2, LibItemNames.MANAWEAVE_LEGS); + } } diff --git a/src/main/java/vazkii/botania/common/item/equipment/armor/terrasteel/ItemTerrasteelArmor.java b/src/main/java/vazkii/botania/common/item/equipment/armor/terrasteel/ItemTerrasteelArmor.java index 7dcb7b24e1..243767044e 100644 --- a/src/main/java/vazkii/botania/common/item/equipment/armor/terrasteel/ItemTerrasteelArmor.java +++ b/src/main/java/vazkii/botania/common/item/equipment/armor/terrasteel/ItemTerrasteelArmor.java @@ -2,17 +2,20 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Apr 14, 2014, 2:58:13 PM (GMT)] */ package vazkii.botania.common.item.equipment.armor.terrasteel; +import com.google.common.collect.HashMultimap; +import com.google.common.collect.Multimap; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; import java.util.List; import java.util.UUID; - import net.minecraft.client.model.ModelBiped; import net.minecraft.entity.SharedMonsterAttributes; import net.minecraft.entity.ai.attributes.AttributeModifier; @@ -26,84 +29,91 @@ import vazkii.botania.common.item.ModItems; import vazkii.botania.common.item.equipment.armor.manasteel.ItemManasteelArmor; -import com.google.common.collect.HashMultimap; -import com.google.common.collect.Multimap; - -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; - public class ItemTerrasteelArmor extends ItemManasteelArmor { - public ItemTerrasteelArmor(int type, String name) { - super(type, name, BotaniaAPI.terrasteelArmorMaterial); - } - - @Override - @SideOnly(Side.CLIENT) - public ModelBiped provideArmorModelForSlot(ItemStack stack, int slot) { - models[slot] = new ModelArmorTerrasteel(slot); - return models[slot]; - } - - @Override - public String getArmorTextureAfterInk(ItemStack stack, int slot) { - return ConfigHandler.enableArmorModels ? LibResources.MODEL_TERRASTEEL_NEW : slot == 2 ? LibResources.MODEL_TERRASTEEL_1 : LibResources.MODEL_TERRASTEEL_0; - } - - @Override - public boolean getIsRepairable(ItemStack par1ItemStack, ItemStack par2ItemStack) { - return par2ItemStack.getItem() == ModItems.manaResource && par2ItemStack.getItemDamage() == 4 ? true : super.getIsRepairable(par1ItemStack, par2ItemStack); - } - - @Override - public Multimap getItemAttributeModifiers() { - Multimap multimap = HashMultimap.create(); - UUID uuid = new UUID(getUnlocalizedName().hashCode(), 0); - multimap.put(SharedMonsterAttributes.knockbackResistance.getAttributeUnlocalizedName(), new AttributeModifier(uuid, "Terrasteel modifier " + type, (double) getArmorDisplay(null, new ItemStack(this), type) / 20, 0)); - return multimap; - } - - static ItemStack[] armorset; - - @Override - public ItemStack[] getArmorSetStacks() { - if(armorset == null) - armorset = new ItemStack[] { - new ItemStack(ModItems.terrasteelHelm), - new ItemStack(ModItems.terrasteelChest), - new ItemStack(ModItems.terrasteelLegs), - new ItemStack(ModItems.terrasteelBoots) - }; - - return armorset; - } - - @Override - public boolean hasArmorSetItem(EntityPlayer player, int i) { - ItemStack stack = player.inventory.armorInventory[3 - i]; - if(stack == null) - return false; - - switch(i) { - case 0: return stack.getItem() == ModItems.terrasteelHelm || stack.getItem() == ModItems.terrasteelHelmRevealing; - case 1: return stack.getItem() == ModItems.terrasteelChest; - case 2: return stack.getItem() == ModItems.terrasteelLegs; - case 3: return stack.getItem() == ModItems.terrasteelBoots; - } - - return false; - } - - @Override - public String getArmorSetName() { - return StatCollector.translateToLocal("botania.armorset.terrasteel.name"); - } - - @Override - public void addArmorSetDescription(ItemStack stack, List list) { - addStringToTooltip(StatCollector.translateToLocal("botania.armorset.terrasteel.desc0"), list); - addStringToTooltip(StatCollector.translateToLocal("botania.armorset.terrasteel.desc1"), list); - addStringToTooltip(StatCollector.translateToLocal("botania.armorset.terrasteel.desc2"), list); - } - + public ItemTerrasteelArmor(int type, String name) { + super(type, name, BotaniaAPI.terrasteelArmorMaterial); + } + + @Override + @SideOnly(Side.CLIENT) + public ModelBiped provideArmorModelForSlot(ItemStack stack, int slot) { + models[slot] = new ModelArmorTerrasteel(slot); + return models[slot]; + } + + @Override + public String getArmorTextureAfterInk(ItemStack stack, int slot) { + return ConfigHandler.enableArmorModels + ? LibResources.MODEL_TERRASTEEL_NEW + : slot == 2 ? LibResources.MODEL_TERRASTEEL_1 : LibResources.MODEL_TERRASTEEL_0; + } + + @Override + public boolean getIsRepairable(ItemStack par1ItemStack, ItemStack par2ItemStack) { + return par2ItemStack.getItem() == ModItems.manaResource && par2ItemStack.getItemDamage() == 4 + ? true + : super.getIsRepairable(par1ItemStack, par2ItemStack); + } + + @Override + public Multimap getItemAttributeModifiers() { + Multimap multimap = HashMultimap.create(); + UUID uuid = new UUID(getUnlocalizedName().hashCode(), 0); + multimap.put( + SharedMonsterAttributes.knockbackResistance.getAttributeUnlocalizedName(), + new AttributeModifier( + uuid, + "Terrasteel modifier " + type, + (double) getArmorDisplay(null, new ItemStack(this), type) / 20, + 0)); + return multimap; + } + + static ItemStack[] armorset; + + @Override + public ItemStack[] getArmorSetStacks() { + if (armorset == null) + armorset = new ItemStack[] { + new ItemStack(ModItems.terrasteelHelm), + new ItemStack(ModItems.terrasteelChest), + new ItemStack(ModItems.terrasteelLegs), + new ItemStack(ModItems.terrasteelBoots) + }; + + return armorset; + } + + @Override + public boolean hasArmorSetItem(EntityPlayer player, int i) { + ItemStack stack = player.inventory.armorInventory[3 - i]; + if (stack == null) return false; + + switch (i) { + case 0: + return stack.getItem() == ModItems.terrasteelHelm + || stack.getItem() == ModItems.terrasteelHelmRevealing; + case 1: + return stack.getItem() == ModItems.terrasteelChest; + case 2: + return stack.getItem() == ModItems.terrasteelLegs; + case 3: + return stack.getItem() == ModItems.terrasteelBoots; + } + + return false; + } + + @Override + public String getArmorSetName() { + return StatCollector.translateToLocal("botania.armorset.terrasteel.name"); + } + + @Override + public void addArmorSetDescription(ItemStack stack, List list) { + addStringToTooltip(StatCollector.translateToLocal("botania.armorset.terrasteel.desc0"), list); + addStringToTooltip(StatCollector.translateToLocal("botania.armorset.terrasteel.desc1"), list); + addStringToTooltip(StatCollector.translateToLocal("botania.armorset.terrasteel.desc2"), list); + } } diff --git a/src/main/java/vazkii/botania/common/item/equipment/armor/terrasteel/ItemTerrasteelBoots.java b/src/main/java/vazkii/botania/common/item/equipment/armor/terrasteel/ItemTerrasteelBoots.java index 5ff5aedda1..48ffc5b684 100644 --- a/src/main/java/vazkii/botania/common/item/equipment/armor/terrasteel/ItemTerrasteelBoots.java +++ b/src/main/java/vazkii/botania/common/item/equipment/armor/terrasteel/ItemTerrasteelBoots.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Apr 14, 2014, 3:14:11 PM (GMT)] */ package vazkii.botania.common.item.equipment.armor.terrasteel; @@ -14,8 +14,7 @@ public class ItemTerrasteelBoots extends ItemTerrasteelArmor { - public ItemTerrasteelBoots() { - super(3, LibItemNames.TERRASTEEL_BOOTS); - } - + public ItemTerrasteelBoots() { + super(3, LibItemNames.TERRASTEEL_BOOTS); + } } diff --git a/src/main/java/vazkii/botania/common/item/equipment/armor/terrasteel/ItemTerrasteelChest.java b/src/main/java/vazkii/botania/common/item/equipment/armor/terrasteel/ItemTerrasteelChest.java index 4f4a7b6a3a..d44849fd90 100644 --- a/src/main/java/vazkii/botania/common/item/equipment/armor/terrasteel/ItemTerrasteelChest.java +++ b/src/main/java/vazkii/botania/common/item/equipment/armor/terrasteel/ItemTerrasteelChest.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Apr 14, 2014, 3:13:36 PM (GMT)] */ package vazkii.botania.common.item.equipment.armor.terrasteel; @@ -14,8 +14,7 @@ public class ItemTerrasteelChest extends ItemTerrasteelArmor { - public ItemTerrasteelChest() { - super(1, LibItemNames.TERRASTEEL_CHEST); - } - + public ItemTerrasteelChest() { + super(1, LibItemNames.TERRASTEEL_CHEST); + } } diff --git a/src/main/java/vazkii/botania/common/item/equipment/armor/terrasteel/ItemTerrasteelHelm.java b/src/main/java/vazkii/botania/common/item/equipment/armor/terrasteel/ItemTerrasteelHelm.java index 213e84f020..a2786bdb5e 100644 --- a/src/main/java/vazkii/botania/common/item/equipment/armor/terrasteel/ItemTerrasteelHelm.java +++ b/src/main/java/vazkii/botania/common/item/equipment/armor/terrasteel/ItemTerrasteelHelm.java @@ -2,16 +2,18 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Apr 14, 2014, 3:13:05 PM (GMT)] */ package vazkii.botania.common.item.equipment.armor.terrasteel; +import cpw.mods.fml.common.eventhandler.SubscribeEvent; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; import java.util.List; - import net.minecraft.client.Minecraft; import net.minecraft.client.renderer.ItemRenderer; import net.minecraft.client.renderer.Tessellator; @@ -28,9 +30,7 @@ import net.minecraftforge.client.event.RenderPlayerEvent; import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.event.entity.living.LivingHurtEvent; - import org.lwjgl.opengl.GL11; - import vazkii.botania.api.item.IAncientWillContainer; import vazkii.botania.api.item.IBaubleRender.Helper; import vazkii.botania.api.mana.IManaDiscountArmor; @@ -39,128 +39,122 @@ import vazkii.botania.client.core.helper.IconHelper; import vazkii.botania.common.core.helper.ItemNBTHelper; import vazkii.botania.common.lib.LibItemNames; -import cpw.mods.fml.common.eventhandler.SubscribeEvent; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; - -public class ItemTerrasteelHelm extends ItemTerrasteelArmor implements IManaDiscountArmor, IAncientWillContainer, IManaGivingItem { - - private static final String TAG_ANCIENT_WILL = "AncientWill"; - static IIcon willIcon; - - public ItemTerrasteelHelm() { - this(LibItemNames.TERRASTEEL_HELM); - MinecraftForge.EVENT_BUS.register(this); - } - - public ItemTerrasteelHelm(String name) { - super(0, name); - } - - @Override - @SideOnly(Side.CLIENT) - public void registerIcons(IIconRegister par1IconRegister) { - super.registerIcons(par1IconRegister); - willIcon = IconHelper.forName(par1IconRegister, "willFlame"); - } - - @Override - public void onArmorTick(World world, EntityPlayer player, ItemStack stack) { - super.onArmorTick(world, player, stack); - if(hasArmorSet(player)) { - int food = player.getFoodStats().getFoodLevel(); - if(food > 0 && food < 18 && player.shouldHeal() && player.ticksExisted % 80 == 0) - player.heal(1F); - ManaItemHandler.dispatchManaExact(stack, player, 1, true); - } - } - - @Override - public float getDiscount(ItemStack stack, int slot, EntityPlayer player) { - return hasArmorSet(player) ? 0.2F : 0F; - } - - @Override - public void addAncientWill(ItemStack stack, int will) { - ItemNBTHelper.setBoolean(stack, TAG_ANCIENT_WILL + will, true); - } - - @Override - public boolean hasAncientWill(ItemStack stack, int will) { - return hasAncientWill_(stack, will); - } - - public static boolean hasAncientWill_(ItemStack stack, int will) { - return ItemNBTHelper.getBoolean(stack, TAG_ANCIENT_WILL + will, false); - } - - @Override - @SideOnly(Side.CLIENT) - public void addArmorSetDescription(ItemStack stack, List list) { - super.addArmorSetDescription(stack, list); - for(int i = 0; i < 6; i++) - if(hasAncientWill(stack, i)) - addStringToTooltip(StatCollector.translateToLocal("botania.armorset.will" + i + ".desc"), list); - } - - public static boolean hasAnyWill(ItemStack stack) { - for(int i = 0; i < 6; i++) - if(hasAncientWill_(stack, i)) - return true; - - return false; - } - - @SideOnly(Side.CLIENT) - public static void renderOnPlayer(ItemStack stack, RenderPlayerEvent event) { - if(hasAnyWill(stack) && !((ItemTerrasteelArmor) stack.getItem()).hasPhantomInk(stack)) { - GL11.glPushMatrix(); - float f = willIcon.getMinU(); - float f1 = willIcon.getMaxU(); - float f2 = willIcon.getMinV(); - float f3 = willIcon.getMaxV(); - Helper.translateToHeadLevel(event.entityPlayer); - Minecraft.getMinecraft().renderEngine.bindTexture(TextureMap.locationItemsTexture); - GL11.glRotatef(90F, 0F, 1F, 0F); - GL11.glRotatef(180F, 1F, 0F, 0F); - GL11.glTranslatef(-0.26F, 0.15F, -0.39F); - GL11.glScalef(0.5F, 0.5F, 0.5F); - ItemRenderer.renderItemIn2D(Tessellator.instance, f1, f2, f, f3, willIcon.getIconWidth(), willIcon.getIconHeight(), 1F / 16F); - GL11.glPopMatrix(); - } - } - - @SubscribeEvent - public void onEntityAttacked(LivingHurtEvent event) { - Entity attacker = event.source.getEntity(); - if(attacker instanceof EntityPlayer) { - EntityPlayer player = (EntityPlayer) attacker; - if(hasArmorSet(player)) { - boolean crit = player.fallDistance > 0.0F && !player.onGround && !player.isOnLadder() && !player.isInWater() && !player.isPotionActive(Potion.blindness) && player.ridingEntity == null; - ItemStack stack = player.inventory.armorItemInSlot(3); - if(crit && stack != null && stack.getItem() instanceof ItemTerrasteelHelm) { - boolean ahrim = hasAncientWill(stack, 0); - boolean dharok = hasAncientWill(stack, 1); - boolean guthan = hasAncientWill(stack, 2); - boolean torag = hasAncientWill(stack, 3); - boolean verac = hasAncientWill(stack, 4); - boolean karil = hasAncientWill(stack, 5); - - if(ahrim) - event.entityLiving.addPotionEffect(new PotionEffect(Potion.weakness.id, 20, 1)); - if(dharok) - event.ammount *= 1F + (1F - player.getHealth() / player.getMaxHealth()) * 0.5F; - if(guthan) - player.heal(event.ammount * 0.25F); - if(torag) - event.entityLiving.addPotionEffect(new PotionEffect(Potion.moveSlowdown.id, 60, 1)); - if(verac) - event.source.setDamageBypassesArmor(); - if(karil) - event.entityLiving.addPotionEffect(new PotionEffect(Potion.wither.id, 60, 1)); - } - } - } - } +public class ItemTerrasteelHelm extends ItemTerrasteelArmor + implements IManaDiscountArmor, IAncientWillContainer, IManaGivingItem { + + private static final String TAG_ANCIENT_WILL = "AncientWill"; + static IIcon willIcon; + + public ItemTerrasteelHelm() { + this(LibItemNames.TERRASTEEL_HELM); + MinecraftForge.EVENT_BUS.register(this); + } + + public ItemTerrasteelHelm(String name) { + super(0, name); + } + + @Override + @SideOnly(Side.CLIENT) + public void registerIcons(IIconRegister par1IconRegister) { + super.registerIcons(par1IconRegister); + willIcon = IconHelper.forName(par1IconRegister, "willFlame"); + } + + @Override + public void onArmorTick(World world, EntityPlayer player, ItemStack stack) { + super.onArmorTick(world, player, stack); + if (hasArmorSet(player)) { + int food = player.getFoodStats().getFoodLevel(); + if (food > 0 && food < 18 && player.shouldHeal() && player.ticksExisted % 80 == 0) player.heal(1F); + ManaItemHandler.dispatchManaExact(stack, player, 1, true); + } + } + + @Override + public float getDiscount(ItemStack stack, int slot, EntityPlayer player) { + return hasArmorSet(player) ? 0.2F : 0F; + } + + @Override + public void addAncientWill(ItemStack stack, int will) { + ItemNBTHelper.setBoolean(stack, TAG_ANCIENT_WILL + will, true); + } + + @Override + public boolean hasAncientWill(ItemStack stack, int will) { + return hasAncientWill_(stack, will); + } + + public static boolean hasAncientWill_(ItemStack stack, int will) { + return ItemNBTHelper.getBoolean(stack, TAG_ANCIENT_WILL + will, false); + } + + @Override + @SideOnly(Side.CLIENT) + public void addArmorSetDescription(ItemStack stack, List list) { + super.addArmorSetDescription(stack, list); + for (int i = 0; i < 6; i++) + if (hasAncientWill(stack, i)) + addStringToTooltip(StatCollector.translateToLocal("botania.armorset.will" + i + ".desc"), list); + } + + public static boolean hasAnyWill(ItemStack stack) { + for (int i = 0; i < 6; i++) if (hasAncientWill_(stack, i)) return true; + + return false; + } + + @SideOnly(Side.CLIENT) + public static void renderOnPlayer(ItemStack stack, RenderPlayerEvent event) { + if (hasAnyWill(stack) && !((ItemTerrasteelArmor) stack.getItem()).hasPhantomInk(stack)) { + GL11.glPushMatrix(); + float f = willIcon.getMinU(); + float f1 = willIcon.getMaxU(); + float f2 = willIcon.getMinV(); + float f3 = willIcon.getMaxV(); + Helper.translateToHeadLevel(event.entityPlayer); + Minecraft.getMinecraft().renderEngine.bindTexture(TextureMap.locationItemsTexture); + GL11.glRotatef(90F, 0F, 1F, 0F); + GL11.glRotatef(180F, 1F, 0F, 0F); + GL11.glTranslatef(-0.26F, 0.15F, -0.39F); + GL11.glScalef(0.5F, 0.5F, 0.5F); + ItemRenderer.renderItemIn2D( + Tessellator.instance, f1, f2, f, f3, willIcon.getIconWidth(), willIcon.getIconHeight(), 1F / 16F); + GL11.glPopMatrix(); + } + } + + @SubscribeEvent + public void onEntityAttacked(LivingHurtEvent event) { + Entity attacker = event.source.getEntity(); + if (attacker instanceof EntityPlayer) { + EntityPlayer player = (EntityPlayer) attacker; + if (hasArmorSet(player)) { + boolean crit = player.fallDistance > 0.0F + && !player.onGround + && !player.isOnLadder() + && !player.isInWater() + && !player.isPotionActive(Potion.blindness) + && player.ridingEntity == null; + ItemStack stack = player.inventory.armorItemInSlot(3); + if (crit && stack != null && stack.getItem() instanceof ItemTerrasteelHelm) { + boolean ahrim = hasAncientWill(stack, 0); + boolean dharok = hasAncientWill(stack, 1); + boolean guthan = hasAncientWill(stack, 2); + boolean torag = hasAncientWill(stack, 3); + boolean verac = hasAncientWill(stack, 4); + boolean karil = hasAncientWill(stack, 5); + + if (ahrim) event.entityLiving.addPotionEffect(new PotionEffect(Potion.weakness.id, 20, 1)); + if (dharok) event.ammount *= 1F + (1F - player.getHealth() / player.getMaxHealth()) * 0.5F; + if (guthan) player.heal(event.ammount * 0.25F); + if (torag) event.entityLiving.addPotionEffect(new PotionEffect(Potion.moveSlowdown.id, 60, 1)); + if (verac) event.source.setDamageBypassesArmor(); + if (karil) event.entityLiving.addPotionEffect(new PotionEffect(Potion.wither.id, 60, 1)); + } + } + } + } } diff --git a/src/main/java/vazkii/botania/common/item/equipment/armor/terrasteel/ItemTerrasteelLegs.java b/src/main/java/vazkii/botania/common/item/equipment/armor/terrasteel/ItemTerrasteelLegs.java index 536819909b..030c13be03 100644 --- a/src/main/java/vazkii/botania/common/item/equipment/armor/terrasteel/ItemTerrasteelLegs.java +++ b/src/main/java/vazkii/botania/common/item/equipment/armor/terrasteel/ItemTerrasteelLegs.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Apr 14, 2014, 3:13:49 PM (GMT)] */ package vazkii.botania.common.item.equipment.armor.terrasteel; @@ -14,8 +14,7 @@ public class ItemTerrasteelLegs extends ItemTerrasteelArmor { - public ItemTerrasteelLegs() { - super(2, LibItemNames.TERRASTEEL_LEGS); - } - + public ItemTerrasteelLegs() { + super(2, LibItemNames.TERRASTEEL_LEGS); + } } diff --git a/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemAuraRing.java b/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemAuraRing.java index 6365a3bccf..7c52285a39 100644 --- a/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemAuraRing.java +++ b/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemAuraRing.java @@ -2,46 +2,45 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Apr 24, 2014, 4:43:47 PM (GMT)] */ package vazkii.botania.common.item.equipment.bauble; +import baubles.api.BaubleType; import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; import vazkii.botania.api.mana.IManaGivingItem; import vazkii.botania.api.mana.ManaItemHandler; import vazkii.botania.common.lib.LibItemNames; -import baubles.api.BaubleType; public class ItemAuraRing extends ItemBauble implements IManaGivingItem { - public ItemAuraRing(String name) { - super(name); - } - - public ItemAuraRing() { - this(LibItemNames.AURA_RING); - } - - @Override - public void onWornTick(ItemStack stack, EntityLivingBase player) { - super.onWornTick(stack, player); - if(player instanceof EntityPlayer && player.ticksExisted % getDelay() == 0) - ManaItemHandler.dispatchManaExact(stack, (EntityPlayer) player, 1, true); - } - - int getDelay() { - return 10; - } - - @Override - public BaubleType getBaubleType(ItemStack itemstack) { - return BaubleType.RING; - } - + public ItemAuraRing(String name) { + super(name); + } + + public ItemAuraRing() { + this(LibItemNames.AURA_RING); + } + + @Override + public void onWornTick(ItemStack stack, EntityLivingBase player) { + super.onWornTick(stack, player); + if (player instanceof EntityPlayer && player.ticksExisted % getDelay() == 0) + ManaItemHandler.dispatchManaExact(stack, (EntityPlayer) player, 1, true); + } + + int getDelay() { + return 10; + } + + @Override + public BaubleType getBaubleType(ItemStack itemstack) { + return BaubleType.RING; + } } diff --git a/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemBauble.java b/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemBauble.java index f8d75a8912..c645e5e3b3 100644 --- a/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemBauble.java +++ b/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemBauble.java @@ -10,9 +10,15 @@ */ package vazkii.botania.common.item.equipment.bauble; +import baubles.api.BaubleType; +import baubles.api.IBauble; +import baubles.common.container.InventoryBaubles; +import baubles.common.lib.PlayerHandler; +import cpw.mods.fml.common.Optional; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; import java.util.List; import java.util.UUID; - import net.minecraft.client.gui.GuiScreen; import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.player.EntityPlayer; @@ -27,194 +33,189 @@ import vazkii.botania.common.core.helper.ItemNBTHelper; import vazkii.botania.common.entity.EntityDoppleganger; import vazkii.botania.common.item.ItemMod; -import baubles.api.BaubleType; -import baubles.api.IBauble; -import baubles.common.container.InventoryBaubles; -import baubles.common.lib.PlayerHandler; -import cpw.mods.fml.common.Optional; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; @Optional.Interface(modid = "Thaumcraft", iface = "thaumcraft.api.IRunicArmor") public abstract class ItemBauble extends ItemMod implements IBauble, ICosmeticAttachable, IPhantomInkable, IRunicArmor { - private static final String TAG_HASHCODE = "playerHashcode"; - private static final String TAG_BAUBLE_UUID_MOST = "baubleUUIDMost"; - private static final String TAG_BAUBLE_UUID_LEAST = "baubleUUIDLeast"; - private static final String TAG_COSMETIC_ITEM = "cosmeticItem"; - private static final String TAG_PHANTOM_INK = "phantomInk"; - - public ItemBauble(String name) { - super(); - setMaxStackSize(1); - setUnlocalizedName(name); - } - - @Override - public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer) { - if(!EntityDoppleganger.isTruePlayer(par3EntityPlayer)) - return par1ItemStack; - - if(canEquip(par1ItemStack, par3EntityPlayer)) { - InventoryBaubles baubles = PlayerHandler.getPlayerBaubles(par3EntityPlayer); - for(int i = 0; i < baubles.getSizeInventory(); i++) { - if(baubles.isItemValidForSlot(i, par1ItemStack)) { - ItemStack stackInSlot = baubles.getStackInSlot(i); - if(stackInSlot == null || ((IBauble) stackInSlot.getItem()).canUnequip(stackInSlot, par3EntityPlayer)) { - if(!par2World.isRemote) { - baubles.setInventorySlotContents(i, par1ItemStack.copy()); - if(!par3EntityPlayer.capabilities.isCreativeMode) - par3EntityPlayer.inventory.setInventorySlotContents(par3EntityPlayer.inventory.currentItem, null); - } - - if(stackInSlot != null) { - ((IBauble) stackInSlot.getItem()).onUnequipped(stackInSlot, par3EntityPlayer); - return stackInSlot.copy(); - } - break; - } - } - } - } - - return par1ItemStack; - } - - @Override - @SideOnly(Side.CLIENT) - public void addInformation(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, List par3List, boolean par4) { - if(GuiScreen.isShiftKeyDown()) - addHiddenTooltip(par1ItemStack, par2EntityPlayer, par3List, par4); - else addStringToTooltip(StatCollector.translateToLocal("botaniamisc.shiftinfo"), par3List); - } - - public void addHiddenTooltip(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, List par3List, boolean par4) { - BaubleType type = getBaubleType(par1ItemStack); - addStringToTooltip(StatCollector.translateToLocal("botania.baubletype." + type.name().toLowerCase()), par3List); - - String key = vazkii.botania.client.core.helper.RenderHelper.getKeyDisplayString("Baubles Inventory"); - - if(key != null) - addStringToTooltip(StatCollector.translateToLocal("botania.baubletooltip").replaceAll("%key%", key), par3List); - - ItemStack cosmetic = getCosmeticItem(par1ItemStack); - if(cosmetic != null) - addStringToTooltip(String.format(StatCollector.translateToLocal("botaniamisc.hasCosmetic"), cosmetic.getDisplayName()), par3List); - - if(hasPhantomInk(par1ItemStack)) - addStringToTooltip(StatCollector.translateToLocal("botaniamisc.hasPhantomInk"), par3List); - } - - void addStringToTooltip(String s, List tooltip) { - tooltip.add(s.replaceAll("&", "\u00a7")); - } - - @Override - public boolean canEquip(ItemStack stack, EntityLivingBase player) { - return true; - } - - @Override - public boolean canUnequip(ItemStack stack, EntityLivingBase player) { - return true; - } - - @Override - public void onWornTick(ItemStack stack, EntityLivingBase player) { - if(getLastPlayerHashcode(stack) != player.hashCode()) { - onEquippedOrLoadedIntoWorld(stack, player); - setLastPlayerHashcode(stack, player.hashCode()); - } - } - - @Override - public void onEquipped(ItemStack stack, EntityLivingBase player) { - if(player != null) { - if(!player.worldObj.isRemote) - player.worldObj.playSoundAtEntity(player, "botania:equipBauble", 0.1F, 1.3F); - - if(player instanceof EntityPlayer) - ((EntityPlayer) player).addStat(ModAchievements.baubleWear, 1); - - onEquippedOrLoadedIntoWorld(stack, player); - setLastPlayerHashcode(stack, player.hashCode()); - } - } - - public void onEquippedOrLoadedIntoWorld(ItemStack stack, EntityLivingBase player) { - // NO-OP - } - - @Override - public void onUnequipped(ItemStack stack, EntityLivingBase player) { - // NO-OP - } - - @Override - public ItemStack getCosmeticItem(ItemStack stack) { - NBTTagCompound cmp = ItemNBTHelper.getCompound(stack, TAG_COSMETIC_ITEM, true); - if(cmp == null) - return null; - return ItemStack.loadItemStackFromNBT(cmp); - } - - @Override - public void setCosmeticItem(ItemStack stack, ItemStack cosmetic) { - NBTTagCompound cmp = new NBTTagCompound(); - if(cosmetic != null) - cosmetic.writeToNBT(cmp); - ItemNBTHelper.setCompound(stack, TAG_COSMETIC_ITEM, cmp); - } - - @Override - public boolean hasContainerItem(ItemStack stack) { - return getContainerItem(stack) != null; - } - - @Override - public ItemStack getContainerItem(ItemStack itemStack) { - return getCosmeticItem(itemStack); - } - - @Override - public boolean doesContainerItemLeaveCraftingGrid(ItemStack p_77630_1_) { - return false; - } - - public static UUID getBaubleUUID(ItemStack stack) { - long most = ItemNBTHelper.getLong(stack, TAG_BAUBLE_UUID_MOST, 0); - if(most == 0) { - UUID uuid = UUID.randomUUID(); - ItemNBTHelper.setLong(stack, TAG_BAUBLE_UUID_MOST, uuid.getMostSignificantBits()); - ItemNBTHelper.setLong(stack, TAG_BAUBLE_UUID_LEAST, uuid.getLeastSignificantBits()); - return getBaubleUUID(stack); - } - - long least = ItemNBTHelper.getLong(stack, TAG_BAUBLE_UUID_LEAST, 0); - return new UUID(most, least); - } - - public static int getLastPlayerHashcode(ItemStack stack) { - return ItemNBTHelper.getInt(stack, TAG_HASHCODE, 0); - } - - public static void setLastPlayerHashcode(ItemStack stack, int hash) { - ItemNBTHelper.setInt(stack, TAG_HASHCODE, hash); - } - - @Override - public boolean hasPhantomInk(ItemStack stack) { - return ItemNBTHelper.getBoolean(stack, TAG_PHANTOM_INK, false); - } - - @Override - public void setPhantomInk(ItemStack stack, boolean ink) { - ItemNBTHelper.setBoolean(stack, TAG_PHANTOM_INK, ink); - } - - @Override - @Optional.Method(modid = "Thaumcraft") - public int getRunicCharge(ItemStack itemstack) { - return 0; - } + private static final String TAG_HASHCODE = "playerHashcode"; + private static final String TAG_BAUBLE_UUID_MOST = "baubleUUIDMost"; + private static final String TAG_BAUBLE_UUID_LEAST = "baubleUUIDLeast"; + private static final String TAG_COSMETIC_ITEM = "cosmeticItem"; + private static final String TAG_PHANTOM_INK = "phantomInk"; + + public ItemBauble(String name) { + super(); + setMaxStackSize(1); + setUnlocalizedName(name); + } + + @Override + public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer) { + if (!EntityDoppleganger.isTruePlayer(par3EntityPlayer)) return par1ItemStack; + + if (canEquip(par1ItemStack, par3EntityPlayer)) { + InventoryBaubles baubles = PlayerHandler.getPlayerBaubles(par3EntityPlayer); + for (int i = 0; i < baubles.getSizeInventory(); i++) { + if (baubles.isItemValidForSlot(i, par1ItemStack)) { + ItemStack stackInSlot = baubles.getStackInSlot(i); + if (stackInSlot == null + || ((IBauble) stackInSlot.getItem()).canUnequip(stackInSlot, par3EntityPlayer)) { + if (!par2World.isRemote) { + baubles.setInventorySlotContents(i, par1ItemStack.copy()); + if (!par3EntityPlayer.capabilities.isCreativeMode) + par3EntityPlayer.inventory.setInventorySlotContents( + par3EntityPlayer.inventory.currentItem, null); + } + + if (stackInSlot != null) { + ((IBauble) stackInSlot.getItem()).onUnequipped(stackInSlot, par3EntityPlayer); + return stackInSlot.copy(); + } + break; + } + } + } + } + + return par1ItemStack; + } + + @Override + @SideOnly(Side.CLIENT) + public void addInformation(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, List par3List, boolean par4) { + if (GuiScreen.isShiftKeyDown()) addHiddenTooltip(par1ItemStack, par2EntityPlayer, par3List, par4); + else addStringToTooltip(StatCollector.translateToLocal("botaniamisc.shiftinfo"), par3List); + } + + public void addHiddenTooltip(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, List par3List, boolean par4) { + BaubleType type = getBaubleType(par1ItemStack); + addStringToTooltip( + StatCollector.translateToLocal( + "botania.baubletype." + type.name().toLowerCase()), + par3List); + + String key = vazkii.botania.client.core.helper.RenderHelper.getKeyDisplayString("Baubles Inventory"); + + if (key != null) + addStringToTooltip( + StatCollector.translateToLocal("botania.baubletooltip").replaceAll("%key%", key), par3List); + + ItemStack cosmetic = getCosmeticItem(par1ItemStack); + if (cosmetic != null) + addStringToTooltip( + String.format(StatCollector.translateToLocal("botaniamisc.hasCosmetic"), cosmetic.getDisplayName()), + par3List); + + if (hasPhantomInk(par1ItemStack)) + addStringToTooltip(StatCollector.translateToLocal("botaniamisc.hasPhantomInk"), par3List); + } + + void addStringToTooltip(String s, List tooltip) { + tooltip.add(s.replaceAll("&", "\u00a7")); + } + + @Override + public boolean canEquip(ItemStack stack, EntityLivingBase player) { + return true; + } + + @Override + public boolean canUnequip(ItemStack stack, EntityLivingBase player) { + return true; + } + + @Override + public void onWornTick(ItemStack stack, EntityLivingBase player) { + if (getLastPlayerHashcode(stack) != player.hashCode()) { + onEquippedOrLoadedIntoWorld(stack, player); + setLastPlayerHashcode(stack, player.hashCode()); + } + } + + @Override + public void onEquipped(ItemStack stack, EntityLivingBase player) { + if (player != null) { + if (!player.worldObj.isRemote) player.worldObj.playSoundAtEntity(player, "botania:equipBauble", 0.1F, 1.3F); + + if (player instanceof EntityPlayer) ((EntityPlayer) player).addStat(ModAchievements.baubleWear, 1); + + onEquippedOrLoadedIntoWorld(stack, player); + setLastPlayerHashcode(stack, player.hashCode()); + } + } + + public void onEquippedOrLoadedIntoWorld(ItemStack stack, EntityLivingBase player) { + // NO-OP + } + + @Override + public void onUnequipped(ItemStack stack, EntityLivingBase player) { + // NO-OP + } + + @Override + public ItemStack getCosmeticItem(ItemStack stack) { + NBTTagCompound cmp = ItemNBTHelper.getCompound(stack, TAG_COSMETIC_ITEM, true); + if (cmp == null) return null; + return ItemStack.loadItemStackFromNBT(cmp); + } + + @Override + public void setCosmeticItem(ItemStack stack, ItemStack cosmetic) { + NBTTagCompound cmp = new NBTTagCompound(); + if (cosmetic != null) cosmetic.writeToNBT(cmp); + ItemNBTHelper.setCompound(stack, TAG_COSMETIC_ITEM, cmp); + } + + @Override + public boolean hasContainerItem(ItemStack stack) { + return getContainerItem(stack) != null; + } + + @Override + public ItemStack getContainerItem(ItemStack itemStack) { + return getCosmeticItem(itemStack); + } + + @Override + public boolean doesContainerItemLeaveCraftingGrid(ItemStack p_77630_1_) { + return false; + } + + public static UUID getBaubleUUID(ItemStack stack) { + long most = ItemNBTHelper.getLong(stack, TAG_BAUBLE_UUID_MOST, 0); + if (most == 0) { + UUID uuid = UUID.randomUUID(); + ItemNBTHelper.setLong(stack, TAG_BAUBLE_UUID_MOST, uuid.getMostSignificantBits()); + ItemNBTHelper.setLong(stack, TAG_BAUBLE_UUID_LEAST, uuid.getLeastSignificantBits()); + return getBaubleUUID(stack); + } + + long least = ItemNBTHelper.getLong(stack, TAG_BAUBLE_UUID_LEAST, 0); + return new UUID(most, least); + } + + public static int getLastPlayerHashcode(ItemStack stack) { + return ItemNBTHelper.getInt(stack, TAG_HASHCODE, 0); + } + + public static void setLastPlayerHashcode(ItemStack stack, int hash) { + ItemNBTHelper.setInt(stack, TAG_HASHCODE, hash); + } + + @Override + public boolean hasPhantomInk(ItemStack stack) { + return ItemNBTHelper.getBoolean(stack, TAG_PHANTOM_INK, false); + } + + @Override + public void setPhantomInk(ItemStack stack, boolean ink) { + ItemNBTHelper.setBoolean(stack, TAG_PHANTOM_INK, ink); + } + + @Override + @Optional.Method(modid = "Thaumcraft") + public int getRunicCharge(ItemStack itemstack) { + return 0; + } } diff --git a/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemBaubleCosmetic.java b/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemBaubleCosmetic.java index 6cf98d16b1..368228babb 100644 --- a/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemBaubleCosmetic.java +++ b/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemBaubleCosmetic.java @@ -2,16 +2,17 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Feb 22, 2015, 2:01:01 PM (GMT)] */ package vazkii.botania.common.item.equipment.bauble; +import baubles.api.BaubleType; +import cpw.mods.fml.common.registry.GameRegistry; import java.util.List; - import net.minecraft.client.Minecraft; import net.minecraft.client.renderer.ItemRenderer; import net.minecraft.client.renderer.Tessellator; @@ -26,316 +27,311 @@ import net.minecraftforge.client.event.RenderPlayerEvent; import net.minecraftforge.oredict.RecipeSorter; import net.minecraftforge.oredict.RecipeSorter.Category; - import org.lwjgl.opengl.GL11; - import vazkii.botania.api.item.ICosmeticBauble; import vazkii.botania.client.core.helper.IconHelper; import vazkii.botania.common.crafting.recipe.CosmeticAttachRecipe; import vazkii.botania.common.crafting.recipe.CosmeticRemoveRecipe; import vazkii.botania.common.lib.LibItemNames; -import baubles.api.BaubleType; -import cpw.mods.fml.common.registry.GameRegistry; public class ItemBaubleCosmetic extends ItemBauble implements ICosmeticBauble { - private static final int SUBTYPES = 32; - IIcon[] icons; + private static final int SUBTYPES = 32; + IIcon[] icons; - public ItemBaubleCosmetic() { - super(LibItemNames.COSMETIC); - setHasSubtypes(true); + public ItemBaubleCosmetic() { + super(LibItemNames.COSMETIC); + setHasSubtypes(true); - GameRegistry.addRecipe(new CosmeticAttachRecipe()); - GameRegistry.addRecipe(new CosmeticRemoveRecipe()); - RecipeSorter.register("botania:cosmeticAttach", CosmeticAttachRecipe.class, Category.SHAPELESS, ""); - RecipeSorter.register("botania:cosmeticRemove", CosmeticRemoveRecipe.class, Category.SHAPELESS, ""); - } + GameRegistry.addRecipe(new CosmeticAttachRecipe()); + GameRegistry.addRecipe(new CosmeticRemoveRecipe()); + RecipeSorter.register("botania:cosmeticAttach", CosmeticAttachRecipe.class, Category.SHAPELESS, ""); + RecipeSorter.register("botania:cosmeticRemove", CosmeticRemoveRecipe.class, Category.SHAPELESS, ""); + } - @Override - public void registerIcons(IIconRegister par1IconRegister) { - icons = new IIcon[SUBTYPES]; - for(int i = 0; i < SUBTYPES; i++) - icons[i] = IconHelper.forItem(par1IconRegister, this, i); - } + @Override + public void registerIcons(IIconRegister par1IconRegister) { + icons = new IIcon[SUBTYPES]; + for (int i = 0; i < SUBTYPES; i++) icons[i] = IconHelper.forItem(par1IconRegister, this, i); + } - @Override - public void getSubItems(Item item, CreativeTabs tab, List list) { - for(int i = 0; i < SUBTYPES; i++) - list.add(new ItemStack(item, 1, i)); - } + @Override + public void getSubItems(Item item, CreativeTabs tab, List list) { + for (int i = 0; i < SUBTYPES; i++) list.add(new ItemStack(item, 1, i)); + } - @Override - public IIcon getIconFromDamage(int dmg) { - return icons[Math.min(SUBTYPES - 1, dmg)]; - } + @Override + public IIcon getIconFromDamage(int dmg) { + return icons[Math.min(SUBTYPES - 1, dmg)]; + } - @Override - public String getUnlocalizedName(ItemStack par1ItemStack) { - return super.getUnlocalizedName(par1ItemStack) + par1ItemStack.getItemDamage(); - } + @Override + public String getUnlocalizedName(ItemStack par1ItemStack) { + return super.getUnlocalizedName(par1ItemStack) + par1ItemStack.getItemDamage(); + } - @Override - public void addHiddenTooltip(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, List par3List, boolean par4) { - addStringToTooltip(StatCollector.translateToLocal("botaniamisc.cosmeticBauble"), par3List); - super.addHiddenTooltip(par1ItemStack, par2EntityPlayer, par3List, par4); - } + @Override + public void addHiddenTooltip(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, List par3List, boolean par4) { + addStringToTooltip(StatCollector.translateToLocal("botaniamisc.cosmeticBauble"), par3List); + super.addHiddenTooltip(par1ItemStack, par2EntityPlayer, par3List, par4); + } - @Override - public BaubleType getBaubleType(ItemStack arg0) { - return BaubleType.AMULET; - } + @Override + public BaubleType getBaubleType(ItemStack arg0) { + return BaubleType.AMULET; + } - @Override - public void onPlayerBaubleRender(ItemStack stack, RenderPlayerEvent event, RenderType type) { - Minecraft.getMinecraft().renderEngine.bindTexture(TextureMap.locationItemsTexture); - if(type == RenderType.HEAD) { - Helper.translateToHeadLevel(event.entityPlayer); - switch(stack.getItemDamage()) { - case 2: - faceTranslate(); - scale(0.75F); - GL11.glTranslatef(0.04F, -0.5F, 0F); - renderIcon(2); - break; - case 4: - faceTranslate(); - scale(0.75F); - GL11.glTranslatef(0.04F, -0.5F, 0F); - renderIcon(4); - break; - case 5: - faceTranslate(); - scale(0.35F); - GL11.glTranslatef(0.3F, -0.5F, 0F); - renderIcon(5); - break; - case 6: - faceTranslate(); - scale(0.35F); - GL11.glTranslatef(0.9F, -0.5F, 0F); - renderIcon(6); - break; - case 7: - faceTranslate(); - scale(0.6F); - GL11.glTranslatef(0.2F, 0.3F, 0.6F); - renderIcon(7); - break; - case 8: - faceTranslate(); - GL11.glRotatef(90F, 0F, 1F, 0F); - scale(0.6F); - GL11.glTranslatef(-0.9F, 0F, 0.2F); - renderIcon(8); - break; - case 9: - faceTranslate(); - GL11.glRotatef(90F, 0F, 1F, 0F); - scale(0.6F); - GL11.glTranslatef(-0.9F, -0.2F, 0.2F); - renderIcon(9); - GL11.glTranslatef(0F, 0F, 1F); - renderIcon(9); - break; - case 10: - faceTranslate(); - GL11.glRotatef(90F, 0F, 1F, 0F); - scale(0.4F); - GL11.glTranslatef(-0.5F, -0.1F, 0.3F); - GL11.glRotatef(120F, 0F, 1F, 0F); - renderIcon(10); - GL11.glRotatef(-100F, 0F, 1F, 0F); - renderIcon(10); - break; - case 11: - faceTranslate(); - scale(0.6F); - GL11.glTranslatef(0.2F, -0.1F, 0.6F); - renderIcon(11); - break; - case 15: - faceTranslate(); - GL11.glTranslatef(-0.1F, -0.55F, 0F); - renderIcon(15); - break; - case 17: - faceTranslate(); - scale(0.35F); - GL11.glTranslatef(0.3F, -0.6F, 0F); - renderIcon(17); - break; - case 18: - faceTranslate(); - scale(0.75F); - GL11.glRotatef(90F, 0F, 1F, 0F); - GL11.glTranslatef(-0.3F, 0.1F, 0.55F); - renderIcon(18); - break; - case 19: - faceTranslate(); - scale(0.6F); - GL11.glTranslatef(0.2F, -0.2F, 0.1F); - renderIcon(19); - break; - case 20: - faceTranslate(); - scale(0.25F); - GL11.glTranslatef(0.4F, 0.5F, -0.1F); - renderIcon(20); - GL11.glTranslatef(1.4F, 0F, 0F); - renderIcon(20); - break; - case 22: - faceTranslate(); - scale(0.75F); - GL11.glTranslatef(0.04F, -0.4F, 0F); - renderIcon(22); - break; - case 23: - faceTranslate(); - scale(0.75F); - GL11.glTranslatef(0.04F, -0.4F, 0F); - renderIcon(23); - break; - case 24: - faceTranslate(); - scale(0.6F); - GL11.glTranslatef(0.5F, 0F, 0.1F); - GL11.glRotatef(60F, 0F, 0F, 1F); - renderIcon(24); - break; - case 25: - faceTranslate(); - scale(0.75F); - GL11.glTranslatef(0.04F, -0.5F, 0F); - renderIcon(25); - break; - case 26: - faceTranslate(); - GL11.glTranslatef(-0.1F, -0.4F, 0F); - GL11.glEnable(GL11.GL_BLEND); - GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); - GL11.glColor4f(1F, 1F, 1F, 0.7F); - renderIcon(26); - break; - case 27: - faceTranslate(); - scale(0.75F); - GL11.glTranslatef(0.04F, -0.65F, 0F); - renderIcon(27); - break; - case 28: - faceTranslate(); - scale(0.25F); - GL11.glTranslatef(1.55F, -0.2F, -0.1F); - renderIcon(28); - GL11.glRotatef(180F, 0F, 1F, 0F); - GL11.glTranslatef(-0.1F, 0F, 0.1F); - renderIcon(28); - break; - case 30: - faceTranslate(); - scale(0.75F); - GL11.glTranslatef(0.04F, -0.4F, 0F); - renderIcon(30); - break; - case 31: - faceTranslate(); - scale(0.5F); - GL11.glTranslatef(0.3F, 0.7F, 0.5F); - renderIcon(31); - break; - } - } else { - Helper.rotateIfSneaking(event.entityPlayer); - switch(stack.getItemDamage()) { - case 0: - chestTranslate(); - scale(0.5F); - GL11.glTranslatef(0.5F, 0.7F, 0F); - renderIcon(0); - break; - case 1: - chestTranslate(); - scale(0.75F); - GL11.glTranslatef(0.15F, -0.1F, 0F); - renderIcon(1); - break; - case 3: - chestTranslate(); - scale(0.6F); - GL11.glTranslatef(0.35F, 0.3F, 0F); - renderIcon(3); - break; - case 12: - chestTranslate(); - scale(0.225F); - GL11.glTranslatef(1.2F, 1.9F, 0F); - renderIcon(12); - break; - case 13: - chestTranslate(); - GL11.glRotatef(-90F, 0F, 1F, 0F); - scale(0.5F); - GL11.glTranslatef(-1.3F, -0.4F, -1F); - renderIcon(13); - break; - case 14: - chestTranslate(); - scale(0.5F); - GL11.glTranslatef(2.3F, 1F, -0.05F); - GL11.glRotatef(180F, 0F, 1F, 0F); - renderIcon(14); - GL11.glRotatef(180F, 0F, 1F, 0F); - GL11.glColor4f(0F, 0F, 0.3F, 1F); - GL11.glTranslatef(-2.6F, 0F, 0.05F); - renderIcon(14); - break; - case 16: - chestTranslate(); - scale(0.225F); - GL11.glTranslatef(2.3F, 1.9F, 0F); - renderIcon(16); - break; - case 21: - chestTranslate(); - scale(0.3F); - GL11.glTranslatef(1.2F, 0.5F, 0F); - renderIcon(21); - break; - case 29: - chestTranslate(); - scale(0.8F); - GL11.glTranslatef(0.2F, -0.2F, -0.35F); - GL11.glRotatef(10F, 0F, 0F, 1F); - renderIcon(29); - break; - } - } - } + @Override + public void onPlayerBaubleRender(ItemStack stack, RenderPlayerEvent event, RenderType type) { + Minecraft.getMinecraft().renderEngine.bindTexture(TextureMap.locationItemsTexture); + if (type == RenderType.HEAD) { + Helper.translateToHeadLevel(event.entityPlayer); + switch (stack.getItemDamage()) { + case 2: + faceTranslate(); + scale(0.75F); + GL11.glTranslatef(0.04F, -0.5F, 0F); + renderIcon(2); + break; + case 4: + faceTranslate(); + scale(0.75F); + GL11.glTranslatef(0.04F, -0.5F, 0F); + renderIcon(4); + break; + case 5: + faceTranslate(); + scale(0.35F); + GL11.glTranslatef(0.3F, -0.5F, 0F); + renderIcon(5); + break; + case 6: + faceTranslate(); + scale(0.35F); + GL11.glTranslatef(0.9F, -0.5F, 0F); + renderIcon(6); + break; + case 7: + faceTranslate(); + scale(0.6F); + GL11.glTranslatef(0.2F, 0.3F, 0.6F); + renderIcon(7); + break; + case 8: + faceTranslate(); + GL11.glRotatef(90F, 0F, 1F, 0F); + scale(0.6F); + GL11.glTranslatef(-0.9F, 0F, 0.2F); + renderIcon(8); + break; + case 9: + faceTranslate(); + GL11.glRotatef(90F, 0F, 1F, 0F); + scale(0.6F); + GL11.glTranslatef(-0.9F, -0.2F, 0.2F); + renderIcon(9); + GL11.glTranslatef(0F, 0F, 1F); + renderIcon(9); + break; + case 10: + faceTranslate(); + GL11.glRotatef(90F, 0F, 1F, 0F); + scale(0.4F); + GL11.glTranslatef(-0.5F, -0.1F, 0.3F); + GL11.glRotatef(120F, 0F, 1F, 0F); + renderIcon(10); + GL11.glRotatef(-100F, 0F, 1F, 0F); + renderIcon(10); + break; + case 11: + faceTranslate(); + scale(0.6F); + GL11.glTranslatef(0.2F, -0.1F, 0.6F); + renderIcon(11); + break; + case 15: + faceTranslate(); + GL11.glTranslatef(-0.1F, -0.55F, 0F); + renderIcon(15); + break; + case 17: + faceTranslate(); + scale(0.35F); + GL11.glTranslatef(0.3F, -0.6F, 0F); + renderIcon(17); + break; + case 18: + faceTranslate(); + scale(0.75F); + GL11.glRotatef(90F, 0F, 1F, 0F); + GL11.glTranslatef(-0.3F, 0.1F, 0.55F); + renderIcon(18); + break; + case 19: + faceTranslate(); + scale(0.6F); + GL11.glTranslatef(0.2F, -0.2F, 0.1F); + renderIcon(19); + break; + case 20: + faceTranslate(); + scale(0.25F); + GL11.glTranslatef(0.4F, 0.5F, -0.1F); + renderIcon(20); + GL11.glTranslatef(1.4F, 0F, 0F); + renderIcon(20); + break; + case 22: + faceTranslate(); + scale(0.75F); + GL11.glTranslatef(0.04F, -0.4F, 0F); + renderIcon(22); + break; + case 23: + faceTranslate(); + scale(0.75F); + GL11.glTranslatef(0.04F, -0.4F, 0F); + renderIcon(23); + break; + case 24: + faceTranslate(); + scale(0.6F); + GL11.glTranslatef(0.5F, 0F, 0.1F); + GL11.glRotatef(60F, 0F, 0F, 1F); + renderIcon(24); + break; + case 25: + faceTranslate(); + scale(0.75F); + GL11.glTranslatef(0.04F, -0.5F, 0F); + renderIcon(25); + break; + case 26: + faceTranslate(); + GL11.glTranslatef(-0.1F, -0.4F, 0F); + GL11.glEnable(GL11.GL_BLEND); + GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); + GL11.glColor4f(1F, 1F, 1F, 0.7F); + renderIcon(26); + break; + case 27: + faceTranslate(); + scale(0.75F); + GL11.glTranslatef(0.04F, -0.65F, 0F); + renderIcon(27); + break; + case 28: + faceTranslate(); + scale(0.25F); + GL11.glTranslatef(1.55F, -0.2F, -0.1F); + renderIcon(28); + GL11.glRotatef(180F, 0F, 1F, 0F); + GL11.glTranslatef(-0.1F, 0F, 0.1F); + renderIcon(28); + break; + case 30: + faceTranslate(); + scale(0.75F); + GL11.glTranslatef(0.04F, -0.4F, 0F); + renderIcon(30); + break; + case 31: + faceTranslate(); + scale(0.5F); + GL11.glTranslatef(0.3F, 0.7F, 0.5F); + renderIcon(31); + break; + } + } else { + Helper.rotateIfSneaking(event.entityPlayer); + switch (stack.getItemDamage()) { + case 0: + chestTranslate(); + scale(0.5F); + GL11.glTranslatef(0.5F, 0.7F, 0F); + renderIcon(0); + break; + case 1: + chestTranslate(); + scale(0.75F); + GL11.glTranslatef(0.15F, -0.1F, 0F); + renderIcon(1); + break; + case 3: + chestTranslate(); + scale(0.6F); + GL11.glTranslatef(0.35F, 0.3F, 0F); + renderIcon(3); + break; + case 12: + chestTranslate(); + scale(0.225F); + GL11.glTranslatef(1.2F, 1.9F, 0F); + renderIcon(12); + break; + case 13: + chestTranslate(); + GL11.glRotatef(-90F, 0F, 1F, 0F); + scale(0.5F); + GL11.glTranslatef(-1.3F, -0.4F, -1F); + renderIcon(13); + break; + case 14: + chestTranslate(); + scale(0.5F); + GL11.glTranslatef(2.3F, 1F, -0.05F); + GL11.glRotatef(180F, 0F, 1F, 0F); + renderIcon(14); + GL11.glRotatef(180F, 0F, 1F, 0F); + GL11.glColor4f(0F, 0F, 0.3F, 1F); + GL11.glTranslatef(-2.6F, 0F, 0.05F); + renderIcon(14); + break; + case 16: + chestTranslate(); + scale(0.225F); + GL11.glTranslatef(2.3F, 1.9F, 0F); + renderIcon(16); + break; + case 21: + chestTranslate(); + scale(0.3F); + GL11.glTranslatef(1.2F, 0.5F, 0F); + renderIcon(21); + break; + case 29: + chestTranslate(); + scale(0.8F); + GL11.glTranslatef(0.2F, -0.2F, -0.35F); + GL11.glRotatef(10F, 0F, 0F, 1F); + renderIcon(29); + break; + } + } + } - public void faceTranslate() { - GL11.glRotatef(90F, 0F, 1F, 0F); - GL11.glRotatef(180F, 1F, 0F, 0F); - GL11.glTranslatef(-0.4F, 0.1F, -0.25F); - } + public void faceTranslate() { + GL11.glRotatef(90F, 0F, 1F, 0F); + GL11.glRotatef(180F, 1F, 0F, 0F); + GL11.glTranslatef(-0.4F, 0.1F, -0.25F); + } - public void chestTranslate() { - GL11.glRotatef(180F, 1F, 0F, 0F); - GL11.glTranslatef(-0.5F, -0.7F, 0.15F); - } + public void chestTranslate() { + GL11.glRotatef(180F, 1F, 0F, 0F); + GL11.glTranslatef(-0.5F, -0.7F, 0.15F); + } - public void scale(float f) { - GL11.glScalef(f, f, f); - } + public void scale(float f) { + GL11.glScalef(f, f, f); + } - public void renderIcon(int i) { - IIcon icon = icons[i]; - float f = icon.getMinU(); - float f1 = icon.getMaxU(); - float f2 = icon.getMinV(); - float f3 = icon.getMaxV(); - ItemRenderer.renderItemIn2D(Tessellator.instance, f1, f2, f, f3, icon.getIconWidth(), icon.getIconHeight(), 1F / 16F); - } + public void renderIcon(int i) { + IIcon icon = icons[i]; + float f = icon.getMinU(); + float f1 = icon.getMaxU(); + float f2 = icon.getMinV(); + float f3 = icon.getMaxV(); + ItemRenderer.renderItemIn2D( + Tessellator.instance, f1, f2, f, f3, icon.getIconWidth(), icon.getIconHeight(), 1F / 16F); + } } diff --git a/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemBaubleModifier.java b/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemBaubleModifier.java index d920e453e5..b2695a1f24 100644 --- a/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemBaubleModifier.java +++ b/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemBaubleModifier.java @@ -2,43 +2,41 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Apr 26, 2014, 10:28:39 PM (GMT)] */ package vazkii.botania.common.item.equipment.bauble; +import com.google.common.collect.HashMultimap; +import com.google.common.collect.Multimap; import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.ai.attributes.AttributeModifier; import net.minecraft.item.ItemStack; -import com.google.common.collect.HashMultimap; -import com.google.common.collect.Multimap; - public abstract class ItemBaubleModifier extends ItemBauble { - Multimap attributes = HashMultimap.create(); - - public ItemBaubleModifier(String name) { - super(name); - } + Multimap attributes = HashMultimap.create(); - @Override - public void onEquippedOrLoadedIntoWorld(ItemStack stack, EntityLivingBase player) { - attributes.clear(); - fillModifiers(attributes, stack); - player.getAttributeMap().applyAttributeModifiers(attributes); - } + public ItemBaubleModifier(String name) { + super(name); + } - @Override - public void onUnequipped(ItemStack stack, EntityLivingBase player) { - attributes.clear(); - fillModifiers(attributes, stack); - player.getAttributeMap().removeAttributeModifiers(attributes); - } + @Override + public void onEquippedOrLoadedIntoWorld(ItemStack stack, EntityLivingBase player) { + attributes.clear(); + fillModifiers(attributes, stack); + player.getAttributeMap().applyAttributeModifiers(attributes); + } - abstract void fillModifiers(Multimap attributes, ItemStack stack); + @Override + public void onUnequipped(ItemStack stack, EntityLivingBase player) { + attributes.clear(); + fillModifiers(attributes, stack); + player.getAttributeMap().removeAttributeModifiers(attributes); + } + abstract void fillModifiers(Multimap attributes, ItemStack stack); } diff --git a/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemBloodPendant.java b/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemBloodPendant.java index 5a7dcd66b9..ad46339b75 100644 --- a/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemBloodPendant.java +++ b/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemBloodPendant.java @@ -2,17 +2,17 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Nov 6, 2014, 5:11:23 PM (GMT)] */ package vazkii.botania.common.item.equipment.bauble; +import baubles.api.BaubleType; import java.awt.Color; import java.util.List; - import net.minecraft.client.Minecraft; import net.minecraft.client.renderer.ItemRenderer; import net.minecraft.client.renderer.OpenGlHelper; @@ -30,9 +30,7 @@ import net.minecraft.util.IIcon; import net.minecraft.util.StatCollector; import net.minecraftforge.client.event.RenderPlayerEvent; - import org.lwjgl.opengl.GL11; - import vazkii.botania.api.BotaniaAPI; import vazkii.botania.api.brew.Brew; import vazkii.botania.api.brew.IBrewContainer; @@ -44,170 +42,180 @@ import vazkii.botania.client.core.helper.IconHelper; import vazkii.botania.common.core.helper.ItemNBTHelper; import vazkii.botania.common.lib.LibItemNames; -import baubles.api.BaubleType; public class ItemBloodPendant extends ItemBauble implements IBrewContainer, IBrewItem, IManaUsingItem, IBaubleRender { - private static final String TAG_BREW_KEY = "brewKey"; - - IIcon[] icons; - - public ItemBloodPendant() { - super(LibItemNames.BLOOD_PENDANT); - setMaxStackSize(1); - } - - @Override - public void getSubItems(Item item, CreativeTabs tab, List list) { - super.getSubItems(item, tab, list); - for(String s : BotaniaAPI.brewMap.keySet()) { - ItemStack brewStack = getItemForBrew(BotaniaAPI.brewMap.get(s), new ItemStack(this)); - if(brewStack != null) - list.add(brewStack); - } - } - - @Override - public void registerIcons(IIconRegister par1IconRegister) { - icons = new IIcon[4]; - for(int i = 0; i < 4; i++) - icons[i] = IconHelper.forItem(par1IconRegister, this, i); - } - - @Override - public boolean requiresMultipleRenderPasses() { - return true; - } - - @Override - public IIcon getIcon(ItemStack stack, int pass) { - return icons[pass]; - } - - @Override - public int getColorFromItemStack(ItemStack stack, int pass) { - if(pass == 0) - return 0xFFFFFF; - - Brew brew = getBrew(stack); - if(brew == BotaniaAPI.fallbackBrew) - return 0xC6000E; - - Color color = new Color(brew.getColor(stack)); - int add = (int) (Math.sin(ClientTickHandler.ticksInGame * 0.2) * 24); - - int r = Math.max(0, Math.min(255, color.getRed() + add)); - int g = Math.max(0, Math.min(255, color.getGreen() + add)); - int b = Math.max(0, Math.min(255, color.getBlue() + add)); - - return r << 16 | g << 8 | b; - } - - @Override - public void addHiddenTooltip(ItemStack stack, EntityPlayer player, List list, boolean adv) { - super.addHiddenTooltip(stack, player, list, adv); - - Brew brew = getBrew(stack); - if(brew == BotaniaAPI.fallbackBrew) { - addStringToTooltip(EnumChatFormatting.LIGHT_PURPLE + StatCollector.translateToLocal("botaniamisc.notInfused"), list); - return; - } - - addStringToTooltip(EnumChatFormatting.LIGHT_PURPLE + String.format(StatCollector.translateToLocal("botaniamisc.brewOf"), StatCollector.translateToLocal(brew.getUnlocalizedName(stack))), list); - for(PotionEffect effect : brew.getPotionEffects(stack)) { - Potion potion = Potion.potionTypes[effect.getPotionID()]; - EnumChatFormatting format = potion.isBadEffect() ? EnumChatFormatting.RED : EnumChatFormatting.GRAY; - addStringToTooltip(" " + format + StatCollector.translateToLocal(effect.getEffectName()) + (effect.getAmplifier() == 0 ? "" : " " + StatCollector.translateToLocal("botania.roman" + (effect.getAmplifier() + 1))), list); - } - } - - @Override - public BaubleType getBaubleType(ItemStack arg0) { - return BaubleType.AMULET; - } - - @Override - public void onWornTick(ItemStack stack, EntityLivingBase player) { - Brew brew = getBrew(stack); - if(brew != BotaniaAPI.fallbackBrew && player instanceof EntityPlayer && !player.worldObj.isRemote) { - EntityPlayer eplayer = (EntityPlayer) player; - PotionEffect effect = brew.getPotionEffects(stack).get(0); - float cost = (float) brew.getManaCost(stack) / effect.getDuration() / (1 + effect.getAmplifier()) * 2.5F; - boolean doRand = cost < 1; - if(ManaItemHandler.requestManaExact(stack, eplayer, (int) Math.ceil(cost), false)) { - PotionEffect currentEffect = player.getActivePotionEffect(Potion.potionTypes[effect.getPotionID()]); - boolean nightVision = effect.getPotionID() == Potion.nightVision.id; - if(currentEffect == null || currentEffect.getDuration() < (nightVision ? 205 : 3)) { - PotionEffect applyEffect = new PotionEffect(effect.getPotionID(), nightVision ? 285 : 80, effect.getAmplifier(), true); - player.addPotionEffect(applyEffect); - } - - if(!doRand || Math.random() < cost) - ManaItemHandler.requestManaExact(stack, eplayer, (int) Math.ceil(cost), true); - } - } - } - - @Override - public Brew getBrew(ItemStack stack) { - String key = ItemNBTHelper.getString(stack, TAG_BREW_KEY, ""); - return BotaniaAPI.getBrewFromKey(key); - } - - public static void setBrew(ItemStack stack, Brew brew) { - setBrew(stack, brew.getKey()); - } - - public static void setBrew(ItemStack stack, String brew) { - ItemNBTHelper.setString(stack, TAG_BREW_KEY, brew); - } - - @Override - public ItemStack getItemForBrew(Brew brew, ItemStack stack) { - if(!brew.canInfuseBloodPendant() || brew.getPotionEffects(stack).size() != 1 || Potion.potionTypes[brew.getPotionEffects(stack).get(0).getPotionID()].isInstant()) - return null; - - ItemStack brewStack = new ItemStack(this); - setBrew(brewStack, brew); - return brewStack; - } - - @Override - public int getManaCost(Brew brew, ItemStack stack) { - return brew.getManaCost() * 10; - } - - @Override - public boolean usesMana(ItemStack stack) { - return getBrew(stack) != BotaniaAPI.fallbackBrew; - } - - @Override - public void onPlayerBaubleRender(ItemStack stack, RenderPlayerEvent event, RenderType type) { - if(type == RenderType.BODY) { - Minecraft.getMinecraft().renderEngine.bindTexture(TextureMap.locationItemsTexture); - Helper.rotateIfSneaking(event.entityPlayer); - boolean armor = event.entityPlayer.getCurrentArmor(2) != null; - GL11.glRotatef(180F, 1F, 0F, 0F); - GL11.glTranslatef(-0.26F, -0.4F, armor ? 0.2F : 0.15F); - GL11.glScalef(0.5F, 0.5F, 0.5F); - - for(int i = 2; i < 4; i++) { - IIcon icon = icons[i]; - float f = icon.getMinU(); - float f1 = icon.getMaxU(); - float f2 = icon.getMinV(); - float f3 = icon.getMaxV(); - ItemRenderer.renderItemIn2D(Tessellator.instance, f1, f2, f, f3, icon.getIconWidth(), icon.getIconHeight(), 1F / 32F); - - Color color = new Color(getColorFromItemStack(stack, 1)); - GL11.glColor3ub((byte) color.getRed(), (byte) color.getGreen(), (byte) color.getBlue()); - int light = 15728880; - int lightmapX = light % 65536; - int lightmapY = light / 65536; - OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, lightmapX, lightmapY); - } - } - } - + private static final String TAG_BREW_KEY = "brewKey"; + + IIcon[] icons; + + public ItemBloodPendant() { + super(LibItemNames.BLOOD_PENDANT); + setMaxStackSize(1); + } + + @Override + public void getSubItems(Item item, CreativeTabs tab, List list) { + super.getSubItems(item, tab, list); + for (String s : BotaniaAPI.brewMap.keySet()) { + ItemStack brewStack = getItemForBrew(BotaniaAPI.brewMap.get(s), new ItemStack(this)); + if (brewStack != null) list.add(brewStack); + } + } + + @Override + public void registerIcons(IIconRegister par1IconRegister) { + icons = new IIcon[4]; + for (int i = 0; i < 4; i++) icons[i] = IconHelper.forItem(par1IconRegister, this, i); + } + + @Override + public boolean requiresMultipleRenderPasses() { + return true; + } + + @Override + public IIcon getIcon(ItemStack stack, int pass) { + return icons[pass]; + } + + @Override + public int getColorFromItemStack(ItemStack stack, int pass) { + if (pass == 0) return 0xFFFFFF; + + Brew brew = getBrew(stack); + if (brew == BotaniaAPI.fallbackBrew) return 0xC6000E; + + Color color = new Color(brew.getColor(stack)); + int add = (int) (Math.sin(ClientTickHandler.ticksInGame * 0.2) * 24); + + int r = Math.max(0, Math.min(255, color.getRed() + add)); + int g = Math.max(0, Math.min(255, color.getGreen() + add)); + int b = Math.max(0, Math.min(255, color.getBlue() + add)); + + return r << 16 | g << 8 | b; + } + + @Override + public void addHiddenTooltip(ItemStack stack, EntityPlayer player, List list, boolean adv) { + super.addHiddenTooltip(stack, player, list, adv); + + Brew brew = getBrew(stack); + if (brew == BotaniaAPI.fallbackBrew) { + addStringToTooltip( + EnumChatFormatting.LIGHT_PURPLE + StatCollector.translateToLocal("botaniamisc.notInfused"), list); + return; + } + + addStringToTooltip( + EnumChatFormatting.LIGHT_PURPLE + + String.format( + StatCollector.translateToLocal("botaniamisc.brewOf"), + StatCollector.translateToLocal(brew.getUnlocalizedName(stack))), + list); + for (PotionEffect effect : brew.getPotionEffects(stack)) { + Potion potion = Potion.potionTypes[effect.getPotionID()]; + EnumChatFormatting format = potion.isBadEffect() ? EnumChatFormatting.RED : EnumChatFormatting.GRAY; + addStringToTooltip( + " " + format + StatCollector.translateToLocal(effect.getEffectName()) + + (effect.getAmplifier() == 0 + ? "" + : " " + + StatCollector.translateToLocal( + "botania.roman" + (effect.getAmplifier() + 1))), + list); + } + } + + @Override + public BaubleType getBaubleType(ItemStack arg0) { + return BaubleType.AMULET; + } + + @Override + public void onWornTick(ItemStack stack, EntityLivingBase player) { + Brew brew = getBrew(stack); + if (brew != BotaniaAPI.fallbackBrew && player instanceof EntityPlayer && !player.worldObj.isRemote) { + EntityPlayer eplayer = (EntityPlayer) player; + PotionEffect effect = brew.getPotionEffects(stack).get(0); + float cost = (float) brew.getManaCost(stack) / effect.getDuration() / (1 + effect.getAmplifier()) * 2.5F; + boolean doRand = cost < 1; + if (ManaItemHandler.requestManaExact(stack, eplayer, (int) Math.ceil(cost), false)) { + PotionEffect currentEffect = player.getActivePotionEffect(Potion.potionTypes[effect.getPotionID()]); + boolean nightVision = effect.getPotionID() == Potion.nightVision.id; + if (currentEffect == null || currentEffect.getDuration() < (nightVision ? 205 : 3)) { + PotionEffect applyEffect = + new PotionEffect(effect.getPotionID(), nightVision ? 285 : 80, effect.getAmplifier(), true); + player.addPotionEffect(applyEffect); + } + + if (!doRand || Math.random() < cost) + ManaItemHandler.requestManaExact(stack, eplayer, (int) Math.ceil(cost), true); + } + } + } + + @Override + public Brew getBrew(ItemStack stack) { + String key = ItemNBTHelper.getString(stack, TAG_BREW_KEY, ""); + return BotaniaAPI.getBrewFromKey(key); + } + + public static void setBrew(ItemStack stack, Brew brew) { + setBrew(stack, brew.getKey()); + } + + public static void setBrew(ItemStack stack, String brew) { + ItemNBTHelper.setString(stack, TAG_BREW_KEY, brew); + } + + @Override + public ItemStack getItemForBrew(Brew brew, ItemStack stack) { + if (!brew.canInfuseBloodPendant() + || brew.getPotionEffects(stack).size() != 1 + || Potion.potionTypes[brew.getPotionEffects(stack).get(0).getPotionID()].isInstant()) return null; + + ItemStack brewStack = new ItemStack(this); + setBrew(brewStack, brew); + return brewStack; + } + + @Override + public int getManaCost(Brew brew, ItemStack stack) { + return brew.getManaCost() * 10; + } + + @Override + public boolean usesMana(ItemStack stack) { + return getBrew(stack) != BotaniaAPI.fallbackBrew; + } + + @Override + public void onPlayerBaubleRender(ItemStack stack, RenderPlayerEvent event, RenderType type) { + if (type == RenderType.BODY) { + Minecraft.getMinecraft().renderEngine.bindTexture(TextureMap.locationItemsTexture); + Helper.rotateIfSneaking(event.entityPlayer); + boolean armor = event.entityPlayer.getCurrentArmor(2) != null; + GL11.glRotatef(180F, 1F, 0F, 0F); + GL11.glTranslatef(-0.26F, -0.4F, armor ? 0.2F : 0.15F); + GL11.glScalef(0.5F, 0.5F, 0.5F); + + for (int i = 2; i < 4; i++) { + IIcon icon = icons[i]; + float f = icon.getMinU(); + float f1 = icon.getMaxU(); + float f2 = icon.getMinV(); + float f3 = icon.getMaxV(); + ItemRenderer.renderItemIn2D( + Tessellator.instance, f1, f2, f, f3, icon.getIconWidth(), icon.getIconHeight(), 1F / 32F); + + Color color = new Color(getColorFromItemStack(stack, 1)); + GL11.glColor3ub((byte) color.getRed(), (byte) color.getGreen(), (byte) color.getBlue()); + int light = 15728880; + int lightmapX = light % 65536; + int lightmapY = light / 65536; + OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, lightmapX, lightmapY); + } + } + } } diff --git a/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemDivaCharm.java b/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemDivaCharm.java index f0a21d180a..51df5cba15 100644 --- a/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemDivaCharm.java +++ b/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemDivaCharm.java @@ -2,16 +2,21 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [May 25, 2014, 10:30:39 PM (GMT)] */ package vazkii.botania.common.item.equipment.bauble; +import baubles.api.BaubleType; +import baubles.common.lib.PlayerHandler; +import cpw.mods.fml.common.eventhandler.SubscribeEvent; +import cpw.mods.fml.relauncher.ReflectionHelper; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; import java.util.List; - import net.minecraft.client.Minecraft; import net.minecraft.client.renderer.ItemRenderer; import net.minecraft.client.renderer.Tessellator; @@ -25,9 +30,7 @@ import net.minecraftforge.client.event.RenderPlayerEvent; import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.event.entity.living.LivingHurtEvent; - import org.lwjgl.opengl.GL11; - import vazkii.botania.api.item.IBaubleRender; import vazkii.botania.api.mana.IManaUsingItem; import vazkii.botania.api.mana.ManaItemHandler; @@ -35,82 +38,99 @@ import vazkii.botania.common.block.subtile.functional.SubTileHeiseiDream; import vazkii.botania.common.lib.LibItemNames; import vazkii.botania.common.lib.LibObfuscation; -import baubles.api.BaubleType; -import baubles.common.lib.PlayerHandler; -import cpw.mods.fml.common.eventhandler.SubscribeEvent; -import cpw.mods.fml.relauncher.ReflectionHelper; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; public class ItemDivaCharm extends ItemBauble implements IManaUsingItem, IBaubleRender { - public ItemDivaCharm() { - super(LibItemNames.DIVA_CHARM); - MinecraftForge.EVENT_BUS.register(this); - } - - @SubscribeEvent - public void onEntityDamaged(LivingHurtEvent event) { - if(event.source.getEntity() instanceof EntityPlayer && event.entityLiving instanceof EntityLiving && !event.entityLiving.worldObj.isRemote && Math.random() < 0.6F) { - EntityPlayer player = (EntityPlayer) event.source.getEntity(); - ItemStack amulet = PlayerHandler.getPlayerBaubles(player).getStackInSlot(0); - if(amulet != null && amulet.getItem() == this) { - final int cost = 250; - if(ManaItemHandler.requestManaExact(amulet, player, cost, false)) { - final int range = 20; + public ItemDivaCharm() { + super(LibItemNames.DIVA_CHARM); + MinecraftForge.EVENT_BUS.register(this); + } - List mobs = player.worldObj.getEntitiesWithinAABB(IMob.class, AxisAlignedBB.getBoundingBox(event.entity.posX - range, event.entity.posY - range, event.entity.posZ - range, event.entity.posX + range, event.entity.posY + range, event.entity.posZ + range)); - if(mobs.size() > 1) { - if(SubTileHeiseiDream.brainwashEntity((EntityLiving) event.entityLiving, mobs)) { - if(event.entityLiving instanceof EntityCreeper) - ReflectionHelper.setPrivateValue(EntityCreeper.class, (EntityCreeper) event.entityLiving, 2, LibObfuscation.TIME_SINCE_IGNITED); - event.entityLiving.heal(event.entityLiving.getMaxHealth()); - if(event.entityLiving.isDead) - event.entityLiving.isDead = false; + @SubscribeEvent + public void onEntityDamaged(LivingHurtEvent event) { + if (event.source.getEntity() instanceof EntityPlayer + && event.entityLiving instanceof EntityLiving + && !event.entityLiving.worldObj.isRemote + && Math.random() < 0.6F) { + EntityPlayer player = (EntityPlayer) event.source.getEntity(); + ItemStack amulet = PlayerHandler.getPlayerBaubles(player).getStackInSlot(0); + if (amulet != null && amulet.getItem() == this) { + final int cost = 250; + if (ManaItemHandler.requestManaExact(amulet, player, cost, false)) { + final int range = 20; - ManaItemHandler.requestManaExact(amulet, player, cost, true); - player.worldObj.playSoundAtEntity(player, "botania:divaCharm", 1F, 1F); + List mobs = player.worldObj.getEntitiesWithinAABB( + IMob.class, + AxisAlignedBB.getBoundingBox( + event.entity.posX - range, + event.entity.posY - range, + event.entity.posZ - range, + event.entity.posX + range, + event.entity.posY + range, + event.entity.posZ + range)); + if (mobs.size() > 1) { + if (SubTileHeiseiDream.brainwashEntity((EntityLiving) event.entityLiving, mobs)) { + if (event.entityLiving instanceof EntityCreeper) + ReflectionHelper.setPrivateValue( + EntityCreeper.class, + (EntityCreeper) event.entityLiving, + 2, + LibObfuscation.TIME_SINCE_IGNITED); + event.entityLiving.heal(event.entityLiving.getMaxHealth()); + if (event.entityLiving.isDead) event.entityLiving.isDead = false; - double x = event.entityLiving.posX; - double y = event.entityLiving.posY; - double z = event.entityLiving.posZ; + ManaItemHandler.requestManaExact(amulet, player, cost, true); + player.worldObj.playSoundAtEntity(player, "botania:divaCharm", 1F, 1F); - for(int i = 0; i < 50; i++) - Botania.proxy.sparkleFX(event.entityLiving.worldObj, x + Math.random() * event.entityLiving.width, y + Math.random() * event.entityLiving.height, z + Math.random() * event.entityLiving.width, 1F, 1F, 0.25F, 1F, 3); - } - } - } - } - } - } + double x = event.entityLiving.posX; + double y = event.entityLiving.posY; + double z = event.entityLiving.posZ; - @Override - public BaubleType getBaubleType(ItemStack arg0) { - return BaubleType.AMULET; - } + for (int i = 0; i < 50; i++) + Botania.proxy.sparkleFX( + event.entityLiving.worldObj, + x + Math.random() * event.entityLiving.width, + y + Math.random() * event.entityLiving.height, + z + Math.random() * event.entityLiving.width, + 1F, + 1F, + 0.25F, + 1F, + 3); + } + } + } + } + } + } - @Override - public boolean usesMana(ItemStack stack) { - return true; - } + @Override + public BaubleType getBaubleType(ItemStack arg0) { + return BaubleType.AMULET; + } - @Override - @SideOnly(Side.CLIENT) - public void onPlayerBaubleRender(ItemStack stack, RenderPlayerEvent event, RenderType type) { - if(type == RenderType.HEAD) { - float f = itemIcon.getMinU(); - float f1 = itemIcon.getMaxU(); - float f2 = itemIcon.getMinV(); - float f3 = itemIcon.getMaxV(); - boolean armor = event.entityPlayer.getCurrentArmor(3) != null; - Helper.translateToHeadLevel(event.entityPlayer); - Minecraft.getMinecraft().renderEngine.bindTexture(TextureMap.locationItemsTexture); - GL11.glRotatef(90F, 0F, 1F, 0F); - GL11.glRotatef(180F, 1F, 0F, 0F); - GL11.glTranslatef(-0.4F, 0.1F, armor ? -0.35F : -0.3F); - GL11.glScalef(0.5F, 0.5F, 0.5F); - ItemRenderer.renderItemIn2D(Tessellator.instance, f1, f2, f, f3, itemIcon.getIconWidth(), itemIcon.getIconHeight(), 1F / 16F); - } - } + @Override + public boolean usesMana(ItemStack stack) { + return true; + } + @Override + @SideOnly(Side.CLIENT) + public void onPlayerBaubleRender(ItemStack stack, RenderPlayerEvent event, RenderType type) { + if (type == RenderType.HEAD) { + float f = itemIcon.getMinU(); + float f1 = itemIcon.getMaxU(); + float f2 = itemIcon.getMinV(); + float f3 = itemIcon.getMaxV(); + boolean armor = event.entityPlayer.getCurrentArmor(3) != null; + Helper.translateToHeadLevel(event.entityPlayer); + Minecraft.getMinecraft().renderEngine.bindTexture(TextureMap.locationItemsTexture); + GL11.glRotatef(90F, 0F, 1F, 0F); + GL11.glRotatef(180F, 1F, 0F, 0F); + GL11.glTranslatef(-0.4F, 0.1F, armor ? -0.35F : -0.3F); + GL11.glScalef(0.5F, 0.5F, 0.5F); + ItemRenderer.renderItemIn2D( + Tessellator.instance, f1, f2, f, f3, itemIcon.getIconWidth(), itemIcon.getIconHeight(), 1F / 16F); + } + } } diff --git a/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemFlightTiara.java b/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemFlightTiara.java index af3b711b4b..9d8d8e1d8d 100644 --- a/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemFlightTiara.java +++ b/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemFlightTiara.java @@ -2,22 +2,27 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [May 26, 2014, 4:05:50 PM (GMT)] */ package vazkii.botania.common.item.equipment.bauble; +import baubles.api.BaubleType; +import baubles.common.lib.PlayerHandler; +import cpw.mods.fml.common.FMLCommonHandler; +import cpw.mods.fml.common.eventhandler.SubscribeEvent; +import cpw.mods.fml.common.gameevent.PlayerEvent; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; import java.security.MessageDigest; import java.security.NoSuchAlgorithmException; import java.security.SecureRandom; import java.util.ArrayList; import java.util.List; - import javax.xml.bind.annotation.adapters.HexBinaryAdapter; - import net.minecraft.client.Minecraft; import net.minecraft.client.gui.Gui; import net.minecraft.client.gui.ScaledResolution; @@ -40,9 +45,7 @@ import net.minecraftforge.client.event.RenderPlayerEvent; import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.event.entity.living.LivingEvent.LivingUpdateEvent; - import org.lwjgl.opengl.GL11; - import vazkii.botania.api.BotaniaAPI; import vazkii.botania.api.item.IBaubleRender; import vazkii.botania.api.mana.IManaUsingItem; @@ -59,494 +62,514 @@ import vazkii.botania.common.core.helper.Vector3; import vazkii.botania.common.item.ModItems; import vazkii.botania.common.lib.LibItemNames; -import baubles.api.BaubleType; -import baubles.common.lib.PlayerHandler; -import cpw.mods.fml.common.FMLCommonHandler; -import cpw.mods.fml.common.eventhandler.SubscribeEvent; -import cpw.mods.fml.common.gameevent.PlayerEvent; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; public class ItemFlightTiara extends ItemBauble implements IManaUsingItem, IBaubleRender, ICraftAchievement { - private static ResourceLocation textureHud = new ResourceLocation(LibResources.GUI_HUD_ICONS); - private static ResourceLocation textureHalo = new ResourceLocation(LibResources.MISC_HALO); - - private static final String TAG_FLYING = "flying"; - private static final String TAG_TIME_LEFT = "timeLeft"; - private static final String TAG_INFINITE_FLIGHT = "infiniteFlight"; - private static final String TAG_DASH_COOLDOWN = "dashCooldown"; - private static final String TAG_IS_SPRINTING = "isSprinting"; - - public static List playersWithFlight = new ArrayList(); - private static final int COST = 35; - private static final int COST_OVERKILL = COST * 3; - private static final int MAX_FLY_TIME = 1200; - - public static IIcon[] wingIcons; - private static final int SUBTYPES = 8; - private static final int WING_TYPES = 9; - - public ItemFlightTiara() { - super(LibItemNames.FLIGHT_TIARA); - MinecraftForge.EVENT_BUS.register(this); - FMLCommonHandler.instance().bus().register(this); - setHasSubtypes(true); - } - - @Override - public BaubleType getBaubleType(ItemStack arg0) { - return BaubleType.AMULET; - } - - @Override - @SideOnly(Side.CLIENT) - public void registerIcons(IIconRegister par1IconRegister) { - itemIcon = IconHelper.forItem(par1IconRegister, this, 0); - wingIcons = new IIcon[WING_TYPES]; - for(int i = 0; i < WING_TYPES; i++) - wingIcons[i] = IconHelper.forItem(par1IconRegister, this, i + 1); - } - - @Override - public void getSubItems(Item item, CreativeTabs tab, List list) { - for(int i = 0; i < SUBTYPES + 1; i++) - list.add(new ItemStack(item, 1, i)); - } - - @Override - public void addHiddenTooltip(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, List par3List, boolean par4) { - super.addHiddenTooltip(par1ItemStack, par2EntityPlayer, par3List, par4); - par3List.add(StatCollector.translateToLocal("botania.wings" + par1ItemStack.getItemDamage())); - } - - @Override - public void onEquipped(ItemStack stack, EntityLivingBase player) { - super.onEquipped(stack, player); - if(stack.getItemDamage() != WING_TYPES && hash(stack.getDisplayName()).equals("16E1BDFD1D6AE1A954C9C5E1B2D9099780F3E1724541F1F2F77310B769CFFBAC")) { - stack.setItemDamage(WING_TYPES); - stack.getTagCompound().removeTag("display"); - } - } - - String hash(String str) { - if(str != null) - try { - MessageDigest md = MessageDigest.getInstance("SHA-256"); - return new HexBinaryAdapter().marshal(md.digest(salt(str).getBytes())); - } catch (NoSuchAlgorithmException e) { - e.printStackTrace(); - } - return ""; - } - - // Might as well be called sugar given it's not secure at all :D - String salt(String str) { - str = str += "wowsuchsaltmuchsecurityverywow"; - SecureRandom rand = new SecureRandom(str.getBytes()); - int l = str.length(); - int steps = rand.nextInt(l); - char[] chrs = str.toCharArray(); - for(int i = 0; i < steps; i++) { - int indA = rand.nextInt(l); - int indB; - do { - indB = rand.nextInt(l); - } while(indB == indA); - char c = (char) (chrs[indA] ^ chrs[indB]); - chrs[indA] = c; - } - - return String.copyValueOf(chrs); - } - - @Override - public void onWornTick(ItemStack stack, EntityLivingBase player) { - super.onWornTick(stack, player); - - if(player instanceof EntityPlayer) { - EntityPlayer p = (EntityPlayer) player; - boolean flying = p.capabilities.isFlying; - - boolean wasSprting = ItemNBTHelper.getBoolean(stack, TAG_IS_SPRINTING, false); - boolean isSprinting = p.isSprinting(); - if(isSprinting != wasSprting) - ItemNBTHelper.setBoolean(stack, TAG_IS_SPRINTING, isSprinting); - - int time = ItemNBTHelper.getInt(stack, TAG_TIME_LEFT, MAX_FLY_TIME); - int newTime = time; - Vector3 look = new Vector3(p.getLookVec()); - look.y = 0; - look.normalize(); - - if(flying) { - if(time > 0 && !ItemNBTHelper.getBoolean(stack, TAG_INFINITE_FLIGHT, false)) - newTime--; - final int maxCd = 80; - int cooldown = ItemNBTHelper.getInt(stack, TAG_DASH_COOLDOWN, 0); - if(!wasSprting && isSprinting && cooldown == 0) { - p.motionX += look.x; - p.motionZ += look.z; - p.worldObj.playSoundAtEntity(p, "botania:dash", 1F, 1F); - ItemNBTHelper.setInt(stack, TAG_DASH_COOLDOWN, maxCd); - } else if(cooldown > 0) { - if(maxCd - cooldown < 2) - player.moveFlying(0F, 1F, 5F); - else if(maxCd - cooldown < 10) - player.setSprinting(false); - ItemNBTHelper.setInt(stack, TAG_DASH_COOLDOWN, cooldown - 2); - if(player instanceof EntityPlayerMP) - BotaniaAPI.internalHandler.sendBaubleUpdatePacket((EntityPlayerMP) player, 0); - } - } else if(!flying) { - boolean doGlide = player.isSneaking() && !player.onGround && player.fallDistance >= 2F; - if(time < MAX_FLY_TIME && player.ticksExisted % (doGlide ? 6 : 2) == 0) - newTime++; - - if(doGlide) { - player.motionY = Math.max(-0.15F, player.motionY); - float mul = 0.6F; - player.motionX = look.x * mul; - player.motionZ = look.z * mul; - player.fallDistance = 2F; - } - } - - ItemNBTHelper.setBoolean(stack, TAG_FLYING, flying); - if(newTime != time) - ItemNBTHelper.setInt(stack, TAG_TIME_LEFT, newTime); - } - } - - @SubscribeEvent - public void updatePlayerFlyStatus(LivingUpdateEvent event) { - if(event.entityLiving instanceof EntityPlayer) { - EntityPlayer player = (EntityPlayer) event.entityLiving; - ItemStack tiara = PlayerHandler.getPlayerBaubles(player).getStackInSlot(0); - int left = ItemNBTHelper.getInt(tiara, TAG_TIME_LEFT, MAX_FLY_TIME); - - if(playersWithFlight.contains(playerStr(player))) { - if(shouldPlayerHaveFlight(player)) { - player.capabilities.allowFlying = true; - if(player.capabilities.isFlying) { - if(!player.worldObj.isRemote) - ManaItemHandler.requestManaExact(tiara, player, getCost(tiara, left), true); - else if(Math.abs(player.motionX) > 0.1 || Math.abs(player.motionZ) > 0.1) { - double x = event.entityLiving.posX - 0.5; - double y = event.entityLiving.posY - 1.7; - double z = event.entityLiving.posZ - 0.5; - - player.getGameProfile().getName(); - float r = 1F; - float g = 1F; - float b = 1F; - - switch(tiara.getItemDamage()) { - case 2 : { - r = 0.1F; - g = 0.1F; - b = 0.1F; - break; - } - case 3 : { - r = 0F; - g = 0.6F; - break; - } - case 4 : { - g = 0.3F; - b = 0.3F; - break; - } - case 5 : { - r = 0.6F; - g = 0F; - b = 0.6F; - break; - } - case 6 : { - r = 0.4F; - g = 0F; - b = 0F; - break; - } - case 7 : { - r = 0.2F; - g = 0.6F; - b = 0.2F; - break; - } - case 8 : { - r = 0.85F; - g = 0.85F; - b = 0F; - break; - } - case 9 : { - r = 0F; - b = 0F; - break; - } - } - - for(int i = 0; i < 2; i++) - Botania.proxy.sparkleFX(event.entityLiving.worldObj, x + Math.random() * event.entityLiving.width, y + Math.random() * 0.4, z + Math.random() * event.entityLiving.width, r, g, b, 2F * (float) Math.random(), 20); - } - } - } else { - if(!player.capabilities.isCreativeMode) { - player.capabilities.allowFlying = false; - player.capabilities.isFlying = false; - player.capabilities.disableDamage = false; - } - playersWithFlight.remove(playerStr(player)); - } - } else if(shouldPlayerHaveFlight(player)) { - playersWithFlight.add(playerStr(player)); - player.capabilities.allowFlying = true; - } - } - } - - @SubscribeEvent - public void playerLoggedOut(PlayerEvent.PlayerLoggedOutEvent event) { - String username = event.player.getGameProfile().getName(); - playersWithFlight.remove(username + ":false"); - playersWithFlight.remove(username + ":true"); - } - - public static String playerStr(EntityPlayer player) { - return player.getGameProfile().getName() + ":" + player.worldObj.isRemote; - } - - private boolean shouldPlayerHaveFlight(EntityPlayer player) { - ItemStack armor = PlayerHandler.getPlayerBaubles(player).getStackInSlot(0); - if(armor != null && armor.getItem() == this) { - int left = ItemNBTHelper.getInt(armor, TAG_TIME_LEFT, MAX_FLY_TIME); - boolean flying = ItemNBTHelper.getBoolean(armor, TAG_FLYING, false); - return (left > (flying ? 0 : MAX_FLY_TIME / 10) || player.inventory.hasItem(ModItems.flugelEye)) && ManaItemHandler.requestManaExact(armor, player, getCost(armor, left), false); - } - - return false; - } - - public int getCost(ItemStack stack, int timeLeft) { - return timeLeft <= 0 ? COST_OVERKILL : COST; - } - - @Override - public boolean usesMana(ItemStack stack) { - return true; - } - - @Override - @SideOnly(Side.CLIENT) - public void onPlayerBaubleRender(ItemStack stack, RenderPlayerEvent event, RenderType type) { - int meta = stack.getItemDamage(); - if(type == RenderType.BODY) { - if(meta > 0 && meta <= ItemFlightTiara.wingIcons.length) { - IIcon icon = ItemFlightTiara.wingIcons[meta - 1]; - Minecraft.getMinecraft().renderEngine.bindTexture(TextureMap.locationItemsTexture); - - boolean flying = event.entityPlayer.capabilities.isFlying; - - float rz = 120F; - float rx = 20F + (float) ((Math.sin((double) (event.entityPlayer.ticksExisted + event.partialRenderTick) * (flying ? 0.4F : 0.2F)) + 0.5F) * (flying ? 30F : 5F)); - float ry = 0F; - float h = 0.2F; - float i = 0.15F; - float s = 1F; - - GL11.glPushMatrix(); - GL11.glEnable(GL11.GL_BLEND); - GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); - GL11.glColor4f(1F, 1F, 1F, 1F); - - int light = 15728880; - int lightmapX = light % 65536; - int lightmapY = light / 65536; - switch(meta) { - case 1 : { // Jibril - h = 0.4F; - break; - } - case 2 : { // Sephiroth - s = 1.3F; - break; - } - case 3 : { // Cirno - h = -0.1F; - rz = 0F; - rx = 0F; - i = 0.3F; - break; - } - case 4 : { // Phoenix - rz = 180F; - h = 0.5F; - rx = 20F; - ry = -(float) ((Math.sin((double) (event.entityPlayer.ticksExisted + event.partialRenderTick) * (flying ? 0.4F : 0.2F)) + 0.6F) * (flying ? 30F : 5F)); - OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, lightmapX, lightmapY); - break; - } - case 5 : { // Kuroyukihime - h = 0.8F; - rz = 180F; - ry = -rx; - rx = 0F; - s = 2F; - break; - } - case 6 : { // Random Devil - rz = 150F; - break; - } - case 7 : { // Lyfa - h = -0.1F; - rz = 0F; - ry = -rx; - rx = 0F; - GL11.glColor4f(1F, 1F, 1F, 0.5F + (float) Math.cos((double) (event.entityPlayer.ticksExisted + event.partialRenderTick) * 0.3F) * 0.2F); - break; - } - case 8 : { // Mega Ultra Chicken - h = 0.1F; - break; - } - case 9 : { // The One - OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, lightmapX, lightmapY); - rz = 180F; - rx = 0F; - s = 1.5F; - h = 1.2F; - GL11.glColor4f(1F, 1F, 1F, 0.5F + (flying ? (float) Math.cos((double) (event.entityPlayer.ticksExisted + event.partialRenderTick) * 0.3F) * 0.25F + 0.25F : 0F)); - } - } - - float f = icon.getMinU(); - float f1 = icon.getMaxU(); - float f2 = icon.getMinV(); - float f3 = icon.getMaxV(); - float sr = 1F / s; - - Helper.rotateIfSneaking(event.entityPlayer); - - GL11.glTranslatef(0F, h, i); - - GL11.glRotatef(rz, 0F, 0F, 1F); - GL11.glRotatef(rx, 1F, 0F, 0F); - GL11.glRotatef(ry, 0F, 1F, 0F); - GL11.glScalef(s, s, s); - ItemRenderer.renderItemIn2D(Tessellator.instance, f1, f2, f, f3, icon.getIconWidth(), icon.getIconHeight(), 1F / 32F); - GL11.glScalef(sr, sr, sr); - GL11.glRotatef(-ry, 0F, 1F, 0F); - GL11.glRotatef(-rx, 1F, 0F, 0F); - GL11.glRotatef(-rz, 0F, 0F, 1F); - - if(meta != 2) { // Sephiroth - GL11.glScalef(-1F, 1F, 1F); - GL11.glRotatef(rz, 0F, 0F, 1F); - GL11.glRotatef(rx, 1F, 0F, 0F); - GL11.glRotatef(ry, 0F, 1F, 0F); - GL11.glScalef(s, s, s); - ItemRenderer.renderItemIn2D(Tessellator.instance, f1, f2, f, f3, icon.getIconWidth(), icon.getIconHeight(), 1F / 32F); - GL11.glScalef(sr, sr, sr); - GL11.glRotatef(-ry, 1F, 0F, 0F); - GL11.glRotatef(-rx, 1F, 0F, 0F); - GL11.glRotatef(-rz, 0F, 0F, 1F); - } - - GL11.glColor3f(1F, 1F, 1F); - GL11.glPopMatrix(); - } - } else if(meta == 1) // Jibril's Halo - renderHalo(event.entityPlayer, event.partialRenderTick); - } - - @SideOnly(Side.CLIENT) - public static void renderHalo(EntityPlayer player, float partialTicks) { - GL11.glEnable(GL11.GL_BLEND); - GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); - GL11.glShadeModel(GL11.GL_SMOOTH); - OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, 240, 240); - GL11.glDisable(GL11.GL_LIGHTING); - GL11.glDisable(GL11.GL_CULL_FACE); - GL11.glColor4f(1F, 1F, 1F, 1F); - - Minecraft.getMinecraft().renderEngine.bindTexture(textureHalo); - - if(player != null) - Helper.translateToHeadLevel(player); - GL11.glRotated(30, 1, 0, -1); - GL11.glTranslatef(-0.1F, -0.5F, -0.1F); - if(player != null) - GL11.glRotatef(player.ticksExisted + partialTicks, 0, 1, 0); - else GL11.glRotatef(Botania.proxy.getWorldElapsedTicks(), 0, 1, 0); - - Tessellator tes = Tessellator.instance; - ShaderHelper.useShader(ShaderHelper.halo); - tes.startDrawingQuads(); - tes.addVertexWithUV(-0.75, 0, -0.75, 0, 0); - tes.addVertexWithUV(-0.75, 0, 0.75, 0, 1); - tes.addVertexWithUV(0.75, 0, 0.75, 1, 1); - tes.addVertexWithUV(0.75, 0, -0.75, 1, 0); - tes.draw(); - ShaderHelper.releaseShader(); - - GL11.glEnable(GL11.GL_LIGHTING); - GL11.glShadeModel(GL11.GL_FLAT); - GL11.glEnable(GL11.GL_CULL_FACE); - } - - @SideOnly(Side.CLIENT) - public static void renderHUD(ScaledResolution resolution, EntityPlayer player, ItemStack stack) { - int u = Math.max(1, stack.getItemDamage()) * 9 - 9; - int v = 0; - - Minecraft mc = Minecraft.getMinecraft(); - mc.renderEngine.bindTexture(textureHud); - int xo = resolution.getScaledWidth() / 2 + 10; - int x = xo; - int y = resolution.getScaledHeight() - ConfigHandler.flightBarHeight; - if(player.getAir() < 300) - y = resolution.getScaledHeight() - ConfigHandler.flightBarBreathHeight; - - int left = ItemNBTHelper.getInt(stack, TAG_TIME_LEFT, MAX_FLY_TIME); - - int segTime = MAX_FLY_TIME / 10; - int segs = left / segTime + 1; - int last = left % segTime; - - for(int i = 0; i < segs; i++) { - float trans = 1F; - if(i == segs - 1) { - trans = (float) last / (float) segTime; - GL11.glEnable(GL11.GL_BLEND); - GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); - GL11.glDisable(GL11.GL_ALPHA_TEST); - } - - GL11.glColor4f(1F, 1F, 1F, trans); - RenderHelper.drawTexturedModalRect(x, y, 0, u, v, 9, 9); - x += 8; - } - - if(player.capabilities.isFlying) { - int width = ItemNBTHelper.getInt(stack, TAG_DASH_COOLDOWN, 0); - GL11.glColor4f(1F, 1F, 1F, 1F); - if(width > 0) - Gui.drawRect(xo, y - 2, xo + 80, y - 1, 0x88000000); - Gui.drawRect(xo, y - 2, xo + width, y - 1, 0xFFFFFFFF); - } - - GL11.glEnable(GL11.GL_ALPHA_TEST); - GL11.glColor4f(1F, 1F, 1F, 1F); - mc.renderEngine.bindTexture(Gui.icons); - } - - @Override - public Achievement getAchievementOnCraft(ItemStack stack, EntityPlayer player, IInventory matrix) { - return stack.getItemDamage() == 1 ? ModAchievements.tiaraWings : null; - } - + private static ResourceLocation textureHud = new ResourceLocation(LibResources.GUI_HUD_ICONS); + private static ResourceLocation textureHalo = new ResourceLocation(LibResources.MISC_HALO); + + private static final String TAG_FLYING = "flying"; + private static final String TAG_TIME_LEFT = "timeLeft"; + private static final String TAG_INFINITE_FLIGHT = "infiniteFlight"; + private static final String TAG_DASH_COOLDOWN = "dashCooldown"; + private static final String TAG_IS_SPRINTING = "isSprinting"; + + public static List playersWithFlight = new ArrayList(); + private static final int COST = 35; + private static final int COST_OVERKILL = COST * 3; + private static final int MAX_FLY_TIME = 1200; + + public static IIcon[] wingIcons; + private static final int SUBTYPES = 8; + private static final int WING_TYPES = 9; + + public ItemFlightTiara() { + super(LibItemNames.FLIGHT_TIARA); + MinecraftForge.EVENT_BUS.register(this); + FMLCommonHandler.instance().bus().register(this); + setHasSubtypes(true); + } + + @Override + public BaubleType getBaubleType(ItemStack arg0) { + return BaubleType.AMULET; + } + + @Override + @SideOnly(Side.CLIENT) + public void registerIcons(IIconRegister par1IconRegister) { + itemIcon = IconHelper.forItem(par1IconRegister, this, 0); + wingIcons = new IIcon[WING_TYPES]; + for (int i = 0; i < WING_TYPES; i++) wingIcons[i] = IconHelper.forItem(par1IconRegister, this, i + 1); + } + + @Override + public void getSubItems(Item item, CreativeTabs tab, List list) { + for (int i = 0; i < SUBTYPES + 1; i++) list.add(new ItemStack(item, 1, i)); + } + + @Override + public void addHiddenTooltip(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, List par3List, boolean par4) { + super.addHiddenTooltip(par1ItemStack, par2EntityPlayer, par3List, par4); + par3List.add(StatCollector.translateToLocal("botania.wings" + par1ItemStack.getItemDamage())); + } + + @Override + public void onEquipped(ItemStack stack, EntityLivingBase player) { + super.onEquipped(stack, player); + if (stack.getItemDamage() != WING_TYPES + && hash(stack.getDisplayName()) + .equals("16E1BDFD1D6AE1A954C9C5E1B2D9099780F3E1724541F1F2F77310B769CFFBAC")) { + stack.setItemDamage(WING_TYPES); + stack.getTagCompound().removeTag("display"); + } + } + + String hash(String str) { + if (str != null) + try { + MessageDigest md = MessageDigest.getInstance("SHA-256"); + return new HexBinaryAdapter().marshal(md.digest(salt(str).getBytes())); + } catch (NoSuchAlgorithmException e) { + e.printStackTrace(); + } + return ""; + } + + // Might as well be called sugar given it's not secure at all :D + String salt(String str) { + str = str += "wowsuchsaltmuchsecurityverywow"; + SecureRandom rand = new SecureRandom(str.getBytes()); + int l = str.length(); + int steps = rand.nextInt(l); + char[] chrs = str.toCharArray(); + for (int i = 0; i < steps; i++) { + int indA = rand.nextInt(l); + int indB; + do { + indB = rand.nextInt(l); + } while (indB == indA); + char c = (char) (chrs[indA] ^ chrs[indB]); + chrs[indA] = c; + } + + return String.copyValueOf(chrs); + } + + @Override + public void onWornTick(ItemStack stack, EntityLivingBase player) { + super.onWornTick(stack, player); + + if (player instanceof EntityPlayer) { + EntityPlayer p = (EntityPlayer) player; + boolean flying = p.capabilities.isFlying; + + boolean wasSprting = ItemNBTHelper.getBoolean(stack, TAG_IS_SPRINTING, false); + boolean isSprinting = p.isSprinting(); + if (isSprinting != wasSprting) ItemNBTHelper.setBoolean(stack, TAG_IS_SPRINTING, isSprinting); + + int time = ItemNBTHelper.getInt(stack, TAG_TIME_LEFT, MAX_FLY_TIME); + int newTime = time; + Vector3 look = new Vector3(p.getLookVec()); + look.y = 0; + look.normalize(); + + if (flying) { + if (time > 0 && !ItemNBTHelper.getBoolean(stack, TAG_INFINITE_FLIGHT, false)) newTime--; + final int maxCd = 80; + int cooldown = ItemNBTHelper.getInt(stack, TAG_DASH_COOLDOWN, 0); + if (!wasSprting && isSprinting && cooldown == 0) { + p.motionX += look.x; + p.motionZ += look.z; + p.worldObj.playSoundAtEntity(p, "botania:dash", 1F, 1F); + ItemNBTHelper.setInt(stack, TAG_DASH_COOLDOWN, maxCd); + } else if (cooldown > 0) { + if (maxCd - cooldown < 2) player.moveFlying(0F, 1F, 5F); + else if (maxCd - cooldown < 10) player.setSprinting(false); + ItemNBTHelper.setInt(stack, TAG_DASH_COOLDOWN, cooldown - 2); + if (player instanceof EntityPlayerMP) + BotaniaAPI.internalHandler.sendBaubleUpdatePacket((EntityPlayerMP) player, 0); + } + } else if (!flying) { + boolean doGlide = player.isSneaking() && !player.onGround && player.fallDistance >= 2F; + if (time < MAX_FLY_TIME && player.ticksExisted % (doGlide ? 6 : 2) == 0) newTime++; + + if (doGlide) { + player.motionY = Math.max(-0.15F, player.motionY); + float mul = 0.6F; + player.motionX = look.x * mul; + player.motionZ = look.z * mul; + player.fallDistance = 2F; + } + } + + ItemNBTHelper.setBoolean(stack, TAG_FLYING, flying); + if (newTime != time) ItemNBTHelper.setInt(stack, TAG_TIME_LEFT, newTime); + } + } + + @SubscribeEvent + public void updatePlayerFlyStatus(LivingUpdateEvent event) { + if (event.entityLiving instanceof EntityPlayer) { + EntityPlayer player = (EntityPlayer) event.entityLiving; + ItemStack tiara = PlayerHandler.getPlayerBaubles(player).getStackInSlot(0); + int left = ItemNBTHelper.getInt(tiara, TAG_TIME_LEFT, MAX_FLY_TIME); + + if (playersWithFlight.contains(playerStr(player))) { + if (shouldPlayerHaveFlight(player)) { + player.capabilities.allowFlying = true; + if (player.capabilities.isFlying) { + if (!player.worldObj.isRemote) + ManaItemHandler.requestManaExact(tiara, player, getCost(tiara, left), true); + else if (Math.abs(player.motionX) > 0.1 || Math.abs(player.motionZ) > 0.1) { + double x = event.entityLiving.posX - 0.5; + double y = event.entityLiving.posY - 1.7; + double z = event.entityLiving.posZ - 0.5; + + player.getGameProfile().getName(); + float r = 1F; + float g = 1F; + float b = 1F; + + switch (tiara.getItemDamage()) { + case 2: { + r = 0.1F; + g = 0.1F; + b = 0.1F; + break; + } + case 3: { + r = 0F; + g = 0.6F; + break; + } + case 4: { + g = 0.3F; + b = 0.3F; + break; + } + case 5: { + r = 0.6F; + g = 0F; + b = 0.6F; + break; + } + case 6: { + r = 0.4F; + g = 0F; + b = 0F; + break; + } + case 7: { + r = 0.2F; + g = 0.6F; + b = 0.2F; + break; + } + case 8: { + r = 0.85F; + g = 0.85F; + b = 0F; + break; + } + case 9: { + r = 0F; + b = 0F; + break; + } + } + + for (int i = 0; i < 2; i++) + Botania.proxy.sparkleFX( + event.entityLiving.worldObj, + x + Math.random() * event.entityLiving.width, + y + Math.random() * 0.4, + z + Math.random() * event.entityLiving.width, + r, + g, + b, + 2F * (float) Math.random(), + 20); + } + } + } else { + if (!player.capabilities.isCreativeMode) { + player.capabilities.allowFlying = false; + player.capabilities.isFlying = false; + player.capabilities.disableDamage = false; + } + playersWithFlight.remove(playerStr(player)); + } + } else if (shouldPlayerHaveFlight(player)) { + playersWithFlight.add(playerStr(player)); + player.capabilities.allowFlying = true; + } + } + } + + @SubscribeEvent + public void playerLoggedOut(PlayerEvent.PlayerLoggedOutEvent event) { + String username = event.player.getGameProfile().getName(); + playersWithFlight.remove(username + ":false"); + playersWithFlight.remove(username + ":true"); + } + + public static String playerStr(EntityPlayer player) { + return player.getGameProfile().getName() + ":" + player.worldObj.isRemote; + } + + private boolean shouldPlayerHaveFlight(EntityPlayer player) { + ItemStack armor = PlayerHandler.getPlayerBaubles(player).getStackInSlot(0); + if (armor != null && armor.getItem() == this) { + int left = ItemNBTHelper.getInt(armor, TAG_TIME_LEFT, MAX_FLY_TIME); + boolean flying = ItemNBTHelper.getBoolean(armor, TAG_FLYING, false); + return (left > (flying ? 0 : MAX_FLY_TIME / 10) || player.inventory.hasItem(ModItems.flugelEye)) + && ManaItemHandler.requestManaExact(armor, player, getCost(armor, left), false); + } + + return false; + } + + public int getCost(ItemStack stack, int timeLeft) { + return timeLeft <= 0 ? COST_OVERKILL : COST; + } + + @Override + public boolean usesMana(ItemStack stack) { + return true; + } + + @Override + @SideOnly(Side.CLIENT) + public void onPlayerBaubleRender(ItemStack stack, RenderPlayerEvent event, RenderType type) { + int meta = stack.getItemDamage(); + if (type == RenderType.BODY) { + if (meta > 0 && meta <= ItemFlightTiara.wingIcons.length) { + IIcon icon = ItemFlightTiara.wingIcons[meta - 1]; + Minecraft.getMinecraft().renderEngine.bindTexture(TextureMap.locationItemsTexture); + + boolean flying = event.entityPlayer.capabilities.isFlying; + + float rz = 120F; + float rx = 20F + + (float) ((Math.sin((double) (event.entityPlayer.ticksExisted + event.partialRenderTick) + * (flying ? 0.4F : 0.2F)) + + 0.5F) + * (flying ? 30F : 5F)); + float ry = 0F; + float h = 0.2F; + float i = 0.15F; + float s = 1F; + + GL11.glPushMatrix(); + GL11.glEnable(GL11.GL_BLEND); + GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); + GL11.glColor4f(1F, 1F, 1F, 1F); + + int light = 15728880; + int lightmapX = light % 65536; + int lightmapY = light / 65536; + switch (meta) { + case 1: { // Jibril + h = 0.4F; + break; + } + case 2: { // Sephiroth + s = 1.3F; + break; + } + case 3: { // Cirno + h = -0.1F; + rz = 0F; + rx = 0F; + i = 0.3F; + break; + } + case 4: { // Phoenix + rz = 180F; + h = 0.5F; + rx = 20F; + ry = -(float) ((Math.sin((double) (event.entityPlayer.ticksExisted + event.partialRenderTick) + * (flying ? 0.4F : 0.2F)) + + 0.6F) + * (flying ? 30F : 5F)); + OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, lightmapX, lightmapY); + break; + } + case 5: { // Kuroyukihime + h = 0.8F; + rz = 180F; + ry = -rx; + rx = 0F; + s = 2F; + break; + } + case 6: { // Random Devil + rz = 150F; + break; + } + case 7: { // Lyfa + h = -0.1F; + rz = 0F; + ry = -rx; + rx = 0F; + GL11.glColor4f( + 1F, + 1F, + 1F, + 0.5F + + (float) Math.cos((double) (event.entityPlayer.ticksExisted + + event.partialRenderTick) + * 0.3F) + * 0.2F); + break; + } + case 8: { // Mega Ultra Chicken + h = 0.1F; + break; + } + case 9: { // The One + OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, lightmapX, lightmapY); + rz = 180F; + rx = 0F; + s = 1.5F; + h = 1.2F; + GL11.glColor4f( + 1F, + 1F, + 1F, + 0.5F + + (flying + ? (float) Math.cos((double) (event.entityPlayer.ticksExisted + + event.partialRenderTick) + * 0.3F) + * 0.25F + + 0.25F + : 0F)); + } + } + + float f = icon.getMinU(); + float f1 = icon.getMaxU(); + float f2 = icon.getMinV(); + float f3 = icon.getMaxV(); + float sr = 1F / s; + + Helper.rotateIfSneaking(event.entityPlayer); + + GL11.glTranslatef(0F, h, i); + + GL11.glRotatef(rz, 0F, 0F, 1F); + GL11.glRotatef(rx, 1F, 0F, 0F); + GL11.glRotatef(ry, 0F, 1F, 0F); + GL11.glScalef(s, s, s); + ItemRenderer.renderItemIn2D( + Tessellator.instance, f1, f2, f, f3, icon.getIconWidth(), icon.getIconHeight(), 1F / 32F); + GL11.glScalef(sr, sr, sr); + GL11.glRotatef(-ry, 0F, 1F, 0F); + GL11.glRotatef(-rx, 1F, 0F, 0F); + GL11.glRotatef(-rz, 0F, 0F, 1F); + + if (meta != 2) { // Sephiroth + GL11.glScalef(-1F, 1F, 1F); + GL11.glRotatef(rz, 0F, 0F, 1F); + GL11.glRotatef(rx, 1F, 0F, 0F); + GL11.glRotatef(ry, 0F, 1F, 0F); + GL11.glScalef(s, s, s); + ItemRenderer.renderItemIn2D( + Tessellator.instance, f1, f2, f, f3, icon.getIconWidth(), icon.getIconHeight(), 1F / 32F); + GL11.glScalef(sr, sr, sr); + GL11.glRotatef(-ry, 1F, 0F, 0F); + GL11.glRotatef(-rx, 1F, 0F, 0F); + GL11.glRotatef(-rz, 0F, 0F, 1F); + } + + GL11.glColor3f(1F, 1F, 1F); + GL11.glPopMatrix(); + } + } else if (meta == 1) // Jibril's Halo + renderHalo(event.entityPlayer, event.partialRenderTick); + } + + @SideOnly(Side.CLIENT) + public static void renderHalo(EntityPlayer player, float partialTicks) { + GL11.glEnable(GL11.GL_BLEND); + GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); + GL11.glShadeModel(GL11.GL_SMOOTH); + OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, 240, 240); + GL11.glDisable(GL11.GL_LIGHTING); + GL11.glDisable(GL11.GL_CULL_FACE); + GL11.glColor4f(1F, 1F, 1F, 1F); + + Minecraft.getMinecraft().renderEngine.bindTexture(textureHalo); + + if (player != null) Helper.translateToHeadLevel(player); + GL11.glRotated(30, 1, 0, -1); + GL11.glTranslatef(-0.1F, -0.5F, -0.1F); + if (player != null) GL11.glRotatef(player.ticksExisted + partialTicks, 0, 1, 0); + else GL11.glRotatef(Botania.proxy.getWorldElapsedTicks(), 0, 1, 0); + + Tessellator tes = Tessellator.instance; + ShaderHelper.useShader(ShaderHelper.halo); + tes.startDrawingQuads(); + tes.addVertexWithUV(-0.75, 0, -0.75, 0, 0); + tes.addVertexWithUV(-0.75, 0, 0.75, 0, 1); + tes.addVertexWithUV(0.75, 0, 0.75, 1, 1); + tes.addVertexWithUV(0.75, 0, -0.75, 1, 0); + tes.draw(); + ShaderHelper.releaseShader(); + + GL11.glEnable(GL11.GL_LIGHTING); + GL11.glShadeModel(GL11.GL_FLAT); + GL11.glEnable(GL11.GL_CULL_FACE); + } + + @SideOnly(Side.CLIENT) + public static void renderHUD(ScaledResolution resolution, EntityPlayer player, ItemStack stack) { + int u = Math.max(1, stack.getItemDamage()) * 9 - 9; + int v = 0; + + Minecraft mc = Minecraft.getMinecraft(); + mc.renderEngine.bindTexture(textureHud); + int xo = resolution.getScaledWidth() / 2 + 10; + int x = xo; + int y = resolution.getScaledHeight() - ConfigHandler.flightBarHeight; + if (player.getAir() < 300) y = resolution.getScaledHeight() - ConfigHandler.flightBarBreathHeight; + + int left = ItemNBTHelper.getInt(stack, TAG_TIME_LEFT, MAX_FLY_TIME); + + int segTime = MAX_FLY_TIME / 10; + int segs = left / segTime + 1; + int last = left % segTime; + + for (int i = 0; i < segs; i++) { + float trans = 1F; + if (i == segs - 1) { + trans = (float) last / (float) segTime; + GL11.glEnable(GL11.GL_BLEND); + GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); + GL11.glDisable(GL11.GL_ALPHA_TEST); + } + + GL11.glColor4f(1F, 1F, 1F, trans); + RenderHelper.drawTexturedModalRect(x, y, 0, u, v, 9, 9); + x += 8; + } + + if (player.capabilities.isFlying) { + int width = ItemNBTHelper.getInt(stack, TAG_DASH_COOLDOWN, 0); + GL11.glColor4f(1F, 1F, 1F, 1F); + if (width > 0) Gui.drawRect(xo, y - 2, xo + 80, y - 1, 0x88000000); + Gui.drawRect(xo, y - 2, xo + width, y - 1, 0xFFFFFFFF); + } + + GL11.glEnable(GL11.GL_ALPHA_TEST); + GL11.glColor4f(1F, 1F, 1F, 1F); + mc.renderEngine.bindTexture(Gui.icons); + } + + @Override + public Achievement getAchievementOnCraft(ItemStack stack, EntityPlayer player, IInventory matrix) { + return stack.getItemDamage() == 1 ? ModAchievements.tiaraWings : null; + } } diff --git a/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemGoldenLaurel.java b/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemGoldenLaurel.java index 278d9e2857..facb5998b4 100644 --- a/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemGoldenLaurel.java +++ b/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemGoldenLaurel.java @@ -2,14 +2,20 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Apr 27, 2014, 8:49:01 PM (GMT)] */ package vazkii.botania.common.item.equipment.bauble; +import baubles.api.BaubleType; +import baubles.common.lib.PlayerHandler; +import cpw.mods.fml.common.eventhandler.EventPriority; +import cpw.mods.fml.common.eventhandler.SubscribeEvent; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; import net.minecraft.client.Minecraft; import net.minecraft.client.renderer.ItemRenderer; import net.minecraft.client.renderer.Tessellator; @@ -22,67 +28,60 @@ import net.minecraftforge.client.event.RenderPlayerEvent; import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.event.entity.living.LivingDeathEvent; - import org.lwjgl.opengl.GL11; - import vazkii.botania.api.item.IBaubleRender; import vazkii.botania.common.lib.LibItemNames; -import baubles.api.BaubleType; -import baubles.common.lib.PlayerHandler; -import cpw.mods.fml.common.eventhandler.EventPriority; -import cpw.mods.fml.common.eventhandler.SubscribeEvent; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; public class ItemGoldenLaurel extends ItemBauble implements IBaubleRender { - public ItemGoldenLaurel() { - super(LibItemNames.GOLDEN_LAUREL); - MinecraftForge.EVENT_BUS.register(this); - } + public ItemGoldenLaurel() { + super(LibItemNames.GOLDEN_LAUREL); + MinecraftForge.EVENT_BUS.register(this); + } - @SubscribeEvent(priority = EventPriority.HIGHEST) - public void onPlayerDeath(LivingDeathEvent event) { - if(event.entity instanceof EntityPlayer) { - EntityPlayer player = (EntityPlayer) event.entity; - ItemStack amulet = PlayerHandler.getPlayerBaubles(player).getStackInSlot(0); + @SubscribeEvent(priority = EventPriority.HIGHEST) + public void onPlayerDeath(LivingDeathEvent event) { + if (event.entity instanceof EntityPlayer) { + EntityPlayer player = (EntityPlayer) event.entity; + ItemStack amulet = PlayerHandler.getPlayerBaubles(player).getStackInSlot(0); - if(amulet != null && amulet.getItem() == this) { - event.setCanceled(true); - player.setHealth(player.getMaxHealth()); - player.addPotionEffect(new PotionEffect(Potion.resistance.id, 300, 6)); - player.addChatMessage(new ChatComponentTranslation("botaniamisc.savedByLaurel")); - player.worldObj.playSoundAtEntity(player, "botania:goldenLaurel", 1F, 0.3F); - PlayerHandler.getPlayerBaubles(player).setInventorySlotContents(0, null); - } - } - } + if (amulet != null && amulet.getItem() == this) { + event.setCanceled(true); + player.setHealth(player.getMaxHealth()); + player.addPotionEffect(new PotionEffect(Potion.resistance.id, 300, 6)); + player.addChatMessage(new ChatComponentTranslation("botaniamisc.savedByLaurel")); + player.worldObj.playSoundAtEntity(player, "botania:goldenLaurel", 1F, 0.3F); + PlayerHandler.getPlayerBaubles(player).setInventorySlotContents(0, null); + } + } + } - @Override - public BaubleType getBaubleType(ItemStack itemstack) { - return BaubleType.AMULET; - } + @Override + public BaubleType getBaubleType(ItemStack itemstack) { + return BaubleType.AMULET; + } - @Override - @SideOnly(Side.CLIENT) - public void onPlayerBaubleRender(ItemStack stack, RenderPlayerEvent event, RenderType type) { - if(type == RenderType.HEAD) { - float f = itemIcon.getMinU(); - float f1 = itemIcon.getMaxU(); - float f2 = itemIcon.getMinV(); - float f3 = itemIcon.getMaxV(); - boolean armor = event.entityPlayer.getCurrentArmor(3) != null; - Helper.translateToHeadLevel(event.entityPlayer); - Minecraft.getMinecraft().renderEngine.bindTexture(TextureMap.locationItemsTexture); - GL11.glRotatef(180F, 0F, 0F, 1F); - GL11.glRotatef(90F, 0F, 1F, 0F); - GL11.glRotatef(-100F, 1F, 0F, 0F); - GL11.glTranslatef(-0.5F, -0.55F, 0.3F); - if(armor) { - GL11.glScalef(1.1F, 1.1F, 1F); - GL11.glTranslatef(-0.05F, -0.1F, 0F); - } - ItemRenderer.renderItemIn2D(Tessellator.instance, f1, f2, f, f3, itemIcon.getIconWidth(), itemIcon.getIconHeight(), 1F / 32F); - } - } + @Override + @SideOnly(Side.CLIENT) + public void onPlayerBaubleRender(ItemStack stack, RenderPlayerEvent event, RenderType type) { + if (type == RenderType.HEAD) { + float f = itemIcon.getMinU(); + float f1 = itemIcon.getMaxU(); + float f2 = itemIcon.getMinV(); + float f3 = itemIcon.getMaxV(); + boolean armor = event.entityPlayer.getCurrentArmor(3) != null; + Helper.translateToHeadLevel(event.entityPlayer); + Minecraft.getMinecraft().renderEngine.bindTexture(TextureMap.locationItemsTexture); + GL11.glRotatef(180F, 0F, 0F, 1F); + GL11.glRotatef(90F, 0F, 1F, 0F); + GL11.glRotatef(-100F, 1F, 0F, 0F); + GL11.glTranslatef(-0.5F, -0.55F, 0.3F); + if (armor) { + GL11.glScalef(1.1F, 1.1F, 1F); + GL11.glTranslatef(-0.05F, -0.1F, 0F); + } + ItemRenderer.renderItemIn2D( + Tessellator.instance, f1, f2, f, f3, itemIcon.getIconWidth(), itemIcon.getIconHeight(), 1F / 32F); + } + } } diff --git a/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemGreaterAuraRing.java b/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemGreaterAuraRing.java index 6a94b5843d..fff95e532d 100644 --- a/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemGreaterAuraRing.java +++ b/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemGreaterAuraRing.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Apr 24, 2014, 5:12:53 PM (GMT)] */ package vazkii.botania.common.item.equipment.bauble; @@ -14,12 +14,12 @@ public class ItemGreaterAuraRing extends ItemAuraRing { - public ItemGreaterAuraRing() { - super(LibItemNames.AURA_RING_GREATER); - } + public ItemGreaterAuraRing() { + super(LibItemNames.AURA_RING_GREATER); + } - @Override - int getDelay() { - return 2; - } + @Override + int getDelay() { + return 2; + } } diff --git a/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemGreaterMagnetRing.java b/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemGreaterMagnetRing.java index 8a19839598..4426c76e59 100644 --- a/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemGreaterMagnetRing.java +++ b/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemGreaterMagnetRing.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Aug 21, 2015, 9:00:04 PM (GMT)] */ package vazkii.botania.common.item.equipment.bauble; @@ -14,8 +14,7 @@ public class ItemGreaterMagnetRing extends ItemMagnetRing { - public ItemGreaterMagnetRing() { - super(LibItemNames.MAGNET_RING_GREATER, 16); - } - + public ItemGreaterMagnetRing() { + super(LibItemNames.MAGNET_RING_GREATER, 16); + } } diff --git a/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemGreaterManaRing.java b/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemGreaterManaRing.java index c680da8f33..cd14330c9c 100644 --- a/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemGreaterManaRing.java +++ b/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemGreaterManaRing.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Apr 24, 2014, 5:20:54 PM (GMT)] */ package vazkii.botania.common.item.equipment.bauble; @@ -15,15 +15,14 @@ public class ItemGreaterManaRing extends ItemManaRing { - private static final int MAX_MANA = ItemManaRing.MAX_MANA * 4; + private static final int MAX_MANA = ItemManaRing.MAX_MANA * 4; - public ItemGreaterManaRing() { - super(LibItemNames.MANA_RING_GREATER); - } - - @Override - public int getMaxMana(ItemStack stack) { - return MAX_MANA; - } + public ItemGreaterManaRing() { + super(LibItemNames.MANA_RING_GREATER); + } + @Override + public int getMaxMana(ItemStack stack) { + return MAX_MANA; + } } diff --git a/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemHolyCloak.java b/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemHolyCloak.java index 50776abf6a..7a004a7dbe 100644 --- a/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemHolyCloak.java +++ b/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemHolyCloak.java @@ -2,14 +2,20 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Dec 4, 2014, 11:03:13 PM (GMT)] */ package vazkii.botania.common.item.equipment.bauble; +import baubles.api.BaubleType; +import baubles.common.container.InventoryBaubles; +import baubles.common.lib.PlayerHandler; +import cpw.mods.fml.common.eventhandler.SubscribeEvent; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; import net.minecraft.client.Minecraft; import net.minecraft.client.model.ModelBiped; import net.minecraft.entity.EntityLivingBase; @@ -19,129 +25,127 @@ import net.minecraftforge.client.event.RenderPlayerEvent; import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.event.entity.living.LivingHurtEvent; - import org.lwjgl.opengl.GL11; - import vazkii.botania.api.item.IBaubleRender; import vazkii.botania.client.lib.LibResources; import vazkii.botania.common.Botania; import vazkii.botania.common.core.helper.ItemNBTHelper; import vazkii.botania.common.lib.LibItemNames; -import baubles.api.BaubleType; -import baubles.common.container.InventoryBaubles; -import baubles.common.lib.PlayerHandler; -import cpw.mods.fml.common.eventhandler.SubscribeEvent; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; public class ItemHolyCloak extends ItemBauble implements IBaubleRender { - private static final ResourceLocation texture = new ResourceLocation(LibResources.MODEL_HOLY_CLOAK); - @SideOnly(Side.CLIENT) - private static ModelBiped model; - - private static final String TAG_COOLDOWN = "cooldown"; - private static final String TAG_IN_EFFECT = "inEffect"; - - public ItemHolyCloak() { - this(LibItemNames.HOLY_CLOAK); - MinecraftForge.EVENT_BUS.register(this); - } - - public ItemHolyCloak(String name) { - super(name); - } - - @SubscribeEvent - public void onPlayerDamage(LivingHurtEvent event) { - if(event.entityLiving instanceof EntityPlayer) { - EntityPlayer player = (EntityPlayer) event.entityLiving; - InventoryBaubles baubles = PlayerHandler.getPlayerBaubles(player); - ItemStack belt = baubles.getStackInSlot(3); - if(belt != null && belt.getItem() instanceof ItemHolyCloak && !isInEffect(belt)) { - ItemHolyCloak cloak = (ItemHolyCloak) belt.getItem(); - int cooldown = getCooldown(belt); - - // Used to prevent StackOverflows with mobs that deal damage when damaged - setInEffect(belt, true); - if(cooldown == 0 && cloak.effectOnDamage(event, player, belt)) - setCooldown(belt, cloak.getCooldownTime(belt)); - setInEffect(belt, false); - } - } - } - - @Override - public void onWornTick(ItemStack stack, EntityLivingBase player) { - int cooldown = getCooldown(stack); - if(cooldown > 0) - setCooldown(stack, cooldown - 1); - } - - public boolean effectOnDamage(LivingHurtEvent event, EntityPlayer player, ItemStack stack) { - if(!event.source.isMagicDamage()) { - event.setCanceled(true); - player.worldObj.playSoundAtEntity(player, "botania:holyCloak", 1F, 1F); - for(int i = 0; i < 30; i++) { - double x = player.posX + Math.random() * player.width * 2 - player.width; - double y = player.posY + Math.random() * player.height; - double z = player.posZ + Math.random() * player.width * 2 - player.width; - boolean yellow = Math.random() > 0.5; - Botania.proxy.sparkleFX(player.worldObj, x, y, z, yellow ? 1F : 0.3F, yellow ? 1F : 0.3F, yellow ? 0.3F : 1F, 0.8F + (float) Math.random() * 0.4F, 3); - } - return true; - } - - return false; - } - - public int getCooldownTime(ItemStack stack) { - return 200; - } - - @Override - public BaubleType getBaubleType(ItemStack arg0) { - return BaubleType.BELT; - } - - public static int getCooldown(ItemStack stack) { - return ItemNBTHelper.getInt(stack, TAG_COOLDOWN, 0); - } - - public static void setCooldown(ItemStack stack, int cooldown) { - ItemNBTHelper.setInt(stack, TAG_COOLDOWN, cooldown); - } - - public static boolean isInEffect(ItemStack stack) { - return ItemNBTHelper.getBoolean(stack, TAG_IN_EFFECT, false); - } - - public static void setInEffect(ItemStack stack, boolean effect) { - ItemNBTHelper.setBoolean(stack, TAG_IN_EFFECT, effect); - } - - @SideOnly(Side.CLIENT) - ResourceLocation getRenderTexture() { - return texture; - } - - @Override - @SideOnly(Side.CLIENT) - public void onPlayerBaubleRender(ItemStack stack, RenderPlayerEvent event, RenderType type) { - if(type == RenderType.BODY) { - Minecraft.getMinecraft().renderEngine.bindTexture(getRenderTexture()); - Helper.rotateIfSneaking(event.entityPlayer); - boolean armor = event.entityPlayer.getCurrentArmor(2) != null; - GL11.glTranslatef(0F, armor ? -0.07F : -0.01F, 0F); - - float s = 0.1F; - GL11.glScalef(s, s, s); - if(model == null) - model = new ModelBiped(); - - model.bipedBody.render(1F); - } - } - + private static final ResourceLocation texture = new ResourceLocation(LibResources.MODEL_HOLY_CLOAK); + + @SideOnly(Side.CLIENT) + private static ModelBiped model; + + private static final String TAG_COOLDOWN = "cooldown"; + private static final String TAG_IN_EFFECT = "inEffect"; + + public ItemHolyCloak() { + this(LibItemNames.HOLY_CLOAK); + MinecraftForge.EVENT_BUS.register(this); + } + + public ItemHolyCloak(String name) { + super(name); + } + + @SubscribeEvent + public void onPlayerDamage(LivingHurtEvent event) { + if (event.entityLiving instanceof EntityPlayer) { + EntityPlayer player = (EntityPlayer) event.entityLiving; + InventoryBaubles baubles = PlayerHandler.getPlayerBaubles(player); + ItemStack belt = baubles.getStackInSlot(3); + if (belt != null && belt.getItem() instanceof ItemHolyCloak && !isInEffect(belt)) { + ItemHolyCloak cloak = (ItemHolyCloak) belt.getItem(); + int cooldown = getCooldown(belt); + + // Used to prevent StackOverflows with mobs that deal damage when damaged + setInEffect(belt, true); + if (cooldown == 0 && cloak.effectOnDamage(event, player, belt)) + setCooldown(belt, cloak.getCooldownTime(belt)); + setInEffect(belt, false); + } + } + } + + @Override + public void onWornTick(ItemStack stack, EntityLivingBase player) { + int cooldown = getCooldown(stack); + if (cooldown > 0) setCooldown(stack, cooldown - 1); + } + + public boolean effectOnDamage(LivingHurtEvent event, EntityPlayer player, ItemStack stack) { + if (!event.source.isMagicDamage()) { + event.setCanceled(true); + player.worldObj.playSoundAtEntity(player, "botania:holyCloak", 1F, 1F); + for (int i = 0; i < 30; i++) { + double x = player.posX + Math.random() * player.width * 2 - player.width; + double y = player.posY + Math.random() * player.height; + double z = player.posZ + Math.random() * player.width * 2 - player.width; + boolean yellow = Math.random() > 0.5; + Botania.proxy.sparkleFX( + player.worldObj, + x, + y, + z, + yellow ? 1F : 0.3F, + yellow ? 1F : 0.3F, + yellow ? 0.3F : 1F, + 0.8F + (float) Math.random() * 0.4F, + 3); + } + return true; + } + + return false; + } + + public int getCooldownTime(ItemStack stack) { + return 200; + } + + @Override + public BaubleType getBaubleType(ItemStack arg0) { + return BaubleType.BELT; + } + + public static int getCooldown(ItemStack stack) { + return ItemNBTHelper.getInt(stack, TAG_COOLDOWN, 0); + } + + public static void setCooldown(ItemStack stack, int cooldown) { + ItemNBTHelper.setInt(stack, TAG_COOLDOWN, cooldown); + } + + public static boolean isInEffect(ItemStack stack) { + return ItemNBTHelper.getBoolean(stack, TAG_IN_EFFECT, false); + } + + public static void setInEffect(ItemStack stack, boolean effect) { + ItemNBTHelper.setBoolean(stack, TAG_IN_EFFECT, effect); + } + + @SideOnly(Side.CLIENT) + ResourceLocation getRenderTexture() { + return texture; + } + + @Override + @SideOnly(Side.CLIENT) + public void onPlayerBaubleRender(ItemStack stack, RenderPlayerEvent event, RenderType type) { + if (type == RenderType.BODY) { + Minecraft.getMinecraft().renderEngine.bindTexture(getRenderTexture()); + Helper.rotateIfSneaking(event.entityPlayer); + boolean armor = event.entityPlayer.getCurrentArmor(2) != null; + GL11.glTranslatef(0F, armor ? -0.07F : -0.01F, 0F); + + float s = 0.1F; + GL11.glScalef(s, s, s); + if (model == null) model = new ModelBiped(); + + model.bipedBody.render(1F); + } + } } - diff --git a/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemIcePendant.java b/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemIcePendant.java index 881113eaff..df3a28100e 100644 --- a/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemIcePendant.java +++ b/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemIcePendant.java @@ -2,19 +2,19 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Apr 26, 2014, 2:06:17 PM (GMT)] */ package vazkii.botania.common.item.equipment.bauble; +import baubles.api.BaubleType; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; - import net.minecraft.block.material.Material; import net.minecraft.client.Minecraft; import net.minecraft.client.renderer.ItemRenderer; @@ -30,120 +30,113 @@ import net.minecraft.util.MathHelper; import net.minecraft.world.World; import net.minecraftforge.client.event.RenderPlayerEvent; - import org.lwjgl.opengl.GL11; - import vazkii.botania.api.item.IBaubleRender; import vazkii.botania.client.core.helper.IconHelper; import vazkii.botania.common.lib.LibItemNames; -import baubles.api.BaubleType; public class ItemIcePendant extends ItemBauble implements IBaubleRender { - IIcon gemIcon; - public static Map> playerIceBlocks = new HashMap(); - - public ItemIcePendant() { - super(LibItemNames.ICE_PENDANT); - } - - @Override - public BaubleType getBaubleType(ItemStack itemstack) { - return BaubleType.AMULET; - } - - @Override - public void registerIcons(IIconRegister par1IconRegister) { - super.registerIcons(par1IconRegister); - gemIcon = IconHelper.forItem(par1IconRegister, this, "Gem"); - } - - @Override - public void onWornTick(ItemStack stack, EntityLivingBase entity) { - super.onWornTick(stack, entity); - - if(entity instanceof EntityPlayer) { - EntityPlayer player = (EntityPlayer) entity; - - if(!player.worldObj.isRemote) - tickIceRemovers(player); - - if(!player.isSneaking() && !player.isInsideOfMaterial(Material.water) && !player.worldObj.isRemote) { - int x = MathHelper.floor_double(player.posX); - int y = MathHelper.floor_double(player.posY - (player.isInWater() ? 0 : 1)); - int z = MathHelper.floor_double(player.posZ); - - int range = 3; - for(int i = -range; i < range + 1; i++) - for(int j = -range; j < range + 1; j++) { - int x1 = x + i; - int z1 = z + j; - - addIceBlock(player, new ChunkCoordinates(x1, y, z1)); - } - } - } - } - - private void addIceBlock(EntityPlayer player, ChunkCoordinates coords) { - String user = player.getCommandSenderName(); - if(!playerIceBlocks.containsKey(user)) - playerIceBlocks.put(user, new ArrayList()); - - List ice = playerIceBlocks.get(user); - if(player.worldObj.getBlock(coords.posX, coords.posY, coords.posZ) == Blocks.water && player.worldObj.getBlockMetadata(coords.posX, coords.posY, coords.posZ) == 0) { - player.worldObj.setBlock(coords.posX, coords.posY, coords.posZ, Blocks.ice); - - if(!player.worldObj.isRemote) - ice.add(new IceRemover(coords)); - } - } - - private void tickIceRemovers(EntityPlayer player) { - String user = player.getCommandSenderName(); - if(!playerIceBlocks.containsKey(user)) - return; - - List removers = playerIceBlocks.get(user); - for(IceRemover ice : new ArrayList(removers)) - ice.tick(player.worldObj, removers); - } - - @Override - public void onPlayerBaubleRender(ItemStack stack, RenderPlayerEvent event, RenderType type) { - if(type == RenderType.BODY) { - Minecraft.getMinecraft().renderEngine.bindTexture(TextureMap.locationItemsTexture); - Helper.rotateIfSneaking(event.entityPlayer); - boolean armor = event.entityPlayer.getCurrentArmor(2) != null; - GL11.glRotatef(180F, 1F, 0F, 0F); - GL11.glTranslatef(-0.36F, -0.3F, armor ? 0.2F : 0.15F); - GL11.glRotatef(-45F, 0F, 0F, 1F); - GL11.glScalef(0.5F, 0.5F, 0.5F); - - float f = gemIcon.getMinU(); - float f1 = gemIcon.getMaxU(); - float f2 = gemIcon.getMinV(); - float f3 = gemIcon.getMaxV(); - ItemRenderer.renderItemIn2D(Tessellator.instance, f1, f2, f, f3, gemIcon.getIconWidth(), gemIcon.getIconHeight(), 1F / 32F); - } - } - - class IceRemover { - - int time = 30; - final ChunkCoordinates coords; - - public IceRemover(ChunkCoordinates coords) { - this.coords = coords; - } - - public void tick(World world, List list) { - if(world.getBlock(coords.posX, coords.posY, coords.posZ) == Blocks.ice) { - if(time-- == 0) - world.setBlock(coords.posX, coords.posY, coords.posZ, Blocks.water, 0, 1 | 2); - else return; - list.remove(this); - } - } - } + IIcon gemIcon; + public static Map> playerIceBlocks = new HashMap(); + + public ItemIcePendant() { + super(LibItemNames.ICE_PENDANT); + } + + @Override + public BaubleType getBaubleType(ItemStack itemstack) { + return BaubleType.AMULET; + } + + @Override + public void registerIcons(IIconRegister par1IconRegister) { + super.registerIcons(par1IconRegister); + gemIcon = IconHelper.forItem(par1IconRegister, this, "Gem"); + } + + @Override + public void onWornTick(ItemStack stack, EntityLivingBase entity) { + super.onWornTick(stack, entity); + + if (entity instanceof EntityPlayer) { + EntityPlayer player = (EntityPlayer) entity; + + if (!player.worldObj.isRemote) tickIceRemovers(player); + + if (!player.isSneaking() && !player.isInsideOfMaterial(Material.water) && !player.worldObj.isRemote) { + int x = MathHelper.floor_double(player.posX); + int y = MathHelper.floor_double(player.posY - (player.isInWater() ? 0 : 1)); + int z = MathHelper.floor_double(player.posZ); + + int range = 3; + for (int i = -range; i < range + 1; i++) + for (int j = -range; j < range + 1; j++) { + int x1 = x + i; + int z1 = z + j; + + addIceBlock(player, new ChunkCoordinates(x1, y, z1)); + } + } + } + } + + private void addIceBlock(EntityPlayer player, ChunkCoordinates coords) { + String user = player.getCommandSenderName(); + if (!playerIceBlocks.containsKey(user)) playerIceBlocks.put(user, new ArrayList()); + + List ice = playerIceBlocks.get(user); + if (player.worldObj.getBlock(coords.posX, coords.posY, coords.posZ) == Blocks.water + && player.worldObj.getBlockMetadata(coords.posX, coords.posY, coords.posZ) == 0) { + player.worldObj.setBlock(coords.posX, coords.posY, coords.posZ, Blocks.ice); + + if (!player.worldObj.isRemote) ice.add(new IceRemover(coords)); + } + } + + private void tickIceRemovers(EntityPlayer player) { + String user = player.getCommandSenderName(); + if (!playerIceBlocks.containsKey(user)) return; + + List removers = playerIceBlocks.get(user); + for (IceRemover ice : new ArrayList(removers)) ice.tick(player.worldObj, removers); + } + + @Override + public void onPlayerBaubleRender(ItemStack stack, RenderPlayerEvent event, RenderType type) { + if (type == RenderType.BODY) { + Minecraft.getMinecraft().renderEngine.bindTexture(TextureMap.locationItemsTexture); + Helper.rotateIfSneaking(event.entityPlayer); + boolean armor = event.entityPlayer.getCurrentArmor(2) != null; + GL11.glRotatef(180F, 1F, 0F, 0F); + GL11.glTranslatef(-0.36F, -0.3F, armor ? 0.2F : 0.15F); + GL11.glRotatef(-45F, 0F, 0F, 1F); + GL11.glScalef(0.5F, 0.5F, 0.5F); + + float f = gemIcon.getMinU(); + float f1 = gemIcon.getMaxU(); + float f2 = gemIcon.getMinV(); + float f3 = gemIcon.getMaxV(); + ItemRenderer.renderItemIn2D( + Tessellator.instance, f1, f2, f, f3, gemIcon.getIconWidth(), gemIcon.getIconHeight(), 1F / 32F); + } + } + + class IceRemover { + + int time = 30; + final ChunkCoordinates coords; + + public IceRemover(ChunkCoordinates coords) { + this.coords = coords; + } + + public void tick(World world, List list) { + if (world.getBlock(coords.posX, coords.posY, coords.posZ) == Blocks.ice) { + if (time-- == 0) world.setBlock(coords.posX, coords.posY, coords.posZ, Blocks.water, 0, 1 | 2); + else return; + list.remove(this); + } + } + } } diff --git a/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemItemFinder.java b/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemItemFinder.java index 2acf57719e..a44a77c9b5 100644 --- a/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemItemFinder.java +++ b/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemItemFinder.java @@ -2,17 +2,24 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jul 31, 2014, 12:59:16 AM (GMT)] */ package vazkii.botania.common.item.equipment.bauble; +import baubles.api.BaubleType; +import baubles.common.container.InventoryBaubles; +import baubles.common.lib.PlayerHandler; +import baubles.common.network.PacketHandler; +import baubles.common.network.PacketSyncBauble; +import cpw.mods.fml.relauncher.ReflectionHelper; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; import java.util.ArrayList; import java.util.List; - import net.minecraft.client.Minecraft; import net.minecraft.client.renderer.ItemRenderer; import net.minecraft.client.renderer.Tessellator; @@ -34,203 +41,225 @@ import net.minecraft.util.MathHelper; import net.minecraft.village.MerchantRecipe; import net.minecraftforge.client.event.RenderPlayerEvent; - import org.lwjgl.opengl.GL11; - import vazkii.botania.api.item.IBaubleRender; import vazkii.botania.client.core.helper.IconHelper; import vazkii.botania.common.Botania; import vazkii.botania.common.core.helper.ItemNBTHelper; import vazkii.botania.common.lib.LibItemNames; import vazkii.botania.common.lib.LibObfuscation; -import baubles.api.BaubleType; -import baubles.common.container.InventoryBaubles; -import baubles.common.lib.PlayerHandler; -import baubles.common.network.PacketHandler; -import baubles.common.network.PacketSyncBauble; -import cpw.mods.fml.relauncher.ReflectionHelper; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; public class ItemItemFinder extends ItemBauble implements IBaubleRender { - IIcon gemIcon; - private static final String TAG_POSITIONS = "highlightPositions"; - - public ItemItemFinder() { - super(LibItemNames.ITEM_FINDER); - } - - @Override - public void registerIcons(IIconRegister par1IconRegister) { - super.registerIcons(par1IconRegister); - gemIcon = IconHelper.forItem(par1IconRegister, this, "Gem"); - } - - @Override - public void onWornTick(ItemStack stack, EntityLivingBase player) { - super.onWornTick(stack, player); - - if(!(player instanceof EntityPlayer)) - return; - - if(player.worldObj.isRemote) - tickClient(stack, (EntityPlayer) player); - else tickServer(stack, (EntityPlayer) player); - } - - public void tickClient(ItemStack stack, EntityPlayer player) { - if(!Botania.proxy.isTheClientPlayer(player)) - return; - - String pos = ItemNBTHelper.getString(stack, TAG_POSITIONS, ""); - String[] tokens = pos.split(";"); - - for(String token : tokens) { - if(token.isEmpty()) - continue; - - if(token.contains(",")) { - String[] tokens_ = token.split(","); - int x = Integer.parseInt(tokens_[0]); - int y = Integer.parseInt(tokens_[1]); - int z = Integer.parseInt(tokens_[2]); - float m = 0.02F; - Botania.proxy.setWispFXDepthTest(false); - Botania.proxy.wispFX(player.worldObj, x + (float) Math.random(), y + (float) Math.random(), z + (float) Math.random(), (float) Math.random(), (float) Math.random(), (float) Math.random(), 0.15F + 0.05F * (float) Math.random(), m * (float) (Math.random() - 0.5), m * (float) (Math.random() - 0.5), m * (float) (Math.random() - 0.5)); - } else { - int id = Integer.parseInt(token); - Entity e = player.worldObj.getEntityByID(id); - - if(e != null && Math.random() < 0.6) { - Botania.proxy.setWispFXDepthTest(Math.random() < 0.6); - Botania.proxy.wispFX(player.worldObj, e.posX + (float) (Math.random() * 0.5 - 0.25) * 0.45F, e.posY + e.height, e.posZ + (float) (Math.random() * 0.5 - 0.25) * 0.45F, (float) Math.random(), (float) Math.random(), (float) Math.random(), 0.15F + 0.05F * (float) Math.random(), -0.05F - 0.03F * (float) Math.random()); - } - } - } - Botania.proxy.setWispFXDepthTest(true); - } - - public void tickServer(ItemStack stack, EntityPlayer player) { - ItemStack pstack = player.getCurrentEquippedItem(); - StringBuilder positionsBuilder = new StringBuilder(); - - if(pstack != null || player.isSneaking()) { - int range = 24; - - List entities = player.worldObj.getEntitiesWithinAABB(Entity.class, AxisAlignedBB.getBoundingBox(player.posX - range, player.posY - range, player.posZ - range, player.posX + range, player.posY + range, player.posZ + range)); - for(Entity e : entities) { - if(e == player) - continue; - - if(e instanceof EntityItem) { - EntityItem item = (EntityItem) e; - ItemStack istack = item.getEntityItem(); - if(player.isSneaking() || istack.isItemEqual(pstack) && ItemStack.areItemStackTagsEqual(istack, pstack)) - positionsBuilder.append(item.getEntityId()).append(";"); - - } else if(e instanceof IInventory) { - IInventory inv = (IInventory) e; - if(scanInventory(inv, pstack)) - positionsBuilder.append(e.getEntityId()).append(";"); - - } else if(e instanceof EntityHorse) { - EntityHorse horse = (EntityHorse) e; - AnimalChest chest = ReflectionHelper.getPrivateValue(EntityHorse.class, horse, LibObfuscation.HORSE_CHEST); - if(scanInventory(chest, pstack)) - positionsBuilder.append(horse.getEntityId()).append(";"); - - } else if(e instanceof EntityPlayer) { - EntityPlayer player_ = (EntityPlayer) e; - InventoryPlayer inv = player_.inventory; - InventoryBaubles binv = PlayerHandler.getPlayerBaubles(player_); - if(scanInventory(inv, pstack) || scanInventory(binv, pstack)) - positionsBuilder.append(player_.getEntityId()).append(";"); - - } else if(e instanceof EntityVillager) { - EntityVillager villager = (EntityVillager) e; - ArrayList recipes = villager.getRecipes(player); - if(pstack != null && recipes != null) - for(MerchantRecipe recipe : recipes) - if(recipe != null && !recipe.isRecipeDisabled() && (equalStacks(pstack, recipe.getItemToBuy()) || equalStacks(pstack, recipe.getItemToSell()))) - positionsBuilder.append(villager.getEntityId()).append(";"); - - } else if(e instanceof EntityLivingBase) { - EntityLivingBase living = (EntityLivingBase) e; - ItemStack estack = living.getEquipmentInSlot(0); - if(pstack != null && estack != null && equalStacks(estack, pstack)) - positionsBuilder.append(living.getEntityId()).append(";"); - } - } - - if(pstack != null) { - range = 12; - int x = MathHelper.floor_double(player.posX); - int y = MathHelper.floor_double(player.posY); - int z = MathHelper.floor_double(player.posZ); - for(int i = -range; i < range + 1; i++) - for(int j = -range; j < range + 1; j++) - for(int k = -range; k < range + 1; k++) { - int xp = x + i; - int yp = y + j; - int zp = z + k; - TileEntity tile = player.worldObj.getTileEntity(xp, yp, zp); - if(tile != null && tile instanceof IInventory) { - IInventory inv = (IInventory) tile; - if(scanInventory(inv, pstack)) - positionsBuilder.append(xp).append(",").append(yp).append(",").append(zp).append(";"); - } - } - } - } - - String current = ItemNBTHelper.getString(stack, TAG_POSITIONS, ""); - String positions = positionsBuilder.toString(); - if(!current.equals(positions)) { - ItemNBTHelper.setString(stack, TAG_POSITIONS, positions); - PacketHandler.INSTANCE.sendToAll(new PacketSyncBauble(player, 0)); - } - } - - boolean equalStacks(ItemStack stack1, ItemStack stack2) { - return stack1.isItemEqual(stack2) && ItemStack.areItemStackTagsEqual(stack1, stack2); - } - - boolean scanInventory(IInventory inv, ItemStack pstack) { - if(pstack == null) - return false; - - for(int l = 0; l < inv.getSizeInventory(); l++) { - ItemStack istack = inv.getStackInSlot(l); - if(istack != null && equalStacks(istack, pstack)) - return true; - } - - return false; - } - - @Override - public BaubleType getBaubleType(ItemStack arg0) { - return BaubleType.AMULET; - } - - @Override - @SideOnly(Side.CLIENT) - public void onPlayerBaubleRender(ItemStack stack, RenderPlayerEvent event, RenderType type) { - if(type == RenderType.HEAD) { - float f = gemIcon.getMinU(); - float f1 = gemIcon.getMaxU(); - float f2 = gemIcon.getMinV(); - float f3 = gemIcon.getMaxV(); - boolean armor = event.entityPlayer.getCurrentArmor(3) != null; - Helper.translateToHeadLevel(event.entityPlayer); - Minecraft.getMinecraft().renderEngine.bindTexture(TextureMap.locationItemsTexture); - GL11.glRotatef(90F, 0F, 1F, 0F); - GL11.glRotatef(180F, 1F, 0F, 0F); - GL11.glTranslatef(-0.4F, 0.1F, armor ? -0.3F : -0.25F); - GL11.glScalef(0.75F, 0.75F, 0.75F); - ItemRenderer.renderItemIn2D(Tessellator.instance, f1, f2, f, f3, gemIcon.getIconWidth(), gemIcon.getIconHeight(), 1F / 16F); - } - } - + IIcon gemIcon; + private static final String TAG_POSITIONS = "highlightPositions"; + + public ItemItemFinder() { + super(LibItemNames.ITEM_FINDER); + } + + @Override + public void registerIcons(IIconRegister par1IconRegister) { + super.registerIcons(par1IconRegister); + gemIcon = IconHelper.forItem(par1IconRegister, this, "Gem"); + } + + @Override + public void onWornTick(ItemStack stack, EntityLivingBase player) { + super.onWornTick(stack, player); + + if (!(player instanceof EntityPlayer)) return; + + if (player.worldObj.isRemote) tickClient(stack, (EntityPlayer) player); + else tickServer(stack, (EntityPlayer) player); + } + + public void tickClient(ItemStack stack, EntityPlayer player) { + if (!Botania.proxy.isTheClientPlayer(player)) return; + + String pos = ItemNBTHelper.getString(stack, TAG_POSITIONS, ""); + String[] tokens = pos.split(";"); + + for (String token : tokens) { + if (token.isEmpty()) continue; + + if (token.contains(",")) { + String[] tokens_ = token.split(","); + int x = Integer.parseInt(tokens_[0]); + int y = Integer.parseInt(tokens_[1]); + int z = Integer.parseInt(tokens_[2]); + float m = 0.02F; + Botania.proxy.setWispFXDepthTest(false); + Botania.proxy.wispFX( + player.worldObj, + x + (float) Math.random(), + y + (float) Math.random(), + z + (float) Math.random(), + (float) Math.random(), + (float) Math.random(), + (float) Math.random(), + 0.15F + 0.05F * (float) Math.random(), + m * (float) (Math.random() - 0.5), + m * (float) (Math.random() - 0.5), + m * (float) (Math.random() - 0.5)); + } else { + int id = Integer.parseInt(token); + Entity e = player.worldObj.getEntityByID(id); + + if (e != null && Math.random() < 0.6) { + Botania.proxy.setWispFXDepthTest(Math.random() < 0.6); + Botania.proxy.wispFX( + player.worldObj, + e.posX + (float) (Math.random() * 0.5 - 0.25) * 0.45F, + e.posY + e.height, + e.posZ + (float) (Math.random() * 0.5 - 0.25) * 0.45F, + (float) Math.random(), + (float) Math.random(), + (float) Math.random(), + 0.15F + 0.05F * (float) Math.random(), + -0.05F - 0.03F * (float) Math.random()); + } + } + } + Botania.proxy.setWispFXDepthTest(true); + } + + public void tickServer(ItemStack stack, EntityPlayer player) { + ItemStack pstack = player.getCurrentEquippedItem(); + StringBuilder positionsBuilder = new StringBuilder(); + + if (pstack != null || player.isSneaking()) { + int range = 24; + + List entities = player.worldObj.getEntitiesWithinAABB( + Entity.class, + AxisAlignedBB.getBoundingBox( + player.posX - range, + player.posY - range, + player.posZ - range, + player.posX + range, + player.posY + range, + player.posZ + range)); + for (Entity e : entities) { + if (e == player) continue; + + if (e instanceof EntityItem) { + EntityItem item = (EntityItem) e; + ItemStack istack = item.getEntityItem(); + if (player.isSneaking() + || istack.isItemEqual(pstack) && ItemStack.areItemStackTagsEqual(istack, pstack)) + positionsBuilder.append(item.getEntityId()).append(";"); + + } else if (e instanceof IInventory) { + IInventory inv = (IInventory) e; + if (scanInventory(inv, pstack)) + positionsBuilder.append(e.getEntityId()).append(";"); + + } else if (e instanceof EntityHorse) { + EntityHorse horse = (EntityHorse) e; + AnimalChest chest = + ReflectionHelper.getPrivateValue(EntityHorse.class, horse, LibObfuscation.HORSE_CHEST); + if (scanInventory(chest, pstack)) + positionsBuilder.append(horse.getEntityId()).append(";"); + + } else if (e instanceof EntityPlayer) { + EntityPlayer player_ = (EntityPlayer) e; + InventoryPlayer inv = player_.inventory; + InventoryBaubles binv = PlayerHandler.getPlayerBaubles(player_); + if (scanInventory(inv, pstack) || scanInventory(binv, pstack)) + positionsBuilder.append(player_.getEntityId()).append(";"); + + } else if (e instanceof EntityVillager) { + EntityVillager villager = (EntityVillager) e; + ArrayList recipes = villager.getRecipes(player); + if (pstack != null && recipes != null) + for (MerchantRecipe recipe : recipes) + if (recipe != null + && !recipe.isRecipeDisabled() + && (equalStacks(pstack, recipe.getItemToBuy()) + || equalStacks(pstack, recipe.getItemToSell()))) + positionsBuilder.append(villager.getEntityId()).append(";"); + + } else if (e instanceof EntityLivingBase) { + EntityLivingBase living = (EntityLivingBase) e; + ItemStack estack = living.getEquipmentInSlot(0); + if (pstack != null && estack != null && equalStacks(estack, pstack)) + positionsBuilder.append(living.getEntityId()).append(";"); + } + } + + if (pstack != null) { + range = 12; + int x = MathHelper.floor_double(player.posX); + int y = MathHelper.floor_double(player.posY); + int z = MathHelper.floor_double(player.posZ); + for (int i = -range; i < range + 1; i++) + for (int j = -range; j < range + 1; j++) + for (int k = -range; k < range + 1; k++) { + int xp = x + i; + int yp = y + j; + int zp = z + k; + TileEntity tile = player.worldObj.getTileEntity(xp, yp, zp); + if (tile != null && tile instanceof IInventory) { + IInventory inv = (IInventory) tile; + if (scanInventory(inv, pstack)) + positionsBuilder + .append(xp) + .append(",") + .append(yp) + .append(",") + .append(zp) + .append(";"); + } + } + } + } + + String current = ItemNBTHelper.getString(stack, TAG_POSITIONS, ""); + String positions = positionsBuilder.toString(); + if (!current.equals(positions)) { + ItemNBTHelper.setString(stack, TAG_POSITIONS, positions); + PacketHandler.INSTANCE.sendToAll(new PacketSyncBauble(player, 0)); + } + } + + boolean equalStacks(ItemStack stack1, ItemStack stack2) { + return stack1.isItemEqual(stack2) && ItemStack.areItemStackTagsEqual(stack1, stack2); + } + + boolean scanInventory(IInventory inv, ItemStack pstack) { + if (pstack == null) return false; + + for (int l = 0; l < inv.getSizeInventory(); l++) { + ItemStack istack = inv.getStackInSlot(l); + if (istack != null && equalStacks(istack, pstack)) return true; + } + + return false; + } + + @Override + public BaubleType getBaubleType(ItemStack arg0) { + return BaubleType.AMULET; + } + + @Override + @SideOnly(Side.CLIENT) + public void onPlayerBaubleRender(ItemStack stack, RenderPlayerEvent event, RenderType type) { + if (type == RenderType.HEAD) { + float f = gemIcon.getMinU(); + float f1 = gemIcon.getMaxU(); + float f2 = gemIcon.getMinV(); + float f3 = gemIcon.getMaxV(); + boolean armor = event.entityPlayer.getCurrentArmor(3) != null; + Helper.translateToHeadLevel(event.entityPlayer); + Minecraft.getMinecraft().renderEngine.bindTexture(TextureMap.locationItemsTexture); + GL11.glRotatef(90F, 0F, 1F, 0F); + GL11.glRotatef(180F, 1F, 0F, 0F); + GL11.glTranslatef(-0.4F, 0.1F, armor ? -0.3F : -0.25F); + GL11.glScalef(0.75F, 0.75F, 0.75F); + ItemRenderer.renderItemIn2D( + Tessellator.instance, f1, f2, f, f3, gemIcon.getIconWidth(), gemIcon.getIconHeight(), 1F / 16F); + } + } } diff --git a/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemKnockbackBelt.java b/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemKnockbackBelt.java index 78952e3127..ebcdc93b1d 100644 --- a/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemKnockbackBelt.java +++ b/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemKnockbackBelt.java @@ -2,14 +2,18 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Apr 26, 2014, 7:08:53 PM (GMT)] */ package vazkii.botania.common.item.equipment.bauble; +import baubles.api.BaubleType; +import com.google.common.collect.Multimap; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; import net.minecraft.client.Minecraft; import net.minecraft.client.model.ModelBiped; import net.minecraft.entity.SharedMonsterAttributes; @@ -17,54 +21,46 @@ import net.minecraft.item.ItemStack; import net.minecraft.util.ResourceLocation; import net.minecraftforge.client.event.RenderPlayerEvent; - import org.lwjgl.opengl.GL11; - import vazkii.botania.api.item.IBaubleRender; import vazkii.botania.client.lib.LibResources; import vazkii.botania.common.lib.LibItemNames; -import baubles.api.BaubleType; - -import com.google.common.collect.Multimap; - -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; public class ItemKnockbackBelt extends ItemBaubleModifier implements IBaubleRender { - private static final ResourceLocation texture = new ResourceLocation(LibResources.MODEL_KNOCKBACK_BELT); - private static ModelBiped model; - - public ItemKnockbackBelt() { - super(LibItemNames.KNOCKBACK_BELT); - } + private static final ResourceLocation texture = new ResourceLocation(LibResources.MODEL_KNOCKBACK_BELT); + private static ModelBiped model; - @Override - public BaubleType getBaubleType(ItemStack itemstack) { - return BaubleType.BELT; - } + public ItemKnockbackBelt() { + super(LibItemNames.KNOCKBACK_BELT); + } - @Override - void fillModifiers(Multimap attributes, ItemStack stack) { - attributes.put(SharedMonsterAttributes.knockbackResistance.getAttributeUnlocalizedName(), new AttributeModifier(getBaubleUUID(stack), "Bauble modifier", 1, 0)); - } + @Override + public BaubleType getBaubleType(ItemStack itemstack) { + return BaubleType.BELT; + } - @Override - @SideOnly(Side.CLIENT) - public void onPlayerBaubleRender(ItemStack stack, RenderPlayerEvent event, RenderType type) { - if(type == RenderType.BODY) { - Minecraft.getMinecraft().renderEngine.bindTexture(texture); - Helper.rotateIfSneaking(event.entityPlayer); - GL11.glTranslatef(0F, 0.2F, 0F); + @Override + void fillModifiers(Multimap attributes, ItemStack stack) { + attributes.put( + SharedMonsterAttributes.knockbackResistance.getAttributeUnlocalizedName(), + new AttributeModifier(getBaubleUUID(stack), "Bauble modifier", 1, 0)); + } - float s = 1.05F / 16F; - GL11.glScalef(s, s, s); + @Override + @SideOnly(Side.CLIENT) + public void onPlayerBaubleRender(ItemStack stack, RenderPlayerEvent event, RenderType type) { + if (type == RenderType.BODY) { + Minecraft.getMinecraft().renderEngine.bindTexture(texture); + Helper.rotateIfSneaking(event.entityPlayer); + GL11.glTranslatef(0F, 0.2F, 0F); - if(model == null) - model = new ModelBiped(); + float s = 1.05F / 16F; + GL11.glScalef(s, s, s); - model.bipedBody.render(1F); - } - } + if (model == null) model = new ModelBiped(); + model.bipedBody.render(1F); + } + } } diff --git a/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemLavaPendant.java b/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemLavaPendant.java index f07540b22d..8eaeff356c 100644 --- a/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemLavaPendant.java +++ b/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemLavaPendant.java @@ -2,14 +2,15 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Apr 26, 2014, 11:23:27 PM (GMT)] */ package vazkii.botania.common.item.equipment.bauble; +import baubles.api.BaubleType; import net.minecraft.client.Minecraft; import net.minecraft.client.renderer.ItemRenderer; import net.minecraft.client.renderer.Tessellator; @@ -19,56 +20,52 @@ import net.minecraft.item.ItemStack; import net.minecraft.util.IIcon; import net.minecraftforge.client.event.RenderPlayerEvent; - import org.lwjgl.opengl.GL11; - import vazkii.botania.api.item.IBaubleRender; import vazkii.botania.client.core.helper.IconHelper; import vazkii.botania.common.lib.LibItemNames; -import baubles.api.BaubleType; public class ItemLavaPendant extends ItemBauble implements IBaubleRender { - IIcon gemIcon; - - public ItemLavaPendant() { - super(LibItemNames.LAVA_PENDANT); - } + IIcon gemIcon; - @Override - public void onWornTick(ItemStack stack, EntityLivingBase player) { - if(player.isBurning()) - player.extinguish(); - } + public ItemLavaPendant() { + super(LibItemNames.LAVA_PENDANT); + } - @Override - public BaubleType getBaubleType(ItemStack itemstack) { - return BaubleType.AMULET; - } + @Override + public void onWornTick(ItemStack stack, EntityLivingBase player) { + if (player.isBurning()) player.extinguish(); + } - @Override - public void registerIcons(IIconRegister par1IconRegister) { - super.registerIcons(par1IconRegister); - gemIcon = IconHelper.forItem(par1IconRegister, this, "Gem"); - } + @Override + public BaubleType getBaubleType(ItemStack itemstack) { + return BaubleType.AMULET; + } - @Override - public void onPlayerBaubleRender(ItemStack stack, RenderPlayerEvent event, RenderType type) { - if(type == RenderType.BODY) { - Minecraft.getMinecraft().renderEngine.bindTexture(TextureMap.locationItemsTexture); - Helper.rotateIfSneaking(event.entityPlayer); - boolean armor = event.entityPlayer.getCurrentArmor(2) != null; - GL11.glRotatef(180F, 1F, 0F, 0F); - GL11.glTranslatef(-0.36F, -0.24F, armor ? 0.2F : 0.15F); - GL11.glRotatef(-45F, 0F, 0F, 1F); - GL11.glScalef(0.5F, 0.5F, 0.5F); + @Override + public void registerIcons(IIconRegister par1IconRegister) { + super.registerIcons(par1IconRegister); + gemIcon = IconHelper.forItem(par1IconRegister, this, "Gem"); + } - float f = gemIcon.getMinU(); - float f1 = gemIcon.getMaxU(); - float f2 = gemIcon.getMinV(); - float f3 = gemIcon.getMaxV(); - ItemRenderer.renderItemIn2D(Tessellator.instance, f1, f2, f, f3, gemIcon.getIconWidth(), gemIcon.getIconHeight(), 1F / 32F); - } - } + @Override + public void onPlayerBaubleRender(ItemStack stack, RenderPlayerEvent event, RenderType type) { + if (type == RenderType.BODY) { + Minecraft.getMinecraft().renderEngine.bindTexture(TextureMap.locationItemsTexture); + Helper.rotateIfSneaking(event.entityPlayer); + boolean armor = event.entityPlayer.getCurrentArmor(2) != null; + GL11.glRotatef(180F, 1F, 0F, 0F); + GL11.glTranslatef(-0.36F, -0.24F, armor ? 0.2F : 0.15F); + GL11.glRotatef(-45F, 0F, 0F, 1F); + GL11.glScalef(0.5F, 0.5F, 0.5F); + float f = gemIcon.getMinU(); + float f1 = gemIcon.getMaxU(); + float f2 = gemIcon.getMinV(); + float f3 = gemIcon.getMaxV(); + ItemRenderer.renderItemIn2D( + Tessellator.instance, f1, f2, f, f3, gemIcon.getIconWidth(), gemIcon.getIconHeight(), 1F / 32F); + } + } } diff --git a/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemMagnetRing.java b/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemMagnetRing.java index 6fab1bdb9c..96051606e0 100644 --- a/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemMagnetRing.java +++ b/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemMagnetRing.java @@ -2,17 +2,22 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [May 17, 2014, 3:16:36 PM (GMT)] */ package vazkii.botania.common.item.equipment.bauble; +import baubles.api.BaubleType; +import baubles.common.container.InventoryBaubles; +import baubles.common.lib.PlayerHandler; +import cpw.mods.fml.common.eventhandler.SubscribeEvent; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; import java.util.Arrays; import java.util.List; - import net.minecraft.block.Block; import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.entity.EntityLivingBase; @@ -33,138 +38,139 @@ import vazkii.botania.common.core.helper.MathHelper; import vazkii.botania.common.core.helper.Vector3; import vazkii.botania.common.lib.LibItemNames; -import baubles.api.BaubleType; -import baubles.common.container.InventoryBaubles; -import baubles.common.lib.PlayerHandler; -import cpw.mods.fml.common.eventhandler.SubscribeEvent; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; public class ItemMagnetRing extends ItemBauble { - IIcon iconOff; - - private static final String TAG_COOLDOWN = "cooldown"; - - private static final List BLACKLIST = Arrays.asList(new String[] { - "appliedenergistics2:item.ItemCrystalSeed", - }); - - int range; - - public ItemMagnetRing() { - this(LibItemNames.MAGNET_RING, 6); - MinecraftForge.EVENT_BUS.register(this); - } - - public ItemMagnetRing(String name, int range) { - super(name); - this.range = range; - } - - @Override - @SideOnly(Side.CLIENT) - public void registerIcons(IIconRegister par1IconRegister) { - itemIcon = IconHelper.forItem(par1IconRegister, this, 0); - iconOff = IconHelper.forItem(par1IconRegister, this, 1); - } - - @Override - @SideOnly(Side.CLIENT) - public IIcon getIconIndex(ItemStack stack) { - return getCooldown(stack) <= 0 ? itemIcon : iconOff; - } - - @SubscribeEvent - public void onTossItem(ItemTossEvent event) { - InventoryBaubles inv = PlayerHandler.getPlayerBaubles(event.player); - for(int i = 0; i < inv.getSizeInventory(); i++) { - ItemStack stack = inv.getStackInSlot(i); - if(stack != null && stack.getItem() instanceof ItemMagnetRing) { - setCooldown(stack, 100); - BotaniaAPI.internalHandler.sendBaubleUpdatePacket(event.player, i); - } - } - } - - @Override - public void onWornTick(ItemStack stack, EntityLivingBase player) { - super.onWornTick(stack, player); - - int cooldown = getCooldown(stack); - - if(SubTileSolegnolia.hasSolegnoliaAround(player)) { - if(cooldown < 0) - setCooldown(stack, 2); - return; - } - - if(cooldown <= 0) { - if(player.isSneaking() == ConfigHandler.invertMagnetRing) { - double x = player.posX; - double y = player.posY -(player.worldObj.isRemote ? 1.62 : 0) + 0.75; - double z = player.posZ; - - List items = player.worldObj.getEntitiesWithinAABB(EntityItem.class, AxisAlignedBB.getBoundingBox(x - range, y - range, z - range, x + range, y + range, z + range)); - int pulled = 0; - for(EntityItem item : items) - if(canPullItem(item)) { - if(pulled > 200) - break; - - MathHelper.setEntityMotionFromVector(item, new Vector3(x, y, z), 0.45F); - if(player.worldObj.isRemote) { - boolean red = player.worldObj.rand.nextBoolean(); - Botania.proxy.sparkleFX(player.worldObj, item.posX, item.posY, item.posZ, red ? 1F : 0F, 0F, red ? 0F : 1F, 1F, 3); - } - pulled++; - } - } - } else setCooldown(stack, cooldown - 1); - } - - private boolean canPullItem(EntityItem item) { - if(item.isDead || SubTileSolegnolia.hasSolegnoliaAround(item)) - return false; - - ItemStack stack = item.getEntityItem(); - if(stack == null || stack.getItem() instanceof IManaItem || stack.getItem() instanceof IRelic || BLACKLIST.contains(itemRegistry.getNameForObject(stack.getItem())) || BotaniaAPI.isItemBlacklistedFromMagnet(stack)) - return false; - - int x = net.minecraft.util.MathHelper.floor_double(item.posX); - int y = (int) Math.floor(item.posY); - int z = net.minecraft.util.MathHelper.floor_double(item.posZ); - Block block = item.worldObj.getBlock(x, y, z); - int meta = item.worldObj.getBlockMetadata(x, y, z); - - if(BotaniaAPI.isBlockBlacklistedFromMagnet(block, meta)) - return false; - - block = item.worldObj.getBlock(x, y - 1, z); - meta = item.worldObj.getBlockMetadata(x, y - 1, z); - - if(BotaniaAPI.isBlockBlacklistedFromMagnet(block, meta)) - return false; - - return true; - } - - public static int getCooldown(ItemStack stack) { - return ItemNBTHelper.getInt(stack, TAG_COOLDOWN, 0); - } - - public static void setCooldown(ItemStack stack, int cooldown) { - ItemNBTHelper.setInt(stack, TAG_COOLDOWN, cooldown); - } - - public static void addItemToBlackList(String item) { - BLACKLIST.add(item); - } - - @Override - public BaubleType getBaubleType(ItemStack arg0) { - return BaubleType.RING; - } - - + IIcon iconOff; + + private static final String TAG_COOLDOWN = "cooldown"; + + private static final List BLACKLIST = Arrays.asList(new String[] { + "appliedenergistics2:item.ItemCrystalSeed", + }); + + int range; + + public ItemMagnetRing() { + this(LibItemNames.MAGNET_RING, 6); + MinecraftForge.EVENT_BUS.register(this); + } + + public ItemMagnetRing(String name, int range) { + super(name); + this.range = range; + } + + @Override + @SideOnly(Side.CLIENT) + public void registerIcons(IIconRegister par1IconRegister) { + itemIcon = IconHelper.forItem(par1IconRegister, this, 0); + iconOff = IconHelper.forItem(par1IconRegister, this, 1); + } + + @Override + @SideOnly(Side.CLIENT) + public IIcon getIconIndex(ItemStack stack) { + return getCooldown(stack) <= 0 ? itemIcon : iconOff; + } + + @SubscribeEvent + public void onTossItem(ItemTossEvent event) { + InventoryBaubles inv = PlayerHandler.getPlayerBaubles(event.player); + for (int i = 0; i < inv.getSizeInventory(); i++) { + ItemStack stack = inv.getStackInSlot(i); + if (stack != null && stack.getItem() instanceof ItemMagnetRing) { + setCooldown(stack, 100); + BotaniaAPI.internalHandler.sendBaubleUpdatePacket(event.player, i); + } + } + } + + @Override + public void onWornTick(ItemStack stack, EntityLivingBase player) { + super.onWornTick(stack, player); + + int cooldown = getCooldown(stack); + + if (SubTileSolegnolia.hasSolegnoliaAround(player)) { + if (cooldown < 0) setCooldown(stack, 2); + return; + } + + if (cooldown <= 0) { + if (player.isSneaking() == ConfigHandler.invertMagnetRing) { + double x = player.posX; + double y = player.posY - (player.worldObj.isRemote ? 1.62 : 0) + 0.75; + double z = player.posZ; + + List items = player.worldObj.getEntitiesWithinAABB( + EntityItem.class, + AxisAlignedBB.getBoundingBox(x - range, y - range, z - range, x + range, y + range, z + range)); + int pulled = 0; + for (EntityItem item : items) + if (canPullItem(item)) { + if (pulled > 200) break; + + MathHelper.setEntityMotionFromVector(item, new Vector3(x, y, z), 0.45F); + if (player.worldObj.isRemote) { + boolean red = player.worldObj.rand.nextBoolean(); + Botania.proxy.sparkleFX( + player.worldObj, + item.posX, + item.posY, + item.posZ, + red ? 1F : 0F, + 0F, + red ? 0F : 1F, + 1F, + 3); + } + pulled++; + } + } + } else setCooldown(stack, cooldown - 1); + } + + private boolean canPullItem(EntityItem item) { + if (item.isDead || SubTileSolegnolia.hasSolegnoliaAround(item)) return false; + + ItemStack stack = item.getEntityItem(); + if (stack == null + || stack.getItem() instanceof IManaItem + || stack.getItem() instanceof IRelic + || BLACKLIST.contains(itemRegistry.getNameForObject(stack.getItem())) + || BotaniaAPI.isItemBlacklistedFromMagnet(stack)) return false; + + int x = net.minecraft.util.MathHelper.floor_double(item.posX); + int y = (int) Math.floor(item.posY); + int z = net.minecraft.util.MathHelper.floor_double(item.posZ); + Block block = item.worldObj.getBlock(x, y, z); + int meta = item.worldObj.getBlockMetadata(x, y, z); + + if (BotaniaAPI.isBlockBlacklistedFromMagnet(block, meta)) return false; + + block = item.worldObj.getBlock(x, y - 1, z); + meta = item.worldObj.getBlockMetadata(x, y - 1, z); + + if (BotaniaAPI.isBlockBlacklistedFromMagnet(block, meta)) return false; + + return true; + } + + public static int getCooldown(ItemStack stack) { + return ItemNBTHelper.getInt(stack, TAG_COOLDOWN, 0); + } + + public static void setCooldown(ItemStack stack, int cooldown) { + ItemNBTHelper.setInt(stack, TAG_COOLDOWN, cooldown); + } + + public static void addItemToBlackList(String item) { + BLACKLIST.add(item); + } + + @Override + public BaubleType getBaubleType(ItemStack arg0) { + return BaubleType.RING; + } } diff --git a/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemManaRing.java b/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemManaRing.java index b5f3665e87..cd3894bfc5 100644 --- a/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemManaRing.java +++ b/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemManaRing.java @@ -2,16 +2,16 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Apr 24, 2014, 2:55:28 PM (GMT)] */ package vazkii.botania.common.item.equipment.bauble; +import baubles.api.BaubleType; import java.util.List; - import net.minecraft.creativetab.CreativeTabs; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; @@ -21,99 +21,97 @@ import vazkii.botania.api.mana.IManaTooltipDisplay; import vazkii.botania.common.core.helper.ItemNBTHelper; import vazkii.botania.common.lib.LibItemNames; -import baubles.api.BaubleType; public class ItemManaRing extends ItemBauble implements IManaItem, IManaTooltipDisplay { - protected static final int MAX_MANA = 500000; - - private static final String TAG_MANA = "mana"; - - public ItemManaRing() { - this(LibItemNames.MANA_RING); - setMaxDamage(1000); - setNoRepair(); - } - - public ItemManaRing(String name) { - super(name); - setMaxDamage(1000); - } - - @Override - public BaubleType getBaubleType(ItemStack itemstack) { - return BaubleType.RING; - } - - @Override - public void getSubItems(Item par1, CreativeTabs par2CreativeTabs, List par3List) { - par3List.add(new ItemStack(par1, 1, 10000)); - } - - @Override - public int getDamage(ItemStack stack) { - float mana = getMana(stack); - return 1000 - (int) (mana / getMaxMana(stack) * 1000); - } - - @Override - public int getDisplayDamage(ItemStack stack) { - return getDamage(stack); - } - - @Override - public int getEntityLifespan(ItemStack itemStack, World world) { - return Integer.MAX_VALUE; - } - - public static void setMana(ItemStack stack, int mana) { - ItemNBTHelper.setInt(stack, TAG_MANA, mana); - } - - @Override - public int getMana(ItemStack stack) { - return ItemNBTHelper.getInt(stack, TAG_MANA, 0); - } - - @Override - public int getMaxMana(ItemStack stack) { - return MAX_MANA; - } - - @Override - public void addMana(ItemStack stack, int mana) { - setMana(stack, Math.min(getMana(stack) + mana, getMaxMana(stack))); - stack.setItemDamage(getDamage(stack)); - } - - @Override - public boolean canReceiveManaFromPool(ItemStack stack, TileEntity pool) { - return true; - } - - @Override - public boolean canReceiveManaFromItem(ItemStack stack, ItemStack otherStack) { - return true; - } - - @Override - public boolean canExportManaToPool(ItemStack stack, TileEntity pool) { - return true; - } - - @Override - public boolean canExportManaToItem(ItemStack stack, ItemStack otherStack) { - return true; - } - - @Override - public boolean isNoExport(ItemStack stack) { - return false; - } - - @Override - public float getManaFractionForDisplay(ItemStack stack) { - return (float) getMana(stack) / (float) getMaxMana(stack); - } - + protected static final int MAX_MANA = 500000; + + private static final String TAG_MANA = "mana"; + + public ItemManaRing() { + this(LibItemNames.MANA_RING); + setMaxDamage(1000); + setNoRepair(); + } + + public ItemManaRing(String name) { + super(name); + setMaxDamage(1000); + } + + @Override + public BaubleType getBaubleType(ItemStack itemstack) { + return BaubleType.RING; + } + + @Override + public void getSubItems(Item par1, CreativeTabs par2CreativeTabs, List par3List) { + par3List.add(new ItemStack(par1, 1, 10000)); + } + + @Override + public int getDamage(ItemStack stack) { + float mana = getMana(stack); + return 1000 - (int) (mana / getMaxMana(stack) * 1000); + } + + @Override + public int getDisplayDamage(ItemStack stack) { + return getDamage(stack); + } + + @Override + public int getEntityLifespan(ItemStack itemStack, World world) { + return Integer.MAX_VALUE; + } + + public static void setMana(ItemStack stack, int mana) { + ItemNBTHelper.setInt(stack, TAG_MANA, mana); + } + + @Override + public int getMana(ItemStack stack) { + return ItemNBTHelper.getInt(stack, TAG_MANA, 0); + } + + @Override + public int getMaxMana(ItemStack stack) { + return MAX_MANA; + } + + @Override + public void addMana(ItemStack stack, int mana) { + setMana(stack, Math.min(getMana(stack) + mana, getMaxMana(stack))); + stack.setItemDamage(getDamage(stack)); + } + + @Override + public boolean canReceiveManaFromPool(ItemStack stack, TileEntity pool) { + return true; + } + + @Override + public boolean canReceiveManaFromItem(ItemStack stack, ItemStack otherStack) { + return true; + } + + @Override + public boolean canExportManaToPool(ItemStack stack, TileEntity pool) { + return true; + } + + @Override + public boolean canExportManaToItem(ItemStack stack, ItemStack otherStack) { + return true; + } + + @Override + public boolean isNoExport(ItemStack stack) { + return false; + } + + @Override + public float getManaFractionForDisplay(ItemStack stack) { + return (float) getMana(stack) / (float) getMaxMana(stack); + } } diff --git a/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemMiningRing.java b/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemMiningRing.java index 0a6f6f8c4f..8a95e26af5 100644 --- a/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemMiningRing.java +++ b/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemMiningRing.java @@ -2,14 +2,15 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [May 17, 2014, 4:12:46 PM (GMT)] */ package vazkii.botania.common.item.equipment.bauble; +import baubles.api.BaubleType; import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; @@ -18,50 +19,46 @@ import vazkii.botania.api.mana.IManaUsingItem; import vazkii.botania.api.mana.ManaItemHandler; import vazkii.botania.common.lib.LibItemNames; -import baubles.api.BaubleType; public class ItemMiningRing extends ItemBauble implements IManaUsingItem { - public ItemMiningRing() { - super(LibItemNames.MINING_RING); - } - - @Override - public void onWornTick(ItemStack stack, EntityLivingBase player) { - super.onWornTick(stack, player); + public ItemMiningRing() { + super(LibItemNames.MINING_RING); + } - if(player instanceof EntityPlayer && !player.worldObj.isRemote) { - int manaCost = 5; - boolean hasMana = ManaItemHandler.requestManaExact(stack, (EntityPlayer) player, manaCost, false); - if(!hasMana) - onUnequipped(stack, player); - else { - if(player.getActivePotionEffect(Potion.digSpeed) != null) - player.removePotionEffect(Potion.digSpeed.id); + @Override + public void onWornTick(ItemStack stack, EntityLivingBase player) { + super.onWornTick(stack, player); - player.addPotionEffect(new PotionEffect(Potion.digSpeed.id, Integer.MAX_VALUE, 1, true)); - } + if (player instanceof EntityPlayer && !player.worldObj.isRemote) { + int manaCost = 5; + boolean hasMana = ManaItemHandler.requestManaExact(stack, (EntityPlayer) player, manaCost, false); + if (!hasMana) onUnequipped(stack, player); + else { + if (player.getActivePotionEffect(Potion.digSpeed) != null) + player.removePotionEffect(Potion.digSpeed.id); - if(player.swingProgress == 0.25F) - ManaItemHandler.requestManaExact(stack, (EntityPlayer) player, manaCost, true); - } - } + player.addPotionEffect(new PotionEffect(Potion.digSpeed.id, Integer.MAX_VALUE, 1, true)); + } - @Override - public void onUnequipped(ItemStack stack, EntityLivingBase player) { - PotionEffect effect = player.getActivePotionEffect(Potion.digSpeed); - if(effect != null && effect.getAmplifier() == 1) - player.removePotionEffect(Potion.digSpeed.id); - } + if (player.swingProgress == 0.25F) + ManaItemHandler.requestManaExact(stack, (EntityPlayer) player, manaCost, true); + } + } - @Override - public BaubleType getBaubleType(ItemStack arg0) { - return BaubleType.RING; - } + @Override + public void onUnequipped(ItemStack stack, EntityLivingBase player) { + PotionEffect effect = player.getActivePotionEffect(Potion.digSpeed); + if (effect != null && effect.getAmplifier() == 1) player.removePotionEffect(Potion.digSpeed.id); + } - @Override - public boolean usesMana(ItemStack stack) { - return true; - } + @Override + public BaubleType getBaubleType(ItemStack arg0) { + return BaubleType.RING; + } + @Override + public boolean usesMana(ItemStack stack) { + return true; + } } diff --git a/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemMonocle.java b/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemMonocle.java index f2af5e85e6..68f4851de2 100644 --- a/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemMonocle.java +++ b/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemMonocle.java @@ -2,14 +2,18 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jan 24, 2015, 3:03:18 PM (GMT)] */ package vazkii.botania.common.item.equipment.bauble; +import baubles.api.BaubleType; +import baubles.common.lib.PlayerHandler; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; import net.minecraft.block.Block; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.ScaledResolution; @@ -25,102 +29,92 @@ import net.minecraft.util.EnumChatFormatting; import net.minecraft.util.MovingObjectPosition; import net.minecraftforge.client.event.RenderPlayerEvent; - import org.lwjgl.opengl.GL11; - import vazkii.botania.api.item.IBurstViewerBauble; import vazkii.botania.api.item.ICosmeticAttachable; import vazkii.botania.api.item.ICosmeticBauble; import vazkii.botania.common.lib.LibItemNames; -import baubles.api.BaubleType; -import baubles.common.lib.PlayerHandler; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; public class ItemMonocle extends ItemBauble implements IBurstViewerBauble, ICosmeticBauble { - public ItemMonocle() { - super(LibItemNames.MONOCLE); - } - - @Override - public BaubleType getBaubleType(ItemStack arg0) { - return BaubleType.AMULET; - } - - @Override - public void onPlayerBaubleRender(ItemStack stack, RenderPlayerEvent event, RenderType type) { - if(type == RenderType.HEAD) { - float f = itemIcon.getMinU(); - float f1 = itemIcon.getMaxU(); - float f2 = itemIcon.getMinV(); - float f3 = itemIcon.getMaxV(); - boolean armor = event.entityPlayer.getCurrentArmor(3) != null; - Helper.translateToHeadLevel(event.entityPlayer); - Minecraft.getMinecraft().renderEngine.bindTexture(TextureMap.locationItemsTexture); - GL11.glRotatef(90F, 0F, 1F, 0F); - GL11.glRotatef(180F, 1F, 0F, 0F); - GL11.glTranslatef(-0.35F, -0.1F, armor ? -0.3F : -0.25F); - GL11.glScalef(0.35F, 0.35F, 0.35F); - ItemRenderer.renderItemIn2D(Tessellator.instance, f1, f2, f, f3, itemIcon.getIconWidth(), itemIcon.getIconHeight(), 1F / 16F); - } - } - - @SideOnly(Side.CLIENT) - public static void renderHUD(ScaledResolution resolution, EntityPlayer player) { - Minecraft mc = Minecraft.getMinecraft(); - MovingObjectPosition pos = mc.objectMouseOver; - if(pos == null) - return; - Block block = player.worldObj.getBlock(pos.blockX, pos.blockY, pos.blockZ); - int meta = player.worldObj.getBlockMetadata(pos.blockX, pos.blockY, pos.blockZ); - player.worldObj.getTileEntity(pos.blockX, pos.blockY, pos.blockZ); - - ItemStack dispStack = null; - String text = ""; - - if(block == Blocks.redstone_wire) { - dispStack = new ItemStack(Items.redstone); - text = EnumChatFormatting.RED + "" + meta; - } else if(block == Blocks.unpowered_repeater || block == Blocks.powered_repeater) { - dispStack = new ItemStack(Items.repeater); - text = "" + (((meta & 12) >> 2) + 1); - } else if(block == Blocks.unpowered_comparator || block == Blocks.powered_comparator) { - dispStack = new ItemStack(Items.comparator); - text = (meta & 4) == 4 ? "-" : "+"; - } - - if(dispStack == null) - return; - - int x = resolution.getScaledWidth() / 2 + 15; - int y = resolution.getScaledHeight() / 2 - 8; - - net.minecraft.client.renderer.RenderHelper.enableGUIStandardItemLighting(); - RenderItem.getInstance().renderItemAndEffectIntoGUI(mc.fontRenderer, mc.renderEngine, dispStack, x, y); - net.minecraft.client.renderer.RenderHelper.disableStandardItemLighting(); - - mc.fontRenderer.drawStringWithShadow(text, x + 20, y + 4, 0xFFFFFF); - } - - public static boolean hasMonocle(EntityPlayer player) { - for(int i = 0; i < 4; i++) { - ItemStack stack = PlayerHandler.getPlayerBaubles(player).getStackInSlot(i); - if(stack != null) { - Item item = stack.getItem(); - if(item instanceof IBurstViewerBauble) - return true; - - if(item instanceof ICosmeticAttachable) { - ICosmeticAttachable attach = (ICosmeticAttachable) item; - ItemStack cosmetic = attach.getCosmeticItem(stack); - if(cosmetic != null && cosmetic.getItem() instanceof IBurstViewerBauble) - return true; - } - } - } - - return false; - } - + public ItemMonocle() { + super(LibItemNames.MONOCLE); + } + + @Override + public BaubleType getBaubleType(ItemStack arg0) { + return BaubleType.AMULET; + } + + @Override + public void onPlayerBaubleRender(ItemStack stack, RenderPlayerEvent event, RenderType type) { + if (type == RenderType.HEAD) { + float f = itemIcon.getMinU(); + float f1 = itemIcon.getMaxU(); + float f2 = itemIcon.getMinV(); + float f3 = itemIcon.getMaxV(); + boolean armor = event.entityPlayer.getCurrentArmor(3) != null; + Helper.translateToHeadLevel(event.entityPlayer); + Minecraft.getMinecraft().renderEngine.bindTexture(TextureMap.locationItemsTexture); + GL11.glRotatef(90F, 0F, 1F, 0F); + GL11.glRotatef(180F, 1F, 0F, 0F); + GL11.glTranslatef(-0.35F, -0.1F, armor ? -0.3F : -0.25F); + GL11.glScalef(0.35F, 0.35F, 0.35F); + ItemRenderer.renderItemIn2D( + Tessellator.instance, f1, f2, f, f3, itemIcon.getIconWidth(), itemIcon.getIconHeight(), 1F / 16F); + } + } + + @SideOnly(Side.CLIENT) + public static void renderHUD(ScaledResolution resolution, EntityPlayer player) { + Minecraft mc = Minecraft.getMinecraft(); + MovingObjectPosition pos = mc.objectMouseOver; + if (pos == null) return; + Block block = player.worldObj.getBlock(pos.blockX, pos.blockY, pos.blockZ); + int meta = player.worldObj.getBlockMetadata(pos.blockX, pos.blockY, pos.blockZ); + player.worldObj.getTileEntity(pos.blockX, pos.blockY, pos.blockZ); + + ItemStack dispStack = null; + String text = ""; + + if (block == Blocks.redstone_wire) { + dispStack = new ItemStack(Items.redstone); + text = EnumChatFormatting.RED + "" + meta; + } else if (block == Blocks.unpowered_repeater || block == Blocks.powered_repeater) { + dispStack = new ItemStack(Items.repeater); + text = "" + (((meta & 12) >> 2) + 1); + } else if (block == Blocks.unpowered_comparator || block == Blocks.powered_comparator) { + dispStack = new ItemStack(Items.comparator); + text = (meta & 4) == 4 ? "-" : "+"; + } + + if (dispStack == null) return; + + int x = resolution.getScaledWidth() / 2 + 15; + int y = resolution.getScaledHeight() / 2 - 8; + + net.minecraft.client.renderer.RenderHelper.enableGUIStandardItemLighting(); + RenderItem.getInstance().renderItemAndEffectIntoGUI(mc.fontRenderer, mc.renderEngine, dispStack, x, y); + net.minecraft.client.renderer.RenderHelper.disableStandardItemLighting(); + + mc.fontRenderer.drawStringWithShadow(text, x + 20, y + 4, 0xFFFFFF); + } + + public static boolean hasMonocle(EntityPlayer player) { + for (int i = 0; i < 4; i++) { + ItemStack stack = PlayerHandler.getPlayerBaubles(player).getStackInSlot(i); + if (stack != null) { + Item item = stack.getItem(); + if (item instanceof IBurstViewerBauble) return true; + + if (item instanceof ICosmeticAttachable) { + ICosmeticAttachable attach = (ICosmeticAttachable) item; + ItemStack cosmetic = attach.getCosmeticItem(stack); + if (cosmetic != null && cosmetic.getItem() instanceof IBurstViewerBauble) return true; + } + } + } + + return false; + } } diff --git a/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemPixieRing.java b/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemPixieRing.java index d3055c7d36..62827f6e75 100644 --- a/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemPixieRing.java +++ b/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemPixieRing.java @@ -2,33 +2,32 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jun 20, 2014, 6:13:45 PM (GMT)] */ package vazkii.botania.common.item.equipment.bauble; +import baubles.api.BaubleType; import net.minecraft.item.ItemStack; import vazkii.botania.api.item.IPixieSpawner; import vazkii.botania.common.lib.LibItemNames; -import baubles.api.BaubleType; public class ItemPixieRing extends ItemBauble implements IPixieSpawner { - public ItemPixieRing() { - super(LibItemNames.PIXIE_RING); - } - - @Override - public BaubleType getBaubleType(ItemStack arg0) { - return BaubleType.RING; - } + public ItemPixieRing() { + super(LibItemNames.PIXIE_RING); + } - @Override - public float getPixieChance(ItemStack stack) { - return 0.075F; - } + @Override + public BaubleType getBaubleType(ItemStack arg0) { + return BaubleType.RING; + } + @Override + public float getPixieChance(ItemStack stack) { + return 0.075F; + } } diff --git a/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemReachRing.java b/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemReachRing.java index 6d9fa50a91..08609ae867 100644 --- a/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemReachRing.java +++ b/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemReachRing.java @@ -2,39 +2,38 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jul 22, 2014, 3:00:09 PM (GMT)] */ package vazkii.botania.common.item.equipment.bauble; +import baubles.api.BaubleType; import net.minecraft.entity.EntityLivingBase; import net.minecraft.item.ItemStack; import vazkii.botania.common.Botania; import vazkii.botania.common.lib.LibItemNames; -import baubles.api.BaubleType; public class ItemReachRing extends ItemBauble { - public ItemReachRing() { - super(LibItemNames.REACH_RING); - } - - @Override - public void onEquippedOrLoadedIntoWorld(ItemStack stack, EntityLivingBase player) { - Botania.proxy.setExtraReach(player, 3.5F); - } + public ItemReachRing() { + super(LibItemNames.REACH_RING); + } - @Override - public void onUnequipped(ItemStack stack, EntityLivingBase player) { - Botania.proxy.setExtraReach(player, -3.5F); - } + @Override + public void onEquippedOrLoadedIntoWorld(ItemStack stack, EntityLivingBase player) { + Botania.proxy.setExtraReach(player, 3.5F); + } - @Override - public BaubleType getBaubleType(ItemStack arg0) { - return BaubleType.RING; - } + @Override + public void onUnequipped(ItemStack stack, EntityLivingBase player) { + Botania.proxy.setExtraReach(player, -3.5F); + } + @Override + public BaubleType getBaubleType(ItemStack arg0) { + return BaubleType.RING; + } } diff --git a/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemSpeedUpBelt.java b/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemSpeedUpBelt.java index 36022a24d6..8c7903358c 100644 --- a/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemSpeedUpBelt.java +++ b/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemSpeedUpBelt.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [24/11/2015, 22:50:29 (GMT)] */ package vazkii.botania.common.item.equipment.bauble; @@ -19,52 +19,51 @@ public class ItemSpeedUpBelt extends ItemTravelBelt { - private static final ResourceLocation texture = new ResourceLocation(LibResources.MODEL_SPEED_UP_BELT); + private static final ResourceLocation texture = new ResourceLocation(LibResources.MODEL_SPEED_UP_BELT); - private static final String TAG_SPEED = "speed"; - private static final String TAG_OLD_X = "oldX"; - private static final String TAG_OLD_Y = "oldY"; - private static final String TAG_OLD_Z = "oldZ"; + private static final String TAG_SPEED = "speed"; + private static final String TAG_OLD_X = "oldX"; + private static final String TAG_OLD_Y = "oldY"; + private static final String TAG_OLD_Z = "oldZ"; - public ItemSpeedUpBelt() { - super(LibItemNames.SPEED_UP_BELT, 0F, 0.2F, 2F); - } + public ItemSpeedUpBelt() { + super(LibItemNames.SPEED_UP_BELT, 0F, 0.2F, 2F); + } - @Override - public ResourceLocation getRenderTexture() { - return texture; - } + @Override + public ResourceLocation getRenderTexture() { + return texture; + } - @Override - public float getSpeed(ItemStack stack) { - return ItemNBTHelper.getFloat(stack, TAG_SPEED, 0F); - } + @Override + public float getSpeed(ItemStack stack) { + return ItemNBTHelper.getFloat(stack, TAG_SPEED, 0F); + } - @Override - public void onMovedTick(ItemStack stack, EntityPlayer player) { - float speed = getSpeed(stack); - float newspeed = Math.min(0.25F, speed + 0.00035F); - ItemNBTHelper.setFloat(stack, TAG_SPEED, newspeed); - commitPositionAndCompare(stack, player); - } + @Override + public void onMovedTick(ItemStack stack, EntityPlayer player) { + float speed = getSpeed(stack); + float newspeed = Math.min(0.25F, speed + 0.00035F); + ItemNBTHelper.setFloat(stack, TAG_SPEED, newspeed); + commitPositionAndCompare(stack, player); + } - @Override - public void onNotMovingTick(ItemStack stack, EntityPlayer player) { - if(!commitPositionAndCompare(stack, player)) - ItemNBTHelper.setFloat(stack, TAG_SPEED, 0F); - } + @Override + public void onNotMovingTick(ItemStack stack, EntityPlayer player) { + if (!commitPositionAndCompare(stack, player)) ItemNBTHelper.setFloat(stack, TAG_SPEED, 0F); + } - public boolean commitPositionAndCompare(ItemStack stack, EntityPlayer player) { - double oldX = ItemNBTHelper.getDouble(stack, TAG_OLD_X, 0); - double oldY = ItemNBTHelper.getDouble(stack, TAG_OLD_Y, 0); - double oldZ = ItemNBTHelper.getDouble(stack, TAG_OLD_Z, 0); + public boolean commitPositionAndCompare(ItemStack stack, EntityPlayer player) { + double oldX = ItemNBTHelper.getDouble(stack, TAG_OLD_X, 0); + double oldY = ItemNBTHelper.getDouble(stack, TAG_OLD_Y, 0); + double oldZ = ItemNBTHelper.getDouble(stack, TAG_OLD_Z, 0); - ItemNBTHelper.setDouble(stack, TAG_OLD_X, player.posX); - ItemNBTHelper.setDouble(stack, TAG_OLD_Y, player.posY); - ItemNBTHelper.setDouble(stack, TAG_OLD_Z, player.posZ); - - return Math.abs(oldX - player.posX) > 0.001 || Math.abs(oldY - player.posY) > 0.001 || Math.abs(oldZ - player.posZ) > 0.001; - } + ItemNBTHelper.setDouble(stack, TAG_OLD_X, player.posX); + ItemNBTHelper.setDouble(stack, TAG_OLD_Y, player.posY); + ItemNBTHelper.setDouble(stack, TAG_OLD_Z, player.posZ); + return Math.abs(oldX - player.posX) > 0.001 + || Math.abs(oldY - player.posY) > 0.001 + || Math.abs(oldZ - player.posZ) > 0.001; + } } - diff --git a/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemSuperLavaPendant.java b/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemSuperLavaPendant.java index dc776b4ca9..c9eb381348 100644 --- a/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemSuperLavaPendant.java +++ b/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemSuperLavaPendant.java @@ -2,14 +2,16 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jul 31, 2014, 6:09:17 PM (GMT)] */ package vazkii.botania.common.item.equipment.bauble; +import baubles.api.BaubleType; +import cpw.mods.fml.relauncher.ReflectionHelper; import net.minecraft.client.Minecraft; import net.minecraft.client.renderer.ItemRenderer; import net.minecraft.client.renderer.Tessellator; @@ -20,65 +22,62 @@ import net.minecraft.item.ItemStack; import net.minecraft.util.IIcon; import net.minecraftforge.client.event.RenderPlayerEvent; - import org.lwjgl.opengl.GL11; - import vazkii.botania.api.item.IBaubleRender; import vazkii.botania.client.core.helper.IconHelper; import vazkii.botania.common.lib.LibItemNames; import vazkii.botania.common.lib.LibObfuscation; -import baubles.api.BaubleType; -import cpw.mods.fml.relauncher.ReflectionHelper; public class ItemSuperLavaPendant extends ItemBauble implements IBaubleRender { - IIcon gemIcon; + IIcon gemIcon; - public ItemSuperLavaPendant() { - super(LibItemNames.SUPER_LAVA_PENDANT); - } + public ItemSuperLavaPendant() { + super(LibItemNames.SUPER_LAVA_PENDANT); + } - @Override - public void onWornTick(ItemStack stack, EntityLivingBase player) { - setImmunity(player, true); - } + @Override + public void onWornTick(ItemStack stack, EntityLivingBase player) { + setImmunity(player, true); + } - @Override - public void onUnequipped(ItemStack stack, EntityLivingBase player) { - setImmunity(player, false); - } + @Override + public void onUnequipped(ItemStack stack, EntityLivingBase player) { + setImmunity(player, false); + } - private void setImmunity(Entity entity, boolean immune) { - ReflectionHelper.setPrivateValue(Entity.class, entity, immune, LibObfuscation.IS_IMMUNE_TO_FIRE); - } + private void setImmunity(Entity entity, boolean immune) { + ReflectionHelper.setPrivateValue(Entity.class, entity, immune, LibObfuscation.IS_IMMUNE_TO_FIRE); + } - @Override - public BaubleType getBaubleType(ItemStack itemstack) { - return BaubleType.AMULET; - } + @Override + public BaubleType getBaubleType(ItemStack itemstack) { + return BaubleType.AMULET; + } - @Override - public void registerIcons(IIconRegister par1IconRegister) { - super.registerIcons(par1IconRegister); - gemIcon = IconHelper.forItem(par1IconRegister, this, "Gem"); - } + @Override + public void registerIcons(IIconRegister par1IconRegister) { + super.registerIcons(par1IconRegister); + gemIcon = IconHelper.forItem(par1IconRegister, this, "Gem"); + } - @Override - public void onPlayerBaubleRender(ItemStack stack, RenderPlayerEvent event, RenderType type) { - if(type == RenderType.BODY) { - Minecraft.getMinecraft().renderEngine.bindTexture(TextureMap.locationItemsTexture); - Helper.rotateIfSneaking(event.entityPlayer); - boolean armor = event.entityPlayer.getCurrentArmor(2) != null; - GL11.glRotatef(180F, 1F, 0F, 0F); - GL11.glTranslatef(-0.36F, -0.24F, armor ? 0.2F : 0.15F); - GL11.glRotatef(-45F, 0F, 0F, 1F); - GL11.glScalef(0.5F, 0.5F, 0.5F); + @Override + public void onPlayerBaubleRender(ItemStack stack, RenderPlayerEvent event, RenderType type) { + if (type == RenderType.BODY) { + Minecraft.getMinecraft().renderEngine.bindTexture(TextureMap.locationItemsTexture); + Helper.rotateIfSneaking(event.entityPlayer); + boolean armor = event.entityPlayer.getCurrentArmor(2) != null; + GL11.glRotatef(180F, 1F, 0F, 0F); + GL11.glTranslatef(-0.36F, -0.24F, armor ? 0.2F : 0.15F); + GL11.glRotatef(-45F, 0F, 0F, 1F); + GL11.glScalef(0.5F, 0.5F, 0.5F); - float f = gemIcon.getMinU(); - float f1 = gemIcon.getMaxU(); - float f2 = gemIcon.getMinV(); - float f3 = gemIcon.getMaxV(); - ItemRenderer.renderItemIn2D(Tessellator.instance, f1, f2, f, f3, gemIcon.getIconWidth(), gemIcon.getIconHeight(), 1F / 32F); - } - } + float f = gemIcon.getMinU(); + float f1 = gemIcon.getMaxU(); + float f2 = gemIcon.getMinV(); + float f3 = gemIcon.getMaxV(); + ItemRenderer.renderItemIn2D( + Tessellator.instance, f1, f2, f, f3, gemIcon.getIconWidth(), gemIcon.getIconHeight(), 1F / 32F); + } + } } diff --git a/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemSuperTravelBelt.java b/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemSuperTravelBelt.java index f884e615bd..b15aa0c3b3 100644 --- a/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemSuperTravelBelt.java +++ b/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemSuperTravelBelt.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jun 20, 2014, 6:26:40 PM (GMT)] */ package vazkii.botania.common.item.equipment.bauble; @@ -16,14 +16,14 @@ public class ItemSuperTravelBelt extends ItemTravelBelt { - private static final ResourceLocation texture = new ResourceLocation(LibResources.MODEL_SUPER_TRAVEL_BELT); + private static final ResourceLocation texture = new ResourceLocation(LibResources.MODEL_SUPER_TRAVEL_BELT); - public ItemSuperTravelBelt() { - super(LibItemNames.SUPER_TRAVEL_BELT, 0.085F, 0.3F, 4F); - } + public ItemSuperTravelBelt() { + super(LibItemNames.SUPER_TRAVEL_BELT, 0.085F, 0.3F, 4F); + } - @Override - public ResourceLocation getRenderTexture() { - return texture; - } + @Override + public ResourceLocation getRenderTexture() { + return texture; + } } diff --git a/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemSwapRing.java b/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemSwapRing.java index 423b2feeb7..367e643734 100644 --- a/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemSwapRing.java +++ b/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemSwapRing.java @@ -2,14 +2,15 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Feb 23, 2015, 7:21:52 PM (GMT)] */ package vazkii.botania.common.item.equipment.bauble; +import baubles.api.BaubleType; import net.minecraft.block.Block; import net.minecraft.block.material.Material; import net.minecraft.entity.EntityLivingBase; @@ -20,74 +21,67 @@ import vazkii.botania.api.item.ISortableTool.ToolType; import vazkii.botania.common.item.equipment.tool.ToolCommons; import vazkii.botania.common.lib.LibItemNames; -import baubles.api.BaubleType; public class ItemSwapRing extends ItemBauble { - public ItemSwapRing() { - super(LibItemNames.SWAP_RING); - } - - @Override - public void onWornTick(ItemStack stack, EntityLivingBase entity) { - if(!(entity instanceof EntityPlayer)) - return; + public ItemSwapRing() { + super(LibItemNames.SWAP_RING); + } - EntityPlayer player = (EntityPlayer) entity; - ItemStack currentStack = player.getCurrentEquippedItem(); - if(currentStack == null || !(currentStack.getItem() instanceof ISortableTool)) - return; + @Override + public void onWornTick(ItemStack stack, EntityLivingBase entity) { + if (!(entity instanceof EntityPlayer)) return; - ISortableTool tool = (ISortableTool) currentStack.getItem(); + EntityPlayer player = (EntityPlayer) entity; + ItemStack currentStack = player.getCurrentEquippedItem(); + if (currentStack == null || !(currentStack.getItem() instanceof ISortableTool)) return; - MovingObjectPosition pos = ToolCommons.raytraceFromEntity(entity.worldObj, entity, true, 4.5F); - ToolType typeToFind = null; + ISortableTool tool = (ISortableTool) currentStack.getItem(); - if(player.isSwingInProgress && pos != null) { - Block block = entity.worldObj.getBlock(pos.blockX, pos.blockY, pos.blockZ); + MovingObjectPosition pos = ToolCommons.raytraceFromEntity(entity.worldObj, entity, true, 4.5F); + ToolType typeToFind = null; - if(block != null) { - Material mat = block.getMaterial(); - if(ToolCommons.isRightMaterial(mat, ToolCommons.materialsPick)) - typeToFind = ToolType.PICK; - else if(ToolCommons.isRightMaterial(mat, ToolCommons.materialsShovel)) - typeToFind = ToolType.SHOVEL; - else if(ToolCommons.isRightMaterial(mat, ToolCommons.materialsAxe)) - typeToFind = ToolType.AXE; - } - } + if (player.isSwingInProgress && pos != null) { + Block block = entity.worldObj.getBlock(pos.blockX, pos.blockY, pos.blockZ); - if(typeToFind == null) - return; + if (block != null) { + Material mat = block.getMaterial(); + if (ToolCommons.isRightMaterial(mat, ToolCommons.materialsPick)) typeToFind = ToolType.PICK; + else if (ToolCommons.isRightMaterial(mat, ToolCommons.materialsShovel)) typeToFind = ToolType.SHOVEL; + else if (ToolCommons.isRightMaterial(mat, ToolCommons.materialsAxe)) typeToFind = ToolType.AXE; + } + } - ItemStack bestTool = currentStack; - int bestToolPriority = tool.getSortingType(currentStack) == typeToFind ? tool.getSortingPriority(currentStack) : -1; - int bestSlot = -1; + if (typeToFind == null) return; - for(int i = 0; i < player.inventory.getSizeInventory(); i++) { - ItemStack stackInSlot = player.inventory.getStackInSlot(i); - if (stackInSlot != null && stackInSlot.getItem() instanceof ISortableTool && stackInSlot != currentStack) { - ISortableTool toolInSlot = (ISortableTool) stackInSlot.getItem(); - if(toolInSlot.getSortingType(stackInSlot).equals(typeToFind)) { - int priority = toolInSlot.getSortingPriority(stackInSlot); - if(priority > bestToolPriority) { - bestTool = stackInSlot; - bestToolPriority = priority; - bestSlot = i; - } - } - } - } + ItemStack bestTool = currentStack; + int bestToolPriority = + tool.getSortingType(currentStack) == typeToFind ? tool.getSortingPriority(currentStack) : -1; + int bestSlot = -1; - if(bestSlot != -1) { - player.inventory.setInventorySlotContents(player.inventory.currentItem, bestTool); - player.inventory.setInventorySlotContents(bestSlot, currentStack); - } - } + for (int i = 0; i < player.inventory.getSizeInventory(); i++) { + ItemStack stackInSlot = player.inventory.getStackInSlot(i); + if (stackInSlot != null && stackInSlot.getItem() instanceof ISortableTool && stackInSlot != currentStack) { + ISortableTool toolInSlot = (ISortableTool) stackInSlot.getItem(); + if (toolInSlot.getSortingType(stackInSlot).equals(typeToFind)) { + int priority = toolInSlot.getSortingPriority(stackInSlot); + if (priority > bestToolPriority) { + bestTool = stackInSlot; + bestToolPriority = priority; + bestSlot = i; + } + } + } + } - @Override - public BaubleType getBaubleType(ItemStack arg0) { - return BaubleType.RING; - } + if (bestSlot != -1) { + player.inventory.setInventorySlotContents(player.inventory.currentItem, bestTool); + player.inventory.setInventorySlotContents(bestSlot, currentStack); + } + } + @Override + public BaubleType getBaubleType(ItemStack arg0) { + return BaubleType.RING; + } } diff --git a/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemTinyPlanet.java b/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemTinyPlanet.java index 7b03ea5dce..24969c05d4 100644 --- a/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemTinyPlanet.java +++ b/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemTinyPlanet.java @@ -2,16 +2,16 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Apr 20, 2014, 10:58:00 PM (GMT)] */ package vazkii.botania.common.item.equipment.bauble; +import baubles.api.BaubleType; import java.util.List; - import net.minecraft.client.Minecraft; import net.minecraft.client.renderer.RenderBlocks; import net.minecraft.client.renderer.texture.TextureMap; @@ -22,94 +22,90 @@ import net.minecraft.util.AxisAlignedBB; import net.minecraft.world.World; import net.minecraftforge.client.event.RenderPlayerEvent; - import org.lwjgl.opengl.GL11; - import vazkii.botania.api.internal.IManaBurst; import vazkii.botania.api.item.IBaubleRender; import vazkii.botania.api.mana.ITinyPlanetExcempt; import vazkii.botania.common.block.ModBlocks; import vazkii.botania.common.core.helper.Vector3; import vazkii.botania.common.lib.LibItemNames; -import baubles.api.BaubleType; public class ItemTinyPlanet extends ItemBauble implements IBaubleRender { - public static final String TAG_ORBIT = "orbit"; - - public ItemTinyPlanet() { - super(LibItemNames.TINY_PLANET); - } - - @Override - public BaubleType getBaubleType(ItemStack itemstack) { - return BaubleType.AMULET; - } - - @Override - public void onWornTick(ItemStack stack, EntityLivingBase player) { - super.onWornTick(stack, player); - - double x = player.posX; - double y = player.posY + 1.2F; - double z = player.posZ; - if(player.worldObj.isRemote) - y -= 1.62F; - - applyEffect(player.worldObj, x, y, z); - } - - public static void applyEffect(World world, double x, double y, double z) { - int range = 8; - List entities = world.getEntitiesWithinAABB(IManaBurst.class, AxisAlignedBB.getBoundingBox(x - range, y - range, z - range, x + range, y + range, z + range)); - for(Entity entity : entities) { - IManaBurst burst = (IManaBurst) entity; - ItemStack lens = burst.getSourceLens(); - if(lens != null && lens.getItem() instanceof ITinyPlanetExcempt && !((ITinyPlanetExcempt) lens.getItem()).shouldPull(lens)) - continue; - - int orbitTime = getEntityOrbitTime(entity); - if(orbitTime == 0) - burst.setMinManaLoss(burst.getMinManaLoss() * 3); - - float radius = Math.min(7.5F, (Math.max(40, orbitTime) - 40) / 40F + 1.5F); - int angle = orbitTime % 360; - - float xTarget = (float) (x + Math.cos(angle * 10 * Math.PI / 180F) * radius); - float yTarget = (float) y; - float zTarget = (float) (z + Math.sin(angle * 10 * Math.PI / 180F) * radius); - - Vector3 targetVec = new Vector3(xTarget, yTarget, zTarget); - Vector3 currentVec = new Vector3(entity.posX, entity.posY, entity.posZ); - Vector3 moveVector = targetVec.copy().sub(currentVec); - - burst.setMotion(moveVector.x, moveVector.y, moveVector.z); - - incrementOrbitTime(entity); - } - } - - public static int getEntityOrbitTime(Entity entity) { - NBTTagCompound cmp = entity.getEntityData(); - if(cmp.hasKey(TAG_ORBIT)) - return cmp.getInteger(TAG_ORBIT); - else return 0; - } - - public static void incrementOrbitTime(Entity entity) { - NBTTagCompound cmp = entity.getEntityData(); - int time = getEntityOrbitTime(entity); - cmp.setInteger(TAG_ORBIT, time + 1); - } - - @Override - public void onPlayerBaubleRender(ItemStack stack, RenderPlayerEvent event, RenderType type) { - if(type == RenderType.HEAD) { - Minecraft.getMinecraft().renderEngine.bindTexture(TextureMap.locationBlocksTexture); - GL11.glTranslatef(0.25F, -0.5F, 0F); - GL11.glScalef(0.5F, 0.5F, 0.5F); - RenderBlocks.getInstance().renderBlockAsItem(ModBlocks.tinyPlanet, 0, 1F); - } - } - + public static final String TAG_ORBIT = "orbit"; + + public ItemTinyPlanet() { + super(LibItemNames.TINY_PLANET); + } + + @Override + public BaubleType getBaubleType(ItemStack itemstack) { + return BaubleType.AMULET; + } + + @Override + public void onWornTick(ItemStack stack, EntityLivingBase player) { + super.onWornTick(stack, player); + + double x = player.posX; + double y = player.posY + 1.2F; + double z = player.posZ; + if (player.worldObj.isRemote) y -= 1.62F; + + applyEffect(player.worldObj, x, y, z); + } + + public static void applyEffect(World world, double x, double y, double z) { + int range = 8; + List entities = world.getEntitiesWithinAABB( + IManaBurst.class, + AxisAlignedBB.getBoundingBox(x - range, y - range, z - range, x + range, y + range, z + range)); + for (Entity entity : entities) { + IManaBurst burst = (IManaBurst) entity; + ItemStack lens = burst.getSourceLens(); + if (lens != null + && lens.getItem() instanceof ITinyPlanetExcempt + && !((ITinyPlanetExcempt) lens.getItem()).shouldPull(lens)) continue; + + int orbitTime = getEntityOrbitTime(entity); + if (orbitTime == 0) burst.setMinManaLoss(burst.getMinManaLoss() * 3); + + float radius = Math.min(7.5F, (Math.max(40, orbitTime) - 40) / 40F + 1.5F); + int angle = orbitTime % 360; + + float xTarget = (float) (x + Math.cos(angle * 10 * Math.PI / 180F) * radius); + float yTarget = (float) y; + float zTarget = (float) (z + Math.sin(angle * 10 * Math.PI / 180F) * radius); + + Vector3 targetVec = new Vector3(xTarget, yTarget, zTarget); + Vector3 currentVec = new Vector3(entity.posX, entity.posY, entity.posZ); + Vector3 moveVector = targetVec.copy().sub(currentVec); + + burst.setMotion(moveVector.x, moveVector.y, moveVector.z); + + incrementOrbitTime(entity); + } + } + + public static int getEntityOrbitTime(Entity entity) { + NBTTagCompound cmp = entity.getEntityData(); + if (cmp.hasKey(TAG_ORBIT)) return cmp.getInteger(TAG_ORBIT); + else return 0; + } + + public static void incrementOrbitTime(Entity entity) { + NBTTagCompound cmp = entity.getEntityData(); + int time = getEntityOrbitTime(entity); + cmp.setInteger(TAG_ORBIT, time + 1); + } + + @Override + public void onPlayerBaubleRender(ItemStack stack, RenderPlayerEvent event, RenderType type) { + if (type == RenderType.HEAD) { + Minecraft.getMinecraft().renderEngine.bindTexture(TextureMap.locationBlocksTexture); + GL11.glTranslatef(0.25F, -0.5F, 0F); + GL11.glScalef(0.5F, 0.5F, 0.5F); + RenderBlocks.getInstance().renderBlockAsItem(ModBlocks.tinyPlanet, 0, 1F); + } + } } diff --git a/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemTravelBelt.java b/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemTravelBelt.java index 1cae596c8f..da80653f3c 100644 --- a/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemTravelBelt.java +++ b/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemTravelBelt.java @@ -2,17 +2,22 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Apr 24, 2014, 11:14:57 PM (GMT)] */ package vazkii.botania.common.item.equipment.bauble; +import baubles.api.BaubleType; +import baubles.common.lib.PlayerHandler; +import cpw.mods.fml.common.eventhandler.SubscribeEvent; +import cpw.mods.fml.common.gameevent.PlayerEvent; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; import java.util.ArrayList; import java.util.List; - import net.minecraft.block.material.Material; import net.minecraft.client.Minecraft; import net.minecraft.client.model.ModelBiped; @@ -23,154 +28,150 @@ import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.event.entity.living.LivingEvent.LivingJumpEvent; import net.minecraftforge.event.entity.living.LivingEvent.LivingUpdateEvent; - import org.lwjgl.opengl.GL11; - import vazkii.botania.api.item.IBaubleRender; import vazkii.botania.api.mana.IManaUsingItem; import vazkii.botania.api.mana.ManaItemHandler; import vazkii.botania.client.lib.LibResources; import vazkii.botania.common.lib.LibItemNames; -import baubles.api.BaubleType; -import baubles.common.lib.PlayerHandler; -import cpw.mods.fml.common.eventhandler.SubscribeEvent; -import cpw.mods.fml.common.gameevent.PlayerEvent; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; public class ItemTravelBelt extends ItemBauble implements IBaubleRender, IManaUsingItem { - private static final ResourceLocation texture = new ResourceLocation(LibResources.MODEL_TRAVEL_BELT); - @SideOnly(Side.CLIENT) - private static ModelBiped model; - - private static final int COST = 1; - private static final int COST_INTERVAL = 10; - - public static List playersWithStepup = new ArrayList(); - - final float speed; - final float jump; - final float fallBuffer; - - public ItemTravelBelt() { - this(LibItemNames.TRAVEL_BELT, 0.035F, 0.2F, 2F); - MinecraftForge.EVENT_BUS.register(this); - } - - public ItemTravelBelt(String name, float speed, float jump, float fallBuffer) { - super(name); - this.speed = speed; - this.jump = jump; - this.fallBuffer = fallBuffer; - } - - @Override - public BaubleType getBaubleType(ItemStack itemstack) { - return BaubleType.BELT; - } - - @SubscribeEvent - public void updatePlayerStepStatus(LivingUpdateEvent event) { - if(event.entityLiving instanceof EntityPlayer) { - EntityPlayer player = (EntityPlayer) event.entityLiving; - String s = playerStr(player); - - ItemStack belt = PlayerHandler.getPlayerBaubles(player).getStackInSlot(3); - if(playersWithStepup.contains(s)) { - if(shouldPlayerHaveStepup(player)) { - ItemTravelBelt beltItem = (ItemTravelBelt) belt.getItem(); - - if((player.onGround || player.capabilities.isFlying) && player.moveForward > 0F && !player.isInsideOfMaterial(Material.water)) { - float speed = beltItem.getSpeed(belt); - player.moveFlying(0F, 1F, player.capabilities.isFlying ? speed : speed); - beltItem.onMovedTick(belt, player); - - if(player.ticksExisted % COST_INTERVAL == 0) - ManaItemHandler.requestManaExact(belt, player, COST, true); - } else beltItem.onNotMovingTick(belt, player); - - if(player.isSneaking()) - player.stepHeight = 0.50001F; // Not 0.5F because that is the default - else player.stepHeight = 1F; - - } else { - player.stepHeight = 0.5F; - playersWithStepup.remove(s); - } - } else if(shouldPlayerHaveStepup(player)) { - playersWithStepup.add(s); - player.stepHeight = 1F; - } - } - } - - public float getSpeed(ItemStack stack) { - return speed; - } - - public void onMovedTick(ItemStack stack, EntityPlayer player) { - // NO-OP - } - - public void onNotMovingTick(ItemStack stack, EntityPlayer player) { - // NO-OP - } - - @SubscribeEvent - public void onPlayerJump(LivingJumpEvent event) { - if(event.entityLiving instanceof EntityPlayer) { - EntityPlayer player = (EntityPlayer) event.entityLiving; - ItemStack belt = PlayerHandler.getPlayerBaubles(player).getStackInSlot(3); - - if(belt != null && belt.getItem() instanceof ItemTravelBelt && ManaItemHandler.requestManaExact(belt, player, COST, false)) { - player.motionY += ((ItemTravelBelt) belt.getItem()).jump; - player.fallDistance = -((ItemTravelBelt) belt.getItem()).fallBuffer; - } - } - } - - private boolean shouldPlayerHaveStepup(EntityPlayer player) { - ItemStack armor = PlayerHandler.getPlayerBaubles(player).getStackInSlot(3); - return armor != null && armor.getItem() instanceof ItemTravelBelt && ManaItemHandler.requestManaExact(armor, player, COST, false); - } - - @SubscribeEvent - public void playerLoggedOut(PlayerEvent.PlayerLoggedOutEvent event) { - String username = event.player.getGameProfile().getName(); - playersWithStepup.remove(username + ":false"); - playersWithStepup.remove(username + ":true"); - } - - public static String playerStr(EntityPlayer player) { - return player.getGameProfile().getName() + ":" + player.worldObj.isRemote; - } - - @SideOnly(Side.CLIENT) - ResourceLocation getRenderTexture() { - return texture; - } - - @Override - @SideOnly(Side.CLIENT) - public void onPlayerBaubleRender(ItemStack stack, RenderPlayerEvent event, RenderType type) { - if(type == RenderType.BODY) { - Minecraft.getMinecraft().renderEngine.bindTexture(getRenderTexture()); - Helper.rotateIfSneaking(event.entityPlayer); - GL11.glTranslatef(0F, 0.2F, 0F); - - float s = 1.05F / 16F; - GL11.glScalef(s, s, s); - if(model == null) - model = new ModelBiped(); - - model.bipedBody.render(1F); - } - } - - @Override - public boolean usesMana(ItemStack stack) { - return true; - } - + private static final ResourceLocation texture = new ResourceLocation(LibResources.MODEL_TRAVEL_BELT); + + @SideOnly(Side.CLIENT) + private static ModelBiped model; + + private static final int COST = 1; + private static final int COST_INTERVAL = 10; + + public static List playersWithStepup = new ArrayList(); + + final float speed; + final float jump; + final float fallBuffer; + + public ItemTravelBelt() { + this(LibItemNames.TRAVEL_BELT, 0.035F, 0.2F, 2F); + MinecraftForge.EVENT_BUS.register(this); + } + + public ItemTravelBelt(String name, float speed, float jump, float fallBuffer) { + super(name); + this.speed = speed; + this.jump = jump; + this.fallBuffer = fallBuffer; + } + + @Override + public BaubleType getBaubleType(ItemStack itemstack) { + return BaubleType.BELT; + } + + @SubscribeEvent + public void updatePlayerStepStatus(LivingUpdateEvent event) { + if (event.entityLiving instanceof EntityPlayer) { + EntityPlayer player = (EntityPlayer) event.entityLiving; + String s = playerStr(player); + + ItemStack belt = PlayerHandler.getPlayerBaubles(player).getStackInSlot(3); + if (playersWithStepup.contains(s)) { + if (shouldPlayerHaveStepup(player)) { + ItemTravelBelt beltItem = (ItemTravelBelt) belt.getItem(); + + if ((player.onGround || player.capabilities.isFlying) + && player.moveForward > 0F + && !player.isInsideOfMaterial(Material.water)) { + float speed = beltItem.getSpeed(belt); + player.moveFlying(0F, 1F, player.capabilities.isFlying ? speed : speed); + beltItem.onMovedTick(belt, player); + + if (player.ticksExisted % COST_INTERVAL == 0) + ManaItemHandler.requestManaExact(belt, player, COST, true); + } else beltItem.onNotMovingTick(belt, player); + + if (player.isSneaking()) player.stepHeight = 0.50001F; // Not 0.5F because that is the default + else player.stepHeight = 1F; + + } else { + player.stepHeight = 0.5F; + playersWithStepup.remove(s); + } + } else if (shouldPlayerHaveStepup(player)) { + playersWithStepup.add(s); + player.stepHeight = 1F; + } + } + } + + public float getSpeed(ItemStack stack) { + return speed; + } + + public void onMovedTick(ItemStack stack, EntityPlayer player) { + // NO-OP + } + + public void onNotMovingTick(ItemStack stack, EntityPlayer player) { + // NO-OP + } + + @SubscribeEvent + public void onPlayerJump(LivingJumpEvent event) { + if (event.entityLiving instanceof EntityPlayer) { + EntityPlayer player = (EntityPlayer) event.entityLiving; + ItemStack belt = PlayerHandler.getPlayerBaubles(player).getStackInSlot(3); + + if (belt != null + && belt.getItem() instanceof ItemTravelBelt + && ManaItemHandler.requestManaExact(belt, player, COST, false)) { + player.motionY += ((ItemTravelBelt) belt.getItem()).jump; + player.fallDistance = -((ItemTravelBelt) belt.getItem()).fallBuffer; + } + } + } + + private boolean shouldPlayerHaveStepup(EntityPlayer player) { + ItemStack armor = PlayerHandler.getPlayerBaubles(player).getStackInSlot(3); + return armor != null + && armor.getItem() instanceof ItemTravelBelt + && ManaItemHandler.requestManaExact(armor, player, COST, false); + } + + @SubscribeEvent + public void playerLoggedOut(PlayerEvent.PlayerLoggedOutEvent event) { + String username = event.player.getGameProfile().getName(); + playersWithStepup.remove(username + ":false"); + playersWithStepup.remove(username + ":true"); + } + + public static String playerStr(EntityPlayer player) { + return player.getGameProfile().getName() + ":" + player.worldObj.isRemote; + } + + @SideOnly(Side.CLIENT) + ResourceLocation getRenderTexture() { + return texture; + } + + @Override + @SideOnly(Side.CLIENT) + public void onPlayerBaubleRender(ItemStack stack, RenderPlayerEvent event, RenderType type) { + if (type == RenderType.BODY) { + Minecraft.getMinecraft().renderEngine.bindTexture(getRenderTexture()); + Helper.rotateIfSneaking(event.entityPlayer); + GL11.glTranslatef(0F, 0.2F, 0F); + + float s = 1.05F / 16F; + GL11.glScalef(s, s, s); + if (model == null) model = new ModelBiped(); + + model.bipedBody.render(1F); + } + } + + @Override + public boolean usesMana(ItemStack stack) { + return true; + } } diff --git a/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemUnholyCloak.java b/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemUnholyCloak.java index 1dbd14b56e..e58e4de8f7 100644 --- a/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemUnholyCloak.java +++ b/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemUnholyCloak.java @@ -2,16 +2,15 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Dec 4, 2014, 11:12:51 PM (GMT)] */ package vazkii.botania.common.item.equipment.bauble; import java.util.List; - import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.monster.IMob; import net.minecraft.entity.player.EntityPlayer; @@ -26,40 +25,58 @@ public class ItemUnholyCloak extends ItemHolyCloak { - private static final ResourceLocation texture = new ResourceLocation(LibResources.MODEL_UNHOLY_CLOAK); - - public ItemUnholyCloak() { - super(LibItemNames.UNHOLY_CLOAK); - } + private static final ResourceLocation texture = new ResourceLocation(LibResources.MODEL_UNHOLY_CLOAK); - @Override - public boolean effectOnDamage(LivingHurtEvent event, EntityPlayer player, ItemStack stack) { - if(!event.source.isUnblockable()) { - int range = 6; - List mobs = player.worldObj.getEntitiesWithinAABB(IMob.class, AxisAlignedBB.getBoundingBox(player.posX - range, player.posY - range, player.posZ - range, player.posX + range, player.posY + range, player.posZ + range)); - for(IMob mob : mobs) - if(mob instanceof EntityLivingBase) { - EntityLivingBase entity = (EntityLivingBase) mob; - entity.attackEntityFrom(DamageSource.causePlayerDamage(player), event.ammount); - } + public ItemUnholyCloak() { + super(LibItemNames.UNHOLY_CLOAK); + } - player.worldObj.playSoundAtEntity(player, "botania:unholyCloak", 1F, 1F); - for(int i = 0; i < 90; i++) { - float rad = i * 4F * (float) Math.PI / 180F; - float xMotion = (float) Math.cos(rad) * 0.2F; - float zMotion = (float) Math.sin(rad) * 0.2F; - Botania.proxy.wispFX(player.worldObj, player.posX, player.posY + 0.5, player.posZ, 0.4F + (float) Math.random() + 0.25F, 0F, 0F, 0.6F + (float) Math.random() * 0.2F, xMotion, 0F, zMotion); - } + @Override + public boolean effectOnDamage(LivingHurtEvent event, EntityPlayer player, ItemStack stack) { + if (!event.source.isUnblockable()) { + int range = 6; + List mobs = player.worldObj.getEntitiesWithinAABB( + IMob.class, + AxisAlignedBB.getBoundingBox( + player.posX - range, + player.posY - range, + player.posZ - range, + player.posX + range, + player.posY + range, + player.posZ + range)); + for (IMob mob : mobs) + if (mob instanceof EntityLivingBase) { + EntityLivingBase entity = (EntityLivingBase) mob; + entity.attackEntityFrom(DamageSource.causePlayerDamage(player), event.ammount); + } - return true; - } + player.worldObj.playSoundAtEntity(player, "botania:unholyCloak", 1F, 1F); + for (int i = 0; i < 90; i++) { + float rad = i * 4F * (float) Math.PI / 180F; + float xMotion = (float) Math.cos(rad) * 0.2F; + float zMotion = (float) Math.sin(rad) * 0.2F; + Botania.proxy.wispFX( + player.worldObj, + player.posX, + player.posY + 0.5, + player.posZ, + 0.4F + (float) Math.random() + 0.25F, + 0F, + 0F, + 0.6F + (float) Math.random() * 0.2F, + xMotion, + 0F, + zMotion); + } - return false; - } + return true; + } - @Override - ResourceLocation getRenderTexture() { - return texture; - } + return false; + } + @Override + ResourceLocation getRenderTexture() { + return texture; + } } diff --git a/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemWaterRing.java b/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemWaterRing.java index 3b3c5d6454..c43ecae48c 100644 --- a/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemWaterRing.java +++ b/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemWaterRing.java @@ -2,14 +2,15 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [May 17, 2014, 3:44:24 PM (GMT)] */ package vazkii.botania.common.item.equipment.bauble; +import baubles.api.BaubleType; import net.minecraft.block.material.Material; import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.player.EntityPlayer; @@ -19,66 +20,60 @@ import vazkii.botania.api.mana.IManaUsingItem; import vazkii.botania.api.mana.ManaItemHandler; import vazkii.botania.common.lib.LibItemNames; -import baubles.api.BaubleType; public class ItemWaterRing extends ItemBauble implements IManaUsingItem { - public ItemWaterRing() { - super(LibItemNames.WATER_RING); - } - - @Override - public void onWornTick(ItemStack stack, EntityLivingBase player) { - super.onWornTick(stack, player); + public ItemWaterRing() { + super(LibItemNames.WATER_RING); + } - if(player.isInsideOfMaterial(Material.water)) { - double motionX = player.motionX * 1.2; - double motionY = player.motionY * 1.2; - double motionZ = player.motionZ * 1.2; + @Override + public void onWornTick(ItemStack stack, EntityLivingBase player) { + super.onWornTick(stack, player); - boolean changeX = Math.min(1.3, Math.abs(motionX)) == Math.abs(motionX); - boolean changeY = Math.min(1.3, Math.abs(motionY)) == Math.abs(motionY); - boolean changeZ = Math.min(1.3, Math.abs(motionZ)) == Math.abs(motionZ); + if (player.isInsideOfMaterial(Material.water)) { + double motionX = player.motionX * 1.2; + double motionY = player.motionY * 1.2; + double motionZ = player.motionZ * 1.2; - if(player instanceof EntityPlayer && ((EntityPlayer) player).capabilities.isFlying) - changeX = changeY = changeZ = false; + boolean changeX = Math.min(1.3, Math.abs(motionX)) == Math.abs(motionX); + boolean changeY = Math.min(1.3, Math.abs(motionY)) == Math.abs(motionY); + boolean changeZ = Math.min(1.3, Math.abs(motionZ)) == Math.abs(motionZ); - if(changeX) - player.motionX = motionX; - if(changeY) - player.motionY = motionY; - if(changeZ) - player.motionZ = motionZ; + if (player instanceof EntityPlayer && ((EntityPlayer) player).capabilities.isFlying) + changeX = changeY = changeZ = false; - PotionEffect effect = player.getActivePotionEffect(Potion.nightVision); - if(effect == null) { - PotionEffect neweffect = new PotionEffect(Potion.nightVision.id, Integer.MAX_VALUE, -42, true); - player.addPotionEffect(neweffect); - } + if (changeX) player.motionX = motionX; + if (changeY) player.motionY = motionY; + if (changeZ) player.motionZ = motionZ; - if(player.getAir() <= 1 && player instanceof EntityPlayer) { - int mana = ManaItemHandler.requestMana(stack, (EntityPlayer) player, 300, true); - if(mana > 0) // If zero gets in the player has no air but won't drown. - player.setAir(mana); - } - } else onUnequipped(stack, player); - } + PotionEffect effect = player.getActivePotionEffect(Potion.nightVision); + if (effect == null) { + PotionEffect neweffect = new PotionEffect(Potion.nightVision.id, Integer.MAX_VALUE, -42, true); + player.addPotionEffect(neweffect); + } - @Override - public void onUnequipped(ItemStack stack, EntityLivingBase player) { - PotionEffect effect = player.getActivePotionEffect(Potion.nightVision); - if(effect != null && effect.getAmplifier() == -42) - player.removePotionEffect(Potion.nightVision.id); - } + if (player.getAir() <= 1 && player instanceof EntityPlayer) { + int mana = ManaItemHandler.requestMana(stack, (EntityPlayer) player, 300, true); + if (mana > 0) // If zero gets in the player has no air but won't drown. + player.setAir(mana); + } + } else onUnequipped(stack, player); + } - @Override - public BaubleType getBaubleType(ItemStack arg0) { - return BaubleType.RING; - } + @Override + public void onUnequipped(ItemStack stack, EntityLivingBase player) { + PotionEffect effect = player.getActivePotionEffect(Potion.nightVision); + if (effect != null && effect.getAmplifier() == -42) player.removePotionEffect(Potion.nightVision.id); + } - @Override - public boolean usesMana(ItemStack stack) { - return true; - } + @Override + public BaubleType getBaubleType(ItemStack arg0) { + return BaubleType.RING; + } + @Override + public boolean usesMana(ItemStack stack) { + return true; + } } diff --git a/src/main/java/vazkii/botania/common/item/equipment/tool/ItemEnderDagger.java b/src/main/java/vazkii/botania/common/item/equipment/tool/ItemEnderDagger.java index e7102c7f08..db5fb376f9 100644 --- a/src/main/java/vazkii/botania/common/item/equipment/tool/ItemEnderDagger.java +++ b/src/main/java/vazkii/botania/common/item/equipment/tool/ItemEnderDagger.java @@ -2,16 +2,15 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jun 10, 2014, 11:48:12 PM (GMT)] */ package vazkii.botania.common.item.equipment.tool; import java.awt.Color; - import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.entity.Entity; import net.minecraft.entity.EntityLivingBase; @@ -29,59 +28,60 @@ public class ItemEnderDagger extends ItemManasteelSword { - IIcon iconFront, iconOverlay; - - public ItemEnderDagger() { - super(BotaniaAPI.manasteelToolMaterial, LibItemNames.ENDER_DAGGER); - setMaxDamage(69); // What you looking at? - setNoRepair(); - } + IIcon iconFront, iconOverlay; - @Override - public void registerIcons(IIconRegister par1IconRegister) { - iconFront = IconHelper.forItem(par1IconRegister, this, 0); - iconOverlay = IconHelper.forItem(par1IconRegister, this, 1); - } + public ItemEnderDagger() { + super(BotaniaAPI.manasteelToolMaterial, LibItemNames.ENDER_DAGGER); + setMaxDamage(69); // What you looking at? + setNoRepair(); + } - @Override - public boolean requiresMultipleRenderPasses() { - return true; - } + @Override + public void registerIcons(IIconRegister par1IconRegister) { + iconFront = IconHelper.forItem(par1IconRegister, this, 0); + iconOverlay = IconHelper.forItem(par1IconRegister, this, 1); + } - @Override - public IIcon getIcon(ItemStack stack, int pass) { - return pass == 0 ? iconFront : iconOverlay; - } + @Override + public boolean requiresMultipleRenderPasses() { + return true; + } - @Override - public int getColorFromItemStack(ItemStack par1ItemStack, int par2) { - if(par2 == 0) - return 0xFFFFFF; + @Override + public IIcon getIcon(ItemStack stack, int pass) { + return pass == 0 ? iconFront : iconOverlay; + } - return Color.HSBtoRGB(0.75F, 1F, 1.5F - (float) Math.min(1F, Math.sin(System.currentTimeMillis() / 100D) * 0.5 + 1.2F)); - } + @Override + public int getColorFromItemStack(ItemStack par1ItemStack, int par2) { + if (par2 == 0) return 0xFFFFFF; - @Override - public EnumAction getItemUseAction(ItemStack par1ItemStack) { - return EnumAction.none; - } + return Color.HSBtoRGB( + 0.75F, 1F, 1.5F - (float) Math.min(1F, Math.sin(System.currentTimeMillis() / 100D) * 0.5 + 1.2F)); + } - @Override - public boolean hitEntity(ItemStack par1ItemStack, EntityLivingBase par2EntityLivingBase, EntityLivingBase par3EntityLivingBase) { - if(par2EntityLivingBase instanceof EntityEnderman && par3EntityLivingBase instanceof EntityPlayer) - par2EntityLivingBase.attackEntityFrom(DamageSource.causePlayerDamage((EntityPlayer) par3EntityLivingBase), 20); - par1ItemStack.damageItem(1, par3EntityLivingBase); - return true; - } + @Override + public EnumAction getItemUseAction(ItemStack par1ItemStack) { + return EnumAction.none; + } - @Override - public void onUpdate(ItemStack stack, World world, Entity player, int par4, boolean par5) { - // NO-OP - } + @Override + public boolean hitEntity( + ItemStack par1ItemStack, EntityLivingBase par2EntityLivingBase, EntityLivingBase par3EntityLivingBase) { + if (par2EntityLivingBase instanceof EntityEnderman && par3EntityLivingBase instanceof EntityPlayer) + par2EntityLivingBase.attackEntityFrom( + DamageSource.causePlayerDamage((EntityPlayer) par3EntityLivingBase), 20); + par1ItemStack.damageItem(1, par3EntityLivingBase); + return true; + } - @Override - public boolean usesMana(ItemStack stack) { - return false; - } + @Override + public void onUpdate(ItemStack stack, World world, Entity player, int par4, boolean par5) { + // NO-OP + } + @Override + public boolean usesMana(ItemStack stack) { + return false; + } } diff --git a/src/main/java/vazkii/botania/common/item/equipment/tool/ItemGlassPick.java b/src/main/java/vazkii/botania/common/item/equipment/tool/ItemGlassPick.java index f651eb9770..74f9b02aea 100644 --- a/src/main/java/vazkii/botania/common/item/equipment/tool/ItemGlassPick.java +++ b/src/main/java/vazkii/botania/common/item/equipment/tool/ItemGlassPick.java @@ -2,14 +2,15 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Aug 6, 2014, 9:55:23 PM (GMT)] */ package vazkii.botania.common.item.equipment.tool; +import cpw.mods.fml.common.eventhandler.SubscribeEvent; import net.minecraft.block.material.Material; import net.minecraft.init.Blocks; import net.minecraft.item.Item; @@ -19,37 +20,44 @@ import net.minecraftforge.event.world.BlockEvent.HarvestDropsEvent; import vazkii.botania.common.item.equipment.tool.manasteel.ItemManasteelPick; import vazkii.botania.common.lib.LibItemNames; -import cpw.mods.fml.common.eventhandler.SubscribeEvent; public class ItemGlassPick extends ItemManasteelPick { - private static final int MANA_PER_DAMAGE = 160; - private static final ToolMaterial MATERIAL = EnumHelper.addToolMaterial("MANASTEEL_GLASS", 0, 125, 4.8F, 1F, 10); - - public ItemGlassPick() { - super(MATERIAL, LibItemNames.GLASS_PICK); - MinecraftForge.EVENT_BUS.register(this); - } - - @SubscribeEvent - public void onBlockDrops(HarvestDropsEvent event) { - if(event.harvester != null && event.block != null && event.drops.isEmpty() && event.harvester.getCurrentEquippedItem() != null && event.harvester.getCurrentEquippedItem().getItem() == this && event.block.getMaterial() == Material.glass && event.block.canSilkHarvest(event.world, event.harvester, event.x, event.y, event.z, event.blockMetadata)) - event.drops.add(new ItemStack(event.block, 1, event.blockMetadata)); - } - - @Override - public int getManaPerDmg() { - return MANA_PER_DAMAGE; - } - - @Override - public boolean getIsRepairable(ItemStack par1ItemStack, ItemStack par2ItemStack) { - return par2ItemStack.getItem() == Item.getItemFromBlock(Blocks.glass) ? true : super.getIsRepairable(par1ItemStack, par2ItemStack); - } - - @Override - public int getSortingPriority(ItemStack stack) { - return 0; - } - + private static final int MANA_PER_DAMAGE = 160; + private static final ToolMaterial MATERIAL = EnumHelper.addToolMaterial("MANASTEEL_GLASS", 0, 125, 4.8F, 1F, 10); + + public ItemGlassPick() { + super(MATERIAL, LibItemNames.GLASS_PICK); + MinecraftForge.EVENT_BUS.register(this); + } + + @SubscribeEvent + public void onBlockDrops(HarvestDropsEvent event) { + if (event.harvester != null + && event.block != null + && event.drops.isEmpty() + && event.harvester.getCurrentEquippedItem() != null + && event.harvester.getCurrentEquippedItem().getItem() == this + && event.block.getMaterial() == Material.glass + && event.block.canSilkHarvest( + event.world, event.harvester, event.x, event.y, event.z, event.blockMetadata)) + event.drops.add(new ItemStack(event.block, 1, event.blockMetadata)); + } + + @Override + public int getManaPerDmg() { + return MANA_PER_DAMAGE; + } + + @Override + public boolean getIsRepairable(ItemStack par1ItemStack, ItemStack par2ItemStack) { + return par2ItemStack.getItem() == Item.getItemFromBlock(Blocks.glass) + ? true + : super.getIsRepairable(par1ItemStack, par2ItemStack); + } + + @Override + public int getSortingPriority(ItemStack stack) { + return 0; + } } diff --git a/src/main/java/vazkii/botania/common/item/equipment/tool/ItemStarSword.java b/src/main/java/vazkii/botania/common/item/equipment/tool/ItemStarSword.java index fa1e78b214..33071d8b12 100644 --- a/src/main/java/vazkii/botania/common/item/equipment/tool/ItemStarSword.java +++ b/src/main/java/vazkii/botania/common/item/equipment/tool/ItemStarSword.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Aug 17, 2015, 3:55:52 PM (GMT)] */ package vazkii.botania.common.item.equipment.tool; @@ -30,56 +30,59 @@ public class ItemStarSword extends ItemManasteelSword implements ICraftAchievement { - private static final int MANA_PER_DAMAGE = 120; + private static final int MANA_PER_DAMAGE = 120; - public ItemStarSword() { - super(BotaniaAPI.terrasteelToolMaterial, LibItemNames.STAR_SWORD); - } + public ItemStarSword() { + super(BotaniaAPI.terrasteelToolMaterial, LibItemNames.STAR_SWORD); + } - @Override - public void onUpdate(ItemStack par1ItemStack, World par2World, Entity par3Entity, int par4, boolean par5) { - super.onUpdate(par1ItemStack, par2World, par3Entity, par4, par5); - if(par3Entity instanceof EntityPlayer) { - EntityPlayer player = (EntityPlayer) par3Entity; - PotionEffect haste = player.getActivePotionEffect(Potion.digSpeed); - float check = haste == null ? 0.16666667F : haste.getAmplifier() == 1 ? 0.5F : 0.4F; + @Override + public void onUpdate(ItemStack par1ItemStack, World par2World, Entity par3Entity, int par4, boolean par5) { + super.onUpdate(par1ItemStack, par2World, par3Entity, par4, par5); + if (par3Entity instanceof EntityPlayer) { + EntityPlayer player = (EntityPlayer) par3Entity; + PotionEffect haste = player.getActivePotionEffect(Potion.digSpeed); + float check = haste == null ? 0.16666667F : haste.getAmplifier() == 1 ? 0.5F : 0.4F; - if(player.getCurrentEquippedItem() == par1ItemStack && player.swingProgress == check && !par2World.isRemote && par2World.rand.nextInt(2) == 0) { - MovingObjectPosition pos = ToolCommons.raytraceFromEntity(par2World, par3Entity, true, 48); - if(pos != null) { - Vector3 posVec = new Vector3(pos.blockX, pos.blockY, pos.blockZ); - Vector3 motVec = new Vector3((Math.random() - 0.5) * 18, 24, (Math.random() - 0.5) * 18); - posVec.add(motVec); - motVec.normalize().negate().multiply(1.5); + if (player.getCurrentEquippedItem() == par1ItemStack + && player.swingProgress == check + && !par2World.isRemote + && par2World.rand.nextInt(2) == 0) { + MovingObjectPosition pos = ToolCommons.raytraceFromEntity(par2World, par3Entity, true, 48); + if (pos != null) { + Vector3 posVec = new Vector3(pos.blockX, pos.blockY, pos.blockZ); + Vector3 motVec = new Vector3((Math.random() - 0.5) * 18, 24, (Math.random() - 0.5) * 18); + posVec.add(motVec); + motVec.normalize().negate().multiply(1.5); - EntityFallingStar star = new EntityFallingStar(par2World, player); - star.setPosition(posVec.x, posVec.y, posVec.z); - star.motionX = motVec.x; - star.motionY = motVec.y; - star.motionZ = motVec.z; - par2World.spawnEntityInWorld(star); + EntityFallingStar star = new EntityFallingStar(par2World, player); + star.setPosition(posVec.x, posVec.y, posVec.z); + star.motionX = motVec.x; + star.motionY = motVec.y; + star.motionZ = motVec.z; + par2World.spawnEntityInWorld(star); - ToolCommons.damageItem(par1ItemStack, 1, player, MANA_PER_DAMAGE); - par2World.playSoundAtEntity(player, "botania:starcaller", 0.4F, 1.4F); - } - } - } - } + ToolCommons.damageItem(par1ItemStack, 1, player, MANA_PER_DAMAGE); + par2World.playSoundAtEntity(player, "botania:starcaller", 0.4F, 1.4F); + } + } + } + } - @Override - public int getManaPerDamage() { - return MANA_PER_DAMAGE; - } - - @Override - public boolean getIsRepairable(ItemStack par1ItemStack, ItemStack par2ItemStack) { - return par2ItemStack.getItem() == ModItems.manaResource && par2ItemStack.getItemDamage() == 4 ? true : super.getIsRepairable(par1ItemStack, par2ItemStack); - } - - @Override - public Achievement getAchievementOnCraft(ItemStack stack, EntityPlayer player, IInventory matrix) { - return ModAchievements.terrasteelWeaponCraft; - } + @Override + public int getManaPerDamage() { + return MANA_PER_DAMAGE; + } + @Override + public boolean getIsRepairable(ItemStack par1ItemStack, ItemStack par2ItemStack) { + return par2ItemStack.getItem() == ModItems.manaResource && par2ItemStack.getItemDamage() == 4 + ? true + : super.getIsRepairable(par1ItemStack, par2ItemStack); + } + @Override + public Achievement getAchievementOnCraft(ItemStack stack, EntityPlayer player, IInventory matrix) { + return ModAchievements.terrasteelWeaponCraft; + } } diff --git a/src/main/java/vazkii/botania/common/item/equipment/tool/ItemThunderSword.java b/src/main/java/vazkii/botania/common/item/equipment/tool/ItemThunderSword.java index 27d6d41f4e..709c3ec45b 100644 --- a/src/main/java/vazkii/botania/common/item/equipment/tool/ItemThunderSword.java +++ b/src/main/java/vazkii/botania/common/item/equipment/tool/ItemThunderSword.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Aug 27, 2015, 10:38:50 PM (GMT)] */ package vazkii.botania.common.item.equipment.tool; @@ -13,7 +13,6 @@ import java.util.ArrayList; import java.util.List; import java.util.Random; - import net.minecraft.command.IEntitySelector; import net.minecraft.entity.Entity; import net.minecraft.entity.EntityLivingBase; @@ -35,60 +34,73 @@ public class ItemThunderSword extends ItemManasteelSword implements ICraftAchievement { - private static final String TAG_LIGHTNING_SEED = "lightningSeed"; - - public ItemThunderSword() { - super(BotaniaAPI.terrasteelToolMaterial, LibItemNames.THUNDER_SWORD); - } - - @Override - public boolean hitEntity(ItemStack stack, EntityLivingBase entity, EntityLivingBase attacker) { - if(!(entity instanceof EntityPlayer) && entity != null) { - double range = 8; - final List alreadyTargetedEntities = new ArrayList(); - int dmg = 5; - long lightningSeed = ItemNBTHelper.getLong(stack, TAG_LIGHTNING_SEED, 0); - - IEntitySelector selector = new IEntitySelector() { - - @Override - public boolean isEntityApplicable(Entity e) { - return e instanceof EntityLivingBase && e instanceof IMob && !(e instanceof EntityPlayer) && !alreadyTargetedEntities.contains(e); - } - - }; - - Random rand = new Random(lightningSeed); - EntityLivingBase lightningSource = entity; - for(int i = 0; i < 4; i++) { - List entities = entity.worldObj.getEntitiesWithinAABBExcludingEntity(lightningSource, AxisAlignedBB.getBoundingBox(lightningSource.posX - range, lightningSource.posY - range, lightningSource.posZ - range, lightningSource.posX + range, lightningSource.posY + range, lightningSource.posZ + range), selector); - if(entities.isEmpty()) - break; - - EntityLivingBase target = entities.get(rand.nextInt(entities.size())); - if(attacker instanceof EntityPlayer) - target.attackEntityFrom(DamageSource.causePlayerDamage((EntityPlayer) attacker), dmg); - else target.attackEntityFrom(DamageSource.causeMobDamage(attacker), dmg); - - Botania.proxy.lightningFX(entity.worldObj, Vector3.fromEntityCenter(lightningSource), Vector3.fromEntityCenter(target), 1, 0x0179C4, 0xAADFFF); - - alreadyTargetedEntities.add(target); - lightningSource = target; - dmg--; - } - - if(!entity.worldObj.isRemote) - ItemNBTHelper.setLong(stack, TAG_LIGHTNING_SEED, entity.worldObj.rand.nextLong()); - } - - - return super.hitEntity(stack, entity, attacker); - } - - @Override - public Achievement getAchievementOnCraft(ItemStack stack, EntityPlayer player, IInventory matrix) { - return ModAchievements.terrasteelWeaponCraft; - } - - + private static final String TAG_LIGHTNING_SEED = "lightningSeed"; + + public ItemThunderSword() { + super(BotaniaAPI.terrasteelToolMaterial, LibItemNames.THUNDER_SWORD); + } + + @Override + public boolean hitEntity(ItemStack stack, EntityLivingBase entity, EntityLivingBase attacker) { + if (!(entity instanceof EntityPlayer) && entity != null) { + double range = 8; + final List alreadyTargetedEntities = new ArrayList(); + int dmg = 5; + long lightningSeed = ItemNBTHelper.getLong(stack, TAG_LIGHTNING_SEED, 0); + + IEntitySelector selector = new IEntitySelector() { + + @Override + public boolean isEntityApplicable(Entity e) { + return e instanceof EntityLivingBase + && e instanceof IMob + && !(e instanceof EntityPlayer) + && !alreadyTargetedEntities.contains(e); + } + }; + + Random rand = new Random(lightningSeed); + EntityLivingBase lightningSource = entity; + for (int i = 0; i < 4; i++) { + List entities = entity.worldObj.getEntitiesWithinAABBExcludingEntity( + lightningSource, + AxisAlignedBB.getBoundingBox( + lightningSource.posX - range, + lightningSource.posY - range, + lightningSource.posZ - range, + lightningSource.posX + range, + lightningSource.posY + range, + lightningSource.posZ + range), + selector); + if (entities.isEmpty()) break; + + EntityLivingBase target = entities.get(rand.nextInt(entities.size())); + if (attacker instanceof EntityPlayer) + target.attackEntityFrom(DamageSource.causePlayerDamage((EntityPlayer) attacker), dmg); + else target.attackEntityFrom(DamageSource.causeMobDamage(attacker), dmg); + + Botania.proxy.lightningFX( + entity.worldObj, + Vector3.fromEntityCenter(lightningSource), + Vector3.fromEntityCenter(target), + 1, + 0x0179C4, + 0xAADFFF); + + alreadyTargetedEntities.add(target); + lightningSource = target; + dmg--; + } + + if (!entity.worldObj.isRemote) + ItemNBTHelper.setLong(stack, TAG_LIGHTNING_SEED, entity.worldObj.rand.nextLong()); + } + + return super.hitEntity(stack, entity, attacker); + } + + @Override + public Achievement getAchievementOnCraft(ItemStack stack, EntityPlayer player, IInventory matrix) { + return ModAchievements.terrasteelWeaponCraft; + } } diff --git a/src/main/java/vazkii/botania/common/item/equipment/tool/ToolCommons.java b/src/main/java/vazkii/botania/common/item/equipment/tool/ToolCommons.java index c6346db91b..f8792d93b0 100644 --- a/src/main/java/vazkii/botania/common/item/equipment/tool/ToolCommons.java +++ b/src/main/java/vazkii/botania/common/item/equipment/tool/ToolCommons.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Apr 13, 2014, 7:13:04 PM (GMT)] */ package vazkii.botania.common.item.equipment.tool; @@ -34,121 +34,199 @@ public final class ToolCommons { - public static Material[] materialsPick = new Material[]{ Material.rock, Material.iron, Material.ice, Material.glass, Material.piston, Material.anvil }; - public static Material[] materialsShovel = new Material[]{ Material.grass, Material.ground, Material.sand, Material.snow, Material.craftedSnow, Material.clay }; - public static Material[] materialsAxe = new Material[]{ Material.coral, Material.leaves, Material.plants, Material.wood, Material.gourd }; - - public static void damageItem(ItemStack stack, int dmg, EntityLivingBase entity, int manaPerDamage) { - int manaToRequest = dmg * manaPerDamage; - boolean manaRequested = entity instanceof EntityPlayer ? ManaItemHandler.requestManaExactForTool(stack, (EntityPlayer) entity, manaToRequest, true) : false; - - if(!manaRequested) - stack.damageItem(dmg, entity); - } - - public static void removeBlocksInIteration(EntityPlayer player, ItemStack stack, World world, int x, int y, int z, int xs, int ys, int zs, int xe, int ye, int ze, Block block, Material[] materialsListing, boolean silk, int fortune, boolean dispose) { - float blockHardness = block == null ? 1F : block.getBlockHardness(world, x, y, z); - - for(int x1 = xs; x1 < xe; x1++) - for(int y1 = ys; y1 < ye; y1++) - for(int z1 = zs; z1 < ze; z1++) - removeBlockWithDrops(player, stack, world, x1 + x, y1 + y, z1 + z, x, y, z, block, materialsListing, silk, fortune, blockHardness, dispose); - } - - public static boolean isRightMaterial(Material material, Material[] materialsListing) { - for(Material mat : materialsListing) - if(material == mat) - return true; - - return false; - } - - public static void removeBlockWithDrops(EntityPlayer player, ItemStack stack, World world, int x, int y, int z, int bx, int by, int bz, Block block, Material[] materialsListing, boolean silk, int fortune, float blockHardness, boolean dispose) { - removeBlockWithDrops(player, stack, world, x, y, z, bx, by, bz, block, materialsListing, silk, fortune, blockHardness, dispose, true); - } - - public static void removeBlockWithDrops(EntityPlayer player, ItemStack stack, World world, int x, int y, int z, int bx, int by, int bz, Block block, Material[] materialsListing, boolean silk, int fortune, float blockHardness, boolean dispose, boolean particles) { - if(!world.blockExists(x, y, z)) - return; - - Block blk = world.getBlock(x, y, z); - int meta = world.getBlockMetadata(x, y, z); - - if(block != null && blk != block) - return; - - Material mat = world.getBlock(x, y, z).getMaterial(); - if(!world.isRemote && blk != null && !blk.isAir(world, x, y, z) && blk.getPlayerRelativeBlockHardness(player, world, x, y, z) > 0) { - if(!blk.canHarvestBlock(player, meta) || !isRightMaterial(mat, materialsListing)) - return; - - if(!player.capabilities.isCreativeMode) { - int localMeta = world.getBlockMetadata(x, y, z); - blk.onBlockHarvested(world, x, y, z, localMeta, player); - - if(blk.removedByPlayer(world, player, x, y, z, true)) { - blk.onBlockDestroyedByPlayer(world, x, y, z, localMeta); - - if(!dispose || !ItemElementiumPick.isDisposable(blk)) - blk.harvestBlock(world, player, x, y, z, localMeta); - } - - damageItem(stack, 1, player, 80); - } else world.setBlockToAir(x, y, z); - - if(particles && !world.isRemote && ConfigHandler.blockBreakParticles && ConfigHandler.blockBreakParticlesTool) - world.playAuxSFX(2001, x, y, z, Block.getIdFromBlock(blk) + (meta << 12)); - } - } - - public static int getToolPriority(ItemStack stack) { - if(stack == null) - return 0; - - Item item = stack.getItem(); - if(!(item instanceof ItemTool)) - return 0; - - ItemTool tool = (ItemTool) item; - ToolMaterial material = tool.func_150913_i(); - int materialLevel = 0; - if(material == BotaniaAPI.manasteelToolMaterial) - materialLevel = 10; - if(material == BotaniaAPI.elementiumToolMaterial) - materialLevel = 11; - if(material == BotaniaAPI.terrasteelToolMaterial) - materialLevel = 20; - - int modifier = 0; - if(item == ModItems.terraPick) - modifier = ItemTerraPick.getLevel(stack); - - int efficiency = EnchantmentHelper.getEnchantmentLevel(Enchantment.efficiency.effectId, stack); - return materialLevel * 100 + modifier * 10 + efficiency; - } - - /** - * @author mDiyo - */ - public static MovingObjectPosition raytraceFromEntity(World world, Entity player, boolean par3, double range) { - float f = 1.0F; - float f1 = player.prevRotationPitch + (player.rotationPitch - player.prevRotationPitch) * f; - float f2 = player.prevRotationYaw + (player.rotationYaw - player.prevRotationYaw) * f; - double d0 = player.prevPosX + (player.posX - player.prevPosX) * f; - double d1 = player.prevPosY + (player.posY - player.prevPosY) * f; - if (!world.isRemote && player instanceof EntityPlayer) - d1 += ((EntityPlayer) player).eyeHeight; - double d2 = player.prevPosZ + (player.posZ - player.prevPosZ) * f; - Vec3 vec3 = Vec3.createVectorHelper(d0, d1, d2); - float f3 = MathHelper.cos(-f2 * 0.017453292F - (float) Math.PI); - float f4 = MathHelper.sin(-f2 * 0.017453292F - (float) Math.PI); - float f5 = -MathHelper.cos(-f1 * 0.017453292F); - float f6 = MathHelper.sin(-f1 * 0.017453292F); - float f7 = f4 * f5; - float f8 = f3 * f5; - double d3 = range; - Vec3 vec31 = vec3.addVector(f7 * d3, f6 * d3, f8 * d3); - return world.rayTraceBlocks(vec3, vec31, par3); - } - + public static Material[] materialsPick = + new Material[] {Material.rock, Material.iron, Material.ice, Material.glass, Material.piston, Material.anvil + }; + public static Material[] materialsShovel = new Material[] { + Material.grass, Material.ground, Material.sand, Material.snow, Material.craftedSnow, Material.clay + }; + public static Material[] materialsAxe = + new Material[] {Material.coral, Material.leaves, Material.plants, Material.wood, Material.gourd}; + + public static void damageItem(ItemStack stack, int dmg, EntityLivingBase entity, int manaPerDamage) { + int manaToRequest = dmg * manaPerDamage; + boolean manaRequested = entity instanceof EntityPlayer + ? ManaItemHandler.requestManaExactForTool(stack, (EntityPlayer) entity, manaToRequest, true) + : false; + + if (!manaRequested) stack.damageItem(dmg, entity); + } + + public static void removeBlocksInIteration( + EntityPlayer player, + ItemStack stack, + World world, + int x, + int y, + int z, + int xs, + int ys, + int zs, + int xe, + int ye, + int ze, + Block block, + Material[] materialsListing, + boolean silk, + int fortune, + boolean dispose) { + float blockHardness = block == null ? 1F : block.getBlockHardness(world, x, y, z); + + for (int x1 = xs; x1 < xe; x1++) + for (int y1 = ys; y1 < ye; y1++) + for (int z1 = zs; z1 < ze; z1++) + removeBlockWithDrops( + player, + stack, + world, + x1 + x, + y1 + y, + z1 + z, + x, + y, + z, + block, + materialsListing, + silk, + fortune, + blockHardness, + dispose); + } + + public static boolean isRightMaterial(Material material, Material[] materialsListing) { + for (Material mat : materialsListing) if (material == mat) return true; + + return false; + } + + public static void removeBlockWithDrops( + EntityPlayer player, + ItemStack stack, + World world, + int x, + int y, + int z, + int bx, + int by, + int bz, + Block block, + Material[] materialsListing, + boolean silk, + int fortune, + float blockHardness, + boolean dispose) { + removeBlockWithDrops( + player, + stack, + world, + x, + y, + z, + bx, + by, + bz, + block, + materialsListing, + silk, + fortune, + blockHardness, + dispose, + true); + } + + public static void removeBlockWithDrops( + EntityPlayer player, + ItemStack stack, + World world, + int x, + int y, + int z, + int bx, + int by, + int bz, + Block block, + Material[] materialsListing, + boolean silk, + int fortune, + float blockHardness, + boolean dispose, + boolean particles) { + if (!world.blockExists(x, y, z)) return; + + Block blk = world.getBlock(x, y, z); + int meta = world.getBlockMetadata(x, y, z); + + if (block != null && blk != block) return; + + Material mat = world.getBlock(x, y, z).getMaterial(); + if (!world.isRemote + && blk != null + && !blk.isAir(world, x, y, z) + && blk.getPlayerRelativeBlockHardness(player, world, x, y, z) > 0) { + if (!blk.canHarvestBlock(player, meta) || !isRightMaterial(mat, materialsListing)) return; + + if (!player.capabilities.isCreativeMode) { + int localMeta = world.getBlockMetadata(x, y, z); + blk.onBlockHarvested(world, x, y, z, localMeta, player); + + if (blk.removedByPlayer(world, player, x, y, z, true)) { + blk.onBlockDestroyedByPlayer(world, x, y, z, localMeta); + + if (!dispose || !ItemElementiumPick.isDisposable(blk)) + blk.harvestBlock(world, player, x, y, z, localMeta); + } + + damageItem(stack, 1, player, 80); + } else world.setBlockToAir(x, y, z); + + if (particles + && !world.isRemote + && ConfigHandler.blockBreakParticles + && ConfigHandler.blockBreakParticlesTool) + world.playAuxSFX(2001, x, y, z, Block.getIdFromBlock(blk) + (meta << 12)); + } + } + + public static int getToolPriority(ItemStack stack) { + if (stack == null) return 0; + + Item item = stack.getItem(); + if (!(item instanceof ItemTool)) return 0; + + ItemTool tool = (ItemTool) item; + ToolMaterial material = tool.func_150913_i(); + int materialLevel = 0; + if (material == BotaniaAPI.manasteelToolMaterial) materialLevel = 10; + if (material == BotaniaAPI.elementiumToolMaterial) materialLevel = 11; + if (material == BotaniaAPI.terrasteelToolMaterial) materialLevel = 20; + + int modifier = 0; + if (item == ModItems.terraPick) modifier = ItemTerraPick.getLevel(stack); + + int efficiency = EnchantmentHelper.getEnchantmentLevel(Enchantment.efficiency.effectId, stack); + return materialLevel * 100 + modifier * 10 + efficiency; + } + + /** + * @author mDiyo + */ + public static MovingObjectPosition raytraceFromEntity(World world, Entity player, boolean par3, double range) { + float f = 1.0F; + float f1 = player.prevRotationPitch + (player.rotationPitch - player.prevRotationPitch) * f; + float f2 = player.prevRotationYaw + (player.rotationYaw - player.prevRotationYaw) * f; + double d0 = player.prevPosX + (player.posX - player.prevPosX) * f; + double d1 = player.prevPosY + (player.posY - player.prevPosY) * f; + if (!world.isRemote && player instanceof EntityPlayer) d1 += ((EntityPlayer) player).eyeHeight; + double d2 = player.prevPosZ + (player.posZ - player.prevPosZ) * f; + Vec3 vec3 = Vec3.createVectorHelper(d0, d1, d2); + float f3 = MathHelper.cos(-f2 * 0.017453292F - (float) Math.PI); + float f4 = MathHelper.sin(-f2 * 0.017453292F - (float) Math.PI); + float f5 = -MathHelper.cos(-f1 * 0.017453292F); + float f6 = MathHelper.sin(-f1 * 0.017453292F); + float f7 = f4 * f5; + float f8 = f3 * f5; + double d3 = range; + Vec3 vec31 = vec3.addVector(f7 * d3, f6 * d3, f8 * d3); + return world.rayTraceBlocks(vec3, vec31, par3); + } } diff --git a/src/main/java/vazkii/botania/common/item/equipment/tool/bow/ItemCrystalBow.java b/src/main/java/vazkii/botania/common/item/equipment/tool/bow/ItemCrystalBow.java index 541b15fd49..28bdaa0a6f 100644 --- a/src/main/java/vazkii/botania/common/item/equipment/tool/bow/ItemCrystalBow.java +++ b/src/main/java/vazkii/botania/common/item/equipment/tool/bow/ItemCrystalBow.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Feb 21, 2015, 6:33:40 PM (GMT)] */ package vazkii.botania.common.item.equipment.tool.bow; @@ -21,32 +21,37 @@ public class ItemCrystalBow extends ItemLivingwoodBow { - private final int ARROW_COST = 200; - - public ItemCrystalBow() { - super(LibItemNames.CRYSTAL_BOW); - } - - @Override - float chargeVelocityMultiplier() { - return 2F; - } - - @Override - boolean postsEvent() { - return false; - } - - @Override - boolean canFire(ItemStack p_77615_1_, World p_77615_2_, EntityPlayer p_77615_3_, int p_77615_4_) { - int infinity = EnchantmentHelper.getEnchantmentLevel(Enchantment.infinity.effectId, p_77615_1_); - return ManaItemHandler.requestManaExactForTool(p_77615_1_, p_77615_3_, ARROW_COST / (infinity + 1), false); - } - - @Override - void onFire(ItemStack p_77615_1_, World p_77615_2_, EntityPlayer p_77615_3_, int p_77615_4_, boolean infinity, EntityArrow arrow) { - arrow.canBePickedUp = 2; - ManaItemHandler.requestManaExactForTool(p_77615_1_, p_77615_3_, ARROW_COST / (infinity ? 2 : 1), false); - } - + private final int ARROW_COST = 200; + + public ItemCrystalBow() { + super(LibItemNames.CRYSTAL_BOW); + } + + @Override + float chargeVelocityMultiplier() { + return 2F; + } + + @Override + boolean postsEvent() { + return false; + } + + @Override + boolean canFire(ItemStack p_77615_1_, World p_77615_2_, EntityPlayer p_77615_3_, int p_77615_4_) { + int infinity = EnchantmentHelper.getEnchantmentLevel(Enchantment.infinity.effectId, p_77615_1_); + return ManaItemHandler.requestManaExactForTool(p_77615_1_, p_77615_3_, ARROW_COST / (infinity + 1), false); + } + + @Override + void onFire( + ItemStack p_77615_1_, + World p_77615_2_, + EntityPlayer p_77615_3_, + int p_77615_4_, + boolean infinity, + EntityArrow arrow) { + arrow.canBePickedUp = 2; + ManaItemHandler.requestManaExactForTool(p_77615_1_, p_77615_3_, ARROW_COST / (infinity ? 2 : 1), false); + } } diff --git a/src/main/java/vazkii/botania/common/item/equipment/tool/bow/ItemLivingwoodBow.java b/src/main/java/vazkii/botania/common/item/equipment/tool/bow/ItemLivingwoodBow.java index c5ea853b9b..c830135ffc 100644 --- a/src/main/java/vazkii/botania/common/item/equipment/tool/bow/ItemLivingwoodBow.java +++ b/src/main/java/vazkii/botania/common/item/equipment/tool/bow/ItemLivingwoodBow.java @@ -2,14 +2,17 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Feb 21, 2015, 4:58:45 PM (GMT)] */ package vazkii.botania.common.item.equipment.tool.bow; +import cpw.mods.fml.common.registry.GameRegistry; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.enchantment.Enchantment; import net.minecraft.enchantment.EnchantmentHelper; @@ -33,163 +36,160 @@ import vazkii.botania.common.item.ModItems; import vazkii.botania.common.item.equipment.tool.ToolCommons; import vazkii.botania.common.lib.LibItemNames; -import cpw.mods.fml.common.registry.GameRegistry; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; public class ItemLivingwoodBow extends ItemBow implements IManaUsingItem { - public static final int MANA_PER_DAMAGE = 40; - IIcon[] pullIcons = new IIcon[3]; - - public ItemLivingwoodBow() { - this(LibItemNames.LIVINGWOOD_BOW); - } - - public ItemLivingwoodBow(String name) { - super(); - setCreativeTab(BotaniaCreativeTab.INSTANCE); - setUnlocalizedName(name); - setMaxDamage(500); - setFull3D(); - } - - @Override - public Item setUnlocalizedName(String par1Str) { - GameRegistry.registerItem(this, par1Str); - return super.setUnlocalizedName(par1Str); - } - - @Override - public String getUnlocalizedNameInefficiently(ItemStack par1ItemStack) { - return super.getUnlocalizedNameInefficiently(par1ItemStack).replaceAll("item.", "item." + LibResources.PREFIX_MOD); - } - - @Override - public ItemStack onItemRightClick(ItemStack p_77659_1_, World p_77659_2_, EntityPlayer p_77659_3_) { - ArrowNockEvent event = new ArrowNockEvent(p_77659_3_, p_77659_1_); - MinecraftForge.EVENT_BUS.post(event); - if(event.isCanceled()) - return event.result; - - if(canFire(p_77659_1_, p_77659_2_, p_77659_3_, 0)) - p_77659_3_.setItemInUse(p_77659_1_, getMaxItemUseDuration(p_77659_1_)); - - return p_77659_1_; - } - - @Override - public void onPlayerStoppedUsing(ItemStack p_77615_1_, World p_77615_2_, EntityPlayer p_77615_3_, int p_77615_4_) { - int j = (int) ((getMaxItemUseDuration(p_77615_1_) - p_77615_4_) * chargeVelocityMultiplier()); - - ArrowLooseEvent event = new ArrowLooseEvent(p_77615_3_, p_77615_1_, j); - MinecraftForge.EVENT_BUS.post(event); - if(event.isCanceled()) - return; - j = event.charge; - - boolean flag = canFire(p_77615_1_, p_77615_2_, p_77615_3_, p_77615_4_); - boolean infinity = EnchantmentHelper.getEnchantmentLevel(Enchantment.infinity.effectId, p_77615_1_) > 0; - - if(flag) { - float f = j / 20.0F; - f = (f * f + f * 2.0F) / 3.0F; - - if(f < 0.1D) - return; - - if(f > 1.0F) - f = 1.0F; - - EntityArrow entityarrow = makeArrow(p_77615_1_, p_77615_2_, p_77615_3_, p_77615_4_, f); - - if(f == 1.0F) - entityarrow.setIsCritical(true); - - int k = EnchantmentHelper.getEnchantmentLevel(Enchantment.power.effectId, p_77615_1_); - - if(k > 0) - entityarrow.setDamage(entityarrow.getDamage() + k * 0.5D + 0.5D); - - int l = EnchantmentHelper.getEnchantmentLevel(Enchantment.punch.effectId, p_77615_1_); - - if(l > 0) - entityarrow.setKnockbackStrength(l); - - if(EnchantmentHelper.getEnchantmentLevel(Enchantment.flame.effectId, p_77615_1_) > 0) - entityarrow.setFire(100); - - ToolCommons.damageItem(p_77615_1_, 1, p_77615_3_, MANA_PER_DAMAGE); - p_77615_2_.playSoundAtEntity(p_77615_3_, "random.bow", 1.0F, 1.0F / (itemRand.nextFloat() * 0.4F + 1.2F) + f * 0.5F); - - onFire(p_77615_1_, p_77615_2_, p_77615_3_, p_77615_4_, infinity, entityarrow); - - if(!p_77615_2_.isRemote) - p_77615_2_.spawnEntityInWorld(entityarrow); - } - } - - float chargeVelocityMultiplier() { - return 1F; - } + public static final int MANA_PER_DAMAGE = 40; + IIcon[] pullIcons = new IIcon[3]; - boolean postsEvent() { - return true; - } + public ItemLivingwoodBow() { + this(LibItemNames.LIVINGWOOD_BOW); + } - EntityArrow makeArrow(ItemStack p_77615_1_, World p_77615_2_, EntityPlayer p_77615_3_, int p_77615_4_, float f) { - return new EntityArrow(p_77615_2_, p_77615_3_, f * 2.0F); - } - - boolean canFire(ItemStack p_77615_1_, World p_77615_2_, EntityPlayer p_77615_3_, int p_77615_4_) { - return p_77615_3_.capabilities.isCreativeMode || EnchantmentHelper.getEnchantmentLevel(Enchantment.infinity.effectId, p_77615_1_) > 0 || p_77615_3_.inventory.hasItem(Items.arrow); - } - - void onFire(ItemStack p_77615_1_, World p_77615_2_, EntityPlayer p_77615_3_, int p_77615_4_, boolean infinity, EntityArrow arrow) { - if(infinity) - arrow.canBePickedUp = 2; - else p_77615_3_.inventory.consumeInventoryItem(Items.arrow); - } + public ItemLivingwoodBow(String name) { + super(); + setCreativeTab(BotaniaCreativeTab.INSTANCE); + setUnlocalizedName(name); + setMaxDamage(500); + setFull3D(); + } - @Override - @SideOnly(Side.CLIENT) - public void registerIcons(IIconRegister par1IconRegister) { - itemIcon = IconHelper.forItem(par1IconRegister, this, 0); - for(int i = 0; i < 3; i++) - pullIcons[i] = IconHelper.forItem(par1IconRegister, this, i + 1); - } + @Override + public Item setUnlocalizedName(String par1Str) { + GameRegistry.registerItem(this, par1Str); + return super.setUnlocalizedName(par1Str); + } - @Override - public void onUpdate(ItemStack stack, World world, Entity player, int par4, boolean par5) { - if(!world.isRemote && player instanceof EntityPlayer && stack.getItemDamage() > 0 && ManaItemHandler.requestManaExactForTool(stack, (EntityPlayer) player, MANA_PER_DAMAGE * 2, true)) - stack.setItemDamage(stack.getItemDamage() - 1); - } + @Override + public String getUnlocalizedNameInefficiently(ItemStack par1ItemStack) { + return super.getUnlocalizedNameInefficiently(par1ItemStack) + .replaceAll("item.", "item." + LibResources.PREFIX_MOD); + } + + @Override + public ItemStack onItemRightClick(ItemStack p_77659_1_, World p_77659_2_, EntityPlayer p_77659_3_) { + ArrowNockEvent event = new ArrowNockEvent(p_77659_3_, p_77659_1_); + MinecraftForge.EVENT_BUS.post(event); + if (event.isCanceled()) return event.result; + + if (canFire(p_77659_1_, p_77659_2_, p_77659_3_, 0)) + p_77659_3_.setItemInUse(p_77659_1_, getMaxItemUseDuration(p_77659_1_)); + + return p_77659_1_; + } + + @Override + public void onPlayerStoppedUsing(ItemStack p_77615_1_, World p_77615_2_, EntityPlayer p_77615_3_, int p_77615_4_) { + int j = (int) ((getMaxItemUseDuration(p_77615_1_) - p_77615_4_) * chargeVelocityMultiplier()); + + ArrowLooseEvent event = new ArrowLooseEvent(p_77615_3_, p_77615_1_, j); + MinecraftForge.EVENT_BUS.post(event); + if (event.isCanceled()) return; + j = event.charge; + + boolean flag = canFire(p_77615_1_, p_77615_2_, p_77615_3_, p_77615_4_); + boolean infinity = EnchantmentHelper.getEnchantmentLevel(Enchantment.infinity.effectId, p_77615_1_) > 0; + + if (flag) { + float f = j / 20.0F; + f = (f * f + f * 2.0F) / 3.0F; + + if (f < 0.1D) return; + + if (f > 1.0F) f = 1.0F; + + EntityArrow entityarrow = makeArrow(p_77615_1_, p_77615_2_, p_77615_3_, p_77615_4_, f); + + if (f == 1.0F) entityarrow.setIsCritical(true); + + int k = EnchantmentHelper.getEnchantmentLevel(Enchantment.power.effectId, p_77615_1_); + + if (k > 0) entityarrow.setDamage(entityarrow.getDamage() + k * 0.5D + 0.5D); + + int l = EnchantmentHelper.getEnchantmentLevel(Enchantment.punch.effectId, p_77615_1_); + + if (l > 0) entityarrow.setKnockbackStrength(l); + + if (EnchantmentHelper.getEnchantmentLevel(Enchantment.flame.effectId, p_77615_1_) > 0) + entityarrow.setFire(100); + + ToolCommons.damageItem(p_77615_1_, 1, p_77615_3_, MANA_PER_DAMAGE); + p_77615_2_.playSoundAtEntity( + p_77615_3_, "random.bow", 1.0F, 1.0F / (itemRand.nextFloat() * 0.4F + 1.2F) + f * 0.5F); + + onFire(p_77615_1_, p_77615_2_, p_77615_3_, p_77615_4_, infinity, entityarrow); + + if (!p_77615_2_.isRemote) p_77615_2_.spawnEntityInWorld(entityarrow); + } + } + + float chargeVelocityMultiplier() { + return 1F; + } + + boolean postsEvent() { + return true; + } + + EntityArrow makeArrow(ItemStack p_77615_1_, World p_77615_2_, EntityPlayer p_77615_3_, int p_77615_4_, float f) { + return new EntityArrow(p_77615_2_, p_77615_3_, f * 2.0F); + } + + boolean canFire(ItemStack p_77615_1_, World p_77615_2_, EntityPlayer p_77615_3_, int p_77615_4_) { + return p_77615_3_.capabilities.isCreativeMode + || EnchantmentHelper.getEnchantmentLevel(Enchantment.infinity.effectId, p_77615_1_) > 0 + || p_77615_3_.inventory.hasItem(Items.arrow); + } + + void onFire( + ItemStack p_77615_1_, + World p_77615_2_, + EntityPlayer p_77615_3_, + int p_77615_4_, + boolean infinity, + EntityArrow arrow) { + if (infinity) arrow.canBePickedUp = 2; + else p_77615_3_.inventory.consumeInventoryItem(Items.arrow); + } + + @Override + @SideOnly(Side.CLIENT) + public void registerIcons(IIconRegister par1IconRegister) { + itemIcon = IconHelper.forItem(par1IconRegister, this, 0); + for (int i = 0; i < 3; i++) pullIcons[i] = IconHelper.forItem(par1IconRegister, this, i + 1); + } - @Override - public boolean getIsRepairable(ItemStack par1ItemStack, ItemStack par2ItemStack) { - return par2ItemStack.getItem() == ModItems.manaResource && par2ItemStack.getItemDamage() == 3 ? true : super.getIsRepairable(par1ItemStack, par2ItemStack); - } + @Override + public void onUpdate(ItemStack stack, World world, Entity player, int par4, boolean par5) { + if (!world.isRemote + && player instanceof EntityPlayer + && stack.getItemDamage() > 0 + && ManaItemHandler.requestManaExactForTool(stack, (EntityPlayer) player, MANA_PER_DAMAGE * 2, true)) + stack.setItemDamage(stack.getItemDamage() - 1); + } - @Override - public boolean usesMana(ItemStack stack) { - return true; - } + @Override + public boolean getIsRepairable(ItemStack par1ItemStack, ItemStack par2ItemStack) { + return par2ItemStack.getItem() == ModItems.manaResource && par2ItemStack.getItemDamage() == 3 + ? true + : super.getIsRepairable(par1ItemStack, par2ItemStack); + } - @Override - public IIcon getIcon(ItemStack stack, int renderPass, EntityPlayer player, ItemStack usingItem, int useRemaining) { - if(stack != usingItem) - return itemIcon; + @Override + public boolean usesMana(ItemStack stack) { + return true; + } - int j = (int) ((getMaxItemUseDuration(stack) - useRemaining) * chargeVelocityMultiplier()); + @Override + public IIcon getIcon(ItemStack stack, int renderPass, EntityPlayer player, ItemStack usingItem, int useRemaining) { + if (stack != usingItem) return itemIcon; - if(j >= 18) - return pullIcons[2]; - if(j > 13) - return pullIcons[1]; - if(j > 0) - return pullIcons[0]; + int j = (int) ((getMaxItemUseDuration(stack) - useRemaining) * chargeVelocityMultiplier()); - return itemIcon; - } + if (j >= 18) return pullIcons[2]; + if (j > 13) return pullIcons[1]; + if (j > 0) return pullIcons[0]; + return itemIcon; + } } diff --git a/src/main/java/vazkii/botania/common/item/equipment/tool/elementium/ItemElementiumAxe.java b/src/main/java/vazkii/botania/common/item/equipment/tool/elementium/ItemElementiumAxe.java index 0357892a39..129de75f1d 100644 --- a/src/main/java/vazkii/botania/common/item/equipment/tool/elementium/ItemElementiumAxe.java +++ b/src/main/java/vazkii/botania/common/item/equipment/tool/elementium/ItemElementiumAxe.java @@ -1,7 +1,7 @@ package vazkii.botania.common.item.equipment.tool.elementium; +import cpw.mods.fml.common.eventhandler.SubscribeEvent; import java.util.Random; - import net.minecraft.enchantment.Enchantment; import net.minecraft.enchantment.EnchantmentHelper; import net.minecraft.entity.item.EntityItem; @@ -20,46 +20,53 @@ import vazkii.botania.common.item.ModItems; import vazkii.botania.common.item.equipment.tool.manasteel.ItemManasteelAxe; import vazkii.botania.common.lib.LibItemNames; -import cpw.mods.fml.common.eventhandler.SubscribeEvent; public class ItemElementiumAxe extends ItemManasteelAxe { - public ItemElementiumAxe() { - super(BotaniaAPI.elementiumToolMaterial, LibItemNames.ELEMENTIUM_AXE); - MinecraftForge.EVENT_BUS.register(this); - } - - // Thanks to SpitefulFox for the drop rates - // https://github.com/SpitefulFox/ForbiddenMagic/blob/master/src/com/spiteful/forbidden/FMEventHandler.java + public ItemElementiumAxe() { + super(BotaniaAPI.elementiumToolMaterial, LibItemNames.ELEMENTIUM_AXE); + MinecraftForge.EVENT_BUS.register(this); + } - @SubscribeEvent - public void onEntityDrops(LivingDropsEvent event) { - if(event.recentlyHit && event.source.getEntity() != null && event.source.getEntity() instanceof EntityPlayer) { - ItemStack weapon = ((EntityPlayer) event.source.getEntity()).getCurrentEquippedItem(); - if(weapon != null && weapon.getItem() == this) { - Random rand = event.entity.worldObj.rand; - int looting = EnchantmentHelper.getEnchantmentLevel(Enchantment.fortune.effectId, weapon); + // Thanks to SpitefulFox for the drop rates + // https://github.com/SpitefulFox/ForbiddenMagic/blob/master/src/com/spiteful/forbidden/FMEventHandler.java - if(event.entityLiving instanceof EntitySkeleton && rand.nextInt(26) <= 3 + looting) - addDrop(event, new ItemStack(Items.skull, 1, ((EntitySkeleton)event.entityLiving).getSkeletonType())); - else if(event.entityLiving instanceof EntityZombie && !(event.entityLiving instanceof EntityPigZombie) && rand.nextInt(26) <= 2 + 2 * looting) - addDrop(event, new ItemStack(Items.skull, 1, 2)); - else if(event.entityLiving instanceof EntityCreeper && rand.nextInt(26) <= 2 + 2 * looting) - addDrop(event, new ItemStack(Items.skull, 1, 4)); - else if(event.entityLiving instanceof EntityPlayer && rand.nextInt(11) <= 1 + looting) { - ItemStack stack = new ItemStack(Items.skull, 1, 3); - ItemNBTHelper.setString(stack, "SkullOwner", ((EntityPlayer)event.entityLiving).getCommandSenderName()); - addDrop(event, stack); - } else if(event.entityLiving instanceof EntityDoppleganger && rand.nextInt(13) < 1 + looting) - addDrop(event, new ItemStack(ModItems.gaiaHead)); - } - } - } + @SubscribeEvent + public void onEntityDrops(LivingDropsEvent event) { + if (event.recentlyHit && event.source.getEntity() != null && event.source.getEntity() instanceof EntityPlayer) { + ItemStack weapon = ((EntityPlayer) event.source.getEntity()).getCurrentEquippedItem(); + if (weapon != null && weapon.getItem() == this) { + Random rand = event.entity.worldObj.rand; + int looting = EnchantmentHelper.getEnchantmentLevel(Enchantment.fortune.effectId, weapon); - private void addDrop(LivingDropsEvent event, ItemStack drop) { - EntityItem entityitem = new EntityItem(event.entityLiving.worldObj, event.entityLiving.posX, event.entityLiving.posY, event.entityLiving.posZ, drop); - entityitem.delayBeforeCanPickup = 10; - event.drops.add(entityitem); - } + if (event.entityLiving instanceof EntitySkeleton && rand.nextInt(26) <= 3 + looting) + addDrop( + event, + new ItemStack(Items.skull, 1, ((EntitySkeleton) event.entityLiving).getSkeletonType())); + else if (event.entityLiving instanceof EntityZombie + && !(event.entityLiving instanceof EntityPigZombie) + && rand.nextInt(26) <= 2 + 2 * looting) addDrop(event, new ItemStack(Items.skull, 1, 2)); + else if (event.entityLiving instanceof EntityCreeper && rand.nextInt(26) <= 2 + 2 * looting) + addDrop(event, new ItemStack(Items.skull, 1, 4)); + else if (event.entityLiving instanceof EntityPlayer && rand.nextInt(11) <= 1 + looting) { + ItemStack stack = new ItemStack(Items.skull, 1, 3); + ItemNBTHelper.setString( + stack, "SkullOwner", ((EntityPlayer) event.entityLiving).getCommandSenderName()); + addDrop(event, stack); + } else if (event.entityLiving instanceof EntityDoppleganger && rand.nextInt(13) < 1 + looting) + addDrop(event, new ItemStack(ModItems.gaiaHead)); + } + } + } + private void addDrop(LivingDropsEvent event, ItemStack drop) { + EntityItem entityitem = new EntityItem( + event.entityLiving.worldObj, + event.entityLiving.posX, + event.entityLiving.posY, + event.entityLiving.posZ, + drop); + entityitem.delayBeforeCanPickup = 10; + event.drops.add(entityitem); + } } diff --git a/src/main/java/vazkii/botania/common/item/equipment/tool/elementium/ItemElementiumPick.java b/src/main/java/vazkii/botania/common/item/equipment/tool/elementium/ItemElementiumPick.java index bead2f8fcc..ad0a54d88a 100644 --- a/src/main/java/vazkii/botania/common/item/equipment/tool/elementium/ItemElementiumPick.java +++ b/src/main/java/vazkii/botania/common/item/equipment/tool/elementium/ItemElementiumPick.java @@ -1,8 +1,6 @@ package vazkii.botania.common.item.equipment.tool.elementium; -import java.util.Arrays; -import java.util.List; - +import cpw.mods.fml.common.eventhandler.SubscribeEvent; import net.minecraft.block.Block; import net.minecraft.item.ItemStack; import net.minecraftforge.common.MinecraftForge; @@ -13,49 +11,48 @@ import vazkii.botania.common.item.equipment.tool.manasteel.ItemManasteelPick; import vazkii.botania.common.item.equipment.tool.terrasteel.ItemTerraPick; import vazkii.botania.common.lib.LibItemNames; -import cpw.mods.fml.common.eventhandler.SubscribeEvent; public class ItemElementiumPick extends ItemManasteelPick { - public ItemElementiumPick() { - super(BotaniaAPI.elementiumToolMaterial, LibItemNames.ELEMENTIUM_PICK); - MinecraftForge.EVENT_BUS.register(this); - } + public ItemElementiumPick() { + super(BotaniaAPI.elementiumToolMaterial, LibItemNames.ELEMENTIUM_PICK); + MinecraftForge.EVENT_BUS.register(this); + } + + @SubscribeEvent + public void onHarvestDrops(HarvestDropsEvent event) { + if (event.harvester != null) { + ItemStack stack = event.harvester.getCurrentEquippedItem(); + if (stack != null + && (stack.getItem() == this + || stack.getItem() == ModItems.terraPick && ItemTerraPick.isTipped(stack))) { + for (int i = 0; i < event.drops.size(); i++) { + ItemStack drop = event.drops.get(i); + if (drop != null) { + Block block = Block.getBlockFromItem(drop.getItem()); + if (block != null) { + if (isDisposable(block) || (isSemiDisposable(block) && !event.harvester.isSneaking())) + event.drops.remove(i); + } + } + } + } + } + } - @SubscribeEvent - public void onHarvestDrops(HarvestDropsEvent event) { - if(event.harvester != null) { - ItemStack stack = event.harvester.getCurrentEquippedItem(); - if(stack != null && (stack.getItem() == this || stack.getItem() == ModItems.terraPick && ItemTerraPick.isTipped(stack))) { - for(int i = 0; i < event.drops.size(); i++) { - ItemStack drop = event.drops.get(i); - if(drop != null) { - Block block = Block.getBlockFromItem(drop.getItem()); - if(block != null){ - if(isDisposable(block) || (isSemiDisposable(block) && !event.harvester.isSneaking())) - event.drops.remove(i); - } - } - } - } - } - } + public static boolean isDisposable(Block block) { + for (int id : OreDictionary.getOreIDs(new ItemStack(block))) { + String name = OreDictionary.getOreName(id); + if (BotaniaAPI.disposableBlocks.contains(name)) return true; + } + return false; + } - public static boolean isDisposable(Block block) { - for(int id : OreDictionary.getOreIDs(new ItemStack(block))) { - String name = OreDictionary.getOreName(id); - if(BotaniaAPI.disposableBlocks.contains(name)) - return true; - } - return false; - } - - public static boolean isSemiDisposable(Block block) { - for(int id : OreDictionary.getOreIDs(new ItemStack(block))) { - String name = OreDictionary.getOreName(id); - if(BotaniaAPI.semiDisposableBlocks.contains(name)) - return true; - } - return false; - } + public static boolean isSemiDisposable(Block block) { + for (int id : OreDictionary.getOreIDs(new ItemStack(block))) { + String name = OreDictionary.getOreName(id); + if (BotaniaAPI.semiDisposableBlocks.contains(name)) return true; + } + return false; + } } diff --git a/src/main/java/vazkii/botania/common/item/equipment/tool/elementium/ItemElementiumShears.java b/src/main/java/vazkii/botania/common/item/equipment/tool/elementium/ItemElementiumShears.java index 00d373f295..117f6ddaa7 100644 --- a/src/main/java/vazkii/botania/common/item/equipment/tool/elementium/ItemElementiumShears.java +++ b/src/main/java/vazkii/botania/common/item/equipment/tool/elementium/ItemElementiumShears.java @@ -1,9 +1,10 @@ package vazkii.botania.common.item.equipment.tool.elementium; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; import java.util.ArrayList; import java.util.List; import java.util.Random; - import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.enchantment.Enchantment; import net.minecraft.enchantment.EnchantmentHelper; @@ -20,73 +21,86 @@ import vazkii.botania.common.item.equipment.tool.ToolCommons; import vazkii.botania.common.item.equipment.tool.manasteel.ItemManasteelShears; import vazkii.botania.common.lib.LibItemNames; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; public class ItemElementiumShears extends ItemManasteelShears { - IIcon dammitReddit; - - public ItemElementiumShears() { - super(LibItemNames.ELEMENTIUM_SHEARS); - } + IIcon dammitReddit; - @Override - public EnumAction getItemUseAction(ItemStack par1ItemStack) { - return EnumAction.bow; - } + public ItemElementiumShears() { + super(LibItemNames.ELEMENTIUM_SHEARS); + } - @Override - public int getMaxItemUseDuration(ItemStack par1ItemStack) { - return 72000; - } + @Override + public EnumAction getItemUseAction(ItemStack par1ItemStack) { + return EnumAction.bow; + } - @Override - public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer) { - par3EntityPlayer.setItemInUse(par1ItemStack, getMaxItemUseDuration(par1ItemStack)); - return par1ItemStack; - } + @Override + public int getMaxItemUseDuration(ItemStack par1ItemStack) { + return 72000; + } - @Override - @SideOnly(Side.CLIENT) - public void registerIcons(IIconRegister par1IconRegister) { - super.registerIcons(par1IconRegister); - dammitReddit = IconHelper.forName(par1IconRegister, "dammitReddit"); - } + @Override + public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer) { + par3EntityPlayer.setItemInUse(par1ItemStack, getMaxItemUseDuration(par1ItemStack)); + return par1ItemStack; + } - @Override - public IIcon getIconIndex(ItemStack par1ItemStack) { - return par1ItemStack.getDisplayName().equalsIgnoreCase("dammit reddit") ? dammitReddit : super.getIconIndex(par1ItemStack); - } + @Override + @SideOnly(Side.CLIENT) + public void registerIcons(IIconRegister par1IconRegister) { + super.registerIcons(par1IconRegister); + dammitReddit = IconHelper.forName(par1IconRegister, "dammitReddit"); + } - @Override - public void onUsingTick(ItemStack stack, EntityPlayer player, int count) { - if(player.worldObj.isRemote) - return; + @Override + public IIcon getIconIndex(ItemStack par1ItemStack) { + return par1ItemStack.getDisplayName().equalsIgnoreCase("dammit reddit") + ? dammitReddit + : super.getIconIndex(par1ItemStack); + } - if(count != getMaxItemUseDuration(stack) && count % 5 == 0) { - int range = 12; - List sheep = player.worldObj.getEntitiesWithinAABB(IShearable.class, AxisAlignedBB.getBoundingBox(player.posX - range, player.posY - range, player.posZ - range, player.posX + range, player.posY + range, player.posZ + range)); - if(sheep.size() > 0) { - for(IShearable target : sheep) { - Entity entity = (Entity) target; - if(target.isShearable(stack, entity.worldObj, (int)entity.posX, (int)entity.posY, (int)entity.posZ)) { - ArrayList drops = target.onSheared(stack, entity.worldObj, (int)entity.posX, (int)entity.posY, (int)entity.posZ, EnchantmentHelper.getEnchantmentLevel(Enchantment.fortune.effectId, stack)); + @Override + public void onUsingTick(ItemStack stack, EntityPlayer player, int count) { + if (player.worldObj.isRemote) return; - Random rand = new Random(); - for(ItemStack drop : drops) { - EntityItem ent = entity.entityDropItem(drop, 1.0F); - ent.motionY += rand.nextFloat() * 0.05F; - ent.motionX += (rand.nextFloat() - rand.nextFloat()) * 0.1F; - ent.motionZ += (rand.nextFloat() - rand.nextFloat()) * 0.1F; - } + if (count != getMaxItemUseDuration(stack) && count % 5 == 0) { + int range = 12; + List sheep = player.worldObj.getEntitiesWithinAABB( + IShearable.class, + AxisAlignedBB.getBoundingBox( + player.posX - range, + player.posY - range, + player.posZ - range, + player.posX + range, + player.posY + range, + player.posZ + range)); + if (sheep.size() > 0) { + for (IShearable target : sheep) { + Entity entity = (Entity) target; + if (target.isShearable( + stack, entity.worldObj, (int) entity.posX, (int) entity.posY, (int) entity.posZ)) { + ArrayList drops = target.onSheared( + stack, + entity.worldObj, + (int) entity.posX, + (int) entity.posY, + (int) entity.posZ, + EnchantmentHelper.getEnchantmentLevel(Enchantment.fortune.effectId, stack)); - ToolCommons.damageItem(stack, 1, player, MANA_PER_DAMAGE); - break; - } - } - } - } - } + Random rand = new Random(); + for (ItemStack drop : drops) { + EntityItem ent = entity.entityDropItem(drop, 1.0F); + ent.motionY += rand.nextFloat() * 0.05F; + ent.motionX += (rand.nextFloat() - rand.nextFloat()) * 0.1F; + ent.motionZ += (rand.nextFloat() - rand.nextFloat()) * 0.1F; + } + ToolCommons.damageItem(stack, 1, player, MANA_PER_DAMAGE); + break; + } + } + } + } + } } diff --git a/src/main/java/vazkii/botania/common/item/equipment/tool/elementium/ItemElementiumShovel.java b/src/main/java/vazkii/botania/common/item/equipment/tool/elementium/ItemElementiumShovel.java index 1c2ca7df05..eb6b1d2070 100644 --- a/src/main/java/vazkii/botania/common/item/equipment/tool/elementium/ItemElementiumShovel.java +++ b/src/main/java/vazkii/botania/common/item/equipment/tool/elementium/ItemElementiumShovel.java @@ -16,32 +16,32 @@ public class ItemElementiumShovel extends ItemManasteelShovel { - public static Material[] materialsShovel = new Material[]{ Material.grass, Material.ground, Material.sand, Material.snow, Material.craftedSnow, Material.clay }; - - public ItemElementiumShovel() { - super(BotaniaAPI.elementiumToolMaterial, LibItemNames.ELEMENTIUM_SHOVEL); - } - - @Override - public boolean onBlockStartBreak(ItemStack stack, int x, int y, int z, EntityPlayer player) { - World world = player.worldObj; - Material mat = world.getBlock(x, y, z).getMaterial(); - if (!ToolCommons.isRightMaterial(mat, materialsShovel)) - return false; - - MovingObjectPosition block = ToolCommons.raytraceFromEntity(world, player, true, 10); - if (block == null) - return false; - - ForgeDirection.getOrientation(block.sideHit); - int fortune = EnchantmentHelper.getFortuneModifier(player); - boolean silk = EnchantmentHelper.getSilkTouchModifier(player); - - Block blk = world.getBlock(x, y, z); - if(blk instanceof BlockFalling) - ToolCommons.removeBlocksInIteration(player, stack, world, x, y, z, 0, -12, 0, 1, 12, 1, blk, materialsShovel, silk, fortune, false); - - return false; - } - + public static Material[] materialsShovel = new Material[] { + Material.grass, Material.ground, Material.sand, Material.snow, Material.craftedSnow, Material.clay + }; + + public ItemElementiumShovel() { + super(BotaniaAPI.elementiumToolMaterial, LibItemNames.ELEMENTIUM_SHOVEL); + } + + @Override + public boolean onBlockStartBreak(ItemStack stack, int x, int y, int z, EntityPlayer player) { + World world = player.worldObj; + Material mat = world.getBlock(x, y, z).getMaterial(); + if (!ToolCommons.isRightMaterial(mat, materialsShovel)) return false; + + MovingObjectPosition block = ToolCommons.raytraceFromEntity(world, player, true, 10); + if (block == null) return false; + + ForgeDirection.getOrientation(block.sideHit); + int fortune = EnchantmentHelper.getFortuneModifier(player); + boolean silk = EnchantmentHelper.getSilkTouchModifier(player); + + Block blk = world.getBlock(x, y, z); + if (blk instanceof BlockFalling) + ToolCommons.removeBlocksInIteration( + player, stack, world, x, y, z, 0, -12, 0, 1, 12, 1, blk, materialsShovel, silk, fortune, false); + + return false; + } } diff --git a/src/main/java/vazkii/botania/common/item/equipment/tool/elementium/ItemElementiumSword.java b/src/main/java/vazkii/botania/common/item/equipment/tool/elementium/ItemElementiumSword.java index 6e089c34be..4fa8051250 100644 --- a/src/main/java/vazkii/botania/common/item/equipment/tool/elementium/ItemElementiumSword.java +++ b/src/main/java/vazkii/botania/common/item/equipment/tool/elementium/ItemElementiumSword.java @@ -8,13 +8,12 @@ public class ItemElementiumSword extends ItemManasteelSword implements IPixieSpawner { - public ItemElementiumSword() { - super(BotaniaAPI.elementiumToolMaterial, LibItemNames.ELEMENTIUM_SWORD); - } - - @Override - public float getPixieChance(ItemStack stack) { - return 0.05F; - } + public ItemElementiumSword() { + super(BotaniaAPI.elementiumToolMaterial, LibItemNames.ELEMENTIUM_SWORD); + } + @Override + public float getPixieChance(ItemStack stack) { + return 0.05F; + } } diff --git a/src/main/java/vazkii/botania/common/item/equipment/tool/manasteel/ItemManasteelAxe.java b/src/main/java/vazkii/botania/common/item/equipment/tool/manasteel/ItemManasteelAxe.java index 6d673dd6dd..725317e814 100644 --- a/src/main/java/vazkii/botania/common/item/equipment/tool/manasteel/ItemManasteelAxe.java +++ b/src/main/java/vazkii/botania/common/item/equipment/tool/manasteel/ItemManasteelAxe.java @@ -2,16 +2,18 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Apr 13, 2014, 7:15:39 PM (GMT)] */ package vazkii.botania.common.item.equipment.tool.manasteel; +import cpw.mods.fml.common.registry.GameRegistry; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; import java.util.regex.Pattern; - import net.minecraft.block.Block; import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.entity.Entity; @@ -33,103 +35,118 @@ import vazkii.botania.common.item.ModItems; import vazkii.botania.common.item.equipment.tool.ToolCommons; import vazkii.botania.common.lib.LibItemNames; -import cpw.mods.fml.common.registry.GameRegistry; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; public class ItemManasteelAxe extends ItemAxe implements IManaUsingItem, ISortableTool { - private static final Pattern SAPLING_PATTERN = Pattern.compile("(?:(?:(?:[A-Z-_.:]|^)sapling)|(?:(?:[a-z-_.:]|^)Sapling))(?:[A-Z-_.:]|$)"); - - private static final int MANA_PER_DAMAGE = 60; - - public ItemManasteelAxe() { - this(BotaniaAPI.manasteelToolMaterial, LibItemNames.MANASTEEL_AXE); - } - - public ItemManasteelAxe(ToolMaterial mat, String name) { - super(mat); - setCreativeTab(BotaniaCreativeTab.INSTANCE); - setUnlocalizedName(name); - } - - @Override - public Item setUnlocalizedName(String par1Str) { - GameRegistry.registerItem(this, par1Str); - return super.setUnlocalizedName(par1Str); - } - - @Override - public String getUnlocalizedNameInefficiently(ItemStack par1ItemStack) { - return super.getUnlocalizedNameInefficiently(par1ItemStack).replaceAll("item.", "item." + LibResources.PREFIX_MOD); - } - - @Override - @SideOnly(Side.CLIENT) - public void registerIcons(IIconRegister par1IconRegister) { - itemIcon = IconHelper.forItem(par1IconRegister, this); - } - - @Override - public boolean hitEntity(ItemStack par1ItemStack, EntityLivingBase par2EntityLivingBase, EntityLivingBase par3EntityLivingBase) { - ToolCommons.damageItem(par1ItemStack, 1, par3EntityLivingBase, getManaPerDamage()); - return true; - } - - @Override - public boolean onBlockDestroyed(ItemStack stack, World world, Block block, int x, int y, int z, EntityLivingBase entity) { - if (block.getBlockHardness(world, x, y, z) != 0F) - ToolCommons.damageItem(stack, 1, entity, getManaPerDamage()); - - return true; - } - - public int getManaPerDamage() { - return MANA_PER_DAMAGE; - } - - @Override - public boolean onItemUse(ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int s, float sx, float sy, float sz) { - for(int i = 0; i < player.inventory.getSizeInventory(); i++) { - ItemStack stackAt = player.inventory.getStackInSlot(i); - if(stackAt != null && SAPLING_PATTERN.matcher(stackAt.getItem().getUnlocalizedName()).find()) { - boolean did = stackAt.getItem().onItemUse(stackAt, player, world, x, y, z, s, sx, sy, sz); - if(stackAt.stackSize == 0) - player.inventory.setInventorySlotContents(i, null); - - ItemsRemainingRenderHandler.set(player, new ItemStack(Blocks.sapling), SAPLING_PATTERN); - return did; - } - } - - return false; - } - - - @Override - public void onUpdate(ItemStack stack, World world, Entity player, int par4, boolean par5) { - if(!world.isRemote && player instanceof EntityPlayer && stack.getItemDamage() > 0 && ManaItemHandler.requestManaExactForTool(stack, (EntityPlayer) player, getManaPerDamage() * 2, true)) - stack.setItemDamage(stack.getItemDamage() - 1); - } - - @Override - public boolean getIsRepairable(ItemStack par1ItemStack, ItemStack par2ItemStack) { - return par2ItemStack.getItem() == ModItems.manaResource && par2ItemStack.getItemDamage() == 0 ? true : super.getIsRepairable(par1ItemStack, par2ItemStack); - } - - @Override - public boolean usesMana(ItemStack stack) { - return true; - } - - @Override - public ToolType getSortingType(ItemStack stack) { - return ToolType.AXE; - } - - @Override - public int getSortingPriority(ItemStack stack) { - return ToolCommons.getToolPriority(stack); - } - -} \ No newline at end of file + private static final Pattern SAPLING_PATTERN = + Pattern.compile("(?:(?:(?:[A-Z-_.:]|^)sapling)|(?:(?:[a-z-_.:]|^)Sapling))(?:[A-Z-_.:]|$)"); + + private static final int MANA_PER_DAMAGE = 60; + + public ItemManasteelAxe() { + this(BotaniaAPI.manasteelToolMaterial, LibItemNames.MANASTEEL_AXE); + } + + public ItemManasteelAxe(ToolMaterial mat, String name) { + super(mat); + setCreativeTab(BotaniaCreativeTab.INSTANCE); + setUnlocalizedName(name); + } + + @Override + public Item setUnlocalizedName(String par1Str) { + GameRegistry.registerItem(this, par1Str); + return super.setUnlocalizedName(par1Str); + } + + @Override + public String getUnlocalizedNameInefficiently(ItemStack par1ItemStack) { + return super.getUnlocalizedNameInefficiently(par1ItemStack) + .replaceAll("item.", "item." + LibResources.PREFIX_MOD); + } + + @Override + @SideOnly(Side.CLIENT) + public void registerIcons(IIconRegister par1IconRegister) { + itemIcon = IconHelper.forItem(par1IconRegister, this); + } + + @Override + public boolean hitEntity( + ItemStack par1ItemStack, EntityLivingBase par2EntityLivingBase, EntityLivingBase par3EntityLivingBase) { + ToolCommons.damageItem(par1ItemStack, 1, par3EntityLivingBase, getManaPerDamage()); + return true; + } + + @Override + public boolean onBlockDestroyed( + ItemStack stack, World world, Block block, int x, int y, int z, EntityLivingBase entity) { + if (block.getBlockHardness(world, x, y, z) != 0F) ToolCommons.damageItem(stack, 1, entity, getManaPerDamage()); + + return true; + } + + public int getManaPerDamage() { + return MANA_PER_DAMAGE; + } + + @Override + public boolean onItemUse( + ItemStack stack, + EntityPlayer player, + World world, + int x, + int y, + int z, + int s, + float sx, + float sy, + float sz) { + for (int i = 0; i < player.inventory.getSizeInventory(); i++) { + ItemStack stackAt = player.inventory.getStackInSlot(i); + if (stackAt != null + && SAPLING_PATTERN + .matcher(stackAt.getItem().getUnlocalizedName()) + .find()) { + boolean did = stackAt.getItem().onItemUse(stackAt, player, world, x, y, z, s, sx, sy, sz); + if (stackAt.stackSize == 0) player.inventory.setInventorySlotContents(i, null); + + ItemsRemainingRenderHandler.set(player, new ItemStack(Blocks.sapling), SAPLING_PATTERN); + return did; + } + } + + return false; + } + + @Override + public void onUpdate(ItemStack stack, World world, Entity player, int par4, boolean par5) { + if (!world.isRemote + && player instanceof EntityPlayer + && stack.getItemDamage() > 0 + && ManaItemHandler.requestManaExactForTool(stack, (EntityPlayer) player, getManaPerDamage() * 2, true)) + stack.setItemDamage(stack.getItemDamage() - 1); + } + + @Override + public boolean getIsRepairable(ItemStack par1ItemStack, ItemStack par2ItemStack) { + return par2ItemStack.getItem() == ModItems.manaResource && par2ItemStack.getItemDamage() == 0 + ? true + : super.getIsRepairable(par1ItemStack, par2ItemStack); + } + + @Override + public boolean usesMana(ItemStack stack) { + return true; + } + + @Override + public ToolType getSortingType(ItemStack stack) { + return ToolType.AXE; + } + + @Override + public int getSortingPriority(ItemStack stack) { + return ToolCommons.getToolPriority(stack); + } +} diff --git a/src/main/java/vazkii/botania/common/item/equipment/tool/manasteel/ItemManasteelPick.java b/src/main/java/vazkii/botania/common/item/equipment/tool/manasteel/ItemManasteelPick.java index 0682455c18..5d2f89409a 100644 --- a/src/main/java/vazkii/botania/common/item/equipment/tool/manasteel/ItemManasteelPick.java +++ b/src/main/java/vazkii/botania/common/item/equipment/tool/manasteel/ItemManasteelPick.java @@ -2,16 +2,18 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Apr 13, 2014, 7:05:58 PM (GMT)] */ package vazkii.botania.common.item.equipment.tool.manasteel; +import cpw.mods.fml.common.registry.GameRegistry; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; import java.util.regex.Pattern; - import net.minecraft.block.Block; import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.entity.Entity; @@ -33,102 +35,118 @@ import vazkii.botania.common.item.ModItems; import vazkii.botania.common.item.equipment.tool.ToolCommons; import vazkii.botania.common.lib.LibItemNames; -import cpw.mods.fml.common.registry.GameRegistry; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; public class ItemManasteelPick extends ItemPickaxe implements IManaUsingItem, ISortableTool { - private static final Pattern TORCH_PATTERN = Pattern.compile("(?:(?:(?:[A-Z-_.:]|^)torch)|(?:(?:[a-z-_.:]|^)Torch))(?:[A-Z-_.:]|$)"); - - private static final int MANA_PER_DAMAGE = 60; - - public ItemManasteelPick() { - this(BotaniaAPI.manasteelToolMaterial, LibItemNames.MANASTEEL_PICK); - } - - public ItemManasteelPick(ToolMaterial mat, String name) { - super(mat); - setCreativeTab(BotaniaCreativeTab.INSTANCE); - setUnlocalizedName(name); - } - - @Override - public Item setUnlocalizedName(String par1Str) { - GameRegistry.registerItem(this, par1Str); - return super.setUnlocalizedName(par1Str); - } - - @Override - public String getUnlocalizedNameInefficiently(ItemStack par1ItemStack) { - return super.getUnlocalizedNameInefficiently(par1ItemStack).replaceAll("item.", "item." + LibResources.PREFIX_MOD); - } - - @Override - @SideOnly(Side.CLIENT) - public void registerIcons(IIconRegister par1IconRegister) { - itemIcon = IconHelper.forItem(par1IconRegister, this); - } - - @Override - public boolean hitEntity(ItemStack par1ItemStack, EntityLivingBase par2EntityLivingBase, EntityLivingBase par3EntityLivingBase) { - ToolCommons.damageItem(par1ItemStack, 1, par3EntityLivingBase, getManaPerDmg()); - return true; - } - - @Override - public boolean onBlockDestroyed(ItemStack stack, World world, Block block, int x, int y, int z, EntityLivingBase entity) { - if(block.getBlockHardness(world, x, y, z) != 0F) - ToolCommons.damageItem(stack, 1, entity, getManaPerDmg()); - - return true; - } - - @Override - public boolean onItemUse(ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int s, float sx, float sy, float sz) { - for(int i = 0; i < player.inventory.getSizeInventory(); i++) { - ItemStack stackAt = player.inventory.getStackInSlot(i); - if(stackAt != null && TORCH_PATTERN.matcher(stackAt.getItem().getUnlocalizedName()).find()) { - boolean did = stackAt.getItem().onItemUse(stackAt, player, world, x, y, z, s, sx, sy, sz); - if(stackAt.stackSize == 0) - player.inventory.setInventorySlotContents(i, null); - - ItemsRemainingRenderHandler.set(player, new ItemStack(Blocks.torch), TORCH_PATTERN); - return did; - } - } - - return false; - } - - public int getManaPerDmg() { - return MANA_PER_DAMAGE; - } - - @Override - public void onUpdate(ItemStack stack, World world, Entity player, int par4, boolean par5) { - if(!world.isRemote && player instanceof EntityPlayer && stack.getItemDamage() > 0 && ManaItemHandler.requestManaExactForTool(stack, (EntityPlayer) player, MANA_PER_DAMAGE * 2, true)) - stack.setItemDamage(stack.getItemDamage() - 1); - } - - @Override - public boolean getIsRepairable(ItemStack par1ItemStack, ItemStack par2ItemStack) { - return par2ItemStack.getItem() == ModItems.manaResource && par2ItemStack.getItemDamage() == 0 ? true : super.getIsRepairable(par1ItemStack, par2ItemStack); - } - - @Override - public boolean usesMana(ItemStack stack) { - return true; - } - - @Override - public ToolType getSortingType(ItemStack stack) { - return ToolType.PICK; - } - - @Override - public int getSortingPriority(ItemStack stack) { - return ToolCommons.getToolPriority(stack); - } - + private static final Pattern TORCH_PATTERN = + Pattern.compile("(?:(?:(?:[A-Z-_.:]|^)torch)|(?:(?:[a-z-_.:]|^)Torch))(?:[A-Z-_.:]|$)"); + + private static final int MANA_PER_DAMAGE = 60; + + public ItemManasteelPick() { + this(BotaniaAPI.manasteelToolMaterial, LibItemNames.MANASTEEL_PICK); + } + + public ItemManasteelPick(ToolMaterial mat, String name) { + super(mat); + setCreativeTab(BotaniaCreativeTab.INSTANCE); + setUnlocalizedName(name); + } + + @Override + public Item setUnlocalizedName(String par1Str) { + GameRegistry.registerItem(this, par1Str); + return super.setUnlocalizedName(par1Str); + } + + @Override + public String getUnlocalizedNameInefficiently(ItemStack par1ItemStack) { + return super.getUnlocalizedNameInefficiently(par1ItemStack) + .replaceAll("item.", "item." + LibResources.PREFIX_MOD); + } + + @Override + @SideOnly(Side.CLIENT) + public void registerIcons(IIconRegister par1IconRegister) { + itemIcon = IconHelper.forItem(par1IconRegister, this); + } + + @Override + public boolean hitEntity( + ItemStack par1ItemStack, EntityLivingBase par2EntityLivingBase, EntityLivingBase par3EntityLivingBase) { + ToolCommons.damageItem(par1ItemStack, 1, par3EntityLivingBase, getManaPerDmg()); + return true; + } + + @Override + public boolean onBlockDestroyed( + ItemStack stack, World world, Block block, int x, int y, int z, EntityLivingBase entity) { + if (block.getBlockHardness(world, x, y, z) != 0F) ToolCommons.damageItem(stack, 1, entity, getManaPerDmg()); + + return true; + } + + @Override + public boolean onItemUse( + ItemStack stack, + EntityPlayer player, + World world, + int x, + int y, + int z, + int s, + float sx, + float sy, + float sz) { + for (int i = 0; i < player.inventory.getSizeInventory(); i++) { + ItemStack stackAt = player.inventory.getStackInSlot(i); + if (stackAt != null + && TORCH_PATTERN + .matcher(stackAt.getItem().getUnlocalizedName()) + .find()) { + boolean did = stackAt.getItem().onItemUse(stackAt, player, world, x, y, z, s, sx, sy, sz); + if (stackAt.stackSize == 0) player.inventory.setInventorySlotContents(i, null); + + ItemsRemainingRenderHandler.set(player, new ItemStack(Blocks.torch), TORCH_PATTERN); + return did; + } + } + + return false; + } + + public int getManaPerDmg() { + return MANA_PER_DAMAGE; + } + + @Override + public void onUpdate(ItemStack stack, World world, Entity player, int par4, boolean par5) { + if (!world.isRemote + && player instanceof EntityPlayer + && stack.getItemDamage() > 0 + && ManaItemHandler.requestManaExactForTool(stack, (EntityPlayer) player, MANA_PER_DAMAGE * 2, true)) + stack.setItemDamage(stack.getItemDamage() - 1); + } + + @Override + public boolean getIsRepairable(ItemStack par1ItemStack, ItemStack par2ItemStack) { + return par2ItemStack.getItem() == ModItems.manaResource && par2ItemStack.getItemDamage() == 0 + ? true + : super.getIsRepairable(par1ItemStack, par2ItemStack); + } + + @Override + public boolean usesMana(ItemStack stack) { + return true; + } + + @Override + public ToolType getSortingType(ItemStack stack) { + return ToolType.PICK; + } + + @Override + public int getSortingPriority(ItemStack stack) { + return ToolCommons.getToolPriority(stack); + } } diff --git a/src/main/java/vazkii/botania/common/item/equipment/tool/manasteel/ItemManasteelShears.java b/src/main/java/vazkii/botania/common/item/equipment/tool/manasteel/ItemManasteelShears.java index 17a2c650eb..150660c204 100644 --- a/src/main/java/vazkii/botania/common/item/equipment/tool/manasteel/ItemManasteelShears.java +++ b/src/main/java/vazkii/botania/common/item/equipment/tool/manasteel/ItemManasteelShears.java @@ -2,17 +2,19 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Apr 13, 2014, 7:28:35 PM (GMT)] */ package vazkii.botania.common.item.equipment.tool.manasteel; +import cpw.mods.fml.common.registry.GameRegistry; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; import java.util.ArrayList; import java.util.Random; - import net.minecraft.block.Block; import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.enchantment.Enchantment; @@ -35,111 +37,125 @@ import vazkii.botania.common.item.ModItems; import vazkii.botania.common.item.equipment.tool.ToolCommons; import vazkii.botania.common.lib.LibItemNames; -import cpw.mods.fml.common.registry.GameRegistry; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; public class ItemManasteelShears extends ItemShears implements IManaUsingItem { - public static final int MANA_PER_DAMAGE = 30; - - public ItemManasteelShears() { - this(LibItemNames.MANASTEEL_SHEARS); - } - - public ItemManasteelShears(String name) { - setCreativeTab(BotaniaCreativeTab.INSTANCE); - setUnlocalizedName(name); - } - - @Override - public Item setUnlocalizedName(String par1Str) { - GameRegistry.registerItem(this, par1Str); - return super.setUnlocalizedName(par1Str); - } - - @Override - public String getUnlocalizedNameInefficiently(ItemStack par1ItemStack) { - return super.getUnlocalizedNameInefficiently(par1ItemStack).replaceAll("item.", "item." + LibResources.PREFIX_MOD); - } - - @Override - @SideOnly(Side.CLIENT) - public void registerIcons(IIconRegister par1IconRegister) { - itemIcon = IconHelper.forItem(par1IconRegister, this); - } - - @Override - public boolean itemInteractionForEntity(ItemStack itemstack, EntityPlayer player, EntityLivingBase entity) { - if(entity.worldObj.isRemote) - return false; - - if(entity instanceof IShearable) { - IShearable target = (IShearable)entity; - if(target.isShearable(itemstack, entity.worldObj, (int) entity.posX, (int) entity.posY, (int) entity.posZ)) { - ArrayList drops = target.onSheared(itemstack, entity.worldObj, (int) entity.posX, (int) entity.posY, (int) entity.posZ, EnchantmentHelper.getEnchantmentLevel(Enchantment.fortune.effectId, itemstack)); - - Random rand = new Random(); - for(ItemStack stack : drops) { - EntityItem ent = entity.entityDropItem(stack, 1.0F); - ent.motionY += rand.nextFloat() * 0.05F; - ent.motionX += (rand.nextFloat() - rand.nextFloat()) * 0.1F; - ent.motionZ += (rand.nextFloat() - rand.nextFloat()) * 0.1F; - } - - ToolCommons.damageItem(itemstack, 1, player, MANA_PER_DAMAGE); - } - - return true; - } - - return false; - } - - @Override - public boolean onBlockStartBreak(ItemStack itemstack, int x, int y, int z, EntityPlayer player) { - if (player.worldObj.isRemote) - return false; - - Block block = player.worldObj.getBlock(x, y, z); - if(block instanceof IShearable) { - IShearable target = (IShearable)block; - if(target.isShearable(itemstack, player.worldObj, x, y, z)) { - ArrayList drops = target.onSheared(itemstack, player.worldObj, x, y, z, EnchantmentHelper.getEnchantmentLevel(Enchantment.fortune.effectId, itemstack)); - Random rand = new Random(); - - for(ItemStack stack : drops) { - float f = 0.7F; - double d = rand.nextFloat() * f + (1D - f) * 0.5; - double d1 = rand.nextFloat() * f + (1D - f) * 0.5; - double d2 = rand.nextFloat() * f + (1D - f) * 0.5; - - EntityItem entityitem = new EntityItem(player.worldObj, x + d, y + d1, z + d2, stack); - entityitem.delayBeforeCanPickup = 10; - player.worldObj.spawnEntityInWorld(entityitem); - } - - ToolCommons.damageItem(itemstack, 1, player, MANA_PER_DAMAGE); - player.addStat(StatList.mineBlockStatArray[Block.getIdFromBlock(block)], 1); - } - } - - return false; - } - - @Override - public void onUpdate(ItemStack stack, World world, Entity player, int par4, boolean par5) { - if(!world.isRemote && player instanceof EntityPlayer && stack.getItemDamage() > 0 && ManaItemHandler.requestManaExactForTool(stack, (EntityPlayer) player, MANA_PER_DAMAGE * 2, true)) - stack.setItemDamage(stack.getItemDamage() - 1); - } - - @Override - public boolean getIsRepairable(ItemStack par1ItemStack, ItemStack par2ItemStack) { - return par2ItemStack.getItem() == ModItems.manaResource && par2ItemStack.getItemDamage() == 0 ? true : super.getIsRepairable(par1ItemStack, par2ItemStack); - } - - @Override - public boolean usesMana(ItemStack stack) { - return true; - } + public static final int MANA_PER_DAMAGE = 30; + + public ItemManasteelShears() { + this(LibItemNames.MANASTEEL_SHEARS); + } + + public ItemManasteelShears(String name) { + setCreativeTab(BotaniaCreativeTab.INSTANCE); + setUnlocalizedName(name); + } + + @Override + public Item setUnlocalizedName(String par1Str) { + GameRegistry.registerItem(this, par1Str); + return super.setUnlocalizedName(par1Str); + } + + @Override + public String getUnlocalizedNameInefficiently(ItemStack par1ItemStack) { + return super.getUnlocalizedNameInefficiently(par1ItemStack) + .replaceAll("item.", "item." + LibResources.PREFIX_MOD); + } + + @Override + @SideOnly(Side.CLIENT) + public void registerIcons(IIconRegister par1IconRegister) { + itemIcon = IconHelper.forItem(par1IconRegister, this); + } + + @Override + public boolean itemInteractionForEntity(ItemStack itemstack, EntityPlayer player, EntityLivingBase entity) { + if (entity.worldObj.isRemote) return false; + + if (entity instanceof IShearable) { + IShearable target = (IShearable) entity; + if (target.isShearable( + itemstack, entity.worldObj, (int) entity.posX, (int) entity.posY, (int) entity.posZ)) { + ArrayList drops = target.onSheared( + itemstack, + entity.worldObj, + (int) entity.posX, + (int) entity.posY, + (int) entity.posZ, + EnchantmentHelper.getEnchantmentLevel(Enchantment.fortune.effectId, itemstack)); + + Random rand = new Random(); + for (ItemStack stack : drops) { + EntityItem ent = entity.entityDropItem(stack, 1.0F); + ent.motionY += rand.nextFloat() * 0.05F; + ent.motionX += (rand.nextFloat() - rand.nextFloat()) * 0.1F; + ent.motionZ += (rand.nextFloat() - rand.nextFloat()) * 0.1F; + } + + ToolCommons.damageItem(itemstack, 1, player, MANA_PER_DAMAGE); + } + + return true; + } + + return false; + } + + @Override + public boolean onBlockStartBreak(ItemStack itemstack, int x, int y, int z, EntityPlayer player) { + if (player.worldObj.isRemote) return false; + + Block block = player.worldObj.getBlock(x, y, z); + if (block instanceof IShearable) { + IShearable target = (IShearable) block; + if (target.isShearable(itemstack, player.worldObj, x, y, z)) { + ArrayList drops = target.onSheared( + itemstack, + player.worldObj, + x, + y, + z, + EnchantmentHelper.getEnchantmentLevel(Enchantment.fortune.effectId, itemstack)); + Random rand = new Random(); + + for (ItemStack stack : drops) { + float f = 0.7F; + double d = rand.nextFloat() * f + (1D - f) * 0.5; + double d1 = rand.nextFloat() * f + (1D - f) * 0.5; + double d2 = rand.nextFloat() * f + (1D - f) * 0.5; + + EntityItem entityitem = new EntityItem(player.worldObj, x + d, y + d1, z + d2, stack); + entityitem.delayBeforeCanPickup = 10; + player.worldObj.spawnEntityInWorld(entityitem); + } + + ToolCommons.damageItem(itemstack, 1, player, MANA_PER_DAMAGE); + player.addStat(StatList.mineBlockStatArray[Block.getIdFromBlock(block)], 1); + } + } + + return false; + } + + @Override + public void onUpdate(ItemStack stack, World world, Entity player, int par4, boolean par5) { + if (!world.isRemote + && player instanceof EntityPlayer + && stack.getItemDamage() > 0 + && ManaItemHandler.requestManaExactForTool(stack, (EntityPlayer) player, MANA_PER_DAMAGE * 2, true)) + stack.setItemDamage(stack.getItemDamage() - 1); + } + + @Override + public boolean getIsRepairable(ItemStack par1ItemStack, ItemStack par2ItemStack) { + return par2ItemStack.getItem() == ModItems.manaResource && par2ItemStack.getItemDamage() == 0 + ? true + : super.getIsRepairable(par1ItemStack, par2ItemStack); + } + + @Override + public boolean usesMana(ItemStack stack) { + return true; + } } diff --git a/src/main/java/vazkii/botania/common/item/equipment/tool/manasteel/ItemManasteelShovel.java b/src/main/java/vazkii/botania/common/item/equipment/tool/manasteel/ItemManasteelShovel.java index 985a84a573..8bfd5c1c97 100644 --- a/src/main/java/vazkii/botania/common/item/equipment/tool/manasteel/ItemManasteelShovel.java +++ b/src/main/java/vazkii/botania/common/item/equipment/tool/manasteel/ItemManasteelShovel.java @@ -2,14 +2,18 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Apr 13, 2014, 7:14:54 PM (GMT)] */ package vazkii.botania.common.item.equipment.tool.manasteel; +import cpw.mods.fml.common.eventhandler.Event.Result; +import cpw.mods.fml.common.registry.GameRegistry; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; import net.minecraft.block.Block; import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.entity.Entity; @@ -32,113 +36,132 @@ import vazkii.botania.common.item.ModItems; import vazkii.botania.common.item.equipment.tool.ToolCommons; import vazkii.botania.common.lib.LibItemNames; -import cpw.mods.fml.common.eventhandler.Event.Result; -import cpw.mods.fml.common.registry.GameRegistry; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; public class ItemManasteelShovel extends ItemSpade implements IManaUsingItem, ISortableTool { - private static final int MANA_PER_DAMAGE = 60; - - public ItemManasteelShovel() { - this(BotaniaAPI.manasteelToolMaterial, LibItemNames.MANASTEEL_SHOVEL); - } - - public ItemManasteelShovel(ToolMaterial mat, String name) { - super(mat); - setCreativeTab(BotaniaCreativeTab.INSTANCE); - setUnlocalizedName(name); - } - - @Override - public Item setUnlocalizedName(String par1Str) { - GameRegistry.registerItem(this, par1Str); - return super.setUnlocalizedName(par1Str); - } - - @Override - public String getUnlocalizedNameInefficiently(ItemStack par1ItemStack) { - return super.getUnlocalizedNameInefficiently(par1ItemStack).replaceAll("item.", "item." + LibResources.PREFIX_MOD); - } - - @Override - @SideOnly(Side.CLIENT) - public void registerIcons(IIconRegister par1IconRegister) { - itemIcon = IconHelper.forItem(par1IconRegister, this); - } - - @Override - public boolean hitEntity(ItemStack par1ItemStack, EntityLivingBase par2EntityLivingBase, EntityLivingBase par3EntityLivingBase) { - ToolCommons.damageItem(par1ItemStack, 1, par3EntityLivingBase, MANA_PER_DAMAGE); - return true; - } - - @Override - public boolean onBlockDestroyed(ItemStack stack, World world, Block block, int x, int y, int z, EntityLivingBase entity) { - if (block.getBlockHardness(world, x, y, z) != 0F) - ToolCommons.damageItem(stack, 1, entity, MANA_PER_DAMAGE); - - return true; - } - - @Override - public boolean onItemUse(ItemStack p_77648_1_, EntityPlayer p_77648_2_, World p_77648_3_, int p_77648_4_, int p_77648_5_, int p_77648_6_, int p_77648_7_, float p_77648_8_, float p_77648_9_, float p_77648_10_) { - if(!p_77648_2_.canPlayerEdit(p_77648_4_, p_77648_5_, p_77648_6_, p_77648_7_, p_77648_1_)) - return false; - else { - UseHoeEvent event = new UseHoeEvent(p_77648_2_, p_77648_1_, p_77648_3_, p_77648_4_, p_77648_5_, p_77648_6_); - if(MinecraftForge.EVENT_BUS.post(event)) - return false; - - if(event.getResult() == Result.ALLOW) { - ToolCommons.damageItem(p_77648_1_, 1, p_77648_2_, MANA_PER_DAMAGE); - return true; - } - - Block block = p_77648_3_.getBlock(p_77648_4_, p_77648_5_, p_77648_6_); - - if(p_77648_7_ != 0 && p_77648_3_.getBlock(p_77648_4_, p_77648_5_ + 1, p_77648_6_).isAir(p_77648_3_, p_77648_4_, p_77648_5_ + 1, p_77648_6_) && (block == Blocks.grass || block == Blocks.dirt)) { - Block block1 = Blocks.farmland; - p_77648_3_.playSoundEffect(p_77648_4_ + 0.5F, p_77648_5_ + 0.5F, p_77648_6_ + 0.5F, block1.stepSound.getStepResourcePath(), (block1.stepSound.getVolume() + 1.0F) / 2.0F, block1.stepSound.getPitch() * 0.8F); - - if (p_77648_3_.isRemote) - return true; - else { - p_77648_3_.setBlock(p_77648_4_, p_77648_5_, p_77648_6_, block1); - ToolCommons.damageItem(p_77648_1_, 1, p_77648_2_, MANA_PER_DAMAGE); - return true; - } - } - - return false; - } - } - - @Override - public void onUpdate(ItemStack stack, World world, Entity player, int par4, boolean par5) { - if(!world.isRemote && player instanceof EntityPlayer && stack.getItemDamage() > 0 && ManaItemHandler.requestManaExactForTool(stack, (EntityPlayer) player, MANA_PER_DAMAGE * 2, true)) - stack.setItemDamage(stack.getItemDamage() - 1); - } - - @Override - public boolean getIsRepairable(ItemStack par1ItemStack, ItemStack par2ItemStack) { - return par2ItemStack.getItem() == ModItems.manaResource && par2ItemStack.getItemDamage() == 0 ? true : super.getIsRepairable(par1ItemStack, par2ItemStack); - } - - @Override - public boolean usesMana(ItemStack stack) { - return true; - } - - @Override - public ToolType getSortingType(ItemStack stack) { - return ToolType.SHOVEL; - } - - @Override - public int getSortingPriority(ItemStack stack) { - return ToolCommons.getToolPriority(stack); - } - + private static final int MANA_PER_DAMAGE = 60; + + public ItemManasteelShovel() { + this(BotaniaAPI.manasteelToolMaterial, LibItemNames.MANASTEEL_SHOVEL); + } + + public ItemManasteelShovel(ToolMaterial mat, String name) { + super(mat); + setCreativeTab(BotaniaCreativeTab.INSTANCE); + setUnlocalizedName(name); + } + + @Override + public Item setUnlocalizedName(String par1Str) { + GameRegistry.registerItem(this, par1Str); + return super.setUnlocalizedName(par1Str); + } + + @Override + public String getUnlocalizedNameInefficiently(ItemStack par1ItemStack) { + return super.getUnlocalizedNameInefficiently(par1ItemStack) + .replaceAll("item.", "item." + LibResources.PREFIX_MOD); + } + + @Override + @SideOnly(Side.CLIENT) + public void registerIcons(IIconRegister par1IconRegister) { + itemIcon = IconHelper.forItem(par1IconRegister, this); + } + + @Override + public boolean hitEntity( + ItemStack par1ItemStack, EntityLivingBase par2EntityLivingBase, EntityLivingBase par3EntityLivingBase) { + ToolCommons.damageItem(par1ItemStack, 1, par3EntityLivingBase, MANA_PER_DAMAGE); + return true; + } + + @Override + public boolean onBlockDestroyed( + ItemStack stack, World world, Block block, int x, int y, int z, EntityLivingBase entity) { + if (block.getBlockHardness(world, x, y, z) != 0F) ToolCommons.damageItem(stack, 1, entity, MANA_PER_DAMAGE); + + return true; + } + + @Override + public boolean onItemUse( + ItemStack p_77648_1_, + EntityPlayer p_77648_2_, + World p_77648_3_, + int p_77648_4_, + int p_77648_5_, + int p_77648_6_, + int p_77648_7_, + float p_77648_8_, + float p_77648_9_, + float p_77648_10_) { + if (!p_77648_2_.canPlayerEdit(p_77648_4_, p_77648_5_, p_77648_6_, p_77648_7_, p_77648_1_)) return false; + else { + UseHoeEvent event = new UseHoeEvent(p_77648_2_, p_77648_1_, p_77648_3_, p_77648_4_, p_77648_5_, p_77648_6_); + if (MinecraftForge.EVENT_BUS.post(event)) return false; + + if (event.getResult() == Result.ALLOW) { + ToolCommons.damageItem(p_77648_1_, 1, p_77648_2_, MANA_PER_DAMAGE); + return true; + } + + Block block = p_77648_3_.getBlock(p_77648_4_, p_77648_5_, p_77648_6_); + + if (p_77648_7_ != 0 + && p_77648_3_ + .getBlock(p_77648_4_, p_77648_5_ + 1, p_77648_6_) + .isAir(p_77648_3_, p_77648_4_, p_77648_5_ + 1, p_77648_6_) + && (block == Blocks.grass || block == Blocks.dirt)) { + Block block1 = Blocks.farmland; + p_77648_3_.playSoundEffect( + p_77648_4_ + 0.5F, + p_77648_5_ + 0.5F, + p_77648_6_ + 0.5F, + block1.stepSound.getStepResourcePath(), + (block1.stepSound.getVolume() + 1.0F) / 2.0F, + block1.stepSound.getPitch() * 0.8F); + + if (p_77648_3_.isRemote) return true; + else { + p_77648_3_.setBlock(p_77648_4_, p_77648_5_, p_77648_6_, block1); + ToolCommons.damageItem(p_77648_1_, 1, p_77648_2_, MANA_PER_DAMAGE); + return true; + } + } + + return false; + } + } + + @Override + public void onUpdate(ItemStack stack, World world, Entity player, int par4, boolean par5) { + if (!world.isRemote + && player instanceof EntityPlayer + && stack.getItemDamage() > 0 + && ManaItemHandler.requestManaExactForTool(stack, (EntityPlayer) player, MANA_PER_DAMAGE * 2, true)) + stack.setItemDamage(stack.getItemDamage() - 1); + } + + @Override + public boolean getIsRepairable(ItemStack par1ItemStack, ItemStack par2ItemStack) { + return par2ItemStack.getItem() == ModItems.manaResource && par2ItemStack.getItemDamage() == 0 + ? true + : super.getIsRepairable(par1ItemStack, par2ItemStack); + } + + @Override + public boolean usesMana(ItemStack stack) { + return true; + } + + @Override + public ToolType getSortingType(ItemStack stack) { + return ToolType.SHOVEL; + } + + @Override + public int getSortingPriority(ItemStack stack) { + return ToolCommons.getToolPriority(stack); + } } diff --git a/src/main/java/vazkii/botania/common/item/equipment/tool/manasteel/ItemManasteelSword.java b/src/main/java/vazkii/botania/common/item/equipment/tool/manasteel/ItemManasteelSword.java index dc7a7d2265..bf0e6ebf8a 100644 --- a/src/main/java/vazkii/botania/common/item/equipment/tool/manasteel/ItemManasteelSword.java +++ b/src/main/java/vazkii/botania/common/item/equipment/tool/manasteel/ItemManasteelSword.java @@ -2,14 +2,17 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Apr 13, 2014, 7:21:32 PM (GMT)] */ package vazkii.botania.common.item.equipment.tool.manasteel; +import cpw.mods.fml.common.registry.GameRegistry; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; import net.minecraft.block.Block; import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.entity.Entity; @@ -29,88 +32,91 @@ import vazkii.botania.common.item.ModItems; import vazkii.botania.common.item.equipment.tool.ToolCommons; import vazkii.botania.common.lib.LibItemNames; -import cpw.mods.fml.common.registry.GameRegistry; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; public class ItemManasteelSword extends ItemSword implements IManaUsingItem { - public static final int MANA_PER_DAMAGE = 60; - - public static IIcon elucidatorIcon; - - public ItemManasteelSword() { - this(BotaniaAPI.manasteelToolMaterial, LibItemNames.MANASTEEL_SWORD); - } - - public ItemManasteelSword(ToolMaterial mat, String name) { - super(mat); - setCreativeTab(BotaniaCreativeTab.INSTANCE); - setUnlocalizedName(name); - } - - @Override - public Item setUnlocalizedName(String par1Str) { - GameRegistry.registerItem(this, par1Str); - return super.setUnlocalizedName(par1Str); - } - - @Override - public String getUnlocalizedNameInefficiently(ItemStack par1ItemStack) { - return super.getUnlocalizedNameInefficiently(par1ItemStack).replaceAll("item.", "item." + LibResources.PREFIX_MOD); - } - - @Override - @SideOnly(Side.CLIENT) - public void registerIcons(IIconRegister par1IconRegister) { - itemIcon = IconHelper.forItem(par1IconRegister, this); - elucidatorIcon = IconHelper.forName(par1IconRegister, "elucidator"); - } - - @Override - public boolean hitEntity(ItemStack par1ItemStack, EntityLivingBase par2EntityLivingBase, EntityLivingBase par3EntityLivingBase) { - if(usesMana(par1ItemStack)) - ToolCommons.damageItem(par1ItemStack, 1, par3EntityLivingBase, getManaPerDamage()); - return true; - } - - @Override - public IIcon getIconIndex(ItemStack par1ItemStack) { - String name = par1ItemStack.getDisplayName().toLowerCase().trim(); - return name.equals("the elucidator") ? elucidatorIcon : super.getIconIndex(par1ItemStack); - } - - @Override - public IIcon getIcon(ItemStack stack, int pass) { - return getIconIndex(stack); - } - - @Override - public boolean onBlockDestroyed(ItemStack stack, World world, Block block, int x, int y, int z, EntityLivingBase entity) { - if(usesMana(stack) && block.getBlockHardness(world, x, y, z) != 0F) - ToolCommons.damageItem(stack, 1, entity, getManaPerDamage()); - - return true; - } - - @Override - public void onUpdate(ItemStack stack, World world, Entity player, int par4, boolean par5) { - if(!world.isRemote && player instanceof EntityPlayer && stack.getItemDamage() > 0 && ManaItemHandler.requestManaExactForTool(stack, (EntityPlayer) player, getManaPerDamage() * 2, true)) - stack.setItemDamage(stack.getItemDamage() - 1); - } - - public int getManaPerDamage() { - return MANA_PER_DAMAGE; - } - - @Override - public boolean getIsRepairable(ItemStack par1ItemStack, ItemStack par2ItemStack) { - return par2ItemStack.getItem() == ModItems.manaResource && par2ItemStack.getItemDamage() == 0 ? true : super.getIsRepairable(par1ItemStack, par2ItemStack); - } - - @Override - public boolean usesMana(ItemStack stack) { - return true; - } - + public static final int MANA_PER_DAMAGE = 60; + + public static IIcon elucidatorIcon; + + public ItemManasteelSword() { + this(BotaniaAPI.manasteelToolMaterial, LibItemNames.MANASTEEL_SWORD); + } + + public ItemManasteelSword(ToolMaterial mat, String name) { + super(mat); + setCreativeTab(BotaniaCreativeTab.INSTANCE); + setUnlocalizedName(name); + } + + @Override + public Item setUnlocalizedName(String par1Str) { + GameRegistry.registerItem(this, par1Str); + return super.setUnlocalizedName(par1Str); + } + + @Override + public String getUnlocalizedNameInefficiently(ItemStack par1ItemStack) { + return super.getUnlocalizedNameInefficiently(par1ItemStack) + .replaceAll("item.", "item." + LibResources.PREFIX_MOD); + } + + @Override + @SideOnly(Side.CLIENT) + public void registerIcons(IIconRegister par1IconRegister) { + itemIcon = IconHelper.forItem(par1IconRegister, this); + elucidatorIcon = IconHelper.forName(par1IconRegister, "elucidator"); + } + + @Override + public boolean hitEntity( + ItemStack par1ItemStack, EntityLivingBase par2EntityLivingBase, EntityLivingBase par3EntityLivingBase) { + if (usesMana(par1ItemStack)) ToolCommons.damageItem(par1ItemStack, 1, par3EntityLivingBase, getManaPerDamage()); + return true; + } + + @Override + public IIcon getIconIndex(ItemStack par1ItemStack) { + String name = par1ItemStack.getDisplayName().toLowerCase().trim(); + return name.equals("the elucidator") ? elucidatorIcon : super.getIconIndex(par1ItemStack); + } + + @Override + public IIcon getIcon(ItemStack stack, int pass) { + return getIconIndex(stack); + } + + @Override + public boolean onBlockDestroyed( + ItemStack stack, World world, Block block, int x, int y, int z, EntityLivingBase entity) { + if (usesMana(stack) && block.getBlockHardness(world, x, y, z) != 0F) + ToolCommons.damageItem(stack, 1, entity, getManaPerDamage()); + + return true; + } + + @Override + public void onUpdate(ItemStack stack, World world, Entity player, int par4, boolean par5) { + if (!world.isRemote + && player instanceof EntityPlayer + && stack.getItemDamage() > 0 + && ManaItemHandler.requestManaExactForTool(stack, (EntityPlayer) player, getManaPerDamage() * 2, true)) + stack.setItemDamage(stack.getItemDamage() - 1); + } + + public int getManaPerDamage() { + return MANA_PER_DAMAGE; + } + + @Override + public boolean getIsRepairable(ItemStack par1ItemStack, ItemStack par2ItemStack) { + return par2ItemStack.getItem() == ModItems.manaResource && par2ItemStack.getItemDamage() == 0 + ? true + : super.getIsRepairable(par1ItemStack, par2ItemStack); + } + + @Override + public boolean usesMana(ItemStack stack) { + return true; + } } diff --git a/src/main/java/vazkii/botania/common/item/equipment/tool/terrasteel/ItemTerraAxe.java b/src/main/java/vazkii/botania/common/item/equipment/tool/terrasteel/ItemTerraAxe.java index 11ad6a5bf6..506031b07c 100644 --- a/src/main/java/vazkii/botania/common/item/equipment/tool/terrasteel/ItemTerraAxe.java +++ b/src/main/java/vazkii/botania/common/item/equipment/tool/terrasteel/ItemTerraAxe.java @@ -2,14 +2,20 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [May 15, 2015, 6:55:34 PM (GMT)] */ package vazkii.botania.common.item.equipment.tool.terrasteel; +import cpw.mods.fml.common.FMLCommonHandler; +import cpw.mods.fml.common.eventhandler.SubscribeEvent; +import cpw.mods.fml.common.gameevent.TickEvent; +import cpw.mods.fml.common.gameevent.TickEvent.Phase; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; import java.util.ArrayList; import java.util.HashMap; import java.util.HashSet; @@ -18,7 +24,6 @@ import java.util.Map; import java.util.PriorityQueue; import java.util.Set; - import net.minecraft.block.Block; import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.enchantment.Enchantment; @@ -37,378 +42,385 @@ import vazkii.botania.common.item.equipment.tool.manasteel.ItemManasteelAxe; import vazkii.botania.common.item.relic.ItemLokiRing; import vazkii.botania.common.lib.LibItemNames; -import cpw.mods.fml.common.FMLCommonHandler; -import cpw.mods.fml.common.eventhandler.SubscribeEvent; -import cpw.mods.fml.common.gameevent.TickEvent; -import cpw.mods.fml.common.gameevent.TickEvent.Phase; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; public class ItemTerraAxe extends ItemManasteelAxe implements ISequentialBreaker { - - - /** - * The number of blocks per tick which the Terra Truncator will - * collect. - */ - public static final int BLOCK_SWAP_RATE = 10; - - /** - * The maximum radius (in blocks) which the Terra Truncator will go - * in order to try and murder/cut down the tree. - */ - public static final int BLOCK_RANGE = 32; - - /** - * The maximum number of leaf blocks which the Terra Truncator will chew/go - * through once a leaf block is encountered. - */ - public static final int LEAF_BLOCK_RANGE = 3; - - /** - * The amount of mana required to restore 1 point of damage. - */ - private static final int MANA_PER_DAMAGE = 100; - - /** - * Represents a map of dimension IDs to a set of all block swappers - * active in that dimension. - */ - private static Map> blockSwappers = new HashMap>(); - - IIcon iconOn, iconOff; - - public ItemTerraAxe() { - super(BotaniaAPI.terrasteelToolMaterial, LibItemNames.TERRA_AXE); - FMLCommonHandler.instance().bus().register(this); - } - - @Override - @SideOnly(Side.CLIENT) - public void registerIcons(IIconRegister par1IconRegister) { - iconOn = IconHelper.forItem(par1IconRegister, this, 0); - iconOff = IconHelper.forItem(par1IconRegister, this, 1); - } - - @Override - public IIcon getIconFromDamage(int p_77617_1_) { - return iconOn; - } - - @Override - public IIcon getIcon(ItemStack stack, int renderPass, EntityPlayer player, ItemStack usingItem, int useRemaining) { - return shouldBreak(player) ? iconOn : iconOff; - } - - public boolean shouldBreak(EntityPlayer player) { - return !player.isSneaking() && !ItemTemperanceStone.hasTemperanceActive(player); - } - - @Override - public boolean onBlockStartBreak(ItemStack stack, int x, int y, int z, EntityPlayer player) { - MovingObjectPosition raycast = ToolCommons.raytraceFromEntity(player.worldObj, player, true, 10); - if(raycast != null) { - breakOtherBlock(player, stack, x, y, z, x, y, z, raycast.sideHit); - ItemLokiRing.breakOnAllCursors(player, this, stack, x, y, z, raycast.sideHit); - } - - return false; - } - - @Override - public int getManaPerDamage() { - return MANA_PER_DAMAGE; - } - - @Override - public void breakOtherBlock(EntityPlayer player, ItemStack stack, int x, int y, int z, int originX, int originY, int originZ, int side) { - if(shouldBreak(player)) { - ChunkCoordinates coords = new ChunkCoordinates(x, y, z); - addBlockSwapper(player.worldObj, player, stack, coords, 32, true); - } - } - - @Override - public boolean disposeOfTrashBlocks(ItemStack stack) { - return false; - } - - @SubscribeEvent - public void onTickEnd(TickEvent.WorldTickEvent event) { - // Block Swapping ticking should only occur on the server - if(event.world.isRemote) - return; - - if(event.phase == Phase.END) { - int dim = event.world.provider.dimensionId; - if(blockSwappers.containsKey(dim)) { - Set swappers = blockSwappers.get(dim); - - // Iterate through all of our swappers, removing any - // which no longer need to tick. - Iterator swapper = swappers.iterator(); - while(swapper.hasNext()) { - BlockSwapper next = swapper.next(); - - // If a null sneaks in or the swapper is done, remove it - if(next == null || !next.tick()) - swapper.remove(); - } - } - } - } - - /** - * Adds a new block swapper to the provided world as the provided player. - * Block swappers are only added on the server, and a marker instance - * which is not actually ticked but contains the proper passed in - * information will be returned to the client. - * - * @param world The world to add the swapper to. - * @param player The player who is responsible for this swapper. - * @param stack The Terra Truncator which caused this block swapper. - * @param origCoords The original coordinates the swapper should start at. - * @param steps The range of the block swapper, in blocks. - * @param leaves If true, will treat leaves specially (see the BlockSwapper - * documentation). - * @return The created block swapper. - */ - private static BlockSwapper addBlockSwapper(World world, EntityPlayer player, ItemStack stack, ChunkCoordinates origCoords, int steps, boolean leaves) { - BlockSwapper swapper = new BlockSwapper(world, player, stack, origCoords, steps, leaves); - - // Block swapper registration should only occur on the server - if(world.isRemote) - return swapper; - - // If the mapping for this dimension doesn't exist, create it. - int dim = world.provider.dimensionId; - if(!blockSwappers.containsKey(dim)) - blockSwappers.put(dim, new HashSet()); - - // Add the swapper - blockSwappers.get(dim).add(swapper); - - return swapper; - } - - /** - * A block swapper for the Terra Truncator, which uses a standard - * Breadth First Search to try and murder/cut down trees. - * - * The Terra Truncator will look up to BLOCK_RANGE blocks to find wood - * to cut down (only cutting down adjacent pieces of wood, so it doesn't - * jump through the air). However, the truncator will only go through - * LEAF_BLOCK_RANGE leave blocks in order to prevent adjacent trees which - * are connected only by leaves from being devoured as well. - * - * The leaf restriction is implemented by reducing the number of remaining - * steps to the min of LEAF_BLOCK_RANGE and the current range. The restriction - * can be removed entirely by setting the "leaves" variable to true, in which - * case leaves will be treated normally. - */ - private static class BlockSwapper { - - /** - * Represents the range which a single block will scan when looking - * for the next candidates for swapping. 1 is a good default. - */ - public static final int SINGLE_BLOCK_RADIUS = 1; - - - /** - * The world the block swapper is doing the swapping in. - */ - private final World world; - - /** - * The player the swapper is swapping for. - */ - private final EntityPlayer player; - - /** - * The Terra Truncator which created this swapper. - */ - private final ItemStack truncator; - - /** - * The origin of the swapper (eg, where it started). - */ - private final ChunkCoordinates origin; - - /** - * Denotes whether leaves should be treated specially. - */ - private final boolean treatLeavesSpecial; - - /** - * The initial range which this block swapper starts with. - */ - private final int range; - - /** - * The priority queue of all possible candidates for swapping. - */ - private PriorityQueue candidateQueue; - - /** - * The set of already swaps coordinates which do not have - * to be revisited. - */ - private Set completedCoords; - - /** - * Creates a new block swapper with the provided parameters. - * @param world The world the swapper is in. - * @param player The player responsible for creating this swapper. - * @param truncator The Terra Truncator responsible for creating this swapper. - * @param origCoords The original coordinates this swapper should start at. - * @param range The range this swapper should swap in. - * @param leaves If true, leaves will be treated specially and - * severely reduce the radius of further spreading when encountered. - */ - public BlockSwapper(World world, EntityPlayer player, ItemStack truncator, ChunkCoordinates origCoords, int range, boolean leaves) { - this.world = world; - this.player = player; - this.truncator = truncator; - this.origin = origCoords; - this.range = range; - this.treatLeavesSpecial = leaves; - - this.candidateQueue = new PriorityQueue(); - this.completedCoords = new HashSet(); - - // Add the origin to our candidate queue with the original range - candidateQueue.offer(new SwapCandidate(this.origin, this.range)); - } - - /** - * Ticks this Block Swapper, which allows it to swap BLOCK_SWAP_RATE - * further blocks and expands the breadth first search. The return - * value signifies whether or not the block swapper has more blocks - * to swap, or if it has finished swapping. - * @return True if the block swapper has more blocks to swap, false - * otherwise (implying it can be safely removed). - */ - public boolean tick() { - // If empty, this swapper is done. - if(candidateQueue.isEmpty()) - return false; - - int remainingSwaps = BLOCK_SWAP_RATE; - while(remainingSwaps > 0 && !candidateQueue.isEmpty()) { - SwapCandidate cand = candidateQueue.poll(); - - // If we've already completed this location, move along, as this - // is just a suboptimal one. - if(completedCoords.contains(cand.coordinates)) - continue; - - // If this candidate is out of range, discard it. - if(cand.range <= 0) - continue; - - // Otherwise, perform the break and then look at the adjacent tiles. - // This is a ridiculous function call here. - ToolCommons.removeBlockWithDrops(player, truncator, world, - cand.coordinates.posX, cand.coordinates.posY, cand.coordinates.posZ, - origin.posX, origin.posY, origin.posZ, - null, ToolCommons.materialsAxe, - EnchantmentHelper.getEnchantmentLevel(Enchantment.silkTouch.effectId, truncator) > 0, - EnchantmentHelper.getEnchantmentLevel(Enchantment.fortune.effectId, truncator), - 0F, false, treatLeavesSpecial); - - remainingSwaps--; - - completedCoords.add(cand.coordinates); - - // Then, go through all of the adjacent blocks and look if - // any of them are any good. - for(ChunkCoordinates adj : adjacent(cand.coordinates)) { - Block block = world.getBlock(adj.posX, adj.posY, adj.posZ); - - boolean isWood = block.isWood(world, adj.posX, adj.posY, adj.posZ); - boolean isLeaf = block.isLeaves(world, adj.posX, adj.posY, adj.posZ); - - // If it's not wood or a leaf, we aren't interested. - if(!isWood && !isLeaf) - continue; - - // If we treat leaves specially and this is a leaf, it gets - // the minimum of the leaf range and the current range - 1. - // Otherwise, it gets the standard range - 1. - int newRange = treatLeavesSpecial && isLeaf ? - Math.min(LEAF_BLOCK_RANGE, cand.range - 1) : - cand.range - 1; - - candidateQueue.offer(new SwapCandidate(adj, newRange)); - } - } - - // If we did any iteration, then hang around until next tick. - return true; - } - - public List adjacent(ChunkCoordinates original) { - List coords = new ArrayList(); - // Visit all the surrounding blocks in the provided radius. - // Gotta love these nested loops, right? - for(int dx = -SINGLE_BLOCK_RADIUS; dx <= SINGLE_BLOCK_RADIUS; dx++) - for(int dy = -SINGLE_BLOCK_RADIUS; dy <= SINGLE_BLOCK_RADIUS; dy++) - for(int dz = -SINGLE_BLOCK_RADIUS; dz <= SINGLE_BLOCK_RADIUS; dz++) { - // Skip the central tile. - if(dx == 0 && dy == 0 && dz == 0) - continue; - - coords.add(new ChunkCoordinates(original.posX + dx, original.posY + dy, original.posZ + dz)); - } - - return coords; - } - - /** - * Represents a potential candidate for swapping/removal. Sorted by - * range (where a larger range is more preferable). As we're using - * a priority queue, which is a min-heap internally, larger ranges - * are considered "smaller" than smaller ranges (so they show up in the - * min-heap first). - */ - public static final class SwapCandidate implements Comparable { - /** - * The location of this swap candidate. - */ - public ChunkCoordinates coordinates; - - /** - * The remaining range of this swap candidate. - */ - public int range; - - /** - * Constructs a new Swap Candidate with the provided - * coordinates and range. - * @param coordinates The coordinates of this candidate. - * @param range The remaining range of this candidate. - */ - public SwapCandidate(ChunkCoordinates coordinates, int range) { - this.coordinates = coordinates; - this.range = range; - } - - @Override - public int compareTo(SwapCandidate other) { - // Aka, a bigger range implies a smaller value, meaning - // bigger ranges will be preferred in a min-heap - return other.range - range; - } - - @Override - public boolean equals(Object other) { - if(!(other instanceof SwapCandidate)) return false; - - SwapCandidate cand = (SwapCandidate) other; - return coordinates.equals(cand.coordinates) && range == cand.range; - } - } - } + /** + * The number of blocks per tick which the Terra Truncator will + * collect. + */ + public static final int BLOCK_SWAP_RATE = 10; + + /** + * The maximum radius (in blocks) which the Terra Truncator will go + * in order to try and murder/cut down the tree. + */ + public static final int BLOCK_RANGE = 32; + + /** + * The maximum number of leaf blocks which the Terra Truncator will chew/go + * through once a leaf block is encountered. + */ + public static final int LEAF_BLOCK_RANGE = 3; + + /** + * The amount of mana required to restore 1 point of damage. + */ + private static final int MANA_PER_DAMAGE = 100; + + /** + * Represents a map of dimension IDs to a set of all block swappers + * active in that dimension. + */ + private static Map> blockSwappers = new HashMap>(); + + IIcon iconOn, iconOff; + + public ItemTerraAxe() { + super(BotaniaAPI.terrasteelToolMaterial, LibItemNames.TERRA_AXE); + FMLCommonHandler.instance().bus().register(this); + } + + @Override + @SideOnly(Side.CLIENT) + public void registerIcons(IIconRegister par1IconRegister) { + iconOn = IconHelper.forItem(par1IconRegister, this, 0); + iconOff = IconHelper.forItem(par1IconRegister, this, 1); + } + + @Override + public IIcon getIconFromDamage(int p_77617_1_) { + return iconOn; + } + + @Override + public IIcon getIcon(ItemStack stack, int renderPass, EntityPlayer player, ItemStack usingItem, int useRemaining) { + return shouldBreak(player) ? iconOn : iconOff; + } + + public boolean shouldBreak(EntityPlayer player) { + return !player.isSneaking() && !ItemTemperanceStone.hasTemperanceActive(player); + } + + @Override + public boolean onBlockStartBreak(ItemStack stack, int x, int y, int z, EntityPlayer player) { + MovingObjectPosition raycast = ToolCommons.raytraceFromEntity(player.worldObj, player, true, 10); + if (raycast != null) { + breakOtherBlock(player, stack, x, y, z, x, y, z, raycast.sideHit); + ItemLokiRing.breakOnAllCursors(player, this, stack, x, y, z, raycast.sideHit); + } + + return false; + } + + @Override + public int getManaPerDamage() { + return MANA_PER_DAMAGE; + } + + @Override + public void breakOtherBlock( + EntityPlayer player, + ItemStack stack, + int x, + int y, + int z, + int originX, + int originY, + int originZ, + int side) { + if (shouldBreak(player)) { + ChunkCoordinates coords = new ChunkCoordinates(x, y, z); + addBlockSwapper(player.worldObj, player, stack, coords, 32, true); + } + } + + @Override + public boolean disposeOfTrashBlocks(ItemStack stack) { + return false; + } + + @SubscribeEvent + public void onTickEnd(TickEvent.WorldTickEvent event) { + // Block Swapping ticking should only occur on the server + if (event.world.isRemote) return; + + if (event.phase == Phase.END) { + int dim = event.world.provider.dimensionId; + if (blockSwappers.containsKey(dim)) { + Set swappers = blockSwappers.get(dim); + + // Iterate through all of our swappers, removing any + // which no longer need to tick. + Iterator swapper = swappers.iterator(); + while (swapper.hasNext()) { + BlockSwapper next = swapper.next(); + + // If a null sneaks in or the swapper is done, remove it + if (next == null || !next.tick()) swapper.remove(); + } + } + } + } + + /** + * Adds a new block swapper to the provided world as the provided player. + * Block swappers are only added on the server, and a marker instance + * which is not actually ticked but contains the proper passed in + * information will be returned to the client. + * + * @param world The world to add the swapper to. + * @param player The player who is responsible for this swapper. + * @param stack The Terra Truncator which caused this block swapper. + * @param origCoords The original coordinates the swapper should start at. + * @param steps The range of the block swapper, in blocks. + * @param leaves If true, will treat leaves specially (see the BlockSwapper + * documentation). + * @return The created block swapper. + */ + private static BlockSwapper addBlockSwapper( + World world, EntityPlayer player, ItemStack stack, ChunkCoordinates origCoords, int steps, boolean leaves) { + BlockSwapper swapper = new BlockSwapper(world, player, stack, origCoords, steps, leaves); + + // Block swapper registration should only occur on the server + if (world.isRemote) return swapper; + + // If the mapping for this dimension doesn't exist, create it. + int dim = world.provider.dimensionId; + if (!blockSwappers.containsKey(dim)) blockSwappers.put(dim, new HashSet()); + + // Add the swapper + blockSwappers.get(dim).add(swapper); + + return swapper; + } + + /** + * A block swapper for the Terra Truncator, which uses a standard + * Breadth First Search to try and murder/cut down trees. + * + * The Terra Truncator will look up to BLOCK_RANGE blocks to find wood + * to cut down (only cutting down adjacent pieces of wood, so it doesn't + * jump through the air). However, the truncator will only go through + * LEAF_BLOCK_RANGE leave blocks in order to prevent adjacent trees which + * are connected only by leaves from being devoured as well. + * + * The leaf restriction is implemented by reducing the number of remaining + * steps to the min of LEAF_BLOCK_RANGE and the current range. The restriction + * can be removed entirely by setting the "leaves" variable to true, in which + * case leaves will be treated normally. + */ + private static class BlockSwapper { + + /** + * Represents the range which a single block will scan when looking + * for the next candidates for swapping. 1 is a good default. + */ + public static final int SINGLE_BLOCK_RADIUS = 1; + + /** + * The world the block swapper is doing the swapping in. + */ + private final World world; + + /** + * The player the swapper is swapping for. + */ + private final EntityPlayer player; + + /** + * The Terra Truncator which created this swapper. + */ + private final ItemStack truncator; + + /** + * The origin of the swapper (eg, where it started). + */ + private final ChunkCoordinates origin; + + /** + * Denotes whether leaves should be treated specially. + */ + private final boolean treatLeavesSpecial; + + /** + * The initial range which this block swapper starts with. + */ + private final int range; + + /** + * The priority queue of all possible candidates for swapping. + */ + private PriorityQueue candidateQueue; + + /** + * The set of already swaps coordinates which do not have + * to be revisited. + */ + private Set completedCoords; + + /** + * Creates a new block swapper with the provided parameters. + * @param world The world the swapper is in. + * @param player The player responsible for creating this swapper. + * @param truncator The Terra Truncator responsible for creating this swapper. + * @param origCoords The original coordinates this swapper should start at. + * @param range The range this swapper should swap in. + * @param leaves If true, leaves will be treated specially and + * severely reduce the radius of further spreading when encountered. + */ + public BlockSwapper( + World world, + EntityPlayer player, + ItemStack truncator, + ChunkCoordinates origCoords, + int range, + boolean leaves) { + this.world = world; + this.player = player; + this.truncator = truncator; + this.origin = origCoords; + this.range = range; + this.treatLeavesSpecial = leaves; + + this.candidateQueue = new PriorityQueue(); + this.completedCoords = new HashSet(); + + // Add the origin to our candidate queue with the original range + candidateQueue.offer(new SwapCandidate(this.origin, this.range)); + } + + /** + * Ticks this Block Swapper, which allows it to swap BLOCK_SWAP_RATE + * further blocks and expands the breadth first search. The return + * value signifies whether or not the block swapper has more blocks + * to swap, or if it has finished swapping. + * @return True if the block swapper has more blocks to swap, false + * otherwise (implying it can be safely removed). + */ + public boolean tick() { + // If empty, this swapper is done. + if (candidateQueue.isEmpty()) return false; + + int remainingSwaps = BLOCK_SWAP_RATE; + while (remainingSwaps > 0 && !candidateQueue.isEmpty()) { + SwapCandidate cand = candidateQueue.poll(); + + // If we've already completed this location, move along, as this + // is just a suboptimal one. + if (completedCoords.contains(cand.coordinates)) continue; + + // If this candidate is out of range, discard it. + if (cand.range <= 0) continue; + + // Otherwise, perform the break and then look at the adjacent tiles. + // This is a ridiculous function call here. + ToolCommons.removeBlockWithDrops( + player, + truncator, + world, + cand.coordinates.posX, + cand.coordinates.posY, + cand.coordinates.posZ, + origin.posX, + origin.posY, + origin.posZ, + null, + ToolCommons.materialsAxe, + EnchantmentHelper.getEnchantmentLevel(Enchantment.silkTouch.effectId, truncator) > 0, + EnchantmentHelper.getEnchantmentLevel(Enchantment.fortune.effectId, truncator), + 0F, + false, + treatLeavesSpecial); + + remainingSwaps--; + + completedCoords.add(cand.coordinates); + + // Then, go through all of the adjacent blocks and look if + // any of them are any good. + for (ChunkCoordinates adj : adjacent(cand.coordinates)) { + Block block = world.getBlock(adj.posX, adj.posY, adj.posZ); + + boolean isWood = block.isWood(world, adj.posX, adj.posY, adj.posZ); + boolean isLeaf = block.isLeaves(world, adj.posX, adj.posY, adj.posZ); + + // If it's not wood or a leaf, we aren't interested. + if (!isWood && !isLeaf) continue; + + // If we treat leaves specially and this is a leaf, it gets + // the minimum of the leaf range and the current range - 1. + // Otherwise, it gets the standard range - 1. + int newRange = + treatLeavesSpecial && isLeaf ? Math.min(LEAF_BLOCK_RANGE, cand.range - 1) : cand.range - 1; + + candidateQueue.offer(new SwapCandidate(adj, newRange)); + } + } + + // If we did any iteration, then hang around until next tick. + return true; + } + + public List adjacent(ChunkCoordinates original) { + List coords = new ArrayList(); + // Visit all the surrounding blocks in the provided radius. + // Gotta love these nested loops, right? + for (int dx = -SINGLE_BLOCK_RADIUS; dx <= SINGLE_BLOCK_RADIUS; dx++) + for (int dy = -SINGLE_BLOCK_RADIUS; dy <= SINGLE_BLOCK_RADIUS; dy++) + for (int dz = -SINGLE_BLOCK_RADIUS; dz <= SINGLE_BLOCK_RADIUS; dz++) { + // Skip the central tile. + if (dx == 0 && dy == 0 && dz == 0) continue; + + coords.add(new ChunkCoordinates(original.posX + dx, original.posY + dy, original.posZ + dz)); + } + + return coords; + } + + /** + * Represents a potential candidate for swapping/removal. Sorted by + * range (where a larger range is more preferable). As we're using + * a priority queue, which is a min-heap internally, larger ranges + * are considered "smaller" than smaller ranges (so they show up in the + * min-heap first). + */ + public static final class SwapCandidate implements Comparable { + /** + * The location of this swap candidate. + */ + public ChunkCoordinates coordinates; + + /** + * The remaining range of this swap candidate. + */ + public int range; + + /** + * Constructs a new Swap Candidate with the provided + * coordinates and range. + * @param coordinates The coordinates of this candidate. + * @param range The remaining range of this candidate. + */ + public SwapCandidate(ChunkCoordinates coordinates, int range) { + this.coordinates = coordinates; + this.range = range; + } + + @Override + public int compareTo(SwapCandidate other) { + // Aka, a bigger range implies a smaller value, meaning + // bigger ranges will be preferred in a min-heap + return other.range - range; + } + + @Override + public boolean equals(Object other) { + if (!(other instanceof SwapCandidate)) return false; + + SwapCandidate cand = (SwapCandidate) other; + return coordinates.equals(cand.coordinates) && range == cand.range; + } + } + } } diff --git a/src/main/java/vazkii/botania/common/item/equipment/tool/terrasteel/ItemTerraPick.java b/src/main/java/vazkii/botania/common/item/equipment/tool/terrasteel/ItemTerraPick.java index 58f01a2c36..dbe118357e 100644 --- a/src/main/java/vazkii/botania/common/item/equipment/tool/terrasteel/ItemTerraPick.java +++ b/src/main/java/vazkii/botania/common/item/equipment/tool/terrasteel/ItemTerraPick.java @@ -2,17 +2,19 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [May 20, 2014, 10:56:14 PM (GMT)] */ package vazkii.botania.common.item.equipment.tool.terrasteel; +import cpw.mods.fml.common.registry.GameRegistry; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; import java.awt.Color; import java.util.List; - import net.minecraft.block.material.Material; import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.creativetab.CreativeTabs; @@ -38,272 +40,302 @@ import vazkii.botania.common.achievement.ModAchievements; import vazkii.botania.common.core.helper.ItemNBTHelper; import vazkii.botania.common.crafting.recipe.TerraPickTippingRecipe; -import vazkii.botania.common.item.ItemSpark; import vazkii.botania.common.item.ItemTemperanceStone; import vazkii.botania.common.item.ModItems; -import vazkii.botania.common.item.equipment.bauble.ItemAuraRing; -import vazkii.botania.common.item.equipment.bauble.ItemGreaterAuraRing; import vazkii.botania.common.item.equipment.tool.ToolCommons; import vazkii.botania.common.item.equipment.tool.manasteel.ItemManasteelPick; import vazkii.botania.common.item.relic.ItemLokiRing; import vazkii.botania.common.item.relic.ItemThorRing; import vazkii.botania.common.lib.LibItemNames; -import cpw.mods.fml.common.registry.GameRegistry; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; public class ItemTerraPick extends ItemManasteelPick implements IManaItem, ISequentialBreaker { - private static final String TAG_ENABLED = "enabled"; - private static final String TAG_MANA = "mana"; - private static final String TAG_TIPPED = "tipped"; - - private static final int MAX_MANA = Integer.MAX_VALUE; - private static final int MANA_PER_DAMAGE = 100; - - private static final Material[] MATERIALS = new Material[] { Material.rock, Material.iron, Material.ice, Material.glass, Material.piston, Material.anvil, Material.grass, Material.ground, Material.sand, Material.snow, Material.craftedSnow, Material.clay }; - - public static final int[] LEVELS = new int[] { - 0, 10000, 1000000, 10000000, 100000000, 1000000000 - }; - - private static final int[] CREATIVE_MANA = new int[] { - 10000 - 1, 1000000 - 1, 10000000 - 1, 100000000 - 1, 1000000000 - 1, MAX_MANA - 1 - }; - - IIcon iconTool, iconOverlay, iconTipped; - - public ItemTerraPick() { - super(BotaniaAPI.terrasteelToolMaterial, LibItemNames.TERRA_PICK); - GameRegistry.addRecipe(new TerraPickTippingRecipe()); - RecipeSorter.register("botania:terraPickTipping", TerraPickTippingRecipe.class, Category.SHAPELESS, ""); - } - - @Override - public void getSubItems(Item item, CreativeTabs tab, List list) { - for(int mana : CREATIVE_MANA) { - ItemStack stack = new ItemStack(item); - setMana(stack, mana); - list.add(stack); - } - } - - @Override - public void addInformation(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, List par3List, boolean par4) { - String rankFormat = StatCollector.translateToLocal("botaniamisc.toolRank"); - String rank = StatCollector.translateToLocal("botania.rank" + getLevel(par1ItemStack)); - par3List.add(String.format(rankFormat, rank).replaceAll("&", "\u00a7")); - if(getMana(par1ItemStack) == Integer.MAX_VALUE) - par3List.add(EnumChatFormatting.RED + StatCollector.translateToLocal("botaniamisc.getALife")); - } - - @Override - public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer) { - getMana(par1ItemStack); - int level = getLevel(par1ItemStack); - - if(level != 0) { - setEnabled(par1ItemStack, !isEnabled(par1ItemStack)); - if(!par2World.isRemote) - par2World.playSoundAtEntity(par3EntityPlayer, "botania:terraPickMode", 0.5F, 0.4F); - } - - return par1ItemStack; - } - - @Override - public boolean onItemUse(ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int s, float sx, float sy, float sz) { - return player.isSneaking() && super.onItemUse(stack, player, world, x, y, z, s, sx, sy, sz); - } - - @Override - public void onUpdate(ItemStack par1ItemStack, World par2World, Entity par3Entity, int par4, boolean par5) { - super.onUpdate(par1ItemStack, par2World, par3Entity, par4, par5); - if(isEnabled(par1ItemStack)) { - int level = getLevel(par1ItemStack); - - if(level == 0) - setEnabled(par1ItemStack, false); - else if(par3Entity instanceof EntityPlayer && !((EntityPlayer) par3Entity).isSwingInProgress) - addMana(par1ItemStack, -level); - } - } - - @Override - public boolean onBlockStartBreak(ItemStack stack, int x, int y, int z, EntityPlayer player) { - MovingObjectPosition raycast = ToolCommons.raytraceFromEntity(player.worldObj, player, true, 10); - if(raycast != null) { - breakOtherBlock(player, stack, x, y, z, x, y, z, raycast.sideHit); - ItemLokiRing.breakOnAllCursors(player, this, stack, x, y, z, raycast.sideHit); - // ^ Doable with API access through the IInternalMethodHandler. - } - - return false; - } - - @Override - public int getManaPerDmg() { - return MANA_PER_DAMAGE; - } - - @Override - public void breakOtherBlock(EntityPlayer player, ItemStack stack, int x, int y, int z, int originX, int originY, int originZ, int side) { - if(!isEnabled(stack)) - return; - - World world = player.worldObj; - Material mat = world.getBlock(x, y, z).getMaterial(); - if(!ToolCommons.isRightMaterial(mat, MATERIALS)) - return; - - if(world.isAirBlock(x, y, z)) - return; - - ForgeDirection direction = ForgeDirection.getOrientation(side); - int fortune = EnchantmentHelper.getFortuneModifier(player); - boolean silk = EnchantmentHelper.getSilkTouchModifier(player); - boolean thor = ItemThorRing.getThorRing(player) != null; - boolean doX = thor || direction.offsetX == 0; - boolean doY = thor || direction.offsetY == 0; - boolean doZ = thor || direction.offsetZ == 0; - - int origLevel = getLevel(stack); - int level = origLevel + (thor ? 1 : 0); - if(ItemTemperanceStone.hasTemperanceActive(player) && level > 2) - level = 2; - - int range = Math.max(0, level - 1); - int rangeY = Math.max(1, range); - - if(range == 0 && level != 1) - return; - - ToolCommons.removeBlocksInIteration(player, stack, world, x, y, z, doX ? -range : 0, doY ? -1 : 0, doZ ? -range : 0, doX ? range + 1 : 1, doY ? rangeY * 2 : 1, doZ ? range + 1 : 1, null, MATERIALS, silk, fortune, isTipped(stack)); - if(origLevel == 5) - player.addStat(ModAchievements.rankSSPick, 1); - } - - @Override - public int getEntityLifespan(ItemStack itemStack, World world) { - return Integer.MAX_VALUE; - } - - @Override - public void registerIcons(IIconRegister par1IconRegister) { - iconTool = IconHelper.forItem(par1IconRegister, this, 0); - iconOverlay = IconHelper.forItem(par1IconRegister, this, 1); - iconTipped = IconHelper.forItem(par1IconRegister, this, 2); - } - - @Override - public boolean requiresMultipleRenderPasses() { - return true; - } - - @Override - public IIcon getIcon(ItemStack stack, int pass) { - return pass == 1 && isEnabled(stack) ? iconOverlay : isTipped(stack) ? iconTipped : iconTool; - } - - @Override - public int getHarvestLevel(ItemStack stack, String toolClass) { - if (!"pickaxe".equals(toolClass)) { - return super.getHarvestLevel(stack, toolClass); - } - // Rank S -> level 8 (Manyullyn) - return getLevel(stack) + 4; - } - - public static boolean isTipped(ItemStack stack) { - return ItemNBTHelper.getBoolean(stack, TAG_TIPPED, false); - } - - public static void setTipped(ItemStack stack) { - ItemNBTHelper.setBoolean(stack, TAG_TIPPED, true); - } - - @Override - @SideOnly(Side.CLIENT) - public int getColorFromItemStack(ItemStack par1ItemStack, int par2) { - if(par2 == 0 || !isEnabled(par1ItemStack)) - return 0xFFFFFF; - - return Color.HSBtoRGB(0.375F, (float) Math.min(1F, Math.sin(System.currentTimeMillis() / 200D) * 0.5 + 1F), 1F); - } - - boolean isEnabled(ItemStack stack) { - return ItemNBTHelper.getBoolean(stack, TAG_ENABLED, false); - } - - void setEnabled(ItemStack stack, boolean enabled) { - ItemNBTHelper.setBoolean(stack, TAG_ENABLED, enabled); - } - - public static void setMana(ItemStack stack, int mana) { - ItemNBTHelper.setInt(stack, TAG_MANA, mana); - } - - @Override - public int getMana(ItemStack stack) { - return getMana_(stack); - } - - public static int getMana_(ItemStack stack) { - return ItemNBTHelper.getInt(stack, TAG_MANA, 0); - } - - public static int getLevel(ItemStack stack) { - int mana = getMana_(stack); - for(int i = LEVELS.length - 1; i > 0; i--) - if(mana >= LEVELS[i]) - return i; - - return 0; - } - - @Override - public int getMaxMana(ItemStack stack) { - return MAX_MANA; - } - - @Override - public void addMana(ItemStack stack, int mana) { - setMana(stack, Math.min(getMana(stack) + mana, MAX_MANA)); - } - - @Override - public boolean canReceiveManaFromPool(ItemStack stack, TileEntity pool) { - return true; - } - - @Override - public boolean canReceiveManaFromItem(ItemStack stack, ItemStack otherStack) { - return !(otherStack.getItem() instanceof IManaGivingItem); - } - - @Override - public boolean canExportManaToPool(ItemStack stack, TileEntity pool) { - return false; - } - - @Override - public boolean canExportManaToItem(ItemStack stack, ItemStack otherStack) { - return false; - } - - @Override - public boolean isNoExport(ItemStack stack) { - return true; - } - - @Override - public boolean getIsRepairable(ItemStack par1ItemStack, ItemStack par2ItemStack) { - return par2ItemStack.getItem() == ModItems.manaResource && par2ItemStack.getItemDamage() == 4 ? true : super.getIsRepairable(par1ItemStack, par2ItemStack); - } - - @Override - public boolean disposeOfTrashBlocks(ItemStack stack) { - return isTipped(stack); - } - + private static final String TAG_ENABLED = "enabled"; + private static final String TAG_MANA = "mana"; + private static final String TAG_TIPPED = "tipped"; + + private static final int MAX_MANA = Integer.MAX_VALUE; + private static final int MANA_PER_DAMAGE = 100; + + private static final Material[] MATERIALS = new Material[] { + Material.rock, + Material.iron, + Material.ice, + Material.glass, + Material.piston, + Material.anvil, + Material.grass, + Material.ground, + Material.sand, + Material.snow, + Material.craftedSnow, + Material.clay + }; + + public static final int[] LEVELS = new int[] {0, 10000, 1000000, 10000000, 100000000, 1000000000}; + + private static final int[] CREATIVE_MANA = + new int[] {10000 - 1, 1000000 - 1, 10000000 - 1, 100000000 - 1, 1000000000 - 1, MAX_MANA - 1}; + + IIcon iconTool, iconOverlay, iconTipped; + + public ItemTerraPick() { + super(BotaniaAPI.terrasteelToolMaterial, LibItemNames.TERRA_PICK); + GameRegistry.addRecipe(new TerraPickTippingRecipe()); + RecipeSorter.register("botania:terraPickTipping", TerraPickTippingRecipe.class, Category.SHAPELESS, ""); + } + + @Override + public void getSubItems(Item item, CreativeTabs tab, List list) { + for (int mana : CREATIVE_MANA) { + ItemStack stack = new ItemStack(item); + setMana(stack, mana); + list.add(stack); + } + } + + @Override + public void addInformation(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, List par3List, boolean par4) { + String rankFormat = StatCollector.translateToLocal("botaniamisc.toolRank"); + String rank = StatCollector.translateToLocal("botania.rank" + getLevel(par1ItemStack)); + par3List.add(String.format(rankFormat, rank).replaceAll("&", "\u00a7")); + if (getMana(par1ItemStack) == Integer.MAX_VALUE) + par3List.add(EnumChatFormatting.RED + StatCollector.translateToLocal("botaniamisc.getALife")); + } + + @Override + public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer) { + getMana(par1ItemStack); + int level = getLevel(par1ItemStack); + + if (level != 0) { + setEnabled(par1ItemStack, !isEnabled(par1ItemStack)); + if (!par2World.isRemote) par2World.playSoundAtEntity(par3EntityPlayer, "botania:terraPickMode", 0.5F, 0.4F); + } + + return par1ItemStack; + } + + @Override + public boolean onItemUse( + ItemStack stack, + EntityPlayer player, + World world, + int x, + int y, + int z, + int s, + float sx, + float sy, + float sz) { + return player.isSneaking() && super.onItemUse(stack, player, world, x, y, z, s, sx, sy, sz); + } + + @Override + public void onUpdate(ItemStack par1ItemStack, World par2World, Entity par3Entity, int par4, boolean par5) { + super.onUpdate(par1ItemStack, par2World, par3Entity, par4, par5); + if (isEnabled(par1ItemStack)) { + int level = getLevel(par1ItemStack); + + if (level == 0) setEnabled(par1ItemStack, false); + else if (par3Entity instanceof EntityPlayer && !((EntityPlayer) par3Entity).isSwingInProgress) + addMana(par1ItemStack, -level); + } + } + + @Override + public boolean onBlockStartBreak(ItemStack stack, int x, int y, int z, EntityPlayer player) { + MovingObjectPosition raycast = ToolCommons.raytraceFromEntity(player.worldObj, player, true, 10); + if (raycast != null) { + breakOtherBlock(player, stack, x, y, z, x, y, z, raycast.sideHit); + ItemLokiRing.breakOnAllCursors(player, this, stack, x, y, z, raycast.sideHit); + // ^ Doable with API access through the IInternalMethodHandler. + } + + return false; + } + + @Override + public int getManaPerDmg() { + return MANA_PER_DAMAGE; + } + + @Override + public void breakOtherBlock( + EntityPlayer player, + ItemStack stack, + int x, + int y, + int z, + int originX, + int originY, + int originZ, + int side) { + if (!isEnabled(stack)) return; + + World world = player.worldObj; + Material mat = world.getBlock(x, y, z).getMaterial(); + if (!ToolCommons.isRightMaterial(mat, MATERIALS)) return; + + if (world.isAirBlock(x, y, z)) return; + + ForgeDirection direction = ForgeDirection.getOrientation(side); + int fortune = EnchantmentHelper.getFortuneModifier(player); + boolean silk = EnchantmentHelper.getSilkTouchModifier(player); + boolean thor = ItemThorRing.getThorRing(player) != null; + boolean doX = thor || direction.offsetX == 0; + boolean doY = thor || direction.offsetY == 0; + boolean doZ = thor || direction.offsetZ == 0; + + int origLevel = getLevel(stack); + int level = origLevel + (thor ? 1 : 0); + if (ItemTemperanceStone.hasTemperanceActive(player) && level > 2) level = 2; + + int range = Math.max(0, level - 1); + int rangeY = Math.max(1, range); + + if (range == 0 && level != 1) return; + + ToolCommons.removeBlocksInIteration( + player, + stack, + world, + x, + y, + z, + doX ? -range : 0, + doY ? -1 : 0, + doZ ? -range : 0, + doX ? range + 1 : 1, + doY ? rangeY * 2 : 1, + doZ ? range + 1 : 1, + null, + MATERIALS, + silk, + fortune, + isTipped(stack)); + if (origLevel == 5) player.addStat(ModAchievements.rankSSPick, 1); + } + + @Override + public int getEntityLifespan(ItemStack itemStack, World world) { + return Integer.MAX_VALUE; + } + + @Override + public void registerIcons(IIconRegister par1IconRegister) { + iconTool = IconHelper.forItem(par1IconRegister, this, 0); + iconOverlay = IconHelper.forItem(par1IconRegister, this, 1); + iconTipped = IconHelper.forItem(par1IconRegister, this, 2); + } + + @Override + public boolean requiresMultipleRenderPasses() { + return true; + } + + @Override + public IIcon getIcon(ItemStack stack, int pass) { + return pass == 1 && isEnabled(stack) ? iconOverlay : isTipped(stack) ? iconTipped : iconTool; + } + + @Override + public int getHarvestLevel(ItemStack stack, String toolClass) { + if (!"pickaxe".equals(toolClass)) { + return super.getHarvestLevel(stack, toolClass); + } + // Rank S -> level 8 (Manyullyn) + return getLevel(stack) + 4; + } + + public static boolean isTipped(ItemStack stack) { + return ItemNBTHelper.getBoolean(stack, TAG_TIPPED, false); + } + + public static void setTipped(ItemStack stack) { + ItemNBTHelper.setBoolean(stack, TAG_TIPPED, true); + } + + @Override + @SideOnly(Side.CLIENT) + public int getColorFromItemStack(ItemStack par1ItemStack, int par2) { + if (par2 == 0 || !isEnabled(par1ItemStack)) return 0xFFFFFF; + + return Color.HSBtoRGB(0.375F, (float) Math.min(1F, Math.sin(System.currentTimeMillis() / 200D) * 0.5 + 1F), 1F); + } + + boolean isEnabled(ItemStack stack) { + return ItemNBTHelper.getBoolean(stack, TAG_ENABLED, false); + } + + void setEnabled(ItemStack stack, boolean enabled) { + ItemNBTHelper.setBoolean(stack, TAG_ENABLED, enabled); + } + + public static void setMana(ItemStack stack, int mana) { + ItemNBTHelper.setInt(stack, TAG_MANA, mana); + } + + @Override + public int getMana(ItemStack stack) { + return getMana_(stack); + } + + public static int getMana_(ItemStack stack) { + return ItemNBTHelper.getInt(stack, TAG_MANA, 0); + } + + public static int getLevel(ItemStack stack) { + int mana = getMana_(stack); + for (int i = LEVELS.length - 1; i > 0; i--) if (mana >= LEVELS[i]) return i; + + return 0; + } + + @Override + public int getMaxMana(ItemStack stack) { + return MAX_MANA; + } + + @Override + public void addMana(ItemStack stack, int mana) { + setMana(stack, Math.min(getMana(stack) + mana, MAX_MANA)); + } + + @Override + public boolean canReceiveManaFromPool(ItemStack stack, TileEntity pool) { + return true; + } + + @Override + public boolean canReceiveManaFromItem(ItemStack stack, ItemStack otherStack) { + return !(otherStack.getItem() instanceof IManaGivingItem); + } + + @Override + public boolean canExportManaToPool(ItemStack stack, TileEntity pool) { + return false; + } + + @Override + public boolean canExportManaToItem(ItemStack stack, ItemStack otherStack) { + return false; + } + + @Override + public boolean isNoExport(ItemStack stack) { + return true; + } + + @Override + public boolean getIsRepairable(ItemStack par1ItemStack, ItemStack par2ItemStack) { + return par2ItemStack.getItem() == ModItems.manaResource && par2ItemStack.getItemDamage() == 4 + ? true + : super.getIsRepairable(par1ItemStack, par2ItemStack); + } + + @Override + public boolean disposeOfTrashBlocks(ItemStack stack) { + return isTipped(stack); + } } diff --git a/src/main/java/vazkii/botania/common/item/equipment/tool/terrasteel/ItemTerraSword.java b/src/main/java/vazkii/botania/common/item/equipment/tool/terrasteel/ItemTerraSword.java index 4865193ec5..d8a654c40d 100644 --- a/src/main/java/vazkii/botania/common/item/equipment/tool/terrasteel/ItemTerraSword.java +++ b/src/main/java/vazkii/botania/common/item/equipment/tool/terrasteel/ItemTerraSword.java @@ -2,16 +2,15 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Apr 14, 2014, 7:34:56 PM (GMT)] */ package vazkii.botania.common.item.equipment.tool.terrasteel; import java.util.List; - import net.minecraft.entity.Entity; import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.player.EntityPlayer; @@ -41,106 +40,121 @@ public class ItemTerraSword extends ItemManasteelSword implements ILensEffect, ICraftAchievement { - private static final String TAG_ATTACKER_USERNAME = "attackerUsername"; - - private static final int MANA_PER_DAMAGE = 100; - - public ItemTerraSword() { - super(BotaniaAPI.terrasteelToolMaterial, LibItemNames.TERRA_SWORD); - } - - @Override - public void onUpdate(ItemStack par1ItemStack, World par2World, Entity par3Entity, int par4, boolean par5) { - super.onUpdate(par1ItemStack, par2World, par3Entity, par4, par5); - if(par3Entity instanceof EntityPlayer) { - EntityPlayer player = (EntityPlayer) par3Entity; - PotionEffect haste = player.getActivePotionEffect(Potion.digSpeed); - float check = haste == null ? 0.16666667F : haste.getAmplifier() == 1 ? 0.5F : 0.4F; - - if(player.getCurrentEquippedItem() == par1ItemStack && player.swingProgress == check && !par2World.isRemote && par2World.rand.nextInt(2) == 0) { - EntityManaBurst burst = getBurst(player, par1ItemStack); - par2World.spawnEntityInWorld(burst); - ToolCommons.damageItem(par1ItemStack, 1, player, MANA_PER_DAMAGE); - par2World.playSoundAtEntity(player, "botania:terraBlade", 0.4F, 1.4F); - } - } - } - - @Override - public int getManaPerDamage() { - return MANA_PER_DAMAGE; - } - - public EntityManaBurst getBurst(EntityPlayer player, ItemStack stack) { - EntityManaBurst burst = new EntityManaBurst(player); - - float motionModifier = 7F; - - burst.setColor(0x20FF20); - burst.setMana(MANA_PER_DAMAGE); - burst.setStartingMana(MANA_PER_DAMAGE); - burst.setMinManaLoss(40); - burst.setManaLossPerTick(4F); - burst.setGravity(0F); - burst.setMotion(burst.motionX * motionModifier, burst.motionY * motionModifier, burst.motionZ * motionModifier); - - ItemStack lens = stack.copy(); - ItemNBTHelper.setString(lens, TAG_ATTACKER_USERNAME, player.getCommandSenderName()); - burst.setSourceLens(lens); - return burst; - } - - @Override - public void apply(ItemStack stack, BurstProperties props) { - // NO-OP - } - - @Override - public boolean collideBurst(IManaBurst burst, MovingObjectPosition pos, boolean isManaBlock, boolean dead, ItemStack stack) { - return dead; - } - - @Override - public void updateBurst(IManaBurst burst, ItemStack stack) { - EntityThrowable entity = (EntityThrowable) burst; - AxisAlignedBB axis = AxisAlignedBB.getBoundingBox(entity.posX, entity.posY, entity.posZ, entity.lastTickPosX, entity.lastTickPosY, entity.lastTickPosZ).expand(1, 1, 1); - List entities = entity.worldObj.getEntitiesWithinAABB(EntityLivingBase.class, axis); - String attacker = ItemNBTHelper.getString(burst.getSourceLens(), TAG_ATTACKER_USERNAME, ""); - - for(EntityLivingBase living : entities) { - if(living instanceof EntityPlayer && (((EntityPlayer) living).getCommandSenderName().equals(attacker) || MinecraftServer.getServer() != null && !MinecraftServer.getServer().isPVPEnabled())) - continue; - - if(living.hurtTime == 0) { - int cost = MANA_PER_DAMAGE / 3; - int mana = burst.getMana(); - if(mana >= cost) { - burst.setMana(mana - cost); - float damage = 4F + BotaniaAPI.terrasteelToolMaterial.getDamageVsEntity(); - if(!burst.isFake() && !entity.worldObj.isRemote) { - EntityPlayer player = living.worldObj.getPlayerEntityByName(attacker); - living.attackEntityFrom(player == null ? DamageSource.magic : DamageSource.causePlayerDamage(player), damage); - entity.setDead(); - break; - } - } - } - } - } - - @Override - public boolean doParticles(IManaBurst burst, ItemStack stack) { - return true; - } - - @Override - public boolean getIsRepairable(ItemStack par1ItemStack, ItemStack par2ItemStack) { - return par2ItemStack.getItem() == ModItems.manaResource && par2ItemStack.getItemDamage() == 4 ? true : super.getIsRepairable(par1ItemStack, par2ItemStack); - } - - @Override - public Achievement getAchievementOnCraft(ItemStack stack, EntityPlayer player, IInventory matrix) { - return ModAchievements.terrasteelWeaponCraft; - } - + private static final String TAG_ATTACKER_USERNAME = "attackerUsername"; + + private static final int MANA_PER_DAMAGE = 100; + + public ItemTerraSword() { + super(BotaniaAPI.terrasteelToolMaterial, LibItemNames.TERRA_SWORD); + } + + @Override + public void onUpdate(ItemStack par1ItemStack, World par2World, Entity par3Entity, int par4, boolean par5) { + super.onUpdate(par1ItemStack, par2World, par3Entity, par4, par5); + if (par3Entity instanceof EntityPlayer) { + EntityPlayer player = (EntityPlayer) par3Entity; + PotionEffect haste = player.getActivePotionEffect(Potion.digSpeed); + float check = haste == null ? 0.16666667F : haste.getAmplifier() == 1 ? 0.5F : 0.4F; + + if (player.getCurrentEquippedItem() == par1ItemStack + && player.swingProgress == check + && !par2World.isRemote + && par2World.rand.nextInt(2) == 0) { + EntityManaBurst burst = getBurst(player, par1ItemStack); + par2World.spawnEntityInWorld(burst); + ToolCommons.damageItem(par1ItemStack, 1, player, MANA_PER_DAMAGE); + par2World.playSoundAtEntity(player, "botania:terraBlade", 0.4F, 1.4F); + } + } + } + + @Override + public int getManaPerDamage() { + return MANA_PER_DAMAGE; + } + + public EntityManaBurst getBurst(EntityPlayer player, ItemStack stack) { + EntityManaBurst burst = new EntityManaBurst(player); + + float motionModifier = 7F; + + burst.setColor(0x20FF20); + burst.setMana(MANA_PER_DAMAGE); + burst.setStartingMana(MANA_PER_DAMAGE); + burst.setMinManaLoss(40); + burst.setManaLossPerTick(4F); + burst.setGravity(0F); + burst.setMotion(burst.motionX * motionModifier, burst.motionY * motionModifier, burst.motionZ * motionModifier); + + ItemStack lens = stack.copy(); + ItemNBTHelper.setString(lens, TAG_ATTACKER_USERNAME, player.getCommandSenderName()); + burst.setSourceLens(lens); + return burst; + } + + @Override + public void apply(ItemStack stack, BurstProperties props) { + // NO-OP + } + + @Override + public boolean collideBurst( + IManaBurst burst, MovingObjectPosition pos, boolean isManaBlock, boolean dead, ItemStack stack) { + return dead; + } + + @Override + public void updateBurst(IManaBurst burst, ItemStack stack) { + EntityThrowable entity = (EntityThrowable) burst; + AxisAlignedBB axis = AxisAlignedBB.getBoundingBox( + entity.posX, + entity.posY, + entity.posZ, + entity.lastTickPosX, + entity.lastTickPosY, + entity.lastTickPosZ) + .expand(1, 1, 1); + List entities = entity.worldObj.getEntitiesWithinAABB(EntityLivingBase.class, axis); + String attacker = ItemNBTHelper.getString(burst.getSourceLens(), TAG_ATTACKER_USERNAME, ""); + + for (EntityLivingBase living : entities) { + if (living instanceof EntityPlayer + && (((EntityPlayer) living).getCommandSenderName().equals(attacker) + || MinecraftServer.getServer() != null + && !MinecraftServer.getServer().isPVPEnabled())) continue; + + if (living.hurtTime == 0) { + int cost = MANA_PER_DAMAGE / 3; + int mana = burst.getMana(); + if (mana >= cost) { + burst.setMana(mana - cost); + float damage = 4F + BotaniaAPI.terrasteelToolMaterial.getDamageVsEntity(); + if (!burst.isFake() && !entity.worldObj.isRemote) { + EntityPlayer player = living.worldObj.getPlayerEntityByName(attacker); + living.attackEntityFrom( + player == null ? DamageSource.magic : DamageSource.causePlayerDamage(player), damage); + entity.setDead(); + break; + } + } + } + } + } + + @Override + public boolean doParticles(IManaBurst burst, ItemStack stack) { + return true; + } + + @Override + public boolean getIsRepairable(ItemStack par1ItemStack, ItemStack par2ItemStack) { + return par2ItemStack.getItem() == ModItems.manaResource && par2ItemStack.getItemDamage() == 4 + ? true + : super.getIsRepairable(par1ItemStack, par2ItemStack); + } + + @Override + public Achievement getAchievementOnCraft(ItemStack stack, EntityPlayer player, IInventory matrix) { + return ModAchievements.terrasteelWeaponCraft; + } } diff --git a/src/main/java/vazkii/botania/common/item/interaction/thaumcraft/ItemElementiumHelmRevealing.java b/src/main/java/vazkii/botania/common/item/interaction/thaumcraft/ItemElementiumHelmRevealing.java index 7fdb8e56c3..f47eae9e58 100644 --- a/src/main/java/vazkii/botania/common/item/interaction/thaumcraft/ItemElementiumHelmRevealing.java +++ b/src/main/java/vazkii/botania/common/item/interaction/thaumcraft/ItemElementiumHelmRevealing.java @@ -2,14 +2,15 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jul 28, 2014, 6:16:24 PM (GMT)] */ package vazkii.botania.common.item.interaction.thaumcraft; +import cpw.mods.fml.common.Optional; import net.minecraft.entity.EntityLivingBase; import net.minecraft.item.ItemStack; import thaumcraft.api.IGoggles; @@ -18,30 +19,29 @@ import vazkii.botania.common.core.handler.ConfigHandler; import vazkii.botania.common.item.equipment.armor.elementium.ItemElementiumHelm; import vazkii.botania.common.lib.LibItemNames; -import cpw.mods.fml.common.Optional; @Optional.InterfaceList({ - @Optional.Interface(modid = "Thaumcraft", iface = "thaumcraft.api.IGoggles", striprefs = true), - @Optional.Interface(modid = "Thaumcraft", iface = "thaumcraft.api.nodes.IRevealer", striprefs = true)}) + @Optional.Interface(modid = "Thaumcraft", iface = "thaumcraft.api.IGoggles", striprefs = true), + @Optional.Interface(modid = "Thaumcraft", iface = "thaumcraft.api.nodes.IRevealer", striprefs = true) +}) public class ItemElementiumHelmRevealing extends ItemElementiumHelm implements IGoggles, IRevealer { - public ItemElementiumHelmRevealing() { - super(LibItemNames.ELEMENTIUM_HELM_R); - } - - @Override - public boolean showNodes(ItemStack itemstack, EntityLivingBase player) { - return true; - } + public ItemElementiumHelmRevealing() { + super(LibItemNames.ELEMENTIUM_HELM_R); + } - @Override - public boolean showIngamePopups(ItemStack itemstack, EntityLivingBase player) { - return true; - } + @Override + public boolean showNodes(ItemStack itemstack, EntityLivingBase player) { + return true; + } - @Override - public String getArmorTextureAfterInk(ItemStack stack, int slot) { - return ConfigHandler.enableArmorModels ? LibResources.MODEL_ELEMENTIUM_NEW : LibResources.MODEL_ELEMENTIUM_2; - } + @Override + public boolean showIngamePopups(ItemStack itemstack, EntityLivingBase player) { + return true; + } + @Override + public String getArmorTextureAfterInk(ItemStack stack, int slot) { + return ConfigHandler.enableArmorModels ? LibResources.MODEL_ELEMENTIUM_NEW : LibResources.MODEL_ELEMENTIUM_2; + } } diff --git a/src/main/java/vazkii/botania/common/item/interaction/thaumcraft/ItemManaInkwell.java b/src/main/java/vazkii/botania/common/item/interaction/thaumcraft/ItemManaInkwell.java index b7c1cea9f6..28740d4b1f 100644 --- a/src/main/java/vazkii/botania/common/item/interaction/thaumcraft/ItemManaInkwell.java +++ b/src/main/java/vazkii/botania/common/item/interaction/thaumcraft/ItemManaInkwell.java @@ -2,16 +2,16 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Sep 26, 2014, 5:39:07 PM (GMT)] */ package vazkii.botania.common.item.interaction.thaumcraft; +import cpw.mods.fml.common.Optional; import java.util.List; - import net.minecraft.creativetab.CreativeTabs; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; @@ -22,103 +22,101 @@ import vazkii.botania.common.core.helper.ItemNBTHelper; import vazkii.botania.common.item.ItemMod; import vazkii.botania.common.lib.LibItemNames; -import cpw.mods.fml.common.Optional; @Optional.Interface(modid = "Thaumcraft", iface = "thaumcraft.api.IScribeTools") public class ItemManaInkwell extends ItemMod implements IManaItem, IScribeTools { - private static final int COST_PER_USE = 50; - private static final int USES = 150; - protected static final int MAX_MANA = COST_PER_USE * USES; - - private static final String TAG_MANA = "mana"; - - public ItemManaInkwell() { - setUnlocalizedName(LibItemNames.MANA_INKWELL); - setMaxDamage(USES); - setMaxStackSize(1); - setNoRepair(); - } - - @Override - public void getSubItems(Item item, CreativeTabs tab, List list) { - list.add(new ItemStack(item, 1, USES)); - list.add(new ItemStack(item)); - } - - @Override - public int getDamage(ItemStack stack) { - float mana = getMana(stack); - return USES - (int) (mana / getMaxMana(stack) * USES); - } - - @Override - public void setDamage(ItemStack stack, int damage) { - int currentDamage = stack.getItemDamage(); - if(damage > currentDamage) { - int cost = (damage - currentDamage) * COST_PER_USE; - int mana = getMana(stack); - if(mana >= cost) { - addMana(stack, -cost); - return; - } - } - super.setDamage(stack, damage); - } - - @Override - public int getDisplayDamage(ItemStack stack) { - return getDamage(stack); - } - - @Override - public int getEntityLifespan(ItemStack itemStack, World world) { - return Integer.MAX_VALUE; - } - - public static void setMana(ItemStack stack, int mana) { - ItemNBTHelper.setInt(stack, TAG_MANA, mana); - } - - @Override - public int getMana(ItemStack stack) { - return ItemNBTHelper.getInt(stack, TAG_MANA, 0); - } - - @Override - public int getMaxMana(ItemStack stack) { - return MAX_MANA; - } - - @Override - public void addMana(ItemStack stack, int mana) { - setMana(stack, Math.min(getMana(stack) + mana, getMaxMana(stack))); - stack.setItemDamage(getDamage(stack)); - } - - @Override - public boolean canReceiveManaFromPool(ItemStack stack, TileEntity pool) { - return true; - } - - @Override - public boolean canReceiveManaFromItem(ItemStack stack, ItemStack otherStack) { - return false; - } - - @Override - public boolean canExportManaToPool(ItemStack stack, TileEntity pool) { - return false; - } - - @Override - public boolean canExportManaToItem(ItemStack stack, ItemStack otherStack) { - return false; - } - - @Override - public boolean isNoExport(ItemStack stack) { - return true; - } - + private static final int COST_PER_USE = 50; + private static final int USES = 150; + protected static final int MAX_MANA = COST_PER_USE * USES; + + private static final String TAG_MANA = "mana"; + + public ItemManaInkwell() { + setUnlocalizedName(LibItemNames.MANA_INKWELL); + setMaxDamage(USES); + setMaxStackSize(1); + setNoRepair(); + } + + @Override + public void getSubItems(Item item, CreativeTabs tab, List list) { + list.add(new ItemStack(item, 1, USES)); + list.add(new ItemStack(item)); + } + + @Override + public int getDamage(ItemStack stack) { + float mana = getMana(stack); + return USES - (int) (mana / getMaxMana(stack) * USES); + } + + @Override + public void setDamage(ItemStack stack, int damage) { + int currentDamage = stack.getItemDamage(); + if (damage > currentDamage) { + int cost = (damage - currentDamage) * COST_PER_USE; + int mana = getMana(stack); + if (mana >= cost) { + addMana(stack, -cost); + return; + } + } + super.setDamage(stack, damage); + } + + @Override + public int getDisplayDamage(ItemStack stack) { + return getDamage(stack); + } + + @Override + public int getEntityLifespan(ItemStack itemStack, World world) { + return Integer.MAX_VALUE; + } + + public static void setMana(ItemStack stack, int mana) { + ItemNBTHelper.setInt(stack, TAG_MANA, mana); + } + + @Override + public int getMana(ItemStack stack) { + return ItemNBTHelper.getInt(stack, TAG_MANA, 0); + } + + @Override + public int getMaxMana(ItemStack stack) { + return MAX_MANA; + } + + @Override + public void addMana(ItemStack stack, int mana) { + setMana(stack, Math.min(getMana(stack) + mana, getMaxMana(stack))); + stack.setItemDamage(getDamage(stack)); + } + + @Override + public boolean canReceiveManaFromPool(ItemStack stack, TileEntity pool) { + return true; + } + + @Override + public boolean canReceiveManaFromItem(ItemStack stack, ItemStack otherStack) { + return false; + } + + @Override + public boolean canExportManaToPool(ItemStack stack, TileEntity pool) { + return false; + } + + @Override + public boolean canExportManaToItem(ItemStack stack, ItemStack otherStack) { + return false; + } + + @Override + public boolean isNoExport(ItemStack stack) { + return true; + } } diff --git a/src/main/java/vazkii/botania/common/item/interaction/thaumcraft/ItemManasteelHelmRevealing.java b/src/main/java/vazkii/botania/common/item/interaction/thaumcraft/ItemManasteelHelmRevealing.java index dd9b80dea8..e36c476404 100644 --- a/src/main/java/vazkii/botania/common/item/interaction/thaumcraft/ItemManasteelHelmRevealing.java +++ b/src/main/java/vazkii/botania/common/item/interaction/thaumcraft/ItemManasteelHelmRevealing.java @@ -2,14 +2,16 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jul 28, 2014, 6:18:05 PM (GMT)] */ package vazkii.botania.common.item.interaction.thaumcraft; +import cpw.mods.fml.common.Optional; +import cpw.mods.fml.common.registry.GameRegistry; import net.minecraft.entity.EntityLivingBase; import net.minecraft.item.ItemStack; import net.minecraftforge.oredict.RecipeSorter; @@ -21,33 +23,33 @@ import vazkii.botania.common.crafting.recipe.HelmRevealingRecipe; import vazkii.botania.common.item.equipment.armor.manasteel.ItemManasteelHelm; import vazkii.botania.common.lib.LibItemNames; -import cpw.mods.fml.common.Optional; -import cpw.mods.fml.common.registry.GameRegistry; @Optional.InterfaceList({ - @Optional.Interface(modid = "Thaumcraft", iface = "thaumcraft.api.IGoggles", striprefs = true), - @Optional.Interface(modid = "Thaumcraft", iface = "thaumcraft.api.nodes.IRevealer", striprefs = true)}) + @Optional.Interface(modid = "Thaumcraft", iface = "thaumcraft.api.IGoggles", striprefs = true), + @Optional.Interface(modid = "Thaumcraft", iface = "thaumcraft.api.nodes.IRevealer", striprefs = true) +}) public class ItemManasteelHelmRevealing extends ItemManasteelHelm implements IGoggles, IRevealer { - public ItemManasteelHelmRevealing() { - super(LibItemNames.MANASTEEL_HELM_R); - GameRegistry.addRecipe(new HelmRevealingRecipe()); //Manasteel is the base so it gets the recipe added in its constructor so that ModItems can call it - RecipeSorter.register("botania:helmRevealing", HelmRevealingRecipe.class, Category.SHAPELESS, ""); - } - - @Override - public boolean showNodes(ItemStack itemstack, EntityLivingBase player) { - return true; - } + public ItemManasteelHelmRevealing() { + super(LibItemNames.MANASTEEL_HELM_R); + GameRegistry.addRecipe( + new HelmRevealingRecipe()); // Manasteel is the base so it gets the recipe added in its constructor so + // that ModItems can call it + RecipeSorter.register("botania:helmRevealing", HelmRevealingRecipe.class, Category.SHAPELESS, ""); + } - @Override - public boolean showIngamePopups(ItemStack itemstack, EntityLivingBase player) { - return true; - } + @Override + public boolean showNodes(ItemStack itemstack, EntityLivingBase player) { + return true; + } - @Override - public String getArmorTextureAfterInk(ItemStack stack, int slot) { - return ConfigHandler.enableArmorModels ? LibResources.MODEL_MANASTEEL_NEW : LibResources.MODEL_MANASTEEL_2; - } + @Override + public boolean showIngamePopups(ItemStack itemstack, EntityLivingBase player) { + return true; + } -} \ No newline at end of file + @Override + public String getArmorTextureAfterInk(ItemStack stack, int slot) { + return ConfigHandler.enableArmorModels ? LibResources.MODEL_MANASTEEL_NEW : LibResources.MODEL_MANASTEEL_2; + } +} diff --git a/src/main/java/vazkii/botania/common/item/interaction/thaumcraft/ItemTerrasteelHelmRevealing.java b/src/main/java/vazkii/botania/common/item/interaction/thaumcraft/ItemTerrasteelHelmRevealing.java index c266bfad02..9634961dbb 100644 --- a/src/main/java/vazkii/botania/common/item/interaction/thaumcraft/ItemTerrasteelHelmRevealing.java +++ b/src/main/java/vazkii/botania/common/item/interaction/thaumcraft/ItemTerrasteelHelmRevealing.java @@ -2,14 +2,15 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jul 28, 2014, 6:22:51 PM (GMT)] */ package vazkii.botania.common.item.interaction.thaumcraft; +import cpw.mods.fml.common.Optional; import net.minecraft.entity.EntityLivingBase; import net.minecraft.item.ItemStack; import thaumcraft.api.IGoggles; @@ -18,30 +19,29 @@ import vazkii.botania.common.core.handler.ConfigHandler; import vazkii.botania.common.item.equipment.armor.terrasteel.ItemTerrasteelHelm; import vazkii.botania.common.lib.LibItemNames; -import cpw.mods.fml.common.Optional; @Optional.InterfaceList({ - @Optional.Interface(modid = "Thaumcraft", iface = "thaumcraft.api.IGoggles", striprefs = true), - @Optional.Interface(modid = "Thaumcraft", iface = "thaumcraft.api.nodes.IRevealer", striprefs = true)}) + @Optional.Interface(modid = "Thaumcraft", iface = "thaumcraft.api.IGoggles", striprefs = true), + @Optional.Interface(modid = "Thaumcraft", iface = "thaumcraft.api.nodes.IRevealer", striprefs = true) +}) public class ItemTerrasteelHelmRevealing extends ItemTerrasteelHelm implements IGoggles, IRevealer { - public ItemTerrasteelHelmRevealing() { - super(LibItemNames.TERRASTEEL_HELM_R); - } - - @Override - public boolean showNodes(ItemStack itemstack, EntityLivingBase player) { - return true; - } + public ItemTerrasteelHelmRevealing() { + super(LibItemNames.TERRASTEEL_HELM_R); + } - @Override - public boolean showIngamePopups(ItemStack itemstack, EntityLivingBase player) { - return true; - } + @Override + public boolean showNodes(ItemStack itemstack, EntityLivingBase player) { + return true; + } - @Override - public String getArmorTextureAfterInk(ItemStack stack, int slot) { - return ConfigHandler.enableArmorModels ? LibResources.MODEL_TERRASTEEL_NEW : LibResources.MODEL_TERRASTEEL_2; - } + @Override + public boolean showIngamePopups(ItemStack itemstack, EntityLivingBase player) { + return true; + } -} \ No newline at end of file + @Override + public String getArmorTextureAfterInk(ItemStack stack, int slot) { + return ConfigHandler.enableArmorModels ? LibResources.MODEL_TERRASTEEL_NEW : LibResources.MODEL_TERRASTEEL_2; + } +} diff --git a/src/main/java/vazkii/botania/common/item/lens/ItemLens.java b/src/main/java/vazkii/botania/common/item/lens/ItemLens.java index 5c58ed735d..335cbcda8a 100644 --- a/src/main/java/vazkii/botania/common/item/lens/ItemLens.java +++ b/src/main/java/vazkii/botania/common/item/lens/ItemLens.java @@ -2,17 +2,17 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jan 31, 2014, 3:02:58 PM (GMT)] */ package vazkii.botania.common.item.lens; +import cpw.mods.fml.common.registry.GameRegistry; import java.awt.Color; import java.util.List; - import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.entity.passive.EntitySheep; @@ -40,332 +40,327 @@ import vazkii.botania.common.crafting.recipe.LensDyeingRecipe; import vazkii.botania.common.item.ItemMod; import vazkii.botania.common.lib.LibItemNames; -import cpw.mods.fml.common.registry.GameRegistry; public class ItemLens extends ItemMod implements ILensControl, ICompositableLens, ITinyPlanetExcempt { - public static final int SUBTYPES = 22; - - public static final int NORMAL = 0, - SPEED = 1, - POWER = 2, - TIME = 3, - EFFICIENCY = 4, - BOUNCE = 5, - GRAVITY = 6, - MINE = 7, - DAMAGE = 8, - PHANTOM = 9, - MAGNET = 10, - EXPLOSIVE = 11, - INFLUENCE = 12, - WEIGHT = 13, - PAINT = 14, - FIRE = 15, - PISTON = 16, - LIGHT = 17, - WARP = 18, - REDIRECT = 19, - FIREWORK = 20, - FLARE = 21; - - public static final int STORM = 5000; - - private static final int PROP_NONE = 0, - PROP_POWER = 1, - PROP_ORIENTATION = 1 << 1, - PROP_TOUCH = 1 << 2, - PROP_INTERACTION = 1 << 3, - PROP_DAMAGE = 1 << 4, - PROP_CONTROL = 1 << 5; - - private static final int[] props = new int[SUBTYPES]; - private static final Lens[] lenses = new Lens[SUBTYPES]; - private static Lens fallbackLens = new Lens(); - private static Lens stormLens = new LensStorm(); - - static { - setProps(NORMAL, PROP_NONE); - setProps(SPEED, PROP_NONE); - setProps(POWER, PROP_POWER); - setProps(TIME, PROP_NONE); - setProps(EFFICIENCY, PROP_NONE); - setProps(BOUNCE, PROP_TOUCH); - setProps(GRAVITY, PROP_ORIENTATION); - setProps(MINE, PROP_TOUCH | PROP_INTERACTION); - setProps(DAMAGE, PROP_DAMAGE); - setProps(PHANTOM, PROP_TOUCH); - setProps(MAGNET, PROP_ORIENTATION); - setProps(EXPLOSIVE, PROP_DAMAGE | PROP_TOUCH | PROP_INTERACTION); - setProps(INFLUENCE, PROP_NONE); - setProps(WEIGHT, PROP_TOUCH | PROP_INTERACTION); - setProps(PAINT, PROP_TOUCH | PROP_INTERACTION); - setProps(FIRE, PROP_DAMAGE | PROP_TOUCH | PROP_INTERACTION); - setProps(PISTON, PROP_TOUCH | PROP_INTERACTION); - setProps(LIGHT, PROP_TOUCH | PROP_INTERACTION); - setProps(WARP, PROP_NONE); - setProps(REDIRECT, PROP_TOUCH | PROP_INTERACTION); - setProps(FIREWORK, PROP_TOUCH); - setProps(FLARE, PROP_CONTROL); - - setLens(NORMAL, fallbackLens); - setLens(SPEED, new LensSpeed()); - setLens(POWER, new LensPower()); - setLens(TIME, new LensTime()); - setLens(EFFICIENCY, new LensEfficiency()); - setLens(BOUNCE, new LensBounce()); - setLens(GRAVITY, new LensGravity()); - setLens(MINE, new LensMine()); - setLens(DAMAGE, new LensDamage()); - setLens(PHANTOM, new LensPhantom()); - setLens(MAGNET, new LensMagnet()); - setLens(EXPLOSIVE, new LensExplosive()); - setLens(INFLUENCE, new LensInfluence()); - setLens(WEIGHT, new LensWeight()); - setLens(PAINT, new LensPaint()); - setLens(FIRE, new LensFire()); - setLens(PISTON, new LensPiston()); - setLens(LIGHT, new LensLight()); - setLens(WARP, new LensWarp()); - setLens(REDIRECT, new LensRedirect()); - setLens(FIREWORK, new LensFirework()); - setLens(FLARE, new LensFlare()); - } - - private static final String TAG_COLOR = "color"; - private static final String TAG_COMPOSITE_LENS = "compositeLens"; - - public static IIcon iconGlass; - - IIcon[] ringIcons; - - public ItemLens() { - super(); - setUnlocalizedName(LibItemNames.LENS); - setMaxStackSize(1); - setHasSubtypes(true); - - GameRegistry.addRecipe(new CompositeLensRecipe()); - GameRegistry.addRecipe(new LensDyeingRecipe()); - RecipeSorter.register("botania:compositeLens", CompositeLensRecipe.class, Category.SHAPELESS, ""); - RecipeSorter.register("botania:lensDying", LensDyeingRecipe.class, Category.SHAPELESS, ""); - } - - @Override - public void registerIcons(IIconRegister par1IconRegister) { - iconGlass = IconHelper.forName(par1IconRegister, "lensInside"); - - ringIcons = new IIcon[SUBTYPES]; - for(int i = 0; i < ringIcons.length; i++) - ringIcons[i] = IconHelper.forName(par1IconRegister, LibItemNames.LENS_NAMES[i]); - } - - @Override - public void getSubItems(Item par1, CreativeTabs par2CreativeTabs, List par3List) { - for(int i = 0; i < SUBTYPES; i++) - par3List.add(new ItemStack(par1, 1, i)); - } - - @Override - public boolean requiresMultipleRenderPasses() { - return true; - } - - @Override - public IIcon getIconFromDamageForRenderPass(int par1, int par2) { - return par2 == 1 ? ringIcons[Math.min(SUBTYPES - 1, par1)] : iconGlass; - } - - @Override - public IIcon getIconFromDamage(int par1) { - return getIconFromDamageForRenderPass(par1, 0); - } - - @Override - public int getColorFromItemStack(ItemStack par1ItemStack, int par2) { - return par2 == 0 ? getLensColor(par1ItemStack) : 0xFFFFFF; - } - - @Override - public String getUnlocalizedName(ItemStack par1ItemStack) { - return "item." + LibItemNames.LENS_NAMES[Math.min(SUBTYPES - 1, par1ItemStack.getItemDamage())]; - } - - @Override - public void addInformation(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, List par3List, boolean par4) { - int storedColor = getStoredColor(par1ItemStack); - if(storedColor != -1) - par3List.add(String.format(StatCollector.translateToLocal("botaniamisc.color"), StatCollector.translateToLocal("botania.color" + storedColor))); - } - - - public String getItemShortTermName(ItemStack stack) { - return StatCollector.translateToLocal(stack.getUnlocalizedName().replaceAll("item.", "item.botania:") + ".short"); - } - - @Override - public String getItemStackDisplayName(ItemStack stack) { - ItemStack compositeLens = getCompositeLens(stack); - if(compositeLens == null) - return super.getItemStackDisplayName(stack); - return String.format(StatCollector.translateToLocal("item.botania:compositeLens.name"), getItemShortTermName(stack), getItemShortTermName(compositeLens)); - } - - @Override - public void apply(ItemStack stack, BurstProperties props) { - int storedColor = getStoredColor(stack); - if(storedColor != -1) - props.color = getLensColor(stack); - - getLens(stack.getItemDamage()).apply(stack, props); - - ItemStack compositeLens = getCompositeLens(stack); - if(compositeLens != null && compositeLens.getItem() instanceof ILens) - ((ILens) compositeLens.getItem()).apply(compositeLens, props); - } - - @Override - public boolean collideBurst(IManaBurst burst, MovingObjectPosition pos, boolean isManaBlock, boolean dead, ItemStack stack) { - EntityThrowable entity = (EntityThrowable) burst; - - dead = getLens(stack.getItemDamage()).collideBurst(burst, entity, pos, isManaBlock, dead, stack); - - ItemStack compositeLens = getCompositeLens(stack); - if(compositeLens != null && compositeLens.getItem() instanceof ILens) - dead = ((ILens) compositeLens.getItem()).collideBurst(burst, pos, isManaBlock, dead, compositeLens); - - return dead; - } - - @Override - public void updateBurst(IManaBurst burst, ItemStack stack) { - EntityThrowable entity = (EntityThrowable) burst; - int storedColor = getStoredColor(stack); - - if(storedColor == 16 && entity.worldObj.isRemote) - burst.setColor(getLensColor(stack)); - - getLens(stack.getItemDamage()).updateBurst(burst, entity, stack); - - ItemStack compositeLens = getCompositeLens(stack); - if(compositeLens != null && compositeLens.getItem() instanceof ILens) - ((ILens) compositeLens.getItem()).updateBurst(burst, compositeLens); - } - - @Override - public int getLensColor(ItemStack stack) { - int storedColor = getStoredColor(stack); - - if(storedColor == -1) - return 0xFFFFFF; - - if(storedColor == 16) - return Color.HSBtoRGB(Botania.proxy.getWorldElapsedTicks() * 2 % 360 / 360F, 1F, 1F); - - float[] color = EntitySheep.fleeceColorTable[storedColor]; - return new Color(color[0], color[1], color[2]).getRGB(); - } - - public static int getStoredColor(ItemStack stack) { - return ItemNBTHelper.getInt(stack, TAG_COLOR, -1); - } - - public static ItemStack setLensColor(ItemStack stack, int color) { - ItemNBTHelper.setInt(stack, TAG_COLOR, color); - return stack; - } - - @Override - public boolean doParticles(IManaBurst burst, ItemStack stack) { - return true; - } - - public static void setProps(int lens, int props_) { - props[lens] = props_; - } - - public static void setLens(int index, Lens lens) { - lenses[index] = lens; - } - - public static boolean isBlacklisted(ItemStack lens1, ItemStack lens2) { - ICompositableLens item1 = (ICompositableLens) lens1.getItem(); - ICompositableLens item2 = (ICompositableLens) lens2.getItem(); - return (item1.getProps(lens1) & item2.getProps(lens2)) != 0; - } - - public static Lens getLens(int index) { - if(index == STORM) - return stormLens; - - Lens lens = lenses[index]; - return lens == null ? fallbackLens : lens; - } - - @Override - public boolean canCombineLenses(ItemStack sourceLens, ItemStack compositeLens) { - ICompositableLens sourceItem = (ICompositableLens) sourceLens.getItem(); - ICompositableLens compositeItem = (ICompositableLens) compositeLens.getItem(); - if(sourceItem == compositeItem && sourceLens.getItemDamage() == compositeLens.getItemDamage()) - return false; - - if(!sourceItem.isCombinable(sourceLens) || !compositeItem.isCombinable(compositeLens)) - return false; - - if(isBlacklisted(sourceLens, compositeLens)) - return false; - - return true; - } - - @Override - public ItemStack getCompositeLens(ItemStack stack) { - NBTTagCompound cmp = ItemNBTHelper.getCompound(stack, TAG_COMPOSITE_LENS, false); - ItemStack lens = ItemStack.loadItemStackFromNBT(cmp); - return lens; - } - - @Override - public ItemStack setCompositeLens(ItemStack sourceLens, ItemStack compositeLens) { - NBTTagCompound cmp = new NBTTagCompound(); - compositeLens.writeToNBT(cmp); - ItemNBTHelper.setCompound(sourceLens, TAG_COMPOSITE_LENS, cmp); - - return sourceLens; - } - - @Override - public boolean shouldPull(ItemStack stack) { - return stack.getItemDamage() != STORM; - } - - @Override - public boolean isControlLens(ItemStack stack) { - return (getProps(stack) & PROP_CONTROL) != 0; - } - - @Override - public boolean allowBurstShooting(ItemStack stack, IManaSpreader spreader, boolean redstone) { - return lenses[stack.getItemDamage()].allowBurstShooting(stack, spreader, redstone); - } - - @Override - public void onControlledSpreaderTick(ItemStack stack, IManaSpreader spreader, boolean redstone) { - lenses[stack.getItemDamage()].onControlledSpreaderTick(stack, spreader, redstone); - } - - @Override - public void onControlledSpreaderPulse(ItemStack stack, IManaSpreader spreader, boolean redstone) { - lenses[stack.getItemDamage()].onControlledSpreaderPulse(stack, spreader, redstone); - } - - @Override - public int getProps(ItemStack stack) { - return props[stack.getItemDamage()]; - } - - @Override - public boolean isCombinable(ItemStack stack) { - return stack.getItemDamage() != NORMAL; - } + public static final int SUBTYPES = 22; + + public static final int NORMAL = 0, + SPEED = 1, + POWER = 2, + TIME = 3, + EFFICIENCY = 4, + BOUNCE = 5, + GRAVITY = 6, + MINE = 7, + DAMAGE = 8, + PHANTOM = 9, + MAGNET = 10, + EXPLOSIVE = 11, + INFLUENCE = 12, + WEIGHT = 13, + PAINT = 14, + FIRE = 15, + PISTON = 16, + LIGHT = 17, + WARP = 18, + REDIRECT = 19, + FIREWORK = 20, + FLARE = 21; + + public static final int STORM = 5000; + + private static final int PROP_NONE = 0, + PROP_POWER = 1, + PROP_ORIENTATION = 1 << 1, + PROP_TOUCH = 1 << 2, + PROP_INTERACTION = 1 << 3, + PROP_DAMAGE = 1 << 4, + PROP_CONTROL = 1 << 5; + + private static final int[] props = new int[SUBTYPES]; + private static final Lens[] lenses = new Lens[SUBTYPES]; + private static Lens fallbackLens = new Lens(); + private static Lens stormLens = new LensStorm(); + + static { + setProps(NORMAL, PROP_NONE); + setProps(SPEED, PROP_NONE); + setProps(POWER, PROP_POWER); + setProps(TIME, PROP_NONE); + setProps(EFFICIENCY, PROP_NONE); + setProps(BOUNCE, PROP_TOUCH); + setProps(GRAVITY, PROP_ORIENTATION); + setProps(MINE, PROP_TOUCH | PROP_INTERACTION); + setProps(DAMAGE, PROP_DAMAGE); + setProps(PHANTOM, PROP_TOUCH); + setProps(MAGNET, PROP_ORIENTATION); + setProps(EXPLOSIVE, PROP_DAMAGE | PROP_TOUCH | PROP_INTERACTION); + setProps(INFLUENCE, PROP_NONE); + setProps(WEIGHT, PROP_TOUCH | PROP_INTERACTION); + setProps(PAINT, PROP_TOUCH | PROP_INTERACTION); + setProps(FIRE, PROP_DAMAGE | PROP_TOUCH | PROP_INTERACTION); + setProps(PISTON, PROP_TOUCH | PROP_INTERACTION); + setProps(LIGHT, PROP_TOUCH | PROP_INTERACTION); + setProps(WARP, PROP_NONE); + setProps(REDIRECT, PROP_TOUCH | PROP_INTERACTION); + setProps(FIREWORK, PROP_TOUCH); + setProps(FLARE, PROP_CONTROL); + + setLens(NORMAL, fallbackLens); + setLens(SPEED, new LensSpeed()); + setLens(POWER, new LensPower()); + setLens(TIME, new LensTime()); + setLens(EFFICIENCY, new LensEfficiency()); + setLens(BOUNCE, new LensBounce()); + setLens(GRAVITY, new LensGravity()); + setLens(MINE, new LensMine()); + setLens(DAMAGE, new LensDamage()); + setLens(PHANTOM, new LensPhantom()); + setLens(MAGNET, new LensMagnet()); + setLens(EXPLOSIVE, new LensExplosive()); + setLens(INFLUENCE, new LensInfluence()); + setLens(WEIGHT, new LensWeight()); + setLens(PAINT, new LensPaint()); + setLens(FIRE, new LensFire()); + setLens(PISTON, new LensPiston()); + setLens(LIGHT, new LensLight()); + setLens(WARP, new LensWarp()); + setLens(REDIRECT, new LensRedirect()); + setLens(FIREWORK, new LensFirework()); + setLens(FLARE, new LensFlare()); + } + + private static final String TAG_COLOR = "color"; + private static final String TAG_COMPOSITE_LENS = "compositeLens"; + + public static IIcon iconGlass; + + IIcon[] ringIcons; + + public ItemLens() { + super(); + setUnlocalizedName(LibItemNames.LENS); + setMaxStackSize(1); + setHasSubtypes(true); + + GameRegistry.addRecipe(new CompositeLensRecipe()); + GameRegistry.addRecipe(new LensDyeingRecipe()); + RecipeSorter.register("botania:compositeLens", CompositeLensRecipe.class, Category.SHAPELESS, ""); + RecipeSorter.register("botania:lensDying", LensDyeingRecipe.class, Category.SHAPELESS, ""); + } + + @Override + public void registerIcons(IIconRegister par1IconRegister) { + iconGlass = IconHelper.forName(par1IconRegister, "lensInside"); + + ringIcons = new IIcon[SUBTYPES]; + for (int i = 0; i < ringIcons.length; i++) + ringIcons[i] = IconHelper.forName(par1IconRegister, LibItemNames.LENS_NAMES[i]); + } + + @Override + public void getSubItems(Item par1, CreativeTabs par2CreativeTabs, List par3List) { + for (int i = 0; i < SUBTYPES; i++) par3List.add(new ItemStack(par1, 1, i)); + } + + @Override + public boolean requiresMultipleRenderPasses() { + return true; + } + + @Override + public IIcon getIconFromDamageForRenderPass(int par1, int par2) { + return par2 == 1 ? ringIcons[Math.min(SUBTYPES - 1, par1)] : iconGlass; + } + + @Override + public IIcon getIconFromDamage(int par1) { + return getIconFromDamageForRenderPass(par1, 0); + } + + @Override + public int getColorFromItemStack(ItemStack par1ItemStack, int par2) { + return par2 == 0 ? getLensColor(par1ItemStack) : 0xFFFFFF; + } + + @Override + public String getUnlocalizedName(ItemStack par1ItemStack) { + return "item." + LibItemNames.LENS_NAMES[Math.min(SUBTYPES - 1, par1ItemStack.getItemDamage())]; + } + + @Override + public void addInformation(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, List par3List, boolean par4) { + int storedColor = getStoredColor(par1ItemStack); + if (storedColor != -1) + par3List.add(String.format( + StatCollector.translateToLocal("botaniamisc.color"), + StatCollector.translateToLocal("botania.color" + storedColor))); + } + + public String getItemShortTermName(ItemStack stack) { + return StatCollector.translateToLocal( + stack.getUnlocalizedName().replaceAll("item.", "item.botania:") + ".short"); + } + + @Override + public String getItemStackDisplayName(ItemStack stack) { + ItemStack compositeLens = getCompositeLens(stack); + if (compositeLens == null) return super.getItemStackDisplayName(stack); + return String.format( + StatCollector.translateToLocal("item.botania:compositeLens.name"), + getItemShortTermName(stack), + getItemShortTermName(compositeLens)); + } + + @Override + public void apply(ItemStack stack, BurstProperties props) { + int storedColor = getStoredColor(stack); + if (storedColor != -1) props.color = getLensColor(stack); + + getLens(stack.getItemDamage()).apply(stack, props); + + ItemStack compositeLens = getCompositeLens(stack); + if (compositeLens != null && compositeLens.getItem() instanceof ILens) + ((ILens) compositeLens.getItem()).apply(compositeLens, props); + } + + @Override + public boolean collideBurst( + IManaBurst burst, MovingObjectPosition pos, boolean isManaBlock, boolean dead, ItemStack stack) { + EntityThrowable entity = (EntityThrowable) burst; + + dead = getLens(stack.getItemDamage()).collideBurst(burst, entity, pos, isManaBlock, dead, stack); + + ItemStack compositeLens = getCompositeLens(stack); + if (compositeLens != null && compositeLens.getItem() instanceof ILens) + dead = ((ILens) compositeLens.getItem()).collideBurst(burst, pos, isManaBlock, dead, compositeLens); + + return dead; + } + + @Override + public void updateBurst(IManaBurst burst, ItemStack stack) { + EntityThrowable entity = (EntityThrowable) burst; + int storedColor = getStoredColor(stack); + + if (storedColor == 16 && entity.worldObj.isRemote) burst.setColor(getLensColor(stack)); + + getLens(stack.getItemDamage()).updateBurst(burst, entity, stack); + + ItemStack compositeLens = getCompositeLens(stack); + if (compositeLens != null && compositeLens.getItem() instanceof ILens) + ((ILens) compositeLens.getItem()).updateBurst(burst, compositeLens); + } + + @Override + public int getLensColor(ItemStack stack) { + int storedColor = getStoredColor(stack); + + if (storedColor == -1) return 0xFFFFFF; + + if (storedColor == 16) return Color.HSBtoRGB(Botania.proxy.getWorldElapsedTicks() * 2 % 360 / 360F, 1F, 1F); + + float[] color = EntitySheep.fleeceColorTable[storedColor]; + return new Color(color[0], color[1], color[2]).getRGB(); + } + + public static int getStoredColor(ItemStack stack) { + return ItemNBTHelper.getInt(stack, TAG_COLOR, -1); + } + + public static ItemStack setLensColor(ItemStack stack, int color) { + ItemNBTHelper.setInt(stack, TAG_COLOR, color); + return stack; + } + + @Override + public boolean doParticles(IManaBurst burst, ItemStack stack) { + return true; + } + + public static void setProps(int lens, int props_) { + props[lens] = props_; + } + + public static void setLens(int index, Lens lens) { + lenses[index] = lens; + } + + public static boolean isBlacklisted(ItemStack lens1, ItemStack lens2) { + ICompositableLens item1 = (ICompositableLens) lens1.getItem(); + ICompositableLens item2 = (ICompositableLens) lens2.getItem(); + return (item1.getProps(lens1) & item2.getProps(lens2)) != 0; + } + + public static Lens getLens(int index) { + if (index == STORM) return stormLens; + + Lens lens = lenses[index]; + return lens == null ? fallbackLens : lens; + } + + @Override + public boolean canCombineLenses(ItemStack sourceLens, ItemStack compositeLens) { + ICompositableLens sourceItem = (ICompositableLens) sourceLens.getItem(); + ICompositableLens compositeItem = (ICompositableLens) compositeLens.getItem(); + if (sourceItem == compositeItem && sourceLens.getItemDamage() == compositeLens.getItemDamage()) return false; + + if (!sourceItem.isCombinable(sourceLens) || !compositeItem.isCombinable(compositeLens)) return false; + + if (isBlacklisted(sourceLens, compositeLens)) return false; + + return true; + } + + @Override + public ItemStack getCompositeLens(ItemStack stack) { + NBTTagCompound cmp = ItemNBTHelper.getCompound(stack, TAG_COMPOSITE_LENS, false); + ItemStack lens = ItemStack.loadItemStackFromNBT(cmp); + return lens; + } + + @Override + public ItemStack setCompositeLens(ItemStack sourceLens, ItemStack compositeLens) { + NBTTagCompound cmp = new NBTTagCompound(); + compositeLens.writeToNBT(cmp); + ItemNBTHelper.setCompound(sourceLens, TAG_COMPOSITE_LENS, cmp); + + return sourceLens; + } + + @Override + public boolean shouldPull(ItemStack stack) { + return stack.getItemDamage() != STORM; + } + + @Override + public boolean isControlLens(ItemStack stack) { + return (getProps(stack) & PROP_CONTROL) != 0; + } + + @Override + public boolean allowBurstShooting(ItemStack stack, IManaSpreader spreader, boolean redstone) { + return lenses[stack.getItemDamage()].allowBurstShooting(stack, spreader, redstone); + } + + @Override + public void onControlledSpreaderTick(ItemStack stack, IManaSpreader spreader, boolean redstone) { + lenses[stack.getItemDamage()].onControlledSpreaderTick(stack, spreader, redstone); + } + + @Override + public void onControlledSpreaderPulse(ItemStack stack, IManaSpreader spreader, boolean redstone) { + lenses[stack.getItemDamage()].onControlledSpreaderPulse(stack, spreader, redstone); + } + + @Override + public int getProps(ItemStack stack) { + return props[stack.getItemDamage()]; + } + + @Override + public boolean isCombinable(ItemStack stack) { + return stack.getItemDamage() != NORMAL; + } } diff --git a/src/main/java/vazkii/botania/common/item/lens/Lens.java b/src/main/java/vazkii/botania/common/item/lens/Lens.java index 96cf391c1f..09f75845b8 100644 --- a/src/main/java/vazkii/botania/common/item/lens/Lens.java +++ b/src/main/java/vazkii/botania/common/item/lens/Lens.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jan 24, 2015, 4:31:16 PM (GMT)] */ package vazkii.botania.common.item.lens; @@ -17,31 +17,35 @@ import vazkii.botania.api.mana.BurstProperties; import vazkii.botania.api.mana.IManaSpreader; -public class Lens { - - public void apply(ItemStack stack, BurstProperties props) { - // NO-OP - } - - public boolean collideBurst(IManaBurst burst, EntityThrowable entity, MovingObjectPosition pos, boolean isManaBlock, boolean dead, ItemStack stack) { - return dead; - } - - public void updateBurst(IManaBurst burst, EntityThrowable entity, ItemStack stack) { - // NO-OP - } - - public boolean allowBurstShooting(ItemStack stack, IManaSpreader spreader, boolean redstone) { - return true; - } - - public void onControlledSpreaderTick(ItemStack stack, IManaSpreader spreader, boolean redstone) { - // NO-OP - } - - public void onControlledSpreaderPulse(ItemStack stack, IManaSpreader spreader, boolean redstone) { - // NO-OP - } - - +public class Lens { + + public void apply(ItemStack stack, BurstProperties props) { + // NO-OP + } + + public boolean collideBurst( + IManaBurst burst, + EntityThrowable entity, + MovingObjectPosition pos, + boolean isManaBlock, + boolean dead, + ItemStack stack) { + return dead; + } + + public void updateBurst(IManaBurst burst, EntityThrowable entity, ItemStack stack) { + // NO-OP + } + + public boolean allowBurstShooting(ItemStack stack, IManaSpreader spreader, boolean redstone) { + return true; + } + + public void onControlledSpreaderTick(ItemStack stack, IManaSpreader spreader, boolean redstone) { + // NO-OP + } + + public void onControlledSpreaderPulse(ItemStack stack, IManaSpreader spreader, boolean redstone) { + // NO-OP + } } diff --git a/src/main/java/vazkii/botania/common/item/lens/LensBounce.java b/src/main/java/vazkii/botania/common/item/lens/LensBounce.java index 28148f7361..b50dc3d78e 100644 --- a/src/main/java/vazkii/botania/common/item/lens/LensBounce.java +++ b/src/main/java/vazkii/botania/common/item/lens/LensBounce.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jan 24, 2015, 4:34:29 PM (GMT)] */ package vazkii.botania.common.item.lens; @@ -20,22 +20,29 @@ public class LensBounce extends Lens { - @Override - public boolean collideBurst(IManaBurst burst, EntityThrowable entity, MovingObjectPosition pos, boolean isManaBlock, boolean dead, ItemStack stack) { - if(!isManaBlock && pos.entityHit == null) { - ChunkCoordinates coords = burst.getBurstSourceChunkCoordinates(); - if(coords.posX != pos.blockX || coords.posY != pos.blockY || coords.posZ != pos.blockZ) { - Vector3 currentMovementVec = new Vector3(entity.motionX, entity.motionY, entity.motionZ); - ForgeDirection dir = ForgeDirection.getOrientation(pos.sideHit); - Vector3 normalVector = new Vector3(dir.offsetX, dir.offsetY, dir.offsetZ).normalize(); - Vector3 movementVec = normalVector.multiply(-2 * currentMovementVec.dotProduct(normalVector)).add(currentMovementVec); + @Override + public boolean collideBurst( + IManaBurst burst, + EntityThrowable entity, + MovingObjectPosition pos, + boolean isManaBlock, + boolean dead, + ItemStack stack) { + if (!isManaBlock && pos.entityHit == null) { + ChunkCoordinates coords = burst.getBurstSourceChunkCoordinates(); + if (coords.posX != pos.blockX || coords.posY != pos.blockY || coords.posZ != pos.blockZ) { + Vector3 currentMovementVec = new Vector3(entity.motionX, entity.motionY, entity.motionZ); + ForgeDirection dir = ForgeDirection.getOrientation(pos.sideHit); + Vector3 normalVector = new Vector3(dir.offsetX, dir.offsetY, dir.offsetZ).normalize(); + Vector3 movementVec = normalVector + .multiply(-2 * currentMovementVec.dotProduct(normalVector)) + .add(currentMovementVec); - burst.setMotion(movementVec.x, movementVec.y, movementVec.z); - dead = false; - } - } - - return dead; - } + burst.setMotion(movementVec.x, movementVec.y, movementVec.z); + dead = false; + } + } + return dead; + } } diff --git a/src/main/java/vazkii/botania/common/item/lens/LensDamage.java b/src/main/java/vazkii/botania/common/item/lens/LensDamage.java index f1a2689012..341e3dd9a2 100644 --- a/src/main/java/vazkii/botania/common/item/lens/LensDamage.java +++ b/src/main/java/vazkii/botania/common/item/lens/LensDamage.java @@ -2,16 +2,15 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jan 24, 2015, 4:37:33 PM (GMT)] */ package vazkii.botania.common.item.lens; import java.util.List; - import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.projectile.EntityThrowable; @@ -22,24 +21,28 @@ public class LensDamage extends Lens { - @Override - public void updateBurst(IManaBurst burst, EntityThrowable entity, ItemStack stack) { - AxisAlignedBB axis = AxisAlignedBB.getBoundingBox(entity.posX, entity.posY, entity.posZ, entity.lastTickPosX, entity.lastTickPosY, entity.lastTickPosZ).expand(1, 1, 1); - List entities = entity.worldObj.getEntitiesWithinAABB(EntityLivingBase.class, axis); - for(EntityLivingBase living : entities) { - if(living instanceof EntityPlayer) - continue; - - if(living.hurtTime == 0) { - int mana = burst.getMana(); - if(mana >= 16) { - burst.setMana(mana - 16); - if(!burst.isFake() && !entity.worldObj.isRemote) - living.attackEntityFrom(DamageSource.magic, 8); - break; - } - } - } - } + @Override + public void updateBurst(IManaBurst burst, EntityThrowable entity, ItemStack stack) { + AxisAlignedBB axis = AxisAlignedBB.getBoundingBox( + entity.posX, + entity.posY, + entity.posZ, + entity.lastTickPosX, + entity.lastTickPosY, + entity.lastTickPosZ) + .expand(1, 1, 1); + List entities = entity.worldObj.getEntitiesWithinAABB(EntityLivingBase.class, axis); + for (EntityLivingBase living : entities) { + if (living instanceof EntityPlayer) continue; + if (living.hurtTime == 0) { + int mana = burst.getMana(); + if (mana >= 16) { + burst.setMana(mana - 16); + if (!burst.isFake() && !entity.worldObj.isRemote) living.attackEntityFrom(DamageSource.magic, 8); + break; + } + } + } + } } diff --git a/src/main/java/vazkii/botania/common/item/lens/LensEfficiency.java b/src/main/java/vazkii/botania/common/item/lens/LensEfficiency.java index 6e5b6eaf8c..cad72d1d4d 100644 --- a/src/main/java/vazkii/botania/common/item/lens/LensEfficiency.java +++ b/src/main/java/vazkii/botania/common/item/lens/LensEfficiency.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jan 24, 2015, 4:34:06 PM (GMT)] */ package vazkii.botania.common.item.lens; @@ -15,10 +15,9 @@ public class LensEfficiency extends Lens { - @Override - public void apply(ItemStack stack, BurstProperties props) { - props.manaLossPerTick /= 5F; - props.ticksBeforeManaLoss *= 1.1F; - } - + @Override + public void apply(ItemStack stack, BurstProperties props) { + props.manaLossPerTick /= 5F; + props.ticksBeforeManaLoss *= 1.1F; + } } diff --git a/src/main/java/vazkii/botania/common/item/lens/LensExplosive.java b/src/main/java/vazkii/botania/common/item/lens/LensExplosive.java index 6d4f8eb10f..0d2e437fa2 100644 --- a/src/main/java/vazkii/botania/common/item/lens/LensExplosive.java +++ b/src/main/java/vazkii/botania/common/item/lens/LensExplosive.java @@ -1,12 +1,12 @@ /** * This class was created by - . It's distributed as + * . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jan 24, 2015, 4:41:44 PM (GMT)] */ package vazkii.botania.common.item.lens; @@ -19,15 +19,24 @@ public class LensExplosive extends Lens { - @Override - public boolean collideBurst(IManaBurst burst, EntityThrowable entity, MovingObjectPosition pos, boolean isManaBlock, boolean dead, ItemStack stack) { - if(!burst.isFake()) { - ChunkCoordinates coords = burst.getBurstSourceChunkCoordinates(); - if(!entity.worldObj.isRemote && pos.entityHit == null && !isManaBlock && (pos.blockX != coords.posX || pos.blockY != coords.posY || pos.blockZ != coords.posZ)) - entity.worldObj.createExplosion(entity, entity.posX, entity.posY, entity.posZ, burst.getMana() / 50F, true); - } else dead = false; - - return dead; - } + @Override + public boolean collideBurst( + IManaBurst burst, + EntityThrowable entity, + MovingObjectPosition pos, + boolean isManaBlock, + boolean dead, + ItemStack stack) { + if (!burst.isFake()) { + ChunkCoordinates coords = burst.getBurstSourceChunkCoordinates(); + if (!entity.worldObj.isRemote + && pos.entityHit == null + && !isManaBlock + && (pos.blockX != coords.posX || pos.blockY != coords.posY || pos.blockZ != coords.posZ)) + entity.worldObj.createExplosion( + entity, entity.posX, entity.posY, entity.posZ, burst.getMana() / 50F, true); + } else dead = false; + return dead; + } } diff --git a/src/main/java/vazkii/botania/common/item/lens/LensFire.java b/src/main/java/vazkii/botania/common/item/lens/LensFire.java index 19ed86c740..23ba1895a9 100644 --- a/src/main/java/vazkii/botania/common/item/lens/LensFire.java +++ b/src/main/java/vazkii/botania/common/item/lens/LensFire.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jan 24, 2015, 4:46:03 PM (GMT)] */ package vazkii.botania.common.item.lens; @@ -23,29 +23,35 @@ public class LensFire extends Lens { - @Override - public boolean collideBurst(IManaBurst burst, EntityThrowable entity, MovingObjectPosition pos, boolean isManaBlock, boolean dead, ItemStack stack) { - ChunkCoordinates coords = burst.getBurstSourceChunkCoordinates(); - if((coords.posX != pos.blockX || coords.posY != pos.blockY || coords.posZ != pos.blockZ) && !burst.isFake() && !isManaBlock) { - ForgeDirection dir = ForgeDirection.getOrientation(pos.sideHit); - - int x = pos.blockX + dir.offsetX; - int y = pos.blockY + dir.offsetY; - int z = pos.blockZ + dir.offsetZ; - - Block blockAt = entity.worldObj.getBlock(pos.blockX, pos.blockY, pos.blockZ); - Block blockAt_ = entity.worldObj.getBlock(x, y, z); - - if(blockAt == Blocks.portal) - entity.worldObj.setBlock(pos.blockX, pos.blockY, pos.blockZ, Blocks.air); - else if(blockAt == ModBlocks.incensePlate) { - TileIncensePlate plate = (TileIncensePlate) entity.worldObj.getTileEntity(pos.blockX, pos.blockY, pos.blockZ); - plate.ignite(); - } else if(blockAt_.isAir(entity.worldObj, x, y, z)) - entity.worldObj.setBlock(x, y, z, Blocks.fire); - } - - return dead; - } - + @Override + public boolean collideBurst( + IManaBurst burst, + EntityThrowable entity, + MovingObjectPosition pos, + boolean isManaBlock, + boolean dead, + ItemStack stack) { + ChunkCoordinates coords = burst.getBurstSourceChunkCoordinates(); + if ((coords.posX != pos.blockX || coords.posY != pos.blockY || coords.posZ != pos.blockZ) + && !burst.isFake() + && !isManaBlock) { + ForgeDirection dir = ForgeDirection.getOrientation(pos.sideHit); + + int x = pos.blockX + dir.offsetX; + int y = pos.blockY + dir.offsetY; + int z = pos.blockZ + dir.offsetZ; + + Block blockAt = entity.worldObj.getBlock(pos.blockX, pos.blockY, pos.blockZ); + Block blockAt_ = entity.worldObj.getBlock(x, y, z); + + if (blockAt == Blocks.portal) entity.worldObj.setBlock(pos.blockX, pos.blockY, pos.blockZ, Blocks.air); + else if (blockAt == ModBlocks.incensePlate) { + TileIncensePlate plate = + (TileIncensePlate) entity.worldObj.getTileEntity(pos.blockX, pos.blockY, pos.blockZ); + plate.ignite(); + } else if (blockAt_.isAir(entity.worldObj, x, y, z)) entity.worldObj.setBlock(x, y, z, Blocks.fire); + } + + return dead; + } } diff --git a/src/main/java/vazkii/botania/common/item/lens/LensFirework.java b/src/main/java/vazkii/botania/common/item/lens/LensFirework.java index a81ef35539..dbf7d89de9 100644 --- a/src/main/java/vazkii/botania/common/item/lens/LensFirework.java +++ b/src/main/java/vazkii/botania/common/item/lens/LensFirework.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [15/11/2015, 19:12:41 (GMT)] */ package vazkii.botania.common.item.lens; @@ -23,53 +23,60 @@ public class LensFirework extends Lens { - @Override - public boolean collideBurst(IManaBurst burst, EntityThrowable entity, MovingObjectPosition pos, boolean isManaBlock, boolean dead, ItemStack stack) { - if(!burst.isFake()) { - ChunkCoordinates coords = burst.getBurstSourceChunkCoordinates(); - if(!entity.worldObj.isRemote && pos.entityHit == null && !isManaBlock && (pos.blockX != coords.posX || pos.blockY != coords.posY || pos.blockZ != coords.posZ)) { - ItemStack fireworkStack = generateFirework(burst.getColor()); + @Override + public boolean collideBurst( + IManaBurst burst, + EntityThrowable entity, + MovingObjectPosition pos, + boolean isManaBlock, + boolean dead, + ItemStack stack) { + if (!burst.isFake()) { + ChunkCoordinates coords = burst.getBurstSourceChunkCoordinates(); + if (!entity.worldObj.isRemote + && pos.entityHit == null + && !isManaBlock + && (pos.blockX != coords.posX || pos.blockY != coords.posY || pos.blockZ != coords.posZ)) { + ItemStack fireworkStack = generateFirework(burst.getColor()); - EntityFireworkRocket rocket = new EntityFireworkRocket(entity.worldObj, entity.posX, entity.posY, entity.posZ, fireworkStack); - entity.worldObj.spawnEntityInWorld(rocket); - } - } else dead = false; + EntityFireworkRocket rocket = + new EntityFireworkRocket(entity.worldObj, entity.posX, entity.posY, entity.posZ, fireworkStack); + entity.worldObj.spawnEntityInWorld(rocket); + } + } else dead = false; - return dead; - } + return dead; + } - public ItemStack generateFirework(int color) { - ItemStack stack = new ItemStack(Items.fireworks); - NBTTagCompound explosion = new NBTTagCompound(); - explosion.setIntArray("Colors", new int[] { color }); + public ItemStack generateFirework(int color) { + ItemStack stack = new ItemStack(Items.fireworks); + NBTTagCompound explosion = new NBTTagCompound(); + explosion.setIntArray("Colors", new int[] {color}); - int type = 1; - double rand = Math.random(); - if(rand > 0.25) { - if(rand > 0.9) - type = 2; - else type = 0; - } + int type = 1; + double rand = Math.random(); + if (rand > 0.25) { + if (rand > 0.9) type = 2; + else type = 0; + } - explosion.setInteger("Type", type); + explosion.setInteger("Type", type); - if(Math.random() < 0.05) - if(Math.random() < 0.5) - explosion.setBoolean("Flicker", true); - else explosion.setBoolean("Trail", true); + if (Math.random() < 0.05) + if (Math.random() < 0.5) explosion.setBoolean("Flicker", true); + else explosion.setBoolean("Trail", true); - ItemNBTHelper.setCompound(stack, "Explosion", explosion); + ItemNBTHelper.setCompound(stack, "Explosion", explosion); - NBTTagCompound fireworks = new NBTTagCompound(); - fireworks.setInteger("Flight", (int) Math.random() * 3 + 2); + NBTTagCompound fireworks = new NBTTagCompound(); + fireworks.setInteger("Flight", (int) Math.random() * 3 + 2); - NBTTagList explosions = new NBTTagList(); - explosions.appendTag(explosion); - fireworks.setTag("Explosions", explosions); + NBTTagList explosions = new NBTTagList(); + explosions.appendTag(explosion); + fireworks.setTag("Explosions", explosions); - ItemNBTHelper.setCompound(stack, "Fireworks", fireworks); - - return stack; - } + ItemNBTHelper.setCompound(stack, "Fireworks", fireworks); + return stack; + } } diff --git a/src/main/java/vazkii/botania/common/item/lens/LensFlare.java b/src/main/java/vazkii/botania/common/item/lens/LensFlare.java index 96345bf7ad..da0025230a 100644 --- a/src/main/java/vazkii/botania/common/item/lens/LensFlare.java +++ b/src/main/java/vazkii/botania/common/item/lens/LensFlare.java @@ -2,16 +2,15 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [15/11/2015, 19:13:10 (GMT)] */ package vazkii.botania.common.item.lens; import java.awt.Color; - import net.minecraft.entity.passive.EntitySheep; import net.minecraft.item.ItemStack; import net.minecraft.tileentity.TileEntity; @@ -21,49 +20,54 @@ public class LensFlare extends Lens { - @Override - public boolean allowBurstShooting(ItemStack stack, IManaSpreader spreader, boolean redstone) { - return false; - } - - @Override - public void onControlledSpreaderTick(ItemStack stack, IManaSpreader spreader, boolean redstone) { - if(!redstone) - emitParticles(stack, spreader, redstone); - } + @Override + public boolean allowBurstShooting(ItemStack stack, IManaSpreader spreader, boolean redstone) { + return false; + } - @Override - public void onControlledSpreaderPulse(ItemStack stack, IManaSpreader spreader, boolean redstone) { - emitParticles(stack, spreader, redstone); - } + @Override + public void onControlledSpreaderTick(ItemStack stack, IManaSpreader spreader, boolean redstone) { + if (!redstone) emitParticles(stack, spreader, redstone); + } - private void emitParticles(ItemStack stack, IManaSpreader spreader, boolean redstone) { - float rotationYaw = -(spreader.getRotationX() + 90F); - float rotationPitch = spreader.getRotationY(); + @Override + public void onControlledSpreaderPulse(ItemStack stack, IManaSpreader spreader, boolean redstone) { + emitParticles(stack, spreader, redstone); + } - // Lots of EntityThrowable copypasta - float f = 0.3F; - float mx = (float) (MathHelper.sin(rotationYaw / 180.0F * (float) Math.PI) * MathHelper.cos(rotationPitch / 180.0F * (float) Math.PI) * f / 2D); - float mz = (float) (-(MathHelper.cos(rotationYaw / 180.0F * (float) Math.PI) * MathHelper.cos(rotationPitch / 180.0F * (float) Math.PI) * f) / 2D); - float my = (float) (MathHelper.sin(rotationPitch / 180.0F * (float) Math.PI) * f / 2D); + private void emitParticles(ItemStack stack, IManaSpreader spreader, boolean redstone) { + float rotationYaw = -(spreader.getRotationX() + 90F); + float rotationPitch = spreader.getRotationY(); - int storedColor = ItemLens.getStoredColor(stack); - float r = 1, g = 1, b = 1; + // Lots of EntityThrowable copypasta + float f = 0.3F; + float mx = (float) (MathHelper.sin(rotationYaw / 180.0F * (float) Math.PI) + * MathHelper.cos(rotationPitch / 180.0F * (float) Math.PI) + * f + / 2D); + float mz = (float) (-(MathHelper.cos(rotationYaw / 180.0F * (float) Math.PI) + * MathHelper.cos(rotationPitch / 180.0F * (float) Math.PI) + * f) + / 2D); + float my = (float) (MathHelper.sin(rotationPitch / 180.0F * (float) Math.PI) * f / 2D); - TileEntity tile = (TileEntity) spreader; - if(storedColor == 16) { - Color c = Color.getHSBColor(tile.getWorldObj().getTotalWorldTime() * 2 % 360 / 360F, 1F, 1F); - r = c.getRed() / 255F; - g = c.getGreen() / 255F; - b = c.getBlue() / 255F; - } else if(storedColor >= 0) { - float[] colortable = EntitySheep.fleeceColorTable[storedColor]; - r = colortable[0]; - g = colortable[1]; - b = colortable[2]; - } + int storedColor = ItemLens.getStoredColor(stack); + float r = 1, g = 1, b = 1; - Botania.proxy.wispFX(tile.getWorldObj(), tile.xCoord + 0.5, tile.yCoord + 0.5, tile.zCoord + 0.5, r, g, b, 0.4F, mx, my, mz); - } + TileEntity tile = (TileEntity) spreader; + if (storedColor == 16) { + Color c = Color.getHSBColor(tile.getWorldObj().getTotalWorldTime() * 2 % 360 / 360F, 1F, 1F); + r = c.getRed() / 255F; + g = c.getGreen() / 255F; + b = c.getBlue() / 255F; + } else if (storedColor >= 0) { + float[] colortable = EntitySheep.fleeceColorTable[storedColor]; + r = colortable[0]; + g = colortable[1]; + b = colortable[2]; + } + Botania.proxy.wispFX( + tile.getWorldObj(), tile.xCoord + 0.5, tile.yCoord + 0.5, tile.zCoord + 0.5, r, g, b, 0.4F, mx, my, mz); + } } diff --git a/src/main/java/vazkii/botania/common/item/lens/LensGravity.java b/src/main/java/vazkii/botania/common/item/lens/LensGravity.java index ae7a684b1e..1fb0e1bf23 100644 --- a/src/main/java/vazkii/botania/common/item/lens/LensGravity.java +++ b/src/main/java/vazkii/botania/common/item/lens/LensGravity.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jan 24, 2015, 4:35:52 PM (GMT)] */ package vazkii.botania.common.item.lens; @@ -15,10 +15,9 @@ public class LensGravity extends Lens { - @Override - public void apply(ItemStack stack, BurstProperties props) { - props.gravity = 0.0015F; - props.ticksBeforeManaLoss *= 1.2F; - } - + @Override + public void apply(ItemStack stack, BurstProperties props) { + props.gravity = 0.0015F; + props.ticksBeforeManaLoss *= 1.2F; + } } diff --git a/src/main/java/vazkii/botania/common/item/lens/LensInfluence.java b/src/main/java/vazkii/botania/common/item/lens/LensInfluence.java index 43c4fa01c0..3d7c4add2c 100644 --- a/src/main/java/vazkii/botania/common/item/lens/LensInfluence.java +++ b/src/main/java/vazkii/botania/common/item/lens/LensInfluence.java @@ -2,16 +2,15 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jan 24, 2015, 4:42:33 PM (GMT)] */ package vazkii.botania.common.item.lens; import java.util.List; - import net.minecraft.entity.Entity; import net.minecraft.entity.item.EntityFallingBlock; import net.minecraft.entity.item.EntityItem; @@ -25,34 +24,72 @@ public class LensInfluence extends Lens { - @Override - public void updateBurst(IManaBurst burst, EntityThrowable entity, ItemStack stack) { - if(!burst.isFake()) { - double range = 3.5; - List movables = entity.worldObj.getEntitiesWithinAABB(EntityItem.class, AxisAlignedBB.getBoundingBox(entity.posX - range, entity.posY - range, entity.posZ - range, entity.posX + range, entity.posY + range, entity.posZ + range)); - movables.addAll(entity.worldObj.getEntitiesWithinAABB(EntityXPOrb.class, AxisAlignedBB.getBoundingBox(entity.posX - range, entity.posY - range, entity.posZ - range, entity.posX + range, entity.posY + range, entity.posZ + range))); - movables.addAll(entity.worldObj.getEntitiesWithinAABB(EntityArrow.class, AxisAlignedBB.getBoundingBox(entity.posX - range, entity.posY - range, entity.posZ - range, entity.posX + range, entity.posY + range, entity.posZ + range))); - movables.addAll(entity.worldObj.getEntitiesWithinAABB(EntityFallingBlock.class, AxisAlignedBB.getBoundingBox(entity.posX - range, entity.posY - range, entity.posZ - range, entity.posX + range, entity.posY + range, entity.posZ + range))); - movables.addAll(entity.worldObj.getEntitiesWithinAABB(IManaBurst.class, AxisAlignedBB.getBoundingBox(entity.posX - range, entity.posY - range, entity.posZ - range, entity.posX + range, entity.posY + range, entity.posZ + range))); - - for(Entity movable : movables) { - if(movable == burst) - continue; + @Override + public void updateBurst(IManaBurst burst, EntityThrowable entity, ItemStack stack) { + if (!burst.isFake()) { + double range = 3.5; + List movables = entity.worldObj.getEntitiesWithinAABB( + EntityItem.class, + AxisAlignedBB.getBoundingBox( + entity.posX - range, + entity.posY - range, + entity.posZ - range, + entity.posX + range, + entity.posY + range, + entity.posZ + range)); + movables.addAll(entity.worldObj.getEntitiesWithinAABB( + EntityXPOrb.class, + AxisAlignedBB.getBoundingBox( + entity.posX - range, + entity.posY - range, + entity.posZ - range, + entity.posX + range, + entity.posY + range, + entity.posZ + range))); + movables.addAll(entity.worldObj.getEntitiesWithinAABB( + EntityArrow.class, + AxisAlignedBB.getBoundingBox( + entity.posX - range, + entity.posY - range, + entity.posZ - range, + entity.posX + range, + entity.posY + range, + entity.posZ + range))); + movables.addAll(entity.worldObj.getEntitiesWithinAABB( + EntityFallingBlock.class, + AxisAlignedBB.getBoundingBox( + entity.posX - range, + entity.posY - range, + entity.posZ - range, + entity.posX + range, + entity.posY + range, + entity.posZ + range))); + movables.addAll(entity.worldObj.getEntitiesWithinAABB( + IManaBurst.class, + AxisAlignedBB.getBoundingBox( + entity.posX - range, + entity.posY - range, + entity.posZ - range, + entity.posX + range, + entity.posY + range, + entity.posZ + range))); - if(movable instanceof IManaBurst) { - IManaBurst otherBurst = (IManaBurst) movable; - ItemStack lens = otherBurst.getSourceLens(); - if(lens != null && lens.getItem() == ModItems.lens && lens.getItemDamage() == ItemLens.INFLUENCE) - continue; + for (Entity movable : movables) { + if (movable == burst) continue; - ((IManaBurst) movable).setMotion(entity.motionX, entity.motionY, entity.motionZ); - } else { - movable.motionX = entity.motionX; - movable.motionY = entity.motionY; - movable.motionZ = entity.motionZ; - } - } - } - } + if (movable instanceof IManaBurst) { + IManaBurst otherBurst = (IManaBurst) movable; + ItemStack lens = otherBurst.getSourceLens(); + if (lens != null && lens.getItem() == ModItems.lens && lens.getItemDamage() == ItemLens.INFLUENCE) + continue; + ((IManaBurst) movable).setMotion(entity.motionX, entity.motionY, entity.motionZ); + } else { + movable.motionX = entity.motionX; + movable.motionY = entity.motionY; + movable.motionZ = entity.motionZ; + } + } + } + } } diff --git a/src/main/java/vazkii/botania/common/item/lens/LensLight.java b/src/main/java/vazkii/botania/common/item/lens/LensLight.java index 3d11335648..96de521725 100644 --- a/src/main/java/vazkii/botania/common/item/lens/LensLight.java +++ b/src/main/java/vazkii/botania/common/item/lens/LensLight.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jan 24, 2015, 4:47:20 PM (GMT)] */ package vazkii.botania.common.item.lens; @@ -24,31 +24,37 @@ public class LensLight extends Lens { - @Override - public boolean collideBurst(IManaBurst burst, EntityThrowable entity, MovingObjectPosition pos, boolean isManaBlock, boolean dead, ItemStack stack) { - ChunkCoordinates coords = burst.getBurstSourceChunkCoordinates(); - if((coords.posX != pos.blockX || coords.posY != pos.blockY || coords.posZ != pos.blockZ) && !burst.isFake() && !isManaBlock) { - ForgeDirection dir = ForgeDirection.getOrientation(pos.sideHit); - - int x = pos.blockX + dir.offsetX; - int y = pos.blockY + dir.offsetY; - int z = pos.blockZ + dir.offsetZ; - - Block blockAt = entity.worldObj.getBlock(pos.blockX, pos.blockY, pos.blockZ); - Block blockAt_ = entity.worldObj.getBlock(x, y, z); - - if(blockAt == ModBlocks.manaFlame) - entity.worldObj.setBlock(pos.blockX, pos.blockY, pos.blockZ, Blocks.air); - else if(blockAt_.isAir(entity.worldObj, x, y, z) || blockAt_.isReplaceable(entity.worldObj, x, y, z)) { - entity.worldObj.setBlock(x, y, z, ModBlocks.manaFlame); - TileEntity tile = entity.worldObj.getTileEntity(x, y, z); - - if(tile instanceof TileManaFlame) - ((TileManaFlame) tile).setColor(burst.getColor()); - } - } - - return dead; - } - + @Override + public boolean collideBurst( + IManaBurst burst, + EntityThrowable entity, + MovingObjectPosition pos, + boolean isManaBlock, + boolean dead, + ItemStack stack) { + ChunkCoordinates coords = burst.getBurstSourceChunkCoordinates(); + if ((coords.posX != pos.blockX || coords.posY != pos.blockY || coords.posZ != pos.blockZ) + && !burst.isFake() + && !isManaBlock) { + ForgeDirection dir = ForgeDirection.getOrientation(pos.sideHit); + + int x = pos.blockX + dir.offsetX; + int y = pos.blockY + dir.offsetY; + int z = pos.blockZ + dir.offsetZ; + + Block blockAt = entity.worldObj.getBlock(pos.blockX, pos.blockY, pos.blockZ); + Block blockAt_ = entity.worldObj.getBlock(x, y, z); + + if (blockAt == ModBlocks.manaFlame) + entity.worldObj.setBlock(pos.blockX, pos.blockY, pos.blockZ, Blocks.air); + else if (blockAt_.isAir(entity.worldObj, x, y, z) || blockAt_.isReplaceable(entity.worldObj, x, y, z)) { + entity.worldObj.setBlock(x, y, z, ModBlocks.manaFlame); + TileEntity tile = entity.worldObj.getTileEntity(x, y, z); + + if (tile instanceof TileManaFlame) ((TileManaFlame) tile).setColor(burst.getColor()); + } + } + + return dead; + } } diff --git a/src/main/java/vazkii/botania/common/item/lens/LensMagnet.java b/src/main/java/vazkii/botania/common/item/lens/LensMagnet.java index 983e46cd5a..0c9a6431a3 100644 --- a/src/main/java/vazkii/botania/common/item/lens/LensMagnet.java +++ b/src/main/java/vazkii/botania/common/item/lens/LensMagnet.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jan 24, 2015, 4:39:58 PM (GMT)] */ package vazkii.botania.common.item.lens; @@ -21,61 +21,71 @@ public class LensMagnet extends Lens { - private static final String TAG_MAGNETIZED = "Botania:Magnetized"; - private static final String TAG_MAGNETIZED_X = "Botania:MagnetizedX"; - private static final String TAG_MAGNETIZED_Y = "Botania:MagnetizedY"; - private static final String TAG_MAGNETIZED_Z = "Botania:MagnetizedZ"; + private static final String TAG_MAGNETIZED = "Botania:Magnetized"; + private static final String TAG_MAGNETIZED_X = "Botania:MagnetizedX"; + private static final String TAG_MAGNETIZED_Y = "Botania:MagnetizedY"; + private static final String TAG_MAGNETIZED_Z = "Botania:MagnetizedZ"; - @Override - public void updateBurst(IManaBurst burst, EntityThrowable entity, ItemStack stack) { - int x = (int) entity.posX; - int y = (int) entity.posY; - int z = (int) entity.posZ; - boolean magnetized = entity.getEntityData().hasKey(TAG_MAGNETIZED); - int range = 3; + @Override + public void updateBurst(IManaBurst burst, EntityThrowable entity, ItemStack stack) { + int x = (int) entity.posX; + int y = (int) entity.posY; + int z = (int) entity.posZ; + boolean magnetized = entity.getEntityData().hasKey(TAG_MAGNETIZED); + int range = 3; - magnetize : { - for(int i = -range; i < range; i++) - for(int j = -range; j < range; j++) - for(int k = -range; k < range; k++) - if(entity.worldObj.getTileEntity(i + x, j + y, k + z) instanceof IManaReceiver) { - TileEntity tile = entity.worldObj.getTileEntity(i + x, j + y, k + z); + magnetize: + { + for (int i = -range; i < range; i++) + for (int j = -range; j < range; j++) + for (int k = -range; k < range; k++) + if (entity.worldObj.getTileEntity(i + x, j + y, k + z) instanceof IManaReceiver) { + TileEntity tile = entity.worldObj.getTileEntity(i + x, j + y, k + z); - if(magnetized) { - int magX = entity.getEntityData().getInteger(TAG_MAGNETIZED_X); - int magY = entity.getEntityData().getInteger(TAG_MAGNETIZED_Y); - int magZ = entity.getEntityData().getInteger(TAG_MAGNETIZED_Z); - if(tile.xCoord != magX || tile.yCoord != magY || tile.zCoord != magZ) - continue; - } + if (magnetized) { + int magX = entity.getEntityData().getInteger(TAG_MAGNETIZED_X); + int magY = entity.getEntityData().getInteger(TAG_MAGNETIZED_Y); + int magZ = entity.getEntityData().getInteger(TAG_MAGNETIZED_Z); + if (tile.xCoord != magX || tile.yCoord != magY || tile.zCoord != magZ) continue; + } - IManaReceiver receiver = (IManaReceiver) tile; + IManaReceiver receiver = (IManaReceiver) tile; - ChunkCoordinates srcCoords = burst.getBurstSourceChunkCoordinates(); + ChunkCoordinates srcCoords = burst.getBurstSourceChunkCoordinates(); - if(MathHelper.pointDistanceSpace(tile.xCoord, tile.yCoord, tile.zCoord, srcCoords.posX, srcCoords.posY, srcCoords.posZ) > 3 && receiver.canRecieveManaFromBursts() && !receiver.isFull()) { - Vector3 burstVec = Vector3.fromEntity(entity); - Vector3 tileVec = Vector3.fromTileEntityCenter(tile).add(0, -0.1, 0); - Vector3 motionVec = new Vector3(entity.motionX, entity.motionY, entity.motionZ); + if (MathHelper.pointDistanceSpace( + tile.xCoord, + tile.yCoord, + tile.zCoord, + srcCoords.posX, + srcCoords.posY, + srcCoords.posZ) + > 3 + && receiver.canRecieveManaFromBursts() + && !receiver.isFull()) { + Vector3 burstVec = Vector3.fromEntity(entity); + Vector3 tileVec = + Vector3.fromTileEntityCenter(tile).add(0, -0.1, 0); + Vector3 motionVec = new Vector3(entity.motionX, entity.motionY, entity.motionZ); - Vector3 normalMotionVec = motionVec.copy().normalize(); - Vector3 magnetVec = tileVec.sub(burstVec).normalize(); - Vector3 differenceVec = normalMotionVec.sub(magnetVec).multiply(motionVec.mag() * 0.1); + Vector3 normalMotionVec = motionVec.copy().normalize(); + Vector3 magnetVec = tileVec.sub(burstVec).normalize(); + Vector3 differenceVec = + normalMotionVec.sub(magnetVec).multiply(motionVec.mag() * 0.1); - Vector3 finalMotionVec = motionVec.sub(differenceVec); - if(!magnetized) { - finalMotionVec.multiply(0.75); - entity.getEntityData().setBoolean(TAG_MAGNETIZED, true); - entity.getEntityData().setInteger(TAG_MAGNETIZED_X, tile.xCoord); - entity.getEntityData().setInteger(TAG_MAGNETIZED_Y, tile.yCoord); - entity.getEntityData().setInteger(TAG_MAGNETIZED_Z, tile.zCoord); - } - - burst.setMotion(finalMotionVec.x, finalMotionVec.y, finalMotionVec.z); - break magnetize; - } - } - } - } + Vector3 finalMotionVec = motionVec.sub(differenceVec); + if (!magnetized) { + finalMotionVec.multiply(0.75); + entity.getEntityData().setBoolean(TAG_MAGNETIZED, true); + entity.getEntityData().setInteger(TAG_MAGNETIZED_X, tile.xCoord); + entity.getEntityData().setInteger(TAG_MAGNETIZED_Y, tile.yCoord); + entity.getEntityData().setInteger(TAG_MAGNETIZED_Z, tile.zCoord); + } + burst.setMotion(finalMotionVec.x, finalMotionVec.y, finalMotionVec.z); + break magnetize; + } + } + } + } } diff --git a/src/main/java/vazkii/botania/common/item/lens/LensMine.java b/src/main/java/vazkii/botania/common/item/lens/LensMine.java index 72020182f4..9ed89f99df 100644 --- a/src/main/java/vazkii/botania/common/item/lens/LensMine.java +++ b/src/main/java/vazkii/botania/common/item/lens/LensMine.java @@ -2,17 +2,16 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jan 24, 2015, 4:36:20 PM (GMT)] */ package vazkii.botania.common.item.lens; import java.util.ArrayList; import java.util.List; - import net.minecraft.block.Block; import net.minecraft.entity.item.EntityItem; import net.minecraft.entity.projectile.EntityThrowable; @@ -30,57 +29,71 @@ public class LensMine extends Lens { - @Override - public boolean collideBurst(IManaBurst burst, EntityThrowable entity, MovingObjectPosition pos, boolean isManaBlock, boolean dead, ItemStack stack) { - World world = entity.worldObj; - int x = pos.blockX; - int y = pos.blockY; - int z = pos.blockZ; - Block block = world.getBlock(x, y, z); - int meta = world.getBlockMetadata(x, y, z); - ItemStack composite = ((ItemLens) ModItems.lens).getCompositeLens(stack); - boolean warp = composite != null && composite.getItem() == ModItems.lens && composite.getItemDamage() == ItemLens.WARP; - - if(warp && (block == ModBlocks.pistonRelay || block == Blocks.piston || block == Blocks.piston_extension || block == Blocks.piston_head)) - return false; + @Override + public boolean collideBurst( + IManaBurst burst, + EntityThrowable entity, + MovingObjectPosition pos, + boolean isManaBlock, + boolean dead, + ItemStack stack) { + World world = entity.worldObj; + int x = pos.blockX; + int y = pos.blockY; + int z = pos.blockZ; + Block block = world.getBlock(x, y, z); + int meta = world.getBlockMetadata(x, y, z); + ItemStack composite = ((ItemLens) ModItems.lens).getCompositeLens(stack); + boolean warp = + composite != null && composite.getItem() == ModItems.lens && composite.getItemDamage() == ItemLens.WARP; + + if (warp + && (block == ModBlocks.pistonRelay + || block == Blocks.piston + || block == Blocks.piston_extension + || block == Blocks.piston_head)) return false; - int harvestLevel = ConfigHandler.harvestLevelBore; - - TileEntity tile = world.getTileEntity(x, y, z); + int harvestLevel = ConfigHandler.harvestLevelBore; - float hardness = block.getBlockHardness(world, x, y, z); - int neededHarvestLevel = block.getHarvestLevel(meta); - int mana = burst.getMana(); + TileEntity tile = world.getTileEntity(x, y, z); - ChunkCoordinates coords = burst.getBurstSourceChunkCoordinates(); - if((coords.posX != x || coords.posY != y || coords.posZ != z) && !(tile instanceof IManaBlock) && neededHarvestLevel <= harvestLevel && hardness != -1 && hardness < 50F && (burst.isFake() || mana >= 24)) { - List items = new ArrayList(); + float hardness = block.getBlockHardness(world, x, y, z); + int neededHarvestLevel = block.getHarvestLevel(meta); + int mana = burst.getMana(); - items.addAll(block.getDrops(world, x, y, z, meta, 0)); + ChunkCoordinates coords = burst.getBurstSourceChunkCoordinates(); + if ((coords.posX != x || coords.posY != y || coords.posZ != z) + && !(tile instanceof IManaBlock) + && neededHarvestLevel <= harvestLevel + && hardness != -1 + && hardness < 50F + && (burst.isFake() || mana >= 24)) { + List items = new ArrayList(); - if(!burst.hasAlreadyCollidedAt(x, y, z)) { - if(!burst.isFake() && !entity.worldObj.isRemote) { - world.setBlockToAir(x, y, z); - if(ConfigHandler.blockBreakParticles) - entity.worldObj.playAuxSFX(2001, x, y, z, Block.getIdFromBlock(block) + (meta << 12)); + items.addAll(block.getDrops(world, x, y, z, meta, 0)); - boolean offBounds = coords.posY < 0; - boolean doWarp = warp && !offBounds; - int dropX = doWarp ? coords.posX : x; - int dropY = doWarp ? coords.posY : y; - int dropZ = doWarp ? coords.posZ : z; + if (!burst.hasAlreadyCollidedAt(x, y, z)) { + if (!burst.isFake() && !entity.worldObj.isRemote) { + world.setBlockToAir(x, y, z); + if (ConfigHandler.blockBreakParticles) + entity.worldObj.playAuxSFX(2001, x, y, z, Block.getIdFromBlock(block) + (meta << 12)); - for(ItemStack stack_ : items) - world.spawnEntityInWorld(new EntityItem(world, dropX + 0.5, dropY + 0.5, dropZ + 0.5, stack_)); + boolean offBounds = coords.posY < 0; + boolean doWarp = warp && !offBounds; + int dropX = doWarp ? coords.posX : x; + int dropY = doWarp ? coords.posY : y; + int dropZ = doWarp ? coords.posZ : z; - burst.setMana(mana - 24); - } - } + for (ItemStack stack_ : items) + world.spawnEntityInWorld(new EntityItem(world, dropX + 0.5, dropY + 0.5, dropZ + 0.5, stack_)); - dead = false; - } + burst.setMana(mana - 24); + } + } - return dead; - } + dead = false; + } + return dead; + } } diff --git a/src/main/java/vazkii/botania/common/item/lens/LensPaint.java b/src/main/java/vazkii/botania/common/item/lens/LensPaint.java index 03afaeb110..2fe3c86c29 100644 --- a/src/main/java/vazkii/botania/common/item/lens/LensPaint.java +++ b/src/main/java/vazkii/botania/common/item/lens/LensPaint.java @@ -2,17 +2,16 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jan 24, 2015, 4:44:01 PM (GMT)] */ package vazkii.botania.common.item.lens; import java.util.ArrayList; import java.util.List; - import net.minecraft.block.Block; import net.minecraft.entity.passive.EntitySheep; import net.minecraft.entity.projectile.EntityThrowable; @@ -27,66 +26,99 @@ public class LensPaint extends Lens { - @Override - public boolean collideBurst(IManaBurst burst, EntityThrowable entity, MovingObjectPosition pos, boolean isManaBlock, boolean dead, ItemStack stack) { - int storedColor = ItemLens.getStoredColor(stack); - if(!burst.isFake() && storedColor > -1 && storedColor < 17) { - if(pos.entityHit != null && pos.entityHit instanceof EntitySheep) { - int r = 20; - int sheepColor = ((EntitySheep) pos.entityHit).getFleeceColor(); - List sheepList = entity.worldObj.getEntitiesWithinAABB(EntitySheep.class, AxisAlignedBB.getBoundingBox(pos.entityHit.posX - r, pos.entityHit.posY - r, pos.entityHit.posZ - r, pos.entityHit.posX + r, pos.entityHit.posY + r, pos.entityHit.posZ + r)); - for(EntitySheep sheep : sheepList) { - if(sheep.getFleeceColor() == sheepColor) - sheep.setFleeceColor(storedColor == 16 ? sheep.worldObj.rand.nextInt(16) : storedColor); - } - dead = true; - } else { - Block block = entity.worldObj.getBlock(pos.blockX, pos.blockY, pos.blockZ); - if(BotaniaAPI.paintableBlocks.contains(block)) { - int meta = entity.worldObj.getBlockMetadata(pos.blockX, pos.blockY, pos.blockZ); - List coordsToPaint = new ArrayList(); - List coordsFound = new ArrayList(); - - ChunkCoordinates theseCoords = new ChunkCoordinates(pos.blockX, pos.blockY, pos.blockZ); - coordsFound.add(theseCoords); - - do { - List iterCoords = new ArrayList(coordsFound); - for(ChunkCoordinates coords : iterCoords) { - coordsFound.remove(coords); - coordsToPaint.add(coords); + @Override + public boolean collideBurst( + IManaBurst burst, + EntityThrowable entity, + MovingObjectPosition pos, + boolean isManaBlock, + boolean dead, + ItemStack stack) { + int storedColor = ItemLens.getStoredColor(stack); + if (!burst.isFake() && storedColor > -1 && storedColor < 17) { + if (pos.entityHit != null && pos.entityHit instanceof EntitySheep) { + int r = 20; + int sheepColor = ((EntitySheep) pos.entityHit).getFleeceColor(); + List sheepList = entity.worldObj.getEntitiesWithinAABB( + EntitySheep.class, + AxisAlignedBB.getBoundingBox( + pos.entityHit.posX - r, + pos.entityHit.posY - r, + pos.entityHit.posZ - r, + pos.entityHit.posX + r, + pos.entityHit.posY + r, + pos.entityHit.posZ + r)); + for (EntitySheep sheep : sheepList) { + if (sheep.getFleeceColor() == sheepColor) + sheep.setFleeceColor(storedColor == 16 ? sheep.worldObj.rand.nextInt(16) : storedColor); + } + dead = true; + } else { + Block block = entity.worldObj.getBlock(pos.blockX, pos.blockY, pos.blockZ); + if (BotaniaAPI.paintableBlocks.contains(block)) { + int meta = entity.worldObj.getBlockMetadata(pos.blockX, pos.blockY, pos.blockZ); + List coordsToPaint = new ArrayList(); + List coordsFound = new ArrayList(); - for(ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS) { - Block block_ = entity.worldObj.getBlock(coords.posX + dir.offsetX, coords.posY + dir.offsetY, coords.posZ + dir.offsetZ); - int meta_ = entity.worldObj.getBlockMetadata(coords.posX + dir.offsetX, coords.posY + dir.offsetY, coords.posZ + dir.offsetZ); - ChunkCoordinates coords_ = new ChunkCoordinates(coords.posX + dir.offsetX, coords.posY + dir.offsetY, coords.posZ + dir.offsetZ); - if(block_ == block && meta_ == meta && !coordsFound.contains(coords_) && !coordsToPaint.contains(coords_)) - coordsFound.add(coords_); - } - } - } while(!coordsFound.isEmpty() && coordsToPaint.size() < 1000); + ChunkCoordinates theseCoords = new ChunkCoordinates(pos.blockX, pos.blockY, pos.blockZ); + coordsFound.add(theseCoords); - for(ChunkCoordinates coords : coordsToPaint) { - int placeColor = storedColor == 16 ? entity.worldObj.rand.nextInt(16) : storedColor; - int metaThere = entity.worldObj.getBlockMetadata(coords.posX, coords.posY, coords.posZ); + do { + List iterCoords = new ArrayList(coordsFound); + for (ChunkCoordinates coords : iterCoords) { + coordsFound.remove(coords); + coordsToPaint.add(coords); - if(metaThere != placeColor) { - if(!entity.worldObj.isRemote) - entity.worldObj.setBlockMetadataWithNotify(coords.posX, coords.posY, coords.posZ, placeColor, 2); - float[] color = EntitySheep.fleeceColorTable[placeColor]; - float r = color[0]; - float g = color[1]; - float b = color[2]; - for(int i = 0; i < 4; i++) - Botania.proxy.sparkleFX(entity.worldObj, coords.posX + (float) Math.random(), coords.posY + (float) Math.random(), coords.posZ + (float) Math.random(), r, g, b, 0.6F + (float) Math.random() * 0.3F, 5); + for (ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS) { + Block block_ = entity.worldObj.getBlock( + coords.posX + dir.offsetX, + coords.posY + dir.offsetY, + coords.posZ + dir.offsetZ); + int meta_ = entity.worldObj.getBlockMetadata( + coords.posX + dir.offsetX, + coords.posY + dir.offsetY, + coords.posZ + dir.offsetZ); + ChunkCoordinates coords_ = new ChunkCoordinates( + coords.posX + dir.offsetX, + coords.posY + dir.offsetY, + coords.posZ + dir.offsetZ); + if (block_ == block + && meta_ == meta + && !coordsFound.contains(coords_) + && !coordsToPaint.contains(coords_)) coordsFound.add(coords_); + } + } + } while (!coordsFound.isEmpty() && coordsToPaint.size() < 1000); - } - } - } - } - } + for (ChunkCoordinates coords : coordsToPaint) { + int placeColor = storedColor == 16 ? entity.worldObj.rand.nextInt(16) : storedColor; + int metaThere = entity.worldObj.getBlockMetadata(coords.posX, coords.posY, coords.posZ); - return dead; - } + if (metaThere != placeColor) { + if (!entity.worldObj.isRemote) + entity.worldObj.setBlockMetadataWithNotify( + coords.posX, coords.posY, coords.posZ, placeColor, 2); + float[] color = EntitySheep.fleeceColorTable[placeColor]; + float r = color[0]; + float g = color[1]; + float b = color[2]; + for (int i = 0; i < 4; i++) + Botania.proxy.sparkleFX( + entity.worldObj, + coords.posX + (float) Math.random(), + coords.posY + (float) Math.random(), + coords.posZ + (float) Math.random(), + r, + g, + b, + 0.6F + (float) Math.random() * 0.3F, + 5); + } + } + } + } + } + return dead; + } } diff --git a/src/main/java/vazkii/botania/common/item/lens/LensPhantom.java b/src/main/java/vazkii/botania/common/item/lens/LensPhantom.java index 1bcff6ec5a..f23fb38c08 100644 --- a/src/main/java/vazkii/botania/common/item/lens/LensPhantom.java +++ b/src/main/java/vazkii/botania/common/item/lens/LensPhantom.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jan 24, 2015, 4:39:24 PM (GMT)] */ package vazkii.botania.common.item.lens; @@ -17,14 +17,19 @@ public class LensPhantom extends Lens { - @Override - public boolean collideBurst(IManaBurst burst, EntityThrowable entity, MovingObjectPosition pos, boolean isManaBlock, boolean dead, ItemStack stack) { - if(!isManaBlock) { - dead = false; - burst.setMinManaLoss(Math.max(0, burst.getMinManaLoss() - 4)); - } - - return dead; - } + @Override + public boolean collideBurst( + IManaBurst burst, + EntityThrowable entity, + MovingObjectPosition pos, + boolean isManaBlock, + boolean dead, + ItemStack stack) { + if (!isManaBlock) { + dead = false; + burst.setMinManaLoss(Math.max(0, burst.getMinManaLoss() - 4)); + } + return dead; + } } diff --git a/src/main/java/vazkii/botania/common/item/lens/LensPiston.java b/src/main/java/vazkii/botania/common/item/lens/LensPiston.java index afedaee185..013753dd31 100644 --- a/src/main/java/vazkii/botania/common/item/lens/LensPiston.java +++ b/src/main/java/vazkii/botania/common/item/lens/LensPiston.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jan 24, 2015, 4:46:39 PM (GMT)] */ package vazkii.botania.common.item.lens; @@ -22,29 +22,42 @@ public class LensPiston extends Lens { - @Override - public boolean collideBurst(IManaBurst burst, EntityThrowable entity, MovingObjectPosition pos, boolean isManaBlock, boolean dead, ItemStack stack) { - ChunkCoordinates coords = burst.getBurstSourceChunkCoordinates(); - if((coords.posX != pos.blockX || coords.posY != pos.blockY || coords.posZ != pos.blockZ) && !burst.isFake() && !isManaBlock && !entity.worldObj.isRemote) { - ForgeDirection dir = ForgeDirection.getOrientation(pos.sideHit).getOpposite(); - int x = pos.blockX + dir.offsetX; - int y = pos.blockY + dir.offsetY; - int z = pos.blockZ + dir.offsetZ; + @Override + public boolean collideBurst( + IManaBurst burst, + EntityThrowable entity, + MovingObjectPosition pos, + boolean isManaBlock, + boolean dead, + ItemStack stack) { + ChunkCoordinates coords = burst.getBurstSourceChunkCoordinates(); + if ((coords.posX != pos.blockX || coords.posY != pos.blockY || coords.posZ != pos.blockZ) + && !burst.isFake() + && !isManaBlock + && !entity.worldObj.isRemote) { + ForgeDirection dir = ForgeDirection.getOrientation(pos.sideHit).getOpposite(); + int x = pos.blockX + dir.offsetX; + int y = pos.blockY + dir.offsetY; + int z = pos.blockZ + dir.offsetZ; - if(entity.worldObj.isAirBlock(x, y, z) || entity.worldObj.getBlock(x, y, z).isReplaceable(entity.worldObj, x, y, z)) { - Block block = entity.worldObj.getBlock(pos.blockX, pos.blockY, pos.blockZ); - int meta = entity.worldObj.getBlockMetadata(pos.blockX, pos.blockY, pos.blockZ); - TileEntity tile = entity.worldObj.getTileEntity(pos.blockX, pos.blockY, pos.blockZ); + if (entity.worldObj.isAirBlock(x, y, z) + || entity.worldObj.getBlock(x, y, z).isReplaceable(entity.worldObj, x, y, z)) { + Block block = entity.worldObj.getBlock(pos.blockX, pos.blockY, pos.blockZ); + int meta = entity.worldObj.getBlockMetadata(pos.blockX, pos.blockY, pos.blockZ); + TileEntity tile = entity.worldObj.getTileEntity(pos.blockX, pos.blockY, pos.blockZ); - if(block.getMobilityFlag() == 0 && block != Blocks.obsidian && block.getBlockHardness(entity.worldObj, pos.blockX, pos.blockY, pos.blockZ) >= 0 && tile == null) { - entity.worldObj.setBlockToAir(pos.blockX, pos.blockY, pos.blockZ); - entity.worldObj.setBlock(x, y, z, block, meta, 1 | 2); - entity.worldObj.playAuxSFX(2001, pos.blockX, pos.blockY, pos.blockZ, Block.getIdFromBlock(block) + (meta << 12)); - } - } - } - - return dead; - } + if (block.getMobilityFlag() == 0 + && block != Blocks.obsidian + && block.getBlockHardness(entity.worldObj, pos.blockX, pos.blockY, pos.blockZ) >= 0 + && tile == null) { + entity.worldObj.setBlockToAir(pos.blockX, pos.blockY, pos.blockZ); + entity.worldObj.setBlock(x, y, z, block, meta, 1 | 2); + entity.worldObj.playAuxSFX( + 2001, pos.blockX, pos.blockY, pos.blockZ, Block.getIdFromBlock(block) + (meta << 12)); + } + } + } + return dead; + } } diff --git a/src/main/java/vazkii/botania/common/item/lens/LensPower.java b/src/main/java/vazkii/botania/common/item/lens/LensPower.java index 84ac6d9fbc..30126d8048 100644 --- a/src/main/java/vazkii/botania/common/item/lens/LensPower.java +++ b/src/main/java/vazkii/botania/common/item/lens/LensPower.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jan 24, 2015, 4:33:14 PM (GMT)] */ package vazkii.botania.common.item.lens; @@ -15,11 +15,10 @@ public class LensPower extends Lens { - @Override - public void apply(ItemStack stack, BurstProperties props) { - props.maxMana *= 2; - props.motionModifier *= 0.85F; - props.manaLossPerTick *= 2F; - } - + @Override + public void apply(ItemStack stack, BurstProperties props) { + props.maxMana *= 2; + props.motionModifier *= 0.85F; + props.manaLossPerTick *= 2F; + } } diff --git a/src/main/java/vazkii/botania/common/item/lens/LensRedirect.java b/src/main/java/vazkii/botania/common/item/lens/LensRedirect.java index d4a37bb6ae..62de3ae2c7 100644 --- a/src/main/java/vazkii/botania/common/item/lens/LensRedirect.java +++ b/src/main/java/vazkii/botania/common/item/lens/LensRedirect.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [15/11/2015, 19:13:03 (GMT)] */ package vazkii.botania.common.item.lens; @@ -23,53 +23,69 @@ public class LensRedirect extends Lens { - @Override - public boolean collideBurst(IManaBurst burst, EntityThrowable entity, MovingObjectPosition pos, boolean isManaBlock, boolean dead, ItemStack stack) { - ChunkCoordinates coords = burst.getBurstSourceChunkCoordinates(); - if(!entity.worldObj.isRemote && pos.entityHit == null && coords.posY != -1 && (pos.blockX != coords.posX || pos.blockY != coords.posY || pos.blockZ != coords.posZ)) { - TileEntity tile = entity.worldObj.getTileEntity(pos.blockX, pos.blockY, pos.blockZ); - if(tile != null && tile instanceof IRedirectable) { - if(!burst.isFake()) { - IRedirectable redir = (IRedirectable) tile; - Vector3 tileVec = Vector3.fromTileEntityCenter(tile); - Vector3 sourceVec = new Vector3(coords.posX + 0.5, coords.posY + 0.5, coords.posZ + 0.5); + @Override + public boolean collideBurst( + IManaBurst burst, + EntityThrowable entity, + MovingObjectPosition pos, + boolean isManaBlock, + boolean dead, + ItemStack stack) { + ChunkCoordinates coords = burst.getBurstSourceChunkCoordinates(); + if (!entity.worldObj.isRemote + && pos.entityHit == null + && coords.posY != -1 + && (pos.blockX != coords.posX || pos.blockY != coords.posY || pos.blockZ != coords.posZ)) { + TileEntity tile = entity.worldObj.getTileEntity(pos.blockX, pos.blockY, pos.blockZ); + if (tile != null && tile instanceof IRedirectable) { + if (!burst.isFake()) { + IRedirectable redir = (IRedirectable) tile; + Vector3 tileVec = Vector3.fromTileEntityCenter(tile); + Vector3 sourceVec = new Vector3(coords.posX + 0.5, coords.posY + 0.5, coords.posZ + 0.5); - AxisAlignedBB axis = entity.worldObj.getBlock(coords.posX, coords.posY, coords.posZ).getCollisionBoundingBoxFromPool(entity.worldObj, coords.posX, coords.posY, coords.posZ); - if(axis == null) - axis = AxisAlignedBB.getBoundingBox(coords.posX, coords.posY, coords.posZ, coords.posX + 1, coords.posY + 1, coords.posZ + 1); + AxisAlignedBB axis = entity.worldObj + .getBlock(coords.posX, coords.posY, coords.posZ) + .getCollisionBoundingBoxFromPool(entity.worldObj, coords.posX, coords.posY, coords.posZ); + if (axis == null) + axis = AxisAlignedBB.getBoundingBox( + coords.posX, + coords.posY, + coords.posZ, + coords.posX + 1, + coords.posY + 1, + coords.posZ + 1); - if(!sourceVec.isInside(axis)) - sourceVec = new Vector3(axis.minX + (axis.maxX - axis.minX) / 2, axis.minY + (axis.maxY - axis.minY) / 2, axis.minZ + (axis.maxZ - axis.minZ) / 2); + if (!sourceVec.isInside(axis)) + sourceVec = new Vector3( + axis.minX + (axis.maxX - axis.minX) / 2, + axis.minY + (axis.maxY - axis.minY) / 2, + axis.minZ + (axis.maxZ - axis.minZ) / 2); - Vector3 diffVec = sourceVec.copy().sub(tileVec); - Vector3 diffVec2D = new Vector3(diffVec.x, diffVec.z, 0); - Vector3 rotVec = new Vector3(0, 1, 0); - double angle = rotVec.angle(diffVec2D) / Math.PI * 180.0; + Vector3 diffVec = sourceVec.copy().sub(tileVec); + Vector3 diffVec2D = new Vector3(diffVec.x, diffVec.z, 0); + Vector3 rotVec = new Vector3(0, 1, 0); + double angle = rotVec.angle(diffVec2D) / Math.PI * 180.0; - if(sourceVec.x < tileVec.x) - angle = -angle; + if (sourceVec.x < tileVec.x) angle = -angle; - redir.setRotationX((float) angle + 90F); + redir.setRotationX((float) angle + 90F); - rotVec = new Vector3(diffVec.x, 0, diffVec.z); - angle = diffVec.angle(rotVec) * 180F / Math.PI; - if(sourceVec.y < tileVec.y) - angle = -angle; - redir.setRotationY((float) angle); + rotVec = new Vector3(diffVec.x, 0, diffVec.z); + angle = diffVec.angle(rotVec) * 180F / Math.PI; + if (sourceVec.y < tileVec.y) angle = -angle; + redir.setRotationY((float) angle); - redir.commitRedirection(); - if(redir instanceof IThrottledPacket) - ((IThrottledPacket) redir).markDispatchable(); - } - } - } + redir.commitRedirection(); + if (redir instanceof IThrottledPacket) ((IThrottledPacket) redir).markDispatchable(); + } + } + } - if(!isManaBlock) { - dead = false; - burst.setMinManaLoss(Math.max(0, burst.getMinManaLoss() - 4)); - } - - return dead; - } + if (!isManaBlock) { + dead = false; + burst.setMinManaLoss(Math.max(0, burst.getMinManaLoss() - 4)); + } + return dead; + } } diff --git a/src/main/java/vazkii/botania/common/item/lens/LensSpeed.java b/src/main/java/vazkii/botania/common/item/lens/LensSpeed.java index d7ada90f5b..fb96b4ed67 100644 --- a/src/main/java/vazkii/botania/common/item/lens/LensSpeed.java +++ b/src/main/java/vazkii/botania/common/item/lens/LensSpeed.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jan 24, 2015, 4:32:47 PM (GMT)] */ package vazkii.botania.common.item.lens; @@ -15,12 +15,11 @@ public class LensSpeed extends Lens { - @Override - public void apply(ItemStack stack, BurstProperties props) { - props.motionModifier *= 2F; - props.maxMana *= 0.75F; - props.ticksBeforeManaLoss /= 3F; - props.manaLossPerTick *= 2F; - } - + @Override + public void apply(ItemStack stack, BurstProperties props) { + props.motionModifier *= 2F; + props.maxMana *= 0.75F; + props.ticksBeforeManaLoss /= 3F; + props.manaLossPerTick *= 2F; + } } diff --git a/src/main/java/vazkii/botania/common/item/lens/LensStorm.java b/src/main/java/vazkii/botania/common/item/lens/LensStorm.java index cfbbe061da..bc33a2bd90 100644 --- a/src/main/java/vazkii/botania/common/item/lens/LensStorm.java +++ b/src/main/java/vazkii/botania/common/item/lens/LensStorm.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jul 25, 2015, 2:10:26 AM (GMT)] */ package vazkii.botania.common.item.lens; @@ -18,15 +18,23 @@ public class LensStorm extends Lens { - @Override - public boolean collideBurst(IManaBurst burst, EntityThrowable entity, MovingObjectPosition pos, boolean isManaBlock, boolean dead, ItemStack stack) { - if(!burst.isFake()) { - ChunkCoordinates coords = burst.getBurstSourceChunkCoordinates(); - if(!entity.worldObj.isRemote && pos.entityHit == null && !isManaBlock && (pos.blockX != coords.posX || pos.blockY != coords.posY || pos.blockZ != coords.posZ)) - entity.worldObj.createExplosion(entity, entity.posX, entity.posY, entity.posZ, 5F, true); - } else dead = false; - - return dead; - } + @Override + public boolean collideBurst( + IManaBurst burst, + EntityThrowable entity, + MovingObjectPosition pos, + boolean isManaBlock, + boolean dead, + ItemStack stack) { + if (!burst.isFake()) { + ChunkCoordinates coords = burst.getBurstSourceChunkCoordinates(); + if (!entity.worldObj.isRemote + && pos.entityHit == null + && !isManaBlock + && (pos.blockX != coords.posX || pos.blockY != coords.posY || pos.blockZ != coords.posZ)) + entity.worldObj.createExplosion(entity, entity.posX, entity.posY, entity.posZ, 5F, true); + } else dead = false; + return dead; + } } diff --git a/src/main/java/vazkii/botania/common/item/lens/LensTime.java b/src/main/java/vazkii/botania/common/item/lens/LensTime.java index 14aa471f4c..f5615b7154 100644 --- a/src/main/java/vazkii/botania/common/item/lens/LensTime.java +++ b/src/main/java/vazkii/botania/common/item/lens/LensTime.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jan 24, 2015, 4:33:41 PM (GMT)] */ package vazkii.botania.common.item.lens; @@ -15,10 +15,9 @@ public class LensTime extends Lens { - @Override - public void apply(ItemStack stack, BurstProperties props) { - props.ticksBeforeManaLoss *= 2.25F; - props.motionModifier *= 0.8F; - } - + @Override + public void apply(ItemStack stack, BurstProperties props) { + props.ticksBeforeManaLoss *= 2.25F; + props.motionModifier *= 0.8F; + } } diff --git a/src/main/java/vazkii/botania/common/item/lens/LensWarp.java b/src/main/java/vazkii/botania/common/item/lens/LensWarp.java index 34f4d0dd83..9dceb985fe 100644 --- a/src/main/java/vazkii/botania/common/item/lens/LensWarp.java +++ b/src/main/java/vazkii/botania/common/item/lens/LensWarp.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Feb 8, 2015, 2:17:01 PM (GMT)] */ package vazkii.botania.common.item.lens; @@ -20,25 +20,33 @@ public class LensWarp extends Lens { - @Override - public boolean collideBurst(IManaBurst burst, EntityThrowable entity, MovingObjectPosition pos, boolean isManaBlock, boolean dead, ItemStack stack) { - if(burst.isFake()) - return dead; - - Block block = entity.worldObj.getBlock(pos.blockX, pos.blockY, pos.blockZ); - if(block == ModBlocks.pistonRelay) { - String key = BlockPistonRelay.mappedPositions.get(BlockPistonRelay.getCoordsAsString(entity.worldObj.provider.dimensionId, pos.blockX, pos.blockY, pos.blockZ)); - if(key != null) { - String[] tokens = key.split(":"); - int worldId = Integer.parseInt(tokens[0]), x = Integer.parseInt(tokens[1]), y = Integer.parseInt(tokens[2]), z = Integer.parseInt(tokens[3]); - if(worldId == entity.worldObj.provider.dimensionId) { - entity.setPosition(x + 0.5, y + 0.5, z + 0.5); - burst.setCollidedAt(x, y, z); - return false; - } - } - } - return dead; - } + @Override + public boolean collideBurst( + IManaBurst burst, + EntityThrowable entity, + MovingObjectPosition pos, + boolean isManaBlock, + boolean dead, + ItemStack stack) { + if (burst.isFake()) return dead; + Block block = entity.worldObj.getBlock(pos.blockX, pos.blockY, pos.blockZ); + if (block == ModBlocks.pistonRelay) { + String key = BlockPistonRelay.mappedPositions.get(BlockPistonRelay.getCoordsAsString( + entity.worldObj.provider.dimensionId, pos.blockX, pos.blockY, pos.blockZ)); + if (key != null) { + String[] tokens = key.split(":"); + int worldId = Integer.parseInt(tokens[0]), + x = Integer.parseInt(tokens[1]), + y = Integer.parseInt(tokens[2]), + z = Integer.parseInt(tokens[3]); + if (worldId == entity.worldObj.provider.dimensionId) { + entity.setPosition(x + 0.5, y + 0.5, z + 0.5); + burst.setCollidedAt(x, y, z); + return false; + } + } + } + return dead; + } } diff --git a/src/main/java/vazkii/botania/common/item/lens/LensWeight.java b/src/main/java/vazkii/botania/common/item/lens/LensWeight.java index 205d92ac9e..88789ca141 100644 --- a/src/main/java/vazkii/botania/common/item/lens/LensWeight.java +++ b/src/main/java/vazkii/botania/common/item/lens/LensWeight.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jan 24, 2015, 4:43:16 PM (GMT)] */ package vazkii.botania.common.item.lens; @@ -20,27 +20,36 @@ public class LensWeight extends Lens { - @Override - public boolean collideBurst(IManaBurst burst, EntityThrowable entity, MovingObjectPosition pos, boolean isManaBlock, boolean dead, ItemStack stack) { - if(!burst.isFake()) { - int x = pos.blockX; - int y = pos.blockY; - int z = pos.blockZ; - int harvestLevel = ConfigHandler.harvestLevelWeight; - - Block block = entity.worldObj.getBlock(x, y, z); - Block blockBelow = entity.worldObj.getBlock(x, y - 1, z); - int meta = entity.worldObj.getBlockMetadata(x, y, z); - int neededHarvestLevel = block.getHarvestLevel(meta); - - if(blockBelow.isAir(entity.worldObj, x, y - 1, z) && block.getBlockHardness(entity.worldObj, x, y, z) != -1 && neededHarvestLevel <= harvestLevel && entity.worldObj.getTileEntity(x, y, z) == null && block.canSilkHarvest(entity.worldObj, null, x, y, z, meta)) { - EntityFallingBlock falling = new EntityFallingBlock(entity.worldObj, x + 0.5, y + 0.5, z + 0.5, block, meta); - if(!entity.worldObj.isRemote) - entity.worldObj.spawnEntityInWorld(falling); - } - } + @Override + public boolean collideBurst( + IManaBurst burst, + EntityThrowable entity, + MovingObjectPosition pos, + boolean isManaBlock, + boolean dead, + ItemStack stack) { + if (!burst.isFake()) { + int x = pos.blockX; + int y = pos.blockY; + int z = pos.blockZ; + int harvestLevel = ConfigHandler.harvestLevelWeight; - return dead; - } + Block block = entity.worldObj.getBlock(x, y, z); + Block blockBelow = entity.worldObj.getBlock(x, y - 1, z); + int meta = entity.worldObj.getBlockMetadata(x, y, z); + int neededHarvestLevel = block.getHarvestLevel(meta); + if (blockBelow.isAir(entity.worldObj, x, y - 1, z) + && block.getBlockHardness(entity.worldObj, x, y, z) != -1 + && neededHarvestLevel <= harvestLevel + && entity.worldObj.getTileEntity(x, y, z) == null + && block.canSilkHarvest(entity.worldObj, null, x, y, z, meta)) { + EntityFallingBlock falling = + new EntityFallingBlock(entity.worldObj, x + 0.5, y + 0.5, z + 0.5, block, meta); + if (!entity.worldObj.isRemote) entity.worldObj.spawnEntityInWorld(falling); + } + } + + return dead; + } } diff --git a/src/main/java/vazkii/botania/common/item/material/ItemDye.java b/src/main/java/vazkii/botania/common/item/material/ItemDye.java index c209a0a83d..bc7db227ba 100644 --- a/src/main/java/vazkii/botania/common/item/material/ItemDye.java +++ b/src/main/java/vazkii/botania/common/item/material/ItemDye.java @@ -2,74 +2,80 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jan 19, 2014, 4:10:47 PM (GMT)] */ package vazkii.botania.common.item.material; import net.minecraft.block.Block; import net.minecraft.entity.EntityLivingBase; -import net.minecraft.entity.item.EntityItem; import net.minecraft.entity.passive.EntitySheep; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.init.Blocks; import net.minecraft.item.ItemStack; import net.minecraft.tileentity.TileEntity; import net.minecraft.world.World; -import vazkii.botania.api.internal.VanillaPacketDispatcher; import vazkii.botania.api.item.IDyablePool; -import vazkii.botania.api.item.IManaDissolvable; -import vazkii.botania.api.mana.IManaPool; import vazkii.botania.common.item.Item16Colors; import vazkii.botania.common.lib.LibItemNames; public class ItemDye extends Item16Colors { - public ItemDye() { - super(LibItemNames.DYE); - } + public ItemDye() { + super(LibItemNames.DYE); + } - @Override - public boolean onItemUse(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, World par3World, int par4, int par5, int par6, int par7, float par8, float par9, float par10) { - Block block = par3World.getBlock(par4, par5, par6); - int meta = par1ItemStack.getItemDamage(); - if(meta != par3World.getBlockMetadata(par4, par5, par6) && (block == Blocks.wool || block == Blocks.carpet)) { - par3World.setBlockMetadataWithNotify(par4, par5, par6, meta, 1 | 2); - par1ItemStack.stackSize--; - return true; - } - - TileEntity tile = par3World.getTileEntity(par4, par5, par6); - if(tile instanceof IDyablePool) { - IDyablePool dyable = (IDyablePool) tile; - int itemMeta = par1ItemStack.getItemDamage(); - if(meta != dyable.getColor()) { - dyable.setColor(meta); - par1ItemStack.stackSize--; - return true; - } - } - - return false; - } + @Override + public boolean onItemUse( + ItemStack par1ItemStack, + EntityPlayer par2EntityPlayer, + World par3World, + int par4, + int par5, + int par6, + int par7, + float par8, + float par9, + float par10) { + Block block = par3World.getBlock(par4, par5, par6); + int meta = par1ItemStack.getItemDamage(); + if (meta != par3World.getBlockMetadata(par4, par5, par6) && (block == Blocks.wool || block == Blocks.carpet)) { + par3World.setBlockMetadataWithNotify(par4, par5, par6, meta, 1 | 2); + par1ItemStack.stackSize--; + return true; + } - @Override - public boolean itemInteractionForEntity(ItemStack p_111207_1_, EntityPlayer p_111207_2_, EntityLivingBase p_111207_3_) { - if(p_111207_3_ instanceof EntitySheep) { - EntitySheep entitysheep = (EntitySheep)p_111207_3_; - int i = p_111207_1_.getItemDamage(); + TileEntity tile = par3World.getTileEntity(par4, par5, par6); + if (tile instanceof IDyablePool) { + IDyablePool dyable = (IDyablePool) tile; + int itemMeta = par1ItemStack.getItemDamage(); + if (meta != dyable.getColor()) { + dyable.setColor(meta); + par1ItemStack.stackSize--; + return true; + } + } - if(!entitysheep.getSheared() && entitysheep.getFleeceColor() != i) { - entitysheep.setFleeceColor(i); - --p_111207_1_.stackSize; - } + return false; + } - return true; - } - return false; - } + @Override + public boolean itemInteractionForEntity( + ItemStack p_111207_1_, EntityPlayer p_111207_2_, EntityLivingBase p_111207_3_) { + if (p_111207_3_ instanceof EntitySheep) { + EntitySheep entitysheep = (EntitySheep) p_111207_3_; + int i = p_111207_1_.getItemDamage(); + if (!entitysheep.getSheared() && entitysheep.getFleeceColor() != i) { + entitysheep.setFleeceColor(i); + --p_111207_1_.stackSize; + } + + return true; + } + return false; + } } diff --git a/src/main/java/vazkii/botania/common/item/material/ItemManaPetal.java b/src/main/java/vazkii/botania/common/item/material/ItemManaPetal.java index 0c35bf25a2..3183e64697 100644 --- a/src/main/java/vazkii/botania/common/item/material/ItemManaPetal.java +++ b/src/main/java/vazkii/botania/common/item/material/ItemManaPetal.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Feb 2, 2014, 12:57:22 PM (GMT)] */ package vazkii.botania.common.item.material; @@ -18,17 +18,17 @@ public class ItemManaPetal extends Item16Colors implements IFlowerComponent { - public ItemManaPetal() { - super(LibItemNames.MANA_PETAL); - } + public ItemManaPetal() { + super(LibItemNames.MANA_PETAL); + } - @Override - public boolean canFit(ItemStack stack, IInventory apothecary) { - return true; - } + @Override + public boolean canFit(ItemStack stack, IInventory apothecary) { + return true; + } - @Override - public int getParticleColor(ItemStack stack) { - return getColorFromItemStack(stack, 0); - } + @Override + public int getParticleColor(ItemStack stack) { + return getColorFromItemStack(stack, 0); + } } diff --git a/src/main/java/vazkii/botania/common/item/material/ItemManaResource.java b/src/main/java/vazkii/botania/common/item/material/ItemManaResource.java index c3693a99a0..9e727fce97 100644 --- a/src/main/java/vazkii/botania/common/item/material/ItemManaResource.java +++ b/src/main/java/vazkii/botania/common/item/material/ItemManaResource.java @@ -2,17 +2,19 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jan 30, 2014, 4:49:16 PM (GMT)] */ package vazkii.botania.common.item.material; +import cpw.mods.fml.common.eventhandler.SubscribeEvent; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; import java.awt.Color; import java.util.List; - import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.entity.item.EntityItem; @@ -39,153 +41,160 @@ import vazkii.botania.common.item.ItemMod; import vazkii.botania.common.item.equipment.tool.ToolCommons; import vazkii.botania.common.lib.LibItemNames; -import cpw.mods.fml.common.eventhandler.SubscribeEvent; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; public class ItemManaResource extends ItemMod implements IFlowerComponent, IElvenItem, IPickupAchievement { - final int types = 24; - IIcon[] icons; - - // begin dank_memes - public IIcon tailIcon = null; - public IIcon phiFlowerIcon = null; - public IIcon goldfishIcon = null; - public IIcon nerfBatIcon = null; - // end dank_memes - - public ItemManaResource() { - super(); - setUnlocalizedName(LibItemNames.MANA_RESOURCE); - setHasSubtypes(true); - MinecraftForge.EVENT_BUS.register(this); - } - - @SubscribeEvent - public void onPlayerInteract(PlayerInteractEvent event) { - boolean rightEvent = event.action == Action.RIGHT_CLICK_AIR; - ItemStack stack = event.entityPlayer.getCurrentEquippedItem(); - boolean correctStack = stack != null && stack.getItem() == Items.glass_bottle; - boolean ender = event.world.provider.dimensionId == 1; - - if(rightEvent && correctStack && ender) { - MovingObjectPosition pos = ToolCommons.raytraceFromEntity(event.world, event.entityPlayer, false, 5F); - - if(pos == null) { - ItemStack stack1 = new ItemStack(this, 1, 15); - event.entityPlayer.addStat(ModAchievements.enderAirMake, 1); - - if(!event.entityPlayer.inventory.addItemStackToInventory(stack1)) - event.entityPlayer.dropPlayerItemWithRandomChoice(stack1, true); - - stack.stackSize--; - if(stack.stackSize == 0) - event.entityPlayer.inventory.setInventorySlotContents(event.entityPlayer.inventory.currentItem, null); - - if(event.world.isRemote) - event.entityPlayer.swingItem(); - else event.world.playSoundAtEntity(event.entityPlayer, "random.pop", 0.5F, 1F); - } - } - } - - @Override - public boolean onItemUse(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, World par3World, int par4, int par5, int par6, int par7, float par8, float par9, float par10) { - if(par1ItemStack.getItemDamage() == 4 || par1ItemStack.getItemDamage() == 14) - return EntityDoppleganger.spawn(par2EntityPlayer, par1ItemStack, par3World, par4, par5, par6, par1ItemStack.getItemDamage() == 14); - else if(par1ItemStack.getItemDamage() == 20 && net.minecraft.item.ItemDye.applyBonemeal(par1ItemStack, par3World, par4, par5, par6, par2EntityPlayer)) { - if(!par3World.isRemote) - par3World.playAuxSFX(2005, par4, par5, par6, 0); - - return true; - } - - return super.onItemUse(par1ItemStack, par2EntityPlayer, par3World, par4, par5, par6, par7, par8, par9, par10); - } - - @Override - public ItemStack onItemRightClick(ItemStack par1ItemStack, World par3World, EntityPlayer par2EntityPlayer) { - if(par1ItemStack.getItemDamage() == 15) { - if(!par2EntityPlayer.capabilities.isCreativeMode) - --par1ItemStack.stackSize; - - par3World.playSoundAtEntity(par2EntityPlayer, "random.bow", 0.5F, 0.4F / (itemRand.nextFloat() * 0.4F + 0.8F)); - - if(!par3World.isRemote) - par3World.spawnEntityInWorld(new EntityEnderAirBottle(par3World, par2EntityPlayer)); - else par2EntityPlayer.swingItem(); - } - - return par1ItemStack; - } - - @Override - @SideOnly(Side.CLIENT) - public void getSubItems(Item par1, CreativeTabs par2CreativeTabs, List par3List) { - for(int i = 0; i < types; i++) - if(Botania.gardenOfGlassLoaded || i != 20 && i != 21) - par3List.add(new ItemStack(par1, 1, i)); - } - - @Override - @SideOnly(Side.CLIENT) - public void registerIcons(IIconRegister par1IconRegister) { - icons = new IIcon[types]; - for(int i = 0; i < icons.length; i++) - icons[i] = IconHelper.forName(par1IconRegister, LibItemNames.MANA_RESOURCE_NAMES[i]); - - tailIcon = IconHelper.forName(par1IconRegister, "tail"); - phiFlowerIcon = IconHelper.forName(par1IconRegister, "phiFlower"); - goldfishIcon = IconHelper.forName(par1IconRegister, "goldfish"); - nerfBatIcon = IconHelper.forName(par1IconRegister, "nerfBat"); - } - - @Override - @SideOnly(Side.CLIENT) - public int getColorFromItemStack(ItemStack par1ItemStack, int par2) { - if(par1ItemStack.getItemDamage() == 5 || par1ItemStack.getItemDamage() == 14) - return Color.HSBtoRGB(Botania.proxy.getWorldElapsedTicks() * 2 % 360 / 360F, 0.25F, 1F); - - return 0xFFFFFF; - } - - @Override - public String getUnlocalizedName(ItemStack par1ItemStack) { - return "item." + LibItemNames.MANA_RESOURCE_NAMES[Math.min(types - 1, par1ItemStack.getItemDamage())]; - } - - @Override - @SideOnly(Side.CLIENT) - public IIcon getIconFromDamage(int par1) { - return icons[Math.min(icons.length - 1, par1)]; - } - - @Override - public boolean canFit(ItemStack stack, IInventory apothecary) { - int meta = stack.getItemDamage(); - return meta == 6 || meta == 8 || meta == 5 || meta == 23; - } - - @Override - public int getParticleColor(ItemStack stack) { - return 0x9b0000; - } - - @Override - public boolean isElvenItem(ItemStack stack) { - int meta = stack.getItemDamage(); - return meta == 7 || meta == 8 || meta == 9; - } - - @Override - public ItemStack getContainerItem(ItemStack itemStack) { - return itemStack.getItemDamage() == 11 ? itemStack.copy() : null; - } - - @Override - public Achievement getAchievementOnPickup(ItemStack stack, EntityPlayer player, EntityItem item) { - return stack.getItemDamage() == 4 ? ModAchievements.terrasteelPickup : null; - } - + final int types = 24; + IIcon[] icons; + + // begin dank_memes + public IIcon tailIcon = null; + public IIcon phiFlowerIcon = null; + public IIcon goldfishIcon = null; + public IIcon nerfBatIcon = null; + // end dank_memes + + public ItemManaResource() { + super(); + setUnlocalizedName(LibItemNames.MANA_RESOURCE); + setHasSubtypes(true); + MinecraftForge.EVENT_BUS.register(this); + } + + @SubscribeEvent + public void onPlayerInteract(PlayerInteractEvent event) { + boolean rightEvent = event.action == Action.RIGHT_CLICK_AIR; + ItemStack stack = event.entityPlayer.getCurrentEquippedItem(); + boolean correctStack = stack != null && stack.getItem() == Items.glass_bottle; + boolean ender = event.world.provider.dimensionId == 1; + + if (rightEvent && correctStack && ender) { + MovingObjectPosition pos = ToolCommons.raytraceFromEntity(event.world, event.entityPlayer, false, 5F); + + if (pos == null) { + ItemStack stack1 = new ItemStack(this, 1, 15); + event.entityPlayer.addStat(ModAchievements.enderAirMake, 1); + + if (!event.entityPlayer.inventory.addItemStackToInventory(stack1)) + event.entityPlayer.dropPlayerItemWithRandomChoice(stack1, true); + + stack.stackSize--; + if (stack.stackSize == 0) + event.entityPlayer.inventory.setInventorySlotContents( + event.entityPlayer.inventory.currentItem, null); + + if (event.world.isRemote) event.entityPlayer.swingItem(); + else event.world.playSoundAtEntity(event.entityPlayer, "random.pop", 0.5F, 1F); + } + } + } + + @Override + public boolean onItemUse( + ItemStack par1ItemStack, + EntityPlayer par2EntityPlayer, + World par3World, + int par4, + int par5, + int par6, + int par7, + float par8, + float par9, + float par10) { + if (par1ItemStack.getItemDamage() == 4 || par1ItemStack.getItemDamage() == 14) + return EntityDoppleganger.spawn( + par2EntityPlayer, par1ItemStack, par3World, par4, par5, par6, par1ItemStack.getItemDamage() == 14); + else if (par1ItemStack.getItemDamage() == 20 + && net.minecraft.item.ItemDye.applyBonemeal( + par1ItemStack, par3World, par4, par5, par6, par2EntityPlayer)) { + if (!par3World.isRemote) par3World.playAuxSFX(2005, par4, par5, par6, 0); + + return true; + } + + return super.onItemUse(par1ItemStack, par2EntityPlayer, par3World, par4, par5, par6, par7, par8, par9, par10); + } + + @Override + public ItemStack onItemRightClick(ItemStack par1ItemStack, World par3World, EntityPlayer par2EntityPlayer) { + if (par1ItemStack.getItemDamage() == 15) { + if (!par2EntityPlayer.capabilities.isCreativeMode) --par1ItemStack.stackSize; + + par3World.playSoundAtEntity( + par2EntityPlayer, "random.bow", 0.5F, 0.4F / (itemRand.nextFloat() * 0.4F + 0.8F)); + + if (!par3World.isRemote) + par3World.spawnEntityInWorld(new EntityEnderAirBottle(par3World, par2EntityPlayer)); + else par2EntityPlayer.swingItem(); + } + + return par1ItemStack; + } + + @Override + @SideOnly(Side.CLIENT) + public void getSubItems(Item par1, CreativeTabs par2CreativeTabs, List par3List) { + for (int i = 0; i < types; i++) + if (Botania.gardenOfGlassLoaded || i != 20 && i != 21) par3List.add(new ItemStack(par1, 1, i)); + } + + @Override + @SideOnly(Side.CLIENT) + public void registerIcons(IIconRegister par1IconRegister) { + icons = new IIcon[types]; + for (int i = 0; i < icons.length; i++) + icons[i] = IconHelper.forName(par1IconRegister, LibItemNames.MANA_RESOURCE_NAMES[i]); + + tailIcon = IconHelper.forName(par1IconRegister, "tail"); + phiFlowerIcon = IconHelper.forName(par1IconRegister, "phiFlower"); + goldfishIcon = IconHelper.forName(par1IconRegister, "goldfish"); + nerfBatIcon = IconHelper.forName(par1IconRegister, "nerfBat"); + } + + @Override + @SideOnly(Side.CLIENT) + public int getColorFromItemStack(ItemStack par1ItemStack, int par2) { + if (par1ItemStack.getItemDamage() == 5 || par1ItemStack.getItemDamage() == 14) + return Color.HSBtoRGB(Botania.proxy.getWorldElapsedTicks() * 2 % 360 / 360F, 0.25F, 1F); + + return 0xFFFFFF; + } + + @Override + public String getUnlocalizedName(ItemStack par1ItemStack) { + return "item." + LibItemNames.MANA_RESOURCE_NAMES[Math.min(types - 1, par1ItemStack.getItemDamage())]; + } + + @Override + @SideOnly(Side.CLIENT) + public IIcon getIconFromDamage(int par1) { + return icons[Math.min(icons.length - 1, par1)]; + } + + @Override + public boolean canFit(ItemStack stack, IInventory apothecary) { + int meta = stack.getItemDamage(); + return meta == 6 || meta == 8 || meta == 5 || meta == 23; + } + + @Override + public int getParticleColor(ItemStack stack) { + return 0x9b0000; + } + + @Override + public boolean isElvenItem(ItemStack stack) { + int meta = stack.getItemDamage(); + return meta == 7 || meta == 8 || meta == 9; + } + + @Override + public ItemStack getContainerItem(ItemStack itemStack) { + return itemStack.getItemDamage() == 11 ? itemStack.copy() : null; + } + + @Override + public Achievement getAchievementOnPickup(ItemStack stack, EntityPlayer player, EntityItem item) { + return stack.getItemDamage() == 4 ? ModAchievements.terrasteelPickup : null; + } } diff --git a/src/main/java/vazkii/botania/common/item/material/ItemPestleAndMortar.java b/src/main/java/vazkii/botania/common/item/material/ItemPestleAndMortar.java index 23e8365376..69f4d14ace 100644 --- a/src/main/java/vazkii/botania/common/item/material/ItemPestleAndMortar.java +++ b/src/main/java/vazkii/botania/common/item/material/ItemPestleAndMortar.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jan 19, 2014, 7:00:34 PM (GMT)] */ package vazkii.botania.common.item.material; @@ -16,16 +16,15 @@ public class ItemPestleAndMortar extends ItemMod { - public ItemPestleAndMortar() { - super(); - setMaxStackSize(1); - setContainerItem(this); - setUnlocalizedName(LibItemNames.PESTLE_AND_MORTAR); - } - - @Override - public boolean doesContainerItemLeaveCraftingGrid(ItemStack par1ItemStack) { - return false; - } + public ItemPestleAndMortar() { + super(); + setMaxStackSize(1); + setContainerItem(this); + setUnlocalizedName(LibItemNames.PESTLE_AND_MORTAR); + } + @Override + public boolean doesContainerItemLeaveCraftingGrid(ItemStack par1ItemStack) { + return false; + } } diff --git a/src/main/java/vazkii/botania/common/item/material/ItemPetal.java b/src/main/java/vazkii/botania/common/item/material/ItemPetal.java index 4f11fbec43..e5224fbf86 100644 --- a/src/main/java/vazkii/botania/common/item/material/ItemPetal.java +++ b/src/main/java/vazkii/botania/common/item/material/ItemPetal.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jan 19, 2014, 3:28:21 PM (GMT)] */ package vazkii.botania.common.item.material; @@ -21,31 +21,40 @@ public class ItemPetal extends Item16Colors implements IFlowerComponent { - public ItemPetal() { - super(LibItemNames.PETAL); - } - - @Override - public boolean onItemUse(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, World par3World, int par4, int par5, int par6, int par7, float par8, float par9, float par10) { - ItemStack stackToPlace = new ItemStack(ModBlocks.buriedPetals, 1, par1ItemStack.getItemDamage()); - stackToPlace.tryPlaceItemIntoWorld(par2EntityPlayer, par3World, par4, par5, par6, par7, par8, par9, par10); - - if(stackToPlace.stackSize == 0) { - if(!par2EntityPlayer.capabilities.isCreativeMode) - par1ItemStack.stackSize--; - - return true; - } - return false; - } - - @Override - public boolean canFit(ItemStack stack, IInventory apothecary) { - return true; - } - - @Override - public int getParticleColor(ItemStack stack) { - return getColorFromItemStack(stack, 0); - } + public ItemPetal() { + super(LibItemNames.PETAL); + } + + @Override + public boolean onItemUse( + ItemStack par1ItemStack, + EntityPlayer par2EntityPlayer, + World par3World, + int par4, + int par5, + int par6, + int par7, + float par8, + float par9, + float par10) { + ItemStack stackToPlace = new ItemStack(ModBlocks.buriedPetals, 1, par1ItemStack.getItemDamage()); + stackToPlace.tryPlaceItemIntoWorld(par2EntityPlayer, par3World, par4, par5, par6, par7, par8, par9, par10); + + if (stackToPlace.stackSize == 0) { + if (!par2EntityPlayer.capabilities.isCreativeMode) par1ItemStack.stackSize--; + + return true; + } + return false; + } + + @Override + public boolean canFit(ItemStack stack, IInventory apothecary) { + return true; + } + + @Override + public int getParticleColor(ItemStack stack) { + return getColorFromItemStack(stack, 0); + } } diff --git a/src/main/java/vazkii/botania/common/item/material/ItemQuartz.java b/src/main/java/vazkii/botania/common/item/material/ItemQuartz.java index 0ab289299a..a7660227ec 100644 --- a/src/main/java/vazkii/botania/common/item/material/ItemQuartz.java +++ b/src/main/java/vazkii/botania/common/item/material/ItemQuartz.java @@ -2,16 +2,15 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jun 11, 2014, 2:16:47 AM (GMT)] */ package vazkii.botania.common.item.material; import java.util.List; - import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.item.Item; @@ -25,43 +24,41 @@ public class ItemQuartz extends ItemMod implements IElvenItem { - private static final int SUBTYPES = 7; - IIcon[] icons; + private static final int SUBTYPES = 7; + IIcon[] icons; - public ItemQuartz() { - setUnlocalizedName(LibItemNames.QUARTZ); - setHasSubtypes(true); - } + public ItemQuartz() { + setUnlocalizedName(LibItemNames.QUARTZ); + setHasSubtypes(true); + } - @Override - public void getSubItems(Item item, CreativeTabs tab, List list) { - for(int i = ConfigHandler.darkQuartzEnabled ? 0 : 1; i < SUBTYPES; i++) - list.add(new ItemStack(item, 1, i)); - } + @Override + public void getSubItems(Item item, CreativeTabs tab, List list) { + for (int i = ConfigHandler.darkQuartzEnabled ? 0 : 1; i < SUBTYPES; i++) list.add(new ItemStack(item, 1, i)); + } - @Override - public void registerIcons(IIconRegister par1IconRegister) { - icons = new IIcon[SUBTYPES]; - for(int i = 0; i < icons.length; i++) - icons[i] = IconHelper.forItem(par1IconRegister, this, i); - } + @Override + public void registerIcons(IIconRegister par1IconRegister) { + icons = new IIcon[SUBTYPES]; + for (int i = 0; i < icons.length; i++) icons[i] = IconHelper.forItem(par1IconRegister, this, i); + } - @Override - public IIcon getIconFromDamage(int par1) { - return icons[Math.min(icons.length - 1, par1)]; - } + @Override + public IIcon getIconFromDamage(int par1) { + return icons[Math.min(icons.length - 1, par1)]; + } - @Override - public String getUnlocalizedName(ItemStack par1ItemStack) { - return getUnlocalizedNameLazy(par1ItemStack) + par1ItemStack.getItemDamage(); - } + @Override + public String getUnlocalizedName(ItemStack par1ItemStack) { + return getUnlocalizedNameLazy(par1ItemStack) + par1ItemStack.getItemDamage(); + } - String getUnlocalizedNameLazy(ItemStack par1ItemStack) { - return super.getUnlocalizedName(par1ItemStack); - } + String getUnlocalizedNameLazy(ItemStack par1ItemStack) { + return super.getUnlocalizedName(par1ItemStack); + } - @Override - public boolean isElvenItem(ItemStack stack) { - return stack.getItemDamage() == 5; - } + @Override + public boolean isElvenItem(ItemStack stack) { + return stack.getItemDamage() == 5; + } } diff --git a/src/main/java/vazkii/botania/common/item/material/ItemRune.java b/src/main/java/vazkii/botania/common/item/material/ItemRune.java index e678f36762..d6eab95e3b 100644 --- a/src/main/java/vazkii/botania/common/item/material/ItemRune.java +++ b/src/main/java/vazkii/botania/common/item/material/ItemRune.java @@ -2,16 +2,15 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Feb 7, 2014, 9:46:24 PM (GMT)] */ package vazkii.botania.common.item.material; import java.util.List; - import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.entity.item.EntityItem; @@ -30,54 +29,51 @@ public class ItemRune extends ItemMod implements IFlowerComponent, IPickupAchievement { - IIcon[] icons; - - public ItemRune() { - super(); - setHasSubtypes(true); - setUnlocalizedName(LibItemNames.RUNE); - } + IIcon[] icons; - @Override - public void registerIcons(IIconRegister par1IconRegister) { - icons = new IIcon[16]; - for(int i = 0; i < icons.length; i++) - icons[i] = IconHelper.forItem(par1IconRegister, this, i); - } + public ItemRune() { + super(); + setHasSubtypes(true); + setUnlocalizedName(LibItemNames.RUNE); + } - @Override - public IIcon getIconFromDamage(int par1) { - return icons[Math.min(icons.length - 1, par1)]; - } + @Override + public void registerIcons(IIconRegister par1IconRegister) { + icons = new IIcon[16]; + for (int i = 0; i < icons.length; i++) icons[i] = IconHelper.forItem(par1IconRegister, this, i); + } - @Override - public void getSubItems(Item par1, CreativeTabs par2CreativeTabs, List par3List) { - for(int i = 0; i < 16; i++) - par3List.add(new ItemStack(par1, 1, i)); - } + @Override + public IIcon getIconFromDamage(int par1) { + return icons[Math.min(icons.length - 1, par1)]; + } - @Override - public String getUnlocalizedName(ItemStack par1ItemStack) { - return getUnlocalizedNameLazy(par1ItemStack) + par1ItemStack.getItemDamage(); - } + @Override + public void getSubItems(Item par1, CreativeTabs par2CreativeTabs, List par3List) { + for (int i = 0; i < 16; i++) par3List.add(new ItemStack(par1, 1, i)); + } - String getUnlocalizedNameLazy(ItemStack par1ItemStack) { - return super.getUnlocalizedName(par1ItemStack); - } + @Override + public String getUnlocalizedName(ItemStack par1ItemStack) { + return getUnlocalizedNameLazy(par1ItemStack) + par1ItemStack.getItemDamage(); + } - @Override - public boolean canFit(ItemStack stack, IInventory apothecary) { - return true; - } + String getUnlocalizedNameLazy(ItemStack par1ItemStack) { + return super.getUnlocalizedName(par1ItemStack); + } - @Override - public int getParticleColor(ItemStack stack) { - return 0xA8A8A8; - } + @Override + public boolean canFit(ItemStack stack, IInventory apothecary) { + return true; + } - @Override - public Achievement getAchievementOnPickup(ItemStack stack, EntityPlayer player, EntityItem item) { - return ModAchievements.runePickup; - } + @Override + public int getParticleColor(ItemStack stack) { + return 0xA8A8A8; + } + @Override + public Achievement getAchievementOnPickup(ItemStack stack, EntityPlayer player, EntityItem item) { + return ModAchievements.runePickup; + } } diff --git a/src/main/java/vazkii/botania/common/item/record/ItemModRecord.java b/src/main/java/vazkii/botania/common/item/record/ItemModRecord.java index 793dd4d7ea..3eb397bb97 100644 --- a/src/main/java/vazkii/botania/common/item/record/ItemModRecord.java +++ b/src/main/java/vazkii/botania/common/item/record/ItemModRecord.java @@ -2,14 +2,17 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Apr 11, 2015, 9:56:00 PM (GMT)] */ package vazkii.botania.common.item.record; +import cpw.mods.fml.common.registry.GameRegistry; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.item.Item; import net.minecraft.item.ItemRecord; @@ -18,41 +21,38 @@ import vazkii.botania.client.core.helper.IconHelper; import vazkii.botania.client.lib.LibResources; import vazkii.botania.common.core.BotaniaCreativeTab; -import cpw.mods.fml.common.registry.GameRegistry; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; public class ItemModRecord extends ItemRecord { - private final String file; - - public ItemModRecord(String record, String name) { - super("botania:" + record); - setCreativeTab(BotaniaCreativeTab.INSTANCE); - setUnlocalizedName(name); - file = "botania:music." + record; - } - - @Override - public Item setUnlocalizedName(String par1Str) { - GameRegistry.registerItem(this, par1Str); - return super.setUnlocalizedName(par1Str); - } - - @Override - public String getUnlocalizedNameInefficiently(ItemStack par1ItemStack) { - return super.getUnlocalizedNameInefficiently(par1ItemStack).replaceAll("item\\.", "item." + LibResources.PREFIX_MOD); - } - - @Override - @SideOnly(Side.CLIENT) - public void registerIcons(IIconRegister par1IconRegister) { - itemIcon = IconHelper.forItem(par1IconRegister, this); - } - - @Override - public ResourceLocation getRecordResource(String name) { - return new ResourceLocation(file); - } - + private final String file; + + public ItemModRecord(String record, String name) { + super("botania:" + record); + setCreativeTab(BotaniaCreativeTab.INSTANCE); + setUnlocalizedName(name); + file = "botania:music." + record; + } + + @Override + public Item setUnlocalizedName(String par1Str) { + GameRegistry.registerItem(this, par1Str); + return super.setUnlocalizedName(par1Str); + } + + @Override + public String getUnlocalizedNameInefficiently(ItemStack par1ItemStack) { + return super.getUnlocalizedNameInefficiently(par1ItemStack) + .replaceAll("item\\.", "item." + LibResources.PREFIX_MOD); + } + + @Override + @SideOnly(Side.CLIENT) + public void registerIcons(IIconRegister par1IconRegister) { + itemIcon = IconHelper.forItem(par1IconRegister, this); + } + + @Override + public ResourceLocation getRecordResource(String name) { + return new ResourceLocation(file); + } } diff --git a/src/main/java/vazkii/botania/common/item/record/ItemRecordGaia1.java b/src/main/java/vazkii/botania/common/item/record/ItemRecordGaia1.java index c1c5d4b9be..221a298a8f 100644 --- a/src/main/java/vazkii/botania/common/item/record/ItemRecordGaia1.java +++ b/src/main/java/vazkii/botania/common/item/record/ItemRecordGaia1.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Apr 11, 2015, 10:03:46 PM (GMT)] */ package vazkii.botania.common.item.record; @@ -14,8 +14,7 @@ public class ItemRecordGaia1 extends ItemModRecord { - public ItemRecordGaia1() { - super("gaia1", LibItemNames.RECORD_GAIA1); - } - + public ItemRecordGaia1() { + super("gaia1", LibItemNames.RECORD_GAIA1); + } } diff --git a/src/main/java/vazkii/botania/common/item/record/ItemRecordGaia2.java b/src/main/java/vazkii/botania/common/item/record/ItemRecordGaia2.java index 2f1f1f6ca7..bfa68158ee 100644 --- a/src/main/java/vazkii/botania/common/item/record/ItemRecordGaia2.java +++ b/src/main/java/vazkii/botania/common/item/record/ItemRecordGaia2.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Apr 11, 2015, 10:06:28 PM (GMT)] */ package vazkii.botania.common.item.record; @@ -14,8 +14,7 @@ public class ItemRecordGaia2 extends ItemModRecord { - public ItemRecordGaia2() { - super("gaia2", LibItemNames.RECORD_GAIA2); - } - + public ItemRecordGaia2() { + super("gaia2", LibItemNames.RECORD_GAIA2); + } } diff --git a/src/main/java/vazkii/botania/common/item/relic/ItemAesirRing.java b/src/main/java/vazkii/botania/common/item/relic/ItemAesirRing.java index c523bb087a..f606d4afdc 100644 --- a/src/main/java/vazkii/botania/common/item/relic/ItemAesirRing.java +++ b/src/main/java/vazkii/botania/common/item/relic/ItemAesirRing.java @@ -2,16 +2,20 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Mar 29, 2015, 10:16:29 PM (GMT)] */ package vazkii.botania.common.item.relic; +import baubles.api.BaubleType; +import com.google.common.collect.HashMultimap; +import com.google.common.collect.Multimap; +import cpw.mods.fml.common.eventhandler.SubscribeEvent; +import cpw.mods.fml.common.registry.GameRegistry; import java.util.List; - import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.SharedMonsterAttributes; import net.minecraft.entity.ai.attributes.AttributeModifier; @@ -33,90 +37,91 @@ import vazkii.botania.common.crafting.recipe.AesirRingRecipe; import vazkii.botania.common.item.ModItems; import vazkii.botania.common.lib.LibItemNames; -import baubles.api.BaubleType; - -import com.google.common.collect.HashMultimap; -import com.google.common.collect.Multimap; - -import cpw.mods.fml.common.eventhandler.SubscribeEvent; -import cpw.mods.fml.common.registry.GameRegistry; - -public class ItemAesirRing extends ItemRelicBauble implements IExtendedWireframeCoordinateListProvider, ICraftAchievement { - - Multimap attributes = HashMultimap.create(); - - public ItemAesirRing() { - super(LibItemNames.AESIR_RING); - GameRegistry.addRecipe(new AesirRingRecipe()); - RecipeSorter.register("botania:aesirRing", AesirRingRecipe.class, Category.SHAPELESS, ""); - MinecraftForge.EVENT_BUS.register(this); - } - - @SubscribeEvent - public void onDropped(ItemTossEvent event) { - if(event.entityItem != null && event.entityItem.getEntityItem() != null && !event.entityItem.worldObj.isRemote) { - ItemStack stack = event.entityItem.getEntityItem(); - if(stack.getItem() != null && stack.getItem() == this) { - event.entityItem.setDead(); - - String user = getSoulbindUsername(stack); - for(Item item : new Item[] { ModItems.thorRing, ModItems.lokiRing, ModItems.odinRing }) { - ItemStack stack1 = new ItemStack(item); - bindToUsername(user, stack1); - EntityItem entity = new EntityItem(event.entityItem.worldObj, event.entityItem.posX, event.entityItem.posY, event.entityItem.posZ, stack1); - entity.motionX = event.entityItem.motionX; - entity.motionY = event.entityItem.motionY; - entity.motionZ = event.entityItem.motionZ; - entity.age = event.entityItem.age; - entity.delayBeforeCanPickup = event.entityItem.delayBeforeCanPickup; - entity.worldObj.spawnEntityInWorld(entity); - } - } - } - } - - @Override - public void onValidPlayerWornTick(ItemStack stack, EntityPlayer player) { - ((ItemOdinRing) ModItems.odinRing).onValidPlayerWornTick(stack, player); - } - - @Override - public BaubleType getBaubleType(ItemStack arg0) { - return BaubleType.RING; - } - - @Override - public List getWireframesToDraw(EntityPlayer player, ItemStack stack) { - return ((IWireframeCoordinateListProvider) ModItems.lokiRing).getWireframesToDraw(player, stack); - } - - @Override - public ChunkCoordinates getSourceWireframe(EntityPlayer player, ItemStack stack) { - return ((IExtendedWireframeCoordinateListProvider) ModItems.lokiRing).getSourceWireframe(player, stack); - } - - @Override - public void onEquippedOrLoadedIntoWorld(ItemStack stack, EntityLivingBase player) { - attributes.clear(); - fillModifiers(attributes, stack); - player.getAttributeMap().applyAttributeModifiers(attributes); - } - - @Override - public void onUnequipped(ItemStack stack, EntityLivingBase player) { - attributes.clear(); - fillModifiers(attributes, stack); - player.getAttributeMap().removeAttributeModifiers(attributes); - } - - - void fillModifiers(Multimap attributes, ItemStack stack) { - attributes.put(SharedMonsterAttributes.maxHealth.getAttributeUnlocalizedName(), new AttributeModifier(getBaubleUUID(stack), "Bauble modifier", 20, 0)); - } - - @Override - public Achievement getAchievementOnCraft(ItemStack stack, EntityPlayer player, IInventory matrix) { - return ModAchievements.relicAesirRing; - } +public class ItemAesirRing extends ItemRelicBauble + implements IExtendedWireframeCoordinateListProvider, ICraftAchievement { + + Multimap attributes = HashMultimap.create(); + + public ItemAesirRing() { + super(LibItemNames.AESIR_RING); + GameRegistry.addRecipe(new AesirRingRecipe()); + RecipeSorter.register("botania:aesirRing", AesirRingRecipe.class, Category.SHAPELESS, ""); + MinecraftForge.EVENT_BUS.register(this); + } + + @SubscribeEvent + public void onDropped(ItemTossEvent event) { + if (event.entityItem != null + && event.entityItem.getEntityItem() != null + && !event.entityItem.worldObj.isRemote) { + ItemStack stack = event.entityItem.getEntityItem(); + if (stack.getItem() != null && stack.getItem() == this) { + event.entityItem.setDead(); + + String user = getSoulbindUsername(stack); + for (Item item : new Item[] {ModItems.thorRing, ModItems.lokiRing, ModItems.odinRing}) { + ItemStack stack1 = new ItemStack(item); + bindToUsername(user, stack1); + EntityItem entity = new EntityItem( + event.entityItem.worldObj, + event.entityItem.posX, + event.entityItem.posY, + event.entityItem.posZ, + stack1); + entity.motionX = event.entityItem.motionX; + entity.motionY = event.entityItem.motionY; + entity.motionZ = event.entityItem.motionZ; + entity.age = event.entityItem.age; + entity.delayBeforeCanPickup = event.entityItem.delayBeforeCanPickup; + entity.worldObj.spawnEntityInWorld(entity); + } + } + } + } + + @Override + public void onValidPlayerWornTick(ItemStack stack, EntityPlayer player) { + ((ItemOdinRing) ModItems.odinRing).onValidPlayerWornTick(stack, player); + } + + @Override + public BaubleType getBaubleType(ItemStack arg0) { + return BaubleType.RING; + } + + @Override + public List getWireframesToDraw(EntityPlayer player, ItemStack stack) { + return ((IWireframeCoordinateListProvider) ModItems.lokiRing).getWireframesToDraw(player, stack); + } + + @Override + public ChunkCoordinates getSourceWireframe(EntityPlayer player, ItemStack stack) { + return ((IExtendedWireframeCoordinateListProvider) ModItems.lokiRing).getSourceWireframe(player, stack); + } + + @Override + public void onEquippedOrLoadedIntoWorld(ItemStack stack, EntityLivingBase player) { + attributes.clear(); + fillModifiers(attributes, stack); + player.getAttributeMap().applyAttributeModifiers(attributes); + } + + @Override + public void onUnequipped(ItemStack stack, EntityLivingBase player) { + attributes.clear(); + fillModifiers(attributes, stack); + player.getAttributeMap().removeAttributeModifiers(attributes); + } + + void fillModifiers(Multimap attributes, ItemStack stack) { + attributes.put( + SharedMonsterAttributes.maxHealth.getAttributeUnlocalizedName(), + new AttributeModifier(getBaubleUUID(stack), "Bauble modifier", 20, 0)); + } + + @Override + public Achievement getAchievementOnCraft(ItemStack stack, EntityPlayer player, IInventory matrix) { + return ModAchievements.relicAesirRing; + } } diff --git a/src/main/java/vazkii/botania/common/item/relic/ItemDice.java b/src/main/java/vazkii/botania/common/item/relic/ItemDice.java index a0594132b5..e3d4b970a6 100644 --- a/src/main/java/vazkii/botania/common/item/relic/ItemDice.java +++ b/src/main/java/vazkii/botania/common/item/relic/ItemDice.java @@ -2,17 +2,16 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Mar 30, 2015, 6:52:35 PM (GMT)] */ package vazkii.botania.common.item.relic; import java.util.ArrayList; import java.util.List; - import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayerMP; import net.minecraft.item.Item; @@ -28,73 +27,69 @@ public class ItemDice extends ItemRelic { - private static final int[] SIDES_FOR_MOON_PHASES = new int[] { - -1, 0, 1, 2, -1, 2, 3, 4 - }; - - public static ItemStack[] relicStacks; - - public ItemDice() { - super(LibItemNames.DICE); - - relicStacks = new ItemStack[] { - new ItemStack(ModItems.infiniteFruit), - new ItemStack(ModItems.kingKey), - new ItemStack(ModItems.flugelEye), - new ItemStack(ModItems.thorRing), - new ItemStack(ModItems.odinRing), - new ItemStack(ModItems.lokiRing) - }; - } - - @Override - public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer player) { - if(isRightPlayer(player, stack) && !player.worldObj.isRemote) { - int moonPhase = world.provider.getMoonPhase(world.getWorldTime()); - int side = SIDES_FOR_MOON_PHASES[moonPhase]; - int relic = side; - if(hasRelicAlready(player, relic)) { - List possible = new ArrayList(); - List alreadyHas = new ArrayList(); - for(int i = 0; i < 6; i++) - if(hasRelicAlready(player, i)) - alreadyHas.add(i); - else possible.add(i); - - if(alreadyHas.size() > 0) - possible.add(alreadyHas.get(world.rand.nextInt(alreadyHas.size()))); - relic = possible.get(world.rand.nextInt(possible.size())); - } - - world.playSoundAtEntity(player, "random.bow", 0.5F, 0.4F / (world.rand.nextFloat() * 0.4F + 0.8F)); - - if(hasRelicAlready(player, relic)) { - player.addChatMessage(new ChatComponentTranslation("botaniamisc.dudDiceRoll", relic + 1).setChatStyle(new ChatStyle().setColor(EnumChatFormatting.DARK_GREEN))); - stack.stackSize--; - return stack; - } - - player.addChatMessage(new ChatComponentTranslation("botaniamisc.diceRoll", relic + 1).setChatStyle(new ChatStyle().setColor(EnumChatFormatting.DARK_GREEN))); - return relicStacks[relic].copy(); - } - - return stack; - } - - @Override - public boolean shouldDamageWrongPlayer() { - return false; - } - - boolean hasRelicAlready(EntityPlayer player, int relic) { - if(relic < 0 || relic > 5 || !(player instanceof EntityPlayerMP)) - return true; - - EntityPlayerMP mpPlayer = (EntityPlayerMP) player; - Item item = relicStacks[relic].getItem(); - IRelic irelic = (IRelic) item; - Achievement achievement = irelic.getBindAchievement(); - return mpPlayer.func_147099_x().hasAchievementUnlocked(achievement); - } - + private static final int[] SIDES_FOR_MOON_PHASES = new int[] {-1, 0, 1, 2, -1, 2, 3, 4}; + + public static ItemStack[] relicStacks; + + public ItemDice() { + super(LibItemNames.DICE); + + relicStacks = new ItemStack[] { + new ItemStack(ModItems.infiniteFruit), + new ItemStack(ModItems.kingKey), + new ItemStack(ModItems.flugelEye), + new ItemStack(ModItems.thorRing), + new ItemStack(ModItems.odinRing), + new ItemStack(ModItems.lokiRing) + }; + } + + @Override + public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer player) { + if (isRightPlayer(player, stack) && !player.worldObj.isRemote) { + int moonPhase = world.provider.getMoonPhase(world.getWorldTime()); + int side = SIDES_FOR_MOON_PHASES[moonPhase]; + int relic = side; + if (hasRelicAlready(player, relic)) { + List possible = new ArrayList(); + List alreadyHas = new ArrayList(); + for (int i = 0; i < 6; i++) + if (hasRelicAlready(player, i)) alreadyHas.add(i); + else possible.add(i); + + if (alreadyHas.size() > 0) possible.add(alreadyHas.get(world.rand.nextInt(alreadyHas.size()))); + relic = possible.get(world.rand.nextInt(possible.size())); + } + + world.playSoundAtEntity(player, "random.bow", 0.5F, 0.4F / (world.rand.nextFloat() * 0.4F + 0.8F)); + + if (hasRelicAlready(player, relic)) { + player.addChatMessage(new ChatComponentTranslation("botaniamisc.dudDiceRoll", relic + 1) + .setChatStyle(new ChatStyle().setColor(EnumChatFormatting.DARK_GREEN))); + stack.stackSize--; + return stack; + } + + player.addChatMessage(new ChatComponentTranslation("botaniamisc.diceRoll", relic + 1) + .setChatStyle(new ChatStyle().setColor(EnumChatFormatting.DARK_GREEN))); + return relicStacks[relic].copy(); + } + + return stack; + } + + @Override + public boolean shouldDamageWrongPlayer() { + return false; + } + + boolean hasRelicAlready(EntityPlayer player, int relic) { + if (relic < 0 || relic > 5 || !(player instanceof EntityPlayerMP)) return true; + + EntityPlayerMP mpPlayer = (EntityPlayerMP) player; + Item item = relicStacks[relic].getItem(); + IRelic irelic = (IRelic) item; + Achievement achievement = irelic.getBindAchievement(); + return mpPlayer.func_147099_x().hasAchievementUnlocked(achievement); + } } diff --git a/src/main/java/vazkii/botania/common/item/relic/ItemExcaliber.java b/src/main/java/vazkii/botania/common/item/relic/ItemExcaliber.java index 471f677e70..40a1f2f5f7 100644 --- a/src/main/java/vazkii/botania/common/item/relic/ItemExcaliber.java +++ b/src/main/java/vazkii/botania/common/item/relic/ItemExcaliber.java @@ -2,48 +2,14 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Mar 29, 2015, 10:12:50 PM (GMT)] */ /*package vazkii.botania.common.item.relic; -import java.util.List; - -import net.minecraft.entity.Entity; -import net.minecraft.entity.EntityLivingBase; -import net.minecraft.entity.SharedMonsterAttributes; -import net.minecraft.entity.ai.attributes.AttributeModifier; -import net.minecraft.entity.boss.IBossDisplayData; -import net.minecraft.entity.monster.IMob; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.entity.projectile.EntityThrowable; -import net.minecraft.item.EnumRarity; -import net.minecraft.item.ItemStack; -import net.minecraft.potion.Potion; -import net.minecraft.potion.PotionEffect; -import net.minecraft.server.MinecraftServer; -import net.minecraft.stats.Achievement; -import net.minecraft.util.AxisAlignedBB; -import net.minecraft.util.DamageSource; -import net.minecraft.util.MovingObjectPosition; -import net.minecraft.world.World; -import net.minecraftforge.common.util.EnumHelper; -import vazkii.botania.api.BotaniaAPI; -import vazkii.botania.api.internal.IManaBurst; -import vazkii.botania.api.item.IRelic; -import vazkii.botania.api.mana.BurstProperties; -import vazkii.botania.api.mana.ILensEffect; -import vazkii.botania.common.core.helper.ItemNBTHelper; -import vazkii.botania.common.core.helper.Vector3; -import vazkii.botania.common.entity.EntityManaBurst; -import vazkii.botania.common.item.equipment.tool.manasteel.ItemManasteelSword; -import vazkii.botania.common.lib.LibItemNames; - -import com.google.common.collect.HashMultimap; -import com.google.common.collect.Multimap; public class ItemExcaliber extends ItemManasteelSword implements IRelic, ILensEffect { @@ -220,4 +186,4 @@ public EnumRarity getRarity(ItemStack p_77613_1_) { } } - */ \ No newline at end of file + */ diff --git a/src/main/java/vazkii/botania/common/item/relic/ItemFlugelEye.java b/src/main/java/vazkii/botania/common/item/relic/ItemFlugelEye.java index d6f9e20f60..a029e3b250 100644 --- a/src/main/java/vazkii/botania/common/item/relic/ItemFlugelEye.java +++ b/src/main/java/vazkii/botania/common/item/relic/ItemFlugelEye.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Mar 29, 2015, 10:13:26 PM (GMT)] */ package vazkii.botania.common.item.relic; @@ -27,413 +27,454 @@ public class ItemFlugelEye extends ItemRelic implements ICoordBoundItem, IManaUsingItem { - public ItemFlugelEye() { - super(LibItemNames.FLUGEL_EYE); - } - - private static final String TAG_X = "x"; - private static final String TAG_Y = "y"; - private static final String TAG_Z = "z"; - private static final String TAG_DIMENSION = "dim"; - - @Override - public boolean onItemUse(ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int side, float hitX, float hitY, float hitZ) { - if(player.isSneaking()) { - if(world.isRemote) { - player.swingItem(); - for(int i = 0; i < 10; i++) { - float x1 = (float) (x + Math.random()); - float y1 = y + 1; - float z1 = (float) (z + Math.random()); - Botania.proxy.wispFX(player.worldObj, x1, y1, z1, (float) Math.random(), (float) Math.random(), (float) Math.random(), (float) Math.random() * 0.5F, -0.05F + (float) Math.random() * 0.05F); - } - } else { - ItemNBTHelper.setInt(stack, TAG_X, x); - ItemNBTHelper.setInt(stack, TAG_Y, y); - ItemNBTHelper.setInt(stack, TAG_Z, z); - ItemNBTHelper.setInt(stack, TAG_DIMENSION, world.provider.dimensionId); - world.playSoundAtEntity(player, "mob.endermen.portal", 1F, 5F); - } - } - - return true; - } - - @Override - public void onUsingTick(ItemStack stack, EntityPlayer player, int count) { - float x = (float) (player.posX - Math.random() * player.width); - float y = (float) (player.posY - 1.6 + Math.random()); - float z = (float) (player.posZ - Math.random() * player.width); - Botania.proxy.wispFX(player.worldObj, x, y, z, (float) Math.random(), (float) Math.random(), (float) Math.random(), (float) Math.random() * 0.7F, -0.05F - (float) Math.random() * 0.05F); - } - - @Override - public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer) { - par3EntityPlayer.setItemInUse(par1ItemStack, getMaxItemUseDuration(par1ItemStack)); - return par1ItemStack; - } - - @Override - public ItemStack onEaten(ItemStack stack, World world, EntityPlayer player) { - int x = ItemNBTHelper.getInt(stack, TAG_X, 0); - int y = ItemNBTHelper.getInt(stack, TAG_Y, -1); - int z = ItemNBTHelper.getInt(stack, TAG_Z, 0); - int dim = ItemNBTHelper.getInt(stack, TAG_DIMENSION, 0); - - int cost = (int) (MathHelper.pointDistanceSpace(x + 0.5, y + 0.5, z + 0.5, player.posX, player.posY, player.posZ) * 10); - - if(y > -1 && dim == world.provider.dimensionId && ManaItemHandler.requestManaExact(stack, player, cost, true)) { - moveParticlesAndSound(player); - if(player instanceof EntityPlayerMP && !world.isRemote) - ((EntityPlayerMP) player).playerNetServerHandler.setPlayerLocation(x + 0.5, y + 1.6, z + 0.5, player.rotationYaw, player.rotationPitch); - moveParticlesAndSound(player); - } - - return stack; - } - - private static void moveParticlesAndSound(Entity entity) { - for(int i = 0; i < 15; i++) { - float x = (float) (entity.posX + Math.random()); - float y = (float) (entity.posY - 1.6 + Math.random()); - float z = (float) (entity.posZ + Math.random()); - Botania.proxy.wispFX(entity.worldObj, x, y, z, (float) Math.random(), (float) Math.random(), (float) Math.random(), (float) Math.random(), -0.3F + (float) Math.random() * 0.2F); - } - if(!entity.worldObj.isRemote) - entity.worldObj.playSoundAtEntity(entity, "mob.endermen.portal", 1F, 1F); - } - - @Override - public int getMaxItemUseDuration(ItemStack par1ItemStack) { - return 40; - } - - @Override - public EnumAction getItemUseAction(ItemStack par1ItemStack) { - return EnumAction.block; - } - - @Override - public ChunkCoordinates getBinding(ItemStack stack) { - int x = ItemNBTHelper.getInt(stack, TAG_X, 0); - int y = ItemNBTHelper.getInt(stack, TAG_Y, -1); - int z = ItemNBTHelper.getInt(stack, TAG_Z, 0); - return y == -1 ? null : new ChunkCoordinates(x, y, z); - } - - @Override - public boolean usesMana(ItemStack stack) { - return true; - } - - /* - // Code from the older iteration of this item: - - private static final ResourceLocation glowTexture = new ResourceLocation(LibResources.MISC_GLOW_CYAN); - - private static final int SEGMENTS = 12; - private static final MultiversePosition FALLBACK_POSITION = new MultiversePosition(0, -1, 0, 0); - - private static final String TAG_EQUIPPED = "equipped"; - private static final String TAG_ROTATION_BASE = "rotationBase"; - private static final String TAG_WARP_PREFIX = "warp"; - private static final String TAG_POS_X = "posX"; - private static final String TAG_POS_Y = "posY"; - private static final String TAG_POS_Z = "posZ"; - private static final String TAG_DIMENSION = "dim"; - private static final String TAG_FIRST_TICK = "firstTick"; - - IIcon[] signs; - - public ItemFlugelEye() { - super(LibItemNames.FLUGEL_EYE); - MinecraftForge.EVENT_BUS.register(this); - } - - @Override - @SideOnly(Side.CLIENT) - public void registerIcons(IIconRegister par1IconRegister) { - super.registerIcons(par1IconRegister); - signs = new IIcon[12]; - for(int i = 0; i < 12; i++) - signs[i] = IconHelper.forName(par1IconRegister, "sign" + i); - } - - @Override - public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer player) { - if(isRightPlayer(player, stack)) { - int segment = getSegmentLookedAt(stack, player); - MultiversePosition pos = getWarpPoint(stack, segment); - if(pos.isValid()) { - if(pos.dim == world.provider.dimensionId && player instanceof EntityPlayerMP) { - ((EntityPlayerMP) player).playerNetServerHandler.setPlayerLocation(pos.x, pos.y, pos.z, player.rotationYaw, player.rotationPitch); - world.playSoundAtEntity(player, "mob.endermen.portal", 1F, 1F); - } - } else setWarpPoint(stack, segment, player.posX, player.posY, player.posZ, world.provider.dimensionId); - } - - return stack; - } - - @Override - public boolean onEntitySwing(EntityLivingBase player, ItemStack stack) { - if(player.isSneaking() && player instanceof EntityPlayer && isRightPlayer((EntityPlayer) player, stack)) { - int segment = getSegmentLookedAt(stack, player); - MultiversePosition pos = getWarpPoint(stack, segment); - if(pos.isValid()) { - setWarpPoint(stack, segment, 0, -1, 0, 0); - return true; - } - } - - return false; - } - - @Override - public void onUpdate(ItemStack stack, World world, Entity entity, int pos, boolean equipped) { - super.onUpdate(stack, world, entity, pos, equipped); - boolean eqLastTick = wasEquipped(stack); - boolean firstTick = isFirstTick(stack); - if(eqLastTick != equipped) - setEquipped(stack, equipped); - - if((!equipped || firstTick) && entity instanceof EntityLivingBase) { - int angles = 360; - int segAngles = angles / SEGMENTS; - float shift = segAngles / 2; - setRotationBase(stack, getCheckingAngle((EntityLivingBase) entity) - shift); - if(firstTick) - tickFirst(stack); - } - } - - private static int getSegmentLookedAt(ItemStack stack, EntityLivingBase player) { - float yaw = getCheckingAngle(player, getRotationBase(stack)); - - int angles = 360; - int segAngles = angles / SEGMENTS; - for(int seg = 0; seg < SEGMENTS; seg++) { - float calcAngle = (float) seg * segAngles; - if(yaw >= calcAngle && yaw < calcAngle + segAngles) - return seg; - } - return 0; - } - - private static float getCheckingAngle(EntityLivingBase player) { - return getCheckingAngle(player, 0F); - } - - // Screw the way minecraft handles rotation - // Really... - private static float getCheckingAngle(EntityLivingBase player, float base) { - float yaw = MathHelper.wrapAngleTo180_float(player.rotationYaw) + 90F; - int angles = 360; - int segAngles = angles / SEGMENTS; - float shift = segAngles / 2; - - if(yaw < 0) - yaw = 180F + (180F + yaw); - yaw -= 360F - base; - float angle = 360F - yaw + shift; - - if(angle < 0) - angle = 360F + angle; - - return angle; - } - - public static boolean isFirstTick(ItemStack stack) { - return ItemNBTHelper.getBoolean(stack, TAG_FIRST_TICK, true); - } - - public static void tickFirst(ItemStack stack) { - ItemNBTHelper.setBoolean(stack, TAG_FIRST_TICK, false); - } - - public static boolean wasEquipped(ItemStack stack) { - return ItemNBTHelper.getBoolean(stack, TAG_EQUIPPED, false); - } - - public static void setEquipped(ItemStack stack, boolean equipped) { - ItemNBTHelper.setBoolean(stack, TAG_EQUIPPED, equipped); - } - - public static float getRotationBase(ItemStack stack) { - return ItemNBTHelper.getFloat(stack, TAG_ROTATION_BASE, 0F); - } - - public static void setRotationBase(ItemStack stack, float rotation) { - ItemNBTHelper.setFloat(stack, TAG_ROTATION_BASE, rotation); - } - - public static void setWarpPoint(ItemStack stack, int warp, double x, double y, double z, int dim) { - NBTTagCompound cmp = new NBTTagCompound(); - cmp.setDouble(TAG_POS_X, x); - cmp.setDouble(TAG_POS_Y, y); - cmp.setDouble(TAG_POS_Z, z); - cmp.setInteger(TAG_DIMENSION, dim); - ItemNBTHelper.setCompound(stack, TAG_WARP_PREFIX + warp, cmp); - } - - public static MultiversePosition getWarpPoint(ItemStack stack, int warp) { - NBTTagCompound cmp = ItemNBTHelper.getCompound(stack, TAG_WARP_PREFIX + warp, true); - if(cmp == null) - return FALLBACK_POSITION; - - double x = cmp.getDouble(TAG_POS_X); - double y = cmp.getDouble(TAG_POS_Y); - double z = cmp.getDouble(TAG_POS_Z); - int dim = cmp.getInteger(TAG_DIMENSION); - return new MultiversePosition(x, y, z, dim); - } - - @SideOnly(Side.CLIENT) - @SubscribeEvent - public void onRenderWorldLast(RenderWorldLastEvent event) { - EntityPlayer player = Minecraft.getMinecraft().thePlayer; - ItemStack stack = player.getCurrentEquippedItem(); - if(stack != null && stack.getItem() == this) - render(stack, player, event.partialTicks); - } - - @SideOnly(Side.CLIENT) - public void render(ItemStack stack, EntityPlayer player, float partialTicks) { - Minecraft mc = Minecraft.getMinecraft(); - Tessellator tess = Tessellator.instance; - Tessellator.renderingWorldRenderer = false; - - GL11.glPushMatrix(); - GL11.glEnable(GL11.GL_BLEND); - GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); - float alpha = ((float) Math.sin((ClientTickHandler.ticksInGame + partialTicks) * 0.2F) * 0.5F + 0.5F) * 0.4F + 0.3F; - - double posX = player.prevPosX + (player.posX - player.prevPosX) * partialTicks; - double posY = player.prevPosY + (player.posY - player.prevPosY) * partialTicks; - double posZ = player.prevPosZ + (player.posZ - player.prevPosZ) * partialTicks; - - GL11.glTranslated(posX - RenderManager.renderPosX, posY - RenderManager.renderPosY, posZ - RenderManager.renderPosZ); - - float base = getRotationBase(stack); - int angles = 360; - int segAngles = angles / SEGMENTS; - float shift = base - segAngles / 2; - - float u = 1F; - float v = 0.25F; - - float s = 3F; - float m = 0.8F; - float y = v * s * 2; - float y0 = 0; - - int segmentLookedAt = getSegmentLookedAt(stack, player); - - for(int seg = 0; seg < SEGMENTS; seg++) { - boolean inside = false; - float rotationAngle = (seg + 0.5F) * segAngles + shift; - if(segmentLookedAt == seg) - inside = true; - - GL11.glPushMatrix(); - GL11.glRotatef(rotationAngle, 0F, 1F, 0F); - GL11.glTranslatef(s * m, -0.75F, 0F); - - mc.renderEngine.bindTexture(TextureMap.locationItemsTexture); - GL11.glScalef(0.75F, 0.75F, 0.75F); - GL11.glTranslatef(0F, 0F, 0.5F); - IIcon icon = signs[seg]; - GL11.glRotatef(90F, 0F, 1F, 0F); - GL11.glColor4f(1F, 1F, 1F, getWarpPoint(stack, seg).isValid() ? 1F : 0.2F); - float f = icon.getMinU(); - float f1 = icon.getMaxU(); - float f2 = icon.getMinV(); - float f3 = icon.getMaxV(); - ItemRenderer.renderItemIn2D(Tessellator.instance, f1, f2, f, f3, icon.getIconWidth(), icon.getIconHeight(), 1F / 16F); - - GL11.glColor3f(1F, 1F, 1F); - GL11.glPopMatrix(); - - GL11.glPushMatrix(); - GL11.glRotatef(180F, 1F, 0F, 0F); - float a = alpha; - if(inside) { - a += 0.3F; - y0 = -y; - } - - if(seg % 2 == 0) - GL11.glColor4f(0.6F, 0.6F, 0.6F, a); - else GL11.glColor4f(1F, 1F, 1F, a); - - mc.renderEngine.bindTexture(glowTexture); - tess.startDrawingQuads(); - for(int i = 0; i < segAngles; i++) { - float ang = i + seg * segAngles + shift; - double xp = Math.cos(ang * Math.PI / 180F) * s; - double zp = Math.sin(ang * Math.PI / 180F) * s; - - tess.addVertexWithUV(xp * m, y, zp * m, u, v); - tess.addVertexWithUV(xp, y0, zp, u, 0); - - xp = Math.cos((ang + 1) * Math.PI / 180F) * s; - zp = Math.sin((ang + 1) * Math.PI / 180F) * s; - - tess.addVertexWithUV(xp, y0, zp, 0, 0); - tess.addVertexWithUV(xp * m, y, zp * m, 0, v); - } - y0 = 0; - tess.draw(); - - GL11.glPopMatrix(); - } - GL11.glPopMatrix(); - } - - @SideOnly(Side.CLIENT) - public static void renderHUD(ScaledResolution resolution, EntityPlayer player, ItemStack stack) { - Minecraft.getMinecraft(); - int slot = getSegmentLookedAt(stack, player); - MultiversePosition pos = getWarpPoint(stack, slot); - - FontRenderer font = Minecraft.getMinecraft().fontRenderer; - String s = StatCollector.translateToLocal("botania.sign" + slot); - font.drawStringWithShadow(s, resolution.getScaledWidth() / 2 - font.getStringWidth(s) / 2, resolution.getScaledHeight() / 2 - 55, 0xFFD409); - - if(pos.isValid()) { - int dist = (int) vazkii.botania.common.core.helper.MathHelper.pointDistanceSpace(pos.x, pos.y, pos.z, player.posX, player.posY - 1.6, player.posZ); - - s = dist == 1 ? StatCollector.translateToLocal("botaniamisc.blockAway") : String.format(StatCollector.translateToLocal("botaniamisc.blocksAway"), dist); - font.drawStringWithShadow(s, resolution.getScaledWidth() / 2 - font.getStringWidth(s) / 2, resolution.getScaledHeight() / 2 - 40, 0x9999FF); - s = StatCollector.translateToLocal("botaniamisc.clickToTeleport"); - font.drawStringWithShadow(s, resolution.getScaledWidth() / 2 - font.getStringWidth(s) / 2, resolution.getScaledHeight() / 2 - 30, 0xFFFFFF); - s = StatCollector.translateToLocal("botaniamisc.clickToRemoveWarp"); - font.drawStringWithShadow(s, resolution.getScaledWidth() / 2 - font.getStringWidth(s) / 2, resolution.getScaledHeight() / 2 - 20, 0xFFFFFF); - } else { - s = StatCollector.translateToLocal("botaniamisc.unboundWarp"); - font.drawStringWithShadow(s, resolution.getScaledWidth() / 2 - font.getStringWidth(s) / 2, resolution.getScaledHeight() / 2 - 40, 0xFFFFFF); - s = StatCollector.translateToLocal("botaniamisc.clickToAddWarp"); - font.drawStringWithShadow(s, resolution.getScaledWidth() / 2 - font.getStringWidth(s) / 2, resolution.getScaledHeight() / 2 - 30, 0xFFFFFF); - } - } - - private static class MultiversePosition { - - public final double x, y, z; - public final int dim; - - public MultiversePosition(double x, double y, double z, int dim) { - this.x = x; - this.y = y; - this.z = z; - this.dim = dim; - } - - boolean isValid() { - return y > 0; - } - - } - */ + public ItemFlugelEye() { + super(LibItemNames.FLUGEL_EYE); + } + + private static final String TAG_X = "x"; + private static final String TAG_Y = "y"; + private static final String TAG_Z = "z"; + private static final String TAG_DIMENSION = "dim"; + + @Override + public boolean onItemUse( + ItemStack stack, + EntityPlayer player, + World world, + int x, + int y, + int z, + int side, + float hitX, + float hitY, + float hitZ) { + if (player.isSneaking()) { + if (world.isRemote) { + player.swingItem(); + for (int i = 0; i < 10; i++) { + float x1 = (float) (x + Math.random()); + float y1 = y + 1; + float z1 = (float) (z + Math.random()); + Botania.proxy.wispFX( + player.worldObj, + x1, + y1, + z1, + (float) Math.random(), + (float) Math.random(), + (float) Math.random(), + (float) Math.random() * 0.5F, + -0.05F + (float) Math.random() * 0.05F); + } + } else { + ItemNBTHelper.setInt(stack, TAG_X, x); + ItemNBTHelper.setInt(stack, TAG_Y, y); + ItemNBTHelper.setInt(stack, TAG_Z, z); + ItemNBTHelper.setInt(stack, TAG_DIMENSION, world.provider.dimensionId); + world.playSoundAtEntity(player, "mob.endermen.portal", 1F, 5F); + } + } + + return true; + } + + @Override + public void onUsingTick(ItemStack stack, EntityPlayer player, int count) { + float x = (float) (player.posX - Math.random() * player.width); + float y = (float) (player.posY - 1.6 + Math.random()); + float z = (float) (player.posZ - Math.random() * player.width); + Botania.proxy.wispFX( + player.worldObj, + x, + y, + z, + (float) Math.random(), + (float) Math.random(), + (float) Math.random(), + (float) Math.random() * 0.7F, + -0.05F - (float) Math.random() * 0.05F); + } + + @Override + public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer) { + par3EntityPlayer.setItemInUse(par1ItemStack, getMaxItemUseDuration(par1ItemStack)); + return par1ItemStack; + } + + @Override + public ItemStack onEaten(ItemStack stack, World world, EntityPlayer player) { + int x = ItemNBTHelper.getInt(stack, TAG_X, 0); + int y = ItemNBTHelper.getInt(stack, TAG_Y, -1); + int z = ItemNBTHelper.getInt(stack, TAG_Z, 0); + int dim = ItemNBTHelper.getInt(stack, TAG_DIMENSION, 0); + + int cost = (int) + (MathHelper.pointDistanceSpace(x + 0.5, y + 0.5, z + 0.5, player.posX, player.posY, player.posZ) * 10); + + if (y > -1 + && dim == world.provider.dimensionId + && ManaItemHandler.requestManaExact(stack, player, cost, true)) { + moveParticlesAndSound(player); + if (player instanceof EntityPlayerMP && !world.isRemote) + ((EntityPlayerMP) player) + .playerNetServerHandler.setPlayerLocation( + x + 0.5, y + 1.6, z + 0.5, player.rotationYaw, player.rotationPitch); + moveParticlesAndSound(player); + } + + return stack; + } + + private static void moveParticlesAndSound(Entity entity) { + for (int i = 0; i < 15; i++) { + float x = (float) (entity.posX + Math.random()); + float y = (float) (entity.posY - 1.6 + Math.random()); + float z = (float) (entity.posZ + Math.random()); + Botania.proxy.wispFX( + entity.worldObj, + x, + y, + z, + (float) Math.random(), + (float) Math.random(), + (float) Math.random(), + (float) Math.random(), + -0.3F + (float) Math.random() * 0.2F); + } + if (!entity.worldObj.isRemote) entity.worldObj.playSoundAtEntity(entity, "mob.endermen.portal", 1F, 1F); + } + + @Override + public int getMaxItemUseDuration(ItemStack par1ItemStack) { + return 40; + } + + @Override + public EnumAction getItemUseAction(ItemStack par1ItemStack) { + return EnumAction.block; + } + + @Override + public ChunkCoordinates getBinding(ItemStack stack) { + int x = ItemNBTHelper.getInt(stack, TAG_X, 0); + int y = ItemNBTHelper.getInt(stack, TAG_Y, -1); + int z = ItemNBTHelper.getInt(stack, TAG_Z, 0); + return y == -1 ? null : new ChunkCoordinates(x, y, z); + } + + @Override + public boolean usesMana(ItemStack stack) { + return true; + } + + /* + // Code from the older iteration of this item: + + private static final ResourceLocation glowTexture = new ResourceLocation(LibResources.MISC_GLOW_CYAN); + + private static final int SEGMENTS = 12; + private static final MultiversePosition FALLBACK_POSITION = new MultiversePosition(0, -1, 0, 0); + + private static final String TAG_EQUIPPED = "equipped"; + private static final String TAG_ROTATION_BASE = "rotationBase"; + private static final String TAG_WARP_PREFIX = "warp"; + private static final String TAG_POS_X = "posX"; + private static final String TAG_POS_Y = "posY"; + private static final String TAG_POS_Z = "posZ"; + private static final String TAG_DIMENSION = "dim"; + private static final String TAG_FIRST_TICK = "firstTick"; + + IIcon[] signs; + + public ItemFlugelEye() { + super(LibItemNames.FLUGEL_EYE); + MinecraftForge.EVENT_BUS.register(this); + } + + @Override + @SideOnly(Side.CLIENT) + public void registerIcons(IIconRegister par1IconRegister) { + super.registerIcons(par1IconRegister); + signs = new IIcon[12]; + for(int i = 0; i < 12; i++) + signs[i] = IconHelper.forName(par1IconRegister, "sign" + i); + } + + @Override + public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer player) { + if(isRightPlayer(player, stack)) { + int segment = getSegmentLookedAt(stack, player); + MultiversePosition pos = getWarpPoint(stack, segment); + if(pos.isValid()) { + if(pos.dim == world.provider.dimensionId && player instanceof EntityPlayerMP) { + ((EntityPlayerMP) player).playerNetServerHandler.setPlayerLocation(pos.x, pos.y, pos.z, player.rotationYaw, player.rotationPitch); + world.playSoundAtEntity(player, "mob.endermen.portal", 1F, 1F); + } + } else setWarpPoint(stack, segment, player.posX, player.posY, player.posZ, world.provider.dimensionId); + } + + return stack; + } + + @Override + public boolean onEntitySwing(EntityLivingBase player, ItemStack stack) { + if(player.isSneaking() && player instanceof EntityPlayer && isRightPlayer((EntityPlayer) player, stack)) { + int segment = getSegmentLookedAt(stack, player); + MultiversePosition pos = getWarpPoint(stack, segment); + if(pos.isValid()) { + setWarpPoint(stack, segment, 0, -1, 0, 0); + return true; + } + } + + return false; + } + + @Override + public void onUpdate(ItemStack stack, World world, Entity entity, int pos, boolean equipped) { + super.onUpdate(stack, world, entity, pos, equipped); + boolean eqLastTick = wasEquipped(stack); + boolean firstTick = isFirstTick(stack); + if(eqLastTick != equipped) + setEquipped(stack, equipped); + + if((!equipped || firstTick) && entity instanceof EntityLivingBase) { + int angles = 360; + int segAngles = angles / SEGMENTS; + float shift = segAngles / 2; + setRotationBase(stack, getCheckingAngle((EntityLivingBase) entity) - shift); + if(firstTick) + tickFirst(stack); + } + } + + private static int getSegmentLookedAt(ItemStack stack, EntityLivingBase player) { + float yaw = getCheckingAngle(player, getRotationBase(stack)); + + int angles = 360; + int segAngles = angles / SEGMENTS; + for(int seg = 0; seg < SEGMENTS; seg++) { + float calcAngle = (float) seg * segAngles; + if(yaw >= calcAngle && yaw < calcAngle + segAngles) + return seg; + } + return 0; + } + + private static float getCheckingAngle(EntityLivingBase player) { + return getCheckingAngle(player, 0F); + } + + // Screw the way minecraft handles rotation + // Really... + private static float getCheckingAngle(EntityLivingBase player, float base) { + float yaw = MathHelper.wrapAngleTo180_float(player.rotationYaw) + 90F; + int angles = 360; + int segAngles = angles / SEGMENTS; + float shift = segAngles / 2; + + if(yaw < 0) + yaw = 180F + (180F + yaw); + yaw -= 360F - base; + float angle = 360F - yaw + shift; + + if(angle < 0) + angle = 360F + angle; + + return angle; + } + + public static boolean isFirstTick(ItemStack stack) { + return ItemNBTHelper.getBoolean(stack, TAG_FIRST_TICK, true); + } + + public static void tickFirst(ItemStack stack) { + ItemNBTHelper.setBoolean(stack, TAG_FIRST_TICK, false); + } + + public static boolean wasEquipped(ItemStack stack) { + return ItemNBTHelper.getBoolean(stack, TAG_EQUIPPED, false); + } + + public static void setEquipped(ItemStack stack, boolean equipped) { + ItemNBTHelper.setBoolean(stack, TAG_EQUIPPED, equipped); + } + + public static float getRotationBase(ItemStack stack) { + return ItemNBTHelper.getFloat(stack, TAG_ROTATION_BASE, 0F); + } + + public static void setRotationBase(ItemStack stack, float rotation) { + ItemNBTHelper.setFloat(stack, TAG_ROTATION_BASE, rotation); + } + + public static void setWarpPoint(ItemStack stack, int warp, double x, double y, double z, int dim) { + NBTTagCompound cmp = new NBTTagCompound(); + cmp.setDouble(TAG_POS_X, x); + cmp.setDouble(TAG_POS_Y, y); + cmp.setDouble(TAG_POS_Z, z); + cmp.setInteger(TAG_DIMENSION, dim); + ItemNBTHelper.setCompound(stack, TAG_WARP_PREFIX + warp, cmp); + } + + public static MultiversePosition getWarpPoint(ItemStack stack, int warp) { + NBTTagCompound cmp = ItemNBTHelper.getCompound(stack, TAG_WARP_PREFIX + warp, true); + if(cmp == null) + return FALLBACK_POSITION; + + double x = cmp.getDouble(TAG_POS_X); + double y = cmp.getDouble(TAG_POS_Y); + double z = cmp.getDouble(TAG_POS_Z); + int dim = cmp.getInteger(TAG_DIMENSION); + return new MultiversePosition(x, y, z, dim); + } + + @SideOnly(Side.CLIENT) + @SubscribeEvent + public void onRenderWorldLast(RenderWorldLastEvent event) { + EntityPlayer player = Minecraft.getMinecraft().thePlayer; + ItemStack stack = player.getCurrentEquippedItem(); + if(stack != null && stack.getItem() == this) + render(stack, player, event.partialTicks); + } + + @SideOnly(Side.CLIENT) + public void render(ItemStack stack, EntityPlayer player, float partialTicks) { + Minecraft mc = Minecraft.getMinecraft(); + Tessellator tess = Tessellator.instance; + Tessellator.renderingWorldRenderer = false; + + GL11.glPushMatrix(); + GL11.glEnable(GL11.GL_BLEND); + GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); + float alpha = ((float) Math.sin((ClientTickHandler.ticksInGame + partialTicks) * 0.2F) * 0.5F + 0.5F) * 0.4F + 0.3F; + + double posX = player.prevPosX + (player.posX - player.prevPosX) * partialTicks; + double posY = player.prevPosY + (player.posY - player.prevPosY) * partialTicks; + double posZ = player.prevPosZ + (player.posZ - player.prevPosZ) * partialTicks; + + GL11.glTranslated(posX - RenderManager.renderPosX, posY - RenderManager.renderPosY, posZ - RenderManager.renderPosZ); + + float base = getRotationBase(stack); + int angles = 360; + int segAngles = angles / SEGMENTS; + float shift = base - segAngles / 2; + + float u = 1F; + float v = 0.25F; + + float s = 3F; + float m = 0.8F; + float y = v * s * 2; + float y0 = 0; + + int segmentLookedAt = getSegmentLookedAt(stack, player); + + for(int seg = 0; seg < SEGMENTS; seg++) { + boolean inside = false; + float rotationAngle = (seg + 0.5F) * segAngles + shift; + if(segmentLookedAt == seg) + inside = true; + + GL11.glPushMatrix(); + GL11.glRotatef(rotationAngle, 0F, 1F, 0F); + GL11.glTranslatef(s * m, -0.75F, 0F); + + mc.renderEngine.bindTexture(TextureMap.locationItemsTexture); + GL11.glScalef(0.75F, 0.75F, 0.75F); + GL11.glTranslatef(0F, 0F, 0.5F); + IIcon icon = signs[seg]; + GL11.glRotatef(90F, 0F, 1F, 0F); + GL11.glColor4f(1F, 1F, 1F, getWarpPoint(stack, seg).isValid() ? 1F : 0.2F); + float f = icon.getMinU(); + float f1 = icon.getMaxU(); + float f2 = icon.getMinV(); + float f3 = icon.getMaxV(); + ItemRenderer.renderItemIn2D(Tessellator.instance, f1, f2, f, f3, icon.getIconWidth(), icon.getIconHeight(), 1F / 16F); + + GL11.glColor3f(1F, 1F, 1F); + GL11.glPopMatrix(); + + GL11.glPushMatrix(); + GL11.glRotatef(180F, 1F, 0F, 0F); + float a = alpha; + if(inside) { + a += 0.3F; + y0 = -y; + } + + if(seg % 2 == 0) + GL11.glColor4f(0.6F, 0.6F, 0.6F, a); + else GL11.glColor4f(1F, 1F, 1F, a); + + mc.renderEngine.bindTexture(glowTexture); + tess.startDrawingQuads(); + for(int i = 0; i < segAngles; i++) { + float ang = i + seg * segAngles + shift; + double xp = Math.cos(ang * Math.PI / 180F) * s; + double zp = Math.sin(ang * Math.PI / 180F) * s; + + tess.addVertexWithUV(xp * m, y, zp * m, u, v); + tess.addVertexWithUV(xp, y0, zp, u, 0); + + xp = Math.cos((ang + 1) * Math.PI / 180F) * s; + zp = Math.sin((ang + 1) * Math.PI / 180F) * s; + + tess.addVertexWithUV(xp, y0, zp, 0, 0); + tess.addVertexWithUV(xp * m, y, zp * m, 0, v); + } + y0 = 0; + tess.draw(); + + GL11.glPopMatrix(); + } + GL11.glPopMatrix(); + } + + @SideOnly(Side.CLIENT) + public static void renderHUD(ScaledResolution resolution, EntityPlayer player, ItemStack stack) { + Minecraft.getMinecraft(); + int slot = getSegmentLookedAt(stack, player); + MultiversePosition pos = getWarpPoint(stack, slot); + + FontRenderer font = Minecraft.getMinecraft().fontRenderer; + String s = StatCollector.translateToLocal("botania.sign" + slot); + font.drawStringWithShadow(s, resolution.getScaledWidth() / 2 - font.getStringWidth(s) / 2, resolution.getScaledHeight() / 2 - 55, 0xFFD409); + + if(pos.isValid()) { + int dist = (int) vazkii.botania.common.core.helper.MathHelper.pointDistanceSpace(pos.x, pos.y, pos.z, player.posX, player.posY - 1.6, player.posZ); + + s = dist == 1 ? StatCollector.translateToLocal("botaniamisc.blockAway") : String.format(StatCollector.translateToLocal("botaniamisc.blocksAway"), dist); + font.drawStringWithShadow(s, resolution.getScaledWidth() / 2 - font.getStringWidth(s) / 2, resolution.getScaledHeight() / 2 - 40, 0x9999FF); + s = StatCollector.translateToLocal("botaniamisc.clickToTeleport"); + font.drawStringWithShadow(s, resolution.getScaledWidth() / 2 - font.getStringWidth(s) / 2, resolution.getScaledHeight() / 2 - 30, 0xFFFFFF); + s = StatCollector.translateToLocal("botaniamisc.clickToRemoveWarp"); + font.drawStringWithShadow(s, resolution.getScaledWidth() / 2 - font.getStringWidth(s) / 2, resolution.getScaledHeight() / 2 - 20, 0xFFFFFF); + } else { + s = StatCollector.translateToLocal("botaniamisc.unboundWarp"); + font.drawStringWithShadow(s, resolution.getScaledWidth() / 2 - font.getStringWidth(s) / 2, resolution.getScaledHeight() / 2 - 40, 0xFFFFFF); + s = StatCollector.translateToLocal("botaniamisc.clickToAddWarp"); + font.drawStringWithShadow(s, resolution.getScaledWidth() / 2 - font.getStringWidth(s) / 2, resolution.getScaledHeight() / 2 - 30, 0xFFFFFF); + } + } + + private static class MultiversePosition { + + public final double x, y, z; + public final int dim; + + public MultiversePosition(double x, double y, double z, int dim) { + this.x = x; + this.y = y; + this.z = z; + this.dim = dim; + } + + boolean isValid() { + return y > 0; + } + + } + */ } diff --git a/src/main/java/vazkii/botania/common/item/relic/ItemInfiniteFruit.java b/src/main/java/vazkii/botania/common/item/relic/ItemInfiniteFruit.java index 1e24a9fc5c..efb3991b5f 100644 --- a/src/main/java/vazkii/botania/common/item/relic/ItemInfiniteFruit.java +++ b/src/main/java/vazkii/botania/common/item/relic/ItemInfiniteFruit.java @@ -2,14 +2,17 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Mar 29, 2015, 10:12:55 PM (GMT)] */ package vazkii.botania.common.item.relic; +import cpw.mods.fml.relauncher.ReflectionHelper; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.EnumAction; @@ -21,70 +24,64 @@ import vazkii.botania.client.core.helper.IconHelper; import vazkii.botania.common.lib.LibItemNames; import vazkii.botania.common.lib.LibObfuscation; -import cpw.mods.fml.relauncher.ReflectionHelper; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; public class ItemInfiniteFruit extends ItemRelic implements IManaUsingItem { - public static IIcon dasBootIcon; - - public ItemInfiniteFruit() { - super(LibItemNames.INFINITE_FRUIT); - } - - @Override - public int getMaxItemUseDuration(ItemStack p_77626_1_) { - return 32; - } - - @Override - public EnumAction getItemUseAction(ItemStack p_77661_1_) { - return isBoot(p_77661_1_) ? EnumAction.drink : EnumAction.eat; - } - - @Override - public ItemStack onItemRightClick(ItemStack p_77659_1_, World p_77659_2_, EntityPlayer p_77659_3_) { - if(p_77659_3_.canEat(false) && isRightPlayer(p_77659_3_, p_77659_1_)) - p_77659_3_.setItemInUse(p_77659_1_, getMaxItemUseDuration(p_77659_1_)); - return p_77659_1_; - } - - @Override - public void onUsingTick(ItemStack stack, EntityPlayer player, int count) { - super.onUsingTick(stack, player, count); - - if(ManaItemHandler.requestManaExact(stack, player, 500, true)) { - if(count % 5 == 0) - player.getFoodStats().addStats(1, 1F); - - if(count == 5) - if(player.canEat(false)) - ReflectionHelper.setPrivateValue(EntityPlayer.class, player, 20, LibObfuscation.ITEM_IN_USE_COUNT); - } - } - - - @Override - @SideOnly(Side.CLIENT) - public void registerIcons(IIconRegister par1IconRegister) { - itemIcon = IconHelper.forItem(par1IconRegister, this); - dasBootIcon = IconHelper.forName(par1IconRegister, "dasBoot"); - } - - @Override - public IIcon getIconIndex(ItemStack par1ItemStack) { - return isBoot(par1ItemStack) ? dasBootIcon : super.getIconIndex(par1ItemStack); - } - - private boolean isBoot(ItemStack par1ItemStack) { - String name = par1ItemStack.getDisplayName().toLowerCase().trim(); - return name.equals("das boot"); - } - - @Override - public boolean usesMana(ItemStack stack) { - return true; - } - + public static IIcon dasBootIcon; + + public ItemInfiniteFruit() { + super(LibItemNames.INFINITE_FRUIT); + } + + @Override + public int getMaxItemUseDuration(ItemStack p_77626_1_) { + return 32; + } + + @Override + public EnumAction getItemUseAction(ItemStack p_77661_1_) { + return isBoot(p_77661_1_) ? EnumAction.drink : EnumAction.eat; + } + + @Override + public ItemStack onItemRightClick(ItemStack p_77659_1_, World p_77659_2_, EntityPlayer p_77659_3_) { + if (p_77659_3_.canEat(false) && isRightPlayer(p_77659_3_, p_77659_1_)) + p_77659_3_.setItemInUse(p_77659_1_, getMaxItemUseDuration(p_77659_1_)); + return p_77659_1_; + } + + @Override + public void onUsingTick(ItemStack stack, EntityPlayer player, int count) { + super.onUsingTick(stack, player, count); + + if (ManaItemHandler.requestManaExact(stack, player, 500, true)) { + if (count % 5 == 0) player.getFoodStats().addStats(1, 1F); + + if (count == 5) + if (player.canEat(false)) + ReflectionHelper.setPrivateValue(EntityPlayer.class, player, 20, LibObfuscation.ITEM_IN_USE_COUNT); + } + } + + @Override + @SideOnly(Side.CLIENT) + public void registerIcons(IIconRegister par1IconRegister) { + itemIcon = IconHelper.forItem(par1IconRegister, this); + dasBootIcon = IconHelper.forName(par1IconRegister, "dasBoot"); + } + + @Override + public IIcon getIconIndex(ItemStack par1ItemStack) { + return isBoot(par1ItemStack) ? dasBootIcon : super.getIconIndex(par1ItemStack); + } + + private boolean isBoot(ItemStack par1ItemStack) { + String name = par1ItemStack.getDisplayName().toLowerCase().trim(); + return name.equals("das boot"); + } + + @Override + public boolean usesMana(ItemStack stack) { + return true; + } } diff --git a/src/main/java/vazkii/botania/common/item/relic/ItemKingKey.java b/src/main/java/vazkii/botania/common/item/relic/ItemKingKey.java index 2dc32c505f..af89187021 100644 --- a/src/main/java/vazkii/botania/common/item/relic/ItemKingKey.java +++ b/src/main/java/vazkii/botania/common/item/relic/ItemKingKey.java @@ -2,16 +2,15 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Aug 16, 2015, 2:54:35 PM (GMT)] */ package vazkii.botania.common.item.relic; import java.util.Random; - import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.EnumAction; @@ -29,116 +28,117 @@ public class ItemKingKey extends ItemRelic implements IManaUsingItem { - private static final String TAG_WEAPONS_SPAWNED = "weaponsSpawned"; - private static final String TAG_CHARGING = "charging"; - - private static final int WEAPON_TYPES = 12; - public static IIcon[] weaponIcons; - - public ItemKingKey() { - super(LibItemNames.KING_KEY); - } - - @Override - public void registerIcons(IIconRegister par1IconRegister) { - super.registerIcons(par1IconRegister); - - weaponIcons = new IIcon[WEAPON_TYPES]; - for(int i = 0; i < WEAPON_TYPES; i++) - weaponIcons[i] = IconHelper.forName(par1IconRegister, "gateWeapon" + i); - } - - @Override - public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer) { - par3EntityPlayer.setItemInUse(par1ItemStack, getMaxItemUseDuration(par1ItemStack)); - setCharging(par1ItemStack, true); - return par1ItemStack; - } - - @Override - public void onPlayerStoppedUsing(ItemStack stack, World world, EntityPlayer player, int time) { - int spawned = getWeaponsSpawned(stack); - if(spawned == 20) { - setCharging(stack, false); - setWeaponsSpawned(stack, 0); - } - } - - @Override - public void onUsingTick(ItemStack stack, EntityPlayer player, int count) { - int spawned = getWeaponsSpawned(stack); - - if(count != getMaxItemUseDuration(stack) && spawned < 20 && !player.worldObj.isRemote && ManaItemHandler.requestManaExact(stack, player, 150, true)) { - Vector3 look = new Vector3(player.getLookVec()); - look.y = 0; - look.normalize().negate().multiply(2); - int div = spawned / 5; - int mod = spawned % 5; - - Vector3 pl = look.copy().add(Vector3.fromEntityCenter(player)).add(0, 1.6, div * 0.1); - - Random rand = player.worldObj.rand; - Vector3 axis = look.copy().normalize().crossProduct(new Vector3(-1, 0, -1)).normalize(); - Vector3 axis1 = axis.copy(); - - double rot = mod * Math.PI / 4 - Math.PI / 2; - - axis1.multiply(div * 3.5 + 5).rotate(rot, look); - if(axis1.y < 0) - axis1.y = -axis1.y; - - Vector3 end = pl.copy().add(axis1); - - EntityBabylonWeapon weapon = new EntityBabylonWeapon(player.worldObj, player); - weapon.posX = end.x; - weapon.posY = end.y; - weapon.posZ = end.z; - weapon.rotationYaw = player.rotationYaw; - weapon.setVariety(rand.nextInt(WEAPON_TYPES)); - weapon.setDelay(spawned); - weapon.setRotation(MathHelper.wrapAngleTo180_float(-player.rotationYaw + 180)); - - player.worldObj.spawnEntityInWorld(weapon); - player.worldObj.playSoundAtEntity(weapon, "botania:babylonSpawn", 1F, 1F + player.worldObj.rand.nextFloat() * 3F); - setWeaponsSpawned(stack, spawned + 1); - } - } - - @Override - public EnumAction getItemUseAction(ItemStack par1ItemStack) { - return EnumAction.bow; - } - - @Override - public int getMaxItemUseDuration(ItemStack par1ItemStack) { - return 72000; - } - - - public static boolean isCharging(ItemStack stack) { - return ItemNBTHelper.getBoolean(stack, TAG_CHARGING, false); - } - - public static int getWeaponsSpawned(ItemStack stack) { - return ItemNBTHelper.getInt(stack, TAG_WEAPONS_SPAWNED, 0); - } - - public static void setCharging(ItemStack stack, boolean charging) { - ItemNBTHelper.setBoolean(stack, TAG_CHARGING, charging); - } - - public static void setWeaponsSpawned(ItemStack stack, int count) { - ItemNBTHelper.setInt(stack, TAG_WEAPONS_SPAWNED, count); - } - - @Override - public boolean isFull3D() { - return true; - } - - @Override - public boolean usesMana(ItemStack stack) { - return true; - } - + private static final String TAG_WEAPONS_SPAWNED = "weaponsSpawned"; + private static final String TAG_CHARGING = "charging"; + + private static final int WEAPON_TYPES = 12; + public static IIcon[] weaponIcons; + + public ItemKingKey() { + super(LibItemNames.KING_KEY); + } + + @Override + public void registerIcons(IIconRegister par1IconRegister) { + super.registerIcons(par1IconRegister); + + weaponIcons = new IIcon[WEAPON_TYPES]; + for (int i = 0; i < WEAPON_TYPES; i++) weaponIcons[i] = IconHelper.forName(par1IconRegister, "gateWeapon" + i); + } + + @Override + public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer) { + par3EntityPlayer.setItemInUse(par1ItemStack, getMaxItemUseDuration(par1ItemStack)); + setCharging(par1ItemStack, true); + return par1ItemStack; + } + + @Override + public void onPlayerStoppedUsing(ItemStack stack, World world, EntityPlayer player, int time) { + int spawned = getWeaponsSpawned(stack); + if (spawned == 20) { + setCharging(stack, false); + setWeaponsSpawned(stack, 0); + } + } + + @Override + public void onUsingTick(ItemStack stack, EntityPlayer player, int count) { + int spawned = getWeaponsSpawned(stack); + + if (count != getMaxItemUseDuration(stack) + && spawned < 20 + && !player.worldObj.isRemote + && ManaItemHandler.requestManaExact(stack, player, 150, true)) { + Vector3 look = new Vector3(player.getLookVec()); + look.y = 0; + look.normalize().negate().multiply(2); + int div = spawned / 5; + int mod = spawned % 5; + + Vector3 pl = look.copy().add(Vector3.fromEntityCenter(player)).add(0, 1.6, div * 0.1); + + Random rand = player.worldObj.rand; + Vector3 axis = + look.copy().normalize().crossProduct(new Vector3(-1, 0, -1)).normalize(); + Vector3 axis1 = axis.copy(); + + double rot = mod * Math.PI / 4 - Math.PI / 2; + + axis1.multiply(div * 3.5 + 5).rotate(rot, look); + if (axis1.y < 0) axis1.y = -axis1.y; + + Vector3 end = pl.copy().add(axis1); + + EntityBabylonWeapon weapon = new EntityBabylonWeapon(player.worldObj, player); + weapon.posX = end.x; + weapon.posY = end.y; + weapon.posZ = end.z; + weapon.rotationYaw = player.rotationYaw; + weapon.setVariety(rand.nextInt(WEAPON_TYPES)); + weapon.setDelay(spawned); + weapon.setRotation(MathHelper.wrapAngleTo180_float(-player.rotationYaw + 180)); + + player.worldObj.spawnEntityInWorld(weapon); + player.worldObj.playSoundAtEntity( + weapon, "botania:babylonSpawn", 1F, 1F + player.worldObj.rand.nextFloat() * 3F); + setWeaponsSpawned(stack, spawned + 1); + } + } + + @Override + public EnumAction getItemUseAction(ItemStack par1ItemStack) { + return EnumAction.bow; + } + + @Override + public int getMaxItemUseDuration(ItemStack par1ItemStack) { + return 72000; + } + + public static boolean isCharging(ItemStack stack) { + return ItemNBTHelper.getBoolean(stack, TAG_CHARGING, false); + } + + public static int getWeaponsSpawned(ItemStack stack) { + return ItemNBTHelper.getInt(stack, TAG_WEAPONS_SPAWNED, 0); + } + + public static void setCharging(ItemStack stack, boolean charging) { + ItemNBTHelper.setBoolean(stack, TAG_CHARGING, charging); + } + + public static void setWeaponsSpawned(ItemStack stack, int count) { + ItemNBTHelper.setInt(stack, TAG_WEAPONS_SPAWNED, count); + } + + @Override + public boolean isFull3D() { + return true; + } + + @Override + public boolean usesMana(ItemStack stack) { + return true; + } } diff --git a/src/main/java/vazkii/botania/common/item/relic/ItemLokiRing.java b/src/main/java/vazkii/botania/common/item/relic/ItemLokiRing.java index 5f77e56350..0084bef3ba 100644 --- a/src/main/java/vazkii/botania/common/item/relic/ItemLokiRing.java +++ b/src/main/java/vazkii/botania/common/item/relic/ItemLokiRing.java @@ -2,17 +2,24 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Mar 29, 2015, 10:13:32 PM (GMT)] */ package vazkii.botania.common.item.relic; +import baubles.api.BaubleType; +import baubles.common.container.InventoryBaubles; +import baubles.common.lib.PlayerHandler; +import baubles.common.network.PacketHandler; +import baubles.common.network.PacketSyncBauble; +import cpw.mods.fml.common.eventhandler.SubscribeEvent; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; import java.util.ArrayList; import java.util.List; - import net.minecraft.block.Block; import net.minecraft.block.material.Material; import net.minecraft.client.Minecraft; @@ -38,249 +45,273 @@ import vazkii.botania.common.item.ModItems; import vazkii.botania.common.item.equipment.tool.ToolCommons; import vazkii.botania.common.lib.LibItemNames; -import baubles.api.BaubleType; -import baubles.common.container.InventoryBaubles; -import baubles.common.lib.PlayerHandler; -import baubles.common.network.PacketHandler; -import baubles.common.network.PacketSyncBauble; -import cpw.mods.fml.common.eventhandler.SubscribeEvent; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; public class ItemLokiRing extends ItemRelicBauble implements IExtendedWireframeCoordinateListProvider, IManaUsingItem { - private static final String TAG_CURSOR_LIST = "cursorList"; - private static final String TAG_CURSOR_PREFIX = "cursor"; - private static final String TAG_CURSOR_COUNT = "cursorCount"; - private static final String TAG_X_OFFSET = "xOffset"; - private static final String TAG_Y_OFFSET = "yOffset"; - private static final String TAG_Z_OFFSET = "zOffset"; - private static final String TAG_X_ORIGIN = "xOrigin"; - private static final String TAG_Y_ORIGIN = "yOrigin"; - private static final String TAG_Z_ORIGIN = "zOrigin"; - - public ItemLokiRing() { - super(LibItemNames.LOKI_RING); - MinecraftForge.EVENT_BUS.register(this); - } - - @SubscribeEvent - public void onPlayerInteract(PlayerInteractEvent event) { - EntityPlayer player = event.entityPlayer; - ItemStack lokiRing = getLokiRing(player); - if(lokiRing == null || player.worldObj.isRemote) - return; - - int slot = -1; - InventoryBaubles inv = PlayerHandler.getPlayerBaubles(player); - for(int i = 0; i < inv.getSizeInventory(); i++) { - ItemStack stack = inv.getStackInSlot(i); - if(stack == lokiRing) { - slot = i; - break; - } - } - - ItemStack heldItemStack = player.getCurrentEquippedItem(); - ChunkCoordinates originCoords = getOriginPos(lokiRing); - MovingObjectPosition lookPos = ToolCommons.raytraceFromEntity(player.worldObj, player, true, 10F); - List cursors = getCursorList(lokiRing); - int cursorCount = cursors.size(); - - int cost = Math.min(cursorCount, (int) Math.pow(Math.E, cursorCount * 0.25)); - - if(heldItemStack == null && event.action == Action.RIGHT_CLICK_BLOCK && player.isSneaking()) { - if(originCoords.posY == -1 && lookPos != null) { - setOriginPos(lokiRing, lookPos.blockX, lookPos.blockY, lookPos.blockZ); - setCursorList(lokiRing, null); - if(player instanceof EntityPlayerMP) - PacketHandler.INSTANCE.sendTo(new PacketSyncBauble(player, slot), (EntityPlayerMP) player); - } else if(lookPos != null) { - if(originCoords.posX == lookPos.blockX && originCoords.posY == lookPos.blockY && originCoords.posZ == lookPos.blockZ) { - setOriginPos(lokiRing, 0, -1, 0); - if(player instanceof EntityPlayerMP) - PacketHandler.INSTANCE.sendTo(new PacketSyncBauble(player, slot), (EntityPlayerMP) player); - } else { - addCursor : { - int relX = lookPos.blockX - originCoords.posX; - int relY = lookPos.blockY - originCoords.posY; - int relZ = lookPos.blockZ - originCoords.posZ; - - for(ChunkCoordinates cursor : cursors) - if(cursor.posX == relX && cursor.posY == relY && cursor.posZ == relZ) { - cursors.remove(cursor); - setCursorList(lokiRing, cursors); - if(player instanceof EntityPlayerMP) - PacketHandler.INSTANCE.sendTo(new PacketSyncBauble(player, slot), (EntityPlayerMP) player); - break addCursor; - } - - addCursor(lokiRing, relX, relY, relZ); - if(player instanceof EntityPlayerMP) - PacketHandler.INSTANCE.sendTo(new PacketSyncBauble(player, slot), (EntityPlayerMP) player); - } - } - } - } else if(heldItemStack != null && event.action == Action.RIGHT_CLICK_BLOCK && lookPos != null && player.isSneaking()) { - for(ChunkCoordinates cursor : cursors) { - int x = lookPos.blockX + cursor.posX; - int y = lookPos.blockY + cursor.posY; - int z = lookPos.blockZ + cursor.posZ; - Item item = heldItemStack.getItem(); - if(!player.worldObj.isAirBlock(x, y, z) && ManaItemHandler.requestManaExact(lokiRing, player, cost, true)) { - item.onItemUse(player.capabilities.isCreativeMode ? heldItemStack.copy() : heldItemStack, player, player.worldObj, x, y, z, lookPos.sideHit, (float) lookPos.hitVec.xCoord - x, (float) lookPos.hitVec.yCoord - y, (float) lookPos.hitVec.zCoord - z); - if(heldItemStack.stackSize == 0) { - event.setCanceled(true); - return; - } - } - } - } - } - - public static void breakOnAllCursors(EntityPlayer player, Item item, ItemStack stack, int x, int y, int z, int side) { - ItemStack lokiRing = getLokiRing(player); - if(lokiRing == null || player.worldObj.isRemote || !(item instanceof ISequentialBreaker)) - return; - - List cursors = getCursorList(lokiRing); - ISequentialBreaker breaker = (ISequentialBreaker) item; - World world = player.worldObj; - boolean silk = EnchantmentHelper.getEnchantmentLevel(Enchantment.silkTouch.effectId, stack) > 0; - int fortune = EnchantmentHelper.getEnchantmentLevel(Enchantment.fortune.effectId, stack); - boolean dispose = breaker.disposeOfTrashBlocks(stack); - - for(int i = 0; i < cursors.size(); i++) { - ChunkCoordinates coords = cursors.get(i); - int xp = x + coords.posX; - int yp = y + coords.posY; - int zp = z + coords.posZ; - Block block = world.getBlock(xp, yp, zp); - breaker.breakOtherBlock(player, stack, xp, yp, zp, x, y, z, side); - ToolCommons.removeBlockWithDrops(player, stack, player.worldObj, xp, yp, zp, x, y, z, block, new Material[] { block.getMaterial() }, silk, fortune, block.getBlockHardness(world, xp, yp, zp), dispose); - } - } - - @Override - public BaubleType getBaubleType(ItemStack arg0) { - return BaubleType.RING; - } - - @Override - public void onUnequipped(ItemStack stack, EntityLivingBase player) { - setCursorList(stack, null); - } - - @Override - @SideOnly(Side.CLIENT) - public List getWireframesToDraw(EntityPlayer player, ItemStack stack) { - if(getLokiRing(player) != stack) - return null; - - MovingObjectPosition lookPos = Minecraft.getMinecraft().objectMouseOver; - - if(lookPos != null && !player.worldObj.isAirBlock(lookPos.blockX, lookPos.blockY, lookPos.blockZ) && lookPos.entityHit == null) { - List list = getCursorList(stack); - ChunkCoordinates origin = getOriginPos(stack); - - if(origin.posY != -1) { - for(ChunkCoordinates coords : list) { - coords.posX += origin.posX; - coords.posY += origin.posY; - coords.posZ += origin.posZ; - } - } else for(ChunkCoordinates coords : list) { - coords.posX += lookPos.blockX; - coords.posY += lookPos.blockY; - coords.posZ += lookPos.blockZ; - } - - return list; - } - - return null; - } - - @Override - public ChunkCoordinates getSourceWireframe(EntityPlayer player, ItemStack stack) { - return getLokiRing(player) == stack ? getOriginPos(stack) : null; - } - - private static ItemStack getLokiRing(EntityPlayer player) { - InventoryBaubles baubles = PlayerHandler.getPlayerBaubles(player); - ItemStack stack1 = baubles.getStackInSlot(1); - ItemStack stack2 = baubles.getStackInSlot(2); - return isLokiRing(stack1) ? stack1 : isLokiRing(stack2) ? stack2 : null; - } - - private static boolean isLokiRing(ItemStack stack) { - return stack != null && (stack.getItem() == ModItems.lokiRing || stack.getItem() == ModItems.aesirRing); - } - - private static ChunkCoordinates getOriginPos(ItemStack stack) { - int x = ItemNBTHelper.getInt(stack, TAG_X_ORIGIN, 0); - int y = ItemNBTHelper.getInt(stack, TAG_Y_ORIGIN, -1); - int z = ItemNBTHelper.getInt(stack, TAG_Z_ORIGIN, 0); - return new ChunkCoordinates(x, y, z); - } - - private static void setOriginPos(ItemStack stack, int x, int y, int z) { - ItemNBTHelper.setInt(stack, TAG_X_ORIGIN, x); - ItemNBTHelper.setInt(stack, TAG_Y_ORIGIN, y); - ItemNBTHelper.setInt(stack, TAG_Z_ORIGIN, z); - } - - private static List getCursorList(ItemStack stack) { - NBTTagCompound cmp = ItemNBTHelper.getCompound(stack, TAG_CURSOR_LIST, false); - List cursors = new ArrayList(); - - int count = cmp.getInteger(TAG_CURSOR_COUNT); - for(int i = 0; i < count; i++) { - NBTTagCompound cursorCmp = cmp.getCompoundTag(TAG_CURSOR_PREFIX + i); - int x = cursorCmp.getInteger(TAG_X_OFFSET); - int y = cursorCmp.getInteger(TAG_Y_OFFSET); - int z = cursorCmp.getInteger(TAG_Z_OFFSET); - cursors.add(new ChunkCoordinates(x, y, z)); - } - - return cursors; - } - - private static void setCursorList(ItemStack stack, List cursors) { - NBTTagCompound cmp = new NBTTagCompound(); - if(cursors != null) { - int i = 0; - for(ChunkCoordinates cursor : cursors) { - NBTTagCompound cursorCmp = cursorToCmp(cursor.posX, cursor.posY, cursor.posZ); - cmp.setTag(TAG_CURSOR_PREFIX + i, cursorCmp); - i++; - } - cmp.setInteger(TAG_CURSOR_COUNT, i); - } - - ItemNBTHelper.setCompound(stack, TAG_CURSOR_LIST, cmp); - } - - private static NBTTagCompound cursorToCmp(int x, int y, int z) { - NBTTagCompound cmp = new NBTTagCompound(); - cmp.setInteger(TAG_X_OFFSET, x); - cmp.setInteger(TAG_Y_OFFSET, y); - cmp.setInteger(TAG_Z_OFFSET, z); - return cmp; - } - - private static void addCursor(ItemStack stack, int x, int y, int z) { - NBTTagCompound cmp = ItemNBTHelper.getCompound(stack, TAG_CURSOR_LIST, false); - int count = cmp.getInteger(TAG_CURSOR_COUNT); - cmp.setTag(TAG_CURSOR_PREFIX + count, cursorToCmp(x, y, z)); - cmp.setInteger(TAG_CURSOR_COUNT, count + 1); - ItemNBTHelper.setCompound(stack, TAG_CURSOR_LIST, cmp); - } - - @Override - public boolean usesMana(ItemStack stack) { - return true; - } - + private static final String TAG_CURSOR_LIST = "cursorList"; + private static final String TAG_CURSOR_PREFIX = "cursor"; + private static final String TAG_CURSOR_COUNT = "cursorCount"; + private static final String TAG_X_OFFSET = "xOffset"; + private static final String TAG_Y_OFFSET = "yOffset"; + private static final String TAG_Z_OFFSET = "zOffset"; + private static final String TAG_X_ORIGIN = "xOrigin"; + private static final String TAG_Y_ORIGIN = "yOrigin"; + private static final String TAG_Z_ORIGIN = "zOrigin"; + + public ItemLokiRing() { + super(LibItemNames.LOKI_RING); + MinecraftForge.EVENT_BUS.register(this); + } + + @SubscribeEvent + public void onPlayerInteract(PlayerInteractEvent event) { + EntityPlayer player = event.entityPlayer; + ItemStack lokiRing = getLokiRing(player); + if (lokiRing == null || player.worldObj.isRemote) return; + + int slot = -1; + InventoryBaubles inv = PlayerHandler.getPlayerBaubles(player); + for (int i = 0; i < inv.getSizeInventory(); i++) { + ItemStack stack = inv.getStackInSlot(i); + if (stack == lokiRing) { + slot = i; + break; + } + } + + ItemStack heldItemStack = player.getCurrentEquippedItem(); + ChunkCoordinates originCoords = getOriginPos(lokiRing); + MovingObjectPosition lookPos = ToolCommons.raytraceFromEntity(player.worldObj, player, true, 10F); + List cursors = getCursorList(lokiRing); + int cursorCount = cursors.size(); + + int cost = Math.min(cursorCount, (int) Math.pow(Math.E, cursorCount * 0.25)); + + if (heldItemStack == null && event.action == Action.RIGHT_CLICK_BLOCK && player.isSneaking()) { + if (originCoords.posY == -1 && lookPos != null) { + setOriginPos(lokiRing, lookPos.blockX, lookPos.blockY, lookPos.blockZ); + setCursorList(lokiRing, null); + if (player instanceof EntityPlayerMP) + PacketHandler.INSTANCE.sendTo(new PacketSyncBauble(player, slot), (EntityPlayerMP) player); + } else if (lookPos != null) { + if (originCoords.posX == lookPos.blockX + && originCoords.posY == lookPos.blockY + && originCoords.posZ == lookPos.blockZ) { + setOriginPos(lokiRing, 0, -1, 0); + if (player instanceof EntityPlayerMP) + PacketHandler.INSTANCE.sendTo(new PacketSyncBauble(player, slot), (EntityPlayerMP) player); + } else { + addCursor: + { + int relX = lookPos.blockX - originCoords.posX; + int relY = lookPos.blockY - originCoords.posY; + int relZ = lookPos.blockZ - originCoords.posZ; + + for (ChunkCoordinates cursor : cursors) + if (cursor.posX == relX && cursor.posY == relY && cursor.posZ == relZ) { + cursors.remove(cursor); + setCursorList(lokiRing, cursors); + if (player instanceof EntityPlayerMP) + PacketHandler.INSTANCE.sendTo( + new PacketSyncBauble(player, slot), (EntityPlayerMP) player); + break addCursor; + } + + addCursor(lokiRing, relX, relY, relZ); + if (player instanceof EntityPlayerMP) + PacketHandler.INSTANCE.sendTo(new PacketSyncBauble(player, slot), (EntityPlayerMP) player); + } + } + } + } else if (heldItemStack != null + && event.action == Action.RIGHT_CLICK_BLOCK + && lookPos != null + && player.isSneaking()) { + for (ChunkCoordinates cursor : cursors) { + int x = lookPos.blockX + cursor.posX; + int y = lookPos.blockY + cursor.posY; + int z = lookPos.blockZ + cursor.posZ; + Item item = heldItemStack.getItem(); + if (!player.worldObj.isAirBlock(x, y, z) + && ManaItemHandler.requestManaExact(lokiRing, player, cost, true)) { + item.onItemUse( + player.capabilities.isCreativeMode ? heldItemStack.copy() : heldItemStack, + player, + player.worldObj, + x, + y, + z, + lookPos.sideHit, + (float) lookPos.hitVec.xCoord - x, + (float) lookPos.hitVec.yCoord - y, + (float) lookPos.hitVec.zCoord - z); + if (heldItemStack.stackSize == 0) { + event.setCanceled(true); + return; + } + } + } + } + } + + public static void breakOnAllCursors( + EntityPlayer player, Item item, ItemStack stack, int x, int y, int z, int side) { + ItemStack lokiRing = getLokiRing(player); + if (lokiRing == null || player.worldObj.isRemote || !(item instanceof ISequentialBreaker)) return; + + List cursors = getCursorList(lokiRing); + ISequentialBreaker breaker = (ISequentialBreaker) item; + World world = player.worldObj; + boolean silk = EnchantmentHelper.getEnchantmentLevel(Enchantment.silkTouch.effectId, stack) > 0; + int fortune = EnchantmentHelper.getEnchantmentLevel(Enchantment.fortune.effectId, stack); + boolean dispose = breaker.disposeOfTrashBlocks(stack); + + for (int i = 0; i < cursors.size(); i++) { + ChunkCoordinates coords = cursors.get(i); + int xp = x + coords.posX; + int yp = y + coords.posY; + int zp = z + coords.posZ; + Block block = world.getBlock(xp, yp, zp); + breaker.breakOtherBlock(player, stack, xp, yp, zp, x, y, z, side); + ToolCommons.removeBlockWithDrops( + player, + stack, + player.worldObj, + xp, + yp, + zp, + x, + y, + z, + block, + new Material[] {block.getMaterial()}, + silk, + fortune, + block.getBlockHardness(world, xp, yp, zp), + dispose); + } + } + + @Override + public BaubleType getBaubleType(ItemStack arg0) { + return BaubleType.RING; + } + + @Override + public void onUnequipped(ItemStack stack, EntityLivingBase player) { + setCursorList(stack, null); + } + + @Override + @SideOnly(Side.CLIENT) + public List getWireframesToDraw(EntityPlayer player, ItemStack stack) { + if (getLokiRing(player) != stack) return null; + + MovingObjectPosition lookPos = Minecraft.getMinecraft().objectMouseOver; + + if (lookPos != null + && !player.worldObj.isAirBlock(lookPos.blockX, lookPos.blockY, lookPos.blockZ) + && lookPos.entityHit == null) { + List list = getCursorList(stack); + ChunkCoordinates origin = getOriginPos(stack); + + if (origin.posY != -1) { + for (ChunkCoordinates coords : list) { + coords.posX += origin.posX; + coords.posY += origin.posY; + coords.posZ += origin.posZ; + } + } else + for (ChunkCoordinates coords : list) { + coords.posX += lookPos.blockX; + coords.posY += lookPos.blockY; + coords.posZ += lookPos.blockZ; + } + + return list; + } + + return null; + } + + @Override + public ChunkCoordinates getSourceWireframe(EntityPlayer player, ItemStack stack) { + return getLokiRing(player) == stack ? getOriginPos(stack) : null; + } + + private static ItemStack getLokiRing(EntityPlayer player) { + InventoryBaubles baubles = PlayerHandler.getPlayerBaubles(player); + ItemStack stack1 = baubles.getStackInSlot(1); + ItemStack stack2 = baubles.getStackInSlot(2); + return isLokiRing(stack1) ? stack1 : isLokiRing(stack2) ? stack2 : null; + } + + private static boolean isLokiRing(ItemStack stack) { + return stack != null && (stack.getItem() == ModItems.lokiRing || stack.getItem() == ModItems.aesirRing); + } + + private static ChunkCoordinates getOriginPos(ItemStack stack) { + int x = ItemNBTHelper.getInt(stack, TAG_X_ORIGIN, 0); + int y = ItemNBTHelper.getInt(stack, TAG_Y_ORIGIN, -1); + int z = ItemNBTHelper.getInt(stack, TAG_Z_ORIGIN, 0); + return new ChunkCoordinates(x, y, z); + } + + private static void setOriginPos(ItemStack stack, int x, int y, int z) { + ItemNBTHelper.setInt(stack, TAG_X_ORIGIN, x); + ItemNBTHelper.setInt(stack, TAG_Y_ORIGIN, y); + ItemNBTHelper.setInt(stack, TAG_Z_ORIGIN, z); + } + + private static List getCursorList(ItemStack stack) { + NBTTagCompound cmp = ItemNBTHelper.getCompound(stack, TAG_CURSOR_LIST, false); + List cursors = new ArrayList(); + + int count = cmp.getInteger(TAG_CURSOR_COUNT); + for (int i = 0; i < count; i++) { + NBTTagCompound cursorCmp = cmp.getCompoundTag(TAG_CURSOR_PREFIX + i); + int x = cursorCmp.getInteger(TAG_X_OFFSET); + int y = cursorCmp.getInteger(TAG_Y_OFFSET); + int z = cursorCmp.getInteger(TAG_Z_OFFSET); + cursors.add(new ChunkCoordinates(x, y, z)); + } + + return cursors; + } + + private static void setCursorList(ItemStack stack, List cursors) { + NBTTagCompound cmp = new NBTTagCompound(); + if (cursors != null) { + int i = 0; + for (ChunkCoordinates cursor : cursors) { + NBTTagCompound cursorCmp = cursorToCmp(cursor.posX, cursor.posY, cursor.posZ); + cmp.setTag(TAG_CURSOR_PREFIX + i, cursorCmp); + i++; + } + cmp.setInteger(TAG_CURSOR_COUNT, i); + } + + ItemNBTHelper.setCompound(stack, TAG_CURSOR_LIST, cmp); + } + + private static NBTTagCompound cursorToCmp(int x, int y, int z) { + NBTTagCompound cmp = new NBTTagCompound(); + cmp.setInteger(TAG_X_OFFSET, x); + cmp.setInteger(TAG_Y_OFFSET, y); + cmp.setInteger(TAG_Z_OFFSET, z); + return cmp; + } + + private static void addCursor(ItemStack stack, int x, int y, int z) { + NBTTagCompound cmp = ItemNBTHelper.getCompound(stack, TAG_CURSOR_LIST, false); + int count = cmp.getInteger(TAG_CURSOR_COUNT); + cmp.setTag(TAG_CURSOR_PREFIX + count, cursorToCmp(x, y, z)); + cmp.setInteger(TAG_CURSOR_COUNT, count + 1); + ItemNBTHelper.setCompound(stack, TAG_CURSOR_LIST, cmp); + } + + @Override + public boolean usesMana(ItemStack stack) { + return true; + } } - diff --git a/src/main/java/vazkii/botania/common/item/relic/ItemOdinRing.java b/src/main/java/vazkii/botania/common/item/relic/ItemOdinRing.java index 3eaa7da187..63f7db71f9 100644 --- a/src/main/java/vazkii/botania/common/item/relic/ItemOdinRing.java +++ b/src/main/java/vazkii/botania/common/item/relic/ItemOdinRing.java @@ -2,17 +2,22 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Mar 29, 2015, 10:13:41 PM (GMT)] */ package vazkii.botania.common.item.relic; +import baubles.api.BaubleType; +import baubles.common.container.InventoryBaubles; +import baubles.common.lib.PlayerHandler; +import com.google.common.collect.HashMultimap; +import com.google.common.collect.Multimap; +import cpw.mods.fml.common.eventhandler.SubscribeEvent; import java.util.ArrayList; import java.util.List; - import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.SharedMonsterAttributes; import net.minecraft.entity.ai.attributes.AttributeModifier; @@ -24,86 +29,76 @@ import vazkii.botania.common.core.handler.ConfigHandler; import vazkii.botania.common.item.ModItems; import vazkii.botania.common.lib.LibItemNames; -import baubles.api.BaubleType; -import baubles.common.container.InventoryBaubles; -import baubles.common.lib.PlayerHandler; - -import com.google.common.collect.HashMultimap; -import com.google.common.collect.Multimap; - -import cpw.mods.fml.common.eventhandler.SubscribeEvent; public class ItemOdinRing extends ItemRelicBauble { - public static List damageNegations = new ArrayList(); - - Multimap attributes = HashMultimap.create(); - - public ItemOdinRing() { - super(LibItemNames.ODIN_RING); - MinecraftForge.EVENT_BUS.register(this); - - damageNegations.add(DamageSource.drown.damageType); - damageNegations.add(DamageSource.fall.damageType); - damageNegations.add(DamageSource.lava.damageType); - if(ConfigHandler.ringOfOdinFireResist) { - damageNegations.add(DamageSource.inFire.damageType); - damageNegations.add(DamageSource.onFire.damageType); - } - - damageNegations.add(DamageSource.inWall.damageType); - damageNegations.add(DamageSource.starve.damageType); - } - - @Override - public void onValidPlayerWornTick(ItemStack stack, EntityPlayer player) { - if(player.isBurning() && ConfigHandler.ringOfOdinFireResist) - player.extinguish(); - } - - @SubscribeEvent - public void onPlayerAttacked(LivingAttackEvent event) { - if(event.entityLiving instanceof EntityPlayer) { - EntityPlayer player = (EntityPlayer) event.entityLiving; - if(getOdinRing(player) != null && damageNegations.contains(event.source.damageType)) - event.setCanceled(true); - } - } - - @Override - public BaubleType getBaubleType(ItemStack arg0) { - return BaubleType.RING; - } - - public static ItemStack getOdinRing(EntityPlayer player) { - InventoryBaubles baubles = PlayerHandler.getPlayerBaubles(player); - ItemStack stack1 = baubles.getStackInSlot(1); - ItemStack stack2 = baubles.getStackInSlot(2); - return isOdinRing(stack1) ? stack1 : isOdinRing(stack2) ? stack2 : null; - } - - private static boolean isOdinRing(ItemStack stack) { - return stack != null && (stack.getItem() == ModItems.odinRing || stack.getItem() == ModItems.aesirRing); - } - - @Override - public void onEquippedOrLoadedIntoWorld(ItemStack stack, EntityLivingBase player) { - attributes.clear(); - fillModifiers(attributes, stack); - player.getAttributeMap().applyAttributeModifiers(attributes); - } - - @Override - public void onUnequipped(ItemStack stack, EntityLivingBase player) { - attributes.clear(); - fillModifiers(attributes, stack); - player.getAttributeMap().removeAttributeModifiers(attributes); - } - - - void fillModifiers(Multimap attributes, ItemStack stack) { - attributes.put(SharedMonsterAttributes.maxHealth.getAttributeUnlocalizedName(), new AttributeModifier(getBaubleUUID(stack), "Bauble modifier", 20, 0)); - } - + public static List damageNegations = new ArrayList(); + + Multimap attributes = HashMultimap.create(); + + public ItemOdinRing() { + super(LibItemNames.ODIN_RING); + MinecraftForge.EVENT_BUS.register(this); + + damageNegations.add(DamageSource.drown.damageType); + damageNegations.add(DamageSource.fall.damageType); + damageNegations.add(DamageSource.lava.damageType); + if (ConfigHandler.ringOfOdinFireResist) { + damageNegations.add(DamageSource.inFire.damageType); + damageNegations.add(DamageSource.onFire.damageType); + } + + damageNegations.add(DamageSource.inWall.damageType); + damageNegations.add(DamageSource.starve.damageType); + } + + @Override + public void onValidPlayerWornTick(ItemStack stack, EntityPlayer player) { + if (player.isBurning() && ConfigHandler.ringOfOdinFireResist) player.extinguish(); + } + + @SubscribeEvent + public void onPlayerAttacked(LivingAttackEvent event) { + if (event.entityLiving instanceof EntityPlayer) { + EntityPlayer player = (EntityPlayer) event.entityLiving; + if (getOdinRing(player) != null && damageNegations.contains(event.source.damageType)) + event.setCanceled(true); + } + } + + @Override + public BaubleType getBaubleType(ItemStack arg0) { + return BaubleType.RING; + } + + public static ItemStack getOdinRing(EntityPlayer player) { + InventoryBaubles baubles = PlayerHandler.getPlayerBaubles(player); + ItemStack stack1 = baubles.getStackInSlot(1); + ItemStack stack2 = baubles.getStackInSlot(2); + return isOdinRing(stack1) ? stack1 : isOdinRing(stack2) ? stack2 : null; + } + + private static boolean isOdinRing(ItemStack stack) { + return stack != null && (stack.getItem() == ModItems.odinRing || stack.getItem() == ModItems.aesirRing); + } + + @Override + public void onEquippedOrLoadedIntoWorld(ItemStack stack, EntityLivingBase player) { + attributes.clear(); + fillModifiers(attributes, stack); + player.getAttributeMap().applyAttributeModifiers(attributes); + } + + @Override + public void onUnequipped(ItemStack stack, EntityLivingBase player) { + attributes.clear(); + fillModifiers(attributes, stack); + player.getAttributeMap().removeAttributeModifiers(attributes); + } + + void fillModifiers(Multimap attributes, ItemStack stack) { + attributes.put( + SharedMonsterAttributes.maxHealth.getAttributeUnlocalizedName(), + new AttributeModifier(getBaubleUUID(stack), "Bauble modifier", 20, 0)); + } } - diff --git a/src/main/java/vazkii/botania/common/item/relic/ItemRelic.java b/src/main/java/vazkii/botania/common/item/relic/ItemRelic.java index 0285c8f7a5..e3e8e9330e 100644 --- a/src/main/java/vazkii/botania/common/item/relic/ItemRelic.java +++ b/src/main/java/vazkii/botania/common/item/relic/ItemRelic.java @@ -2,16 +2,15 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Mar 29, 2015, 7:54:40 PM (GMT)] */ package vazkii.botania.common.item.relic; import java.util.List; - import net.minecraft.client.gui.GuiScreen; import net.minecraft.entity.Entity; import net.minecraft.entity.player.EntityPlayer; @@ -30,124 +29,126 @@ public class ItemRelic extends ItemMod implements IRelic { - private static final String TAG_SOULBIND = "soulbind"; - - Achievement achievement; - - public ItemRelic(String name) { - setUnlocalizedName(name); - setMaxStackSize(1); - } - - @Override - public void onUpdate(ItemStack p_77663_1_, World p_77663_2_, Entity p_77663_3_, int p_77663_4_, boolean p_77663_5_) { - if(p_77663_3_ instanceof EntityPlayer) - updateRelic(p_77663_1_, (EntityPlayer) p_77663_3_); - } - - @Override - public void addInformation(ItemStack p_77624_1_, EntityPlayer p_77624_2_, List p_77624_3_, boolean p_77624_4_) { - addBindInfo(p_77624_3_, p_77624_1_, p_77624_2_); - } - - public static void addBindInfo(List list, ItemStack stack, EntityPlayer player) { - if(GuiScreen.isShiftKeyDown()) { - String bind = getSoulbindUsernameS(stack); - if(bind.isEmpty()) - addStringToTooltip(StatCollector.translateToLocal("botaniamisc.relicUnbound"), list); - else { - addStringToTooltip(String.format(StatCollector.translateToLocal("botaniamisc.relicSoulbound"), bind), list); - if(!isRightPlayer(player, stack)) - addStringToTooltip(String.format(StatCollector.translateToLocal("botaniamisc.notYourSagittarius"), bind), list); - } - - if(stack.getItem() == ModItems.aesirRing) - addStringToTooltip(StatCollector.translateToLocal("botaniamisc.dropIkea"), list); - - if(stack.getItem() == ModItems.dice) { - addStringToTooltip("", list); - String name = stack.getUnlocalizedName() + ".poem"; - for(int i = 0; i < 4; i++) - addStringToTooltip(EnumChatFormatting.ITALIC + StatCollector.translateToLocal(name + i), list); - } - } else addStringToTooltip(StatCollector.translateToLocal("botaniamisc.shiftinfo"), list); - } - - public boolean shouldDamageWrongPlayer() { - return true; - } - - @Override - public int getEntityLifespan(ItemStack itemStack, World world) { - return Integer.MAX_VALUE; - } - - static void addStringToTooltip(String s, List tooltip) { - tooltip.add(s.replaceAll("&", "\u00a7")); - } - - public static String getSoulbindUsernameS(ItemStack stack) { - return ItemNBTHelper.getString(stack, TAG_SOULBIND, ""); - } - - public static void updateRelic(ItemStack stack, EntityPlayer player) { - if(stack == null || !(stack.getItem() instanceof IRelic)) - return; - - String soulbind = getSoulbindUsernameS(stack); - if(soulbind.isEmpty()) { - player.addStat(((IRelic) stack.getItem()).getBindAchievement(), 1); - bindToPlayer(player, stack); - soulbind = getSoulbindUsernameS(stack); - } - - if(!isRightPlayer(player, stack) && player.ticksExisted % 10 == 0 && (!(stack.getItem() instanceof ItemRelic) || ((ItemRelic) stack.getItem()).shouldDamageWrongPlayer())) - player.attackEntityFrom(damageSource(), 2); - } - - public static void bindToPlayer(EntityPlayer player, ItemStack stack) { - bindToUsernameS(player.getCommandSenderName(), stack); - } - - public static void bindToUsernameS(String username, ItemStack stack) { - ItemNBTHelper.setString(stack, TAG_SOULBIND, username); - } - - public static boolean isRightPlayer(EntityPlayer player, ItemStack stack) { - return isRightPlayer(player.getCommandSenderName(), stack); - } - - public static boolean isRightPlayer(String player, ItemStack stack) { - return getSoulbindUsernameS(stack).equals(player); - } - - public static DamageSource damageSource() { - return new DamageSource("botania-relic"); - } - - @Override - public void bindToUsername(String playerName, ItemStack stack) { - bindToUsernameS(playerName, stack); - } - - @Override - public String getSoulbindUsername(ItemStack stack) { - return getSoulbindUsernameS(stack); - } - - @Override - public Achievement getBindAchievement() { - return achievement; - } - - @Override - public void setBindAchievement(Achievement achievement) { - this.achievement = achievement; - } - - @Override - public EnumRarity getRarity(ItemStack p_77613_1_) { - return BotaniaAPI.rarityRelic; - } - + private static final String TAG_SOULBIND = "soulbind"; + + Achievement achievement; + + public ItemRelic(String name) { + setUnlocalizedName(name); + setMaxStackSize(1); + } + + @Override + public void onUpdate( + ItemStack p_77663_1_, World p_77663_2_, Entity p_77663_3_, int p_77663_4_, boolean p_77663_5_) { + if (p_77663_3_ instanceof EntityPlayer) updateRelic(p_77663_1_, (EntityPlayer) p_77663_3_); + } + + @Override + public void addInformation(ItemStack p_77624_1_, EntityPlayer p_77624_2_, List p_77624_3_, boolean p_77624_4_) { + addBindInfo(p_77624_3_, p_77624_1_, p_77624_2_); + } + + public static void addBindInfo(List list, ItemStack stack, EntityPlayer player) { + if (GuiScreen.isShiftKeyDown()) { + String bind = getSoulbindUsernameS(stack); + if (bind.isEmpty()) addStringToTooltip(StatCollector.translateToLocal("botaniamisc.relicUnbound"), list); + else { + addStringToTooltip( + String.format(StatCollector.translateToLocal("botaniamisc.relicSoulbound"), bind), list); + if (!isRightPlayer(player, stack)) + addStringToTooltip( + String.format(StatCollector.translateToLocal("botaniamisc.notYourSagittarius"), bind), + list); + } + + if (stack.getItem() == ModItems.aesirRing) + addStringToTooltip(StatCollector.translateToLocal("botaniamisc.dropIkea"), list); + + if (stack.getItem() == ModItems.dice) { + addStringToTooltip("", list); + String name = stack.getUnlocalizedName() + ".poem"; + for (int i = 0; i < 4; i++) + addStringToTooltip(EnumChatFormatting.ITALIC + StatCollector.translateToLocal(name + i), list); + } + } else addStringToTooltip(StatCollector.translateToLocal("botaniamisc.shiftinfo"), list); + } + + public boolean shouldDamageWrongPlayer() { + return true; + } + + @Override + public int getEntityLifespan(ItemStack itemStack, World world) { + return Integer.MAX_VALUE; + } + + static void addStringToTooltip(String s, List tooltip) { + tooltip.add(s.replaceAll("&", "\u00a7")); + } + + public static String getSoulbindUsernameS(ItemStack stack) { + return ItemNBTHelper.getString(stack, TAG_SOULBIND, ""); + } + + public static void updateRelic(ItemStack stack, EntityPlayer player) { + if (stack == null || !(stack.getItem() instanceof IRelic)) return; + + String soulbind = getSoulbindUsernameS(stack); + if (soulbind.isEmpty()) { + player.addStat(((IRelic) stack.getItem()).getBindAchievement(), 1); + bindToPlayer(player, stack); + soulbind = getSoulbindUsernameS(stack); + } + + if (!isRightPlayer(player, stack) + && player.ticksExisted % 10 == 0 + && (!(stack.getItem() instanceof ItemRelic) || ((ItemRelic) stack.getItem()).shouldDamageWrongPlayer())) + player.attackEntityFrom(damageSource(), 2); + } + + public static void bindToPlayer(EntityPlayer player, ItemStack stack) { + bindToUsernameS(player.getCommandSenderName(), stack); + } + + public static void bindToUsernameS(String username, ItemStack stack) { + ItemNBTHelper.setString(stack, TAG_SOULBIND, username); + } + + public static boolean isRightPlayer(EntityPlayer player, ItemStack stack) { + return isRightPlayer(player.getCommandSenderName(), stack); + } + + public static boolean isRightPlayer(String player, ItemStack stack) { + return getSoulbindUsernameS(stack).equals(player); + } + + public static DamageSource damageSource() { + return new DamageSource("botania-relic"); + } + + @Override + public void bindToUsername(String playerName, ItemStack stack) { + bindToUsernameS(playerName, stack); + } + + @Override + public String getSoulbindUsername(ItemStack stack) { + return getSoulbindUsernameS(stack); + } + + @Override + public Achievement getBindAchievement() { + return achievement; + } + + @Override + public void setBindAchievement(Achievement achievement) { + this.achievement = achievement; + } + + @Override + public EnumRarity getRarity(ItemStack p_77613_1_) { + return BotaniaAPI.rarityRelic; + } } diff --git a/src/main/java/vazkii/botania/common/item/relic/ItemRelicBauble.java b/src/main/java/vazkii/botania/common/item/relic/ItemRelicBauble.java index 6d735743b6..7a90ce34c4 100644 --- a/src/main/java/vazkii/botania/common/item/relic/ItemRelicBauble.java +++ b/src/main/java/vazkii/botania/common/item/relic/ItemRelicBauble.java @@ -2,16 +2,15 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Mar 29, 2015, 7:56:27 PM (GMT)] */ package vazkii.botania.common.item.relic; import java.util.List; - import net.minecraft.entity.Entity; import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.player.EntityPlayer; @@ -25,72 +24,70 @@ public abstract class ItemRelicBauble extends ItemBauble implements IRelic { - Achievement achievement; - - public ItemRelicBauble(String name) { - super(name); - } - - @Override - public void onUpdate(ItemStack p_77663_1_, World p_77663_2_, Entity p_77663_3_, int p_77663_4_, boolean p_77663_5_) { - if(p_77663_3_ instanceof EntityPlayer) - ItemRelic.updateRelic(p_77663_1_, (EntityPlayer) p_77663_3_); - } - - @Override - public void onWornTick(ItemStack stack, EntityLivingBase player) { - super.onWornTick(stack, player); - if(player instanceof EntityPlayer) { - EntityPlayer ePlayer = (EntityPlayer) player; - ItemRelic.updateRelic(stack, ePlayer); - if(ItemRelic.isRightPlayer(ePlayer, stack)) - onValidPlayerWornTick(stack, ePlayer); - } - } - - @Override - public void addHiddenTooltip(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, List par3List, boolean par4) { - super.addHiddenTooltip(par1ItemStack, par2EntityPlayer, par3List, par4); - ItemRelic.addBindInfo(par3List, par1ItemStack, par2EntityPlayer); - } - - public void onValidPlayerWornTick(ItemStack stack, EntityPlayer player) { - // NO-OP - } - - @Override - public boolean canEquip(ItemStack stack, EntityLivingBase player) { - return player instanceof EntityPlayer && ItemRelic.isRightPlayer((EntityPlayer) player, stack); - } - - @Override - public void bindToUsername(String playerName, ItemStack stack) { - ItemRelic.bindToUsernameS(playerName, stack); - } - - @Override - public String getSoulbindUsername(ItemStack stack) { - return ItemRelic.getSoulbindUsernameS(stack); - } - - @Override - public Achievement getBindAchievement() { - return achievement; - } - - @Override - public void setBindAchievement(Achievement achievement) { - this.achievement = achievement; - } - - @Override - public EnumRarity getRarity(ItemStack p_77613_1_) { - return BotaniaAPI.rarityRelic; - } - - @Override - public int getEntityLifespan(ItemStack itemStack, World world) { - return Integer.MAX_VALUE; - } - + Achievement achievement; + + public ItemRelicBauble(String name) { + super(name); + } + + @Override + public void onUpdate( + ItemStack p_77663_1_, World p_77663_2_, Entity p_77663_3_, int p_77663_4_, boolean p_77663_5_) { + if (p_77663_3_ instanceof EntityPlayer) ItemRelic.updateRelic(p_77663_1_, (EntityPlayer) p_77663_3_); + } + + @Override + public void onWornTick(ItemStack stack, EntityLivingBase player) { + super.onWornTick(stack, player); + if (player instanceof EntityPlayer) { + EntityPlayer ePlayer = (EntityPlayer) player; + ItemRelic.updateRelic(stack, ePlayer); + if (ItemRelic.isRightPlayer(ePlayer, stack)) onValidPlayerWornTick(stack, ePlayer); + } + } + + @Override + public void addHiddenTooltip(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, List par3List, boolean par4) { + super.addHiddenTooltip(par1ItemStack, par2EntityPlayer, par3List, par4); + ItemRelic.addBindInfo(par3List, par1ItemStack, par2EntityPlayer); + } + + public void onValidPlayerWornTick(ItemStack stack, EntityPlayer player) { + // NO-OP + } + + @Override + public boolean canEquip(ItemStack stack, EntityLivingBase player) { + return player instanceof EntityPlayer && ItemRelic.isRightPlayer((EntityPlayer) player, stack); + } + + @Override + public void bindToUsername(String playerName, ItemStack stack) { + ItemRelic.bindToUsernameS(playerName, stack); + } + + @Override + public String getSoulbindUsername(ItemStack stack) { + return ItemRelic.getSoulbindUsernameS(stack); + } + + @Override + public Achievement getBindAchievement() { + return achievement; + } + + @Override + public void setBindAchievement(Achievement achievement) { + this.achievement = achievement; + } + + @Override + public EnumRarity getRarity(ItemStack p_77613_1_) { + return BotaniaAPI.rarityRelic; + } + + @Override + public int getEntityLifespan(ItemStack itemStack, World world) { + return Integer.MAX_VALUE; + } } diff --git a/src/main/java/vazkii/botania/common/item/relic/ItemThorRing.java b/src/main/java/vazkii/botania/common/item/relic/ItemThorRing.java index 78dd94da2a..689801f441 100644 --- a/src/main/java/vazkii/botania/common/item/relic/ItemThorRing.java +++ b/src/main/java/vazkii/botania/common/item/relic/ItemThorRing.java @@ -2,42 +2,41 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Mar 29, 2015, 10:13:37 PM (GMT)] */ package vazkii.botania.common.item.relic; +import baubles.api.BaubleType; +import baubles.common.container.InventoryBaubles; +import baubles.common.lib.PlayerHandler; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; import vazkii.botania.common.item.ModItems; import vazkii.botania.common.lib.LibItemNames; -import baubles.api.BaubleType; -import baubles.common.container.InventoryBaubles; -import baubles.common.lib.PlayerHandler; public class ItemThorRing extends ItemRelicBauble { - public ItemThorRing() { - super(LibItemNames.THOR_RING); - } - - @Override - public BaubleType getBaubleType(ItemStack arg0) { - return BaubleType.RING; - } + public ItemThorRing() { + super(LibItemNames.THOR_RING); + } - public static ItemStack getThorRing(EntityPlayer player) { - InventoryBaubles baubles = PlayerHandler.getPlayerBaubles(player); - ItemStack stack1 = baubles.getStackInSlot(1); - ItemStack stack2 = baubles.getStackInSlot(2); - return isThorRing(stack1) ? stack1 : isThorRing(stack2) ? stack2 : null; - } + @Override + public BaubleType getBaubleType(ItemStack arg0) { + return BaubleType.RING; + } - private static boolean isThorRing(ItemStack stack) { - return stack != null && (stack.getItem() == ModItems.thorRing || stack.getItem() == ModItems.aesirRing); - } + public static ItemStack getThorRing(EntityPlayer player) { + InventoryBaubles baubles = PlayerHandler.getPlayerBaubles(player); + ItemStack stack1 = baubles.getStackInSlot(1); + ItemStack stack2 = baubles.getStackInSlot(2); + return isThorRing(stack1) ? stack1 : isThorRing(stack2) ? stack2 : null; + } + private static boolean isThorRing(ItemStack stack) { + return stack != null && (stack.getItem() == ModItems.thorRing || stack.getItem() == ModItems.aesirRing); + } } diff --git a/src/main/java/vazkii/botania/common/item/rod/ItemCobbleRod.java b/src/main/java/vazkii/botania/common/item/rod/ItemCobbleRod.java index 0a5df3c44f..bbbc48adcc 100644 --- a/src/main/java/vazkii/botania/common/item/rod/ItemCobbleRod.java +++ b/src/main/java/vazkii/botania/common/item/rod/ItemCobbleRod.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jan 24, 2015, 10:28:03 PM (GMT)] */ package vazkii.botania.common.item.rod; @@ -23,40 +23,64 @@ public class ItemCobbleRod extends ItemMod implements IManaUsingItem, IBlockProvider { - static final int COST = 150; - - public ItemCobbleRod() { - setMaxStackSize(1); - setUnlocalizedName(LibItemNames.COBBLE_ROD); - } - - @Override - public boolean onItemUse(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, World par3World, int par4, int par5, int par6, int par7, float par8, float par9, float par10) { - return ItemDirtRod.place(par1ItemStack, par2EntityPlayer, par3World, par4, par5, par6, par7, par8, par9, par10, Blocks.cobblestone, COST, 0.3F, 0.3F, 0.3F); - } - - @Override - public boolean isFull3D() { - return true; - } - - @Override - public boolean usesMana(ItemStack stack) { - return true; - } - - @Override - public boolean provideBlock(EntityPlayer player, ItemStack requestor, ItemStack stack, Block block, int meta, boolean doit) { - if(block == Blocks.cobblestone && meta == 0) - return !doit || ManaItemHandler.requestManaExactForTool(requestor, player, COST, true); - return false; - } - - @Override - public int getBlockCount(EntityPlayer player, ItemStack requestor, ItemStack stack, Block block, int meta) { - if(block == Blocks.cobblestone && meta == 0) - return -1; - return 0; - } + static final int COST = 150; + public ItemCobbleRod() { + setMaxStackSize(1); + setUnlocalizedName(LibItemNames.COBBLE_ROD); + } + + @Override + public boolean onItemUse( + ItemStack par1ItemStack, + EntityPlayer par2EntityPlayer, + World par3World, + int par4, + int par5, + int par6, + int par7, + float par8, + float par9, + float par10) { + return ItemDirtRod.place( + par1ItemStack, + par2EntityPlayer, + par3World, + par4, + par5, + par6, + par7, + par8, + par9, + par10, + Blocks.cobblestone, + COST, + 0.3F, + 0.3F, + 0.3F); + } + + @Override + public boolean isFull3D() { + return true; + } + + @Override + public boolean usesMana(ItemStack stack) { + return true; + } + + @Override + public boolean provideBlock( + EntityPlayer player, ItemStack requestor, ItemStack stack, Block block, int meta, boolean doit) { + if (block == Blocks.cobblestone && meta == 0) + return !doit || ManaItemHandler.requestManaExactForTool(requestor, player, COST, true); + return false; + } + + @Override + public int getBlockCount(EntityPlayer player, ItemStack requestor, ItemStack stack, Block block, int meta) { + if (block == Blocks.cobblestone && meta == 0) return -1; + return 0; + } } diff --git a/src/main/java/vazkii/botania/common/item/rod/ItemDirtRod.java b/src/main/java/vazkii/botania/common/item/rod/ItemDirtRod.java index d09ca7b671..5c5f9ee2c1 100644 --- a/src/main/java/vazkii/botania/common/item/rod/ItemDirtRod.java +++ b/src/main/java/vazkii/botania/common/item/rod/ItemDirtRod.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Apr 11, 2014, 2:53:41 PM (GMT)] */ package vazkii.botania.common.item.rod; @@ -31,71 +31,129 @@ public class ItemDirtRod extends ItemMod implements IManaUsingItem, ICraftAchievement, IBlockProvider { - static final int COST = 75; - - public ItemDirtRod() { - this(LibItemNames.DIRT_ROD); - } - - public ItemDirtRod(String name) { - super(); - setMaxStackSize(1); - setUnlocalizedName(name); - } - - @Override - public boolean onItemUse(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, World par3World, int par4, int par5, int par6, int par7, float par8, float par9, float par10) { - return place(par1ItemStack, par2EntityPlayer, par3World, par4, par5, par6, par7, par8, par9, par10, Blocks.dirt, COST, 0.35F, 0.2F, 0.05F); - } - - public static boolean place(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, World par3World, int par4, int par5, int par6, int par7, float par8, float par9, float par10, Block block, int cost, float r, float g, float b) { - if(ManaItemHandler.requestManaExactForTool(par1ItemStack, par2EntityPlayer, cost, false)) { - ForgeDirection dir = ForgeDirection.getOrientation(par7); - int entities = par3World.getEntitiesWithinAABB(EntityLivingBase.class, AxisAlignedBB.getBoundingBox(par4 + dir.offsetX, par5 + dir.offsetY, par6 + dir.offsetZ, par4 + dir.offsetX + 1, par5 + dir.offsetY + 1, par6 + dir.offsetZ + 1)).size(); - - if(entities == 0) { - ItemStack stackToPlace = new ItemStack(block); - stackToPlace.tryPlaceItemIntoWorld(par2EntityPlayer, par3World, par4, par5, par6, par7, par8, par9, par10); - - if(stackToPlace.stackSize == 0) { - ManaItemHandler.requestManaExactForTool(par1ItemStack, par2EntityPlayer, cost, true); - for(int i = 0; i < 6; i++) - Botania.proxy.sparkleFX(par3World, par4 + dir.offsetX + Math.random(), par5 + dir.offsetY + Math.random(), par6 + dir.offsetZ + Math.random(), r, g, b, 1F, 5); - } - } - } - - return true; - } - - @Override - public boolean isFull3D() { - return true; - } - - @Override - public boolean usesMana(ItemStack stack) { - return true; - } - - @Override - public Achievement getAchievementOnCraft(ItemStack stack, EntityPlayer player, IInventory matrix) { - return ModAchievements.dirtRodCraft; - } - - @Override - public boolean provideBlock(EntityPlayer player, ItemStack requestor, ItemStack stack, Block block, int meta, boolean doit) { - if(block == Blocks.dirt && meta == 0) - return !doit || ManaItemHandler.requestManaExactForTool(requestor, player, COST, true); - return false; - } - - @Override - public int getBlockCount(EntityPlayer player, ItemStack requestor, ItemStack stack, Block block, int meta) { - if(block == Blocks.dirt && meta == 0) - return -1; - return 0; - } - - -} \ No newline at end of file + static final int COST = 75; + + public ItemDirtRod() { + this(LibItemNames.DIRT_ROD); + } + + public ItemDirtRod(String name) { + super(); + setMaxStackSize(1); + setUnlocalizedName(name); + } + + @Override + public boolean onItemUse( + ItemStack par1ItemStack, + EntityPlayer par2EntityPlayer, + World par3World, + int par4, + int par5, + int par6, + int par7, + float par8, + float par9, + float par10) { + return place( + par1ItemStack, + par2EntityPlayer, + par3World, + par4, + par5, + par6, + par7, + par8, + par9, + par10, + Blocks.dirt, + COST, + 0.35F, + 0.2F, + 0.05F); + } + + public static boolean place( + ItemStack par1ItemStack, + EntityPlayer par2EntityPlayer, + World par3World, + int par4, + int par5, + int par6, + int par7, + float par8, + float par9, + float par10, + Block block, + int cost, + float r, + float g, + float b) { + if (ManaItemHandler.requestManaExactForTool(par1ItemStack, par2EntityPlayer, cost, false)) { + ForgeDirection dir = ForgeDirection.getOrientation(par7); + int entities = par3World + .getEntitiesWithinAABB( + EntityLivingBase.class, + AxisAlignedBB.getBoundingBox( + par4 + dir.offsetX, + par5 + dir.offsetY, + par6 + dir.offsetZ, + par4 + dir.offsetX + 1, + par5 + dir.offsetY + 1, + par6 + dir.offsetZ + 1)) + .size(); + + if (entities == 0) { + ItemStack stackToPlace = new ItemStack(block); + stackToPlace.tryPlaceItemIntoWorld( + par2EntityPlayer, par3World, par4, par5, par6, par7, par8, par9, par10); + + if (stackToPlace.stackSize == 0) { + ManaItemHandler.requestManaExactForTool(par1ItemStack, par2EntityPlayer, cost, true); + for (int i = 0; i < 6; i++) + Botania.proxy.sparkleFX( + par3World, + par4 + dir.offsetX + Math.random(), + par5 + dir.offsetY + Math.random(), + par6 + dir.offsetZ + Math.random(), + r, + g, + b, + 1F, + 5); + } + } + } + + return true; + } + + @Override + public boolean isFull3D() { + return true; + } + + @Override + public boolean usesMana(ItemStack stack) { + return true; + } + + @Override + public Achievement getAchievementOnCraft(ItemStack stack, EntityPlayer player, IInventory matrix) { + return ModAchievements.dirtRodCraft; + } + + @Override + public boolean provideBlock( + EntityPlayer player, ItemStack requestor, ItemStack stack, Block block, int meta, boolean doit) { + if (block == Blocks.dirt && meta == 0) + return !doit || ManaItemHandler.requestManaExactForTool(requestor, player, COST, true); + return false; + } + + @Override + public int getBlockCount(EntityPlayer player, ItemStack requestor, ItemStack stack, Block block, int meta) { + if (block == Blocks.dirt && meta == 0) return -1; + return 0; + } +} diff --git a/src/main/java/vazkii/botania/common/item/rod/ItemDiviningRod.java b/src/main/java/vazkii/botania/common/item/rod/ItemDiviningRod.java index c8bfde267b..1e2158cf0a 100644 --- a/src/main/java/vazkii/botania/common/item/rod/ItemDiviningRod.java +++ b/src/main/java/vazkii/botania/common/item/rod/ItemDiviningRod.java @@ -2,16 +2,15 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Aug 25, 2014, 2:57:16 PM (GMT)] */ package vazkii.botania.common.item.rod; import java.util.Random; - import net.minecraft.block.Block; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; @@ -32,72 +31,82 @@ public class ItemDiviningRod extends ItemMod implements IManaUsingItem, IAvatarWieldable { - private static final ResourceLocation avatarOverlay = new ResourceLocation(LibResources.MODEL_AVATAR_DIVINING); + private static final ResourceLocation avatarOverlay = new ResourceLocation(LibResources.MODEL_AVATAR_DIVINING); - static final int COST = 3000; + static final int COST = 3000; - public ItemDiviningRod() { - setMaxStackSize(1); - setUnlocalizedName(LibItemNames.DIVINING_ROD); - } + public ItemDiviningRod() { + setMaxStackSize(1); + setUnlocalizedName(LibItemNames.DIVINING_ROD); + } - @Override - public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer p) { - if(ManaItemHandler.requestManaExactForTool(stack, p, COST, true)) { - if(world.isRemote) { - int x = MathHelper.floor_double(p.posX); - int y = MathHelper.floor_double(p.posY); - int z = MathHelper.floor_double(p.posZ); - int range = IManaProficiencyArmor.Helper.hasProficiency(p) ? 20 : 15; - long seedxor = world.rand.nextLong(); - doHighlight(world, x, y, z, range, seedxor); - p.swingItem(); - } else world.playSoundAtEntity(p, "botania:divinationRod", 1F, 1F); - } + @Override + public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer p) { + if (ManaItemHandler.requestManaExactForTool(stack, p, COST, true)) { + if (world.isRemote) { + int x = MathHelper.floor_double(p.posX); + int y = MathHelper.floor_double(p.posY); + int z = MathHelper.floor_double(p.posZ); + int range = IManaProficiencyArmor.Helper.hasProficiency(p) ? 20 : 15; + long seedxor = world.rand.nextLong(); + doHighlight(world, x, y, z, range, seedxor); + p.swingItem(); + } else world.playSoundAtEntity(p, "botania:divinationRod", 1F, 1F); + } - return stack; - } + return stack; + } - public void doHighlight(World world, int x, int y, int z, int range, long seedxor) { - Botania.proxy.setWispFXDepthTest(false); - for(int i = -range; i < range + 1; i++) - for(int j = -range; j < range + 1; j++) - for(int k = -range; k < range + 1; k++) { - int xp = x + i; - int yp = y + j; - int zp = z + k; - Block block = world.getBlock(xp, yp, zp); - int meta = world.getBlockMetadata(xp, yp, zp); - ItemStack orestack = new ItemStack(block, 1, meta); - for(int id : OreDictionary.getOreIDs(orestack)) { - String s = OreDictionary.getOreName(id); - if(s.matches("^ore[A-Z].+")) { - Random rand = new Random(s.hashCode() ^ seedxor); - Botania.proxy.wispFX(world, xp + world.rand.nextFloat(), yp + world.rand.nextFloat(), zp + world.rand.nextFloat(), rand.nextFloat(), rand.nextFloat(), rand.nextFloat(), 0.25F, 0F, 8); - break; - } - } - } - Botania.proxy.setWispFXDepthTest(true); - } + public void doHighlight(World world, int x, int y, int z, int range, long seedxor) { + Botania.proxy.setWispFXDepthTest(false); + for (int i = -range; i < range + 1; i++) + for (int j = -range; j < range + 1; j++) + for (int k = -range; k < range + 1; k++) { + int xp = x + i; + int yp = y + j; + int zp = z + k; + Block block = world.getBlock(xp, yp, zp); + int meta = world.getBlockMetadata(xp, yp, zp); + ItemStack orestack = new ItemStack(block, 1, meta); + for (int id : OreDictionary.getOreIDs(orestack)) { + String s = OreDictionary.getOreName(id); + if (s.matches("^ore[A-Z].+")) { + Random rand = new Random(s.hashCode() ^ seedxor); + Botania.proxy.wispFX( + world, + xp + world.rand.nextFloat(), + yp + world.rand.nextFloat(), + zp + world.rand.nextFloat(), + rand.nextFloat(), + rand.nextFloat(), + rand.nextFloat(), + 0.25F, + 0F, + 8); + break; + } + } + } + Botania.proxy.setWispFXDepthTest(true); + } - @Override - public boolean usesMana(ItemStack stack) { - return true; - } + @Override + public boolean usesMana(ItemStack stack) { + return true; + } - @Override - public void onAvatarUpdate(IAvatarTile tile, ItemStack stack) { - TileEntity te = (TileEntity) tile; - World world = te.getWorldObj(); - if(tile.getCurrentMana() >= COST && tile.getElapsedFunctionalTicks() % 200 == 0 && tile.isEnabled()) { - doHighlight(world, te.xCoord, te.yCoord, te.zCoord, 18, te.xCoord ^ te.yCoord ^ te.zCoord); - tile.recieveMana(-COST); - } - } + @Override + public void onAvatarUpdate(IAvatarTile tile, ItemStack stack) { + TileEntity te = (TileEntity) tile; + World world = te.getWorldObj(); + if (tile.getCurrentMana() >= COST && tile.getElapsedFunctionalTicks() % 200 == 0 && tile.isEnabled()) { + doHighlight(world, te.xCoord, te.yCoord, te.zCoord, 18, te.xCoord ^ te.yCoord ^ te.zCoord); + tile.recieveMana(-COST); + } + } - @Override - public ResourceLocation getOverlayResource(IAvatarTile tile, ItemStack stack) { - return avatarOverlay; - } -} \ No newline at end of file + @Override + public ResourceLocation getOverlayResource(IAvatarTile tile, ItemStack stack) { + return avatarOverlay; + } +} diff --git a/src/main/java/vazkii/botania/common/item/rod/ItemExchangeRod.java b/src/main/java/vazkii/botania/common/item/rod/ItemExchangeRod.java index 01369ff1c8..305a79c513 100644 --- a/src/main/java/vazkii/botania/common/item/rod/ItemExchangeRod.java +++ b/src/main/java/vazkii/botania/common/item/rod/ItemExchangeRod.java @@ -2,17 +2,19 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Aug 20, 2015, 8:08:34 PM (GMT)] */ package vazkii.botania.common.item.rod; +import cpw.mods.fml.common.eventhandler.SubscribeEvent; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; import java.util.ArrayList; import java.util.List; - import net.minecraft.block.Block; import net.minecraft.client.Minecraft; import net.minecraft.entity.Entity; @@ -42,389 +44,407 @@ import vazkii.botania.common.core.helper.ItemNBTHelper; import vazkii.botania.common.item.ItemMod; import vazkii.botania.common.lib.LibItemNames; -import cpw.mods.fml.common.eventhandler.SubscribeEvent; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; public class ItemExchangeRod extends ItemMod implements IManaUsingItem, IWireframeCoordinateListProvider { - private static final int RANGE = 3; - private static final int COST = 40; - - private static final String TAG_BLOCK_NAME = "blockName"; - private static final String TAG_BLOCK_META = "blockMeta"; - private static final String TAG_TARGET_BLOCK_NAME = "targetBlockName"; - private static final String TAG_TARGET_BLOCK_META = "targetBlockMeta"; - private static final String TAG_SWAPPING = "swapping"; - private static final String TAG_SELECT_X = "selectX"; - private static final String TAG_SELECT_Y = "selectY"; - private static final String TAG_SELECT_Z = "selectZ"; - private static final String TAG_EXTRA_RANGE = "extraRange"; - - public ItemExchangeRod() { - setMaxStackSize(1); - setUnlocalizedName(LibItemNames.EXCHANGE_ROD); - MinecraftForge.EVENT_BUS.register(this); - } - - @Override - public boolean onItemUse(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, World par3World, int par4, int par5, int par6, int par7, float par8, float par9, float par10) { - Block wblock = par3World.getBlock(par4, par5, par6); - int wmeta = par3World.getBlockMetadata(par4, par5, par6); - - if(par2EntityPlayer.isSneaking()) { - TileEntity tile = par3World.getTileEntity(par4, par5, par6); - if(tile == null) { - if(BlockCamo.isValidBlock(wblock)) { - Item item = Item.getItemFromBlock(wblock); - if(!item.getHasSubtypes()) - wmeta = 0; - - boolean set = setBlock(par1ItemStack, wblock, wmeta); - par2EntityPlayer.setCurrentItemOrArmor(0, par1ItemStack); - - displayRemainderCounter(par2EntityPlayer, par1ItemStack); - return set; - } - } - } else if(canExchange(par1ItemStack) && !ItemNBTHelper.getBoolean(par1ItemStack, TAG_SWAPPING, false)) { - Block block = getBlock(par1ItemStack); - int meta = getBlockMeta(par1ItemStack); - List swap = getBlocksToSwap(par3World, par1ItemStack, block, meta, par4, par5, par6, null, 0); - if(swap.size() > 0) { - ItemNBTHelper.setBoolean(par1ItemStack, TAG_SWAPPING, true); - ItemNBTHelper.setInt(par1ItemStack, TAG_SELECT_X, par4); - ItemNBTHelper.setInt(par1ItemStack, TAG_SELECT_Y, par5); - ItemNBTHelper.setInt(par1ItemStack, TAG_SELECT_Z, par6); - setTargetBlock(par1ItemStack, wblock, wmeta); - if(par3World.isRemote) - par2EntityPlayer.swingItem(); - } - } - - return false; - } - - @SubscribeEvent - public void onLeftClick(PlayerInteractEvent event) { - if(event.action == Action.LEFT_CLICK_BLOCK) { - ItemStack stack = event.entityPlayer.getCurrentEquippedItem(); - if(stack != null && stack.getItem() == this && canExchange(stack) && ManaItemHandler.requestManaExactForTool(stack, event.entityPlayer, COST, false)) { - if(exchange(event.world, event.entityPlayer, event.x, event.y, event.z, stack, getBlock(stack), getBlockMeta(stack))) - ManaItemHandler.requestManaExactForTool(stack, event.entityPlayer, COST, true); - } - } - } - - @Override - public void onUpdate(ItemStack stack, World world, Entity entity, int something, boolean somethingelse) { - if(!canExchange(stack) || !(entity instanceof EntityPlayer)) - return; - - EntityPlayer player = (EntityPlayer) entity; - - int extraRange = ItemNBTHelper.getInt(stack, TAG_EXTRA_RANGE, 1); - int extraRangeNew = IManaProficiencyArmor.Helper.hasProficiency(player) ? 3 : 1; - if(extraRange != extraRangeNew) - ItemNBTHelper.setInt(stack, TAG_EXTRA_RANGE, extraRangeNew); - - Block block = getBlock(stack); - int meta = getBlockMeta(stack); - if(ItemNBTHelper.getBoolean(stack, TAG_SWAPPING, false)) { - if(!ManaItemHandler.requestManaExactForTool(stack, player, COST, false)) { - ItemNBTHelper.setBoolean(stack, TAG_SWAPPING, false); - return; - } - - int x = ItemNBTHelper.getInt(stack, TAG_SELECT_X, 0); - int y = ItemNBTHelper.getInt(stack, TAG_SELECT_Y, 0); - int z = ItemNBTHelper.getInt(stack, TAG_SELECT_Z, 0); - Block targetBlock = getTargetBlock(stack); - int targetMeta = getTargetBlockMeta(stack); - List swap = getBlocksToSwap(world, stack, block, meta, x, y, z, targetBlock, targetMeta); - if(swap.size() == 0) { - ItemNBTHelper.setBoolean(stack, TAG_SWAPPING, false); - return; - } - - ChunkCoordinates coords = swap.get(world.rand.nextInt(swap.size())); - boolean exchange = exchange(world, player, coords.posX, coords.posY, coords.posZ, stack, block, meta); - if(exchange) - ManaItemHandler.requestManaExactForTool(stack, player, COST, true); - else ItemNBTHelper.setBoolean(stack, TAG_SWAPPING, false); - } - } - - public List getBlocksToSwap(World world, ItemStack stack, Block blockToSwap, int metaToSwap, int xc, int yc, int zc, Block targetBlock, int targetMeta) { - // If we have no target block passed in, infer it to be - // the block which the swapping is centered on (presumably the block - // which the player is looking at) - if(targetBlock == null) { - targetBlock = world.getBlock(xc, yc, zc); - targetMeta = world.getBlockMetadata(xc, yc, zc); - } - - // Our result list - List coordsList = new ArrayList(); - - // We subtract 1 from the effective range as the center tile is included - // So, with a range of 3, we are visiting tiles at -2, -1, 0, 1, 2 - int effRange = RANGE + ItemNBTHelper.getInt(stack, TAG_EXTRA_RANGE, 1) - 1; - - // Iterate in all 3 dimensions through our possible positions. - for(int offsetX = -effRange; offsetX <= effRange; offsetX++) - for(int offsetY = -effRange; offsetY <= effRange; offsetY++) - for(int offsetZ = -effRange; offsetZ <= effRange; offsetZ++) { - int x = xc + offsetX, y = yc + offsetY, z = zc + offsetZ; - - Block currentBlock = world.getBlock(x, y, z); - int currentMeta = world.getBlockMetadata(x, y, z); - - // If this block is not our target, ignore it, as we don't need - // to consider replacing it - if(currentBlock != targetBlock || currentMeta != targetMeta) - continue; - - // If this block is already the block we're swapping to, - // we don't need to swap again - if(currentBlock == blockToSwap && currentMeta == metaToSwap) - continue; - - // Check to see if the block is visible on any side: - for(ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS) { - int adjX = x + dir.offsetX, adjY = y + dir.offsetY, adjZ = z + dir.offsetZ; - Block adjBlock = world.getBlock(adjX, adjY, adjZ); - - // If the side of the adjacent block facing this block is - // _not_ solid, then this block is considered "visible" - // and should be replaced. - - // If there is a rendering-specific way to check for this, - // that should be placed in preference to this. - if(!adjBlock.isSideSolid(world, adjX, adjY, adjZ, dir.getOpposite())) { - coordsList.add(new ChunkCoordinates(x, y, z)); - break; - } - } - } - - return coordsList; - } - - public boolean exchange(World world, EntityPlayer player, int x, int y, int z, ItemStack stack, Block blockToSet, int metaToSet) { - TileEntity tile = world.getTileEntity(x, y, z); - if(tile != null) - return false; - - ItemStack placeStack = removeFromInventory(player, stack, blockToSet, metaToSet, false); - if(placeStack != null) { - Block blockAt = world.getBlock(x, y, z); - int meta = world.getBlockMetadata(x, y, z); - if(!blockAt.isAir(world, x, y, z) && blockAt.getPlayerRelativeBlockHardness(player, world, x, y, z) > 0 && (blockAt != blockToSet || meta != metaToSet)) { - if(!world.isRemote) { - if(!player.capabilities.isCreativeMode) { - List drops = blockAt.getDrops(world, x, y, z, meta, 0); - for(ItemStack drop : drops) - world.spawnEntityInWorld(new EntityItem(world, x + 0.5, y + 0.5, z + 0.5, drop)); - removeFromInventory(player, stack, blockToSet, metaToSet, true); - } - world.playAuxSFX(2001, x, y, z, Block.getIdFromBlock(blockAt) + (meta << 12)); - world.setBlock(x, y, z, blockToSet, metaToSet, 1 | 2); - blockToSet.onBlockPlacedBy(world, x, y, z, player, placeStack); - } - displayRemainderCounter(player, stack); - return true; - } - } - - return false; - } - - public boolean canExchange(ItemStack stack) { - Block block = getBlock(stack); - return block != null && block != Blocks.air; - } - - public static ItemStack removeFromInventory(EntityPlayer player, IInventory inv, ItemStack stack, Block block, int meta, boolean doit) { - List providers = new ArrayList(); - for(int i = inv.getSizeInventory() - 1; i >= 0; i--) { - ItemStack invStack = inv.getStackInSlot(i); - if(invStack == null) - continue; - - Item item = invStack.getItem(); - if(item == Item.getItemFromBlock(block) && invStack.getItemDamage() == meta) { - ItemStack retStack = invStack.copy(); - if(doit) { - invStack.stackSize--; - if(invStack.stackSize == 0) - inv.setInventorySlotContents(i, null); - } - return retStack; - } - - if(item instanceof IBlockProvider) - providers.add(invStack); - } - - for(ItemStack provStack : providers) { - IBlockProvider prov = (IBlockProvider) provStack.getItem(); - if(prov.provideBlock(player, stack, provStack, block, meta, doit)) - return new ItemStack(block, 1, meta); - } - - return null; - } - - public static ItemStack removeFromInventory(EntityPlayer player, ItemStack stack, Block block, int meta, boolean doit) { - if(player.capabilities.isCreativeMode) - return new ItemStack(block, 1, meta); - - ItemStack outStack = removeFromInventory(player, BotaniaAPI.internalHandler.getBaublesInventory(player), stack, block, meta, doit); - if (outStack == null) - outStack = removeFromInventory(player, player.inventory, stack, block, meta, doit); - return outStack; - } - - public static int getInventoryItemCount(EntityPlayer player, ItemStack stack, Block block, int meta) { - if(player.capabilities.isCreativeMode) - return -1; - - int baubleCount = getInventoryItemCount(player, BotaniaAPI.internalHandler.getBaublesInventory(player), stack, block, meta); - if (baubleCount == -1) return -1; - - int count = getInventoryItemCount(player, player.inventory, stack, block, meta); - if (count == -1) return -1; - - return count+baubleCount; - } - - public static int getInventoryItemCount(EntityPlayer player, IInventory inv, ItemStack stack, Block block, int meta) { - if(player.capabilities.isCreativeMode) - return -1; - - int count = 0; - for(int i = 0; i < inv.getSizeInventory(); i++) { - ItemStack invStack = inv.getStackInSlot(i); - if(invStack == null) - continue; - - Item item = invStack.getItem(); - if(item == Item.getItemFromBlock(block) && invStack.getItemDamage() == meta) - count += invStack.stackSize; - - if(item instanceof IBlockProvider) { - IBlockProvider prov = (IBlockProvider) item; - int provCount = prov.getBlockCount(player, stack, invStack, block, meta); - if(provCount == -1) - return -1; - count += provCount; - } - } - - return count; - } - - public void displayRemainderCounter(EntityPlayer player, ItemStack stack) { - Block block = getBlock(stack); - int meta = getBlockMeta(stack); - int count = getInventoryItemCount(player, stack, block, meta); - if(!player.worldObj.isRemote) - ItemsRemainingRenderHandler.set(new ItemStack(block, 1, meta), count); - } - - @Override - public boolean isFull3D() { - return true; - } - - @Override - public boolean usesMana(ItemStack stack) { - return true; - } - - private boolean setBlock(ItemStack stack, Block block, int meta) { - ItemNBTHelper.setString(stack, TAG_BLOCK_NAME, Block.blockRegistry.getNameForObject(block)); - ItemNBTHelper.setInt(stack, TAG_BLOCK_META, meta); - return true; - } - - @Override - public String getItemStackDisplayName(ItemStack par1ItemStack) { - Block block = getBlock(par1ItemStack); - int meta = getBlockMeta(par1ItemStack); - return super.getItemStackDisplayName(par1ItemStack) + (block == null ? "" : " (" + EnumChatFormatting.GREEN + new ItemStack(block, 1, meta).getDisplayName() + EnumChatFormatting.RESET + ")"); - } - - public static String getBlockName(ItemStack stack) { - return ItemNBTHelper.getString(stack, TAG_BLOCK_NAME, ""); - } - - public static Block getBlock(ItemStack stack) { - Block block = Block.getBlockFromName(getBlockName(stack)); - return block; - } - - public static int getBlockMeta(ItemStack stack) { - return ItemNBTHelper.getInt(stack, TAG_BLOCK_META, 0); - } - - private boolean setTargetBlock(ItemStack stack, Block block, int meta) { - ItemNBTHelper.setString(stack, TAG_TARGET_BLOCK_NAME, Block.blockRegistry.getNameForObject(block)); - ItemNBTHelper.setInt(stack, TAG_TARGET_BLOCK_META, meta); - return true; - } - - public static String getTargetBlockName(ItemStack stack) { - return ItemNBTHelper.getString(stack, TAG_TARGET_BLOCK_NAME, ""); - } - - public static Block getTargetBlock(ItemStack stack) { - Block block = Block.getBlockFromName(getTargetBlockName(stack)); - return block; - } - - public static int getTargetBlockMeta(ItemStack stack) { - return ItemNBTHelper.getInt(stack, TAG_TARGET_BLOCK_META, 0); - } - - @Override - @SideOnly(Side.CLIENT) - public List getWireframesToDraw(EntityPlayer player, ItemStack stack) { - ItemStack holding = player.getCurrentEquippedItem(); - if(holding != stack || !canExchange(stack)) - return null; - - Block block = getBlock(stack); - int meta = getBlockMeta(stack); - - MovingObjectPosition pos = Minecraft.getMinecraft().objectMouseOver; - if(pos != null) { - int x = pos.blockX; - int y = pos.blockY; - int z = pos.blockZ; - Block targetBlock = null; - int targetMeta = 0; - if(ItemNBTHelper.getBoolean(stack, TAG_SWAPPING, false)) { - x = ItemNBTHelper.getInt(stack, TAG_SELECT_X, 0); - y = ItemNBTHelper.getInt(stack, TAG_SELECT_Y, 0); - z = ItemNBTHelper.getInt(stack, TAG_SELECT_Z, 0); - targetBlock = getTargetBlock(stack); - targetMeta = getTargetBlockMeta(stack); - } - - if(!player.worldObj.isAirBlock(x, y, z)) { - List coordsList = getBlocksToSwap(player.worldObj, stack, block, meta, x, y, z, targetBlock, targetMeta); - for(ChunkCoordinates coords : coordsList) - if(coords.posX == x && coords.posY == y && coords.posZ == z) { - coordsList.remove(coords); - break; - } - return coordsList; - } - - } - return null; - } - + private static final int RANGE = 3; + private static final int COST = 40; + + private static final String TAG_BLOCK_NAME = "blockName"; + private static final String TAG_BLOCK_META = "blockMeta"; + private static final String TAG_TARGET_BLOCK_NAME = "targetBlockName"; + private static final String TAG_TARGET_BLOCK_META = "targetBlockMeta"; + private static final String TAG_SWAPPING = "swapping"; + private static final String TAG_SELECT_X = "selectX"; + private static final String TAG_SELECT_Y = "selectY"; + private static final String TAG_SELECT_Z = "selectZ"; + private static final String TAG_EXTRA_RANGE = "extraRange"; + + public ItemExchangeRod() { + setMaxStackSize(1); + setUnlocalizedName(LibItemNames.EXCHANGE_ROD); + MinecraftForge.EVENT_BUS.register(this); + } + + @Override + public boolean onItemUse( + ItemStack par1ItemStack, + EntityPlayer par2EntityPlayer, + World par3World, + int par4, + int par5, + int par6, + int par7, + float par8, + float par9, + float par10) { + Block wblock = par3World.getBlock(par4, par5, par6); + int wmeta = par3World.getBlockMetadata(par4, par5, par6); + + if (par2EntityPlayer.isSneaking()) { + TileEntity tile = par3World.getTileEntity(par4, par5, par6); + if (tile == null) { + if (BlockCamo.isValidBlock(wblock)) { + Item item = Item.getItemFromBlock(wblock); + if (!item.getHasSubtypes()) wmeta = 0; + + boolean set = setBlock(par1ItemStack, wblock, wmeta); + par2EntityPlayer.setCurrentItemOrArmor(0, par1ItemStack); + + displayRemainderCounter(par2EntityPlayer, par1ItemStack); + return set; + } + } + } else if (canExchange(par1ItemStack) && !ItemNBTHelper.getBoolean(par1ItemStack, TAG_SWAPPING, false)) { + Block block = getBlock(par1ItemStack); + int meta = getBlockMeta(par1ItemStack); + List swap = + getBlocksToSwap(par3World, par1ItemStack, block, meta, par4, par5, par6, null, 0); + if (swap.size() > 0) { + ItemNBTHelper.setBoolean(par1ItemStack, TAG_SWAPPING, true); + ItemNBTHelper.setInt(par1ItemStack, TAG_SELECT_X, par4); + ItemNBTHelper.setInt(par1ItemStack, TAG_SELECT_Y, par5); + ItemNBTHelper.setInt(par1ItemStack, TAG_SELECT_Z, par6); + setTargetBlock(par1ItemStack, wblock, wmeta); + if (par3World.isRemote) par2EntityPlayer.swingItem(); + } + } + + return false; + } + + @SubscribeEvent + public void onLeftClick(PlayerInteractEvent event) { + if (event.action == Action.LEFT_CLICK_BLOCK) { + ItemStack stack = event.entityPlayer.getCurrentEquippedItem(); + if (stack != null + && stack.getItem() == this + && canExchange(stack) + && ManaItemHandler.requestManaExactForTool(stack, event.entityPlayer, COST, false)) { + if (exchange( + event.world, + event.entityPlayer, + event.x, + event.y, + event.z, + stack, + getBlock(stack), + getBlockMeta(stack))) + ManaItemHandler.requestManaExactForTool(stack, event.entityPlayer, COST, true); + } + } + } + + @Override + public void onUpdate(ItemStack stack, World world, Entity entity, int something, boolean somethingelse) { + if (!canExchange(stack) || !(entity instanceof EntityPlayer)) return; + + EntityPlayer player = (EntityPlayer) entity; + + int extraRange = ItemNBTHelper.getInt(stack, TAG_EXTRA_RANGE, 1); + int extraRangeNew = IManaProficiencyArmor.Helper.hasProficiency(player) ? 3 : 1; + if (extraRange != extraRangeNew) ItemNBTHelper.setInt(stack, TAG_EXTRA_RANGE, extraRangeNew); + + Block block = getBlock(stack); + int meta = getBlockMeta(stack); + if (ItemNBTHelper.getBoolean(stack, TAG_SWAPPING, false)) { + if (!ManaItemHandler.requestManaExactForTool(stack, player, COST, false)) { + ItemNBTHelper.setBoolean(stack, TAG_SWAPPING, false); + return; + } + + int x = ItemNBTHelper.getInt(stack, TAG_SELECT_X, 0); + int y = ItemNBTHelper.getInt(stack, TAG_SELECT_Y, 0); + int z = ItemNBTHelper.getInt(stack, TAG_SELECT_Z, 0); + Block targetBlock = getTargetBlock(stack); + int targetMeta = getTargetBlockMeta(stack); + List swap = getBlocksToSwap(world, stack, block, meta, x, y, z, targetBlock, targetMeta); + if (swap.size() == 0) { + ItemNBTHelper.setBoolean(stack, TAG_SWAPPING, false); + return; + } + + ChunkCoordinates coords = swap.get(world.rand.nextInt(swap.size())); + boolean exchange = exchange(world, player, coords.posX, coords.posY, coords.posZ, stack, block, meta); + if (exchange) ManaItemHandler.requestManaExactForTool(stack, player, COST, true); + else ItemNBTHelper.setBoolean(stack, TAG_SWAPPING, false); + } + } + + public List getBlocksToSwap( + World world, + ItemStack stack, + Block blockToSwap, + int metaToSwap, + int xc, + int yc, + int zc, + Block targetBlock, + int targetMeta) { + // If we have no target block passed in, infer it to be + // the block which the swapping is centered on (presumably the block + // which the player is looking at) + if (targetBlock == null) { + targetBlock = world.getBlock(xc, yc, zc); + targetMeta = world.getBlockMetadata(xc, yc, zc); + } + + // Our result list + List coordsList = new ArrayList(); + + // We subtract 1 from the effective range as the center tile is included + // So, with a range of 3, we are visiting tiles at -2, -1, 0, 1, 2 + int effRange = RANGE + ItemNBTHelper.getInt(stack, TAG_EXTRA_RANGE, 1) - 1; + + // Iterate in all 3 dimensions through our possible positions. + for (int offsetX = -effRange; offsetX <= effRange; offsetX++) + for (int offsetY = -effRange; offsetY <= effRange; offsetY++) + for (int offsetZ = -effRange; offsetZ <= effRange; offsetZ++) { + int x = xc + offsetX, y = yc + offsetY, z = zc + offsetZ; + + Block currentBlock = world.getBlock(x, y, z); + int currentMeta = world.getBlockMetadata(x, y, z); + + // If this block is not our target, ignore it, as we don't need + // to consider replacing it + if (currentBlock != targetBlock || currentMeta != targetMeta) continue; + + // If this block is already the block we're swapping to, + // we don't need to swap again + if (currentBlock == blockToSwap && currentMeta == metaToSwap) continue; + + // Check to see if the block is visible on any side: + for (ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS) { + int adjX = x + dir.offsetX, adjY = y + dir.offsetY, adjZ = z + dir.offsetZ; + Block adjBlock = world.getBlock(adjX, adjY, adjZ); + + // If the side of the adjacent block facing this block is + // _not_ solid, then this block is considered "visible" + // and should be replaced. + + // If there is a rendering-specific way to check for this, + // that should be placed in preference to this. + if (!adjBlock.isSideSolid(world, adjX, adjY, adjZ, dir.getOpposite())) { + coordsList.add(new ChunkCoordinates(x, y, z)); + break; + } + } + } + + return coordsList; + } + + public boolean exchange( + World world, EntityPlayer player, int x, int y, int z, ItemStack stack, Block blockToSet, int metaToSet) { + TileEntity tile = world.getTileEntity(x, y, z); + if (tile != null) return false; + + ItemStack placeStack = removeFromInventory(player, stack, blockToSet, metaToSet, false); + if (placeStack != null) { + Block blockAt = world.getBlock(x, y, z); + int meta = world.getBlockMetadata(x, y, z); + if (!blockAt.isAir(world, x, y, z) + && blockAt.getPlayerRelativeBlockHardness(player, world, x, y, z) > 0 + && (blockAt != blockToSet || meta != metaToSet)) { + if (!world.isRemote) { + if (!player.capabilities.isCreativeMode) { + List drops = blockAt.getDrops(world, x, y, z, meta, 0); + for (ItemStack drop : drops) + world.spawnEntityInWorld(new EntityItem(world, x + 0.5, y + 0.5, z + 0.5, drop)); + removeFromInventory(player, stack, blockToSet, metaToSet, true); + } + world.playAuxSFX(2001, x, y, z, Block.getIdFromBlock(blockAt) + (meta << 12)); + world.setBlock(x, y, z, blockToSet, metaToSet, 1 | 2); + blockToSet.onBlockPlacedBy(world, x, y, z, player, placeStack); + } + displayRemainderCounter(player, stack); + return true; + } + } + + return false; + } + + public boolean canExchange(ItemStack stack) { + Block block = getBlock(stack); + return block != null && block != Blocks.air; + } + + public static ItemStack removeFromInventory( + EntityPlayer player, IInventory inv, ItemStack stack, Block block, int meta, boolean doit) { + List providers = new ArrayList(); + for (int i = inv.getSizeInventory() - 1; i >= 0; i--) { + ItemStack invStack = inv.getStackInSlot(i); + if (invStack == null) continue; + + Item item = invStack.getItem(); + if (item == Item.getItemFromBlock(block) && invStack.getItemDamage() == meta) { + ItemStack retStack = invStack.copy(); + if (doit) { + invStack.stackSize--; + if (invStack.stackSize == 0) inv.setInventorySlotContents(i, null); + } + return retStack; + } + + if (item instanceof IBlockProvider) providers.add(invStack); + } + + for (ItemStack provStack : providers) { + IBlockProvider prov = (IBlockProvider) provStack.getItem(); + if (prov.provideBlock(player, stack, provStack, block, meta, doit)) return new ItemStack(block, 1, meta); + } + + return null; + } + + public static ItemStack removeFromInventory( + EntityPlayer player, ItemStack stack, Block block, int meta, boolean doit) { + if (player.capabilities.isCreativeMode) return new ItemStack(block, 1, meta); + + ItemStack outStack = removeFromInventory( + player, BotaniaAPI.internalHandler.getBaublesInventory(player), stack, block, meta, doit); + if (outStack == null) outStack = removeFromInventory(player, player.inventory, stack, block, meta, doit); + return outStack; + } + + public static int getInventoryItemCount(EntityPlayer player, ItemStack stack, Block block, int meta) { + if (player.capabilities.isCreativeMode) return -1; + + int baubleCount = getInventoryItemCount( + player, BotaniaAPI.internalHandler.getBaublesInventory(player), stack, block, meta); + if (baubleCount == -1) return -1; + + int count = getInventoryItemCount(player, player.inventory, stack, block, meta); + if (count == -1) return -1; + + return count + baubleCount; + } + + public static int getInventoryItemCount( + EntityPlayer player, IInventory inv, ItemStack stack, Block block, int meta) { + if (player.capabilities.isCreativeMode) return -1; + + int count = 0; + for (int i = 0; i < inv.getSizeInventory(); i++) { + ItemStack invStack = inv.getStackInSlot(i); + if (invStack == null) continue; + + Item item = invStack.getItem(); + if (item == Item.getItemFromBlock(block) && invStack.getItemDamage() == meta) count += invStack.stackSize; + + if (item instanceof IBlockProvider) { + IBlockProvider prov = (IBlockProvider) item; + int provCount = prov.getBlockCount(player, stack, invStack, block, meta); + if (provCount == -1) return -1; + count += provCount; + } + } + + return count; + } + + public void displayRemainderCounter(EntityPlayer player, ItemStack stack) { + Block block = getBlock(stack); + int meta = getBlockMeta(stack); + int count = getInventoryItemCount(player, stack, block, meta); + if (!player.worldObj.isRemote) ItemsRemainingRenderHandler.set(new ItemStack(block, 1, meta), count); + } + + @Override + public boolean isFull3D() { + return true; + } + + @Override + public boolean usesMana(ItemStack stack) { + return true; + } + + private boolean setBlock(ItemStack stack, Block block, int meta) { + ItemNBTHelper.setString(stack, TAG_BLOCK_NAME, Block.blockRegistry.getNameForObject(block)); + ItemNBTHelper.setInt(stack, TAG_BLOCK_META, meta); + return true; + } + + @Override + public String getItemStackDisplayName(ItemStack par1ItemStack) { + Block block = getBlock(par1ItemStack); + int meta = getBlockMeta(par1ItemStack); + return super.getItemStackDisplayName(par1ItemStack) + + (block == null + ? "" + : " (" + EnumChatFormatting.GREEN + new ItemStack(block, 1, meta).getDisplayName() + + EnumChatFormatting.RESET + ")"); + } + + public static String getBlockName(ItemStack stack) { + return ItemNBTHelper.getString(stack, TAG_BLOCK_NAME, ""); + } + + public static Block getBlock(ItemStack stack) { + Block block = Block.getBlockFromName(getBlockName(stack)); + return block; + } + + public static int getBlockMeta(ItemStack stack) { + return ItemNBTHelper.getInt(stack, TAG_BLOCK_META, 0); + } + + private boolean setTargetBlock(ItemStack stack, Block block, int meta) { + ItemNBTHelper.setString(stack, TAG_TARGET_BLOCK_NAME, Block.blockRegistry.getNameForObject(block)); + ItemNBTHelper.setInt(stack, TAG_TARGET_BLOCK_META, meta); + return true; + } + + public static String getTargetBlockName(ItemStack stack) { + return ItemNBTHelper.getString(stack, TAG_TARGET_BLOCK_NAME, ""); + } + + public static Block getTargetBlock(ItemStack stack) { + Block block = Block.getBlockFromName(getTargetBlockName(stack)); + return block; + } + + public static int getTargetBlockMeta(ItemStack stack) { + return ItemNBTHelper.getInt(stack, TAG_TARGET_BLOCK_META, 0); + } + + @Override + @SideOnly(Side.CLIENT) + public List getWireframesToDraw(EntityPlayer player, ItemStack stack) { + ItemStack holding = player.getCurrentEquippedItem(); + if (holding != stack || !canExchange(stack)) return null; + + Block block = getBlock(stack); + int meta = getBlockMeta(stack); + + MovingObjectPosition pos = Minecraft.getMinecraft().objectMouseOver; + if (pos != null) { + int x = pos.blockX; + int y = pos.blockY; + int z = pos.blockZ; + Block targetBlock = null; + int targetMeta = 0; + if (ItemNBTHelper.getBoolean(stack, TAG_SWAPPING, false)) { + x = ItemNBTHelper.getInt(stack, TAG_SELECT_X, 0); + y = ItemNBTHelper.getInt(stack, TAG_SELECT_Y, 0); + z = ItemNBTHelper.getInt(stack, TAG_SELECT_Z, 0); + targetBlock = getTargetBlock(stack); + targetMeta = getTargetBlockMeta(stack); + } + + if (!player.worldObj.isAirBlock(x, y, z)) { + List coordsList = + getBlocksToSwap(player.worldObj, stack, block, meta, x, y, z, targetBlock, targetMeta); + for (ChunkCoordinates coords : coordsList) + if (coords.posX == x && coords.posY == y && coords.posZ == z) { + coordsList.remove(coords); + break; + } + return coordsList; + } + } + return null; + } } diff --git a/src/main/java/vazkii/botania/common/item/rod/ItemFireRod.java b/src/main/java/vazkii/botania/common/item/rod/ItemFireRod.java index 32f3b0ffd6..516fb99534 100644 --- a/src/main/java/vazkii/botania/common/item/rod/ItemFireRod.java +++ b/src/main/java/vazkii/botania/common/item/rod/ItemFireRod.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jun 26, 2014, 12:08:06 AM (GMT)] */ package vazkii.botania.common.item.rod; @@ -28,64 +28,79 @@ public class ItemFireRod extends ItemMod implements IManaUsingItem, IAvatarWieldable { - private static final ResourceLocation avatarOverlay = new ResourceLocation(LibResources.MODEL_AVATAR_FIRE); + private static final ResourceLocation avatarOverlay = new ResourceLocation(LibResources.MODEL_AVATAR_FIRE); - private static final int COST = 900; - private static final int COOLDOWN = 1200; + private static final int COST = 900; + private static final int COOLDOWN = 1200; - public ItemFireRod() { - setUnlocalizedName(LibItemNames.FIRE_ROD); - setMaxStackSize(1); - setMaxDamage(COOLDOWN); - } + public ItemFireRod() { + setUnlocalizedName(LibItemNames.FIRE_ROD); + setMaxStackSize(1); + setMaxDamage(COOLDOWN); + } - @Override - public boolean onItemUse(ItemStack par1ItemStack, EntityPlayer player, World par3World, int x, int y, int z, int par7, float par8, float par9, float par10) { - if(!par3World.isRemote && par1ItemStack.getItemDamage() == 0 && ManaItemHandler.requestManaExactForTool(par1ItemStack, player, COST, false)) { - EntityFlameRing entity = new EntityFlameRing(player.worldObj); - entity.setPosition(x + 0.5, y + 1, z + 0.5); - player.worldObj.spawnEntityInWorld(entity); + @Override + public boolean onItemUse( + ItemStack par1ItemStack, + EntityPlayer player, + World par3World, + int x, + int y, + int z, + int par7, + float par8, + float par9, + float par10) { + if (!par3World.isRemote + && par1ItemStack.getItemDamage() == 0 + && ManaItemHandler.requestManaExactForTool(par1ItemStack, player, COST, false)) { + EntityFlameRing entity = new EntityFlameRing(player.worldObj); + entity.setPosition(x + 0.5, y + 1, z + 0.5); + player.worldObj.spawnEntityInWorld(entity); - par1ItemStack.setItemDamage(COOLDOWN); - ManaItemHandler.requestManaExactForTool(par1ItemStack, player, COST, true); - par3World.playSoundAtEntity(player, "mob.blaze.breathe", 1F, 1F); - } + par1ItemStack.setItemDamage(COOLDOWN); + ManaItemHandler.requestManaExactForTool(par1ItemStack, player, COST, true); + par3World.playSoundAtEntity(player, "mob.blaze.breathe", 1F, 1F); + } - return true; - } + return true; + } - @Override - public void onUpdate(ItemStack par1ItemStack, World par2World, Entity par3Entity, int par4, boolean par5) { - if(par1ItemStack.isItemDamaged() && par3Entity instanceof EntityPlayer) - par1ItemStack.setItemDamage(par1ItemStack.getItemDamage() - (IManaProficiencyArmor.Helper.hasProficiency((EntityPlayer) par3Entity) ? 2 : 1)); - } + @Override + public void onUpdate(ItemStack par1ItemStack, World par2World, Entity par3Entity, int par4, boolean par5) { + if (par1ItemStack.isItemDamaged() && par3Entity instanceof EntityPlayer) + par1ItemStack.setItemDamage(par1ItemStack.getItemDamage() + - (IManaProficiencyArmor.Helper.hasProficiency((EntityPlayer) par3Entity) ? 2 : 1)); + } - @Override - public boolean isFull3D() { - return true; - } + @Override + public boolean isFull3D() { + return true; + } - @Override - public boolean usesMana(ItemStack stack) { - return true; - } + @Override + public boolean usesMana(ItemStack stack) { + return true; + } - @Override - public void onAvatarUpdate(IAvatarTile tile, ItemStack stack) { - TileEntity te = (TileEntity) tile; - World world = te.getWorldObj(); + @Override + public void onAvatarUpdate(IAvatarTile tile, ItemStack stack) { + TileEntity te = (TileEntity) tile; + World world = te.getWorldObj(); - if(!world.isRemote && tile.getCurrentMana() >= COST && tile.getElapsedFunctionalTicks() % 300 == 0 && tile.isEnabled()) { - EntityFlameRing entity = new EntityFlameRing(world); - entity.setPosition(te.xCoord + 0.5, te.yCoord, te.zCoord + 0.5); - world.spawnEntityInWorld(entity); - tile.recieveMana(-COST); - } - } - - @Override - public ResourceLocation getOverlayResource(IAvatarTile tile, ItemStack stack) { - return avatarOverlay; - } + if (!world.isRemote + && tile.getCurrentMana() >= COST + && tile.getElapsedFunctionalTicks() % 300 == 0 + && tile.isEnabled()) { + EntityFlameRing entity = new EntityFlameRing(world); + entity.setPosition(te.xCoord + 0.5, te.yCoord, te.zCoord + 0.5); + world.spawnEntityInWorld(entity); + tile.recieveMana(-COST); + } + } + @Override + public ResourceLocation getOverlayResource(IAvatarTile tile, ItemStack stack) { + return avatarOverlay; + } } diff --git a/src/main/java/vazkii/botania/common/item/rod/ItemGravityRod.java b/src/main/java/vazkii/botania/common/item/rod/ItemGravityRod.java index 08e2b8f136..7f11338f89 100644 --- a/src/main/java/vazkii/botania/common/item/rod/ItemGravityRod.java +++ b/src/main/java/vazkii/botania/common/item/rod/ItemGravityRod.java @@ -2,17 +2,16 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Aug 25, 2014, 2:57:16 PM (GMT)] */ package vazkii.botania.common.item.rod; import java.util.ArrayList; import java.util.List; - import net.minecraft.entity.Entity; import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.item.EntityItem; @@ -36,205 +35,230 @@ public class ItemGravityRod extends ItemMod implements IManaUsingItem { - private static final float RANGE = 3F; - private static final int COST = 2; - - private static final String TAG_TICKS_TILL_EXPIRE = "ticksTillExpire"; - private static final String TAG_TICKS_COOLDOWN = "ticksCooldown"; - private static final String TAG_TARGET = "target"; - private static final String TAG_DIST = "dist"; - - public ItemGravityRod() { - setMaxStackSize(1); - setUnlocalizedName(LibItemNames.GRAVITY_ROD); - } - - @Override - public void onUpdate(ItemStack stack, World world, Entity par3Entity, int p_77663_4_, boolean p_77663_5_) { - if(!(par3Entity instanceof EntityPlayer)) - return; - - int ticksTillExpire = ItemNBTHelper.getInt(stack, TAG_TICKS_TILL_EXPIRE, 0); - int ticksCooldown = ItemNBTHelper.getInt(stack, TAG_TICKS_COOLDOWN, 0); - - if(ticksTillExpire == 0) { - ItemNBTHelper.setInt(stack, TAG_TARGET, -1); - ItemNBTHelper.setDouble(stack, TAG_DIST, -1); - } - - if(ticksCooldown > 0) - ticksCooldown--; - - ticksTillExpire--; - ItemNBTHelper.setInt(stack, TAG_TICKS_TILL_EXPIRE, ticksTillExpire); - ItemNBTHelper.setInt(stack, TAG_TICKS_COOLDOWN, ticksCooldown); - - EntityPlayer player = (EntityPlayer) par3Entity; - PotionEffect haste = player.getActivePotionEffect(Potion.digSpeed); - float check = haste == null ? 0.16666667F : haste.getAmplifier() == 1 ? 0.5F : 0.4F; - if(player.getCurrentEquippedItem() == stack && player.swingProgress == check && !world.isRemote) - leftClick(player); - } - - @Override - public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer player) { - int targetID = ItemNBTHelper.getInt(stack, TAG_TARGET, -1); - int ticksCooldown = ItemNBTHelper.getInt(stack, TAG_TICKS_COOLDOWN, 0); - double length = ItemNBTHelper.getDouble(stack, TAG_DIST, -1); - - if(ticksCooldown == 0) { - Entity item = null; - if(targetID != -1 && player.worldObj.getEntityByID(targetID) != null) { - Entity taritem = player.worldObj.getEntityByID(targetID); - - boolean found = false; - Vector3 target = Vector3.fromEntityCenter(player); - List entities = new ArrayList(); - int distance = 1; - while(entities.size() == 0 && distance < 25) { - target.add(new Vector3(player.getLookVec()).multiply(distance)); - - target.y += 0.5; - entities = player.worldObj.getEntitiesWithinAABBExcludingEntity(player, AxisAlignedBB.getBoundingBox(target.x - RANGE, target.y - RANGE, target.z - RANGE, target.x + RANGE, target.y + RANGE, target.z + RANGE)); - distance++; - if(entities.contains(taritem)) - found = true; - } - - if(found) - item = player.worldObj.getEntityByID(targetID); - } - - if(item == null) { - Vector3 target = Vector3.fromEntityCenter(player); - List entities = new ArrayList(); - int distance = 1; - while(entities.size() == 0 && distance < 25) { - target.add(new Vector3(player.getLookVec()).multiply(distance)); - - target.y += 0.5; - entities = player.worldObj.getEntitiesWithinAABBExcludingEntity(player, AxisAlignedBB.getBoundingBox(target.x - RANGE, target.y - RANGE, target.z - RANGE, target.x + RANGE, target.y + RANGE, target.z + RANGE)); - distance++; - } - - if(entities.size() > 0) { - item = entities.get(0); - length = 5.5D; - if(item instanceof EntityItem) - length = 2.0D; - } - } - - if(item != null) { - if(BotaniaAPI.isEntityBlacklistedFromGravityRod(item.getClass())) - return stack; - - if(ManaItemHandler.requestManaExactForTool(stack, player, COST, true)) { - if(item instanceof EntityItem) - ((EntityItem)item).delayBeforeCanPickup = 5; - - if(item instanceof EntityLivingBase) { - EntityLivingBase targetEntity = (EntityLivingBase)item; - targetEntity.fallDistance = 0.0F; - if(targetEntity.getActivePotionEffect(Potion.moveSlowdown) == null) - targetEntity.addPotionEffect(new PotionEffect(Potion.moveSlowdown.id, 2, 3, true)); - } - - Vector3 target3 = Vector3.fromEntityCenter(player); - target3.add(new Vector3(player.getLookVec()).multiply(length)); - target3.y += 0.5; - if(item instanceof EntityItem) - target3.y += 0.25; - - for(int i = 0; i < 4; i++) { - float r = 0.5F + (float) Math.random() * 0.5F; - float b = 0.5F + (float) Math.random() * 0.5F; - float s = 0.2F + (float) Math.random() * 0.1F; - float m = 0.1F; - float xm = ((float) Math.random() - 0.5F) * m; - float ym = ((float) Math.random() - 0.5F) * m; - float zm = ((float) Math.random() - 0.5F) * m; - Botania.proxy.wispFX(world, item.posX + item.width / 2, item.posY + item.height / 2, item.posZ + item.width / 2, r, 0F, b, s, xm, ym, zm); - } - - setEntityMotionFromVector(item, target3, 0.3333333F); - - ItemNBTHelper.setInt(stack, TAG_TARGET, item.getEntityId()); - ItemNBTHelper.setDouble(stack, TAG_DIST, length); - } - } - - if(item != null) - ItemNBTHelper.setInt(stack, TAG_TICKS_TILL_EXPIRE, 5); - } - return stack; - } - - public static void setEntityMotionFromVector(Entity entity, Vector3 originalPosVector, float modifier) { - Vector3 entityVector = Vector3.fromEntityCenter(entity); - Vector3 finalVector = originalPosVector.copy().subtract(entityVector); - - if(finalVector.mag() > 1) - finalVector.normalize(); - - entity.motionX = finalVector.x * modifier; - entity.motionY = finalVector.y * modifier; - entity.motionZ = finalVector.z * modifier; - } - - @Override - public boolean usesMana(ItemStack stack) { - return true; - } - - public static void leftClick(EntityPlayer player) { - ItemStack stack = player.getHeldItem(); - if(stack != null && stack.getItem() == ModItems.gravityRod) { - int targetID = ItemNBTHelper.getInt(stack, TAG_TARGET, -1); - ItemNBTHelper.getDouble(stack, TAG_DIST, -1); - Entity item = null; - - if(targetID != -1 && player.worldObj.getEntityByID(targetID) != null) { - Entity taritem = player.worldObj.getEntityByID(targetID); - - boolean found = false; - Vector3 target = Vector3.fromEntityCenter(player); - List entities = new ArrayList(); - int distance = 1; - while(entities.size() == 0 && distance < 25) { - target.add(new Vector3(player.getLookVec()).multiply(distance)); - - target.y += 0.5; - entities = player.worldObj.getEntitiesWithinAABBExcludingEntity(player, AxisAlignedBB.getBoundingBox(target.x - RANGE, target.y - RANGE, target.z - RANGE, target.x + RANGE, target.y + RANGE, target.z + RANGE)); - distance++; - if(entities.contains(taritem)) - found = true; - } - - if(found) { - item = player.worldObj.getEntityByID(targetID); - ItemNBTHelper.setInt(stack, TAG_TARGET, -1); - ItemNBTHelper.setDouble(stack, TAG_DIST, -1); - Vector3 moveVector = new Vector3(player.getLookVec().normalize()); - if(item instanceof EntityItem) { - ((EntityItem)item).delayBeforeCanPickup = 20; - float mot = IManaProficiencyArmor.Helper.hasProficiency(player) ? 2.25F : 1.5F; - item.motionX = moveVector.x * mot; - item.motionY = moveVector.y; - item.motionZ = moveVector.z * mot; - if(!player.worldObj.isRemote) { - EntityThrownItem thrown = new EntityThrownItem(item.worldObj, item.posX, item.posY, item.posZ, (EntityItem) item); - item.worldObj.spawnEntityInWorld(thrown); - } - item.setDead(); - } else { - item.motionX = moveVector.x * 3.0F; - item.motionY = moveVector.y * 1.5F; - item.motionZ = moveVector.z * 3.0F; - } - ItemNBTHelper.setInt(stack, TAG_TICKS_COOLDOWN, 10); - } - } - } - } -} \ No newline at end of file + private static final float RANGE = 3F; + private static final int COST = 2; + + private static final String TAG_TICKS_TILL_EXPIRE = "ticksTillExpire"; + private static final String TAG_TICKS_COOLDOWN = "ticksCooldown"; + private static final String TAG_TARGET = "target"; + private static final String TAG_DIST = "dist"; + + public ItemGravityRod() { + setMaxStackSize(1); + setUnlocalizedName(LibItemNames.GRAVITY_ROD); + } + + @Override + public void onUpdate(ItemStack stack, World world, Entity par3Entity, int p_77663_4_, boolean p_77663_5_) { + if (!(par3Entity instanceof EntityPlayer)) return; + + int ticksTillExpire = ItemNBTHelper.getInt(stack, TAG_TICKS_TILL_EXPIRE, 0); + int ticksCooldown = ItemNBTHelper.getInt(stack, TAG_TICKS_COOLDOWN, 0); + + if (ticksTillExpire == 0) { + ItemNBTHelper.setInt(stack, TAG_TARGET, -1); + ItemNBTHelper.setDouble(stack, TAG_DIST, -1); + } + + if (ticksCooldown > 0) ticksCooldown--; + + ticksTillExpire--; + ItemNBTHelper.setInt(stack, TAG_TICKS_TILL_EXPIRE, ticksTillExpire); + ItemNBTHelper.setInt(stack, TAG_TICKS_COOLDOWN, ticksCooldown); + + EntityPlayer player = (EntityPlayer) par3Entity; + PotionEffect haste = player.getActivePotionEffect(Potion.digSpeed); + float check = haste == null ? 0.16666667F : haste.getAmplifier() == 1 ? 0.5F : 0.4F; + if (player.getCurrentEquippedItem() == stack && player.swingProgress == check && !world.isRemote) + leftClick(player); + } + + @Override + public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer player) { + int targetID = ItemNBTHelper.getInt(stack, TAG_TARGET, -1); + int ticksCooldown = ItemNBTHelper.getInt(stack, TAG_TICKS_COOLDOWN, 0); + double length = ItemNBTHelper.getDouble(stack, TAG_DIST, -1); + + if (ticksCooldown == 0) { + Entity item = null; + if (targetID != -1 && player.worldObj.getEntityByID(targetID) != null) { + Entity taritem = player.worldObj.getEntityByID(targetID); + + boolean found = false; + Vector3 target = Vector3.fromEntityCenter(player); + List entities = new ArrayList(); + int distance = 1; + while (entities.size() == 0 && distance < 25) { + target.add(new Vector3(player.getLookVec()).multiply(distance)); + + target.y += 0.5; + entities = player.worldObj.getEntitiesWithinAABBExcludingEntity( + player, + AxisAlignedBB.getBoundingBox( + target.x - RANGE, + target.y - RANGE, + target.z - RANGE, + target.x + RANGE, + target.y + RANGE, + target.z + RANGE)); + distance++; + if (entities.contains(taritem)) found = true; + } + + if (found) item = player.worldObj.getEntityByID(targetID); + } + + if (item == null) { + Vector3 target = Vector3.fromEntityCenter(player); + List entities = new ArrayList(); + int distance = 1; + while (entities.size() == 0 && distance < 25) { + target.add(new Vector3(player.getLookVec()).multiply(distance)); + + target.y += 0.5; + entities = player.worldObj.getEntitiesWithinAABBExcludingEntity( + player, + AxisAlignedBB.getBoundingBox( + target.x - RANGE, + target.y - RANGE, + target.z - RANGE, + target.x + RANGE, + target.y + RANGE, + target.z + RANGE)); + distance++; + } + + if (entities.size() > 0) { + item = entities.get(0); + length = 5.5D; + if (item instanceof EntityItem) length = 2.0D; + } + } + + if (item != null) { + if (BotaniaAPI.isEntityBlacklistedFromGravityRod(item.getClass())) return stack; + + if (ManaItemHandler.requestManaExactForTool(stack, player, COST, true)) { + if (item instanceof EntityItem) ((EntityItem) item).delayBeforeCanPickup = 5; + + if (item instanceof EntityLivingBase) { + EntityLivingBase targetEntity = (EntityLivingBase) item; + targetEntity.fallDistance = 0.0F; + if (targetEntity.getActivePotionEffect(Potion.moveSlowdown) == null) + targetEntity.addPotionEffect(new PotionEffect(Potion.moveSlowdown.id, 2, 3, true)); + } + + Vector3 target3 = Vector3.fromEntityCenter(player); + target3.add(new Vector3(player.getLookVec()).multiply(length)); + target3.y += 0.5; + if (item instanceof EntityItem) target3.y += 0.25; + + for (int i = 0; i < 4; i++) { + float r = 0.5F + (float) Math.random() * 0.5F; + float b = 0.5F + (float) Math.random() * 0.5F; + float s = 0.2F + (float) Math.random() * 0.1F; + float m = 0.1F; + float xm = ((float) Math.random() - 0.5F) * m; + float ym = ((float) Math.random() - 0.5F) * m; + float zm = ((float) Math.random() - 0.5F) * m; + Botania.proxy.wispFX( + world, + item.posX + item.width / 2, + item.posY + item.height / 2, + item.posZ + item.width / 2, + r, + 0F, + b, + s, + xm, + ym, + zm); + } + + setEntityMotionFromVector(item, target3, 0.3333333F); + + ItemNBTHelper.setInt(stack, TAG_TARGET, item.getEntityId()); + ItemNBTHelper.setDouble(stack, TAG_DIST, length); + } + } + + if (item != null) ItemNBTHelper.setInt(stack, TAG_TICKS_TILL_EXPIRE, 5); + } + return stack; + } + + public static void setEntityMotionFromVector(Entity entity, Vector3 originalPosVector, float modifier) { + Vector3 entityVector = Vector3.fromEntityCenter(entity); + Vector3 finalVector = originalPosVector.copy().subtract(entityVector); + + if (finalVector.mag() > 1) finalVector.normalize(); + + entity.motionX = finalVector.x * modifier; + entity.motionY = finalVector.y * modifier; + entity.motionZ = finalVector.z * modifier; + } + + @Override + public boolean usesMana(ItemStack stack) { + return true; + } + + public static void leftClick(EntityPlayer player) { + ItemStack stack = player.getHeldItem(); + if (stack != null && stack.getItem() == ModItems.gravityRod) { + int targetID = ItemNBTHelper.getInt(stack, TAG_TARGET, -1); + ItemNBTHelper.getDouble(stack, TAG_DIST, -1); + Entity item = null; + + if (targetID != -1 && player.worldObj.getEntityByID(targetID) != null) { + Entity taritem = player.worldObj.getEntityByID(targetID); + + boolean found = false; + Vector3 target = Vector3.fromEntityCenter(player); + List entities = new ArrayList(); + int distance = 1; + while (entities.size() == 0 && distance < 25) { + target.add(new Vector3(player.getLookVec()).multiply(distance)); + + target.y += 0.5; + entities = player.worldObj.getEntitiesWithinAABBExcludingEntity( + player, + AxisAlignedBB.getBoundingBox( + target.x - RANGE, + target.y - RANGE, + target.z - RANGE, + target.x + RANGE, + target.y + RANGE, + target.z + RANGE)); + distance++; + if (entities.contains(taritem)) found = true; + } + + if (found) { + item = player.worldObj.getEntityByID(targetID); + ItemNBTHelper.setInt(stack, TAG_TARGET, -1); + ItemNBTHelper.setDouble(stack, TAG_DIST, -1); + Vector3 moveVector = new Vector3(player.getLookVec().normalize()); + if (item instanceof EntityItem) { + ((EntityItem) item).delayBeforeCanPickup = 20; + float mot = IManaProficiencyArmor.Helper.hasProficiency(player) ? 2.25F : 1.5F; + item.motionX = moveVector.x * mot; + item.motionY = moveVector.y; + item.motionZ = moveVector.z * mot; + if (!player.worldObj.isRemote) { + EntityThrownItem thrown = new EntityThrownItem( + item.worldObj, item.posX, item.posY, item.posZ, (EntityItem) item); + item.worldObj.spawnEntityInWorld(thrown); + } + item.setDead(); + } else { + item.motionX = moveVector.x * 3.0F; + item.motionY = moveVector.y * 1.5F; + item.motionZ = moveVector.z * 3.0F; + } + ItemNBTHelper.setInt(stack, TAG_TICKS_COOLDOWN, 10); + } + } + } + } +} diff --git a/src/main/java/vazkii/botania/common/item/rod/ItemMissileRod.java b/src/main/java/vazkii/botania/common/item/rod/ItemMissileRod.java index fd694ffdae..f156951792 100644 --- a/src/main/java/vazkii/botania/common/item/rod/ItemMissileRod.java +++ b/src/main/java/vazkii/botania/common/item/rod/ItemMissileRod.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Nov 24, 2014, 5:58:16 PM (GMT)] */ package vazkii.botania.common.item.rod; @@ -30,85 +30,96 @@ public class ItemMissileRod extends ItemMod implements IManaUsingItem, IAvatarWieldable { - private static final ResourceLocation avatarOverlay = new ResourceLocation(LibResources.MODEL_AVATAR_MISSILE); - - private static final int COST_PER = 120; - private static final int COST_AVATAR = 40; - - public ItemMissileRod() { - super(); - setMaxStackSize(1); - setUnlocalizedName(LibItemNames.MISSILE_ROD); - } - - @Override - public EnumAction getItemUseAction(ItemStack par1ItemStack) { - return EnumAction.bow; - } - - @Override - public int getMaxItemUseDuration(ItemStack par1ItemStack) { - return 72000; - } - - @Override - public void onUsingTick(ItemStack stack, EntityPlayer player, int count) { - if(count != getMaxItemUseDuration(stack) && count % (IManaProficiencyArmor.Helper.hasProficiency(player) ? 1 : 2) == 0 && !player.worldObj.isRemote && ManaItemHandler.requestManaExactForTool(stack, player, COST_PER, false)) { - if(spawnMissile(player.worldObj, player, player.posX + (Math.random() - 0.5 * 0.1), player.posY + 2.4 + (Math.random() - 0.5 * 0.1), player.posZ + (Math.random() - 0.5 * 0.1))) - ManaItemHandler.requestManaExactForTool(stack, player, COST_PER, true); - - Botania.proxy.sparkleFX(player.worldObj, player.posX, player.posY + 2.4, player.posZ, 1F, 0.4F, 1F, 6F, 6); - } - } - - public boolean spawnMissile(World world, EntityLivingBase thrower, double x, double y, double z) { - EntityMagicMissile missile; - if(thrower != null) - missile = new EntityMagicMissile(thrower, false); - else missile = new EntityMagicMissile(world); - - missile.setPosition(x, y, z); - if(missile.getTarget()) { - if(!world.isRemote) { - world.playSoundEffect(x, y, z, "botania:missile", 0.6F, 0.8F + (float) Math.random() * 0.2F); - world.spawnEntityInWorld(missile); - } - - return true; - } - return false; - } - - @Override - public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer) { - par3EntityPlayer.setItemInUse(par1ItemStack, getMaxItemUseDuration(par1ItemStack)); - return par1ItemStack; - } - - @Override - public boolean isFull3D() { - return true; - } - - @Override - public boolean usesMana(ItemStack stack) { - return true; - } - - @Override - public void onAvatarUpdate(IAvatarTile tile, ItemStack stack) { - TileEntity te = (TileEntity) tile; - World world = te.getWorldObj(); - if(tile.getCurrentMana() >= COST_AVATAR && tile.getElapsedFunctionalTicks() % 3 == 0 && tile.isEnabled()) - if(spawnMissile(world, null, te.xCoord + 0.5 + (Math.random() - 0.5 * 0.1), te.yCoord + 2.5 + (Math.random() - 0.5 * 0.1), te.zCoord + (Math.random() - 0.5 * 0.1))) { - if(!world.isRemote) - tile.recieveMana(-COST_AVATAR); - Botania.proxy.sparkleFX(world, te.xCoord + 0.5, te.yCoord + 2.5, te.zCoord + 0.5, 1F, 0.4F, 1F, 6F, 6); - } - } - - @Override - public ResourceLocation getOverlayResource(IAvatarTile tile, ItemStack stack) { - return avatarOverlay; - } + private static final ResourceLocation avatarOverlay = new ResourceLocation(LibResources.MODEL_AVATAR_MISSILE); + + private static final int COST_PER = 120; + private static final int COST_AVATAR = 40; + + public ItemMissileRod() { + super(); + setMaxStackSize(1); + setUnlocalizedName(LibItemNames.MISSILE_ROD); + } + + @Override + public EnumAction getItemUseAction(ItemStack par1ItemStack) { + return EnumAction.bow; + } + + @Override + public int getMaxItemUseDuration(ItemStack par1ItemStack) { + return 72000; + } + + @Override + public void onUsingTick(ItemStack stack, EntityPlayer player, int count) { + if (count != getMaxItemUseDuration(stack) + && count % (IManaProficiencyArmor.Helper.hasProficiency(player) ? 1 : 2) == 0 + && !player.worldObj.isRemote + && ManaItemHandler.requestManaExactForTool(stack, player, COST_PER, false)) { + if (spawnMissile( + player.worldObj, + player, + player.posX + (Math.random() - 0.5 * 0.1), + player.posY + 2.4 + (Math.random() - 0.5 * 0.1), + player.posZ + (Math.random() - 0.5 * 0.1))) + ManaItemHandler.requestManaExactForTool(stack, player, COST_PER, true); + + Botania.proxy.sparkleFX(player.worldObj, player.posX, player.posY + 2.4, player.posZ, 1F, 0.4F, 1F, 6F, 6); + } + } + + public boolean spawnMissile(World world, EntityLivingBase thrower, double x, double y, double z) { + EntityMagicMissile missile; + if (thrower != null) missile = new EntityMagicMissile(thrower, false); + else missile = new EntityMagicMissile(world); + + missile.setPosition(x, y, z); + if (missile.getTarget()) { + if (!world.isRemote) { + world.playSoundEffect(x, y, z, "botania:missile", 0.6F, 0.8F + (float) Math.random() * 0.2F); + world.spawnEntityInWorld(missile); + } + + return true; + } + return false; + } + + @Override + public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer) { + par3EntityPlayer.setItemInUse(par1ItemStack, getMaxItemUseDuration(par1ItemStack)); + return par1ItemStack; + } + + @Override + public boolean isFull3D() { + return true; + } + + @Override + public boolean usesMana(ItemStack stack) { + return true; + } + + @Override + public void onAvatarUpdate(IAvatarTile tile, ItemStack stack) { + TileEntity te = (TileEntity) tile; + World world = te.getWorldObj(); + if (tile.getCurrentMana() >= COST_AVATAR && tile.getElapsedFunctionalTicks() % 3 == 0 && tile.isEnabled()) + if (spawnMissile( + world, + null, + te.xCoord + 0.5 + (Math.random() - 0.5 * 0.1), + te.yCoord + 2.5 + (Math.random() - 0.5 * 0.1), + te.zCoord + (Math.random() - 0.5 * 0.1))) { + if (!world.isRemote) tile.recieveMana(-COST_AVATAR); + Botania.proxy.sparkleFX(world, te.xCoord + 0.5, te.yCoord + 2.5, te.zCoord + 0.5, 1F, 0.4F, 1F, 6F, 6); + } + } + + @Override + public ResourceLocation getOverlayResource(IAvatarTile tile, ItemStack stack) { + return avatarOverlay; + } } diff --git a/src/main/java/vazkii/botania/common/item/rod/ItemRainbowRod.java b/src/main/java/vazkii/botania/common/item/rod/ItemRainbowRod.java index 2c2ae87aaa..07bb605c70 100644 --- a/src/main/java/vazkii/botania/common/item/rod/ItemRainbowRod.java +++ b/src/main/java/vazkii/botania/common/item/rod/ItemRainbowRod.java @@ -2,16 +2,15 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jun 20, 2014, 7:09:51 PM (GMT)] */ package vazkii.botania.common.item.rod; import java.util.List; - import net.minecraft.block.Block; import net.minecraft.entity.Entity; import net.minecraft.entity.player.EntityPlayer; @@ -37,172 +36,182 @@ public class ItemRainbowRod extends ItemMod implements IManaUsingItem, IAvatarWieldable { - private static final ResourceLocation avatarOverlay = new ResourceLocation(LibResources.MODEL_AVATAR_RAINBOW); - - private static final int MANA_COST = 750; - private static final int MANA_COST_AVATAR = 10; - private static final int TIME = 600; - - public ItemRainbowRod() { - setMaxDamage(TIME); - setUnlocalizedName(LibItemNames.RAINBOW_ROD); - setMaxStackSize(1); - } - - @Override - public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer) { - if(!par2World.isRemote && par1ItemStack.getItemDamage() == 0 && ManaItemHandler.requestManaExactForTool(par1ItemStack, par3EntityPlayer, MANA_COST, false)) { - Block place = ModBlocks.bifrost; - Vector3 vector = new Vector3(par3EntityPlayer.getLookVec()).normalize(); - - double x = par3EntityPlayer.posX; - double y = par3EntityPlayer.posY; - double z = par3EntityPlayer.posZ; - - double lx = 0; - double ly = -1; - double lz = 0; - - int count = 0; - boolean prof = IManaProficiencyArmor.Helper.hasProficiency(par3EntityPlayer); - int maxlen = prof ? 160 : 100; - int time = prof ? (int) (TIME * 1.6) : TIME; - - while(count < maxlen && (int) lx == (int) x && (int) ly == (int) y && (int) lz == (int) z || count < 4 || par2World.getBlock((int) x, (int) y, (int) z).isAir(par2World, (int) x, (int) y, (int) z) || par2World.getBlock((int) x, (int) y, (int) z) == place) { - if(y >= 256 || y <= 0) - break; - - for(int i = -2; i < 1; i++) - for(int j = -2; j < 1; j++) - if(par2World.getBlock((int) x + i, (int) y, (int) z + j).isAir(par2World, (int) x + i, (int) y, (int) z + j) || par2World.getBlock((int) x + i, (int) y, (int) z + j) == place) { - par2World.setBlock((int) x + i, (int) y, (int) z + j, place); - TileBifrost tile = (TileBifrost) par2World.getTileEntity((int) x + i, (int) y, (int) z + j); - if(tile != null) { - for(int k = 0; k < 4; k++) - Botania.proxy.sparkleFX(par2World, tile.xCoord + Math.random(), tile.yCoord + Math.random(), tile.zCoord + Math.random(), (float) Math.random(), (float) Math.random(), (float) Math.random(), 0.45F + 0.2F * (float) Math.random(), 6); - tile.ticks = time; - } - } - - lx = x; - ly = y; - lz = z; - - x += vector.x; - y += vector.y; - z += vector.z; - count++; - } - - if(count > 0) { - par2World.playSoundAtEntity(par3EntityPlayer, "botania:bifrostRod", 0.5F, 0.25F); - ManaItemHandler.requestManaExactForTool(par1ItemStack, par3EntityPlayer, MANA_COST, false); - par1ItemStack.setItemDamage(TIME); - } - } - - return par1ItemStack; - } - - @Override - public ItemStack getContainerItem(ItemStack itemStack) { - return itemStack.copy(); - } - - @Override - public boolean hasContainerItem(ItemStack stack) { - return getContainerItem(stack) != null; - } - - @Override - public boolean doesContainerItemLeaveCraftingGrid(ItemStack par1ItemStack) { - return false; - } - - @Override - public void onUpdate(ItemStack par1ItemStack, World par2World, Entity par3Entity, int par4, boolean par5) { - if(par1ItemStack.isItemDamaged()) - par1ItemStack.setItemDamage(par1ItemStack.getItemDamage() - 1); - } - - @Override - public boolean isFull3D() { - return true; - } - - @Override - public boolean usesMana(ItemStack stack) { - return true; - } - - @Override - public void onAvatarUpdate(IAvatarTile tile, ItemStack stack) { - TileEntity te = (TileEntity) tile; - World world = te.getWorldObj(); - - if(world.isRemote || tile.getCurrentMana() < MANA_COST_AVATAR * 25 || !tile.isEnabled()) - return; - - int x = te.xCoord; - int y = te.yCoord; - int z = te.zCoord; - int w = 1; - int h = 1; - int l = 20; - - AxisAlignedBB axis = null; - switch(te.getBlockMetadata() - 2) { - case 0 : - axis = AxisAlignedBB.getBoundingBox(x - w, y - h, z - l, x + w + 1, y + h, z); - break; - case 1 : - axis = AxisAlignedBB.getBoundingBox(x - w, y - h, z + 1, x + w + 1, y + h, z + l + 1); - break; - case 2 : - axis = AxisAlignedBB.getBoundingBox(x - l, y - h, z - w, x, y + h, z + w + 1); - break; - case 3 : - axis = AxisAlignedBB.getBoundingBox(x + 1, y - h, z - w, x + l + 1, y + h, z + w + 1); - } - - List players = world.getEntitiesWithinAABB(EntityPlayer.class, axis); - for(EntityPlayer p : players) { - int px = MathHelper.floor_double(p.posX); - int py = MathHelper.floor_double(p.posY) - 1; - int pz = MathHelper.floor_double(p.posZ); - int dist = 5; - int diff = dist / 2; - - for(int i = 0; i < dist; i++) - for(int j = 0; j < dist; j++) { - int ex = px + i - diff; - int ez = pz + j - diff; - - if(!axis.isVecInside(Vec3.createVectorHelper(ex + 0.5, py + 1, ez + 0.5))) - continue; - - Block block = world.getBlock(ex, py, ez); - if(block.isAir(world, ex, py, ez)) { - world.setBlock(ex, py, ez, ModBlocks.bifrost); - TileBifrost tileBifrost = (TileBifrost) world.getTileEntity(ex, py, ez); - tileBifrost.ticks = 10; - tile.recieveMana(-MANA_COST_AVATAR); - } else if(block == ModBlocks.bifrost) { - TileBifrost tileBifrost = (TileBifrost) world.getTileEntity(ex, py, ez); - if(tileBifrost.ticks < 2) { - tileBifrost.ticks = 10; - tile.recieveMana(-MANA_COST_AVATAR); - } - } - } - } - - - } - - @Override - public ResourceLocation getOverlayResource(IAvatarTile tile, ItemStack stack) { - return avatarOverlay; - } - + private static final ResourceLocation avatarOverlay = new ResourceLocation(LibResources.MODEL_AVATAR_RAINBOW); + + private static final int MANA_COST = 750; + private static final int MANA_COST_AVATAR = 10; + private static final int TIME = 600; + + public ItemRainbowRod() { + setMaxDamage(TIME); + setUnlocalizedName(LibItemNames.RAINBOW_ROD); + setMaxStackSize(1); + } + + @Override + public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer) { + if (!par2World.isRemote + && par1ItemStack.getItemDamage() == 0 + && ManaItemHandler.requestManaExactForTool(par1ItemStack, par3EntityPlayer, MANA_COST, false)) { + Block place = ModBlocks.bifrost; + Vector3 vector = new Vector3(par3EntityPlayer.getLookVec()).normalize(); + + double x = par3EntityPlayer.posX; + double y = par3EntityPlayer.posY; + double z = par3EntityPlayer.posZ; + + double lx = 0; + double ly = -1; + double lz = 0; + + int count = 0; + boolean prof = IManaProficiencyArmor.Helper.hasProficiency(par3EntityPlayer); + int maxlen = prof ? 160 : 100; + int time = prof ? (int) (TIME * 1.6) : TIME; + + while (count < maxlen && (int) lx == (int) x && (int) ly == (int) y && (int) lz == (int) z + || count < 4 + || par2World.getBlock((int) x, (int) y, (int) z).isAir(par2World, (int) x, (int) y, (int) z) + || par2World.getBlock((int) x, (int) y, (int) z) == place) { + if (y >= 256 || y <= 0) break; + + for (int i = -2; i < 1; i++) + for (int j = -2; j < 1; j++) + if (par2World + .getBlock((int) x + i, (int) y, (int) z + j) + .isAir(par2World, (int) x + i, (int) y, (int) z + j) + || par2World.getBlock((int) x + i, (int) y, (int) z + j) == place) { + par2World.setBlock((int) x + i, (int) y, (int) z + j, place); + TileBifrost tile = (TileBifrost) par2World.getTileEntity((int) x + i, (int) y, (int) z + j); + if (tile != null) { + for (int k = 0; k < 4; k++) + Botania.proxy.sparkleFX( + par2World, + tile.xCoord + Math.random(), + tile.yCoord + Math.random(), + tile.zCoord + Math.random(), + (float) Math.random(), + (float) Math.random(), + (float) Math.random(), + 0.45F + 0.2F * (float) Math.random(), + 6); + tile.ticks = time; + } + } + + lx = x; + ly = y; + lz = z; + + x += vector.x; + y += vector.y; + z += vector.z; + count++; + } + + if (count > 0) { + par2World.playSoundAtEntity(par3EntityPlayer, "botania:bifrostRod", 0.5F, 0.25F); + ManaItemHandler.requestManaExactForTool(par1ItemStack, par3EntityPlayer, MANA_COST, false); + par1ItemStack.setItemDamage(TIME); + } + } + + return par1ItemStack; + } + + @Override + public ItemStack getContainerItem(ItemStack itemStack) { + return itemStack.copy(); + } + + @Override + public boolean hasContainerItem(ItemStack stack) { + return getContainerItem(stack) != null; + } + + @Override + public boolean doesContainerItemLeaveCraftingGrid(ItemStack par1ItemStack) { + return false; + } + + @Override + public void onUpdate(ItemStack par1ItemStack, World par2World, Entity par3Entity, int par4, boolean par5) { + if (par1ItemStack.isItemDamaged()) par1ItemStack.setItemDamage(par1ItemStack.getItemDamage() - 1); + } + + @Override + public boolean isFull3D() { + return true; + } + + @Override + public boolean usesMana(ItemStack stack) { + return true; + } + + @Override + public void onAvatarUpdate(IAvatarTile tile, ItemStack stack) { + TileEntity te = (TileEntity) tile; + World world = te.getWorldObj(); + + if (world.isRemote || tile.getCurrentMana() < MANA_COST_AVATAR * 25 || !tile.isEnabled()) return; + + int x = te.xCoord; + int y = te.yCoord; + int z = te.zCoord; + int w = 1; + int h = 1; + int l = 20; + + AxisAlignedBB axis = null; + switch (te.getBlockMetadata() - 2) { + case 0: + axis = AxisAlignedBB.getBoundingBox(x - w, y - h, z - l, x + w + 1, y + h, z); + break; + case 1: + axis = AxisAlignedBB.getBoundingBox(x - w, y - h, z + 1, x + w + 1, y + h, z + l + 1); + break; + case 2: + axis = AxisAlignedBB.getBoundingBox(x - l, y - h, z - w, x, y + h, z + w + 1); + break; + case 3: + axis = AxisAlignedBB.getBoundingBox(x + 1, y - h, z - w, x + l + 1, y + h, z + w + 1); + } + + List players = world.getEntitiesWithinAABB(EntityPlayer.class, axis); + for (EntityPlayer p : players) { + int px = MathHelper.floor_double(p.posX); + int py = MathHelper.floor_double(p.posY) - 1; + int pz = MathHelper.floor_double(p.posZ); + int dist = 5; + int diff = dist / 2; + + for (int i = 0; i < dist; i++) + for (int j = 0; j < dist; j++) { + int ex = px + i - diff; + int ez = pz + j - diff; + + if (!axis.isVecInside(Vec3.createVectorHelper(ex + 0.5, py + 1, ez + 0.5))) continue; + + Block block = world.getBlock(ex, py, ez); + if (block.isAir(world, ex, py, ez)) { + world.setBlock(ex, py, ez, ModBlocks.bifrost); + TileBifrost tileBifrost = (TileBifrost) world.getTileEntity(ex, py, ez); + tileBifrost.ticks = 10; + tile.recieveMana(-MANA_COST_AVATAR); + } else if (block == ModBlocks.bifrost) { + TileBifrost tileBifrost = (TileBifrost) world.getTileEntity(ex, py, ez); + if (tileBifrost.ticks < 2) { + tileBifrost.ticks = 10; + tile.recieveMana(-MANA_COST_AVATAR); + } + } + } + } + } + + @Override + public ResourceLocation getOverlayResource(IAvatarTile tile, ItemStack stack) { + return avatarOverlay; + } } diff --git a/src/main/java/vazkii/botania/common/item/rod/ItemSkyDirtRod.java b/src/main/java/vazkii/botania/common/item/rod/ItemSkyDirtRod.java index 81b3909919..d99c4a41f5 100644 --- a/src/main/java/vazkii/botania/common/item/rod/ItemSkyDirtRod.java +++ b/src/main/java/vazkii/botania/common/item/rod/ItemSkyDirtRod.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jul 23, 2014, 1:06:51 AM (GMT)] */ package vazkii.botania.common.item.rod; @@ -24,38 +24,47 @@ public class ItemSkyDirtRod extends ItemDirtRod { - public ItemSkyDirtRod() { - super(LibItemNames.SKY_DIRT_ROD); - } + public ItemSkyDirtRod() { + super(LibItemNames.SKY_DIRT_ROD); + } - @Override - public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer player) { - if(!world.isRemote && ManaItemHandler.requestManaExactForTool(stack, player, COST * 2, false)) { - Vector3 playerVec = Vector3.fromEntityCenter(player); - Vector3 lookVec = new Vector3(player.getLookVec()).multiply(3); - Vector3 placeVec = playerVec.copy().add(lookVec); + @Override + public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer player) { + if (!world.isRemote && ManaItemHandler.requestManaExactForTool(stack, player, COST * 2, false)) { + Vector3 playerVec = Vector3.fromEntityCenter(player); + Vector3 lookVec = new Vector3(player.getLookVec()).multiply(3); + Vector3 placeVec = playerVec.copy().add(lookVec); - int x = MathHelper.floor_double(placeVec.x); - int y = MathHelper.floor_double(placeVec.y) + 1; - int z = MathHelper.floor_double(placeVec.z); + int x = MathHelper.floor_double(placeVec.x); + int y = MathHelper.floor_double(placeVec.y) + 1; + int z = MathHelper.floor_double(placeVec.z); - int entities = world.getEntitiesWithinAABB(EntityLivingBase.class, AxisAlignedBB.getBoundingBox(x, y, z, x + 1, y + 1, z + 1)).size(); + int entities = world.getEntitiesWithinAABB( + EntityLivingBase.class, AxisAlignedBB.getBoundingBox(x, y, z, x + 1, y + 1, z + 1)) + .size(); - if(entities == 0) { - ItemStack stackToPlace = new ItemStack(Blocks.dirt); - stackToPlace.tryPlaceItemIntoWorld(player, world, x, y, z, 0, 0F, 0F, 0F); + if (entities == 0) { + ItemStack stackToPlace = new ItemStack(Blocks.dirt); + stackToPlace.tryPlaceItemIntoWorld(player, world, x, y, z, 0, 0F, 0F, 0F); - if(stackToPlace.stackSize == 0) { - ManaItemHandler.requestManaExactForTool(stack, player, COST * 2, true); - for(int i = 0; i < 6; i++) - Botania.proxy.sparkleFX(world, x + Math.random(), y + Math.random(), z + Math.random(), 0.35F, 0.2F, 0.05F, 1F, 5); - } - } - } - if(world.isRemote) - player.swingItem(); - - return stack; - } + if (stackToPlace.stackSize == 0) { + ManaItemHandler.requestManaExactForTool(stack, player, COST * 2, true); + for (int i = 0; i < 6; i++) + Botania.proxy.sparkleFX( + world, + x + Math.random(), + y + Math.random(), + z + Math.random(), + 0.35F, + 0.2F, + 0.05F, + 1F, + 5); + } + } + } + if (world.isRemote) player.swingItem(); + return stack; + } } diff --git a/src/main/java/vazkii/botania/common/item/rod/ItemSmeltRod.java b/src/main/java/vazkii/botania/common/item/rod/ItemSmeltRod.java index 6a72d46712..415113ac27 100644 --- a/src/main/java/vazkii/botania/common/item/rod/ItemSmeltRod.java +++ b/src/main/java/vazkii/botania/common/item/rod/ItemSmeltRod.java @@ -2,17 +2,16 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jan 24, 2015, 11:05:41 PM (GMT)] */ package vazkii.botania.common.item.rod; import java.util.Map; import java.util.WeakHashMap; - import net.minecraft.block.Block; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.EnumAction; @@ -31,115 +30,124 @@ public class ItemSmeltRod extends ItemMod implements IManaUsingItem { - private static final int TIME = 10; - private static final int COST = 300; - private static final int COST_PER_TICK = COST / TIME; - - public static Map playerData = new WeakHashMap(); - - public ItemSmeltRod() { - setUnlocalizedName(LibItemNames.SMELT_ROD); - setMaxStackSize(1); - } - - @Override - public EnumAction getItemUseAction(ItemStack par1ItemStack) { - return EnumAction.bow; - } - - @Override - public int getMaxItemUseDuration(ItemStack par1ItemStack) { - return 72000; - } - - @Override - public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer) { - par3EntityPlayer.setItemInUse(par1ItemStack, getMaxItemUseDuration(par1ItemStack)); - return par1ItemStack; - } - - @Override - public void onUsingTick(ItemStack stack, EntityPlayer p, int time) { - if(!ManaItemHandler.requestManaExactForTool(stack, p, COST_PER_TICK, false)) - return; - - MovingObjectPosition pos = ToolCommons.raytraceFromEntity(p.worldObj, p, false, 32); - - if(pos != null) { - Block block = p.worldObj.getBlock(pos.blockX, pos.blockY, pos.blockZ); - int meta = p.worldObj.getBlockMetadata(pos.blockX, pos.blockY, pos.blockZ); - - ItemStack blockStack = new ItemStack(block, 1, meta); - ItemStack result = FurnaceRecipes.smelting().getSmeltingResult(blockStack); - - if(result != null && result.getItem() instanceof ItemBlock) { - boolean decremented = false; - - if(playerData.containsKey(p)) { - SmeltData data = playerData.get(p); - - if(data.equalPos(pos)) { - data.progress--; - decremented = true; - if(data.progress <= 0) { - if(!p.worldObj.isRemote) { - p.worldObj.setBlock(pos.blockX, pos.blockY, pos.blockZ, Block.getBlockFromItem(result.getItem()), result.getItemDamage(), 1 | 2); - p.worldObj.playSoundAtEntity(p, "fire.ignite", 0.6F, 1F); - p.worldObj.playSoundAtEntity(p, "fire.fire", 1F, 1F); - - ManaItemHandler.requestManaExactForTool(stack, p, COST_PER_TICK, true); - playerData.remove(p.getGameProfile().getName()); - decremented = false; - } - - for(int i = 0; i < 25; i++) { - double x = pos.blockX + Math.random(); - double y = pos.blockY + Math.random(); - double z = pos.blockZ + Math.random(); - - Botania.proxy.wispFX(p.worldObj, x, y, z, 1F, 0.2F, 0.2F, 0.5F, (float) -Math.random() / 10F); - } - } - } - } - - if(!decremented) - playerData.put(p, new SmeltData(pos, IManaProficiencyArmor.Helper.hasProficiency(p) ? (int) (TIME * 0.6) : TIME)); - else { - for(int i = 0; i < 2; i++) { - double x = pos.blockX + Math.random(); - double y = pos.blockY + Math.random(); - double z = pos.blockZ + Math.random(); - Botania.proxy.wispFX(p.worldObj, x, y, z, 1F, 0.2F, 0.2F, 0.5F, (float) -Math.random() / 10F); - } - if(time % 10 == 0) - p.worldObj.playSoundAtEntity(p, "fire.fire", (float) Math.random() / 2F + 0.5F, 1F); - } - } - } - } - - @Override - public boolean isFull3D() { - return true; - } - - @Override - public boolean usesMana(ItemStack stack) { - return true; - } - - static class SmeltData { - public MovingObjectPosition pos; - public int progress; - - public SmeltData(MovingObjectPosition pos, int progress) { - this.pos = pos; - this.progress = progress; - } - - public boolean equalPos(MovingObjectPosition pos) { - return pos.blockX == this.pos.blockX && pos.blockY == this.pos.blockY && pos.blockZ == this.pos.blockZ; - } - } + private static final int TIME = 10; + private static final int COST = 300; + private static final int COST_PER_TICK = COST / TIME; + + public static Map playerData = new WeakHashMap(); + + public ItemSmeltRod() { + setUnlocalizedName(LibItemNames.SMELT_ROD); + setMaxStackSize(1); + } + + @Override + public EnumAction getItemUseAction(ItemStack par1ItemStack) { + return EnumAction.bow; + } + + @Override + public int getMaxItemUseDuration(ItemStack par1ItemStack) { + return 72000; + } + + @Override + public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer) { + par3EntityPlayer.setItemInUse(par1ItemStack, getMaxItemUseDuration(par1ItemStack)); + return par1ItemStack; + } + + @Override + public void onUsingTick(ItemStack stack, EntityPlayer p, int time) { + if (!ManaItemHandler.requestManaExactForTool(stack, p, COST_PER_TICK, false)) return; + + MovingObjectPosition pos = ToolCommons.raytraceFromEntity(p.worldObj, p, false, 32); + + if (pos != null) { + Block block = p.worldObj.getBlock(pos.blockX, pos.blockY, pos.blockZ); + int meta = p.worldObj.getBlockMetadata(pos.blockX, pos.blockY, pos.blockZ); + + ItemStack blockStack = new ItemStack(block, 1, meta); + ItemStack result = FurnaceRecipes.smelting().getSmeltingResult(blockStack); + + if (result != null && result.getItem() instanceof ItemBlock) { + boolean decremented = false; + + if (playerData.containsKey(p)) { + SmeltData data = playerData.get(p); + + if (data.equalPos(pos)) { + data.progress--; + decremented = true; + if (data.progress <= 0) { + if (!p.worldObj.isRemote) { + p.worldObj.setBlock( + pos.blockX, + pos.blockY, + pos.blockZ, + Block.getBlockFromItem(result.getItem()), + result.getItemDamage(), + 1 | 2); + p.worldObj.playSoundAtEntity(p, "fire.ignite", 0.6F, 1F); + p.worldObj.playSoundAtEntity(p, "fire.fire", 1F, 1F); + + ManaItemHandler.requestManaExactForTool(stack, p, COST_PER_TICK, true); + playerData.remove(p.getGameProfile().getName()); + decremented = false; + } + + for (int i = 0; i < 25; i++) { + double x = pos.blockX + Math.random(); + double y = pos.blockY + Math.random(); + double z = pos.blockZ + Math.random(); + + Botania.proxy.wispFX( + p.worldObj, x, y, z, 1F, 0.2F, 0.2F, 0.5F, (float) -Math.random() / 10F); + } + } + } + } + + if (!decremented) + playerData.put( + p, + new SmeltData( + pos, IManaProficiencyArmor.Helper.hasProficiency(p) ? (int) (TIME * 0.6) : TIME)); + else { + for (int i = 0; i < 2; i++) { + double x = pos.blockX + Math.random(); + double y = pos.blockY + Math.random(); + double z = pos.blockZ + Math.random(); + Botania.proxy.wispFX(p.worldObj, x, y, z, 1F, 0.2F, 0.2F, 0.5F, (float) -Math.random() / 10F); + } + if (time % 10 == 0) + p.worldObj.playSoundAtEntity(p, "fire.fire", (float) Math.random() / 2F + 0.5F, 1F); + } + } + } + } + + @Override + public boolean isFull3D() { + return true; + } + + @Override + public boolean usesMana(ItemStack stack) { + return true; + } + + static class SmeltData { + public MovingObjectPosition pos; + public int progress; + + public SmeltData(MovingObjectPosition pos, int progress) { + this.pos = pos; + this.progress = progress; + } + + public boolean equalPos(MovingObjectPosition pos) { + return pos.blockX == this.pos.blockX && pos.blockY == this.pos.blockY && pos.blockZ == this.pos.blockZ; + } + } } diff --git a/src/main/java/vazkii/botania/common/item/rod/ItemTerraformRod.java b/src/main/java/vazkii/botania/common/item/rod/ItemTerraformRod.java index c9e90d09d1..494b5a1779 100644 --- a/src/main/java/vazkii/botania/common/item/rod/ItemTerraformRod.java +++ b/src/main/java/vazkii/botania/common/item/rod/ItemTerraformRod.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Apr 11, 2014, 2:56:39 PM (GMT)] */ package vazkii.botania.common.item.rod; @@ -13,7 +13,6 @@ import java.util.ArrayList; import java.util.Arrays; import java.util.List; - import net.minecraft.block.Block; import net.minecraft.block.BlockFlower; import net.minecraft.entity.player.EntityPlayer; @@ -38,177 +37,186 @@ import vazkii.botania.common.lib.LibItemNames; import vazkii.botania.common.lib.LibMisc; -public class ItemTerraformRod extends ItemMod implements IManaUsingItem, IBlockProvider, ICraftAchievement{ - - private static final int COST_PER = 55; - - static final List validBlocks = Arrays.asList(new String[] { - "stone", - "dirt", - "grass", - "sand", - "gravel", - "hardenedClay", - "snowLayer", - "mycelium", - "podzol", - "sandstone", - - // Mod support - "blockDiorite", - "stoneDiorite", - "blockGranite", - "stoneGranite", - "blockAndesite", - "stoneAndesite", - "marble", - "blockMarble", - "limestone", - "blockLimestone" - }); - - public ItemTerraformRod() { - super(); - setMaxStackSize(1); - setUnlocalizedName(LibItemNames.TERRAFORM_ROD); - } - - @Override - public EnumAction getItemUseAction(ItemStack par1ItemStack) { - return EnumAction.bow; - } - - @Override - public int getMaxItemUseDuration(ItemStack par1ItemStack) { - return 72000; - } - - @Override - public void onUsingTick(ItemStack stack, EntityPlayer player, int count) { - if(count != getMaxItemUseDuration(stack) && count % 10 == 0) - terraform(stack, player.worldObj, player); - } - - @Override - public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer) { - par3EntityPlayer.setItemInUse(par1ItemStack, getMaxItemUseDuration(par1ItemStack)); - return par1ItemStack; - } - - public void terraform(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer) { - int range = IManaProficiencyArmor.Helper.hasProficiency(par3EntityPlayer) ? 22 : 16; - - int xCenter = (int) par3EntityPlayer.posX; - int yCenter = (int) par3EntityPlayer.posY - (par2World.isRemote ? 2 : 1); - int zCenter = (int) par3EntityPlayer.posZ; - - if(yCenter < 62) // Not below sea level - return; - - int yStart = yCenter + range; - - List blocks = new ArrayList(); - - for(int i = -range; i < range + 1; i++) - for(int j = -range; j < range + 1; j++) { - int k = 0; - while(true) { - if(yStart + k < 0) - break; - - int x = xCenter + i; - int y = yStart + k; - int z = zCenter + j; - - Block block = par2World.getBlock(x, y, z); - int meta = par2World.getBlockMetadata(x, y, z); - - int[] ids = OreDictionary.getOreIDs(new ItemStack(block, 1, meta)); - for(int id : ids) - if(validBlocks.contains(OreDictionary.getOreName(id))) { - boolean hasAir = false; - List airBlocks = new ArrayList(); - - for(ForgeDirection dir : LibMisc.CARDINAL_DIRECTIONS) { - int x_ = x + dir.offsetX; - int y_ = y + dir.offsetY; - int z_ = z + dir.offsetZ; - - Block block_ = par2World.getBlock(x_, y_, z_); - if(block_.isAir(par2World, x_, y_, z_) || block_.isReplaceable(par2World, x_, y_, z_) || block_ instanceof BlockFlower && !(block_ instanceof ISpecialFlower) || block_ == Blocks.double_plant) { - airBlocks.add(new ChunkCoordinates(x_, y_, z_)); - hasAir = true; - } - } - - if(hasAir) { - if(y > yCenter) - blocks.add(new CoordsWithBlock(x, y, z, Blocks.air)); - else for(ChunkCoordinates coords : airBlocks) { - if(par2World.getBlock(coords.posX, coords.posY - 1, coords.posZ) != Blocks.air) - blocks.add(new CoordsWithBlock(coords.posX, coords.posY, coords.posZ, Blocks.dirt)); - } - } - break; - } - --k; - } - } - - int cost = COST_PER * blocks.size(); - - if(par2World.isRemote || ManaItemHandler.requestManaExactForTool(par1ItemStack, par3EntityPlayer, cost, true)) { - if(!par2World.isRemote) - for(CoordsWithBlock block : blocks) - par2World.setBlock(block.posX, block.posY, block.posZ, block.block); - - if(!blocks.isEmpty()) { - for(int i = 0; i < 10; i++) - par2World.playSoundAtEntity(par3EntityPlayer, "step.sand", 1F, 0.4F); - for(int i = 0; i < 120; i++) - Botania.proxy.sparkleFX(par2World, xCenter - range + range * 2 * Math.random(), yCenter + 2 + (Math.random() - 0.5) * 2, zCenter - range + range * 2 * Math.random(), 0.35F, 0.2F, 0.05F, 2F, 5); - } - } - } - - @Override - public boolean isFull3D() { - return true; - } - - class CoordsWithBlock extends ChunkCoordinates { - - final Block block; - - public CoordsWithBlock(int x, int y, int z, Block block) { - super(x, y, z); - this.block = block; - } - - } - - @Override - public boolean usesMana(ItemStack stack) { - return true; - } - - @Override - public boolean provideBlock(EntityPlayer player, ItemStack requestor, ItemStack stack, Block block, int meta, boolean doit) { - if(block == Blocks.dirt && meta == 0) - return !doit || ManaItemHandler.requestManaExactForTool(requestor, player, ItemDirtRod.COST, true); - return false; - } - - @Override - public int getBlockCount(EntityPlayer player, ItemStack requestor, ItemStack stack, Block block, int meta) { - if(block == Blocks.dirt && meta == 0) - return -1; - return 0; - } - - @Override - public Achievement getAchievementOnCraft(ItemStack stack, EntityPlayer player, IInventory matrix) { - return ModAchievements.terraformRodCraft; - } - +public class ItemTerraformRod extends ItemMod implements IManaUsingItem, IBlockProvider, ICraftAchievement { + + private static final int COST_PER = 55; + + static final List validBlocks = Arrays.asList(new String[] { + "stone", + "dirt", + "grass", + "sand", + "gravel", + "hardenedClay", + "snowLayer", + "mycelium", + "podzol", + "sandstone", + + // Mod support + "blockDiorite", + "stoneDiorite", + "blockGranite", + "stoneGranite", + "blockAndesite", + "stoneAndesite", + "marble", + "blockMarble", + "limestone", + "blockLimestone" + }); + + public ItemTerraformRod() { + super(); + setMaxStackSize(1); + setUnlocalizedName(LibItemNames.TERRAFORM_ROD); + } + + @Override + public EnumAction getItemUseAction(ItemStack par1ItemStack) { + return EnumAction.bow; + } + + @Override + public int getMaxItemUseDuration(ItemStack par1ItemStack) { + return 72000; + } + + @Override + public void onUsingTick(ItemStack stack, EntityPlayer player, int count) { + if (count != getMaxItemUseDuration(stack) && count % 10 == 0) terraform(stack, player.worldObj, player); + } + + @Override + public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer) { + par3EntityPlayer.setItemInUse(par1ItemStack, getMaxItemUseDuration(par1ItemStack)); + return par1ItemStack; + } + + public void terraform(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer) { + int range = IManaProficiencyArmor.Helper.hasProficiency(par3EntityPlayer) ? 22 : 16; + + int xCenter = (int) par3EntityPlayer.posX; + int yCenter = (int) par3EntityPlayer.posY - (par2World.isRemote ? 2 : 1); + int zCenter = (int) par3EntityPlayer.posZ; + + if (yCenter < 62) // Not below sea level + return; + + int yStart = yCenter + range; + + List blocks = new ArrayList(); + + for (int i = -range; i < range + 1; i++) + for (int j = -range; j < range + 1; j++) { + int k = 0; + while (true) { + if (yStart + k < 0) break; + + int x = xCenter + i; + int y = yStart + k; + int z = zCenter + j; + + Block block = par2World.getBlock(x, y, z); + int meta = par2World.getBlockMetadata(x, y, z); + + int[] ids = OreDictionary.getOreIDs(new ItemStack(block, 1, meta)); + for (int id : ids) + if (validBlocks.contains(OreDictionary.getOreName(id))) { + boolean hasAir = false; + List airBlocks = new ArrayList(); + + for (ForgeDirection dir : LibMisc.CARDINAL_DIRECTIONS) { + int x_ = x + dir.offsetX; + int y_ = y + dir.offsetY; + int z_ = z + dir.offsetZ; + + Block block_ = par2World.getBlock(x_, y_, z_); + if (block_.isAir(par2World, x_, y_, z_) + || block_.isReplaceable(par2World, x_, y_, z_) + || block_ instanceof BlockFlower && !(block_ instanceof ISpecialFlower) + || block_ == Blocks.double_plant) { + airBlocks.add(new ChunkCoordinates(x_, y_, z_)); + hasAir = true; + } + } + + if (hasAir) { + if (y > yCenter) blocks.add(new CoordsWithBlock(x, y, z, Blocks.air)); + else + for (ChunkCoordinates coords : airBlocks) { + if (par2World.getBlock(coords.posX, coords.posY - 1, coords.posZ) != Blocks.air) + blocks.add(new CoordsWithBlock( + coords.posX, coords.posY, coords.posZ, Blocks.dirt)); + } + } + break; + } + --k; + } + } + + int cost = COST_PER * blocks.size(); + + if (par2World.isRemote + || ManaItemHandler.requestManaExactForTool(par1ItemStack, par3EntityPlayer, cost, true)) { + if (!par2World.isRemote) + for (CoordsWithBlock block : blocks) + par2World.setBlock(block.posX, block.posY, block.posZ, block.block); + + if (!blocks.isEmpty()) { + for (int i = 0; i < 10; i++) par2World.playSoundAtEntity(par3EntityPlayer, "step.sand", 1F, 0.4F); + for (int i = 0; i < 120; i++) + Botania.proxy.sparkleFX( + par2World, + xCenter - range + range * 2 * Math.random(), + yCenter + 2 + (Math.random() - 0.5) * 2, + zCenter - range + range * 2 * Math.random(), + 0.35F, + 0.2F, + 0.05F, + 2F, + 5); + } + } + } + + @Override + public boolean isFull3D() { + return true; + } + + class CoordsWithBlock extends ChunkCoordinates { + + final Block block; + + public CoordsWithBlock(int x, int y, int z, Block block) { + super(x, y, z); + this.block = block; + } + } + + @Override + public boolean usesMana(ItemStack stack) { + return true; + } + + @Override + public boolean provideBlock( + EntityPlayer player, ItemStack requestor, ItemStack stack, Block block, int meta, boolean doit) { + if (block == Blocks.dirt && meta == 0) + return !doit || ManaItemHandler.requestManaExactForTool(requestor, player, ItemDirtRod.COST, true); + return false; + } + + @Override + public int getBlockCount(EntityPlayer player, ItemStack requestor, ItemStack stack, Block block, int meta) { + if (block == Blocks.dirt && meta == 0) return -1; + return 0; + } + + @Override + public Achievement getAchievementOnCraft(ItemStack stack, EntityPlayer player, IInventory matrix) { + return ModAchievements.terraformRodCraft; + } } diff --git a/src/main/java/vazkii/botania/common/item/rod/ItemTornadoRod.java b/src/main/java/vazkii/botania/common/item/rod/ItemTornadoRod.java index 35df27b53b..d70ed81e15 100644 --- a/src/main/java/vazkii/botania/common/item/rod/ItemTornadoRod.java +++ b/src/main/java/vazkii/botania/common/item/rod/ItemTornadoRod.java @@ -2,16 +2,15 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jun 25, 2014, 4:36:13 PM (GMT)] */ package vazkii.botania.common.item.rod; import java.util.List; - import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.entity.Entity; import net.minecraft.entity.player.EntityPlayer; @@ -38,149 +37,173 @@ public class ItemTornadoRod extends ItemMod implements IManaUsingItem, IAvatarWieldable { - private static final ResourceLocation avatarOverlay = new ResourceLocation(LibResources.MODEL_AVATAR_TORNADO); - - private static final int FLY_TIME = 20; - private static final int FALL_MULTIPLIER = 3; - private static final int MAX_DAMAGE = FLY_TIME * FALL_MULTIPLIER; - private static final int COST = 350; - - private static final String TAG_FLYING = "flying"; - - IIcon iconIdle, iconFlying; - - public ItemTornadoRod() { - setMaxDamage(MAX_DAMAGE); - setUnlocalizedName(LibItemNames.TORNADO_ROD); - setMaxStackSize(1); - } - - @Override - public void onUpdate(ItemStack par1ItemStack, World par2World, Entity par3Entity, int par4, boolean holding) { - if(par3Entity instanceof EntityPlayer) { - EntityPlayer player = (EntityPlayer) par3Entity; - player.getCurrentEquippedItem(); - boolean damaged = par1ItemStack.getItemDamage() > 0; - - if(damaged && !isFlying(par1ItemStack)) - par1ItemStack.setItemDamage(par1ItemStack.getItemDamage() - 1); - - int max = FALL_MULTIPLIER * FLY_TIME; - if(par1ItemStack.getItemDamage() >= max) { - setFlying(par1ItemStack, false); - player.stopUsingItem(); - } else if(isFlying(par1ItemStack)) { - if(holding) { - player.fallDistance = 0F; - player.motionY = IManaProficiencyArmor.Helper.hasProficiency(player) ? 1.6 : 1.25; - - player.worldObj.playSoundAtEntity(player, "botania:airRod", 0.1F, 0.25F); - for(int i = 0; i < 5; i++) - Botania.proxy.wispFX(player.worldObj, player.posX, player.posY, player.posZ, 0.25F, 0.25F, 0.25F, 0.35F + (float) Math.random() * 0.1F, 0.2F * (float) (Math.random() - 0.5), -0.01F * (float) Math.random(), 0.2F * (float) (Math.random() - 0.5)); - } - - par1ItemStack.setItemDamage(Math.min(max, par1ItemStack.getItemDamage() + FALL_MULTIPLIER)); - if(par1ItemStack.getItemDamage() == MAX_DAMAGE) - setFlying(par1ItemStack, false); - } - - if(damaged) - player.fallDistance = 0; - } - } - - @Override - public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer) { - int meta = par1ItemStack.getItemDamage(); - if(meta != 0 || ManaItemHandler.requestManaExactForTool(par1ItemStack, par3EntityPlayer, COST, false)) { - par3EntityPlayer.setItemInUse(par1ItemStack, getMaxItemUseDuration(par1ItemStack)); - if(meta == 0) { - setFlying(par1ItemStack, true); - ManaItemHandler.requestManaExactForTool(par1ItemStack, par3EntityPlayer, COST, true); - } - } - - return par1ItemStack; - } - - @Override - public void onUsingTick(ItemStack stack, EntityPlayer player, int count) { - - } - - @Override - public IIcon getIconIndex(ItemStack par1ItemStack) { - return isFlying(par1ItemStack) ? iconFlying : iconIdle; - } - - @Override - public IIcon getIcon(ItemStack stack, int pass) { - return getIconIndex(stack); - } - - @Override - public EnumAction getItemUseAction(ItemStack par1ItemStack) { - return EnumAction.bow; - } - - @Override - public int getMaxItemUseDuration(ItemStack par1ItemStack) { - return 720000; - } - - @Override - public void registerIcons(IIconRegister par1IconRegister) { - iconIdle = IconHelper.forItem(par1IconRegister, this, 0); - iconFlying = IconHelper.forItem(par1IconRegister, this, 1); - } - - public boolean isFlying(ItemStack stack) { - return ItemNBTHelper.getBoolean(stack, TAG_FLYING, false); - } - - public void setFlying(ItemStack stack, boolean flying) { - ItemNBTHelper.setBoolean(stack, TAG_FLYING, flying); - } - - @Override - public boolean isFull3D() { - return true; - } - - @Override - public boolean usesMana(ItemStack stack) { - return true; - } - - @Override - public void onAvatarUpdate(IAvatarTile tile, ItemStack stack) { - TileEntity te = (TileEntity) tile; - World world = te.getWorldObj(); - if(tile.getCurrentMana() >= COST && tile.isEnabled()) { - int range = 5; - int rangeY = 3; - List players = world.getEntitiesWithinAABB(EntityPlayer.class, AxisAlignedBB.getBoundingBox(te.xCoord + 0.5 - range, te.yCoord + 0.5 - rangeY, te.zCoord + 0.5 - range, te.xCoord + 0.5 + range, te.yCoord + 0.5 + rangeY, te.zCoord + 0.5 + range)); - for(EntityPlayer p : players) { - if(p.motionY > 0.3 && p.motionY < 2 && !p.isSneaking()) { - p.motionY = 2.8; - - for(int i = 0; i < 20; i++) - for(int j = 0; j < 5; j++) - Botania.proxy.wispFX(p.worldObj, p.posX, p.posY + i, p.posZ, 0.25F, 0.25F, 0.25F, 0.35F + (float) Math.random() * 0.1F, 0.2F * (float) (Math.random() - 0.5), -0.01F * (float) Math.random(), 0.2F * (float) (Math.random() - 0.5)); - - if(!world.isRemote) { - p.worldObj.playSoundAtEntity(p, "botania:dash", 1F, 1F); - p.addPotionEffect(new PotionEffect(ModPotions.featherfeet.id, 100, 0)); - tile.recieveMana(-COST); - } - } - } - } - } - - @Override - public ResourceLocation getOverlayResource(IAvatarTile tile, ItemStack stack) { - return avatarOverlay; - } - + private static final ResourceLocation avatarOverlay = new ResourceLocation(LibResources.MODEL_AVATAR_TORNADO); + + private static final int FLY_TIME = 20; + private static final int FALL_MULTIPLIER = 3; + private static final int MAX_DAMAGE = FLY_TIME * FALL_MULTIPLIER; + private static final int COST = 350; + + private static final String TAG_FLYING = "flying"; + + IIcon iconIdle, iconFlying; + + public ItemTornadoRod() { + setMaxDamage(MAX_DAMAGE); + setUnlocalizedName(LibItemNames.TORNADO_ROD); + setMaxStackSize(1); + } + + @Override + public void onUpdate(ItemStack par1ItemStack, World par2World, Entity par3Entity, int par4, boolean holding) { + if (par3Entity instanceof EntityPlayer) { + EntityPlayer player = (EntityPlayer) par3Entity; + player.getCurrentEquippedItem(); + boolean damaged = par1ItemStack.getItemDamage() > 0; + + if (damaged && !isFlying(par1ItemStack)) par1ItemStack.setItemDamage(par1ItemStack.getItemDamage() - 1); + + int max = FALL_MULTIPLIER * FLY_TIME; + if (par1ItemStack.getItemDamage() >= max) { + setFlying(par1ItemStack, false); + player.stopUsingItem(); + } else if (isFlying(par1ItemStack)) { + if (holding) { + player.fallDistance = 0F; + player.motionY = IManaProficiencyArmor.Helper.hasProficiency(player) ? 1.6 : 1.25; + + player.worldObj.playSoundAtEntity(player, "botania:airRod", 0.1F, 0.25F); + for (int i = 0; i < 5; i++) + Botania.proxy.wispFX( + player.worldObj, + player.posX, + player.posY, + player.posZ, + 0.25F, + 0.25F, + 0.25F, + 0.35F + (float) Math.random() * 0.1F, + 0.2F * (float) (Math.random() - 0.5), + -0.01F * (float) Math.random(), + 0.2F * (float) (Math.random() - 0.5)); + } + + par1ItemStack.setItemDamage(Math.min(max, par1ItemStack.getItemDamage() + FALL_MULTIPLIER)); + if (par1ItemStack.getItemDamage() == MAX_DAMAGE) setFlying(par1ItemStack, false); + } + + if (damaged) player.fallDistance = 0; + } + } + + @Override + public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer) { + int meta = par1ItemStack.getItemDamage(); + if (meta != 0 || ManaItemHandler.requestManaExactForTool(par1ItemStack, par3EntityPlayer, COST, false)) { + par3EntityPlayer.setItemInUse(par1ItemStack, getMaxItemUseDuration(par1ItemStack)); + if (meta == 0) { + setFlying(par1ItemStack, true); + ManaItemHandler.requestManaExactForTool(par1ItemStack, par3EntityPlayer, COST, true); + } + } + + return par1ItemStack; + } + + @Override + public void onUsingTick(ItemStack stack, EntityPlayer player, int count) {} + + @Override + public IIcon getIconIndex(ItemStack par1ItemStack) { + return isFlying(par1ItemStack) ? iconFlying : iconIdle; + } + + @Override + public IIcon getIcon(ItemStack stack, int pass) { + return getIconIndex(stack); + } + + @Override + public EnumAction getItemUseAction(ItemStack par1ItemStack) { + return EnumAction.bow; + } + + @Override + public int getMaxItemUseDuration(ItemStack par1ItemStack) { + return 720000; + } + + @Override + public void registerIcons(IIconRegister par1IconRegister) { + iconIdle = IconHelper.forItem(par1IconRegister, this, 0); + iconFlying = IconHelper.forItem(par1IconRegister, this, 1); + } + + public boolean isFlying(ItemStack stack) { + return ItemNBTHelper.getBoolean(stack, TAG_FLYING, false); + } + + public void setFlying(ItemStack stack, boolean flying) { + ItemNBTHelper.setBoolean(stack, TAG_FLYING, flying); + } + + @Override + public boolean isFull3D() { + return true; + } + + @Override + public boolean usesMana(ItemStack stack) { + return true; + } + + @Override + public void onAvatarUpdate(IAvatarTile tile, ItemStack stack) { + TileEntity te = (TileEntity) tile; + World world = te.getWorldObj(); + if (tile.getCurrentMana() >= COST && tile.isEnabled()) { + int range = 5; + int rangeY = 3; + List players = world.getEntitiesWithinAABB( + EntityPlayer.class, + AxisAlignedBB.getBoundingBox( + te.xCoord + 0.5 - range, + te.yCoord + 0.5 - rangeY, + te.zCoord + 0.5 - range, + te.xCoord + 0.5 + range, + te.yCoord + 0.5 + rangeY, + te.zCoord + 0.5 + range)); + for (EntityPlayer p : players) { + if (p.motionY > 0.3 && p.motionY < 2 && !p.isSneaking()) { + p.motionY = 2.8; + + for (int i = 0; i < 20; i++) + for (int j = 0; j < 5; j++) + Botania.proxy.wispFX( + p.worldObj, + p.posX, + p.posY + i, + p.posZ, + 0.25F, + 0.25F, + 0.25F, + 0.35F + (float) Math.random() * 0.1F, + 0.2F * (float) (Math.random() - 0.5), + -0.01F * (float) Math.random(), + 0.2F * (float) (Math.random() - 0.5)); + + if (!world.isRemote) { + p.worldObj.playSoundAtEntity(p, "botania:dash", 1F, 1F); + p.addPotionEffect(new PotionEffect(ModPotions.featherfeet.id, 100, 0)); + tile.recieveMana(-COST); + } + } + } + } + } + + @Override + public ResourceLocation getOverlayResource(IAvatarTile tile, ItemStack stack) { + return avatarOverlay; + } } diff --git a/src/main/java/vazkii/botania/common/item/rod/ItemWaterRod.java b/src/main/java/vazkii/botania/common/item/rod/ItemWaterRod.java index 3d8cf21836..6f3ce8e577 100644 --- a/src/main/java/vazkii/botania/common/item/rod/ItemWaterRod.java +++ b/src/main/java/vazkii/botania/common/item/rod/ItemWaterRod.java @@ -13,39 +13,58 @@ public class ItemWaterRod extends ItemMod implements IManaUsingItem { - public static final int COST = 75; - - public ItemWaterRod() { - super(); - setMaxStackSize(1); - setUnlocalizedName(LibItemNames.WATER_ROD); - } - - @Override - public boolean onItemUse(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, World par3World, int par4, int par5, int par6, int par7, float par8, float par9, float par10) { - if(ManaItemHandler.requestManaExactForTool(par1ItemStack, par2EntityPlayer, COST, false) && !par3World.provider.isHellWorld) { - ForgeDirection dir = ForgeDirection.getOrientation(par7); - - ItemStack stackToPlace = new ItemStack(Blocks.flowing_water); - stackToPlace.tryPlaceItemIntoWorld(par2EntityPlayer, par3World, par4, par5, par6, par7, par8, par9, par10); - - if(stackToPlace.stackSize == 0) { - ManaItemHandler.requestManaExactForTool(par1ItemStack, par2EntityPlayer, COST, true); - for(int i = 0; i < 6; i++) - Botania.proxy.sparkleFX(par3World, par4 + dir.offsetX + Math.random(), par5 + dir.offsetY + Math.random(), par6 + dir.offsetZ + Math.random(), 0.2F, 0.2F, 1F, 1F, 5); - } - } - return true; - } - - @Override - public boolean isFull3D() { - return true; - } - - @Override - public boolean usesMana(ItemStack stack) { - return true; - } + public static final int COST = 75; + public ItemWaterRod() { + super(); + setMaxStackSize(1); + setUnlocalizedName(LibItemNames.WATER_ROD); + } + + @Override + public boolean onItemUse( + ItemStack par1ItemStack, + EntityPlayer par2EntityPlayer, + World par3World, + int par4, + int par5, + int par6, + int par7, + float par8, + float par9, + float par10) { + if (ManaItemHandler.requestManaExactForTool(par1ItemStack, par2EntityPlayer, COST, false) + && !par3World.provider.isHellWorld) { + ForgeDirection dir = ForgeDirection.getOrientation(par7); + + ItemStack stackToPlace = new ItemStack(Blocks.flowing_water); + stackToPlace.tryPlaceItemIntoWorld(par2EntityPlayer, par3World, par4, par5, par6, par7, par8, par9, par10); + + if (stackToPlace.stackSize == 0) { + ManaItemHandler.requestManaExactForTool(par1ItemStack, par2EntityPlayer, COST, true); + for (int i = 0; i < 6; i++) + Botania.proxy.sparkleFX( + par3World, + par4 + dir.offsetX + Math.random(), + par5 + dir.offsetY + Math.random(), + par6 + dir.offsetZ + Math.random(), + 0.2F, + 0.2F, + 1F, + 1F, + 5); + } + } + return true; + } + + @Override + public boolean isFull3D() { + return true; + } + + @Override + public boolean usesMana(ItemStack stack) { + return true; + } } diff --git a/src/main/java/vazkii/botania/common/lexicon/ALexiconEntry.java b/src/main/java/vazkii/botania/common/lexicon/ALexiconEntry.java index 5ffc8b9893..6fc1ff96de 100644 --- a/src/main/java/vazkii/botania/common/lexicon/ALexiconEntry.java +++ b/src/main/java/vazkii/botania/common/lexicon/ALexiconEntry.java @@ -5,9 +5,8 @@ public class ALexiconEntry extends BLexiconEntry { - public ALexiconEntry(String unlocalizedName, LexiconCategory category) { - super(unlocalizedName, category); - setKnowledgeType(BotaniaAPI.elvenKnowledge); - } - + public ALexiconEntry(String unlocalizedName, LexiconCategory category) { + super(unlocalizedName, category); + setKnowledgeType(BotaniaAPI.elvenKnowledge); + } } diff --git a/src/main/java/vazkii/botania/common/lexicon/BLexiconCategory.java b/src/main/java/vazkii/botania/common/lexicon/BLexiconCategory.java index 6e4bf200d5..41bf3aa189 100644 --- a/src/main/java/vazkii/botania/common/lexicon/BLexiconCategory.java +++ b/src/main/java/vazkii/botania/common/lexicon/BLexiconCategory.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Oct 18, 2014, 3:46:10 PM (GMT)] */ package vazkii.botania.common.lexicon; @@ -17,11 +17,9 @@ public class BLexiconCategory extends LexiconCategory { - public BLexiconCategory(String unlocalizedName, int priority) { - super(LibLexicon.CATEGORY_PREFIX + unlocalizedName); - setIcon(new ResourceLocation(LibResources.PREFIX_CATEGORIES + unlocalizedName + ".png")); - setPriority(priority); - } - + public BLexiconCategory(String unlocalizedName, int priority) { + super(LibLexicon.CATEGORY_PREFIX + unlocalizedName); + setIcon(new ResourceLocation(LibResources.PREFIX_CATEGORIES + unlocalizedName + ".png")); + setPriority(priority); + } } - diff --git a/src/main/java/vazkii/botania/common/lexicon/BLexiconEntry.java b/src/main/java/vazkii/botania/common/lexicon/BLexiconEntry.java index ed320fb3b6..620afe1224 100644 --- a/src/main/java/vazkii/botania/common/lexicon/BLexiconEntry.java +++ b/src/main/java/vazkii/botania/common/lexicon/BLexiconEntry.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jan 14, 2014, 9:47:21 PM (GMT)] */ package vazkii.botania.common.lexicon; @@ -18,46 +18,46 @@ public class BLexiconEntry extends LexiconEntry { - public BLexiconEntry(String unlocalizedName, LexiconCategory category) { - super(unlocalizedName, category); - BotaniaAPI.addEntry(this, category); - } - - @Override - public LexiconEntry setLexiconPages(LexiconPage... pages) { - for(LexiconPage page : pages) { - page.unlocalizedName = "botania.page." + getLazyUnlocalizedName() + page.unlocalizedName; - if(page instanceof ITwoNamedPage) { - ITwoNamedPage dou = (ITwoNamedPage) page; - dou.setSecondUnlocalizedName("botania.page." + getLazyUnlocalizedName() + dou.getSecondUnlocalizedName()); - } - } - - return super.setLexiconPages(pages); - } - - @Override - public String getUnlocalizedName() { - return "botania.entry." + super.getUnlocalizedName(); - } - - @Override - public String getTagline() { - return "botania.tagline." + super.getUnlocalizedName(); - } - - public String getLazyUnlocalizedName() { - return super.getUnlocalizedName(); - } - - @Override - public String getWebLink() { - return "http://botaniamod.net/lexicon.php#" + unlocalizedName; - } - - @Override - public int compareTo(LexiconEntry o) { - return o instanceof WLexiconEntry ? 1 : super.compareTo(o); - } - + public BLexiconEntry(String unlocalizedName, LexiconCategory category) { + super(unlocalizedName, category); + BotaniaAPI.addEntry(this, category); + } + + @Override + public LexiconEntry setLexiconPages(LexiconPage... pages) { + for (LexiconPage page : pages) { + page.unlocalizedName = "botania.page." + getLazyUnlocalizedName() + page.unlocalizedName; + if (page instanceof ITwoNamedPage) { + ITwoNamedPage dou = (ITwoNamedPage) page; + dou.setSecondUnlocalizedName( + "botania.page." + getLazyUnlocalizedName() + dou.getSecondUnlocalizedName()); + } + } + + return super.setLexiconPages(pages); + } + + @Override + public String getUnlocalizedName() { + return "botania.entry." + super.getUnlocalizedName(); + } + + @Override + public String getTagline() { + return "botania.tagline." + super.getUnlocalizedName(); + } + + public String getLazyUnlocalizedName() { + return super.getUnlocalizedName(); + } + + @Override + public String getWebLink() { + return "http://botaniamod.net/lexicon.php#" + unlocalizedName; + } + + @Override + public int compareTo(LexiconEntry o) { + return o instanceof WLexiconEntry ? 1 : super.compareTo(o); + } } diff --git a/src/main/java/vazkii/botania/common/lexicon/CLexiconEntry.java b/src/main/java/vazkii/botania/common/lexicon/CLexiconEntry.java index 6a200cbffb..0783bec646 100644 --- a/src/main/java/vazkii/botania/common/lexicon/CLexiconEntry.java +++ b/src/main/java/vazkii/botania/common/lexicon/CLexiconEntry.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jun 24, 2015, 5:43:11 PM (GMT)] */ package vazkii.botania.common.lexicon; @@ -16,16 +16,15 @@ public class CLexiconEntry extends BLexiconEntry implements IAddonEntry { - String mod; + String mod; - public CLexiconEntry(String unlocalizedName, LexiconCategory category, String mod) { - super(unlocalizedName, category); - this.mod = mod; - } - - @Override - public String getSubtitle() { - return "[" + LibMisc.MOD_NAME + " x " + mod + "]"; - } + public CLexiconEntry(String unlocalizedName, LexiconCategory category, String mod) { + super(unlocalizedName, category); + this.mod = mod; + } + @Override + public String getSubtitle() { + return "[" + LibMisc.MOD_NAME + " x " + mod + "]"; + } } diff --git a/src/main/java/vazkii/botania/common/lexicon/DLexiconEntry.java b/src/main/java/vazkii/botania/common/lexicon/DLexiconEntry.java index 00a0fc499a..d6c7ed6735 100644 --- a/src/main/java/vazkii/botania/common/lexicon/DLexiconEntry.java +++ b/src/main/java/vazkii/botania/common/lexicon/DLexiconEntry.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [16/12/2015, 20:38:33 (GMT)] */ package vazkii.botania.common.lexicon; @@ -15,13 +15,12 @@ public class DLexiconEntry extends BLexiconEntry { - public DLexiconEntry(String unlocalizedName, LexiconCategory category) { - super(unlocalizedName, category); - } - - @Override - public boolean isVisible() { - return !PersistentVariableHelper.dog; - } + public DLexiconEntry(String unlocalizedName, LexiconCategory category) { + super(unlocalizedName, category); + } + @Override + public boolean isVisible() { + return !PersistentVariableHelper.dog; + } } diff --git a/src/main/java/vazkii/botania/common/lexicon/HLexiconEntry.java b/src/main/java/vazkii/botania/common/lexicon/HLexiconEntry.java index 099956394e..5746740ac0 100644 --- a/src/main/java/vazkii/botania/common/lexicon/HLexiconEntry.java +++ b/src/main/java/vazkii/botania/common/lexicon/HLexiconEntry.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Aug 27, 2015, 7:34:43 PM (GMT)] */ package vazkii.botania.common.lexicon; @@ -14,13 +14,12 @@ public class HLexiconEntry extends ALexiconEntry { - public HLexiconEntry(String unlocalizedName, LexiconCategory category) { - super(unlocalizedName, category); - } - - @Override - public String getWebLink() { - return "http://heads.freshcoal.com/usernames.php"; - } + public HLexiconEntry(String unlocalizedName, LexiconCategory category) { + super(unlocalizedName, category); + } + @Override + public String getWebLink() { + return "http://heads.freshcoal.com/usernames.php"; + } } diff --git a/src/main/java/vazkii/botania/common/lexicon/LexiconData.java b/src/main/java/vazkii/botania/common/lexicon/LexiconData.java index 2c291d353e..87f13f1a1a 100644 --- a/src/main/java/vazkii/botania/common/lexicon/LexiconData.java +++ b/src/main/java/vazkii/botania/common/lexicon/LexiconData.java @@ -2,18 +2,16 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jan 14, 2014, 9:12:15 PM (GMT)] */ package vazkii.botania.common.lexicon; import java.util.ArrayList; import java.util.List; - -import baubles.common.Config; import net.minecraft.init.Blocks; import net.minecraft.init.Items; import net.minecraft.item.ItemStack; @@ -57,1438 +55,1802 @@ public final class LexiconData { - public static LexiconEntry welcome; - public static LexiconEntry tutorial; - - public static LexiconEntry flowers; - public static LexiconEntry apothecary; - public static LexiconEntry lexicon; - public static LexiconEntry wand; - public static LexiconEntry pureDaisy; - public static LexiconEntry runicAltar; - public static LexiconEntry terrasteel; - public static LexiconEntry blackLotus; - public static LexiconEntry flowerBag; - public static LexiconEntry gardenOfGlass; - - public static LexiconEntry manaIntro; - public static LexiconEntry spreader; - public static LexiconEntry pool; - public static LexiconEntry lenses; - public static LexiconEntry distributor; - public static LexiconEntry manaVoid; - public static LexiconEntry manaTablet; - public static LexiconEntry manaMirror; - public static LexiconEntry manaDetector; - public static LexiconEntry redstoneSpreader; - public static LexiconEntry manastar; - public static LexiconEntry dreamwoodSpreader; - public static LexiconEntry elvenLenses; - public static LexiconEntry sparks; - public static LexiconEntry sparkUpgrades; - public static LexiconEntry rfGenerator; - public static LexiconEntry prism; - public static LexiconEntry poolCart; - public static LexiconEntry sparkChanger; - public static LexiconEntry bellows; - - public static LexiconEntry functionalIntro; - public static LexiconEntry flowerShrinking; - public static LexiconEntry flowerSpeed; - public static LexiconEntry jadedAmaranthus; - public static LexiconEntry bellethorne; - public static LexiconEntry dreadthorne; - public static LexiconEntry heiseiDream; - public static LexiconEntry tigerseye; - public static LexiconEntry orechid; - public static LexiconEntry orechidIgnem; - public static LexiconEntry fallenKanade; - public static LexiconEntry exoflame; - public static LexiconEntry agricarnation; - public static LexiconEntry hopperhock; - public static LexiconEntry tangleberrie; - public static LexiconEntry jiyuulia; - public static LexiconEntry rannuncarpus; - public static LexiconEntry hyacidus; - public static LexiconEntry pollidisiac; - public static LexiconEntry clayconia; - public static LexiconEntry loonium; - public static LexiconEntry daffomill; - public static LexiconEntry vinculotus; - public static LexiconEntry spectranthemum; - public static LexiconEntry medumone; - public static LexiconEntry marimorphosis; - public static LexiconEntry bubbell; - public static LexiconEntry solegnolia; - - public static LexiconEntry generatingIntro; - public static LexiconEntry passiveGen; - public static LexiconEntry primusLoci; - public static LexiconEntry daybloom; - public static LexiconEntry nightshade; - public static LexiconEntry endoflame; - public static LexiconEntry hydroangeas; - public static LexiconEntry thermalily; - public static LexiconEntry arcaneRose; - public static LexiconEntry munchdew; - public static LexiconEntry entropinnyum; - public static LexiconEntry kekimurus; - public static LexiconEntry gourmaryllis; - public static LexiconEntry narslimmus; - public static LexiconEntry spectrolus; - public static LexiconEntry rafflowsia; - public static LexiconEntry dandelifeon; - - public static LexiconEntry pylon; - public static LexiconEntry manaEnchanting; - public static LexiconEntry turntable; - public static LexiconEntry alchemy; - public static LexiconEntry openCrate; - public static LexiconEntry forestEye; - public static LexiconEntry forestDrum; - public static LexiconEntry platform; - public static LexiconEntry conjurationCatalyst; - public static LexiconEntry spectralPlatform; - public static LexiconEntry gatherDrum; - public static LexiconEntry craftCrate; - public static LexiconEntry brewery; - public static LexiconEntry flasks; - public static LexiconEntry complexBrews; - public static LexiconEntry incense; - public static LexiconEntry hourglass; - public static LexiconEntry ghostRail; - public static LexiconEntry canopyDrum; - public static LexiconEntry cocoon; - public static LexiconEntry manaBomb; - public static LexiconEntry teruTeruBozu; - public static LexiconEntry avatar; - public static LexiconEntry felPumpkin; - - public static LexiconEntry manaBlaster; - public static LexiconEntry grassSeeds; - public static LexiconEntry dirtRod; - public static LexiconEntry terraformRod; - public static LexiconEntry manasteelGear; - public static LexiconEntry terrasteelArmor; - public static LexiconEntry grassHorn; - public static LexiconEntry terraBlade; - public static LexiconEntry terraPick; - public static LexiconEntry waterRod; - public static LexiconEntry elfGear; - public static LexiconEntry openBucket; - public static LexiconEntry rainbowRod; - public static LexiconEntry tornadoRod; - public static LexiconEntry fireRod; - public static LexiconEntry vineBall; - public static LexiconEntry laputaShard; - public static LexiconEntry virus; - public static LexiconEntry skyDirtRod; - public static LexiconEntry glassPick; - public static LexiconEntry diviningRod; - public static LexiconEntry gravityRod; - public static LexiconEntry regenIvy; - public static LexiconEntry missileRod; - public static LexiconEntry craftingHalo; - public static LexiconEntry clip; - public static LexiconEntry cobbleRod; - public static LexiconEntry smeltRod; - public static LexiconEntry worldSeed; - public static LexiconEntry spellCloth; - public static LexiconEntry thornChakram; - public static LexiconEntry fireChakram; - public static LexiconEntry overgrowthSeed; - public static LexiconEntry livingwoodBow; - public static LexiconEntry crystalBow; - public static LexiconEntry temperanceStone; - public static LexiconEntry terraAxe; - public static LexiconEntry obedienceStick; - public static LexiconEntry slimeBottle; - public static LexiconEntry exchangeRod; - public static LexiconEntry manaweave; - public static LexiconEntry autocraftingHalo; - public static LexiconEntry sextant; - - public static LexiconEntry enderAir; - public static LexiconEntry enderEyeBlock; - public static LexiconEntry pistonRelay; - public static LexiconEntry enderHand; - public static LexiconEntry enderDagger; - public static LexiconEntry spawnerClaw; - public static LexiconEntry redString; - public static LexiconEntry flightTiara; - public static LexiconEntry corporea; - public static LexiconEntry corporeaIndex; - public static LexiconEntry corporeaFunnel; - public static LexiconEntry corporeaInterceptor; - public static LexiconEntry endStoneDecor; - public static LexiconEntry spawnerMover; - public static LexiconEntry keepIvy; - public static LexiconEntry blackHoleTalisman; - public static LexiconEntry corporeaCrystalCube; - public static LexiconEntry luminizerTransport; - public static LexiconEntry starSword; - public static LexiconEntry thunderSword; - public static LexiconEntry corporeaRetainer; - - public static LexiconEntry baublesIntro; - public static LexiconEntry cosmeticBaubles; - public static LexiconEntry tinyPlanet; - public static LexiconEntry manaRing; - public static LexiconEntry auraRing; - public static LexiconEntry travelBelt; - public static LexiconEntry knockbacklBelt; - public static LexiconEntry icePendant; - public static LexiconEntry lavaPendant; - public static LexiconEntry goldLaurel; - public static LexiconEntry waterRing; - public static LexiconEntry miningRing; - public static LexiconEntry magnetRing; - public static LexiconEntry divaCharm; - public static LexiconEntry pixieRing; - public static LexiconEntry superTravelBelt; - public static LexiconEntry reachRing; - public static LexiconEntry itemFinder; - public static LexiconEntry superLavaPendant; - public static LexiconEntry bloodPendant; - public static LexiconEntry judgementCloaks; - public static LexiconEntry monocle; - public static LexiconEntry swapRing; - public static LexiconEntry speedUpBelt; - public static LexiconEntry baubleBox; - - public static LexiconEntry alfhomancyIntro; - public static LexiconEntry elvenMessage; - public static LexiconEntry elvenResources; - public static LexiconEntry gaiaRitual; - public static LexiconEntry gaiaRitualHardmode; - public static LexiconEntry elvenLore; - public static LexiconEntry relics; - public static LexiconEntry relicInfo; - public static LexiconEntry infiniteFruit; - public static LexiconEntry kingKey; - public static LexiconEntry flugelEye; - public static LexiconEntry thorRing; - public static LexiconEntry lokiRing; - public static LexiconEntry odinRing; - - public static LexiconEntry unstableBlocks; - public static LexiconEntry decorativeBlocks; - public static LexiconEntry dispenserTweaks; - public static LexiconEntry shinyFlowers; - public static LexiconEntry prismarine; - public static LexiconEntry shedding; - public static LexiconEntry tinyPotato; - public static LexiconEntry headCreating; - public static LexiconEntry azulejo; - public static LexiconEntry starfield; - public static LexiconEntry dirtPath; - public static LexiconEntry mushrooms; - public static LexiconEntry phantomInk; - public static LexiconEntry stoneAlchemy; - public static LexiconEntry blazeBlock; - public static LexiconEntry challenges; - public static LexiconEntry cacophonium; - public static LexiconEntry pavement; - public static LexiconEntry preventingDecay; - - public static LexiconEntry tcIntegration; - public static LexiconEntry bcIntegration; - public static LexiconEntry banners; - - public static void preInit() { - BotaniaAPI.addCategory(BotaniaAPI.categoryBasics = new BLexiconCategory(LibLexicon.CATEGORY_BASICS, 9)); - BotaniaAPI.addCategory(BotaniaAPI.categoryMana = new BLexiconCategory(LibLexicon.CATEGORY_MANA, 5)); - BotaniaAPI.addCategory( - BotaniaAPI.categoryGenerationFlowers = new BLexiconCategory(LibLexicon.CATEGORY_GENERATION_FLOWERS, 5)); - BotaniaAPI.addCategory( - BotaniaAPI.categoryFunctionalFlowers = new BLexiconCategory(LibLexicon.CATEGORY_FUNCTIONAL_FLOWERS, 5)); - BotaniaAPI.addCategory(BotaniaAPI.categoryDevices = new BLexiconCategory(LibLexicon.CATEGORY_DEVICES, 5)); - BotaniaAPI.addCategory(BotaniaAPI.categoryTools = new BLexiconCategory(LibLexicon.CATEGORY_TOOLS, 5)); - BotaniaAPI.addCategory(BotaniaAPI.categoryBaubles = new BLexiconCategory(LibLexicon.CATEGORY_BAUBLES, 5)); - BotaniaAPI.addCategory(BotaniaAPI.categoryEnder = new BLexiconCategory(LibLexicon.CATEGORY_ENDER, 5)); - BotaniaAPI.addCategory(BotaniaAPI.categoryAlfhomancy = new BLexiconCategory(LibLexicon.CATEGORY_ALFHOMANCY, 5)); - BotaniaAPI.addCategory(BotaniaAPI.categoryMisc = new BLexiconCategory(LibLexicon.CATEGORY_MISC, 0)); - } - - public static void init() { - LexiconCategory categoryBasics = BotaniaAPI.categoryBasics; - LexiconCategory categoryMana = BotaniaAPI.categoryMana; - LexiconCategory categoryGenerationFlowers = BotaniaAPI.categoryGenerationFlowers; - LexiconCategory categoryFunctionalFlowers = BotaniaAPI.categoryFunctionalFlowers; - LexiconCategory categoryDevices = BotaniaAPI.categoryDevices; - LexiconCategory categoryTools = BotaniaAPI.categoryTools; - LexiconCategory categoryBaubles = BotaniaAPI.categoryBaubles; - LexiconCategory categoryEnder = BotaniaAPI.categoryEnder; - LexiconCategory categoryAlfhomancy = BotaniaAPI.categoryAlfhomancy; - LexiconCategory categoryMisc = BotaniaAPI.categoryMisc; - - // BASICS ENTRIES - welcome = new WLexiconEntry(); - tutorial = new TLexiconEntry(); - - flowers = new BLexiconEntry(LibLexicon.BASICS_FLOWERS, categoryBasics); - flowers.setPriority() - .setLexiconPages(new PageText("0"), new PageImage("1", LibResources.ENTRY_FLOWERS), new PageText("2"), - new PageCraftingRecipe("3", ModCraftingRecipes.recipesPetals), - new PageCraftingRecipe("4", ModCraftingRecipes.recipePestleAndMortar), - new PageCraftingRecipe("5", ModCraftingRecipes.recipesDyes), new PageText("6"), - new PageCraftingRecipe("7", ModCraftingRecipes.recipeFertilizerPowder), - new PageCraftingRecipe("8", ModCraftingRecipes.recipeFerilizerDye), new PageText("10"), - new PageText("12"), new PageCraftingRecipe("11", ModCraftingRecipes.recipesPetalsDouble), - new PageCraftingRecipe("9", ModCraftingRecipes.recipesPetalBlocks)) - .setIcon(new ItemStack(ModBlocks.flower, 1, 6)); - - apothecary = new BLexiconEntry(LibLexicon.BASICS_APOTHECARY, categoryBasics); - apothecary.setPriority().setLexiconPages(new PageText("0"), new PageImage("1", LibResources.ENTRY_APOTHECARY), - new PageText("2"), new PageText("3"), new PageText("4"), new PageText("7"), new PageText("6"), - new PageCraftingRecipe("5", ModCraftingRecipes.recipesApothecary)); - - lexicon = new BLexiconEntry(LibLexicon.BASICS_LEXICON, categoryBasics); - lexicon.setPriority().setLexiconPages(new PageText("0"), new PageText("3"), - new PageCraftingRecipe("1", ModCraftingRecipes.recipeLexicon), new PageText("2")); - - wand = new BLexiconEntry(LibLexicon.BASICS_WAND, categoryBasics); - wand.setPriority().setLexiconPages(new PageText("0"), new PageText("1"), new PageText("2"), - new PageCraftingRecipe("3", ModCraftingRecipes.recipesTwigWand)); - - pureDaisy = new BLexiconEntry(LibLexicon.BASICS_PURE_DAISY, categoryBasics); - pureDaisy.setPriority() - .setLexiconPages(new PageText("0"), new PageImage("1", LibResources.ENTRY_PURE_DAISY), - new PageCraftingRecipe("2", ModCraftingRecipes.recipeLivingwoodTwig), new PageText("4"), - new PagePetalRecipe("3", ModPetalRecipes.pureDaisyRecipe)) - .setIcon(ItemBlockSpecialFlower.ofType(LibBlockNames.SUBTILE_PUREDAISY)); - pureDaisy.addExtraDisplayedRecipe(new ItemStack(ModBlocks.livingwood)); - pureDaisy.addExtraDisplayedRecipe(new ItemStack(ModBlocks.livingrock)); - LexiconRecipeMappings.map(new ItemStack(ModBlocks.livingwood), pureDaisy, 1); - LexiconRecipeMappings.map(new ItemStack(ModBlocks.livingrock), pureDaisy, 1); - - runicAltar = new BLexiconEntry(LibLexicon.BASICS_RUNE_ALTAR, categoryBasics); - runicAltar.setPriority().setLexiconPages(new PageText("21"), new PageText("0"), new PageText("1"), - new PageCraftingRecipe("2", ModCraftingRecipes.recipesRuneAltar), new PageText("3"), new PageText("20"), - new PageText("22"), new PageRuneRecipe("4", ModRuneRecipes.recipeWaterRune), - new PageRuneRecipe("5", ModRuneRecipes.recipesEarthRune), - new PageRuneRecipe("6", ModRuneRecipes.recipesAirRune), - new PageRuneRecipe("7", ModRuneRecipes.recipeFireRune), - new PageRuneRecipe("8", ModRuneRecipes.recipeSpringRune), - new PageRuneRecipe("9", ModRuneRecipes.recipeSummerRune), - new PageRuneRecipe("10", ModRuneRecipes.recipeAutumnRune), - new PageRuneRecipe("11", ModRuneRecipes.recipesWinterRune), - new PageRuneRecipe("12", ModRuneRecipes.recipeManaRune), - new PageRuneRecipe("13", ModRuneRecipes.recipeLustRune), - new PageRuneRecipe("14", ModRuneRecipes.recipeGluttonyRune), - new PageRuneRecipe("15", ModRuneRecipes.recipeGreedRune), - new PageRuneRecipe("16", ModRuneRecipes.recipeSlothRune), - new PageRuneRecipe("17", ModRuneRecipes.recipeWrathRune), - new PageRuneRecipe("18", ModRuneRecipes.recipeEnvyRune), - new PageRuneRecipe("19", ModRuneRecipes.recipePrideRune)); - - terrasteel = new BLexiconEntry(LibLexicon.BASICS_TERRASTEEL, categoryBasics); - terrasteel.setLexiconPages(new PageText("0"), new PageCraftingRecipe("1", ModCraftingRecipes.recipeTerraPlate), - new PageText("2"), new PageMultiblock("4", ModMultiblocks.terrasteelPlate), new PageTerrasteel("3")) - .setIcon(new ItemStack(ModItems.manaResource, 1, 4)); - - blackLotus = new BLexiconEntry(LibLexicon.BASICS_BLACK_LOTUS, categoryBasics); - blackLotus.setLexiconPages(new PageText("0")).setIcon(new ItemStack(ModItems.blackLotus)); - blackLotus.addExtraDisplayedRecipe(new ItemStack(ModItems.blackLotus)); - - flowerBag = new BLexiconEntry(LibLexicon.BASICS_FLOWER_BAG, categoryBasics); - flowerBag.setLexiconPages(new PageText("0"), new PageText("2"), - new PageCraftingRecipe("1", ModCraftingRecipes.recipeFlowerBag)); - - if (Botania.gardenOfGlassLoaded) { - gardenOfGlass = new BLexiconEntry(LibLexicon.BASICS_GARDEN_OF_GLASS, categoryBasics); - gardenOfGlass.setLexiconPages(new PageText("0"), new PageText("1"), new PageText("2"), - new PageCraftingRecipe("3", ModCraftingRecipes.recipeRootToSapling), - new PageCraftingRecipe("4", ModCraftingRecipes.recipeRootToFertilizer), - new PageCraftingRecipe("5", ModCraftingRecipes.recipePebbleCobblestone), new PageText("6"), - new PageManaInfusionRecipe("7", ModManaInfusionRecipes.sugarCaneRecipe), - new PageCraftingRecipe("8", ModCraftingRecipes.recipeMagmaToSlimeball), new PageText("9"), - new PageText("11"), new PageCraftingRecipe("12", ModCraftingRecipes.recipeEndPortal)); - gardenOfGlass.setPriority().setIcon(new ItemStack(ModItems.manaResource, 1, 20)); - } - - if (Botania.thaumcraftLoaded) - new CLexiconEntry("wrap", categoryBasics, "Thaumcraft").setLexiconPages(new PageText("0")); // lel - - // MANA ENTRIES - manaIntro = new BLexiconEntry(LibLexicon.MANA_INTRO, categoryMana); - manaIntro.setPriority().setLexiconPages(new PageText("0"), new PageText("1"), new PageText("2")); - - spreader = new BLexiconEntry(LibLexicon.MANA_SPREADER, categoryMana); - spreader.setPriority().setLexiconPages(new PageText("0"), new PageImage("1", LibResources.ENTRY_SPREADER), - new PageText("2"), new PageText("3"), new PageText("4"), new PageText("11"), - new PageCraftingRecipe("5", ModCraftingRecipes.recipesSpreader), new PageText("10")); - - pool = new BLexiconEntry(LibLexicon.MANA_POOL, categoryMana); - pool.setPriority() - .setLexiconPages(new PageText("0"), new PageText("9"), - new PageCraftingRecipe("1", ModCraftingRecipes.recipePool), - new PageCraftingRecipe("10", ModCraftingRecipes.recipePoolDiluted), new PageText("14"), - new PageText("2"), new PageText("8"), - new PageManaInfusionRecipe("3", ModManaInfusionRecipes.manasteelRecipes), - new PageManaInfusionRecipe("4", ModManaInfusionRecipes.manaPearlRecipe), - new PageManaInfusionRecipe("5", ModManaInfusionRecipes.manaDiamondRecipes), - new PageManaInfusionRecipe("6", ModManaInfusionRecipes.manaPowderRecipes), - new PageManaInfusionRecipe("11", ModManaInfusionRecipes.managlassRecipe), - new PageManaInfusionRecipe("12", ModManaInfusionRecipes.manaStringRecipe), - new PageCraftingRecipe("13", ModCraftingRecipes.recipeCobweb), - new PageManaInfusionRecipe("7", ModManaInfusionRecipes.manaCookieRecipe)) - .setIcon(new ItemStack(ModBlocks.pool)); - - sparks = new BLexiconEntry(LibLexicon.MANA_SPARKS, categoryMana); - sparks.setPriority().setLexiconPages(new PageText("0"), new PageText("1"), new PageText("3"), - new PageCraftingRecipe("2", ModCraftingRecipes.recipesSpark)); - - sparkUpgrades = new ALexiconEntry(LibLexicon.MANA_SPARK_UPGRADES, categoryMana); - sparkUpgrades.setLexiconPages(new PageText("0"), new PageText("1"), new PageText("2"), new PageText("3"), - new PageText("4"), new PageCraftingRecipe("5", ModCraftingRecipes.recipesSparkUpgrades)); - - if (ConfigHandler.fluxfieldEnabled) { - rfGenerator = new BLexiconEntry(LibLexicon.MANA_RF_GENERATOR, categoryMana); - rfGenerator.setLexiconPages(new PageText("0"), - new PageCraftingRecipe("1", ModCraftingRecipes.recipeRFGenerator)); - } - - lenses = new BLexiconEntry(LibLexicon.MANA_LENSES, categoryMana); - lenses.setLexiconPages(new PageText("0"), new PageCraftingRecipe("1", ModCraftingRecipes.recipesManaLens), - new PageText("4"), new PageText("5"), new PageText("6"), - new PageCraftingRecipe("7", ModCraftingRecipes.recipeLensVelocity), new PageText("8"), - new PageCraftingRecipe("9", ModCraftingRecipes.recipeLensPotency), new PageText("10"), - new PageCraftingRecipe("11", ModCraftingRecipes.recipeLensResistance), new PageText("12"), - new PageCraftingRecipe("13", ModCraftingRecipes.recipeLensEfficiency), new PageText("14"), - new PageCraftingRecipe("15", ModCraftingRecipes.recipeLensBounce), new PageText("16"), - new PageCraftingRecipe("17", ModCraftingRecipes.recipeLensGravity), new PageText("18"), - new PageCraftingRecipe("19", ModCraftingRecipes.recipeLensBore), new PageText("20"), - new PageCraftingRecipe("21", ModCraftingRecipes.recipeLensDamaging), new PageText("22"), - new PageCraftingRecipe("23", ModCraftingRecipes.recipeLensPhantom), new PageText("24"), - new PageCraftingRecipe("25", ModCraftingRecipes.recipeLensMagnet), new PageText("26"), - new PageCraftingRecipe("27", ModCraftingRecipes.recipeLensExplosive), new PageText("28"), - new PageCraftingRecipe("29", ModCraftingRecipes.recipeLensInfluence), new PageText("30"), - new PageCraftingRecipe("31", ModCraftingRecipes.recipeLensWeight), new PageText("32"), - new PageCraftingRecipe("33", ModCraftingRecipes.recipeLensFire), new PageText("34"), - new PageCraftingRecipe("35", ModCraftingRecipes.recipeLensPiston), new PageText("36"), - new PageCraftingRecipe("37", ModCraftingRecipes.recipesLensFlash)); - - distributor = new BLexiconEntry(LibLexicon.MANA_DISTRIBUTOR, categoryMana); - distributor.setLexiconPages(new PageText("0"), - new PageCraftingRecipe("1", ModCraftingRecipes.recipeDistributor)); - - manaVoid = new BLexiconEntry(LibLexicon.MANA_VOID, categoryMana); - manaVoid.setLexiconPages(new PageText("0"), new PageCraftingRecipe("1", ModCraftingRecipes.recipeManaVoid)); - - manaTablet = new BLexiconEntry(LibLexicon.MANA_TABLET, categoryMana); - manaTablet.setPriority().setLexiconPages(new PageText("0"), new PageText("1"), - new PageCraftingRecipe("2", ModCraftingRecipes.recipesManaTablet)); - - manaMirror = new BLexiconEntry(LibLexicon.MANA_MIRROR, categoryMana); - manaMirror.setLexiconPages(new PageText("0"), new PageCraftingRecipe("1", ModCraftingRecipes.recipeManaMirror)); - - manaDetector = new BLexiconEntry(LibLexicon.MANA_DETECTOR, categoryMana); - manaDetector.setLexiconPages(new PageText("0"), - new PageCraftingRecipe("1", ModCraftingRecipes.recipeManaDetector)); - - redstoneSpreader = new BLexiconEntry(LibLexicon.MANA_REDSTONE_SPREADER, categoryMana); - redstoneSpreader.setPriority().setLexiconPages(new PageText("0"), - new PageCraftingRecipe("1", ModCraftingRecipes.recipeRedstoneSpreader)); - - manastar = new BLexiconEntry(LibLexicon.MANA_MANASTAR, categoryMana); - manastar.setPriority().setLexiconPages(new PageText("0"), - new PagePetalRecipe("1", ModPetalRecipes.manastarRecipe)); - - dreamwoodSpreader = new ALexiconEntry(LibLexicon.MANA_DREAMWOOD_SPREADER, categoryMana); - dreamwoodSpreader.setLexiconPages(new PageText("0"), - new PageCraftingRecipe("1", ModCraftingRecipes.recipesDreamwoodSpreader), new PageText("2"), - new PageCraftingRecipe("3", ModCraftingRecipes.recipeUltraSpreader)); - - elvenLenses = new ALexiconEntry(LibLexicon.MANA_ELVEN_LENSES, categoryMana); - elvenLenses.setLexiconPages(new PageText("0"), new PageText("1"), - new PageCraftingRecipe("2", ModCraftingRecipes.recipeLensPaint), new PageText("3"), - new PageCraftingRecipe("4", ModCraftingRecipes.recipeLensWarp), new PageText("5"), - new PageCraftingRecipe("6", ModCraftingRecipes.recipeLensRedirect), new PageText("7"), - new PageCraftingRecipe("8", ModCraftingRecipes.recipeLensFirework), new PageText("9"), - new PageCraftingRecipe("10", ModCraftingRecipes.recipeLensFlare)); - - prism = new ALexiconEntry(LibLexicon.MANA_PRISM, categoryMana); - prism.setLexiconPages(new PageText("0"), new PageText("1"), new PageText("2"), - new PageCraftingRecipe("3", ModCraftingRecipes.recipePrism)); - - poolCart = new BLexiconEntry(LibLexicon.MANA_POOL_CART, categoryMana); - poolCart.setLexiconPages(new PageText("0"), new PageText("1"), new PageText("2"), - new PageCraftingRecipe("3", ModCraftingRecipes.recipePoolCart), - new PageCraftingRecipe("4", ModCraftingRecipes.recipePump)); - - sparkChanger = new ALexiconEntry(LibLexicon.MANA_SPARK_CHANGER, categoryMana); - sparkChanger.setLexiconPages(new PageText("0"), new PageText("1"), - new PageCraftingRecipe("2", ModCraftingRecipes.recipeSparkChanger)); - - bellows = new BLexiconEntry(LibLexicon.MANA_BELLOWS, categoryMana); - bellows.setLexiconPages(new PageText("0"), new PageText("1"), - new PageCraftingRecipe("2", ModCraftingRecipes.recipeBellows)); - - // FUNCTIONAL FLOWERS ENTRIES - functionalIntro = new BLexiconEntry(LibLexicon.FFLOWER_INTRO, categoryFunctionalFlowers); - functionalIntro - .setPriority().setLexiconPages(new PageText("0"), new PageText("1"), new PageText("2"), - new PageText("3"), new PageCraftingRecipe("4", ModCraftingRecipes.recipeRedstoneRoot)) - .setIcon(null); - ; - - flowerShrinking = new BLexiconEntry(LibLexicon.FFLOWER_SHRINKING, categoryFunctionalFlowers); - flowerShrinking.setPriority() - .setLexiconPages(new PageText("0"), new PageManaInfusionRecipe("1", BotaniaAPI.miniFlowerRecipes)) - .setIcon(ItemBlockSpecialFlower.ofType(LibBlockNames.SUBTILE_BELLETHORN + "Chibi")); - - flowerSpeed = new BLexiconEntry(LibLexicon.FFLOWER_SPEED, categoryFunctionalFlowers); - flowerSpeed.setPriority().setLexiconPages(new PageText("0"), new PageText("1")); - flowerSpeed.setIcon(new ItemStack(Blocks.dirt, 1, 2)); - - jadedAmaranthus = new BLexiconEntry(LibLexicon.FFLOWER_JADED_AMARANTHUS, categoryFunctionalFlowers); - jadedAmaranthus.setLexiconPages(new PageText("0"), - new PagePetalRecipe("1", ModPetalRecipes.jadedAmaranthusRecipe), new PageText("2")); - - bellethorne = new BLexiconEntry(LibLexicon.FFLOWER_BELLETHORNE, categoryFunctionalFlowers); - bellethorne.setLexiconPages(new PageText("0"), new PagePetalRecipe("1", ModPetalRecipes.bellethorneRecipe)); - - dreadthorne = new BLexiconEntry(LibLexicon.FFLOWER_DREADTHORNE, categoryFunctionalFlowers); - dreadthorne.setLexiconPages(new PageText("0"), new PagePetalRecipe("1", ModPetalRecipes.dreadthorneRecipe)); - - heiseiDream = new ALexiconEntry(LibLexicon.FFLOWER_HEISEI_DREAM, categoryFunctionalFlowers); - heiseiDream.setLexiconPages(new PageText("0"), new PagePetalRecipe("1", ModPetalRecipes.heiseiDreamRecipe)); - - tigerseye = new BLexiconEntry(LibLexicon.FFLOWER_TIGERSEYE, categoryFunctionalFlowers); - tigerseye.setLexiconPages(new PageText("0"), new PagePetalRecipe("1", ModPetalRecipes.tigerseyeRecipe)); - - orechid = Botania.gardenOfGlassLoaded ? new BLexiconEntry(LibLexicon.FFLOWER_ORECHID, categoryFunctionalFlowers) - : new ALexiconEntry(LibLexicon.FFLOWER_ORECHID, categoryFunctionalFlowers); - orechid.setLexiconPages(new PageText("0"), new PagePetalRecipe("1", ModPetalRecipes.orechidRecipe)); - if (Botania.gardenOfGlassLoaded) - orechid.setPriority(); - - orechidIgnem = new ALexiconEntry(LibLexicon.FFLOWER_ORECHID_IGNEM, categoryFunctionalFlowers); - orechidIgnem.setLexiconPages(new PageText("0"), new PagePetalRecipe("1", ModPetalRecipes.orechidIgnemRecipe)); - - if (ConfigHandler.fallenKanadeEnabled) { - fallenKanade = new BLexiconEntry(LibLexicon.FFLOWER_FALLEN_KANADE, categoryFunctionalFlowers); - fallenKanade.setLexiconPages(new PageText(Botania.bloodMagicLoaded ? "0a" : "0"), - new PagePetalRecipe("1", ModPetalRecipes.fallenKanadeRecipe)); - } - - exoflame = new BLexiconEntry(LibLexicon.FFLOWER_EXOFLAME, categoryFunctionalFlowers); - exoflame.setLexiconPages(new PageText("0"), new PagePetalRecipe("1", ModPetalRecipes.exoflameRecipe)); - - agricarnation = new BLexiconEntry(LibLexicon.FFLOWER_AGRICARNATION, categoryFunctionalFlowers); - agricarnation.setLexiconPages(new PageText("0"), new PagePetalRecipe("1", ModPetalRecipes.agricarnationRecipe)); - - hopperhock = new BLexiconEntry(LibLexicon.FFLOWER_HOPPERHOCK, categoryFunctionalFlowers); - hopperhock.setLexiconPages(new PageText("0"), new PageText("1"), - new PagePetalRecipe("2", ModPetalRecipes.hopperhockRecipe)); - - tangleberrie = new BLexiconEntry(LibLexicon.FFLOWER_TANGLEBERRIE, categoryFunctionalFlowers); - tangleberrie.setLexiconPages(new PageText("0"), new PagePetalRecipe("1", ModPetalRecipes.tangleberrieRecipe)); - - jiyuulia = new BLexiconEntry(LibLexicon.FFLOWER_JIYUULIA, categoryFunctionalFlowers); - jiyuulia.setLexiconPages(new PageText("0"), new PagePetalRecipe("1", ModPetalRecipes.jiyuuliaRecipe)); - - rannuncarpus = new BLexiconEntry(LibLexicon.FFLOWER_RANNUNCARPUS, categoryFunctionalFlowers); - rannuncarpus.setLexiconPages(new PageText("0"), new PageText("1"), - new PagePetalRecipe("2", ModPetalRecipes.rannuncarpusRecipe)); - - hyacidus = new BLexiconEntry(LibLexicon.FFLOWER_HYACIDUS, categoryFunctionalFlowers); - hyacidus.setLexiconPages(new PageText("0"), new PagePetalRecipe("1", ModPetalRecipes.hyacidusRecipe)); - - pollidisiac = new BLexiconEntry(LibLexicon.FFLOWER_POLLIDISIAC, categoryFunctionalFlowers); - pollidisiac.setLexiconPages(new PageText("0"), new PagePetalRecipe("1", ModPetalRecipes.pollidisiacRecipe)); - - clayconia = new BLexiconEntry(LibLexicon.FFLOWER_CLAYCONIA, categoryFunctionalFlowers); - clayconia.setLexiconPages(new PageText("0"), new PagePetalRecipe("1", ModPetalRecipes.clayconiaRecipe)); - - loonium = new ALexiconEntry(LibLexicon.FFLOWER_LOONIUM, categoryFunctionalFlowers); - loonium.setLexiconPages(new PageText("0"), new PagePetalRecipe("1", ModPetalRecipes.looniumRecipe)); - - daffomill = new BLexiconEntry(LibLexicon.FFLOWER_DAFFOMILL, categoryFunctionalFlowers); - daffomill.setLexiconPages(new PageText("0"), new PagePetalRecipe("1", ModPetalRecipes.daffomillRecipe)); - - vinculotus = new BLexiconEntry(LibLexicon.FFLOWER_VINCULOTUS, categoryFunctionalFlowers); - vinculotus.setLexiconPages(new PageText("0"), new PagePetalRecipe("1", ModPetalRecipes.vinculotusRecipe)); - - spectranthemum = new ALexiconEntry(LibLexicon.FFLOWER_SPECTRANTHEMUN, categoryFunctionalFlowers); - spectranthemum.setLexiconPages(new PageText("0"), new PageText("1"), new PageText("2"), - new PagePetalRecipe("3", ModPetalRecipes.spectranthemumRecipe)); - - medumone = new BLexiconEntry(LibLexicon.FFLOWER_MEDUMONE, categoryFunctionalFlowers); - medumone.setLexiconPages(new PageText("0"), new PagePetalRecipe("1", ModPetalRecipes.medumoneRecipe)); - - marimorphosis = new BLexiconEntry(LibLexicon.FFLOWER_MARIMORPHOSIS, categoryFunctionalFlowers); - marimorphosis.setLexiconPages(new PageText("0"), new PageImage("1", LibResources.ENTRY_METAMORPHIC_STONES), - new PagePetalRecipe("2", ModPetalRecipes.marimorphosisRecipe), - new PageCraftingRecipe("3", ModCraftingRecipes.recipesAltarMeta)); - - bubbell = new ALexiconEntry(LibLexicon.FFLOWER_BUBBELL, categoryFunctionalFlowers); - bubbell.setLexiconPages(new PageText("0"), new PagePetalRecipe("1", ModPetalRecipes.bubbellRecipe)); - - solegnolia = new BLexiconEntry(LibLexicon.FFLOWER_SOLEGNOLIA, categoryFunctionalFlowers); - solegnolia.setLexiconPages(new PageText("0"), new PagePetalRecipe("1", ModPetalRecipes.solegnoliaRecipe)); - - // GENERATING FLOWERS ENTRIES - if (ConfigHandler.hardcorePassiveGeneration > 0) { - generatingIntro = new BLexiconEntry(LibLexicon.GFLOWER_INTRO, categoryGenerationFlowers); - generatingIntro.setPriority().setLexiconPages(new PageText("0"), new PageText("1"), new PageText("2")); - } - - passiveGen = new BLexiconEntry(LibLexicon.GFLOWER_PASSIVE_GENERATION, categoryGenerationFlowers); - passiveGen.setPriority().setLexiconPages(new PageText("0"), new PageText("1")) - .setIcon(new ItemStack(Blocks.deadbush)); - - primusLoci = new BLexiconEntry(LibLexicon.GFLOWER_PRIMUS_LOCI, categoryGenerationFlowers); - primusLoci.setPriority().setLexiconPages(new PageText("0"), new PageText("1")); - primusLoci.setIcon(ItemBlockSpecialFlower.ofType(LibBlockNames.SUBTILE_DAYBLOOM_PRIME)); - primusLoci.addExtraDisplayedRecipe(ItemBlockSpecialFlower.ofType(LibBlockNames.SUBTILE_DAYBLOOM_PRIME)); - primusLoci.addExtraDisplayedRecipe(ItemBlockSpecialFlower.ofType(LibBlockNames.SUBTILE_NIGHTSHADE_PRIME)); - - daybloom = new BLexiconEntry(LibLexicon.GFLOWER_DAYBLOOM, categoryGenerationFlowers); - daybloom.setPriority().setLexiconPages(new PageText("0"), new PageText("1"), - new PagePetalRecipe("2", ModPetalRecipes.daybloomRecipe)); - - nightshade = new BLexiconEntry(LibLexicon.GFLOWER_NIGHTSHADE, categoryGenerationFlowers); - nightshade.setLexiconPages(new PageText("0"), new PagePetalRecipe("1", ModPetalRecipes.nightshadeRecipe)); - - endoflame = new BLexiconEntry(LibLexicon.GFLOWER_ENDOFLAME, categoryGenerationFlowers); - endoflame.setLexiconPages(new PageText("0"), new PageText("1"), new PageText("3"), - new PagePetalRecipe("2", ModPetalRecipes.endoflameRecipe)); - - hydroangeas = new BLexiconEntry(LibLexicon.GFLOWER_HYDROANGEAS, categoryGenerationFlowers); - hydroangeas.setLexiconPages(new PageText("0"), new PageImage("2", LibResources.ENTRY_HYDROANGEAS), - new PagePetalRecipe("1", ModPetalRecipes.hydroangeasRecipe)); - - thermalily = new BLexiconEntry(LibLexicon.GFLOWER_THERMALILY, categoryGenerationFlowers); - thermalily.setLexiconPages(new PageText("0"), new PageText("2"), new PageText("3"), - new PagePetalRecipe("1", ModPetalRecipes.thermalilyRecipe)); - - arcaneRose = new BLexiconEntry(LibLexicon.GFLOWER_ARCANE_ROSE, categoryGenerationFlowers); - arcaneRose.setLexiconPages(new PageText("0"), new PagePetalRecipe("1", ModPetalRecipes.arcaneRoseRecipe)); - - munchdew = new BLexiconEntry(LibLexicon.GFLOWER_MUNCHDEW, categoryGenerationFlowers); - munchdew.setLexiconPages(new PageText("0"), new PageText("1"), - new PagePetalRecipe("2", ModPetalRecipes.munchdewRecipe)); - - entropinnyum = new BLexiconEntry(LibLexicon.GFLOWER_ENTROPINNYUM, categoryGenerationFlowers); - entropinnyum.setLexiconPages(new PageText("0"), new PagePetalRecipe("1", ModPetalRecipes.entropinnyumRecipe)); - - kekimurus = new ALexiconEntry(LibLexicon.GFLOWER_KEKIMURUS, categoryGenerationFlowers); - kekimurus.setLexiconPages(new PageText("0"), new PagePetalRecipe("1", ModPetalRecipes.kekimurusRecipe)); - - gourmaryllis = new BLexiconEntry(LibLexicon.GFLOWER_GOURMARYLLIS, categoryGenerationFlowers); - gourmaryllis.setLexiconPages(new PageText("0"), new PageText("1"), new PageText("2"), - new PagePetalRecipe("3", ModPetalRecipes.gourmaryllisRecipe)); - - narslimmus = new BLexiconEntry(LibLexicon.GFLOWER_NARSLIMMUS, categoryGenerationFlowers); - narslimmus.setLexiconPages(new PageText("0"), new PagePetalRecipe("1", ModPetalRecipes.narslimmusRecipe)); - - spectrolus = new ALexiconEntry(LibLexicon.GFLOWER_SPECTROLUS, categoryGenerationFlowers); - spectrolus.setLexiconPages(new PageText("0"), new PageText("1"), - new PagePetalRecipe("2", ModPetalRecipes.spectrolusRecipe)); - - rafflowsia = new ALexiconEntry(LibLexicon.GFLOWER_RAFFLOWSIA, categoryGenerationFlowers); - rafflowsia.setLexiconPages(new PageText("0"), new PageText("1"), new PageText("2"), new PageText("3"), - new PagePetalRecipe("4", ModPetalRecipes.rafflowsiaRecipe)); - - dandelifeon = new ALexiconEntry(LibLexicon.GFLOWER_DANDELIFEON, categoryGenerationFlowers); - dandelifeon.setLexiconPages(new PageText("_w"), new PageText("0"), new PageText("1"), new PageText("2"), - new PageText("3"), new PageText("4"), new PageText("5"), new PageText("6"), new PageText("10"), - new PageText("7"), new PagePetalRecipe("8", ModPetalRecipes.dandelifeonRecipe), - new PageCraftingRecipe("9", ModCraftingRecipes.recipeCellBlock)); - - // DEVICES ENTRIES - pylon = new BLexiconEntry(LibLexicon.DEVICE_PYLON, categoryDevices); - pylon.setLexiconPages(new PageText("0"), new PageCraftingRecipe("1", ModCraftingRecipes.recipePylon)); - - if (ConfigHandler.enchanterEnabled) { - manaEnchanting = new BLexiconEntry(LibLexicon.DEVICE_MANA_ENCHANTING, categoryDevices); - manaEnchanting - .setLexiconPages(new PageText("0"), new PageText("1"), - new PageMultiblock("2", ModMultiblocks.enchanter), new PageText("5"), new PageText("6"), - new PageText("7"), new PageText("8"), new PageText("9")) - .setIcon(new ItemStack(ModBlocks.enchanter)); - } - - turntable = new BLexiconEntry(LibLexicon.DEVICE_TURNTABLE, categoryDevices); - turntable.setLexiconPages(new PageText("0"), new PageCraftingRecipe("1", ModCraftingRecipes.recipeTurntable)); - - alchemy = new BLexiconEntry(LibLexicon.DEVICE_ALCHEMY, categoryDevices); - alchemy.setLexiconPages(new PageText("0"), - new PageCraftingRecipe("1", ModCraftingRecipes.recipeAlchemyCatalyst), - new PageManaInfusionRecipe("2", ModManaAlchemyRecipes.leatherRecipe), - new PageManaInfusionRecipe("3", ModManaAlchemyRecipes.woodRecipes), - new PageManaInfusionRecipe("4", ModManaAlchemyRecipes.saplingRecipes), - new PageManaInfusionRecipe("5", ModManaAlchemyRecipes.glowstoneDustRecipe), - new PageManaInfusionRecipe("6", ModManaAlchemyRecipes.quartzRecipes).setSkipRegistry(), - new PageManaInfusionRecipe("7", ModManaAlchemyRecipes.chiseledBrickRecipe), - new PageManaInfusionRecipe("8", ModManaAlchemyRecipes.iceRecipe), - new PageManaInfusionRecipe("9", ModManaAlchemyRecipes.swampFolliageRecipes), - new PageManaInfusionRecipe("10", ModManaAlchemyRecipes.fishRecipes), - new PageManaInfusionRecipe("11", ModManaAlchemyRecipes.cropRecipes), - new PageManaInfusionRecipe("12", ModManaAlchemyRecipes.potatoRecipe), - new PageManaInfusionRecipe("13", ModManaAlchemyRecipes.netherWartRecipe), - new PageManaInfusionRecipe("14", ModManaAlchemyRecipes.gunpowderAndFlintRecipes), - new PageManaInfusionRecipe("15", ModManaAlchemyRecipes.nameTagRecipe), - new PageManaInfusionRecipe("16", ModManaAlchemyRecipes.stringRecipes), - new PageManaInfusionRecipe("17", ModManaAlchemyRecipes.slimeballCactusRecipes), - new PageManaInfusionRecipe("18", ModManaAlchemyRecipes.enderPearlRecipe), - new PageManaInfusionRecipe("19", ModManaAlchemyRecipes.redstoneToGlowstoneRecipes), - new PageManaInfusionRecipe("20", ModManaAlchemyRecipes.sandRecipe), - new PageManaInfusionRecipe("21", ModManaAlchemyRecipes.redSandRecipe), - new PageManaInfusionRecipe("22", ModManaAlchemyRecipes.clayBreakdownRecipes), - new PageManaInfusionRecipe("24", ModManaAlchemyRecipes.tallgrassRecipes), - new PageManaInfusionRecipe("25", ModManaAlchemyRecipes.flowersRecipes), - new PageManaInfusionRecipe("23", ModManaAlchemyRecipes.coarseDirtRecipe)); - - openCrate = new BLexiconEntry(LibLexicon.DEVICE_OPEN_CRATE, categoryDevices); - openCrate.setPriority().setLexiconPages(new PageText("0"), new PageText("1"), - new PageCraftingRecipe("2", ModCraftingRecipes.recipeOpenCrate)); - - forestEye = new BLexiconEntry(LibLexicon.DEVICE_FOREST_EYE, categoryDevices); - forestEye.setLexiconPages(new PageText("0"), new PageText("1"), - new PageCraftingRecipe("2", ModCraftingRecipes.recipeForestEye)); - - forestDrum = new BLexiconEntry(LibLexicon.DEVICE_FOREST_DRUM, categoryDevices); - forestDrum.setLexiconPages(new PageText("0"), new PageText("1"), - new PageCraftingRecipe("2", ModCraftingRecipes.recipeForestDrum)); - - platform = new BLexiconEntry(LibLexicon.DEVICE_PLATFORM, categoryDevices); - platform.setLexiconPages(new PageText("0"), new PageText("2"), - new PageCraftingRecipe("1", ModCraftingRecipes.recipePlatform)); - - conjurationCatalyst = new ALexiconEntry(LibLexicon.DEVICE_MANA_CONJURATION, categoryDevices); - conjurationCatalyst.setLexiconPages(new PageText("0"), - new PageCraftingRecipe("1", ModCraftingRecipes.recipeConjurationCatalyst), - new PageManaInfusionRecipe("2", ModManaConjurationRecipes.redstoneRecipe), - new PageManaInfusionRecipe("3", ModManaConjurationRecipes.glowstoneRecipe), - new PageManaInfusionRecipe("4", ModManaConjurationRecipes.quartzRecipe), - new PageManaInfusionRecipe("5", ModManaConjurationRecipes.coalRecipe), - new PageManaInfusionRecipe("6", ModManaConjurationRecipes.snowballRecipe), - new PageManaInfusionRecipe("7", ModManaConjurationRecipes.netherrackRecipe), - new PageManaInfusionRecipe("8", ModManaConjurationRecipes.soulSandRecipe), - new PageManaInfusionRecipe("9", ModManaConjurationRecipes.gravelRecipe), - new PageManaInfusionRecipe("10", ModManaConjurationRecipes.leavesRecipes), - new PageManaInfusionRecipe("11", ModManaConjurationRecipes.grassRecipe)); - - spectralPlatform = new ALexiconEntry(LibLexicon.DEVICE_SPECTRAL_PLATFORM, categoryDevices); - spectralPlatform.setLexiconPages(new PageText("0"), - new PageCraftingRecipe("1", ModCraftingRecipes.recipeSpectralPlatform)); - - gatherDrum = new ALexiconEntry(LibLexicon.DEVICE_GATHER_DRUM, categoryDevices); - gatherDrum.setLexiconPages(new PageText("0"), new PageCraftingRecipe("1", ModCraftingRecipes.recipeGatherDrum)); - - craftCrate = new ALexiconEntry(LibLexicon.DEVICE_CRAFT_CRATE, categoryDevices); - craftCrate - .setLexiconPages(new PageText("0"), new PageText("1"), - new PageCraftingRecipe("2", ModCraftingRecipes.recipePlaceholder), new PageText("3"), - new PageText("4"), new PageText("7"), new PageImage("5", LibResources.ENTRY_CRAFT_CRATE), - new PageCraftingRecipe("6", ModCraftingRecipes.recipeCraftCrate), new PageText("8"), - new PageCraftingRecipe("9", ModCraftingRecipes.recipesPatterns)) - .setIcon(new ItemStack(ModBlocks.openCrate, 1, 1)); - - brewery = new BLexiconEntry(LibLexicon.DEVICE_BREWERY, categoryDevices); - brewery.setLexiconPages(new PageText("0"), new PageText("1"), - new PageCraftingRecipe("2", ModCraftingRecipes.recipeBrewery), - new PageCraftingRecipe("3", ModCraftingRecipes.recipeVial), new PageText("4"), - new PageBrew(ModBrewRecipes.speedBrew, "5a", "5b"), - new PageBrew(ModBrewRecipes.strengthBrew, "6a", "6b"), - new PageBrew(ModBrewRecipes.hasteBrew, "7a", "7b"), - new PageBrew(ModBrewRecipes.healingBrew, "8a", "8b"), - new PageBrew(ModBrewRecipes.jumpBoostBrew, "9a", "9b"), - new PageBrew(ModBrewRecipes.regenerationBrew, "10a", "10b"), - new PageBrew(ModBrewRecipes.weakRegenerationBrew, "17a", "17b"), - new PageBrew(ModBrewRecipes.resistanceBrew, "11a", "11b"), - new PageBrew(ModBrewRecipes.fireResistanceBrew, "12a", "12b"), - new PageBrew(ModBrewRecipes.waterBreathingBrew, "13a", "13b"), - new PageBrew(ModBrewRecipes.invisibilityBrew, "14a", "14b"), - new PageBrew(ModBrewRecipes.nightVisionBrew, "15a", "15b"), - new PageBrew(ModBrewRecipes.absorptionBrew, "16a", "16b")); - - flasks = new ALexiconEntry(LibLexicon.DEVICE_FLASKS, categoryDevices); - flasks.setLexiconPages(new PageText("0"), new PageText("1"), - new PageCraftingRecipe("2", ModCraftingRecipes.recipeFlask)); - - complexBrews = new BLexiconEntry(LibLexicon.DEVICE_COMPLEX_BREWS, categoryDevices); - complexBrews.setLexiconPages(new PageText("0"), new PageBrew(ModBrewRecipes.overloadBrew, "1a", "1b"), - new PageBrew(ModBrewRecipes.soulCrossBrew, "2a", "2b"), - new PageBrew(ModBrewRecipes.featherFeetBrew, "3a", "3b"), - new PageBrew(ModBrewRecipes.emptinessBrew, "4a", "4b"), - new PageBrew(ModBrewRecipes.bloodthirstBrew, "5a", "5b"), - new PageBrew(ModBrewRecipes.allureBrew, "6a", "6b"), new PageBrew(ModBrewRecipes.clearBrew, "7a", "7b")) - .setIcon(((IBrewContainer) ModItems.vial).getItemForBrew(ModBrews.jumpBoost, - new ItemStack(ModItems.vial))); - - incense = new BLexiconEntry(LibLexicon.DEVICE_INCENSE, categoryDevices); - incense.setLexiconPages(new PageText("0"), new PageText("1"), new PageText("2"), new PageText("5"), - new PageCraftingRecipe("3", ModCraftingRecipes.recipeIncenseStick), - new PageCraftingRecipe("4", ModCraftingRecipes.recipeIncensePlate)); - - hourglass = new BLexiconEntry(LibLexicon.DEVICE_HOURGLASS, categoryDevices); - hourglass.setPriority().setLexiconPages(new PageText("0"), new PageText("1"), new PageText("2"), - new PageText("3"), new PageText("4"), new PageCraftingRecipe("5", ModCraftingRecipes.recipeHourglass)); - - ghostRail = new ALexiconEntry(LibLexicon.DEVICE_GHOST_RAIL, categoryDevices); - ghostRail.setLexiconPages(new PageText("0"), new PageCraftingRecipe("1", ModCraftingRecipes.recipeGhostRail)); - - canopyDrum = new BLexiconEntry(LibLexicon.DEVICE_CANOPY_DRUM, categoryDevices); - canopyDrum.setLexiconPages(new PageText("0"), new PageCraftingRecipe("1", ModCraftingRecipes.recipeCanopyDrum)); - - cocoon = Botania.gardenOfGlassLoaded ? new BLexiconEntry(LibLexicon.DEVICE_COCOON, categoryDevices) - : new ALexiconEntry(LibLexicon.DEVICE_COCOON, categoryDevices); - cocoon.setLexiconPages(new PageText("0"), new PageText("1"), - new PageCraftingRecipe("2", ModCraftingRecipes.recipeCocoon)); - - manaBomb = new ALexiconEntry(LibLexicon.DEVICE_MANA_BOMB, categoryDevices); - manaBomb.setLexiconPages(new PageText("0"), new PageCraftingRecipe("1", ModCraftingRecipes.recipeManaBomb)); - - teruTeruBozu = new BLexiconEntry(LibLexicon.DEVICE_TERU_TERU_BOZU, categoryDevices); - teruTeruBozu.setLexiconPages(new PageText("0"), - new PageCraftingRecipe("1", ModCraftingRecipes.recipeTeruTeruBozu)); - - avatar = new BLexiconEntry(LibLexicon.DEVICE_AVATAR, categoryDevices); - avatar.setLexiconPages(new PageText("0"), new PageText("1"), - new PageCraftingRecipe("2", ModCraftingRecipes.recipeAvatar)); - - felPumpkin = new BLexiconEntry(LibLexicon.DEVICE_FEL_PUMPKIN, categoryDevices); - felPumpkin.setLexiconPages(new PageText("0"), new PageCraftingRecipe("1", ModCraftingRecipes.recipeFelPumpkin)); - - // TOOLS ENTRIES - manaBlaster = new BLexiconEntry(LibLexicon.TOOL_MANA_BLASTER, categoryTools); - manaBlaster.setLexiconPages(new PageText("0"), new PageText("1"), new PageText("2"), - new PageCraftingRecipe("3", ModCraftingRecipes.recipeManaBlaster)); - - grassSeeds = new BLexiconEntry(LibLexicon.TOOL_GRASS_SEEDS, categoryTools); - grassSeeds.setLexiconPages(new PageText("0"), - new PageManaInfusionRecipe("1", ModManaInfusionRecipes.grassSeedsRecipe), - new PageManaInfusionRecipe("2", ModManaInfusionRecipes.podzolSeedsRecipe), - new PageManaInfusionRecipe("3", ModManaInfusionRecipes.mycelSeedsRecipes), new PageText("4"), - new PageCraftingRecipe("5", ModCraftingRecipes.recipesAltGrassSeeds)); - - dirtRod = new BLexiconEntry(LibLexicon.TOOL_DIRT_ROD, categoryTools); - dirtRod.setLexiconPages(new PageText("0"), new PageCraftingRecipe("1", ModCraftingRecipes.recipeDirtRod)); - - terraformRod = new BLexiconEntry(LibLexicon.TOOL_TERRAFORM_ROD, categoryTools); - terraformRod.setLexiconPages(new PageText("0"), new PageText("1"), new PageText("2"), - new PageCraftingRecipe("3", ModCraftingRecipes.recipeTerraformRod)); - - manasteelGear = new BLexiconEntry(LibLexicon.TOOL_MANASTEEL_GEAR, categoryTools); - manasteelGear.setPriority().setLexiconPages(new PageText("0"), new PageText("10"), - new PageCraftingRecipe("1", ModCraftingRecipes.recipeManasteelPick), - new PageCraftingRecipe("2", ModCraftingRecipes.recipeManasteelShovel), - new PageCraftingRecipe("3", ModCraftingRecipes.recipeManasteelAxe), - new PageCraftingRecipe("4", ModCraftingRecipes.recipeManasteelShears), - new PageCraftingRecipe("5", ModCraftingRecipes.recipeManasteelSword), - new PageCraftingRecipe("6", ModCraftingRecipes.recipeManasteelHelm), - new PageCraftingRecipe("7", ModCraftingRecipes.recipeManasteelChest), - new PageCraftingRecipe("8", ModCraftingRecipes.recipeManasteelLegs), - new PageCraftingRecipe("9", ModCraftingRecipes.recipeManasteelBoots)); - - terrasteelArmor = new BLexiconEntry(LibLexicon.TOOL_TERRASTEEL_ARMOR, categoryTools); - terrasteelArmor.setLexiconPages(new PageText("0"), - new PageCraftingRecipe("1", ModCraftingRecipes.recipeTerrasteelHelm), - new PageCraftingRecipe("2", ModCraftingRecipes.recipeTerrasteelChest), - new PageCraftingRecipe("3", ModCraftingRecipes.recipeTerrasteelLegs), - new PageCraftingRecipe("4", ModCraftingRecipes.recipeTerrasteelBoots)); - - grassHorn = new BLexiconEntry(LibLexicon.TOOL_GRASS_HORN, categoryTools); - grassHorn.setLexiconPages(new PageText("0"), new PageCraftingRecipe("1", ModCraftingRecipes.recipeGrassHorn), - new PageCraftingRecipe("2", ModCraftingRecipes.recipeLeafHorn), - new PageCraftingRecipe("3", ModCraftingRecipes.recipeSnowHorn)); - - terraBlade = new BLexiconEntry(LibLexicon.TOOL_TERRA_SWORD, categoryTools); - terraBlade.setLexiconPages(new PageText("0"), new PageCraftingRecipe("1", ModCraftingRecipes.recipeTerraSword)); - - terraPick = new BLexiconEntry(LibLexicon.TOOL_TERRA_PICK, categoryTools); - terraPick.setLexiconPages(new PageText("0"), new PageText("1"), new PageText("2"), new PageText("3"), - new PageText("4"), new PageCraftingRecipe("5", ModCraftingRecipes.recipeTerraPick)); - - waterRod = new BLexiconEntry(LibLexicon.TOOL_WATER_ROD, categoryTools); - waterRod.setLexiconPages(new PageText("0"), new PageCraftingRecipe("1", ModCraftingRecipes.recipeWaterRod)); - - elfGear = new ALexiconEntry(LibLexicon.TOOL_ELF_GEAR, categoryTools); - elfGear.setLexiconPages(new PageText("0"), new PageText("1"), new PageText("2"), - new PageCraftingRecipe("3", ModCraftingRecipes.recipeElementiumPick), new PageText("4"), - new PageCraftingRecipe("5", ModCraftingRecipes.recipeElementiumShovel), new PageText("6"), - new PageCraftingRecipe("7", ModCraftingRecipes.recipeElementiumAxe), new PageText("8"), - new PageCraftingRecipe("9", ModCraftingRecipes.recipeElementiumShears), new PageText("10"), - new PageCraftingRecipe("11", ModCraftingRecipes.recipeElementiumSword), - new PageCraftingRecipe("12", ModCraftingRecipes.recipeElementiumHelm), - new PageCraftingRecipe("13", ModCraftingRecipes.recipeElementiumChest), - new PageCraftingRecipe("14", ModCraftingRecipes.recipeElementiumLegs), - new PageCraftingRecipe("15", ModCraftingRecipes.recipeElementiumBoots)); - - openBucket = new ALexiconEntry(LibLexicon.TOOL_OPEN_BUCKET, categoryTools); - openBucket.setLexiconPages(new PageText("0"), new PageCraftingRecipe("1", ModCraftingRecipes.recipeOpenBucket)); - - rainbowRod = new ALexiconEntry(LibLexicon.TOOL_RAINBOW_ROD, categoryTools); - rainbowRod.setLexiconPages(new PageText("0"), new PageText("1"), new PageText("6"), - new PageCraftingRecipe("2", ModCraftingRecipes.recipeRainbowRod), - new PageCraftingRecipe("3", ModCraftingRecipes.recipeBifrost), - new PageCraftingRecipe("4", ModCraftingRecipes.recipeShimmerrock), - new PageCraftingRecipe("5", ModCraftingRecipes.recipeShimmerwoodPlanks), - new PageCraftingRecipe("7", ModCraftingRecipes.recipePoolFabulous)); - - tornadoRod = new BLexiconEntry(LibLexicon.TOOL_TORNADO_ROD, categoryTools); - tornadoRod.setLexiconPages(new PageText("0"), new PageText("2"), - new PageCraftingRecipe("1", ModCraftingRecipes.recipeTornadoRod)); - - fireRod = new BLexiconEntry(LibLexicon.TOOL_FIRE_ROD, categoryTools); - fireRod.setLexiconPages(new PageText("0"), new PageText("2"), - new PageCraftingRecipe("1", ModCraftingRecipes.recipeFireRod)); - - vineBall = new BLexiconEntry(LibLexicon.TOOL_VINE_BALL, categoryTools); - vineBall.setLexiconPages(new PageText("0"), new PageText("1"), - new PageCraftingRecipe("2", ModCraftingRecipes.recipeVineBall), - new PageCraftingRecipe("3", ModCraftingRecipes.recipeSlingshot), - new PageCraftingRecipe("4", ModCraftingRecipes.recipeMossStone)); - - laputaShard = new ALexiconEntry(LibLexicon.TOOL_LAPUTA_SHARD, categoryTools); - laputaShard.setLexiconPages(new PageText("0"), new PageText("2"), - new PageCraftingRecipe("1", ModCraftingRecipes.recipesLaputaShard), - new PageCraftingRecipe("3", ModCraftingRecipes.recipesLaputaShardUpgrade)); - - virus = new ALexiconEntry(LibLexicon.TOOL_VIRUS, categoryTools); - virus.setLexiconPages(new PageText("0"), new PageCraftingRecipe("1", ModCraftingRecipes.recipeVirusZombie), - new PageCraftingRecipe("2", ModCraftingRecipes.recipeVirusSkeleton)); - - skyDirtRod = new ALexiconEntry(LibLexicon.TOOL_SKY_DIRT_ROD, categoryTools); - skyDirtRod.setLexiconPages(new PageText("0"), new PageCraftingRecipe("1", ModCraftingRecipes.recipeSkyDirtRod)); - - glassPick = new BLexiconEntry(LibLexicon.TOOL_GLASS_PICK, categoryTools); - glassPick.setLexiconPages(new PageText("0"), new PageCraftingRecipe("1", ModCraftingRecipes.recipeGlassPick)); - - diviningRod = new BLexiconEntry(LibLexicon.TOOL_DIVINING_ROD, categoryTools); - diviningRod.setLexiconPages(new PageText("0"), new PageText("2"), - new PageCraftingRecipe("1", ModCraftingRecipes.recipeDiviningRod)); - - gravityRod = new ALexiconEntry(LibLexicon.TOOL_GRAVITY_ROD, categoryTools); - gravityRod.setLexiconPages(new PageText("0"), new PageText("1"), - new PageCraftingRecipe("2", ModCraftingRecipes.recipeGravityRod)); - - regenIvy = new ALexiconEntry(LibLexicon.TOOL_REGEN_IVY, categoryTools); - regenIvy.setLexiconPages(new PageText("0"), new PageText("1"), - new PageCraftingRecipe("2", ModCraftingRecipes.recipeRegenIvy)); - - missileRod = new ALexiconEntry(LibLexicon.TOOL_MISSILE_ROD, categoryTools); - missileRod.setLexiconPages(new PageText("0"), new PageText("2"), - new PageCraftingRecipe("1", ModCraftingRecipes.recipeMissileRod)); - - craftingHalo = new BLexiconEntry(LibLexicon.TOOL_CRAFTING_HALO, categoryTools); - craftingHalo.setLexiconPages(new PageText("0"), new PageText("1"), - new PageCraftingRecipe("2", ModCraftingRecipes.recipeCraftingHalo)); - - clip = new ALexiconEntry(LibLexicon.TOOL_CLIP, categoryTools); - clip.setLexiconPages(new PageText("0"), new PageText("1"), - new PageCraftingRecipe("2", ModCraftingRecipes.recipeClip)); - - cobbleRod = new BLexiconEntry(LibLexicon.TOOL_COBBLE_ROD, categoryTools); - cobbleRod.setLexiconPages(new PageText("0"), new PageCraftingRecipe("1", ModCraftingRecipes.recipeCobbleRod)); - - smeltRod = new BLexiconEntry(LibLexicon.TOOL_SMELT_ROD, categoryTools); - smeltRod.setLexiconPages(new PageText("0"), new PageCraftingRecipe("1", ModCraftingRecipes.recipeSmeltRod)); - - worldSeed = new ALexiconEntry(LibLexicon.TOOL_WORLD_SEED, categoryTools); - worldSeed.setLexiconPages(new PageText("0"), new PageCraftingRecipe("1", ModCraftingRecipes.recipeWorldSeed)); - - spellCloth = new BLexiconEntry(LibLexicon.TOOL_SPELL_CLOTH, categoryTools); - spellCloth.setLexiconPages(new PageText("0"), new PageCraftingRecipe("1", ModCraftingRecipes.recipeSpellCloth)); - - thornChakram = new BLexiconEntry(LibLexicon.TOOL_THORN_CHAKRAM, categoryTools); - thornChakram.setLexiconPages(new PageText("0"), - new PageCraftingRecipe("1", ModCraftingRecipes.recipeThornChakram)); - - fireChakram = new ALexiconEntry(LibLexicon.TOOL_FIRE_CHAKRAM, categoryTools); - fireChakram.setLexiconPages(new PageText("0"), - new PageCraftingRecipe("1", ModCraftingRecipes.recipeFireChakram)); - - overgrowthSeed = new BLexiconEntry(LibLexicon.TOOL_OVERGROWTH_SEED, categoryTools); - overgrowthSeed.setPriority().setLexiconPages(new PageText("0"), new PageText("1")) - .setIcon(new ItemStack(ModItems.overgrowthSeed)); - overgrowthSeed.addExtraDisplayedRecipe(new ItemStack(ModItems.overgrowthSeed)); - overgrowthSeed.addExtraDisplayedRecipe(new ItemStack(ModBlocks.enchantedSoil)); - - livingwoodBow = new BLexiconEntry(LibLexicon.TOOL_LIVINGWOOD_BOW, categoryTools); - livingwoodBow.setLexiconPages(new PageText("0"), - new PageCraftingRecipe("1", ModCraftingRecipes.recipeLivingwoodBow)); - - crystalBow = new ALexiconEntry(LibLexicon.TOOL_CRYSTAL_BOW, categoryTools); - crystalBow.setLexiconPages(new PageText("0"), new PageCraftingRecipe("1", ModCraftingRecipes.recipeCrystalBow)); - - temperanceStone = new BLexiconEntry(LibLexicon.TOOL_TEMPERANCE_STONE, categoryTools); - temperanceStone.setLexiconPages(new PageText("0"), - new PageCraftingRecipe("1", ModCraftingRecipes.recipeTemperanceStone)); - - terraAxe = new BLexiconEntry(LibLexicon.TOOL_TERRA_AXE, categoryTools); - terraAxe.setLexiconPages(new PageText("0"), new PageCraftingRecipe("1", ModCraftingRecipes.recipeTerraAxe)); - - obedienceStick = new BLexiconEntry(LibLexicon.TOOL_OBEDIENCE_STICK, categoryTools); - obedienceStick.setPriority().setLexiconPages(new PageText("0"), - new PageCraftingRecipe("1", ModCraftingRecipes.recipeObedienceStick)); - - slimeBottle = new ALexiconEntry(LibLexicon.TOOL_SLIME_BOTTLE, categoryTools); - slimeBottle.setLexiconPages(new PageText("0"), - new PageCraftingRecipe("1", ModCraftingRecipes.recipeSlimeBottle)); - - exchangeRod = new BLexiconEntry(LibLexicon.TOOL_EXCHANGE_ROD, categoryTools); - exchangeRod.setLexiconPages(new PageText("0"), new PageText("1"), new PageText("2"), - new PageCraftingRecipe("3", ModCraftingRecipes.recipeExchangeRod)); - - manaweave = new BLexiconEntry(LibLexicon.TOOL_MANAWEAVE, categoryTools); - manaweave.setLexiconPages(new PageText("0"), new PageText("1"), - new PageCraftingRecipe("2", ModCraftingRecipes.recipeManaweaveCloth), - new PageCraftingRecipe("3", ModCraftingRecipes.recipeManaweaveHelm), - new PageCraftingRecipe("4", ModCraftingRecipes.recipeManaweaveChest), - new PageCraftingRecipe("5", ModCraftingRecipes.recipeManaweaveLegs), - new PageCraftingRecipe("6", ModCraftingRecipes.recipeManaweaveBoots)); - - autocraftingHalo = new BLexiconEntry(LibLexicon.TOOL_AUTOCRAFTING_HALO, categoryTools); - autocraftingHalo.setLexiconPages(new PageText("0"), - new PageCraftingRecipe("1", ModCraftingRecipes.recipeAutocraftingHalo)); - - sextant = new BLexiconEntry(LibLexicon.TOOL_SEXTANT, categoryTools); - sextant.setLexiconPages(new PageText("0"), new PageText("1"), - new PageCraftingRecipe("2", ModCraftingRecipes.recipeSextant)); - - // ENDER ENTRIES - enderAir = new BLexiconEntry(LibLexicon.ENDER_AIR, categoryEnder); - enderAir.setPriority().setLexiconPages(new PageText("0")); - enderAir.addExtraDisplayedRecipe(new ItemStack(ModItems.manaResource, 1, 15)); - LexiconRecipeMappings.map(new ItemStack(ModItems.manaResource, 1, 15), enderAir, 0); - - enderEyeBlock = new BLexiconEntry(LibLexicon.ENDER_ENDER_EYE_BLOCK, categoryEnder); - enderEyeBlock.setLexiconPages(new PageText("0"), - new PageCraftingRecipe("1", ModCraftingRecipes.recipeEnderEyeBlock)); - - pistonRelay = new BLexiconEntry(LibLexicon.ENDER_PISTON_RELAY, categoryEnder); - pistonRelay.setLexiconPages(new PageText("0"), new PageText("1"), - new PageManaInfusionRecipe("2", ModManaInfusionRecipes.pistonRelayRecipe)); - - enderHand = new BLexiconEntry(LibLexicon.ENDER_ENDER_HAND, categoryEnder); - enderHand.setLexiconPages(new PageText(ConfigHandler.enderPickpocketEnabled ? "0" : "0a"), new PageText("2"), - new PageCraftingRecipe(ConfigHandler.enderPickpocketEnabled ? "1" : "1a", - ModCraftingRecipes.recipeEnderHand)); - - enderDagger = new BLexiconEntry(LibLexicon.ENDER_ENDER_DAGGER, categoryEnder); - enderDagger.setLexiconPages(new PageText("0"), new PageText("1"), - new PageCraftingRecipe("2", ModCraftingRecipes.recipeEnderDagger)); - - spawnerClaw = new ALexiconEntry(LibLexicon.ENDER_SPAWNER_CLAW, categoryEnder); - spawnerClaw.setLexiconPages(new PageText("0"), new PageText("1"), - new PageCraftingRecipe("2", ModCraftingRecipes.recipeSpawnerClaw)); - - redString = new ALexiconEntry(LibLexicon.ENDER_RED_STRING, categoryEnder); - redString.setLexiconPages(new PageText("0"), new PageText("1"), - new PageCraftingRecipe("2", ModCraftingRecipes.recipeRedString), new PageText("3"), - new PageCraftingRecipe("4", ModCraftingRecipes.recipeRedStringContainer), new PageText("5"), - new PageCraftingRecipe("6", ModCraftingRecipes.recipeRedStringDispenser), new PageText("7"), - new PageCraftingRecipe("8", ModCraftingRecipes.recipeRedStringFertilizer), new PageText("9"), - new PageCraftingRecipe("10", ModCraftingRecipes.recipeRedStringComparator), new PageText("11"), - new PageCraftingRecipe("12", ModCraftingRecipes.recipeRedStringRelay), new PageText("13"), - new PageCraftingRecipe("14", ModCraftingRecipes.recipeRedStringInterceptor)); - - flightTiara = new ALexiconEntry(LibLexicon.ENDER_FLIGHT_TIARA, categoryEnder); - flightTiara.setLexiconPages(new PageText("0"), new PageText("4"), new PageText("5"), new PageText("6"), - new PageCraftingRecipe("1", ModCraftingRecipes.recipeFlightTiara), new PageText("2"), - new PageCraftingRecipe("3", ModCraftingRecipes.recipesWings)); - - corporea = new ALexiconEntry(LibLexicon.ENDER_CORPOREA, categoryEnder); - corporea.setLexiconPages(new PageText("0"), new PageText("1"), new PageText("2"), new PageText("3"), - new PageText("4"), new PageText("5"), new PageText("6"), - new PageCraftingRecipe("7", ModCraftingRecipes.recipeCorporeaSpark), - new PageCraftingRecipe("8", ModCraftingRecipes.recipeMasterCorporeaSpark)); - - corporeaIndex = new ALexiconEntry(LibLexicon.ENDER_CORPOREA_INDEX, categoryEnder); - corporeaIndex.setLexiconPages(new PageText("0"), new PageText("1"), new PageText("2"), new PageText("3"), - new PageText("4"), new PageText("5"), new PageText("8"), new PageText("6"), - new PageCraftingRecipe("7", ModCraftingRecipes.recipeCorporeaIndex)); - - corporeaFunnel = new ALexiconEntry(LibLexicon.ENDER_CORPOREA_FUNNEL, categoryEnder); - corporeaFunnel.setLexiconPages(new PageText("0"), new PageText("1"), - new PageCraftingRecipe("2", ModCraftingRecipes.recipeCorporeaFunnel)); - - corporeaInterceptor = new ALexiconEntry(LibLexicon.ENDER_CORPOREA_INTERCEPTOR, categoryEnder); - corporeaInterceptor.setLexiconPages(new PageText("0"), new PageText("1"), - new PageCraftingRecipe("2", ModCraftingRecipes.recipeCorporeaInterceptor)); - - if (ConfigHandler.enderStuff19Enabled) { - endStoneDecor = new BLexiconEntry(LibLexicon.ENDER_END_STONE_DECOR, categoryEnder); - endStoneDecor.setLexiconPages(new PageText("0"), - new PageCraftingRecipe("1", ModCraftingRecipes.recipeEndStoneBricks), - new PageCraftingRecipe("2", ModCraftingRecipes.recipeEndStoneChiseledBricks), - new PageCraftingRecipe("3", ModCraftingRecipes.recipeEnderBricks), - new PageCraftingRecipe("4", ModCraftingRecipes.recipePillarEnderBricks)); - } - - spawnerMover = new ALexiconEntry(LibLexicon.ENDER_SPAWNER_MOVER, categoryEnder); - spawnerMover.setLexiconPages(new PageText("0"), - new PageCraftingRecipe("1", ModCraftingRecipes.recipeSpawnerMover)); - - keepIvy = new ALexiconEntry(LibLexicon.ENDER_KEEP_IVY, categoryEnder); - keepIvy.setLexiconPages(new PageText("0"), new PageText("2"), - new PageCraftingRecipe("1", ModCraftingRecipes.recipeKeepIvy)); - - blackHoleTalisman = new ALexiconEntry(LibLexicon.ENDER_BLACK_HOLE_TALISMAN, categoryEnder); - blackHoleTalisman.setLexiconPages(new PageText("0"), new PageText("1"), new PageText("2"), - new PageCraftingRecipe("3", ModCraftingRecipes.recipeBlackHoleTalisman)); - - corporeaCrystalCube = new ALexiconEntry(LibLexicon.ENDER_CORPOREA_CRYSTAL_CUBE, categoryEnder); - corporeaCrystalCube.setLexiconPages(new PageText("0"), new PageText("1"), new PageText("3"), - new PageCraftingRecipe("2", ModCraftingRecipes.recipeCorporeaCrystalCube)); - - luminizerTransport = new ALexiconEntry(LibLexicon.ENDER_LUMINIZER_TRANSPORT, categoryEnder); - luminizerTransport.setLexiconPages(new PageText("0"), new PageText("1"), - new PageCraftingRecipe("2", ModCraftingRecipes.recipeLuminizer), new PageText("3"), - new PageCraftingRecipe("4", ModCraftingRecipes.recipeDetectorLuminizer), new PageText("5"), - new PageCraftingRecipe("6", ModCraftingRecipes.recipeLuminizerLauncher)); - - starSword = new ALexiconEntry(LibLexicon.ENDER_STAR_SWORD, categoryEnder); - starSword.setLexiconPages(new PageText("0"), new PageCraftingRecipe("1", ModCraftingRecipes.recipeStarSword)); - - thunderSword = new ALexiconEntry(LibLexicon.ENDER_THUNDER_SWORD, categoryEnder); - thunderSword.setLexiconPages(new PageText("0"), - new PageCraftingRecipe("1", ModCraftingRecipes.recipeThunderSword)); - - corporeaRetainer = new ALexiconEntry(LibLexicon.ENDER_CORPOREA_RETAINER, categoryEnder); - corporeaRetainer.setLexiconPages(new PageText("0"), new PageText("1"), new PageText("2"), - new PageCraftingRecipe("3", ModCraftingRecipes.recipeCorporeaRetainer)); - - // BAUBLES ENTRIES - baublesIntro = new BLexiconEntry(LibLexicon.BAUBLE_INTRO, categoryBaubles); - baublesIntro.setPriority().setLexiconPages(new PageText("0"), new PageImage("1", LibResources.ENTRY_BAUBLES), - new PageText("2")); - - cosmeticBaubles = new BLexiconEntry(LibLexicon.BAUBLE_COSMETIC, categoryBaubles); - { - List pages = new ArrayList(); - pages.add(new PageText("0")); - pages.add(new PageText("1")); - if (ModCraftingRecipes.recipesCosmeticItems != null) { - for (int i = 0; i < 32; i++) { - pages.add(new PageCraftingRecipe("" + (i + 2), ModCraftingRecipes.recipesCosmeticItems.get(i))); - } - } - cosmeticBaubles.setPriority().setLexiconPages(pages.toArray(new LexiconPage[pages.size()])); - } - - tinyPlanet = new BLexiconEntry(LibLexicon.BAUBLE_TINY_PLANET, categoryBaubles); - tinyPlanet.setLexiconPages(new PageText("0"), new PageCraftingRecipe("1", ModCraftingRecipes.recipeTinyPlanet), - new PageCraftingRecipe("2", ModCraftingRecipes.recipeTinyPlanetBlock)); - - manaRing = new BLexiconEntry(LibLexicon.BAUBLE_MANA_RING, categoryBaubles); - manaRing.setLexiconPages(new PageText("0"), new PageCraftingRecipe("1", ModCraftingRecipes.recipeManaRing), - new PageCraftingRecipe("2", ModCraftingRecipes.recipeGreaterManaRing)); - - auraRing = new BLexiconEntry(LibLexicon.BAUBLE_AURA_RING, categoryBaubles); - auraRing.setLexiconPages(new PageText("0"), new PageCraftingRecipe("1", ModCraftingRecipes.recipeAuraRing), - new PageCraftingRecipe("2", ModCraftingRecipes.recipeGreaterAuraRing)); - - travelBelt = new BLexiconEntry(LibLexicon.BAUBLE_TRAVEL_BELT, categoryBaubles); - travelBelt.setLexiconPages(new PageText("0"), new PageCraftingRecipe("1", ModCraftingRecipes.recipeTravelBelt)); - - knockbacklBelt = new BLexiconEntry(LibLexicon.BAUBLE_KNOCKBACK_BELT, categoryBaubles); - knockbacklBelt.setLexiconPages(new PageText("0"), - new PageCraftingRecipe("1", ModCraftingRecipes.recipeKnocbackBelt)); - - icePendant = new BLexiconEntry(LibLexicon.BAUBLE_ICE_PENDANT, categoryBaubles); - icePendant.setLexiconPages(new PageText("0"), new PageCraftingRecipe("1", ModCraftingRecipes.recipeIcePendant)); - - lavaPendant = new BLexiconEntry(LibLexicon.BAUBLE_LAVA_PENDANT, categoryBaubles); - lavaPendant.setLexiconPages(new PageText("0"), - new PageCraftingRecipe("1", ModCraftingRecipes.recipeFirePendant)); - - goldLaurel = new ALexiconEntry(LibLexicon.BAUBLE_GOLDEN_LAUREL, categoryBaubles); - goldLaurel.setLexiconPages(new PageText("0"), - new PageCraftingRecipe("1", ModCraftingRecipes.recipeGoldenLaurel)); - - waterRing = new BLexiconEntry(LibLexicon.BAUBLE_WATER_RING, categoryBaubles); - waterRing.setLexiconPages(new PageText("0"), new PageCraftingRecipe("1", ModCraftingRecipes.recipeWaterRing)); - - miningRing = new BLexiconEntry(LibLexicon.BAUBLE_MINING_RING, categoryBaubles); - miningRing.setLexiconPages(new PageText("0"), new PageCraftingRecipe("1", ModCraftingRecipes.recipeMiningRing)); - - magnetRing = new BLexiconEntry(LibLexicon.BAUBLE_MAGNET_RING, categoryBaubles); - magnetRing.setLexiconPages(new PageText("0"), new PageCraftingRecipe("1", ModCraftingRecipes.recipeMagnetRing), - new PageCraftingRecipe("2", ModCraftingRecipes.recipeGreaterMagnetRing)); - - divaCharm = new ALexiconEntry(LibLexicon.BAUBLE_DIVA_CHARM, categoryBaubles); - divaCharm.setLexiconPages(new PageText("0"), new PageCraftingRecipe("1", ModCraftingRecipes.recipeDivaCharm)); - - pixieRing = new ALexiconEntry(LibLexicon.BAUBLE_PIXIE_RING, categoryBaubles); - pixieRing.setLexiconPages(new PageText("0"), new PageCraftingRecipe("1", ModCraftingRecipes.recipePixieRing)); - - superTravelBelt = new ALexiconEntry(LibLexicon.BAUBLE_SUPER_TRAVEL_BELT, categoryBaubles); - superTravelBelt.setLexiconPages(new PageText("0"), - new PageCraftingRecipe("1", ModCraftingRecipes.recipeSuperTravelBelt)); - - reachRing = new ALexiconEntry(LibLexicon.BAUBLE_REACH_RING, categoryBaubles); - reachRing.setLexiconPages(new PageText("0"), new PageCraftingRecipe("1", ModCraftingRecipes.recipeReachRing)); - - itemFinder = new BLexiconEntry(LibLexicon.BAUBLE_ITEM_FINDER, categoryBaubles); - itemFinder.setLexiconPages(new PageText("0"), new PageText("1"), - new PageCraftingRecipe("2", ModCraftingRecipes.recipeItemFinder)); - - superLavaPendant = new ALexiconEntry(LibLexicon.BAUBLE_SUPER_LAVA_PENDANT, categoryBaubles); - superLavaPendant.setLexiconPages(new PageText("0"), - new PageCraftingRecipe("1", ModCraftingRecipes.recipeSuperLavaPendant)); - - bloodPendant = new BLexiconEntry(LibLexicon.BAUBLE_BLOOD_PENDANT, categoryBaubles); - bloodPendant.setLexiconPages(new PageText("0"), new PageText("1"), - new PageCraftingRecipe("2", ModCraftingRecipes.recipeBloodPendant)); - - judgementCloaks = new ALexiconEntry(LibLexicon.BAUBLE_JUDGEMENT_CLOAKS, categoryBaubles); - judgementCloaks.setLexiconPages(new PageText("0"), new PageText("1"), - new PageCraftingRecipe("2", ModCraftingRecipes.recipeHolyCloak), - new PageCraftingRecipe("3", ModCraftingRecipes.recipeUnholyCloak)); - - monocle = new BLexiconEntry(LibLexicon.BAUBLE_MONOCLE, categoryBaubles); - monocle.setPriority().setLexiconPages(new PageText("0"), new PageText("2"), - new PageCraftingRecipe("1", ModCraftingRecipes.recipeMonocle)); - - swapRing = new BLexiconEntry(LibLexicon.BAUBLE_SWAP_RING, categoryBaubles); - swapRing.setLexiconPages(new PageText("0"), new PageCraftingRecipe("1", ModCraftingRecipes.recipeSwapRing)); - - speedUpBelt = new BLexiconEntry(LibLexicon.BAUBLE_SPEED_UP_BELT, categoryBaubles); - speedUpBelt.setLexiconPages(new PageText("0"), - new PageCraftingRecipe("1", ModCraftingRecipes.recipeSpeedUpBelt)); - - baubleBox = new BLexiconEntry(LibLexicon.BAUBLE_BOX, categoryBaubles); - baubleBox.setLexiconPages(new PageText("0"), new PageCraftingRecipe("1", ModCraftingRecipes.recipeBaubleCase)) - .setPriority(); - - // ALFHOMANCY ENTRIES - alfhomancyIntro = new BLexiconEntry(LibLexicon.ALF_INTRO, categoryAlfhomancy); - alfhomancyIntro.setPriority() - .setLexiconPages(new PageText("0"), new PageText("1"), - new PageCraftingRecipe("2", ModCraftingRecipes.recipeAlfPortal), - new PageCraftingRecipe("3", ModCraftingRecipes.recipeNaturaPylon), - new PageMultiblock("4", ModMultiblocks.alfPortal), new PageText("5"), new PageText("6"), - new PageText("7")) - .setIcon(new ItemStack(ModItems.lexicon)); - - elvenMessage = new ALexiconEntry(LibLexicon.ALF_MESSAGE, categoryAlfhomancy); - elvenMessage.setPriority() - .setLexiconPages(new PageImage("0", LibResources.ENTRY_ELVEN_GARDE), new PageLoreText("1"), - new PageLoreText("2"), new PageLoreText("3"), new PageLoreText("4"), new PageLoreText("5"), - new PageLoreText("6")) - .setIcon(new ItemStack(Items.writable_book)); - - elvenResources = new ALexiconEntry(LibLexicon.ALF_RESOURCES, categoryAlfhomancy); - elvenResources.setPriority() - .setLexiconPages(new PageText("0"), new PageElvenRecipe("1", ModElvenTradeRecipes.dreamwoodRecipe), - new PageText("2"), new PageCraftingRecipe("10", ModCraftingRecipes.recipeDreamwoodTwig), - new PageElvenRecipe("3", ModElvenTradeRecipes.elementiumRecipes), - new PageElvenRecipe("4", ModElvenTradeRecipes.pixieDustRecipe), - new PageElvenRecipe("5", ModElvenTradeRecipes.dragonstoneRecipes), new PageText("6"), - new PageElvenRecipe("7", ModElvenTradeRecipes.elvenQuartzRecipe), new PageText("8"), - new PageElvenRecipe("9", ModElvenTradeRecipes.alfglassRecipe)) - .setIcon(new ItemStack(ModItems.manaResource, 1, 9)); - - gaiaRitual = new ALexiconEntry(LibLexicon.ALF_GAIA_RITUAL, categoryAlfhomancy); - gaiaRitual.setLexiconPages(new PageText("0"), new PageCraftingRecipe("1", ModCraftingRecipes.recipeGaiaPylon), - new PageMultiblock("2", ModMultiblocks.gaiaRitual), new PageText("3"), new PageText("4"), - new PageText("5")).setIcon(new ItemStack(ModItems.manaResource, 1, 5)); - LexiconRecipeMappings.map(new ItemStack(ModItems.manaResource, 1, 5), gaiaRitual, 0); - - gaiaRitualHardmode = new ALexiconEntry(LibLexicon.ALF_GAIA_RITUAL_HARDMODE, categoryAlfhomancy); - gaiaRitualHardmode - .setLexiconPages(new PageText("0"), new PageText("1"), - new PageCraftingRecipe("2", ModCraftingRecipes.recipeGaiaIngot)) - .setIcon(new ItemStack(ModItems.manaResource, 1, 14)); - - elvenLore = new ALexiconEntry(LibLexicon.ALF_LORE, categoryAlfhomancy); - elvenLore - .setLexiconPages(new PageText("0"), new PageLoreText("1"), new PageLoreText("2"), new PageLoreText("3"), - new PageLoreText("4"), new PageLoreText("5"), new PageLoreText("6"), new PageLoreText("7")) - .setIcon(new ItemStack(Items.writable_book)); - - if (ConfigHandler.relicsEnabled) { - relics = new ALexiconEntry(LibLexicon.ALF_RELICS, categoryAlfhomancy); - relics.setLexiconPages(new PageText("0")).setIcon(new ItemStack(ModItems.dice)); - - relicInfo = new RLexiconEntry(LibLexicon.ALF_RELIC_INFO, categoryAlfhomancy, null); - relicInfo.setLexiconPages(new PageText("0"), new PageText("1")).setIcon(new ItemStack(ModItems.dice)); - - infiniteFruit = new RLexiconEntry(LibLexicon.ALF_INFINITE_FRUIT, categoryAlfhomancy, - ModAchievements.relicInfiniteFruit); - infiniteFruit.setLexiconPages(new PageText("0")); - - kingKey = new RLexiconEntry(LibLexicon.ALF_KING_KEY, categoryAlfhomancy, ModAchievements.relicKingKey); - kingKey.setLexiconPages(new PageText("0")); - - flugelEye = new RLexiconEntry(LibLexicon.ALF_FLUGEL_EYE, categoryAlfhomancy, - ModAchievements.relicFlugelEye); - flugelEye.setLexiconPages(new PageText("0"), new PageText("1")); - - thorRing = new RLexiconEntry(LibLexicon.ALF_THOR_RING, categoryAlfhomancy, ModAchievements.relicThorRing); - thorRing.setLexiconPages(new PageText("0")); - - lokiRing = new RLexiconEntry(LibLexicon.ALF_LOKI_RING, categoryAlfhomancy, ModAchievements.relicLokiRing); - lokiRing.setLexiconPages(new PageText("0"), new PageText("1"), new PageText("2"), new PageText("3")); - - odinRing = new RLexiconEntry(LibLexicon.ALF_ODIN_RING, categoryAlfhomancy, ModAchievements.relicOdinRing); - odinRing.setLexiconPages(new PageText("0")); - } - - // MISCLENAEOUS ENTRIES - unstableBlocks = new BLexiconEntry(LibLexicon.MISC_UNSTABLE_BLOCKS, categoryMisc); - unstableBlocks.setLexiconPages(new PageText("0"), new PageImage("1", LibResources.ENTRY_UNSTABLE_BLOCK), - new PageCraftingRecipe("2", ModCraftingRecipes.recipesUnstableBlocks), new PageText("3"), - new PageImage("4", LibResources.ENTRY_UNSTABLE_BEACON), - new PageCraftingRecipe("5", ModCraftingRecipes.recipesManaBeacons), new PageText("6"), - new PageCraftingRecipe("7", ModCraftingRecipes.recipesSignalFlares)); - - decorativeBlocks = new BLexiconEntry(LibLexicon.MISC_DECORATIVE_BLOCKS, categoryMisc); - if (ConfigHandler.darkQuartzEnabled) - decorativeBlocks.setLexiconPages(new PageText("0"), - new PageCraftingRecipe("1", ModCraftingRecipes.recipeLivingrockDecor1), - new PageCraftingRecipe("2", ModCraftingRecipes.recipeLivingrockDecor2), - new PageCraftingRecipe("3", ModCraftingRecipes.recipeLivingrockDecor3), - new PageCraftingRecipe("4", ModCraftingRecipes.recipeLivingrockDecor4), - new PageCraftingRecipe("5", ModCraftingRecipes.recipeLivingwoodDecor1), - new PageCraftingRecipe("6", ModCraftingRecipes.recipeLivingwoodDecor2), - new PageCraftingRecipe("7", ModCraftingRecipes.recipeLivingwoodDecor3), - new PageCraftingRecipe("8", ModCraftingRecipes.recipeLivingwoodDecor4), - new PageCraftingRecipe("9", ModCraftingRecipes.recipeLivingwoodDecor5), new PageText("10"), - new PageCraftingRecipe("11", ModCraftingRecipes.recipeDarkQuartz), - new PageManaInfusionRecipe("12", ModManaInfusionRecipes.manaQuartzRecipe), - new PageCraftingRecipe("13", ModCraftingRecipes.recipeBlazeQuartz), - new PageCraftingRecipe("14", ModCraftingRecipes.recipesLavenderQuartz), - new PageCraftingRecipe("15", ModCraftingRecipes.recipeRedQuartz), - new PageCraftingRecipe("23", ModCraftingRecipes.recipeSunnyQuartz), new PageText("16"), - new PageCraftingRecipe("17", ModCraftingRecipes.recipeReedBlock), - new PageCraftingRecipe("18", ModCraftingRecipes.recipeThatch), - new PageCraftingRecipe("19", ModCraftingRecipes.recipeRoofTile), - new PageCraftingRecipe("20", ModCraftingRecipes.recipeNetherBrick), - new PageCraftingRecipe("21", ModCraftingRecipes.recipeSoulBrick), - new PageCraftingRecipe("22", ModCraftingRecipes.recipeSnowBrick)); - else - decorativeBlocks.setLexiconPages(new PageText("0"), - new PageCraftingRecipe("1", ModCraftingRecipes.recipeLivingrockDecor1), - new PageCraftingRecipe("2", ModCraftingRecipes.recipeLivingrockDecor2), - new PageCraftingRecipe("3", ModCraftingRecipes.recipeLivingrockDecor3), - new PageCraftingRecipe("4", ModCraftingRecipes.recipeLivingrockDecor4), - new PageCraftingRecipe("5", ModCraftingRecipes.recipeLivingwoodDecor1), - new PageCraftingRecipe("6", ModCraftingRecipes.recipeLivingwoodDecor2), - new PageCraftingRecipe("7", ModCraftingRecipes.recipeLivingwoodDecor3), - new PageCraftingRecipe("8", ModCraftingRecipes.recipeLivingwoodDecor4), - new PageCraftingRecipe("9", ModCraftingRecipes.recipeLivingwoodDecor5), new PageText("10"), - new PageManaInfusionRecipe("12", ModManaInfusionRecipes.manaQuartzRecipe), - new PageCraftingRecipe("13", ModCraftingRecipes.recipeBlazeQuartz), - new PageCraftingRecipe("14", ModCraftingRecipes.recipesLavenderQuartz), - new PageCraftingRecipe("15", ModCraftingRecipes.recipeRedQuartz), - new PageCraftingRecipe("23", ModCraftingRecipes.recipeSunnyQuartz), new PageText("16"), - new PageCraftingRecipe("17", ModCraftingRecipes.recipeReedBlock), - new PageCraftingRecipe("18", ModCraftingRecipes.recipeThatch), - new PageCraftingRecipe("19", ModCraftingRecipes.recipeRoofTile), - new PageCraftingRecipe("20", ModCraftingRecipes.recipeNetherBrick), - new PageCraftingRecipe("21", ModCraftingRecipes.recipeSoulBrick), - new PageCraftingRecipe("22", ModCraftingRecipes.recipeSnowBrick)); - - dispenserTweaks = new BLexiconEntry(LibLexicon.MISC_DISPENSER_TWEAKS, categoryMisc); - dispenserTweaks.setLexiconPages(new PageText("0")).setPriority().setIcon(new ItemStack(Blocks.dispenser)); - - shinyFlowers = new BLexiconEntry(LibLexicon.MISC_SHINY_FLOWERS, categoryMisc); - shinyFlowers.setLexiconPages(new PageText("0"), new PageText("3"), - new PageCraftingRecipe("1", ModCraftingRecipes.recipesShinyFlowers), - new PageCraftingRecipe("2", ModCraftingRecipes.recipesMiniIsland)); - - prismarine = new BLexiconEntry(LibLexicon.MISC_PRISMARINE, categoryMisc); - prismarine.setLexiconPages(new PageText("0"), new PageText("1"), - new PageManaInfusionRecipe("2", ModManaAlchemyRecipes.prismarineRecipe), - new PageCraftingRecipe("3", ModCraftingRecipes.recipePrismarine), - new PageCraftingRecipe("4", ModCraftingRecipes.recipePrismarineBrick), - new PageCraftingRecipe("5", ModCraftingRecipes.recipeDarkPrismarine), - new PageCraftingRecipe("6", ModCraftingRecipes.recipeSeaLamp)); - - tinyPotato = new BLexiconEntry(LibLexicon.MISC_TINY_POTATO, categoryMisc); - tinyPotato.setLexiconPages(new PageText("0"), - new PageManaInfusionRecipe("1", ModManaInfusionRecipes.tinyPotatoRecipe)); - - headCreating = new HLexiconEntry(LibLexicon.MISC_HEAD_CREATING, categoryMisc); - headCreating.setLexiconPages(new PageText("0"), new PageText("2"), - new PageRuneRecipe("1", ModRuneRecipes.recipeHead)); - - azulejo = new BLexiconEntry(LibLexicon.MISC_AZULEJO, categoryMisc); - azulejo.setLexiconPages(new PageText("0"), new PageImage("1", LibResources.ENTRY_AZULEJOS), - new PageCraftingRecipe("2", ModCraftingRecipes.recipeAzulejo), - new PageCraftingRecipe("3", ModCraftingRecipes.recipesAzulejoCycling)); - - starfield = new ALexiconEntry(LibLexicon.MISC_STARFIELD, categoryMisc); - starfield.setLexiconPages(new PageText("0"), new PageCraftingRecipe("1", ModCraftingRecipes.recipeStarfield)); - - dirtPath = new BLexiconEntry(LibLexicon.MISC_DIRT_PATH, categoryMisc); - dirtPath.setLexiconPages(new PageText("0"), new PageCraftingRecipe("1", ModCraftingRecipes.recipeDirtPath), - new PageCraftingRecipe("2", ModCraftingRecipes.recipeDirtPathSlab)); - - mushrooms = new BLexiconEntry(LibLexicon.MISC_MUSHROOMS, categoryMisc); - mushrooms.setLexiconPages(new PageText("0"), new PageCraftingRecipe("1", ModCraftingRecipes.recipesMushrooms)); - - phantomInk = new BLexiconEntry(LibLexicon.MISC_PHANTOM_INK, categoryMisc); - phantomInk.setLexiconPages(new PageText("0"), new PageCraftingRecipe("1", ModCraftingRecipes.recipePhantomInk)); - - if (ConfigHandler.stones18Enabled) { - stoneAlchemy = new BLexiconEntry(LibLexicon.MISC_STONE_ALCHEMY, categoryMisc); - stoneAlchemy.setLexiconPages(new PageText("0"), - new PageManaInfusionRecipe("1", ModManaAlchemyRecipes.stoneRecipes), - new PageCraftingRecipe("2", ModCraftingRecipes.recipe18StonePolish), - new PageCraftingRecipe("3", ModCraftingRecipes.recipe18StoneBrick), - new PageCraftingRecipe("4", ModCraftingRecipes.recipe18StoneChisel)); - } - - blazeBlock = new BLexiconEntry(LibLexicon.MISC_BLAZE_BLOCK, categoryMisc); - blazeBlock.setLexiconPages(new PageText("0"), new PageCraftingRecipe("1", ModCraftingRecipes.recipeBlazeBlock)); - LexiconRecipeMappings.map(new ItemStack(Blocks.obsidian), blazeBlock, 0); - - challenges = new BLexiconEntry(LibLexicon.MISC_CHALLENGES, categoryMisc); - challenges.setLexiconPages(new PageText("0"), new PageText("1"), new PageText("2")).setPriority() - .setIcon(new ItemStack(ModItems.cosmetic, 1, 31)); - - cacophonium = new BLexiconEntry(LibLexicon.MISC_CACOPHONIUM, categoryMisc); - cacophonium.setLexiconPages(new PageText("0"), - new PageCraftingRecipe("1", ModCraftingRecipes.recipeCacophonium), new PageText("2")); - - pavement = new BLexiconEntry(LibLexicon.MISC_PAVEMENT, categoryMisc); - pavement.setLexiconPages(new PageText("0"), new PageCraftingRecipe("1", ModCraftingRecipes.recipesPavement)); - - preventingDecay = new DLexiconEntry(LibLexicon.MISC_PRENTING_DECAY, categoryMisc); - preventingDecay.setLexiconPages(new PageText("0")).setIcon(new ItemStack(Blocks.deadbush)); - - if (Botania.bcTriggersLoaded) { - bcIntegration = new CLexiconEntry(LibLexicon.MISC_BC_INTEGRATION, categoryMisc, "BuildCraft"); - bcIntegration.setLexiconPages(new PageText("0")).setIcon(new ItemStack(Items.redstone)); - } - } - - public static void postInit() { - if (SheddingHandler.hasShedding()) { - shedding = new BLexiconEntry(LibLexicon.MISC_SHEDDING, BotaniaAPI.categoryMisc); - shedding.setLexiconPages(new PageText("0")).setPriority().setIcon(new ItemStack(Items.feather)); - SheddingHandler.addToLexicon(); - } - - if (Botania.thaumcraftLoaded) { - tcIntegration = new CLexiconEntry(LibLexicon.MISC_TC_INTEGRATION, BotaniaAPI.categoryMisc, "Thaumcraft"); - - if (ConfigHandler.enableThaumcraftStablizers) - tcIntegration.setLexiconPages(new PageText("0"), new PageText("1"), - new PageCraftingRecipe("2", ModCraftingRecipes.recipeHelmetOfRevealing), new PageText("3"), - new PageManaInfusionRecipe("4", ModManaInfusionRecipes.manaInkwellRecipe), new PageText("5"), - new PageBrew(ModBrewRecipes.warpWardBrew, "6a", "6b")) - .setIcon(new ItemStack(ModItems.manaInkwell)); - else - tcIntegration.setLexiconPages(new PageText("0"), new PageText("1"), - new PageCraftingRecipe("2", ModCraftingRecipes.recipeHelmetOfRevealing), new PageText("3"), - new PageManaInfusionRecipe("4", ModManaInfusionRecipes.manaInkwellRecipe), - new PageBrew(ModBrewRecipes.warpWardBrew, "6a", "6b")) - .setIcon(new ItemStack(ModItems.manaInkwell)); - } - - if (Botania.etFuturumLoaded) { - banners = new CLexiconEntry(LibLexicon.MISC_BANNERS, BotaniaAPI.categoryMisc, "EtFuturum"); - banners.setLexiconPages(new PageText("0"), new PageImage("1", LibResources.ENTRY_BANNERS)) - .setIcon(new ItemStack(ModItems.lexicon)); - } - } + public static LexiconEntry welcome; + public static LexiconEntry tutorial; + + public static LexiconEntry flowers; + public static LexiconEntry apothecary; + public static LexiconEntry lexicon; + public static LexiconEntry wand; + public static LexiconEntry pureDaisy; + public static LexiconEntry runicAltar; + public static LexiconEntry terrasteel; + public static LexiconEntry blackLotus; + public static LexiconEntry flowerBag; + public static LexiconEntry gardenOfGlass; + + public static LexiconEntry manaIntro; + public static LexiconEntry spreader; + public static LexiconEntry pool; + public static LexiconEntry lenses; + public static LexiconEntry distributor; + public static LexiconEntry manaVoid; + public static LexiconEntry manaTablet; + public static LexiconEntry manaMirror; + public static LexiconEntry manaDetector; + public static LexiconEntry redstoneSpreader; + public static LexiconEntry manastar; + public static LexiconEntry dreamwoodSpreader; + public static LexiconEntry elvenLenses; + public static LexiconEntry sparks; + public static LexiconEntry sparkUpgrades; + public static LexiconEntry rfGenerator; + public static LexiconEntry prism; + public static LexiconEntry poolCart; + public static LexiconEntry sparkChanger; + public static LexiconEntry bellows; + + public static LexiconEntry functionalIntro; + public static LexiconEntry flowerShrinking; + public static LexiconEntry flowerSpeed; + public static LexiconEntry jadedAmaranthus; + public static LexiconEntry bellethorne; + public static LexiconEntry dreadthorne; + public static LexiconEntry heiseiDream; + public static LexiconEntry tigerseye; + public static LexiconEntry orechid; + public static LexiconEntry orechidIgnem; + public static LexiconEntry fallenKanade; + public static LexiconEntry exoflame; + public static LexiconEntry agricarnation; + public static LexiconEntry hopperhock; + public static LexiconEntry tangleberrie; + public static LexiconEntry jiyuulia; + public static LexiconEntry rannuncarpus; + public static LexiconEntry hyacidus; + public static LexiconEntry pollidisiac; + public static LexiconEntry clayconia; + public static LexiconEntry loonium; + public static LexiconEntry daffomill; + public static LexiconEntry vinculotus; + public static LexiconEntry spectranthemum; + public static LexiconEntry medumone; + public static LexiconEntry marimorphosis; + public static LexiconEntry bubbell; + public static LexiconEntry solegnolia; + + public static LexiconEntry generatingIntro; + public static LexiconEntry passiveGen; + public static LexiconEntry primusLoci; + public static LexiconEntry daybloom; + public static LexiconEntry nightshade; + public static LexiconEntry endoflame; + public static LexiconEntry hydroangeas; + public static LexiconEntry thermalily; + public static LexiconEntry arcaneRose; + public static LexiconEntry munchdew; + public static LexiconEntry entropinnyum; + public static LexiconEntry kekimurus; + public static LexiconEntry gourmaryllis; + public static LexiconEntry narslimmus; + public static LexiconEntry spectrolus; + public static LexiconEntry rafflowsia; + public static LexiconEntry dandelifeon; + + public static LexiconEntry pylon; + public static LexiconEntry manaEnchanting; + public static LexiconEntry turntable; + public static LexiconEntry alchemy; + public static LexiconEntry openCrate; + public static LexiconEntry forestEye; + public static LexiconEntry forestDrum; + public static LexiconEntry platform; + public static LexiconEntry conjurationCatalyst; + public static LexiconEntry spectralPlatform; + public static LexiconEntry gatherDrum; + public static LexiconEntry craftCrate; + public static LexiconEntry brewery; + public static LexiconEntry flasks; + public static LexiconEntry complexBrews; + public static LexiconEntry incense; + public static LexiconEntry hourglass; + public static LexiconEntry ghostRail; + public static LexiconEntry canopyDrum; + public static LexiconEntry cocoon; + public static LexiconEntry manaBomb; + public static LexiconEntry teruTeruBozu; + public static LexiconEntry avatar; + public static LexiconEntry felPumpkin; + + public static LexiconEntry manaBlaster; + public static LexiconEntry grassSeeds; + public static LexiconEntry dirtRod; + public static LexiconEntry terraformRod; + public static LexiconEntry manasteelGear; + public static LexiconEntry terrasteelArmor; + public static LexiconEntry grassHorn; + public static LexiconEntry terraBlade; + public static LexiconEntry terraPick; + public static LexiconEntry waterRod; + public static LexiconEntry elfGear; + public static LexiconEntry openBucket; + public static LexiconEntry rainbowRod; + public static LexiconEntry tornadoRod; + public static LexiconEntry fireRod; + public static LexiconEntry vineBall; + public static LexiconEntry laputaShard; + public static LexiconEntry virus; + public static LexiconEntry skyDirtRod; + public static LexiconEntry glassPick; + public static LexiconEntry diviningRod; + public static LexiconEntry gravityRod; + public static LexiconEntry regenIvy; + public static LexiconEntry missileRod; + public static LexiconEntry craftingHalo; + public static LexiconEntry clip; + public static LexiconEntry cobbleRod; + public static LexiconEntry smeltRod; + public static LexiconEntry worldSeed; + public static LexiconEntry spellCloth; + public static LexiconEntry thornChakram; + public static LexiconEntry fireChakram; + public static LexiconEntry overgrowthSeed; + public static LexiconEntry livingwoodBow; + public static LexiconEntry crystalBow; + public static LexiconEntry temperanceStone; + public static LexiconEntry terraAxe; + public static LexiconEntry obedienceStick; + public static LexiconEntry slimeBottle; + public static LexiconEntry exchangeRod; + public static LexiconEntry manaweave; + public static LexiconEntry autocraftingHalo; + public static LexiconEntry sextant; + + public static LexiconEntry enderAir; + public static LexiconEntry enderEyeBlock; + public static LexiconEntry pistonRelay; + public static LexiconEntry enderHand; + public static LexiconEntry enderDagger; + public static LexiconEntry spawnerClaw; + public static LexiconEntry redString; + public static LexiconEntry flightTiara; + public static LexiconEntry corporea; + public static LexiconEntry corporeaIndex; + public static LexiconEntry corporeaFunnel; + public static LexiconEntry corporeaInterceptor; + public static LexiconEntry endStoneDecor; + public static LexiconEntry spawnerMover; + public static LexiconEntry keepIvy; + public static LexiconEntry blackHoleTalisman; + public static LexiconEntry corporeaCrystalCube; + public static LexiconEntry luminizerTransport; + public static LexiconEntry starSword; + public static LexiconEntry thunderSword; + public static LexiconEntry corporeaRetainer; + + public static LexiconEntry baublesIntro; + public static LexiconEntry cosmeticBaubles; + public static LexiconEntry tinyPlanet; + public static LexiconEntry manaRing; + public static LexiconEntry auraRing; + public static LexiconEntry travelBelt; + public static LexiconEntry knockbacklBelt; + public static LexiconEntry icePendant; + public static LexiconEntry lavaPendant; + public static LexiconEntry goldLaurel; + public static LexiconEntry waterRing; + public static LexiconEntry miningRing; + public static LexiconEntry magnetRing; + public static LexiconEntry divaCharm; + public static LexiconEntry pixieRing; + public static LexiconEntry superTravelBelt; + public static LexiconEntry reachRing; + public static LexiconEntry itemFinder; + public static LexiconEntry superLavaPendant; + public static LexiconEntry bloodPendant; + public static LexiconEntry judgementCloaks; + public static LexiconEntry monocle; + public static LexiconEntry swapRing; + public static LexiconEntry speedUpBelt; + public static LexiconEntry baubleBox; + + public static LexiconEntry alfhomancyIntro; + public static LexiconEntry elvenMessage; + public static LexiconEntry elvenResources; + public static LexiconEntry gaiaRitual; + public static LexiconEntry gaiaRitualHardmode; + public static LexiconEntry elvenLore; + public static LexiconEntry relics; + public static LexiconEntry relicInfo; + public static LexiconEntry infiniteFruit; + public static LexiconEntry kingKey; + public static LexiconEntry flugelEye; + public static LexiconEntry thorRing; + public static LexiconEntry lokiRing; + public static LexiconEntry odinRing; + + public static LexiconEntry unstableBlocks; + public static LexiconEntry decorativeBlocks; + public static LexiconEntry dispenserTweaks; + public static LexiconEntry shinyFlowers; + public static LexiconEntry prismarine; + public static LexiconEntry shedding; + public static LexiconEntry tinyPotato; + public static LexiconEntry headCreating; + public static LexiconEntry azulejo; + public static LexiconEntry starfield; + public static LexiconEntry dirtPath; + public static LexiconEntry mushrooms; + public static LexiconEntry phantomInk; + public static LexiconEntry stoneAlchemy; + public static LexiconEntry blazeBlock; + public static LexiconEntry challenges; + public static LexiconEntry cacophonium; + public static LexiconEntry pavement; + public static LexiconEntry preventingDecay; + + public static LexiconEntry tcIntegration; + public static LexiconEntry bcIntegration; + public static LexiconEntry banners; + + public static void preInit() { + BotaniaAPI.addCategory(BotaniaAPI.categoryBasics = new BLexiconCategory(LibLexicon.CATEGORY_BASICS, 9)); + BotaniaAPI.addCategory(BotaniaAPI.categoryMana = new BLexiconCategory(LibLexicon.CATEGORY_MANA, 5)); + BotaniaAPI.addCategory( + BotaniaAPI.categoryGenerationFlowers = new BLexiconCategory(LibLexicon.CATEGORY_GENERATION_FLOWERS, 5)); + BotaniaAPI.addCategory( + BotaniaAPI.categoryFunctionalFlowers = new BLexiconCategory(LibLexicon.CATEGORY_FUNCTIONAL_FLOWERS, 5)); + BotaniaAPI.addCategory(BotaniaAPI.categoryDevices = new BLexiconCategory(LibLexicon.CATEGORY_DEVICES, 5)); + BotaniaAPI.addCategory(BotaniaAPI.categoryTools = new BLexiconCategory(LibLexicon.CATEGORY_TOOLS, 5)); + BotaniaAPI.addCategory(BotaniaAPI.categoryBaubles = new BLexiconCategory(LibLexicon.CATEGORY_BAUBLES, 5)); + BotaniaAPI.addCategory(BotaniaAPI.categoryEnder = new BLexiconCategory(LibLexicon.CATEGORY_ENDER, 5)); + BotaniaAPI.addCategory(BotaniaAPI.categoryAlfhomancy = new BLexiconCategory(LibLexicon.CATEGORY_ALFHOMANCY, 5)); + BotaniaAPI.addCategory(BotaniaAPI.categoryMisc = new BLexiconCategory(LibLexicon.CATEGORY_MISC, 0)); + } + + public static void init() { + LexiconCategory categoryBasics = BotaniaAPI.categoryBasics; + LexiconCategory categoryMana = BotaniaAPI.categoryMana; + LexiconCategory categoryGenerationFlowers = BotaniaAPI.categoryGenerationFlowers; + LexiconCategory categoryFunctionalFlowers = BotaniaAPI.categoryFunctionalFlowers; + LexiconCategory categoryDevices = BotaniaAPI.categoryDevices; + LexiconCategory categoryTools = BotaniaAPI.categoryTools; + LexiconCategory categoryBaubles = BotaniaAPI.categoryBaubles; + LexiconCategory categoryEnder = BotaniaAPI.categoryEnder; + LexiconCategory categoryAlfhomancy = BotaniaAPI.categoryAlfhomancy; + LexiconCategory categoryMisc = BotaniaAPI.categoryMisc; + + // BASICS ENTRIES + welcome = new WLexiconEntry(); + tutorial = new TLexiconEntry(); + + flowers = new BLexiconEntry(LibLexicon.BASICS_FLOWERS, categoryBasics); + flowers.setPriority() + .setLexiconPages( + new PageText("0"), + new PageImage("1", LibResources.ENTRY_FLOWERS), + new PageText("2"), + new PageCraftingRecipe("3", ModCraftingRecipes.recipesPetals), + new PageCraftingRecipe("4", ModCraftingRecipes.recipePestleAndMortar), + new PageCraftingRecipe("5", ModCraftingRecipes.recipesDyes), + new PageText("6"), + new PageCraftingRecipe("7", ModCraftingRecipes.recipeFertilizerPowder), + new PageCraftingRecipe("8", ModCraftingRecipes.recipeFerilizerDye), + new PageText("10"), + new PageText("12"), + new PageCraftingRecipe("11", ModCraftingRecipes.recipesPetalsDouble), + new PageCraftingRecipe("9", ModCraftingRecipes.recipesPetalBlocks)) + .setIcon(new ItemStack(ModBlocks.flower, 1, 6)); + + apothecary = new BLexiconEntry(LibLexicon.BASICS_APOTHECARY, categoryBasics); + apothecary + .setPriority() + .setLexiconPages( + new PageText("0"), + new PageImage("1", LibResources.ENTRY_APOTHECARY), + new PageText("2"), + new PageText("3"), + new PageText("4"), + new PageText("7"), + new PageText("6"), + new PageCraftingRecipe("5", ModCraftingRecipes.recipesApothecary)); + + lexicon = new BLexiconEntry(LibLexicon.BASICS_LEXICON, categoryBasics); + lexicon.setPriority() + .setLexiconPages( + new PageText("0"), + new PageText("3"), + new PageCraftingRecipe("1", ModCraftingRecipes.recipeLexicon), + new PageText("2")); + + wand = new BLexiconEntry(LibLexicon.BASICS_WAND, categoryBasics); + wand.setPriority() + .setLexiconPages( + new PageText("0"), + new PageText("1"), + new PageText("2"), + new PageCraftingRecipe("3", ModCraftingRecipes.recipesTwigWand)); + + pureDaisy = new BLexiconEntry(LibLexicon.BASICS_PURE_DAISY, categoryBasics); + pureDaisy + .setPriority() + .setLexiconPages( + new PageText("0"), + new PageImage("1", LibResources.ENTRY_PURE_DAISY), + new PageCraftingRecipe("2", ModCraftingRecipes.recipeLivingwoodTwig), + new PageText("4"), + new PagePetalRecipe("3", ModPetalRecipes.pureDaisyRecipe)) + .setIcon(ItemBlockSpecialFlower.ofType(LibBlockNames.SUBTILE_PUREDAISY)); + pureDaisy.addExtraDisplayedRecipe(new ItemStack(ModBlocks.livingwood)); + pureDaisy.addExtraDisplayedRecipe(new ItemStack(ModBlocks.livingrock)); + LexiconRecipeMappings.map(new ItemStack(ModBlocks.livingwood), pureDaisy, 1); + LexiconRecipeMappings.map(new ItemStack(ModBlocks.livingrock), pureDaisy, 1); + + runicAltar = new BLexiconEntry(LibLexicon.BASICS_RUNE_ALTAR, categoryBasics); + runicAltar + .setPriority() + .setLexiconPages( + new PageText("21"), + new PageText("0"), + new PageText("1"), + new PageCraftingRecipe("2", ModCraftingRecipes.recipesRuneAltar), + new PageText("3"), + new PageText("20"), + new PageText("22"), + new PageRuneRecipe("4", ModRuneRecipes.recipeWaterRune), + new PageRuneRecipe("5", ModRuneRecipes.recipesEarthRune), + new PageRuneRecipe("6", ModRuneRecipes.recipesAirRune), + new PageRuneRecipe("7", ModRuneRecipes.recipeFireRune), + new PageRuneRecipe("8", ModRuneRecipes.recipeSpringRune), + new PageRuneRecipe("9", ModRuneRecipes.recipeSummerRune), + new PageRuneRecipe("10", ModRuneRecipes.recipeAutumnRune), + new PageRuneRecipe("11", ModRuneRecipes.recipesWinterRune), + new PageRuneRecipe("12", ModRuneRecipes.recipeManaRune), + new PageRuneRecipe("13", ModRuneRecipes.recipeLustRune), + new PageRuneRecipe("14", ModRuneRecipes.recipeGluttonyRune), + new PageRuneRecipe("15", ModRuneRecipes.recipeGreedRune), + new PageRuneRecipe("16", ModRuneRecipes.recipeSlothRune), + new PageRuneRecipe("17", ModRuneRecipes.recipeWrathRune), + new PageRuneRecipe("18", ModRuneRecipes.recipeEnvyRune), + new PageRuneRecipe("19", ModRuneRecipes.recipePrideRune)); + + terrasteel = new BLexiconEntry(LibLexicon.BASICS_TERRASTEEL, categoryBasics); + terrasteel + .setLexiconPages( + new PageText("0"), + new PageCraftingRecipe("1", ModCraftingRecipes.recipeTerraPlate), + new PageText("2"), + new PageMultiblock("4", ModMultiblocks.terrasteelPlate), + new PageTerrasteel("3")) + .setIcon(new ItemStack(ModItems.manaResource, 1, 4)); + + blackLotus = new BLexiconEntry(LibLexicon.BASICS_BLACK_LOTUS, categoryBasics); + blackLotus.setLexiconPages(new PageText("0")).setIcon(new ItemStack(ModItems.blackLotus)); + blackLotus.addExtraDisplayedRecipe(new ItemStack(ModItems.blackLotus)); + + flowerBag = new BLexiconEntry(LibLexicon.BASICS_FLOWER_BAG, categoryBasics); + flowerBag.setLexiconPages( + new PageText("0"), new PageText("2"), new PageCraftingRecipe("1", ModCraftingRecipes.recipeFlowerBag)); + + if (Botania.gardenOfGlassLoaded) { + gardenOfGlass = new BLexiconEntry(LibLexicon.BASICS_GARDEN_OF_GLASS, categoryBasics); + gardenOfGlass.setLexiconPages( + new PageText("0"), + new PageText("1"), + new PageText("2"), + new PageCraftingRecipe("3", ModCraftingRecipes.recipeRootToSapling), + new PageCraftingRecipe("4", ModCraftingRecipes.recipeRootToFertilizer), + new PageCraftingRecipe("5", ModCraftingRecipes.recipePebbleCobblestone), + new PageText("6"), + new PageManaInfusionRecipe("7", ModManaInfusionRecipes.sugarCaneRecipe), + new PageCraftingRecipe("8", ModCraftingRecipes.recipeMagmaToSlimeball), + new PageText("9"), + new PageText("11"), + new PageCraftingRecipe("12", ModCraftingRecipes.recipeEndPortal)); + gardenOfGlass.setPriority().setIcon(new ItemStack(ModItems.manaResource, 1, 20)); + } + + if (Botania.thaumcraftLoaded) + new CLexiconEntry("wrap", categoryBasics, "Thaumcraft").setLexiconPages(new PageText("0")); // lel + + // MANA ENTRIES + manaIntro = new BLexiconEntry(LibLexicon.MANA_INTRO, categoryMana); + manaIntro.setPriority().setLexiconPages(new PageText("0"), new PageText("1"), new PageText("2")); + + spreader = new BLexiconEntry(LibLexicon.MANA_SPREADER, categoryMana); + spreader.setPriority() + .setLexiconPages( + new PageText("0"), + new PageImage("1", LibResources.ENTRY_SPREADER), + new PageText("2"), + new PageText("3"), + new PageText("4"), + new PageText("11"), + new PageCraftingRecipe("5", ModCraftingRecipes.recipesSpreader), + new PageText("10")); + + pool = new BLexiconEntry(LibLexicon.MANA_POOL, categoryMana); + pool.setPriority() + .setLexiconPages( + new PageText("0"), + new PageText("9"), + new PageCraftingRecipe("1", ModCraftingRecipes.recipePool), + new PageCraftingRecipe("10", ModCraftingRecipes.recipePoolDiluted), + new PageText("14"), + new PageText("2"), + new PageText("8"), + new PageManaInfusionRecipe("3", ModManaInfusionRecipes.manasteelRecipes), + new PageManaInfusionRecipe("4", ModManaInfusionRecipes.manaPearlRecipe), + new PageManaInfusionRecipe("5", ModManaInfusionRecipes.manaDiamondRecipes), + new PageManaInfusionRecipe("6", ModManaInfusionRecipes.manaPowderRecipes), + new PageManaInfusionRecipe("11", ModManaInfusionRecipes.managlassRecipe), + new PageManaInfusionRecipe("12", ModManaInfusionRecipes.manaStringRecipe), + new PageCraftingRecipe("13", ModCraftingRecipes.recipeCobweb), + new PageManaInfusionRecipe("7", ModManaInfusionRecipes.manaCookieRecipe)) + .setIcon(new ItemStack(ModBlocks.pool)); + + sparks = new BLexiconEntry(LibLexicon.MANA_SPARKS, categoryMana); + sparks.setPriority() + .setLexiconPages( + new PageText("0"), + new PageText("1"), + new PageText("3"), + new PageCraftingRecipe("2", ModCraftingRecipes.recipesSpark)); + + sparkUpgrades = new ALexiconEntry(LibLexicon.MANA_SPARK_UPGRADES, categoryMana); + sparkUpgrades.setLexiconPages( + new PageText("0"), + new PageText("1"), + new PageText("2"), + new PageText("3"), + new PageText("4"), + new PageCraftingRecipe("5", ModCraftingRecipes.recipesSparkUpgrades)); + + if (ConfigHandler.fluxfieldEnabled) { + rfGenerator = new BLexiconEntry(LibLexicon.MANA_RF_GENERATOR, categoryMana); + rfGenerator.setLexiconPages( + new PageText("0"), new PageCraftingRecipe("1", ModCraftingRecipes.recipeRFGenerator)); + } + + lenses = new BLexiconEntry(LibLexicon.MANA_LENSES, categoryMana); + lenses.setLexiconPages( + new PageText("0"), + new PageCraftingRecipe("1", ModCraftingRecipes.recipesManaLens), + new PageText("4"), + new PageText("5"), + new PageText("6"), + new PageCraftingRecipe("7", ModCraftingRecipes.recipeLensVelocity), + new PageText("8"), + new PageCraftingRecipe("9", ModCraftingRecipes.recipeLensPotency), + new PageText("10"), + new PageCraftingRecipe("11", ModCraftingRecipes.recipeLensResistance), + new PageText("12"), + new PageCraftingRecipe("13", ModCraftingRecipes.recipeLensEfficiency), + new PageText("14"), + new PageCraftingRecipe("15", ModCraftingRecipes.recipeLensBounce), + new PageText("16"), + new PageCraftingRecipe("17", ModCraftingRecipes.recipeLensGravity), + new PageText("18"), + new PageCraftingRecipe("19", ModCraftingRecipes.recipeLensBore), + new PageText("20"), + new PageCraftingRecipe("21", ModCraftingRecipes.recipeLensDamaging), + new PageText("22"), + new PageCraftingRecipe("23", ModCraftingRecipes.recipeLensPhantom), + new PageText("24"), + new PageCraftingRecipe("25", ModCraftingRecipes.recipeLensMagnet), + new PageText("26"), + new PageCraftingRecipe("27", ModCraftingRecipes.recipeLensExplosive), + new PageText("28"), + new PageCraftingRecipe("29", ModCraftingRecipes.recipeLensInfluence), + new PageText("30"), + new PageCraftingRecipe("31", ModCraftingRecipes.recipeLensWeight), + new PageText("32"), + new PageCraftingRecipe("33", ModCraftingRecipes.recipeLensFire), + new PageText("34"), + new PageCraftingRecipe("35", ModCraftingRecipes.recipeLensPiston), + new PageText("36"), + new PageCraftingRecipe("37", ModCraftingRecipes.recipesLensFlash)); + + distributor = new BLexiconEntry(LibLexicon.MANA_DISTRIBUTOR, categoryMana); + distributor.setLexiconPages( + new PageText("0"), new PageCraftingRecipe("1", ModCraftingRecipes.recipeDistributor)); + + manaVoid = new BLexiconEntry(LibLexicon.MANA_VOID, categoryMana); + manaVoid.setLexiconPages(new PageText("0"), new PageCraftingRecipe("1", ModCraftingRecipes.recipeManaVoid)); + + manaTablet = new BLexiconEntry(LibLexicon.MANA_TABLET, categoryMana); + manaTablet + .setPriority() + .setLexiconPages( + new PageText("0"), + new PageText("1"), + new PageCraftingRecipe("2", ModCraftingRecipes.recipesManaTablet)); + + manaMirror = new BLexiconEntry(LibLexicon.MANA_MIRROR, categoryMana); + manaMirror.setLexiconPages(new PageText("0"), new PageCraftingRecipe("1", ModCraftingRecipes.recipeManaMirror)); + + manaDetector = new BLexiconEntry(LibLexicon.MANA_DETECTOR, categoryMana); + manaDetector.setLexiconPages( + new PageText("0"), new PageCraftingRecipe("1", ModCraftingRecipes.recipeManaDetector)); + + redstoneSpreader = new BLexiconEntry(LibLexicon.MANA_REDSTONE_SPREADER, categoryMana); + redstoneSpreader + .setPriority() + .setLexiconPages( + new PageText("0"), new PageCraftingRecipe("1", ModCraftingRecipes.recipeRedstoneSpreader)); + + manastar = new BLexiconEntry(LibLexicon.MANA_MANASTAR, categoryMana); + manastar.setPriority() + .setLexiconPages(new PageText("0"), new PagePetalRecipe("1", ModPetalRecipes.manastarRecipe)); + + dreamwoodSpreader = new ALexiconEntry(LibLexicon.MANA_DREAMWOOD_SPREADER, categoryMana); + dreamwoodSpreader.setLexiconPages( + new PageText("0"), + new PageCraftingRecipe("1", ModCraftingRecipes.recipesDreamwoodSpreader), + new PageText("2"), + new PageCraftingRecipe("3", ModCraftingRecipes.recipeUltraSpreader)); + + elvenLenses = new ALexiconEntry(LibLexicon.MANA_ELVEN_LENSES, categoryMana); + elvenLenses.setLexiconPages( + new PageText("0"), + new PageText("1"), + new PageCraftingRecipe("2", ModCraftingRecipes.recipeLensPaint), + new PageText("3"), + new PageCraftingRecipe("4", ModCraftingRecipes.recipeLensWarp), + new PageText("5"), + new PageCraftingRecipe("6", ModCraftingRecipes.recipeLensRedirect), + new PageText("7"), + new PageCraftingRecipe("8", ModCraftingRecipes.recipeLensFirework), + new PageText("9"), + new PageCraftingRecipe("10", ModCraftingRecipes.recipeLensFlare)); + + prism = new ALexiconEntry(LibLexicon.MANA_PRISM, categoryMana); + prism.setLexiconPages( + new PageText("0"), + new PageText("1"), + new PageText("2"), + new PageCraftingRecipe("3", ModCraftingRecipes.recipePrism)); + + poolCart = new BLexiconEntry(LibLexicon.MANA_POOL_CART, categoryMana); + poolCart.setLexiconPages( + new PageText("0"), + new PageText("1"), + new PageText("2"), + new PageCraftingRecipe("3", ModCraftingRecipes.recipePoolCart), + new PageCraftingRecipe("4", ModCraftingRecipes.recipePump)); + + sparkChanger = new ALexiconEntry(LibLexicon.MANA_SPARK_CHANGER, categoryMana); + sparkChanger.setLexiconPages( + new PageText("0"), + new PageText("1"), + new PageCraftingRecipe("2", ModCraftingRecipes.recipeSparkChanger)); + + bellows = new BLexiconEntry(LibLexicon.MANA_BELLOWS, categoryMana); + bellows.setLexiconPages( + new PageText("0"), new PageText("1"), new PageCraftingRecipe("2", ModCraftingRecipes.recipeBellows)); + + // FUNCTIONAL FLOWERS ENTRIES + functionalIntro = new BLexiconEntry(LibLexicon.FFLOWER_INTRO, categoryFunctionalFlowers); + functionalIntro + .setPriority() + .setLexiconPages( + new PageText("0"), + new PageText("1"), + new PageText("2"), + new PageText("3"), + new PageCraftingRecipe("4", ModCraftingRecipes.recipeRedstoneRoot)) + .setIcon(null); + ; + + flowerShrinking = new BLexiconEntry(LibLexicon.FFLOWER_SHRINKING, categoryFunctionalFlowers); + flowerShrinking + .setPriority() + .setLexiconPages(new PageText("0"), new PageManaInfusionRecipe("1", BotaniaAPI.miniFlowerRecipes)) + .setIcon(ItemBlockSpecialFlower.ofType(LibBlockNames.SUBTILE_BELLETHORN + "Chibi")); + + flowerSpeed = new BLexiconEntry(LibLexicon.FFLOWER_SPEED, categoryFunctionalFlowers); + flowerSpeed.setPriority().setLexiconPages(new PageText("0"), new PageText("1")); + flowerSpeed.setIcon(new ItemStack(Blocks.dirt, 1, 2)); + + jadedAmaranthus = new BLexiconEntry(LibLexicon.FFLOWER_JADED_AMARANTHUS, categoryFunctionalFlowers); + jadedAmaranthus.setLexiconPages( + new PageText("0"), new PagePetalRecipe("1", ModPetalRecipes.jadedAmaranthusRecipe), new PageText("2")); + + bellethorne = new BLexiconEntry(LibLexicon.FFLOWER_BELLETHORNE, categoryFunctionalFlowers); + bellethorne.setLexiconPages(new PageText("0"), new PagePetalRecipe("1", ModPetalRecipes.bellethorneRecipe)); + + dreadthorne = new BLexiconEntry(LibLexicon.FFLOWER_DREADTHORNE, categoryFunctionalFlowers); + dreadthorne.setLexiconPages(new PageText("0"), new PagePetalRecipe("1", ModPetalRecipes.dreadthorneRecipe)); + + heiseiDream = new ALexiconEntry(LibLexicon.FFLOWER_HEISEI_DREAM, categoryFunctionalFlowers); + heiseiDream.setLexiconPages(new PageText("0"), new PagePetalRecipe("1", ModPetalRecipes.heiseiDreamRecipe)); + + tigerseye = new BLexiconEntry(LibLexicon.FFLOWER_TIGERSEYE, categoryFunctionalFlowers); + tigerseye.setLexiconPages(new PageText("0"), new PagePetalRecipe("1", ModPetalRecipes.tigerseyeRecipe)); + + orechid = Botania.gardenOfGlassLoaded + ? new BLexiconEntry(LibLexicon.FFLOWER_ORECHID, categoryFunctionalFlowers) + : new ALexiconEntry(LibLexicon.FFLOWER_ORECHID, categoryFunctionalFlowers); + orechid.setLexiconPages(new PageText("0"), new PagePetalRecipe("1", ModPetalRecipes.orechidRecipe)); + if (Botania.gardenOfGlassLoaded) orechid.setPriority(); + + orechidIgnem = new ALexiconEntry(LibLexicon.FFLOWER_ORECHID_IGNEM, categoryFunctionalFlowers); + orechidIgnem.setLexiconPages(new PageText("0"), new PagePetalRecipe("1", ModPetalRecipes.orechidIgnemRecipe)); + + if (ConfigHandler.fallenKanadeEnabled) { + fallenKanade = new BLexiconEntry(LibLexicon.FFLOWER_FALLEN_KANADE, categoryFunctionalFlowers); + fallenKanade.setLexiconPages( + new PageText(Botania.bloodMagicLoaded ? "0a" : "0"), + new PagePetalRecipe("1", ModPetalRecipes.fallenKanadeRecipe)); + } + + exoflame = new BLexiconEntry(LibLexicon.FFLOWER_EXOFLAME, categoryFunctionalFlowers); + exoflame.setLexiconPages(new PageText("0"), new PagePetalRecipe("1", ModPetalRecipes.exoflameRecipe)); + + agricarnation = new BLexiconEntry(LibLexicon.FFLOWER_AGRICARNATION, categoryFunctionalFlowers); + agricarnation.setLexiconPages(new PageText("0"), new PagePetalRecipe("1", ModPetalRecipes.agricarnationRecipe)); + + hopperhock = new BLexiconEntry(LibLexicon.FFLOWER_HOPPERHOCK, categoryFunctionalFlowers); + hopperhock.setLexiconPages( + new PageText("0"), new PageText("1"), new PagePetalRecipe("2", ModPetalRecipes.hopperhockRecipe)); + + tangleberrie = new BLexiconEntry(LibLexicon.FFLOWER_TANGLEBERRIE, categoryFunctionalFlowers); + tangleberrie.setLexiconPages(new PageText("0"), new PagePetalRecipe("1", ModPetalRecipes.tangleberrieRecipe)); + + jiyuulia = new BLexiconEntry(LibLexicon.FFLOWER_JIYUULIA, categoryFunctionalFlowers); + jiyuulia.setLexiconPages(new PageText("0"), new PagePetalRecipe("1", ModPetalRecipes.jiyuuliaRecipe)); + + rannuncarpus = new BLexiconEntry(LibLexicon.FFLOWER_RANNUNCARPUS, categoryFunctionalFlowers); + rannuncarpus.setLexiconPages( + new PageText("0"), new PageText("1"), new PagePetalRecipe("2", ModPetalRecipes.rannuncarpusRecipe)); + + hyacidus = new BLexiconEntry(LibLexicon.FFLOWER_HYACIDUS, categoryFunctionalFlowers); + hyacidus.setLexiconPages(new PageText("0"), new PagePetalRecipe("1", ModPetalRecipes.hyacidusRecipe)); + + pollidisiac = new BLexiconEntry(LibLexicon.FFLOWER_POLLIDISIAC, categoryFunctionalFlowers); + pollidisiac.setLexiconPages(new PageText("0"), new PagePetalRecipe("1", ModPetalRecipes.pollidisiacRecipe)); + + clayconia = new BLexiconEntry(LibLexicon.FFLOWER_CLAYCONIA, categoryFunctionalFlowers); + clayconia.setLexiconPages(new PageText("0"), new PagePetalRecipe("1", ModPetalRecipes.clayconiaRecipe)); + + loonium = new ALexiconEntry(LibLexicon.FFLOWER_LOONIUM, categoryFunctionalFlowers); + loonium.setLexiconPages(new PageText("0"), new PagePetalRecipe("1", ModPetalRecipes.looniumRecipe)); + + daffomill = new BLexiconEntry(LibLexicon.FFLOWER_DAFFOMILL, categoryFunctionalFlowers); + daffomill.setLexiconPages(new PageText("0"), new PagePetalRecipe("1", ModPetalRecipes.daffomillRecipe)); + + vinculotus = new BLexiconEntry(LibLexicon.FFLOWER_VINCULOTUS, categoryFunctionalFlowers); + vinculotus.setLexiconPages(new PageText("0"), new PagePetalRecipe("1", ModPetalRecipes.vinculotusRecipe)); + + spectranthemum = new ALexiconEntry(LibLexicon.FFLOWER_SPECTRANTHEMUN, categoryFunctionalFlowers); + spectranthemum.setLexiconPages( + new PageText("0"), + new PageText("1"), + new PageText("2"), + new PagePetalRecipe("3", ModPetalRecipes.spectranthemumRecipe)); + + medumone = new BLexiconEntry(LibLexicon.FFLOWER_MEDUMONE, categoryFunctionalFlowers); + medumone.setLexiconPages(new PageText("0"), new PagePetalRecipe("1", ModPetalRecipes.medumoneRecipe)); + + marimorphosis = new BLexiconEntry(LibLexicon.FFLOWER_MARIMORPHOSIS, categoryFunctionalFlowers); + marimorphosis.setLexiconPages( + new PageText("0"), + new PageImage("1", LibResources.ENTRY_METAMORPHIC_STONES), + new PagePetalRecipe("2", ModPetalRecipes.marimorphosisRecipe), + new PageCraftingRecipe("3", ModCraftingRecipes.recipesAltarMeta)); + + bubbell = new ALexiconEntry(LibLexicon.FFLOWER_BUBBELL, categoryFunctionalFlowers); + bubbell.setLexiconPages(new PageText("0"), new PagePetalRecipe("1", ModPetalRecipes.bubbellRecipe)); + + solegnolia = new BLexiconEntry(LibLexicon.FFLOWER_SOLEGNOLIA, categoryFunctionalFlowers); + solegnolia.setLexiconPages(new PageText("0"), new PagePetalRecipe("1", ModPetalRecipes.solegnoliaRecipe)); + + // GENERATING FLOWERS ENTRIES + if (ConfigHandler.hardcorePassiveGeneration > 0) { + generatingIntro = new BLexiconEntry(LibLexicon.GFLOWER_INTRO, categoryGenerationFlowers); + generatingIntro.setPriority().setLexiconPages(new PageText("0"), new PageText("1"), new PageText("2")); + } + + passiveGen = new BLexiconEntry(LibLexicon.GFLOWER_PASSIVE_GENERATION, categoryGenerationFlowers); + passiveGen + .setPriority() + .setLexiconPages(new PageText("0"), new PageText("1")) + .setIcon(new ItemStack(Blocks.deadbush)); + + primusLoci = new BLexiconEntry(LibLexicon.GFLOWER_PRIMUS_LOCI, categoryGenerationFlowers); + primusLoci.setPriority().setLexiconPages(new PageText("0"), new PageText("1")); + primusLoci.setIcon(ItemBlockSpecialFlower.ofType(LibBlockNames.SUBTILE_DAYBLOOM_PRIME)); + primusLoci.addExtraDisplayedRecipe(ItemBlockSpecialFlower.ofType(LibBlockNames.SUBTILE_DAYBLOOM_PRIME)); + primusLoci.addExtraDisplayedRecipe(ItemBlockSpecialFlower.ofType(LibBlockNames.SUBTILE_NIGHTSHADE_PRIME)); + + daybloom = new BLexiconEntry(LibLexicon.GFLOWER_DAYBLOOM, categoryGenerationFlowers); + daybloom.setPriority() + .setLexiconPages( + new PageText("0"), new PageText("1"), new PagePetalRecipe("2", ModPetalRecipes.daybloomRecipe)); + + nightshade = new BLexiconEntry(LibLexicon.GFLOWER_NIGHTSHADE, categoryGenerationFlowers); + nightshade.setLexiconPages(new PageText("0"), new PagePetalRecipe("1", ModPetalRecipes.nightshadeRecipe)); + + endoflame = new BLexiconEntry(LibLexicon.GFLOWER_ENDOFLAME, categoryGenerationFlowers); + endoflame.setLexiconPages( + new PageText("0"), + new PageText("1"), + new PageText("3"), + new PagePetalRecipe("2", ModPetalRecipes.endoflameRecipe)); + + hydroangeas = new BLexiconEntry(LibLexicon.GFLOWER_HYDROANGEAS, categoryGenerationFlowers); + hydroangeas.setLexiconPages( + new PageText("0"), + new PageImage("2", LibResources.ENTRY_HYDROANGEAS), + new PagePetalRecipe("1", ModPetalRecipes.hydroangeasRecipe)); + + thermalily = new BLexiconEntry(LibLexicon.GFLOWER_THERMALILY, categoryGenerationFlowers); + thermalily.setLexiconPages( + new PageText("0"), + new PageText("2"), + new PageText("3"), + new PagePetalRecipe("1", ModPetalRecipes.thermalilyRecipe)); + + arcaneRose = new BLexiconEntry(LibLexicon.GFLOWER_ARCANE_ROSE, categoryGenerationFlowers); + arcaneRose.setLexiconPages(new PageText("0"), new PagePetalRecipe("1", ModPetalRecipes.arcaneRoseRecipe)); + + munchdew = new BLexiconEntry(LibLexicon.GFLOWER_MUNCHDEW, categoryGenerationFlowers); + munchdew.setLexiconPages( + new PageText("0"), new PageText("1"), new PagePetalRecipe("2", ModPetalRecipes.munchdewRecipe)); + + entropinnyum = new BLexiconEntry(LibLexicon.GFLOWER_ENTROPINNYUM, categoryGenerationFlowers); + entropinnyum.setLexiconPages(new PageText("0"), new PagePetalRecipe("1", ModPetalRecipes.entropinnyumRecipe)); + + kekimurus = new ALexiconEntry(LibLexicon.GFLOWER_KEKIMURUS, categoryGenerationFlowers); + kekimurus.setLexiconPages(new PageText("0"), new PagePetalRecipe("1", ModPetalRecipes.kekimurusRecipe)); + + gourmaryllis = new BLexiconEntry(LibLexicon.GFLOWER_GOURMARYLLIS, categoryGenerationFlowers); + gourmaryllis.setLexiconPages( + new PageText("0"), + new PageText("1"), + new PageText("2"), + new PagePetalRecipe("3", ModPetalRecipes.gourmaryllisRecipe)); + + narslimmus = new BLexiconEntry(LibLexicon.GFLOWER_NARSLIMMUS, categoryGenerationFlowers); + narslimmus.setLexiconPages(new PageText("0"), new PagePetalRecipe("1", ModPetalRecipes.narslimmusRecipe)); + + spectrolus = new ALexiconEntry(LibLexicon.GFLOWER_SPECTROLUS, categoryGenerationFlowers); + spectrolus.setLexiconPages( + new PageText("0"), new PageText("1"), new PagePetalRecipe("2", ModPetalRecipes.spectrolusRecipe)); + + rafflowsia = new ALexiconEntry(LibLexicon.GFLOWER_RAFFLOWSIA, categoryGenerationFlowers); + rafflowsia.setLexiconPages( + new PageText("0"), + new PageText("1"), + new PageText("2"), + new PageText("3"), + new PagePetalRecipe("4", ModPetalRecipes.rafflowsiaRecipe)); + + dandelifeon = new ALexiconEntry(LibLexicon.GFLOWER_DANDELIFEON, categoryGenerationFlowers); + dandelifeon.setLexiconPages( + new PageText("_w"), + new PageText("0"), + new PageText("1"), + new PageText("2"), + new PageText("3"), + new PageText("4"), + new PageText("5"), + new PageText("6"), + new PageText("10"), + new PageText("7"), + new PagePetalRecipe("8", ModPetalRecipes.dandelifeonRecipe), + new PageCraftingRecipe("9", ModCraftingRecipes.recipeCellBlock)); + + // DEVICES ENTRIES + pylon = new BLexiconEntry(LibLexicon.DEVICE_PYLON, categoryDevices); + pylon.setLexiconPages(new PageText("0"), new PageCraftingRecipe("1", ModCraftingRecipes.recipePylon)); + + if (ConfigHandler.enchanterEnabled) { + manaEnchanting = new BLexiconEntry(LibLexicon.DEVICE_MANA_ENCHANTING, categoryDevices); + manaEnchanting + .setLexiconPages( + new PageText("0"), + new PageText("1"), + new PageMultiblock("2", ModMultiblocks.enchanter), + new PageText("5"), + new PageText("6"), + new PageText("7"), + new PageText("8"), + new PageText("9")) + .setIcon(new ItemStack(ModBlocks.enchanter)); + } + + turntable = new BLexiconEntry(LibLexicon.DEVICE_TURNTABLE, categoryDevices); + turntable.setLexiconPages(new PageText("0"), new PageCraftingRecipe("1", ModCraftingRecipes.recipeTurntable)); + + alchemy = new BLexiconEntry(LibLexicon.DEVICE_ALCHEMY, categoryDevices); + alchemy.setLexiconPages( + new PageText("0"), + new PageCraftingRecipe("1", ModCraftingRecipes.recipeAlchemyCatalyst), + new PageManaInfusionRecipe("2", ModManaAlchemyRecipes.leatherRecipe), + new PageManaInfusionRecipe("3", ModManaAlchemyRecipes.woodRecipes), + new PageManaInfusionRecipe("4", ModManaAlchemyRecipes.saplingRecipes), + new PageManaInfusionRecipe("5", ModManaAlchemyRecipes.glowstoneDustRecipe), + new PageManaInfusionRecipe("6", ModManaAlchemyRecipes.quartzRecipes).setSkipRegistry(), + new PageManaInfusionRecipe("7", ModManaAlchemyRecipes.chiseledBrickRecipe), + new PageManaInfusionRecipe("8", ModManaAlchemyRecipes.iceRecipe), + new PageManaInfusionRecipe("9", ModManaAlchemyRecipes.swampFolliageRecipes), + new PageManaInfusionRecipe("10", ModManaAlchemyRecipes.fishRecipes), + new PageManaInfusionRecipe("11", ModManaAlchemyRecipes.cropRecipes), + new PageManaInfusionRecipe("12", ModManaAlchemyRecipes.potatoRecipe), + new PageManaInfusionRecipe("13", ModManaAlchemyRecipes.netherWartRecipe), + new PageManaInfusionRecipe("14", ModManaAlchemyRecipes.gunpowderAndFlintRecipes), + new PageManaInfusionRecipe("15", ModManaAlchemyRecipes.nameTagRecipe), + new PageManaInfusionRecipe("16", ModManaAlchemyRecipes.stringRecipes), + new PageManaInfusionRecipe("17", ModManaAlchemyRecipes.slimeballCactusRecipes), + new PageManaInfusionRecipe("18", ModManaAlchemyRecipes.enderPearlRecipe), + new PageManaInfusionRecipe("19", ModManaAlchemyRecipes.redstoneToGlowstoneRecipes), + new PageManaInfusionRecipe("20", ModManaAlchemyRecipes.sandRecipe), + new PageManaInfusionRecipe("21", ModManaAlchemyRecipes.redSandRecipe), + new PageManaInfusionRecipe("22", ModManaAlchemyRecipes.clayBreakdownRecipes), + new PageManaInfusionRecipe("24", ModManaAlchemyRecipes.tallgrassRecipes), + new PageManaInfusionRecipe("25", ModManaAlchemyRecipes.flowersRecipes), + new PageManaInfusionRecipe("23", ModManaAlchemyRecipes.coarseDirtRecipe)); + + openCrate = new BLexiconEntry(LibLexicon.DEVICE_OPEN_CRATE, categoryDevices); + openCrate + .setPriority() + .setLexiconPages( + new PageText("0"), + new PageText("1"), + new PageCraftingRecipe("2", ModCraftingRecipes.recipeOpenCrate)); + + forestEye = new BLexiconEntry(LibLexicon.DEVICE_FOREST_EYE, categoryDevices); + forestEye.setLexiconPages( + new PageText("0"), new PageText("1"), new PageCraftingRecipe("2", ModCraftingRecipes.recipeForestEye)); + + forestDrum = new BLexiconEntry(LibLexicon.DEVICE_FOREST_DRUM, categoryDevices); + forestDrum.setLexiconPages( + new PageText("0"), new PageText("1"), new PageCraftingRecipe("2", ModCraftingRecipes.recipeForestDrum)); + + platform = new BLexiconEntry(LibLexicon.DEVICE_PLATFORM, categoryDevices); + platform.setLexiconPages( + new PageText("0"), new PageText("2"), new PageCraftingRecipe("1", ModCraftingRecipes.recipePlatform)); + + conjurationCatalyst = new ALexiconEntry(LibLexicon.DEVICE_MANA_CONJURATION, categoryDevices); + conjurationCatalyst.setLexiconPages( + new PageText("0"), + new PageCraftingRecipe("1", ModCraftingRecipes.recipeConjurationCatalyst), + new PageManaInfusionRecipe("2", ModManaConjurationRecipes.redstoneRecipe), + new PageManaInfusionRecipe("3", ModManaConjurationRecipes.glowstoneRecipe), + new PageManaInfusionRecipe("4", ModManaConjurationRecipes.quartzRecipe), + new PageManaInfusionRecipe("5", ModManaConjurationRecipes.coalRecipe), + new PageManaInfusionRecipe("6", ModManaConjurationRecipes.snowballRecipe), + new PageManaInfusionRecipe("7", ModManaConjurationRecipes.netherrackRecipe), + new PageManaInfusionRecipe("8", ModManaConjurationRecipes.soulSandRecipe), + new PageManaInfusionRecipe("9", ModManaConjurationRecipes.gravelRecipe), + new PageManaInfusionRecipe("10", ModManaConjurationRecipes.leavesRecipes), + new PageManaInfusionRecipe("11", ModManaConjurationRecipes.grassRecipe)); + + spectralPlatform = new ALexiconEntry(LibLexicon.DEVICE_SPECTRAL_PLATFORM, categoryDevices); + spectralPlatform.setLexiconPages( + new PageText("0"), new PageCraftingRecipe("1", ModCraftingRecipes.recipeSpectralPlatform)); + + gatherDrum = new ALexiconEntry(LibLexicon.DEVICE_GATHER_DRUM, categoryDevices); + gatherDrum.setLexiconPages(new PageText("0"), new PageCraftingRecipe("1", ModCraftingRecipes.recipeGatherDrum)); + + craftCrate = new ALexiconEntry(LibLexicon.DEVICE_CRAFT_CRATE, categoryDevices); + craftCrate + .setLexiconPages( + new PageText("0"), + new PageText("1"), + new PageCraftingRecipe("2", ModCraftingRecipes.recipePlaceholder), + new PageText("3"), + new PageText("4"), + new PageText("7"), + new PageImage("5", LibResources.ENTRY_CRAFT_CRATE), + new PageCraftingRecipe("6", ModCraftingRecipes.recipeCraftCrate), + new PageText("8"), + new PageCraftingRecipe("9", ModCraftingRecipes.recipesPatterns)) + .setIcon(new ItemStack(ModBlocks.openCrate, 1, 1)); + + brewery = new BLexiconEntry(LibLexicon.DEVICE_BREWERY, categoryDevices); + brewery.setLexiconPages( + new PageText("0"), + new PageText("1"), + new PageCraftingRecipe("2", ModCraftingRecipes.recipeBrewery), + new PageCraftingRecipe("3", ModCraftingRecipes.recipeVial), + new PageText("4"), + new PageBrew(ModBrewRecipes.speedBrew, "5a", "5b"), + new PageBrew(ModBrewRecipes.strengthBrew, "6a", "6b"), + new PageBrew(ModBrewRecipes.hasteBrew, "7a", "7b"), + new PageBrew(ModBrewRecipes.healingBrew, "8a", "8b"), + new PageBrew(ModBrewRecipes.jumpBoostBrew, "9a", "9b"), + new PageBrew(ModBrewRecipes.regenerationBrew, "10a", "10b"), + new PageBrew(ModBrewRecipes.weakRegenerationBrew, "17a", "17b"), + new PageBrew(ModBrewRecipes.resistanceBrew, "11a", "11b"), + new PageBrew(ModBrewRecipes.fireResistanceBrew, "12a", "12b"), + new PageBrew(ModBrewRecipes.waterBreathingBrew, "13a", "13b"), + new PageBrew(ModBrewRecipes.invisibilityBrew, "14a", "14b"), + new PageBrew(ModBrewRecipes.nightVisionBrew, "15a", "15b"), + new PageBrew(ModBrewRecipes.absorptionBrew, "16a", "16b")); + + flasks = new ALexiconEntry(LibLexicon.DEVICE_FLASKS, categoryDevices); + flasks.setLexiconPages( + new PageText("0"), new PageText("1"), new PageCraftingRecipe("2", ModCraftingRecipes.recipeFlask)); + + complexBrews = new BLexiconEntry(LibLexicon.DEVICE_COMPLEX_BREWS, categoryDevices); + complexBrews + .setLexiconPages( + new PageText("0"), + new PageBrew(ModBrewRecipes.overloadBrew, "1a", "1b"), + new PageBrew(ModBrewRecipes.soulCrossBrew, "2a", "2b"), + new PageBrew(ModBrewRecipes.featherFeetBrew, "3a", "3b"), + new PageBrew(ModBrewRecipes.emptinessBrew, "4a", "4b"), + new PageBrew(ModBrewRecipes.bloodthirstBrew, "5a", "5b"), + new PageBrew(ModBrewRecipes.allureBrew, "6a", "6b"), + new PageBrew(ModBrewRecipes.clearBrew, "7a", "7b")) + .setIcon(((IBrewContainer) ModItems.vial) + .getItemForBrew(ModBrews.jumpBoost, new ItemStack(ModItems.vial))); + + incense = new BLexiconEntry(LibLexicon.DEVICE_INCENSE, categoryDevices); + incense.setLexiconPages( + new PageText("0"), + new PageText("1"), + new PageText("2"), + new PageText("5"), + new PageCraftingRecipe("3", ModCraftingRecipes.recipeIncenseStick), + new PageCraftingRecipe("4", ModCraftingRecipes.recipeIncensePlate)); + + hourglass = new BLexiconEntry(LibLexicon.DEVICE_HOURGLASS, categoryDevices); + hourglass + .setPriority() + .setLexiconPages( + new PageText("0"), + new PageText("1"), + new PageText("2"), + new PageText("3"), + new PageText("4"), + new PageCraftingRecipe("5", ModCraftingRecipes.recipeHourglass)); + + ghostRail = new ALexiconEntry(LibLexicon.DEVICE_GHOST_RAIL, categoryDevices); + ghostRail.setLexiconPages(new PageText("0"), new PageCraftingRecipe("1", ModCraftingRecipes.recipeGhostRail)); + + canopyDrum = new BLexiconEntry(LibLexicon.DEVICE_CANOPY_DRUM, categoryDevices); + canopyDrum.setLexiconPages(new PageText("0"), new PageCraftingRecipe("1", ModCraftingRecipes.recipeCanopyDrum)); + + cocoon = Botania.gardenOfGlassLoaded + ? new BLexiconEntry(LibLexicon.DEVICE_COCOON, categoryDevices) + : new ALexiconEntry(LibLexicon.DEVICE_COCOON, categoryDevices); + cocoon.setLexiconPages( + new PageText("0"), new PageText("1"), new PageCraftingRecipe("2", ModCraftingRecipes.recipeCocoon)); + + manaBomb = new ALexiconEntry(LibLexicon.DEVICE_MANA_BOMB, categoryDevices); + manaBomb.setLexiconPages(new PageText("0"), new PageCraftingRecipe("1", ModCraftingRecipes.recipeManaBomb)); + + teruTeruBozu = new BLexiconEntry(LibLexicon.DEVICE_TERU_TERU_BOZU, categoryDevices); + teruTeruBozu.setLexiconPages( + new PageText("0"), new PageCraftingRecipe("1", ModCraftingRecipes.recipeTeruTeruBozu)); + + avatar = new BLexiconEntry(LibLexicon.DEVICE_AVATAR, categoryDevices); + avatar.setLexiconPages( + new PageText("0"), new PageText("1"), new PageCraftingRecipe("2", ModCraftingRecipes.recipeAvatar)); + + felPumpkin = new BLexiconEntry(LibLexicon.DEVICE_FEL_PUMPKIN, categoryDevices); + felPumpkin.setLexiconPages(new PageText("0"), new PageCraftingRecipe("1", ModCraftingRecipes.recipeFelPumpkin)); + + // TOOLS ENTRIES + manaBlaster = new BLexiconEntry(LibLexicon.TOOL_MANA_BLASTER, categoryTools); + manaBlaster.setLexiconPages( + new PageText("0"), + new PageText("1"), + new PageText("2"), + new PageCraftingRecipe("3", ModCraftingRecipes.recipeManaBlaster)); + + grassSeeds = new BLexiconEntry(LibLexicon.TOOL_GRASS_SEEDS, categoryTools); + grassSeeds.setLexiconPages( + new PageText("0"), + new PageManaInfusionRecipe("1", ModManaInfusionRecipes.grassSeedsRecipe), + new PageManaInfusionRecipe("2", ModManaInfusionRecipes.podzolSeedsRecipe), + new PageManaInfusionRecipe("3", ModManaInfusionRecipes.mycelSeedsRecipes), + new PageText("4"), + new PageCraftingRecipe("5", ModCraftingRecipes.recipesAltGrassSeeds)); + + dirtRod = new BLexiconEntry(LibLexicon.TOOL_DIRT_ROD, categoryTools); + dirtRod.setLexiconPages(new PageText("0"), new PageCraftingRecipe("1", ModCraftingRecipes.recipeDirtRod)); + + terraformRod = new BLexiconEntry(LibLexicon.TOOL_TERRAFORM_ROD, categoryTools); + terraformRod.setLexiconPages( + new PageText("0"), + new PageText("1"), + new PageText("2"), + new PageCraftingRecipe("3", ModCraftingRecipes.recipeTerraformRod)); + + manasteelGear = new BLexiconEntry(LibLexicon.TOOL_MANASTEEL_GEAR, categoryTools); + manasteelGear + .setPriority() + .setLexiconPages( + new PageText("0"), + new PageText("10"), + new PageCraftingRecipe("1", ModCraftingRecipes.recipeManasteelPick), + new PageCraftingRecipe("2", ModCraftingRecipes.recipeManasteelShovel), + new PageCraftingRecipe("3", ModCraftingRecipes.recipeManasteelAxe), + new PageCraftingRecipe("4", ModCraftingRecipes.recipeManasteelShears), + new PageCraftingRecipe("5", ModCraftingRecipes.recipeManasteelSword), + new PageCraftingRecipe("6", ModCraftingRecipes.recipeManasteelHelm), + new PageCraftingRecipe("7", ModCraftingRecipes.recipeManasteelChest), + new PageCraftingRecipe("8", ModCraftingRecipes.recipeManasteelLegs), + new PageCraftingRecipe("9", ModCraftingRecipes.recipeManasteelBoots)); + + terrasteelArmor = new BLexiconEntry(LibLexicon.TOOL_TERRASTEEL_ARMOR, categoryTools); + terrasteelArmor.setLexiconPages( + new PageText("0"), + new PageCraftingRecipe("1", ModCraftingRecipes.recipeTerrasteelHelm), + new PageCraftingRecipe("2", ModCraftingRecipes.recipeTerrasteelChest), + new PageCraftingRecipe("3", ModCraftingRecipes.recipeTerrasteelLegs), + new PageCraftingRecipe("4", ModCraftingRecipes.recipeTerrasteelBoots)); + + grassHorn = new BLexiconEntry(LibLexicon.TOOL_GRASS_HORN, categoryTools); + grassHorn.setLexiconPages( + new PageText("0"), + new PageCraftingRecipe("1", ModCraftingRecipes.recipeGrassHorn), + new PageCraftingRecipe("2", ModCraftingRecipes.recipeLeafHorn), + new PageCraftingRecipe("3", ModCraftingRecipes.recipeSnowHorn)); + + terraBlade = new BLexiconEntry(LibLexicon.TOOL_TERRA_SWORD, categoryTools); + terraBlade.setLexiconPages(new PageText("0"), new PageCraftingRecipe("1", ModCraftingRecipes.recipeTerraSword)); + + terraPick = new BLexiconEntry(LibLexicon.TOOL_TERRA_PICK, categoryTools); + terraPick.setLexiconPages( + new PageText("0"), + new PageText("1"), + new PageText("2"), + new PageText("3"), + new PageText("4"), + new PageCraftingRecipe("5", ModCraftingRecipes.recipeTerraPick)); + + waterRod = new BLexiconEntry(LibLexicon.TOOL_WATER_ROD, categoryTools); + waterRod.setLexiconPages(new PageText("0"), new PageCraftingRecipe("1", ModCraftingRecipes.recipeWaterRod)); + + elfGear = new ALexiconEntry(LibLexicon.TOOL_ELF_GEAR, categoryTools); + elfGear.setLexiconPages( + new PageText("0"), + new PageText("1"), + new PageText("2"), + new PageCraftingRecipe("3", ModCraftingRecipes.recipeElementiumPick), + new PageText("4"), + new PageCraftingRecipe("5", ModCraftingRecipes.recipeElementiumShovel), + new PageText("6"), + new PageCraftingRecipe("7", ModCraftingRecipes.recipeElementiumAxe), + new PageText("8"), + new PageCraftingRecipe("9", ModCraftingRecipes.recipeElementiumShears), + new PageText("10"), + new PageCraftingRecipe("11", ModCraftingRecipes.recipeElementiumSword), + new PageCraftingRecipe("12", ModCraftingRecipes.recipeElementiumHelm), + new PageCraftingRecipe("13", ModCraftingRecipes.recipeElementiumChest), + new PageCraftingRecipe("14", ModCraftingRecipes.recipeElementiumLegs), + new PageCraftingRecipe("15", ModCraftingRecipes.recipeElementiumBoots)); + + openBucket = new ALexiconEntry(LibLexicon.TOOL_OPEN_BUCKET, categoryTools); + openBucket.setLexiconPages(new PageText("0"), new PageCraftingRecipe("1", ModCraftingRecipes.recipeOpenBucket)); + + rainbowRod = new ALexiconEntry(LibLexicon.TOOL_RAINBOW_ROD, categoryTools); + rainbowRod.setLexiconPages( + new PageText("0"), + new PageText("1"), + new PageText("6"), + new PageCraftingRecipe("2", ModCraftingRecipes.recipeRainbowRod), + new PageCraftingRecipe("3", ModCraftingRecipes.recipeBifrost), + new PageCraftingRecipe("4", ModCraftingRecipes.recipeShimmerrock), + new PageCraftingRecipe("5", ModCraftingRecipes.recipeShimmerwoodPlanks), + new PageCraftingRecipe("7", ModCraftingRecipes.recipePoolFabulous)); + + tornadoRod = new BLexiconEntry(LibLexicon.TOOL_TORNADO_ROD, categoryTools); + tornadoRod.setLexiconPages( + new PageText("0"), new PageText("2"), new PageCraftingRecipe("1", ModCraftingRecipes.recipeTornadoRod)); + + fireRod = new BLexiconEntry(LibLexicon.TOOL_FIRE_ROD, categoryTools); + fireRod.setLexiconPages( + new PageText("0"), new PageText("2"), new PageCraftingRecipe("1", ModCraftingRecipes.recipeFireRod)); + + vineBall = new BLexiconEntry(LibLexicon.TOOL_VINE_BALL, categoryTools); + vineBall.setLexiconPages( + new PageText("0"), + new PageText("1"), + new PageCraftingRecipe("2", ModCraftingRecipes.recipeVineBall), + new PageCraftingRecipe("3", ModCraftingRecipes.recipeSlingshot), + new PageCraftingRecipe("4", ModCraftingRecipes.recipeMossStone)); + + laputaShard = new ALexiconEntry(LibLexicon.TOOL_LAPUTA_SHARD, categoryTools); + laputaShard.setLexiconPages( + new PageText("0"), + new PageText("2"), + new PageCraftingRecipe("1", ModCraftingRecipes.recipesLaputaShard), + new PageCraftingRecipe("3", ModCraftingRecipes.recipesLaputaShardUpgrade)); + + virus = new ALexiconEntry(LibLexicon.TOOL_VIRUS, categoryTools); + virus.setLexiconPages( + new PageText("0"), + new PageCraftingRecipe("1", ModCraftingRecipes.recipeVirusZombie), + new PageCraftingRecipe("2", ModCraftingRecipes.recipeVirusSkeleton)); + + skyDirtRod = new ALexiconEntry(LibLexicon.TOOL_SKY_DIRT_ROD, categoryTools); + skyDirtRod.setLexiconPages(new PageText("0"), new PageCraftingRecipe("1", ModCraftingRecipes.recipeSkyDirtRod)); + + glassPick = new BLexiconEntry(LibLexicon.TOOL_GLASS_PICK, categoryTools); + glassPick.setLexiconPages(new PageText("0"), new PageCraftingRecipe("1", ModCraftingRecipes.recipeGlassPick)); + + diviningRod = new BLexiconEntry(LibLexicon.TOOL_DIVINING_ROD, categoryTools); + diviningRod.setLexiconPages( + new PageText("0"), + new PageText("2"), + new PageCraftingRecipe("1", ModCraftingRecipes.recipeDiviningRod)); + + gravityRod = new ALexiconEntry(LibLexicon.TOOL_GRAVITY_ROD, categoryTools); + gravityRod.setLexiconPages( + new PageText("0"), new PageText("1"), new PageCraftingRecipe("2", ModCraftingRecipes.recipeGravityRod)); + + regenIvy = new ALexiconEntry(LibLexicon.TOOL_REGEN_IVY, categoryTools); + regenIvy.setLexiconPages( + new PageText("0"), new PageText("1"), new PageCraftingRecipe("2", ModCraftingRecipes.recipeRegenIvy)); + + missileRod = new ALexiconEntry(LibLexicon.TOOL_MISSILE_ROD, categoryTools); + missileRod.setLexiconPages( + new PageText("0"), new PageText("2"), new PageCraftingRecipe("1", ModCraftingRecipes.recipeMissileRod)); + + craftingHalo = new BLexiconEntry(LibLexicon.TOOL_CRAFTING_HALO, categoryTools); + craftingHalo.setLexiconPages( + new PageText("0"), + new PageText("1"), + new PageCraftingRecipe("2", ModCraftingRecipes.recipeCraftingHalo)); + + clip = new ALexiconEntry(LibLexicon.TOOL_CLIP, categoryTools); + clip.setLexiconPages( + new PageText("0"), new PageText("1"), new PageCraftingRecipe("2", ModCraftingRecipes.recipeClip)); + + cobbleRod = new BLexiconEntry(LibLexicon.TOOL_COBBLE_ROD, categoryTools); + cobbleRod.setLexiconPages(new PageText("0"), new PageCraftingRecipe("1", ModCraftingRecipes.recipeCobbleRod)); + + smeltRod = new BLexiconEntry(LibLexicon.TOOL_SMELT_ROD, categoryTools); + smeltRod.setLexiconPages(new PageText("0"), new PageCraftingRecipe("1", ModCraftingRecipes.recipeSmeltRod)); + + worldSeed = new ALexiconEntry(LibLexicon.TOOL_WORLD_SEED, categoryTools); + worldSeed.setLexiconPages(new PageText("0"), new PageCraftingRecipe("1", ModCraftingRecipes.recipeWorldSeed)); + + spellCloth = new BLexiconEntry(LibLexicon.TOOL_SPELL_CLOTH, categoryTools); + spellCloth.setLexiconPages(new PageText("0"), new PageCraftingRecipe("1", ModCraftingRecipes.recipeSpellCloth)); + + thornChakram = new BLexiconEntry(LibLexicon.TOOL_THORN_CHAKRAM, categoryTools); + thornChakram.setLexiconPages( + new PageText("0"), new PageCraftingRecipe("1", ModCraftingRecipes.recipeThornChakram)); + + fireChakram = new ALexiconEntry(LibLexicon.TOOL_FIRE_CHAKRAM, categoryTools); + fireChakram.setLexiconPages( + new PageText("0"), new PageCraftingRecipe("1", ModCraftingRecipes.recipeFireChakram)); + + overgrowthSeed = new BLexiconEntry(LibLexicon.TOOL_OVERGROWTH_SEED, categoryTools); + overgrowthSeed + .setPriority() + .setLexiconPages(new PageText("0"), new PageText("1")) + .setIcon(new ItemStack(ModItems.overgrowthSeed)); + overgrowthSeed.addExtraDisplayedRecipe(new ItemStack(ModItems.overgrowthSeed)); + overgrowthSeed.addExtraDisplayedRecipe(new ItemStack(ModBlocks.enchantedSoil)); + + livingwoodBow = new BLexiconEntry(LibLexicon.TOOL_LIVINGWOOD_BOW, categoryTools); + livingwoodBow.setLexiconPages( + new PageText("0"), new PageCraftingRecipe("1", ModCraftingRecipes.recipeLivingwoodBow)); + + crystalBow = new ALexiconEntry(LibLexicon.TOOL_CRYSTAL_BOW, categoryTools); + crystalBow.setLexiconPages(new PageText("0"), new PageCraftingRecipe("1", ModCraftingRecipes.recipeCrystalBow)); + + temperanceStone = new BLexiconEntry(LibLexicon.TOOL_TEMPERANCE_STONE, categoryTools); + temperanceStone.setLexiconPages( + new PageText("0"), new PageCraftingRecipe("1", ModCraftingRecipes.recipeTemperanceStone)); + + terraAxe = new BLexiconEntry(LibLexicon.TOOL_TERRA_AXE, categoryTools); + terraAxe.setLexiconPages(new PageText("0"), new PageCraftingRecipe("1", ModCraftingRecipes.recipeTerraAxe)); + + obedienceStick = new BLexiconEntry(LibLexicon.TOOL_OBEDIENCE_STICK, categoryTools); + obedienceStick + .setPriority() + .setLexiconPages( + new PageText("0"), new PageCraftingRecipe("1", ModCraftingRecipes.recipeObedienceStick)); + + slimeBottle = new ALexiconEntry(LibLexicon.TOOL_SLIME_BOTTLE, categoryTools); + slimeBottle.setLexiconPages( + new PageText("0"), new PageCraftingRecipe("1", ModCraftingRecipes.recipeSlimeBottle)); + + exchangeRod = new BLexiconEntry(LibLexicon.TOOL_EXCHANGE_ROD, categoryTools); + exchangeRod.setLexiconPages( + new PageText("0"), + new PageText("1"), + new PageText("2"), + new PageCraftingRecipe("3", ModCraftingRecipes.recipeExchangeRod)); + + manaweave = new BLexiconEntry(LibLexicon.TOOL_MANAWEAVE, categoryTools); + manaweave.setLexiconPages( + new PageText("0"), + new PageText("1"), + new PageCraftingRecipe("2", ModCraftingRecipes.recipeManaweaveCloth), + new PageCraftingRecipe("3", ModCraftingRecipes.recipeManaweaveHelm), + new PageCraftingRecipe("4", ModCraftingRecipes.recipeManaweaveChest), + new PageCraftingRecipe("5", ModCraftingRecipes.recipeManaweaveLegs), + new PageCraftingRecipe("6", ModCraftingRecipes.recipeManaweaveBoots)); + + autocraftingHalo = new BLexiconEntry(LibLexicon.TOOL_AUTOCRAFTING_HALO, categoryTools); + autocraftingHalo.setLexiconPages( + new PageText("0"), new PageCraftingRecipe("1", ModCraftingRecipes.recipeAutocraftingHalo)); + + sextant = new BLexiconEntry(LibLexicon.TOOL_SEXTANT, categoryTools); + sextant.setLexiconPages( + new PageText("0"), new PageText("1"), new PageCraftingRecipe("2", ModCraftingRecipes.recipeSextant)); + + // ENDER ENTRIES + enderAir = new BLexiconEntry(LibLexicon.ENDER_AIR, categoryEnder); + enderAir.setPriority().setLexiconPages(new PageText("0")); + enderAir.addExtraDisplayedRecipe(new ItemStack(ModItems.manaResource, 1, 15)); + LexiconRecipeMappings.map(new ItemStack(ModItems.manaResource, 1, 15), enderAir, 0); + + enderEyeBlock = new BLexiconEntry(LibLexicon.ENDER_ENDER_EYE_BLOCK, categoryEnder); + enderEyeBlock.setLexiconPages( + new PageText("0"), new PageCraftingRecipe("1", ModCraftingRecipes.recipeEnderEyeBlock)); + + pistonRelay = new BLexiconEntry(LibLexicon.ENDER_PISTON_RELAY, categoryEnder); + pistonRelay.setLexiconPages( + new PageText("0"), + new PageText("1"), + new PageManaInfusionRecipe("2", ModManaInfusionRecipes.pistonRelayRecipe)); + + enderHand = new BLexiconEntry(LibLexicon.ENDER_ENDER_HAND, categoryEnder); + enderHand.setLexiconPages( + new PageText(ConfigHandler.enderPickpocketEnabled ? "0" : "0a"), + new PageText("2"), + new PageCraftingRecipe( + ConfigHandler.enderPickpocketEnabled ? "1" : "1a", ModCraftingRecipes.recipeEnderHand)); + + enderDagger = new BLexiconEntry(LibLexicon.ENDER_ENDER_DAGGER, categoryEnder); + enderDagger.setLexiconPages( + new PageText("0"), + new PageText("1"), + new PageCraftingRecipe("2", ModCraftingRecipes.recipeEnderDagger)); + + spawnerClaw = new ALexiconEntry(LibLexicon.ENDER_SPAWNER_CLAW, categoryEnder); + spawnerClaw.setLexiconPages( + new PageText("0"), + new PageText("1"), + new PageCraftingRecipe("2", ModCraftingRecipes.recipeSpawnerClaw)); + + redString = new ALexiconEntry(LibLexicon.ENDER_RED_STRING, categoryEnder); + redString.setLexiconPages( + new PageText("0"), + new PageText("1"), + new PageCraftingRecipe("2", ModCraftingRecipes.recipeRedString), + new PageText("3"), + new PageCraftingRecipe("4", ModCraftingRecipes.recipeRedStringContainer), + new PageText("5"), + new PageCraftingRecipe("6", ModCraftingRecipes.recipeRedStringDispenser), + new PageText("7"), + new PageCraftingRecipe("8", ModCraftingRecipes.recipeRedStringFertilizer), + new PageText("9"), + new PageCraftingRecipe("10", ModCraftingRecipes.recipeRedStringComparator), + new PageText("11"), + new PageCraftingRecipe("12", ModCraftingRecipes.recipeRedStringRelay), + new PageText("13"), + new PageCraftingRecipe("14", ModCraftingRecipes.recipeRedStringInterceptor)); + + flightTiara = new ALexiconEntry(LibLexicon.ENDER_FLIGHT_TIARA, categoryEnder); + flightTiara.setLexiconPages( + new PageText("0"), + new PageText("4"), + new PageText("5"), + new PageText("6"), + new PageCraftingRecipe("1", ModCraftingRecipes.recipeFlightTiara), + new PageText("2"), + new PageCraftingRecipe("3", ModCraftingRecipes.recipesWings)); + + corporea = new ALexiconEntry(LibLexicon.ENDER_CORPOREA, categoryEnder); + corporea.setLexiconPages( + new PageText("0"), + new PageText("1"), + new PageText("2"), + new PageText("3"), + new PageText("4"), + new PageText("5"), + new PageText("6"), + new PageCraftingRecipe("7", ModCraftingRecipes.recipeCorporeaSpark), + new PageCraftingRecipe("8", ModCraftingRecipes.recipeMasterCorporeaSpark)); + + corporeaIndex = new ALexiconEntry(LibLexicon.ENDER_CORPOREA_INDEX, categoryEnder); + corporeaIndex.setLexiconPages( + new PageText("0"), + new PageText("1"), + new PageText("2"), + new PageText("3"), + new PageText("4"), + new PageText("5"), + new PageText("8"), + new PageText("6"), + new PageCraftingRecipe("7", ModCraftingRecipes.recipeCorporeaIndex)); + + corporeaFunnel = new ALexiconEntry(LibLexicon.ENDER_CORPOREA_FUNNEL, categoryEnder); + corporeaFunnel.setLexiconPages( + new PageText("0"), + new PageText("1"), + new PageCraftingRecipe("2", ModCraftingRecipes.recipeCorporeaFunnel)); + + corporeaInterceptor = new ALexiconEntry(LibLexicon.ENDER_CORPOREA_INTERCEPTOR, categoryEnder); + corporeaInterceptor.setLexiconPages( + new PageText("0"), + new PageText("1"), + new PageCraftingRecipe("2", ModCraftingRecipes.recipeCorporeaInterceptor)); + + if (ConfigHandler.enderStuff19Enabled) { + endStoneDecor = new BLexiconEntry(LibLexicon.ENDER_END_STONE_DECOR, categoryEnder); + endStoneDecor.setLexiconPages( + new PageText("0"), + new PageCraftingRecipe("1", ModCraftingRecipes.recipeEndStoneBricks), + new PageCraftingRecipe("2", ModCraftingRecipes.recipeEndStoneChiseledBricks), + new PageCraftingRecipe("3", ModCraftingRecipes.recipeEnderBricks), + new PageCraftingRecipe("4", ModCraftingRecipes.recipePillarEnderBricks)); + } + + spawnerMover = new ALexiconEntry(LibLexicon.ENDER_SPAWNER_MOVER, categoryEnder); + spawnerMover.setLexiconPages( + new PageText("0"), new PageCraftingRecipe("1", ModCraftingRecipes.recipeSpawnerMover)); + + keepIvy = new ALexiconEntry(LibLexicon.ENDER_KEEP_IVY, categoryEnder); + keepIvy.setLexiconPages( + new PageText("0"), new PageText("2"), new PageCraftingRecipe("1", ModCraftingRecipes.recipeKeepIvy)); + + blackHoleTalisman = new ALexiconEntry(LibLexicon.ENDER_BLACK_HOLE_TALISMAN, categoryEnder); + blackHoleTalisman.setLexiconPages( + new PageText("0"), + new PageText("1"), + new PageText("2"), + new PageCraftingRecipe("3", ModCraftingRecipes.recipeBlackHoleTalisman)); + + corporeaCrystalCube = new ALexiconEntry(LibLexicon.ENDER_CORPOREA_CRYSTAL_CUBE, categoryEnder); + corporeaCrystalCube.setLexiconPages( + new PageText("0"), + new PageText("1"), + new PageText("3"), + new PageCraftingRecipe("2", ModCraftingRecipes.recipeCorporeaCrystalCube)); + + luminizerTransport = new ALexiconEntry(LibLexicon.ENDER_LUMINIZER_TRANSPORT, categoryEnder); + luminizerTransport.setLexiconPages( + new PageText("0"), + new PageText("1"), + new PageCraftingRecipe("2", ModCraftingRecipes.recipeLuminizer), + new PageText("3"), + new PageCraftingRecipe("4", ModCraftingRecipes.recipeDetectorLuminizer), + new PageText("5"), + new PageCraftingRecipe("6", ModCraftingRecipes.recipeLuminizerLauncher)); + + starSword = new ALexiconEntry(LibLexicon.ENDER_STAR_SWORD, categoryEnder); + starSword.setLexiconPages(new PageText("0"), new PageCraftingRecipe("1", ModCraftingRecipes.recipeStarSword)); + + thunderSword = new ALexiconEntry(LibLexicon.ENDER_THUNDER_SWORD, categoryEnder); + thunderSword.setLexiconPages( + new PageText("0"), new PageCraftingRecipe("1", ModCraftingRecipes.recipeThunderSword)); + + corporeaRetainer = new ALexiconEntry(LibLexicon.ENDER_CORPOREA_RETAINER, categoryEnder); + corporeaRetainer.setLexiconPages( + new PageText("0"), + new PageText("1"), + new PageText("2"), + new PageCraftingRecipe("3", ModCraftingRecipes.recipeCorporeaRetainer)); + + // BAUBLES ENTRIES + baublesIntro = new BLexiconEntry(LibLexicon.BAUBLE_INTRO, categoryBaubles); + baublesIntro + .setPriority() + .setLexiconPages(new PageText("0"), new PageImage("1", LibResources.ENTRY_BAUBLES), new PageText("2")); + + cosmeticBaubles = new BLexiconEntry(LibLexicon.BAUBLE_COSMETIC, categoryBaubles); + { + List pages = new ArrayList(); + pages.add(new PageText("0")); + pages.add(new PageText("1")); + if (ModCraftingRecipes.recipesCosmeticItems != null) { + for (int i = 0; i < 32; i++) { + pages.add(new PageCraftingRecipe("" + (i + 2), ModCraftingRecipes.recipesCosmeticItems.get(i))); + } + } + cosmeticBaubles.setPriority().setLexiconPages(pages.toArray(new LexiconPage[pages.size()])); + } + + tinyPlanet = new BLexiconEntry(LibLexicon.BAUBLE_TINY_PLANET, categoryBaubles); + tinyPlanet.setLexiconPages( + new PageText("0"), + new PageCraftingRecipe("1", ModCraftingRecipes.recipeTinyPlanet), + new PageCraftingRecipe("2", ModCraftingRecipes.recipeTinyPlanetBlock)); + + manaRing = new BLexiconEntry(LibLexicon.BAUBLE_MANA_RING, categoryBaubles); + manaRing.setLexiconPages( + new PageText("0"), + new PageCraftingRecipe("1", ModCraftingRecipes.recipeManaRing), + new PageCraftingRecipe("2", ModCraftingRecipes.recipeGreaterManaRing)); + + auraRing = new BLexiconEntry(LibLexicon.BAUBLE_AURA_RING, categoryBaubles); + auraRing.setLexiconPages( + new PageText("0"), + new PageCraftingRecipe("1", ModCraftingRecipes.recipeAuraRing), + new PageCraftingRecipe("2", ModCraftingRecipes.recipeGreaterAuraRing)); + + travelBelt = new BLexiconEntry(LibLexicon.BAUBLE_TRAVEL_BELT, categoryBaubles); + travelBelt.setLexiconPages(new PageText("0"), new PageCraftingRecipe("1", ModCraftingRecipes.recipeTravelBelt)); + + knockbacklBelt = new BLexiconEntry(LibLexicon.BAUBLE_KNOCKBACK_BELT, categoryBaubles); + knockbacklBelt.setLexiconPages( + new PageText("0"), new PageCraftingRecipe("1", ModCraftingRecipes.recipeKnocbackBelt)); + + icePendant = new BLexiconEntry(LibLexicon.BAUBLE_ICE_PENDANT, categoryBaubles); + icePendant.setLexiconPages(new PageText("0"), new PageCraftingRecipe("1", ModCraftingRecipes.recipeIcePendant)); + + lavaPendant = new BLexiconEntry(LibLexicon.BAUBLE_LAVA_PENDANT, categoryBaubles); + lavaPendant.setLexiconPages( + new PageText("0"), new PageCraftingRecipe("1", ModCraftingRecipes.recipeFirePendant)); + + goldLaurel = new ALexiconEntry(LibLexicon.BAUBLE_GOLDEN_LAUREL, categoryBaubles); + goldLaurel.setLexiconPages( + new PageText("0"), new PageCraftingRecipe("1", ModCraftingRecipes.recipeGoldenLaurel)); + + waterRing = new BLexiconEntry(LibLexicon.BAUBLE_WATER_RING, categoryBaubles); + waterRing.setLexiconPages(new PageText("0"), new PageCraftingRecipe("1", ModCraftingRecipes.recipeWaterRing)); + + miningRing = new BLexiconEntry(LibLexicon.BAUBLE_MINING_RING, categoryBaubles); + miningRing.setLexiconPages(new PageText("0"), new PageCraftingRecipe("1", ModCraftingRecipes.recipeMiningRing)); + + magnetRing = new BLexiconEntry(LibLexicon.BAUBLE_MAGNET_RING, categoryBaubles); + magnetRing.setLexiconPages( + new PageText("0"), + new PageCraftingRecipe("1", ModCraftingRecipes.recipeMagnetRing), + new PageCraftingRecipe("2", ModCraftingRecipes.recipeGreaterMagnetRing)); + + divaCharm = new ALexiconEntry(LibLexicon.BAUBLE_DIVA_CHARM, categoryBaubles); + divaCharm.setLexiconPages(new PageText("0"), new PageCraftingRecipe("1", ModCraftingRecipes.recipeDivaCharm)); + + pixieRing = new ALexiconEntry(LibLexicon.BAUBLE_PIXIE_RING, categoryBaubles); + pixieRing.setLexiconPages(new PageText("0"), new PageCraftingRecipe("1", ModCraftingRecipes.recipePixieRing)); + + superTravelBelt = new ALexiconEntry(LibLexicon.BAUBLE_SUPER_TRAVEL_BELT, categoryBaubles); + superTravelBelt.setLexiconPages( + new PageText("0"), new PageCraftingRecipe("1", ModCraftingRecipes.recipeSuperTravelBelt)); + + reachRing = new ALexiconEntry(LibLexicon.BAUBLE_REACH_RING, categoryBaubles); + reachRing.setLexiconPages(new PageText("0"), new PageCraftingRecipe("1", ModCraftingRecipes.recipeReachRing)); + + itemFinder = new BLexiconEntry(LibLexicon.BAUBLE_ITEM_FINDER, categoryBaubles); + itemFinder.setLexiconPages( + new PageText("0"), new PageText("1"), new PageCraftingRecipe("2", ModCraftingRecipes.recipeItemFinder)); + + superLavaPendant = new ALexiconEntry(LibLexicon.BAUBLE_SUPER_LAVA_PENDANT, categoryBaubles); + superLavaPendant.setLexiconPages( + new PageText("0"), new PageCraftingRecipe("1", ModCraftingRecipes.recipeSuperLavaPendant)); + + bloodPendant = new BLexiconEntry(LibLexicon.BAUBLE_BLOOD_PENDANT, categoryBaubles); + bloodPendant.setLexiconPages( + new PageText("0"), + new PageText("1"), + new PageCraftingRecipe("2", ModCraftingRecipes.recipeBloodPendant)); + + judgementCloaks = new ALexiconEntry(LibLexicon.BAUBLE_JUDGEMENT_CLOAKS, categoryBaubles); + judgementCloaks.setLexiconPages( + new PageText("0"), + new PageText("1"), + new PageCraftingRecipe("2", ModCraftingRecipes.recipeHolyCloak), + new PageCraftingRecipe("3", ModCraftingRecipes.recipeUnholyCloak)); + + monocle = new BLexiconEntry(LibLexicon.BAUBLE_MONOCLE, categoryBaubles); + monocle.setPriority() + .setLexiconPages( + new PageText("0"), + new PageText("2"), + new PageCraftingRecipe("1", ModCraftingRecipes.recipeMonocle)); + + swapRing = new BLexiconEntry(LibLexicon.BAUBLE_SWAP_RING, categoryBaubles); + swapRing.setLexiconPages(new PageText("0"), new PageCraftingRecipe("1", ModCraftingRecipes.recipeSwapRing)); + + speedUpBelt = new BLexiconEntry(LibLexicon.BAUBLE_SPEED_UP_BELT, categoryBaubles); + speedUpBelt.setLexiconPages( + new PageText("0"), new PageCraftingRecipe("1", ModCraftingRecipes.recipeSpeedUpBelt)); + + baubleBox = new BLexiconEntry(LibLexicon.BAUBLE_BOX, categoryBaubles); + baubleBox + .setLexiconPages(new PageText("0"), new PageCraftingRecipe("1", ModCraftingRecipes.recipeBaubleCase)) + .setPriority(); + + // ALFHOMANCY ENTRIES + alfhomancyIntro = new BLexiconEntry(LibLexicon.ALF_INTRO, categoryAlfhomancy); + alfhomancyIntro + .setPriority() + .setLexiconPages( + new PageText("0"), + new PageText("1"), + new PageCraftingRecipe("2", ModCraftingRecipes.recipeAlfPortal), + new PageCraftingRecipe("3", ModCraftingRecipes.recipeNaturaPylon), + new PageMultiblock("4", ModMultiblocks.alfPortal), + new PageText("5"), + new PageText("6"), + new PageText("7")) + .setIcon(new ItemStack(ModItems.lexicon)); + + elvenMessage = new ALexiconEntry(LibLexicon.ALF_MESSAGE, categoryAlfhomancy); + elvenMessage + .setPriority() + .setLexiconPages( + new PageImage("0", LibResources.ENTRY_ELVEN_GARDE), + new PageLoreText("1"), + new PageLoreText("2"), + new PageLoreText("3"), + new PageLoreText("4"), + new PageLoreText("5"), + new PageLoreText("6")) + .setIcon(new ItemStack(Items.writable_book)); + + elvenResources = new ALexiconEntry(LibLexicon.ALF_RESOURCES, categoryAlfhomancy); + elvenResources + .setPriority() + .setLexiconPages( + new PageText("0"), + new PageElvenRecipe("1", ModElvenTradeRecipes.dreamwoodRecipe), + new PageText("2"), + new PageCraftingRecipe("10", ModCraftingRecipes.recipeDreamwoodTwig), + new PageElvenRecipe("3", ModElvenTradeRecipes.elementiumRecipes), + new PageElvenRecipe("4", ModElvenTradeRecipes.pixieDustRecipe), + new PageElvenRecipe("5", ModElvenTradeRecipes.dragonstoneRecipes), + new PageText("6"), + new PageElvenRecipe("7", ModElvenTradeRecipes.elvenQuartzRecipe), + new PageText("8"), + new PageElvenRecipe("9", ModElvenTradeRecipes.alfglassRecipe)) + .setIcon(new ItemStack(ModItems.manaResource, 1, 9)); + + gaiaRitual = new ALexiconEntry(LibLexicon.ALF_GAIA_RITUAL, categoryAlfhomancy); + gaiaRitual + .setLexiconPages( + new PageText("0"), + new PageCraftingRecipe("1", ModCraftingRecipes.recipeGaiaPylon), + new PageMultiblock("2", ModMultiblocks.gaiaRitual), + new PageText("3"), + new PageText("4"), + new PageText("5")) + .setIcon(new ItemStack(ModItems.manaResource, 1, 5)); + LexiconRecipeMappings.map(new ItemStack(ModItems.manaResource, 1, 5), gaiaRitual, 0); + + gaiaRitualHardmode = new ALexiconEntry(LibLexicon.ALF_GAIA_RITUAL_HARDMODE, categoryAlfhomancy); + gaiaRitualHardmode + .setLexiconPages( + new PageText("0"), + new PageText("1"), + new PageCraftingRecipe("2", ModCraftingRecipes.recipeGaiaIngot)) + .setIcon(new ItemStack(ModItems.manaResource, 1, 14)); + + elvenLore = new ALexiconEntry(LibLexicon.ALF_LORE, categoryAlfhomancy); + elvenLore + .setLexiconPages( + new PageText("0"), + new PageLoreText("1"), + new PageLoreText("2"), + new PageLoreText("3"), + new PageLoreText("4"), + new PageLoreText("5"), + new PageLoreText("6"), + new PageLoreText("7")) + .setIcon(new ItemStack(Items.writable_book)); + + if (ConfigHandler.relicsEnabled) { + relics = new ALexiconEntry(LibLexicon.ALF_RELICS, categoryAlfhomancy); + relics.setLexiconPages(new PageText("0")).setIcon(new ItemStack(ModItems.dice)); + + relicInfo = new RLexiconEntry(LibLexicon.ALF_RELIC_INFO, categoryAlfhomancy, null); + relicInfo.setLexiconPages(new PageText("0"), new PageText("1")).setIcon(new ItemStack(ModItems.dice)); + + infiniteFruit = new RLexiconEntry( + LibLexicon.ALF_INFINITE_FRUIT, categoryAlfhomancy, ModAchievements.relicInfiniteFruit); + infiniteFruit.setLexiconPages(new PageText("0")); + + kingKey = new RLexiconEntry(LibLexicon.ALF_KING_KEY, categoryAlfhomancy, ModAchievements.relicKingKey); + kingKey.setLexiconPages(new PageText("0")); + + flugelEye = + new RLexiconEntry(LibLexicon.ALF_FLUGEL_EYE, categoryAlfhomancy, ModAchievements.relicFlugelEye); + flugelEye.setLexiconPages(new PageText("0"), new PageText("1")); + + thorRing = new RLexiconEntry(LibLexicon.ALF_THOR_RING, categoryAlfhomancy, ModAchievements.relicThorRing); + thorRing.setLexiconPages(new PageText("0")); + + lokiRing = new RLexiconEntry(LibLexicon.ALF_LOKI_RING, categoryAlfhomancy, ModAchievements.relicLokiRing); + lokiRing.setLexiconPages(new PageText("0"), new PageText("1"), new PageText("2"), new PageText("3")); + + odinRing = new RLexiconEntry(LibLexicon.ALF_ODIN_RING, categoryAlfhomancy, ModAchievements.relicOdinRing); + odinRing.setLexiconPages(new PageText("0")); + } + + // MISCLENAEOUS ENTRIES + unstableBlocks = new BLexiconEntry(LibLexicon.MISC_UNSTABLE_BLOCKS, categoryMisc); + unstableBlocks.setLexiconPages( + new PageText("0"), + new PageImage("1", LibResources.ENTRY_UNSTABLE_BLOCK), + new PageCraftingRecipe("2", ModCraftingRecipes.recipesUnstableBlocks), + new PageText("3"), + new PageImage("4", LibResources.ENTRY_UNSTABLE_BEACON), + new PageCraftingRecipe("5", ModCraftingRecipes.recipesManaBeacons), + new PageText("6"), + new PageCraftingRecipe("7", ModCraftingRecipes.recipesSignalFlares)); + + decorativeBlocks = new BLexiconEntry(LibLexicon.MISC_DECORATIVE_BLOCKS, categoryMisc); + if (ConfigHandler.darkQuartzEnabled) + decorativeBlocks.setLexiconPages( + new PageText("0"), + new PageCraftingRecipe("1", ModCraftingRecipes.recipeLivingrockDecor1), + new PageCraftingRecipe("2", ModCraftingRecipes.recipeLivingrockDecor2), + new PageCraftingRecipe("3", ModCraftingRecipes.recipeLivingrockDecor3), + new PageCraftingRecipe("4", ModCraftingRecipes.recipeLivingrockDecor4), + new PageCraftingRecipe("5", ModCraftingRecipes.recipeLivingwoodDecor1), + new PageCraftingRecipe("6", ModCraftingRecipes.recipeLivingwoodDecor2), + new PageCraftingRecipe("7", ModCraftingRecipes.recipeLivingwoodDecor3), + new PageCraftingRecipe("8", ModCraftingRecipes.recipeLivingwoodDecor4), + new PageCraftingRecipe("9", ModCraftingRecipes.recipeLivingwoodDecor5), + new PageText("10"), + new PageCraftingRecipe("11", ModCraftingRecipes.recipeDarkQuartz), + new PageManaInfusionRecipe("12", ModManaInfusionRecipes.manaQuartzRecipe), + new PageCraftingRecipe("13", ModCraftingRecipes.recipeBlazeQuartz), + new PageCraftingRecipe("14", ModCraftingRecipes.recipesLavenderQuartz), + new PageCraftingRecipe("15", ModCraftingRecipes.recipeRedQuartz), + new PageCraftingRecipe("23", ModCraftingRecipes.recipeSunnyQuartz), + new PageText("16"), + new PageCraftingRecipe("17", ModCraftingRecipes.recipeReedBlock), + new PageCraftingRecipe("18", ModCraftingRecipes.recipeThatch), + new PageCraftingRecipe("19", ModCraftingRecipes.recipeRoofTile), + new PageCraftingRecipe("20", ModCraftingRecipes.recipeNetherBrick), + new PageCraftingRecipe("21", ModCraftingRecipes.recipeSoulBrick), + new PageCraftingRecipe("22", ModCraftingRecipes.recipeSnowBrick)); + else + decorativeBlocks.setLexiconPages( + new PageText("0"), + new PageCraftingRecipe("1", ModCraftingRecipes.recipeLivingrockDecor1), + new PageCraftingRecipe("2", ModCraftingRecipes.recipeLivingrockDecor2), + new PageCraftingRecipe("3", ModCraftingRecipes.recipeLivingrockDecor3), + new PageCraftingRecipe("4", ModCraftingRecipes.recipeLivingrockDecor4), + new PageCraftingRecipe("5", ModCraftingRecipes.recipeLivingwoodDecor1), + new PageCraftingRecipe("6", ModCraftingRecipes.recipeLivingwoodDecor2), + new PageCraftingRecipe("7", ModCraftingRecipes.recipeLivingwoodDecor3), + new PageCraftingRecipe("8", ModCraftingRecipes.recipeLivingwoodDecor4), + new PageCraftingRecipe("9", ModCraftingRecipes.recipeLivingwoodDecor5), + new PageText("10"), + new PageManaInfusionRecipe("12", ModManaInfusionRecipes.manaQuartzRecipe), + new PageCraftingRecipe("13", ModCraftingRecipes.recipeBlazeQuartz), + new PageCraftingRecipe("14", ModCraftingRecipes.recipesLavenderQuartz), + new PageCraftingRecipe("15", ModCraftingRecipes.recipeRedQuartz), + new PageCraftingRecipe("23", ModCraftingRecipes.recipeSunnyQuartz), + new PageText("16"), + new PageCraftingRecipe("17", ModCraftingRecipes.recipeReedBlock), + new PageCraftingRecipe("18", ModCraftingRecipes.recipeThatch), + new PageCraftingRecipe("19", ModCraftingRecipes.recipeRoofTile), + new PageCraftingRecipe("20", ModCraftingRecipes.recipeNetherBrick), + new PageCraftingRecipe("21", ModCraftingRecipes.recipeSoulBrick), + new PageCraftingRecipe("22", ModCraftingRecipes.recipeSnowBrick)); + + dispenserTweaks = new BLexiconEntry(LibLexicon.MISC_DISPENSER_TWEAKS, categoryMisc); + dispenserTweaks.setLexiconPages(new PageText("0")).setPriority().setIcon(new ItemStack(Blocks.dispenser)); + + shinyFlowers = new BLexiconEntry(LibLexicon.MISC_SHINY_FLOWERS, categoryMisc); + shinyFlowers.setLexiconPages( + new PageText("0"), + new PageText("3"), + new PageCraftingRecipe("1", ModCraftingRecipes.recipesShinyFlowers), + new PageCraftingRecipe("2", ModCraftingRecipes.recipesMiniIsland)); + + prismarine = new BLexiconEntry(LibLexicon.MISC_PRISMARINE, categoryMisc); + prismarine.setLexiconPages( + new PageText("0"), + new PageText("1"), + new PageManaInfusionRecipe("2", ModManaAlchemyRecipes.prismarineRecipe), + new PageCraftingRecipe("3", ModCraftingRecipes.recipePrismarine), + new PageCraftingRecipe("4", ModCraftingRecipes.recipePrismarineBrick), + new PageCraftingRecipe("5", ModCraftingRecipes.recipeDarkPrismarine), + new PageCraftingRecipe("6", ModCraftingRecipes.recipeSeaLamp)); + + tinyPotato = new BLexiconEntry(LibLexicon.MISC_TINY_POTATO, categoryMisc); + tinyPotato.setLexiconPages( + new PageText("0"), new PageManaInfusionRecipe("1", ModManaInfusionRecipes.tinyPotatoRecipe)); + + headCreating = new HLexiconEntry(LibLexicon.MISC_HEAD_CREATING, categoryMisc); + headCreating.setLexiconPages( + new PageText("0"), new PageText("2"), new PageRuneRecipe("1", ModRuneRecipes.recipeHead)); + + azulejo = new BLexiconEntry(LibLexicon.MISC_AZULEJO, categoryMisc); + azulejo.setLexiconPages( + new PageText("0"), + new PageImage("1", LibResources.ENTRY_AZULEJOS), + new PageCraftingRecipe("2", ModCraftingRecipes.recipeAzulejo), + new PageCraftingRecipe("3", ModCraftingRecipes.recipesAzulejoCycling)); + + starfield = new ALexiconEntry(LibLexicon.MISC_STARFIELD, categoryMisc); + starfield.setLexiconPages(new PageText("0"), new PageCraftingRecipe("1", ModCraftingRecipes.recipeStarfield)); + + dirtPath = new BLexiconEntry(LibLexicon.MISC_DIRT_PATH, categoryMisc); + dirtPath.setLexiconPages( + new PageText("0"), + new PageCraftingRecipe("1", ModCraftingRecipes.recipeDirtPath), + new PageCraftingRecipe("2", ModCraftingRecipes.recipeDirtPathSlab)); + + mushrooms = new BLexiconEntry(LibLexicon.MISC_MUSHROOMS, categoryMisc); + mushrooms.setLexiconPages(new PageText("0"), new PageCraftingRecipe("1", ModCraftingRecipes.recipesMushrooms)); + + phantomInk = new BLexiconEntry(LibLexicon.MISC_PHANTOM_INK, categoryMisc); + phantomInk.setLexiconPages(new PageText("0"), new PageCraftingRecipe("1", ModCraftingRecipes.recipePhantomInk)); + + if (ConfigHandler.stones18Enabled) { + stoneAlchemy = new BLexiconEntry(LibLexicon.MISC_STONE_ALCHEMY, categoryMisc); + stoneAlchemy.setLexiconPages( + new PageText("0"), + new PageManaInfusionRecipe("1", ModManaAlchemyRecipes.stoneRecipes), + new PageCraftingRecipe("2", ModCraftingRecipes.recipe18StonePolish), + new PageCraftingRecipe("3", ModCraftingRecipes.recipe18StoneBrick), + new PageCraftingRecipe("4", ModCraftingRecipes.recipe18StoneChisel)); + } + + blazeBlock = new BLexiconEntry(LibLexicon.MISC_BLAZE_BLOCK, categoryMisc); + blazeBlock.setLexiconPages(new PageText("0"), new PageCraftingRecipe("1", ModCraftingRecipes.recipeBlazeBlock)); + LexiconRecipeMappings.map(new ItemStack(Blocks.obsidian), blazeBlock, 0); + + challenges = new BLexiconEntry(LibLexicon.MISC_CHALLENGES, categoryMisc); + challenges + .setLexiconPages(new PageText("0"), new PageText("1"), new PageText("2")) + .setPriority() + .setIcon(new ItemStack(ModItems.cosmetic, 1, 31)); + + cacophonium = new BLexiconEntry(LibLexicon.MISC_CACOPHONIUM, categoryMisc); + cacophonium.setLexiconPages( + new PageText("0"), + new PageCraftingRecipe("1", ModCraftingRecipes.recipeCacophonium), + new PageText("2")); + + pavement = new BLexiconEntry(LibLexicon.MISC_PAVEMENT, categoryMisc); + pavement.setLexiconPages(new PageText("0"), new PageCraftingRecipe("1", ModCraftingRecipes.recipesPavement)); + + preventingDecay = new DLexiconEntry(LibLexicon.MISC_PRENTING_DECAY, categoryMisc); + preventingDecay.setLexiconPages(new PageText("0")).setIcon(new ItemStack(Blocks.deadbush)); + + if (Botania.bcTriggersLoaded) { + bcIntegration = new CLexiconEntry(LibLexicon.MISC_BC_INTEGRATION, categoryMisc, "BuildCraft"); + bcIntegration.setLexiconPages(new PageText("0")).setIcon(new ItemStack(Items.redstone)); + } + } + + public static void postInit() { + if (SheddingHandler.hasShedding()) { + shedding = new BLexiconEntry(LibLexicon.MISC_SHEDDING, BotaniaAPI.categoryMisc); + shedding.setLexiconPages(new PageText("0")).setPriority().setIcon(new ItemStack(Items.feather)); + SheddingHandler.addToLexicon(); + } + + if (Botania.thaumcraftLoaded) { + tcIntegration = new CLexiconEntry(LibLexicon.MISC_TC_INTEGRATION, BotaniaAPI.categoryMisc, "Thaumcraft"); + + if (ConfigHandler.enableThaumcraftStablizers) + tcIntegration + .setLexiconPages( + new PageText("0"), + new PageText("1"), + new PageCraftingRecipe("2", ModCraftingRecipes.recipeHelmetOfRevealing), + new PageText("3"), + new PageManaInfusionRecipe("4", ModManaInfusionRecipes.manaInkwellRecipe), + new PageText("5"), + new PageBrew(ModBrewRecipes.warpWardBrew, "6a", "6b")) + .setIcon(new ItemStack(ModItems.manaInkwell)); + else + tcIntegration + .setLexiconPages( + new PageText("0"), + new PageText("1"), + new PageCraftingRecipe("2", ModCraftingRecipes.recipeHelmetOfRevealing), + new PageText("3"), + new PageManaInfusionRecipe("4", ModManaInfusionRecipes.manaInkwellRecipe), + new PageBrew(ModBrewRecipes.warpWardBrew, "6a", "6b")) + .setIcon(new ItemStack(ModItems.manaInkwell)); + } + + if (Botania.etFuturumLoaded) { + banners = new CLexiconEntry(LibLexicon.MISC_BANNERS, BotaniaAPI.categoryMisc, "EtFuturum"); + banners.setLexiconPages(new PageText("0"), new PageImage("1", LibResources.ENTRY_BANNERS)) + .setIcon(new ItemStack(ModItems.lexicon)); + } + } } diff --git a/src/main/java/vazkii/botania/common/lexicon/RLexiconEntry.java b/src/main/java/vazkii/botania/common/lexicon/RLexiconEntry.java index 1980bbff5b..f0176f7239 100644 --- a/src/main/java/vazkii/botania/common/lexicon/RLexiconEntry.java +++ b/src/main/java/vazkii/botania/common/lexicon/RLexiconEntry.java @@ -2,39 +2,39 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Aug 16, 2015, 10:52:36 PM (GMT)] */ package vazkii.botania.common.lexicon; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; import net.minecraft.client.Minecraft; import net.minecraft.client.entity.EntityClientPlayerMP; import net.minecraft.stats.Achievement; import vazkii.botania.api.BotaniaAPI; import vazkii.botania.api.lexicon.LexiconCategory; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; - -public class RLexiconEntry extends BLexiconEntry { - Achievement a; +public class RLexiconEntry extends BLexiconEntry { - public RLexiconEntry(String unlocalizedName, LexiconCategory category, Achievement a) { - super(unlocalizedName, category); - setKnowledgeType(BotaniaAPI.relicKnowledge); - this.a = a; - if(a != null) - setIcon(a.theItemStack.copy()); - } + Achievement a; - @Override - @SideOnly(Side.CLIENT) - public boolean isVisible() { - EntityClientPlayerMP player = Minecraft.getMinecraft().thePlayer; - return a == null || player.capabilities.isCreativeMode || player.getStatFileWriter().hasAchievementUnlocked(a); - } + public RLexiconEntry(String unlocalizedName, LexiconCategory category, Achievement a) { + super(unlocalizedName, category); + setKnowledgeType(BotaniaAPI.relicKnowledge); + this.a = a; + if (a != null) setIcon(a.theItemStack.copy()); + } + @Override + @SideOnly(Side.CLIENT) + public boolean isVisible() { + EntityClientPlayerMP player = Minecraft.getMinecraft().thePlayer; + return a == null + || player.capabilities.isCreativeMode + || player.getStatFileWriter().hasAchievementUnlocked(a); + } } diff --git a/src/main/java/vazkii/botania/common/lexicon/TLexiconEntry.java b/src/main/java/vazkii/botania/common/lexicon/TLexiconEntry.java index d03e649f58..acc0195fc7 100644 --- a/src/main/java/vazkii/botania/common/lexicon/TLexiconEntry.java +++ b/src/main/java/vazkii/botania/common/lexicon/TLexiconEntry.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Feb 16, 2015, 1:41:58 PM (GMT)] */ package vazkii.botania.common.lexicon; @@ -18,12 +18,10 @@ public class TLexiconEntry extends BLexiconEntry { - public TLexiconEntry() { - super(LibLexicon.BASICS_TUTORIAL, BotaniaAPI.categoryBasics); - setPriority(); - setIcon(new ItemStack(Items.book)); - setLexiconPages(new PageTutorial("0")); - } - - + public TLexiconEntry() { + super(LibLexicon.BASICS_TUTORIAL, BotaniaAPI.categoryBasics); + setPriority(); + setIcon(new ItemStack(Items.book)); + setLexiconPages(new PageTutorial("0")); + } } diff --git a/src/main/java/vazkii/botania/common/lexicon/WIPLexiconEntry.java b/src/main/java/vazkii/botania/common/lexicon/WIPLexiconEntry.java index da8b7031f8..8bb2c82ec1 100644 --- a/src/main/java/vazkii/botania/common/lexicon/WIPLexiconEntry.java +++ b/src/main/java/vazkii/botania/common/lexicon/WIPLexiconEntry.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jun 8, 2014, 7:06:06 PM (GMT)] */ package vazkii.botania.common.lexicon; @@ -15,13 +15,12 @@ public class WIPLexiconEntry extends BLexiconEntry implements IAddonEntry { - public WIPLexiconEntry(String unlocalizedName, LexiconCategory category) { - super(unlocalizedName, category); - } - - @Override - public String getSubtitle() { - return "botania.gui.lexicon.wip"; - } + public WIPLexiconEntry(String unlocalizedName, LexiconCategory category) { + super(unlocalizedName, category); + } + @Override + public String getSubtitle() { + return "botania.gui.lexicon.wip"; + } } diff --git a/src/main/java/vazkii/botania/common/lexicon/WLexiconEntry.java b/src/main/java/vazkii/botania/common/lexicon/WLexiconEntry.java index 26d745ec61..ab938ee4e8 100644 --- a/src/main/java/vazkii/botania/common/lexicon/WLexiconEntry.java +++ b/src/main/java/vazkii/botania/common/lexicon/WLexiconEntry.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [May 30, 2015, 10:54:30 PM (GMT)] */ package vazkii.botania.common.lexicon; @@ -20,22 +20,20 @@ public class WLexiconEntry extends BLexiconEntry { - private static final int PAGES = 7; + private static final int PAGES = 7; - public WLexiconEntry() { - super(LibLexicon.BASICS_WELCOME, BotaniaAPI.categoryBasics); - setPriority(); - setIcon(new ItemStack(ModItems.cosmetic, 1, 31)); + public WLexiconEntry() { + super(LibLexicon.BASICS_WELCOME, BotaniaAPI.categoryBasics); + setPriority(); + setIcon(new ItemStack(ModItems.cosmetic, 1, 31)); - LexiconPage[] pages = new LexiconPage[PAGES]; - for(int i = 0; i < PAGES; i++) - pages[i] = new PageText("" + i); - setLexiconPages(pages); - } - - @Override - public int compareTo(LexiconEntry o) { - return -1; - } + LexiconPage[] pages = new LexiconPage[PAGES]; + for (int i = 0; i < PAGES; i++) pages[i] = new PageText("" + i); + setLexiconPages(pages); + } + @Override + public int compareTo(LexiconEntry o) { + return -1; + } } diff --git a/src/main/java/vazkii/botania/common/lexicon/page/PageBrew.java b/src/main/java/vazkii/botania/common/lexicon/page/PageBrew.java index f064ad0deb..5b330f2730 100644 --- a/src/main/java/vazkii/botania/common/lexicon/page/PageBrew.java +++ b/src/main/java/vazkii/botania/common/lexicon/page/PageBrew.java @@ -2,17 +2,18 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Nov 2, 2014, 5:17:46 PM (GMT)] */ package vazkii.botania.common.lexicon.page; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; import java.util.ArrayList; import java.util.List; - import net.minecraft.client.Minecraft; import net.minecraft.client.gui.FontRenderer; import net.minecraft.item.ItemStack; @@ -26,93 +27,92 @@ import vazkii.botania.api.lexicon.ITwoNamedPage; import vazkii.botania.api.recipe.RecipeBrew; import vazkii.botania.common.item.ModItems; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; public class PageBrew extends PageRecipe implements ITwoNamedPage { - RecipeBrew recipe; - String text; - - public PageBrew(RecipeBrew recipe, String unlocalizedName, String bottomText) { - super(bottomText); - this.recipe = recipe; - text = unlocalizedName; - } - - @Override - public void renderRecipe(IGuiLexiconEntry gui, int mx, int my) { - int width = gui.getWidth() - 30; - int height = gui.getHeight(); - int x = gui.getLeft() + 16; - int y = gui.getTop() + 12; - - Brew brew = recipe.getBrew(); - FontRenderer renderer = Minecraft.getMinecraft().fontRenderer; - boolean unicode = renderer.getUnicodeFlag(); - renderer.setUnicodeFlag(true); - String s = EnumChatFormatting.BOLD + String.format(StatCollector.translateToLocal("botaniamisc.brewOf"), StatCollector.translateToLocal(brew.getUnlocalizedName())); - renderer.drawString(s, gui.getLeft() + gui.getWidth() / 2 - renderer.getStringWidth(s) / 2, y, 0x222222); - renderer.setUnicodeFlag(unicode); - PageText.renderText(x, y + 22, width, height, text); - - ItemStack book = Minecraft.getMinecraft().thePlayer.getCurrentEquippedItem(); - if(book != null && book.getItem() instanceof ILexicon && ((ILexicon) book.getItem()).isKnowledgeUnlocked(book, BotaniaAPI.elvenKnowledge)) { - renderItemAtLinePos(gui, 20, 2, y + 12, recipe.getOutput(new ItemStack(ModItems.vial))); - renderItemAtLinePos(gui, 20, 3, y + 12, recipe.getOutput(new ItemStack(ModItems.vial, 1, 1))); - } else renderItemAtLinePos(gui, 0, -1, y + 12, recipe.getOutput(new ItemStack(ModItems.vial))); - - int i = 0; - y = gui.getTop() + gui.getHeight() - 54; - List inputs = new ArrayList(recipe.getInputs()); - - int offset = gui.getWidth() / 2 - inputs.size() * 9; - for(Object input : inputs) { - if(input instanceof String) - input = OreDictionary.getOres((String) input).get(0); - - renderItemAtLinePos(gui, offset, i, y, (ItemStack) input); - i++; - } - - super.renderRecipe(gui, mx, my); - } - - @SideOnly(Side.CLIENT) - public void renderItemAtLinePos(IGuiLexiconEntry gui, int offset, int pos, int yPos, ItemStack stack) { - if(stack == null || stack.getItem() == null) - return; - stack = stack.copy(); - - if(stack.getItemDamage() == Short.MAX_VALUE) - stack.setItemDamage(0); - - int xPos = gui.getLeft() + (pos == -1 ? gui.getWidth() / 2 - 8 : pos * 18) + offset; - - ItemStack stack1 = stack.copy(); - if(stack1.getItemDamage() == -1) - stack1.setItemDamage(0); - - renderItem(gui, xPos, yPos, stack1, false); - } - - @Override - public List getDisplayedRecipes() { - ArrayList list = new ArrayList(); - if (recipe != null) { - list.add(recipe.getOutput(new ItemStack(ModItems.vial))); - } - return list; - } - - @Override - public void setSecondUnlocalizedName(String name) { - text = name; - } - - @Override - public String getSecondUnlocalizedName() { - return text; - } - + RecipeBrew recipe; + String text; + + public PageBrew(RecipeBrew recipe, String unlocalizedName, String bottomText) { + super(bottomText); + this.recipe = recipe; + text = unlocalizedName; + } + + @Override + public void renderRecipe(IGuiLexiconEntry gui, int mx, int my) { + int width = gui.getWidth() - 30; + int height = gui.getHeight(); + int x = gui.getLeft() + 16; + int y = gui.getTop() + 12; + + Brew brew = recipe.getBrew(); + FontRenderer renderer = Minecraft.getMinecraft().fontRenderer; + boolean unicode = renderer.getUnicodeFlag(); + renderer.setUnicodeFlag(true); + String s = EnumChatFormatting.BOLD + + String.format( + StatCollector.translateToLocal("botaniamisc.brewOf"), + StatCollector.translateToLocal(brew.getUnlocalizedName())); + renderer.drawString(s, gui.getLeft() + gui.getWidth() / 2 - renderer.getStringWidth(s) / 2, y, 0x222222); + renderer.setUnicodeFlag(unicode); + PageText.renderText(x, y + 22, width, height, text); + + ItemStack book = Minecraft.getMinecraft().thePlayer.getCurrentEquippedItem(); + if (book != null + && book.getItem() instanceof ILexicon + && ((ILexicon) book.getItem()).isKnowledgeUnlocked(book, BotaniaAPI.elvenKnowledge)) { + renderItemAtLinePos(gui, 20, 2, y + 12, recipe.getOutput(new ItemStack(ModItems.vial))); + renderItemAtLinePos(gui, 20, 3, y + 12, recipe.getOutput(new ItemStack(ModItems.vial, 1, 1))); + } else renderItemAtLinePos(gui, 0, -1, y + 12, recipe.getOutput(new ItemStack(ModItems.vial))); + + int i = 0; + y = gui.getTop() + gui.getHeight() - 54; + List inputs = new ArrayList(recipe.getInputs()); + + int offset = gui.getWidth() / 2 - inputs.size() * 9; + for (Object input : inputs) { + if (input instanceof String) + input = OreDictionary.getOres((String) input).get(0); + + renderItemAtLinePos(gui, offset, i, y, (ItemStack) input); + i++; + } + + super.renderRecipe(gui, mx, my); + } + + @SideOnly(Side.CLIENT) + public void renderItemAtLinePos(IGuiLexiconEntry gui, int offset, int pos, int yPos, ItemStack stack) { + if (stack == null || stack.getItem() == null) return; + stack = stack.copy(); + + if (stack.getItemDamage() == Short.MAX_VALUE) stack.setItemDamage(0); + + int xPos = gui.getLeft() + (pos == -1 ? gui.getWidth() / 2 - 8 : pos * 18) + offset; + + ItemStack stack1 = stack.copy(); + if (stack1.getItemDamage() == -1) stack1.setItemDamage(0); + + renderItem(gui, xPos, yPos, stack1, false); + } + + @Override + public List getDisplayedRecipes() { + ArrayList list = new ArrayList(); + if (recipe != null) { + list.add(recipe.getOutput(new ItemStack(ModItems.vial))); + } + return list; + } + + @Override + public void setSecondUnlocalizedName(String name) { + text = name; + } + + @Override + public String getSecondUnlocalizedName() { + return text; + } } diff --git a/src/main/java/vazkii/botania/common/lexicon/page/PageCraftingRecipe.java b/src/main/java/vazkii/botania/common/lexicon/page/PageCraftingRecipe.java index 5957e097f6..f7ba24a95c 100644 --- a/src/main/java/vazkii/botania/common/lexicon/page/PageCraftingRecipe.java +++ b/src/main/java/vazkii/botania/common/lexicon/page/PageCraftingRecipe.java @@ -2,18 +2,20 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jan 19, 2014, 4:58:19 PM (GMT)] */ package vazkii.botania.common.lexicon.page; +import cpw.mods.fml.relauncher.ReflectionHelper; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; import java.util.ArrayList; import java.util.Arrays; import java.util.List; - import net.minecraft.client.Minecraft; import net.minecraft.client.gui.GuiScreen; import net.minecraft.client.renderer.texture.TextureManager; @@ -25,171 +27,176 @@ import net.minecraft.util.StatCollector; import net.minecraftforge.oredict.ShapedOreRecipe; import net.minecraftforge.oredict.ShapelessOreRecipe; - import org.lwjgl.opengl.GL11; - import vazkii.botania.api.internal.IGuiLexiconEntry; import vazkii.botania.api.lexicon.LexiconEntry; import vazkii.botania.api.lexicon.LexiconRecipeMappings; import vazkii.botania.client.core.helper.RenderHelper; import vazkii.botania.client.lib.LibResources; -import cpw.mods.fml.relauncher.ReflectionHelper; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; public class PageCraftingRecipe extends PageRecipe { - private static final ResourceLocation craftingOverlay = new ResourceLocation(LibResources.GUI_CRAFTING_OVERLAY); - - List recipes; - int ticksElapsed = 0; - int recipeAt = 0; - - boolean oreDictRecipe, shapelessRecipe; - - public PageCraftingRecipe(String unlocalizedName, List recipes) { - super(unlocalizedName); - this.recipes = filterRecipes(recipes); - } - - public PageCraftingRecipe(String unlocalizedName, IRecipe recipe) { - this(unlocalizedName, Arrays.asList(recipe)); - } - - @Override - public void onPageAdded(LexiconEntry entry, int index) { - for(IRecipe recipe : recipes) - if (recipe != null) - LexiconRecipeMappings.map(recipe.getRecipeOutput(), entry, index); - } - - @Override - @SideOnly(Side.CLIENT) - public void renderRecipe(IGuiLexiconEntry gui, int mx, int my) { - oreDictRecipe = shapelessRecipe = false; - - if (recipes.size() == 0) return; - IRecipe recipe = recipes.get(recipeAt); - - renderCraftingRecipe(gui, recipe); - - TextureManager render = Minecraft.getMinecraft().renderEngine; - render.bindTexture(craftingOverlay); - - GL11.glEnable(GL11.GL_BLEND); - GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); - GL11.glColor4f(1F, 1F, 1F, 1F); - ((GuiScreen) gui).drawTexturedModalRect(gui.getLeft(), gui.getTop(), 0, 0, gui.getWidth(), gui.getHeight()); - - int iconX = gui.getLeft() + 115; - int iconY = gui.getTop() + 12; + private static final ResourceLocation craftingOverlay = new ResourceLocation(LibResources.GUI_CRAFTING_OVERLAY); - GL11.glEnable(GL11.GL_BLEND); - GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); - - if(shapelessRecipe) { - ((GuiScreen) gui).drawTexturedModalRect(iconX, iconY, 240, 0, 16, 16); - - if(mx >= iconX && my >= iconY && mx < iconX + 16 && my < iconY + 16) - RenderHelper.renderTooltip(mx, my, Arrays.asList(StatCollector.translateToLocal("botaniamisc.shapeless"))); - - iconY += 20; - } - - render.bindTexture(craftingOverlay); - GL11.glEnable(GL11.GL_BLEND); - - if(oreDictRecipe) { - ((GuiScreen) gui).drawTexturedModalRect(iconX, iconY, 240, 16, 16, 16); - - if(mx >= iconX && my >= iconY && mx < iconX + 16 && my < iconY + 16) - RenderHelper.renderTooltip(mx, my, Arrays.asList(StatCollector.translateToLocal("botaniamisc.oredict"))); - } - GL11.glDisable(GL11.GL_BLEND); - } - - @Override - @SideOnly(Side.CLIENT) - public void updateScreen() { - if(GuiScreen.isShiftKeyDown()) - return; - - if(ticksElapsed % 20 == 0) { - recipeAt++; - - if(recipeAt == recipes.size()) - recipeAt = 0; - } - ++ticksElapsed; - } - - @SideOnly(Side.CLIENT) - public void renderCraftingRecipe(IGuiLexiconEntry gui, IRecipe recipe) { - if(recipe instanceof ShapedRecipes) { - ShapedRecipes shaped = (ShapedRecipes)recipe; - - for(int y = 0; y < shaped.recipeHeight; y++) - for(int x = 0; x < shaped.recipeWidth; x++) - renderItemAtGridPos(gui, 1 + x, 1 + y, shaped.recipeItems[y * shaped.recipeWidth + x], true); - } else if(recipe instanceof ShapedOreRecipe) { - ShapedOreRecipe shaped = (ShapedOreRecipe) recipe; - int width = (Integer) ReflectionHelper.getPrivateValue(ShapedOreRecipe.class, shaped, 4); - int height = (Integer) ReflectionHelper.getPrivateValue(ShapedOreRecipe.class, shaped, 5); - - for(int y = 0; y < height; y++) - for(int x = 0; x < width; x++) { - Object input = shaped.getInput()[y * width + x]; - if(input != null) - renderItemAtGridPos(gui, 1 + x, 1 + y, input instanceof ItemStack ? (ItemStack) input : ((ArrayList) input).get(0), true); - } - - oreDictRecipe = true; - } else if(recipe instanceof ShapelessRecipes) { - ShapelessRecipes shapeless = (ShapelessRecipes) recipe; - - drawGrid : { - for(int y = 0; y < 3; y++) - for(int x = 0; x < 3; x++) { - int index = y * 3 + x; - - if(index >= shapeless.recipeItems.size()) - break drawGrid; - - renderItemAtGridPos(gui, 1 + x, 1 + y, (ItemStack) shapeless.recipeItems.get(index), true); - } - } - - shapelessRecipe = true; - } else if(recipe instanceof ShapelessOreRecipe) { - ShapelessOreRecipe shapeless = (ShapelessOreRecipe) recipe; - - drawGrid : { - for(int y = 0; y < 3; y++) - for(int x = 0; x < 3; x++) { - int index = y * 3 + x; - - if(index >= shapeless.getRecipeSize()) - break drawGrid; - - Object input = shapeless.getInput().get(index); - if(input != null) - renderItemAtGridPos(gui, 1 + x, 1 + y, input instanceof ItemStack ? (ItemStack) input : ((ArrayList) input).get(0), true); - } - } - - shapelessRecipe = true; - oreDictRecipe = true; - } - - renderItemAtGridPos(gui, 2, 0, recipe.getRecipeOutput(), false); - } - - @Override - public List getDisplayedRecipes() { - ArrayList list = new ArrayList(); - for(IRecipe r : recipes) - list.add(r.getRecipeOutput()); - - return list; - } + List recipes; + int ticksElapsed = 0; + int recipeAt = 0; + + boolean oreDictRecipe, shapelessRecipe; + + public PageCraftingRecipe(String unlocalizedName, List recipes) { + super(unlocalizedName); + this.recipes = filterRecipes(recipes); + } + + public PageCraftingRecipe(String unlocalizedName, IRecipe recipe) { + this(unlocalizedName, Arrays.asList(recipe)); + } + + @Override + public void onPageAdded(LexiconEntry entry, int index) { + for (IRecipe recipe : recipes) + if (recipe != null) LexiconRecipeMappings.map(recipe.getRecipeOutput(), entry, index); + } + + @Override + @SideOnly(Side.CLIENT) + public void renderRecipe(IGuiLexiconEntry gui, int mx, int my) { + oreDictRecipe = shapelessRecipe = false; + + if (recipes.size() == 0) return; + IRecipe recipe = recipes.get(recipeAt); + + renderCraftingRecipe(gui, recipe); + + TextureManager render = Minecraft.getMinecraft().renderEngine; + render.bindTexture(craftingOverlay); + + GL11.glEnable(GL11.GL_BLEND); + GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); + GL11.glColor4f(1F, 1F, 1F, 1F); + ((GuiScreen) gui).drawTexturedModalRect(gui.getLeft(), gui.getTop(), 0, 0, gui.getWidth(), gui.getHeight()); + + int iconX = gui.getLeft() + 115; + int iconY = gui.getTop() + 12; + + GL11.glEnable(GL11.GL_BLEND); + GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); + + if (shapelessRecipe) { + ((GuiScreen) gui).drawTexturedModalRect(iconX, iconY, 240, 0, 16, 16); + + if (mx >= iconX && my >= iconY && mx < iconX + 16 && my < iconY + 16) + RenderHelper.renderTooltip( + mx, my, Arrays.asList(StatCollector.translateToLocal("botaniamisc.shapeless"))); + + iconY += 20; + } + + render.bindTexture(craftingOverlay); + GL11.glEnable(GL11.GL_BLEND); + + if (oreDictRecipe) { + ((GuiScreen) gui).drawTexturedModalRect(iconX, iconY, 240, 16, 16, 16); + + if (mx >= iconX && my >= iconY && mx < iconX + 16 && my < iconY + 16) + RenderHelper.renderTooltip( + mx, my, Arrays.asList(StatCollector.translateToLocal("botaniamisc.oredict"))); + } + GL11.glDisable(GL11.GL_BLEND); + } + + @Override + @SideOnly(Side.CLIENT) + public void updateScreen() { + if (GuiScreen.isShiftKeyDown()) return; + + if (ticksElapsed % 20 == 0) { + recipeAt++; + + if (recipeAt == recipes.size()) recipeAt = 0; + } + ++ticksElapsed; + } + + @SideOnly(Side.CLIENT) + public void renderCraftingRecipe(IGuiLexiconEntry gui, IRecipe recipe) { + if (recipe instanceof ShapedRecipes) { + ShapedRecipes shaped = (ShapedRecipes) recipe; + + for (int y = 0; y < shaped.recipeHeight; y++) + for (int x = 0; x < shaped.recipeWidth; x++) + renderItemAtGridPos(gui, 1 + x, 1 + y, shaped.recipeItems[y * shaped.recipeWidth + x], true); + } else if (recipe instanceof ShapedOreRecipe) { + ShapedOreRecipe shaped = (ShapedOreRecipe) recipe; + int width = (Integer) ReflectionHelper.getPrivateValue(ShapedOreRecipe.class, shaped, 4); + int height = (Integer) ReflectionHelper.getPrivateValue(ShapedOreRecipe.class, shaped, 5); + + for (int y = 0; y < height; y++) + for (int x = 0; x < width; x++) { + Object input = shaped.getInput()[y * width + x]; + if (input != null) + renderItemAtGridPos( + gui, + 1 + x, + 1 + y, + input instanceof ItemStack ? (ItemStack) input : ((ArrayList) input).get(0), + true); + } + + oreDictRecipe = true; + } else if (recipe instanceof ShapelessRecipes) { + ShapelessRecipes shapeless = (ShapelessRecipes) recipe; + + drawGrid: + { + for (int y = 0; y < 3; y++) + for (int x = 0; x < 3; x++) { + int index = y * 3 + x; + + if (index >= shapeless.recipeItems.size()) break drawGrid; + + renderItemAtGridPos(gui, 1 + x, 1 + y, (ItemStack) shapeless.recipeItems.get(index), true); + } + } + + shapelessRecipe = true; + } else if (recipe instanceof ShapelessOreRecipe) { + ShapelessOreRecipe shapeless = (ShapelessOreRecipe) recipe; + + drawGrid: + { + for (int y = 0; y < 3; y++) + for (int x = 0; x < 3; x++) { + int index = y * 3 + x; + + if (index >= shapeless.getRecipeSize()) break drawGrid; + + Object input = shapeless.getInput().get(index); + if (input != null) + renderItemAtGridPos( + gui, + 1 + x, + 1 + y, + input instanceof ItemStack + ? (ItemStack) input + : ((ArrayList) input).get(0), + true); + } + } + + shapelessRecipe = true; + oreDictRecipe = true; + } + + renderItemAtGridPos(gui, 2, 0, recipe.getRecipeOutput(), false); + } + + @Override + public List getDisplayedRecipes() { + ArrayList list = new ArrayList(); + for (IRecipe r : recipes) list.add(r.getRecipeOutput()); + + return list; + } } diff --git a/src/main/java/vazkii/botania/common/lexicon/page/PageElvenRecipe.java b/src/main/java/vazkii/botania/common/lexicon/page/PageElvenRecipe.java index 86a5252644..bdd8ff6435 100644 --- a/src/main/java/vazkii/botania/common/lexicon/page/PageElvenRecipe.java +++ b/src/main/java/vazkii/botania/common/lexicon/page/PageElvenRecipe.java @@ -1,9 +1,10 @@ package vazkii.botania.common.lexicon.page; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; import java.util.ArrayList; import java.util.Arrays; import java.util.List; - import net.minecraft.client.Minecraft; import net.minecraft.client.gui.GuiScreen; import net.minecraft.client.renderer.entity.RenderItem; @@ -13,115 +14,103 @@ import net.minecraft.util.IIcon; import net.minecraft.util.ResourceLocation; import net.minecraftforge.oredict.OreDictionary; - import org.lwjgl.opengl.GL11; - import vazkii.botania.api.internal.IGuiLexiconEntry; import vazkii.botania.api.lexicon.LexiconEntry; import vazkii.botania.api.lexicon.LexiconRecipeMappings; import vazkii.botania.api.recipe.RecipeElvenTrade; import vazkii.botania.client.lib.LibResources; import vazkii.botania.common.block.BlockAlfPortal; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; public class PageElvenRecipe extends PageRecipe { - private static final ResourceLocation elvenTradeOverlay = new ResourceLocation(LibResources.GUI_ELVEN_TRADE_OVERLAY); - - List recipes; - int ticksElapsed = 0; - int recipeAt = 0; - - public PageElvenRecipe(String unlocalizedName, List recipes) { - super(unlocalizedName); - this.recipes = filterRecipes(recipes); - } - - public PageElvenRecipe(String unlocalizedName, RecipeElvenTrade recipe) { - this(unlocalizedName, Arrays.asList(recipe)); - } - - @Override - public void onPageAdded(LexiconEntry entry, int index) { - for(RecipeElvenTrade recipe : recipes) - if (recipe != null) - LexiconRecipeMappings.map(recipe.getOutput(), entry, index); - } - - @Override - @SideOnly(Side.CLIENT) - public void renderRecipe(IGuiLexiconEntry gui, int mx, int my) { - if (recipes.size() == 0) return; - RecipeElvenTrade recipe = recipes.get(recipeAt); - - TextureManager render = Minecraft.getMinecraft().renderEngine; - render.bindTexture(elvenTradeOverlay); - GL11.glEnable(GL11.GL_BLEND); - GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); - GL11.glColor4f(1F, 1F, 1F, 1F); - ((GuiScreen) gui).drawTexturedModalRect(gui.getLeft(), gui.getTop(), 0, 0, gui.getWidth(), gui.getHeight()); - GL11.glDisable(GL11.GL_BLEND); - - renderItemAtGridPos(gui, 3, 1, recipe.getOutput(), false); - - List inputs = recipe.getInputs(); - int i = 0; - for(Object obj : inputs) { - Object input = obj; - if(input instanceof String) - input = OreDictionary.getOres((String) input).get(0); - - renderItemAtInputPos(gui, i, (ItemStack) input); - i++; - } - - IIcon portalIcon = BlockAlfPortal.portalTex; - Minecraft.getMinecraft().renderEngine.bindTexture(TextureMap.locationBlocksTexture); - RenderItem.getInstance().renderIcon(gui.getLeft() + 22, gui.getTop() + 36, portalIcon, 48, 48); - } - - @SideOnly(Side.CLIENT) - public void renderItemAtInputPos(IGuiLexiconEntry gui, int x, ItemStack stack) { - if(stack == null || stack.getItem() == null) - return; - stack = stack.copy(); - - if(stack.getItemDamage() == Short.MAX_VALUE) - stack.setItemDamage(0); - - int xPos = gui.getLeft() + x * 20 + 45; - int yPos = gui.getTop() + 14; - ItemStack stack1 = stack.copy(); - if(stack1.getItemDamage() == -1) - stack1.setItemDamage(0); - - renderItem(gui, xPos, yPos, stack1, false); - } - - - @Override - @SideOnly(Side.CLIENT) - public void updateScreen() { - if(GuiScreen.isShiftKeyDown()) - return; - - if(ticksElapsed % 20 == 0) { - recipeAt++; - - if(recipeAt == recipes.size()) - recipeAt = 0; - } - ++ticksElapsed; - } - - @Override - public List getDisplayedRecipes() { - ArrayList list = new ArrayList(); - for(RecipeElvenTrade r : recipes) - list.add(r.getOutput()); - - return list; - } - + private static final ResourceLocation elvenTradeOverlay = + new ResourceLocation(LibResources.GUI_ELVEN_TRADE_OVERLAY); + + List recipes; + int ticksElapsed = 0; + int recipeAt = 0; + + public PageElvenRecipe(String unlocalizedName, List recipes) { + super(unlocalizedName); + this.recipes = filterRecipes(recipes); + } + + public PageElvenRecipe(String unlocalizedName, RecipeElvenTrade recipe) { + this(unlocalizedName, Arrays.asList(recipe)); + } + + @Override + public void onPageAdded(LexiconEntry entry, int index) { + for (RecipeElvenTrade recipe : recipes) + if (recipe != null) LexiconRecipeMappings.map(recipe.getOutput(), entry, index); + } + + @Override + @SideOnly(Side.CLIENT) + public void renderRecipe(IGuiLexiconEntry gui, int mx, int my) { + if (recipes.size() == 0) return; + RecipeElvenTrade recipe = recipes.get(recipeAt); + + TextureManager render = Minecraft.getMinecraft().renderEngine; + render.bindTexture(elvenTradeOverlay); + GL11.glEnable(GL11.GL_BLEND); + GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); + GL11.glColor4f(1F, 1F, 1F, 1F); + ((GuiScreen) gui).drawTexturedModalRect(gui.getLeft(), gui.getTop(), 0, 0, gui.getWidth(), gui.getHeight()); + GL11.glDisable(GL11.GL_BLEND); + + renderItemAtGridPos(gui, 3, 1, recipe.getOutput(), false); + + List inputs = recipe.getInputs(); + int i = 0; + for (Object obj : inputs) { + Object input = obj; + if (input instanceof String) + input = OreDictionary.getOres((String) input).get(0); + + renderItemAtInputPos(gui, i, (ItemStack) input); + i++; + } + + IIcon portalIcon = BlockAlfPortal.portalTex; + Minecraft.getMinecraft().renderEngine.bindTexture(TextureMap.locationBlocksTexture); + RenderItem.getInstance().renderIcon(gui.getLeft() + 22, gui.getTop() + 36, portalIcon, 48, 48); + } + + @SideOnly(Side.CLIENT) + public void renderItemAtInputPos(IGuiLexiconEntry gui, int x, ItemStack stack) { + if (stack == null || stack.getItem() == null) return; + stack = stack.copy(); + + if (stack.getItemDamage() == Short.MAX_VALUE) stack.setItemDamage(0); + + int xPos = gui.getLeft() + x * 20 + 45; + int yPos = gui.getTop() + 14; + ItemStack stack1 = stack.copy(); + if (stack1.getItemDamage() == -1) stack1.setItemDamage(0); + + renderItem(gui, xPos, yPos, stack1, false); + } + + @Override + @SideOnly(Side.CLIENT) + public void updateScreen() { + if (GuiScreen.isShiftKeyDown()) return; + + if (ticksElapsed % 20 == 0) { + recipeAt++; + + if (recipeAt == recipes.size()) recipeAt = 0; + } + ++ticksElapsed; + } + + @Override + public List getDisplayedRecipes() { + ArrayList list = new ArrayList(); + for (RecipeElvenTrade r : recipes) list.add(r.getOutput()); + + return list; + } } diff --git a/src/main/java/vazkii/botania/common/lexicon/page/PageEntity.java b/src/main/java/vazkii/botania/common/lexicon/page/PageEntity.java index 89fba690d5..b1c70ba3db 100644 --- a/src/main/java/vazkii/botania/common/lexicon/page/PageEntity.java +++ b/src/main/java/vazkii/botania/common/lexicon/page/PageEntity.java @@ -2,16 +2,17 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jul 4, 2014, 10:38:50 PM (GMT)] */ package vazkii.botania.common.lexicon.page; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; import java.lang.reflect.Constructor; - import net.minecraft.client.Minecraft; import net.minecraft.client.renderer.OpenGlHelper; import net.minecraft.client.renderer.RenderHelper; @@ -20,98 +21,95 @@ import net.minecraft.entity.EntityList; import net.minecraft.util.MathHelper; import net.minecraft.world.World; - import org.lwjgl.opengl.GL11; import org.lwjgl.opengl.GL12; - import vazkii.botania.api.internal.IGuiLexiconEntry; import vazkii.botania.api.lexicon.LexiconPage; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; - -public class PageEntity extends LexiconPage{ - - Entity dummyEntity; - int relativeMouseX, relativeMouseY; - boolean tooltipEntity; - int size; - Constructor entityConstructor; - - public PageEntity(String unlocalizedName, String entity, int size) { - super(unlocalizedName); - Class EntityClass = (Class) EntityList.stringToClassMapping.get(entity); - this.size = size; - try { - entityConstructor = EntityClass.getConstructor(new Class[] {World.class}); - } catch (Exception e) { - e.printStackTrace(); - } - } - - @Override - @SideOnly(Side.CLIENT) - public void renderScreen(IGuiLexiconEntry gui, int mx, int my) { - prepDummy(); - int text_x = gui.getLeft() + 16; - int text_y = gui.getTop() + gui.getHeight() - 40; - int entity_scale = getEntityScale(size); - int entity_x = gui.getLeft() + gui.getWidth() / 2; - int entity_y = gui.getTop() + gui.getHeight() / 2 + MathHelper.floor_float(dummyEntity.height * entity_scale / 2); - - renderEntity(gui, dummyEntity, entity_x, entity_y, entity_scale, dummyEntity.ticksExisted * 2); - - PageText.renderText(text_x, text_y, gui.getWidth() - 30, gui.getHeight(), getUnlocalizedName()); - } - - @SideOnly(Side.CLIENT) - public int getEntityScale(int targetSize) { - float entity_size = dummyEntity.width; - - if(dummyEntity.width < dummyEntity.height) - entity_size = dummyEntity.height; - - return MathHelper.floor_float(size / entity_size); - - } - - @Override - public void updateScreen() { - prepDummy(); - dummyEntity.ticksExisted++; - } - - @SideOnly(Side.CLIENT) - public void renderEntity(IGuiLexiconEntry gui, Entity entity, int x, int y, int scale, float rotation) { - dummyEntity.worldObj = Minecraft.getMinecraft() != null ? Minecraft.getMinecraft().theWorld : null; - - GL11.glEnable(GL11.GL_COLOR_MATERIAL); - GL11.glPushMatrix(); - GL11.glTranslatef(x, y, 50.0F); - GL11.glScalef(-scale, scale, scale); - GL11.glRotatef(180.0F, 0.0F, 0.0F, 1.0F); - GL11.glRotatef(rotation, 0.0F, 1.0F, 0.0F); - RenderHelper.enableStandardItemLighting(); - GL11.glTranslatef(0.0F, entity.yOffset, 0.0F); - RenderManager.instance.playerViewY = 180.0F; - RenderManager.instance.renderEntityWithPosYaw(entity, 0.0D, 0.0D, 0.0D, 0.0F, 1.0F); - GL11.glPopMatrix(); - RenderHelper.disableStandardItemLighting(); - GL11.glDisable(GL12.GL_RESCALE_NORMAL); - OpenGlHelper.setActiveTexture(OpenGlHelper.lightmapTexUnit); - GL11.glDisable(GL11.GL_TEXTURE_2D); - OpenGlHelper.setActiveTexture(OpenGlHelper.defaultTexUnit); - - if(relativeMouseX >= x - dummyEntity.width * scale / 2 - 10 && relativeMouseY >= y - dummyEntity.height * scale - 20 && relativeMouseX <= x + dummyEntity.width * scale / 2 + 10 && relativeMouseY <= y + 20) - tooltipEntity = true; - } - public void prepDummy() { - if(dummyEntity == null || dummyEntity.isDead) { - try { - dummyEntity = (Entity) entityConstructor.newInstance(new Object[] {Minecraft.getMinecraft().theWorld}); - } catch (Exception e) { - e.printStackTrace(); - } - } - } +public class PageEntity extends LexiconPage { + + Entity dummyEntity; + int relativeMouseX, relativeMouseY; + boolean tooltipEntity; + int size; + Constructor entityConstructor; + + public PageEntity(String unlocalizedName, String entity, int size) { + super(unlocalizedName); + Class EntityClass = (Class) EntityList.stringToClassMapping.get(entity); + this.size = size; + try { + entityConstructor = EntityClass.getConstructor(new Class[] {World.class}); + } catch (Exception e) { + e.printStackTrace(); + } + } + + @Override + @SideOnly(Side.CLIENT) + public void renderScreen(IGuiLexiconEntry gui, int mx, int my) { + prepDummy(); + int text_x = gui.getLeft() + 16; + int text_y = gui.getTop() + gui.getHeight() - 40; + int entity_scale = getEntityScale(size); + int entity_x = gui.getLeft() + gui.getWidth() / 2; + int entity_y = + gui.getTop() + gui.getHeight() / 2 + MathHelper.floor_float(dummyEntity.height * entity_scale / 2); + + renderEntity(gui, dummyEntity, entity_x, entity_y, entity_scale, dummyEntity.ticksExisted * 2); + + PageText.renderText(text_x, text_y, gui.getWidth() - 30, gui.getHeight(), getUnlocalizedName()); + } + + @SideOnly(Side.CLIENT) + public int getEntityScale(int targetSize) { + float entity_size = dummyEntity.width; + + if (dummyEntity.width < dummyEntity.height) entity_size = dummyEntity.height; + + return MathHelper.floor_float(size / entity_size); + } + + @Override + public void updateScreen() { + prepDummy(); + dummyEntity.ticksExisted++; + } + + @SideOnly(Side.CLIENT) + public void renderEntity(IGuiLexiconEntry gui, Entity entity, int x, int y, int scale, float rotation) { + dummyEntity.worldObj = Minecraft.getMinecraft() != null ? Minecraft.getMinecraft().theWorld : null; + + GL11.glEnable(GL11.GL_COLOR_MATERIAL); + GL11.glPushMatrix(); + GL11.glTranslatef(x, y, 50.0F); + GL11.glScalef(-scale, scale, scale); + GL11.glRotatef(180.0F, 0.0F, 0.0F, 1.0F); + GL11.glRotatef(rotation, 0.0F, 1.0F, 0.0F); + RenderHelper.enableStandardItemLighting(); + GL11.glTranslatef(0.0F, entity.yOffset, 0.0F); + RenderManager.instance.playerViewY = 180.0F; + RenderManager.instance.renderEntityWithPosYaw(entity, 0.0D, 0.0D, 0.0D, 0.0F, 1.0F); + GL11.glPopMatrix(); + RenderHelper.disableStandardItemLighting(); + GL11.glDisable(GL12.GL_RESCALE_NORMAL); + OpenGlHelper.setActiveTexture(OpenGlHelper.lightmapTexUnit); + GL11.glDisable(GL11.GL_TEXTURE_2D); + OpenGlHelper.setActiveTexture(OpenGlHelper.defaultTexUnit); + + if (relativeMouseX >= x - dummyEntity.width * scale / 2 - 10 + && relativeMouseY >= y - dummyEntity.height * scale - 20 + && relativeMouseX <= x + dummyEntity.width * scale / 2 + 10 + && relativeMouseY <= y + 20) tooltipEntity = true; + } + + public void prepDummy() { + if (dummyEntity == null || dummyEntity.isDead) { + try { + dummyEntity = (Entity) entityConstructor.newInstance(new Object[] {Minecraft.getMinecraft().theWorld}); + } catch (Exception e) { + e.printStackTrace(); + } + } + } } diff --git a/src/main/java/vazkii/botania/common/lexicon/page/PageGuide.java b/src/main/java/vazkii/botania/common/lexicon/page/PageGuide.java index 35ff293a9c..66456a4908 100644 --- a/src/main/java/vazkii/botania/common/lexicon/page/PageGuide.java +++ b/src/main/java/vazkii/botania/common/lexicon/page/PageGuide.java @@ -2,48 +2,53 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Sep 3, 2014, 9:41:47 PM (GMT)] */ package vazkii.botania.common.lexicon.page; import java.awt.Desktop; import java.net.URI; - import net.minecraft.client.gui.GuiButton; import net.minecraft.util.StatCollector; import vazkii.botania.api.internal.IGuiLexiconEntry; public class PageGuide extends PageText { - GuiButton button; - - public PageGuide(String unlocalizedName) { - super(unlocalizedName); - } - - @Override - public void onOpened(IGuiLexiconEntry gui) { - button = new GuiButton(101, gui.getLeft() + 30, gui.getTop() + gui.getHeight() - 50, gui.getWidth() - 60, 20, StatCollector.translateToLocal("botaniamisc.playVideo")); - gui.getButtonList().add(button); - } - - @Override - public void onClosed(IGuiLexiconEntry gui) { - gui.getButtonList().remove(button); - } - - @Override - public void onActionPerformed(IGuiLexiconEntry gui, GuiButton button) { - if(button == this.button && Desktop.isDesktopSupported()) - try { - Desktop.getDesktop().browse(new URI("https://www.youtube.com/watch?v=rx0xyejC6fI")); - if(Math.random() < 0.01) - Desktop.getDesktop().browse(new URI("https://www.youtube.com/watch?v=dQw4w9WgXcQ")); - } catch(Exception e) { } - } - + GuiButton button; + + public PageGuide(String unlocalizedName) { + super(unlocalizedName); + } + + @Override + public void onOpened(IGuiLexiconEntry gui) { + button = new GuiButton( + 101, + gui.getLeft() + 30, + gui.getTop() + gui.getHeight() - 50, + gui.getWidth() - 60, + 20, + StatCollector.translateToLocal("botaniamisc.playVideo")); + gui.getButtonList().add(button); + } + + @Override + public void onClosed(IGuiLexiconEntry gui) { + gui.getButtonList().remove(button); + } + + @Override + public void onActionPerformed(IGuiLexiconEntry gui, GuiButton button) { + if (button == this.button && Desktop.isDesktopSupported()) + try { + Desktop.getDesktop().browse(new URI("https://www.youtube.com/watch?v=rx0xyejC6fI")); + if (Math.random() < 0.01) + Desktop.getDesktop().browse(new URI("https://www.youtube.com/watch?v=dQw4w9WgXcQ")); + } catch (Exception e) { + } + } } diff --git a/src/main/java/vazkii/botania/common/lexicon/page/PageImage.java b/src/main/java/vazkii/botania/common/lexicon/page/PageImage.java index c86a6004ad..59cc5169b9 100644 --- a/src/main/java/vazkii/botania/common/lexicon/page/PageImage.java +++ b/src/main/java/vazkii/botania/common/lexicon/page/PageImage.java @@ -2,52 +2,49 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jan 16, 2014, 6:13:08 PM (GMT)] */ package vazkii.botania.common.lexicon.page; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.GuiScreen; import net.minecraft.client.renderer.texture.TextureManager; import net.minecraft.util.ResourceLocation; - import org.lwjgl.opengl.GL11; - import vazkii.botania.api.internal.IGuiLexiconEntry; import vazkii.botania.api.lexicon.LexiconPage; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; public class PageImage extends LexiconPage { - ResourceLocation resource; - - public PageImage(String unlocalizedName, String resource) { - super(unlocalizedName); - this.resource = new ResourceLocation(resource); - } - - @Override - @SideOnly(Side.CLIENT) - public void renderScreen(IGuiLexiconEntry gui, int mx, int my) { - TextureManager render = Minecraft.getMinecraft().renderEngine; - render.bindTexture(resource); - - GL11.glEnable(GL11.GL_BLEND); - GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); - GL11.glColor4f(1F, 1F, 1F, 1F); - ((GuiScreen) gui).drawTexturedModalRect(gui.getLeft(), gui.getTop(), 0, 0, gui.getWidth(), gui.getHeight()); - GL11.glDisable(GL11.GL_BLEND); - - int width = gui.getWidth() - 30; - int height = gui.getHeight(); - int x = gui.getLeft() + 16; - int y = gui.getTop() + height - 40; - PageText.renderText(x, y, width, height, getUnlocalizedName()); - } - + ResourceLocation resource; + + public PageImage(String unlocalizedName, String resource) { + super(unlocalizedName); + this.resource = new ResourceLocation(resource); + } + + @Override + @SideOnly(Side.CLIENT) + public void renderScreen(IGuiLexiconEntry gui, int mx, int my) { + TextureManager render = Minecraft.getMinecraft().renderEngine; + render.bindTexture(resource); + + GL11.glEnable(GL11.GL_BLEND); + GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); + GL11.glColor4f(1F, 1F, 1F, 1F); + ((GuiScreen) gui).drawTexturedModalRect(gui.getLeft(), gui.getTop(), 0, 0, gui.getWidth(), gui.getHeight()); + GL11.glDisable(GL11.GL_BLEND); + + int width = gui.getWidth() - 30; + int height = gui.getHeight(); + int x = gui.getLeft() + 16; + int y = gui.getTop() + height - 40; + PageText.renderText(x, y, width, height, getUnlocalizedName()); + } } diff --git a/src/main/java/vazkii/botania/common/lexicon/page/PageLoreText.java b/src/main/java/vazkii/botania/common/lexicon/page/PageLoreText.java index 01b9e2788f..2262a79bb6 100644 --- a/src/main/java/vazkii/botania/common/lexicon/page/PageLoreText.java +++ b/src/main/java/vazkii/botania/common/lexicon/page/PageLoreText.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Nov 7, 2014, 11:46:21 PM (GMT)] */ package vazkii.botania.common.lexicon.page; @@ -13,30 +13,27 @@ import net.minecraft.client.Minecraft; import net.minecraft.client.gui.GuiScreen; import net.minecraft.util.ResourceLocation; - import org.lwjgl.opengl.GL11; - import vazkii.botania.api.internal.IGuiLexiconEntry; import vazkii.botania.client.lib.LibResources; public class PageLoreText extends PageText { - private static final ResourceLocation paperOverlay = new ResourceLocation(LibResources.GUI_PAPER); - - public PageLoreText(String unlocalizedName) { - super(unlocalizedName); - } + private static final ResourceLocation paperOverlay = new ResourceLocation(LibResources.GUI_PAPER); - @Override - public void renderScreen(IGuiLexiconEntry gui, int mx, int my) { - Minecraft.getMinecraft().renderEngine.bindTexture(paperOverlay); + public PageLoreText(String unlocalizedName) { + super(unlocalizedName); + } - GL11.glEnable(GL11.GL_BLEND); - GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); - GL11.glColor4f(1F, 1F, 1F, 1F); - ((GuiScreen) gui).drawTexturedModalRect(gui.getLeft(), gui.getTop(), 0, 0, gui.getWidth(), gui.getHeight()); - GL11.glDisable(GL11.GL_BLEND); - super.renderScreen(gui, mx, my); - } + @Override + public void renderScreen(IGuiLexiconEntry gui, int mx, int my) { + Minecraft.getMinecraft().renderEngine.bindTexture(paperOverlay); + GL11.glEnable(GL11.GL_BLEND); + GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); + GL11.glColor4f(1F, 1F, 1F, 1F); + ((GuiScreen) gui).drawTexturedModalRect(gui.getLeft(), gui.getTop(), 0, 0, gui.getWidth(), gui.getHeight()); + GL11.glDisable(GL11.GL_BLEND); + super.renderScreen(gui, mx, my); + } } diff --git a/src/main/java/vazkii/botania/common/lexicon/page/PageManaInfusionRecipe.java b/src/main/java/vazkii/botania/common/lexicon/page/PageManaInfusionRecipe.java index 0240a4e92b..a76136a58e 100644 --- a/src/main/java/vazkii/botania/common/lexicon/page/PageManaInfusionRecipe.java +++ b/src/main/java/vazkii/botania/common/lexicon/page/PageManaInfusionRecipe.java @@ -2,18 +2,19 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Feb 8, 2014, 1:11:42 PM (GMT)] */ package vazkii.botania.common.lexicon.page; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; import java.util.ArrayList; import java.util.Arrays; import java.util.List; - import net.minecraft.client.Minecraft; import net.minecraft.client.gui.FontRenderer; import net.minecraft.client.gui.GuiScreen; @@ -24,9 +25,7 @@ import net.minecraft.util.ResourceLocation; import net.minecraft.util.StatCollector; import net.minecraftforge.oredict.OreDictionary; - import org.lwjgl.opengl.GL11; - import vazkii.botania.api.internal.IGuiLexiconEntry; import vazkii.botania.api.lexicon.LexiconEntry; import vazkii.botania.api.lexicon.LexiconRecipeMappings; @@ -37,130 +36,135 @@ import vazkii.botania.client.render.tile.RenderTilePool; import vazkii.botania.common.block.ModBlocks; import vazkii.botania.common.block.tile.mana.TilePool; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; public class PageManaInfusionRecipe extends PageRecipe { - private static final ResourceLocation manaInfusionOverlay = new ResourceLocation(LibResources.GUI_MANA_INFUSION_OVERLAY); - - List recipes; - int ticksElapsed = 0; - int recipeAt = 0; - - public PageManaInfusionRecipe(String unlocalizedName, List recipes) { - super(unlocalizedName); - this.recipes = filterRecipes(recipes); - } - - public PageManaInfusionRecipe(String unlocalizedName, RecipeManaInfusion recipe) { - this(unlocalizedName, Arrays.asList(recipe)); - } - - @Override - public void onPageAdded(LexiconEntry entry, int index) { - for(RecipeManaInfusion recipe : recipes) - if (recipe != null) - LexiconRecipeMappings.map(recipe.getOutput(), entry, index); - } - - @Override - @SideOnly(Side.CLIENT) - public void renderRecipe(IGuiLexiconEntry gui, int mx, int my) { - if (recipes.size() == 0) return; - RecipeManaInfusion recipe = recipes.get(recipeAt); - - TextureManager render = Minecraft.getMinecraft().renderEngine; - FontRenderer font = Minecraft.getMinecraft().fontRenderer; - - Object input = recipe.getInput(); - if(input instanceof String) - input = OreDictionary.getOres((String) input).get(0); - - renderItemAtGridPos(gui, 1, 1, (ItemStack) input, false); - - RenderTilePool.forceMana = true; - renderItemAtGridPos(gui, 2, 1, new ItemStack(ModBlocks.pool, 1, recipe.getOutput().getItem() == Item.getItemFromBlock(ModBlocks.pool) ? 2 : 0), false); - - renderItemAtGridPos(gui, 3, 1, recipe.getOutput(), false); - - if(recipe.isAlchemy()) - renderItemAtGridPos(gui, 1, 2, new ItemStack(ModBlocks.alchemyCatalyst), false); - else if(recipe.isConjuration()) - renderItemAtGridPos(gui, 1, 2, new ItemStack(ModBlocks.conjurationCatalyst), false); - - GL11.glEnable(GL11.GL_BLEND); - GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); - String manaUsage = StatCollector.translateToLocal("botaniamisc.manaUsage"); - font.drawString(manaUsage, gui.getLeft() + gui.getWidth() / 2 - font.getStringWidth(manaUsage) / 2, gui.getTop() + 105, 0x66000000); - - int ratio = 10; - int x = gui.getLeft() + gui.getWidth() / 2 - 50; - int y = gui.getTop() + 115; - - if(mx > x + 1 && mx <= x + 101 && my > y - 14 && my <= y + 11) - ratio = 1; - - HUDHandler.renderManaBar(x, y, 0x0000FF, 0.75F, recipe.getManaToConsume(), TilePool.MAX_MANA / ratio); - - String ratioString = String.format(StatCollector.translateToLocal("botaniamisc.ratio"), ratio); - String dropString = StatCollector.translateToLocal("botaniamisc.drop") + " " + EnumChatFormatting.BOLD + "(?)"; - - boolean hoveringOverDrop = false; - - boolean unicode = font.getUnicodeFlag(); - font.setUnicodeFlag(true); - int dw = font.getStringWidth(dropString); - int dx = x + 35 - dw / 2; - int dy = gui.getTop() + 30; - - if(mx > dx && mx <= dx + dw && my > dy && my <= dy + 10) - hoveringOverDrop = true; - - font.drawString(dropString, dx, dy, 0x77000000); - font.drawString(ratioString, x + 50 - font.getStringWidth(ratioString) / 2, y + 5, 0x99000000); - font.setUnicodeFlag(unicode); - - GL11.glDisable(GL11.GL_BLEND); - - render.bindTexture(manaInfusionOverlay); - - GL11.glEnable(GL11.GL_BLEND); - GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); - GL11.glColor4f(1F, 1F, 1F, 1F); - ((GuiScreen) gui).drawTexturedModalRect(gui.getLeft(), gui.getTop(), 0, 0, gui.getWidth(), gui.getHeight()); - GL11.glDisable(GL11.GL_BLEND); - - if(hoveringOverDrop) { - String key = RenderHelper.getKeyDisplayString("key.drop"); - String tip0 = StatCollector.translateToLocal("botaniamisc.dropTip0").replaceAll("%key%", EnumChatFormatting.GREEN + key + EnumChatFormatting.WHITE); - String tip1 = StatCollector.translateToLocal("botaniamisc.dropTip1").replaceAll("%key%", EnumChatFormatting.GREEN + key + EnumChatFormatting.WHITE); - RenderHelper.renderTooltip(mx, my, Arrays.asList(tip0, tip1)); - } - } - - @Override - @SideOnly(Side.CLIENT) - public void updateScreen() { - if(GuiScreen.isShiftKeyDown()) - return; - - if(ticksElapsed % 20 == 0) { - recipeAt++; - - if(recipeAt == recipes.size()) - recipeAt = 0; - } - ++ticksElapsed; - } - - @Override - public List getDisplayedRecipes() { - ArrayList list = new ArrayList(); - for(RecipeManaInfusion r : recipes) - list.add(r.getOutput()); - - return list; - } - + private static final ResourceLocation manaInfusionOverlay = + new ResourceLocation(LibResources.GUI_MANA_INFUSION_OVERLAY); + + List recipes; + int ticksElapsed = 0; + int recipeAt = 0; + + public PageManaInfusionRecipe(String unlocalizedName, List recipes) { + super(unlocalizedName); + this.recipes = filterRecipes(recipes); + } + + public PageManaInfusionRecipe(String unlocalizedName, RecipeManaInfusion recipe) { + this(unlocalizedName, Arrays.asList(recipe)); + } + + @Override + public void onPageAdded(LexiconEntry entry, int index) { + for (RecipeManaInfusion recipe : recipes) + if (recipe != null) LexiconRecipeMappings.map(recipe.getOutput(), entry, index); + } + + @Override + @SideOnly(Side.CLIENT) + public void renderRecipe(IGuiLexiconEntry gui, int mx, int my) { + if (recipes.size() == 0) return; + RecipeManaInfusion recipe = recipes.get(recipeAt); + + TextureManager render = Minecraft.getMinecraft().renderEngine; + FontRenderer font = Minecraft.getMinecraft().fontRenderer; + + Object input = recipe.getInput(); + if (input instanceof String) + input = OreDictionary.getOres((String) input).get(0); + + renderItemAtGridPos(gui, 1, 1, (ItemStack) input, false); + + RenderTilePool.forceMana = true; + renderItemAtGridPos( + gui, + 2, + 1, + new ItemStack( + ModBlocks.pool, + 1, + recipe.getOutput().getItem() == Item.getItemFromBlock(ModBlocks.pool) ? 2 : 0), + false); + + renderItemAtGridPos(gui, 3, 1, recipe.getOutput(), false); + + if (recipe.isAlchemy()) renderItemAtGridPos(gui, 1, 2, new ItemStack(ModBlocks.alchemyCatalyst), false); + else if (recipe.isConjuration()) + renderItemAtGridPos(gui, 1, 2, new ItemStack(ModBlocks.conjurationCatalyst), false); + + GL11.glEnable(GL11.GL_BLEND); + GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); + String manaUsage = StatCollector.translateToLocal("botaniamisc.manaUsage"); + font.drawString( + manaUsage, + gui.getLeft() + gui.getWidth() / 2 - font.getStringWidth(manaUsage) / 2, + gui.getTop() + 105, + 0x66000000); + + int ratio = 10; + int x = gui.getLeft() + gui.getWidth() / 2 - 50; + int y = gui.getTop() + 115; + + if (mx > x + 1 && mx <= x + 101 && my > y - 14 && my <= y + 11) ratio = 1; + + HUDHandler.renderManaBar(x, y, 0x0000FF, 0.75F, recipe.getManaToConsume(), TilePool.MAX_MANA / ratio); + + String ratioString = String.format(StatCollector.translateToLocal("botaniamisc.ratio"), ratio); + String dropString = StatCollector.translateToLocal("botaniamisc.drop") + " " + EnumChatFormatting.BOLD + "(?)"; + + boolean hoveringOverDrop = false; + + boolean unicode = font.getUnicodeFlag(); + font.setUnicodeFlag(true); + int dw = font.getStringWidth(dropString); + int dx = x + 35 - dw / 2; + int dy = gui.getTop() + 30; + + if (mx > dx && mx <= dx + dw && my > dy && my <= dy + 10) hoveringOverDrop = true; + + font.drawString(dropString, dx, dy, 0x77000000); + font.drawString(ratioString, x + 50 - font.getStringWidth(ratioString) / 2, y + 5, 0x99000000); + font.setUnicodeFlag(unicode); + + GL11.glDisable(GL11.GL_BLEND); + + render.bindTexture(manaInfusionOverlay); + + GL11.glEnable(GL11.GL_BLEND); + GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); + GL11.glColor4f(1F, 1F, 1F, 1F); + ((GuiScreen) gui).drawTexturedModalRect(gui.getLeft(), gui.getTop(), 0, 0, gui.getWidth(), gui.getHeight()); + GL11.glDisable(GL11.GL_BLEND); + + if (hoveringOverDrop) { + String key = RenderHelper.getKeyDisplayString("key.drop"); + String tip0 = StatCollector.translateToLocal("botaniamisc.dropTip0") + .replaceAll("%key%", EnumChatFormatting.GREEN + key + EnumChatFormatting.WHITE); + String tip1 = StatCollector.translateToLocal("botaniamisc.dropTip1") + .replaceAll("%key%", EnumChatFormatting.GREEN + key + EnumChatFormatting.WHITE); + RenderHelper.renderTooltip(mx, my, Arrays.asList(tip0, tip1)); + } + } + + @Override + @SideOnly(Side.CLIENT) + public void updateScreen() { + if (GuiScreen.isShiftKeyDown()) return; + + if (ticksElapsed % 20 == 0) { + recipeAt++; + + if (recipeAt == recipes.size()) recipeAt = 0; + } + ++ticksElapsed; + } + + @Override + public List getDisplayedRecipes() { + ArrayList list = new ArrayList(); + for (RecipeManaInfusion r : recipes) list.add(r.getOutput()); + + return list; + } } diff --git a/src/main/java/vazkii/botania/common/lexicon/page/PageMultiblock.java b/src/main/java/vazkii/botania/common/lexicon/page/PageMultiblock.java index e7a7a612d5..ab75be5a54 100644 --- a/src/main/java/vazkii/botania/common/lexicon/page/PageMultiblock.java +++ b/src/main/java/vazkii/botania/common/lexicon/page/PageMultiblock.java @@ -2,17 +2,18 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jun 28, 2015, 1:48:58 AM (GMT)] */ package vazkii.botania.common.lexicon.page; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; import java.util.ArrayList; import java.util.List; - import net.minecraft.client.Minecraft; import net.minecraft.client.gui.FontRenderer; import net.minecraft.client.gui.GuiButton; @@ -25,128 +26,124 @@ import net.minecraft.util.EnumChatFormatting; import net.minecraft.util.ResourceLocation; import net.minecraft.util.StatCollector; - import org.lwjgl.opengl.GL11; import org.lwjgl.opengl.GL12; - import vazkii.botania.api.internal.IGuiLexiconEntry; import vazkii.botania.api.lexicon.LexiconPage; import vazkii.botania.api.lexicon.multiblock.Multiblock; import vazkii.botania.api.lexicon.multiblock.MultiblockSet; import vazkii.botania.client.core.handler.MultiblockRenderHandler; import vazkii.botania.client.lib.LibResources; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; public class PageMultiblock extends LexiconPage { - private static final ResourceLocation multiblockOverlay = new ResourceLocation(LibResources.GUI_MULTIBLOCK_OVERLAY); - - GuiButton button; - MultiblockSet set; - Multiblock mb; - int ticksElapsed; - - public PageMultiblock(String unlocalizedName, MultiblockSet set) { - super(unlocalizedName); - mb = set.getForIndex(0); - this.set = set; - } - - @Override - @SideOnly(Side.CLIENT) - public void renderScreen(IGuiLexiconEntry gui, int mx, int my) { - TextureManager render = Minecraft.getMinecraft().renderEngine; - render.bindTexture(multiblockOverlay); - - GL11.glEnable(GL11.GL_BLEND); - GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); - GL11.glDisable(GL11.GL_ALPHA_TEST); - GL11.glColor4f(1F, 1F, 1F, 1F); - ((GuiScreen) gui).drawTexturedModalRect(gui.getLeft(), gui.getTop(), 0, 0, gui.getWidth(), gui.getHeight()); - GL11.glDisable(GL11.GL_BLEND); - GL11.glEnable(GL11.GL_ALPHA_TEST); - - final float maxX = 90, maxY = 60; - GL11.glPushMatrix(); - GL11.glTranslatef(gui.getLeft() + gui.getWidth() / 2, gui.getTop() + 90, gui.getZLevel() + 100F); - - float diag = (float) Math.sqrt(mb.getXSize() * mb.getXSize() + mb.getZSize() * mb.getZSize()); - float height = mb.getYSize(); - float scaleX = maxX / diag; - float scaleY = maxY / height; - float scale = -Math.min(scaleY, scaleX); - GL11.glScalef(scale, scale, scale); - - GL11.glRotatef(-20F, 1, 0, 0); - GL11.glRotatef(gui.getElapsedTicks(), 0, 1, 0); - - MultiblockRenderHandler.renderMultiblockOnPage(mb); - - GL11.glPopMatrix(); - - FontRenderer font = Minecraft.getMinecraft().fontRenderer; - boolean unicode = font.getUnicodeFlag(); - String s = EnumChatFormatting.BOLD + StatCollector.translateToLocal(getUnlocalizedName()); - font.setUnicodeFlag(true); - font.drawString(s, gui.getLeft() + gui.getWidth() / 2 - font.getStringWidth(s) / 2, gui.getTop() + 16, 0x000000); - font.setUnicodeFlag(unicode); - - GL11.glEnable(GL12.GL_RESCALE_NORMAL); - RenderHelper.enableGUIStandardItemLighting(); - int x = gui.getLeft() + 15; - int y = gui.getTop() + 25; - RenderItem.getInstance().renderItemIntoGUI(font, render, new ItemStack(Blocks.stonebrick), x, y); - RenderHelper.disableStandardItemLighting(); - GL11.glDisable(GL12.GL_RESCALE_NORMAL); - - GL11.glPushMatrix(); - GL11.glTranslatef(0F, 0F, 200F); - if(mx >= x && mx < x + 16 && my >= y && my < y + 16) { - List mats = new ArrayList(); - mats.add(StatCollector.translateToLocal("botaniamisc.materialsRequired")); - for(ItemStack stack : mb.materials) { - String size = "" + stack.stackSize; - if(size.length() < 2) - size = "0" + size; - mats.add(" " + EnumChatFormatting.AQUA + size + " " + EnumChatFormatting.GRAY + stack.getDisplayName()); - } - - vazkii.botania.client.core.helper.RenderHelper.renderTooltip(mx, my, mats); - } - GL11.glPopMatrix(); - } - - @Override - public void onOpened(IGuiLexiconEntry gui) { - button = new GuiButton(101, gui.getLeft() + 30, gui.getTop() + gui.getHeight() - 50, gui.getWidth() - 60, 20, getButtonStr()); - gui.getButtonList().add(button); - } - - String getButtonStr() { - return StatCollector.translateToLocal(MultiblockRenderHandler.currentMultiblock == set ? "botaniamisc.unvisualize" : "botaniamisc.visualize"); - } - - @Override - public void onClosed(IGuiLexiconEntry gui) { - gui.getButtonList().remove(button); - } - - @Override - @SideOnly(Side.CLIENT) - public void onActionPerformed(IGuiLexiconEntry gui, GuiButton button) { - if(button == this.button) { - if(MultiblockRenderHandler.currentMultiblock == set) - MultiblockRenderHandler.setMultiblock(null); - else MultiblockRenderHandler.setMultiblock(set); - button.displayString = getButtonStr(); - } - } - - @Override - @SideOnly(Side.CLIENT) - public void updateScreen() { - ++ticksElapsed; - } - + private static final ResourceLocation multiblockOverlay = new ResourceLocation(LibResources.GUI_MULTIBLOCK_OVERLAY); + + GuiButton button; + MultiblockSet set; + Multiblock mb; + int ticksElapsed; + + public PageMultiblock(String unlocalizedName, MultiblockSet set) { + super(unlocalizedName); + mb = set.getForIndex(0); + this.set = set; + } + + @Override + @SideOnly(Side.CLIENT) + public void renderScreen(IGuiLexiconEntry gui, int mx, int my) { + TextureManager render = Minecraft.getMinecraft().renderEngine; + render.bindTexture(multiblockOverlay); + + GL11.glEnable(GL11.GL_BLEND); + GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); + GL11.glDisable(GL11.GL_ALPHA_TEST); + GL11.glColor4f(1F, 1F, 1F, 1F); + ((GuiScreen) gui).drawTexturedModalRect(gui.getLeft(), gui.getTop(), 0, 0, gui.getWidth(), gui.getHeight()); + GL11.glDisable(GL11.GL_BLEND); + GL11.glEnable(GL11.GL_ALPHA_TEST); + + final float maxX = 90, maxY = 60; + GL11.glPushMatrix(); + GL11.glTranslatef(gui.getLeft() + gui.getWidth() / 2, gui.getTop() + 90, gui.getZLevel() + 100F); + + float diag = (float) Math.sqrt(mb.getXSize() * mb.getXSize() + mb.getZSize() * mb.getZSize()); + float height = mb.getYSize(); + float scaleX = maxX / diag; + float scaleY = maxY / height; + float scale = -Math.min(scaleY, scaleX); + GL11.glScalef(scale, scale, scale); + + GL11.glRotatef(-20F, 1, 0, 0); + GL11.glRotatef(gui.getElapsedTicks(), 0, 1, 0); + + MultiblockRenderHandler.renderMultiblockOnPage(mb); + + GL11.glPopMatrix(); + + FontRenderer font = Minecraft.getMinecraft().fontRenderer; + boolean unicode = font.getUnicodeFlag(); + String s = EnumChatFormatting.BOLD + StatCollector.translateToLocal(getUnlocalizedName()); + font.setUnicodeFlag(true); + font.drawString( + s, gui.getLeft() + gui.getWidth() / 2 - font.getStringWidth(s) / 2, gui.getTop() + 16, 0x000000); + font.setUnicodeFlag(unicode); + + GL11.glEnable(GL12.GL_RESCALE_NORMAL); + RenderHelper.enableGUIStandardItemLighting(); + int x = gui.getLeft() + 15; + int y = gui.getTop() + 25; + RenderItem.getInstance().renderItemIntoGUI(font, render, new ItemStack(Blocks.stonebrick), x, y); + RenderHelper.disableStandardItemLighting(); + GL11.glDisable(GL12.GL_RESCALE_NORMAL); + + GL11.glPushMatrix(); + GL11.glTranslatef(0F, 0F, 200F); + if (mx >= x && mx < x + 16 && my >= y && my < y + 16) { + List mats = new ArrayList(); + mats.add(StatCollector.translateToLocal("botaniamisc.materialsRequired")); + for (ItemStack stack : mb.materials) { + String size = "" + stack.stackSize; + if (size.length() < 2) size = "0" + size; + mats.add(" " + EnumChatFormatting.AQUA + size + " " + EnumChatFormatting.GRAY + stack.getDisplayName()); + } + + vazkii.botania.client.core.helper.RenderHelper.renderTooltip(mx, my, mats); + } + GL11.glPopMatrix(); + } + + @Override + public void onOpened(IGuiLexiconEntry gui) { + button = new GuiButton( + 101, gui.getLeft() + 30, gui.getTop() + gui.getHeight() - 50, gui.getWidth() - 60, 20, getButtonStr()); + gui.getButtonList().add(button); + } + + String getButtonStr() { + return StatCollector.translateToLocal( + MultiblockRenderHandler.currentMultiblock == set ? "botaniamisc.unvisualize" : "botaniamisc.visualize"); + } + + @Override + public void onClosed(IGuiLexiconEntry gui) { + gui.getButtonList().remove(button); + } + + @Override + @SideOnly(Side.CLIENT) + public void onActionPerformed(IGuiLexiconEntry gui, GuiButton button) { + if (button == this.button) { + if (MultiblockRenderHandler.currentMultiblock == set) MultiblockRenderHandler.setMultiblock(null); + else MultiblockRenderHandler.setMultiblock(set); + button.displayString = getButtonStr(); + } + } + + @Override + @SideOnly(Side.CLIENT) + public void updateScreen() { + ++ticksElapsed; + } } diff --git a/src/main/java/vazkii/botania/common/lexicon/page/PagePetalRecipe.java b/src/main/java/vazkii/botania/common/lexicon/page/PagePetalRecipe.java index 3b3b9b4828..72c41ac89e 100644 --- a/src/main/java/vazkii/botania/common/lexicon/page/PagePetalRecipe.java +++ b/src/main/java/vazkii/botania/common/lexicon/page/PagePetalRecipe.java @@ -2,18 +2,19 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Feb 8, 2014, 1:11:35 PM (GMT)] */ package vazkii.botania.common.lexicon.page; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; import java.util.ArrayList; import java.util.Arrays; import java.util.List; - import net.minecraft.client.Minecraft; import net.minecraft.client.gui.FontRenderer; import net.minecraft.client.gui.GuiScreen; @@ -22,9 +23,7 @@ import net.minecraft.util.ResourceLocation; import net.minecraft.util.StatCollector; import net.minecraftforge.oredict.OreDictionary; - import org.lwjgl.opengl.GL11; - import vazkii.botania.api.internal.IGuiLexiconEntry; import vazkii.botania.api.lexicon.LexiconEntry; import vazkii.botania.api.lexicon.LexiconRecipeMappings; @@ -33,118 +32,113 @@ import vazkii.botania.client.lib.LibResources; import vazkii.botania.common.block.ModBlocks; import vazkii.botania.common.core.handler.ConfigHandler; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; public class PagePetalRecipe extends PageRecipe { - private static final ResourceLocation petalOverlay = new ResourceLocation(LibResources.GUI_PETAL_OVERLAY); - - List recipes; - int ticksElapsed = 0; - int recipeAt = 0; - int oredictCounter = 0; - - public PagePetalRecipe(String unlocalizedName, List recipes) { - super(unlocalizedName); - this.recipes = filterRecipes(recipes); - } - - public PagePetalRecipe(String unlocalizedName, T recipe) { - this(unlocalizedName, Arrays.asList(recipe)); - } - - @Override - public void onPageAdded(LexiconEntry entry, int index) { - for(T recipe : recipes) - if (recipe != null) - LexiconRecipeMappings.map(recipe.getOutput(), entry, index); - } - - @Override - @SideOnly(Side.CLIENT) - public void renderRecipe(IGuiLexiconEntry gui, int mx, int my) { - if (recipes.size() == 0) return; - T recipe = recipes.get(recipeAt); - - TextureManager render = Minecraft.getMinecraft().renderEngine; - - renderItemAtGridPos(gui, 3, 0, recipe.getOutput(), false); - renderItemAtGridPos(gui, 2, 1, getMiddleStack(), false); - - List inputs = recipe.getInputs(); - int degreePerInput = (int) (360F / inputs.size()); - float currentDegree = ConfigHandler.lexiconRotatingItems ? GuiScreen.isShiftKeyDown() ? ticksElapsed : (float) (ticksElapsed + ClientTickHandler.partialTicks) : 0; - - for(Object obj : inputs) { - Object input = obj; - if(input instanceof String) { - List ores = OreDictionary.getOres((String) input); - input = ores.get(oredictCounter % ores.size()); - } - - renderItemAtAngle(gui, currentDegree, (ItemStack) input); - - currentDegree += degreePerInput; - } - - renderManaBar(gui, recipe, mx, my); - - render.bindTexture(petalOverlay); - - GL11.glEnable(GL11.GL_BLEND); - GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); - GL11.glColor4f(1F, 1F, 1F, 1F); - ((GuiScreen) gui).drawTexturedModalRect(gui.getLeft(), gui.getTop(), 0, 0, gui.getWidth(), gui.getHeight()); - GL11.glDisable(GL11.GL_BLEND); - } - - ItemStack getMiddleStack() { - return new ItemStack(ModBlocks.altar); - } - - @SideOnly(Side.CLIENT) - public void renderManaBar(IGuiLexiconEntry gui, T recipe, int mx, int my) { - FontRenderer font = Minecraft.getMinecraft().fontRenderer; - GL11.glEnable(GL11.GL_BLEND); - GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); - - int x = gui.getLeft() + gui.getWidth() / 2 - 50; - int y = gui.getTop() + 120; - - boolean unicode = font.getUnicodeFlag(); - font.setUnicodeFlag(true); - String stopStr = StatCollector.translateToLocal("botaniamisc.shiftToStopSpin"); - font.drawString(stopStr, x + 50 - font.getStringWidth(stopStr) / 2, y + 15, 0x99000000); - font.setUnicodeFlag(unicode); - - GL11.glDisable(GL11.GL_BLEND); - } - - @Override - @SideOnly(Side.CLIENT) - public void updateScreen() { - if(GuiScreen.isShiftKeyDown()) - return; - - if(ticksElapsed % 20 == 0) { - recipeAt++; - - if(recipeAt == recipes.size()) { - recipeAt = 0; - oredictCounter++; - } - } - ++ticksElapsed; - } - - @Override - public List getDisplayedRecipes() { - ArrayList list = new ArrayList(); - for(T r : recipes) - list.add(r.getOutput()); - - return list; - } - + private static final ResourceLocation petalOverlay = new ResourceLocation(LibResources.GUI_PETAL_OVERLAY); + + List recipes; + int ticksElapsed = 0; + int recipeAt = 0; + int oredictCounter = 0; + + public PagePetalRecipe(String unlocalizedName, List recipes) { + super(unlocalizedName); + this.recipes = filterRecipes(recipes); + } + + public PagePetalRecipe(String unlocalizedName, T recipe) { + this(unlocalizedName, Arrays.asList(recipe)); + } + + @Override + public void onPageAdded(LexiconEntry entry, int index) { + for (T recipe : recipes) if (recipe != null) LexiconRecipeMappings.map(recipe.getOutput(), entry, index); + } + + @Override + @SideOnly(Side.CLIENT) + public void renderRecipe(IGuiLexiconEntry gui, int mx, int my) { + if (recipes.size() == 0) return; + T recipe = recipes.get(recipeAt); + + TextureManager render = Minecraft.getMinecraft().renderEngine; + + renderItemAtGridPos(gui, 3, 0, recipe.getOutput(), false); + renderItemAtGridPos(gui, 2, 1, getMiddleStack(), false); + + List inputs = recipe.getInputs(); + int degreePerInput = (int) (360F / inputs.size()); + float currentDegree = ConfigHandler.lexiconRotatingItems + ? GuiScreen.isShiftKeyDown() ? ticksElapsed : (float) (ticksElapsed + ClientTickHandler.partialTicks) + : 0; + + for (Object obj : inputs) { + Object input = obj; + if (input instanceof String) { + List ores = OreDictionary.getOres((String) input); + input = ores.get(oredictCounter % ores.size()); + } + + renderItemAtAngle(gui, currentDegree, (ItemStack) input); + + currentDegree += degreePerInput; + } + + renderManaBar(gui, recipe, mx, my); + + render.bindTexture(petalOverlay); + + GL11.glEnable(GL11.GL_BLEND); + GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); + GL11.glColor4f(1F, 1F, 1F, 1F); + ((GuiScreen) gui).drawTexturedModalRect(gui.getLeft(), gui.getTop(), 0, 0, gui.getWidth(), gui.getHeight()); + GL11.glDisable(GL11.GL_BLEND); + } + + ItemStack getMiddleStack() { + return new ItemStack(ModBlocks.altar); + } + + @SideOnly(Side.CLIENT) + public void renderManaBar(IGuiLexiconEntry gui, T recipe, int mx, int my) { + FontRenderer font = Minecraft.getMinecraft().fontRenderer; + GL11.glEnable(GL11.GL_BLEND); + GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); + + int x = gui.getLeft() + gui.getWidth() / 2 - 50; + int y = gui.getTop() + 120; + + boolean unicode = font.getUnicodeFlag(); + font.setUnicodeFlag(true); + String stopStr = StatCollector.translateToLocal("botaniamisc.shiftToStopSpin"); + font.drawString(stopStr, x + 50 - font.getStringWidth(stopStr) / 2, y + 15, 0x99000000); + font.setUnicodeFlag(unicode); + + GL11.glDisable(GL11.GL_BLEND); + } + + @Override + @SideOnly(Side.CLIENT) + public void updateScreen() { + if (GuiScreen.isShiftKeyDown()) return; + + if (ticksElapsed % 20 == 0) { + recipeAt++; + + if (recipeAt == recipes.size()) { + recipeAt = 0; + oredictCounter++; + } + } + ++ticksElapsed; + } + + @Override + public List getDisplayedRecipes() { + ArrayList list = new ArrayList(); + for (T r : recipes) list.add(r.getOutput()); + + return list; + } } diff --git a/src/main/java/vazkii/botania/common/lexicon/page/PageRecipe.java b/src/main/java/vazkii/botania/common/lexicon/page/PageRecipe.java index 76147e43c4..d173db679c 100644 --- a/src/main/java/vazkii/botania/common/lexicon/page/PageRecipe.java +++ b/src/main/java/vazkii/botania/common/lexicon/page/PageRecipe.java @@ -2,18 +2,19 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Feb 8, 2014, 2:46:36 PM (GMT)] */ package vazkii.botania.common.lexicon.page; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; import java.util.ArrayList; import java.util.Arrays; import java.util.List; - import net.minecraft.client.Minecraft; import net.minecraft.client.gui.GuiScreen; import net.minecraft.client.renderer.RenderHelper; @@ -21,173 +22,181 @@ import net.minecraft.item.ItemStack; import net.minecraft.util.EnumChatFormatting; import net.minecraft.util.StatCollector; - import org.lwjgl.input.Mouse; import org.lwjgl.opengl.GL11; import org.lwjgl.opengl.GL12; - import vazkii.botania.api.internal.IGuiLexiconEntry; import vazkii.botania.api.lexicon.ILexicon; import vazkii.botania.api.lexicon.LexiconPage; import vazkii.botania.api.lexicon.LexiconRecipeMappings; import vazkii.botania.api.lexicon.LexiconRecipeMappings.EntryData; import vazkii.botania.client.gui.lexicon.GuiLexiconEntry; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; public class PageRecipe extends LexiconPage { - int relativeMouseX, relativeMouseY; - ItemStack tooltipStack, tooltipContainerStack; - boolean tooltipEntry; - - static boolean mouseDownLastTick = false; - - public PageRecipe(String unlocalizedName) { - super(unlocalizedName); - } - - @Override - @SideOnly(Side.CLIENT) - public void renderScreen(IGuiLexiconEntry gui, int mx, int my) { - relativeMouseX = mx; - relativeMouseY = my; - - renderRecipe(gui, mx, my); - - int width = gui.getWidth() - 30; - int height = gui.getHeight(); - int x = gui.getLeft() + 16; - int y = gui.getTop() + height - 40; - PageText.renderText(x, y, width, height, getUnlocalizedName()); - - if(tooltipStack != null) { - List tooltipData = tooltipStack.getTooltip(Minecraft.getMinecraft().thePlayer, false); - List parsedTooltip = new ArrayList(); - boolean first = true; - - for(String s : tooltipData) { - String s_ = s; - if(!first) - s_ = EnumChatFormatting.GRAY + s; - parsedTooltip.add(s_); - first = false; - } - - vazkii.botania.client.core.helper.RenderHelper.renderTooltip(mx, my, parsedTooltip); - - int tooltipY = 8 + tooltipData.size() * 11; - - if(tooltipEntry) { - vazkii.botania.client.core.helper.RenderHelper.renderTooltipOrange(mx, my + tooltipY, Arrays.asList(EnumChatFormatting.GRAY + StatCollector.translateToLocal("botaniamisc.clickToRecipe"))); - tooltipY += 18; - } - - if(tooltipContainerStack != null) - vazkii.botania.client.core.helper.RenderHelper.renderTooltipGreen(mx, my + tooltipY, Arrays.asList(EnumChatFormatting.AQUA + StatCollector.translateToLocal("botaniamisc.craftingContainer"), tooltipContainerStack.getDisplayName())); - } - - tooltipStack = tooltipContainerStack = null; - tooltipEntry = false; - GL11.glDisable(GL11.GL_BLEND); - mouseDownLastTick = Mouse.isButtonDown(0); - } - - @SideOnly(Side.CLIENT) - public void renderRecipe(IGuiLexiconEntry gui, int mx, int my) { - // NO-OP - } - - @SideOnly(Side.CLIENT) - public void renderItemAtAngle(IGuiLexiconEntry gui, float angle, ItemStack stack) { - if(stack == null || stack.getItem() == null) - return; - - ItemStack workStack = stack.copy(); - - if(workStack.getItemDamage() == Short.MAX_VALUE || workStack.getItemDamage() == -1) - workStack.setItemDamage(0); - - angle -= 90; - int radius = 32; - double xPos = gui.getLeft() + Math.cos(angle * Math.PI / 180D) * radius + gui.getWidth() / 2 - 8; - double yPos = gui.getTop() + Math.sin(angle * Math.PI / 180D) * radius + 53; - - renderItem(gui, xPos, yPos, workStack, false); - } - - @SideOnly(Side.CLIENT) - public void renderItemAtGridPos(IGuiLexiconEntry gui, int x, int y, ItemStack stack, boolean accountForContainer) { - if(stack == null || stack.getItem() == null) - return; - stack = stack.copy(); - - if(stack.getItemDamage() == Short.MAX_VALUE) - stack.setItemDamage(0); - - int xPos = gui.getLeft() + x * 29 + 7 + (y == 0 && x == 3 ? 10 : 0); - int yPos = gui.getTop() + y * 29 + 24 - (y == 0 ? 7 : 0); - ItemStack stack1 = stack.copy(); - if(stack1.getItemDamage() == -1) - stack1.setItemDamage(0); - - renderItem(gui, xPos, yPos, stack1, accountForContainer); - } - - @SideOnly(Side.CLIENT) - public void renderItem(IGuiLexiconEntry gui, double xPos, double yPos, ItemStack stack, boolean accountForContainer) { - RenderItem render = new RenderItem(); - boolean mouseDown = Mouse.isButtonDown(0); - - GL11.glPushMatrix(); - GL11.glEnable(GL11.GL_BLEND); - GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); - RenderHelper.enableGUIStandardItemLighting(); - GL11.glEnable(GL12.GL_RESCALE_NORMAL); - GL11.glEnable(GL11.GL_DEPTH_TEST); - GL11.glPushMatrix(); - GL11.glTranslated(xPos, yPos, 0); - render.renderItemAndEffectIntoGUI(Minecraft.getMinecraft().fontRenderer, Minecraft.getMinecraft().getTextureManager(), stack, 0, 0); - render.renderItemOverlayIntoGUI(Minecraft.getMinecraft().fontRenderer, Minecraft.getMinecraft().getTextureManager(), stack, 0, 0); - GL11.glPopMatrix(); - RenderHelper.disableStandardItemLighting(); - GL11.glPopMatrix(); - - int xpi = (int) xPos; - int ypi = (int) yPos; - if(relativeMouseX >= xpi && relativeMouseY >= ypi && relativeMouseX <= xpi + 16 && relativeMouseY <= ypi + 16) { - tooltipStack = stack; - - EntryData data = LexiconRecipeMappings.getDataForStack(tooltipStack); - ItemStack book = Minecraft.getMinecraft().thePlayer.getCurrentEquippedItem(); - - if(data != null && (data.entry != gui.getEntry() || data.page != gui.getPageOn()) && book != null && book.getItem() instanceof ILexicon && ((ILexicon) book.getItem()).isKnowledgeUnlocked(book, data.entry.getKnowledgeType())) { - tooltipEntry = true; - - if(!mouseDownLastTick && mouseDown && GuiScreen.isShiftKeyDown()) { - GuiLexiconEntry newGui = new GuiLexiconEntry(data.entry, (GuiScreen) gui); - newGui.page = data.page; - Minecraft.getMinecraft().displayGuiScreen(newGui); - } - } else tooltipEntry = false; - - if(accountForContainer) { - ItemStack containerStack = stack.getItem().getContainerItem(stack); - if(containerStack != null && containerStack.getItem() != null) - tooltipContainerStack = containerStack; - } - } - - GL11.glDisable(GL11.GL_LIGHTING); - } - - public static List filterRecipes(List list) { - if (list == null) return new ArrayList(); - ArrayList filtered = new ArrayList(); - for (T entry: list) { - if (entry != null) filtered.add(entry); - } - return filtered; - } - + int relativeMouseX, relativeMouseY; + ItemStack tooltipStack, tooltipContainerStack; + boolean tooltipEntry; + + static boolean mouseDownLastTick = false; + + public PageRecipe(String unlocalizedName) { + super(unlocalizedName); + } + + @Override + @SideOnly(Side.CLIENT) + public void renderScreen(IGuiLexiconEntry gui, int mx, int my) { + relativeMouseX = mx; + relativeMouseY = my; + + renderRecipe(gui, mx, my); + + int width = gui.getWidth() - 30; + int height = gui.getHeight(); + int x = gui.getLeft() + 16; + int y = gui.getTop() + height - 40; + PageText.renderText(x, y, width, height, getUnlocalizedName()); + + if (tooltipStack != null) { + List tooltipData = tooltipStack.getTooltip(Minecraft.getMinecraft().thePlayer, false); + List parsedTooltip = new ArrayList(); + boolean first = true; + + for (String s : tooltipData) { + String s_ = s; + if (!first) s_ = EnumChatFormatting.GRAY + s; + parsedTooltip.add(s_); + first = false; + } + + vazkii.botania.client.core.helper.RenderHelper.renderTooltip(mx, my, parsedTooltip); + + int tooltipY = 8 + tooltipData.size() * 11; + + if (tooltipEntry) { + vazkii.botania.client.core.helper.RenderHelper.renderTooltipOrange( + mx, + my + tooltipY, + Arrays.asList( + EnumChatFormatting.GRAY + StatCollector.translateToLocal("botaniamisc.clickToRecipe"))); + tooltipY += 18; + } + + if (tooltipContainerStack != null) + vazkii.botania.client.core.helper.RenderHelper.renderTooltipGreen( + mx, + my + tooltipY, + Arrays.asList( + EnumChatFormatting.AQUA + + StatCollector.translateToLocal("botaniamisc.craftingContainer"), + tooltipContainerStack.getDisplayName())); + } + + tooltipStack = tooltipContainerStack = null; + tooltipEntry = false; + GL11.glDisable(GL11.GL_BLEND); + mouseDownLastTick = Mouse.isButtonDown(0); + } + + @SideOnly(Side.CLIENT) + public void renderRecipe(IGuiLexiconEntry gui, int mx, int my) { + // NO-OP + } + + @SideOnly(Side.CLIENT) + public void renderItemAtAngle(IGuiLexiconEntry gui, float angle, ItemStack stack) { + if (stack == null || stack.getItem() == null) return; + + ItemStack workStack = stack.copy(); + + if (workStack.getItemDamage() == Short.MAX_VALUE || workStack.getItemDamage() == -1) workStack.setItemDamage(0); + + angle -= 90; + int radius = 32; + double xPos = gui.getLeft() + Math.cos(angle * Math.PI / 180D) * radius + gui.getWidth() / 2 - 8; + double yPos = gui.getTop() + Math.sin(angle * Math.PI / 180D) * radius + 53; + + renderItem(gui, xPos, yPos, workStack, false); + } + + @SideOnly(Side.CLIENT) + public void renderItemAtGridPos(IGuiLexiconEntry gui, int x, int y, ItemStack stack, boolean accountForContainer) { + if (stack == null || stack.getItem() == null) return; + stack = stack.copy(); + + if (stack.getItemDamage() == Short.MAX_VALUE) stack.setItemDamage(0); + + int xPos = gui.getLeft() + x * 29 + 7 + (y == 0 && x == 3 ? 10 : 0); + int yPos = gui.getTop() + y * 29 + 24 - (y == 0 ? 7 : 0); + ItemStack stack1 = stack.copy(); + if (stack1.getItemDamage() == -1) stack1.setItemDamage(0); + + renderItem(gui, xPos, yPos, stack1, accountForContainer); + } + + @SideOnly(Side.CLIENT) + public void renderItem( + IGuiLexiconEntry gui, double xPos, double yPos, ItemStack stack, boolean accountForContainer) { + RenderItem render = new RenderItem(); + boolean mouseDown = Mouse.isButtonDown(0); + + GL11.glPushMatrix(); + GL11.glEnable(GL11.GL_BLEND); + GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); + RenderHelper.enableGUIStandardItemLighting(); + GL11.glEnable(GL12.GL_RESCALE_NORMAL); + GL11.glEnable(GL11.GL_DEPTH_TEST); + GL11.glPushMatrix(); + GL11.glTranslated(xPos, yPos, 0); + render.renderItemAndEffectIntoGUI( + Minecraft.getMinecraft().fontRenderer, Minecraft.getMinecraft().getTextureManager(), stack, 0, 0); + render.renderItemOverlayIntoGUI( + Minecraft.getMinecraft().fontRenderer, Minecraft.getMinecraft().getTextureManager(), stack, 0, 0); + GL11.glPopMatrix(); + RenderHelper.disableStandardItemLighting(); + GL11.glPopMatrix(); + + int xpi = (int) xPos; + int ypi = (int) yPos; + if (relativeMouseX >= xpi + && relativeMouseY >= ypi + && relativeMouseX <= xpi + 16 + && relativeMouseY <= ypi + 16) { + tooltipStack = stack; + + EntryData data = LexiconRecipeMappings.getDataForStack(tooltipStack); + ItemStack book = Minecraft.getMinecraft().thePlayer.getCurrentEquippedItem(); + + if (data != null + && (data.entry != gui.getEntry() || data.page != gui.getPageOn()) + && book != null + && book.getItem() instanceof ILexicon + && ((ILexicon) book.getItem()).isKnowledgeUnlocked(book, data.entry.getKnowledgeType())) { + tooltipEntry = true; + + if (!mouseDownLastTick && mouseDown && GuiScreen.isShiftKeyDown()) { + GuiLexiconEntry newGui = new GuiLexiconEntry(data.entry, (GuiScreen) gui); + newGui.page = data.page; + Minecraft.getMinecraft().displayGuiScreen(newGui); + } + } else tooltipEntry = false; + + if (accountForContainer) { + ItemStack containerStack = stack.getItem().getContainerItem(stack); + if (containerStack != null && containerStack.getItem() != null) tooltipContainerStack = containerStack; + } + } + + GL11.glDisable(GL11.GL_LIGHTING); + } + + public static List filterRecipes(List list) { + if (list == null) return new ArrayList(); + ArrayList filtered = new ArrayList(); + for (T entry : list) { + if (entry != null) filtered.add(entry); + } + return filtered; + } } diff --git a/src/main/java/vazkii/botania/common/lexicon/page/PageRuneRecipe.java b/src/main/java/vazkii/botania/common/lexicon/page/PageRuneRecipe.java index 752cd4190e..e0d446acae 100644 --- a/src/main/java/vazkii/botania/common/lexicon/page/PageRuneRecipe.java +++ b/src/main/java/vazkii/botania/common/lexicon/page/PageRuneRecipe.java @@ -2,73 +2,72 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Feb 8, 2014, 1:11:48 PM (GMT)] */ package vazkii.botania.common.lexicon.page; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; import java.util.List; - import net.minecraft.client.Minecraft; import net.minecraft.client.gui.FontRenderer; import net.minecraft.item.ItemStack; import net.minecraft.util.StatCollector; - import org.lwjgl.opengl.GL11; - import vazkii.botania.api.internal.IGuiLexiconEntry; import vazkii.botania.api.recipe.RecipeRuneAltar; import vazkii.botania.client.core.handler.HUDHandler; import vazkii.botania.common.block.ModBlocks; import vazkii.botania.common.block.tile.mana.TilePool; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; public class PageRuneRecipe extends PagePetalRecipe { - public PageRuneRecipe(String unlocalizedName, List recipes) { - super(unlocalizedName, recipes); - } - - public PageRuneRecipe(String unlocalizedName, RecipeRuneAltar recipes) { - super(unlocalizedName, recipes); - } + public PageRuneRecipe(String unlocalizedName, List recipes) { + super(unlocalizedName, recipes); + } - @Override - ItemStack getMiddleStack() { - return new ItemStack(ModBlocks.runeAltar); - } + public PageRuneRecipe(String unlocalizedName, RecipeRuneAltar recipes) { + super(unlocalizedName, recipes); + } - @Override - @SideOnly(Side.CLIENT) - public void renderManaBar(IGuiLexiconEntry gui, RecipeRuneAltar recipe, int mx, int my) { - FontRenderer font = Minecraft.getMinecraft().fontRenderer; - GL11.glEnable(GL11.GL_BLEND); - GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); - String manaUsage = StatCollector.translateToLocal("botaniamisc.manaUsage"); - font.drawString(manaUsage, gui.getLeft() + gui.getWidth() / 2 - font.getStringWidth(manaUsage) / 2, gui.getTop() + 110, 0x66000000); + @Override + ItemStack getMiddleStack() { + return new ItemStack(ModBlocks.runeAltar); + } - int ratio = 10; - int x = gui.getLeft() + gui.getWidth() / 2 - 50; - int y = gui.getTop() + 120; + @Override + @SideOnly(Side.CLIENT) + public void renderManaBar(IGuiLexiconEntry gui, RecipeRuneAltar recipe, int mx, int my) { + FontRenderer font = Minecraft.getMinecraft().fontRenderer; + GL11.glEnable(GL11.GL_BLEND); + GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); + String manaUsage = StatCollector.translateToLocal("botaniamisc.manaUsage"); + font.drawString( + manaUsage, + gui.getLeft() + gui.getWidth() / 2 - font.getStringWidth(manaUsage) / 2, + gui.getTop() + 110, + 0x66000000); - if(mx > x + 1 && mx <= x + 101 && my > y - 14 && my <= y + 11) - ratio = 1; + int ratio = 10; + int x = gui.getLeft() + gui.getWidth() / 2 - 50; + int y = gui.getTop() + 120; - HUDHandler.renderManaBar(x, y, 0x0000FF, 0.75F, recipe.getManaUsage(), TilePool.MAX_MANA / ratio); + if (mx > x + 1 && mx <= x + 101 && my > y - 14 && my <= y + 11) ratio = 1; - String ratioString = String.format(StatCollector.translateToLocal("botaniamisc.ratio"), ratio); - String stopStr = StatCollector.translateToLocal("botaniamisc.shiftToStopSpin"); + HUDHandler.renderManaBar(x, y, 0x0000FF, 0.75F, recipe.getManaUsage(), TilePool.MAX_MANA / ratio); - boolean unicode = font.getUnicodeFlag(); - font.setUnicodeFlag(true); - font.drawString(stopStr, x + 50 - font.getStringWidth(stopStr) / 2, y + 15, 0x99000000); - font.drawString(ratioString, x + 50 - font.getStringWidth(ratioString) / 2, y + 5, 0x99000000); - font.setUnicodeFlag(unicode); - GL11.glDisable(GL11.GL_BLEND); - } + String ratioString = String.format(StatCollector.translateToLocal("botaniamisc.ratio"), ratio); + String stopStr = StatCollector.translateToLocal("botaniamisc.shiftToStopSpin"); + boolean unicode = font.getUnicodeFlag(); + font.setUnicodeFlag(true); + font.drawString(stopStr, x + 50 - font.getStringWidth(stopStr) / 2, y + 15, 0x99000000); + font.drawString(ratioString, x + 50 - font.getStringWidth(ratioString) / 2, y + 5, 0x99000000); + font.setUnicodeFlag(unicode); + GL11.glDisable(GL11.GL_BLEND); + } } diff --git a/src/main/java/vazkii/botania/common/lexicon/page/PageShedding.java b/src/main/java/vazkii/botania/common/lexicon/page/PageShedding.java index 7ba683c6de..f85e47cf03 100644 --- a/src/main/java/vazkii/botania/common/lexicon/page/PageShedding.java +++ b/src/main/java/vazkii/botania/common/lexicon/page/PageShedding.java @@ -2,18 +2,19 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jul 4, 2014, 10:38:50 PM (GMT)] */ package vazkii.botania.common.lexicon.page; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; import java.util.ArrayList; import java.util.Arrays; import java.util.List; - import net.minecraft.client.Minecraft; import net.minecraft.client.gui.GuiScreen; import net.minecraft.client.renderer.RenderHelper; @@ -25,131 +26,134 @@ import net.minecraft.util.MathHelper; import net.minecraft.util.ResourceLocation; import net.minecraft.util.StatCollector; - import org.lwjgl.input.Mouse; import org.lwjgl.opengl.GL11; import org.lwjgl.opengl.GL12; - import vazkii.botania.api.internal.IGuiLexiconEntry; import vazkii.botania.api.lexicon.LexiconRecipeMappings; import vazkii.botania.api.lexicon.LexiconRecipeMappings.EntryData; import vazkii.botania.client.gui.lexicon.GuiLexiconEntry; import vazkii.botania.client.lib.LibResources; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; public class PageShedding extends PageEntity { - private static final ResourceLocation sheddingOverlay = new ResourceLocation(LibResources.GUI_SHEDDING_OVERLAY); - - ItemStack shedStack; - ItemStack tooltipStack; - boolean tooltipEntry; - - static boolean mouseDownLastTick = false; - - public PageShedding(String unlocalizedName, String entity, int size, ItemStack shedStack) { - super(unlocalizedName, entity, size); - this.shedStack = shedStack; - } - - @Override - @SideOnly(Side.CLIENT) - public void renderScreen(IGuiLexiconEntry gui, int mx, int my) { - prepDummy(); - relativeMouseX = mx; - relativeMouseY = my; - int stack_x = gui.getLeft() + gui.getWidth() / 2 - 8; - int stack_y = gui.getTop() + gui.getHeight() - 40 - 18 - 5; - int entity_scale = getEntityScale(size); - int entity_x = gui.getLeft() + gui.getWidth() / 2; - int entity_y = gui.getTop() + gui.getHeight() / 2 + MathHelper.floor_float(dummyEntity.height * entity_scale / 2) - 29; - - renderEntity(gui, dummyEntity, entity_x, entity_y, entity_scale, dummyEntity.ticksExisted * 2); - - renderItem(gui, stack_x, stack_y, shedStack); - - TextureManager render = Minecraft.getMinecraft().renderEngine; - render.bindTexture(sheddingOverlay); - - GL11.glEnable(GL11.GL_BLEND); - GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); - GL11.glColor4f(1F, 1F, 1F, 1F); - ((GuiScreen) gui).drawTexturedModalRect(gui.getLeft(), gui.getTop(), 0, 0, gui.getWidth(), gui.getHeight()); - - if(tooltipStack != null) { - List tooltipData = tooltipStack.getTooltip(Minecraft.getMinecraft().thePlayer, false); - List parsedTooltip = new ArrayList(); - boolean first = true; - - for(String s : tooltipData) { - String s_ = s; - if(!first) - s_ = EnumChatFormatting.GRAY + s; - parsedTooltip.add(s_); - first = false; - } - - vazkii.botania.client.core.helper.RenderHelper.renderTooltip(mx, my, parsedTooltip); - - int tooltipY = 8 + tooltipData.size() * 11; - - if(tooltipEntry) { - vazkii.botania.client.core.helper.RenderHelper.renderTooltipOrange(mx, my + tooltipY, Arrays.asList(EnumChatFormatting.GRAY + StatCollector.translateToLocal("botaniamisc.clickToRecipe"))); - tooltipY += 18; - } - } - else if(tooltipEntity) { - List parsedTooltip = new ArrayList(); - parsedTooltip.add(EntityList.getEntityString(dummyEntity)); - vazkii.botania.client.core.helper.RenderHelper.renderTooltip(mx, my, parsedTooltip); - } - - tooltipStack = null; - tooltipEntry = tooltipEntity = false; - GL11.glDisable(GL11.GL_BLEND); - mouseDownLastTick = Mouse.isButtonDown(0); - } - - @SideOnly(Side.CLIENT) - public void renderItem(IGuiLexiconEntry gui, int xPos, int yPos, ItemStack stack) { - RenderItem render = new RenderItem(); - boolean mouseDown = Mouse.isButtonDown(0); - - GL11.glPushMatrix(); - GL11.glEnable(GL11.GL_BLEND); - GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); - RenderHelper.enableGUIStandardItemLighting(); - GL11.glEnable(GL12.GL_RESCALE_NORMAL); - GL11.glEnable(GL11.GL_DEPTH_TEST); - render.renderItemAndEffectIntoGUI(Minecraft.getMinecraft().fontRenderer, Minecraft.getMinecraft().getTextureManager(), stack, xPos, yPos); - render.renderItemOverlayIntoGUI(Minecraft.getMinecraft().fontRenderer, Minecraft.getMinecraft().getTextureManager(), stack, xPos, yPos); - RenderHelper.disableStandardItemLighting(); - GL11.glPopMatrix(); - - if(relativeMouseX >= xPos && relativeMouseY >= yPos && relativeMouseX <= xPos + 16 && relativeMouseY <= yPos + 16) { - tooltipStack = stack; - - EntryData data = LexiconRecipeMappings.getDataForStack(tooltipStack); - if(data != null && (data.entry != gui.getEntry() || data.page != gui.getPageOn())) { - tooltipEntry = true; - - if(!mouseDownLastTick && mouseDown && GuiScreen.isShiftKeyDown()) { - GuiLexiconEntry newGui = new GuiLexiconEntry(data.entry, (GuiScreen) gui); - newGui.page = data.page; - Minecraft.getMinecraft().displayGuiScreen(newGui); - } - } - } - - GL11.glDisable(GL11.GL_LIGHTING); - } - - @Override - public List getDisplayedRecipes() { - ArrayList list = new ArrayList(); - list.add(shedStack); - return list; - } - + private static final ResourceLocation sheddingOverlay = new ResourceLocation(LibResources.GUI_SHEDDING_OVERLAY); + + ItemStack shedStack; + ItemStack tooltipStack; + boolean tooltipEntry; + + static boolean mouseDownLastTick = false; + + public PageShedding(String unlocalizedName, String entity, int size, ItemStack shedStack) { + super(unlocalizedName, entity, size); + this.shedStack = shedStack; + } + + @Override + @SideOnly(Side.CLIENT) + public void renderScreen(IGuiLexiconEntry gui, int mx, int my) { + prepDummy(); + relativeMouseX = mx; + relativeMouseY = my; + int stack_x = gui.getLeft() + gui.getWidth() / 2 - 8; + int stack_y = gui.getTop() + gui.getHeight() - 40 - 18 - 5; + int entity_scale = getEntityScale(size); + int entity_x = gui.getLeft() + gui.getWidth() / 2; + int entity_y = + gui.getTop() + gui.getHeight() / 2 + MathHelper.floor_float(dummyEntity.height * entity_scale / 2) - 29; + + renderEntity(gui, dummyEntity, entity_x, entity_y, entity_scale, dummyEntity.ticksExisted * 2); + + renderItem(gui, stack_x, stack_y, shedStack); + + TextureManager render = Minecraft.getMinecraft().renderEngine; + render.bindTexture(sheddingOverlay); + + GL11.glEnable(GL11.GL_BLEND); + GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); + GL11.glColor4f(1F, 1F, 1F, 1F); + ((GuiScreen) gui).drawTexturedModalRect(gui.getLeft(), gui.getTop(), 0, 0, gui.getWidth(), gui.getHeight()); + + if (tooltipStack != null) { + List tooltipData = tooltipStack.getTooltip(Minecraft.getMinecraft().thePlayer, false); + List parsedTooltip = new ArrayList(); + boolean first = true; + + for (String s : tooltipData) { + String s_ = s; + if (!first) s_ = EnumChatFormatting.GRAY + s; + parsedTooltip.add(s_); + first = false; + } + + vazkii.botania.client.core.helper.RenderHelper.renderTooltip(mx, my, parsedTooltip); + + int tooltipY = 8 + tooltipData.size() * 11; + + if (tooltipEntry) { + vazkii.botania.client.core.helper.RenderHelper.renderTooltipOrange( + mx, + my + tooltipY, + Arrays.asList( + EnumChatFormatting.GRAY + StatCollector.translateToLocal("botaniamisc.clickToRecipe"))); + tooltipY += 18; + } + } else if (tooltipEntity) { + List parsedTooltip = new ArrayList(); + parsedTooltip.add(EntityList.getEntityString(dummyEntity)); + vazkii.botania.client.core.helper.RenderHelper.renderTooltip(mx, my, parsedTooltip); + } + + tooltipStack = null; + tooltipEntry = tooltipEntity = false; + GL11.glDisable(GL11.GL_BLEND); + mouseDownLastTick = Mouse.isButtonDown(0); + } + + @SideOnly(Side.CLIENT) + public void renderItem(IGuiLexiconEntry gui, int xPos, int yPos, ItemStack stack) { + RenderItem render = new RenderItem(); + boolean mouseDown = Mouse.isButtonDown(0); + + GL11.glPushMatrix(); + GL11.glEnable(GL11.GL_BLEND); + GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); + RenderHelper.enableGUIStandardItemLighting(); + GL11.glEnable(GL12.GL_RESCALE_NORMAL); + GL11.glEnable(GL11.GL_DEPTH_TEST); + render.renderItemAndEffectIntoGUI( + Minecraft.getMinecraft().fontRenderer, Minecraft.getMinecraft().getTextureManager(), stack, xPos, yPos); + render.renderItemOverlayIntoGUI( + Minecraft.getMinecraft().fontRenderer, Minecraft.getMinecraft().getTextureManager(), stack, xPos, yPos); + RenderHelper.disableStandardItemLighting(); + GL11.glPopMatrix(); + + if (relativeMouseX >= xPos + && relativeMouseY >= yPos + && relativeMouseX <= xPos + 16 + && relativeMouseY <= yPos + 16) { + tooltipStack = stack; + + EntryData data = LexiconRecipeMappings.getDataForStack(tooltipStack); + if (data != null && (data.entry != gui.getEntry() || data.page != gui.getPageOn())) { + tooltipEntry = true; + + if (!mouseDownLastTick && mouseDown && GuiScreen.isShiftKeyDown()) { + GuiLexiconEntry newGui = new GuiLexiconEntry(data.entry, (GuiScreen) gui); + newGui.page = data.page; + Minecraft.getMinecraft().displayGuiScreen(newGui); + } + } + } + + GL11.glDisable(GL11.GL_LIGHTING); + } + + @Override + public List getDisplayedRecipes() { + ArrayList list = new ArrayList(); + list.add(shedStack); + return list; + } } diff --git a/src/main/java/vazkii/botania/common/lexicon/page/PageTerrasteel.java b/src/main/java/vazkii/botania/common/lexicon/page/PageTerrasteel.java index 8f9d313ea8..580cedb7de 100644 --- a/src/main/java/vazkii/botania/common/lexicon/page/PageTerrasteel.java +++ b/src/main/java/vazkii/botania/common/lexicon/page/PageTerrasteel.java @@ -2,97 +2,113 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Apr 14, 2014, 5:57:26 PM (GMT)] */ package vazkii.botania.common.lexicon.page; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; import java.util.ArrayList; import java.util.List; - import net.minecraft.block.Block; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.GuiScreen; import net.minecraft.init.Blocks; import net.minecraft.item.ItemStack; import net.minecraft.util.ResourceLocation; - import org.lwjgl.opengl.GL11; - import vazkii.botania.api.internal.IGuiLexiconEntry; import vazkii.botania.api.lexicon.LexiconEntry; import vazkii.botania.api.lexicon.LexiconRecipeMappings; import vazkii.botania.client.lib.LibResources; import vazkii.botania.common.block.ModBlocks; import vazkii.botania.common.item.ModItems; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; public class PageTerrasteel extends PageRecipe { - private static final ResourceLocation terrasteelOverlay = new ResourceLocation(LibResources.GUI_TERRASTEEL_OVERLAY); - - public PageTerrasteel(String unlocalizedName) { - super(unlocalizedName); - } - - @Override - @SideOnly(Side.CLIENT) - public void renderRecipe(IGuiLexiconEntry gui, int mx, int my) { - Block block1 = ModBlocks.livingrock; - Block block2 = Blocks.lapis_block; - Block block3 = ModBlocks.terraPlate; - - GL11.glTranslatef(0F, 0F, -10F); - renderItem(gui, gui.getLeft() + gui.getWidth() / 2 - 8, gui.getTop() + 103, new ItemStack(block1), false); - - GL11.glTranslatef(0F, 0F, 5F); - renderItem(gui, gui.getLeft() + gui.getWidth() / 2 - 8 + 7, gui.getTop() + 106, new ItemStack(block2), false); - renderItem(gui, gui.getLeft() + gui.getWidth() / 2 - 8 - 6, gui.getTop() + 106, new ItemStack(block2), false); - - GL11.glTranslatef(0F, 0F, 5F); - renderItem(gui, gui.getLeft() + gui.getWidth() / 2 - 8, gui.getTop() + 110, new ItemStack(block1), false); - renderItem(gui, gui.getLeft() + gui.getWidth() / 2 - 8 + 14, gui.getTop() + 110, new ItemStack(block1), false); - renderItem(gui, gui.getLeft() + gui.getWidth() / 2 - 8 - 13, gui.getTop() + 110, new ItemStack(block1), false); - - GL11.glTranslatef(0F, 0F, 5F); - renderItem(gui, gui.getLeft() + gui.getWidth() / 2 - 8 - 6, gui.getTop() + 114, new ItemStack(block2), false); - renderItem(gui, gui.getLeft() + gui.getWidth() / 2 - 8 + 7, gui.getTop() + 114, new ItemStack(block2), false); - - GL11.glTranslatef(0F, 0F, 5F); - renderItem(gui, gui.getLeft() + gui.getWidth() / 2 - 8 + 1, gui.getTop() + 117, new ItemStack(block1), false); - - GL11.glTranslatef(0F, 0F, 5F); - renderItem(gui, gui.getLeft() + gui.getWidth() / 2 - 8, gui.getTop() + 102, new ItemStack(block3), false); - GL11.glTranslatef(0F, 0F, -10F); - - renderItem(gui, gui.getLeft() + gui.getWidth() / 2 - 8, gui.getTop() + 30, new ItemStack(ModItems.manaResource, 1, 4), false); - renderItem(gui, gui.getLeft() + gui.getWidth() / 2 - 8, gui.getTop() + 80, new ItemStack(ModItems.manaResource, 1, 0), false); - renderItem(gui, gui.getLeft() + gui.getWidth() / 2 - 8 - 20, gui.getTop() + 86, new ItemStack(ModItems.manaResource, 1, 1), false); - renderItem(gui, gui.getLeft() + gui.getWidth() / 2 - 8 + 19, gui.getTop() + 86, new ItemStack(ModItems.manaResource, 1, 2), false); - - Minecraft.getMinecraft().renderEngine.bindTexture(terrasteelOverlay); - - GL11.glEnable(GL11.GL_BLEND); - GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); - GL11.glColor4f(1F, 1F, 1F, 1F); - ((GuiScreen) gui).drawTexturedModalRect(gui.getLeft(), gui.getTop(), 0, 0, gui.getWidth(), gui.getHeight()); - GL11.glDisable(GL11.GL_BLEND); - } - - @Override - public void onPageAdded(LexiconEntry entry, int index) { - LexiconRecipeMappings.map(new ItemStack(ModItems.manaResource, 1, 4), entry, index); - } - - @Override - public List getDisplayedRecipes() { - ArrayList list = new ArrayList(); - list.add(new ItemStack(ModItems.manaResource, 1, 4)); - return list; - } - + private static final ResourceLocation terrasteelOverlay = new ResourceLocation(LibResources.GUI_TERRASTEEL_OVERLAY); + + public PageTerrasteel(String unlocalizedName) { + super(unlocalizedName); + } + + @Override + @SideOnly(Side.CLIENT) + public void renderRecipe(IGuiLexiconEntry gui, int mx, int my) { + Block block1 = ModBlocks.livingrock; + Block block2 = Blocks.lapis_block; + Block block3 = ModBlocks.terraPlate; + + GL11.glTranslatef(0F, 0F, -10F); + renderItem(gui, gui.getLeft() + gui.getWidth() / 2 - 8, gui.getTop() + 103, new ItemStack(block1), false); + + GL11.glTranslatef(0F, 0F, 5F); + renderItem(gui, gui.getLeft() + gui.getWidth() / 2 - 8 + 7, gui.getTop() + 106, new ItemStack(block2), false); + renderItem(gui, gui.getLeft() + gui.getWidth() / 2 - 8 - 6, gui.getTop() + 106, new ItemStack(block2), false); + + GL11.glTranslatef(0F, 0F, 5F); + renderItem(gui, gui.getLeft() + gui.getWidth() / 2 - 8, gui.getTop() + 110, new ItemStack(block1), false); + renderItem(gui, gui.getLeft() + gui.getWidth() / 2 - 8 + 14, gui.getTop() + 110, new ItemStack(block1), false); + renderItem(gui, gui.getLeft() + gui.getWidth() / 2 - 8 - 13, gui.getTop() + 110, new ItemStack(block1), false); + + GL11.glTranslatef(0F, 0F, 5F); + renderItem(gui, gui.getLeft() + gui.getWidth() / 2 - 8 - 6, gui.getTop() + 114, new ItemStack(block2), false); + renderItem(gui, gui.getLeft() + gui.getWidth() / 2 - 8 + 7, gui.getTop() + 114, new ItemStack(block2), false); + + GL11.glTranslatef(0F, 0F, 5F); + renderItem(gui, gui.getLeft() + gui.getWidth() / 2 - 8 + 1, gui.getTop() + 117, new ItemStack(block1), false); + + GL11.glTranslatef(0F, 0F, 5F); + renderItem(gui, gui.getLeft() + gui.getWidth() / 2 - 8, gui.getTop() + 102, new ItemStack(block3), false); + GL11.glTranslatef(0F, 0F, -10F); + + renderItem( + gui, + gui.getLeft() + gui.getWidth() / 2 - 8, + gui.getTop() + 30, + new ItemStack(ModItems.manaResource, 1, 4), + false); + renderItem( + gui, + gui.getLeft() + gui.getWidth() / 2 - 8, + gui.getTop() + 80, + new ItemStack(ModItems.manaResource, 1, 0), + false); + renderItem( + gui, + gui.getLeft() + gui.getWidth() / 2 - 8 - 20, + gui.getTop() + 86, + new ItemStack(ModItems.manaResource, 1, 1), + false); + renderItem( + gui, + gui.getLeft() + gui.getWidth() / 2 - 8 + 19, + gui.getTop() + 86, + new ItemStack(ModItems.manaResource, 1, 2), + false); + + Minecraft.getMinecraft().renderEngine.bindTexture(terrasteelOverlay); + + GL11.glEnable(GL11.GL_BLEND); + GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); + GL11.glColor4f(1F, 1F, 1F, 1F); + ((GuiScreen) gui).drawTexturedModalRect(gui.getLeft(), gui.getTop(), 0, 0, gui.getWidth(), gui.getHeight()); + GL11.glDisable(GL11.GL_BLEND); + } + + @Override + public void onPageAdded(LexiconEntry entry, int index) { + LexiconRecipeMappings.map(new ItemStack(ModItems.manaResource, 1, 4), entry, index); + } + + @Override + public List getDisplayedRecipes() { + ArrayList list = new ArrayList(); + list.add(new ItemStack(ModItems.manaResource, 1, 4)); + return list; + } } diff --git a/src/main/java/vazkii/botania/common/lexicon/page/PageText.java b/src/main/java/vazkii/botania/common/lexicon/page/PageText.java index a9a2214458..73d2efdbba 100644 --- a/src/main/java/vazkii/botania/common/lexicon/page/PageText.java +++ b/src/main/java/vazkii/botania/common/lexicon/page/PageText.java @@ -2,17 +2,19 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jan 14, 2014, 6:45:33 PM (GMT)] */ package vazkii.botania.common.lexicon.page; +import com.google.common.base.Joiner; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; import java.util.ArrayList; import java.util.List; - import net.minecraft.client.Minecraft; import net.minecraft.client.gui.FontRenderer; import net.minecraft.util.StatCollector; @@ -20,113 +22,109 @@ import vazkii.botania.api.lexicon.LexiconPage; import vazkii.botania.common.core.handler.ConfigHandler; -import com.google.common.base.Joiner; - -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; - public class PageText extends LexiconPage { - public PageText(String unlocalizedName) { - super(unlocalizedName); - } - - @Override - @SideOnly(Side.CLIENT) - public void renderScreen(IGuiLexiconEntry gui, int mx, int my) { - int width = gui.getWidth() - 30; - int x = gui.getLeft() + 16; - int y = gui.getTop() + 2; - - renderText(x, y, width, gui.getHeight(), getUnlocalizedName()); - } - - public static void renderText(int x, int y, int width, int height, String unlocalizedText) { - renderText(x, y, width, height, 10, unlocalizedText); - } - - @SideOnly(Side.CLIENT) - public static void renderText(int x, int y, int width, int height, int paragraphSize, String unlocalizedText) { - x += 2; - y += 10; - width -= 4; - - FontRenderer font = Minecraft.getMinecraft().fontRenderer; - boolean unicode = font.getUnicodeFlag(); - font.setUnicodeFlag(true); - String text = StatCollector.translateToLocal(unlocalizedText).replaceAll("&", "\u00a7"); - String[] textEntries = text.split("
"); - - List> lines = new ArrayList(); - - String controlCodes = ""; - for(String s : textEntries) { - List words = new ArrayList(); - String lineStr = ""; - String[] tokens = s.split(" "); - for(String token : tokens) { - String prev = lineStr; - String spaced = token + " "; - lineStr += spaced; - - controlCodes = toControlCodes(getControlCodes(prev)); - if(font.getStringWidth(lineStr) > width) { - lines.add(words); - lineStr = controlCodes + spaced; - words = new ArrayList(); - } - - words.add(controlCodes + token); - } - - if(!lineStr.isEmpty()) - lines.add(words); - lines.add(new ArrayList()); - } - - int i = 0; - for(List words : lines) { - words.size(); - int xi = x; - int spacing = 4; - int wcount = words.size(); - int compensationSpaces = 0; - boolean justify = ConfigHandler.lexiconJustifiedText && wcount > 0 && lines.size() > i && !lines.get(i + 1).isEmpty(); - - if(justify) { - String s = Joiner.on("").join(words); - int swidth = font.getStringWidth(s); - int space = width - swidth; - - spacing = wcount == 1 ? 0 : space / (wcount - 1); - compensationSpaces = wcount == 1 ? 0 : space % (wcount - 1); - } - - for(String s : words) { - int extra = 0; - if(compensationSpaces > 0) { - compensationSpaces--; - extra++; - } - font.drawString(s, xi, y, 0); - xi += font.getStringWidth(s) + spacing + extra; - } - - y += words.isEmpty() ? paragraphSize : 10; - i++; - } - - font.setUnicodeFlag(unicode); - } - - public static String getControlCodes(String s) { - String controls = s.replaceAll("(?"); + + List> lines = new ArrayList(); + + String controlCodes = ""; + for (String s : textEntries) { + List words = new ArrayList(); + String lineStr = ""; + String[] tokens = s.split(" "); + for (String token : tokens) { + String prev = lineStr; + String spaced = token + " "; + lineStr += spaced; + + controlCodes = toControlCodes(getControlCodes(prev)); + if (font.getStringWidth(lineStr) > width) { + lines.add(words); + lineStr = controlCodes + spaced; + words = new ArrayList(); + } + + words.add(controlCodes + token); + } + + if (!lineStr.isEmpty()) lines.add(words); + lines.add(new ArrayList()); + } + + int i = 0; + for (List words : lines) { + words.size(); + int xi = x; + int spacing = 4; + int wcount = words.size(); + int compensationSpaces = 0; + boolean justify = ConfigHandler.lexiconJustifiedText + && wcount > 0 + && lines.size() > i + && !lines.get(i + 1).isEmpty(); + + if (justify) { + String s = Joiner.on("").join(words); + int swidth = font.getStringWidth(s); + int space = width - swidth; + + spacing = wcount == 1 ? 0 : space / (wcount - 1); + compensationSpaces = wcount == 1 ? 0 : space % (wcount - 1); + } + + for (String s : words) { + int extra = 0; + if (compensationSpaces > 0) { + compensationSpaces--; + extra++; + } + font.drawString(s, xi, y, 0); + xi += font.getStringWidth(s) + spacing + extra; + } + + y += words.isEmpty() ? paragraphSize : 10; + i++; + } + + font.setUnicodeFlag(unicode); + } + + public static String getControlCodes(String s) { + String controls = s.replaceAll("(?. It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Feb 16, 2015, 1:39:10 PM (GMT)] */ package vazkii.botania.common.lexicon.page; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; import java.awt.Desktop; import java.net.URI; - import net.minecraft.client.Minecraft; import net.minecraft.client.gui.GuiButton; import net.minecraft.util.ChatComponentTranslation; @@ -21,60 +22,75 @@ import net.minecraft.util.StatCollector; import vazkii.botania.api.internal.IGuiLexiconEntry; import vazkii.botania.client.gui.lexicon.GuiLexicon; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; public class PageTutorial extends PageText { - // Turn this on once we have an up to date video - private static final boolean VIDEO_ENABLED = false; - - GuiButton buttonText, buttonVideo; + // Turn this on once we have an up to date video + private static final boolean VIDEO_ENABLED = false; - public PageTutorial(String unlocalizedName) { - super(unlocalizedName); - } + GuiButton buttonText, buttonVideo; - @Override - public void onOpened(IGuiLexiconEntry gui) { - buttonText = new GuiButton(101, gui.getLeft() + 20, gui.getTop() + gui.getHeight() - 40, 50, 20, StatCollector.translateToLocal("botaniamisc.tutorialText")); - if(VIDEO_ENABLED) - buttonVideo = new GuiButton(101, gui.getLeft() + 75, gui.getTop() + gui.getHeight() - 40, 50, 20, StatCollector.translateToLocal("botaniamisc.tutorialVideo")); + public PageTutorial(String unlocalizedName) { + super(unlocalizedName); + } - gui.getButtonList().add(buttonText); - if(VIDEO_ENABLED) - gui.getButtonList().add(buttonVideo); - } + @Override + public void onOpened(IGuiLexiconEntry gui) { + buttonText = new GuiButton( + 101, + gui.getLeft() + 20, + gui.getTop() + gui.getHeight() - 40, + 50, + 20, + StatCollector.translateToLocal("botaniamisc.tutorialText")); + if (VIDEO_ENABLED) + buttonVideo = new GuiButton( + 101, + gui.getLeft() + 75, + gui.getTop() + gui.getHeight() - 40, + 50, + 20, + StatCollector.translateToLocal("botaniamisc.tutorialVideo")); - @Override - public void onClosed(IGuiLexiconEntry gui) { - gui.getButtonList().remove(buttonText); - if(VIDEO_ENABLED) - gui.getButtonList().remove(buttonVideo); - } + gui.getButtonList().add(buttonText); + if (VIDEO_ENABLED) gui.getButtonList().add(buttonVideo); + } - @Override - public void renderScreen(IGuiLexiconEntry gui, int mx, int my) { - super.renderScreen(gui, mx, my); + @Override + public void onClosed(IGuiLexiconEntry gui) { + gui.getButtonList().remove(buttonText); + if (VIDEO_ENABLED) gui.getButtonList().remove(buttonVideo); + } - if(!VIDEO_ENABLED) - PageText.renderText(buttonText.xPosition + buttonText.width + 4, buttonText.yPosition - 14, 65, 100, "botaniamisc.noVideo"); - } + @Override + public void renderScreen(IGuiLexiconEntry gui, int mx, int my) { + super.renderScreen(gui, mx, my); - @Override - @SideOnly(Side.CLIENT) - public void onActionPerformed(IGuiLexiconEntry gui, GuiButton button) { - if(button == buttonText) { - GuiLexicon.startTutorial(); - Minecraft.getMinecraft().displayGuiScreen(new GuiLexicon()); - Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentTranslation("botaniamisc.tutorialStarted").setChatStyle(new ChatStyle().setColor(EnumChatFormatting.GREEN))); - } else if(button == buttonVideo && Desktop.isDesktopSupported()) { - try { - Desktop.getDesktop().browse(new URI("https://www.youtube.com/watch?v=rx0xyejC6fI")); - } catch(Exception e) { - e.printStackTrace(); - } - } - } + if (!VIDEO_ENABLED) + PageText.renderText( + buttonText.xPosition + buttonText.width + 4, + buttonText.yPosition - 14, + 65, + 100, + "botaniamisc.noVideo"); + } + @Override + @SideOnly(Side.CLIENT) + public void onActionPerformed(IGuiLexiconEntry gui, GuiButton button) { + if (button == buttonText) { + GuiLexicon.startTutorial(); + Minecraft.getMinecraft().displayGuiScreen(new GuiLexicon()); + Minecraft.getMinecraft() + .thePlayer + .addChatMessage(new ChatComponentTranslation("botaniamisc.tutorialStarted") + .setChatStyle(new ChatStyle().setColor(EnumChatFormatting.GREEN))); + } else if (button == buttonVideo && Desktop.isDesktopSupported()) { + try { + Desktop.getDesktop().browse(new URI("https://www.youtube.com/watch?v=rx0xyejC6fI")); + } catch (Exception e) { + e.printStackTrace(); + } + } + } } diff --git a/src/main/java/vazkii/botania/common/lib/LibAchievementNames.java b/src/main/java/vazkii/botania/common/lib/LibAchievementNames.java index 5372b364dd..1387b9ffdd 100644 --- a/src/main/java/vazkii/botania/common/lib/LibAchievementNames.java +++ b/src/main/java/vazkii/botania/common/lib/LibAchievementNames.java @@ -2,67 +2,66 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jan 28, 2015, 4:44:34 PM (GMT)] */ package vazkii.botania.common.lib; public final class LibAchievementNames { - public static final String FLOWER_PICKUP = "flowerPickup"; - public static final String LEXICON_USE = "lexiconUse"; - public static final String DAYBLOOM_PICKUP = "daybloomPickup"; - public static final String MANA_POOL_PICKUP = "manaPoolPickup"; - public static final String ENDOFLAME_PICKUP = "endoflamePickup"; - public static final String TINY_POTATO_PET = "tinyPotatoPet"; - public static final String SPARK_CRAFT = "sparkCraft"; - public static final String BAUBLE_WEAR = "baubleWear"; - public static final String MANA_COOKIE_EAT = "manaCookieEat"; - public static final String RUNE_PICKUP = "runePickup"; - public static final String MANA_BLASTER_SHOOT = "manaBlasterShoot"; - public static final String TIARA_WINGS = "tiaraWings"; - public static final String TERRASTEEL_PICKUP = "terrasteelPickup"; - public static final String ELF_PORTAL_OPEN = "elfPortalOpen"; - public static final String GAIA_GUARDIAN_KILL = "gaiaGuardianKill"; - public static final String TERRASTEEL_WEAPON_CRAFT = "terrasteelWeaponCraft"; - public static final String KEKIMURUS_PICKUP = "kekimurusPickup"; - public static final String HEISEI_DREAM_PICKUP = "heiseiDreamPickup"; - public static final String DIRT_ROD_CRAFT = "dirtRodCraft"; - public static final String SPAWNER_MOVER_USE = "spawnerMoverUse"; - public static final String ENDER_AIR_MAKE = "enderAirMake"; - public static final String CORPOREA_CRAFT = "corporeaCraft"; - public static final String CACOPHONIUM_CRAFT = "cacophoniumCraft"; - public static final String MANA_CART_CRAFT = "manaCartCraft"; - public static final String CRAFTING_HALO_CRAFT = "craftingHaloCraft"; - public static final String MANAWEAVE_ARMOR_CRAFT = "manaweaveArmorCraft"; - public static final String ENCHANTER_MAKE = "enchanterMake"; - public static final String POLLIDISIAC_PICKUP = "pollidisiacPickup"; - public static final String BREW_PICKUP = "brewPickup"; - public static final String TERRAFORM_ROD_CRAFT = "terraformRodCraft"; - public static final String BUBBELL_PICKUP = "bubbellPickup"; - public static final String LUMINIZER_RIDE = "luminizerRide"; - public static final String MANA_BOMB_IGNITE = "manaBombIgnite"; - public static final String DANDELIFEON_PICKUP = "dandelifeonPickup"; + public static final String FLOWER_PICKUP = "flowerPickup"; + public static final String LEXICON_USE = "lexiconUse"; + public static final String DAYBLOOM_PICKUP = "daybloomPickup"; + public static final String MANA_POOL_PICKUP = "manaPoolPickup"; + public static final String ENDOFLAME_PICKUP = "endoflamePickup"; + public static final String TINY_POTATO_PET = "tinyPotatoPet"; + public static final String SPARK_CRAFT = "sparkCraft"; + public static final String BAUBLE_WEAR = "baubleWear"; + public static final String MANA_COOKIE_EAT = "manaCookieEat"; + public static final String RUNE_PICKUP = "runePickup"; + public static final String MANA_BLASTER_SHOOT = "manaBlasterShoot"; + public static final String TIARA_WINGS = "tiaraWings"; + public static final String TERRASTEEL_PICKUP = "terrasteelPickup"; + public static final String ELF_PORTAL_OPEN = "elfPortalOpen"; + public static final String GAIA_GUARDIAN_KILL = "gaiaGuardianKill"; + public static final String TERRASTEEL_WEAPON_CRAFT = "terrasteelWeaponCraft"; + public static final String KEKIMURUS_PICKUP = "kekimurusPickup"; + public static final String HEISEI_DREAM_PICKUP = "heiseiDreamPickup"; + public static final String DIRT_ROD_CRAFT = "dirtRodCraft"; + public static final String SPAWNER_MOVER_USE = "spawnerMoverUse"; + public static final String ENDER_AIR_MAKE = "enderAirMake"; + public static final String CORPOREA_CRAFT = "corporeaCraft"; + public static final String CACOPHONIUM_CRAFT = "cacophoniumCraft"; + public static final String MANA_CART_CRAFT = "manaCartCraft"; + public static final String CRAFTING_HALO_CRAFT = "craftingHaloCraft"; + public static final String MANAWEAVE_ARMOR_CRAFT = "manaweaveArmorCraft"; + public static final String ENCHANTER_MAKE = "enchanterMake"; + public static final String POLLIDISIAC_PICKUP = "pollidisiacPickup"; + public static final String BREW_PICKUP = "brewPickup"; + public static final String TERRAFORM_ROD_CRAFT = "terraformRodCraft"; + public static final String BUBBELL_PICKUP = "bubbellPickup"; + public static final String LUMINIZER_RIDE = "luminizerRide"; + public static final String MANA_BOMB_IGNITE = "manaBombIgnite"; + public static final String DANDELIFEON_PICKUP = "dandelifeonPickup"; - public static final String SIGNAL_FLARE_STUN = "signalFlareStun"; - public static final String L20_SHARD_USE = "l20ShardUse"; - public static final String GAIA_GUARDIAN_NO_ARMOR = "gaiaGuardianNoArmor"; - public static final String RANK_SS_PICK = "rankSSPick"; - public static final String SUPER_CORPOREA_REQUEST = "superCorporeaRequest"; - public static final String PINKINATOR = "pinkinator"; + public static final String SIGNAL_FLARE_STUN = "signalFlareStun"; + public static final String L20_SHARD_USE = "l20ShardUse"; + public static final String GAIA_GUARDIAN_NO_ARMOR = "gaiaGuardianNoArmor"; + public static final String RANK_SS_PICK = "rankSSPick"; + public static final String SUPER_CORPOREA_REQUEST = "superCorporeaRequest"; + public static final String PINKINATOR = "pinkinator"; - public static final String RELIC_INFINITE_FRUIT = "infiniteFruit"; - public static final String RELIC_KING_KEY = "kingKey"; - public static final String RELIC_FLUGEL_EYE = "flugelEye"; - public static final String RELIC_THOR_RING = "thorRing"; - public static final String RELIC_ODIN_RING = "odinRing"; - public static final String RELIC_LOKI_RING = "lokiRing"; - public static final String RELIC_AESIR_RING = "aesirRing"; - - public static final String NULL_FLOWER = "nullFlower"; - public static final String DESU_GUN = "desuGun"; + public static final String RELIC_INFINITE_FRUIT = "infiniteFruit"; + public static final String RELIC_KING_KEY = "kingKey"; + public static final String RELIC_FLUGEL_EYE = "flugelEye"; + public static final String RELIC_THOR_RING = "thorRing"; + public static final String RELIC_ODIN_RING = "odinRing"; + public static final String RELIC_LOKI_RING = "lokiRing"; + public static final String RELIC_AESIR_RING = "aesirRing"; + public static final String NULL_FLOWER = "nullFlower"; + public static final String DESU_GUN = "desuGun"; } diff --git a/src/main/java/vazkii/botania/common/lib/LibBlockNames.java b/src/main/java/vazkii/botania/common/lib/LibBlockNames.java index 3d0992cb11..3179bb752c 100644 --- a/src/main/java/vazkii/botania/common/lib/LibBlockNames.java +++ b/src/main/java/vazkii/botania/common/lib/LibBlockNames.java @@ -2,163 +2,162 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jan 16, 2014, 5:55:03 PM (GMT)] */ package vazkii.botania.common.lib; public final class LibBlockNames { - public static final String FLOWER = "flower"; - public static final String ALTAR = "altar"; - public static final String SPECIAL_FLOWER = "specialFlower"; - public static final String LIVING_ROCK = "livingrock"; - public static final String LIVING_WOOD = "livingwood"; - public static final String SPREADER = "spreader"; - public static final String POOL = "pool"; - public static final String RUNE_ALTAR = "runeAltar"; - public static final String UNSTABLE_BLOCK = "unstableBlock"; - public static final String PYLON = "pylon"; - public static final String PISTON_RELAY = "pistonRelay"; - public static final String DISTRIBUTOR = "distributor"; - public static final String MANA_BEACON = "manaBeacon"; - public static final String MANA_VOID = "manaVoid"; - public static final String MANA_DETECTOR = "manaDetector"; - public static final String ENCHANTER = "enchanter"; - public static final String TURNTABLE = "turntable"; - public static final String TINY_PLANET = "tinyPlanetBlock"; - public static final String ALCHEMY_CATALYST = "alchemyCatalyst"; - public static final String OPEN_CRATE = "openCrate"; - public static final String CRAFT_CRATE = "craftCrate"; - public static final String FOREST_EYE = "forestEye"; - public static final String STORAGE = "storage"; - public static final String FOREST_DRUM = "forestDrum"; - public static final String SHINY_FLOWER = "shinyFlower"; - public static final String PLATFORM = "platform"; - public static final String ALF_PORTAL = "alfheimPortal"; - public static final String DREAM_WOOD = "dreamwood"; - public static final String CONJURATION_CATALYST = "conjurationCatalyst"; - public static final String BIFROST = "bifrost"; - public static final String SOLID_VINE = "solidVine"; - public static final String BURIED_PETALS = "buriedPetals"; - public static final String PRISMARINE = "prismarine"; - public static final String SEA_LAMP = "seaLamp"; - public static final String MINI_ISLAND = "miniIsland"; - public static final String TINY_POTATO = "tinyPotato"; - public static final String SPAWNER_CLAW = "spawnerClaw"; - public static final String REED_BLOCK = "reedBlock"; - public static final String THATCH = "thatch"; - public static final String CUSTOM_BRICK = "customBrick"; - public static final String ENDER_EYE_BLOCK = "enderEyeBlock"; - public static final String STARFIELD = "starfield"; - public static final String RF_GENERATOR = "rfGenerator"; - public static final String ELF_GLASS = "elfGlass"; - public static final String BREWERY = "brewery"; - public static final String MANA_GLASS = "manaGlass"; - public static final String TERRA_PLATE = "terraPlate"; - public static final String RED_STRING_CONTAINER = "redStringContainer"; - public static final String RED_STRING_DISPENSER = "redStringDispenser"; - public static final String RED_STRING_FERTILIZER = "redStringFertilizer"; - public static final String RED_STRING_COMPARATOR = "redStringComparator"; - public static final String RED_STRING_RELAY = "redStringRelay"; - public static final String RED_STRING_INTERCEPTOR = "redStringInterceptor"; - public static final String FLOATING_SPECIAL_FLOWER = "floatingSpecialFlower"; - public static final String MANA_FLAME = "manaFlame"; - public static final String PRISM = "prism"; - public static final String DIRT_PATH = "dirtPath"; - public static final String ENCHANTED_SOIL = "enchantedSoil"; - public static final String BIOME_STONE_A = "biomeStoneA"; - public static final String BIOME_STONE_B = "biomeStoneB"; - public static final String PETAL_BLOCK = "petalBlock"; - public static final String CORPOREA_INDEX = "corporeaIndex"; - public static final String CORPOREA_FUNNEL = "corporeaFunnel"; - public static final String END_STONE_BRICK = "endStoneBrick"; - public static final String MUSHROOM = "mushroom"; - public static final String PUMP = "pump"; - public static final String DOUBLE_FLOWER = "doubleFlower"; - public static final String STONE = "stone"; - public static final String FAKE_AIR = "fakeAir"; - public static final String BLAZE_BLOCK = "blazeBlock"; - public static final String CORPOREA_INTERCEPTOR = "corporeaInterceptor"; - public static final String CORPOREA_CRYSTAL_CUBE = "corporeaCrystalCube"; - public static final String INCENSE_PLATE = "incensePlate"; - public static final String HOURGLASS = "hourglass"; - public static final String GHOST_RAIL = "ghostRail"; - public static final String SPARK_CHANGER = "sparkChanger"; - public static final String ROOT = "root"; - public static final String FEL_PUMPKIN = "felPumpkin"; - public static final String COCOON = "cocoon"; - public static final String LIGHT_RELAY = "lightRelay"; - public static final String LIGHT_LAUNCHER = "lightLauncher"; - public static final String MANA_BOMB = "manaBomb"; - public static final String CACOPHONIUM = "cacophoniumBlock"; - public static final String BELLOWS = "bellows"; - public static final String BIFROST_PERM = "bifrostPerm"; - public static final String PAVEMENT = "pavement"; - public static final String CELL_BLOCK = "cellBlock"; - public static final String GAIA_HEAD = "gaiaHeadBlock"; - public static final String CORPOREA_RETAINER = "corporeaRetainer"; - public static final String TERU_TERU_BOZU = "teruTeruBozu"; - public static final String SHIMMERROCK = "shimmerrock"; - public static final String SHIMMERWOOD_PLANKS = "shimmerwoodPlanks"; - public static final String AVATAR = "avatar"; - public static final String ALT_GRASS = "altGrass"; + public static final String FLOWER = "flower"; + public static final String ALTAR = "altar"; + public static final String SPECIAL_FLOWER = "specialFlower"; + public static final String LIVING_ROCK = "livingrock"; + public static final String LIVING_WOOD = "livingwood"; + public static final String SPREADER = "spreader"; + public static final String POOL = "pool"; + public static final String RUNE_ALTAR = "runeAltar"; + public static final String UNSTABLE_BLOCK = "unstableBlock"; + public static final String PYLON = "pylon"; + public static final String PISTON_RELAY = "pistonRelay"; + public static final String DISTRIBUTOR = "distributor"; + public static final String MANA_BEACON = "manaBeacon"; + public static final String MANA_VOID = "manaVoid"; + public static final String MANA_DETECTOR = "manaDetector"; + public static final String ENCHANTER = "enchanter"; + public static final String TURNTABLE = "turntable"; + public static final String TINY_PLANET = "tinyPlanetBlock"; + public static final String ALCHEMY_CATALYST = "alchemyCatalyst"; + public static final String OPEN_CRATE = "openCrate"; + public static final String CRAFT_CRATE = "craftCrate"; + public static final String FOREST_EYE = "forestEye"; + public static final String STORAGE = "storage"; + public static final String FOREST_DRUM = "forestDrum"; + public static final String SHINY_FLOWER = "shinyFlower"; + public static final String PLATFORM = "platform"; + public static final String ALF_PORTAL = "alfheimPortal"; + public static final String DREAM_WOOD = "dreamwood"; + public static final String CONJURATION_CATALYST = "conjurationCatalyst"; + public static final String BIFROST = "bifrost"; + public static final String SOLID_VINE = "solidVine"; + public static final String BURIED_PETALS = "buriedPetals"; + public static final String PRISMARINE = "prismarine"; + public static final String SEA_LAMP = "seaLamp"; + public static final String MINI_ISLAND = "miniIsland"; + public static final String TINY_POTATO = "tinyPotato"; + public static final String SPAWNER_CLAW = "spawnerClaw"; + public static final String REED_BLOCK = "reedBlock"; + public static final String THATCH = "thatch"; + public static final String CUSTOM_BRICK = "customBrick"; + public static final String ENDER_EYE_BLOCK = "enderEyeBlock"; + public static final String STARFIELD = "starfield"; + public static final String RF_GENERATOR = "rfGenerator"; + public static final String ELF_GLASS = "elfGlass"; + public static final String BREWERY = "brewery"; + public static final String MANA_GLASS = "manaGlass"; + public static final String TERRA_PLATE = "terraPlate"; + public static final String RED_STRING_CONTAINER = "redStringContainer"; + public static final String RED_STRING_DISPENSER = "redStringDispenser"; + public static final String RED_STRING_FERTILIZER = "redStringFertilizer"; + public static final String RED_STRING_COMPARATOR = "redStringComparator"; + public static final String RED_STRING_RELAY = "redStringRelay"; + public static final String RED_STRING_INTERCEPTOR = "redStringInterceptor"; + public static final String FLOATING_SPECIAL_FLOWER = "floatingSpecialFlower"; + public static final String MANA_FLAME = "manaFlame"; + public static final String PRISM = "prism"; + public static final String DIRT_PATH = "dirtPath"; + public static final String ENCHANTED_SOIL = "enchantedSoil"; + public static final String BIOME_STONE_A = "biomeStoneA"; + public static final String BIOME_STONE_B = "biomeStoneB"; + public static final String PETAL_BLOCK = "petalBlock"; + public static final String CORPOREA_INDEX = "corporeaIndex"; + public static final String CORPOREA_FUNNEL = "corporeaFunnel"; + public static final String END_STONE_BRICK = "endStoneBrick"; + public static final String MUSHROOM = "mushroom"; + public static final String PUMP = "pump"; + public static final String DOUBLE_FLOWER = "doubleFlower"; + public static final String STONE = "stone"; + public static final String FAKE_AIR = "fakeAir"; + public static final String BLAZE_BLOCK = "blazeBlock"; + public static final String CORPOREA_INTERCEPTOR = "corporeaInterceptor"; + public static final String CORPOREA_CRYSTAL_CUBE = "corporeaCrystalCube"; + public static final String INCENSE_PLATE = "incensePlate"; + public static final String HOURGLASS = "hourglass"; + public static final String GHOST_RAIL = "ghostRail"; + public static final String SPARK_CHANGER = "sparkChanger"; + public static final String ROOT = "root"; + public static final String FEL_PUMPKIN = "felPumpkin"; + public static final String COCOON = "cocoon"; + public static final String LIGHT_RELAY = "lightRelay"; + public static final String LIGHT_LAUNCHER = "lightLauncher"; + public static final String MANA_BOMB = "manaBomb"; + public static final String CACOPHONIUM = "cacophoniumBlock"; + public static final String BELLOWS = "bellows"; + public static final String BIFROST_PERM = "bifrostPerm"; + public static final String PAVEMENT = "pavement"; + public static final String CELL_BLOCK = "cellBlock"; + public static final String GAIA_HEAD = "gaiaHeadBlock"; + public static final String CORPOREA_RETAINER = "corporeaRetainer"; + public static final String TERU_TERU_BOZU = "teruTeruBozu"; + public static final String SHIMMERROCK = "shimmerrock"; + public static final String SHIMMERWOOD_PLANKS = "shimmerwoodPlanks"; + public static final String AVATAR = "avatar"; + public static final String ALT_GRASS = "altGrass"; - public static final String SUBTILE_PUREDAISY = "puredaisy"; - public static final String SUBTILE_MANASTAR = "manastar"; + public static final String SUBTILE_PUREDAISY = "puredaisy"; + public static final String SUBTILE_MANASTAR = "manastar"; - public static final String SUBTILE_DAYBLOOM = "daybloom"; - public static final String SUBTILE_DAYBLOOM_PRIME = "daybloomPrime"; - public static final String SUBTILE_ENDOFLAME = "endoflame"; - public static final String SUBTILE_HYDROANGEAS = "hydroangeas"; - public static final String SUBTILE_THERMALILY = "thermalily"; - public static final String SUBTILE_NIGHTSHADE = "nightshade"; - public static final String SUBTILE_NIGHTSHADE_PRIME = "nightshadePrime"; - public static final String SUBTILE_ARCANE_ROSE = "arcanerose"; - public static final String SUBTILE_MUNCHDEW = "munchdew"; - public static final String SUBTILE_ENTROPINNYUM = "entropinnyum"; - public static final String SUBTILE_KEKIMURUS = "kekimurus"; - public static final String SUBTILE_GOURMARYLLIS = "gourmaryllis"; - public static final String SUBTILE_NARSLIMMUS = "narslimmus"; - public static final String SUBTILE_SPECTROLUS = "spectrolus"; - public static final String SUBTILE_DANDELIFEON = "dandelifeon"; - public static final String SUBTILE_RAFFLOWSIA = "rafflowsia"; + public static final String SUBTILE_DAYBLOOM = "daybloom"; + public static final String SUBTILE_DAYBLOOM_PRIME = "daybloomPrime"; + public static final String SUBTILE_ENDOFLAME = "endoflame"; + public static final String SUBTILE_HYDROANGEAS = "hydroangeas"; + public static final String SUBTILE_THERMALILY = "thermalily"; + public static final String SUBTILE_NIGHTSHADE = "nightshade"; + public static final String SUBTILE_NIGHTSHADE_PRIME = "nightshadePrime"; + public static final String SUBTILE_ARCANE_ROSE = "arcanerose"; + public static final String SUBTILE_MUNCHDEW = "munchdew"; + public static final String SUBTILE_ENTROPINNYUM = "entropinnyum"; + public static final String SUBTILE_KEKIMURUS = "kekimurus"; + public static final String SUBTILE_GOURMARYLLIS = "gourmaryllis"; + public static final String SUBTILE_NARSLIMMUS = "narslimmus"; + public static final String SUBTILE_SPECTROLUS = "spectrolus"; + public static final String SUBTILE_DANDELIFEON = "dandelifeon"; + public static final String SUBTILE_RAFFLOWSIA = "rafflowsia"; - public static final String SUBTILE_BELLETHORN = "bellethorn"; - public static final String SUBTILE_DREADTHORN = "dreadthorn"; - public static final String SUBTILE_HEISEI_DREAM = "heiseiDream"; - public static final String SUBTILE_TIGERSEYE = "tigerseye"; - public static final String SUBTILE_JADED_AMARANTHUS = "jadedAmaranthus"; - public static final String SUBTILE_ORECHID = "orechid"; - public static final String SUBTILE_FALLEN_KANADE = "fallenKanade"; - public static final String SUBTILE_EXOFLAME = "exoflame"; - public static final String SUBTILE_AGRICARNATION = "agricarnation"; - public static final String SUBTILE_HOPPERHOCK = "hopperhock"; - public static final String SUBTILE_TANGLEBERRIE = "tangleberrie"; - public static final String SUBTILE_JIYUULIA = "jiyuulia"; - public static final String SUBTILE_RANNUNCARPUS = "rannuncarpus"; - public static final String SUBTILE_HYACIDUS = "hyacidus"; - public static final String SUBTILE_POLLIDISIAC = "pollidisiac"; - public static final String SUBTILE_CLAYCONIA = "clayconia"; - public static final String SUBTILE_LOONIUM = "loonium"; - public static final String SUBTILE_DAFFOMILL = "daffomill"; - public static final String SUBTILE_VINCULOTUS = "vinculotus"; - public static final String SUBTILE_SPECTRANTHEMUM = "spectranthemum"; - public static final String SUBTILE_MEDUMONE = "medumone"; - public static final String SUBTILE_MARIMORPHOSIS = "marimorphosis"; - public static final String SUBTILE_BUBBELL = "bubbell"; - public static final String SUBTILE_SOLEGNOLIA = "solegnolia"; - public static final String SUBTILE_ORECHID_IGNEM = "orechidIgnem"; - - public static final String QUARTZ_DARK = "Dark"; - public static final String QUARTZ_MANA = "Mana"; - public static final String QUARTZ_BLAZE = "Blaze"; - public static final String QUARTZ_LAVENDER = "Lavender"; - public static final String QUARTZ_RED = "Red"; - public static final String QUARTZ_ELF = "Elf"; - public static final String QUARTZ_SUNNY = "Sunny"; + public static final String SUBTILE_BELLETHORN = "bellethorn"; + public static final String SUBTILE_DREADTHORN = "dreadthorn"; + public static final String SUBTILE_HEISEI_DREAM = "heiseiDream"; + public static final String SUBTILE_TIGERSEYE = "tigerseye"; + public static final String SUBTILE_JADED_AMARANTHUS = "jadedAmaranthus"; + public static final String SUBTILE_ORECHID = "orechid"; + public static final String SUBTILE_FALLEN_KANADE = "fallenKanade"; + public static final String SUBTILE_EXOFLAME = "exoflame"; + public static final String SUBTILE_AGRICARNATION = "agricarnation"; + public static final String SUBTILE_HOPPERHOCK = "hopperhock"; + public static final String SUBTILE_TANGLEBERRIE = "tangleberrie"; + public static final String SUBTILE_JIYUULIA = "jiyuulia"; + public static final String SUBTILE_RANNUNCARPUS = "rannuncarpus"; + public static final String SUBTILE_HYACIDUS = "hyacidus"; + public static final String SUBTILE_POLLIDISIAC = "pollidisiac"; + public static final String SUBTILE_CLAYCONIA = "clayconia"; + public static final String SUBTILE_LOONIUM = "loonium"; + public static final String SUBTILE_DAFFOMILL = "daffomill"; + public static final String SUBTILE_VINCULOTUS = "vinculotus"; + public static final String SUBTILE_SPECTRANTHEMUM = "spectranthemum"; + public static final String SUBTILE_MEDUMONE = "medumone"; + public static final String SUBTILE_MARIMORPHOSIS = "marimorphosis"; + public static final String SUBTILE_BUBBELL = "bubbell"; + public static final String SUBTILE_SOLEGNOLIA = "solegnolia"; + public static final String SUBTILE_ORECHID_IGNEM = "orechidIgnem"; + public static final String QUARTZ_DARK = "Dark"; + public static final String QUARTZ_MANA = "Mana"; + public static final String QUARTZ_BLAZE = "Blaze"; + public static final String QUARTZ_LAVENDER = "Lavender"; + public static final String QUARTZ_RED = "Red"; + public static final String QUARTZ_ELF = "Elf"; + public static final String QUARTZ_SUNNY = "Sunny"; } diff --git a/src/main/java/vazkii/botania/common/lib/LibBrewNames.java b/src/main/java/vazkii/botania/common/lib/LibBrewNames.java index e4219171bc..d3af45ca03 100644 --- a/src/main/java/vazkii/botania/common/lib/LibBrewNames.java +++ b/src/main/java/vazkii/botania/common/lib/LibBrewNames.java @@ -2,38 +2,37 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Nov 1, 2014, 7:03:57 PM (GMT)] */ package vazkii.botania.common.lib; public final class LibBrewNames { - public static final String SPEED = "speed"; - public static final String STRENGTH = "strength"; - public static final String HASTE = "haste"; - public static final String HEALING = "healing"; - public static final String JUMP_BOOST = "jumpBoost"; - public static final String REGEN = "regen"; - public static final String REGEN_WEAK = "regenWeak"; - public static final String RESISTANCE = "resistance"; - public static final String FIRE_RESISTANCE = "fireResistance"; - public static final String WATER_BREATHING = "waterBreathing"; - public static final String INVISIBILITY = "invisibility"; - public static final String NIGHT_VISION = "nightVision"; - public static final String ABSORPTION = "absorption"; + public static final String SPEED = "speed"; + public static final String STRENGTH = "strength"; + public static final String HASTE = "haste"; + public static final String HEALING = "healing"; + public static final String JUMP_BOOST = "jumpBoost"; + public static final String REGEN = "regen"; + public static final String REGEN_WEAK = "regenWeak"; + public static final String RESISTANCE = "resistance"; + public static final String FIRE_RESISTANCE = "fireResistance"; + public static final String WATER_BREATHING = "waterBreathing"; + public static final String INVISIBILITY = "invisibility"; + public static final String NIGHT_VISION = "nightVision"; + public static final String ABSORPTION = "absorption"; - public static final String SOUL_CROSS = "soulCross"; - public static final String FEATHER_FEET = "featherFeet"; - public static final String EMPTINESS = "emptiness"; - public static final String BLOODTHIRST = "bloodthirst"; - public static final String OVERLOAD = "overload"; - public static final String ALLURE = "allure"; - public static final String CLEAR = "clear"; - - public static final String WARP_WARD = "warpWard"; + public static final String SOUL_CROSS = "soulCross"; + public static final String FEATHER_FEET = "featherFeet"; + public static final String EMPTINESS = "emptiness"; + public static final String BLOODTHIRST = "bloodthirst"; + public static final String OVERLOAD = "overload"; + public static final String ALLURE = "allure"; + public static final String CLEAR = "clear"; + public static final String WARP_WARD = "warpWard"; } diff --git a/src/main/java/vazkii/botania/common/lib/LibEntityNames.java b/src/main/java/vazkii/botania/common/lib/LibEntityNames.java index e36c7aa78d..6d6ed2d716 100644 --- a/src/main/java/vazkii/botania/common/lib/LibEntityNames.java +++ b/src/main/java/vazkii/botania/common/lib/LibEntityNames.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jan 26, 2014, 5:30:03 PM (GMT)] */ package vazkii.botania.common.lib; @@ -14,24 +14,23 @@ public final class LibEntityNames { - public static final String MANA_BURST = LibResources.PREFIX_MOD + "manaBurst"; - public static final String SIGNAL_FLARE = LibResources.PREFIX_MOD + "signalFlare"; - public static final String PIXIE = LibResources.PREFIX_MOD + "pixie"; - public static final String FLAME_RING = LibResources.PREFIX_MOD + "flameRing"; - public static final String VINE_BALL = LibResources.PREFIX_MOD + "vineBall"; - public static final String DOPPLEGANGER = LibResources.PREFIX_MOD + "doppleganger"; - public static final String MAGIC_LANDMINE = LibResources.PREFIX_MOD + "magicLandmine"; - public static final String SPARK = LibResources.PREFIX_MOD + "spark"; - public static final String THROWN_ITEM = LibResources.PREFIX_MOD + "thrownItem"; - public static final String MAGIC_MISSILE = LibResources.PREFIX_MOD + "magicMissile"; - public static final String THORN_CHAKRAM = LibResources.PREFIX_MOD + "thornChakram"; - public static final String CORPOREA_SPARK = LibResources.PREFIX_MOD + "corporeaSpark"; - public static final String ENDER_AIR_BOTTLE = LibResources.PREFIX_MOD + "enderAirBottle"; - public static final String POOL_MINECART = LibResources.PREFIX_MOD + "poolMinecart"; - public static final String PINK_WITHER = LibResources.PREFIX_MOD + "pinkWither"; - public static final String PLAYER_MOVER = LibResources.PREFIX_MOD + "playerMover"; - public static final String MANA_STORM = LibResources.PREFIX_MOD + "manaStorm"; - public static final String BABYLON_WEAPON = LibResources.PREFIX_MOD + "babylonWeapon"; - public static final String FALLING_STAR = LibResources.PREFIX_MOD + "fallingStar"; - + public static final String MANA_BURST = LibResources.PREFIX_MOD + "manaBurst"; + public static final String SIGNAL_FLARE = LibResources.PREFIX_MOD + "signalFlare"; + public static final String PIXIE = LibResources.PREFIX_MOD + "pixie"; + public static final String FLAME_RING = LibResources.PREFIX_MOD + "flameRing"; + public static final String VINE_BALL = LibResources.PREFIX_MOD + "vineBall"; + public static final String DOPPLEGANGER = LibResources.PREFIX_MOD + "doppleganger"; + public static final String MAGIC_LANDMINE = LibResources.PREFIX_MOD + "magicLandmine"; + public static final String SPARK = LibResources.PREFIX_MOD + "spark"; + public static final String THROWN_ITEM = LibResources.PREFIX_MOD + "thrownItem"; + public static final String MAGIC_MISSILE = LibResources.PREFIX_MOD + "magicMissile"; + public static final String THORN_CHAKRAM = LibResources.PREFIX_MOD + "thornChakram"; + public static final String CORPOREA_SPARK = LibResources.PREFIX_MOD + "corporeaSpark"; + public static final String ENDER_AIR_BOTTLE = LibResources.PREFIX_MOD + "enderAirBottle"; + public static final String POOL_MINECART = LibResources.PREFIX_MOD + "poolMinecart"; + public static final String PINK_WITHER = LibResources.PREFIX_MOD + "pinkWither"; + public static final String PLAYER_MOVER = LibResources.PREFIX_MOD + "playerMover"; + public static final String MANA_STORM = LibResources.PREFIX_MOD + "manaStorm"; + public static final String BABYLON_WEAPON = LibResources.PREFIX_MOD + "babylonWeapon"; + public static final String FALLING_STAR = LibResources.PREFIX_MOD + "fallingStar"; } diff --git a/src/main/java/vazkii/botania/common/lib/LibGuiIDs.java b/src/main/java/vazkii/botania/common/lib/LibGuiIDs.java index fefcb749a0..b6265b99f5 100644 --- a/src/main/java/vazkii/botania/common/lib/LibGuiIDs.java +++ b/src/main/java/vazkii/botania/common/lib/LibGuiIDs.java @@ -2,19 +2,18 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jan 14, 2014, 6:50:36 PM (GMT)] */ package vazkii.botania.common.lib; public final class LibGuiIDs { - public static final int LEXICON = 0; - public static final int CRAFTING_HALO = 1; - public static final int FLOWER_BAG = 2; - public static final int BAUBLE_BOX = 3; - + public static final int LEXICON = 0; + public static final int CRAFTING_HALO = 1; + public static final int FLOWER_BAG = 2; + public static final int BAUBLE_BOX = 3; } diff --git a/src/main/java/vazkii/botania/common/lib/LibItemNames.java b/src/main/java/vazkii/botania/common/lib/LibItemNames.java index 98f2643f7e..934b974f69 100644 --- a/src/main/java/vazkii/botania/common/lib/LibItemNames.java +++ b/src/main/java/vazkii/botania/common/lib/LibItemNames.java @@ -2,215 +2,215 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jan 14, 2014, 5:49:06 PM (GMT)] */ package vazkii.botania.common.lib; public final class LibItemNames { - public static final String LEXICON = "lexicon"; - public static final String PETAL = "petal"; - public static final String DYE = "dye"; - public static final String PESTLE_AND_MORTAR = "pestleAndMortar"; - public static final String TWIG_WAND = "twigWand"; - public static final String MANA_RESOURCE = "manaResource"; - public static final String LENS = "lens"; - public static final String MANA_PETAL = "manaPetal"; - public static final String RUNE = "rune"; - public static final String SIGNAL_FLARE = "signalFlare"; - public static final String MANA_TABLET = "manaTablet"; - public static final String MANA_GUN = "manaGun"; - public static final String MANA_COOKIE = "manaCookie"; - public static final String FERTILIZER = "fertilizer"; - public static final String GRASS_SEEDS = "grassSeeds"; - public static final String DIRT_ROD = "dirtRod"; - public static final String TERRAFORM_ROD = "terraformRod"; - public static final String MANA_MIRROR = "manaMirror"; - public static final String MANASTEEL_HELM = "manasteelHelm"; - public static final String MANASTEEL_CHEST = "manasteelChest"; - public static final String MANASTEEL_LEGS = "manasteelLegs"; - public static final String MANASTEEL_BOOTS = "manasteelBoots"; - public static final String MANASTEEL_PICK = "manasteelPick"; - public static final String MANASTEEL_SHOVEL = "manasteelShovel"; - public static final String MANASTEEL_AXE = "manasteelAxe"; - public static final String MANASTEEL_SWORD = "manasteelSword"; - public static final String MANASTEEL_SHEARS = "manasteelShears"; - public static final String GRASS_HORN = "grassHorn"; - public static final String TERRASTEEL_HELM = "terrasteelHelm"; - public static final String TERRASTEEL_CHEST = "terrasteelChest"; - public static final String TERRASTEEL_LEGS = "terrasteelLegs"; - public static final String TERRASTEEL_BOOTS = "terrasteelBoots"; - public static final String TERRA_SWORD = "terraSword"; - public static final String TINY_PLANET = "tinyPlanet"; - public static final String MANA_RING = "manaRing"; - public static final String AURA_RING = "auraRing"; - public static final String MANA_RING_GREATER = "manaRingGreater"; - public static final String AURA_RING_GREATER = "auraRingGreater"; - public static final String TRAVEL_BELT = "travelBelt"; - public static final String KNOCKBACK_BELT = "knockbackBelt"; - public static final String ICE_PENDANT = "icePendant"; - public static final String LAVA_PENDANT = "lavaPendant"; - public static final String GOLDEN_LAUREL = "goldenLaurel"; - public static final String MAGNET_RING = "magnetRing"; - public static final String WATER_RING = "waterRing"; - public static final String MINING_RING = "miningRing"; - public static final String TERRA_PICK = "terraPick"; - public static final String DIVA_CHARM = "divaCharm"; - public static final String FLIGHT_TIARA = "flightTiara"; - public static final String ENDER_DAGGER = "enderDagger"; - public static final String QUARTZ = "quartz"; - public static final String WATER_ROD = "waterRod"; - public static final String ELEMENTIUM_HELM = "elementiumHelm"; - public static final String ELEMENTIUM_CHEST = "elementiumChest"; - public static final String ELEMENTIUM_LEGS = "elementiumLegs"; - public static final String ELEMENTIUM_BOOTS = "elementiumBoots"; - public static final String ELEMENTIUM_PICK = "elementiumPick"; - public static final String ELEMENTIUM_SHOVEL = "elementiumShovel"; - public static final String ELEMENTIUM_AXE = "elementiumAxe"; - public static final String ELEMENTIUM_SWORD = "elementiumSword"; - public static final String ELEMENTIUM_SHEARS = "elementiumShears"; - public static final String OPEN_BUCKET = "openBucket"; - public static final String SPAWNER_MOVER = "spawnerMover"; - public static final String PIXIE_RING = "pixieRing"; - public static final String SUPER_TRAVEL_BELT = "superTravelBelt"; - public static final String RAINBOW_ROD = "rainbowRod"; - public static final String TORNADO_ROD = "tornadoRod"; - public static final String FIRE_ROD = "fireRod"; - public static final String VINE_BALL = "vineBall"; - public static final String SLINGSHOT = "slingshot"; - public static final String MANA_BOTTLE = "manaBottle"; - public static final String LAPUTA_SHARD = "laputaShard"; - public static final String VIRUS = "virus"; - public static final String REACH_RING = "reachRing"; - public static final String SKY_DIRT_ROD = "skyDirtRod"; - public static final String MANASTEEL_HELM_R = "manasteelHelmReveal"; - public static final String TERRASTEEL_HELM_R = "terrasteelHelmReveal"; - public static final String ELEMENTIUM_HELM_R = "elementiumHelmReveal"; - public static final String ITEM_FINDER = "itemFinder"; - public static final String SUPER_LAVA_PENDANT = "superLavaPendant"; - public static final String ENDER_HAND = "enderHand"; - public static final String GLASS_PICK = "glassPick"; - public static final String SPARK = "spark"; - public static final String SPARK_UPGRADE = "sparkUpgrade"; - public static final String DIVINING_ROD = "diviningRod"; - public static final String GRAVITY_ROD = "gravityRod"; - public static final String REGEN_IVY = "regenIvy"; - public static final String MANA_INKWELL = "manaInkwell"; - public static final String VIAL = "vial"; - public static final String FLASK = "flask"; - public static final String BREW_VIAL = "brewVial"; - public static final String BREW_FLASK = "brewFlask"; - public static final String BLOOD_PENDANT = "bloodPendant"; - public static final String MISSILE_ROD = "missileRod"; - public static final String HOLY_CLOAK = "holyCloak"; - public static final String UNHOLY_CLOAK = "unholyCloak"; - public static final String CRAFTING_HALO = "craftingHalo"; - public static final String BLACK_LOTUS = "blackLotus"; - public static final String MONOCLE = "monocle"; - public static final String CLIP = "clip"; - public static final String COBBLE_ROD = "cobbleRod"; - public static final String SMELT_ROD = "smeltRod"; - public static final String WORLD_SEED = "worldSeed"; - public static final String SPELL_CLOTH = "spellCloth"; - public static final String THORN_CHAKRAM = "thornChakram"; - public static final String OVERGROWTH_SEED = "overgrowthSeed"; - public static final String CRAFT_PATTERN = "craftPattern"; - public static final String ANCIENT_WILL = "ancientWill"; - public static final String CORPOREA_SPARK = "corporeaSpark"; - public static final String LIVINGWOOD_BOW = "livingwoodBow"; - public static final String CRYSTAL_BOW = "crystalBow"; - public static final String COSMETIC = "cosmetic"; - public static final String SWAP_RING = "swapRing"; - public static final String FLOWER_BAG = "flowerBag"; - public static final String PHANTOM_INK = "phantomInk"; - public static final String POOL_MINECART = "poolMinecart"; - public static final String PINKINATOR = "pinkinator"; - public static final String INFINITE_FRUIT = "infiniteFruit"; - public static final String KING_KEY = "kingKey"; - public static final String FLUGEL_EYE = "flugelEye"; - public static final String THOR_RING = "thorRing"; - public static final String ODIN_RING = "odinRing"; - public static final String LOKI_RING = "lokiRing"; - public static final String AESIR_RING = "aesirRing"; - public static final String DICE = "dice"; - public static final String KEEP_IVY = "keepIvy"; - public static final String BLACK_HOLE_TALISMAN = "blackHoleTalisman"; - public static final String RECORD_GAIA1 = "recordGaia1"; - public static final String RECORD_GAIA2 = "recordGaia2"; - public static final String TEMPERANCE_STONE = "temperanceStone"; - public static final String INCENSE_STICK = "incenseStick"; - public static final String TERRA_AXE = "terraAxe"; - public static final String WATER_BOWL = "waterBowl"; - public static final String OBEDIENCE_STICK = "obedienceStick"; - public static final String CACOPHONIUM = "cacophonium"; - public static final String SLIME_BOTTLE = "slimeBottle"; - public static final String STAR_SWORD = "starSword"; - public static final String EXCHANGE_ROD = "exchangeRod"; - public static final String MAGNET_RING_GREATER = "magnetRingGreater"; - public static final String THUNDER_SWORD = "thunderSword"; - public static final String MANAWEAVE_HELM = "manaweaveHelm"; - public static final String MANAWEAVE_CHEST = "manaweaveChest"; - public static final String MANAWEAVE_LEGS = "manaweaveLegs"; - public static final String MANAWEAVE_BOOTS = "manaweaveBoots"; - public static final String AUTOCRAFTING_HALO = "autocraftingHalo"; - public static final String GAIA_HEAD = "gaiaHead"; - public static final String SEXTANT = "sextant"; - public static final String SPEED_UP_BELT = "speedUpBelt"; - public static final String BAUBLE_BOX = "baubleBox"; + public static final String LEXICON = "lexicon"; + public static final String PETAL = "petal"; + public static final String DYE = "dye"; + public static final String PESTLE_AND_MORTAR = "pestleAndMortar"; + public static final String TWIG_WAND = "twigWand"; + public static final String MANA_RESOURCE = "manaResource"; + public static final String LENS = "lens"; + public static final String MANA_PETAL = "manaPetal"; + public static final String RUNE = "rune"; + public static final String SIGNAL_FLARE = "signalFlare"; + public static final String MANA_TABLET = "manaTablet"; + public static final String MANA_GUN = "manaGun"; + public static final String MANA_COOKIE = "manaCookie"; + public static final String FERTILIZER = "fertilizer"; + public static final String GRASS_SEEDS = "grassSeeds"; + public static final String DIRT_ROD = "dirtRod"; + public static final String TERRAFORM_ROD = "terraformRod"; + public static final String MANA_MIRROR = "manaMirror"; + public static final String MANASTEEL_HELM = "manasteelHelm"; + public static final String MANASTEEL_CHEST = "manasteelChest"; + public static final String MANASTEEL_LEGS = "manasteelLegs"; + public static final String MANASTEEL_BOOTS = "manasteelBoots"; + public static final String MANASTEEL_PICK = "manasteelPick"; + public static final String MANASTEEL_SHOVEL = "manasteelShovel"; + public static final String MANASTEEL_AXE = "manasteelAxe"; + public static final String MANASTEEL_SWORD = "manasteelSword"; + public static final String MANASTEEL_SHEARS = "manasteelShears"; + public static final String GRASS_HORN = "grassHorn"; + public static final String TERRASTEEL_HELM = "terrasteelHelm"; + public static final String TERRASTEEL_CHEST = "terrasteelChest"; + public static final String TERRASTEEL_LEGS = "terrasteelLegs"; + public static final String TERRASTEEL_BOOTS = "terrasteelBoots"; + public static final String TERRA_SWORD = "terraSword"; + public static final String TINY_PLANET = "tinyPlanet"; + public static final String MANA_RING = "manaRing"; + public static final String AURA_RING = "auraRing"; + public static final String MANA_RING_GREATER = "manaRingGreater"; + public static final String AURA_RING_GREATER = "auraRingGreater"; + public static final String TRAVEL_BELT = "travelBelt"; + public static final String KNOCKBACK_BELT = "knockbackBelt"; + public static final String ICE_PENDANT = "icePendant"; + public static final String LAVA_PENDANT = "lavaPendant"; + public static final String GOLDEN_LAUREL = "goldenLaurel"; + public static final String MAGNET_RING = "magnetRing"; + public static final String WATER_RING = "waterRing"; + public static final String MINING_RING = "miningRing"; + public static final String TERRA_PICK = "terraPick"; + public static final String DIVA_CHARM = "divaCharm"; + public static final String FLIGHT_TIARA = "flightTiara"; + public static final String ENDER_DAGGER = "enderDagger"; + public static final String QUARTZ = "quartz"; + public static final String WATER_ROD = "waterRod"; + public static final String ELEMENTIUM_HELM = "elementiumHelm"; + public static final String ELEMENTIUM_CHEST = "elementiumChest"; + public static final String ELEMENTIUM_LEGS = "elementiumLegs"; + public static final String ELEMENTIUM_BOOTS = "elementiumBoots"; + public static final String ELEMENTIUM_PICK = "elementiumPick"; + public static final String ELEMENTIUM_SHOVEL = "elementiumShovel"; + public static final String ELEMENTIUM_AXE = "elementiumAxe"; + public static final String ELEMENTIUM_SWORD = "elementiumSword"; + public static final String ELEMENTIUM_SHEARS = "elementiumShears"; + public static final String OPEN_BUCKET = "openBucket"; + public static final String SPAWNER_MOVER = "spawnerMover"; + public static final String PIXIE_RING = "pixieRing"; + public static final String SUPER_TRAVEL_BELT = "superTravelBelt"; + public static final String RAINBOW_ROD = "rainbowRod"; + public static final String TORNADO_ROD = "tornadoRod"; + public static final String FIRE_ROD = "fireRod"; + public static final String VINE_BALL = "vineBall"; + public static final String SLINGSHOT = "slingshot"; + public static final String MANA_BOTTLE = "manaBottle"; + public static final String LAPUTA_SHARD = "laputaShard"; + public static final String VIRUS = "virus"; + public static final String REACH_RING = "reachRing"; + public static final String SKY_DIRT_ROD = "skyDirtRod"; + public static final String MANASTEEL_HELM_R = "manasteelHelmReveal"; + public static final String TERRASTEEL_HELM_R = "terrasteelHelmReveal"; + public static final String ELEMENTIUM_HELM_R = "elementiumHelmReveal"; + public static final String ITEM_FINDER = "itemFinder"; + public static final String SUPER_LAVA_PENDANT = "superLavaPendant"; + public static final String ENDER_HAND = "enderHand"; + public static final String GLASS_PICK = "glassPick"; + public static final String SPARK = "spark"; + public static final String SPARK_UPGRADE = "sparkUpgrade"; + public static final String DIVINING_ROD = "diviningRod"; + public static final String GRAVITY_ROD = "gravityRod"; + public static final String REGEN_IVY = "regenIvy"; + public static final String MANA_INKWELL = "manaInkwell"; + public static final String VIAL = "vial"; + public static final String FLASK = "flask"; + public static final String BREW_VIAL = "brewVial"; + public static final String BREW_FLASK = "brewFlask"; + public static final String BLOOD_PENDANT = "bloodPendant"; + public static final String MISSILE_ROD = "missileRod"; + public static final String HOLY_CLOAK = "holyCloak"; + public static final String UNHOLY_CLOAK = "unholyCloak"; + public static final String CRAFTING_HALO = "craftingHalo"; + public static final String BLACK_LOTUS = "blackLotus"; + public static final String MONOCLE = "monocle"; + public static final String CLIP = "clip"; + public static final String COBBLE_ROD = "cobbleRod"; + public static final String SMELT_ROD = "smeltRod"; + public static final String WORLD_SEED = "worldSeed"; + public static final String SPELL_CLOTH = "spellCloth"; + public static final String THORN_CHAKRAM = "thornChakram"; + public static final String OVERGROWTH_SEED = "overgrowthSeed"; + public static final String CRAFT_PATTERN = "craftPattern"; + public static final String ANCIENT_WILL = "ancientWill"; + public static final String CORPOREA_SPARK = "corporeaSpark"; + public static final String LIVINGWOOD_BOW = "livingwoodBow"; + public static final String CRYSTAL_BOW = "crystalBow"; + public static final String COSMETIC = "cosmetic"; + public static final String SWAP_RING = "swapRing"; + public static final String FLOWER_BAG = "flowerBag"; + public static final String PHANTOM_INK = "phantomInk"; + public static final String POOL_MINECART = "poolMinecart"; + public static final String PINKINATOR = "pinkinator"; + public static final String INFINITE_FRUIT = "infiniteFruit"; + public static final String KING_KEY = "kingKey"; + public static final String FLUGEL_EYE = "flugelEye"; + public static final String THOR_RING = "thorRing"; + public static final String ODIN_RING = "odinRing"; + public static final String LOKI_RING = "lokiRing"; + public static final String AESIR_RING = "aesirRing"; + public static final String DICE = "dice"; + public static final String KEEP_IVY = "keepIvy"; + public static final String BLACK_HOLE_TALISMAN = "blackHoleTalisman"; + public static final String RECORD_GAIA1 = "recordGaia1"; + public static final String RECORD_GAIA2 = "recordGaia2"; + public static final String TEMPERANCE_STONE = "temperanceStone"; + public static final String INCENSE_STICK = "incenseStick"; + public static final String TERRA_AXE = "terraAxe"; + public static final String WATER_BOWL = "waterBowl"; + public static final String OBEDIENCE_STICK = "obedienceStick"; + public static final String CACOPHONIUM = "cacophonium"; + public static final String SLIME_BOTTLE = "slimeBottle"; + public static final String STAR_SWORD = "starSword"; + public static final String EXCHANGE_ROD = "exchangeRod"; + public static final String MAGNET_RING_GREATER = "magnetRingGreater"; + public static final String THUNDER_SWORD = "thunderSword"; + public static final String MANAWEAVE_HELM = "manaweaveHelm"; + public static final String MANAWEAVE_CHEST = "manaweaveChest"; + public static final String MANAWEAVE_LEGS = "manaweaveLegs"; + public static final String MANAWEAVE_BOOTS = "manaweaveBoots"; + public static final String AUTOCRAFTING_HALO = "autocraftingHalo"; + public static final String GAIA_HEAD = "gaiaHead"; + public static final String SEXTANT = "sextant"; + public static final String SPEED_UP_BELT = "speedUpBelt"; + public static final String BAUBLE_BOX = "baubleBox"; - public static final String[] LENS_NAMES = new String[] { - "lensNormal", - "lensSpeed", - "lensPower", - "lensTime", - "lensEfficiency", - "lensBounce", - "lensGravity", - "lensMine", - "lensDamage", - "lensPhantom", - "lensMagnet", - "lensExplosive", - "lensInfluence", - "lensWeight", - "lensPaint", - "lensFire", - "lensPiston", - "lensLight", - "lensWarp", - "lensRedirect", - "lensFirework", - "lensFlare" - }; + public static final String[] LENS_NAMES = new String[] { + "lensNormal", + "lensSpeed", + "lensPower", + "lensTime", + "lensEfficiency", + "lensBounce", + "lensGravity", + "lensMine", + "lensDamage", + "lensPhantom", + "lensMagnet", + "lensExplosive", + "lensInfluence", + "lensWeight", + "lensPaint", + "lensFire", + "lensPiston", + "lensLight", + "lensWarp", + "lensRedirect", + "lensFirework", + "lensFlare" + }; - public static final String[] MANA_RESOURCE_NAMES = new String[] { - "manasteel", - "manaPearl", - "manaDiamond", - "livingwoodTwig", - "terrasteel", - "lifeEssence", - "redstoneRoot", - "elementium", - "pixieDust", - "dragonstone", - "prismarineShard", - "placeholder", - "redString", - "dreamwoodTwig", - "gaiaIngot", - "enderAirBottle", - "manaString", - "manasteelNugget", - "terrasteelNugget", - "elementiumNugget", - "root", - "pebble", - "manaweaveCloth", - "manaPowder" - }; + public static final String[] MANA_RESOURCE_NAMES = new String[] { + "manasteel", + "manaPearl", + "manaDiamond", + "livingwoodTwig", + "terrasteel", + "lifeEssence", + "redstoneRoot", + "elementium", + "pixieDust", + "dragonstone", + "prismarineShard", + "placeholder", + "redString", + "dreamwoodTwig", + "gaiaIngot", + "enderAirBottle", + "manaString", + "manasteelNugget", + "terrasteelNugget", + "elementiumNugget", + "root", + "pebble", + "manaweaveCloth", + "manaPowder" + }; } diff --git a/src/main/java/vazkii/botania/common/lib/LibLexicon.java b/src/main/java/vazkii/botania/common/lib/LibLexicon.java index 8b6013961a..54353f5d5e 100644 --- a/src/main/java/vazkii/botania/common/lib/LibLexicon.java +++ b/src/main/java/vazkii/botania/common/lib/LibLexicon.java @@ -2,268 +2,266 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jan 14, 2014, 9:14:08 PM (GMT)] */ package vazkii.botania.common.lib; public final class LibLexicon { - public static final String CATEGORY_PREFIX = "botania.category."; + public static final String CATEGORY_PREFIX = "botania.category."; - public static final String CATEGORY_BASICS = "basics"; - public static final String CATEGORY_MANA = "mana"; - public static final String CATEGORY_FUNCTIONAL_FLOWERS = "functionalFlowers"; - public static final String CATEGORY_GENERATION_FLOWERS = "generationFlowers"; - public static final String CATEGORY_DEVICES = "devices"; - public static final String CATEGORY_TOOLS = "tools"; - public static final String CATEGORY_BAUBLES = "baubles"; - public static final String CATEGORY_ENDER = "ender"; - public static final String CATEGORY_ALFHOMANCY = "alfhomancy"; - public static final String CATEGORY_MISC = "misc"; + public static final String CATEGORY_BASICS = "basics"; + public static final String CATEGORY_MANA = "mana"; + public static final String CATEGORY_FUNCTIONAL_FLOWERS = "functionalFlowers"; + public static final String CATEGORY_GENERATION_FLOWERS = "generationFlowers"; + public static final String CATEGORY_DEVICES = "devices"; + public static final String CATEGORY_TOOLS = "tools"; + public static final String CATEGORY_BAUBLES = "baubles"; + public static final String CATEGORY_ENDER = "ender"; + public static final String CATEGORY_ALFHOMANCY = "alfhomancy"; + public static final String CATEGORY_MISC = "misc"; - public static final String BASICS_WELCOME = "welcome"; - public static final String BASICS_TUTORIAL = "tutorial"; - public static final String BASICS_INTRO_VIDEO = "introVideo"; + public static final String BASICS_WELCOME = "welcome"; + public static final String BASICS_TUTORIAL = "tutorial"; + public static final String BASICS_INTRO_VIDEO = "introVideo"; - public static final String BASICS_FLOWERS = "flowers"; - public static final String BASICS_APOTHECARY = "apothecary"; - public static final String BASICS_LEXICON = "lexicon"; - public static final String BASICS_WAND = "wand"; - public static final String BASICS_PURE_DAISY = "pureDaisy"; - public static final String BASICS_RUNE_ALTAR = "runeAltar"; - public static final String BASICS_TERRASTEEL = "terrasteel"; - public static final String BASICS_BLACK_LOTUS = "blackLotus"; - public static final String BASICS_FLOWER_BAG = "flowerBag"; - public static final String BASICS_GARDEN_OF_GLASS = "gardenOfGlass"; + public static final String BASICS_FLOWERS = "flowers"; + public static final String BASICS_APOTHECARY = "apothecary"; + public static final String BASICS_LEXICON = "lexicon"; + public static final String BASICS_WAND = "wand"; + public static final String BASICS_PURE_DAISY = "pureDaisy"; + public static final String BASICS_RUNE_ALTAR = "runeAltar"; + public static final String BASICS_TERRASTEEL = "terrasteel"; + public static final String BASICS_BLACK_LOTUS = "blackLotus"; + public static final String BASICS_FLOWER_BAG = "flowerBag"; + public static final String BASICS_GARDEN_OF_GLASS = "gardenOfGlass"; - public static final String MANA_INTRO = "mIntro"; - public static final String MANA_SPREADER = "spreader"; - public static final String MANA_POOL = "pool"; - public static final String MANA_DISTRIBUTOR = "distributor"; - public static final String MANA_LENSES = "lens"; - public static final String MANA_VOID = "manaVoid"; - public static final String MANA_RF_GENERATOR = "rfGenerator"; - public static final String MANA_TABLET = "manaTablet"; - public static final String MANA_MIRROR = "manaMirror"; - public static final String MANA_DETECTOR = "manaDetector"; - public static final String MANA_COMPOSITE_LENS = "compositeLens"; - public static final String MANA_REDSTONE_SPREADER = "redstoneSpreader"; - public static final String MANA_MANASTAR = "manastar"; - public static final String MANA_DREAMWOOD_SPREADER = "dreamwoodSpreader"; - public static final String MANA_ELVEN_LENSES = "elvenLenses"; - public static final String MANA_SPARKS = "sparks"; - public static final String MANA_SPARK_UPGRADES = "sparkUpgrades"; - public static final String MANA_PRISM = "prism"; - public static final String MANA_POOL_CART = "poolCart"; - public static final String MANA_SPARK_CHANGER = "sparkChanger"; - public static final String MANA_BELLOWS = "bellows"; + public static final String MANA_INTRO = "mIntro"; + public static final String MANA_SPREADER = "spreader"; + public static final String MANA_POOL = "pool"; + public static final String MANA_DISTRIBUTOR = "distributor"; + public static final String MANA_LENSES = "lens"; + public static final String MANA_VOID = "manaVoid"; + public static final String MANA_RF_GENERATOR = "rfGenerator"; + public static final String MANA_TABLET = "manaTablet"; + public static final String MANA_MIRROR = "manaMirror"; + public static final String MANA_DETECTOR = "manaDetector"; + public static final String MANA_COMPOSITE_LENS = "compositeLens"; + public static final String MANA_REDSTONE_SPREADER = "redstoneSpreader"; + public static final String MANA_MANASTAR = "manastar"; + public static final String MANA_DREAMWOOD_SPREADER = "dreamwoodSpreader"; + public static final String MANA_ELVEN_LENSES = "elvenLenses"; + public static final String MANA_SPARKS = "sparks"; + public static final String MANA_SPARK_UPGRADES = "sparkUpgrades"; + public static final String MANA_PRISM = "prism"; + public static final String MANA_POOL_CART = "poolCart"; + public static final String MANA_SPARK_CHANGER = "sparkChanger"; + public static final String MANA_BELLOWS = "bellows"; - public static final String FFLOWER_INTRO = "fIntro"; - public static final String FFLOWER_SHRINKING = "flowerShrinking"; - public static final String FFLOWER_SPEED = "flowerSpeed"; - public static final String FFLOWER_JADED_AMARANTHUS = "jadedAmaranthus"; - public static final String FFLOWER_BELLETHORNE = "bellethorne"; - public static final String FFLOWER_DREADTHORNE = "dreadthorne"; - public static final String FFLOWER_HEISEI_DREAM = "heiseiDream"; - public static final String FFLOWER_TIGERSEYE = "tigerseye"; - public static final String FFLOWER_ORECHID = "orechid"; - public static final String FFLOWER_ORECHID_IGNEM = "orechidIgnem"; - public static final String FFLOWER_FALLEN_KANADE = "fallenKanade"; - public static final String FFLOWER_EXOFLAME = "exoflame"; - public static final String FFLOWER_AGRICARNATION = "agricarnation"; - public static final String FFLOWER_HOPPERHOCK = "hopperhock"; - public static final String FFLOWER_TANGLEBERRIE = "tangleberrie"; - public static final String FFLOWER_JIYUULIA = "jiyuulia"; - public static final String FFLOWER_RANNUNCARPUS = "rannuncarpus"; - public static final String FFLOWER_HYACIDUS = "hyacidus"; - public static final String FFLOWER_POLLIDISIAC = "pollidisiac"; - public static final String FFLOWER_CLAYCONIA = "clayconia"; - public static final String FFLOWER_LOONIUM = "loonium"; - public static final String FFLOWER_DAFFOMILL = "daffomill"; - public static final String FFLOWER_VINCULOTUS = "vinculotus"; - public static final String FFLOWER_SPECTRANTHEMUN = "spectranthemum"; - public static final String FFLOWER_MEDUMONE = "medumone"; - public static final String FFLOWER_MARIMORPHOSIS = "marimorphosis"; - public static final String FFLOWER_BUBBELL = "bubbell"; - public static final String FFLOWER_SOLEGNOLIA = "solegnolia"; + public static final String FFLOWER_INTRO = "fIntro"; + public static final String FFLOWER_SHRINKING = "flowerShrinking"; + public static final String FFLOWER_SPEED = "flowerSpeed"; + public static final String FFLOWER_JADED_AMARANTHUS = "jadedAmaranthus"; + public static final String FFLOWER_BELLETHORNE = "bellethorne"; + public static final String FFLOWER_DREADTHORNE = "dreadthorne"; + public static final String FFLOWER_HEISEI_DREAM = "heiseiDream"; + public static final String FFLOWER_TIGERSEYE = "tigerseye"; + public static final String FFLOWER_ORECHID = "orechid"; + public static final String FFLOWER_ORECHID_IGNEM = "orechidIgnem"; + public static final String FFLOWER_FALLEN_KANADE = "fallenKanade"; + public static final String FFLOWER_EXOFLAME = "exoflame"; + public static final String FFLOWER_AGRICARNATION = "agricarnation"; + public static final String FFLOWER_HOPPERHOCK = "hopperhock"; + public static final String FFLOWER_TANGLEBERRIE = "tangleberrie"; + public static final String FFLOWER_JIYUULIA = "jiyuulia"; + public static final String FFLOWER_RANNUNCARPUS = "rannuncarpus"; + public static final String FFLOWER_HYACIDUS = "hyacidus"; + public static final String FFLOWER_POLLIDISIAC = "pollidisiac"; + public static final String FFLOWER_CLAYCONIA = "clayconia"; + public static final String FFLOWER_LOONIUM = "loonium"; + public static final String FFLOWER_DAFFOMILL = "daffomill"; + public static final String FFLOWER_VINCULOTUS = "vinculotus"; + public static final String FFLOWER_SPECTRANTHEMUN = "spectranthemum"; + public static final String FFLOWER_MEDUMONE = "medumone"; + public static final String FFLOWER_MARIMORPHOSIS = "marimorphosis"; + public static final String FFLOWER_BUBBELL = "bubbell"; + public static final String FFLOWER_SOLEGNOLIA = "solegnolia"; - public static final String GFLOWER_INTRO = "gIntro"; - public static final String GFLOWER_PASSIVE_GENERATION = "passiveGen"; - public static final String GFLOWER_PRIMUS_LOCI = "primusLoci"; - public static final String GFLOWER_DAYBLOOM = "daybloom"; - public static final String GFLOWER_NIGHTSHADE = "nightshade"; - public static final String GFLOWER_ENDOFLAME = "endoflame"; - public static final String GFLOWER_HYDROANGEAS = "hydroangeas"; - public static final String GFLOWER_THERMALILY = "thermalily"; - public static final String GFLOWER_ARCANE_ROSE = "arcanerose"; - public static final String GFLOWER_MUNCHDEW = "munchdew"; - public static final String GFLOWER_ENTROPINNYUM = "entropinnyum"; - public static final String GFLOWER_KEKIMURUS = "kekimurus"; - public static final String GFLOWER_GOURMARYLLIS = "gourmaryllis"; - public static final String GFLOWER_NARSLIMMUS = "narslimmus"; - public static final String GFLOWER_SPECTROLUS = "spectrolus"; - public static final String GFLOWER_RAFFLOWSIA = "rafflowsia"; - public static final String GFLOWER_DANDELIFEON = "dandelifeon"; + public static final String GFLOWER_INTRO = "gIntro"; + public static final String GFLOWER_PASSIVE_GENERATION = "passiveGen"; + public static final String GFLOWER_PRIMUS_LOCI = "primusLoci"; + public static final String GFLOWER_DAYBLOOM = "daybloom"; + public static final String GFLOWER_NIGHTSHADE = "nightshade"; + public static final String GFLOWER_ENDOFLAME = "endoflame"; + public static final String GFLOWER_HYDROANGEAS = "hydroangeas"; + public static final String GFLOWER_THERMALILY = "thermalily"; + public static final String GFLOWER_ARCANE_ROSE = "arcanerose"; + public static final String GFLOWER_MUNCHDEW = "munchdew"; + public static final String GFLOWER_ENTROPINNYUM = "entropinnyum"; + public static final String GFLOWER_KEKIMURUS = "kekimurus"; + public static final String GFLOWER_GOURMARYLLIS = "gourmaryllis"; + public static final String GFLOWER_NARSLIMMUS = "narslimmus"; + public static final String GFLOWER_SPECTROLUS = "spectrolus"; + public static final String GFLOWER_RAFFLOWSIA = "rafflowsia"; + public static final String GFLOWER_DANDELIFEON = "dandelifeon"; - public static final String DEVICE_PYLON = "pylon"; - public static final String DEVICE_MANA_ENCHANTING = "manaEnchanting"; - public static final String DEVICE_TURNTABLE = "turntable"; - public static final String DEVICE_ALCHEMY = "manaAlchemy"; - public static final String DEVICE_OPEN_CRATE = "openCrate"; - public static final String DEVICE_FOREST_EYE = "forestEye"; - public static final String DEVICE_FOREST_DRUM = "forestDrum"; - public static final String DEVICE_PLATFORM = "platform"; - public static final String DEVICE_MANA_CONJURATION = "manaConjuration"; - public static final String DEVICE_SPECTRAL_PLATFORM = "spectralPlatform"; - public static final String DEVICE_GATHER_DRUM = "gatherDrum"; - public static final String DEVICE_CRAFT_CRATE = "craftCrate"; - public static final String DEVICE_BREWERY = "brewery"; - public static final String DEVICE_FLASKS = "flasks"; - public static final String DEVICE_COMPLEX_BREWS = "complexBrews"; - public static final String DEVICE_INCENSE = "incense"; - public static final String DEVICE_HOURGLASS = "hourglass"; - public static final String DEVICE_GHOST_RAIL = "ghostRail"; - public static final String DEVICE_CANOPY_DRUM = "canopyDrum"; - public static final String DEVICE_COCOON = "cocoon"; - public static final String DEVICE_MANA_BOMB = "manaBomb"; - public static final String DEVICE_TERU_TERU_BOZU = "teruTeruBozu"; - public static final String DEVICE_AVATAR = "avatar"; - public static final String DEVICE_FEL_PUMPKIN = "felPumpkin"; + public static final String DEVICE_PYLON = "pylon"; + public static final String DEVICE_MANA_ENCHANTING = "manaEnchanting"; + public static final String DEVICE_TURNTABLE = "turntable"; + public static final String DEVICE_ALCHEMY = "manaAlchemy"; + public static final String DEVICE_OPEN_CRATE = "openCrate"; + public static final String DEVICE_FOREST_EYE = "forestEye"; + public static final String DEVICE_FOREST_DRUM = "forestDrum"; + public static final String DEVICE_PLATFORM = "platform"; + public static final String DEVICE_MANA_CONJURATION = "manaConjuration"; + public static final String DEVICE_SPECTRAL_PLATFORM = "spectralPlatform"; + public static final String DEVICE_GATHER_DRUM = "gatherDrum"; + public static final String DEVICE_CRAFT_CRATE = "craftCrate"; + public static final String DEVICE_BREWERY = "brewery"; + public static final String DEVICE_FLASKS = "flasks"; + public static final String DEVICE_COMPLEX_BREWS = "complexBrews"; + public static final String DEVICE_INCENSE = "incense"; + public static final String DEVICE_HOURGLASS = "hourglass"; + public static final String DEVICE_GHOST_RAIL = "ghostRail"; + public static final String DEVICE_CANOPY_DRUM = "canopyDrum"; + public static final String DEVICE_COCOON = "cocoon"; + public static final String DEVICE_MANA_BOMB = "manaBomb"; + public static final String DEVICE_TERU_TERU_BOZU = "teruTeruBozu"; + public static final String DEVICE_AVATAR = "avatar"; + public static final String DEVICE_FEL_PUMPKIN = "felPumpkin"; - public static final String TOOL_MANA_BLASTER = "manaBlaster"; - public static final String TOOL_GRASS_SEEDS = "grassSeeds"; - public static final String TOOL_DIRT_ROD = "dirtRod"; - public static final String TOOL_TERRAFORM_ROD = "terraformRod"; - public static final String TOOL_MANASTEEL_GEAR = "manaGear"; - public static final String TOOL_TERRASTEEL_ARMOR = "terrasteelArmor"; - public static final String TOOL_GRASS_HORN = "grassHorn"; - public static final String TOOL_TERRA_SWORD = "terraSword"; - public static final String TOOL_TERRA_PICK = "terraPick"; - public static final String TOOL_WATER_ROD = "waterRod"; - public static final String TOOL_ELF_GEAR = "elfGear"; - public static final String TOOL_OPEN_BUCKET = "openBucket"; - public static final String TOOL_RAINBOW_ROD = "rainbowRod"; - public static final String TOOL_TORNADO_ROD = "tornadoRod"; - public static final String TOOL_FIRE_ROD = "fireRod"; - public static final String TOOL_VINE_BALL = "vineBall"; - public static final String TOOL_LAPUTA_SHARD = "laputaShard"; - public static final String TOOL_VIRUS = "virus"; - public static final String TOOL_SKY_DIRT_ROD = "skyDirtRod"; - public static final String TOOL_GLASS_PICK = "glassPick"; - public static final String TOOL_DIVINING_ROD = "diviningRod"; - public static final String TOOL_GRAVITY_ROD = "gravityRod"; - public static final String TOOL_REGEN_IVY = "regenIvy"; - public static final String TOOL_MISSILE_ROD = "missileRod"; - public static final String TOOL_CRAFTING_HALO = "craftingHalo"; - public static final String TOOL_CLIP = "clip"; - public static final String TOOL_COBBLE_ROD = "cobbleRod"; - public static final String TOOL_SMELT_ROD = "smeltRod"; - public static final String TOOL_WORLD_SEED = "worldSeed"; - public static final String TOOL_SPELL_CLOTH = "spellCloth"; - public static final String TOOL_THORN_CHAKRAM = "thornChakram"; - public static final String TOOL_FIRE_CHAKRAM = "fireChakram"; - public static final String TOOL_OVERGROWTH_SEED = "overgrowthSeed"; - public static final String TOOL_LIVINGWOOD_BOW = "livingwoodBow"; - public static final String TOOL_CRYSTAL_BOW = "crystalBow"; - public static final String TOOL_TEMPERANCE_STONE = "temperanceStone"; - public static final String TOOL_TERRA_AXE = "terraAxe"; - public static final String TOOL_OBEDIENCE_STICK = "obedienceStick"; - public static final String TOOL_SLIME_BOTTLE = "slimeBottle"; - public static final String TOOL_EXCHANGE_ROD = "exchangeRod"; - public static final String TOOL_MANAWEAVE = "manaweave"; - public static final String TOOL_AUTOCRAFTING_HALO = "autocraftingHalo"; - public static final String TOOL_SEXTANT = "sextant"; + public static final String TOOL_MANA_BLASTER = "manaBlaster"; + public static final String TOOL_GRASS_SEEDS = "grassSeeds"; + public static final String TOOL_DIRT_ROD = "dirtRod"; + public static final String TOOL_TERRAFORM_ROD = "terraformRod"; + public static final String TOOL_MANASTEEL_GEAR = "manaGear"; + public static final String TOOL_TERRASTEEL_ARMOR = "terrasteelArmor"; + public static final String TOOL_GRASS_HORN = "grassHorn"; + public static final String TOOL_TERRA_SWORD = "terraSword"; + public static final String TOOL_TERRA_PICK = "terraPick"; + public static final String TOOL_WATER_ROD = "waterRod"; + public static final String TOOL_ELF_GEAR = "elfGear"; + public static final String TOOL_OPEN_BUCKET = "openBucket"; + public static final String TOOL_RAINBOW_ROD = "rainbowRod"; + public static final String TOOL_TORNADO_ROD = "tornadoRod"; + public static final String TOOL_FIRE_ROD = "fireRod"; + public static final String TOOL_VINE_BALL = "vineBall"; + public static final String TOOL_LAPUTA_SHARD = "laputaShard"; + public static final String TOOL_VIRUS = "virus"; + public static final String TOOL_SKY_DIRT_ROD = "skyDirtRod"; + public static final String TOOL_GLASS_PICK = "glassPick"; + public static final String TOOL_DIVINING_ROD = "diviningRod"; + public static final String TOOL_GRAVITY_ROD = "gravityRod"; + public static final String TOOL_REGEN_IVY = "regenIvy"; + public static final String TOOL_MISSILE_ROD = "missileRod"; + public static final String TOOL_CRAFTING_HALO = "craftingHalo"; + public static final String TOOL_CLIP = "clip"; + public static final String TOOL_COBBLE_ROD = "cobbleRod"; + public static final String TOOL_SMELT_ROD = "smeltRod"; + public static final String TOOL_WORLD_SEED = "worldSeed"; + public static final String TOOL_SPELL_CLOTH = "spellCloth"; + public static final String TOOL_THORN_CHAKRAM = "thornChakram"; + public static final String TOOL_FIRE_CHAKRAM = "fireChakram"; + public static final String TOOL_OVERGROWTH_SEED = "overgrowthSeed"; + public static final String TOOL_LIVINGWOOD_BOW = "livingwoodBow"; + public static final String TOOL_CRYSTAL_BOW = "crystalBow"; + public static final String TOOL_TEMPERANCE_STONE = "temperanceStone"; + public static final String TOOL_TERRA_AXE = "terraAxe"; + public static final String TOOL_OBEDIENCE_STICK = "obedienceStick"; + public static final String TOOL_SLIME_BOTTLE = "slimeBottle"; + public static final String TOOL_EXCHANGE_ROD = "exchangeRod"; + public static final String TOOL_MANAWEAVE = "manaweave"; + public static final String TOOL_AUTOCRAFTING_HALO = "autocraftingHalo"; + public static final String TOOL_SEXTANT = "sextant"; - public static final String ENDER_AIR = "enderAir"; - public static final String ENDER_ENDER_EYE_BLOCK = "enderEyeBlock"; - public static final String ENDER_PISTON_RELAY = "pistonRelay"; - public static final String ENDER_ENDER_HAND = "enderHand"; - public static final String ENDER_ENDER_DAGGER = "enderDagger"; - public static final String ENDER_SPAWNER_CLAW = "spawnerClaw"; - public static final String ENDER_RED_STRING = "redString"; - public static final String ENDER_FLIGHT_TIARA = "flightTiara"; - public static final String ENDER_CORPOREA = "corporea"; - public static final String ENDER_CORPOREA_INDEX = "corporeaIndex"; - public static final String ENDER_CORPOREA_FUNNEL = "corporeaFunnel"; - public static final String ENDER_CORPOREA_INTERCEPTOR = "corporeaInterceptor"; - public static final String ENDER_END_STONE_DECOR = "endStoneDecor"; - public static final String ENDER_SPAWNER_MOVER = "spawnerMover"; - public static final String ENDER_KEEP_IVY = "keepIvy"; - public static final String ENDER_BLACK_HOLE_TALISMAN = "blackHoleTalisman"; - public static final String ENDER_CORPOREA_CRYSTAL_CUBE = "corporeaCrystalCube"; - public static final String ENDER_LUMINIZER_TRANSPORT = "luminizerTransport"; - public static final String ENDER_STAR_SWORD = "starSword"; - public static final String ENDER_THUNDER_SWORD = "thunderSword"; - public static final String ENDER_CORPOREA_RETAINER = "corporeaRetainer"; + public static final String ENDER_AIR = "enderAir"; + public static final String ENDER_ENDER_EYE_BLOCK = "enderEyeBlock"; + public static final String ENDER_PISTON_RELAY = "pistonRelay"; + public static final String ENDER_ENDER_HAND = "enderHand"; + public static final String ENDER_ENDER_DAGGER = "enderDagger"; + public static final String ENDER_SPAWNER_CLAW = "spawnerClaw"; + public static final String ENDER_RED_STRING = "redString"; + public static final String ENDER_FLIGHT_TIARA = "flightTiara"; + public static final String ENDER_CORPOREA = "corporea"; + public static final String ENDER_CORPOREA_INDEX = "corporeaIndex"; + public static final String ENDER_CORPOREA_FUNNEL = "corporeaFunnel"; + public static final String ENDER_CORPOREA_INTERCEPTOR = "corporeaInterceptor"; + public static final String ENDER_END_STONE_DECOR = "endStoneDecor"; + public static final String ENDER_SPAWNER_MOVER = "spawnerMover"; + public static final String ENDER_KEEP_IVY = "keepIvy"; + public static final String ENDER_BLACK_HOLE_TALISMAN = "blackHoleTalisman"; + public static final String ENDER_CORPOREA_CRYSTAL_CUBE = "corporeaCrystalCube"; + public static final String ENDER_LUMINIZER_TRANSPORT = "luminizerTransport"; + public static final String ENDER_STAR_SWORD = "starSword"; + public static final String ENDER_THUNDER_SWORD = "thunderSword"; + public static final String ENDER_CORPOREA_RETAINER = "corporeaRetainer"; - public static final String BAUBLE_INTRO = "bIntro"; - public static final String BAUBLE_COSMETIC = "cosmeticBaubles"; - public static final String BAUBLE_TINY_PLANET = "tinyPlanet"; - public static final String BAUBLE_MANA_RING = "manaRing"; - public static final String BAUBLE_AURA_RING = "auraRing"; - public static final String BAUBLE_TRAVEL_BELT = "travelBelt"; - public static final String BAUBLE_KNOCKBACK_BELT = "knockbackBelt"; - public static final String BAUBLE_ICE_PENDANT = "icePendant"; - public static final String BAUBLE_LAVA_PENDANT = "lavaPendant"; - public static final String BAUBLE_GOLDEN_LAUREL = "goldenLaurel"; - public static final String BAUBLE_WATER_RING = "waterRing"; - public static final String BAUBLE_MINING_RING = "miningRing"; - public static final String BAUBLE_MAGNET_RING = "magnetRing"; - public static final String BAUBLE_DIVA_CHARM = "divaCharm"; - public static final String BAUBLE_PIXIE_RING = "pixieRing"; - public static final String BAUBLE_SUPER_TRAVEL_BELT = "superTravelBelt"; - public static final String BAUBLE_REACH_RING = "reachRing"; - public static final String BAUBLE_ITEM_FINDER = "itemFinder"; - public static final String BAUBLE_SUPER_LAVA_PENDANT = "superLavaPendant"; - public static final String BAUBLE_BLOOD_PENDANT = "bloodPendant"; - public static final String BAUBLE_JUDGEMENT_CLOAKS = "judgementCloaks"; - public static final String BAUBLE_MONOCLE = "monocle"; - public static final String BAUBLE_SWAP_RING = "swapRing"; - public static final String BAUBLE_SPEED_UP_BELT = "speedUpBelt"; - public static final String BAUBLE_BOX = "baubleBox"; + public static final String BAUBLE_INTRO = "bIntro"; + public static final String BAUBLE_COSMETIC = "cosmeticBaubles"; + public static final String BAUBLE_TINY_PLANET = "tinyPlanet"; + public static final String BAUBLE_MANA_RING = "manaRing"; + public static final String BAUBLE_AURA_RING = "auraRing"; + public static final String BAUBLE_TRAVEL_BELT = "travelBelt"; + public static final String BAUBLE_KNOCKBACK_BELT = "knockbackBelt"; + public static final String BAUBLE_ICE_PENDANT = "icePendant"; + public static final String BAUBLE_LAVA_PENDANT = "lavaPendant"; + public static final String BAUBLE_GOLDEN_LAUREL = "goldenLaurel"; + public static final String BAUBLE_WATER_RING = "waterRing"; + public static final String BAUBLE_MINING_RING = "miningRing"; + public static final String BAUBLE_MAGNET_RING = "magnetRing"; + public static final String BAUBLE_DIVA_CHARM = "divaCharm"; + public static final String BAUBLE_PIXIE_RING = "pixieRing"; + public static final String BAUBLE_SUPER_TRAVEL_BELT = "superTravelBelt"; + public static final String BAUBLE_REACH_RING = "reachRing"; + public static final String BAUBLE_ITEM_FINDER = "itemFinder"; + public static final String BAUBLE_SUPER_LAVA_PENDANT = "superLavaPendant"; + public static final String BAUBLE_BLOOD_PENDANT = "bloodPendant"; + public static final String BAUBLE_JUDGEMENT_CLOAKS = "judgementCloaks"; + public static final String BAUBLE_MONOCLE = "monocle"; + public static final String BAUBLE_SWAP_RING = "swapRing"; + public static final String BAUBLE_SPEED_UP_BELT = "speedUpBelt"; + public static final String BAUBLE_BOX = "baubleBox"; - public static final String ALF_INTRO = "aIntro"; - public static final String ALF_MESSAGE = "elfMessage"; - public static final String ALF_RESOURCES = "elfResources"; - public static final String ALF_GAIA_RITUAL = "gaiaRitual"; - public static final String ALF_GAIA_RITUAL_HARDMODE = "gaiaRitualHardmode"; - public static final String ALF_LORE = "elvenLore"; - public static final String ALF_RELICS = "relics"; - public static final String ALF_RELIC_INFO = "relicInfo"; - public static final String ALF_INFINITE_FRUIT = "infiniteFruit"; - public static final String ALF_KING_KEY = "kingKey"; - public static final String ALF_FLUGEL_EYE = "flugelEye"; - public static final String ALF_THOR_RING = "thorRing"; - public static final String ALF_LOKI_RING = "lokiRing"; - public static final String ALF_ODIN_RING = "odinRing"; + public static final String ALF_INTRO = "aIntro"; + public static final String ALF_MESSAGE = "elfMessage"; + public static final String ALF_RESOURCES = "elfResources"; + public static final String ALF_GAIA_RITUAL = "gaiaRitual"; + public static final String ALF_GAIA_RITUAL_HARDMODE = "gaiaRitualHardmode"; + public static final String ALF_LORE = "elvenLore"; + public static final String ALF_RELICS = "relics"; + public static final String ALF_RELIC_INFO = "relicInfo"; + public static final String ALF_INFINITE_FRUIT = "infiniteFruit"; + public static final String ALF_KING_KEY = "kingKey"; + public static final String ALF_FLUGEL_EYE = "flugelEye"; + public static final String ALF_THOR_RING = "thorRing"; + public static final String ALF_LOKI_RING = "lokiRing"; + public static final String ALF_ODIN_RING = "odinRing"; - public static final String MISC_UNSTABLE_BLOCKS = "unstableBlocks"; - public static final String MISC_DECORATIVE_BLOCKS = "decorativeBlocks"; - public static final String MISC_DISPENSER_TWEAKS = "dispenserTweaks"; - public static final String MISC_SHINY_FLOWERS = "shinyFlowers"; - public static final String MISC_PRISMARINE = "prismarine"; - public static final String MISC_SHEDDING = "shedding"; - public static final String MISC_TINY_POTATO = "tinyPotato"; - public static final String MISC_HEAD_CREATING = "headCreating"; - public static final String MISC_AZULEJO = "azulejo"; - public static final String MISC_STARFIELD = "starfield"; - public static final String MISC_DIRT_PATH = "dirtPath"; - public static final String MISC_MUSHROOMS = "mushrooms"; - public static final String MISC_PHANTOM_INK = "phantomInk"; - public static final String MISC_STONE_ALCHEMY = "stoneAlchemy"; - public static final String MISC_BLAZE_BLOCK = "blazeBlock"; - public static final String MISC_CHALLENGES = "challenges"; - public static final String MISC_CACOPHONIUM = "cacophonium"; - public static final String MISC_PAVEMENT = "pavement"; - public static final String MISC_PRENTING_DECAY = "preventingDecay"; - - public static final String MISC_TC_INTEGRATION = "tcIntegration"; - public static final String MISC_BC_INTEGRATION = "bcIntegration"; - public static final String MISC_BANNERS = "banners"; + public static final String MISC_UNSTABLE_BLOCKS = "unstableBlocks"; + public static final String MISC_DECORATIVE_BLOCKS = "decorativeBlocks"; + public static final String MISC_DISPENSER_TWEAKS = "dispenserTweaks"; + public static final String MISC_SHINY_FLOWERS = "shinyFlowers"; + public static final String MISC_PRISMARINE = "prismarine"; + public static final String MISC_SHEDDING = "shedding"; + public static final String MISC_TINY_POTATO = "tinyPotato"; + public static final String MISC_HEAD_CREATING = "headCreating"; + public static final String MISC_AZULEJO = "azulejo"; + public static final String MISC_STARFIELD = "starfield"; + public static final String MISC_DIRT_PATH = "dirtPath"; + public static final String MISC_MUSHROOMS = "mushrooms"; + public static final String MISC_PHANTOM_INK = "phantomInk"; + public static final String MISC_STONE_ALCHEMY = "stoneAlchemy"; + public static final String MISC_BLAZE_BLOCK = "blazeBlock"; + public static final String MISC_CHALLENGES = "challenges"; + public static final String MISC_CACOPHONIUM = "cacophonium"; + public static final String MISC_PAVEMENT = "pavement"; + public static final String MISC_PRENTING_DECAY = "preventingDecay"; + public static final String MISC_TC_INTEGRATION = "tcIntegration"; + public static final String MISC_BC_INTEGRATION = "bcIntegration"; + public static final String MISC_BANNERS = "banners"; } - diff --git a/src/main/java/vazkii/botania/common/lib/LibMisc.java b/src/main/java/vazkii/botania/common/lib/LibMisc.java index 2bbc98d156..3bfcb530ca 100644 --- a/src/main/java/vazkii/botania/common/lib/LibMisc.java +++ b/src/main/java/vazkii/botania/common/lib/LibMisc.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jan 13, 2014, 6:32:05 PM (GMT)] */ package vazkii.botania.common.lib; @@ -14,32 +14,30 @@ public final class LibMisc { - // Mod Constants - public static final String MOD_ID = "Botania"; - public static final String MOD_NAME = MOD_ID; - public static final String VERSION = "GRADLETOKEN_VERSION"; - public static final String DEPENDENCIES = "required-after:Baubles;after:Thaumcraft"; + // Mod Constants + public static final String MOD_ID = "Botania"; + public static final String MOD_NAME = MOD_ID; + public static final String VERSION = "GRADLETOKEN_VERSION"; + public static final String DEPENDENCIES = "required-after:Baubles;after:Thaumcraft"; - // Network Contants - public static final String NETWORK_CHANNEL = MOD_ID; + // Network Contants + public static final String NETWORK_CHANNEL = MOD_ID; - // Proxy Constants - public static final String PROXY_COMMON = "vazkii.botania.common.core.proxy.CommonProxy"; - public static final String PROXY_CLIENT = "vazkii.botania.client.core.proxy.ClientProxy"; - public static final String GUI_FACTORY = "vazkii.botania.client.core.proxy.GuiFactory"; + // Proxy Constants + public static final String PROXY_COMMON = "vazkii.botania.common.core.proxy.CommonProxy"; + public static final String PROXY_CLIENT = "vazkii.botania.client.core.proxy.ClientProxy"; + public static final String GUI_FACTORY = "vazkii.botania.client.core.proxy.GuiFactory"; - // IMC Keys - public static final String BLACKLIST_ITEM = "blackListItem"; + // IMC Keys + public static final String BLACKLIST_ITEM = "blackListItem"; - public static final ForgeDirection[] CARDINAL_DIRECTIONS = new ForgeDirection[] { - ForgeDirection.NORTH, ForgeDirection.SOUTH, ForgeDirection.EAST, ForgeDirection.WEST - }; - - public static final int[] CONTROL_CODE_COLORS = new int[] { - 0x000000, 0x0000AA, 0x00AA00, 0x00AAAA, - 0xAA0000, 0xAA00AA, 0xFFAA00, 0xAAAAAA, - 0x555555, 0x5555FF, 0x55FF55, 0x55FFFF, - 0xFF5555, 0xFF55FF, 0xFFFF55, 0xFFFFFF - }; + public static final ForgeDirection[] CARDINAL_DIRECTIONS = + new ForgeDirection[] {ForgeDirection.NORTH, ForgeDirection.SOUTH, ForgeDirection.EAST, ForgeDirection.WEST}; + public static final int[] CONTROL_CODE_COLORS = new int[] { + 0x000000, 0x0000AA, 0x00AA00, 0x00AAAA, + 0xAA0000, 0xAA00AA, 0xFFAA00, 0xAAAAAA, + 0x555555, 0x5555FF, 0x55FF55, 0x55FFFF, + 0xFF5555, 0xFF55FF, 0xFFFF55, 0xFFFFFF + }; } diff --git a/src/main/java/vazkii/botania/common/lib/LibObfuscation.java b/src/main/java/vazkii/botania/common/lib/LibObfuscation.java index 44f27a3c61..8e3c9d4972 100644 --- a/src/main/java/vazkii/botania/common/lib/LibObfuscation.java +++ b/src/main/java/vazkii/botania/common/lib/LibObfuscation.java @@ -2,91 +2,90 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jan 17, 2014, 4:52:15 PM (GMT)] */ package vazkii.botania.common.lib; public final class LibObfuscation { - // EffectRenderer - public static final String[] PARTICLE_TEXTURES = new String[] { "particleTextures", "field_110737_b", "b" }; + // EffectRenderer + public static final String[] PARTICLE_TEXTURES = new String[] {"particleTextures", "field_110737_b", "b"}; - // EntityAINearestAttackableTarget - public static final String[] TARGET_CLASS = new String[] { "targetClass", "field_75307_b", "a" }; - public static final String[] TARGET_ENTITY = new String[] { "targetEntity", "field_75309_a", "g" }; + // EntityAINearestAttackableTarget + public static final String[] TARGET_CLASS = new String[] {"targetClass", "field_75307_b", "a"}; + public static final String[] TARGET_ENTITY = new String[] {"targetEntity", "field_75309_a", "g"}; - // EntityAIAttackOnCollide - public static final String[] CLASS_TARGET = new String[] { "classTarget", "field_75444_h", "g" }; + // EntityAIAttackOnCollide + public static final String[] CLASS_TARGET = new String[] {"classTarget", "field_75444_h", "g"}; - // EntityAIAvoidEntity - public static final String[] TARGET_ENTITY_CLASS = new String[] { "targetEntityClass", "field_75381_h", "i" }; + // EntityAIAvoidEntity + public static final String[] TARGET_ENTITY_CLASS = new String[] {"targetEntityClass", "field_75381_h", "i"}; - // EntityCreeper - public static final String[] TIME_SINCE_IGNITED = new String[] { "timeSinceIgnited", "field_70833_d", "bq" }; + // EntityCreeper + public static final String[] TIME_SINCE_IGNITED = new String[] {"timeSinceIgnited", "field_70833_d", "bq"}; - // ThreadDownloadImageData - public static final String[] TEXTURE_UPLOADED = new String[] { "textureUploaded", "field_110559_g", "i" }; - public static final String[] BUFFERED_IMAGE = new String[] { "bufferedImage", "field_110560_d", "g" }; + // ThreadDownloadImageData + public static final String[] TEXTURE_UPLOADED = new String[] {"textureUploaded", "field_110559_g", "i"}; + public static final String[] BUFFERED_IMAGE = new String[] {"bufferedImage", "field_110560_d", "g"}; - // Entity - public static final String[] IS_IMMUNE_TO_FIRE = new String[] { "isImmuneToFire", "field_70178_ae", "ag" }; + // Entity + public static final String[] IS_IMMUNE_TO_FIRE = new String[] {"isImmuneToFire", "field_70178_ae", "ag"}; - // ItemReed - public static final String[] REED_ITEM = new String[] { "field_150935_a", "a" }; + // ItemReed + public static final String[] REED_ITEM = new String[] {"field_150935_a", "a"}; - // EntityAnimal - public static final String[] IN_LOVE = new String[] { "inLove", "field_70881_d", "bp" }; + // EntityAnimal + public static final String[] IN_LOVE = new String[] {"inLove", "field_70881_d", "bp"}; - // EntityPlayer - public static final String[] ITEM_IN_USE = new String[] { "itemInUse", "field_71074_e", "f" }; - public static final String[] ITEM_IN_USE_COUNT = new String[] { "itemInUseCount", "field_71072_f", "g" }; + // EntityPlayer + public static final String[] ITEM_IN_USE = new String[] {"itemInUse", "field_71074_e", "f"}; + public static final String[] ITEM_IN_USE_COUNT = new String[] {"itemInUseCount", "field_71072_f", "g"}; - // Potion - public static final String[] IS_BAD_EFFECT = new String[] { "isBadEffect", "field_76418_K", "J" }; + // Potion + public static final String[] IS_BAD_EFFECT = new String[] {"isBadEffect", "field_76418_K", "J"}; - // EntityHorse - public static final String[] HORSE_JUMP_STRENGTH = new String[] { "horseJumpStrength", "field_110271_bv", "bv" }; - public static final String[] HORSE_CHEST = new String[] { "horseChest", "field_110296_bG", "bG" }; + // EntityHorse + public static final String[] HORSE_JUMP_STRENGTH = new String[] {"horseJumpStrength", "field_110271_bv", "bv"}; + public static final String[] HORSE_CHEST = new String[] {"horseChest", "field_110296_bG", "bG"}; - // PlayerControllerMP - public static final String[] NET_CLIENT_HANDLER = new String[] { "netClientHandler", "field_78774_b", "b" }; - public static final String[] CURRENT_GAME_TYPE = new String[] { "currentGameType", "field_78779_k", "k" }; + // PlayerControllerMP + public static final String[] NET_CLIENT_HANDLER = new String[] {"netClientHandler", "field_78774_b", "b"}; + public static final String[] CURRENT_GAME_TYPE = new String[] {"currentGameType", "field_78779_k", "k"}; - // MobSpawnerBaseLogic - public static final String[] SPAWN_RANGE = new String[] { "spawnRange", "field_98290_m", "m" }; - public static final String[] SPAWN_COUNT = new String[] { "spawnCount", "field_98294_i", "i" }; - public static final String[] MAX_NEARBY_ENTITIES = new String[] { "maxNearbyEntities", "field_98292_k", "k" }; - public static final String[] MAX_SPAWN_DELAY = new String[] { "maxSpawnDelay", "field_98293_h", "h" }; - public static final String[] MIN_SPAWN_DELAY = new String[] { "minSpawnDelay", "field_98283_g", "g" }; - public static final String[] POTENTIAL_ENTITY_SPAWNS = new String[] { "potentialEntitySpawns", "field_98285_e", "e" }; + // MobSpawnerBaseLogic + public static final String[] SPAWN_RANGE = new String[] {"spawnRange", "field_98290_m", "m"}; + public static final String[] SPAWN_COUNT = new String[] {"spawnCount", "field_98294_i", "i"}; + public static final String[] MAX_NEARBY_ENTITIES = new String[] {"maxNearbyEntities", "field_98292_k", "k"}; + public static final String[] MAX_SPAWN_DELAY = new String[] {"maxSpawnDelay", "field_98293_h", "h"}; + public static final String[] MIN_SPAWN_DELAY = new String[] {"minSpawnDelay", "field_98283_g", "g"}; + public static final String[] POTENTIAL_ENTITY_SPAWNS = new String[] {"potentialEntitySpawns", "field_98285_e", "e"}; - // GuiIngame - public static final String[] REMAINING_HIGHLIGHT_TICKS = new String[] { "remainingHighlightTicks", "field_92017_k", "r" }; + // GuiIngame + public static final String[] REMAINING_HIGHLIGHT_TICKS = + new String[] {"remainingHighlightTicks", "field_92017_k", "r"}; - // EntityThrowable - public static final String[] THROWER = new String[] { "thrower", "field_70192_c", "g" }; + // EntityThrowable + public static final String[] THROWER = new String[] {"thrower", "field_70192_c", "g"}; - // GuiContainer - public static final String[] THE_SLOT = new String[] { "theSlot", "field_147006_u", "u" }; + // GuiContainer + public static final String[] THE_SLOT = new String[] {"theSlot", "field_147006_u", "u"}; - // GuiChat - public static final String[] INPUT_FIELD = new String[] { "inputField", "field_146415_a", "a" }; - public static final String[] COMPLETE_FLAG = new String[] { "field_146414_r", "r" }; + // GuiChat + public static final String[] INPUT_FIELD = new String[] {"inputField", "field_146415_a", "a"}; + public static final String[] COMPLETE_FLAG = new String[] {"field_146414_r", "r"}; - // Entityliving - public static final String[] GET_LIVING_SOUND = new String[] { "getLivingSound", "func_70639_aQ", "t" }; + // Entityliving + public static final String[] GET_LIVING_SOUND = new String[] {"getLivingSound", "func_70639_aQ", "t"}; - // TextureAtlasSprite - public static final String[] ANIMATION_METADATA = new String[] { "animationMetadata", "field_110982_k", "j" }; - - // RenderGlobal - public static final String[] STAR_GL_CALL_LIST = new String[] { "starGLCallList", "field_72772_v", "F" }; - public static final String[] GL_SKY_LIST = new String[] { "glSkyList", "field_72771_w", "G" }; - public static final String[] GL_SKY_LIST2 = new String[] { "glSkyList2", "field_72781_x", "H" }; - + // TextureAtlasSprite + public static final String[] ANIMATION_METADATA = new String[] {"animationMetadata", "field_110982_k", "j"}; + // RenderGlobal + public static final String[] STAR_GL_CALL_LIST = new String[] {"starGLCallList", "field_72772_v", "F"}; + public static final String[] GL_SKY_LIST = new String[] {"glSkyList", "field_72771_w", "G"}; + public static final String[] GL_SKY_LIST2 = new String[] {"glSkyList2", "field_72781_x", "H"}; } diff --git a/src/main/java/vazkii/botania/common/lib/LibOreDict.java b/src/main/java/vazkii/botania/common/lib/LibOreDict.java index 145ed48279..b08bb208fc 100644 --- a/src/main/java/vazkii/botania/common/lib/LibOreDict.java +++ b/src/main/java/vazkii/botania/common/lib/LibOreDict.java @@ -2,97 +2,97 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jan 19, 2014, 4:30:32 PM (GMT)] */ package vazkii.botania.common.lib; public final class LibOreDict { - public static final String LEXICON = "lexicaBotania"; - public static final String PESTLE_AND_MORTAR = "pestleAndMortar"; - public static final String TWIG_WAND = "twigWand"; - public static final String LIVING_WOOD = "livingwood"; - public static final String LIVING_ROCK = "livingrock"; - public static final String MANA_STEEL = "ingotManasteel"; - public static final String MANA_PEARL = "manaPearl"; - public static final String MANA_DIAMOND = "manaDiamond"; - public static final String LIVINGWOOD_TWIG = "livingwoodTwig"; - public static final String TERRA_STEEL = "ingotTerrasteel"; - public static final String LIFE_ESSENCE = "eternalLifeEssence"; - public static final String REDSTONE_ROOT = "redstoneRoot"; - public static final String DREAM_WOOD = "dreamwood"; - public static final String ELEMENTIUM = "ingotElvenElementium"; - public static final String PIXIE_DUST = "elvenPixieDust"; - public static final String DRAGONSTONE = "elvenDragonstone"; - public static final String PRISMARINE_SHARD = "shardPrismarine"; - public static final String PLACEHOLDER = "bPlaceholder"; - public static final String RED_STRING = "bRedString"; - public static final String DREAMWOOD_TWIG = "dreamwoodTwig"; - public static final String GAIA_INGOT = "gaiaIngot"; - public static final String ENDER_AIR_BOTTLE = "bEnderAirBottle"; - public static final String MANA_STRING = "manaString"; - public static final String MANASTEEL_NUGGET = "nuggetManasteel"; - public static final String TERRASTEEL_NUGGET = "nuggetTerrasteel"; - public static final String ELEMENTIUM_NUGGET = "nuggetElvenElementium"; - public static final String ROOT = "livingRoot"; - public static final String PEBBLE = "pebble"; - public static final String MANAWEAVE_CLOTH = "clothManaweave"; - public static final String MANA_POWDER = "powderMana"; + public static final String LEXICON = "lexicaBotania"; + public static final String PESTLE_AND_MORTAR = "pestleAndMortar"; + public static final String TWIG_WAND = "twigWand"; + public static final String LIVING_WOOD = "livingwood"; + public static final String LIVING_ROCK = "livingrock"; + public static final String MANA_STEEL = "ingotManasteel"; + public static final String MANA_PEARL = "manaPearl"; + public static final String MANA_DIAMOND = "manaDiamond"; + public static final String LIVINGWOOD_TWIG = "livingwoodTwig"; + public static final String TERRA_STEEL = "ingotTerrasteel"; + public static final String LIFE_ESSENCE = "eternalLifeEssence"; + public static final String REDSTONE_ROOT = "redstoneRoot"; + public static final String DREAM_WOOD = "dreamwood"; + public static final String ELEMENTIUM = "ingotElvenElementium"; + public static final String PIXIE_DUST = "elvenPixieDust"; + public static final String DRAGONSTONE = "elvenDragonstone"; + public static final String PRISMARINE_SHARD = "shardPrismarine"; + public static final String PLACEHOLDER = "bPlaceholder"; + public static final String RED_STRING = "bRedString"; + public static final String DREAMWOOD_TWIG = "dreamwoodTwig"; + public static final String GAIA_INGOT = "gaiaIngot"; + public static final String ENDER_AIR_BOTTLE = "bEnderAirBottle"; + public static final String MANA_STRING = "manaString"; + public static final String MANASTEEL_NUGGET = "nuggetManasteel"; + public static final String TERRASTEEL_NUGGET = "nuggetTerrasteel"; + public static final String ELEMENTIUM_NUGGET = "nuggetElvenElementium"; + public static final String ROOT = "livingRoot"; + public static final String PEBBLE = "pebble"; + public static final String MANAWEAVE_CLOTH = "clothManaweave"; + public static final String MANA_POWDER = "powderMana"; - public static final String VIAL = "bVial"; - public static final String FLASK = "bFlask"; + public static final String VIAL = "bVial"; + public static final String FLASK = "bFlask"; - public static final String PRISMARINE_BLOCK = "blockPrismarine"; - public static final String BLAZE_BLOCK = "blockBlaze"; + public static final String PRISMARINE_BLOCK = "blockPrismarine"; + public static final String BLAZE_BLOCK = "blockBlaze"; - public static final String[] FLOWER = new String[] { - "mysticFlowerWhite", "mysticFlowerOrange", "mysticFlowerMagenta", "mysticFlowerLightBlue", - "mysticFlowerYellow", "mysticFlowerLime", "mysticFlowerPink", "mysticFlowerGray", - "mysticFlowerLightGray", "mysticFlowerCyan", "mysticFlowerPurple", "mysticFlowerBlue", - "mysticFlowerBrown", "mysticFlowerGreen", "mysticFlowerRed", "mysticFlowerBlack" - }; + public static final String[] FLOWER = new String[] { + "mysticFlowerWhite", "mysticFlowerOrange", "mysticFlowerMagenta", "mysticFlowerLightBlue", + "mysticFlowerYellow", "mysticFlowerLime", "mysticFlowerPink", "mysticFlowerGray", + "mysticFlowerLightGray", "mysticFlowerCyan", "mysticFlowerPurple", "mysticFlowerBlue", + "mysticFlowerBrown", "mysticFlowerGreen", "mysticFlowerRed", "mysticFlowerBlack" + }; - public static final String[] DOUBLE_FLOWER = new String[] { - "mysticFlowerWhiteDouble", "mysticFlowerOrangeDouble", "mysticFlowerMagentaDouble", "mysticFlowerLightBlueDouble", - "mysticFlowerYellowDouble", "mysticFlowerLimeDouble", "mysticFlowerPinkDouble", "mysticFlowerGrayDouble", - "mysticFlowerLightGrayDouble", "mysticFlowerCyanDouble", "mysticFlowerPurpleDouble", "mysticFlowerBlueDouble", - "mysticFlowerBrownDouble", "mysticFlowerGreenDouble", "mysticFlowerRedDouble", "mysticFlowerBlackDouble" - }; + public static final String[] DOUBLE_FLOWER = new String[] { + "mysticFlowerWhiteDouble", "mysticFlowerOrangeDouble", "mysticFlowerMagentaDouble", + "mysticFlowerLightBlueDouble", + "mysticFlowerYellowDouble", "mysticFlowerLimeDouble", "mysticFlowerPinkDouble", "mysticFlowerGrayDouble", + "mysticFlowerLightGrayDouble", "mysticFlowerCyanDouble", "mysticFlowerPurpleDouble", "mysticFlowerBlueDouble", + "mysticFlowerBrownDouble", "mysticFlowerGreenDouble", "mysticFlowerRedDouble", "mysticFlowerBlackDouble" + }; - public static final String[] PETAL = new String[] { - "petalWhite", "petalOrange", "petalMagenta", "petalLightBlue", - "petalYellow", "petalLime", "petalPink", "petalGray", - "petalLightGray", "petalCyan", "petalPurple", "petalBlue", - "petalBrown", "petalGreen", "petalRed", "petalBlack" - }; + public static final String[] PETAL = new String[] { + "petalWhite", "petalOrange", "petalMagenta", "petalLightBlue", + "petalYellow", "petalLime", "petalPink", "petalGray", + "petalLightGray", "petalCyan", "petalPurple", "petalBlue", + "petalBrown", "petalGreen", "petalRed", "petalBlack" + }; - public static final String[] DYE = new String[] { - "dyeWhite", "dyeOrange", "dyeMagenta", "dyeLightBlue", - "dyeYellow", "dyeLime", "dyePink", "dyeGray", - "dyeLightGray", "dyeCyan", "dyePurple", "dyeBlue", - "dyeBrown", "dyeGreen", "dyeRed", "dyeBlack" - }; + public static final String[] DYE = new String[] { + "dyeWhite", "dyeOrange", "dyeMagenta", "dyeLightBlue", + "dyeYellow", "dyeLime", "dyePink", "dyeGray", + "dyeLightGray", "dyeCyan", "dyePurple", "dyeBlue", + "dyeBrown", "dyeGreen", "dyeRed", "dyeBlack" + }; - public static final String[] RUNE = new String[] { - "runeWaterB", "runeFireB", "runeEarthB", "runeAirB", - "runeSpringB", "runeSummerB", "runeAutumnB", "runeWinterB", - "runeManaB", "runeLustB", "runeGluttonyB", "runeGreedB", - "runeSlothB", "runeWrathB", "runeEnvyB", "runePrideB" - }; + public static final String[] RUNE = new String[] { + "runeWaterB", "runeFireB", "runeEarthB", "runeAirB", + "runeSpringB", "runeSummerB", "runeAutumnB", "runeWinterB", + "runeManaB", "runeLustB", "runeGluttonyB", "runeGreedB", + "runeSlothB", "runeWrathB", "runeEnvyB", "runePrideB" + }; - public static final String[] STONE_18_VARIANTS = new String[] { - "stoneAndesite", "stoneBasalt", "stoneDiorite", "stoneGranite", - "stoneAndesitePolished", "stoneBasaltPolished", "stoneDioritePolished", "stoneGranitePolished", - "stoneAndesiteBricks", "stoneBasaltBricks", "stoneDioriteBricks", "stoneGraniteBricks", - "stoneAndesiteChiseled", "stoneBasaltChiseled", "stoneDioriteChiseled", "stoneGraniteChiseled" - }; + public static final String[] STONE_18_VARIANTS = new String[] { + "stoneAndesite", "stoneBasalt", "stoneDiorite", "stoneGranite", + "stoneAndesitePolished", "stoneBasaltPolished", "stoneDioritePolished", "stoneGranitePolished", + "stoneAndesiteBricks", "stoneBasaltBricks", "stoneDioriteBricks", "stoneGraniteBricks", + "stoneAndesiteChiseled", "stoneBasaltChiseled", "stoneDioriteChiseled", "stoneGraniteChiseled" + }; - public static final String[] QUARTZ = new String[] { - "quartzDark", "quartzMana", "quartzBlaze", - "quartzLavender", "quartzRed", "quartzElven", "quartzSunny" - }; + public static final String[] QUARTZ = new String[] { + "quartzDark", "quartzMana", "quartzBlaze", "quartzLavender", "quartzRed", "quartzElven", "quartzSunny" + }; } diff --git a/src/main/java/vazkii/botania/common/lib/LibPotionNames.java b/src/main/java/vazkii/botania/common/lib/LibPotionNames.java index 049ca9abb0..048b169197 100644 --- a/src/main/java/vazkii/botania/common/lib/LibPotionNames.java +++ b/src/main/java/vazkii/botania/common/lib/LibPotionNames.java @@ -2,21 +2,20 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Nov 2, 2014, 10:33:37 PM (GMT)] */ package vazkii.botania.common.lib; public final class LibPotionNames { - public static final String SOUL_CROSS = "soulCross"; - public static final String FEATHER_FEET = "featherFeet"; - public static final String EMPTINESS = "emptiness"; - public static final String BLOODTHIRST = "bloodthirst"; - public static final String ALLURE = "allure"; - public static final String CLEAR = "clear"; - + public static final String SOUL_CROSS = "soulCross"; + public static final String FEATHER_FEET = "featherFeet"; + public static final String EMPTINESS = "emptiness"; + public static final String BLOODTHIRST = "bloodthirst"; + public static final String ALLURE = "allure"; + public static final String CLEAR = "clear"; } diff --git a/src/main/java/vazkii/botania/common/lib/LibTriggerNames.java b/src/main/java/vazkii/botania/common/lib/LibTriggerNames.java index 6fc99c6bb9..28863fed0a 100644 --- a/src/main/java/vazkii/botania/common/lib/LibTriggerNames.java +++ b/src/main/java/vazkii/botania/common/lib/LibTriggerNames.java @@ -1,12 +1,10 @@ package vazkii.botania.common.lib; - public class LibTriggerNames { - public static final String TRIGGER_PREFIX = "botania.triggers."; - - public static final String TRIGGER_MANA_PREFIX = TRIGGER_PREFIX + "mana"; - public static final String TRIGGER_MANA_DETECTOR = TRIGGER_PREFIX + "manaDetector"; - public static final String TRIGGER_RUNE_ALTAR_CAN_CRAFT = TRIGGER_PREFIX + "runeAltarCanCraft"; + public static final String TRIGGER_PREFIX = "botania.triggers."; + public static final String TRIGGER_MANA_PREFIX = TRIGGER_PREFIX + "mana"; + public static final String TRIGGER_MANA_DETECTOR = TRIGGER_PREFIX + "manaDetector"; + public static final String TRIGGER_RUNE_ALTAR_CAN_CRAFT = TRIGGER_PREFIX + "runeAltarCanCraft"; } diff --git a/src/main/java/vazkii/botania/common/network/GuiHandler.java b/src/main/java/vazkii/botania/common/network/GuiHandler.java index 0dd9fea9f4..bcced2a0c7 100644 --- a/src/main/java/vazkii/botania/common/network/GuiHandler.java +++ b/src/main/java/vazkii/botania/common/network/GuiHandler.java @@ -2,14 +2,15 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jan 14, 2014, 6:50:15 PM (GMT)] */ package vazkii.botania.common.network; +import cpw.mods.fml.common.network.IGuiHandler; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.world.World; import vazkii.botania.client.gui.bag.ContainerFlowerBag; @@ -20,39 +21,37 @@ import vazkii.botania.client.gui.crafting.GuiCraftingHalo; import vazkii.botania.client.gui.lexicon.GuiLexicon; import vazkii.botania.common.lib.LibGuiIDs; -import cpw.mods.fml.common.network.IGuiHandler; public class GuiHandler implements IGuiHandler { - @Override - public Object getServerGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) { - switch(ID) { - case LibGuiIDs.CRAFTING_HALO : - return new ContainerCraftingHalo(player.inventory, world); - case LibGuiIDs.FLOWER_BAG : - return new ContainerFlowerBag(player); - case LibGuiIDs.BAUBLE_BOX : - return new ContainerBaubleBox(player); - } - - return null; - } + @Override + public Object getServerGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) { + switch (ID) { + case LibGuiIDs.CRAFTING_HALO: + return new ContainerCraftingHalo(player.inventory, world); + case LibGuiIDs.FLOWER_BAG: + return new ContainerFlowerBag(player); + case LibGuiIDs.BAUBLE_BOX: + return new ContainerBaubleBox(player); + } - @Override - public Object getClientGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) { - switch(ID) { - case LibGuiIDs.LEXICON : - GuiLexicon lex = GuiLexicon.currentOpenLexicon; - return lex; - case LibGuiIDs.CRAFTING_HALO : - return new GuiCraftingHalo(player.inventory, world); - case LibGuiIDs.FLOWER_BAG : - return new GuiFlowerBag(player); - case LibGuiIDs.BAUBLE_BOX : - return new GuiBaubleBox(player); - } + return null; + } - return null; - } + @Override + public Object getClientGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) { + switch (ID) { + case LibGuiIDs.LEXICON: + GuiLexicon lex = GuiLexicon.currentOpenLexicon; + return lex; + case LibGuiIDs.CRAFTING_HALO: + return new GuiCraftingHalo(player.inventory, world); + case LibGuiIDs.FLOWER_BAG: + return new GuiFlowerBag(player); + case LibGuiIDs.BAUBLE_BOX: + return new GuiBaubleBox(player); + } + return null; + } } diff --git a/src/main/java/vazkii/botania/common/world/SkyblockWorldEvents.java b/src/main/java/vazkii/botania/common/world/SkyblockWorldEvents.java index 5d84c82333..b746e607c9 100644 --- a/src/main/java/vazkii/botania/common/world/SkyblockWorldEvents.java +++ b/src/main/java/vazkii/botania/common/world/SkyblockWorldEvents.java @@ -2,19 +2,18 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jul 7, 2015, 6:14:18 PM (GMT)] */ package vazkii.botania.common.world; +import cpw.mods.fml.common.eventhandler.SubscribeEvent; import java.awt.Color; - import net.minecraft.block.Block; import net.minecraft.block.material.Material; -import net.minecraft.client.Minecraft; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayerMP; import net.minecraft.init.Blocks; @@ -24,167 +23,180 @@ import net.minecraft.util.ChunkCoordinates; import net.minecraft.util.MovingObjectPosition; import net.minecraft.world.World; -import net.minecraftforge.client.event.RenderWorldEvent; import net.minecraftforge.event.entity.living.LivingEvent.LivingUpdateEvent; import net.minecraftforge.event.entity.player.PlayerInteractEvent; import net.minecraftforge.event.entity.player.PlayerInteractEvent.Action; import net.minecraftforge.event.world.BlockEvent.HarvestDropsEvent; -import vazkii.botania.client.render.world.SkyblockSkyRenderer; import vazkii.botania.common.block.ModBlocks; import vazkii.botania.common.block.tile.TileManaFlame; import vazkii.botania.common.item.ModItems; import vazkii.botania.common.item.equipment.tool.ToolCommons; -import cpw.mods.fml.common.eventhandler.SubscribeEvent; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; public final class SkyblockWorldEvents { - private static final String TAG_MADE_ISLAND = "Botania-MadeIsland"; - private static final String TAG_HAS_OWN_ISLAND = "Botania-HasOwnIsland"; - private static final String TAG_ISLAND_X = "Botania-IslandX"; - private static final String TAG_ISLAND_Y = "Botania-IslandY"; - private static final String TAG_ISLAND_Z = "Botania-IslandZ"; - - @SubscribeEvent - public void onPlayerUpdate(LivingUpdateEvent event) { - if(event.entityLiving instanceof EntityPlayer && !event.entity.worldObj.isRemote) { - EntityPlayer player = (EntityPlayer) event.entityLiving; - NBTTagCompound data = player.getEntityData(); - if(!data.hasKey(EntityPlayer.PERSISTED_NBT_TAG)) - data.setTag(EntityPlayer.PERSISTED_NBT_TAG, new NBTTagCompound()); - - NBTTagCompound persist = data.getCompoundTag(EntityPlayer.PERSISTED_NBT_TAG); - if(player.ticksExisted > 3 && !persist.getBoolean(TAG_MADE_ISLAND)) { - World world = player.worldObj; - if(WorldTypeSkyblock.isWorldSkyblock(world)) { - ChunkCoordinates coords = world.getSpawnPoint(); - if(world.getBlock(coords.posX, coords.posY - 4, coords.posZ) != Blocks.bedrock && world.provider.dimensionId == 0) - spawnPlayer(player, coords.posX, coords.posY, coords.posZ, false); - } - - - persist.setBoolean(TAG_MADE_ISLAND, true); - } - } - } - - @SubscribeEvent - public void onPlayerInteract(PlayerInteractEvent event) { - if(WorldTypeSkyblock.isWorldSkyblock(event.world)) { - ItemStack equipped = event.entityPlayer.getCurrentEquippedItem(); - if(event.action == Action.RIGHT_CLICK_BLOCK && equipped == null && event.entityPlayer.isSneaking()) { - Block block = event.world.getBlock(event.x, event.y, event.z); - if(block == Blocks.grass || block == Blocks.dirt) { - if(event.world.isRemote) - event.entityPlayer.swingItem(); - else { - event.world.playSoundEffect(event.x + 0.5, event.y + 0.5, event.z + 0.5, block.stepSound.getBreakSound(), block.stepSound.getVolume() * 0.4F, block.stepSound.getPitch() + (float) (Math.random() * 0.2 - 0.1)); - if(Math.random() < 0.8) - event.entityPlayer.dropPlayerItemWithRandomChoice(new ItemStack(ModItems.manaResource, 1, 21), false); - } - } - } else if(equipped != null && equipped.getItem() == Items.bowl && event.action == Action.RIGHT_CLICK_BLOCK && !event.world.isRemote) { - MovingObjectPosition movingobjectposition = ToolCommons.raytraceFromEntity(event.world, event.entityPlayer, true, 4.5F); - - if(movingobjectposition != null) { - if (movingobjectposition.typeOfHit == MovingObjectPosition.MovingObjectType.BLOCK && !event.world.isRemote) { - int i = movingobjectposition.blockX; - int j = movingobjectposition.blockY; - int k = movingobjectposition.blockZ; - - if(event.world.getBlock(i, j, k).getMaterial() == Material.water) { - --equipped.stackSize; - - if(equipped.stackSize <= 0) - event.entityPlayer.inventory.setInventorySlotContents(event.entityPlayer.inventory.currentItem, new ItemStack(ModItems.waterBowl)); - else event.entityPlayer.dropPlayerItemWithRandomChoice(new ItemStack(ModItems.waterBowl), false); - } - } - } - } - } - } - - @SubscribeEvent - public void onDrops(HarvestDropsEvent event) { - if(WorldTypeSkyblock.isWorldSkyblock(event.world) && event.block == Blocks.tallgrass) { - ItemStack stackToRemove = null; - for(ItemStack stack : event.drops) - if(stack.getItem() == Items.wheat_seeds && event.world.rand.nextInt(4) == 0) { - stackToRemove = stack; - break; - } - - if(stackToRemove != null) { - event.drops.remove(stackToRemove); - event.drops.add(new ItemStack(event.world.rand.nextBoolean() ? Items.pumpkin_seeds : Items.melon_seeds)); - } - } - } - - public static void spawnPlayer(EntityPlayer player, int x, int y, int z, boolean fabricated) { - NBTTagCompound data = player.getEntityData(); - if(!data.hasKey(EntityPlayer.PERSISTED_NBT_TAG)) - data.setTag(EntityPlayer.PERSISTED_NBT_TAG, new NBTTagCompound()); - NBTTagCompound persist = data.getCompoundTag(EntityPlayer.PERSISTED_NBT_TAG); - - final boolean test = false; - - if(test || !persist.getBoolean(TAG_HAS_OWN_ISLAND)) { - createSkyblock(player.worldObj, x, y, z); - - if(player instanceof EntityPlayerMP) { - EntityPlayerMP pmp = (EntityPlayerMP) player; - pmp.setPositionAndUpdate(x + 0.5, y + 1.6, z + 0.5); - pmp.setSpawnChunk(new ChunkCoordinates(x, y, z), true); - player.inventory.addItemStackToInventory(new ItemStack(ModItems.lexicon)); - } - - if(fabricated) { - persist.setBoolean(TAG_HAS_OWN_ISLAND, true); - persist.setDouble(TAG_ISLAND_X, player.posX); - persist.setDouble(TAG_ISLAND_Y, player.posY); - persist.setDouble(TAG_ISLAND_Z, player.posZ); - } - } else { - double posX = persist.getDouble(TAG_ISLAND_X); - double posY = persist.getDouble(TAG_ISLAND_Y); - double posZ = persist.getDouble(TAG_ISLAND_Z); - - if(player instanceof EntityPlayerMP) { - EntityPlayerMP pmp = (EntityPlayerMP) player; - pmp.setPositionAndUpdate(posX, posY, posZ); - } - } - } - - public static void createSkyblock(World world, int x, int y, int z) { - for(int i = 0; i < 3; i++) - for(int j = 0; j < 4; j++) - for(int k = 0; k < 3; k++) - world.setBlock(x - 1 + i, y - 1 - j, z - 1 + k, j == 0 ? Blocks.grass : Blocks.dirt); - world.setBlock(x - 1, y - 2, z, Blocks.flowing_water); - world.setBlock(x + 1, y + 2, z + 1, ModBlocks.manaFlame); - ((TileManaFlame) world.getTileEntity(x + 1, y + 2, z + 1)).setColor(new Color(70 + world.rand.nextInt(185), 70 + world.rand.nextInt(185), 70 + world.rand.nextInt(185)).getRGB()); - - int[][] rootPositions = new int[][] { - { -1, -3, -1 }, - { -2, -4, -1 }, - { -2, -4, -2 }, - { +1, -4, -1 }, - { +1, -5, -1 }, - { +2, -5, -1 }, - { +2, -6, +0 }, - { +0, -4, +2 }, - { +0, -5, +2 }, - { +0, -5, +3 }, - { +0, -6, +3 }, - }; - for(int[] root : rootPositions) - world.setBlock(x + root[0], y + root[1], z + root[2], ModBlocks.root); - - world.setBlock(x, y - 4, z, Blocks.bedrock); - } - + private static final String TAG_MADE_ISLAND = "Botania-MadeIsland"; + private static final String TAG_HAS_OWN_ISLAND = "Botania-HasOwnIsland"; + private static final String TAG_ISLAND_X = "Botania-IslandX"; + private static final String TAG_ISLAND_Y = "Botania-IslandY"; + private static final String TAG_ISLAND_Z = "Botania-IslandZ"; + + @SubscribeEvent + public void onPlayerUpdate(LivingUpdateEvent event) { + if (event.entityLiving instanceof EntityPlayer && !event.entity.worldObj.isRemote) { + EntityPlayer player = (EntityPlayer) event.entityLiving; + NBTTagCompound data = player.getEntityData(); + if (!data.hasKey(EntityPlayer.PERSISTED_NBT_TAG)) + data.setTag(EntityPlayer.PERSISTED_NBT_TAG, new NBTTagCompound()); + + NBTTagCompound persist = data.getCompoundTag(EntityPlayer.PERSISTED_NBT_TAG); + if (player.ticksExisted > 3 && !persist.getBoolean(TAG_MADE_ISLAND)) { + World world = player.worldObj; + if (WorldTypeSkyblock.isWorldSkyblock(world)) { + ChunkCoordinates coords = world.getSpawnPoint(); + if (world.getBlock(coords.posX, coords.posY - 4, coords.posZ) != Blocks.bedrock + && world.provider.dimensionId == 0) + spawnPlayer(player, coords.posX, coords.posY, coords.posZ, false); + } + + persist.setBoolean(TAG_MADE_ISLAND, true); + } + } + } + + @SubscribeEvent + public void onPlayerInteract(PlayerInteractEvent event) { + if (WorldTypeSkyblock.isWorldSkyblock(event.world)) { + ItemStack equipped = event.entityPlayer.getCurrentEquippedItem(); + if (event.action == Action.RIGHT_CLICK_BLOCK && equipped == null && event.entityPlayer.isSneaking()) { + Block block = event.world.getBlock(event.x, event.y, event.z); + if (block == Blocks.grass || block == Blocks.dirt) { + if (event.world.isRemote) event.entityPlayer.swingItem(); + else { + event.world.playSoundEffect( + event.x + 0.5, + event.y + 0.5, + event.z + 0.5, + block.stepSound.getBreakSound(), + block.stepSound.getVolume() * 0.4F, + block.stepSound.getPitch() + (float) (Math.random() * 0.2 - 0.1)); + if (Math.random() < 0.8) + event.entityPlayer.dropPlayerItemWithRandomChoice( + new ItemStack(ModItems.manaResource, 1, 21), false); + } + } + } else if (equipped != null + && equipped.getItem() == Items.bowl + && event.action == Action.RIGHT_CLICK_BLOCK + && !event.world.isRemote) { + MovingObjectPosition movingobjectposition = + ToolCommons.raytraceFromEntity(event.world, event.entityPlayer, true, 4.5F); + + if (movingobjectposition != null) { + if (movingobjectposition.typeOfHit == MovingObjectPosition.MovingObjectType.BLOCK + && !event.world.isRemote) { + int i = movingobjectposition.blockX; + int j = movingobjectposition.blockY; + int k = movingobjectposition.blockZ; + + if (event.world.getBlock(i, j, k).getMaterial() == Material.water) { + --equipped.stackSize; + + if (equipped.stackSize <= 0) + event.entityPlayer.inventory.setInventorySlotContents( + event.entityPlayer.inventory.currentItem, new ItemStack(ModItems.waterBowl)); + else + event.entityPlayer.dropPlayerItemWithRandomChoice( + new ItemStack(ModItems.waterBowl), false); + } + } + } + } + } + } + + @SubscribeEvent + public void onDrops(HarvestDropsEvent event) { + if (WorldTypeSkyblock.isWorldSkyblock(event.world) && event.block == Blocks.tallgrass) { + ItemStack stackToRemove = null; + for (ItemStack stack : event.drops) + if (stack.getItem() == Items.wheat_seeds && event.world.rand.nextInt(4) == 0) { + stackToRemove = stack; + break; + } + + if (stackToRemove != null) { + event.drops.remove(stackToRemove); + event.drops.add( + new ItemStack(event.world.rand.nextBoolean() ? Items.pumpkin_seeds : Items.melon_seeds)); + } + } + } + + public static void spawnPlayer(EntityPlayer player, int x, int y, int z, boolean fabricated) { + NBTTagCompound data = player.getEntityData(); + if (!data.hasKey(EntityPlayer.PERSISTED_NBT_TAG)) + data.setTag(EntityPlayer.PERSISTED_NBT_TAG, new NBTTagCompound()); + NBTTagCompound persist = data.getCompoundTag(EntityPlayer.PERSISTED_NBT_TAG); + + final boolean test = false; + + if (test || !persist.getBoolean(TAG_HAS_OWN_ISLAND)) { + createSkyblock(player.worldObj, x, y, z); + + if (player instanceof EntityPlayerMP) { + EntityPlayerMP pmp = (EntityPlayerMP) player; + pmp.setPositionAndUpdate(x + 0.5, y + 1.6, z + 0.5); + pmp.setSpawnChunk(new ChunkCoordinates(x, y, z), true); + player.inventory.addItemStackToInventory(new ItemStack(ModItems.lexicon)); + } + + if (fabricated) { + persist.setBoolean(TAG_HAS_OWN_ISLAND, true); + persist.setDouble(TAG_ISLAND_X, player.posX); + persist.setDouble(TAG_ISLAND_Y, player.posY); + persist.setDouble(TAG_ISLAND_Z, player.posZ); + } + } else { + double posX = persist.getDouble(TAG_ISLAND_X); + double posY = persist.getDouble(TAG_ISLAND_Y); + double posZ = persist.getDouble(TAG_ISLAND_Z); + + if (player instanceof EntityPlayerMP) { + EntityPlayerMP pmp = (EntityPlayerMP) player; + pmp.setPositionAndUpdate(posX, posY, posZ); + } + } + } + + public static void createSkyblock(World world, int x, int y, int z) { + for (int i = 0; i < 3; i++) + for (int j = 0; j < 4; j++) + for (int k = 0; k < 3; k++) + world.setBlock(x - 1 + i, y - 1 - j, z - 1 + k, j == 0 ? Blocks.grass : Blocks.dirt); + world.setBlock(x - 1, y - 2, z, Blocks.flowing_water); + world.setBlock(x + 1, y + 2, z + 1, ModBlocks.manaFlame); + ((TileManaFlame) world.getTileEntity(x + 1, y + 2, z + 1)) + .setColor(new Color( + 70 + world.rand.nextInt(185), + 70 + world.rand.nextInt(185), + 70 + world.rand.nextInt(185)) + .getRGB()); + + int[][] rootPositions = new int[][] { + {-1, -3, -1}, + {-2, -4, -1}, + {-2, -4, -2}, + {+1, -4, -1}, + {+1, -5, -1}, + {+2, -5, -1}, + {+2, -6, +0}, + {+0, -4, +2}, + {+0, -5, +2}, + {+0, -5, +3}, + {+0, -6, +3}, + }; + for (int[] root : rootPositions) world.setBlock(x + root[0], y + root[1], z + root[2], ModBlocks.root); + + world.setBlock(x, y - 4, z, Blocks.bedrock); + } } diff --git a/src/main/java/vazkii/botania/common/world/WorldTypeSkyblock.java b/src/main/java/vazkii/botania/common/world/WorldTypeSkyblock.java index 98d7f4ee51..f3127a8595 100644 --- a/src/main/java/vazkii/botania/common/world/WorldTypeSkyblock.java +++ b/src/main/java/vazkii/botania/common/world/WorldTypeSkyblock.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jul 7, 2015, 2:06:01 AM (GMT)] */ package vazkii.botania.common.world; @@ -14,46 +14,44 @@ import net.minecraft.world.WorldType; import net.minecraft.world.chunk.IChunkProvider; import net.minecraft.world.gen.ChunkProviderFlat; -import net.minecraftforge.common.MinecraftForge; public class WorldTypeSkyblock extends WorldType { - public WorldTypeSkyblock() { - super("botania-skyblock"); - } - - public static boolean isWorldSkyblock(World world) { - return world.getWorldInfo().getTerrainType() instanceof WorldTypeSkyblock; - } - - @Override - public boolean showWorldInfoNotice() { - return true; - } - - @Override - public boolean hasVoidParticles(boolean flag) { - return false; - } - - @Override - public int getMinimumSpawnHeight(World world) { - return 86; - } - - @Override - public int getSpawnFuzz() { - return 1; - } - - @Override - public float getCloudHeight() { - return 260f; - } - - @Override - public IChunkProvider getChunkGenerator(World world, String generatorOptions) { - return new ChunkProviderFlat(world, world.getSeed(), false, "2;1x0;"); - } - + public WorldTypeSkyblock() { + super("botania-skyblock"); + } + + public static boolean isWorldSkyblock(World world) { + return world.getWorldInfo().getTerrainType() instanceof WorldTypeSkyblock; + } + + @Override + public boolean showWorldInfoNotice() { + return true; + } + + @Override + public boolean hasVoidParticles(boolean flag) { + return false; + } + + @Override + public int getMinimumSpawnHeight(World world) { + return 86; + } + + @Override + public int getSpawnFuzz() { + return 1; + } + + @Override + public float getCloudHeight() { + return 260f; + } + + @Override + public IChunkProvider getChunkGenerator(World world, String generatorOptions) { + return new ChunkProviderFlat(world, world.getSeed(), false, "2;1x0;"); + } } From 443aa9733b2e7c4c93b79a4ca85e238162f6b01b Mon Sep 17 00:00:00 2001 From: miozune Date: Fri, 19 Aug 2022 16:50:37 +0900 Subject: [PATCH 3/5] Revert "updateBuildScript & spotlessApply" This reverts commit 9bf784e82c1ce44765e92dc7d6568b9ed9180361. --- build.gradle | 435 +- settings.gradle | 10 - .../java/vazkii/botania/api/BotaniaAPI.java | 1258 ++-- .../vazkii/botania/api/boss/IBotaniaBoss.java | 65 +- .../api/boss/IBotaniaBossWithShader.java | 35 +- .../java/vazkii/botania/api/brew/Brew.java | 206 +- .../botania/api/brew/IBrewContainer.java | 27 +- .../vazkii/botania/api/brew/IBrewItem.java | 7 +- .../botania/api/corporea/CorporeaHelper.java | 584 +- .../botania/api/corporea/CorporeaRequest.java | 27 +- .../api/corporea/CorporeaRequestEvent.java | 36 +- .../ICorporeaAutoCompleteController.java | 15 +- .../api/corporea/ICorporeaInterceptor.java | 44 +- .../api/corporea/ICorporeaRequestor.java | 13 +- .../botania/api/corporea/ICorporeaSpark.java | 114 +- .../api/corporea/IWrappedInventory.java | 65 +- .../api/internal/DummyManaNetwork.java | 48 +- .../api/internal/DummyMethodHandler.java | 399 +- .../botania/api/internal/DummyPage.java | 23 +- .../botania/api/internal/DummySubTile.java | 8 +- .../api/internal/IGuiLexiconEntry.java | 97 +- .../api/internal/IInternalMethodHandler.java | 111 +- .../botania/api/internal/IManaBurst.java | 56 +- .../botania/api/internal/IManaNetwork.java | 79 +- .../botania/api/internal/ShaderCallback.java | 7 +- .../api/internal/VanillaPacketDispatcher.java | 41 +- .../api/item/IAncientWillContainer.java | 9 +- .../vazkii/botania/api/item/IAvatarTile.java | 23 +- .../botania/api/item/IAvatarWieldable.java | 21 +- .../botania/api/item/IBaubleRender.java | 92 +- .../botania/api/item/IBlockProvider.java | 34 +- .../botania/api/item/IBurstViewerBauble.java | 8 +- .../botania/api/item/ICosmeticAttachable.java | 21 +- .../botania/api/item/ICosmeticBauble.java | 8 +- .../vazkii/botania/api/item/IDyablePool.java | 11 +- .../botania/api/item/IExoflameHeatable.java | 47 +- .../api/item/IExtendedPlayerController.java | 20 +- ...tendedWireframeCoordinateListProvider.java | 13 +- .../botania/api/item/IFlowerPlaceable.java | 15 +- .../botania/api/item/IFlowerlessBiome.java | 12 +- .../botania/api/item/IFlowerlessWorld.java | 12 +- .../botania/api/item/IGrassHornExcempt.java | 7 +- .../botania/api/item/IHornHarvestable.java | 88 +- .../botania/api/item/IManaDissolvable.java | 15 +- .../api/item/IManaProficiencyArmor.java | 34 +- .../botania/api/item/IPetalApothecary.java | 21 +- .../botania/api/item/IPhantomInkable.java | 9 +- .../botania/api/item/IPixieSpawner.java | 17 +- .../java/vazkii/botania/api/item/IRelic.java | 37 +- .../botania/api/item/ISequentialBreaker.java | 10 +- .../botania/api/item/ISortableTool.java | 55 +- .../IWireframeCoordinateListProvider.java | 22 +- .../api/item/TinyPotatoRenderEvent.java | 31 +- .../lexicon/BotaniaTutorialStartEvent.java | 16 +- .../botania/api/lexicon/IAddonEntry.java | 15 +- .../vazkii/botania/api/lexicon/ILexicon.java | 19 +- .../botania/api/lexicon/ILexiconable.java | 13 +- .../api/lexicon/IRecipeKeyProvider.java | 7 +- .../botania/api/lexicon/ITwoNamedPage.java | 9 +- .../botania/api/lexicon/KnowledgeType.java | 22 +- .../botania/api/lexicon/LexiconCategory.java | 99 +- .../botania/api/lexicon/LexiconEntry.java | 289 +- .../botania/api/lexicon/LexiconPage.java | 189 +- .../api/lexicon/LexiconRecipeMappings.java | 83 +- .../multiblock/IMultiblockRenderHook.java | 19 +- .../api/lexicon/multiblock/Multiblock.java | 306 +- .../api/lexicon/multiblock/MultiblockSet.java | 38 +- .../multiblock/component/AnyComponent.java | 21 +- .../component/ColorSwitchingComponent.java | 35 +- .../multiblock/component/FlowerComponent.java | 27 +- .../component/MultiblockComponent.java | 147 +- .../botania/api/mana/BurstProperties.java | 39 +- .../botania/api/mana/IClientManaHandler.java | 8 +- .../botania/api/mana/ICompositableLens.java | 23 +- .../api/mana/ICreativeManaProvider.java | 8 +- .../vazkii/botania/api/mana/IDirectioned.java | 9 +- .../botania/api/mana/IIdentifiable.java | 7 +- .../vazkii/botania/api/mana/IKeyLocked.java | 13 +- .../botania/api/mana/ILaputaImmobile.java | 7 +- .../java/vazkii/botania/api/mana/ILens.java | 39 +- .../vazkii/botania/api/mana/ILensControl.java | 25 +- .../vazkii/botania/api/mana/ILensEffect.java | 48 +- .../vazkii/botania/api/mana/IManaBlock.java | 13 +- .../botania/api/mana/IManaCollector.java | 35 +- .../botania/api/mana/IManaCollisionGhost.java | 7 +- .../botania/api/mana/IManaDiscountArmor.java | 19 +- .../botania/api/mana/IManaGivingItem.java | 8 +- .../vazkii/botania/api/mana/IManaItem.java | 81 +- .../vazkii/botania/api/mana/IManaPool.java | 17 +- .../botania/api/mana/IManaReceiver.java | 31 +- .../botania/api/mana/IManaSpreader.java | 16 +- .../botania/api/mana/IManaTooltipDisplay.java | 13 +- .../vazkii/botania/api/mana/IManaTrigger.java | 7 +- .../botania/api/mana/IManaUsingItem.java | 7 +- .../vazkii/botania/api/mana/IPingable.java | 20 +- .../api/mana/IPoolOverlayProvider.java | 7 +- .../botania/api/mana/IRedirectable.java | 18 +- .../botania/api/mana/IThrottledPacket.java | 7 +- .../botania/api/mana/ITinyPlanetExcempt.java | 7 +- .../botania/api/mana/ManaItemHandler.java | 459 +- .../botania/api/mana/ManaNetworkEvent.java | 82 +- .../botania/api/mana/TileSignature.java | 13 +- .../api/mana/spark/ISparkAttachable.java | 77 +- .../botania/api/mana/spark/ISparkEntity.java | 91 +- .../botania/api/mana/spark/SparkHelper.java | 25 +- .../java/vazkii/botania/api/package-info.java | 2 +- .../api/recipe/ElvenPortalUpdateEvent.java | 33 +- .../vazkii/botania/api/recipe/IElvenItem.java | 3 +- .../botania/api/recipe/IFlowerComponent.java | 9 +- .../vazkii/botania/api/recipe/RecipeBrew.java | 174 +- .../botania/api/recipe/RecipeElvenTrade.java | 156 +- .../api/recipe/RecipeManaInfusion.java | 131 +- .../botania/api/recipe/RecipeMiniFlower.java | 30 +- .../botania/api/recipe/RecipePetals.java | 145 +- .../botania/api/recipe/RecipePureDaisy.java | 146 +- .../botania/api/recipe/RecipeRuneAltar.java | 21 +- .../botania/api/subtile/ISpecialFlower.java | 8 +- .../api/subtile/ISubTileContainer.java | 23 +- .../subtile/ISubTileSlowableContainer.java | 13 +- .../botania/api/subtile/RadiusDescriptor.java | 142 +- .../botania/api/subtile/SubTileEntity.java | 418 +- .../api/subtile/SubTileFunctional.java | 409 +- .../api/subtile/SubTileGenerating.java | 606 +- .../api/subtile/signature/BasicSignature.java | 86 +- .../api/subtile/signature/PassiveFlower.java | 8 +- .../subtile/signature/SubTileSignature.java | 66 +- .../botania/api/wand/ICoordBoundItem.java | 9 +- .../vazkii/botania/api/wand/ITileBound.java | 17 +- .../botania/api/wand/IWandBindable.java | 23 +- .../vazkii/botania/api/wand/IWandHUD.java | 7 +- .../vazkii/botania/api/wand/IWandable.java | 15 +- .../api/wand/IWireframeAABBProvider.java | 7 +- .../botania/api/wiki/IWikiProvider.java | 29 +- .../botania/api/wiki/SimpleWikiProvider.java | 133 +- .../vazkii/botania/api/wiki/WikiHooks.java | 38 +- .../botania/client/challenge/Challenge.java | 35 +- .../client/challenge/EnumChallengeLevel.java | 28 +- .../client/challenge/ModChallenges.java | 77 +- .../core/handler/BaubleRenderHandler.java | 224 +- .../client/core/handler/BossBarHandler.java | 168 +- .../core/handler/BotaniaPlayerController.java | 41 +- .../core/handler/BoundTileRenderer.java | 301 +- .../core/handler/ClientTickHandler.java | 153 +- .../handler/ContributorFancinessHandler.java | 324 +- .../handler/CorporeaAutoCompleteHandler.java | 304 +- .../client/core/handler/DebugHandler.java | 72 +- .../client/core/handler/HUDHandler.java | 875 ++- .../handler/ItemsRemainingRenderHandler.java | 163 +- .../client/core/handler/LightningHandler.java | 998 ++- .../core/handler/MultiblockBlockAccess.java | 175 +- .../core/handler/MultiblockRenderHandler.java | 305 +- .../handler/PersistentVariableHelper.java | 267 +- .../core/handler/RedStringRenderer.java | 175 +- .../handler/SubTileRadiusRenderHandler.java | 266 +- .../TooltipAdditionDisplayHandler.java | 388 +- .../client/core/handler/TooltipHandler.java | 36 +- .../client/core/helper/FontHelper.java | 45 +- .../client/core/helper/IconHelper.java | 67 +- .../client/core/helper/RenderHelper.java | 446 +- .../client/core/helper/ShaderHelper.java | 329 +- .../client/core/proxy/ClientProxy.java | 735 +-- .../botania/client/core/proxy/GuiFactory.java | 46 +- .../vazkii/botania/client/fx/FXSparkle.java | 457 +- .../java/vazkii/botania/client/fx/FXWisp.java | 291 +- .../client/fx/ParticleRenderDispatcher.java | 68 +- .../client/gui/GuiAchievementsHacky.java | 25 +- .../botania/client/gui/GuiBotaniaConfig.java | 19 +- .../vazkii/botania/client/gui/SlotLocked.java | 27 +- .../client/gui/bag/ContainerFlowerBag.java | 149 +- .../botania/client/gui/bag/GuiFlowerBag.java | 80 +- .../client/gui/bag/InventoryFlowerBag.java | 274 +- .../botania/client/gui/bag/SlotFlower.java | 35 +- .../client/gui/box/ContainerBaubleBox.java | 193 +- .../botania/client/gui/box/GuiBaubleBox.java | 67 +- .../client/gui/box/InventoryBaubleBox.java | 274 +- .../botania/client/gui/box/SlotAnyBauble.java | 33 +- .../gui/crafting/ContainerCraftingHalo.java | 81 +- .../client/gui/crafting/GuiCraftingHalo.java | 47 +- .../gui/crafting/InventoryCraftingHalo.java | 11 +- .../client/gui/lexicon/GuiLexicon.java | 1191 ++-- .../gui/lexicon/GuiLexiconChallenge.java | 313 +- .../gui/lexicon/GuiLexiconChallengesList.java | 250 +- .../client/gui/lexicon/GuiLexiconEntry.java | 754 +-- .../client/gui/lexicon/GuiLexiconHistory.java | 83 +- .../client/gui/lexicon/GuiLexiconIndex.java | 882 +-- .../botania/client/gui/lexicon/IParented.java | 3 +- .../lexicon/button/GuiButtonAchievement.java | 42 +- .../gui/lexicon/button/GuiButtonBack.java | 56 +- .../button/GuiButtonBackWithShift.java | 22 +- .../gui/lexicon/button/GuiButtonBookmark.java | 54 +- .../gui/lexicon/button/GuiButtonCategory.java | 207 +- .../button/GuiButtonChallengeIcon.java | 75 +- .../button/GuiButtonChallengeInfo.java | 40 +- .../lexicon/button/GuiButtonChallenges.java | 42 +- .../gui/lexicon/button/GuiButtonDoot.java | 60 +- .../gui/lexicon/button/GuiButtonHistory.java | 40 +- .../lexicon/button/GuiButtonInvisible.java | 189 +- .../gui/lexicon/button/GuiButtonLexicon.java | 20 +- .../gui/lexicon/button/GuiButtonNotes.java | 66 +- .../gui/lexicon/button/GuiButtonOptions.java | 43 +- .../gui/lexicon/button/GuiButtonPage.java | 55 +- .../gui/lexicon/button/GuiButtonShare.java | 43 +- .../button/GuiButtonUpdateWarning.java | 56 +- .../lexicon/button/GuiButtonViewOnline.java | 45 +- .../integration/nei/NEIBotaniaConfig.java | 72 +- .../client/integration/nei/NEIGuiHooks.java | 15 +- .../integration/nei/NEIInputHandler.java | 161 +- .../nei/recipe/RecipeHandlerBrewery.java | 226 +- .../nei/recipe/RecipeHandlerElvenTrade.java | 288 +- .../recipe/RecipeHandlerFloatingFlowers.java | 126 +- .../recipe/RecipeHandlerLexicaBotania.java | 260 +- .../nei/recipe/RecipeHandlerManaPool.java | 229 +- .../recipe/RecipeHandlerPetalApothecary.java | 241 +- .../nei/recipe/RecipeHandlerPureDaisy.java | 204 +- .../nei/recipe/RecipeHandlerRunicAltar.java | 86 +- .../botania/client/lib/LibRenderIDs.java | 45 +- .../botania/client/lib/LibResources.java | 293 +- .../botania/client/model/IPylonModel.java | 11 +- .../botania/client/model/ModelAltar.java | 138 +- .../botania/client/model/ModelAvatar.java | 99 +- .../botania/client/model/ModelBellows.java | 136 +- .../client/model/ModelBlackHoleCube.java | 165 +- .../botania/client/model/ModelBrewery.java | 164 +- .../botania/client/model/ModelCocoon.java | 27 +- .../client/model/ModelCrystalCube.java | 64 +- .../botania/client/model/ModelHourglass.java | 155 +- .../client/model/ModelIncensePlate.java | 47 +- .../botania/client/model/ModelMiniIsland.java | 127 +- .../botania/client/model/ModelPixie.java | 95 +- .../botania/client/model/ModelPool.java | 80 +- .../botania/client/model/ModelPump.java | 85 +- .../botania/client/model/ModelPylon.java | 37 +- .../botania/client/model/ModelPylonOld.java | 273 +- .../client/model/ModelSkullOverride.java | 61 +- .../client/model/ModelSpawnerClaw.java | 127 +- .../client/model/ModelSpinningCubes.java | 138 +- .../botania/client/model/ModelSpreader.java | 146 +- .../client/model/ModelTeruTeruBozu.java | 75 +- .../botania/client/model/ModelTinyPotato.java | 29 +- .../model/armor/ModelArmorElementium.java | 469 +- .../model/armor/ModelArmorManasteel.java | 349 +- .../model/armor/ModelArmorManaweave.java | 329 +- .../model/armor/ModelArmorTerrasteel.java | 507 +- .../client/render/block/InterpolatedIcon.java | 98 +- .../client/render/block/RenderAltar.java | 57 +- .../client/render/block/RenderAvatar.java | 54 +- .../client/render/block/RenderBellows.java | 56 +- .../client/render/block/RenderBrewery.java | 60 +- .../client/render/block/RenderCocoon.java | 54 +- .../block/RenderCorporeaCrystalCube.java | 58 +- .../render/block/RenderCorporeaIndex.java | 60 +- .../render/block/RenderDoubleFlower.java | 99 +- .../render/block/RenderFloatingFlower.java | 40 +- .../client/render/block/RenderHourglass.java | 58 +- .../render/block/RenderIncensePlate.java | 60 +- .../client/render/block/RenderPool.java | 58 +- .../client/render/block/RenderPump.java | 54 +- .../client/render/block/RenderPylon.java | 58 +- .../render/block/RenderSpawnerClaw.java | 54 +- .../render/block/RenderSpecialFlower.java | 242 +- .../client/render/block/RenderSpreader.java | 66 +- .../render/block/RenderTeruTeruBozu.java | 54 +- .../client/render/block/RenderTinyPotato.java | 54 +- .../render/entity/RenderBabylonWeapon.java | 156 +- .../render/entity/RenderCorporeaSpark.java | 161 +- .../render/entity/RenderDoppleganger.java | 129 +- .../client/render/entity/RenderManaStorm.java | 42 +- .../render/entity/RenderPinkWither.java | 39 +- .../client/render/entity/RenderPixie.java | 113 +- .../render/entity/RenderPoolMinecart.java | 18 +- .../client/render/entity/RenderSpark.java | 17 +- .../client/render/entity/RenderSparkBase.java | 180 +- .../render/entity/RenderThornChakram.java | 94 +- .../botania/client/render/item/RenderBow.java | 127 +- .../render/item/RenderFloatingFlowerItem.java | 61 +- .../client/render/item/RenderLens.java | 194 +- .../client/render/item/RenderLexicon.java | 184 +- .../render/item/RenderTransparentItem.java | 104 +- .../render/tile/RenderTileAlfPortal.java | 96 +- .../client/render/tile/RenderTileAltar.java | 334 +- .../client/render/tile/RenderTileAvatar.java | 157 +- .../client/render/tile/RenderTileBellows.java | 51 +- .../client/render/tile/RenderTileBrewery.java | 149 +- .../client/render/tile/RenderTileCocoon.java | 66 +- .../tile/RenderTileCorporeaCrystalCube.java | 172 +- .../render/tile/RenderTileCorporeaIndex.java | 89 +- .../render/tile/RenderTileEnchanter.java | 184 +- .../render/tile/RenderTileFloatingFlower.java | 86 +- .../render/tile/RenderTileHourglass.java | 82 +- .../render/tile/RenderTileIncensePlate.java | 107 +- .../render/tile/RenderTileLightRelay.java | 120 +- .../client/render/tile/RenderTilePool.java | 258 +- .../client/render/tile/RenderTilePrism.java | 52 +- .../client/render/tile/RenderTilePump.java | 51 +- .../client/render/tile/RenderTilePylon.java | 210 +- .../render/tile/RenderTileRedString.java | 15 +- .../render/tile/RenderTileRuneAltar.java | 206 +- .../render/tile/RenderTileSkullOverride.java | 138 +- .../render/tile/RenderTileSparkChanger.java | 79 +- .../render/tile/RenderTileSpawnerClaw.java | 39 +- .../render/tile/RenderTileSpreader.java | 196 +- .../render/tile/RenderTileStarfield.java | 186 +- .../render/tile/RenderTileTerraPlate.java | 91 +- .../render/tile/RenderTileTeruTeruBozu.java | 76 +- .../render/tile/RenderTileTinyPotato.java | 667 +- .../render/world/SkyblockRenderEvents.java | 26 +- .../render/world/SkyblockSkyRenderer.java | 685 +- .../java/vazkii/botania/common/Botania.java | 158 +- .../botania/common/CustomBotaniaAPI.java | 6 +- .../common/achievement/AchievementMod.java | 33 +- .../achievement/AchievementTriggerer.java | 43 +- .../common/achievement/ICraftAchievement.java | 7 +- .../achievement/IPickupAchievement.java | 7 +- .../common/achievement/ModAchievements.java | 352 +- .../botania/common/block/BlockAlfPortal.java | 78 +- .../botania/common/block/BlockAltGrass.java | 259 +- .../botania/common/block/BlockAltar.java | 503 +- .../botania/common/block/BlockAvatar.java | 289 +- .../botania/common/block/BlockBifrost.java | 157 +- .../common/block/BlockBifrostPerm.java | 103 +- .../common/block/BlockCacophonium.java | 142 +- .../botania/common/block/BlockCamo.java | 248 +- .../botania/common/block/BlockCell.java | 46 +- .../botania/common/block/BlockCocoon.java | 122 +- .../botania/common/block/BlockDreamwood.java | 24 +- .../common/block/BlockEnchantedSoil.java | 111 +- .../botania/common/block/BlockEnderEye.java | 71 +- .../botania/common/block/BlockFakeAir.java | 170 +- .../botania/common/block/BlockFelPumpkin.java | 149 +- .../block/BlockFloatingSpecialFlower.java | 273 +- .../botania/common/block/BlockForestEye.java | 92 +- .../botania/common/block/BlockGaiaHead.java | 139 +- .../botania/common/block/BlockGhostRail.java | 108 +- .../botania/common/block/BlockHourglass.java | 334 +- .../common/block/BlockIncensePlate.java | 241 +- .../common/block/BlockLightLauncher.java | 117 +- .../botania/common/block/BlockLightRelay.java | 237 +- .../botania/common/block/BlockLivingrock.java | 100 +- .../botania/common/block/BlockLivingwood.java | 152 +- .../botania/common/block/BlockManaBomb.java | 53 +- .../vazkii/botania/common/block/BlockMod.java | 80 +- .../common/block/BlockModContainer.java | 85 +- .../common/block/BlockModDoubleFlower.java | 443 +- .../botania/common/block/BlockModFlower.java | 242 +- .../botania/common/block/BlockOpenCrate.java | 350 +- .../common/block/BlockPistonRelay.java | 502 +- .../botania/common/block/BlockPlatform.java | 167 +- .../botania/common/block/BlockPylon.java | 162 +- .../botania/common/block/BlockRoot.java | 59 +- .../botania/common/block/BlockSolidVines.java | 74 +- .../common/block/BlockSparkChanger.java | 294 +- .../common/block/BlockSpecialFlower.java | 458 +- .../botania/common/block/BlockStorage.java | 104 +- .../common/block/BlockTeruTeruBozu.java | 203 +- .../botania/common/block/BlockTinyPlanet.java | 63 +- .../botania/common/block/ModBlocks.java | 693 +- .../botania/common/block/ModFluffBlocks.java | 681 +- .../botania/common/block/ModMultiblocks.java | 25 +- .../block/corporea/BlockCorporeaBase.java | 115 +- .../corporea/BlockCorporeaCrystalCube.java | 150 +- .../block/corporea/BlockCorporeaFunnel.java | 73 +- .../block/corporea/BlockCorporeaIndex.java | 71 +- .../corporea/BlockCorporeaInterceptor.java | 85 +- .../block/corporea/BlockCorporeaRetainer.java | 79 +- .../common/block/decor/Block18Stone.java | 94 +- .../common/block/decor/BlockBlaze.java | 46 +- .../common/block/decor/BlockBuriedPetals.java | 92 +- .../common/block/decor/BlockCustomBrick.java | 100 +- .../common/block/decor/BlockDirtPath.java | 121 +- .../common/block/decor/BlockElfGlass.java | 65 +- .../block/decor/BlockEndStoneBrick.java | 97 +- .../block/decor/BlockFloatingFlower.java | 261 +- .../common/block/decor/BlockManaBeacon.java | 157 +- .../common/block/decor/BlockManaFlame.java | 180 +- .../common/block/decor/BlockManaGlass.java | 69 +- .../common/block/decor/BlockModMushroom.java | 233 +- .../common/block/decor/BlockPavement.java | 96 +- .../common/block/decor/BlockPetalBlock.java | 83 +- .../common/block/decor/BlockPrismarine.java | 126 +- .../common/block/decor/BlockReeds.java | 74 +- .../common/block/decor/BlockSeaLamp.java | 43 +- .../common/block/decor/BlockShimmerrock.java | 62 +- .../block/decor/BlockShimmerwoodPlanks.java | 62 +- .../common/block/decor/BlockShinyFlower.java | 103 +- .../common/block/decor/BlockStarfield.java | 74 +- .../common/block/decor/BlockThatch.java | 25 +- .../common/block/decor/BlockTinyPotato.java | 213 +- .../common/block/decor/BlockUnstable.java | 146 +- .../common/block/decor/IFloatingFlower.java | 111 +- .../decor/biomestone/BlockBiomeStone.java | 102 +- .../decor/biomestone/BlockBiomeStoneA.java | 19 +- .../decor/biomestone/BlockBiomeStoneB.java | 11 +- .../block/decor/panes/BlockAlfglassPane.java | 11 +- .../block/decor/panes/BlockBifrostPane.java | 46 +- .../block/decor/panes/BlockManaglassPane.java | 11 +- .../block/decor/panes/BlockModPane.java | 112 +- .../decor/quartz/BlockSpecialQuartz.java | 251 +- .../decor/quartz/BlockSpecialQuartzSlab.java | 156 +- .../quartz/BlockSpecialQuartzStairs.java | 23 +- .../block/decor/slabs/Block18StoneSlab.java | 51 +- .../decor/slabs/BlockBiomeStoneSlab.java | 51 +- .../block/decor/slabs/BlockDirtPathSlab.java | 37 +- .../block/decor/slabs/BlockEndStoneSlab.java | 41 +- .../decor/slabs/BlockEnderBrickSlab.java | 41 +- .../block/decor/slabs/BlockLivingSlab.java | 34 +- .../block/decor/slabs/BlockModSlab.java | 118 +- .../block/decor/slabs/BlockPavementSlab.java | 52 +- .../block/decor/slabs/BlockReedSlab.java | 46 +- .../block/decor/slabs/BlockThatchSlab.java | 46 +- .../slabs/bricks/BlockCustomBrickSlab.java | 57 +- .../slabs/bricks/BlockSnowBrickSlab.java | 29 +- .../slabs/bricks/BlockSoulBrickSlab.java | 27 +- .../decor/slabs/bricks/BlockTileSlab.java | 27 +- .../slabs/living/BlockDreamwoodPlankSlab.java | 25 +- .../slabs/living/BlockDreamwoodSlab.java | 25 +- .../living/BlockLivingrockBrickSlab.java | 29 +- .../slabs/living/BlockLivingrockSlab.java | 29 +- .../living/BlockLivingwoodPlankSlab.java | 25 +- .../slabs/living/BlockLivingwoodSlab.java | 25 +- .../slabs/living/BlockShimmerrockSlab.java | 33 +- .../living/BlockShimmerwoodPlankSlab.java | 32 +- .../prismarine/BlockDarkPrismarineSlab.java | 23 +- .../prismarine/BlockPrismarineBrickSlab.java | 23 +- .../slabs/prismarine/BlockPrismarineSlab.java | 51 +- .../decor/stairs/Block18StoneStairs.java | 19 +- .../decor/stairs/BlockBiomeStoneStairs.java | 19 +- .../decor/stairs/BlockEndStoneStairs.java | 19 +- .../decor/stairs/BlockEnderBrickStairs.java | 19 +- .../block/decor/stairs/BlockLivingStairs.java | 7 +- .../block/decor/stairs/BlockModStairs.java | 33 +- .../decor/stairs/BlockPavementStairs.java | 19 +- .../block/decor/stairs/BlockReedStairs.java | 20 +- .../block/decor/stairs/BlockThatchStairs.java | 20 +- .../stairs/bricks/BlockCustomBrickStairs.java | 21 +- .../stairs/bricks/BlockSnowBrickStairs.java | 11 +- .../stairs/bricks/BlockSoulBrickStairs.java | 11 +- .../decor/stairs/bricks/BlockTileStairs.java | 11 +- .../living/BlockDreamwoodPlankStairs.java | 7 +- .../stairs/living/BlockDreamwoodStairs.java | 7 +- .../living/BlockLivingrockBrickStairs.java | 7 +- .../stairs/living/BlockLivingrockStairs.java | 7 +- .../living/BlockLivingwoodPlankStairs.java | 7 +- .../stairs/living/BlockLivingwoodStairs.java | 7 +- .../stairs/living/BlockShimmerrockStairs.java | 11 +- .../living/BlockShimmerwoodPlankStairs.java | 11 +- .../prismarine/BlockDarkPrismarineStairs.java | 8 +- .../BlockPrismarineBrickStairs.java | 8 +- .../prismarine/BlockPrismarineStairs.java | 21 +- .../block/decor/walls/Block18StoneWall.java | 23 +- .../decor/walls/BlockBiomeStoneWall.java | 23 +- .../block/decor/walls/BlockModWall.java | 80 +- .../decor/walls/BlockPrismarineWall.java | 25 +- .../block/decor/walls/BlockReedWall.java | 15 +- .../block/decor/walls/BlockVariantWall.java | 64 +- .../walls/living/BlockDreamwoodWall.java | 15 +- .../walls/living/BlockLivingrockWall.java | 17 +- .../walls/living/BlockLivingwoodWall.java | 15 +- .../dispenser/BehaviourPoolMinecart.java | 75 +- .../block/dispenser/BehaviourSeeds.java | 41 +- .../common/block/dispenser/BehaviourWand.java | 43 +- .../block/mana/BlockAlchemyCatalyst.java | 62 +- .../common/block/mana/BlockBellows.java | 107 +- .../common/block/mana/BlockBrewery.java | 275 +- .../block/mana/BlockConjurationCatalyst.java | 18 +- .../common/block/mana/BlockDistributor.java | 65 +- .../common/block/mana/BlockEnchanter.java | 253 +- .../common/block/mana/BlockForestDrum.java | 292 +- .../common/block/mana/BlockManaDetector.java | 90 +- .../common/block/mana/BlockManaVoid.java | 65 +- .../botania/common/block/mana/BlockPool.java | 320 +- .../botania/common/block/mana/BlockPrism.java | 318 +- .../botania/common/block/mana/BlockPump.java | 163 +- .../common/block/mana/BlockRFGenerator.java | 51 +- .../common/block/mana/BlockRuneAltar.java | 273 +- .../common/block/mana/BlockSpawnerClaw.java | 80 +- .../common/block/mana/BlockSpreader.java | 434 +- .../common/block/mana/BlockTerraPlate.java | 183 +- .../common/block/mana/BlockTurntable.java | 72 +- .../common/block/string/BlockRedString.java | 87 +- .../string/BlockRedStringComparator.java | 35 +- .../block/string/BlockRedStringContainer.java | 19 +- .../block/string/BlockRedStringDispenser.java | 41 +- .../string/BlockRedStringFertilizer.java | 52 +- .../string/BlockRedStringInterceptor.java | 78 +- .../block/string/BlockRedStringRelay.java | 19 +- .../common/block/subtile/SubTileDecor.java | 19 +- .../common/block/subtile/SubTileManastar.java | 66 +- .../block/subtile/SubTilePureDaisy.java | 200 +- .../functional/SubTileAgricarnation.java | 174 +- .../subtile/functional/SubTileBellethorn.java | 177 +- .../subtile/functional/SubTileBubbell.java | 186 +- .../subtile/functional/SubTileClayconia.java | 182 +- .../subtile/functional/SubTileDaffomill.java | 254 +- .../subtile/functional/SubTileDreadthorn.java | 56 +- .../subtile/functional/SubTileExoflame.java | 204 +- .../functional/SubTileFallenKanade.java | 78 +- .../functional/SubTileHeiseiDream.java | 180 +- .../subtile/functional/SubTileHopperhock.java | 487 +- .../subtile/functional/SubTileHyacidus.java | 91 +- .../functional/SubTileJadedAmaranthus.java | 130 +- .../subtile/functional/SubTileJiyuulia.java | 53 +- .../subtile/functional/SubTileLoonuim.java | 94 +- .../functional/SubTileMarimorphosis.java | 247 +- .../subtile/functional/SubTileMedumone.java | 85 +- .../subtile/functional/SubTileOrechid.java | 288 +- .../functional/SubTileOrechidIgnem.java | 68 +- .../functional/SubTilePollidisiac.java | 122 +- .../functional/SubTileRannuncarpus.java | 435 +- .../subtile/functional/SubTileSolegnolia.java | 143 +- .../functional/SubTileSpectranthemum.java | 283 +- .../functional/SubTileTangleberrie.java | 156 +- .../subtile/functional/SubTileTigerseye.java | 169 +- .../subtile/functional/SubTileVinculotus.java | 179 +- .../subtile/generating/SubTileArcaneRose.java | 75 +- .../generating/SubTileDandelifeon.java | 357 +- .../subtile/generating/SubTileDaybloom.java | 225 +- .../subtile/generating/SubTileEndoflame.java | 248 +- .../generating/SubTileEntropinnyum.java | 129 +- .../generating/SubTileGourmaryllis.java | 192 +- .../generating/SubTileHydroangeas.java | 345 +- .../subtile/generating/SubTileKekimurus.java | 100 +- .../subtile/generating/SubTileMunchdew.java | 257 +- .../subtile/generating/SubTileNarslimmus.java | 171 +- .../subtile/generating/SubTileNightshade.java | 70 +- .../generating/SubTilePassiveGenerating.java | 13 +- .../subtile/generating/SubTileRafflowsia.java | 213 +- .../subtile/generating/SubTileSpectrolus.java | 220 +- .../subtile/generating/SubTileThermalily.java | 104 +- .../common/block/tile/TileAlfPortal.java | 662 +- .../botania/common/block/tile/TileAltar.java | 736 +-- .../botania/common/block/tile/TileAvatar.java | 231 +- .../common/block/tile/TileBifrost.java | 64 +- .../common/block/tile/TileBrewery.java | 496 +- .../common/block/tile/TileCacophonium.java | 42 +- .../botania/common/block/tile/TileCamo.java | 65 +- .../botania/common/block/tile/TileCell.java | 133 +- .../botania/common/block/tile/TileCocoon.java | 155 +- .../common/block/tile/TileCraftCrate.java | 356 +- .../common/block/tile/TileEnchanter.java | 803 ++- .../common/block/tile/TileEnderEye.java | 75 +- .../common/block/tile/TileFakeAir.java | 77 +- .../common/block/tile/TileFloatingFlower.java | 83 +- .../block/tile/TileFloatingSpecialFlower.java | 91 +- .../common/block/tile/TileForestEye.java | 34 +- .../common/block/tile/TileGaiaHead.java | 8 +- .../common/block/tile/TileHourglass.java | 285 +- .../common/block/tile/TileIncensePlate.java | 274 +- .../common/block/tile/TileLightRelay.java | 573 +- .../common/block/tile/TileManaBeacon.java | 60 +- .../common/block/tile/TileManaFlame.java | 93 +- .../botania/common/block/tile/TileMod.java | 59 +- .../common/block/tile/TileOpenCrate.java | 93 +- .../common/block/tile/TilePlatform.java | 83 +- .../botania/common/block/tile/TilePylon.java | 202 +- .../common/block/tile/TileRuneAltar.java | 776 ++- .../block/tile/TileSimpleInventory.java | 192 +- .../common/block/tile/TileSparkChanger.java | 111 +- .../common/block/tile/TileSpawnerClaw.java | 282 +- .../common/block/tile/TileSpecialFlower.java | 394 +- .../common/block/tile/TileSpiritShrine.java | 123 +- .../common/block/tile/TileStarfield.java | 71 +- .../common/block/tile/TileTerraPlate.java | 438 +- .../common/block/tile/TileTeruTeruBozu.java | 25 +- .../common/block/tile/TileTinyPlanet.java | 21 +- .../common/block/tile/TileTinyPotato.java | 79 +- .../block/tile/corporea/TileCorporeaBase.java | 11 +- .../corporea/TileCorporeaCrystalCube.java | 261 +- .../tile/corporea/TileCorporeaFunnel.java | 165 +- .../tile/corporea/TileCorporeaIndex.java | 641 +- .../corporea/TileCorporeaInterceptor.java | 179 +- .../tile/corporea/TileCorporeaRetainer.java | 206 +- .../common/block/tile/mana/TileBellows.java | 228 +- .../block/tile/mana/TileDistributor.java | 78 +- .../block/tile/mana/TileManaDetector.java | 52 +- .../common/block/tile/mana/TileManaVoid.java | 66 +- .../common/block/tile/mana/TilePool.java | 784 ++- .../common/block/tile/mana/TilePrism.java | 107 +- .../common/block/tile/mana/TilePump.java | 165 +- .../block/tile/mana/TileRFGenerator.java | 250 +- .../common/block/tile/mana/TileSpreader.java | 1417 ++-- .../common/block/tile/mana/TileTurntable.java | 133 +- .../block/tile/string/TileRedString.java | 141 +- .../tile/string/TileRedStringComparator.java | 68 +- .../tile/string/TileRedStringContainer.java | 254 +- .../tile/string/TileRedStringDispenser.java | 36 +- .../tile/string/TileRedStringFertilizer.java | 58 +- .../tile/string/TileRedStringInterceptor.java | 93 +- .../block/tile/string/TileRedStringRelay.java | 21 +- .../vazkii/botania/common/brew/BrewMod.java | 21 +- .../botania/common/brew/BrewModPotion.java | 11 +- .../vazkii/botania/common/brew/ModBrews.java | 132 +- .../botania/common/brew/ModPotions.java | 77 +- .../common/brew/potion/PotionAllure.java | 32 +- .../common/brew/potion/PotionBloodthirst.java | 50 +- .../common/brew/potion/PotionClear.java | 27 +- .../common/brew/potion/PotionEmptiness.java | 50 +- .../common/brew/potion/PotionFeatherfeet.java | 26 +- .../botania/common/brew/potion/PotionMod.java | 45 +- .../common/brew/potion/PotionSoulCross.java | 32 +- .../common/core/BotaniaCreativeTab.java | 794 +-- .../common/core/command/CommandOpen.java | 70 +- .../common/core/command/CommandShare.java | 61 +- .../core/command/CommandSkyblockSpread.java | 73 +- .../common/core/handler/AliasHandler.java | 86 +- .../core/handler/BiomeDecorationHandler.java | 163 +- .../common/core/handler/ChestGenHandler.java | 71 +- .../core/handler/CommonTickHandler.java | 55 +- .../common/core/handler/ConfigHandler.java | 876 ++- .../common/core/handler/IMCHandler.java | 30 +- .../core/handler/InternalMethodHandler.java | 454 +- .../core/handler/ManaNetworkHandler.java | 234 +- .../common/core/handler/PixieHandler.java | 81 +- .../common/core/handler/SheddingHandler.java | 246 +- .../core/handler/SpawnerChangingHandler.java | 44 +- .../handler/TerrasteelCraftingHandler.java | 335 +- .../common/core/helper/ExperienceHelper.java | 71 +- .../common/core/helper/InventoryHelper.java | 665 +- .../common/core/helper/ItemNBTHelper.java | 431 +- .../common/core/helper/MathHelper.java | 44 +- .../common/core/helper/ObfuscationHelper.java | 12 +- .../botania/common/core/helper/Quat.java | 212 +- .../botania/common/core/helper/Vector3.java | 555 +- .../common/core/proxy/CommonProxy.java | 525 +- .../common/crafting/ModBrewRecipes.java | 202 +- .../common/crafting/ModCraftingRecipes.java | 5839 +++++++---------- .../common/crafting/ModElvenTradeRecipes.java | 72 +- .../crafting/ModManaAlchemyRecipes.java | 348 +- .../crafting/ModManaConjurationRecipes.java | 73 +- .../crafting/ModManaInfusionRecipes.java | 157 +- .../common/crafting/ModPetalRecipes.java | 527 +- .../common/crafting/ModPureDaisyRecipes.java | 25 +- .../common/crafting/ModRuneRecipes.java | 223 +- .../crafting/recipe/AesirRingRecipe.java | 92 +- .../crafting/recipe/AncientWillRecipe.java | 91 +- .../BlackHoleTalismanExtractRecipe.java | 77 +- .../crafting/recipe/CompositeLensRecipe.java | 105 +- .../crafting/recipe/CosmeticAttachRecipe.java | 93 +- .../crafting/recipe/CosmeticRemoveRecipe.java | 77 +- .../common/crafting/recipe/HeadRecipe.java | 70 +- .../crafting/recipe/HelmRevealingRecipe.java | 156 +- .../common/crafting/recipe/KeepIvyRecipe.java | 79 +- .../crafting/recipe/LensDyeingRecipe.java | 163 +- .../crafting/recipe/ManaGunClipRecipe.java | 88 +- .../crafting/recipe/ManaGunLensRecipe.java | 113 +- .../recipe/ManaGunRemoveLensRecipe.java | 90 +- .../crafting/recipe/PhantomInkRecipe.java | 81 +- .../crafting/recipe/RegenIvyRecipe.java | 102 +- .../recipe/SpecialFloatingFlowerRecipe.java | 77 +- .../crafting/recipe/SpellClothRecipe.java | 86 +- .../recipe/TerraPickTippingRecipe.java | 79 +- .../common/entity/EntityBabylonWeapon.java | 406 +- .../common/entity/EntityCorporeaSpark.java | 562 +- .../common/entity/EntityDoppleganger.java | 1845 +++--- .../common/entity/EntityEnderAirBottle.java | 93 +- .../common/entity/EntityFallingStar.java | 107 +- .../common/entity/EntityFlameRing.java | 182 +- .../common/entity/EntityFlyingCreature.java | 127 +- .../common/entity/EntityMagicLandmine.java | 144 +- .../common/entity/EntityMagicMissile.java | 330 +- .../common/entity/EntityManaBurst.java | 1753 +++-- .../common/entity/EntityManaStorm.java | 154 +- .../common/entity/EntityPinkWither.java | 148 +- .../botania/common/entity/EntityPixie.java | 235 +- .../common/entity/EntityPoolMinecart.java | 253 +- .../common/entity/EntitySignalFlare.java | 115 +- .../botania/common/entity/EntitySpark.java | 679 +- .../common/entity/EntityThornChakram.java | 278 +- .../common/entity/EntityThrowableCopy.java | 668 +- .../common/entity/EntityThrownItem.java | 230 +- .../botania/common/entity/EntityVineBall.java | 85 +- .../botania/common/entity/ModEntities.java | 69 +- .../buildcraft/StatementAPIPlugin.java | 99 +- .../integration/buildcraft/StatementBase.java | 44 +- .../buildcraft/TriggerManaDetector.java | 74 +- .../buildcraft/TriggerManaLevel.java | 92 +- .../buildcraft/TriggerRuneAltarCanCraft.java | 42 +- .../coloredlights/ColoredLightHelper.java | 71 +- .../coloredlights/ILightHelper.java | 9 +- .../coloredlights/LightHelper.java | 16 +- .../coloredlights/LightHelperColored.java | 21 +- .../coloredlights/LightHelperVanilla.java | 21 +- .../corporea/WrappedDeepStorage.java | 218 +- .../corporea/WrappedIInventory.java | 140 +- .../corporea/WrappedInventoryBase.java | 64 +- .../corporea/WrappedStorageDrawers.java | 174 +- .../integration/etfuturum/ModBanners.java | 62 +- .../multipart/MultipartHandler.java | 95 +- .../botania/common/item/Item16Colors.java | 62 +- .../botania/common/item/ItemAncientWill.java | 80 +- .../common/item/ItemAutocraftingHalo.java | 40 +- .../botania/common/item/ItemBaubleBox.java | 83 +- .../common/item/ItemBlackHoleTalisman.java | 593 +- .../botania/common/item/ItemBlackLotus.java | 120 +- .../botania/common/item/ItemBottledMana.java | 429 +- .../botania/common/item/ItemCacophonium.java | 257 +- .../vazkii/botania/common/item/ItemClip.java | 13 +- .../common/item/ItemCorporeaSpark.java | 100 +- .../botania/common/item/ItemCraftPattern.java | 75 +- .../botania/common/item/ItemCraftingHalo.java | 1107 ++-- .../botania/common/item/ItemEnderHand.java | 114 +- .../botania/common/item/ItemFertilizer.java | 105 +- .../botania/common/item/ItemFlowerBag.java | 257 +- .../botania/common/item/ItemGaiaHead.java | 152 +- .../botania/common/item/ItemGrassHorn.java | 263 +- .../botania/common/item/ItemGrassSeeds.java | 702 +- .../botania/common/item/ItemKeepIvy.java | 151 +- .../botania/common/item/ItemLaputaShard.java | 488 +- .../botania/common/item/ItemLexicon.java | 365 +- .../botania/common/item/ItemManaCookie.java | 84 +- .../botania/common/item/ItemManaGun.java | 607 +- .../botania/common/item/ItemManaMirror.java | 491 +- .../botania/common/item/ItemManaTablet.java | 306 +- .../vazkii/botania/common/item/ItemMod.java | 49 +- .../common/item/ItemObedienceStick.java | 148 +- .../botania/common/item/ItemOpenBucket.java | 82 +- .../common/item/ItemOvergrowthSeed.java | 53 +- .../botania/common/item/ItemPhantomInk.java | 17 +- .../botania/common/item/ItemPinkinator.java | 77 +- .../botania/common/item/ItemPoolMinecart.java | 117 +- .../botania/common/item/ItemRegenIvy.java | 54 +- .../botania/common/item/ItemSextant.java | 278 +- .../botania/common/item/ItemSignalFlare.java | 229 +- .../botania/common/item/ItemSlimeBottle.java | 66 +- .../botania/common/item/ItemSlingshot.java | 87 +- .../vazkii/botania/common/item/ItemSpark.java | 87 +- .../botania/common/item/ItemSparkUpgrade.java | 82 +- .../botania/common/item/ItemSpawnerMover.java | 393 +- .../botania/common/item/ItemSpellCloth.java | 81 +- .../common/item/ItemTemperanceStone.java | 95 +- .../botania/common/item/ItemThornChakram.java | 85 +- .../botania/common/item/ItemTwigWand.java | 545 +- .../botania/common/item/ItemVineBall.java | 28 +- .../vazkii/botania/common/item/ItemVirus.java | 172 +- .../botania/common/item/ItemWaterBowl.java | 13 +- .../botania/common/item/ItemWorldSeed.java | 66 +- .../vazkii/botania/common/item/ModItems.java | 682 +- .../common/item/block/IRarityBlock.java | 7 +- .../common/item/block/ItemBlockDreamwood.java | 15 +- .../common/item/block/ItemBlockElven.java | 19 +- .../block/ItemBlockFloatingSpecialFlower.java | 23 +- .../common/item/block/ItemBlockMod.java | 53 +- .../common/item/block/ItemBlockModSlab.java | 19 +- .../common/item/block/ItemBlockPool.java | 23 +- .../item/block/ItemBlockSpecialFlower.java | 209 +- .../item/block/ItemBlockSpecialQuartz.java | 22 +- .../common/item/block/ItemBlockStorage.java | 18 +- .../item/block/ItemBlockTinyPotato.java | 84 +- .../block/ItemBlockWithMetadataAndName.java | 61 +- .../common/item/brew/ItemBrewBase.java | 318 +- .../common/item/brew/ItemBrewFlask.java | 11 +- .../common/item/brew/ItemBrewVial.java | 11 +- .../common/item/brew/ItemIncenseStick.java | 228 +- .../botania/common/item/brew/ItemVial.java | 77 +- .../armor/elementium/ItemElementiumArmor.java | 138 +- .../armor/elementium/ItemElementiumBoots.java | 15 +- .../armor/elementium/ItemElementiumChest.java | 15 +- .../armor/elementium/ItemElementiumHelm.java | 29 +- .../armor/elementium/ItemElementiumLegs.java | 15 +- .../armor/manasteel/ItemManasteelArmor.java | 430 +- .../armor/manasteel/ItemManasteelBoots.java | 11 +- .../armor/manasteel/ItemManasteelChest.java | 11 +- .../armor/manasteel/ItemManasteelHelm.java | 25 +- .../armor/manasteel/ItemManasteelLegs.java | 11 +- .../armor/manaweave/ItemManaweaveArmor.java | 214 +- .../armor/manaweave/ItemManaweaveBoots.java | 11 +- .../armor/manaweave/ItemManaweaveChest.java | 12 +- .../armor/manaweave/ItemManaweaveHelm.java | 59 +- .../armor/manaweave/ItemManaweaveLegs.java | 11 +- .../armor/terrasteel/ItemTerrasteelArmor.java | 172 +- .../armor/terrasteel/ItemTerrasteelBoots.java | 11 +- .../armor/terrasteel/ItemTerrasteelChest.java | 11 +- .../armor/terrasteel/ItemTerrasteelHelm.java | 250 +- .../armor/terrasteel/ItemTerrasteelLegs.java | 11 +- .../item/equipment/bauble/ItemAuraRing.java | 53 +- .../item/equipment/bauble/ItemBauble.java | 375 +- .../equipment/bauble/ItemBaubleCosmetic.java | 582 +- .../equipment/bauble/ItemBaubleModifier.java | 44 +- .../equipment/bauble/ItemBloodPendant.java | 344 +- .../item/equipment/bauble/ItemDivaCharm.java | 164 +- .../equipment/bauble/ItemFlightTiara.java | 1009 ++- .../equipment/bauble/ItemGoldenLaurel.java | 109 +- .../equipment/bauble/ItemGreaterAuraRing.java | 18 +- .../bauble/ItemGreaterMagnetRing.java | 11 +- .../equipment/bauble/ItemGreaterManaRing.java | 21 +- .../item/equipment/bauble/ItemHolyCloak.java | 240 +- .../item/equipment/bauble/ItemIcePendant.java | 217 +- .../item/equipment/bauble/ItemItemFinder.java | 413 +- .../equipment/bauble/ItemKnockbackBelt.java | 72 +- .../equipment/bauble/ItemLavaPendant.java | 79 +- .../item/equipment/bauble/ItemMagnetRing.java | 274 +- .../item/equipment/bauble/ItemManaRing.java | 188 +- .../item/equipment/bauble/ItemMiningRing.java | 73 +- .../item/equipment/bauble/ItemMonocle.java | 178 +- .../item/equipment/bauble/ItemPixieRing.java | 29 +- .../item/equipment/bauble/ItemReachRing.java | 37 +- .../equipment/bauble/ItemSpeedUpBelt.java | 81 +- .../bauble/ItemSuperLavaPendant.java | 93 +- .../equipment/bauble/ItemSuperTravelBelt.java | 20 +- .../item/equipment/bauble/ItemSwapRing.java | 110 +- .../item/equipment/bauble/ItemTinyPlanet.java | 162 +- .../item/equipment/bauble/ItemTravelBelt.java | 289 +- .../equipment/bauble/ItemUnholyCloak.java | 83 +- .../item/equipment/bauble/ItemWaterRing.java | 97 +- .../item/equipment/tool/ItemEnderDagger.java | 96 +- .../item/equipment/tool/ItemGlassPick.java | 72 +- .../item/equipment/tool/ItemStarSword.java | 95 +- .../item/equipment/tool/ItemThunderSword.java | 130 +- .../item/equipment/tool/ToolCommons.java | 316 +- .../equipment/tool/bow/ItemCrystalBow.java | 65 +- .../equipment/tool/bow/ItemLivingwoodBow.java | 294 +- .../tool/elementium/ItemElementiumAxe.java | 79 +- .../tool/elementium/ItemElementiumPick.java | 83 +- .../tool/elementium/ItemElementiumShears.java | 128 +- .../tool/elementium/ItemElementiumShovel.java | 56 +- .../tool/elementium/ItemElementiumSword.java | 15 +- .../tool/manasteel/ItemManasteelAxe.java | 217 +- .../tool/manasteel/ItemManasteelPick.java | 214 +- .../tool/manasteel/ItemManasteelShears.java | 230 +- .../tool/manasteel/ItemManasteelShovel.java | 239 +- .../tool/manasteel/ItemManasteelSword.java | 172 +- .../tool/terrasteel/ItemTerraAxe.java | 760 ++- .../tool/terrasteel/ItemTerraPick.java | 554 +- .../tool/terrasteel/ItemTerraSword.java | 224 +- .../ItemElementiumHelmRevealing.java | 42 +- .../thaumcraft/ItemManaInkwell.java | 194 +- .../ItemManasteelHelmRevealing.java | 52 +- .../ItemTerrasteelHelmRevealing.java | 44 +- .../botania/common/item/lens/ItemLens.java | 651 +- .../vazkii/botania/common/item/lens/Lens.java | 62 +- .../botania/common/item/lens/LensBounce.java | 43 +- .../botania/common/item/lens/LensDamage.java | 47 +- .../common/item/lens/LensEfficiency.java | 15 +- .../common/item/lens/LensExplosive.java | 35 +- .../botania/common/item/lens/LensFire.java | 60 +- .../common/item/lens/LensFirework.java | 87 +- .../botania/common/item/lens/LensFlare.java | 86 +- .../botania/common/item/lens/LensGravity.java | 15 +- .../common/item/lens/LensInfluence.java | 97 +- .../botania/common/item/lens/LensLight.java | 64 +- .../botania/common/item/lens/LensMagnet.java | 110 +- .../botania/common/item/lens/LensMine.java | 103 +- .../botania/common/item/lens/LensPaint.java | 150 +- .../botania/common/item/lens/LensPhantom.java | 27 +- .../botania/common/item/lens/LensPiston.java | 61 +- .../botania/common/item/lens/LensPower.java | 17 +- .../common/item/lens/LensRedirect.java | 100 +- .../botania/common/item/lens/LensSpeed.java | 19 +- .../botania/common/item/lens/LensStorm.java | 32 +- .../botania/common/item/lens/LensTime.java | 15 +- .../botania/common/item/lens/LensWarp.java | 52 +- .../botania/common/item/lens/LensWeight.java | 55 +- .../botania/common/item/material/ItemDye.java | 96 +- .../common/item/material/ItemManaPetal.java | 26 +- .../item/material/ItemManaResource.java | 307 +- .../item/material/ItemPestleAndMortar.java | 25 +- .../common/item/material/ItemPetal.java | 67 +- .../common/item/material/ItemQuartz.java | 67 +- .../common/item/material/ItemRune.java | 84 +- .../common/item/record/ItemModRecord.java | 72 +- .../common/item/record/ItemRecordGaia1.java | 11 +- .../common/item/record/ItemRecordGaia2.java | 11 +- .../common/item/relic/ItemAesirRing.java | 181 +- .../botania/common/item/relic/ItemDice.java | 139 +- .../common/item/relic/ItemExcaliber.java | 40 +- .../common/item/relic/ItemFlugelEye.java | 861 ++- .../common/item/relic/ItemInfiniteFruit.java | 127 +- .../common/item/relic/ItemKingKey.java | 230 +- .../common/item/relic/ItemLokiRing.java | 521 +- .../common/item/relic/ItemOdinRing.java | 159 +- .../botania/common/item/relic/ItemRelic.java | 247 +- .../common/item/relic/ItemRelicBauble.java | 139 +- .../common/item/relic/ItemThorRing.java | 43 +- .../common/item/rod/ItemCobbleRod.java | 98 +- .../botania/common/item/rod/ItemDirtRod.java | 198 +- .../common/item/rod/ItemDiviningRod.java | 137 +- .../common/item/rod/ItemExchangeRod.java | 790 ++- .../botania/common/item/rod/ItemFireRod.java | 117 +- .../common/item/rod/ItemGravityRod.java | 434 +- .../common/item/rod/ItemMissileRod.java | 177 +- .../common/item/rod/ItemRainbowRod.java | 351 +- .../common/item/rod/ItemSkyDirtRod.java | 69 +- .../botania/common/item/rod/ItemSmeltRod.java | 236 +- .../common/item/rod/ItemTerraformRod.java | 360 +- .../common/item/rod/ItemTornadoRod.java | 319 +- .../botania/common/item/rod/ItemWaterRod.java | 87 +- .../botania/common/lexicon/ALexiconEntry.java | 9 +- .../common/lexicon/BLexiconCategory.java | 16 +- .../botania/common/lexicon/BLexiconEntry.java | 88 +- .../botania/common/lexicon/CLexiconEntry.java | 23 +- .../botania/common/lexicon/DLexiconEntry.java | 19 +- .../botania/common/lexicon/HLexiconEntry.java | 19 +- .../botania/common/lexicon/LexiconData.java | 3238 ++++----- .../botania/common/lexicon/RLexiconEntry.java | 40 +- .../botania/common/lexicon/TLexiconEntry.java | 18 +- .../common/lexicon/WIPLexiconEntry.java | 19 +- .../botania/common/lexicon/WLexiconEntry.java | 32 +- .../botania/common/lexicon/page/PageBrew.java | 178 +- .../lexicon/page/PageCraftingRecipe.java | 327 +- .../common/lexicon/page/PageElvenRecipe.java | 193 +- .../common/lexicon/page/PageEntity.java | 182 +- .../common/lexicon/page/PageGuide.java | 65 +- .../common/lexicon/page/PageImage.java | 61 +- .../common/lexicon/page/PageLoreText.java | 35 +- .../lexicon/page/PageManaInfusionRecipe.java | 260 +- .../common/lexicon/page/PageMultiblock.java | 229 +- .../common/lexicon/page/PagePetalRecipe.java | 226 +- .../common/lexicon/page/PageRecipe.java | 329 +- .../common/lexicon/page/PageRuneRecipe.java | 81 +- .../common/lexicon/page/PageShedding.java | 242 +- .../common/lexicon/page/PageTerrasteel.java | 154 +- .../botania/common/lexicon/page/PageText.java | 218 +- .../common/lexicon/page/PageTutorial.java | 112 +- .../common/lib/LibAchievementNames.java | 103 +- .../botania/common/lib/LibBlockNames.java | 293 +- .../botania/common/lib/LibBrewNames.java | 47 +- .../botania/common/lib/LibEntityNames.java | 43 +- .../vazkii/botania/common/lib/LibGuiIDs.java | 13 +- .../botania/common/lib/LibItemNames.java | 402 +- .../vazkii/botania/common/lib/LibLexicon.java | 484 +- .../vazkii/botania/common/lib/LibMisc.java | 48 +- .../botania/common/lib/LibObfuscation.java | 117 +- .../vazkii/botania/common/lib/LibOreDict.java | 152 +- .../botania/common/lib/LibPotionNames.java | 17 +- .../botania/common/lib/LibTriggerNames.java | 10 +- .../botania/common/network/GuiHandler.java | 61 +- .../common/world/SkyblockWorldEvents.java | 324 +- .../common/world/WorldTypeSkyblock.java | 80 +- 927 files changed, 69700 insertions(+), 74293 deletions(-) delete mode 100644 settings.gradle diff --git a/build.gradle b/build.gradle index 046db33f4a..5ea36f38c9 100644 --- a/build.gradle +++ b/build.gradle @@ -1,27 +1,22 @@ -//version: 1660491897 +//version: 1644612407 /* - DO NOT CHANGE THIS FILE! - Also, you may replace this file at any time if there is an update available. - Please check https://github.com/GTNewHorizons/ExampleMod1.7.10/blob/main/build.gradle for updates. - */ +DO NOT CHANGE THIS FILE! +Also, you may replace this file at any time if there is an update available. +Please check https://github.com/GTNewHorizons/ExampleMod1.7.10/blob/main/build.gradle for updates. +*/ + +import org.gradle.internal.logging.text.StyledTextOutput +import org.gradle.internal.logging.text.StyledTextOutputFactory +import org.gradle.internal.logging.text.StyledTextOutput.Style import com.github.jengelman.gradle.plugins.shadow.tasks.ConfigureShadowRelocation import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar -import org.gradle.internal.logging.text.StyledTextOutput.Style -import org.gradle.internal.logging.text.StyledTextOutputFactory -import java.nio.file.Files -import java.nio.file.Paths import java.util.concurrent.TimeUnit -import java.util.zip.ZipEntry -import java.util.zip.ZipInputStream -import java.util.zip.ZipOutputStream buildscript { repositories { - mavenCentral() - maven { name 'forge' url 'https://maven.minecraftforge.net' @@ -43,29 +38,21 @@ buildscript { classpath 'com.github.GTNewHorizons:ForgeGradle:1.2.7' } } + plugins { id 'java-library' id 'idea' id 'eclipse' id 'scala' id 'maven-publish' - id 'org.jetbrains.kotlin.jvm' version '1.5.30' apply false - id 'org.jetbrains.kotlin.kapt' version '1.5.30' apply false - id 'com.google.devtools.ksp' version '1.5.30-1.0.0' apply false + id 'org.jetbrains.kotlin.jvm' version '1.5.30' apply false + id 'org.jetbrains.kotlin.kapt' version '1.5.30' apply false id 'org.ajoberstar.grgit' version '4.1.1' id 'com.github.johnrengelman.shadow' version '4.0.4' - id 'com.palantir.git-version' version '0.13.0' apply false + id 'com.palantir.git-version' version '0.13.0' apply false id 'de.undercouch.download' version '5.0.1' - id 'com.github.gmazzo.buildconfig' version '3.0.3' apply false - id "com.diffplug.spotless" version "6.7.2" + id 'com.github.gmazzo.buildconfig' version '3.0.3' apply false } -verifySettingsGradle() - -dependencies { - implementation 'com.diffplug:blowdryer:1.6.0' -} - -apply plugin: 'com.diffplug.blowdryer' if (project.file('.git/HEAD').isFile()) { apply plugin: 'com.palantir.git-version' @@ -90,7 +77,6 @@ idea { downloadSources = true } } -apply from: Blowdryer.file('spotless.gradle') if(JavaVersion.current() != JavaVersion.VERSION_1_8) { throw new GradleException("This project requires Java 8, but it's running on " + JavaVersion.current()) @@ -117,11 +103,8 @@ checkPropertyExists("containsMixinsAndOrCoreModOnly") checkPropertyExists("usesShadowedDependencies") checkPropertyExists("developmentEnvironmentUserName") -boolean noPublishedSources = project.hasProperty("noPublishedSources") ? project.noPublishedSources.toBoolean() : false -boolean usesMixinDebug = project.hasProperty('usesMixinDebug') ?: project.usesMixins.toBoolean() -boolean forceEnableMixins = project.hasProperty('forceEnableMixins') ? project.forceEnableMixins.toBoolean() : false -String channel = project.hasProperty('channel') ? project.channel : 'stable' -String mappingsVersion = project.hasProperty('mappingsVersion') ? project.mappingsVersion : '12' +boolean noPublishedSources = project.findProperty("noPublishedSources") ? project.noPublishedSources.toBoolean() : false + String javaSourceDir = "src/main/java/" String scalaSourceDir = "src/main/scala/" String kotlinSourceDir = "src/main/kotlin/" @@ -192,7 +175,7 @@ configurations.all { try { 'git config core.fileMode false'.execute() } -catch (Exception ignored) { +catch (Exception e) { out.style(Style.Failure).println("git isn't installed at all") } @@ -202,12 +185,12 @@ String versionOverride = System.getenv("VERSION") ?: null try { identifiedVersion = versionOverride == null ? gitVersion() : versionOverride } -catch (Exception ignored) { +catch (Exception e) { out.style(Style.Failure).text( - 'This mod must be version controlled by Git AND the repository must provide at least one tag,\n' + - 'or the VERSION override must be set! ').style(Style.SuccessHeader).text('(Do NOT download from GitHub using the ZIP option, instead\n' + - 'clone the repository, see ').style(Style.Info).text('https://gtnh.miraheze.org/wiki/Development').style(Style.SuccessHeader).println(' for details.)' - ) + 'This mod must be version controlled by Git AND the repository must provide at least one tag,\n' + + 'or the VERSION override must be set! ').style(Style.SuccessHeader).text('(Do NOT download from GitHub using the ZIP option, instead\n' + + 'clone the repository, see ').style(Style.Info).text('https://gtnh.miraheze.org/wiki/Development').style(Style.SuccessHeader).println(' for details.)' + ) versionOverride = 'NO-GIT-TAG-SET' identifiedVersion = versionOverride } @@ -216,7 +199,7 @@ ext { modVersion = identifiedVersion } -if(identifiedVersion == versionOverride) { +if( identifiedVersion.equals(versionOverride) ) { out.style(Style.Failure).text('Override version to ').style(Style.Identifier).text(modVersion).style(Style.Failure).println('!\7') } @@ -231,17 +214,13 @@ else { def arguments = [] def jvmArguments = [] -if (usesMixins.toBoolean() || forceEnableMixins) { +if(usesMixins.toBoolean()) { arguments += [ - "--tweakClass org.spongepowered.asm.launch.MixinTweaker" + "--tweakClass org.spongepowered.asm.launch.MixinTweaker" + ] + jvmArguments += [ + "-Dmixin.debug.countInjections=true", "-Dmixin.debug.verbose=true", "-Dmixin.debug.export=true" ] - if (usesMixinDebug.toBoolean()) { - jvmArguments += [ - "-Dmixin.debug.countInjections=true", - "-Dmixin.debug.verbose=true", - "-Dmixin.debug.export=true" - ] - } } minecraft { @@ -296,7 +275,7 @@ repositories { name 'Overmind forge repo mirror' url 'https://gregtech.overminddl1.com/' } - if(usesMixins.toBoolean() || forceEnableMixins) { + if(usesMixins.toBoolean()) { maven { name 'sponge' url 'https://repo.spongepowered.org/repository/maven-public' @@ -313,8 +292,6 @@ dependencies { annotationProcessor('com.google.guava:guava:24.1.1-jre') annotationProcessor('com.google.code.gson:gson:2.8.6') annotationProcessor('org.spongepowered:mixin:0.8-SNAPSHOT') - } - if(usesMixins.toBoolean() || forceEnableMixins) { // using 0.8 to workaround a issue in 0.7 which fails mixin application compile('com.github.GTNewHorizons:SpongePoweredMixin:0.7.12-GTNH') { // Mixin includes a lot of dependencies that are too up-to-date @@ -335,23 +312,18 @@ def refMap = "${tasks.compileJava.temporaryDir}" + File.separator + mixingConfig def mixinSrg = "${tasks.reobf.temporaryDir}" + File.separator + "mixins.srg" task generateAssets { - if (usesMixins.toBoolean()) { - def mixinConfigFile = getFile("/src/main/resources/mixins." + modId + ".json"); - if (!mixinConfigFile.exists()) { - mixinConfigFile.text = """{ + if(usesMixins.toBoolean()) { + getFile("/src/main/resources/mixins." + modId + ".json").text = """{ "required": true, "minVersion": "0.7.11", "package": "${modGroup}.${mixinsPackage}", "plugin": "${modGroup}.${mixinPlugin}", "refmap": "${mixingConfigRefMap}", "target": "@env(DEFAULT)", - "compatibilityLevel": "JAVA_8", - "mixins": [], - "client": [], - "server": [] + "compatibilityLevel": "JAVA_8" } + """ - } } } @@ -372,10 +344,7 @@ shadowJar { } minimize() // This will only allow shading for actually used classes - configurations = [ - project.configurations.shadowImplementation, - project.configurations.shadowCompile - ] + configurations = [project.configurations.shadowImplementation, project.configurations.shadowCompile] dependsOn(relocateShadowJar) } @@ -397,7 +366,7 @@ jar { } reobf { - if(usesMixins.toBoolean() && file(mixinSrg).exists()) { + if(usesMixins.toBoolean()) { addExtraSrgFile mixinSrg } } @@ -406,12 +375,12 @@ afterEvaluate { if(usesMixins.toBoolean()) { tasks.compileJava { options.compilerArgs += [ - "-AreobfSrgFile=${tasks.reobf.srg}", - "-AoutSrgFile=${mixinSrg}", - "-AoutRefMapFile=${refMap}", - // Elan: from what I understand they are just some linter configs so you get some warning on how to properly code - "-XDenableSunApiLintControl", - "-XDignore.symbol.file" + "-AreobfSrgFile=${tasks.reobf.srg}", + "-AoutSrgFile=${mixinSrg}", + "-AoutRefMapFile=${refMap}", + // Elan: from what I understand they are just some linter configs so you get some warning on how to properly code + "-XDenableSunApiLintControl", + "-XDignore.symbol.file" ] } } @@ -420,8 +389,8 @@ afterEvaluate { runClient { if(developmentEnvironmentUserName) { arguments += [ - "--username", - developmentEnvironmentUserName + "--username", + developmentEnvironmentUserName ] } @@ -439,14 +408,13 @@ tasks.withType(JavaExec).configureEach { javaToolchains.launcherFor { languageVersion = projectJavaVersion } - ) + ) } processResources { // this will ensure that this task is redone when the versions change. inputs.property "version", project.version inputs.property "mcversion", project.minecraft.version - exclude("spotless.gradle") // replace stuff in mcmod.info, nothing else from(sourceSets.main.resources.srcDirs) { @@ -454,9 +422,9 @@ processResources { // replace modVersion and minecraftVersion expand "minecraftVersion": project.minecraft.version, - "modVersion": modVersion, - "modId": modId, - "modName": modName + "modVersion": modVersion, + "modId": modId, + "modName": modName } if(usesMixins.toBoolean()) { @@ -466,13 +434,12 @@ processResources { // copy everything else that's not the mcmod.info from(sourceSets.main.resources.srcDirs) { exclude 'mcmod.info' - exclude 'spotless.gradle' } } def getManifestAttributes() { def manifestAttributes = [:] - if(!containsMixinsAndOrCoreModOnly.toBoolean() && (usesMixins.toBoolean() || coreModClass)) { + if(containsMixinsAndOrCoreModOnly.toBoolean() == false && (usesMixins.toBoolean() || coreModClass)) { manifestAttributes += ["FMLCorePluginContainsFMLMod": true] } @@ -486,16 +453,16 @@ def getManifestAttributes() { if(usesMixins.toBoolean()) { manifestAttributes += [ - "TweakClass" : "org.spongepowered.asm.launch.MixinTweaker", - "MixinConfigs" : "mixins." + modId + ".json", - "ForceLoadAsMod" : !containsMixinsAndOrCoreModOnly.toBoolean() + "TweakClass" : "org.spongepowered.asm.launch.MixinTweaker", + "MixinConfigs" : "mixins." + modId + ".json", + "ForceLoadAsMod" : containsMixinsAndOrCoreModOnly.toBoolean() == false ] } return manifestAttributes } task sourcesJar(type: Jar) { - from (sourceSets.main.allSource) + from (sourceSets.main.allJava) from (file("$projectDir/LICENSE")) getArchiveClassifier().set('sources') } @@ -515,10 +482,7 @@ task shadowDevJar(type: ShadowJar) { } minimize() // This will only allow shading for actually used classes - configurations = [ - project.configurations.shadowImplementation, - project.configurations.shadowCompile - ] + configurations = [project.configurations.shadowImplementation, project.configurations.shadowCompile] } task relocateShadowDevJar(type: ConfigureShadowRelocation) { @@ -553,7 +517,7 @@ task devJar(type: Jar) { } task apiJar(type: Jar) { - from (sourceSets.main.allSource) { + from (sourceSets.main.allJava) { include modGroup.toString().replaceAll("\\.", "/") + "/" + apiPackage.toString().replaceAll("\\.", "/") + '/**' } @@ -584,9 +548,6 @@ tasks.withType(GenerateModuleMetadata) { enabled = false } -// workaround variable hiding in pom processing -def projectConfigs = project.configurations - publishing { publications { maven(MavenPublication) { @@ -595,7 +556,7 @@ publishing { artifact source: shadowJar, classifier: "" } if(!noPublishedSources) { - artifact source: sourcesJar, classifier: "sources" + artifact source: sourcesJar, classifier: "src" } artifact source: usesShadowedDependencies.toBoolean() ? shadowDevJar : devJar, classifier: "dev" if (apiPackage) { @@ -607,23 +568,16 @@ publishing { // Using the identified version, not project.version as it has the prepended 1.7.10 version = System.getenv("RELEASE_VERSION") ?: identifiedVersion - // remove extra garbage from minecraft and minecraftDeps configuration + // remove extra garbage from who knows where pom.withXml { - def badArtifacts = [:].withDefault {[] as Set} - for (configuration in [ - projectConfigs.minecraft, - projectConfigs.minecraftDeps - ]) { - for (dependency in configuration.allDependencies) { - badArtifacts[dependency.group == null ? "" : dependency.group] += dependency.name - } - } - // example for specifying extra stuff to ignore - // badArtifacts["org.example.group"] += "artifactName" - + def badPomGroup = ['net.minecraft', 'com.google.code.findbugs', 'org.ow2.asm', 'com.typesafe.akka', 'com.typesafe', 'org.scala-lang', + 'org.scala-lang.plugins', 'net.sf.jopt-simple', 'lzma', 'com.mojang', 'org.apache.commons', 'org.apache.httpcomponents', + 'commons-logging', 'java3d', 'net.sf.trove4j', 'com.ibm.icu', 'com.paulscode', 'io.netty', 'com.google.guava', + 'commons-io', 'commons-codec', 'net.java.jinput', 'net.java.jutils', 'com.google.code.gson', 'org.apache.logging.log4j', + 'org.lwjgl.lwjgl', 'tv.twitch', 'org.jetbrains.kotlin', ''] Node pomNode = asNode() pomNode.dependencies.'*'.findAll() { - badArtifacts[it.groupId.text()].contains(it.artifactId.text()) + badPomGroup.contains(it.groupId.text()) }.each() { it.parent().remove(it) } @@ -647,11 +601,11 @@ task updateBuildScript { doLast { if (performBuildScriptUpdate(projectDir.toString())) return - print("Build script already up-to-date!") + print("Build script already up-to-date!") } } -if (!project.getGradle().startParameter.isOffline() && isNewBuildScriptVersionAvailable(projectDir.toString())) { +if (isNewBuildScriptVersionAvailable(projectDir.toString())) { if (autoUpdateBuildScript.toBoolean()) { performBuildScriptUpdate(projectDir.toString()) } else { @@ -662,26 +616,12 @@ if (!project.getGradle().startParameter.isOffline() && isNewBuildScriptVersionAv static URL availableBuildScriptUrl() { new URL("https://raw.githubusercontent.com/GTNewHorizons/ExampleMod1.7.10/main/build.gradle") } -static URL exampleSettingsGradleUrl() { - new URL("https://raw.githubusercontent.com/GTNewHorizons/ExampleMod1.7.10/main/settings.gradle.example") -} - - -def verifySettingsGradle() { - def settingsFile = getFile("settings.gradle") - if (!settingsFile.exists()) { - println("Downloading default settings.gradle") - exampleSettingsGradleUrl().withInputStream { i -> settingsFile.withOutputStream { it << i } } - throw new GradleException("Settings.gradle has been updated, please re-run task.") - } -} boolean performBuildScriptUpdate(String projectDir) { if (isNewBuildScriptVersionAvailable(projectDir)) { def buildscriptFile = getFile("build.gradle") availableBuildScriptUrl().withInputStream { i -> buildscriptFile.withOutputStream { it << i } } out.style(Style.Success).print("Build script updated. Please REIMPORT the project or RESTART your IDE!") - verifySettingsGradle() return true } return false @@ -712,225 +652,80 @@ configure(updateBuildScript) { description = 'Updates the build script to the latest version' } -// Parameter Deobfuscation +// Deobfuscation -task deobfParams { - doLast { - - String mcpDir = "$project.gradle.gradleUserHomeDir/caches/minecraft/de/oceanlabs/mcp/mcp_$channel/$mappingsVersion" - String mcpZIP = "$mcpDir/mcp_$channel-$mappingsVersion-${minecraftVersion}.zip" - String paramsCSV = "$mcpDir/params.csv" - - download.run { - src "https://maven.minecraftforge.net/de/oceanlabs/mcp/mcp_$channel/$mappingsVersion-$minecraftVersion/mcp_$channel-$mappingsVersion-${minecraftVersion}.zip" - dest mcpZIP - overwrite false +def deobf(String sourceURL) { + try { + URL url = new URL(sourceURL) + String fileName = url.getFile() + + //get rid of directories: + int lastSlash = fileName.lastIndexOf("/") + if(lastSlash > 0) { + fileName = fileName.substring(lastSlash + 1) } - - if(!file(paramsCSV).exists()) { - println("Extracting MCP archive ...") - unzip(mcpZIP, mcpDir) + //get rid of extension: + if(fileName.endsWith(".jar")) { + fileName = fileName.substring(0, fileName.lastIndexOf(".")) } - println("Parsing params.csv ...") - Map params = new HashMap<>() - Files.lines(Paths.get(paramsCSV)).forEach{line -> - String[] cells = line.split(",") - if(cells.length > 2 && cells[0].matches("p_i?\\d+_\\d+_")) { - params.put(cells[0], cells[1]) - } + String hostName = url.getHost() + if(hostName.startsWith("www.")) { + hostName = hostName.substring(4) } + List parts = Arrays.asList(hostName.split("\\.")) + Collections.reverse(parts) + hostName = String.join(".", parts) - out.style(Style.Success).println("Modified ${replaceParams(file("$projectDir/src/main/java"), params)} files!") - out.style(Style.Failure).println("Don't forget to verify that the code still works as before!\n It could be broken due to duplicate variables existing now\n or parameters taking priority over other variables.") -} -} - -static int replaceParams(File file, Map params) { -int fileCount = 0 - -if(file.isDirectory()) { - for(File f : file.listFiles()) { - fileCount += replaceParams(f, params) - } - return fileCount -} -println("Visiting ${file.getName()} ...") -try { - String content = new String(Files.readAllBytes(file.toPath())) - int hash = content.hashCode() - params.forEach{key, value -> - content = content.replaceAll(key, value) - } - if(hash != content.hashCode()) { - Files.write(file.toPath(), content.getBytes("UTF-8")) - return 1 - } -} catch(Exception e) { - e.printStackTrace() -} -return 0 -} - -// Credit: bitsnaps (https://gist.github.com/bitsnaps/00947f2dce66f4bbdabc67d7e7b33681) -static unzip(String zipFileName, String outputDir) { -byte[] buffer = new byte[16384] -ZipInputStream zis = new ZipInputStream(new FileInputStream(zipFileName)) -ZipEntry zipEntry = zis.getNextEntry() -while (zipEntry != null) { - File newFile = new File(outputDir + File.separator, zipEntry.name) - if (zipEntry.isDirectory()) { - if (!newFile.isDirectory() && !newFile.mkdirs()) { - throw new IOException("Failed to create directory $newFile") - } - } else { - // fix for Windows-created archives - File parent = newFile.parentFile - if (!parent.isDirectory() && !parent.mkdirs()) { - throw new IOException("Failed to create directory $parent") - } - // write file content - FileOutputStream fos = new FileOutputStream(newFile) - int len = 0 - while ((len = zis.read(buffer)) > 0) { - fos.write(buffer, 0, len) - } - fos.close() + return deobf(sourceURL, hostName + "/" + fileName) + } catch(Exception e) { + return deobf(sourceURL, "deobf/" + String.valueOf(sourceURL.hashCode())) } - zipEntry = zis.getNextEntry() -} -zis.closeEntry() -zis.close() -} - -configure(deobfParams) { -group = 'forgegradle' -description = 'Rename all obfuscated parameter names inherited from Minecraft classes' } -// Dependency Deobfuscation - -def deobf(String sourceURL) { -try { - URL url = new URL(sourceURL) - String fileName = url.getFile() +// The method above is to be preferred. Use this method if the filename is not at the end of the URL. +def deobf(String sourceURL, String fileName) { + String cacheDir = System.getProperty("user.home") + "/.gradle/caches/" + String bon2Dir = cacheDir + "forge_gradle/deobf" + String bon2File = bon2Dir + "/BON2-2.5.0.jar" + String obfFile = cacheDir + "modules-2/files-2.1/" + fileName + ".jar" + String deobfFile = cacheDir + "modules-2/files-2.1/" + fileName + "-deobf.jar" - //get rid of directories: - int lastSlash = fileName.lastIndexOf("/") - if(lastSlash > 0) { - fileName = fileName.substring(lastSlash + 1) + if(file(deobfFile).exists()) { + return files(deobfFile) } - //get rid of extension: - if(fileName.endsWith(".jar") || fileName.endsWith(".litemod")) { - fileName = fileName.substring(0, fileName.lastIndexOf(".")) + + download.run { + src 'https://github.com/GTNewHorizons/BON2/releases/download/2.5.0/BON2-2.5.0.CUSTOM-all.jar' + dest bon2File + quiet true + overwrite false } - String hostName = url.getHost() - if(hostName.startsWith("www.")) { - hostName = hostName.substring(4) + download.run { + src sourceURL + dest obfFile + quiet true + overwrite false } - List parts = Arrays.asList(hostName.split("\\.")) - Collections.reverse(parts) - hostName = String.join(".", parts) - return deobf(sourceURL, "$hostName/$fileName") -} catch(Exception e) { - return deobf(sourceURL, "deobf/${sourceURL.hashCode()}") -} -} + exec { + commandLine 'java', '-jar', bon2File, '--inputJar', obfFile, '--outputJar', deobfFile, '--mcVer', '1.7.10', '--mappingsVer', 'stable_12', '--notch' + workingDir bon2Dir + standardOutput = new ByteArrayOutputStream() + } -// The method above is to be preferred. Use this method if the filename is not at the end of the URL. -def deobf(String sourceURL, String rawFileName) { -String bon2Version = "2.5.1" -String fileName = URLDecoder.decode(rawFileName, "UTF-8") -String cacheDir = "$project.gradle.gradleUserHomeDir/caches" -String bon2Dir = "$cacheDir/forge_gradle/deobf" -String bon2File = "$bon2Dir/BON2-${bon2Version}.jar" -String obfFile = "$cacheDir/modules-2/files-2.1/${fileName}.jar" -String deobfFile = "$cacheDir/modules-2/files-2.1/${fileName}-deobf.jar" - -if(file(deobfFile).exists()) { return files(deobfFile) } -String mappingsVer -String remoteMappings = project.hasProperty('remoteMappings') ? project.remoteMappings : 'https://raw.githubusercontent.com/MinecraftForge/FML/1.7.10/conf/' -if(remoteMappings) { - String id = "${forgeVersion.split("\\.")[3]}-$minecraftVersion" - String mappingsZIP = "$cacheDir/forge_gradle/maven_downloader/de/oceanlabs/mcp/mcp_snapshot_nodoc/$id/mcp_snapshot_nodoc-${id}.zip" - - zipMappings(mappingsZIP, remoteMappings, bon2Dir) - - mappingsVer = "snapshot_$id" -} else { - mappingsVer = "${channel}_$mappingsVersion" -} - -download.run { - src "http://jenkins.usrv.eu:8081/nexus/content/repositories/releases/com/github/parker8283/BON2/$bon2Version-CUSTOM/BON2-$bon2Version-CUSTOM-all.jar" - dest bon2File - quiet true - overwrite false -} - -download.run { - src sourceURL - dest obfFile - quiet true - overwrite false -} - -exec { - commandLine 'java', '-jar', bon2File, '--inputJar', obfFile, '--outputJar', deobfFile, '--mcVer', minecraftVersion, '--mappingsVer', mappingsVer, '--notch' - workingDir bon2Dir - standardOutput = new FileOutputStream("${deobfFile}.log") -} - -return files(deobfFile) -} - -def zipMappings(String zipPath, String url, String bon2Dir) { -File zipFile = new File(zipPath) -if(zipFile.exists()) { - return -} - -String fieldsCache = "$bon2Dir/data/fields.csv" -String methodsCache = "$bon2Dir/data/methods.csv" - -download.run { - src "${url}fields.csv" - dest fieldsCache - quiet true -} -download.run { - src "${url}methods.csv" - dest methodsCache - quiet true -} - -zipFile.getParentFile().mkdirs() -ZipOutputStream zos = new ZipOutputStream(new FileOutputStream(zipFile)) - -zos.putNextEntry(new ZipEntry("fields.csv")) -Files.copy(Paths.get(fieldsCache), zos) -zos.closeEntry() - -zos.putNextEntry(new ZipEntry("methods.csv")) -Files.copy(Paths.get(methodsCache), zos) -zos.closeEntry() - -zos.close() -} - // Helper methods def checkPropertyExists(String propertyName) { -if (!project.hasProperty(propertyName)) { - throw new GradleException("This project requires a property \"" + propertyName + "\"! Please add it your \"gradle.properties\". You can find all properties and their description here: https://github.com/GTNewHorizons/ExampleMod1.7.10/blob/main/gradle.properties") -} + if (project.hasProperty(propertyName) == false) { + throw new GradleException("This project requires a property \"" + propertyName + "\"! Please add it your \"gradle.properties\". You can find all properties and their description here: https://github.com/GTNewHorizons/ExampleMod1.7.10/blob/main/gradle.properties") + } } def getFile(String relativePath) { -return new File(projectDir, relativePath) + return new File(projectDir, relativePath) } diff --git a/settings.gradle b/settings.gradle deleted file mode 100644 index 97d8f71c52..0000000000 --- a/settings.gradle +++ /dev/null @@ -1,10 +0,0 @@ -plugins { - id 'com.diffplug.blowdryerSetup' version '1.6.0' -} - -apply plugin: 'com.diffplug.blowdryerSetup' - -blowdryerSetup { - github('GTNewHorizons/ExampleMod1.7.10', 'tag', '0.1.4') - //devLocal '.' // Use this when testing config updates locally -} diff --git a/src/main/java/vazkii/botania/api/BotaniaAPI.java b/src/main/java/vazkii/botania/api/BotaniaAPI.java index 77549e44ff..2fc841b3bf 100644 --- a/src/main/java/vazkii/botania/api/BotaniaAPI.java +++ b/src/main/java/vazkii/botania/api/BotaniaAPI.java @@ -2,17 +2,14 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jan 14, 2014, 6:15:28 PM (GMT)] */ package vazkii.botania.api; -import com.google.common.collect.BiMap; -import com.google.common.collect.HashBiMap; -import cpw.mods.fml.common.Loader; import java.util.ArrayList; import java.util.HashMap; import java.util.LinkedHashMap; @@ -20,6 +17,7 @@ import java.util.List; import java.util.Map; import java.util.Set; + import net.minecraft.block.Block; import net.minecraft.entity.Entity; import net.minecraft.init.Blocks; @@ -55,636 +53,626 @@ import vazkii.botania.api.wiki.SimpleWikiProvider; import vazkii.botania.api.wiki.WikiHooks; +import com.google.common.collect.BiMap; +import com.google.common.collect.HashBiMap; + +import cpw.mods.fml.common.Loader; + public final class BotaniaAPI { - private static List categories = new ArrayList(); - private static List allEntries = new ArrayList(); - - public static Map knowledgeTypes = new HashMap(); - - public static Map brewMap = new LinkedHashMap(); - - public static List disposableBlocks = new ArrayList(); - public static List semiDisposableBlocks = new ArrayList(); - - public static List petalRecipes = new ArrayList(); - public static List pureDaisyRecipes = new ArrayList(); - public static List manaInfusionRecipes = new ArrayList(); - public static List runeAltarRecipes = new ArrayList(); - public static List elvenTradeRecipes = new ArrayList(); - public static List brewRecipes = new ArrayList(); - public static List miniFlowerRecipes = new ArrayList(); - - private static BiMap> subTiles = - HashBiMap.>create(); - private static Map, SubTileSignature> subTileSignatures = - new HashMap, SubTileSignature>(); - public static Set subtilesForCreativeMenu = new LinkedHashSet(); - public static Map subTileMods = new HashMap(); - public static BiMap miniFlowers = HashBiMap.create(); - - public static Map oreWeights = new HashMap(); - public static Map oreWeightsNether = new HashMap(); - public static Map seeds = new HashMap(); - public static Set looniumBlacklist = new LinkedHashSet(); - public static Set paintableBlocks = new LinkedHashSet(); - public static Set magnetBlacklist = new LinkedHashSet(); - public static Set> gravityRodBlacklist = new LinkedHashSet>(); - - public static ArmorMaterial manasteelArmorMaterial = - EnumHelper.addArmorMaterial("MANASTEEL", 16, new int[] {2, 6, 5, 2}, 18); - public static ToolMaterial manasteelToolMaterial = EnumHelper.addToolMaterial("MANASTEEL", 3, 300, 6.2F, 2F, 20); - - public static ArmorMaterial elementiumArmorMaterial = - EnumHelper.addArmorMaterial("B_ELEMENTIUM", 18, new int[] {2, 6, 5, 2}, 18); - public static ToolMaterial elementiumToolMaterial = - EnumHelper.addToolMaterial("B_ELEMENTIUM", 3, 720, 6.2F, 2F, 20); - - public static ArmorMaterial terrasteelArmorMaterial = - EnumHelper.addArmorMaterial("TERRASTEEL", 34, new int[] {3, 8, 6, 3}, 26); - public static ToolMaterial terrasteelToolMaterial = EnumHelper.addToolMaterial("TERRASTEEL", 4, 2300, 9F, 3F, 26); - - public static ArmorMaterial manaweaveArmorMaterial = - EnumHelper.addArmorMaterial("MANAWEAVE", 5, new int[] {1, 2, 2, 1}, 18); - - public static EnumRarity rarityRelic = EnumHelper.addRarity("RELIC", EnumChatFormatting.GOLD, "Relic"); - - public static KnowledgeType basicKnowledge; - public static KnowledgeType elvenKnowledge; - - // This is here for completeness sake, but you shouldn't use it - public static KnowledgeType relicKnowledge; - - // All of these categories are initialized during botania's PreInit stage. - public static LexiconCategory categoryBasics; - public static LexiconCategory categoryMana; - public static LexiconCategory categoryFunctionalFlowers; - public static LexiconCategory categoryGenerationFlowers; - public static LexiconCategory categoryDevices; - public static LexiconCategory categoryTools; - public static LexiconCategory categoryBaubles; - public static LexiconCategory categoryEnder; - public static LexiconCategory categoryAlfhomancy; - public static LexiconCategory categoryMisc; - - public static Brew fallbackBrew = new Brew("fallback", "botania.brew.fallback", 0, 0); - - static { - registerSubTile("", DummySubTile.class); - - basicKnowledge = registerKnowledgeType("minecraft", EnumChatFormatting.RESET, true); - elvenKnowledge = registerKnowledgeType("alfheim", EnumChatFormatting.DARK_GREEN, false); - relicKnowledge = registerKnowledgeType("relic", EnumChatFormatting.DARK_PURPLE, false); - - addOreWeight("oreAluminum", 3940); // Tinkers' Construct - addOreWeight("oreAmber", 2075); // Thaumcraft - addOreWeight("oreApatite", 1595); // Forestry - addOreWeight("oreBlueTopaz", 3195); // Ars Magica - addOreWeight("oreCertusQuartz", 3975); // Applied Energistics - addOreWeight("oreChimerite", 3970); // Ars Magica - addOreWeight("oreCinnabar", 2585); // Thaumcraft - addOreWeight("oreCoal", 46525); // Vanilla - addOreWeight("oreCopper", 8325); // IC2, Thermal Expansion, Tinkers' Construct, etc. - addOreWeight("oreDark", 1350); // EvilCraft - addOreWeight("oreDarkIron", 1700); // Factorization (older versions) - addOreWeight("oreFzDarkIron", 1700); // Factorization (newer versions) - addOreWeight("oreDiamond", 1265); // Vanilla - addOreWeight("oreEmerald", 780); // Vanilla - addOreWeight("oreGalena", 1000); // Factorization - addOreWeight("oreGold", 2970); // Vanilla - addOreWeight("oreInfusedAir", 925); // Thaumcraft - addOreWeight("oreInfusedEarth", 925); // Thaumcraft - addOreWeight("oreInfusedEntropy", 925); // Thaumcraft - addOreWeight("oreInfusedFire", 925); // Thaumcraft - addOreWeight("oreInfusedOrder", 925); // Thaumcraft - addOreWeight("oreInfusedWater", 925); // Thaumcraft - addOreWeight("oreIron", 20665); // Vanilla - addOreWeight("oreLapis", 1285); // Vanilla - addOreWeight("oreLead", 7985); // IC2, Thermal Expansion, Factorization, etc. - addOreWeight("oreMCropsEssence", 3085); // Magical Crops - addOreWeight("oreMithril", 8); // Thermal Expansion - addOreWeight("oreNickel", 2275); // Thermal Expansion - addOreWeight("oreOlivine", 1100); // Project RED - addOreWeight("orePlatinum", 365); // Thermal Expansion - addOreWeight("oreRedstone", 6885); // Vanilla - addOreWeight("oreRuby", 1100); // Project RED - addOreWeight("oreSapphire", 1100); // Project RED - addOreWeight("oreSilver", 6300); // Thermal Expansion, Factorization, etc. - addOreWeight("oreSulfur", 1105); // Railcraft - addOreWeight("oreTin", 9450); // IC2, Thermal Expansion, etc. - addOreWeight("oreUranium", 1337); // IC2 - addOreWeight("oreVinteum", 5925); // Ars Magica - addOreWeight("oreYellorite", 3520); // Big Reactors - addOreWeight("oreZinc", 6485); // Flaxbeard's Steam Power - addOreWeight("oreMythril", 6485); // Simple Ores2 - addOreWeight("oreAdamantium", 2275); // Simple Ores2 - addOreWeight("oreTungsten", 3520); // Simple Tungsten - - addOreWeightNether("oreQuartz", 19600); // Vanilla - addOreWeightNether("oreCobalt", 500); // Tinker's Construct - addOreWeightNether("oreArdite", 500); // Tinker's Construct - addOreWeightNether("oreFirestone", 5); // Railcraft - addOreWeightNether("oreNetherCoal", 17000); // Nether Ores - addOreWeightNether("oreNetherCopper", 4700); // Nether Ores - addOreWeightNether("oreNetherDiamond", 175); // Nether Ores - addOreWeightNether("oreNetherEssence", 2460); // Magical Crops - addOreWeightNether("oreNetherGold", 3635); // Nether Ores - addOreWeightNether("oreNetherIron", 5790); // Nether Ores - addOreWeightNether("oreNetherLapis", 3250); // Nether Ores - addOreWeightNether("oreNetherLead", 2790); // Nether Ores - addOreWeightNether("oreNetherNickel", 1790); // Nether Ores - addOreWeightNether("oreNetherPlatinum", 170); // Nether Ores - addOreWeightNether("oreNetherRedstone", 5600); // Nether Ores - addOreWeightNether("oreNetherSilver", 1550); // Nether Ores - addOreWeightNether("oreNetherSteel", 1690); // Nether Ores - addOreWeightNether("oreNetherTin", 3750); // Nether Ores - addOreWeightNether("oreFyrite", 1000); // Netherrocks - addOreWeightNether("oreAshstone", 1000); // Netherrocks - addOreWeightNether("oreDragonstone", 175); // Netherrocks - addOreWeightNether("oreArgonite", 1000); // Netherrocks - addOreWeightNether("oreOnyx", 500); // SimpleOres 2 - addOreWeightNether("oreHaditeCoal", 500); // Hadite - - addSeed(Items.wheat_seeds, Blocks.wheat); - addSeed(Items.potato, Blocks.potatoes); - addSeed(Items.carrot, Blocks.carrots); - addSeed(Items.nether_wart, Blocks.nether_wart); - addSeed(Items.pumpkin_seeds, Blocks.pumpkin_stem); - addSeed(Items.melon_seeds, Blocks.melon_stem); - - registerModWiki("Minecraft", new SimpleWikiProvider("Minecraft Wiki", "http://minecraft.gamepedia.com/%s")); - - IWikiProvider technicWiki = new SimpleWikiProvider("Technic Wiki", "http://wiki.technicpack.net/%s"); - IWikiProvider mekanismWiki = new SimpleWikiProvider("Mekanism Wiki", "http://wiki.aidancbrady.com/wiki/%s"); - IWikiProvider buildcraftWiki = - new SimpleWikiProvider("BuildCraft Wiki", "http://www.mod-buildcraft.com/wiki/doku.php?id=%s"); - - registerModWiki("Mekanism", mekanismWiki); - registerModWiki("MekanismGenerators", mekanismWiki); - registerModWiki("MekanismTools", mekanismWiki); - registerModWiki("EnderIO", new SimpleWikiProvider("EnderIO Wiki", "http://wiki.enderio.com/%s")); - registerModWiki("TropiCraft", new SimpleWikiProvider("Tropicraft Wiki", "http://wiki.tropicraft.net/wiki/%s")); - registerModWiki( - "RandomThings", - new SimpleWikiProvider("Random Things Wiki", "http://randomthingsminecraftmod.wikispaces.com/%s")); - registerModWiki( - "Witchery", - new SimpleWikiProvider("Witchery Wiki", "https://sites.google.com/site/witcherymod/%s", "-", true)); - registerModWiki("AppliedEnergistics2", new SimpleWikiProvider("AE2 Wiki", "http://ae-mod.info/%s")); - registerModWiki("BigReactors", technicWiki); - registerModWiki("BuildCraft|Core", buildcraftWiki); - registerModWiki("BuildCraft|Builders", buildcraftWiki); - registerModWiki("BuildCraft|Energy", buildcraftWiki); - registerModWiki("BuildCraft|Factory", buildcraftWiki); - registerModWiki("BuildCraft|Silicon", buildcraftWiki); - registerModWiki("BuildCraft|Transport", buildcraftWiki); - registerModWiki( - "ArsMagica2", new SimpleWikiProvider("ArsMagica2 Wiki", "http://wiki.arsmagicamod.com/wiki/%s")); - registerModWiki( - "PneumaticCraft", - new SimpleWikiProvider( - "PneumaticCraft Wiki", - "http://www.minemaarten.com/wikis/pneumaticcraft-wiki/pneumaticcraft-wiki-%s")); - registerModWiki( - "StevesCarts2", new SimpleWikiProvider("Steve's Carts Wiki", "http://stevescarts2.wikispaces.com/%s")); - registerModWiki( - "GanysSurface", - new SimpleWikiProvider("Gany's Surface Wiki", "http://ganys-surface.wikia.com/wiki/%s")); - registerModWiki( - "GanysNether", new SimpleWikiProvider("Gany's Nether Wiki", "http://ganys-nether.wikia.com/wiki/%s")); - registerModWiki("GanysEnd", new SimpleWikiProvider("Gany's End Wiki", "http://ganys-end.wikia.com/wiki/%s")); - - registerPaintableBlock(Blocks.stained_glass); - registerPaintableBlock(Blocks.stained_glass_pane); - registerPaintableBlock(Blocks.stained_hardened_clay); - registerPaintableBlock(Blocks.wool); - registerPaintableBlock(Blocks.carpet); - - registerDisposableBlock("dirt"); // Vanilla - registerDisposableBlock("sand"); // Vanilla - registerDisposableBlock("gravel"); // Vanilla - registerDisposableBlock("cobblestone"); // Vanilla - registerDisposableBlock("netherrack"); // Vanilla - registerSemiDisposableBlock("stoneAndesite"); // Botania - registerSemiDisposableBlock("stoneBasalt"); // Botania - registerSemiDisposableBlock("stoneDiorite"); // Botania - registerSemiDisposableBlock("stoneGranite"); // Botania - } - - /** - * The internal method handler in use. - * DO NOT OVERWRITE THIS OR YOU'RE GOING TO FEEL MY WRATH WHEN I UPDATE THE API. - * The fact I have to write that means some moron already tried, don't be that moron. - * @see IInternalMethodHandler - */ - public static IInternalMethodHandler internalHandler = new DummyMethodHandler(); - - /** - * Registers a new Knowledge Type. - * @param id The ID for this knowledge type. - * @param color The color to display this knowledge type as. - */ - public static KnowledgeType registerKnowledgeType(String id, EnumChatFormatting color, boolean autoUnlock) { - KnowledgeType type = new KnowledgeType(id, color, autoUnlock); - knowledgeTypes.put(id, type); - return type; - } - - /** - * Registers a Brew and returns it. - */ - public static Brew registerBrew(Brew brew) { - brewMap.put(brew.getKey(), brew); - return brew; - } - - /** - * Gets a brew from the key passed in, returns the fallback if - * it's not in the map. - */ - public static Brew getBrewFromKey(String key) { - if (brewMap.containsKey(key)) return brewMap.get(key); - return fallbackBrew; - } - - /* - * Registers a Block as disposable using its Ore Dictionary Name. - */ - public static void registerDisposableBlock(String oreDictName) { - disposableBlocks.add(oreDictName); - } - - /* - * Registers a Block as semi disposable using its Ore Dictionary Name. - * This means it will not be trashed when sneaking. - */ - public static void registerSemiDisposableBlock(String oreDictName) { - semiDisposableBlocks.add(oreDictName); - } - - /** - * Registers a paintableBlock and returns it. - */ - public static Block registerPaintableBlock(Block paintable) { - paintableBlocks.add(paintable); - return paintable; - } - - /* - * Blacklists an Entity from being affected by the Rod of the Shaded Mesa. - * Pass in the class for the Entity, e.g. EntityCow.class - */ - public static void blacklistEntityFromGravityRod(Class entity) { - gravityRodBlacklist.add(entity); - } - - /* - * Checks if the provided Entity is contained in the Blacklist. - * Pass in the class for the Entity, e.g. entity.getClass() - */ - public static boolean isEntityBlacklistedFromGravityRod(Class entity) { - return gravityRodBlacklist.contains(entity); - } - - /** - * Blacklists an item from being pulled by the Ring of Magnetization. - * Short.MAX_VALUE can be used as the stack's damage for a wildcard. - */ - public static void blacklistItemFromMagnet(ItemStack stack) { - String key = getMagnetKey(stack); - magnetBlacklist.add(key); - } - - /** - * Blacklists a block from having items on top of it being pulled by the Ring of Magnetization. - * Short.MAX_VALUE can be used as meta for a wildcard. - */ - public static void blacklistBlockFromMagnet(Block block, int meta) { - String key = getMagnetKey(block, meta); - magnetBlacklist.add(key); - } - - public static boolean isItemBlacklistedFromMagnet(ItemStack stack) { - return isItemBlacklistedFromMagnet(stack, 0); - } - - public static boolean isItemBlacklistedFromMagnet(ItemStack stack, int recursion) { - if (recursion > 5) return false; - - if (stack.getItemDamage() != Short.MAX_VALUE) { - ItemStack copy = new ItemStack(stack.getItem(), 0, Short.MAX_VALUE); - boolean general = isItemBlacklistedFromMagnet(copy, recursion + 1); - if (general) return true; - } - - String key = getMagnetKey(stack); - return magnetBlacklist.contains(key); - } - - public static boolean isBlockBlacklistedFromMagnet(Block block, int meta) { - return isBlockBlacklistedFromMagnet(block, meta, 0); - } - - public static boolean isBlockBlacklistedFromMagnet(Block block, int meta, int recursion) { - if (recursion >= 5) return false; - - if (meta != Short.MAX_VALUE) { - boolean general = isBlockBlacklistedFromMagnet(block, Short.MAX_VALUE, recursion + 1); - if (general) return true; - } - - String key = getMagnetKey(block, meta); - return magnetBlacklist.contains(key); - } - - /** - * Registers a Petal Recipe. - * @param output The ItemStack to craft. - * @param inputs The objects for crafting. Can be ItemStack, MappableStackWrapper - * or String (case for Ore Dictionary). The array can't be larger than 16. - * @return The recipe created. - */ - public static RecipePetals registerPetalRecipe(ItemStack output, Object... inputs) { - RecipePetals recipe = new RecipePetals(output, inputs); - petalRecipes.add(recipe); - return recipe; - } - - /** - * Registers a Pure Daisy Recipe. - * @param input The block that works as an input for the recipe. Can be a Block or an oredict String. - * @param output The block to be placed upon recipe completion. - * @param outputMeta The metadata to be placed upon recipe completion. - * @return The recipe created. - */ - public static RecipePureDaisy registerPureDaisyRecipe(Object input, Block output, int outputMeta) { - RecipePureDaisy recipe = new RecipePureDaisy(input, output, outputMeta); - pureDaisyRecipes.add(recipe); - return recipe; - } - - /** - * Registers a Rune Altar Recipe. - * @param output The ItemStack to craft. - * @param mana The amount of mana required. Don't go over 100000! - * @param inputs The objects for crafting. Can be ItemStack, MappableStackWrapper - * or String (case for Ore Dictionary). The array can't be larger than 16. - * @return The recipe created. - */ - public static RecipeRuneAltar registerRuneAltarRecipe(ItemStack output, int mana, Object... inputs) { - RecipeRuneAltar recipe = new RecipeRuneAltar(output, mana, inputs); - runeAltarRecipes.add(recipe); - return recipe; - } - - /** - * Registers a Mana Infusion Recipe (throw an item in a mana pool) - * @param output The ItemStack to craft - * @param input The input item, be it an ItemStack or an ore dictionary entry String. - * @param mana The amount of mana required. Don't go over 100000! - * @return The recipe created. - */ - public static RecipeManaInfusion registerManaInfusionRecipe(ItemStack output, Object input, int mana) { - RecipeManaInfusion recipe = new RecipeManaInfusion(output, input, mana); - manaInfusionRecipes.add(recipe); - return recipe; - } - - /** - * Register a Mana Infusion Recipe and flags it as an Alchemy recipe (requires an - * Alchemy Catalyst below the pool). - * @see BotaniaAPI#registerManaInfusionRecipe - */ - public static RecipeManaInfusion registerManaAlchemyRecipe(ItemStack output, Object input, int mana) { - RecipeManaInfusion recipe = new RecipeManaInfusion(output, input, mana); - recipe.setAlchemy(true); - manaInfusionRecipes.add(0, recipe); - return recipe; - } - - /** - * Register a Mana Infusion Recipe and flags it as an Conjuration recipe (requires a - * Conjuration Catalyst below the pool). - * @see BotaniaAPI#registerManaInfusionRecipe - */ - public static RecipeManaInfusion registerManaConjurationRecipe(ItemStack output, Object input, int mana) { - RecipeManaInfusion recipe = new RecipeManaInfusion(output, input, mana); - recipe.setConjuration(true); - manaInfusionRecipes.add(0, recipe); - return recipe; - } - - /** - * Registers a Elven Trade recipe (throw an item in an Alfheim Portal). - * @param output The ItemStack to return. - * @param inputs The items required, can be ItemStack or ore dictionary entry string. - * @return The recipe created. - */ - public static RecipeElvenTrade registerElvenTradeRecipe(ItemStack output, Object... inputs) { - RecipeElvenTrade recipe = new RecipeElvenTrade(output, inputs); - elvenTradeRecipes.add(recipe); - return recipe; - } - - /** - * Registers a Brew Recipe (for the Botanical Brewery). - * @param brew The brew in to be set in this recipe. - * @inputs The items used in the recipe, no more than 6. - */ - public static RecipeBrew registerBrewRecipe(Brew brew, Object... inputs) { - RecipeBrew recipe = new RecipeBrew(brew, inputs); - brewRecipes.add(recipe); - return recipe; - } - - /** - * Registers a SubTileEntity, a new special flower. Look in the subtile package of the API. - * If you call this after PostInit you're a failiure and we are very disappointed in you. - */ - public static void registerSubTile(String key, Class subtileClass) { - subTiles.put(key, subtileClass); - subTileMods.put(key, Loader.instance().activeModContainer().getModId()); - } - - /** - * Register a SubTileEntity and makes it a mini flower. Also adds the recipe and returns it. - * @see BotaniaAPI#registerSubTile - */ - public static RecipeManaInfusion registerMiniSubTile( - String key, Class subtileClass, String original) { - registerSubTile(key, subtileClass); - miniFlowers.put(original, key); - - RecipeMiniFlower recipe = new RecipeMiniFlower(key, original, 2500); - manaInfusionRecipes.add(recipe); - miniFlowerRecipes.add(recipe); - return recipe; - } - - /** - * Registers a SubTileEntity's signature. - * @see SubTileSignature - */ - public static void registerSubTileSignature( - Class subtileClass, SubTileSignature signature) { - subTileSignatures.put(subtileClass, signature); - } - - /** - * Gets the singleton signature for a SubTileEntity class. Registers a fallback if one wasn't registered - * before the call. - */ - public static SubTileSignature getSignatureForClass(Class subtileClass) { - if (!subTileSignatures.containsKey(subtileClass)) - registerSubTileSignature( - subtileClass, new BasicSignature(subTiles.inverse().get(subtileClass))); - - return subTileSignatures.get(subtileClass); - } - - /** - * Gets the singleton signature for a SubTileEntity's name. Registers a fallback if one wasn't registered - * before the call. - */ - public static SubTileSignature getSignatureForName(String name) { - Class subtileClass = subTiles.get(name); - return getSignatureForClass(subtileClass); - } - - /** - * Adds the key for a SubTileEntity into the creative menu. This goes into the - * subtilesForCreativeMenu Set. This does not need to be called for mini flowers, - * those will just use the mini flower map to add themselves next to the source. - */ - public static void addSubTileToCreativeMenu(String key) { - subtilesForCreativeMenu.add(key); - } - - /** - * Adds a category to the list of registered categories to appear in the Lexicon. - */ - public static void addCategory(LexiconCategory category) { - categories.add(category); - } - - /** - * Gets all registered categories. - */ - public static List getAllCategories() { - return categories; - } - - /** - * Gets all registered entries. - */ - public static List getAllEntries() { - return allEntries; - } - - /** - * Registers a Lexicon Entry and adds it to the category passed in. - */ - public static void addEntry(LexiconEntry entry, LexiconCategory category) { - allEntries.add(entry); - category.entries.add(entry); - } - - /** - * Maps an ore (ore dictionary key) to it's weight on the world generation. This - * is used for the Orechid flower. Check the static block in the BotaniaAPI class - * to get the weights for the vanilla blocks.
- * Alternatively get the values with the OreDetector mod:
- * https://gist.github.com/Vazkii/9493322 - */ - public static void addOreWeight(String ore, int weight) { - oreWeights.put(ore, weight); - } - - /** - * Maps an ore (ore dictionary key) to it's weight on the nether world generation. This - * is used for the Orechid Ignem flower. Check the static block in the BotaniaAPI class - * to get the weights for the vanilla blocks.
- * Alternatively get the values with the OreDetector mod:
- * https://gist.github.com/Vazkii/9493322 - */ - public static void addOreWeightNether(String ore, int weight) { - if (ore.contains("Nether") - && OreDictionary.getOres(ore.replace("Nether", "")).size() == 0) return; - - oreWeightsNether.put(ore, weight); - } - - public static int getOreWeight(String ore) { - return oreWeights.get(ore); - } - - public static int getOreWeightNether(String ore) { - return oreWeightsNether.get(ore); - } - - /** - * Allows an item to be counted as a seed. Any item in this list can be - * dispensed by a dispenser, the block is the block to be placed. - */ - public static void addSeed(Item item, Block block) { - seeds.put(item, block); - } - - /** - * Blacklists an item from the Loonium drop table. - */ - public static void blackListItemFromLoonium(Item item) { - looniumBlacklist.add(item); - } - - /** - * Gets the last recipe to have been added to the recipe list. - */ - public static IRecipe getLatestAddedRecipe() { - List list = CraftingManager.getInstance().getRecipeList(); - return list.get(list.size() - 1); - } - - /** - * Gets the last x recipes added to the recipe list. - */ - public static List getLatestAddedRecipes(int x) { - List list = CraftingManager.getInstance().getRecipeList(); - List newList = new ArrayList(); - for (int i = x - 1; i >= 0; i--) newList.add(list.get(list.size() - 1 - i)); - - return newList; - } - - /** - * Registers a Wiki provider for a mod so it uses that instead of the fallback - * FTB wiki. Make sure to call this on PostInit only! - */ - public static void registerModWiki(String mod, IWikiProvider provider) { - WikiHooks.registerModWiki(mod, provider); - } - - public static Class getSubTileMapping(String key) { - if (!subTiles.containsKey(key)) key = ""; - - return subTiles.get(key); - } - - public static String getSubTileStringMapping(Class clazz) { - return subTiles.inverse().get(clazz); - } - - public static Set getAllSubTiles() { - return subTiles.keySet(); - } - - private static String getMagnetKey(ItemStack stack) { - if (stack == null) return ""; - - return "i_" + stack.getItem().getUnlocalizedName() + "@" + stack.getItemDamage(); - } - - private static String getMagnetKey(Block block, int meta) { - return "bm_" + block.getUnlocalizedName() + "@" + meta; - } + private static List categories = new ArrayList(); + private static List allEntries = new ArrayList(); + + public static Map knowledgeTypes = new HashMap(); + + public static Map brewMap = new LinkedHashMap(); + + public static List disposableBlocks = new ArrayList(); + public static List semiDisposableBlocks = new ArrayList(); + + public static List petalRecipes = new ArrayList(); + public static List pureDaisyRecipes = new ArrayList(); + public static List manaInfusionRecipes = new ArrayList(); + public static List runeAltarRecipes = new ArrayList(); + public static List elvenTradeRecipes = new ArrayList(); + public static List brewRecipes = new ArrayList(); + public static List miniFlowerRecipes = new ArrayList(); + + private static BiMap> subTiles = HashBiMap.> create(); + private static Map, SubTileSignature> subTileSignatures = new HashMap, SubTileSignature>(); + public static Set subtilesForCreativeMenu = new LinkedHashSet(); + public static Map subTileMods = new HashMap(); + public static BiMap miniFlowers = HashBiMap. create(); + + public static Map oreWeights = new HashMap(); + public static Map oreWeightsNether = new HashMap(); + public static Map seeds = new HashMap(); + public static Set looniumBlacklist = new LinkedHashSet(); + public static Set paintableBlocks = new LinkedHashSet(); + public static Set magnetBlacklist = new LinkedHashSet(); + public static Set> gravityRodBlacklist = new LinkedHashSet>(); + + public static ArmorMaterial manasteelArmorMaterial = EnumHelper.addArmorMaterial("MANASTEEL", 16, new int[] { 2, 6, 5, 2 }, 18); + public static ToolMaterial manasteelToolMaterial = EnumHelper.addToolMaterial("MANASTEEL", 3, 300, 6.2F, 2F, 20); + + public static ArmorMaterial elementiumArmorMaterial = EnumHelper.addArmorMaterial("B_ELEMENTIUM", 18, new int[] { 2, 6, 5, 2 }, 18); + public static ToolMaterial elementiumToolMaterial = EnumHelper.addToolMaterial("B_ELEMENTIUM", 3, 720, 6.2F, 2F, 20); + + public static ArmorMaterial terrasteelArmorMaterial = EnumHelper.addArmorMaterial("TERRASTEEL", 34, new int[] {3, 8, 6, 3}, 26); + public static ToolMaterial terrasteelToolMaterial = EnumHelper.addToolMaterial("TERRASTEEL", 4, 2300, 9F, 3F, 26); + + public static ArmorMaterial manaweaveArmorMaterial = EnumHelper.addArmorMaterial("MANAWEAVE", 5, new int[] { 1, 2, 2, 1 }, 18); + + public static EnumRarity rarityRelic = EnumHelper.addRarity("RELIC", EnumChatFormatting.GOLD, "Relic"); + + public static KnowledgeType basicKnowledge; + public static KnowledgeType elvenKnowledge; + + // This is here for completeness sake, but you shouldn't use it + public static KnowledgeType relicKnowledge; + + // All of these categories are initialized during botania's PreInit stage. + public static LexiconCategory categoryBasics; + public static LexiconCategory categoryMana; + public static LexiconCategory categoryFunctionalFlowers; + public static LexiconCategory categoryGenerationFlowers; + public static LexiconCategory categoryDevices; + public static LexiconCategory categoryTools; + public static LexiconCategory categoryBaubles; + public static LexiconCategory categoryEnder; + public static LexiconCategory categoryAlfhomancy; + public static LexiconCategory categoryMisc; + + public static Brew fallbackBrew = new Brew("fallback", "botania.brew.fallback", 0, 0); + + static { + registerSubTile("", DummySubTile.class); + + basicKnowledge = registerKnowledgeType("minecraft", EnumChatFormatting.RESET, true); + elvenKnowledge = registerKnowledgeType("alfheim", EnumChatFormatting.DARK_GREEN, false); + relicKnowledge = registerKnowledgeType("relic", EnumChatFormatting.DARK_PURPLE, false); + + addOreWeight("oreAluminum", 3940); // Tinkers' Construct + addOreWeight("oreAmber", 2075); // Thaumcraft + addOreWeight("oreApatite", 1595); // Forestry + addOreWeight("oreBlueTopaz", 3195); // Ars Magica + addOreWeight("oreCertusQuartz", 3975); // Applied Energistics + addOreWeight("oreChimerite", 3970); // Ars Magica + addOreWeight("oreCinnabar", 2585); // Thaumcraft + addOreWeight("oreCoal", 46525); // Vanilla + addOreWeight("oreCopper", 8325); // IC2, Thermal Expansion, Tinkers' Construct, etc. + addOreWeight("oreDark", 1350); // EvilCraft + addOreWeight("oreDarkIron", 1700); // Factorization (older versions) + addOreWeight("oreFzDarkIron", 1700); // Factorization (newer versions) + addOreWeight("oreDiamond", 1265); // Vanilla + addOreWeight("oreEmerald", 780); // Vanilla + addOreWeight("oreGalena", 1000); // Factorization + addOreWeight("oreGold", 2970); // Vanilla + addOreWeight("oreInfusedAir", 925); // Thaumcraft + addOreWeight("oreInfusedEarth", 925); // Thaumcraft + addOreWeight("oreInfusedEntropy", 925); // Thaumcraft + addOreWeight("oreInfusedFire", 925); // Thaumcraft + addOreWeight("oreInfusedOrder", 925); // Thaumcraft + addOreWeight("oreInfusedWater", 925); // Thaumcraft + addOreWeight("oreIron", 20665); // Vanilla + addOreWeight("oreLapis", 1285); // Vanilla + addOreWeight("oreLead", 7985); // IC2, Thermal Expansion, Factorization, etc. + addOreWeight("oreMCropsEssence", 3085); // Magical Crops + addOreWeight("oreMithril", 8); // Thermal Expansion + addOreWeight("oreNickel", 2275); // Thermal Expansion + addOreWeight("oreOlivine", 1100); // Project RED + addOreWeight("orePlatinum", 365); // Thermal Expansion + addOreWeight("oreRedstone", 6885); // Vanilla + addOreWeight("oreRuby", 1100); // Project RED + addOreWeight("oreSapphire", 1100); // Project RED + addOreWeight("oreSilver", 6300); // Thermal Expansion, Factorization, etc. + addOreWeight("oreSulfur", 1105); // Railcraft + addOreWeight("oreTin", 9450); // IC2, Thermal Expansion, etc. + addOreWeight("oreUranium", 1337); // IC2 + addOreWeight("oreVinteum", 5925); // Ars Magica + addOreWeight("oreYellorite", 3520); // Big Reactors + addOreWeight("oreZinc", 6485); // Flaxbeard's Steam Power + addOreWeight("oreMythril", 6485); // Simple Ores2 + addOreWeight("oreAdamantium", 2275); // Simple Ores2 + addOreWeight("oreTungsten", 3520); // Simple Tungsten + + addOreWeightNether("oreQuartz", 19600); // Vanilla + addOreWeightNether("oreCobalt", 500); // Tinker's Construct + addOreWeightNether("oreArdite", 500); // Tinker's Construct + addOreWeightNether("oreFirestone", 5); // Railcraft + addOreWeightNether("oreNetherCoal", 17000); // Nether Ores + addOreWeightNether("oreNetherCopper", 4700); // Nether Ores + addOreWeightNether("oreNetherDiamond", 175); // Nether Ores + addOreWeightNether("oreNetherEssence", 2460); // Magical Crops + addOreWeightNether("oreNetherGold", 3635); // Nether Ores + addOreWeightNether("oreNetherIron", 5790); // Nether Ores + addOreWeightNether("oreNetherLapis", 3250); // Nether Ores + addOreWeightNether("oreNetherLead", 2790); // Nether Ores + addOreWeightNether("oreNetherNickel", 1790); // Nether Ores + addOreWeightNether("oreNetherPlatinum", 170); // Nether Ores + addOreWeightNether("oreNetherRedstone", 5600); // Nether Ores + addOreWeightNether("oreNetherSilver", 1550); // Nether Ores + addOreWeightNether("oreNetherSteel", 1690); // Nether Ores + addOreWeightNether("oreNetherTin", 3750); // Nether Ores + addOreWeightNether("oreFyrite", 1000); // Netherrocks + addOreWeightNether("oreAshstone", 1000); // Netherrocks + addOreWeightNether("oreDragonstone", 175); // Netherrocks + addOreWeightNether("oreArgonite", 1000); // Netherrocks + addOreWeightNether("oreOnyx", 500); // SimpleOres 2 + addOreWeightNether("oreHaditeCoal", 500); // Hadite + + addSeed(Items.wheat_seeds, Blocks.wheat); + addSeed(Items.potato, Blocks.potatoes); + addSeed(Items.carrot, Blocks.carrots); + addSeed(Items.nether_wart, Blocks.nether_wart); + addSeed(Items.pumpkin_seeds, Blocks.pumpkin_stem); + addSeed(Items.melon_seeds, Blocks.melon_stem); + + registerModWiki("Minecraft", new SimpleWikiProvider("Minecraft Wiki", "http://minecraft.gamepedia.com/%s")); + + IWikiProvider technicWiki = new SimpleWikiProvider("Technic Wiki", "http://wiki.technicpack.net/%s"); + IWikiProvider mekanismWiki = new SimpleWikiProvider("Mekanism Wiki", "http://wiki.aidancbrady.com/wiki/%s"); + IWikiProvider buildcraftWiki = new SimpleWikiProvider("BuildCraft Wiki", "http://www.mod-buildcraft.com/wiki/doku.php?id=%s"); + + registerModWiki("Mekanism", mekanismWiki); + registerModWiki("MekanismGenerators", mekanismWiki); + registerModWiki("MekanismTools", mekanismWiki); + registerModWiki("EnderIO", new SimpleWikiProvider("EnderIO Wiki", "http://wiki.enderio.com/%s")); + registerModWiki("TropiCraft", new SimpleWikiProvider("Tropicraft Wiki", "http://wiki.tropicraft.net/wiki/%s")); + registerModWiki("RandomThings", new SimpleWikiProvider("Random Things Wiki", "http://randomthingsminecraftmod.wikispaces.com/%s")); + registerModWiki("Witchery", new SimpleWikiProvider("Witchery Wiki", "https://sites.google.com/site/witcherymod/%s", "-", true)); + registerModWiki("AppliedEnergistics2", new SimpleWikiProvider("AE2 Wiki", "http://ae-mod.info/%s")); + registerModWiki("BigReactors", technicWiki); + registerModWiki("BuildCraft|Core", buildcraftWiki); + registerModWiki("BuildCraft|Builders", buildcraftWiki); + registerModWiki("BuildCraft|Energy", buildcraftWiki); + registerModWiki("BuildCraft|Factory", buildcraftWiki); + registerModWiki("BuildCraft|Silicon", buildcraftWiki); + registerModWiki("BuildCraft|Transport", buildcraftWiki); + registerModWiki("ArsMagica2", new SimpleWikiProvider("ArsMagica2 Wiki", "http://wiki.arsmagicamod.com/wiki/%s")); + registerModWiki("PneumaticCraft", new SimpleWikiProvider("PneumaticCraft Wiki", "http://www.minemaarten.com/wikis/pneumaticcraft-wiki/pneumaticcraft-wiki-%s")); + registerModWiki("StevesCarts2", new SimpleWikiProvider("Steve's Carts Wiki", "http://stevescarts2.wikispaces.com/%s")); + registerModWiki("GanysSurface", new SimpleWikiProvider("Gany's Surface Wiki", "http://ganys-surface.wikia.com/wiki/%s")); + registerModWiki("GanysNether", new SimpleWikiProvider("Gany's Nether Wiki", "http://ganys-nether.wikia.com/wiki/%s")); + registerModWiki("GanysEnd", new SimpleWikiProvider("Gany's End Wiki", "http://ganys-end.wikia.com/wiki/%s")); + + registerPaintableBlock(Blocks.stained_glass); + registerPaintableBlock(Blocks.stained_glass_pane); + registerPaintableBlock(Blocks.stained_hardened_clay); + registerPaintableBlock(Blocks.wool); + registerPaintableBlock(Blocks.carpet); + + registerDisposableBlock("dirt"); // Vanilla + registerDisposableBlock("sand"); // Vanilla + registerDisposableBlock("gravel"); // Vanilla + registerDisposableBlock("cobblestone"); // Vanilla + registerDisposableBlock("netherrack"); // Vanilla + registerSemiDisposableBlock("stoneAndesite"); // Botania + registerSemiDisposableBlock("stoneBasalt"); // Botania + registerSemiDisposableBlock("stoneDiorite"); // Botania + registerSemiDisposableBlock("stoneGranite"); // Botania + } + + /** + * The internal method handler in use. + * DO NOT OVERWRITE THIS OR YOU'RE GOING TO FEEL MY WRATH WHEN I UPDATE THE API. + * The fact I have to write that means some moron already tried, don't be that moron. + * @see IInternalMethodHandler + */ + public static IInternalMethodHandler internalHandler = new DummyMethodHandler(); + + /** + * Registers a new Knowledge Type. + * @param id The ID for this knowledge type. + * @param color The color to display this knowledge type as. + */ + public static KnowledgeType registerKnowledgeType(String id, EnumChatFormatting color, boolean autoUnlock) { + KnowledgeType type = new KnowledgeType(id, color, autoUnlock); + knowledgeTypes.put(id, type); + return type; + } + + /** + * Registers a Brew and returns it. + */ + public static Brew registerBrew(Brew brew) { + brewMap.put(brew.getKey(), brew); + return brew; + } + + /** + * Gets a brew from the key passed in, returns the fallback if + * it's not in the map. + */ + public static Brew getBrewFromKey(String key) { + if(brewMap.containsKey(key)) + return brewMap.get(key); + return fallbackBrew; + } + + /* + * Registers a Block as disposable using its Ore Dictionary Name. + */ + public static void registerDisposableBlock(String oreDictName) { + disposableBlocks.add(oreDictName); + } + + /* + * Registers a Block as semi disposable using its Ore Dictionary Name. + * This means it will not be trashed when sneaking. + */ + public static void registerSemiDisposableBlock(String oreDictName) { + semiDisposableBlocks.add(oreDictName); + } + + /** + * Registers a paintableBlock and returns it. + */ + public static Block registerPaintableBlock(Block paintable){ + paintableBlocks.add(paintable); + return paintable; + } + + /* + * Blacklists an Entity from being affected by the Rod of the Shaded Mesa. + * Pass in the class for the Entity, e.g. EntityCow.class + */ + public static void blacklistEntityFromGravityRod(Class entity) { + gravityRodBlacklist.add(entity); + } + + /* + * Checks if the provided Entity is contained in the Blacklist. + * Pass in the class for the Entity, e.g. entity.getClass() + */ + public static boolean isEntityBlacklistedFromGravityRod(Class entity) { + return gravityRodBlacklist.contains(entity); + } + + /** + * Blacklists an item from being pulled by the Ring of Magnetization. + * Short.MAX_VALUE can be used as the stack's damage for a wildcard. + */ + public static void blacklistItemFromMagnet(ItemStack stack) { + String key = getMagnetKey(stack); + magnetBlacklist.add(key); + } + + /** + * Blacklists a block from having items on top of it being pulled by the Ring of Magnetization. + * Short.MAX_VALUE can be used as meta for a wildcard. + */ + public static void blacklistBlockFromMagnet(Block block, int meta) { + String key = getMagnetKey(block, meta); + magnetBlacklist.add(key); + } + + public static boolean isItemBlacklistedFromMagnet(ItemStack stack) { + return isItemBlacklistedFromMagnet(stack, 0); + } + + public static boolean isItemBlacklistedFromMagnet(ItemStack stack, int recursion) { + if(recursion > 5) + return false; + + if(stack.getItemDamage() != Short.MAX_VALUE) { + ItemStack copy = new ItemStack(stack.getItem(), 0, Short.MAX_VALUE); + boolean general = isItemBlacklistedFromMagnet(copy, recursion + 1); + if(general) + return true; + } + + String key = getMagnetKey(stack); + return magnetBlacklist.contains(key); + } + + public static boolean isBlockBlacklistedFromMagnet(Block block, int meta) { + return isBlockBlacklistedFromMagnet(block, meta, 0); + } + + public static boolean isBlockBlacklistedFromMagnet(Block block, int meta, int recursion) { + if(recursion >= 5) + return false; + + if(meta != Short.MAX_VALUE) { + boolean general = isBlockBlacklistedFromMagnet(block, Short.MAX_VALUE, recursion + 1); + if(general) + return true; + } + + String key = getMagnetKey(block, meta); + return magnetBlacklist.contains(key); + } + + /** + * Registers a Petal Recipe. + * @param output The ItemStack to craft. + * @param inputs The objects for crafting. Can be ItemStack, MappableStackWrapper + * or String (case for Ore Dictionary). The array can't be larger than 16. + * @return The recipe created. + */ + public static RecipePetals registerPetalRecipe(ItemStack output, Object... inputs) { + RecipePetals recipe = new RecipePetals(output, inputs); + petalRecipes.add(recipe); + return recipe; + } + + /** + * Registers a Pure Daisy Recipe. + * @param input The block that works as an input for the recipe. Can be a Block or an oredict String. + * @param output The block to be placed upon recipe completion. + * @param outputMeta The metadata to be placed upon recipe completion. + * @return The recipe created. + */ + public static RecipePureDaisy registerPureDaisyRecipe(Object input, Block output, int outputMeta) { + RecipePureDaisy recipe = new RecipePureDaisy(input, output, outputMeta); + pureDaisyRecipes.add(recipe); + return recipe; + } + + /** + * Registers a Rune Altar Recipe. + * @param output The ItemStack to craft. + * @param mana The amount of mana required. Don't go over 100000! + * @param inputs The objects for crafting. Can be ItemStack, MappableStackWrapper + * or String (case for Ore Dictionary). The array can't be larger than 16. + * @return The recipe created. + */ + public static RecipeRuneAltar registerRuneAltarRecipe(ItemStack output, int mana, Object... inputs) { + RecipeRuneAltar recipe = new RecipeRuneAltar(output, mana, inputs); + runeAltarRecipes.add(recipe); + return recipe; + } + + /** + * Registers a Mana Infusion Recipe (throw an item in a mana pool) + * @param output The ItemStack to craft + * @param input The input item, be it an ItemStack or an ore dictionary entry String. + * @param mana The amount of mana required. Don't go over 100000! + * @return The recipe created. + */ + public static RecipeManaInfusion registerManaInfusionRecipe(ItemStack output, Object input, int mana) { + RecipeManaInfusion recipe = new RecipeManaInfusion(output, input, mana); + manaInfusionRecipes.add(recipe); + return recipe; + } + + /** + * Register a Mana Infusion Recipe and flags it as an Alchemy recipe (requires an + * Alchemy Catalyst below the pool). + * @see BotaniaAPI#registerManaInfusionRecipe + */ + public static RecipeManaInfusion registerManaAlchemyRecipe(ItemStack output, Object input, int mana) { + RecipeManaInfusion recipe = new RecipeManaInfusion(output, input, mana); + recipe.setAlchemy(true); + manaInfusionRecipes.add(0, recipe); + return recipe; + } + + /** + * Register a Mana Infusion Recipe and flags it as an Conjuration recipe (requires a + * Conjuration Catalyst below the pool). + * @see BotaniaAPI#registerManaInfusionRecipe + */ + public static RecipeManaInfusion registerManaConjurationRecipe(ItemStack output, Object input, int mana) { + RecipeManaInfusion recipe = new RecipeManaInfusion(output, input, mana); + recipe.setConjuration(true); + manaInfusionRecipes.add(0, recipe); + return recipe; + } + + /** + * Registers a Elven Trade recipe (throw an item in an Alfheim Portal). + * @param output The ItemStack to return. + * @param inputs The items required, can be ItemStack or ore dictionary entry string. + * @return The recipe created. + */ + public static RecipeElvenTrade registerElvenTradeRecipe(ItemStack output, Object... inputs) { + RecipeElvenTrade recipe = new RecipeElvenTrade(output, inputs); + elvenTradeRecipes.add(recipe); + return recipe; + } + + /** + * Registers a Brew Recipe (for the Botanical Brewery). + * @param brew The brew in to be set in this recipe. + * @inputs The items used in the recipe, no more than 6. + */ + public static RecipeBrew registerBrewRecipe(Brew brew, Object... inputs) { + RecipeBrew recipe = new RecipeBrew(brew, inputs); + brewRecipes.add(recipe); + return recipe; + } + + /** + * Registers a SubTileEntity, a new special flower. Look in the subtile package of the API. + * If you call this after PostInit you're a failiure and we are very disappointed in you. + */ + public static void registerSubTile(String key, Class subtileClass) { + subTiles.put(key, subtileClass); + subTileMods.put(key, Loader.instance().activeModContainer().getModId()); + } + + /** + * Register a SubTileEntity and makes it a mini flower. Also adds the recipe and returns it. + * @see BotaniaAPI#registerSubTile + */ + public static RecipeManaInfusion registerMiniSubTile(String key, Class subtileClass, String original) { + registerSubTile(key, subtileClass); + miniFlowers.put(original, key); + + RecipeMiniFlower recipe = new RecipeMiniFlower(key, original, 2500); + manaInfusionRecipes.add(recipe); + miniFlowerRecipes.add(recipe); + return recipe; + } + + /** + * Registers a SubTileEntity's signature. + * @see SubTileSignature + */ + public static void registerSubTileSignature(Class subtileClass, SubTileSignature signature) { + subTileSignatures.put(subtileClass, signature); + } + + /** + * Gets the singleton signature for a SubTileEntity class. Registers a fallback if one wasn't registered + * before the call. + */ + public static SubTileSignature getSignatureForClass(Class subtileClass) { + if(!subTileSignatures.containsKey(subtileClass)) + registerSubTileSignature(subtileClass, new BasicSignature(subTiles.inverse().get(subtileClass))); + + return subTileSignatures.get(subtileClass); + } + + /** + * Gets the singleton signature for a SubTileEntity's name. Registers a fallback if one wasn't registered + * before the call. + */ + public static SubTileSignature getSignatureForName(String name) { + Class subtileClass = subTiles.get(name); + return getSignatureForClass(subtileClass); + } + + /** + * Adds the key for a SubTileEntity into the creative menu. This goes into the + * subtilesForCreativeMenu Set. This does not need to be called for mini flowers, + * those will just use the mini flower map to add themselves next to the source. + */ + public static void addSubTileToCreativeMenu(String key) { + subtilesForCreativeMenu.add(key); + } + + /** + * Adds a category to the list of registered categories to appear in the Lexicon. + */ + public static void addCategory(LexiconCategory category) { + categories.add(category); + } + + /** + * Gets all registered categories. + */ + public static List getAllCategories() { + return categories; + } + + /** + * Gets all registered entries. + */ + public static List getAllEntries() { + return allEntries; + } + + /** + * Registers a Lexicon Entry and adds it to the category passed in. + */ + public static void addEntry(LexiconEntry entry, LexiconCategory category) { + allEntries.add(entry); + category.entries.add(entry); + } + + /** + * Maps an ore (ore dictionary key) to it's weight on the world generation. This + * is used for the Orechid flower. Check the static block in the BotaniaAPI class + * to get the weights for the vanilla blocks.
+ * Alternatively get the values with the OreDetector mod:
+ * https://gist.github.com/Vazkii/9493322 + */ + public static void addOreWeight(String ore, int weight) { + oreWeights.put(ore, weight); + } + + /** + * Maps an ore (ore dictionary key) to it's weight on the nether world generation. This + * is used for the Orechid Ignem flower. Check the static block in the BotaniaAPI class + * to get the weights for the vanilla blocks.
+ * Alternatively get the values with the OreDetector mod:
+ * https://gist.github.com/Vazkii/9493322 + */ + public static void addOreWeightNether(String ore, int weight) { + if(ore.contains("Nether") && OreDictionary.getOres(ore.replace("Nether", "")).size() == 0) + return; + + oreWeightsNether.put(ore, weight); + } + + public static int getOreWeight(String ore) { + return oreWeights.get(ore); + } + + public static int getOreWeightNether(String ore) { + return oreWeightsNether.get(ore); + } + + /** + * Allows an item to be counted as a seed. Any item in this list can be + * dispensed by a dispenser, the block is the block to be placed. + */ + public static void addSeed(Item item, Block block) { + seeds.put(item, block); + } + + /** + * Blacklists an item from the Loonium drop table. + */ + public static void blackListItemFromLoonium(Item item) { + looniumBlacklist.add(item); + } + + /** + * Gets the last recipe to have been added to the recipe list. + */ + public static IRecipe getLatestAddedRecipe() { + List list = CraftingManager.getInstance().getRecipeList(); + return list.get(list.size() - 1); + } + + /** + * Gets the last x recipes added to the recipe list. + */ + public static List getLatestAddedRecipes(int x) { + List list = CraftingManager.getInstance().getRecipeList(); + List newList = new ArrayList(); + for(int i = x - 1; i >= 0; i--) + newList.add(list.get(list.size() - 1 - i)); + + return newList; + } + + /** + * Registers a Wiki provider for a mod so it uses that instead of the fallback + * FTB wiki. Make sure to call this on PostInit only! + */ + public static void registerModWiki(String mod, IWikiProvider provider) { + WikiHooks.registerModWiki(mod, provider); + } + + public static Class getSubTileMapping(String key) { + if(!subTiles.containsKey(key)) + key = ""; + + return subTiles.get(key); + } + + public static String getSubTileStringMapping(Class clazz) { + return subTiles.inverse().get(clazz); + } + + public static Set getAllSubTiles() { + return subTiles.keySet(); + } + + private static String getMagnetKey(ItemStack stack) { + if(stack == null) + return ""; + + return "i_" + stack.getItem().getUnlocalizedName() + "@" + stack.getItemDamage(); + } + + private static String getMagnetKey(Block block, int meta) { + return "bm_" + block.getUnlocalizedName() + "@" + meta; + } + } diff --git a/src/main/java/vazkii/botania/api/boss/IBotaniaBoss.java b/src/main/java/vazkii/botania/api/boss/IBotaniaBoss.java index 4894feef04..d337e6ae8f 100644 --- a/src/main/java/vazkii/botania/api/boss/IBotaniaBoss.java +++ b/src/main/java/vazkii/botania/api/boss/IBotaniaBoss.java @@ -2,20 +2,21 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Oct 29, 2014, 6:09:48 PM (GMT)] */ package vazkii.botania.api.boss; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; import java.awt.Rectangle; + import net.minecraft.client.gui.ScaledResolution; import net.minecraft.entity.boss.IBossDisplayData; import net.minecraft.util.ResourceLocation; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; /** * An extension of IBossDisplayData. This counts as a botania boss and as a normal @@ -27,35 +28,35 @@ */ public interface IBotaniaBoss extends IBossDisplayData { - /** - * The ResourceLocation to bind for this boss's boss bar. - * You can use BotaniaAPI.internalMethodHandler.getDefaultBossBarTexture() to get - * the one used by botania bosses. - */ - @SideOnly(Side.CLIENT) - public ResourceLocation getBossBarTexture(); + /** + * The ResourceLocation to bind for this boss's boss bar. + * You can use BotaniaAPI.internalMethodHandler.getDefaultBossBarTexture() to get + * the one used by botania bosses. + */ + @SideOnly(Side.CLIENT) + public ResourceLocation getBossBarTexture(); - /** - * A Rectangle instance delimiting the uv, width and height of this boss's - * boss bar texture. This is for the background, not the bar that shows - * the HP. - */ - @SideOnly(Side.CLIENT) - public Rectangle getBossBarTextureRect(); + /** + * A Rectangle instance delimiting the uv, width and height of this boss's + * boss bar texture. This is for the background, not the bar that shows + * the HP. + */ + @SideOnly(Side.CLIENT) + public Rectangle getBossBarTextureRect(); - /** - * A Rectangle instance delimiting the uv, width and height of this boss's - * boss bar HP texture. This is for the foreground that shows how much - * HP the boss has. The width of the rectangle will be multiplied by the - * faction of the boss's current HP by max HP. - */ - @SideOnly(Side.CLIENT) - public Rectangle getBossBarHPTextureRect(); + /** + * A Rectangle instance delimiting the uv, width and height of this boss's + * boss bar HP texture. This is for the foreground that shows how much + * HP the boss has. The width of the rectangle will be multiplied by the + * faction of the boss's current HP by max HP. + */ + @SideOnly(Side.CLIENT) + public Rectangle getBossBarHPTextureRect(); - /** - * A callback for when this boss's boss bar renders, you can do aditional rendering - * here if needed. - */ - @SideOnly(Side.CLIENT) - public void bossBarRenderCallback(ScaledResolution res, int x, int y); + /** + * A callback for when this boss's boss bar renders, you can do aditional rendering + * here if needed. + */ + @SideOnly(Side.CLIENT) + public void bossBarRenderCallback(ScaledResolution res, int x, int y); } diff --git a/src/main/java/vazkii/botania/api/boss/IBotaniaBossWithShader.java b/src/main/java/vazkii/botania/api/boss/IBotaniaBossWithShader.java index 2281356fd9..82221d37e6 100644 --- a/src/main/java/vazkii/botania/api/boss/IBotaniaBossWithShader.java +++ b/src/main/java/vazkii/botania/api/boss/IBotaniaBossWithShader.java @@ -2,17 +2,17 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Oct 29, 2014, 6:13:21 PM (GMT)] */ package vazkii.botania.api.boss; +import vazkii.botania.api.internal.ShaderCallback; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; -import vazkii.botania.api.internal.ShaderCallback; /** * A Botania boss whose HP bar makes use of shaders. Shaders @@ -23,19 +23,20 @@ */ public interface IBotaniaBossWithShader extends IBotaniaBoss { - /** - * The Shader Program to use for this boss bar. Return 0 case - * you don't want a shader to be used. You can use separate shaders - * for the background and foreground. - * @param background True if rendering the background of the boss bar, - * false if rendering the bar itself that shows the HP. - */ - @SideOnly(Side.CLIENT) - public int getBossBarShaderProgram(boolean background); + /** + * The Shader Program to use for this boss bar. Return 0 case + * you don't want a shader to be used. You can use separate shaders + * for the background and foreground. + * @param background True if rendering the background of the boss bar, + * false if rendering the bar itself that shows the HP. + */ + @SideOnly(Side.CLIENT) + public int getBossBarShaderProgram(boolean background); + + /** + * A callback for the shader, used to pass in uniforms. Return null for no callback. + */ + @SideOnly(Side.CLIENT) + public ShaderCallback getBossBarShaderCallback(boolean background, int shader); - /** - * A callback for the shader, used to pass in uniforms. Return null for no callback. - */ - @SideOnly(Side.CLIENT) - public ShaderCallback getBossBarShaderCallback(boolean background, int shader); } diff --git a/src/main/java/vazkii/botania/api/brew/Brew.java b/src/main/java/vazkii/botania/api/brew/Brew.java index ba3112bb50..d0dd6ba4d5 100644 --- a/src/main/java/vazkii/botania/api/brew/Brew.java +++ b/src/main/java/vazkii/botania/api/brew/Brew.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Nov 1, 2014, 6:22:54 PM (GMT)] */ package vazkii.botania.api.brew; @@ -13,6 +13,7 @@ import java.util.ArrayList; import java.util.Arrays; import java.util.List; + import net.minecraft.item.ItemStack; import net.minecraft.potion.PotionEffect; @@ -21,104 +22,105 @@ */ public class Brew { - String key; - String name; - int color; - int cost; - List effects; - boolean canInfuseBloodPendant = true; - boolean canInfuseIncense = true; - - /** - * @param name The unlocalized name of this potion. - * @param color The color for the potion to be rendered in the bottle, note that it will get - * changed a bit when it renders (for more or less brightness) to give a fancy effect. - * @param cost The cost, in Mana for this brew. - * @param effects A list of effects to apply to the player when they drink it. - */ - public Brew(String key, String name, int color, int cost, PotionEffect... effects) { - this.key = key; - this.name = name; - this.color = color; - this.cost = cost; - this.effects = new ArrayList(Arrays.asList(effects)); - } - - /** - * Sets this brew to not be able to be infused onto the Tainted Blood Pendant. - */ - public Brew setNotBloodPendantInfusable() { - canInfuseBloodPendant = false; - return this; - } - - /** - * Sets this brew to not be able to be infused onto Incense Sticks. - */ - public Brew setNotIncenseInfusable() { - canInfuseIncense = false; - return this; - } - - public boolean canInfuseBloodPendant() { - return canInfuseBloodPendant; - } - - public boolean canInfuseIncense() { - return canInfuseIncense; - } - - /** - * Returns the key for this brew, for it to be found in the map in the API. - * This should ALWAYS return the same result. - */ - public String getKey() { - return key; - } - - /** - * Gets the insensitive unlocalized name. This is used for the lexicon. - */ - public String getUnlocalizedName() { - return name; - } - - /** - * Gets the unlocalized name for the ItemStack passed in. - */ - public String getUnlocalizedName(ItemStack stack) { - return getUnlocalizedName(); - } - - /** - * Gets the display color for the ItemStack passed in. Note that for - * the lexicon, this passes in a botania Managlass Vial or an - * Alfglass Flask at all times. - */ - public int getColor(ItemStack stack) { - return color; - } - - /** - * Gets the insensitive unlocalized mana cost. This is used for the lexicon. - */ - public int getManaCost() { - return cost; - } - - /** - * Gets the mana cost for the ItemStack passed in. - */ - public int getManaCost(ItemStack stack) { - return getManaCost(); - } - - /** - * Gets the list of potion effects for the ItemStack passed in. - * Note that for the lexicon, this passes in a botania Managlass - * Vial or an Alfglass Flask at all times. - */ - public List getPotionEffects(ItemStack stack) { - return effects; - } + String key; + String name; + int color; + int cost; + List effects; + boolean canInfuseBloodPendant = true; + boolean canInfuseIncense = true; + + /** + * @param name The unlocalized name of this potion. + * @param color The color for the potion to be rendered in the bottle, note that it will get + * changed a bit when it renders (for more or less brightness) to give a fancy effect. + * @param cost The cost, in Mana for this brew. + * @param effects A list of effects to apply to the player when they drink it. + */ + public Brew(String key, String name, int color, int cost, PotionEffect... effects) { + this.key = key; + this.name = name; + this.color = color; + this.cost = cost; + this.effects = new ArrayList(Arrays.asList(effects)); + } + + /** + * Sets this brew to not be able to be infused onto the Tainted Blood Pendant. + */ + public Brew setNotBloodPendantInfusable() { + canInfuseBloodPendant = false; + return this; + } + + /** + * Sets this brew to not be able to be infused onto Incense Sticks. + */ + public Brew setNotIncenseInfusable() { + canInfuseIncense = false; + return this; + } + + public boolean canInfuseBloodPendant() { + return canInfuseBloodPendant; + } + + public boolean canInfuseIncense() { + return canInfuseIncense; + } + + /** + * Returns the key for this brew, for it to be found in the map in the API. + * This should ALWAYS return the same result. + */ + public String getKey() { + return key; + } + + /** + * Gets the insensitive unlocalized name. This is used for the lexicon. + */ + public String getUnlocalizedName() { + return name; + } + + /** + * Gets the unlocalized name for the ItemStack passed in. + */ + public String getUnlocalizedName(ItemStack stack) { + return getUnlocalizedName(); + } + + /** + * Gets the display color for the ItemStack passed in. Note that for + * the lexicon, this passes in a botania Managlass Vial or an + * Alfglass Flask at all times. + */ + public int getColor(ItemStack stack) { + return color; + } + + /** + * Gets the insensitive unlocalized mana cost. This is used for the lexicon. + */ + public int getManaCost() { + return cost; + } + + /** + * Gets the mana cost for the ItemStack passed in. + */ + public int getManaCost(ItemStack stack) { + return getManaCost(); + } + + /** + * Gets the list of potion effects for the ItemStack passed in. + * Note that for the lexicon, this passes in a botania Managlass + * Vial or an Alfglass Flask at all times. + */ + public List getPotionEffects(ItemStack stack) { + return effects; + } + } diff --git a/src/main/java/vazkii/botania/api/brew/IBrewContainer.java b/src/main/java/vazkii/botania/api/brew/IBrewContainer.java index 163692240a..0d155ecdb2 100644 --- a/src/main/java/vazkii/botania/api/brew/IBrewContainer.java +++ b/src/main/java/vazkii/botania/api/brew/IBrewContainer.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Nov 1, 2014, 6:26:40 PM (GMT)] */ package vazkii.botania.api.brew; @@ -19,16 +19,17 @@ */ public interface IBrewContainer { - /** - * Returs an ItemStack that should be an item that has the brew - * passed in. - */ - public ItemStack getItemForBrew(Brew brew, ItemStack stack); + /** + * Returs an ItemStack that should be an item that has the brew + * passed in. + */ + public ItemStack getItemForBrew(Brew brew, ItemStack stack); + + /** + * Gets the cost to add this brew onto this container. Return -1 + * to not allow for the brew to be added. Normally you'd + * use brew.getManaCost(stack); + */ + public int getManaCost(Brew brew, ItemStack stack); - /** - * Gets the cost to add this brew onto this container. Return -1 - * to not allow for the brew to be added. Normally you'd - * use brew.getManaCost(stack); - */ - public int getManaCost(Brew brew, ItemStack stack); } diff --git a/src/main/java/vazkii/botania/api/brew/IBrewItem.java b/src/main/java/vazkii/botania/api/brew/IBrewItem.java index 3d0d0dcef3..d51c9fa44b 100644 --- a/src/main/java/vazkii/botania/api/brew/IBrewItem.java +++ b/src/main/java/vazkii/botania/api/brew/IBrewItem.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Nov 1, 2014, 9:20:33 PM (GMT)] */ package vazkii.botania.api.brew; @@ -19,5 +19,6 @@ */ public interface IBrewItem { - public Brew getBrew(ItemStack brew); + public Brew getBrew(ItemStack brew); + } diff --git a/src/main/java/vazkii/botania/api/corporea/CorporeaHelper.java b/src/main/java/vazkii/botania/api/corporea/CorporeaHelper.java index 182073c187..d4934d7da2 100644 --- a/src/main/java/vazkii/botania/api/corporea/CorporeaHelper.java +++ b/src/main/java/vazkii/botania/api/corporea/CorporeaHelper.java @@ -2,14 +2,13 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Feb 14, 2015, 3:28:54 PM (GMT)] */ package vazkii.botania.api.corporea; - import java.util.ArrayList; import java.util.Collections; import java.util.HashMap; @@ -17,6 +16,7 @@ import java.util.Map; import java.util.WeakHashMap; import java.util.regex.Pattern; + import net.minecraft.inventory.IInventory; import net.minecraft.inventory.ISidedInventory; import net.minecraft.item.ItemStack; @@ -29,293 +29,293 @@ public final class CorporeaHelper { - private static final List empty = Collections.unmodifiableList(new ArrayList()); - private static final WeakHashMap, List> cachedNetworks = new WeakHashMap(); - private static final List autoCompleteControllers = - new ArrayList(); - - private static final Pattern patternControlCode = Pattern.compile("(?i)\\u00A7[0-9A-FK-OR]"); - - public static final String[] WILDCARD_STRINGS = new String[] {"...", "~", "+", "?", "*"}; - - /** - * How many items were matched in the last request. If java had "out" params like C# this wouldn't be needed :V - */ - public static int lastRequestMatches = 0; - /** - * How many items were extracted in the last request. - */ - public static int lastRequestExtractions = 0; - - /** - * Gets a list of all the inventories on this spark network. This list is cached for use once every tick, - * and if something changes during that tick it'll still have the first result. - */ - public static List getInventoriesOnNetwork(ICorporeaSpark spark) { - ICorporeaSpark master = spark.getMaster(); - if (master == null) return empty; - List network = master.getConnections(); - - if (cachedNetworks.containsKey(network)) { - List cache = cachedNetworks.get(network); - if (cache != null) return cache; - } - - List inventories = new ArrayList(); - if (network != null) - for (ICorporeaSpark otherSpark : network) - if (otherSpark != null) { - IInventory inv = otherSpark.getInventory(); - if (inv != null) inventories.add(inv); - } - - cachedNetworks.put(network, inventories); - return inventories; - } - - /** - * Gets the amount of available items in the network of the type passed in, checking NBT or not. - * The higher level functions that use a List< IInventory > or a Map< IInventory, Integer > should be - * called instead if the context for those exists to avoid having to get the values again. - */ - public static int getCountInNetwork(ItemStack stack, ICorporeaSpark spark, boolean checkNBT) { - List inventories = getInventoriesOnNetwork(spark); - return getCountInNetwork(stack, inventories, checkNBT); - } - - /** - * Gets the amount of available items in the network of the type passed in, checking NBT or not. - * The higher level function that use a Map< IInventory, Integer > should be - * called instead if the context for this exists to avoid having to get the value again. - */ - public static int getCountInNetwork(ItemStack stack, List inventories, boolean checkNBT) { - Map map = getInventoriesWithItemInNetwork(stack, inventories, checkNBT); - return getCountInNetwork(stack, map, checkNBT); - } - - /** - * Gets the amount of available items in the network of the type passed in, checking NBT or not. - */ - public static int getCountInNetwork(ItemStack stack, Map inventories, boolean checkNBT) { - int count = 0; - - for (IInventory inv : inventories.keySet()) count += inventories.get(inv); - - return count; - } - - /** - * Gets a Map mapping IInventories to the amount of items of the type passed in that exist - * The higher level function that use a List< IInventory > should be - * called instead if the context for this exists to avoid having to get the value again. - */ - public static Map getInventoriesWithItemInNetwork( - ItemStack stack, ICorporeaSpark spark, boolean checkNBT) { - List inventories = getInventoriesOnNetwork(spark); - return getInventoriesWithItemInNetwork(stack, inventories, checkNBT); - } - - /** - * Gets a Map mapping IInventories to the amount of items of the type passed in that exist - * The deeper level function that use a List< IInventory > should be - * called instead if the context for this exists to avoid having to get the value again. - */ - public static Map getInventoriesWithItemInNetwork( - ItemStack stack, List inventories, boolean checkNBT) { - Map countMap = new HashMap(); - List wrappedInventories = BotaniaAPI.internalHandler.wrapInventory(inventories); - for (IWrappedInventory inv : wrappedInventories) { - CorporeaRequest request = new CorporeaRequest(stack, checkNBT, -1); - inv.countItems(request); - if (request.foundItems > 0) { - countMap.put(inv.getWrappedObject(), request.foundItems); - } - } - - return countMap; - } - - /** - * Bridge for requestItem() using an ItemStack. - */ - public static List requestItem(ItemStack stack, ICorporeaSpark spark, boolean checkNBT, boolean doit) { - return requestItem(stack, stack.stackSize, spark, checkNBT, doit); - } - - /** - * Bridge for requestItem() using a String and an item count. - */ - public static List requestItem(String name, int count, ICorporeaSpark spark, boolean doit) { - return requestItem(name, count, spark, false, doit); - } - - /** - * Requests list of ItemStacks of the type passed in from the network, or tries to, checking NBT or not. - * This will remove the items from the adequate inventories unless the "doit" parameter is false. - * Returns a new list of ItemStacks of the items acquired or an empty list if none was found. - * Case itemCount is -1 it'll find EVERY item it can. - *

- * The "matcher" parameter has to be an ItemStack or a String, if the first it'll check if the - * two stacks are similar using the "checkNBT" parameter, else it'll check if the name of the item - * equals or matches (case a regex is passed in) the matcher string. - *

- * When requesting counting of items, individual stacks may exceed maxStackSize for - * purposes of counting huge amounts. - */ - public static List requestItem( - Object matcher, int itemCount, ICorporeaSpark spark, boolean checkNBT, boolean doit) { - List stacks = new ArrayList(); - CorporeaRequestEvent event = new CorporeaRequestEvent(matcher, itemCount, spark, checkNBT, doit); - if (MinecraftForge.EVENT_BUS.post(event)) return stacks; - - List inventories = getInventoriesOnNetwork(spark); - List inventoriesW = BotaniaAPI.internalHandler.wrapInventory(inventories); - Map interceptors = new HashMap(); - - CorporeaRequest request = new CorporeaRequest(matcher, checkNBT, itemCount); - for (IWrappedInventory inv : inventoriesW) { - ICorporeaSpark invSpark = inv.getSpark(); - - Object originalInventory = inv.getWrappedObject(); - if (originalInventory instanceof ICorporeaInterceptor) { - ICorporeaInterceptor interceptor = (ICorporeaInterceptor) originalInventory; - interceptor.interceptRequest(matcher, itemCount, invSpark, spark, stacks, inventories, doit); - interceptors.put(interceptor, invSpark); - } - - if (doit) { - stacks.addAll(inv.extractItems(request)); - } else { - stacks.addAll(inv.countItems(request)); - } - } - - lastRequestMatches = request.foundItems; - lastRequestExtractions = request.extractedItems; - - for (ICorporeaInterceptor interceptor : interceptors.keySet()) - interceptor.interceptRequestLast( - matcher, itemCount, interceptors.get(interceptor), spark, stacks, inventories, doit); - - return stacks; - } - - /** - * Gets the spark attached to the inventory passed case it's a TileEntity. - */ - public static ICorporeaSpark getSparkForInventory(IInventory inv) { - if (!(inv instanceof TileEntity)) return null; - - TileEntity tile = (TileEntity) inv; - return getSparkForBlock(tile.getWorldObj(), tile.xCoord, tile.yCoord, tile.zCoord); - } - - /** - * Gets the spark attached to the block in the coords passed in. Note that the coords passed - * in are for the block that the spark will be on, not the coords of the spark itself. - */ - public static ICorporeaSpark getSparkForBlock(World world, int x, int y, int z) { - List sparks = world.getEntitiesWithinAABB( - ICorporeaSpark.class, AxisAlignedBB.getBoundingBox(x, y + 1, z, x + 1, y + 2, z + 1)); - return sparks.isEmpty() ? null : sparks.get(0); - } - - /** - * Gets if the block in the coords passed in has a spark attached. Note that the coords passed - * in are for the block that the spark will be on, not the coords of the spark itself. - */ - public static boolean doesBlockHaveSpark(World world, int x, int y, int z) { - return getSparkForBlock(world, x, y, z) != null; - } - - /** - * Gets if the slot passed in can be extracted from by a spark. - */ - public static boolean isValidSlot(IInventory inv, int slot) { - return !(inv instanceof ISidedInventory) - || arrayHas(((ISidedInventory) inv).getAccessibleSlotsFromSide(ForgeDirection.UP.ordinal()), slot) - && ((ISidedInventory) inv) - .canExtractItem(slot, inv.getStackInSlot(slot), ForgeDirection.UP.ordinal()); - } - - /** - * Gets if two stacks match. - */ - public static boolean stacksMatch(ItemStack stack1, ItemStack stack2, boolean checkNBT) { - return stack1 != null - && stack2 != null - && stack1.isItemEqual(stack2) - && (!checkNBT || ItemStack.areItemStackTagsEqual(stack1, stack2)); - } - - /** - * Gets if the name of a stack matches the string passed in. - */ - public static boolean stacksMatch(ItemStack stack, String s) { - if (stack == null) return false; - - boolean contains = false; - for (String wc : WILDCARD_STRINGS) { - if (s.endsWith(wc)) { - contains = true; - s = s.substring(0, s.length() - wc.length()); - } else if (s.startsWith(wc)) { - contains = true; - s = s.substring(wc.length()); - } - - if (contains) break; - } - - String name = stripControlCodes(stack.getDisplayName().toLowerCase().trim()); - return equalOrContain(name, s, contains) - || equalOrContain(name + "s", s, contains) - || equalOrContain(name + "es", s, contains) - || name.endsWith("y") && equalOrContain(name.substring(0, name.length() - 1) + "ies", s, contains); - } - - /** - * Clears the cached networks, called once per tick, should not be called outside - * of the botania code. - */ - public static void clearCache() { - cachedNetworks.clear(); - } - - /** - * Helper method to check if an int array contains an int. - */ - public static boolean arrayHas(int[] arr, int val) { - for (int element : arr) if (element == val) return true; - - return false; - } - - /** - * Helper method to make stacksMatch() less messy. - */ - public static boolean equalOrContain(String s1, String s2, boolean contain) { - return contain ? s1.contains(s2) : s1.equals(s2); - } - - /** - * Registers a ICorporeaAutoCompleteController - */ - public static void registerAutoCompleteController(ICorporeaAutoCompleteController controller) { - autoCompleteControllers.add(controller); - } - - /** - * Returns if the auto complete helper should run - */ - public static boolean shouldAutoComplete() { - for (ICorporeaAutoCompleteController controller : autoCompleteControllers) - if (controller.shouldAutoComplete()) return true; - return false; - } - - // Copy from StringUtils - public static String stripControlCodes(String str) { - return patternControlCode.matcher(str).replaceAll(""); - } + private static final List empty = Collections.unmodifiableList(new ArrayList()); + private static final WeakHashMap, List> cachedNetworks = new WeakHashMap(); + private static final List autoCompleteControllers = new ArrayList(); + + private static final Pattern patternControlCode = Pattern.compile("(?i)\\u00A7[0-9A-FK-OR]"); + + public static final String[] WILDCARD_STRINGS = new String[] { + "...", "~", "+", "?" , "*" + }; + + /** + * How many items were matched in the last request. If java had "out" params like C# this wouldn't be needed :V + */ + public static int lastRequestMatches = 0; + /** + * How many items were extracted in the last request. + */ + public static int lastRequestExtractions = 0; + + /** + * Gets a list of all the inventories on this spark network. This list is cached for use once every tick, + * and if something changes during that tick it'll still have the first result. + */ + public static List getInventoriesOnNetwork(ICorporeaSpark spark) { + ICorporeaSpark master = spark.getMaster(); + if(master == null) + return empty; + List network = master.getConnections(); + + if(cachedNetworks.containsKey(network)) { + List cache = cachedNetworks.get(network); + if(cache != null) + return cache; + } + + List inventories = new ArrayList(); + if(network != null) + for(ICorporeaSpark otherSpark : network) + if(otherSpark != null) { + IInventory inv = otherSpark.getInventory(); + if(inv != null) + inventories.add(inv); + } + + cachedNetworks.put(network, inventories); + return inventories; + } + + /** + * Gets the amount of available items in the network of the type passed in, checking NBT or not. + * The higher level functions that use a List< IInventory > or a Map< IInventory, Integer > should be + * called instead if the context for those exists to avoid having to get the values again. + */ + public static int getCountInNetwork(ItemStack stack, ICorporeaSpark spark, boolean checkNBT) { + List inventories = getInventoriesOnNetwork(spark); + return getCountInNetwork(stack, inventories, checkNBT); + } + + /** + * Gets the amount of available items in the network of the type passed in, checking NBT or not. + * The higher level function that use a Map< IInventory, Integer > should be + * called instead if the context for this exists to avoid having to get the value again. + */ + public static int getCountInNetwork(ItemStack stack, List inventories, boolean checkNBT) { + Map map = getInventoriesWithItemInNetwork(stack, inventories, checkNBT); + return getCountInNetwork(stack, map, checkNBT); + } + + /** + * Gets the amount of available items in the network of the type passed in, checking NBT or not. + */ + public static int getCountInNetwork(ItemStack stack, Map inventories, boolean checkNBT) { + int count = 0; + + for(IInventory inv : inventories.keySet()) + count += inventories.get(inv); + + return count; + } + + /** + * Gets a Map mapping IInventories to the amount of items of the type passed in that exist + * The higher level function that use a List< IInventory > should be + * called instead if the context for this exists to avoid having to get the value again. + */ + public static Map getInventoriesWithItemInNetwork(ItemStack stack, ICorporeaSpark spark, boolean checkNBT) { + List inventories = getInventoriesOnNetwork(spark); + return getInventoriesWithItemInNetwork(stack, inventories, checkNBT); + } + + /** + * Gets a Map mapping IInventories to the amount of items of the type passed in that exist + * The deeper level function that use a List< IInventory > should be + * called instead if the context for this exists to avoid having to get the value again. + */ + public static Map getInventoriesWithItemInNetwork(ItemStack stack,List inventories, boolean checkNBT) { + Map countMap = new HashMap(); + List wrappedInventories = BotaniaAPI.internalHandler.wrapInventory(inventories); + for (IWrappedInventory inv : wrappedInventories) { + CorporeaRequest request = new CorporeaRequest(stack, checkNBT, -1); + inv.countItems(request); + if (request.foundItems > 0) { + countMap.put(inv.getWrappedObject(), request.foundItems); + } + } + + return countMap; + } + + /** + * Bridge for requestItem() using an ItemStack. + */ + public static List requestItem(ItemStack stack, ICorporeaSpark spark, boolean checkNBT, boolean doit) { + return requestItem(stack, stack.stackSize, spark, checkNBT, doit); + } + + /** + * Bridge for requestItem() using a String and an item count. + */ + public static List requestItem(String name, int count, ICorporeaSpark spark, boolean doit) { + return requestItem(name, count, spark, false, doit); + } + + /** + * Requests list of ItemStacks of the type passed in from the network, or tries to, checking NBT or not. + * This will remove the items from the adequate inventories unless the "doit" parameter is false. + * Returns a new list of ItemStacks of the items acquired or an empty list if none was found. + * Case itemCount is -1 it'll find EVERY item it can. + *

+ * The "matcher" parameter has to be an ItemStack or a String, if the first it'll check if the + * two stacks are similar using the "checkNBT" parameter, else it'll check if the name of the item + * equals or matches (case a regex is passed in) the matcher string. + *

+ * When requesting counting of items, individual stacks may exceed maxStackSize for + * purposes of counting huge amounts. + */ + public static List requestItem(Object matcher, int itemCount, ICorporeaSpark spark, boolean checkNBT, boolean doit) { + List stacks = new ArrayList(); + CorporeaRequestEvent event = new CorporeaRequestEvent(matcher, itemCount, spark, checkNBT, doit); + if(MinecraftForge.EVENT_BUS.post(event)) + return stacks; + + List inventories = getInventoriesOnNetwork(spark); + List inventoriesW = BotaniaAPI.internalHandler.wrapInventory(inventories); + Map interceptors = new HashMap(); + + CorporeaRequest request = new CorporeaRequest(matcher, checkNBT, itemCount); + for(IWrappedInventory inv : inventoriesW) { + ICorporeaSpark invSpark = inv.getSpark(); + + Object originalInventory = inv.getWrappedObject(); + if(originalInventory instanceof ICorporeaInterceptor) { + ICorporeaInterceptor interceptor = (ICorporeaInterceptor) originalInventory; + interceptor.interceptRequest(matcher, itemCount, invSpark, spark, stacks, inventories, doit); + interceptors.put(interceptor, invSpark); + } + + if(doit) { + stacks.addAll(inv.extractItems(request)); + } else { + stacks.addAll(inv.countItems(request)); + } + } + + lastRequestMatches = request.foundItems; + lastRequestExtractions = request.extractedItems; + + for(ICorporeaInterceptor interceptor : interceptors.keySet()) + interceptor.interceptRequestLast(matcher, itemCount, interceptors.get(interceptor), spark, stacks, inventories, doit); + + return stacks; + } + + /** + * Gets the spark attached to the inventory passed case it's a TileEntity. + */ + public static ICorporeaSpark getSparkForInventory(IInventory inv) { + if(!(inv instanceof TileEntity)) + return null; + + TileEntity tile = (TileEntity) inv; + return getSparkForBlock(tile.getWorldObj(), tile.xCoord, tile.yCoord, tile.zCoord); + } + + /** + * Gets the spark attached to the block in the coords passed in. Note that the coords passed + * in are for the block that the spark will be on, not the coords of the spark itself. + */ + public static ICorporeaSpark getSparkForBlock(World world, int x, int y, int z) { + List sparks = world.getEntitiesWithinAABB(ICorporeaSpark.class, AxisAlignedBB.getBoundingBox(x, y + 1, z, x + 1, y + 2, z + 1)); + return sparks.isEmpty() ? null : sparks.get(0); + } + + /** + * Gets if the block in the coords passed in has a spark attached. Note that the coords passed + * in are for the block that the spark will be on, not the coords of the spark itself. + */ + public static boolean doesBlockHaveSpark(World world, int x, int y, int z) { + return getSparkForBlock(world, x, y, z) != null; + } + + /** + * Gets if the slot passed in can be extracted from by a spark. + */ + public static boolean isValidSlot(IInventory inv, int slot) { + return !(inv instanceof ISidedInventory) || arrayHas(((ISidedInventory) inv).getAccessibleSlotsFromSide(ForgeDirection.UP.ordinal()), slot) && ((ISidedInventory) inv).canExtractItem(slot, inv.getStackInSlot(slot), ForgeDirection.UP.ordinal()); + } + + /** + * Gets if two stacks match. + */ + public static boolean stacksMatch(ItemStack stack1, ItemStack stack2, boolean checkNBT) { + return stack1 != null && stack2 != null && stack1.isItemEqual(stack2) && (!checkNBT || ItemStack.areItemStackTagsEqual(stack1, stack2)); + } + + /** + * Gets if the name of a stack matches the string passed in. + */ + public static boolean stacksMatch(ItemStack stack, String s) { + if(stack == null) + return false; + + boolean contains = false; + for(String wc : WILDCARD_STRINGS) { + if(s.endsWith(wc)) { + contains = true; + s = s.substring(0, s.length() - wc.length()); + } + else if(s.startsWith(wc)) { + contains = true; + s = s.substring(wc.length()); + } + + if(contains) + break; + } + + + String name = stripControlCodes(stack.getDisplayName().toLowerCase().trim()); + return equalOrContain(name, s, contains) || equalOrContain(name + "s", s, contains) || equalOrContain(name + "es", s, contains) || name.endsWith("y") && equalOrContain(name.substring(0, name.length() - 1) + "ies", s, contains); + } + + /** + * Clears the cached networks, called once per tick, should not be called outside + * of the botania code. + */ + public static void clearCache() { + cachedNetworks.clear(); + } + + /** + * Helper method to check if an int array contains an int. + */ + public static boolean arrayHas(int[] arr, int val) { + for (int element : arr) + if(element == val) + return true; + + return false; + } + + /** + * Helper method to make stacksMatch() less messy. + */ + public static boolean equalOrContain(String s1, String s2, boolean contain) { + return contain ? s1.contains(s2) : s1.equals(s2); + } + + /** + * Registers a ICorporeaAutoCompleteController + */ + public static void registerAutoCompleteController(ICorporeaAutoCompleteController controller) { + autoCompleteControllers.add(controller); + } + + /** + * Returns if the auto complete helper should run + */ + public static boolean shouldAutoComplete() { + for(ICorporeaAutoCompleteController controller : autoCompleteControllers) + if(controller.shouldAutoComplete()) + return true; + return false; + } + + // Copy from StringUtils + public static String stripControlCodes(String str) { + return patternControlCode.matcher(str).replaceAll(""); + } } diff --git a/src/main/java/vazkii/botania/api/corporea/CorporeaRequest.java b/src/main/java/vazkii/botania/api/corporea/CorporeaRequest.java index a6461998a3..b1156e5847 100644 --- a/src/main/java/vazkii/botania/api/corporea/CorporeaRequest.java +++ b/src/main/java/vazkii/botania/api/corporea/CorporeaRequest.java @@ -2,24 +2,25 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * */ package vazkii.botania.api.corporea; public class CorporeaRequest { - public Object matcher; - public boolean checkNBT; - public int count; - public int foundItems = 0; - public int extractedItems = 0; + public Object matcher; + public boolean checkNBT; + public int count; + public int foundItems = 0; + public int extractedItems = 0; + + public CorporeaRequest(Object matcher, boolean checkNBT, int count) { + super(); + this.matcher = matcher; + this.checkNBT = checkNBT; + this.count = count; + } - public CorporeaRequest(Object matcher, boolean checkNBT, int count) { - super(); - this.matcher = matcher; - this.checkNBT = checkNBT; - this.count = count; - } } diff --git a/src/main/java/vazkii/botania/api/corporea/CorporeaRequestEvent.java b/src/main/java/vazkii/botania/api/corporea/CorporeaRequestEvent.java index ecf2a27911..a55ef7b75a 100644 --- a/src/main/java/vazkii/botania/api/corporea/CorporeaRequestEvent.java +++ b/src/main/java/vazkii/botania/api/corporea/CorporeaRequestEvent.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Apr 30, 2015, 2:55:57 PM (GMT)] */ package vazkii.botania.api.corporea; @@ -19,20 +19,22 @@ @Cancelable public class CorporeaRequestEvent extends Event { - public final Object request; - public final int count; - public final ICorporeaSpark spark; - public final boolean checkNBT; - /** - * If false then items won't be pulled. - */ - public final boolean realRequest; + public final Object request; + public final int count; + public final ICorporeaSpark spark; + public final boolean checkNBT; + /** + * If false then items won't be pulled. + */ + public final boolean realRequest; + + public CorporeaRequestEvent(Object request, int count, ICorporeaSpark spark, boolean nbt, boolean real) { + this.request = request; + this.count = count; + this.spark = spark; + checkNBT = nbt; + realRequest = real; + } + - public CorporeaRequestEvent(Object request, int count, ICorporeaSpark spark, boolean nbt, boolean real) { - this.request = request; - this.count = count; - this.spark = spark; - checkNBT = nbt; - realRequest = real; - } } diff --git a/src/main/java/vazkii/botania/api/corporea/ICorporeaAutoCompleteController.java b/src/main/java/vazkii/botania/api/corporea/ICorporeaAutoCompleteController.java index 8f47a9039d..fc0a3e9b9a 100644 --- a/src/main/java/vazkii/botania/api/corporea/ICorporeaAutoCompleteController.java +++ b/src/main/java/vazkii/botania/api/corporea/ICorporeaAutoCompleteController.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [June 8, 2015, 1:04:05 PM (GMT)] */ package vazkii.botania.api.corporea; @@ -18,9 +18,10 @@ */ public interface ICorporeaAutoCompleteController { - /** - * Return true if auto completion should be enabled. - */ - @SideOnly(Side.CLIENT) - public boolean shouldAutoComplete(); + /** + * Return true if auto completion should be enabled. + */ + @SideOnly(Side.CLIENT) + public boolean shouldAutoComplete(); + } diff --git a/src/main/java/vazkii/botania/api/corporea/ICorporeaInterceptor.java b/src/main/java/vazkii/botania/api/corporea/ICorporeaInterceptor.java index 3b839fe785..eeea16a79c 100644 --- a/src/main/java/vazkii/botania/api/corporea/ICorporeaInterceptor.java +++ b/src/main/java/vazkii/botania/api/corporea/ICorporeaInterceptor.java @@ -2,15 +2,16 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Apr 19, 2015, 6:23:31 PM (GMT)] */ package vazkii.botania.api.corporea; import java.util.List; + import net.minecraft.inventory.IInventory; import net.minecraft.item.ItemStack; @@ -20,31 +21,18 @@ */ public interface ICorporeaInterceptor { - /** - * Intercepts a request as it goes. The list of inventories has all the inventories - * at this point, but the list of stacks is not complete. The request parameter can - * be either a String or ItemStack. - */ - public void interceptRequest( - Object request, - int count, - ICorporeaSpark spark, - ICorporeaSpark source, - List stacks, - List inventories, - boolean doit); + /** + * Intercepts a request as it goes. The list of inventories has all the inventories + * at this point, but the list of stacks is not complete. The request parameter can + * be either a String or ItemStack. + */ + public void interceptRequest(Object request, int count, ICorporeaSpark spark, ICorporeaSpark source, List stacks, List inventories, boolean doit); + + /** + * Intercepts a request after all the stacks have been found and processed. Both the + * list of inventories and stacks is complete at this point. The request parameter can + * be either a String or ItemStack. + */ + public void interceptRequestLast(Object request, int count, ICorporeaSpark spark, ICorporeaSpark source, List stacks, List inventories, boolean doit); - /** - * Intercepts a request after all the stacks have been found and processed. Both the - * list of inventories and stacks is complete at this point. The request parameter can - * be either a String or ItemStack. - */ - public void interceptRequestLast( - Object request, - int count, - ICorporeaSpark spark, - ICorporeaSpark source, - List stacks, - List inventories, - boolean doit); } diff --git a/src/main/java/vazkii/botania/api/corporea/ICorporeaRequestor.java b/src/main/java/vazkii/botania/api/corporea/ICorporeaRequestor.java index 11be4d26ff..66881b5b3d 100644 --- a/src/main/java/vazkii/botania/api/corporea/ICorporeaRequestor.java +++ b/src/main/java/vazkii/botania/api/corporea/ICorporeaRequestor.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Sep 28, 2015, 11:25:48 AM (GMT)] */ package vazkii.botania.api.corporea; @@ -17,8 +17,9 @@ */ public interface ICorporeaRequestor { - /* - * Executes the passed in request. - */ - public void doCorporeaRequest(Object request, int count, ICorporeaSpark spark); + /* + * Executes the passed in request. + */ + public void doCorporeaRequest(Object request, int count, ICorporeaSpark spark); + } diff --git a/src/main/java/vazkii/botania/api/corporea/ICorporeaSpark.java b/src/main/java/vazkii/botania/api/corporea/ICorporeaSpark.java index 090363ba29..943e29e726 100644 --- a/src/main/java/vazkii/botania/api/corporea/ICorporeaSpark.java +++ b/src/main/java/vazkii/botania/api/corporea/ICorporeaSpark.java @@ -2,15 +2,16 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Feb 13, 2015, 10:53:05 PM (GMT)] */ package vazkii.botania.api.corporea; import java.util.List; + import net.minecraft.inventory.IInventory; import net.minecraft.item.ItemStack; @@ -20,66 +21,67 @@ */ public interface ICorporeaSpark { - /** - * Called to register the connections for the spark network passed in. Parameters include the master spark, - * which is the one that initiated the chain call, the referrer which passed the call to this instance - * and the List of sparks connected. Normal behavior should be to find any sparks around that are not - * already present in the list of connections and add them to it, passing the function call to them. - *

- * The connections List and the master Spark should be kept in this instance as pointers for use in - * getConnections() and getMaster() and passed in to any subsequent registerConnections calls on sparks - * found nearby. This is only called whenever a new spark is added or removed from and to the network, - * at that point the connection list in the master spark would be cleared out, also clearing out the one - * in this instance, as it should be a pointer. - */ - public void registerConnections(ICorporeaSpark master, ICorporeaSpark referrer, List connections); + /** + * Called to register the connections for the spark network passed in. Parameters include the master spark, + * which is the one that initiated the chain call, the referrer which passed the call to this instance + * and the List of sparks connected. Normal behavior should be to find any sparks around that are not + * already present in the list of connections and add them to it, passing the function call to them. + *

+ * The connections List and the master Spark should be kept in this instance as pointers for use in + * getConnections() and getMaster() and passed in to any subsequent registerConnections calls on sparks + * found nearby. This is only called whenever a new spark is added or removed from and to the network, + * at that point the connection list in the master spark would be cleared out, also clearing out the one + * in this instance, as it should be a pointer. + */ + public void registerConnections(ICorporeaSpark master, ICorporeaSpark referrer, List connections); + + /** + * Gets the inventory this spark is bound to, generally the one right below it. + */ + public IInventory getInventory(); - /** - * Gets the inventory this spark is bound to, generally the one right below it. - */ - public IInventory getInventory(); + /** + * Gets the list of sparks this spark is connected to, see registerConnections(). This list + * should also include itself. This list must be checked against on a regular basis to verify + * that the spark is still in the network, if that's not the case, the pointer should be + * eliminated. + */ + public List getConnections(); - /** - * Gets the list of sparks this spark is connected to, see registerConnections(). This list - * should also include itself. This list must be checked against on a regular basis to verify - * that the spark is still in the network, if that's not the case, the pointer should be - * eliminated. - */ - public List getConnections(); + /** + * Gets the list of sparks that this spark added to the list of connections during registerConnections(), this + * is mainly used to create a non messy chain of particles to display the network when a spark is right + * clicked with a wand. + */ + public List getRelatives(); - /** - * Gets the list of sparks that this spark added to the list of connections during registerConnections(), this - * is mainly used to create a non messy chain of particles to display the network when a spark is right - * clicked with a wand. - */ - public List getRelatives(); + /** + * Gets the master spark in this network, see registerConnections(). The value this returns + * should be null and the pointer should be eliminated if the spark is no longer present + * in the network. + */ + public ICorporeaSpark getMaster(); - /** - * Gets the master spark in this network, see registerConnections(). The value this returns - * should be null and the pointer should be eliminated if the spark is no longer present - * in the network. - */ - public ICorporeaSpark getMaster(); + /** + * Called when an item is extracted from the inventory this spark is attached to through this + * spark. + */ + public void onItemExtracted(ItemStack stack); - /** - * Called when an item is extracted from the inventory this spark is attached to through this - * spark. - */ - public void onItemExtracted(ItemStack stack); + /** + * Called when this spark requests items, passes in the result of the request and not the actual requested stack(s). + */ + public void onItemsRequested(List stacks); - /** - * Called when this spark requests items, passes in the result of the request and not the actual requested stack(s). - */ - public void onItemsRequested(List stacks); + /** + * Gets if this spark is considered a master spark. + */ + public boolean isMaster(); - /** - * Gets if this spark is considered a master spark. - */ - public boolean isMaster(); + /** + * Gets the network that this spark is on, or the color it's displaying. Sparks may only connect to others + * of the same network, and on changing network should trigger a re-cache of the previous network. + */ + public int getNetwork(); - /** - * Gets the network that this spark is on, or the color it's displaying. Sparks may only connect to others - * of the same network, and on changing network should trigger a re-cache of the previous network. - */ - public int getNetwork(); } diff --git a/src/main/java/vazkii/botania/api/corporea/IWrappedInventory.java b/src/main/java/vazkii/botania/api/corporea/IWrappedInventory.java index 1ea6dc88e3..0b588f2387 100644 --- a/src/main/java/vazkii/botania/api/corporea/IWrappedInventory.java +++ b/src/main/java/vazkii/botania/api/corporea/IWrappedInventory.java @@ -2,14 +2,15 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * */ package vazkii.botania.api.corporea; import java.util.List; + import net.minecraft.inventory.IInventory; import net.minecraft.item.ItemStack; @@ -20,37 +21,37 @@ */ public interface IWrappedInventory { - /** - * Break encapsulation and exposes original inventory. - */ - IInventory getWrappedObject(); + /** + * Break encapsulation and exposes original inventory. + */ + IInventory getWrappedObject(); - /** - * Counts items in the inventory matching the request - * - * @param request - * - specifies what should be found - * @return List of ItemStack, individual stacks may exceed maxStackSize for - * purposes of counting huge amounts. To get final count requestor - * should sum stackSize of all stacks. - */ - List countItems(CorporeaRequest request); + /** + * Counts items in the inventory matching the request + * + * @param request + * - specifies what should be found + * @return List of ItemStack, individual stacks may exceed maxStackSize for + * purposes of counting huge amounts. To get final count requestor + * should sum stackSize of all stacks. + */ + List countItems(CorporeaRequest request); - /** - * Convenience method for accessing spark over inventory - */ - ICorporeaSpark getSpark(); + /** + * Convenience method for accessing spark over inventory + */ + ICorporeaSpark getSpark(); - /** - * Extracts items matching request from the inventory.
- * {@link CorporeaRequest#count} is updated to reflect how many items are - * yet to be extracted.
- * {@link CorporeaRequest#foundItems} and - * {@link CorporeaRequest#extractedItems} are updated to reflect how many - * items were found and extracted. - * - * @param request - * @return List of ItemStacks to be delivered to the destination. - */ - List extractItems(CorporeaRequest request); + /** + * Extracts items matching request from the inventory.
+ * {@link CorporeaRequest#count} is updated to reflect how many items are + * yet to be extracted.
+ * {@link CorporeaRequest#foundItems} and + * {@link CorporeaRequest#extractedItems} are updated to reflect how many + * items were found and extracted. + * + * @param request + * @return List of ItemStacks to be delivered to the destination. + */ + List extractItems(CorporeaRequest request); } diff --git a/src/main/java/vazkii/botania/api/internal/DummyManaNetwork.java b/src/main/java/vazkii/botania/api/internal/DummyManaNetwork.java index 3ce9d20ee0..f74d0cac9b 100644 --- a/src/main/java/vazkii/botania/api/internal/DummyManaNetwork.java +++ b/src/main/java/vazkii/botania/api/internal/DummyManaNetwork.java @@ -2,16 +2,17 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Mar 7, 2014, 3:47:43 PM (GMT)] */ package vazkii.botania.api.internal; import java.util.ArrayList; import java.util.List; + import net.minecraft.tileentity.TileEntity; import net.minecraft.util.ChunkCoordinates; import net.minecraft.world.World; @@ -19,30 +20,31 @@ public class DummyManaNetwork implements IManaNetwork { - public static final DummyManaNetwork instance = new DummyManaNetwork(); + public static final DummyManaNetwork instance = new DummyManaNetwork(); + + @Override + public void clear() { + // NO-OP + } - @Override - public void clear() { - // NO-OP - } + @Override + public TileEntity getClosestPool(ChunkCoordinates pos, World world, int limit) { + return null; + } - @Override - public TileEntity getClosestPool(ChunkCoordinates pos, World world, int limit) { - return null; - } + @Override + public TileEntity getClosestCollector(ChunkCoordinates pos, World world, int limit) { + return null; + } - @Override - public TileEntity getClosestCollector(ChunkCoordinates pos, World world, int limit) { - return null; - } + @Override + public List getAllCollectorsInWorld(World world) { + return new ArrayList(); + } - @Override - public List getAllCollectorsInWorld(World world) { - return new ArrayList(); - } + @Override + public List getAllPoolsInWorld(World world) { + return new ArrayList(); + } - @Override - public List getAllPoolsInWorld(World world) { - return new ArrayList(); - } } diff --git a/src/main/java/vazkii/botania/api/internal/DummyMethodHandler.java b/src/main/java/vazkii/botania/api/internal/DummyMethodHandler.java index 80c636962d..88ddf474d7 100644 --- a/src/main/java/vazkii/botania/api/internal/DummyMethodHandler.java +++ b/src/main/java/vazkii/botania/api/internal/DummyMethodHandler.java @@ -2,15 +2,16 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jan 14, 2014, 6:43:03 PM (GMT)] */ package vazkii.botania.api.internal; import java.util.List; + import net.minecraft.client.gui.ScaledResolution; import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.entity.Entity; @@ -37,204 +38,198 @@ public class DummyMethodHandler implements IInternalMethodHandler { - @Override - public LexiconPage textPage(String key) { - return dummyPage(key); - } - - @Override - public LexiconPage elfPaperTextPage(String key) { - return dummyPage(key); - } - - @Override - public LexiconPage imagePage(String key, String resource) { - return dummyPage(key); - } - - @Override - public LexiconPage craftingRecipesPage(String key, List recipes) { - return dummyPage(key); - } - - @Override - public LexiconPage craftingRecipePage(String key, IRecipe recipe) { - return dummyPage(key); - } - - @Override - public LexiconPage petalRecipesPage(String key, List recipes) { - return dummyPage(key); - } - - @Override - public LexiconPage petalRecipePage(String key, RecipePetals recipe) { - return dummyPage(key); - } - - @Override - public LexiconPage runeRecipesPage(String key, List recipes) { - return dummyPage(key); - } - - @Override - public LexiconPage runeRecipePage(String key, RecipeRuneAltar recipe) { - return dummyPage(key); - } - - @Override - public LexiconPage manaInfusionRecipesPage(String key, List recipes) { - return dummyPage(key); - } - - @Override - public LexiconPage manaInfusionRecipePage(String key, RecipeManaInfusion recipe) { - return dummyPage(key); - } - - @Override - public LexiconPage elvenTradePage(String key, List recipes) { - return dummyPage(key); - } - - @Override - public LexiconPage elvenTradesPage(String key, RecipeElvenTrade recipe) { - return dummyPage(key); - } - - @Override - public LexiconPage brewPage(String key, String bottomText, RecipeBrew recipe) { - return dummyPage(key); - } - - @Override - public LexiconPage multiblockPage(String key, MultiblockSet mb) { - return dummyPage(key); - } - - private LexiconPage dummyPage(String key) { - return new DummyPage(key); - } - - @Override - public ItemStack getSubTileAsStack(String subTile) { - return new ItemStack(Blocks.stone, 0, 0); - } - - @Override - public ItemStack getSubTileAsFloatingFlowerStack(String subTile) { - return getSubTileAsStack(subTile); - } - - @Override - public String getStackSubTileKey(ItemStack stack) { - return null; - } - - @Override - public IIcon getSubTileIconForName(String name) { - return Blocks.red_flower.getIcon(0, 0); - } - - @Override - public void registerBasicSignatureIcons(String name, IIconRegister register) { - // NO-OP - } - - @Override - public IManaNetwork getManaNetworkInstance() { - return DummyManaNetwork.instance; - } - - @Override - public void drawSimpleManaHUD(int color, int mana, int maxMana, String name, ScaledResolution res) { - // NO-OP - } - - @Override - public void drawComplexManaHUD( - int color, - int mana, - int maxMana, - String name, - ScaledResolution res, - ItemStack bindDisplay, - boolean properlyBound) { - // NO-OP - } - - @Override - public ItemStack getBindDisplayForFlowerType(SubTileEntity e) { - return new ItemStack(Blocks.stone, 0, 0); - } - - @Override - public void renderLexiconText(int x, int y, int width, int height, String unlocalizedText) { - // NO-OP - } - - @Override - public void sparkleFX(World world, double x, double y, double z, float r, float g, float b, float size, int m) { - // NO-OP - } - - @Override - public IInventory getBaublesInventory(EntityPlayer player) { - return null; - } - - @Override - public boolean shouldForceCheck() { - return true; - } - - @Override - public int getPassiveFlowerDecay() { - return 0; - } - - @Override - public ResourceLocation getDefaultBossBarTexture() { - return null; - } - - @Override - public void setBossStatus(IBotaniaBoss status) { - // NO-OP - } - - @Override - public boolean isBuildcraftPipe(TileEntity tile) { - return false; - } - - @Override - public void breakOnAllCursors(EntityPlayer player, Item item, ItemStack stack, int x, int y, int z, int side) { - // NO-OP - } - - @Override - public boolean hasSolegnoliaAround(Entity e) { - return false; - } - - @Override - public long getWorldElapsedTicks() { - return 0; - } - - @Override - public boolean isBotaniaFlower(World world, int x, int y, int z) { - return false; - } - - @Override - public void sendBaubleUpdatePacket(EntityPlayer player, int slot) { - // NO-OP - } - - @Override - public List wrapInventory(List inventories) { - return null; - } + @Override + public LexiconPage textPage(String key) { + return dummyPage(key); + } + + @Override + public LexiconPage elfPaperTextPage(String key) { + return dummyPage(key); + } + + @Override + public LexiconPage imagePage(String key, String resource) { + return dummyPage(key); + } + + @Override + public LexiconPage craftingRecipesPage(String key, List recipes) { + return dummyPage(key); + } + + @Override + public LexiconPage craftingRecipePage(String key, IRecipe recipe) { + return dummyPage(key); + } + + @Override + public LexiconPage petalRecipesPage(String key, List recipes) { + return dummyPage(key); + } + + @Override + public LexiconPage petalRecipePage(String key, RecipePetals recipe) { + return dummyPage(key); + } + + @Override + public LexiconPage runeRecipesPage(String key, List recipes) { + return dummyPage(key); + } + + @Override + public LexiconPage runeRecipePage(String key, RecipeRuneAltar recipe) { + return dummyPage(key); + } + + @Override + public LexiconPage manaInfusionRecipesPage(String key, List recipes) { + return dummyPage(key); + } + + @Override + public LexiconPage manaInfusionRecipePage(String key, RecipeManaInfusion recipe) { + return dummyPage(key); + } + + @Override + public LexiconPage elvenTradePage(String key, List recipes) { + return dummyPage(key); + } + + @Override + public LexiconPage elvenTradesPage(String key, RecipeElvenTrade recipe) { + return dummyPage(key); + } + + @Override + public LexiconPage brewPage(String key, String bottomText, RecipeBrew recipe) { + return dummyPage(key); + } + + @Override + public LexiconPage multiblockPage(String key, MultiblockSet mb) { + return dummyPage(key); + } + + private LexiconPage dummyPage(String key) { + return new DummyPage(key); + } + + @Override + public ItemStack getSubTileAsStack(String subTile) { + return new ItemStack(Blocks.stone, 0, 0); + } + + @Override + public ItemStack getSubTileAsFloatingFlowerStack(String subTile) { + return getSubTileAsStack(subTile); + } + + @Override + public String getStackSubTileKey(ItemStack stack) { + return null; + } + + @Override + public IIcon getSubTileIconForName(String name) { + return Blocks.red_flower.getIcon(0, 0); + } + + @Override + public void registerBasicSignatureIcons(String name, IIconRegister register) { + // NO-OP + } + + @Override + public IManaNetwork getManaNetworkInstance() { + return DummyManaNetwork.instance; + } + + @Override + public void drawSimpleManaHUD(int color, int mana, int maxMana, String name, ScaledResolution res) { + // NO-OP + } + + @Override + public void drawComplexManaHUD(int color, int mana, int maxMana, String name, ScaledResolution res, ItemStack bindDisplay, boolean properlyBound) { + // NO-OP + } + + @Override + public ItemStack getBindDisplayForFlowerType(SubTileEntity e) { + return new ItemStack(Blocks.stone, 0, 0); + } + + @Override + public void renderLexiconText(int x, int y, int width, int height, String unlocalizedText) { + // NO-OP + } + + @Override + public void sparkleFX(World world, double x, double y, double z, float r, float g, float b, float size, int m) { + // NO-OP + } + + @Override + public IInventory getBaublesInventory(EntityPlayer player) { + return null; + } + + @Override + public boolean shouldForceCheck() { + return true; + } + + @Override + public int getPassiveFlowerDecay() { + return 0; + } + + @Override + public ResourceLocation getDefaultBossBarTexture() { + return null; + } + + @Override + public void setBossStatus(IBotaniaBoss status) { + // NO-OP + } + + @Override + public boolean isBuildcraftPipe(TileEntity tile) { + return false; + } + + @Override + public void breakOnAllCursors(EntityPlayer player, Item item, ItemStack stack, int x, int y, int z, int side) { + // NO-OP + } + + @Override + public boolean hasSolegnoliaAround(Entity e) { + return false; + } + + @Override + public long getWorldElapsedTicks() { + return 0; + } + + @Override + public boolean isBotaniaFlower(World world, int x, int y, int z) { + return false; + } + + @Override + public void sendBaubleUpdatePacket(EntityPlayer player, int slot) { + // NO-OP + } + + @Override + public List wrapInventory(List inventories) { + return null; + } + } diff --git a/src/main/java/vazkii/botania/api/internal/DummyPage.java b/src/main/java/vazkii/botania/api/internal/DummyPage.java index 481f1c8f8c..843198c416 100644 --- a/src/main/java/vazkii/botania/api/internal/DummyPage.java +++ b/src/main/java/vazkii/botania/api/internal/DummyPage.java @@ -2,17 +2,17 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jan 14, 2014, 6:41:23 PM (GMT)] */ package vazkii.botania.api.internal; +import vazkii.botania.api.lexicon.LexiconPage; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; -import vazkii.botania.api.lexicon.LexiconPage; /** * A dummy page. It does absolutely nothing and is only @@ -21,13 +21,14 @@ */ public class DummyPage extends LexiconPage { - public DummyPage(String unlocalizedName) { - super(unlocalizedName); - } + public DummyPage(String unlocalizedName) { + super(unlocalizedName); + } + + @Override + @SideOnly(Side.CLIENT) + public void renderScreen(IGuiLexiconEntry gui, int x, int y) { + // NO-OP + } - @Override - @SideOnly(Side.CLIENT) - public void renderScreen(IGuiLexiconEntry gui, int x, int y) { - // NO-OP - } } diff --git a/src/main/java/vazkii/botania/api/internal/DummySubTile.java b/src/main/java/vazkii/botania/api/internal/DummySubTile.java index e8ae39c926..d8ac6ab5b6 100644 --- a/src/main/java/vazkii/botania/api/internal/DummySubTile.java +++ b/src/main/java/vazkii/botania/api/internal/DummySubTile.java @@ -2,14 +2,16 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jan 24, 2014, 4:17:33 PM (GMT)] */ package vazkii.botania.api.internal; import vazkii.botania.api.subtile.SubTileEntity; -public class DummySubTile extends SubTileEntity {} +public class DummySubTile extends SubTileEntity { + +} diff --git a/src/main/java/vazkii/botania/api/internal/IGuiLexiconEntry.java b/src/main/java/vazkii/botania/api/internal/IGuiLexiconEntry.java index 6dd78a31e4..b0d4d6ef4d 100644 --- a/src/main/java/vazkii/botania/api/internal/IGuiLexiconEntry.java +++ b/src/main/java/vazkii/botania/api/internal/IGuiLexiconEntry.java @@ -2,15 +2,16 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jan 14, 2014, 6:48:41 PM (GMT)] */ package vazkii.botania.api.internal; import java.util.List; + import net.minecraft.client.gui.GuiButton; import vazkii.botania.api.lexicon.LexiconEntry; @@ -21,60 +22,60 @@ */ public interface IGuiLexiconEntry { - /** - * Gets the entry currently portrayed in this gui. - */ - public LexiconEntry getEntry(); + /** + * Gets the entry currently portrayed in this gui. + */ + public LexiconEntry getEntry(); - /** - * Gets the current page the lexicon GUI is browsing. - */ - public int getPageOn(); + /** + * Gets the current page the lexicon GUI is browsing. + */ + public int getPageOn(); - /** - * Gets the leftmost part of the GUI. - */ - public int getLeft(); + /** + * Gets the leftmost part of the GUI. + */ + public int getLeft(); - /** - * Gets the topmost part of the GUI. - */ - public int getTop(); + /** + * Gets the topmost part of the GUI. + */ + public int getTop(); - /** - * Gets the GUI's width. - */ - public int getWidth(); + /** + * Gets the GUI's width. + */ + public int getWidth(); - /** - * Gets the GUI's height - */ - public int getHeight(); + /** + * Gets the GUI's height + */ + public int getHeight(); - /** - * Gets the GUI's Z level for rendering. - */ - public float getZLevel(); + /** + * Gets the GUI's Z level for rendering. + */ + public float getZLevel(); - /** - * Gets the list of buttons in this gui. - */ - public List getButtonList(); + /** + * Gets the list of buttons in this gui. + */ + public List getButtonList(); - /** - * Gets the total amount of ticks (+ partial ticks) the player - * has been in this gui. - */ - public float getElapsedTicks(); + /** + * Gets the total amount of ticks (+ partial ticks) the player + * has been in this gui. + */ + public float getElapsedTicks(); - /** - * Gets the current partial ticks. - */ - public float getPartialTicks(); + /** + * Gets the current partial ticks. + */ + public float getPartialTicks(); - /** - * Gets the delta (1F = 1 tick) between this render call - * and the last one. - */ - public float getTickDelta(); + /** + * Gets the delta (1F = 1 tick) between this render call + * and the last one. + */ + public float getTickDelta(); } diff --git a/src/main/java/vazkii/botania/api/internal/IInternalMethodHandler.java b/src/main/java/vazkii/botania/api/internal/IInternalMethodHandler.java index 7e64ea5565..b0e3d10bd9 100644 --- a/src/main/java/vazkii/botania/api/internal/IInternalMethodHandler.java +++ b/src/main/java/vazkii/botania/api/internal/IInternalMethodHandler.java @@ -2,17 +2,16 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jan 14, 2014, 6:34:34 PM (GMT)] */ package vazkii.botania.api.internal; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; import java.util.List; + import net.minecraft.client.gui.ScaledResolution; import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.entity.Entity; @@ -35,6 +34,8 @@ import vazkii.botania.api.recipe.RecipePetals; import vazkii.botania.api.recipe.RecipeRuneAltar; import vazkii.botania.api.subtile.SubTileEntity; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; /** * Any methods that refer to internal methods in Botania are here. @@ -45,95 +46,89 @@ */ public interface IInternalMethodHandler { - public LexiconPage textPage(String key); + public LexiconPage textPage(String key); + + public LexiconPage elfPaperTextPage(String key); - public LexiconPage elfPaperTextPage(String key); + public LexiconPage imagePage(String key, String resource); - public LexiconPage imagePage(String key, String resource); + public LexiconPage craftingRecipesPage(String key, List recipes); - public LexiconPage craftingRecipesPage(String key, List recipes); + public LexiconPage craftingRecipePage(String key, IRecipe recipe); - public LexiconPage craftingRecipePage(String key, IRecipe recipe); + public LexiconPage petalRecipesPage(String key, List recipes); - public LexiconPage petalRecipesPage(String key, List recipes); + public LexiconPage petalRecipePage(String key, RecipePetals recipe); - public LexiconPage petalRecipePage(String key, RecipePetals recipe); + public LexiconPage runeRecipesPage(String key, List recipes); - public LexiconPage runeRecipesPage(String key, List recipes); + public LexiconPage runeRecipePage(String key, RecipeRuneAltar recipe); - public LexiconPage runeRecipePage(String key, RecipeRuneAltar recipe); + public LexiconPage manaInfusionRecipesPage(String key, List recipes); - public LexiconPage manaInfusionRecipesPage(String key, List recipes); + public LexiconPage manaInfusionRecipePage(String key, RecipeManaInfusion recipe); - public LexiconPage manaInfusionRecipePage(String key, RecipeManaInfusion recipe); + public LexiconPage elvenTradePage(String key, List recipes); - public LexiconPage elvenTradePage(String key, List recipes); + public LexiconPage elvenTradesPage(String key, RecipeElvenTrade recipe); - public LexiconPage elvenTradesPage(String key, RecipeElvenTrade recipe); + public LexiconPage brewPage(String key, String bottomText, RecipeBrew recipe); - public LexiconPage brewPage(String key, String bottomText, RecipeBrew recipe); + public LexiconPage multiblockPage(String key, MultiblockSet mb); - public LexiconPage multiblockPage(String key, MultiblockSet mb); + public IManaNetwork getManaNetworkInstance(); - public IManaNetwork getManaNetworkInstance(); + public ItemStack getSubTileAsStack(String subTile); - public ItemStack getSubTileAsStack(String subTile); + public ItemStack getSubTileAsFloatingFlowerStack(String subTile); - public ItemStack getSubTileAsFloatingFlowerStack(String subTile); + public String getStackSubTileKey(ItemStack stack); - public String getStackSubTileKey(ItemStack stack); + public IIcon getSubTileIconForName(String name); - public IIcon getSubTileIconForName(String name); + public void registerBasicSignatureIcons(String name, IIconRegister register); - public void registerBasicSignatureIcons(String name, IIconRegister register); + public boolean shouldForceCheck(); - public boolean shouldForceCheck(); + public int getPassiveFlowerDecay(); - public int getPassiveFlowerDecay(); + public IInventory getBaublesInventory(EntityPlayer player); - public IInventory getBaublesInventory(EntityPlayer player); + public void breakOnAllCursors(EntityPlayer player, Item item, ItemStack stack, int x, int y, int z, int side); - public void breakOnAllCursors(EntityPlayer player, Item item, ItemStack stack, int x, int y, int z, int side); + public boolean hasSolegnoliaAround(Entity e); - public boolean hasSolegnoliaAround(Entity e); + @SideOnly(Side.CLIENT) + public void drawSimpleManaHUD(int color, int mana, int maxMana, String name, ScaledResolution res); - @SideOnly(Side.CLIENT) - public void drawSimpleManaHUD(int color, int mana, int maxMana, String name, ScaledResolution res); + @SideOnly(Side.CLIENT) + public void drawComplexManaHUD(int color, int mana, int maxMana, String name, ScaledResolution res, ItemStack bindDisplay, boolean properlyBound); - @SideOnly(Side.CLIENT) - public void drawComplexManaHUD( - int color, - int mana, - int maxMana, - String name, - ScaledResolution res, - ItemStack bindDisplay, - boolean properlyBound); + @SideOnly(Side.CLIENT) + public ItemStack getBindDisplayForFlowerType(SubTileEntity e); - @SideOnly(Side.CLIENT) - public ItemStack getBindDisplayForFlowerType(SubTileEntity e); + @SideOnly(Side.CLIENT) + public void renderLexiconText(int x, int y, int width, int height, String unlocalizedText); - @SideOnly(Side.CLIENT) - public void renderLexiconText(int x, int y, int width, int height, String unlocalizedText); + @SideOnly(Side.CLIENT) + public ResourceLocation getDefaultBossBarTexture(); - @SideOnly(Side.CLIENT) - public ResourceLocation getDefaultBossBarTexture(); + @SideOnly(Side.CLIENT) + public void setBossStatus(IBotaniaBoss status); - @SideOnly(Side.CLIENT) - public void setBossStatus(IBotaniaBoss status); + public boolean isBuildcraftPipe(TileEntity tile); - public boolean isBuildcraftPipe(TileEntity tile); + public void sparkleFX(World world, double x, double y, double z, float r, float g, float b, float size, int m); - public void sparkleFX(World world, double x, double y, double z, float r, float g, float b, float size, int m); + public long getWorldElapsedTicks(); - public long getWorldElapsedTicks(); + public boolean isBotaniaFlower(World world, int x, int y, int z); - public boolean isBotaniaFlower(World world, int x, int y, int z); + public void sendBaubleUpdatePacket(EntityPlayer player, int slot); - public void sendBaubleUpdatePacket(EntityPlayer player, int slot); + /** + * Wrap inventories in the network into wrappers providing compatibility for storage mods. + */ + List wrapInventory(List inventories); - /** - * Wrap inventories in the network into wrappers providing compatibility for storage mods. - */ - List wrapInventory(List inventories); } diff --git a/src/main/java/vazkii/botania/api/internal/IManaBurst.java b/src/main/java/vazkii/botania/api/internal/IManaBurst.java index a998df7c0d..945aa9916a 100644 --- a/src/main/java/vazkii/botania/api/internal/IManaBurst.java +++ b/src/main/java/vazkii/botania/api/internal/IManaBurst.java @@ -2,15 +2,16 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jan 31, 2014, 4:36:13 PM (GMT)] */ package vazkii.botania.api.internal; import java.util.UUID; + import net.minecraft.item.ItemStack; import net.minecraft.util.ChunkCoordinates; @@ -19,53 +20,54 @@ */ public interface IManaBurst { - public boolean isFake(); + public boolean isFake(); + + public void setMotion(double x, double y, double z); - public void setMotion(double x, double y, double z); + public int getColor(); - public int getColor(); + public void setColor(int color); - public void setColor(int color); + public int getMana(); - public int getMana(); + public void setMana(int mana); - public void setMana(int mana); + public int getStartingMana(); - public int getStartingMana(); + public void setStartingMana(int mana); - public void setStartingMana(int mana); + public int getMinManaLoss(); - public int getMinManaLoss(); + public void setMinManaLoss(int minManaLoss); - public void setMinManaLoss(int minManaLoss); + public float getManaLossPerTick(); - public float getManaLossPerTick(); + public void setManaLossPerTick(float mana); - public void setManaLossPerTick(float mana); + public float getGravity(); - public float getGravity(); + public void setGravity(float gravity); - public void setGravity(float gravity); + public ChunkCoordinates getBurstSourceChunkCoordinates(); - public ChunkCoordinates getBurstSourceChunkCoordinates(); + public void setBurstSourceCoords(int x, int y, int z); - public void setBurstSourceCoords(int x, int y, int z); + public ItemStack getSourceLens(); - public ItemStack getSourceLens(); + public void setSourceLens(ItemStack lens); - public void setSourceLens(ItemStack lens); + public boolean hasAlreadyCollidedAt(int x, int y, int z); - public boolean hasAlreadyCollidedAt(int x, int y, int z); + public void setCollidedAt(int x, int y, int z); - public void setCollidedAt(int x, int y, int z); + public int getTicksExisted(); - public int getTicksExisted(); + public void setFake(boolean fake); - public void setFake(boolean fake); + public void setShooterUUID(UUID uuid); - public void setShooterUUID(UUID uuid); + public UUID getShooterUIID(); - public UUID getShooterUIID(); + public void ping(); - public void ping(); } diff --git a/src/main/java/vazkii/botania/api/internal/IManaNetwork.java b/src/main/java/vazkii/botania/api/internal/IManaNetwork.java index 81183cbc51..fc4553e46c 100644 --- a/src/main/java/vazkii/botania/api/internal/IManaNetwork.java +++ b/src/main/java/vazkii/botania/api/internal/IManaNetwork.java @@ -2,15 +2,16 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Mar 7, 2014, 3:39:48 PM (GMT)] */ package vazkii.botania.api.internal; import java.util.List; + import net.minecraft.tileentity.TileEntity; import net.minecraft.util.ChunkCoordinates; import net.minecraft.world.World; @@ -22,45 +23,45 @@ */ public interface IManaNetwork { - /** - * Clears the entire Mana Network of all it's contents, you probably - * don't want to call this unless you have a very good reason. - */ - public void clear(); + /** + * Clears the entire Mana Network of all it's contents, you probably + * don't want to call this unless you have a very good reason. + */ + public void clear(); - /** - * Gets the closest Mana Collector (eg. Mana Spreader) in the network to the Chunk - * Coordinates passed in, in the given dimension.
- * A way of getting the dimension is via worldObj.provider.dimensionId
- * Note that this function *can* get performance intensive, it's reccomended you - * call it sparingly and take cache of the value returned. - * @param limit The maximum distance the closest block can be, if the closest block - * is farther away than that, null will be returned instead. - */ - public TileEntity getClosestCollector(ChunkCoordinates pos, World world, int limit); + /** + * Gets the closest Mana Collector (eg. Mana Spreader) in the network to the Chunk + * Coordinates passed in, in the given dimension.
+ * A way of getting the dimension is via worldObj.provider.dimensionId
+ * Note that this function *can* get performance intensive, it's reccomended you + * call it sparingly and take cache of the value returned. + * @param limit The maximum distance the closest block can be, if the closest block + * is farther away than that, null will be returned instead. + */ + public TileEntity getClosestCollector(ChunkCoordinates pos, World world, int limit); - /** - * Gets the closest Mana Pool in the network to the Chunk Coordinates passed in, - * in the given dimension.
- * A way of getting the dimension is via worldObj.provider.dimensionId
- * Note that this function *can* get performance intensive, it's reccomended you - * call it sparingly and take cache of the value returned. - * @param limit The maximum distance the closest block can be, if the closest block - * is farther away than that, null will be returned instead. - */ - public TileEntity getClosestPool(ChunkCoordinates pos, World world, int limit); + /** + * Gets the closest Mana Pool in the network to the Chunk Coordinates passed in, + * in the given dimension.
+ * A way of getting the dimension is via worldObj.provider.dimensionId
+ * Note that this function *can* get performance intensive, it's reccomended you + * call it sparingly and take cache of the value returned. + * @param limit The maximum distance the closest block can be, if the closest block + * is farther away than that, null will be returned instead. + */ + public TileEntity getClosestPool(ChunkCoordinates pos, World world, int limit); - /** - * Gets the list of all Mana Collectors (eg. Mana Spreader) in the dimension - * passed in. Note that this is the actual list and not a copy, make sure to - * clone the list if you intend to change it in any way. - */ - public List getAllCollectorsInWorld(World world); + /** + * Gets the list of all Mana Collectors (eg. Mana Spreader) in the dimension + * passed in. Note that this is the actual list and not a copy, make sure to + * clone the list if you intend to change it in any way. + */ + public List getAllCollectorsInWorld(World world); - /** - * Gets the list of all Mana Pools in the dimension passed in. Note that this - * is the actual list and not a copy, make sure to clone the list if you intend - * to change it in any way. - */ - public List getAllPoolsInWorld(World world); + /** + * Gets the list of all Mana Pools in the dimension passed in. Note that this + * is the actual list and not a copy, make sure to clone the list if you intend + * to change it in any way. + */ + public List getAllPoolsInWorld(World world); } diff --git a/src/main/java/vazkii/botania/api/internal/ShaderCallback.java b/src/main/java/vazkii/botania/api/internal/ShaderCallback.java index ee625ee5bc..12186a2319 100644 --- a/src/main/java/vazkii/botania/api/internal/ShaderCallback.java +++ b/src/main/java/vazkii/botania/api/internal/ShaderCallback.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Oct 29, 2014, 6:31:35 PM (GMT)] */ package vazkii.botania.api.internal; @@ -15,5 +15,6 @@ */ public abstract class ShaderCallback { - public abstract void call(int shader); + public abstract void call(int shader); + } diff --git a/src/main/java/vazkii/botania/api/internal/VanillaPacketDispatcher.java b/src/main/java/vazkii/botania/api/internal/VanillaPacketDispatcher.java index 4884edd8b4..dff8b96360 100644 --- a/src/main/java/vazkii/botania/api/internal/VanillaPacketDispatcher.java +++ b/src/main/java/vazkii/botania/api/internal/VanillaPacketDispatcher.java @@ -2,38 +2,41 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Apr 9, 2015, 9:38:44 PM (GMT)] */ package vazkii.botania.api.internal; import java.util.List; + import net.minecraft.entity.player.EntityPlayerMP; import net.minecraft.tileentity.TileEntity; import net.minecraft.world.World; public final class VanillaPacketDispatcher { - public static void dispatchTEToNearbyPlayers(TileEntity tile) { - World world = tile.getWorldObj(); - List players = world.playerEntities; - for (Object player : players) - if (player instanceof EntityPlayerMP) { - EntityPlayerMP mp = (EntityPlayerMP) player; - if (pointDistancePlane(mp.posX, mp.posZ, tile.xCoord + 0.5, tile.zCoord + 0.5) < 64) - ((EntityPlayerMP) player).playerNetServerHandler.sendPacket(tile.getDescriptionPacket()); - } - } + public static void dispatchTEToNearbyPlayers(TileEntity tile) { + World world = tile.getWorldObj(); + List players = world.playerEntities; + for(Object player : players) + if(player instanceof EntityPlayerMP) { + EntityPlayerMP mp = (EntityPlayerMP) player; + if(pointDistancePlane(mp.posX, mp.posZ, tile.xCoord + 0.5, tile.zCoord + 0.5) < 64) + ((EntityPlayerMP) player).playerNetServerHandler.sendPacket(tile.getDescriptionPacket()); + } + } + + public static void dispatchTEToNearbyPlayers(World world, int x, int y, int z) { + TileEntity tile = world.getTileEntity(x, y, z); + if(tile != null) + dispatchTEToNearbyPlayers(tile); + } - public static void dispatchTEToNearbyPlayers(World world, int x, int y, int z) { - TileEntity tile = world.getTileEntity(x, y, z); - if (tile != null) dispatchTEToNearbyPlayers(tile); - } + public static float pointDistancePlane(double x1, double y1, double x2, double y2) { + return (float) Math.hypot(x1 - x2, y1 - y2); + } - public static float pointDistancePlane(double x1, double y1, double x2, double y2) { - return (float) Math.hypot(x1 - x2, y1 - y2); - } } diff --git a/src/main/java/vazkii/botania/api/item/IAncientWillContainer.java b/src/main/java/vazkii/botania/api/item/IAncientWillContainer.java index a5d87ffa1e..2d2abe2b3c 100644 --- a/src/main/java/vazkii/botania/api/item/IAncientWillContainer.java +++ b/src/main/java/vazkii/botania/api/item/IAncientWillContainer.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jan 30, 2015, 11:24:54 PM (GMT)] */ package vazkii.botania.api.item; @@ -18,7 +18,8 @@ */ public interface IAncientWillContainer { - public void addAncientWill(ItemStack stack, int will); + public void addAncientWill(ItemStack stack, int will); + + public boolean hasAncientWill(ItemStack stack, int will); - public boolean hasAncientWill(ItemStack stack, int will); } diff --git a/src/main/java/vazkii/botania/api/item/IAvatarTile.java b/src/main/java/vazkii/botania/api/item/IAvatarTile.java index bfdc245a06..c89f903b22 100644 --- a/src/main/java/vazkii/botania/api/item/IAvatarTile.java +++ b/src/main/java/vazkii/botania/api/item/IAvatarTile.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Oct 24, 2015, 7:00:21 PM (GMT)] */ package vazkii.botania.api.item; @@ -18,14 +18,15 @@ */ public interface IAvatarTile extends IInventory, IManaReceiver { - /** - * Gets the amount of ticks that have elapsed on this avatar while it's functional - * (has redstone signal). - */ - public int getElapsedFunctionalTicks(); + /** + * Gets the amount of ticks that have elapsed on this avatar while it's functional + * (has redstone signal). + */ + public int getElapsedFunctionalTicks(); + + /** + * Gets if this avatar is enabled (isn't powered by a redstone signal). + */ + public boolean isEnabled(); - /** - * Gets if this avatar is enabled (isn't powered by a redstone signal). - */ - public boolean isEnabled(); } diff --git a/src/main/java/vazkii/botania/api/item/IAvatarWieldable.java b/src/main/java/vazkii/botania/api/item/IAvatarWieldable.java index 559f67e564..96910090ac 100644 --- a/src/main/java/vazkii/botania/api/item/IAvatarWieldable.java +++ b/src/main/java/vazkii/botania/api/item/IAvatarWieldable.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Oct 24, 2015, 6:45:50 PM (GMT)] */ package vazkii.botania.api.item; @@ -18,13 +18,14 @@ */ public interface IAvatarWieldable { - /** - * Called on update of the avatar tile. - */ - public void onAvatarUpdate(IAvatarTile tile, ItemStack stack); + /** + * Called on update of the avatar tile. + */ + public void onAvatarUpdate(IAvatarTile tile, ItemStack stack); + + /** + * Gets the overlay resource to render on top of the avatar tile. + */ + public ResourceLocation getOverlayResource(IAvatarTile tile, ItemStack stack); - /** - * Gets the overlay resource to render on top of the avatar tile. - */ - public ResourceLocation getOverlayResource(IAvatarTile tile, ItemStack stack); } diff --git a/src/main/java/vazkii/botania/api/item/IBaubleRender.java b/src/main/java/vazkii/botania/api/item/IBaubleRender.java index 02d4bb288e..d98a29434b 100644 --- a/src/main/java/vazkii/botania/api/item/IBaubleRender.java +++ b/src/main/java/vazkii/botania/api/item/IBaubleRender.java @@ -2,22 +2,24 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Dec 4, 2014, 3:28:43 PM (GMT)] */ package vazkii.botania.api.item; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; import net.minecraft.client.Minecraft; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; import net.minecraftforge.client.event.RenderPlayerEvent; + import org.lwjgl.opengl.GL11; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + /** * A Bauble Item that implements this will be have hooks to render something on * the player while its equipped. @@ -26,52 +28,50 @@ */ public interface IBaubleRender { - /** - * Called for the rendering of the bauble on the player. The player instance can be - * acquired through the event parameter. Transformations are already applied for - * the RenderType passed in. Make sure to check against the type parameter for - * rendering. Will not be called if the item is a ICosmeticAttachable and - * has a cosmetic bauble attached to it. - */ - @SideOnly(Side.CLIENT) - public void onPlayerBaubleRender(ItemStack stack, RenderPlayerEvent event, RenderType type); + /** + * Called for the rendering of the bauble on the player. The player instance can be + * acquired through the event parameter. Transformations are already applied for + * the RenderType passed in. Make sure to check against the type parameter for + * rendering. Will not be called if the item is a ICosmeticAttachable and + * has a cosmetic bauble attached to it. + */ + @SideOnly(Side.CLIENT) + public void onPlayerBaubleRender(ItemStack stack, RenderPlayerEvent event, RenderType type); + + /** + * A few helper methods for the render. + */ + public static class Helper { + + public static void rotateIfSneaking(EntityPlayer player) { + if(player.isSneaking()) + applySneakingRotation(); + } - /** - * A few helper methods for the render. - */ - public static class Helper { + public static void applySneakingRotation() { + GL11.glRotatef(28.64789F, 1.0F, 0.0F, 0.0F); + } - public static void rotateIfSneaking(EntityPlayer player) { - if (player.isSneaking()) applySneakingRotation(); - } + public static void translateToHeadLevel(EntityPlayer player) { + GL11.glTranslated(0, (player != Minecraft.getMinecraft().thePlayer ? 1.68F : 0F) - player.getDefaultEyeHeight() + (player.isSneaking() ? 0.0625 : 0), 0); + } - public static void applySneakingRotation() { - GL11.glRotatef(28.64789F, 1.0F, 0.0F, 0.0F); - } + } - public static void translateToHeadLevel(EntityPlayer player) { - GL11.glTranslated( - 0, - (player != Minecraft.getMinecraft().thePlayer ? 1.68F : 0F) - - player.getDefaultEyeHeight() - + (player.isSneaking() ? 0.0625 : 0), - 0); - } - } + public static enum RenderType { + /** + * Render Type for the player's body, translations apply on the player's rotation. + * Sneaking is not handled and should be done during the render. + * @see IBaubleRender.Helper + */ + BODY, - public static enum RenderType { - /** - * Render Type for the player's body, translations apply on the player's rotation. - * Sneaking is not handled and should be done during the render. - * @see IBaubleRender.Helper - */ - BODY, + /** + * Render Type for the player's body, translations apply on the player's head rotations. + * Sneaking is not handled and should be done during the render.~ + * @see IBaubleRender.Helper + */ + HEAD; + } - /** - * Render Type for the player's body, translations apply on the player's head rotations. - * Sneaking is not handled and should be done during the render.~ - * @see IBaubleRender.Helper - */ - HEAD; - } } diff --git a/src/main/java/vazkii/botania/api/item/IBlockProvider.java b/src/main/java/vazkii/botania/api/item/IBlockProvider.java index 2efd1e2a7d..42f2e3f892 100644 --- a/src/main/java/vazkii/botania/api/item/IBlockProvider.java +++ b/src/main/java/vazkii/botania/api/item/IBlockProvider.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Aug 20, 2015, 10:31:54 PM (GMT)] */ package vazkii.botania.api.item; @@ -21,20 +21,20 @@ */ public interface IBlockProvider { - /** - * Provides the requested item. The doit paremeter specifies whether this is - * just a test (false) or if the item should actually be removed (true). - * If you need to use calls to ManaItemHandler.requestMana[Exact], use - * the requestor as the ItemStack passed in. - */ - public boolean provideBlock( - EntityPlayer player, ItemStack requestor, ItemStack stack, Block block, int meta, boolean doit); + /** + * Provides the requested item. The doit paremeter specifies whether this is + * just a test (false) or if the item should actually be removed (true). + * If you need to use calls to ManaItemHandler.requestMana[Exact], use + * the requestor as the ItemStack passed in. + */ + public boolean provideBlock(EntityPlayer player, ItemStack requestor, ItemStack stack, Block block, int meta, boolean doit); + + /** + * Gets the amount of blocks of the type passed stored in this item. You must + * check for the block passed in to not give the counter for a wrong block. Returning + * -1 states that the item can provide infinite of the item passed in (for example, + * the Rod of the Lands would return -1 if the block is dirt). + */ + public int getBlockCount(EntityPlayer player, ItemStack requestor, ItemStack stack, Block block, int meta); - /** - * Gets the amount of blocks of the type passed stored in this item. You must - * check for the block passed in to not give the counter for a wrong block. Returning - * -1 states that the item can provide infinite of the item passed in (for example, - * the Rod of the Lands would return -1 if the block is dirt). - */ - public int getBlockCount(EntityPlayer player, ItemStack requestor, ItemStack stack, Block block, int meta); } diff --git a/src/main/java/vazkii/botania/api/item/IBurstViewerBauble.java b/src/main/java/vazkii/botania/api/item/IBurstViewerBauble.java index f5f3f1fd75..4402a715f3 100644 --- a/src/main/java/vazkii/botania/api/item/IBurstViewerBauble.java +++ b/src/main/java/vazkii/botania/api/item/IBurstViewerBauble.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jan 24, 2015, 3:08:40 PM (GMT)] */ package vazkii.botania.api.item; @@ -15,4 +15,6 @@ * Having a IBauble of this type equipped on the 0th slot (amulet) * will draw bursts without depth testing and to see sub tile radiuses. */ -public interface IBurstViewerBauble {} +public interface IBurstViewerBauble { + +} diff --git a/src/main/java/vazkii/botania/api/item/ICosmeticAttachable.java b/src/main/java/vazkii/botania/api/item/ICosmeticAttachable.java index fd7d799b95..4fbee0ec0e 100644 --- a/src/main/java/vazkii/botania/api/item/ICosmeticAttachable.java +++ b/src/main/java/vazkii/botania/api/item/ICosmeticAttachable.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Feb 22, 2015, 8:31:39 PM (GMT)] */ package vazkii.botania.api.item; @@ -20,13 +20,14 @@ */ public interface ICosmeticAttachable { - /** - * Gets the cosmetic item stored in the stack passed in. - */ - public ItemStack getCosmeticItem(ItemStack stack); + /** + * Gets the cosmetic item stored in the stack passed in. + */ + public ItemStack getCosmeticItem(ItemStack stack); + + /** + * Sets the stack's cosmetic item to the one passed in. + */ + public void setCosmeticItem(ItemStack stack, ItemStack cosmetic); - /** - * Sets the stack's cosmetic item to the one passed in. - */ - public void setCosmeticItem(ItemStack stack, ItemStack cosmetic); } diff --git a/src/main/java/vazkii/botania/api/item/ICosmeticBauble.java b/src/main/java/vazkii/botania/api/item/ICosmeticBauble.java index 7fee236866..d488ad4e94 100644 --- a/src/main/java/vazkii/botania/api/item/ICosmeticBauble.java +++ b/src/main/java/vazkii/botania/api/item/ICosmeticBauble.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Feb 22, 2015, 2:02:02 PM (GMT)] */ package vazkii.botania.api.item; @@ -15,4 +15,6 @@ * other baubles to add the render to them. Other cosmetic baubles * can't be stacked on this. */ -public interface ICosmeticBauble extends IBaubleRender {} +public interface ICosmeticBauble extends IBaubleRender { + +} diff --git a/src/main/java/vazkii/botania/api/item/IDyablePool.java b/src/main/java/vazkii/botania/api/item/IDyablePool.java index a30b5838f6..8bb8e94eb9 100644 --- a/src/main/java/vazkii/botania/api/item/IDyablePool.java +++ b/src/main/java/vazkii/botania/api/item/IDyablePool.java @@ -2,20 +2,23 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jan 18, 2015, 12:20:44 AM (GMT)] */ package vazkii.botania.api.item; + /** * Used to define a Mana Pool that can be dyed through floral powder. */ public interface IDyablePool { - public int getColor(); + public int getColor(); + + public void setColor(int color); + - public void setColor(int color); } diff --git a/src/main/java/vazkii/botania/api/item/IExoflameHeatable.java b/src/main/java/vazkii/botania/api/item/IExoflameHeatable.java index 56d57fb8be..bd007342dc 100644 --- a/src/main/java/vazkii/botania/api/item/IExoflameHeatable.java +++ b/src/main/java/vazkii/botania/api/item/IExoflameHeatable.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Aug 30, 2014, 4:28:29 PM (GMT)] */ package vazkii.botania.api.item; @@ -15,28 +15,29 @@ */ public interface IExoflameHeatable { - /** - * Can this TileEntity smelt its contents. If true, the Exoflame is allowed - * to fuel it. - */ - public boolean canSmelt(); + /** + * Can this TileEntity smelt its contents. If true, the Exoflame is allowed + * to fuel it. + */ + public boolean canSmelt(); - /** - * Gets the amount of ticks left for the fuel. If below 2, the exoflame - * will call boostBurnTime. - */ - public int getBurnTime(); + /** + * Gets the amount of ticks left for the fuel. If below 2, the exoflame + * will call boostBurnTime. + */ + public int getBurnTime(); - /** - * Called to increase the amount of time this furnace should be burning - * the fuel for. Even if it doesn't have any fuel. - */ - public void boostBurnTime(); + /** + * Called to increase the amount of time this furnace should be burning + * the fuel for. Even if it doesn't have any fuel. + */ + public void boostBurnTime(); + + /** + * Called once every two ticks to increase the speed of the furnace. Feel + * free to not do anything if all you want is to allow the exoflame to feed + * it, not make it faster. + */ + public void boostCookTime(); - /** - * Called once every two ticks to increase the speed of the furnace. Feel - * free to not do anything if all you want is to allow the exoflame to feed - * it, not make it faster. - */ - public void boostCookTime(); } diff --git a/src/main/java/vazkii/botania/api/item/IExtendedPlayerController.java b/src/main/java/vazkii/botania/api/item/IExtendedPlayerController.java index 16ff8770a2..e07d076661 100644 --- a/src/main/java/vazkii/botania/api/item/IExtendedPlayerController.java +++ b/src/main/java/vazkii/botania/api/item/IExtendedPlayerController.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Aug 6, 2014, 6:02:29 PM (GMT)] */ package vazkii.botania.api.item; @@ -16,13 +16,13 @@ */ public interface IExtendedPlayerController { - /** - * Sets the extra reach the player should have. - */ - public void setReachDistanceExtension(float f); + /** + * Sets the extra reach the player should have. + */ + public void setReachDistanceExtension(float f); - /** - * Gets the current reach extension. - */ - public float getReachDistanceExtension(); + /** + * Gets the current reach extension. + */ + public float getReachDistanceExtension(); } diff --git a/src/main/java/vazkii/botania/api/item/IExtendedWireframeCoordinateListProvider.java b/src/main/java/vazkii/botania/api/item/IExtendedWireframeCoordinateListProvider.java index 7b8e05f6e9..7713eaa5bf 100644 --- a/src/main/java/vazkii/botania/api/item/IExtendedWireframeCoordinateListProvider.java +++ b/src/main/java/vazkii/botania/api/item/IExtendedWireframeCoordinateListProvider.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Apr 30, 2015, 1:43:17 PM (GMT)] */ package vazkii.botania.api.item; @@ -20,8 +20,9 @@ */ public interface IExtendedWireframeCoordinateListProvider extends IWireframeCoordinateListProvider { - /** - * Gets the source wireframe to draw, this one will be drawn thicker. - */ - public ChunkCoordinates getSourceWireframe(EntityPlayer player, ItemStack stack); + /** + * Gets the source wireframe to draw, this one will be drawn thicker. + */ + public ChunkCoordinates getSourceWireframe(EntityPlayer player, ItemStack stack); + } diff --git a/src/main/java/vazkii/botania/api/item/IFlowerPlaceable.java b/src/main/java/vazkii/botania/api/item/IFlowerPlaceable.java index db48ed1656..05f1f1f406 100644 --- a/src/main/java/vazkii/botania/api/item/IFlowerPlaceable.java +++ b/src/main/java/vazkii/botania/api/item/IFlowerPlaceable.java @@ -2,14 +2,13 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [17/11/2015, 20:10:53 (GMT)] */ package vazkii.botania.api.item; - import net.minecraft.block.Block; import net.minecraft.item.ItemStack; import vazkii.botania.api.subtile.SubTileEntity; @@ -19,10 +18,10 @@ */ public interface IFlowerPlaceable { - /** - * Gets the block to be placed, return null to not place anything. - */ - public Block getBlockToPlaceByFlower(ItemStack stack, SubTileEntity flower, int x, int y, int z); + /** + * Gets the block to be placed, return null to not place anything. + */ + public Block getBlockToPlaceByFlower(ItemStack stack, SubTileEntity flower, int x, int y, int z); - public void onBlockPlacedByFlower(ItemStack stack, SubTileEntity flower, int x, int y, int z); + public void onBlockPlacedByFlower(ItemStack stack, SubTileEntity flower, int x, int y, int z); } diff --git a/src/main/java/vazkii/botania/api/item/IFlowerlessBiome.java b/src/main/java/vazkii/botania/api/item/IFlowerlessBiome.java index fe31fda143..16543e4c9a 100644 --- a/src/main/java/vazkii/botania/api/item/IFlowerlessBiome.java +++ b/src/main/java/vazkii/botania/api/item/IFlowerlessBiome.java @@ -9,15 +9,13 @@ * File Created @ [? (GMT)] */ package vazkii.botania.api.item; - import net.minecraft.world.World; - /** * A BiomeGenBase that implements this will not have Botania flowers generated. */ public interface IFlowerlessBiome { - /** - * @return Should this world be allowed to generate flowers? - */ - public boolean canGenerateFlowers(World world, int x, int z); -} + /** + * @return Should this world be allowed to generate flowers? + */ + public boolean canGenerateFlowers(World world, int x, int z); +} \ No newline at end of file diff --git a/src/main/java/vazkii/botania/api/item/IFlowerlessWorld.java b/src/main/java/vazkii/botania/api/item/IFlowerlessWorld.java index 414fb04944..5d25d7979d 100644 --- a/src/main/java/vazkii/botania/api/item/IFlowerlessWorld.java +++ b/src/main/java/vazkii/botania/api/item/IFlowerlessWorld.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [? (GMT)] */ package vazkii.botania.api.item; @@ -17,8 +17,8 @@ */ public interface IFlowerlessWorld { - /** - * @return Should this world be allowed to generate flowers? - */ - public boolean generateFlowers(World world); + /** + * @return Should this world be allowed to generate flowers? + */ + public boolean generateFlowers(World world); } diff --git a/src/main/java/vazkii/botania/api/item/IGrassHornExcempt.java b/src/main/java/vazkii/botania/api/item/IGrassHornExcempt.java index 2397617219..601ad91132 100644 --- a/src/main/java/vazkii/botania/api/item/IGrassHornExcempt.java +++ b/src/main/java/vazkii/botania/api/item/IGrassHornExcempt.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Oct 29, 2014, 4:52:04 PM (GMT)] */ package vazkii.botania.api.item; @@ -20,5 +20,6 @@ @Deprecated public interface IGrassHornExcempt { - public boolean canUproot(World world, int x, int y, int z); + public boolean canUproot(World world, int x, int y, int z); + } diff --git a/src/main/java/vazkii/botania/api/item/IHornHarvestable.java b/src/main/java/vazkii/botania/api/item/IHornHarvestable.java index e958360f25..a74af38dcb 100644 --- a/src/main/java/vazkii/botania/api/item/IHornHarvestable.java +++ b/src/main/java/vazkii/botania/api/item/IHornHarvestable.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Oct 24, 2015, 11:16:00 PM (GMT)] */ package vazkii.botania.api.item; @@ -18,45 +18,47 @@ */ public interface IHornHarvestable { - /** - * Returns true if this block can be uprooted. - * Note that the stack param can be null if it's a drum breaking it. - */ - public boolean canHornHarvest(World world, int x, int y, int z, ItemStack stack, EnumHornType hornType); - - /** - * Returns true if harvestByHorn() should be called. If false it just uses the normal - * block breaking method. - * Note that the stack param can be null if it's a drum breaking it. - */ - public boolean hasSpecialHornHarvest(World world, int x, int y, int z, ItemStack stack, EnumHornType hornType); - - /** - * Called to harvest by a horn. - * Note that the stack param can be null if it's a drum breaking it. - */ - public void harvestByHorn(World world, int x, int y, int z, ItemStack stack, EnumHornType hornType); - - public static enum EnumHornType { - - /** - * Horn of the Wild, for grass and crops - */ - WILD, - - /** - * Horn of the Canopy, for leaves - */ - CANOPY, - - /** - * Horn of the Covering, for snow - */ - COVERING; - - public static EnumHornType getTypeForMeta(int meta) { - EnumHornType[] values = EnumHornType.values(); - return values[Math.min(values.length - 1, meta)]; - } - }; + /** + * Returns true if this block can be uprooted. + * Note that the stack param can be null if it's a drum breaking it. + */ + public boolean canHornHarvest(World world, int x, int y, int z, ItemStack stack, EnumHornType hornType); + + /** + * Returns true if harvestByHorn() should be called. If false it just uses the normal + * block breaking method. + * Note that the stack param can be null if it's a drum breaking it. + */ + public boolean hasSpecialHornHarvest(World world, int x, int y, int z, ItemStack stack, EnumHornType hornType); + + /** + * Called to harvest by a horn. + * Note that the stack param can be null if it's a drum breaking it. + */ + public void harvestByHorn(World world, int x, int y, int z, ItemStack stack, EnumHornType hornType); + + public static enum EnumHornType { + + /** + * Horn of the Wild, for grass and crops + */ + WILD, + + /** + * Horn of the Canopy, for leaves + */ + CANOPY, + + /** + * Horn of the Covering, for snow + */ + COVERING; + + public static EnumHornType getTypeForMeta(int meta) { + EnumHornType[] values = EnumHornType.values(); + return values[Math.min(values.length - 1, meta)]; + } + + }; + } diff --git a/src/main/java/vazkii/botania/api/item/IManaDissolvable.java b/src/main/java/vazkii/botania/api/item/IManaDissolvable.java index 5e8d210b32..0d9ad5d4e7 100644 --- a/src/main/java/vazkii/botania/api/item/IManaDissolvable.java +++ b/src/main/java/vazkii/botania/api/item/IManaDissolvable.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jan 18, 2015, 12:10:00 AM (GMT)] */ package vazkii.botania.api.item; @@ -20,9 +20,10 @@ */ public interface IManaDissolvable { - /** - * Called for every tick the item is on a mana pool. If the stack has stack - * size 0 the item is killed. This is called in both the server and client. - */ - public void onDissolveTick(IManaPool pool, ItemStack stack, EntityItem item); + /** + * Called for every tick the item is on a mana pool. If the stack has stack + * size 0 the item is killed. This is called in both the server and client. + */ + public void onDissolveTick(IManaPool pool, ItemStack stack, EntityItem item); + } diff --git a/src/main/java/vazkii/botania/api/item/IManaProficiencyArmor.java b/src/main/java/vazkii/botania/api/item/IManaProficiencyArmor.java index cc7b3f61e7..595e800dbb 100644 --- a/src/main/java/vazkii/botania/api/item/IManaProficiencyArmor.java +++ b/src/main/java/vazkii/botania/api/item/IManaProficiencyArmor.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Aug 28, 2015, 9:04:53 PM (GMT)] */ package vazkii.botania.api.item; @@ -23,20 +23,22 @@ */ public interface IManaProficiencyArmor { - public boolean shouldGiveProficiency(ItemStack stack, int slot, EntityPlayer player); + public boolean shouldGiveProficiency(ItemStack stack, int slot, EntityPlayer player); - public static final class Helper { + public final static class Helper { + + public static boolean hasProficiency(EntityPlayer player) { + for(int i = 0; i < 4; i++) { + ItemStack armor = player.getCurrentArmor(i); + if(armor != null) { + Item item = armor.getItem(); + if(item instanceof IManaProficiencyArmor && ((IManaProficiencyArmor) item).shouldGiveProficiency(armor, i, player)) + return true; + } + } + return false; + } + + } - public static boolean hasProficiency(EntityPlayer player) { - for (int i = 0; i < 4; i++) { - ItemStack armor = player.getCurrentArmor(i); - if (armor != null) { - Item item = armor.getItem(); - if (item instanceof IManaProficiencyArmor - && ((IManaProficiencyArmor) item).shouldGiveProficiency(armor, i, player)) return true; - } - } - return false; - } - } } diff --git a/src/main/java/vazkii/botania/api/item/IPetalApothecary.java b/src/main/java/vazkii/botania/api/item/IPetalApothecary.java index 184fc79fad..15ae69c0be 100644 --- a/src/main/java/vazkii/botania/api/item/IPetalApothecary.java +++ b/src/main/java/vazkii/botania/api/item/IPetalApothecary.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Aug 30, 2014, 4:22:15 PM (GMT)] */ package vazkii.botania.api.item; @@ -16,13 +16,14 @@ */ public interface IPetalApothecary { - /** - * Sets if the the apothecary has water or not. - */ - public void setWater(boolean water); + /** + * Sets if the the apothecary has water or not. + */ + public void setWater(boolean water); + + /** + * Does the apothecary have water in it? + */ + public boolean hasWater(); - /** - * Does the apothecary have water in it? - */ - public boolean hasWater(); } diff --git a/src/main/java/vazkii/botania/api/item/IPhantomInkable.java b/src/main/java/vazkii/botania/api/item/IPhantomInkable.java index f633723609..dc2f397b0b 100644 --- a/src/main/java/vazkii/botania/api/item/IPhantomInkable.java +++ b/src/main/java/vazkii/botania/api/item/IPhantomInkable.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Mar 17, 2015, 4:57:44 PM (GMT)] */ package vazkii.botania.api.item; @@ -17,7 +17,8 @@ */ public interface IPhantomInkable { - public boolean hasPhantomInk(ItemStack stack); + public boolean hasPhantomInk(ItemStack stack); + + public void setPhantomInk(ItemStack stack, boolean ink); - public void setPhantomInk(ItemStack stack, boolean ink); } diff --git a/src/main/java/vazkii/botania/api/item/IPixieSpawner.java b/src/main/java/vazkii/botania/api/item/IPixieSpawner.java index 260341f5f6..de8c9730d1 100644 --- a/src/main/java/vazkii/botania/api/item/IPixieSpawner.java +++ b/src/main/java/vazkii/botania/api/item/IPixieSpawner.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Aug 6, 2014, 6:06:27 PM (GMT)] */ package vazkii.botania.api.item; @@ -20,9 +20,10 @@ */ public interface IPixieSpawner { - /** - * The chance this item adds for pixies to be spawned. From 0.0 to 1.0. All values - * are put together when calculating. - */ - public float getPixieChance(ItemStack stack); -} + /** + * The chance this item adds for pixies to be spawned. From 0.0 to 1.0. All values + * are put together when calculating. + */ + public float getPixieChance(ItemStack stack); + +} \ No newline at end of file diff --git a/src/main/java/vazkii/botania/api/item/IRelic.java b/src/main/java/vazkii/botania/api/item/IRelic.java index deeb9e1bcd..aecd1cde43 100644 --- a/src/main/java/vazkii/botania/api/item/IRelic.java +++ b/src/main/java/vazkii/botania/api/item/IRelic.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Mar 29, 2015, 7:17:41 PM (GMT)] */ package vazkii.botania.api.item; @@ -19,23 +19,24 @@ */ public interface IRelic { - /** - * Binds to the player name passed in. - */ - public void bindToUsername(String playerName, ItemStack stack); + /** + * Binds to the player name passed in. + */ + public void bindToUsername(String playerName, ItemStack stack); - /** - * Gets the username of the person this relic is bound to. - */ - public String getSoulbindUsername(ItemStack stack); + /** + * Gets the username of the person this relic is bound to. + */ + public String getSoulbindUsername(ItemStack stack); - /** - * Sets the achievement that this relic binds to. - */ - public void setBindAchievement(Achievement achievement); + /** + * Sets the achievement that this relic binds to. + */ + public void setBindAchievement(Achievement achievement); + + /** + * Gets the achievement that this relic binds to. + */ + public Achievement getBindAchievement(); - /** - * Gets the achievement that this relic binds to. - */ - public Achievement getBindAchievement(); } diff --git a/src/main/java/vazkii/botania/api/item/ISequentialBreaker.java b/src/main/java/vazkii/botania/api/item/ISequentialBreaker.java index a1eae9892e..87af2d04db 100644 --- a/src/main/java/vazkii/botania/api/item/ISequentialBreaker.java +++ b/src/main/java/vazkii/botania/api/item/ISequentialBreaker.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Mar 30, 2015, 2:46:05 PM (GMT)] */ package vazkii.botania.api.item; @@ -20,8 +20,8 @@ */ public interface ISequentialBreaker { - public void breakOtherBlock( - EntityPlayer player, ItemStack stack, int x, int y, int z, int originX, int originY, int originZ, int side); + public void breakOtherBlock(EntityPlayer player, ItemStack stack, int x, int y, int z, int originX, int originY, int originZ, int side); + + public boolean disposeOfTrashBlocks(ItemStack stack); - public boolean disposeOfTrashBlocks(ItemStack stack); } diff --git a/src/main/java/vazkii/botania/api/item/ISortableTool.java b/src/main/java/vazkii/botania/api/item/ISortableTool.java index 908e0adac0..af450bceef 100644 --- a/src/main/java/vazkii/botania/api/item/ISortableTool.java +++ b/src/main/java/vazkii/botania/api/item/ISortableTool.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Feb 23, 2015, 7:03:48 PM (GMT)] */ package vazkii.botania.api.item; @@ -18,31 +18,30 @@ */ public interface ISortableTool { - /** - * Gets the type of tool that this is. A pick, axe or shovel. - */ - public ToolType getSortingType(ItemStack stack); + /** + * Gets the type of tool that this is. A pick, axe or shovel. + */ + public ToolType getSortingType(ItemStack stack); - /** - * Gets the priority that this tool should have when being sorted. The - * tool with the highest priority will be picked. The way this is specified - * should be (tool-level) * 100 + (tool-modifier) * 10 + (efficiency-level). - *

- * For example, a Manasteel Pickaxe is tool-level 10 and it doesn't have - * modifiers. Assuming Efficiency 4, the priority should be 10 * 100 + 4 = 1004. - * This will rate higher than a similar pickaxe with Efficiency 3.
- * A Terra Shatterer has a modifier, its rank and is tool-level 20. With Efficiency - * 5 and rank B (2) the priority should be 20 * 100 + 2 * 10 + 5 = 2025. - *

- * All intermediate tool levels are there for other mod tools that wish to occupy the spots inbetween. - * Of course, you don't have to always adhere to this. Tools like the Vitreous Pickaxe don't, - * that one in particular is priority 0 so it's never picked. - */ - public int getSortingPriority(ItemStack stack); + /** + * Gets the priority that this tool should have when being sorted. The + * tool with the highest priority will be picked. The way this is specified + * should be (tool-level) * 100 + (tool-modifier) * 10 + (efficiency-level). + *

+ * For example, a Manasteel Pickaxe is tool-level 10 and it doesn't have + * modifiers. Assuming Efficiency 4, the priority should be 10 * 100 + 4 = 1004. + * This will rate higher than a similar pickaxe with Efficiency 3.
+ * A Terra Shatterer has a modifier, its rank and is tool-level 20. With Efficiency + * 5 and rank B (2) the priority should be 20 * 100 + 2 * 10 + 5 = 2025. + *

+ * All intermediate tool levels are there for other mod tools that wish to occupy the spots inbetween. + * Of course, you don't have to always adhere to this. Tools like the Vitreous Pickaxe don't, + * that one in particular is priority 0 so it's never picked. + */ + public int getSortingPriority(ItemStack stack); - public static enum ToolType { - PICK, - AXE, - SHOVEL - } -} + public static enum ToolType { + PICK, AXE, SHOVEL + } + +} \ No newline at end of file diff --git a/src/main/java/vazkii/botania/api/item/IWireframeCoordinateListProvider.java b/src/main/java/vazkii/botania/api/item/IWireframeCoordinateListProvider.java index 2bab862d2f..ae0863ce7b 100644 --- a/src/main/java/vazkii/botania/api/item/IWireframeCoordinateListProvider.java +++ b/src/main/java/vazkii/botania/api/item/IWireframeCoordinateListProvider.java @@ -2,20 +2,21 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Mar 29, 2015, 11:30:41 PM (GMT)] */ package vazkii.botania.api.item; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; import java.util.List; + import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; import net.minecraft.util.ChunkCoordinates; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; /** * An item that implements this will allow for various wireframes to be drawn @@ -24,10 +25,11 @@ */ public interface IWireframeCoordinateListProvider { - /** - * Returns a list of ChunkCoordinates for the wireframes to draw. - * Can be null. - */ - @SideOnly(Side.CLIENT) - public List getWireframesToDraw(EntityPlayer player, ItemStack stack); + /** + * Returns a list of ChunkCoordinates for the wireframes to draw. + * Can be null. + */ + @SideOnly(Side.CLIENT) + public List getWireframesToDraw(EntityPlayer player, ItemStack stack); + } diff --git a/src/main/java/vazkii/botania/api/item/TinyPotatoRenderEvent.java b/src/main/java/vazkii/botania/api/item/TinyPotatoRenderEvent.java index 8974fa7ae6..8b51c2634c 100644 --- a/src/main/java/vazkii/botania/api/item/TinyPotatoRenderEvent.java +++ b/src/main/java/vazkii/botania/api/item/TinyPotatoRenderEvent.java @@ -2,18 +2,18 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jul 25, 2015, 8:02:41 PM (GMT)] */ package vazkii.botania.api.item; +import net.minecraft.tileentity.TileEntity; import cpw.mods.fml.common.eventhandler.Event; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; -import net.minecraft.tileentity.TileEntity; /** * Why would you ever want this ._. @@ -21,17 +21,18 @@ @SideOnly(Side.CLIENT) public class TinyPotatoRenderEvent extends Event { - public final TileEntity tile; - public final String name; - public final double x, y, z; - public final float partTicks; + public final TileEntity tile; + public final String name; + public final double x, y, z; + public final float partTicks; + + public TinyPotatoRenderEvent(TileEntity tile, String name, double x, double y, double z, float partTicks) { + this.tile = tile; + this.name = name; + this.x = x; + this.y = y; + this.z = z; + this.partTicks = partTicks; + } - public TinyPotatoRenderEvent(TileEntity tile, String name, double x, double y, double z, float partTicks) { - this.tile = tile; - this.name = name; - this.x = x; - this.y = y; - this.z = z; - this.partTicks = partTicks; - } } diff --git a/src/main/java/vazkii/botania/api/lexicon/BotaniaTutorialStartEvent.java b/src/main/java/vazkii/botania/api/lexicon/BotaniaTutorialStartEvent.java index c03ea5b799..c082572b8b 100644 --- a/src/main/java/vazkii/botania/api/lexicon/BotaniaTutorialStartEvent.java +++ b/src/main/java/vazkii/botania/api/lexicon/BotaniaTutorialStartEvent.java @@ -2,26 +2,28 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [04/12/2015, 18:29:56 (GMT)] */ package vazkii.botania.api.lexicon; -import cpw.mods.fml.common.eventhandler.Event; import java.util.Queue; +import cpw.mods.fml.common.eventhandler.Event; + /** * Fired when the Lexica Botania's tutorial is started. You can add your * own entries to the tutorial here. Please use this responsibly. */ public class BotaniaTutorialStartEvent extends Event { - public final Queue tutorial; + public final Queue tutorial; + + public BotaniaTutorialStartEvent(Queue tutorial) { + this.tutorial = tutorial; + } - public BotaniaTutorialStartEvent(Queue tutorial) { - this.tutorial = tutorial; - } } diff --git a/src/main/java/vazkii/botania/api/lexicon/IAddonEntry.java b/src/main/java/vazkii/botania/api/lexicon/IAddonEntry.java index 13225b8b4d..a92e608c57 100644 --- a/src/main/java/vazkii/botania/api/lexicon/IAddonEntry.java +++ b/src/main/java/vazkii/botania/api/lexicon/IAddonEntry.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jun 8, 2014, 7:02:48 PM (GMT)] */ package vazkii.botania.api.lexicon; @@ -19,9 +19,10 @@ */ public interface IAddonEntry { - /** - * Returns the unlocalized subtitle to show below the title. Here you'd - * return something like "(This Entry is provided by the Botanic Tinkerer addon)". - */ - public String getSubtitle(); + /** + * Returns the unlocalized subtitle to show below the title. Here you'd + * return something like "(This Entry is provided by the Botanic Tinkerer addon)". + */ + public String getSubtitle(); + } diff --git a/src/main/java/vazkii/botania/api/lexicon/ILexicon.java b/src/main/java/vazkii/botania/api/lexicon/ILexicon.java index 925ee046d1..ee07e17fc0 100644 --- a/src/main/java/vazkii/botania/api/lexicon/ILexicon.java +++ b/src/main/java/vazkii/botania/api/lexicon/ILexicon.java @@ -7,14 +7,15 @@ */ public interface ILexicon { - /** - * Gets if a specific knowledge is unlocked. Check the knowledge types in - * BotaniaAPI. - */ - public boolean isKnowledgeUnlocked(ItemStack stack, KnowledgeType knowledge); + /** + * Gets if a specific knowledge is unlocked. Check the knowledge types in + * BotaniaAPI. + */ + public boolean isKnowledgeUnlocked(ItemStack stack, KnowledgeType knowledge); + + /** + * Unlocks a specfic type of knowledge. + */ + public void unlockKnowledge(ItemStack stack, KnowledgeType knowledge); - /** - * Unlocks a specfic type of knowledge. - */ - public void unlockKnowledge(ItemStack stack, KnowledgeType knowledge); } diff --git a/src/main/java/vazkii/botania/api/lexicon/ILexiconable.java b/src/main/java/vazkii/botania/api/lexicon/ILexiconable.java index b236773c24..5baff9f51d 100644 --- a/src/main/java/vazkii/botania/api/lexicon/ILexiconable.java +++ b/src/main/java/vazkii/botania/api/lexicon/ILexiconable.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jan 20, 2014, 7:05:44 PM (GMT)] */ package vazkii.botania.api.lexicon; @@ -20,8 +20,9 @@ */ public interface ILexiconable { - /** - * Gets the lexicon entry to open at this location. null works too. - */ - public LexiconEntry getEntry(World world, int x, int y, int z, EntityPlayer player, ItemStack lexicon); + /** + * Gets the lexicon entry to open at this location. null works too. + */ + public LexiconEntry getEntry(World world, int x, int y, int z, EntityPlayer player, ItemStack lexicon); + } diff --git a/src/main/java/vazkii/botania/api/lexicon/IRecipeKeyProvider.java b/src/main/java/vazkii/botania/api/lexicon/IRecipeKeyProvider.java index 06249fe4d9..5b0c0631f8 100644 --- a/src/main/java/vazkii/botania/api/lexicon/IRecipeKeyProvider.java +++ b/src/main/java/vazkii/botania/api/lexicon/IRecipeKeyProvider.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Mar 20, 2014, 6:08:48 PM (GMT)] */ package vazkii.botania.api.lexicon; @@ -18,5 +18,6 @@ */ public interface IRecipeKeyProvider { - public String getKey(ItemStack stack); + public String getKey(ItemStack stack); + } diff --git a/src/main/java/vazkii/botania/api/lexicon/ITwoNamedPage.java b/src/main/java/vazkii/botania/api/lexicon/ITwoNamedPage.java index 1801a135c5..073b8704cd 100644 --- a/src/main/java/vazkii/botania/api/lexicon/ITwoNamedPage.java +++ b/src/main/java/vazkii/botania/api/lexicon/ITwoNamedPage.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Nov 3, 2014, 2:59:55 PM (GMT)] */ package vazkii.botania.api.lexicon; @@ -16,7 +16,8 @@ */ public interface ITwoNamedPage { - public void setSecondUnlocalizedName(String name); + public void setSecondUnlocalizedName(String name); + + public String getSecondUnlocalizedName(); - public String getSecondUnlocalizedName(); } diff --git a/src/main/java/vazkii/botania/api/lexicon/KnowledgeType.java b/src/main/java/vazkii/botania/api/lexicon/KnowledgeType.java index 0104b04115..5a08c9ceb4 100644 --- a/src/main/java/vazkii/botania/api/lexicon/KnowledgeType.java +++ b/src/main/java/vazkii/botania/api/lexicon/KnowledgeType.java @@ -4,17 +4,17 @@ public class KnowledgeType { - public final String id; - public final EnumChatFormatting color; - public final boolean autoUnlock; + public final String id; + public final EnumChatFormatting color; + public final boolean autoUnlock; - public KnowledgeType(String id, EnumChatFormatting color, boolean autoUnlock) { - this.id = id; - this.color = color; - this.autoUnlock = autoUnlock; - } + public KnowledgeType(String id, EnumChatFormatting color, boolean autoUnlock) { + this.id = id; + this.color = color; + this.autoUnlock = autoUnlock; + } - public String getUnlocalizedName() { - return "botania.knowledge." + id; - } + public String getUnlocalizedName() { + return "botania.knowledge." + id; + } } diff --git a/src/main/java/vazkii/botania/api/lexicon/LexiconCategory.java b/src/main/java/vazkii/botania/api/lexicon/LexiconCategory.java index 8e9ef29e4c..06f678d0d6 100644 --- a/src/main/java/vazkii/botania/api/lexicon/LexiconCategory.java +++ b/src/main/java/vazkii/botania/api/lexicon/LexiconCategory.java @@ -2,74 +2,75 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jan 14, 2014, 6:23:47 PM (GMT)] */ package vazkii.botania.api.lexicon; import java.util.ArrayList; import java.util.List; + import net.minecraft.util.ResourceLocation; public class LexiconCategory implements Comparable { - private static int count = 0; + private static int count = 0; - public final String unlocalizedName; - public final List entries = new ArrayList(); - private final int sortingId; - private ResourceLocation icon; - private int priority = 5; + public final String unlocalizedName; + public final List entries = new ArrayList(); + private final int sortingId; + private ResourceLocation icon; + private int priority = 5; - /** - * @param unlocalizedName The unlocalized name of this category. This will be localized by the client display. - */ - public LexiconCategory(String unlocalizedName) { - this.unlocalizedName = unlocalizedName; - sortingId = count; - count++; - } + /** + * @param unlocalizedName The unlocalized name of this category. This will be localized by the client display. + */ + public LexiconCategory(String unlocalizedName) { + this.unlocalizedName = unlocalizedName; + sortingId = count; + count++; + } - public String getUnlocalizedName() { - return unlocalizedName; - } + public String getUnlocalizedName() { + return unlocalizedName; + } - /** - * Sets the priority for this category for sorting. Higher numbers - * means they'll appear first in the book. The basics category - * is 9, the miscellaneous category is 0, other vanilla botania categories - * are 5. Using 9 and 0 is not recommended, since having your - * categories before basics or after miscellaneous is a bad idea. - * If two categories have the same priority they'll be sorted - * by insertion order. - */ - public LexiconCategory setPriority(int priority) { - this.priority = priority; - return this; - } + /** + * Sets the priority for this category for sorting. Higher numbers + * means they'll appear first in the book. The basics category + * is 9, the miscellaneous category is 0, other vanilla botania categories + * are 5. Using 9 and 0 is not recommended, since having your + * categories before basics or after miscellaneous is a bad idea. + * If two categories have the same priority they'll be sorted + * by insertion order. + */ + public LexiconCategory setPriority(int priority) { + this.priority = priority; + return this; + } - public int getSortingPriority() { - return priority; - } + public int getSortingPriority() { + return priority; + } - public final int getSortingId() { - return sortingId; - } + public final int getSortingId() { + return sortingId; + } - public LexiconCategory setIcon(ResourceLocation icon) { - this.icon = icon; - return this; - } + public LexiconCategory setIcon(ResourceLocation icon) { + this.icon = icon; + return this; + } - public ResourceLocation getIcon() { - return icon; - } + public ResourceLocation getIcon() { + return icon; + } - @Override - public int compareTo(LexiconCategory category) { - return priority == category.priority ? sortingId - category.sortingId : category.priority - priority; - } + @Override + public int compareTo(LexiconCategory category) { + return priority == category.priority ? sortingId - category.sortingId : category.priority - priority; + } } diff --git a/src/main/java/vazkii/botania/api/lexicon/LexiconEntry.java b/src/main/java/vazkii/botania/api/lexicon/LexiconEntry.java index 93f79d5ce9..2bc025065f 100644 --- a/src/main/java/vazkii/botania/api/lexicon/LexiconEntry.java +++ b/src/main/java/vazkii/botania/api/lexicon/LexiconEntry.java @@ -2,160 +2,165 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jan 14, 2014, 6:17:06 PM (GMT)] */ package vazkii.botania.api.lexicon; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; import java.util.ArrayList; import java.util.Arrays; import java.util.List; + import net.minecraft.item.ItemStack; import net.minecraft.util.StatCollector; import vazkii.botania.api.BotaniaAPI; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; public class LexiconEntry implements Comparable { - public final String unlocalizedName; - public final LexiconCategory category; - - private KnowledgeType type = BotaniaAPI.basicKnowledge; - - public List pages = new ArrayList(); - private boolean priority = false; - private ItemStack icon = null; - - private List extraDisplayedRecipes = new ArrayList(); - - /** - * @param unlocalizedName The unlocalized name of this entry. This will be localized by the client display. - */ - public LexiconEntry(String unlocalizedName, LexiconCategory category) { - this.unlocalizedName = unlocalizedName; - this.category = category; - } - - /** - * Sets this page as prioritized, as in, will appear before others in the lexicon. - */ - public LexiconEntry setPriority() { - priority = true; - return this; - } - - /** - * Sets the Knowledge type of this entry. - */ - public LexiconEntry setKnowledgeType(KnowledgeType type) { - this.type = type; - return this; - } - - public KnowledgeType getKnowledgeType() { - return type; - } - - /** - * Sets the display icon for this entry. Overriding the one already there. When adding recipe pages to the - * entry, this will be called once for the result of the first found recipe. - */ - public void setIcon(ItemStack stack) { - icon = stack; - } - - public ItemStack getIcon() { - return icon; - } - - public boolean isPriority() { - return priority; - } - - public String getUnlocalizedName() { - return unlocalizedName; - } - - public String getTagline() { - return null; // Override this if you want a tagline. You probably do - } - - @SideOnly(Side.CLIENT) - public boolean isVisible() { - return true; - } - - /** - * Sets what pages you want this entry to have. - */ - public LexiconEntry setLexiconPages(LexiconPage... pages) { - this.pages.addAll(Arrays.asList(pages)); - - for (int i = 0; i < this.pages.size(); i++) { - LexiconPage page = this.pages.get(i); - if (!page.skipRegistry) page.onPageAdded(this, i); - } - - return this; - } - - /** - * Returns the web link for this entry. If this isn't null, looking at this entry will - * show a "View Online" button in the book. The String returned should be the URL to - * open when the button is clicked. - */ - public String getWebLink() { - return null; - } - - /** - * Adds a page to the list of pages. - */ - public void addPage(LexiconPage page) { - pages.add(page); - } - - public final String getNameForSorting() { - return (priority ? 0 : 1) + StatCollector.translateToLocal(getUnlocalizedName()); - } - - public List getDisplayedRecipes() { - ArrayList list = new ArrayList(); - for (LexiconPage page : pages) { - List l = page.getDisplayedRecipes(); - - if (l != null) { - ArrayList itemsAddedThisPage = new ArrayList(); - - for (ItemStack s : l) { - addItem: - { - for (ItemStack s1 : itemsAddedThisPage) if (s1.getItem() == s.getItem()) break addItem; - for (ItemStack s1 : list) - if (s1.isItemEqual(s) && ItemStack.areItemStackTagsEqual(s1, s)) break addItem; - - itemsAddedThisPage.add(s); - list.add(s); - } - } - } - } - - list.addAll(extraDisplayedRecipes); - - return list; - } - - public void addExtraDisplayedRecipe(ItemStack stack) { - extraDisplayedRecipes.add(stack); - } - - @Override - public int compareTo(LexiconEntry o) { - return getNameForSorting().compareTo(o.getNameForSorting()); - } -} + public final String unlocalizedName; + public final LexiconCategory category; + + private KnowledgeType type = BotaniaAPI.basicKnowledge; + + public List pages = new ArrayList(); + private boolean priority = false; + private ItemStack icon = null; + + private List extraDisplayedRecipes = new ArrayList(); + + /** + * @param unlocalizedName The unlocalized name of this entry. This will be localized by the client display. + */ + public LexiconEntry(String unlocalizedName, LexiconCategory category) { + this.unlocalizedName = unlocalizedName; + this.category = category; + } + + /** + * Sets this page as prioritized, as in, will appear before others in the lexicon. + */ + public LexiconEntry setPriority() { + priority = true; + return this; + } + + /** + * Sets the Knowledge type of this entry. + */ + public LexiconEntry setKnowledgeType(KnowledgeType type) { + this.type = type; + return this; + } + + public KnowledgeType getKnowledgeType() { + return type; + } + + /** + * Sets the display icon for this entry. Overriding the one already there. When adding recipe pages to the + * entry, this will be called once for the result of the first found recipe. + */ + public void setIcon(ItemStack stack) { + icon = stack; + } + + public ItemStack getIcon() { + return icon; + } + + public boolean isPriority() { + return priority; + } + + public String getUnlocalizedName() { + return unlocalizedName; + } + + public String getTagline() { + return null; // Override this if you want a tagline. You probably do + } + + @SideOnly(Side.CLIENT) + public boolean isVisible() { + return true; + } + + /** + * Sets what pages you want this entry to have. + */ + public LexiconEntry setLexiconPages(LexiconPage... pages) { + this.pages.addAll(Arrays.asList(pages)); + + for(int i = 0; i < this.pages.size(); i++) { + LexiconPage page = this.pages.get(i); + if(!page.skipRegistry) + page.onPageAdded(this, i); + } + + return this; + } + + /** + * Returns the web link for this entry. If this isn't null, looking at this entry will + * show a "View Online" button in the book. The String returned should be the URL to + * open when the button is clicked. + */ + public String getWebLink() { + return null; + } + + /** + * Adds a page to the list of pages. + */ + public void addPage(LexiconPage page) { + pages.add(page); + } + + public final String getNameForSorting() { + return (priority ? 0 : 1) + StatCollector.translateToLocal(getUnlocalizedName()); + } + + public List getDisplayedRecipes() { + ArrayList list = new ArrayList(); + for(LexiconPage page : pages) { + List l = page.getDisplayedRecipes(); + + if(l != null) { + ArrayList itemsAddedThisPage = new ArrayList(); + + for(ItemStack s : l) { + addItem: { + for(ItemStack s1 : itemsAddedThisPage) + if(s1.getItem() == s.getItem()) + break addItem; + for(ItemStack s1 : list) + if(s1.isItemEqual(s) && ItemStack.areItemStackTagsEqual(s1, s)) + break addItem; + + itemsAddedThisPage.add(s); + list.add(s); + } + } + } + } + + list.addAll(extraDisplayedRecipes); + + return list; + } + + public void addExtraDisplayedRecipe(ItemStack stack) { + extraDisplayedRecipes.add(stack); + } + + @Override + public int compareTo(LexiconEntry o) { + return getNameForSorting().compareTo(o.getNameForSorting()); + } + +} \ No newline at end of file diff --git a/src/main/java/vazkii/botania/api/lexicon/LexiconPage.java b/src/main/java/vazkii/botania/api/lexicon/LexiconPage.java index 3c22b665cd..9880b9e9e9 100644 --- a/src/main/java/vazkii/botania/api/lexicon/LexiconPage.java +++ b/src/main/java/vazkii/botania/api/lexicon/LexiconPage.java @@ -2,111 +2,112 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jan 14, 2014, 6:17:24 PM (GMT)] */ package vazkii.botania.api.lexicon; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; import java.util.List; + import net.minecraft.client.gui.GuiButton; import net.minecraft.item.ItemStack; import vazkii.botania.api.internal.IGuiLexiconEntry; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; public abstract class LexiconPage { - public String unlocalizedName; - public boolean skipRegistry; - - public LexiconPage(String unlocalizedName) { - this.unlocalizedName = unlocalizedName; - } - - /** - * Does the rendering for this page. - * @param gui The active GuiScreen - * @param mx The mouse's relative X position. - * @param my The mouse's relative Y position. - */ - @SideOnly(Side.CLIENT) - public abstract void renderScreen(IGuiLexiconEntry gui, int mx, int my); - - /** - * Called per update tick. Non gui-sensitive version, kept for backwards compatibility only. - */ - @SideOnly(Side.CLIENT) - public void updateScreen() { - // NO-OP - } - - /** - * Called per update tick. Feel free to override fully, the - * call to updateScreen() is for backwards compatibility. - */ - @SideOnly(Side.CLIENT) - public void updateScreen(IGuiLexiconEntry gui) { - updateScreen(); - } - - /** - * Called when this page is opened, be it via initGui() or when the player changes page. - * You can add buttons and whatever you'd do on initGui() here. - */ - @SideOnly(Side.CLIENT) - public void onOpened(IGuiLexiconEntry gui) { - // NO-OP - } - - /** - * Called when this page is opened, be it via closing the gui or when the player changes page. - * Make sure to dispose of anything you don't use any more, such as buttons in the gui's buttonList. - */ - @SideOnly(Side.CLIENT) - public void onClosed(IGuiLexiconEntry gui) { - // NO-OP - } - - /** - * Called when a button is pressed, equivalent to GuiScreen.actionPerformed. - */ - @SideOnly(Side.CLIENT) - public void onActionPerformed(IGuiLexiconEntry gui, GuiButton button) { - // NO-OP - } - - /** - * Called when a key is pressed. - */ - @SideOnly(Side.CLIENT) - public void onKeyPressed(char c, int key) { - // NO-OP - } - - /** - * Called when {@link LexiconEntry#setLexiconPages(LexiconPage...)} is called. - */ - public void onPageAdded(LexiconEntry entry, int index) { - // NO-OP - } - - /** - * Shows the list of recipes present in this page for display in the category - * page. Can return null for an entry with no recipes. - */ - public List getDisplayedRecipes() { - return null; - } - - public String getUnlocalizedName() { - return unlocalizedName; - } - - public LexiconPage setSkipRegistry() { - skipRegistry = true; - return this; - } + public String unlocalizedName; + public boolean skipRegistry; + + public LexiconPage(String unlocalizedName) { + this.unlocalizedName = unlocalizedName; + } + + /** + * Does the rendering for this page. + * @param gui The active GuiScreen + * @param mx The mouse's relative X position. + * @param my The mouse's relative Y position. + */ + @SideOnly(Side.CLIENT) + public abstract void renderScreen(IGuiLexiconEntry gui, int mx, int my); + + /** + * Called per update tick. Non gui-sensitive version, kept for backwards compatibility only. + */ + @SideOnly(Side.CLIENT) + public void updateScreen() { + // NO-OP + } + + /** + * Called per update tick. Feel free to override fully, the + * call to updateScreen() is for backwards compatibility. + */ + @SideOnly(Side.CLIENT) + public void updateScreen(IGuiLexiconEntry gui) { + updateScreen(); + } + + /** + * Called when this page is opened, be it via initGui() or when the player changes page. + * You can add buttons and whatever you'd do on initGui() here. + */ + @SideOnly(Side.CLIENT) + public void onOpened(IGuiLexiconEntry gui) { + // NO-OP + } + + /** + * Called when this page is opened, be it via closing the gui or when the player changes page. + * Make sure to dispose of anything you don't use any more, such as buttons in the gui's buttonList. + */ + @SideOnly(Side.CLIENT) + public void onClosed(IGuiLexiconEntry gui) { + // NO-OP + } + + /** + * Called when a button is pressed, equivalent to GuiScreen.actionPerformed. + */ + @SideOnly(Side.CLIENT) + public void onActionPerformed(IGuiLexiconEntry gui, GuiButton button) { + // NO-OP + } + + /** + * Called when a key is pressed. + */ + @SideOnly(Side.CLIENT) + public void onKeyPressed(char c, int key) { + // NO-OP + } + + /** + * Called when {@link LexiconEntry#setLexiconPages(LexiconPage...)} is called. + */ + public void onPageAdded(LexiconEntry entry, int index) { + // NO-OP + } + + /** + * Shows the list of recipes present in this page for display in the category + * page. Can return null for an entry with no recipes. + */ + public List getDisplayedRecipes() { + return null; + } + + public String getUnlocalizedName() { + return unlocalizedName; + } + + public LexiconPage setSkipRegistry() { + skipRegistry = true; + return this; + } } diff --git a/src/main/java/vazkii/botania/api/lexicon/LexiconRecipeMappings.java b/src/main/java/vazkii/botania/api/lexicon/LexiconRecipeMappings.java index fa8a581e52..8202a40a79 100644 --- a/src/main/java/vazkii/botania/api/lexicon/LexiconRecipeMappings.java +++ b/src/main/java/vazkii/botania/api/lexicon/LexiconRecipeMappings.java @@ -2,16 +2,17 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Mar 6, 2014, 3:54:12 PM (GMT)] */ package vazkii.botania.api.lexicon; import java.util.HashMap; import java.util.Map; + import net.minecraft.item.ItemStack; import vazkii.botania.api.mana.IManaItem; @@ -22,52 +23,56 @@ */ public final class LexiconRecipeMappings { - private static Map mappings = new HashMap(); - - /** - * Maps the given stack to the given page of the entry. - */ - public static void map(ItemStack stack, LexiconEntry entry, int page, boolean force) { - EntryData data = new EntryData(entry, page); - String str = stackToString(stack); + private static Map mappings = new HashMap(); - if (force || !mappings.containsKey(str)) mappings.put(str, data); - if (entry.getIcon() == null) entry.setIcon(stack.copy()); - } + /** + * Maps the given stack to the given page of the entry. + */ + public static void map(ItemStack stack, LexiconEntry entry, int page, boolean force) { + EntryData data = new EntryData(entry, page); + String str = stackToString(stack); - public static void map(ItemStack stack, LexiconEntry entry, int page) { - map(stack, entry, page, false); - } + if(force || !mappings.containsKey(str)) + mappings.put(str, data); + if(entry.getIcon() == null) + entry.setIcon(stack.copy()); + } - public static void remove(ItemStack stack) { - mappings.remove(stackToString(stack)); - } + public static void map(ItemStack stack, LexiconEntry entry, int page) { + map(stack, entry, page, false); + } - public static EntryData getDataForStack(ItemStack stack) { - return mappings.get(stackToString(stack)); - } + public static void remove(ItemStack stack) { + mappings.remove(stackToString(stack)); + } - public static String stackToString(ItemStack stack) { - if (stack == null || stack.getItem() == null) return "NULL"; + public static EntryData getDataForStack(ItemStack stack) { + return mappings.get(stackToString(stack)); + } + + public static String stackToString(ItemStack stack) { + if(stack == null || stack.getItem() == null) + return "NULL"; + + if(stack.hasTagCompound() && stack.getItem() instanceof IRecipeKeyProvider) + return ((IRecipeKeyProvider) stack.getItem()).getKey(stack); - if (stack.hasTagCompound() && stack.getItem() instanceof IRecipeKeyProvider) - return ((IRecipeKeyProvider) stack.getItem()).getKey(stack); + return stack.getUnlocalizedName() + (ignoreMeta(stack) ? "" : "~" + stack.getItemDamage()); + } - return stack.getUnlocalizedName() + (ignoreMeta(stack) ? "" : "~" + stack.getItemDamage()); - } + public static boolean ignoreMeta(ItemStack stack) { + return stack.isItemStackDamageable() || stack.getItem() instanceof IManaItem; + } - public static boolean ignoreMeta(ItemStack stack) { - return stack.isItemStackDamageable() || stack.getItem() instanceof IManaItem; - } + public static class EntryData { - public static class EntryData { + public final LexiconEntry entry; + public final int page; - public final LexiconEntry entry; - public final int page; + public EntryData(LexiconEntry entry, int page) { + this.entry = entry; + this.page = page; + } - public EntryData(LexiconEntry entry, int page) { - this.entry = entry; - this.page = page; - } - } + } } diff --git a/src/main/java/vazkii/botania/api/lexicon/multiblock/IMultiblockRenderHook.java b/src/main/java/vazkii/botania/api/lexicon/multiblock/IMultiblockRenderHook.java index 0e20e5717d..9d05c40d94 100644 --- a/src/main/java/vazkii/botania/api/lexicon/multiblock/IMultiblockRenderHook.java +++ b/src/main/java/vazkii/botania/api/lexicon/multiblock/IMultiblockRenderHook.java @@ -2,16 +2,17 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jun 27, 2015, 7:48:47 PM (GMT)] */ package vazkii.botania.api.lexicon.multiblock; import java.util.HashMap; import java.util.Map; + import net.minecraft.block.Block; import net.minecraft.client.renderer.RenderBlocks; import net.minecraft.world.IBlockAccess; @@ -22,16 +23,10 @@ */ public interface IMultiblockRenderHook { - public static Map renderHooks = new HashMap(); + public static Map renderHooks = new HashMap(); + + public void renderBlockForMultiblock(IBlockAccess world, Multiblock mb, Block block, int meta, RenderBlocks renderBlocks, MultiblockComponent comp, float alpha); - public void renderBlockForMultiblock( - IBlockAccess world, - Multiblock mb, - Block block, - int meta, - RenderBlocks renderBlocks, - MultiblockComponent comp, - float alpha); + public boolean needsTranslate(Block block); - public boolean needsTranslate(Block block); } diff --git a/src/main/java/vazkii/botania/api/lexicon/multiblock/Multiblock.java b/src/main/java/vazkii/botania/api/lexicon/multiblock/Multiblock.java index 0e73930125..4cf34b8582 100644 --- a/src/main/java/vazkii/botania/api/lexicon/multiblock/Multiblock.java +++ b/src/main/java/vazkii/botania/api/lexicon/multiblock/Multiblock.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jun 27, 2015, 2:37:22 PM (GMT)] */ package vazkii.botania.api.lexicon.multiblock; @@ -14,6 +14,7 @@ import java.util.Arrays; import java.util.HashMap; import java.util.List; + import net.minecraft.block.Block; import net.minecraft.item.ItemStack; import net.minecraft.util.ChunkCoordinates; @@ -26,147 +27,162 @@ */ public class Multiblock { - public List components = new ArrayList(); - public List materials = new ArrayList(); - - public int minX, minY, minZ, maxX, maxY, maxZ, offX, offY, offZ; - - public HashMap, MultiblockComponent> locationCache = - new HashMap, MultiblockComponent>(); - - /** - * Adds a multiblock component to this multiblock. The component's x y z - * coords should be pivoted to the center of the structure. - */ - public void addComponent(MultiblockComponent component) { - if (getComponentForLocation(component.relPos.posX, component.relPos.posY, component.relPos.posZ) != null) - throw new IllegalArgumentException("Location in multiblock already occupied"); - components.add(component); - changeAxisForNewComponent(component.relPos.posX, component.relPos.posY, component.relPos.posZ); - calculateCostForNewComponent(component); - addComponentToLocationCache(component); - } - - /** - * Constructs and adds a multiblock component to this multiblock. The x y z - * coords should be pivoted to the center of the structure. - */ - public void addComponent(int x, int y, int z, Block block, int meta) { - addComponent(new MultiblockComponent(new ChunkCoordinates(x, y, z), block, meta)); - } - - private void changeAxisForNewComponent(int x, int y, int z) { - if (x < minX) minX = x; - else if (x > maxX) maxX = x; - - if (y < minY) minY = y; - else if (y > maxY) maxY = y; - - if (z < minZ) minZ = z; - else if (z > maxZ) maxZ = z; - } - - private void calculateCostForNewComponent(MultiblockComponent comp) { - ItemStack[] materials = comp.getMaterials(); - if (materials != null) for (ItemStack stack : materials) addStack(stack); - } - - private void addStack(ItemStack stack) { - if (stack == null) return; - - for (ItemStack oStack : materials) - if (oStack.isItemEqual(stack) && ItemStack.areItemStackTagsEqual(oStack, stack)) { - oStack.stackSize += stack.stackSize; - return; - } - - materials.add(stack); - } - - public void setRenderOffset(int x, int y, int z) { - offX = x; - offY = y; - offZ = z; - } - - public List getComponents() { - return components; - } - - /** - * Rotates this multiblock by the angle passed in. For the best results, use - * only multiples of pi/2. - */ - public void rotate(double angle) { - for (MultiblockComponent comp : getComponents()) comp.rotate(angle); - updateLocationCache(); - } - - public Multiblock copy() { - Multiblock mb = new Multiblock(); - for (MultiblockComponent comp : getComponents()) mb.addComponent(comp.copy()); - - return mb; - } - - /** - * Creates a length 4 array of all the rotations multiple of pi/2 required - * to render this multiblock in the world relevant to the 4 cardinal - * orientations. - */ - public Multiblock[] createRotations() { - Multiblock[] blocks = new Multiblock[4]; - blocks[0] = this; - blocks[1] = blocks[0].copy(); - blocks[1].rotate(Math.PI / 2); - blocks[2] = blocks[1].copy(); - blocks[2].rotate(Math.PI / 2); - blocks[3] = blocks[2].copy(); - blocks[3].rotate(Math.PI / 2); - - return blocks; - } - - /** - * Makes a MultiblockSet from this Multiblock and its rotations using - * createRotations(). - */ - public MultiblockSet makeSet() { - return new MultiblockSet(this); - } - - public int getXSize() { - return Math.abs(minX) + Math.abs(maxX) + 1; - } - - public int getYSize() { - return Math.abs(minY) + Math.abs(maxY) + 1; - } - - public int getZSize() { - return Math.abs(minZ) + Math.abs(maxZ) + 1; - } - - /** - * Rebuilds the location cache - */ - public void updateLocationCache() { - locationCache.clear(); - for (MultiblockComponent comp : components) addComponentToLocationCache(comp); - } - - /** - * Adds a single component to the location cache - */ - private void addComponentToLocationCache(MultiblockComponent comp) { - ChunkCoordinates pos = comp.getRelativePosition(); - locationCache.put(Arrays.asList(pos.posX, pos.posY, pos.posZ), comp); - } - - /** - * Gets the component for a given location - */ - public MultiblockComponent getComponentForLocation(int x, int y, int z) { - return locationCache.get(Arrays.asList(x, y, z)); - } + public List components = new ArrayList(); + public List materials = new ArrayList(); + + public int minX, minY, minZ, maxX, maxY, maxZ, offX, offY, offZ; + + public HashMap, MultiblockComponent> locationCache = new HashMap, MultiblockComponent>(); + + /** + * Adds a multiblock component to this multiblock. The component's x y z + * coords should be pivoted to the center of the structure. + */ + public void addComponent(MultiblockComponent component) { + if(getComponentForLocation(component.relPos.posX, component.relPos.posY, component.relPos.posZ) != null) + throw new IllegalArgumentException("Location in multiblock already occupied"); + components.add(component); + changeAxisForNewComponent(component.relPos.posX, component.relPos.posY, component.relPos.posZ); + calculateCostForNewComponent(component); + addComponentToLocationCache(component); + } + + /** + * Constructs and adds a multiblock component to this multiblock. The x y z + * coords should be pivoted to the center of the structure. + */ + public void addComponent(int x, int y, int z, Block block, int meta) { + addComponent(new MultiblockComponent(new ChunkCoordinates(x, y, z), block, meta)); + } + + private void changeAxisForNewComponent(int x, int y, int z) { + if(x < minX) + minX = x; + else if(x > maxX) + maxX = x; + + if(y < minY) + minY = y; + else if(y > maxY) + maxY = y; + + if(z < minZ) + minZ = z; + else if(z > maxZ) + maxZ = z; + } + + private void calculateCostForNewComponent(MultiblockComponent comp) { + ItemStack[] materials = comp.getMaterials(); + if(materials != null) + for(ItemStack stack : materials) + addStack(stack); + } + + private void addStack(ItemStack stack) { + if(stack == null) + return; + + for(ItemStack oStack : materials) + if(oStack.isItemEqual(stack) && ItemStack.areItemStackTagsEqual(oStack, stack)) { + oStack.stackSize += stack.stackSize; + return; + } + + materials.add(stack); + } + + public void setRenderOffset(int x, int y, int z) { + offX = x; + offY = y; + offZ = z; + } + + public List getComponents() { + return components; + } + + /** + * Rotates this multiblock by the angle passed in. For the best results, use + * only multiples of pi/2. + */ + public void rotate(double angle) { + for(MultiblockComponent comp : getComponents()) + comp.rotate(angle); + updateLocationCache(); + } + + public Multiblock copy() { + Multiblock mb = new Multiblock(); + for(MultiblockComponent comp : getComponents()) + mb.addComponent(comp.copy()); + + return mb; + } + + /** + * Creates a length 4 array of all the rotations multiple of pi/2 required + * to render this multiblock in the world relevant to the 4 cardinal + * orientations. + */ + public Multiblock[] createRotations() { + Multiblock[] blocks = new Multiblock[4]; + blocks[0] = this; + blocks[1] = blocks[0].copy(); + blocks[1].rotate(Math.PI / 2); + blocks[2] = blocks[1].copy(); + blocks[2].rotate(Math.PI / 2); + blocks[3] = blocks[2].copy(); + blocks[3].rotate(Math.PI / 2); + + return blocks; + } + + /** + * Makes a MultiblockSet from this Multiblock and its rotations using + * createRotations(). + */ + public MultiblockSet makeSet() { + return new MultiblockSet(this); + } + + public int getXSize() { + return Math.abs(minX) + Math.abs(maxX) + 1; + } + + public int getYSize() { + return Math.abs(minY) + Math.abs(maxY) + 1; + } + + public int getZSize() { + return Math.abs(minZ) + Math.abs(maxZ) + 1; + } + + /** + * Rebuilds the location cache + */ + public void updateLocationCache() { + locationCache.clear(); + for(MultiblockComponent comp : components) + addComponentToLocationCache(comp); + } + + /** + * Adds a single component to the location cache + */ + private void addComponentToLocationCache(MultiblockComponent comp) { + ChunkCoordinates pos = comp.getRelativePosition(); + locationCache.put(Arrays.asList( + pos.posX, + pos.posY, + pos.posZ + ), comp); + } + + /** + * Gets the component for a given location + */ + public MultiblockComponent getComponentForLocation(int x, int y, int z) { + return locationCache.get(Arrays.asList(x, y, z)); + } } diff --git a/src/main/java/vazkii/botania/api/lexicon/multiblock/MultiblockSet.java b/src/main/java/vazkii/botania/api/lexicon/multiblock/MultiblockSet.java index 1fb57345f7..c0435f81e1 100644 --- a/src/main/java/vazkii/botania/api/lexicon/multiblock/MultiblockSet.java +++ b/src/main/java/vazkii/botania/api/lexicon/multiblock/MultiblockSet.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jun 27, 2015, 7:31:58 PM (GMT)] */ package vazkii.botania.api.lexicon.multiblock; @@ -18,26 +18,26 @@ */ public class MultiblockSet { - private final Multiblock[] mbs; + private final Multiblock[] mbs; - public MultiblockSet(Multiblock[] mbs) { - this.mbs = mbs; - } + public MultiblockSet(Multiblock[] mbs) { + this.mbs = mbs; + } - public MultiblockSet(Multiblock mb) { - this(mb.createRotations()); - } + public MultiblockSet(Multiblock mb) { + this(mb.createRotations()); + } - public Multiblock getForEntity(Entity e) { - return getForRotation(e.rotationYaw); - } + public Multiblock getForEntity(Entity e) { + return getForRotation(e.rotationYaw); + } - public Multiblock getForRotation(double rotation) { - int facing = MathHelper.floor_double(rotation * 4.0 / 360.0 + 0.5) & 3; - return getForIndex(facing); - } + public Multiblock getForRotation(double rotation) { + int facing = MathHelper.floor_double(rotation * 4.0 / 360.0 + 0.5) & 3; + return getForIndex(facing); + } - public Multiblock getForIndex(int index) { - return mbs[Math.min(mbs.length - 1, index)]; - } + public Multiblock getForIndex(int index) { + return mbs[Math.min(mbs.length - 1, index)]; + } } diff --git a/src/main/java/vazkii/botania/api/lexicon/multiblock/component/AnyComponent.java b/src/main/java/vazkii/botania/api/lexicon/multiblock/component/AnyComponent.java index ac99056123..f7a159b20b 100644 --- a/src/main/java/vazkii/botania/api/lexicon/multiblock/component/AnyComponent.java +++ b/src/main/java/vazkii/botania/api/lexicon/multiblock/component/AnyComponent.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [01/11/2015, 19:05:57 (GMT)] */ package vazkii.botania.api.lexicon.multiblock.component; @@ -19,13 +19,14 @@ */ public class AnyComponent extends MultiblockComponent { - public AnyComponent(ChunkCoordinates relPos, Block block, int meta) { - super(relPos, block, meta); - } + public AnyComponent(ChunkCoordinates relPos, Block block, int meta) { + super(relPos, block, meta); + } + + @Override + public boolean matches(World world, int x, int y, int z) { + Block block = world.getBlock(x, y, z); + return !block.isAir(world, x, y, z) && block.getCollisionBoundingBoxFromPool(world, x, y, z) != null; + } - @Override - public boolean matches(World world, int x, int y, int z) { - Block block = world.getBlock(x, y, z); - return !block.isAir(world, x, y, z) && block.getCollisionBoundingBoxFromPool(world, x, y, z) != null; - } } diff --git a/src/main/java/vazkii/botania/api/lexicon/multiblock/component/ColorSwitchingComponent.java b/src/main/java/vazkii/botania/api/lexicon/multiblock/component/ColorSwitchingComponent.java index 1b083d36cf..27eb32ae2d 100644 --- a/src/main/java/vazkii/botania/api/lexicon/multiblock/component/ColorSwitchingComponent.java +++ b/src/main/java/vazkii/botania/api/lexicon/multiblock/component/ColorSwitchingComponent.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jun 27, 2015, 7:20:09 PM (GMT)] */ package vazkii.botania.api.lexicon.multiblock.component; @@ -21,22 +21,23 @@ */ public class ColorSwitchingComponent extends MultiblockComponent { - public ColorSwitchingComponent(ChunkCoordinates relPos, Block block) { - super(relPos, block, -1); - } + public ColorSwitchingComponent(ChunkCoordinates relPos, Block block) { + super(relPos, block, -1); + } - @Override - public int getMeta() { - return (int) (BotaniaAPI.internalHandler.getWorldElapsedTicks() / 20) % 16; - } + @Override + public int getMeta() { + return (int) (BotaniaAPI.internalHandler.getWorldElapsedTicks() / 20) % 16; + } - @Override - public boolean matches(World world, int x, int y, int z) { - return world.getBlock(x, y, z) == getBlock(); - } + @Override + public boolean matches(World world, int x, int y, int z) { + return world.getBlock(x, y, z) == getBlock(); + } + + @Override + public MultiblockComponent copy() { + return new ColorSwitchingComponent(relPos, block); + } - @Override - public MultiblockComponent copy() { - return new ColorSwitchingComponent(relPos, block); - } } diff --git a/src/main/java/vazkii/botania/api/lexicon/multiblock/component/FlowerComponent.java b/src/main/java/vazkii/botania/api/lexicon/multiblock/component/FlowerComponent.java index 979ac24258..8a4f0ad72b 100644 --- a/src/main/java/vazkii/botania/api/lexicon/multiblock/component/FlowerComponent.java +++ b/src/main/java/vazkii/botania/api/lexicon/multiblock/component/FlowerComponent.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jun 28, 2015, 3:23:15 PM (GMT)] */ package vazkii.botania.api.lexicon.multiblock.component; @@ -20,17 +20,18 @@ */ public class FlowerComponent extends ColorSwitchingComponent { - public FlowerComponent(ChunkCoordinates relPos, Block block) { - super(relPos, block); - } + public FlowerComponent(ChunkCoordinates relPos, Block block) { + super(relPos, block); + } - @Override - public boolean matches(World world, int x, int y, int z) { - return BotaniaAPI.internalHandler.isBotaniaFlower(world, x, y, z); - } + @Override + public boolean matches(World world, int x, int y, int z) { + return BotaniaAPI.internalHandler.isBotaniaFlower(world, x, y, z); + } + + @Override + public MultiblockComponent copy() { + return new FlowerComponent(relPos, block); + } - @Override - public MultiblockComponent copy() { - return new FlowerComponent(relPos, block); - } } diff --git a/src/main/java/vazkii/botania/api/lexicon/multiblock/component/MultiblockComponent.java b/src/main/java/vazkii/botania/api/lexicon/multiblock/component/MultiblockComponent.java index b1e98401f5..b1a7d895fa 100644 --- a/src/main/java/vazkii/botania/api/lexicon/multiblock/component/MultiblockComponent.java +++ b/src/main/java/vazkii/botania/api/lexicon/multiblock/component/MultiblockComponent.java @@ -2,21 +2,21 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jun 27, 2015, 2:42:32 PM (GMT)] */ package vazkii.botania.api.lexicon.multiblock.component; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; import net.minecraft.block.Block; import net.minecraft.item.ItemStack; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.ChunkCoordinates; import net.minecraft.world.World; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; /** * A component of a multiblock, the normal one @@ -24,74 +24,73 @@ */ public class MultiblockComponent { - public ChunkCoordinates relPos; - public final Block block; - public final int meta; - public final TileEntity tileEntity; - public boolean doFancyRender; - - public MultiblockComponent(ChunkCoordinates relPos, Block block, int meta) { - this(relPos, block, meta, null); - } - - public MultiblockComponent(ChunkCoordinates relPos, Block block, int meta, boolean doFancyRender) { - this(relPos, block, meta, doFancyRender, null); - } - - public MultiblockComponent(ChunkCoordinates relPos, Block block, int meta, TileEntity tileEntity) { - this(relPos, block, meta, block.hasTileEntity() == (tileEntity != null), tileEntity); - } - - public MultiblockComponent( - ChunkCoordinates relPos, Block block, int meta, boolean doFancyRender, TileEntity tileEntity) { - this.relPos = relPos; - this.block = block; - this.meta = meta; - this.tileEntity = tileEntity; - this.doFancyRender = doFancyRender; - } - - public ChunkCoordinates getRelativePosition() { - return relPos; - } - - public Block getBlock() { - return block; - } - - public int getMeta() { - return meta; - } - - public boolean matches(World world, int x, int y, int z) { - return world.getBlock(x, y, z) == getBlock() && (meta == -1 || world.getBlockMetadata(x, y, z) == meta); - } - - public ItemStack[] getMaterials() { - return new ItemStack[] {new ItemStack(block, 1, meta)}; - } - - public void rotate(double angle) { - double x = relPos.posX; - double z = relPos.posZ; - double sin = Math.sin(angle); - double cos = Math.cos(angle); - - double xn = x * cos - z * sin; - double zn = x * sin + z * cos; - relPos = new ChunkCoordinates((int) Math.round(xn), relPos.posY, (int) Math.round(zn)); - } - - public MultiblockComponent copy() { - return new MultiblockComponent(relPos, block, meta, tileEntity); - } - - public TileEntity getTileEntity() { - return tileEntity; - } - - @SideOnly(Side.CLIENT) - public boolean shouldDoFancyRender() { - return doFancyRender; - } + public ChunkCoordinates relPos; + public final Block block; + public final int meta; + public final TileEntity tileEntity; + public boolean doFancyRender; + + public MultiblockComponent(ChunkCoordinates relPos, Block block, int meta) { + this(relPos, block, meta, null); + } + + public MultiblockComponent(ChunkCoordinates relPos, Block block, int meta, boolean doFancyRender) { + this(relPos, block, meta, doFancyRender, null); + } + + public MultiblockComponent(ChunkCoordinates relPos, Block block, int meta, TileEntity tileEntity) { + this(relPos, block, meta, block.hasTileEntity() == (tileEntity != null), tileEntity); + } + + public MultiblockComponent(ChunkCoordinates relPos, Block block, int meta, boolean doFancyRender, TileEntity tileEntity) { + this.relPos = relPos; + this.block = block; + this.meta = meta; + this.tileEntity = tileEntity; + this.doFancyRender = doFancyRender; + } + + public ChunkCoordinates getRelativePosition() { + return relPos; + } + + public Block getBlock() { + return block; + } + + public int getMeta() { + return meta; + } + + public boolean matches(World world, int x, int y, int z) { + return world.getBlock(x, y, z) == getBlock() && (meta == -1 || world.getBlockMetadata(x, y, z) == meta); + } + + public ItemStack[] getMaterials() { + return new ItemStack[] { new ItemStack(block, 1, meta) }; + } + + public void rotate(double angle) { + double x = relPos.posX; + double z = relPos.posZ; + double sin = Math.sin(angle); + double cos = Math.cos(angle); + + double xn = x * cos - z * sin; + double zn = x * sin + z * cos; + relPos = new ChunkCoordinates((int) Math.round(xn), relPos.posY, (int) Math.round(zn)); + } + + public MultiblockComponent copy() { + return new MultiblockComponent(relPos, block, meta, tileEntity); + } + + public TileEntity getTileEntity() { + return tileEntity; + } + + @SideOnly(Side.CLIENT) + public boolean shouldDoFancyRender() { + return doFancyRender; + } } diff --git a/src/main/java/vazkii/botania/api/mana/BurstProperties.java b/src/main/java/vazkii/botania/api/mana/BurstProperties.java index 4d1f367e87..75ff0f8d2a 100644 --- a/src/main/java/vazkii/botania/api/mana/BurstProperties.java +++ b/src/main/java/vazkii/botania/api/mana/BurstProperties.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jan 31, 2014, 3:49:30 PM (GMT)] */ package vazkii.botania.api.mana; @@ -16,26 +16,21 @@ */ public final class BurstProperties { - public int maxMana; - public int ticksBeforeManaLoss; - public float manaLossPerTick; - public float gravity; - public float motionModifier; + public int maxMana; + public int ticksBeforeManaLoss; + public float manaLossPerTick; + public float gravity; + public float motionModifier; - public int color; + public int color; + + public BurstProperties(int maxMana, int ticksBeforeManaLoss, float manaLossPerTick, float gravity, float motionModifier, int color) { + this.maxMana = maxMana; + this.ticksBeforeManaLoss = ticksBeforeManaLoss; + this.manaLossPerTick = manaLossPerTick; + this.gravity = gravity; + this.motionModifier = motionModifier; + this.color = color; + } - public BurstProperties( - int maxMana, - int ticksBeforeManaLoss, - float manaLossPerTick, - float gravity, - float motionModifier, - int color) { - this.maxMana = maxMana; - this.ticksBeforeManaLoss = ticksBeforeManaLoss; - this.manaLossPerTick = manaLossPerTick; - this.gravity = gravity; - this.motionModifier = motionModifier; - this.color = color; - } } diff --git a/src/main/java/vazkii/botania/api/mana/IClientManaHandler.java b/src/main/java/vazkii/botania/api/mana/IClientManaHandler.java index 0cca7dbc7e..aea14b9e81 100644 --- a/src/main/java/vazkii/botania/api/mana/IClientManaHandler.java +++ b/src/main/java/vazkii/botania/api/mana/IClientManaHandler.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jul 2, 2014, 5:26:02 PM (GMT)] */ package vazkii.botania.api.mana; @@ -15,4 +15,6 @@ * called on both client and server. If this is not implemented * the call will only occur on the server. */ -public interface IClientManaHandler extends IManaReceiver {} +public interface IClientManaHandler extends IManaReceiver { + +} diff --git a/src/main/java/vazkii/botania/api/mana/ICompositableLens.java b/src/main/java/vazkii/botania/api/mana/ICompositableLens.java index 8d1deaaf24..775719d8d6 100644 --- a/src/main/java/vazkii/botania/api/mana/ICompositableLens.java +++ b/src/main/java/vazkii/botania/api/mana/ICompositableLens.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Nov 23, 2015, 10:30:34 AM (GMT)] */ package vazkii.botania.api.mana; @@ -17,13 +17,16 @@ */ public interface ICompositableLens extends ILens { - /** - * Returns the properties of the itemstack, used to check if two lenses can combine. - */ - public int getProps(ItemStack stack); + /** + * Returns the properties of the itemstack, used to check if two lenses can combine. + */ + public int getProps(ItemStack stack); + + /** + * Checks if the lens is combinable. + */ + public boolean isCombinable(ItemStack stack); - /** - * Checks if the lens is combinable. - */ - public boolean isCombinable(ItemStack stack); } + + diff --git a/src/main/java/vazkii/botania/api/mana/ICreativeManaProvider.java b/src/main/java/vazkii/botania/api/mana/ICreativeManaProvider.java index 15febc47b6..2556663c29 100644 --- a/src/main/java/vazkii/botania/api/mana/ICreativeManaProvider.java +++ b/src/main/java/vazkii/botania/api/mana/ICreativeManaProvider.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [May 25, 2014, 7:34:00 PM (GMT)] */ package vazkii.botania.api.mana; @@ -19,5 +19,7 @@ */ public interface ICreativeManaProvider { - public boolean isCreative(ItemStack stack); + public boolean isCreative(ItemStack stack); + } + diff --git a/src/main/java/vazkii/botania/api/mana/IDirectioned.java b/src/main/java/vazkii/botania/api/mana/IDirectioned.java index 374aa43f62..ff856f774d 100644 --- a/src/main/java/vazkii/botania/api/mana/IDirectioned.java +++ b/src/main/java/vazkii/botania/api/mana/IDirectioned.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [15/11/2015, 19:27:07 (GMT)] */ package vazkii.botania.api.mana; @@ -17,7 +17,8 @@ */ public interface IDirectioned { - public float getRotationX(); + public float getRotationX(); + + public float getRotationY(); - public float getRotationY(); } diff --git a/src/main/java/vazkii/botania/api/mana/IIdentifiable.java b/src/main/java/vazkii/botania/api/mana/IIdentifiable.java index 705cca1809..65f2edc028 100644 --- a/src/main/java/vazkii/botania/api/mana/IIdentifiable.java +++ b/src/main/java/vazkii/botania/api/mana/IIdentifiable.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jun 19, 2015, 10:05:24 PM (GMT)] */ package vazkii.botania.api.mana; @@ -18,5 +18,6 @@ */ public interface IIdentifiable { - public UUID getIdentifier(); + public UUID getIdentifier(); + } diff --git a/src/main/java/vazkii/botania/api/mana/IKeyLocked.java b/src/main/java/vazkii/botania/api/mana/IKeyLocked.java index 7db7dc75e8..ce71694e47 100644 --- a/src/main/java/vazkii/botania/api/mana/IKeyLocked.java +++ b/src/main/java/vazkii/botania/api/mana/IKeyLocked.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jul 11, 2014, 4:29:32 PM (GMT)] */ package vazkii.botania.api.mana; @@ -13,16 +13,17 @@ /** * A TileEntity that implements this interface has an IO key lock. This * interface defines an input and output key.

- * + * * A Spreader can only shoot mana into a IKeyLocked interfaced TE if the Input * key of the TE is equal to the Output key of the Spreader.

- * + * * A Spreader can only pull mana from a IKeyLocked interfaced IManaPool TE if the * Output key of the IManaPool is equal to the Input key of the Spreader. */ public interface IKeyLocked { - public String getInputKey(); + public String getInputKey(); + + public String getOutputKey(); - public String getOutputKey(); } diff --git a/src/main/java/vazkii/botania/api/mana/ILaputaImmobile.java b/src/main/java/vazkii/botania/api/mana/ILaputaImmobile.java index e2ea58a2bf..dfa2945134 100644 --- a/src/main/java/vazkii/botania/api/mana/ILaputaImmobile.java +++ b/src/main/java/vazkii/botania/api/mana/ILaputaImmobile.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jul 26, 2014, 9:51:58 PM (GMT)] */ package vazkii.botania.api.mana; @@ -17,5 +17,6 @@ */ public interface ILaputaImmobile { - public boolean canMove(World world, int x, int y, int z); + public boolean canMove(World world, int x, int y, int z); + } diff --git a/src/main/java/vazkii/botania/api/mana/ILens.java b/src/main/java/vazkii/botania/api/mana/ILens.java index 2f6cc7f802..d125e57295 100644 --- a/src/main/java/vazkii/botania/api/mana/ILens.java +++ b/src/main/java/vazkii/botania/api/mana/ILens.java @@ -2,40 +2,41 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jan 31, 2014, 3:03:04 PM (GMT)] */ package vazkii.botania.api.mana; +import net.minecraft.item.ItemStack; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; -import net.minecraft.item.ItemStack; /** * Have an Item implement this to be counted as a lens for the mana spreader. */ public interface ILens extends ILensEffect { - @SideOnly(Side.CLIENT) - public int getLensColor(ItemStack stack); + @SideOnly(Side.CLIENT) + public int getLensColor(ItemStack stack); + + /** + * Can the source lens be combined with the composite lens? This is called + * for both the ILens instance of ItemStack.getItem() of sourceLens and compositeLens. + */ + public boolean canCombineLenses(ItemStack sourceLens, ItemStack compositeLens); - /** - * Can the source lens be combined with the composite lens? This is called - * for both the ILens instance of ItemStack.getItem() of sourceLens and compositeLens. - */ - public boolean canCombineLenses(ItemStack sourceLens, ItemStack compositeLens); + /** + * Gets the composite lens in the stack passed in, return null for none. + */ + public ItemStack getCompositeLens(ItemStack stack); - /** - * Gets the composite lens in the stack passed in, return null for none. - */ - public ItemStack getCompositeLens(ItemStack stack); + /** + * Sets the composite lens for the sourceLens as the compositeLens, returns + * the ItemStack with the combination. + */ + public ItemStack setCompositeLens(ItemStack sourceLens, ItemStack compositeLens); - /** - * Sets the composite lens for the sourceLens as the compositeLens, returns - * the ItemStack with the combination. - */ - public ItemStack setCompositeLens(ItemStack sourceLens, ItemStack compositeLens); } diff --git a/src/main/java/vazkii/botania/api/mana/ILensControl.java b/src/main/java/vazkii/botania/api/mana/ILensControl.java index ad1e946f3c..ad0cc6c693 100644 --- a/src/main/java/vazkii/botania/api/mana/ILensControl.java +++ b/src/main/java/vazkii/botania/api/mana/ILensControl.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [15/11/2015, 21:00:32 (GMT)] */ package vazkii.botania.api.mana; @@ -18,17 +18,18 @@ */ public interface ILensControl extends ILens { - public boolean isControlLens(ItemStack stack); + public boolean isControlLens(ItemStack stack); - public boolean allowBurstShooting(ItemStack stack, IManaSpreader spreader, boolean redstone); + public boolean allowBurstShooting(ItemStack stack, IManaSpreader spreader, boolean redstone); - /** - * Used for the tick of a non-redstone spreader. - */ - public void onControlledSpreaderTick(ItemStack stack, IManaSpreader spreader, boolean redstone); + /** + * Used for the tick of a non-redstone spreader. + */ + public void onControlledSpreaderTick(ItemStack stack, IManaSpreader spreader, boolean redstone); + + /** + * Used for when a redstone spreader gets a pulse. + */ + public void onControlledSpreaderPulse(ItemStack stack, IManaSpreader spreader, boolean redstone); - /** - * Used for when a redstone spreader gets a pulse. - */ - public void onControlledSpreaderPulse(ItemStack stack, IManaSpreader spreader, boolean redstone); } diff --git a/src/main/java/vazkii/botania/api/mana/ILensEffect.java b/src/main/java/vazkii/botania/api/mana/ILensEffect.java index 790ccea8bf..4c88f55241 100644 --- a/src/main/java/vazkii/botania/api/mana/ILensEffect.java +++ b/src/main/java/vazkii/botania/api/mana/ILensEffect.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Apr 14, 2014, 7:30:00 PM (GMT)] */ package vazkii.botania.api.mana; @@ -20,29 +20,29 @@ */ public interface ILensEffect { - /** - * Called when a mana spreader that has this focus shoots a burst. This is where - * you change the properties of the burst. - */ - public void apply(ItemStack stack, BurstProperties props); + /** + * Called when a mana spreader that has this focus shoots a burst. This is where + * you change the properties of the burst. + */ + public void apply(ItemStack stack, BurstProperties props); - /** - * Called when a mana burst fired from a mana spreader with this focus collides against - * any block. This is called after the collision is handled. - * @return True to kill the burst. False to keep it alive. - */ - public boolean collideBurst( - IManaBurst burst, MovingObjectPosition pos, boolean isManaBlock, boolean dead, ItemStack stack); + /** + * Called when a mana burst fired from a mana spreader with this focus collides against + * any block. This is called after the collision is handled. + * @return True to kill the burst. False to keep it alive. + */ + public boolean collideBurst(IManaBurst burst, MovingObjectPosition pos, boolean isManaBlock, boolean dead, ItemStack stack); - /** - * Called when a mana burst fired from a mana spreader with this focus is updated. - * This is called before the update is handled. - */ - public void updateBurst(IManaBurst burst, ItemStack stack); + /** + * Called when a mana burst fired from a mana spreader with this focus is updated. + * This is called before the update is handled. + */ + public void updateBurst(IManaBurst burst, ItemStack stack); + + /** + * Called when the mana burst should do it's particles. Return false to not + * do any particles. + */ + public boolean doParticles(IManaBurst burst, ItemStack stack); - /** - * Called when the mana burst should do it's particles. Return false to not - * do any particles. - */ - public boolean doParticles(IManaBurst burst, ItemStack stack); } diff --git a/src/main/java/vazkii/botania/api/mana/IManaBlock.java b/src/main/java/vazkii/botania/api/mana/IManaBlock.java index 0db24c9998..56aa037c75 100644 --- a/src/main/java/vazkii/botania/api/mana/IManaBlock.java +++ b/src/main/java/vazkii/botania/api/mana/IManaBlock.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jan 22, 2014, 4:59:05 PM (GMT)] */ package vazkii.botania.api.mana; @@ -17,8 +17,9 @@ */ public interface IManaBlock { - /** - * Gets the amount of mana currently in this block. - */ - public int getCurrentMana(); + /** + * Gets the amount of mana currently in this block. + */ + public int getCurrentMana(); + } diff --git a/src/main/java/vazkii/botania/api/mana/IManaCollector.java b/src/main/java/vazkii/botania/api/mana/IManaCollector.java index 772d0ddd1e..280e46007e 100644 --- a/src/main/java/vazkii/botania/api/mana/IManaCollector.java +++ b/src/main/java/vazkii/botania/api/mana/IManaCollector.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jan 22, 2014, 5:01:19 PM (GMT)] */ package vazkii.botania.api.mana; @@ -15,27 +15,28 @@ /** * Any TileEntity that implements this is considered a mana collector, by * which nearby generating flowers will pump mana into it.

- * + * * Implementation Instructions:
* - Override invalidate() and onChunkUnload(), calling ManaNetworkEvent.removeCollector(this); on both.
* - On the first tick of onUpdate(), call ManaNetworkEvent.addCollector(this); */ public interface IManaCollector extends IManaReceiver { - /** - * Called every tick on the client case the player is holding a Wand of the Forest. - */ - public void onClientDisplayTick(); + /** + * Called every tick on the client case the player is holding a Wand of the Forest. + */ + public void onClientDisplayTick(); - /** - * Get the multiplier of mana to input into the block, 1.0 is the original amount of mana - * in the burst. 0.9, for example, is 90%, so 10% of the mana in the burst will get - * dissipated. - */ - public float getManaYieldMultiplier(IManaBurst burst); + /** + * Get the multiplier of mana to input into the block, 1.0 is the original amount of mana + * in the burst. 0.9, for example, is 90%, so 10% of the mana in the burst will get + * dissipated. + */ + public float getManaYieldMultiplier(IManaBurst burst); + + /** + * Gets the maximum amount of mana this collector can have. + */ + public int getMaxMana(); - /** - * Gets the maximum amount of mana this collector can have. - */ - public int getMaxMana(); } diff --git a/src/main/java/vazkii/botania/api/mana/IManaCollisionGhost.java b/src/main/java/vazkii/botania/api/mana/IManaCollisionGhost.java index 2cdf1399f4..76b537ed1c 100644 --- a/src/main/java/vazkii/botania/api/mana/IManaCollisionGhost.java +++ b/src/main/java/vazkii/botania/api/mana/IManaCollisionGhost.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Mar 10, 2014, 7:49:19 PM (GMT)] */ package vazkii.botania.api.mana; @@ -16,5 +16,6 @@ */ public interface IManaCollisionGhost { - public boolean isGhost(); + public boolean isGhost(); + } diff --git a/src/main/java/vazkii/botania/api/mana/IManaDiscountArmor.java b/src/main/java/vazkii/botania/api/mana/IManaDiscountArmor.java index 3aa1128b17..56a9683f98 100644 --- a/src/main/java/vazkii/botania/api/mana/IManaDiscountArmor.java +++ b/src/main/java/vazkii/botania/api/mana/IManaDiscountArmor.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jan 28, 2015, 9:22:53 PM (GMT)] */ package vazkii.botania.api.mana; @@ -20,11 +20,12 @@ */ public interface IManaDiscountArmor { - /** - * Gets the mana discount that this piece of armor provides. This is added - * together to create the full discount. - * Value is to be from 0.0 to 1.0. 0.1 is 10% discount, as an example. - * You can also return negative values to make tools cost more. - */ - public float getDiscount(ItemStack stack, int slot, EntityPlayer player); + /** + * Gets the mana discount that this piece of armor provides. This is added + * together to create the full discount. + * Value is to be from 0.0 to 1.0. 0.1 is 10% discount, as an example. + * You can also return negative values to make tools cost more. + */ + public float getDiscount(ItemStack stack, int slot, EntityPlayer player); + } diff --git a/src/main/java/vazkii/botania/api/mana/IManaGivingItem.java b/src/main/java/vazkii/botania/api/mana/IManaGivingItem.java index 4e7f414a08..a1d7f04d9f 100644 --- a/src/main/java/vazkii/botania/api/mana/IManaGivingItem.java +++ b/src/main/java/vazkii/botania/api/mana/IManaGivingItem.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [08/12/2015, 18:10:29 (GMT)] */ package vazkii.botania.api.mana; @@ -15,4 +15,6 @@ * This is used in botania for the terra shatterer to not be constantly * receiving mana from these items.. */ -public interface IManaGivingItem {} +public interface IManaGivingItem { + +} diff --git a/src/main/java/vazkii/botania/api/mana/IManaItem.java b/src/main/java/vazkii/botania/api/mana/IManaItem.java index f507d81687..f4463fb1df 100644 --- a/src/main/java/vazkii/botania/api/mana/IManaItem.java +++ b/src/main/java/vazkii/botania/api/mana/IManaItem.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Mar 6, 2014, 9:07:40 AM (GMT)] */ package vazkii.botania.api.mana; @@ -19,49 +19,50 @@ */ public interface IManaItem { - /** - * Gets the amount of mana this item contains - */ - public int getMana(ItemStack stack); + /** + * Gets the amount of mana this item contains + */ + public int getMana(ItemStack stack); - /** - * Gets the max amount of mana this item can hold. - */ - public int getMaxMana(ItemStack stack); + /** + * Gets the max amount of mana this item can hold. + */ + public int getMaxMana(ItemStack stack); - /** - * Adds mana to this item. - */ - public void addMana(ItemStack stack, int mana); + /** + * Adds mana to this item. + */ + public void addMana(ItemStack stack, int mana); - /** - * Can this item receive mana from a mana Pool? - * @param pool The pool it's receiving mana from, can be casted to IManaPool. - * @see IManaPool#isOutputtingPower() - */ - public boolean canReceiveManaFromPool(ItemStack stack, TileEntity pool); + /** + * Can this item receive mana from a mana Pool? + * @param pool The pool it's receiving mana from, can be casted to IManaPool. + * @see IManaPool#isOutputtingPower() + */ + public boolean canReceiveManaFromPool(ItemStack stack, TileEntity pool); - /** - * Can this item recieve mana from another item? - */ - public boolean canReceiveManaFromItem(ItemStack stack, ItemStack otherStack); + /** + * Can this item recieve mana from another item? + */ + public boolean canReceiveManaFromItem(ItemStack stack, ItemStack otherStack); - /** - * Can this item export mana to a mana Pool? - * @param pool The pool it's exporting mana to, can be casted to IManaPool. - * @see IManaPool#isOutputtingPower() - */ - public boolean canExportManaToPool(ItemStack stack, TileEntity pool); + /** + * Can this item export mana to a mana Pool? + * @param pool The pool it's exporting mana to, can be casted to IManaPool. + * @see IManaPool#isOutputtingPower() + */ + public boolean canExportManaToPool(ItemStack stack,TileEntity pool); - /** - * Can this item export mana to another item? - */ - public boolean canExportManaToItem(ItemStack stack, ItemStack otherStack); + /** + * Can this item export mana to another item? + */ + public boolean canExportManaToItem(ItemStack stack, ItemStack otherStack); + + /** + * If this item simply does not export mana at all, set this to true. This is + * used to skip items that contain mana but can't export it when drawing the + * mana bar above the XP bar. + */ + public boolean isNoExport(ItemStack stack); - /** - * If this item simply does not export mana at all, set this to true. This is - * used to skip items that contain mana but can't export it when drawing the - * mana bar above the XP bar. - */ - public boolean isNoExport(ItemStack stack); } diff --git a/src/main/java/vazkii/botania/api/mana/IManaPool.java b/src/main/java/vazkii/botania/api/mana/IManaPool.java index fa0e1b5b8f..df523a62c7 100644 --- a/src/main/java/vazkii/botania/api/mana/IManaPool.java +++ b/src/main/java/vazkii/botania/api/mana/IManaPool.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jan 22, 2014, 5:03:09 PM (GMT)] */ package vazkii.botania.api.mana; @@ -14,16 +14,17 @@ * Any TileEntity that implements this is considered a Mana Pool, * by which nearby functional flowers will pull mana from it.
* Mana Distributors will also accept it as valid output.

- * + * * Implementation Instructions:
* - Override invalidate() and onChunkUnload(), calling ManaNetworkEvent.removePool(this); on both.
* - On the first tick of onUpdate(), call ManaNetworkEvent.addPool(this); */ public interface IManaPool extends IManaReceiver { - /** - * Returns false if the mana pool is accepting power from other power items, - * true if it's sending power into them. - */ - public boolean isOutputtingPower(); + /** + * Returns false if the mana pool is accepting power from other power items, + * true if it's sending power into them. + */ + public boolean isOutputtingPower(); + } diff --git a/src/main/java/vazkii/botania/api/mana/IManaReceiver.java b/src/main/java/vazkii/botania/api/mana/IManaReceiver.java index 37b9c0c3fe..178856fad2 100644 --- a/src/main/java/vazkii/botania/api/mana/IManaReceiver.java +++ b/src/main/java/vazkii/botania/api/mana/IManaReceiver.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jan 22, 2014, 4:55:00 PM (GMT)] */ package vazkii.botania.api.mana; @@ -15,19 +15,20 @@ */ public interface IManaReceiver extends IManaBlock { - /** - * Is this Mana Receiver is full? Being full means no mana bursts will be sent. - */ - public boolean isFull(); + /** + * Is this Mana Receiver is full? Being full means no mana bursts will be sent. + */ + public boolean isFull(); - /** - * Called when this receiver receives mana. - */ - public void recieveMana(int mana); + /** + * Called when this receiver receives mana. + */ + public void recieveMana(int mana); + + /** + * Can this tile receive mana from bursts? Generally set to false for + * implementations of IManaCollector. + */ + public boolean canRecieveManaFromBursts(); - /** - * Can this tile receive mana from bursts? Generally set to false for - * implementations of IManaCollector. - */ - public boolean canRecieveManaFromBursts(); } diff --git a/src/main/java/vazkii/botania/api/mana/IManaSpreader.java b/src/main/java/vazkii/botania/api/mana/IManaSpreader.java index 0bb57d1560..61b9f8e32c 100644 --- a/src/main/java/vazkii/botania/api/mana/IManaSpreader.java +++ b/src/main/java/vazkii/botania/api/mana/IManaSpreader.java @@ -2,27 +2,29 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Apr 18, 2015, 7:30:00 PM (GMT)] */ package vazkii.botania.api.mana; + /** * Any TileEntity that implements this is considered a Mana Spreader, * by which can fire mana bursts as a spreader. */ public interface IManaSpreader extends IManaBlock, IPingable, IDirectioned { - public void setCanShoot(boolean canShoot); + public void setCanShoot(boolean canShoot); + + public int getBurstParticleTick(); - public int getBurstParticleTick(); + public void setBurstParticleTick(int i); - public void setBurstParticleTick(int i); + public int getLastBurstDeathTick(); - public int getLastBurstDeathTick(); + public void setLastBurstDeathTick(int ticksExisted); - public void setLastBurstDeathTick(int ticksExisted); } diff --git a/src/main/java/vazkii/botania/api/mana/IManaTooltipDisplay.java b/src/main/java/vazkii/botania/api/mana/IManaTooltipDisplay.java index 7f1c79fb6f..21de4740e8 100644 --- a/src/main/java/vazkii/botania/api/mana/IManaTooltipDisplay.java +++ b/src/main/java/vazkii/botania/api/mana/IManaTooltipDisplay.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Oct 23, 2015, 3:54:03 PM (GMT)] */ package vazkii.botania.api.mana; @@ -18,8 +18,9 @@ */ public interface IManaTooltipDisplay { - /** - * Returns the fraction of mana in this item for display. From 0 to 1 (exclusive). - */ - public float getManaFractionForDisplay(ItemStack stack); + /** + * Returns the fraction of mana in this item for display. From 0 to 1 (exclusive). + */ + public float getManaFractionForDisplay(ItemStack stack); + } diff --git a/src/main/java/vazkii/botania/api/mana/IManaTrigger.java b/src/main/java/vazkii/botania/api/mana/IManaTrigger.java index 6b26afba4d..61aadfcaad 100644 --- a/src/main/java/vazkii/botania/api/mana/IManaTrigger.java +++ b/src/main/java/vazkii/botania/api/mana/IManaTrigger.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [May 16, 2014, 7:52:53 PM (GMT)] */ package vazkii.botania.api.mana; @@ -18,5 +18,6 @@ */ public interface IManaTrigger { - public void onBurstCollision(IManaBurst burst, World world, int x, int y, int z); + public void onBurstCollision(IManaBurst burst, World world, int x, int y, int z); + } diff --git a/src/main/java/vazkii/botania/api/mana/IManaUsingItem.java b/src/main/java/vazkii/botania/api/mana/IManaUsingItem.java index ddf1a23200..9fe55fc464 100644 --- a/src/main/java/vazkii/botania/api/mana/IManaUsingItem.java +++ b/src/main/java/vazkii/botania/api/mana/IManaUsingItem.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [May 25, 2014, 7:32:10 PM (GMT)] */ package vazkii.botania.api.mana; @@ -20,5 +20,6 @@ */ public interface IManaUsingItem { - public boolean usesMana(ItemStack stack); + public boolean usesMana(ItemStack stack); + } diff --git a/src/main/java/vazkii/botania/api/mana/IPingable.java b/src/main/java/vazkii/botania/api/mana/IPingable.java index a52ab3b83b..1605b428e2 100644 --- a/src/main/java/vazkii/botania/api/mana/IPingable.java +++ b/src/main/java/vazkii/botania/api/mana/IPingable.java @@ -2,15 +2,16 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jun 19, 2015, 9:52:05 PM (GMT)] */ package vazkii.botania.api.mana; import java.util.UUID; + import vazkii.botania.api.internal.IManaBurst; /** @@ -19,11 +20,12 @@ */ public interface IPingable extends IIdentifiable { - /** - * Pings this object back, telling it that the burst passed in is still alive - * in the world. The UUID parameter should be the UUID with which the burst - * was created, this is used to let the object handle the check for if it's the - * correct ID internally. IManaBurst implementations should do this every tick. - */ - public void pingback(IManaBurst burst, UUID expectedIdentity); + /** + * Pings this object back, telling it that the burst passed in is still alive + * in the world. The UUID parameter should be the UUID with which the burst + * was created, this is used to let the object handle the check for if it's the + * correct ID internally. IManaBurst implementations should do this every tick. + */ + public void pingback(IManaBurst burst, UUID expectedIdentity); + } diff --git a/src/main/java/vazkii/botania/api/mana/IPoolOverlayProvider.java b/src/main/java/vazkii/botania/api/mana/IPoolOverlayProvider.java index 8ab53220a1..e443e2c1b7 100644 --- a/src/main/java/vazkii/botania/api/mana/IPoolOverlayProvider.java +++ b/src/main/java/vazkii/botania/api/mana/IPoolOverlayProvider.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jul 2, 2014, 6:36:54 PM (GMT)] */ package vazkii.botania.api.mana; @@ -20,5 +20,6 @@ */ public interface IPoolOverlayProvider { - public IIcon getIcon(World world, int x, int y, int z); + public IIcon getIcon(World world, int x, int y, int z); + } diff --git a/src/main/java/vazkii/botania/api/mana/IRedirectable.java b/src/main/java/vazkii/botania/api/mana/IRedirectable.java index 2f484d674a..00a1b6aa79 100644 --- a/src/main/java/vazkii/botania/api/mana/IRedirectable.java +++ b/src/main/java/vazkii/botania/api/mana/IRedirectable.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [15/11/2015, 19:28:18 (GMT)] */ package vazkii.botania.api.mana; @@ -17,13 +17,13 @@ */ public interface IRedirectable extends IDirectioned { - public void setRotationX(float rot); + public void setRotationX(float rot); - public void setRotationY(float rot); + public void setRotationY(float rot); - /** - * This should be called after rotation setting is done to allow - * for the block to re-calculate. - */ - public void commitRedirection(); + /** + * This should be called after rotation setting is done to allow + * for the block to re-calculate. + */ + public void commitRedirection(); } diff --git a/src/main/java/vazkii/botania/api/mana/IThrottledPacket.java b/src/main/java/vazkii/botania/api/mana/IThrottledPacket.java index 72f6c6649d..ff760bed0d 100644 --- a/src/main/java/vazkii/botania/api/mana/IThrottledPacket.java +++ b/src/main/java/vazkii/botania/api/mana/IThrottledPacket.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Apr 12, 2015, 3:08:09 PM (GMT)] */ package vazkii.botania.api.mana; @@ -17,5 +17,6 @@ */ public interface IThrottledPacket { - public void markDispatchable(); + public void markDispatchable(); + } diff --git a/src/main/java/vazkii/botania/api/mana/ITinyPlanetExcempt.java b/src/main/java/vazkii/botania/api/mana/ITinyPlanetExcempt.java index a96226a490..a82114c3af 100644 --- a/src/main/java/vazkii/botania/api/mana/ITinyPlanetExcempt.java +++ b/src/main/java/vazkii/botania/api/mana/ITinyPlanetExcempt.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jul 22, 2014, 2:26:14 PM (GMT)] */ package vazkii.botania.api.mana; @@ -18,5 +18,6 @@ */ public interface ITinyPlanetExcempt { - public boolean shouldPull(ItemStack stack); + public boolean shouldPull(ItemStack stack); + } diff --git a/src/main/java/vazkii/botania/api/mana/ManaItemHandler.java b/src/main/java/vazkii/botania/api/mana/ManaItemHandler.java index 82dcbf12e4..d261d55038 100644 --- a/src/main/java/vazkii/botania/api/mana/ManaItemHandler.java +++ b/src/main/java/vazkii/botania/api/mana/ManaItemHandler.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Mar 13, 2014, 5:32:24 PM (GMT)] */ package vazkii.botania.api.mana; @@ -17,224 +17,239 @@ public final class ManaItemHandler { - /** - * Requests mana from items in a given player's inventory. - * @param manaToGet How much mana is to be requested, if less mana exists than this amount, - * the amount of mana existent will be returned instead, if you want exact values use requestManaExact. - * @param remove If true, the mana will be removed from the target item. Set to false to just check. - * @return The amount of mana received from the request. - */ - public static int requestMana(ItemStack stack, EntityPlayer player, int manaToGet, boolean remove) { - if (stack == null) return 0; - - IInventory mainInv = player.inventory; - IInventory baublesInv = BotaniaAPI.internalHandler.getBaublesInventory(player); - - int invSize = mainInv.getSizeInventory(); - int size = invSize; - if (baublesInv != null) size += baublesInv.getSizeInventory(); - - for (int i = 0; i < size; i++) { - boolean useBaubles = i >= invSize; - IInventory inv = useBaubles ? baublesInv : mainInv; - int slot = i - (useBaubles ? invSize : 0); - ItemStack stackInSlot = inv.getStackInSlot(slot); - if (stackInSlot == stack) continue; - - if (stackInSlot != null && stackInSlot.getItem() instanceof IManaItem) { - IManaItem manaItem = (IManaItem) stackInSlot.getItem(); - if (manaItem.canExportManaToItem(stackInSlot, stack) && manaItem.getMana(stackInSlot) > 0) { - if (stack.getItem() instanceof IManaItem - && !((IManaItem) stack.getItem()).canReceiveManaFromItem(stack, stackInSlot)) continue; - - int mana = Math.min(manaToGet, manaItem.getMana(stackInSlot)); - - if (remove) manaItem.addMana(stackInSlot, -mana); - if (useBaubles) BotaniaAPI.internalHandler.sendBaubleUpdatePacket(player, slot); - - return mana; - } - } - } - - return 0; - } - - /** - * Requests an exact amount of mana from items in a given player's inventory. - * @param manaToGet How much mana is to be requested, if less mana exists than this amount, - * false will be returned instead, and nothing will happen. - * @param remove If true, the mana will be removed from the target item. Set to false to just check. - * @return If the request was succesful. - */ - public static boolean requestManaExact(ItemStack stack, EntityPlayer player, int manaToGet, boolean remove) { - if (stack == null) return false; - - IInventory mainInv = player.inventory; - IInventory baublesInv = BotaniaAPI.internalHandler.getBaublesInventory(player); - - int invSize = mainInv.getSizeInventory(); - int size = invSize; - if (baublesInv != null) size += baublesInv.getSizeInventory(); - - for (int i = 0; i < size; i++) { - boolean useBaubles = i >= invSize; - IInventory inv = useBaubles ? baublesInv : mainInv; - int slot = i - (useBaubles ? invSize : 0); - ItemStack stackInSlot = inv.getStackInSlot(slot); - if (stackInSlot == stack) continue; - - if (stackInSlot != null && stackInSlot.getItem() instanceof IManaItem) { - IManaItem manaItemSlot = (IManaItem) stackInSlot.getItem(); - if (manaItemSlot.canExportManaToItem(stackInSlot, stack) - && manaItemSlot.getMana(stackInSlot) > manaToGet) { - if (stack.getItem() instanceof IManaItem - && !((IManaItem) stack.getItem()).canReceiveManaFromItem(stack, stackInSlot)) continue; - - if (remove) manaItemSlot.addMana(stackInSlot, -manaToGet); - if (useBaubles) BotaniaAPI.internalHandler.sendBaubleUpdatePacket(player, slot); - - return true; - } - } - } - - return false; - } - - /** - * Dispatches mana to items in a given player's inventory. Note that this method - * does not automatically remove mana from the item which is exporting. - * @param manaToSend How much mana is to be sent. - * @param remove If true, the mana will be added from the target item. Set to false to just check. - * @return The amount of mana actually sent. - */ - public static int dispatchMana(ItemStack stack, EntityPlayer player, int manaToSend, boolean add) { - if (stack == null) return 0; - - IInventory mainInv = player.inventory; - IInventory baublesInv = BotaniaAPI.internalHandler.getBaublesInventory(player); - - int invSize = mainInv.getSizeInventory(); - int size = invSize; - if (baublesInv != null) size += baublesInv.getSizeInventory(); - - for (int i = 0; i < size; i++) { - boolean useBaubles = i >= invSize; - IInventory inv = useBaubles ? baublesInv : mainInv; - int slot = i - (useBaubles ? invSize : 0); - ItemStack stackInSlot = inv.getStackInSlot(slot); - if (stackInSlot == stack) continue; - - if (stackInSlot != null && stackInSlot.getItem() instanceof IManaItem) { - IManaItem manaItemSlot = (IManaItem) stackInSlot.getItem(); - - if (manaItemSlot.canReceiveManaFromItem(stackInSlot, stack)) { - if (stack.getItem() instanceof IManaItem - && !((IManaItem) stack.getItem()).canExportManaToItem(stack, stackInSlot)) continue; - - int received = 0; - if (manaItemSlot.getMana(stackInSlot) + manaToSend <= manaItemSlot.getMaxMana(stackInSlot)) - received = manaToSend; - else - received = manaToSend - - (manaItemSlot.getMana(stackInSlot) - + manaToSend - - manaItemSlot.getMaxMana(stackInSlot)); - - if (add) manaItemSlot.addMana(stackInSlot, manaToSend); - if (useBaubles) BotaniaAPI.internalHandler.sendBaubleUpdatePacket(player, slot); - - return received; - } - } - } - - return 0; - } - - /** - * Dispatches an exact amount of mana to items in a given player's inventory. Note that this method - * does not automatically remove mana from the item which is exporting. - * @param manaToSend How much mana is to be sent. - * @param remove If true, the mana will be added from the target item. Set to false to just check. - * @return If an item received the mana sent. - */ - public static boolean dispatchManaExact(ItemStack stack, EntityPlayer player, int manaToSend, boolean add) { - if (stack == null) return false; - - IInventory mainInv = player.inventory; - IInventory baublesInv = BotaniaAPI.internalHandler.getBaublesInventory(player); - - int invSize = mainInv.getSizeInventory(); - int size = invSize; - if (baublesInv != null) size += baublesInv.getSizeInventory(); - - for (int i = 0; i < size; i++) { - boolean useBaubles = i >= invSize; - IInventory inv = useBaubles ? baublesInv : mainInv; - int slot = i - (useBaubles ? invSize : 0); - ItemStack stackInSlot = inv.getStackInSlot(slot); - if (stackInSlot == stack) continue; - - if (stackInSlot != null && stackInSlot.getItem() instanceof IManaItem) { - IManaItem manaItemSlot = (IManaItem) stackInSlot.getItem(); - if (manaItemSlot.getMana(stackInSlot) + manaToSend <= manaItemSlot.getMaxMana(stackInSlot) - && manaItemSlot.canReceiveManaFromItem(stackInSlot, stack)) { - if (stack.getItem() instanceof IManaItem - && !((IManaItem) stack.getItem()).canExportManaToItem(stack, stackInSlot)) continue; - - if (add) manaItemSlot.addMana(stackInSlot, manaToSend); - if (useBaubles) BotaniaAPI.internalHandler.sendBaubleUpdatePacket(player, slot); - - return true; - } - } - } - - return false; - } - - /** - * Requests mana from items in a given player's inventory. This version also - * checks for IManaDiscountArmor items equipped to lower the cost. - * @param manaToGet How much mana is to be requested, if less mana exists than this amount, - * the amount of mana existent will be returned instead, if you want exact values use requestManaExact. - * @param remove If true, the mana will be removed from the target item. Set to false to just check. - * @return The amount of mana received from the request. - */ - public static int requestManaForTool(ItemStack stack, EntityPlayer player, int manaToGet, boolean remove) { - float multiplier = Math.max(0F, 1F - getFullDiscountForTools(player)); - int cost = (int) (manaToGet * multiplier); - return (int) (requestMana(stack, player, cost, remove) / multiplier); - } - - /** - * Requests an exact amount of mana from items in a given player's inventory. This version also - * checks for IManaDiscountArmor items equipped to lower the cost. - * @param manaToGet How much mana is to be requested, if less mana exists than this amount, - * false will be returned instead, and nothing will happen. - * @param remove If true, the mana will be removed from the target item. Set to false to just check. - * @return If the request was succesful. - */ - public static boolean requestManaExactForTool(ItemStack stack, EntityPlayer player, int manaToGet, boolean remove) { - float multiplier = Math.max(0F, 1F - getFullDiscountForTools(player)); - int cost = (int) (manaToGet * multiplier); - return requestManaExact(stack, player, cost, remove); - } - - /** - * Gets the sum of all the discounts on IManaDiscountArmor items equipped - * on the player passed in. - */ - public static float getFullDiscountForTools(EntityPlayer player) { - float discount = 0F; - for (int i = 0; i < player.inventory.armorInventory.length; i++) { - ItemStack armor = player.inventory.armorInventory[i]; - if (armor != null && armor.getItem() instanceof IManaDiscountArmor) - discount += ((IManaDiscountArmor) armor.getItem()).getDiscount(armor, i, player); - } - - return discount; - } + /** + * Requests mana from items in a given player's inventory. + * @param manaToGet How much mana is to be requested, if less mana exists than this amount, + * the amount of mana existent will be returned instead, if you want exact values use requestManaExact. + * @param remove If true, the mana will be removed from the target item. Set to false to just check. + * @return The amount of mana received from the request. + */ + public static int requestMana(ItemStack stack, EntityPlayer player, int manaToGet, boolean remove) { + if(stack == null) + return 0; + + IInventory mainInv = player.inventory; + IInventory baublesInv = BotaniaAPI.internalHandler.getBaublesInventory(player); + + int invSize = mainInv.getSizeInventory(); + int size = invSize; + if(baublesInv != null) + size += baublesInv.getSizeInventory(); + + for(int i = 0; i < size; i++) { + boolean useBaubles = i >= invSize; + IInventory inv = useBaubles ? baublesInv : mainInv; + int slot = i - (useBaubles ? invSize : 0); + ItemStack stackInSlot = inv.getStackInSlot(slot); + if(stackInSlot == stack) + continue; + + if(stackInSlot != null && stackInSlot.getItem() instanceof IManaItem) { + IManaItem manaItem = (IManaItem) stackInSlot.getItem(); + if(manaItem.canExportManaToItem(stackInSlot, stack) && manaItem.getMana(stackInSlot) > 0) { + if(stack.getItem() instanceof IManaItem && !((IManaItem) stack.getItem()).canReceiveManaFromItem(stack, stackInSlot)) + continue; + + int mana = Math.min(manaToGet, manaItem.getMana(stackInSlot)); + + if(remove) + manaItem.addMana(stackInSlot, -mana); + if(useBaubles) + BotaniaAPI.internalHandler.sendBaubleUpdatePacket(player, slot); + + return mana; + } + } + } + + return 0; + } + + /** + * Requests an exact amount of mana from items in a given player's inventory. + * @param manaToGet How much mana is to be requested, if less mana exists than this amount, + * false will be returned instead, and nothing will happen. + * @param remove If true, the mana will be removed from the target item. Set to false to just check. + * @return If the request was succesful. + */ + public static boolean requestManaExact(ItemStack stack, EntityPlayer player, int manaToGet, boolean remove) { + if(stack == null) + return false; + + IInventory mainInv = player.inventory; + IInventory baublesInv = BotaniaAPI.internalHandler.getBaublesInventory(player); + + int invSize = mainInv.getSizeInventory(); + int size = invSize; + if(baublesInv != null) + size += baublesInv.getSizeInventory(); + + for(int i = 0; i < size; i++) { + boolean useBaubles = i >= invSize; + IInventory inv = useBaubles ? baublesInv : mainInv; + int slot = i - (useBaubles ? invSize : 0); + ItemStack stackInSlot = inv.getStackInSlot(slot); + if(stackInSlot == stack) + continue; + + if(stackInSlot != null && stackInSlot.getItem() instanceof IManaItem) { + IManaItem manaItemSlot = (IManaItem) stackInSlot.getItem(); + if(manaItemSlot.canExportManaToItem(stackInSlot, stack) && manaItemSlot.getMana(stackInSlot) > manaToGet) { + if(stack.getItem() instanceof IManaItem && !((IManaItem) stack.getItem()).canReceiveManaFromItem(stack, stackInSlot)) + continue; + + if(remove) + manaItemSlot.addMana(stackInSlot, -manaToGet); + if(useBaubles) + BotaniaAPI.internalHandler.sendBaubleUpdatePacket(player, slot); + + return true; + } + } + } + + return false; + } + + /** + * Dispatches mana to items in a given player's inventory. Note that this method + * does not automatically remove mana from the item which is exporting. + * @param manaToSend How much mana is to be sent. + * @param remove If true, the mana will be added from the target item. Set to false to just check. + * @return The amount of mana actually sent. + */ + public static int dispatchMana(ItemStack stack, EntityPlayer player, int manaToSend, boolean add) { + if(stack == null) + return 0; + + IInventory mainInv = player.inventory; + IInventory baublesInv = BotaniaAPI.internalHandler.getBaublesInventory(player); + + int invSize = mainInv.getSizeInventory(); + int size = invSize; + if(baublesInv != null) + size += baublesInv.getSizeInventory(); + + for(int i = 0; i < size; i++) { + boolean useBaubles = i >= invSize; + IInventory inv = useBaubles ? baublesInv : mainInv; + int slot = i - (useBaubles ? invSize : 0); + ItemStack stackInSlot = inv.getStackInSlot(slot); + if(stackInSlot == stack) + continue; + + if(stackInSlot != null && stackInSlot.getItem() instanceof IManaItem) { + IManaItem manaItemSlot = (IManaItem) stackInSlot.getItem(); + + if(manaItemSlot.canReceiveManaFromItem(stackInSlot, stack)) { + if(stack.getItem() instanceof IManaItem && !((IManaItem) stack.getItem()).canExportManaToItem(stack, stackInSlot)) + continue; + + int received = 0; + if(manaItemSlot.getMana(stackInSlot) + manaToSend <= manaItemSlot.getMaxMana(stackInSlot)) + received = manaToSend; + else received = manaToSend - (manaItemSlot.getMana(stackInSlot) + manaToSend - manaItemSlot.getMaxMana(stackInSlot)); + + + if(add) + manaItemSlot.addMana(stackInSlot, manaToSend); + if(useBaubles) + BotaniaAPI.internalHandler.sendBaubleUpdatePacket(player, slot); + + return received; + } + } + } + + return 0; + } + + /** + * Dispatches an exact amount of mana to items in a given player's inventory. Note that this method + * does not automatically remove mana from the item which is exporting. + * @param manaToSend How much mana is to be sent. + * @param remove If true, the mana will be added from the target item. Set to false to just check. + * @return If an item received the mana sent. + */ + public static boolean dispatchManaExact(ItemStack stack, EntityPlayer player, int manaToSend, boolean add) { + if(stack == null) + return false; + + IInventory mainInv = player.inventory; + IInventory baublesInv = BotaniaAPI.internalHandler.getBaublesInventory(player); + + int invSize = mainInv.getSizeInventory(); + int size = invSize; + if(baublesInv != null) + size += baublesInv.getSizeInventory(); + + for(int i = 0; i < size; i++) { + boolean useBaubles = i >= invSize; + IInventory inv = useBaubles ? baublesInv : mainInv; + int slot = i - (useBaubles ? invSize : 0); + ItemStack stackInSlot = inv.getStackInSlot(slot); + if(stackInSlot == stack) + continue; + + if(stackInSlot != null && stackInSlot.getItem() instanceof IManaItem) { + IManaItem manaItemSlot = (IManaItem) stackInSlot.getItem(); + if(manaItemSlot.getMana(stackInSlot) + manaToSend <= manaItemSlot.getMaxMana(stackInSlot) && manaItemSlot.canReceiveManaFromItem(stackInSlot, stack)) { + if(stack.getItem() instanceof IManaItem && !((IManaItem) stack.getItem()).canExportManaToItem(stack, stackInSlot)) + continue; + + if(add) + manaItemSlot.addMana(stackInSlot, manaToSend); + if(useBaubles) + BotaniaAPI.internalHandler.sendBaubleUpdatePacket(player, slot); + + return true; + } + } + } + + return false; + } + + /** + * Requests mana from items in a given player's inventory. This version also + * checks for IManaDiscountArmor items equipped to lower the cost. + * @param manaToGet How much mana is to be requested, if less mana exists than this amount, + * the amount of mana existent will be returned instead, if you want exact values use requestManaExact. + * @param remove If true, the mana will be removed from the target item. Set to false to just check. + * @return The amount of mana received from the request. + */ + public static int requestManaForTool(ItemStack stack, EntityPlayer player, int manaToGet, boolean remove) { + float multiplier = Math.max(0F, 1F - getFullDiscountForTools(player)); + int cost = (int) (manaToGet * multiplier); + return (int) (requestMana(stack, player, cost, remove) / multiplier); + } + + /** + * Requests an exact amount of mana from items in a given player's inventory. This version also + * checks for IManaDiscountArmor items equipped to lower the cost. + * @param manaToGet How much mana is to be requested, if less mana exists than this amount, + * false will be returned instead, and nothing will happen. + * @param remove If true, the mana will be removed from the target item. Set to false to just check. + * @return If the request was succesful. + */ + public static boolean requestManaExactForTool(ItemStack stack, EntityPlayer player, int manaToGet, boolean remove) { + float multiplier = Math.max(0F, 1F - getFullDiscountForTools(player)); + int cost = (int) (manaToGet * multiplier); + return requestManaExact(stack, player, cost, remove); + } + + /** + * Gets the sum of all the discounts on IManaDiscountArmor items equipped + * on the player passed in. + */ + public static float getFullDiscountForTools(EntityPlayer player) { + float discount = 0F; + for(int i = 0; i < player.inventory.armorInventory.length; i++) { + ItemStack armor = player.inventory.armorInventory[i]; + if(armor != null && armor.getItem() instanceof IManaDiscountArmor) + discount += ((IManaDiscountArmor) armor.getItem()).getDiscount(armor, i, player); + } + + return discount; + } } diff --git a/src/main/java/vazkii/botania/api/mana/ManaNetworkEvent.java b/src/main/java/vazkii/botania/api/mana/ManaNetworkEvent.java index 46d73b443d..9116602c56 100644 --- a/src/main/java/vazkii/botania/api/mana/ManaNetworkEvent.java +++ b/src/main/java/vazkii/botania/api/mana/ManaNetworkEvent.java @@ -2,57 +2,55 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jan 22, 2014, 5:04:30 PM (GMT)] */ package vazkii.botania.api.mana; -import cpw.mods.fml.common.eventhandler.Event; import net.minecraft.tileentity.TileEntity; import net.minecraftforge.common.MinecraftForge; +import cpw.mods.fml.common.eventhandler.Event; public class ManaNetworkEvent extends Event { - public final TileEntity tile; - public final ManaBlockType type; - public final Action action; - - public ManaNetworkEvent(TileEntity tile, ManaBlockType type, Action action) { - this.tile = tile; - this.type = type; - this.action = action; - } - - public static void addCollector(TileEntity tile) { - ManaNetworkEvent event = new ManaNetworkEvent(tile, ManaBlockType.COLLECTOR, Action.ADD); - MinecraftForge.EVENT_BUS.post(event); - } - - public static void removeCollector(TileEntity tile) { - ManaNetworkEvent event = new ManaNetworkEvent(tile, ManaBlockType.COLLECTOR, Action.REMOVE); - MinecraftForge.EVENT_BUS.post(event); - } - - public static void addPool(TileEntity tile) { - ManaNetworkEvent event = new ManaNetworkEvent(tile, ManaBlockType.POOL, Action.ADD); - MinecraftForge.EVENT_BUS.post(event); - } - - public static void removePool(TileEntity tile) { - ManaNetworkEvent event = new ManaNetworkEvent(tile, ManaBlockType.POOL, Action.REMOVE); - MinecraftForge.EVENT_BUS.post(event); - } - - public enum ManaBlockType { - POOL, - COLLECTOR - } - - public enum Action { - REMOVE, - ADD - } + public final TileEntity tile; + public final ManaBlockType type; + public final Action action; + + public ManaNetworkEvent(TileEntity tile, ManaBlockType type, Action action) { + this.tile = tile; + this.type = type; + this.action = action; + } + + public static void addCollector(TileEntity tile) { + ManaNetworkEvent event = new ManaNetworkEvent(tile, ManaBlockType.COLLECTOR, Action.ADD); + MinecraftForge.EVENT_BUS.post(event); + } + + public static void removeCollector(TileEntity tile) { + ManaNetworkEvent event = new ManaNetworkEvent(tile, ManaBlockType.COLLECTOR, Action.REMOVE); + MinecraftForge.EVENT_BUS.post(event); + } + + public static void addPool(TileEntity tile) { + ManaNetworkEvent event = new ManaNetworkEvent(tile, ManaBlockType.POOL, Action.ADD); + MinecraftForge.EVENT_BUS.post(event); + } + + public static void removePool(TileEntity tile) { + ManaNetworkEvent event = new ManaNetworkEvent(tile, ManaBlockType.POOL, Action.REMOVE); + MinecraftForge.EVENT_BUS.post(event); + } + + public enum ManaBlockType { + POOL, COLLECTOR + } + + public enum Action { + REMOVE, ADD + } } diff --git a/src/main/java/vazkii/botania/api/mana/TileSignature.java b/src/main/java/vazkii/botania/api/mana/TileSignature.java index ae60ecb107..5573670da1 100644 --- a/src/main/java/vazkii/botania/api/mana/TileSignature.java +++ b/src/main/java/vazkii/botania/api/mana/TileSignature.java @@ -4,11 +4,12 @@ public class TileSignature { - public final TileEntity tile; - public final boolean remoteWorld; + public final TileEntity tile; + public final boolean remoteWorld; + + public TileSignature(TileEntity tile, boolean remoteWorld) { + this.tile = tile; + this.remoteWorld = remoteWorld; + } - public TileSignature(TileEntity tile, boolean remoteWorld) { - this.tile = tile; - this.remoteWorld = remoteWorld; - } } diff --git a/src/main/java/vazkii/botania/api/mana/spark/ISparkAttachable.java b/src/main/java/vazkii/botania/api/mana/spark/ISparkAttachable.java index 75c3d8d264..880e169fea 100644 --- a/src/main/java/vazkii/botania/api/mana/spark/ISparkAttachable.java +++ b/src/main/java/vazkii/botania/api/mana/spark/ISparkAttachable.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Aug 21, 2014, 5:44:13 PM (GMT)] */ package vazkii.botania.api.mana.spark; @@ -19,40 +19,41 @@ */ public interface ISparkAttachable extends IManaReceiver { - /** - * Can this block have a Spark attached to it. Note that this will not - * unattach the Spark if it's changed later. - */ - public boolean canAttachSpark(ItemStack stack); - - /** - * Called when the Spark is attached. - */ - public void attachSpark(ISparkEntity entity); - - /** - * Returns how much space for mana is available in this block, normally the total - the current. - * Should NEVER return negative values. Make sure to check against that. - */ - public int getAvailableSpaceForMana(); - - /** - * Gets the Spark that is attached to this block. A common implementation is - * to check for Spark entities above: - * - * List sparks = worldObj.getEntitiesWithinAABB(ISparkEntity.class, AxisAlignedBB.getBoundingBox(xCoord, yCoord + 1, zCoord, xCoord + 1, yCoord + 2, zCoord + 1)); - * if(sparks.size() == 1) { - * Entity e = (Entity) sparks.get(0); - * return (ISparkEntity) e; - * } - * - * return null; - */ - public ISparkEntity getAttachedSpark(); - - /** - * Return true if this Tile no longer requires mana and all Sparks - * transferring mana to it should cancel their transfer. - */ - public boolean areIncomingTranfersDone(); + /** + * Can this block have a Spark attached to it. Note that this will not + * unattach the Spark if it's changed later. + */ + public boolean canAttachSpark(ItemStack stack); + + /** + * Called when the Spark is attached. + */ + public void attachSpark(ISparkEntity entity); + + /** + * Returns how much space for mana is available in this block, normally the total - the current. + * Should NEVER return negative values. Make sure to check against that. + */ + public int getAvailableSpaceForMana(); + + /** + * Gets the Spark that is attached to this block. A common implementation is + * to check for Spark entities above: + * + List sparks = worldObj.getEntitiesWithinAABB(ISparkEntity.class, AxisAlignedBB.getBoundingBox(xCoord, yCoord + 1, zCoord, xCoord + 1, yCoord + 2, zCoord + 1)); + if(sparks.size() == 1) { + Entity e = (Entity) sparks.get(0); + return (ISparkEntity) e; + } + + return null; + */ + public ISparkEntity getAttachedSpark(); + + /** + * Return true if this Tile no longer requires mana and all Sparks + * transferring mana to it should cancel their transfer. + */ + public boolean areIncomingTranfersDone(); + } diff --git a/src/main/java/vazkii/botania/api/mana/spark/ISparkEntity.java b/src/main/java/vazkii/botania/api/mana/spark/ISparkEntity.java index 6fed71eae4..e35076ceb6 100644 --- a/src/main/java/vazkii/botania/api/mana/spark/ISparkEntity.java +++ b/src/main/java/vazkii/botania/api/mana/spark/ISparkEntity.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Aug 21, 2014, 5:44:07 PM (GMT)] */ package vazkii.botania.api.mana.spark; @@ -17,47 +17,48 @@ */ public interface ISparkEntity { - /** - * Which TileEntity is this Spark attached to? A common implementation is checking the block below. - * - * int x = MathHelper.floor_double(posX); - * int y = MathHelper.floor_double(posY) - 1; - * int z = MathHelper.floor_double(posZ); - * TileEntity tile = worldObj.getTileEntity(x, y, z); - * if(tile != null && tile instanceof ISparkAttachable) - * return (ISparkAttachable) tile; - * - * return null; - */ - public ISparkAttachable getAttachedTile(); - - /** - * Gets a collection of all Sparks this is tranfering to. - */ - public Collection getTransfers(); - - /** - * Registers the Spark passed in as a Spark meant for mana to be transfered towards. - */ - public void registerTransfer(ISparkEntity entity); - - /** - * Gets which upgrade is in this Spark.
- * 0: None
- * 1: Dispersive
- * 2: Dominant
- * 3: Recessive
- * 4: Isolated - */ - public int getUpgrade(); - - /** - * Sets the upgrade on this Spark. See {@link ISparkEntity#getUpgrade} - */ - public void setUpgrade(int upgrade); - - /** - * See {@link ISparkAttachable#areIncomingTranfersDone()} - */ - public boolean areIncomingTransfersDone(); + /** + * Which TileEntity is this Spark attached to? A common implementation is checking the block below. + * + int x = MathHelper.floor_double(posX); + int y = MathHelper.floor_double(posY) - 1; + int z = MathHelper.floor_double(posZ); + TileEntity tile = worldObj.getTileEntity(x, y, z); + if(tile != null && tile instanceof ISparkAttachable) + return (ISparkAttachable) tile; + + return null; + */ + public ISparkAttachable getAttachedTile(); + + /** + * Gets a collection of all Sparks this is tranfering to. + */ + public Collection getTransfers(); + + /** + * Registers the Spark passed in as a Spark meant for mana to be transfered towards. + */ + public void registerTransfer(ISparkEntity entity); + + /** + * Gets which upgrade is in this Spark.
+ * 0: None
+ * 1: Dispersive
+ * 2: Dominant
+ * 3: Recessive
+ * 4: Isolated + */ + public int getUpgrade(); + + /** + * Sets the upgrade on this Spark. See {@link ISparkEntity#getUpgrade} + */ + public void setUpgrade(int upgrade); + + /** + * See {@link ISparkAttachable#areIncomingTranfersDone()} + */ + public boolean areIncomingTransfersDone(); + } diff --git a/src/main/java/vazkii/botania/api/mana/spark/SparkHelper.java b/src/main/java/vazkii/botania/api/mana/spark/SparkHelper.java index 9baf3fa81e..7351036cf1 100644 --- a/src/main/java/vazkii/botania/api/mana/spark/SparkHelper.java +++ b/src/main/java/vazkii/botania/api/mana/spark/SparkHelper.java @@ -2,30 +2,31 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Aug 21, 2014, 7:16:11 PM (GMT)] */ package vazkii.botania.api.mana.spark; import java.util.List; + import net.minecraft.util.AxisAlignedBB; import net.minecraft.world.World; public final class SparkHelper { - public static final int SPARK_SCAN_RANGE = 12; + public static final int SPARK_SCAN_RANGE = 12; + + public static List getSparksAround(World world, double x, double y, double z) { + return SparkHelper.getEntitiesAround(ISparkEntity.class, world, x, y, z); + } - public static List getSparksAround(World world, double x, double y, double z) { - return SparkHelper.getEntitiesAround(ISparkEntity.class, world, x, y, z); - } + public static List getEntitiesAround(Class clazz, World world, double x, double y, double z) { + int r = SPARK_SCAN_RANGE; + List entities = world.getEntitiesWithinAABB(clazz, AxisAlignedBB.getBoundingBox(x - r, y - r, z - r, x + r, y + r, z + r)); + return entities; + } - public static List getEntitiesAround(Class clazz, World world, double x, double y, double z) { - int r = SPARK_SCAN_RANGE; - List entities = world.getEntitiesWithinAABB( - clazz, AxisAlignedBB.getBoundingBox(x - r, y - r, z - r, x + r, y + r, z + r)); - return entities; - } } diff --git a/src/main/java/vazkii/botania/api/package-info.java b/src/main/java/vazkii/botania/api/package-info.java index deffdad863..f5ba9c0248 100644 --- a/src/main/java/vazkii/botania/api/package-info.java +++ b/src/main/java/vazkii/botania/api/package-info.java @@ -1,4 +1,4 @@ @API(owner = "Botania", apiVersion = "76", provides = "BotaniaAPI") package vazkii.botania.api; - import cpw.mods.fml.common.API; + diff --git a/src/main/java/vazkii/botania/api/recipe/ElvenPortalUpdateEvent.java b/src/main/java/vazkii/botania/api/recipe/ElvenPortalUpdateEvent.java index 368ecacb22..40d971359d 100644 --- a/src/main/java/vazkii/botania/api/recipe/ElvenPortalUpdateEvent.java +++ b/src/main/java/vazkii/botania/api/recipe/ElvenPortalUpdateEvent.java @@ -2,19 +2,20 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Apr 17, 2015, 4:58:30 PM (GMT)] */ package vazkii.botania.api.recipe; -import cpw.mods.fml.common.eventhandler.Event; import java.util.List; + import net.minecraft.item.ItemStack; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.AxisAlignedBB; +import cpw.mods.fml.common.eventhandler.Event; /** * An event fired when an Elven Portal TE updates. The portal's @@ -23,19 +24,19 @@ */ public class ElvenPortalUpdateEvent extends Event { - /** - * May be casted to TileAlfPortal if you have botania code access aside from the API. - */ - public final TileEntity portalTile; + /** + * May be casted to TileAlfPortal if you have botania code access aside from the API. + */ + public final TileEntity portalTile; + public final AxisAlignedBB aabb; + public boolean open; + public final List stacksInside; - public final AxisAlignedBB aabb; - public boolean open; - public final List stacksInside; + public ElvenPortalUpdateEvent(TileEntity te, AxisAlignedBB aabb, boolean open, List stacks) { + portalTile = te; + this.aabb = aabb; + this.open = open; + stacksInside = stacks; + } - public ElvenPortalUpdateEvent(TileEntity te, AxisAlignedBB aabb, boolean open, List stacks) { - portalTile = te; - this.aabb = aabb; - this.open = open; - stacksInside = stacks; - } } diff --git a/src/main/java/vazkii/botania/api/recipe/IElvenItem.java b/src/main/java/vazkii/botania/api/recipe/IElvenItem.java index 4bcbb80843..e614014d00 100644 --- a/src/main/java/vazkii/botania/api/recipe/IElvenItem.java +++ b/src/main/java/vazkii/botania/api/recipe/IElvenItem.java @@ -9,5 +9,6 @@ */ public interface IElvenItem { - public boolean isElvenItem(ItemStack stack); + public boolean isElvenItem(ItemStack stack); + } diff --git a/src/main/java/vazkii/botania/api/recipe/IFlowerComponent.java b/src/main/java/vazkii/botania/api/recipe/IFlowerComponent.java index 9da22c5b8f..ca46124123 100644 --- a/src/main/java/vazkii/botania/api/recipe/IFlowerComponent.java +++ b/src/main/java/vazkii/botania/api/recipe/IFlowerComponent.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Feb 15, 2014, 2:36:35 PM (GMT)] */ package vazkii.botania.api.recipe; @@ -18,7 +18,8 @@ */ public interface IFlowerComponent { - public boolean canFit(ItemStack stack, IInventory apothecary); + public boolean canFit(ItemStack stack, IInventory apothecary); + + public int getParticleColor(ItemStack stack); - public int getParticleColor(ItemStack stack); } diff --git a/src/main/java/vazkii/botania/api/recipe/RecipeBrew.java b/src/main/java/vazkii/botania/api/recipe/RecipeBrew.java index 01a02e0c85..95577784ef 100644 --- a/src/main/java/vazkii/botania/api/recipe/RecipeBrew.java +++ b/src/main/java/vazkii/botania/api/recipe/RecipeBrew.java @@ -2,16 +2,17 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Nov 1, 2014, 8:52:00 PM (GMT)] */ package vazkii.botania.api.recipe; import java.util.ArrayList; import java.util.List; + import net.minecraft.init.Items; import net.minecraft.inventory.IInventory; import net.minecraft.item.ItemStack; @@ -21,84 +22,93 @@ public class RecipeBrew { - Brew brew; - List inputs; - - public RecipeBrew(Brew brew, Object... inputs) { - this.brew = brew; - - List inputsToSet = new ArrayList(); - for (Object obj : inputs) { - if (obj instanceof String || obj instanceof ItemStack) inputsToSet.add(obj); - else throw new IllegalArgumentException("Invalid input"); - } - - this.inputs = inputsToSet; - } - - public boolean matches(IInventory inv) { - List inputsMissing = new ArrayList(inputs); - - for (int i = 0; i < inv.getSizeInventory(); i++) { - ItemStack stack = inv.getStackInSlot(i); - if (stack == null) break; - - if (stack.getItem() instanceof IBrewContainer) continue; - - int stackIndex = -1, oredictIndex = -1; - - for (int j = 0; j < inputsMissing.size(); j++) { - Object input = inputsMissing.get(j); - if (input instanceof String) { - List validStacks = OreDictionary.getOres((String) input); - boolean found = false; - for (ItemStack ostack : validStacks) { - ItemStack cstack = ostack.copy(); - if (cstack.getItemDamage() == Short.MAX_VALUE) cstack.setItemDamage(stack.getItemDamage()); - - if (stack.isItemEqual(cstack)) { - oredictIndex = j; - found = true; - break; - } - } - - if (found) break; - } else if (input instanceof ItemStack && simpleAreStacksEqual((ItemStack) input, stack)) { - stackIndex = j; - break; - } - } - - if (stackIndex != -1) inputsMissing.remove(stackIndex); - else if (oredictIndex != -1) inputsMissing.remove(oredictIndex); - else return false; - } - - return inputsMissing.isEmpty(); - } - - boolean simpleAreStacksEqual(ItemStack stack, ItemStack stack2) { - return stack.getItem() == stack2.getItem() && stack.getItemDamage() == stack2.getItemDamage(); - } - - public List getInputs() { - return new ArrayList(inputs); - } - - public Brew getBrew() { - return brew; - } - - public int getManaUsage() { - return brew.getManaCost(); - } - - public ItemStack getOutput(ItemStack stack) { - if (stack == null || !(stack.getItem() instanceof IBrewContainer)) - return new ItemStack(Items.glass_bottle); // Fallback... - IBrewContainer container = (IBrewContainer) stack.getItem(); - - return container.getItemForBrew(brew, stack); - } + Brew brew; + List inputs; + + public RecipeBrew(Brew brew, Object... inputs) { + this.brew = brew; + + List inputsToSet = new ArrayList(); + for(Object obj : inputs) { + if(obj instanceof String || obj instanceof ItemStack) + inputsToSet.add(obj); + else throw new IllegalArgumentException("Invalid input"); + } + + this.inputs = inputsToSet; + } + + public boolean matches(IInventory inv) { + List inputsMissing = new ArrayList(inputs); + + for(int i = 0; i < inv.getSizeInventory(); i++) { + ItemStack stack = inv.getStackInSlot(i); + if(stack == null) + break; + + if(stack.getItem() instanceof IBrewContainer) + continue; + + int stackIndex = -1, oredictIndex = -1; + + for(int j = 0; j < inputsMissing.size(); j++) { + Object input = inputsMissing.get(j); + if(input instanceof String) { + List validStacks = OreDictionary.getOres((String) input); + boolean found = false; + for(ItemStack ostack : validStacks) { + ItemStack cstack = ostack.copy(); + if(cstack.getItemDamage() == Short.MAX_VALUE) + cstack.setItemDamage(stack.getItemDamage()); + + if(stack.isItemEqual(cstack)) { + oredictIndex = j; + found = true; + break; + } + } + + + if(found) + break; + } else if(input instanceof ItemStack && simpleAreStacksEqual((ItemStack) input, stack)) { + stackIndex = j; + break; + } + } + + if(stackIndex != -1) + inputsMissing.remove(stackIndex); + else if(oredictIndex != -1) + inputsMissing.remove(oredictIndex); + else return false; + } + + return inputsMissing.isEmpty(); + } + + boolean simpleAreStacksEqual(ItemStack stack, ItemStack stack2) { + return stack.getItem() == stack2.getItem() && stack.getItemDamage() == stack2.getItemDamage(); + } + + public List getInputs() { + return new ArrayList(inputs); + } + + public Brew getBrew() { + return brew; + } + + public int getManaUsage() { + return brew.getManaCost(); + } + + public ItemStack getOutput(ItemStack stack) { + if(stack == null || !(stack.getItem() instanceof IBrewContainer)) + return new ItemStack(Items.glass_bottle); // Fallback... + IBrewContainer container = (IBrewContainer) stack.getItem(); + + return container.getItemForBrew(brew, stack); + } + } diff --git a/src/main/java/vazkii/botania/api/recipe/RecipeElvenTrade.java b/src/main/java/vazkii/botania/api/recipe/RecipeElvenTrade.java index 9e14b6738c..dbea13e86c 100644 --- a/src/main/java/vazkii/botania/api/recipe/RecipeElvenTrade.java +++ b/src/main/java/vazkii/botania/api/recipe/RecipeElvenTrade.java @@ -2,81 +2,93 @@ import java.util.ArrayList; import java.util.List; + import net.minecraft.item.ItemStack; import net.minecraftforge.oredict.OreDictionary; public class RecipeElvenTrade { - ItemStack output; - List inputs; - - public RecipeElvenTrade(ItemStack output, Object... inputs) { - this.output = output; - - List inputsToSet = new ArrayList(); - for (Object obj : inputs) { - if (obj instanceof String || obj instanceof ItemStack) inputsToSet.add(obj); - else throw new IllegalArgumentException("Invalid input"); - } - - this.inputs = inputsToSet; - } - - public boolean matches(List stacks, boolean remove) { - List inputsMissing = new ArrayList(inputs); - List stacksToRemove = new ArrayList(); - - for (ItemStack stack : stacks) { - if (stack == null) { - continue; - } - if (inputsMissing.isEmpty()) break; - - int stackIndex = -1, oredictIndex = -1; - - for (int j = 0; j < inputsMissing.size(); j++) { - Object input = inputsMissing.get(j); - if (input instanceof String) { - List validStacks = OreDictionary.getOres((String) input); - boolean found = false; - for (ItemStack ostack : validStacks) { - ItemStack cstack = ostack.copy(); - if (cstack.getItemDamage() == Short.MAX_VALUE) cstack.setItemDamage(stack.getItemDamage()); - - if (stack.isItemEqual(cstack)) { - if (!stacksToRemove.contains(stack)) stacksToRemove.add(stack); - oredictIndex = j; - found = true; - break; - } - } - - if (found) break; - } else if (input instanceof ItemStack && simpleAreStacksEqual((ItemStack) input, stack)) { - if (!stacksToRemove.contains(stack)) stacksToRemove.add(stack); - stackIndex = j; - break; - } - } - - if (stackIndex != -1) inputsMissing.remove(stackIndex); - else if (oredictIndex != -1) inputsMissing.remove(oredictIndex); - } - - if (remove) for (ItemStack r : stacksToRemove) stacks.remove(r); - - return inputsMissing.isEmpty(); - } - - boolean simpleAreStacksEqual(ItemStack stack, ItemStack stack2) { - return stack.getItem() == stack2.getItem() && stack.getItemDamage() == stack2.getItemDamage(); - } - - public List getInputs() { - return new ArrayList(inputs); - } - - public ItemStack getOutput() { - return output; - } + ItemStack output; + List inputs; + + public RecipeElvenTrade(ItemStack output, Object... inputs) { + this.output = output; + + List inputsToSet = new ArrayList(); + for(Object obj : inputs) { + if(obj instanceof String || obj instanceof ItemStack) + inputsToSet.add(obj); + else throw new IllegalArgumentException("Invalid input"); + } + + this.inputs = inputsToSet; + } + + public boolean matches(List stacks, boolean remove) { + List inputsMissing = new ArrayList(inputs); + List stacksToRemove = new ArrayList(); + + for(ItemStack stack : stacks) { + if(stack == null) { + continue; + } + if(inputsMissing.isEmpty()) + break; + + int stackIndex = -1, oredictIndex = -1; + + for(int j = 0; j < inputsMissing.size(); j++) { + Object input = inputsMissing.get(j); + if(input instanceof String) { + List validStacks = OreDictionary.getOres((String) input); + boolean found = false; + for(ItemStack ostack : validStacks) { + ItemStack cstack = ostack.copy(); + if(cstack.getItemDamage() == Short.MAX_VALUE) + cstack.setItemDamage(stack.getItemDamage()); + + if(stack.isItemEqual(cstack)) { + if(!stacksToRemove.contains(stack)) + stacksToRemove.add(stack); + oredictIndex = j; + found = true; + break; + } + } + + if(found) + break; + } else if(input instanceof ItemStack && simpleAreStacksEqual((ItemStack) input, stack)) { + if(!stacksToRemove.contains(stack)) + stacksToRemove.add(stack); + stackIndex = j; + break; + } + } + + if(stackIndex != -1) + inputsMissing.remove(stackIndex); + else if(oredictIndex != -1) + inputsMissing.remove(oredictIndex); + } + + if(remove) + for(ItemStack r : stacksToRemove) + stacks.remove(r); + + return inputsMissing.isEmpty(); + } + + boolean simpleAreStacksEqual(ItemStack stack, ItemStack stack2) { + return stack.getItem() == stack2.getItem() && stack.getItemDamage() == stack2.getItemDamage(); + } + + public List getInputs() { + return new ArrayList(inputs); + } + + public ItemStack getOutput() { + return output; + } + } diff --git a/src/main/java/vazkii/botania/api/recipe/RecipeManaInfusion.java b/src/main/java/vazkii/botania/api/recipe/RecipeManaInfusion.java index b5dc0b70df..368c8d4c43 100644 --- a/src/main/java/vazkii/botania/api/recipe/RecipeManaInfusion.java +++ b/src/main/java/vazkii/botania/api/recipe/RecipeManaInfusion.java @@ -2,79 +2,84 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jan 30, 2014, 5:57:07 PM (GMT)] */ package vazkii.botania.api.recipe; import java.util.List; + import net.minecraft.item.ItemStack; import net.minecraftforge.oredict.OreDictionary; public class RecipeManaInfusion { - ItemStack output; - Object input; - int mana; - boolean isAlchemy = false; - boolean isConjuration = false; - - public RecipeManaInfusion(ItemStack output, Object input, int mana) { - this.output = output; - this.input = input; - this.mana = mana; - } - - public boolean matches(ItemStack stack) { - if (input instanceof ItemStack) { - ItemStack inputCopy = ((ItemStack) input).copy(); - if (inputCopy.getItemDamage() == Short.MAX_VALUE) inputCopy.setItemDamage(stack.getItemDamage()); - - return stack.isItemEqual(inputCopy); - } - - if (input instanceof String) { - List validStacks = OreDictionary.getOres((String) input); - - for (ItemStack ostack : validStacks) { - ItemStack cstack = ostack.copy(); - if (cstack.getItemDamage() == Short.MAX_VALUE) cstack.setItemDamage(stack.getItemDamage()); - - if (stack.isItemEqual(cstack)) return true; - } - } - - return false; - } - - public void setAlchemy(boolean alchemy) { - isAlchemy = alchemy; - } - - public boolean isAlchemy() { - return isAlchemy; - } - - public void setConjuration(boolean conjuration) { - isConjuration = conjuration; - } - - public boolean isConjuration() { - return isConjuration; - } - - public Object getInput() { - return input; - } - - public ItemStack getOutput() { - return output; - } - - public int getManaToConsume() { - return mana; - } + ItemStack output; + Object input; + int mana; + boolean isAlchemy = false; + boolean isConjuration = false; + + public RecipeManaInfusion(ItemStack output, Object input, int mana) { + this.output = output; + this.input = input; + this.mana = mana; + } + + public boolean matches(ItemStack stack) { + if(input instanceof ItemStack) { + ItemStack inputCopy = ((ItemStack) input).copy(); + if(inputCopy.getItemDamage() == Short.MAX_VALUE) + inputCopy.setItemDamage(stack.getItemDamage()); + + return stack.isItemEqual(inputCopy); + } + + if(input instanceof String) { + List validStacks = OreDictionary.getOres((String) input); + + for(ItemStack ostack : validStacks) { + ItemStack cstack = ostack.copy(); + if(cstack.getItemDamage() == Short.MAX_VALUE) + cstack.setItemDamage(stack.getItemDamage()); + + if(stack.isItemEqual(cstack)) + return true; + } + } + + return false; + } + + public void setAlchemy(boolean alchemy) { + isAlchemy = alchemy; + } + + public boolean isAlchemy() { + return isAlchemy; + } + + public void setConjuration(boolean conjuration) { + isConjuration = conjuration; + } + + public boolean isConjuration() { + return isConjuration; + } + + public Object getInput() { + return input; + } + + public ItemStack getOutput() { + return output; + } + + public int getManaToConsume() { + return mana; + } } + diff --git a/src/main/java/vazkii/botania/api/recipe/RecipeMiniFlower.java b/src/main/java/vazkii/botania/api/recipe/RecipeMiniFlower.java index 62932f0b57..92908c0a7e 100644 --- a/src/main/java/vazkii/botania/api/recipe/RecipeMiniFlower.java +++ b/src/main/java/vazkii/botania/api/recipe/RecipeMiniFlower.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Apr 22, 2015, 5:57:59 PM (GMT)] */ package vazkii.botania.api.recipe; @@ -15,20 +15,16 @@ public class RecipeMiniFlower extends RecipeManaInfusion { - public RecipeMiniFlower(String flower, String mini, int mana) { - super( - BotaniaAPI.internalHandler.getSubTileAsStack(flower), - BotaniaAPI.internalHandler.getSubTileAsStack(mini), - mana); - setAlchemy(true); - } + public RecipeMiniFlower(String flower, String mini, int mana) { + super(BotaniaAPI.internalHandler.getSubTileAsStack(flower), BotaniaAPI.internalHandler.getSubTileAsStack(mini), mana); + setAlchemy(true); + } + + @Override + public boolean matches(ItemStack stack) { + String key = BotaniaAPI.internalHandler.getStackSubTileKey(stack); + String input = this.input instanceof String ? (String) this.input : BotaniaAPI.internalHandler.getStackSubTileKey((ItemStack) this.input); + return key != null && key.equals(input); + } - @Override - public boolean matches(ItemStack stack) { - String key = BotaniaAPI.internalHandler.getStackSubTileKey(stack); - String input = this.input instanceof String - ? (String) this.input - : BotaniaAPI.internalHandler.getStackSubTileKey((ItemStack) this.input); - return key != null && key.equals(input); - } } diff --git a/src/main/java/vazkii/botania/api/recipe/RecipePetals.java b/src/main/java/vazkii/botania/api/recipe/RecipePetals.java index d2f54060e4..60e46357fb 100644 --- a/src/main/java/vazkii/botania/api/recipe/RecipePetals.java +++ b/src/main/java/vazkii/botania/api/recipe/RecipePetals.java @@ -2,86 +2,95 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jan 22, 2014, 2:02:44 PM (GMT)] */ package vazkii.botania.api.recipe; import java.util.ArrayList; import java.util.List; + import net.minecraft.inventory.IInventory; import net.minecraft.item.ItemStack; import net.minecraftforge.oredict.OreDictionary; public class RecipePetals { - ItemStack output; - List inputs; - - public RecipePetals(ItemStack output, Object... inputs) { - this.output = output; - - List inputsToSet = new ArrayList(); - for (Object obj : inputs) { - if (obj instanceof String || obj instanceof ItemStack) inputsToSet.add(obj); - else throw new IllegalArgumentException("Invalid input"); - } - - this.inputs = inputsToSet; - } - - public boolean matches(IInventory inv) { - List inputsMissing = new ArrayList(inputs); - - for (int i = 0; i < inv.getSizeInventory(); i++) { - ItemStack stack = inv.getStackInSlot(i); - if (stack == null) break; - - int stackIndex = -1, oredictIndex = -1; - - for (int j = 0; j < inputsMissing.size(); j++) { - Object input = inputsMissing.get(j); - if (input instanceof String) { - List validStacks = OreDictionary.getOres((String) input); - boolean found = false; - for (ItemStack ostack : validStacks) { - ItemStack cstack = ostack.copy(); - if (cstack.getItemDamage() == Short.MAX_VALUE) cstack.setItemDamage(stack.getItemDamage()); - - if (stack.isItemEqual(cstack)) { - oredictIndex = j; - found = true; - break; - } - } - - if (found) break; - } else if (input instanceof ItemStack && simpleAreStacksEqual((ItemStack) input, stack)) { - stackIndex = j; - break; - } - } - - if (stackIndex != -1) inputsMissing.remove(stackIndex); - else if (oredictIndex != -1) inputsMissing.remove(oredictIndex); - else return false; - } - - return inputsMissing.isEmpty(); - } - - boolean simpleAreStacksEqual(ItemStack stack, ItemStack stack2) { - return stack.getItem() == stack2.getItem() && stack.getItemDamage() == stack2.getItemDamage(); - } - - public List getInputs() { - return new ArrayList(inputs); - } - - public ItemStack getOutput() { - return output; - } + ItemStack output; + List inputs; + + public RecipePetals(ItemStack output, Object... inputs) { + this.output = output; + + List inputsToSet = new ArrayList(); + for(Object obj : inputs) { + if(obj instanceof String || obj instanceof ItemStack) + inputsToSet.add(obj); + else throw new IllegalArgumentException("Invalid input"); + } + + this.inputs = inputsToSet; + } + + public boolean matches(IInventory inv) { + List inputsMissing = new ArrayList(inputs); + + for(int i = 0; i < inv.getSizeInventory(); i++) { + ItemStack stack = inv.getStackInSlot(i); + if(stack == null) + break; + + int stackIndex = -1, oredictIndex = -1; + + for(int j = 0; j < inputsMissing.size(); j++) { + Object input = inputsMissing.get(j); + if(input instanceof String) { + List validStacks = OreDictionary.getOres((String) input); + boolean found = false; + for(ItemStack ostack : validStacks) { + ItemStack cstack = ostack.copy(); + if(cstack.getItemDamage() == Short.MAX_VALUE) + cstack.setItemDamage(stack.getItemDamage()); + + if(stack.isItemEqual(cstack)) { + oredictIndex = j; + found = true; + break; + } + } + + + if(found) + break; + } else if(input instanceof ItemStack && simpleAreStacksEqual((ItemStack) input, stack)) { + stackIndex = j; + break; + } + } + + if(stackIndex != -1) + inputsMissing.remove(stackIndex); + else if(oredictIndex != -1) + inputsMissing.remove(oredictIndex); + else return false; + } + + return inputsMissing.isEmpty(); + } + + boolean simpleAreStacksEqual(ItemStack stack, ItemStack stack2) { + return stack.getItem() == stack2.getItem() && stack.getItemDamage() == stack2.getItemDamage(); + } + + public List getInputs() { + return new ArrayList(inputs); + } + + public ItemStack getOutput() { + return output; + } + } diff --git a/src/main/java/vazkii/botania/api/recipe/RecipePureDaisy.java b/src/main/java/vazkii/botania/api/recipe/RecipePureDaisy.java index d3cedc6abe..19248e69bd 100644 --- a/src/main/java/vazkii/botania/api/recipe/RecipePureDaisy.java +++ b/src/main/java/vazkii/botania/api/recipe/RecipePureDaisy.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Apr 17, 2015, 5:07:25 PM (GMT)] */ package vazkii.botania.api.recipe; @@ -13,6 +13,7 @@ import java.util.HashMap; import java.util.List; import java.util.Map; + import net.minecraft.block.Block; import net.minecraft.item.ItemStack; import net.minecraft.world.World; @@ -21,71 +22,78 @@ public class RecipePureDaisy { - private static final Map> oreMap = new HashMap(); - - Object input; - Block output; - int outputMeta; - - public RecipePureDaisy(Object input, Block output, int outputMeta) { - this.input = input; - this.output = output; - this.outputMeta = outputMeta; - - if (input != null && !(input instanceof String || input instanceof Block)) - throw new IllegalArgumentException("input must be an oredict String or a Block."); - } - - /** - * This gets called every tick, please be careful with your checks. - */ - public boolean matches(World world, int x, int y, int z, SubTileEntity pureDaisy, Block block, int meta) { - if (input instanceof Block) return block == input; - - ItemStack stack = new ItemStack(block, 1, meta); - String oredict = (String) input; - return isOreDict(stack, oredict); - } - - public boolean isOreDict(ItemStack stack, String entry) { - if (stack == null || stack.getItem() == null) return false; - - List ores; - if (oreMap.containsKey(entry)) ores = oreMap.get(entry); - else { - ores = OreDictionary.getOres(entry); - oreMap.put(entry, ores); - } - - for (ItemStack ostack : ores) { - ItemStack cstack = ostack.copy(); - if (cstack.getItemDamage() == Short.MAX_VALUE) cstack.setItemDamage(stack.getItemDamage()); - - if (stack.isItemEqual(cstack)) return true; - } - - return false; - } - - /** - * Returns true if the block was placed (and if the Pure Daisy should do particles and stuffs). - * Should only place the block if !world.isRemote, but should return true if it would've placed - * it otherwise. You may return false to cancel the normal particles and do your own. - */ - public boolean set(World world, int x, int y, int z, SubTileEntity pureDaisy) { - if (!world.isRemote) world.setBlock(x, y, z, output, outputMeta, 1 | 2); - return true; - } - - public Object getInput() { - return input; - } - - public Block getOutput() { - return output; - } - - public int getOutputMeta() { - return outputMeta; - } + private static final Map> oreMap = new HashMap(); + + Object input; + Block output; + int outputMeta; + + public RecipePureDaisy(Object input, Block output, int outputMeta) { + this.input = input; + this.output = output; + this.outputMeta = outputMeta; + + if(input != null && !(input instanceof String || input instanceof Block)) + throw new IllegalArgumentException("input must be an oredict String or a Block."); + } + + /** + * This gets called every tick, please be careful with your checks. + */ + public boolean matches(World world, int x, int y, int z, SubTileEntity pureDaisy, Block block, int meta) { + if(input instanceof Block) + return block == input; + + ItemStack stack = new ItemStack(block, 1, meta); + String oredict = (String) input; + return isOreDict(stack, oredict); + } + + public boolean isOreDict(ItemStack stack, String entry) { + if(stack == null || stack.getItem() == null) + return false; + + List ores; + if(oreMap.containsKey(entry)) + ores = oreMap.get(entry); + else { + ores = OreDictionary.getOres(entry); + oreMap.put(entry, ores); + } + + for(ItemStack ostack : ores) { + ItemStack cstack = ostack.copy(); + if(cstack.getItemDamage() == Short.MAX_VALUE) + cstack.setItemDamage(stack.getItemDamage()); + + if(stack.isItemEqual(cstack)) + return true; + } + + return false; + } + + /** + * Returns true if the block was placed (and if the Pure Daisy should do particles and stuffs). + * Should only place the block if !world.isRemote, but should return true if it would've placed + * it otherwise. You may return false to cancel the normal particles and do your own. + */ + public boolean set(World world, int x, int y, int z, SubTileEntity pureDaisy) { + if(!world.isRemote) + world.setBlock(x, y, z, output, outputMeta, 1 | 2); + return true; + } + + public Object getInput() { + return input; + } + + public Block getOutput() { + return output; + } + + public int getOutputMeta() { + return outputMeta; + } + } diff --git a/src/main/java/vazkii/botania/api/recipe/RecipeRuneAltar.java b/src/main/java/vazkii/botania/api/recipe/RecipeRuneAltar.java index 9036f19a7c..f8bb211c10 100644 --- a/src/main/java/vazkii/botania/api/recipe/RecipeRuneAltar.java +++ b/src/main/java/vazkii/botania/api/recipe/RecipeRuneAltar.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Feb 5, 2014, 1:41:14 PM (GMT)] */ package vazkii.botania.api.recipe; @@ -14,14 +14,15 @@ public class RecipeRuneAltar extends RecipePetals { - int mana; + int mana; - public RecipeRuneAltar(ItemStack output, int mana, Object... inputs) { - super(output, inputs); - this.mana = mana; - } + public RecipeRuneAltar(ItemStack output, int mana, Object... inputs) { + super(output, inputs); + this.mana = mana; + } + + public int getManaUsage() { + return mana; + } - public int getManaUsage() { - return mana; - } } diff --git a/src/main/java/vazkii/botania/api/subtile/ISpecialFlower.java b/src/main/java/vazkii/botania/api/subtile/ISpecialFlower.java index 862670509f..3bca4313c1 100644 --- a/src/main/java/vazkii/botania/api/subtile/ISpecialFlower.java +++ b/src/main/java/vazkii/botania/api/subtile/ISpecialFlower.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jan 22, 2014, 7:12:28 PM (GMT)] */ package vazkii.botania.api.subtile; @@ -15,4 +15,6 @@ * BlockFlower would be checked against, but isn't convenient for * the special flowers with effects. For Azanor and Lycaon. */ -public interface ISpecialFlower {} +public interface ISpecialFlower { + +} diff --git a/src/main/java/vazkii/botania/api/subtile/ISubTileContainer.java b/src/main/java/vazkii/botania/api/subtile/ISubTileContainer.java index a36b7accea..3a99d6d868 100644 --- a/src/main/java/vazkii/botania/api/subtile/ISubTileContainer.java +++ b/src/main/java/vazkii/botania/api/subtile/ISubTileContainer.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Aug 26, 2014, 5:42:16 PM (GMT)] */ package vazkii.botania.api.subtile; @@ -15,14 +15,15 @@ */ public interface ISubTileContainer { - /** - * Gets the SubTile in this block. Generally shouldn't return null, but in that - * case use the fallback DummySubTile. - */ - public SubTileEntity getSubTile(); + /** + * Gets the SubTile in this block. Generally shouldn't return null, but in that + * case use the fallback DummySubTile. + */ + public SubTileEntity getSubTile(); + + /** + * Sets the SubTile on this block from it's name. + */ + public void setSubTile(String name); - /** - * Sets the SubTile on this block from it's name. - */ - public void setSubTile(String name); } diff --git a/src/main/java/vazkii/botania/api/subtile/ISubTileSlowableContainer.java b/src/main/java/vazkii/botania/api/subtile/ISubTileSlowableContainer.java index 1fa0e00905..6092cd618c 100644 --- a/src/main/java/vazkii/botania/api/subtile/ISubTileSlowableContainer.java +++ b/src/main/java/vazkii/botania/api/subtile/ISubTileSlowableContainer.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [29/12/2015, 23:00:06 (GMT)] */ package vazkii.botania.api.subtile; @@ -18,8 +18,9 @@ */ public interface ISubTileSlowableContainer extends ISubTileContainer { - public static final int SLOWDOWN_FACTOR_PODZOL = 5; - public static final int SLOWDOWN_FACTOR_MYCEL = 10; - - public int getSlowdownFactor(); + public static final int SLOWDOWN_FACTOR_PODZOL = 5; + public static final int SLOWDOWN_FACTOR_MYCEL = 10; + + public int getSlowdownFactor(); + } diff --git a/src/main/java/vazkii/botania/api/subtile/RadiusDescriptor.java b/src/main/java/vazkii/botania/api/subtile/RadiusDescriptor.java index 0d5f01ab03..f57b6fa71d 100644 --- a/src/main/java/vazkii/botania/api/subtile/RadiusDescriptor.java +++ b/src/main/java/vazkii/botania/api/subtile/RadiusDescriptor.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Mar 31, 2015, 2:59:19 PM (GMT)] */ package vazkii.botania.api.subtile; @@ -19,75 +19,71 @@ */ public class RadiusDescriptor { - final ChunkCoordinates subtileCoords; - - public RadiusDescriptor(ChunkCoordinates subtileCoords) { - this.subtileCoords = subtileCoords; - } - - public ChunkCoordinates getSubtileCoords() { - return subtileCoords; - } - - public boolean isCircle() { - return false; - } - - public double getCircleRadius() { - return 0; - } - - public AxisAlignedBB getAABB() { - return null; - } - - public static class Circle extends RadiusDescriptor { - - final double radius; - - public Circle(ChunkCoordinates subtileCoords, double radius) { - super(subtileCoords); - this.radius = radius; - } - - @Override - public boolean isCircle() { - return true; - } - - @Override - public double getCircleRadius() { - return radius; - } - } - - public static class Rectangle extends RadiusDescriptor { - - final AxisAlignedBB aabb; - - public Rectangle(ChunkCoordinates subtileCoords, AxisAlignedBB aabb) { - super(subtileCoords); - this.aabb = aabb; - } - - @Override - public AxisAlignedBB getAABB() { - return aabb; - } - } - - public static class Square extends Rectangle { - - public Square(ChunkCoordinates subtileCoords, int expand) { - super( - subtileCoords, - AxisAlignedBB.getBoundingBox( - subtileCoords.posX - expand, - subtileCoords.posY, - subtileCoords.posZ - expand, - subtileCoords.posX + 1 + expand, - subtileCoords.posY, - subtileCoords.posZ + 1 + expand)); - } - } + final ChunkCoordinates subtileCoords; + + public RadiusDescriptor(ChunkCoordinates subtileCoords) { + this.subtileCoords = subtileCoords; + } + + public ChunkCoordinates getSubtileCoords() { + return subtileCoords; + } + + public boolean isCircle() { + return false; + } + + public double getCircleRadius() { + return 0; + } + + public AxisAlignedBB getAABB() { + return null; + } + + public static class Circle extends RadiusDescriptor { + + final double radius; + + public Circle(ChunkCoordinates subtileCoords, double radius) { + super(subtileCoords); + this.radius = radius; + } + + @Override + public boolean isCircle() { + return true; + } + + @Override + public double getCircleRadius() { + return radius; + } + + } + + public static class Rectangle extends RadiusDescriptor { + + final AxisAlignedBB aabb; + + public Rectangle(ChunkCoordinates subtileCoords, AxisAlignedBB aabb) { + super(subtileCoords); + this.aabb = aabb; + } + + @Override + public AxisAlignedBB getAABB() { + return aabb; + } + + } + + public static class Square extends Rectangle { + + public Square(ChunkCoordinates subtileCoords, int expand) { + super(subtileCoords, AxisAlignedBB.getBoundingBox(subtileCoords.posX - expand, subtileCoords.posY, subtileCoords.posZ - expand, subtileCoords.posX + 1 + expand, subtileCoords.posY, subtileCoords.posZ + 1 + expand)); + } + + } + } diff --git a/src/main/java/vazkii/botania/api/subtile/SubTileEntity.java b/src/main/java/vazkii/botania/api/subtile/SubTileEntity.java index ad16ca6df4..2b98121c16 100644 --- a/src/main/java/vazkii/botania/api/subtile/SubTileEntity.java +++ b/src/main/java/vazkii/botania/api/subtile/SubTileEntity.java @@ -2,17 +2,16 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jan 24, 2014, 3:59:06 PM (GMT)] */ package vazkii.botania.api.subtile; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; import java.util.ArrayList; + import net.minecraft.client.Minecraft; import net.minecraft.client.gui.ScaledResolution; import net.minecraft.entity.EntityLivingBase; @@ -27,6 +26,8 @@ import vazkii.botania.api.internal.VanillaPacketDispatcher; import vazkii.botania.api.lexicon.LexiconEntry; import vazkii.botania.api.wand.IWandBindable; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; /** * A Sub-TileEntity, this is used for the flower system. Make sure to map subclasses @@ -35,209 +36,208 @@ */ public class SubTileEntity { - protected TileEntity supertile; - - public int ticksExisted = 0; - - /** true if this flower is working on Enchanted Soil **/ - public boolean overgrowth = false; - /** true if this flower is working on Enchanted Soil and this is the second tick **/ - public boolean overgrowthBoost = false; - - /** The Tag items should use to store which sub tile they are. **/ - public static final String TAG_TYPE = "type"; - - public static final String TAG_TICKS_EXISTED = "ticksExisted"; - - public void setSupertile(TileEntity tile) { - supertile = tile; - } - - public boolean canUpdate() { - return true; - } - - public void onUpdate() { - ticksExisted++; - } - - public final void writeToPacketNBTInternal(NBTTagCompound cmp) { - cmp.setInteger(TAG_TICKS_EXISTED, ticksExisted); - writeToPacketNBT(cmp); - } - - public final void readFromPacketNBTInternal(NBTTagCompound cmp) { - if (cmp.hasKey(TAG_TICKS_EXISTED)) ticksExisted = cmp.getInteger(TAG_TICKS_EXISTED); - readFromPacketNBT(cmp); - } - - /** - * Writes some extra data to a network packet. This data is read - * by readFromPacketNBT on the client that receives the packet. - * Note: This method is also used to write to the world NBT. - */ - public void writeToPacketNBT(NBTTagCompound cmp) {} - - /** - * Reads data from a network packet. This data is written by - * writeToPacketNBT in the server. Note: This method is also used - * to read from the world NBT. - */ - public void readFromPacketNBT(NBTTagCompound cmp) {} - - public void sync() { - VanillaPacketDispatcher.dispatchTEToNearbyPlayers(supertile); - } - - public String getUnlocalizedName() { - return BotaniaAPI.getSubTileStringMapping(getClass()); - } - - /** - * Gets the icon for this SubTileEntity, this is a block icon. - */ - @SideOnly(Side.CLIENT) - public IIcon getIcon() { - return BotaniaAPI.internalHandler.getSubTileIconForName(getUnlocalizedName()); - } - - /** - * Called when a Wand of the Forest is used on this sub tile. Note that the - * player parameter can be null if this is called from a dispenser. - */ - public boolean onWanded(EntityPlayer player, ItemStack wand) { - return false; - } - - /** - * Called when this sub tile is placed in the world (by an entity). - */ - public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase entity, ItemStack stack) { - // NO-OP - } - - /** - * Called when a player right clicks this sub tile. - */ - public boolean onBlockActivated( - World world, int x, int y, int z, EntityPlayer player, int side, float hitX, float hitY, float hitZ) { - return false; - } - - /** - * Called when this sub tile is added to the world. - */ - public void onBlockAdded(World world, int x, int y, int z) { - // NO-OP - } - - /** - * Called when this sub tile is harvested - */ - public void onBlockHarvested(World world, int x, int y, int z, int side, EntityPlayer player) { - // NO-OP - } - - /** - * Allows additional processing of sub tile drops - */ - public ArrayList getDrops(ArrayList list) { - return list; - } - - /** - * Gets which Lexicon Entry to open when this sub tile is right clicked with a lexicon. - */ - public LexiconEntry getEntry() { - return null; - } - - /** - * Gets the block coordinates this is bound to, for use with the wireframe render - * when the sub tile is being hovered with a wand of the forest. - */ - @SideOnly(Side.CLIENT) - public ChunkCoordinates getBinding() { - return null; - } - - /** - * Returns a descriptor for the radius of this sub tile. This is called while a player - * is looking at the block with a Manaseer Monocle (IBurstViewerBauble). - */ - @SideOnly(Side.CLIENT) - public RadiusDescriptor getRadius() { - return null; - } - - /** - * Gets a ChunkCoordinates instance with the position of this sub tile. - */ - public ChunkCoordinates toChunkCoordinates() { - return new ChunkCoordinates(supertile.xCoord, supertile.yCoord, supertile.zCoord); - } - - /** - * @see IWandBindable#canSelect(EntityPlayer, ItemStack, int, int, int, int) - */ - public boolean canSelect(EntityPlayer player, ItemStack wand, int x, int y, int z, int side) { - return false; - } - - /** - * @see IWandBindable#bindTo(EntityPlayer, ItemStack, int, int, int, int) - */ - public boolean bindTo(EntityPlayer player, ItemStack wand, int x, int y, int z, int side) { - return false; - } - - /** - * Called on the client when the block being pointed at is the one with this sub tile. - * Used to render a HUD portraying some data from this sub tile. - */ - @SideOnly(Side.CLIENT) - public void renderHUD(Minecraft mc, ScaledResolution res) { - // NO-OP - } - - /** - * Gets the light value for this SubTileEntity, this is a int (-1 to default to the flower) - */ - public int getLightValue() { - return -1; - } - - /** - * Gets the comparator input value for this SubTileEntity - */ - public int getComparatorInputOverride(int side) { - return 0; - } - - /** - * Gets the redstone power level for this SubTileEntity - */ - public int getPowerLevel(int side) { - return 0; - } - - /** - * Gets if this SubTileEntity is affected by Enchanted Soil's speed boost. - */ - public boolean isOvergrowthAffected() { - return true; - } - - /** - * Gets ths slowdown factor of this SubTile. - * @see ISubTileSlowableContainer - */ - public int getSlowdownFactor() { - if (supertile instanceof ISubTileSlowableContainer) { - ISubTileSlowableContainer slowable = (ISubTileSlowableContainer) supertile; - return slowable.getSlowdownFactor(); - } - - return 0; - } + protected TileEntity supertile; + + public int ticksExisted = 0; + + /** true if this flower is working on Enchanted Soil **/ + public boolean overgrowth = false; + /** true if this flower is working on Enchanted Soil and this is the second tick **/ + public boolean overgrowthBoost = false; + + /** The Tag items should use to store which sub tile they are. **/ + public static final String TAG_TYPE = "type"; + public static final String TAG_TICKS_EXISTED = "ticksExisted"; + + public void setSupertile(TileEntity tile) { + supertile = tile; + } + + public boolean canUpdate() { + return true; + } + + public void onUpdate() { + ticksExisted++; + } + + public final void writeToPacketNBTInternal(NBTTagCompound cmp) { + cmp.setInteger(TAG_TICKS_EXISTED, ticksExisted); + writeToPacketNBT(cmp); + } + + public final void readFromPacketNBTInternal(NBTTagCompound cmp) { + if(cmp.hasKey(TAG_TICKS_EXISTED)) + ticksExisted = cmp.getInteger(TAG_TICKS_EXISTED); + readFromPacketNBT(cmp); + } + + /** + * Writes some extra data to a network packet. This data is read + * by readFromPacketNBT on the client that receives the packet. + * Note: This method is also used to write to the world NBT. + */ + public void writeToPacketNBT(NBTTagCompound cmp) { } + + /** + * Reads data from a network packet. This data is written by + * writeToPacketNBT in the server. Note: This method is also used + * to read from the world NBT. + */ + public void readFromPacketNBT(NBTTagCompound cmp) { } + + public void sync() { + VanillaPacketDispatcher.dispatchTEToNearbyPlayers(supertile); + } + + public String getUnlocalizedName() { + return BotaniaAPI.getSubTileStringMapping(getClass()); + } + + /** + * Gets the icon for this SubTileEntity, this is a block icon. + */ + @SideOnly(Side.CLIENT) + public IIcon getIcon() { + return BotaniaAPI.internalHandler.getSubTileIconForName(getUnlocalizedName()); + } + + /** + * Called when a Wand of the Forest is used on this sub tile. Note that the + * player parameter can be null if this is called from a dispenser. + */ + public boolean onWanded(EntityPlayer player, ItemStack wand) { + return false; + } + + /** + * Called when this sub tile is placed in the world (by an entity). + */ + public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase entity, ItemStack stack) { + // NO-OP + } + + /** + * Called when a player right clicks this sub tile. + */ + public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int side, float hitX, float hitY, float hitZ) { return false; } + + /** + * Called when this sub tile is added to the world. + */ + public void onBlockAdded(World world, int x, int y, int z) { + //NO-OP + } + + /** + * Called when this sub tile is harvested + */ + public void onBlockHarvested(World world, int x, int y, int z, int side, EntityPlayer player) { + //NO-OP + } + + /** + * Allows additional processing of sub tile drops + */ + public ArrayList getDrops(ArrayList list) { + return list; + } + + /** + * Gets which Lexicon Entry to open when this sub tile is right clicked with a lexicon. + */ + public LexiconEntry getEntry() { + return null; + } + + /** + * Gets the block coordinates this is bound to, for use with the wireframe render + * when the sub tile is being hovered with a wand of the forest. + */ + @SideOnly(Side.CLIENT) + public ChunkCoordinates getBinding() { + return null; + } + + /** + * Returns a descriptor for the radius of this sub tile. This is called while a player + * is looking at the block with a Manaseer Monocle (IBurstViewerBauble). + */ + @SideOnly(Side.CLIENT) + public RadiusDescriptor getRadius() { + return null; + } + + /** + * Gets a ChunkCoordinates instance with the position of this sub tile. + */ + public ChunkCoordinates toChunkCoordinates() { + return new ChunkCoordinates(supertile.xCoord, supertile.yCoord, supertile.zCoord); + } + + /** + * @see IWandBindable#canSelect(EntityPlayer, ItemStack, int, int, int, int) + */ + public boolean canSelect(EntityPlayer player, ItemStack wand, int x, int y, int z, int side) { + return false; + } + + /** + * @see IWandBindable#bindTo(EntityPlayer, ItemStack, int, int, int, int) + */ + public boolean bindTo(EntityPlayer player, ItemStack wand, int x, int y, int z, int side) { + return false; + } + + /** + * Called on the client when the block being pointed at is the one with this sub tile. + * Used to render a HUD portraying some data from this sub tile. + */ + @SideOnly(Side.CLIENT) + public void renderHUD(Minecraft mc, ScaledResolution res) { + // NO-OP + } + + /** + * Gets the light value for this SubTileEntity, this is a int (-1 to default to the flower) + */ + public int getLightValue() { + return -1; + } + + /** + * Gets the comparator input value for this SubTileEntity + */ + public int getComparatorInputOverride(int side) { + return 0; + } + + /** + * Gets the redstone power level for this SubTileEntity + */ + public int getPowerLevel(int side) { + return 0; + } + + /** + * Gets if this SubTileEntity is affected by Enchanted Soil's speed boost. + */ + public boolean isOvergrowthAffected() { + return true; + } + + /** + * Gets ths slowdown factor of this SubTile. + * @see ISubTileSlowableContainer + */ + public int getSlowdownFactor() { + if(supertile instanceof ISubTileSlowableContainer) { + ISubTileSlowableContainer slowable = (ISubTileSlowableContainer) supertile; + return slowable.getSlowdownFactor(); + } + + return 0; + } + + } diff --git a/src/main/java/vazkii/botania/api/subtile/SubTileFunctional.java b/src/main/java/vazkii/botania/api/subtile/SubTileFunctional.java index ad8df9a391..d6156eafed 100644 --- a/src/main/java/vazkii/botania/api/subtile/SubTileFunctional.java +++ b/src/main/java/vazkii/botania/api/subtile/SubTileFunctional.java @@ -2,15 +2,16 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jan 24, 2014, 8:03:44 PM (GMT)] */ package vazkii.botania.api.subtile; import java.awt.Color; + import net.minecraft.client.Minecraft; import net.minecraft.client.gui.ScaledResolution; import net.minecraft.entity.player.EntityPlayer; @@ -29,221 +30,191 @@ */ public class SubTileFunctional extends SubTileEntity { - public static final int RANGE = 10; - - private static final String TAG_MANA = "mana"; - - private static final String TAG_POOL_X = "poolX"; - private static final String TAG_POOL_Y = "poolY"; - private static final String TAG_POOL_Z = "poolZ"; - - public int mana; - - public int redstoneSignal = 0; - - int sizeLastCheck = -1; - TileEntity linkedPool = null; - public int knownMana = -1; - - ChunkCoordinates cachedPoolCoordinates = null; - - /** - * If set to true, redstoneSignal will be updated every tick. - */ - public boolean acceptsRedstone() { - return false; - } - - @Override - public void onUpdate() { - super.onUpdate(); - - linkPool(); - - if (linkedPool != null && isValidBinding()) { - IManaPool pool = (IManaPool) linkedPool; - int manaInPool = pool.getCurrentMana(); - int manaMissing = getMaxMana() - mana; - int manaToRemove = Math.min(manaMissing, manaInPool); - pool.recieveMana(-manaToRemove); - addMana(manaToRemove); - } - - if (acceptsRedstone()) { - redstoneSignal = 0; - for (ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS) { - int redstoneSide = supertile - .getWorldObj() - .getIndirectPowerLevelTo( - supertile.xCoord + dir.offsetX, - supertile.yCoord + dir.offsetY, - supertile.zCoord + dir.offsetZ, - dir.ordinal()); - redstoneSignal = Math.max(redstoneSignal, redstoneSide); - } - } - - if (supertile.getWorldObj().isRemote) { - double particleChance = 1F - (double) mana / (double) getMaxMana() / 3.5F; - Color color = new Color(getColor()); - if (Math.random() > particleChance) - BotaniaAPI.internalHandler.sparkleFX( - supertile.getWorldObj(), - supertile.xCoord + 0.3 + Math.random() * 0.5, - supertile.yCoord + 0.5 + Math.random() * 0.5, - supertile.zCoord + 0.3 + Math.random() * 0.5, - color.getRed() / 255F, - color.getGreen() / 255F, - color.getBlue() / 255F, - (float) Math.random(), - 5); - } - } - - public void linkPool() { - boolean needsNew = false; - if (linkedPool == null) { - needsNew = true; - - if (cachedPoolCoordinates != null) { - needsNew = false; - if (supertile - .getWorldObj() - .blockExists( - cachedPoolCoordinates.posX, cachedPoolCoordinates.posY, cachedPoolCoordinates.posZ)) { - needsNew = true; - TileEntity tileAt = supertile - .getWorldObj() - .getTileEntity( - cachedPoolCoordinates.posX, cachedPoolCoordinates.posY, cachedPoolCoordinates.posZ); - if (tileAt != null && tileAt instanceof IManaPool && !tileAt.isInvalid()) { - linkedPool = tileAt; - needsNew = false; - } - cachedPoolCoordinates = null; - } - } - } else { - TileEntity tileAt = - supertile.getWorldObj().getTileEntity(linkedPool.xCoord, linkedPool.yCoord, linkedPool.zCoord); - if (tileAt != null && tileAt instanceof IManaPool) linkedPool = tileAt; - } - - if (needsNew && ticksExisted == 1) { // Only for new flowers - IManaNetwork network = BotaniaAPI.internalHandler.getManaNetworkInstance(); - int size = network.getAllPoolsInWorld(supertile.getWorldObj()).size(); - if (BotaniaAPI.internalHandler.shouldForceCheck() || size != sizeLastCheck) { - ChunkCoordinates coords = new ChunkCoordinates(supertile.xCoord, supertile.yCoord, supertile.zCoord); - linkedPool = network.getClosestPool(coords, supertile.getWorldObj(), RANGE); - sizeLastCheck = size; - } - } - } - - public void linkToForcefully(TileEntity pool) { - linkedPool = pool; - } - - public void addMana(int mana) { - this.mana = Math.min(getMaxMana(), this.mana + mana); - } - - @Override - public boolean onWanded(EntityPlayer player, ItemStack wand) { - if (player == null) return false; - - knownMana = mana; - player.worldObj.playSoundAtEntity(player, "botania:ding", 0.1F, 1F); - - return super.onWanded(player, wand); - } - - public int getMaxMana() { - return 20; - } - - public int getColor() { - return 0xFFFFFF; - } - - @Override - public void readFromPacketNBT(NBTTagCompound cmp) { - mana = cmp.getInteger(TAG_MANA); - - int x = cmp.getInteger(TAG_POOL_X); - int y = cmp.getInteger(TAG_POOL_Y); - int z = cmp.getInteger(TAG_POOL_Z); - - cachedPoolCoordinates = y < 0 ? null : new ChunkCoordinates(x, y, z); - } - - @Override - public void writeToPacketNBT(NBTTagCompound cmp) { - cmp.setInteger(TAG_MANA, mana); - - if (cachedPoolCoordinates != null) { - cmp.setInteger(TAG_POOL_X, cachedPoolCoordinates.posX); - cmp.setInteger(TAG_POOL_Y, cachedPoolCoordinates.posY); - cmp.setInteger(TAG_POOL_Z, cachedPoolCoordinates.posZ); - } else { - int x = linkedPool == null ? 0 : linkedPool.xCoord; - int y = linkedPool == null ? -1 : linkedPool.yCoord; - int z = linkedPool == null ? 0 : linkedPool.zCoord; - - cmp.setInteger(TAG_POOL_X, x); - cmp.setInteger(TAG_POOL_Y, y); - cmp.setInteger(TAG_POOL_Z, z); - } - } - - @Override - public ChunkCoordinates getBinding() { - if (linkedPool == null) return null; - return new ChunkCoordinates(linkedPool.xCoord, linkedPool.yCoord, linkedPool.zCoord); - } - - @Override - public boolean canSelect(EntityPlayer player, ItemStack wand, int x, int y, int z, int side) { - return true; - } - - @Override - public boolean bindTo(EntityPlayer player, ItemStack wand, int x, int y, int z, int side) { - int range = 10; - range *= range; - - double dist = (x - supertile.xCoord) * (x - supertile.xCoord) - + (y - supertile.yCoord) * (y - supertile.yCoord) - + (z - supertile.zCoord) * (z - supertile.zCoord); - if (range >= dist) { - TileEntity tile = player.worldObj.getTileEntity(x, y, z); - if (tile instanceof IManaPool) { - linkedPool = tile; - return true; - } - } - - return false; - } - - public boolean isValidBinding() { - return linkedPool != null - && !linkedPool.isInvalid() - && supertile.getWorldObj().getTileEntity(linkedPool.xCoord, linkedPool.yCoord, linkedPool.zCoord) - == linkedPool; - } - - @Override - public void renderHUD(Minecraft mc, ScaledResolution res) { - String name = StatCollector.translateToLocal("tile.botania:flower." + getUnlocalizedName() + ".name"); - int color = getColor(); - BotaniaAPI.internalHandler.drawComplexManaHUD( - color, - knownMana, - getMaxMana(), - name, - res, - BotaniaAPI.internalHandler.getBindDisplayForFlowerType(this), - isValidBinding()); - } + public static final int RANGE = 10; + + private static final String TAG_MANA = "mana"; + + private static final String TAG_POOL_X = "poolX"; + private static final String TAG_POOL_Y = "poolY"; + private static final String TAG_POOL_Z = "poolZ"; + + public int mana; + + public int redstoneSignal = 0; + + int sizeLastCheck = -1; + TileEntity linkedPool = null; + public int knownMana = -1; + + ChunkCoordinates cachedPoolCoordinates = null; + + /** + * If set to true, redstoneSignal will be updated every tick. + */ + public boolean acceptsRedstone() { + return false; + } + + @Override + public void onUpdate() { + super.onUpdate(); + + linkPool(); + + if(linkedPool != null && isValidBinding()) { + IManaPool pool = (IManaPool) linkedPool; + int manaInPool = pool.getCurrentMana(); + int manaMissing = getMaxMana() - mana; + int manaToRemove = Math.min(manaMissing, manaInPool); + pool.recieveMana(-manaToRemove); + addMana(manaToRemove); + } + + if(acceptsRedstone()) { + redstoneSignal = 0; + for(ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS) { + int redstoneSide = supertile.getWorldObj().getIndirectPowerLevelTo(supertile.xCoord + dir.offsetX, supertile.yCoord + dir.offsetY, supertile.zCoord + dir.offsetZ, dir.ordinal()); + redstoneSignal = Math.max(redstoneSignal, redstoneSide); + } + } + + if(supertile.getWorldObj().isRemote) { + double particleChance = 1F - (double) mana / (double) getMaxMana() / 3.5F; + Color color = new Color(getColor()); + if(Math.random() > particleChance) + BotaniaAPI.internalHandler.sparkleFX(supertile.getWorldObj(), supertile.xCoord + 0.3 + Math.random() * 0.5, supertile.yCoord + 0.5 + Math.random() * 0.5, supertile.zCoord + 0.3 + Math.random() * 0.5, color.getRed() / 255F, color.getGreen() / 255F, color.getBlue() / 255F, (float) Math.random(), 5); + } + } + + public void linkPool() { + boolean needsNew = false; + if(linkedPool == null) { + needsNew = true; + + if(cachedPoolCoordinates != null) { + needsNew = false; + if(supertile.getWorldObj().blockExists(cachedPoolCoordinates.posX, cachedPoolCoordinates.posY, cachedPoolCoordinates.posZ)) { + needsNew = true; + TileEntity tileAt = supertile.getWorldObj().getTileEntity(cachedPoolCoordinates.posX, cachedPoolCoordinates.posY, cachedPoolCoordinates.posZ); + if(tileAt != null && tileAt instanceof IManaPool && !tileAt.isInvalid()) { + linkedPool = tileAt; + needsNew = false; + } + cachedPoolCoordinates = null; + } + } + } else { + TileEntity tileAt = supertile.getWorldObj().getTileEntity(linkedPool.xCoord, linkedPool.yCoord, linkedPool.zCoord); + if(tileAt != null && tileAt instanceof IManaPool) + linkedPool = tileAt; + } + + if(needsNew && ticksExisted == 1) { // Only for new flowers + IManaNetwork network = BotaniaAPI.internalHandler.getManaNetworkInstance(); + int size = network.getAllPoolsInWorld(supertile.getWorldObj()).size(); + if(BotaniaAPI.internalHandler.shouldForceCheck() || size != sizeLastCheck) { + ChunkCoordinates coords = new ChunkCoordinates(supertile.xCoord, supertile.yCoord, supertile.zCoord); + linkedPool = network.getClosestPool(coords, supertile.getWorldObj(), RANGE); + sizeLastCheck = size; + } + } + } + + public void linkToForcefully(TileEntity pool) { + linkedPool = pool; + } + + public void addMana(int mana) { + this.mana = Math.min(getMaxMana(), this.mana + mana); + } + + @Override + public boolean onWanded(EntityPlayer player, ItemStack wand) { + if(player == null) + return false; + + knownMana = mana; + player.worldObj.playSoundAtEntity(player, "botania:ding", 0.1F, 1F); + + return super.onWanded(player, wand); + } + + public int getMaxMana() { + return 20; + } + + public int getColor() { + return 0xFFFFFF; + } + + @Override + public void readFromPacketNBT(NBTTagCompound cmp) { + mana = cmp.getInteger(TAG_MANA); + + int x = cmp.getInteger(TAG_POOL_X); + int y = cmp.getInteger(TAG_POOL_Y); + int z = cmp.getInteger(TAG_POOL_Z); + + cachedPoolCoordinates = y < 0 ? null : new ChunkCoordinates(x, y, z); + } + + @Override + public void writeToPacketNBT(NBTTagCompound cmp) { + cmp.setInteger(TAG_MANA, mana); + + if(cachedPoolCoordinates != null) { + cmp.setInteger(TAG_POOL_X, cachedPoolCoordinates.posX); + cmp.setInteger(TAG_POOL_Y, cachedPoolCoordinates.posY); + cmp.setInteger(TAG_POOL_Z, cachedPoolCoordinates.posZ); + } else { + int x = linkedPool == null ? 0 : linkedPool.xCoord; + int y = linkedPool == null ? -1 : linkedPool.yCoord; + int z = linkedPool == null ? 0 : linkedPool.zCoord; + + cmp.setInteger(TAG_POOL_X, x); + cmp.setInteger(TAG_POOL_Y, y); + cmp.setInteger(TAG_POOL_Z, z); + } + } + + @Override + public ChunkCoordinates getBinding() { + if(linkedPool == null) + return null; + return new ChunkCoordinates(linkedPool.xCoord, linkedPool.yCoord, linkedPool.zCoord); + } + + @Override + public boolean canSelect(EntityPlayer player, ItemStack wand, int x, int y, int z, int side) { + return true; + } + + @Override + public boolean bindTo(EntityPlayer player, ItemStack wand, int x, int y, int z, int side) { + int range = 10; + range *= range; + + double dist = (x - supertile.xCoord) * (x - supertile.xCoord) + (y - supertile.yCoord) * (y - supertile.yCoord) + (z - supertile.zCoord) * (z - supertile.zCoord); + if(range >= dist) { + TileEntity tile = player.worldObj.getTileEntity(x, y, z); + if(tile instanceof IManaPool) { + linkedPool = tile; + return true; + } + } + + return false; + } + + public boolean isValidBinding() { + return linkedPool != null && !linkedPool.isInvalid() && supertile.getWorldObj().getTileEntity(linkedPool.xCoord, linkedPool.yCoord, linkedPool.zCoord) == linkedPool; + } + + @Override + public void renderHUD(Minecraft mc, ScaledResolution res) { + String name = StatCollector.translateToLocal("tile.botania:flower." + getUnlocalizedName() + ".name"); + int color = getColor(); + BotaniaAPI.internalHandler.drawComplexManaHUD(color, knownMana, getMaxMana(), name, res, BotaniaAPI.internalHandler.getBindDisplayForFlowerType(this), isValidBinding()); + } + } diff --git a/src/main/java/vazkii/botania/api/subtile/SubTileGenerating.java b/src/main/java/vazkii/botania/api/subtile/SubTileGenerating.java index f9f02d123e..02f7a23afc 100644 --- a/src/main/java/vazkii/botania/api/subtile/SubTileGenerating.java +++ b/src/main/java/vazkii/botania/api/subtile/SubTileGenerating.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jan 24, 2014, 8:03:36 PM (GMT)] */ package vazkii.botania.api.subtile; @@ -13,6 +13,7 @@ import java.awt.Color; import java.util.ArrayList; import java.util.List; + import net.minecraft.block.Block; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.ScaledResolution; @@ -35,329 +36,280 @@ */ public class SubTileGenerating extends SubTileEntity { - public static final int RANGE = 6; - - private static final String TAG_MANA = "mana"; - - private static final String TAG_COLLECTOR_X = "collectorX"; - private static final String TAG_COLLECTOR_Y = "collectorY"; - private static final String TAG_COLLECTOR_Z = "collectorZ"; - private static final String TAG_PASSIVE_DECAY_TICKS = "passiveDecayTicks"; - - protected int mana; - - public int redstoneSignal = 0; - - int sizeLastCheck = -1; - protected TileEntity linkedCollector = null; - public int knownMana = -1; - public int passiveDecayTicks; - - ChunkCoordinates cachedCollectorCoordinates = null; - - /** - * If set to true, redstoneSignal will be updated every tick. - */ - public boolean acceptsRedstone() { - return false; - } - - @Override - public void onUpdate() { - super.onUpdate(); - - linkCollector(); - - if (canGeneratePassively()) { - int delay = getDelayBetweenPassiveGeneration(); - if (delay > 0 && ticksExisted % delay == 0 && !supertile.getWorldObj().isRemote) { - if (shouldSyncPassiveGeneration()) sync(); - addMana(getValueForPassiveGeneration()); - } - } - emptyManaIntoCollector(); - - if (acceptsRedstone()) { - redstoneSignal = 0; - for (ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS) { - int redstoneSide = supertile - .getWorldObj() - .getIndirectPowerLevelTo( - supertile.xCoord + dir.offsetX, - supertile.yCoord + dir.offsetY, - supertile.zCoord + dir.offsetZ, - dir.ordinal()); - redstoneSignal = Math.max(redstoneSignal, redstoneSide); - } - } - - if (supertile.getWorldObj().isRemote) { - double particleChance = 1F - (double) mana / (double) getMaxMana() / 3.5F; - Color color = new Color(getColor()); - if (Math.random() > particleChance) - BotaniaAPI.internalHandler.sparkleFX( - supertile.getWorldObj(), - supertile.xCoord + 0.3 + Math.random() * 0.5, - supertile.yCoord + 0.5 + Math.random() * 0.5, - supertile.zCoord + 0.3 + Math.random() * 0.5, - color.getRed() / 255F, - color.getGreen() / 255F, - color.getBlue() / 255F, - (float) Math.random(), - 5); - } - - boolean passive = isPassiveFlower(); - if (!supertile.getWorldObj().isRemote) { - int muhBalance = BotaniaAPI.internalHandler.getPassiveFlowerDecay(); - - if (passive && muhBalance > 0 && passiveDecayTicks > muhBalance) { - supertile - .getWorldObj() - .playAuxSFX( - 2001, - supertile.xCoord, - supertile.yCoord, - supertile.zCoord, - Block.getIdFromBlock(supertile.getBlockType())); - if (supertile - .getWorldObj() - .getBlock(supertile.xCoord, supertile.yCoord - 1, supertile.zCoord) - .isSideSolid( - supertile.getWorldObj(), - supertile.xCoord, - supertile.yCoord - 1, - supertile.zCoord, - ForgeDirection.UP)) - supertile - .getWorldObj() - .setBlock(supertile.xCoord, supertile.yCoord, supertile.zCoord, Blocks.deadbush); - else supertile.getWorldObj().setBlockToAir(supertile.xCoord, supertile.yCoord, supertile.zCoord); - } - } - - if (!overgrowth && passive) passiveDecayTicks++; - } - - public void linkCollector() { - boolean needsNew = false; - if (linkedCollector == null) { - needsNew = true; - - if (cachedCollectorCoordinates != null) { - needsNew = false; - if (supertile - .getWorldObj() - .blockExists( - cachedCollectorCoordinates.posX, - cachedCollectorCoordinates.posY, - cachedCollectorCoordinates.posZ)) { - needsNew = true; - TileEntity tileAt = supertile - .getWorldObj() - .getTileEntity( - cachedCollectorCoordinates.posX, - cachedCollectorCoordinates.posY, - cachedCollectorCoordinates.posZ); - if (tileAt != null && tileAt instanceof IManaCollector && !tileAt.isInvalid()) { - linkedCollector = tileAt; - needsNew = false; - } - cachedCollectorCoordinates = null; - } - } - } else { - TileEntity tileAt = supertile - .getWorldObj() - .getTileEntity(linkedCollector.xCoord, linkedCollector.yCoord, linkedCollector.zCoord); - if (tileAt != null && tileAt instanceof IManaCollector) linkedCollector = tileAt; - } - - if (needsNew && ticksExisted == 1) { // New flowers only - IManaNetwork network = BotaniaAPI.internalHandler.getManaNetworkInstance(); - int size = network.getAllCollectorsInWorld(supertile.getWorldObj()).size(); - if (BotaniaAPI.internalHandler.shouldForceCheck() || size != sizeLastCheck) { - ChunkCoordinates coords = new ChunkCoordinates(supertile.xCoord, supertile.yCoord, supertile.zCoord); - linkedCollector = network.getClosestCollector(coords, supertile.getWorldObj(), RANGE); - sizeLastCheck = size; - } - } - } - - public void linkToForcefully(TileEntity collector) { - linkedCollector = collector; - } - - public void addMana(int mana) { - this.mana = Math.min(getMaxMana(), this.mana + mana); - } - - public void emptyManaIntoCollector() { - if (linkedCollector != null && isValidBinding()) { - IManaCollector collector = (IManaCollector) linkedCollector; - if (!collector.isFull() && mana > 0) { - int manaval = Math.min(mana, collector.getMaxMana() - collector.getCurrentMana()); - mana -= manaval; - collector.recieveMana(manaval); - } - } - } - - public boolean isPassiveFlower() { - return false; - } - - public boolean shouldSyncPassiveGeneration() { - return false; - } - - public boolean canGeneratePassively() { - return false; - } - - public int getDelayBetweenPassiveGeneration() { - return 20; - } - - public int getValueForPassiveGeneration() { - return 1; - } - - @Override - public ArrayList getDrops(ArrayList list) { - ArrayList drops = super.getDrops(list); - populateDropStackNBTs(drops); - return drops; - } - - public void populateDropStackNBTs(List drops) { - if (isPassiveFlower() && ticksExisted > 0 && BotaniaAPI.internalHandler.getPassiveFlowerDecay() > 0) { - ItemStack drop = drops.get(0); - if (drop != null) { - if (!drop.hasTagCompound()) drop.setTagCompound(new NBTTagCompound()); - NBTTagCompound cmp = drop.getTagCompound(); - cmp.setInteger(TAG_PASSIVE_DECAY_TICKS, passiveDecayTicks); - } - } - } - - @Override - public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase entity, ItemStack stack) { - super.onBlockPlacedBy(world, x, y, z, entity, stack); - if (isPassiveFlower()) { - NBTTagCompound cmp = stack.getTagCompound(); - passiveDecayTicks = cmp.getInteger(TAG_PASSIVE_DECAY_TICKS); - } - } - - @Override - public boolean onWanded(EntityPlayer player, ItemStack wand) { - if (player == null) return false; - - if (!player.worldObj.isRemote) sync(); - - knownMana = mana; - player.worldObj.playSoundAtEntity(player, "botania:ding", 0.1F, 1F); - - return super.onWanded(player, wand); - } - - public int getMaxMana() { - return 20; - } - - public int getColor() { - return 0xFFFFFF; - } - - @Override - public void readFromPacketNBT(NBTTagCompound cmp) { - mana = cmp.getInteger(TAG_MANA); - passiveDecayTicks = cmp.getInteger(TAG_PASSIVE_DECAY_TICKS); - - int x = cmp.getInteger(TAG_COLLECTOR_X); - int y = cmp.getInteger(TAG_COLLECTOR_Y); - int z = cmp.getInteger(TAG_COLLECTOR_Z); - - cachedCollectorCoordinates = y < 0 ? null : new ChunkCoordinates(x, y, z); - } - - @Override - public void writeToPacketNBT(NBTTagCompound cmp) { - cmp.setInteger(TAG_MANA, mana); - cmp.setInteger(TAG_TICKS_EXISTED, ticksExisted); - cmp.setInteger(TAG_PASSIVE_DECAY_TICKS, passiveDecayTicks); - - if (cachedCollectorCoordinates != null) { - cmp.setInteger(TAG_COLLECTOR_X, cachedCollectorCoordinates.posX); - cmp.setInteger(TAG_COLLECTOR_Y, cachedCollectorCoordinates.posY); - cmp.setInteger(TAG_COLLECTOR_Z, cachedCollectorCoordinates.posZ); - } else { - int x = linkedCollector == null ? 0 : linkedCollector.xCoord; - int y = linkedCollector == null ? -1 : linkedCollector.yCoord; - int z = linkedCollector == null ? 0 : linkedCollector.zCoord; - - cmp.setInteger(TAG_COLLECTOR_X, x); - cmp.setInteger(TAG_COLLECTOR_Y, y); - cmp.setInteger(TAG_COLLECTOR_Z, z); - } - } - - @Override - public ChunkCoordinates getBinding() { - if (linkedCollector == null) return null; - return new ChunkCoordinates(linkedCollector.xCoord, linkedCollector.yCoord, linkedCollector.zCoord); - } - - @Override - public boolean canSelect(EntityPlayer player, ItemStack wand, int x, int y, int z, int side) { - return true; - } - - @Override - public boolean bindTo(EntityPlayer player, ItemStack wand, int x, int y, int z, int side) { - int range = 6; - range *= range; - - double dist = (x - supertile.xCoord) * (x - supertile.xCoord) - + (y - supertile.yCoord) * (y - supertile.yCoord) - + (z - supertile.zCoord) * (z - supertile.zCoord); - if (range >= dist) { - TileEntity tile = player.worldObj.getTileEntity(x, y, z); - if (tile instanceof IManaCollector) { - linkedCollector = tile; - return true; - } - } - - return false; - } - - public boolean isValidBinding() { - return linkedCollector != null - && !linkedCollector.isInvalid() - && supertile - .getWorldObj() - .getTileEntity(linkedCollector.xCoord, linkedCollector.yCoord, linkedCollector.zCoord) - == linkedCollector; - } - - @Override - public void renderHUD(Minecraft mc, ScaledResolution res) { - String name = StatCollector.translateToLocal("tile.botania:flower." + getUnlocalizedName() + ".name"); - int color = getColor(); - BotaniaAPI.internalHandler.drawComplexManaHUD( - color, - knownMana, - getMaxMana(), - name, - res, - BotaniaAPI.internalHandler.getBindDisplayForFlowerType(this), - isValidBinding()); - } - - @Override - public boolean isOvergrowthAffected() { - return !isPassiveFlower(); - } + public static final int RANGE = 6; + + private static final String TAG_MANA = "mana"; + + private static final String TAG_COLLECTOR_X = "collectorX"; + private static final String TAG_COLLECTOR_Y = "collectorY"; + private static final String TAG_COLLECTOR_Z = "collectorZ"; + private static final String TAG_PASSIVE_DECAY_TICKS = "passiveDecayTicks"; + + protected int mana; + + public int redstoneSignal = 0; + + int sizeLastCheck = -1; + protected TileEntity linkedCollector = null; + public int knownMana = -1; + public int passiveDecayTicks; + + ChunkCoordinates cachedCollectorCoordinates = null; + + /** + * If set to true, redstoneSignal will be updated every tick. + */ + public boolean acceptsRedstone() { + return false; + } + + @Override + public void onUpdate() { + super.onUpdate(); + + linkCollector(); + + if(canGeneratePassively()) { + int delay = getDelayBetweenPassiveGeneration(); + if(delay > 0 && ticksExisted % delay == 0 && !supertile.getWorldObj().isRemote) { + if(shouldSyncPassiveGeneration()) + sync(); + addMana(getValueForPassiveGeneration()); + } + } + emptyManaIntoCollector(); + + if(acceptsRedstone()) { + redstoneSignal = 0; + for(ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS) { + int redstoneSide = supertile.getWorldObj().getIndirectPowerLevelTo(supertile.xCoord + dir.offsetX, supertile.yCoord + dir.offsetY, supertile.zCoord + dir.offsetZ, dir.ordinal()); + redstoneSignal = Math.max(redstoneSignal, redstoneSide); + } + } + + if(supertile.getWorldObj().isRemote) { + double particleChance = 1F - (double) mana / (double) getMaxMana() / 3.5F; + Color color = new Color(getColor()); + if(Math.random() > particleChance) + BotaniaAPI.internalHandler.sparkleFX(supertile.getWorldObj(), supertile.xCoord + 0.3 + Math.random() * 0.5, supertile.yCoord + 0.5 + Math.random() * 0.5, supertile.zCoord + 0.3 + Math.random() * 0.5, color.getRed() / 255F, color.getGreen() / 255F, color.getBlue() / 255F, (float) Math.random(), 5); + } + + boolean passive = isPassiveFlower(); + if(!supertile.getWorldObj().isRemote) { + int muhBalance = BotaniaAPI.internalHandler.getPassiveFlowerDecay(); + + if(passive && muhBalance > 0 && passiveDecayTicks > muhBalance) { + supertile.getWorldObj().playAuxSFX(2001, supertile.xCoord, supertile.yCoord, supertile.zCoord, Block.getIdFromBlock(supertile.getBlockType())); + if(supertile.getWorldObj().getBlock(supertile.xCoord, supertile.yCoord - 1, supertile.zCoord).isSideSolid(supertile.getWorldObj(), supertile.xCoord, supertile.yCoord - 1, supertile.zCoord, ForgeDirection.UP)) + supertile.getWorldObj().setBlock(supertile.xCoord, supertile.yCoord, supertile.zCoord, Blocks.deadbush); + else supertile.getWorldObj().setBlockToAir(supertile.xCoord, supertile.yCoord, supertile.zCoord); + } + } + + if(!overgrowth && passive) + passiveDecayTicks++; + } + + public void linkCollector() { + boolean needsNew = false; + if(linkedCollector == null) { + needsNew = true; + + if(cachedCollectorCoordinates != null) { + needsNew = false; + if(supertile.getWorldObj().blockExists(cachedCollectorCoordinates.posX, cachedCollectorCoordinates.posY, cachedCollectorCoordinates.posZ)) { + needsNew = true; + TileEntity tileAt = supertile.getWorldObj().getTileEntity(cachedCollectorCoordinates.posX, cachedCollectorCoordinates.posY, cachedCollectorCoordinates.posZ); + if(tileAt != null && tileAt instanceof IManaCollector && !tileAt.isInvalid()) { + linkedCollector = tileAt; + needsNew = false; + } + cachedCollectorCoordinates = null; + } + } + } else { + TileEntity tileAt = supertile.getWorldObj().getTileEntity(linkedCollector.xCoord, linkedCollector.yCoord, linkedCollector.zCoord); + if(tileAt != null && tileAt instanceof IManaCollector) + linkedCollector = tileAt; + } + + if(needsNew && ticksExisted == 1) { // New flowers only + IManaNetwork network = BotaniaAPI.internalHandler.getManaNetworkInstance(); + int size = network.getAllCollectorsInWorld(supertile.getWorldObj()).size(); + if(BotaniaAPI.internalHandler.shouldForceCheck() || size != sizeLastCheck) { + ChunkCoordinates coords = new ChunkCoordinates(supertile.xCoord, supertile.yCoord, supertile.zCoord); + linkedCollector = network.getClosestCollector(coords, supertile.getWorldObj(), RANGE); + sizeLastCheck = size; + } + } + } + + public void linkToForcefully(TileEntity collector) { + linkedCollector = collector; + } + + public void addMana(int mana) { + this.mana = Math.min(getMaxMana(), this.mana + mana); + } + + public void emptyManaIntoCollector() { + if(linkedCollector != null && isValidBinding()) { + IManaCollector collector = (IManaCollector) linkedCollector; + if(!collector.isFull() && mana > 0) { + int manaval = Math.min(mana, collector.getMaxMana() - collector.getCurrentMana()); + mana -= manaval; + collector.recieveMana(manaval); + } + } + } + + public boolean isPassiveFlower() { + return false; + } + + public boolean shouldSyncPassiveGeneration() { + return false; + } + + public boolean canGeneratePassively() { + return false; + } + + public int getDelayBetweenPassiveGeneration() { + return 20; + } + + public int getValueForPassiveGeneration() { + return 1; + } + + @Override + public ArrayList getDrops(ArrayList list) { + ArrayList drops = super.getDrops(list); + populateDropStackNBTs(drops); + return drops; + } + + public void populateDropStackNBTs(List drops) { + if(isPassiveFlower() && ticksExisted > 0 && BotaniaAPI.internalHandler.getPassiveFlowerDecay() > 0) { + ItemStack drop = drops.get(0); + if(drop != null) { + if(!drop.hasTagCompound()) + drop.setTagCompound(new NBTTagCompound()); + NBTTagCompound cmp = drop.getTagCompound(); + cmp.setInteger(TAG_PASSIVE_DECAY_TICKS, passiveDecayTicks); + } + } + } + + @Override + public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase entity, ItemStack stack) { + super.onBlockPlacedBy(world, x, y, z, entity, stack); + if(isPassiveFlower()) { + NBTTagCompound cmp = stack.getTagCompound(); + passiveDecayTicks = cmp.getInteger(TAG_PASSIVE_DECAY_TICKS); + } + } + + @Override + public boolean onWanded(EntityPlayer player, ItemStack wand) { + if(player == null) + return false; + + if(!player.worldObj.isRemote) + sync(); + + knownMana = mana; + player.worldObj.playSoundAtEntity(player, "botania:ding", 0.1F, 1F); + + return super.onWanded(player, wand); + } + + public int getMaxMana() { + return 20; + } + + public int getColor() { + return 0xFFFFFF; + } + + @Override + public void readFromPacketNBT(NBTTagCompound cmp) { + mana = cmp.getInteger(TAG_MANA); + passiveDecayTicks = cmp.getInteger(TAG_PASSIVE_DECAY_TICKS); + + int x = cmp.getInteger(TAG_COLLECTOR_X); + int y = cmp.getInteger(TAG_COLLECTOR_Y); + int z = cmp.getInteger(TAG_COLLECTOR_Z); + + cachedCollectorCoordinates = y < 0 ? null : new ChunkCoordinates(x, y, z); + } + + @Override + public void writeToPacketNBT(NBTTagCompound cmp) { + cmp.setInteger(TAG_MANA, mana); + cmp.setInteger(TAG_TICKS_EXISTED, ticksExisted); + cmp.setInteger(TAG_PASSIVE_DECAY_TICKS, passiveDecayTicks); + + if(cachedCollectorCoordinates != null) { + cmp.setInteger(TAG_COLLECTOR_X, cachedCollectorCoordinates.posX); + cmp.setInteger(TAG_COLLECTOR_Y, cachedCollectorCoordinates.posY); + cmp.setInteger(TAG_COLLECTOR_Z, cachedCollectorCoordinates.posZ); + } else { + int x = linkedCollector == null ? 0 : linkedCollector.xCoord; + int y = linkedCollector == null ? -1 : linkedCollector.yCoord; + int z = linkedCollector == null ? 0 : linkedCollector.zCoord; + + cmp.setInteger(TAG_COLLECTOR_X, x); + cmp.setInteger(TAG_COLLECTOR_Y, y); + cmp.setInteger(TAG_COLLECTOR_Z, z); + } + } + + @Override + public ChunkCoordinates getBinding() { + if(linkedCollector == null) + return null; + return new ChunkCoordinates(linkedCollector.xCoord, linkedCollector.yCoord, linkedCollector.zCoord); + } + + @Override + public boolean canSelect(EntityPlayer player, ItemStack wand, int x, int y, int z, int side) { + return true; + } + + @Override + public boolean bindTo(EntityPlayer player, ItemStack wand, int x, int y, int z, int side) { + int range = 6; + range *= range; + + double dist = (x - supertile.xCoord) * (x - supertile.xCoord) + (y - supertile.yCoord) * (y - supertile.yCoord) + (z - supertile.zCoord) * (z - supertile.zCoord); + if(range >= dist) { + TileEntity tile = player.worldObj.getTileEntity(x, y, z); + if(tile instanceof IManaCollector) { + linkedCollector = tile; + return true; + } + } + + return false; + } + + + public boolean isValidBinding() { + return linkedCollector != null && !linkedCollector.isInvalid() && supertile.getWorldObj().getTileEntity(linkedCollector.xCoord, linkedCollector.yCoord, linkedCollector.zCoord) == linkedCollector; + } + + @Override + public void renderHUD(Minecraft mc, ScaledResolution res) { + String name = StatCollector.translateToLocal("tile.botania:flower." + getUnlocalizedName() + ".name"); + int color = getColor(); + BotaniaAPI.internalHandler.drawComplexManaHUD(color, knownMana, getMaxMana(), name, res, BotaniaAPI.internalHandler.getBindDisplayForFlowerType(this), isValidBinding()); + } + + @Override + public boolean isOvergrowthAffected() { + return !isPassiveFlower(); + } + } diff --git a/src/main/java/vazkii/botania/api/subtile/signature/BasicSignature.java b/src/main/java/vazkii/botania/api/subtile/signature/BasicSignature.java index 8893908e0b..b3f5e47ce1 100644 --- a/src/main/java/vazkii/botania/api/subtile/signature/BasicSignature.java +++ b/src/main/java/vazkii/botania/api/subtile/signature/BasicSignature.java @@ -2,15 +2,16 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Oct 17, 2014, 5:34:35 PM (GMT)] */ package vazkii.botania.api.subtile.signature; import java.util.List; + import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; @@ -27,56 +28,61 @@ */ public class BasicSignature extends SubTileSignature { - final String name; + final String name; + + public BasicSignature(String name) { + this.name = name; + } - public BasicSignature(String name) { - this.name = name; - } + @Override + public void registerIcons(IIconRegister register) { + BotaniaAPI.internalHandler.registerBasicSignatureIcons(name, register); + } - @Override - public void registerIcons(IIconRegister register) { - BotaniaAPI.internalHandler.registerBasicSignatureIcons(name, register); - } + @Override + public IIcon getIconForStack(ItemStack stack) { + return BotaniaAPI.internalHandler.getSubTileIconForName(name); + } - @Override - public IIcon getIconForStack(ItemStack stack) { - return BotaniaAPI.internalHandler.getSubTileIconForName(name); - } + @Override + public String getUnlocalizedNameForStack(ItemStack stack) { + return unlocalizedName(""); + } - @Override - public String getUnlocalizedNameForStack(ItemStack stack) { - return unlocalizedName(""); - } + @Override + public String getUnlocalizedLoreTextForStack(ItemStack stack) { + return unlocalizedName(".reference"); + } - @Override - public String getUnlocalizedLoreTextForStack(ItemStack stack) { - return unlocalizedName(".reference"); - } + public String getName() { + return name; + } - public String getName() { - return name; - } + public String getType() { + Class clazz = BotaniaAPI.getSubTileMapping(name); - public String getType() { - Class clazz = BotaniaAPI.getSubTileMapping(name); + if(clazz == null) + return "uwotm8"; - if (clazz == null) return "uwotm8"; + if(clazz.getAnnotation(PassiveFlower.class) != null) + return "botania.flowerType.passiveGenerating"; - if (clazz.getAnnotation(PassiveFlower.class) != null) return "botania.flowerType.passiveGenerating"; + if(SubTileGenerating.class.isAssignableFrom(clazz)) + return "botania.flowerType.generating"; - if (SubTileGenerating.class.isAssignableFrom(clazz)) return "botania.flowerType.generating"; + if(SubTileFunctional.class.isAssignableFrom(clazz)) + return "botania.flowerType.functional"; - if (SubTileFunctional.class.isAssignableFrom(clazz)) return "botania.flowerType.functional"; + return "botania.flowerType.misc"; + } - return "botania.flowerType.misc"; - } + @Override + public void addTooltip(ItemStack stack, EntityPlayer player, List tooltip) { + tooltip.add(EnumChatFormatting.BLUE + StatCollector.translateToLocal(getType())); + } - @Override - public void addTooltip(ItemStack stack, EntityPlayer player, List tooltip) { - tooltip.add(EnumChatFormatting.BLUE + StatCollector.translateToLocal(getType())); - } + private String unlocalizedName(String end) { + return "tile.botania:" + SubTileSignature.SPECIAL_FLOWER_PREFIX + name + end; + } - private String unlocalizedName(String end) { - return "tile.botania:" + SubTileSignature.SPECIAL_FLOWER_PREFIX + name + end; - } } diff --git a/src/main/java/vazkii/botania/api/subtile/signature/PassiveFlower.java b/src/main/java/vazkii/botania/api/subtile/signature/PassiveFlower.java index bc65f0a8e0..008fa83b63 100644 --- a/src/main/java/vazkii/botania/api/subtile/signature/PassiveFlower.java +++ b/src/main/java/vazkii/botania/api/subtile/signature/PassiveFlower.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [04/12/2015, 16:47:01 (GMT)] */ package vazkii.botania.api.subtile.signature; @@ -23,4 +23,6 @@ */ @Retention(value = RUNTIME) @Target(value = TYPE) -public @interface PassiveFlower {} +public @interface PassiveFlower { + +} diff --git a/src/main/java/vazkii/botania/api/subtile/signature/SubTileSignature.java b/src/main/java/vazkii/botania/api/subtile/signature/SubTileSignature.java index 4e85dbeaa8..65fac22650 100644 --- a/src/main/java/vazkii/botania/api/subtile/signature/SubTileSignature.java +++ b/src/main/java/vazkii/botania/api/subtile/signature/SubTileSignature.java @@ -2,15 +2,16 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Oct 17, 2014, 5:29:26 PM (GMT)] */ package vazkii.botania.api.subtile.signature; import java.util.List; + import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; @@ -21,34 +22,35 @@ */ public abstract class SubTileSignature { - public static final String SPECIAL_FLOWER_PREFIX = "flower."; - - /** - * Equivalent to Block.registerBlockIcons. - */ - public abstract void registerIcons(IIconRegister register); - - /** - * Gets the icon to display for the flower item. - */ - public abstract IIcon getIconForStack(ItemStack stack); - - /** - * Gets the display name for the flower item. - */ - public abstract String getUnlocalizedNameForStack(ItemStack stack); - - /** - * Gets the lore text for the flower item, displayed in the item's tooltip. - * If you do not want a reference return a key that does not have localization such - * as "botaniamisc.noloc". - */ - public abstract String getUnlocalizedLoreTextForStack(ItemStack stack); - - /** - * Adds additional text to the tooltip. This text is added after getUnlocalizedLoreTextForStack. - */ - public void addTooltip(ItemStack stack, EntityPlayer player, List tooltip) { - // NO-OP - } + public static final String SPECIAL_FLOWER_PREFIX = "flower."; + + /** + * Equivalent to Block.registerBlockIcons. + */ + public abstract void registerIcons(IIconRegister register); + + /** + * Gets the icon to display for the flower item. + */ + public abstract IIcon getIconForStack(ItemStack stack); + + /** + * Gets the display name for the flower item. + */ + public abstract String getUnlocalizedNameForStack(ItemStack stack); + + /** + * Gets the lore text for the flower item, displayed in the item's tooltip. + * If you do not want a reference return a key that does not have localization such + * as "botaniamisc.noloc". + */ + public abstract String getUnlocalizedLoreTextForStack(ItemStack stack); + + /** + * Adds additional text to the tooltip. This text is added after getUnlocalizedLoreTextForStack. + */ + public void addTooltip(ItemStack stack, EntityPlayer player, List tooltip) { + // NO-OP + } + } diff --git a/src/main/java/vazkii/botania/api/wand/ICoordBoundItem.java b/src/main/java/vazkii/botania/api/wand/ICoordBoundItem.java index 9810a97486..f7c8036d78 100644 --- a/src/main/java/vazkii/botania/api/wand/ICoordBoundItem.java +++ b/src/main/java/vazkii/botania/api/wand/ICoordBoundItem.java @@ -1,9 +1,9 @@ package vazkii.botania.api.wand; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; import net.minecraft.item.ItemStack; import net.minecraft.util.ChunkCoordinates; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; /** * The item equivalent of ITileBound, renders when the @@ -12,6 +12,7 @@ */ public interface ICoordBoundItem { - @SideOnly(Side.CLIENT) - public ChunkCoordinates getBinding(ItemStack stack); + @SideOnly(Side.CLIENT) + public ChunkCoordinates getBinding(ItemStack stack); + } diff --git a/src/main/java/vazkii/botania/api/wand/ITileBound.java b/src/main/java/vazkii/botania/api/wand/ITileBound.java index d08f410ce7..199390b5a5 100644 --- a/src/main/java/vazkii/botania/api/wand/ITileBound.java +++ b/src/main/java/vazkii/botania/api/wand/ITileBound.java @@ -2,17 +2,17 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Mar 24, 2014, 6:47:53 PM (GMT)] */ package vazkii.botania.api.wand; +import net.minecraft.util.ChunkCoordinates; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; -import net.minecraft.util.ChunkCoordinates; /** * Any TileEntity that implements this is technically bound @@ -21,9 +21,10 @@ */ public interface ITileBound { - /** - * Gets where this block is bound to, can return null. - */ - @SideOnly(Side.CLIENT) - public ChunkCoordinates getBinding(); + /** + * Gets where this block is bound to, can return null. + */ + @SideOnly(Side.CLIENT) + public ChunkCoordinates getBinding(); + } diff --git a/src/main/java/vazkii/botania/api/wand/IWandBindable.java b/src/main/java/vazkii/botania/api/wand/IWandBindable.java index 221502d6a4..0c5786c12f 100644 --- a/src/main/java/vazkii/botania/api/wand/IWandBindable.java +++ b/src/main/java/vazkii/botania/api/wand/IWandBindable.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Oct 9, 2014, 3:01:58 PM (GMT)] */ package vazkii.botania.api.wand; @@ -20,14 +20,15 @@ */ public interface IWandBindable extends ITileBound { - /** - * Return true if the Wand can select this tile. - */ - public boolean canSelect(EntityPlayer player, ItemStack wand, int x, int y, int z, int side); + /** + * Return true if the Wand can select this tile. + */ + public boolean canSelect(EntityPlayer player, ItemStack wand, int x, int y, int z, int side); + + /** + * Call to bind the TileEntity to where the player clicked. Return true to deselect + * the TileEntity for another bind or false case the TileEntity should stay selected. + */ + public boolean bindTo(EntityPlayer player, ItemStack wand, int x, int y, int z, int side); - /** - * Call to bind the TileEntity to where the player clicked. Return true to deselect - * the TileEntity for another bind or false case the TileEntity should stay selected. - */ - public boolean bindTo(EntityPlayer player, ItemStack wand, int x, int y, int z, int side); } diff --git a/src/main/java/vazkii/botania/api/wand/IWandHUD.java b/src/main/java/vazkii/botania/api/wand/IWandHUD.java index 0b3f30f3ac..a75e44abc8 100644 --- a/src/main/java/vazkii/botania/api/wand/IWandHUD.java +++ b/src/main/java/vazkii/botania/api/wand/IWandHUD.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Feb 5, 2014, 1:34:44 PM (GMT)] */ package vazkii.botania.api.wand; @@ -20,5 +20,6 @@ */ public interface IWandHUD { - public void renderHUD(Minecraft mc, ScaledResolution res, World world, int x, int y, int z); + public void renderHUD(Minecraft mc, ScaledResolution res, World world, int x, int y, int z); + } diff --git a/src/main/java/vazkii/botania/api/wand/IWandable.java b/src/main/java/vazkii/botania/api/wand/IWandable.java index 15e1177a84..52349fa056 100644 --- a/src/main/java/vazkii/botania/api/wand/IWandable.java +++ b/src/main/java/vazkii/botania/api/wand/IWandable.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jan 22, 2014, 5:12:53 PM (GMT)] */ package vazkii.botania.api.wand; @@ -19,9 +19,10 @@ */ public interface IWandable { - /** - * Called when the block is used by a wand. Note that the player parameter can be null - * if this function is called from a dispenser. - */ - public boolean onUsedByWand(EntityPlayer player, ItemStack stack, World world, int x, int y, int z, int side); + /** + * Called when the block is used by a wand. Note that the player parameter can be null + * if this function is called from a dispenser. + */ + public boolean onUsedByWand(EntityPlayer player, ItemStack stack, World world, int x, int y, int z, int side); + } diff --git a/src/main/java/vazkii/botania/api/wand/IWireframeAABBProvider.java b/src/main/java/vazkii/botania/api/wand/IWireframeAABBProvider.java index 0d63924fdf..3b6e807e7b 100644 --- a/src/main/java/vazkii/botania/api/wand/IWireframeAABBProvider.java +++ b/src/main/java/vazkii/botania/api/wand/IWireframeAABBProvider.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Apr 19, 2014, 7:23:59 PM (GMT)] */ package vazkii.botania.api.wand; @@ -19,5 +19,6 @@ */ public interface IWireframeAABBProvider { - public AxisAlignedBB getWireframeAABB(World world, int x, int y, int z); + public AxisAlignedBB getWireframeAABB(World world, int x, int y, int z); + } diff --git a/src/main/java/vazkii/botania/api/wiki/IWikiProvider.java b/src/main/java/vazkii/botania/api/wiki/IWikiProvider.java index f470f4a437..285c1549eb 100644 --- a/src/main/java/vazkii/botania/api/wiki/IWikiProvider.java +++ b/src/main/java/vazkii/botania/api/wiki/IWikiProvider.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Sep 2, 2014, 5:57:35 PM (GMT)] */ package vazkii.botania.api.wiki; @@ -20,18 +20,19 @@ */ public interface IWikiProvider { - /** - * Gets the name of the block being looked at for display. - */ - public String getBlockName(World world, MovingObjectPosition pos); + /** + * Gets the name of the block being looked at for display. + */ + public String getBlockName(World world, MovingObjectPosition pos); - /** - * Gets the URL to open when the block is clicked. - */ - public String getWikiURL(World world, MovingObjectPosition pos); + /** + * Gets the URL to open when the block is clicked. + */ + public String getWikiURL(World world, MovingObjectPosition pos); + + /** + * Gets the name of the wiki for display. + */ + public String getWikiName(World world, MovingObjectPosition pos); - /** - * Gets the name of the wiki for display. - */ - public String getWikiName(World world, MovingObjectPosition pos); } diff --git a/src/main/java/vazkii/botania/api/wiki/SimpleWikiProvider.java b/src/main/java/vazkii/botania/api/wiki/SimpleWikiProvider.java index 56077fac4b..f03e07c8cf 100644 --- a/src/main/java/vazkii/botania/api/wiki/SimpleWikiProvider.java +++ b/src/main/java/vazkii/botania/api/wiki/SimpleWikiProvider.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Sep 2, 2014, 5:58:39 PM (GMT)] */ package vazkii.botania.api.wiki; @@ -14,70 +14,77 @@ import net.minecraft.item.ItemStack; import net.minecraft.util.MovingObjectPosition; import net.minecraft.world.World; + import org.apache.commons.lang3.text.WordUtils; public class SimpleWikiProvider implements IWikiProvider { - final String name, urlBase, replacement; - final boolean lowercase; - - public SimpleWikiProvider(String name, String urlBase) { - this(name, urlBase, "%20"); - } - - public SimpleWikiProvider(String name, String urlBase, boolean lowercase) { - this(name, urlBase, "%20", lowercase); - } - - public SimpleWikiProvider(String name, String urlBase, String replacement) { - this.name = name; - this.urlBase = urlBase; - this.replacement = replacement; - lowercase = false; - } - - public SimpleWikiProvider(String name, String urlBase, String replacement, boolean lowercase) { - this.name = name; - this.urlBase = urlBase; - this.replacement = replacement; - this.lowercase = lowercase; - } - - @Override - public String getBlockName(World world, MovingObjectPosition pos) { - int x = pos.blockX; - int y = pos.blockY; - int z = pos.blockZ; - - Block block = world.getBlock(x, y, z); - if (block == null) return null; - - ItemStack stack = block.getPickBlock(pos, world, x, y, z); - - if (stack == null || stack.getItem() == null) stack = new ItemStack(block, 1, world.getBlockMetadata(x, y, z)); - - if (stack.getItem() == null) return null; - - String name = stack.getDisplayName(); - if (name == null || name.isEmpty()) return null; - - return name; - } - - @Override - public String getWikiURL(World world, MovingObjectPosition pos) { - String name = getBlockName(world, pos); - if (name == null) return null; - - if (lowercase) { - return String.format(urlBase, name.toLowerCase().replaceAll(" ", replacement)); - } else { - return String.format(urlBase, WordUtils.capitalizeFully(name).replaceAll(" ", replacement)); - } - } + final String name, urlBase, replacement; + final boolean lowercase; + + public SimpleWikiProvider(String name, String urlBase) { + this(name, urlBase, "%20"); + } + + public SimpleWikiProvider(String name, String urlBase, boolean lowercase) { + this(name, urlBase, "%20", lowercase); + } + + public SimpleWikiProvider(String name, String urlBase, String replacement) { + this.name = name; + this.urlBase = urlBase; + this.replacement = replacement; + lowercase = false; + } + + public SimpleWikiProvider(String name, String urlBase, String replacement, boolean lowercase) { + this.name = name; + this.urlBase = urlBase; + this.replacement = replacement; + this.lowercase = lowercase; + } + + @Override + public String getBlockName(World world, MovingObjectPosition pos) { + int x = pos.blockX; + int y = pos.blockY; + int z = pos.blockZ; + + Block block = world.getBlock(x, y, z); + if(block == null) + return null; + + ItemStack stack = block.getPickBlock(pos, world, x, y, z); + + if(stack == null || stack.getItem() == null) + stack = new ItemStack(block, 1, world.getBlockMetadata(x, y, z)); + + if(stack.getItem() == null) + return null; + + String name = stack.getDisplayName(); + if(name == null || name.isEmpty()) + return null; + + return name; + } + + @Override + public String getWikiURL(World world, MovingObjectPosition pos) { + String name = getBlockName(world, pos); + if(name == null) + return null; + + if(lowercase) { + return String.format(urlBase, name.toLowerCase().replaceAll(" ", replacement)); + } else { + return String.format(urlBase, WordUtils.capitalizeFully(name).replaceAll(" ", replacement)); + } + } + + @Override + public String getWikiName(World world, MovingObjectPosition pos) { + return name; + } - @Override - public String getWikiName(World world, MovingObjectPosition pos) { - return name; - } } diff --git a/src/main/java/vazkii/botania/api/wiki/WikiHooks.java b/src/main/java/vazkii/botania/api/wiki/WikiHooks.java index 470bc72284..ae42fd82e6 100644 --- a/src/main/java/vazkii/botania/api/wiki/WikiHooks.java +++ b/src/main/java/vazkii/botania/api/wiki/WikiHooks.java @@ -2,39 +2,41 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Sep 2, 2014, 6:05:03 PM (GMT)] */ package vazkii.botania.api.wiki; -import cpw.mods.fml.common.registry.GameRegistry; -import cpw.mods.fml.common.registry.GameRegistry.UniqueIdentifier; import java.util.HashMap; import java.util.Map; + import net.minecraft.block.Block; +import cpw.mods.fml.common.registry.GameRegistry; +import cpw.mods.fml.common.registry.GameRegistry.UniqueIdentifier; public class WikiHooks { - private static final IWikiProvider FALLBACK_PROVIDER = - new SimpleWikiProvider("FTB Wiki", "http://ftb.gamepedia.com/%s"); + private static final IWikiProvider FALLBACK_PROVIDER = new SimpleWikiProvider("FTB Wiki", "http://ftb.gamepedia.com/%s"); + + private static final Map modWikis = new HashMap(); - private static final Map modWikis = new HashMap(); + public static IWikiProvider getWikiFor(Block block) { + UniqueIdentifier mod = GameRegistry.findUniqueIdentifierFor(block); + return getWikiFor(mod == null ? "" : mod.modId.toLowerCase()); + } - public static IWikiProvider getWikiFor(Block block) { - UniqueIdentifier mod = GameRegistry.findUniqueIdentifierFor(block); - return getWikiFor(mod == null ? "" : mod.modId.toLowerCase()); - } + public static IWikiProvider getWikiFor(String mod) { + if(!modWikis.containsKey(mod)) + modWikis.put(mod, FALLBACK_PROVIDER); - public static IWikiProvider getWikiFor(String mod) { - if (!modWikis.containsKey(mod)) modWikis.put(mod, FALLBACK_PROVIDER); + return modWikis.get(mod); + } - return modWikis.get(mod); - } + public static void registerModWiki(String mod, IWikiProvider provider) { + modWikis.put(mod.toLowerCase(), provider); + } - public static void registerModWiki(String mod, IWikiProvider provider) { - modWikis.put(mod.toLowerCase(), provider); - } } diff --git a/src/main/java/vazkii/botania/client/challenge/Challenge.java b/src/main/java/vazkii/botania/client/challenge/Challenge.java index 0d5fc93a1b..ea3dc228ff 100644 --- a/src/main/java/vazkii/botania/client/challenge/Challenge.java +++ b/src/main/java/vazkii/botania/client/challenge/Challenge.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jun 29, 2015, 4:45:25 PM (GMT)] */ package vazkii.botania.client.challenge; @@ -15,22 +15,23 @@ public class Challenge { - public final String unlocalizedName; - public final ItemStack icon; - public final EnumChallengeLevel level; - public boolean complete = false; + public final String unlocalizedName; + public final ItemStack icon; + public final EnumChallengeLevel level; + public boolean complete = false; - public Challenge(String unlocalizedName, ItemStack icon, EnumChallengeLevel level) { - this.unlocalizedName = unlocalizedName; - this.icon = icon; - this.level = level; - } + public Challenge(String unlocalizedName, ItemStack icon, EnumChallengeLevel level) { + this.unlocalizedName = unlocalizedName; + this.icon = icon; + this.level = level; + } - public void writeToNBT(NBTTagCompound cmp) { - cmp.setBoolean(unlocalizedName, complete); - } + public void writeToNBT(NBTTagCompound cmp) { + cmp.setBoolean(unlocalizedName, complete); + } + + public void readFromNBT(NBTTagCompound cmp) { + complete = cmp.getBoolean(unlocalizedName); + } - public void readFromNBT(NBTTagCompound cmp) { - complete = cmp.getBoolean(unlocalizedName); - } } diff --git a/src/main/java/vazkii/botania/client/challenge/EnumChallengeLevel.java b/src/main/java/vazkii/botania/client/challenge/EnumChallengeLevel.java index e9bbc5301a..8abb8ca4a4 100644 --- a/src/main/java/vazkii/botania/client/challenge/EnumChallengeLevel.java +++ b/src/main/java/vazkii/botania/client/challenge/EnumChallengeLevel.java @@ -2,27 +2,29 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jun 29, 2015, 4:46:16 PM (GMT)] */ package vazkii.botania.client.challenge; public enum EnumChallengeLevel { - EASY("botania.challengelevel.easy"), - NORMAL("botania.challengelevel.normal"), - HARD("botania.challengelevel.hard"), - LUNATIC("botania.challengelevel.lunatic"); - String name; + EASY("botania.challengelevel.easy"), + NORMAL("botania.challengelevel.normal"), + HARD("botania.challengelevel.hard"), + LUNATIC("botania.challengelevel.lunatic"); - private EnumChallengeLevel(String name) { - this.name = name; - } + String name; + + private EnumChallengeLevel(String name) { + this.name = name; + } + + public String getName() { + return name; + } - public String getName() { - return name; - } } diff --git a/src/main/java/vazkii/botania/client/challenge/ModChallenges.java b/src/main/java/vazkii/botania/client/challenge/ModChallenges.java index 6825ba5b0b..4e1ba5e312 100644 --- a/src/main/java/vazkii/botania/client/challenge/ModChallenges.java +++ b/src/main/java/vazkii/botania/client/challenge/ModChallenges.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jun 29, 2015, 4:44:49 PM (GMT)] */ package vazkii.botania.client.challenge; @@ -14,6 +14,7 @@ import java.util.EnumMap; import java.util.HashMap; import java.util.List; + import net.minecraft.init.Blocks; import net.minecraft.init.Items; import net.minecraft.item.ItemStack; @@ -24,51 +25,41 @@ public final class ModChallenges { - public static final EnumMap> challenges = new EnumMap(EnumChallengeLevel.class); - public static final HashMap challengeLookup = new HashMap(); + public static final EnumMap> challenges = new EnumMap(EnumChallengeLevel.class); + public static final HashMap challengeLookup = new HashMap(); + + public static void init() { + for(EnumChallengeLevel level : EnumChallengeLevel.class.getEnumConstants()) + challenges.put(level, new ArrayList()); - public static void init() { - for (EnumChallengeLevel level : EnumChallengeLevel.class.getEnumConstants()) - challenges.put(level, new ArrayList()); + addChallenge(EnumChallengeLevel.EASY, "flowerFarm", new ItemStack(ModBlocks.flower, 1, 6)); + addChallenge(EnumChallengeLevel.EASY, "recordFarm", new ItemStack(Items.record_13)); + addChallenge(EnumChallengeLevel.EASY, "reedFarm", new ItemStack(Items.reeds)); + addChallenge(EnumChallengeLevel.EASY, "cobbleGen", new ItemStack(Blocks.cobblestone)); + addChallenge(EnumChallengeLevel.EASY, "pureDaisy", ItemBlockSpecialFlower.ofType(LibBlockNames.SUBTILE_PUREDAISY)); + addChallenge(EnumChallengeLevel.EASY, "battery", new ItemStack(ModBlocks.pool)); - addChallenge(EnumChallengeLevel.EASY, "flowerFarm", new ItemStack(ModBlocks.flower, 1, 6)); - addChallenge(EnumChallengeLevel.EASY, "recordFarm", new ItemStack(Items.record_13)); - addChallenge(EnumChallengeLevel.EASY, "reedFarm", new ItemStack(Items.reeds)); - addChallenge(EnumChallengeLevel.EASY, "cobbleGen", new ItemStack(Blocks.cobblestone)); - addChallenge( - EnumChallengeLevel.EASY, "pureDaisy", ItemBlockSpecialFlower.ofType(LibBlockNames.SUBTILE_PUREDAISY)); - addChallenge(EnumChallengeLevel.EASY, "battery", new ItemStack(ModBlocks.pool)); + addChallenge(EnumChallengeLevel.NORMAL, "apothecaryRefill", new ItemStack(ModBlocks.altar)); + addChallenge(EnumChallengeLevel.NORMAL, "treeFarm", new ItemStack(Blocks.sapling)); + addChallenge(EnumChallengeLevel.NORMAL, "fullCropFarm", new ItemStack(Items.wheat_seeds)); + addChallenge(EnumChallengeLevel.NORMAL, "animalFarm", new ItemStack(Items.leather)); + addChallenge(EnumChallengeLevel.NORMAL, "boneMealFarm", new ItemStack(Items.dye, 1, 15)); + addChallenge(EnumChallengeLevel.NORMAL, "orechid", ItemBlockSpecialFlower.ofType(LibBlockNames.SUBTILE_ORECHID)); - addChallenge(EnumChallengeLevel.NORMAL, "apothecaryRefill", new ItemStack(ModBlocks.altar)); - addChallenge(EnumChallengeLevel.NORMAL, "treeFarm", new ItemStack(Blocks.sapling)); - addChallenge(EnumChallengeLevel.NORMAL, "fullCropFarm", new ItemStack(Items.wheat_seeds)); - addChallenge(EnumChallengeLevel.NORMAL, "animalFarm", new ItemStack(Items.leather)); - addChallenge(EnumChallengeLevel.NORMAL, "boneMealFarm", new ItemStack(Items.dye, 1, 15)); - addChallenge( - EnumChallengeLevel.NORMAL, "orechid", ItemBlockSpecialFlower.ofType(LibBlockNames.SUBTILE_ORECHID)); + addChallenge(EnumChallengeLevel.HARD, "mobTower", new ItemStack(Items.bone)); + addChallenge(EnumChallengeLevel.HARD, "entropinnyumSetup", ItemBlockSpecialFlower.ofType(LibBlockNames.SUBTILE_ENTROPINNYUM)); + addChallenge(EnumChallengeLevel.HARD, "spectrolusSetup", ItemBlockSpecialFlower.ofType(LibBlockNames.SUBTILE_SPECTROLUS)); + addChallenge(EnumChallengeLevel.HARD, "potionBrewer", new ItemStack(ModBlocks.brewery)); - addChallenge(EnumChallengeLevel.HARD, "mobTower", new ItemStack(Items.bone)); - addChallenge( - EnumChallengeLevel.HARD, - "entropinnyumSetup", - ItemBlockSpecialFlower.ofType(LibBlockNames.SUBTILE_ENTROPINNYUM)); - addChallenge( - EnumChallengeLevel.HARD, - "spectrolusSetup", - ItemBlockSpecialFlower.ofType(LibBlockNames.SUBTILE_SPECTROLUS)); - addChallenge(EnumChallengeLevel.HARD, "potionBrewer", new ItemStack(ModBlocks.brewery)); + addChallenge(EnumChallengeLevel.LUNATIC, "kekimurusSetup", ItemBlockSpecialFlower.ofType(LibBlockNames.SUBTILE_KEKIMURUS)); + addChallenge(EnumChallengeLevel.LUNATIC, "autoQuarry", new ItemStack(Items.diamond_pickaxe)); + addChallenge(EnumChallengeLevel.LUNATIC, "runeCrafter", new ItemStack(ModItems.rune)); + } - addChallenge( - EnumChallengeLevel.LUNATIC, - "kekimurusSetup", - ItemBlockSpecialFlower.ofType(LibBlockNames.SUBTILE_KEKIMURUS)); - addChallenge(EnumChallengeLevel.LUNATIC, "autoQuarry", new ItemStack(Items.diamond_pickaxe)); - addChallenge(EnumChallengeLevel.LUNATIC, "runeCrafter", new ItemStack(ModItems.rune)); - } + public static void addChallenge(EnumChallengeLevel level, String name, ItemStack icon) { + Challenge c = new Challenge("botania.challenge." + name, icon, level); + challenges.get(level).add(c); + challengeLookup.put(c.unlocalizedName, c); + } - public static void addChallenge(EnumChallengeLevel level, String name, ItemStack icon) { - Challenge c = new Challenge("botania.challenge." + name, icon, level); - challenges.get(level).add(c); - challengeLookup.put(c.unlocalizedName, c); - } } diff --git a/src/main/java/vazkii/botania/client/core/handler/BaubleRenderHandler.java b/src/main/java/vazkii/botania/client/core/handler/BaubleRenderHandler.java index d86c05603d..460e7363c9 100644 --- a/src/main/java/vazkii/botania/client/core/handler/BaubleRenderHandler.java +++ b/src/main/java/vazkii/botania/client/core/handler/BaubleRenderHandler.java @@ -2,18 +2,16 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Aug 27, 2014, 8:55:00 PM (GMT)] */ package vazkii.botania.client.core.handler; -import baubles.common.container.InventoryBaubles; -import baubles.common.lib.PlayerHandler; -import cpw.mods.fml.common.eventhandler.SubscribeEvent; import java.awt.Color; + import net.minecraft.client.Minecraft; import net.minecraft.client.renderer.ItemRenderer; import net.minecraft.client.renderer.OpenGlHelper; @@ -25,7 +23,9 @@ import net.minecraft.potion.Potion; import net.minecraft.util.IIcon; import net.minecraftforge.client.event.RenderPlayerEvent; + import org.lwjgl.opengl.GL11; + import vazkii.botania.api.item.IBaubleRender; import vazkii.botania.api.item.IBaubleRender.Helper; import vazkii.botania.api.item.IBaubleRender.RenderType; @@ -34,112 +34,116 @@ import vazkii.botania.common.core.handler.ConfigHandler; import vazkii.botania.common.item.ModItems; import vazkii.botania.common.item.equipment.armor.terrasteel.ItemTerrasteelHelm; +import baubles.common.container.InventoryBaubles; +import baubles.common.lib.PlayerHandler; +import cpw.mods.fml.common.eventhandler.SubscribeEvent; public final class BaubleRenderHandler { - @SubscribeEvent - public void onPlayerRender(RenderPlayerEvent.Specials.Post event) { - if (!ConfigHandler.renderBaubles || event.entityLiving.getActivePotionEffect(Potion.invisibility) != null) - return; - - EntityPlayer player = event.entityPlayer; - InventoryBaubles inv = PlayerHandler.getPlayerBaubles(player); - - dispatchRenders(inv, event, RenderType.BODY); - if (inv.getStackInSlot(3) != null) renderManaTablet(event); - - float yaw = player.prevRotationYawHead - + (player.rotationYawHead - player.prevRotationYawHead) * event.partialRenderTick; - float yawOffset = player.prevRenderYawOffset - + (player.renderYawOffset - player.prevRenderYawOffset) * event.partialRenderTick; - float pitch = - player.prevRotationPitch + (player.rotationPitch - player.prevRotationPitch) * event.partialRenderTick; - - GL11.glPushMatrix(); - GL11.glRotatef(yawOffset, 0, -1, 0); - GL11.glRotatef(yaw - 270, 0, 1, 0); - GL11.glRotatef(pitch, 0, 0, 1); - dispatchRenders(inv, event, RenderType.HEAD); - - ItemStack helm = player.inventory.armorItemInSlot(3); - if (helm != null && helm.getItem() instanceof ItemTerrasteelHelm) - ItemTerrasteelHelm.renderOnPlayer(helm, event); - - ContributorFancinessHandler.render(event); - GL11.glPopMatrix(); - } - - private void dispatchRenders(InventoryBaubles inv, RenderPlayerEvent event, RenderType type) { - for (int i = 0; i < inv.getSizeInventory(); i++) { - ItemStack stack = inv.getStackInSlot(i); - if (stack != null) { - Item item = stack.getItem(); - - if (item instanceof IPhantomInkable) { - IPhantomInkable inkable = (IPhantomInkable) item; - if (inkable.hasPhantomInk(stack)) continue; - } - - if (item instanceof ICosmeticAttachable) { - ICosmeticAttachable attachable = (ICosmeticAttachable) item; - ItemStack cosmetic = attachable.getCosmeticItem(stack); - if (cosmetic != null) { - GL11.glPushMatrix(); - GL11.glColor4f(1F, 1F, 1F, 1F); - ((IBaubleRender) cosmetic.getItem()).onPlayerBaubleRender(cosmetic, event, type); - GL11.glPopMatrix(); - continue; - } - } - - if (item instanceof IBaubleRender) { - GL11.glPushMatrix(); - GL11.glColor4f(1F, 1F, 1F, 1F); - ((IBaubleRender) stack.getItem()).onPlayerBaubleRender(stack, event, type); - GL11.glPopMatrix(); - } - } - } - } - - private void renderManaTablet(RenderPlayerEvent event) { - EntityPlayer player = event.entityPlayer; - boolean renderedOne = false; - for (int i = 0; i < player.inventory.getSizeInventory(); i++) { - ItemStack stack = player.inventory.getStackInSlot(i); - if (stack != null && stack.getItem() == ModItems.manaTablet) { - Item item = stack.getItem(); - GL11.glPushMatrix(); - Minecraft.getMinecraft().renderEngine.bindTexture(TextureMap.locationItemsTexture); - Helper.rotateIfSneaking(event.entityPlayer); - boolean armor = event.entityPlayer.getCurrentArmor(1) != null; - GL11.glRotatef(180F, 1F, 0F, 0F); - GL11.glRotatef(90F, 0F, 1F, 0F); - GL11.glTranslatef(-0.25F, -0.85F, renderedOne ? armor ? 0.2F : 0.28F : armor ? -0.3F : -0.25F); - GL11.glScalef(0.5F, 0.5F, 0.5F); - - GL11.glColor3f(1F, 1F, 1F); - int light = 15728880; - int lightmapX = light % 65536; - int lightmapY = light / 65536; - OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, lightmapX, lightmapY); - for (int j = 0; j < 2; j++) { - IIcon icon = item.getIcon(stack, j); - float f = icon.getMinU(); - float f1 = icon.getMaxU(); - float f2 = icon.getMinV(); - float f3 = icon.getMaxV(); - ItemRenderer.renderItemIn2D( - Tessellator.instance, f1, f2, f, f3, icon.getIconWidth(), icon.getIconHeight(), 1F / 16F); - - Color color = new Color(item.getColorFromItemStack(stack, 1)); - GL11.glColor3ub((byte) color.getRed(), (byte) color.getGreen(), (byte) color.getBlue()); - } - GL11.glPopMatrix(); - - if (renderedOne) return; - renderedOne = true; - } - } - } + @SubscribeEvent + public void onPlayerRender(RenderPlayerEvent.Specials.Post event) { + if(!ConfigHandler.renderBaubles || event.entityLiving.getActivePotionEffect(Potion.invisibility) != null) + return; + + EntityPlayer player = event.entityPlayer; + InventoryBaubles inv = PlayerHandler.getPlayerBaubles(player); + + dispatchRenders(inv, event, RenderType.BODY); + if(inv.getStackInSlot(3) != null) + renderManaTablet(event); + + float yaw = player.prevRotationYawHead + (player.rotationYawHead - player.prevRotationYawHead) * event.partialRenderTick; + float yawOffset = player.prevRenderYawOffset + (player.renderYawOffset - player.prevRenderYawOffset) * event.partialRenderTick; + float pitch = player.prevRotationPitch + (player.rotationPitch - player.prevRotationPitch) * event.partialRenderTick; + + GL11.glPushMatrix(); + GL11.glRotatef(yawOffset, 0, -1, 0); + GL11.glRotatef(yaw - 270, 0, 1, 0); + GL11.glRotatef(pitch, 0, 0, 1); + dispatchRenders(inv, event, RenderType.HEAD); + + ItemStack helm = player.inventory.armorItemInSlot(3); + if(helm != null && helm.getItem() instanceof ItemTerrasteelHelm) + ItemTerrasteelHelm.renderOnPlayer(helm, event); + + ContributorFancinessHandler.render(event); + GL11.glPopMatrix(); + } + + private void dispatchRenders(InventoryBaubles inv, RenderPlayerEvent event, RenderType type) { + for(int i = 0; i < inv.getSizeInventory(); i++) { + ItemStack stack = inv.getStackInSlot(i); + if(stack != null) { + Item item = stack.getItem(); + + if(item instanceof IPhantomInkable) { + IPhantomInkable inkable = (IPhantomInkable) item; + if(inkable.hasPhantomInk(stack)) + continue; + } + + if(item instanceof ICosmeticAttachable) { + ICosmeticAttachable attachable = (ICosmeticAttachable) item; + ItemStack cosmetic = attachable.getCosmeticItem(stack); + if(cosmetic != null) { + GL11.glPushMatrix(); + GL11.glColor4f(1F, 1F, 1F, 1F); + ((IBaubleRender) cosmetic.getItem()).onPlayerBaubleRender(cosmetic, event, type); + GL11.glPopMatrix(); + continue; + } + } + + if(item instanceof IBaubleRender) { + GL11.glPushMatrix(); + GL11.glColor4f(1F, 1F, 1F, 1F); + ((IBaubleRender) stack.getItem()).onPlayerBaubleRender(stack, event, type); + GL11.glPopMatrix(); + } + } + } + } + + private void renderManaTablet(RenderPlayerEvent event) { + EntityPlayer player = event.entityPlayer; + boolean renderedOne = false; + for(int i = 0; i < player.inventory.getSizeInventory(); i++) { + ItemStack stack = player.inventory.getStackInSlot(i); + if(stack != null && stack.getItem() == ModItems.manaTablet) { + Item item = stack.getItem(); + GL11.glPushMatrix(); + Minecraft.getMinecraft().renderEngine.bindTexture(TextureMap.locationItemsTexture); + Helper.rotateIfSneaking(event.entityPlayer); + boolean armor = event.entityPlayer.getCurrentArmor(1) != null; + GL11.glRotatef(180F, 1F, 0F, 0F); + GL11.glRotatef(90F, 0F, 1F, 0F); + GL11.glTranslatef(-0.25F, -0.85F, renderedOne ? armor ? 0.2F : 0.28F : armor ? -0.3F : -0.25F); + GL11.glScalef(0.5F, 0.5F, 0.5F); + + GL11.glColor3f(1F, 1F, 1F); + int light = 15728880; + int lightmapX = light % 65536; + int lightmapY = light / 65536; + OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, lightmapX, lightmapY); + for(int j = 0; j < 2; j++) { + IIcon icon = item.getIcon(stack, j); + float f = icon.getMinU(); + float f1 = icon.getMaxU(); + float f2 = icon.getMinV(); + float f3 = icon.getMaxV(); + ItemRenderer.renderItemIn2D(Tessellator.instance, f1, f2, f, f3, icon.getIconWidth(), icon.getIconHeight(), 1F / 16F); + + Color color = new Color(item.getColorFromItemStack(stack, 1)); + GL11.glColor3ub((byte) color.getRed(), (byte) color.getGreen(), (byte) color.getBlue()); + } + GL11.glPopMatrix(); + + if(renderedOne) + return; + renderedOne = true; + } + } + } + + } diff --git a/src/main/java/vazkii/botania/client/core/handler/BossBarHandler.java b/src/main/java/vazkii/botania/client/core/handler/BossBarHandler.java index f4ad0550fb..ec61a9366d 100644 --- a/src/main/java/vazkii/botania/client/core/handler/BossBarHandler.java +++ b/src/main/java/vazkii/botania/client/core/handler/BossBarHandler.java @@ -2,22 +2,25 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Oct 29, 2014, 6:46:10 PM (GMT)] */ package vazkii.botania.client.core.handler; import java.awt.Rectangle; + import net.minecraft.client.Minecraft; import net.minecraft.client.gui.ScaledResolution; import net.minecraft.entity.Entity; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.util.ResourceLocation; + import org.lwjgl.opengl.ARBShaderObjects; import org.lwjgl.opengl.GL11; + import vazkii.botania.api.boss.IBotaniaBoss; import vazkii.botania.api.boss.IBotaniaBossWithShader; import vazkii.botania.api.internal.ShaderCallback; @@ -28,83 +31,86 @@ public final class BossBarHandler { - public static final ResourceLocation defaultBossBar = new ResourceLocation(LibResources.GUI_BOSS_BAR); - static IBotaniaBoss currentBoss; - - private static final BarCallback barUniformCallback = new BarCallback(); - - public static void setCurrentBoss(IBotaniaBoss status) { - currentBoss = status; - } - - public static void render(ScaledResolution res) { - if (currentBoss == null) return; - - Minecraft mc = Minecraft.getMinecraft(); - Rectangle bgRect = currentBoss.getBossBarTextureRect(); - Rectangle fgRect = currentBoss.getBossBarHPTextureRect(); - String name = currentBoss.func_145748_c_().getFormattedText(); - int c = res.getScaledWidth() / 2; - int x = c - bgRect.width / 2; - int y = 20; - int xf = x + (bgRect.width - fgRect.width) / 2; - int yf = y + (bgRect.height - fgRect.height) / 2; - int fw = (int) ((double) fgRect.width * (currentBoss.getHealth() / currentBoss.getMaxHealth())); - int tx = c - mc.fontRenderer.getStringWidth(name) / 2; - - GL11.glColor4f(1F, 1F, 1F, 1F); - currentBoss.bossBarRenderCallback(res, x, y); - GL11.glEnable(GL11.GL_BLEND); - GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); - mc.renderEngine.bindTexture(currentBoss.getBossBarTexture()); - drawBar(x, y, bgRect.x, bgRect.y, bgRect.width, bgRect.height, true); - drawBar(xf, yf, fgRect.x, fgRect.y, fw, fgRect.height, false); - mc.fontRenderer.drawStringWithShadow(name, tx, y - 10, 0xA2018C); - GL11.glEnable(GL11.GL_BLEND); - - Entity e = (Entity) currentBoss; - EntityPlayer p = mc.thePlayer; - if (e.isDead - || !p.worldObj.loadedEntityList.contains(e) - || MathHelper.pointDistanceSpace(e.posX, e.posY, e.posZ, p.posX, p.posY, p.posZ) > 32) - currentBoss = null; - } - - public static void drawBar(int x, int y, int u, int v, int w, int h, boolean bg) { - boolean useShader = currentBoss instanceof IBotaniaBossWithShader; - if (useShader) { - IBotaniaBossWithShader shader = (IBotaniaBossWithShader) currentBoss; - int program = shader.getBossBarShaderProgram(bg); - ShaderCallback callback = program == 0 ? null : shader.getBossBarShaderCallback(bg, program); - barUniformCallback.set(u, v, callback); - - ShaderHelper.useShader(program, barUniformCallback); - } - - RenderHelper.drawTexturedModalRect(x, y, 0, u, v, w, h); - - if (useShader) ShaderHelper.releaseShader(); - } - - static class BarCallback extends ShaderCallback { - int x, y; - ShaderCallback callback; - - @Override - public void call(int shader) { - int startXUniform = ARBShaderObjects.glGetUniformLocationARB(shader, "startX"); - int startYUniform = ARBShaderObjects.glGetUniformLocationARB(shader, "startY"); - - ARBShaderObjects.glUniform1iARB(startXUniform, x); - ARBShaderObjects.glUniform1iARB(startYUniform, y); - - if (callback != null) callback.call(shader); - } - - void set(int x, int y, ShaderCallback callback) { - this.x = x; - this.y = y; - this.callback = callback; - } - } + public static final ResourceLocation defaultBossBar = new ResourceLocation(LibResources.GUI_BOSS_BAR); + static IBotaniaBoss currentBoss; + + private static final BarCallback barUniformCallback = new BarCallback(); + + public static void setCurrentBoss(IBotaniaBoss status) { + currentBoss = status; + } + + public static void render(ScaledResolution res) { + if(currentBoss == null) + return; + + Minecraft mc = Minecraft.getMinecraft(); + Rectangle bgRect = currentBoss.getBossBarTextureRect(); + Rectangle fgRect = currentBoss.getBossBarHPTextureRect(); + String name = currentBoss.func_145748_c_().getFormattedText(); + int c = res.getScaledWidth() / 2; + int x = c - bgRect.width / 2; + int y = 20; + int xf = x + (bgRect.width - fgRect.width) / 2; + int yf = y + (bgRect.height - fgRect.height) / 2; + int fw = (int) ((double) fgRect.width * (currentBoss.getHealth() / currentBoss.getMaxHealth())); + int tx = c - mc.fontRenderer.getStringWidth(name) / 2; + + GL11.glColor4f(1F, 1F, 1F, 1F); + currentBoss.bossBarRenderCallback(res, x, y); + GL11.glEnable(GL11.GL_BLEND); + GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); + mc.renderEngine.bindTexture(currentBoss.getBossBarTexture()); + drawBar(x, y, bgRect.x, bgRect.y, bgRect.width, bgRect.height, true); + drawBar(xf, yf, fgRect.x, fgRect.y, fw, fgRect.height, false); + mc.fontRenderer.drawStringWithShadow(name, tx, y - 10, 0xA2018C); + GL11.glEnable(GL11.GL_BLEND); + + Entity e = (Entity) currentBoss; + EntityPlayer p = mc.thePlayer; + if(e.isDead || !p.worldObj.loadedEntityList.contains(e) || MathHelper.pointDistanceSpace(e.posX, e.posY, e.posZ, p.posX, p.posY, p.posZ) > 32) + currentBoss = null; + } + + public static void drawBar(int x, int y, int u, int v, int w, int h, boolean bg) { + boolean useShader = currentBoss instanceof IBotaniaBossWithShader; + if(useShader) { + IBotaniaBossWithShader shader = (IBotaniaBossWithShader) currentBoss; + int program = shader.getBossBarShaderProgram(bg); + ShaderCallback callback = program == 0 ? null : shader.getBossBarShaderCallback(bg, program); + barUniformCallback.set(u, v, callback); + + ShaderHelper.useShader(program, barUniformCallback); + } + + RenderHelper.drawTexturedModalRect(x, y, 0, u, v, w, h); + + if(useShader) + ShaderHelper.releaseShader(); + } + + static class BarCallback extends ShaderCallback { + int x, y; + ShaderCallback callback; + + @Override + public void call(int shader) { + int startXUniform = ARBShaderObjects.glGetUniformLocationARB(shader, "startX"); + int startYUniform = ARBShaderObjects.glGetUniformLocationARB(shader, "startY"); + + + ARBShaderObjects.glUniform1iARB(startXUniform, x); + ARBShaderObjects.glUniform1iARB(startYUniform, y); + + if(callback != null) + callback.call(shader); + } + + void set(int x, int y, ShaderCallback callback) { + this.x = x; + this.y = y; + this.callback = callback; + } + } + } diff --git a/src/main/java/vazkii/botania/client/core/handler/BotaniaPlayerController.java b/src/main/java/vazkii/botania/client/core/handler/BotaniaPlayerController.java index c9c649109d..a9610ad3a3 100644 --- a/src/main/java/vazkii/botania/client/core/handler/BotaniaPlayerController.java +++ b/src/main/java/vazkii/botania/client/core/handler/BotaniaPlayerController.java @@ -2,42 +2,43 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jul 22, 2014, 3:33:25 PM (GMT)] */ package vazkii.botania.client.core.handler; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; import net.minecraft.client.Minecraft; import net.minecraft.client.multiplayer.PlayerControllerMP; import net.minecraft.client.network.NetHandlerPlayClient; import vazkii.botania.api.item.IExtendedPlayerController; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; @SideOnly(Side.CLIENT) public class BotaniaPlayerController extends PlayerControllerMP implements IExtendedPlayerController { - private float distance = 0F; + private float distance = 0F; + + public BotaniaPlayerController(Minecraft p_i45062_1_, NetHandlerPlayClient p_i45062_2_) { + super(p_i45062_1_, p_i45062_2_); + } - public BotaniaPlayerController(Minecraft p_i45062_1_, NetHandlerPlayClient p_i45062_2_) { - super(p_i45062_1_, p_i45062_2_); - } + @Override + public float getBlockReachDistance() { + return super.getBlockReachDistance() + distance; + } - @Override - public float getBlockReachDistance() { - return super.getBlockReachDistance() + distance; - } + @Override + public void setReachDistanceExtension(float f) { + distance = f; + } - @Override - public void setReachDistanceExtension(float f) { - distance = f; - } + @Override + public float getReachDistanceExtension() { + return distance; + } - @Override - public float getReachDistanceExtension() { - return distance; - } } diff --git a/src/main/java/vazkii/botania/client/core/handler/BoundTileRenderer.java b/src/main/java/vazkii/botania/client/core/handler/BoundTileRenderer.java index 5203e217f9..232d8a3107 100644 --- a/src/main/java/vazkii/botania/client/core/handler/BoundTileRenderer.java +++ b/src/main/java/vazkii/botania/client/core/handler/BoundTileRenderer.java @@ -2,17 +2,17 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Mar 24, 2014, 7:02:37 PM (GMT)] */ package vazkii.botania.client.core.handler; -import cpw.mods.fml.common.eventhandler.SubscribeEvent; import java.awt.Color; import java.util.List; + import net.minecraft.block.Block; import net.minecraft.client.Minecraft; import net.minecraft.client.renderer.Tessellator; @@ -24,161 +24,164 @@ import net.minecraft.util.ChunkCoordinates; import net.minecraft.world.World; import net.minecraftforge.client.event.RenderWorldLastEvent; + import org.lwjgl.opengl.GL11; + import vazkii.botania.api.BotaniaAPI; import vazkii.botania.api.item.IExtendedWireframeCoordinateListProvider; import vazkii.botania.api.item.IWireframeCoordinateListProvider; import vazkii.botania.api.wand.ICoordBoundItem; import vazkii.botania.api.wand.IWireframeAABBProvider; +import cpw.mods.fml.common.eventhandler.SubscribeEvent; public final class BoundTileRenderer { - @SubscribeEvent - public void onWorldRenderLast(RenderWorldLastEvent event) { - GL11.glPushMatrix(); - GL11.glPushAttrib(GL11.GL_LIGHTING); - GL11.glDisable(GL11.GL_DEPTH_TEST); - GL11.glDisable(GL11.GL_TEXTURE_2D); - GL11.glDisable(GL11.GL_LIGHTING); - GL11.glEnable(GL11.GL_BLEND); - - Tessellator.renderingWorldRenderer = false; - - EntityPlayer player = Minecraft.getMinecraft().thePlayer; - ItemStack stack = player.getCurrentEquippedItem(); - int color = Color.HSBtoRGB(ClientTickHandler.ticksInGame % 200 / 200F, 0.6F, 1F); - if (stack != null && stack.getItem() instanceof ICoordBoundItem) { - ChunkCoordinates coords = ((ICoordBoundItem) stack.getItem()).getBinding(stack); - if (coords != null) renderBlockOutlineAt(coords, color); - } - - IInventory mainInv = player.inventory; - IInventory baublesInv = BotaniaAPI.internalHandler.getBaublesInventory(player); - - int invSize = mainInv.getSizeInventory(); - int size = invSize; - if (baublesInv != null) size += baublesInv.getSizeInventory(); - - for (int i = 0; i < size; i++) { - boolean useBaubles = i >= invSize; - IInventory inv = useBaubles ? baublesInv : mainInv; - ItemStack stackInSlot = inv.getStackInSlot(i - (useBaubles ? invSize : 0)); - - if (stackInSlot != null && stackInSlot.getItem() instanceof IWireframeCoordinateListProvider) { - IWireframeCoordinateListProvider provider = (IWireframeCoordinateListProvider) stackInSlot.getItem(); - List coordsList = provider.getWireframesToDraw(player, stackInSlot); - if (coordsList != null) for (ChunkCoordinates coords : coordsList) renderBlockOutlineAt(coords, color); - - if (stackInSlot.getItem() instanceof IExtendedWireframeCoordinateListProvider) { - ChunkCoordinates coords = ((IExtendedWireframeCoordinateListProvider) stackInSlot.getItem()) - .getSourceWireframe(player, stackInSlot); - if (coords != null && coords.posY > -1) renderBlockOutlineAt(coords, color, 5F); - } - } - } - - GL11.glEnable(GL11.GL_DEPTH_TEST); - GL11.glEnable(GL11.GL_TEXTURE_2D); - GL11.glDisable(GL11.GL_BLEND); - GL11.glPopAttrib(); - GL11.glPopMatrix(); - } - - private void renderBlockOutlineAt(ChunkCoordinates pos, int color) { - renderBlockOutlineAt(pos, color, 1F); - } - - private void renderBlockOutlineAt(ChunkCoordinates pos, int color, float thickness) { - GL11.glPushMatrix(); - GL11.glTranslated( - pos.posX - RenderManager.renderPosX, - pos.posY - RenderManager.renderPosY, - pos.posZ - RenderManager.renderPosZ + 1); - Color colorRGB = new Color(color); - GL11.glColor4ub((byte) colorRGB.getRed(), (byte) colorRGB.getGreen(), (byte) colorRGB.getBlue(), (byte) 255); - - World world = Minecraft.getMinecraft().theWorld; - Block block = world.getBlock(pos.posX, pos.posY, pos.posZ); - drawWireframe: - { - if (block != null) { - AxisAlignedBB axis; - - if (block instanceof IWireframeAABBProvider) - axis = ((IWireframeAABBProvider) block).getWireframeAABB(world, pos.posX, pos.posY, pos.posZ); - else axis = block.getSelectedBoundingBoxFromPool(world, pos.posX, pos.posY, pos.posZ); - - if (axis == null) break drawWireframe; - - axis.minX -= pos.posX; - axis.maxX -= pos.posX; - axis.minY -= pos.posY; - axis.maxY -= pos.posY; - axis.minZ -= pos.posZ + 1; - axis.maxZ -= pos.posZ + 1; - - GL11.glScalef(1F, 1F, 1F); - - GL11.glLineWidth(thickness); - renderBlockOutline(axis); - - GL11.glLineWidth(thickness + 3F); - GL11.glColor4ub( - (byte) colorRGB.getRed(), (byte) colorRGB.getGreen(), (byte) colorRGB.getBlue(), (byte) 64); - renderBlockOutline(axis); - } - } - - GL11.glPopMatrix(); - } - - private void renderBlockOutline(AxisAlignedBB aabb) { - Tessellator tessellator = Tessellator.instance; - - double ix = aabb.minX; - double iy = aabb.minY; - double iz = aabb.minZ; - double ax = aabb.maxX; - double ay = aabb.maxY; - double az = aabb.maxZ; - - tessellator.startDrawing(GL11.GL_LINES); - tessellator.addVertex(ix, iy, iz); - tessellator.addVertex(ix, ay, iz); - - tessellator.addVertex(ix, ay, iz); - tessellator.addVertex(ax, ay, iz); - - tessellator.addVertex(ax, ay, iz); - tessellator.addVertex(ax, iy, iz); - - tessellator.addVertex(ax, iy, iz); - tessellator.addVertex(ix, iy, iz); - - tessellator.addVertex(ix, iy, az); - tessellator.addVertex(ix, ay, az); - - tessellator.addVertex(ix, iy, az); - tessellator.addVertex(ax, iy, az); - - tessellator.addVertex(ax, iy, az); - tessellator.addVertex(ax, ay, az); - - tessellator.addVertex(ix, ay, az); - tessellator.addVertex(ax, ay, az); - - tessellator.addVertex(ix, iy, iz); - tessellator.addVertex(ix, iy, az); - - tessellator.addVertex(ix, ay, iz); - tessellator.addVertex(ix, ay, az); - - tessellator.addVertex(ax, iy, iz); - tessellator.addVertex(ax, iy, az); + @SubscribeEvent + public void onWorldRenderLast(RenderWorldLastEvent event) { + GL11.glPushMatrix(); + GL11.glPushAttrib(GL11.GL_LIGHTING); + GL11.glDisable(GL11.GL_DEPTH_TEST); + GL11.glDisable(GL11.GL_TEXTURE_2D); + GL11.glDisable(GL11.GL_LIGHTING); + GL11.glEnable(GL11.GL_BLEND); + + Tessellator.renderingWorldRenderer = false; + + EntityPlayer player = Minecraft.getMinecraft().thePlayer; + ItemStack stack = player.getCurrentEquippedItem(); + int color = Color.HSBtoRGB(ClientTickHandler.ticksInGame % 200 / 200F, 0.6F, 1F); + if(stack != null && stack.getItem() instanceof ICoordBoundItem) { + ChunkCoordinates coords = ((ICoordBoundItem) stack.getItem()).getBinding(stack); + if(coords != null) + renderBlockOutlineAt(coords, color); + } + + IInventory mainInv = player.inventory; + IInventory baublesInv = BotaniaAPI.internalHandler.getBaublesInventory(player); + + int invSize = mainInv.getSizeInventory(); + int size = invSize; + if(baublesInv != null) + size += baublesInv.getSizeInventory(); + + for(int i = 0; i < size; i++) { + boolean useBaubles = i >= invSize; + IInventory inv = useBaubles ? baublesInv : mainInv; + ItemStack stackInSlot = inv.getStackInSlot(i - (useBaubles ? invSize : 0)); + + if(stackInSlot != null && stackInSlot.getItem() instanceof IWireframeCoordinateListProvider) { + IWireframeCoordinateListProvider provider = (IWireframeCoordinateListProvider) stackInSlot.getItem(); + List coordsList = provider.getWireframesToDraw(player, stackInSlot); + if(coordsList != null) + for(ChunkCoordinates coords : coordsList) + renderBlockOutlineAt(coords, color); + + if(stackInSlot.getItem() instanceof IExtendedWireframeCoordinateListProvider) { + ChunkCoordinates coords = ((IExtendedWireframeCoordinateListProvider) stackInSlot.getItem()).getSourceWireframe(player, stackInSlot); + if(coords != null && coords.posY > -1) + renderBlockOutlineAt(coords, color, 5F); + } + } + } + + GL11.glEnable(GL11.GL_DEPTH_TEST); + GL11.glEnable(GL11.GL_TEXTURE_2D); + GL11.glDisable(GL11.GL_BLEND); + GL11.glPopAttrib(); + GL11.glPopMatrix(); + } + + private void renderBlockOutlineAt(ChunkCoordinates pos, int color) { + renderBlockOutlineAt(pos, color, 1F); + } + + private void renderBlockOutlineAt(ChunkCoordinates pos, int color, float thickness) { + GL11.glPushMatrix(); + GL11.glTranslated(pos.posX - RenderManager.renderPosX, pos.posY - RenderManager.renderPosY, pos.posZ - RenderManager.renderPosZ + 1); + Color colorRGB = new Color(color); + GL11.glColor4ub((byte) colorRGB.getRed(), (byte) colorRGB.getGreen(), (byte) colorRGB.getBlue(), (byte) 255); + + World world = Minecraft.getMinecraft().theWorld; + Block block = world.getBlock(pos.posX, pos.posY, pos.posZ); + drawWireframe : { + if(block != null) { + AxisAlignedBB axis; + + if(block instanceof IWireframeAABBProvider) + axis = ((IWireframeAABBProvider) block).getWireframeAABB(world, pos.posX, pos.posY, pos.posZ); + else axis = block.getSelectedBoundingBoxFromPool(world, pos.posX, pos.posY, pos.posZ); + + if(axis == null) + break drawWireframe; + + axis.minX -= pos.posX; + axis.maxX -= pos.posX; + axis.minY -= pos.posY; + axis.maxY -= pos.posY; + axis.minZ -= pos.posZ + 1; + axis.maxZ -= pos.posZ + 1; + + GL11.glScalef(1F, 1F, 1F); + + GL11.glLineWidth(thickness); + renderBlockOutline(axis); + + GL11.glLineWidth(thickness + 3F); + GL11.glColor4ub((byte) colorRGB.getRed(), (byte) colorRGB.getGreen(), (byte) colorRGB.getBlue(), (byte) 64); + renderBlockOutline(axis); + } + } + + GL11.glPopMatrix(); + } + + private void renderBlockOutline(AxisAlignedBB aabb) { + Tessellator tessellator = Tessellator.instance; + + double ix = aabb.minX; + double iy = aabb.minY; + double iz = aabb.minZ; + double ax = aabb.maxX; + double ay = aabb.maxY; + double az = aabb.maxZ; + + tessellator.startDrawing(GL11.GL_LINES); + tessellator.addVertex(ix, iy, iz); + tessellator.addVertex(ix, ay, iz); + + tessellator.addVertex(ix, ay, iz); + tessellator.addVertex(ax, ay, iz); + + tessellator.addVertex(ax, ay, iz); + tessellator.addVertex(ax, iy, iz); + + tessellator.addVertex(ax, iy, iz); + tessellator.addVertex(ix, iy, iz); + + tessellator.addVertex(ix, iy, az); + tessellator.addVertex(ix, ay, az); + + tessellator.addVertex(ix, iy, az); + tessellator.addVertex(ax, iy, az); + + tessellator.addVertex(ax, iy, az); + tessellator.addVertex(ax, ay, az); + + tessellator.addVertex(ix, ay, az); + tessellator.addVertex(ax, ay, az); + + tessellator.addVertex(ix, iy, iz); + tessellator.addVertex(ix, iy, az); + + tessellator.addVertex(ix, ay, iz); + tessellator.addVertex(ix, ay, az); + + tessellator.addVertex(ax, iy, iz); + tessellator.addVertex(ax, iy, az); - tessellator.addVertex(ax, ay, iz); - tessellator.addVertex(ax, ay, az); + tessellator.addVertex(ax, ay, iz); + tessellator.addVertex(ax, ay, az); - tessellator.draw(); - } + tessellator.draw(); + } } diff --git a/src/main/java/vazkii/botania/client/core/handler/ClientTickHandler.java b/src/main/java/vazkii/botania/client/core/handler/ClientTickHandler.java index 4d216681d6..3f88f926a0 100644 --- a/src/main/java/vazkii/botania/client/core/handler/ClientTickHandler.java +++ b/src/main/java/vazkii/botania/client/core/handler/ClientTickHandler.java @@ -2,20 +2,17 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Feb 3, 2014, 9:59:17 PM (GMT)] */ package vazkii.botania.client.core.handler; -import cpw.mods.fml.common.eventhandler.SubscribeEvent; -import cpw.mods.fml.common.gameevent.TickEvent.ClientTickEvent; -import cpw.mods.fml.common.gameevent.TickEvent.Phase; -import cpw.mods.fml.common.gameevent.TickEvent.RenderTickEvent; import java.util.ArrayList; import java.util.List; + import net.minecraft.client.Minecraft; import net.minecraft.client.gui.GuiScreen; import net.minecraft.entity.player.EntityPlayer; @@ -29,83 +26,95 @@ import vazkii.botania.common.block.tile.corporea.TileCorporeaIndex; import vazkii.botania.common.core.handler.ManaNetworkHandler; import vazkii.botania.common.item.ItemTwigWand; +import cpw.mods.fml.common.eventhandler.SubscribeEvent; +import cpw.mods.fml.common.gameevent.TickEvent.ClientTickEvent; +import cpw.mods.fml.common.gameevent.TickEvent.Phase; +import cpw.mods.fml.common.gameevent.TickEvent.RenderTickEvent; public class ClientTickHandler { - public static int ticksWithLexicaOpen = 0; - public static int pageFlipTicks = 0; - public static int ticksInGame = 0; - public static float partialTicks = 0; - public static float delta = 0; - public static float total = 0; + public static int ticksWithLexicaOpen = 0; + public static int pageFlipTicks = 0; + public static int ticksInGame = 0; + public static float partialTicks = 0; + public static float delta = 0; + public static float total = 0; + + private void calcDelta() { + float oldTotal = total; + total = ticksInGame + partialTicks; + delta = total - oldTotal; + } - private void calcDelta() { - float oldTotal = total; - total = ticksInGame + partialTicks; - delta = total - oldTotal; - } + @SubscribeEvent + public void renderTick(RenderTickEvent event) { + if(event.phase == Phase.START) + partialTicks = event.renderTickTime; + else { + TooltipAdditionDisplayHandler.render(); + calcDelta(); + } + } - @SubscribeEvent - public void renderTick(RenderTickEvent event) { - if (event.phase == Phase.START) partialTicks = event.renderTickTime; - else { - TooltipAdditionDisplayHandler.render(); - calcDelta(); - } - } + @SubscribeEvent + public void clientTickEnd(ClientTickEvent event) { + if(event.phase == Phase.END) { + LightningBolt.update(); + RedStringRenderer.tick(); + ItemsRemainingRenderHandler.tick(); - @SubscribeEvent - public void clientTickEnd(ClientTickEvent event) { - if (event.phase == Phase.END) { - LightningBolt.update(); - RedStringRenderer.tick(); - ItemsRemainingRenderHandler.tick(); + if(Minecraft.getMinecraft().theWorld == null) { + ManaNetworkHandler.instance.clear(); + TileCorporeaIndex.indexes.clear(); + SubTileVinculotus.existingFlowers.clear(); + } - if (Minecraft.getMinecraft().theWorld == null) { - ManaNetworkHandler.instance.clear(); - TileCorporeaIndex.indexes.clear(); - SubTileVinculotus.existingFlowers.clear(); - } + GuiScreen gui = Minecraft.getMinecraft().currentScreen; + if(gui == null || !gui.doesGuiPauseGame()) { + ticksInGame++; + partialTicks = 0; - GuiScreen gui = Minecraft.getMinecraft().currentScreen; - if (gui == null || !gui.doesGuiPauseGame()) { - ticksInGame++; - partialTicks = 0; + EntityPlayer player = Minecraft.getMinecraft().thePlayer; + if(player != null) { + ItemStack stack = player.getCurrentEquippedItem(); + if(stack != null && stack.getItem() instanceof ItemTwigWand) { + List list = new ArrayList(ManaNetworkHandler.instance.getAllCollectorsInWorld(Minecraft.getMinecraft().theWorld)); + for(TileSignature sig : list) { + if(!sig.remoteWorld) + continue; - EntityPlayer player = Minecraft.getMinecraft().thePlayer; - if (player != null) { - ItemStack stack = player.getCurrentEquippedItem(); - if (stack != null && stack.getItem() instanceof ItemTwigWand) { - List list = new ArrayList( - ManaNetworkHandler.instance.getAllCollectorsInWorld(Minecraft.getMinecraft().theWorld)); - for (TileSignature sig : list) { - if (!sig.remoteWorld) continue; + TileEntity tile = sig.tile; + if(tile instanceof IManaCollector) + ((IManaCollector) tile).onClientDisplayTick(); + } + } + } + } - TileEntity tile = sig.tile; - if (tile instanceof IManaCollector) ((IManaCollector) tile).onClientDisplayTick(); - } - } - } - } + int ticksToOpen = 10; + if(gui instanceof GuiLexicon) { + if(ticksWithLexicaOpen < 0) + ticksWithLexicaOpen = 0; + if(ticksWithLexicaOpen < ticksToOpen) + ticksWithLexicaOpen++; + if(pageFlipTicks > 0) + pageFlipTicks--; + } else { + pageFlipTicks = 0; + if(ticksWithLexicaOpen > 0) { + if(ticksWithLexicaOpen > ticksToOpen) + ticksWithLexicaOpen = ticksToOpen; + ticksWithLexicaOpen--; + } + } - int ticksToOpen = 10; - if (gui instanceof GuiLexicon) { - if (ticksWithLexicaOpen < 0) ticksWithLexicaOpen = 0; - if (ticksWithLexicaOpen < ticksToOpen) ticksWithLexicaOpen++; - if (pageFlipTicks > 0) pageFlipTicks--; - } else { - pageFlipTicks = 0; - if (ticksWithLexicaOpen > 0) { - if (ticksWithLexicaOpen > ticksToOpen) ticksWithLexicaOpen = ticksToOpen; - ticksWithLexicaOpen--; - } - } + calcDelta(); + } + } - calcDelta(); - } - } + public static void notifyPageChange() { + if(pageFlipTicks == 0) + pageFlipTicks = 5; + } - public static void notifyPageChange() { - if (pageFlipTicks == 0) pageFlipTicks = 5; - } } diff --git a/src/main/java/vazkii/botania/client/core/handler/ContributorFancinessHandler.java b/src/main/java/vazkii/botania/client/core/handler/ContributorFancinessHandler.java index be8c2262a4..2a652019b4 100644 --- a/src/main/java/vazkii/botania/client/core/handler/ContributorFancinessHandler.java +++ b/src/main/java/vazkii/botania/client/core/handler/ContributorFancinessHandler.java @@ -2,20 +2,20 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Apr 9, 2015, 5:35:26 PM (GMT)] */ package vazkii.botania.client.core.handler; -import cpw.mods.fml.common.FMLLog; import java.io.InputStreamReader; import java.net.URL; import java.util.HashMap; import java.util.Map; import java.util.Properties; + import net.minecraft.client.Minecraft; import net.minecraft.client.renderer.ItemRenderer; import net.minecraft.client.renderer.Tessellator; @@ -23,7 +23,9 @@ import net.minecraft.client.settings.GameSettings.Options; import net.minecraft.util.IIcon; import net.minecraftforge.client.event.RenderPlayerEvent; + import org.lwjgl.opengl.GL11; + import vazkii.botania.api.BotaniaAPI; import vazkii.botania.api.item.IBaubleRender.Helper; import vazkii.botania.api.subtile.signature.SubTileSignature; @@ -32,165 +34,165 @@ import vazkii.botania.common.item.ModItems; import vazkii.botania.common.item.block.ItemBlockSpecialFlower; import vazkii.botania.common.item.material.ItemManaResource; +import cpw.mods.fml.common.FMLLog; public final class ContributorFancinessHandler { - public static volatile Map flowerMap = null; - private static volatile boolean startedLoading = false; - - private static boolean phi = true; - - public static void render(RenderPlayerEvent.Specials event) { - String name = event.entityPlayer.getDisplayName(); - - if (name.equals("Vazkii") || name.equals("_phi")) { - if (phi) renderPhiFlower(event); - else renderTwintails(event); - } else if (name.equals("haighyorkie")) renderGoldfish(event); - - firstStart(); - - name = name.toLowerCase(); - if (Minecraft.getMinecraft().gameSettings.getOptionOrdinalValue(Options.SHOW_CAPE) - && flowerMap != null - && flowerMap.containsKey(name)) renderFlower(event, flowerMap.get(name)); - } - - public static void firstStart() { - if (!startedLoading) { - new ThreadContributorListLoader(); - startedLoading = true; - } - } - - public static void load(Properties props) { - flowerMap = new HashMap(); - for (String key : props.stringPropertyNames()) { - String value = props.getProperty(key); - - try { - int i = Integer.parseInt(value); - if (i < 0 || i >= 16) throw new NumberFormatException(); - flowerMap.put(key, ModBlocks.flower.func_149735_b(0, i)); - } catch (NumberFormatException e) { - SubTileSignature sig = BotaniaAPI.getSignatureForName(value); - if (sig != null) - flowerMap.put(key, ItemBlockSpecialFlower.ofType(value).getIconIndex()); - } - } - } - - private static void renderTwintails(RenderPlayerEvent event) { - GL11.glPushMatrix(); - IIcon icon = ((ItemManaResource) ModItems.manaResource).tailIcon; - float f = icon.getMinU(); - float f1 = icon.getMaxU(); - float f2 = icon.getMinV(); - float f3 = icon.getMaxV(); - Helper.translateToHeadLevel(event.entityPlayer); - Minecraft.getMinecraft().renderEngine.bindTexture(TextureMap.locationItemsTexture); - GL11.glColor4f(1F, 1F, 1F, 1F); - GL11.glRotatef(90F, 0F, 1F, 0F); - float t = 0.13F; - GL11.glTranslatef(t, -0.5F, -0.1F); - if (event.entityPlayer.motionY < 0) GL11.glRotatef((float) event.entityPlayer.motionY * 20F, 1F, 0F, 0F); - - float r = -18F + (float) Math.sin((ClientTickHandler.ticksInGame + event.partialRenderTick) * 0.05F) * 2F; - GL11.glRotatef(r, 0F, 0F, 1F); - float s = 0.9F; - GL11.glScalef(s, s, s); - ItemRenderer.renderItemIn2D( - Tessellator.instance, f1, f2, f, f3, icon.getIconWidth(), icon.getIconHeight(), 1F / 16F); - GL11.glRotatef(-r, 0F, 0F, 1F); - GL11.glTranslatef(-t, -0F, 0F); - GL11.glScalef(-1F, 1F, 1F); - GL11.glTranslatef(t, -0F, 0F); - GL11.glRotatef(r, 0F, 0F, 1F); - ItemRenderer.renderItemIn2D( - Tessellator.instance, f1, f2, f, f3, icon.getIconWidth(), icon.getIconHeight(), 1F / 16F); - GL11.glPopMatrix(); - } - - private static void renderPhiFlower(RenderPlayerEvent event) { - GL11.glPushMatrix(); - IIcon icon = ((ItemManaResource) ModItems.manaResource).phiFlowerIcon; - float f = icon.getMinU(); - float f1 = icon.getMaxU(); - float f2 = icon.getMinV(); - float f3 = icon.getMaxV(); - Helper.translateToHeadLevel(event.entityPlayer); - GL11.glRotatef(90F, 0F, 1F, 0F); - GL11.glRotatef(180F, 1F, 0F, 0F); - GL11.glTranslatef(-0.4F, 0.1F, -0.25F); - Minecraft.getMinecraft().renderEngine.bindTexture(TextureMap.locationItemsTexture); - GL11.glRotatef(90F, 0F, 1F, 0F); - GL11.glScalef(0.4F, 0.4F, 0.4F); - GL11.glTranslatef(-1.2F, 0.2F, 0.125F); - GL11.glRotatef(20F, 1F, 0F, 0F); - ItemRenderer.renderItemIn2D( - Tessellator.instance, f1, f2, f, f3, icon.getIconWidth(), icon.getIconHeight(), 1F / 16F); - GL11.glPopMatrix(); - } - - private static void renderGoldfish(RenderPlayerEvent event) { - GL11.glPushMatrix(); - IIcon icon = ((ItemManaResource) ModItems.manaResource).goldfishIcon; - float f = icon.getMinU(); - float f1 = icon.getMaxU(); - float f2 = icon.getMinV(); - float f3 = icon.getMaxV(); - Helper.rotateIfSneaking(event.entityPlayer); - GL11.glRotatef(90F, 0F, 1F, 0F); - GL11.glRotatef(180F, 0F, 0F, 1F); - GL11.glTranslatef(-0.75F, 0.5F, 0F); - GL11.glScalef(0.4F, 0.4F, 0.4F); - GL11.glTranslatef(1.2F, 0.5F, 0F); - Minecraft.getMinecraft().renderEngine.bindTexture(TextureMap.locationItemsTexture); - ItemRenderer.renderItemIn2D( - Tessellator.instance, f1, f2, f, f3, icon.getIconWidth(), icon.getIconHeight(), 1F / 16F); - GL11.glPopMatrix(); - } - - private static void renderFlower(RenderPlayerEvent event, IIcon icon) { - GL11.glPushMatrix(); - Helper.translateToHeadLevel(event.entityPlayer); - Minecraft.getMinecraft().renderEngine.bindTexture(TextureMap.locationBlocksTexture); - float f = icon.getMinU(); - float f1 = icon.getMaxU(); - float f2 = icon.getMinV(); - float f3 = icon.getMaxV(); - GL11.glRotatef(180F, 0F, 0F, 1F); - GL11.glRotatef(90F, 0F, 1F, 0F); - GL11.glScalef(0.5F, 0.5F, 0.5F); - GL11.glTranslatef(-0.5F, 0.7F, 0F); - - ShaderHelper.useShader(ShaderHelper.gold); - ItemRenderer.renderItemIn2D( - Tessellator.instance, f1, f2, f, f3, icon.getIconWidth(), icon.getIconHeight(), 1F / 16F); - ShaderHelper.releaseShader(); - GL11.glPopMatrix(); - } - - public static class ThreadContributorListLoader extends Thread { - - public ThreadContributorListLoader() { - setName("Botania Contributor Fanciness Thread"); - setDaemon(true); - start(); - } - - @Override - public void run() { - try { - URL url = new URL("https://raw.githubusercontent.com/Vazkii/Botania/master/contributors.properties"); - Properties props = new Properties(); - props.load(new InputStreamReader(url.openStream())); - load(props); - } catch (Exception e) { - FMLLog.info( - "[Botania] Could not load contributors list. Either you're offline or github is down. Nothing to worry about, carry on~"); - e.printStackTrace(); - } - } - } + public volatile static Map flowerMap = null; + private volatile static boolean startedLoading = false; + + private static boolean phi = true; + + public static void render(RenderPlayerEvent.Specials event) { + String name = event.entityPlayer.getDisplayName(); + + if(name.equals("Vazkii") || name.equals("_phi")) { + if(phi) + renderPhiFlower(event); + else renderTwintails(event); + } else if(name.equals("haighyorkie")) + renderGoldfish(event); + + firstStart(); + + name = name.toLowerCase(); + if(Minecraft.getMinecraft().gameSettings.getOptionOrdinalValue(Options.SHOW_CAPE) && flowerMap != null && flowerMap.containsKey(name)) + renderFlower(event, flowerMap.get(name)); + } + + public static void firstStart() { + if(!startedLoading) { + new ThreadContributorListLoader(); + startedLoading = true; + } + } + + public static void load(Properties props) { + flowerMap = new HashMap(); + for(String key : props.stringPropertyNames()) { + String value = props.getProperty(key); + + try { + int i = Integer.parseInt(value); + if(i < 0 || i >= 16) + throw new NumberFormatException(); + flowerMap.put(key, ModBlocks.flower.func_149735_b(0, i)); + } catch(NumberFormatException e) { + SubTileSignature sig = BotaniaAPI.getSignatureForName(value); + if(sig != null) + flowerMap.put(key, ItemBlockSpecialFlower.ofType(value).getIconIndex()); + } + } + } + + private static void renderTwintails(RenderPlayerEvent event) { + GL11.glPushMatrix(); + IIcon icon = ((ItemManaResource) ModItems.manaResource).tailIcon; + float f = icon.getMinU(); + float f1 = icon.getMaxU(); + float f2 = icon.getMinV(); + float f3 = icon.getMaxV(); + Helper.translateToHeadLevel(event.entityPlayer); + Minecraft.getMinecraft().renderEngine.bindTexture(TextureMap.locationItemsTexture); + GL11.glColor4f(1F, 1F, 1F, 1F); + GL11.glRotatef(90F, 0F, 1F, 0F); + float t = 0.13F; + GL11.glTranslatef(t, -0.5F, -0.1F); + if(event.entityPlayer.motionY < 0) + GL11.glRotatef((float) event.entityPlayer.motionY * 20F, 1F, 0F, 0F); + + float r = -18F + (float) Math.sin((ClientTickHandler.ticksInGame + event.partialRenderTick) * 0.05F) * 2F; + GL11.glRotatef(r, 0F, 0F, 1F); + float s = 0.9F; + GL11.glScalef(s, s, s); + ItemRenderer.renderItemIn2D(Tessellator.instance, f1, f2, f, f3, icon.getIconWidth(), icon.getIconHeight(), 1F / 16F); + GL11.glRotatef(-r, 0F, 0F, 1F); + GL11.glTranslatef(-t, -0F, 0F); + GL11.glScalef(-1F, 1F, 1F); + GL11.glTranslatef(t, -0F, 0F); + GL11.glRotatef(r, 0F, 0F, 1F); + ItemRenderer.renderItemIn2D(Tessellator.instance, f1, f2, f, f3, icon.getIconWidth(), icon.getIconHeight(), 1F / 16F); + GL11.glPopMatrix(); + } + + private static void renderPhiFlower(RenderPlayerEvent event) { + GL11.glPushMatrix(); + IIcon icon = ((ItemManaResource) ModItems.manaResource).phiFlowerIcon; + float f = icon.getMinU(); + float f1 = icon.getMaxU(); + float f2 = icon.getMinV(); + float f3 = icon.getMaxV(); + Helper.translateToHeadLevel(event.entityPlayer); + GL11.glRotatef(90F, 0F, 1F, 0F); + GL11.glRotatef(180F, 1F, 0F, 0F); + GL11.glTranslatef(-0.4F, 0.1F, -0.25F); + Minecraft.getMinecraft().renderEngine.bindTexture(TextureMap.locationItemsTexture); + GL11.glRotatef(90F, 0F, 1F, 0F); + GL11.glScalef(0.4F, 0.4F, 0.4F); + GL11.glTranslatef(-1.2F, 0.2F, 0.125F); + GL11.glRotatef(20F, 1F, 0F, 0F); + ItemRenderer.renderItemIn2D(Tessellator.instance, f1, f2, f, f3, icon.getIconWidth(), icon.getIconHeight(), 1F / 16F); + GL11.glPopMatrix(); + } + + private static void renderGoldfish(RenderPlayerEvent event) { + GL11.glPushMatrix(); + IIcon icon = ((ItemManaResource) ModItems.manaResource).goldfishIcon; + float f = icon.getMinU(); + float f1 = icon.getMaxU(); + float f2 = icon.getMinV(); + float f3 = icon.getMaxV(); + Helper.rotateIfSneaking(event.entityPlayer); + GL11.glRotatef(90F, 0F, 1F, 0F); + GL11.glRotatef(180F, 0F, 0F, 1F); + GL11.glTranslatef(-0.75F, 0.5F, 0F); + GL11.glScalef(0.4F, 0.4F, 0.4F); + GL11.glTranslatef(1.2F, 0.5F, 0F); + Minecraft.getMinecraft().renderEngine.bindTexture(TextureMap.locationItemsTexture); + ItemRenderer.renderItemIn2D(Tessellator.instance, f1, f2, f, f3, icon.getIconWidth(), icon.getIconHeight(), 1F / 16F); + GL11.glPopMatrix(); + } + + private static void renderFlower(RenderPlayerEvent event, IIcon icon) { + GL11.glPushMatrix(); + Helper.translateToHeadLevel(event.entityPlayer); + Minecraft.getMinecraft().renderEngine.bindTexture(TextureMap.locationBlocksTexture); + float f = icon.getMinU(); + float f1 = icon.getMaxU(); + float f2 = icon.getMinV(); + float f3 = icon.getMaxV(); + GL11.glRotatef(180F, 0F, 0F, 1F); + GL11.glRotatef(90F, 0F, 1F, 0F); + GL11.glScalef(0.5F, 0.5F, 0.5F); + GL11.glTranslatef(-0.5F, 0.7F, 0F); + + ShaderHelper.useShader(ShaderHelper.gold); + ItemRenderer.renderItemIn2D(Tessellator.instance, f1, f2, f, f3, icon.getIconWidth(), icon.getIconHeight(), 1F / 16F); + ShaderHelper.releaseShader(); + GL11.glPopMatrix(); + } + + public static class ThreadContributorListLoader extends Thread { + + public ThreadContributorListLoader() { + setName("Botania Contributor Fanciness Thread"); + setDaemon(true); + start(); + } + + @Override + public void run() { + try { + URL url = new URL("https://raw.githubusercontent.com/Vazkii/Botania/master/contributors.properties"); + Properties props = new Properties(); + props.load(new InputStreamReader(url.openStream())); + load(props); + } catch(Exception e) { + FMLLog.info("[Botania] Could not load contributors list. Either you're offline or github is down. Nothing to worry about, carry on~"); + e.printStackTrace(); + } + } + + } + } diff --git a/src/main/java/vazkii/botania/client/core/handler/CorporeaAutoCompleteHandler.java b/src/main/java/vazkii/botania/client/core/handler/CorporeaAutoCompleteHandler.java index 3575e8c5b9..b33560e04a 100644 --- a/src/main/java/vazkii/botania/client/core/handler/CorporeaAutoCompleteHandler.java +++ b/src/main/java/vazkii/botania/client/core/handler/CorporeaAutoCompleteHandler.java @@ -2,24 +2,21 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [June 8, 2015, 12:55:20 AM (GMT)] */ package vazkii.botania.client.core.handler; -import cpw.mods.fml.common.eventhandler.SubscribeEvent; -import cpw.mods.fml.common.gameevent.TickEvent.ClientTickEvent; -import cpw.mods.fml.common.gameevent.TickEvent.Phase; -import cpw.mods.fml.relauncher.ReflectionHelper; import java.util.ArrayList; import java.util.Comparator; import java.util.Iterator; import java.util.List; import java.util.SortedSet; import java.util.TreeSet; + import net.minecraft.client.Minecraft; import net.minecraft.client.gui.GuiChat; import net.minecraft.client.gui.GuiScreen; @@ -28,149 +25,166 @@ import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.util.ChatComponentText; + import org.lwjgl.input.Keyboard; + import vazkii.botania.api.corporea.CorporeaHelper; import vazkii.botania.common.lib.LibObfuscation; +import cpw.mods.fml.common.eventhandler.SubscribeEvent; +import cpw.mods.fml.common.gameevent.TickEvent.ClientTickEvent; +import cpw.mods.fml.common.gameevent.TickEvent.Phase; +import cpw.mods.fml.relauncher.ReflectionHelper; public class CorporeaAutoCompleteHandler { - boolean isAutoCompleted = false; - String originalString = ""; - List completions = new ArrayList(); - int position; - - static TreeSet itemNames = new TreeSet(new Comparator() { - @Override - public int compare(String arg0, String arg1) { - return arg0.compareToIgnoreCase(arg1); - } - }); - - private boolean tabLastTick = false; - - public static void updateItemList() { - itemNames.clear(); - Iterator iterator = Item.itemRegistry.iterator(); - ArrayList curList = new ArrayList(); - - while (iterator.hasNext()) { - Item item = iterator.next(); - - if (item != null && item.getCreativeTab() != null) { - curList.clear(); - try { - item.getSubItems(item, (CreativeTabs) null, curList); - for (ItemStack stack : curList) - itemNames.add(CorporeaHelper.stripControlCodes( - stack.getDisplayName().trim())); - } catch (Exception e) { - } - } - } - } - - @SubscribeEvent - public void onTick(ClientTickEvent event) { - if (event.phase != Phase.END) return; - GuiScreen screen = Minecraft.getMinecraft().currentScreen; - if (!(screen instanceof GuiChat)) { - isAutoCompleted = false; - return; - } - GuiChat chat = (GuiChat) screen; - if (isAutoCompleted) { - boolean valid = ReflectionHelper.getPrivateValue(GuiChat.class, chat, LibObfuscation.COMPLETE_FLAG); - if (!valid) isAutoCompleted = false; - } - if (Keyboard.isKeyDown(15)) { - if (tabLastTick) return; - tabLastTick = true; - } else { - tabLastTick = false; - return; - } - - if (!CorporeaHelper.shouldAutoComplete()) return; - - GuiTextField inputField = ReflectionHelper.getPrivateValue(GuiChat.class, chat, LibObfuscation.INPUT_FIELD); - if (!isAutoCompleted) buildAutoCompletes(inputField, chat); - if (isAutoCompleted && !completions.isEmpty()) advanceAutoComplete(inputField, chat); - } - - private void advanceAutoComplete(GuiTextField inputField, GuiChat chat) { - position++; - if (position >= completions.size()) position -= completions.size(); - CompletionData data = completions.get(position); - String str = originalString.substring(0, originalString.length() - data.prefixLength) + data.string; - inputField.setText(str); - } - - private void buildAutoCompletes(GuiTextField inputField, GuiChat chat) { - String leftOfCursor; - if (inputField.getCursorPosition() == 0) leftOfCursor = ""; - else leftOfCursor = inputField.getText().substring(0, inputField.getCursorPosition()); - if (leftOfCursor.length() == 0 || leftOfCursor.charAt(0) == '/') return; - completions = getNames(leftOfCursor); - if (completions.isEmpty()) return; - position = -1; - ReflectionHelper.setPrivateValue(GuiChat.class, chat, true, LibObfuscation.COMPLETE_FLAG); - StringBuilder stringbuilder = new StringBuilder(); - CompletionData data; - for (Iterator iterator = completions.iterator(); - iterator.hasNext(); - stringbuilder.append(data.string)) { - data = iterator.next(); - if (stringbuilder.length() > 0) stringbuilder.append(", "); - } - - Minecraft.getMinecraft() - .ingameGUI - .getChatGUI() - .printChatMessageWithOptionalDeletion(new ChatComponentText(stringbuilder.toString()), 1); - isAutoCompleted = true; - originalString = inputField.getText(); - } - - private ArrayList getNames(String prefix) { - String s = prefix.trim(); - if (s.isEmpty()) return new ArrayList(); - - TreeSet result = new TreeSet(); - String[] words = s.split(" "); - int i = words.length - 1; - String curPrefix = words[i]; - while (i >= 0) { - result.addAll(getNamesStartingWith(curPrefix.toLowerCase())); - i--; - if (i >= 0) curPrefix = words[i] + " " + curPrefix; - } - return new ArrayList(result); - } - - private List getNamesStartingWith(String prefix) { - ArrayList result = new ArrayList(); - int length = prefix.length(); - SortedSet after = itemNames.tailSet(prefix); - for (String str : after) { - if (str.toLowerCase().startsWith(prefix)) result.add(new CompletionData(str, length)); - else return result; - } - return result; - } - - private static class CompletionData implements Comparable { - - private String string; - private int prefixLength; - - public CompletionData(String string, int prefixLength) { - this.string = string; - this.prefixLength = prefixLength; - } - - @Override - public int compareTo(CompletionData arg0) { - return string.compareTo(arg0.string); - } - } + boolean isAutoCompleted = false; + String originalString = ""; + List completions = new ArrayList(); + int position; + + static TreeSet itemNames = new TreeSet( + new Comparator() { + @Override + public int compare(String arg0, String arg1) { + return arg0.compareToIgnoreCase(arg1); + } + }); + + private boolean tabLastTick = false; + + public static void updateItemList() { + itemNames.clear(); + Iterator iterator = Item.itemRegistry.iterator(); + ArrayList curList = new ArrayList(); + + while(iterator.hasNext()) { + Item item = iterator.next(); + + if(item != null && item.getCreativeTab() != null) { + curList.clear(); + try { + item.getSubItems(item, (CreativeTabs) null, curList); + for(ItemStack stack : curList) + itemNames.add(CorporeaHelper.stripControlCodes(stack.getDisplayName().trim())); + } + catch (Exception e) {} + } + } + } + + @SubscribeEvent + public void onTick(ClientTickEvent event) { + if(event.phase != Phase.END) + return; + GuiScreen screen = Minecraft.getMinecraft().currentScreen; + if(!(screen instanceof GuiChat)) { + isAutoCompleted = false; + return; + } + GuiChat chat = (GuiChat) screen; + if(isAutoCompleted) { + boolean valid = ReflectionHelper.getPrivateValue(GuiChat.class, chat, LibObfuscation.COMPLETE_FLAG); + if(!valid) + isAutoCompleted = false; + } + if(Keyboard.isKeyDown(15)) { + if(tabLastTick) + return; + tabLastTick = true; + } else { + tabLastTick = false; + return; + } + + if(!CorporeaHelper.shouldAutoComplete()) + return; + + GuiTextField inputField = ReflectionHelper.getPrivateValue(GuiChat.class, chat, LibObfuscation.INPUT_FIELD); + if(!isAutoCompleted) + buildAutoCompletes(inputField, chat); + if(isAutoCompleted && !completions.isEmpty()) + advanceAutoComplete(inputField, chat); + } + + private void advanceAutoComplete(GuiTextField inputField, GuiChat chat) { + position++; + if(position >= completions.size()) + position -= completions.size(); + CompletionData data = completions.get(position); + String str = originalString.substring(0, originalString.length() - data.prefixLength) + data.string; + inputField.setText(str); + } + + private void buildAutoCompletes(GuiTextField inputField, GuiChat chat) { + String leftOfCursor; + if(inputField.getCursorPosition() == 0) + leftOfCursor = ""; + else + leftOfCursor = inputField.getText().substring(0, inputField.getCursorPosition()); + if(leftOfCursor.length() == 0 || leftOfCursor.charAt(0) == '/') + return; + completions = getNames(leftOfCursor); + if(completions.isEmpty()) + return; + position = -1; + ReflectionHelper.setPrivateValue(GuiChat.class, chat, true, LibObfuscation.COMPLETE_FLAG); + StringBuilder stringbuilder = new StringBuilder(); + CompletionData data; + for(Iterator iterator = completions.iterator(); iterator.hasNext(); stringbuilder.append(data.string)) { + data = iterator.next(); + if(stringbuilder.length() > 0) + stringbuilder.append(", "); + } + + Minecraft.getMinecraft().ingameGUI.getChatGUI().printChatMessageWithOptionalDeletion(new ChatComponentText(stringbuilder.toString()), 1); + isAutoCompleted = true; + originalString = inputField.getText(); + } + + private ArrayList getNames(String prefix) { + String s = prefix.trim(); + if(s.isEmpty()) + return new ArrayList(); + + TreeSet result = new TreeSet(); + String[] words = s.split(" "); + int i = words.length - 1; + String curPrefix = words[i]; + while(i >= 0) { + result.addAll(getNamesStartingWith(curPrefix.toLowerCase())); + i--; + if(i >= 0) + curPrefix = words[i] + " " + curPrefix; + } + return new ArrayList(result); + } + + private List getNamesStartingWith(String prefix) { + ArrayList result = new ArrayList(); + int length = prefix.length(); + SortedSet after = itemNames.tailSet(prefix); + for(String str : after) { + if(str.toLowerCase().startsWith(prefix)) + result.add(new CompletionData(str, length)); + else return result; + } + return result; + } + + private static class CompletionData implements Comparable { + + private String string; + private int prefixLength; + + public CompletionData(String string, int prefixLength) { + this.string = string; + this.prefixLength = prefixLength; + } + + @Override + public int compareTo(CompletionData arg0) { + return string.compareTo(arg0.string); + } + } + } diff --git a/src/main/java/vazkii/botania/client/core/handler/DebugHandler.java b/src/main/java/vazkii/botania/client/core/handler/DebugHandler.java index c2a239bb7e..9e6055b7a2 100644 --- a/src/main/java/vazkii/botania/client/core/handler/DebugHandler.java +++ b/src/main/java/vazkii/botania/client/core/handler/DebugHandler.java @@ -2,67 +2,67 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Oct 21, 2014, 4:58:55 PM (GMT)] */ package vazkii.botania.client.core.handler; -import cpw.mods.fml.common.eventhandler.SubscribeEvent; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.GuiScreen; import net.minecraft.util.EnumChatFormatting; import net.minecraft.world.World; import net.minecraftforge.client.event.RenderGameOverlayEvent; + import org.lwjgl.opengl.ARBFragmentShader; import org.lwjgl.opengl.ContextCapabilities; import org.lwjgl.opengl.GL11; import org.lwjgl.opengl.GL20; import org.lwjgl.opengl.GLContext; + import vazkii.botania.client.fx.ParticleRenderDispatcher; import vazkii.botania.common.core.handler.ConfigHandler; import vazkii.botania.common.core.handler.ManaNetworkHandler; import vazkii.botania.common.lib.LibMisc; +import cpw.mods.fml.common.eventhandler.SubscribeEvent; public final class DebugHandler { - private static final String PREFIX = EnumChatFormatting.GREEN + "[Botania] " + EnumChatFormatting.RESET; + private static final String PREFIX = EnumChatFormatting.GREEN + "[Botania] " + EnumChatFormatting.RESET; + + @SubscribeEvent + public void onDrawDebugText(RenderGameOverlayEvent.Text event) { + World world = Minecraft.getMinecraft().theWorld; + if(Minecraft.getMinecraft().gameSettings.showDebugInfo) { + event.left.add(null); + String version = LibMisc.VERSION; + if(version.contains("GRADLE")) + version = "N/A"; + + event.left.add(PREFIX + "pS: " + ParticleRenderDispatcher.sparkleFxCount + ", pFS: " + ParticleRenderDispatcher.fakeSparkleFxCount + ", pW: " + ParticleRenderDispatcher.wispFxCount + ", pDIW: " + ParticleRenderDispatcher.depthIgnoringWispFxCount + ", pLB: " + ParticleRenderDispatcher.lightningCount); + event.left.add(PREFIX + "netColl: " + ManaNetworkHandler.instance.getAllCollectorsInWorld(world).size() + ", netPool: " + ManaNetworkHandler.instance.getAllPoolsInWorld(world).size() + ", rv: " + version); - @SubscribeEvent - public void onDrawDebugText(RenderGameOverlayEvent.Text event) { - World world = Minecraft.getMinecraft().theWorld; - if (Minecraft.getMinecraft().gameSettings.showDebugInfo) { - event.left.add(null); - String version = LibMisc.VERSION; - if (version.contains("GRADLE")) version = "N/A"; + if(GuiScreen.isCtrlKeyDown() && GuiScreen.isShiftKeyDown()) { + event.left.add(PREFIX + "Config Context"); + event.left.add(" shaders.enabled: " + ConfigHandler.useShaders); + event.left.add(" shaders.secondaryUnit: " + ConfigHandler.glSecondaryTextureUnit); - event.left.add(PREFIX + "pS: " + ParticleRenderDispatcher.sparkleFxCount + ", pFS: " - + ParticleRenderDispatcher.fakeSparkleFxCount + ", pW: " + ParticleRenderDispatcher.wispFxCount - + ", pDIW: " + ParticleRenderDispatcher.depthIgnoringWispFxCount + ", pLB: " - + ParticleRenderDispatcher.lightningCount); - event.left.add(PREFIX + "netColl: " - + ManaNetworkHandler.instance.getAllCollectorsInWorld(world).size() + ", netPool: " - + ManaNetworkHandler.instance.getAllPoolsInWorld(world).size() + ", rv: " + version); + ContextCapabilities caps = GLContext.getCapabilities(); + event.left.add(PREFIX + "OpenGL Context"); + event.left.add(" GL_VERSION: " + GL11.glGetString(GL11.GL_VERSION)); + event.left.add(" GL_RENDERER: " + GL11.glGetString(GL11.GL_RENDERER)); + event.left.add(" GL_SHADING_LANGUAGE_VERSION: " + GL11.glGetString(GL20.GL_SHADING_LANGUAGE_VERSION)); + event.left.add(" GL_MAX_TEXTURE_IMAGE_UNITS_ARB: " + GL11.glGetInteger(ARBFragmentShader.GL_MAX_TEXTURE_IMAGE_UNITS_ARB)); + event.left.add(" GL_ARB_multitexture: " + caps.GL_ARB_multitexture); + event.left.add(" GL_ARB_texture_non_power_of_two: " + caps.GL_ARB_texture_non_power_of_two); + event.left.add(" OpenGL13: " + caps.OpenGL13); + } else if(Minecraft.isRunningOnMac) + event.left.add(PREFIX + "SHIFT+CMD for context"); + else event.left.add(PREFIX + "SHIFT+CTRL for context"); + } + } - if (GuiScreen.isCtrlKeyDown() && GuiScreen.isShiftKeyDown()) { - event.left.add(PREFIX + "Config Context"); - event.left.add(" shaders.enabled: " + ConfigHandler.useShaders); - event.left.add(" shaders.secondaryUnit: " + ConfigHandler.glSecondaryTextureUnit); - ContextCapabilities caps = GLContext.getCapabilities(); - event.left.add(PREFIX + "OpenGL Context"); - event.left.add(" GL_VERSION: " + GL11.glGetString(GL11.GL_VERSION)); - event.left.add(" GL_RENDERER: " + GL11.glGetString(GL11.GL_RENDERER)); - event.left.add(" GL_SHADING_LANGUAGE_VERSION: " + GL11.glGetString(GL20.GL_SHADING_LANGUAGE_VERSION)); - event.left.add(" GL_MAX_TEXTURE_IMAGE_UNITS_ARB: " - + GL11.glGetInteger(ARBFragmentShader.GL_MAX_TEXTURE_IMAGE_UNITS_ARB)); - event.left.add(" GL_ARB_multitexture: " + caps.GL_ARB_multitexture); - event.left.add(" GL_ARB_texture_non_power_of_two: " + caps.GL_ARB_texture_non_power_of_two); - event.left.add(" OpenGL13: " + caps.OpenGL13); - } else if (Minecraft.isRunningOnMac) event.left.add(PREFIX + "SHIFT+CMD for context"); - else event.left.add(PREFIX + "SHIFT+CTRL for context"); - } - } } diff --git a/src/main/java/vazkii/botania/client/core/handler/HUDHandler.java b/src/main/java/vazkii/botania/client/core/handler/HUDHandler.java index 936eb6aaf1..576ae446ee 100644 --- a/src/main/java/vazkii/botania/client/core/handler/HUDHandler.java +++ b/src/main/java/vazkii/botania/client/core/handler/HUDHandler.java @@ -2,19 +2,16 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jan 25, 2014, 6:11:10 PM (GMT)] */ package vazkii.botania.client.core.handler; -import baubles.common.lib.PlayerHandler; -import cpw.mods.fml.common.eventhandler.EventPriority; -import cpw.mods.fml.common.eventhandler.SubscribeEvent; -import cpw.mods.fml.relauncher.ReflectionHelper; import java.awt.Color; + import net.minecraft.block.Block; import net.minecraft.block.BlockLiquid; import net.minecraft.client.Minecraft; @@ -36,8 +33,10 @@ import net.minecraft.util.StatCollector; import net.minecraftforge.client.event.RenderGameOverlayEvent; import net.minecraftforge.client.event.RenderGameOverlayEvent.ElementType; + import org.lwjgl.opengl.GL11; import org.lwjgl.opengl.GL12; + import vazkii.botania.api.BotaniaAPI; import vazkii.botania.api.lexicon.ILexicon; import vazkii.botania.api.lexicon.ILexiconable; @@ -66,455 +65,423 @@ import vazkii.botania.common.item.equipment.bauble.ItemFlightTiara; import vazkii.botania.common.item.equipment.bauble.ItemMonocle; import vazkii.botania.common.lib.LibObfuscation; +import baubles.common.lib.PlayerHandler; +import cpw.mods.fml.common.eventhandler.EventPriority; +import cpw.mods.fml.common.eventhandler.SubscribeEvent; +import cpw.mods.fml.relauncher.ReflectionHelper; public final class HUDHandler { - public static final ResourceLocation manaBar = new ResourceLocation(LibResources.GUI_MANA_HUD); - - @SubscribeEvent(priority = EventPriority.HIGHEST) - public void onDrawScreenPre(RenderGameOverlayEvent.Pre event) { - Minecraft mc = Minecraft.getMinecraft(); - Profiler profiler = mc.mcProfiler; - - if (event.type == ElementType.HEALTH) { - profiler.startSection("botania-hud"); - ItemStack amulet = PlayerHandler.getPlayerBaubles(mc.thePlayer).getStackInSlot(0); - if (amulet != null && amulet.getItem() == ModItems.flightTiara) { - profiler.startSection("flugelTiara"); - ItemFlightTiara.renderHUD(event.resolution, mc.thePlayer, amulet); - profiler.endSection(); - } - profiler.endSection(); - } - } - - @SubscribeEvent - public void onDrawScreenPost(RenderGameOverlayEvent.Post event) { - Minecraft mc = Minecraft.getMinecraft(); - Profiler profiler = mc.mcProfiler; - ItemStack equippedStack = mc.thePlayer.getCurrentEquippedItem(); - - if (event.type == ElementType.ALL) { - profiler.startSection("botania-hud"); - MovingObjectPosition pos = mc.objectMouseOver; - - if (pos != null) { - Block block = mc.theWorld.getBlock(pos.blockX, pos.blockY, pos.blockZ); - TileEntity tile = mc.theWorld.getTileEntity(pos.blockX, pos.blockY, pos.blockZ); - - if (equippedStack != null) { - if (pos != null && equippedStack.getItem() == ModItems.twigWand) { - renderWandModeDisplay(event.resolution); - - if (block instanceof IWandHUD) { - profiler.startSection("wandItem"); - ((IWandHUD) block) - .renderHUD(mc, event.resolution, mc.theWorld, pos.blockX, pos.blockY, pos.blockZ); - profiler.endSection(); - } - } else if (pos != null && equippedStack.getItem() instanceof ILexicon) - drawLexiconHUD(mc.thePlayer.getCurrentEquippedItem(), block, pos, event.resolution); - if (tile != null && tile instanceof TilePool) - renderPoolRecipeHUD(event.resolution, (TilePool) tile, equippedStack); - } - if (tile != null && tile instanceof TileAltar) ((TileAltar) tile).renderHUD(mc, event.resolution); - else if (tile != null && tile instanceof TileRuneAltar) - ((TileRuneAltar) tile).renderHUD(mc, event.resolution); - - if (tile != null && tile instanceof TileCorporeaCrystalCube) - renderCrystalCubeHUD(event.resolution, (TileCorporeaCrystalCube) tile); - } - - if (!TileCorporeaIndex.getInputHandler() - .getNearbyIndexes(mc.thePlayer) - .isEmpty() - && mc.currentScreen != null - && mc.currentScreen instanceof GuiChat) { - profiler.startSection("nearIndex"); - renderNearIndexDisplay(event.resolution); - profiler.endSection(); - } - - if (MultiblockRenderHandler.currentMultiblock != null && MultiblockRenderHandler.anchor == null) { - profiler.startSection("multiblockRightClick"); - String s = StatCollector.translateToLocal("botaniamisc.rightClickToAnchor"); - mc.fontRenderer.drawStringWithShadow( - s, - event.resolution.getScaledWidth() / 2 - mc.fontRenderer.getStringWidth(s) / 2, - event.resolution.getScaledHeight() / 2 - 30, - 0xFFFFFF); - profiler.endSection(); - } - - if (equippedStack != null && equippedStack.getItem() instanceof ItemCraftingHalo) { - profiler.startSection("craftingHalo"); - ItemCraftingHalo.renderHUD(event.resolution, mc.thePlayer, equippedStack); - profiler.endSection(); - } - - if (equippedStack != null && equippedStack.getItem() instanceof ItemSextant) { - profiler.startSection("sextant"); - ItemSextant.renderHUD(event.resolution, mc.thePlayer, equippedStack); - profiler.endSection(); - } - - /*if(equippedStack != null && equippedStack.getItem() == ModItems.flugelEye) { - profiler.startSection("flugelEye"); - ItemFlugelEye.renderHUD(event.resolution, mc.thePlayer, equippedStack); - profiler.endSection(); - }*/ - - if (Botania.proxy.isClientPlayerWearingMonocle()) { - profiler.startSection("monocle"); - ItemMonocle.renderHUD(event.resolution, mc.thePlayer); - profiler.endSection(); - } - - profiler.startSection("manaBar"); - EntityPlayer player = mc.thePlayer; - int totalMana = 0; - int totalMaxMana = 0; - boolean anyRequest = false; - boolean creative = false; - - IInventory mainInv = player.inventory; - IInventory baublesInv = PlayerHandler.getPlayerBaubles(player); - - int invSize = mainInv.getSizeInventory(); - int size = invSize; - if (baublesInv != null) size += baublesInv.getSizeInventory(); - - for (int i = 0; i < size; i++) { - boolean useBaubles = i >= invSize; - IInventory inv = useBaubles ? baublesInv : mainInv; - ItemStack stack = inv.getStackInSlot(i - (useBaubles ? invSize : 0)); - - if (stack != null) { - Item item = stack.getItem(); - if (item instanceof IManaUsingItem) - anyRequest = anyRequest || ((IManaUsingItem) item).usesMana(stack); - - if (item instanceof IManaItem) { - if (!((IManaItem) item).isNoExport(stack)) { - totalMana += ((IManaItem) item).getMana(stack); - totalMaxMana += ((IManaItem) item).getMaxMana(stack); - } - } - - if (item instanceof ICreativeManaProvider && ((ICreativeManaProvider) item).isCreative(stack)) - creative = true; - } - } - - if (anyRequest) renderManaInvBar(event.resolution, creative, totalMana, totalMaxMana); - - profiler.endStartSection("bossBar"); - BossBarHandler.render(event.resolution); - profiler.endStartSection("itemsRemaining"); - ItemsRemainingRenderHandler.render(event.resolution, event.partialTicks); - profiler.endSection(); - profiler.endSection(); - - GL11.glColor4f(1F, 1F, 1F, 1F); - } - } - - private void renderWandModeDisplay(ScaledResolution res) { - Minecraft mc = Minecraft.getMinecraft(); - Profiler profiler = mc.mcProfiler; - - profiler.startSection("wandMode"); - int ticks = ReflectionHelper.getPrivateValue( - GuiIngame.class, mc.ingameGUI, LibObfuscation.REMAINING_HIGHLIGHT_TICKS); - ticks -= 15; - if (ticks > 0) { - int alpha = Math.min(255, (int) (ticks * 256.0F / 10.0F)); - int color = 0x00CC00 + (alpha << 24); - String disp = - StatCollector.translateToLocal(ItemTwigWand.getModeString(mc.thePlayer.getCurrentEquippedItem())); - - int x = res.getScaledWidth() / 2 - mc.fontRenderer.getStringWidth(disp) / 2; - int y = res.getScaledHeight() - 70; - - GL11.glEnable(GL11.GL_BLEND); - GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); - mc.fontRenderer.drawStringWithShadow(disp, x, y, color); - GL11.glDisable(GL11.GL_BLEND); - } - profiler.endSection(); - } - - private void renderManaInvBar(ScaledResolution res, boolean hasCreative, int totalMana, int totalMaxMana) { - Minecraft mc = Minecraft.getMinecraft(); - int width = 182; - int x = res.getScaledWidth() / 2 - width / 2; - int y = res.getScaledHeight() - ConfigHandler.manaBarHeight; - - if (!hasCreative) { - if (totalMaxMana == 0) width = 0; - else width *= (double) totalMana / (double) totalMaxMana; - } - - if (width == 0) { - if (totalMana > 0) width = 1; - else return; - } - - Color color = new Color(Color.HSBtoRGB( - 0.55F, (float) Math.min(1F, Math.sin(System.currentTimeMillis() / 200D) * 0.5 + 1F), 1F)); - GL11.glColor4ub( - (byte) color.getRed(), (byte) color.getGreen(), (byte) color.getBlue(), (byte) (255 - color.getRed())); - mc.renderEngine.bindTexture(manaBar); - - GL11.glEnable(GL11.GL_BLEND); - GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); - RenderHelper.drawTexturedModalRect(x, y, 0, 0, 251, width, 5); - GL11.glDisable(GL11.GL_BLEND); - } - - private void renderPoolRecipeHUD(ScaledResolution res, TilePool tile, ItemStack stack) { - Minecraft mc = Minecraft.getMinecraft(); - Profiler profiler = mc.mcProfiler; - - profiler.startSection("poolRecipe"); - for (RecipeManaInfusion recipe : BotaniaAPI.manaInfusionRecipes) { - if (recipe.matches(stack)) { - if ((!recipe.isAlchemy() || tile.alchemy) && (!recipe.isConjuration() || tile.conjuration)) { - int x = res.getScaledWidth() / 2 - 11; - int y = res.getScaledHeight() / 2 + 10; - - int u = tile.getCurrentMana() >= recipe.getManaToConsume() ? 0 : 22; - int v = mc.thePlayer.getCommandSenderName().equals("haighyorkie") && mc.thePlayer.isSneaking() - ? 23 - : 8; - - GL11.glEnable(GL11.GL_BLEND); - GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); - - mc.renderEngine.bindTexture(manaBar); - RenderHelper.drawTexturedModalRect(x, y, 0, u, v, 22, 15); - GL11.glColor4f(1F, 1F, 1F, 1F); - - net.minecraft.client.renderer.RenderHelper.enableGUIStandardItemLighting(); - RenderItem.getInstance() - .renderItemAndEffectIntoGUI(mc.fontRenderer, mc.renderEngine, stack, x - 20, y); - RenderItem.getInstance() - .renderItemAndEffectIntoGUI( - mc.fontRenderer, mc.renderEngine, recipe.getOutput(), x + 26, y); - RenderItem.getInstance() - .renderItemOverlayIntoGUI(mc.fontRenderer, mc.renderEngine, recipe.getOutput(), x + 26, y); - net.minecraft.client.renderer.RenderHelper.disableStandardItemLighting(); - - GL11.glDisable(GL11.GL_LIGHTING); - GL11.glDisable(GL11.GL_BLEND); - - break; - } - } - } - profiler.endSection(); - } - - private void renderCrystalCubeHUD(ScaledResolution res, TileCorporeaCrystalCube tile) { - Minecraft mc = Minecraft.getMinecraft(); - Profiler profiler = mc.mcProfiler; - - profiler.startSection("crystalCube"); - ItemStack target = tile.getRequestTarget(); - if (target != null) { - String s1 = target.getDisplayName(); - String s2 = tile.getItemCount() + "x"; - int strlen = Math.max(mc.fontRenderer.getStringWidth(s1), mc.fontRenderer.getStringWidth(s2)); - int w = res.getScaledWidth(); - int h = res.getScaledHeight(); - Gui.drawRect(w / 2 + 8, h / 2 - 12, w / 2 + strlen + 32, h / 2 + 10, 0x44000000); - Gui.drawRect(w / 2 + 6, h / 2 - 14, w / 2 + strlen + 34, h / 2 + 12, 0x44000000); - - mc.fontRenderer.drawStringWithShadow(target.getDisplayName(), w / 2 + 30, h / 2 - 10, 0x6666FF); - mc.fontRenderer.drawStringWithShadow(tile.getItemCount() + "x", w / 2 + 30, h / 2, 0xFFFFFF); - net.minecraft.client.renderer.RenderHelper.enableGUIStandardItemLighting(); - GL11.glEnable(GL12.GL_RESCALE_NORMAL); - RenderItem.getInstance() - .renderItemAndEffectIntoGUI(mc.fontRenderer, mc.renderEngine, target, w / 2 + 10, h / 2 - 10); - net.minecraft.client.renderer.RenderHelper.disableStandardItemLighting(); - } - - profiler.endSection(); - } - - private void drawLexiconHUD(ItemStack stack, Block block, MovingObjectPosition pos, ScaledResolution res) { - Minecraft mc = Minecraft.getMinecraft(); - Profiler profiler = mc.mcProfiler; - - profiler.startSection("lexicon"); - FontRenderer font = mc.fontRenderer; - boolean draw = false; - String drawStr = ""; - String secondLine = ""; - - GL11.glEnable(GL11.GL_BLEND); - GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); - int sx = res.getScaledWidth() / 2 - 17; - int sy = res.getScaledHeight() / 2 + 2; - - if (block instanceof ILexiconable) { - LexiconEntry entry = ((ILexiconable) block) - .getEntry( - mc.theWorld, - pos.blockX, - pos.blockY, - pos.blockZ, - mc.thePlayer, - mc.thePlayer.getCurrentEquippedItem()); - if (entry != null) { - if (!((ILexicon) stack.getItem()).isKnowledgeUnlocked(stack, entry.getKnowledgeType())) - font = mc.standardGalacticFontRenderer; - - drawStr = StatCollector.translateToLocal(entry.getUnlocalizedName()); - secondLine = EnumChatFormatting.ITALIC + StatCollector.translateToLocal(entry.getTagline()); - draw = true; - } - } - - if (!draw && pos.entityHit == null) { - profiler.startSection("wikiLookup"); - if (!block.isAir(mc.theWorld, pos.blockX, pos.blockY, pos.blockZ) && !(block instanceof BlockLiquid)) { - IWikiProvider provider = WikiHooks.getWikiFor(block); - String url = provider.getWikiURL(mc.theWorld, pos); - if (url != null && !url.isEmpty()) { - String name = provider.getBlockName(mc.theWorld, pos); - String wikiName = provider.getWikiName(mc.theWorld, pos); - drawStr = name + " @ " + EnumChatFormatting.AQUA + wikiName; - draw = true; - } - } - profiler.endSection(); - } - - if (draw) { - if (!mc.thePlayer.isSneaking()) { - drawStr = "?"; - secondLine = ""; - font = mc.fontRenderer; - } - - RenderItem.getInstance() - .renderItemIntoGUI(mc.fontRenderer, mc.renderEngine, new ItemStack(ModItems.lexicon), sx, sy); - GL11.glDisable(GL11.GL_LIGHTING); - font.drawStringWithShadow(drawStr, sx + 10, sy + 8, 0xFFFFFFFF); - font.drawStringWithShadow(secondLine, sx + 10, sy + 18, 0xFFAAAAAA); - - if (!mc.thePlayer.isSneaking()) { - GL11.glScalef(0.5F, 0.5F, 1F); - mc.fontRenderer.drawStringWithShadow( - EnumChatFormatting.BOLD + "Shift", (sx + 10) * 2 - 16, (sy + 8) * 2 + 20, 0xFFFFFFFF); - GL11.glScalef(2F, 2F, 1F); - } - } - - GL11.glDisable(GL11.GL_BLEND); - GL11.glColor4f(1F, 1F, 1F, 1F); - profiler.endSection(); - } - - private void renderNearIndexDisplay(ScaledResolution res) { - Minecraft mc = Minecraft.getMinecraft(); - String txt0 = StatCollector.translateToLocal("botaniamisc.nearIndex0"); - String txt1 = EnumChatFormatting.GRAY + StatCollector.translateToLocal("botaniamisc.nearIndex1"); - String txt2 = EnumChatFormatting.GRAY + StatCollector.translateToLocal("botaniamisc.nearIndex2"); - - int l = Math.max( - mc.fontRenderer.getStringWidth(txt0), - Math.max(mc.fontRenderer.getStringWidth(txt1), mc.fontRenderer.getStringWidth(txt2))) - + 20; - int x = res.getScaledWidth() - l - 20; - int y = res.getScaledHeight() - 60; - - Gui.drawRect(x - 6, y - 6, x + l + 6, y + 37, 0x44000000); - Gui.drawRect(x - 4, y - 4, x + l + 4, y + 35, 0x44000000); - net.minecraft.client.renderer.RenderHelper.enableGUIStandardItemLighting(); - GL11.glEnable(GL12.GL_RESCALE_NORMAL); - RenderItem.getInstance() - .renderItemAndEffectIntoGUI( - mc.fontRenderer, mc.renderEngine, new ItemStack(ModBlocks.corporeaIndex), x, y + 10); - net.minecraft.client.renderer.RenderHelper.disableStandardItemLighting(); - - mc.fontRenderer.drawStringWithShadow(txt0, x + 20, y, 0xFFFFFF); - mc.fontRenderer.drawStringWithShadow(txt1, x + 20, y + 14, 0xFFFFFF); - mc.fontRenderer.drawStringWithShadow(txt2, x + 20, y + 24, 0xFFFFFF); - } - - public static void drawSimpleManaHUD(int color, int mana, int maxMana, String name, ScaledResolution res) { - GL11.glEnable(GL11.GL_BLEND); - GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); - Minecraft mc = Minecraft.getMinecraft(); - int x = res.getScaledWidth() / 2 - mc.fontRenderer.getStringWidth(name) / 2; - int y = res.getScaledHeight() / 2 + 10; - - mc.fontRenderer.drawStringWithShadow(name, x, y, color); - - x = res.getScaledWidth() / 2 - 51; - y += 10; - - renderManaBar(x, y, color, mana < 0 ? 0.5F : 1F, mana, maxMana); - - if (mana < 0) { - String text = StatCollector.translateToLocal("botaniamisc.statusUnknown"); - x = res.getScaledWidth() / 2 - mc.fontRenderer.getStringWidth(text) / 2; - y -= 1; - mc.fontRenderer.drawString(text, x, y, color); - } - - GL11.glDisable(GL11.GL_BLEND); - } - - public static void drawComplexManaHUD( - int color, - int mana, - int maxMana, - String name, - ScaledResolution res, - ItemStack bindDisplay, - boolean properlyBound) { - drawSimpleManaHUD(color, mana, maxMana, name, res); - - Minecraft mc = Minecraft.getMinecraft(); - - int x = res.getScaledWidth() / 2 + 55; - int y = res.getScaledHeight() / 2 + 12; - - net.minecraft.client.renderer.RenderHelper.enableGUIStandardItemLighting(); - GL11.glEnable(GL12.GL_RESCALE_NORMAL); - RenderItem.getInstance().renderItemAndEffectIntoGUI(mc.fontRenderer, mc.renderEngine, bindDisplay, x, y); - net.minecraft.client.renderer.RenderHelper.disableStandardItemLighting(); - - GL11.glDisable(GL11.GL_DEPTH_TEST); - if (properlyBound) { - mc.fontRenderer.drawStringWithShadow("\u2714", x + 10, y + 9, 0x004C00); - mc.fontRenderer.drawStringWithShadow("\u2714", x + 10, y + 8, 0x0BD20D); - } else { - mc.fontRenderer.drawStringWithShadow("\u2718", x + 10, y + 9, 0x4C0000); - mc.fontRenderer.drawStringWithShadow("\u2718", x + 10, y + 8, 0xD2080D); - } - GL11.glEnable(GL11.GL_DEPTH_TEST); - } - - public static void renderManaBar(int x, int y, int color, float alpha, int mana, int maxMana) { - Minecraft mc = Minecraft.getMinecraft(); - - GL11.glColor4f(1F, 1F, 1F, alpha); - mc.renderEngine.bindTexture(manaBar); - RenderHelper.drawTexturedModalRect(x, y, 0, 0, 0, 102, 5); - - int manaPercentage = Math.max(0, (int) ((double) mana / (double) maxMana * 100)); - - if (manaPercentage == 0 && mana > 0) manaPercentage = 1; - - RenderHelper.drawTexturedModalRect(x + 1, y + 1, 0, 0, 5, 100, 3); - - Color color_ = new Color(color); - GL11.glColor4ub( - (byte) color_.getRed(), (byte) color_.getGreen(), (byte) color_.getBlue(), (byte) (255F * alpha)); - RenderHelper.drawTexturedModalRect(x + 1, y + 1, 0, 0, 5, Math.min(100, manaPercentage), 3); - } + public static final ResourceLocation manaBar = new ResourceLocation(LibResources.GUI_MANA_HUD); + + @SubscribeEvent(priority = EventPriority.HIGHEST) + public void onDrawScreenPre(RenderGameOverlayEvent.Pre event) { + Minecraft mc = Minecraft.getMinecraft(); + Profiler profiler = mc.mcProfiler; + + if(event.type == ElementType.HEALTH) { + profiler.startSection("botania-hud"); + ItemStack amulet = PlayerHandler.getPlayerBaubles(mc.thePlayer).getStackInSlot(0); + if(amulet != null && amulet.getItem() == ModItems.flightTiara) { + profiler.startSection("flugelTiara"); + ItemFlightTiara.renderHUD(event.resolution, mc.thePlayer, amulet); + profiler.endSection(); + } + profiler.endSection(); + } + } + + @SubscribeEvent + public void onDrawScreenPost(RenderGameOverlayEvent.Post event) { + Minecraft mc = Minecraft.getMinecraft(); + Profiler profiler = mc.mcProfiler; + ItemStack equippedStack = mc.thePlayer.getCurrentEquippedItem(); + + if(event.type == ElementType.ALL) { + profiler.startSection("botania-hud"); + MovingObjectPosition pos = mc.objectMouseOver; + + if(pos != null) { + Block block = mc.theWorld.getBlock(pos.blockX, pos.blockY, pos.blockZ); + TileEntity tile = mc.theWorld.getTileEntity(pos.blockX, pos.blockY, pos.blockZ); + + if(equippedStack != null) { + if(pos != null && equippedStack.getItem() == ModItems.twigWand) { + renderWandModeDisplay(event.resolution); + + if(block instanceof IWandHUD) { + profiler.startSection("wandItem"); + ((IWandHUD) block).renderHUD(mc, event.resolution, mc.theWorld, pos.blockX, pos.blockY, pos.blockZ); + profiler.endSection(); + } + } else if(pos != null && equippedStack.getItem() instanceof ILexicon) + drawLexiconHUD(mc.thePlayer.getCurrentEquippedItem(), block, pos, event.resolution); + if(tile != null && tile instanceof TilePool) + renderPoolRecipeHUD(event.resolution, (TilePool) tile, equippedStack); + } + if(tile != null && tile instanceof TileAltar) + ((TileAltar) tile).renderHUD(mc, event.resolution); + else if(tile != null && tile instanceof TileRuneAltar) + ((TileRuneAltar) tile).renderHUD(mc, event.resolution); + + if(tile != null && tile instanceof TileCorporeaCrystalCube) + renderCrystalCubeHUD(event.resolution, (TileCorporeaCrystalCube) tile); + } + + if(!TileCorporeaIndex.getInputHandler().getNearbyIndexes(mc.thePlayer).isEmpty() && mc.currentScreen != null && mc.currentScreen instanceof GuiChat) { + profiler.startSection("nearIndex"); + renderNearIndexDisplay(event.resolution); + profiler.endSection(); + } + + if(MultiblockRenderHandler.currentMultiblock != null && MultiblockRenderHandler.anchor == null) { + profiler.startSection("multiblockRightClick"); + String s = StatCollector.translateToLocal("botaniamisc.rightClickToAnchor"); + mc.fontRenderer.drawStringWithShadow(s, event.resolution.getScaledWidth() / 2 - mc.fontRenderer.getStringWidth(s) / 2, event.resolution.getScaledHeight() / 2 - 30, 0xFFFFFF); + profiler.endSection(); + } + + if(equippedStack != null && equippedStack.getItem() instanceof ItemCraftingHalo) { + profiler.startSection("craftingHalo"); + ItemCraftingHalo.renderHUD(event.resolution, mc.thePlayer, equippedStack); + profiler.endSection(); + } + + if(equippedStack != null && equippedStack.getItem() instanceof ItemSextant) { + profiler.startSection("sextant"); + ItemSextant.renderHUD(event.resolution, mc.thePlayer, equippedStack); + profiler.endSection(); + } + + /*if(equippedStack != null && equippedStack.getItem() == ModItems.flugelEye) { + profiler.startSection("flugelEye"); + ItemFlugelEye.renderHUD(event.resolution, mc.thePlayer, equippedStack); + profiler.endSection(); + }*/ + + if(Botania.proxy.isClientPlayerWearingMonocle()) { + profiler.startSection("monocle"); + ItemMonocle.renderHUD(event.resolution, mc.thePlayer); + profiler.endSection(); + } + + profiler.startSection("manaBar"); + EntityPlayer player = mc.thePlayer; + int totalMana = 0; + int totalMaxMana = 0; + boolean anyRequest = false; + boolean creative = false; + + IInventory mainInv = player.inventory; + IInventory baublesInv = PlayerHandler.getPlayerBaubles(player); + + int invSize = mainInv.getSizeInventory(); + int size = invSize; + if(baublesInv != null) + size += baublesInv.getSizeInventory(); + + for(int i = 0; i < size; i++) { + boolean useBaubles = i >= invSize; + IInventory inv = useBaubles ? baublesInv : mainInv; + ItemStack stack = inv.getStackInSlot(i - (useBaubles ? invSize : 0)); + + if(stack != null) { + Item item = stack.getItem(); + if(item instanceof IManaUsingItem) + anyRequest = anyRequest || ((IManaUsingItem) item).usesMana(stack); + + if(item instanceof IManaItem) { + if(!((IManaItem) item).isNoExport(stack)) { + totalMana += ((IManaItem) item).getMana(stack); + totalMaxMana += ((IManaItem) item).getMaxMana(stack); + } + } + + if(item instanceof ICreativeManaProvider && ((ICreativeManaProvider) item).isCreative(stack)) + creative = true; + } + } + + if(anyRequest) + renderManaInvBar(event.resolution, creative, totalMana, totalMaxMana); + + profiler.endStartSection("bossBar"); + BossBarHandler.render(event.resolution); + profiler.endStartSection("itemsRemaining"); + ItemsRemainingRenderHandler.render(event.resolution, event.partialTicks); + profiler.endSection(); + profiler.endSection(); + + GL11.glColor4f(1F, 1F, 1F, 1F); + } + } + + private void renderWandModeDisplay(ScaledResolution res) { + Minecraft mc = Minecraft.getMinecraft(); + Profiler profiler = mc.mcProfiler; + + profiler.startSection("wandMode"); + int ticks = ReflectionHelper.getPrivateValue(GuiIngame.class, mc.ingameGUI, LibObfuscation.REMAINING_HIGHLIGHT_TICKS); + ticks -= 15; + if(ticks > 0) { + int alpha = Math.min(255, (int) (ticks * 256.0F / 10.0F)); + int color = 0x00CC00 + (alpha << 24); + String disp = StatCollector.translateToLocal(ItemTwigWand.getModeString(mc.thePlayer.getCurrentEquippedItem())); + + int x = res.getScaledWidth() / 2 - mc.fontRenderer.getStringWidth(disp) / 2; + int y = res.getScaledHeight() - 70; + + GL11.glEnable(GL11.GL_BLEND); + GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); + mc.fontRenderer.drawStringWithShadow(disp, x, y, color); + GL11.glDisable(GL11.GL_BLEND); + } + profiler.endSection(); + } + + private void renderManaInvBar(ScaledResolution res, boolean hasCreative, int totalMana, int totalMaxMana) { + Minecraft mc = Minecraft.getMinecraft(); + int width = 182; + int x = res.getScaledWidth() / 2 - width / 2; + int y = res.getScaledHeight() - ConfigHandler.manaBarHeight; + + if(!hasCreative) { + if(totalMaxMana == 0) + width = 0; + else width *= (double) totalMana / (double) totalMaxMana; + } + + if(width == 0) { + if(totalMana > 0) + width = 1; + else return; + } + + Color color = new Color(Color.HSBtoRGB(0.55F, (float) Math.min(1F, Math.sin(System.currentTimeMillis() / 200D) * 0.5 + 1F), 1F)); + GL11.glColor4ub((byte) color.getRed(), (byte) color.getGreen(), (byte) color.getBlue(), (byte) (255 - color.getRed())); + mc.renderEngine.bindTexture(manaBar); + + GL11.glEnable(GL11.GL_BLEND); + GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); + RenderHelper.drawTexturedModalRect(x, y, 0, 0, 251, width, 5); + GL11.glDisable(GL11.GL_BLEND); + } + + private void renderPoolRecipeHUD(ScaledResolution res, TilePool tile, ItemStack stack) { + Minecraft mc = Minecraft.getMinecraft(); + Profiler profiler = mc.mcProfiler; + + profiler.startSection("poolRecipe"); + for(RecipeManaInfusion recipe : BotaniaAPI.manaInfusionRecipes) { + if(recipe.matches(stack)) { + if((!recipe.isAlchemy() || tile.alchemy) && (!recipe.isConjuration() || tile.conjuration)) { + int x = res.getScaledWidth() / 2 - 11; + int y = res.getScaledHeight() / 2 + 10; + + int u = tile.getCurrentMana() >= recipe.getManaToConsume() ? 0 : 22; + int v = mc.thePlayer.getCommandSenderName().equals("haighyorkie") && mc.thePlayer.isSneaking() ? 23 : 8; + + GL11.glEnable(GL11.GL_BLEND); + GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); + + mc.renderEngine.bindTexture(manaBar); + RenderHelper.drawTexturedModalRect(x, y, 0, u, v, 22, 15); + GL11.glColor4f(1F, 1F, 1F, 1F); + + net.minecraft.client.renderer.RenderHelper.enableGUIStandardItemLighting(); + RenderItem.getInstance().renderItemAndEffectIntoGUI(mc.fontRenderer, mc.renderEngine, stack, x - 20, y); + RenderItem.getInstance().renderItemAndEffectIntoGUI(mc.fontRenderer, mc.renderEngine, recipe.getOutput(), x + 26, y); + RenderItem.getInstance().renderItemOverlayIntoGUI(mc.fontRenderer, mc.renderEngine, recipe.getOutput(), x + 26, y); + net.minecraft.client.renderer.RenderHelper.disableStandardItemLighting(); + + GL11.glDisable(GL11.GL_LIGHTING); + GL11.glDisable(GL11.GL_BLEND); + + break; + } + } + } + profiler.endSection(); + } + + private void renderCrystalCubeHUD(ScaledResolution res, TileCorporeaCrystalCube tile) { + Minecraft mc = Minecraft.getMinecraft(); + Profiler profiler = mc.mcProfiler; + + profiler.startSection("crystalCube"); + ItemStack target = tile.getRequestTarget(); + if(target != null) { + String s1 = target.getDisplayName(); + String s2 = tile.getItemCount() + "x"; + int strlen = Math.max(mc.fontRenderer.getStringWidth(s1), mc.fontRenderer.getStringWidth(s2)); + int w = res.getScaledWidth(); + int h = res.getScaledHeight(); + Gui.drawRect(w / 2 + 8, h / 2 - 12, w / 2 + strlen + 32, h / 2 + 10, 0x44000000); + Gui.drawRect(w / 2 + 6, h / 2 - 14, w / 2 + strlen + 34, h / 2 + 12, 0x44000000); + + mc.fontRenderer.drawStringWithShadow(target.getDisplayName(), w / 2 + 30, h / 2 - 10, 0x6666FF); + mc.fontRenderer.drawStringWithShadow(tile.getItemCount() + "x", w / 2 + 30, h / 2, 0xFFFFFF); + net.minecraft.client.renderer.RenderHelper.enableGUIStandardItemLighting(); + GL11.glEnable(GL12.GL_RESCALE_NORMAL); + RenderItem.getInstance().renderItemAndEffectIntoGUI(mc.fontRenderer, mc.renderEngine, target, w / 2 + 10, h / 2 - 10); + net.minecraft.client.renderer.RenderHelper.disableStandardItemLighting(); + } + + profiler.endSection(); + } + + private void drawLexiconHUD(ItemStack stack, Block block, MovingObjectPosition pos, ScaledResolution res) { + Minecraft mc = Minecraft.getMinecraft(); + Profiler profiler = mc.mcProfiler; + + profiler.startSection("lexicon"); + FontRenderer font = mc.fontRenderer; + boolean draw = false; + String drawStr = ""; + String secondLine = ""; + + GL11.glEnable(GL11.GL_BLEND); + GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); + int sx = res.getScaledWidth() / 2 - 17; + int sy = res.getScaledHeight() / 2 + 2; + + if(block instanceof ILexiconable) { + LexiconEntry entry = ((ILexiconable) block).getEntry(mc.theWorld, pos.blockX, pos.blockY, pos.blockZ, mc.thePlayer, mc.thePlayer.getCurrentEquippedItem()); + if(entry != null) { + if(!((ILexicon) stack.getItem()).isKnowledgeUnlocked(stack, entry.getKnowledgeType())) + font = mc.standardGalacticFontRenderer; + + drawStr = StatCollector.translateToLocal(entry.getUnlocalizedName()); + secondLine = EnumChatFormatting.ITALIC + StatCollector.translateToLocal(entry.getTagline()); + draw = true; + } + } + + if(!draw && pos.entityHit == null) { + profiler.startSection("wikiLookup"); + if(!block.isAir(mc.theWorld, pos.blockX, pos.blockY, pos.blockZ) && !(block instanceof BlockLiquid)) { + IWikiProvider provider = WikiHooks.getWikiFor(block); + String url = provider.getWikiURL(mc.theWorld, pos); + if(url != null && !url.isEmpty()) { + String name = provider.getBlockName(mc.theWorld, pos); + String wikiName = provider.getWikiName(mc.theWorld, pos); + drawStr = name + " @ " + EnumChatFormatting.AQUA + wikiName; + draw = true; + } + } + profiler.endSection(); + } + + if(draw) { + if(!mc.thePlayer.isSneaking()) { + drawStr = "?"; + secondLine = ""; + font = mc.fontRenderer; + } + + RenderItem.getInstance().renderItemIntoGUI(mc.fontRenderer, mc.renderEngine, new ItemStack(ModItems.lexicon), sx, sy); + GL11.glDisable(GL11.GL_LIGHTING); + font.drawStringWithShadow(drawStr, sx + 10, sy + 8, 0xFFFFFFFF); + font.drawStringWithShadow(secondLine, sx + 10, sy + 18, 0xFFAAAAAA); + + if(!mc.thePlayer.isSneaking()) { + GL11.glScalef(0.5F, 0.5F, 1F); + mc.fontRenderer.drawStringWithShadow(EnumChatFormatting.BOLD + "Shift", (sx + 10) * 2 - 16, (sy + 8) * 2 + 20, 0xFFFFFFFF); + GL11.glScalef(2F, 2F, 1F); + } + } + + GL11.glDisable(GL11.GL_BLEND); + GL11.glColor4f(1F, 1F, 1F, 1F); + profiler.endSection(); + } + + private void renderNearIndexDisplay(ScaledResolution res) { + Minecraft mc = Minecraft.getMinecraft(); + String txt0 = StatCollector.translateToLocal("botaniamisc.nearIndex0"); + String txt1 = EnumChatFormatting.GRAY + StatCollector.translateToLocal("botaniamisc.nearIndex1"); + String txt2 = EnumChatFormatting.GRAY + StatCollector.translateToLocal("botaniamisc.nearIndex2"); + + int l = Math.max(mc.fontRenderer.getStringWidth(txt0), Math.max(mc.fontRenderer.getStringWidth(txt1), mc.fontRenderer.getStringWidth(txt2))) + 20; + int x = res.getScaledWidth() - l - 20; + int y = res.getScaledHeight() - 60; + + Gui.drawRect(x - 6, y - 6, x + l + 6, y + 37, 0x44000000); + Gui.drawRect(x - 4, y - 4, x + l + 4, y + 35, 0x44000000); + net.minecraft.client.renderer.RenderHelper.enableGUIStandardItemLighting(); + GL11.glEnable(GL12.GL_RESCALE_NORMAL); + RenderItem.getInstance().renderItemAndEffectIntoGUI(mc.fontRenderer, mc.renderEngine, new ItemStack(ModBlocks.corporeaIndex), x, y + 10); + net.minecraft.client.renderer.RenderHelper.disableStandardItemLighting(); + + mc.fontRenderer.drawStringWithShadow(txt0, x + 20, y, 0xFFFFFF); + mc.fontRenderer.drawStringWithShadow(txt1, x + 20, y + 14, 0xFFFFFF); + mc.fontRenderer.drawStringWithShadow(txt2, x + 20, y + 24, 0xFFFFFF); + } + + public static void drawSimpleManaHUD(int color, int mana, int maxMana, String name, ScaledResolution res) { + GL11.glEnable(GL11.GL_BLEND); + GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); + Minecraft mc = Minecraft.getMinecraft(); + int x = res.getScaledWidth() / 2 - mc.fontRenderer.getStringWidth(name) / 2; + int y = res.getScaledHeight() / 2 + 10; + + mc.fontRenderer.drawStringWithShadow(name, x, y, color); + + x = res.getScaledWidth() / 2 - 51; + y += 10; + + renderManaBar(x, y, color, mana < 0 ? 0.5F : 1F, mana, maxMana); + + if(mana < 0) { + String text = StatCollector.translateToLocal("botaniamisc.statusUnknown"); + x = res.getScaledWidth() / 2 - mc.fontRenderer.getStringWidth(text) / 2; + y -= 1; + mc.fontRenderer.drawString(text, x, y, color); + } + + GL11.glDisable(GL11.GL_BLEND); + } + + public static void drawComplexManaHUD(int color, int mana, int maxMana, String name, ScaledResolution res, ItemStack bindDisplay, boolean properlyBound) { + drawSimpleManaHUD(color, mana, maxMana, name, res); + + Minecraft mc = Minecraft.getMinecraft(); + + int x = res.getScaledWidth() / 2 + 55; + int y = res.getScaledHeight() / 2 + 12; + + net.minecraft.client.renderer.RenderHelper.enableGUIStandardItemLighting(); + GL11.glEnable(GL12.GL_RESCALE_NORMAL); + RenderItem.getInstance().renderItemAndEffectIntoGUI(mc.fontRenderer, mc.renderEngine, bindDisplay, x, y); + net.minecraft.client.renderer.RenderHelper.disableStandardItemLighting(); + + GL11.glDisable(GL11.GL_DEPTH_TEST); + if(properlyBound) { + mc.fontRenderer.drawStringWithShadow("\u2714", x + 10, y + 9, 0x004C00); + mc.fontRenderer.drawStringWithShadow("\u2714", x + 10, y + 8, 0x0BD20D); + } else { + mc.fontRenderer.drawStringWithShadow("\u2718", x + 10, y + 9, 0x4C0000); + mc.fontRenderer.drawStringWithShadow("\u2718", x + 10, y + 8, 0xD2080D); + } + GL11.glEnable(GL11.GL_DEPTH_TEST); + } + + public static void renderManaBar(int x, int y, int color, float alpha, int mana, int maxMana) { + Minecraft mc = Minecraft.getMinecraft(); + + GL11.glColor4f(1F, 1F, 1F, alpha); + mc.renderEngine.bindTexture(manaBar); + RenderHelper.drawTexturedModalRect(x, y, 0, 0, 0, 102, 5); + + int manaPercentage = Math.max(0, (int) ((double) mana / (double) maxMana * 100)); + + if(manaPercentage == 0 && mana > 0) + manaPercentage = 1; + + RenderHelper.drawTexturedModalRect(x + 1, y + 1, 0, 0, 5, 100, 3); + + Color color_ = new Color(color); + GL11.glColor4ub((byte) color_.getRed(), (byte) color_.getGreen(),(byte) color_.getBlue(), (byte) (255F * alpha)); + RenderHelper.drawTexturedModalRect(x + 1, y + 1, 0, 0, 5, Math.min(100, manaPercentage), 3); + } } diff --git a/src/main/java/vazkii/botania/client/core/handler/ItemsRemainingRenderHandler.java b/src/main/java/vazkii/botania/client/core/handler/ItemsRemainingRenderHandler.java index eb1f9e582a..4e41b8c15e 100644 --- a/src/main/java/vazkii/botania/client/core/handler/ItemsRemainingRenderHandler.java +++ b/src/main/java/vazkii/botania/client/core/handler/ItemsRemainingRenderHandler.java @@ -2,17 +2,16 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jan 23, 2015, 9:22:10 PM (GMT)] */ package vazkii.botania.client.core.handler; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; import java.util.regex.Pattern; + import net.minecraft.client.Minecraft; import net.minecraft.client.gui.ScaledResolution; import net.minecraft.client.renderer.RenderHelper; @@ -20,84 +19,90 @@ import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; import net.minecraft.util.EnumChatFormatting; + import org.lwjgl.opengl.GL11; import org.lwjgl.opengl.GL12; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + public final class ItemsRemainingRenderHandler { - private static int maxTicks = 30; - private static int leaveTicks = 20; - - private static ItemStack stack; - private static int ticks, count; - - @SideOnly(Side.CLIENT) - public static void render(ScaledResolution resolution, float partTicks) { - if (ticks > 0 && stack != null) { - int pos = maxTicks - ticks; - Minecraft mc = Minecraft.getMinecraft(); - int x = resolution.getScaledWidth() / 2 + 10 + Math.max(0, pos - leaveTicks); - int y = resolution.getScaledHeight() / 2; - - int start = maxTicks - leaveTicks; - float alpha = ticks + partTicks > start ? 1F : (ticks + partTicks) / start; - - GL11.glDisable(GL11.GL_ALPHA_TEST); - GL11.glEnable(GL11.GL_BLEND); - GL11.glEnable(GL12.GL_RESCALE_NORMAL); - GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); - - GL11.glColor4f(1F, 1F, 1F, alpha); - RenderHelper.enableGUIStandardItemLighting(); - int xp = x + (int) (16F * (1F - alpha)); - GL11.glTranslatef(xp, y, 0F); - GL11.glScalef(alpha, 1F, 1F); - RenderItem.getInstance().renderItemAndEffectIntoGUI(mc.fontRenderer, mc.renderEngine, stack, 0, 0); - GL11.glScalef(1F / alpha, 1F, 1F); - GL11.glTranslatef(-xp, -y, 0F); - RenderHelper.disableStandardItemLighting(); - GL11.glColor4f(1F, 1F, 1F, 1F); - GL11.glEnable(GL11.GL_BLEND); - - String text = EnumChatFormatting.GREEN + stack.getDisplayName(); - if (count >= 0) { - int max = stack.getMaxStackSize(); - int stacks = count / max; - int rem = count % max; - - if (stacks == 0) text = "" + count; - else - text = count + " (" + EnumChatFormatting.AQUA + stacks + EnumChatFormatting.RESET + "*" - + EnumChatFormatting.GRAY + max + EnumChatFormatting.RESET + "+" + EnumChatFormatting.YELLOW - + rem + EnumChatFormatting.RESET + ")"; - } else if (count == -1) text = "\u221E"; - - int color = 0x00FFFFFF | (int) (alpha * 0xFF) << 24; - mc.fontRenderer.drawStringWithShadow(text, x + 20, y + 6, color); - - GL11.glDisable(GL11.GL_BLEND); - GL11.glEnable(GL11.GL_ALPHA_TEST); - } - } - - @SideOnly(Side.CLIENT) - public static void tick() { - if (ticks > 0) --ticks; - } - - public static void set(ItemStack stack, int count) { - ItemsRemainingRenderHandler.stack = stack; - ItemsRemainingRenderHandler.count = count; - ticks = stack == null ? 0 : maxTicks; - } - - public static void set(EntityPlayer player, ItemStack displayStack, Pattern pattern) { - int count = 0; - for (int i = 0; i < player.inventory.getSizeInventory(); i++) { - ItemStack stack = player.inventory.getStackInSlot(i); - if (stack != null && pattern.matcher(stack.getUnlocalizedName()).find()) count += stack.stackSize; - } - - set(displayStack, count); - } + private static int maxTicks = 30; + private static int leaveTicks = 20; + + private static ItemStack stack; + private static int ticks, count; + + @SideOnly(Side.CLIENT) + public static void render(ScaledResolution resolution, float partTicks) { + if(ticks > 0 && stack != null) { + int pos = maxTicks - ticks; + Minecraft mc = Minecraft.getMinecraft(); + int x = resolution.getScaledWidth() / 2 + 10 + Math.max(0, pos - leaveTicks); + int y = resolution.getScaledHeight() / 2; + + int start = maxTicks - leaveTicks; + float alpha = ticks + partTicks > start ? 1F : (ticks + partTicks) / start; + + GL11.glDisable(GL11.GL_ALPHA_TEST); + GL11.glEnable(GL11.GL_BLEND); + GL11.glEnable(GL12.GL_RESCALE_NORMAL); + GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); + + GL11.glColor4f(1F, 1F, 1F, alpha); + RenderHelper.enableGUIStandardItemLighting(); + int xp = x + (int) (16F * (1F - alpha)); + GL11.glTranslatef(xp, y, 0F); + GL11.glScalef(alpha, 1F, 1F); + RenderItem.getInstance().renderItemAndEffectIntoGUI(mc.fontRenderer, mc.renderEngine, stack, 0, 0); + GL11.glScalef(1F / alpha,1F, 1F); + GL11.glTranslatef(-xp, -y, 0F); + RenderHelper.disableStandardItemLighting(); + GL11.glColor4f(1F, 1F, 1F, 1F); + GL11.glEnable(GL11.GL_BLEND); + + String text = EnumChatFormatting.GREEN + stack.getDisplayName(); + if(count >= 0) { + int max = stack.getMaxStackSize(); + int stacks = count / max; + int rem = count % max; + + if(stacks == 0) + text = "" + count; + else text = count + " (" + EnumChatFormatting.AQUA + stacks + EnumChatFormatting.RESET + "*" + EnumChatFormatting.GRAY + max + EnumChatFormatting.RESET + "+" + EnumChatFormatting.YELLOW + rem + EnumChatFormatting.RESET + ")"; + } else if(count == -1) + text = "\u221E"; + + int color = 0x00FFFFFF | (int) (alpha * 0xFF) << 24; + mc.fontRenderer.drawStringWithShadow(text, x + 20, y + 6, color); + + GL11.glDisable(GL11.GL_BLEND); + GL11.glEnable(GL11.GL_ALPHA_TEST); + } + } + + @SideOnly(Side.CLIENT) + public static void tick() { + if(ticks > 0) + --ticks; + } + + public static void set(ItemStack stack, int count) { + ItemsRemainingRenderHandler.stack = stack; + ItemsRemainingRenderHandler.count = count; + ticks = stack == null ? 0 : maxTicks; + } + + public static void set(EntityPlayer player, ItemStack displayStack, Pattern pattern) { + int count = 0; + for(int i = 0; i < player.inventory.getSizeInventory(); i++) { + ItemStack stack = player.inventory.getStackInSlot(i); + if(stack != null && pattern.matcher(stack.getUnlocalizedName()).find()) + count += stack.stackSize; + } + + set(displayStack, count); + } + } diff --git a/src/main/java/vazkii/botania/client/core/handler/LightningHandler.java b/src/main/java/vazkii/botania/client/core/handler/LightningHandler.java index 9804ba2afe..d66b638a36 100644 --- a/src/main/java/vazkii/botania/client/core/handler/LightningHandler.java +++ b/src/main/java/vazkii/botania/client/core/handler/LightningHandler.java @@ -2,15 +2,14 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Feb 3, 2014, 9:05:38 PM (GMT)] */ package vazkii.botania.client.core.handler; -import cpw.mods.fml.common.eventhandler.SubscribeEvent; import java.awt.Color; import java.util.ArrayList; import java.util.Collections; @@ -19,6 +18,7 @@ import java.util.Iterator; import java.util.Random; import java.util.concurrent.ConcurrentLinkedQueue; + import net.minecraft.block.Block; import net.minecraft.client.Minecraft; import net.minecraft.client.renderer.ActiveRenderInfo; @@ -33,548 +33,468 @@ import net.minecraft.util.ResourceLocation; import net.minecraft.world.World; import net.minecraftforge.client.event.RenderWorldLastEvent; + import org.lwjgl.opengl.GL11; + import vazkii.botania.client.core.handler.LightningHandler.LightningBolt.Segment; import vazkii.botania.client.fx.ParticleRenderDispatcher; import vazkii.botania.client.lib.LibResources; import vazkii.botania.common.core.helper.Vector3; +import cpw.mods.fml.common.eventhandler.SubscribeEvent; public class LightningHandler { - private static final ResourceLocation outsideResource = new ResourceLocation(LibResources.MISC_WISP_LARGE); - private static final ResourceLocation insideResource = new ResourceLocation(LibResources.MISC_WISP_SMALL); - - static double interpPosX; - static double interpPosY; - static double interpPosZ; - - private static Vector3 getRelativeViewVector(Vector3 pos) { - Entity renderEntity = Minecraft.getMinecraft().renderViewEntity; - return new Vector3( - (float) renderEntity.posX - pos.x, - (float) renderEntity.posY + renderEntity.getEyeHeight() - pos.y, - (float) renderEntity.posZ - pos.z); - } - - @SubscribeEvent - public void onRenderWorldLast(RenderWorldLastEvent event) { - Profiler profiler = Minecraft.getMinecraft().mcProfiler; - - profiler.startSection("botania-particles"); - ParticleRenderDispatcher.dispatch(); - profiler.startSection("redString"); - RedStringRenderer.renderAll(); - profiler.endStartSection("lightning"); - - float frame = event.partialTicks; - Entity entity = Minecraft.getMinecraft().thePlayer; - TextureManager render = Minecraft.getMinecraft().renderEngine; - - interpPosX = entity.lastTickPosX + (entity.posX - entity.lastTickPosX) * frame; - interpPosY = entity.lastTickPosY + (entity.posY - entity.lastTickPosY) * frame; - interpPosZ = entity.lastTickPosZ + (entity.posZ - entity.lastTickPosZ) * frame; - - GL11.glPushMatrix(); - GL11.glTranslated(-interpPosX, -interpPosY, -interpPosZ); - - Tessellator tessellator = Tessellator.instance; - - GL11.glDepthMask(false); - GL11.glEnable(GL11.GL_BLEND); - GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); - - ParticleRenderDispatcher.lightningCount = 0; - - render.bindTexture(outsideResource); - tessellator.startDrawingQuads(); - tessellator.setBrightness(0xF000F0); - for (LightningBolt bolt : LightningBolt.boltlist) - renderBolt( - bolt, - tessellator, - frame, - ActiveRenderInfo.rotationX, - ActiveRenderInfo.rotationXZ, - ActiveRenderInfo.rotationZ, - ActiveRenderInfo.rotationXY, - 0, - false); - tessellator.draw(); - - render.bindTexture(insideResource); - tessellator.startDrawingQuads(); - tessellator.setBrightness(0xF000F0); - for (LightningBolt bolt : LightningBolt.boltlist) - renderBolt( - bolt, - tessellator, - frame, - ActiveRenderInfo.rotationX, - ActiveRenderInfo.rotationXZ, - ActiveRenderInfo.rotationZ, - ActiveRenderInfo.rotationXY, - 1, - true); - tessellator.draw(); - - GL11.glDisable(GL11.GL_BLEND); - GL11.glDepthMask(true); - - GL11.glTranslated(interpPosX, interpPosY, interpPosZ); - GL11.glPopMatrix(); - - profiler.endSection(); - profiler.endSection(); - } - - public static void spawnLightningBolt( - World world, - Vector3 vectorStart, - Vector3 vectorEnd, - float ticksPerMeter, - long seed, - int colorOuter, - int colorInner) { - LightningBolt bolt = - new LightningBolt(world, vectorStart, vectorEnd, ticksPerMeter, seed, colorOuter, colorInner); - bolt.defaultFractal(); - bolt.finalizeBolt(); - LightningBolt.boltlist.add(bolt); - } - - private void renderBolt( - LightningBolt bolt, - Tessellator tessellator, - float partialframe, - float cosyaw, - float cospitch, - float sinyaw, - float cossinpitch, - int pass, - boolean inner) { - ParticleRenderDispatcher.lightningCount++; - float boltage = bolt.particleAge < 0 ? 0 : (float) bolt.particleAge / (float) bolt.particleMaxAge; - float mainalpha = 1; - if (pass == 0) mainalpha = (1 - boltage) * 0.4F; - else mainalpha = 1 - boltage * 0.5F; - - int expandTime = (int) (bolt.length * bolt.speed); - - int renderstart = (int) ((expandTime / 2 - bolt.particleMaxAge + bolt.particleAge) - / (float) (expandTime / 2) - * bolt.numsegments0); - int renderend = (int) ((bolt.particleAge + expandTime) / (float) expandTime * bolt.numsegments0); - - for (Segment rendersegment : bolt.segments) { - if (rendersegment.segmentno < renderstart || rendersegment.segmentno > renderend) continue; - - Vector3 playervec = - getRelativeViewVector(rendersegment.startpoint.point).multiply(-1); - - double width = 0.025F * (playervec.mag() / 5 + 1) * (1 + rendersegment.light) * 0.5F; - - Vector3 diff1 = playervec - .copy() - .crossProduct(rendersegment.prevdiff) - .normalize() - .multiply(width / rendersegment.sinprev); - Vector3 diff2 = playervec - .copy() - .crossProduct(rendersegment.nextdiff) - .normalize() - .multiply(width / rendersegment.sinnext); - - Vector3 startvec = rendersegment.startpoint.point; - Vector3 endvec = rendersegment.endpoint.point; - - int color = inner ? bolt.colorInner : bolt.colorOuter; - tessellator.setColorRGBA_I(color, (int) (mainalpha * rendersegment.light * new Color(color).getAlpha())); - - tessellator.addVertexWithUV(endvec.x - diff2.x, endvec.y - diff2.y, endvec.z - diff2.z, 0.5, 0); - tessellator.addVertexWithUV(startvec.x - diff1.x, startvec.y - diff1.y, startvec.z - diff1.z, 0.5, 0); - tessellator.addVertexWithUV(startvec.x + diff1.x, startvec.y + diff1.y, startvec.z + diff1.z, 0.5, 1); - tessellator.addVertexWithUV(endvec.x + diff2.x, endvec.y + diff2.y, endvec.z + diff2.z, 0.5, 1); - - if (rendersegment.next == null) { - Vector3 roundend = rendersegment - .endpoint - .point - .copy() - .add(rendersegment.diff.copy().normalize().multiply(width)); - - tessellator.addVertexWithUV(roundend.x - diff2.x, roundend.y - diff2.y, roundend.z - diff2.z, 0, 0); - tessellator.addVertexWithUV(endvec.x - diff2.x, endvec.y - diff2.y, endvec.z - diff2.z, 0.5, 0); - tessellator.addVertexWithUV(endvec.x + diff2.x, endvec.y + diff2.y, endvec.z + diff2.z, 0.5, 1); - tessellator.addVertexWithUV(roundend.x + diff2.x, roundend.y + diff2.y, roundend.z + diff2.z, 0, 1); - } - - if (rendersegment.prev == null) { - Vector3 roundend = rendersegment - .startpoint - .point - .copy() - .subtract(rendersegment.diff.copy().normalize().multiply(width)); - - tessellator.addVertexWithUV(startvec.x - diff1.x, startvec.y - diff1.y, startvec.z - diff1.z, 0.5, 0); - tessellator.addVertexWithUV(roundend.x - diff1.x, roundend.y - diff1.y, roundend.z - diff1.z, 0, 0); - tessellator.addVertexWithUV(roundend.x + diff1.x, roundend.y + diff1.y, roundend.z + diff1.z, 0, 1); - tessellator.addVertexWithUV(startvec.x + diff1.x, startvec.y + diff1.y, startvec.z + diff1.z, 0.5, 1); - } - } - } - - public static class LightningBolt { - - public ArrayList segments = new ArrayList(); - public Vector3 start; - public Vector3 end; - ChunkCoordinates target; - HashMap splitparents = new HashMap(); - - public double length; - public int numsegments0; - private int numsplits; - private boolean finalized; - private Random rand; - public long seed; - - public int particleAge; - public int particleMaxAge; - public boolean isDead; - private AxisAlignedBB boundingBox; - - private World world; - private Entity source; - - public static ConcurrentLinkedQueue boltlist = new ConcurrentLinkedQueue(); - - public float speed = 1.5F; - public static final int fadetime = 20; - - public static int playerdamage = 1; - public static int entitydamage = 1; - - public int colorOuter; - public int colorInner; - - public class BoltPoint { - - public BoltPoint(Vector3 basepoint, Vector3 offsetvec) { - point = basepoint.copy().add(offsetvec); - this.basepoint = basepoint; - this.offsetvec = offsetvec; - } - - public Vector3 point; - Vector3 basepoint; - Vector3 offsetvec; - } - - public class SegmentSorter implements Comparator { - - @Override - public int compare(Segment o1, Segment o2) { - int comp = Integer.valueOf(o1.splitno).compareTo(o2.splitno); - if (comp == 0) return Integer.valueOf(o1.segmentno).compareTo(o2.segmentno); - else return comp; - } - } - - public class SegmentLightSorter implements Comparator { - @Override - public int compare(Segment o1, Segment o2) { - return Float.compare(o2.light, o1.light); - } - } - - public class Segment { - public Segment(BoltPoint start, BoltPoint end, float light, int segmentnumber, int splitnumber) { - startpoint = start; - endpoint = end; - this.light = light; - segmentno = segmentnumber; - splitno = splitnumber; - - calcDiff(); - } - - public Segment(Vector3 start, Vector3 end) { - this(new BoltPoint(start, new Vector3(0, 0, 0)), new BoltPoint(end, new Vector3(0, 0, 0)), 1, 0, 0); - } - - public void calcDiff() { - diff = endpoint.point.copy().subtract(startpoint.point); - } - - public void calcEndDiffs() { - if (prev != null) { - Vector3 prevdiffnorm = prev.diff.copy().normalize(); - Vector3 thisdiffnorm = diff.copy().normalize(); - - prevdiff = thisdiffnorm.copy().add(prevdiffnorm).normalize(); - sinprev = (float) Math.sin(thisdiffnorm.angle(prevdiffnorm.multiply(-1)) / 2); - } else { - prevdiff = diff.copy().normalize(); - sinprev = 1; - } - - if (next != null) { - Vector3 nextdiffnorm = next.diff.copy().normalize(); - Vector3 thisdiffnorm = diff.copy().normalize(); - - nextdiff = thisdiffnorm.add(nextdiffnorm).normalize(); - sinnext = (float) Math.sin(thisdiffnorm.angle(nextdiffnorm.multiply(-1)) / 2); - } else { - nextdiff = diff.copy().normalize(); - sinnext = 1; - } - } - - @Override - public String toString() { - return startpoint.point.toString() + " " + endpoint.point.toString(); - } - - public BoltPoint startpoint; - public BoltPoint endpoint; - - public Vector3 diff; - - public Segment prev; - public Segment next; - - public Vector3 nextdiff; - public Vector3 prevdiff; - - public float sinprev; - public float sinnext; - public float light; - - public int segmentno; - public int splitno; - } - - public LightningBolt( - World world, - Vector3 sourcevec, - Vector3 targetvec, - float ticksPerMeter, - long seed, - int colorOuter, - int colorInner) { - this.world = world; - this.seed = seed; - rand = new Random(seed); - - start = sourcevec; - end = targetvec; - - speed = ticksPerMeter; - - this.colorOuter = colorOuter; - this.colorInner = colorInner; - - numsegments0 = 1; - - length = end.copy().subtract(start).mag(); - particleMaxAge = fadetime + rand.nextInt(fadetime) - fadetime / 2; - particleAge = -(int) (length * speed); - - boundingBox = AxisAlignedBB.getBoundingBox(0, 0, 0, 0, 0, 0); - boundingBox.setBB(AxisAlignedBB.getBoundingBox( - Math.min(start.x, end.x), - Math.min(start.y, end.y), - Math.min(start.z, end.z), - Math.max(start.x, end.x), - Math.max(start.y, end.y), - Math.max(start.z, end.z)) - .expand(length / 2, length / 2, length / 2)); - - segments.add(new Segment(start, end)); - } - - public static Vector3 getFocalPoint(TileEntity tile) { - return Vector3.fromTileEntityCenter(tile); - } - - public LightningBolt( - World world, - Vector3 sourcevec, - TileEntity target, - float ticksPerMeter, - long seed, - int colorOuter, - int colorInner) { - this(world, sourcevec, getFocalPoint(target), ticksPerMeter, seed, colorOuter, colorInner); - this.target = new ChunkCoordinates(target.xCoord, target.yCoord, target.zCoord); - } - - public void setWrapper(Entity entity) { - source = entity; - } - - public void fractal(int splits, double amount, double splitchance, double splitlength, double splitangle) { - if (finalized) return; - - ArrayList oldsegments = segments; - segments = new ArrayList(); - - Segment prev = null; - - for (Segment segment : oldsegments) { - prev = segment.prev; - - Vector3 subsegment = segment.diff.copy().multiply(1F / splits); - - BoltPoint[] newpoints = new BoltPoint[splits + 1]; - - Vector3 startpoint = segment.startpoint.point; - newpoints[0] = segment.startpoint; - newpoints[splits] = segment.endpoint; - - for (int i = 1; i < splits; i++) { - Vector3 randoff = segment.diff - .copy() - .perpendicular() - .normalize() - .rotate(rand.nextFloat() * 360, segment.diff); - randoff.multiply((rand.nextFloat() - 0.5F) * amount * 2); - - Vector3 basepoint = startpoint.copy().add(subsegment.copy().multiply(i)); - - newpoints[i] = new BoltPoint(basepoint, randoff); - } - - for (int i = 0; i < splits; i++) { - Segment next = new Segment( - newpoints[i], - newpoints[i + 1], - segment.light, - segment.segmentno * splits + i, - segment.splitno); - next.prev = prev; - if (prev != null) prev.next = next; - - if (i != 0 && rand.nextFloat() < splitchance) { - Vector3 splitrot = next.diff.copy().xCrossProduct().rotate(rand.nextFloat() * 360, next.diff); - Vector3 diff = next.diff - .copy() - .rotate((rand.nextFloat() * 0.66F + 0.33F) * splitangle, splitrot) - .multiply(splitlength); - - numsplits++; - splitparents.put(numsplits, next.splitno); - - Segment split = new Segment( - newpoints[i], - new BoltPoint( - newpoints[i + 1].basepoint, - newpoints[i + 1].offsetvec.copy().add(diff)), - segment.light / 2F, - next.segmentno, - numsplits); - split.prev = prev; - - segments.add(split); - } - - prev = next; - segments.add(next); - } - - if (segment.next != null) segment.next.prev = prev; - } - - numsegments0 *= splits; - } - - public void defaultFractal() { - fractal(2, length / 1.5, 0.7F, 0.7F, 45); - fractal(2, length / 4, 0.5F, 0.8F, 50); - fractal(2, length / 15, 0.5F, 0.9F, 55); - fractal(2, length / 30, 0.5F, 1.0F, 60); - fractal(2, length / 60, 0, 0, 0); - fractal(2, length / 100, 0, 0, 0); - fractal(2, length / 400, 0, 0, 0); - } - - private float rayTraceResistance(Vector3 start, Vector3 end, float prevresistance) { - MovingObjectPosition mop = world.rayTraceBlocks(start.toVec3D(), end.toVec3D()); - - if (mop == null) return prevresistance; - - if (mop.typeOfHit == MovingObjectPosition.MovingObjectType.BLOCK) { - Block block = world.getBlock(mop.blockX, mop.blockY, mop.blockZ); - - if (world.isAirBlock(mop.blockX, mop.blockY, mop.blockZ)) return prevresistance; - - return prevresistance + block.getExplosionResistance(source) + 0.3F; - } else return prevresistance; - } - - private void calculateCollisionAndDiffs() { - HashMap lastactivesegment = new HashMap(); - - Collections.sort(segments, new SegmentSorter()); - - int lastsplitcalc = 0; - int lastactiveseg = 0; // unterminated - float splitresistance = 0; - - for (Segment segment : segments) { - if (segment.splitno > lastsplitcalc) { - lastactivesegment.put(lastsplitcalc, lastactiveseg); - lastsplitcalc = segment.splitno; - lastactiveseg = lastactivesegment.get(splitparents.get(segment.splitno)); - splitresistance = lastactiveseg < segment.segmentno ? 50 : 0; - } - - if (splitresistance >= 40 * segment.light) continue; - - splitresistance = rayTraceResistance(segment.startpoint.point, segment.endpoint.point, splitresistance); - lastactiveseg = segment.segmentno; - } - lastactivesegment.put(lastsplitcalc, lastactiveseg); - - lastsplitcalc = 0; - lastactiveseg = lastactivesegment.get(0); - for (Iterator iterator = segments.iterator(); iterator.hasNext(); ) { - Segment segment = iterator.next(); - if (lastsplitcalc != segment.splitno) { - lastsplitcalc = segment.splitno; - lastactiveseg = lastactivesegment.get(segment.splitno); - } - - if (segment.segmentno > lastactiveseg) iterator.remove(); - segment.calcEndDiffs(); - } - } - - public void finalizeBolt() { - if (finalized) return; - finalized = true; - - calculateCollisionAndDiffs(); - - Collections.sort(segments, new SegmentLightSorter()); - - boltlist.add(this); - } - - public void onUpdate() { - particleAge++; - - if (particleAge >= particleMaxAge) isDead = true; - } - - // Called in ClientTickHandler - public static void update() { - for (Iterator iterator = boltlist.iterator(); iterator.hasNext(); ) { - LightningBolt bolt = iterator.next(); + private static final ResourceLocation outsideResource = new ResourceLocation(LibResources.MISC_WISP_LARGE); + private static final ResourceLocation insideResource = new ResourceLocation(LibResources.MISC_WISP_SMALL); + + static double interpPosX; + static double interpPosY; + static double interpPosZ; + + private static Vector3 getRelativeViewVector(Vector3 pos) { + Entity renderEntity = Minecraft.getMinecraft().renderViewEntity; + return new Vector3((float) renderEntity.posX - pos.x, (float) renderEntity.posY + renderEntity.getEyeHeight() - pos.y, (float) renderEntity.posZ - pos.z); + } + + @SubscribeEvent + public void onRenderWorldLast(RenderWorldLastEvent event) { + Profiler profiler = Minecraft.getMinecraft().mcProfiler; + + profiler.startSection("botania-particles"); + ParticleRenderDispatcher.dispatch(); + profiler.startSection("redString"); + RedStringRenderer.renderAll(); + profiler.endStartSection("lightning"); + + float frame = event.partialTicks; + Entity entity = Minecraft.getMinecraft().thePlayer; + TextureManager render = Minecraft.getMinecraft().renderEngine; + + interpPosX = entity.lastTickPosX + (entity.posX - entity.lastTickPosX) * frame; + interpPosY = entity.lastTickPosY + (entity.posY - entity.lastTickPosY) * frame; + interpPosZ = entity.lastTickPosZ + (entity.posZ - entity.lastTickPosZ) * frame; + + GL11.glPushMatrix(); + GL11.glTranslated(-interpPosX, -interpPosY, -interpPosZ); + + Tessellator tessellator = Tessellator.instance; + + GL11.glDepthMask(false); + GL11.glEnable(GL11.GL_BLEND); + GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); + + ParticleRenderDispatcher.lightningCount = 0; + + render.bindTexture(outsideResource); + tessellator.startDrawingQuads(); + tessellator.setBrightness(0xF000F0); + for(LightningBolt bolt : LightningBolt.boltlist) + renderBolt(bolt, tessellator, frame, ActiveRenderInfo.rotationX, ActiveRenderInfo.rotationXZ, ActiveRenderInfo.rotationZ, ActiveRenderInfo.rotationXY, 0, false); + tessellator.draw(); + + render.bindTexture(insideResource); + tessellator.startDrawingQuads(); + tessellator.setBrightness(0xF000F0); + for(LightningBolt bolt : LightningBolt.boltlist) + renderBolt(bolt, tessellator, frame, ActiveRenderInfo.rotationX, ActiveRenderInfo.rotationXZ, ActiveRenderInfo.rotationZ, ActiveRenderInfo.rotationXY, 1, true); + tessellator.draw(); + + GL11.glDisable(GL11.GL_BLEND); + GL11.glDepthMask(true); + + GL11.glTranslated(interpPosX, interpPosY, interpPosZ); + GL11.glPopMatrix(); + + profiler.endSection(); + profiler.endSection(); + + } + + public static void spawnLightningBolt(World world, Vector3 vectorStart, Vector3 vectorEnd, float ticksPerMeter, long seed, int colorOuter, int colorInner) { + LightningBolt bolt = new LightningBolt(world, vectorStart, vectorEnd, ticksPerMeter, seed, colorOuter, colorInner); + bolt.defaultFractal(); + bolt.finalizeBolt(); + LightningBolt.boltlist.add(bolt); + } + + private void renderBolt(LightningBolt bolt, Tessellator tessellator, float partialframe, float cosyaw, float cospitch, float sinyaw, float cossinpitch, int pass, boolean inner) { + ParticleRenderDispatcher.lightningCount++; + float boltage = bolt.particleAge < 0 ? 0 : (float) bolt.particleAge / (float) bolt.particleMaxAge; + float mainalpha = 1; + if(pass == 0) + mainalpha = (1 - boltage) * 0.4F; + else mainalpha = 1 - boltage * 0.5F; + + int expandTime = (int) (bolt.length * bolt.speed); + + int renderstart = (int) ((expandTime / 2 - bolt.particleMaxAge + bolt.particleAge) / (float) (expandTime / 2) * bolt.numsegments0); + int renderend = (int) ((bolt.particleAge + expandTime) / (float) expandTime * bolt.numsegments0); + + for(Segment rendersegment : bolt.segments) { + if(rendersegment.segmentno < renderstart || rendersegment.segmentno > renderend) + continue; + + Vector3 playervec = getRelativeViewVector(rendersegment.startpoint.point).multiply(-1); + + double width = 0.025F * (playervec.mag() / 5 + 1) * (1 + rendersegment.light) * 0.5F; + + Vector3 diff1 = playervec.copy().crossProduct(rendersegment.prevdiff).normalize().multiply(width / rendersegment.sinprev); + Vector3 diff2 = playervec.copy().crossProduct(rendersegment.nextdiff).normalize().multiply(width / rendersegment.sinnext); + + Vector3 startvec = rendersegment.startpoint.point; + Vector3 endvec = rendersegment.endpoint.point; + + int color = inner ? bolt.colorInner : bolt.colorOuter; + tessellator.setColorRGBA_I(color, (int) (mainalpha * rendersegment.light * new Color(color).getAlpha())); + + tessellator.addVertexWithUV(endvec.x - diff2.x, endvec.y - diff2.y, endvec.z - diff2.z, 0.5, 0); + tessellator.addVertexWithUV(startvec.x - diff1.x, startvec.y - diff1.y, startvec.z - diff1.z, 0.5, 0); + tessellator.addVertexWithUV(startvec.x + diff1.x, startvec.y + diff1.y, startvec.z + diff1.z, 0.5, 1); + tessellator.addVertexWithUV(endvec.x + diff2.x, endvec.y + diff2.y, endvec.z + diff2.z, 0.5, 1); + + if(rendersegment.next == null) { + Vector3 roundend = rendersegment.endpoint.point.copy().add(rendersegment.diff.copy().normalize().multiply(width)); + + tessellator.addVertexWithUV(roundend.x - diff2.x, roundend.y - diff2.y, roundend.z - diff2.z, 0, 0); + tessellator.addVertexWithUV(endvec.x - diff2.x, endvec.y - diff2.y, endvec.z - diff2.z, 0.5, 0); + tessellator.addVertexWithUV(endvec.x + diff2.x, endvec.y + diff2.y, endvec.z + diff2.z, 0.5, 1); + tessellator.addVertexWithUV(roundend.x + diff2.x, roundend.y + diff2.y, roundend.z + diff2.z, 0, 1); + } + + if(rendersegment.prev == null) { + Vector3 roundend = rendersegment.startpoint.point.copy().subtract(rendersegment.diff.copy().normalize().multiply(width)); + + tessellator.addVertexWithUV(startvec.x - diff1.x, startvec.y - diff1.y, startvec.z - diff1.z, 0.5, 0); + tessellator.addVertexWithUV(roundend.x - diff1.x, roundend.y - diff1.y, roundend.z - diff1.z, 0, 0); + tessellator.addVertexWithUV(roundend.x + diff1.x, roundend.y + diff1.y, roundend.z + diff1.z, 0, 1); + tessellator.addVertexWithUV(startvec.x + diff1.x, startvec.y + diff1.y, startvec.z + diff1.z, 0.5, 1); + } + } + } + + public static class LightningBolt { + + public ArrayList segments = new ArrayList(); + public Vector3 start; + public Vector3 end; + ChunkCoordinates target; + HashMap splitparents = new HashMap(); + + public double length; + public int numsegments0; + private int numsplits; + private boolean finalized; + private Random rand; + public long seed; + + public int particleAge; + public int particleMaxAge; + public boolean isDead; + private AxisAlignedBB boundingBox; + + private World world; + private Entity source; + + public static ConcurrentLinkedQueue boltlist = new ConcurrentLinkedQueue(); + + public float speed = 1.5F; + public static final int fadetime = 20; + + public static int playerdamage = 1; + public static int entitydamage = 1; + + public int colorOuter; + public int colorInner; + + public class BoltPoint { + + public BoltPoint(Vector3 basepoint, Vector3 offsetvec) { + point = basepoint.copy().add(offsetvec); + this.basepoint = basepoint; + this.offsetvec = offsetvec; + } + + public Vector3 point; + Vector3 basepoint; + Vector3 offsetvec; + } + + public class SegmentSorter implements Comparator { + + @Override + public int compare(Segment o1, Segment o2) { + int comp = Integer.valueOf(o1.splitno).compareTo(o2.splitno); + if(comp == 0) + return Integer.valueOf(o1.segmentno).compareTo(o2.segmentno); + else return comp; + } + } + + public class SegmentLightSorter implements Comparator { + @Override + public int compare(Segment o1, Segment o2) { + return Float.compare(o2.light, o1.light); + } + } + + public class Segment { + public Segment(BoltPoint start, BoltPoint end, float light, int segmentnumber, int splitnumber) { + startpoint = start; + endpoint = end; + this.light = light; + segmentno = segmentnumber; + splitno = splitnumber; + + calcDiff(); + } + + public Segment(Vector3 start, Vector3 end) { + this(new BoltPoint(start, new Vector3(0, 0, 0)), new BoltPoint(end, new Vector3(0, 0, 0)), 1, 0, 0); + } + + public void calcDiff() { + diff = endpoint.point.copy().subtract(startpoint.point); + } + + public void calcEndDiffs() { + if(prev != null) { + Vector3 prevdiffnorm = prev.diff.copy().normalize(); + Vector3 thisdiffnorm = diff.copy().normalize(); + + prevdiff = thisdiffnorm.copy().add(prevdiffnorm).normalize(); + sinprev = (float) Math.sin(thisdiffnorm.angle(prevdiffnorm.multiply(-1)) / 2); + } else { + prevdiff = diff.copy().normalize(); + sinprev = 1; + } + + if(next != null) { + Vector3 nextdiffnorm = next.diff.copy().normalize(); + Vector3 thisdiffnorm = diff.copy().normalize(); + + nextdiff = thisdiffnorm.add(nextdiffnorm).normalize(); + sinnext = (float) Math.sin(thisdiffnorm.angle(nextdiffnorm.multiply(-1)) / 2); + } else { + nextdiff = diff.copy().normalize(); + sinnext = 1; + } + } + + @Override + public String toString() { + return startpoint.point.toString() + " " + endpoint.point.toString(); + } + + public BoltPoint startpoint; + public BoltPoint endpoint; + + public Vector3 diff; + + public Segment prev; + public Segment next; + + public Vector3 nextdiff; + public Vector3 prevdiff; + + public float sinprev; + public float sinnext; + public float light; + + public int segmentno; + public int splitno; + } + + public LightningBolt(World world, Vector3 sourcevec, Vector3 targetvec, float ticksPerMeter, long seed, int colorOuter, int colorInner) { + this.world = world; + this.seed = seed; + rand = new Random(seed); + + start = sourcevec; + end = targetvec; + + speed = ticksPerMeter; + + this.colorOuter = colorOuter; + this.colorInner = colorInner; + + numsegments0 = 1; + + length = end.copy().subtract(start).mag(); + particleMaxAge = fadetime + rand.nextInt(fadetime) - fadetime / 2; + particleAge = -(int) (length * speed); + + boundingBox = AxisAlignedBB.getBoundingBox(0, 0, 0, 0, 0, 0); + boundingBox.setBB(AxisAlignedBB.getBoundingBox(Math.min(start.x, end.x), Math.min(start.y, end.y), Math.min(start.z, end.z), Math.max(start.x, end.x), Math.max(start.y, end.y), Math.max(start.z, end.z)).expand(length / 2, length / 2, length / 2)); + + segments.add(new Segment(start, end)); + } + + public static Vector3 getFocalPoint(TileEntity tile) { + return Vector3.fromTileEntityCenter(tile); + } + + public LightningBolt(World world, Vector3 sourcevec, TileEntity target, float ticksPerMeter, long seed, int colorOuter, int colorInner) { + this(world, sourcevec, getFocalPoint(target), ticksPerMeter, seed, colorOuter, colorInner); + this.target = new ChunkCoordinates(target.xCoord, target.yCoord, target.zCoord); + } + + public void setWrapper(Entity entity) { + source = entity; + } + + public void fractal(int splits, double amount, double splitchance, double splitlength, double splitangle) { + if(finalized) + return; + + ArrayList oldsegments = segments; + segments = new ArrayList(); + + Segment prev = null; + + for(Segment segment : oldsegments) { + prev = segment.prev; + + Vector3 subsegment = segment.diff.copy().multiply(1F / splits); + + BoltPoint[] newpoints = new BoltPoint[splits + 1]; + + Vector3 startpoint = segment.startpoint.point; + newpoints[0] = segment.startpoint; + newpoints[splits] = segment.endpoint; + + for(int i = 1; i < splits; i++) { + Vector3 randoff = segment.diff.copy().perpendicular().normalize().rotate(rand.nextFloat() * 360, segment.diff); + randoff.multiply((rand.nextFloat() - 0.5F) * amount * 2); + + Vector3 basepoint = startpoint.copy().add(subsegment.copy().multiply(i)); + + newpoints[i] = new BoltPoint(basepoint, randoff); + } + + for(int i = 0; i < splits; i++) { + Segment next = new Segment(newpoints[i], newpoints[i + 1], segment.light, segment.segmentno * splits + i, segment.splitno); + next.prev = prev; + if (prev != null) + prev.next = next; + + if(i != 0 && rand.nextFloat() < splitchance) { + Vector3 splitrot = next.diff.copy().xCrossProduct().rotate(rand.nextFloat() * 360, next.diff); + Vector3 diff = next.diff.copy().rotate((rand.nextFloat() * 0.66F + 0.33F) * splitangle, splitrot).multiply(splitlength); + + numsplits++; + splitparents.put(numsplits, next.splitno); + + Segment split = new Segment(newpoints[i], new BoltPoint(newpoints[i + 1].basepoint, newpoints[i + 1].offsetvec.copy().add(diff)), segment.light / 2F, next.segmentno, numsplits); + split.prev = prev; + + segments.add(split); + } + + prev = next; + segments.add(next); + } + + if(segment.next != null) + segment.next.prev = prev; + } + + numsegments0 *= splits; + } + + public void defaultFractal() { + fractal(2, length / 1.5, 0.7F, 0.7F, 45); + fractal(2, length / 4, 0.5F, 0.8F, 50); + fractal(2, length / 15, 0.5F, 0.9F, 55); + fractal(2, length / 30, 0.5F, 1.0F, 60); + fractal(2, length / 60, 0, 0, 0); + fractal(2, length / 100, 0, 0, 0); + fractal(2, length / 400, 0, 0, 0); + } + + private float rayTraceResistance(Vector3 start, Vector3 end, float prevresistance) { + MovingObjectPosition mop = world.rayTraceBlocks(start.toVec3D(), end.toVec3D()); + + if(mop == null) + return prevresistance; + + if(mop.typeOfHit == MovingObjectPosition.MovingObjectType.BLOCK) { + Block block = world.getBlock(mop.blockX, mop.blockY, mop.blockZ); + + if(world.isAirBlock(mop.blockX, mop.blockY, mop.blockZ)) + return prevresistance; + + return prevresistance + block.getExplosionResistance(source) + 0.3F; + } else return prevresistance; + } + + private void calculateCollisionAndDiffs() { + HashMap lastactivesegment = new HashMap(); + + Collections.sort(segments, new SegmentSorter()); + + int lastsplitcalc = 0; + int lastactiveseg = 0;// unterminated + float splitresistance = 0; + + for(Segment segment : segments) { + if(segment.splitno > lastsplitcalc) { + lastactivesegment.put(lastsplitcalc, lastactiveseg); + lastsplitcalc = segment.splitno; + lastactiveseg = lastactivesegment.get(splitparents.get(segment.splitno)); + splitresistance = lastactiveseg < segment.segmentno ? 50 : 0; + } + + if(splitresistance >= 40 * segment.light) + continue; + + splitresistance = rayTraceResistance(segment.startpoint.point, segment.endpoint.point, splitresistance); + lastactiveseg = segment.segmentno; + } + lastactivesegment.put(lastsplitcalc, lastactiveseg); - bolt.onUpdate(); - if (bolt.isDead) iterator.remove(); - } - } - } -} + lastsplitcalc = 0; + lastactiveseg = lastactivesegment.get(0); + for(Iterator iterator = segments.iterator(); iterator.hasNext();) { + Segment segment = iterator.next(); + if(lastsplitcalc != segment.splitno) { + lastsplitcalc = segment.splitno; + lastactiveseg = lastactivesegment.get(segment.splitno); + } + + if(segment.segmentno > lastactiveseg) + iterator.remove(); + segment.calcEndDiffs(); + } + } + + public void finalizeBolt() { + if(finalized) + return; + finalized = true; + + calculateCollisionAndDiffs(); + + Collections.sort(segments, new SegmentLightSorter()); + + boltlist.add(this); + } + + public void onUpdate() { + particleAge++; + + if (particleAge >= particleMaxAge) + isDead = true; + } + + // Called in ClientTickHandler + public static void update() { + for(Iterator iterator = boltlist.iterator(); iterator.hasNext();) { + LightningBolt bolt = iterator.next(); + + bolt.onUpdate(); + if(bolt.isDead) + iterator.remove(); + } + } + } +} \ No newline at end of file diff --git a/src/main/java/vazkii/botania/client/core/handler/MultiblockBlockAccess.java b/src/main/java/vazkii/botania/client/core/handler/MultiblockBlockAccess.java index 19d2b67f75..c59ac25056 100644 --- a/src/main/java/vazkii/botania/client/core/handler/MultiblockBlockAccess.java +++ b/src/main/java/vazkii/botania/client/core/handler/MultiblockBlockAccess.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Aug 31, 2015, 11:40:59 PM (GMT)] */ package vazkii.botania.client.core.handler; @@ -25,95 +25,108 @@ */ public class MultiblockBlockAccess implements IBlockAccess { - protected IBlockAccess originalBlockAccess; - protected boolean hasBlockAccess = false; - protected Multiblock multiblock; - protected int anchorX, anchorY, anchorZ; + protected IBlockAccess originalBlockAccess; + protected boolean hasBlockAccess = false; + protected Multiblock multiblock; + protected int anchorX, anchorY, anchorZ; - @Override - public Block getBlock(int x, int y, int z) { - MultiblockComponent comp = getComponent(x, y, z); - if (comp != null) return comp.getBlock(); - if (hasBlockAccess) return originalBlockAccess.getBlock(x, y, z); - return Blocks.air; - } + @Override + public Block getBlock(int x, int y, int z) { + MultiblockComponent comp=getComponent(x, y, z); + if(comp != null) + return comp.getBlock(); + if(hasBlockAccess) + return originalBlockAccess.getBlock(x, y, z); + return Blocks.air; + } - @Override - public TileEntity getTileEntity(int x, int y, int z) { - MultiblockComponent comp = getComponent(x, y, z); - if (comp != null) return comp.getTileEntity(); - if (hasBlockAccess) return originalBlockAccess.getTileEntity(x, y, z); - return null; - } + @Override + public TileEntity getTileEntity(int x, int y, int z) { + MultiblockComponent comp=getComponent(x, y, z); + if(comp != null) + return comp.getTileEntity(); + if(hasBlockAccess) + return originalBlockAccess.getTileEntity(x, y, z); + return null; + } - @Override - public int getLightBrightnessForSkyBlocks(int x, int y, int z, int p_72802_4_) { - if (hasBlockAccess) return originalBlockAccess.getLightBrightnessForSkyBlocks(x, y, z, p_72802_4_); - return 15728640; - } + @Override + public int getLightBrightnessForSkyBlocks(int x, int y, int z, int p_72802_4_) { + if(hasBlockAccess) + return originalBlockAccess.getLightBrightnessForSkyBlocks(x,y,z,p_72802_4_); + return 15728640; + } - @Override - public int getBlockMetadata(int x, int y, int z) { - MultiblockComponent comp = getComponent(x, y, z); - if (comp != null) return comp.getMeta(); - if (hasBlockAccess) return originalBlockAccess.getBlockMetadata(x, y, z); - return 0; - } + @Override + public int getBlockMetadata(int x, int y, int z) { + MultiblockComponent comp=getComponent(x, y, z); + if(comp != null) + return comp.getMeta(); + if(hasBlockAccess) + return originalBlockAccess.getBlockMetadata(x, y, z); + return 0; + } - @Override - public int isBlockProvidingPowerTo(int x, int y, int z, int direction) { - return 0; - } + @Override + public int isBlockProvidingPowerTo(int x, int y, int z, int direction) { + return 0; + } - @Override - public boolean isAirBlock(int x, int y, int z) { - MultiblockComponent comp = getComponent(x, y, z); - if (comp != null) return false; - if (hasBlockAccess) return originalBlockAccess.isAirBlock(x, y, z); - return true; - } + @Override + public boolean isAirBlock(int x, int y, int z) { + MultiblockComponent comp=getComponent(x, y, z); + if(comp != null) + return false; + if(hasBlockAccess) + return originalBlockAccess.isAirBlock(x, y, z); + return true; + } - @Override - public BiomeGenBase getBiomeGenForCoords(int x, int z) { - if (hasBlockAccess) return originalBlockAccess.getBiomeGenForCoords(x, z); - return null; - } + @Override + public BiomeGenBase getBiomeGenForCoords(int x, int z) { + if(hasBlockAccess) + return originalBlockAccess.getBiomeGenForCoords(x, z); + return null; + } - @Override - public int getHeight() { - if (hasBlockAccess) return originalBlockAccess.getHeight(); - return 256; - } + @Override + public int getHeight() { + if(hasBlockAccess) + return originalBlockAccess.getHeight(); + return 256; + } - @Override - public boolean extendedLevelsInChunkCache() { - if (hasBlockAccess) return originalBlockAccess.extendedLevelsInChunkCache(); - return false; - } + @Override + public boolean extendedLevelsInChunkCache() { + if(hasBlockAccess) + return originalBlockAccess.extendedLevelsInChunkCache(); + return false; + } - @Override - public boolean isSideSolid(int x, int y, int z, ForgeDirection side, boolean _default) { - if (hasBlockAccess) return originalBlockAccess.isSideSolid(x, y, z, side, _default); - return _default; - } + @Override + public boolean isSideSolid(int x, int y, int z, ForgeDirection side, boolean _default) { + if(hasBlockAccess) + return originalBlockAccess.isSideSolid(x, y, z, side, _default); + return _default; + } - /** - * Updates the block access to the new parameters - */ - public void update(IBlockAccess access, Multiblock mb, int anchorX, int anchorY, int anchorZ) { - originalBlockAccess = access; - multiblock = mb; - this.anchorX = anchorX; - this.anchorY = anchorY; - this.anchorZ = anchorZ; - hasBlockAccess = access != null; - } + /** + * Updates the block access to the new parameters + */ + public void update(IBlockAccess access, Multiblock mb, int anchorX, int anchorY, int anchorZ) { + originalBlockAccess = access; + multiblock = mb; + this.anchorX = anchorX; + this.anchorY = anchorY; + this.anchorZ = anchorZ; + hasBlockAccess = access != null; + } - /** - * Returns the multiblock component for the coordinates, adjusted based on the anchor - */ - protected MultiblockComponent getComponent(int x, int y, int z) { - MultiblockComponent comp = multiblock.getComponentForLocation(x - anchorX, y - anchorY, z - anchorZ); - return comp; - } + /** + * Returns the multiblock component for the coordinates, adjusted based on the anchor + */ + protected MultiblockComponent getComponent(int x, int y, int z) { + MultiblockComponent comp = multiblock.getComponentForLocation(x - anchorX, y - anchorY, z - anchorZ); + return comp; + } } diff --git a/src/main/java/vazkii/botania/client/core/handler/MultiblockRenderHandler.java b/src/main/java/vazkii/botania/client/core/handler/MultiblockRenderHandler.java index f55ed52f4e..14295ff78b 100644 --- a/src/main/java/vazkii/botania/client/core/handler/MultiblockRenderHandler.java +++ b/src/main/java/vazkii/botania/client/core/handler/MultiblockRenderHandler.java @@ -2,15 +2,14 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jun 27, 2015, 7:28:29 PM (GMT)] */ package vazkii.botania.client.core.handler; -import cpw.mods.fml.common.eventhandler.SubscribeEvent; import net.minecraft.block.Block; import net.minecraft.client.Minecraft; import net.minecraft.client.renderer.RenderBlocks; @@ -29,160 +28,164 @@ import net.minecraftforge.client.event.RenderWorldLastEvent; import net.minecraftforge.event.entity.player.PlayerInteractEvent; import net.minecraftforge.event.entity.player.PlayerInteractEvent.Action; + import org.lwjgl.opengl.GL11; + import vazkii.botania.api.lexicon.multiblock.IMultiblockRenderHook; import vazkii.botania.api.lexicon.multiblock.Multiblock; import vazkii.botania.api.lexicon.multiblock.MultiblockSet; import vazkii.botania.api.lexicon.multiblock.component.MultiblockComponent; +import cpw.mods.fml.common.eventhandler.SubscribeEvent; public final class MultiblockRenderHandler { - public static boolean rendering = false; - - private static MultiblockBlockAccess blockAccess = new MultiblockBlockAccess(); - - private static RenderBlocks blockRender = RenderBlocks.getInstance(); - public static MultiblockSet currentMultiblock; - public static ChunkCoordinates anchor; - public static int angle; - public static int dimension; - - public static void setMultiblock(MultiblockSet set) { - currentMultiblock = set; - anchor = null; - angle = 0; - - Minecraft mc = Minecraft.getMinecraft(); - if (mc.theWorld != null) dimension = mc.theWorld.provider.dimensionId; - } - - @SubscribeEvent - public void onWorldRenderLast(RenderWorldLastEvent event) { - Minecraft mc = Minecraft.getMinecraft(); - if (mc.thePlayer != null && mc.objectMouseOver != null && (!mc.thePlayer.isSneaking() || anchor != null)) { - mc.thePlayer.getCurrentEquippedItem(); - renderPlayerLook(mc.thePlayer, mc.objectMouseOver); - } - } - - @SubscribeEvent - public void onPlayerInteract(PlayerInteractEvent event) { - if (currentMultiblock != null - && anchor == null - && event.action == Action.RIGHT_CLICK_BLOCK - && event.entityPlayer == Minecraft.getMinecraft().thePlayer) { - anchor = new ChunkCoordinates(event.x, event.y, event.z); - angle = MathHelper.floor_double(event.entityPlayer.rotationYaw * 4.0 / 360.0 + 0.5) & 3; - event.setCanceled(true); - } - } - - private void renderPlayerLook(EntityPlayer player, MovingObjectPosition src) { - if (currentMultiblock != null && dimension == player.worldObj.provider.dimensionId) { - int anchorX = anchor != null ? anchor.posX : src.blockX; - int anchorY = anchor != null ? anchor.posY : src.blockY; - int anchorZ = anchor != null ? anchor.posZ : src.blockZ; - - GL11.glPushMatrix(); - GL11.glPushAttrib(GL11.GL_LIGHTING); - GL11.glEnable(GL11.GL_BLEND); - GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); - GL11.glDisable(GL11.GL_LIGHTING); - rendering = true; - Multiblock mb = - anchor != null ? currentMultiblock.getForIndex(angle) : currentMultiblock.getForEntity(player); - boolean didAny = false; - - blockAccess.update(player.worldObj, mb, anchorX, anchorY, anchorZ); - - for (MultiblockComponent comp : mb.getComponents()) - if (renderComponentInWorld(player.worldObj, mb, comp, anchorX, anchorY, anchorZ)) didAny = true; - rendering = false; - GL11.glPopAttrib(); - GL11.glPopMatrix(); - - if (!didAny) { - setMultiblock(null); - player.addChatComponentMessage(new ChatComponentTranslation("botaniamisc.structureComplete") - .setChatStyle(new ChatStyle().setColor(EnumChatFormatting.GREEN))); - } - } - } - - private boolean renderComponentInWorld( - World world, Multiblock mb, MultiblockComponent comp, int anchorX, int anchorY, int anchorZ) { - ChunkCoordinates pos = comp.getRelativePosition(); - int x = pos.posX + anchorX; - int y = pos.posY + anchorY; - int z = pos.posZ + anchorZ; - if (anchor != null && comp.matches(world, x, y, z)) return false; - - GL11.glPushMatrix(); - GL11.glTranslated(-RenderManager.renderPosX, -RenderManager.renderPosY, -RenderManager.renderPosZ); - GL11.glDisable(GL11.GL_DEPTH_TEST); - doRenderComponent(mb, comp, x, y, z, 0.4F); - GL11.glPopMatrix(); - return true; - } - - public static void renderMultiblockOnPage(Multiblock mb) { - GL11.glTranslated(-0.5, -0.5, -0.5); - blockAccess.update(null, mb, mb.offX, mb.offY, mb.offZ); - for (MultiblockComponent comp : mb.getComponents()) { - ChunkCoordinates pos = comp.getRelativePosition(); - doRenderComponent(mb, comp, pos.posX + mb.offX, pos.posY + mb.offY, pos.posZ + mb.offZ, 1); - } - } - - private static void doRenderComponent(Multiblock mb, MultiblockComponent comp, int x, int y, int z, float alpha) { - GL11.glPushMatrix(); - GL11.glEnable(GL11.GL_BLEND); - GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); - Block block = comp.getBlock(); - int meta = comp.getMeta(); - Minecraft.getMinecraft().renderEngine.bindTexture(TextureMap.locationBlocksTexture); - blockRender.useInventoryTint = false; - if (block == null) return; - if (IMultiblockRenderHook.renderHooks.containsKey(block)) { - GL11.glColor4f(1F, 1F, 1F, alpha); - IMultiblockRenderHook renderHook = IMultiblockRenderHook.renderHooks.get(block); - if (renderHook.needsTranslate(block)) { - GL11.glTranslated(x + 0.5, y + 0.5, z + 0.5); - } - renderHook.renderBlockForMultiblock(blockAccess, mb, block, comp.getMeta(), blockRender, comp, alpha); - } else { - if (comp.shouldDoFancyRender()) { - int color = block.colorMultiplier(blockAccess, x, y, z); - float red = (color >> 16 & 255) / 255.0F; - float green = (color >> 8 & 255) / 255.0F; - float blue = (color & 255) / 255.0F; - GL11.glColor4f(red, green, blue, alpha); - IBlockAccess oldBlockAccess = blockRender.blockAccess; - blockRender.blockAccess = blockAccess; - Tessellator tessellator = Tessellator.instance; - blockRender.renderAllFaces = true; - tessellator.startDrawingQuads(); - tessellator.disableColor(); - try { - blockRender.renderBlockByRenderType(block, x, y, z); - } catch (Exception e) { - comp.doFancyRender = false; - } - tessellator.draw(); - blockRender.renderAllFaces = false; - blockRender.blockAccess = oldBlockAccess; - } else { - int color = block.getRenderColor(meta); - float red = (color >> 16 & 255) / 255.0F; - float green = (color >> 8 & 255) / 255.0F; - float blue = (color & 255) / 255.0F; - GL11.glColor4f(red, green, blue, alpha); - GL11.glTranslated(x + 0.5, y + 0.5, z + 0.5); - blockRender.renderBlockAsItem(block, meta, 1F); - } - } - GL11.glColor4f(1F, 1F, 1F, 1F); - GL11.glEnable(GL11.GL_DEPTH_TEST); - GL11.glPopMatrix(); - } + public static boolean rendering = false; + + private static MultiblockBlockAccess blockAccess = new MultiblockBlockAccess(); + + private static RenderBlocks blockRender = RenderBlocks.getInstance(); + public static MultiblockSet currentMultiblock; + public static ChunkCoordinates anchor; + public static int angle; + public static int dimension; + + public static void setMultiblock(MultiblockSet set) { + currentMultiblock = set; + anchor = null; + angle = 0; + + Minecraft mc = Minecraft.getMinecraft(); + if(mc.theWorld != null) + dimension = mc.theWorld.provider.dimensionId; + } + + @SubscribeEvent + public void onWorldRenderLast(RenderWorldLastEvent event) { + Minecraft mc = Minecraft.getMinecraft(); + if(mc.thePlayer != null && mc.objectMouseOver != null && (!mc.thePlayer.isSneaking() || anchor != null)) { + mc.thePlayer.getCurrentEquippedItem(); + renderPlayerLook(mc.thePlayer, mc.objectMouseOver); + } + } + + @SubscribeEvent + public void onPlayerInteract(PlayerInteractEvent event) { + if(currentMultiblock != null && anchor == null && event.action == Action.RIGHT_CLICK_BLOCK && event.entityPlayer == Minecraft.getMinecraft().thePlayer) { + anchor = new ChunkCoordinates(event.x, event.y, event.z); + angle = MathHelper.floor_double(event.entityPlayer.rotationYaw * 4.0 / 360.0 + 0.5) & 3; + event.setCanceled(true); + } + } + + private void renderPlayerLook(EntityPlayer player, MovingObjectPosition src) { + if(currentMultiblock != null && dimension == player.worldObj.provider.dimensionId) { + int anchorX = anchor != null ? anchor.posX : src.blockX; + int anchorY = anchor != null ? anchor.posY : src.blockY; + int anchorZ = anchor != null ? anchor.posZ : src.blockZ; + + GL11.glPushMatrix(); + GL11.glPushAttrib(GL11.GL_LIGHTING); + GL11.glEnable(GL11.GL_BLEND); + GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); + GL11.glDisable(GL11.GL_LIGHTING); + rendering = true; + Multiblock mb = anchor != null ? currentMultiblock.getForIndex(angle) : currentMultiblock.getForEntity(player); + boolean didAny = false; + + blockAccess.update(player.worldObj, mb, anchorX, anchorY, anchorZ); + + for(MultiblockComponent comp : mb.getComponents()) + if(renderComponentInWorld(player.worldObj, mb, comp, anchorX, anchorY, anchorZ)) + didAny = true; + rendering = false; + GL11.glPopAttrib(); + GL11.glPopMatrix(); + + if(!didAny) { + setMultiblock(null); + player.addChatComponentMessage(new ChatComponentTranslation("botaniamisc.structureComplete").setChatStyle(new ChatStyle().setColor(EnumChatFormatting.GREEN))); + } + } + } + + private boolean renderComponentInWorld(World world, Multiblock mb, MultiblockComponent comp, int anchorX, int anchorY, int anchorZ) { + ChunkCoordinates pos = comp.getRelativePosition(); + int x = pos.posX + anchorX; + int y = pos.posY + anchorY; + int z = pos.posZ + anchorZ; + if(anchor != null && comp.matches(world, x, y, z)) + return false; + + GL11.glPushMatrix(); + GL11.glTranslated(-RenderManager.renderPosX, -RenderManager.renderPosY, -RenderManager.renderPosZ); + GL11.glDisable(GL11.GL_DEPTH_TEST); + doRenderComponent(mb, comp, x, y, z, 0.4F); + GL11.glPopMatrix(); + return true; + } + + public static void renderMultiblockOnPage(Multiblock mb) { + GL11.glTranslated(-0.5, -0.5, -0.5); + blockAccess.update(null, mb, mb.offX, mb.offY, mb.offZ); + for(MultiblockComponent comp : mb.getComponents()) { + ChunkCoordinates pos = comp.getRelativePosition(); + doRenderComponent(mb, comp, pos.posX + mb.offX, pos.posY + mb.offY, pos.posZ + mb.offZ, 1); + } + } + + private static void doRenderComponent(Multiblock mb, MultiblockComponent comp, int x, int y, int z, float alpha) { + GL11.glPushMatrix(); + GL11.glEnable(GL11.GL_BLEND); + GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); + Block block = comp.getBlock(); + int meta = comp.getMeta(); + Minecraft.getMinecraft().renderEngine.bindTexture(TextureMap.locationBlocksTexture); + blockRender.useInventoryTint = false; + if(block == null) + return; + if(IMultiblockRenderHook.renderHooks.containsKey(block)) { + GL11.glColor4f(1F, 1F, 1F, alpha); + IMultiblockRenderHook renderHook = IMultiblockRenderHook.renderHooks.get(block); + if(renderHook.needsTranslate(block)) { + GL11.glTranslated(x + 0.5, y + 0.5, z + 0.5); + } + renderHook.renderBlockForMultiblock(blockAccess, mb, block, comp.getMeta(), blockRender, comp, alpha); + } + else { + if(comp.shouldDoFancyRender()) { + int color = block.colorMultiplier(blockAccess, x, y, z); + float red = (color >> 16 & 255) / 255.0F; + float green = (color >> 8 & 255) / 255.0F; + float blue = (color & 255) / 255.0F; + GL11.glColor4f(red, green, blue, alpha); + IBlockAccess oldBlockAccess = blockRender.blockAccess; + blockRender.blockAccess = blockAccess; + Tessellator tessellator = Tessellator.instance; + blockRender.renderAllFaces = true; + tessellator.startDrawingQuads(); + tessellator.disableColor(); + try { + blockRender.renderBlockByRenderType(block, x, y, z); + } + catch(Exception e) { + comp.doFancyRender = false; + } + tessellator.draw(); + blockRender.renderAllFaces = false; + blockRender.blockAccess = oldBlockAccess; + } + else { + int color = block.getRenderColor(meta); + float red = (color >> 16 & 255) / 255.0F; + float green = (color >> 8 & 255) / 255.0F; + float blue = (color & 255) / 255.0F; + GL11.glColor4f(red, green, blue, alpha); + GL11.glTranslated(x + 0.5, y + 0.5, z + 0.5); + blockRender.renderBlockAsItem(block, meta, 1F); + } + } + GL11.glColor4f(1F, 1F, 1F, 1F); + GL11.glEnable(GL11.GL_DEPTH_TEST); + GL11.glPopMatrix(); + } } diff --git a/src/main/java/vazkii/botania/client/core/handler/PersistentVariableHelper.java b/src/main/java/vazkii/botania/client/core/handler/PersistentVariableHelper.java index b276cbf4ff..3cceab2437 100644 --- a/src/main/java/vazkii/botania/client/core/handler/PersistentVariableHelper.java +++ b/src/main/java/vazkii/botania/client/core/handler/PersistentVariableHelper.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jun 24, 2015, 5:54:45 PM (GMT)] */ package vazkii.botania.client.core.handler; @@ -16,6 +16,7 @@ import java.io.IOException; import java.util.List; import java.util.Set; + import net.minecraft.nbt.CompressedStreamTools; import net.minecraft.nbt.NBTTagCompound; import vazkii.botania.client.challenge.Challenge; @@ -25,131 +26,139 @@ public final class PersistentVariableHelper { - private static final String TAG_FIRST_LOAD = "firstLoad"; - private static final String TAG_DOG = "dog"; - private static final String TAG_BOOKMARK_COUNT = "bookmarkCount"; - private static final String TAG_BOOKMARK_PREFIX = "bookmark"; - private static final String TAG_BOOKMARKS = "bookmarks"; - private static final String TAG_CHALLENGES = "challenges"; - private static final String TAG_LEXICON_NOTES = "lexiconNotes"; - private static final String TAG_LAST_BOTANIA_VERSION = "lastBotaniaVersion"; - - private static File cacheFile; - - public static boolean firstLoad = true; - public static boolean dog = true; - public static String lastBotaniaVersion = ""; - - public static void save() throws IOException { - NBTTagCompound cmp = new NBTTagCompound(); - - List bookmarks = GuiLexicon.bookmarks; - int count = bookmarks.size(); - cmp.setInteger(TAG_BOOKMARK_COUNT, count); - NBTTagCompound bookmarksCmp = new NBTTagCompound(); - for (int i = 0; i < count; i++) { - GuiLexicon lex = bookmarks.get(i); - NBTTagCompound bookmarkCmp = new NBTTagCompound(); - lex.serialize(bookmarkCmp); - bookmarksCmp.setTag(TAG_BOOKMARK_PREFIX + i, bookmarkCmp); - } - cmp.setTag(TAG_BOOKMARKS, bookmarksCmp); - - NBTTagCompound challengesCmp = new NBTTagCompound(); - for (Challenge c : ModChallenges.challengeLookup.values()) c.writeToNBT(challengesCmp); - cmp.setTag(TAG_CHALLENGES, challengesCmp); - - NBTTagCompound notesCmp = new NBTTagCompound(); - for (String s : GuiLexicon.notes.keySet()) { - String note = GuiLexicon.notes.get(s); - if (note != null && !note.trim().isEmpty()) notesCmp.setString(s, note); - } - cmp.setTag(TAG_LEXICON_NOTES, notesCmp); - - cmp.setBoolean(TAG_FIRST_LOAD, firstLoad); - cmp.setBoolean(TAG_DOG, dog); - cmp.setString(TAG_LAST_BOTANIA_VERSION, lastBotaniaVersion); - - injectNBTToFile(cmp, getCacheFile()); - } - - public static void load() throws IOException { - NBTTagCompound cmp = getCacheCompound(); - - int count = cmp.getInteger(TAG_BOOKMARK_COUNT); - GuiLexicon.bookmarks.clear(); - if (count > 0) { - NBTTagCompound bookmarksCmp = cmp.getCompoundTag(TAG_BOOKMARKS); - for (int i = 0; i < count; i++) { - NBTTagCompound bookmarkCmp = bookmarksCmp.getCompoundTag(TAG_BOOKMARK_PREFIX + i); - GuiLexicon gui = GuiLexicon.create(bookmarkCmp); - if (gui != null) { - GuiLexicon.bookmarks.add(gui); - GuiLexicon.bookmarkKeys.add(gui.getNotesKey()); - } - } - } - - if (cmp.hasKey(TAG_CHALLENGES)) { - NBTTagCompound challengesCmp = cmp.getCompoundTag(TAG_CHALLENGES); - for (Challenge c : ModChallenges.challengeLookup.values()) c.readFromNBT(challengesCmp); - } - - if (cmp.hasKey(TAG_LEXICON_NOTES)) { - NBTTagCompound notesCmp = cmp.getCompoundTag(TAG_LEXICON_NOTES); - Set keys = notesCmp.func_150296_c(); - GuiLexicon.notes.clear(); - for (String key : keys) GuiLexicon.notes.put(key, notesCmp.getString(key)); - } - - lastBotaniaVersion = cmp.hasKey(TAG_LAST_BOTANIA_VERSION) ? cmp.getString(TAG_LAST_BOTANIA_VERSION) : "(N/A)"; - - firstLoad = cmp.hasKey(TAG_FIRST_LOAD) ? cmp.getBoolean(TAG_FIRST_LOAD) : firstLoad; - if (firstLoad) lastBotaniaVersion = LibMisc.VERSION; - - dog = cmp.getBoolean(TAG_DOG); - } - - public static void saveSafe() { - try { - save(); - } catch (IOException e) { - e.printStackTrace(); - } - } - - public static void setCacheFile(File f) { - cacheFile = f; - } - - public static File getCacheFile() throws IOException { - if (!cacheFile.exists()) cacheFile.createNewFile(); - - return cacheFile; - } - - public static NBTTagCompound getCacheCompound() throws IOException { - return getCacheCompound(getCacheFile()); - } - - public static NBTTagCompound getCacheCompound(File cache) throws IOException { - if (cache == null) throw new RuntimeException("No cache file!"); - - try { - NBTTagCompound cmp = CompressedStreamTools.readCompressed(new FileInputStream(cache)); - return cmp; - } catch (IOException e) { - NBTTagCompound cmp = new NBTTagCompound(); - CompressedStreamTools.writeCompressed(cmp, new FileOutputStream(cache)); - return getCacheCompound(cache); - } - } - - public static void injectNBTToFile(NBTTagCompound cmp, File f) { - try { - CompressedStreamTools.writeCompressed(cmp, new FileOutputStream(f)); - } catch (IOException e) { - e.printStackTrace(); - } - } + private static final String TAG_FIRST_LOAD = "firstLoad"; + private static final String TAG_DOG = "dog"; + private static final String TAG_BOOKMARK_COUNT = "bookmarkCount"; + private static final String TAG_BOOKMARK_PREFIX = "bookmark"; + private static final String TAG_BOOKMARKS = "bookmarks"; + private static final String TAG_CHALLENGES = "challenges"; + private static final String TAG_LEXICON_NOTES = "lexiconNotes"; + private static final String TAG_LAST_BOTANIA_VERSION = "lastBotaniaVersion"; + + private static File cacheFile; + + public static boolean firstLoad = true; + public static boolean dog = true; + public static String lastBotaniaVersion = ""; + + public static void save() throws IOException { + NBTTagCompound cmp = new NBTTagCompound(); + + List bookmarks = GuiLexicon.bookmarks; + int count = bookmarks.size(); + cmp.setInteger(TAG_BOOKMARK_COUNT, count); + NBTTagCompound bookmarksCmp = new NBTTagCompound(); + for(int i = 0; i < count; i++) { + GuiLexicon lex = bookmarks.get(i); + NBTTagCompound bookmarkCmp = new NBTTagCompound(); + lex.serialize(bookmarkCmp); + bookmarksCmp.setTag(TAG_BOOKMARK_PREFIX + i, bookmarkCmp); + } + cmp.setTag(TAG_BOOKMARKS, bookmarksCmp); + + NBTTagCompound challengesCmp = new NBTTagCompound(); + for(Challenge c : ModChallenges.challengeLookup.values()) + c.writeToNBT(challengesCmp); + cmp.setTag(TAG_CHALLENGES, challengesCmp); + + NBTTagCompound notesCmp = new NBTTagCompound(); + for(String s : GuiLexicon.notes.keySet()) { + String note = GuiLexicon.notes.get(s); + if(note != null && !note.trim().isEmpty()) + notesCmp.setString(s, note); + } + cmp.setTag(TAG_LEXICON_NOTES, notesCmp); + + cmp.setBoolean(TAG_FIRST_LOAD, firstLoad); + cmp.setBoolean(TAG_DOG, dog); + cmp.setString(TAG_LAST_BOTANIA_VERSION, lastBotaniaVersion); + + injectNBTToFile(cmp, getCacheFile()); + } + + public static void load() throws IOException { + NBTTagCompound cmp = getCacheCompound(); + + int count = cmp.getInteger(TAG_BOOKMARK_COUNT); + GuiLexicon.bookmarks.clear(); + if(count > 0) { + NBTTagCompound bookmarksCmp = cmp.getCompoundTag(TAG_BOOKMARKS); + for(int i = 0; i < count; i++) { + NBTTagCompound bookmarkCmp = bookmarksCmp.getCompoundTag(TAG_BOOKMARK_PREFIX + i); + GuiLexicon gui = GuiLexicon.create(bookmarkCmp); + if(gui != null) { + GuiLexicon.bookmarks.add(gui); + GuiLexicon.bookmarkKeys.add(gui.getNotesKey()); + } + } + } + + if(cmp.hasKey(TAG_CHALLENGES)) { + NBTTagCompound challengesCmp = cmp.getCompoundTag(TAG_CHALLENGES); + for(Challenge c : ModChallenges.challengeLookup.values()) + c.readFromNBT(challengesCmp); + } + + if(cmp.hasKey(TAG_LEXICON_NOTES)) { + NBTTagCompound notesCmp = cmp.getCompoundTag(TAG_LEXICON_NOTES); + Set keys = notesCmp.func_150296_c(); + GuiLexicon.notes.clear(); + for(String key : keys) + GuiLexicon.notes.put(key, notesCmp.getString(key)); + } + + lastBotaniaVersion = cmp.hasKey(TAG_LAST_BOTANIA_VERSION) ? cmp.getString(TAG_LAST_BOTANIA_VERSION) : "(N/A)"; + + firstLoad = cmp.hasKey(TAG_FIRST_LOAD) ? cmp.getBoolean(TAG_FIRST_LOAD) : firstLoad; + if(firstLoad) + lastBotaniaVersion = LibMisc.VERSION; + + dog = cmp.getBoolean(TAG_DOG); + } + + public static void saveSafe() { + try { + save(); + } catch (IOException e) { + e.printStackTrace(); + } + } + + public static void setCacheFile(File f) { + cacheFile = f; + } + + public static File getCacheFile() throws IOException { + if(!cacheFile.exists()) + cacheFile.createNewFile(); + + return cacheFile; + } + + public static NBTTagCompound getCacheCompound() throws IOException { + return getCacheCompound(getCacheFile()); + } + + public static NBTTagCompound getCacheCompound(File cache) throws IOException { + if(cache == null) + throw new RuntimeException("No cache file!"); + + try { + NBTTagCompound cmp = CompressedStreamTools.readCompressed(new FileInputStream(cache)); + return cmp; + } catch(IOException e) { + NBTTagCompound cmp = new NBTTagCompound(); + CompressedStreamTools.writeCompressed(cmp, new FileOutputStream(cache)); + return getCacheCompound(cache); + } + } + + public static void injectNBTToFile(NBTTagCompound cmp, File f) { + try { + CompressedStreamTools.writeCompressed(cmp, new FileOutputStream(f)); + } catch(IOException e) { + e.printStackTrace(); + } + } + } diff --git a/src/main/java/vazkii/botania/client/core/handler/RedStringRenderer.java b/src/main/java/vazkii/botania/client/core/handler/RedStringRenderer.java index a67d0afa42..fdcd0a268a 100644 --- a/src/main/java/vazkii/botania/client/core/handler/RedStringRenderer.java +++ b/src/main/java/vazkii/botania/client/core/handler/RedStringRenderer.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Nov 14, 2014, 7:05:32 PM (GMT)] */ package vazkii.botania.client.core.handler; @@ -13,104 +13,101 @@ import java.util.ArrayDeque; import java.util.Queue; import java.util.Random; + import net.minecraft.client.Minecraft; import net.minecraft.client.renderer.Tessellator; import net.minecraft.client.renderer.entity.RenderManager; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.util.ChunkCoordinates; import net.minecraftforge.common.util.ForgeDirection; + import org.lwjgl.opengl.GL11; + import vazkii.botania.common.block.tile.string.TileRedString; import vazkii.botania.common.core.helper.Vector3; import vazkii.botania.common.item.ModItems; public final class RedStringRenderer { - public static final Queue redStringTiles = new ArrayDeque(); - static float sizeAlpha = 0F; - - public static void renderAll() { - if (!redStringTiles.isEmpty()) { - GL11.glPushMatrix(); - GL11.glDisable(GL11.GL_TEXTURE_2D); - GL11.glEnable(GL11.GL_BLEND); - GL11.glPushAttrib(GL11.GL_LIGHTING); - GL11.glDisable(GL11.GL_LIGHTING); - GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); - GL11.glColor4f(1F, 0F, 0F, sizeAlpha); - - Tessellator.renderingWorldRenderer = false; - TileRedString tile; - while ((tile = redStringTiles.poll()) != null) renderTile(tile); - - GL11.glEnable(GL11.GL_TEXTURE_2D); - GL11.glDisable(GL11.GL_BLEND); - GL11.glPopAttrib(); - GL11.glPopMatrix(); - } - } - - public static void tick() { - EntityPlayer player = Minecraft.getMinecraft().thePlayer; - boolean hasWand = player != null - && player.getCurrentEquippedItem() != null - && player.getCurrentEquippedItem().getItem() == ModItems.twigWand; - if (sizeAlpha > 0F && !hasWand) sizeAlpha -= 0.1F; - else if (sizeAlpha < 1F && hasWand) sizeAlpha += 0.1F; - } - - private static void renderTile(TileRedString tile) { - ForgeDirection dir = ForgeDirection.getOrientation(tile.getBlockMetadata()); - ChunkCoordinates bind = tile.getBinding(); - - if (bind != null) { - GL11.glPushMatrix(); - GL11.glTranslated( - tile.xCoord + 0.5 - RenderManager.renderPosX, - tile.yCoord + 0.5 - RenderManager.renderPosY, - tile.zCoord + 0.5 - RenderManager.renderPosZ); - Vector3 vecOrig = new Vector3(bind.posX - tile.xCoord, bind.posY - tile.yCoord, bind.posZ - tile.zCoord); - Vector3 vecNorm = vecOrig.copy().normalize(); - Vector3 vecMag = vecNorm.copy().multiply(0.025); - Vector3 vecApply = vecMag.copy(); - - int stages = (int) (vecOrig.mag() / vecMag.mag()); - - Tessellator tessellator = Tessellator.instance; - GL11.glLineWidth(1F); - tessellator.startDrawing(GL11.GL_LINES); - - double len = (double) -ClientTickHandler.ticksInGame / 100F - + new Random(dir.ordinal() ^ tile.xCoord ^ tile.yCoord ^ tile.zCoord).nextInt(10000); - double add = vecMag.mag(); - double rand = Math.random() - 0.5; - for (int i = 0; i < stages; i++) { - addVertexAtWithTranslation(tessellator, dir, vecApply.x, vecApply.y, vecApply.z, rand, len); - rand = Math.random() - 0.5; - vecApply.add(vecMag); - len += add; - addVertexAtWithTranslation(tessellator, dir, vecApply.x, vecApply.y, vecApply.z, rand, len); - } - - tessellator.draw(); - - GL11.glPopMatrix(); - } - } - - private static void addVertexAtWithTranslation( - Tessellator tess, ForgeDirection dir, double xpos, double ypos, double zpos, double rand, double l) { - double freq = 20; - double ampl = (0.15 * (Math.sin(l * 2F) * 0.5 + 0.5) + 0.1) * sizeAlpha; - double randMul = 0.05; - double x = xpos + Math.sin(l * freq) * ampl * Math.abs(Math.abs(dir.offsetX) - 1) + rand * randMul; - double y = ypos + Math.cos(l * freq) * ampl * Math.abs(Math.abs(dir.offsetY) - 1) + rand * randMul; - double z = zpos - + (dir.offsetY == 0 ? Math.sin(l * freq) : Math.cos(l * freq)) - * ampl - * Math.abs(Math.abs(dir.offsetZ) - 1) - + rand * randMul; - - tess.addVertex(x, y, z); - } + public static final Queue redStringTiles = new ArrayDeque(); + static float sizeAlpha = 0F; + + public static void renderAll() { + if(!redStringTiles.isEmpty()) { + GL11.glPushMatrix(); + GL11.glDisable(GL11.GL_TEXTURE_2D); + GL11.glEnable(GL11.GL_BLEND); + GL11.glPushAttrib(GL11.GL_LIGHTING); + GL11.glDisable(GL11.GL_LIGHTING); + GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); + GL11.glColor4f(1F, 0F, 0F, sizeAlpha); + + Tessellator.renderingWorldRenderer = false; + TileRedString tile; + while((tile = redStringTiles.poll()) != null) + renderTile(tile); + + GL11.glEnable(GL11.GL_TEXTURE_2D); + GL11.glDisable(GL11.GL_BLEND); + GL11.glPopAttrib(); + GL11.glPopMatrix(); + + } + } + + public static void tick() { + EntityPlayer player = Minecraft.getMinecraft().thePlayer; + boolean hasWand = player != null && player.getCurrentEquippedItem() != null && player.getCurrentEquippedItem().getItem() == ModItems.twigWand; + if(sizeAlpha > 0F && !hasWand) + sizeAlpha -= 0.1F; + else if(sizeAlpha < 1F &&hasWand) + sizeAlpha += 0.1F; + } + + private static void renderTile(TileRedString tile) { + ForgeDirection dir = ForgeDirection.getOrientation(tile.getBlockMetadata()); + ChunkCoordinates bind = tile.getBinding(); + + if(bind != null) { + GL11.glPushMatrix(); + GL11.glTranslated(tile.xCoord + 0.5 - RenderManager.renderPosX, tile.yCoord + 0.5 - RenderManager.renderPosY, tile.zCoord + 0.5 - RenderManager.renderPosZ); + Vector3 vecOrig = new Vector3(bind.posX - tile.xCoord, bind.posY - tile.yCoord, bind.posZ - tile.zCoord); + Vector3 vecNorm = vecOrig.copy().normalize(); + Vector3 vecMag = vecNorm.copy().multiply(0.025); + Vector3 vecApply = vecMag.copy(); + + int stages = (int) (vecOrig.mag() / vecMag.mag()); + + Tessellator tessellator = Tessellator.instance; + GL11.glLineWidth(1F); + tessellator.startDrawing(GL11.GL_LINES); + + double len = (double) -ClientTickHandler.ticksInGame / 100F + new Random(dir.ordinal() ^ tile.xCoord ^ tile.yCoord ^ tile.zCoord).nextInt(10000); + double add = vecMag.mag(); + double rand = Math.random() - 0.5; + for(int i = 0; i < stages; i++) { + addVertexAtWithTranslation(tessellator, dir, vecApply.x, vecApply.y, vecApply.z, rand, len); + rand = Math.random() - 0.5; + vecApply.add(vecMag); + len += add; + addVertexAtWithTranslation(tessellator, dir, vecApply.x, vecApply.y, vecApply.z, rand, len); + } + + tessellator.draw(); + + GL11.glPopMatrix(); + } + } + + private static void addVertexAtWithTranslation(Tessellator tess, ForgeDirection dir, double xpos, double ypos, double zpos, double rand, double l) { + double freq = 20; + double ampl = (0.15 * (Math.sin(l * 2F) * 0.5 + 0.5) + 0.1) * sizeAlpha; + double randMul = 0.05; + double x = xpos + Math.sin(l * freq) * ampl * Math.abs(Math.abs(dir.offsetX) - 1) + rand * randMul; + double y = ypos + Math.cos(l * freq) * ampl * Math.abs(Math.abs(dir.offsetY) - 1) + rand * randMul; + double z = zpos + (dir.offsetY == 0 ? Math.sin(l * freq) : Math.cos(l * freq)) * ampl * Math.abs(Math.abs(dir.offsetZ) - 1) + rand * randMul; + + tess.addVertex(x, y, z); + } + } diff --git a/src/main/java/vazkii/botania/client/core/handler/SubTileRadiusRenderHandler.java b/src/main/java/vazkii/botania/client/core/handler/SubTileRadiusRenderHandler.java index 5bc5f7cc61..ca13332237 100644 --- a/src/main/java/vazkii/botania/client/core/handler/SubTileRadiusRenderHandler.java +++ b/src/main/java/vazkii/botania/client/core/handler/SubTileRadiusRenderHandler.java @@ -2,16 +2,16 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Mar 31, 2015, 3:16:02 PM (GMT)] */ package vazkii.botania.client.core.handler; -import cpw.mods.fml.common.eventhandler.SubscribeEvent; import java.awt.Color; + import net.minecraft.client.Minecraft; import net.minecraft.client.renderer.Tessellator; import net.minecraft.client.renderer.entity.RenderManager; @@ -21,141 +21,147 @@ import net.minecraft.util.ChunkCoordinates; import net.minecraft.util.MovingObjectPosition; import net.minecraftforge.client.event.RenderWorldLastEvent; + import org.lwjgl.opengl.GL11; + import vazkii.botania.api.subtile.ISubTileContainer; import vazkii.botania.api.subtile.RadiusDescriptor; import vazkii.botania.api.subtile.SubTileEntity; import vazkii.botania.common.Botania; import vazkii.botania.common.item.ItemTwigWand; import vazkii.botania.common.item.ModItems; +import cpw.mods.fml.common.eventhandler.SubscribeEvent; public final class SubTileRadiusRenderHandler { - @SubscribeEvent - public void onWorldRenderLast(RenderWorldLastEvent event) { - Minecraft mc = Minecraft.getMinecraft(); - MovingObjectPosition pos = mc.objectMouseOver; - - if (!Botania.proxy.isClientPlayerWearingMonocle() || pos == null || pos.entityHit != null) return; - int x = pos.blockX; - int y = pos.blockY; - int z = pos.blockZ; - - ItemStack stackHeld = mc.thePlayer.getCurrentEquippedItem(); - if (stackHeld != null && stackHeld.getItem() == ModItems.twigWand && ItemTwigWand.getBindMode(stackHeld)) { - ChunkCoordinates coords = ItemTwigWand.getBoundTile(stackHeld); - if (coords.posY != -1) { - x = coords.posX; - y = coords.posY; - z = coords.posZ; - } - } - - TileEntity tile = mc.theWorld.getTileEntity(x, y, z); - if (tile == null || !(tile instanceof ISubTileContainer)) return; - ISubTileContainer container = (ISubTileContainer) tile; - SubTileEntity subtile = container.getSubTile(); - if (subtile == null) return; - RadiusDescriptor descriptor = subtile.getRadius(); - if (descriptor == null) return; - - GL11.glPushMatrix(); - GL11.glDisable(GL11.GL_TEXTURE_2D); - GL11.glPushAttrib(GL11.GL_LIGHTING); - GL11.glDisable(GL11.GL_LIGHTING); - GL11.glEnable(GL11.GL_BLEND); - GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); - Tessellator.renderingWorldRenderer = false; - - if (descriptor.isCircle()) renderCircle(descriptor.getSubtileCoords(), descriptor.getCircleRadius()); - else renderRectangle(descriptor.getAABB()); - - GL11.glEnable(GL11.GL_TEXTURE_2D); - GL11.glDisable(GL11.GL_BLEND); - GL11.glPopAttrib(); - GL11.glPopMatrix(); - } - - public void renderRectangle(AxisAlignedBB aabb) { - GL11.glPushMatrix(); - GL11.glTranslated( - aabb.minX - RenderManager.renderPosX, - aabb.minY - RenderManager.renderPosY, - aabb.minZ - RenderManager.renderPosZ); - int color = Color.HSBtoRGB(ClientTickHandler.ticksInGame % 200 / 200F, 0.6F, 1F); - - Color colorRGB = new Color(color); - GL11.glColor4ub((byte) colorRGB.getRed(), (byte) colorRGB.getGreen(), (byte) colorRGB.getBlue(), (byte) 32); - - double f = 1F / 16F; - double x = aabb.maxX - aabb.minX - f; - double z = aabb.maxZ - aabb.minZ - f; - - Tessellator tessellator = Tessellator.instance; - tessellator.startDrawingQuads(); - tessellator.addVertex(x, f, f); - tessellator.addVertex(f, f, f); - tessellator.addVertex(f, f, z); - tessellator.addVertex(x, f, z); - tessellator.draw(); - - x += f; - z += f; - double f1 = f + f / 4F; - GL11.glColor4ub((byte) colorRGB.getRed(), (byte) colorRGB.getGreen(), (byte) colorRGB.getBlue(), (byte) 64); - tessellator.startDrawingQuads(); - tessellator.addVertex(x, f1, 0); - tessellator.addVertex(0, f1, 0); - tessellator.addVertex(0, f1, z); - tessellator.addVertex(x, f1, z); - tessellator.draw(); - - GL11.glPopMatrix(); - } - - public void renderCircle(ChunkCoordinates center, double radius) { - GL11.glPushMatrix(); - double x = center.posX + 0.5; - double y = center.posY; - double z = center.posZ + 0.5; - GL11.glTranslated(x - RenderManager.renderPosX, y - RenderManager.renderPosY, z - RenderManager.renderPosZ); - int color = Color.HSBtoRGB(ClientTickHandler.ticksInGame % 200 / 200F, 0.6F, 1F); - - Color colorRGB = new Color(color); - GL11.glColor4ub((byte) colorRGB.getRed(), (byte) colorRGB.getGreen(), (byte) colorRGB.getBlue(), (byte) 32); - - double f = 1F / 16F; - - int totalAngles = 360; - int drawAngles = 360; - int step = totalAngles / drawAngles; - - radius -= f; - Tessellator tessellator = Tessellator.instance; - tessellator.startDrawing(GL11.GL_TRIANGLE_FAN); - tessellator.addVertex(0, f, 0); - for (int i = 0; i < totalAngles + 1; i += step) { - double rad = (totalAngles - i) * Math.PI / 180.0; - double xp = Math.cos(rad) * radius; - double zp = Math.sin(rad) * radius; - tessellator.addVertex(xp, f, zp); - } - tessellator.addVertex(0, f, 0); - tessellator.draw(); - - radius += f; - double f1 = f + f / 4F; - GL11.glColor4ub((byte) colorRGB.getRed(), (byte) colorRGB.getGreen(), (byte) colorRGB.getBlue(), (byte) 64); - tessellator.startDrawing(GL11.GL_TRIANGLE_FAN); - tessellator.addVertex(0, f1, 0); - for (int i = 0; i < totalAngles + 1; i += step) { - double rad = (totalAngles - i) * Math.PI / 180.0; - double xp = Math.cos(rad) * radius; - double zp = Math.sin(rad) * radius; - tessellator.addVertex(xp, f1, zp); - } - tessellator.addVertex(0, f1, 0); - tessellator.draw(); - GL11.glPopMatrix(); - } + @SubscribeEvent + public void onWorldRenderLast(RenderWorldLastEvent event) { + Minecraft mc = Minecraft.getMinecraft(); + MovingObjectPosition pos = mc.objectMouseOver; + + if(!Botania.proxy.isClientPlayerWearingMonocle() || pos == null || pos.entityHit != null) + return; + int x = pos.blockX; + int y = pos.blockY; + int z = pos.blockZ; + + ItemStack stackHeld = mc.thePlayer.getCurrentEquippedItem(); + if(stackHeld != null && stackHeld.getItem() == ModItems.twigWand && ItemTwigWand.getBindMode(stackHeld)) { + ChunkCoordinates coords = ItemTwigWand.getBoundTile(stackHeld); + if(coords.posY != -1) { + x = coords.posX; + y = coords.posY; + z = coords.posZ; + } + } + + TileEntity tile = mc.theWorld.getTileEntity(x, y, z); + if(tile == null || !(tile instanceof ISubTileContainer)) + return; + ISubTileContainer container = (ISubTileContainer) tile; + SubTileEntity subtile = container.getSubTile(); + if(subtile == null) + return; + RadiusDescriptor descriptor = subtile.getRadius(); + if(descriptor == null) + return; + + GL11.glPushMatrix(); + GL11.glDisable(GL11.GL_TEXTURE_2D); + GL11.glPushAttrib(GL11.GL_LIGHTING); + GL11.glDisable(GL11.GL_LIGHTING); + GL11.glEnable(GL11.GL_BLEND); + GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); + Tessellator.renderingWorldRenderer = false; + + if(descriptor.isCircle()) + renderCircle(descriptor.getSubtileCoords(), descriptor.getCircleRadius()); + else renderRectangle(descriptor.getAABB()); + + GL11.glEnable(GL11.GL_TEXTURE_2D); + GL11.glDisable(GL11.GL_BLEND); + GL11.glPopAttrib(); + GL11.glPopMatrix(); + } + + public void renderRectangle(AxisAlignedBB aabb) { + GL11.glPushMatrix(); + GL11.glTranslated(aabb.minX - RenderManager.renderPosX, aabb.minY - RenderManager.renderPosY, aabb.minZ - RenderManager.renderPosZ); + int color = Color.HSBtoRGB(ClientTickHandler.ticksInGame % 200 / 200F, 0.6F, 1F); + + Color colorRGB = new Color(color); + GL11.glColor4ub((byte) colorRGB.getRed(), (byte) colorRGB.getGreen(), (byte) colorRGB.getBlue(), (byte) 32); + + double f = 1F / 16F; + double x = aabb.maxX - aabb.minX - f; + double z = aabb.maxZ - aabb.minZ - f; + + Tessellator tessellator = Tessellator.instance; + tessellator.startDrawingQuads(); + tessellator.addVertex(x, f, f); + tessellator.addVertex(f, f, f); + tessellator.addVertex(f, f, z); + tessellator.addVertex(x, f, z); + tessellator.draw(); + + x += f; + z += f; + double f1 = f + f / 4F; + GL11.glColor4ub((byte) colorRGB.getRed(), (byte) colorRGB.getGreen(), (byte) colorRGB.getBlue(), (byte) 64); + tessellator.startDrawingQuads(); + tessellator.addVertex(x, f1, 0); + tessellator.addVertex(0, f1, 0); + tessellator.addVertex(0, f1, z); + tessellator.addVertex(x, f1, z); + tessellator.draw(); + + GL11.glPopMatrix(); + } + + public void renderCircle(ChunkCoordinates center, double radius) { + GL11.glPushMatrix(); + double x = center.posX + 0.5; + double y = center.posY; + double z = center.posZ + 0.5; + GL11.glTranslated(x - RenderManager.renderPosX, y - RenderManager.renderPosY, z - RenderManager.renderPosZ); + int color = Color.HSBtoRGB(ClientTickHandler.ticksInGame % 200 / 200F, 0.6F, 1F); + + Color colorRGB = new Color(color); + GL11.glColor4ub((byte) colorRGB.getRed(), (byte) colorRGB.getGreen(), (byte) colorRGB.getBlue(), (byte) 32); + + double f = 1F / 16F; + + int totalAngles = 360; + int drawAngles = 360; + int step = totalAngles / drawAngles; + + radius -= f; + Tessellator tessellator = Tessellator.instance; + tessellator.startDrawing(GL11.GL_TRIANGLE_FAN); + tessellator.addVertex(0, f, 0); + for(int i = 0; i < totalAngles + 1; i += step) { + double rad = (totalAngles - i) * Math.PI / 180.0; + double xp = Math.cos(rad) * radius; + double zp = Math.sin(rad) * radius; + tessellator.addVertex(xp, f, zp); + } + tessellator.addVertex(0, f, 0); + tessellator.draw(); + + radius += f; + double f1 = f + f / 4F; + GL11.glColor4ub((byte) colorRGB.getRed(), (byte) colorRGB.getGreen(), (byte) colorRGB.getBlue(), (byte) 64); + tessellator.startDrawing(GL11.GL_TRIANGLE_FAN); + tessellator.addVertex(0, f1, 0); + for(int i = 0; i < totalAngles + 1; i += step) { + double rad = (totalAngles - i) * Math.PI / 180.0; + double xp = Math.cos(rad) * radius; + double zp = Math.sin(rad) * radius; + tessellator.addVertex(xp, f1, zp); + } + tessellator.addVertex(0, f1, 0); + tessellator.draw(); + GL11.glPopMatrix(); + } + } diff --git a/src/main/java/vazkii/botania/client/core/handler/TooltipAdditionDisplayHandler.java b/src/main/java/vazkii/botania/client/core/handler/TooltipAdditionDisplayHandler.java index 5b3c789ac0..e7e7b8337a 100644 --- a/src/main/java/vazkii/botania/client/core/handler/TooltipAdditionDisplayHandler.java +++ b/src/main/java/vazkii/botania/client/core/handler/TooltipAdditionDisplayHandler.java @@ -2,18 +2,18 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Apr 23, 2015, 4:24:56 PM (GMT)] */ package vazkii.botania.client.core.handler; -import cpw.mods.fml.relauncher.ReflectionHelper; import java.awt.Color; import java.util.ArrayList; import java.util.List; + import net.minecraft.client.Minecraft; import net.minecraft.client.gui.FontRenderer; import net.minecraft.client.gui.Gui; @@ -26,8 +26,10 @@ import net.minecraft.item.ItemStack; import net.minecraft.util.EnumChatFormatting; import net.minecraft.util.StatCollector; + import org.lwjgl.input.Mouse; import org.lwjgl.opengl.GL11; + import vazkii.botania.api.lexicon.ILexicon; import vazkii.botania.api.lexicon.LexiconRecipeMappings; import vazkii.botania.api.lexicon.LexiconRecipeMappings.EntryData; @@ -38,223 +40,171 @@ import vazkii.botania.common.item.ModItems; import vazkii.botania.common.item.equipment.tool.terrasteel.ItemTerraPick; import vazkii.botania.common.lib.LibObfuscation; +import cpw.mods.fml.relauncher.ReflectionHelper; public final class TooltipAdditionDisplayHandler { - private static float lexiconLookupTime = 0F; - - public static void render() { - Minecraft mc = Minecraft.getMinecraft(); - GuiScreen gui = mc.currentScreen; - if (gui != null - && gui instanceof GuiContainer - && mc.thePlayer != null - && mc.thePlayer.inventory.getItemStack() == null) { - GuiContainer container = (GuiContainer) gui; - Slot slot = ReflectionHelper.getPrivateValue(GuiContainer.class, container, LibObfuscation.THE_SLOT); - if (slot != null && slot.getHasStack()) { - ItemStack stack = slot.getStack(); - if (stack != null) { - ScaledResolution res = new ScaledResolution(mc, mc.displayWidth, mc.displayHeight); - FontRenderer font = mc.fontRenderer; - int mouseX = Mouse.getX() * res.getScaledWidth() / mc.displayWidth; - int mouseY = res.getScaledHeight() - Mouse.getY() * res.getScaledHeight() / mc.displayHeight; - - List tooltip; - try { - tooltip = stack.getTooltip(mc.thePlayer, mc.gameSettings.advancedItemTooltips); - } catch (Exception e) { - tooltip = new ArrayList(); - } - int width = 0; - for (String s : tooltip) width = Math.max(width, font.getStringWidth(s) + 2); - int tooltipHeight = (tooltip.size() - 1) * 10 + 5; - - int height = 3; - int offx = 11; - int offy = 17; - - boolean offscreen = mouseX + width + 19 >= res.getScaledWidth(); - - int fixY = res.getScaledHeight() - (mouseY + tooltipHeight); - if (fixY < 0) offy -= fixY; - if (offscreen) offx = -13 - width; - - if (stack.getItem() instanceof ItemTerraPick) - drawTerraPick(stack, mouseX, mouseY, offx, offy, width, height, font); - else if (stack.getItem() instanceof IManaTooltipDisplay) - drawManaBar( - stack, - (IManaTooltipDisplay) stack.getItem(), - mouseX, - mouseY, - offx, - offy, - width, - height); - - EntryData data = LexiconRecipeMappings.getDataForStack(stack); - if (data != null) { - int lexSlot = -1; - ItemStack lexiconStack = null; - - for (int i = 0; i < InventoryPlayer.getHotbarSize(); i++) { - ItemStack stackAt = mc.thePlayer.inventory.getStackInSlot(i); - if (stackAt != null - && stackAt.getItem() instanceof ILexicon - && ((ILexicon) stackAt.getItem()) - .isKnowledgeUnlocked(stackAt, data.entry.getKnowledgeType())) { - lexiconStack = stackAt; - lexSlot = i; - break; - } - } - - if (lexSlot > -1) { - int x = mouseX + offx - 34; - int y = mouseY - offy; - GL11.glDisable(GL11.GL_DEPTH_TEST); - - Gui.drawRect(x - 4, y - 4, x + 20, y + 26, 0x44000000); - Gui.drawRect(x - 6, y - 6, x + 22, y + 28, 0x44000000); - - if (ConfigHandler.useShiftForQuickLookup - ? GuiScreen.isShiftKeyDown() - : GuiScreen.isCtrlKeyDown()) { - lexiconLookupTime += ClientTickHandler.delta; - - int cx = x + 8; - int cy = y + 8; - float r = 12; - float time = 20F; - float angles = lexiconLookupTime / time * 360F; - - GL11.glDisable(GL11.GL_LIGHTING); - GL11.glDisable(GL11.GL_TEXTURE_2D); - GL11.glShadeModel(GL11.GL_SMOOTH); - GL11.glEnable(GL11.GL_BLEND); - GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); - GL11.glBegin(GL11.GL_TRIANGLE_FAN); - - float a = 0.5F - + 0.2F - * ((float) Math.cos((double) (ClientTickHandler.ticksInGame - + ClientTickHandler.partialTicks) - / 10) - * 0.5F - + 0.5F); - GL11.glColor4f(0F, 0.5F, 0F, a); - GL11.glVertex2i(cx, cy); - GL11.glColor4f(0F, 1F, 0F, 1F); - - for (float i = angles; i > 0; i--) { - double rad = (i - 90) / 180F * Math.PI; - GL11.glVertex2d(cx + Math.cos(rad) * r, cy + Math.sin(rad) * r); - } - GL11.glVertex2i(cx, cy); - GL11.glEnd(); - - GL11.glDisable(GL11.GL_BLEND); - GL11.glEnable(GL11.GL_TEXTURE_2D); - GL11.glShadeModel(GL11.GL_FLAT); - - if (lexiconLookupTime >= time) { - mc.thePlayer.inventory.currentItem = lexSlot; - Botania.proxy.setEntryToOpen(data.entry); - Botania.proxy.setLexiconStack(lexiconStack); - mc.thePlayer.closeScreen(); - ItemLexicon.openBook(mc.thePlayer, lexiconStack, mc.theWorld, false); - } - } else lexiconLookupTime = 0F; - - RenderItem.getInstance() - .renderItemIntoGUI( - mc.fontRenderer, mc.renderEngine, new ItemStack(ModItems.lexicon), x, y); - GL11.glDisable(GL11.GL_LIGHTING); - - font.drawStringWithShadow("?", x + 10, y + 8, 0xFFFFFFFF); - GL11.glScalef(0.5F, 0.5F, 1F); - boolean mac = Minecraft.isRunningOnMac; - mc.fontRenderer.drawStringWithShadow( - EnumChatFormatting.BOLD - + (ConfigHandler.useShiftForQuickLookup ? "Shift" : mac ? "Cmd" : "Ctrl"), - (x + 10) * 2 - 16, - (y + 8) * 2 + 20, - 0xFFFFFFFF); - GL11.glScalef(2F, 2F, 1F); - - GL11.glEnable(GL11.GL_DEPTH_TEST); - } else lexiconLookupTime = 0F; - } else lexiconLookupTime = 0F; - } else lexiconLookupTime = 0F; - } else lexiconLookupTime = 0F; - } else lexiconLookupTime = 0F; - } - - private static void drawTerraPick( - ItemStack stack, int mouseX, int mouseY, int offx, int offy, int width, int height, FontRenderer font) { - int level = ItemTerraPick.getLevel(stack); - int max = ItemTerraPick.LEVELS[Math.min(ItemTerraPick.LEVELS.length - 1, level + 1)]; - boolean ss = level >= ItemTerraPick.LEVELS.length - 1; - int curr = ItemTerraPick.getMana_(stack); - float percent = level == 0 ? 0F : (float) curr / (float) max; - int rainbowWidth = Math.min(width - (ss ? 0 : 1), (int) (width * percent)); - float huePer = width == 0 ? 0F : 1F / width; - float hueOff = (ClientTickHandler.ticksInGame + ClientTickHandler.partialTicks) * 0.01F; - - GL11.glDisable(GL11.GL_DEPTH_TEST); - Gui.drawRect( - mouseX + offx - 1, mouseY - offy - height - 1, mouseX + offx + width + 1, mouseY - offy, 0xFF000000); - for (int i = 0; i < rainbowWidth; i++) - Gui.drawRect( - mouseX + offx + i, - mouseY - offy - height, - mouseX + offx + i + 1, - mouseY - offy, - Color.HSBtoRGB(hueOff + huePer * i, 1F, 1F)); - Gui.drawRect( - mouseX + offx + rainbowWidth, mouseY - offy - height, mouseX + offx + width, mouseY - offy, 0xFF555555); - - String rank = StatCollector.translateToLocal("botania.rank" + level).replaceAll("&", "\u00a7"); - GL11.glPushAttrib(GL11.GL_LIGHTING); - GL11.glDisable(GL11.GL_LIGHTING); - font.drawStringWithShadow(rank, mouseX + offx, mouseY - offy - 12, 0xFFFFFF); - if (!ss) { - rank = StatCollector.translateToLocal("botania.rank" + (level + 1)).replaceAll("&", "\u00a7"); - font.drawStringWithShadow( - rank, mouseX + offx + width - font.getStringWidth(rank), mouseY - offy - 12, 0xFFFFFF); - } - GL11.glEnable(GL11.GL_DEPTH_TEST); - GL11.glPopAttrib(); - } - - private static void drawManaBar( - ItemStack stack, - IManaTooltipDisplay display, - int mouseX, - int mouseY, - int offx, - int offy, - int width, - int height) { - float fraction = display.getManaFractionForDisplay(stack); - int manaBarWidth = (int) Math.ceil(width * fraction); - - GL11.glDisable(GL11.GL_DEPTH_TEST); - Gui.drawRect( - mouseX + offx - 1, mouseY - offy - height - 1, mouseX + offx + width + 1, mouseY - offy, 0xFF000000); - Gui.drawRect( - mouseX + offx, - mouseY - offy - height, - mouseX + offx + manaBarWidth, - mouseY - offy, - Color.HSBtoRGB( - 0.528F, - ((float) Math.sin((ClientTickHandler.ticksInGame + ClientTickHandler.partialTicks) * 0.2) + 1F) - * 0.3F - + 0.4F, - 1F)); - Gui.drawRect( - mouseX + offx + manaBarWidth, mouseY - offy - height, mouseX + offx + width, mouseY - offy, 0xFF555555); - } + private static float lexiconLookupTime = 0F; + + public static void render() { + Minecraft mc = Minecraft.getMinecraft(); + GuiScreen gui = mc.currentScreen; + if(gui != null && gui instanceof GuiContainer && mc.thePlayer != null && mc.thePlayer.inventory.getItemStack() == null) { + GuiContainer container = (GuiContainer) gui; + Slot slot = ReflectionHelper.getPrivateValue(GuiContainer.class, container, LibObfuscation.THE_SLOT); + if(slot != null && slot.getHasStack()) { + ItemStack stack = slot.getStack(); + if(stack != null) { + ScaledResolution res = new ScaledResolution(mc, mc.displayWidth, mc.displayHeight); + FontRenderer font = mc.fontRenderer; + int mouseX = Mouse.getX() * res.getScaledWidth() / mc.displayWidth; + int mouseY = res.getScaledHeight() - Mouse.getY() * res.getScaledHeight() / mc.displayHeight; + + List tooltip; + try { + tooltip = stack.getTooltip(mc.thePlayer, mc.gameSettings.advancedItemTooltips); + } catch(Exception e) { + tooltip = new ArrayList(); + } + int width = 0; + for(String s : tooltip) + width = Math.max(width, font.getStringWidth(s) + 2); + int tooltipHeight = (tooltip.size() - 1) * 10 + 5; + + int height = 3; + int offx = 11; + int offy = 17; + + boolean offscreen = mouseX + width + 19 >= res.getScaledWidth(); + + int fixY = res.getScaledHeight() - (mouseY + tooltipHeight); + if(fixY < 0) + offy -= fixY; + if(offscreen) + offx = -13 - width; + + if(stack.getItem() instanceof ItemTerraPick) + drawTerraPick(stack, mouseX, mouseY, offx, offy, width, height, font); + else if(stack.getItem() instanceof IManaTooltipDisplay) + drawManaBar(stack, (IManaTooltipDisplay) stack.getItem(), mouseX, mouseY, offx, offy, width, height); + + EntryData data = LexiconRecipeMappings.getDataForStack(stack); + if(data != null) { + int lexSlot = -1; + ItemStack lexiconStack = null; + + for(int i = 0; i < InventoryPlayer.getHotbarSize(); i++) { + ItemStack stackAt = mc.thePlayer.inventory.getStackInSlot(i); + if(stackAt != null && stackAt.getItem() instanceof ILexicon && ((ILexicon) stackAt.getItem()).isKnowledgeUnlocked(stackAt, data.entry.getKnowledgeType())) { + lexiconStack = stackAt; + lexSlot = i; + break; + } + } + + if(lexSlot > -1) { + int x = mouseX + offx - 34; + int y = mouseY - offy; + GL11.glDisable(GL11.GL_DEPTH_TEST); + + Gui.drawRect(x - 4, y - 4, x + 20, y + 26, 0x44000000); + Gui.drawRect(x - 6, y - 6, x + 22, y + 28, 0x44000000); + + if(ConfigHandler.useShiftForQuickLookup ? GuiScreen.isShiftKeyDown() : GuiScreen.isCtrlKeyDown()) { + lexiconLookupTime += ClientTickHandler.delta; + + int cx = x + 8; + int cy = y + 8; + float r = 12; + float time = 20F; + float angles = lexiconLookupTime / time * 360F; + + GL11.glDisable(GL11.GL_LIGHTING); + GL11.glDisable(GL11.GL_TEXTURE_2D); + GL11.glShadeModel(GL11.GL_SMOOTH); + GL11.glEnable(GL11.GL_BLEND); + GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); + GL11.glBegin(GL11.GL_TRIANGLE_FAN); + + float a = 0.5F + 0.2F * ((float) Math.cos((double) (ClientTickHandler.ticksInGame + ClientTickHandler.partialTicks) / 10) * 0.5F + 0.5F); + GL11.glColor4f(0F, 0.5F, 0F, a); + GL11.glVertex2i(cx, cy); + GL11.glColor4f(0F, 1F, 0F, 1F); + + for(float i = angles; i > 0; i--) { + double rad = (i - 90) / 180F * Math.PI; + GL11.glVertex2d(cx + Math.cos(rad) * r, cy + Math.sin(rad) * r); + } + GL11.glVertex2i(cx, cy); + GL11.glEnd(); + + GL11.glDisable(GL11.GL_BLEND); + GL11.glEnable(GL11.GL_TEXTURE_2D); + GL11.glShadeModel(GL11.GL_FLAT); + + if(lexiconLookupTime >= time) { + mc.thePlayer.inventory.currentItem = lexSlot; + Botania.proxy.setEntryToOpen(data.entry); + Botania.proxy.setLexiconStack(lexiconStack); + mc.thePlayer.closeScreen(); + ItemLexicon.openBook(mc.thePlayer, lexiconStack, mc.theWorld, false); + + } + } else lexiconLookupTime = 0F; + + RenderItem.getInstance().renderItemIntoGUI(mc.fontRenderer, mc.renderEngine, new ItemStack(ModItems.lexicon), x, y); + GL11.glDisable(GL11.GL_LIGHTING); + + font.drawStringWithShadow("?", x + 10, y + 8, 0xFFFFFFFF); + GL11.glScalef(0.5F, 0.5F, 1F); + boolean mac = Minecraft.isRunningOnMac; + mc.fontRenderer.drawStringWithShadow(EnumChatFormatting.BOLD + (ConfigHandler.useShiftForQuickLookup ? "Shift" : mac ? "Cmd" : "Ctrl"), (x + 10) * 2 - 16, (y + 8) * 2 + 20, 0xFFFFFFFF); + GL11.glScalef(2F, 2F, 1F); + + GL11.glEnable(GL11.GL_DEPTH_TEST); + } else lexiconLookupTime = 0F; + } else lexiconLookupTime = 0F; + } else lexiconLookupTime = 0F; + } else lexiconLookupTime = 0F; + } else lexiconLookupTime = 0F; + } + + private static void drawTerraPick(ItemStack stack, int mouseX, int mouseY, int offx, int offy, int width, int height, FontRenderer font) { + int level = ItemTerraPick.getLevel(stack); + int max = ItemTerraPick.LEVELS[Math.min(ItemTerraPick.LEVELS.length - 1, level + 1)]; + boolean ss = level >= ItemTerraPick.LEVELS.length - 1; + int curr = ItemTerraPick.getMana_(stack); + float percent = level == 0 ? 0F : (float) curr / (float) max; + int rainbowWidth = Math.min(width - (ss ? 0 : 1), (int) (width * percent)); + float huePer = width == 0 ? 0F : 1F / width; + float hueOff = (ClientTickHandler.ticksInGame + ClientTickHandler.partialTicks) * 0.01F; + + GL11.glDisable(GL11.GL_DEPTH_TEST); + Gui.drawRect(mouseX + offx - 1, mouseY - offy - height - 1, mouseX + offx + width + 1, mouseY - offy, 0xFF000000); + for(int i = 0; i < rainbowWidth; i++) + Gui.drawRect(mouseX + offx + i, mouseY - offy - height, mouseX + offx + i + 1, mouseY - offy, Color.HSBtoRGB(hueOff + huePer * i, 1F, 1F)); + Gui.drawRect(mouseX + offx + rainbowWidth, mouseY - offy - height, mouseX + offx + width, mouseY - offy, 0xFF555555); + + String rank = StatCollector.translateToLocal("botania.rank" + level).replaceAll("&", "\u00a7"); + GL11.glPushAttrib(GL11.GL_LIGHTING); + GL11.glDisable(GL11.GL_LIGHTING); + font.drawStringWithShadow(rank, mouseX + offx, mouseY - offy - 12, 0xFFFFFF); + if(!ss) { + rank = StatCollector.translateToLocal("botania.rank" + (level + 1)).replaceAll("&", "\u00a7"); + font.drawStringWithShadow(rank, mouseX + offx + width - font.getStringWidth(rank), mouseY - offy - 12, 0xFFFFFF); + } + GL11.glEnable(GL11.GL_DEPTH_TEST); + GL11.glPopAttrib(); + } + + private static void drawManaBar(ItemStack stack, IManaTooltipDisplay display, int mouseX, int mouseY, int offx, int offy, int width, int height) { + float fraction = display.getManaFractionForDisplay(stack); + int manaBarWidth = (int) Math.ceil(width * fraction); + + GL11.glDisable(GL11.GL_DEPTH_TEST); + Gui.drawRect(mouseX + offx - 1, mouseY - offy - height - 1, mouseX + offx + width + 1, mouseY - offy, 0xFF000000); + Gui.drawRect(mouseX + offx, mouseY - offy - height, mouseX + offx + manaBarWidth, mouseY - offy, Color.HSBtoRGB(0.528F, ((float) Math.sin((ClientTickHandler.ticksInGame + ClientTickHandler.partialTicks) * 0.2) + 1F) * 0.3F + 0.4F, 1F)); + Gui.drawRect(mouseX + offx + manaBarWidth, mouseY - offy - height, mouseX + offx + width, mouseY - offy, 0xFF555555); + } + } diff --git a/src/main/java/vazkii/botania/client/core/handler/TooltipHandler.java b/src/main/java/vazkii/botania/client/core/handler/TooltipHandler.java index f336d34fed..6d1ae432e8 100644 --- a/src/main/java/vazkii/botania/client/core/handler/TooltipHandler.java +++ b/src/main/java/vazkii/botania/client/core/handler/TooltipHandler.java @@ -2,16 +2,14 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jul 26, 2014, 2:33:04 AM (GMT)] */ package vazkii.botania.client.core.handler; -import cpw.mods.fml.common.eventhandler.EventPriority; -import cpw.mods.fml.common.eventhandler.SubscribeEvent; import net.minecraft.init.Blocks; import net.minecraft.item.Item; import net.minecraft.util.StatCollector; @@ -19,23 +17,23 @@ import vazkii.botania.common.core.helper.ItemNBTHelper; import vazkii.botania.common.item.ItemKeepIvy; import vazkii.botania.common.item.ItemRegenIvy; +import cpw.mods.fml.common.eventhandler.EventPriority; +import cpw.mods.fml.common.eventhandler.SubscribeEvent; public final class TooltipHandler { - @SubscribeEvent(priority = EventPriority.HIGHEST) - public void onTooltipEvent(ItemTooltipEvent event) { - if (event.itemStack.getItem() == Item.getItemFromBlock(Blocks.dirt) && event.itemStack.getItemDamage() == 1) { - event.toolTip.add(StatCollector.translateToLocal("botaniamisc.coarseDirt0")); - event.toolTip.add(StatCollector.translateToLocal("botaniamisc.coarseDirt1")); - } else if (event.itemStack.getItem() == Item.getItemFromBlock(Blocks.mob_spawner) - && event.entityPlayer.capabilities.isCreativeMode) - event.toolTip.add(StatCollector.translateToLocal("botaniamisc.spawnerTip")); + @SubscribeEvent(priority = EventPriority.HIGHEST) + public void onTooltipEvent(ItemTooltipEvent event) { + if(event.itemStack.getItem() == Item.getItemFromBlock(Blocks.dirt) && event.itemStack.getItemDamage() == 1) { + event.toolTip.add(StatCollector.translateToLocal("botaniamisc.coarseDirt0")); + event.toolTip.add(StatCollector.translateToLocal("botaniamisc.coarseDirt1")); + } else if(event.itemStack.getItem() == Item.getItemFromBlock(Blocks.mob_spawner) && event.entityPlayer.capabilities.isCreativeMode) + event.toolTip.add(StatCollector.translateToLocal("botaniamisc.spawnerTip")); + + if(ItemNBTHelper.detectNBT(event.itemStack) && ItemNBTHelper.getBoolean(event.itemStack, ItemRegenIvy.TAG_REGEN, false)) + event.toolTip.add(StatCollector.translateToLocal("botaniamisc.hasIvy")); + if(ItemNBTHelper.detectNBT(event.itemStack) && ItemNBTHelper.getBoolean(event.itemStack, ItemKeepIvy.TAG_KEEP, false)) + event.toolTip.add(StatCollector.translateToLocal("botaniamisc.hasKeepIvy")); + } - if (ItemNBTHelper.detectNBT(event.itemStack) - && ItemNBTHelper.getBoolean(event.itemStack, ItemRegenIvy.TAG_REGEN, false)) - event.toolTip.add(StatCollector.translateToLocal("botaniamisc.hasIvy")); - if (ItemNBTHelper.detectNBT(event.itemStack) - && ItemNBTHelper.getBoolean(event.itemStack, ItemKeepIvy.TAG_KEEP, false)) - event.toolTip.add(StatCollector.translateToLocal("botaniamisc.hasKeepIvy")); - } } diff --git a/src/main/java/vazkii/botania/client/core/helper/FontHelper.java b/src/main/java/vazkii/botania/client/core/helper/FontHelper.java index 8451abb2d0..e1f5ed5c01 100644 --- a/src/main/java/vazkii/botania/client/core/helper/FontHelper.java +++ b/src/main/java/vazkii/botania/client/core/helper/FontHelper.java @@ -2,38 +2,41 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jan 16, 2014, 5:30:52 PM (GMT)] */ package vazkii.botania.client.core.helper; public final class FontHelper { - public static boolean isFormatColor(char par0) { - return par0 >= 48 && par0 <= 57 || par0 >= 97 && par0 <= 102 || par0 >= 65 && par0 <= 70; - } + public static boolean isFormatColor(char par0) { + return par0 >= 48 && par0 <= 57 || par0 >= 97 && par0 <= 102 || par0 >= 65 && par0 <= 70; + } - public static boolean isFormatSpecial(char par0) { - return par0 >= 107 && par0 <= 111 || par0 >= 75 && par0 <= 79 || par0 == 114 || par0 == 82; - } + public static boolean isFormatSpecial(char par0) { + return par0 >= 107 && par0 <= 111 || par0 >= 75 && par0 <= 79 || par0 == 114 || par0 == 82; + } - public static String getFormatFromString(String par0Str) { - String s1 = ""; - int i = -1; - int j = par0Str.length(); + public static String getFormatFromString(String par0Str) { + String s1 = ""; + int i = -1; + int j = par0Str.length(); - while ((i = par0Str.indexOf(167, i + 1)) != -1) { - if (i < j - 1) { - char c0 = par0Str.charAt(i + 1); + while ((i = par0Str.indexOf(167, i + 1)) != -1) { + if (i < j - 1) { + char c0 = par0Str.charAt(i + 1); - if (isFormatColor(c0)) s1 = "\u00a7" + c0; - else if (isFormatSpecial(c0)) s1 = s1 + "\u00a7" + c0; - } - } + if (isFormatColor(c0)) + s1 = "\u00a7" + c0; + else if (isFormatSpecial(c0)) + s1 = s1 + "\u00a7" + c0; + } + } + + return s1; + } - return s1; - } } diff --git a/src/main/java/vazkii/botania/client/core/helper/IconHelper.java b/src/main/java/vazkii/botania/client/core/helper/IconHelper.java index 222f266b56..bf3c2304ba 100644 --- a/src/main/java/vazkii/botania/client/core/helper/IconHelper.java +++ b/src/main/java/vazkii/botania/client/core/helper/IconHelper.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jan 14, 2014, 5:28:21 PM (GMT)] */ package vazkii.botania.client.core.helper; @@ -18,43 +18,44 @@ public final class IconHelper { - public static IIcon forName(IIconRegister ir, String name) { - return ir.registerIcon(LibResources.PREFIX_MOD + name); - } + public static IIcon forName(IIconRegister ir, String name) { + return ir.registerIcon(LibResources.PREFIX_MOD + name); + } - public static IIcon forName(IIconRegister ir, String name, String dir) { - return ir.registerIcon(LibResources.PREFIX_MOD + dir + "/" + name); - } + public static IIcon forName(IIconRegister ir, String name, String dir) { + return ir.registerIcon(LibResources.PREFIX_MOD + dir + "/" + name); + } - public static IIcon forBlock(IIconRegister ir, Block block) { - return forName(ir, block.getUnlocalizedName().replaceAll("tile\\.", "")); - } + public static IIcon forBlock(IIconRegister ir, Block block) { + return forName(ir, block.getUnlocalizedName().replaceAll("tile\\.", "")); + } - public static IIcon forBlock(IIconRegister ir, Block block, int i) { - return forBlock(ir, block, Integer.toString(i)); - } + public static IIcon forBlock(IIconRegister ir, Block block, int i) { + return forBlock(ir, block, Integer.toString(i)); + } - public static IIcon forBlock(IIconRegister ir, Block block, int i, String dir) { - return forBlock(ir, block, Integer.toString(i), dir); - } + public static IIcon forBlock(IIconRegister ir, Block block, int i, String dir) { + return forBlock(ir, block, Integer.toString(i), dir); + } - public static IIcon forBlock(IIconRegister ir, Block block, String s) { - return forName(ir, block.getUnlocalizedName().replaceAll("tile\\.", "") + s); - } + public static IIcon forBlock(IIconRegister ir, Block block, String s) { + return forName(ir, block.getUnlocalizedName().replaceAll("tile\\.", "") + s); + } - public static IIcon forBlock(IIconRegister ir, Block block, String s, String dir) { - return forName(ir, block.getUnlocalizedName().replaceAll("tile\\.", "") + s, dir); - } + public static IIcon forBlock(IIconRegister ir, Block block, String s, String dir) { + return forName(ir, block.getUnlocalizedName().replaceAll("tile\\.", "") + s, dir); + } - public static IIcon forItem(IIconRegister ir, Item item) { - return forName(ir, item.getUnlocalizedName().replaceAll("item\\.", "")); - } + public static IIcon forItem(IIconRegister ir, Item item) { + return forName(ir, item.getUnlocalizedName().replaceAll("item\\.", "")); + } - public static IIcon forItem(IIconRegister ir, Item item, int i) { - return forItem(ir, item, Integer.toString(i)); - } + public static IIcon forItem(IIconRegister ir, Item item, int i) { + return forItem(ir, item, Integer.toString(i)); + } - public static IIcon forItem(IIconRegister ir, Item item, String s) { - return forName(ir, item.getUnlocalizedName().replaceAll("item\\.", "") + s); - } -} + public static IIcon forItem(IIconRegister ir, Item item, String s) { + return forName(ir, item.getUnlocalizedName().replaceAll("item\\.", "") + s); + } + +} \ No newline at end of file diff --git a/src/main/java/vazkii/botania/client/core/helper/RenderHelper.java b/src/main/java/vazkii/botania/client/core/helper/RenderHelper.java index db5e006862..ff177cbd1a 100644 --- a/src/main/java/vazkii/botania/client/core/helper/RenderHelper.java +++ b/src/main/java/vazkii/botania/client/core/helper/RenderHelper.java @@ -2,16 +2,17 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jan 19, 2014, 5:40:38 PM (GMT)] */ package vazkii.botania.client.core.helper; import java.util.List; import java.util.Random; + import net.minecraft.client.Minecraft; import net.minecraft.client.gui.FontRenderer; import net.minecraft.client.renderer.Tessellator; @@ -19,230 +20,233 @@ import net.minecraft.client.settings.KeyBinding; import net.minecraft.item.ItemStack; import net.minecraft.util.ResourceLocation; + import org.lwjgl.input.Keyboard; import org.lwjgl.opengl.GL11; + import vazkii.botania.client.core.handler.ClientTickHandler; import vazkii.botania.client.lib.LibResources; public final class RenderHelper { - public static void renderTooltip(int x, int y, List tooltipData) { - int color = 0x505000ff; - int color2 = 0xf0100010; - - renderTooltip(x, y, tooltipData, color, color2); - } - - public static void renderTooltipOrange(int x, int y, List tooltipData) { - int color = 0x50a06600; - int color2 = 0xf01e1200; - - renderTooltip(x, y, tooltipData, color, color2); - } - - public static void renderTooltipGreen(int x, int y, List tooltipData) { - int color = 0x5000a000; - int color2 = 0xf0001e00; - - renderTooltip(x, y, tooltipData, color, color2); - } - - public static void renderTooltip(int x, int y, List tooltipData, int color, int color2) { - boolean lighting = GL11.glGetBoolean(GL11.GL_LIGHTING); - if (lighting) net.minecraft.client.renderer.RenderHelper.disableStandardItemLighting(); - - if (!tooltipData.isEmpty()) { - int var5 = 0; - int var6; - int var7; - FontRenderer fontRenderer = Minecraft.getMinecraft().fontRenderer; - for (var6 = 0; var6 < tooltipData.size(); ++var6) { - var7 = fontRenderer.getStringWidth(tooltipData.get(var6)); - if (var7 > var5) var5 = var7; - } - var6 = x + 12; - var7 = y - 12; - int var9 = 8; - if (tooltipData.size() > 1) var9 += 2 + (tooltipData.size() - 1) * 10; - float z = 300F; - drawGradientRect(var6 - 3, var7 - 4, z, var6 + var5 + 3, var7 - 3, color2, color2); - drawGradientRect(var6 - 3, var7 + var9 + 3, z, var6 + var5 + 3, var7 + var9 + 4, color2, color2); - drawGradientRect(var6 - 3, var7 - 3, z, var6 + var5 + 3, var7 + var9 + 3, color2, color2); - drawGradientRect(var6 - 4, var7 - 3, z, var6 - 3, var7 + var9 + 3, color2, color2); - drawGradientRect(var6 + var5 + 3, var7 - 3, z, var6 + var5 + 4, var7 + var9 + 3, color2, color2); - int var12 = (color & 0xFFFFFF) >> 1 | color & -16777216; - drawGradientRect(var6 - 3, var7 - 3 + 1, z, var6 - 3 + 1, var7 + var9 + 3 - 1, color, var12); - drawGradientRect(var6 + var5 + 2, var7 - 3 + 1, z, var6 + var5 + 3, var7 + var9 + 3 - 1, color, var12); - drawGradientRect(var6 - 3, var7 - 3, z, var6 + var5 + 3, var7 - 3 + 1, color, color); - drawGradientRect(var6 - 3, var7 + var9 + 2, z, var6 + var5 + 3, var7 + var9 + 3, var12, var12); - - GL11.glDisable(GL11.GL_DEPTH_TEST); - for (int var13 = 0; var13 < tooltipData.size(); ++var13) { - String var14 = tooltipData.get(var13); - fontRenderer.drawStringWithShadow(var14, var6, var7, -1); - if (var13 == 0) var7 += 2; - var7 += 10; - } - GL11.glEnable(GL11.GL_DEPTH_TEST); - } - if (!lighting) net.minecraft.client.renderer.RenderHelper.disableStandardItemLighting(); - GL11.glColor4f(1F, 1F, 1F, 1F); - } - - public static void drawGradientRect(int par1, int par2, float z, int par3, int par4, int par5, int par6) { - float var7 = (par5 >> 24 & 255) / 255F; - float var8 = (par5 >> 16 & 255) / 255F; - float var9 = (par5 >> 8 & 255) / 255F; - float var10 = (par5 & 255) / 255F; - float var11 = (par6 >> 24 & 255) / 255F; - float var12 = (par6 >> 16 & 255) / 255F; - float var13 = (par6 >> 8 & 255) / 255F; - float var14 = (par6 & 255) / 255F; - GL11.glDisable(GL11.GL_TEXTURE_2D); - GL11.glEnable(GL11.GL_BLEND); - GL11.glDisable(GL11.GL_ALPHA_TEST); - GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); - GL11.glShadeModel(GL11.GL_SMOOTH); - Tessellator var15 = Tessellator.instance; - var15.startDrawingQuads(); - var15.setColorRGBA_F(var8, var9, var10, var7); - var15.addVertex(par3, par2, z); - var15.addVertex(par1, par2, z); - var15.setColorRGBA_F(var12, var13, var14, var11); - var15.addVertex(par1, par4, z); - var15.addVertex(par3, par4, z); - var15.draw(); - GL11.glShadeModel(GL11.GL_FLAT); - GL11.glDisable(GL11.GL_BLEND); - GL11.glEnable(GL11.GL_ALPHA_TEST); - GL11.glEnable(GL11.GL_TEXTURE_2D); - } - - public static void drawTexturedModalRect(int par1, int par2, float z, int par3, int par4, int par5, int par6) { - drawTexturedModalRect(par1, par2, z, par3, par4, par5, par6, 0.00390625F, 0.00390625F); - } - - public static void drawTexturedModalRect( - int par1, int par2, float z, int par3, int par4, int par5, int par6, float f, float f1) { - Tessellator tessellator = Tessellator.instance; - tessellator.startDrawingQuads(); - tessellator.addVertexWithUV(par1 + 0, par2 + par6, z, (par3 + 0) * f, (par4 + par6) * f1); - tessellator.addVertexWithUV(par1 + par5, par2 + par6, z, (par3 + par5) * f, (par4 + par6) * f1); - tessellator.addVertexWithUV(par1 + par5, par2 + 0, z, (par3 + par5) * f, (par4 + 0) * f1); - tessellator.addVertexWithUV(par1 + 0, par2 + 0, z, (par3 + 0) * f, (par4 + 0) * f1); - tessellator.draw(); - } - - public static void renderStar(int color, float xScale, float yScale, float zScale, long seed) { - Tessellator tessellator = Tessellator.instance; - - int ticks = ClientTickHandler.ticksInGame % 200; - if (ticks >= 100) ticks = 200 - ticks - 1; - - float f1 = ticks / 200F; - float f2 = 0F; - if (f1 > 0.7F) f2 = (f1 - 0.7F) / 0.2F; - Random random = new Random(seed); - - GL11.glPushMatrix(); - GL11.glDisable(GL11.GL_TEXTURE_2D); - GL11.glShadeModel(GL11.GL_SMOOTH); - GL11.glEnable(GL11.GL_BLEND); - GL11.glBlendFunc(770, 1); - GL11.glDisable(GL11.GL_ALPHA_TEST); - GL11.glEnable(GL11.GL_CULL_FACE); - GL11.glDepthMask(false); - GL11.glScalef(xScale, yScale, zScale); - - for (int i = 0; i < (f1 + f1 * f1) / 2F * 90F + 30F; i++) { - GL11.glRotatef(random.nextFloat() * 360F, 1F, 0F, 0F); - GL11.glRotatef(random.nextFloat() * 360F, 0F, 1F, 0F); - GL11.glRotatef(random.nextFloat() * 360F, 0F, 0F, 1F); - GL11.glRotatef(random.nextFloat() * 360F, 1F, 0F, 0F); - GL11.glRotatef(random.nextFloat() * 360F, 0F, 1F, 0F); - GL11.glRotatef(random.nextFloat() * 360F + f1 * 90F, 0F, 0F, 1F); - tessellator.startDrawing(GL11.GL_TRIANGLE_FAN); - float f3 = random.nextFloat() * 20F + 5F + f2 * 10F; - float f4 = random.nextFloat() * 2F + 1F + f2 * 2F; - tessellator.setColorRGBA_I(color, (int) (255F * (1F - f2))); - tessellator.addVertex(0, 0, 0); - tessellator.setColorRGBA_F(0F, 0F, 0F, 0); - tessellator.addVertex(-0.866D * f4, f3, -0.5F * f4); - tessellator.addVertex(0.866D * f4, f3, -0.5F * f4); - tessellator.addVertex(0, f3, 1F * f4); - tessellator.addVertex(-0.866D * f4, f3, -0.5F * f4); - tessellator.draw(); - } - - GL11.glDepthMask(true); - GL11.glDisable(GL11.GL_CULL_FACE); - GL11.glDisable(GL11.GL_BLEND); - GL11.glShadeModel(GL11.GL_FLAT); - GL11.glColor4f(1F, 1F, 1F, 1F); - GL11.glEnable(GL11.GL_TEXTURE_2D); - GL11.glEnable(GL11.GL_ALPHA_TEST); - GL11.glPopMatrix(); - } - - public static void renderProgressPie(int x, int y, float progress, ItemStack stack) { - Minecraft mc = Minecraft.getMinecraft(); - RenderItem.getInstance().renderItemAndEffectIntoGUI(mc.fontRenderer, mc.renderEngine, stack, x, y); - - GL11.glClear(GL11.GL_DEPTH_BUFFER_BIT); - GL11.glEnable(GL11.GL_STENCIL_TEST); - GL11.glColorMask(false, false, false, false); - GL11.glDepthMask(false); - GL11.glStencilFunc(GL11.GL_NEVER, 1, 0xFF); - GL11.glStencilOp(GL11.GL_REPLACE, GL11.GL_KEEP, GL11.GL_KEEP); - GL11.glStencilMask(0xFF); - RenderItem.getInstance().renderItemAndEffectIntoGUI(mc.fontRenderer, mc.renderEngine, stack, x, y); - - mc.renderEngine.bindTexture(new ResourceLocation(LibResources.GUI_MANA_HUD)); - int r = 10; - int centerX = x + 8; - int centerY = y + 8; - int degs = (int) (360 * progress); - float a = 0.5F - + 0.2F - * ((float) Math.cos((double) (ClientTickHandler.ticksInGame + ClientTickHandler.partialTicks) - / 10) - * 0.5F - + 0.5F); - - GL11.glDisable(GL11.GL_LIGHTING); - GL11.glDisable(GL11.GL_TEXTURE_2D); - GL11.glShadeModel(GL11.GL_SMOOTH); - GL11.glEnable(GL11.GL_BLEND); - GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); - GL11.glColorMask(true, true, true, true); - GL11.glDepthMask(true); - GL11.glStencilMask(0x00); - GL11.glStencilFunc(GL11.GL_EQUAL, 1, 0xFF); - GL11.glBegin(GL11.GL_TRIANGLE_FAN); - GL11.glColor4f(0F, 0.5F, 0.5F, a); - GL11.glVertex2i(centerX, centerY); - GL11.glColor4f(0F, 1F, 0.5F, a); - for (int i = degs; i > 0; i--) { - double rad = (i - 90) / 180F * Math.PI; - GL11.glVertex2d(centerX + Math.cos(rad) * r, centerY + Math.sin(rad) * r); - } - GL11.glVertex2i(centerX, centerY); - GL11.glEnd(); - GL11.glDisable(GL11.GL_BLEND); - GL11.glEnable(GL11.GL_TEXTURE_2D); - GL11.glShadeModel(GL11.GL_FLAT); - GL11.glDisable(GL11.GL_STENCIL_TEST); - } - - public static String getKeyDisplayString(String keyName) { - String key = null; - KeyBinding[] keys = Minecraft.getMinecraft().gameSettings.keyBindings; - for (KeyBinding otherKey : keys) - if (otherKey.getKeyDescription().equals(keyName)) { - key = Keyboard.getKeyName(otherKey.getKeyCode()); - break; - } - - return key; - } + public static void renderTooltip(int x, int y, List tooltipData) { + int color = 0x505000ff; + int color2 = 0xf0100010; + + renderTooltip(x, y, tooltipData, color, color2); + } + + public static void renderTooltipOrange(int x, int y, List tooltipData) { + int color = 0x50a06600; + int color2 = 0xf01e1200; + + renderTooltip(x, y, tooltipData, color, color2); + } + + public static void renderTooltipGreen(int x, int y, List tooltipData) { + int color = 0x5000a000; + int color2 = 0xf0001e00; + + renderTooltip(x, y, tooltipData, color, color2); + } + + public static void renderTooltip(int x, int y, List tooltipData, int color, int color2) { + boolean lighting = GL11.glGetBoolean(GL11.GL_LIGHTING); + if(lighting) + net.minecraft.client.renderer.RenderHelper.disableStandardItemLighting(); + + if (!tooltipData.isEmpty()) { + int var5 = 0; + int var6; + int var7; + FontRenderer fontRenderer = Minecraft.getMinecraft().fontRenderer; + for (var6 = 0; var6 < tooltipData.size(); ++var6) { + var7 = fontRenderer.getStringWidth(tooltipData.get(var6)); + if (var7 > var5) + var5 = var7; + } + var6 = x + 12; + var7 = y - 12; + int var9 = 8; + if (tooltipData.size() > 1) + var9 += 2 + (tooltipData.size() - 1) * 10; + float z = 300F; + drawGradientRect(var6 - 3, var7 - 4, z, var6 + var5 + 3, var7 - 3, color2, color2); + drawGradientRect(var6 - 3, var7 + var9 + 3, z, var6 + var5 + 3, var7 + var9 + 4, color2, color2); + drawGradientRect(var6 - 3, var7 - 3, z, var6 + var5 + 3, var7 + var9 + 3, color2, color2); + drawGradientRect(var6 - 4, var7 - 3, z, var6 - 3, var7 + var9 + 3, color2, color2); + drawGradientRect(var6 + var5 + 3, var7 - 3, z, var6 + var5 + 4, var7 + var9 + 3, color2, color2); + int var12 = (color & 0xFFFFFF) >> 1 | color & -16777216; + drawGradientRect(var6 - 3, var7 - 3 + 1, z, var6 - 3 + 1, var7 + var9 + 3 - 1, color, var12); + drawGradientRect(var6 + var5 + 2, var7 - 3 + 1, z, var6 + var5 + 3, var7 + var9 + 3 - 1, color, var12); + drawGradientRect(var6 - 3, var7 - 3, z, var6 + var5 + 3, var7 - 3 + 1, color, color); + drawGradientRect(var6 - 3, var7 + var9 + 2, z, var6 + var5 + 3, var7 + var9 + 3, var12, var12); + + GL11.glDisable(GL11.GL_DEPTH_TEST); + for (int var13 = 0; var13 < tooltipData.size(); ++var13) { + String var14 = tooltipData.get(var13); + fontRenderer.drawStringWithShadow(var14, var6, var7, -1); + if (var13 == 0) + var7 += 2; + var7 += 10; + } + GL11.glEnable(GL11.GL_DEPTH_TEST); + } + if(!lighting) + net.minecraft.client.renderer.RenderHelper.disableStandardItemLighting(); + GL11.glColor4f(1F, 1F, 1F, 1F); + } + + public static void drawGradientRect(int par1, int par2, float z, int par3, int par4, int par5, int par6) { + float var7 = (par5 >> 24 & 255) / 255F; + float var8 = (par5 >> 16 & 255) / 255F; + float var9 = (par5 >> 8 & 255) / 255F; + float var10 = (par5 & 255) / 255F; + float var11 = (par6 >> 24 & 255) / 255F; + float var12 = (par6 >> 16 & 255) / 255F; + float var13 = (par6 >> 8 & 255) / 255F; + float var14 = (par6 & 255) / 255F; + GL11.glDisable(GL11.GL_TEXTURE_2D); + GL11.glEnable(GL11.GL_BLEND); + GL11.glDisable(GL11.GL_ALPHA_TEST); + GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); + GL11.glShadeModel(GL11.GL_SMOOTH); + Tessellator var15 = Tessellator.instance; + var15.startDrawingQuads(); + var15.setColorRGBA_F(var8, var9, var10, var7); + var15.addVertex(par3, par2, z); + var15.addVertex(par1, par2, z); + var15.setColorRGBA_F(var12, var13, var14, var11); + var15.addVertex(par1, par4, z); + var15.addVertex(par3, par4, z); + var15.draw(); + GL11.glShadeModel(GL11.GL_FLAT); + GL11.glDisable(GL11.GL_BLEND); + GL11.glEnable(GL11.GL_ALPHA_TEST); + GL11.glEnable(GL11.GL_TEXTURE_2D); + } + + public static void drawTexturedModalRect(int par1, int par2, float z, int par3, int par4, int par5, int par6) { + drawTexturedModalRect(par1, par2, z, par3, par4, par5, par6, 0.00390625F, 0.00390625F); + } + + public static void drawTexturedModalRect(int par1, int par2, float z, int par3, int par4, int par5, int par6, float f, float f1) { + Tessellator tessellator = Tessellator.instance; + tessellator.startDrawingQuads(); + tessellator.addVertexWithUV(par1 + 0, par2 + par6, z, (par3 + 0) * f, (par4 + par6) * f1); + tessellator.addVertexWithUV(par1 + par5, par2 + par6, z, (par3 + par5) * f, (par4 + par6) * f1); + tessellator.addVertexWithUV(par1 + par5, par2 + 0, z, (par3 + par5) * f, (par4 + 0) * f1); + tessellator.addVertexWithUV(par1 + 0, par2 + 0, z, (par3 + 0) * f, (par4 + 0) * f1); + tessellator.draw(); + } + + public static void renderStar(int color, float xScale, float yScale, float zScale, long seed) { + Tessellator tessellator = Tessellator.instance; + + int ticks = ClientTickHandler.ticksInGame % 200; + if (ticks >= 100) + ticks = 200 - ticks - 1; + + float f1 = ticks / 200F; + float f2 = 0F; + if (f1 > 0.7F) + f2 = (f1 - 0.7F) / 0.2F; + Random random = new Random(seed); + + GL11.glPushMatrix(); + GL11.glDisable(GL11.GL_TEXTURE_2D); + GL11.glShadeModel(GL11.GL_SMOOTH); + GL11.glEnable(GL11.GL_BLEND); + GL11.glBlendFunc(770, 1); + GL11.glDisable(GL11.GL_ALPHA_TEST); + GL11.glEnable(GL11.GL_CULL_FACE); + GL11.glDepthMask(false); + GL11.glScalef(xScale, yScale, zScale); + + for (int i = 0; i < (f1 + f1 * f1) / 2F * 90F + 30F; i++) { + GL11.glRotatef(random.nextFloat() * 360F, 1F, 0F, 0F); + GL11.glRotatef(random.nextFloat() * 360F, 0F, 1F, 0F); + GL11.glRotatef(random.nextFloat() * 360F, 0F, 0F, 1F); + GL11.glRotatef(random.nextFloat() * 360F, 1F, 0F, 0F); + GL11.glRotatef(random.nextFloat() * 360F, 0F, 1F, 0F); + GL11.glRotatef(random.nextFloat() * 360F + f1 * 90F, 0F, 0F, 1F); + tessellator.startDrawing(GL11.GL_TRIANGLE_FAN); + float f3 = random.nextFloat() * 20F + 5F + f2 * 10F; + float f4 = random.nextFloat() * 2F + 1F + f2 * 2F; + tessellator.setColorRGBA_I(color, (int) (255F * (1F - f2))); + tessellator.addVertex(0, 0, 0); + tessellator.setColorRGBA_F(0F, 0F, 0F, 0); + tessellator.addVertex(-0.866D * f4, f3, -0.5F * f4); + tessellator.addVertex(0.866D * f4, f3, -0.5F * f4); + tessellator.addVertex(0, f3, 1F * f4); + tessellator.addVertex(-0.866D * f4, f3, -0.5F * f4); + tessellator.draw(); + } + + GL11.glDepthMask(true); + GL11.glDisable(GL11.GL_CULL_FACE); + GL11.glDisable(GL11.GL_BLEND); + GL11.glShadeModel(GL11.GL_FLAT); + GL11.glColor4f(1F, 1F, 1F, 1F); + GL11.glEnable(GL11.GL_TEXTURE_2D); + GL11.glEnable(GL11.GL_ALPHA_TEST); + GL11.glPopMatrix(); + } + + public static void renderProgressPie(int x, int y, float progress, ItemStack stack) { + Minecraft mc = Minecraft.getMinecraft(); + RenderItem.getInstance().renderItemAndEffectIntoGUI(mc.fontRenderer, mc.renderEngine, stack, x, y); + + GL11.glClear(GL11.GL_DEPTH_BUFFER_BIT); + GL11.glEnable(GL11.GL_STENCIL_TEST); + GL11.glColorMask(false, false, false, false); + GL11.glDepthMask(false); + GL11.glStencilFunc(GL11.GL_NEVER, 1, 0xFF); + GL11.glStencilOp(GL11.GL_REPLACE, GL11.GL_KEEP, GL11.GL_KEEP); + GL11.glStencilMask(0xFF); + RenderItem.getInstance().renderItemAndEffectIntoGUI(mc.fontRenderer, mc.renderEngine, stack, x, y); + + mc.renderEngine.bindTexture(new ResourceLocation(LibResources.GUI_MANA_HUD)); + int r = 10; + int centerX = x + 8; + int centerY = y + 8; + int degs = (int) (360 * progress); + float a = 0.5F + 0.2F * ((float) Math.cos((double) (ClientTickHandler.ticksInGame + ClientTickHandler.partialTicks) / 10) * 0.5F + 0.5F); + + GL11.glDisable(GL11.GL_LIGHTING); + GL11.glDisable(GL11.GL_TEXTURE_2D); + GL11.glShadeModel(GL11.GL_SMOOTH); + GL11.glEnable(GL11.GL_BLEND); + GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); + GL11.glColorMask(true, true, true, true); + GL11.glDepthMask(true); + GL11.glStencilMask(0x00); + GL11.glStencilFunc(GL11.GL_EQUAL, 1, 0xFF); + GL11.glBegin(GL11.GL_TRIANGLE_FAN); + GL11.glColor4f(0F, 0.5F, 0.5F, a); + GL11.glVertex2i(centerX, centerY); + GL11.glColor4f(0F, 1F, 0.5F, a); + for(int i = degs; i > 0; i--) { + double rad = (i - 90) / 180F * Math.PI; + GL11.glVertex2d(centerX + Math.cos(rad) * r, centerY + Math.sin(rad) * r); + } + GL11.glVertex2i(centerX, centerY); + GL11.glEnd(); + GL11.glDisable(GL11.GL_BLEND); + GL11.glEnable(GL11.GL_TEXTURE_2D); + GL11.glShadeModel(GL11.GL_FLAT); + GL11.glDisable(GL11.GL_STENCIL_TEST); + } + + public static String getKeyDisplayString(String keyName) { + String key = null; + KeyBinding[] keys = Minecraft.getMinecraft().gameSettings.keyBindings; + for(KeyBinding otherKey : keys) + if(otherKey.getKeyDescription().equals(keyName)) { + key = Keyboard.getKeyName(otherKey.getKeyCode()); + break; + } + + return key; + } } diff --git a/src/main/java/vazkii/botania/client/core/helper/ShaderHelper.java b/src/main/java/vazkii/botania/client/core/helper/ShaderHelper.java index 3755c8b1e5..1923a011bd 100644 --- a/src/main/java/vazkii/botania/client/core/helper/ShaderHelper.java +++ b/src/main/java/vazkii/botania/client/core/helper/ShaderHelper.java @@ -2,182 +2,199 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Apr 9, 2014, 11:20:26 PM (GMT)] */ package vazkii.botania.client.core.helper; -import cpw.mods.fml.common.FMLLog; import java.io.BufferedReader; import java.io.InputStream; import java.io.InputStreamReader; + import net.minecraft.client.renderer.OpenGlHelper; + import org.apache.logging.log4j.Level; import org.lwjgl.opengl.ARBFragmentShader; import org.lwjgl.opengl.ARBShaderObjects; import org.lwjgl.opengl.ARBVertexShader; import org.lwjgl.opengl.GL11; + import vazkii.botania.api.internal.ShaderCallback; import vazkii.botania.client.core.handler.ClientTickHandler; import vazkii.botania.client.lib.LibResources; import vazkii.botania.common.core.handler.ConfigHandler; +import cpw.mods.fml.common.FMLLog; public final class ShaderHelper { - private static final int VERT = ARBVertexShader.GL_VERTEX_SHADER_ARB; - private static final int FRAG = ARBFragmentShader.GL_FRAGMENT_SHADER_ARB; - - public static int pylonGlow = 0; - public static int enchanterRune = 0; - public static int manaPool = 0; - public static int doppleganger = 0; - public static int halo = 0; - public static int dopplegangerBar = 0; - public static int terraPlateRune = 0; - public static int filmGrain = 0; - public static int gold = 0; - public static int categoryButton = 0; - - public static void initShaders() { - if (!useShaders()) return; - - pylonGlow = createProgram(null, LibResources.SHADER_PYLON_GLOW_FRAG); - enchanterRune = createProgram(null, LibResources.SHADER_ENCHANTER_RUNE_FRAG); - manaPool = createProgram(null, LibResources.SHADER_MANA_POOL_FRAG); - doppleganger = createProgram(LibResources.SHADER_DOPLLEGANGER_VERT, LibResources.SHADER_DOPLLEGANGER_FRAG); - halo = createProgram(null, LibResources.SHADER_HALO_FRAG); - dopplegangerBar = createProgram(null, LibResources.SHADER_DOPLLEGANGER_BAR_FRAG); - terraPlateRune = createProgram(null, LibResources.SHADER_TERRA_PLATE_RUNE_FRAG); - filmGrain = createProgram(null, LibResources.SHADER_FILM_GRAIN_FRAG); - gold = createProgram(null, LibResources.SHADER_GOLD_FRAG); - categoryButton = createProgram(null, LibResources.SHADER_CATEGORY_BUTTON_FRAG); - } - - public static void useShader(int shader, ShaderCallback callback) { - if (!useShaders()) return; - - ARBShaderObjects.glUseProgramObjectARB(shader); - - if (shader != 0) { - int time = ARBShaderObjects.glGetUniformLocationARB(shader, "time"); - ARBShaderObjects.glUniform1iARB(time, ClientTickHandler.ticksInGame); - - if (callback != null) callback.call(shader); - } - } - - public static void useShader(int shader) { - useShader(shader, null); - } - - public static void releaseShader() { - useShader(0); - } - - public static boolean useShaders() { - return ConfigHandler.useShaders && OpenGlHelper.shadersSupported; - } - - // Most of the code taken from the LWJGL wiki - // http://lwjgl.org/wiki/index.php?title=GLSL_Shaders_with_LWJGL - - private static int createProgram(String vert, String frag) { - int vertId = 0, fragId = 0, program = 0; - if (vert != null) vertId = createShader(vert, VERT); - if (frag != null) fragId = createShader(frag, FRAG); - - program = ARBShaderObjects.glCreateProgramObjectARB(); - if (program == 0) return 0; - - if (vert != null) ARBShaderObjects.glAttachObjectARB(program, vertId); - if (frag != null) ARBShaderObjects.glAttachObjectARB(program, fragId); - - ARBShaderObjects.glLinkProgramARB(program); - if (ARBShaderObjects.glGetObjectParameteriARB(program, ARBShaderObjects.GL_OBJECT_LINK_STATUS_ARB) - == GL11.GL_FALSE) { - FMLLog.log(Level.ERROR, getLogInfo(program)); - return 0; - } - - ARBShaderObjects.glValidateProgramARB(program); - if (ARBShaderObjects.glGetObjectParameteriARB(program, ARBShaderObjects.GL_OBJECT_VALIDATE_STATUS_ARB) - == GL11.GL_FALSE) { - FMLLog.log(Level.ERROR, getLogInfo(program)); - return 0; - } - - return program; - } - - private static int createShader(String filename, int shaderType) { - int shader = 0; - try { - shader = ARBShaderObjects.glCreateShaderObjectARB(shaderType); - - if (shader == 0) return 0; - - ARBShaderObjects.glShaderSourceARB(shader, readFileAsString(filename)); - ARBShaderObjects.glCompileShaderARB(shader); - - if (ARBShaderObjects.glGetObjectParameteriARB(shader, ARBShaderObjects.GL_OBJECT_COMPILE_STATUS_ARB) - == GL11.GL_FALSE) throw new RuntimeException("Error creating shader: " + getLogInfo(shader)); - - return shader; - } catch (Exception e) { - ARBShaderObjects.glDeleteObjectARB(shader); - e.printStackTrace(); - return -1; - } - } - - private static String getLogInfo(int obj) { - return ARBShaderObjects.glGetInfoLogARB( - obj, ARBShaderObjects.glGetObjectParameteriARB(obj, ARBShaderObjects.GL_OBJECT_INFO_LOG_LENGTH_ARB)); - } - - private static String readFileAsString(String filename) throws Exception { - StringBuilder source = new StringBuilder(); - InputStream in = ShaderHelper.class.getResourceAsStream(filename); - Exception exception = null; - BufferedReader reader; - - if (in == null) return ""; - - try { - reader = new BufferedReader(new InputStreamReader(in, "UTF-8")); - - Exception innerExc = null; - try { - String line; - while ((line = reader.readLine()) != null) source.append(line).append('\n'); - } catch (Exception exc) { - exception = exc; - } finally { - try { - reader.close(); - } catch (Exception exc) { - if (innerExc == null) innerExc = exc; - else exc.printStackTrace(); - } - } - - if (innerExc != null) throw innerExc; - } catch (Exception exc) { - exception = exc; - } finally { - try { - in.close(); - } catch (Exception exc) { - if (exception == null) exception = exc; - else exc.printStackTrace(); - } - - if (exception != null) throw exception; - } - - return source.toString(); - } + private static final int VERT = ARBVertexShader.GL_VERTEX_SHADER_ARB; + private static final int FRAG = ARBFragmentShader.GL_FRAGMENT_SHADER_ARB; + + public static int pylonGlow = 0; + public static int enchanterRune = 0; + public static int manaPool = 0; + public static int doppleganger = 0; + public static int halo = 0; + public static int dopplegangerBar = 0; + public static int terraPlateRune = 0; + public static int filmGrain = 0; + public static int gold = 0; + public static int categoryButton = 0; + + public static void initShaders() { + if(!useShaders()) + return; + + pylonGlow = createProgram(null, LibResources.SHADER_PYLON_GLOW_FRAG); + enchanterRune = createProgram(null, LibResources.SHADER_ENCHANTER_RUNE_FRAG); + manaPool = createProgram(null, LibResources.SHADER_MANA_POOL_FRAG); + doppleganger = createProgram(LibResources.SHADER_DOPLLEGANGER_VERT, LibResources.SHADER_DOPLLEGANGER_FRAG); + halo = createProgram(null, LibResources.SHADER_HALO_FRAG); + dopplegangerBar = createProgram(null, LibResources.SHADER_DOPLLEGANGER_BAR_FRAG); + terraPlateRune = createProgram(null, LibResources.SHADER_TERRA_PLATE_RUNE_FRAG); + filmGrain = createProgram(null, LibResources.SHADER_FILM_GRAIN_FRAG); + gold = createProgram(null, LibResources.SHADER_GOLD_FRAG); + categoryButton = createProgram(null, LibResources.SHADER_CATEGORY_BUTTON_FRAG); + } + + public static void useShader(int shader, ShaderCallback callback) { + if(!useShaders()) + return; + + ARBShaderObjects.glUseProgramObjectARB(shader); + + if(shader != 0) { + int time = ARBShaderObjects.glGetUniformLocationARB(shader, "time"); + ARBShaderObjects.glUniform1iARB(time, ClientTickHandler.ticksInGame); + + if(callback != null) + callback.call(shader); + } + } + + public static void useShader(int shader) { + useShader(shader, null); + } + + public static void releaseShader() { + useShader(0); + } + + public static boolean useShaders() { + return ConfigHandler.useShaders && OpenGlHelper.shadersSupported; + } + + // Most of the code taken from the LWJGL wiki + // http://lwjgl.org/wiki/index.php?title=GLSL_Shaders_with_LWJGL + + private static int createProgram(String vert, String frag) { + int vertId = 0, fragId = 0, program = 0; + if(vert != null) + vertId = createShader(vert, VERT); + if(frag != null) + fragId = createShader(frag, FRAG); + + program = ARBShaderObjects.glCreateProgramObjectARB(); + if(program == 0) + return 0; + + if(vert != null) + ARBShaderObjects.glAttachObjectARB(program, vertId); + if(frag != null) + ARBShaderObjects.glAttachObjectARB(program, fragId); + + ARBShaderObjects.glLinkProgramARB(program); + if(ARBShaderObjects.glGetObjectParameteriARB(program, ARBShaderObjects.GL_OBJECT_LINK_STATUS_ARB) == GL11.GL_FALSE) { + FMLLog.log(Level.ERROR, getLogInfo(program)); + return 0; + } + + ARBShaderObjects.glValidateProgramARB(program); + if (ARBShaderObjects.glGetObjectParameteriARB(program, ARBShaderObjects.GL_OBJECT_VALIDATE_STATUS_ARB) == GL11.GL_FALSE) { + FMLLog.log(Level.ERROR, getLogInfo(program)); + return 0; + } + + return program; + } + + private static int createShader(String filename, int shaderType){ + int shader = 0; + try { + shader = ARBShaderObjects.glCreateShaderObjectARB(shaderType); + + if(shader == 0) + return 0; + + ARBShaderObjects.glShaderSourceARB(shader, readFileAsString(filename)); + ARBShaderObjects.glCompileShaderARB(shader); + + if (ARBShaderObjects.glGetObjectParameteriARB(shader, ARBShaderObjects.GL_OBJECT_COMPILE_STATUS_ARB) == GL11.GL_FALSE) + throw new RuntimeException("Error creating shader: " + getLogInfo(shader)); + + return shader; + } + catch(Exception e) { + ARBShaderObjects.glDeleteObjectARB(shader); + e.printStackTrace(); + return -1; + } + } + + private static String getLogInfo(int obj) { + return ARBShaderObjects.glGetInfoLogARB(obj, ARBShaderObjects.glGetObjectParameteriARB(obj, ARBShaderObjects.GL_OBJECT_INFO_LOG_LENGTH_ARB)); + } + + private static String readFileAsString(String filename) throws Exception { + StringBuilder source = new StringBuilder(); + InputStream in = ShaderHelper.class.getResourceAsStream(filename); + Exception exception = null; + BufferedReader reader; + + if(in == null) + return ""; + + try { + reader = new BufferedReader(new InputStreamReader(in, "UTF-8")); + + Exception innerExc= null; + try { + String line; + while((line = reader.readLine()) != null) + source.append(line).append('\n'); + } catch(Exception exc) { + exception = exc; + } finally { + try { + reader.close(); + } catch(Exception exc) { + if(innerExc == null) + innerExc = exc; + else exc.printStackTrace(); + } + } + + if(innerExc != null) + throw innerExc; + } catch(Exception exc) { + exception = exc; + } finally { + try { + in.close(); + } catch(Exception exc) { + if(exception == null) + exception = exc; + else exc.printStackTrace(); + } + + if(exception != null) + throw exception; + } + + return source.toString(); + } + } diff --git a/src/main/java/vazkii/botania/client/core/proxy/ClientProxy.java b/src/main/java/vazkii/botania/client/core/proxy/ClientProxy.java index f59303c2c1..ac491c3e19 100644 --- a/src/main/java/vazkii/botania/client/core/proxy/ClientProxy.java +++ b/src/main/java/vazkii/botania/client/core/proxy/ClientProxy.java @@ -2,28 +2,20 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jan 13, 2014, 7:46:05 PM (GMT)] */ package vazkii.botania.client.core.proxy; -import cpw.mods.fml.client.registry.ClientRegistry; -import cpw.mods.fml.client.registry.RenderingRegistry; -import cpw.mods.fml.common.FMLCommonHandler; -import cpw.mods.fml.common.FMLLog; -import cpw.mods.fml.common.Optional; -import cpw.mods.fml.common.event.FMLInitializationEvent; -import cpw.mods.fml.common.event.FMLPostInitializationEvent; -import cpw.mods.fml.common.event.FMLPreInitializationEvent; -import cpw.mods.fml.relauncher.ReflectionHelper; import java.awt.Desktop; import java.io.File; import java.io.IOException; import java.net.URI; import java.util.Calendar; + import net.minecraft.block.Block; import net.minecraft.client.Minecraft; import net.minecraft.client.multiplayer.PlayerControllerMP; @@ -131,6 +123,7 @@ import vazkii.botania.client.render.tile.RenderTileTeruTeruBozu; import vazkii.botania.client.render.tile.RenderTileTinyPotato; import vazkii.botania.client.render.world.SkyblockRenderEvents; +import vazkii.botania.common.Botania; import vazkii.botania.common.block.ModBlocks; import vazkii.botania.common.block.tile.TileAlfPortal; import vazkii.botania.common.block.tile.TileAltar; @@ -180,371 +173,363 @@ import vazkii.botania.common.item.equipment.bauble.ItemMonocle; import vazkii.botania.common.lexicon.LexiconData; import vazkii.botania.common.lib.LibObfuscation; +import cpw.mods.fml.client.registry.ClientRegistry; +import cpw.mods.fml.client.registry.RenderingRegistry; +import cpw.mods.fml.common.FMLCommonHandler; +import cpw.mods.fml.common.FMLLog; +import cpw.mods.fml.common.Optional; +import cpw.mods.fml.common.event.FMLInitializationEvent; +import cpw.mods.fml.common.event.FMLPostInitializationEvent; +import cpw.mods.fml.common.event.FMLPreInitializationEvent; +import cpw.mods.fml.relauncher.ReflectionHelper; public class ClientProxy extends CommonProxy { - public static boolean jingleTheBells = false; - public static boolean dootDoot = false; - - @Override - public void preInit(FMLPreInitializationEvent event) { - PersistentVariableHelper.setCacheFile(new File(Minecraft.getMinecraft().mcDataDir, "BotaniaVars.dat")); - try { - PersistentVariableHelper.load(); - PersistentVariableHelper.save(); - } catch (IOException e) { - FMLLog.severe("Botania's persistent Variables couldn't load!"); - e.printStackTrace(); - } - - super.preInit(event); - } - - @Override - public void init(FMLInitializationEvent event) { - super.init(event); - - ModChallenges.init(); - - FMLCommonHandler.instance().bus().register(new ClientTickHandler()); - MinecraftForge.EVENT_BUS.register(new HUDHandler()); - MinecraftForge.EVENT_BUS.register(new LightningHandler()); - if (ConfigHandler.boundBlockWireframe) MinecraftForge.EVENT_BUS.register(new BoundTileRenderer()); - MinecraftForge.EVENT_BUS.register(new TooltipHandler()); - MinecraftForge.EVENT_BUS.register(new BaubleRenderHandler()); - MinecraftForge.EVENT_BUS.register(new DebugHandler()); - MinecraftForge.EVENT_BUS.register(new SubTileRadiusRenderHandler()); - MinecraftForge.EVENT_BUS.register(new MultiblockRenderHandler()); - MinecraftForge.EVENT_BUS.register(new SkyblockRenderEvents()); - FMLCommonHandler.instance().bus().register(new CorporeaAutoCompleteHandler()); - - if (ConfigHandler.enableSeasonalFeatures) { - Calendar calendar = Calendar.getInstance(); - if ((calendar.get(2) == 11 && calendar.get(5) >= 16) || (calendar.get(2) == 0 && calendar.get(5) <= 2)) - jingleTheBells = true; - if (calendar.get(2) == 9) dootDoot = true; - } - - initRenderers(); - } - - @Override - public void postInit(FMLPostInitializationEvent event) { - super.postInit(event); - CorporeaAutoCompleteHandler.updateItemList(); - } - - private void initRenderers() { - LibRenderIDs.idAltar = RenderingRegistry.getNextAvailableRenderId(); - LibRenderIDs.idSpecialFlower = RenderingRegistry.getNextAvailableRenderId(); - LibRenderIDs.idSpreader = RenderingRegistry.getNextAvailableRenderId(); - LibRenderIDs.idPool = RenderingRegistry.getNextAvailableRenderId(); - LibRenderIDs.idPylon = RenderingRegistry.getNextAvailableRenderId(); - LibRenderIDs.idMiniIsland = RenderingRegistry.getNextAvailableRenderId(); - LibRenderIDs.idTinyPotato = RenderingRegistry.getNextAvailableRenderId(); - LibRenderIDs.idSpawnerClaw = RenderingRegistry.getNextAvailableRenderId(); - LibRenderIDs.idBrewery = RenderingRegistry.getNextAvailableRenderId(); - LibRenderIDs.idCorporeaIndex = RenderingRegistry.getNextAvailableRenderId(); - LibRenderIDs.idPump = RenderingRegistry.getNextAvailableRenderId(); - LibRenderIDs.idDoubleFlower = RenderingRegistry.getNextAvailableRenderId(); - LibRenderIDs.idCorporeaCrystalCybe = RenderingRegistry.getNextAvailableRenderId(); - LibRenderIDs.idIncensePlate = RenderingRegistry.getNextAvailableRenderId(); - LibRenderIDs.idHourglass = RenderingRegistry.getNextAvailableRenderId(); - LibRenderIDs.idCocoon = RenderingRegistry.getNextAvailableRenderId(); - LibRenderIDs.idLightRelay = RenderingRegistry.getNextAvailableRenderId(); - LibRenderIDs.idBellows = RenderingRegistry.getNextAvailableRenderId(); - LibRenderIDs.idTeruTeruBozu = RenderingRegistry.getNextAvailableRenderId(); - LibRenderIDs.idAvatar = RenderingRegistry.getNextAvailableRenderId(); - - RenderSpecialFlower specialFlowerRender = new RenderSpecialFlower(LibRenderIDs.idSpecialFlower); - RenderingRegistry.registerBlockHandler(new RenderAltar()); - RenderingRegistry.registerBlockHandler(specialFlowerRender); - RenderingRegistry.registerBlockHandler(new RenderSpreader()); - RenderingRegistry.registerBlockHandler(new RenderPool()); - RenderingRegistry.registerBlockHandler(new RenderPylon()); - RenderingRegistry.registerBlockHandler(new RenderFloatingFlower()); - RenderingRegistry.registerBlockHandler(new RenderTinyPotato()); - RenderingRegistry.registerBlockHandler(new RenderSpawnerClaw()); - RenderingRegistry.registerBlockHandler(new RenderBrewery()); - RenderingRegistry.registerBlockHandler(new RenderCorporeaIndex()); - RenderingRegistry.registerBlockHandler(new RenderPump()); - RenderingRegistry.registerBlockHandler(new RenderDoubleFlower()); - RenderingRegistry.registerBlockHandler(new RenderCorporeaCrystalCube()); - RenderingRegistry.registerBlockHandler(new RenderIncensePlate()); - RenderingRegistry.registerBlockHandler(new RenderHourglass()); - RenderingRegistry.registerBlockHandler(new RenderCocoon()); - RenderingRegistry.registerBlockHandler(new RenderBellows()); - RenderingRegistry.registerBlockHandler(new RenderTeruTeruBozu()); - RenderingRegistry.registerBlockHandler(new RenderAvatar()); - - IMultiblockRenderHook.renderHooks.put(ModBlocks.flower, specialFlowerRender); - IMultiblockRenderHook.renderHooks.put(ModBlocks.shinyFlower, specialFlowerRender); - - RenderTransparentItem renderTransparentItem = new RenderTransparentItem(); - RenderFloatingFlowerItem renderFloatingFlower = new RenderFloatingFlowerItem(); - RenderBow renderBow = new RenderBow(); - - MinecraftForgeClient.registerItemRenderer(ModItems.lens, new RenderLens()); - if (ConfigHandler.lexicon3dModel) - MinecraftForgeClient.registerItemRenderer(ModItems.lexicon, new RenderLexicon()); - MinecraftForgeClient.registerItemRenderer(ModItems.glassPick, renderTransparentItem); - MinecraftForgeClient.registerItemRenderer(ModItems.spark, renderTransparentItem); - MinecraftForgeClient.registerItemRenderer( - Item.getItemFromBlock(ModBlocks.floatingFlower), renderFloatingFlower); - MinecraftForgeClient.registerItemRenderer( - Item.getItemFromBlock(ModBlocks.floatingSpecialFlower), renderFloatingFlower); - MinecraftForgeClient.registerItemRenderer(ModItems.livingwoodBow, renderBow); - MinecraftForgeClient.registerItemRenderer(ModItems.crystalBow, renderBow); - - RenderTileFloatingFlower renderTileFloatingFlower = new RenderTileFloatingFlower(); - ClientRegistry.bindTileEntitySpecialRenderer(TileAltar.class, new RenderTileAltar()); - ClientRegistry.bindTileEntitySpecialRenderer(TileSpreader.class, new RenderTileSpreader()); - ClientRegistry.bindTileEntitySpecialRenderer(TilePool.class, new RenderTilePool()); - ClientRegistry.bindTileEntitySpecialRenderer(TileRuneAltar.class, new RenderTileRuneAltar()); - ClientRegistry.bindTileEntitySpecialRenderer(TilePylon.class, new RenderTilePylon()); - ClientRegistry.bindTileEntitySpecialRenderer(TileEnchanter.class, new RenderTileEnchanter()); - ClientRegistry.bindTileEntitySpecialRenderer(TileAlfPortal.class, new RenderTileAlfPortal()); - ClientRegistry.bindTileEntitySpecialRenderer(TileFloatingFlower.class, renderTileFloatingFlower); - ClientRegistry.bindTileEntitySpecialRenderer(TileFloatingSpecialFlower.class, renderTileFloatingFlower); - ClientRegistry.bindTileEntitySpecialRenderer(TileTinyPotato.class, new RenderTileTinyPotato()); - ClientRegistry.bindTileEntitySpecialRenderer(TileSpawnerClaw.class, new RenderTileSpawnerClaw()); - ClientRegistry.bindTileEntitySpecialRenderer(TileStarfield.class, new RenderTileStarfield()); - ClientRegistry.bindTileEntitySpecialRenderer(TileBrewery.class, new RenderTileBrewery()); - ClientRegistry.bindTileEntitySpecialRenderer(TileTerraPlate.class, new RenderTileTerraPlate()); - ClientRegistry.bindTileEntitySpecialRenderer(TileRedString.class, new RenderTileRedString()); - ClientRegistry.bindTileEntitySpecialRenderer(TilePrism.class, new RenderTilePrism()); - ClientRegistry.bindTileEntitySpecialRenderer(TileCorporeaIndex.class, new RenderTileCorporeaIndex()); - ClientRegistry.bindTileEntitySpecialRenderer(TilePump.class, new RenderTilePump()); - ClientRegistry.bindTileEntitySpecialRenderer( - TileCorporeaCrystalCube.class, new RenderTileCorporeaCrystalCube()); - ClientRegistry.bindTileEntitySpecialRenderer(TileIncensePlate.class, new RenderTileIncensePlate()); - ClientRegistry.bindTileEntitySpecialRenderer(TileHourglass.class, new RenderTileHourglass()); - ClientRegistry.bindTileEntitySpecialRenderer(TileSparkChanger.class, new RenderTileSparkChanger()); - ClientRegistry.bindTileEntitySpecialRenderer(TileCocoon.class, new RenderTileCocoon()); - ClientRegistry.bindTileEntitySpecialRenderer(TileLightRelay.class, new RenderTileLightRelay()); - ClientRegistry.bindTileEntitySpecialRenderer(TileBellows.class, new RenderTileBellows()); - ClientRegistry.bindTileEntitySpecialRenderer(TileGaiaHead.class, new RenderTileSkullOverride()); - ClientRegistry.bindTileEntitySpecialRenderer(TileTeruTeruBozu.class, new RenderTileTeruTeruBozu()); - ClientRegistry.bindTileEntitySpecialRenderer(TileAvatar.class, new RenderTileAvatar()); - - ClientRegistry.bindTileEntitySpecialRenderer(TileEntitySkull.class, new RenderTileSkullOverride()); - - RenderingRegistry.registerEntityRenderingHandler(EntityPixie.class, new RenderPixie()); - RenderingRegistry.registerEntityRenderingHandler(EntityVineBall.class, new RenderSnowball(ModItems.vineBall)); - RenderingRegistry.registerEntityRenderingHandler(EntityDoppleganger.class, new RenderDoppleganger()); - RenderingRegistry.registerEntityRenderingHandler(EntitySpark.class, new RenderSpark()); - RenderingRegistry.registerEntityRenderingHandler(EntityThornChakram.class, new RenderThornChakram()); - RenderingRegistry.registerEntityRenderingHandler(EntityCorporeaSpark.class, new RenderCorporeaSpark()); - RenderingRegistry.registerEntityRenderingHandler( - EntityEnderAirBottle.class, new RenderSnowball(ModItems.manaResource, 15)); - RenderingRegistry.registerEntityRenderingHandler(EntityPoolMinecart.class, new RenderPoolMinecart()); - RenderingRegistry.registerEntityRenderingHandler(EntityPinkWither.class, new RenderPinkWither()); - RenderingRegistry.registerEntityRenderingHandler(EntityManaStorm.class, new RenderManaStorm()); - RenderingRegistry.registerEntityRenderingHandler(EntityBabylonWeapon.class, new RenderBabylonWeapon()); - - ShaderHelper.initShaders(); - } - - @Override - @Optional.Method(modid = "NotEnoughItems") - public void registerNEIStuff() { - NEIGuiHooks.init(); - } - - @Override - public void setEntryToOpen(LexiconEntry entry) { - GuiLexicon.currentOpenLexicon = new GuiLexiconEntry(entry, new GuiLexiconIndex(entry.category)); - } - - @Override - public void setToTutorialIfFirstLaunch() { - if (PersistentVariableHelper.firstLoad) - GuiLexicon.currentOpenLexicon = new GuiLexiconEntry( - LexiconData.welcome, new GuiLexiconEntry(LexiconData.tutorial, new GuiLexicon())) - .setFirstEntry(); - } - - @Override - public void setLexiconStack(ItemStack stack) { - GuiLexicon.stackUsed = stack; - } - - @Override - public boolean isTheClientPlayer(EntityLivingBase entity) { - return entity == Minecraft.getMinecraft().thePlayer; - } - - @Override - public boolean isClientPlayerWearingMonocle() { - return ItemMonocle.hasMonocle(Minecraft.getMinecraft().thePlayer); - } - - @Override - public void setExtraReach(EntityLivingBase entity, float reach) { - super.setExtraReach(entity, reach); - Minecraft mc = Minecraft.getMinecraft(); - EntityPlayer player = mc.thePlayer; - if (entity == player) { - if (!(mc.playerController instanceof IExtendedPlayerController)) { - GameType type = ReflectionHelper.getPrivateValue( - PlayerControllerMP.class, mc.playerController, LibObfuscation.CURRENT_GAME_TYPE); - NetHandlerPlayClient net = ReflectionHelper.getPrivateValue( - PlayerControllerMP.class, mc.playerController, LibObfuscation.NET_CLIENT_HANDLER); - BotaniaPlayerController controller = new BotaniaPlayerController(mc, net); - boolean isFlying = player.capabilities.isFlying; - boolean allowFlying = player.capabilities.allowFlying; - controller.setGameType(type); - player.capabilities.isFlying = isFlying; - player.capabilities.allowFlying = allowFlying; - mc.playerController = controller; - } - - ((IExtendedPlayerController) mc.playerController) - .setReachDistanceExtension(Math.max( - 0, ((IExtendedPlayerController) mc.playerController).getReachDistanceExtension() + reach)); - } - } - - @Override - public boolean openWikiPage(World world, Block block, MovingObjectPosition pos) { - IWikiProvider wiki = WikiHooks.getWikiFor(block); - String url = wiki.getWikiURL(world, pos); - if (url != null && !url.isEmpty()) { - try { - Desktop.getDesktop().browse(new URI(url)); - } catch (Exception e) { - e.printStackTrace(); - return false; - } - return true; - } - return false; - } - - @Override - public void playRecordClientSided(World world, int x, int y, int z, ItemRecord record) { - Minecraft mc = Minecraft.getMinecraft(); - if (record == null) world.playAuxSFXAtEntity(null, 1005, x, y, z, 0); - else { - world.playAuxSFXAtEntity(null, 1005, x, y, z, Item.getIdFromItem(record)); - mc.ingameGUI.setRecordPlayingMessage(record.getRecordNameLocal()); - } - } - - @Override - public long getWorldElapsedTicks() { - return ClientTickHandler.ticksInGame; - } - - @Override - public void setMultiblock(World world, int x, int y, int z, double radius, Block block) { - MultiblockSextant mb = new MultiblockSextant(); - - int iradius = (int) radius + 1; - for (int i = 0; i < iradius * 2 + 1; i++) - for (int j = 0; j < iradius * 2 + 1; j++) { - int xp = x + i - iradius; - int zp = z + j - iradius; - if ((int) Math.floor(MathHelper.pointDistancePlane(xp, zp, x, z)) == iradius - 1) - mb.addComponent(new AnyComponent(new ChunkCoordinates(xp - x, 1, zp - z), block, 0)); - } - - MultiblockRenderHandler.setMultiblock(mb.makeSet()); - MultiblockRenderHandler.anchor = new ChunkCoordinates(x, y, z); - } - - @Override - public void removeSextantMultiblock() { - MultiblockSet set = MultiblockRenderHandler.currentMultiblock; - if (set != null) { - Multiblock mb = set.getForIndex(0); - if (mb instanceof MultiblockSextant) MultiblockRenderHandler.setMultiblock(null); - } - } - - private static boolean noclipEnabled = false; - private static boolean corruptSparkle = false; - - @Override - public void setSparkleFXNoClip(boolean noclip) { - noclipEnabled = noclip; - } - - @Override - public void setSparkleFXCorrupt(boolean corrupt) { - corruptSparkle = corrupt; - } - - @Override - public void sparkleFX( - World world, double x, double y, double z, float r, float g, float b, float size, int m, boolean fake) { - if (!doParticle(world) && !fake) return; - - FXSparkle sparkle = new FXSparkle(world, x, y, z, size, r, g, b, m); - sparkle.fake = sparkle.noClip = fake; - if (noclipEnabled) sparkle.noClip = true; - if (corruptSparkle) sparkle.corrupt = true; - Minecraft.getMinecraft().effectRenderer.addEffect(sparkle); - } - - private static boolean distanceLimit = true; - private static boolean depthTest = true; - - @Override - public void setWispFXDistanceLimit(boolean limit) { - distanceLimit = limit; - } - - @Override - public void setWispFXDepthTest(boolean test) { - depthTest = test; - } - - @Override - public void wispFX( - World world, - double x, - double y, - double z, - float r, - float g, - float b, - float size, - float motionx, - float motiony, - float motionz, - float maxAgeMul) { - if (!doParticle(world)) return; - - FXWisp wisp = new FXWisp(world, x, y, z, size, r, g, b, distanceLimit, depthTest, maxAgeMul); - wisp.motionX = motionx; - wisp.motionY = motiony; - wisp.motionZ = motionz; - - Minecraft.getMinecraft().effectRenderer.addEffect(wisp); - } - - private boolean doParticle(World world) { - if (!world.isRemote) return false; - - if (!ConfigHandler.useVanillaParticleLimiter) return true; - - float chance = 1F; - if (Minecraft.getMinecraft().gameSettings.particleSetting == 1) chance = 0.6F; - else if (Minecraft.getMinecraft().gameSettings.particleSetting == 2) chance = 0.2F; - - return chance == 1F || Math.random() < chance; - } - - @Override - public void lightningFX( - World world, - Vector3 vectorStart, - Vector3 vectorEnd, - float ticksPerMeter, - long seed, - int colorOuter, - int colorInner) { - LightningHandler.spawnLightningBolt(world, vectorStart, vectorEnd, ticksPerMeter, seed, colorOuter, colorInner); - } + public static boolean jingleTheBells = false; + public static boolean dootDoot = false; + + @Override + public void preInit(FMLPreInitializationEvent event) { + PersistentVariableHelper.setCacheFile(new File(Minecraft.getMinecraft().mcDataDir, "BotaniaVars.dat")); + try { + PersistentVariableHelper.load(); + PersistentVariableHelper.save(); + } catch (IOException e) { + FMLLog.severe("Botania's persistent Variables couldn't load!"); + e.printStackTrace(); + } + + super.preInit(event); + } + + @Override + public void init(FMLInitializationEvent event) { + super.init(event); + + ModChallenges.init(); + + FMLCommonHandler.instance().bus().register(new ClientTickHandler()); + MinecraftForge.EVENT_BUS.register(new HUDHandler()); + MinecraftForge.EVENT_BUS.register(new LightningHandler()); + if(ConfigHandler.boundBlockWireframe) + MinecraftForge.EVENT_BUS.register(new BoundTileRenderer()); + MinecraftForge.EVENT_BUS.register(new TooltipHandler()); + MinecraftForge.EVENT_BUS.register(new BaubleRenderHandler()); + MinecraftForge.EVENT_BUS.register(new DebugHandler()); + MinecraftForge.EVENT_BUS.register(new SubTileRadiusRenderHandler()); + MinecraftForge.EVENT_BUS.register(new MultiblockRenderHandler()); + MinecraftForge.EVENT_BUS.register(new SkyblockRenderEvents()); + FMLCommonHandler.instance().bus().register(new CorporeaAutoCompleteHandler()); + + if(ConfigHandler.enableSeasonalFeatures) { + Calendar calendar = Calendar.getInstance(); + if((calendar.get(2) == 11 && calendar.get(5) >= 16) || (calendar.get(2) == 0 && calendar.get(5) <= 2)) + jingleTheBells = true; + if(calendar.get(2) == 9) + dootDoot = true; + } + + initRenderers(); + } + + @Override + public void postInit(FMLPostInitializationEvent event) { + super.postInit(event); + CorporeaAutoCompleteHandler.updateItemList(); + } + + private void initRenderers() { + LibRenderIDs.idAltar = RenderingRegistry.getNextAvailableRenderId(); + LibRenderIDs.idSpecialFlower = RenderingRegistry.getNextAvailableRenderId(); + LibRenderIDs.idSpreader = RenderingRegistry.getNextAvailableRenderId(); + LibRenderIDs.idPool = RenderingRegistry.getNextAvailableRenderId(); + LibRenderIDs.idPylon = RenderingRegistry.getNextAvailableRenderId(); + LibRenderIDs.idMiniIsland = RenderingRegistry.getNextAvailableRenderId(); + LibRenderIDs.idTinyPotato = RenderingRegistry.getNextAvailableRenderId(); + LibRenderIDs.idSpawnerClaw = RenderingRegistry.getNextAvailableRenderId(); + LibRenderIDs.idBrewery = RenderingRegistry.getNextAvailableRenderId(); + LibRenderIDs.idCorporeaIndex = RenderingRegistry.getNextAvailableRenderId(); + LibRenderIDs.idPump = RenderingRegistry.getNextAvailableRenderId(); + LibRenderIDs.idDoubleFlower = RenderingRegistry.getNextAvailableRenderId(); + LibRenderIDs.idCorporeaCrystalCybe = RenderingRegistry.getNextAvailableRenderId(); + LibRenderIDs.idIncensePlate = RenderingRegistry.getNextAvailableRenderId(); + LibRenderIDs.idHourglass = RenderingRegistry.getNextAvailableRenderId(); + LibRenderIDs.idCocoon = RenderingRegistry.getNextAvailableRenderId(); + LibRenderIDs.idLightRelay = RenderingRegistry.getNextAvailableRenderId(); + LibRenderIDs.idBellows = RenderingRegistry.getNextAvailableRenderId(); + LibRenderIDs.idTeruTeruBozu = RenderingRegistry.getNextAvailableRenderId(); + LibRenderIDs.idAvatar = RenderingRegistry.getNextAvailableRenderId(); + + RenderSpecialFlower specialFlowerRender = new RenderSpecialFlower(LibRenderIDs.idSpecialFlower); + RenderingRegistry.registerBlockHandler(new RenderAltar()); + RenderingRegistry.registerBlockHandler(specialFlowerRender); + RenderingRegistry.registerBlockHandler(new RenderSpreader()); + RenderingRegistry.registerBlockHandler(new RenderPool()); + RenderingRegistry.registerBlockHandler(new RenderPylon()); + RenderingRegistry.registerBlockHandler(new RenderFloatingFlower()); + RenderingRegistry.registerBlockHandler(new RenderTinyPotato()); + RenderingRegistry.registerBlockHandler(new RenderSpawnerClaw()); + RenderingRegistry.registerBlockHandler(new RenderBrewery()); + RenderingRegistry.registerBlockHandler(new RenderCorporeaIndex()); + RenderingRegistry.registerBlockHandler(new RenderPump()); + RenderingRegistry.registerBlockHandler(new RenderDoubleFlower()); + RenderingRegistry.registerBlockHandler(new RenderCorporeaCrystalCube()); + RenderingRegistry.registerBlockHandler(new RenderIncensePlate()); + RenderingRegistry.registerBlockHandler(new RenderHourglass()); + RenderingRegistry.registerBlockHandler(new RenderCocoon()); + RenderingRegistry.registerBlockHandler(new RenderBellows()); + RenderingRegistry.registerBlockHandler(new RenderTeruTeruBozu()); + RenderingRegistry.registerBlockHandler(new RenderAvatar()); + + IMultiblockRenderHook.renderHooks.put(ModBlocks.flower, specialFlowerRender); + IMultiblockRenderHook.renderHooks.put(ModBlocks.shinyFlower, specialFlowerRender); + + RenderTransparentItem renderTransparentItem = new RenderTransparentItem(); + RenderFloatingFlowerItem renderFloatingFlower = new RenderFloatingFlowerItem(); + RenderBow renderBow = new RenderBow(); + + MinecraftForgeClient.registerItemRenderer(ModItems.lens, new RenderLens()); + if(ConfigHandler.lexicon3dModel) + MinecraftForgeClient.registerItemRenderer(ModItems.lexicon, new RenderLexicon()); + MinecraftForgeClient.registerItemRenderer(ModItems.glassPick, renderTransparentItem); + MinecraftForgeClient.registerItemRenderer(ModItems.spark, renderTransparentItem); + MinecraftForgeClient.registerItemRenderer(Item.getItemFromBlock(ModBlocks.floatingFlower), renderFloatingFlower); + MinecraftForgeClient.registerItemRenderer(Item.getItemFromBlock(ModBlocks.floatingSpecialFlower), renderFloatingFlower); + MinecraftForgeClient.registerItemRenderer(ModItems.livingwoodBow, renderBow); + MinecraftForgeClient.registerItemRenderer(ModItems.crystalBow, renderBow); + + RenderTileFloatingFlower renderTileFloatingFlower = new RenderTileFloatingFlower(); + ClientRegistry.bindTileEntitySpecialRenderer(TileAltar.class, new RenderTileAltar()); + ClientRegistry.bindTileEntitySpecialRenderer(TileSpreader.class, new RenderTileSpreader()); + ClientRegistry.bindTileEntitySpecialRenderer(TilePool.class, new RenderTilePool()); + ClientRegistry.bindTileEntitySpecialRenderer(TileRuneAltar.class, new RenderTileRuneAltar()); + ClientRegistry.bindTileEntitySpecialRenderer(TilePylon.class, new RenderTilePylon()); + ClientRegistry.bindTileEntitySpecialRenderer(TileEnchanter.class, new RenderTileEnchanter()); + ClientRegistry.bindTileEntitySpecialRenderer(TileAlfPortal.class, new RenderTileAlfPortal()); + ClientRegistry.bindTileEntitySpecialRenderer(TileFloatingFlower.class, renderTileFloatingFlower); + ClientRegistry.bindTileEntitySpecialRenderer(TileFloatingSpecialFlower.class, renderTileFloatingFlower); + ClientRegistry.bindTileEntitySpecialRenderer(TileTinyPotato.class, new RenderTileTinyPotato()); + ClientRegistry.bindTileEntitySpecialRenderer(TileSpawnerClaw.class, new RenderTileSpawnerClaw()); + ClientRegistry.bindTileEntitySpecialRenderer(TileStarfield.class, new RenderTileStarfield()); + ClientRegistry.bindTileEntitySpecialRenderer(TileBrewery.class, new RenderTileBrewery()); + ClientRegistry.bindTileEntitySpecialRenderer(TileTerraPlate.class, new RenderTileTerraPlate()); + ClientRegistry.bindTileEntitySpecialRenderer(TileRedString.class, new RenderTileRedString()); + ClientRegistry.bindTileEntitySpecialRenderer(TilePrism.class, new RenderTilePrism()); + ClientRegistry.bindTileEntitySpecialRenderer(TileCorporeaIndex.class, new RenderTileCorporeaIndex()); + ClientRegistry.bindTileEntitySpecialRenderer(TilePump.class, new RenderTilePump()); + ClientRegistry.bindTileEntitySpecialRenderer(TileCorporeaCrystalCube.class, new RenderTileCorporeaCrystalCube()); + ClientRegistry.bindTileEntitySpecialRenderer(TileIncensePlate.class, new RenderTileIncensePlate()); + ClientRegistry.bindTileEntitySpecialRenderer(TileHourglass.class, new RenderTileHourglass()); + ClientRegistry.bindTileEntitySpecialRenderer(TileSparkChanger.class, new RenderTileSparkChanger()); + ClientRegistry.bindTileEntitySpecialRenderer(TileCocoon.class, new RenderTileCocoon()); + ClientRegistry.bindTileEntitySpecialRenderer(TileLightRelay.class, new RenderTileLightRelay()); + ClientRegistry.bindTileEntitySpecialRenderer(TileBellows.class, new RenderTileBellows()); + ClientRegistry.bindTileEntitySpecialRenderer(TileGaiaHead.class, new RenderTileSkullOverride()); + ClientRegistry.bindTileEntitySpecialRenderer(TileTeruTeruBozu.class, new RenderTileTeruTeruBozu()); + ClientRegistry.bindTileEntitySpecialRenderer(TileAvatar.class, new RenderTileAvatar()); + + ClientRegistry.bindTileEntitySpecialRenderer(TileEntitySkull.class, new RenderTileSkullOverride()); + + RenderingRegistry.registerEntityRenderingHandler(EntityPixie.class, new RenderPixie()); + RenderingRegistry.registerEntityRenderingHandler(EntityVineBall.class, new RenderSnowball(ModItems.vineBall)); + RenderingRegistry.registerEntityRenderingHandler(EntityDoppleganger.class, new RenderDoppleganger()); + RenderingRegistry.registerEntityRenderingHandler(EntitySpark.class, new RenderSpark()); + RenderingRegistry.registerEntityRenderingHandler(EntityThornChakram.class, new RenderThornChakram()); + RenderingRegistry.registerEntityRenderingHandler(EntityCorporeaSpark.class, new RenderCorporeaSpark()); + RenderingRegistry.registerEntityRenderingHandler(EntityEnderAirBottle.class, new RenderSnowball(ModItems.manaResource, 15)); + RenderingRegistry.registerEntityRenderingHandler(EntityPoolMinecart.class, new RenderPoolMinecart()); + RenderingRegistry.registerEntityRenderingHandler(EntityPinkWither.class, new RenderPinkWither()); + RenderingRegistry.registerEntityRenderingHandler(EntityManaStorm.class, new RenderManaStorm()); + RenderingRegistry.registerEntityRenderingHandler(EntityBabylonWeapon.class, new RenderBabylonWeapon()); + + ShaderHelper.initShaders(); + } + + @Override + @Optional.Method(modid = "NotEnoughItems") + public void registerNEIStuff() { + NEIGuiHooks.init(); + } + + @Override + public void setEntryToOpen(LexiconEntry entry) { + GuiLexicon.currentOpenLexicon = new GuiLexiconEntry(entry, new GuiLexiconIndex(entry.category)); + } + + @Override + public void setToTutorialIfFirstLaunch() { + if(PersistentVariableHelper.firstLoad) + GuiLexicon.currentOpenLexicon = new GuiLexiconEntry(LexiconData.welcome, new GuiLexiconEntry(LexiconData.tutorial, new GuiLexicon())).setFirstEntry(); + } + + @Override + public void setLexiconStack(ItemStack stack) { + GuiLexicon.stackUsed = stack; + } + + @Override + public boolean isTheClientPlayer(EntityLivingBase entity) { + return entity == Minecraft.getMinecraft().thePlayer; + } + + @Override + public boolean isClientPlayerWearingMonocle() { + return ItemMonocle.hasMonocle(Minecraft.getMinecraft().thePlayer); + } + + @Override + public void setExtraReach(EntityLivingBase entity, float reach) { + super.setExtraReach(entity, reach); + Minecraft mc = Minecraft.getMinecraft(); + EntityPlayer player = mc.thePlayer; + if(entity == player) { + if(!(mc.playerController instanceof IExtendedPlayerController)) { + GameType type = ReflectionHelper.getPrivateValue(PlayerControllerMP.class, mc.playerController, LibObfuscation.CURRENT_GAME_TYPE); + NetHandlerPlayClient net = ReflectionHelper.getPrivateValue(PlayerControllerMP.class, mc.playerController, LibObfuscation.NET_CLIENT_HANDLER); + BotaniaPlayerController controller = new BotaniaPlayerController(mc, net); + boolean isFlying = player.capabilities.isFlying; + boolean allowFlying = player.capabilities.allowFlying; + controller.setGameType(type); + player.capabilities.isFlying = isFlying; + player.capabilities.allowFlying = allowFlying; + mc.playerController = controller; + } + + ((IExtendedPlayerController) mc.playerController).setReachDistanceExtension(Math.max(0, ((IExtendedPlayerController) mc.playerController).getReachDistanceExtension() + reach)); + } + } + + @Override + public boolean openWikiPage(World world, Block block, MovingObjectPosition pos) { + IWikiProvider wiki = WikiHooks.getWikiFor(block); + String url = wiki.getWikiURL(world, pos); + if(url != null && !url.isEmpty()) { + try { + Desktop.getDesktop().browse(new URI(url)); + } catch(Exception e) { + e.printStackTrace(); + return false; + } + return true; + } + return false; + } + + @Override + public void playRecordClientSided(World world, int x, int y, int z, ItemRecord record) { + Minecraft mc = Minecraft.getMinecraft(); + if(record == null) + world.playAuxSFXAtEntity(null, 1005, x, y, z, 0); + else { + world.playAuxSFXAtEntity(null, 1005, x, y, z, Item.getIdFromItem(record)); + mc.ingameGUI.setRecordPlayingMessage(record.getRecordNameLocal()); + } + } + + @Override + public long getWorldElapsedTicks() { + return ClientTickHandler.ticksInGame; + } + + @Override + public void setMultiblock(World world, int x, int y, int z, double radius, Block block) { + MultiblockSextant mb = new MultiblockSextant(); + + int iradius = (int) radius + 1; + for(int i = 0; i < iradius * 2 + 1; i++) + for(int j = 0; j < iradius * 2 + 1; j++) { + int xp = x + i - iradius; + int zp = z + j - iradius; + if((int) Math.floor(MathHelper.pointDistancePlane(xp, zp, x, z)) == iradius - 1) + mb.addComponent(new AnyComponent(new ChunkCoordinates(xp - x, 1, zp - z), block, 0)); + } + + MultiblockRenderHandler.setMultiblock(mb.makeSet()); + MultiblockRenderHandler.anchor = new ChunkCoordinates(x, y, z); + } + + @Override + public void removeSextantMultiblock() { + MultiblockSet set = MultiblockRenderHandler.currentMultiblock; + if(set != null) { + Multiblock mb = set.getForIndex(0); + if(mb instanceof MultiblockSextant) + MultiblockRenderHandler.setMultiblock(null); + } + } + + private static boolean noclipEnabled = false; + private static boolean corruptSparkle = false; + + @Override + public void setSparkleFXNoClip(boolean noclip) { + noclipEnabled = noclip; + } + + @Override + public void setSparkleFXCorrupt(boolean corrupt) { + corruptSparkle = corrupt; + } + + @Override + public void sparkleFX(World world, double x, double y, double z, float r, float g, float b, float size, int m, boolean fake) { + if(!doParticle(world) && !fake) + return; + + FXSparkle sparkle = new FXSparkle(world, x, y, z, size, r, g, b, m); + sparkle.fake = sparkle.noClip = fake; + if(noclipEnabled) + sparkle.noClip = true; + if(corruptSparkle) + sparkle.corrupt = true; + Minecraft.getMinecraft().effectRenderer.addEffect(sparkle); + } + + private static boolean distanceLimit = true; + private static boolean depthTest = true; + + @Override + public void setWispFXDistanceLimit(boolean limit) { + distanceLimit = limit; + } + + @Override + public void setWispFXDepthTest(boolean test) { + depthTest = test; + } + + @Override + public void wispFX(World world, double x, double y, double z, float r, float g, float b, float size, float motionx, float motiony, float motionz, float maxAgeMul) { + if(!doParticle(world)) + return; + + FXWisp wisp = new FXWisp(world, x, y, z, size, r, g, b, distanceLimit, depthTest, maxAgeMul); + wisp.motionX = motionx; + wisp.motionY = motiony; + wisp.motionZ = motionz; + + Minecraft.getMinecraft().effectRenderer.addEffect(wisp); + } + + private boolean doParticle(World world) { + if(!world.isRemote) + return false; + + if(!ConfigHandler.useVanillaParticleLimiter) + return true; + + float chance = 1F; + if(Minecraft.getMinecraft().gameSettings.particleSetting == 1) + chance = 0.6F; + else if(Minecraft.getMinecraft().gameSettings.particleSetting == 2) + chance = 0.2F; + + return chance == 1F || Math.random() < chance; + } + + @Override + public void lightningFX(World world, Vector3 vectorStart, Vector3 vectorEnd, float ticksPerMeter, long seed, int colorOuter, int colorInner) { + LightningHandler.spawnLightningBolt(world, vectorStart, vectorEnd, ticksPerMeter, seed, colorOuter, colorInner); + } } + diff --git a/src/main/java/vazkii/botania/client/core/proxy/GuiFactory.java b/src/main/java/vazkii/botania/client/core/proxy/GuiFactory.java index ded018ce14..2a558708d4 100644 --- a/src/main/java/vazkii/botania/client/core/proxy/GuiFactory.java +++ b/src/main/java/vazkii/botania/client/core/proxy/GuiFactory.java @@ -2,39 +2,41 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jun 27, 2014, 1:50:49 AM (GMT)] */ package vazkii.botania.client.core.proxy; -import cpw.mods.fml.client.IModGuiFactory; import java.util.Set; + import net.minecraft.client.Minecraft; import net.minecraft.client.gui.GuiScreen; import vazkii.botania.client.gui.GuiBotaniaConfig; +import cpw.mods.fml.client.IModGuiFactory; public class GuiFactory implements IModGuiFactory { - @Override - public void initialize(Minecraft minecraftInstance) { - // NO-OP - } - - @Override - public Class mainConfigGuiClass() { - return GuiBotaniaConfig.class; - } - - @Override - public Set runtimeGuiCategories() { - return null; - } - - @Override - public RuntimeOptionGuiHandler getHandlerFor(RuntimeOptionCategoryElement element) { - return null; - } + @Override + public void initialize(Minecraft minecraftInstance) { + // NO-OP + } + + @Override + public Class mainConfigGuiClass() { + return GuiBotaniaConfig.class; + } + + @Override + public Set runtimeGuiCategories() { + return null; + } + + @Override + public RuntimeOptionGuiHandler getHandlerFor(RuntimeOptionCategoryElement element) { + return null; + } + } diff --git a/src/main/java/vazkii/botania/client/fx/FXSparkle.java b/src/main/java/vazkii/botania/client/fx/FXSparkle.java index 89559f1e82..61a5636319 100644 --- a/src/main/java/vazkii/botania/client/fx/FXSparkle.java +++ b/src/main/java/vazkii/botania/client/fx/FXSparkle.java @@ -2,23 +2,26 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [? (GMT)] */ package vazkii.botania.client.fx; import java.util.ArrayDeque; import java.util.Queue; + import net.minecraft.client.Minecraft; import net.minecraft.client.particle.EntityFX; import net.minecraft.client.renderer.Tessellator; import net.minecraft.util.MathHelper; import net.minecraft.util.ResourceLocation; import net.minecraft.world.World; + import org.lwjgl.opengl.GL11; + import vazkii.botania.client.core.helper.ShaderHelper; import vazkii.botania.client.lib.LibResources; import vazkii.botania.common.core.handler.ConfigHandler; @@ -26,228 +29,230 @@ public class FXSparkle extends EntityFX { - public static final ResourceLocation particles = new ResourceLocation(LibResources.MISC_PARTICLES); - - public static Queue queuedRenders = new ArrayDeque(); - public static Queue queuedCorruptRenders = new ArrayDeque(); - - // Queue values - float f; - float f1; - float f2; - float f3; - float f4; - float f5; - - public FXSparkle(World world, double x, double y, double z, float size, float red, float green, float blue, int m) { - super(world, x, y, z, 0.0D, 0.0D, 0.0D); - - particleRed = red; - particleGreen = green; - particleBlue = blue; - particleGravity = 0; - motionX = motionY = motionZ = 0; - particleScale *= size; - particleMaxAge = 3 * m; - multiplier = m; - noClip = false; - setSize(0.01F, 0.01F); - prevPosX = posX; - prevPosY = posY; - prevPosZ = posZ; - } - - public static void dispatchQueuedRenders(Tessellator tessellator) { - ParticleRenderDispatcher.sparkleFxCount = 0; - ParticleRenderDispatcher.fakeSparkleFxCount = 0; - - GL11.glColor4f(1.0F, 1.0F, 1.0F, 0.75F); - Minecraft.getMinecraft() - .renderEngine - .bindTexture(ConfigHandler.matrixMode ? ObfuscationHelper.getParticleTexture() : particles); - - tessellator.startDrawingQuads(); - for (FXSparkle sparkle : queuedRenders) sparkle.renderQueued(tessellator); - tessellator.draw(); - - ShaderHelper.useShader(ShaderHelper.filmGrain); - tessellator.startDrawingQuads(); - for (FXSparkle sparkle : queuedCorruptRenders) sparkle.renderQueued(tessellator); - tessellator.draw(); - ShaderHelper.releaseShader(); - - queuedRenders.clear(); - queuedCorruptRenders.clear(); - } - - private void renderQueued(Tessellator tessellator) { - if (fake) ParticleRenderDispatcher.fakeSparkleFxCount++; - else ParticleRenderDispatcher.sparkleFxCount++; - - int part = particle + particleAge / multiplier; - - float var8 = part % 8 / 8.0F; - float var9 = var8 + 0.0624375F * 2; - float var10 = part / 8 / 8.0F; - float var11 = var10 + 0.0624375F * 2; - float var12 = 0.1F * particleScale; - if (shrink) var12 *= (particleMaxAge - particleAge + 1) / (float) particleMaxAge; - float var13 = (float) (prevPosX + (posX - prevPosX) * f - interpPosX); - float var14 = (float) (prevPosY + (posY - prevPosY) * f - interpPosY); - float var15 = (float) (prevPosZ + (posZ - prevPosZ) * f - interpPosZ); - float var16 = 1.0F; - - tessellator.setBrightness(0x0000f0); - - tessellator.setColorRGBA_F(particleRed * var16, particleGreen * var16, particleBlue * var16, 1); - tessellator.addVertexWithUV( - var13 - f1 * var12 - f4 * var12, var14 - f2 * var12, var15 - f3 * var12 - f5 * var12, var9, var11); - tessellator.addVertexWithUV( - var13 - f1 * var12 + f4 * var12, var14 + f2 * var12, var15 - f3 * var12 + f5 * var12, var9, var10); - tessellator.addVertexWithUV( - var13 + f1 * var12 + f4 * var12, var14 + f2 * var12, var15 + f3 * var12 + f5 * var12, var8, var10); - tessellator.addVertexWithUV( - var13 + f1 * var12 - f4 * var12, var14 - f2 * var12, var15 + f3 * var12 - f5 * var12, var8, var11); - } - - @Override - public void renderParticle(Tessellator tessellator, float f, float f1, float f2, float f3, float f4, float f5) { - this.f = f; - this.f1 = f1; - this.f2 = f2; - this.f3 = f3; - this.f4 = f4; - this.f5 = f5; - - if (corrupt) queuedCorruptRenders.add(this); - else queuedRenders.add(this); - } - - @Override - public void onUpdate() { - prevPosX = posX; - prevPosY = posY; - prevPosZ = posZ; - - if (particleAge++ >= particleMaxAge) setDead(); - - motionY -= 0.04D * particleGravity; - - if (!noClip && !fake) pushOutOfBlocks(posX, (boundingBox.minY + boundingBox.maxY) / 2.0D, posZ); - - posX += motionX; - posY += motionY; - posZ += motionZ; - - if (slowdown) { - motionX *= 0.908000001907348633D; - motionY *= 0.908000001907348633D; - motionZ *= 0.908000001907348633D; - - if (onGround) { - motionX *= 0.69999998807907104D; - motionZ *= 0.69999998807907104D; - } - } - - if (fake && particleAge > 1) setDead(); - } - - public void setGravity(float value) { - particleGravity = value; - } - - protected boolean pushOutOfBlocks(double par1, double par3, double par5) { - int var7 = MathHelper.floor_double(par1); - int var8 = MathHelper.floor_double(par3); - int var9 = MathHelper.floor_double(par5); - double var10 = par1 - var7; - double var12 = par3 - var8; - double var14 = par5 - var9; - - if (!worldObj.isAirBlock(var7, var8, var9)) { - boolean var16 = !worldObj.isBlockNormalCubeDefault(var7 - 1, var8, var9, false); - boolean var17 = !worldObj.isBlockNormalCubeDefault(var7 + 1, var8, var9, false); - boolean var18 = !worldObj.isBlockNormalCubeDefault(var7, var8 - 1, var9, false); - boolean var19 = !worldObj.isBlockNormalCubeDefault(var7, var8 + 1, var9, false); - boolean var20 = !worldObj.isBlockNormalCubeDefault(var7, var8, var9 - 1, false); - boolean var21 = !worldObj.isBlockNormalCubeDefault(var7, var8, var9 + 1, false); - byte var22 = -1; - double var23 = 9999.0D; - - if (var16 && var10 < var23) { - var23 = var10; - var22 = 0; - } - - if (var17 && 1.0D - var10 < var23) { - var23 = 1.0D - var10; - var22 = 1; - } - - if (var18 && var12 < var23) { - var23 = var12; - var22 = 2; - } - - if (var19 && 1.0D - var12 < var23) { - var23 = 1.0D - var12; - var22 = 3; - } - - if (var20 && var14 < var23) { - var23 = var14; - var22 = 4; - } - - if (var21 && 1.0D - var14 < var23) { - var23 = 1.0D - var14; - var22 = 5; - } - - float var25 = rand.nextFloat() * 0.05F + 0.025F; - float var26 = (rand.nextFloat() - rand.nextFloat()) * 0.1F; - - if (var22 == 0) { - motionX = -var25; - motionY = motionZ = var26; - } - - if (var22 == 1) { - motionX = var25; - motionY = motionZ = var26; - } - - if (var22 == 2) { - motionY = -var25; - motionX = motionZ = var26; - } - - if (var22 == 3) { - motionY = var25; - motionX = motionZ = var26; - } - - if (var22 == 4) { - motionZ = -var25; - motionY = motionX = var26; - } - - if (var22 == 5) { - motionZ = var25; - motionY = motionX = var26; - } - - return true; - } else return false; - } - - public boolean corrupt = false; - public boolean fake = false; - public int multiplier = 2; - public boolean shrink = true; - public int particle = 16; - public boolean tinkle = false; - public boolean slowdown = true; - public int currentColor = 0; + public static final ResourceLocation particles = new ResourceLocation(LibResources.MISC_PARTICLES); + + public static Queue queuedRenders = new ArrayDeque(); + public static Queue queuedCorruptRenders = new ArrayDeque(); + + // Queue values + float f; + float f1; + float f2; + float f3; + float f4; + float f5; + + public FXSparkle(World world, double x, double y, double z, float size, float red, float green, float blue, int m) { + super(world, x, y, z, 0.0D, 0.0D, 0.0D); + + particleRed = red; + particleGreen = green; + particleBlue = blue; + particleGravity = 0; + motionX = motionY = motionZ = 0; + particleScale *= size; + particleMaxAge = 3 * m; + multiplier = m; + noClip = false; + setSize(0.01F, 0.01F); + prevPosX = posX; + prevPosY = posY; + prevPosZ = posZ; + } + + public static void dispatchQueuedRenders(Tessellator tessellator) { + ParticleRenderDispatcher.sparkleFxCount = 0; + ParticleRenderDispatcher.fakeSparkleFxCount = 0; + + GL11.glColor4f(1.0F, 1.0F, 1.0F, 0.75F); + Minecraft.getMinecraft().renderEngine.bindTexture(ConfigHandler.matrixMode ? ObfuscationHelper.getParticleTexture() : particles); + + tessellator.startDrawingQuads(); + for(FXSparkle sparkle : queuedRenders) + sparkle.renderQueued(tessellator); + tessellator.draw(); + + ShaderHelper.useShader(ShaderHelper.filmGrain); + tessellator.startDrawingQuads(); + for(FXSparkle sparkle : queuedCorruptRenders) + sparkle.renderQueued(tessellator); + tessellator.draw(); + ShaderHelper.releaseShader(); + + queuedRenders.clear(); + queuedCorruptRenders.clear(); + } + + private void renderQueued(Tessellator tessellator) { + if(fake) + ParticleRenderDispatcher.fakeSparkleFxCount++; + else ParticleRenderDispatcher.sparkleFxCount++; + + int part = particle + particleAge/multiplier; + + float var8 = part % 8 / 8.0F; + float var9 = var8 + 0.0624375F*2; + float var10 = part / 8 / 8.0F; + float var11 = var10 + 0.0624375F*2; + float var12 = 0.1F * particleScale; + if (shrink) var12 *= (particleMaxAge-particleAge+1)/(float)particleMaxAge; + float var13 = (float)(prevPosX + (posX - prevPosX) * f - interpPosX); + float var14 = (float)(prevPosY + (posY - prevPosY) * f - interpPosY); + float var15 = (float)(prevPosZ + (posZ - prevPosZ) * f - interpPosZ); + float var16 = 1.0F; + + tessellator.setBrightness(0x0000f0); + + tessellator.setColorRGBA_F(particleRed * var16, particleGreen * var16, particleBlue * var16, 1); + tessellator.addVertexWithUV(var13 - f1 * var12 - f4 * var12, var14 - f2 * var12, var15 - f3 * var12 - f5 * var12, var9, var11); + tessellator.addVertexWithUV(var13 - f1 * var12 + f4 * var12, var14 + f2 * var12, var15 - f3 * var12 + f5 * var12, var9, var10); + tessellator.addVertexWithUV(var13 + f1 * var12 + f4 * var12, var14 + f2 * var12, var15 + f3 * var12 + f5 * var12, var8, var10); + tessellator.addVertexWithUV(var13 + f1 * var12 - f4 * var12, var14 - f2 * var12, var15 + f3 * var12 - f5 * var12, var8, var11); + + } + + @Override + public void renderParticle(Tessellator tessellator, float f, float f1, float f2, float f3, float f4, float f5) { + this.f = f; + this.f1 = f1; + this.f2 = f2; + this.f3 = f3; + this.f4 = f4; + this.f5 = f5; + + if(corrupt) + queuedCorruptRenders.add(this); + else queuedRenders.add(this); + } + + @Override + public void onUpdate() { + prevPosX = posX; + prevPosY = posY; + prevPosZ = posZ; + + if (particleAge++ >= particleMaxAge) + setDead(); + + motionY -= 0.04D * particleGravity; + + if (!noClip && !fake) + pushOutOfBlocks(posX, (boundingBox.minY + boundingBox.maxY) / 2.0D, posZ); + + posX += motionX; + posY += motionY; + posZ += motionZ; + + if (slowdown) { + motionX *= 0.908000001907348633D; + motionY *= 0.908000001907348633D; + motionZ *= 0.908000001907348633D; + + if (onGround) { + motionX *= 0.69999998807907104D; + motionZ *= 0.69999998807907104D; + } + } + + if(fake && particleAge > 1) + setDead(); + } + + public void setGravity(float value) { + particleGravity = value; + } + + protected boolean pushOutOfBlocks(double par1, double par3, double par5) { + int var7 = MathHelper.floor_double(par1); + int var8 = MathHelper.floor_double(par3); + int var9 = MathHelper.floor_double(par5); + double var10 = par1 - var7; + double var12 = par3 - var8; + double var14 = par5 - var9; + + if (!worldObj.isAirBlock(var7, var8, var9)) { + boolean var16 = !worldObj.isBlockNormalCubeDefault(var7 - 1, var8, var9, false); + boolean var17 = !worldObj.isBlockNormalCubeDefault(var7 + 1, var8, var9, false); + boolean var18 = !worldObj.isBlockNormalCubeDefault(var7, var8 - 1, var9, false); + boolean var19 = !worldObj.isBlockNormalCubeDefault(var7, var8 + 1, var9, false); + boolean var20 = !worldObj.isBlockNormalCubeDefault(var7, var8, var9 - 1, false); + boolean var21 = !worldObj.isBlockNormalCubeDefault(var7, var8, var9 + 1, false); + byte var22 = -1; + double var23 = 9999.0D; + + if (var16 && var10 < var23) { + var23 = var10; + var22 = 0; + } + + if (var17 && 1.0D - var10 < var23) { + var23 = 1.0D - var10; + var22 = 1; + } + + if (var18 && var12 < var23) { + var23 = var12; + var22 = 2; + } + + if (var19 && 1.0D - var12 < var23) { + var23 = 1.0D - var12; + var22 = 3; + } + + if (var20 && var14 < var23) { + var23 = var14; + var22 = 4; + } + + if (var21 && 1.0D - var14 < var23) { + var23 = 1.0D - var14; + var22 = 5; + } + + float var25 = rand.nextFloat() * 0.05F + 0.025F; + float var26 = (rand.nextFloat() - rand.nextFloat()) * 0.1F; + + if (var22 == 0) { + motionX = -var25; + motionY=motionZ=var26; + } + + if (var22 == 1) { + motionX = var25; + motionY=motionZ=var26; + } + + if (var22 == 2) { + motionY = -var25; + motionX=motionZ=var26; + } + + if (var22 == 3) { + motionY = var25; + motionX=motionZ=var26; + } + + if (var22 == 4) { + motionZ = -var25; + motionY=motionX=var26; + } + + if (var22 == 5) { + motionZ = var25; + motionY=motionX=var26; + } + + return true; + } else return false; + } + + public boolean corrupt = false; + public boolean fake = false; + public int multiplier = 2; + public boolean shrink = true; + public int particle = 16; + public boolean tinkle = false; + public boolean slowdown = true; + public int currentColor = 0; } diff --git a/src/main/java/vazkii/botania/client/fx/FXWisp.java b/src/main/java/vazkii/botania/client/fx/FXWisp.java index 2369b461dc..05ad91c989 100644 --- a/src/main/java/vazkii/botania/client/fx/FXWisp.java +++ b/src/main/java/vazkii/botania/client/fx/FXWisp.java @@ -2,172 +2,169 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [? (GMT)] */ package vazkii.botania.client.fx; -import cpw.mods.fml.client.FMLClientHandler; import java.util.ArrayDeque; import java.util.Queue; + import net.minecraft.client.Minecraft; import net.minecraft.client.particle.EntityFX; import net.minecraft.client.renderer.Tessellator; import net.minecraft.entity.EntityLivingBase; import net.minecraft.util.ResourceLocation; import net.minecraft.world.World; + import org.lwjgl.opengl.GL11; + import vazkii.botania.client.lib.LibResources; import vazkii.botania.common.core.handler.ConfigHandler; import vazkii.botania.common.core.helper.ObfuscationHelper; +import cpw.mods.fml.client.FMLClientHandler; public class FXWisp extends EntityFX { - public static final ResourceLocation particles = new ResourceLocation(LibResources.MISC_WISP_LARGE); - - public static Queue queuedRenders = new ArrayDeque(); - public static Queue queuedDepthIgnoringRenders = new ArrayDeque(); - - // Queue values - float f; - float f1; - float f2; - float f3; - float f4; - float f5; - - public FXWisp( - World world, - double d, - double d1, - double d2, - float size, - float red, - float green, - float blue, - boolean distanceLimit, - boolean depthTest, - float maxAgeMul) { - super(world, d, d1, d2, 0.0D, 0.0D, 0.0D); - particleRed = red; - particleGreen = green; - particleBlue = blue; - particleGravity = 0; - motionX = motionY = motionZ = 0; - particleScale *= size; - moteParticleScale = particleScale; - particleMaxAge = (int) (28D / (Math.random() * 0.3D + 0.7D) * maxAgeMul); - this.depthTest = depthTest; - - moteHalfLife = particleMaxAge / 2; - noClip = true; - setSize(0.01F, 0.01F); - EntityLivingBase renderentity = FMLClientHandler.instance().getClient().renderViewEntity; - - if (distanceLimit) { - int visibleDistance = 50; - if (!FMLClientHandler.instance().getClient().gameSettings.fancyGraphics) visibleDistance = 25; - - if (renderentity == null || renderentity.getDistance(posX, posY, posZ) > visibleDistance) - particleMaxAge = 0; - } - - prevPosX = posX; - prevPosY = posY; - prevPosZ = posZ; - } - - public static void dispatchQueuedRenders(Tessellator tessellator) { - ParticleRenderDispatcher.wispFxCount = 0; - ParticleRenderDispatcher.depthIgnoringWispFxCount = 0; - - GL11.glColor4f(1.0F, 1.0F, 1.0F, 0.75F); - Minecraft.getMinecraft() - .renderEngine - .bindTexture(ConfigHandler.matrixMode ? ObfuscationHelper.getParticleTexture() : particles); - - if (!queuedRenders.isEmpty()) { - tessellator.startDrawingQuads(); - for (FXWisp wisp : queuedRenders) wisp.renderQueued(tessellator, true); - tessellator.draw(); - } - - if (!queuedDepthIgnoringRenders.isEmpty()) { - GL11.glDisable(GL11.GL_DEPTH_TEST); - tessellator.startDrawingQuads(); - for (FXWisp wisp : queuedDepthIgnoringRenders) wisp.renderQueued(tessellator, false); - tessellator.draw(); - GL11.glEnable(GL11.GL_DEPTH_TEST); - } - - queuedRenders.clear(); - queuedDepthIgnoringRenders.clear(); - } - - private void renderQueued(Tessellator tessellator, boolean depthEnabled) { - if (depthEnabled) ParticleRenderDispatcher.wispFxCount++; - else ParticleRenderDispatcher.depthIgnoringWispFxCount++; - - float agescale = 0; - agescale = (float) particleAge / (float) moteHalfLife; - if (agescale > 1F) agescale = 2 - agescale; - - particleScale = moteParticleScale * agescale; - - float f10 = 0.5F * 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); - - tessellator.setBrightness(240); - tessellator.setColorRGBA_F(particleRed, particleGreen, particleBlue, 0.5F); - 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); - } - - @Override - public void renderParticle(Tessellator tessellator, float f, float f1, float f2, float f3, float f4, float f5) { - this.f = f; - this.f1 = f1; - this.f2 = f2; - this.f3 = f3; - this.f4 = f4; - this.f5 = f5; - - if (depthTest) queuedRenders.add(this); - else queuedDepthIgnoringRenders.add(this); - } - - @Override - public void onUpdate() { - prevPosX = posX; - prevPosY = posY; - prevPosZ = posZ; - - if (particleAge++ >= particleMaxAge) setDead(); - - motionY -= 0.04D * particleGravity; - posX += motionX; - posY += motionY; - posZ += motionZ; - motionX *= 0.98000001907348633D; - motionY *= 0.98000001907348633D; - motionZ *= 0.98000001907348633D; - } - - public void setGravity(float value) { - particleGravity = value; - } - - boolean depthTest = true; - public boolean distanceLimit = true; - float moteParticleScale; - int moteHalfLife; - public boolean tinkle = false; - public int blendmode = 1; + public static final ResourceLocation particles = new ResourceLocation(LibResources.MISC_WISP_LARGE); + + public static Queue queuedRenders = new ArrayDeque(); + public static Queue queuedDepthIgnoringRenders = new ArrayDeque(); + + // Queue values + float f; + float f1; + float f2; + float f3; + float f4; + float f5; + + public FXWisp(World world, double d, double d1, double d2, float size, float red, float green, float blue, boolean distanceLimit, boolean depthTest, float maxAgeMul) { + super(world, d, d1, d2, 0.0D, 0.0D, 0.0D); + particleRed = red; + particleGreen = green; + particleBlue = blue; + particleGravity = 0; + motionX = motionY = motionZ = 0; + particleScale *= size; + moteParticleScale = particleScale; + particleMaxAge = (int)(28D / (Math.random() * 0.3D + 0.7D) * maxAgeMul); + this.depthTest = depthTest; + + moteHalfLife = particleMaxAge / 2; + noClip = true; + setSize(0.01F, 0.01F); + EntityLivingBase renderentity = FMLClientHandler.instance().getClient().renderViewEntity; + + if(distanceLimit) { + int visibleDistance = 50; + if (!FMLClientHandler.instance().getClient().gameSettings.fancyGraphics) + visibleDistance = 25; + + if (renderentity == null || renderentity.getDistance(posX, posY, posZ) > visibleDistance) + particleMaxAge = 0; + } + + prevPosX = posX; + prevPosY = posY; + prevPosZ = posZ; + } + + public static void dispatchQueuedRenders(Tessellator tessellator) { + ParticleRenderDispatcher.wispFxCount = 0; + ParticleRenderDispatcher.depthIgnoringWispFxCount = 0; + + GL11.glColor4f(1.0F, 1.0F, 1.0F, 0.75F); + Minecraft.getMinecraft().renderEngine.bindTexture(ConfigHandler.matrixMode ? ObfuscationHelper.getParticleTexture() : particles); + + if(!queuedRenders.isEmpty()) { + tessellator.startDrawingQuads(); + for(FXWisp wisp : queuedRenders) + wisp.renderQueued(tessellator, true); + tessellator.draw(); + } + + if(!queuedDepthIgnoringRenders.isEmpty()) { + GL11.glDisable(GL11.GL_DEPTH_TEST); + tessellator.startDrawingQuads(); + for(FXWisp wisp : queuedDepthIgnoringRenders) + wisp.renderQueued(tessellator, false); + tessellator.draw(); + GL11.glEnable(GL11.GL_DEPTH_TEST); + } + + queuedRenders.clear(); + queuedDepthIgnoringRenders.clear(); + } + + private void renderQueued(Tessellator tessellator, boolean depthEnabled) { + if(depthEnabled) + ParticleRenderDispatcher.wispFxCount++; + else ParticleRenderDispatcher.depthIgnoringWispFxCount++; + + float agescale = 0; + agescale = (float)particleAge / (float) moteHalfLife; + if (agescale > 1F) + agescale = 2 - agescale; + + particleScale = moteParticleScale * agescale; + + float f10 = 0.5F * 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); + + tessellator.setBrightness(240); + tessellator.setColorRGBA_F(particleRed, particleGreen, particleBlue, 0.5F); + 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); + } + + @Override + public void renderParticle(Tessellator tessellator, float f, float f1, float f2, float f3, float f4, float f5) { + this.f = f; + this.f1 = f1; + this.f2 = f2; + this.f3 = f3; + this.f4 = f4; + this.f5 = f5; + + if(depthTest) + queuedRenders.add(this); + else queuedDepthIgnoringRenders.add(this); + } + + @Override + public void onUpdate() { + prevPosX = posX; + prevPosY = posY; + prevPosZ = posZ; + + if (particleAge++ >= particleMaxAge) + setDead(); + + motionY -= 0.04D * particleGravity; + posX += motionX; + posY += motionY; + posZ += motionZ; + motionX *= 0.98000001907348633D; + motionY *= 0.98000001907348633D; + motionZ *= 0.98000001907348633D; + } + + public void setGravity(float value) { + particleGravity = value; + } + + boolean depthTest = true; + public boolean distanceLimit = true; + float moteParticleScale; + int moteHalfLife; + public boolean tinkle = false; + public int blendmode = 1; } diff --git a/src/main/java/vazkii/botania/client/fx/ParticleRenderDispatcher.java b/src/main/java/vazkii/botania/client/fx/ParticleRenderDispatcher.java index 5adea9a5a3..51915027f7 100644 --- a/src/main/java/vazkii/botania/client/fx/ParticleRenderDispatcher.java +++ b/src/main/java/vazkii/botania/client/fx/ParticleRenderDispatcher.java @@ -2,11 +2,11 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under a * Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License * (http://creativecommons.org/licenses/by-nc-sa/3.0/deed.en_GB) - * + * * File Created @ [Jul 2, 2014, 12:12:45 AM (GMT)] */ package vazkii.botania.client.fx; @@ -14,39 +14,41 @@ import net.minecraft.client.Minecraft; import net.minecraft.client.renderer.Tessellator; import net.minecraft.profiler.Profiler; + import org.lwjgl.opengl.GL11; public final class ParticleRenderDispatcher { - public static int wispFxCount = 0; - public static int depthIgnoringWispFxCount = 0; - public static int sparkleFxCount = 0; - public static int fakeSparkleFxCount = 0; - public static int lightningCount = 0; - - // Called from LightningHandler.onRenderWorldLast since that was - // already registered. /shrug - public static void dispatch() { - Tessellator tessellator = Tessellator.instance; - - Profiler profiler = Minecraft.getMinecraft().mcProfiler; - - GL11.glPushAttrib(GL11.GL_LIGHTING); - GL11.glDepthMask(false); - GL11.glEnable(GL11.GL_BLEND); - GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE); - GL11.glAlphaFunc(GL11.GL_GREATER, 0.003921569F); - GL11.glDisable(GL11.GL_LIGHTING); - - profiler.startSection("sparkle"); - FXSparkle.dispatchQueuedRenders(tessellator); - profiler.endStartSection("wisp"); - FXWisp.dispatchQueuedRenders(tessellator); - profiler.endSection(); - - GL11.glAlphaFunc(GL11.GL_GREATER, 0.1F); - GL11.glDisable(GL11.GL_BLEND); - GL11.glDepthMask(true); - GL11.glPopAttrib(); - } + public static int wispFxCount = 0; + public static int depthIgnoringWispFxCount = 0; + public static int sparkleFxCount = 0; + public static int fakeSparkleFxCount = 0; + public static int lightningCount = 0; + + // Called from LightningHandler.onRenderWorldLast since that was + // already registered. /shrug + public static void dispatch() { + Tessellator tessellator = Tessellator.instance; + + Profiler profiler = Minecraft.getMinecraft().mcProfiler; + + GL11.glPushAttrib(GL11.GL_LIGHTING); + GL11.glDepthMask(false); + GL11.glEnable(GL11.GL_BLEND); + GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE); + GL11.glAlphaFunc(GL11.GL_GREATER, 0.003921569F); + GL11.glDisable(GL11.GL_LIGHTING); + + profiler.startSection("sparkle"); + FXSparkle.dispatchQueuedRenders(tessellator); + profiler.endStartSection("wisp"); + FXWisp.dispatchQueuedRenders(tessellator); + profiler.endSection(); + + GL11.glAlphaFunc(GL11.GL_GREATER, 0.1F); + GL11.glDisable(GL11.GL_BLEND); + GL11.glDepthMask(true); + GL11.glPopAttrib(); + } + } diff --git a/src/main/java/vazkii/botania/client/gui/GuiAchievementsHacky.java b/src/main/java/vazkii/botania/client/gui/GuiAchievementsHacky.java index 19d1fe05cf..9891b66ed3 100644 --- a/src/main/java/vazkii/botania/client/gui/GuiAchievementsHacky.java +++ b/src/main/java/vazkii/botania/client/gui/GuiAchievementsHacky.java @@ -2,31 +2,32 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Apr 3, 2015, 5:55:36 PM (GMT)] */ package vazkii.botania.client.gui; -import cpw.mods.fml.relauncher.ReflectionHelper; import net.minecraft.client.gui.GuiButton; import net.minecraft.client.gui.GuiScreen; import net.minecraft.client.gui.achievement.GuiAchievements; import net.minecraft.stats.StatFileWriter; import vazkii.botania.common.achievement.ModAchievements; +import cpw.mods.fml.relauncher.ReflectionHelper; public class GuiAchievementsHacky extends GuiAchievements { - public GuiAchievementsHacky(GuiScreen p_i45026_1_, StatFileWriter p_i45026_2_) { - super(p_i45026_1_, p_i45026_2_); - ReflectionHelper.setPrivateValue(GuiAchievements.class, this, ModAchievements.pageIndex, "currentPage"); - } + public GuiAchievementsHacky(GuiScreen p_i45026_1_, StatFileWriter p_i45026_2_) { + super(p_i45026_1_, p_i45026_2_); + ReflectionHelper.setPrivateValue(GuiAchievements.class, this, ModAchievements.pageIndex, "currentPage"); + } + + @Override + public void initGui() { + super.initGui(); + ((GuiButton) buttonList.get(1)).displayString = ModAchievements.botaniaPage.getName(); + } - @Override - public void initGui() { - super.initGui(); - ((GuiButton) buttonList.get(1)).displayString = ModAchievements.botaniaPage.getName(); - } } diff --git a/src/main/java/vazkii/botania/client/gui/GuiBotaniaConfig.java b/src/main/java/vazkii/botania/client/gui/GuiBotaniaConfig.java index c1b2ebaaa6..4f9d20e1b1 100644 --- a/src/main/java/vazkii/botania/client/gui/GuiBotaniaConfig.java +++ b/src/main/java/vazkii/botania/client/gui/GuiBotaniaConfig.java @@ -2,30 +2,25 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jun 27, 2014, 1:52:33 AM (GMT)] */ package vazkii.botania.client.gui; -import cpw.mods.fml.client.config.GuiConfig; import net.minecraft.client.gui.GuiScreen; import net.minecraftforge.common.config.ConfigElement; import net.minecraftforge.common.config.Configuration; import vazkii.botania.common.core.handler.ConfigHandler; import vazkii.botania.common.lib.LibMisc; +import cpw.mods.fml.client.config.GuiConfig; public class GuiBotaniaConfig extends GuiConfig { - public GuiBotaniaConfig(GuiScreen parentScreen) { - super( - parentScreen, - new ConfigElement(ConfigHandler.config.getCategory(Configuration.CATEGORY_GENERAL)).getChildElements(), - LibMisc.MOD_ID, - false, - false, - GuiConfig.getAbridgedConfigPath(ConfigHandler.config.toString())); - } + public GuiBotaniaConfig(GuiScreen parentScreen) { + super(parentScreen, new ConfigElement(ConfigHandler.config.getCategory(Configuration.CATEGORY_GENERAL)).getChildElements(), LibMisc.MOD_ID, false, false, GuiConfig.getAbridgedConfigPath(ConfigHandler.config.toString())); + } + } diff --git a/src/main/java/vazkii/botania/client/gui/SlotLocked.java b/src/main/java/vazkii/botania/client/gui/SlotLocked.java index 1bfe03ff01..72b7ccadd5 100644 --- a/src/main/java/vazkii/botania/client/gui/SlotLocked.java +++ b/src/main/java/vazkii/botania/client/gui/SlotLocked.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Sep 6, 2015, 1:11:25 AM (GMT)] */ package vazkii.botania.client.gui; @@ -17,17 +17,18 @@ public class SlotLocked extends Slot { - public SlotLocked(IInventory p_i1824_1_, int p_i1824_2_, int p_i1824_3_, int p_i1824_4_) { - super(p_i1824_1_, p_i1824_2_, p_i1824_3_, p_i1824_4_); - } + public SlotLocked(IInventory p_i1824_1_, int p_i1824_2_, int p_i1824_3_, int p_i1824_4_) { + super(p_i1824_1_, p_i1824_2_, p_i1824_3_, p_i1824_4_); + } - @Override - public boolean canTakeStack(EntityPlayer p_82869_1_) { - return false; - } + @Override + public boolean canTakeStack(EntityPlayer p_82869_1_) { + return false; + } + + @Override + public boolean isItemValid(ItemStack p_75214_1_) { + return false; + } - @Override - public boolean isItemValid(ItemStack p_75214_1_) { - return false; - } } diff --git a/src/main/java/vazkii/botania/client/gui/bag/ContainerFlowerBag.java b/src/main/java/vazkii/botania/client/gui/bag/ContainerFlowerBag.java index dabce7e0d2..5160afa2a3 100644 --- a/src/main/java/vazkii/botania/client/gui/bag/ContainerFlowerBag.java +++ b/src/main/java/vazkii/botania/client/gui/bag/ContainerFlowerBag.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Mar 16, 2015, 6:42:40 PM (GMT)] */ package vazkii.botania.client.gui.bag; @@ -19,72 +19,81 @@ public class ContainerFlowerBag extends Container { - InventoryFlowerBag flowerBagInv; - - public ContainerFlowerBag(EntityPlayer player) { - int i; - int j; - - int slot = player.inventory.currentItem; - IInventory playerInv = player.inventory; - flowerBagInv = new InventoryFlowerBag(player, slot); - - for (i = 0; i < 2; ++i) - for (j = 0; j < 8; ++j) { - int k = j + i * 8; - addSlotToContainer(new SlotFlower(flowerBagInv, k, 17 + j * 18, 26 + i * 18, k)); - } - - for (i = 0; i < 3; ++i) - for (j = 0; j < 9; ++j) addSlotToContainer(new Slot(playerInv, j + i * 9 + 9, 8 + j * 18, 84 + i * 18)); - - for (i = 0; i < 9; ++i) { - if (player.inventory.currentItem == i) addSlotToContainer(new SlotLocked(playerInv, i, 8 + i * 18, 142)); - else addSlotToContainer(new Slot(playerInv, i, 8 + i * 18, 142)); - } - } - - @Override - public boolean canInteractWith(EntityPlayer player) { - boolean can = flowerBagInv.isUseableByPlayer(player); - if (!can) onContainerClosed(player); - - return can; - } - - @Override - public void onContainerClosed(EntityPlayer player) { - super.onContainerClosed(player); - flowerBagInv.pushInventory(); - } - - @Override - public ItemStack transferStackInSlot(EntityPlayer p_82846_1_, int p_82846_2_) { - ItemStack itemstack = null; - Slot slot = (Slot) inventorySlots.get(p_82846_2_); - - if (slot != null && slot.getHasStack()) { - ItemStack itemstack1 = slot.getStack(); - itemstack = itemstack1.copy(); - - if (p_82846_2_ < 16) { - if (!mergeItemStack(itemstack1, 16, 52, true)) return null; - } else { - int i = itemstack.getItemDamage(); - if (i < 16) { - Slot slot1 = (Slot) inventorySlots.get(i); - if (slot1.isItemValid(itemstack) && !mergeItemStack(itemstack1, i, i + 1, true)) return null; - } - } - - if (itemstack1.stackSize == 0) slot.putStack((ItemStack) null); - else slot.onSlotChanged(); - - if (itemstack1.stackSize == itemstack.stackSize) return null; - - slot.onPickupFromSlot(p_82846_1_, itemstack1); - } - - return itemstack; - } + InventoryFlowerBag flowerBagInv; + + public ContainerFlowerBag(EntityPlayer player) { + int i; + int j; + + int slot = player.inventory.currentItem; + IInventory playerInv = player.inventory; + flowerBagInv = new InventoryFlowerBag(player, slot); + + for(i = 0; i < 2; ++i) + for(j = 0; j < 8; ++j) { + int k = j + i * 8; + addSlotToContainer(new SlotFlower(flowerBagInv, k, 17 + j * 18, 26 + i * 18, k)); + } + + for(i = 0; i < 3; ++i) + for(j = 0; j < 9; ++j) + addSlotToContainer(new Slot(playerInv, j + i * 9 + 9, 8 + j * 18, 84 + i * 18)); + + for(i = 0; i < 9; ++i) { + if(player.inventory.currentItem == i) + addSlotToContainer(new SlotLocked(playerInv, i, 8 + i * 18, 142)); + else addSlotToContainer(new Slot(playerInv, i, 8 + i * 18, 142)); + } + + } + + @Override + public boolean canInteractWith(EntityPlayer player) { + boolean can = flowerBagInv.isUseableByPlayer(player); + if(!can) + onContainerClosed(player); + + return can; + } + + @Override + public void onContainerClosed(EntityPlayer player) { + super.onContainerClosed(player); + flowerBagInv.pushInventory(); + } + + @Override + public ItemStack transferStackInSlot(EntityPlayer p_82846_1_, int p_82846_2_) { + ItemStack itemstack = null; + Slot slot = (Slot)inventorySlots.get(p_82846_2_); + + if(slot != null && slot.getHasStack()) { + ItemStack itemstack1 = slot.getStack(); + itemstack = itemstack1.copy(); + + if(p_82846_2_ < 16) { + if(!mergeItemStack(itemstack1, 16, 52, true)) + return null; + } else { + int i = itemstack.getItemDamage(); + if(i < 16) { + Slot slot1 = (Slot)inventorySlots.get(i); + if(slot1.isItemValid(itemstack) && !mergeItemStack(itemstack1, i, i + 1, true)) + return null; + } + } + + if(itemstack1.stackSize == 0) + slot.putStack((ItemStack)null); + else slot.onSlotChanged(); + + if(itemstack1.stackSize == itemstack.stackSize) + return null; + + slot.onPickupFromSlot(p_82846_1_, itemstack1); + } + + return itemstack; + } + } diff --git a/src/main/java/vazkii/botania/client/gui/bag/GuiFlowerBag.java b/src/main/java/vazkii/botania/client/gui/bag/GuiFlowerBag.java index ef30040453..b3cee8997c 100644 --- a/src/main/java/vazkii/botania/client/gui/bag/GuiFlowerBag.java +++ b/src/main/java/vazkii/botania/client/gui/bag/GuiFlowerBag.java @@ -2,15 +2,16 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Mar 16, 2015, 6:42:43 PM (GMT)] */ package vazkii.botania.client.gui.bag; import java.util.List; + import net.minecraft.client.gui.inventory.GuiContainer; import net.minecraft.client.renderer.RenderHelper; import net.minecraft.client.renderer.entity.RenderItem; @@ -20,51 +21,54 @@ import net.minecraft.item.ItemStack; import net.minecraft.util.ResourceLocation; import net.minecraft.util.StatCollector; + import org.lwjgl.opengl.GL11; + import vazkii.botania.client.lib.LibResources; import vazkii.botania.common.block.ModBlocks; public class GuiFlowerBag extends GuiContainer { - private static final ResourceLocation texture = new ResourceLocation(LibResources.GUI_FLOWER_BAG); + private static final ResourceLocation texture = new ResourceLocation(LibResources.GUI_FLOWER_BAG); + + public GuiFlowerBag(EntityPlayer player) { + super(new ContainerFlowerBag(player)); + } - public GuiFlowerBag(EntityPlayer player) { - super(new ContainerFlowerBag(player)); - } + @Override + protected void drawGuiContainerForegroundLayer(int p_146979_1_, int p_146979_2_) { + String s = StatCollector.translateToLocal("item.botania:flowerBag.name"); + fontRendererObj.drawString(s, xSize / 2 - fontRendererObj.getStringWidth(s) / 2, 6, 4210752); + fontRendererObj.drawString(I18n.format("container.inventory", new Object[0]), 8, ySize - 96 + 2, 4210752); + } - @Override - protected void drawGuiContainerForegroundLayer(int p_146979_1_, int p_146979_2_) { - String s = StatCollector.translateToLocal("item.botania:flowerBag.name"); - fontRendererObj.drawString(s, xSize / 2 - fontRendererObj.getStringWidth(s) / 2, 6, 4210752); - fontRendererObj.drawString(I18n.format("container.inventory", new Object[0]), 8, ySize - 96 + 2, 4210752); - } + @Override + protected void drawGuiContainerBackgroundLayer(float p_146976_1_, int p_146976_2_, int p_146976_3_) { + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + mc.getTextureManager().bindTexture(texture); + int k = (width - xSize) / 2; + int l = (height - ySize) / 2; + drawTexturedModalRect(k, l, 0, 0, xSize, ySize); - @Override - protected void drawGuiContainerBackgroundLayer(float p_146976_1_, int p_146976_2_, int p_146976_3_) { - GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); - mc.getTextureManager().bindTexture(texture); - int k = (width - xSize) / 2; - int l = (height - ySize) / 2; - drawTexturedModalRect(k, l, 0, 0, xSize, ySize); + List slotList = inventorySlots.inventorySlots; + for(Slot slot : slotList) + if(slot instanceof SlotFlower) { + SlotFlower slotf = (SlotFlower) slot; + if(!slotf.getHasStack()) { + ItemStack stack = new ItemStack(ModBlocks.flower, 0, slotf.color); + int x = guiLeft + slotf.xDisplayPosition; + int y = guiTop + slotf.yDisplayPosition; + RenderHelper.enableGUIStandardItemLighting(); + RenderItem.getInstance().renderItemIntoGUI(mc.fontRenderer, mc.renderEngine, stack, x, y); + RenderHelper.disableStandardItemLighting(); + mc.fontRenderer.drawStringWithShadow("0", x + 11, y + 9, 0xFF6666); + } + } + } - List slotList = inventorySlots.inventorySlots; - for (Slot slot : slotList) - if (slot instanceof SlotFlower) { - SlotFlower slotf = (SlotFlower) slot; - if (!slotf.getHasStack()) { - ItemStack stack = new ItemStack(ModBlocks.flower, 0, slotf.color); - int x = guiLeft + slotf.xDisplayPosition; - int y = guiTop + slotf.yDisplayPosition; - RenderHelper.enableGUIStandardItemLighting(); - RenderItem.getInstance().renderItemIntoGUI(mc.fontRenderer, mc.renderEngine, stack, x, y); - RenderHelper.disableStandardItemLighting(); - mc.fontRenderer.drawStringWithShadow("0", x + 11, y + 9, 0xFF6666); - } - } - } + @Override + protected boolean checkHotbarKeys(int p_146983_1_) { + return false; + } - @Override - protected boolean checkHotbarKeys(int p_146983_1_) { - return false; - } } diff --git a/src/main/java/vazkii/botania/client/gui/bag/InventoryFlowerBag.java b/src/main/java/vazkii/botania/client/gui/bag/InventoryFlowerBag.java index b9c283e938..10fcb06f97 100644 --- a/src/main/java/vazkii/botania/client/gui/bag/InventoryFlowerBag.java +++ b/src/main/java/vazkii/botania/client/gui/bag/InventoryFlowerBag.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Mar 16, 2015, 6:42:56 PM (GMT)] */ package vazkii.botania.client.gui.bag; @@ -19,136 +19,142 @@ public class InventoryFlowerBag implements IInventory { - private static final ItemStack[] FALLBACK_INVENTORY = new ItemStack[16]; - - EntityPlayer player; - int slot; - ItemStack[] stacks = null; - - boolean invPushed = false; - ItemStack storedInv = null; - - public InventoryFlowerBag(EntityPlayer player, int slot) { - this.player = player; - this.slot = slot; - } - - public static boolean isFlowerBag(ItemStack stack) { - return stack != null && stack.getItem() == ModItems.flowerBag; - } - - ItemStack getStack() { - ItemStack stack = player.inventory.getStackInSlot(slot); - if (stack != null) storedInv = stack; - return stack; - } - - ItemStack[] getInventory() { - if (stacks != null) return stacks; - - ItemStack stack = getStack(); - if (isFlowerBag(getStack())) { - stacks = ItemFlowerBag.loadStacks(stack); - return stacks; - } - - return FALLBACK_INVENTORY; - } - - public void pushInventory() { - if (invPushed) return; - - ItemStack stack = getStack(); - if (stack == null) stack = storedInv; - - if (stack != null) { - ItemStack[] inv = getInventory(); - ItemFlowerBag.setStacks(stack, inv); - } - - invPushed = true; - } - - @Override - public int getSizeInventory() { - return 16; - } - - @Override - public ItemStack getStackInSlot(int i) { - return getInventory()[i]; - } - - @Override - public ItemStack decrStackSize(int i, int j) { - ItemStack[] inventorySlots = getInventory(); - if (inventorySlots[i] != null) { - ItemStack stackAt; - - if (inventorySlots[i].stackSize <= j) { - stackAt = inventorySlots[i]; - inventorySlots[i] = null; - return stackAt; - } else { - stackAt = inventorySlots[i].splitStack(j); - - if (inventorySlots[i].stackSize == 0) inventorySlots[i] = null; - - return stackAt; - } - } - - return null; - } - - @Override - public ItemStack getStackInSlotOnClosing(int i) { - return getStackInSlot(i); - } - - @Override - public void setInventorySlotContents(int i, ItemStack itemstack) { - ItemStack[] inventorySlots = getInventory(); - inventorySlots[i] = itemstack; - } - - @Override - public int getInventoryStackLimit() { - return isFlowerBag(getStack()) ? 64 : 0; - } - - @Override - public boolean isUseableByPlayer(EntityPlayer entityplayer) { - return isFlowerBag(getStack()); - } - - @Override - public boolean isItemValidForSlot(int i, ItemStack itemstack) { - return isFlowerBag(getStack()); - } - - @Override - public boolean hasCustomInventoryName() { - return false; - } - - @Override - public void openInventory() { - // NO-OP - } - - @Override - public void closeInventory() { - // NO-OP - } - - @Override - public String getInventoryName() { - return LibItemNames.FLOWER_BAG; - } - - @Override - public void markDirty() { - // NO-OP - } + private static final ItemStack[] FALLBACK_INVENTORY = new ItemStack[16]; + + EntityPlayer player; + int slot; + ItemStack[] stacks = null; + + boolean invPushed = false; + ItemStack storedInv = null; + + public InventoryFlowerBag(EntityPlayer player, int slot) { + this.player = player; + this.slot = slot; + } + + public static boolean isFlowerBag(ItemStack stack) { + return stack != null && stack.getItem() == ModItems.flowerBag; + } + + ItemStack getStack() { + ItemStack stack = player.inventory.getStackInSlot(slot); + if(stack != null) + storedInv = stack; + return stack; + } + + ItemStack[] getInventory() { + if(stacks != null) + return stacks; + + ItemStack stack = getStack(); + if(isFlowerBag(getStack())) { + stacks = ItemFlowerBag.loadStacks(stack); + return stacks; + } + + return FALLBACK_INVENTORY; + } + + public void pushInventory() { + if(invPushed) + return; + + ItemStack stack = getStack(); + if(stack == null) + stack = storedInv; + + if(stack != null) { + ItemStack[] inv = getInventory(); + ItemFlowerBag.setStacks(stack, inv); + } + + invPushed = true; + } + + @Override + public int getSizeInventory() { + return 16; + } + + @Override + public ItemStack getStackInSlot(int i) { + return getInventory()[i]; + } + + @Override + public ItemStack decrStackSize(int i, int j) { + ItemStack[] inventorySlots = getInventory(); + if (inventorySlots[i] != null) { + ItemStack stackAt; + + if (inventorySlots[i].stackSize <= j) { + stackAt = inventorySlots[i]; + inventorySlots[i] = null; + return stackAt; + } else { + stackAt = inventorySlots[i].splitStack(j); + + if (inventorySlots[i].stackSize == 0) + inventorySlots[i] = null; + + return stackAt; + } + } + + return null; + } + + @Override + public ItemStack getStackInSlotOnClosing(int i) { + return getStackInSlot(i); + } + + @Override + public void setInventorySlotContents(int i, ItemStack itemstack) { + ItemStack[] inventorySlots = getInventory(); + inventorySlots[i] = itemstack; + } + + @Override + public int getInventoryStackLimit() { + return isFlowerBag(getStack()) ? 64 : 0; + } + + @Override + public boolean isUseableByPlayer(EntityPlayer entityplayer) { + return isFlowerBag(getStack()); + } + + @Override + public boolean isItemValidForSlot(int i, ItemStack itemstack) { + return isFlowerBag(getStack()); + } + + @Override + public boolean hasCustomInventoryName() { + return false; + } + + @Override + public void openInventory() { + // NO-OP + } + + @Override + public void closeInventory() { + // NO-OP + } + + @Override + public String getInventoryName() { + return LibItemNames.FLOWER_BAG; + } + + @Override + public void markDirty() { + // NO-OP + } + } diff --git a/src/main/java/vazkii/botania/client/gui/bag/SlotFlower.java b/src/main/java/vazkii/botania/client/gui/bag/SlotFlower.java index 0348a97540..ba4c32378a 100644 --- a/src/main/java/vazkii/botania/client/gui/bag/SlotFlower.java +++ b/src/main/java/vazkii/botania/client/gui/bag/SlotFlower.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Mar 16, 2015, 7:20:05 PM (GMT)] */ package vazkii.botania.client.gui.bag; @@ -17,22 +17,23 @@ public class SlotFlower extends Slot { - InventoryFlowerBag inv; - int color; + InventoryFlowerBag inv; + int color; - public SlotFlower(InventoryFlowerBag p_i1824_1_, int p_i1824_2_, int p_i1824_3_, int p_i1824_4_, int color) { - super(p_i1824_1_, p_i1824_2_, p_i1824_3_, p_i1824_4_); - this.color = color; - inv = p_i1824_1_; - } + public SlotFlower(InventoryFlowerBag p_i1824_1_, int p_i1824_2_, int p_i1824_3_, int p_i1824_4_, int color) { + super(p_i1824_1_, p_i1824_2_, p_i1824_3_, p_i1824_4_); + this.color = color; + inv = p_i1824_1_; + } - @Override - public void onSlotChange(ItemStack oldStack, ItemStack newStack) { - inv.setInventorySlotContents(color, newStack); - } + @Override + public void onSlotChange(ItemStack oldStack, ItemStack newStack) { + inv.setInventorySlotContents(color, newStack); + } + + @Override + public boolean isItemValid(ItemStack stack) { + return stack.getItem() == Item.getItemFromBlock(ModBlocks.flower) && stack.getItemDamage() == color; + } - @Override - public boolean isItemValid(ItemStack stack) { - return stack.getItem() == Item.getItemFromBlock(ModBlocks.flower) && stack.getItemDamage() == color; - } } diff --git a/src/main/java/vazkii/botania/client/gui/box/ContainerBaubleBox.java b/src/main/java/vazkii/botania/client/gui/box/ContainerBaubleBox.java index 3445f09d21..24d54be75b 100644 --- a/src/main/java/vazkii/botania/client/gui/box/ContainerBaubleBox.java +++ b/src/main/java/vazkii/botania/client/gui/box/ContainerBaubleBox.java @@ -2,19 +2,14 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [25/11/2015, 19:59:06 (GMT)] */ package vazkii.botania.client.gui.box; -import baubles.api.BaubleType; -import baubles.api.IBauble; -import baubles.common.container.InventoryBaubles; -import baubles.common.container.SlotBauble; -import baubles.common.lib.PlayerHandler; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.inventory.Container; import net.minecraft.inventory.IInventory; @@ -22,92 +17,106 @@ import net.minecraft.item.ItemStack; import vazkii.botania.api.mana.IManaItem; import vazkii.botania.client.gui.SlotLocked; +import baubles.api.BaubleType; +import baubles.api.IBauble; +import baubles.common.container.InventoryBaubles; +import baubles.common.container.SlotBauble; +import baubles.common.lib.PlayerHandler; public class ContainerBaubleBox extends Container { - InventoryBaubleBox baubleBoxInv; - InventoryBaubles baubles; - - public ContainerBaubleBox(EntityPlayer player) { - int i; - int j; - - int slot = player.inventory.currentItem; - IInventory playerInv = player.inventory; - baubleBoxInv = new InventoryBaubleBox(player, slot); - - baubles = new InventoryBaubles(player); - baubles.setEventHandler(this); - if (!player.worldObj.isRemote) baubles.stackList = PlayerHandler.getPlayerBaubles(player).stackList; - - addSlotToContainer(new SlotBauble(baubles, BaubleType.AMULET, 0, 8, 8 + 0 * 18)); - addSlotToContainer(new SlotBauble(baubles, BaubleType.RING, 1, 8, 8 + 1 * 18)); - addSlotToContainer(new SlotBauble(baubles, BaubleType.RING, 2, 8, 8 + 2 * 18)); - addSlotToContainer(new SlotBauble(baubles, BaubleType.BELT, 3, 8, 8 + 3 * 18)); - - for (i = 0; i < 4; ++i) - for (j = 0; j < 6; ++j) { - int k = j + i * 6; - addSlotToContainer(new SlotAnyBauble(baubleBoxInv, k, 62 + j * 18, 8 + i * 18)); - } - - for (i = 0; i < 3; ++i) - for (j = 0; j < 9; ++j) addSlotToContainer(new Slot(playerInv, j + i * 9 + 9, 8 + j * 18, 84 + i * 18)); - - for (i = 0; i < 9; ++i) { - if (player.inventory.currentItem == i) addSlotToContainer(new SlotLocked(playerInv, i, 8 + i * 18, 142)); - else addSlotToContainer(new Slot(playerInv, i, 8 + i * 18, 142)); - } - } - - @Override - public boolean canInteractWith(EntityPlayer player) { - boolean can = baubleBoxInv.isUseableByPlayer(player); - if (!can) onContainerClosed(player); - - return can; - } - - @Override - public void onContainerClosed(EntityPlayer player) { - super.onContainerClosed(player); - baubleBoxInv.pushInventory(); - - if (!player.worldObj.isRemote) PlayerHandler.setPlayerBaubles(player, baubles); - } - - @Override - public void putStacksInSlots(ItemStack[] p_75131_1_) { - baubles.blockEvents = true; - super.putStacksInSlots(p_75131_1_); - } - - @Override - public ItemStack transferStackInSlot(EntityPlayer p_82846_1_, int p_82846_2_) { - ItemStack itemstack = null; - Slot slot = (Slot) inventorySlots.get(p_82846_2_); - - if (slot != null && slot.getHasStack()) { - ItemStack itemstack1 = slot.getStack(); - itemstack = itemstack1.copy(); - - System.out.println(p_82846_2_ + " " + itemstack); - if (p_82846_2_ < 28) { - if (!mergeItemStack(itemstack1, 28, 64, true)) return null; - } else { - if (itemstack1 != null - && (itemstack1.getItem() instanceof IBauble || itemstack1.getItem() instanceof IManaItem) - && !mergeItemStack(itemstack1, 4, 28, false)) return null; - } - - if (itemstack1.stackSize == 0) slot.putStack((ItemStack) null); - else slot.onSlotChanged(); - - if (itemstack1.stackSize == itemstack.stackSize) return null; - - slot.onPickupFromSlot(p_82846_1_, itemstack1); - } - - return itemstack; - } + InventoryBaubleBox baubleBoxInv; + InventoryBaubles baubles; + + public ContainerBaubleBox(EntityPlayer player) { + int i; + int j; + + int slot = player.inventory.currentItem; + IInventory playerInv = player.inventory; + baubleBoxInv = new InventoryBaubleBox(player, slot); + + baubles = new InventoryBaubles(player); + baubles.setEventHandler(this); + if(!player.worldObj.isRemote) + baubles.stackList = PlayerHandler.getPlayerBaubles(player).stackList; + + addSlotToContainer(new SlotBauble(baubles, BaubleType.AMULET, 0, 8, 8 + 0 * 18)); + addSlotToContainer(new SlotBauble(baubles, BaubleType.RING, 1, 8, 8 + 1 * 18)); + addSlotToContainer(new SlotBauble(baubles, BaubleType.RING, 2, 8, 8 + 2 * 18)); + addSlotToContainer(new SlotBauble(baubles, BaubleType.BELT, 3, 8, 8 + 3 * 18)); + + for(i = 0; i < 4; ++i) + for(j = 0; j < 6; ++j) { + int k = j + i * 6; + addSlotToContainer(new SlotAnyBauble(baubleBoxInv, k, 62 + j * 18, 8 + i * 18)); + } + + for(i = 0; i < 3; ++i) + for(j = 0; j < 9; ++j) + addSlotToContainer(new Slot(playerInv, j + i * 9 + 9, 8 + j * 18, 84 + i * 18)); + + for(i = 0; i < 9; ++i) { + if(player.inventory.currentItem == i) + addSlotToContainer(new SlotLocked(playerInv, i, 8 + i * 18, 142)); + else addSlotToContainer(new Slot(playerInv, i, 8 + i * 18, 142)); + } + + } + + @Override + public boolean canInteractWith(EntityPlayer player) { + boolean can = baubleBoxInv.isUseableByPlayer(player); + if(!can) + onContainerClosed(player); + + return can; + } + + @Override + public void onContainerClosed(EntityPlayer player) { + super.onContainerClosed(player); + baubleBoxInv.pushInventory(); + + if(!player.worldObj.isRemote) + PlayerHandler.setPlayerBaubles(player, baubles); + } + + @Override + public void putStacksInSlots(ItemStack[] p_75131_1_) { + baubles.blockEvents = true; + super.putStacksInSlots(p_75131_1_); + } + + @Override + public ItemStack transferStackInSlot(EntityPlayer p_82846_1_, int p_82846_2_) { + ItemStack itemstack = null; + Slot slot = (Slot)inventorySlots.get(p_82846_2_); + + if(slot != null && slot.getHasStack()) { + ItemStack itemstack1 = slot.getStack(); + itemstack = itemstack1.copy(); + + System.out.println(p_82846_2_ + " " + itemstack); + if(p_82846_2_ < 28) { + if(!mergeItemStack(itemstack1, 28, 64, true)) + return null; + } else { + if(itemstack1 != null && (itemstack1.getItem() instanceof IBauble || itemstack1.getItem() instanceof IManaItem) && !mergeItemStack(itemstack1, 4, 28, false)) + return null; + } + + if(itemstack1.stackSize == 0) + slot.putStack((ItemStack)null); + else slot.onSlotChanged(); + + if(itemstack1.stackSize == itemstack.stackSize) + return null; + + slot.onPickupFromSlot(p_82846_1_, itemstack1); + } + + return itemstack; + } + } diff --git a/src/main/java/vazkii/botania/client/gui/box/GuiBaubleBox.java b/src/main/java/vazkii/botania/client/gui/box/GuiBaubleBox.java index c0c5edf9b8..798a95373b 100644 --- a/src/main/java/vazkii/botania/client/gui/box/GuiBaubleBox.java +++ b/src/main/java/vazkii/botania/client/gui/box/GuiBaubleBox.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [25/11/2015, 19:59:11 (GMT)] */ package vazkii.botania.client.gui.box; @@ -15,42 +15,39 @@ import net.minecraft.entity.player.EntityPlayer; import net.minecraft.inventory.Slot; import net.minecraft.util.ResourceLocation; + import org.lwjgl.opengl.GL11; + import vazkii.botania.client.lib.LibResources; public class GuiBaubleBox extends InventoryEffectRenderer { - private static final ResourceLocation texture = new ResourceLocation(LibResources.GUI_BAUBLE_BOX); - - public GuiBaubleBox(EntityPlayer player) { - super(new ContainerBaubleBox(player)); - } - - @Override - protected boolean checkHotbarKeys(int p_146983_1_) { - return false; - } - - @Override - protected void drawGuiContainerBackgroundLayer(float p_146976_1_, int p_146976_2_, int p_146976_3_) { - GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); - mc.getTextureManager().bindTexture(texture); - int k = (width - xSize) / 2; - int l = (height - ySize) / 2; - drawTexturedModalRect(k, l, 0, 0, xSize, ySize); - - for (int i1 = 0; i1 < 4; ++i1) { - Slot slot = (Slot) inventorySlots.inventorySlots.get(i1); - if (slot.getHasStack() && slot.getSlotStackLimit() == 1) - drawTexturedModalRect(k + slot.xDisplayPosition, l + slot.yDisplayPosition, 200, 0, 16, 16); - } - - GuiInventory.func_147046_a( - guiLeft + 43, - guiTop + 61, - 20, - guiLeft + 43 - p_146976_2_, - guiTop + 45 - 30 - p_146976_3_, - mc.thePlayer); - } + private static final ResourceLocation texture = new ResourceLocation(LibResources.GUI_BAUBLE_BOX); + + public GuiBaubleBox(EntityPlayer player) { + super(new ContainerBaubleBox(player)); + } + + @Override + protected boolean checkHotbarKeys(int p_146983_1_) { + return false; + } + + @Override + protected void drawGuiContainerBackgroundLayer(float p_146976_1_, int p_146976_2_, int p_146976_3_) { + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + mc.getTextureManager().bindTexture(texture); + int k = (width - xSize) / 2; + int l = (height - ySize) / 2; + drawTexturedModalRect(k, l, 0, 0, xSize, ySize); + + for(int i1 = 0; i1 < 4; ++i1) { + Slot slot = (Slot) inventorySlots.inventorySlots.get(i1); + if(slot.getHasStack() && slot.getSlotStackLimit() == 1) + drawTexturedModalRect(k+slot.xDisplayPosition, l+slot.yDisplayPosition, 200, 0, 16, 16); + } + + GuiInventory.func_147046_a(guiLeft + 43, guiTop + 61, 20, guiLeft + 43 - p_146976_2_, guiTop + 45 - 30 - p_146976_3_, mc.thePlayer); + } + } diff --git a/src/main/java/vazkii/botania/client/gui/box/InventoryBaubleBox.java b/src/main/java/vazkii/botania/client/gui/box/InventoryBaubleBox.java index 6cdc8c690b..415eee637c 100644 --- a/src/main/java/vazkii/botania/client/gui/box/InventoryBaubleBox.java +++ b/src/main/java/vazkii/botania/client/gui/box/InventoryBaubleBox.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [25/11/2015, 19:59:16 (GMT)] */ package vazkii.botania.client.gui.box; @@ -19,136 +19,142 @@ public class InventoryBaubleBox implements IInventory { - private static final ItemStack[] FALLBACK_INVENTORY = new ItemStack[16]; - - EntityPlayer player; - int slot; - ItemStack[] stacks = null; - - boolean invPushed = false; - ItemStack storedInv = null; - - public InventoryBaubleBox(EntityPlayer player, int slot) { - this.player = player; - this.slot = slot; - } - - public static boolean isBaubleBox(ItemStack stack) { - return stack != null && stack.getItem() == ModItems.baubleBox; - } - - ItemStack getStack() { - ItemStack stack = player.inventory.getStackInSlot(slot); - if (stack != null) storedInv = stack; - return stack; - } - - ItemStack[] getInventory() { - if (stacks != null) return stacks; - - ItemStack stack = getStack(); - if (isBaubleBox(getStack())) { - stacks = ItemBaubleBox.loadStacks(stack); - return stacks; - } - - return FALLBACK_INVENTORY; - } - - public void pushInventory() { - if (invPushed) return; - - ItemStack stack = getStack(); - if (stack == null) stack = storedInv; - - if (stack != null) { - ItemStack[] inv = getInventory(); - ItemBaubleBox.setStacks(stack, inv); - } - - invPushed = true; - } - - @Override - public int getSizeInventory() { - return 16; - } - - @Override - public ItemStack getStackInSlot(int i) { - return getInventory()[i]; - } - - @Override - public ItemStack decrStackSize(int i, int j) { - ItemStack[] inventorySlots = getInventory(); - if (inventorySlots[i] != null) { - ItemStack stackAt; - - if (inventorySlots[i].stackSize <= j) { - stackAt = inventorySlots[i]; - inventorySlots[i] = null; - return stackAt; - } else { - stackAt = inventorySlots[i].splitStack(j); - - if (inventorySlots[i].stackSize == 0) inventorySlots[i] = null; - - return stackAt; - } - } - - return null; - } - - @Override - public ItemStack getStackInSlotOnClosing(int i) { - return getStackInSlot(i); - } - - @Override - public void setInventorySlotContents(int slot, ItemStack itemstack) { - ItemStack[] inventorySlots = getInventory(); - inventorySlots[slot] = itemstack; - } - - @Override - public int getInventoryStackLimit() { - return isBaubleBox(getStack()) ? 64 : 0; - } - - @Override - public boolean isUseableByPlayer(EntityPlayer entityplayer) { - return isBaubleBox(getStack()); - } - - @Override - public boolean isItemValidForSlot(int i, ItemStack itemstack) { - return isBaubleBox(getStack()); - } - - @Override - public boolean hasCustomInventoryName() { - return false; - } - - @Override - public void openInventory() { - // NO-OP - } - - @Override - public void closeInventory() { - // NO-OP - } - - @Override - public String getInventoryName() { - return LibItemNames.BAUBLE_BOX; - } - - @Override - public void markDirty() { - // NO-OP - } + private static final ItemStack[] FALLBACK_INVENTORY = new ItemStack[16]; + + EntityPlayer player; + int slot; + ItemStack[] stacks = null; + + boolean invPushed = false; + ItemStack storedInv = null; + + public InventoryBaubleBox(EntityPlayer player, int slot) { + this.player = player; + this.slot = slot; + } + + public static boolean isBaubleBox(ItemStack stack) { + return stack != null && stack.getItem() == ModItems.baubleBox; + } + + ItemStack getStack() { + ItemStack stack = player.inventory.getStackInSlot(slot); + if(stack != null) + storedInv = stack; + return stack; + } + + ItemStack[] getInventory() { + if(stacks != null) + return stacks; + + ItemStack stack = getStack(); + if(isBaubleBox(getStack())) { + stacks = ItemBaubleBox.loadStacks(stack); + return stacks; + } + + return FALLBACK_INVENTORY; + } + + public void pushInventory() { + if(invPushed) + return; + + ItemStack stack = getStack(); + if(stack == null) + stack = storedInv; + + if(stack != null) { + ItemStack[] inv = getInventory(); + ItemBaubleBox.setStacks(stack, inv); + } + + invPushed = true; + } + + @Override + public int getSizeInventory() { + return 16; + } + + @Override + public ItemStack getStackInSlot(int i) { + return getInventory()[i]; + } + + @Override + public ItemStack decrStackSize(int i, int j) { + ItemStack[] inventorySlots = getInventory(); + if (inventorySlots[i] != null) { + ItemStack stackAt; + + if (inventorySlots[i].stackSize <= j) { + stackAt = inventorySlots[i]; + inventorySlots[i] = null; + return stackAt; + } else { + stackAt = inventorySlots[i].splitStack(j); + + if (inventorySlots[i].stackSize == 0) + inventorySlots[i] = null; + + return stackAt; + } + } + + return null; + } + + @Override + public ItemStack getStackInSlotOnClosing(int i) { + return getStackInSlot(i); + } + + @Override + public void setInventorySlotContents(int slot, ItemStack itemstack) { + ItemStack[] inventorySlots = getInventory(); + inventorySlots[slot] = itemstack; + } + + @Override + public int getInventoryStackLimit() { + return isBaubleBox(getStack()) ? 64 : 0; + } + + @Override + public boolean isUseableByPlayer(EntityPlayer entityplayer) { + return isBaubleBox(getStack()); + } + + @Override + public boolean isItemValidForSlot(int i, ItemStack itemstack) { + return isBaubleBox(getStack()); + } + + @Override + public boolean hasCustomInventoryName() { + return false; + } + + @Override + public void openInventory() { + // NO-OP + } + + @Override + public void closeInventory() { + // NO-OP + } + + @Override + public String getInventoryName() { + return LibItemNames.BAUBLE_BOX; + } + + @Override + public void markDirty() { + // NO-OP + } + } diff --git a/src/main/java/vazkii/botania/client/gui/box/SlotAnyBauble.java b/src/main/java/vazkii/botania/client/gui/box/SlotAnyBauble.java index 6464ca4751..e19453b9bc 100644 --- a/src/main/java/vazkii/botania/client/gui/box/SlotAnyBauble.java +++ b/src/main/java/vazkii/botania/client/gui/box/SlotAnyBauble.java @@ -2,35 +2,36 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [25/11/2015, 19:59:22 (GMT)] */ package vazkii.botania.client.gui.box; -import baubles.api.IBauble; import net.minecraft.inventory.Slot; import net.minecraft.item.ItemStack; import vazkii.botania.api.mana.IManaItem; +import baubles.api.IBauble; public class SlotAnyBauble extends Slot { - InventoryBaubleBox inv; + InventoryBaubleBox inv; + + public SlotAnyBauble(InventoryBaubleBox p_i1824_1_, int p_i1824_2_, int p_i1824_3_, int p_i1824_4_) { + super(p_i1824_1_, p_i1824_2_, p_i1824_3_, p_i1824_4_); + inv = p_i1824_1_; + } - public SlotAnyBauble(InventoryBaubleBox p_i1824_1_, int p_i1824_2_, int p_i1824_3_, int p_i1824_4_) { - super(p_i1824_1_, p_i1824_2_, p_i1824_3_, p_i1824_4_); - inv = p_i1824_1_; - } + @Override + public void onSlotChange(ItemStack oldStack, ItemStack newStack) { + inv.setInventorySlotContents(slotNumber, newStack); + } - @Override - public void onSlotChange(ItemStack oldStack, ItemStack newStack) { - inv.setInventorySlotContents(slotNumber, newStack); - } + @Override + public boolean isItemValid(ItemStack stack) { + return stack.getItem() instanceof IBauble || stack.getItem() instanceof IManaItem; + } - @Override - public boolean isItemValid(ItemStack stack) { - return stack.getItem() instanceof IBauble || stack.getItem() instanceof IManaItem; - } } diff --git a/src/main/java/vazkii/botania/client/gui/crafting/ContainerCraftingHalo.java b/src/main/java/vazkii/botania/client/gui/crafting/ContainerCraftingHalo.java index d946b88c38..e335f52298 100644 --- a/src/main/java/vazkii/botania/client/gui/crafting/ContainerCraftingHalo.java +++ b/src/main/java/vazkii/botania/client/gui/crafting/ContainerCraftingHalo.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Dec 15, 2014, 6:02:52 PM (GMT)] */ package vazkii.botania.client.gui.crafting; @@ -19,40 +19,45 @@ public class ContainerCraftingHalo extends ContainerWorkbench { - public ContainerCraftingHalo(InventoryPlayer p_i1808_1_, World p_i1808_2_) { - super(p_i1808_1_, p_i1808_2_, 0, 0, 0); - - craftMatrix = new InventoryCraftingHalo(this, 3, 3); - - inventorySlots.clear(); - inventoryItemStacks.clear(); - - // Le copypasta - addSlotToContainer(new SlotCrafting(p_i1808_1_.player, craftMatrix, craftResult, 0, 124, 35)); - int l; - int i1; - - for (l = 0; l < 3; ++l) { - for (i1 = 0; i1 < 3; ++i1) { - addSlotToContainer(new Slot(craftMatrix, i1 + l * 3, 30 + i1 * 18, 17 + l * 18)); - } - } - - for (l = 0; l < 3; ++l) { - for (i1 = 0; i1 < 9; ++i1) { - addSlotToContainer(new Slot(p_i1808_1_, i1 + l * 9 + 9, 8 + i1 * 18, 84 + l * 18)); - } - } - - for (l = 0; l < 9; ++l) { - addSlotToContainer(new Slot(p_i1808_1_, l, 8 + l * 18, 142)); - } - - onCraftMatrixChanged(craftMatrix); - } - - @Override - public boolean canInteractWith(EntityPlayer p_75145_1_) { - return true; - } + public ContainerCraftingHalo(InventoryPlayer p_i1808_1_, World p_i1808_2_) { + super(p_i1808_1_, p_i1808_2_, 0, 0, 0); + + craftMatrix = new InventoryCraftingHalo(this, 3, 3); + + inventorySlots.clear(); + inventoryItemStacks.clear(); + + // Le copypasta + addSlotToContainer(new SlotCrafting(p_i1808_1_.player, craftMatrix, craftResult, 0, 124, 35)); + int l; + int i1; + + for (l = 0; l < 3; ++l) + { + for (i1 = 0; i1 < 3; ++i1) + { + addSlotToContainer(new Slot(craftMatrix, i1 + l * 3, 30 + i1 * 18, 17 + l * 18)); + } + } + + for (l = 0; l < 3; ++l) + { + for (i1 = 0; i1 < 9; ++i1) + { + addSlotToContainer(new Slot(p_i1808_1_, i1 + l * 9 + 9, 8 + i1 * 18, 84 + l * 18)); + } + } + + for (l = 0; l < 9; ++l) + { + addSlotToContainer(new Slot(p_i1808_1_, l, 8 + l * 18, 142)); + } + + onCraftMatrixChanged(craftMatrix); + } + + @Override + public boolean canInteractWith(EntityPlayer p_75145_1_) { + return true; + } } diff --git a/src/main/java/vazkii/botania/client/gui/crafting/GuiCraftingHalo.java b/src/main/java/vazkii/botania/client/gui/crafting/GuiCraftingHalo.java index c14dab3665..fbc503ff61 100644 --- a/src/main/java/vazkii/botania/client/gui/crafting/GuiCraftingHalo.java +++ b/src/main/java/vazkii/botania/client/gui/crafting/GuiCraftingHalo.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Dec 15, 2014, 6:02:04 PM (GMT)] */ package vazkii.botania.client.gui.crafting; @@ -15,30 +15,31 @@ import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.util.ResourceLocation; import net.minecraft.world.World; + import org.lwjgl.opengl.GL11; // This is pretty much a copypasta of GuiCrafting >_> public class GuiCraftingHalo extends GuiContainer { - private static final ResourceLocation craftingTableGuiTextures = - new ResourceLocation("textures/gui/container/crafting_table.png"); - - public GuiCraftingHalo(InventoryPlayer p_i1084_1_, World p_i1084_2_) { - super(new ContainerCraftingHalo(p_i1084_1_, p_i1084_2_)); - } - - @Override - protected void drawGuiContainerForegroundLayer(int p_146979_1_, int p_146979_2_) { - fontRendererObj.drawString(I18n.format("container.crafting", new Object[0]), 28, 6, 4210752); - fontRendererObj.drawString(I18n.format("container.inventory", new Object[0]), 8, ySize - 96 + 2, 4210752); - } - - @Override - protected void drawGuiContainerBackgroundLayer(float p_146976_1_, int p_146976_2_, int p_146976_3_) { - GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); - mc.getTextureManager().bindTexture(craftingTableGuiTextures); - int k = (width - xSize) / 2; - int l = (height - ySize) / 2; - drawTexturedModalRect(k, l, 0, 0, xSize, ySize); - } + private static final ResourceLocation craftingTableGuiTextures = new ResourceLocation("textures/gui/container/crafting_table.png"); + + public GuiCraftingHalo(InventoryPlayer p_i1084_1_, World p_i1084_2_) { + super(new ContainerCraftingHalo(p_i1084_1_, p_i1084_2_)); + } + + @Override + protected void drawGuiContainerForegroundLayer(int p_146979_1_, int p_146979_2_) { + fontRendererObj.drawString(I18n.format("container.crafting", new Object[0]), 28, 6, 4210752); + fontRendererObj.drawString(I18n.format("container.inventory", new Object[0]), 8, ySize - 96 + 2, 4210752); + } + + @Override + protected void drawGuiContainerBackgroundLayer(float p_146976_1_, int p_146976_2_, int p_146976_3_) { + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + mc.getTextureManager().bindTexture(craftingTableGuiTextures); + int k = (width - xSize) / 2; + int l = (height - ySize) / 2; + drawTexturedModalRect(k, l, 0, 0, xSize, ySize); + } + } diff --git a/src/main/java/vazkii/botania/client/gui/crafting/InventoryCraftingHalo.java b/src/main/java/vazkii/botania/client/gui/crafting/InventoryCraftingHalo.java index 708aaa99c0..6089d66717 100644 --- a/src/main/java/vazkii/botania/client/gui/crafting/InventoryCraftingHalo.java +++ b/src/main/java/vazkii/botania/client/gui/crafting/InventoryCraftingHalo.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Dec 20, 2014, 4:29:09 PM (GMT)] */ package vazkii.botania.client.gui.crafting; @@ -15,7 +15,8 @@ public class InventoryCraftingHalo extends InventoryCrafting { - public InventoryCraftingHalo(Container p_i1807_1_, int p_i1807_2_, int p_i1807_3_) { - super(p_i1807_1_, p_i1807_2_, p_i1807_3_); - } + public InventoryCraftingHalo(Container p_i1807_1_, int p_i1807_2_, int p_i1807_3_) { + super(p_i1807_1_, p_i1807_2_, p_i1807_3_); + } + } diff --git a/src/main/java/vazkii/botania/client/gui/lexicon/GuiLexicon.java b/src/main/java/vazkii/botania/client/gui/lexicon/GuiLexicon.java index c52589f2ee..e329a71223 100644 --- a/src/main/java/vazkii/botania/client/gui/lexicon/GuiLexicon.java +++ b/src/main/java/vazkii/botania/client/gui/lexicon/GuiLexicon.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jan 14, 2014, 6:48:05 PM (GMT)] */ package vazkii.botania.client.gui.lexicon; @@ -20,6 +20,7 @@ import java.util.HashMap; import java.util.List; import java.util.Queue; + import net.minecraft.client.Minecraft; import net.minecraft.client.audio.PositionedSoundRecord; import net.minecraft.client.gui.FontRenderer; @@ -32,8 +33,10 @@ import net.minecraft.util.ResourceLocation; import net.minecraft.util.StatCollector; import net.minecraftforge.common.MinecraftForge; + import org.lwjgl.input.Keyboard; import org.lwjgl.opengl.GL11; + import vazkii.botania.api.BotaniaAPI; import vazkii.botania.api.lexicon.BotaniaTutorialStartEvent; import vazkii.botania.api.lexicon.LexiconCategory; @@ -64,597 +67,595 @@ public class GuiLexicon extends GuiScreen { - public static GuiLexicon currentOpenLexicon = new GuiLexicon(); - public static ItemStack stackUsed; - - public static HashMap notes = new HashMap(); - - private static final String TAG_TYPE = "type"; - - private static final int[] KONAMI_CODE = {200, 200, 208, 208, 203, 205, 203, 205, 48, 30}; - - public static final int BOOKMARK_START = 1337; - public static final int NOTES_BUTTON_ID = 1336; // random button tho - public static final int MAX_BOOKMARK_COUNT = 8; - public static List bookmarks = new ArrayList(); - public static List bookmarkKeys = new ArrayList(); - boolean bookmarksNeedPopulation = false; - - public static Queue tutorial = new ArrayDeque(); - - public static final ResourceLocation texture = new ResourceLocation(LibResources.GUI_LEXICON); - public static final ResourceLocation textureToff = new ResourceLocation(LibResources.GUI_TOFF); - - public float lastTime = 0F; - public float partialTicks = 0F; - public float timeDelta = 0F; - - private static final int TUTORIAL_ARROW_WIDTH = 10; - private static final int TUTORIAL_ARROW_HEIGHT = 12; - boolean hasTutorialArrow; - int tutorialArrowX, tutorialArrowY; - int konamiIndex; - - private static final int NOTE_TWEEN_TIME = 5; - public static boolean notesEnabled; - static int notesMoveTime; - public String note = ""; - public String categoryHighlight = ""; - - List allCategories; - - String title; - int guiWidth = 146; - int guiHeight = 180; - int left, top; - - @Override - public final void initGui() { - super.initGui(); - - if (PersistentVariableHelper.firstLoad) { - PersistentVariableHelper.firstLoad = false; - PersistentVariableHelper.saveSafe(); - } - - String key = getNotesKey(); - if (notes.containsKey(key)) note = notes.get(key); - - onInitGui(); - - putTutorialArrow(); - } - - public void onInitGui() { - allCategories = new ArrayList(BotaniaAPI.getAllCategories()); - Collections.sort(allCategories); - - lastTime = ClientTickHandler.ticksInGame; - - title = stackUsed.getDisplayName(); - currentOpenLexicon = this; - - left = width / 2 - guiWidth / 2; - top = height / 2 - guiHeight / 2; - - buttonList.clear(); - if (isIndex()) { - int x = 18; - for (int i = 0; i < 12; i++) { - int y = 16 + i * 12; - buttonList.add(new GuiButtonInvisible((GuiLexiconIndex) this, i, left + x, top + y, 110, 10, "")); - } - populateIndex(); - } else if (isCategoryIndex()) { - int categories = allCategories.size(); - for (int i = 0; i < categories + 1; i++) { - LexiconCategory category = null; - category = i >= categories ? null : allCategories.get(i); - int perline = 5; - int x = i % perline; - int y = i / perline; - - int size = 22; - GuiButtonCategory button = - new GuiButtonCategory(i, left + 18 + x * size, top + 50 + y * size, this, category); - buttonList.add(button); - } - } - populateBookmarks(); - if (isMainPage()) { - buttonList.add(new GuiButtonOptions(-1, left - 6, top + guiHeight - 54)); - buttonList.add(new GuiButtonAchievement(-2, left - 6, top + guiHeight - 40)); - buttonList.add(new GuiButtonChallenges(-3, left - 6, top + guiHeight - 25)); - - GuiButtonUpdateWarning button = new GuiButtonUpdateWarning(-4, left - 6, top + guiHeight - 70); - buttonList.add(button); - - if (PersistentVariableHelper.lastBotaniaVersion.equals(LibMisc.VERSION)) { - button.enabled = false; - button.visible = false; - } - - if (Calendar.getInstance().get(Calendar.MONTH) == Calendar.NOVEMBER - && Calendar.getInstance().get(Calendar.DATE) == 22) - buttonList.add(new GuiButtonDoot(-99, left + 100, top + 12)); - } - - buttonList.add(new GuiButtonNotes(this, NOTES_BUTTON_ID, left - 4, top - 4)); - } - - @Override - public void updateScreen() { - if (notesEnabled && notesMoveTime < NOTE_TWEEN_TIME) notesMoveTime++; - else if (!notesEnabled && notesMoveTime > 0) notesMoveTime--; - } - - @Override - public void drawScreen(int par1, int par2, float par3) { - float time = ClientTickHandler.ticksInGame + par3; - timeDelta = time - lastTime; - lastTime = time; - partialTicks = par3; - - GL11.glColor4f(1F, 1F, 1F, 1F); - mc.renderEngine.bindTexture(texture); - drawNotes(par3); - - GL11.glColor4f(1F, 1F, 1F, 1F); - mc.renderEngine.bindTexture(texture); - drawTexturedModalRect(left, top, 0, 0, guiWidth, guiHeight); - - if (ClientProxy.jingleTheBells) drawTexturedModalRect(left + 3, top + 1, 0, 212, 138, 6); - - String subtitle = getSubtitle(); - if (subtitle != null) drawBookmark(left + guiWidth / 2, top - getTitleHeight() + 10, subtitle, true, 191); - drawBookmark(left + guiWidth / 2, top - getTitleHeight(), getTitle(), true); - - if (isMainPage()) drawHeader(); - - if (bookmarksNeedPopulation) { - populateBookmarks(); - bookmarksNeedPopulation = false; - } - - if (mc.thePlayer.getCommandSenderName().equals("haighyorkie")) { - GL11.glColor4f(1F, 1F, 1F, 1F); - mc.renderEngine.bindTexture(texture); - drawTexturedModalRect(left - 19, top + 42, 67, 180, 19, 26); - if (par1 >= left - 19 && par1 < left && par2 >= top + 62 && par2 < top + 88) { - mc.renderEngine.bindTexture(textureToff); - GL11.glPushMatrix(); - GL11.glScalef(0.5F, 0.5F, 0.5F); - GL11.glEnable(GL11.GL_BLEND); - GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); - GL11.glTranslatef(0F, 0F, 2F); - - int w = 256; - int h = 152; - int x = (int) ((ClientTickHandler.ticksInGame + par3) * 6) % (width + w) - w; - int y = (int) - (top + guiHeight / 2 - h / 4 + Math.sin((ClientTickHandler.ticksInGame + par3) / 6.0) * 40); - - drawTexturedModalRect(x * 2, y * 2, 0, 0, w, h); - GL11.glDisable(GL11.GL_BLEND); - GL11.glPopMatrix(); - - RenderHelper.renderTooltip( - par1, - par2, - Arrays.asList( - EnumChatFormatting.GOLD + "#goldfishchris", - EnumChatFormatting.AQUA + "IT SAYS MANUAL")); - } - } - - super.drawScreen(par1, par2, par3); - - if (hasTutorialArrow) { - mc.renderEngine.bindTexture(texture); - GL11.glEnable(GL11.GL_BLEND); - GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); - GL11.glColor4f( - 1F, 1F, 1F, 0.7F + (float) (Math.sin((ClientTickHandler.ticksInGame + par3) * 0.3F) + 1) * 0.15F); - drawTexturedModalRect(tutorialArrowX, tutorialArrowY, 20, 200, TUTORIAL_ARROW_WIDTH, TUTORIAL_ARROW_HEIGHT); - GL11.glDisable(GL11.GL_BLEND); - } - } - - public void drawNotes(float part) { - int size = 105; - - float time = notesMoveTime; - if (notesMoveTime < NOTE_TWEEN_TIME && notesEnabled) time += part; - else if (notesMoveTime > 0 && !notesEnabled) time -= part; - - int drawSize = (int) (size * time / NOTE_TWEEN_TIME); - int x = left - drawSize; - int y = top + 10; - - drawTexturedModalRect(x, y, 146, 0, drawSize, 125); - - String noteDisplay = note; - if (notesEnabled && ClientTickHandler.ticksInGame % 20 < 10) noteDisplay += "&r_"; - - fontRendererObj.drawString(StatCollector.translateToLocal("botaniamisc.notes"), x + 5, y - 7, 0x666666); - - boolean unicode = fontRendererObj.getUnicodeFlag(); - fontRendererObj.setUnicodeFlag(true); - - PageText.renderText(x + 5, y - 3, 92, 120, 0, noteDisplay); - fontRendererObj.setUnicodeFlag(unicode); - } - - public void drawBookmark(int x, int y, String s, boolean drawLeft) { - drawBookmark(x, y, s, drawLeft, 180); - } - - public void drawBookmark(int x, int y, String s, boolean drawLeft, int v) { - drawBookmark(x, y, s, drawLeft, 0x111111, v); - } - - public void drawBookmark(int x, int y, String s, boolean drawLeft, int color, int v) { - // This function is called from the buttons so I can't use fontRendererObj - FontRenderer font = Minecraft.getMinecraft().fontRenderer; - boolean unicode = font.getUnicodeFlag(); - font.setUnicodeFlag(true); - int l = font.getStringWidth(s); - int fontOff = 0; - - if (!drawLeft) { - x += l / 2; - fontOff = 2; - } - - Minecraft.getMinecraft().renderEngine.bindTexture(texture); - - GL11.glColor4f(1F, 1F, 1F, 1F); - drawTexturedModalRect(x + l / 2 + 3, y - 1, 54, v, 6, 11); - if (drawLeft) drawTexturedModalRect(x - l / 2 - 9, y - 1, 61, v, 6, 11); - for (int i = 0; i < l + 6; i++) drawTexturedModalRect(x - l / 2 - 3 + i, y - 1, 60, v, 1, 11); - - font.drawString(s, x - l / 2 + fontOff, y, color, false); - font.setUnicodeFlag(unicode); - } - - void drawHeader() { - GL11.glPushMatrix(); - GL11.glColor4f(1F, 1F, 1F, 1F); - Minecraft.getMinecraft().renderEngine.bindTexture(texture); - drawTexturedModalRect(left - 8, top + 9, 0, 224, 140, 31); - - int color = 0xffd200; - boolean unicode = fontRendererObj.getUnicodeFlag(); - fontRendererObj.drawString(title, left + 18, top + 13, color); - fontRendererObj.setUnicodeFlag(true); - fontRendererObj.drawString( - String.format(StatCollector.translateToLocal("botaniamisc.edition"), ItemLexicon.getEdition()), - left + 24, - top + 22, - color); - - String s = EnumChatFormatting.BOLD + categoryHighlight; - fontRendererObj.drawString(s, left + guiWidth / 2 - fontRendererObj.getStringWidth(s) / 2, top + 36, 0); - - fontRendererObj.setUnicodeFlag(unicode); - GL11.glPopMatrix(); - - categoryHighlight = ""; - } - - boolean isMainPage() { - return true; - } - - @Override - protected void actionPerformed(GuiButton par1GuiButton) { - if (par1GuiButton.id >= BOOKMARK_START) { - if (par1GuiButton.id >= BOOKMARK_START + MAX_BOOKMARK_COUNT) { - if (par1GuiButton instanceof GuiButtonChallengeInfo) - mc.displayGuiScreen(new GuiLexiconEntry(LexiconData.challenges, this)); - else mc.displayGuiScreen(new GuiLexiconHistory()); - ClientTickHandler.notifyPageChange(); - } else handleBookmark(par1GuiButton); - } else if (par1GuiButton instanceof GuiButtonCategory) { - LexiconCategory category = ((GuiButtonCategory) par1GuiButton).getCategory(); - - mc.displayGuiScreen(new GuiLexiconIndex(category)); - ClientTickHandler.notifyPageChange(); - } else - switch (par1GuiButton.id) { - case -1: - mc.displayGuiScreen(new GuiBotaniaConfig(this)); - break; - case -2: - mc.displayGuiScreen(new GuiAchievementsHacky(this, mc.thePlayer.getStatFileWriter())); - break; - case -3: - mc.displayGuiScreen(new GuiLexiconChallengesList()); - break; - case -4: - if (isShiftKeyDown()) { - try { - if (Desktop.isDesktopSupported()) - Desktop.getDesktop() - .browse(new URI("http://botaniamod.net/changelog.php#" - + PersistentVariableHelper.lastBotaniaVersion.replaceAll( - "\\.|\\s", "-"))); - } catch (Exception e) { - e.printStackTrace(); - } - } else { - PersistentVariableHelper.lastBotaniaVersion = LibMisc.VERSION; - PersistentVariableHelper.saveSafe(); - par1GuiButton.visible = false; - par1GuiButton.enabled = false; - } - - break; - case NOTES_BUTTON_ID: - notesEnabled = !notesEnabled; - break; - } - } - - public void handleBookmark(GuiButton par1GuiButton) { - boolean modified = false; - int i = par1GuiButton.id - BOOKMARK_START; - String key = getNotesKey(); - if (i == bookmarks.size()) { - if (!bookmarkKeys.contains(key)) { - bookmarks.add(copy()); - bookmarkKeys.add(key); - modified = true; - } - } else { - if (isShiftKeyDown()) { - bookmarks.remove(i); - bookmarkKeys.remove(i); - - modified = true; - } else { - GuiLexicon bookmark = bookmarks.get(i).copy(); - if (!bookmark.getTitle().equals(getTitle())) { - Minecraft.getMinecraft().displayGuiScreen(bookmark); - if (bookmark instanceof IParented) ((IParented) bookmark).setParent(this); - ClientTickHandler.notifyPageChange(); - } - } - } - - bookmarksNeedPopulation = true; - if (modified) PersistentVariableHelper.saveSafe(); - } - - @Override - public boolean doesGuiPauseGame() { - return false; - } - - public int bookmarkWidth(String b) { - if (fontRendererObj == null) fontRendererObj = Minecraft.getMinecraft().fontRenderer; - - boolean unicode = fontRendererObj.getUnicodeFlag(); - fontRendererObj.setUnicodeFlag(true); - int width = fontRendererObj.getStringWidth(b) + 15; - fontRendererObj.setUnicodeFlag(unicode); - return width; - } - - String getTitle() { - return title; - } - - String getSubtitle() { - return null; - } - - int getTitleHeight() { - return getSubtitle() == null ? 12 : 22; - } - - boolean isIndex() { - return false; - } - - boolean isChallenge() { - return false; - } - - boolean isCategoryIndex() { - return true; - } - - void populateIndex() { - List categoryList = BotaniaAPI.getAllCategories(); - int shift = 2; - for (int i = shift; i < 12; i++) { - int i_ = i - shift; - GuiButtonInvisible button = (GuiButtonInvisible) buttonList.get(i); - LexiconCategory category = i_ >= categoryList.size() ? null : categoryList.get(i_); - if (category != null) button.displayString = StatCollector.translateToLocal(category.getUnlocalizedName()); - else { - button.displayString = StatCollector.translateToLocal("botaniamisc.lexiconIndex"); - break; - } - } - } - - void populateBookmarks() { - List remove = new ArrayList(); - List buttons = buttonList; - for (GuiButton button : buttons) if (button.id >= BOOKMARK_START) remove.add(button); - buttonList.removeAll(remove); - - int len = bookmarks.size(); - boolean thisExists = false; - for (GuiLexicon lex : bookmarks) if (lex.getTitle().equals(getTitle())) thisExists = true; - - boolean addEnabled = len < MAX_BOOKMARK_COUNT && this instanceof IParented && !thisExists; - for (int i = 0; i < len + (addEnabled ? 1 : 0); i++) { - boolean isAdd = i == bookmarks.size(); - GuiLexicon gui = isAdd ? null : bookmarks.get(i); - buttonList.add(new GuiButtonBookmark( - BOOKMARK_START + i, - left + 138, - top + 18 + 14 * i, - gui == null ? this : gui, - gui == null ? "+" : gui.getTitle())); - } - - if (isMainPage()) - buttonList.add(new GuiButtonHistory( - BOOKMARK_START + MAX_BOOKMARK_COUNT, - left + 138, - top + guiHeight - 24, - StatCollector.translateToLocal("botaniamisc.history"), - this)); - else if (isChallenge()) - buttonList.add(new GuiButtonChallengeInfo( - BOOKMARK_START + MAX_BOOKMARK_COUNT, - left + 138, - top + guiHeight - 24, - StatCollector.translateToLocal("botaniamisc.info"), - this)); - } - - public static void startTutorial() { - tutorial.clear(); - - tutorial.add(LexiconData.lexicon); - tutorial.add(LexiconData.flowers); - tutorial.add(LexiconData.apothecary); - tutorial.add(LexiconData.pureDaisy); - tutorial.add(LexiconData.wand); - tutorial.add(LexiconData.manaIntro); - tutorial.add(LexiconData.pool); - tutorial.add(LexiconData.spreader); - if (ConfigHandler.hardcorePassiveGeneration > 0) tutorial.add(LexiconData.generatingIntro); - tutorial.add(LexiconData.passiveGen); - tutorial.add(LexiconData.daybloom); - tutorial.add(LexiconData.functionalIntro); - tutorial.add(LexiconData.runicAltar); - - MinecraftForge.EVENT_BUS.post(new BotaniaTutorialStartEvent(tutorial)); - } - - public final void putTutorialArrow() { - hasTutorialArrow = !tutorial.isEmpty(); - if (hasTutorialArrow) positionTutorialArrow(); - } - - public void positionTutorialArrow() { - LexiconEntry entry = tutorial.peek(); - LexiconCategory category = entry.category; - - List buttons = buttonList; - for (GuiButton button : buttons) - if (button instanceof GuiButtonCategory) { - GuiButtonCategory catButton = (GuiButtonCategory) button; - if (catButton.getCategory() == category) { - orientTutorialArrowWithButton(button); - break; - } - } - } - - public void orientTutorialArrowWithButton(GuiButton button) { - tutorialArrowX = button.xPosition - TUTORIAL_ARROW_WIDTH; - tutorialArrowY = button.yPosition - TUTORIAL_ARROW_HEIGHT; - } - - boolean closeScreenOnInvKey() { - return true; - } - - @Override - protected void keyTyped(char par1, int par2) { - handleNoteKey(par1, par2); - - if (!notesEnabled && closeScreenOnInvKey() && mc.gameSettings.keyBindInventory.getKeyCode() == par2) { - mc.displayGuiScreen(null); - mc.setIngameFocus(); - } - - if (par2 == KONAMI_CODE[konamiIndex]) { - konamiIndex++; - if (konamiIndex >= KONAMI_CODE.length) { - mc.getSoundHandler() - .playSound(PositionedSoundRecord.func_147673_a(new ResourceLocation("botania:way"))); - konamiIndex = 0; - } - } else konamiIndex = 0; - - super.keyTyped(par1, par2); - } - - public void handleNoteKey(char par1, int par2) { - if (notesEnabled) { - Keyboard.enableRepeatEvents(true); - boolean changed = false; - - if (par2 == 14 && note.length() > 0) { - if (isCtrlKeyDown()) note = ""; - else { - if (note.endsWith("
")) note = note.substring(0, note.length() - 4); - else note = note.substring(0, note.length() - 1); - } - changed = true; - } - - if ((ChatAllowedCharacters.isAllowedCharacter(par1) || par2 == 28) && note.length() < 250) { - note += par2 == 28 ? "
" : par1; - changed = true; - } - - if (changed) { - notes.put(getNotesKey(), note); - PersistentVariableHelper.saveSafe(); - } - } else Keyboard.enableRepeatEvents(false); - } - - public static GuiLexicon create(NBTTagCompound cmp) { - String type = cmp.getString(TAG_TYPE); - try { - GuiLexicon lex = (GuiLexicon) Class.forName(type).newInstance(); - if (lex != null) lex.load(cmp); - if (isValidLexiconGui(lex)) return lex; - return null; - } catch (Exception e) { - e.printStackTrace(); - return null; - } - } - - public void serialize(NBTTagCompound cmp) { - cmp.setString(TAG_TYPE, getClass().getName()); - } - - public String getNotesKey() { - return "index"; - } - - public void load(NBTTagCompound cmp) { - // NO-OP - } - - public GuiLexicon copy() { - return new GuiLexicon(); - } - - public static boolean isValidLexiconGui(GuiLexicon gui) { - if (gui == null) return false; - if (gui.isCategoryIndex() || gui.isChallenge()) return true; - if (gui.isIndex()) { - GuiLexiconIndex indexGui = (GuiLexiconIndex) gui; - if (indexGui.category == null) return true; - return BotaniaAPI.getAllCategories().contains(indexGui.category); - } - - GuiLexiconEntry entryGui = (GuiLexiconEntry) gui; - if (!BotaniaAPI.getAllEntries().contains(entryGui.entry)) return false; - - return entryGui.page < entryGui.entry.pages.size(); - } + public static GuiLexicon currentOpenLexicon = new GuiLexicon(); + public static ItemStack stackUsed; + + public static HashMap notes = new HashMap(); + + private static final String TAG_TYPE = "type"; + + private static final int[] KONAMI_CODE = { 200, 200, 208, 208, 203, 205, 203, 205, 48, 30 }; + + public static final int BOOKMARK_START = 1337; + public static final int NOTES_BUTTON_ID = 1336; // random button tho + public static final int MAX_BOOKMARK_COUNT = 8; + public static List bookmarks = new ArrayList(); + public static List bookmarkKeys = new ArrayList(); + boolean bookmarksNeedPopulation = false; + + public static Queue tutorial = new ArrayDeque(); + + public static final ResourceLocation texture = new ResourceLocation(LibResources.GUI_LEXICON); + public static final ResourceLocation textureToff = new ResourceLocation(LibResources.GUI_TOFF); + + public float lastTime = 0F; + public float partialTicks = 0F; + public float timeDelta = 0F; + + private static final int TUTORIAL_ARROW_WIDTH = 10; + private static final int TUTORIAL_ARROW_HEIGHT = 12; + boolean hasTutorialArrow; + int tutorialArrowX, tutorialArrowY; + int konamiIndex; + + private static final int NOTE_TWEEN_TIME = 5; + public static boolean notesEnabled; + static int notesMoveTime; + public String note = ""; + public String categoryHighlight = ""; + + List allCategories; + + String title; + int guiWidth = 146; + int guiHeight = 180; + int left, top; + + @Override + public final void initGui() { + super.initGui(); + + if(PersistentVariableHelper.firstLoad) { + PersistentVariableHelper.firstLoad = false; + PersistentVariableHelper.saveSafe(); + } + + String key = getNotesKey(); + if(notes.containsKey(key)) + note = notes.get(key); + + onInitGui(); + + putTutorialArrow(); + } + + public void onInitGui() { + allCategories = new ArrayList(BotaniaAPI.getAllCategories()); + Collections.sort(allCategories); + + lastTime = ClientTickHandler.ticksInGame; + + title = stackUsed.getDisplayName(); + currentOpenLexicon = this; + + left = width / 2 - guiWidth / 2; + top = height / 2 - guiHeight / 2; + + buttonList.clear(); + if(isIndex()) { + int x = 18; + for(int i = 0; i < 12; i++) { + int y = 16 + i * 12; + buttonList.add(new GuiButtonInvisible((GuiLexiconIndex) this, i, left + x, top + y, 110, 10, "")); + } + populateIndex(); + } else if(isCategoryIndex()) { + int categories = allCategories.size(); + for(int i = 0; i < categories + 1; i++) { + LexiconCategory category = null; + category = i >= categories ? null : allCategories.get(i); + int perline = 5; + int x = i % perline; + int y = i / perline; + + int size = 22; + GuiButtonCategory button = new GuiButtonCategory(i, left + 18 + x * size, top + 50 + y * size, this, category); + buttonList.add(button); + } + } + populateBookmarks(); + if(isMainPage()) { + buttonList.add(new GuiButtonOptions(-1, left - 6, top + guiHeight - 54)); + buttonList.add(new GuiButtonAchievement(-2, left - 6, top + guiHeight - 40)); + buttonList.add(new GuiButtonChallenges(-3, left - 6, top + guiHeight - 25)); + + GuiButtonUpdateWarning button = new GuiButtonUpdateWarning(-4, left - 6, top + guiHeight - 70); + buttonList.add(button); + + if(PersistentVariableHelper.lastBotaniaVersion.equals(LibMisc.VERSION)) { + button.enabled = false; + button.visible = false; + } + + if(Calendar.getInstance().get(Calendar.MONTH) == Calendar.NOVEMBER && Calendar.getInstance().get(Calendar.DATE) == 22) + buttonList.add(new GuiButtonDoot(-99, left + 100, top + 12)); + } + + buttonList.add(new GuiButtonNotes(this, NOTES_BUTTON_ID, left - 4, top - 4)); + } + + @Override + public void updateScreen() { + if(notesEnabled && notesMoveTime < NOTE_TWEEN_TIME) + notesMoveTime++; + else if(!notesEnabled && notesMoveTime > 0) + notesMoveTime--; + } + + @Override + public void drawScreen(int par1, int par2, float par3) { + float time = ClientTickHandler.ticksInGame + par3; + timeDelta = time - lastTime; + lastTime = time; + partialTicks = par3; + + GL11.glColor4f(1F, 1F, 1F, 1F); + mc.renderEngine.bindTexture(texture); + drawNotes(par3); + + GL11.glColor4f(1F, 1F, 1F, 1F); + mc.renderEngine.bindTexture(texture); + drawTexturedModalRect(left, top, 0, 0, guiWidth, guiHeight); + + if(ClientProxy.jingleTheBells) + drawTexturedModalRect(left + 3, top + 1, 0, 212, 138, 6); + + String subtitle = getSubtitle(); + if(subtitle != null) + drawBookmark(left + guiWidth / 2, top - getTitleHeight() + 10, subtitle, true, 191); + drawBookmark(left + guiWidth / 2, top - getTitleHeight(), getTitle(), true); + + if(isMainPage()) + drawHeader(); + + if(bookmarksNeedPopulation) { + populateBookmarks(); + bookmarksNeedPopulation = false; + } + + if(mc.thePlayer.getCommandSenderName().equals("haighyorkie")) { + GL11.glColor4f(1F, 1F, 1F, 1F); + mc.renderEngine.bindTexture(texture); + drawTexturedModalRect(left - 19, top + 42, 67, 180, 19, 26); + if(par1 >= left - 19 && par1 < left && par2 >= top + 62 && par2 < top + 88) { + mc.renderEngine.bindTexture(textureToff); + GL11.glPushMatrix(); + GL11.glScalef(0.5F, 0.5F, 0.5F); + GL11.glEnable(GL11.GL_BLEND); + GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); + GL11.glTranslatef(0F, 0F, 2F); + + int w = 256; + int h = 152; + int x = (int) ((ClientTickHandler.ticksInGame + par3) * 6) % (width + w) - w; + int y = (int) (top + guiHeight / 2 - h / 4 + Math.sin((ClientTickHandler.ticksInGame + par3) / 6.0) * 40); + + drawTexturedModalRect(x * 2, y * 2, 0, 0, w, h); + GL11.glDisable(GL11.GL_BLEND); + GL11.glPopMatrix(); + + RenderHelper.renderTooltip(par1, par2, Arrays.asList(EnumChatFormatting.GOLD + "#goldfishchris", EnumChatFormatting.AQUA + "IT SAYS MANUAL")); + } + } + + super.drawScreen(par1, par2, par3); + + if(hasTutorialArrow) { + mc.renderEngine.bindTexture(texture); + GL11.glEnable(GL11.GL_BLEND); + GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); + GL11.glColor4f(1F, 1F, 1F, 0.7F + (float) (Math.sin((ClientTickHandler.ticksInGame + par3) * 0.3F) + 1) * 0.15F); + drawTexturedModalRect(tutorialArrowX, tutorialArrowY, 20, 200, TUTORIAL_ARROW_WIDTH, TUTORIAL_ARROW_HEIGHT); + GL11.glDisable(GL11.GL_BLEND); + } + } + + public void drawNotes(float part) { + int size = 105; + + float time = notesMoveTime; + if(notesMoveTime < NOTE_TWEEN_TIME && notesEnabled) + time += part; + else if(notesMoveTime > 0 && !notesEnabled) + time -= part; + + int drawSize = (int) (size * time / NOTE_TWEEN_TIME); + int x = left - drawSize; + int y = top + 10; + + drawTexturedModalRect(x, y, 146, 0, drawSize, 125); + + String noteDisplay = note; + if(notesEnabled && ClientTickHandler.ticksInGame % 20 < 10) + noteDisplay += "&r_"; + + fontRendererObj.drawString(StatCollector.translateToLocal("botaniamisc.notes"), x + 5, y - 7, 0x666666); + + boolean unicode = fontRendererObj.getUnicodeFlag(); + fontRendererObj.setUnicodeFlag(true); + + PageText.renderText(x + 5, y - 3, 92, 120, 0, noteDisplay); + fontRendererObj.setUnicodeFlag(unicode); + } + + + public void drawBookmark(int x, int y, String s, boolean drawLeft) { + drawBookmark(x, y, s, drawLeft, 180); + } + + public void drawBookmark(int x, int y, String s, boolean drawLeft, int v) { + drawBookmark(x, y, s, drawLeft, 0x111111, v); + } + + public void drawBookmark(int x, int y, String s, boolean drawLeft, int color, int v) { + // This function is called from the buttons so I can't use fontRendererObj + FontRenderer font = Minecraft.getMinecraft().fontRenderer; + boolean unicode = font.getUnicodeFlag(); + font.setUnicodeFlag(true); + int l = font.getStringWidth(s); + int fontOff = 0; + + if(!drawLeft) { + x += l / 2; + fontOff = 2; + } + + Minecraft.getMinecraft().renderEngine.bindTexture(texture); + + GL11.glColor4f(1F, 1F, 1F, 1F); + drawTexturedModalRect(x + l / 2 + 3, y - 1, 54, v, 6, 11); + if(drawLeft) + drawTexturedModalRect(x - l / 2 - 9, y - 1, 61, v, 6, 11); + for(int i = 0; i < l + 6; i++) + drawTexturedModalRect(x - l / 2 - 3 + i, y - 1, 60, v, 1, 11); + + font.drawString(s, x - l / 2 + fontOff, y, color, false); + font.setUnicodeFlag(unicode); + } + + void drawHeader() { + GL11.glPushMatrix(); + GL11.glColor4f(1F, 1F, 1F, 1F); + Minecraft.getMinecraft().renderEngine.bindTexture(texture); + drawTexturedModalRect(left - 8, top + 9, 0, 224, 140, 31); + + int color = 0xffd200; + boolean unicode = fontRendererObj.getUnicodeFlag(); + fontRendererObj.drawString(title, left + 18, top + 13, color); + fontRendererObj.setUnicodeFlag(true); + fontRendererObj.drawString(String.format(StatCollector.translateToLocal("botaniamisc.edition"), ItemLexicon.getEdition()), left + 24, top + 22, color); + + String s = EnumChatFormatting.BOLD + categoryHighlight; + fontRendererObj.drawString(s, left + guiWidth / 2 - fontRendererObj.getStringWidth(s) / 2, top + 36, 0); + + fontRendererObj.setUnicodeFlag(unicode); + GL11.glPopMatrix(); + + categoryHighlight = ""; + } + + boolean isMainPage() { + return true; + } + + @Override + protected void actionPerformed(GuiButton par1GuiButton) { + if(par1GuiButton.id >= BOOKMARK_START) { + if(par1GuiButton.id >= BOOKMARK_START + MAX_BOOKMARK_COUNT) { + if(par1GuiButton instanceof GuiButtonChallengeInfo) + mc.displayGuiScreen(new GuiLexiconEntry(LexiconData.challenges, this)); + else mc.displayGuiScreen(new GuiLexiconHistory()); + ClientTickHandler.notifyPageChange(); + } else handleBookmark(par1GuiButton); + } else if(par1GuiButton instanceof GuiButtonCategory) { + LexiconCategory category = ((GuiButtonCategory) par1GuiButton).getCategory(); + + mc.displayGuiScreen(new GuiLexiconIndex(category)); + ClientTickHandler.notifyPageChange(); + } else switch(par1GuiButton.id) { + case -1 : + mc.displayGuiScreen(new GuiBotaniaConfig(this)); + break; + case -2 : + mc.displayGuiScreen(new GuiAchievementsHacky(this, mc.thePlayer.getStatFileWriter())); + break; + case -3 : + mc.displayGuiScreen(new GuiLexiconChallengesList()); + break; + case -4 : + if(isShiftKeyDown()) { + try { + if(Desktop.isDesktopSupported()) + Desktop.getDesktop().browse(new URI("http://botaniamod.net/changelog.php#" + PersistentVariableHelper.lastBotaniaVersion.replaceAll("\\.|\\s", "-"))); + } catch (Exception e) { + e.printStackTrace(); + } + } else { + PersistentVariableHelper.lastBotaniaVersion = LibMisc.VERSION; + PersistentVariableHelper.saveSafe(); + par1GuiButton.visible = false; + par1GuiButton.enabled = false; + } + + break; + case NOTES_BUTTON_ID : + notesEnabled = !notesEnabled; + break; + } + } + + public void handleBookmark(GuiButton par1GuiButton) { + boolean modified = false; + int i = par1GuiButton.id - BOOKMARK_START; + String key = getNotesKey(); + if(i == bookmarks.size()) { + if(!bookmarkKeys.contains(key)) { + bookmarks.add(copy()); + bookmarkKeys.add(key); + modified = true; + } + } else { + if(isShiftKeyDown()) { + bookmarks.remove(i); + bookmarkKeys.remove(i); + + modified = true; + } else { + GuiLexicon bookmark = bookmarks.get(i).copy(); + if(!bookmark.getTitle().equals(getTitle())) { + Minecraft.getMinecraft().displayGuiScreen(bookmark); + if(bookmark instanceof IParented) + ((IParented) bookmark).setParent(this); + ClientTickHandler.notifyPageChange(); + } + } + } + + bookmarksNeedPopulation = true; + if(modified) + PersistentVariableHelper.saveSafe(); + } + + @Override + public boolean doesGuiPauseGame() { + return false; + } + + public int bookmarkWidth(String b) { + if(fontRendererObj == null) + fontRendererObj = Minecraft.getMinecraft().fontRenderer; + + boolean unicode = fontRendererObj.getUnicodeFlag(); + fontRendererObj.setUnicodeFlag(true); + int width = fontRendererObj.getStringWidth(b) + 15; + fontRendererObj.setUnicodeFlag(unicode); + return width; + } + + String getTitle() { + return title; + } + + String getSubtitle() { + return null; + } + + int getTitleHeight() { + return getSubtitle() == null ? 12 : 22; + } + + boolean isIndex() { + return false; + } + + boolean isChallenge() { + return false; + } + + boolean isCategoryIndex() { + return true; + } + + void populateIndex() { + List categoryList = BotaniaAPI.getAllCategories(); + int shift = 2; + for(int i = shift; i < 12; i++) { + int i_ = i - shift; + GuiButtonInvisible button = (GuiButtonInvisible) buttonList.get(i); + LexiconCategory category = i_ >= categoryList.size() ? null : categoryList.get(i_); + if(category != null) + button.displayString = StatCollector.translateToLocal(category.getUnlocalizedName()); + else { + button.displayString = StatCollector.translateToLocal("botaniamisc.lexiconIndex"); + break; + } + } + } + + void populateBookmarks() { + List remove = new ArrayList(); + List buttons = buttonList; + for(GuiButton button : buttons) + if(button.id >= BOOKMARK_START) + remove.add(button); + buttonList.removeAll(remove); + + int len = bookmarks.size(); + boolean thisExists = false; + for(GuiLexicon lex : bookmarks) + if(lex.getTitle().equals(getTitle())) + thisExists = true; + + boolean addEnabled = len < MAX_BOOKMARK_COUNT && this instanceof IParented && !thisExists; + for(int i = 0; i < len + (addEnabled ? 1 : 0); i++) { + boolean isAdd = i == bookmarks.size(); + GuiLexicon gui = isAdd ? null : bookmarks.get(i); + buttonList.add(new GuiButtonBookmark(BOOKMARK_START + i, left + 138, top + 18 + 14 * i, gui == null ? this : gui, gui == null ? "+" : gui.getTitle())); + } + + if(isMainPage()) + buttonList.add(new GuiButtonHistory(BOOKMARK_START + MAX_BOOKMARK_COUNT, left + 138, top + guiHeight - 24, StatCollector.translateToLocal("botaniamisc.history"), this)); + else if(isChallenge()) + buttonList.add(new GuiButtonChallengeInfo(BOOKMARK_START + MAX_BOOKMARK_COUNT, left + 138, top + guiHeight - 24, StatCollector.translateToLocal("botaniamisc.info"), this)); + } + + public static void startTutorial() { + tutorial.clear(); + + tutorial.add(LexiconData.lexicon); + tutorial.add(LexiconData.flowers); + tutorial.add(LexiconData.apothecary); + tutorial.add(LexiconData.pureDaisy); + tutorial.add(LexiconData.wand); + tutorial.add(LexiconData.manaIntro); + tutorial.add(LexiconData.pool); + tutorial.add(LexiconData.spreader); + if(ConfigHandler.hardcorePassiveGeneration > 0) + tutorial.add(LexiconData.generatingIntro); + tutorial.add(LexiconData.passiveGen); + tutorial.add(LexiconData.daybloom); + tutorial.add(LexiconData.functionalIntro); + tutorial.add(LexiconData.runicAltar); + + MinecraftForge.EVENT_BUS.post(new BotaniaTutorialStartEvent(tutorial)); + } + + public final void putTutorialArrow() { + hasTutorialArrow = !tutorial.isEmpty(); + if(hasTutorialArrow) + positionTutorialArrow(); + } + + public void positionTutorialArrow() { + LexiconEntry entry = tutorial.peek(); + LexiconCategory category = entry.category; + + List buttons = buttonList; + for(GuiButton button : buttons) + if(button instanceof GuiButtonCategory) { + GuiButtonCategory catButton = (GuiButtonCategory) button; + if(catButton.getCategory() == category) { + orientTutorialArrowWithButton(button); + break; + } + } + } + + public void orientTutorialArrowWithButton(GuiButton button) { + tutorialArrowX = button.xPosition - TUTORIAL_ARROW_WIDTH; + tutorialArrowY = button.yPosition - TUTORIAL_ARROW_HEIGHT; + } + + boolean closeScreenOnInvKey() { + return true; + } + + @Override + protected void keyTyped(char par1, int par2) { + handleNoteKey(par1, par2); + + if(!notesEnabled && closeScreenOnInvKey() && mc.gameSettings.keyBindInventory.getKeyCode() == par2) { + mc.displayGuiScreen(null); + mc.setIngameFocus(); + } + + if(par2 == KONAMI_CODE[konamiIndex]) { + konamiIndex++; + if(konamiIndex >= KONAMI_CODE.length) { + mc.getSoundHandler().playSound(PositionedSoundRecord.func_147673_a(new ResourceLocation("botania:way"))); + konamiIndex = 0; + } + } else konamiIndex = 0; + + super.keyTyped(par1, par2); + } + + public void handleNoteKey(char par1, int par2) { + if(notesEnabled) { + Keyboard.enableRepeatEvents(true); + boolean changed = false; + + if(par2 == 14 && note.length() > 0) { + if(isCtrlKeyDown()) + note = ""; + else { + if(note.endsWith("
")) + note = note.substring(0, note.length() - 4); + else note = note.substring(0, note.length() - 1); + } + changed = true; + } + + if((ChatAllowedCharacters.isAllowedCharacter(par1) || par2 == 28) && note.length() < 250) { + note += par2 == 28 ? "
" : par1; + changed = true; + } + + if(changed) { + notes.put(getNotesKey(), note); + PersistentVariableHelper.saveSafe(); + } + } else Keyboard.enableRepeatEvents(false); + } + + public static GuiLexicon create(NBTTagCompound cmp) { + String type = cmp.getString(TAG_TYPE); + try { + GuiLexicon lex = (GuiLexicon) Class.forName(type).newInstance(); + if(lex != null) + lex.load(cmp); + if(isValidLexiconGui(lex)) + return lex; + return null; + } catch (Exception e) { + e.printStackTrace(); + return null; + } + } + + public void serialize(NBTTagCompound cmp) { + cmp.setString(TAG_TYPE, getClass().getName()); + } + + public String getNotesKey() { + return "index"; + } + + public void load(NBTTagCompound cmp) { + // NO-OP + } + + public GuiLexicon copy() { + return new GuiLexicon(); + } + + public static boolean isValidLexiconGui(GuiLexicon gui) { + if(gui == null) + return false; + if(gui.isCategoryIndex() || gui.isChallenge()) + return true; + if(gui.isIndex()) { + GuiLexiconIndex indexGui = (GuiLexiconIndex) gui; + if(indexGui.category == null) + return true; + return BotaniaAPI.getAllCategories().contains(indexGui.category); + } + + GuiLexiconEntry entryGui = (GuiLexiconEntry) gui; + if(!BotaniaAPI.getAllEntries().contains(entryGui.entry)) + return false; + + return entryGui.page < entryGui.entry.pages.size(); + } } + diff --git a/src/main/java/vazkii/botania/client/gui/lexicon/GuiLexiconChallenge.java b/src/main/java/vazkii/botania/client/gui/lexicon/GuiLexiconChallenge.java index a664710f55..5f852aedce 100644 --- a/src/main/java/vazkii/botania/client/gui/lexicon/GuiLexiconChallenge.java +++ b/src/main/java/vazkii/botania/client/gui/lexicon/GuiLexiconChallenge.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jun 29, 2015, 5:25:06 PM (GMT)] */ package vazkii.botania.client.gui.lexicon; @@ -16,8 +16,10 @@ import net.minecraft.nbt.NBTTagCompound; import net.minecraft.util.EnumChatFormatting; import net.minecraft.util.StatCollector; + import org.lwjgl.opengl.GL11; import org.lwjgl.opengl.GL12; + import vazkii.botania.client.challenge.Challenge; import vazkii.botania.client.challenge.ModChallenges; import vazkii.botania.client.core.handler.ClientTickHandler; @@ -27,162 +29,153 @@ public class GuiLexiconChallenge extends GuiLexicon implements IParented { - private static final String TAG_CHALLENGE = "challenge"; - - Challenge challenge; - GuiLexicon parent; - GuiButton backButton, completeButton; - - public GuiLexiconChallenge() { - parent = new GuiLexiconChallengesList(); - } - - public GuiLexiconChallenge(GuiLexicon parent, Challenge challenge) { - this.parent = parent; - this.challenge = challenge; - setTitle(); - } - - public void setTitle() { - title = challenge == null ? "(null)" : StatCollector.translateToLocal(challenge.unlocalizedName); - } - - @Override - public void onInitGui() { - super.onInitGui(); - setTitle(); - - buttonList.add(backButton = new GuiButtonBack(12, left + guiWidth / 2 - 8, top + guiHeight + 2)); - buttonList.add(completeButton = new GuiButton(13, left + 20, top + guiHeight - 35, guiWidth - 40, 20, "")); - setCompleteButtonTitle(); - } - - @Override - public void drawScreen(int par1, int par2, float par3) { - super.drawScreen(par1, par2, par3); - - RenderHelper.enableGUIStandardItemLighting(); - GL11.glEnable(GL12.GL_RESCALE_NORMAL); - RenderItem.getInstance() - .renderItemIntoGUI(fontRendererObj, mc.renderEngine, challenge.icon, left + 18, top + 15); - RenderHelper.disableStandardItemLighting(); - GL11.glEnable(GL11.GL_BLEND); - - boolean unicode = fontRendererObj.getUnicodeFlag(); - fontRendererObj.setUnicodeFlag(true); - fontRendererObj.drawString( - EnumChatFormatting.BOLD + StatCollector.translateToLocal(challenge.unlocalizedName), - left + 38, - top + 13, - 0); - fontRendererObj.drawString( - StatCollector.translateToLocal(challenge.level.getName()) + " / " - + (challenge.complete ? EnumChatFormatting.DARK_GREEN : EnumChatFormatting.DARK_RED) - + StatCollector.translateToLocal( - challenge.complete ? "botaniamisc.completed" : "botaniamisc.notCompleted"), - left + 38, - top + 23, - 0); - - int width = guiWidth - 30; - int x = left + 16; - int y = top + 28; - - PageText.renderText(x, y, width, guiHeight, challenge.unlocalizedName + ".desc"); - fontRendererObj.setUnicodeFlag(unicode); - } - - @Override - protected void keyTyped(char par1, int par2) { - if (par2 == 14 && !notesEnabled) // Backspace - back(); - else if (par2 == 199) { // Home - mc.displayGuiScreen(new GuiLexicon()); - ClientTickHandler.notifyPageChange(); - } - - super.keyTyped(par1, par2); - } - - @Override - protected void mouseClicked(int par1, int par2, int par3) { - super.mouseClicked(par1, par2, par3); - - if (par3 == 1) back(); - } - - @Override - protected void actionPerformed(GuiButton par1GuiButton) { - if (par1GuiButton.id >= BOOKMARK_START) super.actionPerformed(par1GuiButton); - else if (par1GuiButton.id == 12) { - mc.displayGuiScreen(parent); - ClientTickHandler.notifyPageChange(); - } else if (par1GuiButton.id == 13) { - challenge.complete = !challenge.complete; - setCompleteButtonTitle(); - PersistentVariableHelper.saveSafe(); - } else if (par1GuiButton.id == NOTES_BUTTON_ID) notesEnabled = !notesEnabled; - } - - void setCompleteButtonTitle() { - completeButton.displayString = StatCollector.translateToLocal( - challenge.complete ? "botaniamisc.markNotCompleted" : "botaniamisc.markCompleted"); - } - - void back() { - if (backButton.enabled) { - actionPerformed(backButton); - backButton.func_146113_a(mc.getSoundHandler()); - } - } - - @Override - public void setParent(GuiLexicon gui) { - parent = gui; - } - - @Override - boolean isMainPage() { - return false; - } - - @Override - String getTitle() { - return title; - } - - @Override - boolean isChallenge() { - return true; - } - - @Override - boolean isCategoryIndex() { - return false; - } - - @Override - public GuiLexicon copy() { - return new GuiLexiconChallenge(parent, challenge); - } - - @Override - public void serialize(NBTTagCompound cmp) { - super.serialize(cmp); - cmp.setString(TAG_CHALLENGE, challenge.unlocalizedName); - } - - @Override - public void load(NBTTagCompound cmp) { - super.load(cmp); - String challengeName = cmp.getString(TAG_CHALLENGE); - Challenge c = ModChallenges.challengeLookup.get(challengeName); - challenge = c; - setTitle(); - } - - @Override - public String getNotesKey() { - return "challenge_" + challenge.unlocalizedName; - } + private static final String TAG_CHALLENGE = "challenge"; + + Challenge challenge; + GuiLexicon parent; + GuiButton backButton, completeButton; + + public GuiLexiconChallenge() { + parent = new GuiLexiconChallengesList(); + } + + public GuiLexiconChallenge(GuiLexicon parent, Challenge challenge) { + this.parent = parent; + this.challenge = challenge; + setTitle(); + } + + public void setTitle() { + title = challenge == null ? "(null)" : StatCollector.translateToLocal(challenge.unlocalizedName); + } + + @Override + public void onInitGui() { + super.onInitGui(); + setTitle(); + + buttonList.add(backButton = new GuiButtonBack(12, left + guiWidth / 2 - 8, top + guiHeight + 2)); + buttonList.add(completeButton = new GuiButton(13, left + 20, top + guiHeight - 35, guiWidth - 40, 20, "")); + setCompleteButtonTitle(); + } + + @Override + public void drawScreen(int par1, int par2, float par3) { + super.drawScreen(par1, par2, par3); + + RenderHelper.enableGUIStandardItemLighting(); + GL11.glEnable(GL12.GL_RESCALE_NORMAL); + RenderItem.getInstance().renderItemIntoGUI(fontRendererObj, mc.renderEngine, challenge.icon, left + 18, top + 15); + RenderHelper.disableStandardItemLighting(); + GL11.glEnable(GL11.GL_BLEND); + + boolean unicode = fontRendererObj.getUnicodeFlag(); + fontRendererObj.setUnicodeFlag(true); + fontRendererObj.drawString(EnumChatFormatting.BOLD + StatCollector.translateToLocal(challenge.unlocalizedName), left + 38, top + 13, 0); + fontRendererObj.drawString(StatCollector.translateToLocal(challenge.level.getName()) + " / " + (challenge.complete ? EnumChatFormatting.DARK_GREEN : EnumChatFormatting.DARK_RED) + StatCollector.translateToLocal(challenge.complete ? "botaniamisc.completed" : "botaniamisc.notCompleted"), left + 38, top + 23, 0); + + int width = guiWidth - 30; + int x = left + 16; + int y = top + 28; + + PageText.renderText(x, y, width, guiHeight, challenge.unlocalizedName + ".desc"); + fontRendererObj.setUnicodeFlag(unicode); + } + + @Override + protected void keyTyped(char par1, int par2) { + if(par2 == 14 && !notesEnabled) // Backspace + back(); + else if(par2 == 199) { // Home + mc.displayGuiScreen(new GuiLexicon()); + ClientTickHandler.notifyPageChange(); + } + + super.keyTyped(par1, par2); + } + + @Override + protected void mouseClicked(int par1, int par2, int par3) { + super.mouseClicked(par1, par2, par3); + + if(par3 == 1) + back(); + } + + @Override + protected void actionPerformed(GuiButton par1GuiButton) { + if(par1GuiButton.id >= BOOKMARK_START) + super.actionPerformed(par1GuiButton); + else if(par1GuiButton.id == 12) { + mc.displayGuiScreen(parent); + ClientTickHandler.notifyPageChange(); + } else if(par1GuiButton.id == 13) { + challenge.complete = !challenge.complete; + setCompleteButtonTitle(); + PersistentVariableHelper.saveSafe(); + } else if(par1GuiButton.id == NOTES_BUTTON_ID) + notesEnabled = !notesEnabled; + } + + void setCompleteButtonTitle() { + completeButton.displayString = StatCollector.translateToLocal(challenge.complete ? "botaniamisc.markNotCompleted" : "botaniamisc.markCompleted"); + } + + void back() { + if(backButton.enabled) { + actionPerformed(backButton); + backButton.func_146113_a(mc.getSoundHandler()); + } + } + + @Override + public void setParent(GuiLexicon gui) { + parent = gui; + } + + @Override + boolean isMainPage() { + return false; + } + + @Override + String getTitle() { + return title; + } + + @Override + boolean isChallenge() { + return true; + } + + @Override + boolean isCategoryIndex() { + return false; + } + + @Override + public GuiLexicon copy() { + return new GuiLexiconChallenge(parent, challenge); + } + + @Override + public void serialize(NBTTagCompound cmp) { + super.serialize(cmp); + cmp.setString(TAG_CHALLENGE, challenge.unlocalizedName); + } + + @Override + public void load(NBTTagCompound cmp) { + super.load(cmp); + String challengeName = cmp.getString(TAG_CHALLENGE); + Challenge c = ModChallenges.challengeLookup.get(challengeName); + challenge = c; + setTitle(); + } + + @Override + public String getNotesKey() { + return "challenge_" + challenge.unlocalizedName; + } + } diff --git a/src/main/java/vazkii/botania/client/gui/lexicon/GuiLexiconChallengesList.java b/src/main/java/vazkii/botania/client/gui/lexicon/GuiLexiconChallengesList.java index 0e6b1c4cb7..66484f628e 100644 --- a/src/main/java/vazkii/botania/client/gui/lexicon/GuiLexiconChallengesList.java +++ b/src/main/java/vazkii/botania/client/gui/lexicon/GuiLexiconChallengesList.java @@ -2,15 +2,16 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jun 29, 2015, 4:24:07 PM (GMT)] */ package vazkii.botania.client.gui.lexicon; import java.util.List; + import net.minecraft.client.gui.GuiButton; import net.minecraft.util.EnumChatFormatting; import net.minecraft.util.StatCollector; @@ -23,126 +24,127 @@ public class GuiLexiconChallengesList extends GuiLexicon implements IParented { - GuiLexicon parent; - GuiButton backButton; - - public GuiLexiconChallengesList() { - parent = new GuiLexicon(); - title = StatCollector.translateToLocal("botaniamisc.challenges"); - } - - @Override - public void onInitGui() { - super.onInitGui(); - title = StatCollector.translateToLocal("botaniamisc.challenges"); - - buttonList.add(backButton = new GuiButtonBack(12, left + guiWidth / 2 - 8, top + guiHeight + 2)); - - int perline = 6; - int i = 13; - int y = top + 20; - for (EnumChallengeLevel level : EnumChallengeLevel.class.getEnumConstants()) { - int j = 0; - for (Challenge c : ModChallenges.challenges.get(level)) { - buttonList.add(new GuiButtonChallengeIcon(i, left + 20 + j % perline * 18, y + j / perline * 17, c)); - i++; - j++; - } - y += 44; - } - } - - @Override - public void drawScreen(int par1, int par2, float par3) { - super.drawScreen(par1, par2, par3); - - boolean unicode = fontRendererObj.getUnicodeFlag(); - fontRendererObj.setUnicodeFlag(true); - for (EnumChallengeLevel level : EnumChallengeLevel.class.getEnumConstants()) { - List list = ModChallenges.challenges.get(level); - int complete = 0; - for (Challenge c : list) if (c.complete) complete++; - - fontRendererObj.drawString( - EnumChatFormatting.BOLD + StatCollector.translateToLocal(level.getName()) + EnumChatFormatting.RESET - + " (" + complete + "/" + list.size() + ")", - left + 20, - top + 11 + level.ordinal() * 44, - 0); - } - fontRendererObj.setUnicodeFlag(unicode); - } - - @Override - protected void keyTyped(char par1, int par2) { - if (par2 == 14 && !notesEnabled) // Backspace - back(); - else if (par2 == 199) { // Home - mc.displayGuiScreen(new GuiLexicon()); - ClientTickHandler.notifyPageChange(); - } - - super.keyTyped(par1, par2); - } - - @Override - protected void mouseClicked(int par1, int par2, int par3) { - super.mouseClicked(par1, par2, par3); - - if (par3 == 1) back(); - } - - @Override - protected void actionPerformed(GuiButton par1GuiButton) { - if (par1GuiButton.id >= BOOKMARK_START) super.actionPerformed(par1GuiButton); - else if (par1GuiButton.id == 12) { - mc.displayGuiScreen(parent); - ClientTickHandler.notifyPageChange(); - } else if (par1GuiButton instanceof GuiButtonChallengeIcon) { - GuiButtonChallengeIcon cbutton = (GuiButtonChallengeIcon) par1GuiButton; - mc.displayGuiScreen(new GuiLexiconChallenge(this, cbutton.challenge)); - } else if (par1GuiButton.id == NOTES_BUTTON_ID) notesEnabled = !notesEnabled; - } - - void back() { - if (backButton.enabled) { - actionPerformed(backButton); - backButton.func_146113_a(mc.getSoundHandler()); - } - } - - @Override - public void setParent(GuiLexicon gui) { - parent = gui; - } - - @Override - boolean isMainPage() { - return false; - } - - @Override - String getTitle() { - return title; - } - - @Override - boolean isChallenge() { - return true; - } - - @Override - boolean isCategoryIndex() { - return false; - } - - @Override - public GuiLexicon copy() { - return new GuiLexiconChallengesList(); - } - - @Override - public String getNotesKey() { - return "challengelist"; - } + GuiLexicon parent; + GuiButton backButton; + + public GuiLexiconChallengesList() { + parent = new GuiLexicon(); + title = StatCollector.translateToLocal("botaniamisc.challenges"); + } + + @Override + public void onInitGui() { + super.onInitGui(); + title = StatCollector.translateToLocal("botaniamisc.challenges"); + + buttonList.add(backButton = new GuiButtonBack(12, left + guiWidth / 2 - 8, top + guiHeight + 2)); + + int perline = 6; + int i = 13; + int y = top + 20; + for(EnumChallengeLevel level : EnumChallengeLevel.class.getEnumConstants()) { + int j = 0; + for(Challenge c : ModChallenges.challenges.get(level)) { + buttonList.add(new GuiButtonChallengeIcon(i, left + 20 + j % perline * 18, y + j / perline * 17, c)); + i++; + j++; + } + y += 44; + } + } + + @Override + public void drawScreen(int par1, int par2, float par3) { + super.drawScreen(par1, par2, par3); + + boolean unicode = fontRendererObj.getUnicodeFlag(); + fontRendererObj.setUnicodeFlag(true); + for(EnumChallengeLevel level : EnumChallengeLevel.class.getEnumConstants()) { + List list = ModChallenges.challenges.get(level); + int complete = 0; + for(Challenge c : list) + if(c.complete) + complete++; + + fontRendererObj.drawString(EnumChatFormatting.BOLD + StatCollector.translateToLocal(level.getName()) + EnumChatFormatting.RESET + " (" + complete + "/" + list.size() + ")", left + 20, top + 11 + level.ordinal() * 44, 0); + } + fontRendererObj.setUnicodeFlag(unicode); + } + + @Override + protected void keyTyped(char par1, int par2) { + if(par2 == 14 && !notesEnabled) // Backspace + back(); + else if(par2 == 199) { // Home + mc.displayGuiScreen(new GuiLexicon()); + ClientTickHandler.notifyPageChange(); + } + + super.keyTyped(par1, par2); + } + + @Override + protected void mouseClicked(int par1, int par2, int par3) { + super.mouseClicked(par1, par2, par3); + + if(par3 == 1) + back(); + } + + @Override + protected void actionPerformed(GuiButton par1GuiButton) { + if(par1GuiButton.id >= BOOKMARK_START) + super.actionPerformed(par1GuiButton); + else if(par1GuiButton.id == 12) { + mc.displayGuiScreen(parent); + ClientTickHandler.notifyPageChange(); + } else if(par1GuiButton instanceof GuiButtonChallengeIcon) { + GuiButtonChallengeIcon cbutton = (GuiButtonChallengeIcon) par1GuiButton; + mc.displayGuiScreen(new GuiLexiconChallenge(this, cbutton.challenge)); + } else if(par1GuiButton.id == NOTES_BUTTON_ID) + notesEnabled = !notesEnabled; + } + + void back() { + if(backButton.enabled) { + actionPerformed(backButton); + backButton.func_146113_a(mc.getSoundHandler()); + } + } + + @Override + public void setParent(GuiLexicon gui) { + parent = gui; + } + + @Override + boolean isMainPage() { + return false; + } + + @Override + String getTitle() { + return title; + } + + @Override + boolean isChallenge() { + return true; + } + + @Override + boolean isCategoryIndex() { + return false; + } + + @Override + public GuiLexicon copy() { + return new GuiLexiconChallengesList(); + } + + @Override + public String getNotesKey() { + return "challengelist"; + } + } diff --git a/src/main/java/vazkii/botania/client/gui/lexicon/GuiLexiconEntry.java b/src/main/java/vazkii/botania/client/gui/lexicon/GuiLexiconEntry.java index e23559920e..4aebd5db32 100644 --- a/src/main/java/vazkii/botania/client/gui/lexicon/GuiLexiconEntry.java +++ b/src/main/java/vazkii/botania/client/gui/lexicon/GuiLexiconEntry.java @@ -13,6 +13,7 @@ import java.awt.Desktop; import java.net.URI; import java.util.List; + import net.minecraft.client.Minecraft; import net.minecraft.client.gui.GuiButton; import net.minecraft.client.gui.GuiScreen; @@ -21,7 +22,9 @@ import net.minecraft.util.ChatStyle; import net.minecraft.util.EnumChatFormatting; import net.minecraft.util.StatCollector; + import org.lwjgl.input.Mouse; + import vazkii.botania.api.BotaniaAPI; import vazkii.botania.api.internal.IGuiLexiconEntry; import vazkii.botania.api.lexicon.IAddonEntry; @@ -35,375 +38,384 @@ public class GuiLexiconEntry extends GuiLexicon implements IGuiLexiconEntry, IParented { - private static final String TAG_ENTRY = "entry"; - private static final String TAG_PAGE = "page"; - - public int page = 0; - public boolean firstEntry = false; - LexiconEntry entry; - GuiScreen parent; - String title; - String subtitle; - - GuiButton leftButton, rightButton, backButton; - - public GuiLexiconEntry() { - parent = new GuiLexicon(); - setTitle(); - } - - public GuiLexiconEntry(LexiconEntry entry, GuiScreen parent) { - this.entry = entry; - this.parent = parent; - setTitle(); - } - - public void setTitle() { - if (entry == null) { - title = "(null)"; - return; - } - - title = StatCollector.translateToLocal(entry.getUnlocalizedName()); - if (entry instanceof IAddonEntry) - subtitle = StatCollector.translateToLocal(((IAddonEntry) entry).getSubtitle()); - else subtitle = null; - } - - @Override - public void onInitGui() { - super.onInitGui(); - - buttonList.add(backButton = new GuiButtonBackWithShift(0, left + guiWidth / 2 - 8, top + guiHeight + 2)); - buttonList.add(leftButton = new GuiButtonPage(1, left, top + guiHeight - 10, false)); - buttonList.add(rightButton = new GuiButtonPage(2, left + guiWidth - 18, top + guiHeight - 10, true)); - buttonList.add(new GuiButtonShare(3, left + guiWidth - 6, top - 2)); - if (entry.getWebLink() != null) buttonList.add(new GuiButtonViewOnline(4, left - 8, top + 12)); - - if (!GuiLexicon.isValidLexiconGui(this)) { - currentOpenLexicon = new GuiLexicon(); - mc.displayGuiScreen(currentOpenLexicon); - ClientTickHandler.notifyPageChange(); - return; - } - - LexiconPage page = entry.pages.get(this.page); - - page.onOpened(this); - updatePageButtons(); - GuiLexiconHistory.visit(entry); - } - - @Override - public LexiconEntry getEntry() { - return entry; - } - - @Override - public int getPageOn() { - return page; - } - - @Override - boolean isMainPage() { - return false; - } - - @Override - String getTitle() { - return String.format("%s " + EnumChatFormatting.ITALIC + "(%s/%s)", title, page + 1, entry.pages.size()); - } - - @Override - String getSubtitle() { - return subtitle; - } - - @Override - boolean isCategoryIndex() { - return false; - } - - @Override - protected void actionPerformed(GuiButton par1GuiButton) { - LexiconPage currentPage = entry.pages.get(page); - LexiconPage newPage; - - if (par1GuiButton.id >= BOOKMARK_START) handleBookmark(par1GuiButton); - else if (par1GuiButton.id == NOTES_BUTTON_ID) notesEnabled = !notesEnabled; - else - switch (par1GuiButton.id) { - case 0: - currentPage.onClosed(this); - mc.displayGuiScreen(GuiScreen.isShiftKeyDown() ? new GuiLexicon() : parent); - ClientTickHandler.notifyPageChange(); - break; - case 1: - currentPage.onClosed(this); - page--; - newPage = entry.pages.get(page); - newPage.onOpened(this); - - ClientTickHandler.notifyPageChange(); - break; - case 2: - currentPage.onClosed(this); - page++; - newPage = entry.pages.get(page); - newPage.onOpened(this); - - ClientTickHandler.notifyPageChange(); - break; - case 3: - Minecraft mc = Minecraft.getMinecraft(); - String cmd = "/botania-share " + entry.getUnlocalizedName(); - - mc.ingameGUI.getChatGUI().addToSentMessages(cmd); - mc.thePlayer.sendChatMessage(cmd); - break; - case 4: - try { - if (Desktop.isDesktopSupported()) Desktop.getDesktop().browse(new URI(entry.getWebLink())); - } catch (Exception e) { - e.printStackTrace(); - } - } - - updatePageButtons(); - currentPage.onActionPerformed(this, par1GuiButton); - } - - public GuiLexiconEntry setFirstEntry() { - firstEntry = true; - return this; - } - - public void updatePageButtons() { - leftButton.enabled = page != 0; - rightButton.enabled = page + 1 < entry.pages.size(); - if (firstEntry) backButton.enabled = !rightButton.enabled; - } - - @Override - public void drawScreen(int par1, int par2, float par3) { - super.drawScreen(par1, par2, par3); - - LexiconPage page = entry.pages.get(this.page); - page.renderScreen(this, par1, par2); - } - - @Override - public void updateScreen() { - super.updateScreen(); - - LexiconPage page = entry.pages.get(this.page); - page.updateScreen(this); - - if (this.page == entry.pages.size() - 1) { - LexiconEntry entry = tutorial.peek(); - if (entry == this.entry) { - tutorial.poll(); - positionTutorialArrow(); - if (tutorial.isEmpty()) { - mc.thePlayer.addChatMessage(new ChatComponentTranslation("botaniamisc.tutorialEnded") - .setChatStyle(new ChatStyle().setColor(EnumChatFormatting.RED))); - hasTutorialArrow = false; - } - } - } - } - - @Override - public void positionTutorialArrow() { - LexiconEntry entry = tutorial.peek(); - if (entry != this.entry) { - orientTutorialArrowWithButton(backButton); - return; - } - - if (rightButton.enabled && rightButton.visible) orientTutorialArrowWithButton(rightButton); - } - - @Override - public int getLeft() { - return left; - } - - @Override - public int getTop() { - return top; - } - - @Override - public int getWidth() { - return guiWidth; - } - - @Override - public int getHeight() { - return guiHeight; - } - - @Override - public float getZLevel() { - return zLevel; - } - - @Override - public void setParent(GuiLexicon gui) { - parent = gui; - } - - int fx = 0; - boolean swiped = false; - - @Override - protected void mouseClickMove(int x, int y, int button, long time) { - if (button == 0 && Math.abs(x - fx) > 100 && mc.gameSettings.touchscreen && !swiped) { - double swipe = (x - fx) / Math.max(1, (double) time); - if (swipe < 0.5) { - nextPage(); - swiped = true; - } else if (swipe > 0.5) { - prevPage(); - swiped = true; - } - } - } - - @Override - protected void mouseClicked(int par1, int par2, int par3) { - super.mouseClicked(par1, par2, par3); - - fx = par1; - switch (par3) { - case 1: - back(); - break; - case 3: - nextPage(); - break; - case 4: - prevPage(); - break; - } - } - - @Override - public void handleMouseInput() { - super.handleMouseInput(); - - if (Mouse.getEventButton() == 0) swiped = false; - - int w = Mouse.getEventDWheel(); - if (w < 0) nextPage(); - else if (w > 0) prevPage(); - } - - @Override - protected void keyTyped(char par1, int par2) { - handleNoteKey(par1, par2); - - LexiconPage page = entry.pages.get(this.page); - page.onKeyPressed(par1, par2); - - if (par2 == 1) { - mc.displayGuiScreen((GuiScreen) null); - mc.setIngameFocus(); - } else if (par2 == 203 || par2 == 200 || par2 == 201) // Left, Up, Page Up - prevPage(); - else if (par2 == 205 || par2 == 208 || par2 == 209) // Right, Down Page Down - nextPage(); - if (par2 == 14 && !notesEnabled) // Backspace - back(); - else if (par2 == 199) { // Home - mc.displayGuiScreen(new GuiLexicon()); - ClientTickHandler.notifyPageChange(); - } - } - - void back() { - if (backButton.enabled) { - actionPerformed(backButton); - backButton.func_146113_a(mc.getSoundHandler()); - } - } - - void nextPage() { - if (rightButton.enabled) { - actionPerformed(rightButton); - rightButton.func_146113_a(mc.getSoundHandler()); - updateNote(); - } - } - - void prevPage() { - if (leftButton.enabled) { - actionPerformed(leftButton); - leftButton.func_146113_a(mc.getSoundHandler()); - updateNote(); - } - } - - void updateNote() { - String key = getNotesKey(); - if (!notes.containsKey(key)) note = ""; - else note = notes.get(key); - } - - @Override - public List getButtonList() { - return buttonList; - } - - @Override - public float getElapsedTicks() { - return lastTime; - } - - @Override - public float getPartialTicks() { - return partialTicks; - } - - @Override - public float getTickDelta() { - return timeDelta; - } - - @Override - public void serialize(NBTTagCompound cmp) { - super.serialize(cmp); - cmp.setString(TAG_ENTRY, entry.getUnlocalizedName()); - cmp.setInteger(TAG_PAGE, page); - } - - @Override - public void load(NBTTagCompound cmp) { - super.load(cmp); - - String entryStr = cmp.getString(TAG_ENTRY); - for (LexiconEntry entry : BotaniaAPI.getAllEntries()) - if (entry.getUnlocalizedName().equals(entryStr)) { - this.entry = entry; - break; - } - - page = cmp.getInteger(TAG_PAGE); - - setTitle(); - } - - @Override - public GuiLexicon copy() { - GuiLexiconEntry gui = new GuiLexiconEntry(entry, new GuiScreen()); - gui.page = page; - gui.setTitle(); - return gui; - } - - @Override - public String getNotesKey() { - return "entry_" + entry.unlocalizedName + "_" + page; - } + private static final String TAG_ENTRY = "entry"; + private static final String TAG_PAGE = "page"; + + public int page = 0; + public boolean firstEntry = false; + LexiconEntry entry; + GuiScreen parent; + String title; + String subtitle; + + GuiButton leftButton, rightButton, backButton; + + public GuiLexiconEntry() { + parent = new GuiLexicon(); + setTitle(); + } + + public GuiLexiconEntry(LexiconEntry entry, GuiScreen parent) { + this.entry = entry; + this.parent = parent; + setTitle(); + } + + public void setTitle() { + if(entry == null) { + title = "(null)"; + return; + } + + title = StatCollector.translateToLocal(entry.getUnlocalizedName()); + if(entry instanceof IAddonEntry) + subtitle = StatCollector.translateToLocal(((IAddonEntry) entry).getSubtitle()); + else subtitle = null; + } + + @Override + public void onInitGui() { + super.onInitGui(); + + buttonList.add(backButton = new GuiButtonBackWithShift(0, left + guiWidth / 2 - 8, top + guiHeight + 2)); + buttonList.add(leftButton = new GuiButtonPage(1, left, top + guiHeight - 10, false)); + buttonList.add(rightButton = new GuiButtonPage(2, left + guiWidth - 18, top + guiHeight - 10, true)); + buttonList.add(new GuiButtonShare(3, left + guiWidth - 6, top - 2)); + if(entry.getWebLink() != null) + buttonList.add(new GuiButtonViewOnline(4, left - 8, top + 12)); + + if(!GuiLexicon.isValidLexiconGui(this)) { + currentOpenLexicon = new GuiLexicon(); + mc.displayGuiScreen(currentOpenLexicon); + ClientTickHandler.notifyPageChange(); + return; + } + + LexiconPage page = entry.pages.get(this.page); + + page.onOpened(this); + updatePageButtons(); + GuiLexiconHistory.visit(entry); + } + + @Override + public LexiconEntry getEntry() { + return entry; + } + + @Override + public int getPageOn() { + return page; + } + + @Override + boolean isMainPage() { + return false; + } + + @Override + String getTitle() { + return String.format("%s " + EnumChatFormatting.ITALIC + "(%s/%s)", title, page + 1, entry.pages.size()); + } + + @Override + String getSubtitle() { + return subtitle; + } + + @Override + boolean isCategoryIndex() { + return false; + } + + @Override + protected void actionPerformed(GuiButton par1GuiButton) { + LexiconPage currentPage = entry.pages.get(page); + LexiconPage newPage; + + if(par1GuiButton.id >= BOOKMARK_START) + handleBookmark(par1GuiButton); + else if(par1GuiButton.id == NOTES_BUTTON_ID) + notesEnabled = !notesEnabled; + else + switch(par1GuiButton.id) { + case 0 : + currentPage.onClosed(this); + mc.displayGuiScreen(GuiScreen.isShiftKeyDown() ? new GuiLexicon() : parent); + ClientTickHandler.notifyPageChange(); + break; + case 1 : + currentPage.onClosed(this); + page--; + newPage = entry.pages.get(page); + newPage.onOpened(this); + + ClientTickHandler.notifyPageChange(); + break; + case 2 : + currentPage.onClosed(this); + page++; + newPage = entry.pages.get(page); + newPage.onOpened(this); + + ClientTickHandler.notifyPageChange(); + break; + case 3 : + Minecraft mc = Minecraft.getMinecraft(); + String cmd = "/botania-share " + entry.getUnlocalizedName(); + + mc.ingameGUI.getChatGUI().addToSentMessages(cmd); + mc.thePlayer.sendChatMessage(cmd); + break; + case 4 : + try { + if(Desktop.isDesktopSupported()) + Desktop.getDesktop().browse(new URI(entry.getWebLink())); + } catch(Exception e) { + e.printStackTrace(); + } + } + + updatePageButtons(); + currentPage.onActionPerformed(this, par1GuiButton); + } + + public GuiLexiconEntry setFirstEntry() { + firstEntry = true; + return this; + } + + public void updatePageButtons() { + leftButton.enabled = page != 0; + rightButton.enabled = page + 1 < entry.pages.size(); + if(firstEntry) + backButton.enabled = !rightButton.enabled; + } + + @Override + public void drawScreen(int par1, int par2, float par3) { + super.drawScreen(par1, par2, par3); + + LexiconPage page = entry.pages.get(this.page); + page.renderScreen(this, par1, par2); + } + + @Override + public void updateScreen() { + super.updateScreen(); + + LexiconPage page = entry.pages.get(this.page); + page.updateScreen(this); + + if(this.page == entry.pages.size() - 1) { + LexiconEntry entry = tutorial.peek(); + if(entry == this.entry) { + tutorial.poll(); + positionTutorialArrow(); + if(tutorial.isEmpty()) { + mc.thePlayer.addChatMessage(new ChatComponentTranslation("botaniamisc.tutorialEnded").setChatStyle(new ChatStyle().setColor(EnumChatFormatting.RED))); + hasTutorialArrow = false; + } + } + } + } + + @Override + public void positionTutorialArrow() { + LexiconEntry entry = tutorial.peek(); + if(entry != this.entry) { + orientTutorialArrowWithButton(backButton); + return; + } + + if(rightButton.enabled && rightButton.visible) + orientTutorialArrowWithButton(rightButton); + } + + @Override + public int getLeft() { + return left; + } + + @Override + public int getTop() { + return top; + } + + @Override + public int getWidth() { + return guiWidth; + } + + @Override + public int getHeight() { + return guiHeight; + } + + @Override + public float getZLevel() { + return zLevel; + } + + @Override + public void setParent(GuiLexicon gui) { + parent = gui; + } + + int fx = 0; + boolean swiped = false; + + @Override + protected void mouseClickMove(int x, int y, int button, long time) { + if(button == 0 && Math.abs(x - fx) > 100 && mc.gameSettings.touchscreen && !swiped) { + double swipe = (x - fx) / Math.max(1, (double) time); + if(swipe < 0.5) { + nextPage(); + swiped = true; + } else if(swipe > 0.5) { + prevPage(); + swiped = true; + } + } + } + + @Override + protected void mouseClicked(int par1, int par2, int par3) { + super.mouseClicked(par1, par2, par3); + + fx = par1; + switch(par3) { + case 1: + back(); + break; + case 3: + nextPage(); + break; + case 4: + prevPage(); + break; + } + } + + @Override + public void handleMouseInput() { + super.handleMouseInput(); + + if(Mouse.getEventButton() == 0) + swiped = false; + + int w = Mouse.getEventDWheel(); + if(w < 0) + nextPage(); + else if(w > 0) + prevPage(); + } + + @Override + protected void keyTyped(char par1, int par2) { + handleNoteKey(par1, par2); + + LexiconPage page = entry.pages.get(this.page); + page.onKeyPressed(par1, par2); + + if(par2 == 1) { + mc.displayGuiScreen((GuiScreen)null); + mc.setIngameFocus(); + } else if(par2 == 203 || par2 == 200 || par2 == 201) // Left, Up, Page Up + prevPage(); + else if(par2 == 205 || par2 == 208 || par2 == 209) // Right, Down Page Down + nextPage(); + if(par2 == 14 && !notesEnabled) // Backspace + back(); + else if(par2 == 199) { // Home + mc.displayGuiScreen(new GuiLexicon()); + ClientTickHandler.notifyPageChange(); + } + } + + void back() { + if(backButton.enabled) { + actionPerformed(backButton); + backButton.func_146113_a(mc.getSoundHandler()); + } + } + + void nextPage() { + if(rightButton.enabled) { + actionPerformed(rightButton); + rightButton.func_146113_a(mc.getSoundHandler()); + updateNote(); + } + } + + void prevPage() { + if(leftButton.enabled) { + actionPerformed(leftButton); + leftButton.func_146113_a(mc.getSoundHandler()); + updateNote(); + } + } + + void updateNote() { + String key = getNotesKey(); + if(!notes.containsKey(key)) + note = ""; + else note = notes.get(key); + } + + @Override + public List getButtonList() { + return buttonList; + } + + @Override + public float getElapsedTicks() { + return lastTime; + } + + @Override + public float getPartialTicks() { + return partialTicks; + } + + @Override + public float getTickDelta() { + return timeDelta; + } + + @Override + public void serialize(NBTTagCompound cmp) { + super.serialize(cmp); + cmp.setString(TAG_ENTRY, entry.getUnlocalizedName()); + cmp.setInteger(TAG_PAGE, page); + } + + @Override + public void load(NBTTagCompound cmp) { + super.load(cmp); + + String entryStr = cmp.getString(TAG_ENTRY); + for(LexiconEntry entry : BotaniaAPI.getAllEntries()) + if(entry.getUnlocalizedName().equals(entryStr)) { + this.entry = entry; + break; + } + + page = cmp.getInteger(TAG_PAGE); + + setTitle(); + } + + @Override + public GuiLexicon copy() { + GuiLexiconEntry gui = new GuiLexiconEntry(entry, new GuiScreen()); + gui.page = page; + gui.setTitle(); + return gui; + } + + @Override + public String getNotesKey() { + return "entry_" + entry.unlocalizedName + "_" + page; + } } diff --git a/src/main/java/vazkii/botania/client/gui/lexicon/GuiLexiconHistory.java b/src/main/java/vazkii/botania/client/gui/lexicon/GuiLexiconHistory.java index b425d92641..159d793a4c 100644 --- a/src/main/java/vazkii/botania/client/gui/lexicon/GuiLexiconHistory.java +++ b/src/main/java/vazkii/botania/client/gui/lexicon/GuiLexiconHistory.java @@ -2,16 +2,17 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Mar 2, 2015, 6:27:58 PM (GMT)] */ package vazkii.botania.client.gui.lexicon; import java.util.ArrayList; import java.util.List; + import net.minecraft.nbt.NBTTagCompound; import net.minecraft.util.StatCollector; import vazkii.botania.api.lexicon.ILexicon; @@ -19,43 +20,43 @@ public class GuiLexiconHistory extends GuiLexiconIndex { - public static List history = new ArrayList(); - - public GuiLexiconHistory() { - super(null); - title = StatCollector.translateToLocal("botaniamisc.historyLong"); - } - - @Override - void buildEntries() { - entriesToDisplay.clear(); - ILexicon lex = (ILexicon) stackUsed.getItem(); - for (int i = history.size() - 1; i >= 0; i--) { - LexiconEntry entry = history.get(i); - if (lex.isKnowledgeUnlocked(stackUsed, entry.getKnowledgeType()) - && StatCollector.translateToLocal(entry.getUnlocalizedName()) - .toLowerCase() - .contains(searchField.getText().toLowerCase().trim())) entriesToDisplay.add(entry); - } - } - - public static void visit(LexiconEntry entry) { - if (history.contains(entry)) history.remove(entry); - history.add(entry); - } - - @Override - public GuiLexicon copy() { - return new GuiLexiconHistory(); - } - - @Override - public void load(NBTTagCompound cmp) { - // NO-OP - } - - @Override - public String getNotesKey() { - return "history"; - } + public static List history = new ArrayList(); + + public GuiLexiconHistory() { + super(null); + title = StatCollector.translateToLocal("botaniamisc.historyLong"); + } + + @Override + void buildEntries() { + entriesToDisplay.clear(); + ILexicon lex = (ILexicon) stackUsed.getItem(); + for(int i = history.size() - 1; i >= 0; i--) { + LexiconEntry entry = history.get(i); + if(lex.isKnowledgeUnlocked(stackUsed, entry.getKnowledgeType()) && StatCollector.translateToLocal(entry.getUnlocalizedName()).toLowerCase().contains(searchField.getText().toLowerCase().trim())) + entriesToDisplay.add(entry); + } + } + + public static void visit(LexiconEntry entry) { + if(history.contains(entry)) + history.remove(entry); + history.add(entry); + } + + @Override + public GuiLexicon copy() { + return new GuiLexiconHistory(); + } + + @Override + public void load(NBTTagCompound cmp) { + // NO-OP + } + + @Override + public String getNotesKey() { + return "history"; + } + } diff --git a/src/main/java/vazkii/botania/client/gui/lexicon/GuiLexiconIndex.java b/src/main/java/vazkii/botania/client/gui/lexicon/GuiLexiconIndex.java index 9ea3590810..2f1d23054e 100644 --- a/src/main/java/vazkii/botania/client/gui/lexicon/GuiLexiconIndex.java +++ b/src/main/java/vazkii/botania/client/gui/lexicon/GuiLexiconIndex.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jan 14, 2014, 6:46:59 PM (GMT)] */ package vazkii.botania.client.gui.lexicon; @@ -13,6 +13,7 @@ import java.util.ArrayList; import java.util.Collections; import java.util.List; + import net.minecraft.client.gui.Gui; import net.minecraft.client.gui.GuiButton; import net.minecraft.client.gui.GuiTextField; @@ -22,9 +23,11 @@ import net.minecraft.nbt.NBTTagCompound; import net.minecraft.util.EnumChatFormatting; import net.minecraft.util.StatCollector; + import org.lwjgl.input.Mouse; import org.lwjgl.opengl.GL11; import org.lwjgl.opengl.GL12; + import vazkii.botania.api.BotaniaAPI; import vazkii.botania.api.lexicon.ILexicon; import vazkii.botania.api.lexicon.LexiconCategory; @@ -37,438 +40,445 @@ public class GuiLexiconIndex extends GuiLexicon implements IParented { - private static final String TAG_CATEGORY = "category"; - private static final String TAG_PAGE = "page"; - - LexiconCategory category; - String title; - int page = 0; - - int tutPage = -1; - - GuiButton leftButton, rightButton, backButton; - GuiLexicon parent; - GuiTextField searchField; - - GuiButton currentButton; - LexiconEntry currentEntry; - float infoTime; - - List entriesToDisplay = new ArrayList(); - - public GuiLexiconIndex() { - parent = new GuiLexicon(); - } - - public GuiLexiconIndex(LexiconCategory category) { - this.category = category; - parent = new GuiLexicon(); - setTitle(); - } - - public void setTitle() { - title = StatCollector.translateToLocal( - category == null ? "botaniamisc.lexiconIndex" : category.getUnlocalizedName()); - } - - @Override - boolean isMainPage() { - return false; - } - - @Override - String getTitle() { - return title; - } - - @Override - boolean isIndex() { - return true; - } - - @Override - boolean isCategoryIndex() { - return false; - } - - @Override - public void onInitGui() { - super.onInitGui(); - - if (!GuiLexicon.isValidLexiconGui(this)) { - currentOpenLexicon = new GuiLexicon(); - mc.displayGuiScreen(currentOpenLexicon); - ClientTickHandler.notifyPageChange(); - return; - } - - buttonList.add(backButton = new GuiButtonBack(12, left + guiWidth / 2 - 8, top + guiHeight + 2)); - buttonList.add(leftButton = new GuiButtonPage(13, left, top + guiHeight - 10, false)); - buttonList.add(rightButton = new GuiButtonPage(14, left + guiWidth - 18, top + guiHeight - 10, true)); - - searchField = new GuiTextField(fontRendererObj, left + guiWidth / 2 + 28, top + guiHeight + 6, 200, 10); - searchField.setCanLoseFocus(false); - searchField.setFocused(true); - searchField.setEnableBackgroundDrawing(false); - - updateAll(); - } - - void updateAll() { - buildEntries(); - updatePageButtons(); - populateIndex(); - } - - void buildEntries() { - entriesToDisplay.clear(); - ILexicon lex = (ILexicon) stackUsed.getItem(); - for (LexiconEntry entry : category == null ? BotaniaAPI.getAllEntries() : category.entries) { - if (entry.isVisible() - && lex.isKnowledgeUnlocked(stackUsed, entry.getKnowledgeType()) - && matchesSearch(entry)) entriesToDisplay.add(entry); - } - Collections.sort(entriesToDisplay); - } - - boolean matchesSearch(LexiconEntry e) { - String search = searchField.getText().trim(); - if (search.isEmpty()) return true; - - search = search.toLowerCase(); - if (StatCollector.translateToLocal(e.getUnlocalizedName()).toLowerCase().contains(search)) return true; - - for (ItemStack stack : e.getDisplayedRecipes()) { - String stackName = stack.getDisplayName().toLowerCase().trim(); - if (stackName.contains(search)) return true; - } - - return false; - } - - @Override - void populateIndex() { - LexiconEntry tutEntry = tutorial != null && !tutorial.isEmpty() ? tutorial.peek() : null; - - for (int i = page * 12; i < (page + 1) * 12; i++) { - GuiButtonInvisible button = (GuiButtonInvisible) buttonList.get(i - page * 12); - LexiconEntry entry = i >= entriesToDisplay.size() ? null : entriesToDisplay.get(i); - if (entry != null) { - button.displayString = - entry.getKnowledgeType().color + "" + (entry.isPriority() ? EnumChatFormatting.ITALIC : "") - + StatCollector.translateToLocal(entry.getUnlocalizedName()); - button.displayStack = entry.getIcon(); - if (entry == tutEntry) tutPage = page; - - if (entry instanceof DLexiconEntry) button.dog = true; - } else button.displayString = ""; - } - } - - public void setHoveredButton(GuiButtonInvisible b) { - if (b == null) currentEntry = null; - else currentEntry = entriesToDisplay.get(b.id + page * 12); - currentButton = b; - } - - @Override - public void drawScreen(int par1, int par2, float par3) { - super.drawScreen(par1, par2, par3); - - if (!searchField.getText().isEmpty()) { - drawBookmark(left + 138, top + guiHeight - 24, " " + searchField.getText(), false); - mc.renderEngine.bindTexture(texture); - GL11.glColor4f(1F, 1F, 1F, 1F); - drawTexturedModalRect(left + 134, top + guiHeight - 26, 86, 180, 12, 12); - - if (entriesToDisplay.size() == 1) { - boolean unicode = mc.fontRenderer.getUnicodeFlag(); - mc.fontRenderer.setUnicodeFlag(true); - String s = StatCollector.translateToLocal("botaniamisc.enterToView"); - mc.fontRenderer.drawString( - s, left + guiWidth / 2 - mc.fontRenderer.getStringWidth(s) / 2, top + 30, 0x666666); - mc.fontRenderer.setUnicodeFlag(unicode); - } - } else { - boolean unicode = mc.fontRenderer.getUnicodeFlag(); - mc.fontRenderer.setUnicodeFlag(true); - String s = StatCollector.translateToLocal("botaniamisc.typeToSearch"); - mc.fontRenderer.drawString( - s, left + 120 - mc.fontRenderer.getStringWidth(s), top + guiHeight - 18, 0x666666); - mc.fontRenderer.setUnicodeFlag(unicode); - } - - float animationTime = 4F; - if (isShiftKeyDown()) { - if (currentButton != null) infoTime = Math.min(animationTime, infoTime + timeDelta); - } else { - infoTime = Math.max(0, infoTime - timeDelta); - - if (currentButton != null && infoTime == 0) { - int x = par1 + 10; - int y = par2; - - x = currentButton.xPosition - 20; - y = currentButton.yPosition; - - mc.fontRenderer.drawStringWithShadow("?", x, y, 0xFFFFFF); - GL11.glScalef(0.5F, 0.5F, 1F); - mc.fontRenderer.drawStringWithShadow( - EnumChatFormatting.BOLD + "Shift", x * 2 - 6, y * 2 + 20, 0xFFFFFF); - GL11.glScalef(2F, 2F, 1F); - } - } - - if (currentButton != null && infoTime > 0) { - float fract = infoTime / animationTime; - - int x = currentButton.xPosition; - int y = currentButton.yPosition; - String s = StatCollector.translateToLocal(currentEntry.getTagline()); - boolean unicode = mc.fontRenderer.getUnicodeFlag(); - mc.fontRenderer.setUnicodeFlag(true); - int width = mc.fontRenderer.getStringWidth(s); - - GL11.glPushMatrix(); - GL11.glTranslatef(x, y, 0); - GL11.glScalef(fract, 1F, 1F); - Gui.drawRect(12, -30, width + 20, -2, 0x44000000); - Gui.drawRect(10, -32, width + 22, -2, 0x44000000); - drawBookmark(width / 2 + 16, -8, s, true, 0xFFFFFF, 180); - mc.fontRenderer.setUnicodeFlag(unicode); - - net.minecraft.client.renderer.RenderHelper.enableGUIStandardItemLighting(); - GL11.glEnable(GL12.GL_RESCALE_NORMAL); - ItemStack paper = new ItemStack(Items.paper, currentEntry.pages.size()); - - RenderItem.getInstance().renderItemAndEffectIntoGUI(mc.fontRenderer, mc.renderEngine, paper, 14, -28); - RenderItem.getInstance().renderItemOverlayIntoGUI(mc.fontRenderer, mc.renderEngine, paper, 14, -28); - List stacks = currentEntry.getDisplayedRecipes(); - - if (stacks.size() > 0) { - int spaceForEach = Math.min(18, (width - 30) / stacks.size()); - for (int i = 0; i < stacks.size(); i++) { - ItemStack stack = stacks.get(i); - RenderItem.getInstance() - .renderItemAndEffectIntoGUI( - mc.fontRenderer, mc.renderEngine, stack, 38 + spaceForEach * i, -28); - } - } - - net.minecraft.client.renderer.RenderHelper.disableStandardItemLighting(); - - GL11.glPopMatrix(); - } - - setHoveredButton(null); - } - - @Override - public void positionTutorialArrow() { - LexiconEntry entry = tutorial.peek(); - LexiconCategory category = entry.category; - if (category != this.category) { - orientTutorialArrowWithButton(backButton); - return; - } - - if (tutPage != -1 && tutPage != page) { - orientTutorialArrowWithButton(tutPage < page ? leftButton : rightButton); - return; - } - - List buttons = buttonList; - for (GuiButton button : buttons) { - int id = button.id; - int index = id + page * 12; - if (index >= entriesToDisplay.size()) continue; - - if (entry == entriesToDisplay.get(index)) { - orientTutorialArrowWithButton(id >= 12 ? rightButton : button); - break; - } - } - } - - @Override - protected void actionPerformed(GuiButton par1GuiButton) { - if (par1GuiButton.id >= BOOKMARK_START) handleBookmark(par1GuiButton); - else if (par1GuiButton.id == NOTES_BUTTON_ID) notesEnabled = !notesEnabled; - else - switch (par1GuiButton.id) { - case 12: - mc.displayGuiScreen(parent); - ClientTickHandler.notifyPageChange(); - break; - case 13: - page--; - updatePageButtons(); - populateIndex(); - ClientTickHandler.notifyPageChange(); - break; - case 14: - page++; - updatePageButtons(); - populateIndex(); - ClientTickHandler.notifyPageChange(); - break; - default: - if (par1GuiButton instanceof GuiButtonInvisible && ((GuiButtonInvisible) par1GuiButton).dog) - ((GuiButtonInvisible) par1GuiButton).click(); - else { - int index = par1GuiButton.id + page * 12; - openEntry(index); - } - } - } - - void openEntry(int index) { - if (index >= entriesToDisplay.size()) return; - - LexiconEntry entry = entriesToDisplay.get(index); - mc.displayGuiScreen(new GuiLexiconEntry(entry, this)); - ClientTickHandler.notifyPageChange(); - } - - public void updatePageButtons() { - leftButton.enabled = page != 0; - rightButton.enabled = page < (entriesToDisplay.size() - 1) / 12; - putTutorialArrow(); - } - - @Override - public void setParent(GuiLexicon gui) { - parent = gui; - } - - int fx = 0; - boolean swiped = false; - - @Override - protected void mouseClickMove(int x, int y, int button, long time) { - if (button == 0 && Math.abs(x - fx) > 100 && mc.gameSettings.touchscreen && !swiped) { - double swipe = (x - fx) / Math.max(1, (double) time); - if (swipe < 0.5) { - nextPage(); - swiped = true; - } else if (swipe > 0.5) { - prevPage(); - swiped = true; - } - } - } - - @Override - protected void mouseClicked(int par1, int par2, int par3) { - super.mouseClicked(par1, par2, par3); - - searchField.mouseClicked(par1, par2, par3); - fx = par1; - switch (par3) { - case 1: - back(); - break; - case 3: - nextPage(); - break; - case 4: - prevPage(); - break; - } - } - - @Override - public void handleMouseInput() { - super.handleMouseInput(); - - if (Mouse.getEventButton() == 0) swiped = false; - - int w = Mouse.getEventDWheel(); - if (w < 0) nextPage(); - else if (w > 0) prevPage(); - } - - @Override - boolean closeScreenOnInvKey() { - return false; - } - - @Override - protected void keyTyped(char par1, int par2) { - if (par2 == 203 || par2 == 200 || par2 == 201) // Left, Up, Page Up - prevPage(); - else if (par2 == 205 || par2 == 208 || par2 == 209) // Right, Down Page Down - nextPage(); - else if (par2 == 14 && !notesEnabled && searchField.getText().isEmpty()) // Backspace - back(); - else if (par2 == 199) { // Home - mc.displayGuiScreen(new GuiLexicon()); - ClientTickHandler.notifyPageChange(); - } else if (par2 == 28 && entriesToDisplay.size() == 1) // Enter - openEntry(0); - - if (!notesEnabled) { - String search = searchField.getText(); - searchField.textboxKeyTyped(par1, par2); - if (!searchField.getText().equalsIgnoreCase(search)) updateAll(); - } - - super.keyTyped(par1, par2); - } - - void back() { - if (backButton.enabled) { - actionPerformed(backButton); - backButton.func_146113_a(mc.getSoundHandler()); - } - } - - void nextPage() { - if (rightButton.enabled) { - actionPerformed(rightButton); - rightButton.func_146113_a(mc.getSoundHandler()); - } - } - - void prevPage() { - if (leftButton.enabled) { - actionPerformed(leftButton); - leftButton.func_146113_a(mc.getSoundHandler()); - } - } - - @Override - public void serialize(NBTTagCompound cmp) { - super.serialize(cmp); - cmp.setString(TAG_CATEGORY, category == null ? "" : category.getUnlocalizedName()); - cmp.setInteger(TAG_PAGE, page); - } - - @Override - public void load(NBTTagCompound cmp) { - super.load(cmp); - String categoryStr = cmp.getString(TAG_CATEGORY); - if (categoryStr.isEmpty()) category = null; - else - for (LexiconCategory cat : BotaniaAPI.getAllCategories()) - if (cat.getUnlocalizedName().equals(categoryStr)) { - category = cat; - break; - } - page = cmp.getInteger(TAG_PAGE); - setTitle(); - } - - @Override - public GuiLexicon copy() { - GuiLexiconIndex gui = new GuiLexiconIndex(category); - gui.page = page; - gui.setTitle(); - return gui; - } - - @Override - public String getNotesKey() { - return "category_" + (category == null ? "lexindex" : category.unlocalizedName); - } + private static final String TAG_CATEGORY = "category"; + private static final String TAG_PAGE = "page"; + + LexiconCategory category; + String title; + int page = 0; + + int tutPage = -1; + + GuiButton leftButton, rightButton, backButton; + GuiLexicon parent; + GuiTextField searchField; + + GuiButton currentButton; + LexiconEntry currentEntry; + float infoTime; + + List entriesToDisplay = new ArrayList(); + + public GuiLexiconIndex() { + parent = new GuiLexicon(); + } + + public GuiLexiconIndex(LexiconCategory category) { + this.category = category; + parent = new GuiLexicon(); + setTitle(); + } + + public void setTitle() { + title = StatCollector.translateToLocal(category == null ? "botaniamisc.lexiconIndex" : category.getUnlocalizedName()); + } + + @Override + boolean isMainPage() { + return false; + } + + @Override + String getTitle() { + return title; + } + + @Override + boolean isIndex() { + return true; + } + + @Override + boolean isCategoryIndex() { + return false; + } + + @Override + public void onInitGui() { + super.onInitGui(); + + if(!GuiLexicon.isValidLexiconGui(this)) { + currentOpenLexicon = new GuiLexicon(); + mc.displayGuiScreen(currentOpenLexicon); + ClientTickHandler.notifyPageChange(); + return; + } + + buttonList.add(backButton = new GuiButtonBack(12, left + guiWidth / 2 - 8, top + guiHeight + 2)); + buttonList.add(leftButton = new GuiButtonPage(13, left, top + guiHeight - 10, false)); + buttonList.add(rightButton = new GuiButtonPage(14, left + guiWidth - 18, top + guiHeight - 10, true)); + + searchField = new GuiTextField(fontRendererObj, left + guiWidth / 2 + 28, top + guiHeight + 6, 200, 10); + searchField.setCanLoseFocus(false); + searchField.setFocused(true); + searchField.setEnableBackgroundDrawing(false); + + updateAll(); + } + + void updateAll() { + buildEntries(); + updatePageButtons(); + populateIndex(); + } + + void buildEntries() { + entriesToDisplay.clear(); + ILexicon lex = (ILexicon) stackUsed.getItem(); + for(LexiconEntry entry : category == null ? BotaniaAPI.getAllEntries() : category.entries) { + if(entry.isVisible() && lex.isKnowledgeUnlocked(stackUsed, entry.getKnowledgeType()) && matchesSearch(entry)) + entriesToDisplay.add(entry); + } + Collections.sort(entriesToDisplay); + } + + boolean matchesSearch(LexiconEntry e) { + String search = searchField.getText().trim(); + if(search.isEmpty()) + return true; + + search = search.toLowerCase(); + if(StatCollector.translateToLocal(e.getUnlocalizedName()).toLowerCase().contains(search)) + return true; + + for(ItemStack stack : e.getDisplayedRecipes()) { + String stackName = stack.getDisplayName().toLowerCase().trim(); + if(stackName.contains(search)) + return true; + } + + return false; + } + + @Override + void populateIndex() { + LexiconEntry tutEntry = tutorial != null && !tutorial.isEmpty() ? tutorial.peek() : null; + + for(int i = page * 12; i < (page + 1) * 12; i++) { + GuiButtonInvisible button = (GuiButtonInvisible) buttonList.get(i - page * 12); + LexiconEntry entry = i >= entriesToDisplay.size() ? null : entriesToDisplay.get(i); + if(entry != null) { + button.displayString = entry.getKnowledgeType().color + "" + (entry.isPriority() ? EnumChatFormatting.ITALIC : "") + StatCollector.translateToLocal(entry.getUnlocalizedName()); + button.displayStack = entry.getIcon(); + if(entry == tutEntry) + tutPage = page; + + if(entry instanceof DLexiconEntry) + button.dog = true; + } else button.displayString = ""; + } + } + + public void setHoveredButton(GuiButtonInvisible b) { + if(b == null) + currentEntry = null; + else currentEntry = entriesToDisplay.get(b.id + page * 12); + currentButton = b; + } + + @Override + public void drawScreen(int par1, int par2, float par3) { + super.drawScreen(par1, par2, par3); + + if(!searchField.getText().isEmpty()) { + drawBookmark(left + 138, top + guiHeight - 24, " " + searchField.getText(), false); + mc.renderEngine.bindTexture(texture); + GL11.glColor4f(1F, 1F, 1F, 1F); + drawTexturedModalRect(left + 134, top + guiHeight - 26, 86, 180, 12, 12); + + if(entriesToDisplay.size() == 1) { + boolean unicode = mc.fontRenderer.getUnicodeFlag(); + mc.fontRenderer.setUnicodeFlag(true); + String s = StatCollector.translateToLocal("botaniamisc.enterToView"); + mc.fontRenderer.drawString(s, left + guiWidth / 2 - mc.fontRenderer.getStringWidth(s) / 2, top + 30, 0x666666); + mc.fontRenderer.setUnicodeFlag(unicode); + } + } else { + boolean unicode = mc.fontRenderer.getUnicodeFlag(); + mc.fontRenderer.setUnicodeFlag(true); + String s = StatCollector.translateToLocal("botaniamisc.typeToSearch"); + mc.fontRenderer.drawString(s, left + 120 - mc.fontRenderer.getStringWidth(s), top + guiHeight - 18, 0x666666); + mc.fontRenderer.setUnicodeFlag(unicode); + } + + float animationTime = 4F; + if(isShiftKeyDown()) { + if(currentButton != null) + infoTime = Math.min(animationTime, infoTime + timeDelta); + } else { + infoTime = Math.max(0, infoTime - timeDelta); + + if(currentButton != null && infoTime == 0) { + int x = par1 + 10; + int y = par2; + + x = currentButton.xPosition - 20; + y = currentButton.yPosition; + + mc.fontRenderer.drawStringWithShadow("?", x, y, 0xFFFFFF); + GL11.glScalef(0.5F, 0.5F, 1F); + mc.fontRenderer.drawStringWithShadow(EnumChatFormatting.BOLD + "Shift", x * 2 - 6, y * 2 + 20, 0xFFFFFF); + GL11.glScalef(2F, 2F, 1F); + } + } + + if(currentButton != null && infoTime > 0) { + float fract = infoTime / animationTime; + + int x = currentButton.xPosition; + int y = currentButton.yPosition; + String s = StatCollector.translateToLocal(currentEntry.getTagline()); + boolean unicode = mc.fontRenderer.getUnicodeFlag(); + mc.fontRenderer.setUnicodeFlag(true); + int width = mc.fontRenderer.getStringWidth(s); + + GL11.glPushMatrix(); + GL11.glTranslatef(x, y, 0); + GL11.glScalef(fract, 1F, 1F); + Gui.drawRect(12, -30, width + 20, -2, 0x44000000); + Gui.drawRect(10, -32, width + 22, -2, 0x44000000); + drawBookmark(width / 2 + 16, -8, s, true, 0xFFFFFF, 180); + mc.fontRenderer.setUnicodeFlag(unicode); + + net.minecraft.client.renderer.RenderHelper.enableGUIStandardItemLighting(); + GL11.glEnable(GL12.GL_RESCALE_NORMAL); + ItemStack paper = new ItemStack(Items.paper, currentEntry.pages.size()); + + RenderItem.getInstance().renderItemAndEffectIntoGUI(mc.fontRenderer, mc.renderEngine, paper, 14, -28); + RenderItem.getInstance().renderItemOverlayIntoGUI(mc.fontRenderer, mc.renderEngine, paper, 14, -28); + List stacks = currentEntry.getDisplayedRecipes(); + + if(stacks.size() > 0) { + int spaceForEach = Math.min(18, (width - 30) / stacks.size()); + for(int i = 0; i < stacks.size(); i++) { + ItemStack stack = stacks.get(i); + RenderItem.getInstance().renderItemAndEffectIntoGUI(mc.fontRenderer, mc.renderEngine, stack, 38 + spaceForEach * i, -28); + } + } + + net.minecraft.client.renderer.RenderHelper.disableStandardItemLighting(); + + GL11.glPopMatrix(); + } + + setHoveredButton(null); + } + + @Override + public void positionTutorialArrow() { + LexiconEntry entry = tutorial.peek(); + LexiconCategory category = entry.category; + if(category != this.category) { + orientTutorialArrowWithButton(backButton); + return; + } + + if(tutPage != -1 && tutPage != page) { + orientTutorialArrowWithButton(tutPage < page ? leftButton : rightButton); + return; + } + + List buttons = buttonList; + for(GuiButton button : buttons) { + int id = button.id; + int index = id + page * 12; + if(index >= entriesToDisplay.size()) + continue; + + if(entry == entriesToDisplay.get(index)) { + orientTutorialArrowWithButton(id >= 12 ? rightButton : button); + break; + } + } + } + + @Override + protected void actionPerformed(GuiButton par1GuiButton) { + if(par1GuiButton.id >= BOOKMARK_START) + handleBookmark(par1GuiButton); + else if(par1GuiButton.id == NOTES_BUTTON_ID) + notesEnabled = !notesEnabled; + else + switch(par1GuiButton.id) { + case 12 : + mc.displayGuiScreen(parent); + ClientTickHandler.notifyPageChange(); + break; + case 13 : + page--; + updatePageButtons(); + populateIndex(); + ClientTickHandler.notifyPageChange(); + break; + case 14 : + page++; + updatePageButtons(); + populateIndex(); + ClientTickHandler.notifyPageChange(); + break; + default : + if(par1GuiButton instanceof GuiButtonInvisible && ((GuiButtonInvisible) par1GuiButton).dog) + ((GuiButtonInvisible) par1GuiButton).click(); + else { + int index = par1GuiButton.id + page * 12; + openEntry(index); + } + } + } + + void openEntry(int index) { + if(index >= entriesToDisplay.size()) + return; + + LexiconEntry entry = entriesToDisplay.get(index); + mc.displayGuiScreen(new GuiLexiconEntry(entry, this)); + ClientTickHandler.notifyPageChange(); + } + + public void updatePageButtons() { + leftButton.enabled = page != 0; + rightButton.enabled = page < (entriesToDisplay.size() - 1) / 12; + putTutorialArrow(); + } + + @Override + public void setParent(GuiLexicon gui) { + parent = gui; + } + + int fx = 0; + boolean swiped = false; + + @Override + protected void mouseClickMove(int x, int y, int button, long time) { + if(button == 0 && Math.abs(x - fx) > 100 && mc.gameSettings.touchscreen && !swiped) { + double swipe = (x - fx) / Math.max(1, (double) time); + if(swipe < 0.5) { + nextPage(); + swiped = true; + } else if(swipe > 0.5) { + prevPage(); + swiped = true; + } + } + } + + @Override + protected void mouseClicked(int par1, int par2, int par3) { + super.mouseClicked(par1, par2, par3); + + searchField.mouseClicked(par1, par2, par3); + fx = par1; + switch(par3) { + case 1: + back(); + break; + case 3: + nextPage(); + break; + case 4: + prevPage(); + break; + } + } + + @Override + public void handleMouseInput() { + super.handleMouseInput(); + + if(Mouse.getEventButton() == 0) + swiped = false; + + int w = Mouse.getEventDWheel(); + if(w < 0) + nextPage(); + else if(w > 0) + prevPage(); + } + + @Override + boolean closeScreenOnInvKey() { + return false; + } + + @Override + protected void keyTyped(char par1, int par2) { + if(par2 == 203 || par2 == 200 || par2 == 201) // Left, Up, Page Up + prevPage(); + else if(par2 == 205 || par2 == 208 || par2 == 209) // Right, Down Page Down + nextPage(); + else if(par2 == 14 && !notesEnabled && searchField.getText().isEmpty()) // Backspace + back(); + else if(par2 == 199) { // Home + mc.displayGuiScreen(new GuiLexicon()); + ClientTickHandler.notifyPageChange(); + } else if(par2 == 28 && entriesToDisplay.size() == 1) // Enter + openEntry(0); + + if(!notesEnabled) { + String search = searchField.getText(); + searchField.textboxKeyTyped(par1, par2); + if(!searchField.getText().equalsIgnoreCase(search)) + updateAll(); + } + + super.keyTyped(par1, par2); + } + + void back() { + if(backButton.enabled) { + actionPerformed(backButton); + backButton.func_146113_a(mc.getSoundHandler()); + } + } + + void nextPage() { + if(rightButton.enabled) { + actionPerformed(rightButton); + rightButton.func_146113_a(mc.getSoundHandler()); + } + } + + void prevPage() { + if(leftButton.enabled) { + actionPerformed(leftButton); + leftButton.func_146113_a(mc.getSoundHandler()); + } + } + + @Override + public void serialize(NBTTagCompound cmp) { + super.serialize(cmp); + cmp.setString(TAG_CATEGORY, category == null ? "" : category.getUnlocalizedName()); + cmp.setInteger(TAG_PAGE, page); + } + + @Override + public void load(NBTTagCompound cmp) { + super.load(cmp); + String categoryStr = cmp.getString(TAG_CATEGORY); + if(categoryStr.isEmpty()) + category = null; + else for(LexiconCategory cat : BotaniaAPI.getAllCategories()) + if(cat.getUnlocalizedName().equals(categoryStr)) { + category = cat; + break; + } + page = cmp.getInteger(TAG_PAGE); + setTitle(); + } + + @Override + public GuiLexicon copy() { + GuiLexiconIndex gui = new GuiLexiconIndex(category); + gui.page = page; + gui.setTitle(); + return gui; + } + + @Override + public String getNotesKey() { + return "category_" + (category == null ? "lexindex" : category.unlocalizedName); + } } + diff --git a/src/main/java/vazkii/botania/client/gui/lexicon/IParented.java b/src/main/java/vazkii/botania/client/gui/lexicon/IParented.java index 20523d78ee..7705930413 100644 --- a/src/main/java/vazkii/botania/client/gui/lexicon/IParented.java +++ b/src/main/java/vazkii/botania/client/gui/lexicon/IParented.java @@ -2,5 +2,6 @@ public interface IParented { - public void setParent(GuiLexicon gui); + public void setParent(GuiLexicon gui); + } diff --git a/src/main/java/vazkii/botania/client/gui/lexicon/button/GuiButtonAchievement.java b/src/main/java/vazkii/botania/client/gui/lexicon/button/GuiButtonAchievement.java index 5e6ee04ad7..822add3436 100644 --- a/src/main/java/vazkii/botania/client/gui/lexicon/button/GuiButtonAchievement.java +++ b/src/main/java/vazkii/botania/client/gui/lexicon/button/GuiButtonAchievement.java @@ -2,43 +2,47 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Apr 3, 2015, 5:44:36 PM (GMT)] */ package vazkii.botania.client.gui.lexicon.button; import java.util.ArrayList; import java.util.List; + import net.minecraft.client.Minecraft; import net.minecraft.util.EnumChatFormatting; import net.minecraft.util.StatCollector; + import org.lwjgl.opengl.GL11; + import vazkii.botania.client.core.helper.RenderHelper; import vazkii.botania.client.gui.lexicon.GuiLexicon; public class GuiButtonAchievement extends GuiButtonLexicon { - public GuiButtonAchievement(int id, int x, int y) { - super(id, x, y, 11, 11, ""); - } + public GuiButtonAchievement(int id, int x, int y) { + super(id, x, y, 11, 11, ""); + } + + @Override + public void drawButton(Minecraft par1Minecraft, int par2, int par3) { + field_146123_n = par2 >= xPosition && par3 >= yPosition && par2 < xPosition + width && par3 < yPosition + height; + int k = getHoverState(field_146123_n); - @Override - public void drawButton(Minecraft par1Minecraft, int par2, int par3) { - field_146123_n = - par2 >= xPosition && par3 >= yPosition && par2 < xPosition + width && par3 < yPosition + height; - int k = getHoverState(field_146123_n); + par1Minecraft.renderEngine.bindTexture(GuiLexicon.texture); + GL11.glColor4f(1F, 1F, 1F, 1F); + drawTexturedModalRect(xPosition, yPosition, k == 2 ? 109 : 98, 191, 11, 11); - par1Minecraft.renderEngine.bindTexture(GuiLexicon.texture); - GL11.glColor4f(1F, 1F, 1F, 1F); - drawTexturedModalRect(xPosition, yPosition, k == 2 ? 109 : 98, 191, 11, 11); + List tooltip = new ArrayList(); + tooltip.add(EnumChatFormatting.YELLOW + StatCollector.translateToLocal("botaniamisc.achievements")); - List tooltip = new ArrayList(); - tooltip.add(EnumChatFormatting.YELLOW + StatCollector.translateToLocal("botaniamisc.achievements")); + int tooltipY = (tooltip.size() - 1) * 10; + if(k == 2) + RenderHelper.renderTooltip(par2, par3 + tooltipY, tooltip); + } - int tooltipY = (tooltip.size() - 1) * 10; - if (k == 2) RenderHelper.renderTooltip(par2, par3 + tooltipY, tooltip); - } -} +} \ No newline at end of file diff --git a/src/main/java/vazkii/botania/client/gui/lexicon/button/GuiButtonBack.java b/src/main/java/vazkii/botania/client/gui/lexicon/button/GuiButtonBack.java index 41dd8b48d1..75f3de6277 100644 --- a/src/main/java/vazkii/botania/client/gui/lexicon/button/GuiButtonBack.java +++ b/src/main/java/vazkii/botania/client/gui/lexicon/button/GuiButtonBack.java @@ -2,46 +2,50 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jan 14, 2014, 9:54:21 PM (GMT)] */ package vazkii.botania.client.gui.lexicon.button; import java.util.Arrays; import java.util.List; + import net.minecraft.client.Minecraft; import net.minecraft.util.StatCollector; + import org.lwjgl.opengl.GL11; + import vazkii.botania.client.core.helper.RenderHelper; import vazkii.botania.client.gui.lexicon.GuiLexicon; public class GuiButtonBack extends GuiButtonLexicon { - public GuiButtonBack(int par1, int par2, int par3) { - super(par1, par2, par3, 18, 9, ""); - } - - @Override - public void drawButton(Minecraft par1Minecraft, int par2, int par3) { - if (enabled) { - field_146123_n = - par2 >= xPosition && par3 >= yPosition && par2 < xPosition + width && par3 < yPosition + height; - int k = getHoverState(field_146123_n); - - par1Minecraft.renderEngine.bindTexture(GuiLexicon.texture); - GL11.glColor4f(1F, 1F, 1F, 1F); - drawTexturedModalRect(xPosition, yPosition, 36, k == 2 ? 180 : 189, 18, 9); - - List tooltip = getTooltip(); - int tooltipY = (tooltip.size() - 1) * 10; - if (k == 2) RenderHelper.renderTooltip(par2, par3 + tooltipY, tooltip); - } - } - - public List getTooltip() { - return Arrays.asList(StatCollector.translateToLocal("botaniamisc.back")); - } + public GuiButtonBack(int par1, int par2, int par3) { + super(par1, par2, par3, 18, 9, ""); + } + + @Override + public void drawButton(Minecraft par1Minecraft, int par2, int par3) { + if(enabled) { + field_146123_n = par2 >= xPosition && par3 >= yPosition && par2 < xPosition + width && par3 < yPosition + height; + int k = getHoverState(field_146123_n); + + par1Minecraft.renderEngine.bindTexture(GuiLexicon.texture); + GL11.glColor4f(1F, 1F, 1F, 1F); + drawTexturedModalRect(xPosition, yPosition, 36, k == 2 ? 180 : 189, 18, 9); + + List tooltip = getTooltip(); + int tooltipY = (tooltip.size() - 1) * 10; + if(k == 2) + RenderHelper.renderTooltip(par2, par3 + tooltipY, tooltip); + } + } + + public List getTooltip() { + return Arrays.asList(StatCollector.translateToLocal("botaniamisc.back")); + } + } diff --git a/src/main/java/vazkii/botania/client/gui/lexicon/button/GuiButtonBackWithShift.java b/src/main/java/vazkii/botania/client/gui/lexicon/button/GuiButtonBackWithShift.java index b9223c4929..329edad85d 100644 --- a/src/main/java/vazkii/botania/client/gui/lexicon/button/GuiButtonBackWithShift.java +++ b/src/main/java/vazkii/botania/client/gui/lexicon/button/GuiButtonBackWithShift.java @@ -2,29 +2,29 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Mar 6, 2014, 6:35:32 PM (GMT)] */ package vazkii.botania.client.gui.lexicon.button; import java.util.Arrays; import java.util.List; + import net.minecraft.util.EnumChatFormatting; import net.minecraft.util.StatCollector; public class GuiButtonBackWithShift extends GuiButtonBack { - public GuiButtonBackWithShift(int par1, int par2, int par3) { - super(par1, par2, par3); - } + public GuiButtonBackWithShift(int par1, int par2, int par3) { + super(par1, par2, par3); + } + + @Override + public List getTooltip() { + return Arrays.asList(StatCollector.translateToLocal("botaniamisc.back"), EnumChatFormatting.GRAY + StatCollector.translateToLocal("botaniamisc.clickToIndex")); + } - @Override - public List getTooltip() { - return Arrays.asList( - StatCollector.translateToLocal("botaniamisc.back"), - EnumChatFormatting.GRAY + StatCollector.translateToLocal("botaniamisc.clickToIndex")); - } } diff --git a/src/main/java/vazkii/botania/client/gui/lexicon/button/GuiButtonBookmark.java b/src/main/java/vazkii/botania/client/gui/lexicon/button/GuiButtonBookmark.java index 95a17d1606..8f972bb1e7 100644 --- a/src/main/java/vazkii/botania/client/gui/lexicon/button/GuiButtonBookmark.java +++ b/src/main/java/vazkii/botania/client/gui/lexicon/button/GuiButtonBookmark.java @@ -2,6 +2,7 @@ import java.util.ArrayList; import java.util.List; + import net.minecraft.client.Minecraft; import net.minecraft.util.EnumChatFormatting; import net.minecraft.util.StatCollector; @@ -10,30 +11,31 @@ public class GuiButtonBookmark extends GuiButtonLexicon { - GuiLexicon gui; - - public GuiButtonBookmark(int par1, int par2, int par3, GuiLexicon gui, String str) { - super(par1, par2, par3, gui.bookmarkWidth(str) + 5, 11, str); - this.gui = gui; - } - - @Override - public void drawButton(Minecraft mc, int par2, int par3) { - gui.drawBookmark(xPosition, yPosition, displayString, false); - field_146123_n = - par2 >= xPosition && par3 >= yPosition && par2 < xPosition + width && par3 < yPosition + height; - int k = getHoverState(field_146123_n); - - List tooltip = new ArrayList(); - if (displayString.equals("+")) tooltip.add(StatCollector.translateToLocal("botaniamisc.clickToAdd")); - else { - tooltip.add(String.format( - StatCollector.translateToLocal("botaniamisc.bookmark"), id - GuiLexicon.BOOKMARK_START + 1)); - tooltip.add(EnumChatFormatting.GRAY + StatCollector.translateToLocal("botaniamisc.clickToSee")); - tooltip.add(EnumChatFormatting.GRAY + StatCollector.translateToLocal("botaniamisc.shiftToRemove")); - } - - int tooltipY = (tooltip.size() + 1) * 5; - if (k == 2) RenderHelper.renderTooltip(par2, par3 + tooltipY, tooltip); - } + GuiLexicon gui; + + public GuiButtonBookmark(int par1, int par2, int par3, GuiLexicon gui, String str) { + super(par1, par2, par3, gui.bookmarkWidth(str) + 5, 11, str); + this.gui = gui; + } + + @Override + public void drawButton(Minecraft mc, int par2, int par3) { + gui.drawBookmark(xPosition, yPosition, displayString, false); + field_146123_n = par2 >= xPosition && par3 >= yPosition && par2 < xPosition + width && par3 < yPosition + height; + int k = getHoverState(field_146123_n); + + List tooltip = new ArrayList(); + if(displayString.equals("+")) + tooltip.add(StatCollector.translateToLocal("botaniamisc.clickToAdd")); + else { + tooltip.add(String.format(StatCollector.translateToLocal("botaniamisc.bookmark"), id - GuiLexicon.BOOKMARK_START + 1)); + tooltip.add(EnumChatFormatting.GRAY + StatCollector.translateToLocal("botaniamisc.clickToSee")); + tooltip.add(EnumChatFormatting.GRAY + StatCollector.translateToLocal("botaniamisc.shiftToRemove")); + } + + int tooltipY = (tooltip.size() + 1) * 5; + if(k == 2) + RenderHelper.renderTooltip(par2, par3 + tooltipY, tooltip); + } + } diff --git a/src/main/java/vazkii/botania/client/gui/lexicon/button/GuiButtonCategory.java b/src/main/java/vazkii/botania/client/gui/lexicon/button/GuiButtonCategory.java index 364f5605c0..ca6b49d3c1 100644 --- a/src/main/java/vazkii/botania/client/gui/lexicon/button/GuiButtonCategory.java +++ b/src/main/java/vazkii/botania/client/gui/lexicon/button/GuiButtonCategory.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Oct 18, 2014, 4:00:30 PM (GMT)] */ package vazkii.botania.client.gui.lexicon.button; @@ -15,9 +15,11 @@ import net.minecraft.client.renderer.texture.TextureManager; import net.minecraft.util.ResourceLocation; import net.minecraft.util.StatCollector; + import org.lwjgl.opengl.ARBMultitexture; import org.lwjgl.opengl.ARBShaderObjects; import org.lwjgl.opengl.GL11; + import vazkii.botania.api.internal.ShaderCallback; import vazkii.botania.api.lexicon.LexiconCategory; import vazkii.botania.client.core.helper.RenderHelper; @@ -28,102 +30,107 @@ public class GuiButtonCategory extends GuiButtonLexicon { - private static final ResourceLocation fallbackResource = new ResourceLocation(LibResources.CATEGORY_INDEX); - private static final ResourceLocation stencilResource = new ResourceLocation(LibResources.GUI_STENCIL); - - private ShaderCallback shaderCallback = new ShaderCallback() { - - @Override - public void call(int shader) { - TextureManager r = Minecraft.getMinecraft().renderEngine; - int heightMatchUniform = ARBShaderObjects.glGetUniformLocationARB(shader, "heightMatch"); - int imageUniform = ARBShaderObjects.glGetUniformLocationARB(shader, "image"); - int maskUniform = ARBShaderObjects.glGetUniformLocationARB(shader, "mask"); - - float heightMatch = ticksHovered / time; - OpenGlHelper.setActiveTexture(ARBMultitexture.GL_TEXTURE0_ARB); - GL11.glBindTexture(GL11.GL_TEXTURE_2D, r.getTexture(resource).getGlTextureId()); - ARBShaderObjects.glUniform1iARB(imageUniform, 0); - - OpenGlHelper.setActiveTexture(ARBMultitexture.GL_TEXTURE0_ARB + ConfigHandler.glSecondaryTextureUnit); - GL11.glEnable(GL11.GL_TEXTURE_2D); - GL11.glGetInteger(GL11.GL_TEXTURE_BINDING_2D); - GL11.glBindTexture(GL11.GL_TEXTURE_2D, r.getTexture(stencilResource).getGlTextureId()); - ARBShaderObjects.glUniform1iARB(maskUniform, ConfigHandler.glSecondaryTextureUnit); - - ARBShaderObjects.glUniform1fARB(heightMatchUniform, heightMatch); - } - }; - static boolean boundStencil = false; - - GuiLexicon gui; - LexiconCategory category; - ResourceLocation resource = null; - float ticksHovered = 0F; - float time = 12F; - int activeTex = 0; - - public GuiButtonCategory(int id, int x, int y, GuiLexicon gui, LexiconCategory category) { - super(id, x, y, 16, 16, ""); - this.gui = gui; - this.category = category; - } - - @Override - public void drawButton(Minecraft mc, int mx, int my) { - boolean inside = mx >= xPosition && my >= yPosition && mx < xPosition + width && my < yPosition + height; - if (inside) ticksHovered = Math.min(time, ticksHovered + gui.timeDelta); - else ticksHovered = Math.max(0F, ticksHovered - gui.timeDelta); - - if (resource == null) { - if (category == null) resource = fallbackResource; - else resource = category.getIcon(); - if (resource == null) resource = fallbackResource; - } - - float s = 1F / 32F; - GL11.glPushMatrix(); - GL11.glEnable(GL11.GL_BLEND); - GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); - GL11.glScalef(0.5F, 0.5F, 0.5F); - GL11.glColor4f(1F, 1F, 1F, 1F); - - if (!boundStencil) { // Allow for the texture manager to take care of the ResourceLocation before we use it - // directly with gl - mc.renderEngine.bindTexture(stencilResource); - boundStencil = true; - } - mc.renderEngine.bindTexture(resource); - - int texture = 0; - boolean shaders = ShaderHelper.useShaders(); - - if (shaders) { - OpenGlHelper.setActiveTexture(ARBMultitexture.GL_TEXTURE0_ARB + ConfigHandler.glSecondaryTextureUnit); - texture = GL11.glGetInteger(GL11.GL_TEXTURE_BINDING_2D); - } - - ShaderHelper.useShader(ShaderHelper.categoryButton, shaderCallback); - RenderHelper.drawTexturedModalRect(xPosition * 2, yPosition * 2, zLevel * 2, 0, 0, 32, 32, s, s); - ShaderHelper.releaseShader(); - - if (shaders) { - OpenGlHelper.setActiveTexture(ARBMultitexture.GL_TEXTURE0_ARB + ConfigHandler.glSecondaryTextureUnit); - GL11.glBindTexture(GL11.GL_TEXTURE_2D, texture); - OpenGlHelper.setActiveTexture(ARBMultitexture.GL_TEXTURE0_ARB); - } - - GL11.glPopMatrix(); - - if (inside) gui.categoryHighlight = StatCollector.translateToLocal(getTooltipText()); - } - - String getTooltipText() { - if (category == null) return "botaniamisc.lexiconIndex"; - return category.getUnlocalizedName(); - } - - public LexiconCategory getCategory() { - return category; - } + private static final ResourceLocation fallbackResource = new ResourceLocation(LibResources.CATEGORY_INDEX); + private static final ResourceLocation stencilResource = new ResourceLocation(LibResources.GUI_STENCIL); + + private ShaderCallback shaderCallback = new ShaderCallback() { + + @Override + public void call(int shader) { + TextureManager r = Minecraft.getMinecraft().renderEngine; + int heightMatchUniform = ARBShaderObjects.glGetUniformLocationARB(shader, "heightMatch"); + int imageUniform = ARBShaderObjects.glGetUniformLocationARB(shader, "image"); + int maskUniform = ARBShaderObjects.glGetUniformLocationARB(shader, "mask"); + + float heightMatch = ticksHovered / time; + OpenGlHelper.setActiveTexture(ARBMultitexture.GL_TEXTURE0_ARB); + GL11.glBindTexture(GL11.GL_TEXTURE_2D, r.getTexture(resource).getGlTextureId()); + ARBShaderObjects.glUniform1iARB(imageUniform, 0); + + OpenGlHelper.setActiveTexture(ARBMultitexture.GL_TEXTURE0_ARB + ConfigHandler.glSecondaryTextureUnit); + GL11.glEnable(GL11.GL_TEXTURE_2D); + GL11.glGetInteger(GL11.GL_TEXTURE_BINDING_2D); + GL11.glBindTexture(GL11.GL_TEXTURE_2D, r.getTexture(stencilResource).getGlTextureId()); + ARBShaderObjects.glUniform1iARB(maskUniform, ConfigHandler.glSecondaryTextureUnit); + + ARBShaderObjects.glUniform1fARB(heightMatchUniform, heightMatch); + } + }; + static boolean boundStencil = false; + + GuiLexicon gui; + LexiconCategory category; + ResourceLocation resource = null; + float ticksHovered = 0F; + float time = 12F; + int activeTex = 0; + + public GuiButtonCategory(int id, int x, int y, GuiLexicon gui, LexiconCategory category) { + super(id, x, y, 16, 16, ""); + this.gui = gui; + this.category = category; + } + + @Override + public void drawButton(Minecraft mc, int mx, int my) { + boolean inside = mx >= xPosition && my >= yPosition && mx < xPosition + width && my < yPosition + height; + if(inside) + ticksHovered = Math.min(time, ticksHovered + gui.timeDelta); + else ticksHovered = Math.max(0F, ticksHovered - gui.timeDelta); + + if(resource == null) { + if(category == null) + resource = fallbackResource; + else resource = category.getIcon(); + if(resource == null) + resource = fallbackResource; + } + + float s = 1F / 32F; + GL11.glPushMatrix(); + GL11.glEnable(GL11.GL_BLEND); + GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); + GL11.glScalef(0.5F, 0.5F, 0.5F); + GL11.glColor4f(1F, 1F, 1F, 1F); + + if(!boundStencil) { // Allow for the texture manager to take care of the ResourceLocation before we use it directly with gl + mc.renderEngine.bindTexture(stencilResource); + boundStencil = true; + } + mc.renderEngine.bindTexture(resource); + + int texture = 0; + boolean shaders = ShaderHelper.useShaders(); + + if(shaders) { + OpenGlHelper.setActiveTexture(ARBMultitexture.GL_TEXTURE0_ARB + ConfigHandler.glSecondaryTextureUnit); + texture = GL11.glGetInteger(GL11.GL_TEXTURE_BINDING_2D); + } + + ShaderHelper.useShader(ShaderHelper.categoryButton, shaderCallback); + RenderHelper.drawTexturedModalRect(xPosition * 2, yPosition * 2, zLevel * 2, 0, 0, 32, 32, s, s); + ShaderHelper.releaseShader(); + + if(shaders) { + OpenGlHelper.setActiveTexture(ARBMultitexture.GL_TEXTURE0_ARB + ConfigHandler.glSecondaryTextureUnit); + GL11.glBindTexture(GL11.GL_TEXTURE_2D, texture); + OpenGlHelper.setActiveTexture(ARBMultitexture.GL_TEXTURE0_ARB); + } + + GL11.glPopMatrix(); + + if(inside) + gui.categoryHighlight = StatCollector.translateToLocal(getTooltipText()); + } + + String getTooltipText() { + if(category == null) + return "botaniamisc.lexiconIndex"; + return category.getUnlocalizedName(); + } + + public LexiconCategory getCategory() { + return category; + } + } diff --git a/src/main/java/vazkii/botania/client/gui/lexicon/button/GuiButtonChallengeIcon.java b/src/main/java/vazkii/botania/client/gui/lexicon/button/GuiButtonChallengeIcon.java index a407ae753e..b75da43aae 100644 --- a/src/main/java/vazkii/botania/client/gui/lexicon/button/GuiButtonChallengeIcon.java +++ b/src/main/java/vazkii/botania/client/gui/lexicon/button/GuiButtonChallengeIcon.java @@ -2,59 +2,62 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jun 29, 2015, 5:00:30 PM (GMT)] */ package vazkii.botania.client.gui.lexicon.button; import java.util.ArrayList; import java.util.List; + import net.minecraft.client.Minecraft; import net.minecraft.client.renderer.RenderHelper; import net.minecraft.client.renderer.entity.RenderItem; import net.minecraft.util.EnumChatFormatting; import net.minecraft.util.StatCollector; + import org.lwjgl.opengl.GL11; import org.lwjgl.opengl.GL12; + import vazkii.botania.client.challenge.Challenge; public class GuiButtonChallengeIcon extends GuiButtonLexicon { - public Challenge challenge; - - public GuiButtonChallengeIcon(int id, int x, int y, Challenge challenge) { - super(id, x, y, 16, 16, ""); - this.challenge = challenge; - } - - @Override - public void drawButton(Minecraft par1Minecraft, int par2, int par3) { - field_146123_n = - par2 >= xPosition && par3 >= yPosition && par2 < xPosition + width && par3 < yPosition + height; - int k = getHoverState(field_146123_n); - - RenderHelper.enableGUIStandardItemLighting(); - GL11.glEnable(GL12.GL_RESCALE_NORMAL); - RenderItem.getInstance() - .renderItemIntoGUI( - par1Minecraft.fontRenderer, par1Minecraft.renderEngine, challenge.icon, xPosition, yPosition); - RenderHelper.disableStandardItemLighting(); - GL11.glEnable(GL11.GL_BLEND); - - if (challenge.complete) { - GL11.glDisable(GL11.GL_DEPTH_TEST); - par1Minecraft.fontRenderer.drawStringWithShadow("\u2714", xPosition + 10, yPosition + 9, 0x004C00); - par1Minecraft.fontRenderer.drawStringWithShadow("\u2714", xPosition + 10, yPosition + 8, 0x0BD20D); - GL11.glEnable(GL11.GL_DEPTH_TEST); - } - - List tooltip = new ArrayList(); - tooltip.add(EnumChatFormatting.AQUA + StatCollector.translateToLocal(challenge.unlocalizedName)); - - int tooltipY = (tooltip.size() - 1) * 10; - if (k == 2) vazkii.botania.client.core.helper.RenderHelper.renderTooltip(par2, par3 + tooltipY, tooltip); - } + public Challenge challenge; + + public GuiButtonChallengeIcon(int id, int x, int y, Challenge challenge) { + super(id, x, y, 16, 16, ""); + this.challenge = challenge; + } + + @Override + public void drawButton(Minecraft par1Minecraft, int par2, int par3) { + field_146123_n = par2 >= xPosition && par3 >= yPosition && par2 < xPosition + width && par3 < yPosition + height; + int k = getHoverState(field_146123_n); + + RenderHelper.enableGUIStandardItemLighting(); + GL11.glEnable(GL12.GL_RESCALE_NORMAL); + RenderItem.getInstance().renderItemIntoGUI(par1Minecraft.fontRenderer, par1Minecraft.renderEngine, challenge.icon, xPosition, yPosition); + RenderHelper.disableStandardItemLighting(); + GL11.glEnable(GL11.GL_BLEND); + + if(challenge.complete) { + GL11.glDisable(GL11.GL_DEPTH_TEST); + par1Minecraft.fontRenderer.drawStringWithShadow("\u2714", xPosition + 10, yPosition + 9, 0x004C00); + par1Minecraft.fontRenderer.drawStringWithShadow("\u2714", xPosition + 10, yPosition + 8, 0x0BD20D); + GL11.glEnable(GL11.GL_DEPTH_TEST); + } + + + List tooltip = new ArrayList(); + tooltip.add(EnumChatFormatting.AQUA + StatCollector.translateToLocal(challenge.unlocalizedName)); + + int tooltipY = (tooltip.size() - 1) * 10; + if(k == 2) + vazkii.botania.client.core.helper.RenderHelper.renderTooltip(par2, par3 + tooltipY, tooltip); + } + } diff --git a/src/main/java/vazkii/botania/client/gui/lexicon/button/GuiButtonChallengeInfo.java b/src/main/java/vazkii/botania/client/gui/lexicon/button/GuiButtonChallengeInfo.java index 806e14dc7e..0dd4fe65a4 100644 --- a/src/main/java/vazkii/botania/client/gui/lexicon/button/GuiButtonChallengeInfo.java +++ b/src/main/java/vazkii/botania/client/gui/lexicon/button/GuiButtonChallengeInfo.java @@ -2,16 +2,17 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jun 29, 2015, 7:42:52 PM (GMT)] */ package vazkii.botania.client.gui.lexicon.button; import java.util.ArrayList; import java.util.List; + import net.minecraft.client.Minecraft; import net.minecraft.util.StatCollector; import vazkii.botania.client.core.helper.RenderHelper; @@ -19,24 +20,25 @@ public class GuiButtonChallengeInfo extends GuiButtonLexicon { - GuiLexicon gui; + GuiLexicon gui; + + public GuiButtonChallengeInfo(int par1, int par2, int par3, String str, GuiLexicon gui) { + super(par1, par2, par3, gui.bookmarkWidth(str) + 5, 11, str); + this.gui = gui; + } - public GuiButtonChallengeInfo(int par1, int par2, int par3, String str, GuiLexicon gui) { - super(par1, par2, par3, gui.bookmarkWidth(str) + 5, 11, str); - this.gui = gui; - } + @Override + public void drawButton(Minecraft mc, int par2, int par3) { + gui.drawBookmark(xPosition, yPosition, displayString, false); + field_146123_n = par2 >= xPosition && par3 >= yPosition && par2 < xPosition + width && par3 < yPosition + height; + int k = getHoverState(field_146123_n); - @Override - public void drawButton(Minecraft mc, int par2, int par3) { - gui.drawBookmark(xPosition, yPosition, displayString, false); - field_146123_n = - par2 >= xPosition && par3 >= yPosition && par2 < xPosition + width && par3 < yPosition + height; - int k = getHoverState(field_146123_n); + List tooltip = new ArrayList(); + tooltip.add(StatCollector.translateToLocal("botaniamisc.challengeInfo")); - List tooltip = new ArrayList(); - tooltip.add(StatCollector.translateToLocal("botaniamisc.challengeInfo")); + int tooltipY = (tooltip.size() + 1) * 5; + if(k == 2) + RenderHelper.renderTooltip(par2, par3 + tooltipY, tooltip); + } - int tooltipY = (tooltip.size() + 1) * 5; - if (k == 2) RenderHelper.renderTooltip(par2, par3 + tooltipY, tooltip); - } -} +} \ No newline at end of file diff --git a/src/main/java/vazkii/botania/client/gui/lexicon/button/GuiButtonChallenges.java b/src/main/java/vazkii/botania/client/gui/lexicon/button/GuiButtonChallenges.java index a3d9cba38e..826dfa2c51 100644 --- a/src/main/java/vazkii/botania/client/gui/lexicon/button/GuiButtonChallenges.java +++ b/src/main/java/vazkii/botania/client/gui/lexicon/button/GuiButtonChallenges.java @@ -2,43 +2,47 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jun 29, 2015, 4:16:09 PM (GMT)] */ package vazkii.botania.client.gui.lexicon.button; import java.util.ArrayList; import java.util.List; + import net.minecraft.client.Minecraft; import net.minecraft.util.EnumChatFormatting; import net.minecraft.util.StatCollector; + import org.lwjgl.opengl.GL11; + import vazkii.botania.client.core.helper.RenderHelper; import vazkii.botania.client.gui.lexicon.GuiLexicon; public class GuiButtonChallenges extends GuiButtonLexicon { - public GuiButtonChallenges(int id, int x, int y) { - super(id, x, y, 11, 11, ""); - } + public GuiButtonChallenges(int id, int x, int y) { + super(id, x, y, 11, 11, ""); + } + + @Override + public void drawButton(Minecraft par1Minecraft, int par2, int par3) { + field_146123_n = par2 >= xPosition && par3 >= yPosition && par2 < xPosition + width && par3 < yPosition + height; + int k = getHoverState(field_146123_n); - @Override - public void drawButton(Minecraft par1Minecraft, int par2, int par3) { - field_146123_n = - par2 >= xPosition && par3 >= yPosition && par2 < xPosition + width && par3 < yPosition + height; - int k = getHoverState(field_146123_n); + par1Minecraft.renderEngine.bindTexture(GuiLexicon.texture); + GL11.glColor4f(1F, 1F, 1F, 1F); + drawTexturedModalRect(xPosition, yPosition, k == 2 ? 131 : 120, 180, 11, 11); - par1Minecraft.renderEngine.bindTexture(GuiLexicon.texture); - GL11.glColor4f(1F, 1F, 1F, 1F); - drawTexturedModalRect(xPosition, yPosition, k == 2 ? 131 : 120, 180, 11, 11); + List tooltip = new ArrayList(); + tooltip.add(EnumChatFormatting.YELLOW + StatCollector.translateToLocal("botaniamisc.challenges")); - List tooltip = new ArrayList(); - tooltip.add(EnumChatFormatting.YELLOW + StatCollector.translateToLocal("botaniamisc.challenges")); + int tooltipY = (tooltip.size() - 1) * 10; + if(k == 2) + RenderHelper.renderTooltip(par2, par3 + tooltipY, tooltip); + } - int tooltipY = (tooltip.size() - 1) * 10; - if (k == 2) RenderHelper.renderTooltip(par2, par3 + tooltipY, tooltip); - } -} +} \ No newline at end of file diff --git a/src/main/java/vazkii/botania/client/gui/lexicon/button/GuiButtonDoot.java b/src/main/java/vazkii/botania/client/gui/lexicon/button/GuiButtonDoot.java index f47c39f0e8..1b2646b9e1 100644 --- a/src/main/java/vazkii/botania/client/gui/lexicon/button/GuiButtonDoot.java +++ b/src/main/java/vazkii/botania/client/gui/lexicon/button/GuiButtonDoot.java @@ -2,23 +2,26 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Oct 11, 2015, 7:04:46 PM (GMT)] */ package vazkii.botania.client.gui.lexicon.button; import java.util.ArrayList; import java.util.List; + import net.minecraft.client.Minecraft; import net.minecraft.client.renderer.entity.RenderItem; import net.minecraft.client.renderer.texture.TextureMap; import net.minecraft.init.Items; import net.minecraft.item.ItemStack; import net.minecraft.util.EnumChatFormatting; + import org.lwjgl.opengl.GL11; + import vazkii.botania.client.core.helper.RenderHelper; import vazkii.botania.common.item.ModItems; @@ -26,40 +29,31 @@ // I should've done this last year public class GuiButtonDoot extends GuiButtonLexicon { - public GuiButtonDoot(int id, int x, int y) { - super(id, x, y, 16, 16, ""); - } + public GuiButtonDoot(int id, int x, int y) { + super(id, x, y, 16, 16, ""); + } - @Override - public void drawButton(Minecraft par1Minecraft, int par2, int par3) { - field_146123_n = - par2 >= xPosition && par3 >= yPosition && par2 < xPosition + width && par3 < yPosition + height; - int k = getHoverState(field_146123_n); + @Override + public void drawButton(Minecraft par1Minecraft, int par2, int par3) { + field_146123_n = par2 >= xPosition && par3 >= yPosition && par2 < xPosition + width && par3 < yPosition + height; + int k = getHoverState(field_146123_n); - par1Minecraft.renderEngine.bindTexture(TextureMap.locationItemsTexture); - GL11.glColor4f(1F, 1F, 1F, 1F); - RenderItem.getInstance() - .renderItemIntoGUI( - par1Minecraft.fontRenderer, - par1Minecraft.renderEngine, - new ItemStack(ModItems.cacophonium), - xPosition, - yPosition); - RenderItem.getInstance() - .renderItemIntoGUI( - par1Minecraft.fontRenderer, - par1Minecraft.renderEngine, - new ItemStack(Items.fireworks), - xPosition + 8, - yPosition + 2); + par1Minecraft.renderEngine.bindTexture(TextureMap.locationItemsTexture); + GL11.glColor4f(1F, 1F, 1F, 1F); + RenderItem.getInstance().renderItemIntoGUI(par1Minecraft.fontRenderer, par1Minecraft.renderEngine, new ItemStack(ModItems.cacophonium), xPosition, yPosition); + RenderItem.getInstance().renderItemIntoGUI(par1Minecraft.fontRenderer, par1Minecraft.renderEngine, new ItemStack(Items.fireworks), xPosition + 8, yPosition + 2); - GL11.glDisable(GL11.GL_LIGHTING); + GL11.glDisable(GL11.GL_LIGHTING); - List tooltip = new ArrayList(); - tooltip.add(EnumChatFormatting.LIGHT_PURPLE + "Happy Birthday Vazkii!"); - tooltip.add(EnumChatFormatting.GRAY + "doot doot"); - if (k == 2) RenderHelper.renderTooltip(xPosition - 100, yPosition + 36, tooltip); - GL11.glEnable(GL11.GL_ALPHA_TEST); - } + List tooltip = new ArrayList(); + tooltip.add(EnumChatFormatting.LIGHT_PURPLE + "Happy Birthday Vazkii!"); + tooltip.add(EnumChatFormatting.GRAY + "doot doot"); + + if(k == 2) + RenderHelper.renderTooltip(xPosition - 100, yPosition + 36, tooltip); + GL11.glEnable(GL11.GL_ALPHA_TEST); + } + } + diff --git a/src/main/java/vazkii/botania/client/gui/lexicon/button/GuiButtonHistory.java b/src/main/java/vazkii/botania/client/gui/lexicon/button/GuiButtonHistory.java index 179cca43fb..b5f1fd75e1 100644 --- a/src/main/java/vazkii/botania/client/gui/lexicon/button/GuiButtonHistory.java +++ b/src/main/java/vazkii/botania/client/gui/lexicon/button/GuiButtonHistory.java @@ -2,16 +2,17 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Mar 2, 2015, 6:01:26 PM (GMT)] */ package vazkii.botania.client.gui.lexicon.button; import java.util.ArrayList; import java.util.List; + import net.minecraft.client.Minecraft; import net.minecraft.util.EnumChatFormatting; import net.minecraft.util.StatCollector; @@ -20,25 +21,26 @@ public class GuiButtonHistory extends GuiButtonLexicon { - GuiLexicon gui; + GuiLexicon gui; + + public GuiButtonHistory(int par1, int par2, int par3, String str, GuiLexicon gui) { + super(par1, par2, par3, gui.bookmarkWidth(str) + 5, 11, str); + this.gui = gui; + } - public GuiButtonHistory(int par1, int par2, int par3, String str, GuiLexicon gui) { - super(par1, par2, par3, gui.bookmarkWidth(str) + 5, 11, str); - this.gui = gui; - } + @Override + public void drawButton(Minecraft mc, int par2, int par3) { + gui.drawBookmark(xPosition, yPosition, displayString, false); + field_146123_n = par2 >= xPosition && par3 >= yPosition && par2 < xPosition + width && par3 < yPosition + height; + int k = getHoverState(field_146123_n); - @Override - public void drawButton(Minecraft mc, int par2, int par3) { - gui.drawBookmark(xPosition, yPosition, displayString, false); - field_146123_n = - par2 >= xPosition && par3 >= yPosition && par2 < xPosition + width && par3 < yPosition + height; - int k = getHoverState(field_146123_n); + List tooltip = new ArrayList(); + tooltip.add(StatCollector.translateToLocal("botaniamisc.historyLong")); + tooltip.add(EnumChatFormatting.GRAY + StatCollector.translateToLocal("botaniamisc.historyDesc")); - List tooltip = new ArrayList(); - tooltip.add(StatCollector.translateToLocal("botaniamisc.historyLong")); - tooltip.add(EnumChatFormatting.GRAY + StatCollector.translateToLocal("botaniamisc.historyDesc")); + int tooltipY = (tooltip.size() + 1) * 5; + if(k == 2) + RenderHelper.renderTooltip(par2, par3 + tooltipY, tooltip); + } - int tooltipY = (tooltip.size() + 1) * 5; - if (k == 2) RenderHelper.renderTooltip(par2, par3 + tooltipY, tooltip); - } } diff --git a/src/main/java/vazkii/botania/client/gui/lexicon/button/GuiButtonInvisible.java b/src/main/java/vazkii/botania/client/gui/lexicon/button/GuiButtonInvisible.java index 291f9d4494..cbfb7d6097 100644 --- a/src/main/java/vazkii/botania/client/gui/lexicon/button/GuiButtonInvisible.java +++ b/src/main/java/vazkii/botania/client/gui/lexicon/button/GuiButtonInvisible.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jan 14, 2014, 8:34:01 PM (GMT)] */ package vazkii.botania.client.gui.lexicon.button; @@ -16,8 +16,10 @@ import net.minecraft.item.ItemStack; import net.minecraft.util.EnumChatFormatting; import net.minecraft.util.ResourceLocation; + import org.lwjgl.opengl.GL11; import org.lwjgl.opengl.GL12; + import vazkii.botania.client.core.handler.ClientTickHandler; import vazkii.botania.client.core.handler.PersistentVariableHelper; import vazkii.botania.client.core.helper.FontHelper; @@ -27,102 +29,91 @@ public class GuiButtonInvisible extends GuiButtonLexicon { - private static final ResourceLocation dogResource = new ResourceLocation(LibResources.GUI_DOG); - - GuiLexiconIndex gui; - public ItemStack displayStack = null; - public boolean dog = false; - float timeHover = 0; - - boolean enableDog = false; - double dogPos = 0; - - public GuiButtonInvisible(GuiLexiconIndex gui, int par1, int par2, int par3, int par4, int par5, String par6Str) { - super(par1, par2, par3, par4, par5, par6Str); - this.gui = gui; - } - - public void click() { - enableDog = true; - PersistentVariableHelper.dog = true; - PersistentVariableHelper.saveSafe(); - } - - @Override - public void drawButton(Minecraft par1Minecraft, int par2, int par3) { - if (enableDog) { - dogPos += ClientTickHandler.delta * 10; - - par1Minecraft.renderEngine.bindTexture(dogResource); - float f = 1F / 64F; - GL11.glTranslated(dogPos, 0, 0); - GL11.glColor4f(1F, 1F, 1F, 1F); - vazkii.botania.client.core.helper.RenderHelper.drawTexturedModalRect( - 0, yPosition, zLevel + 10, (dogPos % 100 < 50) ? 23 : 0, 0, 23, 19, f, f); - xPosition = (int) Math.max(xPosition, dogPos + 10); - - GL11.glTranslated(-dogPos, 0, 0); - } - - field_146123_n = - par2 >= xPosition && par3 >= yPosition && par2 < xPosition + width && par3 < yPosition + height; - int k = getHoverState(field_146123_n); - boolean showStack = displayStack != null && !displayString.isEmpty(); - - if (!displayString.isEmpty() && k == 2) { - timeHover = Math.min(5, timeHover + gui.timeDelta); - gui.setHoveredButton(this); - } else timeHover = Math.max(0, timeHover - gui.timeDelta); - - GL11.glPushMatrix(); - GL11.glEnable(GL11.GL_BLEND); - GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); - - GL11.glDisable(GL11.GL_ALPHA_TEST); - int color = 0; - String format = FontHelper.getFormatFromString(displayString); - if (format.length() > 1) { - char key = format.charAt(format.length() - 1); - if (key == 'o' && format.length() > 3) key = format.charAt(1); - - for (EnumChatFormatting ecf : EnumChatFormatting.class.getEnumConstants()) - if (ecf.getFormattingCode() == key) { - if (ecf.ordinal() > 15) ecf = EnumChatFormatting.BLACK; - color = LibMisc.CONTROL_CODE_COLORS[ecf.ordinal()]; - break; - } - } - - int maxalpha = 0x22; - int alpha = Math.min(maxalpha, (int) (timeHover / 4 * maxalpha)); - drawRect( - xPosition - 5, - yPosition, - (int) (xPosition - 5 + timeHover * 24), - yPosition + height, - alpha << 24 | color); - GL11.glEnable(GL11.GL_ALPHA_TEST); - - boolean unicode = par1Minecraft.fontRenderer.getUnicodeFlag(); - par1Minecraft.fontRenderer.setUnicodeFlag(true); - par1Minecraft.fontRenderer.drawString( - displayString, xPosition + (showStack ? 7 : 0), yPosition + (height - 8) / 2, 0); - par1Minecraft.fontRenderer.setUnicodeFlag(unicode); + private static final ResourceLocation dogResource = new ResourceLocation(LibResources.GUI_DOG); + + GuiLexiconIndex gui; + public ItemStack displayStack = null; + public boolean dog = false; + float timeHover = 0; + + boolean enableDog = false; + double dogPos = 0; + + public GuiButtonInvisible(GuiLexiconIndex gui, int par1, int par2, int par3, int par4, int par5, String par6Str) { + super(par1, par2, par3, par4, par5, par6Str); + this.gui = gui; + } + + public void click() { + enableDog = true; + PersistentVariableHelper.dog = true; + PersistentVariableHelper.saveSafe(); + } + + @Override + public void drawButton(Minecraft par1Minecraft, int par2, int par3) { + if(enableDog) { + dogPos += ClientTickHandler.delta * 10; + + par1Minecraft.renderEngine.bindTexture(dogResource); + float f = 1F / 64F; + GL11.glTranslated(dogPos, 0, 0); + GL11.glColor4f(1F, 1F, 1F, 1F); + vazkii.botania.client.core.helper.RenderHelper.drawTexturedModalRect(0, yPosition, zLevel + 10, (dogPos % 100 < 50) ? 23 : 0, 0, 23, 19, f, f); + xPosition = (int) Math.max(xPosition, dogPos + 10); + + GL11.glTranslated(-dogPos, 0, 0); + } + + field_146123_n = par2 >= xPosition && par3 >= yPosition && par2 < xPosition + width && par3 < yPosition + height; + int k = getHoverState(field_146123_n); + boolean showStack = displayStack != null && !displayString.isEmpty(); + + if(!displayString.isEmpty() && k == 2) { + timeHover = Math.min(5, timeHover + gui.timeDelta); + gui.setHoveredButton(this); + } else timeHover = Math.max(0, timeHover - gui.timeDelta); + + GL11.glPushMatrix(); + GL11.glEnable(GL11.GL_BLEND); + GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); + + GL11.glDisable(GL11.GL_ALPHA_TEST); + int color = 0; + String format = FontHelper.getFormatFromString(displayString); + if(format.length() > 1) { + char key = format.charAt(format.length() - 1); + if(key == 'o' && format.length() > 3) + key = format.charAt(1); + + for(EnumChatFormatting ecf : EnumChatFormatting.class.getEnumConstants()) + if(ecf.getFormattingCode() == key) { + if(ecf.ordinal() > 15) + ecf = EnumChatFormatting.BLACK; + color = LibMisc.CONTROL_CODE_COLORS[ecf.ordinal()]; + break; + } + } + + int maxalpha = 0x22; + int alpha = Math.min(maxalpha, (int) (timeHover / 4 * maxalpha)); + drawRect(xPosition - 5, yPosition, (int) (xPosition - 5 + timeHover * 24), yPosition + height, alpha << 24 | color); + GL11.glEnable(GL11.GL_ALPHA_TEST); + + boolean unicode = par1Minecraft.fontRenderer.getUnicodeFlag(); + par1Minecraft.fontRenderer.setUnicodeFlag(true); + par1Minecraft.fontRenderer.drawString(displayString, xPosition + (showStack ? 7 : 0), yPosition + (height - 8) / 2, 0); + par1Minecraft.fontRenderer.setUnicodeFlag(unicode); + + if(showStack) { + GL11.glScalef(0.5F, 0.5F, 0.5F); + RenderHelper.enableGUIStandardItemLighting(); + GL11.glEnable(GL12.GL_RESCALE_NORMAL); + RenderItem.getInstance().renderItemIntoGUI(par1Minecraft.fontRenderer, par1Minecraft.renderEngine, displayStack, xPosition * 2 - 6, yPosition * 2 + 4); + RenderHelper.disableStandardItemLighting(); + GL11.glEnable(GL11.GL_BLEND); + } + GL11.glPopMatrix(); + } - if (showStack) { - GL11.glScalef(0.5F, 0.5F, 0.5F); - RenderHelper.enableGUIStandardItemLighting(); - GL11.glEnable(GL12.GL_RESCALE_NORMAL); - RenderItem.getInstance() - .renderItemIntoGUI( - par1Minecraft.fontRenderer, - par1Minecraft.renderEngine, - displayStack, - xPosition * 2 - 6, - yPosition * 2 + 4); - RenderHelper.disableStandardItemLighting(); - GL11.glEnable(GL11.GL_BLEND); - } - GL11.glPopMatrix(); - } } diff --git a/src/main/java/vazkii/botania/client/gui/lexicon/button/GuiButtonLexicon.java b/src/main/java/vazkii/botania/client/gui/lexicon/button/GuiButtonLexicon.java index 52f6b669ba..b352679b95 100644 --- a/src/main/java/vazkii/botania/client/gui/lexicon/button/GuiButtonLexicon.java +++ b/src/main/java/vazkii/botania/client/gui/lexicon/button/GuiButtonLexicon.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Aug 7, 2014, 5:53:16 PM (GMT)] */ package vazkii.botania.client.gui.lexicon.button; @@ -17,13 +17,13 @@ public class GuiButtonLexicon extends GuiButton { - public GuiButtonLexicon( - int p_i1021_1_, int p_i1021_2_, int p_i1021_3_, int p_i1021_4_, int p_i1021_5_, String p_i1021_6_) { - super(p_i1021_1_, p_i1021_2_, p_i1021_3_, p_i1021_4_, p_i1021_5_, p_i1021_6_); - } + public GuiButtonLexicon(int p_i1021_1_, int p_i1021_2_, int p_i1021_3_, int p_i1021_4_, int p_i1021_5_, String p_i1021_6_) { + super(p_i1021_1_, p_i1021_2_, p_i1021_3_, p_i1021_4_, p_i1021_5_, p_i1021_6_); + } + + @Override + public void func_146113_a(SoundHandler p_146113_1_) { + p_146113_1_.playSound(PositionedSoundRecord.func_147674_a(new ResourceLocation("botania:lexiconPage"), 1.0F)); + } - @Override - public void func_146113_a(SoundHandler p_146113_1_) { - p_146113_1_.playSound(PositionedSoundRecord.func_147674_a(new ResourceLocation("botania:lexiconPage"), 1.0F)); - } } diff --git a/src/main/java/vazkii/botania/client/gui/lexicon/button/GuiButtonNotes.java b/src/main/java/vazkii/botania/client/gui/lexicon/button/GuiButtonNotes.java index 6d38cc9f44..28729ab7d6 100644 --- a/src/main/java/vazkii/botania/client/gui/lexicon/button/GuiButtonNotes.java +++ b/src/main/java/vazkii/botania/client/gui/lexicon/button/GuiButtonNotes.java @@ -2,52 +2,56 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jul 24, 2015, 2:49:36 AM (GMT)] */ package vazkii.botania.client.gui.lexicon.button; import java.util.ArrayList; import java.util.List; + import net.minecraft.client.Minecraft; import net.minecraft.util.EnumChatFormatting; import net.minecraft.util.StatCollector; + import org.lwjgl.opengl.GL11; + import vazkii.botania.client.core.helper.RenderHelper; import vazkii.botania.client.gui.lexicon.GuiLexicon; public class GuiButtonNotes extends GuiButtonLexicon { - GuiLexicon parent; - - public GuiButtonNotes(GuiLexicon parent, int id, int x, int y) { - super(id, x, y, 11, 11, ""); - this.parent = parent; - } - - @Override - public void drawButton(Minecraft par1Minecraft, int par2, int par3) { - field_146123_n = - par2 >= xPosition && par3 >= yPosition && par2 < xPosition + width && par3 < yPosition + height; - int k = getHoverState(field_146123_n); - - par1Minecraft.renderEngine.bindTexture(GuiLexicon.texture); - GL11.glColor4f(1F, 1F, 1F, 1F); - drawTexturedModalRect(xPosition, yPosition, k == 2 ? 130 : 120, 191, 10, 11); - - List tooltip = new ArrayList(); - if (GuiLexicon.notesEnabled) - tooltip.add(EnumChatFormatting.GREEN + StatCollector.translateToLocal("botaniamisc.hideNotes")); - else { - tooltip.add(EnumChatFormatting.GREEN + StatCollector.translateToLocal("botaniamisc.showNotes")); - if (parent.note != null && !parent.note.isEmpty()) - Minecraft.getMinecraft().fontRenderer.drawStringWithShadow("!", xPosition + 10, yPosition, 0xFF0000); - } - - int tooltipY = (tooltip.size() - 1) * 10; - if (k == 2) RenderHelper.renderTooltip(par2, par3 + tooltipY, tooltip); - } + GuiLexicon parent; + + public GuiButtonNotes(GuiLexicon parent, int id, int x, int y) { + super(id, x, y, 11, 11, ""); + this.parent = parent; + } + + @Override + public void drawButton(Minecraft par1Minecraft, int par2, int par3) { + field_146123_n = par2 >= xPosition && par3 >= yPosition && par2 < xPosition + width && par3 < yPosition + height; + int k = getHoverState(field_146123_n); + + par1Minecraft.renderEngine.bindTexture(GuiLexicon.texture); + GL11.glColor4f(1F, 1F, 1F, 1F); + drawTexturedModalRect(xPosition, yPosition, k == 2 ? 130 : 120, 191, 10, 11); + + List tooltip = new ArrayList(); + if(GuiLexicon.notesEnabled) + tooltip.add(EnumChatFormatting.GREEN + StatCollector.translateToLocal("botaniamisc.hideNotes")); + else { + tooltip.add(EnumChatFormatting.GREEN + StatCollector.translateToLocal("botaniamisc.showNotes")); + if(parent.note != null && !parent.note.isEmpty()) + Minecraft.getMinecraft().fontRenderer.drawStringWithShadow("!", xPosition + 10, yPosition, 0xFF0000); + } + + int tooltipY = (tooltip.size() - 1) * 10; + if(k == 2) + RenderHelper.renderTooltip(par2, par3 + tooltipY, tooltip); + } + } diff --git a/src/main/java/vazkii/botania/client/gui/lexicon/button/GuiButtonOptions.java b/src/main/java/vazkii/botania/client/gui/lexicon/button/GuiButtonOptions.java index e5eb5d953d..013f9bceb2 100644 --- a/src/main/java/vazkii/botania/client/gui/lexicon/button/GuiButtonOptions.java +++ b/src/main/java/vazkii/botania/client/gui/lexicon/button/GuiButtonOptions.java @@ -2,45 +2,48 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Mar 6, 2015, 1:14:05 PM (GMT)] */ package vazkii.botania.client.gui.lexicon.button; import java.util.ArrayList; import java.util.List; + import net.minecraft.client.Minecraft; import net.minecraft.util.EnumChatFormatting; import net.minecraft.util.StatCollector; + import org.lwjgl.opengl.GL11; + import vazkii.botania.client.core.helper.RenderHelper; import vazkii.botania.client.gui.lexicon.GuiLexicon; public class GuiButtonOptions extends GuiButtonLexicon { - public GuiButtonOptions(int id, int x, int y) { - super(id, x, y, 11, 11, ""); - } + public GuiButtonOptions(int id, int x, int y) { + super(id, x, y, 11, 11, ""); + } + + @Override + public void drawButton(Minecraft par1Minecraft, int par2, int par3) { + field_146123_n = par2 >= xPosition && par3 >= yPosition && par2 < xPosition + width && par3 < yPosition + height; + int k = getHoverState(field_146123_n); - @Override - public void drawButton(Minecraft par1Minecraft, int par2, int par3) { - field_146123_n = - par2 >= xPosition && par3 >= yPosition && par2 < xPosition + width && par3 < yPosition + height; - int k = getHoverState(field_146123_n); + par1Minecraft.renderEngine.bindTexture(GuiLexicon.texture); + GL11.glColor4f(1F, 1F, 1F, 1F); + drawTexturedModalRect(xPosition, yPosition, k == 2 ? 109 : 98, 180, 11, 11); - par1Minecraft.renderEngine.bindTexture(GuiLexicon.texture); - GL11.glColor4f(1F, 1F, 1F, 1F); - drawTexturedModalRect(xPosition, yPosition, k == 2 ? 109 : 98, 180, 11, 11); + List tooltip = new ArrayList(); + for(int i = 0; i < 3; i++) + tooltip.add((i == 0 ? EnumChatFormatting.RED : EnumChatFormatting.GRAY) + StatCollector.translateToLocal("botaniamisc.lexiconOptions" + i)); - List tooltip = new ArrayList(); - for (int i = 0; i < 3; i++) - tooltip.add((i == 0 ? EnumChatFormatting.RED : EnumChatFormatting.GRAY) - + StatCollector.translateToLocal("botaniamisc.lexiconOptions" + i)); + int tooltipY = (tooltip.size() - 1) * 10; + if(k == 2) + RenderHelper.renderTooltip(par2, par3 + tooltipY, tooltip); + } - int tooltipY = (tooltip.size() - 1) * 10; - if (k == 2) RenderHelper.renderTooltip(par2, par3 + tooltipY, tooltip); - } } diff --git a/src/main/java/vazkii/botania/client/gui/lexicon/button/GuiButtonPage.java b/src/main/java/vazkii/botania/client/gui/lexicon/button/GuiButtonPage.java index a04173e7b8..fdd0bc7e8b 100644 --- a/src/main/java/vazkii/botania/client/gui/lexicon/button/GuiButtonPage.java +++ b/src/main/java/vazkii/botania/client/gui/lexicon/button/GuiButtonPage.java @@ -2,47 +2,46 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jan 16, 2014, 4:52:06 PM (GMT)] */ package vazkii.botania.client.gui.lexicon.button; import java.util.Arrays; + import net.minecraft.client.Minecraft; import net.minecraft.util.StatCollector; + import org.lwjgl.opengl.GL11; + import vazkii.botania.client.core.helper.RenderHelper; import vazkii.botania.client.gui.lexicon.GuiLexicon; public class GuiButtonPage extends GuiButtonLexicon { - boolean right; - - public GuiButtonPage(int par1, int par2, int par3, boolean right) { - super(par1, par2, par3, 18, 10, ""); - this.right = right; - } - - @Override - public void drawButton(Minecraft par1Minecraft, int par2, int par3) { - if (enabled) { - field_146123_n = - par2 >= xPosition && par3 >= yPosition && par2 < xPosition + width && par3 < yPosition + height; - int k = getHoverState(field_146123_n); - - par1Minecraft.renderEngine.bindTexture(GuiLexicon.texture); - GL11.glColor4f(1F, 1F, 1F, 1F); - drawTexturedModalRect(xPosition, yPosition, k == 2 ? 18 : 0, right ? 180 : 190, 18, 10); - - if (k == 2) - RenderHelper.renderTooltip( - par2, - par3, - Arrays.asList(StatCollector.translateToLocal( - right ? "botaniamisc.nextPage" : "botaniamisc.prevPage"))); - } - } + boolean right; + + public GuiButtonPage(int par1, int par2, int par3, boolean right) { + super(par1, par2, par3, 18, 10, ""); + this.right = right; + } + + @Override + public void drawButton(Minecraft par1Minecraft, int par2, int par3) { + if(enabled) { + field_146123_n = par2 >= xPosition && par3 >= yPosition && par2 < xPosition + width && par3 < yPosition + height; + int k = getHoverState(field_146123_n); + + par1Minecraft.renderEngine.bindTexture(GuiLexicon.texture); + GL11.glColor4f(1F, 1F, 1F, 1F); + drawTexturedModalRect(xPosition, yPosition, k == 2 ? 18 : 0, right ? 180 : 190, 18, 10); + + if(k == 2) + RenderHelper.renderTooltip(par2, par3, Arrays.asList(StatCollector.translateToLocal(right ? "botaniamisc.nextPage" : "botaniamisc.prevPage"))); + } + } + } diff --git a/src/main/java/vazkii/botania/client/gui/lexicon/button/GuiButtonShare.java b/src/main/java/vazkii/botania/client/gui/lexicon/button/GuiButtonShare.java index d2cf5a83bf..339cc48dd7 100644 --- a/src/main/java/vazkii/botania/client/gui/lexicon/button/GuiButtonShare.java +++ b/src/main/java/vazkii/botania/client/gui/lexicon/button/GuiButtonShare.java @@ -2,45 +2,48 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Sep 24, 2014, 3:49:21 PM (GMT)] */ package vazkii.botania.client.gui.lexicon.button; import java.util.Arrays; import java.util.List; + import net.minecraft.client.Minecraft; import net.minecraft.util.EnumChatFormatting; import net.minecraft.util.StatCollector; + import org.lwjgl.opengl.GL11; + import vazkii.botania.client.core.helper.RenderHelper; import vazkii.botania.client.gui.lexicon.GuiLexicon; public class GuiButtonShare extends GuiButtonLexicon { - public GuiButtonShare(int par1, int par2, int par3) { - super(par1, par2, par3, 10, 12, ""); - } + public GuiButtonShare(int par1, int par2, int par3) { + super(par1, par2, par3, 10, 12, ""); + } - @Override - public void drawButton(Minecraft par1Minecraft, int par2, int par3) { - field_146123_n = - par2 >= xPosition && par3 >= yPosition && par2 < xPosition + width && par3 < yPosition + height; - int k = getHoverState(field_146123_n); + @Override + public void drawButton(Minecraft par1Minecraft, int par2, int par3) { + field_146123_n = par2 >= xPosition && par3 >= yPosition && par2 < xPosition + width && par3 < yPosition + height; + int k = getHoverState(field_146123_n); - par1Minecraft.renderEngine.bindTexture(GuiLexicon.texture); - GL11.glColor4f(1F, 1F, 1F, 1F); - drawTexturedModalRect(xPosition, yPosition, k == 2 ? 10 : 0, 200, 10, 12); + par1Minecraft.renderEngine.bindTexture(GuiLexicon.texture); + GL11.glColor4f(1F, 1F, 1F, 1F); + drawTexturedModalRect(xPosition, yPosition, k == 2 ? 10 : 0 , 200, 10, 12); - List tooltip = getTooltip(); - int tooltipY = (tooltip.size() - 1) * 10; - if (k == 2) RenderHelper.renderTooltip(par2, par3 + tooltipY, tooltip); - } + List tooltip = getTooltip(); + int tooltipY = (tooltip.size() - 1) * 10; + if(k == 2) + RenderHelper.renderTooltip(par2, par3 + tooltipY, tooltip); + } - public List getTooltip() { - return Arrays.asList(EnumChatFormatting.AQUA + StatCollector.translateToLocal("botaniamisc.clickToShare")); - } + public List getTooltip() { + return Arrays.asList(EnumChatFormatting.AQUA + StatCollector.translateToLocal("botaniamisc.clickToShare")); + } } diff --git a/src/main/java/vazkii/botania/client/gui/lexicon/button/GuiButtonUpdateWarning.java b/src/main/java/vazkii/botania/client/gui/lexicon/button/GuiButtonUpdateWarning.java index 6c32835ff7..7f50bc6720 100644 --- a/src/main/java/vazkii/botania/client/gui/lexicon/button/GuiButtonUpdateWarning.java +++ b/src/main/java/vazkii/botania/client/gui/lexicon/button/GuiButtonUpdateWarning.java @@ -2,20 +2,23 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Aug 25, 2015, 6:13:11 PM (GMT)] */ package vazkii.botania.client.gui.lexicon.button; import java.util.ArrayList; import java.util.List; + import net.minecraft.client.Minecraft; import net.minecraft.util.EnumChatFormatting; import net.minecraft.util.StatCollector; + import org.lwjgl.opengl.GL11; + import vazkii.botania.client.core.handler.ClientTickHandler; import vazkii.botania.client.core.handler.PersistentVariableHelper; import vazkii.botania.client.core.helper.RenderHelper; @@ -23,34 +26,35 @@ public class GuiButtonUpdateWarning extends GuiButtonLexicon { - public GuiButtonUpdateWarning(int id, int x, int y) { - super(id, x, y, 11, 11, ""); - } + public GuiButtonUpdateWarning(int id, int x, int y) { + super(id, x, y, 11, 11, ""); + } + + @Override + public void drawButton(Minecraft par1Minecraft, int par2, int par3) { + if(!visible || !enabled) + return; - @Override - public void drawButton(Minecraft par1Minecraft, int par2, int par3) { - if (!visible || !enabled) return; + field_146123_n = par2 >= xPosition && par3 >= yPosition && par2 < xPosition + width && par3 < yPosition + height; + int k = getHoverState(field_146123_n); - field_146123_n = - par2 >= xPosition && par3 >= yPosition && par2 < xPosition + width && par3 < yPosition + height; - int k = getHoverState(field_146123_n); + boolean red = k == 2 || ClientTickHandler.ticksInGame % 10 < 5; - boolean red = k == 2 || ClientTickHandler.ticksInGame % 10 < 5; + par1Minecraft.renderEngine.bindTexture(GuiLexicon.texture); + GL11.glColor4f(1F, 1F, 1F, 1F); + drawTexturedModalRect(xPosition, yPosition, red ? 153 : 142, 180, 11, 11); - par1Minecraft.renderEngine.bindTexture(GuiLexicon.texture); - GL11.glColor4f(1F, 1F, 1F, 1F); - drawTexturedModalRect(xPosition, yPosition, red ? 153 : 142, 180, 11, 11); + List tooltip = new ArrayList(); + String version = PersistentVariableHelper.lastBotaniaVersion; + for(int i = 0; i < 6; i++) { + tooltip.add(EnumChatFormatting.GRAY + String.format(StatCollector.translateToLocal("botaniamisc.changes" + i), version).replaceAll("&", "\u00a7")); + if(i == 3) + tooltip.add(""); + } - List tooltip = new ArrayList(); - String version = PersistentVariableHelper.lastBotaniaVersion; - for (int i = 0; i < 6; i++) { - tooltip.add(EnumChatFormatting.GRAY - + String.format(StatCollector.translateToLocal("botaniamisc.changes" + i), version) - .replaceAll("&", "\u00a7")); - if (i == 3) tooltip.add(""); - } + int tooltipY = (tooltip.size() - 1) * 10 - 25; + if(k == 2) + RenderHelper.renderTooltip(par2 - 125, par3 + tooltipY, tooltip); + } - int tooltipY = (tooltip.size() - 1) * 10 - 25; - if (k == 2) RenderHelper.renderTooltip(par2 - 125, par3 + tooltipY, tooltip); - } } diff --git a/src/main/java/vazkii/botania/client/gui/lexicon/button/GuiButtonViewOnline.java b/src/main/java/vazkii/botania/client/gui/lexicon/button/GuiButtonViewOnline.java index 45d84dbe40..3cfb30b454 100644 --- a/src/main/java/vazkii/botania/client/gui/lexicon/button/GuiButtonViewOnline.java +++ b/src/main/java/vazkii/botania/client/gui/lexicon/button/GuiButtonViewOnline.java @@ -2,42 +2,45 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Mar 2, 2015, 5:34:05 PM (GMT)] */ package vazkii.botania.client.gui.lexicon.button; import java.util.Arrays; import java.util.List; + import net.minecraft.client.Minecraft; import net.minecraft.util.EnumChatFormatting; import net.minecraft.util.StatCollector; + import org.lwjgl.opengl.GL11; + import vazkii.botania.client.core.helper.RenderHelper; import vazkii.botania.client.gui.lexicon.GuiLexicon; public class GuiButtonViewOnline extends GuiButtonLexicon { - public GuiButtonViewOnline(int id, int x, int y) { - super(id, x, y, 11, 11, ""); - } - - @Override - public void drawButton(Minecraft par1Minecraft, int par2, int par3) { - field_146123_n = - par2 >= xPosition && par3 >= yPosition && par2 < xPosition + width && par3 < yPosition + height; - int k = getHoverState(field_146123_n); - - par1Minecraft.renderEngine.bindTexture(GuiLexicon.texture); - GL11.glColor4f(1F, 1F, 1F, 1F); - drawTexturedModalRect(xPosition, yPosition, k == 2 ? 41 : 30, 200, 11, 11); - - List tooltip = - Arrays.asList(EnumChatFormatting.AQUA + StatCollector.translateToLocal("botaniamisc.viewOnline")); - int tooltipY = (tooltip.size() - 1) * 10; - if (k == 2) RenderHelper.renderTooltip(par2, par3 + tooltipY, tooltip); - } + public GuiButtonViewOnline(int id, int x, int y) { + super(id, x, y, 11, 11, ""); + } + + @Override + public void drawButton(Minecraft par1Minecraft, int par2, int par3) { + field_146123_n = par2 >= xPosition && par3 >= yPosition && par2 < xPosition + width && par3 < yPosition + height; + int k = getHoverState(field_146123_n); + + par1Minecraft.renderEngine.bindTexture(GuiLexicon.texture); + GL11.glColor4f(1F, 1F, 1F, 1F); + drawTexturedModalRect(xPosition, yPosition, k == 2 ? 41 : 30, 200, 11, 11); + + List tooltip = Arrays.asList(EnumChatFormatting.AQUA + StatCollector.translateToLocal("botaniamisc.viewOnline")); + int tooltipY = (tooltip.size() - 1) * 10; + if(k == 2) + RenderHelper.renderTooltip(par2, par3 + tooltipY, tooltip); + } + } diff --git a/src/main/java/vazkii/botania/client/integration/nei/NEIBotaniaConfig.java b/src/main/java/vazkii/botania/client/integration/nei/NEIBotaniaConfig.java index 4d3f534b53..277bd5806b 100644 --- a/src/main/java/vazkii/botania/client/integration/nei/NEIBotaniaConfig.java +++ b/src/main/java/vazkii/botania/client/integration/nei/NEIBotaniaConfig.java @@ -1,9 +1,7 @@ package vazkii.botania.client.integration.nei; -import codechicken.nei.api.API; -import codechicken.nei.api.IConfigureNEI; -import codechicken.nei.guihook.GuiContainerManager; import org.lwjgl.input.Keyboard; + import vazkii.botania.client.integration.nei.recipe.RecipeHandlerBrewery; import vazkii.botania.client.integration.nei.recipe.RecipeHandlerElvenTrade; import vazkii.botania.client.integration.nei.recipe.RecipeHandlerFloatingFlowers; @@ -13,48 +11,52 @@ import vazkii.botania.client.integration.nei.recipe.RecipeHandlerPureDaisy; import vazkii.botania.client.integration.nei.recipe.RecipeHandlerRunicAltar; import vazkii.botania.common.lib.LibMisc; +import codechicken.nei.api.API; +import codechicken.nei.api.IConfigureNEI; +import codechicken.nei.guihook.GuiContainerManager; public class NEIBotaniaConfig implements IConfigureNEI { - public static final String CORPOREA_KEY = "gui.botania_corporea_request"; - - @Override - public String getName() { - return LibMisc.MOD_NAME; - } - - @Override - public String getVersion() { - return LibMisc.VERSION; - } + public static final String CORPOREA_KEY = "gui.botania_corporea_request"; + + @Override + public String getName() { + return LibMisc.MOD_NAME; + } - @Override - public void loadConfig() { - API.registerRecipeHandler(new RecipeHandlerFloatingFlowers()); - API.registerUsageHandler(new RecipeHandlerFloatingFlowers()); + @Override + public String getVersion() { + return LibMisc.VERSION; + } - API.registerRecipeHandler(new RecipeHandlerPetalApothecary()); - API.registerUsageHandler(new RecipeHandlerPetalApothecary()); + @Override + public void loadConfig() { + API.registerRecipeHandler(new RecipeHandlerFloatingFlowers()); + API.registerUsageHandler(new RecipeHandlerFloatingFlowers()); - API.registerRecipeHandler(new RecipeHandlerRunicAltar()); - API.registerUsageHandler(new RecipeHandlerRunicAltar()); + API.registerRecipeHandler(new RecipeHandlerPetalApothecary()); + API.registerUsageHandler(new RecipeHandlerPetalApothecary()); - API.registerRecipeHandler(new RecipeHandlerManaPool()); - API.registerUsageHandler(new RecipeHandlerManaPool()); + API.registerRecipeHandler(new RecipeHandlerRunicAltar()); + API.registerUsageHandler(new RecipeHandlerRunicAltar()); - API.registerRecipeHandler(new RecipeHandlerElvenTrade()); - API.registerUsageHandler(new RecipeHandlerElvenTrade()); + API.registerRecipeHandler(new RecipeHandlerManaPool()); + API.registerUsageHandler(new RecipeHandlerManaPool()); - API.registerRecipeHandler(new RecipeHandlerBrewery()); - API.registerUsageHandler(new RecipeHandlerBrewery()); + API.registerRecipeHandler(new RecipeHandlerElvenTrade()); + API.registerUsageHandler(new RecipeHandlerElvenTrade()); - API.registerRecipeHandler(new RecipeHandlerPureDaisy()); - API.registerUsageHandler(new RecipeHandlerPureDaisy()); + API.registerRecipeHandler(new RecipeHandlerBrewery()); + API.registerUsageHandler(new RecipeHandlerBrewery()); - API.registerRecipeHandler(new RecipeHandlerLexicaBotania()); - API.registerUsageHandler(new RecipeHandlerLexicaBotania()); + API.registerRecipeHandler(new RecipeHandlerPureDaisy()); + API.registerUsageHandler(new RecipeHandlerPureDaisy()); + + API.registerRecipeHandler(new RecipeHandlerLexicaBotania()); + API.registerUsageHandler(new RecipeHandlerLexicaBotania()); + + API.addKeyBind(CORPOREA_KEY, Keyboard.KEY_C); + GuiContainerManager.addInputHandler(new NEIInputHandler()); + } - API.addKeyBind(CORPOREA_KEY, Keyboard.KEY_C); - GuiContainerManager.addInputHandler(new NEIInputHandler()); - } } diff --git a/src/main/java/vazkii/botania/client/integration/nei/NEIGuiHooks.java b/src/main/java/vazkii/botania/client/integration/nei/NEIGuiHooks.java index ae5719a45b..37953eeaf2 100644 --- a/src/main/java/vazkii/botania/client/integration/nei/NEIGuiHooks.java +++ b/src/main/java/vazkii/botania/client/integration/nei/NEIGuiHooks.java @@ -2,22 +2,23 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Dec 15, 2014, 6:09:38 PM (GMT)] */ package vazkii.botania.client.integration.nei; +import vazkii.botania.client.gui.crafting.GuiCraftingHalo; import codechicken.nei.api.API; import codechicken.nei.recipe.DefaultOverlayHandler; -import vazkii.botania.client.gui.crafting.GuiCraftingHalo; public class NEIGuiHooks { - public static void init() { - API.registerGuiOverlay(GuiCraftingHalo.class, "crafting"); - API.registerGuiOverlayHandler(GuiCraftingHalo.class, new DefaultOverlayHandler(), "crafting"); - } + public static void init() { + API.registerGuiOverlay(GuiCraftingHalo.class, "crafting"); + API.registerGuiOverlayHandler(GuiCraftingHalo.class, new DefaultOverlayHandler(), "crafting"); + } + } diff --git a/src/main/java/vazkii/botania/client/integration/nei/NEIInputHandler.java b/src/main/java/vazkii/botania/client/integration/nei/NEIInputHandler.java index 1e6949b97c..e1ea061889 100644 --- a/src/main/java/vazkii/botania/client/integration/nei/NEIInputHandler.java +++ b/src/main/java/vazkii/botania/client/integration/nei/NEIInputHandler.java @@ -2,95 +2,102 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [25/12/2015, 02:22:32 (GMT)] */ package vazkii.botania.client.integration.nei; +import vazkii.botania.api.corporea.CorporeaHelper; +import vazkii.botania.common.block.tile.corporea.TileCorporeaIndex; +import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.GuiScreen; +import net.minecraft.client.gui.inventory.GuiContainer; +import net.minecraft.item.ItemStack; +import net.minecraft.util.MathHelper; import codechicken.nei.LayoutManager; import codechicken.nei.NEIClientConfig; import codechicken.nei.guihook.GuiContainerManager; import codechicken.nei.guihook.IContainerInputHandler; -import net.minecraft.client.Minecraft; -import net.minecraft.client.gui.inventory.GuiContainer; -import net.minecraft.item.ItemStack; -import vazkii.botania.api.corporea.CorporeaHelper; -import vazkii.botania.common.block.tile.corporea.TileCorporeaIndex; public class NEIInputHandler implements IContainerInputHandler { - @Override - public boolean keyTyped(GuiContainer gui, char c, int i) { - Minecraft mc = Minecraft.getMinecraft(); - if (TileCorporeaIndex.InputHandler.getNearbyIndexes(mc.thePlayer).isEmpty()) return false; - - int bind = NEIClientConfig.getKeyBinding(NEIBotaniaConfig.CORPOREA_KEY); - - if (i == bind) { - LayoutManager layoutManager = LayoutManager.instance(); - if (layoutManager != null && LayoutManager.itemPanel != null && !NEIClientConfig.isHidden()) { - ItemStack stack = GuiContainerManager.getStackMouseOver(gui); - if (stack != null && stack.getItem() != null) { - int count = 1; - int max = stack.getMaxStackSize(); - if (gui.isShiftKeyDown()) { - count = max; - if (gui.isCtrlKeyDown()) count /= 4; - } else if (gui.isCtrlKeyDown()) count = max / 2; - - if (count > 0) { - String name = CorporeaHelper.stripControlCodes(stack.getDisplayName()); - String full = count + " " + name; - - mc.ingameGUI.getChatGUI().addToSentMessages(full); - mc.thePlayer.sendChatMessage(full); - return true; - } - } - } - } - - return false; - } - - @Override - public boolean lastKeyTyped(GuiContainer arg0, char arg1, int arg2) { - return false; - } - - @Override - public boolean mouseClicked(GuiContainer arg0, int arg1, int arg2, int arg3) { - return false; - } - - @Override - public boolean mouseScrolled(GuiContainer arg0, int arg1, int arg2, int arg3) { - return false; - } - - @Override - public void onKeyTyped(GuiContainer arg0, char arg1, int arg2) { - // NO-OP - } - - @Override - public void onMouseClicked(GuiContainer arg0, int arg1, int arg2, int arg3) {} - - @Override - public void onMouseDragged(GuiContainer arg0, int arg1, int arg2, int arg3, long arg4) { - // NO-OP - } - - @Override - public void onMouseScrolled(GuiContainer arg0, int arg1, int arg2, int arg3) { - // NO-OP - } + @Override + public boolean keyTyped(GuiContainer gui, char c, int i) { + Minecraft mc = Minecraft.getMinecraft(); + if(TileCorporeaIndex.InputHandler.getNearbyIndexes(mc.thePlayer).isEmpty()) + return false; + + int bind = NEIClientConfig.getKeyBinding(NEIBotaniaConfig.CORPOREA_KEY); + + if(i == bind) { + LayoutManager layoutManager = LayoutManager.instance(); + if(layoutManager != null && LayoutManager.itemPanel != null && !NEIClientConfig.isHidden()) { + ItemStack stack = GuiContainerManager.getStackMouseOver(gui); + if(stack != null && stack.getItem() != null) { + int count = 1; + int max = stack.getMaxStackSize(); + if(gui.isShiftKeyDown()) { + count = max; + if(gui.isCtrlKeyDown()) + count /= 4; + } else if(gui.isCtrlKeyDown()) + count = max / 2; + + if(count > 0) { + String name = CorporeaHelper.stripControlCodes(stack.getDisplayName()); + String full = count + " " + name; + + mc.ingameGUI.getChatGUI().addToSentMessages(full); + mc.thePlayer.sendChatMessage(full); + return true; + } + } + } + } + + return false; + } + + @Override + public boolean lastKeyTyped(GuiContainer arg0, char arg1, int arg2) { + return false; + } + + @Override + public boolean mouseClicked(GuiContainer arg0, int arg1, int arg2, int arg3) { + return false; + } + + @Override + public boolean mouseScrolled(GuiContainer arg0, int arg1, int arg2, int arg3) { + return false; + } + + @Override + public void onKeyTyped(GuiContainer arg0, char arg1, int arg2) { + // NO-OP + } + + @Override + public void onMouseClicked(GuiContainer arg0, int arg1, int arg2, int arg3) { + } + + @Override + public void onMouseDragged(GuiContainer arg0, int arg1, int arg2, int arg3, long arg4) { + // NO-OP + } + + @Override + public void onMouseScrolled(GuiContainer arg0, int arg1, int arg2, int arg3) { + // NO-OP + } + + @Override + public void onMouseUp(GuiContainer arg0, int arg1, int arg2, int arg3) { + // NO-OP + } - @Override - public void onMouseUp(GuiContainer arg0, int arg1, int arg2, int arg3) { - // NO-OP - } } diff --git a/src/main/java/vazkii/botania/client/integration/nei/recipe/RecipeHandlerBrewery.java b/src/main/java/vazkii/botania/client/integration/nei/recipe/RecipeHandlerBrewery.java index e98eeca134..0f4a091e9f 100644 --- a/src/main/java/vazkii/botania/client/integration/nei/recipe/RecipeHandlerBrewery.java +++ b/src/main/java/vazkii/botania/client/integration/nei/recipe/RecipeHandlerBrewery.java @@ -1,15 +1,15 @@ package vazkii.botania.client.integration.nei.recipe; -import codechicken.lib.gui.GuiDraw; -import codechicken.nei.PositionedStack; -import codechicken.nei.recipe.TemplateRecipeHandler; import java.awt.Rectangle; import java.util.ArrayList; import java.util.List; + import net.minecraft.item.ItemStack; import net.minecraft.util.StatCollector; import net.minecraftforge.oredict.OreDictionary; + import org.lwjgl.opengl.GL11; + import vazkii.botania.api.BotaniaAPI; import vazkii.botania.api.brew.IBrewContainer; import vazkii.botania.api.brew.IBrewItem; @@ -17,110 +17,124 @@ import vazkii.botania.client.lib.LibResources; import vazkii.botania.common.core.helper.ItemNBTHelper; import vazkii.botania.common.item.ModItems; +import codechicken.lib.gui.GuiDraw; +import codechicken.nei.PositionedStack; +import codechicken.nei.recipe.TemplateRecipeHandler; public class RecipeHandlerBrewery extends TemplateRecipeHandler { - public class CachedBreweryRecipe extends CachedRecipe { - - public List inputs = new ArrayList(); - public PositionedStack output; - public int mana; - - public CachedBreweryRecipe(RecipeBrew recipe, ItemStack vial) { - if (recipe == null) return; - - setIngredients(recipe.getInputs()); - ItemStack toVial; - if (vial == null) toVial = new ItemStack(ModItems.vial); - else toVial = vial.copy(); - toVial.stackSize = 1; - inputs.add(new PositionedStack(toVial, 39, 42)); - - output = new PositionedStack(recipe.getOutput(toVial), 87, 42); - } - - public CachedBreweryRecipe(RecipeBrew recipe) { - this(recipe, null); - } - - public void setIngredients(List inputs) { - int left = 96 - inputs.size() * 18 / 2; - - int i = 0; - for (Object o : inputs) { - if (o instanceof String) - this.inputs.add(new PositionedStack(OreDictionary.getOres((String) o), left + i * 18, 6)); - else this.inputs.add(new PositionedStack(o, left + i * 18, 6)); - - i++; - } - } - - @Override - public List getIngredients() { - return getCycledIngredients(cycleticks / 20, inputs); - } - - @Override - public PositionedStack getResult() { - return output; - } - } - - @Override - public String getRecipeName() { - return StatCollector.translateToLocal("botania.nei.brewery"); - } - - @Override - public String getGuiTexture() { - return LibResources.GUI_NEI_BREWERY; - } - - @Override - public void loadTransferRects() { - transferRects.add(new RecipeTransferRect(new Rectangle(87, 25, 15, 14), "botania.brewery")); - } - - @Override - public void drawBackground(int recipe) { - GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); - GuiDraw.changeTexture(getGuiTexture()); - GuiDraw.drawTexturedModalRect(0, 0, 0, 0, 166, 65); - } - - @Override - public void loadCraftingRecipes(String outputId, Object... results) { - if (outputId.equals("botania.brewery")) - for (RecipeBrew recipe : BotaniaAPI.brewRecipes) arecipes.add(new CachedBreweryRecipe(recipe)); - else super.loadCraftingRecipes(outputId, results); - } - - @Override - public void loadCraftingRecipes(ItemStack result) { - if (result.getItem() instanceof IBrewItem) - for (RecipeBrew recipe : BotaniaAPI.brewRecipes) { - if (recipe == null) continue; - - if (((IBrewItem) result.getItem()).getBrew(result) == recipe.getBrew()) - arecipes.add(new CachedBreweryRecipe(recipe)); - } - } - - @Override - public void loadUsageRecipes(ItemStack ingredient) { - if (ingredient.getItem() instanceof IBrewContainer) { - for (RecipeBrew recipe : BotaniaAPI.brewRecipes) { - if (recipe == null) continue; - - if (recipe.getOutput(ingredient) != null) arecipes.add(new CachedBreweryRecipe(recipe, ingredient)); - } - } else - for (RecipeBrew recipe : BotaniaAPI.brewRecipes) { - if (recipe == null) continue; - - CachedBreweryRecipe crecipe = new CachedBreweryRecipe(recipe); - if (ItemNBTHelper.cachedRecipeContainsWithNBT(crecipe.inputs, ingredient)) arecipes.add(crecipe); - } - } + public class CachedBreweryRecipe extends CachedRecipe { + + public List inputs = new ArrayList(); + public PositionedStack output; + public int mana; + + public CachedBreweryRecipe(RecipeBrew recipe, ItemStack vial) { + if(recipe == null) + return; + + setIngredients(recipe.getInputs()); + ItemStack toVial; + if (vial == null) + toVial = new ItemStack(ModItems.vial); + else + toVial = vial.copy(); + toVial.stackSize = 1; + inputs.add(new PositionedStack(toVial, 39, 42)); + + output = new PositionedStack(recipe.getOutput(toVial), 87, 42); + } + + public CachedBreweryRecipe(RecipeBrew recipe) { + this(recipe, null); + } + + public void setIngredients(List inputs) { + int left = 96 - inputs.size() * 18 / 2; + + int i = 0; + for (Object o : inputs) { + if (o instanceof String) + this.inputs.add(new PositionedStack(OreDictionary.getOres((String) o), left + i * 18, 6)); + else + this.inputs.add(new PositionedStack(o, left + i * 18, 6)); + + i++; + } + } + + @Override + public List getIngredients() { + return getCycledIngredients(cycleticks / 20, inputs); + } + + @Override + public PositionedStack getResult() { + return output; + } + + } + + @Override + public String getRecipeName() { + return StatCollector.translateToLocal("botania.nei.brewery"); + } + + @Override + public String getGuiTexture() { + return LibResources.GUI_NEI_BREWERY; + } + + @Override + public void loadTransferRects() { + transferRects.add(new RecipeTransferRect(new Rectangle(87, 25, 15, 14), "botania.brewery")); + } + + @Override + public void drawBackground(int recipe) { + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + GuiDraw.changeTexture(getGuiTexture()); + GuiDraw.drawTexturedModalRect(0, 0, 0, 0, 166, 65); + } + + @Override + public void loadCraftingRecipes(String outputId, Object... results) { + if(outputId.equals("botania.brewery")) + for(RecipeBrew recipe : BotaniaAPI.brewRecipes) + arecipes.add(new CachedBreweryRecipe(recipe)); + else super.loadCraftingRecipes(outputId, results); + } + + @Override + public void loadCraftingRecipes(ItemStack result) { + if(result.getItem() instanceof IBrewItem) + for(RecipeBrew recipe : BotaniaAPI.brewRecipes) { + if(recipe == null) + continue; + + if(((IBrewItem) result.getItem()).getBrew(result) == recipe.getBrew()) + arecipes.add(new CachedBreweryRecipe(recipe)); + } + } + + @Override + public void loadUsageRecipes(ItemStack ingredient) { + if(ingredient.getItem() instanceof IBrewContainer) { + for(RecipeBrew recipe : BotaniaAPI.brewRecipes) { + if(recipe == null) + continue; + + if(recipe.getOutput(ingredient) != null) + arecipes.add(new CachedBreweryRecipe(recipe, ingredient)); + } + } else for(RecipeBrew recipe : BotaniaAPI.brewRecipes) { + if(recipe == null) + continue; + + CachedBreweryRecipe crecipe = new CachedBreweryRecipe(recipe); + if(ItemNBTHelper.cachedRecipeContainsWithNBT(crecipe.inputs, ingredient)) + arecipes.add(crecipe); + } + } + } diff --git a/src/main/java/vazkii/botania/client/integration/nei/recipe/RecipeHandlerElvenTrade.java b/src/main/java/vazkii/botania/client/integration/nei/recipe/RecipeHandlerElvenTrade.java index 7e0468d1bb..b8835187dc 100644 --- a/src/main/java/vazkii/botania/client/integration/nei/recipe/RecipeHandlerElvenTrade.java +++ b/src/main/java/vazkii/botania/client/integration/nei/recipe/RecipeHandlerElvenTrade.java @@ -1,163 +1,169 @@ package vazkii.botania.client.integration.nei.recipe; -import codechicken.lib.gui.GuiDraw; -import codechicken.nei.NEIServerUtils; -import codechicken.nei.PositionedStack; -import codechicken.nei.recipe.TemplateRecipeHandler; import java.awt.Rectangle; import java.util.ArrayList; import java.util.Arrays; import java.util.List; import java.util.stream.Collectors; + import net.minecraft.client.renderer.entity.RenderItem; import net.minecraft.client.renderer.texture.TextureMap; import net.minecraft.item.ItemStack; import net.minecraft.util.StatCollector; import net.minecraftforge.oredict.OreDictionary; + import org.lwjgl.opengl.GL11; + import vazkii.botania.api.BotaniaAPI; import vazkii.botania.api.recipe.RecipeElvenTrade; import vazkii.botania.client.lib.LibResources; import vazkii.botania.common.block.BlockAlfPortal; +import codechicken.lib.gui.GuiDraw; +import codechicken.nei.NEIServerUtils; +import codechicken.nei.PositionedStack; +import codechicken.nei.recipe.TemplateRecipeHandler; import vazkii.botania.common.core.helper.ItemNBTHelper; public class RecipeHandlerElvenTrade extends TemplateRecipeHandler { - public class CachedElvenTradeRecipe extends CachedRecipe { - - public List inputs = new ArrayList(); - public PositionedStack output; - - public CachedElvenTradeRecipe(RecipeElvenTrade recipe) { - if (recipe == null) return; - - setIngredients(recipe.getInputs()); - output = new PositionedStack(recipe.getOutput(), 107, 46); - } - - public void setIngredients(List inputs) { - int i = 0; - for (Object o : inputs) { - if (o instanceof String) - this.inputs.add(new PositionedStack(OreDictionary.getOres((String) o), 60 + i * 18, 6)); - else this.inputs.add(new PositionedStack(o, 60 + i * 18, 6)); - - i++; - } - } - - @Override - public List getIngredients() { - return getCycledIngredients(cycleticks / 20, inputs); - } - - @Override - public PositionedStack getResult() { - return output; - } - } - - @Override - public String getRecipeName() { - return StatCollector.translateToLocal("botania.nei.elvenTrade"); - } - - @Override - public String getGuiTexture() { - return LibResources.GUI_NEI_BLANK; - } - - @Override - public void loadTransferRects() { - transferRects.add(new RecipeTransferRect(new Rectangle(35, 30, 48, 48), "botania.elvenTrade")); - } - - @Override - public int recipiesPerPage() { - return 1; - } - - @Override - public void drawBackground(int recipe) { - super.drawBackground(recipe); - GL11.glEnable(GL11.GL_BLEND); - GL11.glColor4f(1.0F, 1.0F, 1.0F, 0.7F); - GuiDraw.changeTexture(LibResources.GUI_ELVEN_TRADE_OVERLAY); - GuiDraw.drawTexturedModalRect(30, 10, 17, 17, 100, 80); - GL11.glDisable(GL11.GL_BLEND); - GuiDraw.changeTexture(TextureMap.locationBlocksTexture); - RenderItem.getInstance().renderIcon(35, 29, BlockAlfPortal.portalTex, 48, 48); - } - - private static boolean hasElvenKnowledge() { - /*EntityPlayer player = Minecraft.getMinecraft().thePlayer; - if (player != null) { - for (ItemStack stack : player.inventory.mainInventory) { - if (stack != null && stack.getItem() instanceof ILexicon) { - ILexicon lexicon = (ILexicon) stack.getItem(); - if (lexicon.isKnowledgeUnlocked(stack, BotaniaAPI.elvenKnowledge)) { - return true; - } - } - } - } - return false;*/ - return true; - } - - @Override - public void loadCraftingRecipes(String outputId, Object... results) { - if (outputId.equals("botania.elvenTrade") && hasElvenKnowledge()) { - if (hasElvenKnowledge()) { - for (RecipeElvenTrade recipe : filteredElvenTradeRecipes()) { - arecipes.add(new CachedElvenTradeRecipe(recipe)); - } - } - } else super.loadCraftingRecipes(outputId, results); - } - - @Override - public void loadCraftingRecipes(ItemStack result) { - if (hasElvenKnowledge()) { - for (RecipeElvenTrade recipe : filteredElvenTradeRecipes()) { - if (ItemNBTHelper.areStacksSameTypeCraftingWithNBT(recipe.getOutput(), result)) - arecipes.add(new CachedElvenTradeRecipe(recipe)); - } - } - } - - @Override - public void loadUsageRecipes(ItemStack ingredient) { - if (hasElvenKnowledge()) { - for (RecipeElvenTrade recipe : filteredElvenTradeRecipes()) { - CachedElvenTradeRecipe crecipe = new CachedElvenTradeRecipe(recipe); - if (ItemNBTHelper.cachedRecipeContainsWithNBT(crecipe.inputs, ingredient)) arecipes.add(crecipe); - } - } - } - - // hide dummy recipes - private List filteredElvenTradeRecipes() { - return BotaniaAPI.elvenTradeRecipes.stream() - .filter(recipe -> { - if (recipe == null) { - return false; - } - if (recipe.getInputs().size() == 1) { - return !stackSame(recipe.getOutput(), recipe.getInputs().get(0)); - } - return true; - }) - .collect(Collectors.toList()); - } - - private boolean stackSame(ItemStack stack, Object obj) { - if (obj instanceof String) { - return OreDictionary.getOres((String) obj).stream() - .anyMatch(s -> ItemNBTHelper.areStacksSameTypeCraftingWithNBT(stack, s)); - } else { - return Arrays.stream(NEIServerUtils.extractRecipeItems(obj)) - .anyMatch(s -> ItemNBTHelper.areStacksSameTypeCraftingWithNBT(stack, s)); - } - } + public class CachedElvenTradeRecipe extends CachedRecipe { + + public List inputs = new ArrayList(); + public PositionedStack output; + + public CachedElvenTradeRecipe(RecipeElvenTrade recipe) { + if(recipe == null) + return; + + setIngredients(recipe.getInputs()); + output = new PositionedStack(recipe.getOutput(), 107, 46); + } + + public void setIngredients(List inputs) { + int i = 0; + for(Object o : inputs) { + if(o instanceof String) + this.inputs.add(new PositionedStack(OreDictionary.getOres((String) o), 60 + i * 18, 6)); + else this.inputs.add(new PositionedStack(o, 60 + i * 18, 6)); + + i++; + } + } + + @Override + public List getIngredients() { + return getCycledIngredients(cycleticks / 20, inputs); + } + + @Override + public PositionedStack getResult() { + return output; + } + + } + + @Override + public String getRecipeName() { + return StatCollector.translateToLocal("botania.nei.elvenTrade"); + } + + @Override + public String getGuiTexture() { + return LibResources.GUI_NEI_BLANK; + } + + @Override + public void loadTransferRects() { + transferRects.add(new RecipeTransferRect(new Rectangle(35, 30, 48, 48), "botania.elvenTrade")); + } + + @Override + public int recipiesPerPage() { + return 1; + } + + @Override + public void drawBackground(int recipe) { + super.drawBackground(recipe); + GL11.glEnable(GL11.GL_BLEND); + GL11.glColor4f(1.0F, 1.0F, 1.0F, 0.7F); + GuiDraw.changeTexture(LibResources.GUI_ELVEN_TRADE_OVERLAY); + GuiDraw.drawTexturedModalRect(30, 10, 17, 17, 100, 80); + GL11.glDisable(GL11.GL_BLEND); + GuiDraw.changeTexture(TextureMap.locationBlocksTexture); + RenderItem.getInstance().renderIcon(35, 29, BlockAlfPortal.portalTex, 48, 48); + } + + private static boolean hasElvenKnowledge() { + /*EntityPlayer player = Minecraft.getMinecraft().thePlayer; + if (player != null) { + for (ItemStack stack : player.inventory.mainInventory) { + if (stack != null && stack.getItem() instanceof ILexicon) { + ILexicon lexicon = (ILexicon) stack.getItem(); + if (lexicon.isKnowledgeUnlocked(stack, BotaniaAPI.elvenKnowledge)) { + return true; + } + } + } + } + return false;*/ + return true; + } + + @Override + public void loadCraftingRecipes(String outputId, Object... results) { + if(outputId.equals("botania.elvenTrade") && hasElvenKnowledge()) { + if(hasElvenKnowledge()) { + for(RecipeElvenTrade recipe : filteredElvenTradeRecipes()) { + arecipes.add(new CachedElvenTradeRecipe(recipe)); + } + } + } else super.loadCraftingRecipes(outputId, results); + } + + @Override + public void loadCraftingRecipes(ItemStack result) { + if(hasElvenKnowledge()) { + for(RecipeElvenTrade recipe : filteredElvenTradeRecipes()) { + if(ItemNBTHelper.areStacksSameTypeCraftingWithNBT(recipe.getOutput(), result)) + arecipes.add(new CachedElvenTradeRecipe(recipe)); + } + } + } + + @Override + public void loadUsageRecipes(ItemStack ingredient) { + if(hasElvenKnowledge()) { + for(RecipeElvenTrade recipe : filteredElvenTradeRecipes()) { + CachedElvenTradeRecipe crecipe = new CachedElvenTradeRecipe(recipe); + if(ItemNBTHelper.cachedRecipeContainsWithNBT(crecipe.inputs, ingredient)) + arecipes.add(crecipe); + } + } + } + + // hide dummy recipes + private List filteredElvenTradeRecipes() { + return BotaniaAPI.elvenTradeRecipes + .stream() + .filter(recipe -> { + if (recipe == null) { + return false; + } + if (recipe.getInputs().size() == 1) { + return !stackSame(recipe.getOutput(), recipe.getInputs().get(0)); + } + return true; + }) + .collect(Collectors.toList()); + } + + private boolean stackSame(ItemStack stack, Object obj) { + if (obj instanceof String) { + return OreDictionary.getOres((String) obj).stream().anyMatch(s -> ItemNBTHelper.areStacksSameTypeCraftingWithNBT(stack, s)); + } else { + return Arrays.stream(NEIServerUtils.extractRecipeItems(obj)).anyMatch(s -> ItemNBTHelper.areStacksSameTypeCraftingWithNBT(stack, s)); + } + } + } diff --git a/src/main/java/vazkii/botania/client/integration/nei/recipe/RecipeHandlerFloatingFlowers.java b/src/main/java/vazkii/botania/client/integration/nei/recipe/RecipeHandlerFloatingFlowers.java index f1932c8068..d1a1f397a2 100644 --- a/src/main/java/vazkii/botania/client/integration/nei/recipe/RecipeHandlerFloatingFlowers.java +++ b/src/main/java/vazkii/botania/client/integration/nei/recipe/RecipeHandlerFloatingFlowers.java @@ -1,10 +1,9 @@ package vazkii.botania.client.integration.nei.recipe; -import codechicken.nei.PositionedStack; -import codechicken.nei.recipe.TemplateRecipeHandler; import java.awt.Rectangle; import java.util.ArrayList; import java.util.List; + import net.minecraft.block.Block; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; @@ -13,67 +12,70 @@ import vazkii.botania.common.block.BlockFloatingSpecialFlower; import vazkii.botania.common.block.BlockSpecialFlower; import vazkii.botania.common.block.ModBlocks; +import codechicken.nei.PositionedStack; +import codechicken.nei.recipe.TemplateRecipeHandler; public class RecipeHandlerFloatingFlowers extends TemplateRecipeHandler { - public class CachedFloatingFlowerRecipe extends CachedRecipe { - - public List inputs = new ArrayList(); - public PositionedStack output; - - public CachedFloatingFlowerRecipe(ItemStack floatingFlower, ItemStack specialFlower, ItemStack output) { - inputs.add(new PositionedStack(floatingFlower, 25, 6)); - inputs.add(new PositionedStack(specialFlower, 43, 6)); - this.output = new PositionedStack(output, 119, 24); - this.output.setMaxSize(1); - } - - @Override - public List getIngredients() { - return getCycledIngredients(cycleticks / 20, inputs); - } - - @Override - public PositionedStack getResult() { - return output; - } - } - - @Override - public String getRecipeName() { - return StatCollector.translateToLocal("botania.nei.floatingFlowers"); - } - - @Override - public void loadTransferRects() { - transferRects.add(new RecipeTransferRect(new Rectangle(84, 23, 24, 18), "crafting")); - } - - @Override - public String getGuiTexture() { - return "textures/gui/container/crafting_table.png"; - } - - @Override - public void loadCraftingRecipes(ItemStack result) { - if (Block.getBlockFromItem(result.getItem()) instanceof BlockFloatingSpecialFlower) { - ItemStack floatingFlower = new ItemStack(ModBlocks.floatingFlower, 1, OreDictionary.WILDCARD_VALUE); - ItemStack specialFlower = new ItemStack(ModBlocks.specialFlower); - specialFlower.setTagCompound( - (NBTTagCompound) result.getTagCompound().copy()); - - arecipes.add(new CachedFloatingFlowerRecipe(floatingFlower, specialFlower, result.copy())); - } - } - - @Override - public void loadUsageRecipes(ItemStack ingredient) { - if (Block.getBlockFromItem(ingredient.getItem()) instanceof BlockSpecialFlower) { - ItemStack floatingFlower = new ItemStack(ModBlocks.floatingFlower, 1, OreDictionary.WILDCARD_VALUE); - ItemStack result = new ItemStack(ModBlocks.floatingSpecialFlower); - result.setTagCompound((NBTTagCompound) ingredient.getTagCompound().copy()); - - arecipes.add(new CachedFloatingFlowerRecipe(floatingFlower, ingredient.copy(), result)); - } - } + public class CachedFloatingFlowerRecipe extends CachedRecipe { + + public List inputs = new ArrayList(); + public PositionedStack output; + + public CachedFloatingFlowerRecipe(ItemStack floatingFlower, ItemStack specialFlower, ItemStack output) { + inputs.add(new PositionedStack(floatingFlower, 25, 6)); + inputs.add(new PositionedStack(specialFlower, 43, 6)); + this.output = new PositionedStack(output, 119, 24); + this.output.setMaxSize(1); + } + + @Override + public List getIngredients() { + return getCycledIngredients(cycleticks / 20, inputs); + } + + @Override + public PositionedStack getResult() { + return output; + } + + } + + @Override + public String getRecipeName() { + return StatCollector.translateToLocal("botania.nei.floatingFlowers"); + } + + @Override + public void loadTransferRects() { + transferRects.add(new RecipeTransferRect(new Rectangle(84, 23, 24, 18), "crafting")); + } + + @Override + public String getGuiTexture() { + return "textures/gui/container/crafting_table.png"; + } + + @Override + public void loadCraftingRecipes(ItemStack result) { + if(Block.getBlockFromItem(result.getItem()) instanceof BlockFloatingSpecialFlower) { + ItemStack floatingFlower = new ItemStack(ModBlocks.floatingFlower, 1, OreDictionary.WILDCARD_VALUE); + ItemStack specialFlower = new ItemStack(ModBlocks.specialFlower); + specialFlower.setTagCompound((NBTTagCompound) result.getTagCompound().copy()); + + arecipes.add(new CachedFloatingFlowerRecipe(floatingFlower, specialFlower, result.copy())); + } + } + + @Override + public void loadUsageRecipes(ItemStack ingredient) { + if(Block.getBlockFromItem(ingredient.getItem()) instanceof BlockSpecialFlower) { + ItemStack floatingFlower = new ItemStack(ModBlocks.floatingFlower, 1, OreDictionary.WILDCARD_VALUE); + ItemStack result = new ItemStack(ModBlocks.floatingSpecialFlower); + result.setTagCompound((NBTTagCompound) ingredient.getTagCompound().copy()); + + arecipes.add(new CachedFloatingFlowerRecipe(floatingFlower, ingredient.copy(), result)); + } + } + } diff --git a/src/main/java/vazkii/botania/client/integration/nei/recipe/RecipeHandlerLexicaBotania.java b/src/main/java/vazkii/botania/client/integration/nei/recipe/RecipeHandlerLexicaBotania.java index fa544e55a7..ea1933074e 100644 --- a/src/main/java/vazkii/botania/client/integration/nei/recipe/RecipeHandlerLexicaBotania.java +++ b/src/main/java/vazkii/botania/client/integration/nei/recipe/RecipeHandlerLexicaBotania.java @@ -2,150 +2,170 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [12/12/2015, 23:25:47 (GMT)] */ package vazkii.botania.client.integration.nei.recipe; -import codechicken.nei.PositionedStack; -import codechicken.nei.recipe.TemplateRecipeHandler; -import codechicken.nei.recipe.TemplateRecipeHandler.CachedRecipe; -import codechicken.nei.recipe.TemplateRecipeHandler.RecipeTransferRect; import java.awt.Rectangle; import java.util.ArrayList; import java.util.Collection; import java.util.List; + import net.minecraft.client.Minecraft; import net.minecraft.client.gui.FontRenderer; import net.minecraft.client.gui.GuiScreen; +import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.util.EnumChatFormatting; import net.minecraft.util.StatCollector; +import net.minecraftforge.oredict.OreDictionary; + +import org.lwjgl.opengl.GL11; + import vazkii.botania.api.BotaniaAPI; import vazkii.botania.api.lexicon.KnowledgeType; import vazkii.botania.api.lexicon.LexiconEntry; import vazkii.botania.api.lexicon.LexiconRecipeMappings; +import vazkii.botania.api.recipe.RecipeManaInfusion; +import vazkii.botania.client.core.handler.HUDHandler; +import vazkii.botania.client.integration.nei.recipe.RecipeHandlerManaPool.CachedManaPoolRecipe; import vazkii.botania.client.lib.LibResources; +import vazkii.botania.client.render.tile.RenderTilePool; +import vazkii.botania.common.block.ModBlocks; +import vazkii.botania.common.block.tile.mana.TilePool; +import vazkii.botania.common.core.helper.InventoryHelper; import vazkii.botania.common.item.ModItems; +import vazkii.botania.common.lexicon.LexiconData; +import vazkii.botania.common.lexicon.page.PageRecipe; import vazkii.botania.common.lexicon.page.PageText; +import codechicken.lib.gui.GuiDraw; +import codechicken.nei.NEIServerUtils; +import codechicken.nei.PositionedStack; +import codechicken.nei.recipe.TemplateRecipeHandler; +import codechicken.nei.recipe.TemplateRecipeHandler.CachedRecipe; +import codechicken.nei.recipe.TemplateRecipeHandler.RecipeTransferRect; public class RecipeHandlerLexicaBotania extends TemplateRecipeHandler { - public class CachedLexicaBotaniaRecipe extends CachedRecipe { - - public LexiconEntry entry; - public PositionedStack item; - public List otherStacks = new ArrayList(); - - public CachedLexicaBotaniaRecipe(ItemStack stack, LexiconEntry entry) { - otherStacks.add(new PositionedStack(new ItemStack(ModItems.lexicon), 51, 5)); - item = new PositionedStack(stack, 91, 5); - this.entry = entry; - } - - @Override - public List getIngredients() { - return otherStacks; - } - - @Override - public PositionedStack getResult() { - return item; - } - - @Override - public List getOtherStacks() { - return otherStacks; - } - - @Override - public boolean contains(Collection ingredients, ItemStack ingredient) { - return ingredient.getItem() == ModItems.lexicon; - } - } - - @Override - public String getRecipeName() { - return StatCollector.translateToLocal("botania.nei.lexica"); - } - - @Override - public String getGuiTexture() { - return LibResources.GUI_NEI_BLANK; - } - - @Override - public int recipiesPerPage() { - return 1; - } - - @Override - public void loadTransferRects() { - transferRects.add(new RecipeTransferRect(new Rectangle(50, 4, 18, 18), "botania.lexica")); - } - - @Override - public void drawBackground(int recipe) { - super.drawBackground(recipe); - - FontRenderer font = Minecraft.getMinecraft().fontRenderer; - CachedLexicaBotaniaRecipe recipeObj = ((CachedLexicaBotaniaRecipe) arecipes.get(recipe)); - - String s = EnumChatFormatting.UNDERLINE + StatCollector.translateToLocal(recipeObj.entry.getUnlocalizedName()); - font.drawString(s, 82 - font.getStringWidth(s) / 2, 30, 4210752); - - KnowledgeType type = recipeObj.entry.getKnowledgeType(); - s = type.color - + StatCollector.translateToLocal(type.getUnlocalizedName()).replaceAll("\\&.", ""); - font.drawString(s, 82 - font.getStringWidth(s) / 2, 42, 4210752); - - s = "\"" + StatCollector.translateToLocal(recipeObj.entry.getTagline()) + "\""; - PageText.renderText(5, 42, 160, 200, s); - - String key = LexiconRecipeMappings.stackToString(recipeObj.item.item); - String quickInfo = "botania.nei.quickInfo:" + key; - String quickInfoLocal = StatCollector.translateToLocal(quickInfo); - - if (GuiScreen.isShiftKeyDown() - && GuiScreen.isCtrlKeyDown() - && Minecraft.getMinecraft().gameSettings.advancedItemTooltips) s = "name: " + key; - else if (quickInfo.equals(quickInfoLocal)) s = StatCollector.translateToLocal("botania.nei.lexicaNoInfo"); - else { - s = StatCollector.translateToLocal("botania.nei.lexicaSeparator"); - font.drawString(s, 82 - font.getStringWidth(s) / 2, 80, 4210752); - s = quickInfoLocal; - } - - PageText.renderText(5, 80, 160, 200, s); - } - - @Override - public void loadCraftingRecipes(String outputId, Object... results) { - if (outputId.equals("botania.lexica")) { - for (LexiconEntry entry : BotaniaAPI.getAllEntries()) { - List stacks = entry.getDisplayedRecipes(); - for (ItemStack stack : stacks) arecipes.add(new CachedLexicaBotaniaRecipe(stack, entry)); - } - } else super.loadCraftingRecipes(outputId, results); - } - - @Override - public void loadCraftingRecipes(ItemStack result) { - for (LexiconEntry entry : BotaniaAPI.getAllEntries()) { - List stacks = entry.getDisplayedRecipes(); - for (ItemStack stack : stacks) { - String key1 = LexiconRecipeMappings.stackToString(stack); - String key2 = LexiconRecipeMappings.stackToString(result); - if (key1.equals(key2)) arecipes.add(new CachedLexicaBotaniaRecipe(stack, entry)); - } - } - } - - @Override - public void loadUsageRecipes(ItemStack ingredient) { - // NO-OP - } + public class CachedLexicaBotaniaRecipe extends CachedRecipe { + + public LexiconEntry entry; + public PositionedStack item; + public List otherStacks = new ArrayList(); + + public CachedLexicaBotaniaRecipe(ItemStack stack, LexiconEntry entry) { + otherStacks.add(new PositionedStack(new ItemStack(ModItems.lexicon), 51, 5)); + item = new PositionedStack(stack, 91, 5); + this.entry = entry; + } + + @Override + public List getIngredients() { + return otherStacks; + } + + @Override + public PositionedStack getResult() { + return item; + } + + @Override + public List getOtherStacks() { + return otherStacks; + } + + @Override + public boolean contains(Collection ingredients, ItemStack ingredient) { + return ingredient.getItem() == ModItems.lexicon; + } + + } + + @Override + public String getRecipeName() { + return StatCollector.translateToLocal("botania.nei.lexica"); + } + + @Override + public String getGuiTexture() { + return LibResources.GUI_NEI_BLANK; + } + + @Override + public int recipiesPerPage() { + return 1; + } + + @Override + public void loadTransferRects() { + transferRects.add(new RecipeTransferRect(new Rectangle(50, 4, 18, 18), "botania.lexica")); + } + + @Override + public void drawBackground(int recipe) { + super.drawBackground(recipe); + + FontRenderer font = Minecraft.getMinecraft().fontRenderer; + CachedLexicaBotaniaRecipe recipeObj = ((CachedLexicaBotaniaRecipe) arecipes.get(recipe)); + + String s = EnumChatFormatting.UNDERLINE + StatCollector.translateToLocal(recipeObj.entry.getUnlocalizedName()); + font.drawString(s, 82 - font.getStringWidth(s) / 2, 30, 4210752); + + KnowledgeType type = recipeObj.entry.getKnowledgeType(); + s = type.color + StatCollector.translateToLocal(type.getUnlocalizedName()).replaceAll("\\&.", ""); + font.drawString(s, 82 - font.getStringWidth(s) / 2, 42, 4210752); + + s = "\"" + StatCollector.translateToLocal(recipeObj.entry.getTagline()) + "\""; + PageText.renderText(5, 42, 160, 200, s); + + String key = LexiconRecipeMappings.stackToString(recipeObj.item.item); + String quickInfo = "botania.nei.quickInfo:" + key; + String quickInfoLocal = StatCollector.translateToLocal(quickInfo); + + if(GuiScreen.isShiftKeyDown() && GuiScreen.isCtrlKeyDown() && Minecraft.getMinecraft().gameSettings.advancedItemTooltips) + s = "name: " + key; + else if(quickInfo.equals(quickInfoLocal)) + s = StatCollector.translateToLocal("botania.nei.lexicaNoInfo"); + else { + s = StatCollector.translateToLocal("botania.nei.lexicaSeparator"); + font.drawString(s, 82 - font.getStringWidth(s) / 2, 80, 4210752); + s = quickInfoLocal; + } + + PageText.renderText(5, 80, 160, 200, s); + } + + @Override + public void loadCraftingRecipes(String outputId, Object... results) { + if(outputId.equals("botania.lexica")) { + for(LexiconEntry entry : BotaniaAPI.getAllEntries()) { + List stacks = entry.getDisplayedRecipes(); + for(ItemStack stack : stacks) + arecipes.add(new CachedLexicaBotaniaRecipe(stack, entry)); + } + } else super.loadCraftingRecipes(outputId, results); + } + + @Override + public void loadCraftingRecipes(ItemStack result) { + for(LexiconEntry entry : BotaniaAPI.getAllEntries()) { + List stacks = entry.getDisplayedRecipes(); + for(ItemStack stack : stacks) { + String key1 = LexiconRecipeMappings.stackToString(stack); + String key2 = LexiconRecipeMappings.stackToString(result); + if(key1.equals(key2)) + arecipes.add(new CachedLexicaBotaniaRecipe(stack, entry)); + } + } + } + + @Override + public void loadUsageRecipes(ItemStack ingredient) { + // NO-OP + } + } diff --git a/src/main/java/vazkii/botania/client/integration/nei/recipe/RecipeHandlerManaPool.java b/src/main/java/vazkii/botania/client/integration/nei/recipe/RecipeHandlerManaPool.java index c4a115ccab..3548d41266 100644 --- a/src/main/java/vazkii/botania/client/integration/nei/recipe/RecipeHandlerManaPool.java +++ b/src/main/java/vazkii/botania/client/integration/nei/recipe/RecipeHandlerManaPool.java @@ -1,16 +1,17 @@ package vazkii.botania.client.integration.nei.recipe; -import codechicken.lib.gui.GuiDraw; -import codechicken.nei.PositionedStack; -import codechicken.nei.recipe.TemplateRecipeHandler; import java.awt.Rectangle; import java.util.ArrayList; +import java.util.Collection; import java.util.List; + import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.util.StatCollector; import net.minecraftforge.oredict.OreDictionary; + import org.lwjgl.opengl.GL11; + import vazkii.botania.api.BotaniaAPI; import vazkii.botania.api.recipe.RecipeManaInfusion; import vazkii.botania.client.core.handler.HUDHandler; @@ -18,118 +19,120 @@ import vazkii.botania.client.render.tile.RenderTilePool; import vazkii.botania.common.block.ModBlocks; import vazkii.botania.common.block.tile.mana.TilePool; +import codechicken.lib.gui.GuiDraw; +import codechicken.nei.NEIServerUtils; +import codechicken.nei.PositionedStack; +import codechicken.nei.recipe.TemplateRecipeHandler; import vazkii.botania.common.core.helper.ItemNBTHelper; public class RecipeHandlerManaPool extends TemplateRecipeHandler { - public class CachedManaPoolRecipe extends CachedRecipe { - - public List inputs = new ArrayList(); - public PositionedStack output; - public List otherStacks = new ArrayList(); - public int mana; - - public CachedManaPoolRecipe(RecipeManaInfusion recipe) { - if (recipe == null) return; - inputs.add(new PositionedStack( - new ItemStack( - ModBlocks.pool, - 1, - recipe.getOutput().getItem() == Item.getItemFromBlock(ModBlocks.pool) ? 2 : 0), - 71, - 37)); - - if (recipe.getInput() instanceof String) - inputs.add(new PositionedStack(OreDictionary.getOres((String) recipe.getInput()), 42, 37)); - else inputs.add(new PositionedStack(recipe.getInput(), 42, 37)); - - if (recipe.isAlchemy()) - otherStacks.add(new PositionedStack(new ItemStack(ModBlocks.alchemyCatalyst), 10, 37)); - else if (recipe.isConjuration()) - otherStacks.add(new PositionedStack(new ItemStack(ModBlocks.conjurationCatalyst), 10, 37)); - - output = new PositionedStack(recipe.getOutput(), 101, 37); - mana = recipe.getManaToConsume(); - } - - @Override - public List getIngredients() { - return getCycledIngredients(cycleticks / 20, inputs); - } - - @Override - public PositionedStack getResult() { - return output; - } - - @Override - public List getOtherStacks() { - return otherStacks; - } - } - - @Override - public String getRecipeName() { - return StatCollector.translateToLocal("botania.nei.manaPool"); - } - - @Override - public String getGuiTexture() { - return LibResources.GUI_NEI_BLANK; - } - - @Override - public int recipiesPerPage() { - return 1; - } - - @Override - public void loadTransferRects() { - transferRects.add(new RecipeTransferRect(new Rectangle(70, 36, 18, 18), "botania.manaPool")); - } - - @Override - public void drawBackground(int recipe) { - super.drawBackground(recipe); - GL11.glEnable(GL11.GL_BLEND); - GL11.glColor4f(1.0F, 1.0F, 1.0F, 0.5F); - GuiDraw.changeTexture(LibResources.GUI_MANA_INFUSION_OVERLAY); - GuiDraw.drawTexturedModalRect(45, 20, 38, 35, 92, 50); - HUDHandler.renderManaBar( - 32, 80, 0x0000FF, 0.75F, ((CachedManaPoolRecipe) arecipes.get(recipe)).mana, TilePool.MAX_MANA / 10); - RenderTilePool.forceMana = true; - } - - @Override - public void loadCraftingRecipes(String outputId, Object... results) { - if (outputId.equals("botania.manaPool")) { - for (RecipeManaInfusion recipe : BotaniaAPI.manaInfusionRecipes) { - if (recipe == null) continue; - - arecipes.add(new CachedManaPoolRecipe(recipe)); - } - } else super.loadCraftingRecipes(outputId, results); - } - - @Override - public void loadCraftingRecipes(ItemStack result) { - for (RecipeManaInfusion recipe : BotaniaAPI.manaInfusionRecipes) { - if (recipe == null) continue; - - if (ItemNBTHelper.areStacksSameTypeCraftingWithNBT(recipe.getOutput(), result)) - arecipes.add(new CachedManaPoolRecipe(recipe)); - } - } - - @Override - public void loadUsageRecipes(ItemStack ingredient) { - for (RecipeManaInfusion recipe : BotaniaAPI.manaInfusionRecipes) { - if (recipe == null) continue; - - CachedManaPoolRecipe crecipe = new CachedManaPoolRecipe(recipe); - if (ItemNBTHelper.cachedRecipeContainsWithNBT(crecipe.getIngredients(), ingredient) - || ItemNBTHelper.cachedRecipeContainsWithNBT(crecipe.getOtherStacks(), ingredient)) - arecipes.add(crecipe); - } - } + public class CachedManaPoolRecipe extends CachedRecipe { + + public List inputs = new ArrayList(); + public PositionedStack output; + public List otherStacks = new ArrayList(); + public int mana; + + public CachedManaPoolRecipe(RecipeManaInfusion recipe) { + if(recipe == null) + return; + inputs.add(new PositionedStack(new ItemStack(ModBlocks.pool, 1, recipe.getOutput().getItem() == Item.getItemFromBlock(ModBlocks.pool) ? 2 : 0), 71, 37)); + + if(recipe.getInput() instanceof String) + inputs.add(new PositionedStack(OreDictionary.getOres((String) recipe.getInput()), 42, 37)); + else inputs.add(new PositionedStack(recipe.getInput(), 42, 37)); + + if(recipe.isAlchemy()) + otherStacks.add(new PositionedStack(new ItemStack(ModBlocks.alchemyCatalyst), 10, 37)); + else if (recipe.isConjuration()) + otherStacks.add(new PositionedStack(new ItemStack(ModBlocks.conjurationCatalyst), 10, 37)); + + output = new PositionedStack(recipe.getOutput(), 101, 37); + mana = recipe.getManaToConsume(); + } + + @Override + public List getIngredients() { + return getCycledIngredients(cycleticks / 20, inputs); + } + + @Override + public PositionedStack getResult() { + return output; + } + + @Override + public List getOtherStacks() { + return otherStacks; + } + + } + + @Override + public String getRecipeName() { + return StatCollector.translateToLocal("botania.nei.manaPool"); + } + + @Override + public String getGuiTexture() { + return LibResources.GUI_NEI_BLANK; + } + + @Override + public int recipiesPerPage() { + return 1; + } + + @Override + public void loadTransferRects() { + transferRects.add(new RecipeTransferRect(new Rectangle(70, 36, 18, 18), "botania.manaPool")); + } + + @Override + public void drawBackground(int recipe) { + super.drawBackground(recipe); + GL11.glEnable(GL11.GL_BLEND); + GL11.glColor4f(1.0F, 1.0F, 1.0F, 0.5F); + GuiDraw.changeTexture(LibResources.GUI_MANA_INFUSION_OVERLAY); + GuiDraw.drawTexturedModalRect(45, 20, 38, 35, 92, 50); + HUDHandler.renderManaBar(32, 80, 0x0000FF, 0.75F, ((CachedManaPoolRecipe) arecipes.get(recipe)).mana, TilePool.MAX_MANA / 10); + RenderTilePool.forceMana = true; + } + + @Override + public void loadCraftingRecipes(String outputId, Object... results) { + if(outputId.equals("botania.manaPool")) { + for(RecipeManaInfusion recipe : BotaniaAPI.manaInfusionRecipes) { + if(recipe == null) + continue; + + arecipes.add(new CachedManaPoolRecipe(recipe)); + } + } else super.loadCraftingRecipes(outputId, results); + } + + @Override + public void loadCraftingRecipes(ItemStack result) { + for(RecipeManaInfusion recipe : BotaniaAPI.manaInfusionRecipes) { + if(recipe == null) + continue; + + if(ItemNBTHelper.areStacksSameTypeCraftingWithNBT(recipe.getOutput(), result)) + arecipes.add(new CachedManaPoolRecipe(recipe)); + } + } + + @Override + public void loadUsageRecipes(ItemStack ingredient) { + for(RecipeManaInfusion recipe : BotaniaAPI.manaInfusionRecipes) { + if(recipe == null) + continue; + + CachedManaPoolRecipe crecipe = new CachedManaPoolRecipe(recipe); + if(ItemNBTHelper.cachedRecipeContainsWithNBT(crecipe.getIngredients(), ingredient) || ItemNBTHelper.cachedRecipeContainsWithNBT(crecipe.getOtherStacks(), ingredient)) + arecipes.add(crecipe); + } + } + } diff --git a/src/main/java/vazkii/botania/client/integration/nei/recipe/RecipeHandlerPetalApothecary.java b/src/main/java/vazkii/botania/client/integration/nei/recipe/RecipeHandlerPetalApothecary.java index dd49c58e83..f085bfb575 100644 --- a/src/main/java/vazkii/botania/client/integration/nei/recipe/RecipeHandlerPetalApothecary.java +++ b/src/main/java/vazkii/botania/client/integration/nei/recipe/RecipeHandlerPetalApothecary.java @@ -1,136 +1,143 @@ package vazkii.botania.client.integration.nei.recipe; -import codechicken.lib.gui.GuiDraw; -import codechicken.nei.NEIServerUtils; -import codechicken.nei.PositionedStack; -import codechicken.nei.recipe.TemplateRecipeHandler; import java.awt.Rectangle; import java.util.ArrayList; import java.util.List; + import net.minecraft.init.Items; import net.minecraft.item.ItemStack; import net.minecraft.util.StatCollector; import net.minecraftforge.oredict.OreDictionary; + import org.lwjgl.opengl.GL11; + import vazkii.botania.api.BotaniaAPI; import vazkii.botania.api.recipe.RecipePetals; import vazkii.botania.client.lib.LibResources; import vazkii.botania.common.block.ModBlocks; +import codechicken.lib.gui.GuiDraw; +import codechicken.nei.NEIServerUtils; +import codechicken.nei.PositionedStack; +import codechicken.nei.recipe.TemplateRecipeHandler; import vazkii.botania.common.core.helper.ItemNBTHelper; public class RecipeHandlerPetalApothecary extends TemplateRecipeHandler { - public class CachedPetalApothecaryRecipe extends CachedRecipe { - - public List inputs = new ArrayList(); - public PositionedStack output; - - public CachedPetalApothecaryRecipe(RecipePetals recipe, boolean addCenterItem) { - setIngredients(recipe.getInputs()); - output = new PositionedStack(recipe.getOutput(), 111, 21); - if (addCenterItem) inputs.add(new PositionedStack(new ItemStack(ModBlocks.altar), 73, 55)); - } - - public CachedPetalApothecaryRecipe(RecipePetals recipe) { - this(recipe, true); - } - - public void setIngredients(List inputs) { - float degreePerInput = 360F / inputs.size(); - float currentDegree = -90F; - - for (Object o : inputs) { - int posX = (int) Math.round(73 + Math.cos(currentDegree * Math.PI / 180D) * 32); - int posY = (int) Math.round(55 + Math.sin(currentDegree * Math.PI / 180D) * 32); - - if (o instanceof String) - this.inputs.add(new PositionedStack(OreDictionary.getOres((String) o), posX, posY)); - else this.inputs.add(new PositionedStack(o, posX, posY)); - currentDegree += degreePerInput; - } - } - - @Override - public List getIngredients() { - return getCycledIngredients(cycleticks / 20, inputs); - } - - @Override - public PositionedStack getResult() { - return output; - } - } - - @Override - public String getRecipeName() { - return StatCollector.translateToLocal("botania.nei.petalApothecary"); - } - - public String getRecipeID() { - return "botania.petalApothecary"; - } - - @Override - public String getGuiTexture() { - return LibResources.GUI_NEI_BLANK; - } - - @Override - public void loadTransferRects() { - transferRects.add(new RecipeTransferRect(new Rectangle(72, 54, 18, 18), getRecipeID())); - } - - @Override - public int recipiesPerPage() { - return 1; - } - - @Override - public void drawBackground(int recipe) { - super.drawBackground(recipe); - GL11.glEnable(GL11.GL_BLEND); - GL11.glColor4f(1.0F, 1.0F, 1.0F, 0.5F); - GuiDraw.changeTexture(LibResources.GUI_PETAL_OVERLAY); - GuiDraw.drawTexturedModalRect(45, 10, 38, 7, 92, 92); - } - - public List getRecipes() { - return BotaniaAPI.petalRecipes; - } - - public CachedPetalApothecaryRecipe getCachedRecipe(RecipePetals recipe) { - return new CachedPetalApothecaryRecipe(recipe); - } - - @Override - public void loadCraftingRecipes(String outputId, Object... results) { - if (outputId.equals(getRecipeID())) { - for (RecipePetals recipe : getRecipes()) - if (recipe.getOutput().getItem() != Items.skull) arecipes.add(getCachedRecipe(recipe)); - } else super.loadCraftingRecipes(outputId, results); - } - - @Override - public void loadCraftingRecipes(ItemStack result) { - for (RecipePetals recipe : getRecipes()) { - if (recipe == null) continue; - - if (recipe.getOutput().stackTagCompound != null - && ItemNBTHelper.areStacksSameTypeWithNBT(recipe.getOutput(), result) - || recipe.getOutput().stackTagCompound == null - && NEIServerUtils.areStacksSameTypeCrafting(recipe.getOutput(), result) - && recipe.getOutput().getItem() != Items.skull) arecipes.add(getCachedRecipe(recipe)); - } - } - - @Override - public void loadUsageRecipes(ItemStack ingredient) { - for (RecipePetals recipe : getRecipes()) { - if (recipe == null) continue; - - CachedPetalApothecaryRecipe crecipe = getCachedRecipe(recipe); - if (ItemNBTHelper.cachedRecipeContainsWithNBT(crecipe.inputs, ingredient) - && recipe.getOutput().getItem() != Items.skull) arecipes.add(crecipe); - } - } + public class CachedPetalApothecaryRecipe extends CachedRecipe { + + public List inputs = new ArrayList(); + public PositionedStack output; + + public CachedPetalApothecaryRecipe(RecipePetals recipe, boolean addCenterItem) { + setIngredients(recipe.getInputs()); + output = new PositionedStack(recipe.getOutput(), 111, 21); + if(addCenterItem) + inputs.add(new PositionedStack(new ItemStack(ModBlocks.altar), 73, 55)); + } + + public CachedPetalApothecaryRecipe(RecipePetals recipe) { + this(recipe, true); + } + + public void setIngredients(List inputs) { + float degreePerInput = 360F / inputs.size(); + float currentDegree = -90F; + + for(Object o : inputs) { + int posX = (int) Math.round(73 + Math.cos(currentDegree * Math.PI / 180D) * 32); + int posY = (int) Math.round(55 + Math.sin(currentDegree * Math.PI / 180D) * 32); + + if(o instanceof String) + this.inputs.add(new PositionedStack(OreDictionary.getOres((String) o), posX, posY)); + else this.inputs.add(new PositionedStack(o, posX, posY)); + currentDegree += degreePerInput; + } + } + + @Override + public List getIngredients() { + return getCycledIngredients(cycleticks / 20, inputs); + } + + @Override + public PositionedStack getResult() { + return output; + } + + } + + @Override + public String getRecipeName() { + return StatCollector.translateToLocal("botania.nei.petalApothecary"); + } + + public String getRecipeID() { + return "botania.petalApothecary"; + } + + @Override + public String getGuiTexture() { + return LibResources.GUI_NEI_BLANK; + } + + @Override + public void loadTransferRects() { + transferRects.add(new RecipeTransferRect(new Rectangle(72, 54, 18, 18), getRecipeID())); + } + + @Override + public int recipiesPerPage() { + return 1; + } + + @Override + public void drawBackground(int recipe) { + super.drawBackground(recipe); + GL11.glEnable(GL11.GL_BLEND); + GL11.glColor4f(1.0F, 1.0F, 1.0F, 0.5F); + GuiDraw.changeTexture(LibResources.GUI_PETAL_OVERLAY); + GuiDraw.drawTexturedModalRect(45, 10, 38, 7, 92, 92); + } + + public List getRecipes() { + return BotaniaAPI.petalRecipes; + } + + public CachedPetalApothecaryRecipe getCachedRecipe(RecipePetals recipe) { + return new CachedPetalApothecaryRecipe(recipe); + } + + @Override + public void loadCraftingRecipes(String outputId, Object... results) { + if(outputId.equals(getRecipeID())) { + for(RecipePetals recipe : getRecipes()) + if(recipe.getOutput().getItem() != Items.skull) + arecipes.add(getCachedRecipe(recipe)); + } else super.loadCraftingRecipes(outputId, results); + } + + @Override + public void loadCraftingRecipes(ItemStack result) { + for(RecipePetals recipe : getRecipes()){ + if(recipe == null) + continue; + + if(recipe.getOutput().stackTagCompound != null && ItemNBTHelper.areStacksSameTypeWithNBT(recipe.getOutput(), result) || recipe.getOutput().stackTagCompound == null && NEIServerUtils.areStacksSameTypeCrafting(recipe.getOutput(), result) && recipe.getOutput().getItem() != Items.skull) + arecipes.add(getCachedRecipe(recipe)); + } + } + + @Override + public void loadUsageRecipes(ItemStack ingredient) { + for(RecipePetals recipe : getRecipes()) { + if(recipe == null) + continue; + + CachedPetalApothecaryRecipe crecipe = getCachedRecipe(recipe); + if(ItemNBTHelper.cachedRecipeContainsWithNBT(crecipe.inputs, ingredient) && recipe.getOutput().getItem() != Items.skull) + arecipes.add(crecipe); + } + } + + } diff --git a/src/main/java/vazkii/botania/client/integration/nei/recipe/RecipeHandlerPureDaisy.java b/src/main/java/vazkii/botania/client/integration/nei/recipe/RecipeHandlerPureDaisy.java index 61017d108a..a4a49890ac 100644 --- a/src/main/java/vazkii/botania/client/integration/nei/recipe/RecipeHandlerPureDaisy.java +++ b/src/main/java/vazkii/botania/client/integration/nei/recipe/RecipeHandlerPureDaisy.java @@ -1,117 +1,127 @@ package vazkii.botania.client.integration.nei.recipe; -import codechicken.lib.gui.GuiDraw; -import codechicken.nei.PositionedStack; -import codechicken.nei.recipe.TemplateRecipeHandler; import java.awt.Rectangle; import java.util.ArrayList; +import java.util.Collection; import java.util.List; + import net.minecraft.block.Block; import net.minecraft.item.ItemStack; import net.minecraft.util.StatCollector; import net.minecraftforge.oredict.OreDictionary; + import org.lwjgl.opengl.GL11; + import vazkii.botania.api.BotaniaAPI; import vazkii.botania.api.recipe.RecipePureDaisy; import vazkii.botania.client.lib.LibResources; import vazkii.botania.common.core.helper.ItemNBTHelper; import vazkii.botania.common.item.block.ItemBlockSpecialFlower; import vazkii.botania.common.lib.LibBlockNames; +import codechicken.lib.gui.GuiDraw; +import codechicken.nei.NEIServerUtils; +import codechicken.nei.PositionedStack; +import codechicken.nei.recipe.TemplateRecipeHandler; public class RecipeHandlerPureDaisy extends TemplateRecipeHandler { - public class CachedPureDaisyRecipe extends CachedRecipe { - - public List inputs = new ArrayList(); - public PositionedStack output; - public List otherStacks = new ArrayList(); - - public CachedPureDaisyRecipe(RecipePureDaisy recipe) { - if (recipe == null) return; - inputs.add(new PositionedStack(ItemBlockSpecialFlower.ofType(LibBlockNames.SUBTILE_PUREDAISY), 71, 23)); - - if (recipe.getInput() instanceof String) - inputs.add(new PositionedStack(OreDictionary.getOres((String) recipe.getInput()), 42, 23)); - else inputs.add(new PositionedStack(new ItemStack((Block) recipe.getInput()), 42, 23)); - - output = new PositionedStack(new ItemStack(recipe.getOutput()), 101, 23); - } - - @Override - public List getIngredients() { - return getCycledIngredients(cycleticks / 20, inputs); - } - - @Override - public PositionedStack getResult() { - return output; - } - - @Override - public List getOtherStacks() { - return otherStacks; - } - } - - @Override - public String getRecipeName() { - return StatCollector.translateToLocal("botania.nei.pureDaisy"); - } - - @Override - public String getGuiTexture() { - return LibResources.GUI_NEI_BLANK; - } - - @Override - public int recipiesPerPage() { - return 2; - } - - @Override - public void loadTransferRects() { - transferRects.add(new RecipeTransferRect(new Rectangle(70, 22, 18, 18), "botania.pureDaisy")); - } - - @Override - public void drawBackground(int recipe) { - super.drawBackground(recipe); - GL11.glEnable(GL11.GL_BLEND); - GL11.glColor4f(1.0F, 1.0F, 1.0F, 0.5F); - GuiDraw.changeTexture(LibResources.GUI_PURE_DAISY_OVERLAY); - GuiDraw.drawTexturedModalRect(45, 10, 0, 0, 65, 44); - } - - @Override - public void loadCraftingRecipes(String outputId, Object... results) { - if (outputId.equals("botania.pureDaisy")) { - for (RecipePureDaisy recipe : BotaniaAPI.pureDaisyRecipes) { - if (recipe == null) continue; - - arecipes.add(new CachedPureDaisyRecipe(recipe)); - } - } else super.loadCraftingRecipes(outputId, results); - } - - @Override - public void loadCraftingRecipes(ItemStack result) { - for (RecipePureDaisy recipe : BotaniaAPI.pureDaisyRecipes) { - if (recipe == null) continue; - - if (ItemNBTHelper.areStacksSameTypeCraftingWithNBT(new ItemStack(recipe.getOutput()), result)) - arecipes.add(new CachedPureDaisyRecipe(recipe)); - } - } - - @Override - public void loadUsageRecipes(ItemStack ingredient) { - for (RecipePureDaisy recipe : BotaniaAPI.pureDaisyRecipes) { - if (recipe == null) continue; - - CachedPureDaisyRecipe crecipe = new CachedPureDaisyRecipe(recipe); - if (ItemNBTHelper.cachedRecipeContainsWithNBT(crecipe.getIngredients(), ingredient) - || ItemNBTHelper.cachedRecipeContainsWithNBT(crecipe.getOtherStacks(), ingredient)) - arecipes.add(crecipe); - } - } + public class CachedPureDaisyRecipe extends CachedRecipe { + + public List inputs = new ArrayList(); + public PositionedStack output; + public List otherStacks = new ArrayList(); + + public CachedPureDaisyRecipe(RecipePureDaisy recipe) { + if(recipe == null) + return; + inputs.add(new PositionedStack(ItemBlockSpecialFlower.ofType(LibBlockNames.SUBTILE_PUREDAISY), 71, 23)); + + if(recipe.getInput() instanceof String) + inputs.add(new PositionedStack(OreDictionary.getOres((String) recipe.getInput()), 42, 23)); + else inputs.add(new PositionedStack(new ItemStack((Block) recipe.getInput()), 42, 23)); + + output = new PositionedStack(new ItemStack(recipe.getOutput()), 101, 23); + } + + @Override + public List getIngredients() { + return getCycledIngredients(cycleticks / 20, inputs); + } + + @Override + public PositionedStack getResult() { + return output; + } + + @Override + public List getOtherStacks() { + return otherStacks; + } + + } + + @Override + public String getRecipeName() { + return StatCollector.translateToLocal("botania.nei.pureDaisy"); + } + + @Override + public String getGuiTexture() { + return LibResources.GUI_NEI_BLANK; + } + + @Override + public int recipiesPerPage() { + return 2; + } + + @Override + public void loadTransferRects() { + transferRects.add(new RecipeTransferRect(new Rectangle(70, 22, 18, 18), "botania.pureDaisy")); + } + + @Override + public void drawBackground(int recipe) { + super.drawBackground(recipe); + GL11.glEnable(GL11.GL_BLEND); + GL11.glColor4f(1.0F, 1.0F, 1.0F, 0.5F); + GuiDraw.changeTexture(LibResources.GUI_PURE_DAISY_OVERLAY); + GuiDraw.drawTexturedModalRect(45, 10, 0, 0, 65, 44); + } + + @Override + public void loadCraftingRecipes(String outputId, Object... results) { + if(outputId.equals("botania.pureDaisy")) { + for(RecipePureDaisy recipe : BotaniaAPI.pureDaisyRecipes) { + if(recipe == null) + continue; + + arecipes.add(new CachedPureDaisyRecipe(recipe)); + } + } else super.loadCraftingRecipes(outputId, results); + } + + @Override + public void loadCraftingRecipes(ItemStack result) { + for(RecipePureDaisy recipe : BotaniaAPI.pureDaisyRecipes) { + if(recipe == null) + continue; + + if(ItemNBTHelper.areStacksSameTypeCraftingWithNBT(new ItemStack(recipe.getOutput()), result)) + arecipes.add(new CachedPureDaisyRecipe(recipe)); + } + } + + @Override + public void loadUsageRecipes(ItemStack ingredient) { + for(RecipePureDaisy recipe : BotaniaAPI.pureDaisyRecipes) { + if(recipe == null) + continue; + + CachedPureDaisyRecipe crecipe = new CachedPureDaisyRecipe(recipe); + if(ItemNBTHelper.cachedRecipeContainsWithNBT(crecipe.getIngredients(), ingredient) || ItemNBTHelper.cachedRecipeContainsWithNBT(crecipe.getOtherStacks(), ingredient)) + arecipes.add(crecipe); + } + } + } diff --git a/src/main/java/vazkii/botania/client/integration/nei/recipe/RecipeHandlerRunicAltar.java b/src/main/java/vazkii/botania/client/integration/nei/recipe/RecipeHandlerRunicAltar.java index b15f972366..506ad540df 100644 --- a/src/main/java/vazkii/botania/client/integration/nei/recipe/RecipeHandlerRunicAltar.java +++ b/src/main/java/vazkii/botania/client/integration/nei/recipe/RecipeHandlerRunicAltar.java @@ -1,7 +1,7 @@ package vazkii.botania.client.integration.nei.recipe; -import codechicken.nei.PositionedStack; import java.util.List; + import net.minecraft.item.ItemStack; import net.minecraft.util.StatCollector; import vazkii.botania.api.BotaniaAPI; @@ -10,50 +10,48 @@ import vazkii.botania.client.core.handler.HUDHandler; import vazkii.botania.common.block.ModBlocks; import vazkii.botania.common.block.tile.mana.TilePool; +import codechicken.nei.PositionedStack; public class RecipeHandlerRunicAltar extends RecipeHandlerPetalApothecary { - public class CachedRunicAltarRecipe extends CachedPetalApothecaryRecipe { - - public int manaUsage; - - public CachedRunicAltarRecipe(RecipeRuneAltar recipe) { - super(recipe, false); - if (recipe == null) return; - manaUsage = recipe.getManaUsage(); - inputs.add(new PositionedStack(new ItemStack(ModBlocks.runeAltar), 73, 55)); - } - } - - @Override - public String getRecipeName() { - return StatCollector.translateToLocal("botania.nei.runicAltar"); - } - - @Override - public String getRecipeID() { - return "botania.runicAltar"; - } - - @Override - public void drawBackground(int recipe) { - super.drawBackground(recipe); - HUDHandler.renderManaBar( - 32, - 113, - 0x0000FF, - 0.75F, - ((CachedRunicAltarRecipe) arecipes.get(recipe)).manaUsage, - TilePool.MAX_MANA / 10); - } - - @Override - public List getRecipes() { - return BotaniaAPI.runeAltarRecipes; - } - - @Override - public CachedPetalApothecaryRecipe getCachedRecipe(RecipePetals recipe) { - return new CachedRunicAltarRecipe((RecipeRuneAltar) recipe); - } + public class CachedRunicAltarRecipe extends CachedPetalApothecaryRecipe { + + public int manaUsage; + + public CachedRunicAltarRecipe(RecipeRuneAltar recipe) { + super(recipe, false); + if(recipe == null) + return; + manaUsage = recipe.getManaUsage(); + inputs.add(new PositionedStack(new ItemStack(ModBlocks.runeAltar), 73, 55)); + } + + } + + @Override + public String getRecipeName() { + return StatCollector.translateToLocal("botania.nei.runicAltar"); + } + + @Override + public String getRecipeID() { + return "botania.runicAltar"; + } + + @Override + public void drawBackground(int recipe) { + super.drawBackground(recipe); + HUDHandler.renderManaBar(32, 113, 0x0000FF, 0.75F, ((CachedRunicAltarRecipe) arecipes.get(recipe)).manaUsage, TilePool.MAX_MANA / 10); + } + + @Override + public List getRecipes() { + return BotaniaAPI.runeAltarRecipes; + } + + @Override + public CachedPetalApothecaryRecipe getCachedRecipe(RecipePetals recipe) { + return new CachedRunicAltarRecipe((RecipeRuneAltar) recipe); + } + } diff --git a/src/main/java/vazkii/botania/client/lib/LibRenderIDs.java b/src/main/java/vazkii/botania/client/lib/LibRenderIDs.java index 4ddf26fca5..75f424b70b 100644 --- a/src/main/java/vazkii/botania/client/lib/LibRenderIDs.java +++ b/src/main/java/vazkii/botania/client/lib/LibRenderIDs.java @@ -2,34 +2,35 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jan 21, 2014, 8:03:06 PM (GMT)] */ package vazkii.botania.client.lib; public final class LibRenderIDs { - public static int idAltar = -1; - public static int idSpecialFlower = -1; - public static int idSpreader = -1; - public static int idPool = -1; - public static int idPylon = -1; - public static int idMiniIsland = -1; - public static int idTinyPotato = -1; - public static int idSpawnerClaw = -1; - public static int idBrewery = -1; - public static int idCorporeaIndex = -1; - public static int idPump = -1; - public static int idDoubleFlower = -1; - public static int idCorporeaCrystalCybe = -1; - public static int idIncensePlate = -1; - public static int idHourglass = -1; - public static int idCocoon = -1; - public static int idLightRelay = -1; - public static int idBellows = -1; - public static int idTeruTeruBozu = -1; - public static int idAvatar = -1; + public static int idAltar = -1; + public static int idSpecialFlower = -1; + public static int idSpreader = -1; + public static int idPool = -1; + public static int idPylon = -1; + public static int idMiniIsland = -1; + public static int idTinyPotato = -1; + public static int idSpawnerClaw = -1; + public static int idBrewery = -1; + public static int idCorporeaIndex = -1; + public static int idPump = -1; + public static int idDoubleFlower = -1; + public static int idCorporeaCrystalCybe = -1; + public static int idIncensePlate = -1; + public static int idHourglass = -1; + public static int idCocoon = -1; + public static int idLightRelay = -1; + public static int idBellows = -1; + public static int idTeruTeruBozu = -1; + public static int idAvatar = -1; + } diff --git a/src/main/java/vazkii/botania/client/lib/LibResources.java b/src/main/java/vazkii/botania/client/lib/LibResources.java index 15d7e26312..584d12181a 100644 --- a/src/main/java/vazkii/botania/client/lib/LibResources.java +++ b/src/main/java/vazkii/botania/client/lib/LibResources.java @@ -2,168 +2,169 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jan 14, 2014, 5:29:31 PM (GMT)] */ package vazkii.botania.client.lib; public final class LibResources { - public static final String PREFIX_MOD = "botania:"; + public static final String PREFIX_MOD = "botania:"; - public static final String PREFIX_LANG = "/assets/botania/lang/"; - public static final String PREFIX_SHADER = "/assets/botania/shader/"; + public static final String PREFIX_LANG = "/assets/botania/lang/"; + public static final String PREFIX_SHADER = "/assets/botania/shader/"; - public static final String PREFIX_GUI = PREFIX_MOD + "textures/gui/"; - public static final String PREFIX_ENTRIES = PREFIX_GUI + "entries/"; - public static final String PREFIX_MODEL = PREFIX_MOD + "textures/model/"; - public static final String PREFIX_MISC = PREFIX_MOD + "textures/misc/"; - public static final String PREFIX_OBJ_MODEL = PREFIX_MOD + "model/"; - public static final String PREFIX_CATEGORIES = PREFIX_GUI + "categories/"; + public static final String PREFIX_GUI = PREFIX_MOD + "textures/gui/"; + public static final String PREFIX_ENTRIES = PREFIX_GUI + "entries/"; + public static final String PREFIX_MODEL = PREFIX_MOD + "textures/model/"; + public static final String PREFIX_MISC = PREFIX_MOD + "textures/misc/"; + public static final String PREFIX_OBJ_MODEL = PREFIX_MOD + "model/"; + public static final String PREFIX_CATEGORIES = PREFIX_GUI + "categories/"; - public static final String EMTPY_TEXTURE = "emptyTexture"; + public static final String EMTPY_TEXTURE = "emptyTexture"; - public static final String GUI_MANA_HUD = PREFIX_GUI + "manaHud.png"; - public static final String GUI_LEXICON = PREFIX_GUI + "lexicon.png"; - public static final String GUI_PAPER = PREFIX_GUI + "paper.png"; - public static final String GUI_CRAFTING_OVERLAY = PREFIX_GUI + "craftingOverlay.png"; - public static final String GUI_MANA_INFUSION_OVERLAY = PREFIX_GUI + "manaInfusionOverlay.png"; - public static final String GUI_PURE_DAISY_OVERLAY = PREFIX_GUI + "pureDaisyOverlay.png"; - public static final String GUI_PETAL_OVERLAY = PREFIX_GUI + "petalOverlay.png"; - public static final String GUI_TERRASTEEL_OVERLAY = PREFIX_GUI + "terrasteelOverlay.png"; - public static final String GUI_ELVEN_TRADE_OVERLAY = PREFIX_GUI + "elvenTradeOverlay.png"; - public static final String GUI_SHEDDING_OVERLAY = PREFIX_GUI + "sheddingOverlay.png"; - public static final String GUI_MULTIBLOCK_OVERLAY = PREFIX_GUI + "multiblockOverlay.png"; - public static final String GUI_CREATIVE = "botania.png"; - public static final String GUI_TOFF = PREFIX_GUI + "toff.png"; - public static final String GUI_BOSS_BAR = PREFIX_GUI + "bossBar.png"; - public static final String GUI_POTIONS = PREFIX_GUI + "potions.png"; - public static final String GUI_NEI_BLANK = PREFIX_GUI + "neiBlank.png"; - public static final String GUI_NEI_BREWERY = PREFIX_GUI + "neiBrewery.png"; - public static final String GUI_FLOWER_BAG = PREFIX_GUI + "flowerBag.png"; - public static final String GUI_BAUBLE_BOX = PREFIX_GUI + "baubleBox.png"; - public static final String GUI_HUD_ICONS = PREFIX_GUI + "hudIcons.png"; - public static final String GUI_STENCIL = PREFIX_GUI + "stencil.png"; - public static final String GUI_DOG = PREFIX_GUI + "dog.png"; - public static final String GUI_FLOWEY = PREFIX_GUI + "flowey.png"; + public static final String GUI_MANA_HUD = PREFIX_GUI + "manaHud.png"; + public static final String GUI_LEXICON = PREFIX_GUI + "lexicon.png"; + public static final String GUI_PAPER = PREFIX_GUI + "paper.png"; + public static final String GUI_CRAFTING_OVERLAY = PREFIX_GUI + "craftingOverlay.png"; + public static final String GUI_MANA_INFUSION_OVERLAY = PREFIX_GUI + "manaInfusionOverlay.png"; + public static final String GUI_PURE_DAISY_OVERLAY = PREFIX_GUI + "pureDaisyOverlay.png"; + public static final String GUI_PETAL_OVERLAY = PREFIX_GUI + "petalOverlay.png"; + public static final String GUI_TERRASTEEL_OVERLAY = PREFIX_GUI + "terrasteelOverlay.png"; + public static final String GUI_ELVEN_TRADE_OVERLAY = PREFIX_GUI + "elvenTradeOverlay.png"; + public static final String GUI_SHEDDING_OVERLAY = PREFIX_GUI + "sheddingOverlay.png"; + public static final String GUI_MULTIBLOCK_OVERLAY = PREFIX_GUI + "multiblockOverlay.png"; + public static final String GUI_CREATIVE = "botania.png"; + public static final String GUI_TOFF = PREFIX_GUI + "toff.png"; + public static final String GUI_BOSS_BAR = PREFIX_GUI + "bossBar.png"; + public static final String GUI_POTIONS = PREFIX_GUI + "potions.png"; + public static final String GUI_NEI_BLANK = PREFIX_GUI + "neiBlank.png"; + public static final String GUI_NEI_BREWERY = PREFIX_GUI + "neiBrewery.png"; + public static final String GUI_FLOWER_BAG = PREFIX_GUI + "flowerBag.png"; + public static final String GUI_BAUBLE_BOX = PREFIX_GUI + "baubleBox.png"; + public static final String GUI_HUD_ICONS = PREFIX_GUI + "hudIcons.png"; + public static final String GUI_STENCIL = PREFIX_GUI + "stencil.png"; + public static final String GUI_DOG = PREFIX_GUI + "dog.png"; + public static final String GUI_FLOWEY = PREFIX_GUI + "flowey.png"; - public static final String ENTRY_FLOWERS = PREFIX_ENTRIES + "flowers.png"; - public static final String ENTRY_APOTHECARY = PREFIX_ENTRIES + "apothecary.png"; - public static final String ENTRY_PURE_DAISY = PREFIX_ENTRIES + "pureDaisy.png"; - public static final String ENTRY_SPREADER = PREFIX_ENTRIES + "spreader.png"; - public static final String ENTRY_UNSTABLE_BLOCK = PREFIX_ENTRIES + "unstableBlock.png"; - public static final String ENTRY_UNSTABLE_BEACON = PREFIX_ENTRIES + "unstableBeacon.png"; - public static final String ENTRY_BAUBLES = PREFIX_ENTRIES + "baubles.png"; - public static final String ENTRY_ELVEN_GARDE = PREFIX_ENTRIES + "elvenGarde.png"; - public static final String ENTRY_DIMINISHING_RETURNS = PREFIX_ENTRIES + "diminishingReturns.png"; - public static final String ENTRY_HYDROANGEAS = PREFIX_ENTRIES + "hydroangeas.png"; - public static final String ENTRY_CRAFT_CRATE = PREFIX_ENTRIES + "craftCrate.png"; - public static final String ENTRY_AZULEJOS = PREFIX_ENTRIES + "azulejos.png"; - public static final String ENTRY_METAMORPHIC_STONES = PREFIX_ENTRIES + "metamorphicStones.png"; - public static final String ENTRY_BANNERS = PREFIX_ENTRIES + "banners.png"; + public static final String ENTRY_FLOWERS = PREFIX_ENTRIES + "flowers.png"; + public static final String ENTRY_APOTHECARY = PREFIX_ENTRIES + "apothecary.png"; + public static final String ENTRY_PURE_DAISY = PREFIX_ENTRIES + "pureDaisy.png"; + public static final String ENTRY_SPREADER = PREFIX_ENTRIES + "spreader.png"; + public static final String ENTRY_UNSTABLE_BLOCK = PREFIX_ENTRIES + "unstableBlock.png"; + public static final String ENTRY_UNSTABLE_BEACON = PREFIX_ENTRIES + "unstableBeacon.png"; + public static final String ENTRY_BAUBLES = PREFIX_ENTRIES + "baubles.png"; + public static final String ENTRY_ELVEN_GARDE = PREFIX_ENTRIES + "elvenGarde.png"; + public static final String ENTRY_DIMINISHING_RETURNS = PREFIX_ENTRIES + "diminishingReturns.png"; + public static final String ENTRY_HYDROANGEAS = PREFIX_ENTRIES + "hydroangeas.png"; + public static final String ENTRY_CRAFT_CRATE = PREFIX_ENTRIES + "craftCrate.png"; + public static final String ENTRY_AZULEJOS = PREFIX_ENTRIES + "azulejos.png"; + public static final String ENTRY_METAMORPHIC_STONES = PREFIX_ENTRIES + "metamorphicStones.png"; + public static final String ENTRY_BANNERS = PREFIX_ENTRIES + "banners.png"; - public static final String MODEL_ALTAR = PREFIX_MODEL + "altar.png"; - public static final String MODEL_ALTAR_META = PREFIX_MODEL + "altarMeta%d.png"; - public static final String MODEL_ALTAR_MOSSY = PREFIX_MODEL + "altarMossy.png"; - public static final String MODEL_SPREADER = PREFIX_MODEL + "spreader.png"; - public static final String MODEL_SPREADER_REDSTONE = PREFIX_MODEL + "spreaderRedstone.png"; - public static final String MODEL_SPREADER_DREAMWOOD = PREFIX_MODEL + "spreaderDreamwood.png"; - public static final String MODEL_SPREADER_HALLOWEEN = PREFIX_MODEL + "spreader_halloween.png"; - public static final String MODEL_SPREADER_REDSTONE_HALLOWEEN = PREFIX_MODEL + "spreaderRedstone_halloween.png"; - public static final String MODEL_SPREADER_DREAMWOOD_HALLOWEEN = PREFIX_MODEL + "spreaderDreamwood_halloween.png"; - public static final String MODEL_POOL = PREFIX_MODEL + "pool.png"; - public static final String MODEL_INFINITE_POOL = PREFIX_MODEL + "infinitePool.png"; - public static final String MODEL_DILUTED_POOL = PREFIX_MODEL + "dilutedPool.png"; - public static final String MODEL_PYLON_OLD = PREFIX_MODEL + "pylonOld.png"; - public static final String MODEL_PYLON = PREFIX_MODEL + "pylon.png"; - public static final String MODEL_PYLON_GREEN_OLD = PREFIX_MODEL + "pylonOld1.png"; - public static final String MODEL_PYLON_GREEN = PREFIX_MODEL + "pylon1.png"; - public static final String MODEL_PYLON_PINK_OLD = PREFIX_MODEL + "pylonOld2.png"; - public static final String MODEL_PYLON_PINK = PREFIX_MODEL + "pylon2.png"; - public static final String MODEL_LEXICA = PREFIX_MODEL + "lexica.png"; - public static final String MODEL_MANASTEEL_0 = PREFIX_MODEL + "manasteel0.png"; - public static final String MODEL_MANASTEEL_1 = PREFIX_MODEL + "manasteel1.png"; - public static final String MODEL_MANASTEEL_2 = PREFIX_MODEL + "manasteel2.png"; - public static final String MODEL_MANASTEEL_NEW = PREFIX_MODEL + "manasteelNew.png"; - public static final String MODEL_TERRASTEEL_0 = PREFIX_MODEL + "terrasteel0.png"; - public static final String MODEL_TERRASTEEL_1 = PREFIX_MODEL + "terrasteel1.png"; - public static final String MODEL_TERRASTEEL_2 = PREFIX_MODEL + "terrasteel2.png"; - public static final String MODEL_TERRASTEEL_NEW = PREFIX_MODEL + "terrasteelNew.png"; - public static final String MODEL_ELEMENTIUM_0 = PREFIX_MODEL + "elementium0.png"; - public static final String MODEL_ELEMENTIUM_1 = PREFIX_MODEL + "elementium1.png"; - public static final String MODEL_ELEMENTIUM_2 = PREFIX_MODEL + "elementium2.png"; - public static final String MODEL_ELEMENTIUM_NEW = PREFIX_MODEL + "elementiumNew.png"; - public static final String MODEL_MANAWEAVE_0 = PREFIX_MODEL + "manaweave0.png"; - public static final String MODEL_MANAWEAVE_1 = PREFIX_MODEL + "manaweave1.png"; - public static final String MODEL_MANAWEAVE_NEW = PREFIX_MODEL + "manaweaveNew.png"; - public static final String MODEL_MANAWEAVE_NEW_HOLIDAY = PREFIX_MODEL + "manaweaveNewHoliday.png"; - public static final String MODEL_PIXIE = PREFIX_MODEL + "pixie.png"; - public static final String MODEL_TINY_POTATO = PREFIX_MODEL + "tinyPotato.png"; - public static final String MODEL_TINY_POTATO_GS = PREFIX_MODEL + "tinyPotatoGray.png"; - public static final String MODEL_TINY_POTATO_HALLOWEEN = PREFIX_MODEL + "tinyPotato_halloween.png"; - public static final String MODEL_SPAWNER_CLAW = PREFIX_MODEL + "spawnerClaw.png"; - public static final String MODEL_BREWERY = PREFIX_MODEL + "brewery.png"; - public static final String MODEL_TRAVEL_BELT = PREFIX_MODEL + "travelBelt.png"; - public static final String MODEL_SUPER_TRAVEL_BELT = PREFIX_MODEL + "superTravelBelt.png"; - public static final String MODEL_SPEED_UP_BELT = PREFIX_MODEL + "speedUpBelt.png"; - public static final String MODEL_KNOCKBACK_BELT = PREFIX_MODEL + "knockbackBelt.png"; - public static final String MODEL_HOLY_CLOAK = PREFIX_MODEL + "holyCloak.png"; - public static final String MODEL_UNHOLY_CLOAK = PREFIX_MODEL + "unholyCloak.png"; - public static final String MODEL_CORPOREA_INDEX = PREFIX_MODEL + "corporeaIndex.png"; - public static final String MODEL_INVISIBLE_ARMOR = PREFIX_MODEL + "invisibleArmor.png"; - public static final String MODEL_PUMP = PREFIX_MODEL + "pump.png"; - public static final String MODEL_MINI_ISLAND = PREFIX_MODEL + "miniIsland.png"; - public static final String MODEL_MINI_ISLAND_PODZOL = PREFIX_MODEL + "miniIslandPodzol.png"; - public static final String MODEL_MINI_ISLAND_MYCEL = PREFIX_MODEL + "miniIslandMycelium.png"; - public static final String MODEL_MINI_ISLAND_SNOW = PREFIX_MODEL + "miniIslandSnow.png"; - public static final String MODEL_MINI_ISLAND_DRY = PREFIX_MODEL + "miniIslandDry.png"; - public static final String MODEL_MINI_ISLAND_GOLDEN = PREFIX_MODEL + "miniIslandGolden.png"; - public static final String MODEL_MINI_ISLAND_VIVID = PREFIX_MODEL + "miniIslandVivid.png"; - public static final String MODEL_MINI_ISLAND_SCORCHED = PREFIX_MODEL + "miniIslandScorched.png"; - public static final String MODEL_MINI_ISLAND_INFUSED = PREFIX_MODEL + "miniIslandInfused.png"; - public static final String MODEL_MINI_ISLAND_MUTATED = PREFIX_MODEL + "miniIslandMutated.png"; - public static final String MODEL_PINK_WITHER = PREFIX_MODEL + "pinkWither.png"; - public static final String MODEL_CRYSTAL_CUBE = PREFIX_MODEL + "crystalCube.png"; - public static final String MODEL_INCENSE_PLATE = PREFIX_MODEL + "incensePlate.png"; - public static final String MODEL_HOURGLASS = PREFIX_MODEL + "hourglass.png"; - public static final String MODEL_COCOON = PREFIX_MODEL + "cocoon.png"; - public static final String MODEL_BELLOWS = PREFIX_MODEL + "bellows.png"; - public static final String MODEL_TERU_TERU_BOZU = PREFIX_MODEL + "teruTeruBozu.png"; - public static final String MODEL_TERU_TERU_BOZU_HALLOWEEN = PREFIX_MODEL + "teruTeruBozu_halloween.png"; - public static final String MODEL_AVATAR = PREFIX_MODEL + "avatar.png"; - public static final String MODEL_AVATAR_DIVINING = PREFIX_MODEL + "avatarDivining.png"; - public static final String MODEL_AVATAR_FIRE = PREFIX_MODEL + "avatarFire.png"; - public static final String MODEL_AVATAR_MISSILE = PREFIX_MODEL + "avatarMissile.png"; - public static final String MODEL_AVATAR_RAINBOW = PREFIX_MODEL + "avatarRainbow.png"; - public static final String MODEL_AVATAR_TORNADO = PREFIX_MODEL + "avatarTornado.png"; + public static final String MODEL_ALTAR = PREFIX_MODEL + "altar.png"; + public static final String MODEL_ALTAR_META = PREFIX_MODEL + "altarMeta%d.png"; + public static final String MODEL_ALTAR_MOSSY = PREFIX_MODEL + "altarMossy.png"; + public static final String MODEL_SPREADER = PREFIX_MODEL + "spreader.png"; + public static final String MODEL_SPREADER_REDSTONE = PREFIX_MODEL + "spreaderRedstone.png"; + public static final String MODEL_SPREADER_DREAMWOOD = PREFIX_MODEL + "spreaderDreamwood.png"; + public static final String MODEL_SPREADER_HALLOWEEN = PREFIX_MODEL + "spreader_halloween.png"; + public static final String MODEL_SPREADER_REDSTONE_HALLOWEEN = PREFIX_MODEL + "spreaderRedstone_halloween.png"; + public static final String MODEL_SPREADER_DREAMWOOD_HALLOWEEN = PREFIX_MODEL + "spreaderDreamwood_halloween.png"; + public static final String MODEL_POOL = PREFIX_MODEL + "pool.png"; + public static final String MODEL_INFINITE_POOL = PREFIX_MODEL + "infinitePool.png"; + public static final String MODEL_DILUTED_POOL = PREFIX_MODEL + "dilutedPool.png"; + public static final String MODEL_PYLON_OLD = PREFIX_MODEL + "pylonOld.png"; + public static final String MODEL_PYLON = PREFIX_MODEL + "pylon.png"; + public static final String MODEL_PYLON_GREEN_OLD = PREFIX_MODEL + "pylonOld1.png"; + public static final String MODEL_PYLON_GREEN = PREFIX_MODEL + "pylon1.png"; + public static final String MODEL_PYLON_PINK_OLD = PREFIX_MODEL + "pylonOld2.png"; + public static final String MODEL_PYLON_PINK = PREFIX_MODEL + "pylon2.png"; + public static final String MODEL_LEXICA = PREFIX_MODEL + "lexica.png"; + public static final String MODEL_MANASTEEL_0 = PREFIX_MODEL + "manasteel0.png"; + public static final String MODEL_MANASTEEL_1 = PREFIX_MODEL + "manasteel1.png"; + public static final String MODEL_MANASTEEL_2 = PREFIX_MODEL + "manasteel2.png"; + public static final String MODEL_MANASTEEL_NEW = PREFIX_MODEL + "manasteelNew.png"; + public static final String MODEL_TERRASTEEL_0 = PREFIX_MODEL + "terrasteel0.png"; + public static final String MODEL_TERRASTEEL_1 = PREFIX_MODEL + "terrasteel1.png"; + public static final String MODEL_TERRASTEEL_2 = PREFIX_MODEL + "terrasteel2.png"; + public static final String MODEL_TERRASTEEL_NEW = PREFIX_MODEL + "terrasteelNew.png"; + public static final String MODEL_ELEMENTIUM_0 = PREFIX_MODEL + "elementium0.png"; + public static final String MODEL_ELEMENTIUM_1 = PREFIX_MODEL + "elementium1.png"; + public static final String MODEL_ELEMENTIUM_2 = PREFIX_MODEL + "elementium2.png"; + public static final String MODEL_ELEMENTIUM_NEW = PREFIX_MODEL + "elementiumNew.png"; + public static final String MODEL_MANAWEAVE_0 = PREFIX_MODEL + "manaweave0.png"; + public static final String MODEL_MANAWEAVE_1 = PREFIX_MODEL + "manaweave1.png"; + public static final String MODEL_MANAWEAVE_NEW = PREFIX_MODEL + "manaweaveNew.png"; + public static final String MODEL_MANAWEAVE_NEW_HOLIDAY = PREFIX_MODEL + "manaweaveNewHoliday.png"; + public static final String MODEL_PIXIE = PREFIX_MODEL + "pixie.png"; + public static final String MODEL_TINY_POTATO = PREFIX_MODEL + "tinyPotato.png"; + public static final String MODEL_TINY_POTATO_GS = PREFIX_MODEL + "tinyPotatoGray.png"; + public static final String MODEL_TINY_POTATO_HALLOWEEN = PREFIX_MODEL + "tinyPotato_halloween.png"; + public static final String MODEL_SPAWNER_CLAW = PREFIX_MODEL + "spawnerClaw.png"; + public static final String MODEL_BREWERY = PREFIX_MODEL + "brewery.png"; + public static final String MODEL_TRAVEL_BELT = PREFIX_MODEL + "travelBelt.png"; + public static final String MODEL_SUPER_TRAVEL_BELT = PREFIX_MODEL + "superTravelBelt.png"; + public static final String MODEL_SPEED_UP_BELT = PREFIX_MODEL + "speedUpBelt.png"; + public static final String MODEL_KNOCKBACK_BELT = PREFIX_MODEL + "knockbackBelt.png"; + public static final String MODEL_HOLY_CLOAK = PREFIX_MODEL + "holyCloak.png"; + public static final String MODEL_UNHOLY_CLOAK = PREFIX_MODEL + "unholyCloak.png"; + public static final String MODEL_CORPOREA_INDEX = PREFIX_MODEL + "corporeaIndex.png"; + public static final String MODEL_INVISIBLE_ARMOR = PREFIX_MODEL + "invisibleArmor.png"; + public static final String MODEL_PUMP = PREFIX_MODEL + "pump.png"; + public static final String MODEL_MINI_ISLAND = PREFIX_MODEL + "miniIsland.png"; + public static final String MODEL_MINI_ISLAND_PODZOL = PREFIX_MODEL + "miniIslandPodzol.png"; + public static final String MODEL_MINI_ISLAND_MYCEL = PREFIX_MODEL + "miniIslandMycelium.png"; + public static final String MODEL_MINI_ISLAND_SNOW = PREFIX_MODEL + "miniIslandSnow.png"; + public static final String MODEL_MINI_ISLAND_DRY = PREFIX_MODEL + "miniIslandDry.png"; + public static final String MODEL_MINI_ISLAND_GOLDEN = PREFIX_MODEL + "miniIslandGolden.png"; + public static final String MODEL_MINI_ISLAND_VIVID = PREFIX_MODEL + "miniIslandVivid.png"; + public static final String MODEL_MINI_ISLAND_SCORCHED = PREFIX_MODEL + "miniIslandScorched.png"; + public static final String MODEL_MINI_ISLAND_INFUSED = PREFIX_MODEL + "miniIslandInfused.png"; + public static final String MODEL_MINI_ISLAND_MUTATED = PREFIX_MODEL + "miniIslandMutated.png"; + public static final String MODEL_PINK_WITHER = PREFIX_MODEL + "pinkWither.png"; + public static final String MODEL_CRYSTAL_CUBE = PREFIX_MODEL + "crystalCube.png"; + public static final String MODEL_INCENSE_PLATE = PREFIX_MODEL + "incensePlate.png"; + public static final String MODEL_HOURGLASS = PREFIX_MODEL + "hourglass.png"; + public static final String MODEL_COCOON = PREFIX_MODEL + "cocoon.png"; + public static final String MODEL_BELLOWS = PREFIX_MODEL + "bellows.png"; + public static final String MODEL_TERU_TERU_BOZU = PREFIX_MODEL + "teruTeruBozu.png"; + public static final String MODEL_TERU_TERU_BOZU_HALLOWEEN = PREFIX_MODEL + "teruTeruBozu_halloween.png"; + public static final String MODEL_AVATAR = PREFIX_MODEL + "avatar.png"; + public static final String MODEL_AVATAR_DIVINING = PREFIX_MODEL + "avatarDivining.png"; + public static final String MODEL_AVATAR_FIRE = PREFIX_MODEL + "avatarFire.png"; + public static final String MODEL_AVATAR_MISSILE = PREFIX_MODEL + "avatarMissile.png"; + public static final String MODEL_AVATAR_RAINBOW = PREFIX_MODEL + "avatarRainbow.png"; + public static final String MODEL_AVATAR_TORNADO = PREFIX_MODEL + "avatarTornado.png"; - public static final String MISC_PARTICLES = PREFIX_MISC + "particles.png"; - public static final String MISC_WISP_LARGE = PREFIX_MISC + "wispLarge.png"; - public static final String MISC_WISP_SMALL = PREFIX_MISC + "wispSmall.png"; - public static final String MISC_HALO = PREFIX_MISC + "halo.png"; - public static final String MISC_GLOW_GREEN = PREFIX_MISC + "glow0.png"; - public static final String MISC_GLOW_CYAN = PREFIX_MISC + "glow1.png"; - public static final String MISC_BABYLON = PREFIX_MISC + "babylon.png"; - public static final String MISC_SKYBOX = PREFIX_MISC + "skybox.png"; - public static final String MISC_RAINBOW = PREFIX_MISC + "rainbow.png"; - public static final String MISC_PLANET = PREFIX_MISC + "planet"; + public static final String MISC_PARTICLES = PREFIX_MISC + "particles.png"; + public static final String MISC_WISP_LARGE = PREFIX_MISC + "wispLarge.png"; + public static final String MISC_WISP_SMALL = PREFIX_MISC + "wispSmall.png"; + public static final String MISC_HALO = PREFIX_MISC + "halo.png"; + public static final String MISC_GLOW_GREEN = PREFIX_MISC + "glow0.png"; + public static final String MISC_GLOW_CYAN = PREFIX_MISC + "glow1.png"; + public static final String MISC_BABYLON = PREFIX_MISC + "babylon.png"; + public static final String MISC_SKYBOX = PREFIX_MISC + "skybox.png"; + public static final String MISC_RAINBOW = PREFIX_MISC + "rainbow.png"; + public static final String MISC_PLANET = PREFIX_MISC + "planet"; - public static final String OBJ_MODEL_PYLON = PREFIX_OBJ_MODEL + "pylon.obj"; + public static final String OBJ_MODEL_PYLON = PREFIX_OBJ_MODEL + "pylon.obj"; - public static final String CATEGORY_INDEX = PREFIX_CATEGORIES + "index.png"; + public static final String CATEGORY_INDEX = PREFIX_CATEGORIES + "index.png"; + + public static final String SHADER_PYLON_GLOW_FRAG = PREFIX_SHADER + "pylon_glow.frag"; + public static final String SHADER_ENCHANTER_RUNE_FRAG = PREFIX_SHADER + "enchanter_rune.frag"; + public static final String SHADER_MANA_POOL_FRAG = PREFIX_SHADER + "mana_pool.frag"; + public static final String SHADER_DOPLLEGANGER_VERT = PREFIX_SHADER + "doppleganger.vert"; + public static final String SHADER_DOPLLEGANGER_FRAG = PREFIX_SHADER + "doppleganger.frag"; + public static final String SHADER_HALO_FRAG = PREFIX_SHADER + "halo.frag"; + public static final String SHADER_DOPLLEGANGER_BAR_FRAG = PREFIX_SHADER + "doppleganger_bar.frag"; + public static final String SHADER_TERRA_PLATE_RUNE_FRAG = PREFIX_SHADER + "terra_plate_rune.frag"; + public static final String SHADER_FILM_GRAIN_FRAG = PREFIX_SHADER + "film_grain.frag"; + public static final String SHADER_GOLD_FRAG = PREFIX_SHADER + "gold.frag"; + public static final String SHADER_CATEGORY_BUTTON_FRAG = PREFIX_SHADER + "category_button.frag"; - public static final String SHADER_PYLON_GLOW_FRAG = PREFIX_SHADER + "pylon_glow.frag"; - public static final String SHADER_ENCHANTER_RUNE_FRAG = PREFIX_SHADER + "enchanter_rune.frag"; - public static final String SHADER_MANA_POOL_FRAG = PREFIX_SHADER + "mana_pool.frag"; - public static final String SHADER_DOPLLEGANGER_VERT = PREFIX_SHADER + "doppleganger.vert"; - public static final String SHADER_DOPLLEGANGER_FRAG = PREFIX_SHADER + "doppleganger.frag"; - public static final String SHADER_HALO_FRAG = PREFIX_SHADER + "halo.frag"; - public static final String SHADER_DOPLLEGANGER_BAR_FRAG = PREFIX_SHADER + "doppleganger_bar.frag"; - public static final String SHADER_TERRA_PLATE_RUNE_FRAG = PREFIX_SHADER + "terra_plate_rune.frag"; - public static final String SHADER_FILM_GRAIN_FRAG = PREFIX_SHADER + "film_grain.frag"; - public static final String SHADER_GOLD_FRAG = PREFIX_SHADER + "gold.frag"; - public static final String SHADER_CATEGORY_BUTTON_FRAG = PREFIX_SHADER + "category_button.frag"; } diff --git a/src/main/java/vazkii/botania/client/model/IPylonModel.java b/src/main/java/vazkii/botania/client/model/IPylonModel.java index d3a2f9e1a1..c795092a56 100644 --- a/src/main/java/vazkii/botania/client/model/IPylonModel.java +++ b/src/main/java/vazkii/botania/client/model/IPylonModel.java @@ -2,19 +2,18 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Apr 1, 2014, 6:23:24 PM (GMT)] */ package vazkii.botania.client.model; public interface IPylonModel { - public void renderCrystal(); + public void renderCrystal(); + public void renderRing(); + public void renderGems(); - public void renderRing(); - - public void renderGems(); } diff --git a/src/main/java/vazkii/botania/client/model/ModelAltar.java b/src/main/java/vazkii/botania/client/model/ModelAltar.java index e4c65cbbc6..b8827a24d3 100644 --- a/src/main/java/vazkii/botania/client/model/ModelAltar.java +++ b/src/main/java/vazkii/botania/client/model/ModelAltar.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jan 21, 2014, 7:56:15 PM (GMT)] */ package vazkii.botania.client.model; @@ -15,74 +15,74 @@ public class ModelAltar extends ModelBase { - ModelRenderer gobletBase; - ModelRenderer gobletBase2; - ModelRenderer gobletBase3; - ModelRenderer gobletStand; - ModelRenderer kelkBase; - ModelRenderer kelkBase2; - ModelRenderer kelkWall1; - ModelRenderer kelkWall2; - ModelRenderer kelkWall3; - ModelRenderer kelkWall4; + ModelRenderer gobletBase; + ModelRenderer gobletBase2; + ModelRenderer gobletBase3; + ModelRenderer gobletStand; + ModelRenderer kelkBase; + ModelRenderer kelkBase2; + ModelRenderer kelkWall1; + ModelRenderer kelkWall2; + ModelRenderer kelkWall3; + ModelRenderer kelkWall4; - public ModelAltar() { - textureWidth = 256; - textureHeight = 128; + public ModelAltar() { + textureWidth = 256; + textureHeight = 128; - gobletBase = new ModelRenderer(this, 0, 0); - gobletBase.addBox(0F, 0F, 0F, 16, 2, 16); - gobletBase.setRotationPoint(-8F, 22F, -8F); - gobletBase.setTextureSize(256, 128); - gobletBase2 = new ModelRenderer(this, 0, 18); - gobletBase2.addBox(0F, 0F, 0F, 14, 1, 14); - gobletBase2.setRotationPoint(-7F, 21F, -7F); - gobletBase2.setTextureSize(256, 128); - gobletStand = new ModelRenderer(this, 68, 0); - gobletStand.addBox(0F, 0F, 0F, 6, 8, 6); - gobletStand.setRotationPoint(-3F, 12F, -3F); - gobletStand.setTextureSize(256, 128); - gobletBase3 = new ModelRenderer(this, 0, 33); - gobletBase3.addBox(0F, 0F, 0F, 12, 1, 12); - gobletBase3.setRotationPoint(-6F, 20F, -6F); - gobletBase3.setTextureSize(256, 128); - kelkBase = new ModelRenderer(this, 72, 45); - kelkBase.addBox(0F, 0F, 0F, 8, 1, 8); - kelkBase.setRotationPoint(-4F, 11F, -4F); - kelkBase.setTextureSize(256, 128); - kelkBase2 = new ModelRenderer(this, 72, 34); - kelkBase2.addBox(0F, 0F, 0F, 10, 1, 10); - kelkBase2.setRotationPoint(-5F, 10F, -5F); - kelkBase2.setTextureSize(256, 128); - kelkWall1 = new ModelRenderer(this, 72, 18); - kelkWall1.addBox(0F, 0F, 0F, 1, 6, 10); - kelkWall1.setRotationPoint(5F, 4F, -5F); - kelkWall1.setTextureSize(256, 128); - kelkWall2 = new ModelRenderer(this, 72, 18); - kelkWall2.addBox(0F, 0F, 0F, 1, 6, 10); - kelkWall2.setRotationPoint(-6F, 4F, -5F); - kelkWall2.setTextureSize(256, 128); - kelkWall3 = new ModelRenderer(this, 94, 18); - kelkWall3.addBox(0F, 0F, 0F, 10, 6, 1); - kelkWall3.setRotationPoint(-5F, 4F, 5F); - kelkWall3.setTextureSize(256, 128); - kelkWall4 = new ModelRenderer(this, 94, 18); - kelkWall4.addBox(0F, 0F, 0F, 10, 6, 1); - kelkWall4.setRotationPoint(-5F, 4F, -6F); - kelkWall4.setTextureSize(256, 128); - } + gobletBase = new ModelRenderer(this, 0, 0); + gobletBase.addBox(0F, 0F, 0F, 16, 2, 16); + gobletBase.setRotationPoint(-8F, 22F, -8F); + gobletBase.setTextureSize(256, 128); + gobletBase2 = new ModelRenderer(this, 0, 18); + gobletBase2.addBox(0F, 0F, 0F, 14, 1, 14); + gobletBase2.setRotationPoint(-7F, 21F, -7F); + gobletBase2.setTextureSize(256, 128); + gobletStand = new ModelRenderer(this, 68, 0); + gobletStand.addBox(0F, 0F, 0F, 6, 8, 6); + gobletStand.setRotationPoint(-3F, 12F, -3F); + gobletStand.setTextureSize(256, 128); + gobletBase3 = new ModelRenderer(this, 0, 33); + gobletBase3.addBox(0F, 0F, 0F, 12, 1, 12); + gobletBase3.setRotationPoint(-6F, 20F, -6F); + gobletBase3.setTextureSize(256, 128); + kelkBase = new ModelRenderer(this, 72, 45); + kelkBase.addBox(0F, 0F, 0F, 8, 1, 8); + kelkBase.setRotationPoint(-4F, 11F, -4F); + kelkBase.setTextureSize(256, 128); + kelkBase2 = new ModelRenderer(this, 72, 34); + kelkBase2.addBox(0F, 0F, 0F, 10, 1, 10); + kelkBase2.setRotationPoint(-5F, 10F, -5F); + kelkBase2.setTextureSize(256, 128); + kelkWall1 = new ModelRenderer(this, 72, 18); + kelkWall1.addBox(0F, 0F, 0F, 1, 6, 10); + kelkWall1.setRotationPoint(5F, 4F, -5F); + kelkWall1.setTextureSize(256, 128); + kelkWall2 = new ModelRenderer(this, 72, 18); + kelkWall2.addBox(0F, 0F, 0F, 1, 6, 10); + kelkWall2.setRotationPoint(-6F, 4F, -5F); + kelkWall2.setTextureSize(256, 128); + kelkWall3 = new ModelRenderer(this, 94, 18); + kelkWall3.addBox(0F, 0F, 0F, 10, 6, 1); + kelkWall3.setRotationPoint(-5F, 4F, 5F); + kelkWall3.setTextureSize(256, 128); + kelkWall4 = new ModelRenderer(this, 94, 18); + kelkWall4.addBox(0F, 0F, 0F, 10, 6, 1); + kelkWall4.setRotationPoint(-5F, 4F, -6F); + kelkWall4.setTextureSize(256, 128); + } - public void render() { - float f = 1F / 16F; - gobletBase.render(f); - gobletBase2.render(f); - gobletBase3.render(f); - gobletStand.render(f); - kelkBase.render(f); - kelkBase2.render(f); - kelkWall1.render(f); - kelkWall2.render(f); - kelkWall3.render(f); - kelkWall4.render(f); - } + public void render() { + float f = 1F / 16F; + gobletBase.render(f); + gobletBase2.render(f); + gobletBase3.render(f); + gobletStand.render(f); + kelkBase.render(f); + kelkBase2.render(f); + kelkWall1.render(f); + kelkWall2.render(f); + kelkWall3.render(f); + kelkWall4.render(f); + } } diff --git a/src/main/java/vazkii/botania/client/model/ModelAvatar.java b/src/main/java/vazkii/botania/client/model/ModelAvatar.java index c3b20f90ff..934471b34a 100644 --- a/src/main/java/vazkii/botania/client/model/ModelAvatar.java +++ b/src/main/java/vazkii/botania/client/model/ModelAvatar.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [? (GMT)] */ package vazkii.botania.client.model; @@ -15,53 +15,54 @@ public class ModelAvatar extends ModelBase { - public ModelRenderer body; - public ModelRenderer rightarm; - public ModelRenderer leftarm; - public ModelRenderer rightleg; - public ModelRenderer leftleg; - public ModelRenderer head; + public ModelRenderer body; + public ModelRenderer rightarm; + public ModelRenderer leftarm; + public ModelRenderer rightleg; + public ModelRenderer leftleg; + public ModelRenderer head; - public ModelAvatar() { - textureWidth = 32; - textureHeight = 32; - leftleg = new ModelRenderer(this, 0, 20); - leftleg.mirror = true; - leftleg.setRotationPoint(1.5F, 18.0F, -0.5F); - leftleg.addBox(-1.5F, 0.0F, -1.5F, 3, 6, 3, 0.0F); - rightarm = new ModelRenderer(this, 0, 20); - rightarm.setRotationPoint(-3.0F, 15.0F, -1.0F); - rightarm.addBox(-2.0F, -1.0F, -1.0F, 2, 6, 3, 0.0F); - setRotateAngle(rightarm, 0.0F, -0.0F, 0.08726646259971647F); - leftarm = new ModelRenderer(this, 0, 20); - leftarm.mirror = true; - leftarm.setRotationPoint(3.0F, 15.0F, -1.0F); - leftarm.addBox(0.0F, -1.0F, -1.0F, 2, 6, 3, 0.0F); - setRotateAngle(leftarm, 0.0F, -0.0F, -0.08726646259971647F); - head = new ModelRenderer(this, 0, 0); - head.setRotationPoint(0.0F, 14.0F, 0.0F); - head.addBox(-3.0F, -6.0F, -3.0F, 6, 6, 6, 0.0F); - rightleg = new ModelRenderer(this, 0, 20); - rightleg.setRotationPoint(-1.5F, 18.0F, -0.5F); - rightleg.addBox(-1.5F, 0.0F, -1.5F, 3, 6, 3, 0.0F); - body = new ModelRenderer(this, 0, 12); - body.setRotationPoint(0.0F, 14.0F, 0.0F); - body.addBox(-3.0F, 0.0F, -2.0F, 6, 4, 4, 0.0F); - } + public ModelAvatar() { + textureWidth = 32; + textureHeight = 32; + leftleg = new ModelRenderer(this, 0, 20); + leftleg.mirror = true; + leftleg.setRotationPoint(1.5F, 18.0F, -0.5F); + leftleg.addBox(-1.5F, 0.0F, -1.5F, 3, 6, 3, 0.0F); + rightarm = new ModelRenderer(this, 0, 20); + rightarm.setRotationPoint(-3.0F, 15.0F, -1.0F); + rightarm.addBox(-2.0F, -1.0F, -1.0F, 2, 6, 3, 0.0F); + setRotateAngle(rightarm, 0.0F, -0.0F, 0.08726646259971647F); + leftarm = new ModelRenderer(this, 0, 20); + leftarm.mirror = true; + leftarm.setRotationPoint(3.0F, 15.0F, -1.0F); + leftarm.addBox(0.0F, -1.0F, -1.0F, 2, 6, 3, 0.0F); + setRotateAngle(leftarm, 0.0F, -0.0F, -0.08726646259971647F); + head = new ModelRenderer(this, 0, 0); + head.setRotationPoint(0.0F, 14.0F, 0.0F); + head.addBox(-3.0F, -6.0F, -3.0F, 6, 6, 6, 0.0F); + rightleg = new ModelRenderer(this, 0, 20); + rightleg.setRotationPoint(-1.5F, 18.0F, -0.5F); + rightleg.addBox(-1.5F, 0.0F, -1.5F, 3, 6, 3, 0.0F); + body = new ModelRenderer(this, 0, 12); + body.setRotationPoint(0.0F, 14.0F, 0.0F); + body.addBox(-3.0F, 0.0F, -2.0F, 6, 4, 4, 0.0F); + } - public void render() { - float f5 = 1F / 15F; - leftleg.render(f5); - rightarm.render(f5); - leftarm.render(f5); - head.render(f5); - rightleg.render(f5); - body.render(f5); - } + public void render() { + float f5 = 1F / 15F; + leftleg.render(f5); + rightarm.render(f5); + leftarm.render(f5); + head.render(f5); + rightleg.render(f5); + body.render(f5); + } - public void setRotateAngle(ModelRenderer modelRenderer, float x, float y, float z) { - modelRenderer.rotateAngleX = x; - modelRenderer.rotateAngleY = y; - modelRenderer.rotateAngleZ = z; - } -} + public void setRotateAngle(ModelRenderer modelRenderer, float x, float y, float z) { + modelRenderer.rotateAngleX = x; + modelRenderer.rotateAngleY = y; + modelRenderer.rotateAngleZ = z; + } + +} \ No newline at end of file diff --git a/src/main/java/vazkii/botania/client/model/ModelBellows.java b/src/main/java/vazkii/botania/client/model/ModelBellows.java index 6a71cdacd7..f086f946e6 100644 --- a/src/main/java/vazkii/botania/client/model/ModelBellows.java +++ b/src/main/java/vazkii/botania/client/model/ModelBellows.java @@ -2,89 +2,91 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Aug 28, 2015, 5:16:17 PM (GMT)] */ package vazkii.botania.client.model; import net.minecraft.client.model.ModelBase; import net.minecraft.client.model.ModelRenderer; + import org.lwjgl.opengl.GL11; public class ModelBellows extends ModelBase { - ModelRenderer Base; - ModelRenderer Top; - ModelRenderer Funnel; - ModelRenderer Pipe; - ModelRenderer Handle1; - ModelRenderer Handle2; - ModelRenderer Handle3; + ModelRenderer Base; + ModelRenderer Top; + ModelRenderer Funnel; + ModelRenderer Pipe; + ModelRenderer Handle1; + ModelRenderer Handle2; + ModelRenderer Handle3; + + public ModelBellows() { + textureWidth = 64; + textureHeight = 32; + + Base = new ModelRenderer(this, 0, 0); + Base.addBox(0F, 0F, 0F, 10, 2, 10); + Base.setRotationPoint(-5F, 22F, -5F); + Base.setTextureSize(64, 32); + Base.mirror = true; + Top = new ModelRenderer(this, 0, 14); + Top.addBox(0F, 0F, 0F, 8, 1, 8); + Top.setRotationPoint(-4F, 14F, -4F); + Top.setTextureSize(64, 32); + Top.mirror = true; + Funnel = new ModelRenderer(this, 34, 14); + Funnel.addBox(0F, 0F, 0F, 6, 7, 6); + Funnel.setRotationPoint(0F, 0F, 0F); + Funnel.setTextureSize(64, 32); + Funnel.mirror = true; + Pipe = new ModelRenderer(this, 43, 1); + Pipe.addBox(0F, 0F, 0F, 2, 2, 3); + Pipe.setRotationPoint(-1F, 22F, -8F); + Pipe.setTextureSize(64, 32); + Pipe.mirror = true; + Handle1 = new ModelRenderer(this, 43, 8); + Handle1.addBox(0F, 0F, -0.5F, 1, 2, 1); + Handle1.setRotationPoint(-2F, 12F, 0F); + Handle1.setTextureSize(64, 32); + Handle1.mirror = true; + Handle2 = new ModelRenderer(this, 48, 8); + Handle2.addBox(1F, 0F, -0.5F, 2, 1, 1); + Handle2.setRotationPoint(-2F, 12F, 0F); + Handle2.setTextureSize(64, 32); + Handle2.mirror = true; + Handle3 = new ModelRenderer(this, 55, 8); + Handle3.addBox(3F, 0F, -0.5F, 1, 2, 1); + Handle3.setRotationPoint(-2F, 12F, 0F); + Handle3.setTextureSize(64, 32); + Handle3.mirror = true; + } - public ModelBellows() { - textureWidth = 64; - textureHeight = 32; + public void render(float fract) { + float f5 = 1F / 16F; + Base.render(f5); + Pipe.render(f5); - Base = new ModelRenderer(this, 0, 0); - Base.addBox(0F, 0F, 0F, 10, 2, 10); - Base.setRotationPoint(-5F, 22F, -5F); - Base.setTextureSize(64, 32); - Base.mirror = true; - Top = new ModelRenderer(this, 0, 14); - Top.addBox(0F, 0F, 0F, 8, 1, 8); - Top.setRotationPoint(-4F, 14F, -4F); - Top.setTextureSize(64, 32); - Top.mirror = true; - Funnel = new ModelRenderer(this, 34, 14); - Funnel.addBox(0F, 0F, 0F, 6, 7, 6); - Funnel.setRotationPoint(0F, 0F, 0F); - Funnel.setTextureSize(64, 32); - Funnel.mirror = true; - Pipe = new ModelRenderer(this, 43, 1); - Pipe.addBox(0F, 0F, 0F, 2, 2, 3); - Pipe.setRotationPoint(-1F, 22F, -8F); - Pipe.setTextureSize(64, 32); - Pipe.mirror = true; - Handle1 = new ModelRenderer(this, 43, 8); - Handle1.addBox(0F, 0F, -0.5F, 1, 2, 1); - Handle1.setRotationPoint(-2F, 12F, 0F); - Handle1.setTextureSize(64, 32); - Handle1.mirror = true; - Handle2 = new ModelRenderer(this, 48, 8); - Handle2.addBox(1F, 0F, -0.5F, 2, 1, 1); - Handle2.setRotationPoint(-2F, 12F, 0F); - Handle2.setTextureSize(64, 32); - Handle2.mirror = true; - Handle3 = new ModelRenderer(this, 55, 8); - Handle3.addBox(3F, 0F, -0.5F, 1, 2, 1); - Handle3.setRotationPoint(-2F, 12F, 0F); - Handle3.setTextureSize(64, 32); - Handle3.mirror = true; - } + //float fract = Math.max(0.1F, (float) (Math.sin(((double) ClientTickHandler.ticksInGame + ClientTickHandler.partialTicks) * 0.2) + 1F) * 0.5F); + float mov = (1F - fract) * 0.5F; - public void render(float fract) { - float f5 = 1F / 16F; - Base.render(f5); - Pipe.render(f5); + GL11.glTranslatef(0F, mov, 0F); + Top.render(f5); + Handle1.render(f5); + Handle2.render(f5); + Handle3.render(f5); + GL11.glTranslatef(0F, -mov, 0F); - // float fract = Math.max(0.1F, (float) (Math.sin(((double) ClientTickHandler.ticksInGame + - // ClientTickHandler.partialTicks) * 0.2) + 1F) * 0.5F); - float mov = (1F - fract) * 0.5F; + GL11.glRotatef(180F, 1F, 0F, 0F); + GL11.glTranslatef(-0.19F, -1.375F, -0.19F); + GL11.glScalef(1F, fract, 1F); + Funnel.render(f5); + GL11.glScalef(1F, 1F / fract, 1F); + } - GL11.glTranslatef(0F, mov, 0F); - Top.render(f5); - Handle1.render(f5); - Handle2.render(f5); - Handle3.render(f5); - GL11.glTranslatef(0F, -mov, 0F); - GL11.glRotatef(180F, 1F, 0F, 0F); - GL11.glTranslatef(-0.19F, -1.375F, -0.19F); - GL11.glScalef(1F, fract, 1F); - Funnel.render(f5); - GL11.glScalef(1F, 1F / fract, 1F); - } } diff --git a/src/main/java/vazkii/botania/client/model/ModelBlackHoleCube.java b/src/main/java/vazkii/botania/client/model/ModelBlackHoleCube.java index a1e7f58de1..1c770b3b3c 100644 --- a/src/main/java/vazkii/botania/client/model/ModelBlackHoleCube.java +++ b/src/main/java/vazkii/botania/client/model/ModelBlackHoleCube.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [? (GMT)] */ package vazkii.botania.client.model; @@ -15,87 +15,88 @@ import net.minecraft.entity.Entity; public class ModelBlackHoleCube extends ModelBase { - public ModelRenderer shape1; - public ModelRenderer shape1_1; - public ModelRenderer shape1_2; - public ModelRenderer shape1_3; - public ModelRenderer shape1_4; - public ModelRenderer shape1_5; - public ModelRenderer shape1_6; - public ModelRenderer shape1_7; - public ModelRenderer shape1_8; - public ModelRenderer shape1_9; - public ModelRenderer shape1_10; - public ModelRenderer shape1_11; + public ModelRenderer shape1; + public ModelRenderer shape1_1; + public ModelRenderer shape1_2; + public ModelRenderer shape1_3; + public ModelRenderer shape1_4; + public ModelRenderer shape1_5; + public ModelRenderer shape1_6; + public ModelRenderer shape1_7; + public ModelRenderer shape1_8; + public ModelRenderer shape1_9; + public ModelRenderer shape1_10; + public ModelRenderer shape1_11; - public ModelBlackHoleCube() { - textureWidth = 36; - textureHeight = 2; - shape1_3 = new ModelRenderer(this, 0, 0); - shape1_3.setRotationPoint(0.0F, 16.0F, 0.0F); - shape1_3.addBox(-7.0F, 7.0F, -8.0F, 14, 1, 1, 0.0F); - setRotateAngle(shape1_3, 0.0F, 1.5707963267948966F, 0.0F); - shape1_7 = new ModelRenderer(this, 0, 0); - shape1_7.setRotationPoint(0.0F, 16.0F, 0.0F); - shape1_7.addBox(-7.0F, -8.0F, -8.0F, 14, 1, 1, 0.0F); - setRotateAngle(shape1_7, 0.0F, 1.5707963267948966F, 0.0F); - shape1_9 = new ModelRenderer(this, 0, 0); - shape1_9.setRotationPoint(0.0F, 16.0F, 0.0F); - shape1_9.addBox(-7.0F, 7.0F, 7.0F, 14, 1, 1, 0.0F); - setRotateAngle(shape1_9, 0.0F, 3.141592653589793F, 1.5707963267948966F); - shape1_11 = new ModelRenderer(this, 0, 0); - shape1_11.setRotationPoint(0.0F, 16.0F, 0.0F); - shape1_11.addBox(-7.0F, 7.0F, -8.0F, 14, 1, 1, 0.0F); - setRotateAngle(shape1_11, 0.0F, 3.141592653589793F, 1.5707963267948966F); - shape1 = new ModelRenderer(this, 0, 0); - shape1.setRotationPoint(0.0F, 16.0F, 0.0F); - shape1.addBox(-8.0F, 7.0F, 7.0F, 16, 1, 1, 0.0F); - shape1_4 = new ModelRenderer(this, 0, 0); - shape1_4.setRotationPoint(0.0F, 16.0F, 0.0F); - shape1_4.addBox(-8.0F, 7.0F, -8.0F, 16, 1, 1, 0.0F); - shape1_8 = new ModelRenderer(this, 0, 0); - shape1_8.setRotationPoint(0.0F, 16.0F, 0.0F); - shape1_8.addBox(-7.0F, -8.0F, -8.0F, 14, 1, 1, 0.0F); - setRotateAngle(shape1_8, 0.0F, 3.141592653589793F, 1.5707963267948966F); - shape1_2 = new ModelRenderer(this, 0, 0); - shape1_2.setRotationPoint(0.0F, 16.0F, 0.0F); - shape1_2.addBox(-8.0F, -8.0F, -8.0F, 16, 1, 1, 0.0F); - shape1_1 = new ModelRenderer(this, 0, 0); - shape1_1.setRotationPoint(0.0F, 16.0F, 0.0F); - shape1_1.addBox(-8.0F, -8.0F, 7.0F, 16, 1, 1, 0.0F); - shape1_6 = new ModelRenderer(this, 0, 0); - shape1_6.setRotationPoint(0.0F, 16.0F, 0.0F); - shape1_6.addBox(-7.0F, -8.0F, -8.0F, 14, 1, 1, 0.0F); - setRotateAngle(shape1_6, 0.0F, -1.5707963267948966F, 0.0F); - shape1_10 = new ModelRenderer(this, 0, 0); - shape1_10.setRotationPoint(0.0F, 16.0F, 0.0F); - shape1_10.addBox(-7.0F, -8.0F, 7.0F, 14, 1, 1, 0.0F); - setRotateAngle(shape1_10, 0.0F, 3.141592653589793F, 1.5707963267948966F); - shape1_5 = new ModelRenderer(this, 0, 0); - shape1_5.setRotationPoint(0.0F, 16.0F, 0.0F); - shape1_5.addBox(-7.0F, 7.0F, -8.0F, 14, 1, 1, 0.0F); - setRotateAngle(shape1_5, 0.0F, -1.5707963267948966F, 0.0F); - } + public ModelBlackHoleCube() { + textureWidth = 36; + textureHeight = 2; + shape1_3 = new ModelRenderer(this, 0, 0); + shape1_3.setRotationPoint(0.0F, 16.0F, 0.0F); + shape1_3.addBox(-7.0F, 7.0F, -8.0F, 14, 1, 1, 0.0F); + setRotateAngle(shape1_3, 0.0F, 1.5707963267948966F, 0.0F); + shape1_7 = new ModelRenderer(this, 0, 0); + shape1_7.setRotationPoint(0.0F, 16.0F, 0.0F); + shape1_7.addBox(-7.0F, -8.0F, -8.0F, 14, 1, 1, 0.0F); + setRotateAngle(shape1_7, 0.0F, 1.5707963267948966F, 0.0F); + shape1_9 = new ModelRenderer(this, 0, 0); + shape1_9.setRotationPoint(0.0F, 16.0F, 0.0F); + shape1_9.addBox(-7.0F, 7.0F, 7.0F, 14, 1, 1, 0.0F); + setRotateAngle(shape1_9, 0.0F, 3.141592653589793F, 1.5707963267948966F); + shape1_11 = new ModelRenderer(this, 0, 0); + shape1_11.setRotationPoint(0.0F, 16.0F, 0.0F); + shape1_11.addBox(-7.0F, 7.0F, -8.0F, 14, 1, 1, 0.0F); + setRotateAngle(shape1_11, 0.0F, 3.141592653589793F, 1.5707963267948966F); + shape1 = new ModelRenderer(this, 0, 0); + shape1.setRotationPoint(0.0F, 16.0F, 0.0F); + shape1.addBox(-8.0F, 7.0F, 7.0F, 16, 1, 1, 0.0F); + shape1_4 = new ModelRenderer(this, 0, 0); + shape1_4.setRotationPoint(0.0F, 16.0F, 0.0F); + shape1_4.addBox(-8.0F, 7.0F, -8.0F, 16, 1, 1, 0.0F); + shape1_8 = new ModelRenderer(this, 0, 0); + shape1_8.setRotationPoint(0.0F, 16.0F, 0.0F); + shape1_8.addBox(-7.0F, -8.0F, -8.0F, 14, 1, 1, 0.0F); + setRotateAngle(shape1_8, 0.0F, 3.141592653589793F, 1.5707963267948966F); + shape1_2 = new ModelRenderer(this, 0, 0); + shape1_2.setRotationPoint(0.0F, 16.0F, 0.0F); + shape1_2.addBox(-8.0F, -8.0F, -8.0F, 16, 1, 1, 0.0F); + shape1_1 = new ModelRenderer(this, 0, 0); + shape1_1.setRotationPoint(0.0F, 16.0F, 0.0F); + shape1_1.addBox(-8.0F, -8.0F, 7.0F, 16, 1, 1, 0.0F); + shape1_6 = new ModelRenderer(this, 0, 0); + shape1_6.setRotationPoint(0.0F, 16.0F, 0.0F); + shape1_6.addBox(-7.0F, -8.0F, -8.0F, 14, 1, 1, 0.0F); + setRotateAngle(shape1_6, 0.0F, -1.5707963267948966F, 0.0F); + shape1_10 = new ModelRenderer(this, 0, 0); + shape1_10.setRotationPoint(0.0F, 16.0F, 0.0F); + shape1_10.addBox(-7.0F, -8.0F, 7.0F, 14, 1, 1, 0.0F); + setRotateAngle(shape1_10, 0.0F, 3.141592653589793F, 1.5707963267948966F); + shape1_5 = new ModelRenderer(this, 0, 0); + shape1_5.setRotationPoint(0.0F, 16.0F, 0.0F); + shape1_5.addBox(-7.0F, 7.0F, -8.0F, 14, 1, 1, 0.0F); + setRotateAngle(shape1_5, 0.0F, -1.5707963267948966F, 0.0F); + } - @Override - public void render(Entity entity, float f, float f1, float f2, float f3, float f4, float f5) { - shape1_3.render(f5); - shape1_7.render(f5); - shape1_9.render(f5); - shape1_11.render(f5); - shape1.render(f5); - shape1_4.render(f5); - shape1_8.render(f5); - shape1_2.render(f5); - shape1_1.render(f5); - shape1_6.render(f5); - shape1_10.render(f5); - shape1_5.render(f5); - } + @Override + public void render(Entity entity, float f, float f1, float f2, float f3, float f4, float f5) { + shape1_3.render(f5); + shape1_7.render(f5); + shape1_9.render(f5); + shape1_11.render(f5); + shape1.render(f5); + shape1_4.render(f5); + shape1_8.render(f5); + shape1_2.render(f5); + shape1_1.render(f5); + shape1_6.render(f5); + shape1_10.render(f5); + shape1_5.render(f5); + } - public void setRotateAngle(ModelRenderer modelRenderer, float x, float y, float z) { - modelRenderer.rotateAngleX = x; - modelRenderer.rotateAngleY = y; - modelRenderer.rotateAngleZ = z; - } + + public void setRotateAngle(ModelRenderer modelRenderer, float x, float y, float z) { + modelRenderer.rotateAngleX = x; + modelRenderer.rotateAngleY = y; + modelRenderer.rotateAngleZ = z; + } } diff --git a/src/main/java/vazkii/botania/client/model/ModelBrewery.java b/src/main/java/vazkii/botania/client/model/ModelBrewery.java index 3c6134b2f1..aa24757c4b 100644 --- a/src/main/java/vazkii/botania/client/model/ModelBrewery.java +++ b/src/main/java/vazkii/botania/client/model/ModelBrewery.java @@ -2,97 +2,101 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Oct 31, 2014, 4:33:55 PM (GMT)] */ package vazkii.botania.client.model; import net.minecraft.client.model.ModelBase; import net.minecraft.client.model.ModelRenderer; + import org.lwjgl.opengl.GL11; + import vazkii.botania.client.render.tile.RenderTileBrewery; public class ModelBrewery extends ModelBase { - ModelRenderer Pole; - ModelRenderer Top; - ModelRenderer Bottom; - ModelRenderer Plate; - - public ModelBrewery() { - textureWidth = 64; - textureHeight = 32; - - Pole = new ModelRenderer(this, 0, 6); - Pole.addBox(0F, 0F, 0F, 2, 10, 2); - Pole.setRotationPoint(-1F, 10F, -1F); - Pole.setTextureSize(64, 32); - Top = new ModelRenderer(this, 18, 0); - Top.addBox(0F, 0F, 0F, 4, 1, 4); - Top.setRotationPoint(-2F, 9F, -2F); - Top.setTextureSize(64, 32); - Bottom = new ModelRenderer(this, 18, 7); - Bottom.addBox(0F, 0F, 0F, 4, 1, 4); - Bottom.setRotationPoint(-2F, 20F, -2F); - Bottom.setTextureSize(64, 32); - Plate = new ModelRenderer(this, 0, 0); - Plate.addBox(5F, 0F, -2F, 4, 1, 4); - Plate.setRotationPoint(0F, 17F, 0F); - Plate.setTextureSize(64, 32); - } - - public void render(RenderTileBrewery render, double time) { - float f = 1F / 16F; - - float offset = (float) Math.sin(time / 40) * 0.1F + 0.05F; - int plates = render.brewery.getSizeInventory() - 1; - float deg = (float) time / 16F; - float polerot = -deg * 25F; - - GL11.glTranslatef(0F, offset, 0F); - GL11.glRotatef(polerot, 0F, 1F, 0F); - if (render.brewery.getStackInSlot(0) != null) { - GL11.glRotatef(180F, 1F, 0F, 0F); - GL11.glTranslatef(-1F / 8F, -0.5F, 1F / 128F); - render.renderItemStack(render.brewery.getStackInSlot(0)); - GL11.glTranslatef(1F / 8F, 0.5F, -1F / 128F); - GL11.glRotatef(-180F, 1F, 0F, 0F); - } - - Pole.render(f); - Top.render(f); - Bottom.render(f); - GL11.glRotatef(-polerot, 0F, 1F, 0F); - - float degper = (float) (2F * Math.PI) / plates; - for (int i = 0; i < plates; i++) { - Plate.rotateAngleY = deg; - float offset1 = (float) Math.sin(time / 20 + i * 40F) * 0.2F - 0.2F; - if (time == -1) offset1 = 0F; - - GL11.glTranslatef(0F, offset1, 0F); - if (render.brewery.getStackInSlot(i + 1) != null) { - float rot = Plate.rotateAngleY * 180F / (float) Math.PI; - float transX = 0.3125F; - float transY = 1.06F; - float transZ = 0.1245F; - GL11.glRotatef(rot, 0F, 1F, 0F); - GL11.glTranslatef(transX, transY, transZ); - GL11.glRotatef(-90F, 1F, 0F, 0F); - render.renderItemStack(render.brewery.getStackInSlot(i + 1)); - GL11.glRotatef(90F, 1F, 0F, 0F); - GL11.glTranslatef(-transX, -transY, -transZ); - GL11.glRotatef(-rot, 0F, 1F, 0F); - } - - Plate.render(f); - GL11.glTranslatef(0F, -offset1, 0F); - - deg += degper; - } - GL11.glTranslatef(0F, -offset, 0F); - } + ModelRenderer Pole; + ModelRenderer Top; + ModelRenderer Bottom; + ModelRenderer Plate; + + public ModelBrewery() { + textureWidth = 64; + textureHeight = 32; + + Pole = new ModelRenderer(this, 0, 6); + Pole.addBox(0F, 0F, 0F, 2, 10, 2); + Pole.setRotationPoint(-1F, 10F, -1F); + Pole.setTextureSize(64, 32); + Top = new ModelRenderer(this, 18, 0); + Top.addBox(0F, 0F, 0F, 4, 1, 4); + Top.setRotationPoint(-2F, 9F, -2F); + Top.setTextureSize(64, 32); + Bottom = new ModelRenderer(this, 18, 7); + Bottom.addBox(0F, 0F, 0F, 4, 1, 4); + Bottom.setRotationPoint(-2F, 20F, -2F); + Bottom.setTextureSize(64, 32); + Plate = new ModelRenderer(this, 0, 0); + Plate.addBox(5F, 0F, -2F, 4, 1, 4); + Plate.setRotationPoint(0F, 17F, 0F); + Plate.setTextureSize(64, 32); + } + + public void render(RenderTileBrewery render, double time) { + float f = 1F / 16F; + + float offset = (float) Math.sin(time / 40) * 0.1F + 0.05F; + int plates = render.brewery.getSizeInventory() - 1; + float deg = (float) time / 16F; + float polerot = -deg * 25F; + + GL11.glTranslatef(0F, offset, 0F); + GL11.glRotatef(polerot, 0F, 1F, 0F); + if(render.brewery.getStackInSlot(0) != null) { + GL11.glRotatef(180F, 1F, 0F, 0F); + GL11.glTranslatef(-1F / 8F, -0.5F, 1F / 128F); + render.renderItemStack(render.brewery.getStackInSlot(0)); + GL11.glTranslatef(1F / 8F, 0.5F, -1F / 128F); + GL11.glRotatef(-180F, 1F, 0F, 0F); + } + + Pole.render(f); + Top.render(f); + Bottom.render(f); + GL11.glRotatef(-polerot, 0F, 1F, 0F); + + float degper = (float) (2F * Math.PI) / plates; + for(int i = 0; i < plates; i++) { + Plate.rotateAngleY = deg; + float offset1 = (float) Math.sin(time / 20 + i * 40F) * 0.2F - 0.2F; + if(time == -1) + offset1 = 0F; + + GL11.glTranslatef(0F, offset1, 0F); + if(render.brewery.getStackInSlot(i + 1) != null) { + float rot = Plate.rotateAngleY * 180F / (float) Math.PI; + float transX = 0.3125F; + float transY = 1.06F; + float transZ = 0.1245F; + GL11.glRotatef(rot, 0F, 1F, 0F); + GL11.glTranslatef(transX, transY, transZ); + GL11.glRotatef(-90F, 1F, 0F, 0F); + render.renderItemStack(render.brewery.getStackInSlot(i + 1)); + GL11.glRotatef(90F, 1F, 0F, 0F); + GL11.glTranslatef(-transX, -transY, -transZ); + GL11.glRotatef(-rot, 0F, 1F, 0F); + } + + Plate.render(f); + GL11.glTranslatef(0F, -offset1, 0F); + + deg += degper; + } + GL11.glTranslatef(0F, -offset, 0F); + } + } diff --git a/src/main/java/vazkii/botania/client/model/ModelCocoon.java b/src/main/java/vazkii/botania/client/model/ModelCocoon.java index 484a449c4a..2fbc79c1bd 100644 --- a/src/main/java/vazkii/botania/client/model/ModelCocoon.java +++ b/src/main/java/vazkii/botania/client/model/ModelCocoon.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [? (GMT)] */ package vazkii.botania.client.model; @@ -15,17 +15,18 @@ public class ModelCocoon extends ModelBase { - public ModelRenderer shape; + public ModelRenderer shape; - public ModelCocoon() { - textureWidth = 64; - textureHeight = 32; - shape = new ModelRenderer(this, 0, 0); - shape.setRotationPoint(0.0F, 22.0F, 0.0F); - shape.addBox(-5.0F, -8.0F, -7.0F, 10, 10, 14, 0.0F); - } + public ModelCocoon() { + textureWidth = 64; + textureHeight = 32; + shape = new ModelRenderer(this, 0, 0); + shape.setRotationPoint(0.0F, 22.0F, 0.0F); + shape.addBox(-5.0F, -8.0F, -7.0F, 10, 10, 14, 0.0F); + } + + public void render() { + shape.render(1F / 16F); + } - public void render() { - shape.render(1F / 16F); - } } diff --git a/src/main/java/vazkii/botania/client/model/ModelCrystalCube.java b/src/main/java/vazkii/botania/client/model/ModelCrystalCube.java index ae87545ecd..80addf965e 100644 --- a/src/main/java/vazkii/botania/client/model/ModelCrystalCube.java +++ b/src/main/java/vazkii/botania/client/model/ModelCrystalCube.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [? (GMT)] */ package vazkii.botania.client.model; @@ -14,38 +14,38 @@ import net.minecraft.client.model.ModelRenderer; public class ModelCrystalCube extends ModelBase { - public ModelRenderer cube; - public ModelRenderer base1; - public ModelRenderer base2; + public ModelRenderer cube; + public ModelRenderer base1; + public ModelRenderer base2; - public ModelCrystalCube() { - textureWidth = 48; - textureHeight = 32; - cube = new ModelRenderer(this, 0, 0); - cube.setRotationPoint(0.0F, 12.0F, 0.0F); - cube.addBox(-4.0F, -4.0F, -4.0F, 8, 8, 8, 0.0F); - base1 = new ModelRenderer(this, 22, 0); - base1.setRotationPoint(0.0F, 16.0F, 0.0F); - base1.addBox(-3.0F, 7.0F, -3.0F, 6, 1, 6, 0.0F); - base2 = new ModelRenderer(this, 0, 16); - base2.setRotationPoint(0.0F, 0.0F, 0.0F); - base2.addBox(-5.0F, 3.0F, -5.0F, 10, 4, 10, 0.0F); - base1.addChild(base2); - } + public ModelCrystalCube() { + textureWidth = 48; + textureHeight = 32; + cube = new ModelRenderer(this, 0, 0); + cube.setRotationPoint(0.0F, 12.0F, 0.0F); + cube.addBox(-4.0F, -4.0F, -4.0F, 8, 8, 8, 0.0F); + base1 = new ModelRenderer(this, 22, 0); + base1.setRotationPoint(0.0F, 16.0F, 0.0F); + base1.addBox(-3.0F, 7.0F, -3.0F, 6, 1, 6, 0.0F); + base2 = new ModelRenderer(this, 0, 16); + base2.setRotationPoint(0.0F, 0.0F, 0.0F); + base2.addBox(-5.0F, 3.0F, -5.0F, 10, 4, 10, 0.0F); + base1.addChild(base2); + } - public void renderBase() { - float f5 = 1F / 16F; - base1.render(f5); - } + public void renderBase() { + float f5 = 1F / 16F; + base1.render(f5); + } - public void renderCube() { - float f5 = 1F / 16F; - cube.render(f5); - } + public void renderCube() { + float f5 = 1F / 16F; + cube.render(f5); + } - public void setRotateAngle(ModelRenderer modelRenderer, float x, float y, float z) { - modelRenderer.rotateAngleX = x; - modelRenderer.rotateAngleY = y; - modelRenderer.rotateAngleZ = z; - } + public void setRotateAngle(ModelRenderer modelRenderer, float x, float y, float z) { + modelRenderer.rotateAngleX = x; + modelRenderer.rotateAngleY = y; + modelRenderer.rotateAngleZ = z; + } } diff --git a/src/main/java/vazkii/botania/client/model/ModelHourglass.java b/src/main/java/vazkii/botania/client/model/ModelHourglass.java index 2b457f0924..a1ca14ddc7 100644 --- a/src/main/java/vazkii/botania/client/model/ModelHourglass.java +++ b/src/main/java/vazkii/botania/client/model/ModelHourglass.java @@ -2,100 +2,105 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [? (GMT)] */ package vazkii.botania.client.model; import java.awt.Color; + import net.minecraft.client.model.ModelBase; import net.minecraft.client.model.ModelRenderer; + import org.lwjgl.opengl.GL11; public class ModelHourglass extends ModelBase { - public ModelRenderer ring; - public ModelRenderer base1; - public ModelRenderer base2; - public ModelRenderer glass1; - public ModelRenderer sand1; - public ModelRenderer glass2; - public ModelRenderer sand2; + public ModelRenderer ring; + public ModelRenderer base1; + public ModelRenderer base2; + public ModelRenderer glass1; + public ModelRenderer sand1; + public ModelRenderer glass2; + public ModelRenderer sand2; + + public ModelHourglass() { + textureWidth = 48; + textureHeight = 24; + sand2 = new ModelRenderer(this, 24, 0); + sand2.setRotationPoint(0.0F, 0.0F, 0.0F); + sand2.addBox(0F, 0F, 0F, 5, 5, 5, 0.0F); // -2.5F, 1.0F, -2.5F + sand1 = new ModelRenderer(this, 24, 0); + sand1.setRotationPoint(0.0F, 0.0F, 0.0F); + sand1.addBox(0F, 0F, 0F, 5, 5, 5, 0.0F); // -2.5F, -6.0F, -2.5F + glass1 = new ModelRenderer(this, 0, 0); + glass1.setRotationPoint(0.0F, 0.0F, 0.0F); + glass1.addBox(-3.0F, -6.501F, -3.0F, 6, 6, 6, 0.0F); + base2 = new ModelRenderer(this, 0, 12); + base2.setRotationPoint(0.0F, 0.0F, 0.0F); + base2.addBox(-3.5F, 6.502F, -3.5F, 7, 1, 7, 0.0F); + base1 = new ModelRenderer(this, 0, 12); + base1.setRotationPoint(0.0F, 0.0F, 0.0F); + base1.addBox(-3.5F, -7.502F, -3.5F, 7, 1, 7, 0.0F); + ring = new ModelRenderer(this, 28, 12); + ring.setRotationPoint(0.0F, 15.5F, 0.0F); + ring.addBox(-2.0F, -16F, -2.0F, 4, 1, 4, 0.0F); + glass2 = new ModelRenderer(this, 0, 0); + glass2.setRotationPoint(0.0F, 0.0F, 0.0F); + glass2.addBox(-3.0F, 0.501F, -3.0F, 6, 6, 6, 0.0F); + } - public ModelHourglass() { - textureWidth = 48; - textureHeight = 24; - sand2 = new ModelRenderer(this, 24, 0); - sand2.setRotationPoint(0.0F, 0.0F, 0.0F); - sand2.addBox(0F, 0F, 0F, 5, 5, 5, 0.0F); // -2.5F, 1.0F, -2.5F - sand1 = new ModelRenderer(this, 24, 0); - sand1.setRotationPoint(0.0F, 0.0F, 0.0F); - sand1.addBox(0F, 0F, 0F, 5, 5, 5, 0.0F); // -2.5F, -6.0F, -2.5F - glass1 = new ModelRenderer(this, 0, 0); - glass1.setRotationPoint(0.0F, 0.0F, 0.0F); - glass1.addBox(-3.0F, -6.501F, -3.0F, 6, 6, 6, 0.0F); - base2 = new ModelRenderer(this, 0, 12); - base2.setRotationPoint(0.0F, 0.0F, 0.0F); - base2.addBox(-3.5F, 6.502F, -3.5F, 7, 1, 7, 0.0F); - base1 = new ModelRenderer(this, 0, 12); - base1.setRotationPoint(0.0F, 0.0F, 0.0F); - base1.addBox(-3.5F, -7.502F, -3.5F, 7, 1, 7, 0.0F); - ring = new ModelRenderer(this, 28, 12); - ring.setRotationPoint(0.0F, 15.5F, 0.0F); - ring.addBox(-2.0F, -16F, -2.0F, 4, 1, 4, 0.0F); - glass2 = new ModelRenderer(this, 0, 0); - glass2.setRotationPoint(0.0F, 0.0F, 0.0F); - glass2.addBox(-3.0F, 0.501F, -3.0F, 6, 6, 6, 0.0F); - } + public void render(float fract1, float fract2, boolean flip, int color) { + if(flip) { + float fract3 = fract1; + fract1 = fract2; + fract2 = fract3; + } - public void render(float fract1, float fract2, boolean flip, int color) { - if (flip) { - float fract3 = fract1; - fract1 = fract2; - fract2 = fract3; - } + float f = 1F / 16F; + ring.render(f); + base1.render(f); + base2.render(f); + Color c = new Color(color); + GL11.glColor3ub((byte) c.getRed(), (byte) c.getGreen(), (byte) c.getBlue()); + GL11.glPushAttrib(GL11.GL_NORMALIZE); + GL11.glEnable(GL11.GL_NORMALIZE); - float f = 1F / 16F; - ring.render(f); - base1.render(f); - base2.render(f); - Color c = new Color(color); - GL11.glColor3ub((byte) c.getRed(), (byte) c.getGreen(), (byte) c.getBlue()); - GL11.glPushAttrib(GL11.GL_NORMALIZE); - GL11.glEnable(GL11.GL_NORMALIZE); + if(fract1 > 0) { + GL11.glPushMatrix(); + if(flip) + GL11.glTranslatef(-2.5F * f, 1.0F * f, -2.5F * f); + else { + GL11.glRotatef(180F, 0F, 0F, 1F); + GL11.glTranslatef(-2.5F * f, -6.0F * f, -2.5F * f); + } - if (fract1 > 0) { - GL11.glPushMatrix(); - if (flip) GL11.glTranslatef(-2.5F * f, 1.0F * f, -2.5F * f); - else { - GL11.glRotatef(180F, 0F, 0F, 1F); - GL11.glTranslatef(-2.5F * f, -6.0F * f, -2.5F * f); - } + GL11.glScalef(1F, fract1, 1F); + sand1.render(f); + GL11.glPopMatrix(); + } - GL11.glScalef(1F, fract1, 1F); - sand1.render(f); - GL11.glPopMatrix(); - } + if(fract2 > 0) { + GL11.glPushMatrix(); + if(flip) + GL11.glTranslatef(-2.5F * f, -6.0F * f, -2.5F * f); + else { + GL11.glRotatef(180F, 0F, 0F, 1F); + GL11.glTranslatef(-2.5F * f, 1.0F * f, -2.5F * f); + } - if (fract2 > 0) { - GL11.glPushMatrix(); - if (flip) GL11.glTranslatef(-2.5F * f, -6.0F * f, -2.5F * f); - else { - GL11.glRotatef(180F, 0F, 0F, 1F); - GL11.glTranslatef(-2.5F * f, 1.0F * f, -2.5F * f); - } + GL11.glScalef(1F, fract2, 1F); + sand2.render(f); + GL11.glPopMatrix(); + } - GL11.glScalef(1F, fract2, 1F); - sand2.render(f); - GL11.glPopMatrix(); - } + GL11.glPopAttrib(); + GL11.glColor3f(1F, 1F, 1F); + glass1.render(f); + glass2.render(f); + } - GL11.glPopAttrib(); - GL11.glColor3f(1F, 1F, 1F); - glass1.render(f); - glass2.render(f); - } } diff --git a/src/main/java/vazkii/botania/client/model/ModelIncensePlate.java b/src/main/java/vazkii/botania/client/model/ModelIncensePlate.java index 02e2363adb..d7fa2eadb3 100644 --- a/src/main/java/vazkii/botania/client/model/ModelIncensePlate.java +++ b/src/main/java/vazkii/botania/client/model/ModelIncensePlate.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [May 15, 2015, 4:17:37 PM (GMT)] */ package vazkii.botania.client.model; @@ -15,28 +15,29 @@ public class ModelIncensePlate extends ModelBase { - ModelRenderer Plate; - ModelRenderer High; + ModelRenderer Plate; + ModelRenderer High; - public ModelIncensePlate() { - textureWidth = 64; - textureHeight = 32; + public ModelIncensePlate() { + textureWidth = 64; + textureHeight = 32; - Plate = new ModelRenderer(this, 0, 0); - Plate.addBox(0F, 0F, 0F, 12, 1, 4); - Plate.setRotationPoint(-6F, 23F, -2F); - Plate.setTextureSize(64, 32); - Plate.mirror = true; - High = new ModelRenderer(this, 0, 6); - High.addBox(0F, 0F, 0F, 3, 1, 4); - High.setRotationPoint(-6F, 22F, -2F); - High.setTextureSize(64, 32); - High.mirror = true; - } + Plate = new ModelRenderer(this, 0, 0); + Plate.addBox(0F, 0F, 0F, 12, 1, 4); + Plate.setRotationPoint(-6F, 23F, -2F); + Plate.setTextureSize(64, 32); + Plate.mirror = true; + High = new ModelRenderer(this, 0, 6); + High.addBox(0F, 0F, 0F, 3, 1, 4); + High.setRotationPoint(-6F, 22F, -2F); + High.setTextureSize(64, 32); + High.mirror = true; + } + + public void render() { + float f5 = 1F / 16F; + Plate.render(f5); + High.render(f5); + } - public void render() { - float f5 = 1F / 16F; - Plate.render(f5); - High.render(f5); - } } diff --git a/src/main/java/vazkii/botania/client/model/ModelMiniIsland.java b/src/main/java/vazkii/botania/client/model/ModelMiniIsland.java index 99912b1e4f..4b9f2c19cb 100644 --- a/src/main/java/vazkii/botania/client/model/ModelMiniIsland.java +++ b/src/main/java/vazkii/botania/client/model/ModelMiniIsland.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jul 8, 2014, 10:07:54 PM (GMT)] */ package vazkii.botania.client.model; @@ -15,69 +15,70 @@ public class ModelMiniIsland extends ModelBase { - ModelRenderer island; + ModelRenderer island; - public ModelMiniIsland() { - textureWidth = 64; - textureHeight = 32; + public ModelMiniIsland() { + textureWidth = 64; + textureHeight = 32; - setTextureOffset("island.Shape0", 0, 0); - setTextureOffset("island.Shape1-1", 8, 0); - setTextureOffset("island.Shape1-2", 16, 0); - setTextureOffset("island.Shape1-3", 24, 0); - setTextureOffset("island.Shape1-4", 32, 0); - setTextureOffset("island.Shape2-1", 8, 6); - setTextureOffset("island.Shape2-2", 16, 6); - setTextureOffset("island.Shape2-3", 24, 6); - setTextureOffset("island.Shape2-4", 32, 6); - setTextureOffset("island.Shape2-5", 8, 11); - setTextureOffset("island.Shape2-6", 16, 11); - setTextureOffset("island.Shape2-7", 24, 11); - setTextureOffset("island.Shape2-8", 32, 11); - setTextureOffset("island.Shape3-1", 8, 16); - setTextureOffset("island.Shape3-2", 16, 16); - setTextureOffset("island.Shape3-3", 24, 16); - setTextureOffset("island.Shape3-4", 32, 16); - setTextureOffset("island.Shape3-5", 8, 20); - setTextureOffset("island.Shape3-6", 16, 20); - setTextureOffset("island.Shape3-7", 24, 20); - setTextureOffset("island.Shape3-8", 32, 20); - setTextureOffset("island.Shape4-1", 8, 24); - setTextureOffset("island.Shape4-2", 16, 24); - setTextureOffset("island.Shape4-3", 24, 24); - setTextureOffset("island.Shape4-4", 32, 24); + setTextureOffset("island.Shape0", 0, 0); + setTextureOffset("island.Shape1-1", 8, 0); + setTextureOffset("island.Shape1-2", 16, 0); + setTextureOffset("island.Shape1-3", 24, 0); + setTextureOffset("island.Shape1-4", 32, 0); + setTextureOffset("island.Shape2-1", 8, 6); + setTextureOffset("island.Shape2-2", 16, 6); + setTextureOffset("island.Shape2-3", 24, 6); + setTextureOffset("island.Shape2-4", 32, 6); + setTextureOffset("island.Shape2-5", 8, 11); + setTextureOffset("island.Shape2-6", 16, 11); + setTextureOffset("island.Shape2-7", 24, 11); + setTextureOffset("island.Shape2-8", 32, 11); + setTextureOffset("island.Shape3-1", 8, 16); + setTextureOffset("island.Shape3-2", 16, 16); + setTextureOffset("island.Shape3-3", 24, 16); + setTextureOffset("island.Shape3-4", 32, 16); + setTextureOffset("island.Shape3-5", 8, 20); + setTextureOffset("island.Shape3-6", 16, 20); + setTextureOffset("island.Shape3-7", 24, 20); + setTextureOffset("island.Shape3-8", 32, 20); + setTextureOffset("island.Shape4-1", 8, 24); + setTextureOffset("island.Shape4-2", 16, 24); + setTextureOffset("island.Shape4-3", 24, 24); + setTextureOffset("island.Shape4-4", 32, 24); - island = new ModelRenderer(this, "island"); - island.setRotationPoint(0F, 16F, 0F); - // island.mirror = true; - island.addBox("Shape0", -1F, 0F, -1F, 2, 5, 2); - island.addBox("Shape1-1", -1F, 0F, -3F, 2, 4, 2); - island.addBox("Shape1-2", 1F, 0F, -1F, 2, 4, 2); - island.addBox("Shape1-3", -1F, 0F, 1F, 2, 4, 2); - island.addBox("Shape1-4", -3F, 0F, -1F, 2, 4, 2); - island.addBox("Shape2-1", -1F, 0F, -5F, 2, 3, 2); - island.addBox("Shape2-2", 3F, 0F, -1F, 2, 3, 2); - island.addBox("Shape2-3", -1F, 0F, 3F, 2, 3, 2); - island.addBox("Shape2-4", -5F, 0F, -1F, 2, 3, 2); - island.addBox("Shape2-5", 1F, 0F, -3F, 2, 3, 2); - island.addBox("Shape2-6", 1F, 0F, 1F, 2, 3, 2); - island.addBox("Shape2-7", -3F, 0F, 1F, 2, 3, 2); - island.addBox("Shape2-8", -3F, 0F, -3F, 2, 3, 2); - island.addBox("Shape3-1", 1F, 0F, -5F, 2, 2, 2); - island.addBox("Shape3-2", 3F, 0F, 1F, 2, 2, 2); - island.addBox("Shape3-3", -3F, 0F, 3F, 2, 2, 2); - island.addBox("Shape3-4", -5F, 0F, -3F, 2, 2, 2); - island.addBox("Shape3-5", 3F, 0F, -3F, 2, 2, 2); - island.addBox("Shape3-6", 1F, 0F, 3F, 2, 2, 2); - island.addBox("Shape3-7", -5F, 0F, 1F, 2, 2, 2); - island.addBox("Shape3-8", -3F, 0F, -5F, 2, 2, 2); - island.addBox("Shape4-1", 3F, 0F, -5F, 2, 1, 2); - island.addBox("Shape4-2", 3F, 0F, 3F, 2, 1, 2); - island.addBox("Shape4-3", -5F, 0F, 3F, 2, 1, 2); - island.addBox("Shape4-4", -5F, 0F, -5F, 2, 1, 2); - } + island = new ModelRenderer(this, "island"); + island.setRotationPoint(0F, 16F, 0F); + // island.mirror = true; + island.addBox("Shape0", -1F, 0F, -1F, 2, 5, 2); + island.addBox("Shape1-1", -1F, 0F, -3F, 2, 4, 2); + island.addBox("Shape1-2", 1F, 0F, -1F, 2, 4, 2); + island.addBox("Shape1-3", -1F, 0F, 1F, 2, 4, 2); + island.addBox("Shape1-4", -3F, 0F, -1F, 2, 4, 2); + island.addBox("Shape2-1", -1F, 0F, -5F, 2, 3, 2); + island.addBox("Shape2-2", 3F, 0F, -1F, 2, 3, 2); + island.addBox("Shape2-3", -1F, 0F, 3F, 2, 3, 2); + island.addBox("Shape2-4", -5F, 0F, -1F, 2, 3, 2); + island.addBox("Shape2-5", 1F, 0F, -3F, 2, 3, 2); + island.addBox("Shape2-6", 1F, 0F, 1F, 2, 3, 2); + island.addBox("Shape2-7", -3F, 0F, 1F, 2, 3, 2); + island.addBox("Shape2-8", -3F, 0F, -3F, 2, 3, 2); + island.addBox("Shape3-1", 1F, 0F, -5F, 2, 2, 2); + island.addBox("Shape3-2", 3F, 0F, 1F, 2, 2, 2); + island.addBox("Shape3-3", -3F, 0F, 3F, 2, 2, 2); + island.addBox("Shape3-4", -5F, 0F, -3F, 2, 2, 2); + island.addBox("Shape3-5", 3F, 0F, -3F, 2, 2, 2); + island.addBox("Shape3-6", 1F, 0F, 3F, 2, 2, 2); + island.addBox("Shape3-7", -5F, 0F, 1F, 2, 2, 2); + island.addBox("Shape3-8", -3F, 0F, -5F, 2, 2, 2); + island.addBox("Shape4-1", 3F, 0F, -5F, 2, 1, 2); + island.addBox("Shape4-2", 3F, 0F, 3F, 2, 1, 2); + island.addBox("Shape4-3", -5F, 0F, 3F, 2, 1, 2); + island.addBox("Shape4-4", -5F, 0F, -5F, 2, 1, 2); + } + + public void render() { + island.render(1F / 16F); + } - public void render() { - island.render(1F / 16F); - } } diff --git a/src/main/java/vazkii/botania/client/model/ModelPixie.java b/src/main/java/vazkii/botania/client/model/ModelPixie.java index 72709abdf6..902ab687e9 100644 --- a/src/main/java/vazkii/botania/client/model/ModelPixie.java +++ b/src/main/java/vazkii/botania/client/model/ModelPixie.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [? (GMT)] */ package vazkii.botania.client.model; @@ -17,54 +17,55 @@ public class ModelPixie extends ModelBase { - ModelRenderer Body; - ModelRenderer LeftWing; - ModelRenderer RightWing; + ModelRenderer Body; + ModelRenderer LeftWing; + ModelRenderer RightWing; - public ModelPixie() { - textureWidth = 64; - textureHeight = 32; + public ModelPixie() { + textureWidth = 64; + textureHeight = 32; - Body = new ModelRenderer(this, 0, 0); - Body.addBox(0F, 0F, 0F, 4, 4, 4); - Body.setRotationPoint(-2F, 16F, -2F); - Body.setTextureSize(64, 32); - Body.mirror = true; - setRotation(Body, 0F, 0F, 0F); - LeftWing = new ModelRenderer(this, 32, 0); - LeftWing.addBox(0F, 0F, -1F, 0, 4, 7); - LeftWing.setRotationPoint(2F, 15F, 2F); - LeftWing.setTextureSize(64, 32); - LeftWing.mirror = true; - setRotation(LeftWing, 0F, 0F, 0F); - RightWing = new ModelRenderer(this, 50, 0); - RightWing.addBox(0F, 0F, -1F, 0, 4, 7); - RightWing.setRotationPoint(-2F, 15F, 2F); - RightWing.setTextureSize(64, 32); - RightWing.mirror = true; - setRotation(RightWing, 0F, 0F, 0F); - } + Body = new ModelRenderer(this, 0, 0); + Body.addBox(0F, 0F, 0F, 4, 4, 4); + Body.setRotationPoint(-2F, 16F, -2F); + Body.setTextureSize(64, 32); + Body.mirror = true; + setRotation(Body, 0F, 0F, 0F); + LeftWing = new ModelRenderer(this, 32, 0); + LeftWing.addBox(0F, 0F, -1F, 0, 4, 7); + LeftWing.setRotationPoint(2F, 15F, 2F); + LeftWing.setTextureSize(64, 32); + LeftWing.mirror = true; + setRotation(LeftWing, 0F, 0F, 0F); + RightWing = new ModelRenderer(this, 50, 0); + RightWing.addBox(0F, 0F, -1F, 0, 4, 7); + RightWing.setRotationPoint(-2F, 15F, 2F); + RightWing.setTextureSize(64, 32); + RightWing.mirror = true; + setRotation(RightWing, 0F, 0F, 0F); + } - @Override - public void render(Entity entity, float f, float f1, float f2, float f3, float f4, float f5) { - super.render(entity, f, f1, f2, f3, f4, f5); - setRotationAngles(f, f1, f2, f3, f4, f5, entity); - Body.render(f5); - LeftWing.render(f5); - RightWing.render(f5); - } + @Override + public void render(Entity entity, float f, float f1, float f2, float f3, float f4, float f5) { + super.render(entity, f, f1, f2, f3, f4, f5); + setRotationAngles(f, f1, f2, f3, f4, f5, entity); + Body.render(f5); + LeftWing.render(f5); + RightWing.render(f5); + } - private void setRotation(ModelRenderer model, float x, float y, float z) { - model.rotateAngleX = x; - model.rotateAngleY = y; - model.rotateAngleZ = z; - } + private void setRotation(ModelRenderer model, float x, float y, float z) { + model.rotateAngleX = x; + model.rotateAngleY = y; + model.rotateAngleZ = z; + } - @Override - public void setRotationAngles(float f, float f1, float f2, float f3, float f4, float f5, Entity entity) { - super.setRotationAngles(f, f1, f2, f3, f4, f5, entity); + @Override + public void setRotationAngles(float f, float f1, float f2, float f3, float f4, float f5, Entity entity) { + super.setRotationAngles(f, f1, f2, f3, f4, f5, entity); - RightWing.rotateAngleY = -(MathHelper.cos(f2 * 1.7F) * (float) Math.PI * 0.5F); - LeftWing.rotateAngleY = MathHelper.cos(f2 * 1.7F) * (float) Math.PI * 0.5F; - } -} + RightWing.rotateAngleY = -(MathHelper.cos(f2 * 1.7F) * (float)Math.PI * 0.5F); + LeftWing.rotateAngleY = MathHelper.cos(f2 * 1.7F) * (float)Math.PI * 0.5F; + } + +} \ No newline at end of file diff --git a/src/main/java/vazkii/botania/client/model/ModelPool.java b/src/main/java/vazkii/botania/client/model/ModelPool.java index dff7ccbd00..1cc52537a0 100644 --- a/src/main/java/vazkii/botania/client/model/ModelPool.java +++ b/src/main/java/vazkii/botania/client/model/ModelPool.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jan 25, 2014, 1:53:32 PM (GMT)] */ package vazkii.botania.client.model; @@ -15,44 +15,44 @@ public class ModelPool extends ModelBase { - ModelRenderer base; - ModelRenderer side1; - ModelRenderer side2; - ModelRenderer side3; - ModelRenderer side4; + ModelRenderer base; + ModelRenderer side1; + ModelRenderer side2; + ModelRenderer side3; + ModelRenderer side4; - public ModelPool() { - textureWidth = 64; - textureHeight = 32; + public ModelPool() { + textureWidth = 64; + textureHeight = 32; - base = new ModelRenderer(this, 0, 0); - base.addBox(0F, 0F, 0F, 16, 1, 16); - base.setRotationPoint(-8F, 23F, -8F); - base.setTextureSize(64, 32); - side1 = new ModelRenderer(this, 0, 0); - side1.addBox(0F, 0F, 0F, 16, 7, 1); - side1.setRotationPoint(-8F, 16F, 7F); - side1.setTextureSize(64, 32); - side2 = new ModelRenderer(this, 0, 0); - side2.addBox(0F, 0F, 0F, 16, 7, 1); - side2.setRotationPoint(-8F, 16F, -8F); - side2.setTextureSize(64, 32); - side3 = new ModelRenderer(this, 0, 0); - side3.addBox(0F, 0F, 0F, 1, 7, 14); - side3.setRotationPoint(-8F, 16F, -7F); - side3.setTextureSize(64, 32); - side4 = new ModelRenderer(this, 0, 0); - side4.addBox(0F, 0F, 0F, 1, 7, 14); - side4.setRotationPoint(7F, 16F, -7F); - side4.setTextureSize(64, 32); - } + base = new ModelRenderer(this, 0, 0); + base.addBox(0F, 0F, 0F, 16, 1, 16); + base.setRotationPoint(-8F, 23F, -8F); + base.setTextureSize(64, 32); + side1 = new ModelRenderer(this, 0, 0); + side1.addBox(0F, 0F, 0F, 16, 7, 1); + side1.setRotationPoint(-8F, 16F, 7F); + side1.setTextureSize(64, 32); + side2 = new ModelRenderer(this, 0, 0); + side2.addBox(0F, 0F, 0F, 16, 7, 1); + side2.setRotationPoint(-8F, 16F, -8F); + side2.setTextureSize(64, 32); + side3 = new ModelRenderer(this, 0, 0); + side3.addBox(0F, 0F, 0F, 1, 7, 14); + side3.setRotationPoint(-8F, 16F, -7F); + side3.setTextureSize(64, 32); + side4 = new ModelRenderer(this, 0, 0); + side4.addBox(0F, 0F, 0F, 1, 7, 14); + side4.setRotationPoint(7F, 16F, -7F); + side4.setTextureSize(64, 32); + } - public void render() { - float f = 1F / 16F; - base.render(f); - side1.render(f); - side2.render(f); - side3.render(f); - side4.render(f); - } -} + public void render() { + float f = 1F / 16F; + base.render(f); + side1.render(f); + side2.render(f); + side3.render(f); + side4.render(f); + } +} \ No newline at end of file diff --git a/src/main/java/vazkii/botania/client/model/ModelPump.java b/src/main/java/vazkii/botania/client/model/ModelPump.java index 967be99568..e869a3d5e3 100644 --- a/src/main/java/vazkii/botania/client/model/ModelPump.java +++ b/src/main/java/vazkii/botania/client/model/ModelPump.java @@ -2,65 +2,70 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [? (GMT)] */ package vazkii.botania.client.model; import java.util.ArrayList; + import net.minecraft.client.model.ModelBase; import net.minecraft.client.model.ModelRenderer; -public class ModelPump extends ModelBase { +public class ModelPump extends ModelBase{ + + private ArrayList parts = new ArrayList(); + + private ArrayList innerRing = new ArrayList(); + private ArrayList outerRing = new ArrayList(); - private ArrayList parts = new ArrayList(); + public ModelPump() { + textureWidth = 64; + textureHeight = 32; - private ArrayList innerRing = new ArrayList(); - private ArrayList outerRing = new ArrayList(); + ModelRenderer main = new ModelRenderer(this, 0, 0); + main.addBox(-2.0F, -2.0F, -7.0F, 4, 4, 14); + main.setRotationPoint(0.0F, 4.0F, 0.0F); - public ModelPump() { - textureWidth = 64; - textureHeight = 32; + for(float r = 0; r <= Math.PI * 2; r += Math.PI) { + ModelRenderer side = new ModelRenderer(this, 22, 0); - ModelRenderer main = new ModelRenderer(this, 0, 0); - main.addBox(-2.0F, -2.0F, -7.0F, 4, 4, 14); - main.setRotationPoint(0.0F, 4.0F, 0.0F); + side.addBox(-4.0F, -4.0F, 7.0F, 8, 8, 1); + side.setRotationPoint(0.0F, 0.0F, 0.0F); + side.rotateAngleY = r; + main.addChild(side); + } - for (float r = 0; r <= Math.PI * 2; r += Math.PI) { - ModelRenderer side = new ModelRenderer(this, 22, 0); + for(float r = 0; r <= Math.PI * 2; r += Math.PI / 2) { + ModelRenderer innerPlate = new ModelRenderer(this, 0, 18); + ModelRenderer outerPlate = new ModelRenderer(this, 22, 18); - side.addBox(-4.0F, -4.0F, 7.0F, 8, 8, 1); - side.setRotationPoint(0.0F, 0.0F, 0.0F); - side.rotateAngleY = r; - main.addChild(side); - } + innerPlate.addBox(-3.0F, -3.0F, -7.0F, 5, 1, 6); + innerPlate.setRotationPoint(0.0F, 4.0F, 0.0F); + innerPlate.rotateAngleZ = r; + innerRing.add(innerPlate); + parts.add(innerPlate); - for (float r = 0; r <= Math.PI * 2; r += Math.PI / 2) { - ModelRenderer innerPlate = new ModelRenderer(this, 0, 18); - ModelRenderer outerPlate = new ModelRenderer(this, 22, 18); - innerPlate.addBox(-3.0F, -3.0F, -7.0F, 5, 1, 6); - innerPlate.setRotationPoint(0.0F, 4.0F, 0.0F); - innerPlate.rotateAngleZ = r; - innerRing.add(innerPlate); - parts.add(innerPlate); + outerPlate.addBox(-4.0F, -4.0F, 3.0F, 7, 1, 4); + outerPlate.setRotationPoint(0.0F, 4.0F, 0.0F); + outerPlate.rotateAngleZ = r; + outerRing.add(outerPlate); + parts.add(outerPlate); + } - outerPlate.addBox(-4.0F, -4.0F, 3.0F, 7, 1, 4); - outerPlate.setRotationPoint(0.0F, 4.0F, 0.0F); - outerPlate.rotateAngleZ = r; - outerRing.add(outerPlate); - parts.add(outerPlate); - } + parts.add(main); - parts.add(main); - } + } - public void render(float ringPos) { - for (ModelRenderer iRing : innerRing) iRing.rotationPointZ = ringPos; + public void render(float ringPos) { + for(ModelRenderer iRing : innerRing) + iRing.rotationPointZ = ringPos; - for (ModelRenderer part : parts) part.render(1F / 16F); - } -} + for(ModelRenderer part : parts) + part.render(1F / 16F); + } +} \ No newline at end of file diff --git a/src/main/java/vazkii/botania/client/model/ModelPylon.java b/src/main/java/vazkii/botania/client/model/ModelPylon.java index 3779b423c2..3b90bf3717 100644 --- a/src/main/java/vazkii/botania/client/model/ModelPylon.java +++ b/src/main/java/vazkii/botania/client/model/ModelPylon.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Apr 1, 2014, 6:21:48 PM (GMT)] */ package vazkii.botania.client.model; @@ -17,24 +17,25 @@ public class ModelPylon implements IPylonModel { - private IModelCustom model; + private IModelCustom model; - public ModelPylon() { - model = AdvancedModelLoader.loadModel(new ResourceLocation(LibResources.OBJ_MODEL_PYLON)); - } + public ModelPylon() { + model = AdvancedModelLoader.loadModel(new ResourceLocation(LibResources.OBJ_MODEL_PYLON)); + } - @Override - public void renderCrystal() { - model.renderPart("Crystal"); - } + @Override + public void renderCrystal() { + model.renderPart("Crystal"); + } - @Override - public void renderRing() { - model.renderAllExcept("Crystal", "Ring_Gem01", "Ring_Gem02", "Ring_Gem03", "Ring_Gem04"); - } + @Override + public void renderRing() { + model.renderAllExcept("Crystal", "Ring_Gem01", "Ring_Gem02", "Ring_Gem03", "Ring_Gem04"); + } - @Override - public void renderGems() { - for (int i = 1; i < 5; i++) model.renderPart("Ring_Gem0" + i); - } + @Override + public void renderGems() { + for(int i = 1; i < 5; i++) + model.renderPart("Ring_Gem0" + i); + } } diff --git a/src/main/java/vazkii/botania/client/model/ModelPylonOld.java b/src/main/java/vazkii/botania/client/model/ModelPylonOld.java index 862ae8b083..c600dd261f 100644 --- a/src/main/java/vazkii/botania/client/model/ModelPylonOld.java +++ b/src/main/java/vazkii/botania/client/model/ModelPylonOld.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Feb 18, 2014, 10:05:39 PM (GMT)] */ package vazkii.botania.client.model; @@ -15,143 +15,144 @@ public class ModelPylonOld extends ModelBase implements IPylonModel { - ModelRenderer crystal1; - ModelRenderer crystal2; - ModelRenderer crystal3; - ModelRenderer crystal4; - ModelRenderer crystal5; - ModelRenderer crystal6; - ModelRenderer crystal7; - ModelRenderer crystal8; - ModelRenderer outside1; - ModelRenderer outside2; - ModelRenderer outside3; - ModelRenderer outside4; - ModelRenderer outside5; - ModelRenderer outside6; - ModelRenderer outside7; - ModelRenderer outside8; + ModelRenderer crystal1; + ModelRenderer crystal2; + ModelRenderer crystal3; + ModelRenderer crystal4; + ModelRenderer crystal5; + ModelRenderer crystal6; + ModelRenderer crystal7; + ModelRenderer crystal8; + ModelRenderer outside1; + ModelRenderer outside2; + ModelRenderer outside3; + ModelRenderer outside4; + ModelRenderer outside5; + ModelRenderer outside6; + ModelRenderer outside7; + ModelRenderer outside8; - public ModelPylonOld() { - textureWidth = 64; - textureHeight = 32; + public ModelPylonOld() { + textureWidth = 64; + textureHeight = 32; - crystal1 = new ModelRenderer(this, 0, 0); - crystal1.addBox(-1.5F, -7F, -1F, 3, 7, 2); - crystal1.setRotationPoint(0F, 23F, 0F); - crystal1.setTextureSize(256, 128); - setRotation(crystal1, 0.1396263F, -0.418879F, 0F); - crystal2 = new ModelRenderer(this, 0, 0); - crystal2.addBox(-1.5F, -7F, -1F, 3, 7, 2); - crystal2.setRotationPoint(0F, 23F, 0F); - crystal2.setTextureSize(256, 128); - setRotation(crystal2, -0.1396263F, 0.418879F, 0F); - crystal3 = new ModelRenderer(this, 0, 0); - crystal3.addBox(-1.5F, -7F, -1F, 3, 7, 2); - crystal3.setRotationPoint(0F, 23F, 0F); - crystal3.setTextureSize(256, 128); - setRotation(crystal3, 0.1396263F, 0.418879F, 0F); - crystal4 = new ModelRenderer(this, 0, 0); - crystal4.addBox(-1.5F, -7F, -1F, 3, 7, 2); - crystal4.setRotationPoint(0F, 23F, 0F); - crystal4.setTextureSize(256, 128); - setRotation(crystal4, -0.1396263F, -0.418879F, 0F); - crystal5 = new ModelRenderer(this, 0, 0); - crystal5.addBox(-1.5F, 0F, -1F, 3, 7, 2); - crystal5.setRotationPoint(0F, 10F, 0F); - crystal5.setTextureSize(256, 128); - setRotation(crystal5, 0.1396263F, 0.418879F, 0F); - crystal6 = new ModelRenderer(this, 0, 0); - crystal6.addBox(-1.5F, 0F, -1F, 3, 7, 2); - crystal6.setRotationPoint(0F, 10F, 0F); - crystal6.setTextureSize(256, 128); - setRotation(crystal6, 0.1396263F, -0.418879F, 0F); - crystal7 = new ModelRenderer(this, 0, 0); - crystal7.addBox(-1.5F, 0F, -1F, 3, 7, 2); - crystal7.setRotationPoint(0F, 10F, 0F); - crystal7.setTextureSize(256, 128); - setRotation(crystal7, -0.1396263F, -0.418879F, 0F); - crystal8 = new ModelRenderer(this, 0, 0); - crystal8.addBox(-1.5F, 0F, -1F, 3, 7, 2); - crystal8.setRotationPoint(0F, 10F, 0F); - crystal8.setTextureSize(256, 128); - setRotation(crystal8, -0.1396263F, 0.418879F, 0F); - outside1 = new ModelRenderer(this, 17, 0); - outside1.addBox(0F, -4F, -1.5F, 1, 8, 3); - outside1.setRotationPoint(4F, 18F, 0F); - outside1.setTextureSize(256, 128); - setRotation(outside1, 0F, 0F, 0.1396263F); - outside2 = new ModelRenderer(this, 17, 0); - outside2.addBox(-1F, -4F, -1.5F, 1, 8, 3); - outside2.setRotationPoint(-4F, 18F, 0F); - outside2.setTextureSize(256, 128); - setRotation(outside2, 0F, 0F, -0.1396263F); - outside3 = new ModelRenderer(this, 26, 0); - outside3.addBox(-1.5F, -3F, -1F, 3, 6, 1); - outside3.setRotationPoint(0F, 18F, -4F); - outside3.setTextureSize(256, 128); - setRotation(outside3, 0.0698132F, 0F, 0F); - outside4 = new ModelRenderer(this, 26, 0); - outside4.addBox(-1.5F, -3F, 0F, 3, 6, 1); - outside4.setRotationPoint(0F, 18F, 4F); - outside4.setTextureSize(256, 128); - setRotation(outside4, -0.0698132F, 0F, 0F); - outside5 = new ModelRenderer(this, 27, 0); - outside5.addBox(0F, 0F, -4F, 1, 2, 8); - outside5.setRotationPoint(3F, 18F, 0F); - outside5.setTextureSize(256, 128); - setRotation(outside5, 0F, 0F, 0F); - outside6 = new ModelRenderer(this, 27, 0); - outside6.addBox(-1F, -1F, -4F, 1, 2, 8); - outside6.setRotationPoint(-3F, 19F, 0F); - outside6.setTextureSize(256, 128); - setRotation(outside6, 0F, 0F, 0F); - outside7 = new ModelRenderer(this, 17, 12); - outside7.addBox(-3F, -1F, 0F, 6, 2, 1); - outside7.setRotationPoint(0F, 19F, 3F); - outside7.setTextureSize(256, 128); - setRotation(outside7, 0F, 0F, 0F); - outside8 = new ModelRenderer(this, 17, 12); - outside8.addBox(-3F, -1F, -1F, 6, 2, 1); - outside8.setRotationPoint(0F, 19F, -3F); - outside8.setTextureSize(256, 128); - setRotation(outside8, 0F, 0F, 0F); - } + crystal1 = new ModelRenderer(this, 0, 0); + crystal1.addBox(-1.5F, -7F, -1F, 3, 7, 2); + crystal1.setRotationPoint(0F, 23F, 0F); + crystal1.setTextureSize(256, 128); + setRotation(crystal1, 0.1396263F, -0.418879F, 0F); + crystal2 = new ModelRenderer(this, 0, 0); + crystal2.addBox(-1.5F, -7F, -1F, 3, 7, 2); + crystal2.setRotationPoint(0F, 23F, 0F); + crystal2.setTextureSize(256, 128); + setRotation(crystal2, -0.1396263F, 0.418879F, 0F); + crystal3 = new ModelRenderer(this, 0, 0); + crystal3.addBox(-1.5F, -7F, -1F, 3, 7, 2); + crystal3.setRotationPoint(0F, 23F, 0F); + crystal3.setTextureSize(256, 128); + setRotation(crystal3, 0.1396263F, 0.418879F, 0F); + crystal4 = new ModelRenderer(this, 0, 0); + crystal4.addBox(-1.5F, -7F, -1F, 3, 7, 2); + crystal4.setRotationPoint(0F, 23F, 0F); + crystal4.setTextureSize(256, 128); + setRotation(crystal4, -0.1396263F, -0.418879F, 0F); + crystal5 = new ModelRenderer(this, 0, 0); + crystal5.addBox(-1.5F, 0F, -1F, 3, 7, 2); + crystal5.setRotationPoint(0F, 10F, 0F); + crystal5.setTextureSize(256, 128); + setRotation(crystal5, 0.1396263F, 0.418879F, 0F); + crystal6 = new ModelRenderer(this, 0, 0); + crystal6.addBox(-1.5F, 0F, -1F, 3, 7, 2); + crystal6.setRotationPoint(0F, 10F, 0F); + crystal6.setTextureSize(256, 128); + setRotation(crystal6, 0.1396263F, -0.418879F, 0F); + crystal7 = new ModelRenderer(this, 0, 0); + crystal7.addBox(-1.5F, 0F, -1F, 3, 7, 2); + crystal7.setRotationPoint(0F, 10F, 0F); + crystal7.setTextureSize(256, 128); + setRotation(crystal7, -0.1396263F, -0.418879F, 0F); + crystal8 = new ModelRenderer(this, 0, 0); + crystal8.addBox(-1.5F, 0F, -1F, 3, 7, 2); + crystal8.setRotationPoint(0F, 10F, 0F); + crystal8.setTextureSize(256, 128); + setRotation(crystal8, -0.1396263F, 0.418879F, 0F); + outside1 = new ModelRenderer(this, 17, 0); + outside1.addBox(0F, -4F, -1.5F, 1, 8, 3); + outside1.setRotationPoint(4F, 18F, 0F); + outside1.setTextureSize(256, 128); + setRotation(outside1, 0F, 0F, 0.1396263F); + outside2 = new ModelRenderer(this, 17, 0); + outside2.addBox(-1F, -4F, -1.5F, 1, 8, 3); + outside2.setRotationPoint(-4F, 18F, 0F); + outside2.setTextureSize(256, 128); + setRotation(outside2, 0F, 0F, -0.1396263F); + outside3 = new ModelRenderer(this, 26, 0); + outside3.addBox(-1.5F, -3F, -1F, 3, 6, 1); + outside3.setRotationPoint(0F, 18F, -4F); + outside3.setTextureSize(256, 128); + setRotation(outside3, 0.0698132F, 0F, 0F); + outside4 = new ModelRenderer(this, 26, 0); + outside4.addBox(-1.5F, -3F, 0F, 3, 6, 1); + outside4.setRotationPoint(0F, 18F, 4F); + outside4.setTextureSize(256, 128); + setRotation(outside4, -0.0698132F, 0F, 0F); + outside5 = new ModelRenderer(this, 27, 0); + outside5.addBox(0F, 0F, -4F, 1, 2, 8); + outside5.setRotationPoint(3F, 18F, 0F); + outside5.setTextureSize(256, 128); + setRotation(outside5, 0F, 0F, 0F); + outside6 = new ModelRenderer(this, 27, 0); + outside6.addBox(-1F, -1F, -4F, 1, 2, 8); + outside6.setRotationPoint(-3F, 19F, 0F); + outside6.setTextureSize(256, 128); + setRotation(outside6, 0F, 0F, 0F); + outside7 = new ModelRenderer(this, 17, 12); + outside7.addBox(-3F, -1F, 0F, 6, 2, 1); + outside7.setRotationPoint(0F, 19F, 3F); + outside7.setTextureSize(256, 128); + setRotation(outside7, 0F, 0F, 0F); + outside8 = new ModelRenderer(this, 17, 12); + outside8.addBox(-3F, -1F, -1F, 6, 2, 1); + outside8.setRotationPoint(0F, 19F, -3F); + outside8.setTextureSize(256, 128); + setRotation(outside8, 0F, 0F, 0F); + } - @Override - public void renderCrystal() { - float f = 1F / 16F; - crystal1.render(f); - crystal2.render(f); - crystal3.render(f); - crystal4.render(f); - crystal5.render(f); - crystal6.render(f); - crystal7.render(f); - crystal8.render(f); - } + @Override + public void renderCrystal() { + float f = 1F / 16F; + crystal1.render(f); + crystal2.render(f); + crystal3.render(f); + crystal4.render(f); + crystal5.render(f); + crystal6.render(f); + crystal7.render(f); + crystal8.render(f); + } - @Override - public void renderRing() { - float f = 1F / 16F; - outside1.render(f); - outside2.render(f); - outside3.render(f); - outside4.render(f); - outside5.render(f); - outside6.render(f); - outside7.render(f); - outside8.render(f); - } + @Override + public void renderRing() { + float f = 1F / 16F; + outside1.render(f); + outside2.render(f); + outside3.render(f); + outside4.render(f); + outside5.render(f); + outside6.render(f); + outside7.render(f); + outside8.render(f); + } - private void setRotation(ModelRenderer model, float x, float y, float z) { - model.rotateAngleX = x; - model.rotateAngleY = y; - model.rotateAngleZ = z; - } + private void setRotation(ModelRenderer model, float x, float y, float z) { + model.rotateAngleX = x; + model.rotateAngleY = y; + model.rotateAngleZ = z; + } - @Override - public void renderGems() { - // NO-OP - } -} + @Override + public void renderGems() { + // NO-OP + } + +} \ No newline at end of file diff --git a/src/main/java/vazkii/botania/client/model/ModelSkullOverride.java b/src/main/java/vazkii/botania/client/model/ModelSkullOverride.java index 93d0650269..1ad6c4258d 100644 --- a/src/main/java/vazkii/botania/client/model/ModelSkullOverride.java +++ b/src/main/java/vazkii/botania/client/model/ModelSkullOverride.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [? (GMT)] */ package vazkii.botania.client.model; @@ -16,36 +16,35 @@ public class ModelSkullOverride extends ModelBase { - private final ModelRenderer bipedHead; - private final ModelRenderer bipedHeadwear; + private final ModelRenderer bipedHead; + private final ModelRenderer bipedHeadwear; - public ModelSkullOverride() { - textureWidth = 64; - textureHeight = 32; - bipedHead = new ModelRenderer(this, 0, 0); - bipedHead.addBox(-4.0F, -8.0F, -4.0F, 8, 8, 8, 0F); - bipedHead.setRotationPoint(0.0F, 0.0F, 0.0F); - bipedHeadwear = new ModelRenderer(this, 32, 0); - bipedHeadwear.addBox(-4.0F, -8.0F, -4.0F, 8, 8, 8, 0.5F); - bipedHeadwear.setRotationPoint(0.0F, 0.0F, 0.0F); - } + public ModelSkullOverride() { + textureWidth = 64; + textureHeight = 32; + bipedHead = new ModelRenderer(this, 0, 0); + bipedHead.addBox(-4.0F, -8.0F, -4.0F, 8, 8, 8, 0F); + bipedHead.setRotationPoint(0.0F, 0.0F, 0.0F); + bipedHeadwear = new ModelRenderer(this, 32, 0); + bipedHeadwear.addBox(-4.0F, -8.0F, -4.0F, 8, 8, 8, 0.5F); + bipedHeadwear.setRotationPoint(0.0F, 0.0F, 0.0F); + } - public void renderWithoutRotation(float par1) { - bipedHead.render(par1); - bipedHeadwear.render(par1); - } + public void renderWithoutRotation(float par1) { + bipedHead.render(par1); + bipedHeadwear.render(par1); + } - @Override - public void render(Entity par1Entity, float par2, float par3, float par4, float par5, float par6, float par7) { - setRotationAngles(par2, par3, par4, par5, par6, par7, par1Entity); - bipedHead.render(par7); - bipedHeadwear.render(par7); - } + @Override + public void render(Entity par1Entity, float par2, float par3, float par4, float par5, float par6, float par7) { + setRotationAngles(par2, par3, par4, par5, par6, par7, par1Entity); + bipedHead.render(par7); + bipedHeadwear.render(par7); + } - @Override - public void setRotationAngles( - float par1, float par2, float par3, float par4, float par5, float par6, Entity par7Entity) { - bipedHead.rotateAngleY = bipedHeadwear.rotateAngleY = par4 / (180F / (float) Math.PI); - bipedHead.rotateAngleX = bipedHeadwear.rotateAngleX = par5 / (180F / (float) Math.PI); - } -} + @Override + public void setRotationAngles(float par1, float par2, float par3, float par4, float par5, float par6, Entity par7Entity) { + bipedHead.rotateAngleY = bipedHeadwear.rotateAngleY = par4 / (180F / (float)Math.PI); + bipedHead.rotateAngleX = bipedHeadwear.rotateAngleX = par5 / (180F / (float)Math.PI); + } +} \ No newline at end of file diff --git a/src/main/java/vazkii/botania/client/model/ModelSpawnerClaw.java b/src/main/java/vazkii/botania/client/model/ModelSpawnerClaw.java index ce1291f68c..4504ef8c66 100644 --- a/src/main/java/vazkii/botania/client/model/ModelSpawnerClaw.java +++ b/src/main/java/vazkii/botania/client/model/ModelSpawnerClaw.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jul 23, 2014, 5:46:38 PM (GMT)] */ package vazkii.botania.client.model; @@ -14,68 +14,69 @@ import net.minecraft.client.model.ModelRenderer; public class ModelSpawnerClaw extends ModelBase { - ModelRenderer Plate; - ModelRenderer Claw1; - ModelRenderer Claw2; - ModelRenderer Claw3; - ModelRenderer Claw4; - ModelRenderer Claw5; - ModelRenderer Claw6; - ModelRenderer Claw7; - ModelRenderer Claw8; + ModelRenderer Plate; + ModelRenderer Claw1; + ModelRenderer Claw2; + ModelRenderer Claw3; + ModelRenderer Claw4; + ModelRenderer Claw5; + ModelRenderer Claw6; + ModelRenderer Claw7; + ModelRenderer Claw8; - public ModelSpawnerClaw() { - textureWidth = 64; - textureHeight = 32; + public ModelSpawnerClaw() { + textureWidth = 64; + textureHeight = 32; - Plate = new ModelRenderer(this, 0, 0); - Plate.addBox(0F, 0F, 0F, 12, 1, 12); - Plate.setRotationPoint(-6F, 23F, -6F); - Plate.setTextureSize(64, 32); - Claw1 = new ModelRenderer(this, 0, 14); - Claw1.addBox(0F, 0F, 0F, 2, 1, 3); - Claw1.setRotationPoint(-1F, 23F, 6F); - Claw1.setTextureSize(64, 32); - Claw2 = new ModelRenderer(this, 11, 14); - Claw2.addBox(0F, 0F, 0F, 2, 1, 3); - Claw2.setRotationPoint(-1F, 23F, -9F); - Claw2.setTextureSize(64, 32); - Claw3 = new ModelRenderer(this, 0, 19); - Claw3.addBox(0F, 0F, 0F, 3, 1, 2); - Claw3.setRotationPoint(-9F, 23F, -1F); - Claw3.setTextureSize(64, 32); - Claw4 = new ModelRenderer(this, 11, 19); - Claw4.addBox(0F, 0F, 0F, 3, 1, 2); - Claw4.setRotationPoint(6F, 23F, -1F); - Claw4.setTextureSize(64, 32); - Claw5 = new ModelRenderer(this, 23, 16); - Claw5.addBox(0F, 0F, 0F, 2, 5, 1); - Claw5.setRotationPoint(-1F, 24F, 8F); - Claw5.setTextureSize(64, 32); - Claw6 = new ModelRenderer(this, 30, 16); - Claw6.addBox(0F, 0F, 0F, 1, 5, 2); - Claw6.setRotationPoint(8F, 24F, -1F); - Claw6.setTextureSize(64, 32); - Claw7 = new ModelRenderer(this, 37, 16); - Claw7.addBox(0F, 0F, 0F, 2, 5, 1); - Claw7.setRotationPoint(-1F, 24F, -9F); - Claw7.setTextureSize(64, 32); - Claw8 = new ModelRenderer(this, 44, 16); - Claw8.addBox(0F, 0F, 0F, 1, 5, 2); - Claw8.setRotationPoint(-9F, 24F, -1F); - Claw8.setTextureSize(64, 32); - } + Plate = new ModelRenderer(this, 0, 0); + Plate.addBox(0F, 0F, 0F, 12, 1, 12); + Plate.setRotationPoint(-6F, 23F, -6F); + Plate.setTextureSize(64, 32); + Claw1 = new ModelRenderer(this, 0, 14); + Claw1.addBox(0F, 0F, 0F, 2, 1, 3); + Claw1.setRotationPoint(-1F, 23F, 6F); + Claw1.setTextureSize(64, 32); + Claw2 = new ModelRenderer(this, 11, 14); + Claw2.addBox(0F, 0F, 0F, 2, 1, 3); + Claw2.setRotationPoint(-1F, 23F, -9F); + Claw2.setTextureSize(64, 32); + Claw3 = new ModelRenderer(this, 0, 19); + Claw3.addBox(0F, 0F, 0F, 3, 1, 2); + Claw3.setRotationPoint(-9F, 23F, -1F); + Claw3.setTextureSize(64, 32); + Claw4 = new ModelRenderer(this, 11, 19); + Claw4.addBox(0F, 0F, 0F, 3, 1, 2); + Claw4.setRotationPoint(6F, 23F, -1F); + Claw4.setTextureSize(64, 32); + Claw5 = new ModelRenderer(this, 23, 16); + Claw5.addBox(0F, 0F, 0F, 2, 5, 1); + Claw5.setRotationPoint(-1F, 24F, 8F); + Claw5.setTextureSize(64, 32); + Claw6 = new ModelRenderer(this, 30, 16); + Claw6.addBox(0F, 0F, 0F, 1, 5, 2); + Claw6.setRotationPoint(8F, 24F, -1F); + Claw6.setTextureSize(64, 32); + Claw7 = new ModelRenderer(this, 37, 16); + Claw7.addBox(0F, 0F, 0F, 2, 5, 1); + Claw7.setRotationPoint(-1F, 24F, -9F); + Claw7.setTextureSize(64, 32); + Claw8 = new ModelRenderer(this, 44, 16); + Claw8.addBox(0F, 0F, 0F, 1, 5, 2); + Claw8.setRotationPoint(-9F, 24F, -1F); + Claw8.setTextureSize(64, 32); + } + + public void render() { + float f5 = 1F / 16F; + Plate.render(f5); + Claw1.render(f5); + Claw2.render(f5); + Claw3.render(f5); + Claw4.render(f5); + Claw5.render(f5); + Claw6.render(f5); + Claw7.render(f5); + Claw8.render(f5); + } - public void render() { - float f5 = 1F / 16F; - Plate.render(f5); - Claw1.render(f5); - Claw2.render(f5); - Claw3.render(f5); - Claw4.render(f5); - Claw5.render(f5); - Claw6.render(f5); - Claw7.render(f5); - Claw8.render(f5); - } } diff --git a/src/main/java/vazkii/botania/client/model/ModelSpinningCubes.java b/src/main/java/vazkii/botania/client/model/ModelSpinningCubes.java index dbd1773c6b..2220b450c0 100644 --- a/src/main/java/vazkii/botania/client/model/ModelSpinningCubes.java +++ b/src/main/java/vazkii/botania/client/model/ModelSpinningCubes.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Feb 2, 2014, 6:37:00 PM (GMT)] */ package vazkii.botania.client.model; @@ -13,74 +13,78 @@ import net.minecraft.client.model.ModelBase; import net.minecraft.client.model.ModelRenderer; import net.minecraft.client.renderer.OpenGlHelper; + import org.lwjgl.opengl.GL11; + import vazkii.botania.client.core.handler.ClientTickHandler; public class ModelSpinningCubes extends ModelBase { - ModelRenderer spinningCube; - - public ModelSpinningCubes() { - spinningCube = new ModelRenderer(this, 42, 0); - spinningCube.addBox(0F, 0F, 0F, 1, 1, 1); - spinningCube.setRotationPoint(0F, 0F, 0F); - spinningCube.setTextureSize(64, 64); - } - - public void renderSpinningCubes(int cubes, int repeat, int origRepeat) { - GL11.glDisable(GL11.GL_TEXTURE_2D); - - final float modifier = 6F; - final float rotationModifier = 0.2F; - final float radiusBase = 0.35F; - final float radiusMod = 0.05F; - - double ticks = ClientTickHandler.ticksInGame + ClientTickHandler.partialTicks - 1.3 * (origRepeat - repeat); - float offsetPerCube = 360 / cubes; - - GL11.glPushMatrix(); - GL11.glTranslatef(-0.025F, 0.85F, -0.025F); - for (int i = 0; i < cubes; i++) { - float offset = offsetPerCube * i; - float deg = (int) (ticks / rotationModifier % 360F + offset); - float rad = deg * (float) Math.PI / 180F; - float radiusX = (float) (radiusBase + radiusMod * Math.sin(ticks / modifier)); - float radiusZ = (float) (radiusBase + radiusMod * Math.cos(ticks / modifier)); - float x = (float) (radiusX * Math.cos(rad)); - float z = (float) (radiusZ * Math.sin(rad)); - float y = (float) Math.cos((ticks + 50 * i) / 5F) / 10F; - - GL11.glPushMatrix(); - GL11.glTranslatef(x, y, z); - float xRotate = (float) Math.sin(ticks * rotationModifier) / 2F; - float yRotate = (float) Math.max(0.6F, Math.sin(ticks * 0.1F) / 2F + 0.5F); - float zRotate = (float) Math.cos(ticks * rotationModifier) / 2F; - - GL11.glRotatef(deg, xRotate, yRotate, zRotate); - if (repeat < origRepeat) { - GL11.glColor4f(1F, 1F, 1F, (float) repeat / (float) origRepeat * 0.4F); - GL11.glEnable(GL11.GL_BLEND); - GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); - GL11.glDisable(GL11.GL_ALPHA_TEST); - } else GL11.glColor4f(1F, 1F, 1F, 1F); - - int light = 15728880; - int lightmapX = light % 65536; - int lightmapY = light / 65536; - - OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, lightmapX, lightmapY); - spinningCube.render(1F / 16F); - - if (repeat < origRepeat) { - GL11.glDisable(GL11.GL_BLEND); - GL11.glEnable(GL11.GL_ALPHA_TEST); - } - - GL11.glPopMatrix(); - } - GL11.glPopMatrix(); - GL11.glEnable(GL11.GL_TEXTURE_2D); - - if (repeat != 0) renderSpinningCubes(cubes, repeat - 1, origRepeat); - } + ModelRenderer spinningCube; + + public ModelSpinningCubes() { + spinningCube = new ModelRenderer(this, 42, 0); + spinningCube.addBox(0F, 0F, 0F, 1, 1, 1); + spinningCube.setRotationPoint(0F, 0F, 0F); + spinningCube.setTextureSize(64, 64); + } + + public void renderSpinningCubes(int cubes, int repeat, int origRepeat) { + GL11.glDisable(GL11.GL_TEXTURE_2D); + + final float modifier = 6F; + final float rotationModifier = 0.2F; + final float radiusBase = 0.35F; + final float radiusMod = 0.05F; + + double ticks = ClientTickHandler.ticksInGame + ClientTickHandler.partialTicks - 1.3 * (origRepeat - repeat); + float offsetPerCube = 360 / cubes; + + GL11.glPushMatrix(); + GL11.glTranslatef(-0.025F, 0.85F, -0.025F); + for(int i = 0; i < cubes; i++) { + float offset = offsetPerCube * i; + float deg = (int) (ticks / rotationModifier % 360F + offset); + float rad = deg * (float) Math.PI / 180F; + float radiusX = (float) (radiusBase + radiusMod * Math.sin(ticks / modifier)); + float radiusZ = (float) (radiusBase + radiusMod * Math.cos(ticks / modifier)); + float x = (float) (radiusX * Math.cos(rad)); + float z = (float) (radiusZ * Math.sin(rad)); + float y = (float) Math.cos((ticks + 50 * i) / 5F) / 10F; + + GL11.glPushMatrix(); + GL11.glTranslatef(x, y, z); + float xRotate = (float) Math.sin(ticks * rotationModifier) / 2F; + float yRotate = (float) Math.max(0.6F, Math.sin(ticks * 0.1F) / 2F + 0.5F); + float zRotate = (float) Math.cos(ticks * rotationModifier) / 2F; + + GL11.glRotatef(deg, xRotate, yRotate, zRotate); + if(repeat < origRepeat) { + GL11.glColor4f(1F, 1F, 1F, (float) repeat / (float) origRepeat * 0.4F); + GL11.glEnable(GL11.GL_BLEND); + GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); + GL11.glDisable(GL11.GL_ALPHA_TEST); + } else GL11.glColor4f(1F, 1F, 1F, 1F); + + int light = 15728880; + int lightmapX = light % 65536; + int lightmapY = light / 65536; + + OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, lightmapX, lightmapY); + spinningCube.render(1F / 16F); + + if(repeat < origRepeat) { + GL11.glDisable(GL11.GL_BLEND); + GL11.glEnable(GL11.GL_ALPHA_TEST); + } + + GL11.glPopMatrix(); + } + GL11.glPopMatrix(); + GL11.glEnable(GL11.GL_TEXTURE_2D); + + if(repeat != 0) + renderSpinningCubes(cubes, repeat - 1, origRepeat); + } + } diff --git a/src/main/java/vazkii/botania/client/model/ModelSpreader.java b/src/main/java/vazkii/botania/client/model/ModelSpreader.java index 6fd9255373..f0f2161dbb 100644 --- a/src/main/java/vazkii/botania/client/model/ModelSpreader.java +++ b/src/main/java/vazkii/botania/client/model/ModelSpreader.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jan 25, 2014, 1:55:05 PM (GMT)] */ package vazkii.botania.client.model; @@ -15,78 +15,78 @@ public class ModelSpreader extends ModelBase { - ModelRenderer cubeSide1; - ModelRenderer cubeSide2; - ModelRenderer cubeSide3; - ModelRenderer cubeSide4; - ModelRenderer cubeSide5; - ModelRenderer cubeHole1; - ModelRenderer cubeHole2; - ModelRenderer cubeHole3; - ModelRenderer cubeHole4; - ModelRenderer cubeInside; + ModelRenderer cubeSide1; + ModelRenderer cubeSide2; + ModelRenderer cubeSide3; + ModelRenderer cubeSide4; + ModelRenderer cubeSide5; + ModelRenderer cubeHole1; + ModelRenderer cubeHole2; + ModelRenderer cubeHole3; + ModelRenderer cubeHole4; + ModelRenderer cubeInside; - public ModelSpreader() { - textureWidth = 64; - textureHeight = 32; + public ModelSpreader() { + textureWidth = 64; + textureHeight = 32; - cubeSide1 = new ModelRenderer(this, 0, 0); - cubeSide1.addBox(0F, 0F, 0F, 14, 1, 14); - cubeSide1.setRotationPoint(-7F, 22F, -7F); - cubeSide1.setTextureSize(64, 32); - cubeSide2 = new ModelRenderer(this, 0, 0); - cubeSide2.addBox(0F, 0F, 0F, 14, 13, 1); - cubeSide2.setRotationPoint(-7F, 9F, -7F); - cubeSide2.setTextureSize(64, 32); - cubeSide3 = new ModelRenderer(this, 0, 0); - cubeSide3.addBox(0F, 0F, 0F, 1, 13, 13); - cubeSide3.setRotationPoint(-7F, 9F, -6F); - cubeSide3.setTextureSize(64, 32); - cubeSide4 = new ModelRenderer(this, 0, 0); - cubeSide4.addBox(0F, 0F, 0F, 1, 13, 13); - cubeSide4.setRotationPoint(6F, 9F, -6F); - cubeSide4.setTextureSize(64, 32); - cubeSide5 = new ModelRenderer(this, 0, 0); - cubeSide5.addBox(0F, 0F, 0F, 12, 1, 13); - cubeSide5.setRotationPoint(-6F, 9F, -6F); - cubeSide5.setTextureSize(64, 32); - cubeHole1 = new ModelRenderer(this, 0, 0); - cubeHole1.addBox(0F, 0F, 0F, 4, 12, 1); - cubeHole1.setRotationPoint(2F, 10F, 6F); - cubeHole1.setTextureSize(64, 32); - cubeHole2 = new ModelRenderer(this, 0, 0); - cubeHole2.addBox(0F, 0F, 0F, 4, 12, 1); - cubeHole2.setRotationPoint(-6F, 10F, 6F); - cubeHole2.setTextureSize(64, 32); - cubeHole3 = new ModelRenderer(this, 0, 0); - cubeHole3.addBox(0F, 0F, 0F, 4, 4, 1); - cubeHole3.setRotationPoint(-2F, 18F, 6F); - cubeHole3.setTextureSize(64, 32); - cubeHole4 = new ModelRenderer(this, 0, 0); - cubeHole4.addBox(0F, 0F, 0F, 4, 4, 1); - cubeHole4.setRotationPoint(-2F, 10F, 6F); - cubeHole4.setTextureSize(64, 32); - cubeInside = new ModelRenderer(this, 30, 17); - cubeInside.addBox(0F, 0F, 0F, 6, 6, 6); - cubeInside.setRotationPoint(-3F, 13F, -3F); - cubeInside.setTextureSize(64, 32); - } + cubeSide1 = new ModelRenderer(this, 0, 0); + cubeSide1.addBox(0F, 0F, 0F, 14, 1, 14); + cubeSide1.setRotationPoint(-7F, 22F, -7F); + cubeSide1.setTextureSize(64, 32); + cubeSide2 = new ModelRenderer(this, 0, 0); + cubeSide2.addBox(0F, 0F, 0F, 14, 13, 1); + cubeSide2.setRotationPoint(-7F, 9F, -7F); + cubeSide2.setTextureSize(64, 32); + cubeSide3 = new ModelRenderer(this, 0, 0); + cubeSide3.addBox(0F, 0F, 0F, 1, 13, 13); + cubeSide3.setRotationPoint(-7F, 9F, -6F); + cubeSide3.setTextureSize(64, 32); + cubeSide4 = new ModelRenderer(this, 0, 0); + cubeSide4.addBox(0F, 0F, 0F, 1, 13, 13); + cubeSide4.setRotationPoint(6F, 9F, -6F); + cubeSide4.setTextureSize(64, 32); + cubeSide5 = new ModelRenderer(this, 0, 0); + cubeSide5.addBox(0F, 0F, 0F, 12, 1, 13); + cubeSide5.setRotationPoint(-6F, 9F, -6F); + cubeSide5.setTextureSize(64, 32); + cubeHole1 = new ModelRenderer(this, 0, 0); + cubeHole1.addBox(0F, 0F, 0F, 4, 12, 1); + cubeHole1.setRotationPoint(2F, 10F, 6F); + cubeHole1.setTextureSize(64, 32); + cubeHole2 = new ModelRenderer(this, 0, 0); + cubeHole2.addBox(0F, 0F, 0F, 4, 12, 1); + cubeHole2.setRotationPoint(-6F, 10F, 6F); + cubeHole2.setTextureSize(64, 32); + cubeHole3 = new ModelRenderer(this, 0, 0); + cubeHole3.addBox(0F, 0F, 0F, 4, 4, 1); + cubeHole3.setRotationPoint(-2F, 18F, 6F); + cubeHole3.setTextureSize(64, 32); + cubeHole4 = new ModelRenderer(this, 0, 0); + cubeHole4.addBox(0F, 0F, 0F, 4, 4, 1); + cubeHole4.setRotationPoint(-2F, 10F, 6F); + cubeHole4.setTextureSize(64, 32); + cubeInside = new ModelRenderer(this, 30, 17); + cubeInside.addBox(0F, 0F, 0F, 6, 6, 6); + cubeInside.setRotationPoint(-3F, 13F, -3F); + cubeInside.setTextureSize(64, 32); + } - public void render() { - float f = 1F / 16F; - cubeSide1.render(f); - cubeSide2.render(f); - cubeSide3.render(f); - cubeSide4.render(f); - cubeSide5.render(f); - cubeHole1.render(f); - cubeHole2.render(f); - cubeHole3.render(f); - cubeHole4.render(f); - } + public void render() { + float f = 1F / 16F; + cubeSide1.render(f); + cubeSide2.render(f); + cubeSide3.render(f); + cubeSide4.render(f); + cubeSide5.render(f); + cubeHole1.render(f); + cubeHole2.render(f); + cubeHole3.render(f); + cubeHole4.render(f); + } - public void renderCube() { - float f = 1F / 16F; - cubeInside.render(f); - } -} + public void renderCube() { + float f = 1F / 16F; + cubeInside.render(f); + } +} \ No newline at end of file diff --git a/src/main/java/vazkii/botania/client/model/ModelTeruTeruBozu.java b/src/main/java/vazkii/botania/client/model/ModelTeruTeruBozu.java index c414251bb6..06817df7c0 100644 --- a/src/main/java/vazkii/botania/client/model/ModelTeruTeruBozu.java +++ b/src/main/java/vazkii/botania/client/model/ModelTeruTeruBozu.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [? (GMT)] */ package vazkii.botania.client.model; @@ -16,42 +16,43 @@ public class ModelTeruTeruBozu extends ModelBase { - public ModelRenderer thread; - public ModelRenderer cloth; - public ModelRenderer happyFace; - public ModelRenderer sadFace; + public ModelRenderer thread; + public ModelRenderer cloth; + public ModelRenderer happyFace; + public ModelRenderer sadFace; - public ModelTeruTeruBozu() { - textureWidth = 64; - textureHeight = 32; - sadFace = new ModelRenderer(this, 32, 0); - sadFace.setRotationPoint(0.0F, 14.5F, 0.0F); - sadFace.addBox(-4.0F, -6.0F, -4.0F, 8, 8, 8, 0.0F); - setRotateAngle(sadFace, 0.17453292519943295F, 0.0F, 0.0F); - happyFace = new ModelRenderer(this, 0, 0); - happyFace.setRotationPoint(0.0F, 14.5F, 0.0F); - happyFace.addBox(-4.0F, -6.0F, -4.0F, 8, 8, 8, 0.0F); - setRotateAngle(happyFace, -0.17453292519943295F, 0.0F, 0.0F); - thread = new ModelRenderer(this, 32, 16); - thread.setRotationPoint(0.0F, 14.0F, 0.0F); - thread.addBox(-3.0F, 2.0F, -3.0F, 6, 1, 6, 0.0F); - cloth = new ModelRenderer(this, 0, 16); - cloth.setRotationPoint(0.0F, 21.5F, -1.0F); - cloth.addBox(-4.0F, -4.0F, -4.0F, 8, 8, 8, 0.0F); - setRotateAngle(cloth, 0.7853981633974483F, 2.2689280275926285F, 1.5707963267948966F); - } + public ModelTeruTeruBozu() { + textureWidth = 64; + textureHeight = 32; + sadFace = new ModelRenderer(this, 32, 0); + sadFace.setRotationPoint(0.0F, 14.5F, 0.0F); + sadFace.addBox(-4.0F, -6.0F, -4.0F, 8, 8, 8, 0.0F); + setRotateAngle(sadFace, 0.17453292519943295F, 0.0F, 0.0F); + happyFace = new ModelRenderer(this, 0, 0); + happyFace.setRotationPoint(0.0F, 14.5F, 0.0F); + happyFace.addBox(-4.0F, -6.0F, -4.0F, 8, 8, 8, 0.0F); + setRotateAngle(happyFace, -0.17453292519943295F, 0.0F, 0.0F); + thread = new ModelRenderer(this, 32, 16); + thread.setRotationPoint(0.0F, 14.0F, 0.0F); + thread.addBox(-3.0F, 2.0F, -3.0F, 6, 1, 6, 0.0F); + cloth = new ModelRenderer(this, 0, 16); + cloth.setRotationPoint(0.0F, 21.5F, -1.0F); + cloth.addBox(-4.0F, -4.0F, -4.0F, 8, 8, 8, 0.0F); + setRotateAngle(cloth, 0.7853981633974483F, 2.2689280275926285F, 1.5707963267948966F); + } - public void render() { - float f5 = 1F / 16F; - if (Minecraft.getMinecraft().theWorld.isRaining()) sadFace.render(f5); - else happyFace.render(f5); - thread.render(f5); - cloth.render(f5); - } + public void render() { + float f5 = 1F / 16F; + if(Minecraft.getMinecraft().theWorld.isRaining()) + sadFace.render(f5); + else happyFace.render(f5); + thread.render(f5); + cloth.render(f5); + } - public void setRotateAngle(ModelRenderer modelRenderer, float x, float y, float z) { - modelRenderer.rotateAngleX = x; - modelRenderer.rotateAngleY = y; - modelRenderer.rotateAngleZ = z; - } + public void setRotateAngle(ModelRenderer modelRenderer, float x, float y, float z) { + modelRenderer.rotateAngleX = x; + modelRenderer.rotateAngleY = y; + modelRenderer.rotateAngleZ = z; + } } diff --git a/src/main/java/vazkii/botania/client/model/ModelTinyPotato.java b/src/main/java/vazkii/botania/client/model/ModelTinyPotato.java index 38a82ee869..5415f00d05 100644 --- a/src/main/java/vazkii/botania/client/model/ModelTinyPotato.java +++ b/src/main/java/vazkii/botania/client/model/ModelTinyPotato.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jul 18, 2014, 7:55:34 PM (GMT)] */ package vazkii.botania.client.model; @@ -15,19 +15,20 @@ public class ModelTinyPotato extends ModelBase { - ModelRenderer potato; + ModelRenderer potato; - public ModelTinyPotato() { - textureWidth = 64; - textureHeight = 32; + public ModelTinyPotato() { + textureWidth = 64; + textureHeight = 32; - potato = new ModelRenderer(this, 0, 0); - potato.addBox(0F, 0F, 0F, 4, 6, 4); - potato.setRotationPoint(-2F, 18F, -2F); - potato.setTextureSize(64, 32); - } + potato = new ModelRenderer(this, 0, 0); + potato.addBox(0F, 0F, 0F, 4, 6, 4); + potato.setRotationPoint(-2F, 18F, -2F); + potato.setTextureSize(64, 32); + } + + public void render() { + potato.render(1F / 16F); + } - public void render() { - potato.render(1F / 16F); - } } diff --git a/src/main/java/vazkii/botania/client/model/armor/ModelArmorElementium.java b/src/main/java/vazkii/botania/client/model/armor/ModelArmorElementium.java index 947f955dab..8720d8f1ec 100644 --- a/src/main/java/vazkii/botania/client/model/armor/ModelArmorElementium.java +++ b/src/main/java/vazkii/botania/client/model/armor/ModelArmorElementium.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [? (GMT)] */ package vazkii.botania.client.model.armor; @@ -20,245 +20,248 @@ public class ModelArmorElementium extends ModelBiped { - public ModelRenderer helm; - public ModelRenderer body; - public ModelRenderer armR; - public ModelRenderer armL; - public ModelRenderer belt; - public ModelRenderer bootR; - public ModelRenderer bootL; - public ModelRenderer helm1; - public ModelRenderer helm2; - public ModelRenderer helm3; - public ModelRenderer fairy; - public ModelRenderer helmWing1; - public ModelRenderer helmWing2; - public ModelRenderer helmWing3; - public ModelRenderer helmWing4; - public ModelRenderer body2; - public ModelRenderer armRpauldron; - public ModelRenderer wing1; - public ModelRenderer wing2; - public ModelRenderer armLpauldron; - public ModelRenderer wing1_1; - public ModelRenderer wing2_1; - public ModelRenderer legR; - public ModelRenderer legL; - public ModelRenderer bootR1; - public ModelRenderer wing1_2; - public ModelRenderer wing2_2; - public ModelRenderer bootL1; - public ModelRenderer wing1_3; - public ModelRenderer wing2_3; + public ModelRenderer helm; + public ModelRenderer body; + public ModelRenderer armR; + public ModelRenderer armL; + public ModelRenderer belt; + public ModelRenderer bootR; + public ModelRenderer bootL; + public ModelRenderer helm1; + public ModelRenderer helm2; + public ModelRenderer helm3; + public ModelRenderer fairy; + public ModelRenderer helmWing1; + public ModelRenderer helmWing2; + public ModelRenderer helmWing3; + public ModelRenderer helmWing4; + public ModelRenderer body2; + public ModelRenderer armRpauldron; + public ModelRenderer wing1; + public ModelRenderer wing2; + public ModelRenderer armLpauldron; + public ModelRenderer wing1_1; + public ModelRenderer wing2_1; + public ModelRenderer legR; + public ModelRenderer legL; + public ModelRenderer bootR1; + public ModelRenderer wing1_2; + public ModelRenderer wing2_2; + public ModelRenderer bootL1; + public ModelRenderer wing1_3; + public ModelRenderer wing2_3; - int slot; + int slot; - public ModelArmorElementium(int slot) { - this.slot = slot; + public ModelArmorElementium(int slot) { + this.slot = slot; - textureWidth = 64; - textureHeight = 128; - float s = 0.2F; - fairy = new ModelRenderer(this, 34, 32); - fairy.setRotationPoint(0.0F, 0.0F, 0.0F); - fairy.addBox(-2.0F, -8.5F, -7.0F, 4, 4, 4, s); - setRotateAngle(fairy, -0.17453292519943295F, 0.0F, 0.0F); - helm3 = new ModelRenderer(this, 0, 32); - helm3.setRotationPoint(0.0F, 0.0F, 0.0F); - helm3.addBox(-1.0F, -5.5F, -5.5F, 2, 3, 1, s); - setRotateAngle(helm3, -0.17453292519943295F, 0.0F, 0.0F); - wing1_2 = new ModelRenderer(this, 56, 43); - wing1_2.mirror = true; - wing1_2.setRotationPoint(-2.5F, 9.0F, 0.0F); - wing1_2.addBox(0.5F, -2.0F, 0.0F, 0, 2, 3, s); - setRotateAngle(wing1_2, 0.2617993877991494F, -0.7853981633974483F, -0.2617993877991494F); - helm1 = new ModelRenderer(this, 50, 32); - helm1.setRotationPoint(0.0F, 0.0F, 0.0F); - helm1.addBox(-4.0F, -5.0F, -4.5F, 1, 5, 4, s); - legL = new ModelRenderer(this, 12, 79); - legL.mirror = true; - legL.setRotationPoint(1.9F, 12.0F, 0.0F); - legL.addBox(-2.0F, 0.0F, -2.0F, 4, 6, 4, s); - setRotateAngle(legL, 0.0F, 0.0F, 0F); - armL = new ModelRenderer(this, 0, 79); - armL.mirror = true; - armL.setRotationPoint(5.0F, 2.0F, -0.0F); - armL.addBox(1.5F, 6.0F, -2.0F, 2, 4, 4, s); - setRotateAngle(armL, 0.0F, 0.0F, 0F); - armRpauldron = new ModelRenderer(this, 0, 67); - armRpauldron.setRotationPoint(0.0F, 0.0F, 0.0F); - armRpauldron.addBox(-4.0F, -2.5F, -3.0F, 5, 6, 6, s); - legR = new ModelRenderer(this, 12, 79); - legR.setRotationPoint(-1.9F, 12.0F, 0.0F); - legR.addBox(-2.0F, 0.0F, -2.0F, 4, 6, 4, s); - setRotateAngle(legR, 0.0F, 0.0F, 0F); - helmWing2 = new ModelRenderer(this, 46, 45); - helmWing2.mirror = true; - helmWing2.setRotationPoint(-4.0F, -4.0F, -1.0F); - helmWing2.addBox(-0.5F, 0.0F, 0.0F, 1, 3, 4, s); - setRotateAngle(helmWing2, -0.2617993877991494F, -0.2617993877991494F, 0.2617993877991494F); - bootL1 = new ModelRenderer(this, 12, 79); - bootL1.mirror = true; - bootL1.setRotationPoint(0.0F, 0.0F, 0.0F); - bootL1.addBox(-2.0F, 7.0F, -2.0F, 4, 1, 4, s); - armR = new ModelRenderer(this, 0, 79); - armR.setRotationPoint(-5.0F, 2.0F, 0.0F); - armR.addBox(-3.5F, 6.0F, -2.0F, 2, 4, 4, s); - setRotateAngle(armR, 0.0F, 0.0F, 0F); - bootR1 = new ModelRenderer(this, 12, 79); - bootR1.setRotationPoint(0.0F, 0.0F, 0.0F); - bootR1.addBox(-2.0F, 7.0F, -2.0F, 4, 1, 4, s); - bootR = new ModelRenderer(this, 12, 79); - bootR.setRotationPoint(-1.9F, 12.0F, 0.0F); - bootR.addBox(-2.0F, 8.0F, -3.0F, 4, 4, 5, s); - setRotateAngle(bootR, 0.0F, 0.0F, 0F); - wing2_1 = new ModelRenderer(this, 56, 42); - wing2_1.setRotationPoint(4.5F, 0.0F, 0.0F); - wing2_1.addBox(0.0F, 0.0F, -0.5F, 0, 2, 3, s); - setRotateAngle(wing2_1, 0.08726646259971647F, 0.7853981633974483F, 0.2617993877991494F); - wing2_2 = new ModelRenderer(this, 56, 44); - wing2_2.mirror = true; - wing2_2.setRotationPoint(-2.5F, 9.0F, 0.0F); - wing2_2.addBox(0.5F, 0.0F, 0.0F, 0, 1, 2, s); - setRotateAngle(wing2_2, 0.08726646259971647F, -0.7853981633974483F, -0.2617993877991494F); - bootL = new ModelRenderer(this, 12, 79); - bootL.mirror = true; - bootL.setRotationPoint(1.9F, 12.0F, 0.0F); - bootL.addBox(-2.0F, 8.0F, -3.0F, 4, 4, 5, s); - setRotateAngle(bootL, 0.0F, 0.0F, 0F); - body = new ModelRenderer(this, 0, 44); - body.setRotationPoint(0.0F, 0.0F, 0.0F); - body.addBox(-4.5F, 0.0F, -4.0F, 9, 5, 7, s); - setRotateAngle(body, 0.08726646259971647F, 0.0F, 0.0F); - belt = new ModelRenderer(this, 22, 56); - belt.setRotationPoint(0.0F, 0.0F, 0.0F); - belt.addBox(-4.5F, 9.5F, -3.0F, 9, 3, 5, s); - helm = new ModelRenderer(this, 0, 32); - helm.setRotationPoint(0.0F, 0.0F, 0.0F); - helm.addBox(-4.0F, -8.0F, -4.5F, 8, 3, 9, s); - setRotateAngle(helm, 0.08726646259971647F, 0.0F, 0.0F); - helmWing4 = new ModelRenderer(this, 46, 45); - helmWing4.setRotationPoint(4.0F, -4.0F, -1.0F); - helmWing4.addBox(-0.5F, 0.0F, 0.0F, 1, 3, 4, s); - setRotateAngle(helmWing4, -0.2617993877991494F, 0.2617993877991494F, -0.2617993877991494F); - armLpauldron = new ModelRenderer(this, 0, 67); - armLpauldron.mirror = true; - armLpauldron.setRotationPoint(0.0F, 0.0F, -0.0F); - armLpauldron.addBox(-1.0F, -2.5F, -3.0F, 5, 6, 6, s); - wing1_1 = new ModelRenderer(this, 56, 41); - wing1_1.setRotationPoint(4.5F, 0.0F, 0.0F); - wing1_1.addBox(0.0F, -3.0F, -0.5F, 0, 3, 4, s); - setRotateAngle(wing1_1, 0.2617993877991494F, 0.7853981633974483F, 0.2617993877991494F); - helm2 = new ModelRenderer(this, 50, 32); - helm2.mirror = true; - helm2.setRotationPoint(0.0F, 0.0F, 0.0F); - helm2.addBox(3.0F, -5.0F, -4.5F, 1, 5, 4, s); - wing2_3 = new ModelRenderer(this, 56, 44); - wing2_3.setRotationPoint(2.5F, 9.0F, 0.0F); - wing2_3.addBox(0.0F, 0.0F, -0.5F, 0, 1, 2, s); - setRotateAngle(wing2_3, 0.08726646259971647F, 0.7853981633974483F, 0.2617993877991494F); - wing1 = new ModelRenderer(this, 56, 41); - wing1.mirror = true; - wing1.setRotationPoint(-4.5F, 0.0F, 0.0F); - wing1.addBox(0.5F, -3.0F, 0.0F, 0, 3, 4, s); - setRotateAngle(wing1, 0.2617993877991494F, -0.7853981633974483F, -0.2617993877991494F); - body2 = new ModelRenderer(this, 0, 56); - body2.setRotationPoint(0.0F, 0.0F, 0.0F); - body2.addBox(-3.0F, 4.0F, -3.0F, 6, 6, 5, s); - setRotateAngle(body2, -0.08726646259971647F, 0.0F, 0.0F); - helmWing3 = new ModelRenderer(this, 32, 45); - helmWing3.setRotationPoint(4.0F, -4.0F, -1.0F); - helmWing3.addBox(-0.5F, -5.0F, 0.0F, 1, 5, 6, s); - setRotateAngle(helmWing3, 0.2617993877991494F, 0.5235987755982988F, 0.08726646259971647F); - helmWing1 = new ModelRenderer(this, 32, 45); - helmWing1.mirror = true; - helmWing1.setRotationPoint(-4.0F, -4.0F, -1.0F); - helmWing1.addBox(-0.5F, -5.0F, 0.0F, 1, 5, 6, s); - setRotateAngle(helmWing1, 0.2617993877991494F, -0.5235987755982988F, -0.08726646259971647F); - wing2 = new ModelRenderer(this, 56, 42); - wing2.mirror = true; - wing2.setRotationPoint(-4.5F, 0.0F, 0.0F); - wing2.addBox(0.5F, 0.0F, 0.0F, 0, 2, 3, s); - setRotateAngle(wing2, 0.08726646259971647F, -0.7853981633974483F, -0.2617993877991494F); - wing1_3 = new ModelRenderer(this, 56, 43); - wing1_3.setRotationPoint(2.5F, 9.0F, 0.0F); - wing1_3.addBox(0.0F, -2.0F, -0.5F, 0, 2, 3, s); - setRotateAngle(wing1_3, 0.2617993877991494F, 0.7853981633974483F, 0.2617993877991494F); - helm.addChild(fairy); - helm.addChild(helm3); - bootR.addChild(wing1_2); - helm.addChild(helm1); - belt.addChild(legL); - armR.addChild(armRpauldron); - belt.addChild(legR); - helm.addChild(helmWing2); - bootL.addChild(bootL1); - bootR.addChild(bootR1); - armLpauldron.addChild(wing2_1); - bootR.addChild(wing2_2); - helm.addChild(helmWing4); - armL.addChild(armLpauldron); - armLpauldron.addChild(wing1_1); - helm.addChild(helm2); - bootL.addChild(wing2_3); - armRpauldron.addChild(wing1); - body.addChild(body2); - helm.addChild(helmWing3); - helm.addChild(helmWing1); - armRpauldron.addChild(wing2); - bootL.addChild(wing1_3); - } + textureWidth = 64; + textureHeight = 128; + float s = 0.2F; + fairy = new ModelRenderer(this, 34, 32); + fairy.setRotationPoint(0.0F, 0.0F, 0.0F); + fairy.addBox(-2.0F, -8.5F, -7.0F, 4, 4, 4, s); + setRotateAngle(fairy, -0.17453292519943295F, 0.0F, 0.0F); + helm3 = new ModelRenderer(this, 0, 32); + helm3.setRotationPoint(0.0F, 0.0F, 0.0F); + helm3.addBox(-1.0F, -5.5F, -5.5F, 2, 3, 1, s); + setRotateAngle(helm3, -0.17453292519943295F, 0.0F, 0.0F); + wing1_2 = new ModelRenderer(this, 56, 43); + wing1_2.mirror = true; + wing1_2.setRotationPoint(-2.5F, 9.0F, 0.0F); + wing1_2.addBox(0.5F, -2.0F, 0.0F, 0, 2, 3, s); + setRotateAngle(wing1_2, 0.2617993877991494F, -0.7853981633974483F, -0.2617993877991494F); + helm1 = new ModelRenderer(this, 50, 32); + helm1.setRotationPoint(0.0F, 0.0F, 0.0F); + helm1.addBox(-4.0F, -5.0F, -4.5F, 1, 5, 4, s); + legL = new ModelRenderer(this, 12, 79); + legL.mirror = true; + legL.setRotationPoint(1.9F, 12.0F, 0.0F); + legL.addBox(-2.0F, 0.0F, -2.0F, 4, 6, 4, s); + setRotateAngle(legL, 0.0F, 0.0F, 0F); + armL = new ModelRenderer(this, 0, 79); + armL.mirror = true; + armL.setRotationPoint(5.0F, 2.0F, -0.0F); + armL.addBox(1.5F, 6.0F, -2.0F, 2, 4, 4, s); + setRotateAngle(armL, 0.0F, 0.0F, 0F); + armRpauldron = new ModelRenderer(this, 0, 67); + armRpauldron.setRotationPoint(0.0F, 0.0F, 0.0F); + armRpauldron.addBox(-4.0F, -2.5F, -3.0F, 5, 6, 6, s); + legR = new ModelRenderer(this, 12, 79); + legR.setRotationPoint(-1.9F, 12.0F, 0.0F); + legR.addBox(-2.0F, 0.0F, -2.0F, 4, 6, 4, s); + setRotateAngle(legR, 0.0F, 0.0F, 0F); + helmWing2 = new ModelRenderer(this, 46, 45); + helmWing2.mirror = true; + helmWing2.setRotationPoint(-4.0F, -4.0F, -1.0F); + helmWing2.addBox(-0.5F, 0.0F, 0.0F, 1, 3, 4, s); + setRotateAngle(helmWing2, -0.2617993877991494F, -0.2617993877991494F, 0.2617993877991494F); + bootL1 = new ModelRenderer(this, 12, 79); + bootL1.mirror = true; + bootL1.setRotationPoint(0.0F, 0.0F, 0.0F); + bootL1.addBox(-2.0F, 7.0F, -2.0F, 4, 1, 4, s); + armR = new ModelRenderer(this, 0, 79); + armR.setRotationPoint(-5.0F, 2.0F, 0.0F); + armR.addBox(-3.5F, 6.0F, -2.0F, 2, 4, 4, s); + setRotateAngle(armR, 0.0F, 0.0F, 0F); + bootR1 = new ModelRenderer(this, 12, 79); + bootR1.setRotationPoint(0.0F, 0.0F, 0.0F); + bootR1.addBox(-2.0F, 7.0F, -2.0F, 4, 1, 4, s); + bootR = new ModelRenderer(this, 12, 79); + bootR.setRotationPoint(-1.9F, 12.0F, 0.0F); + bootR.addBox(-2.0F, 8.0F, -3.0F, 4, 4, 5, s); + setRotateAngle(bootR, 0.0F, 0.0F, 0F); + wing2_1 = new ModelRenderer(this, 56, 42); + wing2_1.setRotationPoint(4.5F, 0.0F, 0.0F); + wing2_1.addBox(0.0F, 0.0F, -0.5F, 0, 2, 3, s); + setRotateAngle(wing2_1, 0.08726646259971647F, 0.7853981633974483F, 0.2617993877991494F); + wing2_2 = new ModelRenderer(this, 56, 44); + wing2_2.mirror = true; + wing2_2.setRotationPoint(-2.5F, 9.0F, 0.0F); + wing2_2.addBox(0.5F, 0.0F, 0.0F, 0, 1, 2, s); + setRotateAngle(wing2_2, 0.08726646259971647F, -0.7853981633974483F, -0.2617993877991494F); + bootL = new ModelRenderer(this, 12, 79); + bootL.mirror = true; + bootL.setRotationPoint(1.9F, 12.0F, 0.0F); + bootL.addBox(-2.0F, 8.0F, -3.0F, 4, 4, 5, s); + setRotateAngle(bootL, 0.0F, 0.0F, 0F); + body = new ModelRenderer(this, 0, 44); + body.setRotationPoint(0.0F, 0.0F, 0.0F); + body.addBox(-4.5F, 0.0F, -4.0F, 9, 5, 7, s); + setRotateAngle(body, 0.08726646259971647F, 0.0F, 0.0F); + belt = new ModelRenderer(this, 22, 56); + belt.setRotationPoint(0.0F, 0.0F, 0.0F); + belt.addBox(-4.5F, 9.5F, -3.0F, 9, 3, 5, s); + helm = new ModelRenderer(this, 0, 32); + helm.setRotationPoint(0.0F, 0.0F, 0.0F); + helm.addBox(-4.0F, -8.0F, -4.5F, 8, 3, 9, s); + setRotateAngle(helm, 0.08726646259971647F, 0.0F, 0.0F); + helmWing4 = new ModelRenderer(this, 46, 45); + helmWing4.setRotationPoint(4.0F, -4.0F, -1.0F); + helmWing4.addBox(-0.5F, 0.0F, 0.0F, 1, 3, 4, s); + setRotateAngle(helmWing4, -0.2617993877991494F, 0.2617993877991494F, -0.2617993877991494F); + armLpauldron = new ModelRenderer(this, 0, 67); + armLpauldron.mirror = true; + armLpauldron.setRotationPoint(0.0F, 0.0F, -0.0F); + armLpauldron.addBox(-1.0F, -2.5F, -3.0F, 5, 6, 6, s); + wing1_1 = new ModelRenderer(this, 56, 41); + wing1_1.setRotationPoint(4.5F, 0.0F, 0.0F); + wing1_1.addBox(0.0F, -3.0F, -0.5F, 0, 3, 4, s); + setRotateAngle(wing1_1, 0.2617993877991494F, 0.7853981633974483F, 0.2617993877991494F); + helm2 = new ModelRenderer(this, 50, 32); + helm2.mirror = true; + helm2.setRotationPoint(0.0F, 0.0F, 0.0F); + helm2.addBox(3.0F, -5.0F, -4.5F, 1, 5, 4, s); + wing2_3 = new ModelRenderer(this, 56, 44); + wing2_3.setRotationPoint(2.5F, 9.0F, 0.0F); + wing2_3.addBox(0.0F, 0.0F, -0.5F, 0, 1, 2, s); + setRotateAngle(wing2_3, 0.08726646259971647F, 0.7853981633974483F, 0.2617993877991494F); + wing1 = new ModelRenderer(this, 56, 41); + wing1.mirror = true; + wing1.setRotationPoint(-4.5F, 0.0F, 0.0F); + wing1.addBox(0.5F, -3.0F, 0.0F, 0, 3, 4, s); + setRotateAngle(wing1, 0.2617993877991494F, -0.7853981633974483F, -0.2617993877991494F); + body2 = new ModelRenderer(this, 0, 56); + body2.setRotationPoint(0.0F, 0.0F, 0.0F); + body2.addBox(-3.0F, 4.0F, -3.0F, 6, 6, 5, s); + setRotateAngle(body2, -0.08726646259971647F, 0.0F, 0.0F); + helmWing3 = new ModelRenderer(this, 32, 45); + helmWing3.setRotationPoint(4.0F, -4.0F, -1.0F); + helmWing3.addBox(-0.5F, -5.0F, 0.0F, 1, 5, 6, s); + setRotateAngle(helmWing3, 0.2617993877991494F, 0.5235987755982988F, 0.08726646259971647F); + helmWing1 = new ModelRenderer(this, 32, 45); + helmWing1.mirror = true; + helmWing1.setRotationPoint(-4.0F, -4.0F, -1.0F); + helmWing1.addBox(-0.5F, -5.0F, 0.0F, 1, 5, 6, s); + setRotateAngle(helmWing1, 0.2617993877991494F, -0.5235987755982988F, -0.08726646259971647F); + wing2 = new ModelRenderer(this, 56, 42); + wing2.mirror = true; + wing2.setRotationPoint(-4.5F, 0.0F, 0.0F); + wing2.addBox(0.5F, 0.0F, 0.0F, 0, 2, 3, s); + setRotateAngle(wing2, 0.08726646259971647F, -0.7853981633974483F, -0.2617993877991494F); + wing1_3 = new ModelRenderer(this, 56, 43); + wing1_3.setRotationPoint(2.5F, 9.0F, 0.0F); + wing1_3.addBox(0.0F, -2.0F, -0.5F, 0, 2, 3, s); + setRotateAngle(wing1_3, 0.2617993877991494F, 0.7853981633974483F, 0.2617993877991494F); + helm.addChild(fairy); + helm.addChild(helm3); + bootR.addChild(wing1_2); + helm.addChild(helm1); + belt.addChild(legL); + armR.addChild(armRpauldron); + belt.addChild(legR); + helm.addChild(helmWing2); + bootL.addChild(bootL1); + bootR.addChild(bootR1); + armLpauldron.addChild(wing2_1); + bootR.addChild(wing2_2); + helm.addChild(helmWing4); + armL.addChild(armLpauldron); + armLpauldron.addChild(wing1_1); + helm.addChild(helm2); + bootL.addChild(wing2_3); + armRpauldron.addChild(wing1); + body.addChild(body2); + helm.addChild(helmWing3); + helm.addChild(helmWing1); + armRpauldron.addChild(wing2); + bootL.addChild(wing1_3); + } - @Override - public void render(Entity entity, float f, float f1, float f2, float f3, float f4, float f5) { - helm.showModel = slot == 0; - body.showModel = slot == 1; - armR.showModel = slot == 1; - armL.showModel = slot == 1; - legR.showModel = slot == 2; - legL.showModel = slot == 2; - bootL.showModel = slot == 3; - bootR.showModel = slot == 3; - bipedHeadwear.showModel = false; + @Override + public void render(Entity entity, float f, float f1, float f2, float f3, float f4, float f5) { + helm.showModel = slot == 0; + body.showModel = slot == 1; + armR.showModel = slot == 1; + armL.showModel = slot == 1; + legR.showModel = slot == 2; + legL.showModel = slot == 2; + bootL.showModel = slot == 3; + bootR.showModel = slot == 3; + bipedHeadwear.showModel = false; - bipedHead = helm; - bipedBody = body; - bipedRightArm = armR; - bipedLeftArm = armL; - if (slot == 2) { - bipedRightLeg = legR; - bipedLeftLeg = legL; - } else { - bipedRightLeg = bootR; - bipedLeftLeg = bootL; - } + bipedHead = helm; + bipedBody = body; + bipedRightArm = armR; + bipedLeftArm = armL; + if(slot == 2) { + bipedRightLeg = legR; + bipedLeftLeg = legL; + } else { + bipedRightLeg = bootR; + bipedLeftLeg = bootL; + } - prepareForRender(entity); - super.render(entity, f, f1, f2, f3, f4, f5); - } + prepareForRender(entity); + super.render(entity, f, f1, f2, f3, f4, f5); + } - public void prepareForRender(Entity entity) { - EntityLivingBase living = (EntityLivingBase) entity; - isSneak = living != null ? living.isSneaking() : false; - if (living != null && living instanceof EntityPlayer) { - EntityPlayer player = (EntityPlayer) living; + public void prepareForRender(Entity entity) { + EntityLivingBase living = (EntityLivingBase) entity; + isSneak = living != null ? living.isSneaking() : false; + if(living != null && living instanceof EntityPlayer) { + EntityPlayer player = (EntityPlayer) living; - ItemStack itemstack = player.inventory.getCurrentItem(); - heldItemRight = itemstack != null ? 1 : 0; + ItemStack itemstack = player.inventory.getCurrentItem(); + heldItemRight = itemstack != null ? 1 : 0; - aimedBow = false; - if (itemstack != null && player.getItemInUseCount() > 0) { - EnumAction enumaction = itemstack.getItemUseAction(); + aimedBow = false; + if (itemstack != null && player.getItemInUseCount() > 0) { + EnumAction enumaction = itemstack.getItemUseAction(); - if (enumaction == EnumAction.block) heldItemRight = 3; - else if (enumaction == EnumAction.bow) aimedBow = true; - } - } - } + if (enumaction == EnumAction.block) + heldItemRight = 3; + else if (enumaction == EnumAction.bow) + aimedBow = true; + } + } + } - public void setRotateAngle(ModelRenderer modelRenderer, float x, float y, float z) { - modelRenderer.rotateAngleX = x; - modelRenderer.rotateAngleY = y; - modelRenderer.rotateAngleZ = z; - } -} + public void setRotateAngle(ModelRenderer modelRenderer, float x, float y, float z) { + modelRenderer.rotateAngleX = x; + modelRenderer.rotateAngleY = y; + modelRenderer.rotateAngleZ = z; + } + +} \ No newline at end of file diff --git a/src/main/java/vazkii/botania/client/model/armor/ModelArmorManasteel.java b/src/main/java/vazkii/botania/client/model/armor/ModelArmorManasteel.java index 508e3d3efa..a2d163a95c 100644 --- a/src/main/java/vazkii/botania/client/model/armor/ModelArmorManasteel.java +++ b/src/main/java/vazkii/botania/client/model/armor/ModelArmorManasteel.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [? (GMT)] */ package vazkii.botania.client.model.armor; @@ -20,174 +20,177 @@ public class ModelArmorManasteel extends ModelBiped { - public ModelRenderer helm; - public ModelRenderer body; - public ModelRenderer armR; - public ModelRenderer armL; - public ModelRenderer belt; - public ModelRenderer bootR; - public ModelRenderer bootL; - public ModelRenderer helm1; - public ModelRenderer helm2; - public ModelRenderer helm3; - public ModelRenderer helm4; - public ModelRenderer helm5; - public ModelRenderer helm6; - public ModelRenderer helm7; - public ModelRenderer body2; - public ModelRenderer armRpauldron; - public ModelRenderer armLpauldron; - public ModelRenderer legR; - public ModelRenderer legL; - - int slot; - - public ModelArmorManasteel(int slot) { - this.slot = slot; - - textureWidth = 64; - textureHeight = 128; - float s = 0.2F; - armRpauldron = new ModelRenderer(this, 30, 47); - armRpauldron.setRotationPoint(0.0F, 0.0F, 0.0F); - armRpauldron.addBox(-4.0F, -2.0F, -2.5F, 4, 4, 5, 0.2F); - armL = new ModelRenderer(this, 0, 68); - armL.mirror = true; - armL.setRotationPoint(5.0F, 2.0F, -0.0F); - armL.addBox(1.0F, 3.0F, -2.0F, 2, 6, 4, s); - setRotateAngle(armL, 0.0F, 0.0F, -0.17453292519943295F); - legR = new ModelRenderer(this, 12, 68); - legR.setRotationPoint(-1.9F, 12.0F, 0.0F); - legR.addBox(-2.0F, 0.0F, -2.0F, 4, 8, 4, s); - setRotateAngle(legR, 0.0F, 0.0F, 0F); - helm3 = new ModelRenderer(this, 24, 32); - helm3.setRotationPoint(0.0F, 0.0F, 0.0F); - helm3.addBox(-1.0F, -8.5F, -6.5F, 2, 5, 1, s); - setRotateAngle(helm3, -0.17453292519943295F, 0.0F, 0.0F); - helm7 = new ModelRenderer(this, 24, 32); - helm7.setRotationPoint(0.0F, 0.0F, 0.0F); - helm7.addBox(-1.0F, -8.5F, -6.0F, 2, 3, 1, s); - setRotateAngle(helm7, -0.3490658503988659F, 0.0F, 0.0F); - bootL = new ModelRenderer(this, 28, 68); - bootL.mirror = true; - bootL.setRotationPoint(2.0F, 12.0F, 0.0F); - bootL.addBox(-2.0F, 8.0F, -3.0F, 4, 4, 5, s); - setRotateAngle(bootL, 0.0F, 0.0F, 0F); - helm4 = new ModelRenderer(this, 0, 39); - helm4.setRotationPoint(0.0F, 0.0F, 0.0F); - helm4.addBox(-4.0F, -8.0F, -0.5F, 1, 3, 5, s); - bootR = new ModelRenderer(this, 28, 68); - bootR.setRotationPoint(-2.0F, 12.0F, 0.0F); - bootR.addBox(-2.0F, 8.0F, -3.0F, 4, 4, 5, s); - setRotateAngle(bootR, 0.0F, 0.0F, 0F); - legL = new ModelRenderer(this, 12, 68); - legL.mirror = true; - legL.setRotationPoint(1.9F, 12.0F, 0.0F); - legL.addBox(-2.0F, 0.0F, -2.0F, 4, 8, 4, s); - setRotateAngle(legL, 0.0F, 0.0F, 0F); - armR = new ModelRenderer(this, 0, 68); - armR.setRotationPoint(-5.0F, 2.0F, 0.0F); - armR.addBox(-3.0F, 3.0F, -2.0F, 2, 6, 4, s); - setRotateAngle(armR, 0.0F, 0.0F, 0.17453292519943295F); - helm1 = new ModelRenderer(this, 12, 39); - helm1.setRotationPoint(0.0F, 0.0F, 0.0F); - helm1.addBox(-4.0F, -5.0F, -4.5F, 1, 3, 4, s); - helm2 = new ModelRenderer(this, 12, 39); - helm2.mirror = true; - helm2.setRotationPoint(0.0F, 0.0F, 0.0F); - helm2.addBox(3.0F, -5.0F, -4.5F, 1, 3, 4, s); - body2 = new ModelRenderer(this, 0, 59); - body2.setRotationPoint(0.0F, 0.0F, 0.0F); - body2.addBox(-4.0F, 6.0F, -2.5F, 8, 4, 5, s); - setRotateAngle(body2, -0.08726646259971647F, 0.0F, 0.0F); - body = new ModelRenderer(this, 0, 47); - body.setRotationPoint(0.0F, 0.0F, 0.0F); - body.addBox(-4.5F, 0.0F, -3.5F, 9, 6, 6, s); - setRotateAngle(body, 0.08726646259971647F, 0.0F, 0.0F); - helm6 = new ModelRenderer(this, 24, 32); - helm6.setRotationPoint(0.0F, 0.0F, 0.0F); - helm6.addBox(-1.0F, -8.5F, -5.5F, 2, 3, 1, s); - setRotateAngle(helm6, -0.5235987755982988F, 0.0F, 0.0F); - belt = new ModelRenderer(this, 26, 59); - belt.setRotationPoint(0.0F, 0.0F, 0.0F); - belt.addBox(-4.5F, 9.5F, -3.0F, 9, 3, 6, s); - helm = new ModelRenderer(this, 0, 32); - helm.setRotationPoint(0.0F, 0.0F, 0.0F); - helm.addBox(-4.0F, -8.0F, -4.5F, 8, 3, 4, s); - setRotateAngle(helm, 0.08726646259971647F, 0.0F, 0.0F); - armLpauldron = new ModelRenderer(this, 30, 47); - armLpauldron.mirror = true; - armLpauldron.setRotationPoint(0.0F, 0.0F, -0.0F); - armLpauldron.addBox(0.0F, -2.0F, -2.5F, 4, 4, 5, s); - helm5 = new ModelRenderer(this, 0, 39); - helm5.mirror = true; - helm5.setRotationPoint(0.0F, 0.0F, 0.0F); - helm5.addBox(3.0F, -8.0F, -0.5F, 1, 3, 5, s); - - helm.addChild(helm3); - helm.addChild(helm7); - helm.addChild(helm4); - helm.addChild(helm6); - helm.addChild(helm1); - helm.addChild(helm2); - helm.addChild(helm5); - body.addChild(body2); - armL.addChild(armLpauldron); - armR.addChild(armRpauldron); - belt.addChild(legR); - belt.addChild(legL); - } - - @Override - public void render(Entity entity, float f, float f1, float f2, float f3, float f4, float f5) { - helm.showModel = slot == 0; - body.showModel = slot == 1; - armR.showModel = slot == 1; - armL.showModel = slot == 1; - legR.showModel = slot == 2; - legL.showModel = slot == 2; - bootL.showModel = slot == 3; - bootR.showModel = slot == 3; - bipedHeadwear.showModel = false; - - bipedHead = helm; - bipedBody = body; - bipedRightArm = armR; - bipedLeftArm = armL; - if (slot == 2) { - bipedRightLeg = legR; - bipedLeftLeg = legL; - } else { - bipedRightLeg = bootR; - bipedLeftLeg = bootL; - } - - prepareForRender(entity); - super.render(entity, f, f1, f2, f3, f4, f5); - } - - public void prepareForRender(Entity entity) { - EntityLivingBase living = (EntityLivingBase) entity; - isSneak = living != null ? living.isSneaking() : false; - if (living != null && living instanceof EntityPlayer) { - EntityPlayer player = (EntityPlayer) living; - - ItemStack itemstack = player.inventory.getCurrentItem(); - heldItemRight = itemstack != null ? 1 : 0; - - aimedBow = false; - if (itemstack != null && player.getItemInUseCount() > 0) { - EnumAction enumaction = itemstack.getItemUseAction(); - - if (enumaction == EnumAction.block) heldItemRight = 3; - else if (enumaction == EnumAction.bow) aimedBow = true; - } - } - } - - public void setRotateAngle(ModelRenderer modelRenderer, float x, float y, float z) { - modelRenderer.rotateAngleX = x; - modelRenderer.rotateAngleY = y; - modelRenderer.rotateAngleZ = z; - } -} + public ModelRenderer helm; + public ModelRenderer body; + public ModelRenderer armR; + public ModelRenderer armL; + public ModelRenderer belt; + public ModelRenderer bootR; + public ModelRenderer bootL; + public ModelRenderer helm1; + public ModelRenderer helm2; + public ModelRenderer helm3; + public ModelRenderer helm4; + public ModelRenderer helm5; + public ModelRenderer helm6; + public ModelRenderer helm7; + public ModelRenderer body2; + public ModelRenderer armRpauldron; + public ModelRenderer armLpauldron; + public ModelRenderer legR; + public ModelRenderer legL; + + int slot; + + public ModelArmorManasteel(int slot) { + this.slot = slot; + + textureWidth = 64; + textureHeight = 128; + float s = 0.2F; + armRpauldron = new ModelRenderer(this, 30, 47); + armRpauldron.setRotationPoint(0.0F, 0.0F, 0.0F); + armRpauldron.addBox(-4.0F, -2.0F, -2.5F, 4, 4, 5, 0.2F); + armL = new ModelRenderer(this, 0, 68); + armL.mirror = true; + armL.setRotationPoint(5.0F, 2.0F, -0.0F); + armL.addBox(1.0F, 3.0F, -2.0F, 2, 6, 4, s); + setRotateAngle(armL, 0.0F, 0.0F, -0.17453292519943295F); + legR = new ModelRenderer(this, 12, 68); + legR.setRotationPoint(-1.9F, 12.0F, 0.0F); + legR.addBox(-2.0F, 0.0F, -2.0F, 4, 8, 4, s); + setRotateAngle(legR, 0.0F, 0.0F, 0F); + helm3 = new ModelRenderer(this, 24, 32); + helm3.setRotationPoint(0.0F, 0.0F, 0.0F); + helm3.addBox(-1.0F, -8.5F, -6.5F, 2, 5, 1, s); + setRotateAngle(helm3, -0.17453292519943295F, 0.0F, 0.0F); + helm7 = new ModelRenderer(this, 24, 32); + helm7.setRotationPoint(0.0F, 0.0F, 0.0F); + helm7.addBox(-1.0F, -8.5F, -6.0F, 2, 3, 1, s); + setRotateAngle(helm7, -0.3490658503988659F, 0.0F, 0.0F); + bootL = new ModelRenderer(this, 28, 68); + bootL.mirror = true; + bootL.setRotationPoint(2.0F, 12.0F, 0.0F); + bootL.addBox(-2.0F, 8.0F, -3.0F, 4, 4, 5, s); + setRotateAngle(bootL, 0.0F, 0.0F, 0F); + helm4 = new ModelRenderer(this, 0, 39); + helm4.setRotationPoint(0.0F, 0.0F, 0.0F); + helm4.addBox(-4.0F, -8.0F, -0.5F, 1, 3, 5, s); + bootR = new ModelRenderer(this, 28, 68); + bootR.setRotationPoint(-2.0F, 12.0F, 0.0F); + bootR.addBox(-2.0F, 8.0F, -3.0F, 4, 4, 5, s); + setRotateAngle(bootR, 0.0F, 0.0F, 0F); + legL = new ModelRenderer(this, 12, 68); + legL.mirror = true; + legL.setRotationPoint(1.9F, 12.0F, 0.0F); + legL.addBox(-2.0F, 0.0F, -2.0F, 4, 8, 4, s); + setRotateAngle(legL, 0.0F, 0.0F, 0F); + armR = new ModelRenderer(this, 0, 68); + armR.setRotationPoint(-5.0F, 2.0F, 0.0F); + armR.addBox(-3.0F, 3.0F, -2.0F, 2, 6, 4, s); + setRotateAngle(armR, 0.0F, 0.0F, 0.17453292519943295F); + helm1 = new ModelRenderer(this, 12, 39); + helm1.setRotationPoint(0.0F, 0.0F, 0.0F); + helm1.addBox(-4.0F, -5.0F, -4.5F, 1, 3, 4, s); + helm2 = new ModelRenderer(this, 12, 39); + helm2.mirror = true; + helm2.setRotationPoint(0.0F, 0.0F, 0.0F); + helm2.addBox(3.0F, -5.0F, -4.5F, 1, 3, 4, s); + body2 = new ModelRenderer(this, 0, 59); + body2.setRotationPoint(0.0F, 0.0F, 0.0F); + body2.addBox(-4.0F, 6.0F, -2.5F, 8, 4, 5, s); + setRotateAngle(body2, -0.08726646259971647F, 0.0F, 0.0F); + body = new ModelRenderer(this, 0, 47); + body.setRotationPoint(0.0F, 0.0F, 0.0F); + body.addBox(-4.5F, 0.0F, -3.5F, 9, 6, 6, s); + setRotateAngle(body, 0.08726646259971647F, 0.0F, 0.0F); + helm6 = new ModelRenderer(this, 24, 32); + helm6.setRotationPoint(0.0F, 0.0F, 0.0F); + helm6.addBox(-1.0F, -8.5F, -5.5F, 2, 3, 1, s); + setRotateAngle(helm6, -0.5235987755982988F, 0.0F, 0.0F); + belt = new ModelRenderer(this, 26, 59); + belt.setRotationPoint(0.0F, 0.0F, 0.0F); + belt.addBox(-4.5F, 9.5F, -3.0F, 9, 3, 6, s); + helm = new ModelRenderer(this, 0, 32); + helm.setRotationPoint(0.0F, 0.0F, 0.0F); + helm.addBox(-4.0F, -8.0F, -4.5F, 8, 3, 4, s); + setRotateAngle(helm, 0.08726646259971647F, 0.0F, 0.0F); + armLpauldron = new ModelRenderer(this, 30, 47); + armLpauldron.mirror = true; + armLpauldron.setRotationPoint(0.0F, 0.0F, -0.0F); + armLpauldron.addBox(0.0F, -2.0F, -2.5F, 4, 4, 5, s); + helm5 = new ModelRenderer(this, 0, 39); + helm5.mirror = true; + helm5.setRotationPoint(0.0F, 0.0F, 0.0F); + helm5.addBox(3.0F, -8.0F, -0.5F, 1, 3, 5, s); + + helm.addChild(helm3); + helm.addChild(helm7); + helm.addChild(helm4); + helm.addChild(helm6); + helm.addChild(helm1); + helm.addChild(helm2); + helm.addChild(helm5); + body.addChild(body2); + armL.addChild(armLpauldron); + armR.addChild(armRpauldron); + belt.addChild(legR); + belt.addChild(legL); + } + + @Override + public void render(Entity entity, float f, float f1, float f2, float f3, float f4, float f5) { + helm.showModel = slot == 0; + body.showModel = slot == 1; + armR.showModel = slot == 1; + armL.showModel = slot == 1; + legR.showModel = slot == 2; + legL.showModel = slot == 2; + bootL.showModel = slot == 3; + bootR.showModel = slot == 3; + bipedHeadwear.showModel = false; + + bipedHead = helm; + bipedBody = body; + bipedRightArm = armR; + bipedLeftArm = armL; + if(slot == 2) { + bipedRightLeg = legR; + bipedLeftLeg = legL; + } else { + bipedRightLeg = bootR; + bipedLeftLeg = bootL; + } + + prepareForRender(entity); + super.render(entity, f, f1, f2, f3, f4, f5); + } + + public void prepareForRender(Entity entity) { + EntityLivingBase living = (EntityLivingBase) entity; + isSneak = living != null ? living.isSneaking() : false; + if(living != null && living instanceof EntityPlayer) { + EntityPlayer player = (EntityPlayer) living; + + ItemStack itemstack = player.inventory.getCurrentItem(); + heldItemRight = itemstack != null ? 1 : 0; + + aimedBow = false; + if (itemstack != null && player.getItemInUseCount() > 0) { + EnumAction enumaction = itemstack.getItemUseAction(); + + if (enumaction == EnumAction.block) + heldItemRight = 3; + else if(enumaction == EnumAction.bow) + aimedBow = true; + } + } + } + + public void setRotateAngle(ModelRenderer modelRenderer, float x, float y, float z) { + modelRenderer.rotateAngleX = x; + modelRenderer.rotateAngleY = y; + modelRenderer.rotateAngleZ = z; + } + +} \ No newline at end of file diff --git a/src/main/java/vazkii/botania/client/model/armor/ModelArmorManaweave.java b/src/main/java/vazkii/botania/client/model/armor/ModelArmorManaweave.java index 27aeb53bf0..ce2fd8c259 100644 --- a/src/main/java/vazkii/botania/client/model/armor/ModelArmorManaweave.java +++ b/src/main/java/vazkii/botania/client/model/armor/ModelArmorManaweave.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [? (GMT)] */ package vazkii.botania.client.model.armor; @@ -20,175 +20,178 @@ public class ModelArmorManaweave extends ModelBiped { - public ModelRenderer helm; - public ModelRenderer body; - public ModelRenderer armR; - public ModelRenderer armL; - public ModelRenderer legR; - public ModelRenderer legL; - public ModelRenderer bootR; - public ModelRenderer bootL; - public ModelRenderer helm2; - public ModelRenderer helm3; - public ModelRenderer helm4; - public ModelRenderer helmSeam1; - public ModelRenderer helmSeam2; - public ModelRenderer helmSeam3; - public ModelRenderer helmSeam4; - public ModelRenderer body2; - public ModelRenderer armRpauldron; - public ModelRenderer armLpauldron; - public ModelRenderer skirtR; - public ModelRenderer skirtL; + public ModelRenderer helm; + public ModelRenderer body; + public ModelRenderer armR; + public ModelRenderer armL; + public ModelRenderer legR; + public ModelRenderer legL; + public ModelRenderer bootR; + public ModelRenderer bootL; + public ModelRenderer helm2; + public ModelRenderer helm3; + public ModelRenderer helm4; + public ModelRenderer helmSeam1; + public ModelRenderer helmSeam2; + public ModelRenderer helmSeam3; + public ModelRenderer helmSeam4; + public ModelRenderer body2; + public ModelRenderer armRpauldron; + public ModelRenderer armLpauldron; + public ModelRenderer skirtR; + public ModelRenderer skirtL; - int slot; + int slot; - public ModelArmorManaweave(int slot) { - this.slot = slot; + public ModelArmorManaweave(int slot) { + this.slot = slot; - textureWidth = 64; - textureHeight = 128; - float s = 0.2F; - helmSeam3 = new ModelRenderer(this, 26, 61); - helmSeam3.setRotationPoint(0.0F, 0.0F, 0.0F); - helmSeam3.addBox(-0.5F, -9.5F, 5.0F, 1, 11, 1, s); - helmSeam4 = new ModelRenderer(this, 39, 64); - helmSeam4.setRotationPoint(0.0F, 0.0F, 0.0F); - helmSeam4.addBox(-0.5F, 0.5F, -1.0F, 1, 1, 6, s); - skirtL = new ModelRenderer(this, 0, 83); - skirtL.mirror = true; - skirtL.setRotationPoint(0.0F, 0.0F, 0.0F); - skirtL.addBox(-2.0F, -2.0F, -3.5F, 5, 13, 7, s); - setRotateAngle(skirtL, 0.0F, -0.17453292519943295F, -0.2617993877991494F); - armR = new ModelRenderer(this, 24, 83); - armR.setRotationPoint(-5.0F, 2.0F, 0.0F); - armR.addBox(-3.0F, -1.5F, -2.5F, 4, 10, 5, s); - setRotateAngle(armR, 0.0F, 0.0F, 0F); - armL = new ModelRenderer(this, 24, 83); - armL.mirror = true; - armL.setRotationPoint(5.0F, 2.0F, -0.0F); - armL.addBox(-1.0F, -1.5F, -2.5F, 4, 10, 5, s); - setRotateAngle(armL, 0.0F, 0.0F, 0F); - bootR = new ModelRenderer(this, 0, 103); - bootR.setRotationPoint(-2.0F, 12.0F, 0.0F); - bootR.addBox(-2.0F, 8.0F, -3.0F, 4, 4, 5, s); - setRotateAngle(bootR, 0.0F, 0.0F, 0F); - legR = new ModelRenderer(this, 42, 81); - legR.setRotationPoint(-2.0F, 12.0F, 0.0F); - legR.addBox(-2.0F, 0.0F, -2.0F, 4, 6, 4, s); - setRotateAngle(legR, 0.0F, 0.0F, 0F); - helm2 = new ModelRenderer(this, 38, 42); - helm2.setRotationPoint(0.0F, 0.0F, 0.0F); - helm2.addBox(-4.49F, -4.0F, -2.5F, 1, 5, 8, s); - skirtR = new ModelRenderer(this, 0, 83); - skirtR.setRotationPoint(0.0F, 0.0F, 0.0F); - skirtR.addBox(-3.0F, -2.0F, -3.5F, 5, 13, 7, s); - setRotateAngle(skirtR, 0.0F, 0.17453292519943295F, 0.2617993877991494F); - armRpauldron = new ModelRenderer(this, 0, 72); - armRpauldron.setRotationPoint(0.0F, 0.0F, 0.0F); - armRpauldron.addBox(-4.0F, -2.0F, -3.0F, 3, 5, 6, s); - setRotateAngle(armRpauldron, 0.0F, 0.0F, 0F); - bootL = new ModelRenderer(this, 0, 103); - bootL.setRotationPoint(2.0F, 12.0F, 0.0F); - bootL.addBox(-2.0F, 8.0F, -3.0F, 4, 4, 5, s); - setRotateAngle(bootL, 0.0F, 0.0F, 0F); - helmSeam1 = new ModelRenderer(this, 30, 61); - helmSeam1.setRotationPoint(0.0F, 0.0F, 0.0F); - helmSeam1.addBox(-0.5F, -10.5F, -5.0F, 1, 7, 2, s); - helm = new ModelRenderer(this, 0, 32); - helm.setRotationPoint(0.0F, 0.0F, 0.0F); - helm.addBox(-4.5F, -10.0F, -4.5F, 9, 6, 10, s); - setRotateAngle(helm, 0F, 0.0F, 0.0F); - armLpauldron = new ModelRenderer(this, 0, 72); - armLpauldron.mirror = true; - armLpauldron.setRotationPoint(0.0F, 0.0F, 0.0F); - armLpauldron.addBox(1.0F, -2.0F, -3.0F, 3, 5, 6, s); - setRotateAngle(armLpauldron, 0.0F, 0.0F, 0F); - helm4 = new ModelRenderer(this, 38, 32); - helm4.setRotationPoint(0.0F, 0.0F, 0.0F); - helm4.addBox(-3.5F, -4.0F, 0.49F, 7, 5, 5, s); - helmSeam2 = new ModelRenderer(this, 36, 61); - helmSeam2.setRotationPoint(0.0F, 0.0F, 0.0F); - helmSeam2.addBox(-0.5F, -10.5F, -3.0F, 1, 1, 9, s); - legL = new ModelRenderer(this, 42, 81); - legL.mirror = true; - legL.setRotationPoint(2.0F, 12.0F, 0.0F); - legL.addBox(-2.0F, 0.0F, -2.0F, 4, 6, 4, s); - setRotateAngle(legL, 0.0F, 0.0F, 0F); - body2 = new ModelRenderer(this, 0, 61); - body2.setRotationPoint(0.0F, 0.0F, 0.0F); - body2.addBox(-4.0F, 6.0F, -2.5F, 8, 6, 5, s); - body = new ModelRenderer(this, 0, 48); - body.setRotationPoint(0.0F, 0.0F, 0.0F); - body.addBox(-4.5F, 0.0F, -3.0F, 9, 7, 6, s); - helm3 = new ModelRenderer(this, 38, 42); - helm3.mirror = true; - helm3.setRotationPoint(0.0F, 0.0F, 0F); - helm3.addBox(3.49F, -4.0F, -2.5F, 1, 5, 8, s); - helm.addChild(helmSeam3); - helm.addChild(helmSeam4); - legL.addChild(skirtL); - helm.addChild(helm2); - legR.addChild(skirtR); - armR.addChild(armRpauldron); - helm.addChild(helmSeam1); - armL.addChild(armLpauldron); - helm.addChild(helm4); - helm.addChild(helmSeam2); - body.addChild(body2); - helm.addChild(helm3); - } + textureWidth = 64; + textureHeight = 128; + float s = 0.2F; + helmSeam3 = new ModelRenderer(this, 26, 61); + helmSeam3.setRotationPoint(0.0F, 0.0F, 0.0F); + helmSeam3.addBox(-0.5F, -9.5F, 5.0F, 1, 11, 1, s); + helmSeam4 = new ModelRenderer(this, 39, 64); + helmSeam4.setRotationPoint(0.0F, 0.0F, 0.0F); + helmSeam4.addBox(-0.5F, 0.5F, -1.0F, 1, 1, 6, s); + skirtL = new ModelRenderer(this, 0, 83); + skirtL.mirror = true; + skirtL.setRotationPoint(0.0F, 0.0F, 0.0F); + skirtL.addBox(-2.0F, -2.0F, -3.5F, 5, 13, 7, s); + setRotateAngle(skirtL, 0.0F, -0.17453292519943295F, -0.2617993877991494F); + armR = new ModelRenderer(this, 24, 83); + armR.setRotationPoint(-5.0F, 2.0F, 0.0F); + armR.addBox(-3.0F, -1.5F, -2.5F, 4, 10, 5, s); + setRotateAngle(armR, 0.0F, 0.0F, 0F); + armL = new ModelRenderer(this, 24, 83); + armL.mirror = true; + armL.setRotationPoint(5.0F, 2.0F, -0.0F); + armL.addBox(-1.0F, -1.5F, -2.5F, 4, 10, 5, s); + setRotateAngle(armL, 0.0F, 0.0F, 0F); + bootR = new ModelRenderer(this, 0, 103); + bootR.setRotationPoint(-2.0F, 12.0F, 0.0F); + bootR.addBox(-2.0F, 8.0F, -3.0F, 4, 4, 5, s); + setRotateAngle(bootR, 0.0F, 0.0F, 0F); + legR = new ModelRenderer(this, 42, 81); + legR.setRotationPoint(-2.0F, 12.0F, 0.0F); + legR.addBox(-2.0F, 0.0F, -2.0F, 4, 6, 4, s); + setRotateAngle(legR, 0.0F, 0.0F, 0F); + helm2 = new ModelRenderer(this, 38, 42); + helm2.setRotationPoint(0.0F, 0.0F, 0.0F); + helm2.addBox(-4.49F, -4.0F, -2.5F, 1, 5, 8, s); + skirtR = new ModelRenderer(this, 0, 83); + skirtR.setRotationPoint(0.0F, 0.0F, 0.0F); + skirtR.addBox(-3.0F, -2.0F, -3.5F, 5, 13, 7, s); + setRotateAngle(skirtR, 0.0F, 0.17453292519943295F, 0.2617993877991494F); + armRpauldron = new ModelRenderer(this, 0, 72); + armRpauldron.setRotationPoint(0.0F, 0.0F, 0.0F); + armRpauldron.addBox(-4.0F, -2.0F, -3.0F, 3, 5, 6, s); + setRotateAngle(armRpauldron, 0.0F, 0.0F, 0F); + bootL = new ModelRenderer(this, 0, 103); + bootL.setRotationPoint(2.0F, 12.0F, 0.0F); + bootL.addBox(-2.0F, 8.0F, -3.0F, 4, 4, 5, s); + setRotateAngle(bootL, 0.0F, 0.0F, 0F); + helmSeam1 = new ModelRenderer(this, 30, 61); + helmSeam1.setRotationPoint(0.0F, 0.0F, 0.0F); + helmSeam1.addBox(-0.5F, -10.5F, -5.0F, 1, 7, 2, s); + helm = new ModelRenderer(this, 0, 32); + helm.setRotationPoint(0.0F, 0.0F, 0.0F); + helm.addBox(-4.5F, -10.0F, -4.5F, 9, 6, 10, s); + setRotateAngle(helm, 0F, 0.0F, 0.0F); + armLpauldron = new ModelRenderer(this, 0, 72); + armLpauldron.mirror = true; + armLpauldron.setRotationPoint(0.0F, 0.0F, 0.0F); + armLpauldron.addBox(1.0F, -2.0F, -3.0F, 3, 5, 6, s); + setRotateAngle(armLpauldron, 0.0F, 0.0F, 0F); + helm4 = new ModelRenderer(this, 38, 32); + helm4.setRotationPoint(0.0F, 0.0F, 0.0F); + helm4.addBox(-3.5F, -4.0F, 0.49F, 7, 5, 5, s); + helmSeam2 = new ModelRenderer(this, 36, 61); + helmSeam2.setRotationPoint(0.0F, 0.0F, 0.0F); + helmSeam2.addBox(-0.5F, -10.5F, -3.0F, 1, 1, 9, s); + legL = new ModelRenderer(this, 42, 81); + legL.mirror = true; + legL.setRotationPoint(2.0F, 12.0F, 0.0F); + legL.addBox(-2.0F, 0.0F, -2.0F, 4, 6, 4, s); + setRotateAngle(legL, 0.0F, 0.0F, 0F); + body2 = new ModelRenderer(this, 0, 61); + body2.setRotationPoint(0.0F, 0.0F, 0.0F); + body2.addBox(-4.0F, 6.0F, -2.5F, 8, 6, 5, s); + body = new ModelRenderer(this, 0, 48); + body.setRotationPoint(0.0F, 0.0F, 0.0F); + body.addBox(-4.5F, 0.0F, -3.0F, 9, 7, 6, s); + helm3 = new ModelRenderer(this, 38, 42); + helm3.mirror = true; + helm3.setRotationPoint(0.0F, 0.0F, 0F); + helm3.addBox(3.49F, -4.0F, -2.5F, 1, 5, 8, s); + helm.addChild(helmSeam3); + helm.addChild(helmSeam4); + legL.addChild(skirtL); + helm.addChild(helm2); + legR.addChild(skirtR); + armR.addChild(armRpauldron); + helm.addChild(helmSeam1); + armL.addChild(armLpauldron); + helm.addChild(helm4); + helm.addChild(helmSeam2); + body.addChild(body2); + helm.addChild(helm3); + } - @Override - public void render(Entity entity, float f, float f1, float f2, float f3, float f4, float f5) { - helm.showModel = slot == 0; - body.showModel = slot == 1; - armR.showModel = slot == 1; - armL.showModel = slot == 1; - legR.showModel = slot == 2; - legL.showModel = slot == 2; - bootL.showModel = slot == 3; - bootR.showModel = slot == 3; - bipedHeadwear.showModel = false; + @Override + public void render(Entity entity, float f, float f1, float f2, float f3, float f4, float f5) { + helm.showModel = slot == 0; + body.showModel = slot == 1; + armR.showModel = slot == 1; + armL.showModel = slot == 1; + legR.showModel = slot == 2; + legL.showModel = slot == 2; + bootL.showModel = slot == 3; + bootR.showModel = slot == 3; + bipedHeadwear.showModel = false; - bipedHead = helm; - bipedBody = body; - bipedRightArm = armR; - bipedLeftArm = armL; - if (slot == 2) { - bipedRightLeg = legR; - bipedLeftLeg = legL; - } else { - bipedRightLeg = bootR; - bipedLeftLeg = bootL; - } + bipedHead = helm; + bipedBody = body; + bipedRightArm = armR; + bipedLeftArm = armL; + if(slot == 2) { + bipedRightLeg = legR; + bipedLeftLeg = legL; + } else { + bipedRightLeg = bootR; + bipedLeftLeg = bootL; + } - prepareForRender(entity); - super.render(entity, f, f1, f2, f3, f4, f5); - } + prepareForRender(entity); + super.render(entity, f, f1, f2, f3, f4, f5); + } - public void prepareForRender(Entity entity) { - EntityLivingBase living = (EntityLivingBase) entity; - isSneak = living != null ? living.isSneaking() : false; - if (living != null && living instanceof EntityPlayer) { - EntityPlayer player = (EntityPlayer) living; + public void prepareForRender(Entity entity) { + EntityLivingBase living = (EntityLivingBase) entity; + isSneak = living != null ? living.isSneaking() : false; + if(living != null && living instanceof EntityPlayer) { + EntityPlayer player = (EntityPlayer) living; - ItemStack itemstack = player.inventory.getCurrentItem(); - heldItemRight = itemstack != null ? 1 : 0; + ItemStack itemstack = player.inventory.getCurrentItem(); + heldItemRight = itemstack != null ? 1 : 0; - aimedBow = false; - if (itemstack != null && player.getItemInUseCount() > 0) { - EnumAction enumaction = itemstack.getItemUseAction(); + aimedBow = false; + if (itemstack != null && player.getItemInUseCount() > 0) { + EnumAction enumaction = itemstack.getItemUseAction(); - if (enumaction == EnumAction.block) heldItemRight = 3; - else if (enumaction == EnumAction.bow) aimedBow = true; - } - } - } + if (enumaction == EnumAction.block) + heldItemRight = 3; + else if (enumaction == EnumAction.bow) + aimedBow = true; + } + } + } - public void setRotateAngle(ModelRenderer modelRenderer, float x, float y, float z) { - modelRenderer.rotateAngleX = x; - modelRenderer.rotateAngleY = y; - modelRenderer.rotateAngleZ = z; - } -} + public void setRotateAngle(ModelRenderer modelRenderer, float x, float y, float z) { + modelRenderer.rotateAngleX = x; + modelRenderer.rotateAngleY = y; + modelRenderer.rotateAngleZ = z; + } + +} \ No newline at end of file diff --git a/src/main/java/vazkii/botania/client/model/armor/ModelArmorTerrasteel.java b/src/main/java/vazkii/botania/client/model/armor/ModelArmorTerrasteel.java index f6bc4efc83..91104c4eeb 100644 --- a/src/main/java/vazkii/botania/client/model/armor/ModelArmorTerrasteel.java +++ b/src/main/java/vazkii/botania/client/model/armor/ModelArmorTerrasteel.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [? (GMT)] */ package vazkii.botania.client.model.armor; @@ -20,266 +20,269 @@ public class ModelArmorTerrasteel extends ModelBiped { - public ModelRenderer helm; - public ModelRenderer body; - public ModelRenderer armr; - public ModelRenderer armL; - public ModelRenderer belt; - public ModelRenderer bootR; - public ModelRenderer bootL; - public ModelRenderer helm2; - public ModelRenderer helm3; - public ModelRenderer helm4; - public ModelRenderer helmLeaf1; - public ModelRenderer helmLeaf2; - public ModelRenderer helmLeaf3; - public ModelRenderer helmLeaf4; - public ModelRenderer helmLeaf5; - public ModelRenderer helmLeaf6; - public ModelRenderer helmbranch1; - public ModelRenderer helmbranch2; - public ModelRenderer helmbranch3; - public ModelRenderer helmbranch4; - public ModelRenderer body2; - public ModelRenderer armRpauldron; - public ModelRenderer armRbranch1; - public ModelRenderer armRbranch2; - public ModelRenderer armLpauldron; - public ModelRenderer armLbranch1; - public ModelRenderer armLbranch2; - public ModelRenderer legR; - public ModelRenderer legL; - public ModelRenderer bootR1; - public ModelRenderer bootRbranch; - public ModelRenderer bootL2; - public ModelRenderer bootLbranch; + public ModelRenderer helm; + public ModelRenderer body; + public ModelRenderer armr; + public ModelRenderer armL; + public ModelRenderer belt; + public ModelRenderer bootR; + public ModelRenderer bootL; + public ModelRenderer helm2; + public ModelRenderer helm3; + public ModelRenderer helm4; + public ModelRenderer helmLeaf1; + public ModelRenderer helmLeaf2; + public ModelRenderer helmLeaf3; + public ModelRenderer helmLeaf4; + public ModelRenderer helmLeaf5; + public ModelRenderer helmLeaf6; + public ModelRenderer helmbranch1; + public ModelRenderer helmbranch2; + public ModelRenderer helmbranch3; + public ModelRenderer helmbranch4; + public ModelRenderer body2; + public ModelRenderer armRpauldron; + public ModelRenderer armRbranch1; + public ModelRenderer armRbranch2; + public ModelRenderer armLpauldron; + public ModelRenderer armLbranch1; + public ModelRenderer armLbranch2; + public ModelRenderer legR; + public ModelRenderer legL; + public ModelRenderer bootR1; + public ModelRenderer bootRbranch; + public ModelRenderer bootL2; + public ModelRenderer bootLbranch; - int slot; + int slot; - public ModelArmorTerrasteel(int slot) { - this.slot = slot; + public ModelArmorTerrasteel(int slot) { + this.slot = slot; - textureWidth = 64; - textureHeight = 128; - float s = 0.2F; - armr = new ModelRenderer(this, 0, 77); - armr.setRotationPoint(-5.0F, 2.0F, -0.0F); - armr.addBox(-3.0F, 3.0F, -2.0F, 4, 7, 4, s); - setRotateAngle(armr, 0.0F, 0.0F, 0F); - body = new ModelRenderer(this, 0, 44); - body.setRotationPoint(0.0F, 0.0F, 0.0F); - body.addBox(-4.5F, 0.0F, -3.5F, 9, 6, 6, s); - setRotateAngle(body, 0F, 0.0F, 0.0F); - helm4 = new ModelRenderer(this, 56, 32); - helm4.setRotationPoint(0.0F, 0.0F, 0.0F); - helm4.addBox(-1.0F, -7.5F, -6.5F, 2, 6, 2, s); - setRotateAngle(helm4, 0F, 0.0F, 0.0F); - bootR1 = new ModelRenderer(this, 32, 77); - bootR1.setRotationPoint(0.0F, 0.0F, 0.0F); - bootR1.addBox(-2.0F, 6.0F, -2.0F, 4, 2, 4, s); - helmbranch4 = new ModelRenderer(this, 34, 43); - helmbranch4.mirror = true; - helmbranch4.setRotationPoint(0.0F, 0.0F, 0.0F); - helmbranch4.addBox(-2.0F, -8.0F, -4.0F, 1, 2, 7, s); - setRotateAngle(helmbranch4, 0.2617993877991494F, 0.0F, 1.0471975511965976F); - bootL = new ModelRenderer(this, 32, 83); - bootL.mirror = true; - bootL.setRotationPoint(1.9F, 12.0F, 0.0F); - bootL.addBox(-2.0F, 8.0F, -3.0F, 4, 4, 5, s); - setRotateAngle(bootL, 0.0F, 0.0F, 0F); - bootR = new ModelRenderer(this, 32, 83); - bootR.setRotationPoint(-1.9F, 12.0F, 0.1F); - bootR.addBox(-2.0F, 8.0F, -3.0F, 4, 4, 5, s); - setRotateAngle(bootR, 0.0F, 0.0F, 0F); - helmLeaf5 = new ModelRenderer(this, 50, 32); - helmLeaf5.mirror = true; - helmLeaf5.setRotationPoint(0.0F, 0.2F, 0.0F); - helmLeaf5.addBox(-1.0F, -11.0F, -4.5F, 2, 5, 1, s); - setRotateAngle(helmLeaf5, -0.5235987755982988F, -0.5235987755982988F, 0.5235987755982988F); - bootLbranch = new ModelRenderer(this, 48, 77); - bootLbranch.mirror = true; - bootLbranch.setRotationPoint(0.0F, 0.0F, 0.0F); - bootLbranch.addBox(8.0F, 1.0F, -2.0F, 1, 2, 5, s); - setRotateAngle(bootLbranch, 0.2617993877991494F, 0.0F, 1.0471975511965976F); - helmLeaf4 = new ModelRenderer(this, 50, 32); - helmLeaf4.mirror = true; - helmLeaf4.setRotationPoint(0.0F, 0.2F, 0.0F); - helmLeaf4.addBox(-1.5F, -9.0F, -6.0F, 2, 3, 1, s); - setRotateAngle(helmLeaf4, -0.2617993877991494F, -0.2617993877991494F, 0.5235987755982988F); - helmLeaf2 = new ModelRenderer(this, 50, 32); - helmLeaf2.setRotationPoint(0.0F, 0.2F, 0.0F); - helmLeaf2.addBox(-1.0F, -11.0F, -4.5F, 2, 5, 1, s); - setRotateAngle(helmLeaf2, -0.5235987755982988F, 0.5235987755982988F, -0.5235987755982988F); - helm = new ModelRenderer(this, 0, 32); - helm.setRotationPoint(0.0F, 0.0F, 0.0F); - helm.addBox(-4.0F, -8.0F, -4.5F, 8, 3, 9, s); - setRotateAngle(helm, 0.08726646259971647F, 0.0F, 0.0F); - helm2 = new ModelRenderer(this, 34, 32); - helm2.setRotationPoint(0.0F, 0.0F, 0.0F); - helm2.addBox(-4.0F, -5.0F, -4.5F, 2, 5, 6, s); - helm3 = new ModelRenderer(this, 34, 32); - helm3.mirror = true; - helm3.setRotationPoint(0.0F, 0.0F, 0.0F); - helm3.addBox(2.0F, -5.0F, -4.5F, 2, 5, 6, s); - helmbranch1 = new ModelRenderer(this, 34, 43); - helmbranch1.mirror = true; - helmbranch1.setRotationPoint(0.0F, 0.0F, 0F); - helmbranch1.addBox(-2.0F, -10.0F, -1.0F, 1, 2, 7, s); - setRotateAngle(helmbranch1, 0.5235987755982988F, 0.0F, -0.08726646259971647F); - bootL2 = new ModelRenderer(this, 32, 77); - bootL2.mirror = true; - bootL2.setRotationPoint(0.0F, 0.0F, 0.0F); - bootL2.addBox(-2.0F, 6.0F, -2.0F, 4, 2, 4, s); - helmbranch2 = new ModelRenderer(this, 34, 43); - helmbranch2.setRotationPoint(0.0F, 0.0F, 0.0F); - helmbranch2.addBox(1.0F, -10.0F, -1.0F, 1, 2, 7, s); - setRotateAngle(helmbranch2, 0.5235987755982988F, 0.0F, 0.08726646259971647F); - legR = new ModelRenderer(this, 16, 77); - legR.setRotationPoint(-1.9F, 12.0F, 0.0F); - legR.addBox(-2.0F, 0.0F, -2.0F, 4, 6, 4, s); - setRotateAngle(legR, 0.0F, 0.0F, 0F); - helmLeaf6 = new ModelRenderer(this, 50, 32); - helmLeaf6.mirror = true; - helmLeaf6.setRotationPoint(0.0F, 0.2F, 0.0F); - helmLeaf6.addBox(-0.5F, -13.0F, -3.0F, 2, 7, 1, s); - setRotateAngle(helmLeaf6, -0.7853981633974483F, -0.7853981633974483F, 0.7853981633974483F); - armLbranch1 = new ModelRenderer(this, 51, 44); - armLbranch1.mirror = true; - armLbranch1.setRotationPoint(0.0F, 0.0F, -0.0F); - armLbranch1.addBox(2.5F, -5.0F, -1.0F, 1, 5, 2, s); - setRotateAngle(armLbranch1, 0.0F, 0.0F, 0.7853981633974483F); - bootRbranch = new ModelRenderer(this, 48, 77); - bootRbranch.setRotationPoint(0.0F, 0.0F, 0.0F); - bootRbranch.addBox(-9.0F, 1.0F, -2.0F, 1, 2, 5, s); - setRotateAngle(bootRbranch, 0.2617993877991494F, 0.0F, -1.0471975511965976F); - armRbranch2 = new ModelRenderer(this, 50, 43); - armRbranch2.setRotationPoint(0.0F, 0.0F, 0.0F); - armRbranch2.addBox(-1.5F, -5.0F, -1.5F, 1, 5, 3, s); - setRotateAngle(armRbranch2, 0.0F, 0.0F, -0.5235987755982988F); - helmLeaf3 = new ModelRenderer(this, 50, 32); - helmLeaf3.setRotationPoint(0.0F, 0.2F, 0.0F); - helmLeaf3.addBox(-1.5F, -13.0F, -3.0F, 2, 7, 1, s); - setRotateAngle(helmLeaf3, -0.7853981633974483F, 0.7853981633974483F, -0.7853981633974483F); - armRpauldron = new ModelRenderer(this, 0, 66); - armRpauldron.setRotationPoint(0.0F, 0.0F, 0.0F); - armRpauldron.addBox(-4.0F, -2.0F, -3.0F, 5, 5, 6, s); - armLbranch2 = new ModelRenderer(this, 50, 43); - armLbranch2.mirror = true; - armLbranch2.setRotationPoint(0.0F, 0.0F, -0.0F); - armLbranch2.addBox(0.5F, -5.0F, -1.5F, 1, 5, 3, s); - setRotateAngle(armLbranch2, 0.0F, 0.0F, 0.5235987755982988F); - armL = new ModelRenderer(this, 0, 77); - armL.mirror = true; - armL.setRotationPoint(5.0F, 2.0F, -0.0F); - armL.addBox(-1.0F, 3.0F, -2.0F, 4, 7, 4, s); - setRotateAngle(armL, 0.0F, 0.0F, 0F); - body2 = new ModelRenderer(this, 0, 57); - body2.setRotationPoint(0.0F, 0.0F, 0.0F); - body2.addBox(-4.0F, 6.0F, -2.5F, 8, 4, 5, s); - setRotateAngle(body2, -0.08726646259971647F, 0.0F, 0.0F); - helmbranch3 = new ModelRenderer(this, 34, 43); - helmbranch3.setRotationPoint(0.0F, 0.0F, 0.0F); - helmbranch3.addBox(1.0F, -8.0F, -4.0F, 1, 2, 7, s); - setRotateAngle(helmbranch3, 0.2617993877991494F, 0.0F, -1.0471975511965976F); - armRbranch1 = new ModelRenderer(this, 51, 44); - armRbranch1.setRotationPoint(0.0F, 0.0F, 0.0F); - armRbranch1.addBox(-3.5F, -5.0F, -1.0F, 1, 5, 2, s); - setRotateAngle(armRbranch1, 0.0F, 0.0F, -0.7853981633974483F); - belt = new ModelRenderer(this, 22, 66); - belt.setRotationPoint(0.0F, 0.0F, 0.0F); - belt.addBox(-4.5F, 9.5F, -3.0F, 9, 3, 6, s); - helmLeaf1 = new ModelRenderer(this, 50, 32); - helmLeaf1.setRotationPoint(0.0F, 0.2F, 0.0F); - helmLeaf1.addBox(-0.5F, -9.0F, -6.0F, 2, 3, 1, s); - setRotateAngle(helmLeaf1, -0.2617993877991494F, 0.2617993877991494F, -0.5235987755982988F); - armLpauldron = new ModelRenderer(this, 0, 66); - armLpauldron.mirror = true; - armLpauldron.setRotationPoint(0.0F, 0.0F, -0.0F); - armLpauldron.addBox(-1.0F, -2.0F, -3.0F, 5, 5, 6, s); - legL = new ModelRenderer(this, 16, 77); - legL.mirror = true; - legL.setRotationPoint(1.9F, 12.0F, 0.0F); - legL.addBox(-2.0F, 0.0F, -2.0F, 4, 6, 4, s); - setRotateAngle(legL, 0.0F, 0.0F, 0F); + textureWidth = 64; + textureHeight = 128; + float s = 0.2F; + armr = new ModelRenderer(this, 0, 77); + armr.setRotationPoint(-5.0F, 2.0F, -0.0F); + armr.addBox(-3.0F, 3.0F, -2.0F, 4, 7, 4, s); + setRotateAngle(armr, 0.0F, 0.0F, 0F); + body = new ModelRenderer(this, 0, 44); + body.setRotationPoint(0.0F, 0.0F, 0.0F); + body.addBox(-4.5F, 0.0F, -3.5F, 9, 6, 6, s); + setRotateAngle(body, 0F, 0.0F, 0.0F); + helm4 = new ModelRenderer(this, 56, 32); + helm4.setRotationPoint(0.0F, 0.0F, 0.0F); + helm4.addBox(-1.0F, -7.5F, -6.5F, 2, 6, 2, s); + setRotateAngle(helm4, 0F, 0.0F, 0.0F); + bootR1 = new ModelRenderer(this, 32, 77); + bootR1.setRotationPoint(0.0F, 0.0F, 0.0F); + bootR1.addBox(-2.0F, 6.0F, -2.0F, 4, 2, 4, s); + helmbranch4 = new ModelRenderer(this, 34, 43); + helmbranch4.mirror = true; + helmbranch4.setRotationPoint(0.0F, 0.0F, 0.0F); + helmbranch4.addBox(-2.0F, -8.0F, -4.0F, 1, 2, 7, s); + setRotateAngle(helmbranch4, 0.2617993877991494F, 0.0F, 1.0471975511965976F); + bootL = new ModelRenderer(this, 32, 83); + bootL.mirror = true; + bootL.setRotationPoint(1.9F, 12.0F, 0.0F); + bootL.addBox(-2.0F, 8.0F, -3.0F, 4, 4, 5, s); + setRotateAngle(bootL, 0.0F, 0.0F, 0F); + bootR = new ModelRenderer(this, 32, 83); + bootR.setRotationPoint(-1.9F, 12.0F, 0.1F); + bootR.addBox(-2.0F, 8.0F, -3.0F, 4, 4, 5, s); + setRotateAngle(bootR, 0.0F, 0.0F, 0F); + helmLeaf5 = new ModelRenderer(this, 50, 32); + helmLeaf5.mirror = true; + helmLeaf5.setRotationPoint(0.0F, 0.2F, 0.0F); + helmLeaf5.addBox(-1.0F, -11.0F, -4.5F, 2, 5, 1, s); + setRotateAngle(helmLeaf5, -0.5235987755982988F, -0.5235987755982988F, 0.5235987755982988F); + bootLbranch = new ModelRenderer(this, 48, 77); + bootLbranch.mirror = true; + bootLbranch.setRotationPoint(0.0F, 0.0F, 0.0F); + bootLbranch.addBox(8.0F, 1.0F, -2.0F, 1, 2, 5, s); + setRotateAngle(bootLbranch, 0.2617993877991494F, 0.0F, 1.0471975511965976F); + helmLeaf4 = new ModelRenderer(this, 50, 32); + helmLeaf4.mirror = true; + helmLeaf4.setRotationPoint(0.0F, 0.2F, 0.0F); + helmLeaf4.addBox(-1.5F, -9.0F, -6.0F, 2, 3, 1, s); + setRotateAngle(helmLeaf4, -0.2617993877991494F, -0.2617993877991494F, 0.5235987755982988F); + helmLeaf2 = new ModelRenderer(this, 50, 32); + helmLeaf2.setRotationPoint(0.0F, 0.2F, 0.0F); + helmLeaf2.addBox(-1.0F, -11.0F, -4.5F, 2, 5, 1, s); + setRotateAngle(helmLeaf2, -0.5235987755982988F, 0.5235987755982988F, -0.5235987755982988F); + helm = new ModelRenderer(this, 0, 32); + helm.setRotationPoint(0.0F, 0.0F, 0.0F); + helm.addBox(-4.0F, -8.0F, -4.5F, 8, 3, 9, s); + setRotateAngle(helm, 0.08726646259971647F, 0.0F, 0.0F); + helm2 = new ModelRenderer(this, 34, 32); + helm2.setRotationPoint(0.0F, 0.0F, 0.0F); + helm2.addBox(-4.0F, -5.0F, -4.5F, 2, 5, 6, s); + helm3 = new ModelRenderer(this, 34, 32); + helm3.mirror = true; + helm3.setRotationPoint(0.0F, 0.0F, 0.0F); + helm3.addBox(2.0F, -5.0F, -4.5F, 2, 5, 6, s); + helmbranch1 = new ModelRenderer(this, 34, 43); + helmbranch1.mirror = true; + helmbranch1.setRotationPoint(0.0F, 0.0F, 0F); + helmbranch1.addBox(-2.0F, -10.0F, -1.0F, 1, 2, 7, s); + setRotateAngle(helmbranch1, 0.5235987755982988F, 0.0F, -0.08726646259971647F); + bootL2 = new ModelRenderer(this, 32, 77); + bootL2.mirror = true; + bootL2.setRotationPoint(0.0F, 0.0F, 0.0F); + bootL2.addBox(-2.0F, 6.0F, -2.0F, 4, 2, 4, s); + helmbranch2 = new ModelRenderer(this, 34, 43); + helmbranch2.setRotationPoint(0.0F, 0.0F, 0.0F); + helmbranch2.addBox(1.0F, -10.0F, -1.0F, 1, 2, 7, s); + setRotateAngle(helmbranch2, 0.5235987755982988F, 0.0F, 0.08726646259971647F); + legR = new ModelRenderer(this, 16, 77); + legR.setRotationPoint(-1.9F, 12.0F, 0.0F); + legR.addBox(-2.0F, 0.0F, -2.0F, 4, 6, 4, s); + setRotateAngle(legR, 0.0F, 0.0F, 0F); + helmLeaf6 = new ModelRenderer(this, 50, 32); + helmLeaf6.mirror = true; + helmLeaf6.setRotationPoint(0.0F, 0.2F, 0.0F); + helmLeaf6.addBox(-0.5F, -13.0F, -3.0F, 2, 7, 1, s); + setRotateAngle(helmLeaf6, -0.7853981633974483F, -0.7853981633974483F, 0.7853981633974483F); + armLbranch1 = new ModelRenderer(this, 51, 44); + armLbranch1.mirror = true; + armLbranch1.setRotationPoint(0.0F, 0.0F, -0.0F); + armLbranch1.addBox(2.5F, -5.0F, -1.0F, 1, 5, 2, s); + setRotateAngle(armLbranch1, 0.0F, 0.0F, 0.7853981633974483F); + bootRbranch = new ModelRenderer(this, 48, 77); + bootRbranch.setRotationPoint(0.0F, 0.0F, 0.0F); + bootRbranch.addBox(-9.0F, 1.0F, -2.0F, 1, 2, 5, s); + setRotateAngle(bootRbranch, 0.2617993877991494F, 0.0F, -1.0471975511965976F); + armRbranch2 = new ModelRenderer(this, 50, 43); + armRbranch2.setRotationPoint(0.0F, 0.0F, 0.0F); + armRbranch2.addBox(-1.5F, -5.0F, -1.5F, 1, 5, 3, s); + setRotateAngle(armRbranch2, 0.0F, 0.0F, -0.5235987755982988F); + helmLeaf3 = new ModelRenderer(this, 50, 32); + helmLeaf3.setRotationPoint(0.0F, 0.2F, 0.0F); + helmLeaf3.addBox(-1.5F, -13.0F, -3.0F, 2, 7, 1, s); + setRotateAngle(helmLeaf3, -0.7853981633974483F, 0.7853981633974483F, -0.7853981633974483F); + armRpauldron = new ModelRenderer(this, 0, 66); + armRpauldron.setRotationPoint(0.0F, 0.0F, 0.0F); + armRpauldron.addBox(-4.0F, -2.0F, -3.0F, 5, 5, 6, s); + armLbranch2 = new ModelRenderer(this, 50, 43); + armLbranch2.mirror = true; + armLbranch2.setRotationPoint(0.0F, 0.0F, -0.0F); + armLbranch2.addBox(0.5F, -5.0F, -1.5F, 1, 5, 3, s); + setRotateAngle(armLbranch2, 0.0F, 0.0F, 0.5235987755982988F); + armL = new ModelRenderer(this, 0, 77); + armL.mirror = true; + armL.setRotationPoint(5.0F, 2.0F, -0.0F); + armL.addBox(-1.0F, 3.0F, -2.0F, 4, 7, 4, s); + setRotateAngle(armL, 0.0F, 0.0F, 0F); + body2 = new ModelRenderer(this, 0, 57); + body2.setRotationPoint(0.0F, 0.0F, 0.0F); + body2.addBox(-4.0F, 6.0F, -2.5F, 8, 4, 5, s); + setRotateAngle(body2, -0.08726646259971647F, 0.0F, 0.0F); + helmbranch3 = new ModelRenderer(this, 34, 43); + helmbranch3.setRotationPoint(0.0F, 0.0F, 0.0F); + helmbranch3.addBox(1.0F, -8.0F, -4.0F, 1, 2, 7, s); + setRotateAngle(helmbranch3, 0.2617993877991494F, 0.0F, -1.0471975511965976F); + armRbranch1 = new ModelRenderer(this, 51, 44); + armRbranch1.setRotationPoint(0.0F, 0.0F, 0.0F); + armRbranch1.addBox(-3.5F, -5.0F, -1.0F, 1, 5, 2, s); + setRotateAngle(armRbranch1, 0.0F, 0.0F, -0.7853981633974483F); + belt = new ModelRenderer(this, 22, 66); + belt.setRotationPoint(0.0F, 0.0F, 0.0F); + belt.addBox(-4.5F, 9.5F, -3.0F, 9, 3, 6, s); + helmLeaf1 = new ModelRenderer(this, 50, 32); + helmLeaf1.setRotationPoint(0.0F, 0.2F, 0.0F); + helmLeaf1.addBox(-0.5F, -9.0F, -6.0F, 2, 3, 1, s); + setRotateAngle(helmLeaf1, -0.2617993877991494F, 0.2617993877991494F, -0.5235987755982988F); + armLpauldron = new ModelRenderer(this, 0, 66); + armLpauldron.mirror = true; + armLpauldron.setRotationPoint(0.0F, 0.0F, -0.0F); + armLpauldron.addBox(-1.0F, -2.0F, -3.0F, 5, 5, 6, s); + legL = new ModelRenderer(this, 16, 77); + legL.mirror = true; + legL.setRotationPoint(1.9F, 12.0F, 0.0F); + legL.addBox(-2.0F, 0.0F, -2.0F, 4, 6, 4, s); + setRotateAngle(legL, 0.0F, 0.0F, 0F); - helm.addChild(helm4); - bootR.addChild(bootR1); - helm.addChild(helmbranch4); - helm.addChild(helmLeaf5); - bootL.addChild(bootLbranch); - helm.addChild(helmLeaf4); - helm.addChild(helmLeaf2); - helm.addChild(helm2); - helm.addChild(helm3); - helm.addChild(helmbranch1); - bootL.addChild(bootL2); - helm.addChild(helmbranch2); - belt.addChild(legR); - helm.addChild(helmLeaf6); - armLpauldron.addChild(armLbranch1); - bootR.addChild(bootRbranch); - armRpauldron.addChild(armRbranch2); - helm.addChild(helmLeaf3); - armr.addChild(armRpauldron); - armLpauldron.addChild(armLbranch2); - body.addChild(body2); - helm.addChild(helmbranch3); - armRpauldron.addChild(armRbranch1); - helm.addChild(helmLeaf1); - armL.addChild(armLpauldron); - belt.addChild(legL); - } + helm.addChild(helm4); + bootR.addChild(bootR1); + helm.addChild(helmbranch4); + helm.addChild(helmLeaf5); + bootL.addChild(bootLbranch); + helm.addChild(helmLeaf4); + helm.addChild(helmLeaf2); + helm.addChild(helm2); + helm.addChild(helm3); + helm.addChild(helmbranch1); + bootL.addChild(bootL2); + helm.addChild(helmbranch2); + belt.addChild(legR); + helm.addChild(helmLeaf6); + armLpauldron.addChild(armLbranch1); + bootR.addChild(bootRbranch); + armRpauldron.addChild(armRbranch2); + helm.addChild(helmLeaf3); + armr.addChild(armRpauldron); + armLpauldron.addChild(armLbranch2); + body.addChild(body2); + helm.addChild(helmbranch3); + armRpauldron.addChild(armRbranch1); + helm.addChild(helmLeaf1); + armL.addChild(armLpauldron); + belt.addChild(legL); + } - @Override - public void render(Entity entity, float f, float f1, float f2, float f3, float f4, float f5) { - helm.showModel = slot == 0; - body.showModel = slot == 1; - armr.showModel = slot == 1; - armL.showModel = slot == 1; - legR.showModel = slot == 2; - legL.showModel = slot == 2; - bootL.showModel = slot == 3; - bootR.showModel = slot == 3; - bipedHeadwear.showModel = false; + @Override + public void render(Entity entity, float f, float f1, float f2, float f3, float f4, float f5) { + helm.showModel = slot == 0; + body.showModel = slot == 1; + armr.showModel = slot == 1; + armL.showModel = slot == 1; + legR.showModel = slot == 2; + legL.showModel = slot == 2; + bootL.showModel = slot == 3; + bootR.showModel = slot == 3; + bipedHeadwear.showModel = false; - bipedHead = helm; - bipedBody = body; - bipedRightArm = armr; - bipedLeftArm = armL; - if (slot == 2) { - bipedRightLeg = legR; - bipedLeftLeg = legL; - } else { - bipedRightLeg = bootR; - bipedLeftLeg = bootL; - } + bipedHead = helm; + bipedBody = body; + bipedRightArm = armr; + bipedLeftArm = armL; + if(slot == 2) { + bipedRightLeg = legR; + bipedLeftLeg = legL; + } else { + bipedRightLeg = bootR; + bipedLeftLeg = bootL; + } - prepareForRender(entity); - super.render(entity, f, f1, f2, f3, f4, f5); - } + prepareForRender(entity); + super.render(entity, f, f1, f2, f3, f4, f5); + } - public void prepareForRender(Entity entity) { - EntityLivingBase living = (EntityLivingBase) entity; - isSneak = living != null ? living.isSneaking() : false; - if (living != null && living instanceof EntityPlayer) { - EntityPlayer player = (EntityPlayer) living; + public void prepareForRender(Entity entity) { + EntityLivingBase living = (EntityLivingBase) entity; + isSneak = living != null ? living.isSneaking() : false; + if(living != null && living instanceof EntityPlayer) { + EntityPlayer player = (EntityPlayer) living; - ItemStack itemstack = player.inventory.getCurrentItem(); - heldItemRight = itemstack != null ? 1 : 0; + ItemStack itemstack = player.inventory.getCurrentItem(); + heldItemRight = itemstack != null ? 1 : 0; - aimedBow = false; - if (itemstack != null && player.getItemInUseCount() > 0) { - EnumAction enumaction = itemstack.getItemUseAction(); + aimedBow = false; + if (itemstack != null && player.getItemInUseCount() > 0) { + EnumAction enumaction = itemstack.getItemUseAction(); - if (enumaction == EnumAction.block) heldItemRight = 3; - else if (enumaction == EnumAction.bow) aimedBow = true; - } - } - } + if (enumaction == EnumAction.block) + heldItemRight = 3; + else if (enumaction == EnumAction.bow) + aimedBow = true; + } + } + } + + public void setRotateAngle(ModelRenderer modelRenderer, float x, float y, float z) { + modelRenderer.rotateAngleX = x; + modelRenderer.rotateAngleY = y; + modelRenderer.rotateAngleZ = z; + } - public void setRotateAngle(ModelRenderer modelRenderer, float x, float y, float z) { - modelRenderer.rotateAngleX = x; - modelRenderer.rotateAngleY = y; - modelRenderer.rotateAngleZ = z; - } } diff --git a/src/main/java/vazkii/botania/client/render/block/InterpolatedIcon.java b/src/main/java/vazkii/botania/client/render/block/InterpolatedIcon.java index 2f4afee5d4..dbe47f01b4 100644 --- a/src/main/java/vazkii/botania/client/render/block/InterpolatedIcon.java +++ b/src/main/java/vazkii/botania/client/render/block/InterpolatedIcon.java @@ -2,76 +2,78 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Aug 15, 2015, 5:11:16 PM (GMT)] */ package vazkii.botania.client.render.block; -import cpw.mods.fml.relauncher.ReflectionHelper; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; import java.lang.reflect.Field; + import net.minecraft.client.renderer.texture.TextureAtlasSprite; import net.minecraft.client.renderer.texture.TextureUtil; import net.minecraft.client.resources.data.AnimationMetadataSection; import vazkii.botania.common.lib.LibObfuscation; +import cpw.mods.fml.relauncher.ReflectionHelper; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; // This is all vanilla code from 1.8, thanks to ganymedes01 porting it to 1.7 :D @SideOnly(Side.CLIENT) public class InterpolatedIcon extends TextureAtlasSprite { - protected int[][] interpolatedFrameData; - private Field fanimationMetadata; + protected int[][] interpolatedFrameData; + private Field fanimationMetadata; - public InterpolatedIcon(String name) { - super(name); - fanimationMetadata = ReflectionHelper.findField(TextureAtlasSprite.class, LibObfuscation.ANIMATION_METADATA); - fanimationMetadata.setAccessible(true); - } + public InterpolatedIcon(String name) { + super(name); + fanimationMetadata = ReflectionHelper.findField(TextureAtlasSprite.class, LibObfuscation.ANIMATION_METADATA); + fanimationMetadata.setAccessible(true); + } - @Override - public void updateAnimation() { - super.updateAnimation(); - try { - updateAnimationInterpolated(); - } catch (Exception e) { - // NO-OP - } - } + @Override + public void updateAnimation() { + super.updateAnimation(); + try { + updateAnimationInterpolated(); + } catch(Exception e) { + // NO-OP + } + } - private void updateAnimationInterpolated() throws IllegalArgumentException, IllegalAccessException { - AnimationMetadataSection animationMetadata = (AnimationMetadataSection) fanimationMetadata.get(this); + private void updateAnimationInterpolated() throws IllegalArgumentException, IllegalAccessException { + AnimationMetadataSection animationMetadata = (AnimationMetadataSection) fanimationMetadata.get(this); - double d0 = 1.0D - tickCounter / (double) animationMetadata.getFrameTimeSingle(frameCounter); - int i = animationMetadata.getFrameIndex(frameCounter); - int j = animationMetadata.getFrameCount() == 0 ? framesTextureData.size() : animationMetadata.getFrameCount(); - int k = animationMetadata.getFrameIndex((frameCounter + 1) % j); + double d0 = 1.0D - tickCounter / (double) animationMetadata.getFrameTimeSingle(frameCounter); + int i = animationMetadata.getFrameIndex(frameCounter); + int j = animationMetadata.getFrameCount() == 0 ? framesTextureData.size() : animationMetadata.getFrameCount(); + int k = animationMetadata.getFrameIndex((frameCounter + 1) % j); - if (i != k && k >= 0 && k < framesTextureData.size()) { - int[][] aint = (int[][]) framesTextureData.get(i); - int[][] aint1 = (int[][]) framesTextureData.get(k); + if(i != k && k >= 0 && k < framesTextureData.size()) { + int[][] aint = (int[][]) framesTextureData.get(i); + int[][] aint1 = (int[][]) framesTextureData.get(k); - if (interpolatedFrameData == null || interpolatedFrameData.length != aint.length) - interpolatedFrameData = new int[aint.length][]; + if(interpolatedFrameData == null || interpolatedFrameData.length != aint.length) + interpolatedFrameData = new int[aint.length][]; - for (int l = 0; l < aint.length; l++) { - if (interpolatedFrameData[l] == null) interpolatedFrameData[l] = new int[aint[l].length]; + for(int l = 0; l < aint.length; l++) { + if (interpolatedFrameData[l] == null) + interpolatedFrameData[l] = new int[aint[l].length]; - if (l < aint1.length && aint1[l].length == aint[l].length) - for (int i1 = 0; i1 < aint[l].length; ++i1) { - int j1 = aint[l][i1]; - int k1 = aint1[l][i1]; - int l1 = (int) (((j1 & 16711680) >> 16) * d0 + ((k1 & 16711680) >> 16) * (1.0D - d0)); - int i2 = (int) (((j1 & 65280) >> 8) * d0 + ((k1 & 65280) >> 8) * (1.0D - d0)); - int j2 = (int) ((j1 & 255) * d0 + (k1 & 255) * (1.0D - d0)); - interpolatedFrameData[l][i1] = j1 & -16777216 | l1 << 16 | i2 << 8 | j2; - } - } + if(l < aint1.length && aint1[l].length == aint[l].length) + for (int i1 = 0; i1 < aint[l].length; ++i1) { + int j1 = aint[l][i1]; + int k1 = aint1[l][i1]; + int l1 = (int) (((j1 & 16711680) >> 16) * d0 + ((k1 & 16711680) >> 16) * (1.0D - d0)); + int i2 = (int) (((j1 & 65280) >> 8) * d0 + ((k1 & 65280) >> 8) * (1.0D - d0)); + int j2 = (int) ((j1 & 255) * d0 + (k1 & 255) * (1.0D - d0)); + interpolatedFrameData[l][i1] = j1 & -16777216 | l1 << 16 | i2 << 8 | j2; + } + } - TextureUtil.uploadTextureMipmap(interpolatedFrameData, width, height, originX, originY, false, false); - } - } -} + TextureUtil.uploadTextureMipmap(interpolatedFrameData, width, height, originX, originY, false, false); + } + } +} \ No newline at end of file diff --git a/src/main/java/vazkii/botania/client/render/block/RenderAltar.java b/src/main/java/vazkii/botania/client/render/block/RenderAltar.java index 0812f0ba43..2d1e6384e0 100644 --- a/src/main/java/vazkii/botania/client/render/block/RenderAltar.java +++ b/src/main/java/vazkii/botania/client/render/block/RenderAltar.java @@ -2,49 +2,50 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jan 21, 2014, 8:02:01 PM (GMT)] */ package vazkii.botania.client.render.block; -import cpw.mods.fml.client.registry.ISimpleBlockRenderingHandler; import net.minecraft.block.Block; import net.minecraft.client.renderer.RenderBlocks; import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher; import net.minecraft.world.IBlockAccess; + import org.lwjgl.opengl.GL11; + import vazkii.botania.client.lib.LibRenderIDs; import vazkii.botania.client.render.tile.RenderTileAltar; import vazkii.botania.common.block.tile.TileAltar; +import cpw.mods.fml.client.registry.ISimpleBlockRenderingHandler; public class RenderAltar implements ISimpleBlockRenderingHandler { - @Override - public void renderInventoryBlock(Block block, int metadata, int modelID, RenderBlocks renderer) { - GL11.glPushMatrix(); - GL11.glTranslatef(-0.5F, -0.6F, -0.5F); - GL11.glScalef(0.9F, 0.9F, 0.9F); - RenderTileAltar.forceMeta = metadata; - TileEntityRendererDispatcher.instance.renderTileEntityAt(new TileAltar(), 0.0D, 0.0D, 0.0D, 0.0F); - GL11.glPopMatrix(); - } - - @Override - public boolean renderWorldBlock( - IBlockAccess world, int x, int y, int z, Block block, int modelId, RenderBlocks renderer) { - return false; - } - - @Override - public int getRenderId() { - return LibRenderIDs.idAltar; - } - - @Override - public boolean shouldRender3DInInventory(int modelId) { - return true; - } + @Override + public void renderInventoryBlock(Block block, int metadata, int modelID, RenderBlocks renderer) { + GL11.glPushMatrix(); + GL11.glTranslatef(-0.5F, -0.6F, -0.5F); + GL11.glScalef(0.9F, 0.9F, 0.9F); + RenderTileAltar.forceMeta = metadata; + TileEntityRendererDispatcher.instance.renderTileEntityAt(new TileAltar(), 0.0D, 0.0D, 0.0D, 0.0F); + GL11.glPopMatrix(); + } + + @Override + public boolean renderWorldBlock(IBlockAccess world, int x, int y, int z, Block block, int modelId, RenderBlocks renderer) { + return false; + } + + @Override + public int getRenderId() { + return LibRenderIDs.idAltar; + } + + @Override + public boolean shouldRender3DInInventory(int modelId) { + return true; + } } diff --git a/src/main/java/vazkii/botania/client/render/block/RenderAvatar.java b/src/main/java/vazkii/botania/client/render/block/RenderAvatar.java index 22ed39f9d0..f850e12370 100644 --- a/src/main/java/vazkii/botania/client/render/block/RenderAvatar.java +++ b/src/main/java/vazkii/botania/client/render/block/RenderAvatar.java @@ -2,46 +2,48 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Oct 24, 2015, 11:06:11 PM (GMT)] */ package vazkii.botania.client.render.block; -import cpw.mods.fml.client.registry.ISimpleBlockRenderingHandler; import net.minecraft.block.Block; import net.minecraft.client.renderer.RenderBlocks; import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher; import net.minecraft.world.IBlockAccess; + import org.lwjgl.opengl.GL11; + import vazkii.botania.client.lib.LibRenderIDs; import vazkii.botania.common.block.tile.TileAvatar; +import cpw.mods.fml.client.registry.ISimpleBlockRenderingHandler; public class RenderAvatar implements ISimpleBlockRenderingHandler { - @Override - public void renderInventoryBlock(Block block, int metadata, int modelID, RenderBlocks renderer) { - GL11.glPushMatrix(); - GL11.glTranslatef(-0.5F, -0.6F, -0.5F); - TileEntityRendererDispatcher.instance.renderTileEntityAt(new TileAvatar(), 0.0D, 0.0D, 0.0D, 0.0F); - GL11.glPopMatrix(); - } - - @Override - public boolean renderWorldBlock( - IBlockAccess world, int x, int y, int z, Block block, int modelId, RenderBlocks renderer) { - return false; - } - - @Override - public int getRenderId() { - return LibRenderIDs.idAvatar; - } - - @Override - public boolean shouldRender3DInInventory(int modelId) { - return true; - } + @Override + public void renderInventoryBlock(Block block, int metadata, int modelID, RenderBlocks renderer) { + GL11.glPushMatrix(); + GL11.glTranslatef(-0.5F, -0.6F, -0.5F); + TileEntityRendererDispatcher.instance.renderTileEntityAt(new TileAvatar(), 0.0D, 0.0D, 0.0D, 0.0F); + GL11.glPopMatrix(); + } + + @Override + public boolean renderWorldBlock(IBlockAccess world, int x, int y, int z, Block block, int modelId, RenderBlocks renderer) { + return false; + } + + @Override + public int getRenderId() { + return LibRenderIDs.idAvatar; + } + + @Override + public boolean shouldRender3DInInventory(int modelId) { + return true; + } + } diff --git a/src/main/java/vazkii/botania/client/render/block/RenderBellows.java b/src/main/java/vazkii/botania/client/render/block/RenderBellows.java index acac3fbda2..a1e287418c 100644 --- a/src/main/java/vazkii/botania/client/render/block/RenderBellows.java +++ b/src/main/java/vazkii/botania/client/render/block/RenderBellows.java @@ -2,47 +2,49 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Aug 28, 2015, 7:13:45 PM (GMT)] */ package vazkii.botania.client.render.block; -import cpw.mods.fml.client.registry.ISimpleBlockRenderingHandler; import net.minecraft.block.Block; import net.minecraft.client.renderer.RenderBlocks; import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher; import net.minecraft.world.IBlockAccess; + import org.lwjgl.opengl.GL11; + import vazkii.botania.client.lib.LibRenderIDs; import vazkii.botania.common.block.tile.mana.TileBellows; +import cpw.mods.fml.client.registry.ISimpleBlockRenderingHandler; public class RenderBellows implements ISimpleBlockRenderingHandler { - @Override - public void renderInventoryBlock(Block block, int metadata, int modelId, RenderBlocks renderer) { - GL11.glPushMatrix(); - GL11.glTranslatef(-0.5F, -0.3F, -0.5F); - GL11.glScalef(1.2F, 1.2F, 1.2F); - TileEntityRendererDispatcher.instance.renderTileEntityAt(new TileBellows(), 0.0D, 0.0D, 0.0D, 0.0F); - GL11.glPopMatrix(); - } - - @Override - public boolean renderWorldBlock( - IBlockAccess world, int x, int y, int z, Block block, int modelId, RenderBlocks renderer) { - return false; - } - - @Override - public boolean shouldRender3DInInventory(int modelId) { - return true; - } - - @Override - public int getRenderId() { - return LibRenderIDs.idBellows; - } + @Override + public void renderInventoryBlock(Block block, int metadata, int modelId, RenderBlocks renderer) { + GL11.glPushMatrix(); + GL11.glTranslatef(-0.5F, -0.3F, -0.5F); + GL11.glScalef(1.2F, 1.2F, 1.2F); + TileEntityRendererDispatcher.instance.renderTileEntityAt(new TileBellows(), 0.0D, 0.0D, 0.0D, 0.0F); + GL11.glPopMatrix(); + } + + @Override + public boolean renderWorldBlock(IBlockAccess world, int x, int y, int z, Block block, int modelId, RenderBlocks renderer) { + return false; + } + + @Override + public boolean shouldRender3DInInventory(int modelId) { + return true; + } + + @Override + public int getRenderId() { + return LibRenderIDs.idBellows; + } + } diff --git a/src/main/java/vazkii/botania/client/render/block/RenderBrewery.java b/src/main/java/vazkii/botania/client/render/block/RenderBrewery.java index 5bda3cf6b6..aa2eefed38 100644 --- a/src/main/java/vazkii/botania/client/render/block/RenderBrewery.java +++ b/src/main/java/vazkii/botania/client/render/block/RenderBrewery.java @@ -2,50 +2,52 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Oct 31, 2014, 5:00:12 PM (GMT)] */ package vazkii.botania.client.render.block; -import cpw.mods.fml.client.registry.ISimpleBlockRenderingHandler; import net.minecraft.block.Block; import net.minecraft.client.renderer.RenderBlocks; import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher; import net.minecraft.world.IBlockAccess; + import org.lwjgl.opengl.GL11; + import vazkii.botania.client.lib.LibRenderIDs; import vazkii.botania.client.render.tile.RenderTileBrewery; import vazkii.botania.common.block.tile.TileBrewery; +import cpw.mods.fml.client.registry.ISimpleBlockRenderingHandler; public class RenderBrewery implements ISimpleBlockRenderingHandler { - @Override - public void renderInventoryBlock(Block block, int metadata, int modelId, RenderBlocks renderer) { - GL11.glPushMatrix(); - GL11.glTranslatef(-0.5F, -0.5F, -0.5F); - GL11.glScalef(1.2F, 1.2F, 1.2F); - RenderTileBrewery.rotate = false; - TileEntityRendererDispatcher.instance.renderTileEntityAt(new TileBrewery(), 0.0D, 0.0D, 0.0D, 0.0F); - RenderTileBrewery.rotate = true; - GL11.glPopMatrix(); - } - - @Override - public boolean renderWorldBlock( - IBlockAccess world, int x, int y, int z, Block block, int modelId, RenderBlocks renderer) { - return false; - } - - @Override - public boolean shouldRender3DInInventory(int modelId) { - return true; - } - - @Override - public int getRenderId() { - return LibRenderIDs.idBrewery; - } + @Override + public void renderInventoryBlock(Block block, int metadata, int modelId, RenderBlocks renderer) { + GL11.glPushMatrix(); + GL11.glTranslatef(-0.5F, -0.5F, -0.5F); + GL11.glScalef(1.2F, 1.2F, 1.2F); + RenderTileBrewery.rotate = false; + TileEntityRendererDispatcher.instance.renderTileEntityAt(new TileBrewery(), 0.0D, 0.0D, 0.0D, 0.0F); + RenderTileBrewery.rotate = true; + GL11.glPopMatrix(); + } + + @Override + public boolean renderWorldBlock(IBlockAccess world, int x, int y, int z, Block block, int modelId, RenderBlocks renderer) { + return false; + } + + @Override + public boolean shouldRender3DInInventory(int modelId) { + return true; + } + + @Override + public int getRenderId() { + return LibRenderIDs.idBrewery; + } + } diff --git a/src/main/java/vazkii/botania/client/render/block/RenderCocoon.java b/src/main/java/vazkii/botania/client/render/block/RenderCocoon.java index ae3b9964bf..d74f04d174 100644 --- a/src/main/java/vazkii/botania/client/render/block/RenderCocoon.java +++ b/src/main/java/vazkii/botania/client/render/block/RenderCocoon.java @@ -2,46 +2,48 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jul 8, 2015, 5:57:29 PM (GMT)] */ package vazkii.botania.client.render.block; -import cpw.mods.fml.client.registry.ISimpleBlockRenderingHandler; import net.minecraft.block.Block; import net.minecraft.client.renderer.RenderBlocks; import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher; import net.minecraft.world.IBlockAccess; + import org.lwjgl.opengl.GL11; + import vazkii.botania.client.lib.LibRenderIDs; import vazkii.botania.common.block.tile.TileCocoon; +import cpw.mods.fml.client.registry.ISimpleBlockRenderingHandler; public class RenderCocoon implements ISimpleBlockRenderingHandler { - @Override - public void renderInventoryBlock(Block block, int metadata, int modelID, RenderBlocks renderer) { - GL11.glPushMatrix(); - GL11.glTranslatef(-0.5F, -0.5F, -0.5F); - TileEntityRendererDispatcher.instance.renderTileEntityAt(new TileCocoon(), 0.0D, 0.0D, 0.0D, 0.0F); - GL11.glPopMatrix(); - } - - @Override - public boolean renderWorldBlock( - IBlockAccess world, int x, int y, int z, Block block, int modelId, RenderBlocks renderer) { - return false; - } - - @Override - public int getRenderId() { - return LibRenderIDs.idCocoon; - } - - @Override - public boolean shouldRender3DInInventory(int modelId) { - return true; - } + @Override + public void renderInventoryBlock(Block block, int metadata, int modelID, RenderBlocks renderer) { + GL11.glPushMatrix(); + GL11.glTranslatef(-0.5F, -0.5F, -0.5F); + TileEntityRendererDispatcher.instance.renderTileEntityAt(new TileCocoon(), 0.0D, 0.0D, 0.0D, 0.0F); + GL11.glPopMatrix(); + } + + @Override + public boolean renderWorldBlock(IBlockAccess world, int x, int y, int z, Block block, int modelId, RenderBlocks renderer) { + return false; + } + + @Override + public int getRenderId() { + return LibRenderIDs.idCocoon; + } + + @Override + public boolean shouldRender3DInInventory(int modelId) { + return true; + } + } diff --git a/src/main/java/vazkii/botania/client/render/block/RenderCorporeaCrystalCube.java b/src/main/java/vazkii/botania/client/render/block/RenderCorporeaCrystalCube.java index 27f69473c5..1225ae73dc 100644 --- a/src/main/java/vazkii/botania/client/render/block/RenderCorporeaCrystalCube.java +++ b/src/main/java/vazkii/botania/client/render/block/RenderCorporeaCrystalCube.java @@ -2,48 +2,50 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Apr 30, 2015, 6:22:32 PM (GMT)] */ package vazkii.botania.client.render.block; -import cpw.mods.fml.client.registry.ISimpleBlockRenderingHandler; import net.minecraft.block.Block; import net.minecraft.client.renderer.RenderBlocks; import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher; import net.minecraft.world.IBlockAccess; + import org.lwjgl.opengl.GL11; + import vazkii.botania.client.lib.LibRenderIDs; import vazkii.botania.common.block.tile.corporea.TileCorporeaCrystalCube; +import cpw.mods.fml.client.registry.ISimpleBlockRenderingHandler; public class RenderCorporeaCrystalCube implements ISimpleBlockRenderingHandler { - @Override - public void renderInventoryBlock(Block block, int metadata, int modelId, RenderBlocks renderer) { - GL11.glPushMatrix(); - GL11.glTranslatef(-0.5F, -0.5F, -0.5F); - GL11.glDisable(GL11.GL_ALPHA_TEST); - TileEntityRendererDispatcher.instance.renderTileEntityAt(new TileCorporeaCrystalCube(), 0.0D, 0.0D, 0.0D, 0.0F); - GL11.glEnable(GL11.GL_ALPHA_TEST); - GL11.glPopMatrix(); - } - - @Override - public boolean renderWorldBlock( - IBlockAccess world, int x, int y, int z, Block block, int modelId, RenderBlocks renderer) { - return false; - } - - @Override - public boolean shouldRender3DInInventory(int modelId) { - return true; - } - - @Override - public int getRenderId() { - return LibRenderIDs.idCorporeaCrystalCybe; - } + @Override + public void renderInventoryBlock(Block block, int metadata, int modelId, RenderBlocks renderer) { + GL11.glPushMatrix(); + GL11.glTranslatef(-0.5F, -0.5F, -0.5F); + GL11.glDisable(GL11.GL_ALPHA_TEST); + TileEntityRendererDispatcher.instance.renderTileEntityAt(new TileCorporeaCrystalCube(), 0.0D, 0.0D, 0.0D, 0.0F); + GL11.glEnable(GL11.GL_ALPHA_TEST); + GL11.glPopMatrix(); + } + + @Override + public boolean renderWorldBlock(IBlockAccess world, int x, int y, int z, Block block, int modelId, RenderBlocks renderer) { + return false; + } + + @Override + public boolean shouldRender3DInInventory(int modelId) { + return true; + } + + @Override + public int getRenderId() { + return LibRenderIDs.idCorporeaCrystalCybe; + } + } diff --git a/src/main/java/vazkii/botania/client/render/block/RenderCorporeaIndex.java b/src/main/java/vazkii/botania/client/render/block/RenderCorporeaIndex.java index c436ab96a7..4eb43de551 100644 --- a/src/main/java/vazkii/botania/client/render/block/RenderCorporeaIndex.java +++ b/src/main/java/vazkii/botania/client/render/block/RenderCorporeaIndex.java @@ -2,50 +2,52 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Feb 15, 2015, 1:57:50 AM (GMT)] */ package vazkii.botania.client.render.block; -import cpw.mods.fml.client.registry.ISimpleBlockRenderingHandler; import net.minecraft.block.Block; import net.minecraft.client.renderer.RenderBlocks; import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher; import net.minecraft.world.IBlockAccess; + import org.lwjgl.opengl.GL11; + import vazkii.botania.client.lib.LibRenderIDs; import vazkii.botania.client.render.tile.RenderTileCorporeaIndex; import vazkii.botania.common.block.tile.corporea.TileCorporeaIndex; +import cpw.mods.fml.client.registry.ISimpleBlockRenderingHandler; public class RenderCorporeaIndex implements ISimpleBlockRenderingHandler { - @Override - public void renderInventoryBlock(Block block, int metadata, int modelId, RenderBlocks renderer) { - GL11.glPushMatrix(); - GL11.glTranslatef(-0.5F, -0.3F, -0.5F); - GL11.glScalef(1.4F, 1.4F, 1.4F); - RenderTileCorporeaIndex.move = false; - TileEntityRendererDispatcher.instance.renderTileEntityAt(new TileCorporeaIndex(), 0.0D, 0.0D, 0.0D, 0.0F); - RenderTileCorporeaIndex.move = true; - GL11.glPopMatrix(); - } - - @Override - public boolean renderWorldBlock( - IBlockAccess world, int x, int y, int z, Block block, int modelId, RenderBlocks renderer) { - return false; - } - - @Override - public boolean shouldRender3DInInventory(int modelId) { - return true; - } - - @Override - public int getRenderId() { - return LibRenderIDs.idCorporeaIndex; - } + @Override + public void renderInventoryBlock(Block block, int metadata, int modelId, RenderBlocks renderer) { + GL11.glPushMatrix(); + GL11.glTranslatef(-0.5F, -0.3F, -0.5F); + GL11.glScalef(1.4F, 1.4F, 1.4F); + RenderTileCorporeaIndex.move = false; + TileEntityRendererDispatcher.instance.renderTileEntityAt(new TileCorporeaIndex(), 0.0D, 0.0D, 0.0D, 0.0F); + RenderTileCorporeaIndex.move = true; + GL11.glPopMatrix(); + } + + @Override + public boolean renderWorldBlock(IBlockAccess world, int x, int y, int z, Block block, int modelId, RenderBlocks renderer) { + return false; + } + + @Override + public boolean shouldRender3DInInventory(int modelId) { + return true; + } + + @Override + public int getRenderId() { + return LibRenderIDs.idCorporeaIndex; + } + } diff --git a/src/main/java/vazkii/botania/client/render/block/RenderDoubleFlower.java b/src/main/java/vazkii/botania/client/render/block/RenderDoubleFlower.java index 7901744d10..d9a9ab80b8 100644 --- a/src/main/java/vazkii/botania/client/render/block/RenderDoubleFlower.java +++ b/src/main/java/vazkii/botania/client/render/block/RenderDoubleFlower.java @@ -2,15 +2,14 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Mar 22, 2015, 9:00:06 PM (GMT)] */ package vazkii.botania.client.render.block; -import cpw.mods.fml.client.registry.ISimpleBlockRenderingHandler; import net.minecraft.block.Block; import net.minecraft.block.BlockDoublePlant; import net.minecraft.client.renderer.RenderBlocks; @@ -18,65 +17,53 @@ import net.minecraft.util.IIcon; import net.minecraft.world.IBlockAccess; import vazkii.botania.client.lib.LibRenderIDs; +import cpw.mods.fml.client.registry.ISimpleBlockRenderingHandler; public class RenderDoubleFlower implements ISimpleBlockRenderingHandler { - @Override - public void renderInventoryBlock(Block block, int metadata, int modelId, RenderBlocks renderer) { - // NO-OP - } + @Override + public void renderInventoryBlock(Block block, int metadata, int modelId, RenderBlocks renderer) { + // NO-OP + } + + @Override + public boolean renderWorldBlock(IBlockAccess world, int p_147774_2_, int p_147774_3_, int p_147774_4_, Block block, int modelId, RenderBlocks renderer) { + BlockDoublePlant p_147774_1_ = (BlockDoublePlant) block; + Tessellator tessellator = Tessellator.instance; + tessellator.setBrightness(p_147774_1_.getMixedBrightnessForBlock(world, p_147774_2_, p_147774_3_, p_147774_4_)); + tessellator.setColorOpaque_F(1F, 1F, 1F); + long j1 = p_147774_2_ * 3129871 ^ p_147774_4_ * 116129781L; + j1 = j1 * j1 * 42317861L + j1 * 11L; + int i1 = world.getBlockMetadata(p_147774_2_, p_147774_3_, p_147774_4_); + boolean flag1 = BlockDoublePlant.func_149887_c(i1); + if (flag1) + { + if (world.getBlock(p_147774_2_, p_147774_3_ - 1, p_147774_4_) != p_147774_1_) + { + return false; + } - @Override - public boolean renderWorldBlock( - IBlockAccess world, - int p_147774_2_, - int p_147774_3_, - int p_147774_4_, - Block block, - int modelId, - RenderBlocks renderer) { - BlockDoublePlant p_147774_1_ = (BlockDoublePlant) block; - Tessellator tessellator = Tessellator.instance; - tessellator.setBrightness(p_147774_1_.getMixedBrightnessForBlock(world, p_147774_2_, p_147774_3_, p_147774_4_)); - tessellator.setColorOpaque_F(1F, 1F, 1F); - long j1 = p_147774_2_ * 3129871 ^ p_147774_4_ * 116129781L; - j1 = j1 * j1 * 42317861L + j1 * 11L; - int i1 = world.getBlockMetadata(p_147774_2_, p_147774_3_, p_147774_4_); - boolean flag1 = BlockDoublePlant.func_149887_c(i1); - if (flag1) { - if (world.getBlock(p_147774_2_, p_147774_3_ - 1, p_147774_4_) != p_147774_1_) { - return false; - } + BlockDoublePlant.func_149890_d(world.getBlockMetadata(p_147774_2_, p_147774_3_ - 1, p_147774_4_)); + } + else + { + BlockDoublePlant.func_149890_d(i1); + } - BlockDoublePlant.func_149890_d(world.getBlockMetadata(p_147774_2_, p_147774_3_ - 1, p_147774_4_)); - } else { - BlockDoublePlant.func_149890_d(i1); - } + // Only change here, to use xyz rather than side/meta + IIcon icon = renderer.getBlockIcon(block, world, p_147774_2_, p_147774_3_, p_147774_4_, 0); + RenderSpecialFlower.drawCrossedSquares(world, block, icon, p_147774_2_, p_147774_3_, p_147774_4_, p_147774_2_, p_147774_3_, p_147774_4_, 1F, renderer); + return true; + } - // Only change here, to use xyz rather than side/meta - IIcon icon = renderer.getBlockIcon(block, world, p_147774_2_, p_147774_3_, p_147774_4_, 0); - RenderSpecialFlower.drawCrossedSquares( - world, - block, - icon, - p_147774_2_, - p_147774_3_, - p_147774_4_, - p_147774_2_, - p_147774_3_, - p_147774_4_, - 1F, - renderer); - return true; - } + @Override + public boolean shouldRender3DInInventory(int modelId) { + return false; + } - @Override - public boolean shouldRender3DInInventory(int modelId) { - return false; - } + @Override + public int getRenderId() { + return LibRenderIDs.idDoubleFlower; + } - @Override - public int getRenderId() { - return LibRenderIDs.idDoubleFlower; - } } diff --git a/src/main/java/vazkii/botania/client/render/block/RenderFloatingFlower.java b/src/main/java/vazkii/botania/client/render/block/RenderFloatingFlower.java index 3cc0c3409e..4c569ce74a 100644 --- a/src/main/java/vazkii/botania/client/render/block/RenderFloatingFlower.java +++ b/src/main/java/vazkii/botania/client/render/block/RenderFloatingFlower.java @@ -2,40 +2,40 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jul 8, 2014, 11:05:38 PM (GMT)] */ package vazkii.botania.client.render.block; -import cpw.mods.fml.client.registry.ISimpleBlockRenderingHandler; import net.minecraft.block.Block; import net.minecraft.client.renderer.RenderBlocks; import net.minecraft.world.IBlockAccess; import vazkii.botania.client.lib.LibRenderIDs; +import cpw.mods.fml.client.registry.ISimpleBlockRenderingHandler; public class RenderFloatingFlower implements ISimpleBlockRenderingHandler { - @Override - public void renderInventoryBlock(Block block, int metadata, int modelId, RenderBlocks renderer) { - // NO-OP, see RenderFloatingFlowerItem under ./item. - } + @Override + public void renderInventoryBlock(Block block, int metadata, int modelId, RenderBlocks renderer) { + // NO-OP, see RenderFloatingFlowerItem under ./item. + } + + @Override + public boolean renderWorldBlock(IBlockAccess world, int x, int y, int z, Block block, int modelId, RenderBlocks renderer) { + return false; + } - @Override - public boolean renderWorldBlock( - IBlockAccess world, int x, int y, int z, Block block, int modelId, RenderBlocks renderer) { - return false; - } + @Override + public boolean shouldRender3DInInventory(int modelId) { + return true; + } - @Override - public boolean shouldRender3DInInventory(int modelId) { - return true; - } + @Override + public int getRenderId() { + return LibRenderIDs.idMiniIsland; + } - @Override - public int getRenderId() { - return LibRenderIDs.idMiniIsland; - } } diff --git a/src/main/java/vazkii/botania/client/render/block/RenderHourglass.java b/src/main/java/vazkii/botania/client/render/block/RenderHourglass.java index 620286f856..5bb3d923c8 100644 --- a/src/main/java/vazkii/botania/client/render/block/RenderHourglass.java +++ b/src/main/java/vazkii/botania/client/render/block/RenderHourglass.java @@ -2,48 +2,50 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [May 30, 2015, 3:17:41 PM (GMT)] */ package vazkii.botania.client.render.block; -import cpw.mods.fml.client.registry.ISimpleBlockRenderingHandler; import net.minecraft.block.Block; import net.minecraft.client.renderer.RenderBlocks; import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher; import net.minecraft.world.IBlockAccess; + import org.lwjgl.opengl.GL11; + import vazkii.botania.client.lib.LibRenderIDs; import vazkii.botania.common.block.tile.TileHourglass; +import cpw.mods.fml.client.registry.ISimpleBlockRenderingHandler; public class RenderHourglass implements ISimpleBlockRenderingHandler { - @Override - public void renderInventoryBlock(Block block, int metadata, int modelID, RenderBlocks renderer) { - GL11.glPushMatrix(); - GL11.glTranslatef(-0.5F, -0.5F, -0.5F); - GL11.glDisable(GL11.GL_ALPHA_TEST); - TileEntityRendererDispatcher.instance.renderTileEntityAt(new TileHourglass(), 0.0D, 0.0D, 0.0D, 0.0F); - GL11.glEnable(GL11.GL_ALPHA_TEST); - GL11.glPopMatrix(); - } - - @Override - public boolean renderWorldBlock( - IBlockAccess world, int x, int y, int z, Block block, int modelId, RenderBlocks renderer) { - return false; - } - - @Override - public int getRenderId() { - return LibRenderIDs.idHourglass; - } - - @Override - public boolean shouldRender3DInInventory(int modelId) { - return true; - } + @Override + public void renderInventoryBlock(Block block, int metadata, int modelID, RenderBlocks renderer) { + GL11.glPushMatrix(); + GL11.glTranslatef(-0.5F, -0.5F, -0.5F); + GL11.glDisable(GL11.GL_ALPHA_TEST); + TileEntityRendererDispatcher.instance.renderTileEntityAt(new TileHourglass(), 0.0D, 0.0D, 0.0D, 0.0F); + GL11.glEnable(GL11.GL_ALPHA_TEST); + GL11.glPopMatrix(); + } + + @Override + public boolean renderWorldBlock(IBlockAccess world, int x, int y, int z, Block block, int modelId, RenderBlocks renderer) { + return false; + } + + @Override + public int getRenderId() { + return LibRenderIDs.idHourglass; + } + + @Override + public boolean shouldRender3DInInventory(int modelId) { + return true; + } + } diff --git a/src/main/java/vazkii/botania/client/render/block/RenderIncensePlate.java b/src/main/java/vazkii/botania/client/render/block/RenderIncensePlate.java index cc1a5c9698..d487e4fa22 100644 --- a/src/main/java/vazkii/botania/client/render/block/RenderIncensePlate.java +++ b/src/main/java/vazkii/botania/client/render/block/RenderIncensePlate.java @@ -2,47 +2,49 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [May 15, 2015, 5:59:56 PM (GMT)] */ package vazkii.botania.client.render.block; -import cpw.mods.fml.client.registry.ISimpleBlockRenderingHandler; import net.minecraft.block.Block; import net.minecraft.client.renderer.RenderBlocks; import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher; import net.minecraft.world.IBlockAccess; + import org.lwjgl.opengl.GL11; + import vazkii.botania.client.lib.LibRenderIDs; import vazkii.botania.common.block.tile.TileIncensePlate; +import cpw.mods.fml.client.registry.ISimpleBlockRenderingHandler; + +public class RenderIncensePlate implements ISimpleBlockRenderingHandler{ + + @Override + public void renderInventoryBlock(Block block, int metadata, int modelID, RenderBlocks renderer) { + GL11.glPushMatrix(); + GL11.glTranslatef(-0.5F, -0.1F, -0.5F); + GL11.glScalef(1.4F, 1.4F, 1.4F); + TileEntityRendererDispatcher.instance.renderTileEntityAt(new TileIncensePlate(), 0.0D, 0.0D, 0.0D, 0.0F); + GL11.glPopMatrix(); + } + + @Override + public boolean renderWorldBlock(IBlockAccess world, int x, int y, int z, Block block, int modelId, RenderBlocks renderer) { + return false; + } + + @Override + public int getRenderId() { + return LibRenderIDs.idIncensePlate; + } + + @Override + public boolean shouldRender3DInInventory(int modelId) { + return true; + } -public class RenderIncensePlate implements ISimpleBlockRenderingHandler { - - @Override - public void renderInventoryBlock(Block block, int metadata, int modelID, RenderBlocks renderer) { - GL11.glPushMatrix(); - GL11.glTranslatef(-0.5F, -0.1F, -0.5F); - GL11.glScalef(1.4F, 1.4F, 1.4F); - TileEntityRendererDispatcher.instance.renderTileEntityAt(new TileIncensePlate(), 0.0D, 0.0D, 0.0D, 0.0F); - GL11.glPopMatrix(); - } - - @Override - public boolean renderWorldBlock( - IBlockAccess world, int x, int y, int z, Block block, int modelId, RenderBlocks renderer) { - return false; - } - - @Override - public int getRenderId() { - return LibRenderIDs.idIncensePlate; - } - - @Override - public boolean shouldRender3DInInventory(int modelId) { - return true; - } } diff --git a/src/main/java/vazkii/botania/client/render/block/RenderPool.java b/src/main/java/vazkii/botania/client/render/block/RenderPool.java index c1b1c19a0f..29cc7cb519 100644 --- a/src/main/java/vazkii/botania/client/render/block/RenderPool.java +++ b/src/main/java/vazkii/botania/client/render/block/RenderPool.java @@ -2,49 +2,51 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jan 26, 2014, 12:25:06 AM (GMT)] */ package vazkii.botania.client.render.block; -import cpw.mods.fml.client.registry.ISimpleBlockRenderingHandler; import net.minecraft.block.Block; import net.minecraft.client.renderer.RenderBlocks; import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher; import net.minecraft.world.IBlockAccess; + import org.lwjgl.opengl.GL11; + import vazkii.botania.client.lib.LibRenderIDs; import vazkii.botania.client.render.tile.RenderTilePool; import vazkii.botania.common.block.tile.mana.TilePool; +import cpw.mods.fml.client.registry.ISimpleBlockRenderingHandler; public class RenderPool implements ISimpleBlockRenderingHandler { - @Override - public void renderInventoryBlock(Block block, int metadata, int modelID, RenderBlocks renderer) { - GL11.glPushMatrix(); - GL11.glTranslatef(-0.5F, -0.5F, -0.5F); - RenderTilePool.forceMeta = metadata; - RenderTilePool.forceMana = RenderTilePool.forceMana | metadata == 1; - TileEntityRendererDispatcher.instance.renderTileEntityAt(new TilePool(), 0.0D, 0.0D, 0.0D, 0.0F); - GL11.glPopMatrix(); - } - - @Override - public boolean renderWorldBlock( - IBlockAccess world, int x, int y, int z, Block block, int modelId, RenderBlocks renderer) { - return false; - } - - @Override - public int getRenderId() { - return LibRenderIDs.idPool; - } - - @Override - public boolean shouldRender3DInInventory(int modelId) { - return true; - } + @Override + public void renderInventoryBlock(Block block, int metadata, int modelID, RenderBlocks renderer) { + GL11.glPushMatrix(); + GL11.glTranslatef(-0.5F, -0.5F, -0.5F); + RenderTilePool.forceMeta = metadata; + RenderTilePool.forceMana = RenderTilePool.forceMana | metadata == 1; + TileEntityRendererDispatcher.instance.renderTileEntityAt(new TilePool(), 0.0D, 0.0D, 0.0D, 0.0F); + GL11.glPopMatrix(); + } + + @Override + public boolean renderWorldBlock(IBlockAccess world, int x, int y, int z, Block block, int modelId, RenderBlocks renderer) { + return false; + } + + @Override + public int getRenderId() { + return LibRenderIDs.idPool; + } + + @Override + public boolean shouldRender3DInInventory(int modelId) { + return true; + } + } diff --git a/src/main/java/vazkii/botania/client/render/block/RenderPump.java b/src/main/java/vazkii/botania/client/render/block/RenderPump.java index 14124f8859..cbf99719f6 100644 --- a/src/main/java/vazkii/botania/client/render/block/RenderPump.java +++ b/src/main/java/vazkii/botania/client/render/block/RenderPump.java @@ -2,46 +2,48 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Mar 18, 2015, 4:42:08 PM (GMT)] */ package vazkii.botania.client.render.block; -import cpw.mods.fml.client.registry.ISimpleBlockRenderingHandler; import net.minecraft.block.Block; import net.minecraft.client.renderer.RenderBlocks; import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher; import net.minecraft.world.IBlockAccess; + import org.lwjgl.opengl.GL11; + import vazkii.botania.client.lib.LibRenderIDs; import vazkii.botania.common.block.tile.mana.TilePump; +import cpw.mods.fml.client.registry.ISimpleBlockRenderingHandler; public class RenderPump implements ISimpleBlockRenderingHandler { - @Override - public void renderInventoryBlock(Block block, int metadata, int modelId, RenderBlocks renderer) { - GL11.glPushMatrix(); - GL11.glTranslatef(-0.5F, -0.25F, -0.5F); - TileEntityRendererDispatcher.instance.renderTileEntityAt(new TilePump(), 0.0D, 0.0D, 0.0D, 0.0F); - GL11.glPopMatrix(); - } - - @Override - public boolean renderWorldBlock( - IBlockAccess world, int x, int y, int z, Block block, int modelId, RenderBlocks renderer) { - return false; - } - - @Override - public boolean shouldRender3DInInventory(int modelId) { - return true; - } - - @Override - public int getRenderId() { - return LibRenderIDs.idPump; - } + @Override + public void renderInventoryBlock(Block block, int metadata, int modelId, RenderBlocks renderer) { + GL11.glPushMatrix(); + GL11.glTranslatef(-0.5F, -0.25F, -0.5F); + TileEntityRendererDispatcher.instance.renderTileEntityAt(new TilePump(), 0.0D, 0.0D, 0.0D, 0.0F); + GL11.glPopMatrix(); + } + + @Override + public boolean renderWorldBlock(IBlockAccess world, int x, int y, int z, Block block, int modelId, RenderBlocks renderer) { + return false; + } + + @Override + public boolean shouldRender3DInInventory(int modelId) { + return true; + } + + @Override + public int getRenderId() { + return LibRenderIDs.idPump; + } + } diff --git a/src/main/java/vazkii/botania/client/render/block/RenderPylon.java b/src/main/java/vazkii/botania/client/render/block/RenderPylon.java index 3571d73ed2..aad8cfd198 100644 --- a/src/main/java/vazkii/botania/client/render/block/RenderPylon.java +++ b/src/main/java/vazkii/botania/client/render/block/RenderPylon.java @@ -2,49 +2,51 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Feb 18, 2014, 10:20:06 PM (GMT)] */ package vazkii.botania.client.render.block; -import cpw.mods.fml.client.registry.ISimpleBlockRenderingHandler; import net.minecraft.block.Block; import net.minecraft.client.renderer.RenderBlocks; import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher; import net.minecraft.world.IBlockAccess; + import org.lwjgl.opengl.GL11; + import vazkii.botania.client.lib.LibRenderIDs; import vazkii.botania.client.render.tile.RenderTilePylon; import vazkii.botania.common.block.tile.TilePylon; +import cpw.mods.fml.client.registry.ISimpleBlockRenderingHandler; public class RenderPylon implements ISimpleBlockRenderingHandler { - @Override - public void renderInventoryBlock(Block block, int metadata, int modelID, RenderBlocks renderer) { - GL11.glPushMatrix(); - GL11.glTranslatef(-0.5F, -0.7F, -0.5F); - RenderTilePylon.green = metadata == 1; - RenderTilePylon.pink = metadata == 2; - TileEntityRendererDispatcher.instance.renderTileEntityAt(new TilePylon(), 0.0D, 0.0D, 0.0D, 0.0F); - GL11.glPopMatrix(); - } - - @Override - public boolean renderWorldBlock( - IBlockAccess world, int x, int y, int z, Block block, int modelId, RenderBlocks renderer) { - return false; - } - - @Override - public int getRenderId() { - return LibRenderIDs.idPylon; - } - - @Override - public boolean shouldRender3DInInventory(int modelId) { - return true; - } + @Override + public void renderInventoryBlock(Block block, int metadata, int modelID, RenderBlocks renderer) { + GL11.glPushMatrix(); + GL11.glTranslatef(-0.5F, -0.7F, -0.5F); + RenderTilePylon.green = metadata == 1; + RenderTilePylon.pink = metadata == 2; + TileEntityRendererDispatcher.instance.renderTileEntityAt(new TilePylon(), 0.0D, 0.0D, 0.0D, 0.0F); + GL11.glPopMatrix(); + } + + @Override + public boolean renderWorldBlock(IBlockAccess world, int x, int y, int z, Block block, int modelId, RenderBlocks renderer) { + return false; + } + + @Override + public int getRenderId() { + return LibRenderIDs.idPylon; + } + + @Override + public boolean shouldRender3DInInventory(int modelId) { + return true; + } + } diff --git a/src/main/java/vazkii/botania/client/render/block/RenderSpawnerClaw.java b/src/main/java/vazkii/botania/client/render/block/RenderSpawnerClaw.java index ca6a864d83..6c1e455132 100644 --- a/src/main/java/vazkii/botania/client/render/block/RenderSpawnerClaw.java +++ b/src/main/java/vazkii/botania/client/render/block/RenderSpawnerClaw.java @@ -2,46 +2,48 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jul 23, 2014, 6:23:54 PM (GMT)] */ package vazkii.botania.client.render.block; -import cpw.mods.fml.client.registry.ISimpleBlockRenderingHandler; import net.minecraft.block.Block; import net.minecraft.client.renderer.RenderBlocks; import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher; import net.minecraft.world.IBlockAccess; + import org.lwjgl.opengl.GL11; + import vazkii.botania.client.lib.LibRenderIDs; import vazkii.botania.common.block.tile.TileSpawnerClaw; +import cpw.mods.fml.client.registry.ISimpleBlockRenderingHandler; public class RenderSpawnerClaw implements ISimpleBlockRenderingHandler { - @Override - public void renderInventoryBlock(Block block, int metadata, int modelId, RenderBlocks renderer) { - GL11.glPushMatrix(); - GL11.glTranslatef(-0.5F, 0F, -0.5F); - TileEntityRendererDispatcher.instance.renderTileEntityAt(new TileSpawnerClaw(), 0.0D, 0.0D, 0.0D, 0.0F); - GL11.glPopMatrix(); - } - - @Override - public boolean renderWorldBlock( - IBlockAccess world, int x, int y, int z, Block block, int modelId, RenderBlocks renderer) { - return false; - } - - @Override - public boolean shouldRender3DInInventory(int modelId) { - return true; - } - - @Override - public int getRenderId() { - return LibRenderIDs.idSpawnerClaw; - } + @Override + public void renderInventoryBlock(Block block, int metadata, int modelId, RenderBlocks renderer) { + GL11.glPushMatrix(); + GL11.glTranslatef(-0.5F, 0F, -0.5F); + TileEntityRendererDispatcher.instance.renderTileEntityAt(new TileSpawnerClaw(), 0.0D, 0.0D, 0.0D, 0.0F); + GL11.glPopMatrix(); + } + + @Override + public boolean renderWorldBlock(IBlockAccess world, int x, int y, int z, Block block, int modelId, RenderBlocks renderer) { + return false; + } + + @Override + public boolean shouldRender3DInInventory(int modelId) { + return true; + } + + @Override + public int getRenderId() { + return LibRenderIDs.idSpawnerClaw; + } + } diff --git a/src/main/java/vazkii/botania/client/render/block/RenderSpecialFlower.java b/src/main/java/vazkii/botania/client/render/block/RenderSpecialFlower.java index 42076c5085..6de45bc66c 100644 --- a/src/main/java/vazkii/botania/client/render/block/RenderSpecialFlower.java +++ b/src/main/java/vazkii/botania/client/render/block/RenderSpecialFlower.java @@ -2,15 +2,14 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jan 25, 2014, 4:15:46 PM (GMT)] */ package vazkii.botania.client.render.block; -import cpw.mods.fml.client.registry.ISimpleBlockRenderingHandler; import net.minecraft.block.Block; import net.minecraft.client.renderer.EntityRenderer; import net.minecraft.client.renderer.RenderBlocks; @@ -20,134 +19,117 @@ import vazkii.botania.api.lexicon.multiblock.IMultiblockRenderHook; import vazkii.botania.api.lexicon.multiblock.Multiblock; import vazkii.botania.api.lexicon.multiblock.component.MultiblockComponent; +import cpw.mods.fml.client.registry.ISimpleBlockRenderingHandler; public class RenderSpecialFlower implements ISimpleBlockRenderingHandler, IMultiblockRenderHook { - int id; - - public RenderSpecialFlower(int id) { - this.id = id; - } - - @Override - public void renderInventoryBlock(Block block, int metadata, int modelID, RenderBlocks renderer) { - // NO-OP - } - - @Override - public boolean renderWorldBlock( - IBlockAccess blockAccess, int x, int y, int z, Block block, int modelId, RenderBlocks renderer) { - return renderCrossedSquares(blockAccess, block, x, y, z, renderer); - } - - // Copied from RenderBlocks - public static boolean renderCrossedSquares( - IBlockAccess blockAccess, Block par1Block, int par2, int par3, int par4, RenderBlocks render) { - Tessellator tessellator = Tessellator.instance; - tessellator.setBrightness(par1Block.getMixedBrightnessForBlock(blockAccess, par2, par3, par4)); - float f = 1.0F; - int l = par1Block.colorMultiplier(blockAccess, par2, par3, par4); - float f1 = (l >> 16 & 255) / 255.0F; - float f2 = (l >> 8 & 255) / 255.0F; - float f3 = (l & 255) / 255.0F; - - if (EntityRenderer.anaglyphEnable) { - float f4 = (f1 * 30.0F + f2 * 59.0F + f3 * 11.0F) / 100.0F; - float f5 = (f1 * 30.0F + f2 * 70.0F) / 100.0F; - float f6 = (f1 * 30.0F + f3 * 70.0F) / 100.0F; - f1 = f4; - f2 = f5; - f3 = f6; - } - - tessellator.setColorOpaque_F(f * f1, f * f2, f * f3); - double d1 = par2; - double d2 = par3; - double d0 = par4; - long sh; - - sh = par2 * 3129871 ^ par4 * 116129781L ^ par3; - sh = sh * sh * 42317861L + sh * 11L; - d1 += ((sh >> 16 & 15L) / 15.0F - 0.5D) * 0.3D; - d2 += (sh >> 32 & 15L) / 15.0F * -0.15D; - d0 += ((sh >> 24 & 15L) / 15.0F - 0.5D) * 0.3D; - - // Only change here, to use xyz rather than side/meta - IIcon icon = render.getBlockIcon(par1Block, blockAccess, par2, par3, par4, 0); - drawCrossedSquares(blockAccess, par1Block, icon, par2, par3, par4, d1, d2, d0, 1.0F, render); - - return true; - } - - // Copied from RenderBlocks - public static void drawCrossedSquares( - IBlockAccess blockAccess, - Block par1Block, - IIcon icon, - int x, - int y, - int z, - double par3, - double par5, - double par7, - float par9, - RenderBlocks render) { - Tessellator tessellator = Tessellator.instance; - - double d3 = icon.getMinU(); - double d4 = icon.getMinV(); - double d5 = icon.getMaxU(); - double d6 = icon.getMaxV(); - double d7 = 0.45D * par9; - double d8 = par3 + 0.5D - d7; - double d9 = par3 + 0.5D + d7; - double d10 = par7 + 0.5D - d7; - double d11 = par7 + 0.5D + d7; - tessellator.addVertexWithUV(d8, par5 + par9, d10, d3, d4); - tessellator.addVertexWithUV(d8, par5 + 0.0D, d10, d3, d6); - tessellator.addVertexWithUV(d9, par5 + 0.0D, d11, d5, d6); - tessellator.addVertexWithUV(d9, par5 + par9, d11, d5, d4); - tessellator.addVertexWithUV(d9, par5 + par9, d11, d3, d4); - tessellator.addVertexWithUV(d9, par5 + 0.0D, d11, d3, d6); - tessellator.addVertexWithUV(d8, par5 + 0.0D, d10, d5, d6); - tessellator.addVertexWithUV(d8, par5 + par9, d10, d5, d4); - tessellator.addVertexWithUV(d8, par5 + par9, d11, d3, d4); - tessellator.addVertexWithUV(d8, par5 + 0.0D, d11, d3, d6); - tessellator.addVertexWithUV(d9, par5 + 0.0D, d10, d5, d6); - tessellator.addVertexWithUV(d9, par5 + par9, d10, d5, d4); - tessellator.addVertexWithUV(d9, par5 + par9, d10, d3, d4); - tessellator.addVertexWithUV(d9, par5 + 0.0D, d10, d3, d6); - tessellator.addVertexWithUV(d8, par5 + 0.0D, d11, d5, d6); - tessellator.addVertexWithUV(d8, par5 + par9, d11, d5, d4); - } - - @Override - public int getRenderId() { - return id; - } - - @Override - public boolean shouldRender3DInInventory(int modelId) { - return false; - } - - @Override - public void renderBlockForMultiblock( - IBlockAccess world, - Multiblock mb, - Block block, - int meta, - RenderBlocks renderBlocks, - MultiblockComponent comp, - float alpha) { - Tessellator tess = Tessellator.instance; - tess.startDrawingQuads(); - drawCrossedSquares(world, block, block.getIcon(0, meta), 0, 0, 0, -0.5, -0.5, -0.5, 1F, renderBlocks); - tess.draw(); - } - - @Override - public boolean needsTranslate(Block block) { - return true; - } + int id; + + public RenderSpecialFlower(int id) { + this.id = id; + } + + @Override + public void renderInventoryBlock(Block block, int metadata, int modelID, RenderBlocks renderer) { + // NO-OP + } + + @Override + public boolean renderWorldBlock(IBlockAccess blockAccess, int x, int y, int z, Block block, int modelId, RenderBlocks renderer) { + return renderCrossedSquares(blockAccess, block, x, y, z, renderer); + } + + // Copied from RenderBlocks + public static boolean renderCrossedSquares(IBlockAccess blockAccess, Block par1Block, int par2, int par3, int par4, RenderBlocks render) { + Tessellator tessellator = Tessellator.instance; + tessellator.setBrightness(par1Block.getMixedBrightnessForBlock(blockAccess, par2, par3, par4)); + float f = 1.0F; + int l = par1Block.colorMultiplier(blockAccess, par2, par3, par4); + float f1 = (l >> 16 & 255) / 255.0F; + float f2 = (l >> 8 & 255) / 255.0F; + float f3 = (l & 255) / 255.0F; + + if(EntityRenderer.anaglyphEnable) { + float f4 = (f1 * 30.0F + f2 * 59.0F + f3 * 11.0F) / 100.0F; + float f5 = (f1 * 30.0F + f2 * 70.0F) / 100.0F; + float f6 = (f1 * 30.0F + f3 * 70.0F) / 100.0F; + f1 = f4; + f2 = f5; + f3 = f6; + } + + tessellator.setColorOpaque_F(f * f1, f * f2, f * f3); + double d1 = par2; + double d2 = par3; + double d0 = par4; + long sh; + + sh = par2 * 3129871 ^ par4 * 116129781L ^ par3; + sh = sh * sh * 42317861L + sh * 11L; + d1 += ((sh >> 16 & 15L) / 15.0F - 0.5D) * 0.3D; + d2 += (sh >> 32 & 15L) / 15.0F * -0.15D; + d0 += ((sh >> 24 & 15L) / 15.0F - 0.5D) * 0.3D; + + + // Only change here, to use xyz rather than side/meta + IIcon icon = render.getBlockIcon(par1Block, blockAccess, par2, par3, par4, 0); + drawCrossedSquares(blockAccess, par1Block, icon, par2, par3, par4, d1, d2, d0, 1.0F, render); + + return true; + } + + // Copied from RenderBlocks + public static void drawCrossedSquares(IBlockAccess blockAccess, Block par1Block, IIcon icon, int x, int y, int z, double par3, double par5, double par7, float par9, RenderBlocks render) { + Tessellator tessellator = Tessellator.instance; + + double d3 = icon.getMinU(); + double d4 = icon.getMinV(); + double d5 = icon.getMaxU(); + double d6 = icon.getMaxV(); + double d7 = 0.45D * par9; + double d8 = par3 + 0.5D - d7; + double d9 = par3 + 0.5D + d7; + double d10 = par7 + 0.5D - d7; + double d11 = par7 + 0.5D + d7; + tessellator.addVertexWithUV(d8, par5 + par9, d10, d3, d4); + tessellator.addVertexWithUV(d8, par5 + 0.0D, d10, d3, d6); + tessellator.addVertexWithUV(d9, par5 + 0.0D, d11, d5, d6); + tessellator.addVertexWithUV(d9, par5 + par9, d11, d5, d4); + tessellator.addVertexWithUV(d9, par5 + par9, d11, d3, d4); + tessellator.addVertexWithUV(d9, par5 + 0.0D, d11, d3, d6); + tessellator.addVertexWithUV(d8, par5 + 0.0D, d10, d5, d6); + tessellator.addVertexWithUV(d8, par5 + par9, d10, d5, d4); + tessellator.addVertexWithUV(d8, par5 + par9, d11, d3, d4); + tessellator.addVertexWithUV(d8, par5 + 0.0D, d11, d3, d6); + tessellator.addVertexWithUV(d9, par5 + 0.0D, d10, d5, d6); + tessellator.addVertexWithUV(d9, par5 + par9, d10, d5, d4); + tessellator.addVertexWithUV(d9, par5 + par9, d10, d3, d4); + tessellator.addVertexWithUV(d9, par5 + 0.0D, d10, d3, d6); + tessellator.addVertexWithUV(d8, par5 + 0.0D, d11, d5, d6); + tessellator.addVertexWithUV(d8, par5 + par9, d11, d5, d4); + } + + @Override + public int getRenderId() { + return id; + } + + @Override + public boolean shouldRender3DInInventory(int modelId) { + return false; + } + + @Override + public void renderBlockForMultiblock(IBlockAccess world, Multiblock mb, Block block, int meta, RenderBlocks renderBlocks, MultiblockComponent comp, float alpha) { + Tessellator tess = Tessellator.instance; + tess.startDrawingQuads(); + drawCrossedSquares(world, block, block.getIcon(0, meta), 0, 0, 0, -0.5, -0.5, -0.5, 1F, renderBlocks); + tess.draw(); + } + + @Override + public boolean needsTranslate(Block block) { + return true; + } + } diff --git a/src/main/java/vazkii/botania/client/render/block/RenderSpreader.java b/src/main/java/vazkii/botania/client/render/block/RenderSpreader.java index f8cf3dbf13..946dfdb6c4 100644 --- a/src/main/java/vazkii/botania/client/render/block/RenderSpreader.java +++ b/src/main/java/vazkii/botania/client/render/block/RenderSpreader.java @@ -2,52 +2,54 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jan 25, 2014, 9:45:58 PM (GMT)] */ package vazkii.botania.client.render.block; -import cpw.mods.fml.client.registry.ISimpleBlockRenderingHandler; import net.minecraft.block.Block; import net.minecraft.client.renderer.RenderBlocks; import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher; import net.minecraft.world.IBlockAccess; + import org.lwjgl.opengl.GL11; + import vazkii.botania.client.lib.LibRenderIDs; import vazkii.botania.common.block.tile.mana.TileSpreader; +import cpw.mods.fml.client.registry.ISimpleBlockRenderingHandler; public class RenderSpreader implements ISimpleBlockRenderingHandler { - @Override - public void renderInventoryBlock(Block block, int metadata, int modelID, RenderBlocks renderer) { - GL11.glPushMatrix(); - GL11.glTranslatef(-0.5F, -0.5F, -0.5F); - TileSpreader.staticRedstone = metadata == 1; - TileSpreader.staticDreamwood = metadata == 2 || metadata == 3; - TileSpreader.staticUltra = metadata == 3; - - TileSpreader spreader = new TileSpreader(); - spreader.rotationX = -180F; - TileEntityRendererDispatcher.instance.renderTileEntityAt(spreader, 0.0D, 0.0D, 0.0D, 0.0F); - GL11.glPopMatrix(); - } - - @Override - public boolean renderWorldBlock( - IBlockAccess world, int x, int y, int z, Block block, int modelId, RenderBlocks renderer) { - return false; - } - - @Override - public int getRenderId() { - return LibRenderIDs.idSpreader; - } - - @Override - public boolean shouldRender3DInInventory(int modelId) { - return true; - } + @Override + public void renderInventoryBlock(Block block, int metadata, int modelID, RenderBlocks renderer) { + GL11.glPushMatrix(); + GL11.glTranslatef(-0.5F, -0.5F, -0.5F); + TileSpreader.staticRedstone = metadata == 1; + TileSpreader.staticDreamwood = metadata == 2 || metadata == 3; + TileSpreader.staticUltra = metadata == 3; + + TileSpreader spreader = new TileSpreader(); + spreader.rotationX = -180F; + TileEntityRendererDispatcher.instance.renderTileEntityAt(spreader, 0.0D, 0.0D, 0.0D, 0.0F); + GL11.glPopMatrix(); + } + + @Override + public boolean renderWorldBlock(IBlockAccess world, int x, int y, int z, Block block, int modelId, RenderBlocks renderer) { + return false; + } + + @Override + public int getRenderId() { + return LibRenderIDs.idSpreader; + } + + @Override + public boolean shouldRender3DInInventory(int modelId) { + return true; + } + } diff --git a/src/main/java/vazkii/botania/client/render/block/RenderTeruTeruBozu.java b/src/main/java/vazkii/botania/client/render/block/RenderTeruTeruBozu.java index 185bb43cd5..d12f99eaab 100644 --- a/src/main/java/vazkii/botania/client/render/block/RenderTeruTeruBozu.java +++ b/src/main/java/vazkii/botania/client/render/block/RenderTeruTeruBozu.java @@ -2,46 +2,48 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Oct 1, 2015, 9:40:27 PM (GMT)] */ package vazkii.botania.client.render.block; -import cpw.mods.fml.client.registry.ISimpleBlockRenderingHandler; import net.minecraft.block.Block; import net.minecraft.client.renderer.RenderBlocks; import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher; import net.minecraft.world.IBlockAccess; + import org.lwjgl.opengl.GL11; + import vazkii.botania.client.lib.LibRenderIDs; import vazkii.botania.common.block.tile.TileTeruTeruBozu; +import cpw.mods.fml.client.registry.ISimpleBlockRenderingHandler; public class RenderTeruTeruBozu implements ISimpleBlockRenderingHandler { - @Override - public void renderInventoryBlock(Block block, int metadata, int modelID, RenderBlocks renderer) { - GL11.glPushMatrix(); - GL11.glTranslatef(-0.5F, -0.3F, -0.5F); - TileEntityRendererDispatcher.instance.renderTileEntityAt(new TileTeruTeruBozu(), 0.0D, 0.0D, 0.0D, 0.0F); - GL11.glPopMatrix(); - } - - @Override - public boolean renderWorldBlock( - IBlockAccess world, int x, int y, int z, Block block, int modelId, RenderBlocks renderer) { - return false; - } - - @Override - public int getRenderId() { - return LibRenderIDs.idTeruTeruBozu; - } - - @Override - public boolean shouldRender3DInInventory(int modelId) { - return true; - } + @Override + public void renderInventoryBlock(Block block, int metadata, int modelID, RenderBlocks renderer) { + GL11.glPushMatrix(); + GL11.glTranslatef(-0.5F, -0.3F, -0.5F); + TileEntityRendererDispatcher.instance.renderTileEntityAt(new TileTeruTeruBozu(), 0.0D, 0.0D, 0.0D, 0.0F); + GL11.glPopMatrix(); + } + + @Override + public boolean renderWorldBlock(IBlockAccess world, int x, int y, int z, Block block, int modelId, RenderBlocks renderer) { + return false; + } + + @Override + public int getRenderId() { + return LibRenderIDs.idTeruTeruBozu; + } + + @Override + public boolean shouldRender3DInInventory(int modelId) { + return true; + } + } diff --git a/src/main/java/vazkii/botania/client/render/block/RenderTinyPotato.java b/src/main/java/vazkii/botania/client/render/block/RenderTinyPotato.java index a13915da36..2ba503369e 100644 --- a/src/main/java/vazkii/botania/client/render/block/RenderTinyPotato.java +++ b/src/main/java/vazkii/botania/client/render/block/RenderTinyPotato.java @@ -2,46 +2,48 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jul 18, 2014, 11:43:37 PM (GMT)] */ package vazkii.botania.client.render.block; -import cpw.mods.fml.client.registry.ISimpleBlockRenderingHandler; import net.minecraft.block.Block; import net.minecraft.client.renderer.RenderBlocks; import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher; import net.minecraft.world.IBlockAccess; + import org.lwjgl.opengl.GL11; + import vazkii.botania.client.lib.LibRenderIDs; import vazkii.botania.common.block.tile.TileTinyPotato; +import cpw.mods.fml.client.registry.ISimpleBlockRenderingHandler; public class RenderTinyPotato implements ISimpleBlockRenderingHandler { - @Override - public void renderInventoryBlock(Block block, int metadata, int modelId, RenderBlocks renderer) { - GL11.glPushMatrix(); - GL11.glTranslatef(-0.5F, 0F, -0.5F); - TileEntityRendererDispatcher.instance.renderTileEntityAt(new TileTinyPotato(), 0.0D, 0.0D, 0.0D, 0.0F); - GL11.glPopMatrix(); - } - - @Override - public boolean renderWorldBlock( - IBlockAccess world, int x, int y, int z, Block block, int modelId, RenderBlocks renderer) { - return false; - } - - @Override - public boolean shouldRender3DInInventory(int modelId) { - return true; - } - - @Override - public int getRenderId() { - return LibRenderIDs.idTinyPotato; - } + @Override + public void renderInventoryBlock(Block block, int metadata, int modelId, RenderBlocks renderer) { + GL11.glPushMatrix(); + GL11.glTranslatef(-0.5F, 0F, -0.5F); + TileEntityRendererDispatcher.instance.renderTileEntityAt(new TileTinyPotato(), 0.0D, 0.0D, 0.0D, 0.0F); + GL11.glPopMatrix(); + } + + @Override + public boolean renderWorldBlock(IBlockAccess world, int x, int y, int z, Block block, int modelId, RenderBlocks renderer) { + return false; + } + + @Override + public boolean shouldRender3DInInventory(int modelId) { + return true; + } + + @Override + public int getRenderId() { + return LibRenderIDs.idTinyPotato; + } + } diff --git a/src/main/java/vazkii/botania/client/render/entity/RenderBabylonWeapon.java b/src/main/java/vazkii/botania/client/render/entity/RenderBabylonWeapon.java index ea27f08db5..0fc4712ede 100644 --- a/src/main/java/vazkii/botania/client/render/entity/RenderBabylonWeapon.java +++ b/src/main/java/vazkii/botania/client/render/entity/RenderBabylonWeapon.java @@ -2,15 +2,16 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Aug 16, 2015, 6:42:09 PM (GMT)] */ package vazkii.botania.client.render.entity; import java.util.Random; + import net.minecraft.client.Minecraft; import net.minecraft.client.renderer.ItemRenderer; import net.minecraft.client.renderer.OpenGlHelper; @@ -20,7 +21,9 @@ import net.minecraft.entity.Entity; import net.minecraft.util.IIcon; import net.minecraft.util.ResourceLocation; + import org.lwjgl.opengl.GL11; + import vazkii.botania.client.core.helper.ShaderHelper; import vazkii.botania.client.lib.LibResources; import vazkii.botania.common.entity.EntityBabylonWeapon; @@ -28,78 +31,79 @@ public class RenderBabylonWeapon extends Render { - private static final ResourceLocation babylon = new ResourceLocation(LibResources.MISC_BABYLON); - - @Override - public void doRender(Entity par1Entity, double par2, double par4, double par6, float par8, float par9) { - EntityBabylonWeapon weapon = (EntityBabylonWeapon) par1Entity; - GL11.glPushMatrix(); - GL11.glTranslatef((float) par2, (float) par4, (float) par6); - GL11.glRotatef(weapon.getRotation(), 0F, 1F, 0F); - - int live = weapon.getLiveTicks(); - int delay = weapon.getDelay(); - float charge = Math.min(10F, Math.max(live, weapon.getChargeTicks()) + par9); - float chargeMul = charge / 10F; - - GL11.glEnable(GL11.GL_BLEND); - GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); - - Minecraft.getMinecraft().renderEngine.bindTexture(TextureMap.locationItemsTexture); - GL11.glPushMatrix(); - float s = 1.5F; - GL11.glScalef(s, s, s); - GL11.glRotatef(-90F, 0F, 1F, 0F); - GL11.glRotatef(45F, 0F, 0F, 1F); - IIcon icon = ItemKingKey.weaponIcons[weapon.getVariety()]; - GL11.glColor4f(1F, 1F, 1F, chargeMul); - float f = icon.getMinU(); - float f1 = icon.getMaxU(); - float f2 = icon.getMinV(); - float f3 = icon.getMaxV(); - - OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, 240, 240); - GL11.glDisable(GL11.GL_LIGHTING); - ItemRenderer.renderItemIn2D( - Tessellator.instance, f1, f2, f, f3, icon.getIconWidth(), icon.getIconHeight(), 1F / 16F); - GL11.glPopMatrix(); - - GL11.glDisable(GL11.GL_CULL_FACE); - GL11.glShadeModel(GL11.GL_SMOOTH); - GL11.glColor4f(1F, 1F, 1F, chargeMul); - - Minecraft.getMinecraft().renderEngine.bindTexture(babylon); - - Tessellator tes = Tessellator.instance; - ShaderHelper.useShader(ShaderHelper.halo); - Random rand = new Random(weapon.getUniqueID().getMostSignificantBits()); - GL11.glRotatef(-90F, 1F, 0F, 0F); - GL11.glTranslatef(0F, -0.3F + rand.nextFloat() * 0.1F, 1F); - - s = chargeMul; - if (live > delay) s -= Math.min(1F, (live - delay + par9) * 0.2F); - s *= 2F; - GL11.glScalef(s, s, s); - - GL11.glRotatef(charge * 9F + (weapon.ticksExisted + par9) * 0.5F + rand.nextFloat() * 360F, 0F, 1F, 0F); - - tes.startDrawingQuads(); - tes.addVertexWithUV(-1, 0, -1, 0, 0); - tes.addVertexWithUV(-1, 0, 1, 0, 1); - tes.addVertexWithUV(1, 0, 1, 1, 1); - tes.addVertexWithUV(1, 0, -1, 1, 0); - tes.draw(); - - ShaderHelper.releaseShader(); - - GL11.glEnable(GL11.GL_LIGHTING); - GL11.glShadeModel(GL11.GL_FLAT); - GL11.glEnable(GL11.GL_CULL_FACE); - GL11.glPopMatrix(); - } - - @Override - protected ResourceLocation getEntityTexture(Entity p_110775_1_) { - return null; - } + private static final ResourceLocation babylon = new ResourceLocation(LibResources.MISC_BABYLON); + + @Override + public void doRender(Entity par1Entity, double par2, double par4, double par6, float par8, float par9) { + EntityBabylonWeapon weapon = (EntityBabylonWeapon) par1Entity; + GL11.glPushMatrix(); + GL11.glTranslatef((float)par2, (float)par4, (float)par6); + GL11.glRotatef(weapon.getRotation(), 0F, 1F, 0F); + + int live = weapon.getLiveTicks(); + int delay = weapon.getDelay(); + float charge = Math.min(10F, Math.max(live, weapon.getChargeTicks()) + par9); + float chargeMul = charge / 10F; + + GL11.glEnable(GL11.GL_BLEND); + GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); + + Minecraft.getMinecraft().renderEngine.bindTexture(TextureMap.locationItemsTexture); + GL11.glPushMatrix(); + float s = 1.5F; + GL11.glScalef(s, s, s); + GL11.glRotatef(-90F, 0F, 1F, 0F); + GL11.glRotatef(45F, 0F, 0F, 1F); + IIcon icon = ItemKingKey.weaponIcons[weapon.getVariety()]; + GL11.glColor4f(1F, 1F, 1F, chargeMul); + float f = icon.getMinU(); + float f1 = icon.getMaxU(); + float f2 = icon.getMinV(); + float f3 = icon.getMaxV(); + + OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, 240, 240); + GL11.glDisable(GL11.GL_LIGHTING); + ItemRenderer.renderItemIn2D(Tessellator.instance, f1, f2, f, f3, icon.getIconWidth(), icon.getIconHeight(), 1F / 16F); + GL11.glPopMatrix(); + + GL11.glDisable(GL11.GL_CULL_FACE); + GL11.glShadeModel(GL11.GL_SMOOTH); + GL11.glColor4f(1F, 1F, 1F, chargeMul); + + Minecraft.getMinecraft().renderEngine.bindTexture(babylon); + + Tessellator tes = Tessellator.instance; + ShaderHelper.useShader(ShaderHelper.halo); + Random rand = new Random(weapon.getUniqueID().getMostSignificantBits()); + GL11.glRotatef(-90F, 1F, 0F, 0F); + GL11.glTranslatef(0F, -0.3F + rand.nextFloat() * 0.1F, 1F); + + s = chargeMul; + if(live > delay) + s -= Math.min(1F, (live - delay + par9) * 0.2F); + s *= 2F; + GL11.glScalef(s, s, s); + + GL11.glRotatef(charge * 9F + (weapon.ticksExisted + par9) * 0.5F + rand.nextFloat() * 360F, 0F, 1F, 0F); + + tes.startDrawingQuads(); + tes.addVertexWithUV(-1, 0, -1, 0, 0); + tes.addVertexWithUV(-1, 0, 1, 0, 1); + tes.addVertexWithUV(1, 0, 1, 1, 1); + tes.addVertexWithUV(1, 0, -1, 1, 0); + tes.draw(); + + ShaderHelper.releaseShader(); + + GL11.glEnable(GL11.GL_LIGHTING); + GL11.glShadeModel(GL11.GL_FLAT); + GL11.glEnable(GL11.GL_CULL_FACE); + GL11.glPopMatrix(); + } + + @Override + protected ResourceLocation getEntityTexture(Entity p_110775_1_) { + return null; + } + } diff --git a/src/main/java/vazkii/botania/client/render/entity/RenderCorporeaSpark.java b/src/main/java/vazkii/botania/client/render/entity/RenderCorporeaSpark.java index d1216aecfc..5dc731a27b 100644 --- a/src/main/java/vazkii/botania/client/render/entity/RenderCorporeaSpark.java +++ b/src/main/java/vazkii/botania/client/render/entity/RenderCorporeaSpark.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Feb 14, 2015, 1:04:34 AM (GMT)] */ package vazkii.botania.client.render.entity; @@ -21,94 +21,83 @@ import net.minecraft.item.ItemStack; import net.minecraft.util.IIcon; import net.minecraftforge.common.util.ForgeDirection; + import org.lwjgl.opengl.GL11; + import vazkii.botania.common.entity.EntityCorporeaSpark; import vazkii.botania.common.item.ItemCorporeaSpark; public class RenderCorporeaSpark extends RenderSparkBase { - @Override - public IIcon getBaseIcon(EntityCorporeaSpark entity) { - return entity.isMaster() ? ItemCorporeaSpark.worldIconMaster : ItemCorporeaSpark.worldIcon; - } - - @Override - public void colorSpinningIcon(EntityCorporeaSpark entity, float a) { - int network = Math.min(15, entity.getNetwork()); - GL11.glColor4f( - EntitySheep.fleeceColorTable[network][0], - EntitySheep.fleeceColorTable[network][1], - EntitySheep.fleeceColorTable[network][2], - a); - } - - @Override - public IIcon getSpinningIcon(EntityCorporeaSpark entity) { - return ItemCorporeaSpark.iconColorStar; - } - - @Override - public void renderCallback(EntityCorporeaSpark entity, float pticks) { - int time = entity.getItemDisplayTicks(); - if (time == 0) return; - - float absTime = Math.abs(time) - pticks; - - GL11.glPushMatrix(); - GL11.glRotated(90F, 1F, 0F, 0F); - float scalef = 1F / 6F; - GL11.glScalef(scalef, scalef, scalef); - GL11.glEnable(GL11.GL_BLEND); - GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); - GL11.glColor4f(1F, 1F, 1F, absTime / 10); - GL11.glTranslatef(0F, 0F, -2F + (time < 0 ? -absTime : absTime) / 6); - - ItemStack stack = entity.getDisplayedItem(); - if (stack == null) return; - - Item item = stack.getItem(); - boolean block = item instanceof ItemBlock; - Minecraft.getMinecraft() - .renderEngine - .bindTexture(block ? TextureMap.locationBlocksTexture : TextureMap.locationItemsTexture); - IIcon icon = block - ? Block.getBlockFromItem(item).getBlockTextureFromSide(ForgeDirection.UP.ordinal()) - : item.getIcon(stack, 0); - - if (icon != null) { - float minU = icon.getMinU(); - float maxU = icon.getMaxU(); - float minV = icon.getMinV(); - float maxV = icon.getMaxV(); - - int pieces = 8; - float stepU = (maxU - minU) / pieces; - float stepV = (maxV - minV) / pieces; - float gap = 1F + (time > 0 ? 10F - absTime : absTime) * 0.2F; - int shift = pieces / 2; - - float scale = 1F / pieces * 3F; - GL11.glScalef(scale, scale, 1F); - for (int i = -shift; i < shift; i++) { - GL11.glTranslated(gap * i, 0F, 0F); - for (int j = -shift; j < shift; j++) { - GL11.glTranslated(0F, gap * j, 0F); - ItemRenderer.renderItemIn2D( - Tessellator.instance, - minU + stepU * (i + shift), - minV + stepV * (j + shift + 1), - minU + stepU * (i + shift + 1), - minV + stepV * (j + shift), - icon.getIconWidth() / pieces, - icon.getIconHeight() / pieces, - 1F / 8F); - GL11.glTranslated(0F, -gap * j, 0F); - } - GL11.glTranslated(-gap * i, 0F, 0F); - } - } - - GL11.glDisable(GL11.GL_BLEND); - GL11.glPopMatrix(); - } + @Override + public IIcon getBaseIcon(EntityCorporeaSpark entity) { + return entity.isMaster() ? ItemCorporeaSpark.worldIconMaster : ItemCorporeaSpark.worldIcon; + } + + @Override + public void colorSpinningIcon(EntityCorporeaSpark entity, float a) { + int network = Math.min(15, entity.getNetwork()); + GL11.glColor4f(EntitySheep.fleeceColorTable[network][0], EntitySheep.fleeceColorTable[network][1], EntitySheep.fleeceColorTable[network][2], a); + } + + @Override + public IIcon getSpinningIcon(EntityCorporeaSpark entity) { + return ItemCorporeaSpark.iconColorStar; + } + + @Override + public void renderCallback(EntityCorporeaSpark entity, float pticks) { + int time = entity.getItemDisplayTicks(); + if(time == 0) + return; + + float absTime = Math.abs(time) - pticks; + + GL11.glPushMatrix(); + GL11.glRotated(90F, 1F, 0F, 0F); + float scalef = 1F / 6F; + GL11.glScalef(scalef, scalef, scalef); + GL11.glEnable(GL11.GL_BLEND); + GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); + GL11.glColor4f(1F, 1F, 1F, absTime / 10); + GL11.glTranslatef(0F, 0F, -2F + (time < 0 ? -absTime : absTime) / 6); + + ItemStack stack = entity.getDisplayedItem(); + if(stack == null) + return; + + Item item = stack.getItem(); + boolean block = item instanceof ItemBlock; + Minecraft.getMinecraft().renderEngine.bindTexture(block ? TextureMap.locationBlocksTexture : TextureMap.locationItemsTexture); + IIcon icon = block ? Block.getBlockFromItem(item).getBlockTextureFromSide(ForgeDirection.UP.ordinal()) : item.getIcon(stack, 0); + + if(icon != null) { + float minU = icon.getMinU(); + float maxU = icon.getMaxU(); + float minV = icon.getMinV(); + float maxV = icon.getMaxV(); + + int pieces = 8; + float stepU = (maxU - minU) / pieces; + float stepV = (maxV - minV) / pieces; + float gap = 1F + (time > 0 ? 10F - absTime : absTime) * 0.2F; + int shift = pieces / 2; + + float scale = 1F / pieces * 3F; + GL11.glScalef(scale, scale, 1F); + for(int i = -shift; i < shift; i++) { + GL11.glTranslated(gap * i, 0F, 0F); + for(int j = -shift; j < shift; j++) { + GL11.glTranslated(0F, gap * j, 0F); + ItemRenderer.renderItemIn2D(Tessellator.instance, minU + stepU * (i + shift), minV + stepV * (j + shift + 1), minU + stepU * (i + shift + 1), minV + stepV * (j + shift), icon.getIconWidth() / pieces, icon.getIconHeight() / pieces, 1F / 8F); + GL11.glTranslated(0F, -gap * j, 0F); + } + GL11.glTranslated(-gap * i, 0F, 0F); + } + } + + GL11.glDisable(GL11.GL_BLEND); + GL11.glPopMatrix(); + } + } diff --git a/src/main/java/vazkii/botania/client/render/entity/RenderDoppleganger.java b/src/main/java/vazkii/botania/client/render/entity/RenderDoppleganger.java index 51b2ca39c5..3b8c124ba8 100644 --- a/src/main/java/vazkii/botania/client/render/entity/RenderDoppleganger.java +++ b/src/main/java/vazkii/botania/client/render/entity/RenderDoppleganger.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jul 12, 2014, 4:07:26 PM (GMT)] */ package vazkii.botania.client.render.entity; @@ -15,7 +15,9 @@ import net.minecraft.client.renderer.entity.RenderBiped; import net.minecraft.entity.Entity; import net.minecraft.util.ResourceLocation; + import org.lwjgl.opengl.ARBShaderObjects; + import vazkii.botania.api.internal.ShaderCallback; import vazkii.botania.client.core.handler.BossBarHandler; import vazkii.botania.client.core.helper.ShaderHelper; @@ -23,65 +25,66 @@ public class RenderDoppleganger extends RenderBiped { - public static float DEFAULT_GRAIN_INTENSITY = 0.05F; - public static float DEFAULT_DISFIGURATION = 0.025F; - - public static float grainIntensity = DEFAULT_GRAIN_INTENSITY; - public static float disfiguration = DEFAULT_DISFIGURATION; - - public static ShaderCallback callback = new ShaderCallback() { - - @Override - public void call(int shader) { - // Frag Uniforms - int disfigurationUniform = ARBShaderObjects.glGetUniformLocationARB(shader, "disfiguration"); - ARBShaderObjects.glUniform1fARB(disfigurationUniform, disfiguration); - - // Vert Uniforms - int grainIntensityUniform = ARBShaderObjects.glGetUniformLocationARB(shader, "grainIntensity"); - ARBShaderObjects.glUniform1fARB(grainIntensityUniform, grainIntensity); - } - }; - - public static ShaderCallback defaultCallback = new ShaderCallback() { - - @Override - public void call(int shader) { - // Frag Uniforms - int disfigurationUniform = ARBShaderObjects.glGetUniformLocationARB(shader, "disfiguration"); - ARBShaderObjects.glUniform1fARB(disfigurationUniform, DEFAULT_DISFIGURATION); - - // Vert Uniforms - int grainIntensityUniform = ARBShaderObjects.glGetUniformLocationARB(shader, "grainIntensity"); - ARBShaderObjects.glUniform1fARB(grainIntensityUniform, DEFAULT_GRAIN_INTENSITY); - } - }; - - public RenderDoppleganger() { - super(new ModelBiped(0.5F), 0F); - } - - @Override - public void doRender(Entity par1Entity, double par2, double par4, double par6, float par8, float par9) { - EntityDoppleganger dopple = (EntityDoppleganger) par1Entity; - BossBarHandler.setCurrentBoss(dopple); - - int invulTime = dopple.getInvulTime(); - if (invulTime > 0) { - grainIntensity = invulTime > 20 ? 1F : invulTime * 0.05F; - disfiguration = grainIntensity * 0.3F; - } else { - disfiguration = (0.025F + dopple.hurtTime * ((1F - 0.15F) / 20F)) / 2F; - grainIntensity = 0.05F + dopple.hurtTime * ((1F - 0.15F) / 10F); - } - - ShaderHelper.useShader(ShaderHelper.doppleganger, callback); - super.doRender(par1Entity, par2, par4, par6, par8, par9); - ShaderHelper.releaseShader(); - } - - @Override - protected ResourceLocation getEntityTexture(Entity par1Entity) { - return Minecraft.getMinecraft().thePlayer.getLocationSkin(); - } + public static float DEFAULT_GRAIN_INTENSITY = 0.05F; + public static float DEFAULT_DISFIGURATION = 0.025F; + + public static float grainIntensity = DEFAULT_GRAIN_INTENSITY; + public static float disfiguration = DEFAULT_DISFIGURATION; + + public static ShaderCallback callback = new ShaderCallback() { + + @Override + public void call(int shader) { + // Frag Uniforms + int disfigurationUniform = ARBShaderObjects.glGetUniformLocationARB(shader, "disfiguration"); + ARBShaderObjects.glUniform1fARB(disfigurationUniform, disfiguration); + + // Vert Uniforms + int grainIntensityUniform = ARBShaderObjects.glGetUniformLocationARB(shader, "grainIntensity"); + ARBShaderObjects.glUniform1fARB(grainIntensityUniform, grainIntensity); + } + }; + + public static ShaderCallback defaultCallback = new ShaderCallback() { + + @Override + public void call(int shader) { + // Frag Uniforms + int disfigurationUniform = ARBShaderObjects.glGetUniformLocationARB(shader, "disfiguration"); + ARBShaderObjects.glUniform1fARB(disfigurationUniform, DEFAULT_DISFIGURATION); + + // Vert Uniforms + int grainIntensityUniform = ARBShaderObjects.glGetUniformLocationARB(shader, "grainIntensity"); + ARBShaderObjects.glUniform1fARB(grainIntensityUniform, DEFAULT_GRAIN_INTENSITY); + } + }; + + public RenderDoppleganger() { + super(new ModelBiped(0.5F), 0F); + } + + @Override + public void doRender(Entity par1Entity, double par2, double par4, double par6, float par8, float par9) { + EntityDoppleganger dopple = (EntityDoppleganger) par1Entity; + BossBarHandler.setCurrentBoss(dopple); + + int invulTime = dopple.getInvulTime(); + if(invulTime > 0) { + grainIntensity = invulTime > 20 ? 1F : invulTime * 0.05F; + disfiguration = grainIntensity * 0.3F; + } else { + disfiguration = (0.025F + dopple.hurtTime * ((1F - 0.15F) / 20F)) / 2F; + grainIntensity = 0.05F + dopple.hurtTime * ((1F - 0.15F) / 10F); + } + + ShaderHelper.useShader(ShaderHelper.doppleganger, callback); + super.doRender(par1Entity, par2, par4, par6, par8, par9); + ShaderHelper.releaseShader(); + } + + @Override + protected ResourceLocation getEntityTexture(Entity par1Entity) { + return Minecraft.getMinecraft().thePlayer.getLocationSkin(); + } + } diff --git a/src/main/java/vazkii/botania/client/render/entity/RenderManaStorm.java b/src/main/java/vazkii/botania/client/render/entity/RenderManaStorm.java index 7f3add7762..f0f568af4f 100644 --- a/src/main/java/vazkii/botania/client/render/entity/RenderManaStorm.java +++ b/src/main/java/vazkii/botania/client/render/entity/RenderManaStorm.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jul 25, 2015, 2:32:31 AM (GMT)] */ package vazkii.botania.client.render.entity; @@ -13,31 +13,31 @@ import net.minecraft.client.renderer.entity.Render; import net.minecraft.entity.Entity; import net.minecraft.util.ResourceLocation; + import org.lwjgl.opengl.GL11; import org.lwjgl.opengl.GL12; + import vazkii.botania.client.core.helper.RenderHelper; import vazkii.botania.common.entity.EntityManaStorm; public class RenderManaStorm extends Render { - @Override - public void doRender(Entity e, double x, double y, double z, float something, float pticks) { - GL11.glPushMatrix(); - GL11.glTranslated(x, y, z); - EntityManaStorm storm = (EntityManaStorm) e; - float maxScale = 1.95F; - float scale = 0.05F - + ((float) storm.burstsFired / EntityManaStorm.TOTAL_BURSTS - - (storm.deathTime == 0 ? 0 : storm.deathTime + pticks) / EntityManaStorm.DEATH_TIME) - * maxScale; - RenderHelper.renderStar(0x00FF00, scale, scale, scale, e.getUniqueID().getMostSignificantBits()); - GL11.glDisable(GL11.GL_BLEND); - GL11.glDisable(GL12.GL_RESCALE_NORMAL); - GL11.glPopMatrix(); - } + @Override + public void doRender(Entity e, double x, double y, double z, float something, float pticks) { + GL11.glPushMatrix(); + GL11.glTranslated(x, y, z); + EntityManaStorm storm = (EntityManaStorm) e; + float maxScale = 1.95F; + float scale = 0.05F + ((float) storm.burstsFired / EntityManaStorm.TOTAL_BURSTS - (storm.deathTime == 0 ? 0 : storm.deathTime + pticks) / EntityManaStorm.DEATH_TIME) * maxScale; + RenderHelper.renderStar(0x00FF00, scale, scale, scale, e.getUniqueID().getMostSignificantBits()); + GL11.glDisable(GL11.GL_BLEND); + GL11.glDisable(GL12.GL_RESCALE_NORMAL); + GL11.glPopMatrix(); + } + + @Override + protected ResourceLocation getEntityTexture(Entity p_110775_1_) { + return null; + } - @Override - protected ResourceLocation getEntityTexture(Entity p_110775_1_) { - return null; - } } diff --git a/src/main/java/vazkii/botania/client/render/entity/RenderPinkWither.java b/src/main/java/vazkii/botania/client/render/entity/RenderPinkWither.java index 3765d9b901..a6806ca39d 100644 --- a/src/main/java/vazkii/botania/client/render/entity/RenderPinkWither.java +++ b/src/main/java/vazkii/botania/client/render/entity/RenderPinkWither.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Mar 25, 2015, 5:55:59 PM (GMT)] */ package vazkii.botania.client.render.entity; @@ -18,27 +18,22 @@ public class RenderPinkWither extends RenderWither { - private static final ResourceLocation resource = new ResourceLocation(LibResources.MODEL_PINK_WITHER); + private static final ResourceLocation resource = new ResourceLocation(LibResources.MODEL_PINK_WITHER); - int idk = -1; + int idk = -1; - @Override - public void doRender( - EntityWither p_76986_1_, - double p_76986_2_, - double p_76986_4_, - double p_76986_6_, - float p_76986_8_, - float p_76986_9_) { - super.doRender(p_76986_1_, p_76986_2_, p_76986_4_, p_76986_6_, p_76986_8_, p_76986_9_); - if (BossStatus.bossName.equals(p_76986_1_.func_145748_c_().getFormattedText())) { - BossStatus.statusBarTime = -1; - BossStatus.hasColorModifier = false; - } - } + @Override + public void doRender(EntityWither p_76986_1_, double p_76986_2_, double p_76986_4_, double p_76986_6_, float p_76986_8_, float p_76986_9_) { + super.doRender(p_76986_1_, p_76986_2_, p_76986_4_, p_76986_6_, p_76986_8_, p_76986_9_); + if(BossStatus.bossName.equals(p_76986_1_.func_145748_c_().getFormattedText())) { + BossStatus.statusBarTime = -1; + BossStatus.hasColorModifier = false; + } + } + + @Override + protected ResourceLocation getEntityTexture(EntityWither p_110775_1_) { + return resource; + } - @Override - protected ResourceLocation getEntityTexture(EntityWither p_110775_1_) { - return resource; - } } diff --git a/src/main/java/vazkii/botania/client/render/entity/RenderPixie.java b/src/main/java/vazkii/botania/client/render/entity/RenderPixie.java index cdedfb416c..4ef2757543 100644 --- a/src/main/java/vazkii/botania/client/render/entity/RenderPixie.java +++ b/src/main/java/vazkii/botania/client/render/entity/RenderPixie.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [? (GMT)] */ package vazkii.botania.client.render.entity; @@ -15,8 +15,10 @@ import net.minecraft.entity.Entity; import net.minecraft.entity.EntityLivingBase; import net.minecraft.util.ResourceLocation; + import org.lwjgl.opengl.ARBShaderObjects; import org.lwjgl.opengl.GL11; + import vazkii.botania.api.internal.ShaderCallback; import vazkii.botania.client.core.helper.ShaderHelper; import vazkii.botania.client.lib.LibResources; @@ -25,64 +27,69 @@ public class RenderPixie extends RenderLiving { - ShaderCallback callback = new ShaderCallback() { + ShaderCallback callback = new ShaderCallback() { - @Override - public void call(int shader) { - // Frag Uniforms - int disfigurationUniform = ARBShaderObjects.glGetUniformLocationARB(shader, "disfiguration"); - ARBShaderObjects.glUniform1fARB(disfigurationUniform, 0.025F); + @Override + public void call(int shader) { + // Frag Uniforms + int disfigurationUniform = ARBShaderObjects.glGetUniformLocationARB(shader, "disfiguration"); + ARBShaderObjects.glUniform1fARB(disfigurationUniform, 0.025F); - // Vert Uniforms - int grainIntensityUniform = ARBShaderObjects.glGetUniformLocationARB(shader, "grainIntensity"); - ARBShaderObjects.glUniform1fARB(grainIntensityUniform, 0.05F); - } - }; + // Vert Uniforms + int grainIntensityUniform = ARBShaderObjects.glGetUniformLocationARB(shader, "grainIntensity"); + ARBShaderObjects.glUniform1fARB(grainIntensityUniform, 0.05F); + } + }; - public RenderPixie() { - super(new ModelPixie(), 0.25F); - setRenderPassModel(new ModelPixie()); - shadowSize = 0.0F; - } + public RenderPixie() { + super(new ModelPixie(), 0.25F); + setRenderPassModel(new ModelPixie()); + shadowSize = 0.0F; + } - @Override - protected ResourceLocation getEntityTexture(Entity entity) { - return new ResourceLocation(LibResources.MODEL_PIXIE); - } + @Override + protected ResourceLocation getEntityTexture(Entity entity) { + return new ResourceLocation(LibResources.MODEL_PIXIE); + } - @Override - public void doRender(Entity par1Entity, double par2, double par4, double par6, float par8, float par9) { - EntityPixie pixie = (EntityPixie) par1Entity; + @Override + public void doRender(Entity par1Entity, double par2, double par4, double par6, float par8, float par9) { + EntityPixie pixie = (EntityPixie) par1Entity; - if (pixie.getType() == 1) ShaderHelper.useShader(ShaderHelper.doppleganger, callback); - super.doRender(par1Entity, par2, par4, par6, par8, par9); - if (pixie.getType() == 1) ShaderHelper.releaseShader(); - } + if(pixie.getType() == 1) + ShaderHelper.useShader(ShaderHelper.doppleganger, callback); + super.doRender(par1Entity, par2, par4, par6, par8, par9); + if(pixie.getType() == 1) + ShaderHelper.releaseShader(); + } - protected int setPixieBrightness(EntityPixie par1EntityPixie, int par2, float par3) { - if (par2 != 0) return -1; - else { - bindTexture(getEntityTexture(par1EntityPixie)); - float f1 = 1.0F; - GL11.glEnable(GL11.GL_BLEND); - GL11.glDisable(GL11.GL_ALPHA_TEST); - GL11.glBlendFunc(GL11.GL_ONE, GL11.GL_ONE); + protected int setPixieBrightness(EntityPixie par1EntityPixie, int par2, float par3) { + if (par2 != 0) + return -1; + else { + bindTexture(getEntityTexture(par1EntityPixie)); + float f1 = 1.0F; + GL11.glEnable(GL11.GL_BLEND); + GL11.glDisable(GL11.GL_ALPHA_TEST); + GL11.glBlendFunc(GL11.GL_ONE, GL11.GL_ONE); - if (par1EntityPixie.isInvisible()) GL11.glDepthMask(false); - else GL11.glDepthMask(true); + if (par1EntityPixie.isInvisible()) + GL11.glDepthMask(false); + else + GL11.glDepthMask(true); - char c0 = 61680; - int j = c0 % 65536; - int k = c0 / 65536; - OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, j / 1.0F, k / 1.0F); - GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); - GL11.glColor4f(1.0F, 1.0F, 1.0F, f1); - return 1; - } - } + char c0 = 61680; + int j = c0 % 65536; + int k = c0 / 65536; + OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, j / 1.0F, k / 1.0F); + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + GL11.glColor4f(1.0F, 1.0F, 1.0F, f1); + return 1; + } + } - @Override - protected int shouldRenderPass(EntityLivingBase par1EntityLivingBase, int par2, float par3) { - return setPixieBrightness((EntityPixie) par1EntityLivingBase, par2, par3); - } -} + @Override + protected int shouldRenderPass(EntityLivingBase par1EntityLivingBase, int par2, float par3) { + return setPixieBrightness((EntityPixie)par1EntityLivingBase, par2, par3); + } +} \ No newline at end of file diff --git a/src/main/java/vazkii/botania/client/render/entity/RenderPoolMinecart.java b/src/main/java/vazkii/botania/client/render/entity/RenderPoolMinecart.java index 1db0784861..b9a043881a 100644 --- a/src/main/java/vazkii/botania/client/render/entity/RenderPoolMinecart.java +++ b/src/main/java/vazkii/botania/client/render/entity/RenderPoolMinecart.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Mar 17, 2015, 11:17:48 PM (GMT)] */ package vazkii.botania.client.render.entity; @@ -18,10 +18,12 @@ public class RenderPoolMinecart extends RenderMinecart { - @Override - protected void func_147910_a(EntityMinecart p_147910_1_, float p_147910_2_, Block p_147910_3_, int p_147910_4_) { - EntityPoolMinecart poolCart = (EntityPoolMinecart) p_147910_1_; - RenderTilePool.forceManaNumber = poolCart.getMana(); - super.func_147910_a(p_147910_1_, p_147910_2_, p_147910_3_, p_147910_4_); - } + @Override + protected void func_147910_a(EntityMinecart p_147910_1_, float p_147910_2_, Block p_147910_3_, int p_147910_4_) { + EntityPoolMinecart poolCart = (EntityPoolMinecart) p_147910_1_; + RenderTilePool.forceManaNumber = poolCart.getMana(); + super.func_147910_a(p_147910_1_, p_147910_2_, p_147910_3_, p_147910_4_); + } + + } diff --git a/src/main/java/vazkii/botania/client/render/entity/RenderSpark.java b/src/main/java/vazkii/botania/client/render/entity/RenderSpark.java index 091006e9d6..d28bcaca0d 100644 --- a/src/main/java/vazkii/botania/client/render/entity/RenderSpark.java +++ b/src/main/java/vazkii/botania/client/render/entity/RenderSpark.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Feb 14, 2015, 1:03:11 AM (GMT)] */ package vazkii.botania.client.render.entity; @@ -16,11 +16,10 @@ public class RenderSpark extends RenderSparkBase { - @Override - public IIcon getSpinningIcon(EntitySpark entity) { - int upgrade = entity.getUpgrade() - 1; - return upgrade >= 0 && upgrade < ItemSparkUpgrade.worldIcons.length - ? ItemSparkUpgrade.worldIcons[upgrade] - : null; - } + @Override + public IIcon getSpinningIcon(EntitySpark entity) { + int upgrade = entity.getUpgrade() - 1; + return upgrade >= 0 && upgrade < ItemSparkUpgrade.worldIcons.length ? ItemSparkUpgrade.worldIcons[upgrade] : null; + } + } diff --git a/src/main/java/vazkii/botania/client/render/entity/RenderSparkBase.java b/src/main/java/vazkii/botania/client/render/entity/RenderSparkBase.java index 201317469b..ff1109f83e 100644 --- a/src/main/java/vazkii/botania/client/render/entity/RenderSparkBase.java +++ b/src/main/java/vazkii/botania/client/render/entity/RenderSparkBase.java @@ -2,114 +2,116 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Aug 21, 2014, 5:53:22 PM (GMT)] */ package vazkii.botania.client.render.entity; import java.util.Random; + import net.minecraft.client.renderer.Tessellator; import net.minecraft.client.renderer.entity.RenderEntity; import net.minecraft.client.renderer.texture.TextureMap; import net.minecraft.entity.Entity; import net.minecraft.util.IIcon; import net.minecraft.util.ResourceLocation; + import org.lwjgl.opengl.GL11; import org.lwjgl.opengl.GL12; + import vazkii.botania.client.core.handler.ClientTickHandler; import vazkii.botania.common.entity.EntitySpark; import vazkii.botania.common.item.ItemSpark; public class RenderSparkBase extends RenderEntity { - @Override - public void doRender(Entity par1Entity, double par2, double par4, double par6, float par8, float par9) { - T tEntity = (T) par1Entity; - IIcon iicon = getBaseIcon(tEntity); - - GL11.glPushMatrix(); - GL11.glTranslatef((float) par2, (float) par4, (float) par6); - GL11.glEnable(GL12.GL_RESCALE_NORMAL); - GL11.glEnable(GL11.GL_BLEND); - GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); - GL11.glAlphaFunc(GL11.GL_GREATER, 0.05F); - - double time = ClientTickHandler.ticksInGame + par9; - time += new Random(par1Entity.getEntityId()).nextInt(); - float a = 0.1F - + (1 - par1Entity.getDataWatcher().getWatchableObjectInt(EntitySpark.INVISIBILITY_DATA_WATCHER_KEY)) - * 0.8F; - - GL11.glColor4f(1F, 1F, 1F, (0.7F + 0.3F * (float) (Math.sin(time / 5.0) + 0.5) * 2) * a); - - float scale = 0.75F + 0.1F * (float) Math.sin(time / 10); - GL11.glScalef(scale, scale, scale); - bindEntityTexture(par1Entity); - Tessellator tessellator = Tessellator.instance; - - GL11.glPushMatrix(); - float r = 180.0F - renderManager.playerViewY; - GL11.glRotatef(r, 0.0F, 1.0F, 0.0F); - GL11.glRotatef(-renderManager.playerViewX, 1F, 0F, 0F); - func_77026_a(tessellator, iicon); - - IIcon spinningIcon = getSpinningIcon(tEntity); - if (spinningIcon != null) { - GL11.glTranslatef( - -0.02F + (float) Math.sin(time / 20) * 0.2F, 0.24F + (float) Math.cos(time / 20) * 0.2F, 0.005F); - GL11.glScalef(0.2F, 0.2F, 0.2F); - colorSpinningIcon(tEntity, a); - func_77026_a(tessellator, spinningIcon); - } - GL11.glPopMatrix(); - GL11.glColor4f(1F, 1F, 1F, 1F); - renderCallback(tEntity, par9); - - GL11.glDisable(GL11.GL_BLEND); - GL11.glDisable(GL12.GL_RESCALE_NORMAL); - GL11.glPopMatrix(); - } - - public IIcon getBaseIcon(T entity) { - return ItemSpark.worldIcon; - } - - public void colorSpinningIcon(T entity, float a) { - // NO-OP - } - - public IIcon getSpinningIcon(T entity) { - return null; - } - - public void renderCallback(T entity, float pticks) { - // NO-OP - } - - @Override - protected ResourceLocation getEntityTexture(Entity p_110775_1_) { - return TextureMap.locationItemsTexture; - } - - private void func_77026_a(Tessellator p_77026_1_, IIcon p_77026_2_) { - float f = p_77026_2_.getMinU(); - float f1 = p_77026_2_.getMaxU(); - float f2 = p_77026_2_.getMinV(); - float f3 = p_77026_2_.getMaxV(); - float f4 = 1.0F; - float f5 = 0.5F; - float f6 = 0.25F; - - p_77026_1_.startDrawingQuads(); - p_77026_1_.setNormal(0.0F, 1.0F, 0.0F); - p_77026_1_.setBrightness(240); - p_77026_1_.addVertexWithUV(0.0F - f5, 0.0F - f6, 0.0D, f, f3); - p_77026_1_.addVertexWithUV(f4 - f5, 0.0F - f6, 0.0D, f1, f3); - p_77026_1_.addVertexWithUV(f4 - f5, f4 - f6, 0.0D, f1, f2); - p_77026_1_.addVertexWithUV(0.0F - f5, f4 - f6, 0.0D, f, f2); - p_77026_1_.draw(); - } + @Override + public void doRender(Entity par1Entity, double par2, double par4, double par6, float par8, float par9) { + T tEntity = (T) par1Entity; + IIcon iicon = getBaseIcon(tEntity); + + GL11.glPushMatrix(); + GL11.glTranslatef((float)par2, (float)par4, (float)par6); + GL11.glEnable(GL12.GL_RESCALE_NORMAL); + GL11.glEnable(GL11.GL_BLEND); + GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); + GL11.glAlphaFunc(GL11.GL_GREATER, 0.05F); + + double time = ClientTickHandler.ticksInGame + par9; + time += new Random(par1Entity.getEntityId()).nextInt(); + float a = 0.1F + (1 - par1Entity.getDataWatcher().getWatchableObjectInt(EntitySpark.INVISIBILITY_DATA_WATCHER_KEY)) * 0.8F; + + GL11.glColor4f(1F, 1F, 1F, (0.7F + 0.3F * (float) (Math.sin(time / 5.0) + 0.5) * 2) * a); + + float scale = 0.75F + 0.1F * (float) Math.sin(time / 10); + GL11.glScalef(scale, scale, scale); + bindEntityTexture(par1Entity); + Tessellator tessellator = Tessellator.instance; + + GL11.glPushMatrix(); + float r = 180.0F - renderManager.playerViewY; + GL11.glRotatef(r, 0.0F, 1.0F, 0.0F); + GL11.glRotatef(-renderManager.playerViewX, 1F, 0F, 0F); + func_77026_a(tessellator, iicon); + + IIcon spinningIcon = getSpinningIcon(tEntity); + if(spinningIcon != null) { + GL11.glTranslatef(-0.02F + (float) Math.sin(time / 20) * 0.2F, 0.24F + (float) Math.cos(time / 20) * 0.2F, 0.005F); + GL11.glScalef(0.2F, 0.2F, 0.2F); + colorSpinningIcon(tEntity, a); + func_77026_a(tessellator, spinningIcon); + } + GL11.glPopMatrix(); + GL11.glColor4f(1F, 1F, 1F, 1F); + renderCallback(tEntity, par9); + + GL11.glDisable(GL11.GL_BLEND); + GL11.glDisable(GL12.GL_RESCALE_NORMAL); + GL11.glPopMatrix(); + } + + public IIcon getBaseIcon(T entity) { + return ItemSpark.worldIcon; + } + + public void colorSpinningIcon(T entity, float a) { + // NO-OP + } + + public IIcon getSpinningIcon(T entity) { + return null; + } + + public void renderCallback(T entity, float pticks) { + // NO-OP + } + + @Override + protected ResourceLocation getEntityTexture(Entity p_110775_1_) { + return TextureMap.locationItemsTexture; + } + + private void func_77026_a(Tessellator p_77026_1_, IIcon p_77026_2_) { + float f = p_77026_2_.getMinU(); + float f1 = p_77026_2_.getMaxU(); + float f2 = p_77026_2_.getMinV(); + float f3 = p_77026_2_.getMaxV(); + float f4 = 1.0F; + float f5 = 0.5F; + float f6 = 0.25F; + + p_77026_1_.startDrawingQuads(); + p_77026_1_.setNormal(0.0F, 1.0F, 0.0F); + p_77026_1_.setBrightness(240); + p_77026_1_.addVertexWithUV(0.0F - f5, 0.0F - f6, 0.0D, f, f3); + p_77026_1_.addVertexWithUV(f4 - f5, 0.0F - f6, 0.0D, f1, f3); + p_77026_1_.addVertexWithUV(f4 - f5, f4 - f6, 0.0D, f1, f2); + p_77026_1_.addVertexWithUV(0.0F - f5, f4 - f6, 0.0D, f, f2); + p_77026_1_.draw(); + + } + } diff --git a/src/main/java/vazkii/botania/client/render/entity/RenderThornChakram.java b/src/main/java/vazkii/botania/client/render/entity/RenderThornChakram.java index 2dad7b416d..e23e8a18a7 100644 --- a/src/main/java/vazkii/botania/client/render/entity/RenderThornChakram.java +++ b/src/main/java/vazkii/botania/client/render/entity/RenderThornChakram.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Aug 27, 2015, 10:02:12 PM (GMT)] */ package vazkii.botania.client.render.entity; @@ -16,62 +16,60 @@ import net.minecraft.entity.Entity; import net.minecraft.util.IIcon; import net.minecraft.util.ResourceLocation; + import org.lwjgl.opengl.GL11; import org.lwjgl.opengl.GL12; + import vazkii.botania.common.entity.EntityThornChakram; import vazkii.botania.common.item.ModItems; // Basically a bit of an extension of RenderSnowball public class RenderThornChakram extends Render { - @Override - public void doRender( - Entity p_76986_1_, - double p_76986_2_, - double p_76986_4_, - double p_76986_6_, - float p_76986_8_, - float p_76986_9_) { - EntityThornChakram c = (EntityThornChakram) p_76986_1_; - boolean fire = c.isFire(); - IIcon iicon = ModItems.thornChakram.getIconFromDamage(fire ? 1 : 0); + @Override + public void doRender(Entity p_76986_1_, double p_76986_2_, double p_76986_4_, double p_76986_6_, float p_76986_8_, float p_76986_9_) { + EntityThornChakram c = (EntityThornChakram) p_76986_1_; + boolean fire = c.isFire(); + IIcon iicon = ModItems.thornChakram.getIconFromDamage(fire ? 1 : 0); + + if(iicon != null) { + GL11.glPushMatrix(); + GL11.glTranslatef((float)p_76986_2_, (float)p_76986_4_, (float)p_76986_6_); + GL11.glEnable(GL12.GL_RESCALE_NORMAL); + GL11.glScalef(0.5F, 0.5F, 0.5F); + bindEntityTexture(p_76986_1_); + Tessellator tessellator = Tessellator.instance; - if (iicon != null) { - GL11.glPushMatrix(); - GL11.glTranslatef((float) p_76986_2_, (float) p_76986_4_, (float) p_76986_6_); - GL11.glEnable(GL12.GL_RESCALE_NORMAL); - GL11.glScalef(0.5F, 0.5F, 0.5F); - bindEntityTexture(p_76986_1_); - Tessellator tessellator = Tessellator.instance; + func_77026_a(tessellator, iicon, fire ? 240 : -1); + GL11.glDisable(GL12.GL_RESCALE_NORMAL); + GL11.glPopMatrix(); + } + } - func_77026_a(tessellator, iicon, fire ? 240 : -1); - GL11.glDisable(GL12.GL_RESCALE_NORMAL); - GL11.glPopMatrix(); - } - } + @Override + protected ResourceLocation getEntityTexture(Entity p_110775_1_) { + return TextureMap.locationItemsTexture; + } - @Override - protected ResourceLocation getEntityTexture(Entity p_110775_1_) { - return TextureMap.locationItemsTexture; - } + private void func_77026_a(Tessellator p_77026_1_, IIcon p_77026_2_, int light) { + float f = p_77026_2_.getMinU(); + float f1 = p_77026_2_.getMaxU(); + float f2 = p_77026_2_.getMinV(); + float f3 = p_77026_2_.getMaxV(); + float f4 = 1.0F; + float f5 = 0.5F; + float f6 = 0.25F; + GL11.glRotatef(180.0F - renderManager.playerViewY, 0.0F, 1.0F, 0.0F); + GL11.glRotatef(-renderManager.playerViewX, 1.0F, 0.0F, 0.0F); + p_77026_1_.startDrawingQuads(); + p_77026_1_.setNormal(0.0F, 1.0F, 0.0F); + if(light != -1) + p_77026_1_.setBrightness(light); + p_77026_1_.addVertexWithUV(0.0F - f5, 0.0F - f6, 0.0D, f, f3); + p_77026_1_.addVertexWithUV(f4 - f5, 0.0F - f6, 0.0D, f1, f3); + p_77026_1_.addVertexWithUV(f4 - f5, f4 - f6, 0.0D, f1, f2); + p_77026_1_.addVertexWithUV(0.0F - f5, f4 - f6, 0.0D, f, f2); + p_77026_1_.draw(); + } - private void func_77026_a(Tessellator p_77026_1_, IIcon p_77026_2_, int light) { - float f = p_77026_2_.getMinU(); - float f1 = p_77026_2_.getMaxU(); - float f2 = p_77026_2_.getMinV(); - float f3 = p_77026_2_.getMaxV(); - float f4 = 1.0F; - float f5 = 0.5F; - float f6 = 0.25F; - GL11.glRotatef(180.0F - renderManager.playerViewY, 0.0F, 1.0F, 0.0F); - GL11.glRotatef(-renderManager.playerViewX, 1.0F, 0.0F, 0.0F); - p_77026_1_.startDrawingQuads(); - p_77026_1_.setNormal(0.0F, 1.0F, 0.0F); - if (light != -1) p_77026_1_.setBrightness(light); - p_77026_1_.addVertexWithUV(0.0F - f5, 0.0F - f6, 0.0D, f, f3); - p_77026_1_.addVertexWithUV(f4 - f5, 0.0F - f6, 0.0D, f1, f3); - p_77026_1_.addVertexWithUV(f4 - f5, f4 - f6, 0.0D, f1, f2); - p_77026_1_.addVertexWithUV(0.0F - f5, f4 - f6, 0.0D, f, f2); - p_77026_1_.draw(); - } } diff --git a/src/main/java/vazkii/botania/client/render/item/RenderBow.java b/src/main/java/vazkii/botania/client/render/item/RenderBow.java index 9d628bada5..8b22dc0daf 100644 --- a/src/main/java/vazkii/botania/client/render/item/RenderBow.java +++ b/src/main/java/vazkii/botania/client/render/item/RenderBow.java @@ -2,90 +2,93 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Feb 28, 2015, 3:43:09 PM (GMT)] */ package vazkii.botania.client.render.item; -import cpw.mods.fml.relauncher.ReflectionHelper; import net.minecraft.client.renderer.ItemRenderer; import net.minecraft.client.renderer.Tessellator; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; import net.minecraft.util.IIcon; import net.minecraftforge.client.IItemRenderer; + import org.lwjgl.opengl.GL11; + import vazkii.botania.common.lib.LibObfuscation; +import cpw.mods.fml.relauncher.ReflectionHelper; public class RenderBow implements IItemRenderer { - @Override - public boolean handleRenderType(ItemStack item, ItemRenderType type) { - return type != ItemRenderType.INVENTORY; - } + @Override + public boolean handleRenderType(ItemStack item, ItemRenderType type) { + return type != ItemRenderType.INVENTORY; + } + + @Override + public boolean shouldUseRenderHelper(ItemRenderType type, ItemStack item, ItemRendererHelper helper) { + return helper == ItemRendererHelper.ENTITY_ROTATION || helper == ItemRendererHelper.ENTITY_BOBBING; + } + + @Override + public void renderItem(ItemRenderType type, ItemStack item, Object... data) { + switch(type) { + case ENTITY : { + GL11.glPushMatrix(); + GL11.glTranslatef(-0.5F, 0F, 0F); + if(item.isOnItemFrame()) + GL11.glTranslatef(0F, -0.3F, 0.01F); + render(item, null, false); + GL11.glPopMatrix(); + break; + } + case EQUIPPED : { + render(item, data[1] instanceof EntityPlayer ? (EntityPlayer) data[1] : null, true); + break; + } + case EQUIPPED_FIRST_PERSON : { + render(item, data[1] instanceof EntityPlayer ? (EntityPlayer) data[1] : null, false); + break; + } + default : break; + } + } - @Override - public boolean shouldUseRenderHelper(ItemRenderType type, ItemStack item, ItemRendererHelper helper) { - return helper == ItemRendererHelper.ENTITY_ROTATION || helper == ItemRendererHelper.ENTITY_BOBBING; - } + public void render(ItemStack item, EntityPlayer player, boolean transform) { + int dmg = item.getItemDamage(); + IIcon icon = item.getItem().getIconFromDamageForRenderPass(dmg, 0); + if(player != null) { + ItemStack using = ReflectionHelper.getPrivateValue(EntityPlayer.class, player, LibObfuscation.ITEM_IN_USE); + int time = ReflectionHelper.getPrivateValue(EntityPlayer.class, player, LibObfuscation.ITEM_IN_USE_COUNT); + icon = item.getItem().getIcon(item, 0, player, using, time); + if(transform) { + GL11.glTranslatef(0.2F, -0.3F, 0.1F); + //GL11.glRotatef(20.0F, 0.0F, 1.0F, 0.0F); + //GL11.glRotatef(-100.0F, 1.0F, 0.0F, 0.0F); + } + } - @Override - public void renderItem(ItemRenderType type, ItemStack item, Object... data) { - switch (type) { - case ENTITY: { - GL11.glPushMatrix(); - GL11.glTranslatef(-0.5F, 0F, 0F); - if (item.isOnItemFrame()) GL11.glTranslatef(0F, -0.3F, 0.01F); - render(item, null, false); - GL11.glPopMatrix(); - break; - } - case EQUIPPED: { - render(item, data[1] instanceof EntityPlayer ? (EntityPlayer) data[1] : null, true); - break; - } - case EQUIPPED_FIRST_PERSON: { - render(item, data[1] instanceof EntityPlayer ? (EntityPlayer) data[1] : null, false); - break; - } - default: - break; - } - } + float f = icon.getMinU(); + float f1 = icon.getMaxU(); + float f2 = icon.getMinV(); + float f3 = icon.getMaxV(); + float scale = 1F / 16F; - public void render(ItemStack item, EntityPlayer player, boolean transform) { - int dmg = item.getItemDamage(); - IIcon icon = item.getItem().getIconFromDamageForRenderPass(dmg, 0); - if (player != null) { - ItemStack using = ReflectionHelper.getPrivateValue(EntityPlayer.class, player, LibObfuscation.ITEM_IN_USE); - int time = ReflectionHelper.getPrivateValue(EntityPlayer.class, player, LibObfuscation.ITEM_IN_USE_COUNT); - icon = item.getItem().getIcon(item, 0, player, using, time); - if (transform) { - GL11.glTranslatef(0.2F, -0.3F, 0.1F); - // GL11.glRotatef(20.0F, 0.0F, 1.0F, 0.0F); - // GL11.glRotatef(-100.0F, 1.0F, 0.0F, 0.0F); - } - } + GL11.glPushMatrix(); + GL11.glEnable(GL11.GL_BLEND); + GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); + GL11.glColor4f(1F, 1F, 1F, 1F); + ItemRenderer.renderItemIn2D(Tessellator.instance, f1, f2, f, f3, icon.getIconWidth(), icon.getIconHeight(), scale); - float f = icon.getMinU(); - float f1 = icon.getMaxU(); - float f2 = icon.getMinV(); - float f3 = icon.getMaxV(); - float scale = 1F / 16F; + GL11.glDisable(GL11.GL_BLEND); + GL11.glPopMatrix(); - GL11.glPushMatrix(); - GL11.glEnable(GL11.GL_BLEND); - GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); - GL11.glColor4f(1F, 1F, 1F, 1F); - ItemRenderer.renderItemIn2D( - Tessellator.instance, f1, f2, f, f3, icon.getIconWidth(), icon.getIconHeight(), scale); + GL11.glColor4f(1F, 1F, 1F, 1F); + } - GL11.glDisable(GL11.GL_BLEND); - GL11.glPopMatrix(); - GL11.glColor4f(1F, 1F, 1F, 1F); - } } diff --git a/src/main/java/vazkii/botania/client/render/item/RenderFloatingFlowerItem.java b/src/main/java/vazkii/botania/client/render/item/RenderFloatingFlowerItem.java index 26256bcd45..3f66ca3cba 100644 --- a/src/main/java/vazkii/botania/client/render/item/RenderFloatingFlowerItem.java +++ b/src/main/java/vazkii/botania/client/render/item/RenderFloatingFlowerItem.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Nov 17, 2014, 5:48:34 PM (GMT)] */ package vazkii.botania.client.render.item; @@ -14,7 +14,9 @@ import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraftforge.client.IItemRenderer; + import org.lwjgl.opengl.GL11; + import vazkii.botania.common.block.ModBlocks; import vazkii.botania.common.block.tile.TileFloatingFlower; import vazkii.botania.common.item.block.ItemBlockFloatingSpecialFlower; @@ -22,32 +24,31 @@ public class RenderFloatingFlowerItem implements IItemRenderer { - @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 stack, Object... data) { - GL11.glPushMatrix(); - GL11.glTranslatef(-0.5F, -0.5F, -0.5F); - GL11.glEnable(GL11.GL_BLEND); - GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); - float s = 1.4F; - GL11.glScalef(s, s, s); - GL11.glRotatef(-5F, 1F, 0F, 0F); - Item item = stack.getItem(); - TileFloatingFlower.forcedStack = item instanceof ItemBlockFloatingSpecialFlower - ? ItemBlockSpecialFlower.ofType(ItemBlockSpecialFlower.getType(stack)) - : new ItemStack(ModBlocks.flower, 1, stack.getItemDamage()); - - TileEntityRendererDispatcher.instance.renderTileEntityAt(new TileFloatingFlower(), 0.0D, 0.0D, 0.0D, 0.0F); - GL11.glDisable(GL11.GL_BLEND); - GL11.glPopMatrix(); - } + @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 stack, Object... data) { + GL11.glPushMatrix(); + GL11.glTranslatef(-0.5F, -0.5F, -0.5F); + GL11.glEnable(GL11.GL_BLEND); + GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); + float s = 1.4F; + GL11.glScalef(s, s, s); + GL11.glRotatef(-5F, 1F, 0F, 0F); + Item item = stack.getItem(); + TileFloatingFlower.forcedStack = item instanceof ItemBlockFloatingSpecialFlower ? ItemBlockSpecialFlower.ofType(ItemBlockSpecialFlower.getType(stack)) : new ItemStack(ModBlocks.flower, 1, stack.getItemDamage()); + + TileEntityRendererDispatcher.instance.renderTileEntityAt(new TileFloatingFlower(), 0.0D, 0.0D, 0.0D, 0.0F); + GL11.glDisable(GL11.GL_BLEND); + GL11.glPopMatrix(); + } + } diff --git a/src/main/java/vazkii/botania/client/render/item/RenderLens.java b/src/main/java/vazkii/botania/client/render/item/RenderLens.java index 1cfb9c2476..a3b71c2f4d 100644 --- a/src/main/java/vazkii/botania/client/render/item/RenderLens.java +++ b/src/main/java/vazkii/botania/client/render/item/RenderLens.java @@ -2,15 +2,16 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jan 31, 2014, 3:08:00 PM (GMT)] */ package vazkii.botania.client.render.item; import java.awt.Color; + import net.minecraft.client.Minecraft; import net.minecraft.client.renderer.ItemRenderer; import net.minecraft.client.renderer.Tessellator; @@ -18,102 +19,105 @@ import net.minecraft.item.ItemStack; import net.minecraft.util.IIcon; import net.minecraftforge.client.IItemRenderer; + import org.lwjgl.opengl.GL11; + import vazkii.botania.api.mana.ILens; import vazkii.botania.common.item.lens.ItemLens; public class RenderLens implements IItemRenderer { - static RenderItem render = new RenderItem(); - ItemRenderer renderer = new ItemRenderer(Minecraft.getMinecraft()); - - @Override - public boolean handleRenderType(ItemStack item, ItemRenderType type) { - return type != ItemRenderType.INVENTORY; - } - - @Override - public boolean shouldUseRenderHelper(ItemRenderType type, ItemStack item, ItemRendererHelper helper) { - return helper == ItemRendererHelper.ENTITY_ROTATION || helper == ItemRendererHelper.ENTITY_BOBBING; - } - - @Override - public void renderItem(ItemRenderType type, ItemStack item, Object... data) { - switch (type) { - case ENTITY: { - GL11.glPushMatrix(); - GL11.glTranslatef(-0.5F, 0F, 0F); - if (item.isOnItemFrame()) GL11.glTranslatef(0F, -0.3F, 0.01F); - render(item); - GL11.glPopMatrix(); - break; - } - case EQUIPPED: { - render(item); - break; - } - case EQUIPPED_FIRST_PERSON: { - render(item); - break; - } - default: - break; - } - } - - public static void render(ItemStack item) { - Color color = new Color(((ILens) item.getItem()).getLensColor(item)); - render(item, color.getRGB()); - } - - public static void render(ItemStack item, int color_) { - int dmg = item.getItemDamage(); - IIcon icon = item.getItem().getIconFromDamageForRenderPass(dmg, 1); - float f = icon.getMinU(); - float f1 = icon.getMaxU(); - float f2 = icon.getMinV(); - float f3 = icon.getMaxV(); - float scale = 1F / 16F; - - GL11.glColor4f(1F, 1F, 1F, 1F); - ItemRenderer.renderItemIn2D( - Tessellator.instance, f1, f2, f, f3, icon.getIconWidth(), icon.getIconHeight(), scale); - - GL11.glPushMatrix(); - GL11.glEnable(GL11.GL_BLEND); - GL11.glEnable(GL11.GL_CULL_FACE); - GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); - Color color = new Color(color_); - GL11.glColor4ub((byte) color.getRed(), (byte) color.getGreen(), (byte) color.getBlue(), (byte) 255); - - boolean shiny = ItemLens.getStoredColor(item) != -1; - icon = ItemLens.iconGlass; - GL11.glScalef(scale, scale, scale); - GL11.glTranslatef(0F, 0F, -0.5F); - renderShinyLensIcon(icon, shiny); - GL11.glRotatef(180F, 0F, 1F, 0F); - GL11.glTranslatef(-16F, 0F, 0F); - renderShinyLensIcon(icon, shiny); - GL11.glDisable(GL11.GL_CULL_FACE); - GL11.glDisable(GL11.GL_BLEND); - GL11.glPopMatrix(); - - GL11.glColor4f(1F, 1F, 1F, 1F); - } - - public static void renderShinyLensIcon(IIcon icon, boolean shiny) { - float par1 = 0; - float par2 = 0; - float par4 = 16; - float par5 = 16; - float zLevel = 0F; - Tessellator tessellator = Tessellator.instance; - tessellator.startDrawingQuads(); - if (shiny) tessellator.setBrightness(240); - tessellator.addVertexWithUV(par1 + 0, par2 + par5, zLevel, icon.getMinU(), icon.getMaxV()); - tessellator.addVertexWithUV(par1 + par4, par2 + par5, zLevel, icon.getMaxU(), icon.getMaxV()); - tessellator.addVertexWithUV(par1 + par4, par2 + 0, zLevel, icon.getMaxU(), icon.getMinV()); - tessellator.addVertexWithUV(par1 + 0, par2 + 0, zLevel, icon.getMinU(), icon.getMinV()); - tessellator.draw(); - } -} + static RenderItem render = new RenderItem(); + ItemRenderer renderer = new ItemRenderer(Minecraft.getMinecraft()); + + @Override + public boolean handleRenderType(ItemStack item, ItemRenderType type) { + return type != ItemRenderType.INVENTORY; + } + + @Override + public boolean shouldUseRenderHelper(ItemRenderType type, ItemStack item, ItemRendererHelper helper) { + return helper == ItemRendererHelper.ENTITY_ROTATION || helper == ItemRendererHelper.ENTITY_BOBBING; + } + + @Override + public void renderItem(ItemRenderType type, ItemStack item, Object... data) { + switch(type) { + case ENTITY : { + GL11.glPushMatrix(); + GL11.glTranslatef(-0.5F, 0F, 0F); + if(item.isOnItemFrame()) + GL11.glTranslatef(0F, -0.3F, 0.01F); + render(item); + GL11.glPopMatrix(); + break; + } + case EQUIPPED : { + render(item); + break; + } + case EQUIPPED_FIRST_PERSON : { + render(item); + break; + } + default : break; + } + } + + public static void render(ItemStack item) { + Color color = new Color(((ILens) item.getItem()).getLensColor(item)); + render(item, color.getRGB()); + } + + public static void render(ItemStack item, int color_) { + int dmg = item.getItemDamage(); + IIcon icon = item.getItem().getIconFromDamageForRenderPass(dmg, 1); + float f = icon.getMinU(); + float f1 = icon.getMaxU(); + float f2 = icon.getMinV(); + float f3 = icon.getMaxV(); + float scale = 1F / 16F; + + GL11.glColor4f(1F, 1F, 1F, 1F); + ItemRenderer.renderItemIn2D(Tessellator.instance, f1, f2, f, f3, icon.getIconWidth(), icon.getIconHeight(), scale); + + GL11.glPushMatrix(); + GL11.glEnable(GL11.GL_BLEND); + GL11.glEnable(GL11.GL_CULL_FACE); + GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); + Color color = new Color(color_); + GL11.glColor4ub((byte) color.getRed(), (byte) color.getGreen(), (byte) color.getBlue(), (byte) 255); + + boolean shiny = ItemLens.getStoredColor(item) != -1; + icon = ItemLens.iconGlass; + GL11.glScalef(scale, scale, scale); + GL11.glTranslatef(0F, 0F, -0.5F); + renderShinyLensIcon(icon, shiny); + GL11.glRotatef(180F, 0F, 1F, 0F); + GL11.glTranslatef(-16F, 0F, 0F); + renderShinyLensIcon(icon, shiny); + GL11.glDisable(GL11.GL_CULL_FACE); + GL11.glDisable(GL11.GL_BLEND); + GL11.glPopMatrix(); + + GL11.glColor4f(1F, 1F, 1F, 1F); + } + + public static void renderShinyLensIcon(IIcon icon, boolean shiny) { + float par1 = 0; + float par2 = 0; + float par4 = 16; + float par5 = 16; + float zLevel = 0F; + Tessellator tessellator = Tessellator.instance; + tessellator.startDrawingQuads(); + if(shiny) + tessellator.setBrightness(240); + tessellator.addVertexWithUV(par1 + 0, par2 + par5, zLevel, icon.getMinU(), icon.getMaxV()); + tessellator.addVertexWithUV(par1 + par4, par2 + par5, zLevel, icon.getMaxU(), icon.getMaxV()); + tessellator.addVertexWithUV(par1 + par4, par2 + 0, zLevel, icon.getMaxU(), icon.getMinV()); + tessellator.addVertexWithUV(par1 + 0, par2 + 0, zLevel, icon.getMinU(), icon.getMinV()); + tessellator.draw(); + } + +} \ No newline at end of file diff --git a/src/main/java/vazkii/botania/client/render/item/RenderLexicon.java b/src/main/java/vazkii/botania/client/render/item/RenderLexicon.java index 23cde5ae70..694325ae33 100644 --- a/src/main/java/vazkii/botania/client/render/item/RenderLexicon.java +++ b/src/main/java/vazkii/botania/client/render/item/RenderLexicon.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Mar 25, 2014, 8:49:01 PM (GMT)] */ package vazkii.botania.client.render.item; @@ -18,7 +18,9 @@ import net.minecraft.util.ResourceLocation; import net.minecraft.util.StatCollector; import net.minecraftforge.client.IItemRenderer; + import org.lwjgl.opengl.GL11; + import vazkii.botania.client.core.handler.ClientTickHandler; import vazkii.botania.client.gui.lexicon.GuiLexicon; import vazkii.botania.client.lib.LibResources; @@ -27,99 +29,87 @@ public class RenderLexicon implements IItemRenderer { - ModelBook model = new ModelBook(); - ResourceLocation texture = new ResourceLocation(LibResources.MODEL_LEXICA); - - @Override - public boolean handleRenderType(ItemStack item, ItemRenderType type) { - return type == ItemRenderType.EQUIPPED_FIRST_PERSON; - } - - @Override - public boolean shouldUseRenderHelper(ItemRenderType type, ItemStack item, ItemRendererHelper helper) { - return false; - } - - @Override - public void renderItem(ItemRenderType type, ItemStack item, Object... data) { - GL11.glPushMatrix(); - Minecraft mc = Minecraft.getMinecraft(); - mc.renderEngine.bindTexture(texture); - float opening = 0F; - float pageFlip = 0F; - - float ticks = ClientTickHandler.ticksWithLexicaOpen; - if (ticks > 0 && ticks < 10) { - if (mc.currentScreen instanceof GuiLexicon) ticks += ClientTickHandler.partialTicks; - else ticks -= ClientTickHandler.partialTicks; - } - - GL11.glTranslatef(0.3F + 0.02F * ticks, 0.475F + 0.01F * ticks, -0.2F - 0.01F * ticks); - GL11.glRotatef(87.5F + ticks * 5, 0F, 1F, 0F); - GL11.glRotatef(ticks * 2.5F, 0F, 0F, 1F); - GL11.glScalef(0.9F, 0.9F, 0.9F); - opening = ticks / 12F; - - float pageFlipTicks = ClientTickHandler.pageFlipTicks; - if (pageFlipTicks > 0) pageFlipTicks -= ClientTickHandler.partialTicks; - - pageFlip = pageFlipTicks / 5F; - - model.render(null, 0F, 0F, pageFlip, opening, 0F, 1F / 16F); - if (ticks < 3) { - FontRenderer font = Minecraft.getMinecraft().fontRenderer; - GL11.glRotatef(180F, 0F, 0F, 1F); - GL11.glTranslatef(-0.3F, -0.21F, -0.07F); - GL11.glScalef(0.0035F, 0.0035F, -0.0035F); - boolean bevo = - Minecraft.getMinecraft().thePlayer.getCommandSenderName().equalsIgnoreCase("BevoLJ"); - boolean saice = - Minecraft.getMinecraft().thePlayer.getCommandSenderName().equalsIgnoreCase("saice"); - - String title = ModItems.lexicon.getItemStackDisplayName(null); - String origTitle = title; - - if (Minecraft.getMinecraft().thePlayer.getCurrentEquippedItem() != null) - title = Minecraft.getMinecraft() - .thePlayer - .getCurrentEquippedItem() - .getDisplayName(); - if (title.equals(origTitle) && bevo) title = StatCollector.translateToLocal("item.botania:lexicon.bevo"); - if (title.equals(origTitle) && saice) title = StatCollector.translateToLocal("item.botania:lexicon.saice"); - - font.drawString(font.trimStringToWidth(title, 80), 0, 0, 0xD69700); - GL11.glTranslatef(0F, 10F, 0F); - GL11.glScalef(0.6F, 0.6F, 0.6F); - font.drawString( - EnumChatFormatting.ITALIC + "" + EnumChatFormatting.BOLD - + String.format( - StatCollector.translateToLocal("botaniamisc.edition"), ItemLexicon.getEdition()), - 0, - 0, - 0xA07100); - - GL11.glTranslatef(0F, 15F, 0F); - font.drawString(StatCollector.translateToLocal("botaniamisc.lexiconcover0"), 0, 0, 0x79ff92); - - GL11.glTranslatef(0F, 10F, 0F); - font.drawString(StatCollector.translateToLocal("botaniamisc.lexiconcover1"), 0, 0, 0x79ff92); - - GL11.glTranslatef(0F, 50F, 0F); - font.drawString(StatCollector.translateToLocal("botaniamisc.lexiconcover2"), 0, 0, 0x79ff92); - GL11.glTranslatef(0F, 10F, 0F); - font.drawString( - EnumChatFormatting.UNDERLINE + "" + EnumChatFormatting.ITALIC - + StatCollector.translateToLocal("botaniamisc.lexiconcover3"), - 0, - 0, - 0x79ff92); - if (bevo || saice) { - GL11.glTranslatef(0F, 10F, 0F); - font.drawString( - StatCollector.translateToLocal("botaniamisc.lexiconcover" + (bevo ? 4 : 5)), 0, 0, 0x79ff92); - } - } - - GL11.glPopMatrix(); - } + ModelBook model = new ModelBook(); + ResourceLocation texture = new ResourceLocation(LibResources.MODEL_LEXICA); + + @Override + public boolean handleRenderType(ItemStack item, ItemRenderType type) { + return type == ItemRenderType.EQUIPPED_FIRST_PERSON; + } + + @Override + public boolean shouldUseRenderHelper(ItemRenderType type, ItemStack item, ItemRendererHelper helper) { + return false; + } + + @Override + public void renderItem(ItemRenderType type, ItemStack item, Object... data) { + GL11.glPushMatrix(); + Minecraft mc = Minecraft.getMinecraft(); + mc.renderEngine.bindTexture(texture); + float opening = 0F; + float pageFlip = 0F; + + float ticks = ClientTickHandler.ticksWithLexicaOpen; + if(ticks > 0 && ticks < 10) { + if(mc.currentScreen instanceof GuiLexicon) + ticks += ClientTickHandler.partialTicks; + else ticks -= ClientTickHandler.partialTicks; + } + + GL11.glTranslatef(0.3F + 0.02F * ticks, 0.475F + 0.01F * ticks, -0.2F - 0.01F * ticks); + GL11.glRotatef(87.5F + ticks * 5, 0F, 1F, 0F); + GL11.glRotatef(ticks * 2.5F, 0F, 0F, 1F); + GL11.glScalef(0.9F, 0.9F, 0.9F); + opening = ticks / 12F; + + float pageFlipTicks = ClientTickHandler.pageFlipTicks; + if(pageFlipTicks > 0) + pageFlipTicks -= ClientTickHandler.partialTicks; + + pageFlip = pageFlipTicks / 5F; + + model.render(null, 0F, 0F, pageFlip, opening, 0F, 1F / 16F); + if(ticks < 3) { + FontRenderer font = Minecraft.getMinecraft().fontRenderer; + GL11.glRotatef(180F, 0F, 0F, 1F); + GL11.glTranslatef(-0.3F, -0.21F, -0.07F); + GL11.glScalef(0.0035F, 0.0035F, -0.0035F); + boolean bevo = Minecraft.getMinecraft().thePlayer.getCommandSenderName().equalsIgnoreCase("BevoLJ"); + boolean saice = Minecraft.getMinecraft().thePlayer.getCommandSenderName().equalsIgnoreCase("saice"); + + String title = ModItems.lexicon.getItemStackDisplayName(null); + String origTitle = title; + + if(Minecraft.getMinecraft().thePlayer.getCurrentEquippedItem() != null) + title = Minecraft.getMinecraft().thePlayer.getCurrentEquippedItem().getDisplayName(); + if(title.equals(origTitle) && bevo) + title = StatCollector.translateToLocal("item.botania:lexicon.bevo"); + if(title.equals(origTitle) && saice) + title = StatCollector.translateToLocal("item.botania:lexicon.saice"); + + font.drawString(font.trimStringToWidth(title, 80), 0, 0, 0xD69700); + GL11.glTranslatef(0F, 10F, 0F); + GL11.glScalef(0.6F, 0.6F, 0.6F); + font.drawString(EnumChatFormatting.ITALIC + "" + EnumChatFormatting.BOLD + String.format(StatCollector.translateToLocal("botaniamisc.edition"), ItemLexicon.getEdition()), 0, 0, 0xA07100); + + GL11.glTranslatef(0F, 15F, 0F); + font.drawString(StatCollector.translateToLocal("botaniamisc.lexiconcover0"), 0, 0, 0x79ff92); + + GL11.glTranslatef(0F, 10F, 0F); + font.drawString(StatCollector.translateToLocal("botaniamisc.lexiconcover1"), 0, 0, 0x79ff92); + + GL11.glTranslatef(0F, 50F, 0F); + font.drawString(StatCollector.translateToLocal("botaniamisc.lexiconcover2"), 0, 0, 0x79ff92); + GL11.glTranslatef(0F, 10F, 0F); + font.drawString(EnumChatFormatting.UNDERLINE + "" + EnumChatFormatting.ITALIC + StatCollector.translateToLocal("botaniamisc.lexiconcover3"), 0, 0, 0x79ff92); + if(bevo || saice) { + GL11.glTranslatef(0F, 10F, 0F); + font.drawString(StatCollector.translateToLocal("botaniamisc.lexiconcover" + (bevo ? 4 : 5)), 0, 0, 0x79ff92); + } + } + + GL11.glPopMatrix(); + } + } diff --git a/src/main/java/vazkii/botania/client/render/item/RenderTransparentItem.java b/src/main/java/vazkii/botania/client/render/item/RenderTransparentItem.java index 875103512f..72b6bc1275 100644 --- a/src/main/java/vazkii/botania/client/render/item/RenderTransparentItem.java +++ b/src/main/java/vazkii/botania/client/render/item/RenderTransparentItem.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Aug 6, 2014, 10:04:57 PM (GMT)] */ package vazkii.botania.client.render.item; @@ -15,63 +15,65 @@ import net.minecraft.item.ItemStack; import net.minecraft.util.IIcon; import net.minecraftforge.client.IItemRenderer; + import org.lwjgl.opengl.GL11; public class RenderTransparentItem implements IItemRenderer { - @Override - public boolean handleRenderType(ItemStack item, ItemRenderType type) { - return type != ItemRenderType.INVENTORY; - } + @Override + public boolean handleRenderType(ItemStack item, ItemRenderType type) { + return type != ItemRenderType.INVENTORY; + } + + @Override + public boolean shouldUseRenderHelper(ItemRenderType type, ItemStack item, ItemRendererHelper helper) { + return helper == ItemRendererHelper.ENTITY_ROTATION || helper == ItemRendererHelper.ENTITY_BOBBING; + } + + @Override + public void renderItem(ItemRenderType type, ItemStack item, Object... data) { + switch(type) { + case ENTITY : { + GL11.glPushMatrix(); + GL11.glTranslatef(-0.5F, 0F, 0F); + if(item.isOnItemFrame()) + GL11.glTranslatef(0F, -0.3F, 0.01F); + render(item); + GL11.glPopMatrix(); + break; + } + case EQUIPPED : { + render(item); + break; + } + case EQUIPPED_FIRST_PERSON : { + render(item); + break; + } + default : break; + } + } - @Override - public boolean shouldUseRenderHelper(ItemRenderType type, ItemStack item, ItemRendererHelper helper) { - return helper == ItemRendererHelper.ENTITY_ROTATION || helper == ItemRendererHelper.ENTITY_BOBBING; - } + public void render(ItemStack item) { + int dmg = item.getItemDamage(); + IIcon icon = item.getItem().getIconFromDamageForRenderPass(dmg, 0); + float f = icon.getMinU(); + float f1 = icon.getMaxU(); + float f2 = icon.getMinV(); + float f3 = icon.getMaxV(); + float scale = 1F / 16F; - @Override - public void renderItem(ItemRenderType type, ItemStack item, Object... data) { - switch (type) { - case ENTITY: { - GL11.glPushMatrix(); - GL11.glTranslatef(-0.5F, 0F, 0F); - if (item.isOnItemFrame()) GL11.glTranslatef(0F, -0.3F, 0.01F); - render(item); - GL11.glPopMatrix(); - break; - } - case EQUIPPED: { - render(item); - break; - } - case EQUIPPED_FIRST_PERSON: { - render(item); - break; - } - default: - break; - } - } + GL11.glPushMatrix(); + GL11.glEnable(GL11.GL_BLEND); + GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); + GL11.glColor4f(1F, 1F, 1F, 1F); + ItemRenderer.renderItemIn2D(Tessellator.instance, f1, f2, f, f3, icon.getIconWidth(), icon.getIconHeight(), scale); - public void render(ItemStack item) { - int dmg = item.getItemDamage(); - IIcon icon = item.getItem().getIconFromDamageForRenderPass(dmg, 0); - float f = icon.getMinU(); - float f1 = icon.getMaxU(); - float f2 = icon.getMinV(); - float f3 = icon.getMaxV(); - float scale = 1F / 16F; + GL11.glDisable(GL11.GL_BLEND); + GL11.glPopMatrix(); - GL11.glPushMatrix(); - GL11.glEnable(GL11.GL_BLEND); - GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); - GL11.glColor4f(1F, 1F, 1F, 1F); - ItemRenderer.renderItemIn2D( - Tessellator.instance, f1, f2, f, f3, icon.getIconWidth(), icon.getIconHeight(), scale); + GL11.glColor4f(1F, 1F, 1F, 1F); + } - GL11.glDisable(GL11.GL_BLEND); - GL11.glPopMatrix(); - GL11.glColor4f(1F, 1F, 1F, 1F); - } } diff --git a/src/main/java/vazkii/botania/client/render/tile/RenderTileAlfPortal.java b/src/main/java/vazkii/botania/client/render/tile/RenderTileAlfPortal.java index 1481895212..65b77c1e1d 100644 --- a/src/main/java/vazkii/botania/client/render/tile/RenderTileAlfPortal.java +++ b/src/main/java/vazkii/botania/client/render/tile/RenderTileAlfPortal.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jun 9, 2014, 9:55:07 PM (GMT)] */ package vazkii.botania.client.render.tile; @@ -16,64 +16,66 @@ import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.IIcon; + import org.lwjgl.opengl.GL11; + import vazkii.botania.client.core.handler.ClientTickHandler; import vazkii.botania.common.block.BlockAlfPortal; import vazkii.botania.common.block.tile.TileAlfPortal; public class RenderTileAlfPortal extends TileEntitySpecialRenderer { - @Override - public void renderTileEntityAt(TileEntity tileentity, double d0, double d1, double d2, float f) { - TileAlfPortal portal = (TileAlfPortal) tileentity; - int meta = portal.getBlockMetadata(); - if (meta == 0) return; + @Override + public void renderTileEntityAt(TileEntity tileentity, double d0, double d1, double d2, float f) { + TileAlfPortal portal = (TileAlfPortal) tileentity; + int meta = portal.getBlockMetadata(); + if(meta == 0) + return; + + GL11.glPushMatrix(); + GL11.glTranslated(d0, d1, d2); + GL11.glTranslatef(-1F, 1F, 0.25F); - GL11.glPushMatrix(); - GL11.glTranslated(d0, d1, d2); - GL11.glTranslatef(-1F, 1F, 0.25F); + GL11.glEnable(GL11.GL_BLEND); + GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); + GL11.glColor4f(1F, 1F, 1F, 1F); + GL11.glDisable(GL11.GL_ALPHA_TEST); + GL11.glEnable(GL11.GL_CULL_FACE); + float alpha = (float) Math.min(1F, (Math.sin((ClientTickHandler.ticksInGame + f) / 8D) + 1D) / 7D + 0.6D) * (Math.min(60, portal.ticksOpen) / 60F) * 0.5F; + GL11.glColor4f(1F, 1F, 1F, alpha); - GL11.glEnable(GL11.GL_BLEND); - GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); - GL11.glColor4f(1F, 1F, 1F, 1F); - GL11.glDisable(GL11.GL_ALPHA_TEST); - GL11.glEnable(GL11.GL_CULL_FACE); - float alpha = (float) Math.min(1F, (Math.sin((ClientTickHandler.ticksInGame + f) / 8D) + 1D) / 7D + 0.6D) - * (Math.min(60, portal.ticksOpen) / 60F) - * 0.5F; - GL11.glColor4f(1F, 1F, 1F, alpha); + Minecraft.getMinecraft().renderEngine.bindTexture(TextureMap.locationBlocksTexture); - Minecraft.getMinecraft().renderEngine.bindTexture(TextureMap.locationBlocksTexture); + if(meta == 2) { + GL11.glTranslatef(1.25F, 0F, 1.75F); + GL11.glRotatef(90F, 0F, 1F, 0F); + } - if (meta == 2) { - GL11.glTranslatef(1.25F, 0F, 1.75F); - GL11.glRotatef(90F, 0F, 1F, 0F); - } + GL11.glDisable(GL11.GL_CULL_FACE); + GL11.glDisable(GL11.GL_LIGHTING); + renderIcon(0, 0, BlockAlfPortal.portalTex, 3, 3, 240); - GL11.glDisable(GL11.GL_CULL_FACE); - GL11.glDisable(GL11.GL_LIGHTING); - renderIcon(0, 0, BlockAlfPortal.portalTex, 3, 3, 240); + GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); + GL11.glTranslated(0F, 0F, 0.5F); + renderIcon(0, 0, BlockAlfPortal.portalTex, 3, 3, 240); - GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); - GL11.glTranslated(0F, 0F, 0.5F); - renderIcon(0, 0, BlockAlfPortal.portalTex, 3, 3, 240); + GL11.glEnable(GL11.GL_CULL_FACE); + GL11.glEnable(GL11.GL_ALPHA_TEST); + GL11.glDisable(GL11.GL_BLEND); + GL11.glEnable(GL11.GL_LIGHTING); + GL11.glColor4f(1F, 1F, 1F, 1F); + GL11.glPopMatrix(); + } - GL11.glEnable(GL11.GL_CULL_FACE); - GL11.glEnable(GL11.GL_ALPHA_TEST); - GL11.glDisable(GL11.GL_BLEND); - GL11.glEnable(GL11.GL_LIGHTING); - GL11.glColor4f(1F, 1F, 1F, 1F); - GL11.glPopMatrix(); - } + public void renderIcon(int par1, int par2, IIcon par3Icon, int par4, int par5, int brightness) { + Tessellator tessellator = Tessellator.instance; + tessellator.startDrawingQuads(); + tessellator.setBrightness(brightness); + tessellator.addVertexWithUV(par1 + 0, par2 + par5, 0, par3Icon.getMinU(), par3Icon.getMaxV()); + tessellator.addVertexWithUV(par1 + par4, par2 + par5, 0, par3Icon.getMaxU(), par3Icon.getMaxV()); + tessellator.addVertexWithUV(par1 + par4, par2 + 0, 0, par3Icon.getMaxU(), par3Icon.getMinV()); + tessellator.addVertexWithUV(par1 + 0, par2 + 0, 0, par3Icon.getMinU(), par3Icon.getMinV()); + tessellator.draw(); + } - public void renderIcon(int par1, int par2, IIcon par3Icon, int par4, int par5, int brightness) { - Tessellator tessellator = Tessellator.instance; - tessellator.startDrawingQuads(); - tessellator.setBrightness(brightness); - tessellator.addVertexWithUV(par1 + 0, par2 + par5, 0, par3Icon.getMinU(), par3Icon.getMaxV()); - tessellator.addVertexWithUV(par1 + par4, par2 + par5, 0, par3Icon.getMaxU(), par3Icon.getMaxV()); - tessellator.addVertexWithUV(par1 + par4, par2 + 0, 0, par3Icon.getMaxU(), par3Icon.getMinV()); - tessellator.addVertexWithUV(par1 + 0, par2 + 0, 0, par3Icon.getMinU(), par3Icon.getMinV()); - tessellator.draw(); - } } diff --git a/src/main/java/vazkii/botania/client/render/tile/RenderTileAltar.java b/src/main/java/vazkii/botania/client/render/tile/RenderTileAltar.java index 1be031b19b..3ce7df9a0b 100644 --- a/src/main/java/vazkii/botania/client/render/tile/RenderTileAltar.java +++ b/src/main/java/vazkii/botania/client/render/tile/RenderTileAltar.java @@ -2,15 +2,16 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jan 21, 2014, 7:55:47 PM (GMT)] */ package vazkii.botania.client.render.tile; import java.awt.Color; + import net.minecraft.block.Block; import net.minecraft.client.Minecraft; import net.minecraft.client.renderer.ItemRenderer; @@ -25,8 +26,10 @@ import net.minecraft.tileentity.TileEntity; import net.minecraft.util.IIcon; import net.minecraft.util.ResourceLocation; + import org.lwjgl.opengl.GL11; import org.lwjgl.opengl.GL12; + import vazkii.botania.client.core.handler.ClientTickHandler; import vazkii.botania.client.lib.LibResources; import vazkii.botania.client.model.ModelAltar; @@ -34,176 +37,159 @@ public class RenderTileAltar extends TileEntitySpecialRenderer { - private static final ResourceLocation[] textures = new ResourceLocation[] { - new ResourceLocation(LibResources.MODEL_ALTAR), - new ResourceLocation(String.format(LibResources.MODEL_ALTAR_META, 0)), - new ResourceLocation(String.format(LibResources.MODEL_ALTAR_META, 1)), - new ResourceLocation(String.format(LibResources.MODEL_ALTAR_META, 2)), - new ResourceLocation(String.format(LibResources.MODEL_ALTAR_META, 3)), - new ResourceLocation(String.format(LibResources.MODEL_ALTAR_META, 4)), - new ResourceLocation(String.format(LibResources.MODEL_ALTAR_META, 5)), - new ResourceLocation(String.format(LibResources.MODEL_ALTAR_META, 6)), - new ResourceLocation(String.format(LibResources.MODEL_ALTAR_META, 7)) - }; - - private static final ResourceLocation textureMossy = new ResourceLocation(LibResources.MODEL_ALTAR_MOSSY); - - ModelAltar model = new ModelAltar(); - RenderItem renderItem = new RenderItem(); - RenderBlocks renderBlocks = new RenderBlocks(); - public static int forceMeta = -1; - - @Override - public void renderTileEntityAt(TileEntity tileentity, double d0, double d1, double d2, float pticks) { - TileAltar altar = (TileAltar) tileentity; - - GL11.glPushMatrix(); - GL11.glEnable(GL12.GL_RESCALE_NORMAL); - GL11.glColor4f(1F, 1F, 1F, 1F); - Minecraft.getMinecraft() - .renderEngine - .bindTexture( - altar.isMossy - ? textureMossy - : textures[ - Math.min( - textures.length - 1, - forceMeta == -1 ? tileentity.getBlockMetadata() : forceMeta)]); - - GL11.glTranslated(d0 + 0.5, d1 + 1.5, d2 + 0.5); - GL11.glScalef(1F, -1F, -1F); - model.render(); - GL11.glScalef(1F, -1F, -1F); - GL11.glEnable(GL12.GL_RESCALE_NORMAL); - - boolean water = altar.hasWater(); - boolean lava = altar.hasLava(); - if (water || lava) { - GL11.glPushMatrix(); - float s = 1F / 256F * 10F; - float v = 1F / 8F; - float w = -v * 2.5F; - - if (water) { - int petals = 0; - for (int i = 0; i < altar.getSizeInventory(); i++) - if (altar.getStackInSlot(i) != null) petals++; - else break; - - if (petals > 0) { - Minecraft minecraft = Minecraft.getMinecraft(); - final float modifier = 6F; - final float rotationModifier = 0.25F; - final float radiusBase = 1.2F; - final float radiusMod = 0.1F; - - double ticks = (ClientTickHandler.ticksInGame + pticks) * 0.5; - float offsetPerPetal = 360 / petals; - - GL11.glPushMatrix(); - GL11.glTranslatef(-0.05F, -0.5F, 0F); - GL11.glScalef(v, v, v); - for (int i = 0; i < petals; i++) { - float offset = offsetPerPetal * i; - float deg = (int) (ticks / rotationModifier % 360F + offset); - float rad = deg * (float) Math.PI / 180F; - float radiusX = (float) (radiusBase + radiusMod * Math.sin(ticks / modifier)); - float radiusZ = (float) (radiusBase + radiusMod * Math.cos(ticks / modifier)); - float x = (float) (radiusX * Math.cos(rad)); - float z = (float) (radiusZ * Math.sin(rad)); - float y = (float) Math.cos((ticks + 50 * i) / 5F) / 10F; - - GL11.glPushMatrix(); - GL11.glTranslatef(x, y, z); - float xRotate = (float) Math.sin(ticks * rotationModifier) / 2F; - float yRotate = (float) Math.max(0.6F, Math.sin(ticks * 0.1F) / 2F + 0.5F); - float zRotate = (float) Math.cos(ticks * rotationModifier) / 2F; - - v /= 2F; - GL11.glTranslatef(v, v, v); - GL11.glRotatef(deg, xRotate, yRotate, zRotate); - GL11.glTranslatef(-v, -v, -v); - v *= 2F; - - GL11.glColor4f(1F, 1F, 1F, 1F); - - ItemStack stack = altar.getStackInSlot(i); - minecraft.renderEngine.bindTexture( - stack.getItem() instanceof ItemBlock - ? TextureMap.locationBlocksTexture - : TextureMap.locationItemsTexture); - - if (stack.getItem() instanceof ItemBlock - && RenderBlocks.renderItemIn3d( - Block.getBlockFromItem(stack.getItem()).getRenderType())) { - GL11.glScalef(0.5F, 0.5F, 0.5F); - GL11.glTranslatef(1F, 1.1F, 0F); - renderBlocks.renderBlockAsItem( - Block.getBlockFromItem(stack.getItem()), stack.getItemDamage(), 1F); - GL11.glTranslatef(-1F, -1.1F, 0F); - GL11.glScalef(2F, 2F, 2F); - } else { - IIcon icon = stack.getItem().getIcon(stack, 0); - if (icon != null) { - Color color = new Color(stack.getItem().getColorFromItemStack(stack, 0)); - GL11.glColor3ub((byte) color.getRed(), (byte) color.getGreen(), (byte) color.getBlue()); - float f = icon.getMinU(); - float f1 = icon.getMaxU(); - float f2 = icon.getMinV(); - float f3 = icon.getMaxV(); - ItemRenderer.renderItemIn2D( - Tessellator.instance, - f1, - f2, - f, - f3, - icon.getIconWidth(), - icon.getIconHeight(), - 1F / 16F); - GL11.glColor3f(1F, 1F, 1F); - } - } - - GL11.glPopMatrix(); - } - - GL11.glPopMatrix(); - } - } - - Minecraft.getMinecraft().renderEngine.bindTexture(TextureMap.locationBlocksTexture); - Block block = lava ? Blocks.lava : Blocks.water; - int brightness = lava ? 240 : -1; - float alpha = lava ? 1F : 0.7F; - - GL11.glEnable(GL11.GL_BLEND); - GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); - GL11.glDisable(GL11.GL_ALPHA_TEST); - if (lava) GL11.glDisable(GL11.GL_LIGHTING); - GL11.glColor4f(1F, 1F, 1F, alpha); - GL11.glTranslatef(w, -0.3F, w); - GL11.glRotatef(90F, 1F, 0F, 0F); - GL11.glScalef(s, s, s); - - renderIcon(0, 0, block.getIcon(0, 0), 16, 16, brightness); - if (lava) GL11.glEnable(GL11.GL_LIGHTING); - GL11.glEnable(GL11.GL_ALPHA_TEST); - GL11.glDisable(GL11.GL_BLEND); - GL11.glPopMatrix(); - } - GL11.glPopMatrix(); - - forceMeta = -1; - } - - public void renderIcon(int par1, int par2, IIcon par3Icon, int par4, int par5, int brightness) { - Tessellator tessellator = Tessellator.instance; - tessellator.startDrawingQuads(); - if (brightness != -1) tessellator.setBrightness(brightness); - tessellator.addVertexWithUV(par1 + 0, par2 + par5, 0, par3Icon.getMinU(), par3Icon.getMaxV()); - tessellator.addVertexWithUV(par1 + par4, par2 + par5, 0, par3Icon.getMaxU(), par3Icon.getMaxV()); - tessellator.addVertexWithUV(par1 + par4, par2 + 0, 0, par3Icon.getMaxU(), par3Icon.getMinV()); - tessellator.addVertexWithUV(par1 + 0, par2 + 0, 0, par3Icon.getMinU(), par3Icon.getMinV()); - tessellator.draw(); - } + private static final ResourceLocation[] textures = new ResourceLocation[] { + new ResourceLocation(LibResources.MODEL_ALTAR), + new ResourceLocation(String.format(LibResources.MODEL_ALTAR_META, 0)), + new ResourceLocation(String.format(LibResources.MODEL_ALTAR_META, 1)), + new ResourceLocation(String.format(LibResources.MODEL_ALTAR_META, 2)), + new ResourceLocation(String.format(LibResources.MODEL_ALTAR_META, 3)), + new ResourceLocation(String.format(LibResources.MODEL_ALTAR_META, 4)), + new ResourceLocation(String.format(LibResources.MODEL_ALTAR_META, 5)), + new ResourceLocation(String.format(LibResources.MODEL_ALTAR_META, 6)), + new ResourceLocation(String.format(LibResources.MODEL_ALTAR_META, 7)) + }; + + private static final ResourceLocation textureMossy = new ResourceLocation(LibResources.MODEL_ALTAR_MOSSY); + + ModelAltar model = new ModelAltar(); + RenderItem renderItem = new RenderItem(); + RenderBlocks renderBlocks = new RenderBlocks(); + public static int forceMeta = -1; + + @Override + public void renderTileEntityAt(TileEntity tileentity, double d0, double d1, double d2, float pticks) { + TileAltar altar = (TileAltar) tileentity; + + GL11.glPushMatrix(); + GL11.glEnable(GL12.GL_RESCALE_NORMAL); + GL11.glColor4f(1F, 1F, 1F, 1F); + Minecraft.getMinecraft().renderEngine.bindTexture(altar.isMossy ? textureMossy : textures[Math.min(textures.length - 1, forceMeta == -1 ? tileentity.getBlockMetadata() : forceMeta)]); + + GL11.glTranslated(d0 + 0.5, d1 + 1.5, d2 + 0.5); + GL11.glScalef(1F, -1F, -1F); + model.render(); + GL11.glScalef(1F, -1F, -1F); + GL11.glEnable(GL12.GL_RESCALE_NORMAL); + + boolean water = altar.hasWater(); + boolean lava = altar.hasLava(); + if(water || lava) { + GL11.glPushMatrix(); + float s = 1F / 256F * 10F; + float v = 1F / 8F; + float w = -v * 2.5F; + + if(water) { + int petals = 0; + for(int i = 0; i < altar.getSizeInventory(); i++) + if(altar.getStackInSlot(i) != null) + petals++; + else break; + + if(petals > 0) { + Minecraft minecraft = Minecraft.getMinecraft(); + final float modifier = 6F; + final float rotationModifier = 0.25F; + final float radiusBase = 1.2F; + final float radiusMod = 0.1F; + + double ticks = (ClientTickHandler.ticksInGame + pticks) * 0.5; + float offsetPerPetal = 360 / petals; + + GL11.glPushMatrix(); + GL11.glTranslatef(-0.05F, -0.5F, 0F); + GL11.glScalef(v, v, v); + for(int i = 0; i < petals; i++) { + float offset = offsetPerPetal * i; + float deg = (int) (ticks / rotationModifier % 360F + offset); + float rad = deg * (float) Math.PI / 180F; + float radiusX = (float) (radiusBase + radiusMod * Math.sin(ticks / modifier)); + float radiusZ = (float) (radiusBase + radiusMod * Math.cos(ticks / modifier)); + float x = (float) (radiusX * Math.cos(rad)); + float z = (float) (radiusZ * Math.sin(rad)); + float y = (float) Math.cos((ticks + 50 * i) / 5F) / 10F; + + GL11.glPushMatrix(); + GL11.glTranslatef(x, y, z); + float xRotate = (float) Math.sin(ticks * rotationModifier) / 2F; + float yRotate = (float) Math.max(0.6F, Math.sin(ticks * 0.1F) / 2F + 0.5F); + float zRotate = (float) Math.cos(ticks * rotationModifier) / 2F; + + v /= 2F; + GL11.glTranslatef(v, v, v); + GL11.glRotatef(deg, xRotate, yRotate, zRotate); + GL11.glTranslatef(-v, -v, -v); + v *= 2F; + + GL11.glColor4f(1F, 1F, 1F, 1F); + + ItemStack stack = altar.getStackInSlot(i); + minecraft.renderEngine.bindTexture(stack.getItem() instanceof ItemBlock ? TextureMap.locationBlocksTexture : TextureMap.locationItemsTexture); + + if(stack.getItem() instanceof ItemBlock && RenderBlocks.renderItemIn3d(Block.getBlockFromItem(stack.getItem()).getRenderType())) { + GL11.glScalef(0.5F, 0.5F, 0.5F); + GL11.glTranslatef(1F, 1.1F, 0F); + renderBlocks.renderBlockAsItem(Block.getBlockFromItem(stack.getItem()), stack.getItemDamage(), 1F); + GL11.glTranslatef(-1F, -1.1F, 0F); + GL11.glScalef(2F, 2F, 2F); + } else { + IIcon icon = stack.getItem().getIcon(stack, 0); + if (icon != null) { + Color color = new Color(stack.getItem().getColorFromItemStack(stack, 0)); + GL11.glColor3ub((byte) color.getRed(), (byte) color.getGreen(), (byte) color.getBlue()); + float f = icon.getMinU(); + float f1 = icon.getMaxU(); + float f2 = icon.getMinV(); + float f3 = icon.getMaxV(); + ItemRenderer.renderItemIn2D(Tessellator.instance, f1, f2, f, f3, icon.getIconWidth(), icon.getIconHeight(), 1F / 16F); + GL11.glColor3f(1F, 1F, 1F); + } + } + + GL11.glPopMatrix(); + } + + GL11.glPopMatrix(); + } + } + + Minecraft.getMinecraft().renderEngine.bindTexture(TextureMap.locationBlocksTexture); + Block block = lava ? Blocks.lava : Blocks.water; + int brightness = lava ? 240 : -1; + float alpha = lava ? 1F : 0.7F; + + GL11.glEnable(GL11.GL_BLEND); + GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); + GL11.glDisable(GL11.GL_ALPHA_TEST); + if(lava) + GL11.glDisable(GL11.GL_LIGHTING); + GL11.glColor4f(1F, 1F, 1F, alpha); + GL11.glTranslatef(w, -0.3F, w); + GL11.glRotatef(90F, 1F, 0F, 0F); + GL11.glScalef(s, s, s); + + renderIcon(0, 0, block.getIcon(0, 0), 16, 16, brightness); + if(lava) + GL11.glEnable(GL11.GL_LIGHTING); + GL11.glEnable(GL11.GL_ALPHA_TEST); + GL11.glDisable(GL11.GL_BLEND); + GL11.glPopMatrix(); + } + GL11.glPopMatrix(); + + forceMeta = -1; + } + + public void renderIcon(int par1, int par2, IIcon par3Icon, int par4, int par5, int brightness) { + Tessellator tessellator = Tessellator.instance; + tessellator.startDrawingQuads(); + if(brightness != -1) + tessellator.setBrightness(brightness); + tessellator.addVertexWithUV(par1 + 0, par2 + par5, 0, par3Icon.getMinU(), par3Icon.getMaxV()); + tessellator.addVertexWithUV(par1 + par4, par2 + par5, 0, par3Icon.getMaxU(), par3Icon.getMaxV()); + tessellator.addVertexWithUV(par1 + par4, par2 + 0, 0, par3Icon.getMaxU(), par3Icon.getMinV()); + tessellator.addVertexWithUV(par1 + 0, par2 + 0, 0, par3Icon.getMinU(), par3Icon.getMinV()); + tessellator.draw(); + } + } diff --git a/src/main/java/vazkii/botania/client/render/tile/RenderTileAvatar.java b/src/main/java/vazkii/botania/client/render/tile/RenderTileAvatar.java index fe039c15f9..03dd328c68 100644 --- a/src/main/java/vazkii/botania/client/render/tile/RenderTileAvatar.java +++ b/src/main/java/vazkii/botania/client/render/tile/RenderTileAvatar.java @@ -2,15 +2,16 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Oct 24, 2015, 3:51:35 PM (GMT)] */ package vazkii.botania.client.render.tile; import java.awt.Color; + import net.minecraft.client.Minecraft; import net.minecraft.client.renderer.ItemRenderer; import net.minecraft.client.renderer.OpenGlHelper; @@ -21,8 +22,10 @@ import net.minecraft.tileentity.TileEntity; import net.minecraft.util.IIcon; import net.minecraft.util.ResourceLocation; + import org.lwjgl.opengl.GL11; import org.lwjgl.opengl.GL12; + import vazkii.botania.api.item.IAvatarWieldable; import vazkii.botania.client.core.handler.ClientTickHandler; import vazkii.botania.client.lib.LibResources; @@ -31,78 +34,80 @@ public class RenderTileAvatar extends TileEntitySpecialRenderer { - private static final float[] ROTATIONS = new float[] {180F, 0F, 90F, 270F}; - - private static final ResourceLocation texture = new ResourceLocation(LibResources.MODEL_AVATAR); - private static final ModelAvatar model = new ModelAvatar(); - - @Override - public void renderTileEntityAt(TileEntity tileentity, double d0, double d1, double d2, float pticks) { - TileAvatar avatar = (TileAvatar) tileentity; - - GL11.glPushMatrix(); - GL11.glEnable(GL12.GL_RESCALE_NORMAL); - GL11.glColor4f(1F, 1F, 1F, 1F); - GL11.glTranslated(d0, d1, d2); - - Minecraft.getMinecraft().renderEngine.bindTexture(texture); - int meta = avatar.getWorldObj() != null ? avatar.getBlockMetadata() : 0; - - GL11.glTranslatef(0.5F, 1.6F, 0.5F); - GL11.glScalef(1F, -1F, -1F); - GL11.glRotatef(ROTATIONS[Math.max(Math.min(ROTATIONS.length - 1, meta - 2), 0)], 0F, 1F, 0F); - model.render(); - - ItemStack stack = avatar.getStackInSlot(0); - if (stack != null) { - GL11.glPushMatrix(); - Minecraft.getMinecraft().renderEngine.bindTexture(TextureMap.locationItemsTexture); - float s = 0.4F; - GL11.glScalef(s, s, s); - GL11.glRotatef(90F, 0F, 1F, 0F); - GL11.glRotatef(180F, 0F, 0F, 1F); - GL11.glTranslated(-1.2F, -3.5F, -0.65F); - GL11.glRotatef(20F, 0F, 0F, 1F); - - int renderPass = 0; - do { - IIcon icon = stack.getItem().getIcon(stack, renderPass); - if (icon != null) { - Color color = new Color(stack.getItem().getColorFromItemStack(stack, renderPass)); - GL11.glColor3ub((byte) color.getRed(), (byte) color.getGreen(), (byte) color.getBlue()); - float f = icon.getMinU(); - float f1 = icon.getMaxU(); - float f2 = icon.getMinV(); - float f3 = icon.getMaxV(); - ItemRenderer.renderItemIn2D( - Tessellator.instance, f1, f2, f, f3, icon.getIconWidth(), icon.getIconHeight(), 1F / 16F); - GL11.glColor3f(1F, 1F, 1F); - } - renderPass++; - } while (renderPass < stack.getItem().getRenderPasses(stack.getItemDamage())); - GL11.glPopMatrix(); - - IAvatarWieldable wieldable = (IAvatarWieldable) stack.getItem(); - Minecraft.getMinecraft().renderEngine.bindTexture(wieldable.getOverlayResource(avatar, stack)); - s = 1.01F; - - GL11.glPushMatrix(); - GL11.glEnable(GL11.GL_BLEND); - GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); - GL11.glScalef(s, s, s); - GL11.glTranslatef(0F, -0.01F, 0F); - int light = 15728880; - int lightmapX = light % 65536; - int lightmapY = light / 65536; - OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, lightmapX, lightmapY); - float alpha = (float) Math.sin(ClientTickHandler.ticksInGame / 20D) / 2F + 0.5F; - GL11.glColor4f(1F, 1F, 1F, alpha + 0.183F); - model.render(); - GL11.glPopMatrix(); - } - GL11.glColor3f(1F, 1F, 1F); - GL11.glScalef(1F, -1F, -1F); - GL11.glEnable(GL12.GL_RESCALE_NORMAL); - GL11.glPopMatrix(); - } + private static final float[] ROTATIONS = new float[] { + 180F, 0F, 90F, 270F + }; + + private static final ResourceLocation texture = new ResourceLocation(LibResources.MODEL_AVATAR); + private static final ModelAvatar model = new ModelAvatar(); + + @Override + public void renderTileEntityAt(TileEntity tileentity, double d0, double d1, double d2, float pticks) { + TileAvatar avatar = (TileAvatar) tileentity; + + GL11.glPushMatrix(); + GL11.glEnable(GL12.GL_RESCALE_NORMAL); + GL11.glColor4f(1F, 1F, 1F, 1F); + GL11.glTranslated(d0, d1, d2); + + Minecraft.getMinecraft().renderEngine.bindTexture(texture); + int meta = avatar.getWorldObj() != null ? avatar.getBlockMetadata() : 0; + + GL11.glTranslatef(0.5F, 1.6F, 0.5F); + GL11.glScalef(1F, -1F, -1F); + GL11.glRotatef(ROTATIONS[Math.max(Math.min(ROTATIONS.length - 1, meta - 2), 0)], 0F, 1F, 0F); + model.render(); + + ItemStack stack = avatar.getStackInSlot(0); + if(stack != null) { + GL11.glPushMatrix(); + Minecraft.getMinecraft().renderEngine.bindTexture(TextureMap.locationItemsTexture); + float s = 0.4F; + GL11.glScalef(s, s, s); + GL11.glRotatef(90F, 0F, 1F, 0F); + GL11.glRotatef(180F, 0F, 0F, 1F); + GL11.glTranslated(-1.2F, -3.5F, -0.65F); + GL11.glRotatef(20F, 0F, 0F, 1F); + + int renderPass = 0; + do { + IIcon icon = stack.getItem().getIcon(stack, renderPass); + if(icon != null) { + Color color = new Color(stack.getItem().getColorFromItemStack(stack, renderPass)); + GL11.glColor3ub((byte) color.getRed(), (byte) color.getGreen(), (byte) color.getBlue()); + float f = icon.getMinU(); + float f1 = icon.getMaxU(); + float f2 = icon.getMinV(); + float f3 = icon.getMaxV(); + ItemRenderer.renderItemIn2D(Tessellator.instance, f1, f2, f, f3, icon.getIconWidth(), icon.getIconHeight(), 1F / 16F); + GL11.glColor3f(1F, 1F, 1F); + } + renderPass++; + } while(renderPass < stack.getItem().getRenderPasses(stack.getItemDamage())); + GL11.glPopMatrix(); + + IAvatarWieldable wieldable = (IAvatarWieldable) stack.getItem(); + Minecraft.getMinecraft().renderEngine.bindTexture(wieldable.getOverlayResource(avatar, stack)); + s = 1.01F; + + GL11.glPushMatrix(); + GL11.glEnable(GL11.GL_BLEND); + GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); + GL11.glScalef(s, s, s); + GL11.glTranslatef(0F, -0.01F, 0F); + int light = 15728880; + int lightmapX = light % 65536; + int lightmapY = light / 65536; + OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, lightmapX, lightmapY); + float alpha = (float) Math.sin(ClientTickHandler.ticksInGame / 20D) / 2F + 0.5F; + GL11.glColor4f(1F, 1F, 1F, alpha + 0.183F); + model.render(); + GL11.glPopMatrix(); + } + GL11.glColor3f(1F, 1F, 1F); + GL11.glScalef(1F, -1F, -1F); + GL11.glEnable(GL12.GL_RESCALE_NORMAL); + GL11.glPopMatrix(); + } + } diff --git a/src/main/java/vazkii/botania/client/render/tile/RenderTileBellows.java b/src/main/java/vazkii/botania/client/render/tile/RenderTileBellows.java index 7ec5f51e5e..77cd868061 100644 --- a/src/main/java/vazkii/botania/client/render/tile/RenderTileBellows.java +++ b/src/main/java/vazkii/botania/client/render/tile/RenderTileBellows.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Aug 28, 2015, 5:30:41 PM (GMT)] */ package vazkii.botania.client.render.tile; @@ -14,38 +14,43 @@ import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.ResourceLocation; + import org.lwjgl.opengl.GL11; import org.lwjgl.opengl.GL12; + import vazkii.botania.client.lib.LibResources; import vazkii.botania.client.model.ModelBellows; import vazkii.botania.common.block.tile.mana.TileBellows; public class RenderTileBellows extends TileEntitySpecialRenderer { - private static final float[] ROTATIONS = new float[] {180F, 0F, 90F, 270F}; + private static final float[] ROTATIONS = new float[] { + 180F, 0F, 90F, 270F + }; + + private static final ResourceLocation texture = new ResourceLocation(LibResources.MODEL_BELLOWS); + private static final ModelBellows model = new ModelBellows(); - private static final ResourceLocation texture = new ResourceLocation(LibResources.MODEL_BELLOWS); - private static final ModelBellows model = new ModelBellows(); + @Override + public void renderTileEntityAt(TileEntity tileentity, double d0, double d1, double d2, float f) { + TileBellows bellows = (TileBellows) tileentity; - @Override - public void renderTileEntityAt(TileEntity tileentity, double d0, double d1, double d2, float f) { - TileBellows bellows = (TileBellows) tileentity; + GL11.glPushMatrix(); + GL11.glEnable(GL12.GL_RESCALE_NORMAL); + GL11.glColor4f(1F, 1F, 1F, 1F); + GL11.glTranslated(d0, d1, d2); - GL11.glPushMatrix(); - GL11.glEnable(GL12.GL_RESCALE_NORMAL); - GL11.glColor4f(1F, 1F, 1F, 1F); - GL11.glTranslated(d0, d1, d2); + Minecraft.getMinecraft().renderEngine.bindTexture(texture); + int meta = bellows.getWorldObj() != null ? bellows.getBlockMetadata() : 0; - Minecraft.getMinecraft().renderEngine.bindTexture(texture); - int meta = bellows.getWorldObj() != null ? bellows.getBlockMetadata() : 0; + GL11.glTranslatef(0.5F, 1.5F, 0.5F); + GL11.glScalef(1F, -1F, -1F); + GL11.glRotatef(ROTATIONS[Math.max(Math.min(ROTATIONS.length, meta - 2), 0)], 0F, 1F, 0F); + model.render(Math.max(0.1F, 1F - (bellows.movePos + bellows.moving * f + 0.1F))); + GL11.glColor3f(1F, 1F, 1F); + GL11.glScalef(1F, -1F, -1F); + GL11.glEnable(GL12.GL_RESCALE_NORMAL); + GL11.glPopMatrix(); + } - GL11.glTranslatef(0.5F, 1.5F, 0.5F); - GL11.glScalef(1F, -1F, -1F); - GL11.glRotatef(ROTATIONS[Math.max(Math.min(ROTATIONS.length, meta - 2), 0)], 0F, 1F, 0F); - model.render(Math.max(0.1F, 1F - (bellows.movePos + bellows.moving * f + 0.1F))); - GL11.glColor3f(1F, 1F, 1F); - GL11.glScalef(1F, -1F, -1F); - GL11.glEnable(GL12.GL_RESCALE_NORMAL); - GL11.glPopMatrix(); - } } diff --git a/src/main/java/vazkii/botania/client/render/tile/RenderTileBrewery.java b/src/main/java/vazkii/botania/client/render/tile/RenderTileBrewery.java index b4b3d14e04..d649d0edc8 100644 --- a/src/main/java/vazkii/botania/client/render/tile/RenderTileBrewery.java +++ b/src/main/java/vazkii/botania/client/render/tile/RenderTileBrewery.java @@ -2,15 +2,16 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Oct 31, 2014, 4:53:15 PM (GMT)] */ package vazkii.botania.client.render.tile; import java.awt.Color; + import net.minecraft.block.Block; import net.minecraft.client.Minecraft; import net.minecraft.client.renderer.ItemRenderer; @@ -25,8 +26,10 @@ import net.minecraft.util.IIcon; import net.minecraft.util.ResourceLocation; import net.minecraftforge.client.ForgeHooksClient; + import org.lwjgl.opengl.GL11; import org.lwjgl.opengl.GL12; + import vazkii.botania.client.core.handler.ClientTickHandler; import vazkii.botania.client.lib.LibResources; import vazkii.botania.client.model.ModelBrewery; @@ -34,93 +37,73 @@ public class RenderTileBrewery extends TileEntitySpecialRenderer { - private static final ResourceLocation texture = new ResourceLocation(LibResources.MODEL_BREWERY); - ModelBrewery model = new ModelBrewery(); - public TileBrewery brewery; - public static boolean rotate = true; + private static final ResourceLocation texture = new ResourceLocation(LibResources.MODEL_BREWERY); + ModelBrewery model = new ModelBrewery(); + public TileBrewery brewery; + public static boolean rotate = true; + + @Override + public void renderTileEntityAt(TileEntity tileentity, double d0, double d1, double d2, float f) { + brewery = (TileBrewery) tileentity; + GL11.glPushMatrix(); + GL11.glEnable(GL12.GL_RESCALE_NORMAL); + GL11.glColor4f(1F, 1F, 1F, 1F); + GL11.glTranslated(d0, d1, d2); - @Override - public void renderTileEntityAt(TileEntity tileentity, double d0, double d1, double d2, float f) { - brewery = (TileBrewery) tileentity; - GL11.glPushMatrix(); - GL11.glEnable(GL12.GL_RESCALE_NORMAL); - GL11.glColor4f(1F, 1F, 1F, 1F); - GL11.glTranslated(d0, d1, d2); + Minecraft.getMinecraft().renderEngine.bindTexture(texture); + GL11.glScalef(1F, -1F, -1F); + GL11.glTranslatef(0.5F, -1.5F, -0.5F); - Minecraft.getMinecraft().renderEngine.bindTexture(texture); - GL11.glScalef(1F, -1F, -1F); - GL11.glTranslatef(0.5F, -1.5F, -0.5F); + double time = ClientTickHandler.ticksInGame + f; + if(!rotate) + time = -1; - double time = ClientTickHandler.ticksInGame + f; - if (!rotate) time = -1; + model.render(this, time); + GL11.glEnable(GL12.GL_RESCALE_NORMAL); + GL11.glPopMatrix(); + } - model.render(this, time); - GL11.glEnable(GL12.GL_RESCALE_NORMAL); - GL11.glPopMatrix(); - } + public void renderItemStack(ItemStack stack) { + if(stack != null) { + Minecraft mc = Minecraft.getMinecraft(); + mc.renderEngine.bindTexture(stack.getItem() instanceof ItemBlock ? TextureMap.locationBlocksTexture : TextureMap.locationItemsTexture); - public void renderItemStack(ItemStack stack) { - if (stack != null) { - Minecraft mc = Minecraft.getMinecraft(); - mc.renderEngine.bindTexture( - stack.getItem() instanceof ItemBlock - ? TextureMap.locationBlocksTexture - : TextureMap.locationItemsTexture); + float s = 0.25F; + GL11.glScalef(s, s, s); + GL11.glScalef(2F, 2F, 2F); + if(!ForgeHooksClient.renderEntityItem(new EntityItem(brewery.getWorldObj(), brewery.xCoord, brewery.yCoord, brewery.zCoord, stack), stack, 0F, 0F, brewery.getWorldObj().rand, mc.renderEngine, RenderBlocks.getInstance(), 1)) { + GL11.glScalef(0.5F, 0.5F, 0.5F); + if(stack.getItem() instanceof ItemBlock && RenderBlocks.renderItemIn3d(Block.getBlockFromItem(stack.getItem()).getRenderType())) { + GL11.glScalef(0.5F, 0.5F, 0.5F); + GL11.glTranslatef(1F, 1.1F, 0F); + GL11.glPushMatrix(); + RenderBlocks.getInstance().renderBlockAsItem(Block.getBlockFromItem(stack.getItem()), stack.getItemDamage(), 1F); + GL11.glPopMatrix(); + GL11.glTranslatef(-1F, -1.1F, 0F); + GL11.glScalef(2F, 2F, 2F); + } else { + int renderPass = 0; + do { + IIcon icon = stack.getItem().getIcon(stack, renderPass); + if(icon != null) { + Color color = new Color(stack.getItem().getColorFromItemStack(stack, renderPass)); + GL11.glColor3ub((byte) color.getRed(), (byte) color.getGreen(), (byte) color.getBlue()); + float f = icon.getMinU(); + float f1 = icon.getMaxU(); + float f2 = icon.getMinV(); + float f3 = icon.getMaxV(); - float s = 0.25F; - GL11.glScalef(s, s, s); - GL11.glScalef(2F, 2F, 2F); - if (!ForgeHooksClient.renderEntityItem( - new EntityItem(brewery.getWorldObj(), brewery.xCoord, brewery.yCoord, brewery.zCoord, stack), - stack, - 0F, - 0F, - brewery.getWorldObj().rand, - mc.renderEngine, - RenderBlocks.getInstance(), - 1)) { - GL11.glScalef(0.5F, 0.5F, 0.5F); - if (stack.getItem() instanceof ItemBlock - && RenderBlocks.renderItemIn3d( - Block.getBlockFromItem(stack.getItem()).getRenderType())) { - GL11.glScalef(0.5F, 0.5F, 0.5F); - GL11.glTranslatef(1F, 1.1F, 0F); - GL11.glPushMatrix(); - RenderBlocks.getInstance() - .renderBlockAsItem(Block.getBlockFromItem(stack.getItem()), stack.getItemDamage(), 1F); - GL11.glPopMatrix(); - GL11.glTranslatef(-1F, -1.1F, 0F); - GL11.glScalef(2F, 2F, 2F); - } else { - int renderPass = 0; - do { - IIcon icon = stack.getItem().getIcon(stack, renderPass); - if (icon != null) { - Color color = new Color(stack.getItem().getColorFromItemStack(stack, renderPass)); - GL11.glColor3ub((byte) color.getRed(), (byte) color.getGreen(), (byte) color.getBlue()); - float f = icon.getMinU(); - float f1 = icon.getMaxU(); - float f2 = icon.getMinV(); - float f3 = icon.getMaxV(); + ItemRenderer.renderItemIn2D(Tessellator.instance, f1, f2, f, f3, icon.getIconWidth(), icon.getIconHeight(), 1F / 16F); + GL11.glColor3f(1F, 1F, 1F); + } + renderPass++; + } while(renderPass < stack.getItem().getRenderPasses(stack.getItemDamage())); + } + } + GL11.glScalef(1F / s, 1F / s, 1F / s); - ItemRenderer.renderItemIn2D( - Tessellator.instance, - f1, - f2, - f, - f3, - icon.getIconWidth(), - icon.getIconHeight(), - 1F / 16F); - GL11.glColor3f(1F, 1F, 1F); - } - renderPass++; - } while (renderPass < stack.getItem().getRenderPasses(stack.getItemDamage())); - } - } - GL11.glScalef(1F / s, 1F / s, 1F / s); + Minecraft.getMinecraft().renderEngine.bindTexture(texture); + } + } - Minecraft.getMinecraft().renderEngine.bindTexture(texture); - } - } } diff --git a/src/main/java/vazkii/botania/client/render/tile/RenderTileCocoon.java b/src/main/java/vazkii/botania/client/render/tile/RenderTileCocoon.java index 4ff0c37c12..ff7b4679bf 100644 --- a/src/main/java/vazkii/botania/client/render/tile/RenderTileCocoon.java +++ b/src/main/java/vazkii/botania/client/render/tile/RenderTileCocoon.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jul 8, 2015, 4:44:23 PM (GMT)] */ package vazkii.botania.client.render.tile; @@ -14,42 +14,44 @@ import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.ResourceLocation; + import org.lwjgl.opengl.GL11; import org.lwjgl.opengl.GL12; + import vazkii.botania.client.lib.LibResources; import vazkii.botania.client.model.ModelCocoon; import vazkii.botania.common.block.tile.TileCocoon; public class RenderTileCocoon extends TileEntitySpecialRenderer { - private static final ResourceLocation texture = new ResourceLocation(LibResources.MODEL_COCOON); - ModelCocoon model = new ModelCocoon(); - - @Override - public void renderTileEntityAt(TileEntity tileentity, double d0, double d1, double d2, float f) { - TileCocoon cocoon = (TileCocoon) tileentity; - - float rot = 0F; - float modval = 60F - (float) cocoon.timePassed / (float) TileCocoon.TOTAL_TIME * 30F; - if (cocoon.timePassed % modval < 10) { - float mod = (cocoon.timePassed + f) % modval; - float v = mod / 5 * (float) Math.PI * 2; - rot = (float) Math.sin(v) * (float) Math.log(cocoon.timePassed + f); - } - - GL11.glPushMatrix(); - GL11.glEnable(GL12.GL_RESCALE_NORMAL); - GL11.glEnable(GL11.GL_BLEND); - GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); - GL11.glColor4f(1F, 1F, 1F, 1F); - GL11.glTranslated(d0, d1, d2); - Minecraft.getMinecraft().renderEngine.bindTexture(texture); - GL11.glRotatef(90F, 1F, 0F, 0F); - GL11.glTranslatef(0.5F, -0.5F - 3F / 16F, -0.5F + 1F / 16F); - GL11.glRotatef(rot, 0F, 1F, 0F); - model.render(); - GL11.glColor3f(1F, 1F, 1F); - GL11.glEnable(GL12.GL_RESCALE_NORMAL); - GL11.glPopMatrix(); - } + private static final ResourceLocation texture = new ResourceLocation(LibResources.MODEL_COCOON); + ModelCocoon model = new ModelCocoon(); + + @Override + public void renderTileEntityAt(TileEntity tileentity, double d0, double d1, double d2, float f) { + TileCocoon cocoon = (TileCocoon) tileentity; + + float rot = 0F; + float modval = 60F - (float) cocoon.timePassed / (float) TileCocoon.TOTAL_TIME * 30F; + if(cocoon.timePassed % modval < 10) { + float mod = (cocoon.timePassed + f) % modval; + float v = mod / 5 * (float) Math.PI * 2; + rot = (float) Math.sin(v) * (float) Math.log(cocoon.timePassed + f); + } + + GL11.glPushMatrix(); + GL11.glEnable(GL12.GL_RESCALE_NORMAL); + GL11.glEnable(GL11.GL_BLEND); + GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); + GL11.glColor4f(1F, 1F, 1F, 1F); + GL11.glTranslated(d0, d1, d2); + Minecraft.getMinecraft().renderEngine.bindTexture(texture); + GL11.glRotatef(90F, 1F, 0F, 0F); + GL11.glTranslatef(0.5F, -0.5F - 3F / 16F, -0.5F + 1F / 16F); + GL11.glRotatef(rot, 0F, 1F, 0F); + model.render(); + GL11.glColor3f(1F, 1F, 1F); + GL11.glEnable(GL12.GL_RESCALE_NORMAL); + GL11.glPopMatrix(); + } } diff --git a/src/main/java/vazkii/botania/client/render/tile/RenderTileCorporeaCrystalCube.java b/src/main/java/vazkii/botania/client/render/tile/RenderTileCorporeaCrystalCube.java index f8a6ae7803..71f7d6eefa 100644 --- a/src/main/java/vazkii/botania/client/render/tile/RenderTileCorporeaCrystalCube.java +++ b/src/main/java/vazkii/botania/client/render/tile/RenderTileCorporeaCrystalCube.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Apr 30, 2015, 4:10:14 PM (GMT)] */ package vazkii.botania.client.render.tile; @@ -20,8 +20,10 @@ import net.minecraft.item.ItemStack; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.ResourceLocation; + import org.lwjgl.opengl.GL11; import org.lwjgl.opengl.GL12; + import vazkii.botania.client.core.handler.ClientTickHandler; import vazkii.botania.client.lib.LibResources; import vazkii.botania.client.model.ModelCrystalCube; @@ -29,87 +31,87 @@ public class RenderTileCorporeaCrystalCube extends TileEntitySpecialRenderer { - private static final ResourceLocation texture = new ResourceLocation(LibResources.MODEL_CRYSTAL_CUBE); - ModelCrystalCube model = new ModelCrystalCube(); - EntityItem entity = null; - - @Override - public void renderTileEntityAt(TileEntity tileentity, double d0, double d1, double d2, float f) { - TileCorporeaCrystalCube cube = (TileCorporeaCrystalCube) tileentity; - - if (entity == null) - entity = new EntityItem( - cube.getWorldObj(), cube.xCoord, cube.yCoord, cube.zCoord, new ItemStack(Blocks.stone)); - - entity.age = ClientTickHandler.ticksInGame; - ItemStack stack = cube.getRequestTarget(); - entity.setEntityItemStack(stack); - - double time = ClientTickHandler.ticksInGame + f; - double worldTicks = tileentity.getWorldObj() == null ? 0 : time; - - Minecraft mc = Minecraft.getMinecraft(); - GL11.glPushMatrix(); - GL11.glEnable(GL12.GL_RESCALE_NORMAL); - GL11.glEnable(GL11.GL_BLEND); - GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); - GL11.glColor4f(1F, 1F, 1F, 1F); - GL11.glTranslated(d0, d1, d2); - mc.renderEngine.bindTexture(texture); - GL11.glTranslatef(0.5F, 1.5F, 0.5F); - GL11.glScalef(1F, -1F, -1F); - model.renderBase(); - GL11.glTranslatef(0F, (float) Math.sin(worldTicks / 20.0) * 0.05F, 0F); - if (stack != null) { - GL11.glPushMatrix(); - float s = stack.getItem() instanceof ItemBlock ? 0.7F : 0.5F; - GL11.glTranslatef(0F, 0.8F, 0F); - GL11.glScalef(s, s, s); - GL11.glRotatef(180F, 0F, 0F, 1F); - ((Render) RenderManager.instance.entityRenderMap.get(EntityItem.class)).doRender(entity, 0, 0, 0, 1F, f); - GL11.glPopMatrix(); - mc.renderEngine.bindTexture(texture); - } - - GL11.glColor4f(1F, 1F, 1F, 0.4F); - model.renderCube(); - GL11.glColor3f(1F, 1F, 1F); - - if (stack != null) { - int count = cube.getItemCount(); - String countStr = "" + count; - int color = 0xFFFFFF; - if (count > 9999) { - countStr = count / 1000 + "K"; - color = 0xFFFF00; - if (count > 9999999) { - countStr = count / 10000000 + "M"; - color = 0x00FF00; - } - } - color |= 0xA0 << 24; - int colorShade = (color & 16579836) >> 2 | color & -16777216; - - float s = 1F / 64F; - GL11.glScalef(s, s, s); - GL11.glDisable(GL11.GL_LIGHTING); - int l = mc.fontRenderer.getStringWidth(countStr); - - GL11.glTranslatef(0F, 55F, 0F); - float tr = -16.5F; - for (int i = 0; i < 4; i++) { - GL11.glRotatef(90F, 0F, 1F, 0F); - GL11.glTranslatef(0F, 0F, tr); - mc.fontRenderer.drawString(countStr, -l / 2, 0, color); - GL11.glTranslatef(0F, 0F, 0.1F); - mc.fontRenderer.drawString(countStr, -l / 2 + 1, 1, colorShade); - GL11.glTranslatef(0F, 0F, -tr - 0.1F); - } - GL11.glEnable(GL11.GL_LIGHTING); - } - - GL11.glScalef(1F, -1F, -1F); - GL11.glEnable(GL12.GL_RESCALE_NORMAL); - GL11.glPopMatrix(); - } + private static final ResourceLocation texture = new ResourceLocation(LibResources.MODEL_CRYSTAL_CUBE); + ModelCrystalCube model = new ModelCrystalCube(); + EntityItem entity = null; + + @Override + public void renderTileEntityAt(TileEntity tileentity, double d0, double d1, double d2, float f) { + TileCorporeaCrystalCube cube = (TileCorporeaCrystalCube) tileentity; + + if(entity == null) + entity = new EntityItem(cube.getWorldObj(), cube.xCoord, cube.yCoord, cube.zCoord, new ItemStack(Blocks.stone)); + + entity.age = ClientTickHandler.ticksInGame; + ItemStack stack = cube.getRequestTarget(); + entity.setEntityItemStack(stack); + + double time = ClientTickHandler.ticksInGame + f; + double worldTicks = tileentity.getWorldObj() == null ? 0 : time; + + Minecraft mc = Minecraft.getMinecraft(); + GL11.glPushMatrix(); + GL11.glEnable(GL12.GL_RESCALE_NORMAL); + GL11.glEnable(GL11.GL_BLEND); + GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); + GL11.glColor4f(1F, 1F, 1F, 1F); + GL11.glTranslated(d0, d1, d2); + mc.renderEngine.bindTexture(texture); + GL11.glTranslatef(0.5F, 1.5F, 0.5F); + GL11.glScalef(1F, -1F, -1F); + model.renderBase(); + GL11.glTranslatef(0F, (float) Math.sin(worldTicks / 20.0) * 0.05F, 0F); + if(stack != null) { + GL11.glPushMatrix(); + float s = stack.getItem() instanceof ItemBlock ? 0.7F : 0.5F; + GL11.glTranslatef(0F, 0.8F, 0F); + GL11.glScalef(s, s, s); + GL11.glRotatef(180F, 0F, 0F, 1F); + ((Render) RenderManager.instance.entityRenderMap.get(EntityItem.class)).doRender(entity, 0, 0, 0, 1F, f); + GL11.glPopMatrix(); + mc.renderEngine.bindTexture(texture); + } + + GL11.glColor4f(1F, 1F, 1F, 0.4F); + model.renderCube(); + GL11.glColor3f(1F, 1F, 1F); + + if(stack != null) { + int count = cube.getItemCount(); + String countStr = "" + count; + int color = 0xFFFFFF; + if(count > 9999) { + countStr = count / 1000 + "K"; + color = 0xFFFF00; + if(count > 9999999) { + countStr = count / 10000000 + "M"; + color = 0x00FF00; + } + } + color |= 0xA0 << 24; + int colorShade = (color & 16579836) >> 2 | color & -16777216; + + float s = 1F / 64F; + GL11.glScalef(s, s, s); + GL11.glDisable(GL11.GL_LIGHTING); + int l = mc.fontRenderer.getStringWidth(countStr); + + GL11.glTranslatef(0F, 55F, 0F); + float tr = -16.5F; + for(int i = 0; i < 4; i++) { + GL11.glRotatef(90F, 0F, 1F, 0F); + GL11.glTranslatef(0F, 0F, tr); + mc.fontRenderer.drawString(countStr, -l / 2, 0, color); + GL11.glTranslatef(0F, 0F, 0.1F); + mc.fontRenderer.drawString(countStr, -l / 2 + 1, 1, colorShade); + GL11.glTranslatef(0F, 0F, -tr - 0.1F); + } + GL11.glEnable(GL11.GL_LIGHTING); + } + + GL11.glScalef(1F, -1F, -1F); + GL11.glEnable(GL12.GL_RESCALE_NORMAL); + GL11.glPopMatrix(); + } + } diff --git a/src/main/java/vazkii/botania/client/render/tile/RenderTileCorporeaIndex.java b/src/main/java/vazkii/botania/client/render/tile/RenderTileCorporeaIndex.java index d3a8989be6..3e66131aa4 100644 --- a/src/main/java/vazkii/botania/client/render/tile/RenderTileCorporeaIndex.java +++ b/src/main/java/vazkii/botania/client/render/tile/RenderTileCorporeaIndex.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Feb 15, 2015, 12:54:49 AM (GMT)] */ package vazkii.botania.client.render.tile; @@ -15,60 +15,59 @@ import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.ResourceLocation; + import org.lwjgl.opengl.GL11; + import vazkii.botania.client.core.helper.RenderHelper; import vazkii.botania.client.lib.LibResources; import vazkii.botania.common.block.tile.corporea.TileCorporeaIndex; public class RenderTileCorporeaIndex extends TileEntitySpecialRenderer { - private static final ResourceLocation texture = new ResourceLocation(LibResources.MODEL_CORPOREA_INDEX); - ModelEnderCrystal crystal = new ModelEnderCrystal(0F, false); - public static boolean move = true; + private static final ResourceLocation texture = new ResourceLocation(LibResources.MODEL_CORPOREA_INDEX); + ModelEnderCrystal crystal = new ModelEnderCrystal(0F, false); + public static boolean move = true; + + @Override + public void renderTileEntityAt(TileEntity tile, double x, double y, double z, float partticks) { + TileCorporeaIndex index = (TileCorporeaIndex) tile; - @Override - public void renderTileEntityAt(TileEntity tile, double x, double y, double z, float partticks) { - TileCorporeaIndex index = (TileCorporeaIndex) tile; + GL11.glPushMatrix(); + GL11.glTranslated(x + 0.5, y, z + 0.5); + Minecraft.getMinecraft().renderEngine.bindTexture(texture); - GL11.glPushMatrix(); - GL11.glTranslated(x + 0.5, y, z + 0.5); - Minecraft.getMinecraft().renderEngine.bindTexture(texture); + float translation = move ? (float) ((Math.cos((index.ticksWithCloseby + (index.hasCloseby ? partticks : 0)) / 10F) * 0.5 + 0.5) * 0.25) : 0F; + float rotation = move ? index.ticks * 2 + partticks : 0F; + float scale = 0.6F; + GL11.glScalef(scale, scale, scale); + crystal.render(null, 0F, rotation, translation, 0F, 0F, 1F / 16F); + GL11.glScalef(1F / scale, 1F / scale, 1F / scale); - float translation = move - ? (float) ((Math.cos((index.ticksWithCloseby + (index.hasCloseby ? partticks : 0)) / 10F) * 0.5 + 0.5) - * 0.25) - : 0F; - float rotation = move ? index.ticks * 2 + partticks : 0F; - float scale = 0.6F; - GL11.glScalef(scale, scale, scale); - crystal.render(null, 0F, rotation, translation, 0F, 0F, 1F / 16F); - GL11.glScalef(1F / scale, 1F / scale, 1F / scale); + if(index.closeby > 0F) { + float starScale = 0.02F; + float starRadius = (float) TileCorporeaIndex.RADIUS * index.closeby + (index.closeby == 1F ? 0F : index.hasCloseby ? partticks : -partticks) * 0.2F; + double rads = (index.ticksWithCloseby + partticks) * 2 * Math.PI / 180; + double starX = Math.cos(rads) * starRadius; + double starZ = Math.sin(rads) * starRadius; + int color = 0xFF00FF; + int seed = index.xCoord ^ index.yCoord ^ index.zCoord; - if (index.closeby > 0F) { - float starScale = 0.02F; - float starRadius = (float) TileCorporeaIndex.RADIUS * index.closeby - + (index.closeby == 1F ? 0F : index.hasCloseby ? partticks : -partticks) * 0.2F; - double rads = (index.ticksWithCloseby + partticks) * 2 * Math.PI / 180; - double starX = Math.cos(rads) * starRadius; - double starZ = Math.sin(rads) * starRadius; - int color = 0xFF00FF; - int seed = index.xCoord ^ index.yCoord ^ index.zCoord; + GL11.glTranslated(starX, 0.3, starZ); + RenderHelper.renderStar(color, starScale, starScale, starScale, seed); + GL11.glTranslated(-starX * 2, 0, -starZ * 2); + RenderHelper.renderStar(color, starScale, starScale, starScale, seed); + GL11.glTranslated(starX, 0, starZ); - GL11.glTranslated(starX, 0.3, starZ); - RenderHelper.renderStar(color, starScale, starScale, starScale, seed); - GL11.glTranslated(-starX * 2, 0, -starZ * 2); - RenderHelper.renderStar(color, starScale, starScale, starScale, seed); - GL11.glTranslated(starX, 0, starZ); + rads = -rads; + starX = Math.cos(rads) * starRadius; + starZ = Math.sin(rads) * starRadius; + GL11.glTranslated(starX, 0, starZ); + RenderHelper.renderStar(color, starScale, starScale, starScale, seed); + GL11.glTranslated(-starX * 2, 0, -starZ * 2); + RenderHelper.renderStar(color, starScale, starScale, starScale, seed); + GL11.glTranslated(starX, 0, starZ); + } + GL11.glPopMatrix(); + } - rads = -rads; - starX = Math.cos(rads) * starRadius; - starZ = Math.sin(rads) * starRadius; - GL11.glTranslated(starX, 0, starZ); - RenderHelper.renderStar(color, starScale, starScale, starScale, seed); - GL11.glTranslated(-starX * 2, 0, -starZ * 2); - RenderHelper.renderStar(color, starScale, starScale, starScale, seed); - GL11.glTranslated(starX, 0, starZ); - } - GL11.glPopMatrix(); - } } diff --git a/src/main/java/vazkii/botania/client/render/tile/RenderTileEnchanter.java b/src/main/java/vazkii/botania/client/render/tile/RenderTileEnchanter.java index dd9854bf90..6d9b654faa 100644 --- a/src/main/java/vazkii/botania/client/render/tile/RenderTileEnchanter.java +++ b/src/main/java/vazkii/botania/client/render/tile/RenderTileEnchanter.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Mar 15, 2014, 5:04:42 PM (GMT)] */ package vazkii.botania.client.render.tile; @@ -21,7 +21,9 @@ import net.minecraft.entity.item.EntityItem; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.IIcon; + import org.lwjgl.opengl.GL11; + import vazkii.botania.client.core.handler.ClientTickHandler; import vazkii.botania.client.core.helper.ShaderHelper; import vazkii.botania.common.block.mana.BlockEnchanter; @@ -29,95 +31,91 @@ public class RenderTileEnchanter extends TileEntitySpecialRenderer { - RenderItem renderItem = new RenderItem(); - EntityItem item; - - @Override - public void renderTileEntityAt(TileEntity tileentity, double d0, double d1, double d2, float f) { - TileEnchanter enchanter = (TileEnchanter) tileentity; - float alphaMod = 0F; - - if (enchanter.stage == 2) alphaMod = Math.min(20, enchanter.stageTicks) / 20F; - else if (enchanter.stage == 4) alphaMod = (20 - enchanter.stageTicks) / 20F; - else if (enchanter.stage > 2) alphaMod = 1F; - - if (enchanter.itemToEnchant != null) { - if (item == null) - item = new EntityItem( - enchanter.getWorldObj(), - enchanter.xCoord, - enchanter.yCoord + 1, - enchanter.zCoord, - enchanter.itemToEnchant); - - item.age = ClientTickHandler.ticksInGame; - item.setEntityItemStack(enchanter.itemToEnchant); - - GL11.glColor4f(1F, 1F, 1F, 1F); - GL11.glTranslatef(0.5F, 1.25F, 0.5F); - ((Render) RenderManager.instance.entityRenderMap.get(EntityItem.class)).doRender(item, d0, d1, d2, 1F, f); - GL11.glTranslatef(-0.5F, -1.25F, -0.5F); - } - - GL11.glPushMatrix(); - GL11.glTranslated(d0, d1, d2); - - GL11.glRotated(90F, 1F, 0F, 0F); - GL11.glTranslatef(-2F, -2F, -0.001F); - - GL11.glEnable(GL11.GL_BLEND); - GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); - GL11.glColor4f(1F, 1F, 1F, 1F); - GL11.glDisable(GL11.GL_ALPHA_TEST); - float alpha = (float) ((Math.sin((ClientTickHandler.ticksInGame + f) / 8D) + 1D) / 5D + 0.4D) * alphaMod; - - if (alpha > 0) { - if (ShaderHelper.useShaders()) GL11.glColor4f(1F, 1F, 1F, alpha); - else { - int light = 15728880; - int lightmapX = light % 65536; - int lightmapY = light / 65536; - OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, lightmapX, lightmapY); - GL11.glColor4f( - 0.6F + (float) ((Math.cos((ClientTickHandler.ticksInGame + f) / 6D) + 1D) / 5D), - 0.1F, - 0.9F, - alpha); - } - - Minecraft.getMinecraft().renderEngine.bindTexture(TextureMap.locationBlocksTexture); - - if (enchanter.stage == 3 || enchanter.stage == 4) { - int ticks = enchanter.stageTicks + enchanter.stage3EndTicks; - int angle = ticks * 2; - float yTranslation = Math.min(20, ticks) / 20F * 1.15F; - float scale = ticks < 10 ? 1F : 1F - Math.min(20, ticks - 10) / 20F * 0.75F; - - GL11.glTranslatef(2.5F, 2.5F, -yTranslation); - GL11.glScalef(scale, scale, 1F); - GL11.glRotatef(angle, 0F, 0F, 1F); - GL11.glTranslatef(-2.5F, -2.5F, 0F); - } - - ShaderHelper.useShader(ShaderHelper.enchanterRune); - renderIcon(0, 0, BlockEnchanter.overlay, 5, 5, 240); - ShaderHelper.releaseShader(); - } - - GL11.glEnable(GL11.GL_ALPHA_TEST); - GL11.glDisable(GL11.GL_BLEND); - GL11.glColor4f(1F, 1F, 1F, 1F); - GL11.glPopMatrix(); - } - - public void renderIcon(int par1, int par2, IIcon par3Icon, int par4, int par5, int brightness) { - Tessellator tessellator = Tessellator.instance; - tessellator.startDrawingQuads(); - tessellator.setBrightness(brightness); - tessellator.addVertexWithUV(par1 + 0, par2 + par5, 0, par3Icon.getMinU(), par3Icon.getMaxV()); - tessellator.addVertexWithUV(par1 + par4, par2 + par5, 0, par3Icon.getMaxU(), par3Icon.getMaxV()); - tessellator.addVertexWithUV(par1 + par4, par2 + 0, 0, par3Icon.getMaxU(), par3Icon.getMinV()); - tessellator.addVertexWithUV(par1 + 0, par2 + 0, 0, par3Icon.getMinU(), par3Icon.getMinV()); - tessellator.draw(); - } + RenderItem renderItem = new RenderItem(); + EntityItem item; + + @Override + public void renderTileEntityAt(TileEntity tileentity, double d0, double d1, double d2, float f) { + TileEnchanter enchanter = (TileEnchanter) tileentity; + float alphaMod = 0F; + + if(enchanter.stage == 2) + alphaMod = Math.min(20, enchanter.stageTicks) / 20F; + else if(enchanter.stage == 4) + alphaMod = (20 - enchanter.stageTicks) / 20F; + else if(enchanter.stage > 2) + alphaMod = 1F; + + if(enchanter.itemToEnchant != null) { + if(item == null) + item = new EntityItem(enchanter.getWorldObj(), enchanter.xCoord, enchanter.yCoord + 1, enchanter.zCoord, enchanter.itemToEnchant); + + item.age = ClientTickHandler.ticksInGame; + item.setEntityItemStack(enchanter.itemToEnchant); + + GL11.glColor4f(1F, 1F, 1F, 1F); + GL11.glTranslatef(0.5F, 1.25F, 0.5F); + ((Render) RenderManager.instance.entityRenderMap.get(EntityItem.class)).doRender(item, d0, d1, d2, 1F, f); + GL11.glTranslatef(-0.5F, -1.25F, -0.5F); + } + + GL11.glPushMatrix(); + GL11.glTranslated(d0, d1, d2); + + GL11.glRotated(90F, 1F, 0F, 0F); + GL11.glTranslatef(-2F, -2F, -0.001F); + + GL11.glEnable(GL11.GL_BLEND); + GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); + GL11.glColor4f(1F, 1F, 1F, 1F); + GL11.glDisable(GL11.GL_ALPHA_TEST); + float alpha = (float) ((Math.sin((ClientTickHandler.ticksInGame + f) / 8D) + 1D) / 5D + 0.4D) * alphaMod; + + if(alpha > 0) { + if(ShaderHelper.useShaders()) + GL11.glColor4f(1F, 1F, 1F, alpha); + else { + int light = 15728880; + int lightmapX = light % 65536; + int lightmapY = light / 65536; + OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, lightmapX, lightmapY); + GL11.glColor4f(0.6F + (float) ((Math.cos((ClientTickHandler.ticksInGame + f) / 6D) + 1D) / 5D), 0.1F, 0.9F, alpha); + } + + Minecraft.getMinecraft().renderEngine.bindTexture(TextureMap.locationBlocksTexture); + + if(enchanter.stage == 3 || enchanter.stage == 4) { + int ticks = enchanter.stageTicks + enchanter.stage3EndTicks; + int angle = ticks * 2; + float yTranslation = Math.min(20, ticks) / 20F * 1.15F; + float scale = ticks < 10 ? 1F : 1F - Math.min(20, ticks - 10) / 20F * 0.75F; + + GL11.glTranslatef(2.5F, 2.5F, -yTranslation); + GL11.glScalef(scale, scale, 1F); + GL11.glRotatef(angle, 0F, 0F, 1F); + GL11.glTranslatef(-2.5F, -2.5F, 0F); + } + + ShaderHelper.useShader(ShaderHelper.enchanterRune); + renderIcon(0, 0, BlockEnchanter.overlay, 5, 5, 240); + ShaderHelper.releaseShader(); + } + + GL11.glEnable(GL11.GL_ALPHA_TEST); + GL11.glDisable(GL11.GL_BLEND); + GL11.glColor4f(1F, 1F, 1F, 1F); + GL11.glPopMatrix(); + } + + public void renderIcon(int par1, int par2, IIcon par3Icon, int par4, int par5, int brightness) { + Tessellator tessellator = Tessellator.instance; + tessellator.startDrawingQuads(); + tessellator.setBrightness(brightness); + tessellator.addVertexWithUV(par1 + 0, par2 + par5, 0, par3Icon.getMinU(), par3Icon.getMaxV()); + tessellator.addVertexWithUV(par1 + par4, par2 + par5, 0, par3Icon.getMaxU(), par3Icon.getMaxV()); + tessellator.addVertexWithUV(par1 + par4, par2 + 0, 0, par3Icon.getMaxU(), par3Icon.getMinV()); + tessellator.addVertexWithUV(par1 + 0, par2 + 0, 0, par3Icon.getMinU(), par3Icon.getMinV()); + tessellator.draw(); + } + } diff --git a/src/main/java/vazkii/botania/client/render/tile/RenderTileFloatingFlower.java b/src/main/java/vazkii/botania/client/render/tile/RenderTileFloatingFlower.java index 35a68dab45..c688c2587f 100644 --- a/src/main/java/vazkii/botania/client/render/tile/RenderTileFloatingFlower.java +++ b/src/main/java/vazkii/botania/client/render/tile/RenderTileFloatingFlower.java @@ -2,16 +2,17 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jul 8, 2014, 10:58:46 PM (GMT)] */ package vazkii.botania.client.render.tile; import java.awt.*; import java.util.Random; + import net.minecraft.client.Minecraft; import net.minecraft.client.renderer.ItemRenderer; import net.minecraft.client.renderer.Tessellator; @@ -20,57 +21,60 @@ import net.minecraft.item.ItemStack; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.IIcon; + import org.lwjgl.opengl.GL11; + import vazkii.botania.client.core.handler.ClientTickHandler; import vazkii.botania.client.model.ModelMiniIsland; import vazkii.botania.common.block.decor.IFloatingFlower; public class RenderTileFloatingFlower extends TileEntitySpecialRenderer { - private static final ModelMiniIsland model = new ModelMiniIsland(); + private static final ModelMiniIsland model = new ModelMiniIsland(); + + @Override + public void renderTileEntityAt(TileEntity tile, double d0, double d1, double d2, float t) { + IFloatingFlower flower = (IFloatingFlower) tile; + GL11.glPushMatrix(); + GL11.glColor4f(1F, 1F, 1F, 1F); + GL11.glTranslated(d0, d1, d2); - @Override - public void renderTileEntityAt(TileEntity tile, double d0, double d1, double d2, float t) { - IFloatingFlower flower = (IFloatingFlower) tile; - GL11.glPushMatrix(); - GL11.glColor4f(1F, 1F, 1F, 1F); - GL11.glTranslated(d0, d1, d2); + double worldTime = tile.getWorldObj() == null ? 0 : (double) (ClientTickHandler.ticksInGame + t); + if(tile.getWorldObj() != null) + worldTime += new Random(tile.xCoord ^ tile.yCoord ^ tile.zCoord).nextInt(1000); - double worldTime = tile.getWorldObj() == null ? 0 : (double) (ClientTickHandler.ticksInGame + t); - if (tile.getWorldObj() != null) worldTime += new Random(tile.xCoord ^ tile.yCoord ^ tile.zCoord).nextInt(1000); + GL11.glTranslatef(0.5F, 0F, 0.5F); + GL11.glRotatef(-((float) worldTime * 0.5F), 0F, 1F, 0F); + GL11.glTranslatef(-0.5F, 0F, -0.5F); - GL11.glTranslatef(0.5F, 0F, 0.5F); - GL11.glRotatef(-((float) worldTime * 0.5F), 0F, 1F, 0F); - GL11.glTranslatef(-0.5F, 0F, -0.5F); + if(tile.getWorldObj() != null) { + GL11.glTranslatef(0F, (float) Math.sin(worldTime * 0.05F) * 0.1F, 0F); + GL11.glRotatef(4F * (float) Math.sin(worldTime * 0.04F), 1F, 0F, 0F); + } - if (tile.getWorldObj() != null) { - GL11.glTranslatef(0F, (float) Math.sin(worldTime * 0.05F) * 0.1F, 0F); - GL11.glRotatef(4F * (float) Math.sin(worldTime * 0.04F), 1F, 0F, 0F); - } + Minecraft.getMinecraft().renderEngine.bindTexture(flower.getIslandType().getResource()); + Color color = new Color(flower.getIslandType().getColor()); + GL11.glColor3f(color.getRed() / 255f, color.getGreen() / 255f, color.getBlue() / 255f); + GL11.glPushMatrix(); + GL11.glTranslatef(0.5F, 1.4F, 0.5F); + GL11.glScalef(1F, -1F, -1F); + model.render(); + GL11.glPopMatrix(); + GL11.glColor3f(1f, 1f, 1f); - Minecraft.getMinecraft().renderEngine.bindTexture(flower.getIslandType().getResource()); - Color color = new Color(flower.getIslandType().getColor()); - GL11.glColor3f(color.getRed() / 255f, color.getGreen() / 255f, color.getBlue() / 255f); - GL11.glPushMatrix(); - GL11.glTranslatef(0.5F, 1.4F, 0.5F); - GL11.glScalef(1F, -1F, -1F); - model.render(); - GL11.glPopMatrix(); - GL11.glColor3f(1f, 1f, 1f); + ItemStack stack = flower.getDisplayStack(); + IIcon icon = stack.getIconIndex(); - ItemStack stack = flower.getDisplayStack(); - IIcon icon = stack.getIconIndex(); + Minecraft.getMinecraft().renderEngine.bindTexture(TextureMap.locationBlocksTexture); + float f = icon.getMinU(); + float f1 = icon.getMaxU(); + float f2 = icon.getMinV(); + float f3 = icon.getMaxV(); + GL11.glTranslatef(0.25F, 0.4F, 0.5F); + GL11.glScalef(0.5F, 0.5F, 0.5F); + ItemRenderer.renderItemIn2D(Tessellator.instance, f1, f2, f, f3, icon.getIconWidth(), icon.getIconHeight(), 1F / 32F); + GL11.glColor3f(1F, 1F, 1F); + GL11.glPopMatrix(); + } - Minecraft.getMinecraft().renderEngine.bindTexture(TextureMap.locationBlocksTexture); - float f = icon.getMinU(); - float f1 = icon.getMaxU(); - float f2 = icon.getMinV(); - float f3 = icon.getMaxV(); - GL11.glTranslatef(0.25F, 0.4F, 0.5F); - GL11.glScalef(0.5F, 0.5F, 0.5F); - ItemRenderer.renderItemIn2D( - Tessellator.instance, f1, f2, f, f3, icon.getIconWidth(), icon.getIconHeight(), 1F / 32F); - GL11.glColor3f(1F, 1F, 1F); - GL11.glPopMatrix(); - } } diff --git a/src/main/java/vazkii/botania/client/render/tile/RenderTileHourglass.java b/src/main/java/vazkii/botania/client/render/tile/RenderTileHourglass.java index 1e42634094..c5bb50574f 100644 --- a/src/main/java/vazkii/botania/client/render/tile/RenderTileHourglass.java +++ b/src/main/java/vazkii/botania/client/render/tile/RenderTileHourglass.java @@ -2,21 +2,24 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [May 29, 2015, 8:19:32 PM (GMT)] */ package vazkii.botania.client.render.tile; import java.util.Random; + import net.minecraft.client.Minecraft; import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer; import net.minecraft.item.ItemStack; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.ResourceLocation; + import org.lwjgl.opengl.GL11; + import vazkii.botania.client.core.handler.ClientTickHandler; import vazkii.botania.client.lib.LibResources; import vazkii.botania.client.model.ModelHourglass; @@ -24,40 +27,43 @@ public class RenderTileHourglass extends TileEntitySpecialRenderer { - ResourceLocation texture = new ResourceLocation(LibResources.MODEL_HOURGLASS); - ModelHourglass model = new ModelHourglass(); - - @Override - public void renderTileEntityAt(TileEntity tileentity, double d0, double d1, double d2, float ticks) { - TileHourglass hourglass = (TileHourglass) tileentity; - - GL11.glPushMatrix(); - GL11.glEnable(GL11.GL_BLEND); - GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); - GL11.glColor4f(1F, 1F, 1F, 1F); - GL11.glTranslated(d0, d1, d2); - Minecraft.getMinecraft().renderEngine.bindTexture(texture); - - int wtime = tileentity.getWorldObj() == null ? 0 : ClientTickHandler.ticksInGame; - if (wtime != 0) wtime += new Random(tileentity.xCoord ^ tileentity.yCoord ^ tileentity.zCoord).nextInt(360); - - float time = wtime == 0 ? 0 : wtime + ticks; - float x = 0.5F + (float) Math.cos(time * 0.05F) * 0.025F; - float y = 0.55F + (float) (Math.sin(time * 0.04F) + 1F) * 0.05F; - float z = 0.5F + (float) Math.sin(time * 0.05F) * 0.025F; - ItemStack stack = hourglass.getStackInSlot(0); - - float fract1 = stack == null ? 0 : hourglass.timeFraction; - float fract2 = stack == null ? 0 : 1F - hourglass.timeFraction; - GL11.glTranslatef(x, y, z); - - float rot = hourglass.flip ? 180F : 1F; - if (hourglass.flipTicks > 0) rot += (hourglass.flipTicks - ticks) * (180F / 4F); - GL11.glRotatef(rot, 0F, 0F, 1F); - - GL11.glScalef(1F, -1F, -1F); - model.render(fract1, fract2, hourglass.flip, hourglass.getColor()); - GL11.glScalef(1F, -1F, -1F); - GL11.glPopMatrix(); - } + ResourceLocation texture = new ResourceLocation(LibResources.MODEL_HOURGLASS); + ModelHourglass model = new ModelHourglass(); + + @Override + public void renderTileEntityAt(TileEntity tileentity, double d0, double d1, double d2, float ticks) { + TileHourglass hourglass = (TileHourglass) tileentity; + + GL11.glPushMatrix(); + GL11.glEnable(GL11.GL_BLEND); + GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); + GL11.glColor4f(1F, 1F, 1F, 1F); + GL11.glTranslated(d0, d1, d2); + Minecraft.getMinecraft().renderEngine.bindTexture(texture); + + int wtime = tileentity.getWorldObj() == null ? 0 : ClientTickHandler.ticksInGame; + if(wtime != 0) + wtime += new Random(tileentity.xCoord ^ tileentity.yCoord ^ tileentity.zCoord).nextInt(360); + + float time = wtime == 0 ? 0 : wtime + ticks; + float x = 0.5F + (float) Math.cos(time * 0.05F) * 0.025F; + float y = 0.55F + (float) (Math.sin(time * 0.04F) + 1F) * 0.05F; + float z = 0.5F + (float) Math.sin(time * 0.05F) * 0.025F; + ItemStack stack = hourglass.getStackInSlot(0); + + float fract1 = stack == null ? 0 : hourglass.timeFraction; + float fract2 = stack == null ? 0 : 1F - hourglass.timeFraction; + GL11.glTranslatef(x, y, z); + + float rot = hourglass.flip ? 180F : 1F; + if(hourglass.flipTicks > 0) + rot += (hourglass.flipTicks - ticks) * (180F / 4F); + GL11.glRotatef(rot, 0F, 0F, 1F); + + GL11.glScalef(1F, -1F, -1F); + model.render(fract1, fract2, hourglass.flip, hourglass.getColor()); + GL11.glScalef(1F, -1F, -1F); + GL11.glPopMatrix(); + } + } diff --git a/src/main/java/vazkii/botania/client/render/tile/RenderTileIncensePlate.java b/src/main/java/vazkii/botania/client/render/tile/RenderTileIncensePlate.java index 312114fa48..3a786db708 100644 --- a/src/main/java/vazkii/botania/client/render/tile/RenderTileIncensePlate.java +++ b/src/main/java/vazkii/botania/client/render/tile/RenderTileIncensePlate.java @@ -2,15 +2,16 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [May 15, 2015, 4:27:27 PM (GMT)] */ package vazkii.botania.client.render.tile; import java.awt.Color; + import net.minecraft.client.Minecraft; import net.minecraft.client.renderer.ItemRenderer; import net.minecraft.client.renderer.Tessellator; @@ -20,67 +21,71 @@ import net.minecraft.tileentity.TileEntity; import net.minecraft.util.IIcon; import net.minecraft.util.ResourceLocation; + import org.lwjgl.opengl.GL11; import org.lwjgl.opengl.GL12; + import vazkii.botania.client.lib.LibResources; import vazkii.botania.client.model.ModelIncensePlate; import vazkii.botania.common.block.tile.TileIncensePlate; public class RenderTileIncensePlate extends TileEntitySpecialRenderer { - private static final float[] ROTATIONS = new float[] {180F, 0F, 90F, 270F}; + private static final float[] ROTATIONS = new float[] { + 180F, 0F, 90F, 270F + }; + + ResourceLocation texture = new ResourceLocation(LibResources.MODEL_INCENSE_PLATE); + ModelIncensePlate model = new ModelIncensePlate(); - ResourceLocation texture = new ResourceLocation(LibResources.MODEL_INCENSE_PLATE); - ModelIncensePlate model = new ModelIncensePlate(); + @Override + public void renderTileEntityAt(TileEntity tileentity, double d0, double d1, double d2, float ticks) { + TileIncensePlate plate = (TileIncensePlate) tileentity; - @Override - public void renderTileEntityAt(TileEntity tileentity, double d0, double d1, double d2, float ticks) { - TileIncensePlate plate = (TileIncensePlate) tileentity; + int meta = plate.getWorldObj() != null ? plate.getBlockMetadata() : 0; - int meta = plate.getWorldObj() != null ? plate.getBlockMetadata() : 0; + GL11.glPushMatrix(); + GL11.glEnable(GL12.GL_RESCALE_NORMAL); + GL11.glEnable(GL11.GL_BLEND); + GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); + GL11.glColor4f(1F, 1F, 1F, 1F); + GL11.glTranslated(d0, d1, d2); + Minecraft.getMinecraft().renderEngine.bindTexture(texture); + GL11.glTranslatef(0.5F, 1.5F, 0.5F); + GL11.glScalef(1F, -1F, -1F); + GL11.glRotatef(ROTATIONS[Math.max(Math.min(ROTATIONS.length, meta - 2), 0)], 0F, 1F, 0F); + model.render(); + GL11.glScalef(1F, -1F, -1F); - GL11.glPushMatrix(); - GL11.glEnable(GL12.GL_RESCALE_NORMAL); - GL11.glEnable(GL11.GL_BLEND); - GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); - GL11.glColor4f(1F, 1F, 1F, 1F); - GL11.glTranslated(d0, d1, d2); - Minecraft.getMinecraft().renderEngine.bindTexture(texture); - GL11.glTranslatef(0.5F, 1.5F, 0.5F); - GL11.glScalef(1F, -1F, -1F); - GL11.glRotatef(ROTATIONS[Math.max(Math.min(ROTATIONS.length, meta - 2), 0)], 0F, 1F, 0F); - model.render(); - GL11.glScalef(1F, -1F, -1F); + ItemStack stack = plate.getStackInSlot(0); + if(stack != null) { + GL11.glPushMatrix(); + Minecraft.getMinecraft().renderEngine.bindTexture(TextureMap.locationItemsTexture); + float s = 0.4F; + GL11.glTranslatef(0.1F, -1.46F, 0F); + GL11.glScalef(s, s, s); + GL11.glRotatef(180F, 0F, 1F, 0F); - ItemStack stack = plate.getStackInSlot(0); - if (stack != null) { - GL11.glPushMatrix(); - Minecraft.getMinecraft().renderEngine.bindTexture(TextureMap.locationItemsTexture); - float s = 0.4F; - GL11.glTranslatef(0.1F, -1.46F, 0F); - GL11.glScalef(s, s, s); - GL11.glRotatef(180F, 0F, 1F, 0F); + int renderPass = 0; + do { + IIcon icon = stack.getItem().getIcon(stack, renderPass); + if(icon != null) { + Color color = new Color(stack.getItem().getColorFromItemStack(stack, renderPass)); + GL11.glColor3ub((byte) color.getRed(), (byte) color.getGreen(), (byte) color.getBlue()); + float f = icon.getMinU(); + float f1 = icon.getMaxU(); + float f2 = icon.getMinV(); + float f3 = icon.getMaxV(); + ItemRenderer.renderItemIn2D(Tessellator.instance, f1, f2, f, f3, icon.getIconWidth(), icon.getIconHeight(), 1F / 32F); + GL11.glColor3f(1F, 1F, 1F); + } + renderPass++; + } while(renderPass < stack.getItem().getRenderPasses(stack.getItemDamage())); + GL11.glPopMatrix(); + } + GL11.glColor3f(1F, 1F, 1F); + GL11.glEnable(GL12.GL_RESCALE_NORMAL); + GL11.glPopMatrix(); + } - int renderPass = 0; - do { - IIcon icon = stack.getItem().getIcon(stack, renderPass); - if (icon != null) { - Color color = new Color(stack.getItem().getColorFromItemStack(stack, renderPass)); - GL11.glColor3ub((byte) color.getRed(), (byte) color.getGreen(), (byte) color.getBlue()); - float f = icon.getMinU(); - float f1 = icon.getMaxU(); - float f2 = icon.getMinV(); - float f3 = icon.getMaxV(); - ItemRenderer.renderItemIn2D( - Tessellator.instance, f1, f2, f, f3, icon.getIconWidth(), icon.getIconHeight(), 1F / 32F); - GL11.glColor3f(1F, 1F, 1F); - } - renderPass++; - } while (renderPass < stack.getItem().getRenderPasses(stack.getItemDamage())); - GL11.glPopMatrix(); - } - GL11.glColor3f(1F, 1F, 1F); - GL11.glEnable(GL12.GL_RESCALE_NORMAL); - GL11.glPopMatrix(); - } } diff --git a/src/main/java/vazkii/botania/client/render/tile/RenderTileLightRelay.java b/src/main/java/vazkii/botania/client/render/tile/RenderTileLightRelay.java index c38670c971..5213ecda3a 100644 --- a/src/main/java/vazkii/botania/client/render/tile/RenderTileLightRelay.java +++ b/src/main/java/vazkii/botania/client/render/tile/RenderTileLightRelay.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jul 16, 2015, 5:03:57 PM (GMT)] */ package vazkii.botania.client.render.tile; @@ -17,78 +17,82 @@ import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.IIcon; + import org.lwjgl.opengl.GL11; import org.lwjgl.opengl.GL12; + import vazkii.botania.client.core.handler.ClientTickHandler; import vazkii.botania.client.core.helper.ShaderHelper; import vazkii.botania.common.block.BlockLightRelay; public class RenderTileLightRelay extends TileEntitySpecialRenderer { - @Override - public void renderTileEntityAt(TileEntity tile, double x, double y, double z, float pticks) { - Minecraft mc = Minecraft.getMinecraft(); - IIcon iicon = tile.getBlockMetadata() > 0 ? BlockLightRelay.worldIconRed : BlockLightRelay.worldIcon; + @Override + public void renderTileEntityAt(TileEntity tile, double x, double y, double z, float pticks) { + Minecraft mc = Minecraft.getMinecraft(); + IIcon iicon = tile.getBlockMetadata() > 0 ? BlockLightRelay.worldIconRed : BlockLightRelay.worldIcon; - GL11.glPushMatrix(); - GL11.glTranslated(x + 0.5, y + 0.3, z + 0.5); - GL11.glEnable(GL12.GL_RESCALE_NORMAL); - GL11.glEnable(GL11.GL_BLEND); - GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); - GL11.glAlphaFunc(GL11.GL_GREATER, 0.05F); + GL11.glPushMatrix(); + GL11.glTranslated(x + 0.5, y + 0.3, z + 0.5); + GL11.glEnable(GL12.GL_RESCALE_NORMAL); + GL11.glEnable(GL11.GL_BLEND); + GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); + GL11.glAlphaFunc(GL11.GL_GREATER, 0.05F); - double time = ClientTickHandler.ticksInGame + pticks; - GL11.glColor4f(1F, 1F, 1F, 1F); + double time = ClientTickHandler.ticksInGame + pticks; + GL11.glColor4f(1F, 1F, 1F, 1F); - float scale = 0.75F; - GL11.glScalef(scale, scale, scale); - Tessellator tessellator = Tessellator.instance; + float scale = 0.75F; + GL11.glScalef(scale, scale, scale); + Tessellator tessellator = Tessellator.instance; - GL11.glPushMatrix(); - float r = 180.0F - RenderManager.instance.playerViewY; - GL11.glRotatef(r, 0F, 1F, 0F); - GL11.glRotatef(-RenderManager.instance.playerViewX, 1F, 0F, 0F); + GL11.glPushMatrix(); + float r = 180.0F - RenderManager.instance.playerViewY; + GL11.glRotatef(r, 0F, 1F, 0F); + GL11.glRotatef(-RenderManager.instance.playerViewX, 1F, 0F, 0F); - float off = 0.25F; - GL11.glTranslatef(0F, off, 0F); - GL11.glRotated(time, 0F, 0F, 1F); - GL11.glTranslatef(0F, -off, 0F); + float off = 0.25F; + GL11.glTranslatef(0F, off, 0F); + GL11.glRotated(time, 0F, 0F, 1F); + GL11.glTranslatef(0F, -off, 0F); - mc.renderEngine.bindTexture(TextureMap.locationBlocksTexture); - ShaderHelper.useShader(ShaderHelper.halo); - func_77026_a(tessellator, iicon); - ShaderHelper.releaseShader(); + mc.renderEngine.bindTexture(TextureMap.locationBlocksTexture); + ShaderHelper.useShader(ShaderHelper.halo); + func_77026_a(tessellator, iicon); + ShaderHelper.releaseShader(); + + GL11.glPopMatrix(); + GL11.glColor4f(1F, 1F, 1F, 1F); + GL11.glDisable(GL11.GL_BLEND); + GL11.glDisable(GL12.GL_RESCALE_NORMAL); + GL11.glPopMatrix(); + } - GL11.glPopMatrix(); - GL11.glColor4f(1F, 1F, 1F, 1F); - GL11.glDisable(GL11.GL_BLEND); - GL11.glDisable(GL12.GL_RESCALE_NORMAL); - GL11.glPopMatrix(); - } + private void func_77026_a(Tessellator p_77026_1_, IIcon p_77026_2_) { + float f = p_77026_2_.getMinU(); + float f1 = p_77026_2_.getMaxU(); + float f2 = p_77026_2_.getMinV(); + float f3 = p_77026_2_.getMaxV(); + float size = f1 - f; + float pad = size / 8F; + f += pad; + f1 -= pad; + f2 += pad; + f3 -= pad; + + float f4 = 1.0F; + float f5 = 0.5F; + float f6 = 0.25F; - private void func_77026_a(Tessellator p_77026_1_, IIcon p_77026_2_) { - float f = p_77026_2_.getMinU(); - float f1 = p_77026_2_.getMaxU(); - float f2 = p_77026_2_.getMinV(); - float f3 = p_77026_2_.getMaxV(); - float size = f1 - f; - float pad = size / 8F; - f += pad; - f1 -= pad; - f2 += pad; - f3 -= pad; + p_77026_1_.startDrawingQuads(); + p_77026_1_.setNormal(0.0F, 1.0F, 0.0F); + p_77026_1_.setBrightness(240); + p_77026_1_.addVertexWithUV(0.0F - f5, 0.0F - f6, 0.0D, f, f3); + p_77026_1_.addVertexWithUV(f4 - f5, 0.0F - f6, 0.0D, f1, f3); + p_77026_1_.addVertexWithUV(f4 - f5, f4 - f6, 0.0D, f1, f2); + p_77026_1_.addVertexWithUV(0.0F - f5, f4 - f6, 0.0D, f, f2); + p_77026_1_.draw(); - float f4 = 1.0F; - float f5 = 0.5F; - float f6 = 0.25F; + } - p_77026_1_.startDrawingQuads(); - p_77026_1_.setNormal(0.0F, 1.0F, 0.0F); - p_77026_1_.setBrightness(240); - p_77026_1_.addVertexWithUV(0.0F - f5, 0.0F - f6, 0.0D, f, f3); - p_77026_1_.addVertexWithUV(f4 - f5, 0.0F - f6, 0.0D, f1, f3); - p_77026_1_.addVertexWithUV(f4 - f5, f4 - f6, 0.0D, f1, f2); - p_77026_1_.addVertexWithUV(0.0F - f5, f4 - f6, 0.0D, f, f2); - p_77026_1_.draw(); - } } diff --git a/src/main/java/vazkii/botania/client/render/tile/RenderTilePool.java b/src/main/java/vazkii/botania/client/render/tile/RenderTilePool.java index 90d067bb2f..d0395960bc 100644 --- a/src/main/java/vazkii/botania/client/render/tile/RenderTilePool.java +++ b/src/main/java/vazkii/botania/client/render/tile/RenderTilePool.java @@ -2,16 +2,17 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jan 26, 2014, 12:25:11 AM (GMT)] */ package vazkii.botania.client.render.tile; import java.awt.Color; import java.util.Random; + import net.minecraft.block.Block; import net.minecraft.client.Minecraft; import net.minecraft.client.renderer.Tessellator; @@ -22,8 +23,10 @@ import net.minecraft.tileentity.TileEntity; import net.minecraft.util.IIcon; import net.minecraft.util.ResourceLocation; + import org.lwjgl.opengl.GL11; import org.lwjgl.opengl.GL12; + import vazkii.botania.api.mana.IPoolOverlayProvider; import vazkii.botania.client.core.handler.ClientTickHandler; import vazkii.botania.client.core.handler.MultiblockRenderHandler; @@ -35,130 +38,129 @@ public class RenderTilePool extends TileEntitySpecialRenderer { - private static final ResourceLocation texture = new ResourceLocation(LibResources.MODEL_POOL); - private static final ResourceLocation textureInf = new ResourceLocation(LibResources.MODEL_INFINITE_POOL); - private static final ResourceLocation textureDil = new ResourceLocation(LibResources.MODEL_DILUTED_POOL); - - private static final ModelPool model = new ModelPool(); - RenderItem renderItem = new RenderItem(); - - public static int forceMeta = 0; - public static boolean forceMana = false; - public static int forceManaNumber = -1; - - @Override - public void renderTileEntityAt(TileEntity tileentity, double d0, double d1, double d2, float f) { - TilePool pool = (TilePool) tileentity; - - GL11.glPushMatrix(); - GL11.glEnable(GL11.GL_BLEND); - GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); - GL11.glEnable(GL12.GL_RESCALE_NORMAL); - float a = MultiblockRenderHandler.rendering ? 0.6F : 1F; - GL11.glColor4f(1F, 1F, 1F, a); - GL11.glTranslated(d0, d1, d2); - boolean inf = tileentity.getWorldObj() == null ? forceMeta == 1 : tileentity.getBlockMetadata() == 1; - boolean dil = tileentity.getWorldObj() == null ? forceMeta == 2 : tileentity.getBlockMetadata() == 2; - boolean fab = tileentity.getWorldObj() == null ? forceMeta == 3 : tileentity.getBlockMetadata() == 3; - - Minecraft.getMinecraft().renderEngine.bindTexture(inf ? textureInf : dil ? textureDil : texture); - - GL11.glTranslatef(0.5F, 1.5F, 0.5F); - GL11.glScalef(1F, -1F, -1F); - if (fab) { - float time = ClientTickHandler.ticksInGame + ClientTickHandler.partialTicks; - if (tileentity != null) - time += new Random(tileentity.xCoord ^ tileentity.yCoord ^ tileentity.zCoord).nextInt(100000); - - Color color = Color.getHSBColor(time * 0.005F, 0.6F, 1F); - GL11.glColor4ub((byte) color.getRed(), (byte) color.getGreen(), (byte) color.getBlue(), (byte) 255); - } else { - int color = pool.color; - float[] acolor = EntitySheep.fleeceColorTable[color]; - GL11.glColor4f(acolor[0], acolor[1], acolor[2], a); - } - - model.render(); - GL11.glColor4f(1F, 1F, 1F, a); - GL11.glScalef(1F, -1F, -1F); - GL11.glEnable(GL12.GL_RESCALE_NORMAL); - - Minecraft.getMinecraft().renderEngine.bindTexture(TextureMap.locationBlocksTexture); - - int mana = pool.getCurrentMana(); - if (forceManaNumber > -1) mana = forceManaNumber; - int cap = pool.manaCap; - if (cap == -1) cap = TilePool.MAX_MANA; - - float waterLevel = (float) mana / (float) cap * 0.4F; - if (forceMana) waterLevel = 0.4F; - - float s = 1F / 16F; - float v = 1F / 8F; - float w = -v * 3.5F; - - if (pool.getWorldObj() != null) { - Block below = pool.getWorldObj().getBlock(pool.xCoord, pool.yCoord - 1, pool.zCoord); - if (below instanceof IPoolOverlayProvider) { - IIcon overlay = ((IPoolOverlayProvider) below) - .getIcon(pool.getWorldObj(), pool.xCoord, pool.yCoord - 1, pool.zCoord); - if (overlay != null) { - GL11.glPushMatrix(); - GL11.glEnable(GL11.GL_BLEND); - GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); - GL11.glDisable(GL11.GL_ALPHA_TEST); - GL11.glColor4f( - 1F, - 1F, - 1F, - a * (float) ((Math.sin((ClientTickHandler.ticksInGame + f) / 20.0) + 1) * 0.3 + 0.2)); - GL11.glTranslatef(-0.5F, -1F - 0.43F, -0.5F); - GL11.glRotatef(90F, 1F, 0F, 0F); - GL11.glScalef(s, s, s); - - renderIcon(0, 0, overlay, 16, 16, 240); - - GL11.glEnable(GL11.GL_ALPHA_TEST); - GL11.glDisable(GL11.GL_BLEND); - GL11.glPopMatrix(); - } - } - } - - if (waterLevel > 0) { - s = 1F / 256F * 14F; - GL11.glPushMatrix(); - GL11.glEnable(GL11.GL_BLEND); - GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); - GL11.glDisable(GL11.GL_ALPHA_TEST); - GL11.glColor4f(1F, 1F, 1F, a); - GL11.glTranslatef(w, -1F - (0.43F - waterLevel), w); - GL11.glRotatef(90F, 1F, 0F, 0F); - GL11.glScalef(s, s, s); - - ShaderHelper.useShader(ShaderHelper.manaPool); - renderIcon(0, 0, BlockPool.manaIcon, 16, 16, 240); - ShaderHelper.releaseShader(); - - GL11.glEnable(GL11.GL_ALPHA_TEST); - GL11.glDisable(GL11.GL_BLEND); - GL11.glPopMatrix(); - } - GL11.glPopMatrix(); - - forceMeta = 0; - forceMana = false; - forceManaNumber = -1; - } - - public void renderIcon(int par1, int par2, IIcon par3Icon, int par4, int par5, int brightness) { - Tessellator tessellator = Tessellator.instance; - tessellator.startDrawingQuads(); - tessellator.setBrightness(brightness); - tessellator.addVertexWithUV(par1 + 0, par2 + par5, 0, par3Icon.getMinU(), par3Icon.getMaxV()); - tessellator.addVertexWithUV(par1 + par4, par2 + par5, 0, par3Icon.getMaxU(), par3Icon.getMaxV()); - tessellator.addVertexWithUV(par1 + par4, par2 + 0, 0, par3Icon.getMaxU(), par3Icon.getMinV()); - tessellator.addVertexWithUV(par1 + 0, par2 + 0, 0, par3Icon.getMinU(), par3Icon.getMinV()); - tessellator.draw(); - } + private static final ResourceLocation texture = new ResourceLocation(LibResources.MODEL_POOL); + private static final ResourceLocation textureInf = new ResourceLocation(LibResources.MODEL_INFINITE_POOL); + private static final ResourceLocation textureDil = new ResourceLocation(LibResources.MODEL_DILUTED_POOL); + + private static final ModelPool model = new ModelPool(); + RenderItem renderItem = new RenderItem(); + + public static int forceMeta = 0; + public static boolean forceMana = false; + public static int forceManaNumber = -1; + + @Override + public void renderTileEntityAt(TileEntity tileentity, double d0, double d1, double d2, float f) { + TilePool pool = (TilePool) tileentity; + + GL11.glPushMatrix(); + GL11.glEnable(GL11.GL_BLEND); + GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); + GL11.glEnable(GL12.GL_RESCALE_NORMAL); + float a = MultiblockRenderHandler.rendering ? 0.6F : 1F; + GL11.glColor4f(1F, 1F, 1F, a); + GL11.glTranslated(d0, d1, d2); + boolean inf = tileentity.getWorldObj() == null ? forceMeta == 1 : tileentity.getBlockMetadata() == 1; + boolean dil = tileentity.getWorldObj() == null ? forceMeta == 2 : tileentity.getBlockMetadata() == 2; + boolean fab = tileentity.getWorldObj() == null ? forceMeta == 3 : tileentity.getBlockMetadata() == 3; + + Minecraft.getMinecraft().renderEngine.bindTexture(inf ? textureInf : dil ? textureDil : texture); + + GL11.glTranslatef(0.5F, 1.5F, 0.5F); + GL11.glScalef(1F, -1F, -1F); + if(fab) { + float time = ClientTickHandler.ticksInGame + ClientTickHandler.partialTicks; + if(tileentity != null) + time += new Random(tileentity.xCoord ^ tileentity.yCoord ^ tileentity.zCoord).nextInt(100000); + + Color color = Color.getHSBColor(time * 0.005F, 0.6F, 1F); + GL11.glColor4ub((byte) color.getRed(), (byte) color.getGreen(), (byte) color.getBlue(), (byte) 255); + } else { + int color = pool.color; + float[] acolor = EntitySheep.fleeceColorTable[color]; + GL11.glColor4f(acolor[0], acolor[1], acolor[2], a); + } + + model.render(); + GL11.glColor4f(1F, 1F, 1F, a); + GL11.glScalef(1F, -1F, -1F); + GL11.glEnable(GL12.GL_RESCALE_NORMAL); + + Minecraft.getMinecraft().renderEngine.bindTexture(TextureMap.locationBlocksTexture); + + int mana = pool.getCurrentMana(); + if(forceManaNumber > -1) + mana = forceManaNumber; + int cap = pool.manaCap; + if(cap == -1) + cap = TilePool.MAX_MANA; + + float waterLevel = (float) mana / (float) cap * 0.4F; + if(forceMana) + waterLevel = 0.4F; + + float s = 1F / 16F; + float v = 1F / 8F; + float w = -v * 3.5F; + + if(pool.getWorldObj() != null) { + Block below = pool.getWorldObj().getBlock(pool.xCoord, pool.yCoord - 1, pool.zCoord); + if(below instanceof IPoolOverlayProvider) { + IIcon overlay = ((IPoolOverlayProvider) below).getIcon(pool.getWorldObj(), pool.xCoord, pool.yCoord - 1, pool.zCoord); + if(overlay != null) { + GL11.glPushMatrix(); + GL11.glEnable(GL11.GL_BLEND); + GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); + GL11.glDisable(GL11.GL_ALPHA_TEST); + GL11.glColor4f(1F, 1F, 1F, a * (float) ((Math.sin((ClientTickHandler.ticksInGame + f) / 20.0) + 1) * 0.3 + 0.2)); + GL11.glTranslatef(-0.5F, -1F - 0.43F, -0.5F); + GL11.glRotatef(90F, 1F, 0F, 0F); + GL11.glScalef(s, s, s); + + renderIcon(0, 0, overlay, 16, 16, 240); + + GL11.glEnable(GL11.GL_ALPHA_TEST); + GL11.glDisable(GL11.GL_BLEND); + GL11.glPopMatrix(); + } + } + } + + if(waterLevel > 0) { + s = 1F / 256F * 14F; + GL11.glPushMatrix(); + GL11.glEnable(GL11.GL_BLEND); + GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); + GL11.glDisable(GL11.GL_ALPHA_TEST); + GL11.glColor4f(1F, 1F, 1F, a); + GL11.glTranslatef(w, -1F - (0.43F - waterLevel), w); + GL11.glRotatef(90F, 1F, 0F, 0F); + GL11.glScalef(s, s, s); + + ShaderHelper.useShader(ShaderHelper.manaPool); + renderIcon(0, 0, BlockPool.manaIcon, 16, 16, 240); + ShaderHelper.releaseShader(); + + GL11.glEnable(GL11.GL_ALPHA_TEST); + GL11.glDisable(GL11.GL_BLEND); + GL11.glPopMatrix(); + } + GL11.glPopMatrix(); + + forceMeta = 0; + forceMana = false; + forceManaNumber = -1; + } + + public void renderIcon(int par1, int par2, IIcon par3Icon, int par4, int par5, int brightness) { + Tessellator tessellator = Tessellator.instance; + tessellator.startDrawingQuads(); + tessellator.setBrightness(brightness); + tessellator.addVertexWithUV(par1 + 0, par2 + par5, 0, par3Icon.getMinU(), par3Icon.getMaxV()); + tessellator.addVertexWithUV(par1 + par4, par2 + par5, 0, par3Icon.getMaxU(), par3Icon.getMaxV()); + tessellator.addVertexWithUV(par1 + par4, par2 + 0, 0, par3Icon.getMaxU(), par3Icon.getMinV()); + tessellator.addVertexWithUV(par1 + 0, par2 + 0, 0, par3Icon.getMinU(), par3Icon.getMinV()); + tessellator.draw(); + } + } diff --git a/src/main/java/vazkii/botania/client/render/tile/RenderTilePrism.java b/src/main/java/vazkii/botania/client/render/tile/RenderTilePrism.java index 3cfcb3125d..e1c95c37cf 100644 --- a/src/main/java/vazkii/botania/client/render/tile/RenderTilePrism.java +++ b/src/main/java/vazkii/botania/client/render/tile/RenderTilePrism.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jan 17, 2015, 8:05:07 PM (GMT)] */ package vazkii.botania.client.render.tile; @@ -15,7 +15,9 @@ import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer; import net.minecraft.item.ItemStack; import net.minecraft.tileentity.TileEntity; + import org.lwjgl.opengl.GL11; + import vazkii.botania.api.mana.ILens; import vazkii.botania.client.core.handler.ClientTickHandler; import vazkii.botania.client.render.item.RenderLens; @@ -23,27 +25,27 @@ public class RenderTilePrism extends TileEntitySpecialRenderer { - @Override - public void renderTileEntityAt(TileEntity tile, double x, double y, double z, float partTicks) { - TilePrism prism = (TilePrism) tile; - GL11.glPushMatrix(); - GL11.glTranslated(x, y, z); - float pos = - (float) Math.sin((ClientTickHandler.ticksInGame + partTicks) * 0.05F) * 0.5F * (1F - 1F / 16F) - 0.5F; - - ItemStack stack = prism.getStackInSlot(0); - - if (stack != null) { - Minecraft.getMinecraft().renderEngine.bindTexture(TextureMap.locationItemsTexture); - if (stack.getItem() instanceof ILens) { - ILens lens = (ILens) stack.getItem(); - GL11.glPushMatrix(); - GL11.glRotatef(90F, 1F, 0F, 0F); - GL11.glTranslatef(0F, 0F, pos); - RenderLens.render(stack, lens.getLensColor(stack)); - GL11.glPopMatrix(); - } - } - GL11.glPopMatrix(); - } + @Override + public void renderTileEntityAt(TileEntity tile, double x, double y, double z, float partTicks) { + TilePrism prism = (TilePrism) tile; + GL11.glPushMatrix(); + GL11.glTranslated(x, y, z); + float pos = (float) Math.sin((ClientTickHandler.ticksInGame + partTicks) * 0.05F) * 0.5F * (1F - 1F / 16F) - 0.5F; + + ItemStack stack = prism.getStackInSlot(0); + + if(stack != null) { + Minecraft.getMinecraft().renderEngine.bindTexture(TextureMap.locationItemsTexture); + if(stack.getItem() instanceof ILens) { + ILens lens = (ILens) stack.getItem(); + GL11.glPushMatrix(); + GL11.glRotatef(90F, 1F, 0F, 0F); + GL11.glTranslatef(0F, 0F, pos); + RenderLens.render(stack, lens.getLensColor(stack)); + GL11.glPopMatrix(); + } + } + GL11.glPopMatrix(); + } + } diff --git a/src/main/java/vazkii/botania/client/render/tile/RenderTilePump.java b/src/main/java/vazkii/botania/client/render/tile/RenderTilePump.java index 4429fbe980..62e5611775 100644 --- a/src/main/java/vazkii/botania/client/render/tile/RenderTilePump.java +++ b/src/main/java/vazkii/botania/client/render/tile/RenderTilePump.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Mar 18, 2015, 3:15:38 PM (GMT)] */ package vazkii.botania.client.render.tile; @@ -14,38 +14,43 @@ import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.ResourceLocation; + import org.lwjgl.opengl.GL11; import org.lwjgl.opengl.GL12; + import vazkii.botania.client.lib.LibResources; import vazkii.botania.client.model.ModelPump; import vazkii.botania.common.block.tile.mana.TilePump; public class RenderTilePump extends TileEntitySpecialRenderer { - private static final float[] ROTATIONS = new float[] {180F, 0F, 90F, 270F}; + private static final float[] ROTATIONS = new float[] { + 180F, 0F, 90F, 270F + }; + + private static final ResourceLocation texture = new ResourceLocation(LibResources.MODEL_PUMP); + private static final ModelPump model = new ModelPump(); - private static final ResourceLocation texture = new ResourceLocation(LibResources.MODEL_PUMP); - private static final ModelPump model = new ModelPump(); + @Override + public void renderTileEntityAt(TileEntity tileentity, double d0, double d1, double d2, float f) { + TilePump pump = (TilePump) tileentity; - @Override - public void renderTileEntityAt(TileEntity tileentity, double d0, double d1, double d2, float f) { - TilePump pump = (TilePump) tileentity; + GL11.glPushMatrix(); + GL11.glEnable(GL12.GL_RESCALE_NORMAL); + GL11.glColor4f(1F, 1F, 1F, 1F); + GL11.glTranslated(d0, d1, d2); - GL11.glPushMatrix(); - GL11.glEnable(GL12.GL_RESCALE_NORMAL); - GL11.glColor4f(1F, 1F, 1F, 1F); - GL11.glTranslated(d0, d1, d2); + Minecraft.getMinecraft().renderEngine.bindTexture(texture); + int meta = pump.getWorldObj() != null ? pump.getBlockMetadata() : 0; - Minecraft.getMinecraft().renderEngine.bindTexture(texture); - int meta = pump.getWorldObj() != null ? pump.getBlockMetadata() : 0; + GL11.glTranslatef(0.5F, 0.5F, 0.5F); + GL11.glScalef(1F, -1F, -1F); + GL11.glRotatef(ROTATIONS[Math.max(Math.min(ROTATIONS.length - 1, meta - 2), 0)], 0F, 1F, 0F); + model.render(Math.max(0F, Math.min(8F, pump.innerRingPos + pump.moving * f))); + GL11.glColor3f(1F, 1F, 1F); + GL11.glScalef(1F, -1F, -1F); + GL11.glEnable(GL12.GL_RESCALE_NORMAL); + GL11.glPopMatrix(); + } - GL11.glTranslatef(0.5F, 0.5F, 0.5F); - GL11.glScalef(1F, -1F, -1F); - GL11.glRotatef(ROTATIONS[Math.max(Math.min(ROTATIONS.length - 1, meta - 2), 0)], 0F, 1F, 0F); - model.render(Math.max(0F, Math.min(8F, pump.innerRingPos + pump.moving * f))); - GL11.glColor3f(1F, 1F, 1F); - GL11.glScalef(1F, -1F, -1F); - GL11.glEnable(GL12.GL_RESCALE_NORMAL); - GL11.glPopMatrix(); - } } diff --git a/src/main/java/vazkii/botania/client/render/tile/RenderTilePylon.java b/src/main/java/vazkii/botania/client/render/tile/RenderTilePylon.java index 001b0e0917..209fe9596d 100644 --- a/src/main/java/vazkii/botania/client/render/tile/RenderTilePylon.java +++ b/src/main/java/vazkii/botania/client/render/tile/RenderTilePylon.java @@ -2,22 +2,25 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Feb 18, 2014, 10:18:36 PM (GMT)] */ package vazkii.botania.client.render.tile; import java.util.Random; + import net.minecraft.client.Minecraft; import net.minecraft.client.renderer.OpenGlHelper; import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.ResourceLocation; + import org.lwjgl.opengl.GL11; import org.lwjgl.opengl.GL12; + import vazkii.botania.client.core.handler.ClientTickHandler; import vazkii.botania.client.core.handler.MultiblockRenderHandler; import vazkii.botania.client.core.helper.ShaderHelper; @@ -29,102 +32,109 @@ public class RenderTilePylon extends TileEntitySpecialRenderer { - private static final ResourceLocation textureOld = new ResourceLocation(LibResources.MODEL_PYLON_OLD); - private static final ResourceLocation texture = new ResourceLocation(LibResources.MODEL_PYLON); - - private static final ResourceLocation textureGreenOld = new ResourceLocation(LibResources.MODEL_PYLON_GREEN_OLD); - private static final ResourceLocation textureGreen = new ResourceLocation(LibResources.MODEL_PYLON_GREEN); - - private static final ResourceLocation texturePinkOld = new ResourceLocation(LibResources.MODEL_PYLON_PINK_OLD); - private static final ResourceLocation texturePink = new ResourceLocation(LibResources.MODEL_PYLON_PINK); - - IPylonModel model; - public static boolean green = false; - public static boolean pink = false; - - @Override - public void renderTileEntityAt(TileEntity tileentity, double d0, double d1, double d2, float pticks) { - if (model == null) model = ConfigHandler.oldPylonModel ? new ModelPylonOld() : new ModelPylon(); - - GL11.glPushMatrix(); - GL11.glEnable(GL12.GL_RESCALE_NORMAL); - GL11.glEnable(GL11.GL_BLEND); - GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); - float a = MultiblockRenderHandler.rendering ? 0.6F : 1F; - GL11.glColor4f(1F, 1F, 1F, a); - if (tileentity.getWorldObj() != null) { - green = tileentity.getBlockMetadata() == 1; - pink = tileentity.getBlockMetadata() == 2; - } - - if (ConfigHandler.oldPylonModel) - Minecraft.getMinecraft() - .renderEngine - .bindTexture(pink ? texturePinkOld : green ? textureGreenOld : textureOld); - else Minecraft.getMinecraft().renderEngine.bindTexture(pink ? texturePink : green ? textureGreen : texture); - - double worldTime = tileentity.getWorldObj() == null ? 0 : (double) (ClientTickHandler.ticksInGame + pticks); - - if (tileentity != null) - worldTime += new Random(tileentity.xCoord ^ tileentity.yCoord ^ tileentity.zCoord).nextInt(360); - - if (ConfigHandler.oldPylonModel) { - GL11.glTranslated(d0 + 0.5, d1 + 2.2, d2 + 0.5); - GL11.glScalef(1F, -1.5F, -1F); - } else { - GL11.glTranslated(d0 + 0.2 + (green ? -0.1 : 0), d1 + 0.05, d2 + 0.8 + (green ? 0.1 : 0)); - float scale = green ? 0.8F : 0.6F; - GL11.glScalef(scale, 0.6F, scale); - } - - if (!green) { - GL11.glPushMatrix(); - if (!ConfigHandler.oldPylonModel) GL11.glTranslatef(0.5F, 0F, -0.5F); - GL11.glRotatef((float) worldTime * 1.5F, 0F, 1F, 0F); - if (!ConfigHandler.oldPylonModel) GL11.glTranslatef(-0.5F, 0F, 0.5F); - - model.renderRing(); - GL11.glTranslated(0D, Math.sin(worldTime / 20D) / 20 - 0.025, 0D); - model.renderGems(); - GL11.glPopMatrix(); - } - - GL11.glPushMatrix(); - GL11.glTranslated(0D, Math.sin(worldTime / 20D) / 17.5, 0D); - - if (!ConfigHandler.oldPylonModel) GL11.glTranslatef(0.5F, 0F, -0.5F); - - GL11.glRotatef((float) -worldTime, 0F, 1F, 0F); - if (!ConfigHandler.oldPylonModel) GL11.glTranslatef(-0.5F, 0F, 0.5F); - - GL11.glDisable(GL11.GL_CULL_FACE); - model.renderCrystal(); - - GL11.glColor4f(1F, 1F, 1F, a); - if (!ShaderHelper.useShaders()) { - int light = 15728880; - int lightmapX = light % 65536; - int lightmapY = light / 65536; - OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, lightmapX, lightmapY); - float alpha = (float) ((Math.sin(worldTime / 20D) / 2D + 0.5) / (ConfigHandler.oldPylonModel ? 1D : 2D)); - GL11.glColor4f(1F, 1F, 1F, a * (alpha + 0.183F)); - } - - GL11.glDisable(GL11.GL_ALPHA_TEST); - GL11.glScalef(1.1F, 1.1F, 1.1F); - if (!ConfigHandler.oldPylonModel) GL11.glTranslatef(-0.05F, -0.1F, 0.05F); - else GL11.glTranslatef(0F, -0.09F, 0F); - - ShaderHelper.useShader(ShaderHelper.pylonGlow); - model.renderCrystal(); - ShaderHelper.releaseShader(); - - GL11.glEnable(GL11.GL_ALPHA_TEST); - GL11.glEnable(GL11.GL_CULL_FACE); - GL11.glPopMatrix(); - - GL11.glDisable(GL11.GL_BLEND); - GL11.glEnable(GL12.GL_RESCALE_NORMAL); - GL11.glPopMatrix(); - } + private static final ResourceLocation textureOld = new ResourceLocation(LibResources.MODEL_PYLON_OLD); + private static final ResourceLocation texture = new ResourceLocation(LibResources.MODEL_PYLON); + + private static final ResourceLocation textureGreenOld = new ResourceLocation(LibResources.MODEL_PYLON_GREEN_OLD); + private static final ResourceLocation textureGreen = new ResourceLocation(LibResources.MODEL_PYLON_GREEN); + + private static final ResourceLocation texturePinkOld = new ResourceLocation(LibResources.MODEL_PYLON_PINK_OLD); + private static final ResourceLocation texturePink = new ResourceLocation(LibResources.MODEL_PYLON_PINK); + + IPylonModel model; + public static boolean green = false; + public static boolean pink = false; + + @Override + public void renderTileEntityAt(TileEntity tileentity, double d0, double d1, double d2, float pticks) { + if(model == null) + model = ConfigHandler.oldPylonModel ? new ModelPylonOld() : new ModelPylon(); + + GL11.glPushMatrix(); + GL11.glEnable(GL12.GL_RESCALE_NORMAL); + GL11.glEnable(GL11.GL_BLEND); + GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); + float a = MultiblockRenderHandler.rendering ? 0.6F : 1F; + GL11.glColor4f(1F, 1F, 1F, a); + if(tileentity.getWorldObj() != null) { + green = tileentity.getBlockMetadata() == 1; + pink = tileentity.getBlockMetadata() == 2; + } + + if(ConfigHandler.oldPylonModel) + Minecraft.getMinecraft().renderEngine.bindTexture(pink ? texturePinkOld : green ? textureGreenOld : textureOld); + else Minecraft.getMinecraft().renderEngine.bindTexture(pink ? texturePink : green ? textureGreen : texture); + + double worldTime = tileentity.getWorldObj() == null ? 0 : (double) (ClientTickHandler.ticksInGame + pticks); + + if(tileentity != null) + worldTime += new Random(tileentity.xCoord ^ tileentity.yCoord ^ tileentity.zCoord).nextInt(360); + + if(ConfigHandler.oldPylonModel) { + GL11.glTranslated(d0 + 0.5, d1 + 2.2, d2 + 0.5); + GL11.glScalef(1F, -1.5F, -1F); + } else { + GL11.glTranslated(d0 + 0.2 + (green ? -0.1 : 0), d1 + 0.05, d2 + 0.8 + (green ? 0.1 : 0)); + float scale = green ? 0.8F : 0.6F; + GL11.glScalef(scale, 0.6F, scale); + } + + if(!green) { + GL11.glPushMatrix(); + if(!ConfigHandler.oldPylonModel) + GL11.glTranslatef(0.5F, 0F, -0.5F); + GL11.glRotatef((float) worldTime * 1.5F, 0F, 1F, 0F); + if(!ConfigHandler.oldPylonModel) + GL11.glTranslatef(-0.5F, 0F, 0.5F); + + model.renderRing(); + GL11.glTranslated(0D, Math.sin(worldTime / 20D) / 20 - 0.025, 0D); + model.renderGems(); + GL11.glPopMatrix(); + } + + GL11.glPushMatrix(); + GL11.glTranslated(0D, Math.sin(worldTime / 20D) / 17.5, 0D); + + if(!ConfigHandler.oldPylonModel) + GL11.glTranslatef(0.5F, 0F, -0.5F); + + GL11.glRotatef((float) -worldTime, 0F, 1F, 0F); + if(!ConfigHandler.oldPylonModel) + GL11.glTranslatef(-0.5F, 0F, 0.5F); + + + GL11.glDisable(GL11.GL_CULL_FACE); + model.renderCrystal(); + + GL11.glColor4f(1F, 1F, 1F, a); + if(!ShaderHelper.useShaders()) { + int light = 15728880; + int lightmapX = light % 65536; + int lightmapY = light / 65536; + OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, lightmapX, lightmapY); + float alpha = (float) ((Math.sin(worldTime / 20D) / 2D + 0.5) / (ConfigHandler.oldPylonModel ? 1D : 2D)); + GL11.glColor4f(1F, 1F, 1F, a * (alpha + 0.183F)); + } + + GL11.glDisable(GL11.GL_ALPHA_TEST); + GL11.glScalef(1.1F, 1.1F, 1.1F); + if(!ConfigHandler.oldPylonModel) + GL11.glTranslatef(-0.05F, -0.1F, 0.05F); + else GL11.glTranslatef(0F, -0.09F, 0F); + + ShaderHelper.useShader(ShaderHelper.pylonGlow); + model.renderCrystal(); + ShaderHelper.releaseShader(); + + GL11.glEnable(GL11.GL_ALPHA_TEST); + GL11.glEnable(GL11.GL_CULL_FACE); + GL11.glPopMatrix(); + + GL11.glDisable(GL11.GL_BLEND); + GL11.glEnable(GL12.GL_RESCALE_NORMAL); + GL11.glPopMatrix(); + } + + } diff --git a/src/main/java/vazkii/botania/client/render/tile/RenderTileRedString.java b/src/main/java/vazkii/botania/client/render/tile/RenderTileRedString.java index ecfb07a829..24910351c5 100644 --- a/src/main/java/vazkii/botania/client/render/tile/RenderTileRedString.java +++ b/src/main/java/vazkii/botania/client/render/tile/RenderTileRedString.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Nov 14, 2014, 6:52:09 PM (GMT)] */ package vazkii.botania.client.render.tile; @@ -17,9 +17,10 @@ public class RenderTileRedString extends TileEntitySpecialRenderer { - @Override - public void renderTileEntityAt(TileEntity tileentity, double x, double y, double z, float partticks) { - TileRedString trs = (TileRedString) tileentity; - RedStringRenderer.redStringTiles.add(trs); - } + @Override + public void renderTileEntityAt(TileEntity tileentity, double x, double y, double z, float partticks) { + TileRedString trs = (TileRedString) tileentity; + RedStringRenderer.redStringTiles.add(trs); + } } + diff --git a/src/main/java/vazkii/botania/client/render/tile/RenderTileRuneAltar.java b/src/main/java/vazkii/botania/client/render/tile/RenderTileRuneAltar.java index 2ffd56bdc8..245c62cd91 100644 --- a/src/main/java/vazkii/botania/client/render/tile/RenderTileRuneAltar.java +++ b/src/main/java/vazkii/botania/client/render/tile/RenderTileRuneAltar.java @@ -2,15 +2,16 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Feb 2, 2014, 6:34:45 PM (GMT)] */ package vazkii.botania.client.render.tile; import java.awt.Color; + import net.minecraft.block.Block; import net.minecraft.client.Minecraft; import net.minecraft.client.renderer.ItemRenderer; @@ -24,7 +25,9 @@ import net.minecraft.tileentity.TileEntity; import net.minecraft.util.IIcon; import net.minecraftforge.client.ForgeHooksClient; + import org.lwjgl.opengl.GL11; + import vazkii.botania.client.core.handler.ClientTickHandler; import vazkii.botania.client.core.helper.RenderHelper; import vazkii.botania.client.model.ModelSpinningCubes; @@ -32,114 +35,93 @@ public class RenderTileRuneAltar extends TileEntitySpecialRenderer { - ModelSpinningCubes cubes = new ModelSpinningCubes(); - RenderBlocks renderBlocks = new RenderBlocks(); - - @Override - public void renderTileEntityAt(TileEntity tileentity, double x, double y, double z, float partticks) { - TileRuneAltar altar = (TileRuneAltar) tileentity; - - GL11.glPushMatrix(); - GL11.glColor4f(1F, 1F, 1F, 1F); - GL11.glTranslated(x, y, z); - - int items = 0; - for (int i = 0; i < altar.getSizeInventory(); i++) - if (altar.getStackInSlot(i) == null) break; - else items++; - float[] angles = new float[altar.getSizeInventory()]; - - float anglePer = 360F / items; - float totalAngle = 0F; - for (int i = 0; i < angles.length; i++) angles[i] = totalAngle += anglePer; - - double time = ClientTickHandler.ticksInGame + partticks; - - for (int i = 0; i < altar.getSizeInventory(); i++) { - GL11.glPushMatrix(); - GL11.glScalef(0.5F, 0.5F, 0.5F); - GL11.glTranslatef(1F, 2.5F, 1F); - GL11.glRotatef(angles[i] + (float) time, 0F, 1F, 0F); - GL11.glTranslatef(2.25F, 0F, 0.5F); - GL11.glRotatef(90F, 0F, 1F, 0F); - GL11.glTranslated(0D, 0.15 * Math.sin((time + i * 10) / 5D), 0F); - ItemStack stack = altar.getStackInSlot(i); - Minecraft mc = Minecraft.getMinecraft(); - if (stack != null) { - mc.renderEngine.bindTexture( - stack.getItem() instanceof ItemBlock - ? TextureMap.locationBlocksTexture - : TextureMap.locationItemsTexture); - - GL11.glScalef(2F, 2F, 2F); - if (!ForgeHooksClient.renderEntityItem( - new EntityItem(altar.getWorldObj(), altar.xCoord, altar.yCoord, altar.zCoord, stack), - stack, - 0F, - 0F, - altar.getWorldObj().rand, - mc.renderEngine, - renderBlocks, - 1)) { - GL11.glScalef(0.5F, 0.5F, 0.5F); - if (stack.getItem() instanceof ItemBlock - && RenderBlocks.renderItemIn3d( - Block.getBlockFromItem(stack.getItem()).getRenderType())) { - GL11.glScalef(0.5F, 0.5F, 0.5F); - GL11.glTranslatef(1F, 1.1F, 0F); - renderBlocks.renderBlockAsItem( - Block.getBlockFromItem(stack.getItem()), stack.getItemDamage(), 1F); - GL11.glTranslatef(-1F, -1.1F, 0F); - GL11.glScalef(2F, 2F, 2F); - } else { - int renderPass = 0; - do { - IIcon icon = stack.getItem().getIcon(stack, renderPass); - if (icon != null) { - Color color = new Color(stack.getItem().getColorFromItemStack(stack, renderPass)); - GL11.glColor3ub((byte) color.getRed(), (byte) color.getGreen(), (byte) color.getBlue()); - float f = icon.getMinU(); - float f1 = icon.getMaxU(); - float f2 = icon.getMinV(); - float f3 = icon.getMaxV(); - ItemRenderer.renderItemIn2D( - Tessellator.instance, - f1, - f2, - f, - f3, - icon.getIconWidth(), - icon.getIconHeight(), - 1F / 16F); - GL11.glColor3f(1F, 1F, 1F); - } - renderPass++; - } while (renderPass < stack.getItem().getRenderPasses(stack.getItemDamage())); - } - } - } - GL11.glPopMatrix(); - } - - GL11.glDisable(GL11.GL_ALPHA_TEST); - GL11.glPushMatrix(); - GL11.glTranslatef(0.5F, 1.8F, 0.5F); - GL11.glRotatef(180F, 1F, 0F, 1F); - int repeat = 15; - cubes.renderSpinningCubes(2, repeat, repeat); - GL11.glPopMatrix(); - - GL11.glTranslatef(0F, 0.2F, 0F); - float scale = - altar.getTargetMana() == 0 ? 0 : (float) altar.getCurrentMana() / (float) altar.getTargetMana() / 75F; - - if (scale != 0) { - int seed = altar.xCoord ^ altar.yCoord ^ altar.zCoord; - GL11.glTranslatef(0.5F, 0.7F, 0.5F); - RenderHelper.renderStar(0x00E4D7, scale, scale, scale, seed); - } - GL11.glEnable(GL11.GL_ALPHA_TEST); - - GL11.glPopMatrix(); - } + ModelSpinningCubes cubes = new ModelSpinningCubes(); + RenderBlocks renderBlocks = new RenderBlocks(); + + @Override + public void renderTileEntityAt(TileEntity tileentity, double x, double y, double z, float partticks) { + TileRuneAltar altar = (TileRuneAltar) tileentity; + + GL11.glPushMatrix(); + GL11.glColor4f(1F, 1F, 1F, 1F); + GL11.glTranslated(x, y, z); + + int items = 0; + for(int i = 0; i < altar.getSizeInventory(); i++) + if(altar.getStackInSlot(i) == null) + break; + else items++; + float[] angles = new float[altar.getSizeInventory()]; + + float anglePer = 360F / items; + float totalAngle = 0F; + for(int i = 0; i < angles.length; i++) + angles[i] = totalAngle += anglePer; + + double time = ClientTickHandler.ticksInGame + partticks; + + for(int i = 0; i < altar.getSizeInventory(); i++) { + GL11.glPushMatrix(); + GL11.glScalef(0.5F, 0.5F, 0.5F); + GL11.glTranslatef(1F, 2.5F, 1F); + GL11.glRotatef(angles[i] + (float) time, 0F, 1F, 0F); + GL11.glTranslatef(2.25F, 0F, 0.5F); + GL11.glRotatef(90F, 0F, 1F, 0F); + GL11.glTranslated(0D, 0.15 * Math.sin((time + i * 10) / 5D), 0F); + ItemStack stack = altar.getStackInSlot(i); + Minecraft mc = Minecraft.getMinecraft(); + if(stack != null) { + mc.renderEngine.bindTexture(stack.getItem() instanceof ItemBlock ? TextureMap.locationBlocksTexture : TextureMap.locationItemsTexture); + + GL11.glScalef(2F, 2F, 2F); + if(!ForgeHooksClient.renderEntityItem(new EntityItem(altar.getWorldObj(), altar.xCoord, altar.yCoord, altar.zCoord, stack), stack, 0F, 0F, altar.getWorldObj().rand, mc.renderEngine, renderBlocks, 1)) { + GL11.glScalef(0.5F, 0.5F, 0.5F); + if(stack.getItem() instanceof ItemBlock && RenderBlocks.renderItemIn3d(Block.getBlockFromItem(stack.getItem()).getRenderType())) { + GL11.glScalef(0.5F, 0.5F, 0.5F); + GL11.glTranslatef(1F, 1.1F, 0F); + renderBlocks.renderBlockAsItem(Block.getBlockFromItem(stack.getItem()), stack.getItemDamage(), 1F); + GL11.glTranslatef(-1F, -1.1F, 0F); + GL11.glScalef(2F, 2F, 2F); + } else { + int renderPass = 0; + do { + IIcon icon = stack.getItem().getIcon(stack, renderPass); + if(icon != null) { + Color color = new Color(stack.getItem().getColorFromItemStack(stack, renderPass)); + GL11.glColor3ub((byte) color.getRed(), (byte) color.getGreen(), (byte) color.getBlue()); + float f = icon.getMinU(); + float f1 = icon.getMaxU(); + float f2 = icon.getMinV(); + float f3 = icon.getMaxV(); + ItemRenderer.renderItemIn2D(Tessellator.instance, f1, f2, f, f3, icon.getIconWidth(), icon.getIconHeight(), 1F / 16F); + GL11.glColor3f(1F, 1F, 1F); + } + renderPass++; + } while(renderPass < stack.getItem().getRenderPasses(stack.getItemDamage())); + } + } + } + GL11.glPopMatrix(); + } + + GL11.glDisable(GL11.GL_ALPHA_TEST); + GL11.glPushMatrix(); + GL11.glTranslatef(0.5F, 1.8F, 0.5F); + GL11.glRotatef(180F, 1F, 0F, 1F); + int repeat = 15; + cubes.renderSpinningCubes(2, repeat, repeat); + GL11.glPopMatrix(); + + GL11.glTranslatef(0F, 0.2F, 0F); + float scale = altar.getTargetMana() == 0 ? 0 : (float) altar.getCurrentMana() / (float) altar.getTargetMana() / 75F; + + if(scale != 0) { + int seed = altar.xCoord ^ altar.yCoord ^ altar.zCoord; + GL11.glTranslatef(0.5F, 0.7F, 0.5F); + RenderHelper.renderStar(0x00E4D7, scale, scale, scale, seed); + } + GL11.glEnable(GL11.GL_ALPHA_TEST); + + GL11.glPopMatrix(); + } } diff --git a/src/main/java/vazkii/botania/client/render/tile/RenderTileSkullOverride.java b/src/main/java/vazkii/botania/client/render/tile/RenderTileSkullOverride.java index c89e8d75d3..5d49f06fe6 100644 --- a/src/main/java/vazkii/botania/client/render/tile/RenderTileSkullOverride.java +++ b/src/main/java/vazkii/botania/client/render/tile/RenderTileSkullOverride.java @@ -2,108 +2,90 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [? (GMT)] */ package vazkii.botania.client.render.tile; -import com.mojang.authlib.GameProfile; -import com.mojang.authlib.minecraft.MinecraftProfileTexture; import java.util.Map; + import net.minecraft.client.Minecraft; import net.minecraft.client.entity.AbstractClientPlayer; import net.minecraft.client.renderer.tileentity.TileEntitySkullRenderer; import net.minecraft.tileentity.TileEntitySkull; import net.minecraft.util.ResourceLocation; + import org.lwjgl.opengl.GL11; import org.lwjgl.opengl.GL12; + import vazkii.botania.client.core.helper.ShaderHelper; import vazkii.botania.client.model.ModelSkullOverride; import vazkii.botania.client.render.entity.RenderDoppleganger; import vazkii.botania.common.block.tile.TileGaiaHead; +import com.mojang.authlib.GameProfile; +import com.mojang.authlib.minecraft.MinecraftProfileTexture; + public class RenderTileSkullOverride extends TileEntitySkullRenderer { - public static final ModelSkullOverride modelSkull = new ModelSkullOverride(); + public static final ModelSkullOverride modelSkull = new ModelSkullOverride(); - @Override - public void renderTileEntityAt( - TileEntitySkull p_147500_1_, - double p_147500_2_, - double p_147500_4_, - double p_147500_6_, - float p_147500_8_) { - render( - p_147500_1_, - (float) p_147500_2_, - (float) p_147500_4_, - (float) p_147500_6_, - p_147500_1_.getBlockMetadata() & 7, - p_147500_1_.func_145906_b() * 360 / 16.0F, - p_147500_1_.func_145904_a(), - p_147500_1_.func_152108_a()); - } + @Override + public void renderTileEntityAt(TileEntitySkull p_147500_1_, double p_147500_2_, double p_147500_4_, double p_147500_6_, float p_147500_8_) { + render(p_147500_1_, (float) p_147500_2_, (float) p_147500_4_, (float) p_147500_6_, p_147500_1_.getBlockMetadata() & 7, p_147500_1_.func_145906_b() * 360 / 16.0F, p_147500_1_.func_145904_a(), p_147500_1_.func_152108_a()); + } - public void render( - TileEntitySkull skull, - float par1, - float par2, - float par3, - int par4, - float par5, - int par6, - GameProfile gameProfile) { - boolean gaia = skull instanceof TileGaiaHead; - if (par6 == 3 || gaia) { - ResourceLocation resourcelocation = AbstractClientPlayer.locationStevePng; - Minecraft minecraft = Minecraft.getMinecraft(); - if (gaia) resourcelocation = minecraft.thePlayer.getLocationSkin(); - else if (gameProfile != null) { - Map map = minecraft.func_152342_ad().func_152788_a(gameProfile); + public void render(TileEntitySkull skull, float par1, float par2, float par3, int par4, float par5, int par6, GameProfile gameProfile) { + boolean gaia = skull instanceof TileGaiaHead; + if(par6 == 3 || gaia) { + ResourceLocation resourcelocation = AbstractClientPlayer.locationStevePng; + Minecraft minecraft = Minecraft.getMinecraft(); + if(gaia) + resourcelocation = minecraft.thePlayer.getLocationSkin(); + else if(gameProfile != null) { + Map map = minecraft.func_152342_ad().func_152788_a(gameProfile); - if (map.containsKey(MinecraftProfileTexture.Type.SKIN)) { - resourcelocation = minecraft - .func_152342_ad() - .func_152792_a( - (MinecraftProfileTexture) map.get(MinecraftProfileTexture.Type.SKIN), - MinecraftProfileTexture.Type.SKIN); - } - } - bindTexture(resourcelocation); - GL11.glPushMatrix(); - GL11.glDisable(GL11.GL_CULL_FACE); - if (par4 != 1) { - switch (par4) { - case 2: - GL11.glTranslatef(par1 + 0.5F, par2 + 0.25F, par3 + 0.74F); - break; - case 3: - GL11.glTranslatef(par1 + 0.5F, par2 + 0.25F, par3 + 0.26F); - par5 = 180.0F; - break; - case 4: - GL11.glTranslatef(par1 + 0.74F, par2 + 0.25F, par3 + 0.5F); - par5 = 270.0F; - break; - case 5: - default: - GL11.glTranslatef(par1 + 0.26F, par2 + 0.25F, par3 + 0.5F); - par5 = 90.0F; - } - } else GL11.glTranslatef(par1 + 0.5F, par2, par3 + 0.5F); + if (map.containsKey(MinecraftProfileTexture.Type.SKIN)) { + resourcelocation = minecraft.func_152342_ad().func_152792_a((MinecraftProfileTexture)map.get(MinecraftProfileTexture.Type.SKIN), MinecraftProfileTexture.Type.SKIN); + } + } + bindTexture(resourcelocation); + GL11.glPushMatrix(); + GL11.glDisable(GL11.GL_CULL_FACE); + if (par4 != 1) { + switch (par4) { + case 2: + GL11.glTranslatef(par1 + 0.5F, par2 + 0.25F, par3 + 0.74F); + break; + case 3: + GL11.glTranslatef(par1 + 0.5F, par2 + 0.25F, par3 + 0.26F); + par5 = 180.0F; + break; + case 4: + GL11.glTranslatef(par1 + 0.74F, par2 + 0.25F, par3 + 0.5F); + par5 = 270.0F; + break; + case 5: + default: + GL11.glTranslatef(par1 + 0.26F, par2 + 0.25F, par3 + 0.5F); + par5 = 90.0F; + } + } else GL11.glTranslatef(par1 + 0.5F, par2, par3 + 0.5F); - GL11.glEnable(GL12.GL_RESCALE_NORMAL); - GL11.glScalef(-1.0F, -1.0F, 1.0F); - GL11.glEnable(GL11.GL_ALPHA_TEST); - if (gaia) ShaderHelper.useShader(ShaderHelper.doppleganger, RenderDoppleganger.defaultCallback); + GL11.glEnable(GL12.GL_RESCALE_NORMAL); + GL11.glScalef(-1.0F, -1.0F, 1.0F); + GL11.glEnable(GL11.GL_ALPHA_TEST); + if(gaia) + ShaderHelper.useShader(ShaderHelper.doppleganger, RenderDoppleganger.defaultCallback); - modelSkull.render(null, 0F, 0F, 0F, par5, 0F, 0.0625F); + modelSkull.render(null, 0F, 0F, 0F, par5, 0F, 0.0625F); - if (gaia) ShaderHelper.releaseShader(); - GL11.glPopMatrix(); - } else super.func_152674_a(par1, par2, par3, par4, par5, par6, gameProfile); - } -} + if(gaia) + ShaderHelper.releaseShader(); + GL11.glPopMatrix(); + } else super.func_152674_a(par1, par2, par3, par4, par5, par6, gameProfile); + } +} \ No newline at end of file diff --git a/src/main/java/vazkii/botania/client/render/tile/RenderTileSparkChanger.java b/src/main/java/vazkii/botania/client/render/tile/RenderTileSparkChanger.java index f4cf4d5979..97188418e1 100644 --- a/src/main/java/vazkii/botania/client/render/tile/RenderTileSparkChanger.java +++ b/src/main/java/vazkii/botania/client/render/tile/RenderTileSparkChanger.java @@ -2,15 +2,16 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jun 28, 2015, 10:19:20 PM (GMT)] */ package vazkii.botania.client.render.tile; import java.awt.Color; + import net.minecraft.client.Minecraft; import net.minecraft.client.renderer.ItemRenderer; import net.minecraft.client.renderer.Tessellator; @@ -19,45 +20,47 @@ import net.minecraft.item.ItemStack; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.IIcon; + import org.lwjgl.opengl.GL11; + import vazkii.botania.common.block.tile.TileSparkChanger; public class RenderTileSparkChanger extends TileEntitySpecialRenderer { - @Override - public void renderTileEntityAt(TileEntity tileentity, double d0, double d1, double d2, float pticks) { - GL11.glPushMatrix(); - GL11.glTranslated(d0, d1, d2); - GL11.glRotated(90F, 1F, 0F, 0F); - GL11.glTranslatef(0.8F, 0.2F, -0.22F); - GL11.glColor4f(1F, 1F, 1F, 1F); - ItemStack stack = ((TileSparkChanger) tileentity).getStackInSlot(0); - if (stack != null) { - GL11.glPushMatrix(); - Minecraft.getMinecraft().renderEngine.bindTexture(TextureMap.locationItemsTexture); - float s = 0.6F; - GL11.glScalef(s, s, s); - GL11.glRotatef(180F, 0F, 1F, 0F); - - int renderPass = 0; - do { - IIcon icon = stack.getItem().getIcon(stack, renderPass); - if (icon != null) { - Color color = new Color(stack.getItem().getColorFromItemStack(stack, renderPass)); - GL11.glColor3ub((byte) color.getRed(), (byte) color.getGreen(), (byte) color.getBlue()); - float f = icon.getMinU(); - float f1 = icon.getMaxU(); - float f2 = icon.getMinV(); - float f3 = icon.getMaxV(); - ItemRenderer.renderItemIn2D( - Tessellator.instance, f1, f2, f, f3, icon.getIconWidth(), icon.getIconHeight(), 1F / 16F); - GL11.glColor3f(1F, 1F, 1F); - } - renderPass++; - } while (renderPass < stack.getItem().getRenderPasses(stack.getItemDamage())); - GL11.glPopMatrix(); - } - GL11.glColor4f(1F, 1F, 1F, 1F); - GL11.glPopMatrix(); - } + @Override + public void renderTileEntityAt(TileEntity tileentity, double d0, double d1, double d2, float pticks) { + GL11.glPushMatrix(); + GL11.glTranslated(d0, d1, d2); + GL11.glRotated(90F, 1F, 0F, 0F); + GL11.glTranslatef(0.8F, 0.2F, -0.22F); + GL11.glColor4f(1F, 1F, 1F, 1F); + ItemStack stack = ((TileSparkChanger) tileentity).getStackInSlot(0); + if(stack != null) { + GL11.glPushMatrix(); + Minecraft.getMinecraft().renderEngine.bindTexture(TextureMap.locationItemsTexture); + float s = 0.6F; + GL11.glScalef(s, s, s); + GL11.glRotatef(180F, 0F, 1F, 0F); + + int renderPass = 0; + do { + IIcon icon = stack.getItem().getIcon(stack, renderPass); + if(icon != null) { + Color color = new Color(stack.getItem().getColorFromItemStack(stack, renderPass)); + GL11.glColor3ub((byte) color.getRed(), (byte) color.getGreen(), (byte) color.getBlue()); + float f = icon.getMinU(); + float f1 = icon.getMaxU(); + float f2 = icon.getMinV(); + float f3 = icon.getMaxV(); + ItemRenderer.renderItemIn2D(Tessellator.instance, f1, f2, f, f3, icon.getIconWidth(), icon.getIconHeight(), 1F / 16F); + GL11.glColor3f(1F, 1F, 1F); + } + renderPass++; + } while(renderPass < stack.getItem().getRenderPasses(stack.getItemDamage())); + GL11.glPopMatrix(); + } + GL11.glColor4f(1F, 1F, 1F, 1F); + GL11.glPopMatrix(); + } + } diff --git a/src/main/java/vazkii/botania/client/render/tile/RenderTileSpawnerClaw.java b/src/main/java/vazkii/botania/client/render/tile/RenderTileSpawnerClaw.java index c2df14d6aa..92628dc63d 100644 --- a/src/main/java/vazkii/botania/client/render/tile/RenderTileSpawnerClaw.java +++ b/src/main/java/vazkii/botania/client/render/tile/RenderTileSpawnerClaw.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jul 23, 2014, 5:46:10 PM (GMT)] */ package vazkii.botania.client.render.tile; @@ -14,31 +14,34 @@ import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.ResourceLocation; + import org.lwjgl.opengl.GL11; import org.lwjgl.opengl.GL12; + import vazkii.botania.client.lib.LibResources; import vazkii.botania.client.model.ModelSpawnerClaw; public class RenderTileSpawnerClaw extends TileEntitySpecialRenderer { - private static final ResourceLocation texture = new ResourceLocation(LibResources.MODEL_SPAWNER_CLAW); - private static final ModelSpawnerClaw model = new ModelSpawnerClaw(); + private static final ResourceLocation texture = new ResourceLocation(LibResources.MODEL_SPAWNER_CLAW); + private static final ModelSpawnerClaw model = new ModelSpawnerClaw(); + + @Override + public void renderTileEntityAt(TileEntity var1, double d0, double d1, double d2, float var8) { + GL11.glPushMatrix(); + GL11.glEnable(GL12.GL_RESCALE_NORMAL); + GL11.glColor4f(1F, 1F, 1F, 1F); + GL11.glTranslated(d0, d1, d2); - @Override - public void renderTileEntityAt(TileEntity var1, double d0, double d1, double d2, float var8) { - GL11.glPushMatrix(); - GL11.glEnable(GL12.GL_RESCALE_NORMAL); - GL11.glColor4f(1F, 1F, 1F, 1F); - GL11.glTranslated(d0, d1, d2); + Minecraft.getMinecraft().renderEngine.bindTexture(texture); - Minecraft.getMinecraft().renderEngine.bindTexture(texture); + GL11.glTranslatef(0.5F, 1.5F, 0.5F); + GL11.glScalef(1F, -1F, -1F); - GL11.glTranslatef(0.5F, 1.5F, 0.5F); - GL11.glScalef(1F, -1F, -1F); + model.render(); + GL11.glColor3f(1F, 1F, 1F); + GL11.glScalef(1F, -1F, -1F); + GL11.glPopMatrix(); + } - model.render(); - GL11.glColor3f(1F, 1F, 1F); - GL11.glScalef(1F, -1F, -1F); - GL11.glPopMatrix(); - } } diff --git a/src/main/java/vazkii/botania/client/render/tile/RenderTileSpreader.java b/src/main/java/vazkii/botania/client/render/tile/RenderTileSpreader.java index 7f38185507..e13a116c7c 100644 --- a/src/main/java/vazkii/botania/client/render/tile/RenderTileSpreader.java +++ b/src/main/java/vazkii/botania/client/render/tile/RenderTileSpreader.java @@ -2,16 +2,17 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jan 25, 2014, 9:42:31 PM (GMT)] */ package vazkii.botania.client.render.tile; import java.awt.Color; import java.util.Random; + import net.minecraft.block.Block; import net.minecraft.client.Minecraft; import net.minecraft.client.renderer.RenderBlocks; @@ -21,8 +22,10 @@ import net.minecraft.item.ItemStack; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.ResourceLocation; + import org.lwjgl.opengl.GL11; import org.lwjgl.opengl.GL12; + import vazkii.botania.api.mana.ILens; import vazkii.botania.client.core.handler.ClientTickHandler; import vazkii.botania.client.core.proxy.ClientProxy; @@ -33,103 +36,94 @@ public class RenderTileSpreader extends TileEntitySpecialRenderer { - private static final ResourceLocation texture = new ResourceLocation(LibResources.MODEL_SPREADER); - private static final ResourceLocation textureRs = new ResourceLocation(LibResources.MODEL_SPREADER_REDSTONE); - private static final ResourceLocation textureDw = new ResourceLocation(LibResources.MODEL_SPREADER_DREAMWOOD); - - private static final ResourceLocation textureHalloween = - new ResourceLocation(LibResources.MODEL_SPREADER_HALLOWEEN); - private static final ResourceLocation textureRsHalloween = - new ResourceLocation(LibResources.MODEL_SPREADER_REDSTONE_HALLOWEEN); - private static final ResourceLocation textureDwHalloween = - new ResourceLocation(LibResources.MODEL_SPREADER_DREAMWOOD_HALLOWEEN); - - private static final ModelSpreader model = new ModelSpreader(); - - @Override - public void renderTileEntityAt(TileEntity tileentity, double d0, double d1, double d2, float ticks) { - TileSpreader spreader = (TileSpreader) tileentity; - GL11.glPushMatrix(); - GL11.glEnable(GL12.GL_RESCALE_NORMAL); - GL11.glColor4f(1F, 1F, 1F, 1F); - GL11.glTranslated(d0, d1, d2); - - GL11.glTranslatef(0.5F, 1.5F, 0.5F); - GL11.glRotatef(spreader.rotationX + 90F, 0F, 1F, 0F); - GL11.glTranslatef(0F, -1F, 0F); - GL11.glRotatef(spreader.rotationY, 1F, 0F, 0F); - GL11.glTranslatef(0F, 1F, 0F); - - ResourceLocation r = spreader.isRedstone() ? textureRs : spreader.isDreamwood() ? textureDw : texture; - if (ClientProxy.dootDoot) - r = spreader.isRedstone() - ? textureRsHalloween - : spreader.isDreamwood() ? textureDwHalloween : textureHalloween; - - Minecraft.getMinecraft().renderEngine.bindTexture(r); - GL11.glScalef(1F, -1F, -1F); - - double time = ClientTickHandler.ticksInGame + ticks; - - if (spreader.isULTRA_SPREADER()) { - Color color = Color.getHSBColor( - (float) ((time * 5 + new Random(spreader.xCoord ^ spreader.yCoord ^ spreader.zCoord).nextInt(10000)) - % 360) - / 360F, - 0.4F, - 0.9F); - GL11.glColor3f(color.getRed() / 255F, color.getGreen() / 255F, color.getBlue() / 255F); - } - model.render(); - GL11.glColor3f(1F, 1F, 1F); - - GL11.glPushMatrix(); - double worldTicks = tileentity.getWorldObj() == null ? 0 : time; - GL11.glRotatef((float) worldTicks % 360, 0F, 1F, 0F); - GL11.glTranslatef(0F, (float) Math.sin(worldTicks / 20.0) * 0.05F, 0F); - model.renderCube(); - GL11.glPopMatrix(); - GL11.glScalef(1F, -1F, -1F); - ItemStack stack = spreader.getStackInSlot(0); - - if (stack != null) { - Minecraft.getMinecraft().renderEngine.bindTexture(TextureMap.locationItemsTexture); - ILens lens = (ILens) stack.getItem(); - GL11.glPushMatrix(); - GL11.glTranslatef(-0.4F, -1.4F, -0.4375F); - GL11.glScalef(0.8F, 0.8F, 0.8F); - RenderLens.render(stack, lens.getLensColor(stack)); - GL11.glPopMatrix(); - } - - if (spreader.paddingColor != -1) { - Minecraft.getMinecraft().renderEngine.bindTexture(TextureMap.locationBlocksTexture); - - Block block = Blocks.carpet; - int color = spreader.paddingColor; - RenderBlocks render = RenderBlocks.getInstance(); - float f = 1F / 16F; - GL11.glTranslatef(0F, -f, 0F); - render.renderBlockAsItem(block, color, 1F); - GL11.glTranslatef(0F, -f * 15, 0F); - render.renderBlockAsItem(block, color, 1F); - GL11.glRotatef(90F, 1F, 0F, 0F); - GL11.glRotatef(90F, 0F, 1F, 0F); - - GL11.glPushMatrix(); - GL11.glScalef(f * 14F, 1F, 1F); - render.renderBlockAsItem(block, color, 1F); - GL11.glPopMatrix(); - - GL11.glRotatef(90F, 1F, 0F, 0F); - GL11.glTranslatef(0F, 0F, -f / 2); - GL11.glScalef(f * 14F, 1F, f * 15F); - render.renderBlockAsItem(block, color, 1F); - GL11.glTranslatef(0F, f * 15F, 0F); - render.renderBlockAsItem(block, color, 1F); - } - - GL11.glEnable(GL12.GL_RESCALE_NORMAL); - GL11.glPopMatrix(); - } + private static final ResourceLocation texture = new ResourceLocation(LibResources.MODEL_SPREADER); + private static final ResourceLocation textureRs = new ResourceLocation(LibResources.MODEL_SPREADER_REDSTONE); + private static final ResourceLocation textureDw = new ResourceLocation(LibResources.MODEL_SPREADER_DREAMWOOD); + + private static final ResourceLocation textureHalloween = new ResourceLocation(LibResources.MODEL_SPREADER_HALLOWEEN); + private static final ResourceLocation textureRsHalloween = new ResourceLocation(LibResources.MODEL_SPREADER_REDSTONE_HALLOWEEN); + private static final ResourceLocation textureDwHalloween = new ResourceLocation(LibResources.MODEL_SPREADER_DREAMWOOD_HALLOWEEN); + + private static final ModelSpreader model = new ModelSpreader(); + + @Override + public void renderTileEntityAt(TileEntity tileentity, double d0, double d1, double d2, float ticks) { + TileSpreader spreader = (TileSpreader) tileentity; + GL11.glPushMatrix(); + GL11.glEnable(GL12.GL_RESCALE_NORMAL); + GL11.glColor4f(1F, 1F, 1F, 1F); + GL11.glTranslated(d0, d1, d2); + + GL11.glTranslatef(0.5F, 1.5F, 0.5F); + GL11.glRotatef(spreader.rotationX + 90F, 0F, 1F, 0F); + GL11.glTranslatef(0F, -1F, 0F); + GL11.glRotatef(spreader.rotationY, 1F, 0F, 0F); + GL11.glTranslatef(0F, 1F, 0F); + + ResourceLocation r = spreader.isRedstone() ? textureRs : spreader.isDreamwood() ? textureDw : texture; + if(ClientProxy.dootDoot) + r = spreader.isRedstone() ? textureRsHalloween : spreader.isDreamwood() ? textureDwHalloween : textureHalloween; + + Minecraft.getMinecraft().renderEngine.bindTexture(r); + GL11.glScalef(1F, -1F, -1F); + + double time = ClientTickHandler.ticksInGame + ticks; + + if(spreader.isULTRA_SPREADER()) { + Color color = Color.getHSBColor((float) ((time * 5 + new Random(spreader.xCoord ^ spreader.yCoord ^ spreader.zCoord).nextInt(10000)) % 360) / 360F, 0.4F, 0.9F); + GL11.glColor3f(color.getRed() / 255F, color.getGreen() / 255F, color.getBlue() / 255F); + } + model.render(); + GL11.glColor3f(1F, 1F, 1F); + + GL11.glPushMatrix(); + double worldTicks = tileentity.getWorldObj() == null ? 0 : time; + GL11.glRotatef((float) worldTicks % 360, 0F, 1F, 0F); + GL11.glTranslatef(0F, (float) Math.sin(worldTicks / 20.0) * 0.05F, 0F); + model.renderCube(); + GL11.glPopMatrix(); + GL11.glScalef(1F, -1F, -1F); + ItemStack stack = spreader.getStackInSlot(0); + + if(stack != null) { + Minecraft.getMinecraft().renderEngine.bindTexture(TextureMap.locationItemsTexture); + ILens lens = (ILens) stack.getItem(); + GL11.glPushMatrix(); + GL11.glTranslatef(-0.4F, -1.4F, -0.4375F); + GL11.glScalef(0.8F, 0.8F, 0.8F); + RenderLens.render(stack, lens.getLensColor(stack)); + GL11.glPopMatrix(); + } + + if(spreader.paddingColor != -1) { + Minecraft.getMinecraft().renderEngine.bindTexture(TextureMap.locationBlocksTexture); + + Block block = Blocks.carpet; + int color = spreader.paddingColor; + RenderBlocks render = RenderBlocks.getInstance(); + float f = 1F / 16F; + GL11.glTranslatef(0F, -f, 0F); + render.renderBlockAsItem(block, color, 1F); + GL11.glTranslatef(0F, -f * 15, 0F); + render.renderBlockAsItem(block, color, 1F); + GL11.glRotatef(90F, 1F, 0F, 0F); + GL11.glRotatef(90F, 0F, 1F, 0F); + + GL11.glPushMatrix(); + GL11.glScalef(f * 14F, 1F, 1F); + render.renderBlockAsItem(block, color, 1F); + GL11.glPopMatrix(); + + GL11.glRotatef(90F, 1F, 0F, 0F); + GL11.glTranslatef(0F, 0F, -f / 2); + GL11.glScalef(f * 14F, 1F, f * 15F); + render.renderBlockAsItem(block, color, 1F); + GL11.glTranslatef(0F, f * 15F, 0F); + render.renderBlockAsItem(block, color, 1F); + } + + GL11.glEnable(GL12.GL_RESCALE_NORMAL); + GL11.glPopMatrix(); + } + } diff --git a/src/main/java/vazkii/botania/client/render/tile/RenderTileStarfield.java b/src/main/java/vazkii/botania/client/render/tile/RenderTileStarfield.java index 2ef22f8eca..b1991082ac 100644 --- a/src/main/java/vazkii/botania/client/render/tile/RenderTileStarfield.java +++ b/src/main/java/vazkii/botania/client/render/tile/RenderTileStarfield.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Aug 8, 2014, 2:38:15 PM (GMT)] */ package vazkii.botania.client.render.tile; @@ -13,6 +13,7 @@ import java.awt.Color; import java.nio.FloatBuffer; import java.util.Random; + import net.minecraft.client.Minecraft; import net.minecraft.client.renderer.ActiveRenderInfo; import net.minecraft.client.renderer.GLAllocation; @@ -20,6 +21,7 @@ import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.ResourceLocation; + import org.lwjgl.opengl.GL11; // THIS CODE WAS STOLEN FROM THE END PORTAL @@ -29,103 +31,101 @@ // HELP public class RenderTileStarfield extends TileEntitySpecialRenderer { - private static final ResourceLocation field_147529_c = new ResourceLocation("textures/environment/end_sky.png"); - private static final ResourceLocation field_147526_d = new ResourceLocation("textures/entity/end_portal.png"); - private static final Random field_147527_e = new Random(31100L); - FloatBuffer field_147528_b = GLAllocation.createDirectFloatBuffer(16); - - @Override - public void renderTileEntityAt( - TileEntity p_147500_1_, double p_147500_2_, double p_147500_4_, double p_147500_6_, float p_147500_8_) { - float f1 = (float) field_147501_a.field_147560_j; - float f2 = (float) field_147501_a.field_147561_k; - float f3 = (float) field_147501_a.field_147558_l; - GL11.glDisable(GL11.GL_LIGHTING); - field_147527_e.setSeed(31100L); - float f4 = 0.24F; + private static final ResourceLocation field_147529_c = new ResourceLocation("textures/environment/end_sky.png"); + private static final ResourceLocation field_147526_d = new ResourceLocation("textures/entity/end_portal.png"); + private static final Random field_147527_e = new Random(31100L); + FloatBuffer field_147528_b = GLAllocation.createDirectFloatBuffer(16); + @Override + public void renderTileEntityAt(TileEntity p_147500_1_, double p_147500_2_, double p_147500_4_, double p_147500_6_, float p_147500_8_) { + float f1 = (float)field_147501_a.field_147560_j; + float f2 = (float)field_147501_a.field_147561_k; + float f3 = (float)field_147501_a.field_147558_l; + GL11.glDisable(GL11.GL_LIGHTING); + field_147527_e.setSeed(31100L); + float f4 = 0.24F; - for (int i = 0; i < 16; ++i) { - GL11.glPushMatrix(); - float f5 = 16 - i; - float f6 = 0.0625F; - float f7 = 1.0F / (f5 + 1.0F); + for(int i = 0; i < 16; ++i) { + GL11.glPushMatrix(); + float f5 = 16 - i; + float f6 = 0.0625F; + float f7 = 1.0F / (f5 + 1.0F); - if (i == 0) { - bindTexture(field_147529_c); - f7 = 0.1F; - f5 = 65.0F; - f6 = 0.125F; - GL11.glEnable(GL11.GL_BLEND); - GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); - } + if(i == 0) { + bindTexture(field_147529_c); + f7 = 0.1F; + f5 = 65.0F; + f6 = 0.125F; + GL11.glEnable(GL11.GL_BLEND); + GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); + } - if (i == 1) { - bindTexture(field_147526_d); - GL11.glEnable(GL11.GL_BLEND); - GL11.glBlendFunc(GL11.GL_ONE, GL11.GL_ONE); - f6 = 0.5F; - } + if(i == 1) { + bindTexture(field_147526_d); + GL11.glEnable(GL11.GL_BLEND); + GL11.glBlendFunc(GL11.GL_ONE, GL11.GL_ONE); + f6 = 0.5F; + } - float f8 = (float) -(p_147500_4_ + f4); - float f9 = f8 + ActiveRenderInfo.objectY; - float f10 = f8 + f5 + ActiveRenderInfo.objectY; - float f11 = f9 / f10; - f11 += (float) (p_147500_4_ + f4); - GL11.glTranslatef(f1, f11, f3); - GL11.glTexGeni(GL11.GL_S, GL11.GL_TEXTURE_GEN_MODE, GL11.GL_OBJECT_LINEAR); - GL11.glTexGeni(GL11.GL_T, GL11.GL_TEXTURE_GEN_MODE, GL11.GL_OBJECT_LINEAR); - GL11.glTexGeni(GL11.GL_R, GL11.GL_TEXTURE_GEN_MODE, GL11.GL_OBJECT_LINEAR); - GL11.glTexGeni(GL11.GL_Q, GL11.GL_TEXTURE_GEN_MODE, GL11.GL_EYE_LINEAR); - GL11.glTexGen(GL11.GL_S, GL11.GL_OBJECT_PLANE, func_147525_a(1.0F, 0.0F, 0.0F, 0.0F)); - GL11.glTexGen(GL11.GL_T, GL11.GL_OBJECT_PLANE, func_147525_a(0.0F, 0.0F, 1.0F, 0.0F)); - GL11.glTexGen(GL11.GL_R, GL11.GL_OBJECT_PLANE, func_147525_a(0.0F, 0.0F, 0.0F, 1.0F)); - GL11.glTexGen(GL11.GL_Q, GL11.GL_EYE_PLANE, func_147525_a(0.0F, 1.0F, 0.0F, 0.0F)); - GL11.glEnable(GL11.GL_TEXTURE_GEN_S); - GL11.glEnable(GL11.GL_TEXTURE_GEN_T); - GL11.glEnable(GL11.GL_TEXTURE_GEN_R); - GL11.glEnable(GL11.GL_TEXTURE_GEN_Q); - GL11.glPopMatrix(); - GL11.glMatrixMode(GL11.GL_TEXTURE); - GL11.glPushMatrix(); - GL11.glLoadIdentity(); - GL11.glTranslatef(0.0F, Minecraft.getSystemTime() % 20000L / 20000.0F, 0.0F); - GL11.glScalef(f6, f6, f6); - GL11.glTranslatef(0.5F, 0.5F, 0.0F); - GL11.glRotatef((i * i * 4321 + i * 9) * 2.0F, 0.0F, 0.0F, 1.0F); - GL11.glTranslatef(-0.5F, -0.5F, 0.0F); - GL11.glTranslatef(-f1, -f3, -f2); - f9 = f8 + ActiveRenderInfo.objectY; - GL11.glTranslatef(ActiveRenderInfo.objectX * f5 / f9, ActiveRenderInfo.objectZ * f5 / f9, -f2); - Tessellator tessellator = Tessellator.instance; - tessellator.startDrawingQuads(); + float f8 = (float)-(p_147500_4_ + f4); + float f9 = f8 + ActiveRenderInfo.objectY; + float f10 = f8 + f5 + ActiveRenderInfo.objectY; + float f11 = f9 / f10; + f11 += (float)(p_147500_4_ + f4); + GL11.glTranslatef(f1, f11, f3); + GL11.glTexGeni(GL11.GL_S, GL11.GL_TEXTURE_GEN_MODE, GL11.GL_OBJECT_LINEAR); + GL11.glTexGeni(GL11.GL_T, GL11.GL_TEXTURE_GEN_MODE, GL11.GL_OBJECT_LINEAR); + GL11.glTexGeni(GL11.GL_R, GL11.GL_TEXTURE_GEN_MODE, GL11.GL_OBJECT_LINEAR); + GL11.glTexGeni(GL11.GL_Q, GL11.GL_TEXTURE_GEN_MODE, GL11.GL_EYE_LINEAR); + GL11.glTexGen(GL11.GL_S, GL11.GL_OBJECT_PLANE, func_147525_a(1.0F, 0.0F, 0.0F, 0.0F)); + GL11.glTexGen(GL11.GL_T, GL11.GL_OBJECT_PLANE, func_147525_a(0.0F, 0.0F, 1.0F, 0.0F)); + GL11.glTexGen(GL11.GL_R, GL11.GL_OBJECT_PLANE, func_147525_a(0.0F, 0.0F, 0.0F, 1.0F)); + GL11.glTexGen(GL11.GL_Q, GL11.GL_EYE_PLANE, func_147525_a(0.0F, 1.0F, 0.0F, 0.0F)); + GL11.glEnable(GL11.GL_TEXTURE_GEN_S); + GL11.glEnable(GL11.GL_TEXTURE_GEN_T); + GL11.glEnable(GL11.GL_TEXTURE_GEN_R); + GL11.glEnable(GL11.GL_TEXTURE_GEN_Q); + GL11.glPopMatrix(); + GL11.glMatrixMode(GL11.GL_TEXTURE); + GL11.glPushMatrix(); + GL11.glLoadIdentity(); + GL11.glTranslatef(0.0F, Minecraft.getSystemTime() % 20000L / 20000.0F, 0.0F); + GL11.glScalef(f6, f6, f6); + GL11.glTranslatef(0.5F, 0.5F, 0.0F); + GL11.glRotatef((i * i * 4321 + i * 9) * 2.0F, 0.0F, 0.0F, 1.0F); + GL11.glTranslatef(-0.5F, -0.5F, 0.0F); + GL11.glTranslatef(-f1, -f3, -f2); + f9 = f8 + ActiveRenderInfo.objectY; + GL11.glTranslatef(ActiveRenderInfo.objectX * f5 / f9, ActiveRenderInfo.objectZ * f5 / f9, -f2); + Tessellator tessellator = Tessellator.instance; + tessellator.startDrawingQuads(); - Color color = Color.getHSBColor(Minecraft.getSystemTime() / 20F % 360 / 360F, 1F, 1F); - f11 = color.getRed() / 255F; - float f12 = color.getGreen() / 255F; - float f13 = color.getBlue() / 255F; + Color color = Color.getHSBColor(Minecraft.getSystemTime() / 20F % 360 / 360F, 1F, 1F); + f11 = color.getRed() / 255F; + float f12 = color.getGreen() / 255F; + float f13 = color.getBlue() / 255F; - tessellator.setColorRGBA_F(f11 * f7, f12 * f7, f13 * f7, 1.0F); - tessellator.addVertex(p_147500_2_, p_147500_4_ + f4, p_147500_6_); - tessellator.addVertex(p_147500_2_, p_147500_4_ + f4, p_147500_6_ + 1.0D); - tessellator.addVertex(p_147500_2_ + 1.0D, p_147500_4_ + f4, p_147500_6_ + 1.0D); - tessellator.addVertex(p_147500_2_ + 1.0D, p_147500_4_ + f4, p_147500_6_); - tessellator.draw(); - GL11.glPopMatrix(); - GL11.glMatrixMode(GL11.GL_MODELVIEW); - } + tessellator.setColorRGBA_F(f11 * f7, f12 * f7, f13 * f7, 1.0F); + tessellator.addVertex(p_147500_2_, p_147500_4_ + f4, p_147500_6_); + tessellator.addVertex(p_147500_2_, p_147500_4_ + f4, p_147500_6_ + 1.0D); + tessellator.addVertex(p_147500_2_ + 1.0D, p_147500_4_ + f4, p_147500_6_ + 1.0D); + tessellator.addVertex(p_147500_2_ + 1.0D, p_147500_4_ + f4, p_147500_6_); + tessellator.draw(); + GL11.glPopMatrix(); + GL11.glMatrixMode(GL11.GL_MODELVIEW); + } - GL11.glDisable(GL11.GL_BLEND); - GL11.glDisable(GL11.GL_TEXTURE_GEN_S); - GL11.glDisable(GL11.GL_TEXTURE_GEN_T); - GL11.glDisable(GL11.GL_TEXTURE_GEN_R); - GL11.glDisable(GL11.GL_TEXTURE_GEN_Q); - GL11.glEnable(GL11.GL_LIGHTING); - } + GL11.glDisable(GL11.GL_BLEND); + GL11.glDisable(GL11.GL_TEXTURE_GEN_S); + GL11.glDisable(GL11.GL_TEXTURE_GEN_T); + GL11.glDisable(GL11.GL_TEXTURE_GEN_R); + GL11.glDisable(GL11.GL_TEXTURE_GEN_Q); + GL11.glEnable(GL11.GL_LIGHTING); + } - private FloatBuffer func_147525_a(float p_147525_1_, float p_147525_2_, float p_147525_3_, float p_147525_4_) { - field_147528_b.clear(); - field_147528_b.put(p_147525_1_).put(p_147525_2_).put(p_147525_3_).put(p_147525_4_); - field_147528_b.flip(); - return field_147528_b; - } + private FloatBuffer func_147525_a(float p_147525_1_, float p_147525_2_, float p_147525_3_, float p_147525_4_) { + field_147528_b.clear(); + field_147528_b.put(p_147525_1_).put(p_147525_2_).put(p_147525_3_).put(p_147525_4_); + field_147528_b.flip(); + return field_147528_b; + } } diff --git a/src/main/java/vazkii/botania/client/render/tile/RenderTileTerraPlate.java b/src/main/java/vazkii/botania/client/render/tile/RenderTileTerraPlate.java index def9f91135..c87a336dfe 100644 --- a/src/main/java/vazkii/botania/client/render/tile/RenderTileTerraPlate.java +++ b/src/main/java/vazkii/botania/client/render/tile/RenderTileTerraPlate.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Nov 8, 2014, 7:20:26 PM (GMT)] */ package vazkii.botania.client.render.tile; @@ -17,7 +17,9 @@ import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.IIcon; + import org.lwjgl.opengl.GL11; + import vazkii.botania.client.core.handler.ClientTickHandler; import vazkii.botania.client.core.helper.ShaderHelper; import vazkii.botania.common.block.mana.BlockTerraPlate; @@ -25,53 +27,54 @@ public class RenderTileTerraPlate extends TileEntitySpecialRenderer { - @Override - public void renderTileEntityAt(TileEntity tileentity, double d0, double d1, double d2, float f) { - TileTerraPlate plate = (TileTerraPlate) tileentity; + @Override + public void renderTileEntityAt(TileEntity tileentity, double d0, double d1, double d2, float f) { + TileTerraPlate plate = (TileTerraPlate) tileentity; + + float max = TileTerraPlate.MAX_MANA / 10F; + float alphaMod = Math.min(max, plate.getCurrentMana()) / max; + GL11.glPushMatrix(); + GL11.glTranslated(d0, d1, d2); - float max = TileTerraPlate.MAX_MANA / 10F; - float alphaMod = Math.min(max, plate.getCurrentMana()) / max; - GL11.glPushMatrix(); - GL11.glTranslated(d0, d1, d2); + GL11.glRotated(90F, 1F, 0F, 0F); + GL11.glTranslatef(0F, 0F, -3F / 16F - 0.001F); - GL11.glRotated(90F, 1F, 0F, 0F); - GL11.glTranslatef(0F, 0F, -3F / 16F - 0.001F); + GL11.glEnable(GL11.GL_BLEND); + GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); + GL11.glColor4f(1F, 1F, 1F, 1F); + GL11.glDisable(GL11.GL_ALPHA_TEST); + float alpha = (float) ((Math.sin((ClientTickHandler.ticksInGame + f) / 8D) + 1D) / 5D + 0.6D) * alphaMod; + if(ShaderHelper.useShaders()) + GL11.glColor4f(1F, 1F, 1F, alpha); + else { + int light = 15728880; + int lightmapX = light % 65536; + int lightmapY = light / 65536; + OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, lightmapX, lightmapY); + GL11.glColor4f(0.6F + (float) ((Math.cos((ClientTickHandler.ticksInGame + f) / 6D) + 1D) / 5D), 0.1F, 0.9F, alpha); + } - GL11.glEnable(GL11.GL_BLEND); - GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); - GL11.glColor4f(1F, 1F, 1F, 1F); - GL11.glDisable(GL11.GL_ALPHA_TEST); - float alpha = (float) ((Math.sin((ClientTickHandler.ticksInGame + f) / 8D) + 1D) / 5D + 0.6D) * alphaMod; - if (ShaderHelper.useShaders()) GL11.glColor4f(1F, 1F, 1F, alpha); - else { - int light = 15728880; - int lightmapX = light % 65536; - int lightmapY = light / 65536; - OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, lightmapX, lightmapY); - GL11.glColor4f( - 0.6F + (float) ((Math.cos((ClientTickHandler.ticksInGame + f) / 6D) + 1D) / 5D), 0.1F, 0.9F, alpha); - } + Minecraft.getMinecraft().renderEngine.bindTexture(TextureMap.locationBlocksTexture); - Minecraft.getMinecraft().renderEngine.bindTexture(TextureMap.locationBlocksTexture); + ShaderHelper.useShader(ShaderHelper.terraPlateRune); + renderIcon(0, 0, BlockTerraPlate.overlay, 1, 1, 240); + ShaderHelper.releaseShader(); - ShaderHelper.useShader(ShaderHelper.terraPlateRune); - renderIcon(0, 0, BlockTerraPlate.overlay, 1, 1, 240); - ShaderHelper.releaseShader(); + GL11.glEnable(GL11.GL_ALPHA_TEST); + GL11.glDisable(GL11.GL_BLEND); + GL11.glColor4f(1F, 1F, 1F, 1F); + GL11.glPopMatrix(); + } - GL11.glEnable(GL11.GL_ALPHA_TEST); - GL11.glDisable(GL11.GL_BLEND); - GL11.glColor4f(1F, 1F, 1F, 1F); - GL11.glPopMatrix(); - } + public void renderIcon(int par1, int par2, IIcon par3Icon, int par4, int par5, int brightness) { + Tessellator tessellator = Tessellator.instance; + tessellator.startDrawingQuads(); + tessellator.setBrightness(brightness); + tessellator.addVertexWithUV(par1 + 0, par2 + par5, 0, par3Icon.getMinU(), par3Icon.getMaxV()); + tessellator.addVertexWithUV(par1 + par4, par2 + par5, 0, par3Icon.getMaxU(), par3Icon.getMaxV()); + tessellator.addVertexWithUV(par1 + par4, par2 + 0, 0, par3Icon.getMaxU(), par3Icon.getMinV()); + tessellator.addVertexWithUV(par1 + 0, par2 + 0, 0, par3Icon.getMinU(), par3Icon.getMinV()); + tessellator.draw(); + } - public void renderIcon(int par1, int par2, IIcon par3Icon, int par4, int par5, int brightness) { - Tessellator tessellator = Tessellator.instance; - tessellator.startDrawingQuads(); - tessellator.setBrightness(brightness); - tessellator.addVertexWithUV(par1 + 0, par2 + par5, 0, par3Icon.getMinU(), par3Icon.getMaxV()); - tessellator.addVertexWithUV(par1 + par4, par2 + par5, 0, par3Icon.getMaxU(), par3Icon.getMaxV()); - tessellator.addVertexWithUV(par1 + par4, par2 + 0, 0, par3Icon.getMaxU(), par3Icon.getMinV()); - tessellator.addVertexWithUV(par1 + 0, par2 + 0, 0, par3Icon.getMinU(), par3Icon.getMinV()); - tessellator.draw(); - } } diff --git a/src/main/java/vazkii/botania/client/render/tile/RenderTileTeruTeruBozu.java b/src/main/java/vazkii/botania/client/render/tile/RenderTileTeruTeruBozu.java index 6fbf61077b..adcb0cbc97 100644 --- a/src/main/java/vazkii/botania/client/render/tile/RenderTileTeruTeruBozu.java +++ b/src/main/java/vazkii/botania/client/render/tile/RenderTileTeruTeruBozu.java @@ -2,21 +2,24 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Oct 1, 2015, 9:02:30 PM (GMT)] */ package vazkii.botania.client.render.tile; import java.util.Random; + import net.minecraft.client.Minecraft; import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.ResourceLocation; + import org.lwjgl.opengl.GL11; import org.lwjgl.opengl.GL12; + import vazkii.botania.client.core.proxy.ClientProxy; import vazkii.botania.client.lib.LibResources; import vazkii.botania.client.model.ModelTeruTeruBozu; @@ -24,38 +27,39 @@ public class RenderTileTeruTeruBozu extends TileEntitySpecialRenderer { - private static final ResourceLocation texture = new ResourceLocation(LibResources.MODEL_TERU_TERU_BOZU); - private static final ResourceLocation textureHalloween = - new ResourceLocation(LibResources.MODEL_TERU_TERU_BOZU_HALLOWEEN); - ModelTeruTeruBozu model = new ModelTeruTeruBozu(); - - @Override - public void renderTileEntityAt(TileEntity tileentity, double d0, double d1, double d2, float f) { - GL11.glPushMatrix(); - GL11.glEnable(GL12.GL_RESCALE_NORMAL); - GL11.glEnable(GL11.GL_BLEND); - GL11.glDisable(GL11.GL_CULL_FACE); - GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); - GL11.glColor4f(1F, 1F, 1F, 1F); - GL11.glTranslated(d0, d1, d2); - Minecraft.getMinecraft().renderEngine.bindTexture(ClientProxy.dootDoot ? textureHalloween : texture); - GL11.glRotatef(180F, 1F, 0F, 0F); - double time = Botania.proxy.getWorldElapsedTicks() + f; - boolean hasWorld = tileentity.getWorldObj() != null; - if (hasWorld) time += new Random(tileentity.xCoord ^ tileentity.yCoord ^ tileentity.zCoord).nextInt(1000); - - GL11.glTranslatef(0.5F, -1.25F + (hasWorld ? (float) Math.sin(time * 0.01F) * 0.05F : 0F), -0.5F); - if (hasWorld) { - GL11.glRotated(time * 0.3, 0F, 1F, 0F); - GL11.glRotatef(4F * (float) Math.sin(time * 0.05F), 0F, 0F, 1F); - float s = 0.75F; - GL11.glScalef(s, s, s); - } - - model.render(); - GL11.glColor3f(1F, 1F, 1F); - GL11.glEnable(GL12.GL_RESCALE_NORMAL); - GL11.glEnable(GL11.GL_CULL_FACE); - GL11.glPopMatrix(); - } + private static final ResourceLocation texture = new ResourceLocation(LibResources.MODEL_TERU_TERU_BOZU); + private static final ResourceLocation textureHalloween = new ResourceLocation(LibResources.MODEL_TERU_TERU_BOZU_HALLOWEEN); + ModelTeruTeruBozu model = new ModelTeruTeruBozu(); + + @Override + public void renderTileEntityAt(TileEntity tileentity, double d0, double d1, double d2, float f) { + GL11.glPushMatrix(); + GL11.glEnable(GL12.GL_RESCALE_NORMAL); + GL11.glEnable(GL11.GL_BLEND); + GL11.glDisable(GL11.GL_CULL_FACE); + GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); + GL11.glColor4f(1F, 1F, 1F, 1F); + GL11.glTranslated(d0, d1, d2); + Minecraft.getMinecraft().renderEngine.bindTexture(ClientProxy.dootDoot ? textureHalloween : texture); + GL11.glRotatef(180F, 1F, 0F, 0F); + double time = Botania.proxy.getWorldElapsedTicks() + f; + boolean hasWorld = tileentity.getWorldObj() != null; + if(hasWorld) + time += new Random(tileentity.xCoord ^ tileentity.yCoord ^ tileentity.zCoord).nextInt(1000); + + GL11.glTranslatef(0.5F, -1.25F + (hasWorld ? (float) Math.sin(time * 0.01F) * 0.05F : 0F), -0.5F); + if(hasWorld) { + GL11.glRotated(time * 0.3, 0F, 1F, 0F); + GL11.glRotatef(4F * (float) Math.sin(time * 0.05F), 0F, 0F, 1F); + float s = 0.75F; + GL11.glScalef(s, s, s); + } + + model.render(); + GL11.glColor3f(1F, 1F, 1F); + GL11.glEnable(GL12.GL_RESCALE_NORMAL); + GL11.glEnable(GL11.GL_CULL_FACE); + GL11.glPopMatrix(); + } + } diff --git a/src/main/java/vazkii/botania/client/render/tile/RenderTileTinyPotato.java b/src/main/java/vazkii/botania/client/render/tile/RenderTileTinyPotato.java index 0d4fe36aee..d8883a54a7 100644 --- a/src/main/java/vazkii/botania/client/render/tile/RenderTileTinyPotato.java +++ b/src/main/java/vazkii/botania/client/render/tile/RenderTileTinyPotato.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jul 18, 2014, 10:48:46 PM (GMT)] */ package vazkii.botania.client.render.tile; @@ -25,8 +25,10 @@ import net.minecraft.util.MovingObjectPosition; import net.minecraft.util.ResourceLocation; import net.minecraftforge.common.MinecraftForge; + import org.lwjgl.opengl.GL11; import org.lwjgl.opengl.GL12; + import vazkii.botania.api.item.TinyPotatoRenderEvent; import vazkii.botania.client.core.handler.ContributorFancinessHandler; import vazkii.botania.client.core.helper.ShaderHelper; @@ -41,359 +43,358 @@ public class RenderTileTinyPotato extends TileEntitySpecialRenderer { - private static final ResourceLocation texture = new ResourceLocation(LibResources.MODEL_TINY_POTATO); - private static final ResourceLocation textureGrayscale = new ResourceLocation(LibResources.MODEL_TINY_POTATO_GS); - private static final ResourceLocation textureHalloween = - new ResourceLocation(LibResources.MODEL_TINY_POTATO_HALLOWEEN); - private static final ModelTinyPotato model = new ModelTinyPotato(); + private static final ResourceLocation texture = new ResourceLocation(LibResources.MODEL_TINY_POTATO); + private static final ResourceLocation textureGrayscale = new ResourceLocation(LibResources.MODEL_TINY_POTATO_GS); + private static final ResourceLocation textureHalloween = new ResourceLocation(LibResources.MODEL_TINY_POTATO_HALLOWEEN); + private static final ModelTinyPotato model = new ModelTinyPotato(); + + @Override + public void renderTileEntityAt(TileEntity var1, double d0, double d1, double d2, float var8) { + TileTinyPotato potato = (TileTinyPotato) var1; + GL11.glPushMatrix(); + GL11.glEnable(GL12.GL_RESCALE_NORMAL); + GL11.glColor4f(1F, 1F, 1F, 1F); + GL11.glTranslated(d0, d1, d2); - @Override - public void renderTileEntityAt(TileEntity var1, double d0, double d1, double d2, float var8) { - TileTinyPotato potato = (TileTinyPotato) var1; - GL11.glPushMatrix(); - GL11.glEnable(GL12.GL_RESCALE_NORMAL); - GL11.glColor4f(1F, 1F, 1F, 1F); - GL11.glTranslated(d0, d1, d2); + Minecraft mc = Minecraft.getMinecraft(); + mc.renderEngine.bindTexture(ClientProxy.dootDoot ? textureHalloween : texture); + String name = potato.name.toLowerCase(); - Minecraft mc = Minecraft.getMinecraft(); - mc.renderEngine.bindTexture(ClientProxy.dootDoot ? textureHalloween : texture); - String name = potato.name.toLowerCase(); + boolean usedShader = false; + if(name.startsWith("gaia ")) { + ShaderHelper.useShader(ShaderHelper.doppleganger); + name = name.substring(5); + usedShader = true; + } else if(name.startsWith("hot ")) { + ShaderHelper.useShader(ShaderHelper.halo); + name = name.substring(4); + usedShader = true; + } else if(name.startsWith("magic ")) { + ShaderHelper.useShader(ShaderHelper.enchanterRune); + name = name.substring(6); + usedShader = true; + } else if(name.startsWith("gold ")) { + ShaderHelper.useShader(ShaderHelper.gold); + name = name.substring(5); + usedShader = true; + } else if(name.startsWith("snoop ")) { + ShaderHelper.useShader(ShaderHelper.terraPlateRune); + name = name.substring(6); + usedShader = true; + } - boolean usedShader = false; - if (name.startsWith("gaia ")) { - ShaderHelper.useShader(ShaderHelper.doppleganger); - name = name.substring(5); - usedShader = true; - } else if (name.startsWith("hot ")) { - ShaderHelper.useShader(ShaderHelper.halo); - name = name.substring(4); - usedShader = true; - } else if (name.startsWith("magic ")) { - ShaderHelper.useShader(ShaderHelper.enchanterRune); - name = name.substring(6); - usedShader = true; - } else if (name.startsWith("gold ")) { - ShaderHelper.useShader(ShaderHelper.gold); - name = name.substring(5); - usedShader = true; - } else if (name.startsWith("snoop ")) { - ShaderHelper.useShader(ShaderHelper.terraPlateRune); - name = name.substring(6); - usedShader = true; - } + GL11.glTranslatef(0.5F, 1.5F, 0.5F); + GL11.glScalef(1F, -1F, -1F); + int meta = potato.getWorldObj() == null ? 3 : potato.getBlockMetadata(); + float rotY = meta * 90F - 180F; + GL11.glRotatef(rotY, 0F, 1F, 0F); - GL11.glTranslatef(0.5F, 1.5F, 0.5F); - GL11.glScalef(1F, -1F, -1F); - int meta = potato.getWorldObj() == null ? 3 : potato.getBlockMetadata(); - float rotY = meta * 90F - 180F; - GL11.glRotatef(rotY, 0F, 1F, 0F); + float jump = potato.jumpTicks; + if(jump > 0) + jump -= var8; - float jump = potato.jumpTicks; - if (jump > 0) jump -= var8; + float up = (float) -Math.abs(Math.sin(jump / 10 * Math.PI)) * 0.2F; + float rotZ = (float) Math.sin(jump / 10 * Math.PI) * 2; - float up = (float) -Math.abs(Math.sin(jump / 10 * Math.PI)) * 0.2F; - float rotZ = (float) Math.sin(jump / 10 * Math.PI) * 2; + GL11.glTranslatef(0F, up, 0F); + GL11.glRotatef(rotZ, 0F, 0F, 1F); - GL11.glTranslatef(0F, up, 0F); - GL11.glRotatef(rotZ, 0F, 0F, 1F); + GL11.glPushMatrix(); + if(name.equals("pahimar")) { + GL11.glScalef(1F, 0.3F, 1F); + GL11.glTranslatef(0F, 3.5F, 0F); + } else if(name.equals("kyle hyde")) + mc.renderEngine.bindTexture(textureGrayscale); + else if(name.equals("dinnerbone") || name.equals("grumm")) { + GL11.glRotatef(180F, 0F, 0F, 1F); + GL11.glTranslatef(0F, -2.625F, 0F); + } else if(name.equals("aureylian")) + GL11.glColor3f(1F, 0.5F, 1F); - GL11.glPushMatrix(); - if (name.equals("pahimar")) { - GL11.glScalef(1F, 0.3F, 1F); - GL11.glTranslatef(0F, 3.5F, 0F); - } else if (name.equals("kyle hyde")) mc.renderEngine.bindTexture(textureGrayscale); - else if (name.equals("dinnerbone") || name.equals("grumm")) { - GL11.glRotatef(180F, 0F, 0F, 1F); - GL11.glTranslatef(0F, -2.625F, 0F); - } else if (name.equals("aureylian")) GL11.glColor3f(1F, 0.5F, 1F); - boolean render = !(name.equals("mami") || name.equals("soaryn") || name.equals("eloraam") && jump != 0); - if (render) model.render(); - if (name.equals("kingdaddydmac")) { - GL11.glTranslated(0.5F, 0F, 0F); - model.render(); - } + boolean render = !(name.equals("mami") || name.equals("soaryn") || name.equals("eloraam") && jump != 0); + if(render) + model.render(); + if(name.equals("kingdaddydmac")) { + GL11.glTranslated(0.5F, 0F, 0F); + model.render(); + } - if (usedShader) ShaderHelper.releaseShader(); + if(usedShader) + ShaderHelper.releaseShader(); - GL11.glPopMatrix(); + GL11.glPopMatrix(); - if (!name.isEmpty()) { - GL11.glPushMatrix(); - mc.renderEngine.bindTexture(TextureMap.locationItemsTexture); + if(!name.isEmpty()) { + GL11.glPushMatrix(); + mc.renderEngine.bindTexture(TextureMap.locationItemsTexture); - ContributorFancinessHandler.firstStart(); + ContributorFancinessHandler.firstStart(); - float scale = 1F / 4F; - GL11.glTranslatef(0F, 1F, 0F); - GL11.glScalef(scale, scale, scale); - if (name.equals("phi") || name.equals("vazkii")) { - GL11.glTranslatef(0.45F, 0F, 0.4F); - GL11.glRotatef(90F, 0F, 1F, 0F); - GL11.glRotatef(20F, 1F, 0F, 1F); - renderIcon(((ItemManaResource) ModItems.manaResource).phiFlowerIcon); + float scale = 1F / 4F; + GL11.glTranslatef(0F, 1F, 0F); + GL11.glScalef(scale, scale, scale); + if(name.equals("phi") || name.equals("vazkii")) { + GL11.glTranslatef(0.45F, 0F, 0.4F); + GL11.glRotatef(90F, 0F, 1F, 0F); + GL11.glRotatef(20F, 1F, 0F, 1F); + renderIcon(((ItemManaResource) ModItems.manaResource).phiFlowerIcon); - if (name.equals("vazkii")) { - GL11.glRotatef(-20F, 1F, 0F, 1F); - GL11.glScalef(1.25F, 1.25F, 1.25F); - GL11.glRotatef(180F, 0F, 0F, 1F); - GL11.glTranslatef(-1.5F, -1.3F, -0.75F); - renderIcon(((ItemManaResource) ModItems.manaResource).nerfBatIcon); - } - } else if (name.equals("skull kid")) { - GL11.glScalef(1.25F, 1.25F, 1.25F); - GL11.glRotatef(180F, 0F, 0F, 1F); - GL11.glTranslatef(-0.5F, -1.2F, -0.4F); - renderIcon(ModItems.cosmetic.getIconFromDamage(23)); - } else if (name.equals("kamina")) { - GL11.glScalef(1.25F, 1.25F, 1.25F); - GL11.glRotatef(180F, 0F, 0F, 1F); - GL11.glTranslatef(-0.5F, -1.1F, -0.4F); - renderIcon(ModItems.cosmetic.getIconFromDamage(26)); - } else if (name.equals("haighyorkie")) { - GL11.glScalef(1.25F, 1.25F, 1.25F); - GL11.glRotatef(180F, 0F, 0F, 1F); - GL11.glRotatef(90F, 0F, 1F, 0F); - GL11.glTranslatef(-0.5F, -1.2F, -0.4F); - renderIcon(((ItemManaResource) ModItems.manaResource).goldfishIcon); - } else if (name.equals("chitoge")) { - GL11.glScalef(1.25F, 1.25F, 1.25F); - GL11.glRotatef(180F, 0F, 0F, 1F); - GL11.glTranslatef(-0.5F, -0.7F, 0.1F); - renderIcon(ModItems.cosmetic.getIconFromDamage(7)); - } else if (name.equals("direwolf20")) { - GL11.glRotatef(180F, 0F, 0F, 1F); - GL11.glTranslatef(-0.5F, -2.2F, -0.5F); - renderIcon(ModItems.cosmetic.getIconFromDamage(0)); - } else if (name.equals("doctor")) { - GL11.glScalef(1.25F, 1.25F, 1.25F); - GL11.glRotatef(180F, 0F, 0F, 1F); - GL11.glTranslatef(-0.5F, -1.15F, -0.4F); - renderIcon(ModItems.cosmetic.getIconFromDamage(25)); - } else if (name.equals("snoo")) { - GL11.glScalef(1.25F, 1.25F, 1.25F); - GL11.glRotatef(180F, 0F, 0F, 1F); - GL11.glTranslatef(-0.5F, -0.7F, 0.1F); - GL11.glRotatef(20F, 0F, 0F, 1F); - renderIcon(ModItems.cosmetic.getIconFromDamage(24)); - } else if (name.equals("charlotte")) { - GL11.glScalef(1.25F, 1.25F, 1.25F); - GL11.glRotatef(180F, 0F, 0F, 1F); - GL11.glTranslatef(-0.5F, -1.2F, -0.4F); - renderIcon(ModItems.cosmetic.getIconFromDamage(12)); - } else if (name.equals("greg") || name.equals("gregorioust")) { - GL11.glScalef(1.25F, 1.25F, 1.25F); - GL11.glRotatef(180F, 0F, 0F, 1F); - GL11.glRotatef(90F, 0F, 1F, 0F); - GL11.glTranslatef(-0.5F, -1.5F, -0.4F); - renderIcon(Items.book.getIconFromDamage(0)); + if(name.equals("vazkii")) { + GL11.glRotatef(-20F, 1F, 0F, 1F); + GL11.glScalef(1.25F, 1.25F, 1.25F); + GL11.glRotatef(180F, 0F, 0F, 1F); + GL11.glTranslatef(-1.5F, -1.3F, -0.75F); + renderIcon(((ItemManaResource) ModItems.manaResource).nerfBatIcon); + } + } else if(name.equals("skull kid")) { + GL11.glScalef(1.25F, 1.25F, 1.25F); + GL11.glRotatef(180F, 0F, 0F, 1F); + GL11.glTranslatef(-0.5F, -1.2F, -0.4F); + renderIcon(ModItems.cosmetic.getIconFromDamage(23)); + } else if(name.equals("kamina")) { + GL11.glScalef(1.25F, 1.25F, 1.25F); + GL11.glRotatef(180F, 0F, 0F, 1F); + GL11.glTranslatef(-0.5F, -1.1F, -0.4F); + renderIcon(ModItems.cosmetic.getIconFromDamage(26)); + } else if(name.equals("haighyorkie")) { + GL11.glScalef(1.25F, 1.25F, 1.25F); + GL11.glRotatef(180F, 0F, 0F, 1F); + GL11.glRotatef(90F, 0F, 1F, 0F); + GL11.glTranslatef(-0.5F, -1.2F, -0.4F); + renderIcon(((ItemManaResource) ModItems.manaResource).goldfishIcon); + } else if(name.equals("chitoge")) { + GL11.glScalef(1.25F, 1.25F, 1.25F); + GL11.glRotatef(180F, 0F, 0F, 1F); + GL11.glTranslatef(-0.5F, -0.7F, 0.1F); + renderIcon(ModItems.cosmetic.getIconFromDamage(7)); + } else if(name.equals("direwolf20")) { + GL11.glRotatef(180F, 0F, 0F, 1F); + GL11.glTranslatef(-0.5F, -2.2F, -0.5F); + renderIcon(ModItems.cosmetic.getIconFromDamage(0)); + } else if(name.equals("doctor")) { + GL11.glScalef(1.25F, 1.25F, 1.25F); + GL11.glRotatef(180F, 0F, 0F, 1F); + GL11.glTranslatef(-0.5F, -1.15F, -0.4F); + renderIcon(ModItems.cosmetic.getIconFromDamage(25)); + } else if(name.equals("snoo")) { + GL11.glScalef(1.25F, 1.25F, 1.25F); + GL11.glRotatef(180F, 0F, 0F, 1F); + GL11.glTranslatef(-0.5F, -0.7F, 0.1F); + GL11.glRotatef(20F, 0F, 0F, 1F); + renderIcon(ModItems.cosmetic.getIconFromDamage(24)); + } else if(name.equals("charlotte")) { + GL11.glScalef(1.25F, 1.25F, 1.25F); + GL11.glRotatef(180F, 0F, 0F, 1F); + GL11.glTranslatef(-0.5F, -1.2F, -0.4F); + renderIcon(ModItems.cosmetic.getIconFromDamage(12)); + } else if(name.equals("greg") || name.equals("gregorioust")) { + GL11.glScalef(1.25F, 1.25F, 1.25F); + GL11.glRotatef(180F, 0F, 0F, 1F); + GL11.glRotatef(90F, 0F, 1F, 0F); + GL11.glTranslatef(-0.5F, -1.5F, -0.4F); + renderIcon(Items.book.getIconFromDamage(0)); - mc.renderEngine.bindTexture(TextureMap.locationBlocksTexture); - GL11.glTranslatef(0.5F, 0.5F, 0F); - GL11.glScalef(0.3F, 0.3F, 0.3F); + mc.renderEngine.bindTexture(TextureMap.locationBlocksTexture); + GL11.glTranslatef(0.5F, 0.5F, 0F); + GL11.glScalef(0.3F, 0.3F, 0.3F); - RenderBlocks.getInstance().renderBlockAsItem(Blocks.iron_ore, 0, 1F); - } else if (name.equals("profmobius")) { - GL11.glScalef(1.25F, 1.25F, 1.25F); - GL11.glRotatef(180F, 0F, 0F, 1F); - GL11.glRotatef(90F, 0F, 1F, 0F); - GL11.glTranslatef(-0.5F, -1.2F, -0.4F); - renderIcon(Items.bread.getIconFromDamage(0)); - } else if (name.equals("martysgames") || name.equals("marty")) { - GL11.glScalef(0.7F, 0.7F, 0.7F); - GL11.glRotatef(180F, 0F, 0F, 1F); - GL11.glTranslatef(-0.75F, -2.4F, -0.7F); - GL11.glRotatef(10F, 0F, 0F, 1F); - renderIcon(ItemInfiniteFruit.dasBootIcon); - } else if (name.equals("tromped")) { - GL11.glScalef(1.25F, 1.25F, 1.25F); - GL11.glRotatef(180F, 0F, 0F, 1F); - GL11.glRotatef(90F, 0F, 1F, 0F); - GL11.glTranslatef(-0.5F, -1.2F, -0.4F); - renderIcon(ModItems.cacophonium.getIconFromDamage(0)); - } else if (name.equals("kain vinosec")) { - GL11.glScalef(1.25F, 1.25F, 1.25F); - GL11.glRotatef(180F, 0F, 0F, 1F); - GL11.glRotatef(90F, 0F, 1F, 0F); - GL11.glTranslatef(-0.3F, -1.5F, -0.4F); - renderIcon(ModItems.recordGaia1.getIconFromDamage(0)); - GL11.glTranslatef(0F, 0F, 0.85F); - renderIcon(ModItems.recordGaia2.getIconFromDamage(0)); - } else if (name.equals("mankrik")) { - GL11.glScalef(1.25F, 1.25F, 1.25F); - GL11.glRotatef(180F, 0F, 0F, 1F); - GL11.glTranslatef(-0.5F, -0.2F, -0.1F); - renderIcon(ModItems.cosmetic.getIconFromDamage(31)); - } else if (name.equals("kurumi")) { - GL11.glScalef(0.4F, 0.4F, 0.4F); - GL11.glRotatef(180F, 0F, 0F, 1F); - GL11.glTranslatef(-0.9F, -2.5F, -1.3F); - renderIcon(ModItems.cosmetic.getIconFromDamage(17)); - } else if (name.equals("ichun")) { - GL11.glScalef(1.25F, 1.25F, 1.25F); - GL11.glRotatef(180F, 0F, 0F, 1F); - GL11.glTranslatef(-0.5F, -1.2F, -0.4F); - renderIcon(ModItems.cosmetic.getIconFromDamage(15)); - } else if (name.equals("wiiv") || name.equals("dylan4ever") || name.equals("dylankaiser")) { - GL11.glScalef(1.5F, 1.5F, 1.5F); - GL11.glRotatef(180F, 0F, 0F, 1F); - GL11.glRotatef(90F, 0F, 1F, 0F); - GL11.glTranslatef(-0.5F, -1.1F, -0.325F); - renderIcon(Items.painting.getIconFromDamage(0)); - } else if (name.equals("jibril")) { - GL11.glScalef(1.5F, 1.5F, 1.5F); - GL11.glTranslatef(0F, 0.7F, 0F); - GL11.glRotatef(90F, 0F, 1F, 0F); - ItemFlightTiara.renderHalo(null, var8); - } else if (name.equals("nebris")) { - mc.renderEngine.bindTexture(TextureMap.locationBlocksTexture); - GL11.glRotatef(180F, 1F, 0F, 0F); - RenderBlocks.getInstance().renderBlockAsItem(Blocks.glowstone, 0, 1F); - } else if (name.equals("ible")) { - mc.renderEngine.bindTexture(TextureMap.locationBlocksTexture); - GL11.glScalef(1.2F, 1.2F, 1.2F); - GL11.glTranslatef(0F, 0.7F, 0F); - GL11.glRotatef(180F, 1F, 0F, 0F); - GL11.glEnable(GL11.GL_BLEND); - GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); - RenderBlocks.getInstance().renderBlockAsItem(Blocks.portal, 0, 1F); - } else if (name.equals("razz") || name.equals("razzleberryfox")) { - GL11.glScalef(1.25F, 1.25F, 1.25F); - GL11.glRotatef(180F, 0F, 0F, 1F); - GL11.glRotatef(90F, 0F, 1F, 0F); - GL11.glTranslatef(-0.5F, -1F, 0.45F); - renderIcon(ModItems.cosmetic.getIconFromDamage(8)); - } else if (name.equals("etho") || name.equals("ethoslab")) { - GL11.glScalef(1.25F, 1.25F, 1.25F); - GL11.glRotatef(180F, 0F, 0F, 1F); - GL11.glRotatef(90F, 0F, 1F, 0F); - GL11.glTranslatef(-0.5F, -1.2F, -0.4F); - renderIcon(Items.cookie.getIconFromDamage(0)); - } else if (name.equals("sethbling")) { - mc.renderEngine.bindTexture(TextureMap.locationBlocksTexture); - GL11.glScalef(1.2F, 1.2F, 1.2F); - GL11.glTranslatef(0F, 0.9F, 0F); - GL11.glRotatef(180F, 1F, 0F, 0F); - RenderBlocks.getInstance().renderBlockAsItem(Blocks.command_block, 0, 1F); - } else if (name.equals("bdoubleo100") || name.equals("bdoubleo")) { - GL11.glScalef(1.25F, 1.25F, 1.25F); - GL11.glRotatef(180F, 0F, 0F, 1F); - GL11.glTranslatef(-1F, -1.1F, -0.1F); - renderIcon(Items.stick.getIconFromDamage(0)); - } else if (name.equals("kingdaddydmac")) { - GL11.glScalef(0.5F, 0.5F, 0.5F); - GL11.glRotatef(180F, 0F, 0F, 1F); - GL11.glRotatef(90F, 0F, 1F, 0F); - GL11.glTranslatef(-0.3F, -2.5F, 1.075F); - renderIcon(ModItems.manaRing.getIconFromDamage(0)); - GL11.glTranslatef(0F, 0F, -4F); - renderIcon(ModItems.manaRing.getIconFromDamage(0)); + RenderBlocks.getInstance().renderBlockAsItem(Blocks.iron_ore, 0, 1F); + } else if(name.equals("profmobius")) { + GL11.glScalef(1.25F, 1.25F, 1.25F); + GL11.glRotatef(180F, 0F, 0F, 1F); + GL11.glRotatef(90F, 0F, 1F, 0F); + GL11.glTranslatef(-0.5F, -1.2F, -0.4F); + renderIcon(Items.bread.getIconFromDamage(0)); + } else if(name.equals("martysgames") || name.equals("marty")) { + GL11.glScalef(0.7F, 0.7F, 0.7F); + GL11.glRotatef(180F, 0F, 0F, 1F); + GL11.glTranslatef(-0.75F, -2.4F, -0.7F); + GL11.glRotatef(10F, 0F, 0F, 1F); + renderIcon(ItemInfiniteFruit.dasBootIcon); + } else if(name.equals("tromped")) { + GL11.glScalef(1.25F, 1.25F, 1.25F); + GL11.glRotatef(180F, 0F, 0F, 1F); + GL11.glRotatef(90F, 0F, 1F, 0F); + GL11.glTranslatef(-0.5F, -1.2F, -0.4F); + renderIcon(ModItems.cacophonium.getIconFromDamage(0)); + } else if(name.equals("kain vinosec")) { + GL11.glScalef(1.25F, 1.25F, 1.25F); + GL11.glRotatef(180F, 0F, 0F, 1F); + GL11.glRotatef(90F, 0F, 1F, 0F); + GL11.glTranslatef(-0.3F, -1.5F, -0.4F); + renderIcon(ModItems.recordGaia1.getIconFromDamage(0)); + GL11.glTranslatef(0F, 0F, 0.85F); + renderIcon(ModItems.recordGaia2.getIconFromDamage(0)); + } else if(name.equals("mankrik")) { + GL11.glScalef(1.25F, 1.25F, 1.25F); + GL11.glRotatef(180F, 0F, 0F, 1F); + GL11.glTranslatef(-0.5F, -0.2F, -0.1F); + renderIcon(ModItems.cosmetic.getIconFromDamage(31)); + } else if(name.equals("kurumi")) { + GL11.glScalef(0.4F, 0.4F, 0.4F); + GL11.glRotatef(180F, 0F, 0F, 1F); + GL11.glTranslatef(-0.9F, -2.5F, -1.3F); + renderIcon(ModItems.cosmetic.getIconFromDamage(17)); + } else if(name.equals("ichun")) { + GL11.glScalef(1.25F, 1.25F, 1.25F); + GL11.glRotatef(180F, 0F, 0F, 1F); + GL11.glTranslatef(-0.5F, -1.2F, -0.4F); + renderIcon(ModItems.cosmetic.getIconFromDamage(15)); + } else if(name.equals("wiiv") || name.equals("dylan4ever") || name.equals("dylankaiser")) { + GL11.glScalef(1.5F, 1.5F, 1.5F); + GL11.glRotatef(180F, 0F, 0F, 1F); + GL11.glRotatef(90F, 0F, 1F, 0F); + GL11.glTranslatef(-0.5F, -1.1F, -0.325F); + renderIcon(Items.painting.getIconFromDamage(0)); + } else if(name.equals("jibril")) { + GL11.glScalef(1.5F, 1.5F, 1.5F); + GL11.glTranslatef(0F, 0.7F, 0F); + GL11.glRotatef(90F, 0F, 1F, 0F); + ItemFlightTiara.renderHalo(null, var8); + } else if(name.equals("nebris")) { + mc.renderEngine.bindTexture(TextureMap.locationBlocksTexture); + GL11.glRotatef(180F, 1F, 0F, 0F); + RenderBlocks.getInstance().renderBlockAsItem(Blocks.glowstone, 0, 1F); + } else if(name.equals("ible")) { + mc.renderEngine.bindTexture(TextureMap.locationBlocksTexture); + GL11.glScalef(1.2F, 1.2F, 1.2F); + GL11.glTranslatef(0F, 0.7F, 0F); + GL11.glRotatef(180F, 1F, 0F, 0F); + GL11.glEnable(GL11.GL_BLEND); + GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); + RenderBlocks.getInstance().renderBlockAsItem(Blocks.portal, 0, 1F); + } else if(name.equals("razz") || name.equals("razzleberryfox")) { + GL11.glScalef(1.25F, 1.25F, 1.25F); + GL11.glRotatef(180F, 0F, 0F, 1F); + GL11.glRotatef(90F, 0F, 1F, 0F); + GL11.glTranslatef(-0.5F, -1F, 0.45F); + renderIcon(ModItems.cosmetic.getIconFromDamage(8)); + } else if(name.equals("etho") || name.equals("ethoslab")) { + GL11.glScalef(1.25F, 1.25F, 1.25F); + GL11.glRotatef(180F, 0F, 0F, 1F); + GL11.glRotatef(90F, 0F, 1F, 0F); + GL11.glTranslatef(-0.5F, -1.2F, -0.4F); + renderIcon(Items.cookie.getIconFromDamage(0)); + } else if(name.equals("sethbling")) { + mc.renderEngine.bindTexture(TextureMap.locationBlocksTexture); + GL11.glScalef(1.2F, 1.2F, 1.2F); + GL11.glTranslatef(0F, 0.9F, 0F); + GL11.glRotatef(180F, 1F, 0F, 0F); + RenderBlocks.getInstance().renderBlockAsItem(Blocks.command_block, 0, 1F); + } else if(name.equals("bdoubleo100") || name.equals("bdoubleo")) { + GL11.glScalef(1.25F, 1.25F, 1.25F); + GL11.glRotatef(180F, 0F, 0F, 1F); + GL11.glTranslatef(-1F, -1.1F, -0.1F); + renderIcon(Items.stick.getIconFromDamage(0)); + } else if(name.equals("kingdaddydmac")) { + GL11.glScalef(0.5F, 0.5F, 0.5F); + GL11.glRotatef(180F, 0F, 0F, 1F); + GL11.glRotatef(90F, 0F, 1F, 0F); + GL11.glTranslatef(-0.3F, -2.5F, 1.075F); + renderIcon(ModItems.manaRing.getIconFromDamage(0)); + GL11.glTranslatef(0F, 0F, -4F); + renderIcon(ModItems.manaRing.getIconFromDamage(0)); - mc.renderEngine.bindTexture(TextureMap.locationBlocksTexture); - GL11.glScalef(1.5F, 1.5F, 1.5F); - GL11.glTranslatef(1.5F, -0.5F, 0.7F); - RenderBlocks.getInstance().renderBlockAsItem(Blocks.cake, 0, 1F); - } else if (name.equals("sjin")) { - GL11.glScalef(1.25F, 1.25F, 1.25F); - GL11.glRotatef(180F, 0F, 0F, 1F); - GL11.glTranslatef(-0.5F, -1.27F, -0.4F); - renderIcon(ModItems.cosmetic.getIconFromDamage(27)); - } else if (name.equals("martyn") || name.equals("inthelittlewood")) { - GL11.glScalef(1.25F, 1.25F, 1.25F); - GL11.glRotatef(180F, 0F, 0F, 1F); - GL11.glTranslatef(-0.5F, -0.45F, -0.1F); - mc.renderEngine.bindTexture(TextureMap.locationBlocksTexture); - renderIcon(Blocks.sapling.getIcon(0, 0)); - } else if (ContributorFancinessHandler.flowerMap != null - && ContributorFancinessHandler.flowerMap.containsKey(name)) { - IIcon icon = ContributorFancinessHandler.flowerMap.get(name); - if (icon != null) { - mc.renderEngine.bindTexture(TextureMap.locationBlocksTexture); - GL11.glRotatef(180F, 1F, 0F, 0F); - GL11.glTranslatef(-0.5F, -0.5F, 0F); - ShaderHelper.useShader(ShaderHelper.gold); - renderIcon(icon); - ShaderHelper.releaseShader(); - } - } + mc.renderEngine.bindTexture(TextureMap.locationBlocksTexture); + GL11.glScalef(1.5F, 1.5F, 1.5F); + GL11.glTranslatef(1.5F, -0.5F, 0.7F); + RenderBlocks.getInstance().renderBlockAsItem(Blocks.cake, 0, 1F); + } else if(name.equals("sjin")) { + GL11.glScalef(1.25F, 1.25F, 1.25F); + GL11.glRotatef(180F, 0F, 0F, 1F); + GL11.glTranslatef(-0.5F, -1.27F, -0.4F); + renderIcon(ModItems.cosmetic.getIconFromDamage(27)); + } else if(name.equals("martyn") || name.equals("inthelittlewood")) { + GL11.glScalef(1.25F, 1.25F, 1.25F); + GL11.glRotatef(180F, 0F, 0F, 1F); + GL11.glTranslatef(-0.5F, -0.45F, -0.1F); + mc.renderEngine.bindTexture(TextureMap.locationBlocksTexture); + renderIcon(Blocks.sapling.getIcon(0, 0)); + }else if(ContributorFancinessHandler.flowerMap != null && ContributorFancinessHandler.flowerMap.containsKey(name)) { + IIcon icon = ContributorFancinessHandler.flowerMap.get(name); + if(icon != null) { + mc.renderEngine.bindTexture(TextureMap.locationBlocksTexture); + GL11.glRotatef(180F, 1F, 0F, 0F); + GL11.glTranslatef(-0.5F, -0.5F, 0F); + ShaderHelper.useShader(ShaderHelper.gold); + renderIcon(icon); + ShaderHelper.releaseShader(); + } + } - GL11.glPopMatrix(); - } + GL11.glPopMatrix(); + } - MinecraftForge.EVENT_BUS.post(new TinyPotatoRenderEvent(potato, potato.name, d0, d1, d2, var8)); + MinecraftForge.EVENT_BUS.post(new TinyPotatoRenderEvent(potato, potato.name, d0, d1, d2, var8)); - GL11.glRotatef(-rotZ, 0F, 0F, 1F); - GL11.glRotatef(-rotY, 0F, 1F, 0F); - GL11.glColor3f(1F, 1F, 1F); - GL11.glScalef(1F, -1F, -1F); + GL11.glRotatef(-rotZ, 0F, 0F, 1F); + GL11.glRotatef(-rotY, 0F, 1F, 0F); + GL11.glColor3f(1F, 1F, 1F); + GL11.glScalef(1F, -1F, -1F); - MovingObjectPosition pos = mc.objectMouseOver; - if (!name.isEmpty() - && pos != null - && pos.blockX == potato.xCoord - && pos.blockY == potato.yCoord - && pos.blockZ == potato.zCoord) { - GL11.glPushMatrix(); - GL11.glTranslatef(0F, -0.6F, 0F); - GL11.glRotatef(-RenderManager.instance.playerViewY, 0.0F, 1.0F, 0.0F); - GL11.glRotatef(RenderManager.instance.playerViewX, 1.0F, 0.0F, 0.0F); - float f = 1.6F; - float f1 = 0.016666668F * f; - GL11.glScalef(-f1, -f1, f1); - GL11.glDisable(GL11.GL_LIGHTING); - GL11.glTranslatef(0.0F, 0F / f1, 0.0F); - GL11.glDepthMask(false); - GL11.glEnable(GL11.GL_BLEND); - OpenGlHelper.glBlendFunc(770, 771, 1, 0); - Tessellator tessellator = Tessellator.instance; - GL11.glDisable(GL11.GL_TEXTURE_2D); - tessellator.startDrawingQuads(); - int i = mc.fontRenderer.getStringWidth(potato.name) / 2; - tessellator.setColorRGBA_F(0.0F, 0.0F, 0.0F, 0.25F); - tessellator.addVertex(-i - 1, -1.0D, 0.0D); - tessellator.addVertex(-i - 1, 8.0D, 0.0D); - tessellator.addVertex(i + 1, 8.0D, 0.0D); - tessellator.addVertex(i + 1, -1.0D, 0.0D); - tessellator.draw(); - GL11.glEnable(GL11.GL_TEXTURE_2D); - GL11.glDepthMask(true); - mc.fontRenderer.drawString(potato.name, -mc.fontRenderer.getStringWidth(potato.name) / 2, 0, 0xFFFFFF); - if (name.equals("pahimar") || name.equals("soaryn")) { - GL11.glTranslatef(0F, 14F, 0F); - String s = name.equals("pahimar") ? "[WIP]" : "(soon)"; - GL11.glDepthMask(false); - GL11.glEnable(GL11.GL_BLEND); - OpenGlHelper.glBlendFunc(770, 771, 1, 0); - GL11.glDisable(GL11.GL_TEXTURE_2D); - tessellator.startDrawingQuads(); - i = mc.fontRenderer.getStringWidth(s) / 2; - tessellator.setColorRGBA_F(0.0F, 0.0F, 0.0F, 0.25F); - tessellator.addVertex(-i - 1, -1.0D, 0.0D); - tessellator.addVertex(-i - 1, 8.0D, 0.0D); - tessellator.addVertex(i + 1, 8.0D, 0.0D); - tessellator.addVertex(i + 1, -1.0D, 0.0D); - tessellator.draw(); - GL11.glEnable(GL11.GL_TEXTURE_2D); - GL11.glDepthMask(true); - mc.fontRenderer.drawString(s, -mc.fontRenderer.getStringWidth(s) / 2, 0, 0xFFFFFF); - } + MovingObjectPosition pos = mc.objectMouseOver; + if(!name.isEmpty() && pos != null && pos.blockX == potato.xCoord && pos.blockY == potato.yCoord && pos.blockZ == potato.zCoord) { + GL11.glPushMatrix(); + GL11.glTranslatef(0F, -0.6F, 0F); + GL11.glRotatef(-RenderManager.instance.playerViewY, 0.0F, 1.0F, 0.0F); + GL11.glRotatef(RenderManager.instance.playerViewX, 1.0F, 0.0F, 0.0F); + float f = 1.6F; + float f1 = 0.016666668F * f; + GL11.glScalef(-f1, -f1, f1); + GL11.glDisable(GL11.GL_LIGHTING); + GL11.glTranslatef(0.0F, 0F / f1, 0.0F); + GL11.glDepthMask(false); + GL11.glEnable(GL11.GL_BLEND); + OpenGlHelper.glBlendFunc(770, 771, 1, 0); + Tessellator tessellator = Tessellator.instance; + GL11.glDisable(GL11.GL_TEXTURE_2D); + tessellator.startDrawingQuads(); + int i = mc.fontRenderer.getStringWidth(potato.name) / 2; + tessellator.setColorRGBA_F(0.0F, 0.0F, 0.0F, 0.25F); + tessellator.addVertex(-i - 1, -1.0D, 0.0D); + tessellator.addVertex(-i - 1, 8.0D, 0.0D); + tessellator.addVertex(i + 1, 8.0D, 0.0D); + tessellator.addVertex(i + 1, -1.0D, 0.0D); + tessellator.draw(); + GL11.glEnable(GL11.GL_TEXTURE_2D); + GL11.glDepthMask(true); + mc.fontRenderer.drawString(potato.name, -mc.fontRenderer.getStringWidth(potato.name) / 2, 0, 0xFFFFFF); + if(name.equals("pahimar") || name.equals("soaryn")) { + GL11.glTranslatef(0F, 14F, 0F); + String s = name.equals("pahimar") ? "[WIP]" : "(soon)"; + GL11.glDepthMask(false); + GL11.glEnable(GL11.GL_BLEND); + OpenGlHelper.glBlendFunc(770, 771, 1, 0); + GL11.glDisable(GL11.GL_TEXTURE_2D); + tessellator.startDrawingQuads(); + i = mc.fontRenderer.getStringWidth(s) / 2; + tessellator.setColorRGBA_F(0.0F, 0.0F, 0.0F, 0.25F); + tessellator.addVertex(-i - 1, -1.0D, 0.0D); + tessellator.addVertex(-i - 1, 8.0D, 0.0D); + tessellator.addVertex(i + 1, 8.0D, 0.0D); + tessellator.addVertex(i + 1, -1.0D, 0.0D); + tessellator.draw(); + GL11.glEnable(GL11.GL_TEXTURE_2D); + GL11.glDepthMask(true); + mc.fontRenderer.drawString(s, -mc.fontRenderer.getStringWidth(s) / 2, 0, 0xFFFFFF); + } - GL11.glEnable(GL11.GL_LIGHTING); - GL11.glDisable(GL11.GL_BLEND); - GL11.glColor4f(1F, 1F, 1F, 1F); - GL11.glScalef(1F / -f1, 1F / -f1, 1F / f1); - GL11.glPopMatrix(); - } + GL11.glEnable(GL11.GL_LIGHTING); + GL11.glDisable(GL11.GL_BLEND); + GL11.glColor4f(1F, 1F, 1F, 1F); + GL11.glScalef(1F / -f1, 1F / -f1, 1F / f1); + GL11.glPopMatrix(); + } - GL11.glPopMatrix(); - } + GL11.glPopMatrix(); + } - public void renderIcon(IIcon icon) { - float f = icon.getMinU(); - float f1 = icon.getMaxU(); - float f2 = icon.getMinV(); - float f3 = icon.getMaxV(); - ItemRenderer.renderItemIn2D( - Tessellator.instance, f1, f2, f, f3, icon.getIconWidth(), icon.getIconHeight(), 1F / 16F); - } -} + public void renderIcon(IIcon icon) { + float f = icon.getMinU(); + float f1 = icon.getMaxU(); + float f2 = icon.getMinV(); + float f3 = icon.getMaxV(); + ItemRenderer.renderItemIn2D(Tessellator.instance, f1, f2, f, f3, icon.getIconWidth(), icon.getIconHeight(), 1F / 16F); + } +} \ No newline at end of file diff --git a/src/main/java/vazkii/botania/client/render/world/SkyblockRenderEvents.java b/src/main/java/vazkii/botania/client/render/world/SkyblockRenderEvents.java index a8f8388d12..007b637fb5 100644 --- a/src/main/java/vazkii/botania/client/render/world/SkyblockRenderEvents.java +++ b/src/main/java/vazkii/botania/client/render/world/SkyblockRenderEvents.java @@ -2,32 +2,30 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [18/12/2015, 02:19:53 (GMT)] */ package vazkii.botania.client.render.world; -import cpw.mods.fml.common.eventhandler.SubscribeEvent; import net.minecraft.client.Minecraft; import net.minecraft.world.World; import net.minecraftforge.client.event.RenderWorldLastEvent; import vazkii.botania.common.core.handler.ConfigHandler; import vazkii.botania.common.world.WorldTypeSkyblock; +import cpw.mods.fml.common.eventhandler.SubscribeEvent; public final class SkyblockRenderEvents { - @SubscribeEvent - public void onRender(RenderWorldLastEvent event) { - World world = Minecraft.getMinecraft().theWorld; - if (ConfigHandler.enableFancySkybox - && world.provider.dimensionId == 0 - && (ConfigHandler.enableFancySkyboxInNormalWorlds - || WorldTypeSkyblock.isWorldSkyblock(Minecraft.getMinecraft().theWorld))) { - if (!(world.provider.getSkyRenderer() instanceof SkyblockSkyRenderer)) - world.provider.setSkyRenderer(new SkyblockSkyRenderer()); - } - } + @SubscribeEvent + public void onRender(RenderWorldLastEvent event) { + World world = Minecraft.getMinecraft().theWorld; + if(ConfigHandler.enableFancySkybox && world.provider.dimensionId == 0 && (ConfigHandler.enableFancySkyboxInNormalWorlds || WorldTypeSkyblock.isWorldSkyblock(Minecraft.getMinecraft().theWorld))) { + if(!(world.provider.getSkyRenderer() instanceof SkyblockSkyRenderer)) + world.provider.setSkyRenderer(new SkyblockSkyRenderer()); + } + } + } diff --git a/src/main/java/vazkii/botania/client/render/world/SkyblockSkyRenderer.java b/src/main/java/vazkii/botania/client/render/world/SkyblockSkyRenderer.java index 432c99b367..39cc7a2162 100644 --- a/src/main/java/vazkii/botania/client/render/world/SkyblockSkyRenderer.java +++ b/src/main/java/vazkii/botania/client/render/world/SkyblockSkyRenderer.java @@ -2,16 +2,16 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [18/12/2015, 02:06:56 (GMT)] */ package vazkii.botania.client.render.world; -import cpw.mods.fml.relauncher.ReflectionHelper; import java.util.Random; + import net.minecraft.client.Minecraft; import net.minecraft.client.multiplayer.WorldClient; import net.minecraft.client.renderer.OpenGlHelper; @@ -22,352 +22,349 @@ import net.minecraft.util.ResourceLocation; import net.minecraft.util.Vec3; import net.minecraftforge.client.IRenderHandler; + import org.lwjgl.opengl.GL11; + import vazkii.botania.client.core.handler.ClientTickHandler; import vazkii.botania.client.lib.LibResources; import vazkii.botania.common.lib.LibObfuscation; +import cpw.mods.fml.relauncher.ReflectionHelper; public class SkyblockSkyRenderer extends IRenderHandler { - private static final ResourceLocation textureSkybox = new ResourceLocation(LibResources.MISC_SKYBOX); - private static final ResourceLocation textureRainbow = new ResourceLocation(LibResources.MISC_RAINBOW); - private static final ResourceLocation textureMoonPhases = - new ResourceLocation("textures/environment/moon_phases.png"); - private static final ResourceLocation textureSun = new ResourceLocation("textures/environment/sun.png"); - private static final ResourceLocation[] planetTextures = new ResourceLocation[] { - new ResourceLocation(LibResources.MISC_PLANET + "0.png"), - new ResourceLocation(LibResources.MISC_PLANET + "1.png"), - new ResourceLocation(LibResources.MISC_PLANET + "2.png"), - new ResourceLocation(LibResources.MISC_PLANET + "3.png"), - new ResourceLocation(LibResources.MISC_PLANET + "4.png"), - new ResourceLocation(LibResources.MISC_PLANET + "5.png") - }; - - @Override - public void render(float partialTicks, WorldClient world, Minecraft mc) { - boolean test = false; - if (test) return; - - int glSkyList = - ReflectionHelper.getPrivateValue(RenderGlobal.class, mc.renderGlobal, LibObfuscation.GL_SKY_LIST); - int glSkyList2 = ReflectionHelper.getPrivateValue( - RenderGlobal.class, - mc.renderGlobal, - LibObfuscation.GL_SKY_LIST2); // Horizon line. We don't have it here - int starGLCallList = - ReflectionHelper.getPrivateValue(RenderGlobal.class, mc.renderGlobal, LibObfuscation.STAR_GL_CALL_LIST); - - GL11.glDisable(GL11.GL_TEXTURE_2D); - Vec3 vec3 = world.getSkyColor(mc.renderViewEntity, partialTicks); - float f1 = (float) vec3.xCoord; - float f2 = (float) vec3.yCoord; - float f3 = (float) vec3.zCoord; - float f6; - - float insideVoid = 0; - if (mc.thePlayer.posY <= -2) insideVoid = (float) Math.min(1F, -(mc.thePlayer.posY + 2) / 30F); - - f1 = Math.max(0F, f1 - insideVoid); - f2 = Math.max(0F, f2 - insideVoid); - f3 = Math.max(0F, f3 - insideVoid); - - Tessellator tessellator1 = Tessellator.instance; - GL11.glDepthMask(false); - GL11.glEnable(GL11.GL_FOG); - GL11.glColor3f(f1, f2, f3); - GL11.glCallList(glSkyList); - GL11.glDisable(GL11.GL_FOG); - GL11.glDisable(GL11.GL_ALPHA_TEST); - GL11.glEnable(GL11.GL_BLEND); - OpenGlHelper.glBlendFunc(770, 771, 1, 0); - RenderHelper.disableStandardItemLighting(); - float[] afloat = world.provider.calcSunriseSunsetColors(world.getCelestialAngle(partialTicks), partialTicks); - float f7; - float f8; - float f9; - float f10; - - // === Sunset - if (afloat != null) { - GL11.glDisable(GL11.GL_TEXTURE_2D); - GL11.glShadeModel(GL11.GL_SMOOTH); - GL11.glPushMatrix(); - GL11.glRotatef(90.0F, 1.0F, 0.0F, 0.0F); - GL11.glRotatef( - MathHelper.sin(world.getCelestialAngleRadians(partialTicks)) < 0.0F ? 180.0F : 0.0F, - 0.0F, - 0.0F, - 1.0F); - GL11.glRotatef(90.0F, 0.0F, 0.0F, 1.0F); - f6 = afloat[0]; - f7 = afloat[1]; - f8 = afloat[2]; - float f11; - - tessellator1.startDrawing(6); - tessellator1.setColorRGBA_F(f6, f7, f8, afloat[3] * (1F - insideVoid)); - tessellator1.addVertex(0.0D, 100.0D, 0.0D); - byte b0 = 16; - tessellator1.setColorRGBA_F(afloat[0], afloat[1], afloat[2], 0.0F); - - for (int j = 0; j <= b0; ++j) { - f11 = (float) j * (float) Math.PI * 2.0F / (float) b0; - float f12 = MathHelper.sin(f11); - float f13 = MathHelper.cos(f11); - tessellator1.addVertex( - (double) (f12 * 120.0F), (double) (f13 * 120.0F), (double) (-f13 * 40.0F * afloat[3])); - } - - tessellator1.draw(); - GL11.glPopMatrix(); - GL11.glShadeModel(GL11.GL_FLAT); - } - - GL11.glEnable(GL11.GL_TEXTURE_2D); - GL11.glPushMatrix(); - f6 = Math.max(0.2F, 1.0F - world.getRainStrength(partialTicks)) * (1F - insideVoid); - f7 = 0.0F; - f8 = 0.0F; - f9 = 0.0F; - - GL11.glTranslatef(f7, f8, f9); - GL11.glRotatef(-90.0F, 0.0F, 1.0F, 0.0F); - - float celAng = world.getCelestialAngle(partialTicks); - float effCelAng = celAng; - if (celAng > 0.5) effCelAng = 0.5F - (celAng - 0.5F); - - // === Planets - f10 = 20F; - float lowA = Math.max(0F, effCelAng - 0.3F) * f6; - float a = Math.max(0.1F, lowA); - - OpenGlHelper.glBlendFunc(770, 771, 1, 0); - GL11.glPushMatrix(); - GL11.glColor4f(1F, 1F, 1F, (a * 4) * (1F - insideVoid)); - GL11.glRotatef(90F, 0.5F, 0.5F, 0.0F); - for (int p = 0; p < planetTextures.length; p++) { - mc.renderEngine.bindTexture(planetTextures[p]); - drawObject(tessellator1, f10); - - switch (p) { - case 0: - GL11.glRotatef(70F, 1F, 0F, 0F); - f10 = 12F; - break; - case 1: - GL11.glRotatef(120F, 0F, 0F, 1F); - f10 = 15F; - break; - case 2: - GL11.glRotatef(80F, 1F, 0F, 1F); - f10 = 25F; - break; - case 3: - GL11.glRotatef(100F, 0F, 0F, 1F); - f10 = 10F; - break; - case 4: - GL11.glRotatef(-60F, 1F, 0F, 0.5F); - f10 = 40F; - } - } - GL11.glColor4f(1F, 1F, 1F, 1F); - GL11.glPopMatrix(); - - // === Rays - mc.renderEngine.bindTexture(textureSkybox); - - f10 = 20F; - a = lowA; - GL11.glPushMatrix(); - OpenGlHelper.glBlendFunc(770, 1, 1, 0); - GL11.glTranslatef(0F, -1F, 0F); - GL11.glRotatef(220F, 1F, 0F, 0F); - GL11.glColor4f(1F, 1F, 1F, a); - int angles = 90; - float s = 3F; - float m = 1F; - float y = 2F; - float y0 = 0F; - float uPer = 1F / 360F; - float anglePer = 360F / angles; - double fuzzPer = (Math.PI * 10) / angles; - float rotSpeed = 1F; - float rotSpeedMod = 0.4F; - - for (int p = 0; p < 3; p++) { - float baseAngle = rotSpeed * rotSpeedMod * (ClientTickHandler.ticksInGame + ClientTickHandler.partialTicks); - GL11.glRotatef( - (ClientTickHandler.ticksInGame + ClientTickHandler.partialTicks) * 0.25F * rotSpeed * rotSpeedMod, - 0F, - 1F, - 0F); - - tessellator1.startDrawingQuads(); - for (int i = 0; i < angles; i++) { - int j = i; - if (i % 2 == 0) j--; - - float ang = j * anglePer + baseAngle; - double xp = Math.cos(ang * Math.PI / 180F) * f10; - double zp = Math.sin(ang * Math.PI / 180F) * f10; - double yo = Math.sin(fuzzPer * j) * 1; - - float ut = ang * uPer; - if (i % 2 == 0) { - tessellator1.addVertexWithUV(xp, yo + y0 + y, zp, ut, 1F); - tessellator1.addVertexWithUV(xp, yo + y0, zp, ut, 0); - } else { - tessellator1.addVertexWithUV(xp, yo + y0, zp, ut, 0); - tessellator1.addVertexWithUV(xp, yo + y0 + y, zp, ut, 1F); - } - } - tessellator1.draw(); - - switch (p) { - case 0: - GL11.glRotatef(20F, 1F, 0F, 0F); - GL11.glColor4f(1F, 0.4F, 0.4F, a); - fuzzPer = (Math.PI * 14) / angles; - rotSpeed = 0.2F; - break; - case 1: - GL11.glRotatef(50F, 1F, 0F, 0F); - GL11.glColor4f(0.4F, 1F, 0.7F, a); - fuzzPer = (Math.PI * 6) / angles; - rotSpeed = 2F; - break; - } - } - GL11.glPopMatrix(); - - // === Rainbow - GL11.glPushMatrix(); - OpenGlHelper.glBlendFunc(770, 771, 1, 0); - mc.renderEngine.bindTexture(textureRainbow); - f10 = 10F; - float effCelAng1 = celAng; - if (effCelAng1 > 0.25F) effCelAng1 = 1F - effCelAng1; - effCelAng1 = 0.25F - Math.min(0.25F, effCelAng1); - - long time = world.getWorldTime() + 1000; - int day = (int) (time / 24000L); - Random rand = new Random(day * 0xFF); - float angle1 = rand.nextFloat() * 360F; - float angle2 = rand.nextFloat() * 360F; - GL11.glColor4f(1F, 1F, 1F, effCelAng1 * (1F - insideVoid)); - GL11.glRotatef(angle1, 0F, 1F, 0F); - GL11.glRotatef(angle2, 0F, 0F, 1F); - - tessellator1.startDrawingQuads(); - for (int i = 0; i < angles; i++) { - int j = i; - if (i % 2 == 0) j--; - - float ang = j * anglePer; - double xp = Math.cos(ang * Math.PI / 180F) * f10; - double zp = Math.sin(ang * Math.PI / 180F) * f10; - double yo = 0; - - float ut = ang * uPer; - if (i % 2 == 0) { - tessellator1.addVertexWithUV(xp, yo + y0 + y, zp, ut, 1F); - tessellator1.addVertexWithUV(xp, yo + y0, zp, ut, 0); - } else { - tessellator1.addVertexWithUV(xp, yo + y0, zp, ut, 0); - tessellator1.addVertexWithUV(xp, yo + y0 + y, zp, ut, 1F); - } - } - tessellator1.draw(); - GL11.glPopMatrix(); - - GL11.glColor4f(1F, 1F, 1F, 1F - insideVoid); - - OpenGlHelper.glBlendFunc(770, 1, 1, 0); - - // === Sun - GL11.glRotatef(world.getCelestialAngle(partialTicks) * 360.0F, 1.0F, 0.0F, 0.0F); - f10 = 60.0F; - mc.renderEngine.bindTexture(textureSun); - drawObject(tessellator1, f10); - - // === Moon - f10 = 60.0F; - mc.renderEngine.bindTexture(textureMoonPhases); - int k = world.getMoonPhase(); - int l = k % 4; - int i1 = k / 4 % 2; - float f14 = (float) (l + 0) / 4.0F; - float f15 = (float) (i1 + 0) / 2.0F; - float f16 = (float) (l + 1) / 4.0F; - float f17 = (float) (i1 + 1) / 2.0F; - tessellator1.startDrawingQuads(); - tessellator1.addVertexWithUV((double) (-f10), -100.0D, (double) f10, (double) f16, (double) f17); - tessellator1.addVertexWithUV((double) f10, -100.0D, (double) f10, (double) f14, (double) f17); - tessellator1.addVertexWithUV((double) f10, -100.0D, (double) (-f10), (double) f14, (double) f15); - tessellator1.addVertexWithUV((double) (-f10), -100.0D, (double) (-f10), (double) f16, (double) f15); - tessellator1.draw(); - - // === Stars - f6 *= Math.max(0.1F, effCelAng * 2); - float t = (ClientTickHandler.ticksInGame + partialTicks + 2000) * 0.005F; - GL11.glPushMatrix(); - GL11.glDisable(GL11.GL_TEXTURE_2D); - - GL11.glPushMatrix(); - GL11.glRotatef(t * 3, 0F, 1F, 0F); - GL11.glColor4f(1F, 1F, 1F, f6); - GL11.glCallList(starGLCallList); - GL11.glPopMatrix(); - - GL11.glPushMatrix(); - GL11.glRotatef(t, 0F, 1F, 0F); - GL11.glColor4f(0.5F, 1F, 1F, f6); - GL11.glCallList(starGLCallList); - GL11.glPopMatrix(); - - GL11.glPushMatrix(); - GL11.glRotatef(t * 2, 0F, 1F, 0F); - GL11.glColor4f(1F, 0.75F, 0.75F, f6); - GL11.glCallList(starGLCallList); - GL11.glPopMatrix(); - - GL11.glPushMatrix(); - GL11.glRotatef(t * 3, 0F, 0F, 1F); - GL11.glColor4f(1F, 1F, 1F, 0.25F * f6); - GL11.glCallList(starGLCallList); - GL11.glPopMatrix(); - - GL11.glPushMatrix(); - GL11.glRotatef(t, 0F, 0F, 1F); - GL11.glColor4f(0.5F, 1F, 1F, 0.25F * f6); - GL11.glCallList(starGLCallList); - GL11.glPopMatrix(); - - GL11.glPushMatrix(); - GL11.glRotatef(t * 2, 0F, 0F, 1F); - GL11.glColor4f(1F, 0.75F, 0.75F, 0.25F * f6); - GL11.glCallList(starGLCallList); - GL11.glPopMatrix(); - - GL11.glEnable(GL11.GL_TEXTURE_2D); - GL11.glPopMatrix(); - - GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); - GL11.glDisable(GL11.GL_BLEND); - GL11.glEnable(GL11.GL_ALPHA_TEST); - GL11.glEnable(GL11.GL_FOG); - GL11.glPopMatrix(); - GL11.glDepthMask(true); - } - - private void drawObject(Tessellator tess, float f10) { - tess.startDrawingQuads(); - tess.addVertexWithUV((double) (-f10), 100.0D, (double) (-f10), 0.0D, 0.0D); - tess.addVertexWithUV((double) f10, 100.0D, (double) (-f10), 1.0D, 0.0D); - tess.addVertexWithUV((double) f10, 100.0D, (double) f10, 1.0D, 1.0D); - tess.addVertexWithUV((double) (-f10), 100.0D, (double) f10, 0.0D, 1.0D); - tess.draw(); - } + private static final ResourceLocation textureSkybox = new ResourceLocation(LibResources.MISC_SKYBOX); + private static final ResourceLocation textureRainbow = new ResourceLocation(LibResources.MISC_RAINBOW); + private static final ResourceLocation textureMoonPhases = new ResourceLocation("textures/environment/moon_phases.png"); + private static final ResourceLocation textureSun = new ResourceLocation("textures/environment/sun.png"); + private static final ResourceLocation[] planetTextures = new ResourceLocation[] { + new ResourceLocation(LibResources.MISC_PLANET + "0.png"), + new ResourceLocation(LibResources.MISC_PLANET + "1.png"), + new ResourceLocation(LibResources.MISC_PLANET + "2.png"), + new ResourceLocation(LibResources.MISC_PLANET + "3.png"), + new ResourceLocation(LibResources.MISC_PLANET + "4.png"), + new ResourceLocation(LibResources.MISC_PLANET + "5.png") + }; + + @Override + public void render(float partialTicks, WorldClient world, Minecraft mc) { + boolean test = false; + if(test) + return; + + int glSkyList = ReflectionHelper.getPrivateValue(RenderGlobal.class, mc.renderGlobal, LibObfuscation.GL_SKY_LIST); + int glSkyList2 = ReflectionHelper.getPrivateValue(RenderGlobal.class, mc.renderGlobal, LibObfuscation.GL_SKY_LIST2); // Horizon line. We don't have it here + int starGLCallList = ReflectionHelper.getPrivateValue(RenderGlobal.class, mc.renderGlobal, LibObfuscation.STAR_GL_CALL_LIST); + + GL11.glDisable(GL11.GL_TEXTURE_2D); + Vec3 vec3 = world.getSkyColor(mc.renderViewEntity, partialTicks); + float f1 = (float)vec3.xCoord; + float f2 = (float)vec3.yCoord; + float f3 = (float)vec3.zCoord; + float f6; + + float insideVoid = 0; + if(mc.thePlayer.posY <= -2) + insideVoid = (float) Math.min(1F, -(mc.thePlayer.posY + 2) / 30F); + + f1 = Math.max(0F, f1 - insideVoid); + f2 = Math.max(0F, f2 - insideVoid); + f3 = Math.max(0F, f3 - insideVoid); + + Tessellator tessellator1 = Tessellator.instance; + GL11.glDepthMask(false); + GL11.glEnable(GL11.GL_FOG); + GL11.glColor3f(f1, f2, f3); + GL11.glCallList(glSkyList); + GL11.glDisable(GL11.GL_FOG); + GL11.glDisable(GL11.GL_ALPHA_TEST); + GL11.glEnable(GL11.GL_BLEND); + OpenGlHelper.glBlendFunc(770, 771, 1, 0); + RenderHelper.disableStandardItemLighting(); + float[] afloat = world.provider.calcSunriseSunsetColors(world.getCelestialAngle(partialTicks), partialTicks); + float f7; + float f8; + float f9; + float f10; + + // === Sunset + if(afloat != null) { + GL11.glDisable(GL11.GL_TEXTURE_2D); + GL11.glShadeModel(GL11.GL_SMOOTH); + GL11.glPushMatrix(); + GL11.glRotatef(90.0F, 1.0F, 0.0F, 0.0F); + GL11.glRotatef(MathHelper.sin(world.getCelestialAngleRadians(partialTicks)) < 0.0F ? 180.0F : 0.0F, 0.0F, 0.0F, 1.0F); + GL11.glRotatef(90.0F, 0.0F, 0.0F, 1.0F); + f6 = afloat[0]; + f7 = afloat[1]; + f8 = afloat[2]; + float f11; + + tessellator1.startDrawing(6); + tessellator1.setColorRGBA_F(f6, f7, f8, afloat[3] * (1F - insideVoid)); + tessellator1.addVertex(0.0D, 100.0D, 0.0D); + byte b0 = 16; + tessellator1.setColorRGBA_F(afloat[0], afloat[1], afloat[2], 0.0F); + + for(int j = 0; j <= b0; ++j) { + f11 = (float)j * (float)Math.PI * 2.0F / (float)b0; + float f12 = MathHelper.sin(f11); + float f13 = MathHelper.cos(f11); + tessellator1.addVertex((double)(f12 * 120.0F), (double)(f13 * 120.0F), (double)(-f13 * 40.0F * afloat[3])); + } + + tessellator1.draw(); + GL11.glPopMatrix(); + GL11.glShadeModel(GL11.GL_FLAT); + } + + GL11.glEnable(GL11.GL_TEXTURE_2D); + GL11.glPushMatrix(); + f6 = Math.max(0.2F, 1.0F - world.getRainStrength(partialTicks)) * (1F - insideVoid); + f7 = 0.0F; + f8 = 0.0F; + f9 = 0.0F; + + GL11.glTranslatef(f7, f8, f9); + GL11.glRotatef(-90.0F, 0.0F, 1.0F, 0.0F); + + float celAng = world.getCelestialAngle(partialTicks); + float effCelAng = celAng; + if(celAng > 0.5) + effCelAng = 0.5F - (celAng - 0.5F); + + // === Planets + f10 = 20F; + float lowA = Math.max(0F, effCelAng - 0.3F) * f6; + float a = Math.max(0.1F, lowA); + + OpenGlHelper.glBlendFunc(770, 771, 1, 0); + GL11.glPushMatrix(); + GL11.glColor4f(1F, 1F, 1F, (a * 4) * (1F - insideVoid)); + GL11.glRotatef(90F, 0.5F, 0.5F, 0.0F); + for(int p = 0; p < planetTextures.length; p++) { + mc.renderEngine.bindTexture(planetTextures[p]); + drawObject(tessellator1, f10); + + switch(p) { + case 0: + GL11.glRotatef(70F, 1F, 0F, 0F); + f10 = 12F; + break; + case 1: + GL11.glRotatef(120F, 0F, 0F, 1F); + f10 = 15F; + break; + case 2: + GL11.glRotatef(80F, 1F, 0F, 1F); + f10 = 25F; + break; + case 3: + GL11.glRotatef(100F, 0F, 0F, 1F); + f10 = 10F; + break; + case 4: + GL11.glRotatef(-60F, 1F, 0F, 0.5F); + f10 = 40F; + } + } + GL11.glColor4f(1F, 1F, 1F, 1F); + GL11.glPopMatrix(); + + // === Rays + mc.renderEngine.bindTexture(textureSkybox); + + f10 = 20F; + a = lowA; + GL11.glPushMatrix(); + OpenGlHelper.glBlendFunc(770, 1, 1, 0); + GL11.glTranslatef(0F, -1F, 0F); + GL11.glRotatef(220F, 1F, 0F, 0F); + GL11.glColor4f(1F, 1F, 1F, a); + int angles = 90; + float s = 3F; + float m = 1F; + float y = 2F; + float y0 = 0F; + float uPer = 1F / 360F; + float anglePer = 360F / angles; + double fuzzPer = (Math.PI * 10) / angles; + float rotSpeed = 1F; + float rotSpeedMod = 0.4F; + + for(int p = 0; p < 3; p++) { + float baseAngle = rotSpeed * rotSpeedMod * (ClientTickHandler.ticksInGame + ClientTickHandler.partialTicks); + GL11.glRotatef((ClientTickHandler.ticksInGame + ClientTickHandler.partialTicks) * 0.25F * rotSpeed * rotSpeedMod, 0F, 1F, 0F); + + tessellator1.startDrawingQuads(); + for(int i = 0; i < angles; i++) { + int j = i; + if(i % 2 == 0) + j--; + + float ang = j * anglePer + baseAngle; + double xp = Math.cos(ang * Math.PI / 180F) * f10; + double zp = Math.sin(ang * Math.PI / 180F) * f10; + double yo = Math.sin(fuzzPer * j) * 1; + + float ut = ang * uPer; + if(i % 2 == 0) { + tessellator1.addVertexWithUV(xp, yo + y0 + y, zp, ut, 1F); + tessellator1.addVertexWithUV(xp, yo + y0, zp, ut, 0); + } else { + tessellator1.addVertexWithUV(xp, yo + y0, zp, ut, 0); + tessellator1.addVertexWithUV(xp, yo + y0 + y, zp, ut, 1F); + } + + } + tessellator1.draw(); + + switch(p) { + case 0: + GL11.glRotatef(20F, 1F, 0F, 0F); + GL11.glColor4f(1F, 0.4F, 0.4F, a); + fuzzPer = (Math.PI * 14) / angles; + rotSpeed = 0.2F; + break; + case 1: + GL11.glRotatef(50F, 1F, 0F, 0F); + GL11.glColor4f(0.4F, 1F, 0.7F, a); + fuzzPer = (Math.PI * 6) / angles; + rotSpeed = 2F; + break; + } + } + GL11.glPopMatrix(); + + // === Rainbow + GL11.glPushMatrix(); + OpenGlHelper.glBlendFunc(770, 771, 1, 0); + mc.renderEngine.bindTexture(textureRainbow); + f10 = 10F; + float effCelAng1 = celAng; + if(effCelAng1 > 0.25F) + effCelAng1 = 1F - effCelAng1; + effCelAng1 = 0.25F - Math.min(0.25F, effCelAng1); + + long time = world.getWorldTime() + 1000; + int day = (int) (time / 24000L); + Random rand = new Random(day * 0xFF); + float angle1 = rand.nextFloat() * 360F; + float angle2 = rand.nextFloat() * 360F; + GL11.glColor4f(1F, 1F, 1F, effCelAng1 * (1F - insideVoid)); + GL11.glRotatef(angle1, 0F, 1F, 0F); + GL11.glRotatef(angle2, 0F, 0F, 1F); + + tessellator1.startDrawingQuads(); + for(int i = 0; i < angles; i++) { + int j = i; + if(i % 2 == 0) + j--; + + float ang = j * anglePer; + double xp = Math.cos(ang * Math.PI / 180F) * f10; + double zp = Math.sin(ang * Math.PI / 180F) * f10; + double yo = 0; + + float ut = ang * uPer; + if(i % 2 == 0) { + tessellator1.addVertexWithUV(xp, yo + y0 + y, zp, ut, 1F); + tessellator1.addVertexWithUV(xp, yo + y0, zp, ut, 0); + } else { + tessellator1.addVertexWithUV(xp, yo + y0, zp, ut, 0); + tessellator1.addVertexWithUV(xp, yo + y0 + y, zp, ut, 1F); + } + + } + tessellator1.draw(); + GL11.glPopMatrix(); + + GL11.glColor4f(1F, 1F, 1F, 1F - insideVoid); + + OpenGlHelper.glBlendFunc(770, 1, 1, 0); + + // === Sun + GL11.glRotatef(world.getCelestialAngle(partialTicks) * 360.0F, 1.0F, 0.0F, 0.0F); + f10 = 60.0F; + mc.renderEngine.bindTexture(textureSun); + drawObject(tessellator1, f10); + + // === Moon + f10 = 60.0F; + mc.renderEngine.bindTexture(textureMoonPhases); + int k = world.getMoonPhase(); + int l = k % 4; + int i1 = k / 4 % 2; + float f14 = (float)(l + 0) / 4.0F; + float f15 = (float)(i1 + 0) / 2.0F; + float f16 = (float)(l + 1) / 4.0F; + float f17 = (float)(i1 + 1) / 2.0F; + tessellator1.startDrawingQuads(); + tessellator1.addVertexWithUV((double)(-f10), -100.0D, (double)f10, (double)f16, (double)f17); + tessellator1.addVertexWithUV((double)f10, -100.0D, (double)f10, (double)f14, (double)f17); + tessellator1.addVertexWithUV((double)f10, -100.0D, (double)(-f10), (double)f14, (double)f15); + tessellator1.addVertexWithUV((double)(-f10), -100.0D, (double)(-f10), (double)f16, (double)f15); + tessellator1.draw(); + + // === Stars + f6 *= Math.max(0.1F, effCelAng * 2); + float t = (ClientTickHandler.ticksInGame + partialTicks + 2000) * 0.005F; + GL11.glPushMatrix(); + GL11.glDisable(GL11.GL_TEXTURE_2D); + + GL11.glPushMatrix(); + GL11.glRotatef(t * 3, 0F, 1F, 0F); + GL11.glColor4f(1F, 1F, 1F, f6); + GL11.glCallList(starGLCallList); + GL11.glPopMatrix(); + + GL11.glPushMatrix(); + GL11.glRotatef(t, 0F, 1F, 0F); + GL11.glColor4f(0.5F, 1F, 1F, f6); + GL11.glCallList(starGLCallList); + GL11.glPopMatrix(); + + GL11.glPushMatrix(); + GL11.glRotatef(t * 2, 0F, 1F, 0F); + GL11.glColor4f(1F, 0.75F, 0.75F, f6); + GL11.glCallList(starGLCallList); + GL11.glPopMatrix(); + + GL11.glPushMatrix(); + GL11.glRotatef(t * 3, 0F, 0F, 1F); + GL11.glColor4f(1F, 1F, 1F, 0.25F * f6); + GL11.glCallList(starGLCallList); + GL11.glPopMatrix(); + + GL11.glPushMatrix(); + GL11.glRotatef(t, 0F, 0F, 1F); + GL11.glColor4f(0.5F, 1F, 1F, 0.25F * f6); + GL11.glCallList(starGLCallList); + GL11.glPopMatrix(); + + GL11.glPushMatrix(); + GL11.glRotatef(t * 2, 0F, 0F, 1F); + GL11.glColor4f(1F, 0.75F, 0.75F, 0.25F * f6); + GL11.glCallList(starGLCallList); + GL11.glPopMatrix(); + + GL11.glEnable(GL11.GL_TEXTURE_2D); + GL11.glPopMatrix(); + + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + GL11.glDisable(GL11.GL_BLEND); + GL11.glEnable(GL11.GL_ALPHA_TEST); + GL11.glEnable(GL11.GL_FOG); + GL11.glPopMatrix(); + GL11.glDepthMask(true); + } + + private void drawObject(Tessellator tess, float f10) { + tess.startDrawingQuads(); + tess.addVertexWithUV((double)(-f10), 100.0D, (double)(-f10), 0.0D, 0.0D); + tess.addVertexWithUV((double)f10, 100.0D, (double)(-f10), 1.0D, 0.0D); + tess.addVertexWithUV((double)f10, 100.0D, (double)f10, 1.0D, 1.0D); + tess.addVertexWithUV((double)(-f10), 100.0D, (double)f10, 0.0D, 1.0D); + tess.draw(); + } + } diff --git a/src/main/java/vazkii/botania/common/Botania.java b/src/main/java/vazkii/botania/common/Botania.java index 0366d12e43..8d43e9d713 100644 --- a/src/main/java/vazkii/botania/common/Botania.java +++ b/src/main/java/vazkii/botania/common/Botania.java @@ -2,14 +2,21 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jan 13, 2014, 6:32:39 PM (GMT)] */ package vazkii.botania.common; +import vazkii.botania.common.core.handler.IMCHandler; +import vazkii.botania.common.core.handler.ManaNetworkHandler; +import vazkii.botania.common.core.proxy.CommonProxy; +import vazkii.botania.common.integration.coloredlights.ILightHelper; +import vazkii.botania.common.integration.coloredlights.LightHelperColored; +import vazkii.botania.common.integration.coloredlights.LightHelperVanilla; +import vazkii.botania.common.lib.LibMisc; import cpw.mods.fml.common.Loader; import cpw.mods.fml.common.Mod; import cpw.mods.fml.common.Mod.EventHandler; @@ -23,87 +30,74 @@ import cpw.mods.fml.common.event.FMLServerAboutToStartEvent; import cpw.mods.fml.common.event.FMLServerStartingEvent; import cpw.mods.fml.common.event.FMLServerStoppingEvent; -import vazkii.botania.common.core.handler.IMCHandler; -import vazkii.botania.common.core.handler.ManaNetworkHandler; -import vazkii.botania.common.core.proxy.CommonProxy; -import vazkii.botania.common.integration.coloredlights.ILightHelper; -import vazkii.botania.common.integration.coloredlights.LightHelperColored; -import vazkii.botania.common.integration.coloredlights.LightHelperVanilla; -import vazkii.botania.common.lib.LibMisc; -@Mod( - modid = LibMisc.MOD_ID, - name = LibMisc.MOD_NAME, - version = LibMisc.VERSION, - dependencies = LibMisc.DEPENDENCIES, - guiFactory = LibMisc.GUI_FACTORY) +@Mod(modid = LibMisc.MOD_ID, name = LibMisc.MOD_NAME, version = LibMisc.VERSION, dependencies = LibMisc.DEPENDENCIES, guiFactory = LibMisc.GUI_FACTORY) public class Botania { - public static boolean gardenOfGlassLoaded = false; - - public static boolean thaumcraftLoaded = false; - public static boolean bcTriggersLoaded = false; - public static boolean bloodMagicLoaded = false; - public static boolean coloredLightsLoaded = false; - public static boolean etFuturumLoaded = false; - public static boolean storageDrawersLoaded = false; - - public static ILightHelper lightHelper; - - @Instance(LibMisc.MOD_ID) - public static Botania instance; - - @SidedProxy(serverSide = LibMisc.PROXY_COMMON, clientSide = LibMisc.PROXY_CLIENT) - public static CommonProxy proxy; - - @EventHandler - public void preInit(FMLPreInitializationEvent event) { - gardenOfGlassLoaded = Loader.isModLoaded("GardenOfGlass"); - - thaumcraftLoaded = Loader.isModLoaded("Thaumcraft"); - bcTriggersLoaded = ModAPIManager.INSTANCE.hasAPI("BuildCraftAPI|statements"); - bloodMagicLoaded = Loader.isModLoaded("AWWayofTime"); // Psh, noob - coloredLightsLoaded = Loader.isModLoaded("easycoloredlights"); - etFuturumLoaded = Loader.isModLoaded("etfuturum"); - storageDrawersLoaded = Loader.isModLoaded("StorageDrawers"); - - lightHelper = coloredLightsLoaded ? new LightHelperColored() : new LightHelperVanilla(); - - proxy.preInit(event); - } - - @EventHandler - public void init(FMLInitializationEvent event) { - proxy.init(event); - } - - @EventHandler - public void postInit(FMLPostInitializationEvent event) { - proxy.postInit(event); - } - - @EventHandler - public void serverStarting(FMLServerAboutToStartEvent event) { - proxy.serverAboutToStart(event); - } - - @EventHandler - public void serverStarting(FMLServerStartingEvent event) { - proxy.serverStarting(event); - } - - @EventHandler - public void serverStopping(FMLServerStoppingEvent event) { - ManaNetworkHandler.instance.clear(); - } - - @EventHandler - public void handleIMC(FMLInterModComms.IMCEvent event) { - IMCHandler.processMessages(event.getMessages()); - } - - /*@EventHandler - public void missingMappings(FMLMissingMappingsEvent event) { - AliasHandler.onMissingMappings(event); - }*/ + public static boolean gardenOfGlassLoaded = false; + + public static boolean thaumcraftLoaded = false; + public static boolean bcTriggersLoaded = false; + public static boolean bloodMagicLoaded = false; + public static boolean coloredLightsLoaded = false; + public static boolean etFuturumLoaded = false; + public static boolean storageDrawersLoaded = false; + + public static ILightHelper lightHelper; + + @Instance(LibMisc.MOD_ID) + public static Botania instance; + + @SidedProxy(serverSide = LibMisc.PROXY_COMMON, clientSide = LibMisc.PROXY_CLIENT) + public static CommonProxy proxy; + + @EventHandler + public void preInit(FMLPreInitializationEvent event) { + gardenOfGlassLoaded = Loader.isModLoaded("GardenOfGlass"); + + thaumcraftLoaded = Loader.isModLoaded("Thaumcraft"); + bcTriggersLoaded = ModAPIManager.INSTANCE.hasAPI("BuildCraftAPI|statements"); + bloodMagicLoaded = Loader.isModLoaded("AWWayofTime"); // Psh, noob + coloredLightsLoaded = Loader.isModLoaded("easycoloredlights"); + etFuturumLoaded = Loader.isModLoaded("etfuturum"); + storageDrawersLoaded = Loader.isModLoaded("StorageDrawers"); + + lightHelper = coloredLightsLoaded ? new LightHelperColored() : new LightHelperVanilla(); + + proxy.preInit(event); + } + @EventHandler + public void init(FMLInitializationEvent event) { + proxy.init(event); + } + + @EventHandler + public void postInit(FMLPostInitializationEvent event) { + proxy.postInit(event); + } + + @EventHandler + public void serverStarting(FMLServerAboutToStartEvent event) { + proxy.serverAboutToStart(event); + } + + @EventHandler + public void serverStarting(FMLServerStartingEvent event) { + proxy.serverStarting(event); + } + + @EventHandler + public void serverStopping(FMLServerStoppingEvent event) { + ManaNetworkHandler.instance.clear(); + } + + @EventHandler + public void handleIMC(FMLInterModComms.IMCEvent event) { + IMCHandler.processMessages(event.getMessages()); + } + + /*@EventHandler + public void missingMappings(FMLMissingMappingsEvent event) { + AliasHandler.onMissingMappings(event); + }*/ } diff --git a/src/main/java/vazkii/botania/common/CustomBotaniaAPI.java b/src/main/java/vazkii/botania/common/CustomBotaniaAPI.java index a67d948473..0bf1db8bc2 100644 --- a/src/main/java/vazkii/botania/common/CustomBotaniaAPI.java +++ b/src/main/java/vazkii/botania/common/CustomBotaniaAPI.java @@ -1,10 +1,12 @@ package vazkii.botania.common; -import java.util.HashMap; -import java.util.Map; import net.minecraft.item.Item; import vazkii.botania.api.recipe.IFlowerComponent; +import java.util.HashMap; +import java.util.Map; +import java.util.Set; + public class CustomBotaniaAPI { public static Map extraFlowerComponents = new HashMap(); } diff --git a/src/main/java/vazkii/botania/common/achievement/AchievementMod.java b/src/main/java/vazkii/botania/common/achievement/AchievementMod.java index 359ec44d29..7da1fa5f2c 100644 --- a/src/main/java/vazkii/botania/common/achievement/AchievementMod.java +++ b/src/main/java/vazkii/botania/common/achievement/AchievementMod.java @@ -2,16 +2,17 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jan 28, 2015, 4:41:43 PM (GMT)] */ package vazkii.botania.common.achievement; import java.util.ArrayList; import java.util.List; + import net.minecraft.block.Block; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; @@ -20,21 +21,23 @@ public class AchievementMod extends Achievement { - public static List achievements = new ArrayList(); + public static List achievements = new ArrayList(); + + public AchievementMod(String name, int x, int y, ItemStack icon, Achievement parent) { + super("achievement.botania:" + name, "botania:" + name, x, y, icon, parent); + achievements.add(this); + registerStat(); - public AchievementMod(String name, int x, int y, ItemStack icon, Achievement parent) { - super("achievement.botania:" + name, "botania:" + name, x, y, icon, parent); - achievements.add(this); - registerStat(); + if(icon.getItem() instanceof IRelic) + ((IRelic) icon.getItem()).setBindAchievement(this); + } - if (icon.getItem() instanceof IRelic) ((IRelic) icon.getItem()).setBindAchievement(this); - } + public AchievementMod(String name, int x, int y, Item icon, Achievement parent) { + this(name, x, y, new ItemStack(icon), parent); + } - public AchievementMod(String name, int x, int y, Item icon, Achievement parent) { - this(name, x, y, new ItemStack(icon), parent); - } + public AchievementMod(String name, int x, int y, Block icon, Achievement parent) { + this(name, x, y, new ItemStack(icon), parent); + } - public AchievementMod(String name, int x, int y, Block icon, Achievement parent) { - this(name, x, y, new ItemStack(icon), parent); - } } diff --git a/src/main/java/vazkii/botania/common/achievement/AchievementTriggerer.java b/src/main/java/vazkii/botania/common/achievement/AchievementTriggerer.java index 36a69ce612..0d67196f9e 100644 --- a/src/main/java/vazkii/botania/common/achievement/AchievementTriggerer.java +++ b/src/main/java/vazkii/botania/common/achievement/AchievementTriggerer.java @@ -2,38 +2,39 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jan 28, 2015, 5:57:07 PM (GMT)] */ package vazkii.botania.common.achievement; +import net.minecraft.item.ItemStack; +import net.minecraft.stats.Achievement; import cpw.mods.fml.common.eventhandler.SubscribeEvent; import cpw.mods.fml.common.gameevent.PlayerEvent.ItemCraftedEvent; import cpw.mods.fml.common.gameevent.PlayerEvent.ItemPickupEvent; -import net.minecraft.item.ItemStack; -import net.minecraft.stats.Achievement; public final class AchievementTriggerer { - @SubscribeEvent - public void onItemPickedUp(ItemPickupEvent event) { - ItemStack stack = event.pickedUp.getEntityItem(); - if (stack != null && stack.getItem() instanceof IPickupAchievement) { - Achievement achievement = - ((IPickupAchievement) stack.getItem()).getAchievementOnPickup(stack, event.player, event.pickedUp); - if (achievement != null) event.player.addStat(achievement, 1); - } - } + @SubscribeEvent + public void onItemPickedUp(ItemPickupEvent event) { + ItemStack stack = event.pickedUp.getEntityItem(); + if(stack != null && stack.getItem() instanceof IPickupAchievement) { + Achievement achievement = ((IPickupAchievement) stack.getItem()).getAchievementOnPickup(stack, event.player, event.pickedUp); + if(achievement != null) + event.player.addStat(achievement, 1); + } + } + + @SubscribeEvent + public void onItemCrafted(ItemCraftedEvent event) { + if(event.crafting != null && event.crafting.getItem() instanceof ICraftAchievement) { + Achievement achievement = ((ICraftAchievement) event.crafting.getItem()).getAchievementOnCraft(event.crafting, event.player, event.craftMatrix); + if(achievement != null) + event.player.addStat(achievement, 1); + } + } - @SubscribeEvent - public void onItemCrafted(ItemCraftedEvent event) { - if (event.crafting != null && event.crafting.getItem() instanceof ICraftAchievement) { - Achievement achievement = ((ICraftAchievement) event.crafting.getItem()) - .getAchievementOnCraft(event.crafting, event.player, event.craftMatrix); - if (achievement != null) event.player.addStat(achievement, 1); - } - } } diff --git a/src/main/java/vazkii/botania/common/achievement/ICraftAchievement.java b/src/main/java/vazkii/botania/common/achievement/ICraftAchievement.java index 06b99f1d68..279fb06db5 100644 --- a/src/main/java/vazkii/botania/common/achievement/ICraftAchievement.java +++ b/src/main/java/vazkii/botania/common/achievement/ICraftAchievement.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jan 28, 2015, 5:59:07 PM (GMT)] */ package vazkii.botania.common.achievement; @@ -17,5 +17,6 @@ public interface ICraftAchievement { - public Achievement getAchievementOnCraft(ItemStack stack, EntityPlayer player, IInventory matrix); + public Achievement getAchievementOnCraft(ItemStack stack, EntityPlayer player, IInventory matrix); + } diff --git a/src/main/java/vazkii/botania/common/achievement/IPickupAchievement.java b/src/main/java/vazkii/botania/common/achievement/IPickupAchievement.java index 7a14b22981..2276c2f1cf 100644 --- a/src/main/java/vazkii/botania/common/achievement/IPickupAchievement.java +++ b/src/main/java/vazkii/botania/common/achievement/IPickupAchievement.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jan 28, 2015, 5:59:03 PM (GMT)] */ package vazkii.botania.common.achievement; @@ -17,5 +17,6 @@ public interface IPickupAchievement { - public Achievement getAchievementOnPickup(ItemStack stack, EntityPlayer player, EntityItem item); + public Achievement getAchievementOnPickup(ItemStack stack, EntityPlayer player, EntityItem item); + } diff --git a/src/main/java/vazkii/botania/common/achievement/ModAchievements.java b/src/main/java/vazkii/botania/common/achievement/ModAchievements.java index e08509de71..9db5d62dda 100644 --- a/src/main/java/vazkii/botania/common/achievement/ModAchievements.java +++ b/src/main/java/vazkii/botania/common/achievement/ModAchievements.java @@ -2,15 +2,14 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jan 28, 2015, 4:27:39 PM (GMT)] */ package vazkii.botania.common.achievement; -import cpw.mods.fml.common.FMLCommonHandler; import net.minecraft.init.Items; import net.minecraft.item.ItemStack; import net.minecraft.stats.Achievement; @@ -22,217 +21,144 @@ import vazkii.botania.common.lib.LibAchievementNames; import vazkii.botania.common.lib.LibBlockNames; import vazkii.botania.common.lib.LibMisc; +import cpw.mods.fml.common.FMLCommonHandler; public final class ModAchievements { - public static AchievementPage botaniaPage; - public static int pageIndex; - - public static Achievement flowerPickup; - public static Achievement lexiconUse; - public static Achievement daybloomPickup; - public static Achievement cacophoniumCraft; - public static Achievement manaPoolPickup; - - public static Achievement endoflamePickup; - public static Achievement tinyPotatoPet; - public static Achievement sparkCraft; - public static Achievement baubleWear; - public static Achievement manaCookieEat; - public static Achievement manaweaveArmorCraft; - public static Achievement craftingHaloCraft; - public static Achievement manaCartCraft; - public static Achievement enchanterMake; - public static Achievement runePickup; - - public static Achievement dirtRodCraft; - public static Achievement terraformRodCraft; - public static Achievement manaBlasterShoot; - public static Achievement pollidisiacPickup; - public static Achievement brewPickup; - public static Achievement terrasteelPickup; - - public static Achievement terrasteelWeaponCraft; - public static Achievement elfPortalOpen; - - public static Achievement kekimurusPickup; - public static Achievement heiseiDreamPickup; - public static Achievement bubbellPickup; - public static Achievement luminizerRide; - - public static Achievement enderAirMake; - public static Achievement corporeaCraft; - - public static Achievement gaiaGuardianKill; - - public static Achievement spawnerMoverUse; - public static Achievement tiaraWings; - public static Achievement manaBombIgnite; - public static Achievement dandelifeonPickup; - - public static Achievement signalFlareStun; - public static Achievement l20ShardUse; - public static Achievement gaiaGuardianNoArmor; - public static Achievement rankSSPick; - public static Achievement superCorporeaRequest; - public static Achievement pinkinator; - - public static Achievement relicInfiniteFruit; - public static Achievement relicKingKey; - public static Achievement relicFlugelEye; - public static Achievement relicThorRing; - public static Achievement relicOdinRing; - public static Achievement relicLokiRing; - public static Achievement relicAesirRing; - - public static Achievement nullFlower; - public static Achievement desuGun; - - public static void init() { - flowerPickup = new AchievementMod( - LibAchievementNames.FLOWER_PICKUP, 0, 4, new ItemStack(ModBlocks.flower, 1, 6), null); - lexiconUse = new AchievementMod(LibAchievementNames.LEXICON_USE, 1, 5, ModItems.lexicon, flowerPickup); - daybloomPickup = new AchievementMod( - LibAchievementNames.DAYBLOOM_PICKUP, - 3, - 5, - ItemBlockSpecialFlower.ofType(LibBlockNames.SUBTILE_DAYBLOOM), - lexiconUse); - cacophoniumCraft = - new AchievementMod(LibAchievementNames.CACOPHONIUM_CRAFT, -1, 2, ModItems.cacophonium, flowerPickup); - manaPoolPickup = new AchievementMod(LibAchievementNames.MANA_POOL_PICKUP, 3, 2, ModBlocks.pool, daybloomPickup); - - endoflamePickup = new AchievementMod( - LibAchievementNames.ENDOFLAME_PICKUP, - 2, - 0, - ItemBlockSpecialFlower.ofType(LibBlockNames.SUBTILE_ENDOFLAME), - manaPoolPickup); - tinyPotatoPet = - new AchievementMod(LibAchievementNames.TINY_POTATO_PET, 2, -2, ModBlocks.tinyPotato, manaPoolPickup); - sparkCraft = new AchievementMod(LibAchievementNames.SPARK_CRAFT, 4, -2, ModItems.spark, manaPoolPickup); - baubleWear = new AchievementMod(LibAchievementNames.BAUBLE_WEAR, 4, 0, ModItems.manaRing, manaPoolPickup); - manaCookieEat = - new AchievementMod(LibAchievementNames.MANA_COOKIE_EAT, 2, -4, ModItems.manaCookie, manaPoolPickup); - manaweaveArmorCraft = new AchievementMod( - LibAchievementNames.MANAWEAVE_ARMOR_CRAFT, 4, -4, ModItems.manaweaveChest, manaPoolPickup); - craftingHaloCraft = new AchievementMod( - LibAchievementNames.CRAFTING_HALO_CRAFT, 3, -6, ModItems.craftingHalo, manaPoolPickup); - manaCartCraft = - new AchievementMod(LibAchievementNames.MANA_CART_CRAFT, 5, 3, ModItems.poolMinecart, manaPoolPickup); - enchanterMake = - new AchievementMod(LibAchievementNames.ENCHANTER_MAKE, 1, 2, ModBlocks.enchanter, manaPoolPickup); - runePickup = new AchievementMod(LibAchievementNames.RUNE_PICKUP, 6, 2, ModBlocks.runeAltar, manaPoolPickup); - - dirtRodCraft = new AchievementMod(LibAchievementNames.DIRT_ROD_CRAFT, 8, 3, ModItems.dirtRod, runePickup); - terraformRodCraft = - new AchievementMod(LibAchievementNames.TERRAFORM_ROD_CRAFT, 10, 3, ModItems.terraformRod, dirtRodCraft); - manaBlasterShoot = - new AchievementMod(LibAchievementNames.MANA_BLASTER_SHOOT, 8, 1, ModItems.manaGun, runePickup); - pollidisiacPickup = new AchievementMod( - LibAchievementNames.POLLIDISIAC_PICKUP, - 8, - 5, - ItemBlockSpecialFlower.ofType(LibBlockNames.SUBTILE_POLLIDISIAC), - runePickup); - brewPickup = new AchievementMod(LibAchievementNames.BREW_PICKUP, 6, 0, ModBlocks.brewery, runePickup); - terrasteelPickup = new AchievementMod( - LibAchievementNames.TERRASTEEL_PICKUP, - 6, - 9, - new ItemStack(ModItems.manaResource, 1, 4), - runePickup) - .setSpecial(); - - terrasteelWeaponCraft = new AchievementMod( - LibAchievementNames.TERRASTEEL_WEAPON_CRAFT, 8, 10, ModItems.terraSword, terrasteelPickup); - elfPortalOpen = new AchievementMod( - LibAchievementNames.ELF_PORTAL_OPEN, 4, 9, ModBlocks.alfPortal, terrasteelPickup) - .setSpecial(); - - kekimurusPickup = new AchievementMod( - LibAchievementNames.KEKIMURUS_PICKUP, - 3, - 11, - ItemBlockSpecialFlower.ofType(LibBlockNames.SUBTILE_KEKIMURUS), - elfPortalOpen); - heiseiDreamPickup = new AchievementMod( - LibAchievementNames.HEISEI_DREAM_PICKUP, - 5, - 11, - ItemBlockSpecialFlower.ofType(LibBlockNames.SUBTILE_HEISEI_DREAM), - elfPortalOpen); - bubbellPickup = new AchievementMod( - LibAchievementNames.BUBBELL_PICKUP, - 6, - 12, - ItemBlockSpecialFlower.ofType(LibBlockNames.SUBTILE_BUBBELL), - elfPortalOpen); - enderAirMake = new AchievementMod( - LibAchievementNames.ENDER_AIR_MAKE, 4, 14, new ItemStack(ModItems.manaResource, 1, 15), elfPortalOpen); - corporeaCraft = - new AchievementMod(LibAchievementNames.CORPOREA_CRAFT, 2, 14, ModBlocks.corporeaFunnel, enderAirMake); - luminizerRide = - new AchievementMod(LibAchievementNames.LUMINIZER_RIDE, 6, 14, ModBlocks.lightRelay, enderAirMake); - - gaiaGuardianKill = new AchievementMod( - LibAchievementNames.GAIA_GUARDIAN_KILL, - 2, - 9, - new ItemStack(ModItems.manaResource, 1, 5), - elfPortalOpen) - .setSpecial(); - - spawnerMoverUse = new AchievementMod( - LibAchievementNames.SPAWNER_MOVER_USE, -1, 10, ModItems.spawnerMover, gaiaGuardianKill); - tiaraWings = new AchievementMod(LibAchievementNames.TIARA_WINGS, -1, 8, ModItems.flightTiara, gaiaGuardianKill); - manaBombIgnite = - new AchievementMod(LibAchievementNames.MANA_BOMB_IGNITE, 0, 11, ModBlocks.manaBomb, gaiaGuardianKill); - dandelifeonPickup = new AchievementMod( - LibAchievementNames.DANDELIFEON_PICKUP, - 0, - 7, - ItemBlockSpecialFlower.ofType(LibBlockNames.SUBTILE_DANDELIFEON), - gaiaGuardianKill); - - signalFlareStun = new AchievementMod(LibAchievementNames.SIGNAL_FLARE_STUN, -3, 1, ModItems.signalFlare, null) - .setSpecial(); - l20ShardUse = - new AchievementMod(LibAchievementNames.L20_SHARD_USE, -5, 3, ModItems.laputaShard, null).setSpecial(); - gaiaGuardianNoArmor = new AchievementMod( - LibAchievementNames.GAIA_GUARDIAN_NO_ARMOR, -5, 1, new ItemStack(Items.skull, 1, 3), null) - .setSpecial(); - rankSSPick = new AchievementMod(LibAchievementNames.RANK_SS_PICK, -3, 3, ModItems.terraPick, null).setSpecial(); - superCorporeaRequest = new AchievementMod( - LibAchievementNames.SUPER_CORPOREA_REQUEST, -3, -1, ModBlocks.corporeaIndex, null) - .setSpecial(); - pinkinator = new AchievementMod(LibAchievementNames.PINKINATOR, -5, -1, ModItems.pinkinator, null).setSpecial(); - - if (ConfigHandler.relicsEnabled) { - relicInfiniteFruit = - new AchievementMod(LibAchievementNames.RELIC_INFINITE_FRUIT, -9, 8, ModItems.infiniteFruit, null); - relicKingKey = new AchievementMod(LibAchievementNames.RELIC_KING_KEY, -7, 11, ModItems.kingKey, null); - relicFlugelEye = new AchievementMod(LibAchievementNames.RELIC_FLUGEL_EYE, -5, 8, ModItems.flugelEye, null); - relicThorRing = new AchievementMod(LibAchievementNames.RELIC_THOR_RING, -7, 7, ModItems.thorRing, null); - relicOdinRing = new AchievementMod(LibAchievementNames.RELIC_ODIN_RING, -9, 10, ModItems.odinRing, null); - relicLokiRing = new AchievementMod(LibAchievementNames.RELIC_LOKI_RING, -5, 10, ModItems.lokiRing, null); - relicAesirRing = new AchievementMod(LibAchievementNames.RELIC_AESIR_RING, -7, 9, ModItems.aesirRing, null) - .setSpecial(); - } - - nullFlower = - new AchievementMod(LibAchievementNames.NULL_FLOWER, -8, 0, ModBlocks.specialFlower, null).setSpecial(); - - ItemStack desu = new ItemStack(ModItems.manaGun); - desu.setStackDisplayName("desu gun"); - desuGun = new AchievementMod(LibAchievementNames.DESU_GUN, -8, 2, desu, null).setSpecial(); - - pageIndex = AchievementPage.getAchievementPages().size(); - botaniaPage = new AchievementPage( - LibMisc.MOD_NAME, - AchievementMod.achievements.toArray(new Achievement[AchievementMod.achievements.size()])); - AchievementPage.registerAchievementPage(botaniaPage); - - FMLCommonHandler.instance().bus().register(new AchievementTriggerer()); - } + public static AchievementPage botaniaPage; + public static int pageIndex; + + public static Achievement flowerPickup; + public static Achievement lexiconUse; + public static Achievement daybloomPickup; + public static Achievement cacophoniumCraft; + public static Achievement manaPoolPickup; + + public static Achievement endoflamePickup; + public static Achievement tinyPotatoPet; + public static Achievement sparkCraft; + public static Achievement baubleWear; + public static Achievement manaCookieEat; + public static Achievement manaweaveArmorCraft; + public static Achievement craftingHaloCraft; + public static Achievement manaCartCraft; + public static Achievement enchanterMake; + public static Achievement runePickup; + + public static Achievement dirtRodCraft; + public static Achievement terraformRodCraft; + public static Achievement manaBlasterShoot; + public static Achievement pollidisiacPickup; + public static Achievement brewPickup; + public static Achievement terrasteelPickup; + + public static Achievement terrasteelWeaponCraft; + public static Achievement elfPortalOpen; + + public static Achievement kekimurusPickup; + public static Achievement heiseiDreamPickup; + public static Achievement bubbellPickup; + public static Achievement luminizerRide; + + public static Achievement enderAirMake; + public static Achievement corporeaCraft; + + public static Achievement gaiaGuardianKill; + + public static Achievement spawnerMoverUse; + public static Achievement tiaraWings; + public static Achievement manaBombIgnite; + public static Achievement dandelifeonPickup; + + public static Achievement signalFlareStun; + public static Achievement l20ShardUse; + public static Achievement gaiaGuardianNoArmor; + public static Achievement rankSSPick; + public static Achievement superCorporeaRequest; + public static Achievement pinkinator; + + public static Achievement relicInfiniteFruit; + public static Achievement relicKingKey; + public static Achievement relicFlugelEye; + public static Achievement relicThorRing; + public static Achievement relicOdinRing; + public static Achievement relicLokiRing; + public static Achievement relicAesirRing; + + public static Achievement nullFlower; + public static Achievement desuGun; + + public static void init() { + flowerPickup = new AchievementMod(LibAchievementNames.FLOWER_PICKUP, 0, 4, new ItemStack(ModBlocks.flower, 1, 6), null); + lexiconUse = new AchievementMod(LibAchievementNames.LEXICON_USE, 1, 5, ModItems.lexicon, flowerPickup); + daybloomPickup = new AchievementMod(LibAchievementNames.DAYBLOOM_PICKUP, 3, 5, ItemBlockSpecialFlower.ofType(LibBlockNames.SUBTILE_DAYBLOOM), lexiconUse); + cacophoniumCraft = new AchievementMod(LibAchievementNames.CACOPHONIUM_CRAFT, -1, 2, ModItems.cacophonium, flowerPickup); + manaPoolPickup = new AchievementMod(LibAchievementNames.MANA_POOL_PICKUP, 3, 2, ModBlocks.pool, daybloomPickup); + + endoflamePickup = new AchievementMod(LibAchievementNames.ENDOFLAME_PICKUP, 2, 0, ItemBlockSpecialFlower.ofType(LibBlockNames.SUBTILE_ENDOFLAME), manaPoolPickup); + tinyPotatoPet = new AchievementMod(LibAchievementNames.TINY_POTATO_PET, 2, -2, ModBlocks.tinyPotato, manaPoolPickup); + sparkCraft = new AchievementMod(LibAchievementNames.SPARK_CRAFT, 4, -2, ModItems.spark, manaPoolPickup); + baubleWear = new AchievementMod(LibAchievementNames.BAUBLE_WEAR, 4, 0, ModItems.manaRing, manaPoolPickup); + manaCookieEat = new AchievementMod(LibAchievementNames.MANA_COOKIE_EAT, 2, -4, ModItems.manaCookie, manaPoolPickup); + manaweaveArmorCraft = new AchievementMod(LibAchievementNames.MANAWEAVE_ARMOR_CRAFT, 4, -4, ModItems.manaweaveChest, manaPoolPickup); + craftingHaloCraft = new AchievementMod(LibAchievementNames.CRAFTING_HALO_CRAFT, 3, -6, ModItems.craftingHalo, manaPoolPickup); + manaCartCraft = new AchievementMod(LibAchievementNames.MANA_CART_CRAFT, 5, 3, ModItems.poolMinecart, manaPoolPickup); + enchanterMake = new AchievementMod(LibAchievementNames.ENCHANTER_MAKE, 1, 2, ModBlocks.enchanter, manaPoolPickup); + runePickup = new AchievementMod(LibAchievementNames.RUNE_PICKUP, 6, 2, ModBlocks.runeAltar, manaPoolPickup); + + dirtRodCraft = new AchievementMod(LibAchievementNames.DIRT_ROD_CRAFT, 8, 3, ModItems.dirtRod, runePickup); + terraformRodCraft = new AchievementMod(LibAchievementNames.TERRAFORM_ROD_CRAFT, 10, 3, ModItems.terraformRod, dirtRodCraft); + manaBlasterShoot = new AchievementMod(LibAchievementNames.MANA_BLASTER_SHOOT, 8, 1, ModItems.manaGun, runePickup); + pollidisiacPickup = new AchievementMod(LibAchievementNames.POLLIDISIAC_PICKUP, 8, 5, ItemBlockSpecialFlower.ofType(LibBlockNames.SUBTILE_POLLIDISIAC), runePickup); + brewPickup = new AchievementMod(LibAchievementNames.BREW_PICKUP, 6, 0, ModBlocks.brewery, runePickup); + terrasteelPickup = new AchievementMod(LibAchievementNames.TERRASTEEL_PICKUP, 6, 9, new ItemStack(ModItems.manaResource, 1, 4), runePickup).setSpecial(); + + terrasteelWeaponCraft = new AchievementMod(LibAchievementNames.TERRASTEEL_WEAPON_CRAFT, 8, 10, ModItems.terraSword, terrasteelPickup); + elfPortalOpen = new AchievementMod(LibAchievementNames.ELF_PORTAL_OPEN, 4, 9, ModBlocks.alfPortal, terrasteelPickup).setSpecial(); + + kekimurusPickup = new AchievementMod(LibAchievementNames.KEKIMURUS_PICKUP, 3, 11, ItemBlockSpecialFlower.ofType(LibBlockNames.SUBTILE_KEKIMURUS), elfPortalOpen); + heiseiDreamPickup = new AchievementMod(LibAchievementNames.HEISEI_DREAM_PICKUP, 5, 11, ItemBlockSpecialFlower.ofType(LibBlockNames.SUBTILE_HEISEI_DREAM), elfPortalOpen); + bubbellPickup = new AchievementMod(LibAchievementNames.BUBBELL_PICKUP, 6, 12, ItemBlockSpecialFlower.ofType(LibBlockNames.SUBTILE_BUBBELL), elfPortalOpen); + enderAirMake = new AchievementMod(LibAchievementNames.ENDER_AIR_MAKE, 4, 14, new ItemStack(ModItems.manaResource, 1, 15), elfPortalOpen); + corporeaCraft = new AchievementMod(LibAchievementNames.CORPOREA_CRAFT, 2, 14, ModBlocks.corporeaFunnel, enderAirMake); + luminizerRide = new AchievementMod(LibAchievementNames.LUMINIZER_RIDE, 6, 14, ModBlocks.lightRelay, enderAirMake); + + gaiaGuardianKill = new AchievementMod(LibAchievementNames.GAIA_GUARDIAN_KILL, 2, 9, new ItemStack(ModItems.manaResource, 1, 5), elfPortalOpen).setSpecial(); + + spawnerMoverUse = new AchievementMod(LibAchievementNames.SPAWNER_MOVER_USE, -1, 10, ModItems.spawnerMover, gaiaGuardianKill); + tiaraWings = new AchievementMod(LibAchievementNames.TIARA_WINGS, -1, 8, ModItems.flightTiara, gaiaGuardianKill); + manaBombIgnite = new AchievementMod(LibAchievementNames.MANA_BOMB_IGNITE, 0, 11, ModBlocks.manaBomb, gaiaGuardianKill); + dandelifeonPickup = new AchievementMod(LibAchievementNames.DANDELIFEON_PICKUP, 0, 7, ItemBlockSpecialFlower.ofType(LibBlockNames.SUBTILE_DANDELIFEON), gaiaGuardianKill); + + signalFlareStun = new AchievementMod(LibAchievementNames.SIGNAL_FLARE_STUN, -3, 1, ModItems.signalFlare, null).setSpecial(); + l20ShardUse = new AchievementMod(LibAchievementNames.L20_SHARD_USE, -5, 3, ModItems.laputaShard, null).setSpecial(); + gaiaGuardianNoArmor = new AchievementMod(LibAchievementNames.GAIA_GUARDIAN_NO_ARMOR, -5, 1, new ItemStack(Items.skull, 1, 3), null).setSpecial(); + rankSSPick = new AchievementMod(LibAchievementNames.RANK_SS_PICK, -3, 3, ModItems.terraPick, null).setSpecial(); + superCorporeaRequest = new AchievementMod(LibAchievementNames.SUPER_CORPOREA_REQUEST, -3, -1, ModBlocks.corporeaIndex, null).setSpecial(); + pinkinator = new AchievementMod(LibAchievementNames.PINKINATOR, -5, -1, ModItems.pinkinator, null).setSpecial(); + + if(ConfigHandler.relicsEnabled) { + relicInfiniteFruit = new AchievementMod(LibAchievementNames.RELIC_INFINITE_FRUIT, -9, 8, ModItems.infiniteFruit, null); + relicKingKey = new AchievementMod(LibAchievementNames.RELIC_KING_KEY, -7, 11, ModItems.kingKey, null); + relicFlugelEye = new AchievementMod(LibAchievementNames.RELIC_FLUGEL_EYE, -5, 8, ModItems.flugelEye, null); + relicThorRing = new AchievementMod(LibAchievementNames.RELIC_THOR_RING, -7, 7, ModItems.thorRing, null); + relicOdinRing = new AchievementMod(LibAchievementNames.RELIC_ODIN_RING, -9, 10, ModItems.odinRing, null); + relicLokiRing = new AchievementMod(LibAchievementNames.RELIC_LOKI_RING, -5, 10, ModItems.lokiRing, null); + relicAesirRing = new AchievementMod(LibAchievementNames.RELIC_AESIR_RING, -7, 9, ModItems.aesirRing, null).setSpecial(); + } + + nullFlower = new AchievementMod(LibAchievementNames.NULL_FLOWER, -8, 0, ModBlocks.specialFlower, null).setSpecial(); + + ItemStack desu = new ItemStack(ModItems.manaGun); + desu.setStackDisplayName("desu gun"); + desuGun = new AchievementMod(LibAchievementNames.DESU_GUN, -8, 2, desu, null).setSpecial(); + + pageIndex = AchievementPage.getAchievementPages().size(); + botaniaPage = new AchievementPage(LibMisc.MOD_NAME, AchievementMod.achievements.toArray(new Achievement[AchievementMod.achievements.size()])); + AchievementPage.registerAchievementPage(botaniaPage); + + FMLCommonHandler.instance().bus().register(new AchievementTriggerer()); + } + } + diff --git a/src/main/java/vazkii/botania/common/block/BlockAlfPortal.java b/src/main/java/vazkii/botania/common/block/BlockAlfPortal.java index 371266cb9e..2e8245885e 100644 --- a/src/main/java/vazkii/botania/common/block/BlockAlfPortal.java +++ b/src/main/java/vazkii/botania/common/block/BlockAlfPortal.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jun 9, 2014, 7:17:46 PM (GMT)] */ package vazkii.botania.common.block; @@ -29,47 +29,49 @@ public class BlockAlfPortal extends BlockModContainer implements IWandable, ILexiconable { - IIcon iconOff, iconOn; - public static IIcon portalTex; + IIcon iconOff, iconOn; + public static IIcon portalTex; - public BlockAlfPortal() { - super(Material.wood); - setHardness(10F); - setStepSound(soundTypeWood); - setBlockName(LibBlockNames.ALF_PORTAL); - } + public BlockAlfPortal() { + super(Material.wood); + setHardness(10F); + setStepSound(soundTypeWood); + setBlockName(LibBlockNames.ALF_PORTAL); + } - @Override - public void registerBlockIcons(IIconRegister par1IconRegister) { - iconOff = IconHelper.forBlock(par1IconRegister, this, 0); - iconOn = IconHelper.forBlock(par1IconRegister, this, 1); - portalTex = IconHelper.forBlock(par1IconRegister, this, "Inside"); - } + @Override + public void registerBlockIcons(IIconRegister par1IconRegister) { + iconOff = IconHelper.forBlock(par1IconRegister, this, 0); + iconOn = IconHelper.forBlock(par1IconRegister, this, 1); + portalTex = IconHelper.forBlock(par1IconRegister, this, "Inside"); + } - @Override - public IIcon getIcon(int side, int meta) { - return meta == 0 ? iconOff : iconOn; - } + @Override + public IIcon getIcon(int side, int meta) { + return meta == 0 ? iconOff : iconOn; + } - @Override - public TileEntity createNewTileEntity(World world, int meta) { - return new TileAlfPortal(); - } + @Override + public TileEntity createNewTileEntity(World world, int meta) { + return new TileAlfPortal(); + } - @Override - public LexiconEntry getEntry(World world, int x, int y, int z, EntityPlayer player, ItemStack lexicon) { - return LexiconData.alfhomancyIntro; - } + @Override + public LexiconEntry getEntry(World world, int x, int y, int z, EntityPlayer player, ItemStack lexicon) { + return LexiconData.alfhomancyIntro; + } - @Override - public boolean onUsedByWand(EntityPlayer player, ItemStack stack, World world, int x, int y, int z, int side) { - boolean did = ((TileAlfPortal) world.getTileEntity(x, y, z)).onWanded(); - if (did && player != null) player.addStat(ModAchievements.elfPortalOpen, 1); - return did; - } + @Override + public boolean onUsedByWand(EntityPlayer player, ItemStack stack, World world, int x, int y, int z, int side) { + boolean did = ((TileAlfPortal) world.getTileEntity(x, y, z)).onWanded(); + if(did && player != null) + player.addStat(ModAchievements.elfPortalOpen, 1); + return did; + } + + @Override + public int getLightValue(IBlockAccess world, int x, int y, int z) { + return world.getBlockMetadata(x, y, z) == 0 ? 0 : 15; + } - @Override - public int getLightValue(IBlockAccess world, int x, int y, int z) { - return world.getBlockMetadata(x, y, z) == 0 ? 0 : 15; - } } diff --git a/src/main/java/vazkii/botania/common/block/BlockAltGrass.java b/src/main/java/vazkii/botania/common/block/BlockAltGrass.java index 63119409a9..1f7a5c3daf 100644 --- a/src/main/java/vazkii/botania/common/block/BlockAltGrass.java +++ b/src/main/java/vazkii/botania/common/block/BlockAltGrass.java @@ -2,17 +2,17 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [17/11/2015, 18:33:30 (GMT)] */ package vazkii.botania.common.block; -import cpw.mods.fml.common.registry.GameRegistry; import java.util.List; import java.util.Random; + import net.minecraft.block.Block; import net.minecraft.block.material.Material; import net.minecraft.client.renderer.texture.IIconRegister; @@ -35,149 +35,118 @@ import vazkii.botania.common.item.block.ItemBlockWithMetadataAndName; import vazkii.botania.common.lexicon.LexiconData; import vazkii.botania.common.lib.LibBlockNames; +import cpw.mods.fml.common.registry.GameRegistry; public class BlockAltGrass extends BlockMod implements ILexiconable { - private static final int SUBTYPES = 6; - IIcon[] icons; - - public BlockAltGrass() { - super(Material.grass); - setHardness(0.6F); - setStepSound(soundTypeGrass); - setBlockName(LibBlockNames.ALT_GRASS); - setTickRandomly(true); - } - - @Override - public boolean isToolEffective(String type, int metadata) { - return type.equals("shovel"); - } - - @Override - public Block setBlockName(String par1Str) { - GameRegistry.registerBlock(this, ItemBlockWithMetadataAndName.class, par1Str); - return super.setBlockName(par1Str); - } - - @Override - protected boolean shouldRegisterInNameSet() { - return false; - } - - @Override - public void getSubBlocks(Item item, CreativeTabs tab, List list) { - for (int i = 0; i < 6; i++) list.add(new ItemStack(item, 1, i)); - } - - @Override - public void registerBlockIcons(IIconRegister par1IconRegister) { - icons = new IIcon[SUBTYPES * 2]; - for (int i = 0; i < icons.length; i++) icons[i] = IconHelper.forBlock(par1IconRegister, this, i); - } - - @Override - public IIcon getIcon(int side, int meta) { - return side == 0 || meta >= SUBTYPES - ? Blocks.dirt.getIcon(side, meta) - : side == 1 ? icons[meta * 2] : icons[meta * 2 + 1]; - } - - @Override - public void updateTick(World world, int x, int y, int z, Random rand) { - if (!world.isRemote && world.getBlockLightValue(x, y + 1, z) >= 9) { - int meta = world.getBlockMetadata(x, y, z); - for (int l = 0; l < 4; ++l) { - int i1 = x + rand.nextInt(3) - 1; - int j1 = y + rand.nextInt(5) - 3; - int k1 = z + rand.nextInt(3) - 1; - - world.getBlock(i1, j1 + 1, k1); - - if (world.getBlock(i1, j1, k1) == Blocks.dirt - && world.getBlockMetadata(i1, j1, k1) == 0 - && world.getBlockLightValue(i1, j1 + 1, k1) >= 4 - && world.getBlockLightOpacity(i1, j1 + 1, k1) <= 2) - world.setBlock(i1, j1, k1, this, meta, 1 | 2); - } - } - } - - @Override - public Item getItemDropped(int p_149650_1_, Random p_149650_2_, int p_149650_3_) { - return Blocks.dirt.getItemDropped(0, p_149650_2_, p_149650_3_); - } - - @Override - public ItemStack getPickBlock(MovingObjectPosition target, World world, int x, int y, int z) { - return new ItemStack(this, 1, world.getBlockMetadata(x, y, z)); - } - - @Override - public boolean canSustainPlant( - IBlockAccess world, int x, int y, int z, ForgeDirection direction, IPlantable plantable) { - EnumPlantType type = plantable.getPlantType(world, x, y - 1, z); - return type == EnumPlantType.Plains || type == EnumPlantType.Beach; - } - - @Override - public void randomDisplayTick(World world, int x, int y, int z, Random r) { - int meta = world.getBlockMetadata(x, y, z); - switch (meta) { - case 0: // Dry - break; - case 1: // Golden - break; - case 2: // Vivid - break; - case 3: // Scorched - if (r.nextInt(80) == 0) - world.spawnParticle("flame", x + r.nextFloat(), y + 1.1, z + r.nextFloat(), 0, 0, 0); - break; - case 4: // Infused - if (r.nextInt(100) == 0) - Botania.proxy.sparkleFX( - world, - x + r.nextFloat(), - y + 1.05, - z + r.nextFloat(), - 0F, - 1F, - 1F, - r.nextFloat() * 0.2F + 1F, - 5); - break; - case 5: // Mutated - if (r.nextInt(100) == 0) { - if (r.nextInt(100) > 25) - Botania.proxy.sparkleFX( - world, - x + r.nextFloat(), - y + 1.05, - z + r.nextFloat(), - 1F, - 0F, - 1F, - r.nextFloat() * 0.2F + 1F, - 5); - else - Botania.proxy.sparkleFX( - world, - x + r.nextFloat(), - y + 1.05, - z + r.nextFloat(), - 1F, - 1F, - 0F, - r.nextFloat() * 0.2F + 1F, - 5); - } - break; - } - } - - @Override - public LexiconEntry getEntry(World world, int x, int y, int z, EntityPlayer player, ItemStack lexicon) { - return LexiconData.grassSeeds; - } + private static final int SUBTYPES = 6; + IIcon[] icons; + + public BlockAltGrass() { + super(Material.grass); + setHardness(0.6F); + setStepSound(soundTypeGrass); + setBlockName(LibBlockNames.ALT_GRASS); + setTickRandomly(true); + } + + @Override + public boolean isToolEffective(String type, int metadata) { + return type.equals("shovel"); + } + + @Override + public Block setBlockName(String par1Str) { + GameRegistry.registerBlock(this, ItemBlockWithMetadataAndName.class, par1Str); + return super.setBlockName(par1Str); + } + + @Override + protected boolean shouldRegisterInNameSet() { + return false; + } + + @Override + public void getSubBlocks(Item item, CreativeTabs tab, List list) { + for(int i = 0; i < 6; i++) + list.add(new ItemStack(item, 1, i)); + } + + @Override + public void registerBlockIcons(IIconRegister par1IconRegister) { + icons = new IIcon[SUBTYPES * 2]; + for(int i = 0; i < icons.length; i++) + icons[i] = IconHelper.forBlock(par1IconRegister, this, i); + } + + @Override + public IIcon getIcon(int side, int meta) { + return side == 0 || meta >= SUBTYPES ? Blocks.dirt.getIcon(side, meta) : side == 1 ? icons[meta * 2] : icons[meta * 2 + 1]; + } + + @Override + public void updateTick(World world, int x, int y, int z, Random rand) { + if(!world.isRemote && world.getBlockLightValue(x, y + 1, z) >= 9) { + int meta = world.getBlockMetadata(x, y, z); + for(int l = 0; l < 4; ++l) { + int i1 = x + rand.nextInt(3) - 1; + int j1 = y + rand.nextInt(5) - 3; + int k1 = z + rand.nextInt(3) - 1; + + world.getBlock(i1, j1 + 1, k1); + + if(world.getBlock(i1, j1, k1) == Blocks.dirt && world.getBlockMetadata(i1, j1, k1) == 0 && world.getBlockLightValue(i1, j1 + 1, k1) >= 4 && world.getBlockLightOpacity(i1, j1 + 1, k1) <= 2) + world.setBlock(i1, j1, k1, this, meta, 1 | 2); + } + } + } + + @Override + public Item getItemDropped(int p_149650_1_, Random p_149650_2_, int p_149650_3_) { + return Blocks.dirt.getItemDropped(0, p_149650_2_, p_149650_3_); + } + + @Override + public ItemStack getPickBlock(MovingObjectPosition target, World world, int x, int y, int z) { + return new ItemStack(this, 1, world.getBlockMetadata(x, y, z)); + } + + @Override + public boolean canSustainPlant(IBlockAccess world, int x, int y, int z, ForgeDirection direction, IPlantable plantable) { + EnumPlantType type = plantable.getPlantType(world, x, y - 1, z); + return type == EnumPlantType.Plains || type == EnumPlantType.Beach; + } + + @Override + public void randomDisplayTick(World world, int x, int y, int z, Random r) { + int meta = world.getBlockMetadata(x, y, z); + switch(meta) { + case 0: // Dry + break; + case 1: // Golden + break; + case 2: // Vivid + break; + case 3: // Scorched + if(r.nextInt(80) == 0) + world.spawnParticle("flame", x + r.nextFloat(), y + 1.1, z + r.nextFloat(), 0, 0, 0); + break; + case 4: // Infused + if(r.nextInt(100) == 0) + Botania.proxy.sparkleFX(world, x + r.nextFloat(), y + 1.05, z + r.nextFloat(), 0F, 1F, 1F, r.nextFloat() * 0.2F + 1F, 5); + break; + case 5: // Mutated + if(r.nextInt(100) == 0) { + if(r.nextInt(100) > 25) + Botania.proxy.sparkleFX(world, x + r.nextFloat(), y + 1.05, z + r.nextFloat(), 1F, 0F, 1F, r.nextFloat() * 0.2F + 1F, 5); + else Botania.proxy.sparkleFX(world, x + r.nextFloat(), y + 1.05, z + r.nextFloat(), 1F, 1F, 0F, r.nextFloat() * 0.2F + 1F, 5); + } + break; + } + } + + @Override + public LexiconEntry getEntry(World world, int x, int y, int z, EntityPlayer player, ItemStack lexicon) { + return LexiconData.grassSeeds; + } } diff --git a/src/main/java/vazkii/botania/common/block/BlockAltar.java b/src/main/java/vazkii/botania/common/block/BlockAltar.java index 5eed53f4a4..01abb60f47 100644 --- a/src/main/java/vazkii/botania/common/block/BlockAltar.java +++ b/src/main/java/vazkii/botania/common/block/BlockAltar.java @@ -2,17 +2,17 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jan 21, 2014, 7:48:54 PM (GMT)] */ package vazkii.botania.common.block; -import cpw.mods.fml.common.registry.GameRegistry; import java.util.List; import java.util.Random; + import net.minecraft.block.Block; import net.minecraft.block.material.Material; import net.minecraft.client.renderer.texture.IIconRegister; @@ -46,265 +46,246 @@ import vazkii.botania.common.item.rod.ItemWaterRod; import vazkii.botania.common.lexicon.LexiconData; import vazkii.botania.common.lib.LibBlockNames; +import cpw.mods.fml.common.registry.GameRegistry; public class BlockAltar extends BlockModContainer implements ILexiconable { - Random random; - - protected BlockAltar() { - super(Material.rock); - setHardness(3.5F); - setStepSound(soundTypeStone); - setBlockName(LibBlockNames.ALTAR); - - float f = 1F / 16F * 2F; - setBlockBounds(f, f, f, 1F - f, 1F / 16F * 20F, 1F - f); - - random = new Random(); - } - - @Override - public void registerBlockIcons(IIconRegister par1IconRegister) { - // NO-OP - } - - @Override - protected boolean shouldRegisterInNameSet() { - return false; - } - - @Override - public Block setBlockName(String par1Str) { - GameRegistry.registerBlock(this, ItemBlockWithMetadataAndName.class, par1Str); - return super.setBlockName(par1Str); - } - - @Override - public void getSubBlocks(Item item, CreativeTabs tab, List list) { - for (int i = 0; i < 9; i++) list.add(new ItemStack(item, 1, i)); - } - - @Override - public void onEntityCollidedWithBlock(World par1World, int par2, int par3, int par4, Entity par5Entity) { - if (par5Entity instanceof EntityItem) { - TileAltar tile = (TileAltar) par1World.getTileEntity(par2, par3, par4); - if (tile.collideEntityItem((EntityItem) par5Entity)) - VanillaPacketDispatcher.dispatchTEToNearbyPlayers(tile); - } - } - - @Override - public int getLightValue(IBlockAccess world, int x, int y, int z) { - TileAltar tile = (TileAltar) world.getTileEntity(x, y, z); - return tile.hasLava ? 15 : 0; - } - - @Override - public boolean onBlockActivated( - World par1World, - int par2, - int par3, - int par4, - EntityPlayer par5EntityPlayer, - int par6, - float par7, - float par8, - float par9) { - ItemStack stack = par5EntityPlayer.getCurrentEquippedItem(); - TileAltar tile = (TileAltar) par1World.getTileEntity(par2, par3, par4); - - if (par5EntityPlayer.isSneaking()) { - for (int i = tile.getSizeInventory() - 1; i >= 0; i--) { - ItemStack stackAt = tile.getStackInSlot(i); - if (stackAt != null) { - ItemStack copy = stackAt.copy(); - if (!par5EntityPlayer.inventory.addItemStackToInventory(copy)) - par5EntityPlayer.dropPlayerItemWithRandomChoice(copy, false); - tile.setInventorySlotContents(i, null); - par1World.func_147453_f(par2, par3, par4, this); - break; - } - } - } else if (tile.isEmpty() && tile.hasWater && stack == null) tile.trySetLastRecipe(par5EntityPlayer); - else { - if (stack != null - && (isValidWaterContainer(stack) - || stack.getItem() == ModItems.waterRod - && ManaItemHandler.requestManaExact( - stack, par5EntityPlayer, ItemWaterRod.COST, false))) { - if (!tile.hasWater) { - if (stack.getItem() == ModItems.waterRod) - ManaItemHandler.requestManaExact(stack, par5EntityPlayer, ItemWaterRod.COST, true); - else if (!par5EntityPlayer.capabilities.isCreativeMode) - par5EntityPlayer.inventory.setInventorySlotContents( - par5EntityPlayer.inventory.currentItem, getContainer(stack)); - - tile.setWater(true); - par1World.func_147453_f(par2, par3, par4, this); - } - - return true; - } else if (stack != null && stack.getItem() == Items.lava_bucket) { - if (!par5EntityPlayer.capabilities.isCreativeMode) - par5EntityPlayer.inventory.setInventorySlotContents( - par5EntityPlayer.inventory.currentItem, getContainer(stack)); - - tile.setLava(true); - tile.setWater(false); - par1World.func_147453_f(par2, par3, par4, this); - - return true; - } else if (stack != null - && stack.getItem() == Items.bucket - && (tile.hasWater || tile.hasLava) - && !Botania.gardenOfGlassLoaded) { - ItemStack bucket = tile.hasLava ? new ItemStack(Items.lava_bucket) : new ItemStack(Items.water_bucket); - if (stack.stackSize == 1) - par5EntityPlayer.inventory.setInventorySlotContents(par5EntityPlayer.inventory.currentItem, bucket); - else { - if (!par5EntityPlayer.inventory.addItemStackToInventory(bucket)) - par5EntityPlayer.dropPlayerItemWithRandomChoice(bucket, false); - stack.stackSize--; - } - - if (tile.hasLava) tile.setLava(false); - else tile.setWater(false); - par1World.func_147453_f(par2, par3, par4, this); - - return true; - } - } - - return false; - } - - @Override - public void fillWithRain(World world, int x, int y, int z) { - if (world.rand.nextInt(20) == 1) { - TileEntity tile = world.getTileEntity(x, y, z); - if (tile instanceof TileAltar) { - TileAltar altar = (TileAltar) tile; - if (!altar.hasLava && !altar.hasWater) altar.setWater(true); - world.func_147453_f(x, y, z, this); - } - } - } - - @Override - public int damageDropped(int meta) { - return meta; - } - - private boolean isValidWaterContainer(ItemStack stack) { - if (stack == null || stack.stackSize != 1) return false; - if (stack.getItem() == ModItems.waterBowl) return true; - - if (stack.getItem() instanceof IFluidContainerItem) { - FluidStack fluidStack = ((IFluidContainerItem) stack.getItem()).getFluid(stack); - return fluidStack != null - && fluidStack.getFluid() == FluidRegistry.WATER - && fluidStack.amount >= FluidContainerRegistry.BUCKET_VOLUME; - } - FluidStack fluidStack = FluidContainerRegistry.getFluidForFilledItem(stack); - return fluidStack != null - && fluidStack.getFluid() == FluidRegistry.WATER - && fluidStack.amount >= FluidContainerRegistry.BUCKET_VOLUME; - } - - private ItemStack getContainer(ItemStack stack) { - if (stack.getItem() == ModItems.waterBowl) return new ItemStack(Items.bowl); - - if (stack.getItem().hasContainerItem(stack)) return stack.getItem().getContainerItem(stack); - else if (stack.getItem() instanceof IFluidContainerItem) { - ((IFluidContainerItem) stack.getItem()).drain(stack, FluidContainerRegistry.BUCKET_VOLUME, true); - return stack; - } - return FluidContainerRegistry.drainFluidContainer(stack); - } - - @Override - public IIcon getIcon(int par1, int par2) { - return par2 == 0 ? Blocks.cobblestone.getIcon(par1, par2) : ModFluffBlocks.biomeStoneA.getIcon(par1, par2 + 7); - } - - @Override - public boolean isOpaqueCube() { - return false; - } - - @Override - public boolean renderAsNormalBlock() { - return false; - } - - @Override - public int getRenderType() { - return LibRenderIDs.idAltar; - } - - @Override - public TileEntity createNewTileEntity(World world, int meta) { - return new TileAltar(); - } - - @Override - public void breakBlock(World par1World, int par2, int par3, int par4, Block par5, int par6) { - TileSimpleInventory inv = (TileSimpleInventory) par1World.getTileEntity(par2, par3, par4); - - if (inv != null) { - for (int j1 = 0; j1 < inv.getSizeInventory(); ++j1) { - ItemStack itemstack = inv.getStackInSlot(j1); - - if (itemstack != null) { - float f = random.nextFloat() * 0.8F + 0.1F; - float f1 = random.nextFloat() * 0.8F + 0.1F; - EntityItem entityitem; - - for (float f2 = random.nextFloat() * 0.8F + 0.1F; - itemstack.stackSize > 0; - par1World.spawnEntityInWorld(entityitem)) { - int k1 = random.nextInt(21) + 10; - - if (k1 > itemstack.stackSize) k1 = itemstack.stackSize; - - itemstack.stackSize -= k1; - entityitem = new EntityItem( - par1World, - par2 + f, - par3 + f1, - par4 + f2, - new ItemStack(itemstack.getItem(), k1, itemstack.getItemDamage())); - float f3 = 0.05F; - entityitem.motionX = (float) random.nextGaussian() * f3; - entityitem.motionY = (float) random.nextGaussian() * f3 + 0.2F; - entityitem.motionZ = (float) random.nextGaussian() * f3; - - if (itemstack.hasTagCompound()) - entityitem.getEntityItem().setTagCompound((NBTTagCompound) - itemstack.getTagCompound().copy()); - } - } - } - - par1World.func_147453_f(par2, par3, par4, par5); - } - - super.breakBlock(par1World, par2, par3, par4, par5, par6); - } - - @Override - public boolean hasComparatorInputOverride() { - return true; - } - - @Override - public int getComparatorInputOverride(World par1World, int par2, int par3, int par4, int par5) { - TileAltar altar = (TileAltar) par1World.getTileEntity(par2, par3, par4); - return altar.hasWater ? 15 : 0; - } - - @Override - public LexiconEntry getEntry(World world, int x, int y, int z, EntityPlayer player, ItemStack lexicon) { - return LexiconData.apothecary; - } + Random random; + + protected BlockAltar() { + super(Material.rock); + setHardness(3.5F); + setStepSound(soundTypeStone); + setBlockName(LibBlockNames.ALTAR); + + float f = 1F / 16F * 2F; + setBlockBounds(f, f, f, 1F - f, 1F / 16F * 20F, 1F - f); + + random = new Random(); + } + + @Override + public void registerBlockIcons(IIconRegister par1IconRegister) { + // NO-OP + } + + @Override + protected boolean shouldRegisterInNameSet() { + return false; + } + + @Override + public Block setBlockName(String par1Str) { + GameRegistry.registerBlock(this, ItemBlockWithMetadataAndName.class, par1Str); + return super.setBlockName(par1Str); + } + + @Override + public void getSubBlocks(Item item, CreativeTabs tab, List list) { + for(int i = 0; i < 9; i++) + list.add(new ItemStack(item, 1, i)); + } + + @Override + public void onEntityCollidedWithBlock(World par1World, int par2, int par3, int par4, Entity par5Entity) { + if(par5Entity instanceof EntityItem) { + TileAltar tile = (TileAltar) par1World.getTileEntity(par2, par3, par4); + if(tile.collideEntityItem((EntityItem) par5Entity)) + VanillaPacketDispatcher.dispatchTEToNearbyPlayers(tile); + } + } + + @Override + public int getLightValue(IBlockAccess world, int x, int y, int z) { + TileAltar tile = (TileAltar) world.getTileEntity(x, y, z); + return tile.hasLava ? 15 : 0; + } + + @Override + public boolean onBlockActivated(World par1World, int par2, int par3, int par4, EntityPlayer par5EntityPlayer, int par6, float par7, float par8, float par9) { + ItemStack stack = par5EntityPlayer.getCurrentEquippedItem(); + TileAltar tile = (TileAltar) par1World.getTileEntity(par2, par3, par4); + + if(par5EntityPlayer.isSneaking()) { + for(int i = tile.getSizeInventory() - 1; i >= 0; i--) { + ItemStack stackAt = tile.getStackInSlot(i); + if(stackAt != null) { + ItemStack copy = stackAt.copy(); + if(!par5EntityPlayer.inventory.addItemStackToInventory(copy)) + par5EntityPlayer.dropPlayerItemWithRandomChoice(copy, false); + tile.setInventorySlotContents(i, null); + par1World.func_147453_f(par2, par3, par4, this); + break; + } + } + } else if(tile.isEmpty() && tile.hasWater && stack == null) + tile.trySetLastRecipe(par5EntityPlayer); + else { + if(stack != null && (isValidWaterContainer(stack) || stack.getItem() == ModItems.waterRod && ManaItemHandler.requestManaExact(stack, par5EntityPlayer, ItemWaterRod.COST, false))) { + if(!tile.hasWater) { + if(stack.getItem() == ModItems.waterRod) + ManaItemHandler.requestManaExact(stack, par5EntityPlayer, ItemWaterRod.COST, true); + else if(!par5EntityPlayer.capabilities.isCreativeMode) + par5EntityPlayer.inventory.setInventorySlotContents(par5EntityPlayer.inventory.currentItem, getContainer(stack)); + + tile.setWater(true); + par1World.func_147453_f(par2, par3, par4, this); + } + + return true; + } else if(stack != null && stack.getItem() == Items.lava_bucket) { + if(!par5EntityPlayer.capabilities.isCreativeMode) + par5EntityPlayer.inventory.setInventorySlotContents(par5EntityPlayer.inventory.currentItem, getContainer(stack)); + + tile.setLava(true); + tile.setWater(false); + par1World.func_147453_f(par2, par3, par4, this); + + return true; + } else if(stack != null && stack.getItem() == Items.bucket && (tile.hasWater || tile.hasLava) && !Botania.gardenOfGlassLoaded) { + ItemStack bucket = tile.hasLava ? new ItemStack(Items.lava_bucket) : new ItemStack(Items.water_bucket); + if(stack.stackSize == 1) + par5EntityPlayer.inventory.setInventorySlotContents(par5EntityPlayer.inventory.currentItem, bucket); + else { + if(!par5EntityPlayer.inventory.addItemStackToInventory(bucket)) + par5EntityPlayer.dropPlayerItemWithRandomChoice(bucket, false); + stack.stackSize--; + } + + if(tile.hasLava) + tile.setLava(false); + else tile.setWater(false); + par1World.func_147453_f(par2, par3, par4, this); + + return true; + } + } + + return false; + } + + @Override + public void fillWithRain(World world, int x, int y, int z) { + if(world.rand.nextInt(20) == 1) { + TileEntity tile = world.getTileEntity(x, y, z); + if(tile instanceof TileAltar) { + TileAltar altar = (TileAltar) tile; + if(!altar.hasLava && !altar.hasWater) + altar.setWater(true); + world.func_147453_f(x, y, z, this); + } + } + } + + @Override + public int damageDropped(int meta) { + return meta; + } + + private boolean isValidWaterContainer(ItemStack stack) { + if(stack == null || stack.stackSize != 1) + return false; + if(stack.getItem() == ModItems.waterBowl) + return true; + + if(stack.getItem() instanceof IFluidContainerItem) { + FluidStack fluidStack = ((IFluidContainerItem) stack.getItem()).getFluid(stack); + return fluidStack != null && fluidStack.getFluid() == FluidRegistry.WATER && fluidStack.amount >= FluidContainerRegistry.BUCKET_VOLUME; + } + FluidStack fluidStack = FluidContainerRegistry.getFluidForFilledItem(stack); + return fluidStack != null && fluidStack.getFluid() == FluidRegistry.WATER && fluidStack.amount >= FluidContainerRegistry.BUCKET_VOLUME; + } + + private ItemStack getContainer(ItemStack stack) { + if(stack.getItem() == ModItems.waterBowl) + return new ItemStack(Items.bowl); + + if (stack.getItem().hasContainerItem(stack)) + return stack.getItem().getContainerItem(stack); + else if (stack.getItem() instanceof IFluidContainerItem) { + ((IFluidContainerItem) stack.getItem()).drain(stack, FluidContainerRegistry.BUCKET_VOLUME, true); + return stack; + } + return FluidContainerRegistry.drainFluidContainer(stack); + } + + @Override + public IIcon getIcon(int par1, int par2) { + return par2 == 0 ? Blocks.cobblestone.getIcon(par1, par2) : ModFluffBlocks.biomeStoneA.getIcon(par1, par2 + 7); + } + + @Override + public boolean isOpaqueCube() { + return false; + } + + @Override + public boolean renderAsNormalBlock() { + return false; + } + + @Override + public int getRenderType() { + return LibRenderIDs.idAltar; + } + + @Override + public TileEntity createNewTileEntity(World world, int meta) { + return new TileAltar(); + } + + @Override + public void breakBlock(World par1World, int par2, int par3, int par4, Block par5, int par6) { + TileSimpleInventory inv = (TileSimpleInventory) par1World.getTileEntity(par2, par3, par4); + + if (inv != null) { + for (int j1 = 0; j1 < inv.getSizeInventory(); ++j1) { + ItemStack itemstack = inv.getStackInSlot(j1); + + if (itemstack != null) { + float f = random.nextFloat() * 0.8F + 0.1F; + float f1 = random.nextFloat() * 0.8F + 0.1F; + EntityItem entityitem; + + for (float f2 = random.nextFloat() * 0.8F + 0.1F; itemstack.stackSize > 0; par1World.spawnEntityInWorld(entityitem)) { + int k1 = random.nextInt(21) + 10; + + if (k1 > itemstack.stackSize) + k1 = itemstack.stackSize; + + itemstack.stackSize -= k1; + entityitem = new EntityItem(par1World, par2 + f, par3 + f1, par4 + f2, new ItemStack(itemstack.getItem(), k1, itemstack.getItemDamage())); + float f3 = 0.05F; + entityitem.motionX = (float)random.nextGaussian() * f3; + entityitem.motionY = (float)random.nextGaussian() * f3 + 0.2F; + entityitem.motionZ = (float)random.nextGaussian() * f3; + + if (itemstack.hasTagCompound()) + entityitem.getEntityItem().setTagCompound((NBTTagCompound)itemstack.getTagCompound().copy()); + } + } + } + + par1World.func_147453_f(par2, par3, par4, par5); + } + + super.breakBlock(par1World, par2, par3, par4, par5, par6); + } + + @Override + public boolean hasComparatorInputOverride() { + return true; + } + + @Override + public int getComparatorInputOverride(World par1World, int par2, int par3, int par4, int par5) { + TileAltar altar = (TileAltar) par1World.getTileEntity(par2, par3, par4); + return altar.hasWater ? 15 : 0; + } + + @Override + public LexiconEntry getEntry(World world, int x, int y, int z, EntityPlayer player, ItemStack lexicon) { + return LexiconData.apothecary; + } + } diff --git a/src/main/java/vazkii/botania/common/block/BlockAvatar.java b/src/main/java/vazkii/botania/common/block/BlockAvatar.java index 30576683ba..f6eed47566 100644 --- a/src/main/java/vazkii/botania/common/block/BlockAvatar.java +++ b/src/main/java/vazkii/botania/common/block/BlockAvatar.java @@ -2,15 +2,16 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Oct 24, 2015, 3:15:11 PM (GMT)] */ package vazkii.botania.common.block; import java.util.Random; + import net.minecraft.block.Block; import net.minecraft.block.material.Material; import net.minecraft.client.renderer.texture.IIconRegister; @@ -38,152 +39,140 @@ public class BlockAvatar extends BlockModContainer implements ILexiconable { - private static final int[] META_ROTATIONS = new int[] {2, 5, 3, 4}; - - Random random; - - protected BlockAvatar() { - super(Material.wood); - setHardness(2.0F); - setStepSound(soundTypeWood); - setBlockName(LibBlockNames.AVATAR); - setBlockBounds(true); - - random = new Random(); - } - - @Override - public boolean onBlockActivated( - World world, int x, int y, int z, EntityPlayer player, int s, float xs, float ys, float zs) { - TileAvatar avatar = (TileAvatar) world.getTileEntity(x, y, z); - ItemStack stackOnAvatar = avatar.getStackInSlot(0); - ItemStack stackOnPlayer = player.getCurrentEquippedItem(); - if (stackOnAvatar != null) { - ItemStack copyStack = stackOnAvatar.copy(); - avatar.setInventorySlotContents(0, null); - if (!player.inventory.addItemStackToInventory(copyStack)) - player.dropPlayerItemWithRandomChoice(copyStack, true); - return true; - } else if (stackOnPlayer != null && stackOnPlayer.getItem() instanceof IAvatarWieldable) { - ItemStack copyStack = stackOnPlayer.copy(); - avatar.setInventorySlotContents(0, copyStack); - stackOnPlayer.stackSize--; - return true; - } - - return false; - } - - @Override - public void setBlockBoundsBasedOnState(IBlockAccess w, int x, int y, int z) { - setBlockBounds(w.getBlockMetadata(x, y, z) < 4); - } - - public void setBlockBounds(boolean horiz) { - float f = 1F / 16F; - float w = f * 9; - float l = f * 6; - float ws = (1F - w) / 2; - float ls = (1F - l) / 2; - - if (horiz) setBlockBounds(ws, 0F, ls, 1F - ws, 1F + f, 1F - ls); - else setBlockBounds(ls, 0F, ws, 1F - ls, 1F + f, 1F - ws); - } - - @Override - public void breakBlock(World par1World, int par2, int par3, int par4, Block par5, int par6) { - TileSimpleInventory inv = (TileSimpleInventory) par1World.getTileEntity(par2, par3, par4); - - if (inv != null) { - for (int j1 = 0; j1 < inv.getSizeInventory(); ++j1) { - ItemStack itemstack = inv.getStackInSlot(j1); - - if (itemstack != null) { - float f = random.nextFloat() * 0.8F + 0.1F; - float f1 = random.nextFloat() * 0.8F + 0.1F; - EntityItem entityitem; - - for (float f2 = random.nextFloat() * 0.8F + 0.1F; - itemstack.stackSize > 0; - par1World.spawnEntityInWorld(entityitem)) { - int k1 = random.nextInt(21) + 10; - - if (k1 > itemstack.stackSize) k1 = itemstack.stackSize; - - itemstack.stackSize -= k1; - entityitem = new EntityItem( - par1World, - par2 + f, - par3 + f1, - par4 + f2, - new ItemStack(itemstack.getItem(), k1, itemstack.getItemDamage())); - float f3 = 0.05F; - entityitem.motionX = (float) random.nextGaussian() * f3; - entityitem.motionY = (float) random.nextGaussian() * f3 + 0.2F; - entityitem.motionZ = (float) random.nextGaussian() * f3; - - if (itemstack.hasTagCompound()) - entityitem.getEntityItem().setTagCompound((NBTTagCompound) - itemstack.getTagCompound().copy()); - } - } - } - - par1World.func_147453_f(par2, par3, par4, par5); - } - - super.breakBlock(par1World, par2, par3, par4, par5, par6); - } - - @Override - public void onBlockPlacedBy( - World p_149689_1_, - int p_149689_2_, - int p_149689_3_, - int p_149689_4_, - EntityLivingBase p_149689_5_, - ItemStack p_149689_6_) { - int l = MathHelper.floor_double(p_149689_5_.rotationYaw * 4.0F / 360.0F + 0.5D) & 3; - p_149689_1_.setBlockMetadataWithNotify(p_149689_2_, p_149689_3_, p_149689_4_, META_ROTATIONS[l], 2); - } - - @Override - public boolean rotateBlock(World worldObj, int x, int y, int z, ForgeDirection axis) { - return RotationHelper.rotateVanillaBlock(Blocks.furnace, worldObj, x, y, z, axis); - } - - @Override - public void registerBlockIcons(IIconRegister par1IconRegister) { - // NO-OP - } - - @Override - public IIcon getIcon(int side, int meta) { - return ModBlocks.livingwood.getIcon(0, 0); - } - - @Override - public boolean isOpaqueCube() { - return false; - } - - @Override - public boolean renderAsNormalBlock() { - return false; - } - - @Override - public int getRenderType() { - return LibRenderIDs.idAvatar; - } - - @Override - public TileEntity createNewTileEntity(World world, int meta) { - return new TileAvatar(); - } - - @Override - public LexiconEntry getEntry(World world, int x, int y, int z, EntityPlayer player, ItemStack lexicon) { - return LexiconData.avatar; - } + private static final int[] META_ROTATIONS = new int[] { 2, 5, 3, 4 }; + + Random random; + + protected BlockAvatar() { + super(Material.wood); + setHardness(2.0F); + setStepSound(soundTypeWood); + setBlockName(LibBlockNames.AVATAR); + setBlockBounds(true); + + random = new Random(); + } + + @Override + public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int s, float xs, float ys, float zs) { + TileAvatar avatar = (TileAvatar) world.getTileEntity(x, y, z); + ItemStack stackOnAvatar = avatar.getStackInSlot(0); + ItemStack stackOnPlayer = player.getCurrentEquippedItem(); + if(stackOnAvatar != null) { + ItemStack copyStack = stackOnAvatar.copy(); + avatar.setInventorySlotContents(0, null); + if(!player.inventory.addItemStackToInventory(copyStack)) + player.dropPlayerItemWithRandomChoice(copyStack, true); + return true; + } else if(stackOnPlayer != null && stackOnPlayer.getItem() instanceof IAvatarWieldable) { + ItemStack copyStack = stackOnPlayer.copy(); + avatar.setInventorySlotContents(0, copyStack); + stackOnPlayer.stackSize--; + return true; + } + + return false; + } + + @Override + public void setBlockBoundsBasedOnState(IBlockAccess w, int x, int y, int z) { + setBlockBounds(w.getBlockMetadata(x, y, z) < 4); + } + + public void setBlockBounds(boolean horiz) { + float f = 1F / 16F; + float w = f * 9; + float l = f * 6; + float ws = (1F - w) / 2; + float ls = (1F - l) / 2; + + if(horiz) + setBlockBounds(ws, 0F, ls, 1F - ws, 1F + f, 1F - ls); + else setBlockBounds(ls, 0F, ws, 1F - ls, 1F + f, 1F - ws); + } + + @Override + public void breakBlock(World par1World, int par2, int par3, int par4, Block par5, int par6) { + TileSimpleInventory inv = (TileSimpleInventory) par1World.getTileEntity(par2, par3, par4); + + if (inv != null) { + for (int j1 = 0; j1 < inv.getSizeInventory(); ++j1) { + ItemStack itemstack = inv.getStackInSlot(j1); + + if (itemstack != null) { + float f = random.nextFloat() * 0.8F + 0.1F; + float f1 = random.nextFloat() * 0.8F + 0.1F; + EntityItem entityitem; + + for (float f2 = random.nextFloat() * 0.8F + 0.1F; itemstack.stackSize > 0; par1World.spawnEntityInWorld(entityitem)) { + int k1 = random.nextInt(21) + 10; + + if (k1 > itemstack.stackSize) + k1 = itemstack.stackSize; + + itemstack.stackSize -= k1; + entityitem = new EntityItem(par1World, par2 + f, par3 + f1, par4 + f2, new ItemStack(itemstack.getItem(), k1, itemstack.getItemDamage())); + float f3 = 0.05F; + entityitem.motionX = (float)random.nextGaussian() * f3; + entityitem.motionY = (float)random.nextGaussian() * f3 + 0.2F; + entityitem.motionZ = (float)random.nextGaussian() * f3; + + if (itemstack.hasTagCompound()) + entityitem.getEntityItem().setTagCompound((NBTTagCompound)itemstack.getTagCompound().copy()); + } + } + } + + par1World.func_147453_f(par2, par3, par4, par5); + } + + super.breakBlock(par1World, par2, par3, par4, par5, par6); + } + + @Override + public void onBlockPlacedBy(World p_149689_1_, int p_149689_2_, int p_149689_3_, int p_149689_4_, EntityLivingBase p_149689_5_, ItemStack p_149689_6_) { + int l = MathHelper.floor_double(p_149689_5_.rotationYaw * 4.0F / 360.0F + 0.5D) & 3; + p_149689_1_.setBlockMetadataWithNotify(p_149689_2_, p_149689_3_, p_149689_4_, META_ROTATIONS[l], 2); + } + + @Override + public boolean rotateBlock(World worldObj, int x, int y, int z, ForgeDirection axis) { + return RotationHelper.rotateVanillaBlock(Blocks.furnace, worldObj, x, y, z, axis); + } + + @Override + public void registerBlockIcons(IIconRegister par1IconRegister) { + // NO-OP + } + + @Override + public IIcon getIcon(int side, int meta) { + return ModBlocks.livingwood.getIcon(0, 0); + } + + @Override + public boolean isOpaqueCube() { + return false; + } + + @Override + public boolean renderAsNormalBlock() { + return false; + } + + @Override + public int getRenderType() { + return LibRenderIDs.idAvatar; + } + + @Override + public TileEntity createNewTileEntity(World world, int meta) { + return new TileAvatar(); + } + + @Override + public LexiconEntry getEntry(World world, int x, int y, int z, EntityPlayer player, ItemStack lexicon) { + return LexiconData.avatar; + } + } diff --git a/src/main/java/vazkii/botania/common/block/BlockBifrost.java b/src/main/java/vazkii/botania/common/block/BlockBifrost.java index cf3dbf9c0e..8f2736bd7c 100644 --- a/src/main/java/vazkii/botania/common/block/BlockBifrost.java +++ b/src/main/java/vazkii/botania/common/block/BlockBifrost.java @@ -2,18 +2,16 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jun 20, 2014, 8:23:17 PM (GMT)] */ package vazkii.botania.common.block; -import cpw.mods.fml.common.eventhandler.SubscribeEvent; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; import java.util.Random; + import net.minecraft.block.Block; import net.minecraft.block.material.Material; import net.minecraft.client.renderer.texture.IIconRegister; @@ -33,81 +31,82 @@ import vazkii.botania.common.item.ModItems; import vazkii.botania.common.lexicon.LexiconData; import vazkii.botania.common.lib.LibBlockNames; +import cpw.mods.fml.common.eventhandler.SubscribeEvent; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; public class BlockBifrost extends BlockModContainer implements ILexiconable { - public BlockBifrost() { - super(Material.glass); - setBlockName(LibBlockNames.BIFROST); - setLightOpacity(0); - setLightLevel(1F); - setBlockUnbreakable(); - setStepSound(soundTypeGlass); - MinecraftForge.EVENT_BUS.register(this); - } - - @Override - public boolean registerInCreative() { - return false; - } - - @Override - public boolean isOpaqueCube() { - return false; - } - - @Override - public ItemStack getPickBlock(MovingObjectPosition target, World world, int x, int y, int z) { - return new ItemStack(ModItems.rainbowRod); - } - - public boolean shouldSideBeRendered1( - IBlockAccess p_149646_1_, int p_149646_2_, int p_149646_3_, int p_149646_4_, int p_149646_5_) { - Block block = p_149646_1_.getBlock(p_149646_2_, p_149646_3_, p_149646_4_); - - return block == this - ? false - : super.shouldSideBeRendered(p_149646_1_, p_149646_2_, p_149646_3_, p_149646_4_, p_149646_5_); - } - - @Override - public boolean shouldSideBeRendered( - IBlockAccess p_149646_1_, int p_149646_2_, int p_149646_3_, int p_149646_4_, int p_149646_5_) { - return shouldSideBeRendered1(p_149646_1_, p_149646_2_, p_149646_3_, p_149646_4_, 1 - p_149646_5_); - } - - @Override - public int getRenderBlockPass() { - return 1; - } - - @Override - public int quantityDropped(int meta, int fortune, Random random) { - return 0; - } - - @SubscribeEvent - @SideOnly(Side.CLIENT) - public void loadTextures(TextureStitchEvent.Pre event) { - if (event.map.getTextureType() == 0) { - TextureAtlasSprite icon = new InterpolatedIcon("botania:bifrost"); - if (event.map.setTextureEntry("botania:bifrost", icon)) blockIcon = icon; - } - } - - @Override - @SideOnly(Side.CLIENT) - public void registerBlockIcons(IIconRegister par1IconRegister) { - // NO-OP - } - - @Override - public TileEntity createNewTileEntity(World world, int meta) { - return new TileBifrost(); - } - - @Override - public LexiconEntry getEntry(World world, int x, int y, int z, EntityPlayer player, ItemStack lexicon) { - return LexiconData.rainbowRod; - } + public BlockBifrost() { + super(Material.glass); + setBlockName(LibBlockNames.BIFROST); + setLightOpacity(0); + setLightLevel(1F); + setBlockUnbreakable(); + setStepSound(soundTypeGlass); + MinecraftForge.EVENT_BUS.register(this); + } + + @Override + public boolean registerInCreative() { + return false; + } + + @Override + public boolean isOpaqueCube() { + return false; + } + + @Override + public ItemStack getPickBlock(MovingObjectPosition target, World world, int x, int y, int z) { + return new ItemStack(ModItems.rainbowRod); + } + + public boolean shouldSideBeRendered1(IBlockAccess p_149646_1_, int p_149646_2_, int p_149646_3_, int p_149646_4_, int p_149646_5_) { + Block block = p_149646_1_.getBlock(p_149646_2_, p_149646_3_, p_149646_4_); + + return block == this ? false : super.shouldSideBeRendered(p_149646_1_, p_149646_2_, p_149646_3_, p_149646_4_, p_149646_5_); + } + + @Override + public boolean shouldSideBeRendered(IBlockAccess p_149646_1_, int p_149646_2_, int p_149646_3_, int p_149646_4_, int p_149646_5_) { + return shouldSideBeRendered1(p_149646_1_, p_149646_2_, p_149646_3_, p_149646_4_, 1 - p_149646_5_); + } + + @Override + public int getRenderBlockPass() { + return 1; + } + + @Override + public int quantityDropped(int meta, int fortune, Random random) { + return 0; + } + + @SubscribeEvent + @SideOnly(Side.CLIENT) + public void loadTextures(TextureStitchEvent.Pre event) { + if(event.map.getTextureType() == 0) { + TextureAtlasSprite icon = new InterpolatedIcon("botania:bifrost"); + if(event.map.setTextureEntry("botania:bifrost", icon)) + blockIcon = icon; + } + } + + @Override + @SideOnly(Side.CLIENT) + public void registerBlockIcons(IIconRegister par1IconRegister) { + // NO-OP + } + + @Override + public TileEntity createNewTileEntity(World world, int meta) { + return new TileBifrost(); + } + + @Override + public LexiconEntry getEntry(World world, int x, int y, int z, EntityPlayer player, ItemStack lexicon) { + return LexiconData.rainbowRod; + } + } diff --git a/src/main/java/vazkii/botania/common/block/BlockBifrostPerm.java b/src/main/java/vazkii/botania/common/block/BlockBifrostPerm.java index d9bb62958d..49eb550100 100644 --- a/src/main/java/vazkii/botania/common/block/BlockBifrostPerm.java +++ b/src/main/java/vazkii/botania/common/block/BlockBifrostPerm.java @@ -2,15 +2,16 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Aug 28, 2015, 10:46:20 PM (GMT)] */ package vazkii.botania.common.block; import java.util.Random; + import net.minecraft.block.Block; import net.minecraft.block.material.Material; import net.minecraft.client.renderer.texture.IIconRegister; @@ -27,68 +28,56 @@ public class BlockBifrostPerm extends BlockMod implements ILexiconable { - public BlockBifrostPerm() { - super(Material.glass); - setBlockName(LibBlockNames.BIFROST_PERM); - setLightOpacity(0); - setHardness(0.3F); - setLightLevel(1F); - setStepSound(soundTypeGlass); - setTickRandomly(true); - } + public BlockBifrostPerm() { + super(Material.glass); + setBlockName(LibBlockNames.BIFROST_PERM); + setLightOpacity(0); + setHardness(0.3F); + setLightLevel(1F); + setStepSound(soundTypeGlass); + setTickRandomly(true); + } + + @Override + public IIcon getIcon(int side, int meta) { + return ModBlocks.bifrost.getIcon(side, meta); + } - @Override - public IIcon getIcon(int side, int meta) { - return ModBlocks.bifrost.getIcon(side, meta); - } + @Override + public void registerBlockIcons(IIconRegister par1IconRegister) { + // NO-OP + } - @Override - public void registerBlockIcons(IIconRegister par1IconRegister) { - // NO-OP - } + @Override + public boolean isOpaqueCube() { + return false; + } - @Override - public boolean isOpaqueCube() { - return false; - } + public boolean shouldSideBeRendered1(IBlockAccess p_149646_1_, int p_149646_2_, int p_149646_3_, int p_149646_4_, int p_149646_5_) { + Block block = p_149646_1_.getBlock(p_149646_2_, p_149646_3_, p_149646_4_); - public boolean shouldSideBeRendered1( - IBlockAccess p_149646_1_, int p_149646_2_, int p_149646_3_, int p_149646_4_, int p_149646_5_) { - Block block = p_149646_1_.getBlock(p_149646_2_, p_149646_3_, p_149646_4_); + return block == this ? false : super.shouldSideBeRendered(p_149646_1_, p_149646_2_, p_149646_3_, p_149646_4_, p_149646_5_); + } - return block == this - ? false - : super.shouldSideBeRendered(p_149646_1_, p_149646_2_, p_149646_3_, p_149646_4_, p_149646_5_); - } + @Override + public boolean shouldSideBeRendered(IBlockAccess p_149646_1_, int p_149646_2_, int p_149646_3_, int p_149646_4_, int p_149646_5_) { + return shouldSideBeRendered1(p_149646_1_, p_149646_2_, p_149646_3_, p_149646_4_, 1 - p_149646_5_); + } - @Override - public boolean shouldSideBeRendered( - IBlockAccess p_149646_1_, int p_149646_2_, int p_149646_3_, int p_149646_4_, int p_149646_5_) { - return shouldSideBeRendered1(p_149646_1_, p_149646_2_, p_149646_3_, p_149646_4_, 1 - p_149646_5_); - } + @Override + public void randomDisplayTick(World world, int x, int y, int z, Random rand) { + if(rand.nextBoolean()) + Botania.proxy.sparkleFX(world, x + Math.random(), y + Math.random(), z + Math.random(), (float) Math.random(), (float) Math.random(), (float) Math.random(), 0.45F + 0.2F * (float) Math.random(), 6); + } - @Override - public void randomDisplayTick(World world, int x, int y, int z, Random rand) { - if (rand.nextBoolean()) - Botania.proxy.sparkleFX( - world, - x + Math.random(), - y + Math.random(), - z + Math.random(), - (float) Math.random(), - (float) Math.random(), - (float) Math.random(), - 0.45F + 0.2F * (float) Math.random(), - 6); - } + @Override + public int getRenderBlockPass() { + return 1; + } - @Override - public int getRenderBlockPass() { - return 1; - } + @Override + public LexiconEntry getEntry(World world, int x, int y, int z, EntityPlayer player, ItemStack lexicon) { + return LexiconData.rainbowRod; + } - @Override - public LexiconEntry getEntry(World world, int x, int y, int z, EntityPlayer player, ItemStack lexicon) { - return LexiconData.rainbowRod; - } } diff --git a/src/main/java/vazkii/botania/common/block/BlockCacophonium.java b/src/main/java/vazkii/botania/common/block/BlockCacophonium.java index b231048c41..d0129c4fae 100644 --- a/src/main/java/vazkii/botania/common/block/BlockCacophonium.java +++ b/src/main/java/vazkii/botania/common/block/BlockCacophonium.java @@ -2,15 +2,16 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Aug 23, 2015, 7:23:26 PM (GMT)] */ package vazkii.botania.common.block; import java.util.ArrayList; + import net.minecraft.block.Block; import net.minecraft.block.material.Material; import net.minecraft.client.renderer.texture.IIconRegister; @@ -26,71 +27,74 @@ public class BlockCacophonium extends BlockModContainer { - IIcon top; - - protected BlockCacophonium() { - super(Material.wood); - setBlockName(LibBlockNames.CACOPHONIUM); - setHardness(0.8F); - } - - @Override - public void registerBlockIcons(IIconRegister reg) { - blockIcon = IconHelper.forBlock(reg, this, 0); - top = IconHelper.forBlock(reg, this, 1); - } - - @Override - public IIcon getIcon(int side, int meta) { - return side == 1 ? blockIcon : top; - } - - @Override - protected boolean canSilkHarvest() { - return false; - } - - @Override - public boolean registerInCreative() { - return false; - } - - @Override - public void onNeighborBlockChange(World world, int x, int y, int z, Block block) { - boolean power = - world.isBlockIndirectlyGettingPowered(x, y, z) || world.isBlockIndirectlyGettingPowered(x, y + 1, z); - int meta = world.getBlockMetadata(x, y, z); - boolean powered = (meta & 8) != 0; - - if (power && !powered) { - TileEntity tile = world.getTileEntity(x, y, z); - if (tile != null && tile instanceof TileCacophonium) ((TileCacophonium) tile).annoyDirewolf(); - world.setBlockMetadataWithNotify(x, y, z, meta | 8, 4); - } else if (!power && powered) world.setBlockMetadataWithNotify(x, y, z, meta & -9, 4); - } - - @Override - public void onBlockHarvested( - World par1World, int par2, int par3, int par4, int par5, EntityPlayer par6EntityPlayer) { - if (!par6EntityPlayer.capabilities.isCreativeMode) dropBlockAsItem(par1World, par2, par3, par4, par5, 0); - } - - @Override - public ArrayList getDrops(World world, int x, int y, int z, int metadata, int fortune) { - ArrayList stacks = new ArrayList(); - - TileEntity tile = world.getTileEntity(x, y, z); - if (tile != null && tile instanceof TileCacophonium) { - stacks.add(new ItemStack(Blocks.noteblock)); - ItemStack thingy = ((TileCacophonium) tile).stack; - if (thingy != null) stacks.add(thingy.copy()); - } - - return stacks; - } - - @Override - public TileEntity createNewTileEntity(World world, int meta) { - return new TileCacophonium(); - } + IIcon top; + + protected BlockCacophonium() { + super(Material.wood); + setBlockName(LibBlockNames.CACOPHONIUM); + setHardness(0.8F); + } + + @Override + public void registerBlockIcons(IIconRegister reg) { + blockIcon = IconHelper.forBlock(reg, this, 0); + top = IconHelper.forBlock(reg, this, 1); + } + + @Override + public IIcon getIcon(int side, int meta) { + return side == 1 ? blockIcon : top; + } + + @Override + protected boolean canSilkHarvest() { + return false; + } + + @Override + public boolean registerInCreative() { + return false; + } + + @Override + public void onNeighborBlockChange(World world, int x, int y, int z, Block block) { + boolean power = world.isBlockIndirectlyGettingPowered(x, y, z) || world.isBlockIndirectlyGettingPowered(x, y + 1, z); + int meta = world.getBlockMetadata(x, y, z); + boolean powered = (meta & 8) != 0; + + if(power && !powered) { + TileEntity tile = world.getTileEntity(x, y, z); + if(tile != null && tile instanceof TileCacophonium) + ((TileCacophonium) tile).annoyDirewolf(); + world.setBlockMetadataWithNotify(x, y, z, meta | 8, 4); + } else if(!power && powered) + world.setBlockMetadataWithNotify(x, y, z, meta & -9, 4); + } + + @Override + public void onBlockHarvested(World par1World, int par2, int par3, int par4, int par5, EntityPlayer par6EntityPlayer) { + if(!par6EntityPlayer.capabilities.isCreativeMode) + dropBlockAsItem(par1World, par2, par3, par4, par5, 0); + } + + @Override + public ArrayList getDrops(World world, int x, int y, int z, int metadata, int fortune) { + ArrayList stacks = new ArrayList(); + + TileEntity tile = world.getTileEntity(x, y, z); + if(tile != null && tile instanceof TileCacophonium) { + stacks.add(new ItemStack(Blocks.noteblock)); + ItemStack thingy = ((TileCacophonium) tile).stack; + if(thingy != null) + stacks.add(thingy.copy()); + } + + return stacks; + } + + @Override + public TileEntity createNewTileEntity(World world, int meta) { + return new TileCacophonium(); + } + } diff --git a/src/main/java/vazkii/botania/common/block/BlockCamo.java b/src/main/java/vazkii/botania/common/block/BlockCamo.java index a3f4b7cee3..968d834921 100644 --- a/src/main/java/vazkii/botania/common/block/BlockCamo.java +++ b/src/main/java/vazkii/botania/common/block/BlockCamo.java @@ -2,18 +2,17 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jun 7, 2014, 2:20:51 PM (GMT)] */ package vazkii.botania.common.block; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; import java.util.Arrays; import java.util.List; + import net.minecraft.block.Block; import net.minecraft.block.BlockDirectional; import net.minecraft.block.material.Material; @@ -25,129 +24,124 @@ import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; import vazkii.botania.common.block.tile.TileCamo; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; public abstract class BlockCamo extends BlockModContainer { - static List validRenderTypes = Arrays.asList(0, 31, 39); - - protected BlockCamo(Material par2Material) { - super(par2Material); - } - - @Override - public IIcon getIcon(IBlockAccess world, int x, int y, int z, int side) { - TileEntity tile = world.getTileEntity(x, y, z); - int meta = world.getBlockMetadata(x, y, z); - - if (tile instanceof TileCamo) { - TileCamo camo = (TileCamo) tile; - Block block = camo.camo; - if (block != null && isValidBlock(block)) return block.getIcon(side, camo.camoMeta); - } - - return getIconFromSideAfterCheck(tile, meta, side); - } - - public static boolean isValidBlock(Block block) { - return block.isOpaqueCube() || isValidRenderType(block.getRenderType()); - } - - public static boolean isValidRenderType(int type) { - return validRenderTypes.contains(type); - } - - @Override - public boolean onBlockActivated( - World par1World, - int par2, - int par3, - int par4, - EntityPlayer par5EntityPlayer, - int par6, - float par7, - float par8, - float par9) { - TileEntity tile = par1World.getTileEntity(par2, par3, par4); - - if (tile instanceof TileCamo) { - TileCamo camo = (TileCamo) tile; - ItemStack currentStack = par5EntityPlayer.getCurrentEquippedItem(); - - if (currentStack == null) currentStack = new ItemStack(Block.getBlockFromName("air"), 1, 0); - - boolean doChange = true; - Block block = null; - checkChange: - { - if (currentStack.getItem() != Item.getItemFromBlock(Block.getBlockFromName("air"))) { - if (Item.getIdFromItem(currentStack.getItem()) == 0) { - doChange = false; - break checkChange; - } - - block = Block.getBlockFromItem(currentStack.getItem()); - if (block == null - || !isValidBlock(block) - || block instanceof BlockCamo - || block.getMaterial() == Material.air) doChange = false; - } - } - - if (doChange && currentStack.getItem() != null) { - int metadata = currentStack.getItemDamage(); - if (block instanceof BlockDirectional) { - switch (par6) { - case 0: - case 1: - break; - case 2: - metadata = metadata & 12 | 2; - break; - case 3: - metadata = metadata & 12; - break; - case 4: - metadata = metadata & 12 | 1; - break; - case 5: - metadata = metadata & 12 | 3; - break; - } - } - camo.camo = Block.getBlockFromItem(currentStack.getItem()); - camo.camoMeta = metadata; - par1World.markBlockForUpdate(par2, par3, par4); - - return true; - } - } - - return false; - } - - @Override - public boolean isOpaqueCube() { - return false; - } - - @Override - public boolean renderAsNormalBlock() { - return false; - } - - @Override - @SideOnly(Side.CLIENT) - public int colorMultiplier(IBlockAccess par1World, int par2, int par3, int par4) { - TileEntity tile = par1World.getTileEntity(par2, par3, par4); - if (tile instanceof TileCamo) { - TileCamo camo = (TileCamo) tile; - Block block = camo.camo; - if (block != null) return block instanceof BlockCamo ? 0xFFFFFF : block.getRenderColor(camo.camoMeta); - } - return 0xFFFFFF; - } - - public IIcon getIconFromSideAfterCheck(TileEntity tile, int meta, int side) { - return getIcon(side, meta); - } -} + static List validRenderTypes = Arrays.asList(0, 31, 39); + + protected BlockCamo(Material par2Material) { + super(par2Material); + } + + @Override + public IIcon getIcon(IBlockAccess world, int x, int y, int z, int side) { + TileEntity tile = world.getTileEntity(x, y, z); + int meta = world.getBlockMetadata(x, y, z); + + if(tile instanceof TileCamo) { + TileCamo camo = (TileCamo) tile; + Block block = camo.camo; + if(block != null && isValidBlock(block)) + return block.getIcon(side, camo.camoMeta); + } + + return getIconFromSideAfterCheck(tile, meta, side); + } + + public static boolean isValidBlock(Block block) { + return block.isOpaqueCube() || isValidRenderType(block.getRenderType()); + } + + public static boolean isValidRenderType(int type) { + return validRenderTypes.contains(type); + } + + @Override + public boolean onBlockActivated(World par1World, int par2, int par3, int par4, EntityPlayer par5EntityPlayer, int par6, float par7, float par8, float par9) { + TileEntity tile = par1World.getTileEntity(par2, par3, par4); + + if(tile instanceof TileCamo) { + TileCamo camo = (TileCamo) tile; + ItemStack currentStack = par5EntityPlayer.getCurrentEquippedItem(); + + if(currentStack == null) + currentStack = new ItemStack(Block.getBlockFromName("air"), 1, 0); + + boolean doChange = true; + Block block = null; + checkChange : { + if(currentStack.getItem() != Item.getItemFromBlock(Block.getBlockFromName("air"))) { + if(Item.getIdFromItem(currentStack.getItem()) == 0) { + doChange = false; + break checkChange; + } + + block = Block.getBlockFromItem(currentStack.getItem()); + if(block == null || !isValidBlock(block) || block instanceof BlockCamo || block.getMaterial() == Material.air) + doChange = false; + } + } + + if(doChange && currentStack.getItem() != null) { + int metadata = currentStack.getItemDamage(); + if(block instanceof BlockDirectional) { + switch (par6) { + case 0: + case 1: + break; + case 2: + metadata = metadata & 12 | 2; + break; + case 3: + metadata = metadata & 12; + break; + case 4: + metadata = metadata & 12 | 1; + break; + case 5: + metadata = metadata & 12 | 3; + break; + } + } + camo.camo = Block.getBlockFromItem(currentStack.getItem()); + camo.camoMeta = metadata; + par1World.markBlockForUpdate(par2,par3,par4); + + return true; + } + } + + return false; + } + + @Override + public boolean isOpaqueCube() { + return false; + } + + @Override + public boolean renderAsNormalBlock() { + return false; + } + + @Override + @SideOnly(Side.CLIENT) + public int colorMultiplier(IBlockAccess par1World, int par2, int par3, int par4) { + TileEntity tile = par1World.getTileEntity(par2, par3, par4); + if(tile instanceof TileCamo) { + TileCamo camo = (TileCamo) tile; + Block block = camo.camo; + if(block != null) + return block instanceof BlockCamo ? 0xFFFFFF : block.getRenderColor(camo.camoMeta); + + } + return 0xFFFFFF; + } + + public IIcon getIconFromSideAfterCheck(TileEntity tile, int meta, int side) { + return getIcon(side, meta); + } + +} \ No newline at end of file diff --git a/src/main/java/vazkii/botania/common/block/BlockCell.java b/src/main/java/vazkii/botania/common/block/BlockCell.java index 20a243c7ca..b538b2372a 100644 --- a/src/main/java/vazkii/botania/common/block/BlockCell.java +++ b/src/main/java/vazkii/botania/common/block/BlockCell.java @@ -2,15 +2,16 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Sep 6, 2015, 4:03:56 PM (GMT)] */ package vazkii.botania.common.block; import java.util.ArrayList; + import net.minecraft.block.material.Material; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; @@ -24,24 +25,25 @@ public class BlockCell extends BlockModContainer implements ILexiconable { - public BlockCell() { - super(Material.gourd); - setBlockName(LibBlockNames.CELL_BLOCK); - setStepSound(soundTypeCloth); - } - - @Override - public ArrayList getDrops(World world, int x, int y, int z, int metadata, int fortune) { - return new ArrayList(); - } - - @Override - public TileEntity createNewTileEntity(World world, int meta) { - return new TileCell(); - } - - @Override - public LexiconEntry getEntry(World world, int x, int y, int z, EntityPlayer player, ItemStack lexicon) { - return LexiconData.dandelifeon; - } + public BlockCell() { + super(Material.gourd); + setBlockName(LibBlockNames.CELL_BLOCK); + setStepSound(soundTypeCloth); + } + + @Override + public ArrayList getDrops(World world, int x, int y, int z, int metadata, int fortune) { + return new ArrayList(); + } + + @Override + public TileEntity createNewTileEntity(World world, int meta) { + return new TileCell(); + } + + @Override + public LexiconEntry getEntry(World world, int x, int y, int z, EntityPlayer player, ItemStack lexicon) { + return LexiconData.dandelifeon; + } + } diff --git a/src/main/java/vazkii/botania/common/block/BlockCocoon.java b/src/main/java/vazkii/botania/common/block/BlockCocoon.java index c099e585c5..bcf82a5038 100644 --- a/src/main/java/vazkii/botania/common/block/BlockCocoon.java +++ b/src/main/java/vazkii/botania/common/block/BlockCocoon.java @@ -2,15 +2,16 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jul 8, 2015, 4:29:01 PM (GMT)] */ package vazkii.botania.common.block; import java.util.ArrayList; + import net.minecraft.block.material.Material; import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.entity.player.EntityPlayer; @@ -29,72 +30,73 @@ public class BlockCocoon extends BlockModContainer implements ILexiconable { - protected BlockCocoon() { - super(Material.cloth); - setHardness(3.0F); - setResistance(50.0F); - setStepSound(soundTypeCloth); - setBlockName(LibBlockNames.COCOON); - float f = 3F / 16F; - float f1 = 14F / 16F; - setBlockBounds(f, 0F, f, 1F - f, f1, 1F - f); - } + protected BlockCocoon() { + super(Material.cloth); + setHardness(3.0F); + setResistance(50.0F); + setStepSound(soundTypeCloth); + setBlockName(LibBlockNames.COCOON); + float f = 3F / 16F; + float f1 = 14F / 16F; + setBlockBounds(f, 0F, f, 1F - f, f1, 1F - f); + } + + @Override + public void registerBlockIcons(IIconRegister par1IconRegister) { + // NO-OP + } - @Override - public void registerBlockIcons(IIconRegister par1IconRegister) { - // NO-OP - } + @Override + public IIcon getIcon(int p_149691_1_, int p_149691_2_) { + return Blocks.web.getBlockTextureFromSide(0); + } - @Override - public IIcon getIcon(int p_149691_1_, int p_149691_2_) { - return Blocks.web.getBlockTextureFromSide(0); - } + @Override + public boolean renderAsNormalBlock() { + return false; + } - @Override - public boolean renderAsNormalBlock() { - return false; - } + @Override + public boolean isOpaqueCube() { + return false; + } - @Override - public boolean isOpaqueCube() { - return false; - } + @Override + public int getRenderType() { + return LibRenderIDs.idCocoon; + } - @Override - public int getRenderType() { - return LibRenderIDs.idCocoon; - } + @Override + public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int s, float xs, float ys, float zs) { + TileCocoon cocoon = (TileCocoon) world.getTileEntity(x, y, z); + ItemStack item = player.getCurrentEquippedItem(); + if(cocoon.emeraldsGiven < TileCocoon.MAX_EMERALDS && item != null && item.getItem() == Items.emerald) { + if(!player.capabilities.isCreativeMode) + item.stackSize--; + cocoon.emeraldsGiven++; + world.playAuxSFX(2005, x, y, z, 6 + world.rand.nextInt(4)); + } + return false; + } - @Override - public boolean onBlockActivated( - World world, int x, int y, int z, EntityPlayer player, int s, float xs, float ys, float zs) { - TileCocoon cocoon = (TileCocoon) world.getTileEntity(x, y, z); - ItemStack item = player.getCurrentEquippedItem(); - if (cocoon.emeraldsGiven < TileCocoon.MAX_EMERALDS && item != null && item.getItem() == Items.emerald) { - if (!player.capabilities.isCreativeMode) item.stackSize--; - cocoon.emeraldsGiven++; - world.playAuxSFX(2005, x, y, z, 6 + world.rand.nextInt(4)); - } - return false; - } + @Override + public ArrayList getDrops(World world, int x, int y, int z, int metadata, int fortune) { + return new ArrayList(); + } - @Override - public ArrayList getDrops(World world, int x, int y, int z, int metadata, int fortune) { - return new ArrayList(); - } + @Override + protected boolean canSilkHarvest() { + return false; + } - @Override - protected boolean canSilkHarvest() { - return false; - } + @Override + public TileEntity createNewTileEntity(World world, int meta) { + return new TileCocoon(); + } - @Override - public TileEntity createNewTileEntity(World world, int meta) { - return new TileCocoon(); - } + @Override + public LexiconEntry getEntry(World world, int x, int y, int z, EntityPlayer player, ItemStack lexicon) { + return LexiconData.cocoon; + } - @Override - public LexiconEntry getEntry(World world, int x, int y, int z, EntityPlayer player, ItemStack lexicon) { - return LexiconData.cocoon; - } } diff --git a/src/main/java/vazkii/botania/common/block/BlockDreamwood.java b/src/main/java/vazkii/botania/common/block/BlockDreamwood.java index d1615bd155..5ed43a1556 100644 --- a/src/main/java/vazkii/botania/common/block/BlockDreamwood.java +++ b/src/main/java/vazkii/botania/common/block/BlockDreamwood.java @@ -1,6 +1,5 @@ package vazkii.botania.common.block; -import cpw.mods.fml.common.registry.GameRegistry; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; import net.minecraft.world.World; @@ -8,20 +7,21 @@ import vazkii.botania.common.item.block.ItemBlockDreamwood; import vazkii.botania.common.lexicon.LexiconData; import vazkii.botania.common.lib.LibBlockNames; +import cpw.mods.fml.common.registry.GameRegistry; public class BlockDreamwood extends BlockLivingwood { - public BlockDreamwood() { - super(LibBlockNames.DREAM_WOOD); - } + public BlockDreamwood() { + super(LibBlockNames.DREAM_WOOD); + } - @Override - void register(String name) { - GameRegistry.registerBlock(this, ItemBlockDreamwood.class, name); - } + @Override + void register(String name) { + GameRegistry.registerBlock(this, ItemBlockDreamwood.class, name); + } - @Override - public LexiconEntry getEntry(World world, int x, int y, int z, EntityPlayer player, ItemStack lexicon) { - return LexiconData.elvenResources; - } + @Override + public LexiconEntry getEntry(World world, int x, int y, int z, EntityPlayer player, ItemStack lexicon) { + return LexiconData.elvenResources; + } } diff --git a/src/main/java/vazkii/botania/common/block/BlockEnchantedSoil.java b/src/main/java/vazkii/botania/common/block/BlockEnchantedSoil.java index 3f6b5c1373..1c66aca3f7 100644 --- a/src/main/java/vazkii/botania/common/block/BlockEnchantedSoil.java +++ b/src/main/java/vazkii/botania/common/block/BlockEnchantedSoil.java @@ -2,18 +2,16 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jan 26, 2015, 6:08:29 PM (GMT)] */ package vazkii.botania.common.block; -import cpw.mods.fml.common.eventhandler.SubscribeEvent; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; import java.util.Random; + import net.minecraft.block.material.Material; import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.client.renderer.texture.TextureAtlasSprite; @@ -34,66 +32,71 @@ import vazkii.botania.client.render.block.InterpolatedIcon; import vazkii.botania.common.lexicon.LexiconData; import vazkii.botania.common.lib.LibBlockNames; +import cpw.mods.fml.common.eventhandler.SubscribeEvent; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; public class BlockEnchantedSoil extends BlockMod implements ILexiconable { - IIcon iconSide; + IIcon iconSide; + + public BlockEnchantedSoil() { + super(Material.grass); + setHardness(0.6F); + setStepSound(soundTypeGrass); + setBlockName(LibBlockNames.ENCHANTED_SOIL); + MinecraftForge.EVENT_BUS.register(this); + } - public BlockEnchantedSoil() { - super(Material.grass); - setHardness(0.6F); - setStepSound(soundTypeGrass); - setBlockName(LibBlockNames.ENCHANTED_SOIL); - MinecraftForge.EVENT_BUS.register(this); - } + @Override + boolean registerInCreative() { + return false; + } - @Override - boolean registerInCreative() { - return false; - } + @Override + @SideOnly(Side.CLIENT) + public void registerBlockIcons(IIconRegister par1IconRegister) { + // NO-OP + } - @Override - @SideOnly(Side.CLIENT) - public void registerBlockIcons(IIconRegister par1IconRegister) { - // NO-OP - } + @SubscribeEvent + @SideOnly(Side.CLIENT) + public void loadTextures(TextureStitchEvent.Pre event) { + if(event.map.getTextureType() == 0) { + TextureAtlasSprite icon = new InterpolatedIcon("botania:enchantedSoil0"); + if(event.map.setTextureEntry("botania:enchantedSoil0", icon)) + blockIcon = icon; - @SubscribeEvent - @SideOnly(Side.CLIENT) - public void loadTextures(TextureStitchEvent.Pre event) { - if (event.map.getTextureType() == 0) { - TextureAtlasSprite icon = new InterpolatedIcon("botania:enchantedSoil0"); - if (event.map.setTextureEntry("botania:enchantedSoil0", icon)) blockIcon = icon; + icon = new InterpolatedIcon("botania:enchantedSoil1"); + if(event.map.setTextureEntry("botania:enchantedSoil1", icon)) + iconSide = icon; + } + } - icon = new InterpolatedIcon("botania:enchantedSoil1"); - if (event.map.setTextureEntry("botania:enchantedSoil1", icon)) iconSide = icon; - } - } + @Override + @SideOnly(Side.CLIENT) + public IIcon getIcon(int side, int meta) { + return side == 0 ? Blocks.dirt.getIcon(0, 0) : side == 1 ? blockIcon : iconSide; + } - @Override - @SideOnly(Side.CLIENT) - public IIcon getIcon(int side, int meta) { - return side == 0 ? Blocks.dirt.getIcon(0, 0) : side == 1 ? blockIcon : iconSide; - } + @Override + public Item getItemDropped(int p_149650_1_, Random p_149650_2_, int p_149650_3_) { + return Blocks.dirt.getItemDropped(0, p_149650_2_, p_149650_3_); + } - @Override - public Item getItemDropped(int p_149650_1_, Random p_149650_2_, int p_149650_3_) { - return Blocks.dirt.getItemDropped(0, p_149650_2_, p_149650_3_); - } + @Override + public boolean canSustainPlant(IBlockAccess world, int x, int y, int z, ForgeDirection direction, IPlantable plantable) { + return plantable.getPlantType(world, x, y - 1, z) == EnumPlantType.Plains; + } - @Override - public boolean canSustainPlant( - IBlockAccess world, int x, int y, int z, ForgeDirection direction, IPlantable plantable) { - return plantable.getPlantType(world, x, y - 1, z) == EnumPlantType.Plains; - } + @Override + protected boolean canSilkHarvest() { + return false; + } - @Override - protected boolean canSilkHarvest() { - return false; - } + @Override + public LexiconEntry getEntry(World world, int x, int y, int z, EntityPlayer player, ItemStack lexicon) { + return LexiconData.overgrowthSeed; + } - @Override - public LexiconEntry getEntry(World world, int x, int y, int z, EntityPlayer player, ItemStack lexicon) { - return LexiconData.overgrowthSeed; - } } diff --git a/src/main/java/vazkii/botania/common/block/BlockEnderEye.java b/src/main/java/vazkii/botania/common/block/BlockEnderEye.java index 7309410485..5ea86885ac 100644 --- a/src/main/java/vazkii/botania/common/block/BlockEnderEye.java +++ b/src/main/java/vazkii/botania/common/block/BlockEnderEye.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jul 30, 2014, 1:05:07 PM (GMT)] */ package vazkii.botania.common.block; @@ -27,44 +27,45 @@ public class BlockEnderEye extends BlockModContainer implements ILexiconable { - IIcon iconOff, iconOn; + IIcon iconOff, iconOn; - protected BlockEnderEye() { - super(Material.iron); - setHardness(3F); - setResistance(10F); - setStepSound(soundTypeMetal); - setBlockName(LibBlockNames.ENDER_EYE_BLOCK); - } + protected BlockEnderEye() { + super(Material.iron); + setHardness(3F); + setResistance(10F); + setStepSound(soundTypeMetal); + setBlockName(LibBlockNames.ENDER_EYE_BLOCK); + } - @Override - public void registerBlockIcons(IIconRegister par1IconRegister) { - iconOff = IconHelper.forBlock(par1IconRegister, this, 0); - iconOn = IconHelper.forBlock(par1IconRegister, this, 1); - } + @Override + public void registerBlockIcons(IIconRegister par1IconRegister) { + iconOff = IconHelper.forBlock(par1IconRegister, this, 0); + iconOn = IconHelper.forBlock(par1IconRegister, this, 1); + } - @Override - public IIcon getIcon(int side, int meta) { - return meta == 0 ? iconOff : iconOn; - } + @Override + public IIcon getIcon(int side, int meta) { + return meta == 0 ? iconOff : iconOn; + } - @Override - public boolean canProvidePower() { - return true; - } + @Override + public boolean canProvidePower() { + return true; + } - @Override - public int isProvidingWeakPower(IBlockAccess world, int x, int y, int z, int side) { - return world.getBlockMetadata(x, y, z); - } + @Override + public int isProvidingWeakPower(IBlockAccess world, int x, int y, int z, int side) { + return world.getBlockMetadata(x, y, z); + } - @Override - public TileEntity createNewTileEntity(World world, int meta) { - return new TileEnderEye(); - } + @Override + public TileEntity createNewTileEntity(World world, int meta) { + return new TileEnderEye(); + } + + @Override + public LexiconEntry getEntry(World world, int x, int y, int z, EntityPlayer player, ItemStack lexicon) { + return LexiconData.enderEyeBlock; + } - @Override - public LexiconEntry getEntry(World world, int x, int y, int z, EntityPlayer player, ItemStack lexicon) { - return LexiconData.enderEyeBlock; - } } diff --git a/src/main/java/vazkii/botania/common/block/BlockFakeAir.java b/src/main/java/vazkii/botania/common/block/BlockFakeAir.java index 1c83c4f4e8..e55e112953 100644 --- a/src/main/java/vazkii/botania/common/block/BlockFakeAir.java +++ b/src/main/java/vazkii/botania/common/block/BlockFakeAir.java @@ -2,16 +2,17 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Apr 10, 2015, 10:22:38 PM (GMT)] */ package vazkii.botania.common.block; import java.util.ArrayList; import java.util.Random; + import net.minecraft.block.Block; import net.minecraft.block.material.Material; import net.minecraft.entity.Entity; @@ -27,86 +28,87 @@ public class BlockFakeAir extends BlockModContainer { - public BlockFakeAir() { - super(Material.air); - setBlockName(LibBlockNames.FAKE_AIR); - setBlockBounds(0, 0, 0, 0, 0, 0); - setTickRandomly(true); - } - - @Override - public void onNeighborBlockChange(World world, int x, int y, int z, Block block) { - if (shouldRemove(world, x, y, z)) world.scheduleBlockUpdate(x, y, z, this, tickRate(world)); - } - - private boolean shouldRemove(World world, int x, int y, int z) { - return !world.isRemote && world.getTileEntity(x, y, z) == null - || !(world.getTileEntity(x, y, z) instanceof TileFakeAir) - || !((TileFakeAir) world.getTileEntity(x, y, z)).canStay(); - } - - @Override - public void updateTick(World world, int x, int y, int z, Random rand) { - if (shouldRemove(world, x, y, z)) world.setBlock(x, y, z, Blocks.water); - } - - @Override - public int tickRate(World p_149738_1_) { - return 4; - } - - @Override - public boolean registerInCreative() { - return false; - } - - @Override - public boolean isBlockNormalCube() { - return false; - } - - @Override - public boolean isOpaqueCube() { - return false; - } - - @Override - public boolean canEntityDestroy(IBlockAccess world, int x, int y, int z, Entity e) { - return false; - } - - @Override - public boolean canCollideCheck(int par1, boolean par2) { - return false; - } - - @Override - public boolean canBeReplacedByLeaves(IBlockAccess world, int x, int y, int z) { - return true; - } - - @Override - public boolean canDropFromExplosion(Explosion par1Explosion) { - return false; - } - - @Override - public ArrayList getDrops(World world, int x, int y, int z, int metadata, int fortune) { - return new ArrayList(); // Empty List - } - - @Override - public AxisAlignedBB getCollisionBoundingBoxFromPool(World par1World, int par2, int par3, int par4) { - return null; - } - - @Override - public boolean isAir(IBlockAccess world, int x, int y, int z) { - return true; - } - - @Override - public TileEntity createNewTileEntity(World world, int meta) { - return new TileFakeAir(); - } + public BlockFakeAir() { + super(Material.air); + setBlockName(LibBlockNames.FAKE_AIR); + setBlockBounds(0, 0, 0, 0, 0, 0); + setTickRandomly(true); + } + + @Override + public void onNeighborBlockChange(World world, int x, int y, int z, Block block) { + if(shouldRemove(world, x, y, z)) + world.scheduleBlockUpdate(x, y, z, this, tickRate(world)); + } + + private boolean shouldRemove(World world, int x, int y, int z) { + return !world.isRemote && world.getTileEntity(x, y, z) == null || !(world.getTileEntity(x, y, z) instanceof TileFakeAir) || !((TileFakeAir) world.getTileEntity(x, y, z)).canStay(); + } + + @Override + public void updateTick(World world, int x, int y, int z, Random rand) { + if(shouldRemove(world, x, y, z)) + world.setBlock(x, y, z, Blocks.water); + } + + @Override + public int tickRate(World p_149738_1_) { + return 4; + } + + @Override + public boolean registerInCreative() { + return false; + } + + @Override + public boolean isBlockNormalCube() { + return false; + } + + @Override + public boolean isOpaqueCube() { + return false; + } + + @Override + public boolean canEntityDestroy(IBlockAccess world, int x, int y, int z, Entity e) { + return false; + } + + @Override + public boolean canCollideCheck(int par1, boolean par2) { + return false; + } + + @Override + public boolean canBeReplacedByLeaves(IBlockAccess world, int x, int y, int z) { + return true; + } + + @Override + public boolean canDropFromExplosion(Explosion par1Explosion) { + return false; + } + + @Override + public ArrayList getDrops(World world, int x, int y, int z, int metadata, int fortune) { + return new ArrayList(); // Empty List + } + + @Override + public AxisAlignedBB getCollisionBoundingBoxFromPool(World par1World, int par2, int par3, int par4) { + return null; + } + + @Override + public boolean isAir(IBlockAccess world, int x, int y, int z) { + return true; + } + + @Override + public TileEntity createNewTileEntity(World world, int meta) { + return new TileFakeAir(); + } + } diff --git a/src/main/java/vazkii/botania/common/block/BlockFelPumpkin.java b/src/main/java/vazkii/botania/common/block/BlockFelPumpkin.java index 3a2a3cf985..9f439a05fc 100644 --- a/src/main/java/vazkii/botania/common/block/BlockFelPumpkin.java +++ b/src/main/java/vazkii/botania/common/block/BlockFelPumpkin.java @@ -2,17 +2,14 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jul 7, 2015, 7:59:10 PM (GMT)] */ package vazkii.botania.common.block; -import cpw.mods.fml.common.eventhandler.SubscribeEvent; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; import net.minecraft.block.material.Material; import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.entity.EntityLivingBase; @@ -32,97 +29,77 @@ import vazkii.botania.client.core.helper.IconHelper; import vazkii.botania.common.lexicon.LexiconData; import vazkii.botania.common.lib.LibBlockNames; +import cpw.mods.fml.common.eventhandler.SubscribeEvent; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; public class BlockFelPumpkin extends BlockMod implements ILexiconable { - private static final String TAG_FEL_SPAWNED = "Botania-FelSpawned"; + private static final String TAG_FEL_SPAWNED = "Botania-FelSpawned"; + + IIcon top, face; - IIcon top, face; + public BlockFelPumpkin() { + super(Material.gourd); + setBlockName(LibBlockNames.FEL_PUMPKIN); + setHardness(1F); + setStepSound(soundTypeWood); + MinecraftForge.EVENT_BUS.register(this); + } - public BlockFelPumpkin() { - super(Material.gourd); - setBlockName(LibBlockNames.FEL_PUMPKIN); - setHardness(1F); - setStepSound(soundTypeWood); - MinecraftForge.EVENT_BUS.register(this); - } + @Override + @SideOnly(Side.CLIENT) + public IIcon getIcon(int p_149691_1_, int p_149691_2_) { + return p_149691_1_ == 1 ? top : p_149691_1_ == 0 ? top : p_149691_2_ == 2 && p_149691_1_ == 2 ? face : p_149691_2_ == 3 && p_149691_1_ == 5 ? face : p_149691_2_ == 0 && p_149691_1_ == 3 ? face : p_149691_2_ == 1 && p_149691_1_ == 4 ? face : blockIcon; + } - @Override - @SideOnly(Side.CLIENT) - public IIcon getIcon(int p_149691_1_, int p_149691_2_) { - return p_149691_1_ == 1 - ? top - : p_149691_1_ == 0 - ? top - : p_149691_2_ == 2 && p_149691_1_ == 2 - ? face - : p_149691_2_ == 3 && p_149691_1_ == 5 - ? face - : p_149691_2_ == 0 && p_149691_1_ == 3 - ? face - : p_149691_2_ == 1 && p_149691_1_ == 4 ? face : blockIcon; - } + @Override + public void onBlockAdded(World p_149726_1_, int p_149726_2_, int p_149726_3_, int p_149726_4_) { + super.onBlockAdded(p_149726_1_, p_149726_2_, p_149726_3_, p_149726_4_); - @Override - public void onBlockAdded(World p_149726_1_, int p_149726_2_, int p_149726_3_, int p_149726_4_) { - super.onBlockAdded(p_149726_1_, p_149726_2_, p_149726_3_, p_149726_4_); + if(!p_149726_1_.isRemote && p_149726_1_.getBlock(p_149726_2_, p_149726_3_ - 1, p_149726_4_) == Blocks.iron_bars && p_149726_1_.getBlock(p_149726_2_, p_149726_3_ - 2, p_149726_4_) == Blocks.iron_bars) { + p_149726_1_.setBlock(p_149726_2_, p_149726_3_, p_149726_4_, getBlockById(0), 0, 2); + p_149726_1_.setBlock(p_149726_2_, p_149726_3_ - 1, p_149726_4_, getBlockById(0), 0, 2); + p_149726_1_.setBlock(p_149726_2_, p_149726_3_ - 2, p_149726_4_, getBlockById(0), 0, 2); + EntityBlaze blaze = new EntityBlaze(p_149726_1_); + blaze.setLocationAndAngles(p_149726_2_ + 0.5D, p_149726_3_ - 1.95D, p_149726_4_ + 0.5D, 0.0F, 0.0F); + blaze.getEntityData().setBoolean(TAG_FEL_SPAWNED, true); + p_149726_1_.spawnEntityInWorld(blaze); + p_149726_1_.notifyBlockChange(p_149726_2_, p_149726_3_, p_149726_4_, getBlockById(0)); + p_149726_1_.notifyBlockChange(p_149726_2_, p_149726_3_ - 1, p_149726_4_, getBlockById(0)); + p_149726_1_.notifyBlockChange(p_149726_2_, p_149726_3_ - 2, p_149726_4_, getBlockById(0)); + } + } - if (!p_149726_1_.isRemote - && p_149726_1_.getBlock(p_149726_2_, p_149726_3_ - 1, p_149726_4_) == Blocks.iron_bars - && p_149726_1_.getBlock(p_149726_2_, p_149726_3_ - 2, p_149726_4_) == Blocks.iron_bars) { - p_149726_1_.setBlock(p_149726_2_, p_149726_3_, p_149726_4_, getBlockById(0), 0, 2); - p_149726_1_.setBlock(p_149726_2_, p_149726_3_ - 1, p_149726_4_, getBlockById(0), 0, 2); - p_149726_1_.setBlock(p_149726_2_, p_149726_3_ - 2, p_149726_4_, getBlockById(0), 0, 2); - EntityBlaze blaze = new EntityBlaze(p_149726_1_); - blaze.setLocationAndAngles(p_149726_2_ + 0.5D, p_149726_3_ - 1.95D, p_149726_4_ + 0.5D, 0.0F, 0.0F); - blaze.getEntityData().setBoolean(TAG_FEL_SPAWNED, true); - p_149726_1_.spawnEntityInWorld(blaze); - p_149726_1_.notifyBlockChange(p_149726_2_, p_149726_3_, p_149726_4_, getBlockById(0)); - p_149726_1_.notifyBlockChange(p_149726_2_, p_149726_3_ - 1, p_149726_4_, getBlockById(0)); - p_149726_1_.notifyBlockChange(p_149726_2_, p_149726_3_ - 2, p_149726_4_, getBlockById(0)); - } - } + @Override + public void onBlockPlacedBy(World p_149689_1_, int p_149689_2_, int p_149689_3_, int p_149689_4_, EntityLivingBase p_149689_5_, ItemStack p_149689_6_) { + int l = MathHelper.floor_double(p_149689_5_.rotationYaw * 4.0F / 360.0F + 2.5D) & 3; + p_149689_1_.setBlockMetadataWithNotify(p_149689_2_, p_149689_3_, p_149689_4_, l, 2); + } - @Override - public void onBlockPlacedBy( - World p_149689_1_, - int p_149689_2_, - int p_149689_3_, - int p_149689_4_, - EntityLivingBase p_149689_5_, - ItemStack p_149689_6_) { - int l = MathHelper.floor_double(p_149689_5_.rotationYaw * 4.0F / 360.0F + 2.5D) & 3; - p_149689_1_.setBlockMetadataWithNotify(p_149689_2_, p_149689_3_, p_149689_4_, l, 2); - } + @Override + @SideOnly(Side.CLIENT) + public void registerBlockIcons(IIconRegister p_149651_1_) { + face = IconHelper.forBlock(p_149651_1_, this); + top = Blocks.pumpkin.getIcon(0, 0); + blockIcon = Blocks.pumpkin.getIcon(2, 0); + } - @Override - @SideOnly(Side.CLIENT) - public void registerBlockIcons(IIconRegister p_149651_1_) { - face = IconHelper.forBlock(p_149651_1_, this); - top = Blocks.pumpkin.getIcon(0, 0); - blockIcon = Blocks.pumpkin.getIcon(2, 0); - } + @SubscribeEvent + public void onDrops(LivingDropsEvent event) { + if(event.entity instanceof EntityBlaze && event.entity.getEntityData().getBoolean(TAG_FEL_SPAWNED)) + if(event.drops.isEmpty()) + event.drops.add(new EntityItem(event.entity.worldObj, event.entity.posX, event.entity.posY, event.entity.posZ, new ItemStack(Items.blaze_powder, 6))); + else for(EntityItem item : event.drops) { + ItemStack stack = item.getEntityItem(); + if(stack.getItem() == Items.blaze_rod) + item.setEntityItemStack(new ItemStack(Items.blaze_powder, stack.stackSize * 10)); + } + } - @SubscribeEvent - public void onDrops(LivingDropsEvent event) { - if (event.entity instanceof EntityBlaze && event.entity.getEntityData().getBoolean(TAG_FEL_SPAWNED)) - if (event.drops.isEmpty()) - event.drops.add(new EntityItem( - event.entity.worldObj, - event.entity.posX, - event.entity.posY, - event.entity.posZ, - new ItemStack(Items.blaze_powder, 6))); - else - for (EntityItem item : event.drops) { - ItemStack stack = item.getEntityItem(); - if (stack.getItem() == Items.blaze_rod) - item.setEntityItemStack(new ItemStack(Items.blaze_powder, stack.stackSize * 10)); - } - } + @Override + public LexiconEntry getEntry(World world, int x, int y, int z, EntityPlayer player, ItemStack lexicon) { + return LexiconData.gardenOfGlass; + } - @Override - public LexiconEntry getEntry(World world, int x, int y, int z, EntityPlayer player, ItemStack lexicon) { - return LexiconData.gardenOfGlass; - } } diff --git a/src/main/java/vazkii/botania/common/block/BlockFloatingSpecialFlower.java b/src/main/java/vazkii/botania/common/block/BlockFloatingSpecialFlower.java index 6155e0be3b..c504304299 100644 --- a/src/main/java/vazkii/botania/common/block/BlockFloatingSpecialFlower.java +++ b/src/main/java/vazkii/botania/common/block/BlockFloatingSpecialFlower.java @@ -2,18 +2,18 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Nov 17, 2014, 5:31:53 PM (GMT)] */ package vazkii.botania.common.block; -import cpw.mods.fml.common.registry.GameRegistry; import java.util.ArrayList; import java.util.List; import java.util.Random; + import net.minecraft.client.Minecraft; import net.minecraft.client.gui.ScaledResolution; import net.minecraft.creativetab.CreativeTabs; @@ -41,141 +41,136 @@ import vazkii.botania.common.item.block.ItemBlockFloatingSpecialFlower; import vazkii.botania.common.item.block.ItemBlockSpecialFlower; import vazkii.botania.common.lib.LibBlockNames; +import cpw.mods.fml.common.registry.GameRegistry; -public class BlockFloatingSpecialFlower extends BlockFloatingFlower - implements ISpecialFlower, IWandable, ILexiconable, IWandHUD { - - public BlockFloatingSpecialFlower() { - super(LibBlockNames.FLOATING_SPECIAL_FLOWER); - - GameRegistry.addRecipe(new SpecialFloatingFlowerRecipe()); - RecipeSorter.register( - "botania:floatingSpecialFlower", SpecialFloatingFlowerRecipe.class, Category.SHAPELESS, ""); - } - - @Override - public int getLightValue(IBlockAccess world, int x, int y, int z) { - int currentLight = ((TileSpecialFlower) world.getTileEntity(x, y, z)).getLightValue(); - if (currentLight == -1) currentLight = originalLight; - return LightHelper.getPackedColor(world.getBlockMetadata(x, y, z), currentLight); - } - - @Override - public boolean hasComparatorInputOverride() { - return true; - } - - @Override - public int getComparatorInputOverride(World world, int x, int y, int z, int side) { - return ((TileSpecialFlower) world.getTileEntity(x, y, z)).getComparatorInputOverride(side); - } - - @Override - public int isProvidingWeakPower(IBlockAccess world, int x, int y, int z, int side) { - return ((TileSpecialFlower) world.getTileEntity(x, y, z)).getPowerLevel(side); - } - - @Override - public int isProvidingStrongPower(IBlockAccess world, int x, int y, int z, int side) { - return isProvidingWeakPower(world, x, y, z, side); - } - - @Override - public boolean canProvidePower() { - return true; - } - - @Override - public void randomDisplayTick(World par1World, int par2, int par3, int par4, Random par5Random) { - // NO-OP - } - - @Override - public void getSubBlocks(Item par1, CreativeTabs par2CreativeTabs, List par3List) { - for (String s : BotaniaAPI.subtilesForCreativeMenu) { - par3List.add(ItemBlockSpecialFlower.ofType(new ItemStack(par1), s)); - if (BotaniaAPI.miniFlowers.containsKey(s)) - par3List.add(ItemBlockSpecialFlower.ofType(new ItemStack(par1), BotaniaAPI.miniFlowers.get(s))); - } - } - - @Override - public ItemStack getPickBlock(MovingObjectPosition target, World world, int x, int y, int z) { - String name = ((TileSpecialFlower) world.getTileEntity(x, y, z)).subTileName; - return ItemBlockSpecialFlower.ofType(new ItemStack(world.getBlock(x, y, z)), name); - } - - @Override - public void onBlockHarvested( - World par1World, int par2, int par3, int par4, int par5, EntityPlayer par6EntityPlayer) { - if (!par6EntityPlayer.capabilities.isCreativeMode) { - dropBlockAsItem(par1World, par2, par3, par4, par5, 0); - ((TileSpecialFlower) par1World.getTileEntity(par2, par3, par4)) - .onBlockHarvested(par1World, par2, par3, par4, par5, par6EntityPlayer); - } - } - - @Override - public ArrayList getDrops(World world, int x, int y, int z, int metadata, int fortune) { - ArrayList list = new ArrayList(); - TileEntity tile = world.getTileEntity(x, y, z); - - if (tile != null) { - String name = ((TileSpecialFlower) tile).subTileName; - list.add(ItemBlockSpecialFlower.ofType(new ItemStack(world.getBlock(x, y, z)), name)); - ((TileSpecialFlower) tile).getDrops(list); - } - - return list; - } - - @Override - public boolean onBlockEventReceived(World par1World, int par2, int par3, int par4, int par5, int par6) { - super.onBlockEventReceived(par1World, par2, par3, par4, par5, par6); - TileEntity tileentity = par1World.getTileEntity(par2, par3, par4); - return tileentity != null ? tileentity.receiveClientEvent(par5, par6) : false; - } - - @Override - public boolean onUsedByWand(EntityPlayer player, ItemStack stack, World world, int x, int y, int z, int side) { - return ((TileSpecialFlower) world.getTileEntity(x, y, z)).onWanded(stack, player); - } - - @Override - public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase entity, ItemStack stack) { - ((TileSpecialFlower) world.getTileEntity(x, y, z)).onBlockPlacedBy(world, x, y, z, entity, stack); - } - - @Override - public boolean onBlockActivated( - World world, int x, int y, int z, EntityPlayer player, int side, float hitX, float hitY, float hitZ) { - return ((TileSpecialFlower) world.getTileEntity(x, y, z)) - .onBlockActivated(world, x, y, z, player, side, hitX, hitY, hitZ) - || super.onBlockActivated(world, x, y, z, player, side, hitX, hitY, hitZ); - } - - @Override - public void onBlockAdded(World world, int x, int y, int z) { - ((TileSpecialFlower) world.getTileEntity(x, y, z)).onBlockAdded(world, x, y, z); - } - - @Override - public void renderHUD(Minecraft mc, ScaledResolution res, World world, int x, int y, int z) { - ((TileSpecialFlower) world.getTileEntity(x, y, z)).renderHUD(mc, res); - } - - @Override - protected void register(String name) { - GameRegistry.registerBlock(this, ItemBlockFloatingSpecialFlower.class, name); - } - - @Override - public TileEntity createNewTileEntity(World world, int meta) { - return new TileFloatingSpecialFlower(); - } - - @Override - public LexiconEntry getEntry(World world, int x, int y, int z, EntityPlayer player, ItemStack lexicon) { - return ((TileSpecialFlower) world.getTileEntity(x, y, z)).getEntry(); - } +public class BlockFloatingSpecialFlower extends BlockFloatingFlower implements ISpecialFlower, IWandable, ILexiconable, IWandHUD { + + public BlockFloatingSpecialFlower() { + super(LibBlockNames.FLOATING_SPECIAL_FLOWER); + + GameRegistry.addRecipe(new SpecialFloatingFlowerRecipe()); + RecipeSorter.register("botania:floatingSpecialFlower", SpecialFloatingFlowerRecipe.class, Category.SHAPELESS, ""); + } + + @Override + public int getLightValue(IBlockAccess world, int x, int y, int z) { + int currentLight = ((TileSpecialFlower) world.getTileEntity(x, y, z)).getLightValue(); + if(currentLight == -1) + currentLight = originalLight; + return LightHelper.getPackedColor(world.getBlockMetadata(x, y, z), currentLight); + } + + @Override + public boolean hasComparatorInputOverride() { + return true; + } + + @Override + public int getComparatorInputOverride(World world, int x, int y, int z, int side) { + return ((TileSpecialFlower) world.getTileEntity(x, y, z)).getComparatorInputOverride(side); + } + + @Override + public int isProvidingWeakPower(IBlockAccess world, int x, int y, int z, int side) { + return ((TileSpecialFlower) world.getTileEntity(x, y, z)).getPowerLevel(side); + } + + @Override + public int isProvidingStrongPower(IBlockAccess world, int x, int y, int z, int side) { + return isProvidingWeakPower(world, x, y, z, side); + } + + @Override + public boolean canProvidePower() { + return true; + } + + @Override + public void randomDisplayTick(World par1World, int par2, int par3, int par4, Random par5Random) { + // NO-OP + } + + @Override + public void getSubBlocks(Item par1, CreativeTabs par2CreativeTabs, List par3List) { + for(String s : BotaniaAPI.subtilesForCreativeMenu) { + par3List.add(ItemBlockSpecialFlower.ofType(new ItemStack(par1), s)); + if(BotaniaAPI.miniFlowers.containsKey(s)) + par3List.add(ItemBlockSpecialFlower.ofType(new ItemStack(par1), BotaniaAPI.miniFlowers.get(s))); + } + } + + @Override + public ItemStack getPickBlock(MovingObjectPosition target, World world, int x, int y, int z) { + String name = ((TileSpecialFlower) world.getTileEntity(x, y, z)).subTileName; + return ItemBlockSpecialFlower.ofType(new ItemStack(world.getBlock(x, y, z)), name); + } + + @Override + public void onBlockHarvested(World par1World, int par2, int par3, int par4, int par5, EntityPlayer par6EntityPlayer) { + if(!par6EntityPlayer.capabilities.isCreativeMode) { + dropBlockAsItem(par1World, par2, par3, par4, par5, 0); + ((TileSpecialFlower) par1World.getTileEntity(par2, par3, par4)).onBlockHarvested(par1World, par2, par3, par4, par5, par6EntityPlayer); + } + } + + @Override + public ArrayList getDrops(World world, int x, int y, int z, int metadata, int fortune) { + ArrayList list = new ArrayList(); + TileEntity tile = world.getTileEntity(x, y, z); + + if(tile != null) { + String name = ((TileSpecialFlower) tile).subTileName; + list.add(ItemBlockSpecialFlower.ofType(new ItemStack(world.getBlock(x, y, z)), name)); + ((TileSpecialFlower) tile).getDrops(list); + } + + return list; + } + + @Override + public boolean onBlockEventReceived(World par1World, int par2, int par3, int par4, int par5, int par6) { + super.onBlockEventReceived(par1World, par2, par3, par4, par5, par6); + TileEntity tileentity = par1World.getTileEntity(par2, par3, par4); + return tileentity != null ? tileentity.receiveClientEvent(par5, par6) : false; + } + + @Override + public boolean onUsedByWand(EntityPlayer player, ItemStack stack, World world, int x, int y, int z, int side) { + return ((TileSpecialFlower) world.getTileEntity(x, y, z)).onWanded(stack, player); + } + + @Override + public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase entity, ItemStack stack) { + ((TileSpecialFlower) world.getTileEntity(x, y, z)).onBlockPlacedBy(world, x, y, z, entity, stack); + } + + @Override + public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int side, float hitX, float hitY, float hitZ) { + return ((TileSpecialFlower) world.getTileEntity(x, y, z)).onBlockActivated(world, x, y, z, player, side, hitX, hitY, hitZ) || super.onBlockActivated(world, x, y, z, player, side, hitX, hitY, hitZ); + } + + @Override + public void onBlockAdded(World world, int x, int y, int z) { + ((TileSpecialFlower) world.getTileEntity(x, y, z)).onBlockAdded(world, x, y, z); + } + + @Override + public void renderHUD(Minecraft mc, ScaledResolution res, World world, int x, int y, int z) { + ((TileSpecialFlower) world.getTileEntity(x, y, z)).renderHUD(mc, res); + } + + @Override + protected void register(String name) { + GameRegistry.registerBlock(this, ItemBlockFloatingSpecialFlower.class, name); + } + + @Override + public TileEntity createNewTileEntity(World world, int meta) { + return new TileFloatingSpecialFlower(); + } + + @Override + public LexiconEntry getEntry(World world, int x, int y, int z, EntityPlayer player, ItemStack lexicon) { + return ((TileSpecialFlower) world.getTileEntity(x, y, z)).getEntry(); + } } diff --git a/src/main/java/vazkii/botania/common/block/BlockForestEye.java b/src/main/java/vazkii/botania/common/block/BlockForestEye.java index d7a22739cd..aa03b96ccf 100644 --- a/src/main/java/vazkii/botania/common/block/BlockForestEye.java +++ b/src/main/java/vazkii/botania/common/block/BlockForestEye.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [May 9, 2014, 10:55:17 PM (GMT)] */ package vazkii.botania.common.block; @@ -26,56 +26,58 @@ public class BlockForestEye extends BlockModContainer implements ILexiconable { - IIcon[] icons; + IIcon[] icons; - public BlockForestEye() { - super(Material.iron); - setHardness(5.0F); - setResistance(10.0F); - setStepSound(soundTypeMetal); - setBlockBounds(0.25F, 0.25F, 0.25F, 0.75F, 0.75F, 0.75F); - setBlockName(LibBlockNames.FOREST_EYE); - } + public BlockForestEye() { + super(Material.iron); + setHardness(5.0F); + setResistance(10.0F); + setStepSound(soundTypeMetal); + setBlockBounds(0.25F, 0.25F, 0.25F, 0.75F, 0.75F, 0.75F); + setBlockName(LibBlockNames.FOREST_EYE); + } - @Override - public void registerBlockIcons(IIconRegister par1IconRegister) { - icons = new IIcon[6]; - for (int i = 0; i < icons.length; i++) icons[i] = IconHelper.forBlock(par1IconRegister, this, i); - } + @Override + public void registerBlockIcons(IIconRegister par1IconRegister) { + icons = new IIcon[6]; + for(int i = 0; i < icons.length; i++) + icons[i] = IconHelper.forBlock(par1IconRegister, this, i); + } - @Override - public IIcon getIcon(int par1, int par2) { - return icons[Math.min(icons.length - 1, par1)]; - } + @Override + public IIcon getIcon(int par1, int par2) { + return icons[Math.min(icons.length - 1, par1)]; + } - @Override - public boolean renderAsNormalBlock() { - return false; - } + @Override + public boolean renderAsNormalBlock() { + return false; + } - @Override - public boolean isOpaqueCube() { - return false; - } + @Override + public boolean isOpaqueCube() { + return false; + } - @Override - public boolean hasComparatorInputOverride() { - return true; - } + @Override + public boolean hasComparatorInputOverride() { + return true; + } - @Override - public int getComparatorInputOverride(World par1World, int par2, int par3, int par4, int par5) { - TileForestEye eye = (TileForestEye) par1World.getTileEntity(par2, par3, par4); - return Math.min(15, Math.max(0, eye.entities - 1)); - } + @Override + public int getComparatorInputOverride(World par1World, int par2, int par3, int par4, int par5) { + TileForestEye eye = (TileForestEye) par1World.getTileEntity(par2, par3, par4); + return Math.min(15, Math.max(0, eye.entities - 1)); + } - @Override - public TileEntity createNewTileEntity(World world, int meta) { - return new TileForestEye(); - } + @Override + public TileEntity createNewTileEntity(World world, int meta) { + return new TileForestEye(); + } + + @Override + public LexiconEntry getEntry(World world, int x, int y, int z, EntityPlayer player, ItemStack lexicon) { + return LexiconData.forestEye; + } - @Override - public LexiconEntry getEntry(World world, int x, int y, int z, EntityPlayer player, ItemStack lexicon) { - return LexiconData.forestEye; - } } diff --git a/src/main/java/vazkii/botania/common/block/BlockGaiaHead.java b/src/main/java/vazkii/botania/common/block/BlockGaiaHead.java index 82a844a7b8..9b49819a9f 100644 --- a/src/main/java/vazkii/botania/common/block/BlockGaiaHead.java +++ b/src/main/java/vazkii/botania/common/block/BlockGaiaHead.java @@ -2,19 +2,17 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Sep 23, 2015, 11:44:35 PM (GMT)] */ package vazkii.botania.common.block; -import cpw.mods.fml.common.registry.GameRegistry; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; import java.util.ArrayList; import java.util.Random; + import net.minecraft.block.Block; import net.minecraft.block.BlockSkull; import net.minecraft.client.renderer.texture.IIconRegister; @@ -29,71 +27,74 @@ import vazkii.botania.common.item.ModItems; import vazkii.botania.common.item.block.ItemBlockMod; import vazkii.botania.common.lib.LibBlockNames; +import cpw.mods.fml.common.registry.GameRegistry; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; public class BlockGaiaHead extends BlockSkull { - public BlockGaiaHead() { - setBlockName(LibBlockNames.GAIA_HEAD); - setHardness(1.0F); - } - - @Override - public Block setBlockName(String par1Str) { - GameRegistry.registerBlock(this, ItemBlockMod.class, par1Str); - return super.setBlockName(par1Str); - } - - @Override - @SideOnly(Side.CLIENT) - public Item getItem(World p_149694_1_, int p_149694_2_, int p_149694_3_, int p_149694_4_) { - return ModItems.gaiaHead; - } - - @Override - public void registerBlockIcons(IIconRegister p_149651_1_) { - // NO-OP - } - - @Override - public ArrayList getDrops( - World p_149749_1_, int p_149749_2_, int p_149749_3_, int p_149749_4_, int p_149749_6_, int fortune) { - ArrayList ret = new ArrayList(); - - if ((p_149749_6_ & 8) == 0) { - ItemStack itemstack = new ItemStack(ModItems.gaiaHead, 1); - TileEntitySkull tileentityskull = - (TileEntitySkull) p_149749_1_.getTileEntity(p_149749_2_, p_149749_3_, p_149749_4_); - - if (tileentityskull == null) return ret; - - ret.add(itemstack); - } - return ret; - } - - @Override - public Item getItemDropped(int p_149650_1_, Random p_149650_2_, int p_149650_3_) { - return ModItems.gaiaHead; - } - - @Override - public int getDamageValue(World p_149643_1_, int p_149643_2_, int p_149643_3_, int p_149643_4_) { - return 0; - } - - @Override - public int damageDropped(int p_149692_1_) { - return 0; - } - - @Override - public TileEntity createNewTileEntity(World p_149915_1_, int p_149915_2_) { - return new TileGaiaHead(); - } - - @Override - @SideOnly(Side.CLIENT) - public IIcon getIcon(int p_149691_1_, int p_149691_2_) { - return Blocks.coal_block.getBlockTextureFromSide(p_149691_1_); - } + public BlockGaiaHead() { + setBlockName(LibBlockNames.GAIA_HEAD); + setHardness(1.0F); + } + + @Override + public Block setBlockName(String par1Str) { + GameRegistry.registerBlock(this, ItemBlockMod.class, par1Str); + return super.setBlockName(par1Str); + } + + @Override + @SideOnly(Side.CLIENT) + public Item getItem(World p_149694_1_, int p_149694_2_, int p_149694_3_, int p_149694_4_) { + return ModItems.gaiaHead; + } + + @Override + public void registerBlockIcons(IIconRegister p_149651_1_) { + // NO-OP + } + + @Override + public ArrayList getDrops(World p_149749_1_, int p_149749_2_, int p_149749_3_, int p_149749_4_, int p_149749_6_, int fortune) { + ArrayList ret = new ArrayList(); + + if((p_149749_6_ & 8) == 0) { + ItemStack itemstack = new ItemStack(ModItems.gaiaHead, 1); + TileEntitySkull tileentityskull = (TileEntitySkull)p_149749_1_.getTileEntity(p_149749_2_, p_149749_3_, p_149749_4_); + + if(tileentityskull == null) + return ret; + + ret.add(itemstack); + } + return ret; + } + + @Override + public Item getItemDropped(int p_149650_1_, Random p_149650_2_, int p_149650_3_) { + return ModItems.gaiaHead; + } + + @Override + public int getDamageValue(World p_149643_1_, int p_149643_2_, int p_149643_3_, int p_149643_4_) { + return 0; + } + + @Override + public int damageDropped(int p_149692_1_) { + return 0; + } + + @Override + public TileEntity createNewTileEntity(World p_149915_1_, int p_149915_2_) { + return new TileGaiaHead(); + } + + @Override + @SideOnly(Side.CLIENT) + public IIcon getIcon(int p_149691_1_, int p_149691_2_) { + return Blocks.coal_block.getBlockTextureFromSide(p_149691_1_); + } + } diff --git a/src/main/java/vazkii/botania/common/block/BlockGhostRail.java b/src/main/java/vazkii/botania/common/block/BlockGhostRail.java index ce6f024f6b..428ec97a5a 100644 --- a/src/main/java/vazkii/botania/common/block/BlockGhostRail.java +++ b/src/main/java/vazkii/botania/common/block/BlockGhostRail.java @@ -2,18 +2,14 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jun 9, 2015, 12:48:18 AM (GMT)] */ package vazkii.botania.common.block; -import cpw.mods.fml.common.eventhandler.SubscribeEvent; -import cpw.mods.fml.common.registry.GameRegistry; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; import net.minecraft.block.Block; import net.minecraft.block.BlockRailBase; import net.minecraft.client.renderer.texture.IIconRegister; @@ -30,60 +26,68 @@ import vazkii.botania.common.item.block.ItemBlockMod; import vazkii.botania.common.lexicon.LexiconData; import vazkii.botania.common.lib.LibBlockNames; +import cpw.mods.fml.common.eventhandler.SubscribeEvent; +import cpw.mods.fml.common.registry.GameRegistry; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; public class BlockGhostRail extends BlockRailBase implements ILexiconable { - private static final String TAG_FLOAT_TICKS = "Botania_FloatTicks"; + private static final String TAG_FLOAT_TICKS = "Botania_FloatTicks"; + + public BlockGhostRail() { + super(true); + setCreativeTab(BotaniaCreativeTab.INSTANCE); + MinecraftForge.EVENT_BUS.register(this); + setBlockName(LibBlockNames.GHOST_RAIL); + } - public BlockGhostRail() { - super(true); - setCreativeTab(BotaniaCreativeTab.INSTANCE); - MinecraftForge.EVENT_BUS.register(this); - setBlockName(LibBlockNames.GHOST_RAIL); - } + @Override + public Block setBlockName(String par1Str) { + GameRegistry.registerBlock(this, ItemBlockMod.class, par1Str); + return super.setBlockName(par1Str); + } - @Override - public Block setBlockName(String par1Str) { - GameRegistry.registerBlock(this, ItemBlockMod.class, par1Str); - return super.setBlockName(par1Str); - } + @Override + @SideOnly(Side.CLIENT) + public void registerBlockIcons(IIconRegister par1IconRegister) { + blockIcon = IconHelper.forBlock(par1IconRegister, this); + } - @Override - @SideOnly(Side.CLIENT) - public void registerBlockIcons(IIconRegister par1IconRegister) { - blockIcon = IconHelper.forBlock(par1IconRegister, this); - } + @SubscribeEvent + public void onMinecartUpdate(MinecartUpdateEvent event) { + int x = MathHelper.floor_double(event.entity.posX); + int y = MathHelper.floor_double(event.entity.posY); + int z = MathHelper.floor_double(event.entity.posZ); + Block block = event.entity.worldObj.getBlock(x, y, z); + boolean air = block.isAir(event.entity.worldObj, x, y, z); + int floatTicks = event.entity.getEntityData().getInteger(TAG_FLOAT_TICKS); - @SubscribeEvent - public void onMinecartUpdate(MinecartUpdateEvent event) { - int x = MathHelper.floor_double(event.entity.posX); - int y = MathHelper.floor_double(event.entity.posY); - int z = MathHelper.floor_double(event.entity.posZ); - Block block = event.entity.worldObj.getBlock(x, y, z); - boolean air = block.isAir(event.entity.worldObj, x, y, z); - int floatTicks = event.entity.getEntityData().getInteger(TAG_FLOAT_TICKS); + if(block == this) + event.entity.getEntityData().setInteger(TAG_FLOAT_TICKS, 20); + else if(block instanceof BlockRailBase || block == ModBlocks.dreamwood) { + event.entity.getEntityData().setInteger(TAG_FLOAT_TICKS, 0); + if(floatTicks > 0) + event.entity.worldObj.playAuxSFX(2003, x, y, z, 0); + } + floatTicks = event.entity.getEntityData().getInteger(TAG_FLOAT_TICKS); - if (block == this) event.entity.getEntityData().setInteger(TAG_FLOAT_TICKS, 20); - else if (block instanceof BlockRailBase || block == ModBlocks.dreamwood) { - event.entity.getEntityData().setInteger(TAG_FLOAT_TICKS, 0); - if (floatTicks > 0) event.entity.worldObj.playAuxSFX(2003, x, y, z, 0); - } - floatTicks = event.entity.getEntityData().getInteger(TAG_FLOAT_TICKS); + if(floatTicks > 0) { + Block blockBelow = event.entity.worldObj.getBlock(x, y - 1, z); + boolean airBelow = blockBelow.isAir(event.entity.worldObj, x, y - 1, z); + if(air && airBelow || !air && !airBelow) + event.entity.noClip = true; + event.entity.motionY = 0.2; + event.entity.motionX *= 1.4; + event.entity.motionZ *= 1.4; + event.entity.getEntityData().setInteger(TAG_FLOAT_TICKS, floatTicks - 1); + event.entity.worldObj.playAuxSFX(2000, x, y, z, 0); + } else event.entity.noClip = false; + } - if (floatTicks > 0) { - Block blockBelow = event.entity.worldObj.getBlock(x, y - 1, z); - boolean airBelow = blockBelow.isAir(event.entity.worldObj, x, y - 1, z); - if (air && airBelow || !air && !airBelow) event.entity.noClip = true; - event.entity.motionY = 0.2; - event.entity.motionX *= 1.4; - event.entity.motionZ *= 1.4; - event.entity.getEntityData().setInteger(TAG_FLOAT_TICKS, floatTicks - 1); - event.entity.worldObj.playAuxSFX(2000, x, y, z, 0); - } else event.entity.noClip = false; - } + @Override + public LexiconEntry getEntry(World world, int x, int y, int z, EntityPlayer player, ItemStack lexicon) { + return LexiconData.ghostRail; + } - @Override - public LexiconEntry getEntry(World world, int x, int y, int z, EntityPlayer player, ItemStack lexicon) { - return LexiconData.ghostRail; - } } diff --git a/src/main/java/vazkii/botania/common/block/BlockHourglass.java b/src/main/java/vazkii/botania/common/block/BlockHourglass.java index d4c16545e1..99c51a1d59 100644 --- a/src/main/java/vazkii/botania/common/block/BlockHourglass.java +++ b/src/main/java/vazkii/botania/common/block/BlockHourglass.java @@ -2,15 +2,16 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [May 29, 2015, 8:17:08 PM (GMT)] */ package vazkii.botania.common.block; import java.util.Random; + import net.minecraft.block.Block; import net.minecraft.block.material.Material; import net.minecraft.client.Minecraft; @@ -41,171 +42,166 @@ public class BlockHourglass extends BlockModContainer implements IManaTrigger, IWandable, IWandHUD, ILexiconable { - Random random; - - protected BlockHourglass() { - super(Material.iron); - setBlockName(LibBlockNames.HOURGLASS); - setHardness(2.0F); - setStepSound(soundTypeMetal); - - float f = 1F / 16F; - float w = 8F * f; - float d = (1F - w) / 2; - setBlockBounds(d, 0F, d, 1F - d, 1.15F, 1F - d); - - random = new Random(); - } - - @Override - public boolean onBlockActivated( - World world, int x, int y, int z, EntityPlayer player, int side, float xs, float ys, float zs) { - TileHourglass hourglass = (TileHourglass) world.getTileEntity(x, y, z); - ItemStack hgStack = hourglass.getStackInSlot(0); - ItemStack stack = player.getCurrentEquippedItem(); - if (stack != null && stack.getItem() == ModItems.twigWand) return false; - - if (hourglass.lock) { - if (!player.worldObj.isRemote) - player.addChatMessage(new ChatComponentTranslation("botaniamisc.hourglassLock")); - return true; - } - - if (hgStack == null && TileHourglass.getStackItemTime(stack) > 0) { - hourglass.setInventorySlotContents(0, stack.copy()); - hourglass.markDirty(); - stack.stackSize = 0; - return true; - } else if (hgStack != null) { - ItemStack copy = hgStack.copy(); - if (!player.inventory.addItemStackToInventory(copy)) player.dropPlayerItemWithRandomChoice(copy, false); - hourglass.setInventorySlotContents(0, null); - hourglass.markDirty(); - return true; - } - - return false; - } - - @Override - public boolean canProvidePower() { - return true; - } - - @Override - public int isProvidingWeakPower(IBlockAccess world, int x, int y, int z, int side) { - return world.getBlockMetadata(x, y, z) == 0 ? 0 : 15; - } - - @Override - public int tickRate(World world) { - return 4; - } - - @Override - public void updateTick(World world, int x, int y, int z, Random rand) { - world.setBlockMetadataWithNotify(x, y, z, 0, 1 | 2); - } - - @Override - public void breakBlock(World par1World, int par2, int par3, int par4, Block par5, int par6) { - TileSimpleInventory inv = (TileSimpleInventory) par1World.getTileEntity(par2, par3, par4); - - if (inv != null) { - for (int j1 = 0; j1 < inv.getSizeInventory(); ++j1) { - ItemStack itemstack = inv.getStackInSlot(j1); - - if (itemstack != null) { - float f = random.nextFloat() * 0.8F + 0.1F; - float f1 = random.nextFloat() * 0.8F + 0.1F; - EntityItem entityitem; - - for (float f2 = random.nextFloat() * 0.8F + 0.1F; - itemstack.stackSize > 0; - par1World.spawnEntityInWorld(entityitem)) { - int k1 = random.nextInt(21) + 10; - - if (k1 > itemstack.stackSize) k1 = itemstack.stackSize; - - itemstack.stackSize -= k1; - entityitem = new EntityItem( - par1World, - par2 + f, - par3 + f1, - par4 + f2, - new ItemStack(itemstack.getItem(), k1, itemstack.getItemDamage())); - float f3 = 0.05F; - entityitem.motionX = (float) random.nextGaussian() * f3; - entityitem.motionY = (float) random.nextGaussian() * f3 + 0.2F; - entityitem.motionZ = (float) random.nextGaussian() * f3; - - if (itemstack.hasTagCompound()) - entityitem.getEntityItem().setTagCompound((NBTTagCompound) - itemstack.getTagCompound().copy()); - } - } - } - - par1World.func_147453_f(par2, par3, par4, par5); - } - - super.breakBlock(par1World, par2, par3, par4, par5, par6); - } - - @Override - public void registerBlockIcons(IIconRegister par1IconRegister) { - // NO-OP - } - - @Override - public IIcon getIcon(int p_149691_1_, int p_149691_2_) { - return ModBlocks.manaGlass.getIcon(0, 0); - } - - @Override - public boolean isOpaqueCube() { - return false; - } - - @Override - public boolean renderAsNormalBlock() { - return false; - } - - @Override - public int getRenderType() { - return LibRenderIDs.idHourglass; - } - - @Override - public TileEntity createNewTileEntity(World world, int meta) { - return new TileHourglass(); - } - - @Override - public void onBurstCollision(IManaBurst burst, World world, int x, int y, int z) { - if (!world.isRemote && !burst.isFake()) { - TileHourglass tile = (TileHourglass) world.getTileEntity(x, y, z); - tile.move = !tile.move; - VanillaPacketDispatcher.dispatchTEToNearbyPlayers(tile); - } - } - - @Override - public boolean onUsedByWand(EntityPlayer player, ItemStack stack, World world, int x, int y, int z, int side) { - TileHourglass tile = (TileHourglass) world.getTileEntity(x, y, z); - tile.lock = !tile.lock; - return false; - } - - @Override - public void renderHUD(Minecraft mc, ScaledResolution res, World world, int x, int y, int z) { - TileHourglass tile = (TileHourglass) world.getTileEntity(x, y, z); - tile.renderHUD(res); - } - - @Override - public LexiconEntry getEntry(World world, int x, int y, int z, EntityPlayer player, ItemStack lexicon) { - return LexiconData.hourglass; - } + Random random; + + protected BlockHourglass() { + super(Material.iron); + setBlockName(LibBlockNames.HOURGLASS); + setHardness(2.0F); + setStepSound(soundTypeMetal); + + float f = 1F / 16F; + float w = 8F * f; + float d = (1F - w) / 2; + setBlockBounds(d, 0F, d, 1F - d, 1.15F, 1F - d); + + random = new Random(); + } + + @Override + public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int side, float xs, float ys, float zs) { + TileHourglass hourglass = (TileHourglass) world.getTileEntity(x, y, z); + ItemStack hgStack = hourglass.getStackInSlot(0); + ItemStack stack = player.getCurrentEquippedItem(); + if(stack != null && stack.getItem() == ModItems.twigWand) + return false; + + if(hourglass.lock) { + if(!player.worldObj.isRemote) + player.addChatMessage(new ChatComponentTranslation("botaniamisc.hourglassLock")); + return true; + } + + if(hgStack == null && TileHourglass.getStackItemTime(stack) > 0) { + hourglass.setInventorySlotContents(0, stack.copy()); + hourglass.markDirty(); + stack.stackSize = 0; + return true; + } else if(hgStack != null) { + ItemStack copy = hgStack.copy(); + if(!player.inventory.addItemStackToInventory(copy)) + player.dropPlayerItemWithRandomChoice(copy, false); + hourglass.setInventorySlotContents(0, null); + hourglass.markDirty(); + return true; + } + + return false; + } + + @Override + public boolean canProvidePower() { + return true; + } + + @Override + public int isProvidingWeakPower(IBlockAccess world, int x, int y, int z, int side) { + return world.getBlockMetadata(x, y, z) == 0 ? 0 : 15; + } + + @Override + public int tickRate(World world) { + return 4; + } + + @Override + public void updateTick(World world, int x, int y, int z, Random rand) { + world.setBlockMetadataWithNotify(x, y, z, 0, 1 | 2); + } + + @Override + public void breakBlock(World par1World, int par2, int par3, int par4, Block par5, int par6) { + TileSimpleInventory inv = (TileSimpleInventory) par1World.getTileEntity(par2, par3, par4); + + if (inv != null) { + for (int j1 = 0; j1 < inv.getSizeInventory(); ++j1) { + ItemStack itemstack = inv.getStackInSlot(j1); + + if (itemstack != null) { + float f = random.nextFloat() * 0.8F + 0.1F; + float f1 = random.nextFloat() * 0.8F + 0.1F; + EntityItem entityitem; + + for (float f2 = random.nextFloat() * 0.8F + 0.1F; itemstack.stackSize > 0; par1World.spawnEntityInWorld(entityitem)) { + int k1 = random.nextInt(21) + 10; + + if (k1 > itemstack.stackSize) + k1 = itemstack.stackSize; + + itemstack.stackSize -= k1; + entityitem = new EntityItem(par1World, par2 + f, par3 + f1, par4 + f2, new ItemStack(itemstack.getItem(), k1, itemstack.getItemDamage())); + float f3 = 0.05F; + entityitem.motionX = (float)random.nextGaussian() * f3; + entityitem.motionY = (float)random.nextGaussian() * f3 + 0.2F; + entityitem.motionZ = (float)random.nextGaussian() * f3; + + if (itemstack.hasTagCompound()) + entityitem.getEntityItem().setTagCompound((NBTTagCompound)itemstack.getTagCompound().copy()); + } + } + } + + par1World.func_147453_f(par2, par3, par4, par5); + } + + super.breakBlock(par1World, par2, par3, par4, par5, par6); + } + + @Override + public void registerBlockIcons(IIconRegister par1IconRegister) { + // NO-OP + } + + @Override + public IIcon getIcon(int p_149691_1_, int p_149691_2_) { + return ModBlocks.manaGlass.getIcon(0, 0); + } + + @Override + public boolean isOpaqueCube() { + return false; + } + + @Override + public boolean renderAsNormalBlock() { + return false; + } + + @Override + public int getRenderType() { + return LibRenderIDs.idHourglass; + } + + @Override + public TileEntity createNewTileEntity(World world, int meta) { + return new TileHourglass(); + } + + @Override + public void onBurstCollision(IManaBurst burst, World world, int x, int y, int z) { + if(!world.isRemote && !burst.isFake()) { + TileHourglass tile = (TileHourglass) world.getTileEntity(x, y, z); + tile.move = !tile.move; + VanillaPacketDispatcher.dispatchTEToNearbyPlayers(tile); + } + } + + @Override + public boolean onUsedByWand(EntityPlayer player, ItemStack stack, World world, int x, int y, int z, int side) { + TileHourglass tile = (TileHourglass) world.getTileEntity(x, y, z); + tile.lock = !tile.lock; + return false; + } + + @Override + public void renderHUD(Minecraft mc, ScaledResolution res, World world, int x, int y, int z) { + TileHourglass tile = (TileHourglass) world.getTileEntity(x, y, z); + tile.renderHUD(res); + } + + @Override + public LexiconEntry getEntry(World world, int x, int y, int z, EntityPlayer player, ItemStack lexicon) { + return LexiconData.hourglass; + } + } diff --git a/src/main/java/vazkii/botania/common/block/BlockIncensePlate.java b/src/main/java/vazkii/botania/common/block/BlockIncensePlate.java index eb471c2dd4..1a44465f07 100644 --- a/src/main/java/vazkii/botania/common/block/BlockIncensePlate.java +++ b/src/main/java/vazkii/botania/common/block/BlockIncensePlate.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [May 15, 2015, 4:07:09 PM (GMT)] */ package vazkii.botania.common.block; @@ -34,124 +34,121 @@ public class BlockIncensePlate extends BlockModContainer implements ILexiconable { - private static final int[] META_ROTATIONS = new int[] {2, 5, 3, 4}; - - protected BlockIncensePlate() { - super(Material.wood); - setBlockName(LibBlockNames.INCENSE_PLATE); - setHardness(2.0F); - setStepSound(soundTypeWood); - setBlockBounds(true); - } - - @Override - public boolean onBlockActivated( - World world, int x, int y, int z, EntityPlayer player, int s, float xs, float ys, float zs) { - TileIncensePlate plate = (TileIncensePlate) world.getTileEntity(x, y, z); - ItemStack stack = player.getCurrentEquippedItem(); - ItemStack plateStack = plate.getStackInSlot(0); - boolean did = false; - - if (world.isRemote) return true; - - if (plateStack == null && plate.isItemValidForSlot(0, stack)) { - plate.setInventorySlotContents(0, stack.copy()); - stack.stackSize--; - did = true; - } else if (plateStack != null && !plate.burning) { - if (stack != null && stack.getItem() == Items.flint_and_steel) { - plate.ignite(); - stack.damageItem(1, player); - did = true; - } else { - ItemStack addStack = plateStack.copy(); - if (!player.inventory.addItemStackToInventory(addStack)) - player.dropPlayerItemWithRandomChoice(addStack, false); - plate.setInventorySlotContents(0, null); - - did = true; - } - } - - if (did) VanillaPacketDispatcher.dispatchTEToNearbyPlayers(plate); - - return did; - } - - @Override - public void onBlockPlacedBy( - World p_149689_1_, - int p_149689_2_, - int p_149689_3_, - int p_149689_4_, - EntityLivingBase p_149689_5_, - ItemStack p_149689_6_) { - int l = MathHelper.floor_double(p_149689_5_.rotationYaw * 4.0F / 360.0F + 0.5D) & 3; - p_149689_1_.setBlockMetadataWithNotify(p_149689_2_, p_149689_3_, p_149689_4_, META_ROTATIONS[l], 2); - } - - @Override - public boolean hasComparatorInputOverride() { - return true; - } - - @Override - public int getComparatorInputOverride(World world, int x, int y, int z, int side) { - return ((TileIncensePlate) world.getTileEntity(x, y, z)).comparatorOutput; - } - - @Override - public void setBlockBoundsBasedOnState(IBlockAccess w, int x, int y, int z) { - setBlockBounds(w.getBlockMetadata(x, y, z) < 4); - } - - public void setBlockBounds(boolean horiz) { - float f = 1F / 16F; - float w = 12 * f; - float l = 4 * f; - float xs = (1F - w) / 2; - float zs = (1F - l) / 2; - if (horiz) setBlockBounds(xs, 0F, zs, 1F - xs, f, 1f - zs); - else setBlockBounds(zs, 0F, xs, 1F - zs, f, 1f - xs); - } - - @Override - public boolean rotateBlock(World worldObj, int x, int y, int z, ForgeDirection axis) { - return RotationHelper.rotateVanillaBlock(Blocks.furnace, worldObj, x, y, z, axis); - } - - @Override - public void registerBlockIcons(IIconRegister par1IconRegister) { - // NO-OP - } - - @Override - public IIcon getIcon(int p_149691_1_, int p_149691_2_) { - return ModBlocks.livingwood.getIcon(0, 0); - } - - @Override - public boolean isOpaqueCube() { - return false; - } - - @Override - public boolean renderAsNormalBlock() { - return false; - } - - @Override - public int getRenderType() { - return LibRenderIDs.idIncensePlate; - } - - @Override - public TileEntity createNewTileEntity(World world, int meta) { - return new TileIncensePlate(); - } - - @Override - public LexiconEntry getEntry(World world, int x, int y, int z, EntityPlayer player, ItemStack lexicon) { - return LexiconData.incense; - } + private static final int[] META_ROTATIONS = new int[] { 2, 5, 3, 4 }; + + protected BlockIncensePlate() { + super(Material.wood); + setBlockName(LibBlockNames.INCENSE_PLATE); + setHardness(2.0F); + setStepSound(soundTypeWood); + setBlockBounds(true); + } + + @Override + public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int s, float xs, float ys, float zs) { + TileIncensePlate plate = (TileIncensePlate) world.getTileEntity(x, y, z); + ItemStack stack = player.getCurrentEquippedItem(); + ItemStack plateStack = plate.getStackInSlot(0); + boolean did = false; + + if(world.isRemote) + return true; + + if(plateStack == null && plate.isItemValidForSlot(0, stack)) { + plate.setInventorySlotContents(0, stack.copy()); + stack.stackSize--; + did = true; + } else if(plateStack != null && !plate.burning) { + if(stack != null && stack.getItem() == Items.flint_and_steel) { + plate.ignite(); + stack.damageItem(1, player); + did = true; + } else { + ItemStack addStack = plateStack.copy(); + if(!player.inventory.addItemStackToInventory(addStack)) + player.dropPlayerItemWithRandomChoice(addStack, false); + plate.setInventorySlotContents(0, null); + + did = true; + } + } + + if(did) + VanillaPacketDispatcher.dispatchTEToNearbyPlayers(plate); + + return did; + } + + @Override + public void onBlockPlacedBy(World p_149689_1_, int p_149689_2_, int p_149689_3_, int p_149689_4_, EntityLivingBase p_149689_5_, ItemStack p_149689_6_) { + int l = MathHelper.floor_double(p_149689_5_.rotationYaw * 4.0F / 360.0F + 0.5D) & 3; + p_149689_1_.setBlockMetadataWithNotify(p_149689_2_, p_149689_3_, p_149689_4_, META_ROTATIONS[l], 2); + } + + @Override + public boolean hasComparatorInputOverride() { + return true; + } + + @Override + public int getComparatorInputOverride(World world, int x, int y, int z, int side) { + return ((TileIncensePlate) world.getTileEntity(x, y, z)).comparatorOutput; + } + + @Override + public void setBlockBoundsBasedOnState(IBlockAccess w, int x, int y, int z) { + setBlockBounds(w.getBlockMetadata(x, y, z) < 4); + } + + public void setBlockBounds(boolean horiz) { + float f = 1F / 16F; + float w = 12 * f; + float l = 4 * f; + float xs = (1F - w) / 2; + float zs = (1F - l) / 2; + if(horiz) + setBlockBounds(xs, 0F, zs, 1F - xs, f, 1f - zs); + else setBlockBounds(zs, 0F, xs, 1F - zs, f, 1f - xs); + } + + @Override + public boolean rotateBlock(World worldObj, int x, int y, int z, ForgeDirection axis) { + return RotationHelper.rotateVanillaBlock(Blocks.furnace, worldObj, x, y, z, axis); + } + + @Override + public void registerBlockIcons(IIconRegister par1IconRegister) { + // NO-OP + } + + @Override + public IIcon getIcon(int p_149691_1_, int p_149691_2_) { + return ModBlocks.livingwood.getIcon(0, 0); + } + + @Override + public boolean isOpaqueCube() { + return false; + } + + @Override + public boolean renderAsNormalBlock() { + return false; + } + + @Override + public int getRenderType() { + return LibRenderIDs.idIncensePlate; + } + + @Override + public TileEntity createNewTileEntity(World world, int meta) { + return new TileIncensePlate(); + } + + @Override + public LexiconEntry getEntry(World world, int x, int y, int z, EntityPlayer player, ItemStack lexicon) { + return LexiconData.incense; + } + } diff --git a/src/main/java/vazkii/botania/common/block/BlockLightLauncher.java b/src/main/java/vazkii/botania/common/block/BlockLightLauncher.java index 05ddb0d9f9..dc0d407fa0 100644 --- a/src/main/java/vazkii/botania/common/block/BlockLightLauncher.java +++ b/src/main/java/vazkii/botania/common/block/BlockLightLauncher.java @@ -2,16 +2,17 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jul 17, 2015, 4:08:58 PM (GMT)] */ package vazkii.botania.common.block; import java.util.ArrayList; import java.util.List; + import net.minecraft.block.Block; import net.minecraft.block.material.Material; import net.minecraft.entity.Entity; @@ -33,68 +34,70 @@ public class BlockLightLauncher extends BlockMod implements ILexiconable { - public BlockLightLauncher() { - super(Material.wood); - setHardness(2.0F); - setStepSound(soundTypeWood); - setBlockName(LibBlockNames.LIGHT_LAUNCHER); - setBlockBounds(0F, 0F, 0F, 1F, 0.25F, 1F); - } + public BlockLightLauncher() { + super(Material.wood); + setHardness(2.0F); + setStepSound(soundTypeWood); + setBlockName(LibBlockNames.LIGHT_LAUNCHER); + setBlockBounds(0F, 0F, 0F, 1F, 0.25F, 1F); + } + + @Override + public boolean isOpaqueCube() { + return false; + } - @Override - public boolean isOpaqueCube() { - return false; - } + @Override + public boolean renderAsNormalBlock() { + return false; + } - @Override - public boolean renderAsNormalBlock() { - return false; - } + @Override + public boolean getBlocksMovement(IBlockAccess p_149655_1_, int p_149655_2_, int p_149655_3_, int p_149655_4_) { + return false; + } - @Override - public boolean getBlocksMovement(IBlockAccess p_149655_1_, int p_149655_2_, int p_149655_3_, int p_149655_4_) { - return false; - } + @Override + public void onNeighborBlockChange(World world, int x, int y, int z, Block block) { + boolean power = world.isBlockIndirectlyGettingPowered(x, y, z) || world.isBlockIndirectlyGettingPowered(x, y + 1, z); + int meta = world.getBlockMetadata(x, y, z); + boolean powered = (meta & 8) != 0; - @Override - public void onNeighborBlockChange(World world, int x, int y, int z, Block block) { - boolean power = - world.isBlockIndirectlyGettingPowered(x, y, z) || world.isBlockIndirectlyGettingPowered(x, y + 1, z); - int meta = world.getBlockMetadata(x, y, z); - boolean powered = (meta & 8) != 0; + if(power && !powered) { + pickUpEntities(world, x, y, z); + world.setBlockMetadataWithNotify(x, y, z, meta | 8, 4); + } else if(!power && powered) + world.setBlockMetadataWithNotify(x, y, z, meta & -9, 4); + } - if (power && !powered) { - pickUpEntities(world, x, y, z); - world.setBlockMetadataWithNotify(x, y, z, meta | 8, 4); - } else if (!power && powered) world.setBlockMetadataWithNotify(x, y, z, meta & -9, 4); - } + public void pickUpEntities(World world, int x, int y, int z) { + List relays = new ArrayList(); + for(ForgeDirection dir : LibMisc.CARDINAL_DIRECTIONS) { + TileEntity tile = world.getTileEntity(x + dir.offsetX, y, z + dir.offsetZ); + if(tile instanceof TileLightRelay) { + TileLightRelay relay = (TileLightRelay) tile; + if(relay.getBinding() != null) + relays.add(relay); + } + } - public void pickUpEntities(World world, int x, int y, int z) { - List relays = new ArrayList(); - for (ForgeDirection dir : LibMisc.CARDINAL_DIRECTIONS) { - TileEntity tile = world.getTileEntity(x + dir.offsetX, y, z + dir.offsetZ); - if (tile instanceof TileLightRelay) { - TileLightRelay relay = (TileLightRelay) tile; - if (relay.getBinding() != null) relays.add(relay); - } - } + if(!relays.isEmpty()) { + AxisAlignedBB aabb = AxisAlignedBB.getBoundingBox(x, y, z, x + 1, y + 1, z + 1); + List entities = world.getEntitiesWithinAABB(EntityLivingBase.class, aabb); + entities.addAll(world.getEntitiesWithinAABB(EntityItem.class, aabb)); - if (!relays.isEmpty()) { - AxisAlignedBB aabb = AxisAlignedBB.getBoundingBox(x, y, z, x + 1, y + 1, z + 1); - List entities = world.getEntitiesWithinAABB(EntityLivingBase.class, aabb); - entities.addAll(world.getEntitiesWithinAABB(EntityItem.class, aabb)); + if(!entities.isEmpty()) { + for(Entity entity : entities) { + TileLightRelay relay = relays.get(world.rand.nextInt(relays.size())); + relay.mountEntity(entity); + } + } + } + } - if (!entities.isEmpty()) { - for (Entity entity : entities) { - TileLightRelay relay = relays.get(world.rand.nextInt(relays.size())); - relay.mountEntity(entity); - } - } - } - } + @Override + public LexiconEntry getEntry(World world, int x, int y, int z, EntityPlayer player, ItemStack lexicon) { + return LexiconData.luminizerTransport; + } - @Override - public LexiconEntry getEntry(World world, int x, int y, int z, EntityPlayer player, ItemStack lexicon) { - return LexiconData.luminizerTransport; - } } diff --git a/src/main/java/vazkii/botania/common/block/BlockLightRelay.java b/src/main/java/vazkii/botania/common/block/BlockLightRelay.java index ab252016a1..04e0d77c21 100644 --- a/src/main/java/vazkii/botania/common/block/BlockLightRelay.java +++ b/src/main/java/vazkii/botania/common/block/BlockLightRelay.java @@ -2,17 +2,17 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jul 15, 2015, 8:31:13 PM (GMT)] */ package vazkii.botania.common.block; -import cpw.mods.fml.common.registry.GameRegistry; import java.util.List; import java.util.Random; + import net.minecraft.block.Block; import net.minecraft.block.material.Material; import net.minecraft.client.renderer.texture.IIconRegister; @@ -34,122 +34,123 @@ import vazkii.botania.common.item.block.ItemBlockWithMetadataAndName; import vazkii.botania.common.lexicon.LexiconData; import vazkii.botania.common.lib.LibBlockNames; +import cpw.mods.fml.common.registry.GameRegistry; public class BlockLightRelay extends BlockModContainer implements IWandable, ILexiconable { - public static IIcon invIcon, worldIcon, invIconRed, worldIconRed; - - protected BlockLightRelay() { - super(Material.glass); - float f = 5F / 16F; - setBlockBounds(f, f, f, 1F - f, 1F - f, 1F - f); - setBlockName(LibBlockNames.LIGHT_RELAY); - } - - @Override - public Block setBlockName(String par1Str) { - register(par1Str); - return super.setBlockName(par1Str); - } - - void register(String name) { - GameRegistry.registerBlock(this, ItemBlockWithMetadataAndName.class, name); - } - - @Override - public void getSubBlocks(Item item, CreativeTabs tab, List list) { - for (int i = 0; i < 2; i++) list.add(new ItemStack(item, 1, i)); - } - - @Override - public int damageDropped(int meta) { - return meta == 0 ? 0 : 1; - } - - @Override - protected boolean shouldRegisterInNameSet() { - return false; - } - - @Override - public boolean getBlocksMovement(IBlockAccess p_149655_1_, int p_149655_2_, int p_149655_3_, int p_149655_4_) { - return false; - } - - @Override - public boolean onBlockActivated( - World world, int x, int y, int z, EntityPlayer player, int s, float xs, float ys, float zs) { - ((TileLightRelay) world.getTileEntity(x, y, z)).mountEntity(player); - return true; - } - - @Override - public AxisAlignedBB getCollisionBoundingBoxFromPool( - World p_149668_1_, int p_149668_2_, int p_149668_3_, int p_149668_4_) { - return null; - } - - @Override - public int tickRate(World p_149738_1_) { - return 2; - } - - @Override - public void updateTick(World world, int x, int y, int z, Random rand) { - world.setBlockMetadataWithNotify(x, y, z, world.getBlockMetadata(x, y, z) & -9, 1 | 2); - } - - @Override - public boolean canProvidePower() { - return true; - } - - @Override - public int isProvidingWeakPower(IBlockAccess world, int x, int y, int z, int s) { - int meta = world.getBlockMetadata(x, y, z); - return (meta & 8) != 0 ? 15 : 0; - } - - @Override - public void registerBlockIcons(IIconRegister par1IconRegister) { - invIcon = IconHelper.forBlock(par1IconRegister, this, 0); - worldIcon = IconHelper.forBlock(par1IconRegister, this, 1); - invIconRed = IconHelper.forBlock(par1IconRegister, this, 2); - worldIconRed = IconHelper.forBlock(par1IconRegister, this, 3); - } - - @Override - public IIcon getIcon(int side, int meta) { - return meta > 0 ? invIconRed : invIcon; - } - - @Override - public boolean renderAsNormalBlock() { - return false; - } - - @Override - public boolean isOpaqueCube() { - return false; - } - - @Override - public int getRenderType() { - return LibRenderIDs.idLightRelay; - } - - @Override - public TileEntity createNewTileEntity(World world, int meta) { - return new TileLightRelay(); - } - - @Override - public boolean onUsedByWand(EntityPlayer player, ItemStack stack, World world, int x, int y, int z, int side) { - return false; - } - - @Override - public LexiconEntry getEntry(World world, int x, int y, int z, EntityPlayer player, ItemStack lexicon) { - return LexiconData.luminizerTransport; - } + public static IIcon invIcon, worldIcon, invIconRed, worldIconRed; + + protected BlockLightRelay() { + super(Material.glass); + float f = 5F / 16F; + setBlockBounds(f, f, f, 1F - f, 1F - f, 1F - f); + setBlockName(LibBlockNames.LIGHT_RELAY); + } + + @Override + public Block setBlockName(String par1Str) { + register(par1Str); + return super.setBlockName(par1Str); + } + + void register(String name) { + GameRegistry.registerBlock(this, ItemBlockWithMetadataAndName.class, name); + } + + @Override + public void getSubBlocks(Item item, CreativeTabs tab, List list) { + for(int i = 0; i < 2; i++) + list.add(new ItemStack(item, 1, i)); + } + + @Override + public int damageDropped(int meta) { + return meta == 0 ? 0 : 1; + } + + @Override + protected boolean shouldRegisterInNameSet() { + return false; + } + + @Override + public boolean getBlocksMovement(IBlockAccess p_149655_1_, int p_149655_2_, int p_149655_3_, int p_149655_4_) { + return false; + } + + @Override + public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int s, float xs, float ys, float zs) { + ((TileLightRelay) world.getTileEntity(x, y, z)).mountEntity(player); + return true; + } + + @Override + public AxisAlignedBB getCollisionBoundingBoxFromPool(World p_149668_1_, int p_149668_2_, int p_149668_3_, int p_149668_4_) { + return null; + } + + @Override + public int tickRate(World p_149738_1_) { + return 2; + } + + @Override + public void updateTick(World world, int x, int y, int z, Random rand) { + world.setBlockMetadataWithNotify(x, y, z, world.getBlockMetadata(x, y, z) & -9, 1 | 2); + } + + @Override + public boolean canProvidePower() { + return true; + } + + @Override + public int isProvidingWeakPower(IBlockAccess world, int x, int y, int z, int s) { + int meta = world.getBlockMetadata(x, y, z); + return (meta & 8) != 0 ? 15 : 0; + } + + @Override + public void registerBlockIcons(IIconRegister par1IconRegister) { + invIcon = IconHelper.forBlock(par1IconRegister, this, 0); + worldIcon = IconHelper.forBlock(par1IconRegister, this, 1); + invIconRed = IconHelper.forBlock(par1IconRegister, this, 2); + worldIconRed = IconHelper.forBlock(par1IconRegister, this, 3); + } + + @Override + public IIcon getIcon(int side, int meta) { + return meta > 0 ? invIconRed : invIcon; + } + + @Override + public boolean renderAsNormalBlock() { + return false; + } + + @Override + public boolean isOpaqueCube() { + return false; + } + + @Override + public int getRenderType() { + return LibRenderIDs.idLightRelay; + } + + @Override + public TileEntity createNewTileEntity(World world, int meta) { + return new TileLightRelay(); + } + + @Override + public boolean onUsedByWand(EntityPlayer player, ItemStack stack, World world, int x, int y, int z, int side) { + return false; + } + + @Override + public LexiconEntry getEntry(World world, int x, int y, int z, EntityPlayer player, ItemStack lexicon) { + return LexiconData.luminizerTransport; + } + } diff --git a/src/main/java/vazkii/botania/common/block/BlockLivingrock.java b/src/main/java/vazkii/botania/common/block/BlockLivingrock.java index 28e8be2091..e0b6e86216 100644 --- a/src/main/java/vazkii/botania/common/block/BlockLivingrock.java +++ b/src/main/java/vazkii/botania/common/block/BlockLivingrock.java @@ -2,16 +2,16 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jan 25, 2014, 10:03:04 PM (GMT)] */ package vazkii.botania.common.block; -import cpw.mods.fml.common.registry.GameRegistry; import java.util.List; + import net.minecraft.block.Block; import net.minecraft.block.material.Material; import net.minecraft.client.renderer.texture.IIconRegister; @@ -28,61 +28,65 @@ import vazkii.botania.common.item.block.ItemBlockWithMetadataAndName; import vazkii.botania.common.lexicon.LexiconData; import vazkii.botania.common.lib.LibBlockNames; +import cpw.mods.fml.common.registry.GameRegistry; public class BlockLivingrock extends BlockMod implements ILexiconable { - private static final int TYPES = 5; - IIcon[] icons; + private static final int TYPES = 5; + IIcon[] icons; + + public BlockLivingrock() { + super(Material.rock); + setHardness(2.0F); + setResistance(10.0F); + setStepSound(soundTypeStone); + setBlockName(LibBlockNames.LIVING_ROCK); + } - public BlockLivingrock() { - super(Material.rock); - setHardness(2.0F); - setResistance(10.0F); - setStepSound(soundTypeStone); - setBlockName(LibBlockNames.LIVING_ROCK); - } + @Override + protected boolean shouldRegisterInNameSet() { + return false; + } - @Override - protected boolean shouldRegisterInNameSet() { - return false; - } + @Override + public int damageDropped(int par1) { + return par1; + } - @Override - public int damageDropped(int par1) { - return par1; - } + @Override + public Block setBlockName(String par1Str) { + GameRegistry.registerBlock(this, ItemBlockWithMetadataAndName.class, par1Str); + return super.setBlockName(par1Str); + } - @Override - public Block setBlockName(String par1Str) { - GameRegistry.registerBlock(this, ItemBlockWithMetadataAndName.class, par1Str); - return super.setBlockName(par1Str); - } + @Override + public void getSubBlocks(Item par1, CreativeTabs par2CreativeTabs, List par3List) { + for(int i = 0; i < TYPES; i++) + par3List.add(new ItemStack(par1, 1, i)); + } - @Override - public void getSubBlocks(Item par1, CreativeTabs par2CreativeTabs, List par3List) { - for (int i = 0; i < TYPES; i++) par3List.add(new ItemStack(par1, 1, i)); - } + @Override + public void registerBlockIcons(IIconRegister par1IconRegister) { + icons = new IIcon[TYPES]; + for(int i = 0; i < TYPES; i++) + icons[i] = IconHelper.forBlock(par1IconRegister, this, i); + } - @Override - public void registerBlockIcons(IIconRegister par1IconRegister) { - icons = new IIcon[TYPES]; - for (int i = 0; i < TYPES; i++) icons[i] = IconHelper.forBlock(par1IconRegister, this, i); - } + @Override + public IIcon getIcon(int par1, int par2) { + return icons[Math.min(TYPES - 1, par2)]; + } - @Override - public IIcon getIcon(int par1, int par2) { - return icons[Math.min(TYPES - 1, par2)]; - } + @Override + public ItemStack getPickBlock(MovingObjectPosition target, World world, int x, int y, int z) { + int meta = world.getBlockMetadata(x, y, z); + return new ItemStack(this, 1, meta); + } - @Override - public ItemStack getPickBlock(MovingObjectPosition target, World world, int x, int y, int z) { - int meta = world.getBlockMetadata(x, y, z); - return new ItemStack(this, 1, meta); - } + @Override + public LexiconEntry getEntry(World world, int x, int y, int z, EntityPlayer player, ItemStack lexicon) { + int meta = world.getBlockMetadata(x, y, z); + return meta == 0 ? LexiconData.pureDaisy : LexiconData.decorativeBlocks; + } - @Override - public LexiconEntry getEntry(World world, int x, int y, int z, EntityPlayer player, ItemStack lexicon) { - int meta = world.getBlockMetadata(x, y, z); - return meta == 0 ? LexiconData.pureDaisy : LexiconData.decorativeBlocks; - } } diff --git a/src/main/java/vazkii/botania/common/block/BlockLivingwood.java b/src/main/java/vazkii/botania/common/block/BlockLivingwood.java index 740d724af6..a9571b6757 100644 --- a/src/main/java/vazkii/botania/common/block/BlockLivingwood.java +++ b/src/main/java/vazkii/botania/common/block/BlockLivingwood.java @@ -2,16 +2,16 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jan 25, 2014, 10:04:25 PM (GMT)] */ package vazkii.botania.common.block; -import cpw.mods.fml.common.registry.GameRegistry; import java.util.List; + import net.minecraft.block.Block; import net.minecraft.block.material.Material; import net.minecraft.client.renderer.texture.IIconRegister; @@ -29,78 +29,82 @@ import vazkii.botania.common.item.block.ItemBlockWithMetadataAndName; import vazkii.botania.common.lexicon.LexiconData; import vazkii.botania.common.lib.LibBlockNames; +import cpw.mods.fml.common.registry.GameRegistry; public class BlockLivingwood extends BlockMod implements ILexiconable { - private static final int TYPES = 6; - IIcon[] icons; - - public BlockLivingwood() { - this(LibBlockNames.LIVING_WOOD); - } - - public BlockLivingwood(String name) { - super(Material.wood); - setHardness(2.0F); - setStepSound(soundTypeWood); - setBlockName(name); - } - - @Override - protected boolean shouldRegisterInNameSet() { - return false; - } - - @Override - public int damageDropped(int par1) { - return par1; - } - - @Override - public Block setBlockName(String par1Str) { - register(par1Str); - return super.setBlockName(par1Str); - } - - void register(String name) { - GameRegistry.registerBlock(this, ItemBlockWithMetadataAndName.class, name); - } - - @Override - public void getSubBlocks(Item par1, CreativeTabs par2CreativeTabs, List par3List) { - for (int i = 0; i < TYPES; i++) par3List.add(new ItemStack(par1, 1, i)); - } - - @Override - public void registerBlockIcons(IIconRegister par1IconRegister) { - icons = new IIcon[TYPES]; - for (int i = 0; i < TYPES; i++) icons[i] = IconHelper.forBlock(par1IconRegister, this, i); - } - - @Override - public IIcon getIcon(int par1, int par2) { - return icons[Math.min(TYPES - 1, par2)]; - } - - @Override - public ItemStack getPickBlock(MovingObjectPosition target, World world, int x, int y, int z) { - int meta = world.getBlockMetadata(x, y, z); - return new ItemStack(this, 1, meta); - } - - @Override - public int getLightValue(IBlockAccess world, int x, int y, int z) { - return world.getBlockMetadata(x, y, z) == 5 ? 12 : 0; - } - - @Override - public LexiconEntry getEntry(World world, int x, int y, int z, EntityPlayer player, ItemStack lexicon) { - int meta = world.getBlockMetadata(x, y, z); - return meta == 0 ? LexiconData.pureDaisy : LexiconData.decorativeBlocks; - } - - @Override - public boolean canSustainLeaves(IBlockAccess world, int x, int y, int z) { - return world.getBlockMetadata(x, y, z) == 0; - } + private static final int TYPES = 6; + IIcon[] icons; + + public BlockLivingwood() { + this(LibBlockNames.LIVING_WOOD); + } + + public BlockLivingwood(String name) { + super(Material.wood); + setHardness(2.0F); + setStepSound(soundTypeWood); + setBlockName(name); + } + + @Override + protected boolean shouldRegisterInNameSet() { + return false; + } + + @Override + public int damageDropped(int par1) { + return par1; + } + + @Override + public Block setBlockName(String par1Str) { + register(par1Str); + return super.setBlockName(par1Str); + } + + void register(String name) { + GameRegistry.registerBlock(this, ItemBlockWithMetadataAndName.class, name); + } + + @Override + public void getSubBlocks(Item par1, CreativeTabs par2CreativeTabs, List par3List) { + for(int i = 0; i < TYPES; i++) + par3List.add(new ItemStack(par1, 1, i)); + } + + @Override + public void registerBlockIcons(IIconRegister par1IconRegister) { + icons = new IIcon[TYPES]; + for(int i = 0; i < TYPES; i++) + icons[i] = IconHelper.forBlock(par1IconRegister, this, i); + } + + @Override + public IIcon getIcon(int par1, int par2) { + return icons[Math.min(TYPES - 1, par2)]; + } + + @Override + public ItemStack getPickBlock(MovingObjectPosition target, World world, int x, int y, int z) { + int meta = world.getBlockMetadata(x, y, z); + return new ItemStack(this, 1, meta); + } + + @Override + public int getLightValue(IBlockAccess world, int x, int y, int z) { + return world.getBlockMetadata(x, y, z) == 5 ? 12 : 0; + } + + @Override + public LexiconEntry getEntry(World world, int x, int y, int z, EntityPlayer player, ItemStack lexicon) { + int meta = world.getBlockMetadata(x, y, z); + return meta == 0 ? LexiconData.pureDaisy : LexiconData.decorativeBlocks; + } + + @Override + public boolean canSustainLeaves(IBlockAccess world, int x, int y, int z) { + return world.getBlockMetadata(x, y, z) == 0; + } + } diff --git a/src/main/java/vazkii/botania/common/block/BlockManaBomb.java b/src/main/java/vazkii/botania/common/block/BlockManaBomb.java index 536032b65d..5154cd7276 100644 --- a/src/main/java/vazkii/botania/common/block/BlockManaBomb.java +++ b/src/main/java/vazkii/botania/common/block/BlockManaBomb.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jul 25, 2015, 12:24:10 AM (GMT)] */ package vazkii.botania.common.block; @@ -28,31 +28,32 @@ public class BlockManaBomb extends BlockMod implements IManaTrigger, ILexiconable, ICraftAchievement { - public BlockManaBomb() { - super(Material.wood); - setHardness(12.0F); - setStepSound(soundTypeWood); - setBlockName(LibBlockNames.MANA_BOMB); - } + public BlockManaBomb() { + super(Material.wood); + setHardness(12.0F); + setStepSound(soundTypeWood); + setBlockName(LibBlockNames.MANA_BOMB); + } - @Override - public void onBurstCollision(IManaBurst burst, World world, int x, int y, int z) { - if (!burst.isFake() && !world.isRemote) { - world.playAuxSFX(2001, x, y, z, getIdFromBlock(this)); - world.setBlockToAir(x, y, z); - EntityManaStorm storm = new EntityManaStorm(world); - storm.setPosition(x + 0.5, y + 0.5, z + 0.5); - world.spawnEntityInWorld(storm); - } - } + @Override + public void onBurstCollision(IManaBurst burst, World world, int x, int y, int z) { + if(!burst.isFake() && !world.isRemote) { + world.playAuxSFX(2001, x, y, z, getIdFromBlock(this)); + world.setBlockToAir(x, y, z); + EntityManaStorm storm = new EntityManaStorm(world); + storm.setPosition(x + 0.5, y + 0.5, z + 0.5); + world.spawnEntityInWorld(storm); + } + } - @Override - public LexiconEntry getEntry(World world, int x, int y, int z, EntityPlayer player, ItemStack lexicon) { - return LexiconData.manaBomb; - } + @Override + public LexiconEntry getEntry(World world, int x, int y, int z, EntityPlayer player, ItemStack lexicon) { + return LexiconData.manaBomb; + } + + @Override + public Achievement getAchievementOnCraft(ItemStack stack, EntityPlayer player, IInventory matrix) { + return ModAchievements.manaBombIgnite; + } - @Override - public Achievement getAchievementOnCraft(ItemStack stack, EntityPlayer player, IInventory matrix) { - return ModAchievements.manaBombIgnite; - } } diff --git a/src/main/java/vazkii/botania/common/block/BlockMod.java b/src/main/java/vazkii/botania/common/block/BlockMod.java index 7e26d8ee7e..e797d0c8f7 100644 --- a/src/main/java/vazkii/botania/common/block/BlockMod.java +++ b/src/main/java/vazkii/botania/common/block/BlockMod.java @@ -2,17 +2,14 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jan 14, 2014, 5:31:15 PM (GMT)] */ package vazkii.botania.common.block; -import cpw.mods.fml.common.registry.GameRegistry; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; import net.minecraft.block.Block; import net.minecraft.block.material.Material; import net.minecraft.client.renderer.texture.IIconRegister; @@ -21,41 +18,46 @@ import vazkii.botania.common.core.BotaniaCreativeTab; import vazkii.botania.common.item.block.ItemBlockElven; import vazkii.botania.common.item.block.ItemBlockMod; +import cpw.mods.fml.common.registry.GameRegistry; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; public class BlockMod extends Block { - public int originalLight; - - public BlockMod(Material par2Material) { - super(par2Material); - if (registerInCreative()) setCreativeTab(BotaniaCreativeTab.INSTANCE); - } - - @Override - public Block setBlockName(String par1Str) { - if (shouldRegisterInNameSet()) - GameRegistry.registerBlock( - this, this instanceof IElvenItem ? ItemBlockElven.class : ItemBlockMod.class, par1Str); - return super.setBlockName(par1Str); - } - - protected boolean shouldRegisterInNameSet() { - return true; - } - - @Override - public Block setLightLevel(float p_149715_1_) { - originalLight = (int) (p_149715_1_ * 15); - return super.setLightLevel(p_149715_1_); - } - - @Override - @SideOnly(Side.CLIENT) - public void registerBlockIcons(IIconRegister par1IconRegister) { - blockIcon = IconHelper.forBlock(par1IconRegister, this); - } - - boolean registerInCreative() { - return true; - } + public int originalLight; + + public BlockMod(Material par2Material) { + super(par2Material); + if(registerInCreative()) + setCreativeTab(BotaniaCreativeTab.INSTANCE); + } + + @Override + public Block setBlockName(String par1Str) { + if(shouldRegisterInNameSet()) + GameRegistry.registerBlock(this, this instanceof IElvenItem ? ItemBlockElven.class : ItemBlockMod.class, par1Str); + return super.setBlockName(par1Str); + } + + protected boolean shouldRegisterInNameSet() { + return true; + } + + @Override + public Block setLightLevel(float p_149715_1_) { + originalLight = (int) (p_149715_1_ * 15); + return super.setLightLevel(p_149715_1_); + } + + @Override + @SideOnly(Side.CLIENT) + public void registerBlockIcons(IIconRegister par1IconRegister) { + blockIcon = IconHelper.forBlock(par1IconRegister, this); + } + + boolean registerInCreative() { + return true; + } + + } diff --git a/src/main/java/vazkii/botania/common/block/BlockModContainer.java b/src/main/java/vazkii/botania/common/block/BlockModContainer.java index 6de4e257ac..d1ff8357e7 100644 --- a/src/main/java/vazkii/botania/common/block/BlockModContainer.java +++ b/src/main/java/vazkii/botania/common/block/BlockModContainer.java @@ -2,17 +2,14 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jan 14, 2014, 5:32:55 PM (GMT)] */ package vazkii.botania.common.block; -import cpw.mods.fml.common.registry.GameRegistry; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; import net.minecraft.block.Block; import net.minecraft.block.BlockContainer; import net.minecraft.block.material.Material; @@ -22,42 +19,48 @@ import vazkii.botania.client.core.helper.IconHelper; import vazkii.botania.common.core.BotaniaCreativeTab; import vazkii.botania.common.item.block.ItemBlockMod; +import cpw.mods.fml.common.registry.GameRegistry; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; public abstract class BlockModContainer extends BlockContainer { - public int originalLight; - - protected BlockModContainer(Material par2Material) { - super(par2Material); - if (registerInCreative()) setCreativeTab(BotaniaCreativeTab.INSTANCE); - } - - @Override - public Block setBlockName(String par1Str) { - if (shouldRegisterInNameSet()) GameRegistry.registerBlock(this, ItemBlockMod.class, par1Str); - return super.setBlockName(par1Str); - } - - protected boolean shouldRegisterInNameSet() { - return true; - } - - @Override - public Block setLightLevel(float p_149715_1_) { - originalLight = (int) (p_149715_1_ * 15); - return super.setLightLevel(p_149715_1_); - } - - @Override - @SideOnly(Side.CLIENT) - public void registerBlockIcons(IIconRegister par1IconRegister) { - blockIcon = IconHelper.forBlock(par1IconRegister, this); - } - - public boolean registerInCreative() { - return true; - } - - @Override - public abstract T createNewTileEntity(World world, int meta); -} + public int originalLight; + + protected BlockModContainer(Material par2Material) { + super(par2Material); + if(registerInCreative()) + setCreativeTab(BotaniaCreativeTab.INSTANCE); + } + + @Override + public Block setBlockName(String par1Str) { + if(shouldRegisterInNameSet()) + GameRegistry.registerBlock(this, ItemBlockMod.class, par1Str); + return super.setBlockName(par1Str); + } + + protected boolean shouldRegisterInNameSet() { + return true; + } + + @Override + public Block setLightLevel(float p_149715_1_) { + originalLight = (int) (p_149715_1_ * 15); + return super.setLightLevel(p_149715_1_); + } + + @Override + @SideOnly(Side.CLIENT) + public void registerBlockIcons(IIconRegister par1IconRegister) { + blockIcon = IconHelper.forBlock(par1IconRegister, this); + } + + public boolean registerInCreative() { + return true; + } + + @Override + public abstract T createNewTileEntity(World world, int meta); + +} \ No newline at end of file diff --git a/src/main/java/vazkii/botania/common/block/BlockModDoubleFlower.java b/src/main/java/vazkii/botania/common/block/BlockModDoubleFlower.java index 32575b2eab..bdbe1ae818 100644 --- a/src/main/java/vazkii/botania/common/block/BlockModDoubleFlower.java +++ b/src/main/java/vazkii/botania/common/block/BlockModDoubleFlower.java @@ -2,20 +2,18 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Mar 22, 2015, 7:46:55 PM (GMT)] */ package vazkii.botania.common.block; -import cpw.mods.fml.common.registry.GameRegistry; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; import java.util.ArrayList; import java.util.List; import java.util.Random; + import net.minecraft.block.Block; import net.minecraft.block.BlockDoublePlant; import net.minecraft.client.renderer.texture.IIconRegister; @@ -43,255 +41,202 @@ import vazkii.botania.common.item.block.ItemBlockWithMetadataAndName; import vazkii.botania.common.lexicon.LexiconData; import vazkii.botania.common.lib.LibBlockNames; +import cpw.mods.fml.common.registry.GameRegistry; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; public class BlockModDoubleFlower extends BlockDoublePlant implements ILexiconable { - private static final int COUNT = 8; - - IIcon[] doublePlantTopIcons, doublePlantBottomIcons; - IIcon[] doublePlantTopIconsAlt, doublePlantBottomIconsAlt; - - final int offset; - - public BlockModDoubleFlower(boolean second) { - offset = second ? 8 : 0; - setBlockName(LibBlockNames.DOUBLE_FLOWER + (second ? 2 : 1)); - setHardness(0F); - setStepSound(soundTypeGrass); - setTickRandomly(false); - setCreativeTab(BotaniaCreativeTab.INSTANCE); - } - - @Override - public Block setBlockName(String par1Str) { - if (!par1Str.equals("doublePlant")) - GameRegistry.registerBlock(this, ItemBlockWithMetadataAndName.class, par1Str); - return super.setBlockName(par1Str); - } - - @Override - public Item getItemDropped(int p_149650_1_, Random p_149650_2_, int p_149650_3_) { - return null; - } - - @Override - public int damageDropped(int p_149692_1_) { - return p_149692_1_ & 7; - } - - @Override - @SideOnly(Side.CLIENT) - public IIcon func_149888_a(boolean top, int index) { - return (ConfigHandler.altFlowerTextures - ? top ? doublePlantTopIconsAlt : doublePlantBottomIconsAlt - : top ? doublePlantTopIcons : doublePlantBottomIcons) - [index & 7]; - } - - @Override - public void func_149889_c( - World p_149889_1_, int p_149889_2_, int p_149889_3_, int p_149889_4_, int p_149889_5_, int p_149889_6_) { - p_149889_1_.setBlock(p_149889_2_, p_149889_3_, p_149889_4_, this, p_149889_5_, p_149889_6_); - p_149889_1_.setBlock(p_149889_2_, p_149889_3_ + 1, p_149889_4_, this, p_149889_5_ | 8, p_149889_6_); - } - - @Override - public void onBlockPlacedBy( - World p_149689_1_, - int p_149689_2_, - int p_149689_3_, - int p_149689_4_, - EntityLivingBase p_149689_5_, - ItemStack p_149689_6_) { - p_149689_1_.setBlock(p_149689_2_, p_149689_3_ + 1, p_149689_4_, this, p_149689_6_.getItemDamage() | 8, 2); - } - - @Override - public boolean func_149851_a(World world, int x, int y, int z, boolean fuckifiknow) { - return false; - } - - @Override - public void harvestBlock( - World p_149636_1_, - EntityPlayer p_149636_2_, - int p_149636_3_, - int p_149636_4_, - int p_149636_5_, - int p_149636_6_) { - if (p_149636_1_.isRemote - || p_149636_2_.getCurrentEquippedItem() == null - || p_149636_2_.getCurrentEquippedItem().getItem() != Items.shears - || func_149887_c(p_149636_6_)) - harvestBlockCopy(p_149636_1_, p_149636_2_, p_149636_3_, p_149636_4_, p_149636_5_, p_149636_6_); - } - - // This is how I get around encapsulation - public void harvestBlockCopy( - World p_149636_1_, - EntityPlayer p_149636_2_, - int p_149636_3_, - int p_149636_4_, - int p_149636_5_, - int p_149636_6_) { - p_149636_2_.addStat(StatList.mineBlockStatArray[getIdFromBlock(this)], 1); - p_149636_2_.addExhaustion(0.025F); - - if (this.canSilkHarvest(p_149636_1_, p_149636_2_, p_149636_3_, p_149636_4_, p_149636_5_, p_149636_6_) - && EnchantmentHelper.getSilkTouchModifier(p_149636_2_)) { - ArrayList items = new ArrayList(); - ItemStack itemstack = createStackedBlock(p_149636_6_); - - if (itemstack != null) items.add(itemstack); - - ForgeEventFactory.fireBlockHarvesting( - items, - p_149636_1_, - this, - p_149636_3_, - p_149636_4_, - p_149636_5_, - p_149636_6_, - 0, - 1.0f, - true, - p_149636_2_); - for (ItemStack is : items) this.dropBlockAsItem(p_149636_1_, p_149636_3_, p_149636_4_, p_149636_5_, is); - } else { - harvesters.set(p_149636_2_); - int i1 = EnchantmentHelper.getFortuneModifier(p_149636_2_); - this.dropBlockAsItem(p_149636_1_, p_149636_3_, p_149636_4_, p_149636_5_, p_149636_6_, i1); - harvesters.set(null); - } - } - - @Override - public void onBlockHarvested( - World p_149681_1_, - int p_149681_2_, - int p_149681_3_, - int p_149681_4_, - int p_149681_5_, - EntityPlayer p_149681_6_) { - if (func_149887_c(p_149681_5_)) { - if (p_149681_1_.getBlock(p_149681_2_, p_149681_3_ - 1, p_149681_4_) == this) { - if (!p_149681_6_.capabilities.isCreativeMode) { - int i1 = p_149681_1_.getBlockMetadata(p_149681_2_, p_149681_3_ - 1, p_149681_4_); - int j1 = func_149890_d(i1); - - if (j1 != 3 && j1 != 2) - ; - // p_149681_1_.func_147480_a(p_149681_2_, p_149681_3_ - 1, p_149681_4_, true); - else { - /*if (!p_149681_1_.isRemote && p_149681_6_.getCurrentEquippedItem() != null && p_149681_6_.getCurrentEquippedItem().getItem() == Items.shears) + private static final int COUNT = 8; + + IIcon[] doublePlantTopIcons, doublePlantBottomIcons; + IIcon[] doublePlantTopIconsAlt, doublePlantBottomIconsAlt; + + final int offset; + + public BlockModDoubleFlower(boolean second) { + offset = second ? 8 : 0; + setBlockName(LibBlockNames.DOUBLE_FLOWER + (second ? 2 : 1)); + setHardness(0F); + setStepSound(soundTypeGrass); + setTickRandomly(false); + setCreativeTab(BotaniaCreativeTab.INSTANCE); + } + + @Override + public Block setBlockName(String par1Str) { + if(!par1Str.equals("doublePlant")) + GameRegistry.registerBlock(this, ItemBlockWithMetadataAndName.class, par1Str); + return super.setBlockName(par1Str); + } + + @Override + public Item getItemDropped(int p_149650_1_, Random p_149650_2_, int p_149650_3_) { + return null; + } + + @Override + public int damageDropped(int p_149692_1_) { + return p_149692_1_ & 7; + } + + @Override + @SideOnly(Side.CLIENT) + public IIcon func_149888_a(boolean top, int index) { + return (ConfigHandler.altFlowerTextures ? top ? doublePlantTopIconsAlt : doublePlantBottomIconsAlt : top ? doublePlantTopIcons : doublePlantBottomIcons)[index & 7]; + } + + @Override + public void func_149889_c(World p_149889_1_, int p_149889_2_, int p_149889_3_, int p_149889_4_, int p_149889_5_, int p_149889_6_) { + p_149889_1_.setBlock(p_149889_2_, p_149889_3_, p_149889_4_, this, p_149889_5_, p_149889_6_); + p_149889_1_.setBlock(p_149889_2_, p_149889_3_ + 1, p_149889_4_, this, p_149889_5_ | 8, p_149889_6_); + } + + @Override + public void onBlockPlacedBy(World p_149689_1_, int p_149689_2_, int p_149689_3_, int p_149689_4_, EntityLivingBase p_149689_5_, ItemStack p_149689_6_) { + p_149689_1_.setBlock(p_149689_2_, p_149689_3_ + 1, p_149689_4_, this, p_149689_6_.getItemDamage() | 8, 2); + } + + @Override + public boolean func_149851_a(World world, int x, int y, int z, boolean fuckifiknow) { + return false; + } + + @Override + public void harvestBlock(World p_149636_1_, EntityPlayer p_149636_2_, int p_149636_3_, int p_149636_4_, int p_149636_5_, int p_149636_6_) { + if(p_149636_1_.isRemote || p_149636_2_.getCurrentEquippedItem() == null || p_149636_2_.getCurrentEquippedItem().getItem() != Items.shears || func_149887_c(p_149636_6_)) + harvestBlockCopy(p_149636_1_, p_149636_2_, p_149636_3_, p_149636_4_, p_149636_5_, p_149636_6_); + } + + // This is how I get around encapsulation + public void harvestBlockCopy(World p_149636_1_, EntityPlayer p_149636_2_, int p_149636_3_, int p_149636_4_, int p_149636_5_, int p_149636_6_) { + p_149636_2_.addStat(StatList.mineBlockStatArray[getIdFromBlock(this)], 1); + p_149636_2_.addExhaustion(0.025F); + + if(this.canSilkHarvest(p_149636_1_, p_149636_2_, p_149636_3_, p_149636_4_, p_149636_5_, p_149636_6_) && EnchantmentHelper.getSilkTouchModifier(p_149636_2_)) { + ArrayList items = new ArrayList(); + ItemStack itemstack = createStackedBlock(p_149636_6_); + + if(itemstack != null) + items.add(itemstack); + + ForgeEventFactory.fireBlockHarvesting(items, p_149636_1_, this, p_149636_3_, p_149636_4_, p_149636_5_, p_149636_6_, 0, 1.0f, true, p_149636_2_); + for(ItemStack is : items) + this.dropBlockAsItem(p_149636_1_, p_149636_3_, p_149636_4_, p_149636_5_, is); + } else { + harvesters.set(p_149636_2_); + int i1 = EnchantmentHelper.getFortuneModifier(p_149636_2_); + this.dropBlockAsItem(p_149636_1_, p_149636_3_, p_149636_4_, p_149636_5_, p_149636_6_, i1); + harvesters.set(null); + } + } + + @Override + public void onBlockHarvested(World p_149681_1_, int p_149681_2_, int p_149681_3_, int p_149681_4_, int p_149681_5_, EntityPlayer p_149681_6_) { + if(func_149887_c(p_149681_5_)) { + if(p_149681_1_.getBlock(p_149681_2_, p_149681_3_ - 1, p_149681_4_) == this) { + if(!p_149681_6_.capabilities.isCreativeMode) { + int i1 = p_149681_1_.getBlockMetadata(p_149681_2_, p_149681_3_ - 1, p_149681_4_); + int j1 = func_149890_d(i1); + + if(j1 != 3 && j1 != 2); + //p_149681_1_.func_147480_a(p_149681_2_, p_149681_3_ - 1, p_149681_4_, true); + else { + /*if (!p_149681_1_.isRemote && p_149681_6_.getCurrentEquippedItem() != null && p_149681_6_.getCurrentEquippedItem().getItem() == Items.shears) { this.func_149886_b(p_149681_1_, p_149681_2_, p_149681_3_, p_149681_4_, i1, p_149681_6_); }*/ - p_149681_1_.setBlockToAir(p_149681_2_, p_149681_3_ - 1, p_149681_4_); - } - } else p_149681_1_.setBlockToAir(p_149681_2_, p_149681_3_ - 1, p_149681_4_); - } - } else if (p_149681_6_.capabilities.isCreativeMode - && p_149681_1_.getBlock(p_149681_2_, p_149681_3_ + 1, p_149681_4_) == this) - p_149681_1_.setBlock(p_149681_2_, p_149681_3_ + 1, p_149681_4_, Blocks.air, 0, 2); - - // super.onBlockHarvested(p_149681_1_, p_149681_2_, p_149681_3_, p_149681_4_, p_149681_5_, p_149681_6_); - } - - @Override - public boolean isShearable(ItemStack item, IBlockAccess world, int x, int y, int z) { - return true; - } - - @Override - public ArrayList onSheared(ItemStack item, IBlockAccess world, int x, int y, int z, int fortune) { - ArrayList ret = new ArrayList(); - ret.add(new ItemStack(this, 1, world.getBlockMetadata(x, y, z) & 7)); - return ret; - } - - @Override - public ArrayList getDrops(World world, int x, int y, int z, int meta, int fortune) { - return new ArrayList(); - } - - @Override - public IIcon getIcon(int p_149691_1_, int p_149691_2_) { - boolean top = func_149887_c(p_149691_2_); - return (ConfigHandler.altFlowerTextures - ? top ? doublePlantTopIconsAlt : doublePlantBottomIconsAlt - : top ? doublePlantTopIcons : doublePlantBottomIcons) - [p_149691_2_ & 7]; - } - - @Override - public IIcon getIcon(IBlockAccess world, int x, int y, int z, int side) { - int meta = world.getBlockMetadata(x, y, z); - boolean top = func_149887_c(meta); - if (top) meta = world.getBlockMetadata(x, y - 1, z); - - return (ConfigHandler.altFlowerTextures - ? top ? doublePlantBottomIconsAlt : doublePlantTopIconsAlt - : top ? doublePlantBottomIcons : doublePlantTopIcons) - [meta & 7]; - } - - @Override - public void registerBlockIcons(IIconRegister register) { - doublePlantTopIcons = new IIcon[COUNT]; - doublePlantBottomIcons = new IIcon[COUNT]; - doublePlantTopIconsAlt = new IIcon[COUNT]; - doublePlantBottomIconsAlt = new IIcon[COUNT]; - for (int i = 0; i < COUNT; i++) { - int off = offset(i); - doublePlantTopIcons[i] = IconHelper.forName(register, "flower" + off + "Tall0"); - doublePlantBottomIcons[i] = IconHelper.forName(register, "flower" + off + "Tall1"); - doublePlantTopIconsAlt[i] = IconHelper.forName(register, "flower" + off + "Tall0", BlockModFlower.ALT_DIR); - doublePlantBottomIconsAlt[i] = - IconHelper.forName(register, "flower" + off + "Tall1", BlockModFlower.ALT_DIR); - } - } - - @Override - public int colorMultiplier(IBlockAccess blockAccess, int x, int y, int z) { - return 16777215; - } - - @Override - public void getSubBlocks(Item p_149666_1_, CreativeTabs p_149666_2_, List p_149666_3_) { - for (int i = 0; i < COUNT; ++i) p_149666_3_.add(new ItemStack(p_149666_1_, 1, i)); - } - - @Override - public int getRenderType() { - return LibRenderIDs.idDoubleFlower; - } - - @Override - public void randomDisplayTick(World par1World, int par2, int par3, int par4, Random par5Random) { - int meta = par1World.getBlockMetadata(par2, par3, par4); - float[] color = EntitySheep.fleeceColorTable[offset(meta & 7)]; - - if (par5Random.nextDouble() < ConfigHandler.flowerParticleFrequency) - Botania.proxy.sparkleFX( - par1World, - par2 + 0.3 + par5Random.nextFloat() * 0.5, - par3 + 0.5 + par5Random.nextFloat() * 0.5, - par4 + 0.3 + par5Random.nextFloat() * 0.5, - color[0], - color[1], - color[2], - par5Random.nextFloat(), - 5); - } - - @Override - public LexiconEntry getEntry(World world, int x, int y, int z, EntityPlayer player, ItemStack lexicon) { - return LexiconData.flowers; - } - - int offset(int meta) { - return meta + offset; - } + p_149681_1_.setBlockToAir(p_149681_2_, p_149681_3_ - 1, p_149681_4_); + } + } else p_149681_1_.setBlockToAir(p_149681_2_, p_149681_3_ - 1, p_149681_4_); + } + } else if(p_149681_6_.capabilities.isCreativeMode && p_149681_1_.getBlock(p_149681_2_, p_149681_3_ + 1, p_149681_4_) == this) + p_149681_1_.setBlock(p_149681_2_, p_149681_3_ + 1, p_149681_4_, Blocks.air, 0, 2); + + //super.onBlockHarvested(p_149681_1_, p_149681_2_, p_149681_3_, p_149681_4_, p_149681_5_, p_149681_6_); + } + + @Override + public boolean isShearable(ItemStack item, IBlockAccess world, int x, int y, int z) { + return true; + } + + @Override + public ArrayList onSheared(ItemStack item, IBlockAccess world, int x, int y, int z, int fortune) { + ArrayList ret = new ArrayList(); + ret.add(new ItemStack(this, 1, world.getBlockMetadata(x, y, z) & 7)); + return ret; + } + + @Override + public ArrayList getDrops(World world, int x, int y, int z, int meta, int fortune) { + return new ArrayList(); + } + + @Override + public IIcon getIcon(int p_149691_1_, int p_149691_2_) { + boolean top = func_149887_c(p_149691_2_); + return (ConfigHandler.altFlowerTextures ? top ? doublePlantTopIconsAlt : doublePlantBottomIconsAlt : top ? doublePlantTopIcons : doublePlantBottomIcons)[p_149691_2_ & 7]; + } + + @Override + public IIcon getIcon(IBlockAccess world, int x, int y, int z, int side) { + int meta = world.getBlockMetadata(x, y, z); + boolean top = func_149887_c(meta); + if(top) + meta = world.getBlockMetadata(x, y - 1, z); + + return (ConfigHandler.altFlowerTextures ? top ? doublePlantBottomIconsAlt : doublePlantTopIconsAlt : top ? doublePlantBottomIcons : doublePlantTopIcons)[meta & 7]; + } + + @Override + public void registerBlockIcons(IIconRegister register) { + doublePlantTopIcons = new IIcon[COUNT]; + doublePlantBottomIcons = new IIcon[COUNT]; + doublePlantTopIconsAlt = new IIcon[COUNT]; + doublePlantBottomIconsAlt = new IIcon[COUNT]; + for(int i = 0; i < COUNT; i++) { + int off = offset(i); + doublePlantTopIcons[i] = IconHelper.forName(register, "flower" + off + "Tall0"); + doublePlantBottomIcons[i] = IconHelper.forName(register, "flower" + off + "Tall1"); + doublePlantTopIconsAlt[i] = IconHelper.forName(register, "flower" + off + "Tall0", BlockModFlower.ALT_DIR); + doublePlantBottomIconsAlt[i] = IconHelper.forName(register, "flower" + off + "Tall1", BlockModFlower.ALT_DIR); + } + } + + @Override + public int colorMultiplier(IBlockAccess blockAccess, int x, int y, int z) { + return 16777215; + } + + @Override + public void getSubBlocks(Item p_149666_1_, CreativeTabs p_149666_2_, List p_149666_3_) { + for(int i = 0; i < COUNT; ++i) + p_149666_3_.add(new ItemStack(p_149666_1_, 1, i)); + } + + @Override + public int getRenderType() { + return LibRenderIDs.idDoubleFlower; + } + + @Override + public void randomDisplayTick(World par1World, int par2, int par3, int par4, Random par5Random) { + int meta = par1World.getBlockMetadata(par2, par3, par4); + float[] color = EntitySheep.fleeceColorTable[offset(meta & 7)]; + + if(par5Random.nextDouble() < ConfigHandler.flowerParticleFrequency) + Botania.proxy.sparkleFX(par1World, par2 + 0.3 + par5Random.nextFloat() * 0.5, par3 + 0.5 + par5Random.nextFloat() * 0.5, par4 + 0.3 + par5Random.nextFloat() * 0.5, color[0], color[1], color[2], par5Random.nextFloat(), 5); + } + + @Override + public LexiconEntry getEntry(World world, int x, int y, int z, EntityPlayer player, ItemStack lexicon) { + return LexiconData.flowers; + } + + int offset(int meta) { + return meta + offset; + } + } diff --git a/src/main/java/vazkii/botania/common/block/BlockModFlower.java b/src/main/java/vazkii/botania/common/block/BlockModFlower.java index 2f3794d85e..084e217c74 100644 --- a/src/main/java/vazkii/botania/common/block/BlockModFlower.java +++ b/src/main/java/vazkii/botania/common/block/BlockModFlower.java @@ -2,19 +2,17 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jan 16, 2014, 5:50:31 PM (GMT)] */ package vazkii.botania.common.block; -import cpw.mods.fml.common.registry.GameRegistry; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; import java.util.List; import java.util.Random; + import net.minecraft.block.Block; import net.minecraft.block.BlockFlower; import net.minecraft.block.IGrowable; @@ -40,126 +38,122 @@ import vazkii.botania.common.item.block.ItemBlockWithMetadataAndName; import vazkii.botania.common.lexicon.LexiconData; import vazkii.botania.common.lib.LibBlockNames; +import cpw.mods.fml.common.registry.GameRegistry; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; public class BlockModFlower extends BlockFlower implements ILexiconable, IPickupAchievement, IGrowable { - public static IIcon[] icons; - public static IIcon[] iconsAlt; - - public int originalLight; - - public static final String ALT_DIR = "alt"; - - protected BlockModFlower() { - this(LibBlockNames.FLOWER); - } - - protected BlockModFlower(String name) { - super(0); - setBlockName(name); - setHardness(0F); - setStepSound(soundTypeGrass); - setBlockBounds(0.3F, 0.0F, 0.3F, 0.8F, 1, 0.8F); - setTickRandomly(false); - setCreativeTab(registerInCreative() ? BotaniaCreativeTab.INSTANCE : null); - } - - public boolean registerInCreative() { - return true; - } - - @Override - public void getSubBlocks(Item par1, CreativeTabs par2CreativeTabs, List par3List) { - for (int i = 0; i < 16; i++) par3List.add(new ItemStack(par1, 1, i)); - } - - @Override - public Block setBlockName(String par1Str) { - GameRegistry.registerBlock(this, ItemBlockWithMetadataAndName.class, par1Str); - return super.setBlockName(par1Str); - } - - @Override - @SideOnly(Side.CLIENT) - public void registerBlockIcons(IIconRegister par1IconRegister) { - icons = new IIcon[17]; - iconsAlt = new IIcon[17]; - - for (int i = 0; i < icons.length; i++) { - icons[i] = IconHelper.forBlock(par1IconRegister, this, i); - iconsAlt[i] = IconHelper.forBlock(par1IconRegister, this, i, ALT_DIR); - } - } - - @Override - public Block setLightLevel(float p_149715_1_) { - originalLight = (int) (p_149715_1_ * 15); - return super.setLightLevel(p_149715_1_); - } - - @Override - public IIcon getIcon(int par1, int par2) { - return (ConfigHandler.altFlowerTextures ? iconsAlt : icons)[Math.min(icons.length - 1, par2)]; - } - - @Override - public int getRenderType() { - return LibRenderIDs.idSpecialFlower; - } - - @Override - public int damageDropped(int par1) { - return par1; - } - - @Override - public void randomDisplayTick(World par1World, int par2, int par3, int par4, Random par5Random) { - int meta = par1World.getBlockMetadata(par2, par3, par4); - float[] color = EntitySheep.fleeceColorTable[meta]; - - if (par5Random.nextDouble() < ConfigHandler.flowerParticleFrequency) - Botania.proxy.sparkleFX( - par1World, - par2 + 0.3 + par5Random.nextFloat() * 0.5, - par3 + 0.5 + par5Random.nextFloat() * 0.5, - par4 + 0.3 + par5Random.nextFloat() * 0.5, - color[0], - color[1], - color[2], - par5Random.nextFloat(), - 5); - } - - @Override - public LexiconEntry getEntry(World world, int x, int y, int z, EntityPlayer player, ItemStack lexicon) { - return LexiconData.flowers; - } - - @Override - public Achievement getAchievementOnPickup(ItemStack stack, EntityPlayer player, EntityItem item) { - return ModAchievements.flowerPickup; - } - - @Override - public boolean func_149851_a(World world, int x, int y, int z, boolean fuckifiknow) { - return world.isAirBlock(x, y + 1, z); - } - - @Override - public boolean func_149852_a(World world, Random rand, int x, int y, int z) { - return func_149851_a(world, x, y, z, false); - } - - @Override - public void func_149853_b(World world, Random rand, int x, int y, int z) { - int meta = world.getBlockMetadata(x, y, z); - placeDoubleFlower(world, x, y, z, meta, 1 | 2); - } - - public static void placeDoubleFlower(World world, int x, int y, int z, int meta, int flags) { - Block flower = meta >= 8 ? ModBlocks.doubleFlower2 : ModBlocks.doubleFlower1; - int placeMeta = meta & 7; - world.setBlock(x, y, z, flower, placeMeta, flags); - world.setBlock(x, y + 1, z, flower, placeMeta | 8, flags); - } + public static IIcon[] icons; + public static IIcon[] iconsAlt; + + public int originalLight; + + public static final String ALT_DIR = "alt"; + + protected BlockModFlower() { + this(LibBlockNames.FLOWER); + } + + protected BlockModFlower(String name) { + super(0); + setBlockName(name); + setHardness(0F); + setStepSound(soundTypeGrass); + setBlockBounds(0.3F, 0.0F, 0.3F, 0.8F, 1, 0.8F); + setTickRandomly(false); + setCreativeTab(registerInCreative() ? BotaniaCreativeTab.INSTANCE : null); + } + + public boolean registerInCreative() { + return true; + } + + @Override + public void getSubBlocks(Item par1, CreativeTabs par2CreativeTabs, List par3List) { + for(int i = 0; i < 16; i++) + par3List.add(new ItemStack(par1, 1, i)); + } + + @Override + public Block setBlockName(String par1Str) { + GameRegistry.registerBlock(this, ItemBlockWithMetadataAndName.class, par1Str); + return super.setBlockName(par1Str); + } + + @Override + @SideOnly(Side.CLIENT) + public void registerBlockIcons(IIconRegister par1IconRegister) { + icons = new IIcon[17]; + iconsAlt = new IIcon[17]; + + for(int i = 0; i < icons.length; i++) { + icons[i] = IconHelper.forBlock(par1IconRegister, this, i); + iconsAlt[i] = IconHelper.forBlock(par1IconRegister, this, i, ALT_DIR); + } + } + + @Override + public Block setLightLevel(float p_149715_1_) { + originalLight = (int) (p_149715_1_ * 15); + return super.setLightLevel(p_149715_1_); + } + + @Override + public IIcon getIcon(int par1, int par2) { + return (ConfigHandler.altFlowerTextures ? iconsAlt : icons)[Math.min(icons.length - 1, par2)]; + } + + @Override + public int getRenderType() { + return LibRenderIDs.idSpecialFlower; + } + + @Override + public int damageDropped(int par1) { + return par1; + } + + @Override + public void randomDisplayTick(World par1World, int par2, int par3, int par4, Random par5Random) { + int meta = par1World.getBlockMetadata(par2, par3, par4); + float[] color = EntitySheep.fleeceColorTable[meta]; + + if(par5Random.nextDouble() < ConfigHandler.flowerParticleFrequency) + Botania.proxy.sparkleFX(par1World, par2 + 0.3 + par5Random.nextFloat() * 0.5, par3 + 0.5 + par5Random.nextFloat() * 0.5, par4 + 0.3 + par5Random.nextFloat() * 0.5, color[0], color[1], color[2], par5Random.nextFloat(), 5); + } + + @Override + public LexiconEntry getEntry(World world, int x, int y, int z, EntityPlayer player, ItemStack lexicon) { + return LexiconData.flowers; + } + + @Override + public Achievement getAchievementOnPickup(ItemStack stack, EntityPlayer player, EntityItem item) { + return ModAchievements.flowerPickup; + } + + @Override + public boolean func_149851_a(World world, int x, int y, int z, boolean fuckifiknow) { + return world.isAirBlock(x, y + 1, z); + } + + @Override + public boolean func_149852_a(World world, Random rand, int x, int y, int z) { + return func_149851_a(world, x, y, z, false); + } + + @Override + public void func_149853_b(World world, Random rand, int x, int y, int z) { + int meta = world.getBlockMetadata(x, y, z); + placeDoubleFlower(world, x, y, z, meta, 1 | 2); + } + + public static void placeDoubleFlower(World world, int x, int y, int z, int meta, int flags) { + Block flower = meta >= 8 ? ModBlocks.doubleFlower2 : ModBlocks.doubleFlower1; + int placeMeta = meta & 7; + world.setBlock(x, y, z, flower, placeMeta, flags); + world.setBlock(x, y + 1, z, flower, placeMeta | 8, flags); + } + } diff --git a/src/main/java/vazkii/botania/common/block/BlockOpenCrate.java b/src/main/java/vazkii/botania/common/block/BlockOpenCrate.java index d8aebe5a9d..be6647ce85 100644 --- a/src/main/java/vazkii/botania/common/block/BlockOpenCrate.java +++ b/src/main/java/vazkii/botania/common/block/BlockOpenCrate.java @@ -2,17 +2,17 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [May 4, 2014, 12:29:56 PM (GMT)] */ package vazkii.botania.common.block; -import cpw.mods.fml.common.registry.GameRegistry; import java.util.List; import java.util.Random; + import net.minecraft.block.Block; import net.minecraft.block.material.Material; import net.minecraft.client.Minecraft; @@ -30,8 +30,10 @@ import net.minecraft.util.IIcon; import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; + import org.lwjgl.opengl.GL11; import org.lwjgl.opengl.GL12; + import vazkii.botania.api.lexicon.ILexiconable; import vazkii.botania.api.lexicon.LexiconEntry; import vazkii.botania.api.wand.IWandHUD; @@ -43,179 +45,177 @@ import vazkii.botania.common.item.block.ItemBlockWithMetadataAndName; import vazkii.botania.common.lexicon.LexiconData; import vazkii.botania.common.lib.LibBlockNames; +import cpw.mods.fml.common.registry.GameRegistry; public class BlockOpenCrate extends BlockModContainer implements ILexiconable, IWandable, IWandHUD { - IIcon iconSide; - IIcon iconBottom; - IIcon iconSideCraft; - IIcon iconBottomCraft; - - IIcon[] sidePatternIcons; - - Random random; - - private static final int SUBTYPES = 2; - - public BlockOpenCrate() { - super(Material.wood); - setHardness(2.0F); - setStepSound(soundTypeWood); - setBlockName(LibBlockNames.OPEN_CRATE); - - random = new Random(); - } - - @Override - protected boolean shouldRegisterInNameSet() { - return false; - } - - @Override - public Block setBlockName(String par1Str) { - GameRegistry.registerBlock(this, ItemBlockWithMetadataAndName.class, par1Str); - return super.setBlockName(par1Str); - } - - @Override - public void getSubBlocks(Item par1, CreativeTabs par2CreativeTabs, List par3List) { - for (int i = 0; i < SUBTYPES; i++) par3List.add(new ItemStack(par1, 1, i)); - } - - @Override - public int damageDropped(int meta) { - return meta; - } - - @Override - public boolean hasComparatorInputOverride() { - return true; - } - - @Override - public int getComparatorInputOverride(World par1World, int par2, int par3, int par4, int par5) { - TileOpenCrate crate = (TileOpenCrate) par1World.getTileEntity(par2, par3, par4); - return crate.getSignal(); - } - - @Override - public void breakBlock(World par1World, int par2, int par3, int par4, Block par5, int par6) { - TileSimpleInventory inv = (TileSimpleInventory) par1World.getTileEntity(par2, par3, par4); - - if (inv != null) { - for (int j1 = 0; j1 < inv.getSizeInventory(); ++j1) { - ItemStack itemstack = inv.getStackInSlot(j1); - - if (itemstack != null) { - float f = random.nextFloat() * 0.8F + 0.1F; - float f1 = random.nextFloat() * 0.8F + 0.1F; - EntityItem entityitem; - - for (float f2 = random.nextFloat() * 0.8F + 0.1F; - itemstack.stackSize > 0; - par1World.spawnEntityInWorld(entityitem)) { - int k1 = random.nextInt(21) + 10; - - if (k1 > itemstack.stackSize) k1 = itemstack.stackSize; - - itemstack.stackSize -= k1; - entityitem = new EntityItem( - par1World, - par2 + f, - par3 + f1, - par4 + f2, - new ItemStack(itemstack.getItem(), k1, itemstack.getItemDamage())); - float f3 = 0.05F; - entityitem.motionX = (float) random.nextGaussian() * f3; - entityitem.motionY = (float) random.nextGaussian() * f3 + 0.2F; - entityitem.motionZ = (float) random.nextGaussian() * f3; - - if (itemstack.hasTagCompound()) - entityitem.getEntityItem().setTagCompound((NBTTagCompound) - itemstack.getTagCompound().copy()); - } - } - } - - par1World.func_147453_f(par2, par3, par4, par5); - } - - super.breakBlock(par1World, par2, par3, par4, par5, par6); - } - - @Override - public void registerBlockIcons(IIconRegister par1IconRegister) { - iconSide = IconHelper.forBlock(par1IconRegister, this, 0); - iconBottom = IconHelper.forBlock(par1IconRegister, this, 1); - iconSideCraft = IconHelper.forBlock(par1IconRegister, this, 2); - iconBottomCraft = IconHelper.forBlock(par1IconRegister, this, 3); - - sidePatternIcons = new IIcon[TileCraftCrate.PATTERNS.length]; - for (int i = 0; i < sidePatternIcons.length; i++) - sidePatternIcons[i] = IconHelper.forName(par1IconRegister, "ocPattern" + i); - } - - @Override - public IIcon getIcon(int side, int meta) { - return meta == 0 ? side == 0 ? iconBottom : iconSide : side == 0 ? iconBottomCraft : iconSideCraft; - } - - @Override - public IIcon getIcon(IBlockAccess world, int x, int y, int z, int side) { - TileEntity tile = world.getTileEntity(x, y, z); - if (tile != null && tile instanceof TileCraftCrate && ((TileCraftCrate) tile).pattern != -1 && side != 0) - return sidePatternIcons[((TileCraftCrate) tile).pattern]; - - return super.getIcon(world, x, y, z, side); - } - - @Override - public TileEntity createNewTileEntity(World world, int meta) { - return meta == 0 ? new TileOpenCrate() : new TileCraftCrate(); - } - - @Override - public LexiconEntry getEntry(World world, int x, int y, int z, EntityPlayer player, ItemStack lexicon) { - return world.getBlockMetadata(x, y, z) == 0 ? LexiconData.openCrate : LexiconData.craftCrate; - } - - @Override - public boolean onUsedByWand(EntityPlayer player, ItemStack stack, World world, int x, int y, int z, int side) { - TileOpenCrate crate = (TileOpenCrate) world.getTileEntity(x, y, z); - return crate.onWanded(player, stack); - } - - @Override - public void renderHUD(Minecraft mc, ScaledResolution res, World world, int x, int y, int z) { - TileEntity tile = world.getTileEntity(x, y, z); - if (tile instanceof TileCraftCrate) { - TileCraftCrate craft = (TileCraftCrate) tile; - - int width = 52; - int height = 52; - int xc = res.getScaledWidth() / 2 + 20; - int yc = res.getScaledHeight() / 2 - height / 2; - - Gui.drawRect(xc - 6, yc - 6, xc + width + 6, yc + height + 6, 0x22000000); - Gui.drawRect(xc - 4, yc - 4, xc + width + 4, yc + height + 4, 0x22000000); - - for (int i = 0; i < 3; i++) - for (int j = 0; j < 3; j++) { - int index = i * 3 + j; - int xp = xc + j * 18; - int yp = yc + i * 18; - - boolean enabled = true; - if (craft.pattern > -1) enabled = TileCraftCrate.PATTERNS[craft.pattern][index]; - - Gui.drawRect(xp, yp, xp + 16, yp + 16, enabled ? 0x22FFFFFF : 0x22FF0000); - - ItemStack item = craft.getStackInSlot(index); - net.minecraft.client.renderer.RenderHelper.enableGUIStandardItemLighting(); - GL11.glEnable(GL12.GL_RESCALE_NORMAL); - RenderItem.getInstance().renderItemAndEffectIntoGUI(mc.fontRenderer, mc.renderEngine, item, xp, yp); - net.minecraft.client.renderer.RenderHelper.disableStandardItemLighting(); - } - } - } + IIcon iconSide; + IIcon iconBottom; + IIcon iconSideCraft; + IIcon iconBottomCraft; + + IIcon[] sidePatternIcons; + + Random random; + + private static final int SUBTYPES = 2; + + public BlockOpenCrate() { + super(Material.wood); + setHardness(2.0F); + setStepSound(soundTypeWood); + setBlockName(LibBlockNames.OPEN_CRATE); + + random = new Random(); + } + + @Override + protected boolean shouldRegisterInNameSet() { + return false; + } + + @Override + public Block setBlockName(String par1Str) { + GameRegistry.registerBlock(this, ItemBlockWithMetadataAndName.class, par1Str); + return super.setBlockName(par1Str); + } + + @Override + public void getSubBlocks(Item par1, CreativeTabs par2CreativeTabs, List par3List) { + for(int i = 0; i < SUBTYPES; i++) + par3List.add(new ItemStack(par1, 1, i)); + } + + @Override + public int damageDropped(int meta) { + return meta; + } + + + @Override + public boolean hasComparatorInputOverride() { + return true; + } + + @Override + public int getComparatorInputOverride(World par1World, int par2, int par3, int par4, int par5) { + TileOpenCrate crate = (TileOpenCrate) par1World.getTileEntity(par2, par3, par4); + return crate.getSignal(); + } + + @Override + public void breakBlock(World par1World, int par2, int par3, int par4, Block par5, int par6) { + TileSimpleInventory inv = (TileSimpleInventory) par1World.getTileEntity(par2, par3, par4); + + if (inv != null) { + for (int j1 = 0; j1 < inv.getSizeInventory(); ++j1) { + ItemStack itemstack = inv.getStackInSlot(j1); + + if (itemstack != null) { + float f = random.nextFloat() * 0.8F + 0.1F; + float f1 = random.nextFloat() * 0.8F + 0.1F; + EntityItem entityitem; + + for (float f2 = random.nextFloat() * 0.8F + 0.1F; itemstack.stackSize > 0; par1World.spawnEntityInWorld(entityitem)) { + int k1 = random.nextInt(21) + 10; + + if (k1 > itemstack.stackSize) + k1 = itemstack.stackSize; + + itemstack.stackSize -= k1; + entityitem = new EntityItem(par1World, par2 + f, par3 + f1, par4 + f2, new ItemStack(itemstack.getItem(), k1, itemstack.getItemDamage())); + float f3 = 0.05F; + entityitem.motionX = (float)random.nextGaussian() * f3; + entityitem.motionY = (float)random.nextGaussian() * f3 + 0.2F; + entityitem.motionZ = (float)random.nextGaussian() * f3; + + if (itemstack.hasTagCompound()) + entityitem.getEntityItem().setTagCompound((NBTTagCompound)itemstack.getTagCompound().copy()); + } + } + } + + par1World.func_147453_f(par2, par3, par4, par5); + } + + super.breakBlock(par1World, par2, par3, par4, par5, par6); + } + + @Override + public void registerBlockIcons(IIconRegister par1IconRegister) { + iconSide = IconHelper.forBlock(par1IconRegister, this, 0); + iconBottom = IconHelper.forBlock(par1IconRegister, this, 1); + iconSideCraft = IconHelper.forBlock(par1IconRegister, this, 2); + iconBottomCraft = IconHelper.forBlock(par1IconRegister, this, 3); + + sidePatternIcons = new IIcon[TileCraftCrate.PATTERNS.length]; + for(int i = 0; i < sidePatternIcons.length; i++) + sidePatternIcons[i] = IconHelper.forName(par1IconRegister, "ocPattern" + i); + } + + @Override + public IIcon getIcon(int side, int meta) { + return meta == 0 ? side == 0 ? iconBottom : iconSide : side == 0 ? iconBottomCraft : iconSideCraft; + } + + @Override + public IIcon getIcon(IBlockAccess world, int x, int y, int z, int side) { + TileEntity tile = world.getTileEntity(x, y, z); + if(tile != null && tile instanceof TileCraftCrate && ((TileCraftCrate) tile).pattern != -1 && side != 0) + return sidePatternIcons[((TileCraftCrate) tile).pattern]; + + return super.getIcon(world, x, y, z, side); + } + + @Override + public TileEntity createNewTileEntity(World world, int meta) { + return meta == 0 ? new TileOpenCrate() : new TileCraftCrate(); + } + + @Override + public LexiconEntry getEntry(World world, int x, int y, int z, EntityPlayer player, ItemStack lexicon) { + return world.getBlockMetadata(x, y, z) == 0 ? LexiconData.openCrate : LexiconData.craftCrate; + } + + @Override + public boolean onUsedByWand(EntityPlayer player, ItemStack stack, World world, int x, int y, int z, int side) { + TileOpenCrate crate = (TileOpenCrate) world.getTileEntity(x, y, z); + return crate.onWanded(player, stack); + } + + @Override + public void renderHUD(Minecraft mc, ScaledResolution res, World world, int x, int y, int z) { + TileEntity tile = world.getTileEntity(x, y, z); + if(tile instanceof TileCraftCrate) { + TileCraftCrate craft = (TileCraftCrate) tile; + + int width = 52; + int height = 52; + int xc = res.getScaledWidth() / 2 + 20; + int yc = res.getScaledHeight() / 2 - height / 2; + + Gui.drawRect(xc - 6, yc - 6, xc + width + 6, yc + height + 6, 0x22000000); + Gui.drawRect(xc - 4, yc - 4, xc + width + 4, yc + height + 4, 0x22000000); + + for(int i = 0; i < 3; i++) + for(int j = 0; j < 3; j++) { + int index = i * 3 + j; + int xp = xc + j * 18; + int yp = yc + i * 18; + + boolean enabled = true; + if(craft.pattern > -1) + enabled = TileCraftCrate.PATTERNS[craft.pattern][index]; + + Gui.drawRect(xp, yp, xp + 16, yp + 16, enabled ? 0x22FFFFFF : 0x22FF0000); + + ItemStack item = craft.getStackInSlot(index); + net.minecraft.client.renderer.RenderHelper.enableGUIStandardItemLighting(); + GL11.glEnable(GL12.GL_RESCALE_NORMAL); + RenderItem.getInstance().renderItemAndEffectIntoGUI(mc.fontRenderer, mc.renderEngine, item, xp, yp); + net.minecraft.client.renderer.RenderHelper.disableStandardItemLighting(); + } + } + } + } diff --git a/src/main/java/vazkii/botania/common/block/BlockPistonRelay.java b/src/main/java/vazkii/botania/common/block/BlockPistonRelay.java index 416bf57a74..80dfcdfe41 100644 --- a/src/main/java/vazkii/botania/common/block/BlockPistonRelay.java +++ b/src/main/java/vazkii/botania/common/block/BlockPistonRelay.java @@ -2,25 +2,21 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Feb 20, 2014, 4:57:36 PM (GMT)] */ package vazkii.botania.common.block; -import cpw.mods.fml.common.FMLCommonHandler; -import cpw.mods.fml.common.eventhandler.SubscribeEvent; -import cpw.mods.fml.common.gameevent.TickEvent; -import cpw.mods.fml.common.gameevent.TickEvent.Phase; -import cpw.mods.fml.common.gameevent.TickEvent.Type; import java.util.ArrayList; import java.util.Collection; import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.Random; + import net.minecraft.block.Block; import net.minecraft.block.material.Material; import net.minecraft.entity.item.EntityItem; @@ -42,262 +38,244 @@ import vazkii.botania.api.wand.IWandable; import vazkii.botania.common.lexicon.LexiconData; import vazkii.botania.common.lib.LibBlockNames; +import cpw.mods.fml.common.FMLCommonHandler; +import cpw.mods.fml.common.eventhandler.SubscribeEvent; +import cpw.mods.fml.common.gameevent.TickEvent; +import cpw.mods.fml.common.gameevent.TickEvent.Phase; +import cpw.mods.fml.common.gameevent.TickEvent.Type; public class BlockPistonRelay extends BlockMod implements IWandable, ILexiconable { - public static Map playerPositions = new HashMap(); - public static Map mappedPositions = new HashMap(); - - static List removeThese = new ArrayList(); - static List checkedCoords = new ArrayList(); - static Map coordsToCheck = new HashMap(); - - public BlockPistonRelay() { - super(Material.gourd); - setBlockName(LibBlockNames.PISTON_RELAY); - setHardness(2F); - setResistance(10F); - setStepSound(soundTypeMetal); - - MinecraftForge.EVENT_BUS.register(this); - FMLCommonHandler.instance().bus().register(this); - } - - @Override - public int quantityDropped(int meta, int fortune, Random random) { - return 0; - } - - @Override - public boolean isOpaqueCube() { - return false; - } - - @Override - public void breakBlock(World par1World, int par2, int par3, int par4, Block par5, int par6) { - mapCoords(par1World.provider.dimensionId, par2, par3, par4, 2); - } - - public static String getCoordsAsString(int world, int x, int y, int z) { - return world + ":" + x + ":" + y + ":" + z; - } - - static void mapCoords(int world, int x, int y, int z, int time) { - String coords = getCoordsAsString(world, x, y, z); - coordsToCheck.put(coords, time); - } - - static void decrCoords(String key) { - int time = getTimeInCoords(key); - - if (time <= 0) removeThese.add(key); - else coordsToCheck.put(key, time - 1); - } - - static int getTimeInCoords(String key) { - return coordsToCheck.get(key); - } - - static Block getBlockAt(String key) { - MinecraftServer server = MinecraftServer.getServer(); - if (server == null) return Blocks.air; - - String[] tokens = key.split(":"); - int worldId = Integer.parseInt(tokens[0]), - x = Integer.parseInt(tokens[1]), - y = Integer.parseInt(tokens[2]), - z = Integer.parseInt(tokens[3]); - World world = server.worldServerForDimension(worldId); - return world.getBlock(x, y, z); - } - - static int getBlockMetaAt(String key) { - MinecraftServer server = MinecraftServer.getServer(); - if (server == null) return 0; - - String[] tokens = key.split(":"); - int worldId = Integer.parseInt(tokens[0]), - x = Integer.parseInt(tokens[1]), - y = Integer.parseInt(tokens[2]), - z = Integer.parseInt(tokens[3]); - World world = server.worldServerForDimension(worldId); - return world.getBlockMetadata(x, y, z); - } - - @Override - public boolean onUsedByWand(EntityPlayer player, ItemStack stack, World world, int x, int y, int z, int side) { - if (player == null) return false; - - if (!player.isSneaking()) { - playerPositions.put(player.getCommandSenderName(), getCoordsAsString(world.provider.dimensionId, x, y, z)); - world.playSoundEffect(x, y, z, "botania:ding", 0.5F, 1F); - } else { - dropBlockAsItem(world, x, y, z, new ItemStack(this)); - world.setBlockToAir(x, y, z); - if (!world.isRemote) world.playAuxSFX(2001, x, y, z, Block.getIdFromBlock(this)); - } - - return true; - } - - @SubscribeEvent - public void onWorldLoad(WorldEvent.Load event) { - WorldData.get(event.world); - } - - @SubscribeEvent - public void onWorldUnload(WorldEvent.Unload event) { - WorldData.get(event.world).markDirty(); - } - - public static class WorldData extends WorldSavedData { - - private static final String ID = "PistonRelayPairs"; - - public WorldData(String id) { - super(id); - } - - @Override - public void readFromNBT(NBTTagCompound nbttagcompound) { - mappedPositions.clear(); - - Collection tags = nbttagcompound.func_150296_c(); - for (String key : tags) { - NBTBase tag = nbttagcompound.getTag(key); - if (tag instanceof NBTTagString) { - String value = ((NBTTagString) tag).func_150285_a_(); - - mappedPositions.put(key, value); - } - } - } - - @Override - public void writeToNBT(NBTTagCompound nbttagcompound) { - for (String s : mappedPositions.keySet()) nbttagcompound.setString(s, mappedPositions.get(s)); - } - - public static WorldData get(World world) { - if (world.mapStorage == null) return null; - - WorldData data = (WorldData) world.mapStorage.loadData(WorldData.class, ID); - - if (data == null) { - data = new WorldData(ID); - data.markDirty(); - world.mapStorage.setData(ID, data); - } - return data; - } - } - - @SubscribeEvent - public void tickEnd(TickEvent event) { - if (event.type == Type.SERVER && event.phase == Phase.END) { - List coordsToCheckCopy = new ArrayList(coordsToCheck.keySet()); - for (String s : coordsToCheckCopy) { - decrCoords(s); - if (checkedCoords.contains(s)) continue; - - Block block = getBlockAt(s); - if (block == Blocks.piston_extension) { - int meta = getBlockMetaAt(s); - boolean sticky = (meta & 8) == 8; - ForgeDirection dir = ForgeDirection.getOrientation(meta & ~8); - - MinecraftServer server = MinecraftServer.getServer(); - - if (server != null && getTimeInCoords(s) == 0) { - String newPos; - - { - String[] tokens = s.split(":"); - int worldId = Integer.parseInt(tokens[0]), - x = Integer.parseInt(tokens[1]), - y = Integer.parseInt(tokens[2]), - z = Integer.parseInt(tokens[3]); - World world = server.worldServerForDimension(worldId); - if (world.isAirBlock(x + dir.offsetX, y + dir.offsetY, z + dir.offsetZ)) - world.setBlock( - x + dir.offsetX, y + dir.offsetY, z + dir.offsetZ, ModBlocks.pistonRelay); - else if (!world.isRemote) { - ItemStack stack = new ItemStack(ModBlocks.pistonRelay); - world.spawnEntityInWorld(new EntityItem( - world, x + dir.offsetX, y + dir.offsetY, z + dir.offsetZ, stack)); - } - checkedCoords.add(s); - newPos = getCoordsAsString( - world.provider.dimensionId, x + dir.offsetX, y + dir.offsetY, z + dir.offsetZ); - } - - if (mappedPositions.containsKey(s)) { - String pos = mappedPositions.get(s); - String[] tokens = pos.split(":"); - int worldId = Integer.parseInt(tokens[0]), - x = Integer.parseInt(tokens[1]), - y = Integer.parseInt(tokens[2]), - z = Integer.parseInt(tokens[3]); - World world = server.worldServerForDimension(worldId); - - Block srcBlock = world.getBlock(x, y, z); - int srcMeta = world.getBlockMetadata(x, y, z); - TileEntity tile = world.getTileEntity(x, y, z); - Material mat = srcBlock.getMaterial(); - - if (!sticky - && tile == null - && mat.getMaterialMobility() == 0 - && srcBlock.getBlockHardness(world, x, y, z) != -1 - && !srcBlock.isAir(world, x, y, z)) { - Material destMat = world.getBlock(x + dir.offsetX, y + dir.offsetY, z + dir.offsetZ) - .getMaterial(); - if (world.isAirBlock(x + dir.offsetX, y + dir.offsetY, z + dir.offsetZ) - || destMat.isReplaceable()) { - world.setBlock(x, y, z, Blocks.air); - world.setBlock( - x + dir.offsetX, - y + dir.offsetY, - z + dir.offsetZ, - srcBlock, - srcMeta, - 1 | 2); - mappedPositions.put( - s, - getCoordsAsString( - world.provider.dimensionId, - x + dir.offsetX, - y + dir.offsetY, - z + dir.offsetZ)); - } - } - - pos = mappedPositions.get(s); - mappedPositions.remove(s); - mappedPositions.put(newPos, pos); - save(world); - } - } - } - } - } - - // ConcurrentModificationException failsafe - ArrayList remove = new ArrayList(removeThese); - for (String s : remove) { - coordsToCheck.remove(s); - if (checkedCoords.contains(s)) checkedCoords.remove(s); - } - removeThese.clear(); - } - - public void save(World world) { - WorldData data = WorldData.get(world); - if (data != null) data.markDirty(); - } - - @Override - public LexiconEntry getEntry(World world, int x, int y, int z, EntityPlayer player, ItemStack lexicon) { - return LexiconData.pistonRelay; - } + public static Map playerPositions = new HashMap(); + public static Map mappedPositions = new HashMap(); + + static List removeThese = new ArrayList(); + static List checkedCoords = new ArrayList(); + static Map coordsToCheck = new HashMap(); + + public BlockPistonRelay() { + super(Material.gourd); + setBlockName(LibBlockNames.PISTON_RELAY); + setHardness(2F); + setResistance(10F); + setStepSound(soundTypeMetal); + + MinecraftForge.EVENT_BUS.register(this); + FMLCommonHandler.instance().bus().register(this); + } + + @Override + public int quantityDropped(int meta, int fortune, Random random) { + return 0; + } + + @Override + public boolean isOpaqueCube() { + return false; + } + + @Override + public void breakBlock(World par1World, int par2, int par3, int par4, Block par5, int par6) { + mapCoords(par1World.provider.dimensionId, par2, par3, par4, 2); + } + + public static String getCoordsAsString(int world, int x, int y, int z) { + return world + ":" + x + ":" + y + ":" + z; + } + + static void mapCoords(int world, int x, int y, int z, int time) { + String coords = getCoordsAsString(world, x, y, z); + coordsToCheck.put(coords, time); + } + + static void decrCoords(String key) { + int time = getTimeInCoords(key); + + if(time <= 0) + removeThese.add(key); + else coordsToCheck.put(key, time - 1); + } + + static int getTimeInCoords(String key) { + return coordsToCheck.get(key); + } + + static Block getBlockAt(String key) { + MinecraftServer server = MinecraftServer.getServer(); + if(server == null) + return Blocks.air; + + String[] tokens = key.split(":"); + int worldId = Integer.parseInt(tokens[0]), x = Integer.parseInt(tokens[1]), y = Integer.parseInt(tokens[2]), z = Integer.parseInt(tokens[3]); + World world = server.worldServerForDimension(worldId); + return world.getBlock(x, y, z); + } + + static int getBlockMetaAt(String key) { + MinecraftServer server = MinecraftServer.getServer(); + if(server == null) + return 0; + + String[] tokens = key.split(":"); + int worldId = Integer.parseInt(tokens[0]), x = Integer.parseInt(tokens[1]), y = Integer.parseInt(tokens[2]), z = Integer.parseInt(tokens[3]); + World world = server.worldServerForDimension(worldId); + return world.getBlockMetadata(x, y, z); + } + + @Override + public boolean onUsedByWand(EntityPlayer player, ItemStack stack, World world, int x, int y, int z, int side) { + if(player == null) + return false; + + if(!player.isSneaking()) { + playerPositions.put(player.getCommandSenderName(), getCoordsAsString(world.provider.dimensionId, x, y, z)); + world.playSoundEffect(x, y, z, "botania:ding", 0.5F, 1F); + } else { + dropBlockAsItem(world, x, y, z, new ItemStack(this)); + world.setBlockToAir(x, y, z); + if(!world.isRemote) + world.playAuxSFX(2001, x, y , z, Block.getIdFromBlock(this)); + } + + return true; + } + + @SubscribeEvent + public void onWorldLoad(WorldEvent.Load event) { + WorldData.get(event.world); + } + + @SubscribeEvent + public void onWorldUnload(WorldEvent.Unload event) { + WorldData.get(event.world).markDirty(); + } + + public static class WorldData extends WorldSavedData { + + private static final String ID = "PistonRelayPairs"; + + public WorldData(String id) { + super(id); + } + + @Override + public void readFromNBT(NBTTagCompound nbttagcompound) { + mappedPositions.clear(); + + Collection tags = nbttagcompound.func_150296_c(); + for(String key : tags) { + NBTBase tag = nbttagcompound.getTag(key); + if(tag instanceof NBTTagString) { + String value = ((NBTTagString) tag).func_150285_a_(); + + mappedPositions.put(key, value); + } + } + } + + @Override + public void writeToNBT(NBTTagCompound nbttagcompound) { + for(String s : mappedPositions.keySet()) + nbttagcompound.setString(s, mappedPositions.get(s)); + } + + public static WorldData get(World world) { + if(world.mapStorage == null) + return null; + + WorldData data = (WorldData) world.mapStorage.loadData(WorldData.class, ID); + + if (data == null) { + data = new WorldData(ID); + data.markDirty(); + world.mapStorage.setData(ID, data); + } + return data; + } + } + + @SubscribeEvent + public void tickEnd(TickEvent event) { + if(event.type == Type.SERVER && event.phase == Phase.END) { + List coordsToCheckCopy = new ArrayList(coordsToCheck.keySet()); + for(String s : coordsToCheckCopy) { + decrCoords(s); + if(checkedCoords.contains(s)) + continue; + + Block block = getBlockAt(s); + if(block == Blocks.piston_extension) { + int meta = getBlockMetaAt(s); + boolean sticky = (meta & 8) == 8; + ForgeDirection dir = ForgeDirection.getOrientation(meta & ~8); + + MinecraftServer server = MinecraftServer.getServer(); + + if(server != null && getTimeInCoords(s) == 0) { + String newPos; + + { + String[] tokens = s.split(":"); + int worldId = Integer.parseInt(tokens[0]), x = Integer.parseInt(tokens[1]), y = Integer.parseInt(tokens[2]), z = Integer.parseInt(tokens[3]); + World world = server.worldServerForDimension(worldId); + if(world.isAirBlock(x + dir.offsetX, y + dir.offsetY, z + dir.offsetZ)) + world.setBlock(x + dir.offsetX, y + dir.offsetY, z + dir.offsetZ, ModBlocks.pistonRelay); + else if(!world.isRemote) { + ItemStack stack = new ItemStack(ModBlocks.pistonRelay); + world.spawnEntityInWorld(new EntityItem(world, x + dir.offsetX, y + dir.offsetY, z + dir.offsetZ, stack)); + } + checkedCoords.add(s); + newPos = getCoordsAsString(world.provider.dimensionId, x + dir.offsetX, y + dir.offsetY, z + dir.offsetZ); + } + + if(mappedPositions.containsKey(s)) { + String pos = mappedPositions.get(s); + String[] tokens = pos.split(":"); + int worldId = Integer.parseInt(tokens[0]), x = Integer.parseInt(tokens[1]), y = Integer.parseInt(tokens[2]), z = Integer.parseInt(tokens[3]); + World world = server.worldServerForDimension(worldId); + + Block srcBlock = world.getBlock(x, y, z); + int srcMeta = world.getBlockMetadata(x, y, z); + TileEntity tile = world.getTileEntity(x, y, z); + Material mat = srcBlock.getMaterial(); + + if(!sticky && tile == null && mat.getMaterialMobility() == 0 && srcBlock.getBlockHardness(world, x, y, z) != -1 && !srcBlock.isAir(world, x, y, z)) { + Material destMat = world.getBlock(x + dir.offsetX, y + dir.offsetY, z + dir.offsetZ).getMaterial(); + if(world.isAirBlock(x + dir.offsetX, y + dir.offsetY, z + dir.offsetZ) || destMat.isReplaceable()) { + world.setBlock(x, y, z, Blocks.air); + world.setBlock(x + dir.offsetX, y + dir.offsetY, z + dir.offsetZ, srcBlock, srcMeta, 1 | 2); + mappedPositions.put(s, getCoordsAsString(world.provider.dimensionId, x + dir.offsetX, y + dir.offsetY, z + dir.offsetZ)); + } + } + + pos = mappedPositions.get(s); + mappedPositions.remove(s); + mappedPositions.put(newPos, pos); + save(world); + } + } + } + } + } + + // ConcurrentModificationException failsafe + ArrayList remove = new ArrayList(removeThese); + for(String s : remove) { + coordsToCheck.remove(s); + if(checkedCoords.contains(s)) + checkedCoords.remove(s); + } + removeThese.clear(); + } + + public void save(World world) { + WorldData data = WorldData.get(world); + if(data != null) + data.markDirty(); + } + + @Override + public LexiconEntry getEntry(World world, int x, int y, int z, EntityPlayer player, ItemStack lexicon) { + return LexiconData.pistonRelay; + } } diff --git a/src/main/java/vazkii/botania/common/block/BlockPlatform.java b/src/main/java/vazkii/botania/common/block/BlockPlatform.java index 22488782b4..75346747fc 100644 --- a/src/main/java/vazkii/botania/common/block/BlockPlatform.java +++ b/src/main/java/vazkii/botania/common/block/BlockPlatform.java @@ -2,16 +2,16 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jun 7, 2014, 2:25:22 PM (GMT)] */ package vazkii.botania.common.block; -import cpw.mods.fml.common.registry.GameRegistry; import java.util.List; + import net.minecraft.block.Block; import net.minecraft.block.material.Material; import net.minecraft.client.renderer.texture.IIconRegister; @@ -32,90 +32,83 @@ import vazkii.botania.common.item.block.ItemBlockWithMetadataAndName; import vazkii.botania.common.lexicon.LexiconData; import vazkii.botania.common.lib.LibBlockNames; +import cpw.mods.fml.common.registry.GameRegistry; public class BlockPlatform extends BlockCamo implements ILexiconable, IWandable { - IIcon[] icons; - private static final int SUBTYPES = 3; - - public BlockPlatform() { - super(Material.wood); - setHardness(2.0F); - setResistance(5.0F); - setStepSound(Block.soundTypeWood); - setBlockName(LibBlockNames.PLATFORM); - } - - @Override - protected boolean shouldRegisterInNameSet() { - return false; - } - - @Override - public int damageDropped(int par1) { - return par1; - } - - @Override - public Block setBlockName(String par1Str) { - GameRegistry.registerBlock(this, ItemBlockWithMetadataAndName.class, par1Str); - return super.setBlockName(par1Str); - } - - @Override - public void getSubBlocks(Item par1, CreativeTabs par2CreativeTabs, List par3List) { - for (int i = 0; i < SUBTYPES; i++) par3List.add(new ItemStack(par1, 1, i)); - } - - @Override - public void registerBlockIcons(IIconRegister par1IconRegister) { - icons = new IIcon[SUBTYPES]; - for (int i = 0; i < SUBTYPES; i++) icons[i] = IconHelper.forBlock(par1IconRegister, this, i); - } - - @Override - public IIcon getIcon(int par1, int par2) { - return icons[Math.min(SUBTYPES - 1, par2)]; - } - - @Override - public void addCollisionBoxesToList( - World par1World, - int par2, - int par3, - int par4, - AxisAlignedBB par5AxisAlignedBB, - List par6List, - Entity par7Entity) { - int meta = par1World.getBlockMetadata(par2, par3, par4); - if (meta == 2 - || meta == 0 - && par7Entity != null - && par7Entity.posY > par3 + (par7Entity instanceof EntityPlayer ? 2 : 0) - && (!(par7Entity instanceof EntityPlayer) || !par7Entity.isSneaking())) - super.addCollisionBoxesToList(par1World, par2, par3, par4, par5AxisAlignedBB, par6List, par7Entity); - } - - @Override - public float getBlockHardness(World par1World, int par2, int par3, int par4) { - int meta = par1World.getBlockMetadata(par2, par3, par4); - return meta == 2 ? -1F : super.getBlockHardness(par1World, par2, par3, par4); - } - - @Override - public TileCamo createNewTileEntity(World world, int meta) { - return new TilePlatform(); - } - - @Override - public LexiconEntry getEntry(World world, int x, int y, int z, EntityPlayer player, ItemStack lexicon) { - int meta = world.getBlockMetadata(x, y, z); - return meta == 0 ? LexiconData.platform : meta == 2 ? null : LexiconData.spectralPlatform; - } - - @Override - public boolean onUsedByWand(EntityPlayer player, ItemStack stack, World world, int x, int y, int z, int side) { - TilePlatform tile = (TilePlatform) world.getTileEntity(x, y, z); - return tile.onWanded(player); - } -} + IIcon[] icons; + private static final int SUBTYPES = 3; + + public BlockPlatform() { + super(Material.wood); + setHardness(2.0F); + setResistance(5.0F); + setStepSound(Block.soundTypeWood); + setBlockName(LibBlockNames.PLATFORM); + } + + @Override + protected boolean shouldRegisterInNameSet() { + return false; + } + + @Override + public int damageDropped(int par1) { + return par1; + } + + @Override + public Block setBlockName(String par1Str) { + GameRegistry.registerBlock(this, ItemBlockWithMetadataAndName.class, par1Str); + return super.setBlockName(par1Str); + } + + @Override + public void getSubBlocks(Item par1, CreativeTabs par2CreativeTabs, List par3List) { + for(int i = 0; i < SUBTYPES; i++) + par3List.add(new ItemStack(par1, 1, i)); + } + + @Override + public void registerBlockIcons(IIconRegister par1IconRegister) { + icons = new IIcon[SUBTYPES]; + for(int i = 0; i < SUBTYPES; i++) + icons[i] = IconHelper.forBlock(par1IconRegister, this, i); + } + + @Override + public IIcon getIcon(int par1, int par2) { + return icons[Math.min(SUBTYPES - 1, par2)]; + } + + @Override + public void addCollisionBoxesToList(World par1World, int par2, int par3, int par4, AxisAlignedBB par5AxisAlignedBB, List par6List, Entity par7Entity) { + int meta = par1World.getBlockMetadata(par2, par3, par4); + if(meta == 2 || meta == 0 && par7Entity != null && par7Entity.posY > par3 + (par7Entity instanceof EntityPlayer ? 2 : 0) && (!(par7Entity instanceof EntityPlayer) || !par7Entity.isSneaking())) + super.addCollisionBoxesToList(par1World, par2, par3, par4, par5AxisAlignedBB, par6List, par7Entity); + } + + @Override + public float getBlockHardness(World par1World, int par2, int par3, int par4) { + int meta = par1World.getBlockMetadata(par2, par3, par4); + return meta == 2 ? -1F : super.getBlockHardness(par1World, par2, par3, par4); + } + + @Override + public TileCamo createNewTileEntity(World world, int meta) { + return new TilePlatform(); + } + + @Override + public LexiconEntry getEntry(World world, int x, int y, int z, EntityPlayer player, ItemStack lexicon) { + int meta = world.getBlockMetadata(x, y, z); + return meta == 0 ? LexiconData.platform : meta == 2 ? null : LexiconData.spectralPlatform; + } + + @Override + public boolean onUsedByWand(EntityPlayer player, ItemStack stack, World world, int x, int y, int z, int side) { + TilePlatform tile = (TilePlatform) world.getTileEntity(x, y, z); + return tile.onWanded(player); + } + +} \ No newline at end of file diff --git a/src/main/java/vazkii/botania/common/block/BlockPylon.java b/src/main/java/vazkii/botania/common/block/BlockPylon.java index a946815935..c6ed2b1333 100644 --- a/src/main/java/vazkii/botania/common/block/BlockPylon.java +++ b/src/main/java/vazkii/botania/common/block/BlockPylon.java @@ -2,17 +2,16 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Feb 18, 2014, 10:13:02 PM (GMT)] */ package vazkii.botania.common.block; -import cpw.mods.fml.common.Optional; -import cpw.mods.fml.common.registry.GameRegistry; import java.util.List; + import net.minecraft.block.Block; import net.minecraft.block.material.Material; import net.minecraft.client.renderer.texture.IIconRegister; @@ -33,85 +32,86 @@ import vazkii.botania.common.item.block.ItemBlockWithMetadataAndName; import vazkii.botania.common.lexicon.LexiconData; import vazkii.botania.common.lib.LibBlockNames; +import cpw.mods.fml.common.Optional; +import cpw.mods.fml.common.registry.GameRegistry; @Optional.Interface(modid = "Thaumcraft", iface = "thaumcraft.api.crafting.IInfusionStabiliser", striprefs = true) public class BlockPylon extends BlockModContainer implements ILexiconable, IInfusionStabiliser { - public BlockPylon() { - super(Material.iron); - setHardness(5.5F); - setStepSound(soundTypeMetal); - setBlockName(LibBlockNames.PYLON); - setLightLevel(0.5F); - - float f = 1F / 16F * 2F; - setBlockBounds(f, 0F, f, 1F - f, 1F / 16F * 21F, 1F - f); - } - - @Override - protected boolean shouldRegisterInNameSet() { - return false; - } - - @Override - public Block setBlockName(String par1Str) { - GameRegistry.registerBlock(this, ItemBlockWithMetadataAndName.class, par1Str); - return super.setBlockName(par1Str); - } - - @Override - public void registerBlockIcons(IIconRegister par1IconRegister) { - // NO-OP - } - - @Override - public int damageDropped(int par1) { - return par1; - } - - @Override - public void getSubBlocks(Item par1, CreativeTabs par2, List par3) { - for (int i = 0; i < 3; i++) par3.add(new ItemStack(par1, 1, i)); - } - - @Override - public IIcon getIcon(int par1, int par2) { - return par2 == 0 ? Blocks.diamond_block.getIcon(0, 0) : ModBlocks.storage.getIcon(0, par2); - } - - @Override - public boolean isOpaqueCube() { - return false; - } - - @Override - public boolean renderAsNormalBlock() { - return false; - } - - @Override - public int getRenderType() { - return LibRenderIDs.idPylon; - } - - @Override - public float getEnchantPowerBonus(World world, int x, int y, int z) { - return world.getBlockMetadata(x, y, z) == 0 ? 8 : 15; - } - - @Override - public TileEntity createNewTileEntity(World world, int meta) { - return new TilePylon(); - } - - @Override - public LexiconEntry getEntry(World world, int x, int y, int z, EntityPlayer player, ItemStack lexicon) { - int meta = world.getBlockMetadata(x, y, z); - return meta == 0 ? LexiconData.pylon : meta == 1 ? LexiconData.alfhomancyIntro : LexiconData.gaiaRitual; - } - - @Override - public boolean canStabaliseInfusion(World world, int x, int y, int z) { - return ConfigHandler.enableThaumcraftStablizers; - } + public BlockPylon() { + super(Material.iron); + setHardness(5.5F); + setStepSound(soundTypeMetal); + setBlockName(LibBlockNames.PYLON); + setLightLevel(0.5F); + + float f = 1F / 16F * 2F; + setBlockBounds(f, 0F, f, 1F - f, 1F / 16F * 21F, 1F - f); + } + @Override + protected boolean shouldRegisterInNameSet() { + return false; + } + + @Override + public Block setBlockName(String par1Str) { + GameRegistry.registerBlock(this, ItemBlockWithMetadataAndName.class, par1Str); + return super.setBlockName(par1Str); + } + + @Override + public void registerBlockIcons(IIconRegister par1IconRegister) { + // NO-OP + } + + @Override + public int damageDropped(int par1) { + return par1; + } + + @Override + public void getSubBlocks(Item par1, CreativeTabs par2, List par3) { + for(int i = 0; i < 3; i++) + par3.add(new ItemStack(par1, 1, i)); + } + + @Override + public IIcon getIcon(int par1, int par2) { + return par2 == 0 ? Blocks.diamond_block.getIcon(0, 0) : ModBlocks.storage.getIcon(0, par2); + } + + @Override + public boolean isOpaqueCube() { + return false; + } + + @Override + public boolean renderAsNormalBlock() { + return false; + } + + @Override + public int getRenderType() { + return LibRenderIDs.idPylon; + } + + @Override + public float getEnchantPowerBonus(World world, int x, int y, int z) { + return world.getBlockMetadata(x, y, z) == 0 ? 8 : 15; + } + + @Override + public TileEntity createNewTileEntity(World world, int meta) { + return new TilePylon(); + } + + @Override + public LexiconEntry getEntry(World world, int x, int y, int z, EntityPlayer player, ItemStack lexicon) { + int meta = world.getBlockMetadata(x, y, z); + return meta == 0 ? LexiconData.pylon : meta == 1 ? LexiconData.alfhomancyIntro : LexiconData.gaiaRitual; + } + @Override + public boolean canStabaliseInfusion(World world, int x, int y, int z) { + return ConfigHandler.enableThaumcraftStablizers; + } } diff --git a/src/main/java/vazkii/botania/common/block/BlockRoot.java b/src/main/java/vazkii/botania/common/block/BlockRoot.java index 6b6570b88e..4a5810bfe6 100644 --- a/src/main/java/vazkii/botania/common/block/BlockRoot.java +++ b/src/main/java/vazkii/botania/common/block/BlockRoot.java @@ -2,15 +2,16 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jul 7, 2015, 4:27:47 PM (GMT)] */ package vazkii.botania.common.block; import java.util.Random; + import net.minecraft.block.material.Material; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.Item; @@ -24,30 +25,32 @@ public class BlockRoot extends BlockMod implements ILexiconable { - public BlockRoot() { - super(Material.plants); - setHardness(1.2F); - setStepSound(soundTypeWood); - setBlockName(LibBlockNames.ROOT); - } - - @Override - public Item getItemDropped(int p_149650_1_, Random p_149650_2_, int p_149650_3_) { - return ModItems.manaResource; - } - - @Override - public int damageDropped(int p_149692_1_) { - return 20; - } - - @Override - public int quantityDropped(Random r) { - return 2 + r.nextInt(3); - } - - @Override - public LexiconEntry getEntry(World world, int x, int y, int z, EntityPlayer player, ItemStack lexicon) { - return LexiconData.gardenOfGlass; - } + public BlockRoot() { + super(Material.plants); + setHardness(1.2F); + setStepSound(soundTypeWood); + setBlockName(LibBlockNames.ROOT); + } + + + @Override + public Item getItemDropped(int p_149650_1_, Random p_149650_2_, int p_149650_3_) { + return ModItems.manaResource; + } + + @Override + public int damageDropped(int p_149692_1_) { + return 20; + } + + @Override + public int quantityDropped(Random r) { + return 2 + r.nextInt(3); + } + + @Override + public LexiconEntry getEntry(World world, int x, int y, int z, EntityPlayer player, ItemStack lexicon) { + return LexiconData.gardenOfGlass; + } + } diff --git a/src/main/java/vazkii/botania/common/block/BlockSolidVines.java b/src/main/java/vazkii/botania/common/block/BlockSolidVines.java index 8b6149a503..f75af748e1 100644 --- a/src/main/java/vazkii/botania/common/block/BlockSolidVines.java +++ b/src/main/java/vazkii/botania/common/block/BlockSolidVines.java @@ -2,16 +2,16 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jun 26, 2014, 11:31:51 PM (GMT)] */ package vazkii.botania.common.block; -import cpw.mods.fml.common.registry.GameRegistry; import java.util.Random; + import net.minecraft.block.Block; import net.minecraft.block.BlockVine; import net.minecraft.entity.player.EntityPlayer; @@ -26,46 +26,48 @@ import vazkii.botania.common.item.block.ItemBlockMod; import vazkii.botania.common.lexicon.LexiconData; import vazkii.botania.common.lib.LibBlockNames; +import cpw.mods.fml.common.registry.GameRegistry; public class BlockSolidVines extends BlockVine implements ILexiconable { - public BlockSolidVines() { - setBlockName(LibBlockNames.SOLID_VINE); - setHardness(0.5F); - setStepSound(soundTypeGrass); - setBlockTextureName("vine"); - setCreativeTab(null); - } + public BlockSolidVines() { + setBlockName(LibBlockNames.SOLID_VINE); + setHardness(0.5F); + setStepSound(soundTypeGrass); + setBlockTextureName("vine"); + setCreativeTab(null); + } + + @Override + public AxisAlignedBB getCollisionBoundingBoxFromPool(World w, int x, int y, int z) { + setBlockBoundsBasedOnState(w, x, y, z); + return AxisAlignedBB.getBoundingBox(x + minX, y + minY, z + minZ, x + maxX, y + maxY, z + maxZ); + } - @Override - public AxisAlignedBB getCollisionBoundingBoxFromPool(World w, int x, int y, int z) { - setBlockBoundsBasedOnState(w, x, y, z); - return AxisAlignedBB.getBoundingBox(x + minX, y + minY, z + minZ, x + maxX, y + maxY, z + maxZ); - } + @Override + public void updateTick(World p_149674_1_, int p_149674_2_, int p_149674_3_, int p_149674_4_, Random p_149674_5_) { + // NO-OP + } - @Override - public void updateTick(World p_149674_1_, int p_149674_2_, int p_149674_3_, int p_149674_4_, Random p_149674_5_) { - // NO-OP - } + @Override + public Block setBlockName(String par1Str) { + GameRegistry.registerBlock(this, ItemBlockMod.class, par1Str); + return super.setBlockName(par1Str); + } - @Override - public Block setBlockName(String par1Str) { - GameRegistry.registerBlock(this, ItemBlockMod.class, par1Str); - return super.setBlockName(par1Str); - } + @Override + public boolean isShearable(ItemStack item, IBlockAccess world, int x, int y, int z) { + return false; + } - @Override - public boolean isShearable(ItemStack item, IBlockAccess world, int x, int y, int z) { - return false; - } + @Override + public ItemStack getPickBlock(MovingObjectPosition target, World world, int x, int y, int z) { + return new ItemStack(Blocks.vine); + } - @Override - public ItemStack getPickBlock(MovingObjectPosition target, World world, int x, int y, int z) { - return new ItemStack(Blocks.vine); - } + @Override + public LexiconEntry getEntry(World world, int x, int y, int z, EntityPlayer player, ItemStack lexicon) { + return LexiconData.vineBall; + } - @Override - public LexiconEntry getEntry(World world, int x, int y, int z, EntityPlayer player, ItemStack lexicon) { - return LexiconData.vineBall; - } } diff --git a/src/main/java/vazkii/botania/common/block/BlockSparkChanger.java b/src/main/java/vazkii/botania/common/block/BlockSparkChanger.java index 23203557b9..f8a69fe9ff 100644 --- a/src/main/java/vazkii/botania/common/block/BlockSparkChanger.java +++ b/src/main/java/vazkii/botania/common/block/BlockSparkChanger.java @@ -2,15 +2,16 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jun 28, 2015, 10:01:01 PM (GMT)] */ package vazkii.botania.common.block; import java.util.Random; + import net.minecraft.block.Block; import net.minecraft.block.material.Material; import net.minecraft.client.renderer.texture.IIconRegister; @@ -33,150 +34,147 @@ public class BlockSparkChanger extends BlockModContainer implements ILexiconable { - IIcon[] icons; - Random random; - - public BlockSparkChanger() { - super(Material.rock); - setBlockBounds(0F, 0F, 0F, 1F, 3F / 16F, 1F); - setHardness(2.0F); - setResistance(10.0F); - setStepSound(soundTypeStone); - setBlockName(LibBlockNames.SPARK_CHANGER); - - random = new Random(); - } - - @Override - public boolean renderAsNormalBlock() { - return false; - } - - @Override - public boolean isOpaqueCube() { - return false; - } - - @Override - public boolean getBlocksMovement(IBlockAccess p_149655_1_, int p_149655_2_, int p_149655_3_, int p_149655_4_) { - return false; - } - - @Override - public void registerBlockIcons(IIconRegister par1IconRegister) { - icons = new IIcon[3]; - for (int i = 0; i < icons.length; i++) icons[i] = IconHelper.forBlock(par1IconRegister, this, i); - } - - @Override - public IIcon getIcon(int par1, int par2) { - return icons[Math.min(2, par1)]; - } - - @Override - public void onNeighborBlockChange(World world, int x, int y, int z, Block block) { - boolean power = - world.isBlockIndirectlyGettingPowered(x, y, z) || world.isBlockIndirectlyGettingPowered(x, y + 1, z); - int meta = world.getBlockMetadata(x, y, z); - boolean powered = (meta & 8) != 0; - - if (power && !powered) { - ((TileSparkChanger) world.getTileEntity(x, y, z)).doSwap(); - world.setBlockMetadataWithNotify(x, y, z, meta | 8, 4); - } else if (!power && powered) world.setBlockMetadataWithNotify(x, y, z, meta & -9, 4); - } - - @Override - public boolean onBlockActivated( - World world, int x, int y, int z, EntityPlayer player, int s, float xs, float ys, float zs) { - TileSparkChanger changer = (TileSparkChanger) world.getTileEntity(x, y, z); - ItemStack cstack = changer.getStackInSlot(0); - ItemStack pstack = player.getCurrentEquippedItem(); - if (cstack != null) { - changer.setInventorySlotContents(0, null); - world.func_147453_f(x, y, z, this); - changer.markDirty(); - if (!player.inventory.addItemStackToInventory(cstack)) player.dropPlayerItemWithRandomChoice(cstack, false); - return true; - } else if (pstack != null && pstack.getItem() == ModItems.sparkUpgrade) { - changer.setInventorySlotContents(0, pstack.copy().splitStack(1)); - world.func_147453_f(x, y, z, this); - changer.markDirty(); - - pstack.stackSize--; - if (pstack.stackSize == 0) player.inventory.setInventorySlotContents(player.inventory.currentItem, null); - - return true; - } - - return false; - } - - @Override - public void breakBlock(World par1World, int par2, int par3, int par4, Block par5, int par6) { - TileSimpleInventory inv = (TileSimpleInventory) par1World.getTileEntity(par2, par3, par4); - - if (inv != null) { - for (int j1 = 0; j1 < inv.getSizeInventory(); ++j1) { - ItemStack itemstack = inv.getStackInSlot(j1); - - if (itemstack != null) { - float f = random.nextFloat() * 0.8F + 0.1F; - float f1 = random.nextFloat() * 0.8F + 0.1F; - EntityItem entityitem; - - for (float f2 = random.nextFloat() * 0.8F + 0.1F; - itemstack.stackSize > 0; - par1World.spawnEntityInWorld(entityitem)) { - int k1 = random.nextInt(21) + 10; - - if (k1 > itemstack.stackSize) k1 = itemstack.stackSize; - - itemstack.stackSize -= k1; - entityitem = new EntityItem( - par1World, - par2 + f, - par3 + f1, - par4 + f2, - new ItemStack(itemstack.getItem(), k1, itemstack.getItemDamage())); - float f3 = 0.05F; - entityitem.motionX = (float) random.nextGaussian() * f3; - entityitem.motionY = (float) random.nextGaussian() * f3 + 0.2F; - entityitem.motionZ = (float) random.nextGaussian() * f3; - - if (itemstack.hasTagCompound()) - entityitem.getEntityItem().setTagCompound((NBTTagCompound) - itemstack.getTagCompound().copy()); - } - } - } - - par1World.func_147453_f(par2, par3, par4, par5); - } - - super.breakBlock(par1World, par2, par3, par4, par5, par6); - } - - @Override - public boolean hasComparatorInputOverride() { - return true; - } - - @Override - public int getComparatorInputOverride(World world, int x, int y, int z, int s) { - TileSparkChanger changer = (TileSparkChanger) world.getTileEntity(x, y, z); - ItemStack stack = changer.getStackInSlot(0); - if (stack == null) return 0; - return stack.getItemDamage() + 1; - } - - @Override - public TileEntity createNewTileEntity(World world, int meta) { - return new TileSparkChanger(); - } - - @Override - public LexiconEntry getEntry(World world, int x, int y, int z, EntityPlayer player, ItemStack lexicon) { - return LexiconData.sparkChanger; - } + IIcon[] icons; + Random random; + + public BlockSparkChanger() { + super(Material.rock); + setBlockBounds(0F, 0F, 0F, 1F, 3F / 16F, 1F); + setHardness(2.0F); + setResistance(10.0F); + setStepSound(soundTypeStone); + setBlockName(LibBlockNames.SPARK_CHANGER); + + random = new Random(); + } + + @Override + public boolean renderAsNormalBlock() { + return false; + } + + @Override + public boolean isOpaqueCube() { + return false; + } + + @Override + public boolean getBlocksMovement(IBlockAccess p_149655_1_, int p_149655_2_, int p_149655_3_, int p_149655_4_) { + return false; + } + + @Override + public void registerBlockIcons(IIconRegister par1IconRegister) { + icons = new IIcon[3]; + for(int i = 0; i < icons.length; i++) + icons[i] = IconHelper.forBlock(par1IconRegister, this, i); + } + + @Override + public IIcon getIcon(int par1, int par2) { + return icons[Math.min(2, par1)]; + } + + @Override + public void onNeighborBlockChange(World world, int x, int y, int z, Block block) { + boolean power = world.isBlockIndirectlyGettingPowered(x, y, z) || world.isBlockIndirectlyGettingPowered(x, y + 1, z); + int meta = world.getBlockMetadata(x, y, z); + boolean powered = (meta & 8) != 0; + + if(power && !powered) { + ((TileSparkChanger) world.getTileEntity(x, y, z)).doSwap(); + world.setBlockMetadataWithNotify(x, y, z, meta | 8, 4); + } else if(!power && powered) + world.setBlockMetadataWithNotify(x, y, z, meta & -9, 4); + } + + @Override + public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int s, float xs, float ys, float zs) { + TileSparkChanger changer = (TileSparkChanger) world.getTileEntity(x, y, z); + ItemStack cstack = changer.getStackInSlot(0); + ItemStack pstack = player.getCurrentEquippedItem(); + if(cstack != null) { + changer.setInventorySlotContents(0, null); + world.func_147453_f(x, y, z, this); + changer.markDirty(); + if(!player.inventory.addItemStackToInventory(cstack)) + player.dropPlayerItemWithRandomChoice(cstack, false); + return true; + } else if(pstack != null && pstack.getItem() == ModItems.sparkUpgrade) { + changer.setInventorySlotContents(0, pstack.copy().splitStack(1)); + world.func_147453_f(x, y, z, this); + changer.markDirty(); + + pstack.stackSize--; + if(pstack.stackSize == 0) + player.inventory.setInventorySlotContents(player.inventory.currentItem, null); + + return true; + } + + return false; + } + + @Override + public void breakBlock(World par1World, int par2, int par3, int par4, Block par5, int par6) { + TileSimpleInventory inv = (TileSimpleInventory) par1World.getTileEntity(par2, par3, par4); + + if (inv != null) { + for (int j1 = 0; j1 < inv.getSizeInventory(); ++j1) { + ItemStack itemstack = inv.getStackInSlot(j1); + + if (itemstack != null) { + float f = random.nextFloat() * 0.8F + 0.1F; + float f1 = random.nextFloat() * 0.8F + 0.1F; + EntityItem entityitem; + + for (float f2 = random.nextFloat() * 0.8F + 0.1F; itemstack.stackSize > 0; par1World.spawnEntityInWorld(entityitem)) { + int k1 = random.nextInt(21) + 10; + + if (k1 > itemstack.stackSize) + k1 = itemstack.stackSize; + + itemstack.stackSize -= k1; + entityitem = new EntityItem(par1World, par2 + f, par3 + f1, par4 + f2, new ItemStack(itemstack.getItem(), k1, itemstack.getItemDamage())); + float f3 = 0.05F; + entityitem.motionX = (float)random.nextGaussian() * f3; + entityitem.motionY = (float)random.nextGaussian() * f3 + 0.2F; + entityitem.motionZ = (float)random.nextGaussian() * f3; + + if (itemstack.hasTagCompound()) + entityitem.getEntityItem().setTagCompound((NBTTagCompound)itemstack.getTagCompound().copy()); + } + } + } + + par1World.func_147453_f(par2, par3, par4, par5); + } + + super.breakBlock(par1World, par2, par3, par4, par5, par6); + } + + @Override + public boolean hasComparatorInputOverride() { + return true; + } + + @Override + public int getComparatorInputOverride(World world, int x, int y, int z, int s) { + TileSparkChanger changer = (TileSparkChanger) world.getTileEntity(x, y, z); + ItemStack stack = changer.getStackInSlot(0); + if(stack == null) + return 0; + return stack.getItemDamage() + 1; + } + + @Override + public TileEntity createNewTileEntity(World world, int meta) { + return new TileSparkChanger(); + } + + @Override + public LexiconEntry getEntry(World world, int x, int y, int z, EntityPlayer player, ItemStack lexicon) { + return LexiconData.sparkChanger; + } + } diff --git a/src/main/java/vazkii/botania/common/block/BlockSpecialFlower.java b/src/main/java/vazkii/botania/common/block/BlockSpecialFlower.java index adacc7614c..e44ac4941d 100644 --- a/src/main/java/vazkii/botania/common/block/BlockSpecialFlower.java +++ b/src/main/java/vazkii/botania/common/block/BlockSpecialFlower.java @@ -2,20 +2,20 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jan 22, 2014, 7:06:38 PM (GMT)] */ package vazkii.botania.common.block; -import cpw.mods.fml.common.registry.GameRegistry; import java.util.ArrayList; import java.util.Arrays; import java.util.HashMap; import java.util.List; import java.util.Map; + import net.minecraft.block.Block; import net.minecraft.block.BlockFlower; import net.minecraft.block.ITileEntityProvider; @@ -47,231 +47,231 @@ import vazkii.botania.common.item.ModItems; import vazkii.botania.common.item.block.ItemBlockSpecialFlower; import vazkii.botania.common.lib.LibBlockNames; +import cpw.mods.fml.common.registry.GameRegistry; + +public class BlockSpecialFlower extends BlockFlower implements ITileEntityProvider, ISpecialFlower, IWandable, ILexiconable, IWandHUD { + + public static Map icons = new HashMap(); + public static Map iconsAlt = new HashMap(); + + static { + BotaniaAPI.subtilesForCreativeMenu.addAll(Arrays.asList(new String[] { + // Misc + LibBlockNames.SUBTILE_PUREDAISY, + LibBlockNames.SUBTILE_MANASTAR, + + // Generating + LibBlockNames.SUBTILE_DAYBLOOM, + LibBlockNames.SUBTILE_NIGHTSHADE, + LibBlockNames.SUBTILE_ENDOFLAME, + LibBlockNames.SUBTILE_HYDROANGEAS, + LibBlockNames.SUBTILE_THERMALILY, + LibBlockNames.SUBTILE_ARCANE_ROSE, + LibBlockNames.SUBTILE_MUNCHDEW, + LibBlockNames.SUBTILE_ENTROPINNYUM, + LibBlockNames.SUBTILE_KEKIMURUS, + LibBlockNames.SUBTILE_GOURMARYLLIS, + LibBlockNames.SUBTILE_NARSLIMMUS, + LibBlockNames.SUBTILE_SPECTROLUS, + LibBlockNames.SUBTILE_RAFFLOWSIA, + LibBlockNames.SUBTILE_DANDELIFEON, + + // Functional + LibBlockNames.SUBTILE_JADED_AMARANTHUS, + LibBlockNames.SUBTILE_BELLETHORN, + LibBlockNames.SUBTILE_DREADTHORN, + LibBlockNames.SUBTILE_HEISEI_DREAM, + LibBlockNames.SUBTILE_TIGERSEYE, + LibBlockNames.SUBTILE_MARIMORPHOSIS, + LibBlockNames.SUBTILE_ORECHID, + LibBlockNames.SUBTILE_ORECHID_IGNEM, + LibBlockNames.SUBTILE_FALLEN_KANADE, + LibBlockNames.SUBTILE_EXOFLAME, + LibBlockNames.SUBTILE_AGRICARNATION, + LibBlockNames.SUBTILE_HOPPERHOCK, + LibBlockNames.SUBTILE_RANNUNCARPUS, + LibBlockNames.SUBTILE_TANGLEBERRIE, + LibBlockNames.SUBTILE_JIYUULIA, + LibBlockNames.SUBTILE_HYACIDUS, + LibBlockNames.SUBTILE_MEDUMONE, + LibBlockNames.SUBTILE_POLLIDISIAC, + LibBlockNames.SUBTILE_CLAYCONIA, + LibBlockNames.SUBTILE_LOONIUM, + LibBlockNames.SUBTILE_DAFFOMILL, + LibBlockNames.SUBTILE_VINCULOTUS, + LibBlockNames.SUBTILE_SPECTRANTHEMUM, + LibBlockNames.SUBTILE_BUBBELL, + LibBlockNames.SUBTILE_SOLEGNOLIA + })); + } + + protected BlockSpecialFlower() { + super(0); + setBlockName(LibBlockNames.SPECIAL_FLOWER); + setHardness(0.1F); + setStepSound(soundTypeGrass); + setTickRandomly(false); + setCreativeTab(BotaniaCreativeTab.INSTANCE); + setBlockBounds(0.3F, 0.0F, 0.3F, 0.8F, 1, 0.8F); + } + + @Override + public int getLightValue(IBlockAccess world, int x, int y, int z) { + int currentLight = ((TileSpecialFlower) world.getTileEntity(x, y, z)).getLightValue(); + if(currentLight == -1) + currentLight = 0; + return LightHelper.getPackedColor(world.getBlockMetadata(x, y, z), currentLight); + } + + @Override + public boolean hasComparatorInputOverride() { + return true; + } + + @Override + public int getComparatorInputOverride(World world, int x, int y, int z, int side) { + return ((TileSpecialFlower) world.getTileEntity(x, y, z)).getComparatorInputOverride(side); + } + + @Override + public int isProvidingWeakPower(IBlockAccess world, int x, int y, int z, int side) { + return ((TileSpecialFlower) world.getTileEntity(x, y, z)).getPowerLevel(side); + } + + @Override + public int isProvidingStrongPower(IBlockAccess world, int x, int y, int z, int side) { + return isProvidingWeakPower(world, x, y, z, side); + } + + @Override + public boolean canProvidePower() { + return true; + } + + @Override + public int getRenderType() { + return LibRenderIDs.idSpecialFlower; + } + + @Override + public Block setBlockName(String par1Str) { + GameRegistry.registerBlock(this, ItemBlockSpecialFlower.class, par1Str); + return super.setBlockName(par1Str); + } + + @Override + public void getSubBlocks(Item par1, CreativeTabs par2CreativeTabs, List par3List) { + for(String s : BotaniaAPI.subtilesForCreativeMenu) { + par3List.add(ItemBlockSpecialFlower.ofType(s)); + if(BotaniaAPI.miniFlowers.containsKey(s)) + par3List.add(ItemBlockSpecialFlower.ofType(BotaniaAPI.miniFlowers.get(s))); + } + } + + @Override + public void registerBlockIcons(IIconRegister par1IconRegister) { + for(String s : BotaniaAPI.getAllSubTiles()) + if(!s.isEmpty()) + BotaniaAPI.getSignatureForName(s).registerIcons(par1IconRegister); + } + + @Override + public IIcon getIcon(IBlockAccess par1iBlockAccess, int par2, int par3, int par4, int par5) { + return ((TileSpecialFlower) par1iBlockAccess.getTileEntity(par2, par3, par4)).getIcon(); + } + + @Override + public IIcon getIcon(int par1, int par2) { + return BlockModFlower.icons[16]; + } + + @Override + public ItemStack getPickBlock(MovingObjectPosition target, World world, int x, int y, int z) { + String name = ((TileSpecialFlower) world.getTileEntity(x, y, z)).subTileName; + return ItemBlockSpecialFlower.ofType(name); + } + + @Override + protected boolean canPlaceBlockOn(Block block) { + return super.canPlaceBlockOn(block) || block == ModBlocks.redStringRelay || block == Blocks.mycelium; + } + + @Override + public void onBlockHarvested(World par1World, int par2, int par3, int par4, int par5, EntityPlayer par6EntityPlayer) { + if(!par6EntityPlayer.capabilities.isCreativeMode) { + dropBlockAsItem(par1World, par2, par3, par4, par5, 0); + ((TileSpecialFlower) par1World.getTileEntity(par2, par3, par4)).onBlockHarvested(par1World, par2, par3, par4, par5, par6EntityPlayer); + } + } + + @Override + public ArrayList getDrops(World world, int x, int y, int z, int metadata, int fortune) { + ArrayList list = new ArrayList(); + TileEntity tile = world.getTileEntity(x, y, z); + + if(tile != null) { + String name = ((TileSpecialFlower) tile).subTileName; + list.add(ItemBlockSpecialFlower.ofType(name)); + ((TileSpecialFlower) tile).getDrops(list); + } + + return list; + } + + @Override + public boolean onBlockEventReceived(World par1World, int par2, int par3, int par4, int par5, int par6) { + super.onBlockEventReceived(par1World, par2, par3, par4, par5, par6); + TileEntity tileentity = par1World.getTileEntity(par2, par3, par4); + return tileentity != null ? tileentity.receiveClientEvent(par5, par6) : false; + } + + @Override + public TileEntity createNewTileEntity(World world, int meta) { + return new TileSpecialFlower(); + } + + @Override + public LexiconEntry getEntry(World world, int x, int y, int z, EntityPlayer player, ItemStack lexicon) { + return ((TileSpecialFlower) world.getTileEntity(x, y, z)).getEntry(); + } + + @Override + public boolean onUsedByWand(EntityPlayer player, ItemStack stack, World world, int x, int y, int z, int side) { + return ((TileSpecialFlower) world.getTileEntity(x, y, z)).onWanded(stack, player); + } + + @Override + public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase entity, ItemStack stack) { + ((TileSpecialFlower) world.getTileEntity(x, y, z)).onBlockPlacedBy(world, x, y, z, entity, stack); + } + + @Override + public void onBlockAdded(World world, int x, int y, int z) { + ((TileSpecialFlower) world.getTileEntity(x, y, z)).onBlockAdded(world, x, y, z); + } + + @Override + public int colorMultiplier(IBlockAccess world, int x, int y, int z) { + float[] rgb = EntitySheep.fleeceColorTable[world.getBlockMetadata(x, y, z)]; + return ((int) (rgb[0] * 255) << 16) + ((int) (rgb[1] * 255) << 8) + (int) (rgb[2] * 255); + } + + @Override + public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int side, float hitX, float hitY, float hitZ) { + ItemStack stack = player.getCurrentEquippedItem(); + if(stack != null && stack.getItem() == ModItems.dye) { + int newMeta = stack.getItemDamage(); + int oldMeta = world.getBlockMetadata(x, y, z); + if(newMeta != oldMeta) + world.setBlockMetadataWithNotify(x, y, z, newMeta, 1 | 2); + } + + return ((TileSpecialFlower) world.getTileEntity(x, y, z)).onBlockActivated(world, x, y, z, player, side, hitX, hitY, hitZ); + } + + @Override + public void renderHUD(Minecraft mc, ScaledResolution res, World world, int x, int y, int z) { + ((TileSpecialFlower) world.getTileEntity(x, y, z)).renderHUD(mc, res); + } -public class BlockSpecialFlower extends BlockFlower - implements ITileEntityProvider, ISpecialFlower, IWandable, ILexiconable, IWandHUD { - - public static Map icons = new HashMap(); - public static Map iconsAlt = new HashMap(); - - static { - BotaniaAPI.subtilesForCreativeMenu.addAll(Arrays.asList(new String[] { - // Misc - LibBlockNames.SUBTILE_PUREDAISY, - LibBlockNames.SUBTILE_MANASTAR, - - // Generating - LibBlockNames.SUBTILE_DAYBLOOM, - LibBlockNames.SUBTILE_NIGHTSHADE, - LibBlockNames.SUBTILE_ENDOFLAME, - LibBlockNames.SUBTILE_HYDROANGEAS, - LibBlockNames.SUBTILE_THERMALILY, - LibBlockNames.SUBTILE_ARCANE_ROSE, - LibBlockNames.SUBTILE_MUNCHDEW, - LibBlockNames.SUBTILE_ENTROPINNYUM, - LibBlockNames.SUBTILE_KEKIMURUS, - LibBlockNames.SUBTILE_GOURMARYLLIS, - LibBlockNames.SUBTILE_NARSLIMMUS, - LibBlockNames.SUBTILE_SPECTROLUS, - LibBlockNames.SUBTILE_RAFFLOWSIA, - LibBlockNames.SUBTILE_DANDELIFEON, - - // Functional - LibBlockNames.SUBTILE_JADED_AMARANTHUS, - LibBlockNames.SUBTILE_BELLETHORN, - LibBlockNames.SUBTILE_DREADTHORN, - LibBlockNames.SUBTILE_HEISEI_DREAM, - LibBlockNames.SUBTILE_TIGERSEYE, - LibBlockNames.SUBTILE_MARIMORPHOSIS, - LibBlockNames.SUBTILE_ORECHID, - LibBlockNames.SUBTILE_ORECHID_IGNEM, - LibBlockNames.SUBTILE_FALLEN_KANADE, - LibBlockNames.SUBTILE_EXOFLAME, - LibBlockNames.SUBTILE_AGRICARNATION, - LibBlockNames.SUBTILE_HOPPERHOCK, - LibBlockNames.SUBTILE_RANNUNCARPUS, - LibBlockNames.SUBTILE_TANGLEBERRIE, - LibBlockNames.SUBTILE_JIYUULIA, - LibBlockNames.SUBTILE_HYACIDUS, - LibBlockNames.SUBTILE_MEDUMONE, - LibBlockNames.SUBTILE_POLLIDISIAC, - LibBlockNames.SUBTILE_CLAYCONIA, - LibBlockNames.SUBTILE_LOONIUM, - LibBlockNames.SUBTILE_DAFFOMILL, - LibBlockNames.SUBTILE_VINCULOTUS, - LibBlockNames.SUBTILE_SPECTRANTHEMUM, - LibBlockNames.SUBTILE_BUBBELL, - LibBlockNames.SUBTILE_SOLEGNOLIA - })); - } - - protected BlockSpecialFlower() { - super(0); - setBlockName(LibBlockNames.SPECIAL_FLOWER); - setHardness(0.1F); - setStepSound(soundTypeGrass); - setTickRandomly(false); - setCreativeTab(BotaniaCreativeTab.INSTANCE); - setBlockBounds(0.3F, 0.0F, 0.3F, 0.8F, 1, 0.8F); - } - - @Override - public int getLightValue(IBlockAccess world, int x, int y, int z) { - int currentLight = ((TileSpecialFlower) world.getTileEntity(x, y, z)).getLightValue(); - if (currentLight == -1) currentLight = 0; - return LightHelper.getPackedColor(world.getBlockMetadata(x, y, z), currentLight); - } - - @Override - public boolean hasComparatorInputOverride() { - return true; - } - - @Override - public int getComparatorInputOverride(World world, int x, int y, int z, int side) { - return ((TileSpecialFlower) world.getTileEntity(x, y, z)).getComparatorInputOverride(side); - } - - @Override - public int isProvidingWeakPower(IBlockAccess world, int x, int y, int z, int side) { - return ((TileSpecialFlower) world.getTileEntity(x, y, z)).getPowerLevel(side); - } - - @Override - public int isProvidingStrongPower(IBlockAccess world, int x, int y, int z, int side) { - return isProvidingWeakPower(world, x, y, z, side); - } - - @Override - public boolean canProvidePower() { - return true; - } - - @Override - public int getRenderType() { - return LibRenderIDs.idSpecialFlower; - } - - @Override - public Block setBlockName(String par1Str) { - GameRegistry.registerBlock(this, ItemBlockSpecialFlower.class, par1Str); - return super.setBlockName(par1Str); - } - - @Override - public void getSubBlocks(Item par1, CreativeTabs par2CreativeTabs, List par3List) { - for (String s : BotaniaAPI.subtilesForCreativeMenu) { - par3List.add(ItemBlockSpecialFlower.ofType(s)); - if (BotaniaAPI.miniFlowers.containsKey(s)) - par3List.add(ItemBlockSpecialFlower.ofType(BotaniaAPI.miniFlowers.get(s))); - } - } - - @Override - public void registerBlockIcons(IIconRegister par1IconRegister) { - for (String s : BotaniaAPI.getAllSubTiles()) - if (!s.isEmpty()) BotaniaAPI.getSignatureForName(s).registerIcons(par1IconRegister); - } - - @Override - public IIcon getIcon(IBlockAccess par1iBlockAccess, int par2, int par3, int par4, int par5) { - return ((TileSpecialFlower) par1iBlockAccess.getTileEntity(par2, par3, par4)).getIcon(); - } - - @Override - public IIcon getIcon(int par1, int par2) { - return BlockModFlower.icons[16]; - } - - @Override - public ItemStack getPickBlock(MovingObjectPosition target, World world, int x, int y, int z) { - String name = ((TileSpecialFlower) world.getTileEntity(x, y, z)).subTileName; - return ItemBlockSpecialFlower.ofType(name); - } - - @Override - protected boolean canPlaceBlockOn(Block block) { - return super.canPlaceBlockOn(block) || block == ModBlocks.redStringRelay || block == Blocks.mycelium; - } - - @Override - public void onBlockHarvested( - World par1World, int par2, int par3, int par4, int par5, EntityPlayer par6EntityPlayer) { - if (!par6EntityPlayer.capabilities.isCreativeMode) { - dropBlockAsItem(par1World, par2, par3, par4, par5, 0); - ((TileSpecialFlower) par1World.getTileEntity(par2, par3, par4)) - .onBlockHarvested(par1World, par2, par3, par4, par5, par6EntityPlayer); - } - } - - @Override - public ArrayList getDrops(World world, int x, int y, int z, int metadata, int fortune) { - ArrayList list = new ArrayList(); - TileEntity tile = world.getTileEntity(x, y, z); - - if (tile != null) { - String name = ((TileSpecialFlower) tile).subTileName; - list.add(ItemBlockSpecialFlower.ofType(name)); - ((TileSpecialFlower) tile).getDrops(list); - } - - return list; - } - - @Override - public boolean onBlockEventReceived(World par1World, int par2, int par3, int par4, int par5, int par6) { - super.onBlockEventReceived(par1World, par2, par3, par4, par5, par6); - TileEntity tileentity = par1World.getTileEntity(par2, par3, par4); - return tileentity != null ? tileentity.receiveClientEvent(par5, par6) : false; - } - - @Override - public TileEntity createNewTileEntity(World world, int meta) { - return new TileSpecialFlower(); - } - - @Override - public LexiconEntry getEntry(World world, int x, int y, int z, EntityPlayer player, ItemStack lexicon) { - return ((TileSpecialFlower) world.getTileEntity(x, y, z)).getEntry(); - } - - @Override - public boolean onUsedByWand(EntityPlayer player, ItemStack stack, World world, int x, int y, int z, int side) { - return ((TileSpecialFlower) world.getTileEntity(x, y, z)).onWanded(stack, player); - } - - @Override - public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase entity, ItemStack stack) { - ((TileSpecialFlower) world.getTileEntity(x, y, z)).onBlockPlacedBy(world, x, y, z, entity, stack); - } - - @Override - public void onBlockAdded(World world, int x, int y, int z) { - ((TileSpecialFlower) world.getTileEntity(x, y, z)).onBlockAdded(world, x, y, z); - } - - @Override - public int colorMultiplier(IBlockAccess world, int x, int y, int z) { - float[] rgb = EntitySheep.fleeceColorTable[world.getBlockMetadata(x, y, z)]; - return ((int) (rgb[0] * 255) << 16) + ((int) (rgb[1] * 255) << 8) + (int) (rgb[2] * 255); - } - - @Override - public boolean onBlockActivated( - World world, int x, int y, int z, EntityPlayer player, int side, float hitX, float hitY, float hitZ) { - ItemStack stack = player.getCurrentEquippedItem(); - if (stack != null && stack.getItem() == ModItems.dye) { - int newMeta = stack.getItemDamage(); - int oldMeta = world.getBlockMetadata(x, y, z); - if (newMeta != oldMeta) world.setBlockMetadataWithNotify(x, y, z, newMeta, 1 | 2); - } - - return ((TileSpecialFlower) world.getTileEntity(x, y, z)) - .onBlockActivated(world, x, y, z, player, side, hitX, hitY, hitZ); - } - - @Override - public void renderHUD(Minecraft mc, ScaledResolution res, World world, int x, int y, int z) { - ((TileSpecialFlower) world.getTileEntity(x, y, z)).renderHUD(mc, res); - } } diff --git a/src/main/java/vazkii/botania/common/block/BlockStorage.java b/src/main/java/vazkii/botania/common/block/BlockStorage.java index 743c90c461..bf35e1173b 100644 --- a/src/main/java/vazkii/botania/common/block/BlockStorage.java +++ b/src/main/java/vazkii/botania/common/block/BlockStorage.java @@ -2,18 +2,16 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [May 14, 2014, 8:37:26 PM (GMT)] */ package vazkii.botania.common.block; -import cpw.mods.fml.common.registry.GameRegistry; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; import java.util.List; + import net.minecraft.block.Block; import net.minecraft.block.material.Material; import net.minecraft.client.renderer.texture.IIconRegister; @@ -30,62 +28,68 @@ import vazkii.botania.common.item.block.ItemBlockStorage; import vazkii.botania.common.lexicon.LexiconData; import vazkii.botania.common.lib.LibBlockNames; +import cpw.mods.fml.common.registry.GameRegistry; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; public class BlockStorage extends BlockMod implements ILexiconable { - private static final int SUBTYPES = 5; + private static final int SUBTYPES = 5; + + IIcon[] icons; - IIcon[] icons; + public BlockStorage() { + super(Material.iron); + setHardness(3F); + setResistance(10F); + setStepSound(soundTypeMetal); + setBlockName(LibBlockNames.STORAGE); + } - public BlockStorage() { - super(Material.iron); - setHardness(3F); - setResistance(10F); - setStepSound(soundTypeMetal); - setBlockName(LibBlockNames.STORAGE); - } + @Override + public void getSubBlocks(Item par1, CreativeTabs par2, List par3) { + for(int i = 0; i < SUBTYPES; i++) + par3.add(new ItemStack(par1, 1, i)); + } - @Override - public void getSubBlocks(Item par1, CreativeTabs par2, List par3) { - for (int i = 0; i < SUBTYPES; i++) par3.add(new ItemStack(par1, 1, i)); - } + @Override + public Block setBlockName(String par1Str) { + GameRegistry.registerBlock(this, ItemBlockStorage.class, par1Str); + return super.setBlockName(par1Str); + } - @Override - public Block setBlockName(String par1Str) { - GameRegistry.registerBlock(this, ItemBlockStorage.class, par1Str); - return super.setBlockName(par1Str); - } + @Override + public int damageDropped(int meta) { + return meta; + } - @Override - public int damageDropped(int meta) { - return meta; - } + @Override + protected boolean shouldRegisterInNameSet() { + return false; + } - @Override - protected boolean shouldRegisterInNameSet() { - return false; - } + @Override + @SideOnly(Side.CLIENT) + public void registerBlockIcons(IIconRegister par1IconRegister) { + icons = new IIcon[SUBTYPES]; + for(int i = 0; i < icons.length; i++) + icons[i] = IconHelper.forBlock(par1IconRegister, this, i); + } - @Override - @SideOnly(Side.CLIENT) - public void registerBlockIcons(IIconRegister par1IconRegister) { - icons = new IIcon[SUBTYPES]; - for (int i = 0; i < icons.length; i++) icons[i] = IconHelper.forBlock(par1IconRegister, this, i); - } + @Override + public IIcon getIcon(int par1, int par2) { + return icons[Math.min(icons.length - 1, par2)]; + } - @Override - public IIcon getIcon(int par1, int par2) { - return icons[Math.min(icons.length - 1, par2)]; - } + @Override + public boolean isBeaconBase(IBlockAccess worldObj, int x, int y, int z, int beaconX, int beaconY, int beaconZ) { + return true; + } - @Override - public boolean isBeaconBase(IBlockAccess worldObj, int x, int y, int z, int beaconX, int beaconY, int beaconZ) { - return true; - } + @Override + public LexiconEntry getEntry(World world, int x, int y, int z, EntityPlayer player, ItemStack lexicon) { + int meta = world.getBlockMetadata(x, y, z); + return meta == 0 ? LexiconData.pool : LexiconData.terrasteel; + } - @Override - public LexiconEntry getEntry(World world, int x, int y, int z, EntityPlayer player, ItemStack lexicon) { - int meta = world.getBlockMetadata(x, y, z); - return meta == 0 ? LexiconData.pool : LexiconData.terrasteel; - } } diff --git a/src/main/java/vazkii/botania/common/block/BlockTeruTeruBozu.java b/src/main/java/vazkii/botania/common/block/BlockTeruTeruBozu.java index 1a1b7a419f..30e15f7177 100644 --- a/src/main/java/vazkii/botania/common/block/BlockTeruTeruBozu.java +++ b/src/main/java/vazkii/botania/common/block/BlockTeruTeruBozu.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Oct 1, 2015, 1:11:26 PM (GMT)] */ package vazkii.botania.common.block; @@ -30,102 +30,105 @@ public class BlockTeruTeruBozu extends BlockModContainer implements ILexiconable { - public BlockTeruTeruBozu() { - super(Material.cloth); - setBlockName(LibBlockNames.TERU_TERU_BOZU); - float f = 0.25F; - setBlockBounds(f, 0.01F, f, 1F - f, 0.99F, 1F - f); - } - - @Override - public void onEntityCollidedWithBlock(World world, int x, int y, int z, Entity e) { - if (!world.isRemote && e instanceof EntityItem) { - EntityItem item = (EntityItem) e; - ItemStack stack = item.getEntityItem(); - if (isSunflower(stack) && removeRain(world)) { - stack.stackSize--; - if (stack.stackSize == 0) e.setDead(); - } - } - } - - @Override - public boolean onBlockActivated( - World world, int x, int y, int z, EntityPlayer player, int s, float xs, float ys, float zs) { - ItemStack stack = player.getCurrentEquippedItem(); - if (stack != null && (isSunflower(stack) && removeRain(world) || isBlueOrchid(stack) && startRain(world))) { - if (!player.capabilities.isCreativeMode) stack.stackSize--; - return true; - } - return false; - } - - public boolean isSunflower(ItemStack stack) { - return stack.getItem() == Item.getItemFromBlock(Blocks.double_plant) && stack.getItemDamage() == 0; - } - - public boolean isBlueOrchid(ItemStack stack) { - return stack.getItem() == Item.getItemFromBlock(Blocks.red_flower) && stack.getItemDamage() == 1; - } - - public boolean removeRain(World world) { - if (world.isRaining()) { - world.getWorldInfo().setRaining(false); - return true; - } - return false; - } - - public boolean startRain(World world) { - if (!world.isRaining()) { - if (world.rand.nextInt(10) == 0) world.getWorldInfo().setRaining(true); - return true; - } - return false; - } - - @Override - public boolean hasComparatorInputOverride() { - return true; - } - - @Override - public int getComparatorInputOverride(World world, int x, int y, int z, int s) { - return world.isRaining() ? 15 : 0; - } - - @Override - public void registerBlockIcons(IIconRegister par1IconRegister) { - // NO-OP - } - - @Override - public IIcon getIcon(int side, int meta) { - return Blocks.wool.getIcon(0, 0); - } - - @Override - public boolean isOpaqueCube() { - return false; - } - - @Override - public boolean renderAsNormalBlock() { - return false; - } - - @Override - public int getRenderType() { - return LibRenderIDs.idTeruTeruBozu; - } - - @Override - public TileEntity createNewTileEntity(World world, int meta) { - return new TileTeruTeruBozu(); - } - - @Override - public LexiconEntry getEntry(World world, int x, int y, int z, EntityPlayer player, ItemStack lexicon) { - return LexiconData.teruTeruBozu; - } + public BlockTeruTeruBozu() { + super(Material.cloth); + setBlockName(LibBlockNames.TERU_TERU_BOZU); + float f = 0.25F; + setBlockBounds(f, 0.01F, f, 1F - f, 0.99F, 1F - f); + } + + @Override + public void onEntityCollidedWithBlock(World world, int x, int y, int z, Entity e) { + if(!world.isRemote && e instanceof EntityItem) { + EntityItem item = (EntityItem) e; + ItemStack stack = item.getEntityItem(); + if(isSunflower(stack) && removeRain(world)) { + stack.stackSize--; + if(stack.stackSize == 0) + e.setDead(); + } + } + } + + @Override + public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int s, float xs, float ys, float zs) { + ItemStack stack = player.getCurrentEquippedItem(); + if(stack != null && (isSunflower(stack) && removeRain(world) || isBlueOrchid(stack) && startRain(world))) { + if(!player.capabilities.isCreativeMode) + stack.stackSize--; + return true; + } + return false; + } + + public boolean isSunflower(ItemStack stack) { + return stack.getItem() == Item.getItemFromBlock(Blocks.double_plant) && stack.getItemDamage() == 0; + } + + public boolean isBlueOrchid(ItemStack stack) { + return stack.getItem() == Item.getItemFromBlock(Blocks.red_flower) && stack.getItemDamage() == 1; + } + + public boolean removeRain(World world) { + if(world.isRaining()) { + world.getWorldInfo().setRaining(false); + return true; + } + return false; + } + + public boolean startRain(World world) { + if(!world.isRaining()) { + if(world.rand.nextInt(10) == 0) + world.getWorldInfo().setRaining(true); + return true; + } + return false; + } + + @Override + public boolean hasComparatorInputOverride() { + return true; + } + + @Override + public int getComparatorInputOverride(World world, int x, int y, int z, int s) { + return world.isRaining() ? 15 : 0; + } + + @Override + public void registerBlockIcons(IIconRegister par1IconRegister) { + // NO-OP + } + + @Override + public IIcon getIcon(int side, int meta) { + return Blocks.wool.getIcon(0, 0); + } + + @Override + public boolean isOpaqueCube() { + return false; + } + + @Override + public boolean renderAsNormalBlock() { + return false; + } + + @Override + public int getRenderType() { + return LibRenderIDs.idTeruTeruBozu; + } + + @Override + public TileEntity createNewTileEntity(World world, int meta) { + return new TileTeruTeruBozu(); + } + + @Override + public LexiconEntry getEntry(World world, int x, int y, int z, EntityPlayer player, ItemStack lexicon) { + return LexiconData.teruTeruBozu; + } + } diff --git a/src/main/java/vazkii/botania/common/block/BlockTinyPlanet.java b/src/main/java/vazkii/botania/common/block/BlockTinyPlanet.java index 1ea0075494..6720700cf5 100644 --- a/src/main/java/vazkii/botania/common/block/BlockTinyPlanet.java +++ b/src/main/java/vazkii/botania/common/block/BlockTinyPlanet.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [May 1, 2014, 3:49:12 PM (GMT)] */ package vazkii.botania.common.block; @@ -23,33 +23,34 @@ public class BlockTinyPlanet extends BlockModContainer implements ILexiconable { - protected BlockTinyPlanet() { - super(Material.rock); - setHardness(20F); - setResistance(100F); - setStepSound(soundTypeStone); - float size = 3F / 16F; - setBlockBounds(size, size, size, 1F - size, 1F - size, 1F - size); - setBlockName(LibBlockNames.TINY_PLANET); - } - - @Override - public boolean renderAsNormalBlock() { - return false; - } - - @Override - public boolean isOpaqueCube() { - return false; - } - - @Override - public TileEntity createNewTileEntity(World world, int meta) { - return new TileTinyPlanet(); - } - - @Override - public LexiconEntry getEntry(World world, int x, int y, int z, EntityPlayer player, ItemStack lexicon) { - return LexiconData.tinyPlanet; - } + protected BlockTinyPlanet() { + super(Material.rock); + setHardness(20F); + setResistance(100F); + setStepSound(soundTypeStone); + float size = 3F / 16F; + setBlockBounds(size, size, size, 1F - size, 1F - size, 1F - size); + setBlockName(LibBlockNames.TINY_PLANET); + } + + @Override + public boolean renderAsNormalBlock() { + return false; + } + + @Override + public boolean isOpaqueCube() { + return false; + } + + @Override + public TileEntity createNewTileEntity(World world, int meta) { + return new TileTinyPlanet(); + } + + @Override + public LexiconEntry getEntry(World world, int x, int y, int z, EntityPlayer player, ItemStack lexicon) { + return LexiconData.tinyPlanet; + } + } diff --git a/src/main/java/vazkii/botania/common/block/ModBlocks.java b/src/main/java/vazkii/botania/common/block/ModBlocks.java index ff4057c117..075722c82e 100644 --- a/src/main/java/vazkii/botania/common/block/ModBlocks.java +++ b/src/main/java/vazkii/botania/common/block/ModBlocks.java @@ -2,16 +2,14 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jan 14, 2014, 5:17:55 PM (GMT)] */ package vazkii.botania.common.block; -import cpw.mods.fml.common.Loader; -import cpw.mods.fml.common.registry.GameRegistry; import net.minecraft.block.Block; import net.minecraft.block.BlockDispenser; import net.minecraft.init.Blocks; @@ -175,371 +173,370 @@ import vazkii.botania.common.item.ModItems; import vazkii.botania.common.lib.LibBlockNames; import vazkii.botania.common.lib.LibOreDict; +import cpw.mods.fml.common.Loader; +import cpw.mods.fml.common.registry.GameRegistry; public final class ModBlocks { - public static Block flower; - public static Block altar; - public static Block livingrock; - public static Block livingwood; - public static Block specialFlower; - public static Block spreader; - public static Block pool; - public static Block runeAltar; - public static Block unstableBlock; - public static Block pylon; - public static Block pistonRelay; - public static Block distributor; - public static Block manaBeacon; - public static Block manaVoid; - public static Block manaDetector; - public static Block enchanter; - public static Block turntable; - public static Block tinyPlanet; - public static Block alchemyCatalyst; - public static Block openCrate; - public static Block forestEye; - public static Block storage; - public static Block forestDrum; - public static Block shinyFlower; - public static Block platform; - public static Block alfPortal; - public static Block dreamwood; - public static Block conjurationCatalyst; - public static Block bifrost; - public static Block solidVines; - public static Block buriedPetals; - public static Block prismarine; - public static Block seaLamp; - public static Block floatingFlower; - public static Block tinyPotato; - public static Block spawnerClaw; - public static Block reedBlock; - public static Block thatch; - public static Block customBrick; - public static Block enderEye; - public static Block starfield; - public static Block rfGenerator; - public static Block elfGlass; - public static Block brewery; - public static Block manaGlass; - public static Block terraPlate; - public static Block redStringContainer; - public static Block redStringDispenser; - public static Block redStringFertilizer; - public static Block redStringComparator; - public static Block redStringRelay; - public static Block floatingSpecialFlower; - public static Block manaFlame; - public static Block prism; - public static Block dirtPath; - public static Block enchantedSoil; - public static Block petalBlock; - public static Block corporeaIndex; - public static Block corporeaFunnel; - public static Block endStoneBrick; - public static Block mushroom; - public static Block pump; - public static Block doubleFlower1; - public static Block doubleFlower2; - public static Block fakeAir; - public static Block blazeBlock; - public static Block corporeaInterceptor; - public static Block corporeaCrystalCube; - public static Block incensePlate; - public static Block hourglass; - public static Block ghostRail; - public static Block sparkChanger; - public static Block root; - public static Block felPumpkin; - public static Block cocoon; - public static Block lightRelay; - public static Block lightLauncher; - public static Block manaBomb; - public static Block cacophonium; - public static Block bellows; - public static Block bifrostPerm; - public static Block cellBlock; - public static Block redStringInterceptor; - public static Block gaiaHead; - public static Block corporeaRetainer; - public static Block teruTeruBozu; - public static Block shimmerrock; - public static Block shimmerwoodPlanks; - public static Block avatar; - public static Block altGrass; + public static Block flower; + public static Block altar; + public static Block livingrock; + public static Block livingwood; + public static Block specialFlower; + public static Block spreader; + public static Block pool; + public static Block runeAltar; + public static Block unstableBlock; + public static Block pylon; + public static Block pistonRelay; + public static Block distributor; + public static Block manaBeacon; + public static Block manaVoid; + public static Block manaDetector; + public static Block enchanter; + public static Block turntable; + public static Block tinyPlanet; + public static Block alchemyCatalyst; + public static Block openCrate; + public static Block forestEye; + public static Block storage; + public static Block forestDrum; + public static Block shinyFlower; + public static Block platform; + public static Block alfPortal; + public static Block dreamwood; + public static Block conjurationCatalyst; + public static Block bifrost; + public static Block solidVines; + public static Block buriedPetals; + public static Block prismarine; + public static Block seaLamp; + public static Block floatingFlower; + public static Block tinyPotato; + public static Block spawnerClaw; + public static Block reedBlock; + public static Block thatch; + public static Block customBrick; + public static Block enderEye; + public static Block starfield; + public static Block rfGenerator; + public static Block elfGlass; + public static Block brewery; + public static Block manaGlass; + public static Block terraPlate; + public static Block redStringContainer; + public static Block redStringDispenser; + public static Block redStringFertilizer; + public static Block redStringComparator; + public static Block redStringRelay; + public static Block floatingSpecialFlower; + public static Block manaFlame; + public static Block prism; + public static Block dirtPath; + public static Block enchantedSoil; + public static Block petalBlock; + public static Block corporeaIndex; + public static Block corporeaFunnel; + public static Block endStoneBrick; + public static Block mushroom; + public static Block pump; + public static Block doubleFlower1; + public static Block doubleFlower2; + public static Block fakeAir; + public static Block blazeBlock; + public static Block corporeaInterceptor; + public static Block corporeaCrystalCube; + public static Block incensePlate; + public static Block hourglass; + public static Block ghostRail; + public static Block sparkChanger; + public static Block root; + public static Block felPumpkin; + public static Block cocoon; + public static Block lightRelay; + public static Block lightLauncher; + public static Block manaBomb; + public static Block cacophonium; + public static Block bellows; + public static Block bifrostPerm; + public static Block cellBlock; + public static Block redStringInterceptor; + public static Block gaiaHead; + public static Block corporeaRetainer; + public static Block teruTeruBozu; + public static Block shimmerrock; + public static Block shimmerwoodPlanks; + public static Block avatar; + public static Block altGrass; + + public static void init() { + flower = new BlockModFlower(); + altar = new BlockAltar(); + livingrock = new BlockLivingrock(); + livingwood = new BlockLivingwood(); + specialFlower = new BlockSpecialFlower(); + spreader = new BlockSpreader(); + pool = new BlockPool(); + runeAltar = new BlockRuneAltar(); + unstableBlock = new BlockUnstable(); + pylon = new BlockPylon(); + pistonRelay = new BlockPistonRelay(); + distributor = new BlockDistributor(); + manaBeacon = new BlockManaBeacon(); + manaVoid = new BlockManaVoid(); + manaDetector = new BlockManaDetector(); + enchanter = new BlockEnchanter(); + turntable = new BlockTurntable(); + tinyPlanet = new BlockTinyPlanet(); + alchemyCatalyst = new BlockAlchemyCatalyst(); + openCrate = new BlockOpenCrate(); + forestEye = new BlockForestEye(); + storage = new BlockStorage(); + forestDrum = new BlockForestDrum(); + shinyFlower = new BlockShinyFlower(); + platform = new BlockPlatform(); + alfPortal = new BlockAlfPortal(); + dreamwood = new BlockDreamwood(); + conjurationCatalyst = new BlockConjurationCatalyst(); + bifrost = new BlockBifrost(); + solidVines = new BlockSolidVines(); + buriedPetals = new BlockBuriedPetals(); + prismarine = new BlockPrismarine(); + seaLamp = new BlockSeaLamp(); + floatingFlower = new BlockFloatingFlower(); + tinyPotato = new BlockTinyPotato(); + spawnerClaw = new BlockSpawnerClaw(); + reedBlock = new BlockReeds(); + thatch = new BlockThatch(); + customBrick = new BlockCustomBrick(); + enderEye = new BlockEnderEye(); + starfield = new BlockStarfield(); + rfGenerator = new BlockRFGenerator(); + elfGlass = new BlockElfGlass(); + brewery = new BlockBrewery(); + manaGlass = new BlockManaGlass(); + terraPlate = new BlockTerraPlate(); + redStringContainer = new BlockRedStringContainer(); + redStringDispenser = new BlockRedStringDispenser(); + redStringFertilizer = new BlockRedStringFertilizer(); + redStringComparator = new BlockRedStringComparator(); + redStringRelay = new BlockRedStringRelay(); + floatingSpecialFlower = new BlockFloatingSpecialFlower(); + manaFlame = new BlockManaFlame(); + prism = new BlockPrism(); + dirtPath = new BlockDirtPath(); + enchantedSoil = new BlockEnchantedSoil(); + petalBlock = new BlockPetalBlock(); + corporeaIndex = new BlockCorporeaIndex(); + corporeaFunnel = new BlockCorporeaFunnel(); + endStoneBrick = new BlockEndStoneBrick(); + mushroom = new BlockModMushroom(); + pump = new BlockPump(); + doubleFlower1 = new BlockModDoubleFlower(false); + doubleFlower2 = new BlockModDoubleFlower(true); + fakeAir = new BlockFakeAir(); + blazeBlock = new BlockBlaze(); + corporeaInterceptor = new BlockCorporeaInterceptor(); + corporeaCrystalCube = new BlockCorporeaCrystalCube(); + incensePlate = new BlockIncensePlate(); + hourglass = new BlockHourglass(); + ghostRail = new BlockGhostRail(); + sparkChanger = new BlockSparkChanger(); + root = new BlockRoot(); + felPumpkin = new BlockFelPumpkin(); + cocoon = new BlockCocoon(); + lightRelay = new BlockLightRelay(); + lightLauncher = new BlockLightLauncher(); + manaBomb = new BlockManaBomb(); + cacophonium = new BlockCacophonium(); + bellows = new BlockBellows(); + bifrostPerm = new BlockBifrostPerm(); + cellBlock = new BlockCell(); + redStringInterceptor = new BlockRedStringInterceptor(); + gaiaHead = new BlockGaiaHead(); + corporeaRetainer = new BlockCorporeaRetainer(); + teruTeruBozu = new BlockTeruTeruBozu(); + shimmerrock = new BlockShimmerrock(); + shimmerwoodPlanks = new BlockShimmerwoodPlanks(); + avatar = new BlockAvatar(); + altGrass = new BlockAltGrass(); - public static void init() { - flower = new BlockModFlower(); - altar = new BlockAltar(); - livingrock = new BlockLivingrock(); - livingwood = new BlockLivingwood(); - specialFlower = new BlockSpecialFlower(); - spreader = new BlockSpreader(); - pool = new BlockPool(); - runeAltar = new BlockRuneAltar(); - unstableBlock = new BlockUnstable(); - pylon = new BlockPylon(); - pistonRelay = new BlockPistonRelay(); - distributor = new BlockDistributor(); - manaBeacon = new BlockManaBeacon(); - manaVoid = new BlockManaVoid(); - manaDetector = new BlockManaDetector(); - enchanter = new BlockEnchanter(); - turntable = new BlockTurntable(); - tinyPlanet = new BlockTinyPlanet(); - alchemyCatalyst = new BlockAlchemyCatalyst(); - openCrate = new BlockOpenCrate(); - forestEye = new BlockForestEye(); - storage = new BlockStorage(); - forestDrum = new BlockForestDrum(); - shinyFlower = new BlockShinyFlower(); - platform = new BlockPlatform(); - alfPortal = new BlockAlfPortal(); - dreamwood = new BlockDreamwood(); - conjurationCatalyst = new BlockConjurationCatalyst(); - bifrost = new BlockBifrost(); - solidVines = new BlockSolidVines(); - buriedPetals = new BlockBuriedPetals(); - prismarine = new BlockPrismarine(); - seaLamp = new BlockSeaLamp(); - floatingFlower = new BlockFloatingFlower(); - tinyPotato = new BlockTinyPotato(); - spawnerClaw = new BlockSpawnerClaw(); - reedBlock = new BlockReeds(); - thatch = new BlockThatch(); - customBrick = new BlockCustomBrick(); - enderEye = new BlockEnderEye(); - starfield = new BlockStarfield(); - rfGenerator = new BlockRFGenerator(); - elfGlass = new BlockElfGlass(); - brewery = new BlockBrewery(); - manaGlass = new BlockManaGlass(); - terraPlate = new BlockTerraPlate(); - redStringContainer = new BlockRedStringContainer(); - redStringDispenser = new BlockRedStringDispenser(); - redStringFertilizer = new BlockRedStringFertilizer(); - redStringComparator = new BlockRedStringComparator(); - redStringRelay = new BlockRedStringRelay(); - floatingSpecialFlower = new BlockFloatingSpecialFlower(); - manaFlame = new BlockManaFlame(); - prism = new BlockPrism(); - dirtPath = new BlockDirtPath(); - enchantedSoil = new BlockEnchantedSoil(); - petalBlock = new BlockPetalBlock(); - corporeaIndex = new BlockCorporeaIndex(); - corporeaFunnel = new BlockCorporeaFunnel(); - endStoneBrick = new BlockEndStoneBrick(); - mushroom = new BlockModMushroom(); - pump = new BlockPump(); - doubleFlower1 = new BlockModDoubleFlower(false); - doubleFlower2 = new BlockModDoubleFlower(true); - fakeAir = new BlockFakeAir(); - blazeBlock = new BlockBlaze(); - corporeaInterceptor = new BlockCorporeaInterceptor(); - corporeaCrystalCube = new BlockCorporeaCrystalCube(); - incensePlate = new BlockIncensePlate(); - hourglass = new BlockHourglass(); - ghostRail = new BlockGhostRail(); - sparkChanger = new BlockSparkChanger(); - root = new BlockRoot(); - felPumpkin = new BlockFelPumpkin(); - cocoon = new BlockCocoon(); - lightRelay = new BlockLightRelay(); - lightLauncher = new BlockLightLauncher(); - manaBomb = new BlockManaBomb(); - cacophonium = new BlockCacophonium(); - bellows = new BlockBellows(); - bifrostPerm = new BlockBifrostPerm(); - cellBlock = new BlockCell(); - redStringInterceptor = new BlockRedStringInterceptor(); - gaiaHead = new BlockGaiaHead(); - corporeaRetainer = new BlockCorporeaRetainer(); - teruTeruBozu = new BlockTeruTeruBozu(); - shimmerrock = new BlockShimmerrock(); - shimmerwoodPlanks = new BlockShimmerwoodPlanks(); - avatar = new BlockAvatar(); - altGrass = new BlockAltGrass(); + ModFluffBlocks.init(); - ModFluffBlocks.init(); + for(int i = 0; i < 16; i++) + OreDictionary.registerOre(LibOreDict.FLOWER[i], new ItemStack(flower, 1, i)); - for (int i = 0; i < 16; i++) OreDictionary.registerOre(LibOreDict.FLOWER[i], new ItemStack(flower, 1, i)); + OreDictionary.registerOre(LibOreDict.LIVING_ROCK, livingrock); + OreDictionary.registerOre(LibOreDict.LIVING_WOOD, livingwood); + OreDictionary.registerOre(LibOreDict.DREAM_WOOD, dreamwood); - OreDictionary.registerOre(LibOreDict.LIVING_ROCK, livingrock); - OreDictionary.registerOre(LibOreDict.LIVING_WOOD, livingwood); - OreDictionary.registerOre(LibOreDict.DREAM_WOOD, dreamwood); + for(int i = 0; i < 8; i++) { + OreDictionary.registerOre(LibOreDict.DOUBLE_FLOWER[i], new ItemStack(doubleFlower1, 1, i)); + OreDictionary.registerOre(LibOreDict.DOUBLE_FLOWER[i + 8], new ItemStack(doubleFlower2, 1, i)); + } - for (int i = 0; i < 8; i++) { - OreDictionary.registerOre(LibOreDict.DOUBLE_FLOWER[i], new ItemStack(doubleFlower1, 1, i)); - OreDictionary.registerOre(LibOreDict.DOUBLE_FLOWER[i + 8], new ItemStack(doubleFlower2, 1, i)); - } + OreDictionary.registerOre(LibOreDict.PRISMARINE_BLOCK, new ItemStack(prismarine, 1, OreDictionary.WILDCARD_VALUE)); + OreDictionary.registerOre(LibOreDict.BLAZE_BLOCK, blazeBlock); - OreDictionary.registerOre( - LibOreDict.PRISMARINE_BLOCK, new ItemStack(prismarine, 1, OreDictionary.WILDCARD_VALUE)); - OreDictionary.registerOre(LibOreDict.BLAZE_BLOCK, blazeBlock); + for(int i = 0; i < 16; i++) + OreDictionary.registerOre(LibOreDict.STONE_18_VARIANTS[i], new ItemStack(ModFluffBlocks.stone, 1, i)); - for (int i = 0; i < 16; i++) - OreDictionary.registerOre(LibOreDict.STONE_18_VARIANTS[i], new ItemStack(ModFluffBlocks.stone, 1, i)); + // Vanilla OreDict entries + OreDictionary.registerOre("dirt", Blocks.dirt); + OreDictionary.registerOre("grass", Blocks.grass); + OreDictionary.registerOre("sand", Block.getBlockFromName("sand")); + OreDictionary.registerOre("gravel", Block.getBlockFromName("gravel")); + OreDictionary.registerOre("hardenedClay", new ItemStack(Blocks.hardened_clay, 1, OreDictionary.WILDCARD_VALUE)); + OreDictionary.registerOre("snowLayer", Blocks.snow_layer); + OreDictionary.registerOre("mycelium", Blocks.mycelium); + OreDictionary.registerOre("podzol", new ItemStack(Blocks.dirt, 1, 2)); + OreDictionary.registerOre("netherrack", Blocks.netherrack); + OreDictionary.registerOre("soulSand", Blocks.soul_sand); + OreDictionary.registerOre("ice", Blocks.ice); + OreDictionary.registerOre("slabCobblestone", new ItemStack(Blocks.stone_slab, 1, 3)); + OreDictionary.registerOre("chestWood", Blocks.chest); + OreDictionary.registerOre("craftingTableWood", Blocks.crafting_table); - // Vanilla OreDict entries - OreDictionary.registerOre("dirt", Blocks.dirt); - OreDictionary.registerOre("grass", Blocks.grass); - OreDictionary.registerOre("sand", Block.getBlockFromName("sand")); - OreDictionary.registerOre("gravel", Block.getBlockFromName("gravel")); - OreDictionary.registerOre("hardenedClay", new ItemStack(Blocks.hardened_clay, 1, OreDictionary.WILDCARD_VALUE)); - OreDictionary.registerOre("snowLayer", Blocks.snow_layer); - OreDictionary.registerOre("mycelium", Blocks.mycelium); - OreDictionary.registerOre("podzol", new ItemStack(Blocks.dirt, 1, 2)); - OreDictionary.registerOre("netherrack", Blocks.netherrack); - OreDictionary.registerOre("soulSand", Blocks.soul_sand); - OreDictionary.registerOre("ice", Blocks.ice); - OreDictionary.registerOre("slabCobblestone", new ItemStack(Blocks.stone_slab, 1, 3)); - OreDictionary.registerOre("chestWood", Blocks.chest); - OreDictionary.registerOre("craftingTableWood", Blocks.crafting_table); + BotaniaAPI.registerPaintableBlock(unstableBlock); + BotaniaAPI.registerPaintableBlock(manaBeacon); - BotaniaAPI.registerPaintableBlock(unstableBlock); - BotaniaAPI.registerPaintableBlock(manaBeacon); + initTileEntities(); + } - initTileEntities(); - } + public static void addDispenserBehaviours() { + for(Item seed : BotaniaAPI.seeds.keySet()) + BlockDispenser.dispenseBehaviorRegistry.putObject(seed, new BehaviourSeeds(BotaniaAPI.seeds.get(seed))); + BlockDispenser.dispenseBehaviorRegistry.putObject(ModItems.twigWand, new BehaviourWand()); + BlockDispenser.dispenseBehaviorRegistry.putObject(ModItems.poolMinecart, new BehaviourPoolMinecart()); + } - public static void addDispenserBehaviours() { - for (Item seed : BotaniaAPI.seeds.keySet()) - BlockDispenser.dispenseBehaviorRegistry.putObject(seed, new BehaviourSeeds(BotaniaAPI.seeds.get(seed))); - BlockDispenser.dispenseBehaviorRegistry.putObject(ModItems.twigWand, new BehaviourWand()); - BlockDispenser.dispenseBehaviorRegistry.putObject(ModItems.poolMinecart, new BehaviourPoolMinecart()); - } + private static void initTileEntities() { + registerTile(TileAltar.class, LibBlockNames.ALTAR); + registerTile(TileSpecialFlower.class, LibBlockNames.SPECIAL_FLOWER); + registerTile(TileSpreader.class, LibBlockNames.SPREADER); + registerTile(TilePool.class, LibBlockNames.POOL); + registerTile(TileRuneAltar.class, LibBlockNames.RUNE_ALTAR); + registerTile(TilePylon.class, LibBlockNames.PYLON); + registerTile(TileDistributor.class, LibBlockNames.DISTRIBUTOR); + registerTile(TileManaBeacon.class, LibBlockNames.MANA_BEACON); + registerTile(TileManaVoid.class, LibBlockNames.MANA_VOID); + registerTile(TileManaDetector.class, LibBlockNames.MANA_DETECTOR); + registerTile(TileEnchanter.class, LibBlockNames.ENCHANTER); + registerTile(TileTurntable.class, LibBlockNames.TURNTABLE); + registerTile(TileTinyPlanet.class, LibBlockNames.TINY_PLANET); + registerTile(TileOpenCrate.class, LibBlockNames.OPEN_CRATE); + registerTile(TileCraftCrate.class, LibBlockNames.CRAFT_CRATE); + registerTile(TileForestEye.class, LibBlockNames.FOREST_EYE); + registerTile(TilePlatform.class, LibBlockNames.PLATFORM); + registerTile(TileAlfPortal.class, LibBlockNames.ALF_PORTAL); + registerTile(TileBifrost.class, LibBlockNames.BIFROST); + registerTile(TileFloatingFlower.class, LibBlockNames.MINI_ISLAND); + registerTile(TileTinyPotato.class, LibBlockNames.TINY_POTATO); + registerTile(TileSpawnerClaw.class, LibBlockNames.SPAWNER_CLAW); + registerTile(TileEnderEye.class, LibBlockNames.ENDER_EYE_BLOCK); + registerTile(TileStarfield.class, LibBlockNames.STARFIELD); + registerTile(TileRFGenerator.class, LibBlockNames.RF_GENERATOR); + registerTile(TileBrewery.class, LibBlockNames.BREWERY); + registerTile(TileTerraPlate.class, LibBlockNames.TERRA_PLATE); + registerTile(TileRedStringContainer.class, LibBlockNames.RED_STRING_CONTAINER); + registerTile(TileRedStringDispenser.class, LibBlockNames.RED_STRING_DISPENSER); + registerTile(TileRedStringFertilizer.class, LibBlockNames.RED_STRING_FERTILIZER); + registerTile(TileRedStringComparator.class, LibBlockNames.RED_STRING_COMPARATOR); + registerTile(TileRedStringRelay.class, LibBlockNames.RED_STRING_RELAY); + registerTile(TileFloatingSpecialFlower.class, LibBlockNames.FLOATING_SPECIAL_FLOWER); + registerTile(TileManaFlame.class, LibBlockNames.MANA_FLAME); + registerTile(TilePrism.class, LibBlockNames.PRISM); + registerTile(TileCorporeaIndex.class, LibBlockNames.CORPOREA_INDEX); + registerTile(TileCorporeaFunnel.class, LibBlockNames.CORPOREA_FUNNEL); + registerTile(TilePump.class, LibBlockNames.PUMP); + registerTile(TileFakeAir.class, LibBlockNames.FAKE_AIR); + registerTile(TileCorporeaInterceptor.class, LibBlockNames.CORPOREA_INTERCEPTOR); + registerTile(TileCorporeaCrystalCube.class, LibBlockNames.CORPOREA_CRYSTAL_CUBE); + registerTile(TileIncensePlate.class, LibBlockNames.INCENSE_PLATE); + registerTile(TileHourglass.class, LibBlockNames.HOURGLASS); + registerTile(TileSparkChanger.class, LibBlockNames.SPARK_CHANGER); + registerTile(TileCocoon.class, LibBlockNames.COCOON); + registerTile(TileLightRelay.class, LibBlockNames.LIGHT_RELAY); + registerTile(TileCacophonium.class, LibBlockNames.CACOPHONIUM); + registerTile(TileBellows.class, LibBlockNames.BELLOWS); + registerTile(TileCell.class, LibBlockNames.CELL_BLOCK); + registerTile(TileRedStringInterceptor.class, LibBlockNames.RED_STRING_INTERCEPTOR); + registerTile(TileGaiaHead.class, LibBlockNames.GAIA_HEAD); + registerTile(TileCorporeaRetainer.class, LibBlockNames.CORPOREA_RETAINER); + registerTile(TileTeruTeruBozu.class, LibBlockNames.TERU_TERU_BOZU); + registerTile(TileAvatar.class, LibBlockNames.AVATAR); - private static void initTileEntities() { - registerTile(TileAltar.class, LibBlockNames.ALTAR); - registerTile(TileSpecialFlower.class, LibBlockNames.SPECIAL_FLOWER); - registerTile(TileSpreader.class, LibBlockNames.SPREADER); - registerTile(TilePool.class, LibBlockNames.POOL); - registerTile(TileRuneAltar.class, LibBlockNames.RUNE_ALTAR); - registerTile(TilePylon.class, LibBlockNames.PYLON); - registerTile(TileDistributor.class, LibBlockNames.DISTRIBUTOR); - registerTile(TileManaBeacon.class, LibBlockNames.MANA_BEACON); - registerTile(TileManaVoid.class, LibBlockNames.MANA_VOID); - registerTile(TileManaDetector.class, LibBlockNames.MANA_DETECTOR); - registerTile(TileEnchanter.class, LibBlockNames.ENCHANTER); - registerTile(TileTurntable.class, LibBlockNames.TURNTABLE); - registerTile(TileTinyPlanet.class, LibBlockNames.TINY_PLANET); - registerTile(TileOpenCrate.class, LibBlockNames.OPEN_CRATE); - registerTile(TileCraftCrate.class, LibBlockNames.CRAFT_CRATE); - registerTile(TileForestEye.class, LibBlockNames.FOREST_EYE); - registerTile(TilePlatform.class, LibBlockNames.PLATFORM); - registerTile(TileAlfPortal.class, LibBlockNames.ALF_PORTAL); - registerTile(TileBifrost.class, LibBlockNames.BIFROST); - registerTile(TileFloatingFlower.class, LibBlockNames.MINI_ISLAND); - registerTile(TileTinyPotato.class, LibBlockNames.TINY_POTATO); - registerTile(TileSpawnerClaw.class, LibBlockNames.SPAWNER_CLAW); - registerTile(TileEnderEye.class, LibBlockNames.ENDER_EYE_BLOCK); - registerTile(TileStarfield.class, LibBlockNames.STARFIELD); - registerTile(TileRFGenerator.class, LibBlockNames.RF_GENERATOR); - registerTile(TileBrewery.class, LibBlockNames.BREWERY); - registerTile(TileTerraPlate.class, LibBlockNames.TERRA_PLATE); - registerTile(TileRedStringContainer.class, LibBlockNames.RED_STRING_CONTAINER); - registerTile(TileRedStringDispenser.class, LibBlockNames.RED_STRING_DISPENSER); - registerTile(TileRedStringFertilizer.class, LibBlockNames.RED_STRING_FERTILIZER); - registerTile(TileRedStringComparator.class, LibBlockNames.RED_STRING_COMPARATOR); - registerTile(TileRedStringRelay.class, LibBlockNames.RED_STRING_RELAY); - registerTile(TileFloatingSpecialFlower.class, LibBlockNames.FLOATING_SPECIAL_FLOWER); - registerTile(TileManaFlame.class, LibBlockNames.MANA_FLAME); - registerTile(TilePrism.class, LibBlockNames.PRISM); - registerTile(TileCorporeaIndex.class, LibBlockNames.CORPOREA_INDEX); - registerTile(TileCorporeaFunnel.class, LibBlockNames.CORPOREA_FUNNEL); - registerTile(TilePump.class, LibBlockNames.PUMP); - registerTile(TileFakeAir.class, LibBlockNames.FAKE_AIR); - registerTile(TileCorporeaInterceptor.class, LibBlockNames.CORPOREA_INTERCEPTOR); - registerTile(TileCorporeaCrystalCube.class, LibBlockNames.CORPOREA_CRYSTAL_CUBE); - registerTile(TileIncensePlate.class, LibBlockNames.INCENSE_PLATE); - registerTile(TileHourglass.class, LibBlockNames.HOURGLASS); - registerTile(TileSparkChanger.class, LibBlockNames.SPARK_CHANGER); - registerTile(TileCocoon.class, LibBlockNames.COCOON); - registerTile(TileLightRelay.class, LibBlockNames.LIGHT_RELAY); - registerTile(TileCacophonium.class, LibBlockNames.CACOPHONIUM); - registerTile(TileBellows.class, LibBlockNames.BELLOWS); - registerTile(TileCell.class, LibBlockNames.CELL_BLOCK); - registerTile(TileRedStringInterceptor.class, LibBlockNames.RED_STRING_INTERCEPTOR); - registerTile(TileGaiaHead.class, LibBlockNames.GAIA_HEAD); - registerTile(TileCorporeaRetainer.class, LibBlockNames.CORPOREA_RETAINER); - registerTile(TileTeruTeruBozu.class, LibBlockNames.TERU_TERU_BOZU); - registerTile(TileAvatar.class, LibBlockNames.AVATAR); + BotaniaAPI.registerSubTile(LibBlockNames.SUBTILE_PUREDAISY, SubTilePureDaisy.class); + BotaniaAPI.registerSubTile(LibBlockNames.SUBTILE_MANASTAR, SubTileManastar.class); - BotaniaAPI.registerSubTile(LibBlockNames.SUBTILE_PUREDAISY, SubTilePureDaisy.class); - BotaniaAPI.registerSubTile(LibBlockNames.SUBTILE_MANASTAR, SubTileManastar.class); + registerSubTileWithDecor(LibBlockNames.SUBTILE_DAYBLOOM, SubTileDaybloom.class, SubTileDecor.Daybloom.class); + BotaniaAPI.registerSubTile(LibBlockNames.SUBTILE_DAYBLOOM_PRIME, SubTileDaybloom.Prime.class); + BotaniaAPI.registerSubTile(LibBlockNames.SUBTILE_ENDOFLAME, SubTileEndoflame.class); + registerSubTileWithDecor(LibBlockNames.SUBTILE_HYDROANGEAS, SubTileHydroangeas.class, SubTileDecor.Hydroangeas.class); + BotaniaAPI.registerSubTile(LibBlockNames.SUBTILE_THERMALILY, SubTileThermalily.class); + registerSubTileWithDecor(LibBlockNames.SUBTILE_NIGHTSHADE, SubTileNightshade.class, SubTileDecor.Nightshade.class); + BotaniaAPI.registerSubTile(LibBlockNames.SUBTILE_NIGHTSHADE_PRIME, SubTileNightshade.Prime.class); + BotaniaAPI.registerSubTile(LibBlockNames.SUBTILE_ARCANE_ROSE, SubTileArcaneRose.class); + BotaniaAPI.registerSubTile(LibBlockNames.SUBTILE_MUNCHDEW, SubTileMunchdew.class); + BotaniaAPI.registerSubTile(LibBlockNames.SUBTILE_ENTROPINNYUM, SubTileEntropinnyum.class); + BotaniaAPI.registerSubTile(LibBlockNames.SUBTILE_KEKIMURUS, SubTileKekimurus.class); + BotaniaAPI.registerSubTile(LibBlockNames.SUBTILE_GOURMARYLLIS, SubTileGourmaryllis.class); + BotaniaAPI.registerSubTile(LibBlockNames.SUBTILE_NARSLIMMUS, SubTileNarslimmus.class); + BotaniaAPI.registerSubTile(LibBlockNames.SUBTILE_SPECTROLUS, SubTileSpectrolus.class); + BotaniaAPI.registerSubTile(LibBlockNames.SUBTILE_DANDELIFEON, SubTileDandelifeon.class); + BotaniaAPI.registerSubTile(LibBlockNames.SUBTILE_RAFFLOWSIA, SubTileRafflowsia.class); - registerSubTileWithDecor(LibBlockNames.SUBTILE_DAYBLOOM, SubTileDaybloom.class, SubTileDecor.Daybloom.class); - BotaniaAPI.registerSubTile(LibBlockNames.SUBTILE_DAYBLOOM_PRIME, SubTileDaybloom.Prime.class); - BotaniaAPI.registerSubTile(LibBlockNames.SUBTILE_ENDOFLAME, SubTileEndoflame.class); - registerSubTileWithDecor( - LibBlockNames.SUBTILE_HYDROANGEAS, SubTileHydroangeas.class, SubTileDecor.Hydroangeas.class); - BotaniaAPI.registerSubTile(LibBlockNames.SUBTILE_THERMALILY, SubTileThermalily.class); - registerSubTileWithDecor( - LibBlockNames.SUBTILE_NIGHTSHADE, SubTileNightshade.class, SubTileDecor.Nightshade.class); - BotaniaAPI.registerSubTile(LibBlockNames.SUBTILE_NIGHTSHADE_PRIME, SubTileNightshade.Prime.class); - BotaniaAPI.registerSubTile(LibBlockNames.SUBTILE_ARCANE_ROSE, SubTileArcaneRose.class); - BotaniaAPI.registerSubTile(LibBlockNames.SUBTILE_MUNCHDEW, SubTileMunchdew.class); - BotaniaAPI.registerSubTile(LibBlockNames.SUBTILE_ENTROPINNYUM, SubTileEntropinnyum.class); - BotaniaAPI.registerSubTile(LibBlockNames.SUBTILE_KEKIMURUS, SubTileKekimurus.class); - BotaniaAPI.registerSubTile(LibBlockNames.SUBTILE_GOURMARYLLIS, SubTileGourmaryllis.class); - BotaniaAPI.registerSubTile(LibBlockNames.SUBTILE_NARSLIMMUS, SubTileNarslimmus.class); - BotaniaAPI.registerSubTile(LibBlockNames.SUBTILE_SPECTROLUS, SubTileSpectrolus.class); - BotaniaAPI.registerSubTile(LibBlockNames.SUBTILE_DANDELIFEON, SubTileDandelifeon.class); - BotaniaAPI.registerSubTile(LibBlockNames.SUBTILE_RAFFLOWSIA, SubTileRafflowsia.class); + registerSubTileWithMini(LibBlockNames.SUBTILE_BELLETHORN, SubTileBellethorn.class); + BotaniaAPI.registerSubTile(LibBlockNames.SUBTILE_DREADTHORN, SubTileDreadthorn.class); + BotaniaAPI.registerSubTile(LibBlockNames.SUBTILE_HEISEI_DREAM, SubTileHeiseiDream.class); + BotaniaAPI.registerSubTile(LibBlockNames.SUBTILE_TIGERSEYE, SubTileTigerseye.class); + BotaniaAPI.registerSubTile(LibBlockNames.SUBTILE_JADED_AMARANTHUS, SubTileJadedAmaranthus.class); + BotaniaAPI.registerSubTile(LibBlockNames.SUBTILE_ORECHID, SubTileOrechid.class); + BotaniaAPI.registerSubTile(LibBlockNames.SUBTILE_ORECHID_IGNEM, SubTileOrechidIgnem.class); + BotaniaAPI.registerSubTile(LibBlockNames.SUBTILE_FALLEN_KANADE, SubTileFallenKanade.class); + BotaniaAPI.registerSubTile(LibBlockNames.SUBTILE_EXOFLAME, SubTileExoflame.class); + registerSubTileWithMini(LibBlockNames.SUBTILE_AGRICARNATION, SubTileAgricarnation.class); + registerSubTileWithMini(LibBlockNames.SUBTILE_HOPPERHOCK, SubTileHopperhock.class); + BotaniaAPI.registerSubTile(LibBlockNames.SUBTILE_TANGLEBERRIE, SubTileTangleberrie.class); + BotaniaAPI.registerSubTile(LibBlockNames.SUBTILE_JIYUULIA, SubTileJiyuulia.class); + registerSubTileWithMini(LibBlockNames.SUBTILE_RANNUNCARPUS, SubTileRannuncarpus.class); + BotaniaAPI.registerSubTile(LibBlockNames.SUBTILE_HYACIDUS, SubTileHyacidus.class); + BotaniaAPI.registerSubTile(LibBlockNames.SUBTILE_POLLIDISIAC, SubTilePollidisiac.class); + registerSubTileWithMini(LibBlockNames.SUBTILE_CLAYCONIA, SubTileClayconia.class); + BotaniaAPI.registerSubTile(LibBlockNames.SUBTILE_LOONIUM, SubTileLoonuim.class); + BotaniaAPI.registerSubTile(LibBlockNames.SUBTILE_DAFFOMILL, SubTileDaffomill.class); + BotaniaAPI.registerSubTile(LibBlockNames.SUBTILE_VINCULOTUS, SubTileVinculotus.class); + BotaniaAPI.registerSubTile(LibBlockNames.SUBTILE_SPECTRANTHEMUM, SubTileSpectranthemum.class); + BotaniaAPI.registerSubTile(LibBlockNames.SUBTILE_MEDUMONE, SubTileMedumone.class); + registerSubTileWithMini(LibBlockNames.SUBTILE_MARIMORPHOSIS, SubTileMarimorphosis.class); + registerSubTileWithMini(LibBlockNames.SUBTILE_BUBBELL, SubTileBubbell.class); + registerSubTileWithMini(LibBlockNames.SUBTILE_SOLEGNOLIA, SubTileSolegnolia.class); + } - registerSubTileWithMini(LibBlockNames.SUBTILE_BELLETHORN, SubTileBellethorn.class); - BotaniaAPI.registerSubTile(LibBlockNames.SUBTILE_DREADTHORN, SubTileDreadthorn.class); - BotaniaAPI.registerSubTile(LibBlockNames.SUBTILE_HEISEI_DREAM, SubTileHeiseiDream.class); - BotaniaAPI.registerSubTile(LibBlockNames.SUBTILE_TIGERSEYE, SubTileTigerseye.class); - BotaniaAPI.registerSubTile(LibBlockNames.SUBTILE_JADED_AMARANTHUS, SubTileJadedAmaranthus.class); - BotaniaAPI.registerSubTile(LibBlockNames.SUBTILE_ORECHID, SubTileOrechid.class); - BotaniaAPI.registerSubTile(LibBlockNames.SUBTILE_ORECHID_IGNEM, SubTileOrechidIgnem.class); - BotaniaAPI.registerSubTile(LibBlockNames.SUBTILE_FALLEN_KANADE, SubTileFallenKanade.class); - BotaniaAPI.registerSubTile(LibBlockNames.SUBTILE_EXOFLAME, SubTileExoflame.class); - registerSubTileWithMini(LibBlockNames.SUBTILE_AGRICARNATION, SubTileAgricarnation.class); - registerSubTileWithMini(LibBlockNames.SUBTILE_HOPPERHOCK, SubTileHopperhock.class); - BotaniaAPI.registerSubTile(LibBlockNames.SUBTILE_TANGLEBERRIE, SubTileTangleberrie.class); - BotaniaAPI.registerSubTile(LibBlockNames.SUBTILE_JIYUULIA, SubTileJiyuulia.class); - registerSubTileWithMini(LibBlockNames.SUBTILE_RANNUNCARPUS, SubTileRannuncarpus.class); - BotaniaAPI.registerSubTile(LibBlockNames.SUBTILE_HYACIDUS, SubTileHyacidus.class); - BotaniaAPI.registerSubTile(LibBlockNames.SUBTILE_POLLIDISIAC, SubTilePollidisiac.class); - registerSubTileWithMini(LibBlockNames.SUBTILE_CLAYCONIA, SubTileClayconia.class); - BotaniaAPI.registerSubTile(LibBlockNames.SUBTILE_LOONIUM, SubTileLoonuim.class); - BotaniaAPI.registerSubTile(LibBlockNames.SUBTILE_DAFFOMILL, SubTileDaffomill.class); - BotaniaAPI.registerSubTile(LibBlockNames.SUBTILE_VINCULOTUS, SubTileVinculotus.class); - BotaniaAPI.registerSubTile(LibBlockNames.SUBTILE_SPECTRANTHEMUM, SubTileSpectranthemum.class); - BotaniaAPI.registerSubTile(LibBlockNames.SUBTILE_MEDUMONE, SubTileMedumone.class); - registerSubTileWithMini(LibBlockNames.SUBTILE_MARIMORPHOSIS, SubTileMarimorphosis.class); - registerSubTileWithMini(LibBlockNames.SUBTILE_BUBBELL, SubTileBubbell.class); - registerSubTileWithMini(LibBlockNames.SUBTILE_SOLEGNOLIA, SubTileSolegnolia.class); - } + public static void registerMultiparts() { + if(Loader.isModLoaded("ForgeMultipart")) { + try { + Class clazz = Class.forName("vazkii.botania.common.integration.multipart.MultipartHandler"); + clazz.newInstance(); + } catch(Throwable e) {} + } + } - public static void registerMultiparts() { - if (Loader.isModLoaded("ForgeMultipart")) { - try { - Class clazz = Class.forName("vazkii.botania.common.integration.multipart.MultipartHandler"); - clazz.newInstance(); - } catch (Throwable e) { - } - } - } + private static void registerSubTileWithMini(String key, Class clazz) { + BotaniaAPI.registerSubTile(key, clazz); - private static void registerSubTileWithMini(String key, Class clazz) { - BotaniaAPI.registerSubTile(key, clazz); + for(Class innerClazz : clazz.getDeclaredClasses()) + if(innerClazz.getSimpleName().equals("Mini")) + BotaniaAPI.registerMiniSubTile(key + "Chibi", innerClazz, key); + } - for (Class innerClazz : clazz.getDeclaredClasses()) - if (innerClazz.getSimpleName().equals("Mini")) - BotaniaAPI.registerMiniSubTile(key + "Chibi", innerClazz, key); - } + private static void registerSubTileWithDecor(String key, Class clazz, Class decor) { + BotaniaAPI.registerSubTile(key, clazz); + BotaniaAPI.registerMiniSubTile(key + "Decor", decor, key); + } - private static void registerSubTileWithDecor( - String key, Class clazz, Class decor) { - BotaniaAPI.registerSubTile(key, clazz); - BotaniaAPI.registerMiniSubTile(key + "Decor", decor, key); - } + private static void registerTile(Class clazz, String key) { + GameRegistry.registerTileEntity(clazz, LibResources.PREFIX_MOD + key); + } - private static void registerTile(Class clazz, String key) { - GameRegistry.registerTileEntity(clazz, LibResources.PREFIX_MOD + key); - } } diff --git a/src/main/java/vazkii/botania/common/block/ModFluffBlocks.java b/src/main/java/vazkii/botania/common/block/ModFluffBlocks.java index 9ab82ae003..3c2ea950d3 100644 --- a/src/main/java/vazkii/botania/common/block/ModFluffBlocks.java +++ b/src/main/java/vazkii/botania/common/block/ModFluffBlocks.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jan 24, 2015, 2:35:08 PM (GMT)] */ package vazkii.botania.common.block; @@ -79,342 +79,343 @@ public final class ModFluffBlocks { - public static Block livingwoodStairs; - public static Block livingwoodSlab; - public static Block livingwoodSlabFull; - public static Block livingwoodWall; - public static Block livingwoodPlankStairs; - public static Block livingwoodPlankSlab; - public static Block livingwoodPlankSlabFull; - public static Block livingrockStairs; - public static Block livingrockSlab; - public static Block livingrockSlabFull; - public static Block livingrockWall; - public static Block livingrockBrickStairs; - public static Block livingrockBrickSlab; - public static Block livingrockBrickSlabFull; - public static Block dreamwoodStairs; - public static Block dreamwoodSlab; - public static Block dreamwoodSlabFull; - public static Block dreamwoodWall; - public static Block dreamwoodPlankStairs; - public static Block dreamwoodPlankSlab; - public static Block dreamwoodPlankSlabFull; - - public static Block prismarineStairs; - public static Block prismarineSlab; - public static Block prismarineSlabFull; - public static Block prismarineWall; - public static Block prismarineBrickStairs; - public static Block prismarineBrickSlab; - public static Block prismarineBrickSlabFull; - public static Block darkPrismarineStairs; - public static Block darkPrismarineSlab; - public static Block darkPrismarineSlabFull; - - public static Block reedStairs; - public static Block reedSlab; - public static Block reedSlabFull; - public static Block reedWall; - public static Block thatchStairs; - public static Block thatchSlab; - public static Block thatchSlabFull; - - public static Block netherBrickStairs; - public static Block netherBrickSlab; - public static Block netherBrickSlabFull; - public static Block soulBrickStairs; - public static Block soulBrickSlab; - public static Block soulBrickSlabFull; - public static Block snowBrickStairs; - public static Block snowBrickSlab; - public static Block snowBrickSlabFull; - public static Block tileStairs; - public static Block tileSlab; - public static Block tileSlabFull; - - public static Block darkQuartz; - public static Block darkQuartzSlab; - public static Block darkQuartzSlabFull; - public static Block darkQuartzStairs; - public static Block manaQuartz; - public static Block manaQuartzSlab; - public static Block manaQuartzSlabFull; - public static Block manaQuartzStairs; - public static Block blazeQuartz; - public static Block blazeQuartzSlab; - public static Block blazeQuartzSlabFull; - public static Block blazeQuartzStairs; - public static Block lavenderQuartz; - public static Block lavenderQuartzSlab; - public static Block lavenderQuartzSlabFull; - public static Block lavenderQuartzStairs; - public static Block redQuartz; - public static Block redQuartzSlab; - public static Block redQuartzSlabFull; - public static Block redQuartzStairs; - public static Block elfQuartz; - public static Block elfQuartzSlab; - public static Block elfQuartzSlabFull; - public static Block elfQuartzStairs; - public static Block sunnyQuartz; - public static Block sunnyQuartzSlab; - public static Block sunnyQuartzSlabFull; - public static Block sunnyQuartzStairs; - - public static Block dirtPathSlab; - public static Block dirtPathSlabFull; - - public static Block biomeStoneA; - public static Block biomeStoneB; - public static Block stone; - public static Block pavement; - - public static Block[] biomeStoneStairs = new Block[24]; - public static Block[] biomeStoneSlabs = new Block[24]; - public static Block[] biomeStoneFullSlabs = new Block[24]; - public static Block biomeStoneWall; - - public static Block[] stoneStairs = new Block[8]; - public static Block[] stoneSlabs = new Block[8]; - public static Block[] stoneFullSlabs = new Block[8]; - public static Block stoneWall; - - public static Block[] pavementStairs = new Block[BlockPavement.TYPES]; - public static Block[] pavementSlabs = new Block[BlockPavement.TYPES]; - public static Block[] pavementFullSlabs = new Block[BlockPavement.TYPES]; - - public static Block endStoneSlab; - public static Block endStoneSlabFull; - public static Block endStoneStairs; - public static Block enderBrickSlab; - public static Block enderBrickSlabFull; - public static Block enderBrickStairs; - - public static Block shimmerrockSlab; - public static Block shimmerrockSlabFull; - public static Block shimmerrockStairs; - public static Block shimmerwoodPlankSlab; - public static Block shimmerwoodPlankSlabFull; - public static Block shimmerwoodPlankStairs; - - public static Block managlassPane; - public static Block alfglassPane; - public static Block bifrostPane; - - public static void init() { - livingwoodStairs = new BlockLivingwoodStairs(); - livingwoodSlab = new BlockLivingwoodSlab(false); - livingwoodSlabFull = new BlockLivingwoodSlab(true); - livingwoodWall = new BlockLivingwoodWall(); - livingwoodPlankStairs = new BlockLivingwoodPlankStairs(); - livingwoodPlankSlab = new BlockLivingwoodPlankSlab(false); - livingwoodPlankSlabFull = new BlockLivingwoodPlankSlab(true); - livingrockStairs = new BlockLivingrockStairs(); - livingrockSlab = new BlockLivingrockSlab(false); - livingrockSlabFull = new BlockLivingrockSlab(true); - livingrockWall = new BlockLivingrockWall(); - livingrockBrickStairs = new BlockLivingrockBrickStairs(); - livingrockBrickSlab = new BlockLivingrockBrickSlab(false); - livingrockBrickSlabFull = new BlockLivingrockBrickSlab(true); - dreamwoodStairs = new BlockDreamwoodStairs(); - dreamwoodSlab = new BlockDreamwoodSlab(false); - dreamwoodSlabFull = new BlockDreamwoodSlab(true); - dreamwoodWall = new BlockDreamwoodWall(); - dreamwoodPlankStairs = new BlockDreamwoodPlankStairs(); - dreamwoodPlankSlab = new BlockDreamwoodPlankSlab(false); - dreamwoodPlankSlabFull = new BlockDreamwoodPlankSlab(true); - - prismarineStairs = new BlockPrismarineStairs(); - prismarineSlab = new BlockPrismarineSlab(false); - prismarineSlabFull = new BlockPrismarineSlab(true); - prismarineWall = new BlockPrismarineWall(); - prismarineBrickStairs = new BlockPrismarineBrickStairs(); - prismarineBrickSlab = new BlockPrismarineBrickSlab(false); - prismarineBrickSlabFull = new BlockPrismarineBrickSlab(true); - darkPrismarineStairs = new BlockDarkPrismarineStairs(); - darkPrismarineSlab = new BlockDarkPrismarineSlab(false); - darkPrismarineSlabFull = new BlockDarkPrismarineSlab(true); - - reedStairs = new BlockReedStairs(); - reedSlab = new BlockReedSlab(false); - reedSlabFull = new BlockReedSlab(true); - reedWall = new BlockReedWall(); - thatchStairs = new BlockThatchStairs(); - thatchSlab = new BlockThatchSlab(false); - thatchSlabFull = new BlockThatchSlab(true); - - netherBrickStairs = new BlockCustomBrickStairs(); - netherBrickSlab = new BlockCustomBrickSlab(false); - netherBrickSlabFull = new BlockCustomBrickSlab(true); - soulBrickStairs = new BlockSoulBrickStairs(); - soulBrickSlab = new BlockSoulBrickSlab(false); - soulBrickSlabFull = new BlockSoulBrickSlab(true); - snowBrickStairs = new BlockSnowBrickStairs(); - snowBrickSlab = new BlockSnowBrickSlab(false); - snowBrickSlabFull = new BlockSnowBrickSlab(true); - tileStairs = new BlockTileStairs(); - tileSlab = new BlockTileSlab(false); - tileSlabFull = new BlockTileSlab(true); - - biomeStoneA = new BlockBiomeStoneA(); - biomeStoneB = new BlockBiomeStoneB(); - stone = new Block18Stone(); - pavement = new BlockPavement(); - - if (ConfigHandler.darkQuartzEnabled) { - darkQuartz = new BlockSpecialQuartz(LibBlockNames.QUARTZ_DARK); - darkQuartzSlab = new BlockSpecialQuartzSlab(darkQuartz, false); - darkQuartzSlabFull = new BlockSpecialQuartzSlab(darkQuartz, true); - darkQuartzStairs = new BlockSpecialQuartzStairs(darkQuartz); - } - - manaQuartz = new BlockSpecialQuartz(LibBlockNames.QUARTZ_MANA); - manaQuartzSlab = new BlockSpecialQuartzSlab(manaQuartz, false); - manaQuartzSlabFull = new BlockSpecialQuartzSlab(manaQuartz, true); - manaQuartzStairs = new BlockSpecialQuartzStairs(manaQuartz); - blazeQuartz = new BlockSpecialQuartz(LibBlockNames.QUARTZ_BLAZE); - blazeQuartzSlab = new BlockSpecialQuartzSlab(blazeQuartz, false); - blazeQuartzSlabFull = new BlockSpecialQuartzSlab(blazeQuartz, true); - blazeQuartzStairs = new BlockSpecialQuartzStairs(blazeQuartz); - lavenderQuartz = new BlockSpecialQuartz(LibBlockNames.QUARTZ_LAVENDER); - lavenderQuartzSlab = new BlockSpecialQuartzSlab(lavenderQuartz, false); - lavenderQuartzSlabFull = new BlockSpecialQuartzSlab(lavenderQuartz, true); - lavenderQuartzStairs = new BlockSpecialQuartzStairs(lavenderQuartz); - redQuartz = new BlockSpecialQuartz(LibBlockNames.QUARTZ_RED); - redQuartzSlab = new BlockSpecialQuartzSlab(redQuartz, false); - redQuartzSlabFull = new BlockSpecialQuartzSlab(redQuartz, true); - redQuartzStairs = new BlockSpecialQuartzStairs(redQuartz); - elfQuartz = new BlockSpecialQuartz(LibBlockNames.QUARTZ_ELF); - elfQuartzSlab = new BlockSpecialQuartzSlab(elfQuartz, false); - elfQuartzSlabFull = new BlockSpecialQuartzSlab(elfQuartz, true); - elfQuartzStairs = new BlockSpecialQuartzStairs(elfQuartz); - sunnyQuartz = new BlockSpecialQuartz(LibBlockNames.QUARTZ_SUNNY); - sunnyQuartzSlab = new BlockSpecialQuartzSlab(sunnyQuartz, false); - sunnyQuartzSlabFull = new BlockSpecialQuartzSlab(sunnyQuartz, true); - sunnyQuartzStairs = new BlockSpecialQuartzStairs(sunnyQuartz); - - dirtPathSlab = new BlockDirtPathSlab(false); - dirtPathSlabFull = new BlockDirtPathSlab(true); - - for (int i = 0; i < 24; i++) { - int meta = i % 16; - Block block = i < 16 ? biomeStoneA : biomeStoneB; - biomeStoneStairs[i] = new BlockBiomeStoneStairs(block, meta); - biomeStoneSlabs[i] = new BlockBiomeStoneSlab(false, block, meta, i); - biomeStoneFullSlabs[i] = new BlockBiomeStoneSlab(true, block, meta, i); - } - biomeStoneWall = new BlockBiomeStoneWall(); - - for (int i = 0; i < 8; i++) { - int meta = i > 3 ? i + 4 : i; - stoneStairs[i] = new Block18StoneStairs(meta); - stoneSlabs[i] = new Block18StoneSlab(false, meta, i); - stoneFullSlabs[i] = new Block18StoneSlab(true, meta, i); - } - stoneWall = new Block18StoneWall(); - - for (int i = 0; i < pavementStairs.length; i++) { - pavementStairs[i] = new BlockPavementStairs(i); - pavementSlabs[i] = new BlockPavementSlab(false, i, i); - pavementFullSlabs[i] = new BlockPavementSlab(true, i, i); - } - - endStoneSlab = new BlockEndStoneSlab(false); - endStoneSlabFull = new BlockEndStoneSlab(true); - endStoneStairs = new BlockEndStoneStairs(); - enderBrickSlab = new BlockEnderBrickSlab(false); - enderBrickSlabFull = new BlockEnderBrickSlab(true); - enderBrickStairs = new BlockEnderBrickStairs(); - - shimmerrockSlab = new BlockShimmerrockSlab(false); - shimmerrockSlabFull = new BlockShimmerrockSlab(true); - shimmerrockStairs = new BlockShimmerrockStairs(); - shimmerwoodPlankSlab = new BlockShimmerwoodPlankSlab(false); - shimmerwoodPlankSlabFull = new BlockShimmerwoodPlankSlab(true); - shimmerwoodPlankStairs = new BlockShimmerwoodPlankStairs(); - - managlassPane = new BlockManaglassPane(); - alfglassPane = new BlockAlfglassPane(); - bifrostPane = new BlockBifrostPane(); - - if (ConfigHandler.darkQuartzEnabled) { - ((BlockModSlab) darkQuartzSlab).register(); - ((BlockModSlab) darkQuartzSlabFull).register(); - } - ((BlockModSlab) manaQuartzSlab).register(); - ((BlockModSlab) manaQuartzSlabFull).register(); - ((BlockModSlab) blazeQuartzSlab).register(); - ((BlockModSlab) blazeQuartzSlabFull).register(); - ((BlockModSlab) lavenderQuartzSlab).register(); - ((BlockModSlab) lavenderQuartzSlabFull).register(); - ((BlockModSlab) redQuartzSlab).register(); - ((BlockModSlab) redQuartzSlabFull).register(); - ((BlockModSlab) elfQuartzSlab).register(); - ((BlockModSlab) elfQuartzSlabFull).register(); - ((BlockModSlab) sunnyQuartzSlab).register(); - ((BlockModSlab) sunnyQuartzSlabFull).register(); - - ((BlockModSlab) livingwoodSlab).register(); - ((BlockModSlab) livingwoodSlabFull).register(); - ((BlockModSlab) livingwoodPlankSlab).register(); - ((BlockModSlab) livingwoodPlankSlabFull).register(); - ((BlockModSlab) livingrockSlab).register(); - ((BlockModSlab) livingrockSlabFull).register(); - ((BlockModSlab) livingrockBrickSlab).register(); - ((BlockModSlab) livingrockBrickSlabFull).register(); - ((BlockModSlab) dreamwoodSlab).register(); - ((BlockModSlab) dreamwoodSlabFull).register(); - ((BlockModSlab) dreamwoodPlankSlab).register(); - ((BlockModSlab) dreamwoodPlankSlabFull).register(); - - ((BlockModSlab) reedSlab).register(); - ((BlockModSlab) reedSlabFull).register(); - ((BlockModSlab) thatchSlab).register(); - ((BlockModSlab) thatchSlabFull).register(); - - ((BlockModSlab) prismarineSlab).register(); - ((BlockModSlab) prismarineSlabFull).register(); - ((BlockModSlab) prismarineBrickSlab).register(); - ((BlockModSlab) prismarineBrickSlabFull).register(); - ((BlockModSlab) darkPrismarineSlab).register(); - ((BlockModSlab) darkPrismarineSlabFull).register(); - - ((BlockModSlab) netherBrickSlab).register(); - ((BlockModSlab) netherBrickSlabFull).register(); - ((BlockModSlab) soulBrickSlab).register(); - ((BlockModSlab) soulBrickSlabFull).register(); - ((BlockModSlab) snowBrickSlab).register(); - ((BlockModSlab) snowBrickSlabFull).register(); - ((BlockModSlab) tileSlab).register(); - ((BlockModSlab) tileSlabFull).register(); - - ((BlockModSlab) dirtPathSlab).register(); - ((BlockModSlab) dirtPathSlabFull).register(); - - ((BlockModSlab) endStoneSlab).register(); - ((BlockModSlab) endStoneSlabFull).register(); - ((BlockModSlab) enderBrickSlab).register(); - ((BlockModSlab) enderBrickSlabFull).register(); - - ((BlockModSlab) shimmerrockSlab).register(); - ((BlockModSlab) shimmerrockSlabFull).register(); - ((BlockModSlab) shimmerwoodPlankSlab).register(); - ((BlockModSlab) shimmerwoodPlankSlabFull).register(); - - for (int i = 0; i < 24; i++) { - ((BlockModSlab) biomeStoneSlabs[i]).register(); - ((BlockModSlab) biomeStoneFullSlabs[i]).register(); - } - - for (int i = 0; i < 8; i++) { - ((BlockModSlab) stoneSlabs[i]).register(); - ((BlockModSlab) stoneFullSlabs[i]).register(); - } - - for (int i = 0; i < pavementSlabs.length; i++) { - ((BlockModSlab) pavementSlabs[i]).register(); - ((BlockModSlab) pavementFullSlabs[i]).register(); - } - } + public static Block livingwoodStairs; + public static Block livingwoodSlab; + public static Block livingwoodSlabFull; + public static Block livingwoodWall; + public static Block livingwoodPlankStairs; + public static Block livingwoodPlankSlab; + public static Block livingwoodPlankSlabFull; + public static Block livingrockStairs; + public static Block livingrockSlab; + public static Block livingrockSlabFull; + public static Block livingrockWall; + public static Block livingrockBrickStairs; + public static Block livingrockBrickSlab; + public static Block livingrockBrickSlabFull; + public static Block dreamwoodStairs; + public static Block dreamwoodSlab; + public static Block dreamwoodSlabFull; + public static Block dreamwoodWall; + public static Block dreamwoodPlankStairs; + public static Block dreamwoodPlankSlab; + public static Block dreamwoodPlankSlabFull; + + public static Block prismarineStairs; + public static Block prismarineSlab; + public static Block prismarineSlabFull; + public static Block prismarineWall; + public static Block prismarineBrickStairs; + public static Block prismarineBrickSlab; + public static Block prismarineBrickSlabFull; + public static Block darkPrismarineStairs; + public static Block darkPrismarineSlab; + public static Block darkPrismarineSlabFull; + + public static Block reedStairs; + public static Block reedSlab; + public static Block reedSlabFull; + public static Block reedWall; + public static Block thatchStairs; + public static Block thatchSlab; + public static Block thatchSlabFull; + + public static Block netherBrickStairs; + public static Block netherBrickSlab; + public static Block netherBrickSlabFull; + public static Block soulBrickStairs; + public static Block soulBrickSlab; + public static Block soulBrickSlabFull; + public static Block snowBrickStairs; + public static Block snowBrickSlab; + public static Block snowBrickSlabFull; + public static Block tileStairs; + public static Block tileSlab; + public static Block tileSlabFull; + + public static Block darkQuartz; + public static Block darkQuartzSlab; + public static Block darkQuartzSlabFull; + public static Block darkQuartzStairs; + public static Block manaQuartz; + public static Block manaQuartzSlab; + public static Block manaQuartzSlabFull; + public static Block manaQuartzStairs; + public static Block blazeQuartz; + public static Block blazeQuartzSlab; + public static Block blazeQuartzSlabFull; + public static Block blazeQuartzStairs; + public static Block lavenderQuartz; + public static Block lavenderQuartzSlab; + public static Block lavenderQuartzSlabFull; + public static Block lavenderQuartzStairs; + public static Block redQuartz; + public static Block redQuartzSlab; + public static Block redQuartzSlabFull; + public static Block redQuartzStairs; + public static Block elfQuartz; + public static Block elfQuartzSlab; + public static Block elfQuartzSlabFull; + public static Block elfQuartzStairs; + public static Block sunnyQuartz; + public static Block sunnyQuartzSlab; + public static Block sunnyQuartzSlabFull; + public static Block sunnyQuartzStairs; + + public static Block dirtPathSlab; + public static Block dirtPathSlabFull; + + public static Block biomeStoneA; + public static Block biomeStoneB; + public static Block stone; + public static Block pavement; + + public static Block[] biomeStoneStairs = new Block[24]; + public static Block[] biomeStoneSlabs = new Block[24]; + public static Block[] biomeStoneFullSlabs = new Block[24]; + public static Block biomeStoneWall; + + public static Block[] stoneStairs = new Block[8]; + public static Block[] stoneSlabs = new Block[8]; + public static Block[] stoneFullSlabs = new Block[8]; + public static Block stoneWall; + + public static Block[] pavementStairs = new Block[BlockPavement.TYPES]; + public static Block[] pavementSlabs = new Block[BlockPavement.TYPES]; + public static Block[] pavementFullSlabs = new Block[BlockPavement.TYPES]; + + public static Block endStoneSlab; + public static Block endStoneSlabFull; + public static Block endStoneStairs; + public static Block enderBrickSlab; + public static Block enderBrickSlabFull; + public static Block enderBrickStairs; + + public static Block shimmerrockSlab; + public static Block shimmerrockSlabFull; + public static Block shimmerrockStairs; + public static Block shimmerwoodPlankSlab; + public static Block shimmerwoodPlankSlabFull; + public static Block shimmerwoodPlankStairs; + + public static Block managlassPane; + public static Block alfglassPane; + public static Block bifrostPane; + + public static void init() { + livingwoodStairs = new BlockLivingwoodStairs(); + livingwoodSlab = new BlockLivingwoodSlab(false); + livingwoodSlabFull = new BlockLivingwoodSlab(true); + livingwoodWall = new BlockLivingwoodWall(); + livingwoodPlankStairs = new BlockLivingwoodPlankStairs(); + livingwoodPlankSlab = new BlockLivingwoodPlankSlab(false); + livingwoodPlankSlabFull = new BlockLivingwoodPlankSlab(true); + livingrockStairs = new BlockLivingrockStairs(); + livingrockSlab = new BlockLivingrockSlab(false); + livingrockSlabFull = new BlockLivingrockSlab(true); + livingrockWall = new BlockLivingrockWall(); + livingrockBrickStairs = new BlockLivingrockBrickStairs(); + livingrockBrickSlab = new BlockLivingrockBrickSlab(false); + livingrockBrickSlabFull = new BlockLivingrockBrickSlab(true); + dreamwoodStairs = new BlockDreamwoodStairs(); + dreamwoodSlab = new BlockDreamwoodSlab(false); + dreamwoodSlabFull = new BlockDreamwoodSlab(true); + dreamwoodWall = new BlockDreamwoodWall(); + dreamwoodPlankStairs = new BlockDreamwoodPlankStairs(); + dreamwoodPlankSlab = new BlockDreamwoodPlankSlab(false); + dreamwoodPlankSlabFull = new BlockDreamwoodPlankSlab(true); + + prismarineStairs = new BlockPrismarineStairs(); + prismarineSlab = new BlockPrismarineSlab(false); + prismarineSlabFull = new BlockPrismarineSlab(true); + prismarineWall = new BlockPrismarineWall(); + prismarineBrickStairs = new BlockPrismarineBrickStairs(); + prismarineBrickSlab = new BlockPrismarineBrickSlab(false); + prismarineBrickSlabFull = new BlockPrismarineBrickSlab(true); + darkPrismarineStairs = new BlockDarkPrismarineStairs(); + darkPrismarineSlab = new BlockDarkPrismarineSlab(false); + darkPrismarineSlabFull = new BlockDarkPrismarineSlab(true); + + reedStairs = new BlockReedStairs(); + reedSlab = new BlockReedSlab(false); + reedSlabFull = new BlockReedSlab(true); + reedWall = new BlockReedWall(); + thatchStairs = new BlockThatchStairs(); + thatchSlab = new BlockThatchSlab(false); + thatchSlabFull = new BlockThatchSlab(true); + + netherBrickStairs = new BlockCustomBrickStairs(); + netherBrickSlab = new BlockCustomBrickSlab(false); + netherBrickSlabFull = new BlockCustomBrickSlab(true); + soulBrickStairs = new BlockSoulBrickStairs(); + soulBrickSlab = new BlockSoulBrickSlab(false); + soulBrickSlabFull = new BlockSoulBrickSlab(true); + snowBrickStairs = new BlockSnowBrickStairs(); + snowBrickSlab = new BlockSnowBrickSlab(false); + snowBrickSlabFull = new BlockSnowBrickSlab(true); + tileStairs = new BlockTileStairs(); + tileSlab = new BlockTileSlab(false); + tileSlabFull = new BlockTileSlab(true); + + biomeStoneA = new BlockBiomeStoneA(); + biomeStoneB = new BlockBiomeStoneB(); + stone = new Block18Stone(); + pavement = new BlockPavement(); + + if(ConfigHandler.darkQuartzEnabled) { + darkQuartz = new BlockSpecialQuartz(LibBlockNames.QUARTZ_DARK); + darkQuartzSlab = new BlockSpecialQuartzSlab(darkQuartz, false); + darkQuartzSlabFull = new BlockSpecialQuartzSlab(darkQuartz, true); + darkQuartzStairs = new BlockSpecialQuartzStairs(darkQuartz); + } + + manaQuartz = new BlockSpecialQuartz(LibBlockNames.QUARTZ_MANA); + manaQuartzSlab = new BlockSpecialQuartzSlab(manaQuartz, false); + manaQuartzSlabFull = new BlockSpecialQuartzSlab(manaQuartz, true); + manaQuartzStairs = new BlockSpecialQuartzStairs(manaQuartz); + blazeQuartz = new BlockSpecialQuartz(LibBlockNames.QUARTZ_BLAZE); + blazeQuartzSlab = new BlockSpecialQuartzSlab(blazeQuartz, false); + blazeQuartzSlabFull = new BlockSpecialQuartzSlab(blazeQuartz, true); + blazeQuartzStairs = new BlockSpecialQuartzStairs(blazeQuartz); + lavenderQuartz = new BlockSpecialQuartz(LibBlockNames.QUARTZ_LAVENDER); + lavenderQuartzSlab = new BlockSpecialQuartzSlab(lavenderQuartz, false); + lavenderQuartzSlabFull = new BlockSpecialQuartzSlab(lavenderQuartz, true); + lavenderQuartzStairs = new BlockSpecialQuartzStairs(lavenderQuartz); + redQuartz = new BlockSpecialQuartz(LibBlockNames.QUARTZ_RED); + redQuartzSlab = new BlockSpecialQuartzSlab(redQuartz, false); + redQuartzSlabFull = new BlockSpecialQuartzSlab(redQuartz, true); + redQuartzStairs = new BlockSpecialQuartzStairs(redQuartz); + elfQuartz = new BlockSpecialQuartz(LibBlockNames.QUARTZ_ELF); + elfQuartzSlab = new BlockSpecialQuartzSlab(elfQuartz, false); + elfQuartzSlabFull = new BlockSpecialQuartzSlab(elfQuartz, true); + elfQuartzStairs = new BlockSpecialQuartzStairs(elfQuartz); + sunnyQuartz = new BlockSpecialQuartz(LibBlockNames.QUARTZ_SUNNY); + sunnyQuartzSlab = new BlockSpecialQuartzSlab(sunnyQuartz, false); + sunnyQuartzSlabFull = new BlockSpecialQuartzSlab(sunnyQuartz, true); + sunnyQuartzStairs = new BlockSpecialQuartzStairs(sunnyQuartz); + + dirtPathSlab = new BlockDirtPathSlab(false); + dirtPathSlabFull = new BlockDirtPathSlab(true); + + for(int i = 0; i < 24; i++) { + int meta = i % 16; + Block block = i < 16 ? biomeStoneA : biomeStoneB; + biomeStoneStairs[i] = new BlockBiomeStoneStairs(block, meta); + biomeStoneSlabs[i] = new BlockBiomeStoneSlab(false, block, meta, i); + biomeStoneFullSlabs[i] = new BlockBiomeStoneSlab(true, block, meta, i); + } + biomeStoneWall = new BlockBiomeStoneWall(); + + for(int i = 0; i < 8; i++) { + int meta = i > 3 ? i + 4 : i; + stoneStairs[i] = new Block18StoneStairs(meta); + stoneSlabs[i] = new Block18StoneSlab(false, meta, i); + stoneFullSlabs[i] = new Block18StoneSlab(true, meta, i); + } + stoneWall = new Block18StoneWall(); + + for(int i = 0; i < pavementStairs.length; i++) { + pavementStairs[i] = new BlockPavementStairs(i); + pavementSlabs[i] = new BlockPavementSlab(false, i, i); + pavementFullSlabs[i] = new BlockPavementSlab(true, i, i); + } + + endStoneSlab = new BlockEndStoneSlab(false); + endStoneSlabFull = new BlockEndStoneSlab(true); + endStoneStairs = new BlockEndStoneStairs(); + enderBrickSlab = new BlockEnderBrickSlab(false); + enderBrickSlabFull = new BlockEnderBrickSlab(true); + enderBrickStairs = new BlockEnderBrickStairs(); + + shimmerrockSlab = new BlockShimmerrockSlab(false); + shimmerrockSlabFull = new BlockShimmerrockSlab(true); + shimmerrockStairs = new BlockShimmerrockStairs(); + shimmerwoodPlankSlab = new BlockShimmerwoodPlankSlab(false); + shimmerwoodPlankSlabFull = new BlockShimmerwoodPlankSlab(true); + shimmerwoodPlankStairs = new BlockShimmerwoodPlankStairs(); + + managlassPane = new BlockManaglassPane(); + alfglassPane = new BlockAlfglassPane(); + bifrostPane = new BlockBifrostPane(); + + if(ConfigHandler.darkQuartzEnabled) { + ((BlockModSlab) darkQuartzSlab).register(); + ((BlockModSlab) darkQuartzSlabFull).register(); + } + ((BlockModSlab) manaQuartzSlab).register(); + ((BlockModSlab) manaQuartzSlabFull).register(); + ((BlockModSlab) blazeQuartzSlab).register(); + ((BlockModSlab) blazeQuartzSlabFull).register(); + ((BlockModSlab) lavenderQuartzSlab).register(); + ((BlockModSlab) lavenderQuartzSlabFull).register(); + ((BlockModSlab) redQuartzSlab).register(); + ((BlockModSlab) redQuartzSlabFull).register(); + ((BlockModSlab) elfQuartzSlab).register(); + ((BlockModSlab) elfQuartzSlabFull).register(); + ((BlockModSlab) sunnyQuartzSlab).register(); + ((BlockModSlab) sunnyQuartzSlabFull).register(); + + ((BlockModSlab) livingwoodSlab).register(); + ((BlockModSlab) livingwoodSlabFull).register(); + ((BlockModSlab) livingwoodPlankSlab).register(); + ((BlockModSlab) livingwoodPlankSlabFull).register(); + ((BlockModSlab) livingrockSlab).register(); + ((BlockModSlab) livingrockSlabFull).register(); + ((BlockModSlab) livingrockBrickSlab).register(); + ((BlockModSlab) livingrockBrickSlabFull).register(); + ((BlockModSlab) dreamwoodSlab).register(); + ((BlockModSlab) dreamwoodSlabFull).register(); + ((BlockModSlab) dreamwoodPlankSlab).register(); + ((BlockModSlab) dreamwoodPlankSlabFull).register(); + + ((BlockModSlab) reedSlab).register(); + ((BlockModSlab) reedSlabFull).register(); + ((BlockModSlab) thatchSlab).register(); + ((BlockModSlab) thatchSlabFull).register(); + + ((BlockModSlab) prismarineSlab).register(); + ((BlockModSlab) prismarineSlabFull).register(); + ((BlockModSlab) prismarineBrickSlab).register(); + ((BlockModSlab) prismarineBrickSlabFull).register(); + ((BlockModSlab) darkPrismarineSlab).register(); + ((BlockModSlab) darkPrismarineSlabFull).register(); + + ((BlockModSlab) netherBrickSlab).register(); + ((BlockModSlab) netherBrickSlabFull).register(); + ((BlockModSlab) soulBrickSlab).register(); + ((BlockModSlab) soulBrickSlabFull).register(); + ((BlockModSlab) snowBrickSlab).register(); + ((BlockModSlab) snowBrickSlabFull).register(); + ((BlockModSlab) tileSlab).register(); + ((BlockModSlab) tileSlabFull).register(); + + ((BlockModSlab) dirtPathSlab).register(); + ((BlockModSlab) dirtPathSlabFull).register(); + + ((BlockModSlab) endStoneSlab).register(); + ((BlockModSlab) endStoneSlabFull).register(); + ((BlockModSlab) enderBrickSlab).register(); + ((BlockModSlab) enderBrickSlabFull).register(); + + ((BlockModSlab) shimmerrockSlab).register(); + ((BlockModSlab) shimmerrockSlabFull).register(); + ((BlockModSlab) shimmerwoodPlankSlab).register(); + ((BlockModSlab) shimmerwoodPlankSlabFull).register(); + + for(int i = 0; i < 24; i++) { + ((BlockModSlab) biomeStoneSlabs[i]).register(); + ((BlockModSlab) biomeStoneFullSlabs[i]).register(); + } + + for(int i = 0; i < 8; i++) { + ((BlockModSlab) stoneSlabs[i]).register(); + ((BlockModSlab) stoneFullSlabs[i]).register(); + } + + for(int i = 0; i < pavementSlabs.length; i++) { + ((BlockModSlab) pavementSlabs[i]).register(); + ((BlockModSlab) pavementFullSlabs[i]).register(); + } + } + } diff --git a/src/main/java/vazkii/botania/common/block/ModMultiblocks.java b/src/main/java/vazkii/botania/common/block/ModMultiblocks.java index ff02d8d083..26e531e5e9 100644 --- a/src/main/java/vazkii/botania/common/block/ModMultiblocks.java +++ b/src/main/java/vazkii/botania/common/block/ModMultiblocks.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jun 27, 2015, 3:11:36 PM (GMT)] */ package vazkii.botania.common.block; @@ -18,15 +18,16 @@ public final class ModMultiblocks { - public static MultiblockSet enchanter; - public static MultiblockSet alfPortal; - public static MultiblockSet terrasteelPlate; - public static MultiblockSet gaiaRitual; + public static MultiblockSet enchanter; + public static MultiblockSet alfPortal; + public static MultiblockSet terrasteelPlate; + public static MultiblockSet gaiaRitual; + + public static void init() { + enchanter = TileEnchanter.makeMultiblockSet(); + alfPortal = TileAlfPortal.makeMultiblockSet(); + terrasteelPlate = TileTerraPlate.makeMultiblockSet(); + gaiaRitual = EntityDoppleganger.makeMultiblockSet(); + } - public static void init() { - enchanter = TileEnchanter.makeMultiblockSet(); - alfPortal = TileAlfPortal.makeMultiblockSet(); - terrasteelPlate = TileTerraPlate.makeMultiblockSet(); - gaiaRitual = EntityDoppleganger.makeMultiblockSet(); - } } diff --git a/src/main/java/vazkii/botania/common/block/corporea/BlockCorporeaBase.java b/src/main/java/vazkii/botania/common/block/corporea/BlockCorporeaBase.java index bd8b2c61bc..4be814d28f 100644 --- a/src/main/java/vazkii/botania/common/block/corporea/BlockCorporeaBase.java +++ b/src/main/java/vazkii/botania/common/block/corporea/BlockCorporeaBase.java @@ -2,15 +2,16 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Feb 15, 2015, 12:23:33 AM (GMT)] */ package vazkii.botania.common.block.corporea; import java.util.Random; + import net.minecraft.block.Block; import net.minecraft.block.material.Material; import net.minecraft.entity.item.EntityItem; @@ -28,62 +29,56 @@ public abstract class BlockCorporeaBase extends BlockModContainer implements ICraftAchievement { - Random random; - - public BlockCorporeaBase(Material material, String name) { - super(material); - setBlockName(name); - - random = new Random(); - } - - @Override - public void breakBlock(World par1World, int par2, int par3, int par4, Block par5, int par6) { - TileSimpleInventory inv = (TileSimpleInventory) par1World.getTileEntity(par2, par3, par4); - - if (inv != null) { - for (int j1 = 0; j1 < inv.getSizeInventory(); ++j1) { - ItemStack itemstack = inv.getStackInSlot(j1); - - if (itemstack != null) { - float f = random.nextFloat() * 0.8F + 0.1F; - float f1 = random.nextFloat() * 0.8F + 0.1F; - EntityItem entityitem; - - for (float f2 = random.nextFloat() * 0.8F + 0.1F; - itemstack.stackSize > 0; - par1World.spawnEntityInWorld(entityitem)) { - int k1 = random.nextInt(21) + 10; - - if (k1 > itemstack.stackSize) k1 = itemstack.stackSize; - - itemstack.stackSize -= k1; - entityitem = new EntityItem( - par1World, - par2 + f, - par3 + f1, - par4 + f2, - new ItemStack(itemstack.getItem(), k1, itemstack.getItemDamage())); - float f3 = 0.05F; - entityitem.motionX = (float) random.nextGaussian() * f3; - entityitem.motionY = (float) random.nextGaussian() * f3 + 0.2F; - entityitem.motionZ = (float) random.nextGaussian() * f3; - - if (itemstack.hasTagCompound()) - entityitem.getEntityItem().setTagCompound((NBTTagCompound) - itemstack.getTagCompound().copy()); - } - } - } - - par1World.func_147453_f(par2, par3, par4, par5); - } - - super.breakBlock(par1World, par2, par3, par4, par5, par6); - } - - @Override - public Achievement getAchievementOnCraft(ItemStack stack, EntityPlayer player, IInventory matrix) { - return ModAchievements.corporeaCraft; - } + Random random; + + public BlockCorporeaBase(Material material, String name) { + super(material); + setBlockName(name); + + random = new Random(); + } + + @Override + public void breakBlock(World par1World, int par2, int par3, int par4, Block par5, int par6) { + TileSimpleInventory inv = (TileSimpleInventory) par1World.getTileEntity(par2, par3, par4); + + if (inv != null) { + for (int j1 = 0; j1 < inv.getSizeInventory(); ++j1) { + ItemStack itemstack = inv.getStackInSlot(j1); + + if (itemstack != null) { + float f = random.nextFloat() * 0.8F + 0.1F; + float f1 = random.nextFloat() * 0.8F + 0.1F; + EntityItem entityitem; + + for (float f2 = random.nextFloat() * 0.8F + 0.1F; itemstack.stackSize > 0; par1World.spawnEntityInWorld(entityitem)) { + int k1 = random.nextInt(21) + 10; + + if (k1 > itemstack.stackSize) + k1 = itemstack.stackSize; + + itemstack.stackSize -= k1; + entityitem = new EntityItem(par1World, par2 + f, par3 + f1, par4 + f2, new ItemStack(itemstack.getItem(), k1, itemstack.getItemDamage())); + float f3 = 0.05F; + entityitem.motionX = (float)random.nextGaussian() * f3; + entityitem.motionY = (float)random.nextGaussian() * f3 + 0.2F; + entityitem.motionZ = (float)random.nextGaussian() * f3; + + if (itemstack.hasTagCompound()) + entityitem.getEntityItem().setTagCompound((NBTTagCompound)itemstack.getTagCompound().copy()); + } + } + } + + par1World.func_147453_f(par2, par3, par4, par5); + } + + super.breakBlock(par1World, par2, par3, par4, par5, par6); + } + + @Override + public Achievement getAchievementOnCraft(ItemStack stack, EntityPlayer player, IInventory matrix) { + return ModAchievements.corporeaCraft; + } + } diff --git a/src/main/java/vazkii/botania/common/block/corporea/BlockCorporeaCrystalCube.java b/src/main/java/vazkii/botania/common/block/corporea/BlockCorporeaCrystalCube.java index 801724b1cd..c41f79dbd9 100644 --- a/src/main/java/vazkii/botania/common/block/corporea/BlockCorporeaCrystalCube.java +++ b/src/main/java/vazkii/botania/common/block/corporea/BlockCorporeaCrystalCube.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Apr 30, 2015, 3:56:19 PM (GMT)] */ package vazkii.botania.common.block.corporea; @@ -27,77 +27,77 @@ public class BlockCorporeaCrystalCube extends BlockCorporeaBase implements ILexiconable { - public BlockCorporeaCrystalCube() { - super(Material.iron, LibBlockNames.CORPOREA_CRYSTAL_CUBE); - setHardness(5.5F); - setStepSound(soundTypeMetal); - float f = (1F - 10F / 16F) / 2F; - setBlockBounds(f, 0F, f, 1F - f, 1F, 1F - f); - } - - @Override - public void onBlockClicked(World world, int x, int y, int z, EntityPlayer player) { - if (!world.isRemote) { - TileCorporeaCrystalCube cube = (TileCorporeaCrystalCube) world.getTileEntity(x, y, z); - cube.doRequest(player.isSneaking()); - } - } - - @Override - public boolean onBlockActivated( - World world, int x, int y, int z, EntityPlayer player, int s, float xs, float ys, float zs) { - ItemStack stack = player.getCurrentEquippedItem(); - - if (stack != null) { - TileCorporeaCrystalCube cube = (TileCorporeaCrystalCube) world.getTileEntity(x, y, z); - cube.setRequestTarget(stack); - return true; - } - return false; - } - - @Override - public boolean isOpaqueCube() { - return false; - } - - @Override - public boolean renderAsNormalBlock() { - return false; - } - - @Override - public int getRenderType() { - return LibRenderIDs.idCorporeaCrystalCybe; - } - - @Override - public void registerBlockIcons(IIconRegister par1IconRegister) { - // NO-OP - } - - @Override - public IIcon getIcon(int side, int meta) { - return ModBlocks.storage.getIcon(0, 2); - } - - @Override - public TileCorporeaBase createNewTileEntity(World world, int meta) { - return new TileCorporeaCrystalCube(); - } - - @Override - public LexiconEntry getEntry(World world, int x, int y, int z, EntityPlayer player, ItemStack lexicon) { - return LexiconData.corporeaCrystalCube; - } - - @Override - public boolean hasComparatorInputOverride() { - return true; - } - - @Override - public int getComparatorInputOverride(World world, int x, int y, int z, int s) { - return ((TileCorporeaCrystalCube) world.getTileEntity(x, y, z)).compValue; - } + public BlockCorporeaCrystalCube() { + super(Material.iron, LibBlockNames.CORPOREA_CRYSTAL_CUBE); + setHardness(5.5F); + setStepSound(soundTypeMetal); + float f = (1F - 10F / 16F) / 2F; + setBlockBounds(f, 0F, f, 1F - f, 1F, 1F - f); + } + + @Override + public void onBlockClicked(World world, int x, int y, int z, EntityPlayer player) { + if(!world.isRemote) { + TileCorporeaCrystalCube cube = (TileCorporeaCrystalCube) world.getTileEntity(x, y, z); + cube.doRequest(player.isSneaking()); + } + } + + @Override + public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int s, float xs, float ys, float zs) { + ItemStack stack = player.getCurrentEquippedItem(); + + if(stack != null) { + TileCorporeaCrystalCube cube = (TileCorporeaCrystalCube) world.getTileEntity(x, y, z); + cube.setRequestTarget(stack); + return true; + } + return false; + } + + @Override + public boolean isOpaqueCube() { + return false; + } + + @Override + public boolean renderAsNormalBlock() { + return false; + } + + @Override + public int getRenderType() { + return LibRenderIDs.idCorporeaCrystalCybe; + } + + @Override + public void registerBlockIcons(IIconRegister par1IconRegister) { + // NO-OP + } + + @Override + public IIcon getIcon(int side, int meta) { + return ModBlocks.storage.getIcon(0, 2); + } + + @Override + public TileCorporeaBase createNewTileEntity(World world, int meta) { + return new TileCorporeaCrystalCube(); + } + + @Override + public LexiconEntry getEntry(World world, int x, int y, int z, EntityPlayer player, ItemStack lexicon) { + return LexiconData.corporeaCrystalCube; + } + + @Override + public boolean hasComparatorInputOverride() { + return true; + } + + @Override + public int getComparatorInputOverride(World world, int x, int y, int z, int s) { + return ((TileCorporeaCrystalCube) world.getTileEntity(x, y, z)).compValue; + } + } diff --git a/src/main/java/vazkii/botania/common/block/corporea/BlockCorporeaFunnel.java b/src/main/java/vazkii/botania/common/block/corporea/BlockCorporeaFunnel.java index 3236994d22..0ce2ef19f1 100644 --- a/src/main/java/vazkii/botania/common/block/corporea/BlockCorporeaFunnel.java +++ b/src/main/java/vazkii/botania/common/block/corporea/BlockCorporeaFunnel.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Feb 16, 2015, 2:17:05 PM (GMT)] */ package vazkii.botania.common.block.corporea; @@ -27,45 +27,46 @@ public class BlockCorporeaFunnel extends BlockCorporeaBase implements ILexiconable { - IIcon[] icons; + IIcon[] icons; - public BlockCorporeaFunnel() { - super(Material.iron, LibBlockNames.CORPOREA_FUNNEL); - setHardness(5.5F); - setStepSound(soundTypeMetal); - } + public BlockCorporeaFunnel() { + super(Material.iron, LibBlockNames.CORPOREA_FUNNEL); + setHardness(5.5F); + setStepSound(soundTypeMetal); + } - @Override - public void registerBlockIcons(IIconRegister par1IconRegister) { - icons = new IIcon[2]; - for (int i = 0; i < icons.length; i++) icons[i] = IconHelper.forBlock(par1IconRegister, this, i); - } + @Override + public void registerBlockIcons(IIconRegister par1IconRegister) { + icons = new IIcon[2]; + for(int i = 0; i < icons.length; i++) + icons[i] = IconHelper.forBlock(par1IconRegister, this, i); + } - @Override - public void onNeighborBlockChange(World world, int x, int y, int z, Block block) { - boolean power = - world.isBlockIndirectlyGettingPowered(x, y, z) || world.isBlockIndirectlyGettingPowered(x, y + 1, z); - int meta = world.getBlockMetadata(x, y, z); - boolean powered = (meta & 8) != 0; + @Override + public void onNeighborBlockChange(World world, int x, int y, int z, Block block) { + boolean power = world.isBlockIndirectlyGettingPowered(x, y, z) || world.isBlockIndirectlyGettingPowered(x, y + 1, z); + int meta = world.getBlockMetadata(x, y, z); + boolean powered = (meta & 8) != 0; - if (power && !powered) { - ((TileCorporeaFunnel) world.getTileEntity(x, y, z)).doRequest(); - world.setBlockMetadataWithNotify(x, y, z, meta | 8, 4); - } else if (!power && powered) world.setBlockMetadataWithNotify(x, y, z, meta & -9, 4); - } + if(power && !powered) { + ((TileCorporeaFunnel) world.getTileEntity(x, y, z)).doRequest(); + world.setBlockMetadataWithNotify(x, y, z, meta | 8, 4); + } else if(!power && powered) + world.setBlockMetadataWithNotify(x, y, z, meta & -9, 4); + } - @Override - public IIcon getIcon(int par1, int par2) { - return icons[par1 > 1 ? 1 : 0]; - } + @Override + public IIcon getIcon(int par1, int par2) { + return icons[par1 > 1 ? 1 : 0]; + } - @Override - public TileCorporeaBase createNewTileEntity(World world, int meta) { - return new TileCorporeaFunnel(); - } + @Override + public TileCorporeaBase createNewTileEntity(World world, int meta) { + return new TileCorporeaFunnel(); + } - @Override - public LexiconEntry getEntry(World world, int x, int y, int z, EntityPlayer player, ItemStack lexicon) { - return LexiconData.corporeaFunnel; - } + @Override + public LexiconEntry getEntry(World world, int x, int y, int z, EntityPlayer player, ItemStack lexicon) { + return LexiconData.corporeaFunnel; + } } diff --git a/src/main/java/vazkii/botania/common/block/corporea/BlockCorporeaIndex.java b/src/main/java/vazkii/botania/common/block/corporea/BlockCorporeaIndex.java index 29b3473b38..f2f604cc5a 100644 --- a/src/main/java/vazkii/botania/common/block/corporea/BlockCorporeaIndex.java +++ b/src/main/java/vazkii/botania/common/block/corporea/BlockCorporeaIndex.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Feb 15, 2015, 12:49:58 AM (GMT)] */ package vazkii.botania.common.block.corporea; @@ -27,44 +27,45 @@ public class BlockCorporeaIndex extends BlockCorporeaBase implements ILexiconable { - public BlockCorporeaIndex() { - super(Material.iron, LibBlockNames.CORPOREA_INDEX); - setHardness(5.5F); - setStepSound(soundTypeMetal); - } + public BlockCorporeaIndex() { + super(Material.iron, LibBlockNames.CORPOREA_INDEX); + setHardness(5.5F); + setStepSound(soundTypeMetal); + } - @Override - public boolean isOpaqueCube() { - return false; - } + @Override + public boolean isOpaqueCube() { + return false; + } - @Override - public boolean renderAsNormalBlock() { - return false; - } + @Override + public boolean renderAsNormalBlock() { + return false; + } - @Override - public void registerBlockIcons(IIconRegister par1IconRegister) { - // NO-OP - } + @Override + public void registerBlockIcons(IIconRegister par1IconRegister) { + // NO-OP + } - @Override - public IIcon getIcon(int side, int meta) { - return ModBlocks.storage.getIcon(0, 2); - } + @Override + public IIcon getIcon(int side, int meta) { + return ModBlocks.storage.getIcon(0, 2); + } - @Override - public int getRenderType() { - return LibRenderIDs.idCorporeaIndex; - } + @Override + public int getRenderType() { + return LibRenderIDs.idCorporeaIndex; + } - @Override - public TileCorporeaBase createNewTileEntity(World world, int meta) { - return new TileCorporeaIndex(); - } + @Override + public TileCorporeaBase createNewTileEntity(World world, int meta) { + return new TileCorporeaIndex(); + } + + @Override + public LexiconEntry getEntry(World world, int x, int y, int z, EntityPlayer player, ItemStack lexicon) { + return LexiconData.corporeaIndex; + } - @Override - public LexiconEntry getEntry(World world, int x, int y, int z, EntityPlayer player, ItemStack lexicon) { - return LexiconData.corporeaIndex; - } } diff --git a/src/main/java/vazkii/botania/common/block/corporea/BlockCorporeaInterceptor.java b/src/main/java/vazkii/botania/common/block/corporea/BlockCorporeaInterceptor.java index 09a9aa7460..b8c18f0270 100644 --- a/src/main/java/vazkii/botania/common/block/corporea/BlockCorporeaInterceptor.java +++ b/src/main/java/vazkii/botania/common/block/corporea/BlockCorporeaInterceptor.java @@ -2,15 +2,16 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Apr 19, 2015, 6:18:03 PM (GMT)] */ package vazkii.botania.common.block.corporea; import java.util.Random; + import net.minecraft.block.material.Material; import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.entity.player.EntityPlayer; @@ -28,52 +29,54 @@ public class BlockCorporeaInterceptor extends BlockCorporeaBase implements ILexiconable { - IIcon[] icons; + IIcon[] icons; + + public BlockCorporeaInterceptor() { + super(Material.iron, LibBlockNames.CORPOREA_INTERCEPTOR); + setHardness(5.5F); + setStepSound(soundTypeMetal); + } - public BlockCorporeaInterceptor() { - super(Material.iron, LibBlockNames.CORPOREA_INTERCEPTOR); - setHardness(5.5F); - setStepSound(soundTypeMetal); - } + @Override + public void registerBlockIcons(IIconRegister par1IconRegister) { + icons = new IIcon[2]; + for(int i = 0; i < icons.length; i++) + icons[i] = IconHelper.forBlock(par1IconRegister, this, i); + } - @Override - public void registerBlockIcons(IIconRegister par1IconRegister) { - icons = new IIcon[2]; - for (int i = 0; i < icons.length; i++) icons[i] = IconHelper.forBlock(par1IconRegister, this, i); - } + @Override + public IIcon getIcon(int par1, int par2) { + return icons[par1 > 1 ? 1 : 0]; + } - @Override - public IIcon getIcon(int par1, int par2) { - return icons[par1 > 1 ? 1 : 0]; - } + @Override + public void updateTick(World world, int x, int y, int z, Random rand) { + world.setBlockMetadataWithNotify(x, y, z, 0, 1 | 2); + } - @Override - public void updateTick(World world, int x, int y, int z, Random rand) { - world.setBlockMetadataWithNotify(x, y, z, 0, 1 | 2); - } + @Override + public boolean canProvidePower() { + return true; + } - @Override - public boolean canProvidePower() { - return true; - } + @Override + public int isProvidingWeakPower(IBlockAccess world, int x, int y, int z, int side) { + return world.getBlockMetadata(x, y, z) != 0 ? 15 : 0; + } - @Override - public int isProvidingWeakPower(IBlockAccess world, int x, int y, int z, int side) { - return world.getBlockMetadata(x, y, z) != 0 ? 15 : 0; - } + @Override + public int tickRate(World p_149738_1_) { + return 2; + } - @Override - public int tickRate(World p_149738_1_) { - return 2; - } + @Override + public TileCorporeaBase createNewTileEntity(World world, int meta) { + return new TileCorporeaInterceptor(); + } - @Override - public TileCorporeaBase createNewTileEntity(World world, int meta) { - return new TileCorporeaInterceptor(); - } + @Override + public LexiconEntry getEntry(World world, int x, int y, int z, EntityPlayer player, ItemStack lexicon) { + return LexiconData.corporeaInterceptor; + } - @Override - public LexiconEntry getEntry(World world, int x, int y, int z, EntityPlayer player, ItemStack lexicon) { - return LexiconData.corporeaInterceptor; - } } diff --git a/src/main/java/vazkii/botania/common/block/corporea/BlockCorporeaRetainer.java b/src/main/java/vazkii/botania/common/block/corporea/BlockCorporeaRetainer.java index 61ff942393..2d804b7146 100644 --- a/src/main/java/vazkii/botania/common/block/corporea/BlockCorporeaRetainer.java +++ b/src/main/java/vazkii/botania/common/block/corporea/BlockCorporeaRetainer.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Sep 28, 2015, 11:53:13 AM (GMT)] */ package vazkii.botania.common.block.corporea; @@ -29,48 +29,49 @@ public class BlockCorporeaRetainer extends BlockModContainer implements ILexiconable, ICraftAchievement { - public BlockCorporeaRetainer() { - super(Material.iron); - setHardness(5.5F); - setStepSound(soundTypeMetal); - setBlockName(LibBlockNames.CORPOREA_RETAINER); - } + public BlockCorporeaRetainer() { + super(Material.iron); + setHardness(5.5F); + setStepSound(soundTypeMetal); + setBlockName(LibBlockNames.CORPOREA_RETAINER); + } - @Override - public void onNeighborBlockChange(World world, int x, int y, int z, Block block) { - boolean power = - world.isBlockIndirectlyGettingPowered(x, y, z) || world.isBlockIndirectlyGettingPowered(x, y + 1, z); - int meta = world.getBlockMetadata(x, y, z); - boolean powered = (meta & 8) != 0; + @Override + public void onNeighborBlockChange(World world, int x, int y, int z, Block block) { + boolean power = world.isBlockIndirectlyGettingPowered(x, y, z) || world.isBlockIndirectlyGettingPowered(x, y + 1, z); + int meta = world.getBlockMetadata(x, y, z); + boolean powered = (meta & 8) != 0; - if (power && !powered) { - ((TileCorporeaRetainer) world.getTileEntity(x, y, z)).fulfilRequest(); - world.setBlockMetadataWithNotify(x, y, z, meta | 8, 4); - } else if (!power && powered) world.setBlockMetadataWithNotify(x, y, z, meta & -9, 4); - } + if(power && !powered) { + ((TileCorporeaRetainer) world.getTileEntity(x, y, z)).fulfilRequest(); + world.setBlockMetadataWithNotify(x, y, z, meta | 8, 4); + } else if(!power && powered) + world.setBlockMetadataWithNotify(x, y, z, meta & -9, 4); + } - @Override - public boolean hasComparatorInputOverride() { - return true; - } + @Override + public boolean hasComparatorInputOverride() { + return true; + } - @Override - public int getComparatorInputOverride(World world, int x, int y, int z, int s) { - return ((TileCorporeaRetainer) world.getTileEntity(x, y, z)).hasPendingRequest() ? 15 : 0; - } + @Override + public int getComparatorInputOverride(World world, int x, int y, int z, int s) { + return ((TileCorporeaRetainer) world.getTileEntity(x, y, z)).hasPendingRequest() ? 15 : 0; + } - @Override - public TileEntity createNewTileEntity(World world, int meta) { - return new TileCorporeaRetainer(); - } + @Override + public TileEntity createNewTileEntity(World world, int meta) { + return new TileCorporeaRetainer(); + } - @Override - public Achievement getAchievementOnCraft(ItemStack stack, EntityPlayer player, IInventory matrix) { - return ModAchievements.corporeaCraft; - } + @Override + public Achievement getAchievementOnCraft(ItemStack stack, EntityPlayer player, IInventory matrix) { + return ModAchievements.corporeaCraft; + } + + @Override + public LexiconEntry getEntry(World world, int x, int y, int z, EntityPlayer player, ItemStack lexicon) { + return LexiconData.corporeaRetainer; + } - @Override - public LexiconEntry getEntry(World world, int x, int y, int z, EntityPlayer player, ItemStack lexicon) { - return LexiconData.corporeaRetainer; - } } diff --git a/src/main/java/vazkii/botania/common/block/decor/Block18Stone.java b/src/main/java/vazkii/botania/common/block/decor/Block18Stone.java index e28fcbef5d..6614a15d19 100644 --- a/src/main/java/vazkii/botania/common/block/decor/Block18Stone.java +++ b/src/main/java/vazkii/botania/common/block/decor/Block18Stone.java @@ -2,16 +2,16 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Apr 10, 2015, 7:34:31 PM (GMT)] */ package vazkii.botania.common.block.decor; -import cpw.mods.fml.common.registry.GameRegistry; import java.util.List; + import net.minecraft.block.Block; import net.minecraft.block.material.Material; import net.minecraft.client.renderer.texture.IIconRegister; @@ -29,58 +29,62 @@ import vazkii.botania.common.item.block.ItemBlockWithMetadataAndName; import vazkii.botania.common.lexicon.LexiconData; import vazkii.botania.common.lib.LibBlockNames; +import cpw.mods.fml.common.registry.GameRegistry; public class Block18Stone extends BlockMod implements ILexiconable { - private static IIcon[] icons = new IIcon[16]; + private static IIcon[] icons = new IIcon[16]; + + public Block18Stone() { + super(Material.rock); + setHardness(1.5F); + setResistance(10F); + setStepSound(soundTypeStone); + setBlockName(LibBlockNames.STONE); + } - public Block18Stone() { - super(Material.rock); - setHardness(1.5F); - setResistance(10F); - setStepSound(soundTypeStone); - setBlockName(LibBlockNames.STONE); - } + @Override + public void registerBlockIcons(IIconRegister register) { + for(int i = 0; i < 16; i++) + icons[i] = IconHelper.forBlock(register, this, i); + } - @Override - public void registerBlockIcons(IIconRegister register) { - for (int i = 0; i < 16; i++) icons[i] = IconHelper.forBlock(register, this, i); - } + @Override + public void getSubBlocks(Item item, CreativeTabs tab, List list) { + for(int i = 0; i < 16; i++) + list.add(new ItemStack(item, 1, i)); + } - @Override - public void getSubBlocks(Item item, CreativeTabs tab, List list) { - for (int i = 0; i < 16; i++) list.add(new ItemStack(item, 1, i)); - } + @Override + public IIcon getIcon(int side, int meta) { + return icons[meta]; + } - @Override - public IIcon getIcon(int side, int meta) { - return icons[meta]; - } + @Override + protected boolean shouldRegisterInNameSet() { + return false; + } - @Override - protected boolean shouldRegisterInNameSet() { - return false; - } + @Override + public int damageDropped(int par1) { + return par1; + } - @Override - public int damageDropped(int par1) { - return par1; - } + @Override + public Block setBlockName(String par1Str) { + GameRegistry.registerBlock(this, ItemBlockWithMetadataAndName.class, par1Str); + return super.setBlockName(par1Str); + } - @Override - public Block setBlockName(String par1Str) { - GameRegistry.registerBlock(this, ItemBlockWithMetadataAndName.class, par1Str); - return super.setBlockName(par1Str); - } + @Override + public ItemStack getPickBlock(MovingObjectPosition target, World world, int x, int y, int z) { + int meta = world.getBlockMetadata(x, y, z); + return new ItemStack(this, 1, meta); + } - @Override - public ItemStack getPickBlock(MovingObjectPosition target, World world, int x, int y, int z) { - int meta = world.getBlockMetadata(x, y, z); - return new ItemStack(this, 1, meta); - } + @Override + public LexiconEntry getEntry(World world, int x, int y, int z, EntityPlayer player, ItemStack lexicon) { + return LexiconData.stoneAlchemy; + } - @Override - public LexiconEntry getEntry(World world, int x, int y, int z, EntityPlayer player, ItemStack lexicon) { - return LexiconData.stoneAlchemy; - } } diff --git a/src/main/java/vazkii/botania/common/block/decor/BlockBlaze.java b/src/main/java/vazkii/botania/common/block/decor/BlockBlaze.java index 8c40b9c65c..a627d1cde4 100644 --- a/src/main/java/vazkii/botania/common/block/decor/BlockBlaze.java +++ b/src/main/java/vazkii/botania/common/block/decor/BlockBlaze.java @@ -2,16 +2,14 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Apr 17, 2015, 7:55:33 PM (GMT)] */ package vazkii.botania.common.block.decor; -import cpw.mods.fml.common.IFuelHandler; -import cpw.mods.fml.common.registry.GameRegistry; import net.minecraft.block.material.Material; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.init.Items; @@ -25,29 +23,29 @@ import vazkii.botania.common.block.BlockMod; import vazkii.botania.common.lexicon.LexiconData; import vazkii.botania.common.lib.LibBlockNames; +import cpw.mods.fml.common.IFuelHandler; +import cpw.mods.fml.common.registry.GameRegistry; public class BlockBlaze extends BlockMod implements ILexiconable, IFuelHandler { - public BlockBlaze() { - super(Material.iron); - setHardness(3F); - setResistance(10F); - setStepSound(soundTypeMetal); - setLightLevel(1F); - setBlockName(LibBlockNames.BLAZE_BLOCK); - GameRegistry.registerFuelHandler(this); - } + public BlockBlaze() { + super(Material.iron); + setHardness(3F); + setResistance(10F); + setStepSound(soundTypeMetal); + setLightLevel(1F); + setBlockName(LibBlockNames.BLAZE_BLOCK); + GameRegistry.registerFuelHandler(this); + } + + @Override + public LexiconEntry getEntry(World world, int x, int y, int z, EntityPlayer player, ItemStack lexicon) { + return LexiconData.blazeBlock; + } - @Override - public LexiconEntry getEntry(World world, int x, int y, int z, EntityPlayer player, ItemStack lexicon) { - return LexiconData.blazeBlock; - } + @Override + public int getBurnTime(ItemStack fuel) { + return fuel.getItem() == Item.getItemFromBlock(this) ? TileEntityFurnace.getItemBurnTime(new ItemStack(Items.blaze_rod)) * (Botania.gardenOfGlassLoaded ? 5 : 10) : 0; + } - @Override - public int getBurnTime(ItemStack fuel) { - return fuel.getItem() == Item.getItemFromBlock(this) - ? TileEntityFurnace.getItemBurnTime(new ItemStack(Items.blaze_rod)) - * (Botania.gardenOfGlassLoaded ? 5 : 10) - : 0; - } } diff --git a/src/main/java/vazkii/botania/common/block/decor/BlockBuriedPetals.java b/src/main/java/vazkii/botania/common/block/decor/BlockBuriedPetals.java index 4703d19484..147a5905dd 100644 --- a/src/main/java/vazkii/botania/common/block/decor/BlockBuriedPetals.java +++ b/src/main/java/vazkii/botania/common/block/decor/BlockBuriedPetals.java @@ -2,16 +2,16 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jun 28, 2014, 6:43:33 PM (GMT)] */ package vazkii.botania.common.block.decor; -import cpw.mods.fml.common.Optional; import java.util.Random; + import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.entity.passive.EntitySheep; import net.minecraft.item.Item; @@ -24,62 +24,54 @@ import vazkii.botania.common.integration.coloredlights.ColoredLightHelper; import vazkii.botania.common.item.ModItems; import vazkii.botania.common.lib.LibBlockNames; +import cpw.mods.fml.common.Optional; public class BlockBuriedPetals extends BlockModFlower { - public BlockBuriedPetals() { - super(LibBlockNames.BURIED_PETALS); - setBlockBounds(0F, 0F, 0F, 1F, 0.1F, 1F); - setLightLevel(0.25F); - } + public BlockBuriedPetals() { + super(LibBlockNames.BURIED_PETALS); + setBlockBounds(0F, 0F, 0F, 1F, 0.1F, 1F); + setLightLevel(0.25F); + } - @Override - @Optional.Method(modid = "easycoloredlights") - public int getLightValue(IBlockAccess world, int x, int y, int z) { - return ColoredLightHelper.getPackedColor(world.getBlockMetadata(x, y, z), originalLight); - } + @Override + @Optional.Method(modid = "easycoloredlights") + public int getLightValue(IBlockAccess world, int x, int y, int z) { + return ColoredLightHelper.getPackedColor(world.getBlockMetadata(x, y, z), originalLight); + } - @Override - public void randomDisplayTick(World par1World, int par2, int par3, int par4, Random par5Random) { - int meta = par1World.getBlockMetadata(par2, par3, par4); - float[] color = EntitySheep.fleeceColorTable[meta]; + @Override + public void randomDisplayTick(World par1World, int par2, int par3, int par4, Random par5Random) { + int meta = par1World.getBlockMetadata(par2, par3, par4); + float[] color = EntitySheep.fleeceColorTable[meta]; - Botania.proxy.setSparkleFXNoClip(true); - Botania.proxy.sparkleFX( - par1World, - par2 + 0.3 + par5Random.nextFloat() * 0.5, - par3 + 0.1 + par5Random.nextFloat() * 0.1, - par4 + 0.3 + par5Random.nextFloat() * 0.5, - color[0], - color[1], - color[2], - par5Random.nextFloat(), - 5); - Botania.proxy.setSparkleFXNoClip(false); - } + Botania.proxy.setSparkleFXNoClip(true); + Botania.proxy.sparkleFX(par1World, par2 + 0.3 + par5Random.nextFloat() * 0.5, par3 + 0.1 + par5Random.nextFloat() * 0.1, par4 + 0.3 + par5Random.nextFloat() * 0.5, color[0], color[1], color[2], par5Random.nextFloat(), 5); + Botania.proxy.setSparkleFXNoClip(false); + } - @Override - public boolean registerInCreative() { - return false; - } + @Override + public boolean registerInCreative() { + return false; + } - @Override - public void registerBlockIcons(IIconRegister par1IconRegister) { - blockIcon = IconHelper.forBlock(par1IconRegister, this); - } + @Override + public void registerBlockIcons(IIconRegister par1IconRegister) { + blockIcon = IconHelper.forBlock(par1IconRegister, this); + } - @Override - public IIcon getIcon(int par1, int par2) { - return blockIcon; - } + @Override + public IIcon getIcon(int par1, int par2) { + return blockIcon; + } - @Override - public Item getItemDropped(int p_149650_1_, Random p_149650_2_, int p_149650_3_) { - return ModItems.petal; - } + @Override + public Item getItemDropped(int p_149650_1_, Random p_149650_2_, int p_149650_3_) { + return ModItems.petal; + } - @Override - public int getRenderType() { - return 0; - } + @Override + public int getRenderType() { + return 0; + } } diff --git a/src/main/java/vazkii/botania/common/block/decor/BlockCustomBrick.java b/src/main/java/vazkii/botania/common/block/decor/BlockCustomBrick.java index 7015251bd3..063738508c 100644 --- a/src/main/java/vazkii/botania/common/block/decor/BlockCustomBrick.java +++ b/src/main/java/vazkii/botania/common/block/decor/BlockCustomBrick.java @@ -2,16 +2,16 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jul 28, 2014, 9:51:48 PM (GMT)] */ package vazkii.botania.common.block.decor; -import cpw.mods.fml.common.registry.GameRegistry; import java.util.List; + import net.minecraft.block.Block; import net.minecraft.block.material.Material; import net.minecraft.client.renderer.texture.IIconRegister; @@ -29,61 +29,65 @@ import vazkii.botania.common.item.block.ItemBlockWithMetadataAndName; import vazkii.botania.common.lexicon.LexiconData; import vazkii.botania.common.lib.LibBlockNames; +import cpw.mods.fml.common.registry.GameRegistry; public class BlockCustomBrick extends BlockMod implements ILexiconable { - private static final int TYPES = 16; - IIcon[] icons; + private static final int TYPES = 16; + IIcon[] icons; + + public BlockCustomBrick() { + super(Material.rock); + setHardness(2.0F); + setResistance(5.0F); + setStepSound(soundTypeStone); + setBlockName(LibBlockNames.CUSTOM_BRICK); + } - public BlockCustomBrick() { - super(Material.rock); - setHardness(2.0F); - setResistance(5.0F); - setStepSound(soundTypeStone); - setBlockName(LibBlockNames.CUSTOM_BRICK); - } + @Override + protected boolean shouldRegisterInNameSet() { + return false; + } - @Override - protected boolean shouldRegisterInNameSet() { - return false; - } + @Override + public int damageDropped(int par1) { + return par1; + } - @Override - public int damageDropped(int par1) { - return par1; - } + @Override + public Block setBlockName(String par1Str) { + GameRegistry.registerBlock(this, ItemBlockWithMetadataAndName.class, par1Str); + return super.setBlockName(par1Str); + } - @Override - public Block setBlockName(String par1Str) { - GameRegistry.registerBlock(this, ItemBlockWithMetadataAndName.class, par1Str); - return super.setBlockName(par1Str); - } + @Override + public void getSubBlocks(Item par1, CreativeTabs par2CreativeTabs, List par3List) { + for(int i = 0; i < TYPES; i++) + par3List.add(new ItemStack(par1, 1, i)); + } - @Override - public void getSubBlocks(Item par1, CreativeTabs par2CreativeTabs, List par3List) { - for (int i = 0; i < TYPES; i++) par3List.add(new ItemStack(par1, 1, i)); - } + @Override + public void registerBlockIcons(IIconRegister par1IconRegister) { + icons = new IIcon[TYPES]; + for(int i = 0; i < TYPES; i++) + icons[i] = IconHelper.forBlock(par1IconRegister, this, i); + } - @Override - public void registerBlockIcons(IIconRegister par1IconRegister) { - icons = new IIcon[TYPES]; - for (int i = 0; i < TYPES; i++) icons[i] = IconHelper.forBlock(par1IconRegister, this, i); - } + @Override + public IIcon getIcon(int par1, int par2) { + return icons[Math.min(TYPES - 1, par2)]; + } - @Override - public IIcon getIcon(int par1, int par2) { - return icons[Math.min(TYPES - 1, par2)]; - } + @Override + public ItemStack getPickBlock(MovingObjectPosition target, World world, int x, int y, int z) { + int meta = world.getBlockMetadata(x, y, z); + return new ItemStack(this, 1, meta); + } - @Override - public ItemStack getPickBlock(MovingObjectPosition target, World world, int x, int y, int z) { - int meta = world.getBlockMetadata(x, y, z); - return new ItemStack(this, 1, meta); - } + @Override + public LexiconEntry getEntry(World world, int x, int y, int z, EntityPlayer player, ItemStack lexicon) { + int meta = world.getBlockMetadata(x, y, z); + return meta >= 4 ? LexiconData.azulejo : LexiconData.decorativeBlocks; + } - @Override - public LexiconEntry getEntry(World world, int x, int y, int z, EntityPlayer player, ItemStack lexicon) { - int meta = world.getBlockMetadata(x, y, z); - return meta >= 4 ? LexiconData.azulejo : LexiconData.decorativeBlocks; - } } diff --git a/src/main/java/vazkii/botania/common/block/decor/BlockDirtPath.java b/src/main/java/vazkii/botania/common/block/decor/BlockDirtPath.java index 7e7d557644..500bd4e473 100644 --- a/src/main/java/vazkii/botania/common/block/decor/BlockDirtPath.java +++ b/src/main/java/vazkii/botania/common/block/decor/BlockDirtPath.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jan 18, 2015, 1:47:03 AM (GMT)] */ package vazkii.botania.common.block.decor; @@ -29,72 +29,75 @@ public class BlockDirtPath extends BlockMod implements ILexiconable { - public BlockDirtPath() { - super(Material.ground); - setBlockBounds(0F, 0F, 0F, 1F, 15F / 16F, 1F); - setLightOpacity(255); - setHardness(0.6F); - setStepSound(soundTypeGravel); - setBlockName(LibBlockNames.DIRT_PATH); - useNeighborBrightness = true; - } + public BlockDirtPath() { + super(Material.ground); + setBlockBounds(0F, 0F, 0F, 1F, 15F / 16F, 1F); + setLightOpacity(255); + setHardness(0.6F); + setStepSound(soundTypeGravel); + setBlockName(LibBlockNames.DIRT_PATH); + useNeighborBrightness = true; + } - @Override - public boolean isToolEffective(String type, int metadata) { - return type.equals("shovel"); - } + @Override + public boolean isToolEffective(String type, int metadata) { + return type.equals("shovel"); + } - @Override - public void onEntityWalking(World world, int x, int y, int z, Entity entity) { - float speed = 2F; - float max = 0.4F; + @Override + public void onEntityWalking(World world, int x, int y, int z, Entity entity) { + float speed = 2F; + float max = 0.4F; - double motionX = Math.abs(entity.motionX); - double motionZ = Math.abs(entity.motionZ); - if (motionX < max) entity.motionX *= speed; - if (motionZ < max) entity.motionZ *= speed; - } + double motionX = Math.abs(entity.motionX); + double motionZ = Math.abs(entity.motionZ); + if(motionX < max) + entity.motionX *= speed; + if(motionZ < max) + entity.motionZ *= speed; + } - @Override - public void setBlockBoundsBasedOnState(IBlockAccess world, int x, int y, int z) { - Block blockAbove = world.getBlock(x, y + 1, z); - if (!blockAbove.isAir(world, x, y + 1, z)) setBlockBounds(0F, 0F, 0F, 1F, 1, 1F); - else setBlockBounds(0F, 0F, 0F, 1F, 15F / 16F, 1F); - } + @Override + public void setBlockBoundsBasedOnState(IBlockAccess world, int x, int y, int z) { + Block blockAbove = world.getBlock(x, y + 1, z); + if(!blockAbove.isAir(world, x, y + 1, z)) + setBlockBounds(0F, 0F, 0F, 1F, 1, 1F); + else setBlockBounds(0F, 0F, 0F, 1F, 15F / 16F, 1F); + } - @Override - public boolean isSideSolid(IBlockAccess world, int x, int y, int z, ForgeDirection side) { - return side == ForgeDirection.DOWN; - } + @Override + public boolean isSideSolid(IBlockAccess world, int x, int y, int z, ForgeDirection side) { + return side == ForgeDirection.DOWN; + } - @Override - public void onNeighborBlockChange(World world, int x, int y, int z, Block block) { - setBlockBoundsBasedOnState(world, x, y, z); - } + @Override + public void onNeighborBlockChange(World world, int x, int y, int z, Block block) { + setBlockBoundsBasedOnState(world, x, y, z); + } - @Override - public AxisAlignedBB getCollisionBoundingBoxFromPool(World world, int x, int y, int z) { - return AxisAlignedBB.getBoundingBox(x, y, z, x + 1, y + 1, z + 1); - } + @Override + public AxisAlignedBB getCollisionBoundingBoxFromPool(World world, int x, int y, int z) { + return AxisAlignedBB.getBoundingBox(x, y, z, x + 1, y + 1, z + 1); + } - @Override - public boolean isOpaqueCube() { - return false; - } + @Override + public boolean isOpaqueCube() { + return false; + } - @Override - public boolean renderAsNormalBlock() { - return false; - } + @Override + public boolean renderAsNormalBlock() { + return false; + } - @Override - public boolean canSustainPlant( - IBlockAccess world, int x, int y, int z, ForgeDirection direction, IPlantable plantable) { - return plantable.getPlantType(world, x, y - 1, z) == EnumPlantType.Plains; - } + @Override + public boolean canSustainPlant(IBlockAccess world, int x, int y, int z, ForgeDirection direction, IPlantable plantable) { + return plantable.getPlantType(world, x, y - 1, z) == EnumPlantType.Plains; + } + + @Override + public LexiconEntry getEntry(World world, int x, int y, int z, EntityPlayer player, ItemStack lexicon) { + return LexiconData.dirtPath; + } - @Override - public LexiconEntry getEntry(World world, int x, int y, int z, EntityPlayer player, ItemStack lexicon) { - return LexiconData.dirtPath; - } } diff --git a/src/main/java/vazkii/botania/common/block/decor/BlockElfGlass.java b/src/main/java/vazkii/botania/common/block/decor/BlockElfGlass.java index c2a4887d87..f4597f2b93 100644 --- a/src/main/java/vazkii/botania/common/block/decor/BlockElfGlass.java +++ b/src/main/java/vazkii/botania/common/block/decor/BlockElfGlass.java @@ -2,15 +2,16 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Sep 8, 2014, 6:40:17 PM (GMT)] */ package vazkii.botania.common.block.decor; import java.util.Random; + import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; @@ -26,33 +27,35 @@ public class BlockElfGlass extends BlockManaGlass implements IElvenItem, ILexiconable { - private static final int ICON_COUNT = 4; - IIcon[] icons; - - public BlockElfGlass() { - super(LibBlockNames.ELF_GLASS); - } - - @Override - public void registerBlockIcons(IIconRegister par1IconRegister) { - icons = new IIcon[ICON_COUNT]; - for (int i = 0; i < ICON_COUNT; i++) icons[i] = IconHelper.forBlock(par1IconRegister, this, i); - blockIcon = IconHelper.forBlock(par1IconRegister, this); - } - - @Override - public IIcon getIcon(IBlockAccess world, int x, int y, int z, int s) { - int v = (int) Math.floor(new Random(x * 10 ^ y * 20 ^ z * 30).nextInt(ICON_COUNT * 100) / 100.0); - return icons[v]; - } - - @Override - public boolean isElvenItem(ItemStack stack) { - return true; - } - - @Override - public LexiconEntry getEntry(World world, int x, int y, int z, EntityPlayer player, ItemStack lexicon) { - return LexiconData.elvenResources; - } + private static final int ICON_COUNT = 4; + IIcon[] icons; + + public BlockElfGlass() { + super(LibBlockNames.ELF_GLASS); + } + + @Override + public void registerBlockIcons(IIconRegister par1IconRegister) { + icons = new IIcon[ICON_COUNT]; + for(int i = 0; i < ICON_COUNT; i++) + icons[i] = IconHelper.forBlock(par1IconRegister, this, i); + blockIcon = IconHelper.forBlock(par1IconRegister, this); + } + + @Override + public IIcon getIcon(IBlockAccess world, int x, int y, int z, int s) { + int v = (int) Math.floor(new Random(x * 10 ^ y * 20 ^ z * 30).nextInt(ICON_COUNT * 100) / 100.0); + return icons[v]; + } + + @Override + public boolean isElvenItem(ItemStack stack) { + return true; + } + + @Override + public LexiconEntry getEntry(World world, int x, int y, int z, EntityPlayer player, ItemStack lexicon) { + return LexiconData.elvenResources; + } + } diff --git a/src/main/java/vazkii/botania/common/block/decor/BlockEndStoneBrick.java b/src/main/java/vazkii/botania/common/block/decor/BlockEndStoneBrick.java index 81120bd591..22b476c676 100644 --- a/src/main/java/vazkii/botania/common/block/decor/BlockEndStoneBrick.java +++ b/src/main/java/vazkii/botania/common/block/decor/BlockEndStoneBrick.java @@ -2,16 +2,16 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Feb 16, 2015, 8:17:12 PM (GMT)] */ package vazkii.botania.common.block.decor; -import cpw.mods.fml.common.registry.GameRegistry; import java.util.List; + import net.minecraft.block.Block; import net.minecraft.block.material.Material; import net.minecraft.client.renderer.texture.IIconRegister; @@ -29,60 +29,63 @@ import vazkii.botania.common.item.block.ItemBlockWithMetadataAndName; import vazkii.botania.common.lexicon.LexiconData; import vazkii.botania.common.lib.LibBlockNames; +import cpw.mods.fml.common.registry.GameRegistry; public class BlockEndStoneBrick extends BlockMod implements ILexiconable { - private static IIcon[] icons = new IIcon[5]; + private static IIcon[] icons = new IIcon[5]; + + public BlockEndStoneBrick() { + super(Material.rock); + setHardness(1.5F); + setResistance(10F); + setStepSound(soundTypeStone); + setBlockName(LibBlockNames.END_STONE_BRICK); + } - public BlockEndStoneBrick() { - super(Material.rock); - setHardness(1.5F); - setResistance(10F); - setStepSound(soundTypeStone); - setBlockName(LibBlockNames.END_STONE_BRICK); - } + @Override + public void registerBlockIcons(IIconRegister register) { + for(int i = 0; i < icons.length; i++) { + icons[i] = IconHelper.forBlock(register, this, i); + } + } - @Override - public void registerBlockIcons(IIconRegister register) { - for (int i = 0; i < icons.length; i++) { - icons[i] = IconHelper.forBlock(register, this, i); - } - } + @Override + public void getSubBlocks(Item item, CreativeTabs tab, List list) { + for(int i = 0; i < 4; i++) + list.add(new ItemStack(item, 1, i)); + } - @Override - public void getSubBlocks(Item item, CreativeTabs tab, List list) { - for (int i = 0; i < 4; i++) list.add(new ItemStack(item, 1, i)); - } + @Override + public IIcon getIcon(int side, int meta) { + return meta == 3 ? icons[side == 0 || side == 1 ? 4 : 3] : icons[Math.min(icons.length - 1, meta)]; + } - @Override - public IIcon getIcon(int side, int meta) { - return meta == 3 ? icons[side == 0 || side == 1 ? 4 : 3] : icons[Math.min(icons.length - 1, meta)]; - } + @Override + protected boolean shouldRegisterInNameSet() { + return false; + } - @Override - protected boolean shouldRegisterInNameSet() { - return false; - } + @Override + public int damageDropped(int par1) { + return par1; + } - @Override - public int damageDropped(int par1) { - return par1; - } + @Override + public Block setBlockName(String par1Str) { + GameRegistry.registerBlock(this, ItemBlockWithMetadataAndName.class, par1Str); + return super.setBlockName(par1Str); + } - @Override - public Block setBlockName(String par1Str) { - GameRegistry.registerBlock(this, ItemBlockWithMetadataAndName.class, par1Str); - return super.setBlockName(par1Str); - } + @Override + public ItemStack getPickBlock(MovingObjectPosition target, World world, int x, int y, int z) { + int meta = world.getBlockMetadata(x, y, z); + return new ItemStack(this, 1, meta); + } - @Override - public ItemStack getPickBlock(MovingObjectPosition target, World world, int x, int y, int z) { - int meta = world.getBlockMetadata(x, y, z); - return new ItemStack(this, 1, meta); - } + @Override + public LexiconEntry getEntry(World world, int x, int y, int z, EntityPlayer player, ItemStack lexicon) { + return LexiconData.endStoneDecor; + } - @Override - public LexiconEntry getEntry(World world, int x, int y, int z, EntityPlayer player, ItemStack lexicon) { - return LexiconData.endStoneDecor; - } } diff --git a/src/main/java/vazkii/botania/common/block/decor/BlockFloatingFlower.java b/src/main/java/vazkii/botania/common/block/decor/BlockFloatingFlower.java index e6bdd358bc..0d69eae4e5 100644 --- a/src/main/java/vazkii/botania/common/block/decor/BlockFloatingFlower.java +++ b/src/main/java/vazkii/botania/common/block/decor/BlockFloatingFlower.java @@ -2,18 +2,16 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jul 8, 2014, 10:16:53 PM (GMT)] */ package vazkii.botania.common.block.decor; import cpw.mods.fml.common.Optional; import cpw.mods.fml.common.registry.GameRegistry; -import java.util.List; -import java.util.Random; import net.minecraft.block.Block; import net.minecraft.block.material.Material; import net.minecraft.client.renderer.texture.IIconRegister; @@ -44,136 +42,133 @@ import vazkii.botania.common.lexicon.LexiconData; import vazkii.botania.common.lib.LibBlockNames; +import java.util.List; +import java.util.Random; + @Optional.Interface(modid = "Thaumcraft", iface = "thaumcraft.api.crafting.IInfusionStabiliser", striprefs = true) public class BlockFloatingFlower extends BlockModContainer implements ILexiconable, IInfusionStabiliser { - public BlockFloatingFlower() { - this(LibBlockNames.MINI_ISLAND); - } - - public BlockFloatingFlower(String name) { - super(Material.ground); - setBlockName(name); - setHardness(0.5F); - setStepSound(soundTypeGravel); - setLightLevel(1F); - - float f = 0.1F; - setBlockBounds(f, f, f, 1F - f, 1F - f, 1F - f); - } - - @Override - @Optional.Method(modid = "easycoloredlights") - public int getLightValue(IBlockAccess world, int x, int y, int z) { - return ColoredLightHelper.getPackedColor(world.getBlockMetadata(x, y, z), originalLight); - } - - @Override - protected boolean shouldRegisterInNameSet() { - return false; - } - - @Override - public Block setBlockName(String par1Str) { - register(par1Str); - return super.setBlockName(par1Str); - } - - protected void register(String name) { - GameRegistry.registerBlock(this, ItemBlockWithMetadataAndName.class, name); - } - - @Override - public void randomDisplayTick(World par1World, int par2, int par3, int par4, Random par5Random) { - int meta = par1World.getBlockMetadata(par2, par3, par4); - float[] color = EntitySheep.fleeceColorTable[meta]; - - if (par5Random.nextDouble() < ConfigHandler.flowerParticleFrequency) - Botania.proxy.sparkleFX( - par1World, - par2 + 0.3 + par5Random.nextFloat() * 0.5, - par3 + 0.5 + par5Random.nextFloat() * 0.5, - par4 + 0.3 + par5Random.nextFloat() * 0.5, - color[0], - color[1], - color[2], - par5Random.nextFloat(), - 5); - } - - @Override - public void registerBlockIcons(IIconRegister par1IconRegister) { - // NO-OP - } - - @Override - public void getSubBlocks(Item par1, CreativeTabs par2, List par3) { - for (int i = 0; i < 16; i++) par3.add(new ItemStack(par1, 1, i)); - } - - @Override - public int damageDropped(int par1) { - return par1; - } - - @Override - public boolean isOpaqueCube() { - return false; - } - - @Override - public boolean renderAsNormalBlock() { - return false; - } - - @Override - public IIcon getIcon(int par1, int par2) { - return Blocks.dirt.getIcon(par1, par2); - } - - @Override - public boolean onBlockActivated( - World world, int x, int y, int z, EntityPlayer player, int side, float hitX, float hitY, float hitZ) { - ItemStack stack = player.getCurrentEquippedItem(); - if (stack != null) { - IFloatingFlower flower = (IFloatingFlower) world.getTileEntity(x, y, z); - IslandType type = null; - if (stack.getItem() == Items.snowball) type = IslandType.SNOW; - else if (stack.getItem() instanceof IFloatingFlowerVariant) { - IslandType newType = ((IFloatingFlowerVariant) stack.getItem()).getIslandType(stack); - if (newType != null) type = newType; - } - - if (type != null && type != flower.getIslandType()) { - if (!world.isRemote) { - flower.setIslandType(type); - VanillaPacketDispatcher.dispatchTEToNearbyPlayers(world, x, y, z); - } - - if (!player.capabilities.isCreativeMode) stack.stackSize--; - return true; - } - } - return false; - } - - @Override - public int getRenderType() { - return LibRenderIDs.idMiniIsland; - } - - @Override - public TileEntity createNewTileEntity(World world, int meta) { - return new TileFloatingFlower(); - } - - @Override - public LexiconEntry getEntry(World world, int x, int y, int z, EntityPlayer player, ItemStack lexicon) { - return LexiconData.shinyFlowers; - } - - @Override - public boolean canStabaliseInfusion(World world, int x, int y, int z) { - return ConfigHandler.enableThaumcraftStablizers; - } + public BlockFloatingFlower() { + this(LibBlockNames.MINI_ISLAND); + } + + public BlockFloatingFlower(String name) { + super(Material.ground); + setBlockName(name); + setHardness(0.5F); + setStepSound(soundTypeGravel); + setLightLevel(1F); + + float f = 0.1F; + setBlockBounds(f, f, f, 1F - f, 1F - f, 1F - f); + } + + @Override + @Optional.Method(modid = "easycoloredlights") + public int getLightValue(IBlockAccess world, int x, int y, int z) { + return ColoredLightHelper.getPackedColor(world.getBlockMetadata(x, y, z), originalLight); + } + + @Override + protected boolean shouldRegisterInNameSet() { + return false; + } + + @Override + public Block setBlockName(String par1Str) { + register(par1Str); + return super.setBlockName(par1Str); + } + + protected void register(String name) { + GameRegistry.registerBlock(this, ItemBlockWithMetadataAndName.class, name); + } + + @Override + public void randomDisplayTick(World par1World, int par2, int par3, int par4, Random par5Random) { + int meta = par1World.getBlockMetadata(par2, par3, par4); + float[] color = EntitySheep.fleeceColorTable[meta]; + + if(par5Random.nextDouble() < ConfigHandler.flowerParticleFrequency) + Botania.proxy.sparkleFX(par1World, par2 + 0.3 + par5Random.nextFloat() * 0.5, par3 + 0.5 + par5Random.nextFloat() * 0.5, par4 + 0.3 + par5Random.nextFloat() * 0.5, color[0], color[1], color[2], par5Random.nextFloat(), 5); + } + + @Override + public void registerBlockIcons(IIconRegister par1IconRegister) { + // NO-OP + } + + @Override + public void getSubBlocks(Item par1, CreativeTabs par2, List par3) { + for(int i = 0; i < 16; i++) + par3.add(new ItemStack(par1, 1, i)); + } + + @Override + public int damageDropped(int par1) { + return par1; + } + + @Override + public boolean isOpaqueCube() { + return false; + } + + @Override + public boolean renderAsNormalBlock() { + return false; + } + + @Override + public IIcon getIcon(int par1, int par2) { + return Blocks.dirt.getIcon(par1, par2); + } + + @Override + public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int side, float hitX, float hitY, float hitZ) { + ItemStack stack = player.getCurrentEquippedItem(); + if(stack != null) { + IFloatingFlower flower = (IFloatingFlower) world.getTileEntity(x, y, z); + IslandType type = null; + if(stack.getItem() == Items.snowball) + type = IslandType.SNOW; + else if(stack.getItem() instanceof IFloatingFlowerVariant) { + IslandType newType = ((IFloatingFlowerVariant) stack.getItem()).getIslandType(stack); + if(newType != null) + type = newType; + } + + if(type != null && type != flower.getIslandType()) { + if(!world.isRemote) { + flower.setIslandType(type); + VanillaPacketDispatcher.dispatchTEToNearbyPlayers(world, x, y, z); + } + + if(!player.capabilities.isCreativeMode) + stack.stackSize--; + return true; + } + } + return false; + } + + @Override + public int getRenderType() { + return LibRenderIDs.idMiniIsland; + } + + @Override + public TileEntity createNewTileEntity(World world, int meta) { + return new TileFloatingFlower(); + } + + @Override + public LexiconEntry getEntry(World world, int x, int y, int z, EntityPlayer player, ItemStack lexicon) { + return LexiconData.shinyFlowers; + } + + @Override + public boolean canStabaliseInfusion(World world, int x, int y, int z) { + return ConfigHandler.enableThaumcraftStablizers; + } } diff --git a/src/main/java/vazkii/botania/common/block/decor/BlockManaBeacon.java b/src/main/java/vazkii/botania/common/block/decor/BlockManaBeacon.java index 0952f2fd9f..90d3d7a119 100644 --- a/src/main/java/vazkii/botania/common/block/decor/BlockManaBeacon.java +++ b/src/main/java/vazkii/botania/common/block/decor/BlockManaBeacon.java @@ -2,17 +2,17 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Mar 3, 2014, 4:53:59 PM (GMT)] */ package vazkii.botania.common.block.decor; -import cpw.mods.fml.common.registry.GameRegistry; import java.awt.Color; import java.util.List; + import net.minecraft.block.Block; import net.minecraft.block.material.Material; import net.minecraft.client.renderer.texture.IIconRegister; @@ -33,81 +33,84 @@ import vazkii.botania.common.item.block.ItemBlockWithMetadataAndName; import vazkii.botania.common.lexicon.LexiconData; import vazkii.botania.common.lib.LibBlockNames; +import cpw.mods.fml.common.registry.GameRegistry; public class BlockManaBeacon extends BlockModContainer implements ILexiconable { - IIcon[] icons; - - public BlockManaBeacon() { - super(Material.iron); - setHardness(5.0F); - setResistance(10.0F); - setStepSound(soundTypeMetal); - float size = 3F / 16F; - setBlockBounds(size, size, size, 1F - size, 1F - size, 1F - size); - setBlockName(LibBlockNames.MANA_BEACON); - } - - @Override - public void registerBlockIcons(IIconRegister par1IconRegister) { - icons = new IIcon[2]; - for (int i = 0; i < 2; i++) icons[i] = IconHelper.forBlock(par1IconRegister, this, i); - } - - @Override - public IIcon getIcon(int par1, int par2) { - return icons[par1 == 1 ? 1 : 0]; - } - - @Override - public void getSubBlocks(Item par1, CreativeTabs par2CreativeTabs, List par3List) { - for (int i = 0; i < 16; i++) par3List.add(new ItemStack(par1, 1, i)); - } - - @Override - public Block setBlockName(String par1Str) { - GameRegistry.registerBlock(this, ItemBlockWithMetadataAndName.class, par1Str); - return super.setBlockName(par1Str); - } - - @Override - protected boolean shouldRegisterInNameSet() { - return false; - } - - @Override - public boolean renderAsNormalBlock() { - return false; - } - - @Override - public boolean isOpaqueCube() { - return false; - } - - @Override - public int damageDropped(int par1) { - return par1; - } - - @Override - public int getRenderColor(int par1) { - float[] color = EntitySheep.fleeceColorTable[par1]; - return new Color(color[0], color[1], color[2]).getRGB(); - } - - @Override - public int colorMultiplier(IBlockAccess par1iBlockAccess, int par2, int par3, int par4) { - return getRenderColor(par1iBlockAccess.getBlockMetadata(par2, par3, par4)); - } - - @Override - public LexiconEntry getEntry(World world, int x, int y, int z, EntityPlayer player, ItemStack lexicon) { - return LexiconData.unstableBlocks; - } - - @Override - public TileEntity createNewTileEntity(World world, int meta) { - return new TileManaBeacon(); - } + IIcon[] icons; + + public BlockManaBeacon() { + super(Material.iron); + setHardness(5.0F); + setResistance(10.0F); + setStepSound(soundTypeMetal); + float size = 3F / 16F; + setBlockBounds(size, size, size, 1F - size, 1F - size, 1F - size); + setBlockName(LibBlockNames.MANA_BEACON); + } + + @Override + public void registerBlockIcons(IIconRegister par1IconRegister) { + icons = new IIcon[2]; + for(int i = 0; i < 2; i++) + icons[i] = IconHelper.forBlock(par1IconRegister, this, i); + } + + @Override + public IIcon getIcon(int par1, int par2) { + return icons[par1 == 1 ? 1 : 0]; + } + + @Override + public void getSubBlocks(Item par1, CreativeTabs par2CreativeTabs, List par3List) { + for(int i = 0; i < 16; i++) + par3List.add(new ItemStack(par1, 1, i)); + } + + @Override + public Block setBlockName(String par1Str) { + GameRegistry.registerBlock(this, ItemBlockWithMetadataAndName.class, par1Str); + return super.setBlockName(par1Str); + } + + @Override + protected boolean shouldRegisterInNameSet() { + return false; + } + + @Override + public boolean renderAsNormalBlock() { + return false; + } + + @Override + public boolean isOpaqueCube() { + return false; + } + + @Override + public int damageDropped(int par1) { + return par1; + } + + @Override + public int getRenderColor(int par1) { + float[] color = EntitySheep.fleeceColorTable[par1]; + return new Color(color[0], color[1], color[2]).getRGB(); + } + + @Override + public int colorMultiplier(IBlockAccess par1iBlockAccess, int par2, int par3, int par4) { + return getRenderColor(par1iBlockAccess.getBlockMetadata(par2, par3, par4)); + } + + @Override + public LexiconEntry getEntry(World world, int x, int y, int z, EntityPlayer player, ItemStack lexicon) { + return LexiconData.unstableBlocks; + } + + @Override + public TileEntity createNewTileEntity(World world, int meta) { + return new TileManaBeacon(); + } } diff --git a/src/main/java/vazkii/botania/common/block/decor/BlockManaFlame.java b/src/main/java/vazkii/botania/common/block/decor/BlockManaFlame.java index 1c0af52a8f..fdf5c95b66 100644 --- a/src/main/java/vazkii/botania/common/block/decor/BlockManaFlame.java +++ b/src/main/java/vazkii/botania/common/block/decor/BlockManaFlame.java @@ -2,16 +2,16 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Dec 21, 2014, 12:28:06 AM (GMT)] */ package vazkii.botania.common.block.decor; -import cpw.mods.fml.common.Optional; import java.util.ArrayList; + import net.minecraft.block.material.Material; import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.entity.player.EntityPlayer; @@ -31,94 +31,94 @@ import vazkii.botania.common.lexicon.LexiconData; import vazkii.botania.common.lib.LibBlockNames; import vazkii.botania.common.world.WorldTypeSkyblock; +import cpw.mods.fml.common.Optional; public class BlockManaFlame extends BlockModContainer implements ILexiconable { - public BlockManaFlame() { - super(Material.cloth); - setBlockName(LibBlockNames.MANA_FLAME); - float f = 0.25F; - setStepSound(soundTypeCloth); - setBlockBounds(f, f, f, 1F - f, 1F - f, 1F - f); - setLightLevel(1F); - } - - @Override - public boolean registerInCreative() { - return false; - } - - @Override - @Optional.Method(modid = "easycoloredlights") - public int getLightValue(IBlockAccess world, int x, int y, int z) { - return ((TileManaFlame) world.getTileEntity(x, y, z)).getLightColor(); - } - - @Override - public void registerBlockIcons(IIconRegister par1IconRegister) { - // NO-OP - } - - @Override - public int getRenderType() { - return -1; - } - - @Override - public boolean isOpaqueCube() { - return false; - } - - @Override - public boolean renderAsNormalBlock() { - return false; - } - - @Override - public boolean getBlocksMovement(IBlockAccess p_149655_1_, int p_149655_2_, int p_149655_3_, int p_149655_4_) { - return true; - } - - @Override - public AxisAlignedBB getCollisionBoundingBoxFromPool( - World p_149668_1_, int p_149668_2_, int p_149668_3_, int p_149668_4_) { - return null; - } - - @Override - public boolean onBlockActivated( - World world, int x, int y, int z, EntityPlayer player, int s, float xs, float ys, float zs) { - if (WorldTypeSkyblock.isWorldSkyblock(world)) { - ItemStack stack = player.getCurrentEquippedItem(); - if (stack != null - && stack.getItem() == Item.getItemFromBlock(Blocks.sapling) - && !player.inventory.hasItem(ModItems.lexicon)) { - if (!world.isRemote) stack.stackSize--; - if (!player.inventory.addItemStackToInventory(new ItemStack(ModItems.lexicon))) - player.dropPlayerItemWithRandomChoice(new ItemStack(ModItems.lexicon), false); - return true; - } - } - return false; - } - - @Override - public IIcon getIcon(int side, int meta) { - return Blocks.fire.getIcon(side, meta); - } - - @Override - public ArrayList getDrops(World world, int x, int y, int z, int metadata, int fortune) { - return new ArrayList(); - } - - @Override - public TileEntity createNewTileEntity(World world, int meta) { - return new TileManaFlame(); - } - - @Override - public LexiconEntry getEntry(World world, int x, int y, int z, EntityPlayer player, ItemStack lexicon) { - return LexiconData.lenses; - } + public BlockManaFlame() { + super(Material.cloth); + setBlockName(LibBlockNames.MANA_FLAME); + float f = 0.25F; + setStepSound(soundTypeCloth); + setBlockBounds(f, f, f, 1F - f, 1F - f, 1F - f); + setLightLevel(1F); + } + + @Override + public boolean registerInCreative() { + return false; + } + + @Override + @Optional.Method(modid = "easycoloredlights") + public int getLightValue(IBlockAccess world, int x, int y, int z) { + return ((TileManaFlame) world.getTileEntity(x, y, z)).getLightColor(); + } + + @Override + public void registerBlockIcons(IIconRegister par1IconRegister) { + // NO-OP + } + + @Override + public int getRenderType() { + return -1; + } + + @Override + public boolean isOpaqueCube() { + return false; + } + + @Override + public boolean renderAsNormalBlock() { + return false; + } + + @Override + public boolean getBlocksMovement(IBlockAccess p_149655_1_, int p_149655_2_, int p_149655_3_, int p_149655_4_) { + return true; + } + + @Override + public AxisAlignedBB getCollisionBoundingBoxFromPool(World p_149668_1_, int p_149668_2_, int p_149668_3_, int p_149668_4_) { + return null; + } + + @Override + public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int s, float xs, float ys, float zs) { + if(WorldTypeSkyblock.isWorldSkyblock(world)) { + ItemStack stack = player.getCurrentEquippedItem(); + if(stack != null && stack.getItem() == Item.getItemFromBlock(Blocks.sapling) && !player.inventory.hasItem(ModItems.lexicon)) { + if(!world.isRemote) + stack.stackSize--; + if(!player.inventory.addItemStackToInventory(new ItemStack(ModItems.lexicon))) + player.dropPlayerItemWithRandomChoice(new ItemStack(ModItems.lexicon), false); + return true; + } + + } + return false; + } + + @Override + public IIcon getIcon(int side, int meta) { + return Blocks.fire.getIcon(side, meta); + } + + @Override + public ArrayList getDrops(World world, int x, int y, int z, int metadata, int fortune) { + return new ArrayList(); + } + + @Override + public TileEntity createNewTileEntity(World world, int meta) { + return new TileManaFlame(); + } + + @Override + public LexiconEntry getEntry(World world, int x, int y, int z, EntityPlayer player, ItemStack lexicon) { + return LexiconData.lenses; + } + } diff --git a/src/main/java/vazkii/botania/common/block/decor/BlockManaGlass.java b/src/main/java/vazkii/botania/common/block/decor/BlockManaGlass.java index 8ff8d6f0a0..b38cc8e33a 100644 --- a/src/main/java/vazkii/botania/common/block/decor/BlockManaGlass.java +++ b/src/main/java/vazkii/botania/common/block/decor/BlockManaGlass.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Nov 1, 2014, 6:09:29 PM (GMT)] */ package vazkii.botania.common.block.decor; @@ -24,45 +24,42 @@ public class BlockManaGlass extends BlockMod implements ILexiconable { - public BlockManaGlass() { - this(LibBlockNames.MANA_GLASS); - } + public BlockManaGlass() { + this(LibBlockNames.MANA_GLASS); + } - public BlockManaGlass(String name) { - super(Material.glass); - setHardness(0.3F); - setStepSound(soundTypeGlass); - setLightLevel(1.0F); - setBlockName(name); - } + public BlockManaGlass(String name) { + super(Material.glass); + setHardness(0.3F); + setStepSound(soundTypeGlass); + setLightLevel(1.0F); + setBlockName(name); + } - @Override - public boolean isOpaqueCube() { - return false; - } + @Override + public boolean isOpaqueCube() { + return false; + } - public boolean shouldSideBeRendered1( - IBlockAccess p_149646_1_, int p_149646_2_, int p_149646_3_, int p_149646_4_, int p_149646_5_) { - Block block = p_149646_1_.getBlock(p_149646_2_, p_149646_3_, p_149646_4_); + public boolean shouldSideBeRendered1(IBlockAccess p_149646_1_, int p_149646_2_, int p_149646_3_, int p_149646_4_, int p_149646_5_) { + Block block = p_149646_1_.getBlock(p_149646_2_, p_149646_3_, p_149646_4_); - return block == this - ? false - : super.shouldSideBeRendered(p_149646_1_, p_149646_2_, p_149646_3_, p_149646_4_, p_149646_5_); - } + return block == this ? false : super.shouldSideBeRendered(p_149646_1_, p_149646_2_, p_149646_3_, p_149646_4_, p_149646_5_); + } - @Override - public boolean shouldSideBeRendered( - IBlockAccess p_149646_1_, int p_149646_2_, int p_149646_3_, int p_149646_4_, int p_149646_5_) { - return shouldSideBeRendered1(p_149646_1_, p_149646_2_, p_149646_3_, p_149646_4_, 1 - p_149646_5_); - } + @Override + public boolean shouldSideBeRendered(IBlockAccess p_149646_1_, int p_149646_2_, int p_149646_3_, int p_149646_4_, int p_149646_5_) { + return shouldSideBeRendered1(p_149646_1_, p_149646_2_, p_149646_3_, p_149646_4_, 1 - p_149646_5_); + } - @Override - public int getRenderBlockPass() { - return 1; - } + @Override + public int getRenderBlockPass() { + return 1; + } + + @Override + public LexiconEntry getEntry(World world, int x, int y, int z, EntityPlayer player, ItemStack lexicon) { + return LexiconData.pool; + } - @Override - public LexiconEntry getEntry(World world, int x, int y, int z, EntityPlayer player, ItemStack lexicon) { - return LexiconData.pool; - } } diff --git a/src/main/java/vazkii/botania/common/block/decor/BlockModMushroom.java b/src/main/java/vazkii/botania/common/block/decor/BlockModMushroom.java index 897f1c82d5..e66816ebca 100644 --- a/src/main/java/vazkii/botania/common/block/decor/BlockModMushroom.java +++ b/src/main/java/vazkii/botania/common/block/decor/BlockModMushroom.java @@ -2,20 +2,17 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Feb 23, 2015, 4:24:08 PM (GMT)] */ package vazkii.botania.common.block.decor; -import cpw.mods.fml.common.Optional; -import cpw.mods.fml.common.registry.GameRegistry; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; import java.util.List; import java.util.Random; + import net.minecraft.block.Block; import net.minecraft.block.BlockMushroom; import net.minecraft.client.renderer.texture.IIconRegister; @@ -41,123 +38,117 @@ import vazkii.botania.common.item.block.ItemBlockWithMetadataAndName; import vazkii.botania.common.lexicon.LexiconData; import vazkii.botania.common.lib.LibBlockNames; +import cpw.mods.fml.common.Optional; +import cpw.mods.fml.common.registry.GameRegistry; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; @Optional.Interface(modid = "Thaumcraft", iface = "thaumcraft.api.crafting.IInfusionStabiliser", striprefs = true) public class BlockModMushroom extends BlockMushroom implements IInfusionStabiliser, IHornHarvestable, ILexiconable { - public static IIcon[] icons; - public int originalLight; - - public BlockModMushroom() { - setBlockName(LibBlockNames.MUSHROOM); - setLightLevel(0.2F); - setHardness(0F); - setStepSound(soundTypeGrass); - setBlockBounds(0.3F, 0.0F, 0.3F, 0.8F, 1, 0.8F); - setTickRandomly(false); - setCreativeTab(BotaniaCreativeTab.INSTANCE); - } - - @Override - public void updateTick(World p_149674_1_, int p_149674_2_, int p_149674_3_, int p_149674_4_, Random p_149674_5_) { - // NO-OP, to prevent spreading - } - - @Override - public boolean canBlockStay(World p_149718_1_, int p_149718_2_, int p_149718_3_, int p_149718_4_) { - if (p_149718_3_ >= 0 && p_149718_3_ < 256) { - Block block = p_149718_1_.getBlock(p_149718_2_, p_149718_3_ - 1, p_149718_4_); - return block == Blocks.mycelium - || block == Blocks.dirt - && p_149718_1_.getBlockMetadata(p_149718_2_, p_149718_3_ - 1, p_149718_4_) == 2 - || block.canSustainPlant( - p_149718_1_, p_149718_2_, p_149718_3_ - 1, p_149718_4_, ForgeDirection.UP, this); - } - - return false; - } - - @Override - public void getSubBlocks(Item par1, CreativeTabs par2CreativeTabs, List par3List) { - for (int i = 0; i < 16; i++) par3List.add(new ItemStack(par1, 1, i)); - } - - @Override - public Block setBlockName(String par1Str) { - GameRegistry.registerBlock(this, ItemBlockWithMetadataAndName.class, par1Str); - return super.setBlockName(par1Str); - } - - @Override - @SideOnly(Side.CLIENT) - public void registerBlockIcons(IIconRegister par1IconRegister) { - icons = new IIcon[16]; - - for (int i = 0; i < icons.length; i++) icons[i] = IconHelper.forBlock(par1IconRegister, this, i); - } - - @Override - public Block setLightLevel(float p_149715_1_) { - originalLight = (int) (p_149715_1_ * 15); - return super.setLightLevel(p_149715_1_); - } - - @Override - @Optional.Method(modid = "easycoloredlights") - public int getLightValue(IBlockAccess world, int x, int y, int z) { - return ColoredLightHelper.getPackedColor(world.getBlockMetadata(x, y, z), originalLight); - } - - @Override - public IIcon getIcon(int par1, int par2) { - return icons[par2]; - } - - @Override - public int damageDropped(int par1) { - return par1; - } - - @Override - public void randomDisplayTick(World par1World, int par2, int par3, int par4, Random par5Random) { - int meta = par1World.getBlockMetadata(par2, par3, par4); - float[] color = EntitySheep.fleeceColorTable[meta]; - - if (par5Random.nextDouble() < ConfigHandler.flowerParticleFrequency * 0.25F) - Botania.proxy.sparkleFX( - par1World, - par2 + 0.3 + par5Random.nextFloat() * 0.5, - par3 + 0.5 + par5Random.nextFloat() * 0.5, - par4 + 0.3 + par5Random.nextFloat() * 0.5, - color[0], - color[1], - color[2], - par5Random.nextFloat(), - 5); - } - - @Override - public boolean canStabaliseInfusion(World world, int x, int y, int z) { - return ConfigHandler.enableThaumcraftStablizers; - } - - @Override - public LexiconEntry getEntry(World world, int x, int y, int z, EntityPlayer player, ItemStack lexicon) { - return LexiconData.mushrooms; - } - - @Override - public boolean canHornHarvest(World world, int x, int y, int z, ItemStack stack, EnumHornType hornType) { - return false; - } - - @Override - public boolean hasSpecialHornHarvest(World world, int x, int y, int z, ItemStack stack, EnumHornType hornType) { - return false; - } - - @Override - public void harvestByHorn(World world, int x, int y, int z, ItemStack stack, EnumHornType hornType) { - // NO-OP - } + public static IIcon[] icons; + public int originalLight; + + public BlockModMushroom() { + setBlockName(LibBlockNames.MUSHROOM); + setLightLevel(0.2F); + setHardness(0F); + setStepSound(soundTypeGrass); + setBlockBounds(0.3F, 0.0F, 0.3F, 0.8F, 1, 0.8F); + setTickRandomly(false); + setCreativeTab(BotaniaCreativeTab.INSTANCE); + } + + @Override + public void updateTick(World p_149674_1_, int p_149674_2_, int p_149674_3_, int p_149674_4_, Random p_149674_5_) { + // NO-OP, to prevent spreading + } + + @Override + public boolean canBlockStay(World p_149718_1_, int p_149718_2_, int p_149718_3_, int p_149718_4_) { + if(p_149718_3_ >= 0 && p_149718_3_ < 256) { + Block block = p_149718_1_.getBlock(p_149718_2_, p_149718_3_ - 1, p_149718_4_); + return block == Blocks.mycelium || block == Blocks.dirt && p_149718_1_.getBlockMetadata(p_149718_2_, p_149718_3_ - 1, p_149718_4_) == 2 || block.canSustainPlant(p_149718_1_, p_149718_2_, p_149718_3_ - 1, p_149718_4_, ForgeDirection.UP, this); + } + + return false; + } + + @Override + public void getSubBlocks(Item par1, CreativeTabs par2CreativeTabs, List par3List) { + for(int i = 0; i < 16; i++) + par3List.add(new ItemStack(par1, 1, i)); + } + + @Override + public Block setBlockName(String par1Str) { + GameRegistry.registerBlock(this, ItemBlockWithMetadataAndName.class, par1Str); + return super.setBlockName(par1Str); + } + + @Override + @SideOnly(Side.CLIENT) + public void registerBlockIcons(IIconRegister par1IconRegister) { + icons = new IIcon[16]; + + for(int i = 0; i < icons.length; i++) + icons[i] = IconHelper.forBlock(par1IconRegister, this, i); + } + + @Override + public Block setLightLevel(float p_149715_1_) { + originalLight = (int) (p_149715_1_ * 15); + return super.setLightLevel(p_149715_1_); + } + + @Override + @Optional.Method(modid = "easycoloredlights") + public int getLightValue(IBlockAccess world, int x, int y, int z) { + return ColoredLightHelper.getPackedColor(world.getBlockMetadata(x, y, z), originalLight); + } + + @Override + public IIcon getIcon(int par1, int par2) { + return icons[par2]; + } + + @Override + public int damageDropped(int par1) { + return par1; + } + + @Override + public void randomDisplayTick(World par1World, int par2, int par3, int par4, Random par5Random) { + int meta = par1World.getBlockMetadata(par2, par3, par4); + float[] color = EntitySheep.fleeceColorTable[meta]; + + if(par5Random.nextDouble() < ConfigHandler.flowerParticleFrequency * 0.25F) + Botania.proxy.sparkleFX(par1World, par2 + 0.3 + par5Random.nextFloat() * 0.5, par3 + 0.5 + par5Random.nextFloat() * 0.5, par4 + 0.3 + par5Random.nextFloat() * 0.5, color[0], color[1], color[2], par5Random.nextFloat(), 5); + } + + @Override + public boolean canStabaliseInfusion(World world, int x, int y, int z) { + return ConfigHandler.enableThaumcraftStablizers; + } + + @Override + public LexiconEntry getEntry(World world, int x, int y, int z, EntityPlayer player, ItemStack lexicon) { + return LexiconData.mushrooms; + } + + @Override + public boolean canHornHarvest(World world, int x, int y, int z, ItemStack stack, EnumHornType hornType) { + return false; + } + + @Override + public boolean hasSpecialHornHarvest(World world, int x, int y, int z, ItemStack stack, EnumHornType hornType) { + return false; + } + + @Override + public void harvestByHorn(World world, int x, int y, int z, ItemStack stack, EnumHornType hornType) { + // NO-OP + } + } diff --git a/src/main/java/vazkii/botania/common/block/decor/BlockPavement.java b/src/main/java/vazkii/botania/common/block/decor/BlockPavement.java index 346e6e635a..d13de732de 100644 --- a/src/main/java/vazkii/botania/common/block/decor/BlockPavement.java +++ b/src/main/java/vazkii/botania/common/block/decor/BlockPavement.java @@ -2,18 +2,16 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Sep 1, 2015, 6:35:06 PM (GMT)] */ package vazkii.botania.common.block.decor; -import cpw.mods.fml.common.registry.GameRegistry; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; import java.util.List; + import net.minecraft.block.Block; import net.minecraft.block.material.Material; import net.minecraft.client.renderer.texture.IIconRegister; @@ -27,56 +25,62 @@ import vazkii.botania.common.block.BlockMod; import vazkii.botania.common.item.block.ItemBlockWithMetadataAndName; import vazkii.botania.common.lib.LibBlockNames; +import cpw.mods.fml.common.registry.GameRegistry; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; public class BlockPavement extends BlockMod { - public static final int TYPES = 6; - IIcon[] icons; + public static final int TYPES = 6; + IIcon[] icons; + + public BlockPavement() { + super(Material.rock); + setHardness(2.0F); + setResistance(10.0F); + setStepSound(soundTypeStone); + setBlockName(LibBlockNames.PAVEMENT); + } - public BlockPavement() { - super(Material.rock); - setHardness(2.0F); - setResistance(10.0F); - setStepSound(soundTypeStone); - setBlockName(LibBlockNames.PAVEMENT); - } + @Override + protected boolean shouldRegisterInNameSet() { + return false; + } - @Override - protected boolean shouldRegisterInNameSet() { - return false; - } + @Override + public int damageDropped(int par1) { + return par1; + } - @Override - public int damageDropped(int par1) { - return par1; - } + @Override + public Block setBlockName(String par1Str) { + GameRegistry.registerBlock(this, ItemBlockWithMetadataAndName.class, par1Str); + return super.setBlockName(par1Str); + } - @Override - public Block setBlockName(String par1Str) { - GameRegistry.registerBlock(this, ItemBlockWithMetadataAndName.class, par1Str); - return super.setBlockName(par1Str); - } + @Override + public void getSubBlocks(Item par1, CreativeTabs par2CreativeTabs, List par3List) { + for(int i = 0; i < TYPES; i++) + par3List.add(new ItemStack(par1, 1, i)); + } - @Override - public void getSubBlocks(Item par1, CreativeTabs par2CreativeTabs, List par3List) { - for (int i = 0; i < TYPES; i++) par3List.add(new ItemStack(par1, 1, i)); - } + @Override + @SideOnly(Side.CLIENT) + public void registerBlockIcons(IIconRegister par1IconRegister) { + icons = new IIcon[TYPES]; + for(int i = 0; i < TYPES; i++) + icons[i] = IconHelper.forBlock(par1IconRegister, this, i); + } - @Override - @SideOnly(Side.CLIENT) - public void registerBlockIcons(IIconRegister par1IconRegister) { - icons = new IIcon[TYPES]; - for (int i = 0; i < TYPES; i++) icons[i] = IconHelper.forBlock(par1IconRegister, this, i); - } + @Override + public IIcon getIcon(int par1, int par2) { + return icons[Math.min(TYPES - 1, par2)]; + } - @Override - public IIcon getIcon(int par1, int par2) { - return icons[Math.min(TYPES - 1, par2)]; - } + @Override + public ItemStack getPickBlock(MovingObjectPosition target, World world, int x, int y, int z) { + int meta = world.getBlockMetadata(x, y, z); + return new ItemStack(this, 1, meta); + } - @Override - public ItemStack getPickBlock(MovingObjectPosition target, World world, int x, int y, int z) { - int meta = world.getBlockMetadata(x, y, z); - return new ItemStack(this, 1, meta); - } } diff --git a/src/main/java/vazkii/botania/common/block/decor/BlockPetalBlock.java b/src/main/java/vazkii/botania/common/block/decor/BlockPetalBlock.java index e7d22a87df..1ee7e29821 100644 --- a/src/main/java/vazkii/botania/common/block/decor/BlockPetalBlock.java +++ b/src/main/java/vazkii/botania/common/block/decor/BlockPetalBlock.java @@ -2,17 +2,17 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Feb 9, 2015, 5:17:17 PM (GMT)] */ package vazkii.botania.common.block.decor; -import cpw.mods.fml.common.registry.GameRegistry; import java.awt.Color; import java.util.List; + import net.minecraft.block.Block; import net.minecraft.block.material.Material; import net.minecraft.creativetab.CreativeTabs; @@ -28,53 +28,52 @@ import vazkii.botania.common.item.block.ItemBlockWithMetadataAndName; import vazkii.botania.common.lexicon.LexiconData; import vazkii.botania.common.lib.LibBlockNames; +import cpw.mods.fml.common.registry.GameRegistry; public class BlockPetalBlock extends BlockMod implements ILexiconable { - public BlockPetalBlock() { - super(Material.plants); - setHardness(0.4F); - setStepSound(soundTypeGrass); - setBlockName(LibBlockNames.PETAL_BLOCK); - } + public BlockPetalBlock() { + super(Material.plants); + setHardness(0.4F); + setStepSound(soundTypeGrass); + setBlockName(LibBlockNames.PETAL_BLOCK); + } + + @Override + public void getSubBlocks(Item item, CreativeTabs tab, List list) { + for(int i = 0; i < 16; i++) + list.add(new ItemStack(item, 1, i)); + } - @Override - public void getSubBlocks(Item item, CreativeTabs tab, List list) { - for (int i = 0; i < 16; i++) list.add(new ItemStack(item, 1, i)); - } + @Override + protected boolean shouldRegisterInNameSet() { + return false; + } - @Override - protected boolean shouldRegisterInNameSet() { - return false; - } + @Override + public Block setBlockName(String par1Str) { + GameRegistry.registerBlock(this, ItemBlockWithMetadataAndName.class, par1Str); + return super.setBlockName(par1Str); + } - @Override - public Block setBlockName(String par1Str) { - GameRegistry.registerBlock(this, ItemBlockWithMetadataAndName.class, par1Str); - return super.setBlockName(par1Str); - } + @Override + public int getRenderColor(int meta) { + return new Color(EntitySheep.fleeceColorTable[meta][0], EntitySheep.fleeceColorTable[meta][1], EntitySheep.fleeceColorTable[meta][2]).getRGB(); + } - @Override - public int getRenderColor(int meta) { - return new Color( - EntitySheep.fleeceColorTable[meta][0], - EntitySheep.fleeceColorTable[meta][1], - EntitySheep.fleeceColorTable[meta][2]) - .getRGB(); - } + @Override + public int colorMultiplier(IBlockAccess world, int x, int y, int z) { + return getRenderColor(world.getBlockMetadata(x, y, z)); + } - @Override - public int colorMultiplier(IBlockAccess world, int x, int y, int z) { - return getRenderColor(world.getBlockMetadata(x, y, z)); - } + @Override + public int damageDropped(int meta) { + return meta; + } - @Override - public int damageDropped(int meta) { - return meta; - } + @Override + public LexiconEntry getEntry(World world, int x, int y, int z, EntityPlayer player, ItemStack lexicon) { + return LexiconData.flowers; + } - @Override - public LexiconEntry getEntry(World world, int x, int y, int z, EntityPlayer player, ItemStack lexicon) { - return LexiconData.flowers; - } } diff --git a/src/main/java/vazkii/botania/common/block/decor/BlockPrismarine.java b/src/main/java/vazkii/botania/common/block/decor/BlockPrismarine.java index 794fe28930..870ac12e36 100644 --- a/src/main/java/vazkii/botania/common/block/decor/BlockPrismarine.java +++ b/src/main/java/vazkii/botania/common/block/decor/BlockPrismarine.java @@ -2,19 +2,16 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jun 28, 2014, 8:25:39 PM (GMT)] */ package vazkii.botania.common.block.decor; -import cpw.mods.fml.common.eventhandler.SubscribeEvent; -import cpw.mods.fml.common.registry.GameRegistry; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; import java.util.List; + import net.minecraft.block.Block; import net.minecraft.block.material.Material; import net.minecraft.client.renderer.texture.IIconRegister; @@ -36,71 +33,78 @@ import vazkii.botania.common.item.block.ItemBlockWithMetadataAndName; import vazkii.botania.common.lexicon.LexiconData; import vazkii.botania.common.lib.LibBlockNames; +import cpw.mods.fml.common.eventhandler.SubscribeEvent; +import cpw.mods.fml.common.registry.GameRegistry; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; public class BlockPrismarine extends BlockMod implements ILexiconable { - private static final int TYPES = 3; - IIcon[] icons; + private static final int TYPES = 3; + IIcon[] icons; - public BlockPrismarine() { - super(Material.rock); - setHardness(2.0F); - setResistance(10.0F); - setStepSound(soundTypeStone); - setBlockName(LibBlockNames.PRISMARINE); - MinecraftForge.EVENT_BUS.register(this); - } + public BlockPrismarine() { + super(Material.rock); + setHardness(2.0F); + setResistance(10.0F); + setStepSound(soundTypeStone); + setBlockName(LibBlockNames.PRISMARINE); + MinecraftForge.EVENT_BUS.register(this); + } - @Override - protected boolean shouldRegisterInNameSet() { - return false; - } + @Override + protected boolean shouldRegisterInNameSet() { + return false; + } - @Override - public int damageDropped(int par1) { - return par1; - } + @Override + public int damageDropped(int par1) { + return par1; + } - @Override - public Block setBlockName(String par1Str) { - GameRegistry.registerBlock(this, ItemBlockWithMetadataAndName.class, par1Str); - return super.setBlockName(par1Str); - } + @Override + public Block setBlockName(String par1Str) { + GameRegistry.registerBlock(this, ItemBlockWithMetadataAndName.class, par1Str); + return super.setBlockName(par1Str); + } - @Override - public void getSubBlocks(Item par1, CreativeTabs par2CreativeTabs, List par3List) { - for (int i = 0; i < TYPES; i++) par3List.add(new ItemStack(par1, 1, i)); - } + @Override + public void getSubBlocks(Item par1, CreativeTabs par2CreativeTabs, List par3List) { + for(int i = 0; i < TYPES; i++) + par3List.add(new ItemStack(par1, 1, i)); + } - @Override - @SideOnly(Side.CLIENT) - public void registerBlockIcons(IIconRegister par1IconRegister) { - icons = new IIcon[TYPES]; - for (int i = 1; i < TYPES; i++) icons[i] = IconHelper.forBlock(par1IconRegister, this, i); - } + @Override + @SideOnly(Side.CLIENT) + public void registerBlockIcons(IIconRegister par1IconRegister) { + icons = new IIcon[TYPES]; + for(int i = 1; i < TYPES; i++) + icons[i] = IconHelper.forBlock(par1IconRegister, this, i); + } - @SubscribeEvent - @SideOnly(Side.CLIENT) - public void loadTextures(TextureStitchEvent.Pre event) { - if (event.map.getTextureType() == 0) { - TextureAtlasSprite icon = new InterpolatedIcon("botania:prismarine0"); - if (event.map.setTextureEntry("botania:prismarine0", icon)) icons[0] = icon; - } - } + @SubscribeEvent + @SideOnly(Side.CLIENT) + public void loadTextures(TextureStitchEvent.Pre event) { + if(event.map.getTextureType() == 0) { + TextureAtlasSprite icon = new InterpolatedIcon("botania:prismarine0"); + if(event.map.setTextureEntry("botania:prismarine0", icon)) + icons[0] = icon; + } + } - @Override - public IIcon getIcon(int par1, int par2) { - return icons[Math.min(TYPES - 1, par2)]; - } + @Override + public IIcon getIcon(int par1, int par2) { + return icons[Math.min(TYPES - 1, par2)]; + } - @Override - public ItemStack getPickBlock(MovingObjectPosition target, World world, int x, int y, int z) { - int meta = world.getBlockMetadata(x, y, z); - return new ItemStack(this, 1, meta); - } + @Override + public ItemStack getPickBlock(MovingObjectPosition target, World world, int x, int y, int z) { + int meta = world.getBlockMetadata(x, y, z); + return new ItemStack(this, 1, meta); + } - @Override - public LexiconEntry getEntry(World world, int x, int y, int z, EntityPlayer player, ItemStack lexicon) { - return LexiconData.prismarine; - } -} + @Override + public LexiconEntry getEntry(World world, int x, int y, int z, EntityPlayer player, ItemStack lexicon) { + return LexiconData.prismarine; + } +} \ No newline at end of file diff --git a/src/main/java/vazkii/botania/common/block/decor/BlockReeds.java b/src/main/java/vazkii/botania/common/block/decor/BlockReeds.java index d8519d8c08..0cfdf2caed 100644 --- a/src/main/java/vazkii/botania/common/block/decor/BlockReeds.java +++ b/src/main/java/vazkii/botania/common/block/decor/BlockReeds.java @@ -2,17 +2,14 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jul 28, 2014, 8:02:49 PM (GMT)] */ package vazkii.botania.common.block.decor; -import cpw.mods.fml.common.registry.GameRegistry; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; import net.minecraft.block.Block; import net.minecraft.block.BlockRotatedPillar; import net.minecraft.block.material.Material; @@ -28,44 +25,49 @@ import vazkii.botania.common.item.block.ItemBlockMod; import vazkii.botania.common.lexicon.LexiconData; import vazkii.botania.common.lib.LibBlockNames; +import cpw.mods.fml.common.registry.GameRegistry; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; public class BlockReeds extends BlockRotatedPillar implements ILexiconable { - IIcon topIcon; + IIcon topIcon; + + public BlockReeds() { + super(Material.wood); + setHardness(1.0F); + setStepSound(soundTypeWood); + setBlockName(LibBlockNames.REED_BLOCK); + setCreativeTab(BotaniaCreativeTab.INSTANCE); + } + - public BlockReeds() { - super(Material.wood); - setHardness(1.0F); - setStepSound(soundTypeWood); - setBlockName(LibBlockNames.REED_BLOCK); - setCreativeTab(BotaniaCreativeTab.INSTANCE); - } + @Override + public Block setBlockName(String par1Str) { + GameRegistry.registerBlock(this, ItemBlockMod.class, par1Str); + return super.setBlockName(par1Str); + } - @Override - public Block setBlockName(String par1Str) { - GameRegistry.registerBlock(this, ItemBlockMod.class, par1Str); - return super.setBlockName(par1Str); - } + @Override + @SideOnly(Side.CLIENT) + public void registerBlockIcons(IIconRegister par1IconRegister) { + blockIcon = IconHelper.forBlock(par1IconRegister, this, 0); + topIcon = IconHelper.forBlock(par1IconRegister, this, 1); + } - @Override - @SideOnly(Side.CLIENT) - public void registerBlockIcons(IIconRegister par1IconRegister) { - blockIcon = IconHelper.forBlock(par1IconRegister, this, 0); - topIcon = IconHelper.forBlock(par1IconRegister, this, 1); - } + @Override + public LexiconEntry getEntry(World world, int x, int y, int z, EntityPlayer player, ItemStack lexicon) { + return LexiconData.decorativeBlocks; + } - @Override - public LexiconEntry getEntry(World world, int x, int y, int z, EntityPlayer player, ItemStack lexicon) { - return LexiconData.decorativeBlocks; - } + @Override + protected IIcon getSideIcon(int p_150163_1_) { + return blockIcon; + } - @Override - protected IIcon getSideIcon(int p_150163_1_) { - return blockIcon; - } + @Override + protected IIcon getTopIcon(int p_150161_1_) { + return topIcon; + } - @Override - protected IIcon getTopIcon(int p_150161_1_) { - return topIcon; - } } diff --git a/src/main/java/vazkii/botania/common/block/decor/BlockSeaLamp.java b/src/main/java/vazkii/botania/common/block/decor/BlockSeaLamp.java index 5f9b43d0b3..3811350962 100644 --- a/src/main/java/vazkii/botania/common/block/decor/BlockSeaLamp.java +++ b/src/main/java/vazkii/botania/common/block/decor/BlockSeaLamp.java @@ -2,15 +2,14 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jun 28, 2014, 9:24:43 PM (GMT)] */ package vazkii.botania.common.block.decor; -import cpw.mods.fml.common.Optional; import net.minecraft.block.material.Material; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; @@ -22,29 +21,29 @@ import vazkii.botania.common.integration.coloredlights.ColoredLightHelper; import vazkii.botania.common.lexicon.LexiconData; import vazkii.botania.common.lib.LibBlockNames; +import cpw.mods.fml.common.Optional; public class BlockSeaLamp extends BlockMod implements ILexiconable { - public BlockSeaLamp() { - super(Material.glass); - setHardness(0.3F); - setStepSound(soundTypeGlass); - setLightLevel(1.0F); - setBlockName(LibBlockNames.SEA_LAMP); - } + public BlockSeaLamp() { + super(Material.glass); + setHardness(0.3F); + setStepSound(soundTypeGlass); + setLightLevel(1.0F); + setBlockName(LibBlockNames.SEA_LAMP); + } + + int coloredLight = -1; - int coloredLight = -1; + @Override + @Optional.Method(modid = "easycoloredlights") + public int getLightValue(IBlockAccess world, int x, int y, int z) { + return coloredLight == -1 ? (coloredLight = ColoredLightHelper.makeRGBLightValue(85, 136, 125, originalLight)) : coloredLight; + } - @Override - @Optional.Method(modid = "easycoloredlights") - public int getLightValue(IBlockAccess world, int x, int y, int z) { - return coloredLight == -1 - ? (coloredLight = ColoredLightHelper.makeRGBLightValue(85, 136, 125, originalLight)) - : coloredLight; - } + @Override + public LexiconEntry getEntry(World world, int x, int y, int z, EntityPlayer player, ItemStack lexicon) { + return LexiconData.prismarine; + } - @Override - public LexiconEntry getEntry(World world, int x, int y, int z, EntityPlayer player, ItemStack lexicon) { - return LexiconData.prismarine; - } } diff --git a/src/main/java/vazkii/botania/common/block/decor/BlockShimmerrock.java b/src/main/java/vazkii/botania/common/block/decor/BlockShimmerrock.java index c0c08deae9..c99f9c53eb 100644 --- a/src/main/java/vazkii/botania/common/block/decor/BlockShimmerrock.java +++ b/src/main/java/vazkii/botania/common/block/decor/BlockShimmerrock.java @@ -2,17 +2,14 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Oct 10, 2015, 10:29:22 PM (GMT)] */ package vazkii.botania.common.block.decor; -import cpw.mods.fml.common.eventhandler.SubscribeEvent; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; import net.minecraft.block.material.Material; import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.client.renderer.texture.TextureAtlasSprite; @@ -27,35 +24,40 @@ import vazkii.botania.common.block.BlockMod; import vazkii.botania.common.lexicon.LexiconData; import vazkii.botania.common.lib.LibBlockNames; +import cpw.mods.fml.common.eventhandler.SubscribeEvent; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; public class BlockShimmerrock extends BlockMod implements ILexiconable { - public BlockShimmerrock() { - super(Material.rock); - setHardness(2.0F); - setResistance(10.0F); - setStepSound(soundTypeStone); - setBlockName(LibBlockNames.SHIMMERROCK); - MinecraftForge.EVENT_BUS.register(this); - } + public BlockShimmerrock() { + super(Material.rock); + setHardness(2.0F); + setResistance(10.0F); + setStepSound(soundTypeStone); + setBlockName(LibBlockNames.SHIMMERROCK); + MinecraftForge.EVENT_BUS.register(this); + } + + @SubscribeEvent + @SideOnly(Side.CLIENT) + public void loadTextures(TextureStitchEvent.Pre event) { + if(event.map.getTextureType() == 0) { + TextureAtlasSprite icon = new InterpolatedIcon("botania:shimmerrock"); + if(event.map.setTextureEntry("botania:shimmerrock", icon)) + blockIcon = icon; + } + } - @SubscribeEvent - @SideOnly(Side.CLIENT) - public void loadTextures(TextureStitchEvent.Pre event) { - if (event.map.getTextureType() == 0) { - TextureAtlasSprite icon = new InterpolatedIcon("botania:shimmerrock"); - if (event.map.setTextureEntry("botania:shimmerrock", icon)) blockIcon = icon; - } - } + @Override + @SideOnly(Side.CLIENT) + public void registerBlockIcons(IIconRegister par1IconRegister) { + // NO-OP + } - @Override - @SideOnly(Side.CLIENT) - public void registerBlockIcons(IIconRegister par1IconRegister) { - // NO-OP - } + @Override + public LexiconEntry getEntry(World world, int x, int y, int z, EntityPlayer player, ItemStack lexicon) { + return LexiconData.rainbowRod; + } - @Override - public LexiconEntry getEntry(World world, int x, int y, int z, EntityPlayer player, ItemStack lexicon) { - return LexiconData.rainbowRod; - } } diff --git a/src/main/java/vazkii/botania/common/block/decor/BlockShimmerwoodPlanks.java b/src/main/java/vazkii/botania/common/block/decor/BlockShimmerwoodPlanks.java index 40756f755f..3a45c951d6 100644 --- a/src/main/java/vazkii/botania/common/block/decor/BlockShimmerwoodPlanks.java +++ b/src/main/java/vazkii/botania/common/block/decor/BlockShimmerwoodPlanks.java @@ -2,17 +2,14 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Oct 11, 2015, 3:08:09 PM (GMT)] */ package vazkii.botania.common.block.decor; -import cpw.mods.fml.common.eventhandler.SubscribeEvent; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; import net.minecraft.block.material.Material; import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.client.renderer.texture.TextureAtlasSprite; @@ -27,34 +24,39 @@ import vazkii.botania.common.block.BlockMod; import vazkii.botania.common.lexicon.LexiconData; import vazkii.botania.common.lib.LibBlockNames; +import cpw.mods.fml.common.eventhandler.SubscribeEvent; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +public class BlockShimmerwoodPlanks extends BlockMod implements ILexiconable { -public class BlockShimmerwoodPlanks extends BlockMod implements ILexiconable { + public BlockShimmerwoodPlanks() { + super(Material.wood); + setHardness(2.0F); + setStepSound(soundTypeWood); + setBlockName(LibBlockNames.SHIMMERWOOD_PLANKS); + MinecraftForge.EVENT_BUS.register(this); + } - public BlockShimmerwoodPlanks() { - super(Material.wood); - setHardness(2.0F); - setStepSound(soundTypeWood); - setBlockName(LibBlockNames.SHIMMERWOOD_PLANKS); - MinecraftForge.EVENT_BUS.register(this); - } + @SubscribeEvent + @SideOnly(Side.CLIENT) + public void loadTextures(TextureStitchEvent.Pre event) { + if(event.map.getTextureType() == 0) { + TextureAtlasSprite icon = new InterpolatedIcon("botania:shimmerwoodPlanks"); + if(event.map.setTextureEntry("botania:shimmerwoodPlanks", icon)) + blockIcon = icon; + } + } - @SubscribeEvent - @SideOnly(Side.CLIENT) - public void loadTextures(TextureStitchEvent.Pre event) { - if (event.map.getTextureType() == 0) { - TextureAtlasSprite icon = new InterpolatedIcon("botania:shimmerwoodPlanks"); - if (event.map.setTextureEntry("botania:shimmerwoodPlanks", icon)) blockIcon = icon; - } - } + @Override + @SideOnly(Side.CLIENT) + public void registerBlockIcons(IIconRegister par1IconRegister) { + // NO-OP + } - @Override - @SideOnly(Side.CLIENT) - public void registerBlockIcons(IIconRegister par1IconRegister) { - // NO-OP - } + @Override + public LexiconEntry getEntry(World world, int x, int y, int z, EntityPlayer player, ItemStack lexicon) { + return LexiconData.rainbowRod; + } - @Override - public LexiconEntry getEntry(World world, int x, int y, int z, EntityPlayer player, ItemStack lexicon) { - return LexiconData.rainbowRod; - } } diff --git a/src/main/java/vazkii/botania/common/block/decor/BlockShinyFlower.java b/src/main/java/vazkii/botania/common/block/decor/BlockShinyFlower.java index d621b992d6..7ec379792f 100644 --- a/src/main/java/vazkii/botania/common/block/decor/BlockShinyFlower.java +++ b/src/main/java/vazkii/botania/common/block/decor/BlockShinyFlower.java @@ -2,15 +2,14 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jun 2, 2014, 8:15:49 PM (GMT)] */ package vazkii.botania.common.block.decor; -import cpw.mods.fml.common.Optional; import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; @@ -26,66 +25,68 @@ import vazkii.botania.common.integration.coloredlights.ColoredLightHelper; import vazkii.botania.common.lexicon.LexiconData; import vazkii.botania.common.lib.LibBlockNames; +import cpw.mods.fml.common.Optional; @Optional.Interface(modid = "Thaumcraft", iface = "thaumcraft.api.crafting.IInfusionStabiliser", striprefs = true) public class BlockShinyFlower extends BlockModFlower implements IInfusionStabiliser, IHornHarvestable { - private static IIcon[] icons; - private static IIcon[] iconsAlt; + private static IIcon[] icons; + private static IIcon[] iconsAlt; + + public BlockShinyFlower() { + super(LibBlockNames.SHINY_FLOWER); + setLightLevel(1F); + } - public BlockShinyFlower() { - super(LibBlockNames.SHINY_FLOWER); - setLightLevel(1F); - } + @Override + @Optional.Method(modid = "easycoloredlights") + public int getLightValue(IBlockAccess world, int x, int y, int z) { + return ColoredLightHelper.getPackedColor(world.getBlockMetadata(x, y, z), originalLight); + } - @Override - @Optional.Method(modid = "easycoloredlights") - public int getLightValue(IBlockAccess world, int x, int y, int z) { - return ColoredLightHelper.getPackedColor(world.getBlockMetadata(x, y, z), originalLight); - } + @Override + public void registerBlockIcons(IIconRegister register) { + icons = new IIcon[16]; + iconsAlt = new IIcon[16]; + for(int i = 0; i < 16; i++) { + icons[i] = IconHelper.forName(register, "flowerGlimmering" + i); + iconsAlt[i] = IconHelper.forName(register, "flowerGlimmering" + i, BlockModFlower.ALT_DIR); + } + } - @Override - public void registerBlockIcons(IIconRegister register) { - icons = new IIcon[16]; - iconsAlt = new IIcon[16]; - for (int i = 0; i < 16; i++) { - icons[i] = IconHelper.forName(register, "flowerGlimmering" + i); - iconsAlt[i] = IconHelper.forName(register, "flowerGlimmering" + i, BlockModFlower.ALT_DIR); - } - } + @Override + public IIcon getIcon(int par1, int par2) { + return (ConfigHandler.altFlowerTextures ? iconsAlt : icons)[Math.min(icons.length - 1, par2)]; + } - @Override - public IIcon getIcon(int par1, int par2) { - return (ConfigHandler.altFlowerTextures ? iconsAlt : icons)[Math.min(icons.length - 1, par2)]; - } + @Override + public LexiconEntry getEntry(World world, int x, int y, int z, EntityPlayer player, ItemStack lexicon) { + return LexiconData.shinyFlowers; + } - @Override - public LexiconEntry getEntry(World world, int x, int y, int z, EntityPlayer player, ItemStack lexicon) { - return LexiconData.shinyFlowers; - } + @Override + public boolean func_149851_a(World world, int x, int y, int z, boolean fuckifiknow) { + return false; + } - @Override - public boolean func_149851_a(World world, int x, int y, int z, boolean fuckifiknow) { - return false; - } + @Override + public boolean canStabaliseInfusion(World world, int x, int y, int z) { + return ConfigHandler.enableThaumcraftStablizers; + } - @Override - public boolean canStabaliseInfusion(World world, int x, int y, int z) { - return ConfigHandler.enableThaumcraftStablizers; - } + @Override + public boolean canHornHarvest(World world, int x, int y, int z, ItemStack stack, EnumHornType hornType) { + return false; + } - @Override - public boolean canHornHarvest(World world, int x, int y, int z, ItemStack stack, EnumHornType hornType) { - return false; - } + @Override + public boolean hasSpecialHornHarvest(World world, int x, int y, int z, ItemStack stack, EnumHornType hornType) { + return false; + } - @Override - public boolean hasSpecialHornHarvest(World world, int x, int y, int z, ItemStack stack, EnumHornType hornType) { - return false; - } + @Override + public void harvestByHorn(World world, int x, int y, int z, ItemStack stack, EnumHornType hornType) { + // NO-OP + } - @Override - public void harvestByHorn(World world, int x, int y, int z, ItemStack stack, EnumHornType hornType) { - // NO-OP - } } diff --git a/src/main/java/vazkii/botania/common/block/decor/BlockStarfield.java b/src/main/java/vazkii/botania/common/block/decor/BlockStarfield.java index efc33c220c..bbde621f0c 100644 --- a/src/main/java/vazkii/botania/common/block/decor/BlockStarfield.java +++ b/src/main/java/vazkii/botania/common/block/decor/BlockStarfield.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Aug 7, 2014, 6:36:37 PM (GMT)] */ package vazkii.botania.common.block.decor; @@ -27,46 +27,48 @@ public class BlockStarfield extends BlockModContainer implements ILexiconable { - IIcon[] icons; + IIcon[] icons; - public BlockStarfield() { - super(Material.iron); - setHardness(5F); - setResistance(2000F); - setStepSound(soundTypeMetal); - setBlockName(LibBlockNames.STARFIELD); + public BlockStarfield() { + super(Material.iron); + setHardness(5F); + setResistance(2000F); + setStepSound(soundTypeMetal); + setBlockName(LibBlockNames.STARFIELD); - setBlockBounds(0F, 0F, 0F, 1F, 0.25F, 1F); - } + setBlockBounds(0F, 0F, 0F, 1F, 0.25F, 1F); + } - @Override - public void registerBlockIcons(IIconRegister par1IconRegister) { - icons = new IIcon[3]; - for (int i = 0; i < icons.length; i++) icons[i] = IconHelper.forBlock(par1IconRegister, this, i); - } + @Override + public void registerBlockIcons(IIconRegister par1IconRegister) { + icons = new IIcon[3]; + for(int i = 0; i < icons.length; i++) + icons[i] = IconHelper.forBlock(par1IconRegister, this, i); + } - @Override - public IIcon getIcon(int par1, int par2) { - return icons[Math.min(2, par1)]; - } + @Override + public IIcon getIcon(int par1, int par2) { + return icons[Math.min(2, par1)]; + } - @Override - public boolean renderAsNormalBlock() { - return false; - } + @Override + public boolean renderAsNormalBlock() { + return false; + } - @Override - public boolean isOpaqueCube() { - return false; - } + @Override + public boolean isOpaqueCube() { + return false; + } - @Override - public TileEntity createNewTileEntity(World world, int meta) { - return new TileStarfield(); - } + @Override + public TileEntity createNewTileEntity(World world, int meta) { + return new TileStarfield(); + } + + @Override + public LexiconEntry getEntry(World world, int x, int y, int z, EntityPlayer player, ItemStack lexicon) { + return LexiconData.starfield; + } - @Override - public LexiconEntry getEntry(World world, int x, int y, int z, EntityPlayer player, ItemStack lexicon) { - return LexiconData.starfield; - } } diff --git a/src/main/java/vazkii/botania/common/block/decor/BlockThatch.java b/src/main/java/vazkii/botania/common/block/decor/BlockThatch.java index ab204fe7b4..2efb259869 100644 --- a/src/main/java/vazkii/botania/common/block/decor/BlockThatch.java +++ b/src/main/java/vazkii/botania/common/block/decor/BlockThatch.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jul 28, 2014, 9:07:00 PM (GMT)] */ package vazkii.botania.common.block.decor; @@ -22,15 +22,16 @@ public class BlockThatch extends BlockMod implements ILexiconable { - public BlockThatch() { - super(Material.grass); - setHardness(1.0F); - setStepSound(soundTypeGrass); - setBlockName(LibBlockNames.THATCH); - } + public BlockThatch() { + super(Material.grass); + setHardness(1.0F); + setStepSound(soundTypeGrass); + setBlockName(LibBlockNames.THATCH); + } + + @Override + public LexiconEntry getEntry(World world, int x, int y, int z, EntityPlayer player, ItemStack lexicon) { + return LexiconData.decorativeBlocks; + } - @Override - public LexiconEntry getEntry(World world, int x, int y, int z, EntityPlayer player, ItemStack lexicon) { - return LexiconData.decorativeBlocks; - } } diff --git a/src/main/java/vazkii/botania/common/block/decor/BlockTinyPotato.java b/src/main/java/vazkii/botania/common/block/decor/BlockTinyPotato.java index 679aa84beb..6c3a99b0fa 100644 --- a/src/main/java/vazkii/botania/common/block/decor/BlockTinyPotato.java +++ b/src/main/java/vazkii/botania/common/block/decor/BlockTinyPotato.java @@ -2,16 +2,16 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jul 18, 2014, 7:58:08 PM (GMT)] */ package vazkii.botania.common.block.decor; -import cpw.mods.fml.common.registry.GameRegistry; import java.util.ArrayList; + import net.minecraft.block.Block; import net.minecraft.block.material.Material; import net.minecraft.client.renderer.texture.IIconRegister; @@ -32,118 +32,103 @@ import vazkii.botania.common.item.block.ItemBlockTinyPotato; import vazkii.botania.common.lexicon.LexiconData; import vazkii.botania.common.lib.LibBlockNames; +import cpw.mods.fml.common.registry.GameRegistry; public class BlockTinyPotato extends BlockModContainer implements ILexiconable { - public BlockTinyPotato() { - super(Material.cloth); - setHardness(0.25F); - setBlockName(LibBlockNames.TINY_POTATO); - float f = 1F / 16F * 6F; - setBlockBounds(f, 0, f, 1F - f, f, 1F - f); - } - - @Override - public Block setBlockName(String par1Str) { - GameRegistry.registerBlock(this, ItemBlockTinyPotato.class, par1Str); - return super.setBlockName(par1Str); - } - - @Override - protected boolean shouldRegisterInNameSet() { - return false; - } - - @Override - public void registerBlockIcons(IIconRegister par1IconRegister) { - // NO-OP - } - - @Override - public IIcon getIcon(int side, int meta) { - return Blocks.hardened_clay.getIcon(0, 0); - } - - @Override - public boolean onBlockActivated( - World par1World, - int par2, - int par3, - int par4, - EntityPlayer par5EntityPlayer, - int par6, - float par7, - float par8, - float par9) { - TileEntity tile = par1World.getTileEntity(par2, par3, par4); - if (tile instanceof TileTinyPotato) { - ((TileTinyPotato) tile).interact(); - par5EntityPlayer.addStat(ModAchievements.tinyPotatoPet, 1); - par1World.spawnParticle( - "heart", - par2 + minX + Math.random() * (maxX - minX), - par3 + maxY, - par4 + minZ + Math.random() * (maxZ - minZ), - 0, - 0, - 0); - } - return true; - } - - @Override - public void onBlockPlacedBy( - World par1World, int par2, int par3, int par4, EntityLivingBase par5EntityLiving, ItemStack par6ItemStack) { - int l1 = MathHelper.floor_double(par5EntityLiving.rotationYaw * 4.0F / 360.0F + 0.5D) & 3; - - par1World.setBlockMetadataWithNotify(par2, par3, par4, l1, 2); - if (par6ItemStack.hasDisplayName()) - ((TileTinyPotato) par1World.getTileEntity(par2, par3, par4)).name = par6ItemStack.getDisplayName(); - } - - @Override - public void onBlockHarvested( - World par1World, int par2, int par3, int par4, int par5, EntityPlayer par6EntityPlayer) { - if (!par6EntityPlayer.capabilities.isCreativeMode) dropBlockAsItem(par1World, par2, par3, par4, par5, 0); - } - - @Override - public ArrayList getDrops(World world, int x, int y, int z, int metadata, int fortune) { - ArrayList list = new ArrayList(); - TileEntity tile = world.getTileEntity(x, y, z); - - if (tile != null) { - ItemStack stack = new ItemStack(this); - String name = ((TileTinyPotato) tile).name; - if (!name.isEmpty()) stack.setStackDisplayName(name); - list.add(stack); - } - - return list; - } - - @Override - public boolean isOpaqueCube() { - return false; - } - - @Override - public boolean renderAsNormalBlock() { - return false; - } - - @Override - public int getRenderType() { - return LibRenderIDs.idTinyPotato; - } - - @Override - public TileEntity createNewTileEntity(World world, int meta) { - return new TileTinyPotato(); - } - - @Override - public LexiconEntry getEntry(World world, int x, int y, int z, EntityPlayer player, ItemStack lexicon) { - return LexiconData.tinyPotato; - } + public BlockTinyPotato() { + super(Material.cloth); + setHardness(0.25F); + setBlockName(LibBlockNames.TINY_POTATO); + float f = 1F / 16F * 6F; + setBlockBounds(f, 0, f, 1F - f, f, 1F - f); + } + + @Override + public Block setBlockName(String par1Str) { + GameRegistry.registerBlock(this, ItemBlockTinyPotato.class, par1Str); + return super.setBlockName(par1Str); + } + + @Override + protected boolean shouldRegisterInNameSet() { + return false; + } + + @Override + public void registerBlockIcons(IIconRegister par1IconRegister) { + // NO-OP + } + + @Override + public IIcon getIcon(int side, int meta) { + return Blocks.hardened_clay.getIcon(0, 0); + } + + @Override + public boolean onBlockActivated(World par1World, int par2, int par3, int par4, EntityPlayer par5EntityPlayer, int par6, float par7, float par8, float par9) { + TileEntity tile = par1World.getTileEntity(par2, par3, par4); + if(tile instanceof TileTinyPotato) { + ((TileTinyPotato) tile).interact(); + par5EntityPlayer.addStat(ModAchievements.tinyPotatoPet, 1); + par1World.spawnParticle("heart", par2 + minX + Math.random() * (maxX - minX), par3 + maxY, par4 + minZ + Math.random() * (maxZ - minZ), 0, 0 ,0); + } + return true; + } + + @Override + public void onBlockPlacedBy(World par1World, int par2, int par3, int par4, EntityLivingBase par5EntityLiving, ItemStack par6ItemStack) { + int l1 = MathHelper.floor_double(par5EntityLiving.rotationYaw * 4.0F / 360.0F + 0.5D) & 3; + + par1World.setBlockMetadataWithNotify(par2, par3, par4, l1, 2); + if (par6ItemStack.hasDisplayName()) + ((TileTinyPotato) par1World.getTileEntity(par2, par3, par4)).name = par6ItemStack.getDisplayName(); + } + + @Override + public void onBlockHarvested(World par1World, int par2, int par3, int par4, int par5, EntityPlayer par6EntityPlayer) { + if(!par6EntityPlayer.capabilities.isCreativeMode) + dropBlockAsItem(par1World, par2, par3, par4, par5, 0); + } + + @Override + public ArrayList getDrops(World world, int x, int y, int z, int metadata, int fortune) { + ArrayList list = new ArrayList(); + TileEntity tile = world.getTileEntity(x, y, z); + + if(tile != null) { + ItemStack stack = new ItemStack(this); + String name = ((TileTinyPotato) tile).name; + if(!name.isEmpty()) + stack.setStackDisplayName(name); + list.add(stack); + } + + return list; + } + + @Override + public boolean isOpaqueCube() { + return false; + } + + @Override + public boolean renderAsNormalBlock() { + return false; + } + + @Override + public int getRenderType() { + return LibRenderIDs.idTinyPotato; + } + + @Override + public TileEntity createNewTileEntity(World world, int meta) { + return new TileTinyPotato(); + } + + @Override + public LexiconEntry getEntry(World world, int x, int y, int z, EntityPlayer player, ItemStack lexicon) { + return LexiconData.tinyPotato; + } } diff --git a/src/main/java/vazkii/botania/common/block/decor/BlockUnstable.java b/src/main/java/vazkii/botania/common/block/decor/BlockUnstable.java index a04ca7e276..32bc04b1e1 100644 --- a/src/main/java/vazkii/botania/common/block/decor/BlockUnstable.java +++ b/src/main/java/vazkii/botania/common/block/decor/BlockUnstable.java @@ -2,18 +2,18 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Feb 4, 2014, 6:00:44 PM (GMT)] */ package vazkii.botania.common.block.decor; -import cpw.mods.fml.common.registry.GameRegistry; import java.awt.Color; import java.util.List; import java.util.Random; + import net.minecraft.block.Block; import net.minecraft.block.material.Material; import net.minecraft.creativetab.CreativeTabs; @@ -31,78 +31,76 @@ import vazkii.botania.common.item.block.ItemBlockWithMetadataAndName; import vazkii.botania.common.lexicon.LexiconData; import vazkii.botania.common.lib.LibBlockNames; +import cpw.mods.fml.common.registry.GameRegistry; public class BlockUnstable extends BlockMod implements ILexiconable { - public BlockUnstable() { - super(Material.iron); - setHardness(5.0F); - setResistance(10.0F); - setStepSound(soundTypeMetal); - setBlockBounds(0.25F, 0.25F, 0.25F, 0.75F, 0.75F, 0.75F); - setBlockName(LibBlockNames.UNSTABLE_BLOCK); - } - - @Override - public void getSubBlocks(Item par1, CreativeTabs par2CreativeTabs, List par3List) { - for (int i = 0; i < 16; i++) par3List.add(new ItemStack(par1, 1, i)); - } - - @Override - public Block setBlockName(String par1Str) { - GameRegistry.registerBlock(this, ItemBlockWithMetadataAndName.class, par1Str); - return super.setBlockName(par1Str); - } - - @Override - protected boolean shouldRegisterInNameSet() { - return false; - } - - @Override - public boolean renderAsNormalBlock() { - return false; - } - - @Override - public boolean isOpaqueCube() { - return false; - } - - @Override - public void randomDisplayTick(World par1World, int par2, int par3, int par4, Random par5Random) { - int color = getRenderColor(par1World.getBlockMetadata(par2, par3, par4)); - int colorBright = new Color(color).brighter().getRGB(); - int colorDark = new Color(color).darker().getRGB(); - - Vector3 origVector = new Vector3(par2 + 0.5, par3 + 0.5, par4 + 0.5); - Vector3 endVector = origVector - .copy() - .add( - par1World.rand.nextDouble() * 2 - 1, - par1World.rand.nextDouble() * 2 - 1, - par1World.rand.nextDouble() * 2 - 1); - Botania.proxy.lightningFX(par1World, origVector, endVector, 5F, colorDark, colorBright); - } - - @Override - public int damageDropped(int par1) { - return par1; - } - - @Override - public int getRenderColor(int par1) { - float[] color = EntitySheep.fleeceColorTable[par1]; - return new Color(color[0], color[1], color[2]).getRGB(); - } - - @Override - public int colorMultiplier(IBlockAccess par1iBlockAccess, int par2, int par3, int par4) { - return getRenderColor(par1iBlockAccess.getBlockMetadata(par2, par3, par4)); - } - - @Override - public LexiconEntry getEntry(World world, int x, int y, int z, EntityPlayer player, ItemStack lexicon) { - return LexiconData.unstableBlocks; - } + public BlockUnstable() { + super(Material.iron); + setHardness(5.0F); + setResistance(10.0F); + setStepSound(soundTypeMetal); + setBlockBounds(0.25F, 0.25F, 0.25F, 0.75F, 0.75F, 0.75F); + setBlockName(LibBlockNames.UNSTABLE_BLOCK); + } + + @Override + public void getSubBlocks(Item par1, CreativeTabs par2CreativeTabs, List par3List) { + for(int i = 0; i < 16; i++) + par3List.add(new ItemStack(par1, 1, i)); + } + + @Override + public Block setBlockName(String par1Str) { + GameRegistry.registerBlock(this, ItemBlockWithMetadataAndName.class, par1Str); + return super.setBlockName(par1Str); + } + + @Override + protected boolean shouldRegisterInNameSet() { + return false; + } + + @Override + public boolean renderAsNormalBlock() { + return false; + } + + @Override + public boolean isOpaqueCube() { + return false; + } + + @Override + public void randomDisplayTick(World par1World, int par2, int par3, int par4, Random par5Random) { + int color = getRenderColor(par1World.getBlockMetadata(par2, par3, par4)); + int colorBright = new Color(color).brighter().getRGB(); + int colorDark = new Color(color).darker().getRGB(); + + Vector3 origVector = new Vector3(par2 + 0.5, par3 + 0.5, par4 + 0.5); + Vector3 endVector = origVector.copy().add(par1World.rand.nextDouble() * 2 - 1, par1World.rand.nextDouble() * 2 - 1, par1World.rand.nextDouble() * 2 - 1); + Botania.proxy.lightningFX(par1World, origVector, endVector, 5F, colorDark, colorBright); + } + + @Override + public int damageDropped(int par1) { + return par1; + } + + @Override + public int getRenderColor(int par1) { + float[] color = EntitySheep.fleeceColorTable[par1]; + return new Color(color[0], color[1], color[2]).getRGB(); + } + + @Override + public int colorMultiplier(IBlockAccess par1iBlockAccess, int par2, int par3, int par4) { + return getRenderColor(par1iBlockAccess.getBlockMetadata(par2, par3, par4)); + } + + @Override + public LexiconEntry getEntry(World world, int x, int y, int z, EntityPlayer player, ItemStack lexicon) { + return LexiconData.unstableBlocks; + } + } diff --git a/src/main/java/vazkii/botania/common/block/decor/IFloatingFlower.java b/src/main/java/vazkii/botania/common/block/decor/IFloatingFlower.java index 6b832ed189..1240b9eaed 100644 --- a/src/main/java/vazkii/botania/common/block/decor/IFloatingFlower.java +++ b/src/main/java/vazkii/botania/common/block/decor/IFloatingFlower.java @@ -2,70 +2,73 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Nov 17, 2014, 6:05:18 PM (GMT)] */ package vazkii.botania.common.block.decor; -import java.util.HashMap; import net.minecraft.item.ItemStack; import net.minecraft.util.ResourceLocation; import vazkii.botania.client.lib.LibResources; +import java.util.HashMap; + public interface IFloatingFlower { - public ItemStack getDisplayStack(); - - public IslandType getIslandType(); - - public void setIslandType(IslandType type); - - public class IslandType { - private static HashMap registry = new HashMap(); - - public static final IslandType GRASS = new IslandType("GRASS", LibResources.MODEL_MINI_ISLAND); - public static final IslandType PODZOL = new IslandType("PODZOL", LibResources.MODEL_MINI_ISLAND_PODZOL); - public static final IslandType MYCEL = new IslandType("MYCEL", LibResources.MODEL_MINI_ISLAND_MYCEL); - public static final IslandType SNOW = new IslandType("SNOW", LibResources.MODEL_MINI_ISLAND_SNOW); - public static final IslandType DRY = new IslandType("DRY", LibResources.MODEL_MINI_ISLAND_DRY); - public static final IslandType GOLDEN = new IslandType("GOLDEN", LibResources.MODEL_MINI_ISLAND_GOLDEN); - public static final IslandType VIVID = new IslandType("VIVID", LibResources.MODEL_MINI_ISLAND_VIVID); - public static final IslandType SCORCHED = new IslandType("SCORCHED", LibResources.MODEL_MINI_ISLAND_SCORCHED); - public static final IslandType INFUSED = new IslandType("INFUSED", LibResources.MODEL_MINI_ISLAND_INFUSED); - public static final IslandType MUTATED = new IslandType("MUTATED", LibResources.MODEL_MINI_ISLAND_MUTATED); - - public IslandType(String name, String s) { - this(name, new ResourceLocation(s)); - } - - public IslandType(String name, ResourceLocation s) { - if (registry.containsKey(name)) throw new IllegalArgumentException(name + " already registered!"); - this.typeName = name; - res = s; - registry.put(name, this); - } - - private final ResourceLocation res; - public final String typeName; - - public static IslandType ofType(String typeStr) { - IslandType type = registry.get(typeStr); - return type == null ? GRASS : type; - } - - public ResourceLocation getResource() { - return res; - } - - public int getColor() { - return 0xFFFFFF; - } - - public String toString() { - return this.typeName; - } - } + public ItemStack getDisplayStack(); + + public IslandType getIslandType(); + + public void setIslandType(IslandType type); + + public class IslandType { + private static HashMap registry = new HashMap(); + + public static final IslandType GRASS = new IslandType("GRASS", LibResources.MODEL_MINI_ISLAND); + public static final IslandType PODZOL = new IslandType("PODZOL", LibResources.MODEL_MINI_ISLAND_PODZOL); + public static final IslandType MYCEL = new IslandType("MYCEL", LibResources.MODEL_MINI_ISLAND_MYCEL); + public static final IslandType SNOW = new IslandType("SNOW", LibResources.MODEL_MINI_ISLAND_SNOW); + public static final IslandType DRY = new IslandType("DRY", LibResources.MODEL_MINI_ISLAND_DRY); + public static final IslandType GOLDEN = new IslandType("GOLDEN", LibResources.MODEL_MINI_ISLAND_GOLDEN); + public static final IslandType VIVID = new IslandType("VIVID", LibResources.MODEL_MINI_ISLAND_VIVID); + public static final IslandType SCORCHED = new IslandType("SCORCHED", LibResources.MODEL_MINI_ISLAND_SCORCHED); + public static final IslandType INFUSED = new IslandType("INFUSED", LibResources.MODEL_MINI_ISLAND_INFUSED); + public static final IslandType MUTATED = new IslandType("MUTATED", LibResources.MODEL_MINI_ISLAND_MUTATED); + + public IslandType(String name, String s) { + this(name, new ResourceLocation(s)); + } + + public IslandType(String name, ResourceLocation s) { + if (registry.containsKey(name)) throw new IllegalArgumentException(name+" already registered!"); + this.typeName = name; + res = s; + registry.put(name, this); + } + + private final ResourceLocation res; + public final String typeName; + + public static IslandType ofType(String typeStr) { + IslandType type = registry.get(typeStr); + return type == null ? GRASS : type; + } + + public ResourceLocation getResource() { + return res; + } + + public int getColor() { + return 0xFFFFFF; + } + + public String toString() { + return this.typeName; + } + + } + } diff --git a/src/main/java/vazkii/botania/common/block/decor/biomestone/BlockBiomeStone.java b/src/main/java/vazkii/botania/common/block/decor/biomestone/BlockBiomeStone.java index cf4b80f316..bec9355264 100644 --- a/src/main/java/vazkii/botania/common/block/decor/biomestone/BlockBiomeStone.java +++ b/src/main/java/vazkii/botania/common/block/decor/biomestone/BlockBiomeStone.java @@ -2,16 +2,16 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jan 29, 2015, 6:54:20 PM (GMT)] */ package vazkii.botania.common.block.decor.biomestone; -import cpw.mods.fml.common.registry.GameRegistry; import java.util.List; + import net.minecraft.block.Block; import net.minecraft.block.material.Material; import net.minecraft.client.renderer.texture.IIconRegister; @@ -28,63 +28,65 @@ import vazkii.botania.common.block.BlockMod; import vazkii.botania.common.item.block.ItemBlockWithMetadataAndName; import vazkii.botania.common.lexicon.LexiconData; +import cpw.mods.fml.common.registry.GameRegistry; public class BlockBiomeStone extends BlockMod implements ILexiconable { - private static IIcon[] icons = new IIcon[32]; - int iconOffset; + private static IIcon[] icons = new IIcon[32]; + int iconOffset; - public BlockBiomeStone(int iconOffset, String name) { - super(Material.rock); - setHardness(1.5F); - setResistance(10F); - setStepSound(soundTypeStone); - setBlockName(name); - this.iconOffset = iconOffset; - } + public BlockBiomeStone(int iconOffset, String name) { + super(Material.rock); + setHardness(1.5F); + setResistance(10F); + setStepSound(soundTypeStone); + setBlockName(name); + this.iconOffset = iconOffset; + } - @Override - public void registerBlockIcons(IIconRegister register) { - for (int i = 0; i < 16; i++) { - int index = i + iconOffset; - icons[index] = IconHelper.forName(register, "biomeStone" + index); - } - } + @Override + public void registerBlockIcons(IIconRegister register) { + for(int i = 0; i < 16; i++) { + int index = i + iconOffset; + icons[index] = IconHelper.forName(register, "biomeStone" + index); + } + } - @Override - public void getSubBlocks(Item item, CreativeTabs tab, List list) { - for (int i = 0; i < 16; i++) list.add(new ItemStack(item, 1, i)); - } + @Override + public void getSubBlocks(Item item, CreativeTabs tab, List list) { + for(int i = 0; i < 16; i++) + list.add(new ItemStack(item, 1, i)); + } - @Override - public IIcon getIcon(int side, int meta) { - return icons[meta + iconOffset]; - } + @Override + public IIcon getIcon(int side, int meta) { + return icons[meta + iconOffset]; + } - @Override - protected boolean shouldRegisterInNameSet() { - return false; - } + @Override + protected boolean shouldRegisterInNameSet() { + return false; + } - @Override - public int damageDropped(int par1) { - return par1; - } + @Override + public int damageDropped(int par1) { + return par1; + } - @Override - public Block setBlockName(String par1Str) { - GameRegistry.registerBlock(this, ItemBlockWithMetadataAndName.class, par1Str); - return super.setBlockName(par1Str); - } + @Override + public Block setBlockName(String par1Str) { + GameRegistry.registerBlock(this, ItemBlockWithMetadataAndName.class, par1Str); + return super.setBlockName(par1Str); + } - @Override - public ItemStack getPickBlock(MovingObjectPosition target, World world, int x, int y, int z) { - int meta = world.getBlockMetadata(x, y, z); - return new ItemStack(this, 1, meta); - } + @Override + public ItemStack getPickBlock(MovingObjectPosition target, World world, int x, int y, int z) { + int meta = world.getBlockMetadata(x, y, z); + return new ItemStack(this, 1, meta); + } - @Override - public LexiconEntry getEntry(World world, int x, int y, int z, EntityPlayer player, ItemStack lexicon) { - return LexiconData.marimorphosis; - } + @Override + public LexiconEntry getEntry(World world, int x, int y, int z, EntityPlayer player, ItemStack lexicon) { + return LexiconData.marimorphosis; + } } diff --git a/src/main/java/vazkii/botania/common/block/decor/biomestone/BlockBiomeStoneA.java b/src/main/java/vazkii/botania/common/block/decor/biomestone/BlockBiomeStoneA.java index 60d3b412d7..2a9928204c 100644 --- a/src/main/java/vazkii/botania/common/block/decor/biomestone/BlockBiomeStoneA.java +++ b/src/main/java/vazkii/botania/common/block/decor/biomestone/BlockBiomeStoneA.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jan 29, 2015, 7:17:35 PM (GMT)] */ package vazkii.botania.common.block.decor.biomestone; @@ -14,12 +14,13 @@ public class BlockBiomeStoneA extends BlockBiomeStone { - public BlockBiomeStoneA() { - super(0, LibBlockNames.BIOME_STONE_A); - } + public BlockBiomeStoneA() { + super(0, LibBlockNames.BIOME_STONE_A); + } + + @Override + public int damageDropped(int par1) { + return par1 % 8 + 8; + } - @Override - public int damageDropped(int par1) { - return par1 % 8 + 8; - } } diff --git a/src/main/java/vazkii/botania/common/block/decor/biomestone/BlockBiomeStoneB.java b/src/main/java/vazkii/botania/common/block/decor/biomestone/BlockBiomeStoneB.java index 9033a29fa1..405432fc5f 100644 --- a/src/main/java/vazkii/botania/common/block/decor/biomestone/BlockBiomeStoneB.java +++ b/src/main/java/vazkii/botania/common/block/decor/biomestone/BlockBiomeStoneB.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jan 29, 2015, 7:17:41 PM (GMT)] */ package vazkii.botania.common.block.decor.biomestone; @@ -14,7 +14,8 @@ public class BlockBiomeStoneB extends BlockBiomeStone { - public BlockBiomeStoneB() { - super(16, LibBlockNames.BIOME_STONE_B); - } + public BlockBiomeStoneB() { + super(16, LibBlockNames.BIOME_STONE_B); + } + } diff --git a/src/main/java/vazkii/botania/common/block/decor/panes/BlockAlfglassPane.java b/src/main/java/vazkii/botania/common/block/decor/panes/BlockAlfglassPane.java index 52815ef8e3..081d8e7dad 100644 --- a/src/main/java/vazkii/botania/common/block/decor/panes/BlockAlfglassPane.java +++ b/src/main/java/vazkii/botania/common/block/decor/panes/BlockAlfglassPane.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Sep 30, 2015, 10:17:02 PM (GMT)] */ package vazkii.botania.common.block.decor.panes; @@ -14,7 +14,8 @@ public class BlockAlfglassPane extends BlockModPane { - public BlockAlfglassPane() { - super(ModBlocks.elfGlass); - } + public BlockAlfglassPane() { + super(ModBlocks.elfGlass); + } + } diff --git a/src/main/java/vazkii/botania/common/block/decor/panes/BlockBifrostPane.java b/src/main/java/vazkii/botania/common/block/decor/panes/BlockBifrostPane.java index e8300b1279..495e390164 100644 --- a/src/main/java/vazkii/botania/common/block/decor/panes/BlockBifrostPane.java +++ b/src/main/java/vazkii/botania/common/block/decor/panes/BlockBifrostPane.java @@ -2,43 +2,45 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Sep 30, 2015, 10:18:50 PM (GMT)] */ package vazkii.botania.common.block.decor.panes; -import cpw.mods.fml.common.eventhandler.SubscribeEvent; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.client.renderer.texture.TextureAtlasSprite; import net.minecraftforge.client.event.TextureStitchEvent; import net.minecraftforge.common.MinecraftForge; import vazkii.botania.client.render.block.InterpolatedIcon; import vazkii.botania.common.block.ModBlocks; +import cpw.mods.fml.common.eventhandler.SubscribeEvent; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; public class BlockBifrostPane extends BlockModPane { - public BlockBifrostPane() { - super(ModBlocks.bifrostPerm); - MinecraftForge.EVENT_BUS.register(this); - } + public BlockBifrostPane() { + super(ModBlocks.bifrostPerm); + MinecraftForge.EVENT_BUS.register(this); + } + + @SubscribeEvent + @SideOnly(Side.CLIENT) + public void loadTextures(TextureStitchEvent.Pre event) { + if(event.map.getTextureType() == 0) { + TextureAtlasSprite icon = new InterpolatedIcon("botania:bifrostPermPane"); + if(event.map.setTextureEntry("botania:bifrostPermPane", icon)) + iconTop = icon; + } + } - @SubscribeEvent - @SideOnly(Side.CLIENT) - public void loadTextures(TextureStitchEvent.Pre event) { - if (event.map.getTextureType() == 0) { - TextureAtlasSprite icon = new InterpolatedIcon("botania:bifrostPermPane"); - if (event.map.setTextureEntry("botania:bifrostPermPane", icon)) iconTop = icon; - } - } + @Override + @SideOnly(Side.CLIENT) + public void registerBlockIcons(IIconRegister reg) { + // NO-OP + } - @Override - @SideOnly(Side.CLIENT) - public void registerBlockIcons(IIconRegister reg) { - // NO-OP - } } diff --git a/src/main/java/vazkii/botania/common/block/decor/panes/BlockManaglassPane.java b/src/main/java/vazkii/botania/common/block/decor/panes/BlockManaglassPane.java index 5f97e03cc7..d509b38b90 100644 --- a/src/main/java/vazkii/botania/common/block/decor/panes/BlockManaglassPane.java +++ b/src/main/java/vazkii/botania/common/block/decor/panes/BlockManaglassPane.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Sep 30, 2015, 10:16:46 PM (GMT)] */ package vazkii.botania.common.block.decor.panes; @@ -14,7 +14,8 @@ public class BlockManaglassPane extends BlockModPane { - public BlockManaglassPane() { - super(ModBlocks.manaGlass); - } + public BlockManaglassPane() { + super(ModBlocks.manaGlass); + } + } diff --git a/src/main/java/vazkii/botania/common/block/decor/panes/BlockModPane.java b/src/main/java/vazkii/botania/common/block/decor/panes/BlockModPane.java index 9544071639..206ba158d4 100644 --- a/src/main/java/vazkii/botania/common/block/decor/panes/BlockModPane.java +++ b/src/main/java/vazkii/botania/common/block/decor/panes/BlockModPane.java @@ -2,17 +2,14 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Sep 30, 2015, 10:01:17 PM (GMT)] */ package vazkii.botania.common.block.decor.panes; -import cpw.mods.fml.common.registry.GameRegistry; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; import net.minecraft.block.Block; import net.minecraft.block.BlockPane; import net.minecraft.block.material.Material; @@ -24,68 +21,69 @@ import vazkii.botania.common.block.ModBlocks; import vazkii.botania.common.core.BotaniaCreativeTab; import vazkii.botania.common.item.block.ItemBlockMod; +import cpw.mods.fml.common.registry.GameRegistry; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; public class BlockModPane extends BlockPane { - Block source; - public IIcon iconTop; + Block source; + public IIcon iconTop; + + public BlockModPane(Block source) { + super("", "", Material.glass, false); + this.source = source; + setBlockName(source.getUnlocalizedName().replaceAll("tile.", "") + "Pane"); + setCreativeTab(BotaniaCreativeTab.INSTANCE); + setHardness(0.3F); + setStepSound(soundTypeGlass); + setLightLevel(1.0F); + useNeighborBrightness = true; + } - public BlockModPane(Block source) { - super("", "", Material.glass, false); - this.source = source; - setBlockName(source.getUnlocalizedName().replaceAll("tile.", "") + "Pane"); - setCreativeTab(BotaniaCreativeTab.INSTANCE); - setHardness(0.3F); - setStepSound(soundTypeGlass); - setLightLevel(1.0F); - useNeighborBrightness = true; - } + @Override + public Block setBlockName(String par1Str) { + GameRegistry.registerBlock(this, ItemBlockMod.class, par1Str); + return super.setBlockName(par1Str); + } - @Override - public Block setBlockName(String par1Str) { - GameRegistry.registerBlock(this, ItemBlockMod.class, par1Str); - return super.setBlockName(par1Str); - } + @Override + @SideOnly(Side.CLIENT) + public void registerBlockIcons(IIconRegister reg) { + iconTop = IconHelper.forBlock(reg, this); + } - @Override - @SideOnly(Side.CLIENT) - public void registerBlockIcons(IIconRegister reg) { - iconTop = IconHelper.forBlock(reg, this); - } + @Override + public boolean shouldSideBeRendered(IBlockAccess iblockaccess, int i, int j, int k, int l) { + return false; + } - @Override - public boolean shouldSideBeRendered(IBlockAccess iblockaccess, int i, int j, int k, int l) { - return false; - } + @Override + public int getRenderType() { + return 18; + } - @Override - public int getRenderType() { - return 18; - } + @Override + public int getRenderBlockPass() { + return 1; + } - @Override - public int getRenderBlockPass() { - return 1; - } + @Override + @SideOnly(Side.CLIENT) + public IIcon func_150097_e() { + return source.getIcon(0, 0); + } - @Override - @SideOnly(Side.CLIENT) - public IIcon func_150097_e() { - return source.getIcon(0, 0); - } + @Override + @SideOnly(Side.CLIENT) + public IIcon getIcon(int side, int meta) { + return side >= 2 ? iconTop : source.getIcon(side, meta); + } - @Override - @SideOnly(Side.CLIENT) - public IIcon getIcon(int side, int meta) { - return side >= 2 ? iconTop : source.getIcon(side, meta); - } + @Override + public boolean canPaneConnectTo(IBlockAccess world, int x, int y, int z, ForgeDirection dir) { + Block block = world.getBlock(x, y, z); + return block == ModBlocks.elfGlass || block == ModBlocks.manaGlass || block == ModBlocks.bifrostPerm || super.canPaneConnectTo(world, x, y, z, dir); + } - @Override - public boolean canPaneConnectTo(IBlockAccess world, int x, int y, int z, ForgeDirection dir) { - Block block = world.getBlock(x, y, z); - return block == ModBlocks.elfGlass - || block == ModBlocks.manaGlass - || block == ModBlocks.bifrostPerm - || super.canPaneConnectTo(world, x, y, z, dir); - } } diff --git a/src/main/java/vazkii/botania/common/block/decor/quartz/BlockSpecialQuartz.java b/src/main/java/vazkii/botania/common/block/decor/quartz/BlockSpecialQuartz.java index 560e0b4017..7773404ad2 100644 --- a/src/main/java/vazkii/botania/common/block/decor/quartz/BlockSpecialQuartz.java +++ b/src/main/java/vazkii/botania/common/block/decor/quartz/BlockSpecialQuartz.java @@ -2,18 +2,16 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jun 11, 2014, 1:05:32 AM (GMT)] */ package vazkii.botania.common.block.decor.quartz; -import cpw.mods.fml.common.registry.GameRegistry; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; import java.util.List; + import net.minecraft.block.Block; import net.minecraft.block.material.Material; import net.minecraft.client.renderer.texture.IIconRegister; @@ -30,130 +28,127 @@ import vazkii.botania.common.block.ModFluffBlocks; import vazkii.botania.common.item.block.ItemBlockSpecialQuartz; import vazkii.botania.common.lexicon.LexiconData; +import cpw.mods.fml.common.registry.GameRegistry; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; public class BlockSpecialQuartz extends BlockMod implements ILexiconable { - private final String[] iconNames; - public final String type; - private IIcon[] specialQuartzIcons; - private IIcon chiseledSpecialQuartzIcon; - private IIcon pillarSpecialQuartzIcon; - private IIcon specialQuartzTopIcon; - - public BlockSpecialQuartz(String type) { - super(Material.rock); - this.type = type; - iconNames = new String[] { - "block" + type + "Quartz0", "chiseled" + type + "Quartz0", "pillar" + type + "Quartz0", null, null - }; - setHardness(0.8F); - setResistance(10F); - setBlockName("quartzType" + type); - } - - @Override - public Block setBlockName(String par1Str) { - GameRegistry.registerBlock(this, ItemBlockSpecialQuartz.class, par1Str); - return super.setBlockName(par1Str); - } - - @Override - protected boolean shouldRegisterInNameSet() { - return false; - } - - public String[] getNames() { - return new String[] { - "tile.botania:block" + type + "Quartz", - "tile.botania:chiseled" + type + "Quartz", - "tile.botania:pillar" + type + "Quartz", - }; - } - - @Override - @SideOnly(Side.CLIENT) - public IIcon getIcon(int par1, int par2) { - if (par2 != 2 && par2 != 3 && par2 != 4) { - if (par1 != 1 && (par1 != 0 || par2 != 1)) { - if (par1 == 0) return specialQuartzTopIcon; - else { - if (par2 < 0 || par2 >= specialQuartzIcons.length) par2 = 0; - - return specialQuartzIcons[par2]; - } - } else return par2 == 1 ? chiseledSpecialQuartzIcon : specialQuartzTopIcon; - } else - return par2 == 2 && (par1 == 1 || par1 == 0) - ? pillarSpecialQuartzIcon - : par2 == 3 && (par1 == 5 || par1 == 4) - ? pillarSpecialQuartzIcon - : par2 == 4 && (par1 == 2 || par1 == 3) - ? pillarSpecialQuartzIcon - : specialQuartzIcons[par2]; - } - - @Override - public int onBlockPlaced( - World par1World, int par2, int par3, int par4, int par5, float par6, float par7, float par8, int par9) { - if (par9 == 2) { - switch (par5) { - case 0: - case 1: - par9 = 2; - break; - case 2: - case 3: - par9 = 4; - break; - case 4: - case 5: - par9 = 3; - } - } - - return par9; - } - - @Override - public int damageDropped(int par1) { - return par1 != 3 && par1 != 4 ? par1 : 2; - } - - @Override - public ItemStack createStackedBlock(int par1) { - return par1 != 3 && par1 != 4 ? super.createStackedBlock(par1) : new ItemStack(this, 1, 2); - } - - @Override - public int getRenderType() { - return 39; - } - - @Override - @SideOnly(Side.CLIENT) - public void getSubBlocks(Item item, CreativeTabs tab, List par3List) { - par3List.add(new ItemStack(this, 1, 0)); - par3List.add(new ItemStack(this, 1, 1)); - par3List.add(new ItemStack(this, 1, 2)); - } - - @Override - @SideOnly(Side.CLIENT) - public void registerBlockIcons(IIconRegister par1IconRegister) { - specialQuartzIcons = new IIcon[iconNames.length]; - - for (int i = 0; i < specialQuartzIcons.length; ++i) { - if (iconNames[i] == null) specialQuartzIcons[i] = specialQuartzIcons[i - 1]; - else specialQuartzIcons[i] = IconHelper.forName(par1IconRegister, iconNames[i]); - } - - specialQuartzTopIcon = IconHelper.forName(par1IconRegister, "block" + type + "Quartz1"); - chiseledSpecialQuartzIcon = IconHelper.forName(par1IconRegister, "chiseled" + type + "Quartz1"); - pillarSpecialQuartzIcon = IconHelper.forName(par1IconRegister, "pillar" + type + "Quartz1"); - } - - @Override - public LexiconEntry getEntry(World world, int x, int y, int z, EntityPlayer player, ItemStack lexicon) { - return this == ModFluffBlocks.elfQuartz ? LexiconData.elvenResources : LexiconData.decorativeBlocks; - } + private final String[] iconNames; + public final String type; + private IIcon[] specialQuartzIcons; + private IIcon chiseledSpecialQuartzIcon; + private IIcon pillarSpecialQuartzIcon; + private IIcon specialQuartzTopIcon; + + public BlockSpecialQuartz(String type) { + super(Material.rock); + this.type = type; + iconNames = new String[]{ "block" + type + "Quartz0", "chiseled" + type + "Quartz0", "pillar" + type + "Quartz0", null, null }; + setHardness(0.8F); + setResistance(10F); + setBlockName("quartzType" + type); + } + + @Override + public Block setBlockName(String par1Str) { + GameRegistry.registerBlock(this, ItemBlockSpecialQuartz.class, par1Str); + return super.setBlockName(par1Str); + } + + @Override + protected boolean shouldRegisterInNameSet() { + return false; + } + + public String[] getNames() { + return new String[] { + "tile.botania:block" + type + "Quartz", + "tile.botania:chiseled" + type + "Quartz", + "tile.botania:pillar" + type + "Quartz", + }; + } + + @Override + @SideOnly(Side.CLIENT) + public IIcon getIcon(int par1, int par2) { + if (par2 != 2 && par2 != 3 && par2 != 4) { + if (par1 != 1 && (par1 != 0 || par2 != 1)) { + if (par1 == 0) + return specialQuartzTopIcon; + else { + if (par2 < 0 || par2 >= specialQuartzIcons.length) + par2 = 0; + + return specialQuartzIcons[par2]; + } + } else return par2 == 1 ? chiseledSpecialQuartzIcon : specialQuartzTopIcon; + } else + return par2 == 2 && (par1 == 1 || par1 == 0) ? pillarSpecialQuartzIcon : par2 == 3 && (par1 == 5 || par1 == 4) ? pillarSpecialQuartzIcon : par2 == 4 && (par1 == 2 || par1 == 3) ? pillarSpecialQuartzIcon : specialQuartzIcons[par2]; + } + + @Override + public int onBlockPlaced(World par1World, int par2, int par3, int par4, int par5, float par6, float par7, float par8, int par9) { + if (par9 == 2) { + switch (par5) { + case 0: + case 1: + par9 = 2; + break; + case 2: + case 3: + par9 = 4; + break; + case 4: + case 5: + par9 = 3; + } + } + + return par9; + } + + @Override + public int damageDropped(int par1) { + return par1 != 3 && par1 != 4 ? par1 : 2; + } + + @Override + public ItemStack createStackedBlock(int par1) { + return par1 != 3 && par1 != 4 ? super.createStackedBlock(par1) : new ItemStack(this, 1, 2); + } + + @Override + public int getRenderType() { + return 39; + } + + @Override + @SideOnly(Side.CLIENT) + public void getSubBlocks(Item item, CreativeTabs tab, List par3List) { + par3List.add(new ItemStack(this, 1, 0)); + par3List.add(new ItemStack(this, 1, 1)); + par3List.add(new ItemStack(this, 1, 2)); + } + + @Override + @SideOnly(Side.CLIENT) + public void registerBlockIcons(IIconRegister par1IconRegister) { + specialQuartzIcons = new IIcon[iconNames.length]; + + for (int i = 0; i < specialQuartzIcons.length; ++i) { + if (iconNames[i] == null) + specialQuartzIcons[i] = specialQuartzIcons[i - 1]; + else specialQuartzIcons[i] = IconHelper.forName(par1IconRegister, iconNames[i]); + } + + specialQuartzTopIcon = IconHelper.forName(par1IconRegister, "block" + type + "Quartz1"); + chiseledSpecialQuartzIcon = IconHelper.forName(par1IconRegister, "chiseled" + type + "Quartz1"); + pillarSpecialQuartzIcon = IconHelper.forName(par1IconRegister, "pillar" + type + "Quartz1"); + } + + @Override + public LexiconEntry getEntry(World world, int x, int y, int z, EntityPlayer player, ItemStack lexicon) { + return this == ModFluffBlocks.elfQuartz ? LexiconData.elvenResources : LexiconData.decorativeBlocks; + } } diff --git a/src/main/java/vazkii/botania/common/block/decor/quartz/BlockSpecialQuartzSlab.java b/src/main/java/vazkii/botania/common/block/decor/quartz/BlockSpecialQuartzSlab.java index 0890c91838..c26bbc8c1d 100644 --- a/src/main/java/vazkii/botania/common/block/decor/quartz/BlockSpecialQuartzSlab.java +++ b/src/main/java/vazkii/botania/common/block/decor/quartz/BlockSpecialQuartzSlab.java @@ -2,17 +2,16 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jun 11, 2014, 1:08:28 AM (GMT)] */ package vazkii.botania.common.block.decor.quartz; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; import java.util.Random; + import net.minecraft.block.Block; import net.minecraft.block.BlockSlab; import net.minecraft.block.material.Material; @@ -27,73 +26,90 @@ import vazkii.botania.common.block.ModFluffBlocks; import vazkii.botania.common.block.decor.slabs.BlockModSlab; import vazkii.botania.common.lexicon.LexiconData; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; public class BlockSpecialQuartzSlab extends BlockModSlab { - Block source; - - public BlockSpecialQuartzSlab(Block source, boolean par2) { - super(par2, Material.rock, "quartzSlab" + ((BlockSpecialQuartz) source).type + (par2 ? "Full" : "Half")); - setHardness(0.8F); - setResistance(10F); - this.source = source; - } - - @Override - public BlockSlab getFullBlock() { - if (source == ModFluffBlocks.darkQuartz) return (BlockSlab) ModFluffBlocks.darkQuartzSlabFull; - if (source == ModFluffBlocks.manaQuartz) return (BlockSlab) ModFluffBlocks.manaQuartzSlabFull; - if (source == ModFluffBlocks.blazeQuartz) return (BlockSlab) ModFluffBlocks.blazeQuartzSlabFull; - if (source == ModFluffBlocks.lavenderQuartz) return (BlockSlab) ModFluffBlocks.lavenderQuartzSlabFull; - if (source == ModFluffBlocks.redQuartz) return (BlockSlab) ModFluffBlocks.redQuartzSlabFull; - if (source == ModFluffBlocks.elfQuartz) return (BlockSlab) ModFluffBlocks.elfQuartzSlabFull; - if (source == ModFluffBlocks.sunnyQuartz) return (BlockSlab) ModFluffBlocks.sunnyQuartzSlabFull; - - return this; - } - - @Override - public BlockSlab getSingleBlock() { - if (source == ModFluffBlocks.darkQuartz) return (BlockSlab) ModFluffBlocks.darkQuartzSlab; - if (source == ModFluffBlocks.manaQuartz) return (BlockSlab) ModFluffBlocks.manaQuartzSlab; - if (source == ModFluffBlocks.blazeQuartz) return (BlockSlab) ModFluffBlocks.blazeQuartzSlab; - if (source == ModFluffBlocks.lavenderQuartz) return (BlockSlab) ModFluffBlocks.lavenderQuartzSlab; - if (source == ModFluffBlocks.redQuartz) return (BlockSlab) ModFluffBlocks.redQuartzSlab; - if (source == ModFluffBlocks.elfQuartz) return (BlockSlab) ModFluffBlocks.elfQuartzSlab; - if (source == ModFluffBlocks.sunnyQuartz) return (BlockSlab) ModFluffBlocks.sunnyQuartzSlab; - - return this; - } - - @Override - public ItemStack getPickBlock(MovingObjectPosition target, World world, int x, int y, int z) { - return new ItemStack(getSingleBlock()); - } - - @Override - @SideOnly(Side.CLIENT) - public IIcon getIcon(int par1, int par2) { - return source.getBlockTextureFromSide(par1); - } - - @Override - public Item getItemDropped(int p_149650_1_, Random p_149650_2_, int p_149650_3_) { - return Item.getItemFromBlock(getSingleBlock()); - } - - @Override - public ItemStack createStackedBlock(int par1) { - return new ItemStack(getSingleBlock()); - } - - @Override - @SideOnly(Side.CLIENT) - public void registerBlockIcons(IIconRegister par1IconRegister) { - // NO-OP - } - - @Override - public LexiconEntry getEntry(World world, int x, int y, int z, EntityPlayer player, ItemStack lexicon) { - return this == ModFluffBlocks.elfQuartzSlab ? LexiconData.elvenResources : LexiconData.decorativeBlocks; - } + Block source; + + public BlockSpecialQuartzSlab(Block source, boolean par2) { + super(par2, Material.rock, "quartzSlab" + ((BlockSpecialQuartz) source).type + (par2 ? "Full" : "Half")); + setHardness(0.8F); + setResistance(10F); + this.source = source; + } + + @Override + public BlockSlab getFullBlock() { + if(source == ModFluffBlocks.darkQuartz) + return (BlockSlab) ModFluffBlocks.darkQuartzSlabFull; + if(source == ModFluffBlocks.manaQuartz) + return (BlockSlab) ModFluffBlocks.manaQuartzSlabFull; + if(source == ModFluffBlocks.blazeQuartz) + return (BlockSlab) ModFluffBlocks.blazeQuartzSlabFull; + if(source == ModFluffBlocks.lavenderQuartz) + return (BlockSlab) ModFluffBlocks.lavenderQuartzSlabFull; + if(source == ModFluffBlocks.redQuartz) + return (BlockSlab) ModFluffBlocks.redQuartzSlabFull; + if(source == ModFluffBlocks.elfQuartz) + return (BlockSlab) ModFluffBlocks.elfQuartzSlabFull; + if(source == ModFluffBlocks.sunnyQuartz) + return (BlockSlab) ModFluffBlocks.sunnyQuartzSlabFull; + + return this; + } + + @Override + public BlockSlab getSingleBlock() { + if(source == ModFluffBlocks.darkQuartz) + return (BlockSlab) ModFluffBlocks.darkQuartzSlab; + if(source == ModFluffBlocks.manaQuartz) + return (BlockSlab) ModFluffBlocks.manaQuartzSlab; + if(source == ModFluffBlocks.blazeQuartz) + return (BlockSlab) ModFluffBlocks.blazeQuartzSlab; + if(source == ModFluffBlocks.lavenderQuartz) + return (BlockSlab) ModFluffBlocks.lavenderQuartzSlab; + if(source == ModFluffBlocks.redQuartz) + return (BlockSlab) ModFluffBlocks.redQuartzSlab; + if(source == ModFluffBlocks.elfQuartz) + return (BlockSlab) ModFluffBlocks.elfQuartzSlab; + if(source == ModFluffBlocks.sunnyQuartz) + return (BlockSlab) ModFluffBlocks.sunnyQuartzSlab; + + return this; + } + + @Override + public ItemStack getPickBlock(MovingObjectPosition target, World world, int x, int y, int z) { + return new ItemStack(getSingleBlock()); + } + + @Override + @SideOnly(Side.CLIENT) + public IIcon getIcon(int par1, int par2) { + return source.getBlockTextureFromSide(par1); + } + + @Override + public Item getItemDropped(int p_149650_1_, Random p_149650_2_, int p_149650_3_) { + return Item.getItemFromBlock(getSingleBlock()); + } + + @Override + public ItemStack createStackedBlock(int par1) { + return new ItemStack(getSingleBlock()); + } + + @Override + @SideOnly(Side.CLIENT) + public void registerBlockIcons(IIconRegister par1IconRegister) { + // NO-OP + } + + @Override + public LexiconEntry getEntry(World world, int x, int y, int z, EntityPlayer player, ItemStack lexicon) { + return this == ModFluffBlocks.elfQuartzSlab ? LexiconData.elvenResources : LexiconData.decorativeBlocks; + } + } diff --git a/src/main/java/vazkii/botania/common/block/decor/quartz/BlockSpecialQuartzStairs.java b/src/main/java/vazkii/botania/common/block/decor/quartz/BlockSpecialQuartzStairs.java index b587ae3c17..b2494da450 100644 --- a/src/main/java/vazkii/botania/common/block/decor/quartz/BlockSpecialQuartzStairs.java +++ b/src/main/java/vazkii/botania/common/block/decor/quartz/BlockSpecialQuartzStairs.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jun 11, 2014, 1:12:50 AM (GMT)] */ package vazkii.botania.common.block.decor.quartz; @@ -21,14 +21,13 @@ public class BlockSpecialQuartzStairs extends BlockModStairs { - public BlockSpecialQuartzStairs(Block source) { - super(source, 0, "quartzStairs" + ((BlockSpecialQuartz) source).type); - } + public BlockSpecialQuartzStairs(Block source) { + super(source, 0, "quartzStairs" + ((BlockSpecialQuartz) source).type); + } - @Override - public LexiconEntry getEntry(World world, int x, int y, int z, EntityPlayer player, ItemStack lexicon) { - return this == ModFluffBlocks.elfQuartzStairs - ? LexiconData.elvenResources - : super.getEntry(world, x, y, z, player, lexicon); - } -} + @Override + public LexiconEntry getEntry(World world, int x, int y, int z, EntityPlayer player, ItemStack lexicon) { + return this == ModFluffBlocks.elfQuartzStairs ? LexiconData.elvenResources : super.getEntry(world, x, y, z, player, lexicon); + } + +} \ No newline at end of file diff --git a/src/main/java/vazkii/botania/common/block/decor/slabs/Block18StoneSlab.java b/src/main/java/vazkii/botania/common/block/decor/slabs/Block18StoneSlab.java index b2f0236780..b5ff215d63 100644 --- a/src/main/java/vazkii/botania/common/block/decor/slabs/Block18StoneSlab.java +++ b/src/main/java/vazkii/botania/common/block/decor/slabs/Block18StoneSlab.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Apr 10, 2015, 7:52:06 PM (GMT)] */ package vazkii.botania.common.block.decor.slabs; @@ -20,27 +20,28 @@ public class Block18StoneSlab extends BlockLivingSlab { - int index; - - public Block18StoneSlab(boolean full, int meta, int index) { - super(full, ModFluffBlocks.stone, meta); - this.index = index; - setHardness(1.5F); - setResistance(10F); - } - - @Override - public BlockSlab getFullBlock() { - return (BlockSlab) ModFluffBlocks.stoneFullSlabs[index]; - } - - @Override - public BlockSlab getSingleBlock() { - return (BlockSlab) ModFluffBlocks.stoneSlabs[index]; - } - - @Override - public LexiconEntry getEntry(World world, int x, int y, int z, EntityPlayer player, ItemStack lexicon) { - return LexiconData.stoneAlchemy; - } + int index; + + public Block18StoneSlab(boolean full, int meta, int index) { + super(full, ModFluffBlocks.stone, meta); + this.index = index; + setHardness(1.5F); + setResistance(10F); + } + + @Override + public BlockSlab getFullBlock() { + return (BlockSlab) ModFluffBlocks.stoneFullSlabs[index]; + } + + @Override + public BlockSlab getSingleBlock() { + return (BlockSlab) ModFluffBlocks.stoneSlabs[index]; + } + + @Override + public LexiconEntry getEntry(World world, int x, int y, int z, EntityPlayer player, ItemStack lexicon) { + return LexiconData.stoneAlchemy; + } + } diff --git a/src/main/java/vazkii/botania/common/block/decor/slabs/BlockBiomeStoneSlab.java b/src/main/java/vazkii/botania/common/block/decor/slabs/BlockBiomeStoneSlab.java index aecbb635ba..aa20c9def0 100644 --- a/src/main/java/vazkii/botania/common/block/decor/slabs/BlockBiomeStoneSlab.java +++ b/src/main/java/vazkii/botania/common/block/decor/slabs/BlockBiomeStoneSlab.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jan 29, 2015, 7:34:16 PM (GMT)] */ package vazkii.botania.common.block.decor.slabs; @@ -21,27 +21,28 @@ public class BlockBiomeStoneSlab extends BlockLivingSlab { - int index; - - public BlockBiomeStoneSlab(boolean full, Block source, int meta, int index) { - super(full, source, meta); - this.index = index; - setHardness(1.5F); - setResistance(10F); - } - - @Override - public BlockSlab getFullBlock() { - return (BlockSlab) ModFluffBlocks.biomeStoneFullSlabs[index]; - } - - @Override - public BlockSlab getSingleBlock() { - return (BlockSlab) ModFluffBlocks.biomeStoneSlabs[index]; - } - - @Override - public LexiconEntry getEntry(World world, int x, int y, int z, EntityPlayer player, ItemStack lexicon) { - return LexiconData.marimorphosis; - } + int index; + + public BlockBiomeStoneSlab(boolean full, Block source, int meta, int index) { + super(full, source, meta); + this.index = index; + setHardness(1.5F); + setResistance(10F); + } + + @Override + public BlockSlab getFullBlock() { + return (BlockSlab) ModFluffBlocks.biomeStoneFullSlabs[index]; + } + + @Override + public BlockSlab getSingleBlock() { + return (BlockSlab) ModFluffBlocks.biomeStoneSlabs[index]; + } + + @Override + public LexiconEntry getEntry(World world, int x, int y, int z, EntityPlayer player, ItemStack lexicon) { + return LexiconData.marimorphosis; + } + } diff --git a/src/main/java/vazkii/botania/common/block/decor/slabs/BlockDirtPathSlab.java b/src/main/java/vazkii/botania/common/block/decor/slabs/BlockDirtPathSlab.java index 4a69c3450f..a91b5bbab0 100644 --- a/src/main/java/vazkii/botania/common/block/decor/slabs/BlockDirtPathSlab.java +++ b/src/main/java/vazkii/botania/common/block/decor/slabs/BlockDirtPathSlab.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jan 26, 2015, 10:15:05 PM (GMT)] */ package vazkii.botania.common.block.decor.slabs; @@ -21,23 +21,24 @@ public class BlockDirtPathSlab extends BlockLivingSlab { - public BlockDirtPathSlab(boolean full) { - super(full, ModBlocks.dirtPath, 0); - setHardness(0.6F); - } + public BlockDirtPathSlab(boolean full) { + super(full, ModBlocks.dirtPath, 0); + setHardness(0.6F); + } - @Override - public BlockSlab getFullBlock() { - return (BlockSlab) ModFluffBlocks.dirtPathSlabFull; - } + @Override + public BlockSlab getFullBlock() { + return (BlockSlab) ModFluffBlocks.dirtPathSlabFull; + } - @Override - public BlockSlab getSingleBlock() { - return (BlockSlab) ModFluffBlocks.dirtPathSlab; - } + @Override + public BlockSlab getSingleBlock() { + return (BlockSlab) ModFluffBlocks.dirtPathSlab; + } + + @Override + public LexiconEntry getEntry(World world, int x, int y, int z, EntityPlayer player, ItemStack lexicon) { + return LexiconData.dirtPath; + } - @Override - public LexiconEntry getEntry(World world, int x, int y, int z, EntityPlayer player, ItemStack lexicon) { - return LexiconData.dirtPath; - } } diff --git a/src/main/java/vazkii/botania/common/block/decor/slabs/BlockEndStoneSlab.java b/src/main/java/vazkii/botania/common/block/decor/slabs/BlockEndStoneSlab.java index 8222e8d2aa..4a2a65d9fb 100644 --- a/src/main/java/vazkii/botania/common/block/decor/slabs/BlockEndStoneSlab.java +++ b/src/main/java/vazkii/botania/common/block/decor/slabs/BlockEndStoneSlab.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Feb 16, 2015, 8:45:00 PM (GMT)] */ package vazkii.botania.common.block.decor.slabs; @@ -21,25 +21,26 @@ public class BlockEndStoneSlab extends BlockLivingSlab { - public BlockEndStoneSlab(boolean full) { - super(full, ModBlocks.endStoneBrick, 0); - setHardness(1.5F); - setResistance(10F); - setStepSound(soundTypeStone); - } + public BlockEndStoneSlab(boolean full) { + super(full, ModBlocks.endStoneBrick, 0); + setHardness(1.5F); + setResistance(10F); + setStepSound(soundTypeStone); + } - @Override - public BlockSlab getFullBlock() { - return (BlockSlab) ModFluffBlocks.endStoneSlabFull; - } + @Override + public BlockSlab getFullBlock() { + return (BlockSlab) ModFluffBlocks.endStoneSlabFull; + } - @Override - public BlockSlab getSingleBlock() { - return (BlockSlab) ModFluffBlocks.endStoneSlab; - } + @Override + public BlockSlab getSingleBlock() { + return (BlockSlab) ModFluffBlocks.endStoneSlab; + } + + @Override + public LexiconEntry getEntry(World world, int x, int y, int z, EntityPlayer player, ItemStack lexicon) { + return LexiconData.endStoneDecor; + } - @Override - public LexiconEntry getEntry(World world, int x, int y, int z, EntityPlayer player, ItemStack lexicon) { - return LexiconData.endStoneDecor; - } } diff --git a/src/main/java/vazkii/botania/common/block/decor/slabs/BlockEnderBrickSlab.java b/src/main/java/vazkii/botania/common/block/decor/slabs/BlockEnderBrickSlab.java index e68bf44c9a..ce28c608bf 100644 --- a/src/main/java/vazkii/botania/common/block/decor/slabs/BlockEnderBrickSlab.java +++ b/src/main/java/vazkii/botania/common/block/decor/slabs/BlockEnderBrickSlab.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jul 7, 2015, 10:37:15 PM (GMT)] */ package vazkii.botania.common.block.decor.slabs; @@ -21,25 +21,26 @@ public class BlockEnderBrickSlab extends BlockLivingSlab { - public BlockEnderBrickSlab(boolean full) { - super(full, ModBlocks.endStoneBrick, 2); - setHardness(1.5F); - setResistance(10F); - setStepSound(soundTypeStone); - } + public BlockEnderBrickSlab(boolean full) { + super(full, ModBlocks.endStoneBrick, 2); + setHardness(1.5F); + setResistance(10F); + setStepSound(soundTypeStone); + } - @Override - public BlockSlab getFullBlock() { - return (BlockSlab) ModFluffBlocks.enderBrickSlabFull; - } + @Override + public BlockSlab getFullBlock() { + return (BlockSlab) ModFluffBlocks.enderBrickSlabFull; + } - @Override - public BlockSlab getSingleBlock() { - return (BlockSlab) ModFluffBlocks.enderBrickSlab; - } + @Override + public BlockSlab getSingleBlock() { + return (BlockSlab) ModFluffBlocks.enderBrickSlab; + } + + @Override + public LexiconEntry getEntry(World world, int x, int y, int z, EntityPlayer player, ItemStack lexicon) { + return LexiconData.endStoneDecor; + } - @Override - public LexiconEntry getEntry(World world, int x, int y, int z, EntityPlayer player, ItemStack lexicon) { - return LexiconData.endStoneDecor; - } } diff --git a/src/main/java/vazkii/botania/common/block/decor/slabs/BlockLivingSlab.java b/src/main/java/vazkii/botania/common/block/decor/slabs/BlockLivingSlab.java index ede6e0d48e..5737748432 100644 --- a/src/main/java/vazkii/botania/common/block/decor/slabs/BlockLivingSlab.java +++ b/src/main/java/vazkii/botania/common/block/decor/slabs/BlockLivingSlab.java @@ -1,28 +1,26 @@ package vazkii.botania.common.block.decor.slabs; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; import net.minecraft.block.Block; import net.minecraft.util.IIcon; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; public abstract class BlockLivingSlab extends BlockModSlab { - Block source; - int meta; + Block source; + int meta; + + public BlockLivingSlab(boolean full, Block source, int meta) { + super(full, source.getMaterial(), source.getUnlocalizedName().replaceAll("tile.", "") + meta + "Slab" + (full ? "Full" : "")); + setStepSound(source.stepSound); + this.source = source; + this.meta = meta; + } - public BlockLivingSlab(boolean full, Block source, int meta) { - super( - full, - source.getMaterial(), - source.getUnlocalizedName().replaceAll("tile.", "") + meta + "Slab" + (full ? "Full" : "")); - setStepSound(source.stepSound); - this.source = source; - this.meta = meta; - } + @Override + @SideOnly(Side.CLIENT) + public IIcon getIcon(int par1, int par2) { + return source.getIcon(par1, meta); + } - @Override - @SideOnly(Side.CLIENT) - public IIcon getIcon(int par1, int par2) { - return source.getIcon(par1, meta); - } } diff --git a/src/main/java/vazkii/botania/common/block/decor/slabs/BlockModSlab.java b/src/main/java/vazkii/botania/common/block/decor/slabs/BlockModSlab.java index 3712e12d8f..d6f502f614 100644 --- a/src/main/java/vazkii/botania/common/block/decor/slabs/BlockModSlab.java +++ b/src/main/java/vazkii/botania/common/block/decor/slabs/BlockModSlab.java @@ -1,9 +1,7 @@ package vazkii.botania.common.block.decor.slabs; -import cpw.mods.fml.common.registry.GameRegistry; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; import java.util.Random; + import net.minecraft.block.BlockSlab; import net.minecraft.block.material.Material; import net.minecraft.client.renderer.texture.IIconRegister; @@ -17,62 +15,66 @@ import vazkii.botania.common.core.BotaniaCreativeTab; import vazkii.botania.common.item.block.ItemBlockModSlab; import vazkii.botania.common.lexicon.LexiconData; +import cpw.mods.fml.common.registry.GameRegistry; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; public abstract class BlockModSlab extends BlockSlab implements ILexiconable { - String name; - - public BlockModSlab(boolean full, Material mat, String name) { - super(full, mat); - this.name = name; - setBlockName(name); - if (!full) { - setCreativeTab(BotaniaCreativeTab.INSTANCE); - useNeighborBrightness = true; - } - } - - public abstract BlockSlab getFullBlock(); - - public abstract BlockSlab getSingleBlock(); - - @Override - public ItemStack getPickBlock(MovingObjectPosition target, World world, int x, int y, int z) { - return new ItemStack(getSingleBlock()); - } - - @Override - public Item getItemDropped(int p_149650_1_, Random p_149650_2_, int p_149650_3_) { - return Item.getItemFromBlock(getSingleBlock()); - } - - @Override - public int quantityDropped(int meta, int fortune, Random random) { - return super.quantityDropped(meta, fortune, random); - } - - @Override - public ItemStack createStackedBlock(int par1) { - return new ItemStack(getSingleBlock()); - } - - @Override - @SideOnly(Side.CLIENT) - public void registerBlockIcons(IIconRegister par1IconRegister) { - // NO-OP - } - - public void register() { - GameRegistry.registerBlock(this, ItemBlockModSlab.class, name); - } - - @Override - public String func_150002_b(int i) { - return name; - } - - @Override - public LexiconEntry getEntry(World world, int x, int y, int z, EntityPlayer player, ItemStack lexicon) { - return LexiconData.decorativeBlocks; - } + String name; + + public BlockModSlab(boolean full, Material mat, String name) { + super(full, mat); + this.name = name; + setBlockName(name); + if(!full) { + setCreativeTab(BotaniaCreativeTab.INSTANCE); + useNeighborBrightness = true; + } + } + + public abstract BlockSlab getFullBlock(); + + public abstract BlockSlab getSingleBlock(); + + @Override + public ItemStack getPickBlock(MovingObjectPosition target, World world, int x, int y, int z) { + return new ItemStack(getSingleBlock()); + } + + @Override + public Item getItemDropped(int p_149650_1_, Random p_149650_2_, int p_149650_3_) { + return Item.getItemFromBlock(getSingleBlock()); + } + + @Override + public int quantityDropped(int meta, int fortune, Random random) { + return super.quantityDropped(meta, fortune, random); + } + + @Override + public ItemStack createStackedBlock(int par1) { + return new ItemStack(getSingleBlock()); + } + + @Override + @SideOnly(Side.CLIENT) + public void registerBlockIcons(IIconRegister par1IconRegister) { + // NO-OP + } + + public void register() { + GameRegistry.registerBlock(this, ItemBlockModSlab.class, name); + } + + @Override + public String func_150002_b(int i) { + return name; + } + + @Override + public LexiconEntry getEntry(World world, int x, int y, int z, EntityPlayer player, ItemStack lexicon) { + return LexiconData.decorativeBlocks; + } + } diff --git a/src/main/java/vazkii/botania/common/block/decor/slabs/BlockPavementSlab.java b/src/main/java/vazkii/botania/common/block/decor/slabs/BlockPavementSlab.java index df37cac565..9e071232f4 100644 --- a/src/main/java/vazkii/botania/common/block/decor/slabs/BlockPavementSlab.java +++ b/src/main/java/vazkii/botania/common/block/decor/slabs/BlockPavementSlab.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Sep 1, 2015, 7:17:45 PM (GMT)] */ package vazkii.botania.common.block.decor.slabs; @@ -20,27 +20,29 @@ public class BlockPavementSlab extends BlockLivingSlab { - int index; - - public BlockPavementSlab(boolean full, int meta, int index) { - super(full, ModFluffBlocks.pavement, meta); - this.index = index; - setHardness(2F); - setResistance(10F); - } - - @Override - public BlockSlab getFullBlock() { - return (BlockSlab) ModFluffBlocks.pavementFullSlabs[index]; - } - - @Override - public BlockSlab getSingleBlock() { - return (BlockSlab) ModFluffBlocks.pavementSlabs[index]; - } - - @Override - public LexiconEntry getEntry(World world, int x, int y, int z, EntityPlayer player, ItemStack lexicon) { - return LexiconData.pavement; - } + int index; + + public BlockPavementSlab(boolean full, int meta, int index) { + super(full, ModFluffBlocks.pavement, meta); + this.index = index; + setHardness(2F); + setResistance(10F); + } + + @Override + public BlockSlab getFullBlock() { + return (BlockSlab) ModFluffBlocks.pavementFullSlabs[index]; + } + + @Override + public BlockSlab getSingleBlock() { + return (BlockSlab) ModFluffBlocks.pavementSlabs[index]; + } + + @Override + public LexiconEntry getEntry(World world, int x, int y, int z, EntityPlayer player, ItemStack lexicon) { + return LexiconData.pavement; + } + + } diff --git a/src/main/java/vazkii/botania/common/block/decor/slabs/BlockReedSlab.java b/src/main/java/vazkii/botania/common/block/decor/slabs/BlockReedSlab.java index 69c0c99a62..23c955d44e 100644 --- a/src/main/java/vazkii/botania/common/block/decor/slabs/BlockReedSlab.java +++ b/src/main/java/vazkii/botania/common/block/decor/slabs/BlockReedSlab.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jul 28, 2014, 8:49:59 PM (GMT)] */ package vazkii.botania.common.block.decor.slabs; @@ -21,24 +21,26 @@ public class BlockReedSlab extends BlockLivingSlab { - public BlockReedSlab(boolean full) { - super(full, ModBlocks.reedBlock, 0); - setHardness(1.0F); - setStepSound(soundTypeWood); - } - - @Override - public BlockSlab getFullBlock() { - return (BlockSlab) ModFluffBlocks.reedSlabFull; - } - - @Override - public BlockSlab getSingleBlock() { - return (BlockSlab) ModFluffBlocks.reedSlab; - } - - @Override - public LexiconEntry getEntry(World world, int x, int y, int z, EntityPlayer player, ItemStack lexicon) { - return LexiconData.decorativeBlocks; - } + public BlockReedSlab(boolean full) { + super(full, ModBlocks.reedBlock, 0); + setHardness(1.0F); + setStepSound(soundTypeWood); + } + + @Override + public BlockSlab getFullBlock() { + return (BlockSlab) ModFluffBlocks.reedSlabFull; + } + + @Override + public BlockSlab getSingleBlock() { + return (BlockSlab) ModFluffBlocks.reedSlab; + } + + @Override + public LexiconEntry getEntry(World world, int x, int y, int z, EntityPlayer player, ItemStack lexicon) { + return LexiconData.decorativeBlocks; + } + + } diff --git a/src/main/java/vazkii/botania/common/block/decor/slabs/BlockThatchSlab.java b/src/main/java/vazkii/botania/common/block/decor/slabs/BlockThatchSlab.java index 8c88f169c2..228ec633ae 100644 --- a/src/main/java/vazkii/botania/common/block/decor/slabs/BlockThatchSlab.java +++ b/src/main/java/vazkii/botania/common/block/decor/slabs/BlockThatchSlab.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jul 28, 2014, 8:49:59 PM (GMT)] */ package vazkii.botania.common.block.decor.slabs; @@ -21,24 +21,26 @@ public class BlockThatchSlab extends BlockLivingSlab { - public BlockThatchSlab(boolean full) { - super(full, ModBlocks.thatch, 0); - setHardness(1.0F); - setStepSound(soundTypeGrass); - } - - @Override - public BlockSlab getFullBlock() { - return (BlockSlab) ModFluffBlocks.thatchSlabFull; - } - - @Override - public BlockSlab getSingleBlock() { - return (BlockSlab) ModFluffBlocks.thatchSlab; - } - - @Override - public LexiconEntry getEntry(World world, int x, int y, int z, EntityPlayer player, ItemStack lexicon) { - return LexiconData.decorativeBlocks; - } + public BlockThatchSlab(boolean full) { + super(full, ModBlocks.thatch, 0); + setHardness(1.0F); + setStepSound(soundTypeGrass); + } + + @Override + public BlockSlab getFullBlock() { + return (BlockSlab) ModFluffBlocks.thatchSlabFull; + } + + @Override + public BlockSlab getSingleBlock() { + return (BlockSlab) ModFluffBlocks.thatchSlab; + } + + @Override + public LexiconEntry getEntry(World world, int x, int y, int z, EntityPlayer player, ItemStack lexicon) { + return LexiconData.decorativeBlocks; + } + + } diff --git a/src/main/java/vazkii/botania/common/block/decor/slabs/bricks/BlockCustomBrickSlab.java b/src/main/java/vazkii/botania/common/block/decor/slabs/bricks/BlockCustomBrickSlab.java index 2f441f06aa..7c6cde0e1d 100644 --- a/src/main/java/vazkii/botania/common/block/decor/slabs/bricks/BlockCustomBrickSlab.java +++ b/src/main/java/vazkii/botania/common/block/decor/slabs/bricks/BlockCustomBrickSlab.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jul 28, 2014, 10:15:41 PM (GMT)] */ package vazkii.botania.common.block.decor.slabs.bricks; @@ -22,29 +22,30 @@ public class BlockCustomBrickSlab extends BlockLivingSlab { - public BlockCustomBrickSlab(boolean full) { - this(full, 0); - } - - public BlockCustomBrickSlab(boolean full, int meta) { - super(full, ModBlocks.customBrick, meta); - setHardness(2.0F); - setResistance(5.0F); - setStepSound(soundTypeStone); - } - - @Override - public BlockSlab getFullBlock() { - return (BlockSlab) ModFluffBlocks.netherBrickSlabFull; - } - - @Override - public BlockSlab getSingleBlock() { - return (BlockSlab) ModFluffBlocks.netherBrickSlab; - } - - @Override - public LexiconEntry getEntry(World world, int x, int y, int z, EntityPlayer player, ItemStack lexicon) { - return LexiconData.decorativeBlocks; - } -} + public BlockCustomBrickSlab(boolean full) { + this(full, 0); + } + + public BlockCustomBrickSlab(boolean full, int meta) { + super(full, ModBlocks.customBrick, meta); + setHardness(2.0F); + setResistance(5.0F); + setStepSound(soundTypeStone); + } + + @Override + public BlockSlab getFullBlock() { + return (BlockSlab) ModFluffBlocks.netherBrickSlabFull; + } + + @Override + public BlockSlab getSingleBlock() { + return (BlockSlab) ModFluffBlocks.netherBrickSlab; + } + + @Override + public LexiconEntry getEntry(World world, int x, int y, int z, EntityPlayer player, ItemStack lexicon) { + return LexiconData.decorativeBlocks; + } + +} \ No newline at end of file diff --git a/src/main/java/vazkii/botania/common/block/decor/slabs/bricks/BlockSnowBrickSlab.java b/src/main/java/vazkii/botania/common/block/decor/slabs/bricks/BlockSnowBrickSlab.java index 3d376683a1..f827d82070 100644 --- a/src/main/java/vazkii/botania/common/block/decor/slabs/bricks/BlockSnowBrickSlab.java +++ b/src/main/java/vazkii/botania/common/block/decor/slabs/bricks/BlockSnowBrickSlab.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jul 28, 2014, 11:32:45 PM (GMT)] */ package vazkii.botania.common.block.decor.slabs.bricks; @@ -15,17 +15,18 @@ public class BlockSnowBrickSlab extends BlockCustomBrickSlab { - public BlockSnowBrickSlab(boolean full) { - super(full, 2); - } + public BlockSnowBrickSlab(boolean full) { + super(full, 2); + } - @Override - public BlockSlab getFullBlock() { - return (BlockSlab) ModFluffBlocks.snowBrickSlabFull; - } + @Override + public BlockSlab getFullBlock() { + return (BlockSlab) ModFluffBlocks.snowBrickSlabFull; + } - @Override - public BlockSlab getSingleBlock() { - return (BlockSlab) ModFluffBlocks.snowBrickSlab; - } -} + @Override + public BlockSlab getSingleBlock() { + return (BlockSlab) ModFluffBlocks.snowBrickSlab; + } + +} \ No newline at end of file diff --git a/src/main/java/vazkii/botania/common/block/decor/slabs/bricks/BlockSoulBrickSlab.java b/src/main/java/vazkii/botania/common/block/decor/slabs/bricks/BlockSoulBrickSlab.java index 2efbf90731..d3afdf03eb 100644 --- a/src/main/java/vazkii/botania/common/block/decor/slabs/bricks/BlockSoulBrickSlab.java +++ b/src/main/java/vazkii/botania/common/block/decor/slabs/bricks/BlockSoulBrickSlab.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jul 28, 2014, 10:19:46 PM (GMT)] */ package vazkii.botania.common.block.decor.slabs.bricks; @@ -15,17 +15,18 @@ public class BlockSoulBrickSlab extends BlockCustomBrickSlab { - public BlockSoulBrickSlab(boolean full) { - super(full, 1); - } + public BlockSoulBrickSlab(boolean full) { + super(full, 1); + } - @Override - public BlockSlab getFullBlock() { - return (BlockSlab) ModFluffBlocks.soulBrickSlabFull; - } + @Override + public BlockSlab getFullBlock() { + return (BlockSlab) ModFluffBlocks.soulBrickSlabFull; + } + + @Override + public BlockSlab getSingleBlock() { + return (BlockSlab) ModFluffBlocks.soulBrickSlab; + } - @Override - public BlockSlab getSingleBlock() { - return (BlockSlab) ModFluffBlocks.soulBrickSlab; - } } diff --git a/src/main/java/vazkii/botania/common/block/decor/slabs/bricks/BlockTileSlab.java b/src/main/java/vazkii/botania/common/block/decor/slabs/bricks/BlockTileSlab.java index 9433a9e042..41ac1e9198 100644 --- a/src/main/java/vazkii/botania/common/block/decor/slabs/bricks/BlockTileSlab.java +++ b/src/main/java/vazkii/botania/common/block/decor/slabs/bricks/BlockTileSlab.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jul 28, 2014, 11:49:42 PM (GMT)] */ package vazkii.botania.common.block.decor.slabs.bricks; @@ -15,17 +15,18 @@ public class BlockTileSlab extends BlockCustomBrickSlab { - public BlockTileSlab(boolean full) { - super(full, 3); - } + public BlockTileSlab(boolean full) { + super(full, 3); + } - @Override - public BlockSlab getFullBlock() { - return (BlockSlab) ModFluffBlocks.tileSlabFull; - } + @Override + public BlockSlab getFullBlock() { + return (BlockSlab) ModFluffBlocks.tileSlabFull; + } + + @Override + public BlockSlab getSingleBlock() { + return (BlockSlab) ModFluffBlocks.tileSlab; + } - @Override - public BlockSlab getSingleBlock() { - return (BlockSlab) ModFluffBlocks.tileSlab; - } } diff --git a/src/main/java/vazkii/botania/common/block/decor/slabs/living/BlockDreamwoodPlankSlab.java b/src/main/java/vazkii/botania/common/block/decor/slabs/living/BlockDreamwoodPlankSlab.java index 697c645ba0..3474f89edd 100644 --- a/src/main/java/vazkii/botania/common/block/decor/slabs/living/BlockDreamwoodPlankSlab.java +++ b/src/main/java/vazkii/botania/common/block/decor/slabs/living/BlockDreamwoodPlankSlab.java @@ -7,18 +7,19 @@ public class BlockDreamwoodPlankSlab extends BlockLivingSlab { - public BlockDreamwoodPlankSlab(boolean full) { - super(full, ModBlocks.dreamwood, 1); - setHardness(2.0F); - } + public BlockDreamwoodPlankSlab(boolean full) { + super(full, ModBlocks.dreamwood, 1); + setHardness(2.0F); + } - @Override - public BlockSlab getFullBlock() { - return (BlockSlab) ModFluffBlocks.dreamwoodPlankSlabFull; - } + @Override + public BlockSlab getFullBlock() { + return (BlockSlab) ModFluffBlocks.dreamwoodPlankSlabFull; + } + + @Override + public BlockSlab getSingleBlock() { + return (BlockSlab) ModFluffBlocks.dreamwoodPlankSlab; + } - @Override - public BlockSlab getSingleBlock() { - return (BlockSlab) ModFluffBlocks.dreamwoodPlankSlab; - } } diff --git a/src/main/java/vazkii/botania/common/block/decor/slabs/living/BlockDreamwoodSlab.java b/src/main/java/vazkii/botania/common/block/decor/slabs/living/BlockDreamwoodSlab.java index 83a1e3ff74..9531c1eb92 100644 --- a/src/main/java/vazkii/botania/common/block/decor/slabs/living/BlockDreamwoodSlab.java +++ b/src/main/java/vazkii/botania/common/block/decor/slabs/living/BlockDreamwoodSlab.java @@ -7,18 +7,19 @@ public class BlockDreamwoodSlab extends BlockLivingSlab { - public BlockDreamwoodSlab(boolean full) { - super(full, ModBlocks.dreamwood, 0); - setHardness(2.0F); - } + public BlockDreamwoodSlab(boolean full) { + super(full, ModBlocks.dreamwood, 0); + setHardness(2.0F); + } - @Override - public BlockSlab getFullBlock() { - return (BlockSlab) ModFluffBlocks.dreamwoodSlabFull; - } + @Override + public BlockSlab getFullBlock() { + return (BlockSlab) ModFluffBlocks.dreamwoodSlabFull; + } + + @Override + public BlockSlab getSingleBlock() { + return (BlockSlab) ModFluffBlocks.dreamwoodSlab; + } - @Override - public BlockSlab getSingleBlock() { - return (BlockSlab) ModFluffBlocks.dreamwoodSlab; - } } diff --git a/src/main/java/vazkii/botania/common/block/decor/slabs/living/BlockLivingrockBrickSlab.java b/src/main/java/vazkii/botania/common/block/decor/slabs/living/BlockLivingrockBrickSlab.java index 6ce10fe7d8..f4cc7b46b9 100644 --- a/src/main/java/vazkii/botania/common/block/decor/slabs/living/BlockLivingrockBrickSlab.java +++ b/src/main/java/vazkii/botania/common/block/decor/slabs/living/BlockLivingrockBrickSlab.java @@ -7,20 +7,21 @@ public class BlockLivingrockBrickSlab extends BlockLivingSlab { - public BlockLivingrockBrickSlab(boolean full) { - super(full, ModBlocks.livingrock, 1); - setHardness(2.0F); - setResistance(10.0F); - setStepSound(soundTypeStone); - } + public BlockLivingrockBrickSlab(boolean full) { + super(full, ModBlocks.livingrock, 1); + setHardness(2.0F); + setResistance(10.0F); + setStepSound(soundTypeStone); + } - @Override - public BlockSlab getFullBlock() { - return (BlockSlab) ModFluffBlocks.livingrockBrickSlabFull; - } + @Override + public BlockSlab getFullBlock() { + return (BlockSlab) ModFluffBlocks.livingrockBrickSlabFull; + } + + @Override + public BlockSlab getSingleBlock() { + return (BlockSlab) ModFluffBlocks.livingrockBrickSlab; + } - @Override - public BlockSlab getSingleBlock() { - return (BlockSlab) ModFluffBlocks.livingrockBrickSlab; - } } diff --git a/src/main/java/vazkii/botania/common/block/decor/slabs/living/BlockLivingrockSlab.java b/src/main/java/vazkii/botania/common/block/decor/slabs/living/BlockLivingrockSlab.java index 6f6c49b8d3..4866a67129 100644 --- a/src/main/java/vazkii/botania/common/block/decor/slabs/living/BlockLivingrockSlab.java +++ b/src/main/java/vazkii/botania/common/block/decor/slabs/living/BlockLivingrockSlab.java @@ -7,20 +7,21 @@ public class BlockLivingrockSlab extends BlockLivingSlab { - public BlockLivingrockSlab(boolean full) { - super(full, ModBlocks.livingrock, 0); - setHardness(2.0F); - setResistance(10.0F); - setStepSound(soundTypeStone); - } + public BlockLivingrockSlab(boolean full) { + super(full, ModBlocks.livingrock, 0); + setHardness(2.0F); + setResistance(10.0F); + setStepSound(soundTypeStone); + } - @Override - public BlockSlab getFullBlock() { - return (BlockSlab) ModFluffBlocks.livingrockSlabFull; - } + @Override + public BlockSlab getFullBlock() { + return (BlockSlab) ModFluffBlocks.livingrockSlabFull; + } + + @Override + public BlockSlab getSingleBlock() { + return (BlockSlab) ModFluffBlocks.livingrockSlab; + } - @Override - public BlockSlab getSingleBlock() { - return (BlockSlab) ModFluffBlocks.livingrockSlab; - } } diff --git a/src/main/java/vazkii/botania/common/block/decor/slabs/living/BlockLivingwoodPlankSlab.java b/src/main/java/vazkii/botania/common/block/decor/slabs/living/BlockLivingwoodPlankSlab.java index 74d975dd9a..4ecc38374e 100644 --- a/src/main/java/vazkii/botania/common/block/decor/slabs/living/BlockLivingwoodPlankSlab.java +++ b/src/main/java/vazkii/botania/common/block/decor/slabs/living/BlockLivingwoodPlankSlab.java @@ -7,18 +7,19 @@ public class BlockLivingwoodPlankSlab extends BlockLivingSlab { - public BlockLivingwoodPlankSlab(boolean full) { - super(full, ModBlocks.livingwood, 1); - setHardness(2.0F); - } + public BlockLivingwoodPlankSlab(boolean full) { + super(full, ModBlocks.livingwood, 1); + setHardness(2.0F); + } - @Override - public BlockSlab getFullBlock() { - return (BlockSlab) ModFluffBlocks.livingwoodPlankSlabFull; - } + @Override + public BlockSlab getFullBlock() { + return (BlockSlab) ModFluffBlocks.livingwoodPlankSlabFull; + } + + @Override + public BlockSlab getSingleBlock() { + return (BlockSlab) ModFluffBlocks.livingwoodPlankSlab; + } - @Override - public BlockSlab getSingleBlock() { - return (BlockSlab) ModFluffBlocks.livingwoodPlankSlab; - } } diff --git a/src/main/java/vazkii/botania/common/block/decor/slabs/living/BlockLivingwoodSlab.java b/src/main/java/vazkii/botania/common/block/decor/slabs/living/BlockLivingwoodSlab.java index 41f0266ca4..53ea9e7459 100644 --- a/src/main/java/vazkii/botania/common/block/decor/slabs/living/BlockLivingwoodSlab.java +++ b/src/main/java/vazkii/botania/common/block/decor/slabs/living/BlockLivingwoodSlab.java @@ -7,18 +7,19 @@ public class BlockLivingwoodSlab extends BlockLivingSlab { - public BlockLivingwoodSlab(boolean full) { - super(full, ModBlocks.livingwood, 0); - setHardness(2.0F); - } + public BlockLivingwoodSlab(boolean full) { + super(full, ModBlocks.livingwood, 0); + setHardness(2.0F); + } - @Override - public BlockSlab getFullBlock() { - return (BlockSlab) ModFluffBlocks.livingwoodSlabFull; - } + @Override + public BlockSlab getFullBlock() { + return (BlockSlab) ModFluffBlocks.livingwoodSlabFull; + } + + @Override + public BlockSlab getSingleBlock() { + return (BlockSlab) ModFluffBlocks.livingwoodSlab; + } - @Override - public BlockSlab getSingleBlock() { - return (BlockSlab) ModFluffBlocks.livingwoodSlab; - } } diff --git a/src/main/java/vazkii/botania/common/block/decor/slabs/living/BlockShimmerrockSlab.java b/src/main/java/vazkii/botania/common/block/decor/slabs/living/BlockShimmerrockSlab.java index 823eb7fa99..8302a16475 100644 --- a/src/main/java/vazkii/botania/common/block/decor/slabs/living/BlockShimmerrockSlab.java +++ b/src/main/java/vazkii/botania/common/block/decor/slabs/living/BlockShimmerrockSlab.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Oct 11, 2015, 3:47:24 PM (GMT)] */ package vazkii.botania.common.block.decor.slabs.living; @@ -17,20 +17,21 @@ public class BlockShimmerrockSlab extends BlockLivingSlab { - public BlockShimmerrockSlab(boolean full) { - super(full, ModBlocks.shimmerrock, 0); - setHardness(2.0F); - setResistance(10.0F); - setStepSound(soundTypeStone); - } + public BlockShimmerrockSlab(boolean full) { + super(full, ModBlocks.shimmerrock, 0); + setHardness(2.0F); + setResistance(10.0F); + setStepSound(soundTypeStone); + } - @Override - public BlockSlab getFullBlock() { - return (BlockSlab) ModFluffBlocks.shimmerrockSlabFull; - } + @Override + public BlockSlab getFullBlock() { + return (BlockSlab) ModFluffBlocks.shimmerrockSlabFull; + } + + @Override + public BlockSlab getSingleBlock() { + return (BlockSlab) ModFluffBlocks.shimmerrockSlab; + } - @Override - public BlockSlab getSingleBlock() { - return (BlockSlab) ModFluffBlocks.shimmerrockSlab; - } } diff --git a/src/main/java/vazkii/botania/common/block/decor/slabs/living/BlockShimmerwoodPlankSlab.java b/src/main/java/vazkii/botania/common/block/decor/slabs/living/BlockShimmerwoodPlankSlab.java index d44656380d..1f4b2fb09f 100644 --- a/src/main/java/vazkii/botania/common/block/decor/slabs/living/BlockShimmerwoodPlankSlab.java +++ b/src/main/java/vazkii/botania/common/block/decor/slabs/living/BlockShimmerwoodPlankSlab.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Oct 11, 2015, 3:47:47 PM (GMT)] */ package vazkii.botania.common.block.decor.slabs.living; @@ -17,20 +17,20 @@ public class BlockShimmerwoodPlankSlab extends BlockLivingSlab { - public BlockShimmerwoodPlankSlab(boolean full) { - super(full, ModBlocks.shimmerwoodPlanks, 0); - setHardness(2.0F); - setResistance(10.0F); - setStepSound(soundTypeWood); - } + public BlockShimmerwoodPlankSlab(boolean full) { + super(full, ModBlocks.shimmerwoodPlanks, 0); + setHardness(2.0F); + setResistance(10.0F); + setStepSound(soundTypeWood); + } - @Override - public BlockSlab getFullBlock() { - return (BlockSlab) ModFluffBlocks.shimmerwoodPlankSlabFull; - } + @Override + public BlockSlab getFullBlock() { + return (BlockSlab) ModFluffBlocks.shimmerwoodPlankSlabFull; + } - @Override - public BlockSlab getSingleBlock() { - return (BlockSlab) ModFluffBlocks.shimmerwoodPlankSlab; - } + @Override + public BlockSlab getSingleBlock() { + return (BlockSlab) ModFluffBlocks.shimmerwoodPlankSlab; + } } diff --git a/src/main/java/vazkii/botania/common/block/decor/slabs/prismarine/BlockDarkPrismarineSlab.java b/src/main/java/vazkii/botania/common/block/decor/slabs/prismarine/BlockDarkPrismarineSlab.java index 7dbf6f0341..4d11d827ee 100644 --- a/src/main/java/vazkii/botania/common/block/decor/slabs/prismarine/BlockDarkPrismarineSlab.java +++ b/src/main/java/vazkii/botania/common/block/decor/slabs/prismarine/BlockDarkPrismarineSlab.java @@ -5,17 +5,18 @@ public class BlockDarkPrismarineSlab extends BlockPrismarineSlab { - public BlockDarkPrismarineSlab(boolean full) { - super(full, 2); - } + public BlockDarkPrismarineSlab(boolean full) { + super(full, 2); + } - @Override - public BlockSlab getFullBlock() { - return (BlockSlab) ModFluffBlocks.darkPrismarineSlabFull; - } + @Override + public BlockSlab getFullBlock() { + return (BlockSlab) ModFluffBlocks.darkPrismarineSlabFull; + } + + @Override + public BlockSlab getSingleBlock() { + return (BlockSlab) ModFluffBlocks.darkPrismarineSlab; + } - @Override - public BlockSlab getSingleBlock() { - return (BlockSlab) ModFluffBlocks.darkPrismarineSlab; - } } diff --git a/src/main/java/vazkii/botania/common/block/decor/slabs/prismarine/BlockPrismarineBrickSlab.java b/src/main/java/vazkii/botania/common/block/decor/slabs/prismarine/BlockPrismarineBrickSlab.java index 43495e35cc..9b7f5fa7a7 100644 --- a/src/main/java/vazkii/botania/common/block/decor/slabs/prismarine/BlockPrismarineBrickSlab.java +++ b/src/main/java/vazkii/botania/common/block/decor/slabs/prismarine/BlockPrismarineBrickSlab.java @@ -5,17 +5,18 @@ public class BlockPrismarineBrickSlab extends BlockPrismarineSlab { - public BlockPrismarineBrickSlab(boolean full) { - super(full, 1); - } + public BlockPrismarineBrickSlab(boolean full) { + super(full, 1); + } - @Override - public BlockSlab getFullBlock() { - return (BlockSlab) ModFluffBlocks.prismarineBrickSlabFull; - } + @Override + public BlockSlab getFullBlock() { + return (BlockSlab) ModFluffBlocks.prismarineBrickSlabFull; + } + + @Override + public BlockSlab getSingleBlock() { + return (BlockSlab) ModFluffBlocks.prismarineBrickSlab; + } - @Override - public BlockSlab getSingleBlock() { - return (BlockSlab) ModFluffBlocks.prismarineBrickSlab; - } } diff --git a/src/main/java/vazkii/botania/common/block/decor/slabs/prismarine/BlockPrismarineSlab.java b/src/main/java/vazkii/botania/common/block/decor/slabs/prismarine/BlockPrismarineSlab.java index 3afe5a2c49..b9e385f032 100644 --- a/src/main/java/vazkii/botania/common/block/decor/slabs/prismarine/BlockPrismarineSlab.java +++ b/src/main/java/vazkii/botania/common/block/decor/slabs/prismarine/BlockPrismarineSlab.java @@ -12,29 +12,30 @@ public class BlockPrismarineSlab extends BlockLivingSlab { - public BlockPrismarineSlab(boolean full) { - this(full, 0); - } - - public BlockPrismarineSlab(boolean full, int meta) { - super(full, ModBlocks.prismarine, meta); - setHardness(2.0F); - setResistance(10.0F); - setStepSound(soundTypeStone); - } - - @Override - public BlockSlab getFullBlock() { - return (BlockSlab) ModFluffBlocks.prismarineSlabFull; - } - - @Override - public BlockSlab getSingleBlock() { - return (BlockSlab) ModFluffBlocks.prismarineSlab; - } - - @Override - public LexiconEntry getEntry(World world, int x, int y, int z, EntityPlayer player, ItemStack lexicon) { - return LexiconData.prismarine; - } + public BlockPrismarineSlab(boolean full) { + this(full, 0); + } + + public BlockPrismarineSlab(boolean full, int meta) { + super(full, ModBlocks.prismarine, meta); + setHardness(2.0F); + setResistance(10.0F); + setStepSound(soundTypeStone); + } + + @Override + public BlockSlab getFullBlock() { + return (BlockSlab) ModFluffBlocks.prismarineSlabFull; + } + + @Override + public BlockSlab getSingleBlock() { + return (BlockSlab) ModFluffBlocks.prismarineSlab; + } + + @Override + public LexiconEntry getEntry(World world, int x, int y, int z, EntityPlayer player, ItemStack lexicon) { + return LexiconData.prismarine; + } + } diff --git a/src/main/java/vazkii/botania/common/block/decor/stairs/Block18StoneStairs.java b/src/main/java/vazkii/botania/common/block/decor/stairs/Block18StoneStairs.java index 0e1bb4f60c..3873be4c17 100644 --- a/src/main/java/vazkii/botania/common/block/decor/stairs/Block18StoneStairs.java +++ b/src/main/java/vazkii/botania/common/block/decor/stairs/Block18StoneStairs.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Apr 10, 2015, 7:51:29 PM (GMT)] */ package vazkii.botania.common.block.decor.stairs; @@ -19,12 +19,13 @@ public class Block18StoneStairs extends BlockLivingStairs { - public Block18StoneStairs(int meta) { - super(ModFluffBlocks.stone, meta); - } + public Block18StoneStairs(int meta) { + super(ModFluffBlocks.stone, meta); + } + + @Override + public LexiconEntry getEntry(World world, int x, int y, int z, EntityPlayer player, ItemStack lexicon) { + return LexiconData.stoneAlchemy; + } - @Override - public LexiconEntry getEntry(World world, int x, int y, int z, EntityPlayer player, ItemStack lexicon) { - return LexiconData.stoneAlchemy; - } } diff --git a/src/main/java/vazkii/botania/common/block/decor/stairs/BlockBiomeStoneStairs.java b/src/main/java/vazkii/botania/common/block/decor/stairs/BlockBiomeStoneStairs.java index 2ef630cd25..20ff8e624e 100644 --- a/src/main/java/vazkii/botania/common/block/decor/stairs/BlockBiomeStoneStairs.java +++ b/src/main/java/vazkii/botania/common/block/decor/stairs/BlockBiomeStoneStairs.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jan 29, 2015, 10:39:38 PM (GMT)] */ package vazkii.botania.common.block.decor.stairs; @@ -19,12 +19,13 @@ public class BlockBiomeStoneStairs extends BlockLivingStairs { - public BlockBiomeStoneStairs(Block source, int meta) { - super(source, meta); - } + public BlockBiomeStoneStairs(Block source, int meta) { + super(source, meta); + } + + @Override + public LexiconEntry getEntry(World world, int x, int y, int z, EntityPlayer player, ItemStack lexicon) { + return LexiconData.marimorphosis; + } - @Override - public LexiconEntry getEntry(World world, int x, int y, int z, EntityPlayer player, ItemStack lexicon) { - return LexiconData.marimorphosis; - } } diff --git a/src/main/java/vazkii/botania/common/block/decor/stairs/BlockEndStoneStairs.java b/src/main/java/vazkii/botania/common/block/decor/stairs/BlockEndStoneStairs.java index f448932e14..a2da6e37b6 100644 --- a/src/main/java/vazkii/botania/common/block/decor/stairs/BlockEndStoneStairs.java +++ b/src/main/java/vazkii/botania/common/block/decor/stairs/BlockEndStoneStairs.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Feb 16, 2015, 8:44:03 PM (GMT)] */ package vazkii.botania.common.block.decor.stairs; @@ -19,12 +19,13 @@ public class BlockEndStoneStairs extends BlockLivingStairs { - public BlockEndStoneStairs() { - super(ModBlocks.endStoneBrick, 0); - } + public BlockEndStoneStairs() { + super(ModBlocks.endStoneBrick, 0); + } + + @Override + public LexiconEntry getEntry(World world, int x, int y, int z, EntityPlayer player, ItemStack lexicon) { + return LexiconData.endStoneDecor; + } - @Override - public LexiconEntry getEntry(World world, int x, int y, int z, EntityPlayer player, ItemStack lexicon) { - return LexiconData.endStoneDecor; - } } diff --git a/src/main/java/vazkii/botania/common/block/decor/stairs/BlockEnderBrickStairs.java b/src/main/java/vazkii/botania/common/block/decor/stairs/BlockEnderBrickStairs.java index e9812a1b32..fdd23147c1 100644 --- a/src/main/java/vazkii/botania/common/block/decor/stairs/BlockEnderBrickStairs.java +++ b/src/main/java/vazkii/botania/common/block/decor/stairs/BlockEnderBrickStairs.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jul 7, 2015, 10:38:15 PM (GMT)] */ package vazkii.botania.common.block.decor.stairs; @@ -19,12 +19,13 @@ public class BlockEnderBrickStairs extends BlockLivingStairs { - public BlockEnderBrickStairs() { - super(ModBlocks.endStoneBrick, 2); - } + public BlockEnderBrickStairs() { + super(ModBlocks.endStoneBrick, 2); + } + + @Override + public LexiconEntry getEntry(World world, int x, int y, int z, EntityPlayer player, ItemStack lexicon) { + return LexiconData.endStoneDecor; + } - @Override - public LexiconEntry getEntry(World world, int x, int y, int z, EntityPlayer player, ItemStack lexicon) { - return LexiconData.endStoneDecor; - } } diff --git a/src/main/java/vazkii/botania/common/block/decor/stairs/BlockLivingStairs.java b/src/main/java/vazkii/botania/common/block/decor/stairs/BlockLivingStairs.java index b30cd96644..2dba633b5f 100644 --- a/src/main/java/vazkii/botania/common/block/decor/stairs/BlockLivingStairs.java +++ b/src/main/java/vazkii/botania/common/block/decor/stairs/BlockLivingStairs.java @@ -4,7 +4,8 @@ public class BlockLivingStairs extends BlockModStairs { - public BlockLivingStairs(Block source, int meta) { - super(source, meta, source.getUnlocalizedName().replaceAll("tile.", "") + meta + "Stairs"); - } + public BlockLivingStairs(Block source, int meta) { + super(source, meta, source.getUnlocalizedName().replaceAll("tile.", "") + meta + "Stairs"); + } + } diff --git a/src/main/java/vazkii/botania/common/block/decor/stairs/BlockModStairs.java b/src/main/java/vazkii/botania/common/block/decor/stairs/BlockModStairs.java index a30a541318..82ad317d5f 100644 --- a/src/main/java/vazkii/botania/common/block/decor/stairs/BlockModStairs.java +++ b/src/main/java/vazkii/botania/common/block/decor/stairs/BlockModStairs.java @@ -1,6 +1,5 @@ package vazkii.botania.common.block.decor.stairs; -import cpw.mods.fml.common.registry.GameRegistry; import net.minecraft.block.Block; import net.minecraft.block.BlockStairs; import net.minecraft.entity.player.EntityPlayer; @@ -11,24 +10,26 @@ import vazkii.botania.common.core.BotaniaCreativeTab; import vazkii.botania.common.item.block.ItemBlockMod; import vazkii.botania.common.lexicon.LexiconData; +import cpw.mods.fml.common.registry.GameRegistry; public class BlockModStairs extends BlockStairs implements ILexiconable { - public BlockModStairs(Block source, int meta, String name) { - super(source, meta); - setBlockName(name); - setCreativeTab(BotaniaCreativeTab.INSTANCE); - useNeighborBrightness = true; - } + public BlockModStairs(Block source, int meta, String name) { + super(source, meta); + setBlockName(name); + setCreativeTab(BotaniaCreativeTab.INSTANCE); + useNeighborBrightness = true; + } + + @Override + public Block setBlockName(String par1Str) { + GameRegistry.registerBlock(this, ItemBlockMod.class, par1Str); + return super.setBlockName(par1Str); + } - @Override - public Block setBlockName(String par1Str) { - GameRegistry.registerBlock(this, ItemBlockMod.class, par1Str); - return super.setBlockName(par1Str); - } + @Override + public LexiconEntry getEntry(World world, int x, int y, int z, EntityPlayer player, ItemStack lexicon) { + return LexiconData.decorativeBlocks; + } - @Override - public LexiconEntry getEntry(World world, int x, int y, int z, EntityPlayer player, ItemStack lexicon) { - return LexiconData.decorativeBlocks; - } } diff --git a/src/main/java/vazkii/botania/common/block/decor/stairs/BlockPavementStairs.java b/src/main/java/vazkii/botania/common/block/decor/stairs/BlockPavementStairs.java index 26f7c443d4..fd96247177 100644 --- a/src/main/java/vazkii/botania/common/block/decor/stairs/BlockPavementStairs.java +++ b/src/main/java/vazkii/botania/common/block/decor/stairs/BlockPavementStairs.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Sep 1, 2015, 7:16:53 PM (GMT)] */ package vazkii.botania.common.block.decor.stairs; @@ -19,12 +19,13 @@ public class BlockPavementStairs extends BlockLivingStairs { - public BlockPavementStairs(int meta) { - super(ModFluffBlocks.pavement, meta); - } + public BlockPavementStairs(int meta) { + super(ModFluffBlocks.pavement, meta); + } + + @Override + public LexiconEntry getEntry(World world, int x, int y, int z, EntityPlayer player, ItemStack lexicon) { + return LexiconData.pavement; + } - @Override - public LexiconEntry getEntry(World world, int x, int y, int z, EntityPlayer player, ItemStack lexicon) { - return LexiconData.pavement; - } } diff --git a/src/main/java/vazkii/botania/common/block/decor/stairs/BlockReedStairs.java b/src/main/java/vazkii/botania/common/block/decor/stairs/BlockReedStairs.java index a13857f8c2..c2c0453076 100644 --- a/src/main/java/vazkii/botania/common/block/decor/stairs/BlockReedStairs.java +++ b/src/main/java/vazkii/botania/common/block/decor/stairs/BlockReedStairs.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jul 28, 2014, 8:47:52 PM (GMT)] */ package vazkii.botania.common.block.decor.stairs; @@ -19,12 +19,14 @@ public class BlockReedStairs extends BlockLivingStairs { - public BlockReedStairs() { - super(ModBlocks.reedBlock, 0); - } + public BlockReedStairs() { + super(ModBlocks.reedBlock, 0); + } + + @Override + public LexiconEntry getEntry(World world, int x, int y, int z, EntityPlayer player, ItemStack lexicon) { + return LexiconData.decorativeBlocks; + } + - @Override - public LexiconEntry getEntry(World world, int x, int y, int z, EntityPlayer player, ItemStack lexicon) { - return LexiconData.decorativeBlocks; - } } diff --git a/src/main/java/vazkii/botania/common/block/decor/stairs/BlockThatchStairs.java b/src/main/java/vazkii/botania/common/block/decor/stairs/BlockThatchStairs.java index c6ed76fb58..d55162c512 100644 --- a/src/main/java/vazkii/botania/common/block/decor/stairs/BlockThatchStairs.java +++ b/src/main/java/vazkii/botania/common/block/decor/stairs/BlockThatchStairs.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jul 28, 2014, 8:47:52 PM (GMT)] */ package vazkii.botania.common.block.decor.stairs; @@ -19,12 +19,14 @@ public class BlockThatchStairs extends BlockLivingStairs { - public BlockThatchStairs() { - super(ModBlocks.thatch, 0); - } + public BlockThatchStairs() { + super(ModBlocks.thatch, 0); + } + + @Override + public LexiconEntry getEntry(World world, int x, int y, int z, EntityPlayer player, ItemStack lexicon) { + return LexiconData.decorativeBlocks; + } + - @Override - public LexiconEntry getEntry(World world, int x, int y, int z, EntityPlayer player, ItemStack lexicon) { - return LexiconData.decorativeBlocks; - } } diff --git a/src/main/java/vazkii/botania/common/block/decor/stairs/bricks/BlockCustomBrickStairs.java b/src/main/java/vazkii/botania/common/block/decor/stairs/bricks/BlockCustomBrickStairs.java index 3563eb72b3..e49976d2aa 100644 --- a/src/main/java/vazkii/botania/common/block/decor/stairs/bricks/BlockCustomBrickStairs.java +++ b/src/main/java/vazkii/botania/common/block/decor/stairs/bricks/BlockCustomBrickStairs.java @@ -10,16 +10,17 @@ public class BlockCustomBrickStairs extends BlockLivingStairs { - public BlockCustomBrickStairs() { - this(0); - } + public BlockCustomBrickStairs() { + this(0); + } - public BlockCustomBrickStairs(int meta) { - super(ModBlocks.customBrick, meta); - } + public BlockCustomBrickStairs(int meta) { + super(ModBlocks.customBrick, meta); + } + + @Override + public LexiconEntry getEntry(World world, int x, int y, int z, EntityPlayer player, ItemStack lexicon) { + return LexiconData.decorativeBlocks; + } - @Override - public LexiconEntry getEntry(World world, int x, int y, int z, EntityPlayer player, ItemStack lexicon) { - return LexiconData.decorativeBlocks; - } } diff --git a/src/main/java/vazkii/botania/common/block/decor/stairs/bricks/BlockSnowBrickStairs.java b/src/main/java/vazkii/botania/common/block/decor/stairs/bricks/BlockSnowBrickStairs.java index baf8013af6..de545e4c74 100644 --- a/src/main/java/vazkii/botania/common/block/decor/stairs/bricks/BlockSnowBrickStairs.java +++ b/src/main/java/vazkii/botania/common/block/decor/stairs/bricks/BlockSnowBrickStairs.java @@ -2,17 +2,18 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jul 28, 2014, 11:28:47 PM (GMT)] */ package vazkii.botania.common.block.decor.stairs.bricks; public class BlockSnowBrickStairs extends BlockCustomBrickStairs { - public BlockSnowBrickStairs() { - super(2); - } + public BlockSnowBrickStairs() { + super(2); + } + } diff --git a/src/main/java/vazkii/botania/common/block/decor/stairs/bricks/BlockSoulBrickStairs.java b/src/main/java/vazkii/botania/common/block/decor/stairs/bricks/BlockSoulBrickStairs.java index 30425e7323..7d031030be 100644 --- a/src/main/java/vazkii/botania/common/block/decor/stairs/bricks/BlockSoulBrickStairs.java +++ b/src/main/java/vazkii/botania/common/block/decor/stairs/bricks/BlockSoulBrickStairs.java @@ -2,17 +2,18 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jul 28, 2014, 10:10:00 PM (GMT)] */ package vazkii.botania.common.block.decor.stairs.bricks; public class BlockSoulBrickStairs extends BlockCustomBrickStairs { - public BlockSoulBrickStairs() { - super(1); - } + public BlockSoulBrickStairs() { + super(1); + } + } diff --git a/src/main/java/vazkii/botania/common/block/decor/stairs/bricks/BlockTileStairs.java b/src/main/java/vazkii/botania/common/block/decor/stairs/bricks/BlockTileStairs.java index d559238f8d..943fe3b393 100644 --- a/src/main/java/vazkii/botania/common/block/decor/stairs/bricks/BlockTileStairs.java +++ b/src/main/java/vazkii/botania/common/block/decor/stairs/bricks/BlockTileStairs.java @@ -2,17 +2,18 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jul 28, 2014, 10:10:00 PM (GMT)] */ package vazkii.botania.common.block.decor.stairs.bricks; public class BlockTileStairs extends BlockCustomBrickStairs { - public BlockTileStairs() { - super(3); - } + public BlockTileStairs() { + super(3); + } + } diff --git a/src/main/java/vazkii/botania/common/block/decor/stairs/living/BlockDreamwoodPlankStairs.java b/src/main/java/vazkii/botania/common/block/decor/stairs/living/BlockDreamwoodPlankStairs.java index ed5cfa6cac..bba59293c0 100644 --- a/src/main/java/vazkii/botania/common/block/decor/stairs/living/BlockDreamwoodPlankStairs.java +++ b/src/main/java/vazkii/botania/common/block/decor/stairs/living/BlockDreamwoodPlankStairs.java @@ -5,7 +5,8 @@ public class BlockDreamwoodPlankStairs extends BlockLivingStairs { - public BlockDreamwoodPlankStairs() { - super(ModBlocks.dreamwood, 1); - } + public BlockDreamwoodPlankStairs() { + super(ModBlocks.dreamwood, 1); + } + } diff --git a/src/main/java/vazkii/botania/common/block/decor/stairs/living/BlockDreamwoodStairs.java b/src/main/java/vazkii/botania/common/block/decor/stairs/living/BlockDreamwoodStairs.java index 96d4b2a1f2..7d87c4a0a7 100644 --- a/src/main/java/vazkii/botania/common/block/decor/stairs/living/BlockDreamwoodStairs.java +++ b/src/main/java/vazkii/botania/common/block/decor/stairs/living/BlockDreamwoodStairs.java @@ -5,7 +5,8 @@ public class BlockDreamwoodStairs extends BlockLivingStairs { - public BlockDreamwoodStairs() { - super(ModBlocks.dreamwood, 0); - } + public BlockDreamwoodStairs() { + super(ModBlocks.dreamwood, 0); + } + } diff --git a/src/main/java/vazkii/botania/common/block/decor/stairs/living/BlockLivingrockBrickStairs.java b/src/main/java/vazkii/botania/common/block/decor/stairs/living/BlockLivingrockBrickStairs.java index 8117fc359e..08618fc798 100644 --- a/src/main/java/vazkii/botania/common/block/decor/stairs/living/BlockLivingrockBrickStairs.java +++ b/src/main/java/vazkii/botania/common/block/decor/stairs/living/BlockLivingrockBrickStairs.java @@ -5,7 +5,8 @@ public class BlockLivingrockBrickStairs extends BlockLivingStairs { - public BlockLivingrockBrickStairs() { - super(ModBlocks.livingrock, 1); - } + public BlockLivingrockBrickStairs() { + super(ModBlocks.livingrock, 1); + } + } diff --git a/src/main/java/vazkii/botania/common/block/decor/stairs/living/BlockLivingrockStairs.java b/src/main/java/vazkii/botania/common/block/decor/stairs/living/BlockLivingrockStairs.java index 844bfec5ec..a974af4e8e 100644 --- a/src/main/java/vazkii/botania/common/block/decor/stairs/living/BlockLivingrockStairs.java +++ b/src/main/java/vazkii/botania/common/block/decor/stairs/living/BlockLivingrockStairs.java @@ -5,7 +5,8 @@ public class BlockLivingrockStairs extends BlockLivingStairs { - public BlockLivingrockStairs() { - super(ModBlocks.livingrock, 0); - } + public BlockLivingrockStairs() { + super(ModBlocks.livingrock, 0); + } + } diff --git a/src/main/java/vazkii/botania/common/block/decor/stairs/living/BlockLivingwoodPlankStairs.java b/src/main/java/vazkii/botania/common/block/decor/stairs/living/BlockLivingwoodPlankStairs.java index d799371231..9ffc1a3159 100644 --- a/src/main/java/vazkii/botania/common/block/decor/stairs/living/BlockLivingwoodPlankStairs.java +++ b/src/main/java/vazkii/botania/common/block/decor/stairs/living/BlockLivingwoodPlankStairs.java @@ -5,7 +5,8 @@ public class BlockLivingwoodPlankStairs extends BlockLivingStairs { - public BlockLivingwoodPlankStairs() { - super(ModBlocks.livingwood, 1); - } + public BlockLivingwoodPlankStairs() { + super(ModBlocks.livingwood, 1); + } + } diff --git a/src/main/java/vazkii/botania/common/block/decor/stairs/living/BlockLivingwoodStairs.java b/src/main/java/vazkii/botania/common/block/decor/stairs/living/BlockLivingwoodStairs.java index 5b54b6a7c8..d1dec721f6 100644 --- a/src/main/java/vazkii/botania/common/block/decor/stairs/living/BlockLivingwoodStairs.java +++ b/src/main/java/vazkii/botania/common/block/decor/stairs/living/BlockLivingwoodStairs.java @@ -5,7 +5,8 @@ public class BlockLivingwoodStairs extends BlockLivingStairs { - public BlockLivingwoodStairs() { - super(ModBlocks.livingwood, 0); - } + public BlockLivingwoodStairs() { + super(ModBlocks.livingwood, 0); + } + } diff --git a/src/main/java/vazkii/botania/common/block/decor/stairs/living/BlockShimmerrockStairs.java b/src/main/java/vazkii/botania/common/block/decor/stairs/living/BlockShimmerrockStairs.java index 2250590917..34e6cfe2a7 100644 --- a/src/main/java/vazkii/botania/common/block/decor/stairs/living/BlockShimmerrockStairs.java +++ b/src/main/java/vazkii/botania/common/block/decor/stairs/living/BlockShimmerrockStairs.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Oct 11, 2015, 3:46:12 PM (GMT)] */ package vazkii.botania.common.block.decor.stairs.living; @@ -15,7 +15,8 @@ public class BlockShimmerrockStairs extends BlockLivingStairs { - public BlockShimmerrockStairs() { - super(ModBlocks.shimmerrock, 0); - } + public BlockShimmerrockStairs() { + super(ModBlocks.shimmerrock, 0); + } + } diff --git a/src/main/java/vazkii/botania/common/block/decor/stairs/living/BlockShimmerwoodPlankStairs.java b/src/main/java/vazkii/botania/common/block/decor/stairs/living/BlockShimmerwoodPlankStairs.java index 05b5065a2c..5714756e16 100644 --- a/src/main/java/vazkii/botania/common/block/decor/stairs/living/BlockShimmerwoodPlankStairs.java +++ b/src/main/java/vazkii/botania/common/block/decor/stairs/living/BlockShimmerwoodPlankStairs.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Oct 11, 2015, 3:45:02 PM (GMT)] */ package vazkii.botania.common.block.decor.stairs.living; @@ -15,7 +15,8 @@ public class BlockShimmerwoodPlankStairs extends BlockLivingStairs { - public BlockShimmerwoodPlankStairs() { - super(ModBlocks.shimmerwoodPlanks, 0); - } + public BlockShimmerwoodPlankStairs() { + super(ModBlocks.shimmerwoodPlanks, 0); + } + } diff --git a/src/main/java/vazkii/botania/common/block/decor/stairs/prismarine/BlockDarkPrismarineStairs.java b/src/main/java/vazkii/botania/common/block/decor/stairs/prismarine/BlockDarkPrismarineStairs.java index 965fa631de..2d3c999633 100644 --- a/src/main/java/vazkii/botania/common/block/decor/stairs/prismarine/BlockDarkPrismarineStairs.java +++ b/src/main/java/vazkii/botania/common/block/decor/stairs/prismarine/BlockDarkPrismarineStairs.java @@ -1,8 +1,10 @@ package vazkii.botania.common.block.decor.stairs.prismarine; + public class BlockDarkPrismarineStairs extends BlockPrismarineStairs { - public BlockDarkPrismarineStairs() { - super(2); - } + public BlockDarkPrismarineStairs() { + super(2); + } + } diff --git a/src/main/java/vazkii/botania/common/block/decor/stairs/prismarine/BlockPrismarineBrickStairs.java b/src/main/java/vazkii/botania/common/block/decor/stairs/prismarine/BlockPrismarineBrickStairs.java index c49aee6f44..f3d015e469 100644 --- a/src/main/java/vazkii/botania/common/block/decor/stairs/prismarine/BlockPrismarineBrickStairs.java +++ b/src/main/java/vazkii/botania/common/block/decor/stairs/prismarine/BlockPrismarineBrickStairs.java @@ -1,8 +1,10 @@ package vazkii.botania.common.block.decor.stairs.prismarine; + public class BlockPrismarineBrickStairs extends BlockPrismarineStairs { - public BlockPrismarineBrickStairs() { - super(1); - } + public BlockPrismarineBrickStairs() { + super(1); + } + } diff --git a/src/main/java/vazkii/botania/common/block/decor/stairs/prismarine/BlockPrismarineStairs.java b/src/main/java/vazkii/botania/common/block/decor/stairs/prismarine/BlockPrismarineStairs.java index e6fc1262b5..3a823ffd3b 100644 --- a/src/main/java/vazkii/botania/common/block/decor/stairs/prismarine/BlockPrismarineStairs.java +++ b/src/main/java/vazkii/botania/common/block/decor/stairs/prismarine/BlockPrismarineStairs.java @@ -10,16 +10,17 @@ public class BlockPrismarineStairs extends BlockLivingStairs { - public BlockPrismarineStairs() { - this(0); - } + public BlockPrismarineStairs() { + this(0); + } - public BlockPrismarineStairs(int meta) { - super(ModBlocks.prismarine, meta); - } + public BlockPrismarineStairs(int meta) { + super(ModBlocks.prismarine, meta); + } + + @Override + public LexiconEntry getEntry(World world, int x, int y, int z, EntityPlayer player, ItemStack lexicon) { + return LexiconData.prismarine; + } - @Override - public LexiconEntry getEntry(World world, int x, int y, int z, EntityPlayer player, ItemStack lexicon) { - return LexiconData.prismarine; - } } diff --git a/src/main/java/vazkii/botania/common/block/decor/walls/Block18StoneWall.java b/src/main/java/vazkii/botania/common/block/decor/walls/Block18StoneWall.java index 27f03e7cac..64b30f6956 100644 --- a/src/main/java/vazkii/botania/common/block/decor/walls/Block18StoneWall.java +++ b/src/main/java/vazkii/botania/common/block/decor/walls/Block18StoneWall.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jul 18, 2015, 8:41:10 PM (GMT)] */ package vazkii.botania.common.block.decor.walls; @@ -19,14 +19,15 @@ public class Block18StoneWall extends BlockVariantWall { - public Block18StoneWall() { - super(ModFluffBlocks.stone, 4); - setHardness(1.5F); - setResistance(10F); - } + public Block18StoneWall() { + super(ModFluffBlocks.stone, 4); + setHardness(1.5F); + setResistance(10F); + } + + @Override + public LexiconEntry getEntry(World world, int x, int y, int z, EntityPlayer player, ItemStack lexicon) { + return LexiconData.stoneAlchemy; + } - @Override - public LexiconEntry getEntry(World world, int x, int y, int z, EntityPlayer player, ItemStack lexicon) { - return LexiconData.stoneAlchemy; - } } diff --git a/src/main/java/vazkii/botania/common/block/decor/walls/BlockBiomeStoneWall.java b/src/main/java/vazkii/botania/common/block/decor/walls/BlockBiomeStoneWall.java index 50b868f778..3f8a3e037d 100644 --- a/src/main/java/vazkii/botania/common/block/decor/walls/BlockBiomeStoneWall.java +++ b/src/main/java/vazkii/botania/common/block/decor/walls/BlockBiomeStoneWall.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jul 18, 2015, 8:31:47 PM (GMT)] */ package vazkii.botania.common.block.decor.walls; @@ -19,14 +19,15 @@ public class BlockBiomeStoneWall extends BlockVariantWall { - public BlockBiomeStoneWall() { - super(ModFluffBlocks.biomeStoneA, 8, 8); - setHardness(1.5F); - setResistance(10F); - } + public BlockBiomeStoneWall() { + super(ModFluffBlocks.biomeStoneA, 8, 8); + setHardness(1.5F); + setResistance(10F); + } + + @Override + public LexiconEntry getEntry(World world, int x, int y, int z, EntityPlayer player, ItemStack lexicon) { + return LexiconData.marimorphosis; + } - @Override - public LexiconEntry getEntry(World world, int x, int y, int z, EntityPlayer player, ItemStack lexicon) { - return LexiconData.marimorphosis; - } } diff --git a/src/main/java/vazkii/botania/common/block/decor/walls/BlockModWall.java b/src/main/java/vazkii/botania/common/block/decor/walls/BlockModWall.java index 7d24cd800f..b0a3863b7a 100644 --- a/src/main/java/vazkii/botania/common/block/decor/walls/BlockModWall.java +++ b/src/main/java/vazkii/botania/common/block/decor/walls/BlockModWall.java @@ -2,16 +2,16 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jul 18, 2015, 8:15:36 PM (GMT)] */ package vazkii.botania.common.block.decor.walls; -import cpw.mods.fml.common.registry.GameRegistry; import java.util.List; + import net.minecraft.block.Block; import net.minecraft.block.BlockWall; import net.minecraft.client.renderer.texture.IIconRegister; @@ -25,51 +25,53 @@ import vazkii.botania.api.lexicon.LexiconEntry; import vazkii.botania.common.item.block.ItemBlockMod; import vazkii.botania.common.lexicon.LexiconData; +import cpw.mods.fml.common.registry.GameRegistry; public class BlockModWall extends BlockWall implements ILexiconable { - Block block; - int meta; + Block block; + int meta; + + public BlockModWall(Block block, int meta) { + super(block); + this.block = block; + this.meta = meta; + setBlockName(block.getUnlocalizedName().replaceAll("tile.", "") + meta + "Wall"); + } - public BlockModWall(Block block, int meta) { - super(block); - this.block = block; - this.meta = meta; - setBlockName(block.getUnlocalizedName().replaceAll("tile.", "") + meta + "Wall"); - } + @Override + public boolean canPlaceTorchOnTop(World world, int x, int y, int z) { + return true; + } - @Override - public boolean canPlaceTorchOnTop(World world, int x, int y, int z) { - return true; - } + @Override + public Block setBlockName(String par1Str) { + register(par1Str); + return super.setBlockName(par1Str); + } - @Override - public Block setBlockName(String par1Str) { - register(par1Str); - return super.setBlockName(par1Str); - } + public void register(String name) { + GameRegistry.registerBlock(this, ItemBlockMod.class, name); + } - public void register(String name) { - GameRegistry.registerBlock(this, ItemBlockMod.class, name); - } + @Override + public void getSubBlocks(Item item, CreativeTabs tabs, List list) { + list.add(new ItemStack(item)); + } - @Override - public void getSubBlocks(Item item, CreativeTabs tabs, List list) { - list.add(new ItemStack(item)); - } + @Override + public IIcon getIcon(int side, int meta) { + return block.getIcon(side, this.meta); + } - @Override - public IIcon getIcon(int side, int meta) { - return block.getIcon(side, this.meta); - } + @Override + public LexiconEntry getEntry(World world, int x, int y, int z, EntityPlayer player, ItemStack lexicon) { + return LexiconData.decorativeBlocks; + } - @Override - public LexiconEntry getEntry(World world, int x, int y, int z, EntityPlayer player, ItemStack lexicon) { - return LexiconData.decorativeBlocks; - } + @Override + public void registerBlockIcons(IIconRegister p_149651_1_) { + // NO-OP + } - @Override - public void registerBlockIcons(IIconRegister p_149651_1_) { - // NO-OP - } } diff --git a/src/main/java/vazkii/botania/common/block/decor/walls/BlockPrismarineWall.java b/src/main/java/vazkii/botania/common/block/decor/walls/BlockPrismarineWall.java index b47b2d0ad8..0c0029950f 100644 --- a/src/main/java/vazkii/botania/common/block/decor/walls/BlockPrismarineWall.java +++ b/src/main/java/vazkii/botania/common/block/decor/walls/BlockPrismarineWall.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jul 18, 2015, 8:30:00 PM (GMT)] */ package vazkii.botania.common.block.decor.walls; @@ -19,15 +19,16 @@ public class BlockPrismarineWall extends BlockModWall { - public BlockPrismarineWall() { - super(ModBlocks.prismarine, 0); - setHardness(2.0F); - setResistance(10.0F); - setStepSound(soundTypeStone); - } + public BlockPrismarineWall() { + super(ModBlocks.prismarine, 0); + setHardness(2.0F); + setResistance(10.0F); + setStepSound(soundTypeStone); + } + + @Override + public LexiconEntry getEntry(World world, int x, int y, int z, EntityPlayer player, ItemStack lexicon) { + return LexiconData.prismarine; + } - @Override - public LexiconEntry getEntry(World world, int x, int y, int z, EntityPlayer player, ItemStack lexicon) { - return LexiconData.prismarine; - } } diff --git a/src/main/java/vazkii/botania/common/block/decor/walls/BlockReedWall.java b/src/main/java/vazkii/botania/common/block/decor/walls/BlockReedWall.java index 37482c5d57..508389fd86 100644 --- a/src/main/java/vazkii/botania/common/block/decor/walls/BlockReedWall.java +++ b/src/main/java/vazkii/botania/common/block/decor/walls/BlockReedWall.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jul 18, 2015, 8:31:04 PM (GMT)] */ package vazkii.botania.common.block.decor.walls; @@ -14,9 +14,10 @@ public class BlockReedWall extends BlockModWall { - public BlockReedWall() { - super(ModBlocks.reedBlock, 0); - setHardness(1.0F); - setStepSound(soundTypeWood); - } + public BlockReedWall() { + super(ModBlocks.reedBlock, 0); + setHardness(1.0F); + setStepSound(soundTypeWood); + } + } diff --git a/src/main/java/vazkii/botania/common/block/decor/walls/BlockVariantWall.java b/src/main/java/vazkii/botania/common/block/decor/walls/BlockVariantWall.java index 644920105e..4c457bb441 100644 --- a/src/main/java/vazkii/botania/common/block/decor/walls/BlockVariantWall.java +++ b/src/main/java/vazkii/botania/common/block/decor/walls/BlockVariantWall.java @@ -2,50 +2,54 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jul 18, 2015, 8:42:16 PM (GMT)] */ package vazkii.botania.common.block.decor.walls; -import cpw.mods.fml.common.registry.GameRegistry; import java.util.List; + import net.minecraft.block.Block; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.util.IIcon; import vazkii.botania.common.item.block.ItemBlockWithMetadataAndName; +import cpw.mods.fml.common.registry.GameRegistry; public class BlockVariantWall extends BlockModWall { - int metaStates; - int metaShift; - - public BlockVariantWall(Block block, int metaStates, int metaShift) { - super(block, 0); - this.metaStates = metaStates; - this.metaShift = metaShift; - } - - public BlockVariantWall(Block block, int metaStates) { - this(block, metaStates, 0); - } - - @Override - public void register(String name) { - GameRegistry.registerBlock(this, ItemBlockWithMetadataAndName.class, name); - } - - @Override - public void getSubBlocks(Item item, CreativeTabs tabs, List list) { - for (int i = 0; i < metaStates; i++) list.add(new ItemStack(item, 1, i)); - } - - @Override - public IIcon getIcon(int side, int meta) { - return block.getIcon(side, meta + metaShift); - } + int metaStates; + int metaShift; + + public BlockVariantWall(Block block, int metaStates, int metaShift) { + super(block, 0); + this.metaStates = metaStates; + this.metaShift = metaShift; + } + + public BlockVariantWall(Block block, int metaStates) { + this(block, metaStates, 0); + } + + @Override + public void register(String name) { + GameRegistry.registerBlock(this, ItemBlockWithMetadataAndName.class, name); + } + + @Override + public void getSubBlocks(Item item, CreativeTabs tabs, List list) { + for(int i = 0; i < metaStates; i++) + list.add(new ItemStack(item, 1, i)); + } + + @Override + public IIcon getIcon(int side, int meta) { + return block.getIcon(side, meta + metaShift); + } + + } diff --git a/src/main/java/vazkii/botania/common/block/decor/walls/living/BlockDreamwoodWall.java b/src/main/java/vazkii/botania/common/block/decor/walls/living/BlockDreamwoodWall.java index c420536f8e..6006e41a37 100644 --- a/src/main/java/vazkii/botania/common/block/decor/walls/living/BlockDreamwoodWall.java +++ b/src/main/java/vazkii/botania/common/block/decor/walls/living/BlockDreamwoodWall.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jul 18, 2015, 8:29:16 PM (GMT)] */ package vazkii.botania.common.block.decor.walls.living; @@ -15,9 +15,10 @@ public class BlockDreamwoodWall extends BlockModWall { - public BlockDreamwoodWall() { - super(ModBlocks.dreamwood, 0); - setHardness(2.0F); - setStepSound(soundTypeWood); - } + public BlockDreamwoodWall() { + super(ModBlocks.dreamwood, 0); + setHardness(2.0F); + setStepSound(soundTypeWood); + } + } diff --git a/src/main/java/vazkii/botania/common/block/decor/walls/living/BlockLivingrockWall.java b/src/main/java/vazkii/botania/common/block/decor/walls/living/BlockLivingrockWall.java index 41a4aaee84..603eebc83d 100644 --- a/src/main/java/vazkii/botania/common/block/decor/walls/living/BlockLivingrockWall.java +++ b/src/main/java/vazkii/botania/common/block/decor/walls/living/BlockLivingrockWall.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jul 18, 2015, 8:25:54 PM (GMT)] */ package vazkii.botania.common.block.decor.walls.living; @@ -15,10 +15,11 @@ public class BlockLivingrockWall extends BlockModWall { - public BlockLivingrockWall() { - super(ModBlocks.livingrock, 0); - setHardness(2.0F); - setResistance(10.0F); - setStepSound(soundTypeStone); - } + public BlockLivingrockWall() { + super(ModBlocks.livingrock, 0); + setHardness(2.0F); + setResistance(10.0F); + setStepSound(soundTypeStone); + } + } diff --git a/src/main/java/vazkii/botania/common/block/decor/walls/living/BlockLivingwoodWall.java b/src/main/java/vazkii/botania/common/block/decor/walls/living/BlockLivingwoodWall.java index 86149c5c6f..b958d4ff7c 100644 --- a/src/main/java/vazkii/botania/common/block/decor/walls/living/BlockLivingwoodWall.java +++ b/src/main/java/vazkii/botania/common/block/decor/walls/living/BlockLivingwoodWall.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jul 18, 2015, 8:28:06 PM (GMT)] */ package vazkii.botania.common.block.decor.walls.living; @@ -15,9 +15,10 @@ public class BlockLivingwoodWall extends BlockModWall { - public BlockLivingwoodWall() { - super(ModBlocks.livingwood, 0); - setHardness(2.0F); - setStepSound(soundTypeWood); - } + public BlockLivingwoodWall() { + super(ModBlocks.livingwood, 0); + setHardness(2.0F); + setStepSound(soundTypeWood); + } + } diff --git a/src/main/java/vazkii/botania/common/block/dispenser/BehaviourPoolMinecart.java b/src/main/java/vazkii/botania/common/block/dispenser/BehaviourPoolMinecart.java index e510e45b63..5639c93863 100644 --- a/src/main/java/vazkii/botania/common/block/dispenser/BehaviourPoolMinecart.java +++ b/src/main/java/vazkii/botania/common/block/dispenser/BehaviourPoolMinecart.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Mar 18, 2015, 12:22:58 AM (GMT)] */ package vazkii.botania.common.block.dispenser; @@ -24,38 +24,41 @@ public class BehaviourPoolMinecart extends BehaviorDefaultDispenseItem { - @Override - public ItemStack dispenseStack(IBlockSource p_82487_1_, ItemStack p_82487_2_) { - EnumFacing enumfacing = BlockDispenser.func_149937_b(p_82487_1_.getBlockMetadata()); - World world = p_82487_1_.getWorld(); - double d0 = p_82487_1_.getX() + enumfacing.getFrontOffsetX() * 1.125F; - double d1 = p_82487_1_.getY() + enumfacing.getFrontOffsetY() * 1.125F; - double d2 = p_82487_1_.getZ() + enumfacing.getFrontOffsetZ() * 1.125F; - int i = p_82487_1_.getXInt() + enumfacing.getFrontOffsetX(); - int j = p_82487_1_.getYInt() + enumfacing.getFrontOffsetY(); - int k = p_82487_1_.getZInt() + enumfacing.getFrontOffsetZ(); - Block block = world.getBlock(i, j, k); - double d3; - - if (BlockRailBase.func_150051_a(block)) d3 = 0.0D; - else { - if (block.getMaterial() != Material.air || !BlockRailBase.func_150051_a(world.getBlock(i, j - 1, k))) - return super.dispenseStack(p_82487_1_, p_82487_2_); - - d3 = -1.0D; - } - - EntityMinecart entityminecart = new EntityPoolMinecart(world, d0, d1 + d3, d2); - - if (p_82487_2_.hasDisplayName()) entityminecart.setMinecartName(p_82487_2_.getDisplayName()); - - world.spawnEntityInWorld(entityminecart); - p_82487_2_.splitStack(1); - return p_82487_2_; - } - - @Override - protected void playDispenseSound(IBlockSource p_82485_1_) { - p_82485_1_.getWorld().playAuxSFX(1000, p_82485_1_.getXInt(), p_82485_1_.getYInt(), p_82485_1_.getZInt(), 0); - } + @Override + public ItemStack dispenseStack(IBlockSource p_82487_1_, ItemStack p_82487_2_) { + EnumFacing enumfacing = BlockDispenser.func_149937_b(p_82487_1_.getBlockMetadata()); + World world = p_82487_1_.getWorld(); + double d0 = p_82487_1_.getX() + enumfacing.getFrontOffsetX() * 1.125F; + double d1 = p_82487_1_.getY() + enumfacing.getFrontOffsetY() * 1.125F; + double d2 = p_82487_1_.getZ() + enumfacing.getFrontOffsetZ() * 1.125F; + int i = p_82487_1_.getXInt() + enumfacing.getFrontOffsetX(); + int j = p_82487_1_.getYInt() + enumfacing.getFrontOffsetY(); + int k = p_82487_1_.getZInt() + enumfacing.getFrontOffsetZ(); + Block block = world.getBlock(i, j, k); + double d3; + + if(BlockRailBase.func_150051_a(block)) + d3 = 0.0D; + else { + if(block.getMaterial() != Material.air || !BlockRailBase.func_150051_a(world.getBlock(i, j - 1, k))) + return super.dispenseStack(p_82487_1_, p_82487_2_); + + d3 = -1.0D; + } + + EntityMinecart entityminecart = new EntityPoolMinecart(world, d0, d1 + d3, d2); + + if(p_82487_2_.hasDisplayName()) + entityminecart.setMinecartName(p_82487_2_.getDisplayName()); + + world.spawnEntityInWorld(entityminecart); + p_82487_2_.splitStack(1); + return p_82487_2_; + } + + @Override + protected void playDispenseSound(IBlockSource p_82485_1_) { + p_82485_1_.getWorld().playAuxSFX(1000, p_82485_1_.getXInt(), p_82485_1_.getYInt(), p_82485_1_.getZInt(), 0); + } + } diff --git a/src/main/java/vazkii/botania/common/block/dispenser/BehaviourSeeds.java b/src/main/java/vazkii/botania/common/block/dispenser/BehaviourSeeds.java index 0d11c56d07..bd679c72ba 100644 --- a/src/main/java/vazkii/botania/common/block/dispenser/BehaviourSeeds.java +++ b/src/main/java/vazkii/botania/common/block/dispenser/BehaviourSeeds.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [May 16, 2014, 10:36:05 PM (GMT)] */ package vazkii.botania.common.block.dispenser; @@ -20,26 +20,27 @@ public class BehaviourSeeds extends BehaviorDefaultDispenseItem { - Block block; + Block block; - public BehaviourSeeds(Block block) { - this.block = block; - } + public BehaviourSeeds(Block block) { + this.block = block; + } - @Override - public ItemStack dispenseStack(IBlockSource par1IBlockSource, ItemStack par2ItemStack) { - EnumFacing facing = BlockDispenser.func_149937_b(par1IBlockSource.getBlockMetadata()); - int x = par1IBlockSource.getXInt() + facing.getFrontOffsetX(); - int y = par1IBlockSource.getYInt() + facing.getFrontOffsetY(); - int z = par1IBlockSource.getZInt() + facing.getFrontOffsetZ(); - World world = par1IBlockSource.getWorld(); + @Override + public ItemStack dispenseStack(IBlockSource par1IBlockSource, ItemStack par2ItemStack) { + EnumFacing facing = BlockDispenser.func_149937_b(par1IBlockSource.getBlockMetadata()); + int x = par1IBlockSource.getXInt() + facing.getFrontOffsetX(); + int y = par1IBlockSource.getYInt() + facing.getFrontOffsetY(); + int z = par1IBlockSource.getZInt() + facing.getFrontOffsetZ(); + World world = par1IBlockSource.getWorld(); - if (world.getBlock(x, y, z).isAir(world, x, y, z) && block.canBlockStay(world, x, y, z)) { - world.setBlock(x, y, z, block); - par2ItemStack.stackSize--; - return par2ItemStack; - } + if(world.getBlock(x, y, z).isAir(world, x, y, z) && block.canBlockStay(world, x, y, z)) { + world.setBlock(x, y, z, block); + par2ItemStack.stackSize--; + return par2ItemStack; + } + + return super.dispenseStack(par1IBlockSource, par2ItemStack); + } - return super.dispenseStack(par1IBlockSource, par2ItemStack); - } } diff --git a/src/main/java/vazkii/botania/common/block/dispenser/BehaviourWand.java b/src/main/java/vazkii/botania/common/block/dispenser/BehaviourWand.java index 9ab63ab9c4..b50b971f7f 100644 --- a/src/main/java/vazkii/botania/common/block/dispenser/BehaviourWand.java +++ b/src/main/java/vazkii/botania/common/block/dispenser/BehaviourWand.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [May 16, 2014, 11:11:31 PM (GMT)] */ package vazkii.botania.common.block.dispenser; @@ -21,29 +21,20 @@ public class BehaviourWand extends BehaviorDefaultDispenseItem { - @Override - protected ItemStack dispenseStack(IBlockSource par1IBlockSource, ItemStack par2ItemStack) { - ForgeDirection facing = - ForgeDirection.getOrientation(BlockDispenser.func_149937_b(par1IBlockSource.getBlockMetadata()) - .ordinal()); - int x = par1IBlockSource.getXInt() + facing.offsetX; - int y = par1IBlockSource.getYInt() + facing.offsetY; - int z = par1IBlockSource.getZInt() + facing.offsetZ; - World world = par1IBlockSource.getWorld(); - Block block = world.getBlock(x, y, z); - if (block instanceof IWandable) { - ((IWandable) block) - .onUsedByWand( - null, - par2ItemStack, - world, - x, - y, - z, - facing.getOpposite().ordinal()); - return par2ItemStack; - } + @Override + protected ItemStack dispenseStack(IBlockSource par1IBlockSource, ItemStack par2ItemStack) { + ForgeDirection facing = ForgeDirection.getOrientation(BlockDispenser.func_149937_b(par1IBlockSource.getBlockMetadata()).ordinal()); + int x = par1IBlockSource.getXInt() + facing.offsetX; + int y = par1IBlockSource.getYInt() + facing.offsetY; + int z = par1IBlockSource.getZInt() + facing.offsetZ; + World world = par1IBlockSource.getWorld(); + Block block = world.getBlock(x, y, z); + if(block instanceof IWandable) { + ((IWandable) block).onUsedByWand(null, par2ItemStack, world, x, y, z, facing.getOpposite().ordinal()); + return par2ItemStack; + } + + return super.dispenseStack(par1IBlockSource, par2ItemStack); + } - return super.dispenseStack(par1IBlockSource, par2ItemStack); - } } diff --git a/src/main/java/vazkii/botania/common/block/mana/BlockAlchemyCatalyst.java b/src/main/java/vazkii/botania/common/block/mana/BlockAlchemyCatalyst.java index 72d7aeb1c1..0c60b16357 100644 --- a/src/main/java/vazkii/botania/common/block/mana/BlockAlchemyCatalyst.java +++ b/src/main/java/vazkii/botania/common/block/mana/BlockAlchemyCatalyst.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [May 2, 2014, 7:18:49 PM (GMT)] */ package vazkii.botania.common.block.mana; @@ -27,38 +27,40 @@ public class BlockAlchemyCatalyst extends BlockMod implements ILexiconable, IPoolOverlayProvider { - IIcon[] icons; + IIcon[] icons; - public BlockAlchemyCatalyst() { - this(LibBlockNames.ALCHEMY_CATALYST); - } + public BlockAlchemyCatalyst() { + this(LibBlockNames.ALCHEMY_CATALYST); + } - public BlockAlchemyCatalyst(String name) { - super(Material.rock); - setHardness(2.0F); - setResistance(10.0F); - setStepSound(Block.soundTypeStone); - setBlockName(name); - } + public BlockAlchemyCatalyst(String name) { + super(Material.rock); + setHardness(2.0F); + setResistance(10.0F); + setStepSound(Block.soundTypeStone); + setBlockName(name); + } - @Override - public void registerBlockIcons(IIconRegister par1IconRegister) { - icons = new IIcon[4]; - for (int i = 0; i < icons.length; i++) icons[i] = IconHelper.forBlock(par1IconRegister, this, i); - } + @Override + public void registerBlockIcons(IIconRegister par1IconRegister) { + icons = new IIcon[4]; + for(int i = 0; i < icons.length; i++) + icons[i] = IconHelper.forBlock(par1IconRegister, this, i); + } - @Override - public IIcon getIcon(int par1, int par2) { - return icons[Math.min(2, par1)]; - } + @Override + public IIcon getIcon(int par1, int par2) { + return icons[Math.min(2, par1)]; + } - @Override - public LexiconEntry getEntry(World world, int x, int y, int z, EntityPlayer player, ItemStack lexicon) { - return LexiconData.alchemy; - } + @Override + public LexiconEntry getEntry(World world, int x, int y, int z, EntityPlayer player, ItemStack lexicon) { + return LexiconData.alchemy; + } + + @Override + public IIcon getIcon(World world, int x, int y, int z) { + return icons[3]; + } - @Override - public IIcon getIcon(World world, int x, int y, int z) { - return icons[3]; - } } diff --git a/src/main/java/vazkii/botania/common/block/mana/BlockBellows.java b/src/main/java/vazkii/botania/common/block/mana/BlockBellows.java index dc60a215cd..341061899a 100644 --- a/src/main/java/vazkii/botania/common/block/mana/BlockBellows.java +++ b/src/main/java/vazkii/botania/common/block/mana/BlockBellows.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Aug 28, 2015, 5:18:13 PM (GMT)] */ package vazkii.botania.common.block.mana; @@ -31,69 +31,64 @@ public class BlockBellows extends BlockModContainer implements ILexiconable { - private static final int[] META_ROTATIONS = new int[] {3, 4, 2, 5}; + private static final int[] META_ROTATIONS = new int[] { 3, 4, 2, 5 }; - public BlockBellows() { - super(Material.wood); - setHardness(2.0F); - setStepSound(soundTypeWood); - setBlockName(LibBlockNames.BELLOWS); + public BlockBellows() { + super(Material.wood); + setHardness(2.0F); + setStepSound(soundTypeWood); + setBlockName(LibBlockNames.BELLOWS); - float f = (1F - 10 / 16F) / 2F; - setBlockBounds(f, 0F, f, 1F - f, 10F / 16F, 1F - f); - } + float f = (1F - 10 / 16F) / 2F; + setBlockBounds(f, 0F, f, 1F - f, 10F / 16F, 1F - f); + } - @Override - public void onBlockPlacedBy( - World p_149689_1_, - int p_149689_2_, - int p_149689_3_, - int p_149689_4_, - EntityLivingBase p_149689_5_, - ItemStack p_149689_6_) { - int l = MathHelper.floor_double(p_149689_5_.rotationYaw * 4.0F / 360.0F + 0.5D) & 3; - p_149689_1_.setBlockMetadataWithNotify(p_149689_2_, p_149689_3_, p_149689_4_, META_ROTATIONS[l], 2); - } + @Override + public void onBlockPlacedBy(World p_149689_1_, int p_149689_2_, int p_149689_3_, int p_149689_4_, EntityLivingBase p_149689_5_, ItemStack p_149689_6_) { + int l = MathHelper.floor_double(p_149689_5_.rotationYaw * 4.0F / 360.0F + 0.5D) & 3; + p_149689_1_.setBlockMetadataWithNotify(p_149689_2_, p_149689_3_, p_149689_4_, META_ROTATIONS[l], 2); + } - @Override - public void registerBlockIcons(IIconRegister par1IconRegister) { - // NO-OP - } + @Override + public void registerBlockIcons(IIconRegister par1IconRegister) { + // NO-OP + } - @Override - public boolean onBlockActivated( - World world, int x, int y, int z, EntityPlayer player, int s, float xs, float ys, float zs) { - if (EntityDoppleganger.isTruePlayer(player)) ((TileBellows) world.getTileEntity(x, y, z)).interact(); - return true; - } + @Override + public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int s, float xs, float ys, float zs) { + if(EntityDoppleganger.isTruePlayer(player)) + ((TileBellows) world.getTileEntity(x, y, z)).interact(); + return true; + } - @Override - public boolean isOpaqueCube() { - return false; - } + @Override + public boolean isOpaqueCube() { + return false; + } - @Override - public boolean renderAsNormalBlock() { - return false; - } + @Override + public boolean renderAsNormalBlock() { + return false; + } - @Override - public IIcon getIcon(int par1, int par2) { - return ModBlocks.livingwood.getIcon(par1, 0); - } + @Override + public IIcon getIcon(int par1, int par2) { + return ModBlocks.livingwood.getIcon(par1, 0); + } - @Override - public int getRenderType() { - return LibRenderIDs.idBellows; - } + @Override + public int getRenderType() { + return LibRenderIDs.idBellows; + } - @Override - public TileEntity createNewTileEntity(World world, int meta) { - return new TileBellows(); - } + @Override + public TileEntity createNewTileEntity(World world, int meta) { + return new TileBellows(); + } + + @Override + public LexiconEntry getEntry(World world, int x, int y, int z, EntityPlayer player, ItemStack lexicon) { + return LexiconData.bellows; + } - @Override - public LexiconEntry getEntry(World world, int x, int y, int z, EntityPlayer player, ItemStack lexicon) { - return LexiconData.bellows; - } } diff --git a/src/main/java/vazkii/botania/common/block/mana/BlockBrewery.java b/src/main/java/vazkii/botania/common/block/mana/BlockBrewery.java index 00a496a5b3..1c83b153cb 100644 --- a/src/main/java/vazkii/botania/common/block/mana/BlockBrewery.java +++ b/src/main/java/vazkii/botania/common/block/mana/BlockBrewery.java @@ -2,15 +2,16 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Oct 31, 2014, 4:37:29 PM (GMT)] */ package vazkii.botania.common.block.mana; import java.util.Random; + import net.minecraft.block.Block; import net.minecraft.block.material.Material; import net.minecraft.client.Minecraft; @@ -36,146 +37,132 @@ public class BlockBrewery extends BlockModContainer implements ILexiconable, IWandHUD { - Random random; - - public BlockBrewery() { - super(Material.rock); - float f = 6F / 16F; - setBlockBounds(f, 0.05F, f, 1F - f, 0.95F, 1F - f); - setBlockName(LibBlockNames.BREWERY); - setHardness(2.0F); - setResistance(10.0F); - setStepSound(soundTypeStone); - - random = new Random(); - } - - @Override - public IIcon getIcon(int side, int meta) { - return Blocks.cobblestone.getIcon(side, meta); - } - - @Override - public boolean onBlockActivated( - World par1World, - int par2, - int par3, - int par4, - EntityPlayer par5EntityPlayer, - int par6, - float par7, - float par8, - float par9) { - TileBrewery brew = (TileBrewery) par1World.getTileEntity(par2, par3, par4); - - if (par5EntityPlayer.isSneaking()) { - if (brew.recipe == null && par1World.getBlockMetadata(par2, par3, par4) == 0) - for (int i = brew.getSizeInventory() - 1; i >= 0; i--) { - ItemStack stackAt = brew.getStackInSlot(i); - if (stackAt != null) { - ItemStack copy = stackAt.copy(); - if (!par5EntityPlayer.inventory.addItemStackToInventory(copy)) - par5EntityPlayer.dropPlayerItemWithRandomChoice(copy, false); - brew.setInventorySlotContents(i, null); - par1World.func_147453_f(par2, par3, par4, this); - break; - } - } - } else { - ItemStack stack = par5EntityPlayer.getCurrentEquippedItem(); - if (stack != null) return brew.addItem(par5EntityPlayer, stack); - } - return false; - } - - @Override - public void breakBlock(World par1World, int par2, int par3, int par4, Block par5, int par6) { - TileSimpleInventory inv = (TileSimpleInventory) par1World.getTileEntity(par2, par3, par4); - - if (inv != null) { - for (int j1 = 0; j1 < inv.getSizeInventory(); ++j1) { - ItemStack itemstack = inv.getStackInSlot(j1); - - if (itemstack != null) { - float f = random.nextFloat() * 0.8F + 0.1F; - float f1 = random.nextFloat() * 0.8F + 0.1F; - EntityItem entityitem; - - for (float f2 = random.nextFloat() * 0.8F + 0.1F; - itemstack.stackSize > 0; - par1World.spawnEntityInWorld(entityitem)) { - int k1 = random.nextInt(21) + 10; - - if (k1 > itemstack.stackSize) k1 = itemstack.stackSize; - - itemstack.stackSize -= k1; - entityitem = new EntityItem( - par1World, - par2 + f, - par3 + f1, - par4 + f2, - new ItemStack(itemstack.getItem(), k1, itemstack.getItemDamage())); - float f3 = 0.05F; - entityitem.motionX = (float) random.nextGaussian() * f3; - entityitem.motionY = (float) random.nextGaussian() * f3 + 0.2F; - entityitem.motionZ = (float) random.nextGaussian() * f3; - - if (itemstack.hasTagCompound()) - entityitem.getEntityItem().setTagCompound((NBTTagCompound) - itemstack.getTagCompound().copy()); - } - } - } - - par1World.func_147453_f(par2, par3, par4, par5); - } - - super.breakBlock(par1World, par2, par3, par4, par5, par6); - } - - @Override - public boolean hasComparatorInputOverride() { - return true; - } - - @Override - public int getComparatorInputOverride(World par1World, int par2, int par3, int par4, int par5) { - TileBrewery brew = (TileBrewery) par1World.getTileEntity(par2, par3, par4); - return brew.signal; - } - - @Override - public void registerBlockIcons(IIconRegister par1IconRegister) { - // NO-OP - } - - @Override - public int getRenderType() { - return LibRenderIDs.idBrewery; - } - - @Override - public boolean isOpaqueCube() { - return false; - } - - @Override - public boolean renderAsNormalBlock() { - return false; - } - - @Override - public TileEntity createNewTileEntity(World world, int meta) { - return new TileBrewery(); - } - - @Override - public LexiconEntry getEntry(World world, int x, int y, int z, EntityPlayer player, ItemStack lexicon) { - return LexiconData.brewery; - } - - @Override - public void renderHUD(Minecraft mc, ScaledResolution res, World world, int x, int y, int z) { - ((TileBrewery) world.getTileEntity(x, y, z)).renderHUD(mc, res); - } + Random random; + + public BlockBrewery() { + super(Material.rock); + float f = 6F / 16F; + setBlockBounds(f, 0.05F, f, 1F - f, 0.95F, 1F - f); + setBlockName(LibBlockNames.BREWERY); + setHardness(2.0F); + setResistance(10.0F); + setStepSound(soundTypeStone); + + random = new Random(); + } + + @Override + public IIcon getIcon(int side, int meta) { + return Blocks.cobblestone.getIcon(side, meta); + } + + @Override + public boolean onBlockActivated(World par1World, int par2, int par3, int par4, EntityPlayer par5EntityPlayer, int par6, float par7, float par8, float par9) { + TileBrewery brew = (TileBrewery) par1World.getTileEntity(par2, par3, par4); + + if(par5EntityPlayer.isSneaking()) { + if(brew.recipe == null && par1World.getBlockMetadata(par2, par3, par4) == 0) + for(int i = brew.getSizeInventory() - 1; i >= 0; i--) { + ItemStack stackAt = brew.getStackInSlot(i); + if(stackAt != null) { + ItemStack copy = stackAt.copy(); + if(!par5EntityPlayer.inventory.addItemStackToInventory(copy)) + par5EntityPlayer.dropPlayerItemWithRandomChoice(copy, false); + brew.setInventorySlotContents(i, null); + par1World.func_147453_f(par2, par3, par4, this); + break; + } + } + } else { + ItemStack stack = par5EntityPlayer.getCurrentEquippedItem(); + if(stack != null) + return brew.addItem(par5EntityPlayer, stack); + } + return false; + } + + @Override + public void breakBlock(World par1World, int par2, int par3, int par4, Block par5, int par6) { + TileSimpleInventory inv = (TileSimpleInventory) par1World.getTileEntity(par2, par3, par4); + + if (inv != null) { + for (int j1 = 0; j1 < inv.getSizeInventory(); ++j1) { + ItemStack itemstack = inv.getStackInSlot(j1); + + if (itemstack != null) { + float f = random.nextFloat() * 0.8F + 0.1F; + float f1 = random.nextFloat() * 0.8F + 0.1F; + EntityItem entityitem; + + for (float f2 = random.nextFloat() * 0.8F + 0.1F; itemstack.stackSize > 0; par1World.spawnEntityInWorld(entityitem)) { + int k1 = random.nextInt(21) + 10; + + if (k1 > itemstack.stackSize) + k1 = itemstack.stackSize; + + itemstack.stackSize -= k1; + entityitem = new EntityItem(par1World, par2 + f, par3 + f1, par4 + f2, new ItemStack(itemstack.getItem(), k1, itemstack.getItemDamage())); + float f3 = 0.05F; + entityitem.motionX = (float)random.nextGaussian() * f3; + entityitem.motionY = (float)random.nextGaussian() * f3 + 0.2F; + entityitem.motionZ = (float)random.nextGaussian() * f3; + + if (itemstack.hasTagCompound()) + entityitem.getEntityItem().setTagCompound((NBTTagCompound)itemstack.getTagCompound().copy()); + } + } + } + + par1World.func_147453_f(par2, par3, par4, par5); + } + + super.breakBlock(par1World, par2, par3, par4, par5, par6); + } + + @Override + public boolean hasComparatorInputOverride() { + return true; + } + + @Override + public int getComparatorInputOverride(World par1World, int par2, int par3, int par4, int par5) { + TileBrewery brew = (TileBrewery) par1World.getTileEntity(par2, par3, par4); + return brew.signal; + } + + @Override + public void registerBlockIcons(IIconRegister par1IconRegister) { + // NO-OP + } + + @Override + public int getRenderType() { + return LibRenderIDs.idBrewery; + } + + @Override + public boolean isOpaqueCube() { + return false; + } + + @Override + public boolean renderAsNormalBlock() { + return false; + } + + @Override + public TileEntity createNewTileEntity(World world, int meta) { + return new TileBrewery(); + } + + @Override + public LexiconEntry getEntry(World world, int x, int y, int z, EntityPlayer player, ItemStack lexicon) { + return LexiconData.brewery; + } + + @Override + public void renderHUD(Minecraft mc, ScaledResolution res, World world, int x, int y, int z) { + ((TileBrewery) world.getTileEntity(x, y, z)).renderHUD(mc, res); + } + } diff --git a/src/main/java/vazkii/botania/common/block/mana/BlockConjurationCatalyst.java b/src/main/java/vazkii/botania/common/block/mana/BlockConjurationCatalyst.java index 91344f2e27..818223a53e 100644 --- a/src/main/java/vazkii/botania/common/block/mana/BlockConjurationCatalyst.java +++ b/src/main/java/vazkii/botania/common/block/mana/BlockConjurationCatalyst.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jun 20, 2014, 1:27:14 AM (GMT)] */ package vazkii.botania.common.block.mana; @@ -19,12 +19,12 @@ public class BlockConjurationCatalyst extends BlockAlchemyCatalyst { - public BlockConjurationCatalyst() { - super(LibBlockNames.CONJURATION_CATALYST); - } + public BlockConjurationCatalyst() { + super(LibBlockNames.CONJURATION_CATALYST); + } - @Override - public LexiconEntry getEntry(World world, int x, int y, int z, EntityPlayer player, ItemStack lexicon) { - return LexiconData.conjurationCatalyst; - } + @Override + public LexiconEntry getEntry(World world, int x, int y, int z, EntityPlayer player, ItemStack lexicon) { + return LexiconData.conjurationCatalyst; + } } diff --git a/src/main/java/vazkii/botania/common/block/mana/BlockDistributor.java b/src/main/java/vazkii/botania/common/block/mana/BlockDistributor.java index ac23c02a7c..f5b8aba150 100644 --- a/src/main/java/vazkii/botania/common/block/mana/BlockDistributor.java +++ b/src/main/java/vazkii/botania/common/block/mana/BlockDistributor.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Mar 3, 2014, 1:44:29 AM (GMT)] */ package vazkii.botania.common.block.mana; @@ -28,34 +28,35 @@ public class BlockDistributor extends BlockModContainer implements ILexiconable { - IIcon iconSide, iconTop; - - public BlockDistributor() { - super(Material.rock); - setHardness(2.0F); - setResistance(10.0F); - setStepSound(soundTypeStone); - setBlockName(LibBlockNames.DISTRIBUTOR); - } - - @Override - public void registerBlockIcons(IIconRegister par1IconRegister) { - iconTop = IconHelper.forBlock(par1IconRegister, this, 0); - iconSide = IconHelper.forBlock(par1IconRegister, this, 1); - } - - @Override - public IIcon getIcon(int par1, int par2) { - return par1 == 0 ? ModBlocks.livingrock.getIcon(0, 0) : par1 == 1 ? iconTop : iconSide; - } - - @Override - public TileEntity createNewTileEntity(World world, int meta) { - return new TileDistributor(); - } - - @Override - public LexiconEntry getEntry(World world, int x, int y, int z, EntityPlayer player, ItemStack lexicon) { - return LexiconData.distributor; - } + IIcon iconSide, iconTop; + + public BlockDistributor() { + super(Material.rock); + setHardness(2.0F); + setResistance(10.0F); + setStepSound(soundTypeStone); + setBlockName(LibBlockNames.DISTRIBUTOR); + } + + @Override + public void registerBlockIcons(IIconRegister par1IconRegister) { + iconTop = IconHelper.forBlock(par1IconRegister, this, 0); + iconSide = IconHelper.forBlock(par1IconRegister, this, 1); + } + + @Override + public IIcon getIcon(int par1, int par2) { + return par1 == 0 ? ModBlocks.livingrock.getIcon(0, 0) : par1 == 1 ? iconTop : iconSide; + } + + @Override + public TileEntity createNewTileEntity(World world, int meta) { + return new TileDistributor(); + } + + @Override + public LexiconEntry getEntry(World world, int x, int y, int z, EntityPlayer player, ItemStack lexicon) { + return LexiconData.distributor; + } + } diff --git a/src/main/java/vazkii/botania/common/block/mana/BlockEnchanter.java b/src/main/java/vazkii/botania/common/block/mana/BlockEnchanter.java index cf868cbd61..2318fc4cb5 100644 --- a/src/main/java/vazkii/botania/common/block/mana/BlockEnchanter.java +++ b/src/main/java/vazkii/botania/common/block/mana/BlockEnchanter.java @@ -2,15 +2,16 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Mar 15, 2014, 4:08:26 PM (GMT)] */ package vazkii.botania.common.block.mana; import java.util.Random; + import net.minecraft.block.Block; import net.minecraft.block.material.Material; import net.minecraft.client.Minecraft; @@ -40,137 +41,119 @@ public class BlockEnchanter extends BlockModContainer implements IWandable, ILexiconable, IWandHUD { - Random random; - public static IIcon overlay; - - public BlockEnchanter() { - super(Material.rock); - setHardness(3.0F); - setResistance(5.0F); - setLightLevel(1.0F); - setStepSound(soundTypeStone); - setBlockName(LibBlockNames.ENCHANTER); - - random = new Random(); - } - - @Override - public boolean registerInCreative() { - return false; - } - - @Override - public void registerBlockIcons(IIconRegister par1IconRegister) { - super.registerBlockIcons(par1IconRegister); - overlay = IconHelper.forBlock(par1IconRegister, this, "Overlay"); - } - - @Override - public TileEntity createNewTileEntity(World world, int meta) { - return new TileEnchanter(); - } - - @Override - public Item getItemDropped(int p_149650_1_, Random p_149650_2_, int p_149650_3_) { - return Item.getItemFromBlock(Blocks.lapis_block); - } - - @Override - public boolean isOpaqueCube() { - return false; - } - - @Override - public boolean onBlockActivated( - World par1World, - int par2, - int par3, - int par4, - EntityPlayer par5EntityPlayer, - int par6, - float par7, - float par8, - float par9) { - TileEnchanter enchanter = (TileEnchanter) par1World.getTileEntity(par2, par3, par4); - ItemStack stack = par5EntityPlayer.getCurrentEquippedItem(); - if (stack != null && stack.getItem() == ModItems.twigWand) return false; - - boolean stackEnchantable = stack != null - && stack.getItem() != Items.book - && stack.isItemEnchantable() - && stack.stackSize == 1 - && stack.getItem().getItemEnchantability(stack) > 0; - - if (enchanter.itemToEnchant == null) { - if (stackEnchantable) { - enchanter.itemToEnchant = stack.copy(); - par5EntityPlayer.inventory.setInventorySlotContents(par5EntityPlayer.inventory.currentItem, null); - enchanter.sync(); - } - } else if (enchanter.stage == 0) { - if (par5EntityPlayer.inventory.addItemStackToInventory(enchanter.itemToEnchant.copy())) { - enchanter.itemToEnchant = null; - enchanter.sync(); - } else par5EntityPlayer.addChatMessage(new ChatComponentTranslation("botaniamisc.invFull")); - } - - return true; - } - - @Override - public void breakBlock(World par1World, int par2, int par3, int par4, Block par5, int par6) { - TileEnchanter enchanter = (TileEnchanter) par1World.getTileEntity(par2, par3, par4); - - ItemStack itemstack = enchanter.itemToEnchant; - - if (itemstack != null) { - float f = random.nextFloat() * 0.8F + 0.1F; - float f1 = random.nextFloat() * 0.8F + 0.1F; - EntityItem entityitem; - - for (float f2 = random.nextFloat() * 0.8F + 0.1F; - itemstack.stackSize > 0; - par1World.spawnEntityInWorld(entityitem)) { - int k1 = random.nextInt(21) + 10; - - if (k1 > itemstack.stackSize) k1 = itemstack.stackSize; - - itemstack.stackSize -= k1; - entityitem = new EntityItem( - par1World, - par2 + f, - par3 + f1, - par4 + f2, - new ItemStack(itemstack.getItem(), k1, itemstack.getItemDamage())); - float f3 = 0.05F; - entityitem.motionX = (float) random.nextGaussian() * f3 * 0.5; - entityitem.motionY = (float) random.nextGaussian() * f3 + 0.2F; - entityitem.motionZ = (float) random.nextGaussian() * f3 * 0.5; - - if (itemstack.hasTagCompound()) - entityitem.getEntityItem().setTagCompound((NBTTagCompound) - itemstack.getTagCompound().copy()); - } - } - - par1World.func_147453_f(par2, par3, par4, par5); - - super.breakBlock(par1World, par2, par3, par4, par5, par6); - } - - @Override - public boolean onUsedByWand(EntityPlayer player, ItemStack stack, World world, int x, int y, int z, int side) { - ((TileEnchanter) world.getTileEntity(x, y, z)).onWanded(player, stack); - return true; - } - - @Override - public LexiconEntry getEntry(World world, int x, int y, int z, EntityPlayer player, ItemStack lexicon) { - return LexiconData.manaEnchanting; - } - - @Override - public void renderHUD(Minecraft mc, ScaledResolution res, World world, int x, int y, int z) { - ((TileEnchanter) world.getTileEntity(x, y, z)).renderHUD(mc, res); - } + Random random; + public static IIcon overlay; + + public BlockEnchanter() { + super(Material.rock); + setHardness(3.0F); + setResistance(5.0F); + setLightLevel(1.0F); + setStepSound(soundTypeStone); + setBlockName(LibBlockNames.ENCHANTER); + + random = new Random(); + } + + @Override + public boolean registerInCreative() { + return false; + } + + @Override + public void registerBlockIcons(IIconRegister par1IconRegister) { + super.registerBlockIcons(par1IconRegister); + overlay = IconHelper.forBlock(par1IconRegister, this, "Overlay"); + } + + @Override + public TileEntity createNewTileEntity(World world, int meta) { + return new TileEnchanter(); + } + + @Override + public Item getItemDropped(int p_149650_1_, Random p_149650_2_, int p_149650_3_) { + return Item.getItemFromBlock(Blocks.lapis_block); + } + + @Override + public boolean isOpaqueCube() { + return false; + } + + @Override + public boolean onBlockActivated(World par1World, int par2, int par3, int par4, EntityPlayer par5EntityPlayer, int par6, float par7, float par8, float par9) { + TileEnchanter enchanter = (TileEnchanter) par1World.getTileEntity(par2, par3, par4); + ItemStack stack = par5EntityPlayer.getCurrentEquippedItem(); + if(stack != null && stack.getItem() == ModItems.twigWand) + return false; + + boolean stackEnchantable = stack != null && stack.getItem() != Items.book && stack.isItemEnchantable() && stack.stackSize == 1 && stack.getItem().getItemEnchantability(stack) > 0; + + if(enchanter.itemToEnchant == null) { + if(stackEnchantable) { + enchanter.itemToEnchant = stack.copy(); + par5EntityPlayer.inventory.setInventorySlotContents(par5EntityPlayer.inventory.currentItem, null); + enchanter.sync(); + } + } else if(enchanter.stage == 0) { + if(par5EntityPlayer.inventory.addItemStackToInventory(enchanter.itemToEnchant.copy())) { + enchanter.itemToEnchant = null; + enchanter.sync(); + } else par5EntityPlayer.addChatMessage(new ChatComponentTranslation("botaniamisc.invFull")); + } + + return true; + } + + @Override + public void breakBlock(World par1World, int par2, int par3, int par4, Block par5, int par6) { + TileEnchanter enchanter = (TileEnchanter) par1World.getTileEntity(par2, par3, par4); + + ItemStack itemstack = enchanter.itemToEnchant; + + if (itemstack != null) { + float f = random.nextFloat() * 0.8F + 0.1F; + float f1 = random.nextFloat() * 0.8F + 0.1F; + EntityItem entityitem; + + for (float f2 = random.nextFloat() * 0.8F + 0.1F; itemstack.stackSize > 0; par1World.spawnEntityInWorld(entityitem)) { + int k1 = random.nextInt(21) + 10; + + if (k1 > itemstack.stackSize) + k1 = itemstack.stackSize; + + itemstack.stackSize -= k1; + entityitem = new EntityItem(par1World, par2 + f, par3 + f1, par4 + f2, new ItemStack(itemstack.getItem(), k1, itemstack.getItemDamage())); + float f3 = 0.05F; + entityitem.motionX = (float)random.nextGaussian() * f3 * 0.5; + entityitem.motionY = (float)random.nextGaussian() * f3 + 0.2F; + entityitem.motionZ = (float)random.nextGaussian() * f3 * 0.5; + + if (itemstack.hasTagCompound()) + entityitem.getEntityItem().setTagCompound((NBTTagCompound)itemstack.getTagCompound().copy()); + } + } + + par1World.func_147453_f(par2, par3, par4, par5); + + super.breakBlock(par1World, par2, par3, par4, par5, par6); + } + + @Override + public boolean onUsedByWand(EntityPlayer player, ItemStack stack, World world, int x, int y, int z, int side) { + ((TileEnchanter) world.getTileEntity(x, y, z)).onWanded(player, stack); + return true; + } + + @Override + public LexiconEntry getEntry(World world, int x, int y, int z, EntityPlayer player, ItemStack lexicon) { + return LexiconData.manaEnchanting; + } + + @Override + public void renderHUD(Minecraft mc, ScaledResolution res, World world, int x, int y, int z) { + ((TileEnchanter) world.getTileEntity(x, y, z)).renderHUD(mc, res); + } + } diff --git a/src/main/java/vazkii/botania/common/block/mana/BlockForestDrum.java b/src/main/java/vazkii/botania/common/block/mana/BlockForestDrum.java index 1e24c6c9cf..3893d556ca 100644 --- a/src/main/java/vazkii/botania/common/block/mana/BlockForestDrum.java +++ b/src/main/java/vazkii/botania/common/block/mana/BlockForestDrum.java @@ -2,18 +2,18 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [May 16, 2014, 7:34:37 PM (GMT)] */ package vazkii.botania.common.block.mana; -import cpw.mods.fml.common.registry.GameRegistry; import java.util.ArrayList; import java.util.Collections; import java.util.List; + import net.minecraft.block.Block; import net.minecraft.block.material.Material; import net.minecraft.client.renderer.texture.IIconRegister; @@ -39,153 +39,147 @@ import vazkii.botania.common.item.block.ItemBlockWithMetadataAndName; import vazkii.botania.common.lexicon.LexiconData; import vazkii.botania.common.lib.LibBlockNames; +import cpw.mods.fml.common.registry.GameRegistry; public class BlockForestDrum extends BlockMod implements IManaTrigger, ILexiconable { - IIcon iconBases, iconFaces; - IIcon iconBasesA, iconFacesA; - IIcon iconBasesB, iconFacesB; - - public BlockForestDrum() { - super(Material.wood); - float f = 1F / 16F; - setBlockBounds(f * 3, 0F, f * 3, 1F - f * 3, 1F - f * 2, 1F - f * 3); - - setHardness(2.0F); - setStepSound(soundTypeWood); - setBlockName(LibBlockNames.FOREST_DRUM); - } - - @Override - protected boolean shouldRegisterInNameSet() { - return false; - } - - @Override - public Block setBlockName(String par1Str) { - GameRegistry.registerBlock(this, ItemBlockWithMetadataAndName.class, par1Str); - return super.setBlockName(par1Str); - } - - @Override - public boolean renderAsNormalBlock() { - return false; - } - - @Override - public boolean isOpaqueCube() { - return false; - } - - @Override - public int damageDropped(int meta) { - return meta; - } - - @Override - public void registerBlockIcons(IIconRegister par1IconRegister) { - iconBases = IconHelper.forBlock(par1IconRegister, this, 0); - iconFaces = IconHelper.forBlock(par1IconRegister, this, 1); - iconBasesA = IconHelper.forBlock(par1IconRegister, this, 2); - iconFacesA = IconHelper.forBlock(par1IconRegister, this, 3); - iconBasesB = IconHelper.forBlock(par1IconRegister, this, 4); - iconFacesB = IconHelper.forBlock(par1IconRegister, this, 5); - } - - @Override - public void getSubBlocks(Item item, CreativeTabs tab, List list) { - for (int i = 0; i < 3; i++) list.add(new ItemStack(item, 1, i)); - } - - @Override - public IIcon getIcon(int side, int meta) { - boolean animal = meta == 1; - boolean tree = meta == 2; - return side < 2 - ? animal ? iconBasesA : tree ? iconBasesB : iconBases - : animal ? iconFacesA : tree ? iconFacesB : iconFaces; - } - - @Override - public void onBurstCollision(IManaBurst burst, World world, int x, int y, int z) { - if (burst.isFake()) return; - - if (world.getBlockMetadata(x, y, z) == 0) ItemGrassHorn.breakGrass(world, null, 0, x, y, z); - else if (world.getBlockMetadata(x, y, z) == 2) ItemGrassHorn.breakGrass(world, null, 1, x, y, z); - else if (!world.isRemote) { - int range = 10; - List entities = world.getEntitiesWithinAABB( - EntityLiving.class, - AxisAlignedBB.getBoundingBox( - x - range, y - range, z - range, x + range + 1, y + range + 1, z + range + 1)); - List shearables = new ArrayList(); - ItemStack stack = new ItemStack(this, 1, 1); - - for (EntityLiving entity : entities) { - if (entity instanceof IShearable - && ((IShearable) entity) - .isShearable(stack, world, (int) entity.posX, (int) entity.posY, (int) entity.posZ)) { - shearables.add(entity); - } else if (entity instanceof EntityCow) { - List items = world.getEntitiesWithinAABB( - EntityItem.class, - AxisAlignedBB.getBoundingBox( - entity.posX, - entity.posY, - entity.posZ, - entity.posX + entity.width, - entity.posY + entity.height, - entity.posZ + entity.width)); - for (EntityItem item : items) { - ItemStack itemstack = item.getEntityItem(); - if (itemstack != null && itemstack.getItem() == Items.bucket && !world.isRemote) { - while (itemstack.stackSize > 0) { - EntityItem ent = entity.entityDropItem(new ItemStack(Items.milk_bucket), 1.0F); - ent.motionY += world.rand.nextFloat() * 0.05F; - ent.motionX += (world.rand.nextFloat() - world.rand.nextFloat()) * 0.1F; - ent.motionZ += (world.rand.nextFloat() - world.rand.nextFloat()) * 0.1F; - itemstack.stackSize--; - } - item.setDead(); - } - } - } - } - - Collections.shuffle(shearables); - int sheared = 0; - - for (EntityLiving entity : shearables) { - if (sheared > 4) break; - - List stacks = ((IShearable) entity) - .onSheared(stack, world, (int) entity.posX, (int) entity.posY, (int) entity.posZ, 0); - if (stacks != null) - for (ItemStack wool : stacks) { - EntityItem ent = entity.entityDropItem(wool, 1.0F); - ent.motionY += world.rand.nextFloat() * 0.05F; - ent.motionX += (world.rand.nextFloat() - world.rand.nextFloat()) * 0.1F; - ent.motionZ += (world.rand.nextFloat() - world.rand.nextFloat()) * 0.1F; - } - ++sheared; - } - } - - if (!world.isRemote) for (int i = 0; i < 10; i++) world.playSoundEffect(x, y, z, "note.bd", 1F, 1F); - else world.spawnParticle("note", x + 0.5, y + 1.2, z + 0.5D, 1.0 / 24.0, 0, 0); - } - - @Override - public LexiconEntry getEntry(World world, int x, int y, int z, EntityPlayer player, ItemStack lexicon) { - int meta = world.getBlockMetadata(x, y, z); - - switch (meta) { - case 1: - return LexiconData.gatherDrum; - case 2: - return LexiconData.canopyDrum; - default: - return LexiconData.forestDrum; - } - } + IIcon iconBases, iconFaces; + IIcon iconBasesA, iconFacesA; + IIcon iconBasesB, iconFacesB; + + public BlockForestDrum() { + super(Material.wood); + float f = 1F / 16F; + setBlockBounds(f * 3, 0F, f * 3, 1F - f * 3, 1F - f * 2, 1F - f * 3); + + setHardness(2.0F); + setStepSound(soundTypeWood); + setBlockName(LibBlockNames.FOREST_DRUM); + } + + @Override + protected boolean shouldRegisterInNameSet() { + return false; + } + + @Override + public Block setBlockName(String par1Str) { + GameRegistry.registerBlock(this, ItemBlockWithMetadataAndName.class, par1Str); + return super.setBlockName(par1Str); + } + + @Override + public boolean renderAsNormalBlock() { + return false; + } + + @Override + public boolean isOpaqueCube() { + return false; + } + + @Override + public int damageDropped(int meta) { + return meta; + } + + @Override + public void registerBlockIcons(IIconRegister par1IconRegister) { + iconBases = IconHelper.forBlock(par1IconRegister, this, 0); + iconFaces = IconHelper.forBlock(par1IconRegister, this, 1); + iconBasesA = IconHelper.forBlock(par1IconRegister, this, 2); + iconFacesA = IconHelper.forBlock(par1IconRegister, this, 3); + iconBasesB = IconHelper.forBlock(par1IconRegister, this, 4); + iconFacesB = IconHelper.forBlock(par1IconRegister, this, 5); + } + + @Override + public void getSubBlocks(Item item, CreativeTabs tab, List list) { + for(int i = 0; i < 3; i++) + list.add(new ItemStack(item, 1, i)); + } + + @Override + public IIcon getIcon(int side, int meta) { + boolean animal = meta == 1; + boolean tree = meta == 2; + return side < 2 ? animal ? iconBasesA : tree ? iconBasesB : iconBases : animal ? iconFacesA : tree ? iconFacesB : iconFaces; + } + + @Override + public void onBurstCollision(IManaBurst burst, World world, int x, int y, int z) { + if(burst.isFake()) + return; + + if(world.getBlockMetadata(x, y, z) == 0) + ItemGrassHorn.breakGrass(world, null, 0, x, y, z); + else if(world.getBlockMetadata(x, y, z) == 2) + ItemGrassHorn.breakGrass(world, null, 1, x, y, z); + else if(!world.isRemote) { + int range = 10; + List entities = world.getEntitiesWithinAABB(EntityLiving.class, AxisAlignedBB.getBoundingBox(x - range, y - range, z - range, x + range + 1, y + range + 1, z + range + 1)); + List shearables = new ArrayList(); + ItemStack stack = new ItemStack(this, 1, 1); + + for(EntityLiving entity : entities) { + if(entity instanceof IShearable && ((IShearable) entity).isShearable(stack, world, (int) entity.posX, (int) entity.posY, (int) entity.posZ)) { + shearables.add(entity); + } else if(entity instanceof EntityCow) { + List items = world.getEntitiesWithinAABB(EntityItem.class, AxisAlignedBB.getBoundingBox(entity.posX, entity.posY, entity.posZ, entity.posX + entity.width, entity.posY + entity.height, entity.posZ + entity.width)); + for(EntityItem item : items) { + ItemStack itemstack = item.getEntityItem(); + if(itemstack != null && itemstack.getItem() == Items.bucket && !world.isRemote) { + while(itemstack.stackSize > 0) { + EntityItem ent = entity.entityDropItem(new ItemStack(Items.milk_bucket), 1.0F); + ent.motionY += world.rand.nextFloat() * 0.05F; + ent.motionX += (world.rand.nextFloat() - world.rand.nextFloat()) * 0.1F; + ent.motionZ += (world.rand.nextFloat() - world.rand.nextFloat()) * 0.1F; + itemstack.stackSize--; + } + item.setDead(); + } + } + } + } + + Collections.shuffle(shearables); + int sheared = 0; + + for(EntityLiving entity : shearables) { + if(sheared > 4) + break; + + List stacks = ((IShearable) entity).onSheared(stack, world, (int) entity.posX, (int) entity.posY, (int) entity.posZ, 0); + if(stacks != null) + for(ItemStack wool : stacks) { + EntityItem ent = entity.entityDropItem(wool, 1.0F); + ent.motionY += world.rand.nextFloat() * 0.05F; + ent.motionX += (world.rand.nextFloat() - world.rand.nextFloat()) * 0.1F; + ent.motionZ += (world.rand.nextFloat() - world.rand.nextFloat()) * 0.1F; + } + ++sheared; + } + } + + if(!world.isRemote) + for(int i = 0; i < 10; i++) + world.playSoundEffect(x, y, z, "note.bd", 1F, 1F); + else world.spawnParticle("note", x + 0.5, y + 1.2, z + 0.5D, 1.0 / 24.0, 0, 0); + + } + + @Override + public LexiconEntry getEntry(World world, int x, int y, int z, EntityPlayer player, ItemStack lexicon) { + int meta = world.getBlockMetadata(x, y, z); + + switch(meta) { + case 1: + return LexiconData.gatherDrum; + case 2: + return LexiconData.canopyDrum; + default: + return LexiconData.forestDrum; + } + } + } diff --git a/src/main/java/vazkii/botania/common/block/mana/BlockManaDetector.java b/src/main/java/vazkii/botania/common/block/mana/BlockManaDetector.java index b57c7efa84..2487ce7b44 100644 --- a/src/main/java/vazkii/botania/common/block/mana/BlockManaDetector.java +++ b/src/main/java/vazkii/botania/common/block/mana/BlockManaDetector.java @@ -2,15 +2,16 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Mar 10, 2014, 7:57:38 PM (GMT)] */ package vazkii.botania.common.block.mana; import java.util.List; + import net.minecraft.block.Block; import net.minecraft.block.material.Material; import net.minecraft.client.renderer.texture.IIconRegister; @@ -33,57 +34,52 @@ public class BlockManaDetector extends BlockModContainer implements ILexiconable { - IIcon[] icons; + IIcon[] icons; + + public BlockManaDetector() { + super(Material.rock); + setHardness(2.0F); + setResistance(10.0F); + setStepSound(Block.soundTypeStone); + setBlockName(LibBlockNames.MANA_DETECTOR); + } - public BlockManaDetector() { - super(Material.rock); - setHardness(2.0F); - setResistance(10.0F); - setStepSound(Block.soundTypeStone); - setBlockName(LibBlockNames.MANA_DETECTOR); - } + @Override + public void registerBlockIcons(IIconRegister par1IconRegister) { + icons = new IIcon[2]; + for(int i = 0; i < icons.length; i++) + icons[i] = IconHelper.forBlock(par1IconRegister, this, i); + } - @Override - public void registerBlockIcons(IIconRegister par1IconRegister) { - icons = new IIcon[2]; - for (int i = 0; i < icons.length; i++) icons[i] = IconHelper.forBlock(par1IconRegister, this, i); - } + @Override + public IIcon getIcon(int par1, int par2) { + return icons[Math.min(icons.length - 1, par2)]; + } - @Override - public IIcon getIcon(int par1, int par2) { - return icons[Math.min(icons.length - 1, par2)]; - } + @Override + public boolean canProvidePower() { + return true; + } - @Override - public boolean canProvidePower() { - return true; - } + @Override + public int isProvidingWeakPower(IBlockAccess par1iBlockAccess, int par2, int par3, int par4, int par5) { + return par1iBlockAccess.getBlockMetadata(par2, par3, par4) != 0 ? 15 : 0; + } - @Override - public int isProvidingWeakPower(IBlockAccess par1iBlockAccess, int par2, int par3, int par4, int par5) { - return par1iBlockAccess.getBlockMetadata(par2, par3, par4) != 0 ? 15 : 0; - } + @Override + public void addCollisionBoxesToList(World par1World, int par2, int par3, int par4, AxisAlignedBB par5AxisAlignedBB, List par6List, Entity par7Entity) { + if(par7Entity != null && !(par7Entity instanceof IManaBurst)) + super.addCollisionBoxesToList(par1World, par2, par3, par4, par5AxisAlignedBB, par6List, par7Entity); + } - @Override - public void addCollisionBoxesToList( - World par1World, - int par2, - int par3, - int par4, - AxisAlignedBB par5AxisAlignedBB, - List par6List, - Entity par7Entity) { - if (par7Entity != null && !(par7Entity instanceof IManaBurst)) - super.addCollisionBoxesToList(par1World, par2, par3, par4, par5AxisAlignedBB, par6List, par7Entity); - } + @Override + public TileEntity createNewTileEntity(World world, int meta) { + return new TileManaDetector(); + } - @Override - public TileEntity createNewTileEntity(World world, int meta) { - return new TileManaDetector(); - } + @Override + public LexiconEntry getEntry(World world, int x, int y, int z, EntityPlayer player, ItemStack lexicon) { + return LexiconData.manaDetector; + } - @Override - public LexiconEntry getEntry(World world, int x, int y, int z, EntityPlayer player, ItemStack lexicon) { - return LexiconData.manaDetector; - } } diff --git a/src/main/java/vazkii/botania/common/block/mana/BlockManaVoid.java b/src/main/java/vazkii/botania/common/block/mana/BlockManaVoid.java index 6418185706..622375863b 100644 --- a/src/main/java/vazkii/botania/common/block/mana/BlockManaVoid.java +++ b/src/main/java/vazkii/botania/common/block/mana/BlockManaVoid.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Mar 5, 2014, 12:55:47 AM (GMT)] */ package vazkii.botania.common.block.mana; @@ -29,34 +29,35 @@ public class BlockManaVoid extends BlockModContainer implements ILexiconable, IPoolOverlayProvider { - IIcon overlay; - - public BlockManaVoid() { - super(Material.rock); - setHardness(2.0F); - setResistance(2000F); - setStepSound(Block.soundTypeStone); - setBlockName(LibBlockNames.MANA_VOID); - } - - @Override - public void registerBlockIcons(IIconRegister par1IconRegister) { - blockIcon = IconHelper.forBlock(par1IconRegister, this, 0); - overlay = IconHelper.forBlock(par1IconRegister, this, 1); - } - - @Override - public TileEntity createNewTileEntity(World world, int id) { - return new TileManaVoid(); - } - - @Override - public LexiconEntry getEntry(World world, int x, int y, int z, EntityPlayer player, ItemStack lexicon) { - return LexiconData.manaVoid; - } - - @Override - public IIcon getIcon(World world, int x, int y, int z) { - return overlay; - } + IIcon overlay; + + public BlockManaVoid() { + super(Material.rock); + setHardness(2.0F); + setResistance(2000F); + setStepSound(Block.soundTypeStone); + setBlockName(LibBlockNames.MANA_VOID); + } + + @Override + public void registerBlockIcons(IIconRegister par1IconRegister) { + blockIcon = IconHelper.forBlock(par1IconRegister, this, 0); + overlay = IconHelper.forBlock(par1IconRegister, this, 1); + } + + @Override + public TileEntity createNewTileEntity(World world, int id) { + return new TileManaVoid(); + } + + @Override + public LexiconEntry getEntry(World world, int x, int y, int z, EntityPlayer player, ItemStack lexicon) { + return LexiconData.manaVoid; + } + + @Override + public IIcon getIcon(World world, int x, int y, int z) { + return overlay; + } + } diff --git a/src/main/java/vazkii/botania/common/block/mana/BlockPool.java b/src/main/java/vazkii/botania/common/block/mana/BlockPool.java index 4d4a763a21..ec1075a37d 100644 --- a/src/main/java/vazkii/botania/common/block/mana/BlockPool.java +++ b/src/main/java/vazkii/botania/common/block/mana/BlockPool.java @@ -2,17 +2,17 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jan 26, 2014, 12:22:58 AM (GMT)] */ package vazkii.botania.common.block.mana; -import cpw.mods.fml.common.registry.GameRegistry; import java.util.ArrayList; import java.util.List; + import net.minecraft.block.Block; import net.minecraft.block.material.Material; import net.minecraft.client.Minecraft; @@ -41,6 +41,7 @@ import vazkii.botania.client.core.helper.IconHelper; import vazkii.botania.client.lib.LibRenderIDs; import vazkii.botania.common.achievement.ICraftAchievement; +import vazkii.botania.common.achievement.IPickupAchievement; import vazkii.botania.common.achievement.ModAchievements; import vazkii.botania.common.block.BlockModContainer; import vazkii.botania.common.block.ModBlocks; @@ -48,168 +49,159 @@ import vazkii.botania.common.item.block.ItemBlockPool; import vazkii.botania.common.lexicon.LexiconData; import vazkii.botania.common.lib.LibBlockNames; +import cpw.mods.fml.common.registry.GameRegistry; public class BlockPool extends BlockModContainer implements IWandHUD, IWandable, ILexiconable, ICraftAchievement { - boolean lastFragile = false; - - public static IIcon manaIcon; - - public BlockPool() { - super(Material.rock); - setHardness(2.0F); - setResistance(10.0F); - setStepSound(soundTypeStone); - setBlockName(LibBlockNames.POOL); - setBlockBounds(0F, 0F, 0F, 1F, 0.5F, 1F); - - BotaniaAPI.blacklistBlockFromMagnet(this, Short.MAX_VALUE); - } - - @Override - protected boolean shouldRegisterInNameSet() { - return false; - } - - @Override - public Block setBlockName(String par1Str) { - GameRegistry.registerBlock(this, ItemBlockPool.class, par1Str); - return super.setBlockName(par1Str); - } - - @Override - public void registerBlockIcons(IIconRegister par1IconRegister) { - manaIcon = IconHelper.forName(par1IconRegister, "manaWater"); - } - - @Override - public int damageDropped(int meta) { - return meta; - } - - @Override - public void breakBlock(World par1World, int par2, int par3, int par4, Block par5, int par6) { - TilePool pool = (TilePool) par1World.getTileEntity(par2, par3, par4); - lastFragile = pool.fragile; - super.breakBlock(par1World, par2, par3, par4, par5, par6); - } - - @Override - public ArrayList getDrops(World world, int x, int y, int z, int metadata, int fortune) { - ArrayList drops = new ArrayList(); - - if (!lastFragile) drops.add(new ItemStack(this, 1, metadata)); - - return drops; - } - - @Override - public void getSubBlocks(Item par1, CreativeTabs par2, List par3) { - par3.add(new ItemStack(par1, 1, 0)); - par3.add(new ItemStack(par1, 1, 2)); - par3.add(new ItemStack(par1, 1, 3)); - par3.add(new ItemStack(par1, 1, 1)); - } - - @Override - public TileEntity createNewTileEntity(World world, int meta) { - return new TilePool(); - } - - @Override - public void onEntityCollidedWithBlock(World par1World, int par2, int par3, int par4, Entity par5Entity) { - if (par5Entity instanceof EntityItem) { - TilePool tile = (TilePool) par1World.getTileEntity(par2, par3, par4); - if (tile.collideEntityItem((EntityItem) par5Entity)) - VanillaPacketDispatcher.dispatchTEToNearbyPlayers(par1World, par2, par3, par4); - } - } - - @Override - public void addCollisionBoxesToList( - World p_149743_1_, - int p_149743_2_, - int p_149743_3_, - int p_149743_4_, - AxisAlignedBB p_149743_5_, - List p_149743_6_, - Entity p_149743_7_) { - float f = 1F / 16F; - setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, f, 1.0F); - super.addCollisionBoxesToList( - p_149743_1_, p_149743_2_, p_149743_3_, p_149743_4_, p_149743_5_, p_149743_6_, p_149743_7_); - setBlockBounds(0.0F, 0.0F, 0.0F, f, 0.5F, 1.0F); - super.addCollisionBoxesToList( - p_149743_1_, p_149743_2_, p_149743_3_, p_149743_4_, p_149743_5_, p_149743_6_, p_149743_7_); - setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 0.5F, f); - super.addCollisionBoxesToList( - p_149743_1_, p_149743_2_, p_149743_3_, p_149743_4_, p_149743_5_, p_149743_6_, p_149743_7_); - setBlockBounds(1.0F - f, 0.0F, 0.0F, 1.0F, 0.5F, 1.0F); - super.addCollisionBoxesToList( - p_149743_1_, p_149743_2_, p_149743_3_, p_149743_4_, p_149743_5_, p_149743_6_, p_149743_7_); - setBlockBounds(0.0F, 0.0F, 1.0F - f, 1.0F, 0.5F, 1.0F); - super.addCollisionBoxesToList( - p_149743_1_, p_149743_2_, p_149743_3_, p_149743_4_, p_149743_5_, p_149743_6_, p_149743_7_); - setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 0.5F, 1.0F); - } - - @Override - public boolean isSideSolid(IBlockAccess world, int x, int y, int z, ForgeDirection side) { - return side == ForgeDirection.DOWN; - } - - @Override - public boolean isOpaqueCube() { - return false; - } - - @Override - public boolean renderAsNormalBlock() { - return false; - } - - @Override - public IIcon getIcon(int par1, int par2) { - return ModBlocks.livingrock.getIcon(par1, 0); - } - - @Override - public int getRenderType() { - return LibRenderIDs.idPool; - } - - @Override - public boolean hasComparatorInputOverride() { - return true; - } - - @Override - public int getComparatorInputOverride(World par1World, int par2, int par3, int par4, int par5) { - TilePool pool = (TilePool) par1World.getTileEntity(par2, par3, par4); - int val = (int) ((double) pool.getCurrentMana() / (double) pool.manaCap * 15.0); - if (pool.getCurrentMana() > 0) val = Math.max(val, 1); - - return val; - } - - @Override - public void renderHUD(Minecraft mc, ScaledResolution res, World world, int x, int y, int z) { - ((TilePool) world.getTileEntity(x, y, z)).renderHUD(mc, res); - } - - @Override - public boolean onUsedByWand(EntityPlayer player, ItemStack stack, World world, int x, int y, int z, int side) { - ((TilePool) world.getTileEntity(x, y, z)).onWanded(player, stack); - return true; - } - - @Override - public LexiconEntry getEntry(World world, int x, int y, int z, EntityPlayer player, ItemStack lexicon) { - return world.getBlockMetadata(x, y, z) == 3 ? LexiconData.rainbowRod : LexiconData.pool; - } - - @Override - public Achievement getAchievementOnCraft(ItemStack stack, EntityPlayer player, IInventory matrix) { - return ModAchievements.manaPoolPickup; - } + boolean lastFragile = false; + + public static IIcon manaIcon; + + public BlockPool() { + super(Material.rock); + setHardness(2.0F); + setResistance(10.0F); + setStepSound(soundTypeStone); + setBlockName(LibBlockNames.POOL); + setBlockBounds(0F, 0F, 0F, 1F, 0.5F, 1F); + + BotaniaAPI.blacklistBlockFromMagnet(this, Short.MAX_VALUE); + } + + @Override + protected boolean shouldRegisterInNameSet() { + return false; + } + + @Override + public Block setBlockName(String par1Str) { + GameRegistry.registerBlock(this, ItemBlockPool.class, par1Str); + return super.setBlockName(par1Str); + } + + @Override + public void registerBlockIcons(IIconRegister par1IconRegister) { + manaIcon = IconHelper.forName(par1IconRegister, "manaWater"); + } + + @Override + public int damageDropped(int meta) { + return meta; + } + + @Override + public void breakBlock(World par1World, int par2, int par3, int par4, Block par5, int par6) { + TilePool pool = (TilePool) par1World.getTileEntity(par2, par3, par4); + lastFragile = pool.fragile; + super.breakBlock(par1World, par2, par3, par4, par5, par6); + } + + @Override + public ArrayList getDrops(World world, int x, int y, int z, int metadata, int fortune) { + ArrayList drops = new ArrayList(); + + if(!lastFragile) + drops.add(new ItemStack(this, 1, metadata)); + + return drops; + } + + @Override + public void getSubBlocks(Item par1, CreativeTabs par2, List par3) { + par3.add(new ItemStack(par1, 1, 0)); + par3.add(new ItemStack(par1, 1, 2)); + par3.add(new ItemStack(par1, 1, 3)); + par3.add(new ItemStack(par1, 1, 1)); + } + + @Override + public TileEntity createNewTileEntity(World world, int meta) { + return new TilePool(); + } + + @Override + public void onEntityCollidedWithBlock(World par1World, int par2, int par3, int par4, Entity par5Entity) { + if(par5Entity instanceof EntityItem) { + TilePool tile = (TilePool) par1World.getTileEntity(par2, par3, par4); + if(tile.collideEntityItem((EntityItem) par5Entity)) + VanillaPacketDispatcher.dispatchTEToNearbyPlayers(par1World, par2, par3, par4); + } + } + + @Override + public void addCollisionBoxesToList(World p_149743_1_, int p_149743_2_, int p_149743_3_, int p_149743_4_, AxisAlignedBB p_149743_5_, List p_149743_6_, Entity p_149743_7_) { + float f = 1F / 16F; + setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, f, 1.0F); + super.addCollisionBoxesToList(p_149743_1_, p_149743_2_, p_149743_3_, p_149743_4_, p_149743_5_, p_149743_6_, p_149743_7_); + setBlockBounds(0.0F, 0.0F, 0.0F, f, 0.5F, 1.0F); + super.addCollisionBoxesToList(p_149743_1_, p_149743_2_, p_149743_3_, p_149743_4_, p_149743_5_, p_149743_6_, p_149743_7_); + setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 0.5F, f); + super.addCollisionBoxesToList(p_149743_1_, p_149743_2_, p_149743_3_, p_149743_4_, p_149743_5_, p_149743_6_, p_149743_7_); + setBlockBounds(1.0F - f, 0.0F, 0.0F, 1.0F, 0.5F, 1.0F); + super.addCollisionBoxesToList(p_149743_1_, p_149743_2_, p_149743_3_, p_149743_4_, p_149743_5_, p_149743_6_, p_149743_7_); + setBlockBounds(0.0F, 0.0F, 1.0F - f, 1.0F, 0.5F, 1.0F); + super.addCollisionBoxesToList(p_149743_1_, p_149743_2_, p_149743_3_, p_149743_4_, p_149743_5_, p_149743_6_, p_149743_7_); + setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 0.5F, 1.0F); + } + + @Override + public boolean isSideSolid(IBlockAccess world, int x, int y, int z, ForgeDirection side) { + return side == ForgeDirection.DOWN; + } + + @Override + public boolean isOpaqueCube() { + return false; + } + + @Override + public boolean renderAsNormalBlock() { + return false; + } + + @Override + public IIcon getIcon(int par1, int par2) { + return ModBlocks.livingrock.getIcon(par1, 0); + } + + @Override + public int getRenderType() { + return LibRenderIDs.idPool; + } + + @Override + public boolean hasComparatorInputOverride() { + return true; + } + + @Override + public int getComparatorInputOverride(World par1World, int par2, int par3, int par4, int par5) { + TilePool pool = (TilePool) par1World.getTileEntity(par2, par3, par4); + int val = (int) ((double) pool.getCurrentMana() / (double) pool.manaCap * 15.0); + if(pool.getCurrentMana() > 0) + val = Math.max(val, 1); + + return val; + } + + @Override + public void renderHUD(Minecraft mc, ScaledResolution res, World world, int x, int y, int z) { + ((TilePool) world.getTileEntity(x, y, z)).renderHUD(mc, res); + } + + @Override + public boolean onUsedByWand(EntityPlayer player, ItemStack stack, World world, int x, int y, int z, int side) { + ((TilePool) world.getTileEntity(x, y, z)).onWanded(player, stack); + return true; + } + + @Override + public LexiconEntry getEntry(World world, int x, int y, int z, EntityPlayer player, ItemStack lexicon) { + return world.getBlockMetadata(x, y, z) == 3 ? LexiconData.rainbowRod : LexiconData.pool; + } + + @Override + public Achievement getAchievementOnCraft(ItemStack stack, EntityPlayer player, IInventory matrix) { + return ModAchievements.manaPoolPickup; + } } diff --git a/src/main/java/vazkii/botania/common/block/mana/BlockPrism.java b/src/main/java/vazkii/botania/common/block/mana/BlockPrism.java index 9058f1df99..0748d93219 100644 --- a/src/main/java/vazkii/botania/common/block/mana/BlockPrism.java +++ b/src/main/java/vazkii/botania/common/block/mana/BlockPrism.java @@ -2,15 +2,16 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jan 17, 2015, 7:16:48 PM (GMT)] */ package vazkii.botania.common.block.mana; import java.util.Random; + import net.minecraft.block.Block; import net.minecraft.block.material.Material; import net.minecraft.client.renderer.texture.IIconRegister; @@ -36,166 +37,155 @@ public class BlockPrism extends BlockModContainer implements IManaTrigger, ILexiconable { - Random random; - IIcon[] icons; - - public BlockPrism() { - super(Material.glass); - setHardness(0.3F); - setStepSound(soundTypeGlass); - setLightLevel(1.0F); - setBlockName(LibBlockNames.PRISM); - float f = 0.25F; - setBlockBounds(f, 0F, f, 1F - f, 1F, 1F - f); - - random = new Random(); - } - - @Override - public void registerBlockIcons(IIconRegister par1IconRegister) { - icons = new IIcon[2]; - for (int i = 0; i < icons.length; i++) icons[i] = IconHelper.forBlock(par1IconRegister, this, i); - } - - @Override - public IIcon getIcon(int side, int meta) { - return side > 1 ? icons[1] : icons[0]; - } - - @Override - public int getRenderBlockPass() { - return 1; - } - - @Override - public AxisAlignedBB getCollisionBoundingBoxFromPool( - World p_149668_1_, int p_149668_2_, int p_149668_3_, int p_149668_4_) { - return null; - } - - @Override - public boolean isOpaqueCube() { - return false; - } - - @Override - public boolean renderAsNormalBlock() { - return false; - } - - @Override - public boolean onBlockActivated( - World par1World, - int par2, - int par3, - int par4, - EntityPlayer par5EntityPlayer, - int par6, - float par7, - float par8, - float par9) { - TileEntity tile = par1World.getTileEntity(par2, par3, par4); - if (!(tile instanceof TilePrism)) return false; - - TilePrism prism = (TilePrism) tile; - ItemStack lens = prism.getStackInSlot(0); - ItemStack heldItem = par5EntityPlayer.getCurrentEquippedItem(); - boolean isHeldItemLens = heldItem != null && heldItem.getItem() instanceof ILens; - int meta = par1World.getBlockMetadata(par2, par3, par4); - - if (lens == null && isHeldItemLens) { - if (!par5EntityPlayer.capabilities.isCreativeMode) - par5EntityPlayer.inventory.setInventorySlotContents(par5EntityPlayer.inventory.currentItem, null); - - prism.setInventorySlotContents(0, heldItem.copy()); - prism.markDirty(); - par1World.setBlockMetadataWithNotify(par2, par3, par4, meta | 1, 1 | 2); - } else if (lens != null) { - ItemStack add = lens.copy(); - if (!par5EntityPlayer.inventory.addItemStackToInventory(add)) - par5EntityPlayer.dropPlayerItemWithRandomChoice(add, false); - prism.setInventorySlotContents(0, null); - prism.markDirty(); - par1World.setBlockMetadataWithNotify(par2, par3, par4, meta & 14, 1 | 2); - } - - return true; - } - - @Override - public void onNeighborBlockChange(World world, int x, int y, int z, Block block) { - boolean power = - world.isBlockIndirectlyGettingPowered(x, y, z) || world.isBlockIndirectlyGettingPowered(x, y + 1, z); - int meta = world.getBlockMetadata(x, y, z); - boolean powered = (meta & 8) != 0; - - if (!world.isRemote) { - if (power && !powered) world.setBlockMetadataWithNotify(x, y, z, meta | 8, 1 | 2); - else if (!power && powered) world.setBlockMetadataWithNotify(x, y, z, meta & -9, 1 | 2); - } - } - - @Override - public void breakBlock(World par1World, int par2, int par3, int par4, Block par5, int par6) { - TileEntity tile = par1World.getTileEntity(par2, par3, par4); - if (!(tile instanceof TileSimpleInventory)) return; - - TileSimpleInventory inv = (TileSimpleInventory) tile; - - if (inv != null) { - for (int j1 = 0; j1 < inv.getSizeInventory(); ++j1) { - ItemStack itemstack = inv.getStackInSlot(j1); - - if (itemstack != null) { - float f = random.nextFloat() * 0.8F + 0.1F; - float f1 = random.nextFloat() * 0.8F + 0.1F; - EntityItem entityitem; - - for (float f2 = random.nextFloat() * 0.8F + 0.1F; - itemstack.stackSize > 0; - par1World.spawnEntityInWorld(entityitem)) { - int k1 = random.nextInt(21) + 10; - - if (k1 > itemstack.stackSize) k1 = itemstack.stackSize; - - itemstack.stackSize -= k1; - entityitem = new EntityItem( - par1World, - par2 + f, - par3 + f1, - par4 + f2, - new ItemStack(itemstack.getItem(), k1, itemstack.getItemDamage())); - float f3 = 0.05F; - entityitem.motionX = (float) random.nextGaussian() * f3; - entityitem.motionY = (float) random.nextGaussian() * f3 + 0.2F; - entityitem.motionZ = (float) random.nextGaussian() * f3; - - if (itemstack.hasTagCompound()) - entityitem.getEntityItem().setTagCompound((NBTTagCompound) - itemstack.getTagCompound().copy()); - } - } - } - - par1World.func_147453_f(par2, par3, par4, par5); - } - - super.breakBlock(par1World, par2, par3, par4, par5, par6); - } - - @Override - public TileEntity createNewTileEntity(World world, int meta) { - return new TilePrism(); - } - - @Override - public void onBurstCollision(IManaBurst burst, World world, int x, int y, int z) { - TileEntity tile = world.getTileEntity(x, y, z); - if (tile != null && tile instanceof TilePrism) ((TilePrism) tile).onBurstCollision(burst); - } - - @Override - public LexiconEntry getEntry(World world, int x, int y, int z, EntityPlayer player, ItemStack lexicon) { - return LexiconData.prism; - } + Random random; + IIcon[] icons; + + public BlockPrism() { + super(Material.glass); + setHardness(0.3F); + setStepSound(soundTypeGlass); + setLightLevel(1.0F); + setBlockName(LibBlockNames.PRISM); + float f = 0.25F; + setBlockBounds(f, 0F, f, 1F - f, 1F, 1F - f); + + random = new Random(); + } + + @Override + public void registerBlockIcons(IIconRegister par1IconRegister) { + icons = new IIcon[2]; + for(int i = 0; i < icons.length; i++) + icons[i] = IconHelper.forBlock(par1IconRegister, this, i); + } + + @Override + public IIcon getIcon(int side, int meta) { + return side > 1 ? icons[1] : icons[0]; + } + + @Override + public int getRenderBlockPass() { + return 1; + } + + @Override + public AxisAlignedBB getCollisionBoundingBoxFromPool(World p_149668_1_, int p_149668_2_, int p_149668_3_, int p_149668_4_) { + return null; + } + + @Override + public boolean isOpaqueCube() { + return false; + } + + @Override + public boolean renderAsNormalBlock() { + return false; + } + + @Override + public boolean onBlockActivated(World par1World, int par2, int par3, int par4, EntityPlayer par5EntityPlayer, int par6, float par7, float par8, float par9) { + TileEntity tile = par1World.getTileEntity(par2, par3, par4); + if(!(tile instanceof TilePrism)) + return false; + + TilePrism prism = (TilePrism) tile; + ItemStack lens = prism.getStackInSlot(0); + ItemStack heldItem = par5EntityPlayer.getCurrentEquippedItem(); + boolean isHeldItemLens = heldItem != null && heldItem.getItem() instanceof ILens; + int meta = par1World.getBlockMetadata(par2, par3, par4); + + if(lens == null && isHeldItemLens) { + if(!par5EntityPlayer.capabilities.isCreativeMode) + par5EntityPlayer.inventory.setInventorySlotContents(par5EntityPlayer.inventory.currentItem, null); + + prism.setInventorySlotContents(0, heldItem.copy()); + prism.markDirty(); + par1World.setBlockMetadataWithNotify(par2, par3, par4, meta | 1, 1 | 2); + } else if(lens != null) { + ItemStack add = lens.copy(); + if(!par5EntityPlayer.inventory.addItemStackToInventory(add)) + par5EntityPlayer.dropPlayerItemWithRandomChoice(add, false); + prism.setInventorySlotContents(0, null); + prism.markDirty(); + par1World.setBlockMetadataWithNotify(par2, par3, par4, meta & 14, 1 | 2); + } + + return true; + } + + @Override + public void onNeighborBlockChange(World world, int x, int y, int z, Block block) { + boolean power = world.isBlockIndirectlyGettingPowered(x, y, z) || world.isBlockIndirectlyGettingPowered(x, y + 1, z); + int meta = world.getBlockMetadata(x, y, z); + boolean powered = (meta & 8) != 0; + + if(!world.isRemote) { + if(power && !powered) + world.setBlockMetadataWithNotify(x, y, z, meta | 8, 1 | 2); + else if(!power && powered) + world.setBlockMetadataWithNotify(x, y, z, meta & -9, 1 | 2); + } + } + + @Override + public void breakBlock(World par1World, int par2, int par3, int par4, Block par5, int par6) { + TileEntity tile = par1World.getTileEntity(par2, par3, par4); + if(!(tile instanceof TileSimpleInventory)) + return; + + TileSimpleInventory inv = (TileSimpleInventory) tile; + + if (inv != null) { + for (int j1 = 0; j1 < inv.getSizeInventory(); ++j1) { + ItemStack itemstack = inv.getStackInSlot(j1); + + if (itemstack != null) { + float f = random.nextFloat() * 0.8F + 0.1F; + float f1 = random.nextFloat() * 0.8F + 0.1F; + EntityItem entityitem; + + for (float f2 = random.nextFloat() * 0.8F + 0.1F; itemstack.stackSize > 0; par1World.spawnEntityInWorld(entityitem)) { + int k1 = random.nextInt(21) + 10; + + if (k1 > itemstack.stackSize) + k1 = itemstack.stackSize; + + itemstack.stackSize -= k1; + entityitem = new EntityItem(par1World, par2 + f, par3 + f1, par4 + f2, new ItemStack(itemstack.getItem(), k1, itemstack.getItemDamage())); + float f3 = 0.05F; + entityitem.motionX = (float)random.nextGaussian() * f3; + entityitem.motionY = (float)random.nextGaussian() * f3 + 0.2F; + entityitem.motionZ = (float)random.nextGaussian() * f3; + + if (itemstack.hasTagCompound()) + entityitem.getEntityItem().setTagCompound((NBTTagCompound)itemstack.getTagCompound().copy()); + } + } + } + + par1World.func_147453_f(par2, par3, par4, par5); + } + + super.breakBlock(par1World, par2, par3, par4, par5, par6); + } + + @Override + public TileEntity createNewTileEntity(World world, int meta) { + return new TilePrism(); + } + + @Override + public void onBurstCollision(IManaBurst burst, World world, int x, int y, int z) { + TileEntity tile = world.getTileEntity(x, y, z); + if(tile != null && tile instanceof TilePrism) + ((TilePrism) tile).onBurstCollision(burst); + } + + @Override + public LexiconEntry getEntry(World world, int x, int y, int z, EntityPlayer player, ItemStack lexicon) { + return LexiconData.prism; + } + } diff --git a/src/main/java/vazkii/botania/common/block/mana/BlockPump.java b/src/main/java/vazkii/botania/common/block/mana/BlockPump.java index bd0243e013..aa4a4c6e6a 100644 --- a/src/main/java/vazkii/botania/common/block/mana/BlockPump.java +++ b/src/main/java/vazkii/botania/common/block/mana/BlockPump.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Mar 17, 2015, 9:46:53 PM (GMT)] */ package vazkii.botania.common.block.mana; @@ -34,86 +34,81 @@ public class BlockPump extends BlockModContainer implements ILexiconable { - private static final int[] META_ROTATIONS = new int[] {2, 5, 3, 4}; - - public BlockPump() { - super(Material.rock); - setHardness(2.0F); - setResistance(10.0F); - setStepSound(soundTypeStone); - setBlockName(LibBlockNames.PUMP); - setBlockBounds(true); - } - - @Override - public void onBlockPlacedBy( - World p_149689_1_, - int p_149689_2_, - int p_149689_3_, - int p_149689_4_, - EntityLivingBase p_149689_5_, - ItemStack p_149689_6_) { - int l = MathHelper.floor_double(p_149689_5_.rotationYaw * 4.0F / 360.0F + 0.5D) & 3; - p_149689_1_.setBlockMetadataWithNotify(p_149689_2_, p_149689_3_, p_149689_4_, META_ROTATIONS[l], 2); - } - - @Override - public void setBlockBoundsBasedOnState(IBlockAccess w, int x, int y, int z) { - setBlockBounds(w.getBlockMetadata(x, y, z) < 4); - } - - public void setBlockBounds(boolean horiz) { - if (horiz) setBlockBounds(0.25F, 0F, 0F, 0.75F, 0.5F, 1F); - else setBlockBounds(0F, 0F, 0.25F, 1F, 0.5F, 0.75F); - } - - @Override - public boolean rotateBlock(World worldObj, int x, int y, int z, ForgeDirection axis) { - return RotationHelper.rotateVanillaBlock(Blocks.furnace, worldObj, x, y, z, axis); - } - - @Override - public void registerBlockIcons(IIconRegister par1IconRegister) { - // NO-OP - } - - @Override - public IIcon getIcon(int par1, int par2) { - return ModBlocks.livingrock.getIcon(0, 0); - } - - @Override - public int getRenderType() { - return LibRenderIDs.idPump; - } - - @Override - public boolean isOpaqueCube() { - return false; - } - - @Override - public boolean renderAsNormalBlock() { - return false; - } - - @Override - public boolean hasComparatorInputOverride() { - return true; - } - - @Override - public int getComparatorInputOverride(World world, int x, int y, int z, int side) { - return ((TilePump) world.getTileEntity(x, y, z)).comparator; - } - - @Override - public LexiconEntry getEntry(World world, int x, int y, int z, EntityPlayer player, ItemStack lexicon) { - return LexiconData.poolCart; - } - - @Override - public TileEntity createNewTileEntity(World world, int meta) { - return new TilePump(); - } + private static final int[] META_ROTATIONS = new int[] { 2, 5, 3, 4 }; + + public BlockPump() { + super(Material.rock); + setHardness(2.0F); + setResistance(10.0F); + setStepSound(soundTypeStone); + setBlockName(LibBlockNames.PUMP); + setBlockBounds(true); + } + + @Override + public void onBlockPlacedBy(World p_149689_1_, int p_149689_2_, int p_149689_3_, int p_149689_4_, EntityLivingBase p_149689_5_, ItemStack p_149689_6_) { + int l = MathHelper.floor_double(p_149689_5_.rotationYaw * 4.0F / 360.0F + 0.5D) & 3; + p_149689_1_.setBlockMetadataWithNotify(p_149689_2_, p_149689_3_, p_149689_4_, META_ROTATIONS[l], 2); + } + + @Override + public void setBlockBoundsBasedOnState(IBlockAccess w, int x, int y, int z) { + setBlockBounds(w.getBlockMetadata(x, y, z) < 4); + } + + public void setBlockBounds(boolean horiz) { + if(horiz) + setBlockBounds(0.25F, 0F, 0F, 0.75F, 0.5F, 1F); + else setBlockBounds(0F, 0F, 0.25F, 1F, 0.5F, 0.75F); + } + + @Override + public boolean rotateBlock(World worldObj, int x, int y, int z, ForgeDirection axis) { + return RotationHelper.rotateVanillaBlock(Blocks.furnace, worldObj, x, y, z, axis); + } + + @Override + public void registerBlockIcons(IIconRegister par1IconRegister) { + // NO-OP + } + + @Override + public IIcon getIcon(int par1, int par2) { + return ModBlocks.livingrock.getIcon(0, 0); + } + + @Override + public int getRenderType() { + return LibRenderIDs.idPump; + } + + @Override + public boolean isOpaqueCube() { + return false; + } + + @Override + public boolean renderAsNormalBlock() { + return false; + } + + @Override + public boolean hasComparatorInputOverride() { + return true; + } + + @Override + public int getComparatorInputOverride(World world, int x, int y, int z, int side) { + return ((TilePump) world.getTileEntity(x, y, z)).comparator; + } + + @Override + public LexiconEntry getEntry(World world, int x, int y, int z, EntityPlayer player, ItemStack lexicon) { + return LexiconData.poolCart; + } + + @Override + public TileEntity createNewTileEntity(World world, int meta) { + return new TilePump(); + } } diff --git a/src/main/java/vazkii/botania/common/block/mana/BlockRFGenerator.java b/src/main/java/vazkii/botania/common/block/mana/BlockRFGenerator.java index 3fc94698ab..79e7e35dbd 100644 --- a/src/main/java/vazkii/botania/common/block/mana/BlockRFGenerator.java +++ b/src/main/java/vazkii/botania/common/block/mana/BlockRFGenerator.java @@ -2,15 +2,14 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Aug 29, 2014, 9:51:58 PM (GMT)] */ package vazkii.botania.common.block.mana; -import cpw.mods.fml.common.Optional; import net.minecraft.block.material.Material; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; @@ -23,32 +22,34 @@ import vazkii.botania.common.block.tile.mana.TileRFGenerator; import vazkii.botania.common.lexicon.LexiconData; import vazkii.botania.common.lib.LibBlockNames; +import cpw.mods.fml.common.Optional; public class BlockRFGenerator extends BlockModContainer implements ILexiconable { - public BlockRFGenerator() { - super(Material.rock); - setHardness(2.0F); - setResistance(10.0F); - setStepSound(soundTypeStone); - setBlockName(LibBlockNames.RF_GENERATOR); - } + public BlockRFGenerator() { + super(Material.rock); + setHardness(2.0F); + setResistance(10.0F); + setStepSound(soundTypeStone); + setBlockName(LibBlockNames.RF_GENERATOR); + } + + @Override + @Optional.Method(modid = "CoFHAPI|energy") + public void onNeighborChange(IBlockAccess world, int x, int y, int z, int tileX, int tileY, int tileZ) { + TileEntity tile = world.getTileEntity(x, y, z); + if(tile != null && tile instanceof TileRFGenerator) + ((TileRFGenerator) tile).onNeighborTileChange(tileX, tileY, tileZ); + } - @Override - @Optional.Method(modid = "CoFHAPI|energy") - public void onNeighborChange(IBlockAccess world, int x, int y, int z, int tileX, int tileY, int tileZ) { - TileEntity tile = world.getTileEntity(x, y, z); - if (tile != null && tile instanceof TileRFGenerator) - ((TileRFGenerator) tile).onNeighborTileChange(tileX, tileY, tileZ); - } + @Override + public TileEntity createNewTileEntity(World world, int meta) { + return new TileRFGenerator(); + } - @Override - public TileEntity createNewTileEntity(World world, int meta) { - return new TileRFGenerator(); - } + @Override + public LexiconEntry getEntry(World world, int x, int y, int z, EntityPlayer player, ItemStack lexicon) { + return LexiconData.rfGenerator; + } - @Override - public LexiconEntry getEntry(World world, int x, int y, int z, EntityPlayer player, ItemStack lexicon) { - return LexiconData.rfGenerator; - } } diff --git a/src/main/java/vazkii/botania/common/block/mana/BlockRuneAltar.java b/src/main/java/vazkii/botania/common/block/mana/BlockRuneAltar.java index 03a159a649..23ef4ef8eb 100644 --- a/src/main/java/vazkii/botania/common/block/mana/BlockRuneAltar.java +++ b/src/main/java/vazkii/botania/common/block/mana/BlockRuneAltar.java @@ -2,15 +2,16 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Feb 2, 2014, 2:10:14 PM (GMT)] */ package vazkii.botania.common.block.mana; import java.util.Random; + import net.minecraft.block.Block; import net.minecraft.block.material.Material; import net.minecraft.client.renderer.texture.IIconRegister; @@ -34,144 +35,132 @@ public class BlockRuneAltar extends BlockModContainer implements IWandable, ILexiconable { - Random random; - IIcon[] icons; - - public BlockRuneAltar() { - super(Material.rock); - setBlockBounds(0F, 0F, 0F, 1F, 0.75F, 1F); - setHardness(2.0F); - setResistance(10.0F); - setStepSound(soundTypeStone); - setBlockName(LibBlockNames.RUNE_ALTAR); - - BotaniaAPI.blacklistBlockFromMagnet(this, Short.MAX_VALUE); - - random = new Random(); - } - - @Override - public boolean isOpaqueCube() { - return false; - } - - @Override - public boolean renderAsNormalBlock() { - return false; - } - - @Override - public void registerBlockIcons(IIconRegister par1IconRegister) { - icons = new IIcon[3]; - for (int i = 0; i < icons.length; i++) icons[i] = IconHelper.forBlock(par1IconRegister, this, i); - } - - @Override - public boolean onBlockActivated( - World par1World, - int par2, - int par3, - int par4, - EntityPlayer par5EntityPlayer, - int par6, - float par7, - float par8, - float par9) { - TileRuneAltar altar = (TileRuneAltar) par1World.getTileEntity(par2, par3, par4); - ItemStack stack = par5EntityPlayer.getCurrentEquippedItem(); - - if (par5EntityPlayer.isSneaking()) { - if (altar.manaToGet == 0) - for (int i = altar.getSizeInventory() - 1; i >= 0; i--) { - ItemStack stackAt = altar.getStackInSlot(i); - if (stackAt != null) { - ItemStack copy = stackAt.copy(); - if (!par5EntityPlayer.inventory.addItemStackToInventory(copy)) - par5EntityPlayer.dropPlayerItemWithRandomChoice(copy, false); - altar.setInventorySlotContents(i, null); - par1World.func_147453_f(par2, par3, par4, this); - break; - } - } - } else if (altar.isEmpty() && stack == null) altar.trySetLastRecipe(par5EntityPlayer); - else if (stack != null) return altar.addItem(par5EntityPlayer, stack); - return false; - } - - @Override - public void breakBlock(World par1World, int par2, int par3, int par4, Block par5, int par6) { - TileSimpleInventory inv = (TileSimpleInventory) par1World.getTileEntity(par2, par3, par4); - - if (inv != null) { - for (int j1 = 0; j1 < inv.getSizeInventory(); ++j1) { - ItemStack itemstack = inv.getStackInSlot(j1); - - if (itemstack != null) { - float f = random.nextFloat() * 0.8F + 0.1F; - float f1 = random.nextFloat() * 0.8F + 0.1F; - EntityItem entityitem; - - for (float f2 = random.nextFloat() * 0.8F + 0.1F; - itemstack.stackSize > 0; - par1World.spawnEntityInWorld(entityitem)) { - int k1 = random.nextInt(21) + 10; - - if (k1 > itemstack.stackSize) k1 = itemstack.stackSize; - - itemstack.stackSize -= k1; - entityitem = new EntityItem( - par1World, - par2 + f, - par3 + f1, - par4 + f2, - new ItemStack(itemstack.getItem(), k1, itemstack.getItemDamage())); - float f3 = 0.05F; - entityitem.motionX = (float) random.nextGaussian() * f3; - entityitem.motionY = (float) random.nextGaussian() * f3 + 0.2F; - entityitem.motionZ = (float) random.nextGaussian() * f3; - - if (itemstack.hasTagCompound()) - entityitem.getEntityItem().setTagCompound((NBTTagCompound) - itemstack.getTagCompound().copy()); - } - } - } - - par1World.func_147453_f(par2, par3, par4, par5); - } - - super.breakBlock(par1World, par2, par3, par4, par5, par6); - } - - @Override - public IIcon getIcon(int par1, int par2) { - return icons[Math.min(2, par1)]; - } - - @Override - public TileEntity createNewTileEntity(World world, int meta) { - return new TileRuneAltar(); - } - - @Override - public boolean hasComparatorInputOverride() { - return true; - } - - @Override - public int getComparatorInputOverride(World par1World, int par2, int par3, int par4, int par5) { - TileRuneAltar altar = (TileRuneAltar) par1World.getTileEntity(par2, par3, par4); - return altar.signal; - } - - @Override - public boolean onUsedByWand(EntityPlayer player, ItemStack stack, World world, int x, int y, int z, int side) { - ((TileRuneAltar) world.getTileEntity(x, y, z)).onWanded(player, stack); - return true; - } - - @Override - public LexiconEntry getEntry(World world, int x, int y, int z, EntityPlayer player, ItemStack lexicon) { - return LexiconData.runicAltar; - } + Random random; + IIcon[] icons; + + public BlockRuneAltar() { + super(Material.rock); + setBlockBounds(0F, 0F, 0F, 1F, 0.75F, 1F); + setHardness(2.0F); + setResistance(10.0F); + setStepSound(soundTypeStone); + setBlockName(LibBlockNames.RUNE_ALTAR); + + BotaniaAPI.blacklistBlockFromMagnet(this, Short.MAX_VALUE); + + random = new Random(); + } + + @Override + public boolean isOpaqueCube() { + return false; + } + + @Override + public boolean renderAsNormalBlock() { + return false; + } + + @Override + public void registerBlockIcons(IIconRegister par1IconRegister) { + icons = new IIcon[3]; + for(int i = 0; i < icons.length; i++) + icons[i] = IconHelper.forBlock(par1IconRegister, this, i); + } + + @Override + public boolean onBlockActivated(World par1World, int par2, int par3, int par4, EntityPlayer par5EntityPlayer, int par6, float par7, float par8, float par9) { + TileRuneAltar altar = (TileRuneAltar) par1World.getTileEntity(par2, par3, par4); + ItemStack stack = par5EntityPlayer.getCurrentEquippedItem(); + + if(par5EntityPlayer.isSneaking()) { + if(altar.manaToGet == 0) + for(int i = altar.getSizeInventory() - 1; i >= 0; i--) { + ItemStack stackAt = altar.getStackInSlot(i); + if(stackAt != null) { + ItemStack copy = stackAt.copy(); + if(!par5EntityPlayer.inventory.addItemStackToInventory(copy)) + par5EntityPlayer.dropPlayerItemWithRandomChoice(copy, false); + altar.setInventorySlotContents(i, null); + par1World.func_147453_f(par2, par3, par4, this); + break; + } + } + } else if(altar.isEmpty() && stack == null) + altar.trySetLastRecipe(par5EntityPlayer); + else if(stack != null) + return altar.addItem(par5EntityPlayer, stack); + return false; + } + + @Override + public void breakBlock(World par1World, int par2, int par3, int par4, Block par5, int par6) { + TileSimpleInventory inv = (TileSimpleInventory) par1World.getTileEntity(par2, par3, par4); + + if (inv != null) { + for (int j1 = 0; j1 < inv.getSizeInventory(); ++j1) { + ItemStack itemstack = inv.getStackInSlot(j1); + + if (itemstack != null) { + float f = random.nextFloat() * 0.8F + 0.1F; + float f1 = random.nextFloat() * 0.8F + 0.1F; + EntityItem entityitem; + + for (float f2 = random.nextFloat() * 0.8F + 0.1F; itemstack.stackSize > 0; par1World.spawnEntityInWorld(entityitem)) { + int k1 = random.nextInt(21) + 10; + + if (k1 > itemstack.stackSize) + k1 = itemstack.stackSize; + + itemstack.stackSize -= k1; + entityitem = new EntityItem(par1World, par2 + f, par3 + f1, par4 + f2, new ItemStack(itemstack.getItem(), k1, itemstack.getItemDamage())); + float f3 = 0.05F; + entityitem.motionX = (float)random.nextGaussian() * f3; + entityitem.motionY = (float)random.nextGaussian() * f3 + 0.2F; + entityitem.motionZ = (float)random.nextGaussian() * f3; + + if (itemstack.hasTagCompound()) + entityitem.getEntityItem().setTagCompound((NBTTagCompound)itemstack.getTagCompound().copy()); + } + } + } + + par1World.func_147453_f(par2, par3, par4, par5); + } + + super.breakBlock(par1World, par2, par3, par4, par5, par6); + } + + @Override + public IIcon getIcon(int par1, int par2) { + return icons[Math.min(2, par1)]; + } + + @Override + public TileEntity createNewTileEntity(World world, int meta) { + return new TileRuneAltar(); + } + + @Override + public boolean hasComparatorInputOverride() { + return true; + } + + @Override + public int getComparatorInputOverride(World par1World, int par2, int par3, int par4, int par5) { + TileRuneAltar altar = (TileRuneAltar) par1World.getTileEntity(par2, par3, par4); + return altar.signal; + } + + @Override + public boolean onUsedByWand(EntityPlayer player, ItemStack stack, World world, int x, int y, int z, int side) { + ((TileRuneAltar) world.getTileEntity(x, y, z)).onWanded(player, stack); + return true; + } + + @Override + public LexiconEntry getEntry(World world, int x, int y, int z, EntityPlayer player, ItemStack lexicon) { + return LexiconData.runicAltar; + } + } diff --git a/src/main/java/vazkii/botania/common/block/mana/BlockSpawnerClaw.java b/src/main/java/vazkii/botania/common/block/mana/BlockSpawnerClaw.java index 370e3b5706..c21a20fb5e 100644 --- a/src/main/java/vazkii/botania/common/block/mana/BlockSpawnerClaw.java +++ b/src/main/java/vazkii/botania/common/block/mana/BlockSpawnerClaw.java @@ -2,15 +2,16 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jul 23, 2014, 5:28:55 PM (GMT)] */ package vazkii.botania.common.block.mana; import java.util.List; + import net.minecraft.block.material.Material; import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.creativetab.CreativeTabs; @@ -30,49 +31,50 @@ public class BlockSpawnerClaw extends BlockModContainer implements ILexiconable { - public BlockSpawnerClaw() { - super(Material.iron); - setHardness(3.0F); - setBlockName(LibBlockNames.SPAWNER_CLAW); + public BlockSpawnerClaw() { + super(Material.iron); + setHardness(3.0F); + setBlockName(LibBlockNames.SPAWNER_CLAW); + + float f = 1F / 8F; + float f1 = 1F / 16F; + setBlockBounds(f, 0F, f, 1F - f, f1, 1F - f); + } - float f = 1F / 8F; - float f1 = 1F / 16F; - setBlockBounds(f, 0F, f, 1F - f, f1, 1F - f); - } + @Override + public void getSubBlocks(Item item, CreativeTabs tab, List list) { + list.add(new ItemStack(item)); + list.add(new ItemStack(Blocks.mob_spawner)); + } - @Override - public void getSubBlocks(Item item, CreativeTabs tab, List list) { - list.add(new ItemStack(item)); - list.add(new ItemStack(Blocks.mob_spawner)); - } + @Override + public void registerBlockIcons(IIconRegister par1IconRegister) { + //NO-OP + } - @Override - public void registerBlockIcons(IIconRegister par1IconRegister) { - // NO-OP - } + @Override + public boolean isOpaqueCube() { + return false; + } - @Override - public boolean isOpaqueCube() { - return false; - } + @Override + public boolean renderAsNormalBlock() { + return false; + } - @Override - public boolean renderAsNormalBlock() { - return false; - } + @Override + public int getRenderType() { + return LibRenderIDs.idSpawnerClaw; + } - @Override - public int getRenderType() { - return LibRenderIDs.idSpawnerClaw; - } + @Override + public TileEntity createNewTileEntity(World world, int meta) { + return new TileSpawnerClaw(); + } - @Override - public TileEntity createNewTileEntity(World world, int meta) { - return new TileSpawnerClaw(); - } + @Override + public LexiconEntry getEntry(World world, int x, int y, int z, EntityPlayer player, ItemStack lexicon) { + return LexiconData.spawnerClaw; + } - @Override - public LexiconEntry getEntry(World world, int x, int y, int z, EntityPlayer player, ItemStack lexicon) { - return LexiconData.spawnerClaw; - } } diff --git a/src/main/java/vazkii/botania/common/block/mana/BlockSpreader.java b/src/main/java/vazkii/botania/common/block/mana/BlockSpreader.java index fb100a33fc..8227d736fc 100644 --- a/src/main/java/vazkii/botania/common/block/mana/BlockSpreader.java +++ b/src/main/java/vazkii/botania/common/block/mana/BlockSpreader.java @@ -2,17 +2,17 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jan 25, 2014, 9:38:23 PM (GMT)] */ package vazkii.botania.common.block.mana; -import cpw.mods.fml.common.registry.GameRegistry; import java.util.List; import java.util.Random; + import net.minecraft.block.Block; import net.minecraft.block.BlockPistonBase; import net.minecraft.block.material.Material; @@ -45,229 +45,209 @@ import vazkii.botania.common.item.block.ItemBlockWithMetadataAndName; import vazkii.botania.common.lexicon.LexiconData; import vazkii.botania.common.lib.LibBlockNames; +import cpw.mods.fml.common.registry.GameRegistry; + +public class BlockSpreader extends BlockModContainer implements IWandable, IWandHUD, ILexiconable, IWireframeAABBProvider { + + Random random; + + public BlockSpreader() { + super(Material.wood); + setHardness(2.0F); + setStepSound(soundTypeWood); + setBlockName(LibBlockNames.SPREADER); + + random = new Random(); + } + + @Override + protected boolean shouldRegisterInNameSet() { + return false; + } + + @Override + public Block setBlockName(String par1Str) { + GameRegistry.registerBlock(this, ItemBlockWithMetadataAndName.class, par1Str); + return super.setBlockName(par1Str); + } + + @Override + public void registerBlockIcons(IIconRegister par1IconRegister) { + // NO-OP + } + + @Override + public void getSubBlocks(Item par1, CreativeTabs par2, List par3) { + for(int i = 0; i < 4; i++) + par3.add(new ItemStack(par1, 1, i)); + } + + @Override + public void onBlockPlacedBy(World par1World, int par2, int par3, int par4, EntityLivingBase par5EntityLivingBase, ItemStack par6ItemStack) { + int orientation = BlockPistonBase.determineOrientation(par1World, par2, par3, par4, par5EntityLivingBase); + TileSpreader spreader = (TileSpreader) par1World.getTileEntity(par2, par3, par4); + par1World.setBlockMetadataWithNotify(par2, par3, par4, par6ItemStack.getItemDamage(), 1 | 2); + + switch(orientation) { + case 0: + spreader.rotationY = -90F; + break; + case 1: + spreader.rotationY = 90F; + break; + case 2: + spreader.rotationX = 270F; + break; + case 3: + spreader.rotationX = 90F; + break; + case 4: + break; + default: + spreader.rotationX = 180F; + break; + } + } + + @Override + public int damageDropped(int par1) { + return par1; + } + + @Override + public boolean isOpaqueCube() { + return false; + } + + @Override + public boolean renderAsNormalBlock() { + return false; + } + + @Override + public IIcon getIcon(int par1, int par2) { + return par2 >= 2 ? ModBlocks.dreamwood.getIcon(par1, 0) : ModBlocks.livingwood.getIcon(par1, 0); + } + + @Override + public int getRenderType() { + return LibRenderIDs.idSpreader; + } + + @Override + public boolean onBlockActivated(World par1World, int par2, int par3, int par4, EntityPlayer par5EntityPlayer, int par6, float par7, float par8, float par9) { + TileEntity tile = par1World.getTileEntity(par2, par3, par4); + if(!(tile instanceof TileSpreader)) + return false; + + TileSpreader spreader = (TileSpreader) tile; + ItemStack lens = spreader.getStackInSlot(0); + ItemStack heldItem = par5EntityPlayer.getCurrentEquippedItem(); + boolean isHeldItemLens = heldItem != null && heldItem.getItem() instanceof ILens; + boolean wool = heldItem != null && heldItem.getItem() == Item.getItemFromBlock(Blocks.wool); + + if(heldItem != null) + if(heldItem.getItem() == ModItems.twigWand) + return false; + + if(lens == null && isHeldItemLens) { + if (!par5EntityPlayer.capabilities.isCreativeMode) + par5EntityPlayer.inventory.setInventorySlotContents(par5EntityPlayer.inventory.currentItem, null); + + spreader.setInventorySlotContents(0, heldItem.copy()); + spreader.markDirty(); + } else if(lens != null && !wool) { + ItemStack add = lens.copy(); + if(!par5EntityPlayer.inventory.addItemStackToInventory(add)) + par5EntityPlayer.dropPlayerItemWithRandomChoice(add, false); + spreader.setInventorySlotContents(0, null); + spreader.markDirty(); + } + + if(wool && spreader.paddingColor == -1) { + spreader.paddingColor = heldItem.getItemDamage(); + heldItem.stackSize--; + if(heldItem.stackSize == 0) + par5EntityPlayer.inventory.setInventorySlotContents(par5EntityPlayer.inventory.currentItem, null); + } else if(heldItem == null && spreader.paddingColor != -1 && lens == null) { + ItemStack pad = new ItemStack(Blocks.wool, 1, spreader.paddingColor); + if(!par5EntityPlayer.inventory.addItemStackToInventory(pad)) + par5EntityPlayer.dropPlayerItemWithRandomChoice(pad, false); + spreader.paddingColor = -1; + spreader.markDirty(); + } + + return true; + } + + @Override + public void breakBlock(World par1World, int par2, int par3, int par4, Block par5, int par6) { + TileEntity tile = par1World.getTileEntity(par2, par3, par4); + if(!(tile instanceof TileSpreader)) + return; + + TileSpreader inv = (TileSpreader) tile; + + if (inv != null) { + for (int j1 = 0; j1 < inv.getSizeInventory() + 1; ++j1) { + ItemStack itemstack = j1 >= inv.getSizeInventory() ? inv.paddingColor == -1 ? null : new ItemStack(Blocks.wool, 1, inv.paddingColor) : inv.getStackInSlot(j1); + + if(itemstack != null) { + float f = random.nextFloat() * 0.8F + 0.1F; + float f1 = random.nextFloat() * 0.8F + 0.1F; + EntityItem entityitem; + + for (float f2 = random.nextFloat() * 0.8F + 0.1F; itemstack.stackSize > 0; par1World.spawnEntityInWorld(entityitem)) { + int k1 = random.nextInt(21) + 10; + + if (k1 > itemstack.stackSize) + k1 = itemstack.stackSize; + + itemstack.stackSize -= k1; + entityitem = new EntityItem(par1World, par2 + f, par3 + f1, par4 + f2, new ItemStack(itemstack.getItem(), k1, itemstack.getItemDamage())); + float f3 = 0.05F; + entityitem.motionX = (float)random.nextGaussian() * f3; + entityitem.motionY = (float)random.nextGaussian() * f3 + 0.2F; + entityitem.motionZ = (float)random.nextGaussian() * f3; + + if (itemstack.hasTagCompound()) + entityitem.getEntityItem().setTagCompound((NBTTagCompound)itemstack.getTagCompound().copy()); + } + } + } + + par1World.func_147453_f(par2, par3, par4, par5); + } + + super.breakBlock(par1World, par2, par3, par4, par5, par6); + } + + @Override + public boolean onUsedByWand(EntityPlayer player, ItemStack stack, World world, int x, int y, int z, int side) { + ((TileSpreader) world.getTileEntity(x, y, z)).onWanded(player, stack); + return true; + } + + @Override + public TileEntity createNewTileEntity(World world, int meta) { + return new TileSpreader(); + } + + @Override + public void renderHUD(Minecraft mc, ScaledResolution res, World world, int x, int y, int z) { + ((TileSpreader) world.getTileEntity(x, y, z)).renderHUD(mc, res); + } + + @Override + public LexiconEntry getEntry(World world, int x, int y, int z, EntityPlayer player, ItemStack lexicon) { + int meta = world.getBlockMetadata(x, y, z); + return meta == 0 ? LexiconData.spreader : meta == 1 ? LexiconData.redstoneSpreader : LexiconData.dreamwoodSpreader; + } + + @Override + public AxisAlignedBB getWireframeAABB(World world, int x, int y, int z) { + float f = 1F / 16F; + return AxisAlignedBB.getBoundingBox(x + f, y + f, z + f, x + 1 - f, y + 1 - f, z + 1 - f); + } -public class BlockSpreader extends BlockModContainer - implements IWandable, IWandHUD, ILexiconable, IWireframeAABBProvider { - - Random random; - - public BlockSpreader() { - super(Material.wood); - setHardness(2.0F); - setStepSound(soundTypeWood); - setBlockName(LibBlockNames.SPREADER); - - random = new Random(); - } - - @Override - protected boolean shouldRegisterInNameSet() { - return false; - } - - @Override - public Block setBlockName(String par1Str) { - GameRegistry.registerBlock(this, ItemBlockWithMetadataAndName.class, par1Str); - return super.setBlockName(par1Str); - } - - @Override - public void registerBlockIcons(IIconRegister par1IconRegister) { - // NO-OP - } - - @Override - public void getSubBlocks(Item par1, CreativeTabs par2, List par3) { - for (int i = 0; i < 4; i++) par3.add(new ItemStack(par1, 1, i)); - } - - @Override - public void onBlockPlacedBy( - World par1World, - int par2, - int par3, - int par4, - EntityLivingBase par5EntityLivingBase, - ItemStack par6ItemStack) { - int orientation = BlockPistonBase.determineOrientation(par1World, par2, par3, par4, par5EntityLivingBase); - TileSpreader spreader = (TileSpreader) par1World.getTileEntity(par2, par3, par4); - par1World.setBlockMetadataWithNotify(par2, par3, par4, par6ItemStack.getItemDamage(), 1 | 2); - - switch (orientation) { - case 0: - spreader.rotationY = -90F; - break; - case 1: - spreader.rotationY = 90F; - break; - case 2: - spreader.rotationX = 270F; - break; - case 3: - spreader.rotationX = 90F; - break; - case 4: - break; - default: - spreader.rotationX = 180F; - break; - } - } - - @Override - public int damageDropped(int par1) { - return par1; - } - - @Override - public boolean isOpaqueCube() { - return false; - } - - @Override - public boolean renderAsNormalBlock() { - return false; - } - - @Override - public IIcon getIcon(int par1, int par2) { - return par2 >= 2 ? ModBlocks.dreamwood.getIcon(par1, 0) : ModBlocks.livingwood.getIcon(par1, 0); - } - - @Override - public int getRenderType() { - return LibRenderIDs.idSpreader; - } - - @Override - public boolean onBlockActivated( - World par1World, - int par2, - int par3, - int par4, - EntityPlayer par5EntityPlayer, - int par6, - float par7, - float par8, - float par9) { - TileEntity tile = par1World.getTileEntity(par2, par3, par4); - if (!(tile instanceof TileSpreader)) return false; - - TileSpreader spreader = (TileSpreader) tile; - ItemStack lens = spreader.getStackInSlot(0); - ItemStack heldItem = par5EntityPlayer.getCurrentEquippedItem(); - boolean isHeldItemLens = heldItem != null && heldItem.getItem() instanceof ILens; - boolean wool = heldItem != null && heldItem.getItem() == Item.getItemFromBlock(Blocks.wool); - - if (heldItem != null) if (heldItem.getItem() == ModItems.twigWand) return false; - - if (lens == null && isHeldItemLens) { - if (!par5EntityPlayer.capabilities.isCreativeMode) - par5EntityPlayer.inventory.setInventorySlotContents(par5EntityPlayer.inventory.currentItem, null); - - spreader.setInventorySlotContents(0, heldItem.copy()); - spreader.markDirty(); - } else if (lens != null && !wool) { - ItemStack add = lens.copy(); - if (!par5EntityPlayer.inventory.addItemStackToInventory(add)) - par5EntityPlayer.dropPlayerItemWithRandomChoice(add, false); - spreader.setInventorySlotContents(0, null); - spreader.markDirty(); - } - - if (wool && spreader.paddingColor == -1) { - spreader.paddingColor = heldItem.getItemDamage(); - heldItem.stackSize--; - if (heldItem.stackSize == 0) - par5EntityPlayer.inventory.setInventorySlotContents(par5EntityPlayer.inventory.currentItem, null); - } else if (heldItem == null && spreader.paddingColor != -1 && lens == null) { - ItemStack pad = new ItemStack(Blocks.wool, 1, spreader.paddingColor); - if (!par5EntityPlayer.inventory.addItemStackToInventory(pad)) - par5EntityPlayer.dropPlayerItemWithRandomChoice(pad, false); - spreader.paddingColor = -1; - spreader.markDirty(); - } - - return true; - } - - @Override - public void breakBlock(World par1World, int par2, int par3, int par4, Block par5, int par6) { - TileEntity tile = par1World.getTileEntity(par2, par3, par4); - if (!(tile instanceof TileSpreader)) return; - - TileSpreader inv = (TileSpreader) tile; - - if (inv != null) { - for (int j1 = 0; j1 < inv.getSizeInventory() + 1; ++j1) { - ItemStack itemstack = j1 >= inv.getSizeInventory() - ? inv.paddingColor == -1 ? null : new ItemStack(Blocks.wool, 1, inv.paddingColor) - : inv.getStackInSlot(j1); - - if (itemstack != null) { - float f = random.nextFloat() * 0.8F + 0.1F; - float f1 = random.nextFloat() * 0.8F + 0.1F; - EntityItem entityitem; - - for (float f2 = random.nextFloat() * 0.8F + 0.1F; - itemstack.stackSize > 0; - par1World.spawnEntityInWorld(entityitem)) { - int k1 = random.nextInt(21) + 10; - - if (k1 > itemstack.stackSize) k1 = itemstack.stackSize; - - itemstack.stackSize -= k1; - entityitem = new EntityItem( - par1World, - par2 + f, - par3 + f1, - par4 + f2, - new ItemStack(itemstack.getItem(), k1, itemstack.getItemDamage())); - float f3 = 0.05F; - entityitem.motionX = (float) random.nextGaussian() * f3; - entityitem.motionY = (float) random.nextGaussian() * f3 + 0.2F; - entityitem.motionZ = (float) random.nextGaussian() * f3; - - if (itemstack.hasTagCompound()) - entityitem.getEntityItem().setTagCompound((NBTTagCompound) - itemstack.getTagCompound().copy()); - } - } - } - - par1World.func_147453_f(par2, par3, par4, par5); - } - - super.breakBlock(par1World, par2, par3, par4, par5, par6); - } - - @Override - public boolean onUsedByWand(EntityPlayer player, ItemStack stack, World world, int x, int y, int z, int side) { - ((TileSpreader) world.getTileEntity(x, y, z)).onWanded(player, stack); - return true; - } - - @Override - public TileEntity createNewTileEntity(World world, int meta) { - return new TileSpreader(); - } - - @Override - public void renderHUD(Minecraft mc, ScaledResolution res, World world, int x, int y, int z) { - ((TileSpreader) world.getTileEntity(x, y, z)).renderHUD(mc, res); - } - - @Override - public LexiconEntry getEntry(World world, int x, int y, int z, EntityPlayer player, ItemStack lexicon) { - int meta = world.getBlockMetadata(x, y, z); - return meta == 0 - ? LexiconData.spreader - : meta == 1 ? LexiconData.redstoneSpreader : LexiconData.dreamwoodSpreader; - } - - @Override - public AxisAlignedBB getWireframeAABB(World world, int x, int y, int z) { - float f = 1F / 16F; - return AxisAlignedBB.getBoundingBox(x + f, y + f, z + f, x + 1 - f, y + 1 - f, z + 1 - f); - } } diff --git a/src/main/java/vazkii/botania/common/block/mana/BlockTerraPlate.java b/src/main/java/vazkii/botania/common/block/mana/BlockTerraPlate.java index a770d7ab98..c5579a6823 100644 --- a/src/main/java/vazkii/botania/common/block/mana/BlockTerraPlate.java +++ b/src/main/java/vazkii/botania/common/block/mana/BlockTerraPlate.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Nov 8, 2014, 5:25:12 PM (GMT)] */ package vazkii.botania.common.block.mana; @@ -31,92 +31,95 @@ public class BlockTerraPlate extends BlockModContainer implements ILexiconable { - public static IIcon overlay; - IIcon[] icons; - - public BlockTerraPlate() { - super(Material.iron); - setBlockBounds(0F, 0F, 0F, 1F, 3F / 16F, 1F); - setHardness(3F); - setResistance(10F); - setStepSound(soundTypeMetal); - setBlockName(LibBlockNames.TERRA_PLATE); - - BotaniaAPI.blacklistBlockFromMagnet(this, Short.MAX_VALUE); - } - - @Override - public boolean onBlockActivated( - World worldObj, int x, int y, int z, EntityPlayer player, int s, float xs, float ys, float zs) { - ItemStack stack = player.getCurrentEquippedItem(); - if (stack != null && stack.getItem() == ModItems.manaResource && stack.getItemDamage() < 3) { - if (player == null || !player.capabilities.isCreativeMode) { - stack.stackSize--; - if (stack.stackSize == 0 && player != null) - player.inventory.setInventorySlotContents(player.inventory.currentItem, null); - } - - ItemStack target = stack.copy(); - target.stackSize = 1; - EntityItem item = new EntityItem(worldObj, x + 0.5, y + 0.5, z + 0.5, target); - item.delayBeforeCanPickup = 40; - item.motionX = item.motionY = item.motionZ = 0; - if (!worldObj.isRemote) worldObj.spawnEntityInWorld(item); - - return true; - } - - return false; - } - - @Override - public boolean renderAsNormalBlock() { - return false; - } - - @Override - public boolean isOpaqueCube() { - return false; - } - - @Override - public boolean getBlocksMovement(IBlockAccess p_149655_1_, int p_149655_2_, int p_149655_3_, int p_149655_4_) { - return false; - } - - @Override - public void registerBlockIcons(IIconRegister par1IconRegister) { - icons = new IIcon[3]; - for (int i = 0; i < icons.length; i++) icons[i] = IconHelper.forBlock(par1IconRegister, this, i); - overlay = IconHelper.forBlock(par1IconRegister, this, "Overlay"); - } - - @Override - public IIcon getIcon(int par1, int par2) { - return icons[Math.min(2, par1)]; - } - - @Override - public TileEntity createNewTileEntity(World world, int meta) { - return new TileTerraPlate(); - } - - @Override - public LexiconEntry getEntry(World world, int x, int y, int z, EntityPlayer player, ItemStack lexicon) { - return LexiconData.terrasteel; - } - - @Override - public boolean hasComparatorInputOverride() { - return true; - } - - @Override - public int getComparatorInputOverride(World par1World, int par2, int par3, int par4, int par5) { - TileTerraPlate plate = (TileTerraPlate) par1World.getTileEntity(par2, par3, par4); - int val = (int) ((double) plate.getCurrentMana() / (double) TileTerraPlate.MAX_MANA * 15.0); - if (plate.getCurrentMana() > 0) val = Math.max(val, 1); - - return val; - } + public static IIcon overlay; + IIcon[] icons; + + public BlockTerraPlate() { + super(Material.iron); + setBlockBounds(0F, 0F, 0F, 1F, 3F / 16F, 1F); + setHardness(3F); + setResistance(10F); + setStepSound(soundTypeMetal); + setBlockName(LibBlockNames.TERRA_PLATE); + + BotaniaAPI.blacklistBlockFromMagnet(this, Short.MAX_VALUE); + } + + @Override + public boolean onBlockActivated(World worldObj, int x, int y, int z, EntityPlayer player, int s, float xs, float ys, float zs) { + ItemStack stack = player.getCurrentEquippedItem(); + if(stack != null && stack.getItem() == ModItems.manaResource && stack.getItemDamage() < 3) { + if(player == null || !player.capabilities.isCreativeMode) { + stack.stackSize--; + if(stack.stackSize == 0 && player != null) + player.inventory.setInventorySlotContents(player.inventory.currentItem, null); + } + + ItemStack target = stack.copy(); + target.stackSize = 1; + EntityItem item = new EntityItem(worldObj, x + 0.5, y + 0.5, z + 0.5, target); + item.delayBeforeCanPickup = 40; + item.motionX = item.motionY = item.motionZ = 0; + if(!worldObj.isRemote) + worldObj.spawnEntityInWorld(item); + + return true; + } + + return false; + } + + @Override + public boolean renderAsNormalBlock() { + return false; + } + + @Override + public boolean isOpaqueCube() { + return false; + } + + @Override + public boolean getBlocksMovement(IBlockAccess p_149655_1_, int p_149655_2_, int p_149655_3_, int p_149655_4_) { + return false; + } + + @Override + public void registerBlockIcons(IIconRegister par1IconRegister) { + icons = new IIcon[3]; + for(int i = 0; i < icons.length; i++) + icons[i] = IconHelper.forBlock(par1IconRegister, this, i); + overlay = IconHelper.forBlock(par1IconRegister, this, "Overlay"); + } + + @Override + public IIcon getIcon(int par1, int par2) { + return icons[Math.min(2, par1)]; + } + + @Override + public TileEntity createNewTileEntity(World world, int meta) { + return new TileTerraPlate(); + } + + @Override + public LexiconEntry getEntry(World world, int x, int y, int z, EntityPlayer player, ItemStack lexicon) { + return LexiconData.terrasteel; + } + + @Override + public boolean hasComparatorInputOverride() { + return true; + } + + @Override + public int getComparatorInputOverride(World par1World, int par2, int par3, int par4, int par5) { + TileTerraPlate plate = (TileTerraPlate) par1World.getTileEntity(par2, par3, par4); + int val = (int) ((double) plate.getCurrentMana() / (double) TileTerraPlate.MAX_MANA * 15.0); + if(plate.getCurrentMana() > 0) + val = Math.max(val, 1); + + return val; + } + } diff --git a/src/main/java/vazkii/botania/common/block/mana/BlockTurntable.java b/src/main/java/vazkii/botania/common/block/mana/BlockTurntable.java index efeab06bc9..ea88ef91c0 100644 --- a/src/main/java/vazkii/botania/common/block/mana/BlockTurntable.java +++ b/src/main/java/vazkii/botania/common/block/mana/BlockTurntable.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Mar 16, 2014, 10:08:14 PM (GMT)] */ package vazkii.botania.common.block.mana; @@ -31,44 +31,46 @@ public class BlockTurntable extends BlockModContainer implements IWandable, IWandHUD, ILexiconable { - IIcon[] icons; + IIcon[] icons; - public BlockTurntable() { - super(Material.wood); - setHardness(2.0F); - setStepSound(soundTypeWood); - setBlockName(LibBlockNames.TURNTABLE); - } + public BlockTurntable() { + super(Material.wood); + setHardness(2.0F); + setStepSound(soundTypeWood); + setBlockName(LibBlockNames.TURNTABLE); + } - @Override - public void registerBlockIcons(IIconRegister par1IconRegister) { - icons = new IIcon[2]; - for (int i = 0; i < icons.length; i++) icons[i] = IconHelper.forBlock(par1IconRegister, this, i); - } + @Override + public void registerBlockIcons(IIconRegister par1IconRegister) { + icons = new IIcon[2]; + for(int i = 0; i < icons.length; i++) + icons[i] = IconHelper.forBlock(par1IconRegister, this, i); + } - @Override - public IIcon getIcon(int par1, int par2) { - return par1 == 1 ? icons[0] : icons[1]; - } + @Override + public IIcon getIcon(int par1, int par2) { + return par1 == 1 ? icons[0] : icons[1]; + } - @Override - public TileEntity createNewTileEntity(World world, int meta) { - return new TileTurntable(); - } + @Override + public TileEntity createNewTileEntity(World world, int meta) { + return new TileTurntable(); + } - @Override - public void renderHUD(Minecraft mc, ScaledResolution res, World world, int x, int y, int z) { - ((TileTurntable) world.getTileEntity(x, y, z)).renderHUD(mc, res); - } + @Override + public void renderHUD(Minecraft mc, ScaledResolution res, World world, int x, int y, int z) { + ((TileTurntable) world.getTileEntity(x, y, z)).renderHUD(mc, res); + } - @Override - public boolean onUsedByWand(EntityPlayer player, ItemStack stack, World world, int x, int y, int z, int side) { - ((TileTurntable) world.getTileEntity(x, y, z)).onWanded(player, stack); - return true; - } + @Override + public boolean onUsedByWand(EntityPlayer player, ItemStack stack, World world, int x, int y, int z, int side) { + ((TileTurntable) world.getTileEntity(x, y, z)).onWanded(player, stack); + return true; + } + + @Override + public LexiconEntry getEntry(World world, int x, int y, int z, EntityPlayer player, ItemStack lexicon) { + return LexiconData.turntable; + } - @Override - public LexiconEntry getEntry(World world, int x, int y, int z, EntityPlayer player, ItemStack lexicon) { - return LexiconData.turntable; - } } diff --git a/src/main/java/vazkii/botania/common/block/string/BlockRedString.java b/src/main/java/vazkii/botania/common/block/string/BlockRedString.java index 746a18e8f4..d87199730e 100644 --- a/src/main/java/vazkii/botania/common/block/string/BlockRedString.java +++ b/src/main/java/vazkii/botania/common/block/string/BlockRedString.java @@ -2,16 +2,14 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Nov 14, 2014, 4:43:14 PM (GMT)] */ package vazkii.botania.common.block.string; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; import net.minecraft.block.BlockPistonBase; import net.minecraft.block.material.Material; import net.minecraft.client.renderer.texture.IIconRegister; @@ -29,56 +27,53 @@ import vazkii.botania.common.block.BlockModContainer; import vazkii.botania.common.block.tile.string.TileRedString; import vazkii.botania.common.lexicon.LexiconData; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; public abstract class BlockRedString extends BlockModContainer implements ILexiconable { - IIcon senderIcon; - IIcon sideIcon; + IIcon senderIcon; + IIcon sideIcon; + + public BlockRedString(String name) { + super(Material.rock); + setHardness(2.0F); + setResistance(10.0F); + setStepSound(soundTypeStone); + setBlockName(name); + } - public BlockRedString(String name) { - super(Material.rock); - setHardness(2.0F); - setResistance(10.0F); - setStepSound(soundTypeStone); - setBlockName(name); - } + @Override + public void onBlockPlacedBy(World par1World, int par2, int par3, int par4, EntityLivingBase par5EntityLivingBase, ItemStack par6ItemStack) { + int orientation = BlockPistonBase.determineOrientation(par1World, par2, par3, par4, par5EntityLivingBase); + par1World.setBlockMetadataWithNotify(par2, par3, par4, orientation, 1 | 2); + } - @Override - public void onBlockPlacedBy( - World par1World, - int par2, - int par3, - int par4, - EntityLivingBase par5EntityLivingBase, - ItemStack par6ItemStack) { - int orientation = BlockPistonBase.determineOrientation(par1World, par2, par3, par4, par5EntityLivingBase); - par1World.setBlockMetadataWithNotify(par2, par3, par4, orientation, 1 | 2); - } + @Override + public boolean rotateBlock(World worldObj, int x, int y, int z, ForgeDirection axis) { + return RotationHelper.rotateVanillaBlock(Blocks.piston, worldObj, x, y, z, axis); + } - @Override - public boolean rotateBlock(World worldObj, int x, int y, int z, ForgeDirection axis) { - return RotationHelper.rotateVanillaBlock(Blocks.piston, worldObj, x, y, z, axis); - } + @Override + @SideOnly(Side.CLIENT) + public void registerBlockIcons(IIconRegister par1IconRegister) { + senderIcon = IconHelper.forName(par1IconRegister, "redStringSender"); + sideIcon = registerSideIcon(par1IconRegister); + } - @Override - @SideOnly(Side.CLIENT) - public void registerBlockIcons(IIconRegister par1IconRegister) { - senderIcon = IconHelper.forName(par1IconRegister, "redStringSender"); - sideIcon = registerSideIcon(par1IconRegister); - } + @SideOnly(Side.CLIENT) + public IIcon registerSideIcon(IIconRegister register) { + return IconHelper.forBlock(register, this); + } - @SideOnly(Side.CLIENT) - public IIcon registerSideIcon(IIconRegister register) { - return IconHelper.forBlock(register, this); - } + @Override + public IIcon getIcon(int side, int meta) { + return side == meta ? senderIcon : sideIcon; + } - @Override - public IIcon getIcon(int side, int meta) { - return side == meta ? senderIcon : sideIcon; - } + @Override + public LexiconEntry getEntry(World world, int x, int y, int z, EntityPlayer player, ItemStack lexicon) { + return LexiconData.redString; + } - @Override - public LexiconEntry getEntry(World world, int x, int y, int z, EntityPlayer player, ItemStack lexicon) { - return LexiconData.redString; - } } diff --git a/src/main/java/vazkii/botania/common/block/string/BlockRedStringComparator.java b/src/main/java/vazkii/botania/common/block/string/BlockRedStringComparator.java index 7415144db8..02db2de057 100644 --- a/src/main/java/vazkii/botania/common/block/string/BlockRedStringComparator.java +++ b/src/main/java/vazkii/botania/common/block/string/BlockRedStringComparator.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Nov 16, 2014, 10:19:28 PM (GMT)] */ package vazkii.botania.common.block.string; @@ -17,22 +17,23 @@ public class BlockRedStringComparator extends BlockRedString { - public BlockRedStringComparator() { - super(LibBlockNames.RED_STRING_COMPARATOR); - } + public BlockRedStringComparator() { + super(LibBlockNames.RED_STRING_COMPARATOR); + } - @Override - public boolean hasComparatorInputOverride() { - return true; - } + @Override + public boolean hasComparatorInputOverride() { + return true; + } - @Override - public int getComparatorInputOverride(World world, int x, int y, int z, int side) { - return ((TileRedStringComparator) world.getTileEntity(x, y, z)).getComparatorValue(); - } + @Override + public int getComparatorInputOverride(World world, int x, int y, int z, int side) { + return ((TileRedStringComparator) world.getTileEntity(x, y, z)).getComparatorValue(); + } + + @Override + public TileRedString createNewTileEntity(World world, int meta) { + return new TileRedStringComparator(); + } - @Override - public TileRedString createNewTileEntity(World world, int meta) { - return new TileRedStringComparator(); - } } diff --git a/src/main/java/vazkii/botania/common/block/string/BlockRedStringContainer.java b/src/main/java/vazkii/botania/common/block/string/BlockRedStringContainer.java index 351d7690c9..3fc3f6cd05 100644 --- a/src/main/java/vazkii/botania/common/block/string/BlockRedStringContainer.java +++ b/src/main/java/vazkii/botania/common/block/string/BlockRedStringContainer.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Nov 14, 2014, 5:29:56 PM (GMT)] */ package vazkii.botania.common.block.string; @@ -17,12 +17,13 @@ public class BlockRedStringContainer extends BlockRedString { - public BlockRedStringContainer() { - super(LibBlockNames.RED_STRING_CONTAINER); - } + public BlockRedStringContainer() { + super(LibBlockNames.RED_STRING_CONTAINER); + } + + @Override + public TileRedString createNewTileEntity(World world, int meta) { + return new TileRedStringContainer(); + } - @Override - public TileRedString createNewTileEntity(World world, int meta) { - return new TileRedStringContainer(); - } } diff --git a/src/main/java/vazkii/botania/common/block/string/BlockRedStringDispenser.java b/src/main/java/vazkii/botania/common/block/string/BlockRedStringDispenser.java index 83badcb59a..9ef22db23a 100644 --- a/src/main/java/vazkii/botania/common/block/string/BlockRedStringDispenser.java +++ b/src/main/java/vazkii/botania/common/block/string/BlockRedStringDispenser.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Nov 14, 2014, 10:59:20 PM (GMT)] */ package vazkii.botania.common.block.string; @@ -18,25 +18,26 @@ public class BlockRedStringDispenser extends BlockRedString { - public BlockRedStringDispenser() { - super(LibBlockNames.RED_STRING_DISPENSER); - } + public BlockRedStringDispenser() { + super(LibBlockNames.RED_STRING_DISPENSER); + } - @Override - public void onNeighborBlockChange(World world, int x, int y, int z, Block block) { - boolean power = - world.isBlockIndirectlyGettingPowered(x, y, z) || world.isBlockIndirectlyGettingPowered(x, y + 1, z); - int meta = world.getBlockMetadata(x, y, z); - boolean powered = (meta & 8) != 0; + @Override + public void onNeighborBlockChange(World world, int x, int y, int z, Block block) { + boolean power = world.isBlockIndirectlyGettingPowered(x, y, z) || world.isBlockIndirectlyGettingPowered(x, y + 1, z); + int meta = world.getBlockMetadata(x, y, z); + boolean powered = (meta & 8) != 0; - if (power && !powered) { - ((TileRedStringDispenser) world.getTileEntity(x, y, z)).tickDispenser(); - world.setBlockMetadataWithNotify(x, y, z, meta | 8, 4); - } else if (!power && powered) world.setBlockMetadataWithNotify(x, y, z, meta & -9, 4); - } + if(power && !powered) { + ((TileRedStringDispenser) world.getTileEntity(x, y, z)).tickDispenser(); + world.setBlockMetadataWithNotify(x, y, z, meta | 8, 4); + } else if(!power && powered) + world.setBlockMetadataWithNotify(x, y, z, meta & -9, 4); + } + + @Override + public TileRedString createNewTileEntity(World world, int meta) { + return new TileRedStringDispenser(); + } - @Override - public TileRedString createNewTileEntity(World world, int meta) { - return new TileRedStringDispenser(); - } } diff --git a/src/main/java/vazkii/botania/common/block/string/BlockRedStringFertilizer.java b/src/main/java/vazkii/botania/common/block/string/BlockRedStringFertilizer.java index d18dac5184..2483d69e02 100644 --- a/src/main/java/vazkii/botania/common/block/string/BlockRedStringFertilizer.java +++ b/src/main/java/vazkii/botania/common/block/string/BlockRedStringFertilizer.java @@ -2,15 +2,16 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Nov 16, 2014, 7:10:46 PM (GMT)] */ package vazkii.botania.common.block.string; import java.util.Random; + import net.minecraft.block.IGrowable; import net.minecraft.world.World; import vazkii.botania.common.block.tile.string.TileRedString; @@ -19,27 +20,28 @@ public class BlockRedStringFertilizer extends BlockRedString implements IGrowable { - public BlockRedStringFertilizer() { - super(LibBlockNames.RED_STRING_FERTILIZER); - } - - @Override - public boolean func_149851_a(World world, int x, int y, int z, boolean something) { - return ((TileRedStringFertilizer) world.getTileEntity(x, y, z)).func_149851_a(world, something); - } - - @Override - public boolean func_149852_a(World world, Random rand, int x, int y, int z) { - return ((TileRedStringFertilizer) world.getTileEntity(x, y, z)).func_149852_a(world, rand); - } - - @Override - public void func_149853_b(World world, Random rand, int x, int y, int z) { - ((TileRedStringFertilizer) world.getTileEntity(x, y, z)).func_149853_b(world, rand); - } - - @Override - public TileRedString createNewTileEntity(World world, int meta) { - return new TileRedStringFertilizer(); - } + public BlockRedStringFertilizer() { + super(LibBlockNames.RED_STRING_FERTILIZER); + } + + @Override + public boolean func_149851_a(World world, int x, int y, int z, boolean something) { + return ((TileRedStringFertilizer) world.getTileEntity(x, y, z)).func_149851_a(world, something); + } + + @Override + public boolean func_149852_a(World world, Random rand, int x, int y, int z) { + return ((TileRedStringFertilizer) world.getTileEntity(x, y, z)).func_149852_a(world, rand); + } + + @Override + public void func_149853_b(World world, Random rand, int x, int y, int z) { + ((TileRedStringFertilizer) world.getTileEntity(x, y, z)).func_149853_b(world, rand); + } + + @Override + public TileRedString createNewTileEntity(World world, int meta) { + return new TileRedStringFertilizer(); + } + } diff --git a/src/main/java/vazkii/botania/common/block/string/BlockRedStringInterceptor.java b/src/main/java/vazkii/botania/common/block/string/BlockRedStringInterceptor.java index a87f16b3d0..6512281e1d 100644 --- a/src/main/java/vazkii/botania/common/block/string/BlockRedStringInterceptor.java +++ b/src/main/java/vazkii/botania/common/block/string/BlockRedStringInterceptor.java @@ -2,16 +2,16 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Sep 21, 2015, 4:56:52 PM (GMT)] */ package vazkii.botania.common.block.string; -import cpw.mods.fml.common.eventhandler.SubscribeEvent; import java.util.Random; + import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; import net.minecraftforge.common.MinecraftForge; @@ -20,42 +20,44 @@ import vazkii.botania.common.block.tile.string.TileRedString; import vazkii.botania.common.block.tile.string.TileRedStringInterceptor; import vazkii.botania.common.lib.LibBlockNames; +import cpw.mods.fml.common.eventhandler.SubscribeEvent; public class BlockRedStringInterceptor extends BlockRedString { - public BlockRedStringInterceptor() { - super(LibBlockNames.RED_STRING_INTERCEPTOR); - MinecraftForge.EVENT_BUS.register(this); - } - - @SubscribeEvent - public void onInteract(PlayerInteractEvent event) { - if (event.action == Action.RIGHT_CLICK_BLOCK) - TileRedStringInterceptor.onInteract(event.entityPlayer, event.world, event.x, event.y, event.z); - } - - @Override - public boolean canProvidePower() { - return true; - } - - @Override - public int isProvidingWeakPower(IBlockAccess world, int x, int y, int z, int side) { - return (world.getBlockMetadata(x, y, z) & 8) == 0 ? 0 : 15; - } - - @Override - public void updateTick(World world, int x, int y, int z, Random update) { - world.setBlockMetadataWithNotify(x, y, z, world.getBlockMetadata(x, y, z) & -9, 1 | 2); - } - - @Override - public int tickRate(World p_149738_1_) { - return 2; - } - - @Override - public TileRedString createNewTileEntity(World world, int meta) { - return new TileRedStringInterceptor(); - } + public BlockRedStringInterceptor() { + super(LibBlockNames.RED_STRING_INTERCEPTOR); + MinecraftForge.EVENT_BUS.register(this); + } + + @SubscribeEvent + public void onInteract(PlayerInteractEvent event) { + if(event.action == Action.RIGHT_CLICK_BLOCK) + TileRedStringInterceptor.onInteract(event.entityPlayer, event.world, event.x, event.y, event.z); + } + + @Override + public boolean canProvidePower() { + return true; + } + + @Override + public int isProvidingWeakPower(IBlockAccess world, int x, int y, int z, int side) { + return (world.getBlockMetadata(x, y, z) & 8) == 0 ? 0 : 15; + } + + @Override + public void updateTick(World world, int x, int y, int z, Random update) { + world.setBlockMetadataWithNotify(x, y, z, world.getBlockMetadata(x, y, z) & -9, 1 | 2); + } + + @Override + public int tickRate(World p_149738_1_) { + return 2; + } + + @Override + public TileRedString createNewTileEntity(World world, int meta) { + return new TileRedStringInterceptor(); + } + } diff --git a/src/main/java/vazkii/botania/common/block/string/BlockRedStringRelay.java b/src/main/java/vazkii/botania/common/block/string/BlockRedStringRelay.java index eaa77f78bb..0a291ff0e7 100644 --- a/src/main/java/vazkii/botania/common/block/string/BlockRedStringRelay.java +++ b/src/main/java/vazkii/botania/common/block/string/BlockRedStringRelay.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Nov 16, 2014, 10:46:48 PM (GMT)] */ package vazkii.botania.common.block.string; @@ -17,12 +17,13 @@ public class BlockRedStringRelay extends BlockRedString { - public BlockRedStringRelay() { - super(LibBlockNames.RED_STRING_RELAY); - } + public BlockRedStringRelay() { + super(LibBlockNames.RED_STRING_RELAY); + } + + @Override + public TileRedString createNewTileEntity(World world, int meta) { + return new TileRedStringRelay(); + } - @Override - public TileRedString createNewTileEntity(World world, int meta) { - return new TileRedStringRelay(); - } } diff --git a/src/main/java/vazkii/botania/common/block/subtile/SubTileDecor.java b/src/main/java/vazkii/botania/common/block/subtile/SubTileDecor.java index 60853b8592..4eb580e278 100644 --- a/src/main/java/vazkii/botania/common/block/subtile/SubTileDecor.java +++ b/src/main/java/vazkii/botania/common/block/subtile/SubTileDecor.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Sep 28, 2015, 10:17:01 PM (GMT)] */ package vazkii.botania.common.block.subtile; @@ -14,14 +14,13 @@ public class SubTileDecor extends SubTileEntity { - @Override - public boolean canUpdate() { - return false; - } + @Override + public boolean canUpdate() { + return false; + } - public static class Daybloom extends SubTileDecor {} + public static class Daybloom extends SubTileDecor { } + public static class Nightshade extends SubTileDecor { } + public static class Hydroangeas extends SubTileDecor { } - public static class Nightshade extends SubTileDecor {} - - public static class Hydroangeas extends SubTileDecor {} } diff --git a/src/main/java/vazkii/botania/common/block/subtile/SubTileManastar.java b/src/main/java/vazkii/botania/common/block/subtile/SubTileManastar.java index 4a90afede0..4c5c45c192 100644 --- a/src/main/java/vazkii/botania/common/block/subtile/SubTileManastar.java +++ b/src/main/java/vazkii/botania/common/block/subtile/SubTileManastar.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jun 6, 2014, 9:57:19 PM (GMT)] */ package vazkii.botania.common.block.subtile; @@ -21,39 +21,31 @@ public class SubTileManastar extends SubTileEntity { - int manaLastTick = -1; - - @Override - public void onUpdate() { - super.onUpdate(); - - int mana = 0; - for (ForgeDirection dir : LibMisc.CARDINAL_DIRECTIONS) { - TileEntity tile = supertile - .getWorldObj() - .getTileEntity(supertile.xCoord + dir.offsetX, supertile.yCoord, supertile.zCoord + dir.offsetZ); - if (tile instanceof IManaPool) mana += ((IManaPool) tile).getCurrentMana(); - } - - if (manaLastTick != -1 && mana != manaLastTick && Math.random() > 0.6) { - boolean more = mana > manaLastTick; - Botania.proxy.wispFX( - supertile.getWorldObj(), - supertile.xCoord + 0.55 + Math.random() * 0.2 - 0.1, - supertile.yCoord + 0.75 + Math.random() * 0.2 - 0.1, - supertile.zCoord + 0.5, - more ? 0.05F : 1F, - 0.05F, - more ? 1F : 0.05F, - (float) Math.random() / 7, - (float) -Math.random() / 50); - } - - if (ticksExisted % 60 == 0) manaLastTick = mana; - } - - @Override - public LexiconEntry getEntry() { - return LexiconData.manastar; - } + int manaLastTick = -1; + + @Override + public void onUpdate() { + super.onUpdate(); + + int mana = 0; + for(ForgeDirection dir : LibMisc.CARDINAL_DIRECTIONS) { + TileEntity tile = supertile.getWorldObj().getTileEntity(supertile.xCoord + dir.offsetX, supertile.yCoord, supertile.zCoord + dir.offsetZ); + if(tile instanceof IManaPool) + mana += ((IManaPool) tile).getCurrentMana(); + } + + if(manaLastTick != -1 && mana != manaLastTick && Math.random() > 0.6) { + boolean more = mana > manaLastTick; + Botania.proxy.wispFX(supertile.getWorldObj(), supertile.xCoord + 0.55 + Math.random() * 0.2 - 0.1, supertile.yCoord + 0.75 + Math.random() * 0.2 - 0.1, supertile.zCoord + 0.5, more ? 0.05F : 1F, 0.05F, more ? 1F : 0.05F, (float) Math.random() / 7, (float) -Math.random() / 50); + } + + if(ticksExisted % 60 == 0) + manaLastTick = mana; + } + + @Override + public LexiconEntry getEntry() { + return LexiconData.manastar; + } + } diff --git a/src/main/java/vazkii/botania/common/block/subtile/SubTilePureDaisy.java b/src/main/java/vazkii/botania/common/block/subtile/SubTilePureDaisy.java index c17b965dd4..0f2b780e35 100644 --- a/src/main/java/vazkii/botania/common/block/subtile/SubTilePureDaisy.java +++ b/src/main/java/vazkii/botania/common/block/subtile/SubTilePureDaisy.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jan 28, 2014, 9:09:39 PM (GMT)] */ package vazkii.botania.common.block.subtile; @@ -25,109 +25,95 @@ public class SubTilePureDaisy extends SubTileEntity { - private static final String TAG_POSITION = "position"; - private static final String TAG_TICKS_REMAINING = "ticksRemaining"; - - private static final int TOTAL_TIME = 1200; - private static final int TIME_PER = TOTAL_TIME / 8; - - private static final int[][] POSITIONS = new int[][] { - {-1, 0, -1}, - {-1, 0, 0}, - {-1, 0, 1}, - {0, 0, 1}, - {1, 0, 1}, - {1, 0, 0}, - {1, 0, -1}, - {0, 0, -1}, - }; - - int positionAt = 0; - int[] ticksRemaining = new int[] {TIME_PER, TIME_PER, TIME_PER, TIME_PER, TIME_PER, TIME_PER, TIME_PER, TIME_PER}; - - @Override - public void onUpdate() { - super.onUpdate(); - - positionAt++; - if (positionAt == POSITIONS.length) positionAt = 0; - - int[] acoords = POSITIONS[positionAt]; - ChunkCoordinates coords = new ChunkCoordinates( - supertile.xCoord + acoords[0], supertile.yCoord + acoords[1], supertile.zCoord + acoords[2]); - World world = supertile.getWorldObj(); - if (!world.isAirBlock(coords.posX, coords.posY, coords.posZ)) { - Block block = world.getBlock(coords.posX, coords.posY, coords.posZ); - int meta = world.getBlockMetadata(coords.posX, coords.posY, coords.posZ); - RecipePureDaisy recipe = null; - for (RecipePureDaisy recipe_ : BotaniaAPI.pureDaisyRecipes) - if (recipe_.matches(world, coords.posX, coords.posY, coords.posZ, this, block, meta)) { - recipe = recipe_; - break; - } - - if (recipe != null) { - ticksRemaining[positionAt] = ticksRemaining[positionAt] - 1; - - Botania.proxy.sparkleFX( - supertile.getWorldObj(), - coords.posX + Math.random(), - coords.posY + Math.random(), - coords.posZ + Math.random(), - 1F, - 1F, - 1F, - (float) Math.random(), - 5); - - if (ticksRemaining[positionAt] <= 0) { - ticksRemaining[positionAt] = TIME_PER; - - if (recipe.set(world, coords.posX, coords.posY, coords.posZ, this)) { - for (int i = 0; i < 25; i++) { - double x = coords.posX + Math.random(); - double y = coords.posY + Math.random() + 0.5; - double z = coords.posZ + Math.random(); - - Botania.proxy.wispFX( - supertile.getWorldObj(), x, y, z, 1F, 1F, 1F, (float) Math.random() / 2F); - } - if (ConfigHandler.blockBreakParticles) - supertile - .getWorldObj() - .playAuxSFX( - 2001, - coords.posX, - coords.posY, - coords.posZ, - Block.getIdFromBlock(recipe.getOutput()) + (recipe.getOutputMeta() << 12)); - } - } - } else ticksRemaining[positionAt] = TIME_PER; - } - } - - @Override - public RadiusDescriptor getRadius() { - return new RadiusDescriptor.Square(toChunkCoordinates(), 1); - } - - @Override - public void readFromPacketNBT(NBTTagCompound cmp) { - positionAt = cmp.getInteger(TAG_POSITION); - - if (supertile.getWorldObj() != null && !supertile.getWorldObj().isRemote) - for (int i = 0; i < ticksRemaining.length; i++) ticksRemaining[i] = cmp.getInteger(TAG_TICKS_REMAINING + i); - } - - @Override - public void writeToPacketNBT(NBTTagCompound cmp) { - cmp.setInteger(TAG_POSITION, positionAt); - for (int i = 0; i < ticksRemaining.length; i++) cmp.setInteger(TAG_TICKS_REMAINING + i, ticksRemaining[i]); - } - - @Override - public LexiconEntry getEntry() { - return LexiconData.pureDaisy; - } + private static final String TAG_POSITION = "position"; + private static final String TAG_TICKS_REMAINING = "ticksRemaining"; + + private static final int TOTAL_TIME = 1200; + private static final int TIME_PER = TOTAL_TIME / 8; + + private static final int[][] POSITIONS = new int[][] { + { -1, 0, -1 }, + { -1, 0, 0 }, + { -1, 0, 1 }, + { 0, 0, 1 }, + { 1, 0, 1 }, + { 1, 0, 0 }, + { 1, 0, -1 }, + { 0, 0, -1 }, + }; + + int positionAt = 0; + int[] ticksRemaining = new int[] { TIME_PER, TIME_PER, TIME_PER, TIME_PER, TIME_PER, TIME_PER, TIME_PER, TIME_PER }; + + @Override + public void onUpdate() { + super.onUpdate(); + + positionAt++; + if(positionAt == POSITIONS.length) + positionAt = 0; + + int[] acoords = POSITIONS[positionAt]; + ChunkCoordinates coords = new ChunkCoordinates(supertile.xCoord + acoords[0], supertile.yCoord + acoords[1], supertile.zCoord + acoords[2]); + World world = supertile.getWorldObj(); + if(!world.isAirBlock(coords.posX, coords.posY, coords.posZ)) { + Block block = world.getBlock(coords.posX, coords.posY, coords.posZ); + int meta = world.getBlockMetadata(coords.posX, coords.posY, coords.posZ); + RecipePureDaisy recipe = null; + for(RecipePureDaisy recipe_ : BotaniaAPI.pureDaisyRecipes) + if(recipe_.matches(world, coords.posX, coords.posY, coords.posZ, this, block, meta)) { + recipe = recipe_; + break; + } + + + if(recipe != null) { + ticksRemaining[positionAt] = ticksRemaining[positionAt] - 1; + + Botania.proxy.sparkleFX(supertile.getWorldObj(), coords.posX + Math.random(), coords.posY + Math.random(), coords.posZ + Math.random(), 1F, 1F, 1F, (float) Math.random(), 5); + + if(ticksRemaining[positionAt] <= 0) { + ticksRemaining[positionAt] = TIME_PER; + + if(recipe.set(world,coords.posX, coords.posY, coords.posZ, this)) { + for(int i = 0; i < 25; i++) { + double x = coords.posX + Math.random(); + double y = coords.posY + Math.random() + 0.5; + double z = coords.posZ + Math.random(); + + Botania.proxy.wispFX(supertile.getWorldObj(), x, y, z, 1F, 1F, 1F, (float) Math.random() / 2F); + } + if(ConfigHandler.blockBreakParticles) + supertile.getWorldObj().playAuxSFX(2001, coords.posX, coords.posY, coords.posZ, Block.getIdFromBlock(recipe.getOutput()) + (recipe.getOutputMeta() << 12)); + } + } + } else ticksRemaining[positionAt] = TIME_PER; + } + } + + @Override + public RadiusDescriptor getRadius() { + return new RadiusDescriptor.Square(toChunkCoordinates(), 1); + } + + @Override + public void readFromPacketNBT(NBTTagCompound cmp) { + positionAt = cmp.getInteger(TAG_POSITION); + + if(supertile.getWorldObj() != null && !supertile.getWorldObj().isRemote) + for(int i = 0; i < ticksRemaining.length; i++) + ticksRemaining[i] = cmp.getInteger(TAG_TICKS_REMAINING + i); + } + + @Override + public void writeToPacketNBT(NBTTagCompound cmp) { + cmp.setInteger(TAG_POSITION, positionAt); + for(int i = 0; i < ticksRemaining.length; i++) + cmp.setInteger(TAG_TICKS_REMAINING + i, ticksRemaining[i]); + } + + @Override + public LexiconEntry getEntry() { + return LexiconData.pureDaisy; + } } diff --git a/src/main/java/vazkii/botania/common/block/subtile/functional/SubTileAgricarnation.java b/src/main/java/vazkii/botania/common/block/subtile/functional/SubTileAgricarnation.java index 7982591bff..e6392a57ec 100644 --- a/src/main/java/vazkii/botania/common/block/subtile/functional/SubTileAgricarnation.java +++ b/src/main/java/vazkii/botania/common/block/subtile/functional/SubTileAgricarnation.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Mar 19, 2014, 10:16:53 PM (GMT)] */ package vazkii.botania.common.block.subtile.functional; @@ -25,100 +25,78 @@ public class SubTileAgricarnation extends SubTileFunctional { - private static final int RANGE = 5; - private static final int RANGE_MINI = 2; - - @Override - public void onUpdate() { - super.onUpdate(); - - if (ticksExisted % 6 == 0 && redstoneSignal == 0) { - int range = getRange(); - int x = supertile.xCoord + supertile.getWorldObj().rand.nextInt(range * 2 + 1) - range; - int z = supertile.zCoord + supertile.getWorldObj().rand.nextInt(range * 2 + 1) - range; - - for (int i = 4; i > -2; i--) { - int y = supertile.yCoord + i; - - if (supertile.getWorldObj().isAirBlock(x, y, z)) continue; - - if (isPlant(x, y, z) && mana > 5) { - Block block = supertile.getWorldObj().getBlock(x, y, z); - mana -= 5; - supertile.getWorldObj().scheduleBlockUpdate(x, y, z, block, 1); - if (ConfigHandler.blockBreakParticles) - supertile - .getWorldObj() - .playAuxSFX( - 2005, - x, - y, - z, - 6 + supertile.getWorldObj().rand.nextInt(4)); - supertile - .getWorldObj() - .playSoundEffect( - x, y, z, "botania:agricarnation", 0.01F, 0.5F + (float) Math.random() * 0.5F); - - break; - } - } - } - } - - @Override - public boolean acceptsRedstone() { - return true; - } - - boolean isPlant(int x, int y, int z) { - Block block = supertile.getWorldObj().getBlock(x, y, z); - if (block == Blocks.grass - || block == Blocks.leaves - || block == Blocks.leaves2 - || block instanceof BlockBush && !(block instanceof BlockCrops) && !(block instanceof BlockSapling)) - return false; - - Material mat = block.getMaterial(); - return mat != null - && (mat == Material.plants - || mat == Material.cactus - || mat == Material.grass - || mat == Material.leaves - || mat == Material.gourd) - && block instanceof IGrowable - && ((IGrowable) block) - .func_149851_a(supertile.getWorldObj(), x, y, z, supertile.getWorldObj().isRemote); - } - - @Override - public int getColor() { - return 0x8EF828; - } - - @Override - public int getMaxMana() { - return 200; - } - - public int getRange() { - return RANGE; - } - - @Override - public RadiusDescriptor getRadius() { - return new RadiusDescriptor.Square(toChunkCoordinates(), getRange()); - } - - @Override - public LexiconEntry getEntry() { - return LexiconData.agricarnation; - } - - public static class Mini extends SubTileAgricarnation { - @Override - public int getRange() { - return RANGE_MINI; - } - } + private static final int RANGE = 5; + private static final int RANGE_MINI = 2; + + @Override + public void onUpdate() { + super.onUpdate(); + + if(ticksExisted % 6 == 0 && redstoneSignal == 0) { + int range = getRange(); + int x = supertile.xCoord + supertile.getWorldObj().rand.nextInt(range * 2 + 1) - range; + int z = supertile.zCoord + supertile.getWorldObj().rand.nextInt(range * 2 + 1) - range; + + for(int i = 4; i > -2; i--) { + int y = supertile.yCoord + i; + + if(supertile.getWorldObj().isAirBlock(x, y, z)) + continue; + + if(isPlant(x, y, z) && mana > 5) { + Block block = supertile.getWorldObj().getBlock(x, y, z); + mana -= 5; + supertile.getWorldObj().scheduleBlockUpdate(x, y, z, block, 1); + if(ConfigHandler.blockBreakParticles) + supertile.getWorldObj().playAuxSFX(2005, x, y, z, 6 + supertile.getWorldObj().rand.nextInt(4)); + supertile.getWorldObj().playSoundEffect(x, y, z, "botania:agricarnation", 0.01F, 0.5F + (float) Math.random() * 0.5F); + + break; + } + } + } + } + + @Override + public boolean acceptsRedstone() { + return true; + } + + boolean isPlant(int x, int y, int z) { + Block block = supertile.getWorldObj().getBlock(x, y, z); + if(block == Blocks.grass || block == Blocks.leaves || block == Blocks.leaves2 || block instanceof BlockBush && !(block instanceof BlockCrops) && !(block instanceof BlockSapling)) + return false; + + Material mat = block.getMaterial(); + return mat != null && (mat == Material.plants || mat == Material.cactus || mat == Material.grass || mat == Material.leaves || mat == Material.gourd) && block instanceof IGrowable && ((IGrowable) block).func_149851_a(supertile.getWorldObj(), x, y, z, supertile.getWorldObj().isRemote); + } + + @Override + public int getColor() { + return 0x8EF828; + } + + @Override + public int getMaxMana() { + return 200; + } + + public int getRange() { + return RANGE; + } + + @Override + public RadiusDescriptor getRadius() { + return new RadiusDescriptor.Square(toChunkCoordinates(), getRange()); + } + + @Override + public LexiconEntry getEntry() { + return LexiconData.agricarnation; + } + + public static class Mini extends SubTileAgricarnation { + @Override public int getRange() { return RANGE_MINI; } + } + } diff --git a/src/main/java/vazkii/botania/common/block/subtile/functional/SubTileBellethorn.java b/src/main/java/vazkii/botania/common/block/subtile/functional/SubTileBellethorn.java index 6dfc2874be..52604a8d68 100644 --- a/src/main/java/vazkii/botania/common/block/subtile/functional/SubTileBellethorn.java +++ b/src/main/java/vazkii/botania/common/block/subtile/functional/SubTileBellethorn.java @@ -2,15 +2,16 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jan 27, 2014, 2:47:40 PM (GMT)] */ package vazkii.botania.common.block.subtile.functional; import java.util.List; + import net.minecraft.command.IEntitySelector; import net.minecraft.entity.Entity; import net.minecraft.entity.EntityLivingBase; @@ -25,94 +26,86 @@ public class SubTileBellethorn extends SubTileFunctional { - public static final int RANGE = 6; - public static final int RANGE_MINI = 1; - - @Override - public int getColor() { - return 0xBA3421; - } - - @Override - public int getMaxMana() { - return 1000; - } - - @Override - public void onUpdate() { - super.onUpdate(); - - if (redstoneSignal > 0) return; - - final int manaToUse = getManaCost(); - - if (ticksExisted % 5 == 0) { - int range = getRange(); - List entities = supertile - .getWorldObj() - .getEntitiesWithinAABB( - EntityLivingBase.class, - AxisAlignedBB.getBoundingBox( - supertile.xCoord - range, - supertile.yCoord, - supertile.zCoord - range, - supertile.xCoord + range + 1, - supertile.yCoord + 1, - supertile.zCoord + range + 1)); - IEntitySelector selector = getSelector(); - - for (EntityLivingBase entity : entities) { - if (!selector.isEntityApplicable(entity)) continue; - - if (entity.hurtTime == 0 && mana >= manaToUse) { - int dmg = 4; - if (entity instanceof EntityWitch) dmg = 20; - - entity.attackEntityFrom(DamageSource.magic, dmg); - mana -= manaToUse; - break; - } - } - } - } - - @Override - public boolean acceptsRedstone() { - return true; - } - - public int getManaCost() { - return 24; - } - - public int getRange() { - return RANGE; - } - - public IEntitySelector getSelector() { - return new IEntitySelector() { - - @Override - public boolean isEntityApplicable(Entity entity) { - return !(entity instanceof EntityPlayer); - } - }; - } - - @Override - public RadiusDescriptor getRadius() { - return new RadiusDescriptor.Square(toChunkCoordinates(), getRange()); - } - - @Override - public LexiconEntry getEntry() { - return LexiconData.bellethorne; - } - - public static class Mini extends SubTileBellethorn { - @Override - public int getRange() { - return RANGE_MINI; - } - } + public static final int RANGE = 6; + public static final int RANGE_MINI = 1; + + @Override + public int getColor() { + return 0xBA3421; + } + + @Override + public int getMaxMana() { + return 1000; + } + + @Override + public void onUpdate() { + super.onUpdate(); + + if(redstoneSignal > 0) + return; + + final int manaToUse = getManaCost(); + + if(ticksExisted % 5 == 0) { + int range = getRange(); + List entities = supertile.getWorldObj().getEntitiesWithinAABB(EntityLivingBase.class, AxisAlignedBB.getBoundingBox(supertile.xCoord - range, supertile.yCoord, supertile.zCoord - range, supertile.xCoord + range + 1, supertile.yCoord + 1, supertile.zCoord + range + 1)); + IEntitySelector selector = getSelector(); + + for(EntityLivingBase entity : entities) { + if(!selector.isEntityApplicable(entity)) + continue; + + if(entity.hurtTime == 0 && mana >= manaToUse) { + int dmg = 4; + if(entity instanceof EntityWitch) + dmg = 20; + + entity.attackEntityFrom(DamageSource.magic, dmg); + mana -= manaToUse; + break; + } + } + } + } + + @Override + public boolean acceptsRedstone() { + return true; + } + + public int getManaCost() { + return 24; + } + + public int getRange() { + return RANGE; + } + + public IEntitySelector getSelector() { + return new IEntitySelector() { + + @Override + public boolean isEntityApplicable(Entity entity) { + return !(entity instanceof EntityPlayer); + } + + }; + } + + @Override + public RadiusDescriptor getRadius() { + return new RadiusDescriptor.Square(toChunkCoordinates(), getRange()); + } + + @Override + public LexiconEntry getEntry() { + return LexiconData.bellethorne; + } + + public static class Mini extends SubTileBellethorn { + @Override public int getRange() { return RANGE_MINI; } + } + } diff --git a/src/main/java/vazkii/botania/common/block/subtile/functional/SubTileBubbell.java b/src/main/java/vazkii/botania/common/block/subtile/functional/SubTileBubbell.java index 536b4b484b..10c62757cd 100644 --- a/src/main/java/vazkii/botania/common/block/subtile/functional/SubTileBubbell.java +++ b/src/main/java/vazkii/botania/common/block/subtile/functional/SubTileBubbell.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Apr 10, 2015, 10:28:42 PM (GMT)] */ package vazkii.botania.common.block.subtile.functional; @@ -26,102 +26,88 @@ public class SubTileBubbell extends SubTileFunctional { - private static final int RANGE = 12; - private static final int RANGE_MINI = 6; - private static final int COST_PER_TICK = 4; - private static final String TAG_RANGE = "range"; - - int range = 2; - - @Override - public void onUpdate() { - super.onUpdate(); - - if (mana > COST_PER_TICK) { - mana -= COST_PER_TICK; - - if (ticksExisted % 10 == 0 && range < getRange()) range++; - - for (int i = -range; i < range + 1; i++) - for (int j = -range; j < range + 1; j++) - for (int k = -range; k < range + 1; k++) - if (MathHelper.pointDistanceSpace(i, j, k, 0, 0, 0) < range) { - Block block = supertile - .getWorldObj() - .getBlock(supertile.xCoord + i, supertile.yCoord + j, supertile.zCoord + k); - if (block.getMaterial() == Material.water) { - supertile - .getWorldObj() - .setBlock( - supertile.xCoord + i, - supertile.yCoord + j, - supertile.zCoord + k, - ModBlocks.fakeAir, - 0, - 2); - TileFakeAir air = (TileFakeAir) supertile - .getWorldObj() - .getTileEntity( - supertile.xCoord + i, supertile.yCoord + j, supertile.zCoord + k); - air.setFlower(supertile); - } - } - } - } - - public static boolean isValidBubbell(World world, int x, int y, int z) { - TileEntity tile = world.getTileEntity(x, y, z); - if (tile != null && tile instanceof ISubTileContainer) { - ISubTileContainer container = (ISubTileContainer) tile; - if (container.getSubTile() != null && container.getSubTile() instanceof SubTileBubbell) { - SubTileBubbell bubbell = (SubTileBubbell) container.getSubTile(); - return bubbell.mana > COST_PER_TICK; - } - } - - return false; - } - - @Override - public void writeToPacketNBT(NBTTagCompound cmp) { - super.writeToPacketNBT(cmp); - cmp.setInteger(TAG_RANGE, range); - } - - @Override - public void readFromPacketNBT(NBTTagCompound cmp) { - super.readFromPacketNBT(cmp); - range = cmp.getInteger(TAG_RANGE); - } - - @Override - public int getMaxMana() { - return 2000; - } - - @Override - public int getColor() { - return 0x0DCF89; - } - - public int getRange() { - return RANGE; - } - - @Override - public RadiusDescriptor getRadius() { - return new RadiusDescriptor.Circle(toChunkCoordinates(), range); - } - - @Override - public LexiconEntry getEntry() { - return LexiconData.bubbell; - } - - public static class Mini extends SubTileBubbell { - @Override - public int getRange() { - return RANGE_MINI; - } - } + private static final int RANGE = 12; + private static final int RANGE_MINI = 6; + private static final int COST_PER_TICK = 4; + private static final String TAG_RANGE = "range"; + + int range = 2; + + @Override + public void onUpdate() { + super.onUpdate(); + + if(mana > COST_PER_TICK) { + mana -= COST_PER_TICK; + + if(ticksExisted % 10 == 0 && range < getRange()) + range++; + + for(int i = -range; i < range + 1; i++) + for(int j = -range; j < range + 1; j++) + for(int k = -range; k < range + 1; k++) + if(MathHelper.pointDistanceSpace(i, j, k, 0, 0, 0) < range) { + Block block = supertile.getWorldObj().getBlock(supertile.xCoord + i, supertile.yCoord + j, supertile.zCoord + k); + if(block.getMaterial() == Material.water) { + supertile.getWorldObj().setBlock(supertile.xCoord + i, supertile.yCoord + j, supertile.zCoord + k, ModBlocks.fakeAir, 0, 2); + TileFakeAir air = (TileFakeAir) supertile.getWorldObj().getTileEntity(supertile.xCoord + i, supertile.yCoord + j, supertile.zCoord + k); + air.setFlower(supertile); + } + } + } + } + + public static boolean isValidBubbell(World world, int x, int y, int z) { + TileEntity tile = world.getTileEntity(x, y, z); + if(tile != null && tile instanceof ISubTileContainer) { + ISubTileContainer container = (ISubTileContainer) tile; + if(container.getSubTile() != null && container.getSubTile() instanceof SubTileBubbell) { + SubTileBubbell bubbell = (SubTileBubbell) container.getSubTile(); + return bubbell.mana > COST_PER_TICK; + } + } + + return false; + } + + @Override + public void writeToPacketNBT(NBTTagCompound cmp) { + super.writeToPacketNBT(cmp); + cmp.setInteger(TAG_RANGE, range); + } + + @Override + public void readFromPacketNBT(NBTTagCompound cmp) { + super.readFromPacketNBT(cmp); + range = cmp.getInteger(TAG_RANGE); + } + + @Override + public int getMaxMana() { + return 2000; + } + + @Override + public int getColor() { + return 0x0DCF89; + } + + public int getRange() { + return RANGE; + } + + @Override + public RadiusDescriptor getRadius() { + return new RadiusDescriptor.Circle(toChunkCoordinates(), range); + } + + @Override + public LexiconEntry getEntry() { + return LexiconData.bubbell; + } + + public static class Mini extends SubTileBubbell { + @Override public int getRange() { return RANGE_MINI; } + } + } diff --git a/src/main/java/vazkii/botania/common/block/subtile/functional/SubTileClayconia.java b/src/main/java/vazkii/botania/common/block/subtile/functional/SubTileClayconia.java index b284487663..11e645f5b0 100644 --- a/src/main/java/vazkii/botania/common/block/subtile/functional/SubTileClayconia.java +++ b/src/main/java/vazkii/botania/common/block/subtile/functional/SubTileClayconia.java @@ -2,16 +2,17 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [May 17, 2014, 12:05:37 AM (GMT)] */ package vazkii.botania.common.block.subtile.functional; import java.util.ArrayList; import java.util.List; + import net.minecraft.block.Block; import net.minecraft.entity.item.EntityItem; import net.minecraft.init.Items; @@ -25,101 +26,84 @@ public class SubTileClayconia extends SubTileFunctional { - private static final int COST = 80; - private static final int RANGE = 5; - private static final int RANGE_Y = 3; - - private static final int RANGE_MINI = 2; - private static final int RANGE_Y_MINI = 1; - - @Override - public void onUpdate() { - super.onUpdate(); - - if (!supertile.getWorldObj().isRemote && ticksExisted % 5 == 0) { - if (mana >= COST) { - ChunkCoordinates coords = getCoordsToPut(); - if (coords != null) { - supertile.getWorldObj().setBlockToAir(coords.posX, coords.posY, coords.posZ); - if (ConfigHandler.blockBreakParticles) - supertile - .getWorldObj() - .playAuxSFX( - 2001, - coords.posX, - coords.posY, - coords.posZ, - Block.getIdFromBlock(Block.getBlockFromName("sand"))); - EntityItem item = new EntityItem( - supertile.getWorldObj(), - coords.posX + 0.5, - coords.posY + 0.5, - coords.posZ + 0.5, - new ItemStack(Items.clay_ball)); - supertile.getWorldObj().spawnEntityInWorld(item); - mana -= COST; - } - } - } - } - - public ChunkCoordinates getCoordsToPut() { - List possibleCoords = new ArrayList(); - - int range = getRange(); - int rangeY = getRangeY(); - - for (int i = -range; i < range + 1; i++) - for (int j = -rangeY; j < rangeY + 1; j++) - for (int k = -range; k < range + 1; k++) { - int x = supertile.xCoord + i; - int y = supertile.yCoord + j; - int z = supertile.zCoord + k; - Block block = supertile.getWorldObj().getBlock(x, y, z); - if (block == Block.getBlockFromName("sand")) possibleCoords.add(new ChunkCoordinates(x, y, z)); - } - - if (possibleCoords.isEmpty()) return null; - return possibleCoords.get(supertile.getWorldObj().rand.nextInt(possibleCoords.size())); - } - - @Override - public RadiusDescriptor getRadius() { - return new RadiusDescriptor.Square(toChunkCoordinates(), getRange()); - } - - public int getRange() { - return RANGE; - } - - public int getRangeY() { - return RANGE_Y; - } - - @Override - public int getColor() { - return 0x7B8792; - } - - @Override - public int getMaxMana() { - return 640; - } - - @Override - public LexiconEntry getEntry() { - return LexiconData.clayconia; - } - - public static class Mini extends SubTileClayconia { - @Override - public int getRange() { - return RANGE_MINI; - } - - @Override - public int getRangeY() { - return RANGE_Y_MINI; - } - } + private static final int COST = 80; + private static final int RANGE = 5; + private static final int RANGE_Y = 3; + + private static final int RANGE_MINI = 2; + private static final int RANGE_Y_MINI = 1; + + @Override + public void onUpdate() { + super.onUpdate(); + + if(!supertile.getWorldObj().isRemote && ticksExisted % 5 == 0) { + if(mana >= COST) { + ChunkCoordinates coords = getCoordsToPut(); + if(coords != null) { + supertile.getWorldObj().setBlockToAir(coords.posX, coords.posY, coords.posZ); + if(ConfigHandler.blockBreakParticles) + supertile.getWorldObj().playAuxSFX(2001, coords.posX, coords.posY, coords.posZ, Block.getIdFromBlock(Block.getBlockFromName("sand"))); + EntityItem item = new EntityItem(supertile.getWorldObj(), coords.posX + 0.5, coords.posY + 0.5, coords.posZ + 0.5, new ItemStack(Items.clay_ball)); + supertile.getWorldObj().spawnEntityInWorld(item); + mana -= COST; + } + } + } + } + + public ChunkCoordinates getCoordsToPut() { + List possibleCoords = new ArrayList(); + + int range = getRange(); + int rangeY = getRangeY(); + + for(int i = -range; i < range + 1; i++) + for(int j = -rangeY; j < rangeY + 1; j++) + for(int k = -range; k < range + 1; k++) { + int x = supertile.xCoord + i; + int y = supertile.yCoord + j; + int z = supertile.zCoord + k; + Block block = supertile.getWorldObj().getBlock(x, y, z); + if(block == Block.getBlockFromName("sand")) + possibleCoords.add(new ChunkCoordinates(x, y, z)); + } + + if(possibleCoords.isEmpty()) + return null; + return possibleCoords.get(supertile.getWorldObj().rand.nextInt(possibleCoords.size())); + } + + @Override + public RadiusDescriptor getRadius() { + return new RadiusDescriptor.Square(toChunkCoordinates(), getRange()); + } + + public int getRange() { + return RANGE; + } + + public int getRangeY() { + return RANGE_Y; + } + + @Override + public int getColor() { + return 0x7B8792; + } + + @Override + public int getMaxMana() { + return 640; + } + + @Override + public LexiconEntry getEntry() { + return LexiconData.clayconia; + } + + public static class Mini extends SubTileClayconia { + @Override public int getRange() { return RANGE_MINI; } + @Override public int getRangeY() { return RANGE_Y_MINI; } + } } diff --git a/src/main/java/vazkii/botania/common/block/subtile/functional/SubTileDaffomill.java b/src/main/java/vazkii/botania/common/block/subtile/functional/SubTileDaffomill.java index b4a3b3f683..a4fd3f0b35 100644 --- a/src/main/java/vazkii/botania/common/block/subtile/functional/SubTileDaffomill.java +++ b/src/main/java/vazkii/botania/common/block/subtile/functional/SubTileDaffomill.java @@ -2,15 +2,16 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jun 20, 2014, 11:43:02 PM (GMT)] */ package vazkii.botania.common.block.subtile.functional; import java.util.List; + import net.minecraft.entity.item.EntityItem; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; @@ -25,133 +26,124 @@ public class SubTileDaffomill extends SubTileFunctional { - private static final String TAG_ORIENTATION = "orientation"; - private static final String TAG_WIND_TICKS = "windTicks"; - - int windTicks = 0; - int orientation = 0; - - @Override - public void onUpdate() { - super.onUpdate(); - - ForgeDirection dir = ForgeDirection.getOrientation(orientation + 2); - if (supertile.getWorldObj().rand.nextInt(4) == 0) - Botania.proxy.wispFX( - supertile.getWorldObj(), - supertile.xCoord + Math.random(), - supertile.yCoord + Math.random(), - supertile.zCoord + Math.random(), - 0.05F, - 0.05F, - 0.05F, - 0.25F + (float) Math.random() * 0.15F, - dir.offsetX * 0.1F, - dir.offsetY * 0.1F, - dir.offsetZ * 0.1F); - - if (windTicks == 0 && mana > 0) { - windTicks = 20; - mana--; - } - - if (windTicks > 0 && redstoneSignal == 0) { - AxisAlignedBB axis = aabbForOrientation(); - - if (axis != null) { - List items = supertile.getWorldObj().getEntitiesWithinAABB(EntityItem.class, axis); - int slowdown = getSlowdownFactor(); - for (EntityItem item : items) - if (!item.isDead && item.age >= slowdown) { - item.motionX += dir.offsetX * 0.05; - item.motionY += dir.offsetY * 0.05; - item.motionZ += dir.offsetZ * 0.05; - } - } - - windTicks--; - } - } - - AxisAlignedBB aabbForOrientation() { - int x = supertile.xCoord; - int y = supertile.yCoord; - int z = supertile.zCoord; - int w = 2; - int h = 3; - int l = 16; - - AxisAlignedBB axis = null; - switch (orientation) { - case 0: - axis = AxisAlignedBB.getBoundingBox(x - w, y - h, z - l, x + w + 1, y + h, z); - break; - case 1: - axis = AxisAlignedBB.getBoundingBox(x - w, y - h, z + 1, x + w + 1, y + h, z + l + 1); - break; - case 2: - axis = AxisAlignedBB.getBoundingBox(x - l, y - h, z - w, x, y + h, z + w + 1); - break; - case 3: - axis = AxisAlignedBB.getBoundingBox(x + 1, y - h, z - w, x + l + 1, y + h, z + w + 1); - } - return axis; - } - - @Override - public boolean acceptsRedstone() { - return true; - } - - @Override - public boolean onWanded(EntityPlayer player, ItemStack wand) { - if (player == null) return false; - - if (player.isSneaking()) { - if (!player.worldObj.isRemote) { - orientation = orientation == 3 ? 0 : orientation + 1; - sync(); - } - - return true; - } else return super.onWanded(player, wand); - } - - @Override - public RadiusDescriptor getRadius() { - AxisAlignedBB aabb = aabbForOrientation(); - aabb.minY = supertile.yCoord; - return new RadiusDescriptor.Rectangle(toChunkCoordinates(), aabb); - } - - @Override - public int getColor() { - return 0xD8BA00; - } - - @Override - public int getMaxMana() { - return 100; - } - - @Override - public LexiconEntry getEntry() { - return LexiconData.daffomill; - } - - @Override - public void writeToPacketNBT(NBTTagCompound cmp) { - super.writeToPacketNBT(cmp); - - cmp.setInteger(TAG_ORIENTATION, orientation); - cmp.setInteger(TAG_WIND_TICKS, windTicks); - } - - @Override - public void readFromPacketNBT(NBTTagCompound cmp) { - super.readFromPacketNBT(cmp); - - orientation = cmp.getInteger(TAG_ORIENTATION); - windTicks = cmp.getInteger(TAG_WIND_TICKS); - } + private static final String TAG_ORIENTATION = "orientation"; + private static final String TAG_WIND_TICKS = "windTicks"; + + int windTicks = 0; + int orientation = 0; + + @Override + public void onUpdate() { + super.onUpdate(); + + ForgeDirection dir = ForgeDirection.getOrientation(orientation + 2); + if(supertile.getWorldObj().rand.nextInt(4) == 0) + Botania.proxy.wispFX(supertile.getWorldObj(), supertile.xCoord + Math.random(), supertile.yCoord + Math.random(), supertile.zCoord + Math.random(), 0.05F, 0.05F, 0.05F, 0.25F + (float) Math.random() * 0.15F, dir.offsetX * 0.1F, dir.offsetY * 0.1F, dir.offsetZ * 0.1F); + + if(windTicks == 0 && mana > 0) { + windTicks = 20; + mana--; + } + + if(windTicks > 0 && redstoneSignal == 0) { + AxisAlignedBB axis = aabbForOrientation(); + + if(axis != null) { + List items = supertile.getWorldObj().getEntitiesWithinAABB(EntityItem.class, axis); + int slowdown = getSlowdownFactor(); + for(EntityItem item : items) + if(!item.isDead && item.age >= slowdown) { + item.motionX += dir.offsetX * 0.05; + item.motionY += dir.offsetY * 0.05; + item.motionZ += dir.offsetZ * 0.05; + } + } + + windTicks--; + } + } + + AxisAlignedBB aabbForOrientation() { + int x = supertile.xCoord; + int y = supertile.yCoord; + int z = supertile.zCoord; + int w = 2; + int h = 3; + int l = 16; + + AxisAlignedBB axis = null; + switch(orientation) { + case 0 : + axis = AxisAlignedBB.getBoundingBox(x - w, y - h, z - l, x + w + 1, y + h, z); + break; + case 1 : + axis = AxisAlignedBB.getBoundingBox(x - w, y - h, z + 1, x + w + 1, y + h, z + l + 1); + break; + case 2 : + axis = AxisAlignedBB.getBoundingBox(x - l, y - h, z - w, x, y + h, z + w + 1); + break; + case 3 : + axis = AxisAlignedBB.getBoundingBox(x + 1, y - h, z - w, x + l + 1, y + h, z + w + 1); + } + return axis; + } + + @Override + public boolean acceptsRedstone() { + return true; + } + + @Override + public boolean onWanded(EntityPlayer player, ItemStack wand) { + if(player == null) + return false; + + if(player.isSneaking()) { + if(!player.worldObj.isRemote) { + orientation = orientation == 3 ? 0 : orientation + 1; + sync(); + } + + return true; + } else return super.onWanded(player, wand); + } + + @Override + public RadiusDescriptor getRadius() { + AxisAlignedBB aabb = aabbForOrientation(); + aabb.minY = supertile.yCoord; + return new RadiusDescriptor.Rectangle(toChunkCoordinates(), aabb); + } + + @Override + public int getColor() { + return 0xD8BA00; + } + + @Override + public int getMaxMana() { + return 100; + } + + @Override + public LexiconEntry getEntry() { + return LexiconData.daffomill; + } + + @Override + public void writeToPacketNBT(NBTTagCompound cmp) { + super.writeToPacketNBT(cmp); + + cmp.setInteger(TAG_ORIENTATION, orientation); + cmp.setInteger(TAG_WIND_TICKS, windTicks); + } + + @Override + public void readFromPacketNBT(NBTTagCompound cmp) { + super.readFromPacketNBT(cmp); + + orientation = cmp.getInteger(TAG_ORIENTATION); + windTicks = cmp.getInteger(TAG_WIND_TICKS); + } + } diff --git a/src/main/java/vazkii/botania/common/block/subtile/functional/SubTileDreadthorn.java b/src/main/java/vazkii/botania/common/block/subtile/functional/SubTileDreadthorn.java index 5537b7f753..332389f7bc 100644 --- a/src/main/java/vazkii/botania/common/block/subtile/functional/SubTileDreadthorn.java +++ b/src/main/java/vazkii/botania/common/block/subtile/functional/SubTileDreadthorn.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [May 15, 2014, 4:25:24 PM (GMT)] */ package vazkii.botania.common.block.subtile.functional; @@ -18,29 +18,31 @@ public class SubTileDreadthorn extends SubTileBellethorn { - @Override - public int getColor() { - return 0x260B45; - } - - @Override - public IEntitySelector getSelector() { - return new IEntitySelector() { - - @Override - public boolean isEntityApplicable(Entity var1) { - return var1 instanceof EntityAnimal && ((EntityAnimal) var1).getGrowingAge() == 0; - } - }; - } - - @Override - public int getManaCost() { - return 30; - } - - @Override - public LexiconEntry getEntry() { - return LexiconData.dreadthorne; - } + @Override + public int getColor() { + return 0x260B45; + } + + @Override + public IEntitySelector getSelector() { + return new IEntitySelector() { + + @Override + public boolean isEntityApplicable(Entity var1) { + return var1 instanceof EntityAnimal && ((EntityAnimal) var1).getGrowingAge() == 0; + } + + }; + } + + @Override + public int getManaCost() { + return 30; + } + + @Override + public LexiconEntry getEntry() { + return LexiconData.dreadthorne; + } + } diff --git a/src/main/java/vazkii/botania/common/block/subtile/functional/SubTileExoflame.java b/src/main/java/vazkii/botania/common/block/subtile/functional/SubTileExoflame.java index 6bf2ed0e12..4684517eb6 100644 --- a/src/main/java/vazkii/botania/common/block/subtile/functional/SubTileExoflame.java +++ b/src/main/java/vazkii/botania/common/block/subtile/functional/SubTileExoflame.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Mar 19, 2014, 3:42:32 PM (GMT)] */ package vazkii.botania.common.block.subtile.functional; @@ -25,101 +25,107 @@ public class SubTileExoflame extends SubTileFunctional { - private static final int RANGE = 5; - private static final int RANGE_Y = 2; - - @Override - public void onUpdate() { - super.onUpdate(); - - boolean did = false; - int cost = 300; - - fireFurnaces: - { - for (int i = -RANGE; i < RANGE + 1; i++) - for (int j = -RANGE_Y; j < RANGE_Y + 1; j++) - for (int k = -RANGE; k < RANGE + 1; k++) { - int x = supertile.xCoord + i; - int y = supertile.yCoord + j; - int z = supertile.zCoord + k; - - TileEntity tile = supertile.getWorldObj().getTileEntity(x, y, z); - Block block = supertile.getWorldObj().getBlock(x, y, z); - if (tile != null) { - if (tile instanceof TileEntityFurnace - && (block == Blocks.furnace || block == Blocks.lit_furnace)) { - TileEntityFurnace furnace = (TileEntityFurnace) tile; - boolean canSmelt = canFurnaceSmelt(furnace); - if (canSmelt && mana > 2) { - if (furnace.furnaceBurnTime < 2) { - if (furnace.furnaceBurnTime == 0) - BlockFurnace.updateFurnaceBlockState( - true, supertile.getWorldObj(), x, y, z); - furnace.furnaceBurnTime = 200; - mana = Math.max(0, mana - cost); - } - if (ticksExisted % 2 == 0) - furnace.furnaceCookTime = Math.min(199, furnace.furnaceCookTime + 1); - - did = true; - - if (mana <= 0) break fireFurnaces; - } - } else if (tile instanceof IExoflameHeatable) { - IExoflameHeatable heatable = (IExoflameHeatable) tile; - - if (heatable.canSmelt() && mana > 2) { - if (heatable.getBurnTime() == 0) { - heatable.boostBurnTime(); - mana = Math.max(0, mana - cost); - } - - if (ticksExisted % 2 == 0) heatable.boostCookTime(); - - if (mana <= 0) break fireFurnaces; - } - } - } - } - } - - if (did) sync(); - } - - public static boolean canFurnaceSmelt(TileEntityFurnace furnace) { - if (furnace.getStackInSlot(0) == null) return false; - else { - ItemStack itemstack = FurnaceRecipes.smelting().getSmeltingResult(furnace.getStackInSlot(0)); - - if (itemstack == null) return false; - - if (furnace.getStackInSlot(2) == null) return true; - - if (!furnace.getStackInSlot(2).isItemEqual(itemstack)) return false; - - int result = furnace.getStackInSlot(2).stackSize + itemstack.stackSize; - return result <= 64 && result <= itemstack.getMaxStackSize(); - } - } - - @Override - public RadiusDescriptor getRadius() { - return new RadiusDescriptor.Square(toChunkCoordinates(), RANGE); - } - - @Override - public int getMaxMana() { - return 300; - } - - @Override - public int getColor() { - return 0x661600; - } - - @Override - public LexiconEntry getEntry() { - return LexiconData.exoflame; - } + private static final int RANGE = 5; + private static final int RANGE_Y = 2; + + @Override + public void onUpdate() { + super.onUpdate(); + + boolean did = false; + int cost = 300; + + fireFurnaces : { + for(int i = -RANGE; i < RANGE + 1; i++) + for(int j = -RANGE_Y; j < RANGE_Y + 1; j++) + for(int k = -RANGE; k < RANGE + 1; k++) { + int x = supertile.xCoord + i; + int y = supertile.yCoord + j; + int z = supertile.zCoord + k; + + TileEntity tile = supertile.getWorldObj().getTileEntity(x, y, z); + Block block = supertile.getWorldObj().getBlock(x, y, z); + if(tile != null) { + if(tile instanceof TileEntityFurnace && (block == Blocks.furnace || block == Blocks.lit_furnace)) { + TileEntityFurnace furnace = (TileEntityFurnace) tile; + boolean canSmelt = canFurnaceSmelt(furnace); + if(canSmelt && mana > 2) { + if(furnace.furnaceBurnTime < 2) { + if(furnace.furnaceBurnTime == 0) + BlockFurnace.updateFurnaceBlockState(true, supertile.getWorldObj(), x, y, z); + furnace.furnaceBurnTime = 200; + mana = Math.max(0, mana - cost); + } + if(ticksExisted % 2 == 0) + furnace.furnaceCookTime = Math.min(199, furnace.furnaceCookTime + 1); + + did = true; + + if(mana <= 0) + break fireFurnaces; + } + } else if(tile instanceof IExoflameHeatable) { + IExoflameHeatable heatable = (IExoflameHeatable) tile; + + if(heatable.canSmelt() && mana > 2) { + if(heatable.getBurnTime() == 0) { + heatable.boostBurnTime(); + mana = Math.max(0, mana - cost); + } + + if(ticksExisted % 2 == 0) + heatable.boostCookTime(); + + if(mana <= 0) + break fireFurnaces; + } + } + } + } + } + + if(did) + sync(); + } + + public static boolean canFurnaceSmelt(TileEntityFurnace furnace){ + if(furnace.getStackInSlot(0) == null) + return false; + else { + ItemStack itemstack = FurnaceRecipes.smelting().getSmeltingResult(furnace.getStackInSlot(0)); + + if(itemstack == null) + return false; + + if(furnace.getStackInSlot(2) == null) + return true; + + if(!furnace.getStackInSlot(2).isItemEqual(itemstack)) + return false; + + int result = furnace.getStackInSlot(2).stackSize + itemstack.stackSize; + return result <= 64 && result <= itemstack.getMaxStackSize(); + } + } + + @Override + public RadiusDescriptor getRadius() { + return new RadiusDescriptor.Square(toChunkCoordinates(), RANGE); + } + + @Override + public int getMaxMana() { + return 300; + } + + @Override + public int getColor() { + return 0x661600; + } + + @Override + public LexiconEntry getEntry() { + return LexiconData.exoflame; + } + } diff --git a/src/main/java/vazkii/botania/common/block/subtile/functional/SubTileFallenKanade.java b/src/main/java/vazkii/botania/common/block/subtile/functional/SubTileFallenKanade.java index bab6d1102a..45f94df803 100644 --- a/src/main/java/vazkii/botania/common/block/subtile/functional/SubTileFallenKanade.java +++ b/src/main/java/vazkii/botania/common/block/subtile/functional/SubTileFallenKanade.java @@ -2,15 +2,16 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Mar 14, 2014, 8:54:11 PM (GMT)] */ package vazkii.botania.common.block.subtile.functional; import java.util.List; + import net.minecraft.entity.player.EntityPlayer; import net.minecraft.potion.Potion; import net.minecraft.potion.PotionEffect; @@ -22,52 +23,43 @@ public class SubTileFallenKanade extends SubTileFunctional { - private static final int RANGE = 2; + private static final int RANGE = 2; + + @Override + public void onUpdate() { + super.onUpdate(); - @Override - public void onUpdate() { - super.onUpdate(); + final int cost = 120; - final int cost = 120; + if(!supertile.getWorldObj().isRemote && supertile.getWorldObj().provider.dimensionId != 1) { + List players = supertile.getWorldObj().getEntitiesWithinAABB(EntityPlayer.class, AxisAlignedBB.getBoundingBox(supertile.xCoord - RANGE, supertile.yCoord - RANGE, supertile.zCoord - RANGE, supertile.xCoord + RANGE + 1, supertile.yCoord + RANGE + 1, supertile.zCoord + RANGE + 1)); + for(EntityPlayer player : players) { + if(player.getActivePotionEffect(Potion.regeneration) == null && mana >= cost ) { + player.addPotionEffect(new PotionEffect(Potion.regeneration.id, 60, 2)); + mana -= cost; + } + } + } + } - if (!supertile.getWorldObj().isRemote && supertile.getWorldObj().provider.dimensionId != 1) { - List players = supertile - .getWorldObj() - .getEntitiesWithinAABB( - EntityPlayer.class, - AxisAlignedBB.getBoundingBox( - supertile.xCoord - RANGE, - supertile.yCoord - RANGE, - supertile.zCoord - RANGE, - supertile.xCoord + RANGE + 1, - supertile.yCoord + RANGE + 1, - supertile.zCoord + RANGE + 1)); - for (EntityPlayer player : players) { - if (player.getActivePotionEffect(Potion.regeneration) == null && mana >= cost) { - player.addPotionEffect(new PotionEffect(Potion.regeneration.id, 60, 2)); - mana -= cost; - } - } - } - } + @Override + public RadiusDescriptor getRadius() { + return new RadiusDescriptor.Square(toChunkCoordinates(), RANGE); + } - @Override - public RadiusDescriptor getRadius() { - return new RadiusDescriptor.Square(toChunkCoordinates(), RANGE); - } + @Override + public int getColor() { + return 0xFFFF00; + } - @Override - public int getColor() { - return 0xFFFF00; - } + @Override + public int getMaxMana() { + return 900; + } - @Override - public int getMaxMana() { - return 900; - } + @Override + public LexiconEntry getEntry() { + return LexiconData.fallenKanade; + } - @Override - public LexiconEntry getEntry() { - return LexiconData.fallenKanade; - } } diff --git a/src/main/java/vazkii/botania/common/block/subtile/functional/SubTileHeiseiDream.java b/src/main/java/vazkii/botania/common/block/subtile/functional/SubTileHeiseiDream.java index 0129165459..0c66e7fdc5 100644 --- a/src/main/java/vazkii/botania/common/block/subtile/functional/SubTileHeiseiDream.java +++ b/src/main/java/vazkii/botania/common/block/subtile/functional/SubTileHeiseiDream.java @@ -2,17 +2,17 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Feb 16, 2014, 12:37:40 AM (GMT)] */ package vazkii.botania.common.block.subtile.functional; -import cpw.mods.fml.relauncher.ReflectionHelper; import java.util.ArrayList; import java.util.List; + import net.minecraft.entity.EntityLiving; import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.ai.EntityAIAttackOnCollide; @@ -25,99 +25,89 @@ import vazkii.botania.api.subtile.SubTileFunctional; import vazkii.botania.common.lexicon.LexiconData; import vazkii.botania.common.lib.LibObfuscation; +import cpw.mods.fml.relauncher.ReflectionHelper; public class SubTileHeiseiDream extends SubTileFunctional { - private static final int RANGE = 5; - - @Override - public void onUpdate() { - super.onUpdate(); - - final int cost = 100; - - List mobs = supertile - .getWorldObj() - .getEntitiesWithinAABB( - IMob.class, - AxisAlignedBB.getBoundingBox( - supertile.xCoord - RANGE, - supertile.yCoord - RANGE, - supertile.zCoord - RANGE, - supertile.xCoord + RANGE + 1, - supertile.yCoord + RANGE + 1, - supertile.zCoord + RANGE + 1)); - if (mobs.size() > 1 && mana >= cost) - for (IMob mob : mobs) { - if (mob instanceof EntityLiving) { - EntityLiving entity = (EntityLiving) mob; - if (brainwashEntity(entity, mobs)) { - mana -= cost; - sync(); - break; - } - } - } - } - - public static boolean brainwashEntity(EntityLiving entity, List mobs) { - EntityLivingBase target = entity.getAttackTarget(); - boolean did = false; - - if (target == null || !(target instanceof IMob)) { - IMob newTarget; - do newTarget = mobs.get(entity.worldObj.rand.nextInt(mobs.size())); - while (newTarget == entity); - - if (newTarget instanceof EntityLiving) { - List entries = new ArrayList(entity.tasks.taskEntries); - entries.addAll(new ArrayList(entity.targetTasks.taskEntries)); - - for (EntityAITaskEntry entry : entries) - if (entry.action instanceof EntityAINearestAttackableTarget) { - messWithGetTargetAI((EntityAINearestAttackableTarget) entry.action, (EntityLiving) newTarget); - did = true; - } else if (entry.action instanceof EntityAIAttackOnCollide) { - messWithAttackOnCollideAI((EntityAIAttackOnCollide) entry.action); - did = true; - } - - if (did) entity.setAttackTarget((EntityLiving) newTarget); - } - } - - return did; - } - - private static void messWithGetTargetAI(EntityAINearestAttackableTarget aiEntry, EntityLivingBase target) { - ReflectionHelper.setPrivateValue( - EntityAINearestAttackableTarget.class, aiEntry, IMob.class, LibObfuscation.TARGET_CLASS); - ReflectionHelper.setPrivateValue( - EntityAINearestAttackableTarget.class, aiEntry, target, LibObfuscation.TARGET_ENTITY); - } - - private static void messWithAttackOnCollideAI(EntityAIAttackOnCollide aiEntry) { - ReflectionHelper.setPrivateValue( - EntityAIAttackOnCollide.class, aiEntry, IMob.class, LibObfuscation.CLASS_TARGET); - } - - @Override - public RadiusDescriptor getRadius() { - return new RadiusDescriptor.Square(toChunkCoordinates(), RANGE); - } - - @Override - public int getColor() { - return 0xFF219D; - } - - @Override - public int getMaxMana() { - return 1000; - } - - @Override - public LexiconEntry getEntry() { - return LexiconData.heiseiDream; - } + private static final int RANGE = 5; + + @Override + public void onUpdate() { + super.onUpdate(); + + final int cost = 100; + + List mobs = supertile.getWorldObj().getEntitiesWithinAABB(IMob.class, AxisAlignedBB.getBoundingBox(supertile.xCoord - RANGE, supertile.yCoord - RANGE, supertile.zCoord - RANGE, supertile.xCoord + RANGE + 1, supertile.yCoord + RANGE + 1, supertile.zCoord + RANGE + 1)); + if(mobs.size() > 1 && mana >= cost) + for(IMob mob : mobs) { + if(mob instanceof EntityLiving) { + EntityLiving entity = (EntityLiving) mob; + if(brainwashEntity(entity, mobs)) { + mana -= cost; + sync(); + break; + } + } + } + } + + public static boolean brainwashEntity(EntityLiving entity, List mobs) { + EntityLivingBase target = entity.getAttackTarget(); + boolean did = false; + + if(target == null || !(target instanceof IMob)) { + IMob newTarget; + do newTarget = mobs.get(entity.worldObj.rand.nextInt(mobs.size())); + while(newTarget == entity); + + if(newTarget instanceof EntityLiving) { + List entries = new ArrayList(entity.tasks.taskEntries); + entries.addAll(new ArrayList(entity.targetTasks.taskEntries)); + + for(EntityAITaskEntry entry : entries) + if(entry.action instanceof EntityAINearestAttackableTarget) { + messWithGetTargetAI((EntityAINearestAttackableTarget) entry.action, (EntityLiving) newTarget); + did = true; + } else if(entry.action instanceof EntityAIAttackOnCollide) { + messWithAttackOnCollideAI((EntityAIAttackOnCollide) entry.action); + did = true; + } + + if(did) + entity.setAttackTarget((EntityLiving) newTarget); + } + } + + return did; + } + + private static void messWithGetTargetAI(EntityAINearestAttackableTarget aiEntry, EntityLivingBase target) { + ReflectionHelper.setPrivateValue(EntityAINearestAttackableTarget.class, aiEntry, IMob.class, LibObfuscation.TARGET_CLASS); + ReflectionHelper.setPrivateValue(EntityAINearestAttackableTarget.class, aiEntry, target, LibObfuscation.TARGET_ENTITY); + } + + private static void messWithAttackOnCollideAI(EntityAIAttackOnCollide aiEntry) { + ReflectionHelper.setPrivateValue(EntityAIAttackOnCollide.class, aiEntry, IMob.class, LibObfuscation.CLASS_TARGET); + } + + @Override + public RadiusDescriptor getRadius() { + return new RadiusDescriptor.Square(toChunkCoordinates(), RANGE); + } + + @Override + public int getColor() { + return 0xFF219D; + } + + @Override + public int getMaxMana() { + return 1000; + } + + @Override + public LexiconEntry getEntry() { + return LexiconData.heiseiDream; + } + } diff --git a/src/main/java/vazkii/botania/common/block/subtile/functional/SubTileHopperhock.java b/src/main/java/vazkii/botania/common/block/subtile/functional/SubTileHopperhock.java index 6ea4e51598..84aea3c2ca 100644 --- a/src/main/java/vazkii/botania/common/block/subtile/functional/SubTileHopperhock.java +++ b/src/main/java/vazkii/botania/common/block/subtile/functional/SubTileHopperhock.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Mar 20, 2014, 5:54:39 PM (GMT)] */ package vazkii.botania.common.block.subtile.functional; @@ -15,6 +15,7 @@ import java.util.List; import java.util.Set; import java.util.WeakHashMap; + import net.minecraft.block.Block; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.ScaledResolution; @@ -29,7 +30,10 @@ import net.minecraft.util.AxisAlignedBB; import net.minecraft.util.StatCollector; import net.minecraftforge.common.util.ForgeDirection; + import org.lwjgl.opengl.GL11; + +import scala.reflect.internal.util.WeakHashSet; import vazkii.botania.api.lexicon.LexiconEntry; import vazkii.botania.api.mana.IManaItem; import vazkii.botania.api.subtile.RadiusDescriptor; @@ -40,251 +44,236 @@ public class SubTileHopperhock extends SubTileFunctional { - private static final String TAG_FILTER_TYPE = "filterType"; - private static final int RANGE_MANA = 10; - private static final int RANGE = 6; - - private static final int RANGE_MANA_MINI = 2; - private static final int RANGE_MINI = 1; - - private static Set particled = Collections.newSetFromMap(new WeakHashMap()); - - int filterType = 0; - - @Override - public void onUpdate() { - super.onUpdate(); - - if (redstoneSignal > 0) return; - - boolean pulledAny = false; - int range = getRange(); - - int x = supertile.xCoord; - int y = supertile.yCoord; - int z = supertile.zCoord; - - List items = supertile - .getWorldObj() - .getEntitiesWithinAABB( - EntityItem.class, - AxisAlignedBB.getBoundingBox( - x - range, y - range, z - range, x + range + 1, y + range + 1, z + range + 1)); - int slowdown = getSlowdownFactor(); - - for (EntityItem item : items) { - if (item.age < (60 + slowdown) || item.age >= 105 && item.age < 110 || item.isDead) continue; - - ItemStack stack = item.getEntityItem(); - - IInventory invToPutItemIn = null; - ForgeDirection sideToPutItemIn = ForgeDirection.UNKNOWN; - boolean priorityInv = false; - int amountToPutIn = 0; - - for (ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS) { - int x_ = x + dir.offsetX; - int y_ = y + dir.offsetY; - int z_ = z + dir.offsetZ; - - IInventory inv = InventoryHelper.getInventory(supertile.getWorldObj(), x_, y_, z_); - if (inv != null) { - List filter = getFilterForInventory(inv, x_, y_, z_, true); - boolean canAccept = canAcceptItem(stack, filter, filterType); - int availablePut = supertile.getWorldObj().isRemote - ? 1 - : InventoryHelper.testInventoryInsertion(inv, stack, dir); - canAccept &= availablePut > 0; - - if (canAccept) { - boolean priority = !filter.isEmpty(); - - setInv: - { - if (priorityInv && !priority) break setInv; - - invToPutItemIn = inv; - priorityInv = priority; - sideToPutItemIn = dir.getOpposite(); - amountToPutIn = availablePut; - } - } - } - } - - if (invToPutItemIn != null && !item.isDead) { - boolean remote = supertile.getWorldObj().isRemote; - if (remote) { - if (!particled.contains(item)) { - SubTileSpectranthemum.spawnExplosionParticles(item, 3); - particled.add(item); - } - } else { - InventoryHelper.insertItemIntoInventory( - invToPutItemIn, stack.splitStack(amountToPutIn), sideToPutItemIn, -1); - item.setEntityItemStack( - stack); // Just in case someone subclasses EntityItem and changes something important. - invToPutItemIn.markDirty(); - if (item.getEntityItem().stackSize == 0) item.setDead(); - pulledAny = true; - } - } - } - - if (pulledAny && mana > 1) mana--; - } - - public boolean canAcceptItem(ItemStack stack, List filter, int filterType) { - if (stack == null) return false; - - if (filter.isEmpty()) return true; - - switch (filterType) { - case 0: { // Accept items in frames only - boolean anyFilter = false; - for (ItemStack filterEntry : filter) { - if (filterEntry == null) continue; - anyFilter = true; - - boolean itemEqual = stack.getItem() == filterEntry.getItem(); - boolean damageEqual = stack.getItemDamage() == filterEntry.getItemDamage(); - boolean nbtEqual = ItemStack.areItemStackTagsEqual(filterEntry, stack); - - if (itemEqual && damageEqual && nbtEqual) return true; - - if (!stack.getHasSubtypes() - && stack.isItemStackDamageable() - && stack.getMaxStackSize() == 1 - && itemEqual - && nbtEqual) return true; - - if (stack.getItem() instanceof IManaItem && itemEqual) return true; - } - - return !anyFilter; - } - case 1: - return !canAcceptItem(stack, filter, 0); // Accept items not in frames only - default: - return true; // Accept all items - } - } - - public List getFilterForInventory( - IInventory inv, int x, int y, int z, boolean recursiveForDoubleChests) { - List filter = new ArrayList(); - - if (recursiveForDoubleChests) { - TileEntity tileEntity = supertile.getWorldObj().getTileEntity(x, y, z); - Block chest = supertile.getWorldObj().getBlock(x, y, z); - - if (tileEntity instanceof TileEntityChest) - for (ForgeDirection dir : LibMisc.CARDINAL_DIRECTIONS) - if (supertile.getWorldObj().getBlock(x + dir.offsetX, y, z + dir.offsetZ) == chest) { - filter.addAll(getFilterForInventory( - (IInventory) supertile.getWorldObj().getTileEntity(x + dir.offsetX, y, z + dir.offsetZ), - x + dir.offsetX, - y, - z + dir.offsetZ, - false)); - break; - } - } - - final int[] orientationToDir = new int[] {3, 4, 2, 5}; - - for (ForgeDirection dir : LibMisc.CARDINAL_DIRECTIONS) { - AxisAlignedBB aabb = AxisAlignedBB.getBoundingBox( - x + dir.offsetX, - y + dir.offsetY, - z + dir.offsetZ, - x + dir.offsetX + 1, - y + dir.offsetY + 1, - z + dir.offsetZ + 1); - List frames = supertile.getWorldObj().getEntitiesWithinAABB(EntityItemFrame.class, aabb); - for (EntityItemFrame frame : frames) { - int orientation = frame.hangingDirection; - if (orientationToDir[orientation] == dir.ordinal()) filter.add(frame.getDisplayedItem()); - } - } - - return filter; - } - - @Override - public boolean acceptsRedstone() { - return true; - } - - @Override - public boolean onWanded(EntityPlayer player, ItemStack wand) { - if (player == null) return false; - - if (player.isSneaking()) { - filterType = filterType == 2 ? 0 : filterType + 1; - sync(); - - return true; - } else return super.onWanded(player, wand); - } - - @Override - public RadiusDescriptor getRadius() { - return new RadiusDescriptor.Square(toChunkCoordinates(), getRange()); - } - - public int getRange() { - return mana > 0 ? RANGE_MANA : RANGE; - } - - @Override - public void writeToPacketNBT(NBTTagCompound cmp) { - super.writeToPacketNBT(cmp); - - cmp.setInteger(TAG_FILTER_TYPE, filterType); - } - - @Override - public void readFromPacketNBT(NBTTagCompound cmp) { - super.readFromPacketNBT(cmp); - - filterType = cmp.getInteger(TAG_FILTER_TYPE); - } - - @Override - public void renderHUD(Minecraft mc, ScaledResolution res) { - super.renderHUD(mc, res); - - int color = getColor(); - String filter = StatCollector.translateToLocal("botaniamisc.filter" + filterType); - GL11.glEnable(GL11.GL_BLEND); - GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); - int x = res.getScaledWidth() / 2 - mc.fontRenderer.getStringWidth(filter) / 2; - int y = res.getScaledHeight() / 2 + 30; - - mc.fontRenderer.drawStringWithShadow(filter, x, y, color); - GL11.glDisable(GL11.GL_BLEND); - } - - @Override - public LexiconEntry getEntry() { - return LexiconData.hopperhock; - } - - @Override - public int getMaxMana() { - return 20; - } - - @Override - public int getColor() { - return 0x3F3F3F; - } - - public static class Mini extends SubTileHopperhock { - @Override - public int getRange() { - return mana > 0 ? RANGE_MANA_MINI : RANGE_MINI; - } - } + private static final String TAG_FILTER_TYPE = "filterType"; + private static final int RANGE_MANA = 10; + private static final int RANGE = 6; + + private static final int RANGE_MANA_MINI = 2; + private static final int RANGE_MINI = 1; + + private static Set particled = Collections.newSetFromMap(new WeakHashMap()); + + int filterType = 0; + + @Override + public void onUpdate() { + super.onUpdate(); + + if(redstoneSignal > 0) + return; + + boolean pulledAny = false; + int range = getRange(); + + int x = supertile.xCoord; + int y = supertile.yCoord; + int z = supertile.zCoord; + + List items = supertile.getWorldObj().getEntitiesWithinAABB(EntityItem.class, AxisAlignedBB.getBoundingBox(x - range, y - range, z - range, x + range + 1, y + range + 1, z + range + 1)); + int slowdown = getSlowdownFactor(); + + for(EntityItem item : items) { + if(item.age < (60 + slowdown) || item.age >= 105 && item.age < 110 || item.isDead) + continue; + + ItemStack stack = item.getEntityItem(); + + IInventory invToPutItemIn = null; + ForgeDirection sideToPutItemIn = ForgeDirection.UNKNOWN; + boolean priorityInv = false; + int amountToPutIn = 0; + + for(ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS) { + int x_ = x + dir.offsetX; + int y_ = y + dir.offsetY; + int z_ = z + dir.offsetZ; + + IInventory inv = InventoryHelper.getInventory(supertile.getWorldObj(), x_, y_, z_); + if(inv != null) { + List filter = getFilterForInventory(inv, x_, y_, z_, true); + boolean canAccept = canAcceptItem(stack, filter, filterType); + int availablePut = supertile.getWorldObj().isRemote ? 1 : InventoryHelper.testInventoryInsertion(inv, stack, dir); + canAccept &= availablePut > 0; + + if(canAccept) { + boolean priority = !filter.isEmpty(); + + setInv : { + if(priorityInv && !priority) + break setInv; + + invToPutItemIn = inv; + priorityInv = priority; + sideToPutItemIn = dir.getOpposite(); + amountToPutIn = availablePut; + } + } + } + } + + if(invToPutItemIn != null && !item.isDead) { + boolean remote = supertile.getWorldObj().isRemote; + if(remote) { + if(!particled.contains(item)) { + SubTileSpectranthemum.spawnExplosionParticles(item, 3); + particled.add(item); + } + } else { + InventoryHelper.insertItemIntoInventory(invToPutItemIn, stack.splitStack(amountToPutIn), sideToPutItemIn, -1); + item.setEntityItemStack(stack); // Just in case someone subclasses EntityItem and changes something important. + invToPutItemIn.markDirty(); + if(item.getEntityItem().stackSize == 0) + item.setDead(); + pulledAny = true; + } + } + } + + if(pulledAny && mana > 1) + mana--; + } + + public boolean canAcceptItem(ItemStack stack, List filter, int filterType) { + if(stack == null) + return false; + + if(filter.isEmpty()) + return true; + + switch(filterType) { + case 0 : { // Accept items in frames only + boolean anyFilter = false; + for(ItemStack filterEntry : filter) { + if(filterEntry == null) + continue; + anyFilter = true; + + boolean itemEqual = stack.getItem() == filterEntry.getItem(); + boolean damageEqual = stack.getItemDamage() == filterEntry.getItemDamage(); + boolean nbtEqual = ItemStack.areItemStackTagsEqual(filterEntry, stack); + + if(itemEqual && damageEqual && nbtEqual) + return true; + + if(!stack.getHasSubtypes() && stack.isItemStackDamageable() && stack.getMaxStackSize() == 1 && itemEqual && nbtEqual) + return true; + + if(stack.getItem() instanceof IManaItem && itemEqual) + return true; + } + + return !anyFilter; + } + case 1 : return !canAcceptItem(stack, filter, 0); // Accept items not in frames only + default : return true; // Accept all items + } + } + + public List getFilterForInventory(IInventory inv, int x, int y, int z, boolean recursiveForDoubleChests) { + List filter = new ArrayList(); + + if(recursiveForDoubleChests) { + TileEntity tileEntity = supertile.getWorldObj().getTileEntity(x, y, z); + Block chest = supertile.getWorldObj().getBlock(x, y, z); + + if(tileEntity instanceof TileEntityChest) + for(ForgeDirection dir : LibMisc.CARDINAL_DIRECTIONS) + if(supertile.getWorldObj().getBlock(x + dir.offsetX, y, z + dir.offsetZ) == chest) { + filter.addAll(getFilterForInventory((IInventory) supertile.getWorldObj().getTileEntity(x + dir.offsetX, y, z + dir.offsetZ), x + dir.offsetX, y, z + dir.offsetZ, false)); + break; + } + } + + final int[] orientationToDir = new int[] { + 3, 4, 2, 5 + }; + + for(ForgeDirection dir : LibMisc.CARDINAL_DIRECTIONS) { + AxisAlignedBB aabb = AxisAlignedBB.getBoundingBox(x + dir.offsetX, y + dir.offsetY, z + dir.offsetZ, x + dir.offsetX + 1, y + dir.offsetY + 1, z + dir.offsetZ + 1); + List frames = supertile.getWorldObj().getEntitiesWithinAABB(EntityItemFrame.class, aabb); + for(EntityItemFrame frame : frames) { + int orientation = frame.hangingDirection; + if(orientationToDir[orientation] == dir.ordinal()) + filter.add(frame.getDisplayedItem()); + } + } + + return filter; + } + + @Override + public boolean acceptsRedstone() { + return true; + } + + @Override + public boolean onWanded(EntityPlayer player, ItemStack wand) { + if(player == null) + return false; + + if(player.isSneaking()) { + filterType = filterType == 2 ? 0 : filterType + 1; + sync(); + + return true; + } + else return super.onWanded(player, wand); + } + + @Override + public RadiusDescriptor getRadius() { + return new RadiusDescriptor.Square(toChunkCoordinates(), getRange()); + } + + public int getRange() { + return mana > 0 ? RANGE_MANA : RANGE; + } + + @Override + public void writeToPacketNBT(NBTTagCompound cmp) { + super.writeToPacketNBT(cmp); + + cmp.setInteger(TAG_FILTER_TYPE, filterType); + } + + @Override + public void readFromPacketNBT(NBTTagCompound cmp) { + super.readFromPacketNBT(cmp); + + filterType = cmp.getInteger(TAG_FILTER_TYPE); + } + + @Override + public void renderHUD(Minecraft mc, ScaledResolution res) { + super.renderHUD(mc, res); + + int color = getColor(); + String filter = StatCollector.translateToLocal("botaniamisc.filter" + filterType); + GL11.glEnable(GL11.GL_BLEND); + GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); + int x = res.getScaledWidth() / 2 - mc.fontRenderer.getStringWidth(filter) / 2; + int y = res.getScaledHeight() / 2 + 30; + + mc.fontRenderer.drawStringWithShadow(filter, x, y, color); + GL11.glDisable(GL11.GL_BLEND); + } + + @Override + public LexiconEntry getEntry() { + return LexiconData.hopperhock; + } + + @Override + public int getMaxMana() { + return 20; + } + + @Override + public int getColor() { + return 0x3F3F3F; + } + + public static class Mini extends SubTileHopperhock { + @Override public int getRange() { return mana > 0 ? RANGE_MANA_MINI : RANGE_MINI; } + } } diff --git a/src/main/java/vazkii/botania/common/block/subtile/functional/SubTileHyacidus.java b/src/main/java/vazkii/botania/common/block/subtile/functional/SubTileHyacidus.java index da02e35d8d..c658d1d6a5 100644 --- a/src/main/java/vazkii/botania/common/block/subtile/functional/SubTileHyacidus.java +++ b/src/main/java/vazkii/botania/common/block/subtile/functional/SubTileHyacidus.java @@ -2,15 +2,16 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [May 15, 2014, 4:47:41 PM (GMT)] */ package vazkii.botania.common.block.subtile.functional; import java.util.List; + import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.EnumCreatureAttribute; import net.minecraft.entity.player.EntityPlayer; @@ -24,61 +25,49 @@ public class SubTileHyacidus extends SubTileFunctional { - private static final int RANGE = 6; + private static final int RANGE = 6; + + @Override + public void onUpdate() { + super.onUpdate(); - @Override - public void onUpdate() { - super.onUpdate(); + if(redstoneSignal > 0) + return; - if (redstoneSignal > 0) return; + final int cost = 20; - final int cost = 20; + List entities = supertile.getWorldObj().getEntitiesWithinAABB(EntityLivingBase.class, AxisAlignedBB.getBoundingBox(supertile.xCoord - RANGE, supertile.yCoord - RANGE, supertile.zCoord - RANGE, supertile.xCoord + RANGE + 1, supertile.yCoord + RANGE + 1, supertile.zCoord + RANGE + 1)); + for(EntityLivingBase entity : entities) { + if(!(entity instanceof EntityPlayer) && entity.getActivePotionEffect(Potion.poison) == null && mana >= cost && !entity.worldObj.isRemote && entity.getCreatureAttribute() != EnumCreatureAttribute.UNDEAD) { + entity.addPotionEffect(new PotionEffect(Potion.poison.id, 60, 0)); + mana -= cost; + } + } + } - List entities = supertile - .getWorldObj() - .getEntitiesWithinAABB( - EntityLivingBase.class, - AxisAlignedBB.getBoundingBox( - supertile.xCoord - RANGE, - supertile.yCoord - RANGE, - supertile.zCoord - RANGE, - supertile.xCoord + RANGE + 1, - supertile.yCoord + RANGE + 1, - supertile.zCoord + RANGE + 1)); - for (EntityLivingBase entity : entities) { - if (!(entity instanceof EntityPlayer) - && entity.getActivePotionEffect(Potion.poison) == null - && mana >= cost - && !entity.worldObj.isRemote - && entity.getCreatureAttribute() != EnumCreatureAttribute.UNDEAD) { - entity.addPotionEffect(new PotionEffect(Potion.poison.id, 60, 0)); - mana -= cost; - } - } - } + @Override + public boolean acceptsRedstone() { + return true; + } - @Override - public boolean acceptsRedstone() { - return true; - } + @Override + public int getColor() { + return 0x8B438F; + } - @Override - public int getColor() { - return 0x8B438F; - } + @Override + public int getMaxMana() { + return 180; + } - @Override - public int getMaxMana() { - return 180; - } + @Override + public RadiusDescriptor getRadius() { + return new RadiusDescriptor.Square(toChunkCoordinates(), RANGE); + } - @Override - public RadiusDescriptor getRadius() { - return new RadiusDescriptor.Square(toChunkCoordinates(), RANGE); - } + @Override + public LexiconEntry getEntry() { + return LexiconData.hyacidus; + } - @Override - public LexiconEntry getEntry() { - return LexiconData.hyacidus; - } -} +} \ No newline at end of file diff --git a/src/main/java/vazkii/botania/common/block/subtile/functional/SubTileJadedAmaranthus.java b/src/main/java/vazkii/botania/common/block/subtile/functional/SubTileJadedAmaranthus.java index 4422d768cd..8501cd1796 100644 --- a/src/main/java/vazkii/botania/common/block/subtile/functional/SubTileJadedAmaranthus.java +++ b/src/main/java/vazkii/botania/common/block/subtile/functional/SubTileJadedAmaranthus.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Mar 3, 2014, 10:31:29 PM (GMT)] */ package vazkii.botania.common.block.subtile.functional; @@ -21,69 +21,65 @@ public class SubTileJadedAmaranthus extends SubTileFunctional { - private static final int COST = 100; - int RANGE = 4; - - @Override - public void onUpdate() { - super.onUpdate(); - - if (redstoneSignal > 0) return; - - if (mana >= COST && !supertile.getWorldObj().isRemote && ticksExisted % 30 == 0) { - int x = supertile.xCoord - RANGE + supertile.getWorldObj().rand.nextInt(RANGE * 2 + 1); - int y = supertile.yCoord + RANGE; - int z = supertile.zCoord - RANGE + supertile.getWorldObj().rand.nextInt(RANGE * 2 + 1); - - for (int i = 0; i < RANGE * 2; i++) { - Block blockAbove = supertile.getWorldObj().getBlock(x, y + 1, z); - if ((supertile.getWorldObj().isAirBlock(x, y + 1, z) - || blockAbove.isReplaceable(supertile.getWorldObj(), x, y + 1, z)) - && blockAbove.getMaterial() != Material.water - && ModBlocks.flower.canPlaceBlockAt(supertile.getWorldObj(), x, y + 1, z)) { - int color = supertile.getWorldObj().rand.nextInt(16); - if (ModBlocks.flower.canBlockStay(supertile.getWorldObj(), x, y + 1, z)) { - if (ConfigHandler.blockBreakParticles) - supertile - .getWorldObj() - .playAuxSFX( - 2001, x, y + 1, z, Block.getIdFromBlock(ModBlocks.flower) + (color << 12)); - supertile.getWorldObj().setBlock(x, y + 1, z, ModBlocks.flower, color, 1 | 2); - } - - mana -= COST; - sync(); - - break; - } - - y--; - } - } - } - - @Override - public boolean acceptsRedstone() { - return true; - } - - @Override - public int getColor() { - return 0x961283; - } - - @Override - public RadiusDescriptor getRadius() { - return new RadiusDescriptor.Square(toChunkCoordinates(), RANGE); - } - - @Override - public LexiconEntry getEntry() { - return LexiconData.jadedAmaranthus; - } - - @Override - public int getMaxMana() { - return COST; - } + private static final int COST = 100; + int RANGE = 4; + + @Override + public void onUpdate() { + super.onUpdate(); + + if(redstoneSignal > 0) + return; + + if(mana >= COST && !supertile.getWorldObj().isRemote && ticksExisted % 30 == 0) { + int x = supertile.xCoord - RANGE + supertile.getWorldObj().rand.nextInt(RANGE * 2 + 1); + int y = supertile.yCoord + RANGE; + int z = supertile.zCoord - RANGE + supertile.getWorldObj().rand.nextInt(RANGE * 2 + 1); + + for(int i = 0; i < RANGE * 2; i++) { + Block blockAbove = supertile.getWorldObj().getBlock(x, y + 1, z); + if((supertile.getWorldObj().isAirBlock(x, y + 1, z) || blockAbove.isReplaceable(supertile.getWorldObj(), x, y + 1, z)) && blockAbove.getMaterial() != Material.water && ModBlocks.flower.canPlaceBlockAt(supertile.getWorldObj(), x, y + 1, z)) { + int color = supertile.getWorldObj().rand.nextInt(16); + if(ModBlocks.flower.canBlockStay(supertile.getWorldObj(), x, y + 1, z)) { + if(ConfigHandler.blockBreakParticles) + supertile.getWorldObj().playAuxSFX(2001, x, y + 1, z, Block.getIdFromBlock(ModBlocks.flower) + (color << 12)); + supertile.getWorldObj().setBlock(x, y + 1, z, ModBlocks.flower, color, 1 | 2); + } + + mana -= COST; + sync(); + + break; + } + + y--; + } + } + } + + @Override + public boolean acceptsRedstone() { + return true; + } + + @Override + public int getColor() { + return 0x961283; + } + + @Override + public RadiusDescriptor getRadius() { + return new RadiusDescriptor.Square(toChunkCoordinates(), RANGE); + } + + @Override + public LexiconEntry getEntry() { + return LexiconData.jadedAmaranthus; + } + + @Override + public int getMaxMana() { + return COST; + } + } diff --git a/src/main/java/vazkii/botania/common/block/subtile/functional/SubTileJiyuulia.java b/src/main/java/vazkii/botania/common/block/subtile/functional/SubTileJiyuulia.java index 5982a77868..da2b4a75db 100644 --- a/src/main/java/vazkii/botania/common/block/subtile/functional/SubTileJiyuulia.java +++ b/src/main/java/vazkii/botania/common/block/subtile/functional/SubTileJiyuulia.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Apr 14, 2014, 11:40:51 PM (GMT)] */ package vazkii.botania.common.block.subtile.functional; @@ -15,28 +15,29 @@ public class SubTileJiyuulia extends SubTileTangleberrie { - @Override - double getMaxDistance() { - return 0; - } - - @Override - double getRange() { - return 8; - } - - @Override - float getMotionVelocity() { - return -super.getMotionVelocity() * 2; - } - - @Override - public int getColor() { - return 0xBD9ACA; - } - - @Override - public LexiconEntry getEntry() { - return LexiconData.jiyuulia; - } + @Override + double getMaxDistance() { + return 0; + } + + @Override + double getRange() { + return 8; + } + + @Override + float getMotionVelocity() { + return -super.getMotionVelocity() * 2; + } + + @Override + public int getColor() { + return 0xBD9ACA; + } + + @Override + public LexiconEntry getEntry() { + return LexiconData.jiyuulia; + } + } diff --git a/src/main/java/vazkii/botania/common/block/subtile/functional/SubTileLoonuim.java b/src/main/java/vazkii/botania/common/block/subtile/functional/SubTileLoonuim.java index adc629a048..ce14cfaed5 100644 --- a/src/main/java/vazkii/botania/common/block/subtile/functional/SubTileLoonuim.java +++ b/src/main/java/vazkii/botania/common/block/subtile/functional/SubTileLoonuim.java @@ -2,15 +2,16 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [May 31, 2014, 7:49:43 PM (GMT)] */ package vazkii.botania.common.block.subtile.functional; import java.util.Random; + import net.minecraft.entity.item.EntityItem; import net.minecraft.item.ItemStack; import net.minecraftforge.common.ChestGenHooks; @@ -22,60 +23,57 @@ public class SubTileLoonuim extends SubTileFunctional { - private static final int COST = 35000; - private static final int RANGE = 3; + private static final int COST = 35000; + private static final int RANGE = 3; + + @Override + public void onUpdate() { + super.onUpdate(); + if(redstoneSignal == 0 && ticksExisted % 200 == 0 && mana >= COST) { + Random rand = supertile.getWorldObj().rand; - @Override - public void onUpdate() { - super.onUpdate(); - if (redstoneSignal == 0 && ticksExisted % 200 == 0 && mana >= COST) { - Random rand = supertile.getWorldObj().rand; + ItemStack stack; + do { + stack = ChestGenHooks.getOneItem(ChestGenHooks.DUNGEON_CHEST, rand); + } while(stack == null || BotaniaAPI.looniumBlacklist.contains(stack.getItem())); - ItemStack stack; - do { - stack = ChestGenHooks.getOneItem(ChestGenHooks.DUNGEON_CHEST, rand); - } while (stack == null || BotaniaAPI.looniumBlacklist.contains(stack.getItem())); + int bound = RANGE * 2 + 1; + EntityItem entity = new EntityItem(supertile.getWorldObj(), supertile.xCoord - RANGE + rand.nextInt(bound) , supertile.yCoord + 1, supertile.zCoord - RANGE + rand.nextInt(bound), stack); + entity.motionX = 0; + entity.motionY = 0; + entity.motionZ = 0; - int bound = RANGE * 2 + 1; - EntityItem entity = new EntityItem( - supertile.getWorldObj(), - supertile.xCoord - RANGE + rand.nextInt(bound), - supertile.yCoord + 1, - supertile.zCoord - RANGE + rand.nextInt(bound), - stack); - entity.motionX = 0; - entity.motionY = 0; - entity.motionZ = 0; + if(!supertile.getWorldObj().isRemote) + supertile.getWorldObj().spawnEntityInWorld(entity); - if (!supertile.getWorldObj().isRemote) supertile.getWorldObj().spawnEntityInWorld(entity); + mana -= COST; + sync(); + } + } - mana -= COST; - sync(); - } - } + @Override + public int getColor() { + return 0x274A00; + } - @Override - public int getColor() { - return 0x274A00; - } + @Override + public LexiconEntry getEntry() { + return LexiconData.loonium; + } - @Override - public LexiconEntry getEntry() { - return LexiconData.loonium; - } + @Override + public int getMaxMana() { + return COST; + } - @Override - public int getMaxMana() { - return COST; - } + @Override + public boolean acceptsRedstone() { + return true; + } - @Override - public boolean acceptsRedstone() { - return true; - } + @Override + public RadiusDescriptor getRadius() { + return new RadiusDescriptor.Square(toChunkCoordinates(), RANGE); + } - @Override - public RadiusDescriptor getRadius() { - return new RadiusDescriptor.Square(toChunkCoordinates(), RANGE); - } } diff --git a/src/main/java/vazkii/botania/common/block/subtile/functional/SubTileMarimorphosis.java b/src/main/java/vazkii/botania/common/block/subtile/functional/SubTileMarimorphosis.java index 937788a9d9..fb2d58a898 100644 --- a/src/main/java/vazkii/botania/common/block/subtile/functional/SubTileMarimorphosis.java +++ b/src/main/java/vazkii/botania/common/block/subtile/functional/SubTileMarimorphosis.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jan 29, 2015, 8:17:55 PM (GMT)] */ package vazkii.botania.common.block.subtile.functional; @@ -13,6 +13,7 @@ import java.util.ArrayList; import java.util.Arrays; import java.util.List; + import net.minecraft.block.Block; import net.minecraft.init.Blocks; import net.minecraft.item.ItemStack; @@ -28,128 +29,122 @@ public class SubTileMarimorphosis extends SubTileFunctional { - private static final int COST = 12; - private static final int RANGE = 8; - private static final int RANGE_Y = 5; - - private static final int RANGE_MINI = 2; - private static final int RANGE_Y_MINI = 1; - - private static final Type[] TYPES = new Type[] { - Type.FOREST, Type.PLAINS, Type.MOUNTAIN, Type.MUSHROOM, Type.SWAMP, Type.SANDY, Type.COLD, Type.MESA - }; - - @Override - public void onUpdate() { - super.onUpdate(); - if (redstoneSignal > 0) return; - - if (!supertile.getWorldObj().isRemote && mana >= COST && ticksExisted % 2 == 0) { - ChunkCoordinates coords = getCoordsToPut(); - if (coords != null) { - ItemStack stack = getStoneToPut(coords); - if (stack != null) { - Block block = Block.getBlockFromItem(stack.getItem()); - int meta = stack.getItemDamage(); - supertile.getWorldObj().setBlock(coords.posX, coords.posY, coords.posZ, block, meta, 1 | 2); - if (ConfigHandler.blockBreakParticles) - supertile - .getWorldObj() - .playAuxSFX( - 2001, - coords.posX, - coords.posY, - coords.posZ, - Block.getIdFromBlock(block) + (meta << 12)); - - mana -= COST; - sync(); - } - } - } - } - - public ItemStack getStoneToPut(ChunkCoordinates coords) { - List types = Arrays.asList(BiomeDictionary.getTypesForBiome( - supertile.getWorldObj().getBiomeGenForCoords(coords.posX, coords.posZ))); - - List values = new ArrayList(); - for (int i = 0; i < 8; i++) { - int times = 1; - if (types.contains(TYPES[i])) times = 12; - - for (int j = 0; j < times; j++) values.add(i); - } - - return new ItemStack( - ModFluffBlocks.biomeStoneA, - 1, - values.get(supertile.getWorldObj().rand.nextInt(values.size()))); - } - - public ChunkCoordinates getCoordsToPut() { - List possibleCoords = new ArrayList(); - - int range = getRange(); - int rangeY = getRangeY(); - - for (int i = -range; i < range + 1; i++) - for (int j = -rangeY; j < rangeY; j++) - for (int k = -range; k < range + 1; k++) { - int x = supertile.xCoord + i; - int y = supertile.yCoord + j; - int z = supertile.zCoord + k; - Block block = supertile.getWorldObj().getBlock(x, y, z); - if (block != null && block.isReplaceableOreGen(supertile.getWorldObj(), x, y, z, Blocks.stone)) - possibleCoords.add(new ChunkCoordinates(x, y, z)); - } - - if (possibleCoords.isEmpty()) return null; - return possibleCoords.get(supertile.getWorldObj().rand.nextInt(possibleCoords.size())); - } - - @Override - public RadiusDescriptor getRadius() { - return new RadiusDescriptor.Square(toChunkCoordinates(), getRange()); - } - - public int getRange() { - return RANGE; - } - - public int getRangeY() { - return RANGE_Y; - } - - @Override - public int getColor() { - return 0x769897; - } - - @Override - public boolean acceptsRedstone() { - return true; - } - - @Override - public int getMaxMana() { - return 1000; - } - - @Override - public LexiconEntry getEntry() { - return LexiconData.marimorphosis; - } - - public static class Mini extends SubTileMarimorphosis { - @Override - public int getRange() { - return RANGE_MINI; - } - - @Override - public int getRangeY() { - return RANGE_Y_MINI; - } - } + private static final int COST = 12; + private static final int RANGE = 8; + private static final int RANGE_Y = 5; + + private static final int RANGE_MINI = 2; + private static final int RANGE_Y_MINI = 1; + + private static final Type[] TYPES = new Type[] { + Type.FOREST, + Type.PLAINS, + Type.MOUNTAIN, + Type.MUSHROOM, + Type.SWAMP, + Type.SANDY, + Type.COLD, + Type.MESA + }; + + @Override + public void onUpdate() { + super.onUpdate(); + if(redstoneSignal > 0) + return; + + if(!supertile.getWorldObj().isRemote && mana >= COST && ticksExisted % 2 == 0) { + ChunkCoordinates coords = getCoordsToPut(); + if(coords != null) { + ItemStack stack = getStoneToPut(coords); + if(stack != null) { + Block block = Block.getBlockFromItem(stack.getItem()); + int meta = stack.getItemDamage(); + supertile.getWorldObj().setBlock(coords.posX, coords.posY, coords.posZ, block, meta, 1 | 2); + if(ConfigHandler.blockBreakParticles) + supertile.getWorldObj().playAuxSFX(2001, coords.posX, coords.posY, coords.posZ, Block.getIdFromBlock(block) + (meta << 12)); + + mana -= COST; + sync(); + } + } + } + } + + public ItemStack getStoneToPut(ChunkCoordinates coords) { + List types = Arrays.asList(BiomeDictionary.getTypesForBiome(supertile.getWorldObj().getBiomeGenForCoords(coords.posX, coords.posZ))); + + List values = new ArrayList(); + for(int i = 0; i < 8; i++) { + int times = 1; + if(types.contains(TYPES[i])) + times = 12; + + for(int j = 0; j < times; j++) + values.add(i); + } + + return new ItemStack(ModFluffBlocks.biomeStoneA, 1, values.get(supertile.getWorldObj().rand.nextInt(values.size()))); + } + + public ChunkCoordinates getCoordsToPut() { + List possibleCoords = new ArrayList(); + + int range = getRange(); + int rangeY = getRangeY(); + + for(int i = -range; i < range + 1; i++) + for(int j = -rangeY; j < rangeY; j++) + for(int k = -range; k < range + 1; k++) { + int x = supertile.xCoord + i; + int y = supertile.yCoord + j; + int z = supertile.zCoord + k; + Block block = supertile.getWorldObj().getBlock(x, y, z); + if(block != null && block.isReplaceableOreGen(supertile.getWorldObj(), x, y, z, Blocks.stone)) + possibleCoords.add(new ChunkCoordinates(x, y, z)); + } + + if(possibleCoords.isEmpty()) + return null; + return possibleCoords.get(supertile.getWorldObj().rand.nextInt(possibleCoords.size())); + } + + @Override + public RadiusDescriptor getRadius() { + return new RadiusDescriptor.Square(toChunkCoordinates(), getRange()); + } + + public int getRange() { + return RANGE; + } + + public int getRangeY() { + return RANGE_Y; + } + + @Override + public int getColor() { + return 0x769897; + } + + @Override + public boolean acceptsRedstone() { + return true; + } + + @Override + public int getMaxMana() { + return 1000; + } + + @Override + public LexiconEntry getEntry() { + return LexiconData.marimorphosis; + } + + public static class Mini extends SubTileMarimorphosis { + @Override public int getRange() { return RANGE_MINI; } + @Override public int getRangeY() { return RANGE_Y_MINI; } + } + } diff --git a/src/main/java/vazkii/botania/common/block/subtile/functional/SubTileMedumone.java b/src/main/java/vazkii/botania/common/block/subtile/functional/SubTileMedumone.java index e4c8df385b..ec614af021 100644 --- a/src/main/java/vazkii/botania/common/block/subtile/functional/SubTileMedumone.java +++ b/src/main/java/vazkii/botania/common/block/subtile/functional/SubTileMedumone.java @@ -2,15 +2,16 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jan 27, 2015, 7:33:17 PM (GMT)] */ package vazkii.botania.common.block.subtile.functional; import java.util.List; + import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.potion.Potion; @@ -23,56 +24,48 @@ public class SubTileMedumone extends SubTileFunctional { - private static final int RANGE = 6; + private static final int RANGE = 6; + + @Override + public void onUpdate() { + super.onUpdate(); - @Override - public void onUpdate() { - super.onUpdate(); + if(mana > 0) { + List entities = supertile.getWorldObj().getEntitiesWithinAABB(EntityLivingBase.class, AxisAlignedBB.getBoundingBox(supertile.xCoord - RANGE, supertile.yCoord, supertile.zCoord - RANGE, supertile.xCoord + RANGE + 1, supertile.yCoord + 1, supertile.zCoord + RANGE + 1)); - if (mana > 0) { - List entities = supertile - .getWorldObj() - .getEntitiesWithinAABB( - EntityLivingBase.class, - AxisAlignedBB.getBoundingBox( - supertile.xCoord - RANGE, - supertile.yCoord, - supertile.zCoord - RANGE, - supertile.xCoord + RANGE + 1, - supertile.yCoord + 1, - supertile.zCoord + RANGE + 1)); + for(EntityLivingBase entity : entities) + if(!(entity instanceof EntityPlayer)) { + entity.addPotionEffect(new PotionEffect(Potion.moveSlowdown.id, 2, 100)); + mana--; + if(mana == 0) + return; + } + } + } - for (EntityLivingBase entity : entities) - if (!(entity instanceof EntityPlayer)) { - entity.addPotionEffect(new PotionEffect(Potion.moveSlowdown.id, 2, 100)); - mana--; - if (mana == 0) return; - } - } - } + @Override + public boolean acceptsRedstone() { + return true; + } - @Override - public boolean acceptsRedstone() { - return true; - } + @Override + public RadiusDescriptor getRadius() { + return new RadiusDescriptor.Square(toChunkCoordinates(), RANGE); + } - @Override - public RadiusDescriptor getRadius() { - return new RadiusDescriptor.Square(toChunkCoordinates(), RANGE); - } + @Override + public int getColor() { + return 0x3D2204; + } - @Override - public int getColor() { - return 0x3D2204; - } + @Override + public int getMaxMana() { + return 4000; + } - @Override - public int getMaxMana() { - return 4000; - } + @Override + public LexiconEntry getEntry() { + return LexiconData.medumone; + } - @Override - public LexiconEntry getEntry() { - return LexiconData.medumone; - } } diff --git a/src/main/java/vazkii/botania/common/block/subtile/functional/SubTileOrechid.java b/src/main/java/vazkii/botania/common/block/subtile/functional/SubTileOrechid.java index d6c2e57aa3..8a027957b5 100644 --- a/src/main/java/vazkii/botania/common/block/subtile/functional/SubTileOrechid.java +++ b/src/main/java/vazkii/botania/common/block/subtile/functional/SubTileOrechid.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Mar 11, 2014, 5:40:55 PM (GMT)] */ package vazkii.botania.common.block.subtile.functional; @@ -14,6 +14,7 @@ import java.util.Collection; import java.util.List; import java.util.Map; + import net.minecraft.block.Block; import net.minecraft.init.Blocks; import net.minecraft.item.Item; @@ -31,148 +32,143 @@ public class SubTileOrechid extends SubTileFunctional { - private static final int COST = 17500; - private static final int COST_GOG = 700; - private static final int DELAY = 100; - private static final int DELAY_GOG = 2; - private static final int RANGE = 5; - private static final int RANGE_Y = 3; - - @Override - public void onUpdate() { - super.onUpdate(); - - if (redstoneSignal > 0 || !canOperate()) return; - - int cost = getCost(); - if (!supertile.getWorldObj().isRemote && mana >= cost && ticksExisted % getDelay() == 0) { - ChunkCoordinates coords = getCoordsToPut(); - if (coords != null) { - ItemStack stack = getOreToPut(); - if (stack != null) { - Block block = Block.getBlockFromItem(stack.getItem()); - int meta = stack.getItemDamage(); - supertile.getWorldObj().setBlock(coords.posX, coords.posY, coords.posZ, block, meta, 1 | 2); - if (ConfigHandler.blockBreakParticles) - supertile - .getWorldObj() - .playAuxSFX( - 2001, - coords.posX, - coords.posY, - coords.posZ, - Block.getIdFromBlock(block) + (meta << 12)); - supertile - .getWorldObj() - .playSoundEffect( - supertile.xCoord, supertile.yCoord, supertile.zCoord, "botania:orechid", 2F, 1F); - - mana -= cost; - sync(); - } - } - } - } - - public ItemStack getOreToPut() { - Collection values = new ArrayList(); - Map map = getOreMap(); - for (String s : map.keySet()) values.add(new StringRandomItem(map.get(s), s)); - - String ore = ((StringRandomItem) WeightedRandom.getRandomItem(supertile.getWorldObj().rand, values)).s; - - List ores = OreDictionary.getOres(ore); - - for (ItemStack stack : ores) { - Item item = stack.getItem(); - String clname = item.getClass().getName(); - - // This poem is dedicated to Greg - // - // Greg. - // I get what you do when - // others say it's a grind. - // But take your TE ores - // and stick them in your behind. - if (clname.startsWith("gregtech") || clname.startsWith("gregapi")) continue; - - return stack; - } - - return getOreToPut(); - } - - public ChunkCoordinates getCoordsToPut() { - List possibleCoords = new ArrayList(); - - Block source = getSourceBlock(); - for (int i = -RANGE; i < RANGE + 1; i++) - for (int j = -RANGE_Y; j < RANGE_Y; j++) - for (int k = -RANGE; k < RANGE + 1; k++) { - int x = supertile.xCoord + i; - int y = supertile.yCoord + j; - int z = supertile.zCoord + k; - Block block = supertile.getWorldObj().getBlock(x, y, z); - if (block != null && block.isReplaceableOreGen(supertile.getWorldObj(), x, y, z, source)) - possibleCoords.add(new ChunkCoordinates(x, y, z)); - } - - if (possibleCoords.isEmpty()) return null; - return possibleCoords.get(supertile.getWorldObj().rand.nextInt(possibleCoords.size())); - } - - public boolean canOperate() { - return true; - } - - public Map getOreMap() { - return BotaniaAPI.oreWeights; - } - - public Block getSourceBlock() { - return Blocks.stone; - } - - public int getCost() { - return Botania.gardenOfGlassLoaded ? COST_GOG : COST; - } - - public int getDelay() { - return Botania.gardenOfGlassLoaded ? DELAY_GOG : DELAY; - } - - @Override - public RadiusDescriptor getRadius() { - return new RadiusDescriptor.Square(toChunkCoordinates(), RANGE); - } - - @Override - public boolean acceptsRedstone() { - return true; - } - - @Override - public int getColor() { - return 0x818181; - } - - @Override - public int getMaxMana() { - return getCost(); - } - - @Override - public LexiconEntry getEntry() { - return LexiconData.orechid; - } - - private static class StringRandomItem extends WeightedRandom.Item { - - public String s; - - public StringRandomItem(int par1, String s) { - super(par1); - this.s = s; - } - } + private static final int COST = 17500; + private static final int COST_GOG = 700; + private static final int DELAY = 100; + private static final int DELAY_GOG = 2; + private static final int RANGE = 5; + private static final int RANGE_Y = 3; + + @Override + public void onUpdate() { + super.onUpdate(); + + if(redstoneSignal > 0 || !canOperate()) + return; + + int cost = getCost(); + if(!supertile.getWorldObj().isRemote && mana >= cost && ticksExisted % getDelay() == 0) { + ChunkCoordinates coords = getCoordsToPut(); + if(coords != null) { + ItemStack stack = getOreToPut(); + if(stack != null) { + Block block = Block.getBlockFromItem(stack.getItem()); + int meta = stack.getItemDamage(); + supertile.getWorldObj().setBlock(coords.posX, coords.posY, coords.posZ, block, meta, 1 | 2); + if(ConfigHandler.blockBreakParticles) + supertile.getWorldObj().playAuxSFX(2001, coords.posX, coords.posY, coords.posZ, Block.getIdFromBlock(block) + (meta << 12)); + supertile.getWorldObj().playSoundEffect(supertile.xCoord, supertile.yCoord, supertile.zCoord, "botania:orechid", 2F, 1F); + + mana -= cost; + sync(); + } + } + } + } + + public ItemStack getOreToPut() { + Collection values = new ArrayList(); + Map map = getOreMap(); + for(String s : map.keySet()) + values.add(new StringRandomItem(map.get(s), s)); + + String ore = ((StringRandomItem) WeightedRandom.getRandomItem(supertile.getWorldObj().rand, values)).s; + + List ores = OreDictionary.getOres(ore); + + for(ItemStack stack : ores) { + Item item = stack.getItem(); + String clname = item.getClass().getName(); + + // This poem is dedicated to Greg + // + // Greg. + // I get what you do when + // others say it's a grind. + // But take your TE ores + // and stick them in your behind. + if(clname.startsWith("gregtech") || clname.startsWith("gregapi")) + continue; + + return stack; + } + + return getOreToPut(); + } + + public ChunkCoordinates getCoordsToPut() { + List possibleCoords = new ArrayList(); + + Block source = getSourceBlock(); + for(int i = -RANGE; i < RANGE + 1; i++) + for(int j = -RANGE_Y; j < RANGE_Y; j++) + for(int k = -RANGE; k < RANGE + 1; k++) { + int x = supertile.xCoord + i; + int y = supertile.yCoord + j; + int z = supertile.zCoord + k; + Block block = supertile.getWorldObj().getBlock(x, y, z); + if(block != null && block.isReplaceableOreGen(supertile.getWorldObj(), x, y, z, source)) + possibleCoords.add(new ChunkCoordinates(x, y, z)); + } + + if(possibleCoords.isEmpty()) + return null; + return possibleCoords.get(supertile.getWorldObj().rand.nextInt(possibleCoords.size())); + } + + public boolean canOperate() { + return true; + } + + public Map getOreMap() { + return BotaniaAPI.oreWeights; + } + + public Block getSourceBlock() { + return Blocks.stone; + } + + public int getCost() { + return Botania.gardenOfGlassLoaded ? COST_GOG : COST; + } + + public int getDelay() { + return Botania.gardenOfGlassLoaded ? DELAY_GOG : DELAY; + } + + @Override + public RadiusDescriptor getRadius() { + return new RadiusDescriptor.Square(toChunkCoordinates(), RANGE); + } + + @Override + public boolean acceptsRedstone() { + return true; + } + + @Override + public int getColor() { + return 0x818181; + } + + @Override + public int getMaxMana() { + return getCost(); + } + + @Override + public LexiconEntry getEntry() { + return LexiconData.orechid; + } + + private static class StringRandomItem extends WeightedRandom.Item { + + public String s; + + public StringRandomItem(int par1, String s) { + super(par1); + this.s = s; + } + + } } diff --git a/src/main/java/vazkii/botania/common/block/subtile/functional/SubTileOrechidIgnem.java b/src/main/java/vazkii/botania/common/block/subtile/functional/SubTileOrechidIgnem.java index 1203285a09..0b6a21f0e2 100644 --- a/src/main/java/vazkii/botania/common/block/subtile/functional/SubTileOrechidIgnem.java +++ b/src/main/java/vazkii/botania/common/block/subtile/functional/SubTileOrechidIgnem.java @@ -2,15 +2,16 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Apr 30, 2015, 3:27:20 PM (GMT)] */ package vazkii.botania.common.block.subtile.functional; import java.util.Map; + import net.minecraft.block.Block; import net.minecraft.init.Blocks; import vazkii.botania.api.BotaniaAPI; @@ -19,35 +20,36 @@ public class SubTileOrechidIgnem extends SubTileOrechid { - private static final int COST = 20000; - - @Override - public boolean canOperate() { - return supertile.getWorldObj().provider.isHellWorld; - } - - @Override - public Map getOreMap() { - return BotaniaAPI.oreWeightsNether; - } - - @Override - public Block getSourceBlock() { - return Blocks.netherrack; - } - - @Override - public int getCost() { - return COST; - } - - @Override - public int getColor() { - return 0xAE3030; - } - - @Override - public LexiconEntry getEntry() { - return LexiconData.orechidIgnem; - } + private static final int COST = 20000; + + @Override + public boolean canOperate() { + return supertile.getWorldObj().provider.isHellWorld; + } + + @Override + public Map getOreMap() { + return BotaniaAPI.oreWeightsNether; + } + + @Override + public Block getSourceBlock() { + return Blocks.netherrack; + } + + @Override + public int getCost() { + return COST; + } + + @Override + public int getColor() { + return 0xAE3030; + } + + @Override + public LexiconEntry getEntry() { + return LexiconData.orechidIgnem; + } + } diff --git a/src/main/java/vazkii/botania/common/block/subtile/functional/SubTilePollidisiac.java b/src/main/java/vazkii/botania/common/block/subtile/functional/SubTilePollidisiac.java index 00c024af95..485c81318e 100644 --- a/src/main/java/vazkii/botania/common/block/subtile/functional/SubTilePollidisiac.java +++ b/src/main/java/vazkii/botania/common/block/subtile/functional/SubTilePollidisiac.java @@ -2,16 +2,16 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [May 15, 2014, 5:56:47 PM (GMT)] */ package vazkii.botania.common.block.subtile.functional; -import cpw.mods.fml.relauncher.ReflectionHelper; import java.util.List; + import net.minecraft.entity.item.EntityItem; import net.minecraft.entity.passive.EntityAnimal; import net.minecraft.item.ItemStack; @@ -21,84 +21,68 @@ import vazkii.botania.api.subtile.SubTileFunctional; import vazkii.botania.common.lexicon.LexiconData; import vazkii.botania.common.lib.LibObfuscation; +import cpw.mods.fml.relauncher.ReflectionHelper; public class SubTilePollidisiac extends SubTileFunctional { - private static final int RANGE = 6; - - @Override - public void onUpdate() { - super.onUpdate(); + private static final int RANGE = 6; - if (!supertile.getWorldObj().isRemote) { - int manaCost = 12; + @Override + public void onUpdate() { + super.onUpdate(); - List items = supertile - .getWorldObj() - .getEntitiesWithinAABB( - EntityItem.class, - AxisAlignedBB.getBoundingBox( - supertile.xCoord - RANGE, - supertile.yCoord, - supertile.zCoord - RANGE, - supertile.xCoord + 1 + RANGE, - supertile.yCoord + 1, - supertile.zCoord + 1 + RANGE)); - List animals = supertile - .getWorldObj() - .getEntitiesWithinAABB( - EntityAnimal.class, - AxisAlignedBB.getBoundingBox( - supertile.xCoord - RANGE, - supertile.yCoord, - supertile.zCoord - RANGE, - supertile.xCoord + 1 + RANGE, - supertile.yCoord + 1, - supertile.zCoord + 1 + RANGE)); - int slowdown = getSlowdownFactor(); + if(!supertile.getWorldObj().isRemote) { + int manaCost = 12; - for (EntityAnimal animal : animals) { - if (mana < manaCost) break; + List items = supertile.getWorldObj().getEntitiesWithinAABB(EntityItem.class, AxisAlignedBB.getBoundingBox(supertile.xCoord - RANGE, supertile.yCoord, supertile.zCoord - RANGE, supertile.xCoord + 1 + RANGE, supertile.yCoord + 1, supertile.zCoord + 1 +RANGE)); + List animals = supertile.getWorldObj().getEntitiesWithinAABB(EntityAnimal.class, AxisAlignedBB.getBoundingBox(supertile.xCoord - RANGE, supertile.yCoord, supertile.zCoord - RANGE, supertile.xCoord + 1 +RANGE, supertile.yCoord + 1, supertile.zCoord + 1 +RANGE)); + int slowdown = getSlowdownFactor(); + + for(EntityAnimal animal : animals) { + if(mana < manaCost) + break; - int love = ReflectionHelper.getPrivateValue(EntityAnimal.class, animal, LibObfuscation.IN_LOVE); - if (animal.getGrowingAge() == 0 && love <= 0) { - for (EntityItem item : items) { - if (item.age < (60 + slowdown) || item.isDead) continue; + int love = ReflectionHelper.getPrivateValue(EntityAnimal.class, animal, LibObfuscation.IN_LOVE); + if(animal.getGrowingAge() == 0 && love <= 0) { + for(EntityItem item : items) { + if(item.age < (60 + slowdown) || item.isDead) + continue; - ItemStack stack = item.getEntityItem(); - if (animal.isBreedingItem(stack)) { - stack.stackSize--; - if (stack.stackSize == 0) item.setDead(); + ItemStack stack = item.getEntityItem(); + if(animal.isBreedingItem(stack)) { + stack.stackSize--; + if(stack.stackSize == 0) + item.setDead(); - mana -= manaCost; + mana -= manaCost; - ReflectionHelper.setPrivateValue(EntityAnimal.class, animal, 1200, LibObfuscation.IN_LOVE); - animal.setTarget(null); - supertile.getWorldObj().setEntityState(animal, (byte) 18); - } - } - } - } - } - } + ReflectionHelper.setPrivateValue(EntityAnimal.class, animal, 1200, LibObfuscation.IN_LOVE); + animal.setTarget(null); + supertile.getWorldObj().setEntityState(animal, (byte)18); + } + } + } + } + } + } - @Override - public RadiusDescriptor getRadius() { - return new RadiusDescriptor.Square(toChunkCoordinates(), RANGE); - } + @Override + public RadiusDescriptor getRadius() { + return new RadiusDescriptor.Square(toChunkCoordinates(), RANGE); + } - @Override - public int getMaxMana() { - return 120; - } + @Override + public int getMaxMana() { + return 120; + } - @Override - public int getColor() { - return 0xCF4919; - } + @Override + public int getColor() { + return 0xCF4919; + } - @Override - public LexiconEntry getEntry() { - return LexiconData.pollidisiac; - } + @Override + public LexiconEntry getEntry() { + return LexiconData.pollidisiac; + } } diff --git a/src/main/java/vazkii/botania/common/block/subtile/functional/SubTileRannuncarpus.java b/src/main/java/vazkii/botania/common/block/subtile/functional/SubTileRannuncarpus.java index ad51505ac1..f890fd7783 100644 --- a/src/main/java/vazkii/botania/common/block/subtile/functional/SubTileRannuncarpus.java +++ b/src/main/java/vazkii/botania/common/block/subtile/functional/SubTileRannuncarpus.java @@ -2,17 +2,17 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [May 1, 2014, 6:08:25 PM (GMT)] */ package vazkii.botania.common.block.subtile.functional; -import cpw.mods.fml.relauncher.ReflectionHelper; import java.util.ArrayList; import java.util.List; + import net.minecraft.block.Block; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.ScaledResolution; @@ -29,7 +29,9 @@ import net.minecraft.util.AxisAlignedBB; import net.minecraft.util.ChunkCoordinates; import net.minecraft.world.World; + import org.lwjgl.opengl.GL11; + import vazkii.botania.api.item.IFlowerPlaceable; import vazkii.botania.api.lexicon.LexiconEntry; import vazkii.botania.api.subtile.ISubTileContainer; @@ -41,240 +43,201 @@ import vazkii.botania.common.item.block.ItemBlockSpecialFlower; import vazkii.botania.common.lexicon.LexiconData; import vazkii.botania.common.lib.LibObfuscation; +import cpw.mods.fml.relauncher.ReflectionHelper; public class SubTileRannuncarpus extends SubTileFunctional { - private static final int RANGE = 2; - private static final int RANGE_Y = 3; - private static final int RANGE_PLACE_MANA = 8; - private static final int RANGE_PLACE = 6; - private static final int RANGE_PLACE_Y = 6; - - private static final int RANGE_PLACE_MANA_MINI = 3; - private static final int RANGE_PLACE_MINI = 2; - private static final int RANGE_PLACE_Y_MINI = 2; - - @Override - public void onUpdate() { - super.onUpdate(); - - if (redstoneSignal > 0) return; - - if (ticksExisted % 10 == 0) { - BlockData filter = getUnderlyingBlock(); - - boolean scanned = false; - List validPositions = new ArrayList(); - - int rangePlace = getRange(); - int rangePlaceY = getRangeY(); - - int x = supertile.xCoord; - int y = supertile.yCoord; - int z = supertile.zCoord; - - List items = supertile - .getWorldObj() - .getEntitiesWithinAABB( - EntityItem.class, - AxisAlignedBB.getBoundingBox( - x - RANGE, y - RANGE_Y, z - RANGE, x + RANGE + 1, y + RANGE_Y, z + RANGE + 1)); - int slowdown = getSlowdownFactor(); - for (EntityItem item : items) { - if (item.age < (60 + slowdown) || item.isDead) continue; - - ItemStack stack = item.getEntityItem(); - Item stackItem = stack.getItem(); - if (stackItem instanceof ItemBlock - || stackItem instanceof ItemReed - || stackItem instanceof ItemRedstone - || stackItem instanceof IFlowerPlaceable) { - if (!scanned) { - for (int i = -rangePlace; i < rangePlace + 1; i++) - for (int j = -rangePlaceY; j < rangePlaceY + 1; j++) - for (int l = -rangePlace; l < rangePlace + 1; l++) { - int xp = x + i; - int yp = y + j; - int zp = z + l; - Block blockAbove = supertile.getWorldObj().getBlock(xp, yp + 1, zp); - - if (filter.equals(supertile.getWorldObj(), xp, yp, zp) - && (blockAbove.isAir(supertile.getWorldObj(), xp, yp + 1, zp) - || blockAbove.isReplaceable( - supertile.getWorldObj(), xp, yp + 1, zp))) - validPositions.add(new ChunkCoordinates(xp, yp + 1, zp)); - } - - scanned = true; - } - - if (!validPositions.isEmpty() && !supertile.getWorldObj().isRemote) { - ChunkCoordinates coords = - validPositions.get(supertile.getWorldObj().rand.nextInt(validPositions.size())); - - Block blockToPlace = null; - if (stackItem instanceof IFlowerPlaceable) - blockToPlace = ((IFlowerPlaceable) stackItem) - .getBlockToPlaceByFlower(stack, this, coords.posX, coords.posY, coords.posZ); - if (stackItem instanceof ItemBlock) blockToPlace = ((ItemBlock) stackItem).field_150939_a; - else if (stackItem instanceof ItemReed) - blockToPlace = ReflectionHelper.getPrivateValue( - ItemReed.class, (ItemReed) stackItem, LibObfuscation.REED_ITEM); - else if (stackItem instanceof ItemRedstone) blockToPlace = Blocks.redstone_wire; - - if (blockToPlace != null) { - if (blockToPlace.canPlaceBlockAt( - supertile.getWorldObj(), coords.posX, coords.posY, coords.posZ)) { - supertile - .getWorldObj() - .setBlock( - coords.posX, - coords.posY, - coords.posZ, - blockToPlace, - stack.getItemDamage(), - 1 | 2); - if (ConfigHandler.blockBreakParticles) - supertile - .getWorldObj() - .playAuxSFX( - 2001, - coords.posX, - coords.posY, - coords.posZ, - Block.getIdFromBlock(blockToPlace) + (stack.getItemDamage() << 12)); - validPositions.remove(coords); - - TileEntity tile = - supertile.getWorldObj().getTileEntity(coords.posX, coords.posY, coords.posZ); - if (tile != null && tile instanceof ISubTileContainer) { - ISubTileContainer container = (ISubTileContainer) tile; - String subtileName = ItemBlockSpecialFlower.getType(stack); - container.setSubTile(subtileName); - SubTileEntity subtile = container.getSubTile(); - subtile.onBlockPlacedBy( - supertile.getWorldObj(), - coords.posX, - coords.posY, - coords.posZ, - null, - stack); - } - - if (stackItem instanceof IFlowerPlaceable) - ((IFlowerPlaceable) stackItem) - .onBlockPlacedByFlower(stack, this, coords.posX, coords.posY, coords.posZ); - - if (!supertile.getWorldObj().isRemote) { - stack.stackSize--; - if (stack.stackSize == 0) item.setDead(); - } - - if (mana > 1) mana--; - return; - } - } - } - } - } - } - } - - public BlockData getUnderlyingBlock() { - return new BlockData( - supertile.getWorldObj(), - supertile.xCoord, - supertile.yCoord - (supertile instanceof IFloatingFlower ? 1 : 2), - supertile.zCoord); - } - - @Override - public boolean acceptsRedstone() { - return true; - } - - @Override - public void renderHUD(Minecraft mc, ScaledResolution res) { - super.renderHUD(mc, res); - - BlockData filter = getUnderlyingBlock(); - ItemStack recieverStack = new ItemStack(Item.getItemFromBlock(filter.block), 1, filter.meta); - int color = getColor(); - - GL11.glEnable(GL11.GL_BLEND); - GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); - if (recieverStack != null && recieverStack.getItem() != null) { - String stackName = recieverStack.getDisplayName(); - int width = 16 + mc.fontRenderer.getStringWidth(stackName) / 2; - int x = res.getScaledWidth() / 2 - width; - int y = res.getScaledHeight() / 2 + 30; - - mc.fontRenderer.drawStringWithShadow(stackName, x + 20, y + 5, color); - RenderHelper.enableGUIStandardItemLighting(); - RenderItem.getInstance().renderItemAndEffectIntoGUI(mc.fontRenderer, mc.renderEngine, recieverStack, x, y); - RenderHelper.disableStandardItemLighting(); - } - - GL11.glDisable(GL11.GL_LIGHTING); - GL11.glDisable(GL11.GL_BLEND); - } - - @Override - public RadiusDescriptor getRadius() { - return new RadiusDescriptor.Square(toChunkCoordinates(), getRange()); - } - - public int getRange() { - return mana > 0 ? RANGE_PLACE_MANA : RANGE_PLACE; - } - - public int getRangeY() { - return RANGE_PLACE_Y; - } - - @Override - public int getMaxMana() { - return 20; - } - - @Override - public int getColor() { - return 0xFFB27F; - } - - @Override - public LexiconEntry getEntry() { - return LexiconData.rannuncarpus; - } - - public static class Mini extends SubTileRannuncarpus { - @Override - public int getRange() { - return mana > 0 ? RANGE_PLACE_MANA_MINI : RANGE_PLACE_MINI; - } - - @Override - public int getRangeY() { - return RANGE_PLACE_Y_MINI; - } - } - - static class BlockData { - - Block block; - int meta; - - public BlockData(World world, int x, int y, int z) { - block = world.getBlock(x, y, z); - meta = world.getBlockMetadata(x, y, z); - } - - public boolean equals(BlockData data) { - return block == data.block && meta == data.meta; - } - - public boolean equals(World world, int x, int y, int z) { - return equals(new BlockData(world, x, y, z)); - } - } + private static final int RANGE = 2; + private static final int RANGE_Y = 3; + private static final int RANGE_PLACE_MANA = 8; + private static final int RANGE_PLACE = 6; + private static final int RANGE_PLACE_Y = 6; + + private static final int RANGE_PLACE_MANA_MINI = 3; + private static final int RANGE_PLACE_MINI = 2; + private static final int RANGE_PLACE_Y_MINI = 2; + + @Override + public void onUpdate() { + super.onUpdate(); + + if(redstoneSignal > 0) + return; + + if(ticksExisted % 10 == 0) { + BlockData filter = getUnderlyingBlock(); + + boolean scanned = false; + List validPositions = new ArrayList(); + + int rangePlace = getRange(); + int rangePlaceY = getRangeY(); + + int x = supertile.xCoord; + int y = supertile.yCoord; + int z = supertile.zCoord; + + List items = supertile.getWorldObj().getEntitiesWithinAABB(EntityItem.class, AxisAlignedBB.getBoundingBox(x - RANGE, y - RANGE_Y, z - RANGE, x + RANGE + 1, y + RANGE_Y, z + RANGE + 1)); + int slowdown = getSlowdownFactor(); + for(EntityItem item : items) { + if(item.age < (60 + slowdown) || item.isDead) + continue; + + ItemStack stack = item.getEntityItem(); + Item stackItem = stack.getItem(); + if(stackItem instanceof ItemBlock || stackItem instanceof ItemReed || stackItem instanceof ItemRedstone || stackItem instanceof IFlowerPlaceable) { + if(!scanned) { + for(int i = -rangePlace; i < rangePlace + 1; i++) + for(int j = -rangePlaceY; j < rangePlaceY + 1; j++) + for(int l = -rangePlace; l < rangePlace + 1; l++) { + int xp = x + i; + int yp = y + j; + int zp = z + l; + Block blockAbove = supertile.getWorldObj().getBlock(xp, yp + 1, zp); + + if(filter.equals(supertile.getWorldObj(), xp, yp, zp) && (blockAbove.isAir(supertile.getWorldObj(), xp, yp + 1, zp) || blockAbove.isReplaceable(supertile.getWorldObj(), xp, yp + 1, zp))) + validPositions.add(new ChunkCoordinates(xp, yp + 1, zp)); + } + + scanned = true; + } + + + if(!validPositions.isEmpty() && !supertile.getWorldObj().isRemote) { + ChunkCoordinates coords = validPositions.get(supertile.getWorldObj().rand.nextInt(validPositions.size())); + + Block blockToPlace = null; + if(stackItem instanceof IFlowerPlaceable) + blockToPlace = ((IFlowerPlaceable) stackItem).getBlockToPlaceByFlower(stack, this, coords.posX, coords.posY, coords.posZ); + if(stackItem instanceof ItemBlock) + blockToPlace = ((ItemBlock) stackItem).field_150939_a; + else if(stackItem instanceof ItemReed) + blockToPlace = ReflectionHelper.getPrivateValue(ItemReed.class, (ItemReed) stackItem, LibObfuscation.REED_ITEM); + else if(stackItem instanceof ItemRedstone) + blockToPlace = Blocks.redstone_wire; + + if(blockToPlace != null) { + if(blockToPlace.canPlaceBlockAt(supertile.getWorldObj(), coords.posX, coords.posY, coords.posZ)) { + supertile.getWorldObj().setBlock(coords.posX, coords.posY, coords.posZ, blockToPlace, stack.getItemDamage(), 1 | 2); + if(ConfigHandler.blockBreakParticles) + supertile.getWorldObj().playAuxSFX(2001, coords.posX, coords.posY, coords.posZ, Block.getIdFromBlock(blockToPlace) + (stack.getItemDamage() << 12)); + validPositions.remove(coords); + + TileEntity tile = supertile.getWorldObj().getTileEntity(coords.posX, coords.posY, coords.posZ); + if(tile != null && tile instanceof ISubTileContainer) { + ISubTileContainer container = (ISubTileContainer) tile; + String subtileName = ItemBlockSpecialFlower.getType(stack); + container.setSubTile(subtileName); + SubTileEntity subtile = container.getSubTile(); + subtile.onBlockPlacedBy(supertile.getWorldObj(), coords.posX, coords.posY, coords.posZ, null, stack); + } + + if(stackItem instanceof IFlowerPlaceable) + ((IFlowerPlaceable) stackItem).onBlockPlacedByFlower(stack, this, coords.posX, coords.posY, coords.posZ); + + if(!supertile.getWorldObj().isRemote) { + stack.stackSize--; + if(stack.stackSize == 0) + item.setDead(); + } + + if(mana > 1) + mana--; + return; + } + } + } + } + } + } + } + + public BlockData getUnderlyingBlock() { + return new BlockData(supertile.getWorldObj(), supertile.xCoord, supertile.yCoord - (supertile instanceof IFloatingFlower ? 1 : 2), supertile.zCoord); + } + + @Override + public boolean acceptsRedstone() { + return true; + } + + @Override + public void renderHUD(Minecraft mc, ScaledResolution res) { + super.renderHUD(mc, res); + + BlockData filter = getUnderlyingBlock(); + ItemStack recieverStack = new ItemStack(Item.getItemFromBlock(filter.block), 1, filter.meta); + int color = getColor(); + + GL11.glEnable(GL11.GL_BLEND); + GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); + if(recieverStack != null && recieverStack.getItem() != null) { + String stackName = recieverStack.getDisplayName(); + int width = 16 + mc.fontRenderer.getStringWidth(stackName) / 2; + int x = res.getScaledWidth() / 2 - width; + int y = res.getScaledHeight() / 2 + 30; + + mc.fontRenderer.drawStringWithShadow(stackName, x + 20, y + 5, color); + RenderHelper.enableGUIStandardItemLighting(); + RenderItem.getInstance().renderItemAndEffectIntoGUI(mc.fontRenderer, mc.renderEngine, recieverStack, x, y); + RenderHelper.disableStandardItemLighting(); + } + + GL11.glDisable(GL11.GL_LIGHTING); + GL11.glDisable(GL11.GL_BLEND); + } + + @Override + public RadiusDescriptor getRadius() { + return new RadiusDescriptor.Square(toChunkCoordinates(), getRange()); + } + + public int getRange() { + return mana > 0 ? RANGE_PLACE_MANA : RANGE_PLACE; + } + + public int getRangeY() { + return RANGE_PLACE_Y; + } + + @Override + public int getMaxMana() { + return 20; + } + + @Override + public int getColor() { + return 0xFFB27F; + } + + @Override + public LexiconEntry getEntry() { + return LexiconData.rannuncarpus; + } + + public static class Mini extends SubTileRannuncarpus { + @Override public int getRange() { return mana > 0 ? RANGE_PLACE_MANA_MINI : RANGE_PLACE_MINI; } + @Override public int getRangeY() { return RANGE_PLACE_Y_MINI; } + } + + static class BlockData { + + Block block; + int meta; + + public BlockData(World world, int x, int y, int z) { + block = world.getBlock(x, y, z); + meta = world.getBlockMetadata(x, y, z); + } + + public boolean equals(BlockData data) { + return block == data.block && meta == data.meta; + } + + public boolean equals(World world, int x, int y, int z) { + return equals(new BlockData(world, x, y, z)); + } + + } + } diff --git a/src/main/java/vazkii/botania/common/block/subtile/functional/SubTileSolegnolia.java b/src/main/java/vazkii/botania/common/block/subtile/functional/SubTileSolegnolia.java index ee5b10d846..9ad426e520 100644 --- a/src/main/java/vazkii/botania/common/block/subtile/functional/SubTileSolegnolia.java +++ b/src/main/java/vazkii/botania/common/block/subtile/functional/SubTileSolegnolia.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Apr 11, 2015, 4:53:35 PM (GMT)] */ package vazkii.botania.common.block.subtile.functional; @@ -13,6 +13,7 @@ import java.util.Collections; import java.util.Set; import java.util.WeakHashMap; + import net.minecraft.entity.Entity; import vazkii.botania.api.lexicon.LexiconEntry; import vazkii.botania.api.subtile.RadiusDescriptor; @@ -22,79 +23,67 @@ public class SubTileSolegnolia extends SubTileFunctional { - private static final double RANGE = 5; - private static final double RANGE_MINI = 1; - - public static Set existingFlowers = Collections.newSetFromMap(new WeakHashMap()); - private static boolean registered = false; - - @Override - public void onUpdate() { - super.onUpdate(); - - if (!existingFlowers.contains(this)) { - existingFlowers.add(this); - if (!registered) registered = true; - } - } - - @Override - public boolean acceptsRedstone() { - return true; - } - - public static boolean hasSolegnoliaAround(Entity e) { - for (SubTileSolegnolia flower : existingFlowers) { - if (flower.redstoneSignal > 0 - || flower.supertile.getWorldObj() != e.worldObj - || flower.supertile - .getWorldObj() - .getTileEntity( - flower.supertile.xCoord, flower.supertile.yCoord, flower.supertile.zCoord) - != flower.supertile) continue; - - double range = flower.getRange(); - if (MathHelper.pointDistanceSpace( - e.posX, - e.posY, - e.posZ, - flower.supertile.xCoord + 0.5, - flower.supertile.yCoord + 0.5, - flower.supertile.zCoord + 0.5) - <= range) return true; - } - - return false; - } - - @Override - public int getMaxMana() { - return 1; - } - - @Override - public int getColor() { - return 0xC99C4D; - } - - public double getRange() { - return RANGE; - } - - @Override - public RadiusDescriptor getRadius() { - return new RadiusDescriptor.Circle(toChunkCoordinates(), getRange()); - } - - @Override - public LexiconEntry getEntry() { - return LexiconData.solegnolia; - } - - public static class Mini extends SubTileSolegnolia { - @Override - public double getRange() { - return RANGE_MINI; - } - } + private static final double RANGE = 5; + private static final double RANGE_MINI = 1; + + public static Set existingFlowers = Collections.newSetFromMap(new WeakHashMap()); + private static boolean registered = false; + + @Override + public void onUpdate() { + super.onUpdate(); + + if(!existingFlowers.contains(this)) { + existingFlowers.add(this); + if(!registered) + registered = true; + } + } + + @Override + public boolean acceptsRedstone() { + return true; + } + + public static boolean hasSolegnoliaAround(Entity e) { + for(SubTileSolegnolia flower : existingFlowers) { + if(flower.redstoneSignal > 0 || flower.supertile.getWorldObj() != e.worldObj || flower.supertile.getWorldObj().getTileEntity(flower.supertile.xCoord, flower.supertile.yCoord, flower.supertile.zCoord) != flower.supertile) + continue; + + double range = flower.getRange(); + if(MathHelper.pointDistanceSpace(e.posX, e.posY, e.posZ, flower.supertile.xCoord + 0.5, flower.supertile.yCoord + 0.5, flower.supertile.zCoord + 0.5) <= range) + return true; + } + + return false; + } + + @Override + public int getMaxMana() { + return 1; + } + + @Override + public int getColor() { + return 0xC99C4D; + } + + public double getRange() { + return RANGE; + } + + @Override + public RadiusDescriptor getRadius() { + return new RadiusDescriptor.Circle(toChunkCoordinates(), getRange()); + } + + @Override + public LexiconEntry getEntry() { + return LexiconData.solegnolia; + } + + public static class Mini extends SubTileSolegnolia { + @Override public double getRange() { return RANGE_MINI; } + } + } diff --git a/src/main/java/vazkii/botania/common/block/subtile/functional/SubTileSpectranthemum.java b/src/main/java/vazkii/botania/common/block/subtile/functional/SubTileSpectranthemum.java index 4445ea98ee..d896964901 100644 --- a/src/main/java/vazkii/botania/common/block/subtile/functional/SubTileSpectranthemum.java +++ b/src/main/java/vazkii/botania/common/block/subtile/functional/SubTileSpectranthemum.java @@ -2,17 +2,16 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jan 27, 2015, 4:06:58 PM (GMT)] */ package vazkii.botania.common.block.subtile.functional; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; import java.util.List; + import net.minecraft.client.Minecraft; import net.minecraft.entity.item.EntityItem; import net.minecraft.entity.player.EntityPlayer; @@ -27,152 +26,138 @@ import vazkii.botania.api.subtile.SubTileFunctional; import vazkii.botania.common.core.helper.MathHelper; import vazkii.botania.common.lexicon.LexiconData; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; public class SubTileSpectranthemum extends SubTileFunctional { - private static final String TAG_BIND_X = "bindX"; - private static final String TAG_BIND_Y = "bindY"; - private static final String TAG_BIND_Z = "bindZ"; - - private static final int COST = 24; - private static final int RANGE = 2; - private static final int BIND_RANGE = 12; - - private static final String TAG_TELEPORTED = "Botania_TPd"; - - int bindX, bindY = -1, bindZ; - - @Override - public void onUpdate() { - super.onUpdate(); - - if (redstoneSignal == 0 && supertile.getWorldObj().blockExists(bindX, bindY, bindZ)) { - int x = supertile.xCoord; - int y = supertile.yCoord; - int z = supertile.zCoord; - - boolean did = false; - List items = supertile - .getWorldObj() - .getEntitiesWithinAABB( - EntityItem.class, - AxisAlignedBB.getBoundingBox( - x - RANGE, y - RANGE, z - RANGE, x + RANGE + 1, y + RANGE, z + RANGE + 1)); - int slowdown = getSlowdownFactor(); - - for (EntityItem item : items) { - if (item.age < (60 + slowdown) - || item.isDead - || item.getEntityData().getBoolean(TAG_TELEPORTED)) continue; - - ItemStack stack = item.getEntityItem(); - if (stack != null) { - Item sitem = stack.getItem(); - if (sitem instanceof IManaItem) continue; - - int cost = stack.stackSize * COST; - if (mana >= cost) { - spawnExplosionParticles(item, 10); - item.setPosition(bindX + 0.5, bindY + 1.5, bindZ + 0.5); - item.getEntityData().setBoolean(TAG_TELEPORTED, true); - item.motionX = item.motionY = item.motionZ = 0; - spawnExplosionParticles(item, 10); - if (!supertile.getWorldObj().isRemote) { - mana -= cost; - did = true; - } - } - } - } - - if (did) sync(); - } - } - - public static void spawnExplosionParticles(EntityItem item, int p) { - for (int i = 0; i < p; i++) { - double m = 0.01; - double d0 = item.worldObj.rand.nextGaussian() * m; - double d1 = item.worldObj.rand.nextGaussian() * m; - double d2 = item.worldObj.rand.nextGaussian() * m; - double d3 = 10.0D; - item.worldObj.spawnParticle( - "explode", - item.posX + item.worldObj.rand.nextFloat() * item.width * 2.0F - item.width - d0 * d3, - item.posY + item.worldObj.rand.nextFloat() * item.height - d1 * d3, - item.posZ + item.worldObj.rand.nextFloat() * item.width * 2.0F - item.width - d2 * d3, - d0, - d1, - d2); - } - } - - @Override - public RadiusDescriptor getRadius() { - return new RadiusDescriptor.Square(toChunkCoordinates(), RANGE); - } - - @Override - public void writeToPacketNBT(NBTTagCompound cmp) { - super.writeToPacketNBT(cmp); - cmp.setInteger(TAG_BIND_X, bindX); - cmp.setInteger(TAG_BIND_Y, bindY); - cmp.setInteger(TAG_BIND_Z, bindZ); - } - - @Override - public void readFromPacketNBT(NBTTagCompound cmp) { - super.readFromPacketNBT(cmp); - bindX = cmp.getInteger(TAG_BIND_X); - bindY = cmp.getInteger(TAG_BIND_Y); - bindZ = cmp.getInteger(TAG_BIND_Z); - } - - @Override - public boolean acceptsRedstone() { - return true; - } - - @Override - public int getColor() { - return 0x98BCFF; - } - - @Override - public int getMaxMana() { - return 16000; - } - - @Override - public boolean bindTo(EntityPlayer player, ItemStack wand, int x, int y, int z, int side) { - boolean bound = super.bindTo(player, wand, x, y, z, side); - - if (!bound - && (x != bindX || y != bindY || z != bindZ) - && MathHelper.pointDistanceSpace(x, y, z, supertile.xCoord, supertile.yCoord, supertile.zCoord) - <= BIND_RANGE - && (x != supertile.xCoord || y != supertile.yCoord || z != supertile.zCoord)) { - bindX = x; - bindY = y; - bindZ = z; - sync(); - - return true; - } - - return bound; - } - - @Override - @SideOnly(Side.CLIENT) - public ChunkCoordinates getBinding() { - return Minecraft.getMinecraft().thePlayer.isSneaking() && bindY != -1 - ? new ChunkCoordinates(bindX, bindY, bindZ) - : super.getBinding(); - } - - @Override - public LexiconEntry getEntry() { - return LexiconData.spectranthemum; - } + private static final String TAG_BIND_X = "bindX"; + private static final String TAG_BIND_Y = "bindY"; + private static final String TAG_BIND_Z = "bindZ"; + + private static final int COST = 24; + private static final int RANGE = 2; + private static final int BIND_RANGE = 12; + + private static final String TAG_TELEPORTED = "Botania_TPd"; + + int bindX, bindY = -1, bindZ; + + @Override + public void onUpdate() { + super.onUpdate(); + + if(redstoneSignal == 0 && supertile.getWorldObj().blockExists(bindX, bindY, bindZ)) { + int x = supertile.xCoord; + int y = supertile.yCoord; + int z = supertile.zCoord; + + boolean did = false; + List items = supertile.getWorldObj().getEntitiesWithinAABB(EntityItem.class, AxisAlignedBB.getBoundingBox(x - RANGE, y - RANGE, z - RANGE, x + RANGE + 1, y + RANGE, z + RANGE + 1)); + int slowdown = getSlowdownFactor(); + + for(EntityItem item : items) { + if(item.age < (60 + slowdown) || item.isDead || item.getEntityData().getBoolean(TAG_TELEPORTED)) + continue; + + ItemStack stack = item.getEntityItem(); + if(stack != null) { + Item sitem = stack.getItem(); + if(sitem instanceof IManaItem) + continue; + + int cost = stack.stackSize * COST; + if(mana >= cost) { + spawnExplosionParticles(item, 10); + item.setPosition(bindX + 0.5, bindY + 1.5, bindZ + 0.5); + item.getEntityData().setBoolean(TAG_TELEPORTED, true); + item.motionX = item.motionY = item.motionZ = 0; + spawnExplosionParticles(item, 10); + if(!supertile.getWorldObj().isRemote) { + mana -= cost; + did = true; + } + } + } + } + + if(did) + sync(); + } + } + + public static void spawnExplosionParticles(EntityItem item, int p) { + for(int i = 0; i < p; i++) { + double m = 0.01; + double d0 = item.worldObj.rand.nextGaussian() * m; + double d1 = item.worldObj.rand.nextGaussian() * m; + double d2 = item.worldObj.rand.nextGaussian() * m; + double d3 = 10.0D; + item.worldObj.spawnParticle("explode", item.posX + item.worldObj.rand.nextFloat() * item.width * 2.0F - item.width - d0 * d3, item.posY + item.worldObj.rand.nextFloat() * item.height - d1 * d3, item.posZ + item.worldObj.rand.nextFloat() * item.width * 2.0F - item.width - d2 * d3, d0, d1, d2); + } + } + + @Override + public RadiusDescriptor getRadius() { + return new RadiusDescriptor.Square(toChunkCoordinates(), RANGE); + } + + @Override + public void writeToPacketNBT(NBTTagCompound cmp) { + super.writeToPacketNBT(cmp); + cmp.setInteger(TAG_BIND_X, bindX); + cmp.setInteger(TAG_BIND_Y, bindY); + cmp.setInteger(TAG_BIND_Z, bindZ); + } + + @Override + public void readFromPacketNBT(NBTTagCompound cmp) { + super.readFromPacketNBT(cmp); + bindX = cmp.getInteger(TAG_BIND_X); + bindY = cmp.getInteger(TAG_BIND_Y); + bindZ = cmp.getInteger(TAG_BIND_Z); + } + + @Override + public boolean acceptsRedstone() { + return true; + } + + @Override + public int getColor() { + return 0x98BCFF; + } + + @Override + public int getMaxMana() { + return 16000; + } + + @Override + public boolean bindTo(EntityPlayer player, ItemStack wand, int x, int y, int z, int side) { + boolean bound = super.bindTo(player, wand, x, y, z, side); + + if(!bound && (x != bindX || y != bindY || z != bindZ) && MathHelper.pointDistanceSpace(x, y, z, supertile.xCoord, supertile.yCoord, supertile.zCoord) <= BIND_RANGE && (x != supertile.xCoord || y != supertile.yCoord || z != supertile.zCoord)) { + bindX = x; + bindY = y; + bindZ = z; + sync(); + + return true; + } + + return bound; + } + + @Override + @SideOnly(Side.CLIENT) + public ChunkCoordinates getBinding() { + return Minecraft.getMinecraft().thePlayer.isSneaking() && bindY != -1 ? new ChunkCoordinates(bindX, bindY, bindZ) : super.getBinding(); + } + + @Override + public LexiconEntry getEntry() { + return LexiconData.spectranthemum; + } + } diff --git a/src/main/java/vazkii/botania/common/block/subtile/functional/SubTileTangleberrie.java b/src/main/java/vazkii/botania/common/block/subtile/functional/SubTileTangleberrie.java index ead09ea5a7..7959ee403c 100644 --- a/src/main/java/vazkii/botania/common/block/subtile/functional/SubTileTangleberrie.java +++ b/src/main/java/vazkii/botania/common/block/subtile/functional/SubTileTangleberrie.java @@ -2,15 +2,16 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Apr 14, 2014, 11:40:59 PM (GMT)] */ package vazkii.botania.common.block.subtile.functional; import java.util.List; + import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.boss.IBossDisplayData; import net.minecraft.entity.player.EntityPlayer; @@ -25,84 +26,75 @@ public class SubTileTangleberrie extends SubTileFunctional { - @Override - public void onUpdate() { - super.onUpdate(); - - if (mana > 0) { - double x1 = supertile.xCoord + 0.5; - double y1 = supertile.yCoord + 0.5; - double z1 = supertile.zCoord + 0.5; - - double maxDist = getMaxDistance(); - double range = getRange(); - - AxisAlignedBB boundingBox = AxisAlignedBB.getBoundingBox( - x1 - range, y1 - range, z1 - range, x1 + range + 1, y1 + range + 1, z1 + range + 1); - List entities = - supertile.getWorldObj().getEntitiesWithinAABB(EntityLivingBase.class, boundingBox); - - for (EntityLivingBase entity : entities) { - if (entity instanceof EntityPlayer || entity instanceof IBossDisplayData) continue; - - double x2 = entity.posX; - double y2 = entity.posY; - double z2 = entity.posZ; - - float distance = MathHelper.pointDistanceSpace(x1, y1, z1, x2, y2, z2); - - if (distance > maxDist && distance < range) { - MathHelper.setEntityMotionFromVector(entity, new Vector3(x1, y1, z1), getMotionVelocity()); - if (supertile.getWorldObj().rand.nextInt(3) == 0) - Botania.proxy.sparkleFX( - supertile.getWorldObj(), - x2 + Math.random() * entity.width, - y2 + Math.random() * entity.height, - z2 + Math.random() * entity.width, - 0.5F, - 0.5F, - 0.5F, - 1F, - 3); - } - } - - if (ticksExisted % 4 == 0) { - mana--; - sync(); - } - } - } - - double getMaxDistance() { - return 6; - } - - double getRange() { - return 7; - } - - float getMotionVelocity() { - return 0.05F; - } - - @Override - public RadiusDescriptor getRadius() { - return new RadiusDescriptor.Circle(toChunkCoordinates(), getRange()); - } - - @Override - public int getColor() { - return 0x4B797C; - } - - @Override - public int getMaxMana() { - return 20; - } - - @Override - public LexiconEntry getEntry() { - return LexiconData.tangleberrie; - } + @Override + public void onUpdate() { + super.onUpdate(); + + if(mana > 0) { + double x1 = supertile.xCoord + 0.5; + double y1 = supertile.yCoord + 0.5; + double z1 = supertile.zCoord + 0.5; + + double maxDist = getMaxDistance(); + double range = getRange(); + + AxisAlignedBB boundingBox = AxisAlignedBB.getBoundingBox(x1 - range, y1 - range, z1 - range, x1 + range + 1, y1 + range + 1, z1 + range + 1); + List entities = supertile.getWorldObj().getEntitiesWithinAABB(EntityLivingBase.class, boundingBox); + + for(EntityLivingBase entity : entities) { + if(entity instanceof EntityPlayer || entity instanceof IBossDisplayData) + continue; + + double x2 = entity.posX; + double y2 = entity.posY; + double z2 = entity.posZ; + + float distance = MathHelper.pointDistanceSpace(x1, y1, z1, x2, y2, z2); + + if(distance > maxDist && distance < range) { + MathHelper.setEntityMotionFromVector(entity, new Vector3(x1, y1, z1), getMotionVelocity()); + if(supertile.getWorldObj().rand.nextInt(3) == 0) + Botania.proxy.sparkleFX(supertile.getWorldObj(), x2 + Math.random() * entity.width, y2 + Math.random() * entity.height, z2 + Math.random() * entity.width, 0.5F, 0.5F, 0.5F, 1F, 3); + } + } + + if(ticksExisted % 4 == 0) { + mana--; + sync(); + } + } + } + + double getMaxDistance() { + return 6; + } + + double getRange() { + return 7; + } + + float getMotionVelocity() { + return 0.05F; + } + + @Override + public RadiusDescriptor getRadius() { + return new RadiusDescriptor.Circle(toChunkCoordinates(), getRange()); + } + + @Override + public int getColor() { + return 0x4B797C; + } + + @Override + public int getMaxMana() { + return 20; + } + + @Override + public LexiconEntry getEntry() { + return LexiconData.tangleberrie; + } + } diff --git a/src/main/java/vazkii/botania/common/block/subtile/functional/SubTileTigerseye.java b/src/main/java/vazkii/botania/common/block/subtile/functional/SubTileTigerseye.java index ade74af8d2..07b01ed5fc 100644 --- a/src/main/java/vazkii/botania/common/block/subtile/functional/SubTileTigerseye.java +++ b/src/main/java/vazkii/botania/common/block/subtile/functional/SubTileTigerseye.java @@ -2,17 +2,17 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Feb 16, 2014, 3:36:26 PM (GMT)] */ package vazkii.botania.common.block.subtile.functional; -import cpw.mods.fml.relauncher.ReflectionHelper; import java.util.ArrayList; import java.util.List; + import net.minecraft.entity.EntityLiving; import net.minecraft.entity.ai.EntityAIAvoidEntity; import net.minecraft.entity.ai.EntityAINearestAttackableTarget; @@ -27,97 +27,80 @@ import vazkii.botania.api.subtile.SubTileFunctional; import vazkii.botania.common.lexicon.LexiconData; import vazkii.botania.common.lib.LibObfuscation; +import cpw.mods.fml.relauncher.ReflectionHelper; public class SubTileTigerseye extends SubTileFunctional { - private static final int RANGE = 10; - private static final int RANGE_Y = 4; - - @Override - public void onUpdate() { - super.onUpdate(); - final int cost = 70; - - boolean shouldAfffect = mana >= cost; - - List entities = supertile - .getWorldObj() - .getEntitiesWithinAABB( - EntityLiving.class, - AxisAlignedBB.getBoundingBox( - supertile.xCoord - RANGE, - supertile.yCoord - RANGE_Y, - supertile.zCoord - RANGE, - supertile.xCoord + RANGE + 1, - supertile.yCoord + RANGE_Y + 1, - supertile.zCoord + RANGE + 1)); - - for (EntityLiving entity : entities) { - List entries = new ArrayList(entity.tasks.taskEntries); - entries.addAll(new ArrayList(entity.targetTasks.taskEntries)); - - boolean avoidsOcelots = false; - if (shouldAfffect) - for (EntityAITaskEntry entry : entries) { - if (entry.action instanceof EntityAIAvoidEntity) - avoidsOcelots = messWithRunAwayAI((EntityAIAvoidEntity) entry.action) || avoidsOcelots; - - if (entry.action instanceof EntityAINearestAttackableTarget) - messWithGetTargetAI((EntityAINearestAttackableTarget) entry.action); - } - - if (entity instanceof EntityCreeper) { - ReflectionHelper.setPrivateValue( - EntityCreeper.class, (EntityCreeper) entity, 2, LibObfuscation.TIME_SINCE_IGNITED); - entity.setAttackTarget(null); - } - - if (avoidsOcelots) { - mana -= cost; - sync(); - shouldAfffect = false; - } - } - } - - private boolean messWithRunAwayAI(EntityAIAvoidEntity aiEntry) { - if (ReflectionHelper.getPrivateValue(EntityAIAvoidEntity.class, aiEntry, LibObfuscation.TARGET_ENTITY_CLASS) - == EntityOcelot.class) { - ReflectionHelper.setPrivateValue( - EntityAIAvoidEntity.class, aiEntry, EntityPlayer.class, LibObfuscation.TARGET_ENTITY_CLASS); - return true; - } - return false; - } - - private void messWithGetTargetAI(EntityAINearestAttackableTarget aiEntry) { - if (ReflectionHelper.getPrivateValue( - EntityAINearestAttackableTarget.class, aiEntry, LibObfuscation.TARGET_CLASS) - == EntityPlayer.class) - ReflectionHelper.setPrivateValue( - EntityAINearestAttackableTarget.class, - aiEntry, - EntityEnderCrystal.class, - LibObfuscation.TARGET_CLASS); // Something random that won't be around - } - - @Override - public RadiusDescriptor getRadius() { - return new RadiusDescriptor.Square(toChunkCoordinates(), RANGE); - } - - @Override - public int getColor() { - return 0xB1A618; - } - - @Override - public int getMaxMana() { - return 1000; - } - - @Override - public LexiconEntry getEntry() { - return LexiconData.tigerseye; - } + private static final int RANGE = 10; + private static final int RANGE_Y = 4; + + @Override + public void onUpdate() { + super.onUpdate(); + final int cost = 70; + + boolean shouldAfffect = mana >= cost; + + List entities = supertile.getWorldObj().getEntitiesWithinAABB(EntityLiving.class, AxisAlignedBB.getBoundingBox(supertile.xCoord - RANGE, supertile.yCoord - RANGE_Y, supertile.zCoord - RANGE, supertile.xCoord + RANGE + 1, supertile.yCoord + RANGE_Y + 1, supertile.zCoord + RANGE + 1)); + + for(EntityLiving entity : entities) { + List entries = new ArrayList(entity.tasks.taskEntries); + entries.addAll(new ArrayList(entity.targetTasks.taskEntries)); + + boolean avoidsOcelots = false; + if(shouldAfffect) + for(EntityAITaskEntry entry : entries) { + if(entry.action instanceof EntityAIAvoidEntity) + avoidsOcelots = messWithRunAwayAI((EntityAIAvoidEntity) entry.action) || avoidsOcelots; + + if(entry.action instanceof EntityAINearestAttackableTarget) + messWithGetTargetAI((EntityAINearestAttackableTarget) entry.action); + } + + if(entity instanceof EntityCreeper) { + ReflectionHelper.setPrivateValue(EntityCreeper.class, (EntityCreeper) entity, 2, LibObfuscation.TIME_SINCE_IGNITED); + entity.setAttackTarget(null); + } + + if(avoidsOcelots) { + mana -= cost; + sync(); + shouldAfffect = false; + } + } + } + + private boolean messWithRunAwayAI(EntityAIAvoidEntity aiEntry) { + if(ReflectionHelper.getPrivateValue(EntityAIAvoidEntity.class, aiEntry, LibObfuscation.TARGET_ENTITY_CLASS) == EntityOcelot.class) { + ReflectionHelper.setPrivateValue(EntityAIAvoidEntity.class, aiEntry, EntityPlayer.class, LibObfuscation.TARGET_ENTITY_CLASS); + return true; + } + return false; + } + + private void messWithGetTargetAI(EntityAINearestAttackableTarget aiEntry) { + if(ReflectionHelper.getPrivateValue(EntityAINearestAttackableTarget.class, aiEntry, LibObfuscation.TARGET_CLASS) == EntityPlayer.class) + ReflectionHelper.setPrivateValue(EntityAINearestAttackableTarget.class, aiEntry, EntityEnderCrystal.class, LibObfuscation.TARGET_CLASS); // Something random that won't be around + } + + @Override + public RadiusDescriptor getRadius() { + return new RadiusDescriptor.Square(toChunkCoordinates(), RANGE); + } + + @Override + public int getColor() { + return 0xB1A618; + } + + @Override + public int getMaxMana() { + return 1000; + } + + @Override + public LexiconEntry getEntry() { + return LexiconData.tigerseye; + } + } diff --git a/src/main/java/vazkii/botania/common/block/subtile/functional/SubTileVinculotus.java b/src/main/java/vazkii/botania/common/block/subtile/functional/SubTileVinculotus.java index 07a3f1cb5d..74110d252b 100644 --- a/src/main/java/vazkii/botania/common/block/subtile/functional/SubTileVinculotus.java +++ b/src/main/java/vazkii/botania/common/block/subtile/functional/SubTileVinculotus.java @@ -2,20 +2,20 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jul 15, 2014, 4:30:08 PM (GMT)] */ package vazkii.botania.common.block.subtile.functional; -import cpw.mods.fml.common.eventhandler.SubscribeEvent; import java.util.ArrayList; import java.util.Collections; import java.util.List; import java.util.Set; import java.util.WeakHashMap; + import net.minecraft.entity.monster.EntityEnderman; import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.event.entity.living.EnderTeleportEvent; @@ -24,96 +24,91 @@ import vazkii.botania.api.subtile.SubTileFunctional; import vazkii.botania.common.core.helper.MathHelper; import vazkii.botania.common.lexicon.LexiconData; +import cpw.mods.fml.common.eventhandler.SubscribeEvent; public class SubTileVinculotus extends SubTileFunctional { - public static Set existingFlowers = Collections.newSetFromMap(new WeakHashMap()); - private static boolean registered = false; - private static final int RANGE = 64; - - @Override - public void onUpdate() { - super.onUpdate(); - - if (!existingFlowers.contains(this)) { - existingFlowers.add(this); - if (!registered) { - MinecraftForge.EVENT_BUS.register(new EndermanIntercepter()); - registered = true; - } - } - } - - @Override - public RadiusDescriptor getRadius() { - return new RadiusDescriptor.Circle(toChunkCoordinates(), RANGE); - } - - @Override - public boolean acceptsRedstone() { - return true; - } - - @Override - public int getColor() { - return 0x0A6051; - } - - @Override - public int getMaxMana() { - return 500; - } - - @Override - public LexiconEntry getEntry() { - return LexiconData.vinculotus; - } - - public static class EndermanIntercepter { - - @SubscribeEvent - public void onEndermanTeleport(EnderTeleportEvent event) { - if (event.entity.worldObj.isRemote) return; - - int cost = 50; - - if (event.entity instanceof EntityEnderman) { - List possibleFlowers = new ArrayList(); - for (SubTileVinculotus flower : existingFlowers) { - if (flower.redstoneSignal > 0 - || flower.mana <= cost - || flower.supertile.getWorldObj() != event.entity.worldObj - || flower.supertile - .getWorldObj() - .getTileEntity( - flower.supertile.xCoord, - flower.supertile.yCoord, - flower.supertile.zCoord) - != flower.supertile) continue; - - double x = flower.supertile.xCoord + 0.5; - double y = flower.supertile.yCoord + 1.5; - double z = flower.supertile.zCoord + 0.5; - - if (MathHelper.pointDistanceSpace(x, y, z, event.targetX, event.targetY, event.targetZ) < RANGE) - possibleFlowers.add(flower); - } - - if (!possibleFlowers.isEmpty()) { - SubTileVinculotus flower = - possibleFlowers.get(event.entity.worldObj.rand.nextInt(possibleFlowers.size())); - - double x = flower.supertile.xCoord + 0.5; - double y = flower.supertile.yCoord + 1.5; - double z = flower.supertile.zCoord + 0.5; - - event.targetX = x + Math.random() * 3 - 1; - event.targetY = y; - event.targetZ = z + Math.random() * 3 - 1; - flower.mana -= cost; - flower.sync(); - } - } - } - } + public static Set existingFlowers = Collections.newSetFromMap(new WeakHashMap()); + private static boolean registered = false; + private static final int RANGE = 64; + + @Override + public void onUpdate() { + super.onUpdate(); + + if(!existingFlowers.contains(this)) { + existingFlowers.add(this); + if(!registered) { + MinecraftForge.EVENT_BUS.register(new EndermanIntercepter()); + registered = true; + } + } + } + + @Override + public RadiusDescriptor getRadius() { + return new RadiusDescriptor.Circle(toChunkCoordinates(), RANGE); + } + + @Override + public boolean acceptsRedstone() { + return true; + } + + @Override + public int getColor() { + return 0x0A6051; + } + + @Override + public int getMaxMana() { + return 500; + } + + @Override + public LexiconEntry getEntry() { + return LexiconData.vinculotus; + } + + public static class EndermanIntercepter { + + @SubscribeEvent + public void onEndermanTeleport(EnderTeleportEvent event) { + if(event.entity.worldObj.isRemote) + return; + + int cost = 50; + + if(event.entity instanceof EntityEnderman) { + List possibleFlowers = new ArrayList(); + for(SubTileVinculotus flower : existingFlowers) { + if(flower.redstoneSignal > 0 || flower.mana <= cost || flower.supertile.getWorldObj() != event.entity.worldObj || flower.supertile.getWorldObj().getTileEntity(flower.supertile.xCoord, flower.supertile.yCoord, flower.supertile.zCoord) != flower.supertile) + continue; + + double x = flower.supertile.xCoord + 0.5; + double y = flower.supertile.yCoord + 1.5; + double z = flower.supertile.zCoord + 0.5; + + if(MathHelper.pointDistanceSpace(x, y, z, event.targetX, event.targetY, event.targetZ) < RANGE) + possibleFlowers.add(flower); + } + + if(!possibleFlowers.isEmpty()) { + SubTileVinculotus flower = possibleFlowers.get(event.entity.worldObj.rand.nextInt(possibleFlowers.size())); + + double x = flower.supertile.xCoord + 0.5; + double y = flower.supertile.yCoord + 1.5; + double z = flower.supertile.zCoord + 0.5; + + event.targetX = x + Math.random() * 3 - 1; + event.targetY = y; + event.targetZ = z + Math.random() * 3 - 1; + flower.mana -= cost; + flower.sync(); + } + } + } + + } + } diff --git a/src/main/java/vazkii/botania/common/block/subtile/generating/SubTileArcaneRose.java b/src/main/java/vazkii/botania/common/block/subtile/generating/SubTileArcaneRose.java index 4e844fa2b6..08b5701c29 100644 --- a/src/main/java/vazkii/botania/common/block/subtile/generating/SubTileArcaneRose.java +++ b/src/main/java/vazkii/botania/common/block/subtile/generating/SubTileArcaneRose.java @@ -2,15 +2,16 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Mar 18, 2014, 8:45:25 PM (GMT)] */ package vazkii.botania.common.block.subtile.generating; import java.util.List; + import net.minecraft.entity.player.EntityPlayer; import net.minecraft.util.AxisAlignedBB; import vazkii.botania.api.lexicon.LexiconEntry; @@ -21,50 +22,42 @@ public class SubTileArcaneRose extends SubTileGenerating { - private static final int RANGE = 1; + private static final int RANGE = 1; + + @Override + public void onUpdate() { + super.onUpdate(); - @Override - public void onUpdate() { - super.onUpdate(); + if(mana >= getMaxMana()) + return; - if (mana >= getMaxMana()) return; + List players = supertile.getWorldObj().getEntitiesWithinAABB(EntityPlayer.class, AxisAlignedBB.getBoundingBox(supertile.xCoord - RANGE, supertile.yCoord, supertile.zCoord - RANGE, supertile.xCoord + RANGE + 1, supertile.yCoord + 1, supertile.zCoord + RANGE + 1)); + for(EntityPlayer player : players) + if(ExperienceHelper.getPlayerXP(player) >= 1 && player.onGround) { + ExperienceHelper.drainPlayerXP(player, 1); + mana += 50; + return; + } + } - List players = supertile - .getWorldObj() - .getEntitiesWithinAABB( - EntityPlayer.class, - AxisAlignedBB.getBoundingBox( - supertile.xCoord - RANGE, - supertile.yCoord, - supertile.zCoord - RANGE, - supertile.xCoord + RANGE + 1, - supertile.yCoord + 1, - supertile.zCoord + RANGE + 1)); - for (EntityPlayer player : players) - if (ExperienceHelper.getPlayerXP(player) >= 1 && player.onGround) { - ExperienceHelper.drainPlayerXP(player, 1); - mana += 50; - return; - } - } + @Override + public RadiusDescriptor getRadius() { + return new RadiusDescriptor.Square(toChunkCoordinates(), RANGE); + } - @Override - public RadiusDescriptor getRadius() { - return new RadiusDescriptor.Square(toChunkCoordinates(), RANGE); - } + @Override + public int getColor() { + return 0xFF8EF8; + } - @Override - public int getColor() { - return 0xFF8EF8; - } + @Override + public int getMaxMana() { + return 6000; + } - @Override - public int getMaxMana() { - return 6000; - } + @Override + public LexiconEntry getEntry() { + return LexiconData.arcaneRose; + } - @Override - public LexiconEntry getEntry() { - return LexiconData.arcaneRose; - } } diff --git a/src/main/java/vazkii/botania/common/block/subtile/generating/SubTileDandelifeon.java b/src/main/java/vazkii/botania/common/block/subtile/generating/SubTileDandelifeon.java index b325c5346a..a6adf90b3a 100644 --- a/src/main/java/vazkii/botania/common/block/subtile/generating/SubTileDandelifeon.java +++ b/src/main/java/vazkii/botania/common/block/subtile/generating/SubTileDandelifeon.java @@ -2,16 +2,17 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Sep 6, 2015, 3:46:10 PM (GMT)] */ package vazkii.botania.common.block.subtile.generating; import java.util.ArrayList; import java.util.List; + import net.minecraft.block.Block; import net.minecraft.tileentity.TileEntity; import net.minecraft.world.World; @@ -24,175 +25,185 @@ public class SubTileDandelifeon extends SubTileGenerating { - private static final int RANGE = 12; - private static final int SPEED = 10; - private static final int MAX_GENERATIONS = 60; - private static final int MANA_PER_GEN = 150; - - private static final int[][] ADJACENT_BLOCKS = new int[][] { - {-1, -1}, - {-1, +0}, - {-1, +1}, - {+0, +1}, - {+1, +1}, - {+1, +0}, - {+1, -1}, - {+0, -1} - }; - - @Override - public void onUpdate() { - super.onUpdate(); - - if (!supertile.getWorldObj().isRemote && redstoneSignal > 0 && ticksExisted % SPEED == 0) runSimulation(); - } - - void runSimulation() { - int[][] table = getCellTable(); - List changes = new ArrayList(); - new ArrayList(); - boolean wipe = false; - - for (int i = 0; i < table.length; i++) - for (int j = 0; j < table[0].length; j++) { - int gen = table[i][j]; - int adj = getAdjCells(table, i, j); - - int newVal = gen; - if (adj < 2 || adj > 3) newVal = -1; - else { - if (adj == 3 && gen == -1) newVal = getSpawnCellGeneration(table, i, j); - else if (gen > -1) newVal = gen + 1; - } - - int xdist = Math.abs(i - RANGE); - int zdist = Math.abs(j - RANGE); - int allowDist = 1; - if (xdist <= allowDist && zdist <= allowDist && newVal > -1) { - gen = newVal; - newVal = gen == 1 ? -1 : -2; - } - - if (newVal != gen) { - changes.add(new int[] {i, j, newVal, gen}); - if (newVal == -2) wipe = true; - } - } - - int x = supertile.xCoord; - int y = supertile.yCoord; - int z = supertile.zCoord; - - for (int[] change : changes) { - int px = x - RANGE + change[0]; - int pz = z - RANGE + change[1]; - int val = change[2]; - if (val != -2 && wipe) val = -1; - - int old = change[3]; - - setBlockForGeneration(px, y, pz, val, old); - } - } - - int[][] getCellTable() { - int diam = RANGE * 2 + 1; - int[][] table = new int[diam][diam]; - - int x = supertile.xCoord; - int y = supertile.yCoord; - int z = supertile.zCoord; - - for (int i = 0; i < diam; i++) - for (int j = 0; j < diam; j++) { - int px = x - RANGE + i; - int pz = z - RANGE + j; - table[i][j] = getCellGeneration(px, y, pz); - } - - return table; - } - - int getCellGeneration(int x, int y, int z) { - TileEntity tile = supertile.getWorldObj().getTileEntity(x, y, z); - if (tile instanceof TileCell) - return ((TileCell) tile).isSameFlower(supertile) ? ((TileCell) tile).getGeneration() : 0; - - return -1; - } - - int getAdjCells(int[][] table, int x, int z) { - int count = 0; - for (int[] shift : ADJACENT_BLOCKS) { - int xp = x + shift[0]; - int zp = z + shift[1]; - if (!isOffBounds(table, xp, zp)) { - int gen = table[xp][zp]; - if (gen >= 0) count++; - } - } - - return count; - } - - int getSpawnCellGeneration(int[][] table, int x, int z) { - int max = -1; - for (int[] shift : ADJACENT_BLOCKS) { - int xp = x + shift[0]; - int zp = z + shift[1]; - if (!isOffBounds(table, xp, zp)) { - int gen = table[xp][zp]; - if (gen > max) max = gen; - } - } - - return max == -1 ? -1 : max + 1; - } - - boolean isOffBounds(int[][] table, int x, int z) { - return x < 0 || z < 0 || x >= table.length || z >= table[0].length; - } - - void setBlockForGeneration(int x, int y, int z, int gen, int prevGen) { - World world = supertile.getWorldObj(); - Block blockAt = world.getBlock(x, y, z); - TileEntity tile = world.getTileEntity(x, y, z); - if (gen == -2) { - int val = prevGen * MANA_PER_GEN; - mana = Math.min(getMaxMana(), mana + val); - // world.setBlockToAir(x, y, z); - } else if (blockAt == ModBlocks.cellBlock) { - if (gen < 0 || gen > MAX_GENERATIONS) world.setBlockToAir(x, y, z); - else ((TileCell) tile).setGeneration(supertile, gen); - } else if (gen >= 0 && blockAt.isAir(supertile.getWorldObj(), x, y, z)) { - world.setBlock(x, y, z, ModBlocks.cellBlock); - tile = world.getTileEntity(x, y, z); - ((TileCell) tile).setGeneration(supertile, gen); - } - } - - @Override - public boolean acceptsRedstone() { - return true; - } - - @Override - public RadiusDescriptor getRadius() { - return new RadiusDescriptor.Square(toChunkCoordinates(), RANGE); - } - - @Override - public int getMaxMana() { - return 50000; - } - - @Override - public int getColor() { - return 0x9c0a7e; - } - - @Override - public LexiconEntry getEntry() { - return LexiconData.dandelifeon; - } + private static final int RANGE = 12; + private static final int SPEED = 10; + private static final int MAX_GENERATIONS = 60; + private static final int MANA_PER_GEN = 150; + + private static final int[][] ADJACENT_BLOCKS = new int[][] { + { -1, -1 }, + { -1, +0 }, + { -1, +1 }, + { +0, +1 }, + { +1, +1 }, + { +1, +0 }, + { +1, -1 }, + { +0, -1 } + }; + + @Override + public void onUpdate() { + super.onUpdate(); + + if(!supertile.getWorldObj().isRemote && redstoneSignal > 0 && ticksExisted % SPEED == 0) + runSimulation(); + } + + void runSimulation() { + int[][] table = getCellTable(); + List changes = new ArrayList(); + new ArrayList(); + boolean wipe = false; + + for(int i = 0; i < table.length; i++) + for(int j = 0; j < table[0].length; j++) { + int gen = table[i][j]; + int adj = getAdjCells(table, i, j); + + int newVal = gen; + if(adj < 2 || adj > 3) + newVal = -1; + else { + if(adj == 3 && gen == -1) + newVal = getSpawnCellGeneration(table, i, j); + else if(gen > -1) + newVal = gen + 1; + } + + int xdist = Math.abs(i - RANGE); + int zdist = Math.abs(j - RANGE); + int allowDist = 1; + if(xdist <= allowDist && zdist <= allowDist && newVal > -1) { + gen = newVal; + newVal = gen == 1 ? -1 : -2; + } + + if(newVal != gen) { + changes.add(new int[] { i, j, newVal, gen }); + if(newVal == -2) + wipe = true; + } + } + + int x = supertile.xCoord; + int y = supertile.yCoord; + int z = supertile.zCoord; + + for(int[] change : changes) { + int px = x - RANGE + change[0]; + int pz = z - RANGE + change[1]; + int val = change[2]; + if(val != -2 && wipe) + val = -1; + + int old = change[3]; + + setBlockForGeneration(px, y, pz, val, old); + } + } + + int[][] getCellTable() { + int diam = RANGE * 2 + 1; + int[][] table = new int[diam][diam]; + + int x = supertile.xCoord; + int y = supertile.yCoord; + int z = supertile.zCoord; + + for(int i = 0; i < diam; i++) + for(int j = 0; j < diam; j++) { + int px = x - RANGE + i; + int pz = z - RANGE + j; + table[i][j] = getCellGeneration(px, y, pz); + } + + return table; + } + + int getCellGeneration(int x, int y, int z) { + TileEntity tile = supertile.getWorldObj().getTileEntity(x, y, z); + if(tile instanceof TileCell) + return ((TileCell) tile).isSameFlower(supertile) ? ((TileCell) tile).getGeneration() : 0; + + return -1; + } + + int getAdjCells(int[][] table, int x, int z) { + int count = 0; + for(int[] shift : ADJACENT_BLOCKS) { + int xp = x + shift[0]; + int zp = z + shift[1]; + if(!isOffBounds(table, xp, zp)) { + int gen = table[xp][zp]; + if(gen >= 0) + count++; + } + } + + return count; + } + + int getSpawnCellGeneration(int[][] table, int x, int z) { + int max = -1; + for(int[] shift : ADJACENT_BLOCKS) { + int xp = x + shift[0]; + int zp = z + shift[1]; + if(!isOffBounds(table, xp, zp)) { + int gen = table[xp][zp]; + if(gen > max) + max = gen; + } + } + + return max == -1 ? -1 : max + 1; + } + + boolean isOffBounds(int[][] table, int x, int z) { + return x < 0 || z < 0 || x >= table.length || z >= table[0].length; + } + + void setBlockForGeneration(int x, int y, int z, int gen, int prevGen) { + World world = supertile.getWorldObj(); + Block blockAt = world.getBlock(x, y, z); + TileEntity tile = world.getTileEntity(x, y, z); + if(gen == -2) { + int val = prevGen * MANA_PER_GEN; + mana = Math.min(getMaxMana(), mana + val); + //world.setBlockToAir(x, y, z); + } else if(blockAt == ModBlocks.cellBlock) { + if(gen < 0 || gen > MAX_GENERATIONS) + world.setBlockToAir(x, y, z); + else ((TileCell) tile).setGeneration(supertile, gen); + } else if(gen >= 0 && blockAt.isAir(supertile.getWorldObj(), x, y, z)) { + world.setBlock(x, y, z, ModBlocks.cellBlock); + tile = world.getTileEntity(x, y, z); + ((TileCell) tile).setGeneration(supertile, gen); + } + } + + @Override + public boolean acceptsRedstone() { + return true; + } + + @Override + public RadiusDescriptor getRadius() { + return new RadiusDescriptor.Square(toChunkCoordinates(), RANGE); + } + + @Override + public int getMaxMana() { + return 50000; + } + + @Override + public int getColor() { + return 0x9c0a7e; + } + + @Override + public LexiconEntry getEntry() { + return LexiconData.dandelifeon; + } + } diff --git a/src/main/java/vazkii/botania/common/block/subtile/generating/SubTileDaybloom.java b/src/main/java/vazkii/botania/common/block/subtile/generating/SubTileDaybloom.java index c6a5d4a359..aa9723c093 100644 --- a/src/main/java/vazkii/botania/common/block/subtile/generating/SubTileDaybloom.java +++ b/src/main/java/vazkii/botania/common/block/subtile/generating/SubTileDaybloom.java @@ -2,15 +2,16 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jan 25, 2014, 3:09:35 PM (GMT)] */ package vazkii.botania.common.block.subtile.generating; import java.util.ArrayList; + import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import vazkii.botania.api.lexicon.LexiconEntry; @@ -20,119 +21,109 @@ @PassiveFlower public class SubTileDaybloom extends SubTilePassiveGenerating { - private static final String TAG_PRIME_POSITION_X = "primePositionX"; - private static final String TAG_PRIME_POSITION_Y = "primePositionY"; - private static final String TAG_PRIME_POSITION_Z = "primePositionZ"; - private static final String TAG_SAVED_POSITION = "savedPosition"; - - int primePositionX, primePositionY, primePositionZ; - boolean savedPosition; - - @Override - public int getColor() { - return 0xFFFF00; - } - - @Override - public void onUpdate() { - super.onUpdate(); - - if (isPrime() - && (!savedPosition - || primePositionX != supertile.xCoord - || primePositionY != supertile.yCoord - || primePositionZ != supertile.zCoord)) - supertile.getWorldObj().setBlockToAir(supertile.xCoord, supertile.yCoord, supertile.zCoord); - } - - public void setPrimusPosition() { - primePositionX = supertile.xCoord; - primePositionY = supertile.yCoord; - primePositionZ = supertile.zCoord; - - savedPosition = true; - } - - @Override - public ArrayList getDrops(ArrayList list) { - if (isPrime()) list.clear(); - - return super.getDrops(list); - } - - @Override - public boolean canGeneratePassively() { - boolean rain = supertile - .getWorldObj() - .getWorldChunkManager() - .getBiomeGenAt(supertile.xCoord, supertile.zCoord) - .getIntRainfall() - > 0 - && (supertile.getWorldObj().isRaining() - || supertile.getWorldObj().isThundering()); - return supertile.getWorldObj().isDaytime() - && !rain - && supertile.getWorldObj().canBlockSeeTheSky(supertile.xCoord, supertile.yCoord + 1, supertile.zCoord); - } - - @Override - public int getDelayBetweenPassiveGeneration() { - return isPrime() ? 10 : 12; - } - - @Override - public void writeToPacketNBT(NBTTagCompound cmp) { - super.writeToPacketNBT(cmp); - - if (isPrime()) { - cmp.setInteger(TAG_PRIME_POSITION_X, primePositionX); - cmp.setInteger(TAG_PRIME_POSITION_Y, primePositionY); - cmp.setInteger(TAG_PRIME_POSITION_Z, primePositionZ); - cmp.setBoolean(TAG_SAVED_POSITION, savedPosition); - } - } - - @Override - public void readFromPacketNBT(NBTTagCompound cmp) { - super.readFromPacketNBT(cmp); - - if (isPrime()) { - primePositionX = cmp.getInteger(TAG_PRIME_POSITION_X); - primePositionY = cmp.getInteger(TAG_PRIME_POSITION_Y); - primePositionZ = cmp.getInteger(TAG_PRIME_POSITION_Z); - savedPosition = cmp.getBoolean(TAG_SAVED_POSITION); - } - } - - @Override - public boolean shouldSyncPassiveGeneration() { - return true; - } - - @Override - public boolean isPassiveFlower() { - return !isPrime(); - } - - @Override - public LexiconEntry getEntry() { - return LexiconData.daybloom; - } - - public boolean isPrime() { - return false; - } - - public static class Prime extends SubTileDaybloom { - - @Override - public boolean isPrime() { - return true; - } - - @Override - public LexiconEntry getEntry() { - return LexiconData.primusLoci; - } - } + private static final String TAG_PRIME_POSITION_X = "primePositionX"; + private static final String TAG_PRIME_POSITION_Y = "primePositionY"; + private static final String TAG_PRIME_POSITION_Z = "primePositionZ"; + private static final String TAG_SAVED_POSITION = "savedPosition"; + + int primePositionX, primePositionY, primePositionZ; + boolean savedPosition; + + @Override + public int getColor() { + return 0xFFFF00; + } + + @Override + public void onUpdate() { + super.onUpdate(); + + if(isPrime() && (!savedPosition || primePositionX != supertile.xCoord || primePositionY != supertile.yCoord || primePositionZ != supertile.zCoord)) + supertile.getWorldObj().setBlockToAir(supertile.xCoord, supertile.yCoord, supertile.zCoord); + } + + public void setPrimusPosition() { + primePositionX = supertile.xCoord; + primePositionY = supertile.yCoord; + primePositionZ = supertile.zCoord; + + savedPosition = true; + } + + @Override + public ArrayList getDrops(ArrayList list) { + if(isPrime()) + list.clear(); + + return super.getDrops(list); + } + + @Override + public boolean canGeneratePassively() { + boolean rain = supertile.getWorldObj().getWorldChunkManager().getBiomeGenAt(supertile.xCoord, supertile.zCoord).getIntRainfall() > 0 && (supertile.getWorldObj().isRaining() || supertile.getWorldObj().isThundering()); + return supertile.getWorldObj().isDaytime() && !rain && supertile.getWorldObj().canBlockSeeTheSky(supertile.xCoord, supertile.yCoord + 1, supertile.zCoord); + } + + @Override + public int getDelayBetweenPassiveGeneration() { + return isPrime() ? 10 : 12; + } + + @Override + public void writeToPacketNBT(NBTTagCompound cmp) { + super.writeToPacketNBT(cmp); + + if(isPrime()) { + cmp.setInteger(TAG_PRIME_POSITION_X, primePositionX); + cmp.setInteger(TAG_PRIME_POSITION_Y, primePositionY); + cmp.setInteger(TAG_PRIME_POSITION_Z, primePositionZ); + cmp.setBoolean(TAG_SAVED_POSITION, savedPosition); + } + } + + @Override + public void readFromPacketNBT(NBTTagCompound cmp) { + super.readFromPacketNBT(cmp); + + if(isPrime()) { + primePositionX = cmp.getInteger(TAG_PRIME_POSITION_X); + primePositionY = cmp.getInteger(TAG_PRIME_POSITION_Y); + primePositionZ = cmp.getInteger(TAG_PRIME_POSITION_Z); + savedPosition = cmp.getBoolean(TAG_SAVED_POSITION); + } + } + + @Override + public boolean shouldSyncPassiveGeneration() { + return true; + } + + @Override + public boolean isPassiveFlower() { + return !isPrime(); + } + + @Override + public LexiconEntry getEntry() { + return LexiconData.daybloom; + } + + public boolean isPrime() { + return false; + } + + public static class Prime extends SubTileDaybloom { + + @Override + public boolean isPrime() { + return true; + } + + @Override + public LexiconEntry getEntry() { + return LexiconData.primusLoci; + } + + } + } diff --git a/src/main/java/vazkii/botania/common/block/subtile/generating/SubTileEndoflame.java b/src/main/java/vazkii/botania/common/block/subtile/generating/SubTileEndoflame.java index 21cd2bef4b..9210b93e64 100644 --- a/src/main/java/vazkii/botania/common/block/subtile/generating/SubTileEndoflame.java +++ b/src/main/java/vazkii/botania/common/block/subtile/generating/SubTileEndoflame.java @@ -2,15 +2,16 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Feb 15, 2014, 9:47:56 PM (GMT)] */ package vazkii.botania.common.block.subtile.generating; import java.util.List; + import net.minecraft.entity.item.EntityItem; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; @@ -20,143 +21,118 @@ import vazkii.botania.api.lexicon.LexiconEntry; import vazkii.botania.api.subtile.RadiusDescriptor; import vazkii.botania.api.subtile.SubTileGenerating; +import vazkii.botania.common.Botania; import vazkii.botania.common.block.ModBlocks; import vazkii.botania.common.lexicon.LexiconData; public class SubTileEndoflame extends SubTileGenerating { - private static final String TAG_BURN_TIME = "burnTime"; - private static final int FUEL_CAP = 32000; - private static final int RANGE = 3; - - int burnTime = 0; - - @Override - public void onUpdate() { - super.onUpdate(); - - if (linkedCollector != null) { - if (burnTime == 0) { - if (mana < getMaxMana()) { - boolean didSomething = false; - - int slowdown = getSlowdownFactor(); - - List items = supertile - .getWorldObj() - .getEntitiesWithinAABB( - EntityItem.class, - AxisAlignedBB.getBoundingBox( - supertile.xCoord - RANGE, - supertile.yCoord - RANGE, - supertile.zCoord - RANGE, - supertile.xCoord + RANGE + 1, - supertile.yCoord + RANGE + 1, - supertile.zCoord + RANGE + 1)); - for (EntityItem item : items) { - if (item.age >= (59 + slowdown) && !item.isDead) { - ItemStack stack = item.getEntityItem(); - if (stack.getItem().hasContainerItem(stack)) continue; - - int burnTime = stack == null || stack.getItem() == Item.getItemFromBlock(ModBlocks.spreader) - ? 0 - : TileEntityFurnace.getItemBurnTime(stack); - if (burnTime > 0 && stack.stackSize > 0) { - this.burnTime = Math.min(FUEL_CAP, burnTime) / 2; - - if (!supertile.getWorldObj().isRemote) { - stack.stackSize--; - supertile - .getWorldObj() - .playSoundEffect( - supertile.xCoord, - supertile.yCoord, - supertile.zCoord, - "botania:endoflame", - 0.2F, - 1F); - - if (stack.stackSize == 0) item.setDead(); - - didSomething = true; - } else { - item.worldObj.spawnParticle( - "largesmoke", item.posX, item.posY + 0.1, item.posZ, 0.0D, 0.0D, 0.0D); - item.worldObj.spawnParticle( - "flame", item.posX, item.posY, item.posZ, 0.0D, 0.0D, 0.0D); - } - - break; - } - } - } - - if (didSomething) sync(); - } - } else { - if (supertile.getWorldObj().rand.nextInt(10) == 0) - supertile - .getWorldObj() - .spawnParticle( - "flame", - supertile.xCoord + 0.4 + Math.random() * 0.2, - supertile.yCoord + 0.65, - supertile.zCoord + 0.4 + Math.random() * 0.2, - 0.0D, - 0.0D, - 0.0D); - - burnTime--; - } - } - } - - @Override - public int getMaxMana() { - return 300; - } - - @Override - public int getValueForPassiveGeneration() { - return 3; - } - - @Override - public int getColor() { - return 0x785000; - } - - @Override - public RadiusDescriptor getRadius() { - return new RadiusDescriptor.Square(toChunkCoordinates(), RANGE); - } - - @Override - public LexiconEntry getEntry() { - return LexiconData.endoflame; - } - - @Override - public void writeToPacketNBT(NBTTagCompound cmp) { - super.writeToPacketNBT(cmp); - - cmp.setInteger(TAG_BURN_TIME, burnTime); - } - - @Override - public void readFromPacketNBT(NBTTagCompound cmp) { - super.readFromPacketNBT(cmp); - - burnTime = cmp.getInteger(TAG_BURN_TIME); - } - - @Override - public boolean canGeneratePassively() { - return burnTime > 0; - } - - @Override - public int getDelayBetweenPassiveGeneration() { - return 2; - } + private static final String TAG_BURN_TIME = "burnTime"; + private static final int FUEL_CAP = 32000; + private static final int RANGE = 3; + + int burnTime = 0; + + @Override + public void onUpdate() { + super.onUpdate(); + + if(linkedCollector != null) { + if(burnTime == 0) { + if(mana < getMaxMana()) { + boolean didSomething = false; + + int slowdown = getSlowdownFactor(); + + List items = supertile.getWorldObj().getEntitiesWithinAABB(EntityItem.class, AxisAlignedBB.getBoundingBox(supertile.xCoord - RANGE, supertile.yCoord - RANGE, supertile.zCoord - RANGE, supertile.xCoord + RANGE + 1, supertile.yCoord + RANGE + 1, supertile.zCoord + RANGE + 1)); + for(EntityItem item : items) { + if(item.age >= (59 + slowdown) && !item.isDead) { + ItemStack stack = item.getEntityItem(); + if(stack.getItem().hasContainerItem(stack)) + continue; + + int burnTime = stack == null || stack.getItem() == Item.getItemFromBlock(ModBlocks.spreader) ? 0 : TileEntityFurnace.getItemBurnTime(stack); + if(burnTime > 0 && stack.stackSize > 0) { + this.burnTime = Math.min(FUEL_CAP, burnTime) / 2; + + if(!supertile.getWorldObj().isRemote) { + stack.stackSize--; + supertile.getWorldObj().playSoundEffect(supertile.xCoord, supertile.yCoord, supertile.zCoord, "botania:endoflame", 0.2F, 1F); + + if(stack.stackSize == 0) + item.setDead(); + + didSomething = true; + } else { + item.worldObj.spawnParticle("largesmoke", item.posX, item.posY + 0.1, item.posZ, 0.0D, 0.0D, 0.0D); + item.worldObj.spawnParticle("flame", item.posX, item.posY, item.posZ, 0.0D, 0.0D, 0.0D); + } + + + break; + } + } + } + + if(didSomething) + sync(); + } + } else { + if(supertile.getWorldObj().rand.nextInt(10) == 0) + supertile.getWorldObj().spawnParticle("flame", supertile.xCoord + 0.4 + Math.random() * 0.2, supertile.yCoord + 0.65, supertile.zCoord + 0.4 + Math.random() * 0.2, 0.0D, 0.0D, 0.0D); + + burnTime--; + } + } + } + + @Override + public int getMaxMana() { + return 300; + } + + @Override + public int getValueForPassiveGeneration() { + return 3; + } + + @Override + public int getColor() { + return 0x785000; + } + + @Override + public RadiusDescriptor getRadius() { + return new RadiusDescriptor.Square(toChunkCoordinates(), RANGE); + } + + @Override + public LexiconEntry getEntry() { + return LexiconData.endoflame; + } + + @Override + public void writeToPacketNBT(NBTTagCompound cmp) { + super.writeToPacketNBT(cmp); + + cmp.setInteger(TAG_BURN_TIME, burnTime); + } + + @Override + public void readFromPacketNBT(NBTTagCompound cmp) { + super.readFromPacketNBT(cmp); + + burnTime = cmp.getInteger(TAG_BURN_TIME); + } + + @Override + public boolean canGeneratePassively() { + return burnTime > 0; + } + + @Override + public int getDelayBetweenPassiveGeneration() { + return 2; + } + } diff --git a/src/main/java/vazkii/botania/common/block/subtile/generating/SubTileEntropinnyum.java b/src/main/java/vazkii/botania/common/block/subtile/generating/SubTileEntropinnyum.java index 32e2fbfd00..37e81be647 100644 --- a/src/main/java/vazkii/botania/common/block/subtile/generating/SubTileEntropinnyum.java +++ b/src/main/java/vazkii/botania/common/block/subtile/generating/SubTileEntropinnyum.java @@ -2,15 +2,16 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jun 7, 2014, 10:59:44 PM (GMT)] */ package vazkii.botania.common.block.subtile.generating; import java.util.List; + import net.minecraft.entity.item.EntityTNTPrimed; import net.minecraft.util.AxisAlignedBB; import net.minecraft.util.MathHelper; @@ -22,97 +23,51 @@ public class SubTileEntropinnyum extends SubTileGenerating { - private static final int RANGE = 12; + private static final int RANGE = 12; + + @Override + public void onUpdate() { + super.onUpdate(); - @Override - public void onUpdate() { - super.onUpdate(); + if(mana == 0) { + List tnts = supertile.getWorldObj().getEntitiesWithinAABB(EntityTNTPrimed.class, AxisAlignedBB.getBoundingBox(supertile.xCoord - RANGE, supertile.yCoord - RANGE, supertile.zCoord - RANGE, supertile.xCoord + RANGE + 1, supertile.yCoord + RANGE + 1, supertile.zCoord + RANGE + 1)); + for(EntityTNTPrimed tnt : tnts) { + if(tnt.fuse == 1 && !tnt.isDead && !supertile.getWorldObj().getBlock(MathHelper.floor_double(tnt.posX), MathHelper.floor_double(tnt.posY), MathHelper.floor_double(tnt.posZ)).getMaterial().isLiquid()) { + if(!supertile.getWorldObj().isRemote) { + tnt.setDead(); + mana += getMaxMana(); + supertile.getWorldObj().playSoundEffect(tnt.posX, tnt.posY, tnt.posZ, "random.explode", 0.2F, (1F + (supertile.getWorldObj().rand.nextFloat() - supertile.getWorldObj().rand.nextFloat()) * 0.2F) * 0.7F); + sync(); + } - if (mana == 0) { - List tnts = supertile - .getWorldObj() - .getEntitiesWithinAABB( - EntityTNTPrimed.class, - AxisAlignedBB.getBoundingBox( - supertile.xCoord - RANGE, - supertile.yCoord - RANGE, - supertile.zCoord - RANGE, - supertile.xCoord + RANGE + 1, - supertile.yCoord + RANGE + 1, - supertile.zCoord + RANGE + 1)); - for (EntityTNTPrimed tnt : tnts) { - if (tnt.fuse == 1 - && !tnt.isDead - && !supertile - .getWorldObj() - .getBlock( - MathHelper.floor_double(tnt.posX), - MathHelper.floor_double(tnt.posY), - MathHelper.floor_double(tnt.posZ)) - .getMaterial() - .isLiquid()) { - if (!supertile.getWorldObj().isRemote) { - tnt.setDead(); - mana += getMaxMana(); - supertile - .getWorldObj() - .playSoundEffect( - tnt.posX, - tnt.posY, - tnt.posZ, - "random.explode", - 0.2F, - (1F - + (supertile - .getWorldObj() - .rand - .nextFloat() - - supertile - .getWorldObj() - .rand - .nextFloat()) - * 0.2F) - * 0.7F); - sync(); - } + for(int i = 0; i < 50; i++) + Botania.proxy.sparkleFX(tnt.worldObj, tnt.posX + Math.random() * 4 - 2, tnt.posY + Math.random() * 4 - 2, tnt.posZ + Math.random() * 4 - 2, 1F, (float) Math.random() * 0.25F, (float) Math.random() * 0.25F, (float) (Math.random() * 0.65F + 1.25F), 12); - for (int i = 0; i < 50; i++) - Botania.proxy.sparkleFX( - tnt.worldObj, - tnt.posX + Math.random() * 4 - 2, - tnt.posY + Math.random() * 4 - 2, - tnt.posZ + Math.random() * 4 - 2, - 1F, - (float) Math.random() * 0.25F, - (float) Math.random() * 0.25F, - (float) (Math.random() * 0.65F + 1.25F), - 12); + supertile.getWorldObj().spawnParticle("hugeexplosion", tnt.posX, tnt.posY, tnt.posZ, 1D, 0D, 0D); + return; + } + } + } + } - supertile.getWorldObj().spawnParticle("hugeexplosion", tnt.posX, tnt.posY, tnt.posZ, 1D, 0D, 0D); - return; - } - } - } - } + @Override + public int getColor() { + return 0xcb0000; + } - @Override - public int getColor() { - return 0xcb0000; - } + @Override + public int getMaxMana() { + return 6500; + } - @Override - public int getMaxMana() { - return 6500; - } + @Override + public RadiusDescriptor getRadius() { + return new RadiusDescriptor.Square(toChunkCoordinates(), RANGE); + }; - @Override - public RadiusDescriptor getRadius() { - return new RadiusDescriptor.Square(toChunkCoordinates(), RANGE); - } - ; + @Override + public LexiconEntry getEntry() { + return LexiconData.entropinnyum; + } - @Override - public LexiconEntry getEntry() { - return LexiconData.entropinnyum; - } } diff --git a/src/main/java/vazkii/botania/common/block/subtile/generating/SubTileGourmaryllis.java b/src/main/java/vazkii/botania/common/block/subtile/generating/SubTileGourmaryllis.java index 90e3d137ec..5109539e70 100644 --- a/src/main/java/vazkii/botania/common/block/subtile/generating/SubTileGourmaryllis.java +++ b/src/main/java/vazkii/botania/common/block/subtile/generating/SubTileGourmaryllis.java @@ -2,15 +2,16 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jul 26, 2014, 1:42:17 PM (GMT)] */ package vazkii.botania.common.block.subtile.generating; import java.util.List; + import net.minecraft.entity.item.EntityItem; import net.minecraft.item.Item; import net.minecraft.item.ItemFood; @@ -24,109 +25,86 @@ public class SubTileGourmaryllis extends SubTileGenerating { - private static final String TAG_COOLDOWN = "cooldown"; - private static final int RANGE = 1; - - int cooldown = 0; - int storedMana = 0; - - @Override - public void onUpdate() { - super.onUpdate(); - - if (cooldown > 0) cooldown--; - if (cooldown == 0 && !supertile.getWorldObj().isRemote) { - mana = Math.min(getMaxMana(), mana + storedMana); - storedMana = 0; - sync(); - } - - int slowdown = getSlowdownFactor(); - - boolean remote = supertile.getWorldObj().isRemote; - List items = supertile - .getWorldObj() - .getEntitiesWithinAABB( - EntityItem.class, - AxisAlignedBB.getBoundingBox( - supertile.xCoord - RANGE, - supertile.yCoord - RANGE, - supertile.zCoord - RANGE, - supertile.xCoord + RANGE + 1, - supertile.yCoord + RANGE + 1, - supertile.zCoord + RANGE + 1)); - for (EntityItem item : items) { - ItemStack stack = item.getEntityItem(); - if (stack != null && stack.getItem() instanceof ItemFood && !item.isDead && item.age >= slowdown) { - if (cooldown == 0) { - if (!remote) { - int val = ((ItemFood) stack.getItem()).func_150905_g(stack); - storedMana = val * val * 64; - cooldown = val * 10; - supertile - .getWorldObj() - .playSoundEffect( - supertile.xCoord, - supertile.yCoord, - supertile.zCoord, - "random.eat", - 0.2F, - 0.5F + (float) Math.random() * 0.5F); - sync(); - } else - for (int i = 0; i < 10; i++) { - float m = 0.2F; - float mx = (float) (Math.random() - 0.5) * m; - float my = (float) (Math.random() - 0.5) * m; - float mz = (float) (Math.random() - 0.5) * m; - supertile - .getWorldObj() - .spawnParticle( - "iconcrack_" + Item.getIdFromItem(stack.getItem()), - item.posX, - item.posY, - item.posZ, - mx, - my, - mz); - } - } - - if (!remote) item.setDead(); - } - } - } - - @Override - public void writeToPacketNBT(NBTTagCompound cmp) { - super.writeToPacketNBT(cmp); - cmp.setInteger(TAG_COOLDOWN, cooldown); - cmp.setInteger(TAG_COOLDOWN, cooldown); - } - - @Override - public void readFromPacketNBT(NBTTagCompound cmp) { - super.readFromPacketNBT(cmp); - cooldown = cmp.getInteger(TAG_COOLDOWN); - } - - @Override - public RadiusDescriptor getRadius() { - return new RadiusDescriptor.Square(toChunkCoordinates(), RANGE); - } - - @Override - public int getMaxMana() { - return 8000; - } - - @Override - public int getColor() { - return 0xD3D604; - } - - @Override - public LexiconEntry getEntry() { - return LexiconData.gourmaryllis; - } + private static final String TAG_COOLDOWN = "cooldown"; + private static final int RANGE = 1; + + int cooldown = 0; + int storedMana = 0; + + @Override + public void onUpdate() { + super.onUpdate(); + + if(cooldown > 0) + cooldown--; + if(cooldown == 0 && !supertile.getWorldObj().isRemote) { + mana = Math.min(getMaxMana(), mana + storedMana); + storedMana = 0; + sync(); + } + + int slowdown = getSlowdownFactor(); + + boolean remote = supertile.getWorldObj().isRemote; + List items = supertile.getWorldObj().getEntitiesWithinAABB(EntityItem.class, AxisAlignedBB.getBoundingBox(supertile.xCoord - RANGE, supertile.yCoord - RANGE, supertile.zCoord - RANGE, supertile.xCoord + RANGE + 1, supertile.yCoord + RANGE + 1, supertile.zCoord + RANGE + 1)); + for(EntityItem item : items) { + ItemStack stack = item.getEntityItem(); + if(stack != null && stack.getItem() instanceof ItemFood && !item.isDead && item.age >= slowdown) { + if(cooldown == 0) { + if(!remote) { + int val = ((ItemFood) stack.getItem()).func_150905_g(stack); + storedMana = val * val * 64; + cooldown = val * 10; + supertile.getWorldObj().playSoundEffect(supertile.xCoord, supertile.yCoord, supertile.zCoord, "random.eat", 0.2F, 0.5F + (float) Math.random() * 0.5F); + sync(); + } else + for(int i = 0; i < 10; i++) { + float m = 0.2F; + float mx = (float) (Math.random() - 0.5) * m; + float my = (float) (Math.random() - 0.5) * m; + float mz = (float) (Math.random() - 0.5) * m; + supertile.getWorldObj().spawnParticle("iconcrack_" + Item.getIdFromItem(stack.getItem()), item.posX, item.posY, item.posZ, mx, my, mz); + } + + } + + if(!remote) + item.setDead(); + } + } + } + + @Override + public void writeToPacketNBT(NBTTagCompound cmp) { + super.writeToPacketNBT(cmp); + cmp.setInteger(TAG_COOLDOWN, cooldown); + cmp.setInteger(TAG_COOLDOWN, cooldown); + } + + @Override + public void readFromPacketNBT(NBTTagCompound cmp) { + super.readFromPacketNBT(cmp); + cooldown = cmp.getInteger(TAG_COOLDOWN); + } + + @Override + public RadiusDescriptor getRadius() { + return new RadiusDescriptor.Square(toChunkCoordinates(), RANGE); + } + + @Override + public int getMaxMana() { + return 8000; + } + + @Override + public int getColor() { + return 0xD3D604; + } + + @Override + public LexiconEntry getEntry() { + return LexiconData.gourmaryllis; + } + } diff --git a/src/main/java/vazkii/botania/common/block/subtile/generating/SubTileHydroangeas.java b/src/main/java/vazkii/botania/common/block/subtile/generating/SubTileHydroangeas.java index f10afb77fe..7bb064c870 100644 --- a/src/main/java/vazkii/botania/common/block/subtile/generating/SubTileHydroangeas.java +++ b/src/main/java/vazkii/botania/common/block/subtile/generating/SubTileHydroangeas.java @@ -13,6 +13,7 @@ import java.util.Arrays; import java.util.Collections; import java.util.List; + import net.minecraft.block.Block; import net.minecraft.block.material.Material; import net.minecraft.entity.EntityLivingBase; @@ -31,197 +32,155 @@ @PassiveFlower public class SubTileHydroangeas extends SubTilePassiveGenerating { - private static final String TAG_BURN_TIME = "burnTime"; - private static final String TAG_COOLDOWN = "cooldown"; - - private static final int[][] OFFSETS = {{0, 1}, {0, -1}, {1, 0}, {-1, 0}, {-1, 1}, {-1, -1}, {1, 1}, {1, -1}}; - - int burnTime, cooldown; - - @Override - public void onUpdate() { - super.onUpdate(); - - if (cooldown > 0) { - cooldown--; - for (int i = 0; i < 3; i++) - Botania.proxy.wispFX( - supertile.getWorldObj(), - supertile.xCoord + 0.5 + Math.random() * 0.2 - 0.1, - supertile.yCoord + 0.5 + Math.random() * 0.2 - 0.1, - supertile.zCoord + 0.5 + Math.random() * 0.2 - 0.1, - 0.1F, - 0.1F, - 0.1F, - (float) Math.random() / 6, - (float) -Math.random() / 30); - } - - if (burnTime == 0) { - if (mana < getMaxMana() && !supertile.getWorldObj().isRemote) { - List offsets = Arrays.asList(OFFSETS); - Collections.shuffle(offsets); - - for (int[] offsetArray : offsets) { - int[] positions = {supertile.xCoord + offsetArray[0], supertile.zCoord + offsetArray[1]}; - - Material search = getMaterialToSearchFor(); - if (supertile - .getWorldObj() - .getBlock(positions[0], supertile.yCoord, positions[1]) - .getMaterial() - == search - && (getBlockToSearchBelow() == null - || supertile - .getWorldObj() - .getBlock(positions[0], supertile.yCoord - 1, positions[1]) - == getBlockToSearchBelow()) - && supertile.getWorldObj().getBlockMetadata(positions[0], supertile.yCoord, positions[1]) - == 0) { - if (search != Material.water) - supertile.getWorldObj().setBlockToAir(positions[0], supertile.yCoord, positions[1]); - else { - int waterAround = 0; - for (ForgeDirection dir : LibMisc.CARDINAL_DIRECTIONS) - if (supertile - .getWorldObj() - .getBlock( - positions[0] + dir.offsetX, - supertile.yCoord, - positions[1] + dir.offsetZ) - .getMaterial() - == search) waterAround++; - - if (waterAround < 2) - supertile.getWorldObj().setBlockToAir(positions[0], supertile.yCoord, positions[1]); - } - - if (cooldown == 0) burnTime += getBurnTime(); - else cooldown = getCooldown(); - - sync(); - playSound(); - break; - } - } - } - } else { - if (supertile.getWorldObj().rand.nextInt(8) == 0) doBurnParticles(); - burnTime--; - if (burnTime == 0) { - cooldown = getCooldown(); - sync(); - } - } - } - - public void doBurnParticles() { - Botania.proxy.wispFX( - supertile.getWorldObj(), - supertile.xCoord + 0.55 + Math.random() * 0.2 - 0.1, - supertile.yCoord + 0.55 + Math.random() * 0.2 - 0.1, - supertile.zCoord + 0.5, - 0.05F, - 0.05F, - 0.7F, - (float) Math.random() / 6, - (float) -Math.random() / 60); - } - - public Material getMaterialToSearchFor() { - return Material.water; - } - - public Block getBlockToSearchBelow() { - return null; - } - - public void playSound() { - supertile - .getWorldObj() - .playSoundEffect( - supertile.xCoord, - supertile.yCoord, - supertile.zCoord, - "random.drink", - 0.01F, - 0.5F + (float) Math.random() * 0.5F); - } - - public int getBurnTime() { - return 40; - } - - @Override - public RadiusDescriptor getRadius() { - return new RadiusDescriptor.Square(toChunkCoordinates(), 1); - } - - @Override - public int getMaxMana() { - return 150; - } - - @Override - public int getColor() { - return 0x532FE0; - } - - @Override - public LexiconEntry getEntry() { - return LexiconData.hydroangeas; - } - - @Override - public void writeToPacketNBT(NBTTagCompound cmp) { - super.writeToPacketNBT(cmp); - - cmp.setInteger(TAG_BURN_TIME, burnTime); - cmp.setInteger(TAG_COOLDOWN, cooldown); - } - - @Override - public void readFromPacketNBT(NBTTagCompound cmp) { - super.readFromPacketNBT(cmp); - - burnTime = cmp.getInteger(TAG_BURN_TIME); - cooldown = cmp.getInteger(TAG_COOLDOWN); - } - - @Override - public void populateDropStackNBTs(List drops) { - super.populateDropStackNBTs(drops); - int cooldown = this.cooldown; - if (burnTime > 0) cooldown = getCooldown(); - - if (cooldown > 0) ItemNBTHelper.setInt(drops.get(0), TAG_COOLDOWN, getCooldown()); - } - - @Override - public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase entity, ItemStack stack) { - super.onBlockPlacedBy(world, x, y, z, entity, stack); - cooldown = ItemNBTHelper.getInt(stack, TAG_COOLDOWN, 0); - } - - @Override - public boolean canGeneratePassively() { - return burnTime > 0; - } - - @Override - public int getDelayBetweenPassiveGeneration() { - boolean rain = supertile - .getWorldObj() - .getWorldChunkManager() - .getBiomeGenAt(supertile.xCoord, supertile.zCoord) - .getIntRainfall() - > 0 - && (supertile.getWorldObj().isRaining() - || supertile.getWorldObj().isThundering()); - return rain ? 1 : 2; - } - - public int getCooldown() { - return 0; - } + private static final String TAG_BURN_TIME = "burnTime"; + private static final String TAG_COOLDOWN = "cooldown"; + + private static final int[][] OFFSETS = { { 0, 1 }, { 0, -1 }, { 1, 0 }, { -1, 0 }, { -1, 1 }, { -1, -1 }, { 1, 1 }, { 1, -1 } }; + + int burnTime, cooldown; + + @Override + public void onUpdate() { + super.onUpdate(); + + if(cooldown > 0) { + cooldown--; + for(int i = 0; i < 3; i++) + Botania.proxy.wispFX(supertile.getWorldObj(), supertile.xCoord + 0.5 + Math.random() * 0.2 - 0.1, supertile.yCoord + 0.5 + Math.random() * 0.2 - 0.1, supertile.zCoord + 0.5 + Math.random() * 0.2 - 0.1, 0.1F, 0.1F, 0.1F, (float) Math.random() / 6, (float) -Math.random() / 30); + } + + if(burnTime == 0) { + if(mana < getMaxMana() && !supertile.getWorldObj().isRemote) { + List offsets = Arrays.asList(OFFSETS); + Collections.shuffle(offsets); + + for(int[] offsetArray : offsets) { + int[] positions = { + supertile.xCoord + offsetArray[0], + supertile.zCoord + offsetArray[1] + }; + + Material search = getMaterialToSearchFor(); + if(supertile.getWorldObj().getBlock(positions[0], supertile.yCoord, positions[1]).getMaterial() == search && (getBlockToSearchBelow() == null || supertile.getWorldObj().getBlock(positions[0], supertile.yCoord - 1, positions[1]) == getBlockToSearchBelow()) && supertile.getWorldObj().getBlockMetadata(positions[0], supertile.yCoord, positions[1]) == 0) { + if(search != Material.water) + supertile.getWorldObj().setBlockToAir(positions[0], supertile.yCoord, positions[1]); + else { + int waterAround = 0; + for(ForgeDirection dir : LibMisc.CARDINAL_DIRECTIONS) + if(supertile.getWorldObj().getBlock(positions[0] + dir.offsetX, supertile.yCoord, positions[1] + dir.offsetZ).getMaterial() == search) + waterAround++; + + if(waterAround < 2) + supertile.getWorldObj().setBlockToAir(positions[0], supertile.yCoord, positions[1]); + } + + if(cooldown == 0) + burnTime += getBurnTime(); + else cooldown = getCooldown(); + + sync(); + playSound(); + break; + } + } + } + } else { + if(supertile.getWorldObj().rand.nextInt(8) == 0) + doBurnParticles(); + burnTime--; + if(burnTime == 0) { + cooldown = getCooldown(); + sync(); + } + } + } + + public void doBurnParticles() { + Botania.proxy.wispFX(supertile.getWorldObj(), supertile.xCoord + 0.55 + Math.random() * 0.2 - 0.1, supertile.yCoord + 0.55 + Math.random() * 0.2 - 0.1, supertile.zCoord + 0.5, 0.05F, 0.05F, 0.7F, (float) Math.random() / 6, (float) -Math.random() / 60); + } + + public Material getMaterialToSearchFor() { + return Material.water; + } + + public Block getBlockToSearchBelow() { + return null; + } + + public void playSound() { + supertile.getWorldObj().playSoundEffect(supertile.xCoord, supertile.yCoord, supertile.zCoord, "random.drink", 0.01F, 0.5F + (float) Math.random() * 0.5F); + } + + public int getBurnTime() { + return 40; + } + + @Override + public RadiusDescriptor getRadius() { + return new RadiusDescriptor.Square(toChunkCoordinates(), 1); + } + + @Override + public int getMaxMana() { + return 150; + } + + @Override + public int getColor() { + return 0x532FE0; + } + + @Override + public LexiconEntry getEntry() { + return LexiconData.hydroangeas; + } + + @Override + public void writeToPacketNBT(NBTTagCompound cmp) { + super.writeToPacketNBT(cmp); + + cmp.setInteger(TAG_BURN_TIME, burnTime); + cmp.setInteger(TAG_COOLDOWN, cooldown); + } + + @Override + public void readFromPacketNBT(NBTTagCompound cmp) { + super.readFromPacketNBT(cmp); + + burnTime = cmp.getInteger(TAG_BURN_TIME); + cooldown = cmp.getInteger(TAG_COOLDOWN); + } + + @Override + public void populateDropStackNBTs(List drops) { + super.populateDropStackNBTs(drops); + int cooldown = this.cooldown; + if(burnTime > 0) + cooldown = getCooldown(); + + if(cooldown > 0) + ItemNBTHelper.setInt(drops.get(0), TAG_COOLDOWN, getCooldown()); + } + + @Override + public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase entity, ItemStack stack) { + super.onBlockPlacedBy(world, x, y, z, entity, stack); + cooldown = ItemNBTHelper.getInt(stack, TAG_COOLDOWN, 0); + } + + @Override + public boolean canGeneratePassively() { + return burnTime > 0; + } + + @Override + public int getDelayBetweenPassiveGeneration() { + boolean rain = supertile.getWorldObj().getWorldChunkManager().getBiomeGenAt(supertile.xCoord, supertile.zCoord).getIntRainfall() > 0 && (supertile.getWorldObj().isRaining() || supertile.getWorldObj().isThundering()); + return rain ? 1 : 2; + } + + public int getCooldown() { + return 0; + } + } diff --git a/src/main/java/vazkii/botania/common/block/subtile/generating/SubTileKekimurus.java b/src/main/java/vazkii/botania/common/block/subtile/generating/SubTileKekimurus.java index 9eeb5dc68b..cbb2a15e1c 100644 --- a/src/main/java/vazkii/botania/common/block/subtile/generating/SubTileKekimurus.java +++ b/src/main/java/vazkii/botania/common/block/subtile/generating/SubTileKekimurus.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jun 8, 2014, 6:26:37 PM (GMT)] */ package vazkii.botania.common.block.subtile.generating; @@ -19,64 +19,56 @@ public class SubTileKekimurus extends SubTileGenerating { - private static final int RANGE = 5; + private static final int RANGE = 5; - @Override - public void onUpdate() { - super.onUpdate(); + @Override + public void onUpdate() { + super.onUpdate(); - int mana = 1800; + int mana = 1800; - if (getMaxMana() - this.mana >= mana && !supertile.getWorldObj().isRemote && ticksExisted % 80 == 0) { - for (int i = 0; i < RANGE * 2 + 1; i++) - for (int j = 0; j < RANGE * 2 + 1; j++) - for (int k = 0; k < RANGE * 2 + 1; k++) { - int x = supertile.xCoord + i - RANGE; - int y = supertile.yCoord + j - RANGE; - int z = supertile.zCoord + k - RANGE; - Block block = supertile.getWorldObj().getBlock(x, y, z); - if (block instanceof BlockCake) { - int meta = supertile.getWorldObj().getBlockMetadata(x, y, z) + 1; - if (meta == 6) supertile.getWorldObj().setBlockToAir(x, y, z); - else supertile.getWorldObj().setBlockMetadataWithNotify(x, y, z, meta, 1 | 2); + if(getMaxMana() - this.mana >= mana && !supertile.getWorldObj().isRemote && ticksExisted % 80 == 0) { + for(int i = 0; i < RANGE * 2 + 1; i++) + for(int j = 0; j < RANGE * 2 + 1; j++) + for(int k = 0; k < RANGE * 2 + 1; k++) { + int x = supertile.xCoord + i - RANGE; + int y = supertile.yCoord + j - RANGE; + int z = supertile.zCoord + k - RANGE; + Block block = supertile.getWorldObj().getBlock(x, y, z); + if(block instanceof BlockCake) { + int meta = supertile.getWorldObj().getBlockMetadata(x, y, z) + 1; + if(meta == 6) + supertile.getWorldObj().setBlockToAir(x, y, z); + else supertile.getWorldObj().setBlockMetadataWithNotify(x, y, z, meta, 1 | 2); - supertile - .getWorldObj() - .playAuxSFX(2001, x, y, z, Block.getIdFromBlock(block) + (meta << 12)); - supertile - .getWorldObj() - .playSoundEffect( - supertile.xCoord, - supertile.yCoord, - supertile.zCoord, - "random.eat", - 1F, - 0.5F + (float) Math.random() * 0.5F); - this.mana += mana; - sync(); - return; - } - } - } - } + supertile.getWorldObj().playAuxSFX(2001, x, y, z, Block.getIdFromBlock(block) + (meta << 12)); + supertile.getWorldObj().playSoundEffect(supertile.xCoord, supertile.yCoord, supertile.zCoord, "random.eat", 1F, 0.5F + (float) Math.random() * 0.5F); + this.mana += mana; + sync(); + return; + } + } + } + } - @Override - public RadiusDescriptor getRadius() { - return new RadiusDescriptor.Square(toChunkCoordinates(), RANGE); - } + @Override + public RadiusDescriptor getRadius() { + return new RadiusDescriptor.Square(toChunkCoordinates(), RANGE); + } - @Override - public LexiconEntry getEntry() { - return LexiconData.kekimurus; - } + @Override + public LexiconEntry getEntry() { + return LexiconData.kekimurus; + } - @Override - public int getColor() { - return 0x935D28; - } + @Override + public int getColor() { + return 0x935D28; + } + + @Override + public int getMaxMana() { + return 9001; + } - @Override - public int getMaxMana() { - return 9001; - } } diff --git a/src/main/java/vazkii/botania/common/block/subtile/generating/SubTileMunchdew.java b/src/main/java/vazkii/botania/common/block/subtile/generating/SubTileMunchdew.java index 85a14a3637..0b7a66f58f 100644 --- a/src/main/java/vazkii/botania/common/block/subtile/generating/SubTileMunchdew.java +++ b/src/main/java/vazkii/botania/common/block/subtile/generating/SubTileMunchdew.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [May 15, 2014, 7:25:47 PM (GMT)] */ package vazkii.botania.common.block.subtile.generating; @@ -13,6 +13,7 @@ import java.util.ArrayList; import java.util.Collections; import java.util.List; + import net.minecraft.block.Block; import net.minecraft.block.material.Material; import net.minecraft.entity.EntityLivingBase; @@ -30,136 +31,124 @@ public class SubTileMunchdew extends SubTileGenerating { - private static final String TAG_COOLDOWN = "cooldown"; - private static final String TAG_ATE_ONCE = "ateOnce"; - - private static final int RANGE = 8; - private static final int RANGE_Y = 16; - - boolean ateOnce = false; - int ticksWithoutEating = -1; - int cooldown = 0; - - @Override - public void onUpdate() { - super.onUpdate(); - - if (cooldown > 0) { - cooldown--; - ticksWithoutEating = 0; - return; - } - - int manaPerLeaf = 160; - eatLeaves: - { - if (getMaxMana() - mana >= manaPerLeaf && !supertile.getWorldObj().isRemote && ticksExisted % 4 == 0) { - List coords = new ArrayList(); - int x = supertile.xCoord; - int y = supertile.yCoord; - int z = supertile.zCoord; - - for (int i = -RANGE; i < RANGE + 1; i++) - for (int j = 0; j < RANGE_Y; j++) - for (int k = -RANGE; k < RANGE + 1; k++) { - int xp = x + i; - int yp = y + j; - int zp = z + k; - Block block = supertile.getWorldObj().getBlock(xp, yp, zp); - if (block.getMaterial() == Material.leaves) { - boolean exposed = false; - for (ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS) - if (supertile - .getWorldObj() - .getBlock(xp + dir.offsetX, yp + dir.offsetY, zp + dir.offsetZ) - .isAir( - supertile.getWorldObj(), - xp + dir.offsetX, - yp + dir.offsetY, - zp + dir.offsetZ)) { - exposed = true; - break; - } - - if (exposed) coords.add(new ChunkCoordinates(xp, yp, zp)); - } - } - - if (coords.isEmpty()) break eatLeaves; - - Collections.shuffle(coords); - ChunkCoordinates breakCoords = coords.get(0); - Block block = supertile.getWorldObj().getBlock(breakCoords.posX, breakCoords.posY, breakCoords.posZ); - int meta = - supertile.getWorldObj().getBlockMetadata(breakCoords.posX, breakCoords.posY, breakCoords.posZ); - supertile.getWorldObj().setBlockToAir(breakCoords.posX, breakCoords.posY, breakCoords.posZ); - ticksWithoutEating = 0; - ateOnce = true; - if (ConfigHandler.blockBreakParticles) - supertile - .getWorldObj() - .playAuxSFX( - 2001, - breakCoords.posX, - breakCoords.posY, - breakCoords.posZ, - Block.getIdFromBlock(block) + (meta << 12)); - mana += manaPerLeaf; - } - } - - if (ateOnce) { - ticksWithoutEating++; - if (ticksWithoutEating >= 5) cooldown = 1600; - } - } - - @Override - public RadiusDescriptor getRadius() { - return new RadiusDescriptor.Square(toChunkCoordinates(), RANGE); - } - - @Override - public void writeToPacketNBT(NBTTagCompound cmp) { - super.writeToPacketNBT(cmp); - - cmp.setInteger(TAG_COOLDOWN, cooldown); - cmp.setBoolean(TAG_ATE_ONCE, ateOnce); - } - - @Override - public void readFromPacketNBT(NBTTagCompound cmp) { - super.readFromPacketNBT(cmp); - - cooldown = cmp.getInteger(TAG_COOLDOWN); - ateOnce = cmp.getBoolean(TAG_ATE_ONCE); - } - - @Override - public ArrayList getDrops(ArrayList list) { - ArrayList drops = super.getDrops(list); - if (cooldown > 0) ItemNBTHelper.setInt(drops.get(0), TAG_COOLDOWN, cooldown); - return drops; - } - - @Override - public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase entity, ItemStack stack) { - super.onBlockPlacedBy(world, x, y, z, entity, stack); - cooldown = ItemNBTHelper.getInt(stack, TAG_COOLDOWN, 0); - } - - @Override - public int getColor() { - return 0x79C42F; - } - - @Override - public int getMaxMana() { - return 10000; - } - - @Override - public LexiconEntry getEntry() { - return LexiconData.munchdew; - } + private static final String TAG_COOLDOWN = "cooldown"; + private static final String TAG_ATE_ONCE = "ateOnce"; + + private static final int RANGE = 8; + private static final int RANGE_Y = 16; + + boolean ateOnce = false; + int ticksWithoutEating = -1; + int cooldown = 0; + + @Override + public void onUpdate() { + super.onUpdate(); + + if(cooldown > 0) { + cooldown--; + ticksWithoutEating = 0; + return; + } + + int manaPerLeaf = 160; + eatLeaves : { + if(getMaxMana() - mana >= manaPerLeaf && !supertile.getWorldObj().isRemote && ticksExisted % 4 == 0) { + List coords = new ArrayList(); + int x = supertile.xCoord; + int y = supertile.yCoord; + int z = supertile.zCoord; + + for(int i = -RANGE; i < RANGE + 1; i++) + for(int j = 0; j < RANGE_Y; j++) + for(int k = -RANGE; k < RANGE + 1; k++) { + int xp = x + i; + int yp = y + j; + int zp = z + k; + Block block = supertile.getWorldObj().getBlock(xp, yp, zp); + if(block.getMaterial() == Material.leaves) { + boolean exposed = false; + for(ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS) + if(supertile.getWorldObj().getBlock(xp + dir.offsetX, yp + dir.offsetY, zp + dir.offsetZ).isAir(supertile.getWorldObj(), xp + dir.offsetX, yp + dir.offsetY, zp + dir.offsetZ)) { + exposed = true; + break; + } + + if(exposed) + coords.add(new ChunkCoordinates(xp, yp, zp)); + } + } + + if(coords.isEmpty()) + break eatLeaves; + + Collections.shuffle(coords); + ChunkCoordinates breakCoords = coords.get(0); + Block block = supertile.getWorldObj().getBlock(breakCoords.posX, breakCoords.posY, breakCoords.posZ); + int meta = supertile.getWorldObj().getBlockMetadata(breakCoords.posX, breakCoords.posY, breakCoords.posZ); + supertile.getWorldObj().setBlockToAir(breakCoords.posX, breakCoords.posY, breakCoords.posZ); + ticksWithoutEating = 0; + ateOnce = true; + if(ConfigHandler.blockBreakParticles) + supertile.getWorldObj().playAuxSFX(2001, breakCoords.posX, breakCoords.posY, breakCoords.posZ, Block.getIdFromBlock(block) + (meta << 12)); + mana += manaPerLeaf; + } + } + + if(ateOnce) { + ticksWithoutEating++; + if(ticksWithoutEating >= 5) + cooldown = 1600; + } + } + + @Override + public RadiusDescriptor getRadius() { + return new RadiusDescriptor.Square(toChunkCoordinates(), RANGE); + } + + @Override + public void writeToPacketNBT(NBTTagCompound cmp) { + super.writeToPacketNBT(cmp); + + cmp.setInteger(TAG_COOLDOWN, cooldown); + cmp.setBoolean(TAG_ATE_ONCE, ateOnce); + } + + @Override + public void readFromPacketNBT(NBTTagCompound cmp) { + super.readFromPacketNBT(cmp); + + cooldown = cmp.getInteger(TAG_COOLDOWN); + ateOnce = cmp.getBoolean(TAG_ATE_ONCE); + } + + @Override + public ArrayList getDrops(ArrayList list) { + ArrayList drops = super.getDrops(list); + if(cooldown > 0) + ItemNBTHelper.setInt(drops.get(0), TAG_COOLDOWN, cooldown); + return drops; + } + + @Override + public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase entity, ItemStack stack) { + super.onBlockPlacedBy(world, x, y, z, entity, stack); + cooldown = ItemNBTHelper.getInt(stack, TAG_COOLDOWN, 0); + } + + @Override + public int getColor() { + return 0x79C42F; + } + + @Override + public int getMaxMana() { + return 10000; + } + + @Override + public LexiconEntry getEntry() { + return LexiconData.munchdew; + } } diff --git a/src/main/java/vazkii/botania/common/block/subtile/generating/SubTileNarslimmus.java b/src/main/java/vazkii/botania/common/block/subtile/generating/SubTileNarslimmus.java index 0c2ae6d96b..875fbb094b 100644 --- a/src/main/java/vazkii/botania/common/block/subtile/generating/SubTileNarslimmus.java +++ b/src/main/java/vazkii/botania/common/block/subtile/generating/SubTileNarslimmus.java @@ -2,17 +2,16 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jan 29, 2015, 10:43:54 PM (GMT)] */ package vazkii.botania.common.block.subtile.generating; -import cpw.mods.fml.common.eventhandler.Event.Result; -import cpw.mods.fml.common.eventhandler.SubscribeEvent; import java.util.List; + import net.minecraft.entity.monster.EntitySlime; import net.minecraft.util.AxisAlignedBB; import net.minecraft.util.MathHelper; @@ -23,98 +22,80 @@ import vazkii.botania.api.subtile.RadiusDescriptor; import vazkii.botania.api.subtile.SubTileGenerating; import vazkii.botania.common.lexicon.LexiconData; +import cpw.mods.fml.common.eventhandler.Event.Result; +import cpw.mods.fml.common.eventhandler.SubscribeEvent; public class SubTileNarslimmus extends SubTileGenerating { - public static final String TAG_WORLD_SPAWNED = "Botania:WorldSpawned"; - - private static final int RANGE = 2; - - @Override - public void onUpdate() { - super.onUpdate(); - - if (ticksExisted % 5 == 0) { - List slimes = supertile - .getWorldObj() - .getEntitiesWithinAABB( - EntitySlime.class, - AxisAlignedBB.getBoundingBox( - supertile.xCoord - RANGE, - supertile.yCoord - RANGE, - supertile.zCoord - RANGE, - supertile.xCoord + RANGE + 1, - supertile.yCoord + RANGE, - supertile.zCoord + RANGE + 1)); - for (EntitySlime slime : slimes) { - if (slime.getEntityData().getBoolean(TAG_WORLD_SPAWNED) && !slime.isDead) { - int size = slime.getSlimeSize(); - int mul = (int) Math.pow(2, size); - int mana = 820 * mul; - if (!slime.worldObj.isRemote) { - slime.setDead(); - slime.worldObj.playSoundAtEntity(slime, "mob.slime." + (size > 1 ? "big" : "small"), 1F, 0.02F); - this.mana = Math.min(getMaxMana(), this.mana + mana); - sync(); - } - - for (int j = 0; j < mul * 8; ++j) { - float f = slime.worldObj.rand.nextFloat() * (float) Math.PI * 2.0F; - float f1 = slime.worldObj.rand.nextFloat() * 0.5F + 0.5F; - float f2 = MathHelper.sin(f) * size * 0.5F * f1; - float f3 = MathHelper.cos(f) * size * 0.5F * f1; - float f4 = slime.worldObj.rand.nextFloat() * size * 0.5F * f1; - slime.worldObj.spawnParticle( - "slime", - slime.posX + f2, - slime.boundingBox.minY + f4, - slime.posZ + f3, - 0.0D, - 0.0D, - 0.0D); - } - break; - } - } - } - } - - @Override - public RadiusDescriptor getRadius() { - return new RadiusDescriptor.Square(toChunkCoordinates(), RANGE); - } - - @Override - public int getMaxMana() { - return 8000; - } - - @Override - public int getColor() { - return 0x71C373; - } - - @Override - public LexiconEntry getEntry() { - return LexiconData.narslimmus; - } - - public static class SpawnIntercepter { - - @SubscribeEvent - public void onSpawn(LivingSpawnEvent.CheckSpawn event) { - if (event.entityLiving instanceof EntitySlime - && event.getResult() != Result.DENY - && isSlimeChunk( - event.entityLiving.worldObj, - MathHelper.floor_double(event.x), - MathHelper.floor_double(event.z))) - event.entityLiving.getEntityData().setBoolean(TAG_WORLD_SPAWNED, true); - } - - public static boolean isSlimeChunk(World world, int x, int z) { - Chunk chunk = world.getChunkFromBlockCoords(x, z); - return chunk.getRandomWithSeed(987234911L).nextInt(10) == 0; - } - } + public static final String TAG_WORLD_SPAWNED = "Botania:WorldSpawned"; + + private static final int RANGE = 2; + + @Override + public void onUpdate() { + super.onUpdate(); + + if(ticksExisted % 5 == 0) { + List slimes = supertile.getWorldObj().getEntitiesWithinAABB(EntitySlime.class, AxisAlignedBB.getBoundingBox(supertile.xCoord - RANGE, supertile.yCoord - RANGE, supertile.zCoord - RANGE, supertile.xCoord + RANGE + 1, supertile.yCoord + RANGE, supertile.zCoord + RANGE + 1)); + for(EntitySlime slime : slimes) { + if(slime.getEntityData().getBoolean(TAG_WORLD_SPAWNED) && !slime.isDead) { + int size = slime.getSlimeSize(); + int mul = (int) Math.pow(2, size); + int mana = 820 * mul; + if(!slime.worldObj.isRemote) { + slime.setDead(); + slime.worldObj.playSoundAtEntity(slime, "mob.slime." + (size > 1 ? "big" : "small"), 1F, 0.02F); + this.mana = Math.min(getMaxMana(), this.mana + mana); + sync(); + } + + for (int j = 0; j < mul * 8; ++j) { + float f = slime.worldObj.rand.nextFloat() * (float)Math.PI * 2.0F; + float f1 = slime.worldObj.rand.nextFloat() * 0.5F + 0.5F; + float f2 = MathHelper.sin(f) * size * 0.5F * f1; + float f3 = MathHelper.cos(f) * size * 0.5F * f1; + float f4 = slime.worldObj.rand.nextFloat() * size * 0.5F * f1; + slime.worldObj.spawnParticle("slime", slime.posX + f2, slime.boundingBox.minY + f4, slime.posZ + f3, 0.0D, 0.0D, 0.0D); + } + break; + } + } + } + } + + @Override + public RadiusDescriptor getRadius() { + return new RadiusDescriptor.Square(toChunkCoordinates(), RANGE); + } + + @Override + public int getMaxMana() { + return 8000; + } + + @Override + public int getColor() { + return 0x71C373; + } + + @Override + public LexiconEntry getEntry() { + return LexiconData.narslimmus; + } + + public static class SpawnIntercepter { + + @SubscribeEvent + public void onSpawn(LivingSpawnEvent.CheckSpawn event) { + if(event.entityLiving instanceof EntitySlime && event.getResult() != Result.DENY && isSlimeChunk(event.entityLiving.worldObj, MathHelper.floor_double(event.x), MathHelper.floor_double(event.z))) + event.entityLiving.getEntityData().setBoolean(TAG_WORLD_SPAWNED, true); + } + + public static boolean isSlimeChunk(World world, int x, int z) { + Chunk chunk = world.getChunkFromBlockCoords(x, z); + return chunk.getRandomWithSeed(987234911L).nextInt(10) == 0; + } + + } + } diff --git a/src/main/java/vazkii/botania/common/block/subtile/generating/SubTileNightshade.java b/src/main/java/vazkii/botania/common/block/subtile/generating/SubTileNightshade.java index 97d641aa00..4ad851412f 100644 --- a/src/main/java/vazkii/botania/common/block/subtile/generating/SubTileNightshade.java +++ b/src/main/java/vazkii/botania/common/block/subtile/generating/SubTileNightshade.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Mar 16, 2014, 11:15:42 PM (GMT)] */ package vazkii.botania.common.block.subtile.generating; @@ -17,36 +17,38 @@ @PassiveFlower public class SubTileNightshade extends SubTileDaybloom { - @Override - public int getDelayBetweenPassiveGeneration() { - return super.getDelayBetweenPassiveGeneration(); - } - - @Override - public boolean canGeneratePassively() { - return !super.canGeneratePassively() && !supertile.getWorldObj().isDaytime(); - } - - @Override - public int getColor() { - return 0x3D2A90; - } - - @Override - public LexiconEntry getEntry() { - return LexiconData.nightshade; - } - - public static class Prime extends SubTileNightshade { - - @Override - public boolean isPrime() { - return true; - } - - @Override - public LexiconEntry getEntry() { - return LexiconData.primusLoci; - } - } + @Override + public int getDelayBetweenPassiveGeneration() { + return super.getDelayBetweenPassiveGeneration(); + } + + @Override + public boolean canGeneratePassively() { + return !super.canGeneratePassively() && !supertile.getWorldObj().isDaytime(); + } + + @Override + public int getColor() { + return 0x3D2A90; + } + + @Override + public LexiconEntry getEntry() { + return LexiconData.nightshade; + } + + public static class Prime extends SubTileNightshade { + + @Override + public boolean isPrime() { + return true; + } + + @Override + public LexiconEntry getEntry() { + return LexiconData.primusLoci; + } + + } + } diff --git a/src/main/java/vazkii/botania/common/block/subtile/generating/SubTilePassiveGenerating.java b/src/main/java/vazkii/botania/common/block/subtile/generating/SubTilePassiveGenerating.java index 93a17e173a..be40920793 100644 --- a/src/main/java/vazkii/botania/common/block/subtile/generating/SubTilePassiveGenerating.java +++ b/src/main/java/vazkii/botania/common/block/subtile/generating/SubTilePassiveGenerating.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Mar 16, 2015, 6:03:16 PM (GMT)] */ package vazkii.botania.common.block.subtile.generating; @@ -14,8 +14,9 @@ public class SubTilePassiveGenerating extends SubTileGenerating { - @Override - public boolean isPassiveFlower() { - return true; - } + @Override + public boolean isPassiveFlower() { + return true; + } + } diff --git a/src/main/java/vazkii/botania/common/block/subtile/generating/SubTileRafflowsia.java b/src/main/java/vazkii/botania/common/block/subtile/generating/SubTileRafflowsia.java index 37788de889..07a42d947c 100644 --- a/src/main/java/vazkii/botania/common/block/subtile/generating/SubTileRafflowsia.java +++ b/src/main/java/vazkii/botania/common/block/subtile/generating/SubTileRafflowsia.java @@ -2,15 +2,16 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Oct 11, 2015, 5:05:05 PM (GMT)] */ package vazkii.botania.common.block.subtile.generating; import java.util.List; + import net.minecraft.block.Block; import net.minecraft.entity.EntityLivingBase; import net.minecraft.item.ItemStack; @@ -27,108 +28,108 @@ public class SubTileRafflowsia extends SubTileGenerating { - private static final String TAG_LAST_FLOWER = "lastFlower"; - private static final String TAG_LAST_FLOWER_TIMES = "lastFlowerTimes"; - - String lastFlower; - int lastFlowerTimes; - - private static final int RANGE = 5; - - @Override - public void onUpdate() { - super.onUpdate(); - - int mana = 2100; - - if (getMaxMana() - this.mana >= mana && !supertile.getWorldObj().isRemote && ticksExisted % 40 == 0) { - for (int i = 0; i < RANGE * 2 + 1; i++) - for (int j = 0; j < RANGE * 2 + 1; j++) - for (int k = 0; k < RANGE * 2 + 1; k++) { - int x = supertile.xCoord + i - RANGE; - int y = supertile.yCoord + j - RANGE; - int z = supertile.zCoord + k - RANGE; - Block block = supertile.getWorldObj().getBlock(x, y, z); - TileEntity tile = supertile.getWorldObj().getTileEntity(x, y, z); - if (tile instanceof ISubTileContainer) { - SubTileEntity stile = ((ISubTileContainer) tile).getSubTile(); - String name = stile.getUnlocalizedName(); - - if (stile instanceof SubTileGenerating && ((SubTileGenerating) stile).isPassiveFlower()) { - boolean last = name.equals(lastFlower); - if (last) lastFlowerTimes++; - else { - lastFlower = name; - lastFlowerTimes = 1; - } - - float mod = 1F / lastFlowerTimes; - - int meta = supertile.getWorldObj().getBlockMetadata(x, y, z) + 1; - supertile.getWorldObj().setBlockToAir(x, y, z); - - supertile - .getWorldObj() - .playAuxSFX(2001, x, y, z, Block.getIdFromBlock(block) + (meta << 12)); - this.mana += mana * mod; - sync(); - return; - } - } - } - } - } - - @Override - public void writeToPacketNBT(NBTTagCompound cmp) { - super.writeToPacketNBT(cmp); - - cmp.setString(TAG_LAST_FLOWER, lastFlower); - cmp.setInteger(TAG_LAST_FLOWER_TIMES, lastFlowerTimes); - } - - @Override - public void readFromPacketNBT(NBTTagCompound cmp) { - super.readFromPacketNBT(cmp); - - lastFlower = cmp.getString(TAG_LAST_FLOWER); - lastFlowerTimes = cmp.getInteger(TAG_LAST_FLOWER_TIMES); - } - - @Override - public void populateDropStackNBTs(List drops) { - super.populateDropStackNBTs(drops); - - ItemStack stack = drops.get(0); - ItemNBTHelper.setString(stack, TAG_LAST_FLOWER, lastFlower); - ItemNBTHelper.setInt(stack, TAG_LAST_FLOWER_TIMES, lastFlowerTimes); - } - - @Override - public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase entity, ItemStack stack) { - super.onBlockPlacedBy(world, x, y, z, entity, stack); - - lastFlower = ItemNBTHelper.getString(stack, TAG_LAST_FLOWER, ""); - lastFlowerTimes = ItemNBTHelper.getInt(stack, TAG_LAST_FLOWER_TIMES, 0); - } - - @Override - public RadiusDescriptor getRadius() { - return new RadiusDescriptor.Square(toChunkCoordinates(), RANGE); - } - - @Override - public int getColor() { - return 0x502C76; - } - - @Override - public int getMaxMana() { - return 9000; - } - - @Override - public LexiconEntry getEntry() { - return LexiconData.rafflowsia; - } + private static final String TAG_LAST_FLOWER = "lastFlower"; + private static final String TAG_LAST_FLOWER_TIMES = "lastFlowerTimes"; + + String lastFlower; + int lastFlowerTimes; + + private static final int RANGE = 5; + + @Override + public void onUpdate() { + super.onUpdate(); + + int mana = 2100; + + if(getMaxMana() - this.mana >= mana && !supertile.getWorldObj().isRemote && ticksExisted % 40 == 0) { + for(int i = 0; i < RANGE * 2 + 1; i++) + for(int j = 0; j < RANGE * 2 + 1; j++) + for(int k = 0; k < RANGE * 2 + 1; k++) { + int x = supertile.xCoord + i - RANGE; + int y = supertile.yCoord + j - RANGE; + int z = supertile.zCoord + k - RANGE; + Block block = supertile.getWorldObj().getBlock(x, y, z); + TileEntity tile = supertile.getWorldObj().getTileEntity(x, y, z); + if(tile instanceof ISubTileContainer) { + SubTileEntity stile = ((ISubTileContainer) tile).getSubTile(); + String name = stile.getUnlocalizedName(); + + if(stile instanceof SubTileGenerating && ((SubTileGenerating) stile).isPassiveFlower()) { + boolean last = name.equals(lastFlower); + if(last) + lastFlowerTimes++; + else { + lastFlower = name; + lastFlowerTimes = 1; + } + + float mod = 1F / lastFlowerTimes; + + int meta = supertile.getWorldObj().getBlockMetadata(x, y, z) + 1; + supertile.getWorldObj().setBlockToAir(x, y, z); + + supertile.getWorldObj().playAuxSFX(2001, x, y, z, Block.getIdFromBlock(block) + (meta << 12)); + this.mana += mana * mod; + sync(); + return; + } + } + } + } + } + + @Override + public void writeToPacketNBT(NBTTagCompound cmp) { + super.writeToPacketNBT(cmp); + + cmp.setString(TAG_LAST_FLOWER, lastFlower); + cmp.setInteger(TAG_LAST_FLOWER_TIMES, lastFlowerTimes); + } + + @Override + public void readFromPacketNBT(NBTTagCompound cmp) { + super.readFromPacketNBT(cmp); + + lastFlower = cmp.getString(TAG_LAST_FLOWER); + lastFlowerTimes = cmp.getInteger(TAG_LAST_FLOWER_TIMES); + } + + @Override + public void populateDropStackNBTs(List drops) { + super.populateDropStackNBTs(drops); + + ItemStack stack = drops.get(0); + ItemNBTHelper.setString(stack, TAG_LAST_FLOWER, lastFlower); + ItemNBTHelper.setInt(stack, TAG_LAST_FLOWER_TIMES, lastFlowerTimes); + } + + @Override + public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase entity, ItemStack stack) { + super.onBlockPlacedBy(world, x, y, z, entity, stack); + + lastFlower = ItemNBTHelper.getString(stack, TAG_LAST_FLOWER, ""); + lastFlowerTimes = ItemNBTHelper.getInt(stack, TAG_LAST_FLOWER_TIMES, 0); + } + + @Override + public RadiusDescriptor getRadius() { + return new RadiusDescriptor.Square(toChunkCoordinates(), RANGE); + } + + @Override + public int getColor() { + return 0x502C76; + } + + @Override + public int getMaxMana() { + return 9000; + } + + @Override + public LexiconEntry getEntry() { + return LexiconData.rafflowsia; + } + } diff --git a/src/main/java/vazkii/botania/common/block/subtile/generating/SubTileSpectrolus.java b/src/main/java/vazkii/botania/common/block/subtile/generating/SubTileSpectrolus.java index 76c7574656..1bfeb03edb 100644 --- a/src/main/java/vazkii/botania/common/block/subtile/generating/SubTileSpectrolus.java +++ b/src/main/java/vazkii/botania/common/block/subtile/generating/SubTileSpectrolus.java @@ -2,16 +2,17 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jan 30, 2015, 1:37:26 PM (GMT)] */ package vazkii.botania.common.block.subtile.generating; import java.awt.Color; import java.util.List; + import net.minecraft.client.Minecraft; import net.minecraft.client.gui.ScaledResolution; import net.minecraft.client.renderer.RenderHelper; @@ -22,7 +23,9 @@ import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.util.AxisAlignedBB; + import org.lwjgl.opengl.GL11; + import vazkii.botania.api.lexicon.LexiconEntry; import vazkii.botania.api.subtile.RadiusDescriptor; import vazkii.botania.api.subtile.SubTileGenerating; @@ -30,119 +33,102 @@ public class SubTileSpectrolus extends SubTileGenerating { - private static final String TAG_NEXT_COLOR = "nextColor"; - - private static final int RANGE = 1; - - int nextColor; - - @Override - public void onUpdate() { - super.onUpdate(); - - boolean remote = supertile.getWorldObj().isRemote; - Item wool = Item.getItemFromBlock(Blocks.wool); - List items = supertile - .getWorldObj() - .getEntitiesWithinAABB( - EntityItem.class, - AxisAlignedBB.getBoundingBox( - supertile.xCoord - RANGE, - supertile.yCoord - RANGE, - supertile.zCoord - RANGE, - supertile.xCoord + RANGE + 1, - supertile.yCoord + RANGE + 1, - supertile.zCoord + RANGE + 1)); - int slowdown = getSlowdownFactor(); - - for (EntityItem item : items) { - ItemStack stack = item.getEntityItem(); - if (stack != null && stack.getItem() == wool && !item.isDead && item.age >= slowdown) { - int meta = stack.getItemDamage(); - if (meta == nextColor) { - if (!remote) { - mana = Math.min(getMaxMana(), mana + 300); - nextColor = nextColor == 15 ? 0 : nextColor + 1; - sync(); - } - - for (int i = 0; i < 10; i++) { - float m = 0.2F; - float mx = (float) (Math.random() - 0.5) * m; - float my = (float) (Math.random() - 0.5) * m; - float mz = (float) (Math.random() - 0.5) * m; - supertile - .getWorldObj() - .spawnParticle( - "blockcrack_" + Item.getIdFromItem(stack.getItem()) + "_" + meta, - item.posX, - item.posY, - item.posZ, - mx, - my, - mz); - } - } - - if (!remote) item.setDead(); - } - } - } - - @Override - public RadiusDescriptor getRadius() { - return new RadiusDescriptor.Square(toChunkCoordinates(), RANGE); - } - - @Override - public int getMaxMana() { - return 8000; - } - - @Override - public int getColor() { - return Color.HSBtoRGB(ticksExisted / 100F, 1F, 1F); - } - - @Override - public LexiconEntry getEntry() { - return LexiconData.spectrolus; - } - - @Override - public void renderHUD(Minecraft mc, ScaledResolution res) { - super.renderHUD(mc, res); - - ItemStack stack = new ItemStack(Blocks.wool, 1, nextColor); - int color = getColor(); - - GL11.glEnable(GL11.GL_BLEND); - GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); - if (stack != null && stack.getItem() != null) { - String stackName = stack.getDisplayName(); - int width = 16 + mc.fontRenderer.getStringWidth(stackName) / 2; - int x = res.getScaledWidth() / 2 - width; - int y = res.getScaledHeight() / 2 + 30; - - mc.fontRenderer.drawStringWithShadow(stackName, x + 20, y + 5, color); - RenderHelper.enableGUIStandardItemLighting(); - RenderItem.getInstance().renderItemAndEffectIntoGUI(mc.fontRenderer, mc.renderEngine, stack, x, y); - RenderHelper.disableStandardItemLighting(); - } - - GL11.glDisable(GL11.GL_LIGHTING); - GL11.glDisable(GL11.GL_BLEND); - } - - @Override - public void writeToPacketNBT(NBTTagCompound cmp) { - super.writeToPacketNBT(cmp); - cmp.setInteger(TAG_NEXT_COLOR, nextColor); - } - - @Override - public void readFromPacketNBT(NBTTagCompound cmp) { - super.readFromPacketNBT(cmp); - nextColor = cmp.getInteger(TAG_NEXT_COLOR); - } + private static final String TAG_NEXT_COLOR = "nextColor"; + + private static final int RANGE = 1; + + int nextColor; + + @Override + public void onUpdate() { + super.onUpdate(); + + boolean remote = supertile.getWorldObj().isRemote; + Item wool = Item.getItemFromBlock(Blocks.wool); + List items = supertile.getWorldObj().getEntitiesWithinAABB(EntityItem.class, AxisAlignedBB.getBoundingBox(supertile.xCoord - RANGE, supertile.yCoord - RANGE, supertile.zCoord - RANGE, supertile.xCoord + RANGE + 1, supertile.yCoord + RANGE + 1, supertile.zCoord + RANGE + 1)); + int slowdown = getSlowdownFactor(); + + for(EntityItem item : items) { + ItemStack stack = item.getEntityItem(); + if(stack != null && stack.getItem() == wool && !item.isDead && item.age >= slowdown) { + int meta = stack.getItemDamage(); + if(meta == nextColor) { + if(!remote) { + mana = Math.min(getMaxMana(), mana + 300); + nextColor = nextColor == 15 ? 0 : nextColor + 1; + sync(); + } + + for(int i = 0; i < 10; i++) { + float m = 0.2F; + float mx = (float) (Math.random() - 0.5) * m; + float my = (float) (Math.random() - 0.5) * m; + float mz = (float) (Math.random() - 0.5) * m; + supertile.getWorldObj().spawnParticle("blockcrack_" + Item.getIdFromItem(stack.getItem()) + "_" + meta, item.posX, item.posY, item.posZ, mx, my, mz); + } + } + + if(!remote) + item.setDead(); + } + } + } + + @Override + public RadiusDescriptor getRadius() { + return new RadiusDescriptor.Square(toChunkCoordinates(), RANGE); + } + + @Override + public int getMaxMana() { + return 8000; + } + + @Override + public int getColor() { + return Color.HSBtoRGB(ticksExisted / 100F, 1F, 1F); + } + + @Override + public LexiconEntry getEntry() { + return LexiconData.spectrolus; + } + + @Override + public void renderHUD(Minecraft mc, ScaledResolution res) { + super.renderHUD(mc, res); + + ItemStack stack = new ItemStack(Blocks.wool, 1, nextColor); + int color = getColor(); + + GL11.glEnable(GL11.GL_BLEND); + GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); + if(stack != null && stack.getItem() != null) { + String stackName = stack.getDisplayName(); + int width = 16 + mc.fontRenderer.getStringWidth(stackName) / 2; + int x = res.getScaledWidth() / 2 - width; + int y = res.getScaledHeight() / 2 + 30; + + mc.fontRenderer.drawStringWithShadow(stackName, x + 20, y + 5, color); + RenderHelper.enableGUIStandardItemLighting(); + RenderItem.getInstance().renderItemAndEffectIntoGUI(mc.fontRenderer, mc.renderEngine, stack, x, y); + RenderHelper.disableStandardItemLighting(); + } + + GL11.glDisable(GL11.GL_LIGHTING); + GL11.glDisable(GL11.GL_BLEND); + } + + @Override + public void writeToPacketNBT(NBTTagCompound cmp) { + super.writeToPacketNBT(cmp); + cmp.setInteger(TAG_NEXT_COLOR, nextColor); + } + + @Override + public void readFromPacketNBT(NBTTagCompound cmp) { + super.readFromPacketNBT(cmp); + nextColor = cmp.getInteger(TAG_NEXT_COLOR); + } + } diff --git a/src/main/java/vazkii/botania/common/block/subtile/generating/SubTileThermalily.java b/src/main/java/vazkii/botania/common/block/subtile/generating/SubTileThermalily.java index 937f5c98c4..13e0fb1c8c 100644 --- a/src/main/java/vazkii/botania/common/block/subtile/generating/SubTileThermalily.java +++ b/src/main/java/vazkii/botania/common/block/subtile/generating/SubTileThermalily.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Mar 10, 2014, 9:44:02 PM (GMT)] */ package vazkii.botania.common.block.subtile.generating; @@ -17,69 +17,59 @@ public class SubTileThermalily extends SubTileHydroangeas { - @Override - public int getColor() { - return 0xD03C00; - } + @Override + public int getColor(){ + return 0xD03C00; + } - @Override - public LexiconEntry getEntry() { - return LexiconData.thermalily; - } + @Override + public LexiconEntry getEntry() { + return LexiconData.thermalily; + } - @Override - public void doBurnParticles() { - Botania.proxy.wispFX( - supertile.getWorldObj(), - supertile.xCoord + 0.55 + Math.random() * 0.2 - 0.1, - supertile.yCoord + 0.9 + Math.random() * 0.2 - 0.1, - supertile.zCoord + 0.5, - 0.7F, - 0.05F, - 0.05F, - (float) Math.random() / 6, - (float) -Math.random() / 60); - } + @Override + public void doBurnParticles() { + Botania.proxy.wispFX(supertile.getWorldObj(), supertile.xCoord + 0.55 + Math.random() * 0.2 - 0.1, supertile.yCoord + 0.9 + Math.random() * 0.2 - 0.1, supertile.zCoord + 0.5, 0.7F, 0.05F, 0.05F, (float) Math.random() / 6, (float) -Math.random() / 60); + } - @Override - public boolean isPassiveFlower() { - return false; - } + @Override + public boolean isPassiveFlower() { + return false; + } - @Override - public Material getMaterialToSearchFor() { - return Material.lava; - } + @Override + public Material getMaterialToSearchFor() { + return Material.lava; + } - @Override - public void playSound() { - supertile - .getWorldObj() - .playSoundEffect(supertile.xCoord, supertile.yCoord, supertile.zCoord, "botania:thermalily", 0.2F, 1F); - } + @Override + public void playSound() { + supertile.getWorldObj().playSoundEffect(supertile.xCoord, supertile.yCoord, supertile.zCoord, "botania:thermalily", 0.2F, 1F); + } - @Override - public int getDelayBetweenPassiveGeneration() { - return 1; - } + @Override + public int getDelayBetweenPassiveGeneration() { + return 1; + } - @Override - public int getBurnTime() { - return 900; - } + @Override + public int getBurnTime() { + return 900; + } - @Override - public int getValueForPassiveGeneration() { - return 20; - } + @Override + public int getValueForPassiveGeneration() { + return 20; + } - @Override - public int getMaxMana() { - return 500; - } + @Override + public int getMaxMana() { + return 500; + } + + @Override + public int getCooldown() { + return 6000; + } - @Override - public int getCooldown() { - return 6000; - } } diff --git a/src/main/java/vazkii/botania/common/block/tile/TileAlfPortal.java b/src/main/java/vazkii/botania/common/block/tile/TileAlfPortal.java index 59a6f4f1ec..d3d475ee79 100644 --- a/src/main/java/vazkii/botania/common/block/tile/TileAlfPortal.java +++ b/src/main/java/vazkii/botania/common/block/tile/TileAlfPortal.java @@ -2,17 +2,17 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jun 9, 2014, 8:51:55 PM (GMT)] */ package vazkii.botania.common.block.tile; -import com.google.common.base.Function; import java.util.ArrayList; import java.util.List; + import net.minecraft.block.Block; import net.minecraft.entity.item.EntityItem; import net.minecraft.init.Blocks; @@ -35,323 +35,345 @@ import vazkii.botania.common.item.ItemLexicon; import vazkii.botania.common.lexicon.LexiconData; +import com.google.common.base.Function; + public class TileAlfPortal extends TileMod { - private static final int[][] LIVINGWOOD_POSITIONS = { - {-1, 0, 0}, {1, 0, 0}, {-2, 1, 0}, {2, 1, 0}, {-2, 3, 0}, {2, 3, 0}, {-1, 4, 0}, {1, 4, 0} - }; - - private static final int[][] GLIMMERING_LIVINGWOOD_POSITIONS = {{-2, 2, 0}, {2, 2, 0}, {0, 4, 0}}; - - private static final int[][] PYLON_POSITIONS = {{-3, 1, 3}, {3, 1, 3}}; - - private static final int[][] POOL_POSITIONS = {{-3, 0, 3}, {3, 0, 3}}; - - private static final int[][] AIR_POSITIONS = { - {-1, 1, 0}, {0, 1, 0}, {1, 1, 0}, {-1, 2, 0}, {0, 2, 0}, {1, 2, 0}, {-1, 3, 0}, {0, 3, 0}, {1, 3, 0} - }; - - private static final String TAG_TICKS_OPEN = "ticksOpen"; - private static final String TAG_TICKS_SINCE_LAST_ITEM = "ticksSinceLastItem"; - private static final String TAG_STACK_COUNT = "stackCount"; - private static final String TAG_STACK = "portalStack"; - private static final String TAG_PORTAL_FLAG = "_elvenPortal"; - - List stacksIn = new ArrayList(); - - public int ticksOpen = 0; - int ticksSinceLastItem = 0; - private boolean closeNow = false; - private boolean hasUnloadedParts = false; - - private static final Function CONVERTER_X_Z = new Function() { - @Override - public int[] apply(int[] input) { - return new int[] {input[2], input[1], input[0]}; - } - }; - - private static final Function CONVERTER_X_Z_FP = new Function() { - @Override - public double[] apply(double[] input) { - return new double[] {input[2], input[1], input[0]}; - } - }; - - private static final Function CONVERTER_Z_SWAP = new Function() { - @Override - public int[] apply(int[] input) { - return new int[] {input[0], input[1], -input[2]}; - } - }; - - public static MultiblockSet makeMultiblockSet() { - Multiblock mb = new Multiblock(); - - for (int[] l : LIVINGWOOD_POSITIONS) mb.addComponent(l[0], l[1] + 1, l[2], ModBlocks.livingwood, 0); - for (int[] g : GLIMMERING_LIVINGWOOD_POSITIONS) mb.addComponent(g[0], g[1] + 1, g[2], ModBlocks.livingwood, 5); - for (int[] p : PYLON_POSITIONS) mb.addComponent(-p[0], p[1] + 1, -p[2], ModBlocks.pylon, 1); - for (int[] p : POOL_POSITIONS) mb.addComponent(-p[0], p[1] + 1, -p[2], ModBlocks.pool, 0); - - mb.addComponent(0, 1, 0, ModBlocks.alfPortal, 0); - mb.setRenderOffset(0, -1, 0); - - return mb.makeSet(); - } - - @Override - public void updateEntity() { - int meta = getBlockMetadata(); - if (meta == 0) { - ticksOpen = 0; - return; - } - int newMeta = getValidMetadata(); - - if (!hasUnloadedParts) { - ticksOpen++; - - AxisAlignedBB aabb = getPortalAABB(); - boolean open = ticksOpen > 60; - ElvenPortalUpdateEvent event = new ElvenPortalUpdateEvent(this, aabb, open, stacksIn); - MinecraftForge.EVENT_BUS.post(event); - - if (ticksOpen > 60) { - ticksSinceLastItem++; - if (ConfigHandler.elfPortalParticlesEnabled) blockParticle(meta); - - List items = worldObj.getEntitiesWithinAABB(EntityItem.class, aabb); - if (!worldObj.isRemote) - for (EntityItem item : items) { - if (item.isDead) continue; - - ItemStack stack = item.getEntityItem(); - if (stack != null - && (!(stack.getItem() instanceof IElvenItem) - || !((IElvenItem) stack.getItem()).isElvenItem(stack)) - && !item.getEntityData().hasKey(TAG_PORTAL_FLAG)) { - item.setDead(); - addItem(stack); - ticksSinceLastItem = 0; - } - } - - if (ticksSinceLastItem >= 4) { - if (!worldObj.isRemote) resolveRecipes(); - } - } - } else closeNow = false; - - if (closeNow) { - worldObj.setBlockMetadataWithNotify(xCoord, yCoord, zCoord, 0, 1 | 2); - for (int i = 0; i < 36; i++) blockParticle(meta); - closeNow = false; - } else if (newMeta != meta) { - if (newMeta == 0) for (int i = 0; i < 36; i++) blockParticle(meta); - worldObj.setBlockMetadataWithNotify(xCoord, yCoord, zCoord, newMeta, 1 | 2); - } - - hasUnloadedParts = false; - } - - private void blockParticle(int meta) { - int i = worldObj.rand.nextInt(AIR_POSITIONS.length); - double[] pos = - new double[] {AIR_POSITIONS[i][0] + 0.5F, AIR_POSITIONS[i][1] + 0.5F, AIR_POSITIONS[i][2] + 0.5F}; - if (meta == 2) pos = CONVERTER_X_Z_FP.apply(pos); - - float motionMul = 0.2F; - Botania.proxy.wispFX( - getWorldObj(), - xCoord + pos[0], - yCoord + pos[1], - zCoord + pos[2], - (float) (Math.random() * 0.25F), - (float) (Math.random() * 0.5F + 0.5F), - (float) (Math.random() * 0.25F), - (float) (Math.random() * 0.15F + 0.1F), - (float) (Math.random() - 0.5F) * motionMul, - (float) (Math.random() - 0.5F) * motionMul, - (float) (Math.random() - 0.5F) * motionMul); - } - - public boolean onWanded() { - int meta = getBlockMetadata(); - if (meta == 0) { - int newMeta = getValidMetadata(); - if (newMeta != 0) { - worldObj.setBlockMetadataWithNotify(xCoord, yCoord, zCoord, newMeta, 1 | 2); - return true; - } - } - - return false; - } - - AxisAlignedBB getPortalAABB() { - AxisAlignedBB aabb = - AxisAlignedBB.getBoundingBox(xCoord - 1, yCoord + 1, zCoord, xCoord + 2, yCoord + 4, zCoord + 1); - if (getBlockMetadata() == 2) - aabb = AxisAlignedBB.getBoundingBox(xCoord, yCoord + 1, zCoord - 1, xCoord + 1, yCoord + 4, zCoord + 2); - - return aabb; - } - - void addItem(ItemStack stack) { - int size = stack.stackSize; - stack.stackSize = 1; - for (int i = 0; i < size; i++) stacksIn.add(stack.copy()); - } - - void resolveRecipes() { - int i = 0; - for (ItemStack stack : stacksIn) { - if (stack != null && stack.getItem() instanceof ILexicon) { - ((ILexicon) stack.getItem()).unlockKnowledge(stack, BotaniaAPI.elvenKnowledge); - ItemLexicon.setForcedPage(stack, LexiconData.elvenMessage.getUnlocalizedName()); - spawnItem(stack); - stacksIn.remove(i); - return; - } - i++; - } - - for (RecipeElvenTrade recipe : BotaniaAPI.elvenTradeRecipes) { - if (recipe.matches(stacksIn, false)) { - recipe.matches(stacksIn, true); - spawnItem(recipe.getOutput().copy()); - break; - } - } - } - - void spawnItem(ItemStack stack) { - EntityItem item = new EntityItem(worldObj, xCoord + 0.5, yCoord + 1.5, zCoord + 0.5, stack); - item.getEntityData().setBoolean(TAG_PORTAL_FLAG, true); - worldObj.spawnEntityInWorld(item); - ticksSinceLastItem = 0; - } - - @Override - public void writeToNBT(NBTTagCompound cmp) { - super.writeToNBT(cmp); - - cmp.setInteger(TAG_STACK_COUNT, stacksIn.size()); - int i = 0; - for (ItemStack stack : stacksIn) { - NBTTagCompound stackcmp = new NBTTagCompound(); - stack.writeToNBT(stackcmp); - cmp.setTag(TAG_STACK + i, stackcmp); - i++; - } - } - - @Override - public void readFromNBT(NBTTagCompound cmp) { - super.readFromNBT(cmp); - - int count = cmp.getInteger(TAG_STACK_COUNT); - stacksIn.clear(); - for (int i = 0; i < count; i++) { - NBTTagCompound stackcmp = cmp.getCompoundTag(TAG_STACK + i); - ItemStack stack = ItemStack.loadItemStackFromNBT(stackcmp); - stacksIn.add(stack); - } - } - - @Override - public void writeCustomNBT(NBTTagCompound cmp) { - cmp.setInteger(TAG_TICKS_OPEN, ticksOpen); - cmp.setInteger(TAG_TICKS_SINCE_LAST_ITEM, ticksSinceLastItem); - } - - @Override - public void readCustomNBT(NBTTagCompound cmp) { - ticksOpen = cmp.getInteger(TAG_TICKS_OPEN); - ticksSinceLastItem = cmp.getInteger(TAG_TICKS_SINCE_LAST_ITEM); - } - - private int getValidMetadata() { - if (checkConverter(null)) return 1; - - if (checkConverter(CONVERTER_X_Z)) return 2; - - return 0; - } - - private boolean checkConverter(Function baseConverter) { - return checkMultipleConverters(baseConverter) || checkMultipleConverters(CONVERTER_Z_SWAP, baseConverter); - } - - private boolean checkMultipleConverters(Function... converters) { - if (!check2DArray(AIR_POSITIONS, Blocks.air, -1, converters)) return false; - if (!check2DArray(LIVINGWOOD_POSITIONS, ModBlocks.livingwood, 0, converters)) return false; - if (!check2DArray(GLIMMERING_LIVINGWOOD_POSITIONS, ModBlocks.livingwood, 5, converters)) return false; - if (!check2DArray(PYLON_POSITIONS, ModBlocks.pylon, 1, converters)) return false; - if (!check2DArray(POOL_POSITIONS, ModBlocks.pool, -1, converters)) return false; - - lightPylons(converters); - return true; - } - - private void lightPylons(Function... converters) { - if (ticksOpen < 50) return; - - int cost = ticksOpen == 50 ? 75000 : 2; - - for (int[] pos : PYLON_POSITIONS) { - for (Function f : converters) if (f != null) pos = f.apply(pos); - - TileEntity tile = worldObj.getTileEntity(xCoord + pos[0], yCoord + pos[1], zCoord + pos[2]); - if (tile instanceof TilePylon) { - TilePylon pylon = (TilePylon) tile; - pylon.activated = true; - pylon.centerX = xCoord; - pylon.centerY = yCoord; - pylon.centerZ = zCoord; - } - - tile = worldObj.getTileEntity(xCoord + pos[0], yCoord + pos[1] - 1, zCoord + pos[2]); - if (tile instanceof TilePool) { - TilePool pool = (TilePool) tile; - if (pool.getCurrentMana() < cost) closeNow = true; - else if (!worldObj.isRemote) pool.recieveMana(-cost); - } - } - } - - private boolean check2DArray(int[][] positions, Block block, int meta, Function... converters) { - for (int[] pos : positions) { - for (Function f : converters) if (f != null) pos = f.apply(pos); - - if (!checkPosition(pos, block, meta)) return false; - } - - return true; - } - - private boolean checkPosition(int[] pos, Block block, int meta) { - int x = xCoord + pos[0]; - int y = yCoord + pos[1]; - int z = zCoord + pos[2]; - if (!worldObj.blockExists(x, y, z)) { - hasUnloadedParts = true; - return true; // Don't fuck everything up if there's a chunk unload - } - - Block blockat = worldObj.getBlock(x, y, z); - if (block == Blocks.air ? blockat.isAir(worldObj, x, y, z) : blockat == block) { - if (meta == -1) return true; - - int metaat = worldObj.getBlockMetadata(x, y, z); - return meta == metaat; - } - - return false; - } - - @Override - public AxisAlignedBB getRenderBoundingBox() { - return INFINITE_EXTENT_AABB; - } + private static final int[][] LIVINGWOOD_POSITIONS = { + { -1, 0, 0}, { 1, 0, 0}, { -2, 1, 0}, { 2, 1, 0}, { -2, 3, 0}, { 2, 3, 0}, { -1, 4, 0}, { 1, 4, 0} + }; + + private static final int[][] GLIMMERING_LIVINGWOOD_POSITIONS = { + { -2, 2, 0 }, { 2, 2, 0 }, { 0, 4, 0 } + }; + + private static final int[][] PYLON_POSITIONS = { + { -3, 1, 3 }, { 3, 1, 3 } + }; + + private static final int[][] POOL_POSITIONS = { + { -3, 0, 3 }, { 3, 0, 3 } + }; + + private static final int[][] AIR_POSITIONS = { + { -1, 1, 0 }, { 0, 1, 0 }, { 1, 1, 0 }, { -1, 2, 0 }, { 0, 2, 0 }, { 1, 2, 0 }, { -1, 3, 0 }, { 0, 3, 0 }, { 1, 3, 0 } + }; + + private static final String TAG_TICKS_OPEN = "ticksOpen"; + private static final String TAG_TICKS_SINCE_LAST_ITEM = "ticksSinceLastItem"; + private static final String TAG_STACK_COUNT = "stackCount"; + private static final String TAG_STACK = "portalStack"; + private static final String TAG_PORTAL_FLAG = "_elvenPortal"; + + List stacksIn = new ArrayList(); + + public int ticksOpen = 0; + int ticksSinceLastItem = 0; + private boolean closeNow = false; + private boolean hasUnloadedParts = false; + + private static final Function CONVERTER_X_Z = new Function() { + @Override + public int[] apply(int[] input) { + return new int[] { input[2], input[1], input[0] }; + } + }; + + private static final Function CONVERTER_X_Z_FP = new Function() { + @Override + public double[] apply(double[] input) { + return new double[] { input[2], input[1], input[0] }; + } + }; + + private static final Function CONVERTER_Z_SWAP = new Function() { + @Override + public int[] apply(int[] input) { + return new int[] { input[0], input[1], -input[2] }; + } + }; + + public static MultiblockSet makeMultiblockSet() { + Multiblock mb = new Multiblock(); + + for(int[] l : LIVINGWOOD_POSITIONS) + mb.addComponent(l[0], l[1] + 1, l[2], ModBlocks.livingwood, 0); + for(int[] g : GLIMMERING_LIVINGWOOD_POSITIONS) + mb.addComponent(g[0], g[1] + 1, g[2], ModBlocks.livingwood, 5); + for(int[] p : PYLON_POSITIONS) + mb.addComponent(-p[0], p[1] + 1, -p[2], ModBlocks.pylon, 1); + for(int[] p : POOL_POSITIONS) + mb.addComponent(-p[0], p[1] + 1, -p[2], ModBlocks.pool, 0); + + mb.addComponent(0, 1, 0, ModBlocks.alfPortal, 0); + mb.setRenderOffset(0, -1, 0); + + return mb.makeSet(); + } + + @Override + public void updateEntity() { + int meta = getBlockMetadata(); + if(meta == 0) { + ticksOpen = 0; + return; + } + int newMeta = getValidMetadata(); + + if(!hasUnloadedParts) { + ticksOpen++; + + AxisAlignedBB aabb = getPortalAABB(); + boolean open = ticksOpen > 60; + ElvenPortalUpdateEvent event = new ElvenPortalUpdateEvent(this, aabb, open, stacksIn); + MinecraftForge.EVENT_BUS.post(event); + + if(ticksOpen > 60) { + ticksSinceLastItem++; + if(ConfigHandler.elfPortalParticlesEnabled) + blockParticle(meta); + + List items = worldObj.getEntitiesWithinAABB(EntityItem.class, aabb); + if(!worldObj.isRemote) + for(EntityItem item : items) { + if(item.isDead) + continue; + + ItemStack stack = item.getEntityItem(); + if(stack != null && (!(stack.getItem() instanceof IElvenItem) || !((IElvenItem) stack.getItem()).isElvenItem(stack)) && !item.getEntityData().hasKey(TAG_PORTAL_FLAG)) { + item.setDead(); + addItem(stack); + ticksSinceLastItem = 0; + } + } + + if(ticksSinceLastItem >= 4) { + if(!worldObj.isRemote) + resolveRecipes(); + } + } + } else closeNow = false; + + if(closeNow) { + worldObj.setBlockMetadataWithNotify(xCoord, yCoord, zCoord, 0, 1 | 2); + for(int i = 0; i < 36; i++) + blockParticle(meta); + closeNow = false; + } else if(newMeta != meta) { + if(newMeta == 0) + for(int i = 0; i < 36; i++) + blockParticle(meta); + worldObj.setBlockMetadataWithNotify(xCoord, yCoord, zCoord, newMeta, 1 | 2); + } + + hasUnloadedParts = false; + } + + private void blockParticle(int meta) { + int i = worldObj.rand.nextInt(AIR_POSITIONS.length); + double[] pos = new double[] { + AIR_POSITIONS[i][0] + 0.5F, AIR_POSITIONS[i][1] + 0.5F, AIR_POSITIONS[i][2] + 0.5F + }; + if(meta == 2) + pos = CONVERTER_X_Z_FP.apply(pos); + + float motionMul = 0.2F; + Botania.proxy.wispFX(getWorldObj(), xCoord + pos[0], yCoord + pos[1], zCoord + pos[2], (float) (Math.random() * 0.25F), (float) (Math.random() * 0.5F + 0.5F), (float) (Math.random() * 0.25F), (float) (Math.random() * 0.15F + 0.1F), (float) (Math.random() - 0.5F) * motionMul, (float) (Math.random() - 0.5F) * motionMul, (float) (Math.random() - 0.5F) * motionMul); + } + + public boolean onWanded() { + int meta = getBlockMetadata(); + if(meta == 0) { + int newMeta = getValidMetadata(); + if(newMeta != 0) { + worldObj.setBlockMetadataWithNotify(xCoord, yCoord, zCoord, newMeta, 1 | 2); + return true; + } + } + + return false; + } + + AxisAlignedBB getPortalAABB() { + AxisAlignedBB aabb = AxisAlignedBB.getBoundingBox(xCoord - 1, yCoord + 1, zCoord, xCoord + 2, yCoord + 4, zCoord + 1); + if(getBlockMetadata() == 2) + aabb = AxisAlignedBB.getBoundingBox(xCoord, yCoord + 1, zCoord - 1, xCoord + 1, yCoord + 4, zCoord + 2); + + return aabb; + } + + void addItem(ItemStack stack) { + int size = stack.stackSize; + stack.stackSize = 1; + for(int i = 0; i < size; i++) + stacksIn.add(stack.copy()); + } + + void resolveRecipes() { + int i = 0; + for(ItemStack stack : stacksIn) { + if(stack != null && stack.getItem() instanceof ILexicon) { + ((ILexicon) stack.getItem()).unlockKnowledge(stack, BotaniaAPI.elvenKnowledge); + ItemLexicon.setForcedPage(stack, LexiconData.elvenMessage.getUnlocalizedName()); + spawnItem(stack); + stacksIn.remove(i); + return; + } + i++; + } + + for(RecipeElvenTrade recipe : BotaniaAPI.elvenTradeRecipes) { + if(recipe.matches(stacksIn, false)) { + recipe.matches(stacksIn, true); + spawnItem(recipe.getOutput().copy()); + break; + } + } + } + + void spawnItem(ItemStack stack) { + EntityItem item = new EntityItem(worldObj, xCoord + 0.5, yCoord + 1.5, zCoord + 0.5, stack); + item.getEntityData().setBoolean(TAG_PORTAL_FLAG, true); + worldObj.spawnEntityInWorld(item); + ticksSinceLastItem = 0; + } + + @Override + public void writeToNBT(NBTTagCompound cmp) { + super.writeToNBT(cmp); + + cmp.setInteger(TAG_STACK_COUNT, stacksIn.size()); + int i = 0; + for(ItemStack stack : stacksIn) { + NBTTagCompound stackcmp = new NBTTagCompound(); + stack.writeToNBT(stackcmp); + cmp.setTag(TAG_STACK + i, stackcmp); + i++; + } + } + + @Override + public void readFromNBT(NBTTagCompound cmp) { + super.readFromNBT(cmp); + + int count = cmp.getInteger(TAG_STACK_COUNT); + stacksIn.clear(); + for(int i = 0; i < count; i++) { + NBTTagCompound stackcmp = cmp.getCompoundTag(TAG_STACK + i); + ItemStack stack = ItemStack.loadItemStackFromNBT(stackcmp); + stacksIn.add(stack); + } + } + + @Override + public void writeCustomNBT(NBTTagCompound cmp) { + cmp.setInteger(TAG_TICKS_OPEN, ticksOpen); + cmp.setInteger(TAG_TICKS_SINCE_LAST_ITEM, ticksSinceLastItem); + } + + @Override + public void readCustomNBT(NBTTagCompound cmp) { + ticksOpen = cmp.getInteger(TAG_TICKS_OPEN); + ticksSinceLastItem = cmp.getInteger(TAG_TICKS_SINCE_LAST_ITEM); + } + + private int getValidMetadata() { + if(checkConverter(null)) + return 1; + + if(checkConverter(CONVERTER_X_Z)) + return 2; + + return 0; + } + + private boolean checkConverter(Function baseConverter) { + return checkMultipleConverters(baseConverter) || checkMultipleConverters(CONVERTER_Z_SWAP, baseConverter); + } + + private boolean checkMultipleConverters(Function... converters) { + if(!check2DArray(AIR_POSITIONS, Blocks.air, -1, converters)) + return false; + if(!check2DArray(LIVINGWOOD_POSITIONS, ModBlocks.livingwood, 0, converters)) + return false; + if(!check2DArray(GLIMMERING_LIVINGWOOD_POSITIONS, ModBlocks.livingwood, 5, converters)) + return false; + if(!check2DArray(PYLON_POSITIONS, ModBlocks.pylon, 1, converters)) + return false; + if(!check2DArray(POOL_POSITIONS, ModBlocks.pool, -1, converters)) + return false; + + lightPylons(converters); + return true; + } + + private void lightPylons(Function... converters) { + if(ticksOpen < 50) + return; + + int cost = ticksOpen == 50 ? 75000 : 2; + + for(int[] pos : PYLON_POSITIONS) { + for(Function f : converters) + if(f != null) + pos = f.apply(pos); + + TileEntity tile = worldObj.getTileEntity(xCoord + pos[0], yCoord + pos[1], zCoord + pos[2]); + if(tile instanceof TilePylon) { + TilePylon pylon = (TilePylon) tile; + pylon.activated = true; + pylon.centerX = xCoord; + pylon.centerY = yCoord; + pylon.centerZ = zCoord; + } + + tile = worldObj.getTileEntity(xCoord + pos[0], yCoord + pos[1] - 1, zCoord + pos[2]); + if(tile instanceof TilePool) { + TilePool pool = (TilePool) tile; + if(pool.getCurrentMana() < cost) + closeNow = true; + else if(!worldObj.isRemote) + pool.recieveMana(-cost); + } + } + } + + private boolean check2DArray(int[][] positions, Block block, int meta, Function... converters) { + for(int[] pos : positions) { + for(Function f : converters) + if(f != null) + pos = f.apply(pos); + + if(!checkPosition(pos, block, meta)) + return false; + } + + return true; + } + + private boolean checkPosition(int[] pos, Block block, int meta) { + int x = xCoord + pos[0]; + int y = yCoord + pos[1]; + int z = zCoord + pos[2]; + if(!worldObj.blockExists(x, y, z)) { + hasUnloadedParts = true; + return true; // Don't fuck everything up if there's a chunk unload + } + + Block blockat = worldObj.getBlock(x, y, z); + if(block == Blocks.air ? blockat.isAir(worldObj, x, y, z) : blockat == block) { + if(meta == -1) + return true; + + int metaat = worldObj.getBlockMetadata(x, y, z); + return meta == metaat; + } + + return false; + } + + @Override + public AxisAlignedBB getRenderBoundingBox() { + return INFINITE_EXTENT_AABB; + } } diff --git a/src/main/java/vazkii/botania/common/block/tile/TileAltar.java b/src/main/java/vazkii/botania/common/block/tile/TileAltar.java index 2ea60ae122..483e490217 100644 --- a/src/main/java/vazkii/botania/common/block/tile/TileAltar.java +++ b/src/main/java/vazkii/botania/common/block/tile/TileAltar.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jan 21, 2014, 7:51:36 PM (GMT)] */ package vazkii.botania.common.block.tile; @@ -14,6 +14,7 @@ import java.util.ArrayList; import java.util.List; import java.util.regex.Pattern; + import net.minecraft.client.Minecraft; import net.minecraft.client.gui.ScaledResolution; import net.minecraft.client.renderer.entity.RenderItem; @@ -29,7 +30,9 @@ import net.minecraft.nbt.NBTTagCompound; import net.minecraft.util.AxisAlignedBB; import net.minecraft.util.StatCollector; + import org.lwjgl.opengl.GL11; + import vazkii.botania.api.BotaniaAPI; import vazkii.botania.api.internal.VanillaPacketDispatcher; import vazkii.botania.api.item.IPetalApothecary; @@ -43,383 +46,354 @@ public class TileAltar extends TileSimpleInventory implements ISidedInventory, IPetalApothecary { - private static final Pattern SEED_PATTERN = - Pattern.compile("(?:(?:(?:[A-Z-_.:]|^)seed)|(?:(?:[a-z-_.:]|^)Seed))(?:[sA-Z-_.:]|$)"); - - public static final String TAG_HAS_WATER = "hasWater"; - public static final String TAG_HAS_LAVA = "hasLava"; - public static final String TAG_IS_MOSSY = "isMossy"; - - public boolean hasWater = false; - public boolean hasLava = false; - - public boolean isMossy = false; - - List lastRecipe = null; - int recipeKeepTicks = 0; - - public boolean collideEntityItem(EntityItem item) { - ItemStack stack = item.getEntityItem(); - if (stack == null || item.isDead) return false; - - if (!isMossy && getBlockMetadata() == 0) { - if (stack.getItem() == Item.getItemFromBlock(Blocks.vine) && !worldObj.isRemote) { - isMossy = true; - worldObj.func_147453_f(xCoord, yCoord, zCoord, worldObj.getBlock(xCoord, yCoord, zCoord)); - stack.stackSize--; - if (stack.stackSize == 0) item.setDead(); - VanillaPacketDispatcher.dispatchTEToNearbyPlayers(worldObj, xCoord, yCoord, zCoord); - } - } - - if (!hasWater() && !hasLava()) { - if (stack.getItem() == Items.water_bucket && !worldObj.isRemote) { - setWater(true); - worldObj.func_147453_f(xCoord, yCoord, zCoord, worldObj.getBlock(xCoord, yCoord, zCoord)); - stack.func_150996_a(Items.bucket); // Set item - } else if (stack.getItem() == Items.lava_bucket && !worldObj.isRemote) { - setLava(true); - worldObj.func_147453_f(xCoord, yCoord, zCoord, worldObj.getBlock(xCoord, yCoord, zCoord)); - stack.func_150996_a(Items.bucket); // Set item - } else return false; - } - - if (hasLava()) { - item.setFire(100); - return true; - } - - boolean didChange = false; - - if (canGoInAltar(stack, this)) { - if (getStackInSlot(getSizeInventory() - 1) != null) return false; - - if (!worldObj.isRemote) { - stack.stackSize--; - if (stack.stackSize == 0) item.setDead(); - - for (int i = 0; i < getSizeInventory(); i++) - if (getStackInSlot(i) == null) { - ItemStack stackToPut = stack.copy(); - stackToPut.stackSize = 1; - setInventorySlotContents(i, stackToPut); - didChange = true; - worldObj.playSoundAtEntity(item, "game.neutral.swim.splash", 0.1F, 1F); - break; - } - } - } else if (stack.getItem() != null - && SEED_PATTERN - .matcher(stack.getItem().getUnlocalizedName(stack)) - .find()) { - for (RecipePetals recipe : BotaniaAPI.petalRecipes) { - if (recipe.matches(this)) { - saveLastRecipe(); - - if (!worldObj.isRemote) { - for (int i = 0; i < getSizeInventory(); i++) setInventorySlotContents(i, null); - - stack.stackSize--; - if (stack.stackSize == 0) item.setDead(); - - ItemStack output = recipe.getOutput().copy(); - EntityItem outputItem = - new EntityItem(worldObj, xCoord + 0.5, yCoord + 1.5, zCoord + 0.5, output); - worldObj.spawnEntityInWorld(outputItem); - - setWater(false); - worldObj.func_147453_f(xCoord, yCoord, zCoord, worldObj.getBlock(xCoord, yCoord, zCoord)); - } - - craftingFanciness(); - didChange = true; - - break; - } - } - } - - return didChange; - } - - private IFlowerComponent getFlowerComponent(ItemStack stack) { - IFlowerComponent component = CustomBotaniaAPI.extraFlowerComponents.get(stack.getItem()); - if (component == null) { - if (stack.getItem() instanceof IFlowerComponent) { - component = (IFlowerComponent) stack.getItem(); - } - } - return component; - } - - private boolean canGoInAltar(ItemStack stack, TileAltar reference) { - IFlowerComponent component = getFlowerComponent(stack); - return component != null && component.canFit(stack, reference); - } - - public void saveLastRecipe() { - lastRecipe = new ArrayList(); - for (int i = 0; i < getSizeInventory(); i++) { - ItemStack stack = getStackInSlot(i); - if (stack == null) break; - lastRecipe.add(stack.copy()); - } - recipeKeepTicks = 400; - } - - public void trySetLastRecipe(EntityPlayer player) { - tryToSetLastRecipe(player, this, lastRecipe); - if (!isEmpty()) VanillaPacketDispatcher.dispatchTEToNearbyPlayers(worldObj, xCoord, yCoord, zCoord); - } - - public static void tryToSetLastRecipe(EntityPlayer player, IInventory inv, List lastRecipe) { - if (lastRecipe == null || lastRecipe.isEmpty() || player.worldObj.isRemote) return; - - int index = 0; - boolean didAny = false; - for (ItemStack stack : lastRecipe) { - if (stack == null) continue; - - for (int i = 0; i < player.inventory.getSizeInventory(); i++) { - ItemStack pstack = player.inventory.getStackInSlot(i); - if (pstack != null && pstack.isItemEqual(stack) && ItemStack.areItemStackTagsEqual(stack, pstack)) { - pstack.stackSize--; - if (pstack.stackSize == 0) player.inventory.setInventorySlotContents(i, null); - - ItemStack stackToPut = pstack.copy(); - stackToPut.stackSize = 1; - inv.setInventorySlotContents(index, stackToPut); - didAny = true; - index++; - break; - } - } - } - - if (didAny) { - if (inv instanceof TileAltar) - player.worldObj.playSoundAtEntity(player, "game.neutral.swim.splash", 0.1F, 1F); - if (player instanceof EntityPlayerMP) { - EntityPlayerMP mp = (EntityPlayerMP) player; - mp.inventoryContainer.detectAndSendChanges(); - } - } - } - - public void craftingFanciness() { - worldObj.playSoundEffect(xCoord, yCoord, zCoord, "botania:altarCraft", 1F, 1F); - for (int i = 0; i < 25; i++) { - float red = (float) Math.random(); - float green = (float) Math.random(); - float blue = (float) Math.random(); - Botania.proxy.sparkleFX( - worldObj, - xCoord + 0.5 + Math.random() * 0.4 - 0.2, - yCoord + 1, - zCoord + 0.5 + Math.random() * 0.4 - 0.2, - red, - green, - blue, - (float) Math.random(), - 10); - } - } - - public boolean isEmpty() { - for (int i = 0; i < getSizeInventory(); i++) if (getStackInSlot(i) != null) return false; - - return true; - } - - @Override - public void updateEntity() { - List items = worldObj.getEntitiesWithinAABB( - EntityItem.class, - AxisAlignedBB.getBoundingBox( - xCoord, yCoord + 1D / 16D * 20D, zCoord, xCoord + 1, yCoord + 1D / 16D * 21D, zCoord + 1)); - - boolean didChange = false; - - for (EntityItem item : items) didChange = collideEntityItem(item) || didChange; - - if (didChange) VanillaPacketDispatcher.dispatchTEToNearbyPlayers(worldObj, xCoord, yCoord, zCoord); - - for (int i = 0; i < getSizeInventory(); i++) { - ItemStack stackAt = getStackInSlot(i); - if (stackAt == null) break; - - if (Math.random() >= 0.97) { - Color color = new Color(getFlowerComponent(stackAt).getParticleColor(stackAt)); - float red = color.getRed() / 255F; - float green = color.getGreen() / 255F; - float blue = color.getBlue() / 255F; - if (Math.random() >= 0.75F) - worldObj.playSoundEffect( - xCoord + 0.5, yCoord + 0.5, zCoord + 0.5, "game.neutral.swim.splash", 0.1F, 10F); - Botania.proxy.sparkleFX( - worldObj, - xCoord + 0.5 + Math.random() * 0.4 - 0.2, - yCoord + 1, - zCoord + 0.5 + Math.random() * 0.4 - 0.2, - red, - green, - blue, - (float) Math.random(), - 10); - } - } - - if (hasLava()) { - isMossy = false; - worldObj.spawnParticle( - "smoke", - xCoord + 0.5 + Math.random() * 0.4 - 0.2, - yCoord + 1, - zCoord + 0.5 + Math.random() * 0.4 - 0.2, - 0, - 0.05, - 0); - if (Math.random() > 0.9) - worldObj.spawnParticle( - "lava", - xCoord + 0.5 + Math.random() * 0.4 - 0.2, - yCoord + 1, - zCoord + 0.5 + Math.random() * 0.4 - 0.2, - 0, - 0.01, - 0); - } - - if (recipeKeepTicks > 0) --recipeKeepTicks; - else lastRecipe = null; - } - - @Override - public void writeCustomNBT(NBTTagCompound cmp) { - super.writeCustomNBT(cmp); - - cmp.setBoolean(TAG_HAS_WATER, hasWater()); - cmp.setBoolean(TAG_HAS_LAVA, hasLava()); - cmp.setBoolean(TAG_IS_MOSSY, isMossy); - } - - @Override - public void readCustomNBT(NBTTagCompound cmp) { - super.readCustomNBT(cmp); - - hasWater = cmp.getBoolean(TAG_HAS_WATER); - hasLava = cmp.getBoolean(TAG_HAS_LAVA); - isMossy = cmp.getBoolean(TAG_IS_MOSSY); - } - - @Override - public String getInventoryName() { - return LibBlockNames.ALTAR; - } - - @Override - public int getSizeInventory() { - return 16; - } - - @Override - public int getInventoryStackLimit() { - return 1; - } - - @Override - public boolean isItemValidForSlot(int i, ItemStack itemstack) { - return false; - } - - @Override - public int[] getAccessibleSlotsFromSide(int var1) { - return new int[0]; - } - - @Override - public boolean canInsertItem(int i, ItemStack itemstack, int j) { - return false; - } - - @Override - public boolean canExtractItem(int i, ItemStack itemstack, int j) { - return false; - } - - @Override - public void setWater(boolean water) { - hasWater = water; - VanillaPacketDispatcher.dispatchTEToNearbyPlayers(worldObj, xCoord, yCoord, zCoord); - } - - public void setLava(boolean lava) { - hasLava = lava; - VanillaPacketDispatcher.dispatchTEToNearbyPlayers(worldObj, xCoord, yCoord, zCoord); - } - - @Override - public boolean hasWater() { - return hasWater; - } - - public boolean hasLava() { - return hasLava; - } - - public void renderHUD(Minecraft mc, ScaledResolution res) { - int xc = res.getScaledWidth() / 2; - int yc = res.getScaledHeight() / 2; - - float angle = -90; - int radius = 24; - int amt = 0; - for (int i = 0; i < getSizeInventory(); i++) { - if (getStackInSlot(i) == null) break; - amt++; - } - - if (amt > 0) { - float anglePer = 360F / amt; - - for (RecipePetals recipe : BotaniaAPI.petalRecipes) - if (recipe.matches(this)) { - GL11.glColor4f(1F, 1F, 1F, 1F); - mc.renderEngine.bindTexture(HUDHandler.manaBar); - RenderHelper.drawTexturedModalRect(xc + radius + 9, yc - 8, 0, 0, 8, 22, 15); - - ItemStack stack = recipe.getOutput(); - - net.minecraft.client.renderer.RenderHelper.enableGUIStandardItemLighting(); - RenderItem.getInstance() - .renderItemIntoGUI(mc.fontRenderer, mc.renderEngine, stack, xc + radius + 32, yc - 8); - RenderItem.getInstance() - .renderItemIntoGUI( - mc.fontRenderer, - mc.renderEngine, - new ItemStack(Items.wheat_seeds), - xc + radius + 16, - yc + 6); - net.minecraft.client.renderer.RenderHelper.disableStandardItemLighting(); - mc.fontRenderer.drawStringWithShadow("+", xc + radius + 14, yc + 10, 0xFFFFFF); - } - - net.minecraft.client.renderer.RenderHelper.enableGUIStandardItemLighting(); - for (int i = 0; i < amt; i++) { - double xPos = xc + Math.cos(angle * Math.PI / 180D) * radius - 8; - double yPos = yc + Math.sin(angle * Math.PI / 180D) * radius - 8; - GL11.glTranslated(xPos, yPos, 0); - RenderItem.getInstance().renderItemIntoGUI(mc.fontRenderer, mc.renderEngine, getStackInSlot(i), 0, 0); - GL11.glTranslated(-xPos, -yPos, 0); - - angle += anglePer; - } - net.minecraft.client.renderer.RenderHelper.disableStandardItemLighting(); - } else if (recipeKeepTicks > 0 && hasWater) { - String s = StatCollector.translateToLocal("botaniamisc.altarRefill0"); - mc.fontRenderer.drawStringWithShadow(s, xc - mc.fontRenderer.getStringWidth(s) / 2, yc + 10, 0xFFFFFF); - s = StatCollector.translateToLocal("botaniamisc.altarRefill1"); - mc.fontRenderer.drawStringWithShadow(s, xc - mc.fontRenderer.getStringWidth(s) / 2, yc + 20, 0xFFFFFF); - } - } + private static final Pattern SEED_PATTERN = Pattern.compile("(?:(?:(?:[A-Z-_.:]|^)seed)|(?:(?:[a-z-_.:]|^)Seed))(?:[sA-Z-_.:]|$)"); + + public static final String TAG_HAS_WATER = "hasWater"; + public static final String TAG_HAS_LAVA = "hasLava"; + public static final String TAG_IS_MOSSY = "isMossy"; + + public boolean hasWater = false; + public boolean hasLava = false; + + public boolean isMossy = false; + + List lastRecipe = null; + int recipeKeepTicks = 0; + + public boolean collideEntityItem(EntityItem item) { + ItemStack stack = item.getEntityItem(); + if(stack == null || item.isDead) + return false; + + if(!isMossy && getBlockMetadata() == 0) { + if(stack.getItem() == Item.getItemFromBlock(Blocks.vine) && !worldObj.isRemote) { + isMossy = true; + worldObj.func_147453_f(xCoord, yCoord, zCoord, worldObj.getBlock(xCoord, yCoord, zCoord)); + stack.stackSize--; + if(stack.stackSize == 0) + item.setDead(); + VanillaPacketDispatcher.dispatchTEToNearbyPlayers(worldObj, xCoord, yCoord, zCoord); + } + } + + if(!hasWater() && !hasLava()) { + if(stack.getItem() == Items.water_bucket && !worldObj.isRemote) { + setWater(true); + worldObj.func_147453_f(xCoord, yCoord, zCoord, worldObj.getBlock(xCoord, yCoord, zCoord)); + stack.func_150996_a(Items.bucket); // Set item + } else if(stack.getItem() == Items.lava_bucket && !worldObj.isRemote) { + setLava(true); + worldObj.func_147453_f(xCoord, yCoord, zCoord, worldObj.getBlock(xCoord, yCoord, zCoord)); + stack.func_150996_a(Items.bucket); // Set item + } else return false; + } + + if(hasLava()) { + item.setFire(100); + return true; + } + + boolean didChange = false; + + if(canGoInAltar(stack, this)) { + if(getStackInSlot(getSizeInventory() - 1) != null) + return false; + + if(!worldObj.isRemote) { + stack.stackSize--; + if(stack.stackSize == 0) + item.setDead(); + + for(int i = 0; i < getSizeInventory(); i++) + if(getStackInSlot(i) == null) { + ItemStack stackToPut = stack.copy(); + stackToPut.stackSize = 1; + setInventorySlotContents(i, stackToPut); + didChange = true; + worldObj.playSoundAtEntity(item, "game.neutral.swim.splash", 0.1F, 1F); + break; + } + } + } else if(stack.getItem() != null && SEED_PATTERN.matcher(stack.getItem().getUnlocalizedName(stack)).find()) { + for(RecipePetals recipe : BotaniaAPI.petalRecipes) { + if(recipe.matches(this)) { + saveLastRecipe(); + + if(!worldObj.isRemote) { + for(int i = 0; i < getSizeInventory(); i++) + setInventorySlotContents(i, null); + + stack.stackSize--; + if(stack.stackSize == 0) + item.setDead(); + + ItemStack output = recipe.getOutput().copy(); + EntityItem outputItem = new EntityItem(worldObj, xCoord + 0.5, yCoord + 1.5, zCoord + 0.5, output); + worldObj.spawnEntityInWorld(outputItem); + + setWater(false); + worldObj.func_147453_f(xCoord, yCoord, zCoord, worldObj.getBlock(xCoord, yCoord, zCoord)); + } + + craftingFanciness(); + didChange = true; + + break; + } + } + } + + return didChange; + } + + private IFlowerComponent getFlowerComponent(ItemStack stack) { + IFlowerComponent component = CustomBotaniaAPI.extraFlowerComponents.get(stack.getItem()); + if (component == null) { + if (stack.getItem() instanceof IFlowerComponent) { + component = (IFlowerComponent) stack.getItem(); + } + } + return component; + } + + private boolean canGoInAltar(ItemStack stack, TileAltar reference) { + IFlowerComponent component = getFlowerComponent(stack); + return component != null && component.canFit(stack, reference); + } + + public void saveLastRecipe() { + lastRecipe = new ArrayList(); + for(int i = 0; i < getSizeInventory(); i++) { + ItemStack stack = getStackInSlot(i); + if(stack == null) + break; + lastRecipe.add(stack.copy()); + } + recipeKeepTicks = 400; + } + + public void trySetLastRecipe(EntityPlayer player) { + tryToSetLastRecipe(player, this, lastRecipe); + if(!isEmpty()) + VanillaPacketDispatcher.dispatchTEToNearbyPlayers(worldObj, xCoord, yCoord, zCoord); + } + + public static void tryToSetLastRecipe(EntityPlayer player, IInventory inv, List lastRecipe) { + if(lastRecipe == null || lastRecipe.isEmpty() || player.worldObj.isRemote) + return; + + int index = 0; + boolean didAny = false; + for(ItemStack stack : lastRecipe) { + if(stack == null) + continue; + + for(int i = 0; i < player.inventory.getSizeInventory(); i++) { + ItemStack pstack = player.inventory.getStackInSlot(i); + if(pstack != null && pstack.isItemEqual(stack) && ItemStack.areItemStackTagsEqual(stack, pstack)) { + pstack.stackSize--; + if(pstack.stackSize == 0) + player.inventory.setInventorySlotContents(i, null); + + ItemStack stackToPut = pstack.copy(); + stackToPut.stackSize = 1; + inv.setInventorySlotContents(index, stackToPut); + didAny = true; + index++; + break; + } + } + } + + if(didAny) { + if(inv instanceof TileAltar) + player.worldObj.playSoundAtEntity(player, "game.neutral.swim.splash", 0.1F, 1F); + if(player instanceof EntityPlayerMP) { + EntityPlayerMP mp = (EntityPlayerMP) player; + mp.inventoryContainer.detectAndSendChanges(); + } + } + } + + public void craftingFanciness() { + worldObj.playSoundEffect(xCoord, yCoord, zCoord, "botania:altarCraft", 1F, 1F); + for(int i = 0; i < 25; i++) { + float red = (float) Math.random(); + float green = (float) Math.random(); + float blue = (float) Math.random(); + Botania.proxy.sparkleFX(worldObj, xCoord + 0.5 + Math.random() * 0.4 - 0.2, yCoord + 1, zCoord + 0.5 + Math.random() * 0.4 - 0.2, red, green, blue, (float) Math.random(), 10); + } + } + + public boolean isEmpty() { + for(int i = 0; i < getSizeInventory(); i++) + if(getStackInSlot(i) != null) + return false; + + return true; + } + + @Override + public void updateEntity() { + List items = worldObj.getEntitiesWithinAABB(EntityItem.class, AxisAlignedBB.getBoundingBox(xCoord, yCoord + 1D / 16D * 20D, zCoord, xCoord + 1, yCoord + 1D / 16D * 21D, zCoord + 1)); + + boolean didChange = false; + + for(EntityItem item : items) + didChange = collideEntityItem(item) || didChange; + + if(didChange) + VanillaPacketDispatcher.dispatchTEToNearbyPlayers(worldObj, xCoord, yCoord, zCoord); + + for(int i = 0; i < getSizeInventory(); i++) { + ItemStack stackAt = getStackInSlot(i); + if(stackAt == null) + break; + + if(Math.random() >= 0.97) { + Color color = new Color(getFlowerComponent(stackAt).getParticleColor(stackAt)); + float red = color.getRed() / 255F; + float green = color.getGreen() / 255F; + float blue = color.getBlue() / 255F; + if(Math.random() >= 0.75F) + worldObj.playSoundEffect(xCoord + 0.5, yCoord + 0.5, zCoord + 0.5, "game.neutral.swim.splash", 0.1F, 10F); + Botania.proxy.sparkleFX(worldObj, xCoord + 0.5 + Math.random() * 0.4 - 0.2, yCoord + 1, zCoord + 0.5 + Math.random() * 0.4 - 0.2, red, green, blue, (float) Math.random(), 10); + } + } + + if(hasLava()) { + isMossy = false; + worldObj.spawnParticle("smoke", xCoord + 0.5 + Math.random() * 0.4 - 0.2, yCoord + 1, zCoord + 0.5 + Math.random() * 0.4 - 0.2, 0, 0.05, 0); + if(Math.random() > 0.9) + worldObj.spawnParticle("lava", xCoord + 0.5 + Math.random() * 0.4 - 0.2, yCoord + 1, zCoord + 0.5 + Math.random() * 0.4 - 0.2, 0, 0.01, 0); + } + + if(recipeKeepTicks > 0) + --recipeKeepTicks; + else lastRecipe = null; + } + + @Override + public void writeCustomNBT(NBTTagCompound cmp) { + super.writeCustomNBT(cmp); + + cmp.setBoolean(TAG_HAS_WATER, hasWater()); + cmp.setBoolean(TAG_HAS_LAVA, hasLava()); + cmp.setBoolean(TAG_IS_MOSSY, isMossy); + } + + @Override + public void readCustomNBT(NBTTagCompound cmp) { + super.readCustomNBT(cmp); + + hasWater = cmp.getBoolean(TAG_HAS_WATER); + hasLava = cmp.getBoolean(TAG_HAS_LAVA); + isMossy = cmp.getBoolean(TAG_IS_MOSSY); + } + + @Override + public String getInventoryName() { + return LibBlockNames.ALTAR; + } + + @Override + public int getSizeInventory() { + return 16; + } + + @Override + public int getInventoryStackLimit() { + return 1; + } + + @Override + public boolean isItemValidForSlot(int i, ItemStack itemstack) { + return false; + } + + @Override + public int[] getAccessibleSlotsFromSide(int var1) { + return new int[0]; + } + + @Override + public boolean canInsertItem(int i, ItemStack itemstack, int j) { + return false; + } + + @Override + public boolean canExtractItem(int i, ItemStack itemstack, int j) { + return false; + } + + @Override + public void setWater(boolean water) { + hasWater = water; + VanillaPacketDispatcher.dispatchTEToNearbyPlayers(worldObj, xCoord, yCoord, zCoord); + } + + public void setLava(boolean lava) { + hasLava = lava; + VanillaPacketDispatcher.dispatchTEToNearbyPlayers(worldObj, xCoord, yCoord, zCoord); + } + + @Override + public boolean hasWater() { + return hasWater; + } + + public boolean hasLava() { + return hasLava; + } + + public void renderHUD(Minecraft mc, ScaledResolution res) { + int xc = res.getScaledWidth() / 2; + int yc = res.getScaledHeight() / 2; + + float angle = -90; + int radius = 24; + int amt = 0; + for(int i = 0; i < getSizeInventory(); i++) { + if(getStackInSlot(i) == null) + break; + amt++; + } + + if(amt > 0) { + float anglePer = 360F / amt; + + for(RecipePetals recipe : BotaniaAPI.petalRecipes) + if(recipe.matches(this)) { + GL11.glColor4f(1F, 1F, 1F, 1F); + mc.renderEngine.bindTexture(HUDHandler.manaBar); + RenderHelper.drawTexturedModalRect(xc + radius + 9, yc - 8, 0, 0, 8, 22, 15); + + ItemStack stack = recipe.getOutput(); + + net.minecraft.client.renderer.RenderHelper.enableGUIStandardItemLighting(); + RenderItem.getInstance().renderItemIntoGUI(mc.fontRenderer, mc.renderEngine, stack, xc + radius + 32, yc - 8); + RenderItem.getInstance().renderItemIntoGUI(mc.fontRenderer, mc.renderEngine, new ItemStack(Items.wheat_seeds), xc + radius + 16, yc + 6); + net.minecraft.client.renderer.RenderHelper.disableStandardItemLighting(); + mc.fontRenderer.drawStringWithShadow("+", xc + radius + 14, yc + 10, 0xFFFFFF); + } + + net.minecraft.client.renderer.RenderHelper.enableGUIStandardItemLighting(); + for(int i = 0; i < amt; i++) { + double xPos = xc + Math.cos(angle * Math.PI / 180D) * radius - 8; + double yPos = yc + Math.sin(angle * Math.PI / 180D) * radius - 8; + GL11.glTranslated(xPos, yPos, 0); + RenderItem.getInstance().renderItemIntoGUI(mc.fontRenderer, mc.renderEngine, getStackInSlot(i), 0, 0); + GL11.glTranslated(-xPos, -yPos, 0); + + angle += anglePer; + } + net.minecraft.client.renderer.RenderHelper.disableStandardItemLighting(); + } else if(recipeKeepTicks > 0 && hasWater) { + String s = StatCollector.translateToLocal("botaniamisc.altarRefill0"); + mc.fontRenderer.drawStringWithShadow(s, xc - mc.fontRenderer.getStringWidth(s) / 2, yc + 10, 0xFFFFFF); + s = StatCollector.translateToLocal("botaniamisc.altarRefill1"); + mc.fontRenderer.drawStringWithShadow(s, xc - mc.fontRenderer.getStringWidth(s) / 2, yc + 20, 0xFFFFFF); + } + } + } diff --git a/src/main/java/vazkii/botania/common/block/tile/TileAvatar.java b/src/main/java/vazkii/botania/common/block/tile/TileAvatar.java index 3898d900ef..1e0e62b28c 100644 --- a/src/main/java/vazkii/botania/common/block/tile/TileAvatar.java +++ b/src/main/java/vazkii/botania/common/block/tile/TileAvatar.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Oct 24, 2015, 3:17:44 PM (GMT)] */ package vazkii.botania.common.block.tile; @@ -20,117 +20,118 @@ public class TileAvatar extends TileSimpleInventory implements IAvatarTile, ISidedInventory { - private static final int MAX_MANA = 6400; - - private static final String TAG_ENABLED = "enabled"; - private static final String TAG_TICKS_ELAPSED = "ticksElapsed"; - private static final String TAG_MANA = "ticksElapsed"; - - boolean enabled; - int ticksElapsed; - int mana; - - @Override - public void updateEntity() { - super.updateEntity(); - - enabled = true; - for (ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS) { - int redstoneSide = worldObj.getIndirectPowerLevelTo( - xCoord + dir.offsetX, yCoord + dir.offsetY, zCoord + dir.offsetZ, dir.ordinal()); - if (redstoneSide > 0) { - enabled = false; - break; - } - } - - ItemStack stack = getStackInSlot(0); - if (stack != null && stack.getItem() instanceof IAvatarWieldable) { - IAvatarWieldable wieldable = (IAvatarWieldable) stack.getItem(); - wieldable.onAvatarUpdate(this, stack); - } - - if (enabled) ticksElapsed++; - } - - @Override - public void writeCustomNBT(NBTTagCompound par1nbtTagCompound) { - super.writeCustomNBT(par1nbtTagCompound); - par1nbtTagCompound.setBoolean(TAG_ENABLED, enabled); - par1nbtTagCompound.setInteger(TAG_TICKS_ELAPSED, ticksElapsed); - par1nbtTagCompound.setInteger(TAG_MANA, mana); - } - - @Override - public void readCustomNBT(NBTTagCompound par1nbtTagCompound) { - super.readCustomNBT(par1nbtTagCompound); - enabled = par1nbtTagCompound.getBoolean(TAG_ENABLED); - ticksElapsed = par1nbtTagCompound.getInteger(TAG_TICKS_ELAPSED); - mana = par1nbtTagCompound.getInteger(TAG_MANA); - } - - @Override - public int getSizeInventory() { - return 1; - } - - @Override - public int getInventoryStackLimit() { - return 1; - } - - @Override - public boolean isItemValidForSlot(int i, ItemStack itemstack) { - return itemstack != null && itemstack.getItem() instanceof IAvatarTile; - } - - @Override - public int[] getAccessibleSlotsFromSide(int p_94128_1_) { - return new int[0]; - } - - @Override - public boolean canInsertItem(int p_102007_1_, ItemStack p_102007_2_, int p_102007_3_) { - return false; - } - - @Override - public boolean canExtractItem(int p_102008_1_, ItemStack p_102008_2_, int p_102008_3_) { - return false; - } - - @Override - public String getInventoryName() { - return LibBlockNames.AVATAR; - } - - @Override - public boolean isFull() { - return mana >= MAX_MANA; - } - - @Override - public void recieveMana(int mana) { - this.mana = Math.min(MAX_MANA, this.mana + mana); - } - - @Override - public boolean canRecieveManaFromBursts() { - return getStackInSlot(0) != null; - } - - @Override - public int getCurrentMana() { - return mana; - } - - @Override - public int getElapsedFunctionalTicks() { - return ticksElapsed; - } - - @Override - public boolean isEnabled() { - return enabled; - } + private static final int MAX_MANA = 6400; + + private static final String TAG_ENABLED = "enabled"; + private static final String TAG_TICKS_ELAPSED = "ticksElapsed"; + private static final String TAG_MANA = "ticksElapsed"; + + boolean enabled; + int ticksElapsed; + int mana; + + @Override + public void updateEntity() { + super.updateEntity(); + + enabled = true; + for(ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS) { + int redstoneSide = worldObj.getIndirectPowerLevelTo(xCoord + dir.offsetX, yCoord + dir.offsetY, zCoord + dir.offsetZ, dir.ordinal()); + if(redstoneSide > 0) { + enabled = false; + break; + } + } + + ItemStack stack = getStackInSlot(0); + if(stack != null && stack.getItem() instanceof IAvatarWieldable) { + IAvatarWieldable wieldable = (IAvatarWieldable) stack.getItem(); + wieldable.onAvatarUpdate(this, stack); + } + + if(enabled) + ticksElapsed++; + } + + @Override + public void writeCustomNBT(NBTTagCompound par1nbtTagCompound) { + super.writeCustomNBT(par1nbtTagCompound); + par1nbtTagCompound.setBoolean(TAG_ENABLED, enabled); + par1nbtTagCompound.setInteger(TAG_TICKS_ELAPSED, ticksElapsed); + par1nbtTagCompound.setInteger(TAG_MANA, mana); + } + + @Override + public void readCustomNBT(NBTTagCompound par1nbtTagCompound) { + super.readCustomNBT(par1nbtTagCompound); + enabled = par1nbtTagCompound.getBoolean(TAG_ENABLED); + ticksElapsed = par1nbtTagCompound.getInteger(TAG_TICKS_ELAPSED); + mana = par1nbtTagCompound.getInteger(TAG_MANA); + } + + @Override + public int getSizeInventory() { + return 1; + } + + @Override + public int getInventoryStackLimit() { + return 1; + } + + @Override + public boolean isItemValidForSlot(int i, ItemStack itemstack) { + return itemstack != null && itemstack.getItem() instanceof IAvatarTile; + } + + @Override + public int[] getAccessibleSlotsFromSide(int p_94128_1_) { + return new int[0]; + } + + @Override + public boolean canInsertItem(int p_102007_1_, ItemStack p_102007_2_, int p_102007_3_) { + return false; + } + + @Override + public boolean canExtractItem(int p_102008_1_, ItemStack p_102008_2_, int p_102008_3_) { + return false; + } + + @Override + public String getInventoryName() { + return LibBlockNames.AVATAR; + } + + @Override + public boolean isFull() { + return mana >= MAX_MANA; + } + + @Override + public void recieveMana(int mana) { + this.mana = Math.min(MAX_MANA, this.mana + mana); + } + + @Override + public boolean canRecieveManaFromBursts() { + return getStackInSlot(0) != null; + } + + @Override + public int getCurrentMana() { + return mana; + } + + @Override + public int getElapsedFunctionalTicks() { + return ticksElapsed; + } + + @Override + public boolean isEnabled() { + return enabled; + } + } diff --git a/src/main/java/vazkii/botania/common/block/tile/TileBifrost.java b/src/main/java/vazkii/botania/common/block/tile/TileBifrost.java index 272289b42e..acefc2ffd3 100644 --- a/src/main/java/vazkii/botania/common/block/tile/TileBifrost.java +++ b/src/main/java/vazkii/botania/common/block/tile/TileBifrost.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jun 20, 2014, 8:35:27 PM (GMT)] */ package vazkii.botania.common.block.tile; @@ -15,38 +15,30 @@ public class TileBifrost extends TileMod { - private static final String TAG_TICKS = "ticks"; - - public int ticks = 0; - - @Override - public void updateEntity() { - if (!worldObj.isRemote) { - if (ticks <= 0) { - worldObj.setBlockToAir(xCoord, yCoord, zCoord); - } else ticks--; - } else if (Math.random() < 0.1) - Botania.proxy.sparkleFX( - worldObj, - xCoord + Math.random(), - yCoord + Math.random(), - zCoord + Math.random(), - (float) Math.random(), - (float) Math.random(), - (float) Math.random(), - 0.45F + 0.2F * (float) Math.random(), - 6); - } - - @Override - public void writeToNBT(NBTTagCompound par1nbtTagCompound) { - super.writeToNBT(par1nbtTagCompound); - par1nbtTagCompound.setInteger(TAG_TICKS, ticks); - } - - @Override - public void readFromNBT(NBTTagCompound par1nbtTagCompound) { - super.readFromNBT(par1nbtTagCompound); - ticks = par1nbtTagCompound.getInteger(TAG_TICKS); - } + private static final String TAG_TICKS = "ticks"; + + public int ticks = 0; + + @Override + public void updateEntity() { + if(!worldObj.isRemote) { + if(ticks <= 0) { + worldObj.setBlockToAir(xCoord, yCoord, zCoord); + } else ticks--; + } else if(Math.random() < 0.1) + Botania.proxy.sparkleFX(worldObj, xCoord + Math.random(), yCoord + Math.random(), zCoord + Math.random(), (float) Math.random(), (float) Math.random(), (float) Math.random(), 0.45F + 0.2F * (float) Math.random(), 6); + } + + @Override + public void writeToNBT(NBTTagCompound par1nbtTagCompound) { + super.writeToNBT(par1nbtTagCompound); + par1nbtTagCompound.setInteger(TAG_TICKS, ticks); + } + + @Override + public void readFromNBT(NBTTagCompound par1nbtTagCompound) { + super.readFromNBT(par1nbtTagCompound); + ticks = par1nbtTagCompound.getInteger(TAG_TICKS); + } + } diff --git a/src/main/java/vazkii/botania/common/block/tile/TileBrewery.java b/src/main/java/vazkii/botania/common/block/tile/TileBrewery.java index c4436c7651..2a4961a9cf 100644 --- a/src/main/java/vazkii/botania/common/block/tile/TileBrewery.java +++ b/src/main/java/vazkii/botania/common/block/tile/TileBrewery.java @@ -2,16 +2,17 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Oct 31, 2014, 4:42:36 PM (GMT)] */ package vazkii.botania.common.block.tile; import java.awt.Color; import java.util.List; + import net.minecraft.client.Minecraft; import net.minecraft.client.gui.ScaledResolution; import net.minecraft.entity.item.EntityItem; @@ -33,270 +34,229 @@ // This is mostly copypasta from TileRuneAltar public class TileBrewery extends TileSimpleInventory implements ISidedInventory, IManaReceiver { - private static final String TAG_MANA = "mana"; - - public RecipeBrew recipe; - int mana = 0; - int manaLastTick = 0; - public int signal = 0; - - public boolean addItem(EntityPlayer player, ItemStack stack) { - if (recipe != null - || stack == null - || stack.getItem() instanceof IBrewItem - && ((IBrewItem) stack.getItem()).getBrew(stack) != null - && ((IBrewItem) stack.getItem()).getBrew(stack) != BotaniaAPI.fallbackBrew - || getStackInSlot(0) == null != stack.getItem() instanceof IBrewContainer) return false; - - boolean did = false; - - for (int i = 0; i < getSizeInventory(); i++) - if (getStackInSlot(i) == null) { - did = true; - ItemStack stackToAdd = stack.copy(); - stackToAdd.stackSize = 1; - setInventorySlotContents(i, stackToAdd); - - if (player == null || !player.capabilities.isCreativeMode) { - stack.stackSize--; - if (stack.stackSize == 0 && player != null) - player.inventory.setInventorySlotContents(player.inventory.currentItem, null); - } - - break; - } - - if (did) { - VanillaPacketDispatcher.dispatchTEToNearbyPlayers(worldObj, xCoord, yCoord, zCoord); - for (RecipeBrew recipe : BotaniaAPI.brewRecipes) - if (recipe.matches(this) && recipe.getOutput(getStackInSlot(0)) != null) { - this.recipe = recipe; - worldObj.setBlockMetadataWithNotify(xCoord, yCoord, zCoord, 1, 1 | 2); - } - } - - return true; - } - - @Override - public void updateEntity() { - super.updateEntity(); - - if (mana > 0 && recipe == null) { - for (RecipeBrew recipe : BotaniaAPI.brewRecipes) - if (recipe.matches(this)) { - this.recipe = recipe; - worldObj.setBlockMetadataWithNotify(xCoord, yCoord, zCoord, 1, 1 | 2); - } - - if (recipe == null) mana = 0; - } - - // Update every tick. - recieveMana(0); - - if (!worldObj.isRemote && recipe == null) { - List items = worldObj.getEntitiesWithinAABB( - EntityItem.class, - AxisAlignedBB.getBoundingBox(xCoord, yCoord, zCoord, xCoord + 1, yCoord + 1, zCoord + 1)); - for (EntityItem item : items) - if (!item.isDead && item.getEntityItem() != null) { - ItemStack stack = item.getEntityItem(); - if (addItem(null, stack) && stack.stackSize == 0) item.setDead(); - } - } - - if (recipe != null) { - if (!recipe.matches(this)) { - recipe = null; - worldObj.setBlockMetadataWithNotify(xCoord, yCoord, zCoord, 0, 1 | 2); - } - - if (recipe != null) { - if (mana != manaLastTick) { - Color color = new Color(recipe.getBrew().getColor(getStackInSlot(0))); - float r = color.getRed() / 255F; - float g = color.getGreen() / 255F; - float b = color.getBlue() / 255F; - for (int i = 0; i < 5; i++) { - Botania.proxy.wispFX( - worldObj, - xCoord + 0.7 - Math.random() * 0.4, - yCoord + 0.9 - Math.random() * 0.2, - zCoord + 0.7 - Math.random() * 0.4, - r, - g, - b, - 0.1F + (float) Math.random() * 0.05F, - 0.03F - (float) Math.random() * 0.06F, - 0.03F + (float) Math.random() * 0.015F, - 0.03F - (float) Math.random() * 0.06F); - for (int j = 0; j < 2; j++) - Botania.proxy.wispFX( - worldObj, - xCoord + 0.7 - Math.random() * 0.4, - yCoord + 0.9 - Math.random() * 0.2, - zCoord + 0.7 - Math.random() * 0.4, - 0.2F, - 0.2F, - 0.2F, - 0.1F + (float) Math.random() * 0.2F, - 0.03F - (float) Math.random() * 0.06F, - 0.03F + (float) Math.random() * 0.015F, - 0.03F - (float) Math.random() * 0.06F); - } - } - - if (mana >= getManaCost() && !worldObj.isRemote) { - int mana = getManaCost(); - recieveMana(-mana); - if (!worldObj.isRemote) { - ItemStack output = recipe.getOutput(getStackInSlot(0)); - EntityItem outputItem = - new EntityItem(worldObj, xCoord + 0.5, yCoord + 1.5, zCoord + 0.5, output); - worldObj.spawnEntityInWorld(outputItem); - } - - for (int i = 0; i < getSizeInventory(); i++) setInventorySlotContents(i, null); - - craftingFanciness(); - } - } - } - - int newSignal = 0; - if (recipe != null) newSignal++; - - if (newSignal != signal) { - signal = newSignal; - worldObj.func_147453_f(xCoord, yCoord, zCoord, worldObj.getBlock(xCoord, yCoord, zCoord)); - } - - manaLastTick = mana; - } - - public int getManaCost() { - ItemStack stack = getStackInSlot(0); - if (recipe == null || stack == null || !(stack.getItem() instanceof IBrewContainer)) return 0; - IBrewContainer container = (IBrewContainer) stack.getItem(); - return container.getManaCost(recipe.getBrew(), stack); - } - - public void craftingFanciness() { - worldObj.playSoundEffect( - xCoord, yCoord, zCoord, "botania:potionCreate", 1F, 1.5F + (float) Math.random() * 0.25F); - for (int i = 0; i < 25; i++) { - Color color = new Color(recipe.getBrew().getColor(getStackInSlot(0))); - float r = color.getRed() / 255F; - float g = color.getGreen() / 255F; - float b = color.getBlue() / 255F; - Botania.proxy.sparkleFX( - worldObj, - xCoord + 0.5 + Math.random() * 0.4 - 0.2, - yCoord + 1, - zCoord + 0.5 + Math.random() * 0.4 - 0.2, - r, - g, - b, - (float) Math.random() * 2F + 0.5F, - 10); - for (int j = 0; j < 2; j++) - Botania.proxy.wispFX( - worldObj, - xCoord + 0.7 - Math.random() * 0.4, - yCoord + 0.9 - Math.random() * 0.2, - zCoord + 0.7 - Math.random() * 0.4, - 0.2F, - 0.2F, - 0.2F, - 0.1F + (float) Math.random() * 0.2F, - 0.05F - (float) Math.random() * 0.1F, - 0.05F + (float) Math.random() * 0.03F, - 0.05F - (float) Math.random() * 0.1F); - } - } - - @Override - public void writeCustomNBT(NBTTagCompound par1nbtTagCompound) { - super.writeCustomNBT(par1nbtTagCompound); - - par1nbtTagCompound.setInteger(TAG_MANA, mana); - } - - @Override - public void readCustomNBT(NBTTagCompound par1nbtTagCompound) { - super.readCustomNBT(par1nbtTagCompound); - - mana = par1nbtTagCompound.getInteger(TAG_MANA); - } - - @Override - public int getSizeInventory() { - return 7; - } - - @Override - public AxisAlignedBB getRenderBoundingBox() { - return INFINITE_EXTENT_AABB; - } - - @Override - public String getInventoryName() { - return LibBlockNames.RUNE_ALTAR; - } - - @Override - public int getInventoryStackLimit() { - return 1; - } - - @Override - public int[] getAccessibleSlotsFromSide(int var1) { - int accessibleSlot = -1; - for (int i = 0; i < getSizeInventory(); i++) if (getStackInSlot(i) != null) accessibleSlot = i; - - return accessibleSlot == -1 ? new int[0] : new int[] {accessibleSlot}; - } - - @Override - public boolean canInsertItem(int i, ItemStack itemstack, int j) { - return true; - } - - @Override - public boolean canExtractItem(int i, ItemStack itemstack, int j) { - return mana == 0; - } - - @Override - public int getCurrentMana() { - return mana; - } - - @Override - public boolean isFull() { - return mana >= getManaCost(); - } - - @Override - public void recieveMana(int mana) { - this.mana = Math.min(this.mana + mana, getManaCost()); - } - - @Override - public boolean canRecieveManaFromBursts() { - return !isFull(); - } - - public void renderHUD(Minecraft mc, ScaledResolution res) { - int manaToGet = getManaCost(); - if (manaToGet > 0) { - int x = res.getScaledWidth() / 2 + 20; - int y = res.getScaledHeight() / 2 - 8; - - if (recipe == null) return; - - RenderHelper.renderProgressPie(x, y, (float) mana / (float) manaToGet, recipe.getOutput(getStackInSlot(0))); - } - } + private static final String TAG_MANA = "mana"; + + public RecipeBrew recipe; + int mana = 0; + int manaLastTick = 0; + public int signal = 0; + + public boolean addItem(EntityPlayer player, ItemStack stack) { + if(recipe != null || stack == null || stack.getItem() instanceof IBrewItem && ((IBrewItem) stack.getItem()).getBrew(stack) != null && ((IBrewItem) stack.getItem()).getBrew(stack) != BotaniaAPI.fallbackBrew || getStackInSlot(0) == null != stack.getItem() instanceof IBrewContainer) + return false; + + boolean did = false; + + for(int i = 0; i < getSizeInventory(); i++) + if(getStackInSlot(i) == null) { + did = true; + ItemStack stackToAdd = stack.copy(); + stackToAdd.stackSize = 1; + setInventorySlotContents(i, stackToAdd); + + if(player == null || !player.capabilities.isCreativeMode) { + stack.stackSize--; + if(stack.stackSize == 0 && player != null) + player.inventory.setInventorySlotContents(player.inventory.currentItem, null); + } + + break; + } + + if(did) { + VanillaPacketDispatcher.dispatchTEToNearbyPlayers(worldObj, xCoord, yCoord, zCoord); + for(RecipeBrew recipe : BotaniaAPI.brewRecipes) + if(recipe.matches(this) && recipe.getOutput(getStackInSlot(0)) != null) { + this.recipe = recipe; + worldObj.setBlockMetadataWithNotify(xCoord, yCoord, zCoord, 1, 1 | 2); + } + } + + return true; + } + + @Override + public void updateEntity() { + super.updateEntity(); + + if(mana > 0 && recipe == null) { + for(RecipeBrew recipe : BotaniaAPI.brewRecipes) + if(recipe.matches(this)) { + this.recipe = recipe; + worldObj.setBlockMetadataWithNotify(xCoord, yCoord, zCoord, 1, 1 | 2); + } + + if(recipe == null) + mana = 0; + } + + // Update every tick. + recieveMana(0); + + if(!worldObj.isRemote && recipe == null) { + List items = worldObj.getEntitiesWithinAABB(EntityItem.class, AxisAlignedBB.getBoundingBox(xCoord, yCoord, zCoord, xCoord + 1, yCoord + 1, zCoord + 1)); + for(EntityItem item : items) + if(!item.isDead && item.getEntityItem() != null) { + ItemStack stack = item.getEntityItem(); + if(addItem(null, stack) && stack.stackSize == 0) + item.setDead(); + } + } + + if(recipe != null) { + if(!recipe.matches(this)) { + recipe = null; + worldObj.setBlockMetadataWithNotify(xCoord, yCoord, zCoord, 0, 1 | 2); + } + + if(recipe != null) { + if(mana != manaLastTick) { + Color color = new Color(recipe.getBrew().getColor(getStackInSlot(0))); + float r = color.getRed() / 255F; + float g = color.getGreen() / 255F; + float b = color.getBlue() / 255F; + for(int i = 0; i < 5; i++) { + Botania.proxy.wispFX(worldObj, xCoord + 0.7 - Math.random() * 0.4, yCoord + 0.9 - Math.random() * 0.2, zCoord + 0.7 - Math.random() * 0.4, r, g, b, 0.1F + (float) Math.random() * 0.05F, 0.03F - (float) Math.random() * 0.06F, 0.03F + (float) Math.random() * 0.015F, 0.03F - (float) Math.random() * 0.06F); + for(int j = 0; j < 2; j++) + Botania.proxy.wispFX(worldObj, xCoord + 0.7 - Math.random() * 0.4, yCoord + 0.9 - Math.random() * 0.2, zCoord + 0.7 - Math.random() * 0.4, 0.2F, 0.2F, 0.2F, 0.1F + (float) Math.random() * 0.2F, 0.03F - (float) Math.random() * 0.06F, 0.03F + (float) Math.random() * 0.015F, 0.03F - (float) Math.random() * 0.06F); + } + } + + if(mana >= getManaCost() && !worldObj.isRemote) { + int mana = getManaCost(); + recieveMana(-mana); + if(!worldObj.isRemote) { + ItemStack output = recipe.getOutput(getStackInSlot(0)); + EntityItem outputItem = new EntityItem(worldObj, xCoord + 0.5, yCoord + 1.5, zCoord + 0.5, output); + worldObj.spawnEntityInWorld(outputItem); + } + + for(int i = 0; i < getSizeInventory(); i++) + setInventorySlotContents(i, null); + + craftingFanciness(); + } + } + } + + int newSignal = 0; + if(recipe != null) + newSignal++; + + if(newSignal != signal) { + signal = newSignal; + worldObj.func_147453_f(xCoord, yCoord, zCoord, worldObj.getBlock(xCoord, yCoord, zCoord)); + } + + manaLastTick = mana; + } + + public int getManaCost() { + ItemStack stack = getStackInSlot(0); + if(recipe == null || stack == null || !(stack.getItem() instanceof IBrewContainer)) + return 0; + IBrewContainer container = (IBrewContainer) stack.getItem(); + return container.getManaCost(recipe.getBrew(), stack); + } + + public void craftingFanciness() { + worldObj.playSoundEffect(xCoord, yCoord, zCoord, "botania:potionCreate", 1F, 1.5F + (float) Math.random() * 0.25F); + for(int i = 0; i < 25; i++) { + Color color = new Color(recipe.getBrew().getColor(getStackInSlot(0))); + float r = color.getRed() / 255F; + float g = color.getGreen() / 255F; + float b = color.getBlue() / 255F; + Botania.proxy.sparkleFX(worldObj, xCoord + 0.5 + Math.random() * 0.4 - 0.2, yCoord + 1, zCoord + 0.5 + Math.random() * 0.4 - 0.2, r, g, b, (float) Math.random() * 2F + 0.5F, 10); + for(int j = 0; j < 2; j++) + Botania.proxy.wispFX(worldObj, xCoord + 0.7 - Math.random() * 0.4, yCoord + 0.9 - Math.random() * 0.2, zCoord + 0.7 - Math.random() * 0.4, 0.2F, 0.2F, 0.2F, 0.1F + (float) Math.random() * 0.2F, 0.05F - (float) Math.random() * 0.1F, 0.05F + (float) Math.random() * 0.03F, 0.05F - (float) Math.random() * 0.1F); + } + } + + @Override + public void writeCustomNBT(NBTTagCompound par1nbtTagCompound) { + super.writeCustomNBT(par1nbtTagCompound); + + par1nbtTagCompound.setInteger(TAG_MANA, mana); + } + + @Override + public void readCustomNBT(NBTTagCompound par1nbtTagCompound) { + super.readCustomNBT(par1nbtTagCompound); + + mana = par1nbtTagCompound.getInteger(TAG_MANA); + } + + @Override + public int getSizeInventory() { + return 7; + } + + @Override + public AxisAlignedBB getRenderBoundingBox() { + return INFINITE_EXTENT_AABB; + } + + @Override + public String getInventoryName() { + return LibBlockNames.RUNE_ALTAR; + } + + @Override + public int getInventoryStackLimit() { + return 1; + } + + @Override + public int[] getAccessibleSlotsFromSide(int var1) { + int accessibleSlot = -1; + for(int i = 0; i < getSizeInventory(); i++) + if(getStackInSlot(i) != null) + accessibleSlot = i; + + return accessibleSlot == -1 ? new int[0] : new int[] { accessibleSlot }; + } + + @Override + public boolean canInsertItem(int i, ItemStack itemstack, int j) { + return true; + } + + @Override + public boolean canExtractItem(int i, ItemStack itemstack, int j) { + return mana == 0; + } + + @Override + public int getCurrentMana() { + return mana; + } + + @Override + public boolean isFull() { + return mana >= getManaCost(); + } + + @Override + public void recieveMana(int mana) { + this.mana = Math.min(this.mana + mana, getManaCost()); + } + + @Override + public boolean canRecieveManaFromBursts() { + return !isFull(); + } + + public void renderHUD(Minecraft mc, ScaledResolution res) { + int manaToGet = getManaCost(); + if(manaToGet > 0) { + int x = res.getScaledWidth() / 2 + 20; + int y = res.getScaledHeight() / 2 - 8; + + if(recipe == null) + return; + + RenderHelper.renderProgressPie(x, y, (float) mana / (float) manaToGet, recipe.getOutput(getStackInSlot(0))); + } + } + } diff --git a/src/main/java/vazkii/botania/common/block/tile/TileCacophonium.java b/src/main/java/vazkii/botania/common/block/tile/TileCacophonium.java index b3c5f6cad3..a1dc474ebf 100644 --- a/src/main/java/vazkii/botania/common/block/tile/TileCacophonium.java +++ b/src/main/java/vazkii/botania/common/block/tile/TileCacophonium.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Aug 23, 2015, 7:25:38 PM (GMT)] */ package vazkii.botania.common.block.tile; @@ -16,28 +16,30 @@ public class TileCacophonium extends TileMod { - private static final String TAG_STACK = "stack"; + private static final String TAG_STACK = "stack"; - public ItemStack stack; + public ItemStack stack; - public void annoyDirewolf() { - ItemCacophonium.playSound(worldObj, stack, xCoord, yCoord, zCoord, 1F); - } + public void annoyDirewolf() { + ItemCacophonium.playSound(worldObj, stack, xCoord, yCoord, zCoord, 1F); + } - @Override - public void writeCustomNBT(NBTTagCompound cmp) { - super.writeCustomNBT(cmp); + @Override + public void writeCustomNBT(NBTTagCompound cmp) { + super.writeCustomNBT(cmp); - NBTTagCompound cmp1 = new NBTTagCompound(); - if (stack != null) stack.writeToNBT(cmp1); - cmp.setTag(TAG_STACK, cmp1); - } + NBTTagCompound cmp1 = new NBTTagCompound(); + if(stack != null) + stack.writeToNBT(cmp1); + cmp.setTag(TAG_STACK, cmp1); + } - @Override - public void readCustomNBT(NBTTagCompound cmp) { - super.readCustomNBT(cmp); + @Override + public void readCustomNBT(NBTTagCompound cmp) { + super.readCustomNBT(cmp); + + NBTTagCompound cmp1 = cmp.getCompoundTag(TAG_STACK); + stack = ItemStack.loadItemStackFromNBT(cmp1); + } - NBTTagCompound cmp1 = cmp.getCompoundTag(TAG_STACK); - stack = ItemStack.loadItemStackFromNBT(cmp1); - } } diff --git a/src/main/java/vazkii/botania/common/block/tile/TileCamo.java b/src/main/java/vazkii/botania/common/block/tile/TileCamo.java index 257cacd11f..e96e0e3751 100644 --- a/src/main/java/vazkii/botania/common/block/tile/TileCamo.java +++ b/src/main/java/vazkii/botania/common/block/tile/TileCamo.java @@ -2,14 +2,15 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jun 7, 2014, 2:21:28 PM (GMT)] */ package vazkii.botania.common.block.tile; + import net.minecraft.block.Block; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.network.NetworkManager; @@ -17,34 +18,34 @@ public class TileCamo extends TileMod { - private static final String TAG_CAMO = "camo"; - private static final String TAG_CAMO_META = "camoMeta"; - - public Block camo; - public int camoMeta; - - @Override - public boolean canUpdate() { - return false; - } - - @Override - public void writeCustomNBT(NBTTagCompound cmp) { - if (camo != null) { - cmp.setString(TAG_CAMO, Block.blockRegistry.getNameForObject(camo)); - cmp.setInteger(TAG_CAMO_META, camoMeta); - } - } - - @Override - public void readCustomNBT(NBTTagCompound cmp) { - camo = Block.getBlockFromName(cmp.getString(TAG_CAMO)); - camoMeta = cmp.getInteger(TAG_CAMO_META); - } - - @Override - public void onDataPacket(NetworkManager manager, S35PacketUpdateTileEntity packet) { - super.onDataPacket(manager, packet); - worldObj.markBlockRangeForRenderUpdate(xCoord, yCoord, zCoord, xCoord, yCoord, zCoord); - } + private static final String TAG_CAMO = "camo"; + private static final String TAG_CAMO_META = "camoMeta"; + + public Block camo; + public int camoMeta; + + @Override + public boolean canUpdate() { + return false; + } + + @Override + public void writeCustomNBT(NBTTagCompound cmp) { + if(camo != null) { + cmp.setString(TAG_CAMO, Block.blockRegistry.getNameForObject(camo)); + cmp.setInteger(TAG_CAMO_META, camoMeta); + } + } + + @Override + public void readCustomNBT(NBTTagCompound cmp) { + camo = Block.getBlockFromName(cmp.getString(TAG_CAMO)); + camoMeta = cmp.getInteger(TAG_CAMO_META); + } + + @Override + public void onDataPacket(NetworkManager manager, S35PacketUpdateTileEntity packet) { + super.onDataPacket(manager, packet); + worldObj.markBlockRangeForRenderUpdate(xCoord,yCoord,zCoord,xCoord,yCoord,zCoord); + } } diff --git a/src/main/java/vazkii/botania/common/block/tile/TileCell.java b/src/main/java/vazkii/botania/common/block/tile/TileCell.java index 856f53bba6..ed5f734418 100644 --- a/src/main/java/vazkii/botania/common/block/tile/TileCell.java +++ b/src/main/java/vazkii/botania/common/block/tile/TileCell.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Sep 6, 2015, 4:07:16 PM (GMT)] */ package vazkii.botania.common.block.tile; @@ -16,76 +16,77 @@ public class TileCell extends TileMod { - private static final String TAG_GENERATION = "generation"; - private static final String TAG_TICKED = "ticked"; - private static final String TAG_FLOWER_X = "flowerX"; - private static final String TAG_FLOWER_Y = "flowerY"; - private static final String TAG_FLOWER_Z = "flowerZ"; - private static final String TAG_VALID_X = "validX"; - private static final String TAG_VALID_Y = "validY"; - private static final String TAG_VALID_Z = "validZ"; + private static final String TAG_GENERATION = "generation"; + private static final String TAG_TICKED = "ticked"; + private static final String TAG_FLOWER_X = "flowerX"; + private static final String TAG_FLOWER_Y = "flowerY"; + private static final String TAG_FLOWER_Z = "flowerZ"; + private static final String TAG_VALID_X = "validX"; + private static final String TAG_VALID_Y = "validY"; + private static final String TAG_VALID_Z = "validZ"; - private int generation; - private boolean ticked; - private ChunkCoordinates flowerCoords = new ChunkCoordinates(); - private ChunkCoordinates validCoords = new ChunkCoordinates(); + private int generation; + private boolean ticked; + private ChunkCoordinates flowerCoords = new ChunkCoordinates(); + private ChunkCoordinates validCoords = new ChunkCoordinates(); - @Override - public boolean canUpdate() { - return false; - } + @Override + public boolean canUpdate() { + return false; + } - public void setGeneration(TileEntity flower, int gen) { - generation = gen; - if (!ticked) { - flowerCoords.posX = flower.xCoord; - flowerCoords.posY = flower.yCoord; - flowerCoords.posZ = flower.zCoord; - validCoords.posX = xCoord; - validCoords.posY = yCoord; - validCoords.posZ = zCoord; - ticked = true; - } else if (!matchCoords(validCoords, this) || !matchCoords(flowerCoords, flower)) - worldObj.setBlockToAir(xCoord, yCoord, zCoord); - } + public void setGeneration(TileEntity flower, int gen) { + generation = gen; + if(!ticked) { + flowerCoords.posX = flower.xCoord; + flowerCoords.posY = flower.yCoord; + flowerCoords.posZ = flower.zCoord; + validCoords.posX = xCoord; + validCoords.posY = yCoord; + validCoords.posZ = zCoord; + ticked = true; + } else if(!matchCoords(validCoords, this) || !matchCoords(flowerCoords, flower)) + worldObj.setBlockToAir(xCoord, yCoord, zCoord); + } - public boolean isSameFlower(TileEntity flower) { - return matchCoords(validCoords, this) && matchCoords(flowerCoords, flower); - } + public boolean isSameFlower(TileEntity flower) { + return matchCoords(validCoords, this) && matchCoords(flowerCoords, flower); + } - private boolean matchCoords(ChunkCoordinates coords, TileEntity tile) { - return coords.posX == tile.xCoord && coords.posY == tile.yCoord && coords.posZ == tile.zCoord; - } + private boolean matchCoords(ChunkCoordinates coords, TileEntity tile) { + return coords.posX == tile.xCoord && coords.posY == tile.yCoord && coords.posZ == tile.zCoord; + } - public int getGeneration() { - return generation; - } + public int getGeneration() { + return generation; + } - @Override - public void writeCustomNBT(NBTTagCompound cmp) { - cmp.setInteger(TAG_GENERATION, generation); - cmp.setBoolean(TAG_TICKED, ticked); - if (ticked) { - cmp.setInteger(TAG_FLOWER_X, flowerCoords.posX); - cmp.setInteger(TAG_FLOWER_Y, flowerCoords.posY); - cmp.setInteger(TAG_FLOWER_Z, flowerCoords.posZ); - cmp.setInteger(TAG_VALID_X, validCoords.posX); - cmp.setInteger(TAG_VALID_Y, validCoords.posY); - cmp.setInteger(TAG_VALID_Z, validCoords.posZ); - } - } + @Override + public void writeCustomNBT(NBTTagCompound cmp) { + cmp.setInteger(TAG_GENERATION, generation); + cmp.setBoolean(TAG_TICKED, ticked); + if(ticked) { + cmp.setInteger(TAG_FLOWER_X, flowerCoords.posX); + cmp.setInteger(TAG_FLOWER_Y, flowerCoords.posY); + cmp.setInteger(TAG_FLOWER_Z, flowerCoords.posZ); + cmp.setInteger(TAG_VALID_X, validCoords.posX); + cmp.setInteger(TAG_VALID_Y, validCoords.posY); + cmp.setInteger(TAG_VALID_Z, validCoords.posZ); + } + } + + @Override + public void readCustomNBT(NBTTagCompound cmp) { + generation = cmp.getInteger(TAG_GENERATION); + ticked = cmp.getBoolean(TAG_TICKED); + if(ticked) { + flowerCoords.posX = cmp.getInteger(TAG_FLOWER_X); + flowerCoords.posY = cmp.getInteger(TAG_FLOWER_Y); + flowerCoords.posZ = cmp.getInteger(TAG_FLOWER_Z); + validCoords.posX = cmp.getInteger(TAG_VALID_X); + validCoords.posY = cmp.getInteger(TAG_VALID_Y); + validCoords.posZ = cmp.getInteger(TAG_VALID_Z); + } + } - @Override - public void readCustomNBT(NBTTagCompound cmp) { - generation = cmp.getInteger(TAG_GENERATION); - ticked = cmp.getBoolean(TAG_TICKED); - if (ticked) { - flowerCoords.posX = cmp.getInteger(TAG_FLOWER_X); - flowerCoords.posY = cmp.getInteger(TAG_FLOWER_Y); - flowerCoords.posZ = cmp.getInteger(TAG_FLOWER_Z); - validCoords.posX = cmp.getInteger(TAG_VALID_X); - validCoords.posY = cmp.getInteger(TAG_VALID_Y); - validCoords.posZ = cmp.getInteger(TAG_VALID_Z); - } - } } diff --git a/src/main/java/vazkii/botania/common/block/tile/TileCocoon.java b/src/main/java/vazkii/botania/common/block/tile/TileCocoon.java index c068570bcd..1dd09aed97 100644 --- a/src/main/java/vazkii/botania/common/block/tile/TileCocoon.java +++ b/src/main/java/vazkii/botania/common/block/tile/TileCocoon.java @@ -2,15 +2,14 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jul 8, 2015, 4:32:34 PM (GMT)] */ package vazkii.botania.common.block.tile; -import cpw.mods.fml.common.registry.VillagerRegistry; import net.minecraft.block.Block; import net.minecraft.entity.EntityAgeable; import net.minecraft.entity.passive.EntityChicken; @@ -23,90 +22,94 @@ import net.minecraft.entity.passive.EntityVillager; import net.minecraft.entity.passive.EntityWolf; import net.minecraft.nbt.NBTTagCompound; +import cpw.mods.fml.common.registry.VillagerRegistry; public class TileCocoon extends TileMod { - private static final String TAG_TIME_PASSED = "timePassed"; - private static final String TAG_EMERALDS_GIVEN = "emeraldsGiven"; + private static final String TAG_TIME_PASSED = "timePassed"; + private static final String TAG_EMERALDS_GIVEN = "emeraldsGiven"; + + public static final int TOTAL_TIME = 2400; + public static final int MAX_EMERALDS = 20; - public static final int TOTAL_TIME = 2400; - public static final int MAX_EMERALDS = 20; + public int timePassed; + public int emeraldsGiven; - public int timePassed; - public int emeraldsGiven; + @Override + public void updateEntity() { + timePassed++; + if(timePassed >= TOTAL_TIME) + hatch(); + } - @Override - public void updateEntity() { - timePassed++; - if (timePassed >= TOTAL_TIME) hatch(); - } + public void hatch() { + if(!worldObj.isRemote) { + worldObj.playAuxSFX(2001, xCoord, yCoord, zCoord, Block.getIdFromBlock(getBlockType())); + worldObj.setBlockToAir(xCoord, yCoord, zCoord); - public void hatch() { - if (!worldObj.isRemote) { - worldObj.playAuxSFX(2001, xCoord, yCoord, zCoord, Block.getIdFromBlock(getBlockType())); - worldObj.setBlockToAir(xCoord, yCoord, zCoord); + EntityAgeable entity = null; - EntityAgeable entity = null; + float villagerChance = Math.min(1F, (float) emeraldsGiven / (float) MAX_EMERALDS); - float villagerChance = Math.min(1F, (float) emeraldsGiven / (float) MAX_EMERALDS); + if(Math.random() < villagerChance) { + EntityVillager villager = new EntityVillager(worldObj); + VillagerRegistry.applyRandomTrade(villager, worldObj.rand); + entity = villager; + } else { + float specialChance = 0.05F; + if(Math.random() < specialChance) { + int entityType = worldObj.rand.nextInt(3); + switch(entityType) { + case 0: + entity = new EntityHorse(worldObj); + break; + case 1: + entity = new EntityWolf(worldObj); + break; + case 2: + entity = new EntityOcelot(worldObj); + break; + } + } else { + int entityType = worldObj.rand.nextInt(4); + switch(entityType) { + case 0: + entity = new EntitySheep(worldObj); + break; + case 1: + if(Math.random() < 0.01) + entity = new EntityMooshroom(worldObj); + else entity = new EntityCow(worldObj); + break; + case 2: + entity = new EntityPig(worldObj); + break; + case 3: + entity = new EntityChicken(worldObj); + break; + } + } + } - if (Math.random() < villagerChance) { - EntityVillager villager = new EntityVillager(worldObj); - VillagerRegistry.applyRandomTrade(villager, worldObj.rand); - entity = villager; - } else { - float specialChance = 0.05F; - if (Math.random() < specialChance) { - int entityType = worldObj.rand.nextInt(3); - switch (entityType) { - case 0: - entity = new EntityHorse(worldObj); - break; - case 1: - entity = new EntityWolf(worldObj); - break; - case 2: - entity = new EntityOcelot(worldObj); - break; - } - } else { - int entityType = worldObj.rand.nextInt(4); - switch (entityType) { - case 0: - entity = new EntitySheep(worldObj); - break; - case 1: - if (Math.random() < 0.01) entity = new EntityMooshroom(worldObj); - else entity = new EntityCow(worldObj); - break; - case 2: - entity = new EntityPig(worldObj); - break; - case 3: - entity = new EntityChicken(worldObj); - break; - } - } - } + if(entity != null) { + entity.setPosition(xCoord + 0.5, yCoord + 0.5, zCoord + 0.5); + entity.setGrowingAge(-24000); + worldObj.spawnEntityInWorld(entity); + entity.spawnExplosionParticle(); + } + } + } - if (entity != null) { - entity.setPosition(xCoord + 0.5, yCoord + 0.5, zCoord + 0.5); - entity.setGrowingAge(-24000); - worldObj.spawnEntityInWorld(entity); - entity.spawnExplosionParticle(); - } - } - } + @Override + public void writeCustomNBT(NBTTagCompound cmp) { + cmp.setInteger(TAG_TIME_PASSED, timePassed); + cmp.setInteger(TAG_EMERALDS_GIVEN, emeraldsGiven); + } - @Override - public void writeCustomNBT(NBTTagCompound cmp) { - cmp.setInteger(TAG_TIME_PASSED, timePassed); - cmp.setInteger(TAG_EMERALDS_GIVEN, emeraldsGiven); - } + @Override + public void readCustomNBT(NBTTagCompound cmp) { + timePassed = cmp.getInteger(TAG_TIME_PASSED); + emeraldsGiven = cmp.getInteger(TAG_EMERALDS_GIVEN); + } - @Override - public void readCustomNBT(NBTTagCompound cmp) { - timePassed = cmp.getInteger(TAG_TIME_PASSED); - emeraldsGiven = cmp.getInteger(TAG_EMERALDS_GIVEN); - } } diff --git a/src/main/java/vazkii/botania/common/block/tile/TileCraftCrate.java b/src/main/java/vazkii/botania/common/block/tile/TileCraftCrate.java index 17253660d8..49def343f4 100644 --- a/src/main/java/vazkii/botania/common/block/tile/TileCraftCrate.java +++ b/src/main/java/vazkii/botania/common/block/tile/TileCraftCrate.java @@ -2,15 +2,16 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jul 26, 2014, 4:50:20 PM (GMT)] */ package vazkii.botania.common.block.tile; import java.util.List; + import net.minecraft.entity.player.EntityPlayer; import net.minecraft.inventory.Container; import net.minecraft.inventory.InventoryCrafting; @@ -25,181 +26,178 @@ public class TileCraftCrate extends TileOpenCrate { - public static final boolean[][] PATTERNS = new boolean[][] { - { - true, false, false, - false, false, false, - false, false, false - }, - { - true, true, false, - true, true, false, - false, false, false - }, - { - true, false, false, - true, false, false, - false, false, false - }, - { - true, true, false, - false, false, false, - false, false, false - }, - { - true, false, false, - true, false, false, - true, false, false - }, - { - true, true, true, - false, false, false, - false, false, false - }, - { - true, true, false, - true, true, false, - true, true, false - }, - { - true, true, true, - true, true, true, - false, false, false - }, - { - true, true, true, - true, false, true, - true, true, true - } - }; - - private static final String TAG_PATTERN = "pattern"; - - public int pattern = -1; - int signal = 0; - - @Override - public int getSizeInventory() { - return 10; - } - - @Override - public int getInventoryStackLimit() { - return 1; - } - - @Override - public boolean isItemValidForSlot(int i, ItemStack itemstack) { - return i != 9 && !isLocked(i); - } - - public boolean isLocked(int slot) { - return pattern != -1 && !PATTERNS[pattern][slot]; - } - - @Override - public void updateEntity() { - if (!worldObj.isRemote && (craft(true) && canEject() || isFull())) ejectAll(); - - int newSignal = 0; - for (; newSignal < 9; newSignal++) // dis for loop be derpy - if (!isLocked(newSignal) && getStackInSlot(newSignal) == null) break; - - if (newSignal != signal) { - signal = newSignal; - worldObj.func_147453_f(xCoord, yCoord, zCoord, worldObj.getBlock(xCoord, yCoord, zCoord)); - } - } - - boolean craft(boolean fullCheck) { - if (fullCheck && !isFull()) return false; - - InventoryCrafting craft = new InventoryCrafting( - new Container() { - @Override - public boolean canInteractWith(EntityPlayer p_75145_1_) { - return false; - } - }, - 3, - 3); - for (int i = 0; i < 9; i++) { - ItemStack stack = getStackInSlot(i); - - if (stack == null || isLocked(i) || stack.getItem() == ModItems.manaResource && stack.getItemDamage() == 11) - continue; - - craft.setInventorySlotContents(i, stack.copy()); - } - - List recipes = CraftingManager.getInstance().getRecipeList(); - for (IRecipe recipe : recipes) - if (recipe.matches(craft, worldObj)) { - setInventorySlotContents(9, recipe.getCraftingResult(craft)); - - for (int i = 0; i < 9; i++) { - ItemStack stack = getStackInSlot(i); - if (stack == null) continue; - - ItemStack container = stack.getItem().getContainerItem(stack); - setInventorySlotContents(i, container); - } - return true; - } - - return false; - } - - boolean isFull() { - for (int i = 0; i < 9; i++) if (!isLocked(i) && getStackInSlot(i) == null) return false; - - return true; - } - - void ejectAll() { - for (int i = 0; i < getSizeInventory(); ++i) { - ItemStack stack = getStackInSlot(i); - if (stack != null) eject(stack, false); - setInventorySlotContents(i, null); - markDirty(); - } - } - - @Override - public void writeCustomNBT(NBTTagCompound par1nbtTagCompound) { - super.writeCustomNBT(par1nbtTagCompound); - par1nbtTagCompound.setInteger(TAG_PATTERN, pattern); - } - - @Override - public void readCustomNBT(NBTTagCompound par1nbtTagCompound) { - super.readCustomNBT(par1nbtTagCompound); - pattern = par1nbtTagCompound.getInteger(TAG_PATTERN); - } - - @Override - public boolean onWanded(EntityPlayer player, ItemStack stack) { - craft(false); - ejectAll(); - return true; - } - - @Override - public void markDirty() { - super.markDirty(); - VanillaPacketDispatcher.dispatchTEToNearbyPlayers(this); - } - - @Override - public int getSignal() { - return signal; - } - - @Override - public void onDataPacket(NetworkManager manager, S35PacketUpdateTileEntity packet) { - int lastPattern = pattern; - super.onDataPacket(manager, packet); - if (pattern != lastPattern) - worldObj.markBlockRangeForRenderUpdate(xCoord, yCoord, zCoord, xCoord, yCoord, zCoord); - } + public static final boolean[][] PATTERNS = new boolean[][] { + { + true, false, false, + false, false, false, + false, false, false + }, { + true, true, false, + true, true, false, + false, false, false + }, { + true, false, false, + true, false, false, + false, false, false + }, { + true, true, false, + false, false, false, + false, false, false + }, { + true, false, false, + true, false, false, + true, false, false + }, { + true, true, true, + false, false, false, + false, false, false + }, { + true, true, false, + true, true, false, + true, true, false + }, { + true, true, true, + true, true, true, + false, false, false + }, { + true, true, true, + true, false, true, + true, true, true + } + }; + + private static final String TAG_PATTERN = "pattern"; + + public int pattern = -1; + int signal = 0; + + @Override + public int getSizeInventory() { + return 10; + } + + @Override + public int getInventoryStackLimit() { + return 1; + } + + @Override + public boolean isItemValidForSlot(int i, ItemStack itemstack) { + return i != 9 && !isLocked(i); + } + + public boolean isLocked(int slot) { + return pattern != -1 && !PATTERNS[pattern][slot]; + } + + @Override + public void updateEntity() { + if(!worldObj.isRemote && (craft(true) && canEject() || isFull())) + ejectAll(); + + int newSignal = 0; + for(; newSignal < 9; newSignal++) // dis for loop be derpy + if(!isLocked(newSignal) && getStackInSlot(newSignal) == null) + break; + + if(newSignal != signal) { + signal = newSignal; + worldObj.func_147453_f(xCoord, yCoord, zCoord, worldObj.getBlock(xCoord, yCoord, zCoord)); + } + } + + boolean craft(boolean fullCheck) { + if(fullCheck && !isFull()) + return false; + + InventoryCrafting craft = new InventoryCrafting(new Container() { + @Override + public boolean canInteractWith(EntityPlayer p_75145_1_) { + return false; + } + }, 3, 3); + for(int i = 0; i < 9; i++) { + ItemStack stack = getStackInSlot(i); + + if(stack == null || isLocked(i) || stack.getItem() == ModItems.manaResource && stack.getItemDamage() == 11) + continue; + + craft.setInventorySlotContents(i, stack.copy()); + } + + List recipes = CraftingManager.getInstance().getRecipeList(); + for(IRecipe recipe : recipes) + if(recipe.matches(craft, worldObj)) { + setInventorySlotContents(9, recipe.getCraftingResult(craft)); + + for(int i = 0; i < 9; i++) { + ItemStack stack = getStackInSlot(i); + if(stack == null) + continue; + + ItemStack container = stack.getItem().getContainerItem(stack); + setInventorySlotContents(i, container); + } + return true; + } + + return false; + } + + boolean isFull() { + for(int i = 0; i < 9; i++) + if(!isLocked(i) && getStackInSlot(i) == null) + return false; + + return true; + } + + void ejectAll() { + for(int i = 0; i < getSizeInventory(); ++i) { + ItemStack stack = getStackInSlot(i); + if(stack != null) + eject(stack, false); + setInventorySlotContents(i, null); + markDirty(); + } + } + + @Override + public void writeCustomNBT(NBTTagCompound par1nbtTagCompound) { + super.writeCustomNBT(par1nbtTagCompound); + par1nbtTagCompound.setInteger(TAG_PATTERN, pattern); + } + + @Override + public void readCustomNBT(NBTTagCompound par1nbtTagCompound) { + super.readCustomNBT(par1nbtTagCompound); + pattern = par1nbtTagCompound.getInteger(TAG_PATTERN); + } + + @Override + public boolean onWanded(EntityPlayer player, ItemStack stack) { + craft(false); + ejectAll(); + return true; + } + + @Override + public void markDirty() { + super.markDirty(); + VanillaPacketDispatcher.dispatchTEToNearbyPlayers(this); + } + + @Override + public int getSignal() { + return signal; + } + + @Override + public void onDataPacket(NetworkManager manager, S35PacketUpdateTileEntity packet) { + int lastPattern = pattern; + super.onDataPacket(manager, packet); + if(pattern != lastPattern) + worldObj.markBlockRangeForRenderUpdate(xCoord,yCoord,zCoord,xCoord,yCoord,zCoord); + } + } diff --git a/src/main/java/vazkii/botania/common/block/tile/TileEnchanter.java b/src/main/java/vazkii/botania/common/block/tile/TileEnchanter.java index 533a84034c..e615e22679 100644 --- a/src/main/java/vazkii/botania/common/block/tile/TileEnchanter.java +++ b/src/main/java/vazkii/botania/common/block/tile/TileEnchanter.java @@ -2,16 +2,17 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Mar 15, 2014, 4:57:52 PM (GMT)] */ package vazkii.botania.common.block.tile; import java.util.ArrayList; import java.util.List; + import net.minecraft.client.Minecraft; import net.minecraft.client.gui.ScaledResolution; import net.minecraft.enchantment.Enchantment; @@ -43,417 +44,389 @@ public class TileEnchanter extends TileMod implements ISparkAttachable { - private static final String TAG_STAGE = "stage"; - private static final String TAG_STAGE_TICKS = "stageTicks"; - private static final String TAG_STAGE_3_END_TICKS = "stage3EndTicks"; - private static final String TAG_MANA_REQUIRED = "manaRequired"; - private static final String TAG_MANA = "mana"; - private static final String TAG_ITEM = "item"; - private static final String TAG_ENCHANTS = "enchantsToApply"; - - public int stage = 0; - public int stageTicks = 0; - - public int stage3EndTicks = 0; - - int manaRequired = -1; - int mana = 0; - - public ItemStack itemToEnchant = null; - List enchants = new ArrayList(); - - private static final int[][] OBSIDIAN_LOCATIONS = new int[][] { - {0, -1, 0}, - {0, -1, 1}, - {0, -1, -1}, - {1, -1, 0}, - {-1, -1, 0}, - {0, -1, 2}, - {-1, -1, 2}, - {1, -1, 2}, - {0, -1, -2}, - {-1, -1, -2}, - {1, -1, -2}, - {2, -1, 0}, - {2, -1, 1}, - {2, -1, -1}, - {-2, -1, 0}, - {-2, -1, 1}, - {-2, -1, -1} - }; - - private static final int[][][] PYLON_LOCATIONS = new int[][][] { - {{-5, 1, 0}, {5, 1, 0}, {-4, 1, 3}, {4, 1, 3}, {-4, 1, -3}, {4, 1, -3}}, - {{0, 1, -5}, {0, 1, 5}, {3, 1, -4}, {3, 1, 4}, {-3, 1, -4}, {-3, 1, 4}} - }; - - private static final int[][] FLOWER_LOCATIONS = new int[][] {{-1, 0, -1}, {1, 0, -1}, {-1, 0, 1}, {1, 0, 1}}; - - public static MultiblockSet makeMultiblockSet() { - Multiblock mb = new Multiblock(); - - for (int[] o : OBSIDIAN_LOCATIONS) mb.addComponent(o[0], o[1] + 1, o[2], Blocks.obsidian, 0); - for (int[] p : PYLON_LOCATIONS[0]) { - mb.addComponent(p[0], p[1] + 1, p[2], ModBlocks.pylon, 0); - mb.addComponent(new FlowerComponent(new ChunkCoordinates(p[0], p[1], p[2]), ModBlocks.flower)); - } - for (int[] f : FLOWER_LOCATIONS) - mb.addComponent(new FlowerComponent(new ChunkCoordinates(f[0], f[1] + 1, f[2]), ModBlocks.flower)); - - mb.addComponent(0, 1, 0, Blocks.lapis_block, 0); - - return mb.makeSet(); - } - - public void onWanded(EntityPlayer player, ItemStack wand) { - if (stage != 0 || itemToEnchant == null || !itemToEnchant.isItemEnchantable()) return; - - List items = worldObj.getEntitiesWithinAABB( - EntityItem.class, - AxisAlignedBB.getBoundingBox(xCoord - 2, yCoord, zCoord - 2, xCoord + 3, yCoord + 1, zCoord + 3)); - int count = items.size(); - - if (count > 0 && !worldObj.isRemote) { - for (EntityItem entity : items) { - ItemStack item = entity.getEntityItem(); - if (item.getItem() == Items.enchanted_book) { - NBTTagList enchants = Items.enchanted_book.func_92110_g(item); - if (enchants != null && enchants.tagCount() > 0) { - NBTTagCompound enchant = enchants.getCompoundTagAt(0); - short id = enchant.getShort("id"); - if (isEnchantmentValid(id)) { - advanceStage(); - return; - } - } - } - } - } - } - - @Override - public void updateEntity() { - if (getBlockMetadata() < PYLON_LOCATIONS.length) - for (int[] pylon : PYLON_LOCATIONS[getBlockMetadata()]) { - TileEntity tile = worldObj.getTileEntity(xCoord + pylon[0], yCoord + pylon[1], zCoord + pylon[2]); - if (tile != null && tile instanceof TilePylon) ((TilePylon) tile).activated = false; - } - - if (!canEnchanterExist(worldObj, xCoord, yCoord, zCoord, getBlockMetadata())) { - - worldObj.setBlock(xCoord, yCoord, zCoord, Blocks.lapis_block, 0, 1 | 2); - for (int i = 0; i < 50; i++) { - float red = (float) Math.random(); - float green = (float) Math.random(); - float blue = (float) Math.random(); - Botania.proxy.wispFX( - worldObj, - xCoord + 0.5, - yCoord + 0.5, - zCoord + 0.5, - red, - green, - blue, - (float) Math.random() * 0.15F + 0.15F, - (float) (Math.random() - 0.5F) * 0.25F, - (float) (Math.random() - 0.5F) * 0.25F, - (float) (Math.random() - 0.5F) * 0.25F); - } - worldObj.playSoundEffect(xCoord, yCoord, zCoord, "botania:enchanterBlock", 0.5F, 10F); - } - - switch (stage) { - case 1: { // Get books - if (stageTicks % 20 == 0) { - List items = worldObj.getEntitiesWithinAABB( - EntityItem.class, - AxisAlignedBB.getBoundingBox( - xCoord - 2, yCoord, zCoord - 2, xCoord + 3, yCoord + 1, zCoord + 3)); - int count = items.size(); - boolean addedEnch = false; - - if (count > 0 && !worldObj.isRemote) { - for (EntityItem entity : items) { - ItemStack item = entity.getEntityItem(); - if (item.getItem() == Items.enchanted_book) { - NBTTagList enchants = Items.enchanted_book.func_92110_g(item); - if (enchants != null && enchants.tagCount() > 0) { - NBTTagCompound enchant = enchants.getCompoundTagAt(0); - short enchantId = enchant.getShort("id"); - short enchantLvl = enchant.getShort("lvl"); - if (!hasEnchantAlready(enchantId) && isEnchantmentValid(enchantId)) { - this.enchants.add(new EnchantmentData(enchantId, enchantLvl)); - worldObj.playSoundEffect(xCoord, yCoord, zCoord, "botania:ding", 1F, 1F); - addedEnch = true; - break; - } - } - } - } - } - - if (!addedEnch) { - if (enchants.isEmpty()) stage = 0; - else advanceStage(); - } - } - break; - } - case 2: { // Get Mana - for (int[] pylon : PYLON_LOCATIONS[getBlockMetadata()]) { - TilePylon pylonTile = - (TilePylon) worldObj.getTileEntity(xCoord + pylon[0], yCoord + pylon[1], zCoord + pylon[2]); - if (pylonTile != null) { - pylonTile.activated = true; - pylonTile.centerX = xCoord; - pylonTile.centerY = yCoord; - pylonTile.centerZ = zCoord; - } - } - - if (manaRequired == -1) { - manaRequired = 0; - for (EnchantmentData data : enchants) { - Enchantment ench = Enchantment.enchantmentsList[data.enchant]; - manaRequired += (int) (5000F - * ((15 - Math.min(15, ench.getWeight())) * 1.05F) - * ((3F + data.level * data.level) * 0.25F) - * (0.9F + enchants.size() * 0.05F)); - } - } else if (mana >= manaRequired) { - manaRequired = 0; - for (int[] pylon : PYLON_LOCATIONS[getBlockMetadata()]) - ((TilePylon) worldObj.getTileEntity(xCoord + pylon[0], yCoord + pylon[1], zCoord + pylon[2])) - .activated = false; - - advanceStage(); - } else { - ISparkEntity spark = getAttachedSpark(); - if (spark != null) { - List sparkEntities = - SparkHelper.getSparksAround(worldObj, xCoord + 0.5, yCoord + 0.5, zCoord + 0.5); - for (ISparkEntity otherSpark : sparkEntities) { - if (spark == otherSpark) continue; - - if (otherSpark.getAttachedTile() != null - && otherSpark.getAttachedTile() instanceof IManaPool) - otherSpark.registerTransfer(spark); - } - } - } - - break; - } - case 3: { // Enchant - if (stageTicks >= 100) { - for (EnchantmentData data : enchants) - if (EnchantmentHelper.getEnchantmentLevel(data.enchant, itemToEnchant) == 0) - itemToEnchant.addEnchantment(Enchantment.enchantmentsList[data.enchant], data.level); - - enchants.clear(); - manaRequired = -1; - mana = 0; - - craftingFanciness(); - advanceStage(); - } - break; - } - case 4: { // Reset - if (stageTicks >= 20) advanceStage(); - - break; - } - } - - if (stage != 0) stageTicks++; - } - - public void advanceStage() { - stage++; - - if (stage == 4) stage3EndTicks = stageTicks; - else if (stage == 5) { - stage = 0; - stage3EndTicks = 0; - } - - stageTicks = 0; - sync(); - } - - public void craftingFanciness() { - worldObj.playSoundEffect(xCoord, yCoord, zCoord, "botania:enchanterEnchant", 1F, 1F); - for (int i = 0; i < 25; i++) { - float red = (float) Math.random(); - float green = (float) Math.random(); - float blue = (float) Math.random(); - Botania.proxy.sparkleFX( - worldObj, - xCoord + 0.5 + Math.random() * 0.4 - 0.2, - yCoord + 1, - zCoord + 0.5 + Math.random() * 0.4 - 0.2, - red, - green, - blue, - (float) Math.random(), - 10); - } - } - - @Override - public AxisAlignedBB getRenderBoundingBox() { - return INFINITE_EXTENT_AABB; - } - - @Override - public int getCurrentMana() { - return mana; - } - - @Override - public boolean isFull() { - return mana >= manaRequired; - } - - @Override - public void recieveMana(int mana) { - this.mana = Math.min(manaRequired, this.mana + mana); - } - - @Override - public boolean canRecieveManaFromBursts() { - return manaRequired > 0; - } - - public void sync() { - VanillaPacketDispatcher.dispatchTEToNearbyPlayers(worldObj, xCoord, yCoord, zCoord); - } - - @Override - public void writeCustomNBT(NBTTagCompound cmp) { - cmp.setInteger(TAG_MANA, mana); - cmp.setInteger(TAG_MANA_REQUIRED, manaRequired); - cmp.setInteger(TAG_STAGE, stage); - cmp.setInteger(TAG_STAGE_TICKS, stageTicks); - cmp.setInteger(TAG_STAGE_3_END_TICKS, stage3EndTicks); - - NBTTagCompound itemCmp = new NBTTagCompound(); - if (itemToEnchant != null) itemToEnchant.writeToNBT(itemCmp); - cmp.setTag(TAG_ITEM, itemCmp); - - String enchStr = ""; - for (EnchantmentData data : enchants) enchStr = enchStr + data.enchant + ":" + data.level + ","; - cmp.setString(TAG_ENCHANTS, enchStr.isEmpty() ? enchStr : enchStr.substring(0, enchStr.length() - 1)); - } - - @Override - public void readCustomNBT(NBTTagCompound cmp) { - mana = cmp.getInteger(TAG_MANA); - manaRequired = cmp.getInteger(TAG_MANA_REQUIRED); - stage = cmp.getInteger(TAG_STAGE); - stageTicks = cmp.getInteger(TAG_STAGE_TICKS); - stage3EndTicks = cmp.getInteger(TAG_STAGE_3_END_TICKS); - - NBTTagCompound itemCmp = cmp.getCompoundTag(TAG_ITEM); - itemToEnchant = ItemStack.loadItemStackFromNBT(itemCmp); - - enchants.clear(); - String enchStr = cmp.getString(TAG_ENCHANTS); - if (!enchStr.isEmpty()) { - String[] enchTokens = enchStr.split(","); - for (String token : enchTokens) { - String[] entryTokens = token.split(":"); - int id = Integer.parseInt(entryTokens[0]); - int lvl = Integer.parseInt(entryTokens[1]); - enchants.add(new EnchantmentData(id, lvl)); - } - } - } - - private boolean hasEnchantAlready(int enchant) { - for (EnchantmentData data : enchants) if (data.enchant == enchant) return true; - - return false; - } - - public boolean isEnchantmentValid(short id) { - Enchantment ench = Enchantment.enchantmentsList[id]; - if (!ench.canApply(itemToEnchant) || !ench.type.canEnchantItem(itemToEnchant.getItem())) return false; - - for (EnchantmentData data : enchants) { - Enchantment otherEnch = Enchantment.enchantmentsList[data.enchant]; - if (!otherEnch.canApplyTogether(ench) || !ench.canApplyTogether(otherEnch)) return false; - } - - return true; - } - - public static boolean canEnchanterExist(World world, int x, int y, int z, int meta) { - for (int[] obsidian : OBSIDIAN_LOCATIONS) - if (world.getBlock(obsidian[0] + x, obsidian[1] + y, obsidian[2] + z) != Blocks.obsidian) return false; - - for (int[] pylon : PYLON_LOCATIONS[meta]) - if (world.getBlock(pylon[0] + x, pylon[1] + y, pylon[2] + z) != ModBlocks.pylon - || !BotaniaAPI.internalHandler.isBotaniaFlower(world, pylon[0] + x, pylon[1] + y - 1, pylon[2] + z)) - return false; - - for (int[] flower : FLOWER_LOCATIONS) - if (!BotaniaAPI.internalHandler.isBotaniaFlower(world, flower[0] + x, flower[1] + y, flower[2] + z)) - return false; - - return true; - } - - @Override - public boolean canAttachSpark(ItemStack stack) { - return true; - } - - @Override - public void attachSpark(ISparkEntity entity) { - // NO-OP - } - - @Override - public ISparkEntity getAttachedSpark() { - List sparks = worldObj.getEntitiesWithinAABB( - ISparkEntity.class, - AxisAlignedBB.getBoundingBox(xCoord, yCoord + 1, zCoord, xCoord + 1, yCoord + 2, zCoord + 1)); - if (sparks.size() == 1) { - Entity e = (Entity) sparks.get(0); - return (ISparkEntity) e; - } - - return null; - } - - @Override - public boolean areIncomingTranfersDone() { - return stage == 3; - } - - @Override - public int getAvailableSpaceForMana() { - return Math.max(0, manaRequired - getCurrentMana()); - } - - public void renderHUD(Minecraft mc, ScaledResolution res) { - if (manaRequired > 0 && itemToEnchant != null) { - int x = res.getScaledWidth() / 2 + 20; - int y = res.getScaledHeight() / 2 - 8; - - RenderHelper.renderProgressPie(x, y, (float) mana / (float) manaRequired, itemToEnchant); - } - } - - private static class EnchantmentData { - - public int enchant, level; - - public EnchantmentData(int enchant, int level) { - this.enchant = enchant; - this.level = level; - } - } + private static final String TAG_STAGE = "stage"; + private static final String TAG_STAGE_TICKS = "stageTicks"; + private static final String TAG_STAGE_3_END_TICKS = "stage3EndTicks"; + private static final String TAG_MANA_REQUIRED = "manaRequired"; + private static final String TAG_MANA = "mana"; + private static final String TAG_ITEM = "item"; + private static final String TAG_ENCHANTS = "enchantsToApply"; + + public int stage = 0; + public int stageTicks = 0; + + public int stage3EndTicks = 0; + + int manaRequired = -1; + int mana = 0; + + public ItemStack itemToEnchant = null; + List enchants = new ArrayList(); + + private static final int[][] OBSIDIAN_LOCATIONS = new int[][] { + { 0, -1, 0 }, + { 0, -1, 1 }, { 0, -1, -1 }, { 1, -1, 0 }, { -1, -1, 0 }, + { 0, -1, 2 }, { -1, -1, 2 }, { 1, -1, 2 }, + { 0, -1, -2 }, { -1, -1, -2 }, { 1, -1, -2 }, + { 2, -1, 0 }, { 2, -1, 1 }, { 2, -1, -1 }, + { -2, -1, 0 }, { -2, -1, 1 }, { -2, -1, -1 } + }; + + private static final int[][][] PYLON_LOCATIONS = new int[][][] { + { { -5, 1, 0 }, { 5, 1, 0 }, { -4, 1, 3 }, { 4, 1, 3 }, { -4, 1, -3 }, { 4, 1, -3 } }, + { { 0, 1, -5 }, { 0, 1, 5 }, { 3, 1, -4 }, { 3, 1, 4 }, { -3, 1, -4 }, { -3, 1, 4 } } + }; + + private static final int[][] FLOWER_LOCATIONS = new int[][] { + { -1, 0, -1 }, { 1, 0, -1 }, { -1, 0, 1 }, { 1, 0, 1 } + }; + + public static MultiblockSet makeMultiblockSet() { + Multiblock mb = new Multiblock(); + + for(int[] o : OBSIDIAN_LOCATIONS) + mb.addComponent(o[0], o[1] + 1, o[2], Blocks.obsidian, 0); + for(int[] p : PYLON_LOCATIONS[0]) { + mb.addComponent(p[0], p[1] + 1, p[2], ModBlocks.pylon, 0); + mb.addComponent(new FlowerComponent(new ChunkCoordinates(p[0], p[1], p[2]), ModBlocks.flower)); + } + for(int[] f : FLOWER_LOCATIONS) + mb.addComponent(new FlowerComponent(new ChunkCoordinates(f[0], f[1] + 1, f[2]), ModBlocks.flower)); + + mb.addComponent(0, 1, 0, Blocks.lapis_block, 0); + + return mb.makeSet(); + } + + public void onWanded(EntityPlayer player, ItemStack wand) { + if(stage != 0 || itemToEnchant == null || !itemToEnchant.isItemEnchantable()) + return; + + List items = worldObj.getEntitiesWithinAABB(EntityItem.class, AxisAlignedBB.getBoundingBox(xCoord - 2, yCoord, zCoord - 2, xCoord + 3, yCoord + 1, zCoord + 3)); + int count = items.size(); + + if(count > 0 && !worldObj.isRemote) { + for(EntityItem entity : items) { + ItemStack item = entity.getEntityItem(); + if(item.getItem() == Items.enchanted_book) { + NBTTagList enchants = Items.enchanted_book.func_92110_g(item); + if(enchants != null && enchants.tagCount() > 0) { + NBTTagCompound enchant = enchants.getCompoundTagAt(0); + short id = enchant.getShort("id"); + if(isEnchantmentValid(id)) { + advanceStage(); + return; + } + } + } + } + } + } + + @Override + public void updateEntity() { + if(getBlockMetadata() < PYLON_LOCATIONS.length) + for(int[] pylon : PYLON_LOCATIONS[getBlockMetadata()]) { + TileEntity tile = worldObj.getTileEntity(xCoord + pylon[0], yCoord + pylon[1], zCoord + pylon[2]); + if(tile != null && tile instanceof TilePylon) + ((TilePylon) tile).activated = false; + } + + if(!canEnchanterExist(worldObj, xCoord, yCoord, zCoord, getBlockMetadata())) { + + worldObj.setBlock(xCoord, yCoord, zCoord, Blocks.lapis_block, 0, 1 | 2); + for(int i = 0; i < 50; i++) { + float red = (float) Math.random(); + float green = (float) Math.random(); + float blue = (float) Math.random(); + Botania.proxy.wispFX(worldObj, xCoord + 0.5, yCoord + 0.5, zCoord + 0.5, red, green, blue, (float) Math.random() * 0.15F + 0.15F, (float) (Math.random() - 0.5F) * 0.25F, (float) (Math.random() - 0.5F) * 0.25F, (float) (Math.random() - 0.5F) * 0.25F); + } + worldObj.playSoundEffect(xCoord, yCoord, zCoord, "botania:enchanterBlock", 0.5F, 10F); + } + + switch(stage) { + case 1 : { // Get books + if(stageTicks % 20 == 0) { + List items = worldObj.getEntitiesWithinAABB(EntityItem.class, AxisAlignedBB.getBoundingBox(xCoord - 2, yCoord, zCoord - 2, xCoord + 3, yCoord + 1, zCoord + 3)); + int count = items.size(); + boolean addedEnch = false; + + if(count > 0 && !worldObj.isRemote) { + for(EntityItem entity : items) { + ItemStack item = entity.getEntityItem(); + if(item.getItem() == Items.enchanted_book) { + NBTTagList enchants = Items.enchanted_book.func_92110_g(item); + if(enchants != null && enchants.tagCount() > 0) { + NBTTagCompound enchant = enchants.getCompoundTagAt(0); + short enchantId = enchant.getShort("id"); + short enchantLvl = enchant.getShort("lvl"); + if(!hasEnchantAlready(enchantId) && isEnchantmentValid(enchantId)) { + this.enchants.add(new EnchantmentData(enchantId, enchantLvl)); + worldObj.playSoundEffect(xCoord, yCoord, zCoord, "botania:ding", 1F, 1F); + addedEnch = true; + break; + } + } + } + } + } + + if(!addedEnch) { + if(enchants.isEmpty()) + stage = 0; + else advanceStage(); + } + } + break; + } + case 2 : { // Get Mana + for(int[] pylon : PYLON_LOCATIONS[getBlockMetadata()]) { + TilePylon pylonTile = (TilePylon) worldObj.getTileEntity(xCoord + pylon[0], yCoord + pylon[1], zCoord + pylon[2]); + if(pylonTile != null) { + pylonTile.activated = true; + pylonTile.centerX = xCoord; + pylonTile.centerY = yCoord; + pylonTile.centerZ = zCoord; + } + } + + if(manaRequired == -1) { + manaRequired = 0; + for(EnchantmentData data : enchants) { + Enchantment ench = Enchantment.enchantmentsList[data.enchant]; + manaRequired += (int) (5000F * ((15 - Math.min(15, ench.getWeight())) * 1.05F) * ((3F + data.level * data.level) * 0.25F) * (0.9F + enchants.size() * 0.05F)); + } + } else if(mana >= manaRequired) { + manaRequired = 0; + for(int[] pylon : PYLON_LOCATIONS[getBlockMetadata()]) + ((TilePylon) worldObj.getTileEntity(xCoord + pylon[0], yCoord + pylon[1], zCoord + pylon[2])).activated = false; + + advanceStage(); + } else { + ISparkEntity spark = getAttachedSpark(); + if(spark != null) { + List sparkEntities = SparkHelper.getSparksAround(worldObj, xCoord + 0.5, yCoord + 0.5, zCoord + 0.5); + for(ISparkEntity otherSpark : sparkEntities) { + if(spark == otherSpark) + continue; + + if(otherSpark.getAttachedTile() != null && otherSpark.getAttachedTile() instanceof IManaPool) + otherSpark.registerTransfer(spark); + } + } + } + + break; + } + case 3 : { // Enchant + if(stageTicks >= 100) { + for(EnchantmentData data : enchants) + if(EnchantmentHelper.getEnchantmentLevel(data.enchant, itemToEnchant) == 0) + itemToEnchant.addEnchantment(Enchantment.enchantmentsList[data.enchant], data.level); + + enchants.clear(); + manaRequired = -1; + mana = 0; + + craftingFanciness(); + advanceStage(); + } + break; + } + case 4 : { // Reset + if(stageTicks >= 20) + advanceStage(); + + break; + } + } + + if(stage != 0) + stageTicks++; + } + + public void advanceStage() { + stage++; + + if(stage == 4) + stage3EndTicks = stageTicks; + else if(stage == 5) { + stage = 0; + stage3EndTicks = 0; + } + + stageTicks = 0; + sync(); + } + + public void craftingFanciness() { + worldObj.playSoundEffect(xCoord, yCoord, zCoord, "botania:enchanterEnchant", 1F, 1F); + for(int i = 0; i < 25; i++) { + float red = (float) Math.random(); + float green = (float) Math.random(); + float blue = (float) Math.random(); + Botania.proxy.sparkleFX(worldObj, xCoord + 0.5 + Math.random() * 0.4 - 0.2, yCoord + 1, zCoord + 0.5 + Math.random() * 0.4 - 0.2, red, green, blue, (float) Math.random(), 10); + } + } + + @Override + public AxisAlignedBB getRenderBoundingBox() { + return INFINITE_EXTENT_AABB; + } + + @Override + public int getCurrentMana() { + return mana; + } + + @Override + public boolean isFull() { + return mana >= manaRequired; + } + + @Override + public void recieveMana(int mana) { + this.mana = Math.min(manaRequired, this.mana + mana); + } + + @Override + public boolean canRecieveManaFromBursts() { + return manaRequired > 0; + } + + public void sync() { + VanillaPacketDispatcher.dispatchTEToNearbyPlayers(worldObj, xCoord, yCoord, zCoord); + } + + @Override + public void writeCustomNBT(NBTTagCompound cmp) { + cmp.setInteger(TAG_MANA, mana); + cmp.setInteger(TAG_MANA_REQUIRED, manaRequired); + cmp.setInteger(TAG_STAGE, stage); + cmp.setInteger(TAG_STAGE_TICKS, stageTicks); + cmp.setInteger(TAG_STAGE_3_END_TICKS, stage3EndTicks); + + NBTTagCompound itemCmp = new NBTTagCompound(); + if(itemToEnchant != null) + itemToEnchant.writeToNBT(itemCmp); + cmp.setTag(TAG_ITEM, itemCmp); + + String enchStr = ""; + for(EnchantmentData data : enchants) + enchStr = enchStr + data.enchant + ":" + data.level + ","; + cmp.setString(TAG_ENCHANTS, enchStr.isEmpty() ? enchStr : enchStr.substring(0, enchStr.length() - 1)); + } + + @Override + public void readCustomNBT(NBTTagCompound cmp) { + mana = cmp.getInteger(TAG_MANA); + manaRequired = cmp.getInteger(TAG_MANA_REQUIRED); + stage = cmp.getInteger(TAG_STAGE); + stageTicks = cmp.getInteger(TAG_STAGE_TICKS); + stage3EndTicks = cmp.getInteger(TAG_STAGE_3_END_TICKS); + + NBTTagCompound itemCmp = cmp.getCompoundTag(TAG_ITEM); + itemToEnchant = ItemStack.loadItemStackFromNBT(itemCmp); + + enchants.clear(); + String enchStr = cmp.getString(TAG_ENCHANTS); + if(!enchStr.isEmpty()) { + String[] enchTokens = enchStr.split(","); + for(String token : enchTokens) { + String[] entryTokens = token.split(":"); + int id = Integer.parseInt(entryTokens[0]); + int lvl = Integer.parseInt(entryTokens[1]); + enchants.add(new EnchantmentData(id, lvl)); + } + } + } + + private boolean hasEnchantAlready(int enchant) { + for(EnchantmentData data : enchants) + if(data.enchant == enchant) + return true; + + return false; + } + + public boolean isEnchantmentValid(short id) { + Enchantment ench = Enchantment.enchantmentsList[id]; + if(!ench.canApply(itemToEnchant) || !ench.type.canEnchantItem(itemToEnchant.getItem())) + return false; + + for(EnchantmentData data : enchants) { + Enchantment otherEnch = Enchantment.enchantmentsList[data.enchant]; + if(!otherEnch.canApplyTogether(ench) || !ench.canApplyTogether(otherEnch)) + return false; + } + + return true; + } + + public static boolean canEnchanterExist(World world, int x, int y, int z, int meta) { + for(int[] obsidian : OBSIDIAN_LOCATIONS) + if(world.getBlock(obsidian[0] + x, obsidian[1] + y, obsidian[2] + z) != Blocks.obsidian) + return false; + + for(int[] pylon : PYLON_LOCATIONS[meta]) + if(world.getBlock(pylon[0] + x, pylon[1] + y, pylon[2] + z) != ModBlocks.pylon || !BotaniaAPI.internalHandler.isBotaniaFlower(world, pylon[0] + x, pylon[1] + y - 1, pylon[2] + z)) + return false; + + for(int[] flower : FLOWER_LOCATIONS) + if(!BotaniaAPI.internalHandler.isBotaniaFlower(world, flower[0] + x, flower[1] + y, flower[2] + z)) + return false; + + return true; + } + + @Override + public boolean canAttachSpark(ItemStack stack) { + return true; + } + + @Override + public void attachSpark(ISparkEntity entity) { + // NO-OP + } + + @Override + public ISparkEntity getAttachedSpark() { + List sparks = worldObj.getEntitiesWithinAABB(ISparkEntity.class, AxisAlignedBB.getBoundingBox(xCoord, yCoord + 1, zCoord, xCoord + 1, yCoord + 2, zCoord + 1)); + if(sparks.size() == 1) { + Entity e = (Entity) sparks.get(0); + return (ISparkEntity) e; + } + + return null; + } + + @Override + public boolean areIncomingTranfersDone() { + return stage == 3; + } + + @Override + public int getAvailableSpaceForMana() { + return Math.max(0, manaRequired - getCurrentMana()); + } + + public void renderHUD(Minecraft mc, ScaledResolution res) { + if(manaRequired > 0 && itemToEnchant != null) { + int x = res.getScaledWidth() / 2 + 20; + int y = res.getScaledHeight() / 2 - 8; + + RenderHelper.renderProgressPie(x, y, (float) mana / (float) manaRequired, itemToEnchant); + } + } + + private static class EnchantmentData { + + public int enchant, level; + + public EnchantmentData(int enchant, int level) { + this.enchant = enchant; + this.level = level; + } + } + } diff --git a/src/main/java/vazkii/botania/common/block/tile/TileEnderEye.java b/src/main/java/vazkii/botania/common/block/tile/TileEnderEye.java index 17c303b0dc..99be1db8b3 100644 --- a/src/main/java/vazkii/botania/common/block/tile/TileEnderEye.java +++ b/src/main/java/vazkii/botania/common/block/tile/TileEnderEye.java @@ -2,15 +2,16 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jul 30, 2014, 1:10:34 PM (GMT)] */ package vazkii.botania.common.block.tile; import java.util.List; + import net.minecraft.entity.player.EntityPlayer; import net.minecraft.init.Blocks; import net.minecraft.item.Item; @@ -21,42 +22,36 @@ public class TileEnderEye extends TileMod { - @Override - public void updateEntity() { - int meta = getBlockMetadata(); - int range = 80; - List players = worldObj.getEntitiesWithinAABB( - EntityPlayer.class, - AxisAlignedBB.getBoundingBox( - xCoord - range, - yCoord - range, - zCoord - range, - xCoord + range, - yCoord + range, - zCoord + range)); - - boolean looking = false; - for (EntityPlayer player : players) { - ItemStack helm = player.getCurrentArmor(3); - if (helm != null && helm.getItem() == Item.getItemFromBlock(Blocks.pumpkin)) continue; - - MovingObjectPosition pos = ToolCommons.raytraceFromEntity(worldObj, player, true, 64); - if (pos != null && pos.blockX == xCoord && pos.blockY == yCoord && pos.blockZ == zCoord) { - looking = true; - break; - } - } - - int newMeta = looking ? 15 : 0; - if (newMeta != meta && !worldObj.isRemote) - worldObj.setBlockMetadataWithNotify(xCoord, yCoord, zCoord, newMeta, 1 | 2); - - if (looking) { - double x = xCoord - 0.1 + Math.random() * 1.2; - double y = yCoord - 0.1 + Math.random() * 1.2; - double z = zCoord - 0.1 + Math.random() * 1.2; - - worldObj.spawnParticle("reddust", x, y, z, 1, 0, 0); - } - } + @Override + public void updateEntity() { + int meta = getBlockMetadata(); + int range = 80; + List players = worldObj.getEntitiesWithinAABB(EntityPlayer.class, AxisAlignedBB.getBoundingBox(xCoord - range, yCoord - range, zCoord - range, xCoord + range, yCoord + range, zCoord + range)); + + boolean looking = false; + for(EntityPlayer player : players) { + ItemStack helm = player.getCurrentArmor(3); + if(helm != null && helm.getItem() == Item.getItemFromBlock(Blocks.pumpkin)) + continue; + + MovingObjectPosition pos = ToolCommons.raytraceFromEntity(worldObj, player, true, 64); + if(pos != null && pos.blockX == xCoord && pos.blockY == yCoord && pos.blockZ == zCoord) { + looking = true; + break; + } + } + + int newMeta = looking ? 15 : 0; + if(newMeta != meta && !worldObj.isRemote) + worldObj.setBlockMetadataWithNotify(xCoord, yCoord, zCoord, newMeta, 1 | 2); + + if(looking) { + double x = xCoord - 0.1 + Math.random() * 1.2; + double y = yCoord - 0.1 + Math.random() * 1.2; + double z = zCoord - 0.1 + Math.random() * 1.2; + + worldObj.spawnParticle("reddust", x, y, z, 1, 0, 0); + } + } + } diff --git a/src/main/java/vazkii/botania/common/block/tile/TileFakeAir.java b/src/main/java/vazkii/botania/common/block/tile/TileFakeAir.java index e6fff737d9..cc82c96195 100644 --- a/src/main/java/vazkii/botania/common/block/tile/TileFakeAir.java +++ b/src/main/java/vazkii/botania/common/block/tile/TileFakeAir.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Apr 10, 2015, 10:24:48 PM (GMT)] */ package vazkii.botania.common.block.tile; @@ -16,40 +16,41 @@ public class TileFakeAir extends TileMod { - private static final String TAG_FLOWER_X = "flowerX"; - private static final String TAG_FLOWER_Y = "flowerY"; - private static final String TAG_FLOWER_Z = "flowerZ"; - - int flowerX, flowerY, flowerZ; - - @Override - public boolean canUpdate() { - return false; - } - - public void setFlower(TileEntity tile) { - flowerX = tile.xCoord; - flowerY = tile.yCoord; - flowerZ = tile.zCoord; - } - - public boolean canStay() { - return SubTileBubbell.isValidBubbell(worldObj, flowerX, flowerY, flowerZ); - } - - @Override - public void writeToNBT(NBTTagCompound par1nbtTagCompound) { - super.writeToNBT(par1nbtTagCompound); - par1nbtTagCompound.setInteger(TAG_FLOWER_X, flowerX); - par1nbtTagCompound.setInteger(TAG_FLOWER_Y, flowerY); - par1nbtTagCompound.setInteger(TAG_FLOWER_Z, flowerZ); - } - - @Override - public void readFromNBT(NBTTagCompound par1nbtTagCompound) { - super.readFromNBT(par1nbtTagCompound); - flowerX = par1nbtTagCompound.getInteger(TAG_FLOWER_X); - flowerY = par1nbtTagCompound.getInteger(TAG_FLOWER_Y); - flowerZ = par1nbtTagCompound.getInteger(TAG_FLOWER_Z); - } + private static final String TAG_FLOWER_X = "flowerX"; + private static final String TAG_FLOWER_Y = "flowerY"; + private static final String TAG_FLOWER_Z = "flowerZ"; + + int flowerX, flowerY, flowerZ; + + @Override + public boolean canUpdate() { + return false; + } + + public void setFlower(TileEntity tile) { + flowerX = tile.xCoord; + flowerY = tile.yCoord; + flowerZ = tile.zCoord; + } + + public boolean canStay() { + return SubTileBubbell.isValidBubbell(worldObj, flowerX, flowerY, flowerZ); + } + + @Override + public void writeToNBT(NBTTagCompound par1nbtTagCompound) { + super.writeToNBT(par1nbtTagCompound); + par1nbtTagCompound.setInteger(TAG_FLOWER_X, flowerX); + par1nbtTagCompound.setInteger(TAG_FLOWER_Y, flowerY); + par1nbtTagCompound.setInteger(TAG_FLOWER_Z, flowerZ); + } + + @Override + public void readFromNBT(NBTTagCompound par1nbtTagCompound) { + super.readFromNBT(par1nbtTagCompound); + flowerX = par1nbtTagCompound.getInteger(TAG_FLOWER_X); + flowerY = par1nbtTagCompound.getInteger(TAG_FLOWER_Y); + flowerZ = par1nbtTagCompound.getInteger(TAG_FLOWER_Z); + } + } diff --git a/src/main/java/vazkii/botania/common/block/tile/TileFloatingFlower.java b/src/main/java/vazkii/botania/common/block/tile/TileFloatingFlower.java index 1299b26de5..03f4c4b696 100644 --- a/src/main/java/vazkii/botania/common/block/tile/TileFloatingFlower.java +++ b/src/main/java/vazkii/botania/common/block/tile/TileFloatingFlower.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jul 8, 2014, 10:17:28 PM (GMT)] */ package vazkii.botania.common.block.tile; @@ -17,43 +17,44 @@ public class TileFloatingFlower extends TileMod implements IFloatingFlower { - public static final String TAG_ISLAND_TYPE = "islandType"; - public static ItemStack forcedStack = null; - IslandType type = IslandType.GRASS; - - @Override - public ItemStack getDisplayStack() { - if (forcedStack != null) { - ItemStack retStack = forcedStack; - forcedStack = null; - return retStack; - } - - return new ItemStack(ModBlocks.shinyFlower, 1, getBlockMetadata()); - } - - @Override - public boolean canUpdate() { - return false; - } - - @Override - public IslandType getIslandType() { - return type; - } - - @Override - public void setIslandType(IslandType type) { - this.type = type; - } - - @Override - public void writeCustomNBT(NBTTagCompound cmp) { - cmp.setString(TAG_ISLAND_TYPE, type.toString()); - } - - @Override - public void readCustomNBT(NBTTagCompound cmp) { - type = IslandType.ofType(cmp.getString(TAG_ISLAND_TYPE)); - } + public static final String TAG_ISLAND_TYPE = "islandType"; + public static ItemStack forcedStack = null; + IslandType type = IslandType.GRASS; + + @Override + public ItemStack getDisplayStack() { + if(forcedStack != null) { + ItemStack retStack = forcedStack; + forcedStack = null; + return retStack; + } + + return new ItemStack(ModBlocks.shinyFlower, 1, getBlockMetadata()); + } + + @Override + public boolean canUpdate() { + return false; + } + + @Override + public IslandType getIslandType() { + return type; + } + + @Override + public void setIslandType(IslandType type) { + this.type = type; + } + + @Override + public void writeCustomNBT(NBTTagCompound cmp) { + cmp.setString(TAG_ISLAND_TYPE, type.toString()); + } + + @Override + public void readCustomNBT(NBTTagCompound cmp) { + type = IslandType.ofType(cmp.getString(TAG_ISLAND_TYPE)); + } + } diff --git a/src/main/java/vazkii/botania/common/block/tile/TileFloatingSpecialFlower.java b/src/main/java/vazkii/botania/common/block/tile/TileFloatingSpecialFlower.java index cd219e527e..9e6fce1680 100644 --- a/src/main/java/vazkii/botania/common/block/tile/TileFloatingSpecialFlower.java +++ b/src/main/java/vazkii/botania/common/block/tile/TileFloatingSpecialFlower.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Nov 17, 2014, 5:41:58 PM (GMT)] */ package vazkii.botania.common.block.tile; @@ -17,46 +17,49 @@ public class TileFloatingSpecialFlower extends TileSpecialFlower implements IFloatingFlower { - public static final String TAG_ISLAND_TYPE = "islandType"; - IslandType type = IslandType.GRASS; - - @Override - public boolean isOnSpecialSoil() { - return false; - } - - @Override - public ItemStack getDisplayStack() { - return ItemBlockSpecialFlower.ofType(subTileName); - } - - @Override - public IslandType getIslandType() { - return type; - } - - @Override - public void setIslandType(IslandType type) { - this.type = type; - } - - @Override - public void writeCustomNBT(NBTTagCompound cmp) { - super.writeCustomNBT(cmp); - cmp.setString(TAG_ISLAND_TYPE, type.toString()); - } - - @Override - public void readCustomNBT(NBTTagCompound cmp) { - super.readCustomNBT(cmp); - type = IslandType.ofType(cmp.getString(TAG_ISLAND_TYPE)); - } - - @Override - public int getSlowdownFactor() { - IslandType type = getIslandType(); - if (type == IslandType.MYCEL) return SLOWDOWN_FACTOR_MYCEL; - else if (type == IslandType.PODZOL) return SLOWDOWN_FACTOR_PODZOL; - return 0; - } + public static final String TAG_ISLAND_TYPE = "islandType"; + IslandType type = IslandType.GRASS; + + @Override + public boolean isOnSpecialSoil() { + return false; + } + + @Override + public ItemStack getDisplayStack() { + return ItemBlockSpecialFlower.ofType(subTileName); + } + + @Override + public IslandType getIslandType() { + return type; + } + + @Override + public void setIslandType(IslandType type) { + this.type = type; + } + + @Override + public void writeCustomNBT(NBTTagCompound cmp) { + super.writeCustomNBT(cmp); + cmp.setString(TAG_ISLAND_TYPE, type.toString()); + } + + @Override + public void readCustomNBT(NBTTagCompound cmp) { + super.readCustomNBT(cmp); + type = IslandType.ofType(cmp.getString(TAG_ISLAND_TYPE)); + } + + @Override + public int getSlowdownFactor() { + IslandType type = getIslandType(); + if (type == IslandType.MYCEL) + return SLOWDOWN_FACTOR_MYCEL; + else if (type == IslandType.PODZOL) + return SLOWDOWN_FACTOR_PODZOL; + return 0; + } + } diff --git a/src/main/java/vazkii/botania/common/block/tile/TileForestEye.java b/src/main/java/vazkii/botania/common/block/tile/TileForestEye.java index 49d5aa57df..9f0e63c8f5 100644 --- a/src/main/java/vazkii/botania/common/block/tile/TileForestEye.java +++ b/src/main/java/vazkii/botania/common/block/tile/TileForestEye.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [May 10, 2014, 5:50:01 PM (GMT)] */ package vazkii.botania.common.block.tile; @@ -15,24 +15,16 @@ public class TileForestEye extends TileMod { - public int entities = 0; + public int entities = 0; + + @Override + public void updateEntity() { + int range = 6; + int entityCount = worldObj.getEntitiesWithinAABB(EntityAnimal.class, AxisAlignedBB.getBoundingBox(xCoord - range, yCoord - range, zCoord - range, xCoord + range + 1, yCoord + range + 1, zCoord + range + 1)).size(); + if(entityCount != entities) { + entities = entityCount; + worldObj.func_147453_f(xCoord, yCoord, zCoord, worldObj.getBlock(xCoord, yCoord, zCoord)); + } + } - @Override - public void updateEntity() { - int range = 6; - int entityCount = worldObj.getEntitiesWithinAABB( - EntityAnimal.class, - AxisAlignedBB.getBoundingBox( - xCoord - range, - yCoord - range, - zCoord - range, - xCoord + range + 1, - yCoord + range + 1, - zCoord + range + 1)) - .size(); - if (entityCount != entities) { - entities = entityCount; - worldObj.func_147453_f(xCoord, yCoord, zCoord, worldObj.getBlock(xCoord, yCoord, zCoord)); - } - } } diff --git a/src/main/java/vazkii/botania/common/block/tile/TileGaiaHead.java b/src/main/java/vazkii/botania/common/block/tile/TileGaiaHead.java index a665ed76cd..6d705d90a8 100644 --- a/src/main/java/vazkii/botania/common/block/tile/TileGaiaHead.java +++ b/src/main/java/vazkii/botania/common/block/tile/TileGaiaHead.java @@ -2,14 +2,16 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Sep 23, 2015, 11:47:40 PM (GMT)] */ package vazkii.botania.common.block.tile; import net.minecraft.tileentity.TileEntitySkull; -public class TileGaiaHead extends TileEntitySkull {} +public class TileGaiaHead extends TileEntitySkull { + +} diff --git a/src/main/java/vazkii/botania/common/block/tile/TileHourglass.java b/src/main/java/vazkii/botania/common/block/tile/TileHourglass.java index 78c7c0a0a1..f182076216 100644 --- a/src/main/java/vazkii/botania/common/block/tile/TileHourglass.java +++ b/src/main/java/vazkii/botania/common/block/tile/TileHourglass.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [May 29, 2015, 8:21:17 PM (GMT)] */ package vazkii.botania.common.block.tile; @@ -20,145 +20,158 @@ import net.minecraft.nbt.NBTTagCompound; import net.minecraft.util.StatCollector; import net.minecraft.util.StringUtils; + import org.lwjgl.opengl.GL11; import org.lwjgl.opengl.GL12; + import vazkii.botania.api.internal.VanillaPacketDispatcher; import vazkii.botania.common.lib.LibBlockNames; public class TileHourglass extends TileSimpleInventory { - private static final String TAG_TIME = "time"; - private static final String TAG_TIME_FRACTION = "timeFraction"; - private static final String TAG_FLIP = "flip"; - private static final String TAG_FLIP_TICKS = "flipTicks"; - private static final String TAG_LOCK = "lock"; - private static final String TAG_MOVE = "move"; - - int time = 0; - public float timeFraction = 0F; - public boolean flip = false; - public int flipTicks = 0; - public boolean lock = false; - public boolean move = true; - - @Override - public void updateEntity() { - super.updateEntity(); - - int totalTime = getTotalTime(); - if (totalTime > 0) { - if (move) time++; - if (time >= totalTime) { - time = 0; - flip = !flip; - flipTicks = 4; - worldObj.setBlockMetadataWithNotify(xCoord, yCoord, zCoord, 1, 1 | 2); - worldObj.scheduleBlockUpdate( - xCoord, yCoord, zCoord, getBlockType(), getBlockType().tickRate(worldObj)); - } - timeFraction = (float) time / (float) totalTime; - } else { - time = 0; - timeFraction = 0F; - } - - if (flipTicks > 0) flipTicks--; - } - - public int getTotalTime() { - ItemStack stack = getStackInSlot(0); - if (stack == null) return 0; - - return getStackItemTime(stack) * stack.stackSize; - } - - public static int getStackItemTime(ItemStack stack) { - if (stack == null) return 0; - if (stack.getItem() == Item.getItemFromBlock(Blocks.sand)) return stack.getItemDamage() == 1 ? 200 : 20; - if (stack.getItem() == Item.getItemFromBlock(Blocks.soul_sand)) return 1200; - return 0; - } - - public int getColor() { - ItemStack stack = getStackInSlot(0); - if (stack == null) return 0; - if (stack.getItem() == Item.getItemFromBlock(Blocks.sand)) - return stack.getItemDamage() == 1 ? 0xE95800 : 0xFFEC49; - if (stack.getItem() == Item.getItemFromBlock(Blocks.soul_sand)) return 0x5A412f; - return 0; - } - - @Override - public boolean isItemValidForSlot(int i, ItemStack itemstack) { - if (itemstack == null) return false; - Item item = itemstack.getItem(); - return item == Item.getItemFromBlock(Blocks.sand) || item == Item.getItemFromBlock(Blocks.soul_sand); - } - - @Override - public void writeCustomNBT(NBTTagCompound par1nbtTagCompound) { - super.writeCustomNBT(par1nbtTagCompound); - par1nbtTagCompound.setInteger(TAG_TIME, time); - par1nbtTagCompound.setFloat(TAG_TIME_FRACTION, timeFraction); - par1nbtTagCompound.setBoolean(TAG_FLIP, flip); - par1nbtTagCompound.setInteger(TAG_FLIP_TICKS, flipTicks); - par1nbtTagCompound.setBoolean(TAG_MOVE, move); - par1nbtTagCompound.setBoolean(TAG_LOCK, lock); - } - - @Override - public void readCustomNBT(NBTTagCompound par1nbtTagCompound) { - super.readCustomNBT(par1nbtTagCompound); - time = par1nbtTagCompound.getInteger(TAG_TIME); - timeFraction = par1nbtTagCompound.getFloat(TAG_TIME_FRACTION); - flip = par1nbtTagCompound.getBoolean(TAG_FLIP); - flipTicks = par1nbtTagCompound.getInteger(TAG_FLIP_TICKS); - move = par1nbtTagCompound.getBoolean(TAG_MOVE); - lock = par1nbtTagCompound.getBoolean(TAG_LOCK); - } - - @Override - public int getSizeInventory() { - return 1; - } - - @Override - public void markDirty() { - super.markDirty(); - time = 0; - timeFraction = 0F; - VanillaPacketDispatcher.dispatchTEToNearbyPlayers(this); - } - - public void renderHUD(ScaledResolution res) { - Minecraft mc = Minecraft.getMinecraft(); - int x = res.getScaledWidth() / 2 + 10; - int y = res.getScaledHeight() / 2 - 10; - - ItemStack stack = getStackInSlot(0); - if (stack != null) { - RenderHelper.enableGUIStandardItemLighting(); - GL11.glEnable(GL12.GL_RESCALE_NORMAL); - RenderItem.getInstance().renderItemIntoGUI(mc.fontRenderer, mc.renderEngine, stack, x, y); - RenderItem.getInstance().renderItemOverlayIntoGUI(mc.fontRenderer, mc.renderEngine, stack, x, y); - GL11.glDisable(GL12.GL_RESCALE_NORMAL); - RenderHelper.disableStandardItemLighting(); - - int time = getTotalTime(); - String timeStr = StringUtils.ticksToElapsedTime(time); - mc.fontRenderer.drawStringWithShadow(timeStr, x + 20, y, getColor()); - - String status = ""; - if (lock) status = "locked"; - if (!move) status = status.isEmpty() ? "stopped" : "lockedStopped"; - if (!status.isEmpty()) - mc.fontRenderer.drawStringWithShadow( - StatCollector.translateToLocal("botaniamisc." + status), x + 20, y + 12, getColor()); - } - } - - @Override - public String getInventoryName() { - return LibBlockNames.HOURGLASS; - } + private static final String TAG_TIME = "time"; + private static final String TAG_TIME_FRACTION = "timeFraction"; + private static final String TAG_FLIP = "flip"; + private static final String TAG_FLIP_TICKS = "flipTicks"; + private static final String TAG_LOCK = "lock"; + private static final String TAG_MOVE = "move"; + + int time = 0; + public float timeFraction = 0F; + public boolean flip = false; + public int flipTicks = 0; + public boolean lock = false; + public boolean move = true; + + @Override + public void updateEntity() { + super.updateEntity(); + + int totalTime = getTotalTime(); + if(totalTime > 0) { + if(move) + time++; + if(time >= totalTime) { + time = 0; + flip = !flip; + flipTicks = 4; + worldObj.setBlockMetadataWithNotify(xCoord, yCoord, zCoord, 1, 1 | 2); + worldObj.scheduleBlockUpdate(xCoord, yCoord, zCoord, getBlockType(), getBlockType().tickRate(worldObj)); + } + timeFraction = (float) time / (float) totalTime; + } else { + time = 0; + timeFraction = 0F; + } + + if(flipTicks > 0) + flipTicks--; + } + + public int getTotalTime() { + ItemStack stack = getStackInSlot(0); + if(stack == null) + return 0; + + return getStackItemTime(stack) * stack.stackSize; + } + + public static int getStackItemTime(ItemStack stack) { + if(stack == null) + return 0; + if(stack.getItem() == Item.getItemFromBlock(Blocks.sand)) + return stack.getItemDamage() == 1 ? 200 : 20; + if(stack.getItem() == Item.getItemFromBlock(Blocks.soul_sand)) + return 1200; + return 0; + } + + public int getColor() { + ItemStack stack = getStackInSlot(0); + if(stack == null) + return 0; + if(stack.getItem() == Item.getItemFromBlock(Blocks.sand)) + return stack.getItemDamage() == 1 ? 0xE95800 : 0xFFEC49; + if(stack.getItem() == Item.getItemFromBlock(Blocks.soul_sand)) + return 0x5A412f; + return 0; + } + + @Override + public boolean isItemValidForSlot(int i, ItemStack itemstack) { + if(itemstack == null) + return false; + Item item = itemstack.getItem(); + return item == Item.getItemFromBlock(Blocks.sand) || item == Item.getItemFromBlock(Blocks.soul_sand); + } + + @Override + public void writeCustomNBT(NBTTagCompound par1nbtTagCompound) { + super.writeCustomNBT(par1nbtTagCompound); + par1nbtTagCompound.setInteger(TAG_TIME, time); + par1nbtTagCompound.setFloat(TAG_TIME_FRACTION, timeFraction); + par1nbtTagCompound.setBoolean(TAG_FLIP, flip); + par1nbtTagCompound.setInteger(TAG_FLIP_TICKS, flipTicks); + par1nbtTagCompound.setBoolean(TAG_MOVE, move); + par1nbtTagCompound.setBoolean(TAG_LOCK, lock); + } + + @Override + public void readCustomNBT(NBTTagCompound par1nbtTagCompound) { + super.readCustomNBT(par1nbtTagCompound); + time = par1nbtTagCompound.getInteger(TAG_TIME); + timeFraction = par1nbtTagCompound.getFloat(TAG_TIME_FRACTION); + flip = par1nbtTagCompound.getBoolean(TAG_FLIP); + flipTicks = par1nbtTagCompound.getInteger(TAG_FLIP_TICKS); + move = par1nbtTagCompound.getBoolean(TAG_MOVE); + lock = par1nbtTagCompound.getBoolean(TAG_LOCK); + } + + @Override + public int getSizeInventory() { + return 1; + } + + @Override + public void markDirty() { + super.markDirty(); + time = 0; + timeFraction = 0F; + VanillaPacketDispatcher.dispatchTEToNearbyPlayers(this); + } + + public void renderHUD(ScaledResolution res) { + Minecraft mc = Minecraft.getMinecraft(); + int x = res.getScaledWidth() / 2 + 10; + int y = res.getScaledHeight() / 2 - 10; + + ItemStack stack = getStackInSlot(0); + if(stack != null) { + RenderHelper.enableGUIStandardItemLighting(); + GL11.glEnable(GL12.GL_RESCALE_NORMAL); + RenderItem.getInstance().renderItemIntoGUI(mc.fontRenderer, mc.renderEngine, stack, x, y); + RenderItem.getInstance().renderItemOverlayIntoGUI(mc.fontRenderer, mc.renderEngine, stack, x, y); + GL11.glDisable(GL12.GL_RESCALE_NORMAL); + RenderHelper.disableStandardItemLighting(); + + int time = getTotalTime(); + String timeStr = StringUtils.ticksToElapsedTime(time); + mc.fontRenderer.drawStringWithShadow(timeStr, x + 20, y, getColor()); + + String status = ""; + if(lock) + status = "locked"; + if(!move) + status = status.isEmpty() ? "stopped" : "lockedStopped"; + if(!status.isEmpty()) + mc.fontRenderer.drawStringWithShadow(StatCollector.translateToLocal("botaniamisc." + status), x + 20, y + 12, getColor()); + } + + } + + @Override + public String getInventoryName() { + return LibBlockNames.HOURGLASS; + } + } diff --git a/src/main/java/vazkii/botania/common/block/tile/TileIncensePlate.java b/src/main/java/vazkii/botania/common/block/tile/TileIncensePlate.java index 33303703e6..133ad72ad5 100644 --- a/src/main/java/vazkii/botania/common/block/tile/TileIncensePlate.java +++ b/src/main/java/vazkii/botania/common/block/tile/TileIncensePlate.java @@ -2,16 +2,17 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [May 15, 2015, 4:09:07 PM (GMT)] */ package vazkii.botania.common.block.tile; import java.awt.Color; import java.util.List; + import net.minecraft.entity.player.EntityPlayer; import net.minecraft.inventory.ISidedInventory; import net.minecraft.item.ItemStack; @@ -29,153 +30,124 @@ public class TileIncensePlate extends TileSimpleInventory implements ISidedInventory { - private static final String TAG_TIME_LEFT = "timeLeft"; - private static final String TAG_BURNING = "burning"; - private static final int RANGE = 32; - - public int timeLeft = 0; - public boolean burning = false; - - public int comparatorOutput = 0; - - @Override - public void updateEntity() { - ItemStack stack = getStackInSlot(0); - if (stack != null && burning) { - Brew brew = ((ItemIncenseStick) ModItems.incenseStick).getBrew(stack); - PotionEffect effect = brew.getPotionEffects(stack).get(0); - if (timeLeft > 0) { - timeLeft--; - if (!worldObj.isRemote) { - List players = worldObj.getEntitiesWithinAABB( - EntityPlayer.class, - AxisAlignedBB.getBoundingBox( - xCoord + 0.5 - RANGE, - yCoord + 0.5 - RANGE, - zCoord + 0.5 - RANGE, - xCoord + 0.5 + RANGE, - yCoord + 0.5 + RANGE, - zCoord + 0.5 + RANGE)); - for (EntityPlayer player : players) { - PotionEffect currentEffect = - player.getActivePotionEffect(Potion.potionTypes[effect.getPotionID()]); - boolean nightVision = effect.getPotionID() == Potion.nightVision.id; - if (currentEffect == null || currentEffect.getDuration() < (nightVision ? 205 : 3)) { - PotionEffect applyEffect = new PotionEffect( - effect.getPotionID(), nightVision ? 285 : 80, effect.getAmplifier(), true); - player.addPotionEffect(applyEffect); - } - } - - if (worldObj.rand.nextInt(20) == 0) - worldObj.playSoundEffect(xCoord + 0.5, yCoord + 0.1, zCoord + 0.5, "fire.fire", 0.1F, 1F); - } else { - double x = xCoord + 0.5; - double y = yCoord + 0.5; - double z = zCoord + 0.5; - Color color = new Color(brew.getColor(stack)); - float r = color.getRed() / 255F; - float g = color.getGreen() / 255F; - float b = color.getBlue() / 255F; - Botania.proxy.wispFX( - worldObj, - x - (Math.random() - 0.5) * 0.2, - y - (Math.random() - 0.5) * 0.2, - z - (Math.random() - 0.5) * 0.2, - r, - g, - b, - 0.05F + (float) Math.random() * 0.02F, - 0.005F - (float) Math.random() * 0.01F, - 0.01F + (float) Math.random() * 0.005F, - 0.005F - (float) Math.random() * 0.01F); - Botania.proxy.wispFX( - worldObj, - x - (Math.random() - 0.5) * 0.2, - y - (Math.random() - 0.5) * 0.2, - z - (Math.random() - 0.5) * 0.2, - 0.2F, - 0.2F, - 0.2F, - 0.05F + (float) Math.random() * 0.02F, - 0.005F - (float) Math.random() * 0.01F, - 0.01F + (float) Math.random() * 0.001F, - 0.005F - (float) Math.random() * 0.01F); - } - } else { - setInventorySlotContents(0, null); - burning = false; - VanillaPacketDispatcher.dispatchTEToNearbyPlayers(this); - } - } else timeLeft = 0; - - int newComparator = 0; - if (stack != null) newComparator = 1; - if (burning) newComparator = 2; - if (comparatorOutput != newComparator) { - comparatorOutput = newComparator; - worldObj.func_147453_f(xCoord, yCoord, zCoord, worldObj.getBlock(xCoord, yCoord, zCoord)); - } - } - - public void ignite() { - ItemStack stack = getStackInSlot(0); - if (stack == null || burning) return; - - burning = true; - Brew brew = ((ItemIncenseStick) ModItems.incenseStick).getBrew(stack); - timeLeft = brew.getPotionEffects(stack).get(0).getDuration() * ItemIncenseStick.TIME_MULTIPLIER; - } - - @Override - public int getSizeInventory() { - return 1; - } - - @Override - public String getInventoryName() { - return LibBlockNames.INCENSE_PLATE; - } - - @Override - public void writeCustomNBT(NBTTagCompound par1nbtTagCompound) { - super.writeCustomNBT(par1nbtTagCompound); - par1nbtTagCompound.setInteger(TAG_TIME_LEFT, timeLeft); - par1nbtTagCompound.setBoolean(TAG_BURNING, burning); - } - - @Override - public void readCustomNBT(NBTTagCompound par1nbtTagCompound) { - super.readCustomNBT(par1nbtTagCompound); - timeLeft = par1nbtTagCompound.getInteger(TAG_TIME_LEFT); - burning = par1nbtTagCompound.getBoolean(TAG_BURNING); - } - - @Override - public boolean isItemValidForSlot(int i, ItemStack itemstack) { - return itemstack != null - && itemstack.getItem() == ModItems.incenseStick - && ((ItemIncenseStick) ModItems.incenseStick).getBrew(itemstack) != BotaniaAPI.fallbackBrew; - } - - @Override - public int[] getAccessibleSlotsFromSide(int side) { - return new int[] {0}; - } - - @Override - public boolean canInsertItem(int slot, ItemStack stack, int side) { - return isItemValidForSlot(slot, stack); - } - - @Override - public boolean canExtractItem(int p_102008_1_, ItemStack p_102008_2_, int p_102008_3_) { - return false; - } - - @Override - public void markDirty() { - super.markDirty(); - if (!worldObj.isRemote) VanillaPacketDispatcher.dispatchTEToNearbyPlayers(this); - } + private static final String TAG_TIME_LEFT = "timeLeft"; + private static final String TAG_BURNING = "burning"; + private static final int RANGE = 32; + + public int timeLeft = 0; + public boolean burning = false; + + public int comparatorOutput = 0; + + @Override + public void updateEntity() { + ItemStack stack = getStackInSlot(0); + if(stack != null && burning) { + Brew brew = ((ItemIncenseStick) ModItems.incenseStick).getBrew(stack); + PotionEffect effect = brew.getPotionEffects(stack).get(0); + if(timeLeft > 0) { + timeLeft--; + if(!worldObj.isRemote) { + List players = worldObj.getEntitiesWithinAABB(EntityPlayer.class, AxisAlignedBB.getBoundingBox(xCoord + 0.5 - RANGE, yCoord + 0.5 - RANGE, zCoord + 0.5 - RANGE, xCoord + 0.5 + RANGE, yCoord + 0.5 + RANGE, zCoord + 0.5 + RANGE)); + for(EntityPlayer player : players) { + PotionEffect currentEffect = player.getActivePotionEffect(Potion.potionTypes[effect.getPotionID()]); + boolean nightVision = effect.getPotionID() == Potion.nightVision.id; + if(currentEffect == null || currentEffect.getDuration() < (nightVision ? 205 : 3)) { + PotionEffect applyEffect = new PotionEffect(effect.getPotionID(), nightVision ? 285 : 80, effect.getAmplifier(), true); + player.addPotionEffect(applyEffect); + } + } + + if(worldObj.rand.nextInt(20) == 0) + worldObj.playSoundEffect(xCoord + 0.5, yCoord + 0.1, zCoord + 0.5, "fire.fire", 0.1F, 1F); + } else { + double x = xCoord + 0.5; + double y = yCoord + 0.5; + double z = zCoord + 0.5; + Color color = new Color(brew.getColor(stack)); + float r = color.getRed() / 255F; + float g = color.getGreen() / 255F; + float b = color.getBlue() / 255F; + Botania.proxy.wispFX(worldObj, x - (Math.random() - 0.5) * 0.2, y - (Math.random() - 0.5) * 0.2, z - (Math.random() - 0.5) * 0.2, r, g, b, 0.05F + (float) Math.random() * 0.02F, 0.005F - (float) Math.random() * 0.01F, 0.01F + (float) Math.random() * 0.005F, 0.005F - (float) Math.random() * 0.01F); + Botania.proxy.wispFX(worldObj, x - (Math.random() - 0.5) * 0.2, y - (Math.random() - 0.5) * 0.2, z - (Math.random() - 0.5) * 0.2, 0.2F, 0.2F, 0.2F, 0.05F + (float) Math.random() * 0.02F, 0.005F - (float) Math.random() * 0.01F, 0.01F + (float) Math.random() * 0.001F, 0.005F - (float) Math.random() * 0.01F); + } + } else { + setInventorySlotContents(0, null); + burning = false; + VanillaPacketDispatcher.dispatchTEToNearbyPlayers(this); + } + } else timeLeft = 0; + + int newComparator = 0; + if(stack != null) + newComparator = 1; + if(burning) + newComparator = 2; + if(comparatorOutput != newComparator) { + comparatorOutput = newComparator; + worldObj.func_147453_f(xCoord, yCoord, zCoord, worldObj.getBlock(xCoord, yCoord, zCoord)); + } + } + + public void ignite() { + ItemStack stack = getStackInSlot(0); + if(stack == null || burning) + return; + + burning = true; + Brew brew = ((ItemIncenseStick) ModItems.incenseStick).getBrew(stack); + timeLeft = brew.getPotionEffects(stack).get(0).getDuration() * ItemIncenseStick.TIME_MULTIPLIER; + } + + @Override + public int getSizeInventory() { + return 1; + } + + @Override + public String getInventoryName() { + return LibBlockNames.INCENSE_PLATE; + } + + @Override + public void writeCustomNBT(NBTTagCompound par1nbtTagCompound) { + super.writeCustomNBT(par1nbtTagCompound); + par1nbtTagCompound.setInteger(TAG_TIME_LEFT, timeLeft); + par1nbtTagCompound.setBoolean(TAG_BURNING, burning); + } + + @Override + public void readCustomNBT(NBTTagCompound par1nbtTagCompound) { + super.readCustomNBT(par1nbtTagCompound); + timeLeft = par1nbtTagCompound.getInteger(TAG_TIME_LEFT); + burning = par1nbtTagCompound.getBoolean(TAG_BURNING); + } + + @Override + public boolean isItemValidForSlot(int i, ItemStack itemstack) { + return itemstack != null && itemstack.getItem() == ModItems.incenseStick && ((ItemIncenseStick) ModItems.incenseStick).getBrew(itemstack) != BotaniaAPI.fallbackBrew; + } + + @Override + public int[] getAccessibleSlotsFromSide(int side) { + return new int[] { 0 }; + } + + @Override + public boolean canInsertItem(int slot, ItemStack stack, int side) { + return isItemValidForSlot(slot, stack); + } + + @Override + public boolean canExtractItem(int p_102008_1_, ItemStack p_102008_2_, int p_102008_3_) { + return false; + } + + @Override + public void markDirty() { + super.markDirty(); + if(!worldObj.isRemote) + VanillaPacketDispatcher.dispatchTEToNearbyPlayers(this); + } + } diff --git a/src/main/java/vazkii/botania/common/block/tile/TileLightRelay.java b/src/main/java/vazkii/botania/common/block/tile/TileLightRelay.java index 3bc6be2024..063526503e 100644 --- a/src/main/java/vazkii/botania/common/block/tile/TileLightRelay.java +++ b/src/main/java/vazkii/botania/common/block/tile/TileLightRelay.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jul 15, 2015, 8:32:04 PM (GMT)] */ package vazkii.botania.common.block.tile; @@ -13,6 +13,7 @@ import java.awt.Color; import java.util.ArrayList; import java.util.List; + import net.minecraft.block.Block; import net.minecraft.entity.Entity; import net.minecraft.entity.item.EntityEnderPearl; @@ -34,305 +35,271 @@ public class TileLightRelay extends TileMod implements IWandBindable { - private static final int MAX_DIST = 20; - - private static final String TAG_BIND_X = "bindX"; - private static final String TAG_BIND_Y = "bindY"; - private static final String TAG_BIND_Z = "bindZ"; - - int bindX, bindY = -1, bindZ; - int ticksElapsed = 0; - - public void mountEntity(Entity e) { - if (e.ridingEntity != null || worldObj.isRemote || bindY == -1 || !isValidBinding()) return; - - EntityPlayerMover mover = new EntityPlayerMover(worldObj, xCoord, yCoord, zCoord, bindX, bindY, bindZ); - worldObj.spawnEntityInWorld(mover); - e.mountEntity(mover); - if (!(e instanceof EntityItem)) { - worldObj.playSoundAtEntity(mover, "botania:lightRelay", 0.2F, (float) Math.random() * 0.3F + 0.7F); - if (e instanceof EntityPlayer) ((EntityPlayer) e).addStat(ModAchievements.luminizerRide, 1); - } - } - - @Override - public void updateEntity() { - ticksElapsed++; - - if (bindY > -1 && isValidBinding()) { - Vector3 vec = getMovementVector(); - - double dist = 0.1; - int size = (int) (vec.mag() / dist); - int count = 10; - int start = ticksElapsed % size; - - Vector3 vecMag = vec.copy().normalize().multiply(dist); - Vector3 vecTip = vecMag.copy().multiply(start).add(xCoord + 0.5, yCoord + 0.5, zCoord + 0.5); - - double radPer = Math.PI / 16.0; - float mul = 0.5F; - float mulPer = 0.4F; - float maxMul = 2; - for (int i = start; i < start + count; i++) { - mul = Math.min(maxMul, mul + mulPer); - double rad = radPer * (i + ticksElapsed * 0.4); - Vector3 vecRot = vecMag.copy() - .crossProduct(Vector3.one) - .multiply(mul) - .rotate(rad, vecMag) - .add(vecTip); - Botania.proxy.wispFX( - worldObj, - vecRot.x, - vecRot.y, - vecRot.z, - 0.4F, - 0.4F, - 1F, - 0.1F, - (float) -vecMag.x, - (float) -vecMag.y, - (float) -vecMag.z, - 1F); - vecTip.add(vecMag); - } - - ChunkCoordinates endpoint = getEndpoint(); - if (endpoint != null && !worldObj.isRemote) { - float range = 0.5F; - List enderPearls = worldObj.getEntitiesWithinAABB( - EntityEnderPearl.class, - AxisAlignedBB.getBoundingBox( - xCoord - range, - yCoord - range, - zCoord - range, - xCoord + 1 + range, - yCoord + 1 + range, - zCoord + 1 + range)); - for (EntityEnderPearl pearl : enderPearls) { - pearl.posX = endpoint.posX + pearl.posX - xCoord; - pearl.posY = endpoint.posY + pearl.posY - yCoord; - pearl.posZ = endpoint.posZ + pearl.posZ - zCoord; - } - } - } - } - - public boolean isValidBinding() { - Block block = worldObj.getBlock(bindX, bindY, bindZ); - return block == ModBlocks.lightRelay; - } - - public ChunkCoordinates getEndpoint() { - List pointsPassed = new ArrayList(); - TileLightRelay relay = this; - ChunkCoordinates lastCoords = null; - - // Doing while(true) gives an unreachable code error - boolean run = true; - while (run) { - if (pointsPassed.contains(relay)) return null; // Circular path - pointsPassed.add(relay); - - ChunkCoordinates coords = relay.getBinding(); - if (coords == null) return lastCoords; - - TileEntity tile = worldObj.getTileEntity(coords.posX, coords.posY, coords.posZ); - if (tile != null && tile instanceof TileLightRelay) relay = (TileLightRelay) tile; - else return lastCoords; - - lastCoords = coords; - } - - return null; - } - - public Vector3 getMovementVector() { - return new Vector3(bindX - xCoord, bindY - yCoord, bindZ - zCoord); - } - - @Override - public ChunkCoordinates getBinding() { - return bindY == -1 ? null : new ChunkCoordinates(bindX, bindY, bindZ); - } - - @Override - public boolean canSelect(EntityPlayer player, ItemStack wand, int x, int y, int z, int side) { - return true; - } - - @Override - public boolean bindTo(EntityPlayer player, ItemStack wand, int x, int y, int z, int side) { - if (player.worldObj.getBlock(x, y, z) != ModBlocks.lightRelay - || MathHelper.pointDistanceSpace(x, y, z, xCoord, yCoord, zCoord) > MAX_DIST) return false; - - bindX = x; - bindY = y; - bindZ = z; - return true; - } - - @Override - public void readCustomNBT(NBTTagCompound cmp) { - bindX = cmp.getInteger(TAG_BIND_X); - bindY = cmp.getInteger(TAG_BIND_Y); - bindZ = cmp.getInteger(TAG_BIND_Z); - } - - @Override - public void writeCustomNBT(NBTTagCompound cmp) { - cmp.setInteger(TAG_BIND_X, bindX); - cmp.setInteger(TAG_BIND_Y, bindY); - cmp.setInteger(TAG_BIND_Z, bindZ); - } - - public static class EntityPlayerMover extends Entity { - - private static final String TAG_EXIT_X = "exitX"; - private static final String TAG_EXIT_Y = "exitY"; - private static final String TAG_EXIT_Z = "exitZ"; - - public EntityPlayerMover(World world) { - super(world); - } - - public EntityPlayerMover(World world, int x, int y, int z, int exitX, int exitY, int exitZ) { - this(world); - setPosition(x + 0.5, y + 0.5, z + 0.5); - setExit(exitX, exitY, exitZ); - } - - @Override - protected void entityInit() { - setSize(0F, 0F); - noClip = true; - - dataWatcher.addObject(20, 0); - dataWatcher.addObject(21, 0); - dataWatcher.addObject(22, 0); - dataWatcher.setObjectWatched(20); - dataWatcher.setObjectWatched(21); - dataWatcher.setObjectWatched(22); - } - - @Override - public void onUpdate() { - super.onUpdate(); - - if (riddenByEntity == null && !worldObj.isRemote) { - setDead(); - return; - } - - boolean isItem = riddenByEntity instanceof EntityItem; - if (!isItem && ticksExisted % 30 == 0) - worldObj.playSoundAtEntity(this, "botania:lightRelay", 0.05F, (float) Math.random() * 0.3F + 0.7F); - - int exitX = getExitX(); - int exitY = getExitY(); - int exitZ = getExitZ(); - - int x = net.minecraft.util.MathHelper.floor_double(posX); - int y = net.minecraft.util.MathHelper.floor_double(posY); - int z = net.minecraft.util.MathHelper.floor_double(posZ); - if (x == exitX && y == exitY && z == exitZ) { - TileEntity tile = worldObj.getTileEntity(x, y, z); - if (tile != null && tile instanceof TileLightRelay) { - int meta = worldObj.getBlockMetadata(x, y, z); - if (meta > 0) { - worldObj.setBlockMetadataWithNotify(x, y, z, meta | 8, 1 | 2); - worldObj.scheduleBlockUpdate( - x, - y, - z, - tile.getBlockType(), - tile.getBlockType().tickRate(worldObj)); - } - - TileLightRelay relay = (TileLightRelay) tile; - ChunkCoordinates bind = relay.getBinding(); - if (bind != null && relay.isValidBinding()) { - setExit(bind.posX, bind.posY, bind.posZ); - return; - } - } - - posY += 1.5; - setDead(); - } else { - Vector3 thisVec = Vector3.fromEntity(this); - Vector3 motVec = thisVec.negate() - .add(exitX + 0.5, exitY + 0.5, exitZ + 0.5) - .normalize() - .multiply(0.5); - - Color color; - - int count = 4; - for (int i = 0; i < count; i++) { - color = Color.getHSBColor(ticksExisted / 36F + 1F / count * i, 1F, 1F); - double rad = Math.PI * 2.0 / count * i + ticksExisted / Math.PI; - double cos = Math.cos(rad); - double sin = Math.sin(rad); - double s = 0.4; - - Botania.proxy.sparkleFX( - worldObj, - posX + cos * s, - posY - 0.5, - posZ + sin * s, - color.getRed() / 255F, - color.getGreen() / 255F, - color.getBlue() / 255F, - 1.2F, - 10); - } - - posX += motVec.x; - posY += motVec.y; - posZ += motVec.z; - } - } - - @Override - public boolean shouldRiderSit() { - return false; - } - - @Override - public boolean attackEntityFrom(DamageSource p_70097_1_, float p_70097_2_) { - return false; - } - - @Override - protected void readEntityFromNBT(NBTTagCompound cmp) { - setExit(cmp.getInteger(TAG_EXIT_X), cmp.getInteger(TAG_EXIT_Y), cmp.getInteger(TAG_EXIT_Z)); - } - - @Override - protected void writeEntityToNBT(NBTTagCompound cmp) { - cmp.setInteger(TAG_EXIT_X, getExitX()); - cmp.setInteger(TAG_EXIT_Y, getExitY()); - cmp.setInteger(TAG_EXIT_Z, getExitZ()); - } - - public int getExitX() { - return dataWatcher.getWatchableObjectInt(20); - } - - public int getExitY() { - return dataWatcher.getWatchableObjectInt(21); - } - - public int getExitZ() { - return dataWatcher.getWatchableObjectInt(22); - } - - public void setExit(int x, int y, int z) { - dataWatcher.updateObject(20, x); - dataWatcher.updateObject(21, y); - dataWatcher.updateObject(22, z); - } - } + private static final int MAX_DIST = 20; + + private static final String TAG_BIND_X = "bindX"; + private static final String TAG_BIND_Y = "bindY"; + private static final String TAG_BIND_Z = "bindZ"; + + int bindX, bindY = -1, bindZ; + int ticksElapsed = 0; + + public void mountEntity(Entity e) { + if(e.ridingEntity != null || worldObj.isRemote || bindY == -1 || !isValidBinding()) + return; + + EntityPlayerMover mover = new EntityPlayerMover(worldObj, xCoord, yCoord, zCoord, bindX, bindY, bindZ); + worldObj.spawnEntityInWorld(mover); + e.mountEntity(mover); + if(!(e instanceof EntityItem)) { + worldObj.playSoundAtEntity(mover, "botania:lightRelay", 0.2F, (float) Math.random() * 0.3F + 0.7F); + if(e instanceof EntityPlayer) + ((EntityPlayer) e).addStat(ModAchievements.luminizerRide, 1); + } + } + + @Override + public void updateEntity() { + ticksElapsed++; + + if(bindY > -1 && isValidBinding()) { + Vector3 vec = getMovementVector(); + + double dist = 0.1; + int size = (int) (vec.mag() / dist); + int count = 10; + int start = ticksElapsed % size; + + Vector3 vecMag = vec.copy().normalize().multiply(dist); + Vector3 vecTip = vecMag.copy().multiply(start).add(xCoord + 0.5, yCoord + 0.5, zCoord + 0.5); + + double radPer = Math.PI / 16.0; + float mul = 0.5F; + float mulPer = 0.4F; + float maxMul = 2; + for(int i = start; i < start + count; i++) { + mul = Math.min(maxMul, mul + mulPer); + double rad = radPer * (i + ticksElapsed * 0.4); + Vector3 vecRot = vecMag.copy().crossProduct(Vector3.one).multiply(mul).rotate(rad, vecMag).add(vecTip); + Botania.proxy.wispFX(worldObj, vecRot.x, vecRot.y, vecRot.z, 0.4F, 0.4F, 1F, 0.1F, (float) -vecMag.x, (float) -vecMag.y, (float) -vecMag.z, 1F); + vecTip.add(vecMag); + } + + ChunkCoordinates endpoint = getEndpoint(); + if(endpoint != null && !worldObj.isRemote) { + float range = 0.5F; + List enderPearls = worldObj.getEntitiesWithinAABB(EntityEnderPearl.class, AxisAlignedBB.getBoundingBox(xCoord - range, yCoord - range, zCoord - range, xCoord + 1 + range, yCoord + 1 + range, zCoord + 1 + range)); + for(EntityEnderPearl pearl : enderPearls) { + pearl.posX = endpoint.posX + pearl.posX - xCoord; + pearl.posY = endpoint.posY + pearl.posY - yCoord; + pearl.posZ = endpoint.posZ + pearl.posZ - zCoord; + } + } + } + } + + public boolean isValidBinding() { + Block block = worldObj.getBlock(bindX, bindY, bindZ); + return block == ModBlocks.lightRelay; + } + + public ChunkCoordinates getEndpoint() { + List pointsPassed = new ArrayList(); + TileLightRelay relay = this; + ChunkCoordinates lastCoords = null; + + // Doing while(true) gives an unreachable code error + boolean run = true; + while(run) { + if(pointsPassed.contains(relay)) + return null; // Circular path + pointsPassed.add(relay); + + ChunkCoordinates coords = relay.getBinding(); + if(coords == null) + return lastCoords; + + TileEntity tile = worldObj.getTileEntity(coords.posX, coords.posY, coords.posZ); + if(tile != null && tile instanceof TileLightRelay) + relay = (TileLightRelay) tile; + else return lastCoords; + + lastCoords = coords; + } + + return null; + } + + public Vector3 getMovementVector() { + return new Vector3(bindX - xCoord, bindY - yCoord, bindZ - zCoord); + } + + @Override + public ChunkCoordinates getBinding() { + return bindY == -1 ? null : new ChunkCoordinates(bindX, bindY, bindZ); + } + + @Override + public boolean canSelect(EntityPlayer player, ItemStack wand, int x, int y, int z, int side) { + return true; + } + + @Override + public boolean bindTo(EntityPlayer player, ItemStack wand, int x, int y, int z, int side) { + if(player.worldObj.getBlock(x, y, z) != ModBlocks.lightRelay || MathHelper.pointDistanceSpace(x, y, z, xCoord, yCoord, zCoord) > MAX_DIST) + return false; + + bindX = x; + bindY = y; + bindZ = z; + return true; + } + + @Override + public void readCustomNBT(NBTTagCompound cmp) { + bindX = cmp.getInteger(TAG_BIND_X); + bindY = cmp.getInteger(TAG_BIND_Y); + bindZ = cmp.getInteger(TAG_BIND_Z); + } + + @Override + public void writeCustomNBT(NBTTagCompound cmp) { + cmp.setInteger(TAG_BIND_X, bindX); + cmp.setInteger(TAG_BIND_Y, bindY); + cmp.setInteger(TAG_BIND_Z, bindZ); + } + + public static class EntityPlayerMover extends Entity { + + private static final String TAG_EXIT_X = "exitX"; + private static final String TAG_EXIT_Y = "exitY"; + private static final String TAG_EXIT_Z = "exitZ"; + + public EntityPlayerMover(World world) { + super(world); + } + + public EntityPlayerMover(World world, int x, int y, int z, int exitX, int exitY, int exitZ) { + this(world); + setPosition(x + 0.5, y + 0.5, z + 0.5); + setExit(exitX, exitY, exitZ); + } + + @Override + protected void entityInit() { + setSize(0F, 0F); + noClip = true; + + dataWatcher.addObject(20, 0); + dataWatcher.addObject(21, 0); + dataWatcher.addObject(22, 0); + dataWatcher.setObjectWatched(20); + dataWatcher.setObjectWatched(21); + dataWatcher.setObjectWatched(22); + } + + @Override + public void onUpdate() { + super.onUpdate(); + + if(riddenByEntity == null && !worldObj.isRemote) { + setDead(); + return; + } + + boolean isItem = riddenByEntity instanceof EntityItem; + if(!isItem && ticksExisted % 30 == 0) + worldObj.playSoundAtEntity(this, "botania:lightRelay", 0.05F, (float) Math.random() * 0.3F + 0.7F); + + int exitX = getExitX(); + int exitY = getExitY(); + int exitZ = getExitZ(); + + int x = net.minecraft.util.MathHelper.floor_double(posX); + int y = net.minecraft.util.MathHelper.floor_double(posY); + int z = net.minecraft.util.MathHelper.floor_double(posZ); + if(x == exitX && y == exitY && z == exitZ) { + TileEntity tile = worldObj.getTileEntity(x, y, z); + if(tile != null && tile instanceof TileLightRelay) { + int meta = worldObj.getBlockMetadata(x, y, z); + if(meta > 0) { + worldObj.setBlockMetadataWithNotify(x, y, z, meta | 8, 1 | 2); + worldObj.scheduleBlockUpdate(x, y, z, tile.getBlockType(), tile.getBlockType().tickRate(worldObj)); + } + + TileLightRelay relay = (TileLightRelay) tile; + ChunkCoordinates bind = relay.getBinding(); + if(bind != null && relay.isValidBinding()) { + setExit(bind.posX, bind.posY, bind.posZ); + return; + } + } + + posY += 1.5; + setDead(); + } else { + Vector3 thisVec = Vector3.fromEntity(this); + Vector3 motVec = thisVec.negate().add(exitX + 0.5, exitY + 0.5, exitZ + 0.5).normalize().multiply(0.5); + + Color color; + + int count = 4; + for(int i = 0; i < count; i++) { + color = Color.getHSBColor(ticksExisted / 36F + 1F / count * i, 1F, 1F); + double rad = Math.PI * 2.0 / count * i + ticksExisted / Math.PI; + double cos = Math.cos(rad); + double sin = Math.sin(rad); + double s = 0.4; + + Botania.proxy.sparkleFX(worldObj, posX + cos * s, posY - 0.5, posZ + sin * s, color.getRed() / 255F, color.getGreen() / 255F, color.getBlue() / 255F, 1.2F, 10); + } + + posX += motVec.x; + posY += motVec.y; + posZ += motVec.z; + } + } + + @Override + public boolean shouldRiderSit() { + return false; + } + + @Override + public boolean attackEntityFrom(DamageSource p_70097_1_, float p_70097_2_) { + return false; + } + + @Override + protected void readEntityFromNBT(NBTTagCompound cmp) { + setExit(cmp.getInteger(TAG_EXIT_X), cmp.getInteger(TAG_EXIT_Y), cmp.getInteger(TAG_EXIT_Z)); + } + + @Override + protected void writeEntityToNBT(NBTTagCompound cmp) { + cmp.setInteger(TAG_EXIT_X, getExitX()); + cmp.setInteger(TAG_EXIT_Y, getExitY()); + cmp.setInteger(TAG_EXIT_Z, getExitZ()); + } + + public int getExitX() { + return dataWatcher.getWatchableObjectInt(20); + } + + public int getExitY() { + return dataWatcher.getWatchableObjectInt(21); + } + + public int getExitZ() { + return dataWatcher.getWatchableObjectInt(22); + } + + public void setExit(int x, int y, int z) { + dataWatcher.updateObject(20, x); + dataWatcher.updateObject(21, y); + dataWatcher.updateObject(22, z); + } + + } + } diff --git a/src/main/java/vazkii/botania/common/block/tile/TileManaBeacon.java b/src/main/java/vazkii/botania/common/block/tile/TileManaBeacon.java index a84c46fa1e..d4d0936d81 100644 --- a/src/main/java/vazkii/botania/common/block/tile/TileManaBeacon.java +++ b/src/main/java/vazkii/botania/common/block/tile/TileManaBeacon.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Mar 3, 2014, 5:09:30 PM (GMT)] */ package vazkii.botania.common.block.tile; @@ -16,46 +16,24 @@ public class TileManaBeacon extends TileMod { - @Override - public void updateEntity() { - boolean redstone = false; - for (ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS) { - int redstoneSide = worldObj.getIndirectPowerLevelTo( - xCoord + dir.offsetX, yCoord + dir.offsetY, zCoord + dir.offsetZ, dir.ordinal()); - if (redstoneSide > 0) redstone = true; - } + @Override + public void updateEntity() { + boolean redstone = false; + for(ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS) { + int redstoneSide = worldObj.getIndirectPowerLevelTo(xCoord + dir.offsetX, yCoord + dir.offsetY, zCoord + dir.offsetZ, dir.ordinal()); + if(redstoneSide > 0) + redstone = true; + } - if (!redstone) { - float[] color = EntitySheep.fleeceColorTable[worldObj.getBlockMetadata(xCoord, yCoord, zCoord)]; + if(!redstone) { + float[] color = EntitySheep.fleeceColorTable[worldObj.getBlockMetadata(xCoord, yCoord, zCoord)]; - Botania.proxy.setWispFXDistanceLimit(false); - Botania.proxy.wispFX( - worldObj, - xCoord + 0.5, - yCoord + 0.5, - zCoord + 0.5, - color[0], - color[1], - color[2], - (float) Math.random() * 5 + 1F, - (float) (Math.random() - 0.5F), - 10F * (float) Math.sqrt(256F / (256F - yCoord)), - (float) (Math.random() - 0.5F)); + Botania.proxy.setWispFXDistanceLimit(false); + Botania.proxy.wispFX(worldObj, xCoord + 0.5, yCoord + 0.5, zCoord + 0.5, color[0], color[1], color[2], (float) Math.random() * 5 + 1F, (float) (Math.random() - 0.5F), 10F * (float) Math.sqrt(256F / (256F - yCoord)), (float) (Math.random() - 0.5F)); - for (int i = 0; i < 2; i++) - Botania.proxy.wispFX( - worldObj, - xCoord + 0.5, - 256, - zCoord + 0.5, - color[0], - color[1], - color[2], - (float) Math.random() * 15 + 8F, - (float) (Math.random() - 0.5F) * 8F, - 0F, - (float) (Math.random() - 0.5F) * 8F); - Botania.proxy.setWispFXDistanceLimit(true); - } - } + for(int i = 0; i < 2; i++) + Botania.proxy.wispFX(worldObj, xCoord + 0.5, 256, zCoord + 0.5, color[0], color[1], color[2], (float) Math.random() * 15 + 8F, (float) (Math.random() - 0.5F) * 8F, 0F, (float) (Math.random() - 0.5F) * 8F); + Botania.proxy.setWispFXDistanceLimit(true); + } + } } diff --git a/src/main/java/vazkii/botania/common/block/tile/TileManaFlame.java b/src/main/java/vazkii/botania/common/block/tile/TileManaFlame.java index 70749e3de7..a1815d3ba8 100644 --- a/src/main/java/vazkii/botania/common/block/tile/TileManaFlame.java +++ b/src/main/java/vazkii/botania/common/block/tile/TileManaFlame.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Dec 21, 2014, 12:33:12 AM (GMT)] */ package vazkii.botania.common.block.tile; @@ -16,62 +16,63 @@ public class TileManaFlame extends TileMod { - private static final String TAG_COLOR = "color"; + private static final String TAG_COLOR = "color"; - int color = 0x20FF20; + int color = 0x20FF20; - int lightColor = -1; + int lightColor = -1; - public void setColor(int color) { - this.color = color; - } + public void setColor(int color) { + this.color = color; + } - public int getColor() { - return color; - } + public int getColor() { + return color; + } - @Override - public void updateEntity() { - float c = 0.3F; + @Override + public void updateEntity() { + float c = 0.3F; - if (Math.random() < c) { - float v = 0.1F; + if(Math.random() < c) { + float v = 0.1F; - float r = (float) (color >> 16 & 0xFF) / 0xFF + (float) (Math.random() - 0.5) * v; - float g = (float) (color >> 8 & 0xFF) / 0xFF + (float) (Math.random() - 0.5) * v; - float b = (float) (color & 0xFF) / 0xFF + (float) (Math.random() - 0.5) * v; + float r = (float) (color >> 16 & 0xFF) / 0xFF + (float) (Math.random() - 0.5) * v; + float g = (float) (color >> 8 & 0xFF) / 0xFF + (float) (Math.random() - 0.5) * v; + float b = (float) (color & 0xFF) / 0xFF + (float) (Math.random() - 0.5) * v; - float w = 0.15F; - float h = 0.05F; - double x = xCoord + 0.5 + (Math.random() - 0.5) * w; - double y = yCoord + 0.25 + (Math.random() - 0.5) * h; - double z = zCoord + 0.5 + (Math.random() - 0.5) * w; + float w = 0.15F; + float h = 0.05F; + double x = xCoord + 0.5 + (Math.random() - 0.5) * w; + double y = yCoord + 0.25 + (Math.random() - 0.5) * h; + double z = zCoord + 0.5 + (Math.random() - 0.5) * w; - float s = 0.2F + (float) Math.random() * 0.1F; - float m = 0.03F + (float) Math.random() * 0.015F; + float s = 0.2F + (float) Math.random() * 0.1F; + float m = 0.03F + (float) Math.random() * 0.015F; - Botania.proxy.wispFX(worldObj, x, y, z, r, g, b, s, -m); - } - } + Botania.proxy.wispFX(worldObj, x, y, z, r, g, b, s, -m); + } + } - public int getLightColor() { - if (lightColor == -1) { - float r = (float) (color >> 16 & 0xFF) / 0xFF; - float g = (float) (color >> 8 & 0xFF) / 0xFF; - float b = (float) (color & 0xFF) / 0xFF; - lightColor = ColoredLightHelper.makeRGBLightValue(r, g, b, 1F); - } + public int getLightColor() { + if(lightColor == -1) { + float r = (float) (color >> 16 & 0xFF) / 0xFF; + float g = (float) (color >> 8 & 0xFF) / 0xFF; + float b = (float) (color & 0xFF) / 0xFF; + lightColor = ColoredLightHelper.makeRGBLightValue(r, g, b, 1F); + } - return lightColor; - } + return lightColor; + } - @Override - public void writeCustomNBT(NBTTagCompound cmp) { - cmp.setInteger(TAG_COLOR, color); - } + @Override + public void writeCustomNBT(NBTTagCompound cmp) { + cmp.setInteger(TAG_COLOR, color); + } + + @Override + public void readCustomNBT(NBTTagCompound cmp) { + color = cmp.getInteger(TAG_COLOR); + } - @Override - public void readCustomNBT(NBTTagCompound cmp) { - color = cmp.getInteger(TAG_COLOR); - } } diff --git a/src/main/java/vazkii/botania/common/block/tile/TileMod.java b/src/main/java/vazkii/botania/common/block/tile/TileMod.java index 877656521a..b1deaf4837 100644 --- a/src/main/java/vazkii/botania/common/block/tile/TileMod.java +++ b/src/main/java/vazkii/botania/common/block/tile/TileMod.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jan 21, 2014, 9:18:28 PM (GMT)] */ package vazkii.botania.common.block.tile; @@ -18,38 +18,39 @@ public class TileMod extends TileEntity { - @Override - public void writeToNBT(NBTTagCompound par1nbtTagCompound) { - super.writeToNBT(par1nbtTagCompound); + @Override + public void writeToNBT(NBTTagCompound par1nbtTagCompound) { + super.writeToNBT(par1nbtTagCompound); - writeCustomNBT(par1nbtTagCompound); - } + writeCustomNBT(par1nbtTagCompound); + } - @Override - public void readFromNBT(NBTTagCompound par1nbtTagCompound) { - super.readFromNBT(par1nbtTagCompound); + @Override + public void readFromNBT(NBTTagCompound par1nbtTagCompound) { + super.readFromNBT(par1nbtTagCompound); - readCustomNBT(par1nbtTagCompound); - } + readCustomNBT(par1nbtTagCompound); + } - public void writeCustomNBT(NBTTagCompound cmp) { - // NO-OP - } + public void writeCustomNBT(NBTTagCompound cmp) { + // NO-OP + } - public void readCustomNBT(NBTTagCompound cmp) { - // NO-OP - } + public void readCustomNBT(NBTTagCompound cmp) { + // NO-OP + } - @Override - public Packet getDescriptionPacket() { - NBTTagCompound nbttagcompound = new NBTTagCompound(); - writeCustomNBT(nbttagcompound); - return new S35PacketUpdateTileEntity(xCoord, yCoord, zCoord, -999, nbttagcompound); - } + @Override + public Packet getDescriptionPacket() { + NBTTagCompound nbttagcompound = new NBTTagCompound(); + writeCustomNBT(nbttagcompound); + return new S35PacketUpdateTileEntity(xCoord, yCoord, zCoord, -999, nbttagcompound); + } + + @Override + public void onDataPacket(NetworkManager net, S35PacketUpdateTileEntity packet) { + super.onDataPacket(net, packet); + readCustomNBT(packet.func_148857_g()); + } - @Override - public void onDataPacket(NetworkManager net, S35PacketUpdateTileEntity packet) { - super.onDataPacket(net, packet); - readCustomNBT(packet.func_148857_g()); - } } diff --git a/src/main/java/vazkii/botania/common/block/tile/TileOpenCrate.java b/src/main/java/vazkii/botania/common/block/tile/TileOpenCrate.java index c76e1e5967..33f12dc652 100644 --- a/src/main/java/vazkii/botania/common/block/tile/TileOpenCrate.java +++ b/src/main/java/vazkii/botania/common/block/tile/TileOpenCrate.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [May 4, 2014, 12:51:05 PM (GMT)] */ package vazkii.botania.common.block.tile; @@ -19,57 +19,58 @@ public class TileOpenCrate extends TileSimpleInventory { - @Override - public int getSizeInventory() { - return 1; - } + @Override + public int getSizeInventory() { + return 1; + } - @Override - public String getInventoryName() { - return LibBlockNames.OPEN_CRATE; - } + @Override + public String getInventoryName() { + return LibBlockNames.OPEN_CRATE; + } - @Override - public void updateEntity() { - boolean redstone = false; - for (ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS) { - int redstoneSide = worldObj.getIndirectPowerLevelTo( - xCoord + dir.offsetX, yCoord + dir.offsetY, zCoord + dir.offsetZ, dir.ordinal()); - if (redstoneSide > 0) { - redstone = true; - break; - } - } + @Override + public void updateEntity() { + boolean redstone = false; + for(ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS) { + int redstoneSide = worldObj.getIndirectPowerLevelTo(xCoord + dir.offsetX, yCoord + dir.offsetY, zCoord + dir.offsetZ, dir.ordinal()); + if(redstoneSide > 0) { + redstone = true; + break; + } + } - if (canEject()) { - ItemStack stack = getStackInSlot(0); - if (stack != null) eject(stack, redstone); - } - } + if(canEject()) { + ItemStack stack = getStackInSlot(0); + if(stack != null) + eject(stack, redstone); + } + } - public boolean canEject() { - Block blockBelow = worldObj.getBlock(xCoord, yCoord - 1, zCoord); - return blockBelow.isAir(worldObj, xCoord, yCoord - 1, zCoord) - || blockBelow.getCollisionBoundingBoxFromPool(worldObj, xCoord, yCoord - 1, zCoord) == null; - } + public boolean canEject() { + Block blockBelow = worldObj.getBlock(xCoord, yCoord - 1, zCoord); + return blockBelow.isAir(worldObj, xCoord, yCoord - 1, zCoord) || blockBelow.getCollisionBoundingBoxFromPool(worldObj, xCoord, yCoord - 1, zCoord) == null; + } - public void eject(ItemStack stack, boolean redstone) { - EntityItem item = new EntityItem(worldObj, xCoord + 0.5, yCoord - 0.5, zCoord + 0.5, stack); - item.motionX = 0; - item.motionY = 0; - item.motionZ = 0; + public void eject(ItemStack stack, boolean redstone) { + EntityItem item = new EntityItem(worldObj, xCoord + 0.5, yCoord - 0.5, zCoord + 0.5, stack); + item.motionX = 0; + item.motionY = 0; + item.motionZ = 0; - if (redstone) item.age = -200; + if(redstone) + item.age = -200; - setInventorySlotContents(0, null); - if (!worldObj.isRemote) worldObj.spawnEntityInWorld(item); - } + setInventorySlotContents(0, null); + if(!worldObj.isRemote) + worldObj.spawnEntityInWorld(item); + } - public boolean onWanded(EntityPlayer player, ItemStack stack) { - return false; - } + public boolean onWanded(EntityPlayer player, ItemStack stack) { + return false; + } - public int getSignal() { - return 0; - } + public int getSignal() { + return 0; + } } diff --git a/src/main/java/vazkii/botania/common/block/tile/TilePlatform.java b/src/main/java/vazkii/botania/common/block/tile/TilePlatform.java index 48dd96552e..416ca3eb23 100644 --- a/src/main/java/vazkii/botania/common/block/tile/TilePlatform.java +++ b/src/main/java/vazkii/botania/common/block/tile/TilePlatform.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jun 7, 2014, 2:24:51 PM (GMT)] */ package vazkii.botania.common.block.tile; @@ -17,42 +17,45 @@ public class TilePlatform extends TileCamo implements IManaCollisionGhost { - @Override - public boolean isGhost() { - return true; - } - - public boolean onWanded(EntityPlayer player) { - if (player != null) { - if (camo == null || player.isSneaking()) swapSelfAndPass(this, true); - else swapSurroudings(this, false); - return true; - } - - return false; - } - - void swapSelfAndPass(TilePlatform tile, boolean empty) { - swap(tile, empty); - swapSurroudings(tile, empty); - } - - void swapSurroudings(TilePlatform tile, boolean empty) { - for (ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS) { - int x = tile.xCoord + dir.offsetX; - int y = tile.yCoord + dir.offsetY; - int z = tile.zCoord + dir.offsetZ; - TileEntity tileAt = worldObj.getTileEntity(x, y, z); - if (tileAt != null && tileAt instanceof TilePlatform) { - TilePlatform platform = (TilePlatform) tileAt; - if (empty ? platform.camo != null : platform.camo == null) swapSelfAndPass(platform, empty); - } - } - } - - void swap(TilePlatform tile, boolean empty) { - tile.camo = empty ? null : camo; - tile.camoMeta = empty ? 0 : camoMeta; - worldObj.markBlockForUpdate(tile.xCoord, tile.yCoord, tile.zCoord); - } + @Override + public boolean isGhost() { + return true; + } + + public boolean onWanded(EntityPlayer player) { + if(player != null) { + if(camo == null || player.isSneaking()) + swapSelfAndPass(this, true); + else swapSurroudings(this, false); + return true; + } + + return false; + } + + void swapSelfAndPass(TilePlatform tile, boolean empty) { + swap(tile, empty); + swapSurroudings(tile, empty); + } + + void swapSurroudings(TilePlatform tile, boolean empty) { + for(ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS) { + int x = tile.xCoord + dir.offsetX; + int y = tile.yCoord + dir.offsetY; + int z = tile.zCoord + dir.offsetZ; + TileEntity tileAt = worldObj.getTileEntity(x, y, z); + if(tileAt != null && tileAt instanceof TilePlatform) { + TilePlatform platform = (TilePlatform) tileAt; + if(empty ? platform.camo != null : platform.camo == null) + swapSelfAndPass(platform, empty); + } + } + } + + void swap(TilePlatform tile, boolean empty) { + tile.camo = empty ? null : camo; + tile.camoMeta = empty ? 0 : camoMeta; + worldObj.markBlockForUpdate(tile.xCoord, tile.yCoord, tile.zCoord); + } + } diff --git a/src/main/java/vazkii/botania/common/block/tile/TilePylon.java b/src/main/java/vazkii/botania/common/block/tile/TilePylon.java index ac6c3f3d5d..a3b89b029d 100644 --- a/src/main/java/vazkii/botania/common/block/tile/TilePylon.java +++ b/src/main/java/vazkii/botania/common/block/tile/TilePylon.java @@ -2,15 +2,16 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Feb 18, 2014, 10:15:50 PM (GMT)] */ package vazkii.botania.common.block.tile; import java.util.Random; + import net.minecraft.block.Block; import net.minecraft.entity.passive.EntitySheep; import net.minecraft.tileentity.TileEntity; @@ -21,135 +22,68 @@ public class TilePylon extends TileEntity { - boolean activated = false; - int centerX, centerY, centerZ; - int ticks = 0; - - @Override - public void updateEntity() { - ++ticks; - int meta = getBlockMetadata(); - - if (activated && worldObj.isRemote) { - if (worldObj.getBlock(centerX, centerY, centerZ) != getBlockForMeta() - || meta != 0 && worldObj.getBlockMetadata(centerX, centerY, centerZ) == 0) { - activated = false; - return; - } - - Vector3 centerBlock = - new Vector3(centerX + 0.5, centerY + 0.75 + (Math.random() - 0.5 * 0.25), centerZ + 0.5); - - if (meta == 1) { - if (ConfigHandler.elfPortalParticlesEnabled) { - double worldTime = ticks; - worldTime += new Random(xCoord ^ yCoord ^ zCoord).nextInt(1000); - worldTime /= 5; - - float r = 0.75F + (float) Math.random() * 0.05F; - double x = xCoord + 0.5 + Math.cos(worldTime) * r; - double z = zCoord + 0.5 + Math.sin(worldTime) * r; - - Vector3 ourCoords = new Vector3(x, yCoord + 0.25, z); - centerBlock.sub(new Vector3(0, 0.5, 0)); - Vector3 movementVector = - centerBlock.sub(ourCoords).normalize().multiply(0.2); - - Botania.proxy.wispFX( - worldObj, - x, - yCoord + 0.25, - z, - (float) Math.random() * 0.25F, - 0.75F + (float) Math.random() * 0.25F, - (float) Math.random() * 0.25F, - 0.25F + (float) Math.random() * 0.1F, - -0.075F - (float) Math.random() * 0.015F); - if (worldObj.rand.nextInt(3) == 0) - Botania.proxy.wispFX( - worldObj, - x, - yCoord + 0.25, - z, - (float) Math.random() * 0.25F, - 0.75F + (float) Math.random() * 0.25F, - (float) Math.random() * 0.25F, - 0.25F + (float) Math.random() * 0.1F, - (float) movementVector.x, - (float) movementVector.y, - (float) movementVector.z); - } - } else { - Vector3 ourCoords = Vector3.fromTileEntityCenter(this).add(0, 1 + (Math.random() - 0.5 * 0.25), 0); - Vector3 movementVector = centerBlock.sub(ourCoords).normalize().multiply(0.2); - - Block block = worldObj.getBlock(xCoord, yCoord - 1, zCoord); - if (block == ModBlocks.flower || block == ModBlocks.shinyFlower) { - int fmeta = worldObj.getBlockMetadata(xCoord, yCoord - 1, zCoord); - float[] color = EntitySheep.fleeceColorTable[fmeta]; - - if (worldObj.rand.nextInt(4) == 0) - Botania.proxy.sparkleFX( - worldObj, - centerBlock.x + (Math.random() - 0.5) * 0.5, - centerBlock.y, - centerBlock.z + (Math.random() - 0.5) * 0.5, - color[0], - color[1], - color[2], - (float) Math.random(), - 8); - - Botania.proxy.wispFX( - worldObj, - xCoord + 0.5 + (Math.random() - 0.5) * 0.25, - yCoord - 0.5, - zCoord + 0.5 + (Math.random() - 0.5) * 0.25, - color[0], - color[1], - color[2], - (float) Math.random() / 3F, - -0.04F); - Botania.proxy.wispFX( - worldObj, - xCoord + 0.5 + (Math.random() - 0.5) * 0.125, - yCoord + 1.5, - zCoord + 0.5 + (Math.random() - 0.5) * 0.125, - color[0], - color[1], - color[2], - (float) Math.random() / 5F, - -0.001F); - Botania.proxy.wispFX( - worldObj, - xCoord + 0.5 + (Math.random() - 0.5) * 0.25, - yCoord + 1.5, - zCoord + 0.5 + (Math.random() - 0.5) * 0.25, - color[0], - color[1], - color[2], - (float) Math.random() / 8F, - (float) movementVector.x, - (float) movementVector.y, - (float) movementVector.z); - } - } - } - - if (worldObj.rand.nextBoolean() && worldObj.isRemote) - Botania.proxy.sparkleFX( - worldObj, - xCoord + Math.random(), - yCoord + Math.random() * 1.5, - zCoord + Math.random(), - meta == 2 ? 1F : 0.5F, - meta == 1 ? 1F : 0.5F, - meta == 1 ? 0.5F : 1F, - (float) Math.random(), - 2); - } - - private Block getBlockForMeta() { - return getBlockMetadata() == 0 ? ModBlocks.enchanter : ModBlocks.alfPortal; - } -} + boolean activated = false; + int centerX, centerY, centerZ; + int ticks = 0; + + + + @Override + public void updateEntity() { + ++ticks; + int meta = getBlockMetadata(); + + if(activated && worldObj.isRemote) { + if(worldObj.getBlock(centerX, centerY, centerZ) != getBlockForMeta() || meta != 0 && worldObj.getBlockMetadata(centerX, centerY, centerZ) == 0) { + activated = false; + return; + } + + Vector3 centerBlock = new Vector3(centerX + 0.5, centerY + 0.75 + (Math.random() - 0.5 * 0.25), centerZ + 0.5); + + if(meta == 1) { + if(ConfigHandler.elfPortalParticlesEnabled) { + double worldTime = ticks; + worldTime += new Random(xCoord ^ yCoord ^ zCoord).nextInt(1000); + worldTime /= 5; + + float r = 0.75F + (float) Math.random() * 0.05F; + double x = xCoord + 0.5 + Math.cos(worldTime) * r; + double z = zCoord + 0.5 + Math.sin(worldTime) * r; + + Vector3 ourCoords = new Vector3(x, yCoord + 0.25, z); + centerBlock.sub(new Vector3(0, 0.5, 0)); + Vector3 movementVector = centerBlock.sub(ourCoords).normalize().multiply(0.2); + + Botania.proxy.wispFX(worldObj, x, yCoord + 0.25, z, (float) Math.random() * 0.25F, 0.75F + (float) Math.random() * 0.25F, (float) Math.random() * 0.25F, 0.25F + (float) Math.random() * 0.1F, -0.075F - (float) Math.random() * 0.015F); + if(worldObj.rand.nextInt(3) == 0) + Botania.proxy.wispFX(worldObj, x, yCoord + 0.25, z, (float) Math.random() * 0.25F, 0.75F + (float) Math.random() * 0.25F, (float) Math.random() * 0.25F, 0.25F + (float) Math.random() * 0.1F, (float) movementVector.x, (float) movementVector.y, (float) movementVector.z); + } + } else { + Vector3 ourCoords = Vector3.fromTileEntityCenter(this).add(0, 1 + (Math.random() - 0.5 * 0.25), 0); + Vector3 movementVector = centerBlock.sub(ourCoords).normalize().multiply(0.2); + + Block block = worldObj.getBlock(xCoord, yCoord - 1, zCoord); + if(block == ModBlocks.flower || block == ModBlocks.shinyFlower) { + int fmeta = worldObj.getBlockMetadata(xCoord, yCoord - 1, zCoord); + float[] color = EntitySheep.fleeceColorTable[fmeta]; + + if(worldObj.rand.nextInt(4) == 0) + Botania.proxy.sparkleFX(worldObj, centerBlock.x + (Math.random() - 0.5) * 0.5, centerBlock.y, centerBlock.z + (Math.random() - 0.5) * 0.5, color[0], color[1], color[2], (float) Math.random(), 8); + + Botania.proxy.wispFX(worldObj, xCoord + 0.5 + (Math.random() - 0.5) * 0.25, yCoord - 0.5, zCoord + 0.5 + (Math.random() - 0.5) * 0.25, color[0], color[1], color[2], (float) Math.random() / 3F, -0.04F); + Botania.proxy.wispFX(worldObj, xCoord + 0.5 + (Math.random() - 0.5) * 0.125, yCoord + 1.5, zCoord + 0.5 + (Math.random() - 0.5) * 0.125, color[0], color[1], color[2], (float) Math.random() / 5F, -0.001F); + Botania.proxy.wispFX(worldObj, xCoord + 0.5 + (Math.random() - 0.5) * 0.25, yCoord + 1.5, zCoord + 0.5 + (Math.random() - 0.5) * 0.25, color[0], color[1], color[2], (float) Math.random() / 8F, (float) movementVector.x, (float) movementVector.y, (float) movementVector.z); + } + } + } + + if(worldObj.rand.nextBoolean() && worldObj.isRemote) + Botania.proxy.sparkleFX(worldObj, xCoord + Math.random(), yCoord + Math.random() * 1.5, zCoord + Math.random(), meta == 2 ? 1F : 0.5F, meta == 1 ? 1F : 0.5F, meta == 1 ? 0.5F : 1F, (float) Math.random(), 2); + } + + private Block getBlockForMeta() { + return getBlockMetadata() == 0 ? ModBlocks.enchanter : ModBlocks.alfPortal; + } + +} \ No newline at end of file diff --git a/src/main/java/vazkii/botania/common/block/tile/TileRuneAltar.java b/src/main/java/vazkii/botania/common/block/tile/TileRuneAltar.java index e65726b4d8..0ac4be2be4 100644 --- a/src/main/java/vazkii/botania/common/block/tile/TileRuneAltar.java +++ b/src/main/java/vazkii/botania/common/block/tile/TileRuneAltar.java @@ -2,16 +2,17 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Feb 2, 2014, 6:31:19 PM (GMT)] */ package vazkii.botania.common.block.tile; import java.util.ArrayList; import java.util.List; + import net.minecraft.client.Minecraft; import net.minecraft.client.gui.ScaledResolution; import net.minecraft.client.renderer.entity.RenderItem; @@ -23,8 +24,10 @@ import net.minecraft.nbt.NBTTagCompound; import net.minecraft.util.AxisAlignedBB; import net.minecraft.util.StatCollector; + import org.lwjgl.opengl.GL11; import org.lwjgl.opengl.GL12; + import vazkii.botania.api.BotaniaAPI; import vazkii.botania.api.internal.VanillaPacketDispatcher; import vazkii.botania.api.mana.IManaReceiver; @@ -39,399 +42,378 @@ public class TileRuneAltar extends TileSimpleInventory implements ISidedInventory, IManaReceiver { - private static final String TAG_MANA = "mana"; - private static final String TAG_MANA_TO_GET = "manaToGet"; - - RecipeRuneAltar currentRecipe; - - public int manaToGet = 0; - int mana = 0; - int cooldown = 0; - public int signal = 0; - - List lastRecipe = null; - int recipeKeepTicks = 0; - - public boolean addItem(EntityPlayer player, ItemStack stack) { - if (cooldown > 0 || stack.getItem() == ModItems.twigWand || stack.getItem() == ModItems.lexicon) return false; - - if (stack.getItem() == Item.getItemFromBlock(ModBlocks.livingrock) && stack.getItemDamage() == 0) { - if (player == null || !player.capabilities.isCreativeMode) { - stack.stackSize--; - if (stack.stackSize == 0 && player != null) - player.inventory.setInventorySlotContents(player.inventory.currentItem, null); - } - - EntityItem item = new EntityItem( - worldObj, xCoord + 0.5, yCoord + 1, zCoord + 0.5, new ItemStack(ModBlocks.livingrock)); - item.delayBeforeCanPickup = 40; - item.motionX = item.motionY = item.motionZ = 0; - if (!worldObj.isRemote) worldObj.spawnEntityInWorld(item); - - return true; - } - - if (manaToGet != 0) return false; - - boolean did = false; - - for (int i = 0; i < getSizeInventory(); i++) - if (getStackInSlot(i) == null) { - did = true; - ItemStack stackToAdd = stack.copy(); - stackToAdd.stackSize = 1; - setInventorySlotContents(i, stackToAdd); - - if (player == null || !player.capabilities.isCreativeMode) { - stack.stackSize--; - if (stack.stackSize == 0 && player != null) - player.inventory.setInventorySlotContents(player.inventory.currentItem, null); - } - - break; - } - - if (did) VanillaPacketDispatcher.dispatchTEToNearbyPlayers(worldObj, xCoord, yCoord, zCoord); - - return true; - } - - @Override - public void updateEntity() { - super.updateEntity(); - - // Update every tick. - recieveMana(0); - - if (!worldObj.isRemote && manaToGet == 0) { - List items = worldObj.getEntitiesWithinAABB( - EntityItem.class, - AxisAlignedBB.getBoundingBox(xCoord, yCoord, zCoord, xCoord + 1, yCoord + 1, zCoord + 1)); - for (EntityItem item : items) - if (!item.isDead - && item.getEntityItem() != null - && item.getEntityItem().getItem() != Item.getItemFromBlock(ModBlocks.livingrock)) { - ItemStack stack = item.getEntityItem(); - if (addItem(null, stack) && stack.stackSize == 0) item.setDead(); - } - } - - if (worldObj.isRemote && manaToGet > 0 && mana >= manaToGet) { - if (worldObj.rand.nextInt(20) == 0) { - Vector3 vec = Vector3.fromTileEntityCenter(this); - Vector3 endVec = vec.copy().add(0, 2.5, 0); - Botania.proxy.lightningFX(worldObj, vec, endVec, 2F, 0x00948B, 0x00E4D7); - } - } - - if (cooldown > 0) { - cooldown--; - Botania.proxy.wispFX( - getWorldObj(), - xCoord + Math.random(), - yCoord + 0.8, - zCoord + Math.random(), - 0.2F, - 0.2F, - 0.2F, - 0.2F, - -0.025F); - } - - int newSignal = 0; - if (manaToGet > 0) { - newSignal++; - if (mana >= manaToGet) newSignal++; - } - - if (newSignal != signal) { - signal = newSignal; - worldObj.func_147453_f(xCoord, yCoord, zCoord, worldObj.getBlock(xCoord, yCoord, zCoord)); - } - - if (recipeKeepTicks > 0) --recipeKeepTicks; - else lastRecipe = null; - - updateRecipe(); - } - - public void updateRecipe() { - int manaToGet = this.manaToGet; - - getMana: - { - if (currentRecipe != null) this.manaToGet = currentRecipe.getManaUsage(); - else { - for (RecipeRuneAltar recipe : BotaniaAPI.runeAltarRecipes) - if (recipe.matches(this)) { - this.manaToGet = recipe.getManaUsage(); - break getMana; - } - this.manaToGet = 0; - } - } - - if (manaToGet != this.manaToGet) { - worldObj.playSoundEffect(xCoord, yCoord, zCoord, "botania:runeAltarStart", 1F, 1F); - VanillaPacketDispatcher.dispatchTEToNearbyPlayers(worldObj, xCoord, yCoord, zCoord); - } - } - - public void saveLastRecipe() { - lastRecipe = new ArrayList(); - for (int i = 0; i < getSizeInventory(); i++) { - ItemStack stack = getStackInSlot(i); - if (stack == null) break; - lastRecipe.add(stack.copy()); - } - recipeKeepTicks = 400; - } - - public void trySetLastRecipe(EntityPlayer player) { - TileAltar.tryToSetLastRecipe(player, this, lastRecipe); - if (!isEmpty()) VanillaPacketDispatcher.dispatchTEToNearbyPlayers(worldObj, xCoord, yCoord, zCoord); - } - - public boolean hasValidRecipe() { - for (RecipeRuneAltar recipe : BotaniaAPI.runeAltarRecipes) if (recipe.matches(this)) return true; - - return false; - } - - public void onWanded(EntityPlayer player, ItemStack wand) { - RecipeRuneAltar recipe = null; - - if (currentRecipe != null) recipe = currentRecipe; - else - for (RecipeRuneAltar recipe_ : BotaniaAPI.runeAltarRecipes) { - if (recipe_.matches(this)) { - recipe = recipe_; - break; - } - } - - if (manaToGet > 0 && mana >= manaToGet) { - List items = worldObj.getEntitiesWithinAABB( - EntityItem.class, - AxisAlignedBB.getBoundingBox(xCoord, yCoord, zCoord, xCoord + 1, yCoord + 1, zCoord + 1)); - EntityItem livingrock = null; - for (EntityItem item : items) - if (!item.isDead - && item.getEntityItem() != null - && item.getEntityItem().getItem() == Item.getItemFromBlock(ModBlocks.livingrock)) { - livingrock = item; - break; - } - - if (livingrock != null) { - int mana = recipe.getManaUsage(); - recieveMana(-mana); - if (!worldObj.isRemote) { - ItemStack output = recipe.getOutput().copy(); - EntityItem outputItem = new EntityItem(worldObj, xCoord + 0.5, yCoord + 1.5, zCoord + 0.5, output); - worldObj.spawnEntityInWorld(outputItem); - currentRecipe = null; - cooldown = 60; - } - - saveLastRecipe(); - if (!worldObj.isRemote) { - for (int i = 0; i < getSizeInventory(); i++) { - ItemStack stack = getStackInSlot(i); - if (stack != null) { - if (stack.getItem() == ModItems.rune - && (player == null || !player.capabilities.isCreativeMode)) { - EntityItem outputItem = new EntityItem( - worldObj, xCoord + 0.5, yCoord + 1.5, zCoord + 0.5, stack.copy()); - worldObj.spawnEntityInWorld(outputItem); - } - - setInventorySlotContents(i, null); - } - } - - ItemStack livingrockItem = livingrock.getEntityItem(); - livingrockItem.stackSize--; - if (livingrockItem.stackSize == 0) livingrock.setDead(); - } - - craftingFanciness(); - } - } - } - - public void craftingFanciness() { - worldObj.playSoundEffect(xCoord, yCoord, zCoord, "botania:runeAltarCraft", 1F, 1F); - for (int i = 0; i < 25; i++) { - float red = (float) Math.random(); - float green = (float) Math.random(); - float blue = (float) Math.random(); - Botania.proxy.sparkleFX( - worldObj, - xCoord + 0.5 + Math.random() * 0.4 - 0.2, - yCoord + 1, - zCoord + 0.5 + Math.random() * 0.4 - 0.2, - red, - green, - blue, - (float) Math.random(), - 10); - } - } - - public boolean isEmpty() { - for (int i = 0; i < getSizeInventory(); i++) if (getStackInSlot(i) != null) return false; - - return true; - } - - @Override - public void writeCustomNBT(NBTTagCompound par1nbtTagCompound) { - super.writeCustomNBT(par1nbtTagCompound); - - par1nbtTagCompound.setInteger(TAG_MANA, mana); - par1nbtTagCompound.setInteger(TAG_MANA_TO_GET, manaToGet); - } - - @Override - public void readCustomNBT(NBTTagCompound par1nbtTagCompound) { - super.readCustomNBT(par1nbtTagCompound); - - mana = par1nbtTagCompound.getInteger(TAG_MANA); - manaToGet = par1nbtTagCompound.getInteger(TAG_MANA_TO_GET); - } - - @Override - public int getSizeInventory() { - return 16; - } - - @Override - public AxisAlignedBB getRenderBoundingBox() { - return INFINITE_EXTENT_AABB; - } - - @Override - public String getInventoryName() { - return LibBlockNames.RUNE_ALTAR; - } - - @Override - public int getInventoryStackLimit() { - return 1; - } - - @Override - public int[] getAccessibleSlotsFromSide(int var1) { - int accessibleSlot = -1; - for (int i = 0; i < getSizeInventory(); i++) if (getStackInSlot(i) != null) accessibleSlot = i; - - return accessibleSlot == -1 ? new int[0] : new int[] {accessibleSlot}; - } - - @Override - public boolean canInsertItem(int i, ItemStack itemstack, int j) { - return true; - } - - @Override - public boolean canExtractItem(int i, ItemStack itemstack, int j) { - return mana == 0; - } - - @Override - public int getCurrentMana() { - return mana; - } - - @Override - public boolean isFull() { - return mana >= manaToGet; - } - - @Override - public void recieveMana(int mana) { - this.mana = Math.min(this.mana + mana, manaToGet); - } - - @Override - public boolean canRecieveManaFromBursts() { - return !isFull(); - } - - public void renderHUD(Minecraft mc, ScaledResolution res) { - int xc = res.getScaledWidth() / 2; - int yc = res.getScaledHeight() / 2; - - float angle = -90; - int radius = 24; - int amt = 0; - for (int i = 0; i < getSizeInventory(); i++) { - if (getStackInSlot(i) == null) break; - amt++; - } - - if (amt > 0) { - float anglePer = 360F / amt; - for (RecipeRuneAltar recipe : BotaniaAPI.runeAltarRecipes) - if (recipe.matches(this)) { - GL11.glEnable(GL11.GL_BLEND); - GL11.glEnable(GL12.GL_RESCALE_NORMAL); - GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); - - recipe.getOutput(); - float progress = (float) mana / (float) manaToGet; - - mc.renderEngine.bindTexture(HUDHandler.manaBar); - GL11.glColor4f(1F, 1F, 1F, 1F); - RenderHelper.drawTexturedModalRect(xc + radius + 9, yc - 8, 0, progress == 1F ? 0 : 22, 8, 22, 15); - - net.minecraft.client.renderer.RenderHelper.enableGUIStandardItemLighting(); - if (progress == 1F) { - RenderItem.getInstance() - .renderItemIntoGUI( - mc.fontRenderer, - mc.renderEngine, - new ItemStack(ModBlocks.livingrock), - xc + radius + 16, - yc + 8); - GL11.glTranslatef(0F, 0F, 100F); - RenderItem.getInstance() - .renderItemIntoGUI( - mc.fontRenderer, - mc.renderEngine, - new ItemStack(ModItems.twigWand), - xc + radius + 24, - yc + 8); - GL11.glTranslatef(0F, 0F, -100F); - } - - RenderHelper.renderProgressPie(xc + radius + 32, yc - 8, progress, recipe.getOutput()); - net.minecraft.client.renderer.RenderHelper.disableStandardItemLighting(); - - if (progress == 1F) mc.fontRenderer.drawStringWithShadow("+", xc + radius + 14, yc + 12, 0xFFFFFF); - } - - net.minecraft.client.renderer.RenderHelper.enableGUIStandardItemLighting(); - for (int i = 0; i < amt; i++) { - double xPos = xc + Math.cos(angle * Math.PI / 180D) * radius - 8; - double yPos = yc + Math.sin(angle * Math.PI / 180D) * radius - 8; - GL11.glTranslated(xPos, yPos, 0); - RenderItem.getInstance().renderItemIntoGUI(mc.fontRenderer, mc.renderEngine, getStackInSlot(i), 0, 0); - GL11.glTranslated(-xPos, -yPos, 0); - - angle += anglePer; - } - net.minecraft.client.renderer.RenderHelper.disableStandardItemLighting(); - } else if (recipeKeepTicks > 0) { - String s = StatCollector.translateToLocal("botaniamisc.altarRefill0"); - mc.fontRenderer.drawStringWithShadow(s, xc - mc.fontRenderer.getStringWidth(s) / 2, yc + 10, 0xFFFFFF); - s = StatCollector.translateToLocal("botaniamisc.altarRefill1"); - mc.fontRenderer.drawStringWithShadow(s, xc - mc.fontRenderer.getStringWidth(s) / 2, yc + 20, 0xFFFFFF); - } - } - - public int getTargetMana() { - return manaToGet; - } + private static final String TAG_MANA = "mana"; + private static final String TAG_MANA_TO_GET = "manaToGet"; + + RecipeRuneAltar currentRecipe; + + public int manaToGet = 0; + int mana = 0; + int cooldown = 0; + public int signal = 0; + + List lastRecipe = null; + int recipeKeepTicks = 0; + + public boolean addItem(EntityPlayer player, ItemStack stack) { + if(cooldown > 0 || stack.getItem() == ModItems.twigWand || stack.getItem() == ModItems.lexicon) + return false; + + if(stack.getItem() == Item.getItemFromBlock(ModBlocks.livingrock) && stack.getItemDamage() == 0) { + if(player == null || !player.capabilities.isCreativeMode) { + stack.stackSize--; + if(stack.stackSize == 0 && player != null) + player.inventory.setInventorySlotContents(player.inventory.currentItem, null); + } + + EntityItem item = new EntityItem(worldObj, xCoord + 0.5, yCoord + 1, zCoord + 0.5, new ItemStack(ModBlocks.livingrock)); + item.delayBeforeCanPickup = 40; + item.motionX = item.motionY = item.motionZ = 0; + if(!worldObj.isRemote) + worldObj.spawnEntityInWorld(item); + + return true; + } + + if(manaToGet != 0) + return false; + + boolean did = false; + + for(int i = 0; i < getSizeInventory(); i++) + if(getStackInSlot(i) == null) { + did = true; + ItemStack stackToAdd = stack.copy(); + stackToAdd.stackSize = 1; + setInventorySlotContents(i, stackToAdd); + + if(player == null || !player.capabilities.isCreativeMode) { + stack.stackSize--; + if(stack.stackSize == 0 && player != null) + player.inventory.setInventorySlotContents(player.inventory.currentItem, null); + } + + break; + } + + if(did) + VanillaPacketDispatcher.dispatchTEToNearbyPlayers(worldObj, xCoord, yCoord, zCoord); + + return true; + } + + @Override + public void updateEntity() { + super.updateEntity(); + + // Update every tick. + recieveMana(0); + + if(!worldObj.isRemote && manaToGet == 0) { + List items = worldObj.getEntitiesWithinAABB(EntityItem.class, AxisAlignedBB.getBoundingBox(xCoord, yCoord, zCoord, xCoord + 1, yCoord + 1, zCoord + 1)); + for(EntityItem item : items) + if(!item.isDead && item.getEntityItem() != null && item.getEntityItem().getItem() != Item.getItemFromBlock(ModBlocks.livingrock)) { + ItemStack stack = item.getEntityItem(); + if(addItem(null, stack) && stack.stackSize == 0) + item.setDead(); + } + } + + + if(worldObj.isRemote && manaToGet > 0 && mana >= manaToGet) { + if(worldObj.rand.nextInt(20) == 0) { + Vector3 vec = Vector3.fromTileEntityCenter(this); + Vector3 endVec = vec.copy().add(0, 2.5, 0); + Botania.proxy.lightningFX(worldObj, vec, endVec, 2F, 0x00948B, 0x00E4D7); + } + } + + if(cooldown > 0) { + cooldown--; + Botania.proxy.wispFX(getWorldObj(), xCoord + Math.random(), yCoord + 0.8, zCoord + Math.random(), 0.2F, 0.2F, 0.2F, 0.2F, -0.025F); + } + + int newSignal = 0; + if(manaToGet > 0) { + newSignal++; + if(mana >= manaToGet) + newSignal++; + } + + if(newSignal != signal) { + signal = newSignal; + worldObj.func_147453_f(xCoord, yCoord, zCoord, worldObj.getBlock(xCoord, yCoord, zCoord)); + } + + if(recipeKeepTicks > 0) + --recipeKeepTicks; + else lastRecipe = null; + + updateRecipe(); + } + + public void updateRecipe() { + int manaToGet = this.manaToGet; + + getMana : { + if(currentRecipe != null) + this.manaToGet = currentRecipe.getManaUsage(); + else { + for(RecipeRuneAltar recipe : BotaniaAPI.runeAltarRecipes) + if(recipe.matches(this)) { + this.manaToGet = recipe.getManaUsage(); + break getMana; + } + this.manaToGet = 0; + } + } + + if(manaToGet != this.manaToGet) { + worldObj.playSoundEffect(xCoord, yCoord, zCoord, "botania:runeAltarStart", 1F, 1F); + VanillaPacketDispatcher.dispatchTEToNearbyPlayers(worldObj, xCoord, yCoord, zCoord); + } + } + + public void saveLastRecipe() { + lastRecipe = new ArrayList(); + for(int i = 0; i < getSizeInventory(); i++) { + ItemStack stack = getStackInSlot(i); + if(stack == null) + break; + lastRecipe.add(stack.copy()); + } + recipeKeepTicks = 400; + } + + public void trySetLastRecipe(EntityPlayer player) { + TileAltar.tryToSetLastRecipe(player, this, lastRecipe); + if(!isEmpty()) + VanillaPacketDispatcher.dispatchTEToNearbyPlayers(worldObj, xCoord, yCoord, zCoord); + } + + public boolean hasValidRecipe() { + for(RecipeRuneAltar recipe : BotaniaAPI.runeAltarRecipes) + if(recipe.matches(this)) + return true; + + return false; + } + + public void onWanded(EntityPlayer player, ItemStack wand) { + RecipeRuneAltar recipe = null; + + if(currentRecipe != null) + recipe = currentRecipe; + else for(RecipeRuneAltar recipe_ : BotaniaAPI.runeAltarRecipes) { + if(recipe_.matches(this)) { + recipe = recipe_; + break; + } + } + + if(manaToGet > 0 && mana >= manaToGet) { + List items = worldObj.getEntitiesWithinAABB(EntityItem.class, AxisAlignedBB.getBoundingBox(xCoord, yCoord, zCoord, xCoord + 1, yCoord + 1, zCoord + 1)); + EntityItem livingrock = null; + for(EntityItem item : items) + if(!item.isDead && item.getEntityItem() != null && item.getEntityItem().getItem() == Item.getItemFromBlock(ModBlocks.livingrock)) { + livingrock = item; + break; + } + + if(livingrock != null) { + int mana = recipe.getManaUsage(); + recieveMana(-mana); + if(!worldObj.isRemote) { + ItemStack output = recipe.getOutput().copy(); + EntityItem outputItem = new EntityItem(worldObj, xCoord + 0.5, yCoord + 1.5, zCoord + 0.5, output); + worldObj.spawnEntityInWorld(outputItem); + currentRecipe = null; + cooldown = 60; + } + + saveLastRecipe(); + if(!worldObj.isRemote) { + for(int i = 0; i < getSizeInventory(); i++) { + ItemStack stack = getStackInSlot(i); + if(stack != null) { + if(stack.getItem() == ModItems.rune && (player == null || !player.capabilities.isCreativeMode)) { + EntityItem outputItem = new EntityItem(worldObj, xCoord + 0.5, yCoord + 1.5, zCoord + 0.5, stack.copy()); + worldObj.spawnEntityInWorld(outputItem); + } + + setInventorySlotContents(i, null); + } + } + + ItemStack livingrockItem = livingrock.getEntityItem(); + livingrockItem.stackSize--; + if(livingrockItem.stackSize == 0) + livingrock.setDead(); + } + + craftingFanciness(); + } + } + } + + public void craftingFanciness() { + worldObj.playSoundEffect(xCoord, yCoord, zCoord, "botania:runeAltarCraft", 1F, 1F); + for(int i = 0; i < 25; i++) { + float red = (float) Math.random(); + float green = (float) Math.random(); + float blue = (float) Math.random(); + Botania.proxy.sparkleFX(worldObj, xCoord + 0.5 + Math.random() * 0.4 - 0.2, yCoord + 1, zCoord + 0.5 + Math.random() * 0.4 - 0.2, red, green, blue, (float) Math.random(), 10); + } + } + + public boolean isEmpty() { + for(int i = 0; i < getSizeInventory(); i++) + if(getStackInSlot(i) != null) + return false; + + return true; + } + + @Override + public void writeCustomNBT(NBTTagCompound par1nbtTagCompound) { + super.writeCustomNBT(par1nbtTagCompound); + + par1nbtTagCompound.setInteger(TAG_MANA, mana); + par1nbtTagCompound.setInteger(TAG_MANA_TO_GET, manaToGet); + } + + @Override + public void readCustomNBT(NBTTagCompound par1nbtTagCompound) { + super.readCustomNBT(par1nbtTagCompound); + + mana = par1nbtTagCompound.getInteger(TAG_MANA); + manaToGet = par1nbtTagCompound.getInteger(TAG_MANA_TO_GET); + } + + @Override + public int getSizeInventory() { + return 16; + } + + @Override + public AxisAlignedBB getRenderBoundingBox() { + return INFINITE_EXTENT_AABB; + } + + @Override + public String getInventoryName() { + return LibBlockNames.RUNE_ALTAR; + } + + @Override + public int getInventoryStackLimit() { + return 1; + } + + @Override + public int[] getAccessibleSlotsFromSide(int var1) { + int accessibleSlot = -1; + for(int i = 0; i < getSizeInventory(); i++) + if(getStackInSlot(i) != null) + accessibleSlot = i; + + return accessibleSlot == -1 ? new int[0] : new int[] { accessibleSlot }; + } + + @Override + public boolean canInsertItem(int i, ItemStack itemstack, int j) { + return true; + } + + @Override + public boolean canExtractItem(int i, ItemStack itemstack, int j) { + return mana == 0; + } + + @Override + public int getCurrentMana() { + return mana; + } + + @Override + public boolean isFull() { + return mana >= manaToGet; + } + + @Override + public void recieveMana(int mana) { + this.mana = Math.min(this.mana + mana, manaToGet); + } + + @Override + public boolean canRecieveManaFromBursts() { + return !isFull(); + } + + public void renderHUD(Minecraft mc, ScaledResolution res) { + int xc = res.getScaledWidth() / 2; + int yc = res.getScaledHeight() / 2; + + float angle = -90; + int radius = 24; + int amt = 0; + for(int i = 0; i < getSizeInventory(); i++) { + if(getStackInSlot(i) == null) + break; + amt++; + } + + if(amt > 0) { + float anglePer = 360F / amt; + for(RecipeRuneAltar recipe : BotaniaAPI.runeAltarRecipes) + if(recipe.matches(this)) { + GL11.glEnable(GL11.GL_BLEND); + GL11.glEnable(GL12.GL_RESCALE_NORMAL); + GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); + + recipe.getOutput(); + float progress = (float) mana / (float) manaToGet; + + mc.renderEngine.bindTexture(HUDHandler.manaBar); + GL11.glColor4f(1F, 1F, 1F, 1F); + RenderHelper.drawTexturedModalRect(xc + radius + 9, yc - 8, 0, progress == 1F ? 0 : 22, 8, 22, 15); + + net.minecraft.client.renderer.RenderHelper.enableGUIStandardItemLighting(); + if(progress == 1F) { + RenderItem.getInstance().renderItemIntoGUI(mc.fontRenderer, mc.renderEngine, new ItemStack(ModBlocks.livingrock), xc + radius + 16, yc + 8); + GL11.glTranslatef(0F, 0F, 100F); + RenderItem.getInstance().renderItemIntoGUI(mc.fontRenderer, mc.renderEngine, new ItemStack(ModItems.twigWand), xc + radius + 24, yc + 8); + GL11.glTranslatef(0F, 0F, -100F); + } + + RenderHelper.renderProgressPie(xc + radius + 32, yc - 8, progress, recipe.getOutput()); + net.minecraft.client.renderer.RenderHelper.disableStandardItemLighting(); + + if(progress == 1F) + mc.fontRenderer.drawStringWithShadow("+", xc + radius + 14, yc + 12, 0xFFFFFF); + } + + net.minecraft.client.renderer.RenderHelper.enableGUIStandardItemLighting(); + for(int i = 0; i < amt; i++) { + double xPos = xc + Math.cos(angle * Math.PI / 180D) * radius - 8; + double yPos = yc + Math.sin(angle * Math.PI / 180D) * radius - 8; + GL11.glTranslated(xPos, yPos, 0); + RenderItem.getInstance().renderItemIntoGUI(mc.fontRenderer, mc.renderEngine, getStackInSlot(i), 0, 0); + GL11.glTranslated(-xPos, -yPos, 0); + + angle += anglePer; + } + net.minecraft.client.renderer.RenderHelper.disableStandardItemLighting(); + } else if(recipeKeepTicks > 0) { + String s = StatCollector.translateToLocal("botaniamisc.altarRefill0"); + mc.fontRenderer.drawStringWithShadow(s, xc - mc.fontRenderer.getStringWidth(s) / 2, yc + 10, 0xFFFFFF); + s = StatCollector.translateToLocal("botaniamisc.altarRefill1"); + mc.fontRenderer.drawStringWithShadow(s, xc - mc.fontRenderer.getStringWidth(s) / 2, yc + 20, 0xFFFFFF); + } + } + + public int getTargetMana() { + return manaToGet; + } + } diff --git a/src/main/java/vazkii/botania/common/block/tile/TileSimpleInventory.java b/src/main/java/vazkii/botania/common/block/tile/TileSimpleInventory.java index 1ac479223c..15a9f41442 100644 --- a/src/main/java/vazkii/botania/common/block/tile/TileSimpleInventory.java +++ b/src/main/java/vazkii/botania/common/block/tile/TileSimpleInventory.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jan 21, 2014, 9:56:24 PM (GMT)] */ package vazkii.botania.common.block.tile; @@ -18,98 +18,98 @@ public abstract class TileSimpleInventory extends TileMod implements IInventory { - ItemStack[] inventorySlots = new ItemStack[getSizeInventory()]; - - @Override - public void readCustomNBT(NBTTagCompound par1NBTTagCompound) { - NBTTagList var2 = par1NBTTagCompound.getTagList("Items", 10); - inventorySlots = new ItemStack[getSizeInventory()]; - for (int var3 = 0; var3 < var2.tagCount(); ++var3) { - NBTTagCompound var4 = var2.getCompoundTagAt(var3); - byte var5 = var4.getByte("Slot"); - if (var5 >= 0 && var5 < inventorySlots.length) inventorySlots[var5] = ItemStack.loadItemStackFromNBT(var4); - } - } - - @Override - public void writeCustomNBT(NBTTagCompound par1NBTTagCompound) { - NBTTagList var2 = new NBTTagList(); - for (int var3 = 0; var3 < inventorySlots.length; ++var3) { - if (inventorySlots[var3] != null) { - NBTTagCompound var4 = new NBTTagCompound(); - var4.setByte("Slot", (byte) var3); - inventorySlots[var3].writeToNBT(var4); - var2.appendTag(var4); - } - } - par1NBTTagCompound.setTag("Items", var2); - } - - @Override - public ItemStack getStackInSlot(int i) { - return inventorySlots[i]; - } - - @Override - public ItemStack decrStackSize(int i, int j) { - if (inventorySlots[i] != null) { - ItemStack stackAt; - - if (inventorySlots[i].stackSize <= j) { - stackAt = inventorySlots[i]; - inventorySlots[i] = null; - return stackAt; - } else { - stackAt = inventorySlots[i].splitStack(j); - - if (inventorySlots[i].stackSize == 0) inventorySlots[i] = null; - - return stackAt; - } - } - - return null; - } - - @Override - public ItemStack getStackInSlotOnClosing(int i) { - return getStackInSlot(i); - } - - @Override - public void setInventorySlotContents(int i, ItemStack itemstack) { - inventorySlots[i] = itemstack; - } - - @Override - public int getInventoryStackLimit() { - return 64; - } - - @Override - public boolean isUseableByPlayer(EntityPlayer entityplayer) { - return worldObj.getTileEntity(xCoord, yCoord, zCoord) != this - ? false - : entityplayer.getDistanceSq(xCoord + 0.5D, yCoord + 0.5D, zCoord + 0.5D) <= 64; - } - - @Override - public boolean isItemValidForSlot(int i, ItemStack itemstack) { - return true; - } - - @Override - public boolean hasCustomInventoryName() { - return false; - } - - @Override - public void openInventory() { - // NO-OP - } - - @Override - public void closeInventory() { - // NO-OP - } + ItemStack[] inventorySlots = new ItemStack[getSizeInventory()]; + + @Override + public void readCustomNBT(NBTTagCompound par1NBTTagCompound) { + NBTTagList var2 = par1NBTTagCompound.getTagList("Items", 10); + inventorySlots = new ItemStack[getSizeInventory()]; + for (int var3 = 0; var3 < var2.tagCount(); ++var3) { + NBTTagCompound var4 = var2.getCompoundTagAt(var3); + byte var5 = var4.getByte("Slot"); + if (var5 >= 0 && var5 < inventorySlots.length) + inventorySlots[var5] = ItemStack.loadItemStackFromNBT(var4); + } + } + + @Override + public void writeCustomNBT(NBTTagCompound par1NBTTagCompound) { + NBTTagList var2 = new NBTTagList(); + for (int var3 = 0; var3 < inventorySlots.length; ++var3) { + if (inventorySlots[var3] != null) { + NBTTagCompound var4 = new NBTTagCompound(); + var4.setByte("Slot", (byte)var3); + inventorySlots[var3].writeToNBT(var4); + var2.appendTag(var4); + } + } + par1NBTTagCompound.setTag("Items", var2); + } + + @Override + public ItemStack getStackInSlot(int i) { + return inventorySlots[i]; + } + + @Override + public ItemStack decrStackSize(int i, int j) { + if (inventorySlots[i] != null) { + ItemStack stackAt; + + if (inventorySlots[i].stackSize <= j) { + stackAt = inventorySlots[i]; + inventorySlots[i] = null; + return stackAt; + } else { + stackAt = inventorySlots[i].splitStack(j); + + if (inventorySlots[i].stackSize == 0) + inventorySlots[i] = null; + + return stackAt; + } + } + + return null; + } + + @Override + public ItemStack getStackInSlotOnClosing(int i) { + return getStackInSlot(i); + } + + @Override + public void setInventorySlotContents(int i, ItemStack itemstack) { + inventorySlots[i] = itemstack; + } + + @Override + public int getInventoryStackLimit() { + return 64; + } + + @Override + public boolean isUseableByPlayer(EntityPlayer entityplayer) { + return worldObj.getTileEntity(xCoord, yCoord, zCoord) != this ? false : entityplayer.getDistanceSq(xCoord + 0.5D, yCoord + 0.5D, zCoord + 0.5D) <= 64; + } + + @Override + public boolean isItemValidForSlot(int i, ItemStack itemstack) { + return true; + } + + @Override + public boolean hasCustomInventoryName() { + return false; + } + + @Override + public void openInventory() { + // NO-OP + } + + @Override + public void closeInventory() { + // NO-OP + } } diff --git a/src/main/java/vazkii/botania/common/block/tile/TileSparkChanger.java b/src/main/java/vazkii/botania/common/block/tile/TileSparkChanger.java index dd1b5ddc94..8b37e9c676 100644 --- a/src/main/java/vazkii/botania/common/block/tile/TileSparkChanger.java +++ b/src/main/java/vazkii/botania/common/block/tile/TileSparkChanger.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jun 28, 2015, 10:02:11 PM (GMT)] */ package vazkii.botania.common.block.tile; @@ -13,6 +13,7 @@ import java.util.ArrayList; import java.util.Collection; import java.util.List; + import net.minecraft.item.ItemStack; import net.minecraft.tileentity.TileEntity; import net.minecraftforge.common.util.ForgeDirection; @@ -25,62 +26,66 @@ public class TileSparkChanger extends TileSimpleInventory { - public void doSwap() { - if (worldObj.isRemote) return; + public void doSwap() { + if(worldObj.isRemote) + return; + + ItemStack changeStack = getStackInSlot(0); + List attachables = new ArrayList(); + for(ForgeDirection dir : LibMisc.CARDINAL_DIRECTIONS) { + TileEntity tile = worldObj.getTileEntity(xCoord + dir.offsetX, yCoord, zCoord + dir.offsetZ); + if(tile != null && tile instanceof ISparkAttachable) { + ISparkAttachable attach = (ISparkAttachable) tile; + ISparkEntity spark = attach.getAttachedSpark(); + if(spark != null) { + int upg = spark.getUpgrade(); + int newUpg = changeStack == null ? 0 : changeStack.getItemDamage() + 1; + if(upg != newUpg) + attachables.add(attach); + } + } + } - ItemStack changeStack = getStackInSlot(0); - List attachables = new ArrayList(); - for (ForgeDirection dir : LibMisc.CARDINAL_DIRECTIONS) { - TileEntity tile = worldObj.getTileEntity(xCoord + dir.offsetX, yCoord, zCoord + dir.offsetZ); - if (tile != null && tile instanceof ISparkAttachable) { - ISparkAttachable attach = (ISparkAttachable) tile; - ISparkEntity spark = attach.getAttachedSpark(); - if (spark != null) { - int upg = spark.getUpgrade(); - int newUpg = changeStack == null ? 0 : changeStack.getItemDamage() + 1; - if (upg != newUpg) attachables.add(attach); - } - } - } + if(attachables.size() > 0) { + ISparkAttachable attach = attachables.get(worldObj.rand.nextInt(attachables.size())); + ISparkEntity spark = attach.getAttachedSpark(); + int upg = spark.getUpgrade(); + ItemStack sparkStack = upg == 0 ? null : new ItemStack(ModItems.sparkUpgrade, 1, upg - 1); + int newUpg = changeStack == null ? 0 : changeStack.getItemDamage() + 1; + spark.setUpgrade(newUpg); + Collection transfers = spark.getTransfers(); + if(transfers != null) + transfers.clear(); + setInventorySlotContents(0, sparkStack); + worldObj.func_147453_f(xCoord, yCoord, zCoord, worldObj.getBlock(xCoord, yCoord, zCoord)); + markDirty(); + } + } - if (attachables.size() > 0) { - ISparkAttachable attach = attachables.get(worldObj.rand.nextInt(attachables.size())); - ISparkEntity spark = attach.getAttachedSpark(); - int upg = spark.getUpgrade(); - ItemStack sparkStack = upg == 0 ? null : new ItemStack(ModItems.sparkUpgrade, 1, upg - 1); - int newUpg = changeStack == null ? 0 : changeStack.getItemDamage() + 1; - spark.setUpgrade(newUpg); - Collection transfers = spark.getTransfers(); - if (transfers != null) transfers.clear(); - setInventorySlotContents(0, sparkStack); - worldObj.func_147453_f(xCoord, yCoord, zCoord, worldObj.getBlock(xCoord, yCoord, zCoord)); - markDirty(); - } - } + @Override + public int getSizeInventory() { + return 1; + } - @Override - public int getSizeInventory() { - return 1; - } + @Override + public boolean isItemValidForSlot(int i, ItemStack itemstack) { + return itemstack != null && itemstack.getItem() == ModItems.sparkUpgrade; + } - @Override - public boolean isItemValidForSlot(int i, ItemStack itemstack) { - return itemstack != null && itemstack.getItem() == ModItems.sparkUpgrade; - } + @Override + public int getInventoryStackLimit() { + return 1; + } - @Override - public int getInventoryStackLimit() { - return 1; - } + @Override + public void markDirty() { + super.markDirty(); + VanillaPacketDispatcher.dispatchTEToNearbyPlayers(this); + } - @Override - public void markDirty() { - super.markDirty(); - VanillaPacketDispatcher.dispatchTEToNearbyPlayers(this); - } + @Override + public String getInventoryName() { + return LibBlockNames.SPARK_CHANGER; + } - @Override - public String getInventoryName() { - return LibBlockNames.SPARK_CHANGER; - } } diff --git a/src/main/java/vazkii/botania/common/block/tile/TileSpawnerClaw.java b/src/main/java/vazkii/botania/common/block/tile/TileSpawnerClaw.java index 9edb884c8e..81e97bb4e9 100644 --- a/src/main/java/vazkii/botania/common/block/tile/TileSpawnerClaw.java +++ b/src/main/java/vazkii/botania/common/block/tile/TileSpawnerClaw.java @@ -2,16 +2,16 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jul 23, 2014, 5:32:11 PM (GMT)] */ package vazkii.botania.common.block.tile; -import cpw.mods.fml.relauncher.ReflectionHelper; import java.util.List; + import net.minecraft.entity.Entity; import net.minecraft.entity.EntityList; import net.minecraft.entity.EntityLiving; @@ -24,159 +24,131 @@ import vazkii.botania.api.mana.IManaReceiver; import vazkii.botania.common.Botania; import vazkii.botania.common.lib.LibObfuscation; +import cpw.mods.fml.relauncher.ReflectionHelper; public class TileSpawnerClaw extends TileMod implements IManaReceiver { - private static final String TAG_MANA = "mana"; - - int mana = 0; - - @Override - public void updateEntity() { - TileEntity tileBelow = worldObj.getTileEntity(xCoord, yCoord - 1, zCoord); - if (mana >= 5 && tileBelow instanceof TileEntityMobSpawner) { - TileEntityMobSpawner spawner = (TileEntityMobSpawner) tileBelow; - MobSpawnerBaseLogic logic = spawner.func_145881_a(); - - if (!logic.isActivated()) { - if (!worldObj.isRemote) mana -= 6; - - if (logic.getSpawnerWorld().isRemote) { - if (logic.spawnDelay > 0) --logic.spawnDelay; - - if (Math.random() > 0.5) - Botania.proxy.wispFX( - worldObj, - xCoord + 0.3 + Math.random() * 0.5, - yCoord - 0.3 + Math.random() * 0.25, - zCoord + Math.random(), - 0.6F - (float) Math.random() * 0.3F, - 0.1F, - 0.6F - (float) Math.random() * 0.3F, - (float) Math.random() / 3F, - -0.025F - 0.005F * (float) Math.random(), - 2F); - - logic.field_98284_d = logic.field_98287_c; - logic.field_98287_c = (logic.field_98287_c + 1000.0F / (logic.spawnDelay + 200.0F)) % 360.0D; - } else if (logic.spawnDelay == -1) resetTimer(logic); - - if (logic.spawnDelay > 0) { - --logic.spawnDelay; - return; - } - - boolean flag = false; - - int spawnCount = - ReflectionHelper.getPrivateValue(MobSpawnerBaseLogic.class, logic, LibObfuscation.SPAWN_COUNT); - int spawnRange = - ReflectionHelper.getPrivateValue(MobSpawnerBaseLogic.class, logic, LibObfuscation.SPAWN_RANGE); - int maxNearbyEntities = ReflectionHelper.getPrivateValue( - MobSpawnerBaseLogic.class, logic, LibObfuscation.MAX_NEARBY_ENTITIES); - - for (int i = 0; i < spawnCount; ++i) { - Entity entity = - EntityList.createEntityByName(logic.getEntityNameToSpawn(), logic.getSpawnerWorld()); - - if (entity == null) return; - - int j = logic.getSpawnerWorld() - .getEntitiesWithinAABB( - entity.getClass(), - AxisAlignedBB.getBoundingBox( - logic.getSpawnerX(), - logic.getSpawnerY(), - logic.getSpawnerZ(), - logic.getSpawnerX() + 1, - logic.getSpawnerY() + 1, - logic.getSpawnerZ() + 1) - .expand(spawnRange * 2, 4.0D, spawnRange * 2)) - .size(); - - if (j >= maxNearbyEntities) { - resetTimer(logic); - return; - } - - double d2 = logic.getSpawnerX() - + (logic.getSpawnerWorld().rand.nextDouble() - - logic.getSpawnerWorld().rand.nextDouble()) - * spawnRange; - double d3 = - logic.getSpawnerY() + logic.getSpawnerWorld().rand.nextInt(3) - 1; - double d4 = logic.getSpawnerZ() - + (logic.getSpawnerWorld().rand.nextDouble() - - logic.getSpawnerWorld().rand.nextDouble()) - * spawnRange; - EntityLiving entityliving = entity instanceof EntityLiving ? (EntityLiving) entity : null; - entity.setLocationAndAngles( - d2, d3, d4, logic.getSpawnerWorld().rand.nextFloat() * 360.0F, 0.0F); - - if (entityliving == null || entityliving.getCanSpawnHere()) { - if (!worldObj.isRemote) logic.func_98265_a(entity); - logic.getSpawnerWorld() - .playAuxSFX(2004, logic.getSpawnerX(), logic.getSpawnerY(), logic.getSpawnerZ(), 0); - - if (entityliving != null) entityliving.spawnExplosionParticle(); - - flag = true; - } - } - - if (flag) resetTimer(logic); - } - } - } - - private void resetTimer(MobSpawnerBaseLogic logic) { - int maxSpawnDelay = - ReflectionHelper.getPrivateValue(MobSpawnerBaseLogic.class, logic, LibObfuscation.MAX_SPAWN_DELAY); - int minSpawnDelay = - ReflectionHelper.getPrivateValue(MobSpawnerBaseLogic.class, logic, LibObfuscation.MIN_SPAWN_DELAY); - List potentialEntitySpawns = ReflectionHelper.getPrivateValue( - MobSpawnerBaseLogic.class, logic, LibObfuscation.POTENTIAL_ENTITY_SPAWNS); - - if (maxSpawnDelay <= minSpawnDelay) logic.spawnDelay = minSpawnDelay; - else { - int i = maxSpawnDelay - minSpawnDelay; - logic.spawnDelay = minSpawnDelay + logic.getSpawnerWorld().rand.nextInt(i); - } - - if (potentialEntitySpawns != null && potentialEntitySpawns.size() > 0) - logic.setRandomEntity((MobSpawnerBaseLogic.WeightedRandomMinecart) - WeightedRandom.getRandomItem(logic.getSpawnerWorld().rand, potentialEntitySpawns)); - - logic.func_98267_a(1); - } - - @Override - public void writeCustomNBT(NBTTagCompound cmp) { - cmp.setInteger(TAG_MANA, mana); - } - - @Override - public void readCustomNBT(NBTTagCompound cmp) { - mana = cmp.getInteger(TAG_MANA); - } - - @Override - public int getCurrentMana() { - return mana; - } - - @Override - public boolean isFull() { - return mana >= 160; - } - - @Override - public void recieveMana(int mana) { - this.mana = Math.min(160, this.mana + mana); - } - - @Override - public boolean canRecieveManaFromBursts() { - return true; - } + private static final String TAG_MANA = "mana"; + + int mana = 0; + + @Override + public void updateEntity() { + TileEntity tileBelow = worldObj.getTileEntity(xCoord, yCoord - 1, zCoord); + if(mana >= 5 && tileBelow instanceof TileEntityMobSpawner) { + TileEntityMobSpawner spawner = (TileEntityMobSpawner) tileBelow; + MobSpawnerBaseLogic logic = spawner.func_145881_a(); + + if(!logic.isActivated()) { + if(!worldObj.isRemote) + mana -= 6; + + if(logic.getSpawnerWorld().isRemote) { + if(logic.spawnDelay > 0) + --logic.spawnDelay; + + if(Math.random() > 0.5) + Botania.proxy.wispFX(worldObj, xCoord + 0.3 + Math.random() * 0.5, yCoord - 0.3 + Math.random() * 0.25, zCoord + Math.random(), 0.6F - (float) Math.random() * 0.3F, 0.1F, 0.6F - (float) Math.random() * 0.3F, (float) Math.random() / 3F, -0.025F - 0.005F * (float) Math.random(), 2F); + + logic.field_98284_d = logic.field_98287_c; + logic.field_98287_c = (logic.field_98287_c + 1000.0F / (logic.spawnDelay + 200.0F)) % 360.0D; + } else if(logic.spawnDelay == -1) + resetTimer(logic); + + if(logic.spawnDelay > 0) { + --logic.spawnDelay; + return; + } + + boolean flag = false; + + int spawnCount = ReflectionHelper.getPrivateValue(MobSpawnerBaseLogic.class, logic, LibObfuscation.SPAWN_COUNT); + int spawnRange = ReflectionHelper.getPrivateValue(MobSpawnerBaseLogic.class, logic, LibObfuscation.SPAWN_RANGE); + int maxNearbyEntities = ReflectionHelper.getPrivateValue(MobSpawnerBaseLogic.class, logic, LibObfuscation.MAX_NEARBY_ENTITIES); + + for(int i = 0; i < spawnCount; ++i) { + Entity entity = EntityList.createEntityByName(logic.getEntityNameToSpawn(), logic.getSpawnerWorld()); + + if (entity == null) + return; + + int j = logic.getSpawnerWorld().getEntitiesWithinAABB(entity.getClass(), AxisAlignedBB.getBoundingBox(logic.getSpawnerX(), logic.getSpawnerY(), logic.getSpawnerZ(), logic.getSpawnerX() + 1, logic.getSpawnerY() + 1, logic.getSpawnerZ() + 1).expand(spawnRange * 2, 4.0D, spawnRange * 2)).size(); + + if (j >= maxNearbyEntities) { + resetTimer(logic); + return; + } + + double d2 = logic.getSpawnerX() + (logic.getSpawnerWorld().rand.nextDouble() - logic.getSpawnerWorld().rand.nextDouble()) * spawnRange; + double d3 = logic.getSpawnerY() + logic.getSpawnerWorld().rand.nextInt(3) - 1; + double d4 = logic.getSpawnerZ() + (logic.getSpawnerWorld().rand.nextDouble() - logic.getSpawnerWorld().rand.nextDouble()) * spawnRange; + EntityLiving entityliving = entity instanceof EntityLiving ? (EntityLiving)entity : null; + entity.setLocationAndAngles(d2, d3, d4, logic.getSpawnerWorld().rand.nextFloat() * 360.0F, 0.0F); + + if(entityliving == null || entityliving.getCanSpawnHere()) { + if(!worldObj.isRemote) + logic.func_98265_a(entity); + logic.getSpawnerWorld().playAuxSFX(2004, logic.getSpawnerX(), logic.getSpawnerY(), logic.getSpawnerZ(), 0); + + if (entityliving != null) + entityliving.spawnExplosionParticle(); + + flag = true; + } + } + + if (flag) + resetTimer(logic); + } + } + } + + private void resetTimer(MobSpawnerBaseLogic logic) { + int maxSpawnDelay = ReflectionHelper.getPrivateValue(MobSpawnerBaseLogic.class, logic, LibObfuscation.MAX_SPAWN_DELAY); + int minSpawnDelay = ReflectionHelper.getPrivateValue(MobSpawnerBaseLogic.class, logic, LibObfuscation.MIN_SPAWN_DELAY); + List potentialEntitySpawns = ReflectionHelper.getPrivateValue(MobSpawnerBaseLogic.class, logic, LibObfuscation.POTENTIAL_ENTITY_SPAWNS); + + if(maxSpawnDelay <= minSpawnDelay) + logic.spawnDelay = minSpawnDelay; + else { + int i = maxSpawnDelay - minSpawnDelay; + logic.spawnDelay = minSpawnDelay + logic.getSpawnerWorld().rand.nextInt(i); + } + + if(potentialEntitySpawns != null && potentialEntitySpawns.size() > 0) + logic.setRandomEntity((MobSpawnerBaseLogic.WeightedRandomMinecart)WeightedRandom.getRandomItem(logic.getSpawnerWorld().rand, potentialEntitySpawns)); + + logic.func_98267_a(1); + } + + @Override + public void writeCustomNBT(NBTTagCompound cmp) { + cmp.setInteger(TAG_MANA, mana); + } + + @Override + public void readCustomNBT(NBTTagCompound cmp) { + mana = cmp.getInteger(TAG_MANA); + } + + @Override + public int getCurrentMana() { + return mana; + } + + @Override + public boolean isFull() { + return mana >= 160; + } + + @Override + public void recieveMana(int mana) { + this.mana = Math.min(160, this.mana + mana); + } + + @Override + public boolean canRecieveManaFromBursts() { + return true; + } + } diff --git a/src/main/java/vazkii/botania/common/block/tile/TileSpecialFlower.java b/src/main/java/vazkii/botania/common/block/tile/TileSpecialFlower.java index 48901d31aa..34dbfb26ff 100644 --- a/src/main/java/vazkii/botania/common/block/tile/TileSpecialFlower.java +++ b/src/main/java/vazkii/botania/common/block/tile/TileSpecialFlower.java @@ -2,15 +2,16 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jan 22, 2014, 7:21:51 PM (GMT)] */ package vazkii.botania.common.block.tile; import java.util.ArrayList; + import net.minecraft.block.Block; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.ScaledResolution; @@ -33,192 +34,205 @@ public class TileSpecialFlower extends TileMod implements IWandBindable, ISubTileSlowableContainer { - private static final String TAG_SUBTILE_NAME = "subTileName"; - private static final String TAG_SUBTILE_CMP = "subTileCmp"; - - public String subTileName = ""; - SubTileEntity subTile; - - @Override - public SubTileEntity getSubTile() { - return subTile; - } - - @Override - public void setSubTile(String name) { - subTileName = name; - provideSubTile(subTileName); - } - - public void setSubTile(SubTileEntity tile) { - subTile = tile; - subTile.setSupertile(this); - } - - private void provideSubTile(String name) { - subTileName = name; - - Class tileClass = BotaniaAPI.getSubTileMapping(name); - try { - SubTileEntity tile = tileClass.newInstance(); - setSubTile(tile); - } catch (Exception e) { - e.printStackTrace(); - } - } - - @Override - public void updateEntity() { - if (subTile != null) { - TileEntity tileBelow = worldObj.getTileEntity(xCoord, yCoord - 1, zCoord); - if (tileBelow instanceof TileRedStringRelay) { - ChunkCoordinates coords = ((TileRedStringRelay) tileBelow).getBinding(); - if (coords != null) { - int currX = xCoord; - int currY = yCoord; - int currZ = zCoord; - xCoord = coords.posX; - yCoord = coords.posY; - zCoord = coords.posZ; - subTile.onUpdate(); - xCoord = currX; - yCoord = currY; - zCoord = currZ; - - return; - } - } - - boolean special = isOnSpecialSoil(); - if (special) { - subTile.overgrowth = true; - if (subTile.isOvergrowthAffected()) { - subTile.onUpdate(); - subTile.overgrowthBoost = true; - } - } - subTile.onUpdate(); - subTile.overgrowth = false; - subTile.overgrowthBoost = false; - } - } - - public boolean isOnSpecialSoil() { - return worldObj.getBlock(xCoord, yCoord - 1, zCoord) == ModBlocks.enchantedSoil; - } - - @Override - public boolean canUpdate() { - return subTile == null || subTile.canUpdate(); - } - - @Override - public void writeCustomNBT(NBTTagCompound cmp) { - super.writeCustomNBT(cmp); - - cmp.setString(TAG_SUBTILE_NAME, subTileName); - NBTTagCompound subCmp = new NBTTagCompound(); - cmp.setTag(TAG_SUBTILE_CMP, subCmp); - - if (subTile != null) subTile.writeToPacketNBTInternal(subCmp); - } - - @Override - public void readCustomNBT(NBTTagCompound cmp) { - super.readCustomNBT(cmp); - - subTileName = cmp.getString(TAG_SUBTILE_NAME); - NBTTagCompound subCmp = cmp.getCompoundTag(TAG_SUBTILE_CMP); - - if (subTile == null - || !BotaniaAPI.getSubTileStringMapping(subTile.getClass()).equals(subTileName)) - provideSubTile(subTileName); - - if (subTile != null) subTile.readFromPacketNBTInternal(subCmp); - } - - public IIcon getIcon() { - return subTile == null ? Blocks.red_flower.getIcon(0, 0) : subTile.getIcon(); - } - - public LexiconEntry getEntry() { - return subTile == null ? null : subTile.getEntry(); - } - - public boolean onWanded(ItemStack wand, EntityPlayer player) { - return subTile == null ? false : subTile.onWanded(player, wand); - } - - public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase entity, ItemStack stack) { - if (subTile != null) subTile.onBlockPlacedBy(world, x, y, z, entity, stack); - } - - public boolean onBlockActivated( - World world, int x, int y, int z, EntityPlayer player, int side, float hitX, float hitY, float hitZ) { - return subTile == null ? false : subTile.onBlockActivated(world, x, y, z, player, side, hitX, hitY, hitZ); - } - - public void onBlockAdded(World world, int x, int y, int z) { - if (subTile != null) subTile.onBlockAdded(world, x, y, z); - } - - public void onBlockHarvested(World world, int x, int y, int z, int side, EntityPlayer player) { - if (subTile != null) subTile.onBlockHarvested(world, x, y, z, side, player); - } - - public ArrayList getDrops(ArrayList list) { - if (subTile != null) subTile.getDrops(list); - - return list; - } - - public void renderHUD(Minecraft mc, ScaledResolution res) { - if (subTile != null) subTile.renderHUD(mc, res); - } - - @Override - public ChunkCoordinates getBinding() { - if (subTile == null) return null; - return subTile.getBinding(); - } - - @Override - public boolean canSelect(EntityPlayer player, ItemStack wand, int x, int y, int z, int side) { - if (subTile == null) return false; - return subTile.canSelect(player, wand, x, y, z, side); - } - - @Override - public boolean bindTo(EntityPlayer player, ItemStack wand, int x, int y, int z, int side) { - if (subTile == null) return false; - return subTile.bindTo(player, wand, x, y, z, side); - } - - public int getLightValue() { - if (subTile == null) return -1; - return subTile.getLightValue(); - } - - public int getComparatorInputOverride(int side) { - if (subTile == null) return 0; - return subTile.getComparatorInputOverride(side); - } - - public int getPowerLevel(int side) { - if (subTile == null) return 0; - return subTile.getPowerLevel(side); - } - - @Override - public int getSlowdownFactor() { - Block below = worldObj.getBlock(xCoord, yCoord - 1, zCoord); - if (below == Blocks.mycelium) return SLOWDOWN_FACTOR_MYCEL; - - if (below == Blocks.dirt) { - int meta = worldObj.getBlockMetadata(xCoord, yCoord - 1, zCoord); - if (meta == 2) return SLOWDOWN_FACTOR_PODZOL; - } - - return 0; - } + private static final String TAG_SUBTILE_NAME = "subTileName"; + private static final String TAG_SUBTILE_CMP = "subTileCmp"; + + public String subTileName = ""; + SubTileEntity subTile; + + @Override + public SubTileEntity getSubTile() { + return subTile; + } + + @Override + public void setSubTile(String name) { + subTileName = name; + provideSubTile(subTileName); + } + + public void setSubTile(SubTileEntity tile) { + subTile = tile; + subTile.setSupertile(this); + } + + private void provideSubTile(String name) { + subTileName = name; + + Class tileClass = BotaniaAPI.getSubTileMapping(name); + try { + SubTileEntity tile = tileClass.newInstance(); + setSubTile(tile); + } catch (Exception e) { + e.printStackTrace(); + } + } + + @Override + public void updateEntity() { + if(subTile != null) { + TileEntity tileBelow = worldObj.getTileEntity(xCoord, yCoord - 1, zCoord); + if(tileBelow instanceof TileRedStringRelay) { + ChunkCoordinates coords = ((TileRedStringRelay) tileBelow).getBinding(); + if(coords != null) { + int currX = xCoord; + int currY = yCoord; + int currZ = zCoord; + xCoord = coords.posX; + yCoord = coords.posY; + zCoord = coords.posZ; + subTile.onUpdate(); + xCoord = currX; + yCoord = currY; + zCoord = currZ; + + return; + } + } + + boolean special = isOnSpecialSoil(); + if(special) { + subTile.overgrowth = true; + if(subTile.isOvergrowthAffected()) { + subTile.onUpdate(); + subTile.overgrowthBoost = true; + } + } + subTile.onUpdate(); + subTile.overgrowth = false; + subTile.overgrowthBoost = false; + } + } + + public boolean isOnSpecialSoil() { + return worldObj.getBlock(xCoord, yCoord - 1, zCoord) == ModBlocks.enchantedSoil; + } + + @Override + public boolean canUpdate() { + return subTile == null || subTile.canUpdate(); + } + + @Override + public void writeCustomNBT(NBTTagCompound cmp) { + super.writeCustomNBT(cmp); + + cmp.setString(TAG_SUBTILE_NAME, subTileName); + NBTTagCompound subCmp = new NBTTagCompound(); + cmp.setTag(TAG_SUBTILE_CMP, subCmp); + + if(subTile != null) + subTile.writeToPacketNBTInternal(subCmp); + } + + @Override + public void readCustomNBT(NBTTagCompound cmp) { + super.readCustomNBT(cmp); + + subTileName = cmp.getString(TAG_SUBTILE_NAME); + NBTTagCompound subCmp = cmp.getCompoundTag(TAG_SUBTILE_CMP); + + if(subTile == null || !BotaniaAPI.getSubTileStringMapping(subTile.getClass()).equals(subTileName)) + provideSubTile(subTileName); + + if(subTile != null) + subTile.readFromPacketNBTInternal(subCmp); + } + + public IIcon getIcon() { + return subTile == null ? Blocks.red_flower.getIcon(0, 0) : subTile.getIcon(); + } + + public LexiconEntry getEntry() { + return subTile == null ? null : subTile.getEntry(); + } + + public boolean onWanded(ItemStack wand, EntityPlayer player) { + return subTile == null ? false : subTile.onWanded(player, wand); + } + + public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase entity, ItemStack stack) { + if (subTile != null) + subTile.onBlockPlacedBy(world, x, y, z, entity, stack); + } + + public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int side, float hitX, float hitY, float hitZ) { + return subTile == null ? false : subTile.onBlockActivated(world, x, y, z, player, side, hitX, hitY, hitZ); + } + + public void onBlockAdded(World world, int x, int y, int z) { + if (subTile != null) + subTile.onBlockAdded(world, x, y, z); + } + + public void onBlockHarvested(World world, int x, int y, int z, int side, EntityPlayer player) { + if (subTile != null) + subTile.onBlockHarvested(world, x, y, z, side, player); + } + + public ArrayList getDrops(ArrayList list) { + if (subTile != null) + subTile.getDrops(list); + + return list; + } + + public void renderHUD(Minecraft mc, ScaledResolution res) { + if(subTile != null) + subTile.renderHUD(mc, res); + } + + @Override + public ChunkCoordinates getBinding() { + if(subTile == null) + return null; + return subTile.getBinding(); + } + + @Override + public boolean canSelect(EntityPlayer player, ItemStack wand, int x, int y, int z, int side) { + if(subTile == null) + return false; + return subTile.canSelect(player, wand, x, y, z, side); + } + + @Override + public boolean bindTo(EntityPlayer player, ItemStack wand, int x, int y, int z, int side) { + if(subTile == null) + return false; + return subTile.bindTo(player, wand, x, y, z, side); + } + + public int getLightValue() { + if(subTile == null) + return -1; + return subTile.getLightValue(); + } + + public int getComparatorInputOverride(int side) { + if(subTile == null) + return 0; + return subTile.getComparatorInputOverride(side); + } + + public int getPowerLevel(int side) { + if(subTile == null) + return 0; + return subTile.getPowerLevel(side); + } + + @Override + public int getSlowdownFactor() { + Block below = worldObj.getBlock(xCoord, yCoord - 1, zCoord); + if(below == Blocks.mycelium) + return SLOWDOWN_FACTOR_MYCEL; + + if(below == Blocks.dirt) { + int meta = worldObj.getBlockMetadata(xCoord, yCoord - 1, zCoord); + if(meta == 2) + return SLOWDOWN_FACTOR_PODZOL; + } + + return 0; + } } diff --git a/src/main/java/vazkii/botania/common/block/tile/TileSpiritShrine.java b/src/main/java/vazkii/botania/common/block/tile/TileSpiritShrine.java index 2ef90f7d3e..1925fad265 100644 --- a/src/main/java/vazkii/botania/common/block/tile/TileSpiritShrine.java +++ b/src/main/java/vazkii/botania/common/block/tile/TileSpiritShrine.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Apr 1, 2014, 1:55:57 PM (GMT)] */ package vazkii.botania.common.block.tile; @@ -14,80 +14,49 @@ public class TileSpiritShrine extends TileMod { - int ticks; + int ticks; + + @Override + public void updateEntity() { + if(worldObj.isRemote) { + if(ticks >= 40) { + float[][] colors = new float[][] { + { 0F, 0.25F, 1F }, + { 1F, 0F, 0.2F }, + { 0F, 1F, 0.25F }, + { 1F, 1F, 0.25F }, + { 1F, 0.25F, 1F }, + { 0.25F, 1F, 1F } + }; + + int totalSpiritCount = 6; + double tickIncrement = 360D / totalSpiritCount; + + int liftTicks = 40 * (totalSpiritCount + 1); + int existTicks = liftTicks * 2; + int lowerTicks = existTicks + liftTicks; + + if(ticks < lowerTicks) { + int speed = 5; + double wticks = ticks * speed - tickIncrement; + double r = Math.sin((ticks >= liftTicks ? (ticks - liftTicks) * speed - tickIncrement : -tickIncrement) * Math.PI / 180 * 0.75) + 1 * 1.25 + 0.5; + double g = Math.sin(wticks * Math.PI / 180 * 0.55); + + for(int i = 0; i < totalSpiritCount; i++) { + double x = xCoord + Math.sin(wticks * Math.PI / 180) * r + 0.5; + double y = yCoord + (ticks > existTicks ? 40 - (double) (ticks - existTicks) : Math.min(80 + 40 * i, ticks) - 40 * (i + 1)) * 0.1; + double z = zCoord + Math.cos(wticks * Math.PI / 180) * r + 0.5; + + wticks += tickIncrement; + float[] colorsfx = colors[i >= colors.length ? 0 : i]; + Botania.proxy.wispFX(worldObj, x, y, z, colorsfx[0], colorsfx[1], colorsfx[2], 0.85F, (float)g * 0.05F, 0.25F); + Botania.proxy.wispFX(worldObj, x, y, z, colorsfx[0], colorsfx[1], colorsfx[2], (float) Math.random() * 0.1F + 0.1F, (float) (Math.random() - 0.5) * 0.05F, (float) (Math.random() - 0.5) * 0.05F, (float) (Math.random() - 0.5) * 0.05F, 0.9F); + } + } + } + + ++ticks; + } + } - @Override - public void updateEntity() { - if (worldObj.isRemote) { - if (ticks >= 40) { - float[][] colors = new float[][] { - {0F, 0.25F, 1F}, - {1F, 0F, 0.2F}, - {0F, 1F, 0.25F}, - {1F, 1F, 0.25F}, - {1F, 0.25F, 1F}, - {0.25F, 1F, 1F} - }; - - int totalSpiritCount = 6; - double tickIncrement = 360D / totalSpiritCount; - - int liftTicks = 40 * (totalSpiritCount + 1); - int existTicks = liftTicks * 2; - int lowerTicks = existTicks + liftTicks; - - if (ticks < lowerTicks) { - int speed = 5; - double wticks = ticks * speed - tickIncrement; - double r = - Math.sin((ticks >= liftTicks ? (ticks - liftTicks) * speed - tickIncrement : -tickIncrement) - * Math.PI - / 180 - * 0.75) - + 1 * 1.25 - + 0.5; - double g = Math.sin(wticks * Math.PI / 180 * 0.55); - - for (int i = 0; i < totalSpiritCount; i++) { - double x = xCoord + Math.sin(wticks * Math.PI / 180) * r + 0.5; - double y = yCoord - + (ticks > existTicks - ? 40 - (double) (ticks - existTicks) - : Math.min(80 + 40 * i, ticks) - 40 * (i + 1)) - * 0.1; - double z = zCoord + Math.cos(wticks * Math.PI / 180) * r + 0.5; - - wticks += tickIncrement; - float[] colorsfx = colors[i >= colors.length ? 0 : i]; - Botania.proxy.wispFX( - worldObj, - x, - y, - z, - colorsfx[0], - colorsfx[1], - colorsfx[2], - 0.85F, - (float) g * 0.05F, - 0.25F); - Botania.proxy.wispFX( - worldObj, - x, - y, - z, - colorsfx[0], - colorsfx[1], - colorsfx[2], - (float) Math.random() * 0.1F + 0.1F, - (float) (Math.random() - 0.5) * 0.05F, - (float) (Math.random() - 0.5) * 0.05F, - (float) (Math.random() - 0.5) * 0.05F, - 0.9F); - } - } - } - - ++ticks; - } - } } diff --git a/src/main/java/vazkii/botania/common/block/tile/TileStarfield.java b/src/main/java/vazkii/botania/common/block/tile/TileStarfield.java index 9492724d4f..06eeaa350b 100644 --- a/src/main/java/vazkii/botania/common/block/tile/TileStarfield.java +++ b/src/main/java/vazkii/botania/common/block/tile/TileStarfield.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Aug 7, 2014, 6:42:33 PM (GMT)] */ package vazkii.botania.common.block.tile; @@ -14,37 +14,38 @@ public class TileStarfield extends TileMod { - @Override - public void updateEntity() { - int meta = getBlockMetadata(); - if (!worldObj.isRemote) { - int newMeta = worldObj.isDaytime() ? 0 : 1; - if (newMeta != meta) { - worldObj.setBlockMetadataWithNotify(xCoord, yCoord, zCoord, newMeta, 1 | 2); - meta = newMeta; - } - } - - if (meta == 1) { - double radius = 512; - int iter = 2; - for (int i = 0; i < iter; i++) { - double x = xCoord + 0.5 + (Math.random() - 0.5) * radius; - double y = yCoord + 256; - double z = zCoord + 0.5 + (Math.random() - 0.5) * radius; - - float w = 0.6F; - float c = 1F - w; - - float r = w + (float) Math.random() * c; - float g = w + (float) Math.random() * c; - float b = w + (float) Math.random() * c; - - float s = 20F + (float) Math.random() * 20F; - int m = 50; - - Botania.proxy.sparkleFX(worldObj, x, y, z, r, g, b, s, m); - } - } - } + @Override + public void updateEntity() { + int meta = getBlockMetadata(); + if(!worldObj.isRemote) { + int newMeta = worldObj.isDaytime() ? 0 : 1; + if(newMeta != meta) { + worldObj.setBlockMetadataWithNotify(xCoord, yCoord, zCoord, newMeta, 1 | 2); + meta = newMeta; + } + } + + if(meta == 1) { + double radius = 512; + int iter = 2; + for(int i = 0; i < iter; i++) { + double x = xCoord + 0.5 + (Math.random() - 0.5) * radius; + double y = yCoord + 256; + double z = zCoord + 0.5 + (Math.random() - 0.5) * radius; + + float w = 0.6F; + float c = 1F - w; + + float r = w + (float) Math.random() * c; + float g = w + (float) Math.random() * c; + float b = w + (float) Math.random() * c; + + float s = 20F + (float) Math.random() * 20F; + int m = 50; + + Botania.proxy.sparkleFX(worldObj, x, y, z, r, g, b, s, m); + } + } + } + } diff --git a/src/main/java/vazkii/botania/common/block/tile/TileTerraPlate.java b/src/main/java/vazkii/botania/common/block/tile/TileTerraPlate.java index 6dcc8ac9bd..f59d61d6d4 100644 --- a/src/main/java/vazkii/botania/common/block/tile/TileTerraPlate.java +++ b/src/main/java/vazkii/botania/common/block/tile/TileTerraPlate.java @@ -2,15 +2,16 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Nov 8, 2014, 5:25:32 PM (GMT)] */ package vazkii.botania.common.block.tile; import java.util.List; + import net.minecraft.block.Block; import net.minecraft.entity.Entity; import net.minecraft.entity.item.EntityItem; @@ -32,229 +33,212 @@ public class TileTerraPlate extends TileMod implements ISparkAttachable { - public static final int MAX_MANA = TilePool.MAX_MANA / 2; - private static final int[][] LAPIS_BLOCKS = { - { - 1, 0, - }, - {-1, 0}, - {0, 1}, - {0, -1} - }; - - private static final int[][] LIVINGROCK_BLOCKS = {{0, 0}, {1, 1}, {1, -1}, {-1, 1}, {-1, -1}}; - - private static final String TAG_MANA = "mana"; - - int mana; - - public static MultiblockSet makeMultiblockSet() { - Multiblock mb = new Multiblock(); - - for (int[] l : LAPIS_BLOCKS) mb.addComponent(l[0], 0, l[1], Blocks.lapis_block, 0); - for (int[] l : LIVINGROCK_BLOCKS) mb.addComponent(l[0], 0, l[1], ModBlocks.livingrock, 0); - - mb.addComponent(0, 1, 0, ModBlocks.terraPlate, 0); - mb.setRenderOffset(0, 1, 0); - - return mb.makeSet(); - } - - @Override - public void updateEntity() { - boolean removeMana = true; - - if (hasValidPlatform()) { - List items = getItems(); - if (areItemsValid(items)) { - removeMana = false; - ISparkEntity spark = getAttachedSpark(); - if (spark != null) { - List sparkEntities = - SparkHelper.getSparksAround(worldObj, xCoord + 0.5, yCoord + 0.5, zCoord + 0.5); - for (ISparkEntity otherSpark : sparkEntities) { - if (spark == otherSpark) continue; - - if (otherSpark.getAttachedTile() != null && otherSpark.getAttachedTile() instanceof IManaPool) - otherSpark.registerTransfer(spark); - } - } - if (mana > 0) doParticles(); - - if (mana >= MAX_MANA && !worldObj.isRemote) { - EntityItem item = items.get(0); - for (EntityItem otherItem : items) - if (otherItem != item) otherItem.setDead(); - else item.setEntityItemStack(new ItemStack(ModItems.manaResource, 1, 4)); - item.worldObj.playSoundAtEntity(item, "botania:terrasteelCraft", 1F, 1F); - mana = 0; - worldObj.func_147453_f(xCoord, yCoord, zCoord, worldObj.getBlock(xCoord, yCoord, zCoord)); - VanillaPacketDispatcher.dispatchTEToNearbyPlayers(worldObj, xCoord, yCoord, zCoord); - } - } - } - - if (removeMana) recieveMana(-1000); - } - - void doParticles() { - if (worldObj.isRemote) { - int ticks = (int) (100.0 * ((double) getCurrentMana() / (double) MAX_MANA)); - - int totalSpiritCount = 3; - double tickIncrement = 360D / totalSpiritCount; - - int speed = 5; - double wticks = ticks * speed - tickIncrement; - - double r = Math.sin((ticks - 100) / 10D) * 2; - double g = Math.sin(wticks * Math.PI / 180 * 0.55); - - for (int i = 0; i < totalSpiritCount; i++) { - double x = xCoord + Math.sin(wticks * Math.PI / 180) * r + 0.5; - double y = yCoord + 0.25 + Math.abs(r) * 0.7; - double z = zCoord + Math.cos(wticks * Math.PI / 180) * r + 0.5; - - wticks += tickIncrement; - float[] colorsfx = new float[] {0F, (float) ticks / (float) 100, 1F - (float) ticks / (float) 100}; - Botania.proxy.wispFX( - worldObj, x, y, z, colorsfx[0], colorsfx[1], colorsfx[2], 0.85F, (float) g * 0.05F, 0.25F); - Botania.proxy.wispFX( - worldObj, - x, - y, - z, - colorsfx[0], - colorsfx[1], - colorsfx[2], - (float) Math.random() * 0.1F + 0.1F, - (float) (Math.random() - 0.5) * 0.05F, - (float) (Math.random() - 0.5) * 0.05F, - (float) (Math.random() - 0.5) * 0.05F, - 0.9F); - - if (ticks == 100) - for (int j = 0; j < 15; j++) - Botania.proxy.wispFX( - worldObj, - xCoord + 0.5, - yCoord + 0.5, - zCoord + 0.5, - colorsfx[0], - colorsfx[1], - colorsfx[2], - (float) Math.random() * 0.15F + 0.15F, - (float) (Math.random() - 0.5F) * 0.125F, - (float) (Math.random() - 0.5F) * 0.125F, - (float) (Math.random() - 0.5F) * 0.125F); - } - } - } - - List getItems() { - return worldObj.getEntitiesWithinAABB( - EntityItem.class, - AxisAlignedBB.getBoundingBox(xCoord, yCoord, zCoord, xCoord + 1, yCoord + 1, zCoord + 1)); - } - - boolean areItemsValid(List items) { - if (items.size() != 3) return false; - - ItemStack ingot = null; - ItemStack pearl = null; - ItemStack diamond = null; - for (EntityItem item : items) { - ItemStack stack = item.getEntityItem(); - if (stack.getItem() != ModItems.manaResource || stack.stackSize != 1) return false; - - int meta = stack.getItemDamage(); - if (meta == 0) ingot = stack; - else if (meta == 1) pearl = stack; - else if (meta == 2) diamond = stack; - else return false; - } - - return ingot != null && pearl != null && diamond != null; - } - - boolean hasValidPlatform() { - return checkAll(LAPIS_BLOCKS, Blocks.lapis_block) && checkAll(LIVINGROCK_BLOCKS, ModBlocks.livingrock); - } - - boolean checkAll(int[][] positions, Block block) { - for (int[] position : positions) { - int[] positions_ = position; - if (!checkPlatform(positions_[0], positions_[1], block)) return false; - } - - return true; - } - - boolean checkPlatform(int xOff, int zOff, Block block) { - return worldObj.getBlock(xCoord + xOff, yCoord - 1, zOff + zCoord) == block; - } - - @Override - public void writeCustomNBT(NBTTagCompound cmp) { - cmp.setInteger(TAG_MANA, mana); - } - - @Override - public void readCustomNBT(NBTTagCompound cmp) { - mana = cmp.getInteger(TAG_MANA); - } - - @Override - public int getCurrentMana() { - return mana; - } - - @Override - public boolean isFull() { - return mana >= MAX_MANA; - } - - @Override - public void recieveMana(int mana) { - this.mana = Math.max(0, Math.min(MAX_MANA, this.mana + mana)); - worldObj.func_147453_f(xCoord, yCoord, zCoord, worldObj.getBlock(xCoord, yCoord, zCoord)); - } - - @Override - public boolean canRecieveManaFromBursts() { - return areItemsValid(getItems()); - } - - @Override - public boolean canAttachSpark(ItemStack stack) { - return true; - } - - @Override - public void attachSpark(ISparkEntity entity) { - // NO-OP - } - - @Override - public ISparkEntity getAttachedSpark() { - List sparks = worldObj.getEntitiesWithinAABB( - ISparkEntity.class, - AxisAlignedBB.getBoundingBox(xCoord, yCoord + 1, zCoord, xCoord + 1, yCoord + 2, zCoord + 1)); - if (sparks.size() == 1) { - Entity e = (Entity) sparks.get(0); - return (ISparkEntity) e; - } - - return null; - } - - @Override - public boolean areIncomingTranfersDone() { - return !areItemsValid(getItems()); - } - - @Override - public int getAvailableSpaceForMana() { - return Math.max(0, MAX_MANA - getCurrentMana()); - } + public static final int MAX_MANA = TilePool.MAX_MANA / 2; + private static final int[][] LAPIS_BLOCKS = { + { 1, 0, }, { -1, 0 }, { 0, 1 }, { 0, -1 } + }; + + private static final int[][] LIVINGROCK_BLOCKS = { + { 0, 0 }, { 1, 1 }, { 1, -1 }, { -1, 1 }, { -1, -1 } + }; + + private static final String TAG_MANA = "mana"; + + int mana; + + public static MultiblockSet makeMultiblockSet() { + Multiblock mb = new Multiblock(); + + for(int[] l : LAPIS_BLOCKS) + mb.addComponent(l[0], 0, l[1], Blocks.lapis_block, 0); + for(int[] l : LIVINGROCK_BLOCKS) + mb.addComponent(l[0], 0, l[1], ModBlocks.livingrock, 0); + + mb.addComponent(0, 1, 0, ModBlocks.terraPlate, 0); + mb.setRenderOffset(0, 1, 0); + + return mb.makeSet(); + } + + @Override + public void updateEntity() { + boolean removeMana = true; + + if(hasValidPlatform()) { + List items = getItems(); + if(areItemsValid(items)) { + removeMana = false; + ISparkEntity spark = getAttachedSpark(); + if(spark != null) { + List sparkEntities = SparkHelper.getSparksAround(worldObj, xCoord + 0.5, yCoord + 0.5, zCoord + 0.5); + for(ISparkEntity otherSpark : sparkEntities) { + if(spark == otherSpark) + continue; + + if(otherSpark.getAttachedTile() != null && otherSpark.getAttachedTile() instanceof IManaPool) + otherSpark.registerTransfer(spark); + } + } + if(mana > 0) + doParticles(); + + if(mana >= MAX_MANA && !worldObj.isRemote) { + EntityItem item = items.get(0); + for(EntityItem otherItem : items) + if(otherItem != item) + otherItem.setDead(); + else item.setEntityItemStack(new ItemStack(ModItems.manaResource, 1, 4)); + item.worldObj.playSoundAtEntity(item, "botania:terrasteelCraft", 1F, 1F); + mana = 0; + worldObj.func_147453_f(xCoord, yCoord, zCoord, worldObj.getBlock(xCoord, yCoord, zCoord)); + VanillaPacketDispatcher.dispatchTEToNearbyPlayers(worldObj, xCoord, yCoord, zCoord); + } + } + } + + if(removeMana) + recieveMana(-1000); + } + + void doParticles() { + if(worldObj.isRemote) { + int ticks = (int) (100.0 * ((double) getCurrentMana() / (double) MAX_MANA)); + + int totalSpiritCount = 3; + double tickIncrement = 360D / totalSpiritCount; + + int speed = 5; + double wticks = ticks * speed - tickIncrement; + + double r = Math.sin((ticks - 100) / 10D) * 2; + double g = Math.sin(wticks * Math.PI / 180 * 0.55); + + for(int i = 0; i < totalSpiritCount; i++) { + double x = xCoord + Math.sin(wticks * Math.PI / 180) * r + 0.5; + double y = yCoord + 0.25 + Math.abs(r) * 0.7; + double z = zCoord + Math.cos(wticks * Math.PI / 180) * r + 0.5; + + wticks += tickIncrement; + float[] colorsfx = new float[] { + 0F, (float) ticks / (float) 100, 1F - (float) ticks / (float) 100 + }; + Botania.proxy.wispFX(worldObj, x, y, z, colorsfx[0], colorsfx[1], colorsfx[2], 0.85F, (float)g * 0.05F, 0.25F); + Botania.proxy.wispFX(worldObj, x, y, z, colorsfx[0], colorsfx[1], colorsfx[2], (float) Math.random() * 0.1F + 0.1F, (float) (Math.random() - 0.5) * 0.05F, (float) (Math.random() - 0.5) * 0.05F, (float) (Math.random() - 0.5) * 0.05F, 0.9F); + + if(ticks == 100) + for(int j = 0; j < 15; j++) + Botania.proxy.wispFX(worldObj, xCoord + 0.5, yCoord + 0.5, zCoord + 0.5, colorsfx[0], colorsfx[1], colorsfx[2], (float) Math.random() * 0.15F + 0.15F, (float) (Math.random() - 0.5F) * 0.125F, (float) (Math.random() - 0.5F) * 0.125F, (float) (Math.random() - 0.5F) * 0.125F); + } + } + } + + List getItems() { + return worldObj.getEntitiesWithinAABB(EntityItem.class, AxisAlignedBB.getBoundingBox(xCoord, yCoord, zCoord, xCoord + 1, yCoord + 1, zCoord + 1)); + } + + boolean areItemsValid(List items) { + if(items.size() != 3) + return false; + + ItemStack ingot = null; + ItemStack pearl = null; + ItemStack diamond = null; + for(EntityItem item : items) { + ItemStack stack = item.getEntityItem(); + if(stack.getItem() != ModItems.manaResource || stack.stackSize != 1) + return false; + + int meta = stack.getItemDamage(); + if(meta == 0) + ingot = stack; + else if(meta == 1) + pearl = stack; + else if(meta == 2) + diamond = stack; + else return false; + } + + return ingot != null && pearl != null && diamond != null; + } + + boolean hasValidPlatform() { + return checkAll(LAPIS_BLOCKS, Blocks.lapis_block) && checkAll(LIVINGROCK_BLOCKS, ModBlocks.livingrock); + } + + boolean checkAll(int[][] positions, Block block) { + for (int[] position : positions) { + int[] positions_ = position; + if(!checkPlatform(positions_[0], positions_[1], block)) + return false; + } + + return true; + } + + boolean checkPlatform(int xOff, int zOff, Block block) { + return worldObj.getBlock(xCoord + xOff, yCoord - 1, zOff + zCoord) == block; + } + + @Override + public void writeCustomNBT(NBTTagCompound cmp) { + cmp.setInteger(TAG_MANA, mana); + } + + @Override + public void readCustomNBT(NBTTagCompound cmp) { + mana = cmp.getInteger(TAG_MANA); + } + + @Override + public int getCurrentMana() { + return mana; + } + + @Override + public boolean isFull() { + return mana >= MAX_MANA; + } + + @Override + public void recieveMana(int mana) { + this.mana = Math.max(0, Math.min(MAX_MANA, this.mana + mana)); + worldObj.func_147453_f(xCoord, yCoord, zCoord, worldObj.getBlock(xCoord, yCoord, zCoord)); + } + + @Override + public boolean canRecieveManaFromBursts() { + return areItemsValid(getItems()); + } + + @Override + public boolean canAttachSpark(ItemStack stack) { + return true; + } + + @Override + public void attachSpark(ISparkEntity entity) { + // NO-OP + } + + @Override + public ISparkEntity getAttachedSpark() { + List sparks = worldObj.getEntitiesWithinAABB(ISparkEntity.class, AxisAlignedBB.getBoundingBox(xCoord, yCoord + 1, zCoord, xCoord + 1, yCoord + 2, zCoord + 1)); + if(sparks.size() == 1) { + Entity e = (Entity) sparks.get(0); + return (ISparkEntity) e; + } + + return null; + } + + @Override + public boolean areIncomingTranfersDone() { + return !areItemsValid(getItems()); + } + + @Override + public int getAvailableSpaceForMana() { + return Math.max(0, MAX_MANA - getCurrentMana()); + } + } diff --git a/src/main/java/vazkii/botania/common/block/tile/TileTeruTeruBozu.java b/src/main/java/vazkii/botania/common/block/tile/TileTeruTeruBozu.java index 6aff9faff0..21e8fd2d0c 100644 --- a/src/main/java/vazkii/botania/common/block/tile/TileTeruTeruBozu.java +++ b/src/main/java/vazkii/botania/common/block/tile/TileTeruTeruBozu.java @@ -2,26 +2,27 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Oct 1, 2015, 1:11:44 PM (GMT)] */ package vazkii.botania.common.block.tile; public class TileTeruTeruBozu extends TileMod { - public boolean wasRaining = false; + public boolean wasRaining = false; - @Override - public void updateEntity() { - boolean isRaining = worldObj.isRaining(); - if (isRaining && worldObj.rand.nextInt(9600) == 0) - worldObj.getWorldInfo().setRaining(false); + @Override + public void updateEntity() { + boolean isRaining = worldObj.isRaining(); + if(isRaining && worldObj.rand.nextInt(9600) == 0) + worldObj.getWorldInfo().setRaining(false); + + if(wasRaining != isRaining) + worldObj.func_147453_f(xCoord, yCoord, zCoord, worldObj.getBlock(xCoord, yCoord, zCoord)); + wasRaining = isRaining; + } - if (wasRaining != isRaining) - worldObj.func_147453_f(xCoord, yCoord, zCoord, worldObj.getBlock(xCoord, yCoord, zCoord)); - wasRaining = isRaining; - } } diff --git a/src/main/java/vazkii/botania/common/block/tile/TileTinyPlanet.java b/src/main/java/vazkii/botania/common/block/tile/TileTinyPlanet.java index dfc286d924..c7c14bc8b3 100644 --- a/src/main/java/vazkii/botania/common/block/tile/TileTinyPlanet.java +++ b/src/main/java/vazkii/botania/common/block/tile/TileTinyPlanet.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [May 1, 2014, 3:49:53 PM (GMT)] */ package vazkii.botania.common.block.tile; @@ -15,13 +15,14 @@ public class TileTinyPlanet extends TileMod implements IManaCollisionGhost { - @Override - public void updateEntity() { - ItemTinyPlanet.applyEffect(worldObj, xCoord + 0.5, yCoord + 0.5, zCoord + 0.5); - } + @Override + public void updateEntity() { + ItemTinyPlanet.applyEffect(worldObj, xCoord + 0.5, yCoord + 0.5, zCoord + 0.5); + } + + @Override + public boolean isGhost() { + return true; + } - @Override - public boolean isGhost() { - return true; - } } diff --git a/src/main/java/vazkii/botania/common/block/tile/TileTinyPotato.java b/src/main/java/vazkii/botania/common/block/tile/TileTinyPotato.java index 5d889c7435..bc3f60e320 100644 --- a/src/main/java/vazkii/botania/common/block/tile/TileTinyPotato.java +++ b/src/main/java/vazkii/botania/common/block/tile/TileTinyPotato.java @@ -2,51 +2,56 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jul 18, 2014, 8:05:08 PM (GMT)] */ package vazkii.botania.common.block.tile; import net.minecraft.nbt.NBTTagCompound; + public class TileTinyPotato extends TileMod { - private static final String TAG_NAME = "name"; - - public int jumpTicks = 0; - public String name = ""; - public int nextDoIt = 0; - - public void interact() { - jump(); - if (name.equalsIgnoreCase("shia labeouf") && !worldObj.isRemote && nextDoIt == 0) { - nextDoIt = 40; - worldObj.playSoundEffect(xCoord, yCoord, zCoord, "botania:doit", 1F, 1F); - } - } - - public void jump() { - if (jumpTicks == 0) jumpTicks = 20; - } - - @Override - public void updateEntity() { - if (worldObj.rand.nextInt(100) == 0) jump(); - - if (jumpTicks > 0) jumpTicks--; - if (nextDoIt > 0) nextDoIt--; - } - - @Override - public void writeCustomNBT(NBTTagCompound cmp) { - cmp.setString(TAG_NAME, name); - } - - @Override - public void readCustomNBT(NBTTagCompound cmp) { - name = cmp.getString(TAG_NAME); - } + private static final String TAG_NAME = "name"; + + public int jumpTicks = 0; + public String name = ""; + public int nextDoIt = 0; + + public void interact() { + jump(); + if(name.equalsIgnoreCase("shia labeouf") && !worldObj.isRemote && nextDoIt == 0) { + nextDoIt = 40; + worldObj.playSoundEffect(xCoord, yCoord, zCoord, "botania:doit", 1F, 1F); + } + } + + public void jump() { + if(jumpTicks == 0) + jumpTicks = 20; + } + + @Override + public void updateEntity() { + if(worldObj.rand.nextInt(100) == 0) + jump(); + + if(jumpTicks > 0) + jumpTicks--; + if(nextDoIt > 0) + nextDoIt--; + } + + @Override + public void writeCustomNBT(NBTTagCompound cmp) { + cmp.setString(TAG_NAME, name); + } + + @Override + public void readCustomNBT(NBTTagCompound cmp) { + name = cmp.getString(TAG_NAME); + } } diff --git a/src/main/java/vazkii/botania/common/block/tile/corporea/TileCorporeaBase.java b/src/main/java/vazkii/botania/common/block/tile/corporea/TileCorporeaBase.java index e55bd444d6..d3af0ac8e3 100644 --- a/src/main/java/vazkii/botania/common/block/tile/corporea/TileCorporeaBase.java +++ b/src/main/java/vazkii/botania/common/block/tile/corporea/TileCorporeaBase.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Feb 15, 2015, 12:25:19 AM (GMT)] */ package vazkii.botania.common.block.tile.corporea; @@ -16,7 +16,8 @@ public abstract class TileCorporeaBase extends TileSimpleInventory { - public ICorporeaSpark getSpark() { - return CorporeaHelper.getSparkForBlock(worldObj, xCoord, yCoord, zCoord); - } + public ICorporeaSpark getSpark() { + return CorporeaHelper.getSparkForBlock(worldObj, xCoord, yCoord, zCoord); + } + } diff --git a/src/main/java/vazkii/botania/common/block/tile/corporea/TileCorporeaCrystalCube.java b/src/main/java/vazkii/botania/common/block/tile/corporea/TileCorporeaCrystalCube.java index a67aa16fab..0c8b71c2ea 100644 --- a/src/main/java/vazkii/botania/common/block/tile/corporea/TileCorporeaCrystalCube.java +++ b/src/main/java/vazkii/botania/common/block/tile/corporea/TileCorporeaCrystalCube.java @@ -2,15 +2,16 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Apr 30, 2015, 3:57:57 PM (GMT)] */ package vazkii.botania.common.block.tile.corporea; import java.util.List; + import net.minecraft.entity.item.EntityItem; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; @@ -22,127 +23,137 @@ public class TileCorporeaCrystalCube extends TileCorporeaBase implements ICorporeaRequestor { - private static final String TAG_REQUEST_TARGET = "requestTarget"; - private static final String TAG_ITEM_COUNT = "itemCount"; - - private static final double LOG_2 = Math.log(2); - - ItemStack requestTarget; - int itemCount = 0; - int ticks = 0; - public int compValue = 0; - - @Override - public void updateEntity() { - ++ticks; - if (ticks % 20 == 0) updateCount(); - } - - public void setRequestTarget(ItemStack stack) { - if (stack != null) { - ItemStack copy = stack.copy(); - copy.stackSize = 1; - requestTarget = copy; - updateCount(); - if (!worldObj.isRemote) VanillaPacketDispatcher.dispatchTEToNearbyPlayers(this); - } - } - - public ItemStack getRequestTarget() { - return requestTarget; - } - - public int getItemCount() { - return itemCount; - } - - public void doRequest(boolean fullStack) { - if (worldObj.isRemote) return; - - ICorporeaSpark spark = getSpark(); - if (spark != null && spark.getMaster() != null && requestTarget != null) { - int count = fullStack ? requestTarget.getMaxStackSize() : 1; - doCorporeaRequest(requestTarget, count, spark); - } - } - - private void updateCount() { - if (worldObj.isRemote) return; - - int oldCount = itemCount; - itemCount = 0; - ICorporeaSpark spark = getSpark(); - if (spark != null && spark.getMaster() != null && requestTarget != null) { - List stacks = CorporeaHelper.requestItem(requestTarget, -1, spark, true, false); - for (ItemStack stack : stacks) itemCount += stack.stackSize; - } - - if (itemCount != oldCount) { - VanillaPacketDispatcher.dispatchTEToNearbyPlayers(this); - onUpdateCount(); - } - } - - private void onUpdateCount() { - compValue = getComparatorValue(); - worldObj.func_147453_f(xCoord, yCoord, zCoord, worldObj.getBlock(xCoord, yCoord, zCoord)); - } - - @Override - public void writeCustomNBT(NBTTagCompound par1nbtTagCompound) { - super.writeCustomNBT(par1nbtTagCompound); - NBTTagCompound cmp = new NBTTagCompound(); - if (requestTarget != null) requestTarget.writeToNBT(cmp); - par1nbtTagCompound.setTag(TAG_REQUEST_TARGET, cmp); - par1nbtTagCompound.setInteger(TAG_ITEM_COUNT, itemCount); - } - - @Override - public void readCustomNBT(NBTTagCompound par1nbtTagCompound) { - super.readCustomNBT(par1nbtTagCompound); - NBTTagCompound cmp = par1nbtTagCompound.getCompoundTag(TAG_REQUEST_TARGET); - requestTarget = ItemStack.loadItemStackFromNBT(cmp); - itemCount = par1nbtTagCompound.getInteger(TAG_ITEM_COUNT); - } - - @Override - public int getSizeInventory() { - return 1; - } - - public int getComparatorValue() { - if (itemCount == 0) return 0; - return Math.min(15, (int) Math.floor(Math.log(itemCount) / LOG_2) + 1); - } - - @Override - public boolean isItemValidForSlot(int i, ItemStack itemstack) { - return false; - } - - @Override - public String getInventoryName() { - return LibBlockNames.CORPOREA_CRYSTAL_CUBE; - } - - @Override - public void doCorporeaRequest(Object request, int count, ICorporeaSpark spark) { - if (!(request instanceof ItemStack)) return; - - List stacks = CorporeaHelper.requestItem(request, count, spark, true, true); - spark.onItemsRequested(stacks); - boolean did = false; - for (ItemStack reqStack : stacks) - if (requestTarget != null) { - EntityItem item = new EntityItem(worldObj, xCoord + 0.5, yCoord + 1.5, zCoord + 0.5, reqStack); - worldObj.spawnEntityInWorld(item); - itemCount -= reqStack.stackSize; - did = true; - } - - if (did) { - VanillaPacketDispatcher.dispatchTEToNearbyPlayers(this); - onUpdateCount(); - } - } + private static final String TAG_REQUEST_TARGET = "requestTarget"; + private static final String TAG_ITEM_COUNT = "itemCount"; + + private static final double LOG_2 = Math.log(2); + + ItemStack requestTarget; + int itemCount = 0; + int ticks = 0; + public int compValue = 0; + + @Override + public void updateEntity() { + ++ticks; + if(ticks % 20 == 0) + updateCount(); + } + + public void setRequestTarget(ItemStack stack) { + if(stack != null) { + ItemStack copy = stack.copy(); + copy.stackSize = 1; + requestTarget = copy; + updateCount(); + if(!worldObj.isRemote) + VanillaPacketDispatcher.dispatchTEToNearbyPlayers(this); + } + + } + + public ItemStack getRequestTarget() { + return requestTarget; + } + + public int getItemCount() { + return itemCount; + } + + public void doRequest(boolean fullStack) { + if(worldObj.isRemote) + return; + + ICorporeaSpark spark = getSpark(); + if(spark != null && spark.getMaster() != null && requestTarget != null) { + int count = fullStack ? requestTarget.getMaxStackSize() : 1; + doCorporeaRequest(requestTarget, count, spark); + } + } + + private void updateCount() { + if(worldObj.isRemote) + return; + + int oldCount = itemCount; + itemCount = 0; + ICorporeaSpark spark = getSpark(); + if(spark != null && spark.getMaster() != null && requestTarget != null) { + List stacks = CorporeaHelper.requestItem(requestTarget, -1, spark, true, false); + for(ItemStack stack : stacks) + itemCount += stack.stackSize; + } + + if(itemCount != oldCount) { + VanillaPacketDispatcher.dispatchTEToNearbyPlayers(this); + onUpdateCount(); + } + } + + private void onUpdateCount() { + compValue = getComparatorValue(); + worldObj.func_147453_f(xCoord, yCoord, zCoord, worldObj.getBlock(xCoord, yCoord, zCoord)); + } + + @Override + public void writeCustomNBT(NBTTagCompound par1nbtTagCompound) { + super.writeCustomNBT(par1nbtTagCompound); + NBTTagCompound cmp = new NBTTagCompound(); + if(requestTarget != null) + requestTarget.writeToNBT(cmp); + par1nbtTagCompound.setTag(TAG_REQUEST_TARGET, cmp); + par1nbtTagCompound.setInteger(TAG_ITEM_COUNT, itemCount); + } + + @Override + public void readCustomNBT(NBTTagCompound par1nbtTagCompound) { + super.readCustomNBT(par1nbtTagCompound); + NBTTagCompound cmp = par1nbtTagCompound.getCompoundTag(TAG_REQUEST_TARGET); + requestTarget = ItemStack.loadItemStackFromNBT(cmp); + itemCount = par1nbtTagCompound.getInteger(TAG_ITEM_COUNT); + } + + @Override + public int getSizeInventory() { + return 1; + } + + public int getComparatorValue() { + if(itemCount == 0) + return 0; + return Math.min(15, (int) Math.floor(Math.log(itemCount) / LOG_2) + 1); + } + + @Override + public boolean isItemValidForSlot(int i, ItemStack itemstack) { + return false; + } + + @Override + public String getInventoryName() { + return LibBlockNames.CORPOREA_CRYSTAL_CUBE; + } + + @Override + public void doCorporeaRequest(Object request, int count, ICorporeaSpark spark) { + if(!(request instanceof ItemStack)) + return; + + List stacks = CorporeaHelper.requestItem(request, count, spark, true, true); + spark.onItemsRequested(stacks); + boolean did = false; + for(ItemStack reqStack : stacks) + if(requestTarget != null) { + EntityItem item = new EntityItem(worldObj, xCoord + 0.5, yCoord + 1.5, zCoord + 0.5, reqStack); + worldObj.spawnEntityInWorld(item); + itemCount -= reqStack.stackSize; + did = true; + } + + if(did) { + VanillaPacketDispatcher.dispatchTEToNearbyPlayers(this); + onUpdateCount(); + } + } + } diff --git a/src/main/java/vazkii/botania/common/block/tile/corporea/TileCorporeaFunnel.java b/src/main/java/vazkii/botania/common/block/tile/corporea/TileCorporeaFunnel.java index e1cd4e898e..5692517383 100644 --- a/src/main/java/vazkii/botania/common/block/tile/corporea/TileCorporeaFunnel.java +++ b/src/main/java/vazkii/botania/common/block/tile/corporea/TileCorporeaFunnel.java @@ -2,16 +2,17 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Feb 16, 2015, 2:18:30 PM (GMT)] */ package vazkii.botania.common.block.tile.corporea; import java.util.ArrayList; import java.util.List; + import net.minecraft.entity.item.EntityItem; import net.minecraft.entity.item.EntityItemFrame; import net.minecraft.inventory.IInventory; @@ -27,86 +28,82 @@ public class TileCorporeaFunnel extends TileCorporeaBase implements ICorporeaRequestor { - public void doRequest() { - ICorporeaSpark spark = getSpark(); - if (spark != null && spark.getMaster() != null) { - List filter = getFilter(); - if (!filter.isEmpty()) { - ItemStack stack = filter.get(worldObj.rand.nextInt(filter.size())); - - if (stack != null) doCorporeaRequest(stack, stack.stackSize, spark); - } - } - } - - public List getFilter() { - List filter = new ArrayList(); - - final int[] orientationToDir = new int[] {3, 4, 2, 5}; - final int[] rotationToStackSize = new int[] {1, 16, 32, 64}; - - for (ForgeDirection dir : LibMisc.CARDINAL_DIRECTIONS) { - List frames = worldObj.getEntitiesWithinAABB( - EntityItemFrame.class, - AxisAlignedBB.getBoundingBox( - xCoord + dir.offsetX, - yCoord + dir.offsetY, - zCoord + dir.offsetZ, - xCoord + dir.offsetX + 1, - yCoord + dir.offsetY + 1, - zCoord + dir.offsetZ + 1)); - for (EntityItemFrame frame : frames) { - int orientation = frame.hangingDirection; - if (orientationToDir[orientation] == dir.ordinal()) { - ItemStack stack = frame.getDisplayedItem(); - if (stack != null) { - ItemStack copy = stack.copy(); - copy.stackSize = rotationToStackSize[frame.getRotation()]; - filter.add(copy); - } - } - } - } - - return filter; - } - - @Override - public boolean isItemValidForSlot(int i, ItemStack itemstack) { - return false; - } - - @Override - public int getSizeInventory() { - return 1; - } - - @Override - public String getInventoryName() { - return LibBlockNames.CORPOREA_FUNNEL; - } - - @Override - public void doCorporeaRequest(Object request, int count, ICorporeaSpark spark) { - if (!(request instanceof ItemStack)) return; - - IInventory inv = InventoryHelper.getInventory(worldObj, xCoord, yCoord - 1, zCoord); - if (inv == null || inv instanceof TileCorporeaFunnel) - inv = InventoryHelper.getInventory(worldObj, xCoord, yCoord - 2, zCoord); - - List stacks = CorporeaHelper.requestItem(request, count, spark, true, true); - spark.onItemsRequested(stacks); - for (ItemStack reqStack : stacks) - if (request != null) { - if (inv != null - && !(inv instanceof TileCorporeaFunnel) - && reqStack.stackSize - == InventoryHelper.testInventoryInsertion(inv, reqStack, ForgeDirection.UP)) - InventoryHelper.insertItemIntoInventory(inv, reqStack); - else { - EntityItem item = new EntityItem(worldObj, xCoord + 0.5, yCoord + 1.5, zCoord + 0.5, reqStack); - worldObj.spawnEntityInWorld(item); - } - } - } + public void doRequest() { + ICorporeaSpark spark = getSpark(); + if(spark != null && spark.getMaster() != null) { + List filter = getFilter(); + if(!filter.isEmpty()) { + ItemStack stack = filter.get(worldObj.rand.nextInt(filter.size())); + + if(stack != null) + doCorporeaRequest(stack, stack.stackSize, spark); + } + } + } + + public List getFilter() { + List filter = new ArrayList(); + + final int[] orientationToDir = new int[] { + 3, 4, 2, 5 + }; + final int[] rotationToStackSize = new int[] { + 1, 16, 32, 64 + }; + + for(ForgeDirection dir : LibMisc.CARDINAL_DIRECTIONS) { + List frames = worldObj.getEntitiesWithinAABB(EntityItemFrame.class, AxisAlignedBB.getBoundingBox(xCoord + dir.offsetX, yCoord + dir.offsetY, zCoord + dir.offsetZ, xCoord + dir.offsetX + 1, yCoord + dir.offsetY + 1, zCoord + dir.offsetZ + 1)); + for(EntityItemFrame frame : frames) { + int orientation = frame.hangingDirection; + if(orientationToDir[orientation] == dir.ordinal()) { + ItemStack stack = frame.getDisplayedItem(); + if(stack != null) { + ItemStack copy = stack.copy(); + copy.stackSize = rotationToStackSize[frame.getRotation()]; + filter.add(copy); + } + } + } + } + + return filter; + } + + @Override + public boolean isItemValidForSlot(int i, ItemStack itemstack) { + return false; + } + + @Override + public int getSizeInventory() { + return 1; + } + + @Override + public String getInventoryName() { + return LibBlockNames.CORPOREA_FUNNEL; + } + + @Override + public void doCorporeaRequest(Object request, int count, ICorporeaSpark spark) { + if(!(request instanceof ItemStack)) + return; + + IInventory inv = InventoryHelper.getInventory(worldObj, xCoord, yCoord - 1, zCoord); + if(inv == null || inv instanceof TileCorporeaFunnel) + inv = InventoryHelper.getInventory(worldObj, xCoord, yCoord - 2, zCoord); + + List stacks = CorporeaHelper.requestItem(request, count, spark, true, true); + spark.onItemsRequested(stacks); + for(ItemStack reqStack : stacks) + if(request != null) { + if(inv != null && !(inv instanceof TileCorporeaFunnel) && reqStack.stackSize == InventoryHelper.testInventoryInsertion(inv, reqStack, ForgeDirection.UP)) + InventoryHelper.insertItemIntoInventory(inv, reqStack); + else { + EntityItem item = new EntityItem(worldObj, xCoord + 0.5, yCoord + 1.5, zCoord + 0.5, reqStack); + worldObj.spawnEntityInWorld(item); + } + } + } + } diff --git a/src/main/java/vazkii/botania/common/block/tile/corporea/TileCorporeaIndex.java b/src/main/java/vazkii/botania/common/block/tile/corporea/TileCorporeaIndex.java index 25470db207..11875e1f07 100644 --- a/src/main/java/vazkii/botania/common/block/tile/corporea/TileCorporeaIndex.java +++ b/src/main/java/vazkii/botania/common/block/tile/corporea/TileCorporeaIndex.java @@ -2,18 +2,14 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Feb 15, 2015, 12:42:29 AM (GMT)] */ package vazkii.botania.common.block.tile.corporea; -import cpw.mods.fml.common.eventhandler.EventPriority; -import cpw.mods.fml.common.eventhandler.SubscribeEvent; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; import java.util.ArrayList; import java.util.Collections; import java.util.LinkedHashMap; @@ -23,6 +19,7 @@ import java.util.WeakHashMap; import java.util.regex.Matcher; import java.util.regex.Pattern; + import net.minecraft.client.Minecraft; import net.minecraft.entity.item.EntityItem; import net.minecraft.entity.player.EntityPlayer; @@ -32,7 +29,9 @@ import net.minecraft.util.ChatStyle; import net.minecraft.util.EnumChatFormatting; import net.minecraftforge.event.ServerChatEvent; + import org.apache.commons.lang3.text.WordUtils; + import vazkii.botania.api.corporea.CorporeaHelper; import vazkii.botania.api.corporea.ICorporeaAutoCompleteController; import vazkii.botania.api.corporea.ICorporeaRequestor; @@ -40,370 +39,274 @@ import vazkii.botania.common.achievement.ModAchievements; import vazkii.botania.common.core.helper.MathHelper; import vazkii.botania.common.lib.LibBlockNames; +import cpw.mods.fml.common.eventhandler.EventPriority; +import cpw.mods.fml.common.eventhandler.SubscribeEvent; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; public class TileCorporeaIndex extends TileCorporeaBase implements ICorporeaRequestor { - public static final double RADIUS = 2.5; - - private static InputHandler input; - public static final Set indexes = Collections.newSetFromMap(new WeakHashMap()); - - private static final Map patterns = new LinkedHashMap(); - - /** - * (name) = Item name, or "this" for the name of the item in your hand - * (n), (n1), (n2), etc = Numbers - * [text] = Optional - * = Either a or b - */ - static { - // (name) = 1 - addPattern("(.+)", new IRegexStacker() { - @Override - public int getCount(Matcher m) { - return 1; - } - - @Override - public String getName(Matcher m) { - return m.group(1); - } - }); - - // [a][n] (name) = 1 - addPattern("a??n?? (.+)", new IRegexStacker() { - @Override - public int getCount(Matcher m) { - return 1; - } - - @Override - public String getName(Matcher m) { - return m.group(1); - } - }); - - // (n)[x][ of] (name) = n - addPattern("(\\d+)x?(?: of)? (.+)", new IRegexStacker() { - @Override - public int getCount(Matcher m) { - return i(m, 1); - } - - @Override - public String getName(Matcher m) { - return m.group(2); - } - }); - - // [a ]stack[ of] (name) = 64 - addPattern("(?:a )?stack(?: of)? (.+)", new IRegexStacker() { - @Override - public int getCount(Matcher m) { - return 64; - } - - @Override - public String getName(Matcher m) { - return m.group(1); - } - }); - - // (n)[x] stack[s][ of] (name) = n * 64 - addPattern("(\\d+)x?? stacks?(?: of)? (.+)", new IRegexStacker() { - @Override - public int getCount(Matcher m) { - return 64 * i(m, 1); - } - - @Override - public String getName(Matcher m) { - return m.group(2); - } - }); - - // [a ]stack (n)[x][ of] (name) = 64 + n - addPattern("(?:a )?stack (?:(?:and)|(?:\\+)) (\\d+)(?: of)? (.+)", new IRegexStacker() { - @Override - public int getCount(Matcher m) { - return 64 + i(m, 1); - } - - @Override - public String getName(Matcher m) { - return m.group(2); - } - }); - - // (n1)[x] stack[s] (n2)[x][ of] (name) = n1 * 64 + n2 - addPattern("(\\d+)x?? stacks? (?:(?:and)|(?:\\+)) (\\d+)x?(?: of)? (.+)", new IRegexStacker() { - @Override - public int getCount(Matcher m) { - return 64 * i(m, 1) + i(m, 2); - } - - @Override - public String getName(Matcher m) { - return m.group(3); - } - }); - - // [a ]half [of ][a ]stack[ of] (name) = 32 - addPattern("(?:a )?half (?:of )?(?:a )?stack(?: of)? (.+)", new IRegexStacker() { - @Override - public int getCount(Matcher m) { - return 32; - } - - @Override - public String getName(Matcher m) { - return m.group(1); - } - }); - - // [a ]quarter [of ][a ]stack[ of] (name) = 16 - addPattern("(?:a )?quarter (?:of )?(?:a )?stack(?: of)? (.+)", new IRegexStacker() { - @Override - public int getCount(Matcher m) { - return 16; - } - - @Override - public String getName(Matcher m) { - return m.group(1); - } - }); - - // [a ]dozen[ of] (name) = 12 - addPattern("(?:a )?dozen(?: of)? (.+)", new IRegexStacker() { - @Override - public int getCount(Matcher m) { - return 12; - } - - @Override - public String getName(Matcher m) { - return m.group(1); - } - }); - - // (n)[x] dozen[s][ of] (name) = n * 12 - addPattern("(\\d+)x?? dozens?(?: of)? (.+)", new IRegexStacker() { - @Override - public int getCount(Matcher m) { - return 12 * i(m, 1); - } - - @Override - public String getName(Matcher m) { - return m.group(2); - } - }); - - // [ ](name) = 2147483647 - addPattern("(?:all|every) (?:(?:of|the) )?(.+)", new IRegexStacker() { - @Override - public int getCount(Matcher m) { - return Integer.MAX_VALUE; - } - - @Override - public String getName(Matcher m) { - return m.group(1); - } - }); - - // [the ]answer to life[,] the universe and everything [of ](name) = 42 - addPattern("(?:the )?answer to life,? the universe and everything (?:of )?(.+)", new IRegexStacker() { - @Override - public int getCount(Matcher m) { - return 42; - } - - @Override - public String getName(Matcher m) { - return m.group(1); - } - }); - - // (name) = 0 (display only) - addPattern("(?:count|show|display|tell) (.+)", new IRegexStacker() { - @Override - public int getCount(Matcher m) { - return 0; - } - - @Override - public String getName(Matcher m) { - return m.group(1); - } - }); - } - - public int ticks = 0; - public int ticksWithCloseby = 0; - public float closeby = 0F; - public boolean hasCloseby; - - @Override - public void updateEntity() { - super.updateEntity(); - - double x = xCoord + 0.5; - double y = yCoord + 0.5; - double z = zCoord + 0.5; - - List players = worldObj.getEntitiesWithinAABB( - EntityPlayer.class, - AxisAlignedBB.getBoundingBox(x - RADIUS, y - RADIUS, z - RADIUS, x + RADIUS, y + RADIUS, z + RADIUS)); - hasCloseby = false; - for (EntityPlayer player : players) - if (isInRangeOfIndex(player, this)) { - hasCloseby = true; - break; - } - - float step = 0.2F; - ticks++; - if (hasCloseby) { - ticksWithCloseby++; - if (closeby < 1F) closeby += step; - } else if (closeby > 0F) closeby -= step; - - if (!isInvalid() && !indexes.contains(this)) indexes.add(this); - } - - @Override - public void invalidate() { - super.invalidate(); - indexes.remove(this); - } - - @Override - public void onChunkUnload() { - super.onChunkUnload(); - indexes.remove(this); - } - - @Override - public int getSizeInventory() { - return 0; - } - - @Override - public String getInventoryName() { - return LibBlockNames.CORPOREA_INDEX; - } - - @Override - public void doCorporeaRequest(Object request, int count, ICorporeaSpark spark) { - if (!(request instanceof String)) return; - - List stacks = CorporeaHelper.requestItem((String) request, count, spark, true); - spark.onItemsRequested(stacks); - for (ItemStack stack : stacks) - if (stack != null) { - EntityItem item = new EntityItem(worldObj, xCoord + 0.5, yCoord + 1.5, zCoord + 0.5, stack); - worldObj.spawnEntityInWorld(item); - } - } - - public static boolean isInRangeOfIndex(EntityPlayer player, TileCorporeaIndex index) { - return player.worldObj.provider.dimensionId == index.worldObj.provider.dimensionId - && MathHelper.pointDistancePlane(index.xCoord + 0.5, index.zCoord + 0.5, player.posX, player.posZ) - < RADIUS - && Math.abs(index.yCoord + 0.5 - player.posY + (player.worldObj.isRemote ? 0 : 1.6)) < 5; - } - - public static void addPattern(String pattern, IRegexStacker stacker) { - patterns.put(Pattern.compile(pattern), stacker); - } - - public static int i(Matcher m, int g) { - try { - int i = Math.abs(Integer.parseInt(m.group(g))); - return i; - } catch (NumberFormatException e) { - return 0; - } - } - - public static InputHandler getInputHandler() { - if (input == null) input = new InputHandler(); - return input; - } - - public static final class InputHandler implements ICorporeaAutoCompleteController { - - public InputHandler() { - CorporeaHelper.registerAutoCompleteController(this); - } - - @SubscribeEvent(priority = EventPriority.HIGHEST) - public void onChatMessage(ServerChatEvent event) { - List nearbyIndexes = getNearbyIndexes(event.player); - if (!nearbyIndexes.isEmpty()) { - String msg = event.message.toLowerCase().trim(); - for (TileCorporeaIndex index : nearbyIndexes) { - if (index.worldObj.isRemote) continue; - - ICorporeaSpark spark = index.getSpark(); - if (spark != null) { - String name = ""; - int count = 0; - for (Pattern pattern : patterns.keySet()) { - Matcher matcher = pattern.matcher(msg); - if (matcher.matches()) { - IRegexStacker stacker = patterns.get(pattern); - count = stacker.getCount(matcher); - name = stacker.getName(matcher).toLowerCase().trim(); - pattern.toString(); - } - } - - if (name.equals("this")) { - ItemStack stack = event.player.getCurrentEquippedItem(); - if (stack != null) - name = stack.getDisplayName().toLowerCase().trim(); - } - - index.doCorporeaRequest(name, count, spark); - - event.player.addChatMessage(new ChatComponentTranslation( - "botaniamisc.requestMsg", - count, - WordUtils.capitalizeFully(name), - CorporeaHelper.lastRequestMatches, - CorporeaHelper.lastRequestExtractions) - .setChatStyle(new ChatStyle().setColor(EnumChatFormatting.LIGHT_PURPLE))); - if (CorporeaHelper.lastRequestExtractions >= 50000) - event.player.addStat(ModAchievements.superCorporeaRequest, 1); - } - } - - event.setCanceled(true); - } - } - - public static List getNearbyIndexes(EntityPlayer player) { - List indexList = new ArrayList(); - for (TileCorporeaIndex index : indexes) - if (isInRangeOfIndex(player, index) && index.worldObj.isRemote == player.worldObj.isRemote) - indexList.add(index); - return indexList; - } - - @Override - @SideOnly(Side.CLIENT) - public boolean shouldAutoComplete() { - return !getNearbyIndexes(Minecraft.getMinecraft().thePlayer).isEmpty(); - } - } - - public static interface IRegexStacker { - - public int getCount(Matcher m); - - public String getName(Matcher m); - } + public static final double RADIUS = 2.5; + + private static InputHandler input; + public static final Set indexes = Collections.newSetFromMap(new WeakHashMap()); + + private static final Map patterns = new LinkedHashMap(); + + /** + * (name) = Item name, or "this" for the name of the item in your hand + * (n), (n1), (n2), etc = Numbers + * [text] = Optional + * = Either a or b + */ + static { + // (name) = 1 + addPattern("(.+)", new IRegexStacker() { + @Override public int getCount(Matcher m) { return 1; } + @Override public String getName(Matcher m) { return m.group(1); } + }); + + // [a][n] (name) = 1 + addPattern("a??n?? (.+)", new IRegexStacker() { + @Override public int getCount(Matcher m) { return 1; } + @Override public String getName(Matcher m) { return m.group(1); } + }); + + //(n)[x][ of] (name) = n + addPattern("(\\d+)x?(?: of)? (.+)", new IRegexStacker() { + @Override public int getCount(Matcher m) { return i(m, 1); } + @Override public String getName(Matcher m) { return m.group(2); } + }); + + // [a ]stack[ of] (name) = 64 + addPattern("(?:a )?stack(?: of)? (.+)", new IRegexStacker() { + @Override public int getCount(Matcher m) { return 64; } + @Override public String getName(Matcher m) { return m.group(1); } + }); + + // (n)[x] stack[s][ of] (name) = n * 64 + addPattern("(\\d+)x?? stacks?(?: of)? (.+)", new IRegexStacker() { + @Override public int getCount(Matcher m) { return 64 * i(m, 1); } + @Override public String getName(Matcher m) { return m.group(2); } + }); + + // [a ]stack (n)[x][ of] (name) = 64 + n + addPattern("(?:a )?stack (?:(?:and)|(?:\\+)) (\\d+)(?: of)? (.+)", new IRegexStacker() { + @Override public int getCount(Matcher m) { return 64 + i(m, 1); } + @Override public String getName(Matcher m) { return m.group(2); } + }); + + // (n1)[x] stack[s] (n2)[x][ of] (name) = n1 * 64 + n2 + addPattern("(\\d+)x?? stacks? (?:(?:and)|(?:\\+)) (\\d+)x?(?: of)? (.+)", new IRegexStacker() { + @Override public int getCount(Matcher m) { return 64 * i(m, 1) + i(m, 2); } + @Override public String getName(Matcher m) { return m.group(3); } + }); + + // [a ]half [of ][a ]stack[ of] (name) = 32 + addPattern("(?:a )?half (?:of )?(?:a )?stack(?: of)? (.+)", new IRegexStacker() { + @Override public int getCount(Matcher m) { return 32; } + @Override public String getName(Matcher m) { return m.group(1); } + }); + + // [a ]quarter [of ][a ]stack[ of] (name) = 16 + addPattern("(?:a )?quarter (?:of )?(?:a )?stack(?: of)? (.+)", new IRegexStacker() { + @Override public int getCount(Matcher m) { return 16; } + @Override public String getName(Matcher m) { return m.group(1); } + }); + + // [a ]dozen[ of] (name) = 12 + addPattern("(?:a )?dozen(?: of)? (.+)", new IRegexStacker() { + @Override public int getCount(Matcher m) { return 12; } + @Override public String getName(Matcher m) { return m.group(1); } + }); + + // (n)[x] dozen[s][ of] (name) = n * 12 + addPattern("(\\d+)x?? dozens?(?: of)? (.+)", new IRegexStacker() { + @Override public int getCount(Matcher m) { return 12 * i(m, 1); } + @Override public String getName(Matcher m) { return m.group(2); } + }); + + // [ ](name) = 2147483647 + addPattern("(?:all|every) (?:(?:of|the) )?(.+)", new IRegexStacker() { + @Override public int getCount(Matcher m) { return Integer.MAX_VALUE; } + @Override public String getName(Matcher m) { return m.group(1); } + }); + + // [the ]answer to life[,] the universe and everything [of ](name) = 42 + addPattern("(?:the )?answer to life,? the universe and everything (?:of )?(.+)", new IRegexStacker() { + @Override public int getCount(Matcher m) { return 42; } + @Override public String getName(Matcher m) { return m.group(1); } + }); + + // (name) = 0 (display only) + addPattern("(?:count|show|display|tell) (.+)", new IRegexStacker() { + @Override public int getCount(Matcher m) { return 0; } + @Override public String getName(Matcher m) { return m.group(1); } + }); + } + + public int ticks = 0; + public int ticksWithCloseby = 0; + public float closeby = 0F; + public boolean hasCloseby; + + @Override + public void updateEntity() { + super.updateEntity(); + + double x = xCoord + 0.5; + double y = yCoord + 0.5; + double z = zCoord + 0.5; + + List players = worldObj.getEntitiesWithinAABB(EntityPlayer.class, AxisAlignedBB.getBoundingBox(x - RADIUS, y - RADIUS, z - RADIUS, x + RADIUS, y + RADIUS, z + RADIUS)); + hasCloseby = false; + for(EntityPlayer player : players) + if(isInRangeOfIndex(player, this)) { + hasCloseby = true; + break; + } + + float step = 0.2F; + ticks++; + if(hasCloseby) { + ticksWithCloseby++; + if(closeby < 1F) + closeby += step; + } else if(closeby > 0F) + closeby -= step; + + if(!isInvalid() && !indexes.contains(this)) + indexes.add(this); + } + + @Override + public void invalidate() { + super.invalidate(); + indexes.remove(this); + } + + @Override + public void onChunkUnload() { + super.onChunkUnload(); + indexes.remove(this); + } + + @Override + public int getSizeInventory() { + return 0; + } + + @Override + public String getInventoryName() { + return LibBlockNames.CORPOREA_INDEX; + } + + @Override + public void doCorporeaRequest(Object request, int count, ICorporeaSpark spark) { + if(!(request instanceof String)) + return; + + List stacks = CorporeaHelper.requestItem((String) request, count, spark, true); + spark.onItemsRequested(stacks); + for(ItemStack stack : stacks) + if(stack != null) { + EntityItem item = new EntityItem(worldObj, xCoord + 0.5, yCoord + 1.5, zCoord + 0.5, stack); + worldObj.spawnEntityInWorld(item); + } + } + + public static boolean isInRangeOfIndex(EntityPlayer player, TileCorporeaIndex index) { + return player.worldObj.provider.dimensionId == index.worldObj.provider.dimensionId && MathHelper.pointDistancePlane(index.xCoord + 0.5, index.zCoord + 0.5, player.posX, player.posZ) < RADIUS && Math.abs(index.yCoord + 0.5 - player.posY + (player.worldObj.isRemote ? 0 : 1.6)) < 5; + } + + public static void addPattern(String pattern, IRegexStacker stacker) { + patterns.put(Pattern.compile(pattern), stacker); + } + + public static int i(Matcher m, int g) { + try { + int i = Math.abs(Integer.parseInt(m.group(g))); + return i; + } catch(NumberFormatException e) { + return 0; + } + } + + public static InputHandler getInputHandler() { + if(input == null) + input = new InputHandler(); + return input; + } + + public static final class InputHandler implements ICorporeaAutoCompleteController { + + public InputHandler() { + CorporeaHelper.registerAutoCompleteController(this); + } + + @SubscribeEvent(priority = EventPriority.HIGHEST) + public void onChatMessage(ServerChatEvent event) { + List nearbyIndexes = getNearbyIndexes(event.player); + if(!nearbyIndexes.isEmpty()) { + String msg = event.message.toLowerCase().trim(); + for(TileCorporeaIndex index : nearbyIndexes) { + if(index.worldObj.isRemote) + continue; + + ICorporeaSpark spark = index.getSpark(); + if(spark != null) { + String name = ""; + int count = 0; + for(Pattern pattern : patterns.keySet()) { + Matcher matcher = pattern.matcher(msg); + if(matcher.matches()) { + IRegexStacker stacker = patterns.get(pattern); + count = stacker.getCount(matcher); + name = stacker.getName(matcher).toLowerCase().trim(); + pattern.toString(); + } + } + + if(name.equals("this")) { + ItemStack stack = event.player.getCurrentEquippedItem(); + if(stack != null) + name = stack.getDisplayName().toLowerCase().trim(); + } + + index.doCorporeaRequest(name, count, spark); + + event.player.addChatMessage(new ChatComponentTranslation("botaniamisc.requestMsg", count, WordUtils.capitalizeFully(name), CorporeaHelper.lastRequestMatches, CorporeaHelper.lastRequestExtractions).setChatStyle(new ChatStyle().setColor(EnumChatFormatting.LIGHT_PURPLE))); + if(CorporeaHelper.lastRequestExtractions >= 50000) + event.player.addStat(ModAchievements.superCorporeaRequest, 1); + } + } + + event.setCanceled(true); + } + } + + public static List getNearbyIndexes(EntityPlayer player) { + List indexList = new ArrayList(); + for(TileCorporeaIndex index : indexes) + if(isInRangeOfIndex(player, index) && index.worldObj.isRemote == player.worldObj.isRemote) + indexList.add(index); + return indexList; + } + + @Override + @SideOnly(Side.CLIENT) + public boolean shouldAutoComplete() { + return !getNearbyIndexes(Minecraft.getMinecraft().thePlayer).isEmpty(); + } + + } + + public static interface IRegexStacker { + + public int getCount(Matcher m); + + public String getName(Matcher m); + + } + } diff --git a/src/main/java/vazkii/botania/common/block/tile/corporea/TileCorporeaInterceptor.java b/src/main/java/vazkii/botania/common/block/tile/corporea/TileCorporeaInterceptor.java index 28d91f0aed..bfc5734c90 100644 --- a/src/main/java/vazkii/botania/common/block/tile/corporea/TileCorporeaInterceptor.java +++ b/src/main/java/vazkii/botania/common/block/tile/corporea/TileCorporeaInterceptor.java @@ -2,16 +2,17 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Apr 19, 2015, 6:21:08 PM (GMT)] */ package vazkii.botania.common.block.tile.corporea; import java.util.ArrayList; import java.util.List; + import net.minecraft.entity.item.EntityItemFrame; import net.minecraft.inventory.IInventory; import net.minecraft.item.ItemStack; @@ -26,99 +27,83 @@ public class TileCorporeaInterceptor extends TileCorporeaBase implements ICorporeaInterceptor { - @Override - public boolean isItemValidForSlot(int i, ItemStack itemstack) { - return false; - } - - @Override - public int getSizeInventory() { - return 1; - } - - @Override - public String getInventoryName() { - return LibBlockNames.CORPOREA_INTERCEPTOR; - } - - @Override - public void interceptRequest( - Object request, - int count, - ICorporeaSpark spark, - ICorporeaSpark source, - List stacks, - List inventories, - boolean doit) { - // NO-OP - } - - @Override - public void interceptRequestLast( - Object request, - int count, - ICorporeaSpark spark, - ICorporeaSpark source, - List stacks, - List inventories, - boolean doit) { - List filter = getFilter(); - for (ItemStack stack : filter) - if (requestMatches(request, stack)) { - int missing = count; - for (ItemStack stack_ : stacks) missing -= stack_.stackSize; - - if (missing > 0 && getBlockMetadata() == 0) { - worldObj.setBlockMetadataWithNotify(xCoord, yCoord, zCoord, 1, 1 | 2); - worldObj.scheduleBlockUpdate(xCoord, yCoord, zCoord, getBlockType(), 2); - - TileEntity requestor = (TileEntity) source.getInventory(); - for (ForgeDirection dir : LibMisc.CARDINAL_DIRECTIONS) { - TileEntity tile = worldObj.getTileEntity(xCoord + dir.offsetX, yCoord, zCoord + dir.offsetZ); - if (tile != null && tile instanceof TileCorporeaRetainer) - ((TileCorporeaRetainer) tile) - .setPendingRequest( - requestor.xCoord, requestor.yCoord, requestor.zCoord, request, count); - } - - return; - } - } - } - - public boolean requestMatches(Object request, ItemStack filter) { - if (filter == null) return false; - - if (request instanceof ItemStack) { - ItemStack stack = (ItemStack) request; - return stack != null && stack.isItemEqual(filter) && ItemStack.areItemStackTagsEqual(filter, stack); - } - - String name = (String) request; - return CorporeaHelper.stacksMatch(filter, name); - } - - public List getFilter() { - List filter = new ArrayList(); - - final int[] orientationToDir = new int[] {3, 4, 2, 5}; - - for (ForgeDirection dir : LibMisc.CARDINAL_DIRECTIONS) { - List frames = worldObj.getEntitiesWithinAABB( - EntityItemFrame.class, - AxisAlignedBB.getBoundingBox( - xCoord + dir.offsetX, - yCoord + dir.offsetY, - zCoord + dir.offsetZ, - xCoord + dir.offsetX + 1, - yCoord + dir.offsetY + 1, - zCoord + dir.offsetZ + 1)); - for (EntityItemFrame frame : frames) { - int orientation = frame.hangingDirection; - if (orientationToDir[orientation] == dir.ordinal()) filter.add(frame.getDisplayedItem()); - } - } - - return filter; - } + @Override + public boolean isItemValidForSlot(int i, ItemStack itemstack) { + return false; + } + + @Override + public int getSizeInventory() { + return 1; + } + + @Override + public String getInventoryName() { + return LibBlockNames.CORPOREA_INTERCEPTOR; + } + + @Override + public void interceptRequest(Object request, int count, ICorporeaSpark spark, ICorporeaSpark source, List stacks, List inventories, boolean doit) { + // NO-OP + } + + @Override + public void interceptRequestLast(Object request, int count, ICorporeaSpark spark, ICorporeaSpark source, List stacks, List inventories, boolean doit) { + List filter = getFilter(); + for(ItemStack stack : filter) + if(requestMatches(request, stack)) { + int missing = count; + for(ItemStack stack_ : stacks) + missing -= stack_.stackSize; + + if(missing > 0 && getBlockMetadata() == 0) { + worldObj.setBlockMetadataWithNotify(xCoord, yCoord, zCoord, 1, 1 | 2); + worldObj.scheduleBlockUpdate(xCoord, yCoord, zCoord, getBlockType(), 2); + + TileEntity requestor = (TileEntity) source.getInventory(); + for(ForgeDirection dir : LibMisc.CARDINAL_DIRECTIONS) { + TileEntity tile = worldObj.getTileEntity(xCoord + dir.offsetX, yCoord, zCoord + dir.offsetZ); + if(tile != null && tile instanceof TileCorporeaRetainer) + ((TileCorporeaRetainer) tile).setPendingRequest(requestor.xCoord, requestor.yCoord, requestor.zCoord, request, count); + } + + return; + } + } + + } + + public boolean requestMatches(Object request, ItemStack filter) { + if(filter == null) + return false; + + if(request instanceof ItemStack) { + ItemStack stack = (ItemStack) request; + return stack != null && stack.isItemEqual(filter) && ItemStack.areItemStackTagsEqual(filter, stack); + } + + String name = (String) request; + return CorporeaHelper.stacksMatch(filter, name); + } + + public List getFilter() { + List filter = new ArrayList(); + + final int[] orientationToDir = new int[] { + 3, 4, 2, 5 + }; + + for(ForgeDirection dir : LibMisc.CARDINAL_DIRECTIONS) { + List frames = worldObj.getEntitiesWithinAABB(EntityItemFrame.class, AxisAlignedBB.getBoundingBox(xCoord + dir.offsetX, yCoord + dir.offsetY, zCoord + dir.offsetZ, xCoord + dir.offsetX + 1, yCoord + dir.offsetY + 1, zCoord + dir.offsetZ + 1)); + for(EntityItemFrame frame : frames) { + int orientation = frame.hangingDirection; + if(orientationToDir[orientation] == dir.ordinal()) + filter.add(frame.getDisplayedItem()); + } + } + + return filter; + } + + } diff --git a/src/main/java/vazkii/botania/common/block/tile/corporea/TileCorporeaRetainer.java b/src/main/java/vazkii/botania/common/block/tile/corporea/TileCorporeaRetainer.java index ccb6a597ae..841981fad3 100644 --- a/src/main/java/vazkii/botania/common/block/tile/corporea/TileCorporeaRetainer.java +++ b/src/main/java/vazkii/botania/common/block/tile/corporea/TileCorporeaRetainer.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Sep 28, 2015, 11:55:56 AM (GMT)] */ package vazkii.botania.common.block.tile.corporea; @@ -20,104 +20,106 @@ public class TileCorporeaRetainer extends TileMod { - private static final String TAG_PENDING_REQUEST = "pendingRequest"; - private static final String TAG_REQUEST_X = "requestX"; - private static final String TAG_REQUEST_Y = "requestY"; - private static final String TAG_REQUEST_Z = "requestZ"; - private static final String TAG_REQUEST_TYPE = "requestType"; - private static final String TAG_REQUEST_CONTENTS = "requestContents"; - private static final String TAG_REQUEST_STACK = "requestStack"; - private static final String TAG_REQUEST_COUNT = "requestCount"; - - private static final int REQUEST_NULL = 0; - private static final int REQUEST_ITEMSTACK = 1; - private static final int REQUEST_STRING = 2; - - boolean pendingRequest = false; - int requestX, requestY, requestZ; - Object request; - int requestCount; - - public void setPendingRequest(int x, int y, int z, Object request, int requestCount) { - if (pendingRequest) return; - - requestX = x; - requestY = y; - requestZ = z; - this.request = request; - this.requestCount = requestCount; - pendingRequest = true; - worldObj.func_147453_f(xCoord, yCoord, zCoord, worldObj.getBlock(xCoord, yCoord, zCoord)); - } - - public boolean hasPendingRequest() { - return pendingRequest; - } - - public void fulfilRequest() { - if (!hasPendingRequest()) return; - - ICorporeaSpark spark = CorporeaHelper.getSparkForBlock(worldObj, requestX, requestY, requestZ); - if (spark != null) { - IInventory inv = spark.getInventory(); - if (inv != null && inv instanceof ICorporeaRequestor) { - ICorporeaRequestor requestor = (ICorporeaRequestor) inv; - requestor.doCorporeaRequest(request, requestCount, spark); - pendingRequest = false; - worldObj.func_147453_f(xCoord, yCoord, zCoord, worldObj.getBlock(xCoord, yCoord, zCoord)); - } - } - } - - @Override - public void writeCustomNBT(NBTTagCompound cmp) { - super.writeCustomNBT(cmp); - - cmp.setBoolean(TAG_PENDING_REQUEST, pendingRequest); - cmp.setInteger(TAG_REQUEST_X, requestX); - cmp.setInteger(TAG_REQUEST_Y, requestY); - cmp.setInteger(TAG_REQUEST_Z, requestZ); - - int reqType = REQUEST_NULL; - if (request != null) reqType = request instanceof String ? REQUEST_STRING : REQUEST_ITEMSTACK; - cmp.setInteger(TAG_REQUEST_TYPE, reqType); - - switch (reqType) { - case REQUEST_STRING: - cmp.setString(TAG_REQUEST_CONTENTS, (String) request); - break; - case REQUEST_ITEMSTACK: - NBTTagCompound cmp1 = new NBTTagCompound(); - ((ItemStack) request).writeToNBT(cmp1); - cmp.setTag(TAG_REQUEST_STACK, cmp1); - break; - default: - break; - } - cmp.setInteger(TAG_REQUEST_COUNT, requestCount); - } - - @Override - public void readCustomNBT(NBTTagCompound cmp) { - super.readCustomNBT(cmp); - - pendingRequest = cmp.getBoolean(TAG_PENDING_REQUEST); - requestX = cmp.getInteger(TAG_REQUEST_X); - requestY = cmp.getInteger(TAG_REQUEST_Y); - requestZ = cmp.getInteger(TAG_REQUEST_Z); - - int reqType = cmp.getInteger(TAG_REQUEST_TYPE); - switch (reqType) { - case REQUEST_STRING: - request = cmp.getString(TAG_REQUEST_CONTENTS); - break; - case REQUEST_ITEMSTACK: - NBTTagCompound cmp1 = cmp.getCompoundTag(TAG_REQUEST_STACK); - request = ItemStack.loadItemStackFromNBT(cmp1); - break; - default: - break; - } - requestCount = cmp.getInteger(TAG_REQUEST_COUNT); - } + private static final String TAG_PENDING_REQUEST = "pendingRequest"; + private static final String TAG_REQUEST_X = "requestX"; + private static final String TAG_REQUEST_Y = "requestY"; + private static final String TAG_REQUEST_Z = "requestZ"; + private static final String TAG_REQUEST_TYPE = "requestType"; + private static final String TAG_REQUEST_CONTENTS = "requestContents"; + private static final String TAG_REQUEST_STACK = "requestStack"; + private static final String TAG_REQUEST_COUNT = "requestCount"; + + private static final int REQUEST_NULL = 0; + private static final int REQUEST_ITEMSTACK = 1; + private static final int REQUEST_STRING = 2; + + boolean pendingRequest = false; + int requestX, requestY, requestZ; + Object request; + int requestCount; + + public void setPendingRequest(int x, int y, int z, Object request, int requestCount) { + if(pendingRequest) + return; + + requestX = x; + requestY = y; + requestZ = z; + this.request = request; + this.requestCount = requestCount; + pendingRequest = true; + worldObj.func_147453_f(xCoord, yCoord, zCoord, worldObj.getBlock(xCoord, yCoord, zCoord)); + } + + public boolean hasPendingRequest() { + return pendingRequest; + } + + public void fulfilRequest() { + if(!hasPendingRequest()) + return; + + ICorporeaSpark spark = CorporeaHelper.getSparkForBlock(worldObj, requestX, requestY, requestZ); + if(spark != null) { + IInventory inv = spark.getInventory(); + if(inv != null && inv instanceof ICorporeaRequestor) { + ICorporeaRequestor requestor = (ICorporeaRequestor) inv; + requestor.doCorporeaRequest(request, requestCount, spark); + pendingRequest = false; + worldObj.func_147453_f(xCoord, yCoord, zCoord, worldObj.getBlock(xCoord, yCoord, zCoord)); + } + } + } + + @Override + public void writeCustomNBT(NBTTagCompound cmp) { + super.writeCustomNBT(cmp); + + cmp.setBoolean(TAG_PENDING_REQUEST, pendingRequest); + cmp.setInteger(TAG_REQUEST_X, requestX); + cmp.setInteger(TAG_REQUEST_Y, requestY); + cmp.setInteger(TAG_REQUEST_Z, requestZ); + + int reqType = REQUEST_NULL; + if(request != null) + reqType = request instanceof String ? REQUEST_STRING : REQUEST_ITEMSTACK; + cmp.setInteger(TAG_REQUEST_TYPE, reqType); + + switch (reqType) { + case REQUEST_STRING: + cmp.setString(TAG_REQUEST_CONTENTS, (String) request); + break; + case REQUEST_ITEMSTACK: + NBTTagCompound cmp1 = new NBTTagCompound(); + ((ItemStack) request).writeToNBT(cmp1); + cmp.setTag(TAG_REQUEST_STACK, cmp1); + break; + default: break; + } + cmp.setInteger(TAG_REQUEST_COUNT, requestCount); + } + + @Override + public void readCustomNBT(NBTTagCompound cmp) { + super.readCustomNBT(cmp); + + pendingRequest = cmp.getBoolean(TAG_PENDING_REQUEST); + requestX = cmp.getInteger(TAG_REQUEST_X); + requestY = cmp.getInteger(TAG_REQUEST_Y); + requestZ = cmp.getInteger(TAG_REQUEST_Z); + + int reqType = cmp.getInteger(TAG_REQUEST_TYPE); + switch (reqType) { + case REQUEST_STRING: + request = cmp.getString(TAG_REQUEST_CONTENTS); + break; + case REQUEST_ITEMSTACK: + NBTTagCompound cmp1 = cmp.getCompoundTag(TAG_REQUEST_STACK); + request = ItemStack.loadItemStackFromNBT(cmp1); + break; + default: break; + } + requestCount = cmp.getInteger(TAG_REQUEST_COUNT); + } + } diff --git a/src/main/java/vazkii/botania/common/block/tile/mana/TileBellows.java b/src/main/java/vazkii/botania/common/block/tile/mana/TileBellows.java index ecb0eaf24d..11dfaa35fc 100644 --- a/src/main/java/vazkii/botania/common/block/tile/mana/TileBellows.java +++ b/src/main/java/vazkii/botania/common/block/tile/mana/TileBellows.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Aug 28, 2015, 5:27:43 PM (GMT)] */ package vazkii.botania.common.block.tile.mana; @@ -21,113 +21,119 @@ public class TileBellows extends TileMod { - private static final String TAG_ACTIVE = "active"; - - public float movePos; - public boolean active = false; - public float moving = 0F; - - public void interact() { - if (moving == 0F) setActive(true); - } - - @Override - public void updateEntity() { - boolean disable = true; - TileEntity tile = getLinkedTile(); - if (!active && tile instanceof TilePool) { - TilePool pool = (TilePool) tile; - boolean transfer = pool.isDoingTransfer; - if (transfer) { - if (!active && pool.ticksDoingTransfer >= getBlockMetadata() * 2 - 2) setActive(true); - disable = false; - } - } - - float max = 0.9F; - float min = 0F; - - float incr = max / 20F; - - if (movePos < max && active && moving >= 0F) { - if (moving == 0F) - worldObj.playSoundEffect(xCoord + 0.5, yCoord + 0.5, zCoord + 0.5, "botania:bellows", 0.1F, 3F); - - if (tile instanceof TileEntityFurnace) { - TileEntityFurnace furnace = (TileEntityFurnace) tile; - if (SubTileExoflame.canFurnaceSmelt(furnace)) { - furnace.furnaceCookTime = Math.min(199, furnace.furnaceCookTime + 20); - furnace.furnaceBurnTime = Math.max(0, furnace.furnaceBurnTime - 10); - } - - if (furnace.getBlockType() == Blocks.lit_furnace) { - // Copypasta from BlockFurnace - int x = furnace.xCoord; - int y = furnace.yCoord; - int z = furnace.zCoord; - int l = worldObj.getBlockMetadata(x, y, z); - float f = x + 0.5F; - float f1 = y + 0.0F + worldObj.rand.nextFloat() * 6.0F / 16.0F; - float f2 = z + 0.5F; - float f3 = 0.52F; - float f4 = worldObj.rand.nextFloat() * 0.6F - 0.3F; - - if (l == 4) { - worldObj.spawnParticle("smoke", f - f3, f1, f2 + f4, 0.0D, 0.0D, 0.0D); - worldObj.spawnParticle("flame", f - f3, f1, f2 + f4, 0.0D, 0.0D, 0.0D); - } else if (l == 5) { - worldObj.spawnParticle("smoke", f + f3, f1, f2 + f4, 0.0D, 0.0D, 0.0D); - worldObj.spawnParticle("flame", f + f3, f1, f2 + f4, 0.0D, 0.0D, 0.0D); - } else if (l == 2) { - worldObj.spawnParticle("smoke", f + f4, f1, f2 - f3, 0.0D, 0.0D, 0.0D); - worldObj.spawnParticle("flame", f + f4, f1, f2 - f3, 0.0D, 0.0D, 0.0D); - } else if (l == 3) { - worldObj.spawnParticle("smoke", f + f4, f1, f2 + f3, 0.0D, 0.0D, 0.0D); - worldObj.spawnParticle("flame", f + f4, f1, f2 + f3, 0.0D, 0.0D, 0.0D); - } - } - } - - movePos += incr * 3; - moving = incr * 3; - if (movePos >= max) { - movePos = Math.min(max, movePos); - moving = 0F; - if (disable) setActive(false); - } - } else if (movePos > min) { - movePos -= incr; - moving = -incr; - if (movePos <= min) { - movePos = Math.max(min, movePos); - moving = 0F; - } - } - - super.updateEntity(); - } - - public TileEntity getLinkedTile() { - int meta = getBlockMetadata(); - ForgeDirection dir = ForgeDirection.getOrientation(meta); - return worldObj.getTileEntity(xCoord + dir.offsetX, yCoord, zCoord + dir.offsetZ); - } - - @Override - public void writeCustomNBT(NBTTagCompound cmp) { - cmp.setBoolean(TAG_ACTIVE, active); - } - - @Override - public void readCustomNBT(NBTTagCompound cmp) { - active = cmp.getBoolean(TAG_ACTIVE); - } - - public void setActive(boolean active) { - if (!worldObj.isRemote) { - boolean diff = this.active != active; - this.active = active; - if (diff) VanillaPacketDispatcher.dispatchTEToNearbyPlayers(worldObj, xCoord, yCoord, zCoord); - } - } + private static final String TAG_ACTIVE = "active"; + + public float movePos; + public boolean active = false; + public float moving = 0F; + + public void interact() { + if(moving == 0F) + setActive(true); + } + + @Override + public void updateEntity() { + boolean disable = true; + TileEntity tile = getLinkedTile(); + if(!active && tile instanceof TilePool) { + TilePool pool = (TilePool) tile; + boolean transfer = pool.isDoingTransfer; + if(transfer) { + if(!active && pool.ticksDoingTransfer >= getBlockMetadata() * 2 - 2) + setActive(true); + disable = false; + } + } + + float max = 0.9F; + float min = 0F; + + float incr = max / 20F; + + if(movePos < max && active && moving >= 0F) { + if(moving == 0F) + worldObj.playSoundEffect(xCoord + 0.5, yCoord + 0.5, zCoord + 0.5, "botania:bellows", 0.1F, 3F); + + if(tile instanceof TileEntityFurnace) { + TileEntityFurnace furnace = (TileEntityFurnace) tile; + if(SubTileExoflame.canFurnaceSmelt(furnace)) { + furnace.furnaceCookTime = Math.min(199, furnace.furnaceCookTime + 20); + furnace.furnaceBurnTime = Math.max(0, furnace.furnaceBurnTime - 10); + } + + if(furnace.getBlockType() == Blocks.lit_furnace) { + // Copypasta from BlockFurnace + int x = furnace.xCoord; + int y = furnace.yCoord; + int z = furnace.zCoord; + int l = worldObj.getBlockMetadata(x, y, z); + float f = x + 0.5F; + float f1 = y + 0.0F + worldObj.rand.nextFloat() * 6.0F / 16.0F; + float f2 = z + 0.5F; + float f3 = 0.52F; + float f4 = worldObj.rand.nextFloat() * 0.6F - 0.3F; + + if(l == 4) { + worldObj.spawnParticle("smoke", f - f3, f1, f2 + f4, 0.0D, 0.0D, 0.0D); + worldObj.spawnParticle("flame", f - f3, f1, f2 + f4, 0.0D, 0.0D, 0.0D); + } else if(l == 5) { + worldObj.spawnParticle("smoke", f + f3, f1, f2 + f4, 0.0D, 0.0D, 0.0D); + worldObj.spawnParticle("flame", f + f3, f1, f2 + f4, 0.0D, 0.0D, 0.0D); + } else if(l == 2) { + worldObj.spawnParticle("smoke", f + f4, f1, f2 - f3, 0.0D, 0.0D, 0.0D); + worldObj.spawnParticle("flame", f + f4, f1, f2 - f3, 0.0D, 0.0D, 0.0D); + } else if(l == 3) { + worldObj.spawnParticle("smoke", f + f4, f1, f2 + f3, 0.0D, 0.0D, 0.0D); + worldObj.spawnParticle("flame", f + f4, f1, f2 + f3, 0.0D, 0.0D, 0.0D); + } + } + } + + movePos += incr * 3; + moving = incr * 3; + if(movePos >= max) { + movePos = Math.min(max, movePos); + moving = 0F; + if(disable) + setActive(false); + } + } else if(movePos > min) { + movePos -= incr; + moving = -incr; + if(movePos <= min) { + movePos = Math.max(min, movePos); + moving = 0F; + } + } + + super.updateEntity(); + } + + public TileEntity getLinkedTile() { + int meta = getBlockMetadata(); + ForgeDirection dir = ForgeDirection.getOrientation(meta); + return worldObj.getTileEntity(xCoord + dir.offsetX, yCoord, zCoord + dir.offsetZ); + } + + @Override + public void writeCustomNBT(NBTTagCompound cmp) { + cmp.setBoolean(TAG_ACTIVE, active); + } + + @Override + public void readCustomNBT(NBTTagCompound cmp) { + active = cmp.getBoolean(TAG_ACTIVE); + } + + public void setActive(boolean active) { + if(!worldObj.isRemote) { + boolean diff = this.active != active; + this.active = active; + if(diff) + VanillaPacketDispatcher.dispatchTEToNearbyPlayers(worldObj, xCoord, yCoord, zCoord); + } + } + + } diff --git a/src/main/java/vazkii/botania/common/block/tile/mana/TileDistributor.java b/src/main/java/vazkii/botania/common/block/tile/mana/TileDistributor.java index f174a9afee..e0aa3d60fd 100644 --- a/src/main/java/vazkii/botania/common/block/tile/mana/TileDistributor.java +++ b/src/main/java/vazkii/botania/common/block/tile/mana/TileDistributor.java @@ -2,16 +2,17 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Mar 3, 2014, 1:51:34 AM (GMT)] */ package vazkii.botania.common.block.tile.mana; import java.util.ArrayList; import java.util.List; + import net.minecraft.tileentity.TileEntity; import net.minecraftforge.common.util.ForgeDirection; import vazkii.botania.api.internal.VanillaPacketDispatcher; @@ -22,45 +23,46 @@ public class TileDistributor extends TileMod implements IManaReceiver { - List validPools = new ArrayList(); + List validPools = new ArrayList(); - @Override - public void updateEntity() { - validPools.clear(); - for (ForgeDirection dir : LibMisc.CARDINAL_DIRECTIONS) { - TileEntity tileAt = worldObj.getTileEntity(xCoord + dir.offsetX, yCoord, zCoord + dir.offsetZ); - if (tileAt != null && tileAt instanceof IManaPool) { - IManaReceiver receiver = (IManaReceiver) tileAt; - if (!receiver.isFull()) validPools.add(receiver); - } - } - } + @Override + public void updateEntity() { + validPools.clear(); + for(ForgeDirection dir : LibMisc.CARDINAL_DIRECTIONS) { + TileEntity tileAt = worldObj.getTileEntity(xCoord + dir.offsetX, yCoord, zCoord + dir.offsetZ); + if(tileAt != null && tileAt instanceof IManaPool) { + IManaReceiver receiver = (IManaReceiver) tileAt; + if(!receiver.isFull()) + validPools.add(receiver); + } + } + } - @Override - public int getCurrentMana() { - return 0; - } + @Override + public int getCurrentMana() { + return 0; + } - @Override - public boolean isFull() { - return validPools.isEmpty(); - } + @Override + public boolean isFull() { + return validPools.isEmpty(); + } - @Override - public void recieveMana(int mana) { - int tiles = validPools.size(); - if (tiles != 0) { - int manaForEach = mana / tiles; - for (IManaReceiver pool : validPools) { - pool.recieveMana(manaForEach); - TileEntity tile = (TileEntity) pool; - VanillaPacketDispatcher.dispatchTEToNearbyPlayers(worldObj, tile.xCoord, tile.yCoord, tile.zCoord); - } - } - } + @Override + public void recieveMana(int mana) { + int tiles = validPools.size(); + if(tiles != 0) { + int manaForEach = mana / tiles; + for(IManaReceiver pool : validPools) { + pool.recieveMana(manaForEach); + TileEntity tile = (TileEntity) pool; + VanillaPacketDispatcher.dispatchTEToNearbyPlayers(worldObj, tile.xCoord, tile.yCoord, tile.zCoord); + } + } + } - @Override - public boolean canRecieveManaFromBursts() { - return !isFull(); - } + @Override + public boolean canRecieveManaFromBursts() { + return !isFull(); + } } diff --git a/src/main/java/vazkii/botania/common/block/tile/mana/TileManaDetector.java b/src/main/java/vazkii/botania/common/block/tile/mana/TileManaDetector.java index c2066e5cfd..90bd75db12 100644 --- a/src/main/java/vazkii/botania/common/block/tile/mana/TileManaDetector.java +++ b/src/main/java/vazkii/botania/common/block/tile/mana/TileManaDetector.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Mar 10, 2014, 7:55:12 PM (GMT)] */ package vazkii.botania.common.block.tile.mana; @@ -18,37 +18,23 @@ public class TileManaDetector extends TileMod implements IManaCollisionGhost { - @Override - public void updateEntity() { - if (!worldObj.isRemote) { - int meta = getBlockMetadata(); - int expectedMeta = worldObj.getEntitiesWithinAABB( - IManaBurst.class, - AxisAlignedBB.getBoundingBox( - xCoord, yCoord, zCoord, xCoord + 1, yCoord + 1, zCoord + 1)) - .size() - != 0 - ? 1 - : 0; - if (meta != expectedMeta) worldObj.setBlockMetadataWithNotify(xCoord, yCoord, zCoord, expectedMeta, 1 | 2); + @Override + public void updateEntity() { + if(!worldObj.isRemote) { + int meta = getBlockMetadata(); + int expectedMeta = worldObj.getEntitiesWithinAABB(IManaBurst.class, AxisAlignedBB.getBoundingBox(xCoord, yCoord, zCoord, xCoord + 1, yCoord + 1, zCoord + 1)).size() != 0 ? 1 : 0; + if(meta != expectedMeta) + worldObj.setBlockMetadataWithNotify(xCoord, yCoord, zCoord, expectedMeta, 1 | 2); - if (expectedMeta == 1) - for (int i = 0; i < 4; i++) - Botania.proxy.sparkleFX( - getWorldObj(), - xCoord + Math.random(), - yCoord + Math.random(), - zCoord + Math.random(), - 1F, - 0.2F, - 0.2F, - 0.7F + 0.5F * (float) Math.random(), - 5); - } - } + if(expectedMeta == 1) + for(int i = 0; i < 4; i++) + Botania.proxy.sparkleFX(getWorldObj(), xCoord + Math.random(), yCoord + Math.random(), zCoord + Math.random(), 1F, 0.2F, 0.2F, 0.7F + 0.5F * (float) Math.random(), 5); + } + } + + @Override + public boolean isGhost() { + return true; + } - @Override - public boolean isGhost() { - return true; - } } diff --git a/src/main/java/vazkii/botania/common/block/tile/mana/TileManaVoid.java b/src/main/java/vazkii/botania/common/block/tile/mana/TileManaVoid.java index a4f524cbcf..d4b240ed08 100644 --- a/src/main/java/vazkii/botania/common/block/tile/mana/TileManaVoid.java +++ b/src/main/java/vazkii/botania/common/block/tile/mana/TileManaVoid.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Mar 5, 2014, 12:59:27 AM (GMT)] */ package vazkii.botania.common.block.tile.mana; @@ -16,39 +16,31 @@ public class TileManaVoid extends TileMod implements IClientManaHandler { - @Override - public boolean canUpdate() { - return false; - } - - @Override - public int getCurrentMana() { - return 0; - } - - @Override - public boolean isFull() { - return false; - } - - @Override - public void recieveMana(int mana) { - if (mana > 0) - for (int i = 0; i < 10; i++) - Botania.proxy.sparkleFX( - getWorldObj(), - xCoord + Math.random(), - yCoord + Math.random(), - zCoord + Math.random(), - 0.2F, - 0.2F, - 0.2F, - 0.7F + 0.5F * (float) Math.random(), - 5); - } - - @Override - public boolean canRecieveManaFromBursts() { - return true; - } + @Override + public boolean canUpdate() { + return false; + } + + @Override + public int getCurrentMana() { + return 0; + } + + @Override + public boolean isFull() { + return false; + } + + @Override + public void recieveMana(int mana) { + if(mana > 0) + for(int i = 0; i < 10; i++) + Botania.proxy.sparkleFX(getWorldObj(), xCoord + Math.random(), yCoord + Math.random(), zCoord + Math.random(), 0.2F, 0.2F, 0.2F, 0.7F + 0.5F * (float) Math.random(), 5); + } + + @Override + public boolean canRecieveManaFromBursts() { + return true; + } + } diff --git a/src/main/java/vazkii/botania/common/block/tile/mana/TilePool.java b/src/main/java/vazkii/botania/common/block/tile/mana/TilePool.java index 777f53f5bc..f6252385b7 100644 --- a/src/main/java/vazkii/botania/common/block/tile/mana/TilePool.java +++ b/src/main/java/vazkii/botania/common/block/tile/mana/TilePool.java @@ -2,16 +2,17 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jan 26, 2014, 12:23:55 AM (GMT)] */ package vazkii.botania.common.block.tile.mana; import java.awt.Color; import java.util.List; + import net.minecraft.block.Block; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.ScaledResolution; @@ -27,7 +28,9 @@ import net.minecraft.util.AxisAlignedBB; import net.minecraft.util.StatCollector; import net.minecraftforge.common.util.ForgeDirection; + import org.lwjgl.opengl.GL11; + import vazkii.botania.api.BotaniaAPI; import vazkii.botania.api.internal.VanillaPacketDispatcher; import vazkii.botania.api.item.IDyablePool; @@ -54,404 +57,381 @@ import vazkii.botania.common.item.ModItems; import vazkii.botania.common.lib.LibMisc; -public class TilePool extends TileMod - implements IManaPool, IDyablePool, IKeyLocked, ISparkAttachable, IThrottledPacket { - - public static final int MAX_MANA = 1000000; - public static final int MAX_MANA_DILLUTED = 10000; - - private static final String TAG_MANA = "mana"; - private static final String TAG_KNOWN_MANA = "knownMana"; - private static final String TAG_OUTPUTTING = "outputting"; - private static final String TAG_COLOR = "color"; - private static final String TAG_MANA_CAP = "manaCap"; - private static final String TAG_CAN_ACCEPT = "canAccept"; - private static final String TAG_CAN_SPARE = "canSpare"; - private static final String TAG_FRAGILE = "fragile"; - private static final String TAG_INPUT_KEY = "inputKey"; - private static final String TAG_OUTPUT_KEY = "outputKey"; - - boolean outputting = false; - public boolean alchemy = false; - public boolean conjuration = false; - boolean catalystsRegistered = false; - - public int color = 0; - int mana; - int knownMana = -1; - - public int manaCap = -1; - int soundTicks = 0; - boolean canAccept = true; - boolean canSpare = true; - public boolean fragile = false; - public boolean isDoingTransfer = false; - public int ticksDoingTransfer = 0; - - String inputKey = ""; - String outputKey = ""; - - int ticks = 0; - boolean sendPacket = false; - - @Override - public boolean isFull() { - Block blockBelow = worldObj.getBlock(xCoord, yCoord - 1, zCoord); - return blockBelow != ModBlocks.manaVoid && getCurrentMana() >= manaCap; - } - - @Override - public void recieveMana(int mana) { - this.mana = Math.max(0, Math.min(getCurrentMana() + mana, manaCap)); - worldObj.func_147453_f(xCoord, yCoord, zCoord, worldObj.getBlock(xCoord, yCoord, zCoord)); - markDispatchable(); - } - - @Override - public void invalidate() { - super.invalidate(); - ManaNetworkEvent.removePool(this); - } - - @Override - public void onChunkUnload() { - super.onChunkUnload(); - invalidate(); - } - - public boolean collideEntityItem(EntityItem item) { - if (item.isDead) return false; - - boolean didChange = false; - ItemStack stack = item.getEntityItem(); - if (stack == null) return false; - - if (stack.getItem() instanceof IManaDissolvable) { - ((IManaDissolvable) stack.getItem()).onDissolveTick(this, stack, item); - if (stack.stackSize == 0) item.setDead(); - } - - if (item.age > 100 && item.age < 130 || !catalystsRegistered) return false; - - for (RecipeManaInfusion recipe : BotaniaAPI.manaInfusionRecipes) { - if (recipe.matches(stack) && (!recipe.isAlchemy() || alchemy) && (!recipe.isConjuration() || conjuration)) { - int mana = recipe.getManaToConsume(); - if (getCurrentMana() >= mana) { - recieveMana(-mana); - - if (!worldObj.isRemote) { - stack.stackSize--; - if (stack.stackSize == 0) item.setDead(); - - ItemStack output = recipe.getOutput().copy(); - EntityItem outputItem = - new EntityItem(worldObj, xCoord + 0.5, yCoord + 1.5, zCoord + 0.5, output); - outputItem.age = 105; - worldObj.spawnEntityInWorld(outputItem); - } - - craftingFanciness(); - didChange = true; - } - - break; - } - } - - return didChange; - } - - public void craftingFanciness() { - if (soundTicks == 0) { - worldObj.playSoundEffect(xCoord, yCoord, zCoord, "botania:manaPoolCraft", 0.4F, 4F); - soundTicks = 6; - } - - for (int i = 0; i < 25; i++) { - float red = (float) Math.random(); - float green = (float) Math.random(); - float blue = (float) Math.random(); - Botania.proxy.sparkleFX( - worldObj, - xCoord + 0.5 + Math.random() * 0.4 - 0.2, - yCoord + 1, - zCoord + 0.5 + Math.random() * 0.4 - 0.2, - red, - green, - blue, - (float) Math.random(), - 10); - } - } - - @Override - public void updateEntity() { - boolean wasDoingTransfer = isDoingTransfer; - isDoingTransfer = false; - if (manaCap == -1) manaCap = getBlockMetadata() == 2 ? MAX_MANA_DILLUTED : MAX_MANA; - - if (!ManaNetworkHandler.instance.isPoolIn(this) && !isInvalid()) ManaNetworkEvent.addPool(this); - - if (soundTicks > 0) soundTicks--; - - if (worldObj.isRemote) { - double particleChance = 1F - (double) getCurrentMana() / (double) manaCap * 0.1; - Color color = new Color(0x00C6FF); - if (Math.random() > particleChance) - Botania.proxy.wispFX( - worldObj, - xCoord + 0.3 + Math.random() * 0.5, - yCoord + 0.6 + Math.random() * 0.25, - zCoord + Math.random(), - color.getRed() / 255F, - color.getGreen() / 255F, - color.getBlue() / 255F, - (float) Math.random() / 3F, - (float) -Math.random() / 25F, - 2F); - } - - if (sendPacket && ticks % 10 == 0) { - VanillaPacketDispatcher.dispatchTEToNearbyPlayers(this); - sendPacket = false; - } - - alchemy = worldObj.getBlock(xCoord, yCoord - 1, zCoord) == ModBlocks.alchemyCatalyst; - conjuration = worldObj.getBlock(xCoord, yCoord - 1, zCoord) == ModBlocks.conjurationCatalyst; - catalystsRegistered = true; - - List items = worldObj.getEntitiesWithinAABB( - EntityItem.class, - AxisAlignedBB.getBoundingBox(xCoord, yCoord, zCoord, xCoord + 1, yCoord + 1, zCoord + 1)); - for (EntityItem item : items) { - if (item.isDead) continue; - - ItemStack stack = item.getEntityItem(); - if (stack != null && stack.getItem() instanceof IManaItem) { - IManaItem mana = (IManaItem) stack.getItem(); - if (outputting && mana.canReceiveManaFromPool(stack, this) - || !outputting && mana.canExportManaToPool(stack, this)) { - boolean didSomething = false; - - int bellowCount = 0; - if (outputting) - for (ForgeDirection dir : LibMisc.CARDINAL_DIRECTIONS) { - TileEntity tile = - worldObj.getTileEntity(xCoord + dir.offsetX, yCoord, zCoord + dir.offsetZ); - if (tile != null - && tile instanceof TileBellows - && ((TileBellows) tile).getLinkedTile() == this) bellowCount++; - } - int transfRate = 1000 * (bellowCount + 1); - - if (outputting) { - if (canSpare) { - if (getCurrentMana() > 0 && mana.getMana(stack) < mana.getMaxMana(stack)) - didSomething = true; - - int manaVal = Math.min( - transfRate, - Math.min(getCurrentMana(), mana.getMaxMana(stack) - mana.getMana(stack))); - if (!worldObj.isRemote) mana.addMana(stack, manaVal); - recieveMana(-manaVal); - } - } else { - if (canAccept) { - if (mana.getMana(stack) > 0 && !isFull()) didSomething = true; - - int manaVal = - Math.min(transfRate, Math.min(manaCap - getCurrentMana(), mana.getMana(stack))); - if (!worldObj.isRemote) mana.addMana(stack, -manaVal); - recieveMana(manaVal); - } - } - - if (didSomething) { - if (worldObj.isRemote - && ConfigHandler.chargingAnimationEnabled - && worldObj.rand.nextInt(20) == 0) { - Vector3 itemVec = Vector3.fromTileEntity(this).add(0.5, 0.5 + Math.random() * 0.3, 0.5); - Vector3 tileVec = Vector3.fromTileEntity(this) - .add(0.2 + Math.random() * 0.6, 0, 0.2 + Math.random() * 0.6); - LightningHandler.spawnLightningBolt( - worldObj, - outputting ? tileVec : itemVec, - outputting ? itemVec : tileVec, - 80, - worldObj.rand.nextLong(), - 0x4400799c, - 0x4400C6FF); - } - isDoingTransfer = outputting; - } - } - } - } - - if (isDoingTransfer) ticksDoingTransfer++; - else { - ticksDoingTransfer = 0; - if (wasDoingTransfer) VanillaPacketDispatcher.dispatchTEToNearbyPlayers(this); - } - - ticks++; - } - - @Override - public void writeCustomNBT(NBTTagCompound cmp) { - cmp.setInteger(TAG_MANA, mana); - cmp.setBoolean(TAG_OUTPUTTING, outputting); - cmp.setInteger(TAG_COLOR, color); - - cmp.setInteger(TAG_MANA_CAP, manaCap); - cmp.setBoolean(TAG_CAN_ACCEPT, canAccept); - cmp.setBoolean(TAG_CAN_SPARE, canSpare); - cmp.setBoolean(TAG_FRAGILE, fragile); - - cmp.setString(TAG_INPUT_KEY, inputKey); - cmp.setString(TAG_OUTPUT_KEY, outputKey); - } - - @Override - public void readCustomNBT(NBTTagCompound cmp) { - mana = cmp.getInteger(TAG_MANA); - outputting = cmp.getBoolean(TAG_OUTPUTTING); - color = cmp.getInteger(TAG_COLOR); - - if (cmp.hasKey(TAG_MANA_CAP)) manaCap = cmp.getInteger(TAG_MANA_CAP); - if (cmp.hasKey(TAG_CAN_ACCEPT)) canAccept = cmp.getBoolean(TAG_CAN_ACCEPT); - if (cmp.hasKey(TAG_CAN_SPARE)) canSpare = cmp.getBoolean(TAG_CAN_SPARE); - fragile = cmp.getBoolean(TAG_FRAGILE); - - if (cmp.hasKey(TAG_INPUT_KEY)) inputKey = cmp.getString(TAG_INPUT_KEY); - if (cmp.hasKey(TAG_OUTPUT_KEY)) inputKey = cmp.getString(TAG_OUTPUT_KEY); - - if (cmp.hasKey(TAG_KNOWN_MANA)) knownMana = cmp.getInteger(TAG_KNOWN_MANA); - } - - public void onWanded(EntityPlayer player, ItemStack wand) { - if (player == null) return; - - if (player.isSneaking()) { - outputting = !outputting; - VanillaPacketDispatcher.dispatchTEToNearbyPlayers(worldObj, xCoord, yCoord, zCoord); - } - - if (!worldObj.isRemote) { - NBTTagCompound nbttagcompound = new NBTTagCompound(); - writeCustomNBT(nbttagcompound); - nbttagcompound.setInteger(TAG_KNOWN_MANA, getCurrentMana()); - if (player instanceof EntityPlayerMP) - ((EntityPlayerMP) player) - .playerNetServerHandler.sendPacket( - new S35PacketUpdateTileEntity(xCoord, yCoord, zCoord, -999, nbttagcompound)); - } - - worldObj.playSoundAtEntity(player, "botania:ding", 0.11F, 1F); - } - - public void renderHUD(Minecraft mc, ScaledResolution res) { - ItemStack pool = new ItemStack(ModBlocks.pool, 1, getBlockMetadata()); - String name = StatCollector.translateToLocal( - pool.getUnlocalizedName().replaceAll("tile.", "tile." + LibResources.PREFIX_MOD) + ".name"); - int color = 0x4444FF; - HUDHandler.drawSimpleManaHUD(color, knownMana, manaCap, name, res); - - int x = res.getScaledWidth() / 2 - 11; - int y = res.getScaledHeight() / 2 + 30; - - int u = outputting ? 22 : 0; - int v = 38; - - GL11.glEnable(GL11.GL_BLEND); - GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); - - mc.renderEngine.bindTexture(HUDHandler.manaBar); - RenderHelper.drawTexturedModalRect(x, y, 0, u, v, 22, 15); - GL11.glColor4f(1F, 1F, 1F, 1F); - - ItemStack tablet = new ItemStack(ModItems.manaTablet); - ItemManaTablet.setStackCreative(tablet); - - net.minecraft.client.renderer.RenderHelper.enableGUIStandardItemLighting(); - RenderItem.getInstance().renderItemAndEffectIntoGUI(mc.fontRenderer, mc.renderEngine, tablet, x - 20, y); - RenderItem.getInstance().renderItemAndEffectIntoGUI(mc.fontRenderer, mc.renderEngine, pool, x + 26, y); - net.minecraft.client.renderer.RenderHelper.disableStandardItemLighting(); - - GL11.glDisable(GL11.GL_LIGHTING); - GL11.glDisable(GL11.GL_BLEND); - } - - @Override - public boolean canRecieveManaFromBursts() { - return true; - } - - @Override - public boolean isOutputtingPower() { - return outputting; - } - - @Override - public int getCurrentMana() { - return worldObj != null && getBlockMetadata() == 1 ? MAX_MANA : mana; - } - - @Override - public String getInputKey() { - return inputKey; - } - - @Override - public String getOutputKey() { - return outputKey; - } - - @Override - public boolean canAttachSpark(ItemStack stack) { - return true; - } - - @Override - public void attachSpark(ISparkEntity entity) { - // NO-OP - } - - @Override - public ISparkEntity getAttachedSpark() { - List sparks = worldObj.getEntitiesWithinAABB( - ISparkEntity.class, - AxisAlignedBB.getBoundingBox(xCoord, yCoord + 1, zCoord, xCoord + 1, yCoord + 2, zCoord + 1)); - if (sparks.size() == 1) { - Entity e = (Entity) sparks.get(0); - return (ISparkEntity) e; - } - - return null; - } - - @Override - public boolean areIncomingTranfersDone() { - return false; - } - - @Override - public int getAvailableSpaceForMana() { - return Math.max(0, manaCap - getCurrentMana()); - } - - @Override - public int getColor() { - return color; - } - - @Override - public void setColor(int color) { - this.color = color; - } - - @Override - public void markDispatchable() { - sendPacket = true; - } +public class TilePool extends TileMod implements IManaPool, IDyablePool, IKeyLocked, ISparkAttachable, IThrottledPacket { + + public static final int MAX_MANA = 1000000; + public static final int MAX_MANA_DILLUTED = 10000; + + private static final String TAG_MANA = "mana"; + private static final String TAG_KNOWN_MANA = "knownMana"; + private static final String TAG_OUTPUTTING = "outputting"; + private static final String TAG_COLOR = "color"; + private static final String TAG_MANA_CAP = "manaCap"; + private static final String TAG_CAN_ACCEPT = "canAccept"; + private static final String TAG_CAN_SPARE = "canSpare"; + private static final String TAG_FRAGILE = "fragile"; + private static final String TAG_INPUT_KEY = "inputKey"; + private static final String TAG_OUTPUT_KEY = "outputKey"; + + boolean outputting = false; + public boolean alchemy = false; + public boolean conjuration = false; + boolean catalystsRegistered = false; + + public int color = 0; + int mana; + int knownMana = -1; + + public int manaCap = -1; + int soundTicks = 0; + boolean canAccept = true; + boolean canSpare = true; + public boolean fragile = false; + public boolean isDoingTransfer = false; + public int ticksDoingTransfer = 0; + + String inputKey = ""; + String outputKey = ""; + + int ticks = 0; + boolean sendPacket = false; + + @Override + public boolean isFull() { + Block blockBelow = worldObj.getBlock(xCoord, yCoord - 1, zCoord); + return blockBelow != ModBlocks.manaVoid && getCurrentMana() >= manaCap; + } + + @Override + public void recieveMana(int mana) { + this.mana = Math.max(0, Math.min(getCurrentMana() + mana, manaCap)); + worldObj.func_147453_f(xCoord, yCoord, zCoord, worldObj.getBlock(xCoord, yCoord, zCoord)); + markDispatchable(); + } + + @Override + public void invalidate() { + super.invalidate(); + ManaNetworkEvent.removePool(this); + } + + @Override + public void onChunkUnload() { + super.onChunkUnload(); + invalidate(); + } + + public boolean collideEntityItem(EntityItem item) { + if(item.isDead) + return false; + + boolean didChange = false; + ItemStack stack = item.getEntityItem(); + if(stack == null) + return false; + + if(stack.getItem() instanceof IManaDissolvable) { + ((IManaDissolvable) stack.getItem()).onDissolveTick(this, stack, item); + if(stack.stackSize == 0) + item.setDead(); + } + + if(item.age > 100 && item.age < 130 || !catalystsRegistered) + return false; + + for(RecipeManaInfusion recipe : BotaniaAPI.manaInfusionRecipes) { + if(recipe.matches(stack) && (!recipe.isAlchemy() || alchemy) && (!recipe.isConjuration() || conjuration)) { + int mana = recipe.getManaToConsume(); + if(getCurrentMana() >= mana) { + recieveMana(-mana); + + if(!worldObj.isRemote) { + stack.stackSize--; + if(stack.stackSize == 0) + item.setDead(); + + ItemStack output = recipe.getOutput().copy(); + EntityItem outputItem = new EntityItem(worldObj, xCoord + 0.5, yCoord + 1.5, zCoord + 0.5, output); + outputItem.age = 105; + worldObj.spawnEntityInWorld(outputItem); + } + + craftingFanciness(); + didChange = true; + } + + break; + } + } + + return didChange; + } + + public void craftingFanciness() { + if(soundTicks == 0) { + worldObj.playSoundEffect(xCoord, yCoord, zCoord, "botania:manaPoolCraft", 0.4F, 4F); + soundTicks = 6; + } + + for(int i = 0; i < 25; i++) { + float red = (float) Math.random(); + float green = (float) Math.random(); + float blue = (float) Math.random(); + Botania.proxy.sparkleFX(worldObj, xCoord + 0.5 + Math.random() * 0.4 - 0.2, yCoord + 1, zCoord + 0.5 + Math.random() * 0.4 - 0.2, red, green, blue, (float) Math.random(), 10); + } + } + + @Override + public void updateEntity() { + boolean wasDoingTransfer = isDoingTransfer; + isDoingTransfer = false; + if(manaCap == -1) + manaCap = getBlockMetadata() == 2 ? MAX_MANA_DILLUTED : MAX_MANA; + + if(!ManaNetworkHandler.instance.isPoolIn(this) && !isInvalid()) + ManaNetworkEvent.addPool(this); + + if(soundTicks > 0) + soundTicks--; + + if(worldObj.isRemote) { + double particleChance = 1F - (double) getCurrentMana() / (double) manaCap * 0.1; + Color color = new Color(0x00C6FF); + if(Math.random() > particleChance) + Botania.proxy.wispFX(worldObj, xCoord + 0.3 + Math.random() * 0.5, yCoord + 0.6 + Math.random() * 0.25, zCoord + Math.random(), color.getRed() / 255F, color.getGreen() / 255F, color.getBlue() / 255F, (float) Math.random() / 3F, (float) -Math.random() / 25F, 2F); + } + + if(sendPacket && ticks % 10 == 0) { + VanillaPacketDispatcher.dispatchTEToNearbyPlayers(this); + sendPacket = false; + } + + alchemy = worldObj.getBlock(xCoord, yCoord - 1, zCoord) == ModBlocks.alchemyCatalyst; + conjuration = worldObj.getBlock(xCoord, yCoord - 1, zCoord) == ModBlocks.conjurationCatalyst; + catalystsRegistered = true; + + List items = worldObj.getEntitiesWithinAABB(EntityItem.class, AxisAlignedBB.getBoundingBox(xCoord, yCoord, zCoord, xCoord + 1, yCoord + 1, zCoord + 1)); + for(EntityItem item : items) { + if(item.isDead) + continue; + + ItemStack stack = item.getEntityItem(); + if(stack != null && stack.getItem() instanceof IManaItem) { + IManaItem mana = (IManaItem) stack.getItem(); + if(outputting && mana.canReceiveManaFromPool(stack, this) || !outputting && mana.canExportManaToPool(stack, this)) { + boolean didSomething = false; + + int bellowCount = 0; + if(outputting) + for(ForgeDirection dir : LibMisc.CARDINAL_DIRECTIONS) { + TileEntity tile = worldObj.getTileEntity(xCoord + dir.offsetX, yCoord, zCoord + dir.offsetZ); + if(tile != null && tile instanceof TileBellows && ((TileBellows) tile).getLinkedTile() == this) + bellowCount++; + } + int transfRate = 1000 * (bellowCount + 1); + + if(outputting) { + if(canSpare) { + if(getCurrentMana() > 0 && mana.getMana(stack) < mana.getMaxMana(stack)) + didSomething = true; + + int manaVal = Math.min(transfRate, Math.min(getCurrentMana(), mana.getMaxMana(stack) - mana.getMana(stack))); + if(!worldObj.isRemote) + mana.addMana(stack, manaVal); + recieveMana(-manaVal); + } + } else { + if(canAccept) { + if(mana.getMana(stack) > 0 && !isFull()) + didSomething = true; + + int manaVal = Math.min(transfRate, Math.min(manaCap - getCurrentMana(), mana.getMana(stack))); + if(!worldObj.isRemote) + mana.addMana(stack, -manaVal); + recieveMana(manaVal); + } + } + + if(didSomething) { + if(worldObj.isRemote && ConfigHandler.chargingAnimationEnabled && worldObj.rand.nextInt(20) == 0) { + Vector3 itemVec = Vector3.fromTileEntity(this).add(0.5, 0.5 + Math.random() * 0.3, 0.5); + Vector3 tileVec = Vector3.fromTileEntity(this).add(0.2 + Math.random() * 0.6, 0, 0.2 + Math.random() * 0.6); + LightningHandler.spawnLightningBolt(worldObj, outputting ? tileVec : itemVec, outputting ? itemVec : tileVec, 80, worldObj.rand.nextLong(), 0x4400799c, 0x4400C6FF); + } + isDoingTransfer = outputting; + } + } + } + } + + if(isDoingTransfer) + ticksDoingTransfer++; + else { + ticksDoingTransfer = 0; + if(wasDoingTransfer) + VanillaPacketDispatcher.dispatchTEToNearbyPlayers(this); + } + + ticks++; + } + + @Override + public void writeCustomNBT(NBTTagCompound cmp) { + cmp.setInteger(TAG_MANA, mana); + cmp.setBoolean(TAG_OUTPUTTING, outputting); + cmp.setInteger(TAG_COLOR, color); + + cmp.setInteger(TAG_MANA_CAP, manaCap); + cmp.setBoolean(TAG_CAN_ACCEPT, canAccept); + cmp.setBoolean(TAG_CAN_SPARE, canSpare); + cmp.setBoolean(TAG_FRAGILE, fragile); + + cmp.setString(TAG_INPUT_KEY, inputKey); + cmp.setString(TAG_OUTPUT_KEY, outputKey); + } + + @Override + public void readCustomNBT(NBTTagCompound cmp) { + mana = cmp.getInteger(TAG_MANA); + outputting = cmp.getBoolean(TAG_OUTPUTTING); + color = cmp.getInteger(TAG_COLOR); + + if(cmp.hasKey(TAG_MANA_CAP)) + manaCap = cmp.getInteger(TAG_MANA_CAP); + if(cmp.hasKey(TAG_CAN_ACCEPT)) + canAccept = cmp.getBoolean(TAG_CAN_ACCEPT); + if(cmp.hasKey(TAG_CAN_SPARE)) + canSpare = cmp.getBoolean(TAG_CAN_SPARE); + fragile = cmp.getBoolean(TAG_FRAGILE); + + if(cmp.hasKey(TAG_INPUT_KEY)) + inputKey = cmp.getString(TAG_INPUT_KEY); + if(cmp.hasKey(TAG_OUTPUT_KEY)) + inputKey = cmp.getString(TAG_OUTPUT_KEY); + + if(cmp.hasKey(TAG_KNOWN_MANA)) + knownMana = cmp.getInteger(TAG_KNOWN_MANA); + } + + public void onWanded(EntityPlayer player, ItemStack wand) { + if(player == null) + return; + + if(player.isSneaking()) { + outputting = !outputting; + VanillaPacketDispatcher.dispatchTEToNearbyPlayers(worldObj, xCoord, yCoord, zCoord); + } + + if(!worldObj.isRemote) { + NBTTagCompound nbttagcompound = new NBTTagCompound(); + writeCustomNBT(nbttagcompound); + nbttagcompound.setInteger(TAG_KNOWN_MANA, getCurrentMana()); + if(player instanceof EntityPlayerMP) + ((EntityPlayerMP) player).playerNetServerHandler.sendPacket(new S35PacketUpdateTileEntity(xCoord, yCoord, zCoord, -999, nbttagcompound)); + } + + worldObj.playSoundAtEntity(player, "botania:ding", 0.11F, 1F); + } + + public void renderHUD(Minecraft mc, ScaledResolution res) { + ItemStack pool = new ItemStack(ModBlocks.pool, 1, getBlockMetadata()); + String name = StatCollector.translateToLocal(pool.getUnlocalizedName().replaceAll("tile.", "tile." + LibResources.PREFIX_MOD) + ".name"); + int color = 0x4444FF; + HUDHandler.drawSimpleManaHUD(color, knownMana, manaCap, name, res); + + int x = res.getScaledWidth() / 2 - 11; + int y = res.getScaledHeight() / 2 + 30; + + int u = outputting ? 22 : 0; + int v = 38; + + GL11.glEnable(GL11.GL_BLEND); + GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); + + mc.renderEngine.bindTexture(HUDHandler.manaBar); + RenderHelper.drawTexturedModalRect(x, y, 0, u, v, 22, 15); + GL11.glColor4f(1F, 1F, 1F, 1F); + + ItemStack tablet = new ItemStack(ModItems.manaTablet); + ItemManaTablet.setStackCreative(tablet); + + net.minecraft.client.renderer.RenderHelper.enableGUIStandardItemLighting(); + RenderItem.getInstance().renderItemAndEffectIntoGUI(mc.fontRenderer, mc.renderEngine, tablet, x - 20, y); + RenderItem.getInstance().renderItemAndEffectIntoGUI(mc.fontRenderer, mc.renderEngine, pool, x + 26, y); + net.minecraft.client.renderer.RenderHelper.disableStandardItemLighting(); + + GL11.glDisable(GL11.GL_LIGHTING); + GL11.glDisable(GL11.GL_BLEND); + } + + @Override + public boolean canRecieveManaFromBursts() { + return true; + } + + @Override + public boolean isOutputtingPower() { + return outputting; + } + + @Override + public int getCurrentMana() { + return worldObj != null && getBlockMetadata() == 1 ? MAX_MANA : mana; + } + + @Override + public String getInputKey() { + return inputKey; + } + + @Override + public String getOutputKey() { + return outputKey; + } + + @Override + public boolean canAttachSpark(ItemStack stack) { + return true; + } + + @Override + public void attachSpark(ISparkEntity entity) { + // NO-OP + } + + @Override + public ISparkEntity getAttachedSpark() { + List sparks = worldObj.getEntitiesWithinAABB(ISparkEntity.class, AxisAlignedBB.getBoundingBox(xCoord, yCoord + 1, zCoord, xCoord + 1, yCoord + 2, zCoord + 1)); + if(sparks.size() == 1) { + Entity e = (Entity) sparks.get(0); + return (ISparkEntity) e; + } + + return null; + } + + @Override + public boolean areIncomingTranfersDone() { + return false; + } + + @Override + public int getAvailableSpaceForMana() { + return Math.max(0, manaCap - getCurrentMana()); + } + + @Override + public int getColor() { + return color; + } + + @Override + public void setColor(int color) { + this.color = color; + } + + @Override + public void markDispatchable() { + sendPacket = true; + } } diff --git a/src/main/java/vazkii/botania/common/block/tile/mana/TilePrism.java b/src/main/java/vazkii/botania/common/block/tile/mana/TilePrism.java index d9d31cbfb8..974315976d 100644 --- a/src/main/java/vazkii/botania/common/block/tile/mana/TilePrism.java +++ b/src/main/java/vazkii/botania/common/block/tile/mana/TilePrism.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jan 17, 2015, 7:27:04 PM (GMT)] */ package vazkii.botania.common.block.tile.mana; @@ -23,71 +23,60 @@ public class TilePrism extends TileSimpleInventory implements IManaCollisionGhost, ISidedInventory { - public void onBurstCollision(IManaBurst burst) { - ItemStack lens = getStackInSlot(0); - boolean active = (getBlockMetadata() & 8) == 0; - boolean valid = lens != null - && lens.getItem() instanceof ILens - && (!(lens.getItem() instanceof ITinyPlanetExcempt) - || ((ITinyPlanetExcempt) lens.getItem()).shouldPull(lens)); + public void onBurstCollision(IManaBurst burst) { + ItemStack lens = getStackInSlot(0); + boolean active = (getBlockMetadata() & 8) == 0; + boolean valid = lens != null && lens.getItem() instanceof ILens && (!(lens.getItem() instanceof ITinyPlanetExcempt) || ((ITinyPlanetExcempt) lens.getItem()).shouldPull(lens)); - if (active) { - burst.setSourceLens(valid ? lens.copy() : null); - burst.setColor(0xFFFFFF); - burst.setGravity(0F); + if(active) { + burst.setSourceLens(valid ? lens.copy() : null); + burst.setColor(0xFFFFFF); + burst.setGravity(0F); - if (valid) { - Entity burstEntity = (Entity) burst; - BurstProperties properties = new BurstProperties( - burst.getStartingMana(), - burst.getMinManaLoss(), - burst.getManaLossPerTick(), - burst.getGravity(), - 1F, - burst.getColor()); + if(valid) { + Entity burstEntity = (Entity) burst; + BurstProperties properties = new BurstProperties(burst.getStartingMana(), burst.getMinManaLoss(), burst.getManaLossPerTick(), burst.getGravity(), 1F, burst.getColor()); - ((ILens) lens.getItem()).apply(lens, properties); + ((ILens) lens.getItem()).apply(lens, properties); - burst.setColor(properties.color); - burst.setStartingMana(properties.maxMana); - burst.setMinManaLoss(properties.ticksBeforeManaLoss); - burst.setManaLossPerTick(properties.manaLossPerTick); - burst.setGravity(properties.gravity); - burst.setMotion( - burstEntity.motionX * properties.motionModifier, - burstEntity.motionY * properties.motionModifier, - burstEntity.motionZ * properties.motionModifier); - } - } - } + burst.setColor(properties.color); + burst.setStartingMana(properties.maxMana); + burst.setMinManaLoss(properties.ticksBeforeManaLoss); + burst.setManaLossPerTick(properties.manaLossPerTick); + burst.setGravity(properties.gravity); + burst.setMotion(burstEntity.motionX * properties.motionModifier, burstEntity.motionY * properties.motionModifier,burstEntity.motionZ * properties.motionModifier); + } + } + } - @Override - public boolean isGhost() { - return true; - } + @Override + public boolean isGhost() { + return true; + } - @Override - public int getSizeInventory() { - return 1; - } + @Override + public int getSizeInventory() { + return 1; + } - @Override - public String getInventoryName() { - return LibBlockNames.PRISM; - } + @Override + public String getInventoryName() { + return LibBlockNames.PRISM; + } - @Override - public int[] getAccessibleSlotsFromSide(int p_94128_1_) { - return new int[] {0}; - } + @Override + public int[] getAccessibleSlotsFromSide(int p_94128_1_) { + return new int[] { 0 }; + } - @Override - public boolean canInsertItem(int p_102007_1_, ItemStack p_102007_2_, int p_102007_3_) { - return p_102007_2_.getItem() instanceof ILens; - } + @Override + public boolean canInsertItem(int p_102007_1_, ItemStack p_102007_2_, int p_102007_3_) { + return p_102007_2_.getItem() instanceof ILens; + } + + @Override + public boolean canExtractItem(int p_102008_1_, ItemStack p_102008_2_, int p_102008_3_) { + return true; + } - @Override - public boolean canExtractItem(int p_102008_1_, ItemStack p_102008_2_, int p_102008_3_) { - return true; - } } diff --git a/src/main/java/vazkii/botania/common/block/tile/mana/TilePump.java b/src/main/java/vazkii/botania/common/block/tile/mana/TilePump.java index 16febbd8aa..e5adc8b708 100644 --- a/src/main/java/vazkii/botania/common/block/tile/mana/TilePump.java +++ b/src/main/java/vazkii/botania/common/block/tile/mana/TilePump.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Mar 18, 2015, 3:16:57 PM (GMT)] */ package vazkii.botania.common.block.tile.mana; @@ -17,83 +17,86 @@ public class TilePump extends TileMod { - private static final String TAG_ACTIVE = "active"; - - public float innerRingPos; - public boolean active = false; - public boolean hasCart = false; - public boolean hasCartOnTop = false; - public float moving = 0F; - - public int comparator; - public boolean hasRedstone = false; - int lastComparator = 0; - - @Override - public void updateEntity() { - hasRedstone = false; - for (ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS) { - int redstoneSide = worldObj.getIndirectPowerLevelTo( - xCoord + dir.offsetX, yCoord + dir.offsetY, zCoord + dir.offsetZ, dir.ordinal()); - if (redstoneSide > 0) { - hasRedstone = true; - break; - } - } - - float max = 8F; - float min = 0F; - - float incr = max / 10F; - - if (innerRingPos < max && active && moving >= 0F) { - innerRingPos += incr; - moving = incr; - if (innerRingPos >= max) { - innerRingPos = Math.min(max, innerRingPos); - moving = 0F; - for (int x = 0; x < 2; x++) - worldObj.spawnParticle( - "explode", xCoord + Math.random(), yCoord + Math.random(), zCoord + Math.random(), 0, 0, 0); - } - } else if (innerRingPos > min) { - innerRingPos -= incr * 2; - moving = -incr * 2; - if (innerRingPos <= min) { - innerRingPos = Math.max(min, innerRingPos); - moving = 0F; - } - } - - if (!hasCartOnTop) comparator = 0; - if (!hasCart && active) setActive(false); - if (active && hasRedstone) setActive(false); - - hasCart = false; - hasCartOnTop = false; - - if (comparator != lastComparator) - worldObj.func_147453_f(xCoord, yCoord, zCoord, worldObj.getBlock(xCoord, yCoord, zCoord)); - lastComparator = comparator; - - super.updateEntity(); - } - - @Override - public void writeCustomNBT(NBTTagCompound cmp) { - cmp.setBoolean(TAG_ACTIVE, active); - } - - @Override - public void readCustomNBT(NBTTagCompound cmp) { - active = cmp.getBoolean(TAG_ACTIVE); - } - - public void setActive(boolean active) { - if (!worldObj.isRemote) { - boolean diff = this.active != active; - this.active = active; - if (diff) VanillaPacketDispatcher.dispatchTEToNearbyPlayers(worldObj, xCoord, yCoord, zCoord); - } - } + private static final String TAG_ACTIVE = "active"; + + public float innerRingPos; + public boolean active = false; + public boolean hasCart = false; + public boolean hasCartOnTop = false; + public float moving = 0F; + + public int comparator; + public boolean hasRedstone = false; + int lastComparator = 0; + + @Override + public void updateEntity() { + hasRedstone = false; + for(ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS) { + int redstoneSide = worldObj.getIndirectPowerLevelTo(xCoord + dir.offsetX, yCoord + dir.offsetY, zCoord + dir.offsetZ, dir.ordinal()); + if(redstoneSide > 0) { + hasRedstone = true; + break; + } + } + + float max = 8F; + float min = 0F; + + float incr = max / 10F; + + if(innerRingPos < max && active && moving >= 0F) { + innerRingPos += incr; + moving = incr; + if(innerRingPos >= max) { + innerRingPos = Math.min(max, innerRingPos); + moving = 0F; + for(int x = 0; x < 2; x++) + worldObj.spawnParticle("explode", xCoord + Math.random(), yCoord + Math.random(), zCoord + Math.random(), 0, 0, 0); + } + } else if(innerRingPos > min) { + innerRingPos -= incr * 2; + moving = -incr * 2; + if(innerRingPos <= min) { + innerRingPos = Math.max(min, innerRingPos); + moving = 0F; + } + } + + if(!hasCartOnTop) + comparator = 0; + if(!hasCart && active) + setActive(false); + if(active && hasRedstone) + setActive(false); + + hasCart = false; + hasCartOnTop = false; + + if(comparator != lastComparator) + worldObj.func_147453_f(xCoord, yCoord, zCoord, worldObj.getBlock(xCoord, yCoord, zCoord)); + lastComparator = comparator; + + super.updateEntity(); + } + + @Override + public void writeCustomNBT(NBTTagCompound cmp) { + cmp.setBoolean(TAG_ACTIVE, active); + } + + @Override + public void readCustomNBT(NBTTagCompound cmp) { + active = cmp.getBoolean(TAG_ACTIVE); + } + + public void setActive(boolean active) { + if(!worldObj.isRemote) { + boolean diff = this.active != active; + this.active = active; + if(diff) + VanillaPacketDispatcher.dispatchTEToNearbyPlayers(worldObj, xCoord, yCoord, zCoord); + } + } + } diff --git a/src/main/java/vazkii/botania/common/block/tile/mana/TileRFGenerator.java b/src/main/java/vazkii/botania/common/block/tile/mana/TileRFGenerator.java index 42c6f78baa..59e76677f1 100644 --- a/src/main/java/vazkii/botania/common/block/tile/mana/TileRFGenerator.java +++ b/src/main/java/vazkii/botania/common/block/tile/mana/TileRFGenerator.java @@ -2,138 +2,150 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Aug 29, 2014, 10:01:32 PM (GMT)] */ package vazkii.botania.common.block.tile.mana; -import cofh.api.energy.IEnergyConnection; -import cofh.api.energy.IEnergyReceiver; -import cpw.mods.fml.common.Optional; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.tileentity.TileEntity; import net.minecraftforge.common.util.ForgeDirection; import vazkii.botania.api.mana.IManaReceiver; import vazkii.botania.common.block.tile.TileMod; +import cofh.api.energy.IEnergyConnection; +import cofh.api.energy.IEnergyReceiver; +import cpw.mods.fml.common.Optional; @Optional.Interface(iface = "cofh.api.energy.IEnergyConnection", modid = "CoFHAPI|energy") public class TileRFGenerator extends TileMod implements IManaReceiver, IEnergyConnection { - private static final int CONVERSION_RATE = 10; - private static final int MAX_MANA = 1280 * CONVERSION_RATE; - - private static final String TAG_MANA = "mana"; - - int mana = 0; - - // Thanks to skyboy for help with this cuz I'm a noob with RF - private IEnergyReceiver[] receiverCache; - private boolean deadCache; - - @Override - @Optional.Method(modid = "CoFHAPI|energy") - public void validate() { - super.validate(); - deadCache = true; - receiverCache = null; - } - - @Override - @Optional.Method(modid = "CoFHAPI|energy") - public void updateEntity() { - super.updateEntity(); - if (!worldObj.isRemote) { - if (deadCache) reCache(); - - int transfer = Math.min(mana, 160 * CONVERSION_RATE); - mana -= transfer; - mana += transmitEnergy(transfer); - } - } - - @Optional.Method(modid = "CoFHAPI|energy") - protected final int transmitEnergy(int energy) { - if (receiverCache != null) - for (int i = receiverCache.length; i-- > 0; ) { - IEnergyReceiver tile = receiverCache[i]; - if (tile == null) continue; - - ForgeDirection from = ForgeDirection.VALID_DIRECTIONS[i]; - if (tile.receiveEnergy(from, energy, true) > 0) energy -= tile.receiveEnergy(from, energy, false); - - if (energy <= 0) return 0; - } - - return energy; - } - - @Optional.Method(modid = "CoFHAPI|energy") - private void reCache() { - if (deadCache) { - for (ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS) - onNeighborTileChange(xCoord + dir.offsetX, yCoord + dir.offsetY, zCoord + dir.offsetZ); - deadCache = false; - } - } - - @Optional.Method(modid = "CoFHAPI|energy") - public void onNeighborTileChange(int x, int y, int z) { - TileEntity tile = worldObj.getTileEntity(x, y, z); - - if (x < xCoord) addCache(tile, 5); - else if (x > xCoord) addCache(tile, 4); - else if (z < zCoord) addCache(tile, 3); - else if (z > zCoord) addCache(tile, 2); - else if (y < yCoord) addCache(tile, 1); - else if (y > yCoord) addCache(tile, 0); - } - - @Optional.Method(modid = "CoFHAPI|energy") - private void addCache(TileEntity tile, int side) { - if (receiverCache != null) receiverCache[side] = null; - - if (tile instanceof IEnergyReceiver - && ((IEnergyReceiver) tile).canConnectEnergy(ForgeDirection.VALID_DIRECTIONS[side])) { - if (receiverCache == null) receiverCache = new IEnergyReceiver[6]; - receiverCache[side] = (IEnergyReceiver) tile; - } - } - - @Override - public int getCurrentMana() { - return mana / CONVERSION_RATE; - } - - @Override - public boolean isFull() { - return mana >= MAX_MANA; - } - - @Override - public void recieveMana(int mana) { - this.mana = Math.min(MAX_MANA, this.mana + mana * CONVERSION_RATE); - } - - @Override - public boolean canRecieveManaFromBursts() { - return true; - } - - @Override - public void writeCustomNBT(NBTTagCompound cmp) { - cmp.setInteger(TAG_MANA, mana); - } - - @Override - public void readCustomNBT(NBTTagCompound cmp) { - mana = cmp.getInteger(TAG_MANA); - } - - @Override - public boolean canConnectEnergy(ForgeDirection from) { - return true; - } + private static final int CONVERSION_RATE = 10; + private static final int MAX_MANA = 1280 * CONVERSION_RATE; + + private static final String TAG_MANA = "mana"; + + int mana = 0; + + // Thanks to skyboy for help with this cuz I'm a noob with RF + private IEnergyReceiver[] receiverCache; + private boolean deadCache; + + @Override + @Optional.Method(modid = "CoFHAPI|energy") + public void validate() { + super.validate(); + deadCache = true; + receiverCache = null; + } + + @Override + @Optional.Method(modid = "CoFHAPI|energy") + public void updateEntity() { + super.updateEntity(); + if(!worldObj.isRemote) { + if(deadCache) + reCache(); + + int transfer = Math.min(mana, 160 * CONVERSION_RATE); + mana -= transfer; + mana += transmitEnergy(transfer); + } + } + + @Optional.Method(modid = "CoFHAPI|energy") + protected final int transmitEnergy(int energy) { + if(receiverCache != null) + for(int i = receiverCache.length; i-- > 0;) { + IEnergyReceiver tile = receiverCache[i]; + if(tile == null) + continue; + + ForgeDirection from = ForgeDirection.VALID_DIRECTIONS[i]; + if(tile.receiveEnergy(from, energy, true) > 0) + energy -= tile.receiveEnergy(from, energy, false); + + if(energy <= 0) + return 0; + } + + return energy; + } + + @Optional.Method(modid = "CoFHAPI|energy") + private void reCache() { + if(deadCache) { + for(ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS) + onNeighborTileChange(xCoord + dir.offsetX, yCoord + dir.offsetY, zCoord + dir.offsetZ); + deadCache = false; + } + } + + @Optional.Method(modid = "CoFHAPI|energy") + public void onNeighborTileChange(int x, int y, int z) { + TileEntity tile = worldObj.getTileEntity(x, y, z); + + if(x < xCoord) + addCache(tile, 5); + else if(x > xCoord) + addCache(tile, 4); + else if(z < zCoord) + addCache(tile, 3); + else if(z > zCoord) + addCache(tile, 2); + else if(y < yCoord) + addCache(tile, 1); + else if(y > yCoord) + addCache(tile, 0); + } + + @Optional.Method(modid = "CoFHAPI|energy") + private void addCache(TileEntity tile, int side) { + if(receiverCache != null) + receiverCache[side] = null; + + if(tile instanceof IEnergyReceiver && ((IEnergyReceiver)tile).canConnectEnergy(ForgeDirection.VALID_DIRECTIONS[side])) { + if(receiverCache == null) + receiverCache = new IEnergyReceiver[6]; + receiverCache[side] = (IEnergyReceiver)tile; + } + } + + @Override + public int getCurrentMana() { + return mana / CONVERSION_RATE; + } + + @Override + public boolean isFull() { + return mana >= MAX_MANA; + } + + @Override + public void recieveMana(int mana) { + this.mana = Math.min(MAX_MANA, this.mana + mana * CONVERSION_RATE); + } + + @Override + public boolean canRecieveManaFromBursts() { + return true; + } + + @Override + public void writeCustomNBT(NBTTagCompound cmp) { + cmp.setInteger(TAG_MANA, mana); + } + + @Override + public void readCustomNBT(NBTTagCompound cmp) { + mana = cmp.getInteger(TAG_MANA); + } + + @Override + public boolean canConnectEnergy(ForgeDirection from) { + return true; + } + } diff --git a/src/main/java/vazkii/botania/common/block/tile/mana/TileSpreader.java b/src/main/java/vazkii/botania/common/block/tile/mana/TileSpreader.java index d7465b4191..dff35de37b 100644 --- a/src/main/java/vazkii/botania/common/block/tile/mana/TileSpreader.java +++ b/src/main/java/vazkii/botania/common/block/tile/mana/TileSpreader.java @@ -2,16 +2,17 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jan 25, 2014, 9:40:57 PM (GMT)] */ package vazkii.botania.common.block.tile.mana; import java.util.List; import java.util.UUID; + import net.minecraft.client.Minecraft; import net.minecraft.client.gui.ScaledResolution; import net.minecraft.client.renderer.RenderHelper; @@ -31,7 +32,9 @@ import net.minecraft.util.Vec3; import net.minecraft.world.World; import net.minecraftforge.common.util.ForgeDirection; + import org.lwjgl.opengl.GL11; + import vazkii.botania.api.internal.IManaBurst; import vazkii.botania.api.internal.VanillaPacketDispatcher; import vazkii.botania.api.mana.BurstProperties; @@ -58,713 +61,705 @@ import vazkii.botania.common.entity.EntityManaBurst.PositionProperties; import vazkii.botania.common.lib.LibBlockNames; -public class TileSpreader extends TileSimpleInventory - implements IManaCollector, IWandBindable, IKeyLocked, IThrottledPacket, IManaSpreader, IRedirectable { - - private static final int MAX_MANA = 1000; - private static final int ULTRA_MAX_MANA = 6400; - private static final int TICKS_ALLOWED_WITHOUT_PINGBACK = 20; - private static final double PINGBACK_EXPIRED_SEARCH_DISTANCE = 0.5; - - private static final String TAG_HAS_IDENTITY = "hasIdentity"; - private static final String TAG_UUID_MOST = "uuidMost"; - private static final String TAG_UUID_LEAST = "uuidLeast"; - private static final String TAG_MANA = "mana"; - private static final String TAG_KNOWN_MANA = "knownMana"; - private static final String TAG_REQUEST_UPDATE = "requestUpdate"; - private static final String TAG_ROTATION_X = "rotationX"; - private static final String TAG_ROTATION_Y = "rotationY"; - private static final String TAG_PADDING_COLOR = "paddingColor"; - private static final String TAG_CAN_SHOOT_BURST = "canShootBurst"; - private static final String TAG_PINGBACK_TICKS = "pingbackTicks"; - private static final String TAG_LAST_PINGBACK_X = "lastPingbackX"; - private static final String TAG_LAST_PINGBACK_Y = "lastPingbackY"; - private static final String TAG_LAST_PINGBACK_Z = "lastPingbackZ"; - - private static final String TAG_FORCE_CLIENT_BINDING_X = "forceClientBindingX"; - private static final String TAG_FORCE_CLIENT_BINDING_Y = "forceClientBindingY"; - private static final String TAG_FORCE_CLIENT_BINDING_Z = "forceClientBindingZ"; - - // Map Maker Tags - - private static final String TAG_INPUT_KEY = "inputKey"; - private static final String TAG_OUTPUT_KEY = "outputKey"; - - private static final String TAG_MAPMAKER_OVERRIDE = "mapmakerOverrideEnabled"; - private static final String TAG_FORCED_COLOR = "mmForcedColor"; - private static final String TAG_FORCED_MANA_PAYLOAD = "mmForcedManaPayload"; - private static final String TAG_FORCED_TICKS_BEFORE_MANA_LOSS = "mmForcedTicksBeforeManaLoss"; - private static final String TAG_FORCED_MANA_LOSS_PER_TICK = "mmForcedManaLossPerTick"; - private static final String TAG_FORCED_GRAVITY = "mmForcedGravity"; - private static final String TAG_FORCED_VELOCITY_MULTIPLIER = "mmForcedVelocityMultiplier"; - - boolean mapmakerOverride = false; - int mmForcedColor = 0x20FF20; - int mmForcedManaPayload = 160; - int mmForcedTicksBeforeManaLoss = 60; - float mmForcedManaLossPerTick = 4F; - float mmForcedGravity = 0F; - float mmForcedVelocityMultiplier = 1F; - - String inputKey = ""; - String outputKey = ""; - - // End Map Maker Tags - - public static boolean staticRedstone = false; - public static boolean staticDreamwood = false; - public static boolean staticUltra = false; - - UUID identity; - - int mana; - int knownMana = -1; - public float rotationX, rotationY; - public int paddingColor = -1; - - boolean requestsClientUpdate = false; - boolean hasReceivedInitialPacket = false; - - IManaReceiver receiver = null; - IManaReceiver receiverLastTick = null; - - boolean redstoneLastTick = true; - public boolean canShootBurst = true; - public int lastBurstDeathTick = -1; - public int burstParticleTick = 0; - - public int pingbackTicks = 0; - public double lastPingbackX = 0; - public double lastPingbackY = -1; - public double lastPingbackZ = 0; - - List lastTentativeBurst; - boolean invalidTentativeBurst = false; - - @Override - public boolean isFull() { - return mana >= getMaxMana(); - } - - @Override - public void recieveMana(int mana) { - this.mana = Math.min(this.mana + mana, getMaxMana()); - } - - @Override - public void invalidate() { - super.invalidate(); - ManaNetworkEvent.removeCollector(this); - } - - @Override - public void onChunkUnload() { - super.onChunkUnload(); - invalidate(); - } - - @Override - public void updateEntity() { - boolean inNetwork = ManaNetworkHandler.instance.isCollectorIn(this); - boolean wasInNetwork = inNetwork; - if (!inNetwork && !isInvalid()) { - ManaNetworkEvent.addCollector(this); - inNetwork = true; - } - - boolean redstone = false; - - for (ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS) { - TileEntity tileAt = - worldObj.getTileEntity(xCoord + dir.offsetX, yCoord + dir.offsetY, zCoord + dir.offsetZ); - if (tileAt instanceof IManaPool) { - IManaPool pool = (IManaPool) tileAt; - if (wasInNetwork && (pool != receiver || isRedstone())) { - if (pool instanceof IKeyLocked - && !((IKeyLocked) pool).getOutputKey().equals(getInputKey())) continue; - - int manaInPool = pool.getCurrentMana(); - if (manaInPool > 0 && !isFull()) { - int manaMissing = getMaxMana() - mana; - int manaToRemove = Math.min(manaInPool, manaMissing); - pool.recieveMana(-manaToRemove); - recieveMana(manaToRemove); - } - } - } - - int redstoneSide = worldObj.getIndirectPowerLevelTo( - xCoord + dir.offsetX, yCoord + dir.offsetY, zCoord + dir.offsetZ, dir.ordinal()); - if (redstoneSide > 0) redstone = true; - } - - if (needsNewBurstSimulation()) checkForReceiver(); - - if (!canShootBurst) - if (pingbackTicks <= 0) { - double x = lastPingbackX; - double y = lastPingbackY; - double z = lastPingbackZ; - AxisAlignedBB aabb = AxisAlignedBB.getBoundingBox(x, y, z, x, y, z) - .expand( - PINGBACK_EXPIRED_SEARCH_DISTANCE, - PINGBACK_EXPIRED_SEARCH_DISTANCE, - PINGBACK_EXPIRED_SEARCH_DISTANCE); - List bursts = worldObj.getEntitiesWithinAABB(IManaBurst.class, aabb); - IManaBurst found = null; - UUID identity = getIdentifier(); - for (IManaBurst burst : bursts) - if (burst != null && identity.equals(burst.getShooterUIID())) { - found = burst; - break; - } - - if (found != null) found.ping(); - else setCanShoot(true); - } else pingbackTicks--; - - boolean shouldShoot = !redstone; - - boolean isredstone = isRedstone(); - if (isredstone) shouldShoot = redstone && !redstoneLastTick; - - if (shouldShoot && receiver != null && receiver instanceof IKeyLocked) - shouldShoot = ((IKeyLocked) receiver).getInputKey().equals(getOutputKey()); - - ItemStack lens = getStackInSlot(0); - ILensControl control = getLensController(lens); - if (control != null) { - if (isredstone) { - if (shouldShoot) control.onControlledSpreaderPulse(lens, this, redstone); - } else control.onControlledSpreaderTick(lens, this, redstone); - - shouldShoot &= control.allowBurstShooting(lens, this, redstone); - } - - if (shouldShoot) tryShootBurst(); - - if (receiverLastTick != receiver && !worldObj.isRemote) { - requestsClientUpdate = true; - VanillaPacketDispatcher.dispatchTEToNearbyPlayers(worldObj, xCoord, yCoord, zCoord); - } - - redstoneLastTick = redstone; - receiverLastTick = receiver; - } - - @Override - public void writeCustomNBT(NBTTagCompound cmp) { - super.writeCustomNBT(cmp); - - UUID identity = getIdentifier(); - cmp.setBoolean(TAG_HAS_IDENTITY, true); - cmp.setLong(TAG_UUID_MOST, identity.getMostSignificantBits()); - cmp.setLong(TAG_UUID_LEAST, identity.getLeastSignificantBits()); - - cmp.setInteger(TAG_MANA, mana); - cmp.setFloat(TAG_ROTATION_X, rotationX); - cmp.setFloat(TAG_ROTATION_Y, rotationY); - cmp.setBoolean(TAG_REQUEST_UPDATE, requestsClientUpdate); - cmp.setInteger(TAG_PADDING_COLOR, paddingColor); - cmp.setBoolean(TAG_CAN_SHOOT_BURST, canShootBurst); - - cmp.setInteger(TAG_PINGBACK_TICKS, pingbackTicks); - cmp.setDouble(TAG_LAST_PINGBACK_X, lastPingbackX); - cmp.setDouble(TAG_LAST_PINGBACK_Y, lastPingbackY); - cmp.setDouble(TAG_LAST_PINGBACK_Z, lastPingbackZ); - - cmp.setString(TAG_INPUT_KEY, inputKey); - cmp.setString(TAG_OUTPUT_KEY, outputKey); - - cmp.setInteger(TAG_FORCE_CLIENT_BINDING_X, receiver == null ? 0 : ((TileEntity) receiver).xCoord); - cmp.setInteger(TAG_FORCE_CLIENT_BINDING_Y, receiver == null ? -1 : ((TileEntity) receiver).yCoord); - cmp.setInteger(TAG_FORCE_CLIENT_BINDING_Z, receiver == null ? 0 : ((TileEntity) receiver).zCoord); - - cmp.setBoolean(TAG_MAPMAKER_OVERRIDE, mapmakerOverride); - cmp.setInteger(TAG_FORCED_COLOR, mmForcedColor); - cmp.setInteger(TAG_FORCED_MANA_PAYLOAD, mmForcedManaPayload); - cmp.setInteger(TAG_FORCED_TICKS_BEFORE_MANA_LOSS, mmForcedTicksBeforeManaLoss); - cmp.setFloat(TAG_FORCED_MANA_LOSS_PER_TICK, mmForcedManaLossPerTick); - cmp.setFloat(TAG_FORCED_GRAVITY, mmForcedGravity); - cmp.setFloat(TAG_FORCED_VELOCITY_MULTIPLIER, mmForcedVelocityMultiplier); - - requestsClientUpdate = false; - } - - @Override - public void readCustomNBT(NBTTagCompound cmp) { - super.readCustomNBT(cmp); - - if (cmp.getBoolean(TAG_HAS_IDENTITY)) { - long most = cmp.getLong(TAG_UUID_MOST); - long least = cmp.getLong(TAG_UUID_LEAST); - UUID identity = getIdentifierUnsafe(); - if (identity == null - || most != identity.getMostSignificantBits() - || least != identity.getLeastSignificantBits()) identity = new UUID(most, least); - } else getIdentifier(); - - mana = cmp.getInteger(TAG_MANA); - rotationX = cmp.getFloat(TAG_ROTATION_X); - rotationY = cmp.getFloat(TAG_ROTATION_Y); - requestsClientUpdate = cmp.getBoolean(TAG_REQUEST_UPDATE); - - if (cmp.hasKey(TAG_INPUT_KEY)) inputKey = cmp.getString(TAG_INPUT_KEY); - if (cmp.hasKey(TAG_OUTPUT_KEY)) inputKey = cmp.getString(TAG_OUTPUT_KEY); - - mapmakerOverride = cmp.getBoolean(TAG_MAPMAKER_OVERRIDE); - mmForcedColor = cmp.getInteger(TAG_FORCED_COLOR); - mmForcedManaPayload = cmp.getInteger(TAG_FORCED_MANA_PAYLOAD); - mmForcedTicksBeforeManaLoss = cmp.getInteger(TAG_FORCED_TICKS_BEFORE_MANA_LOSS); - mmForcedManaLossPerTick = cmp.getFloat(TAG_FORCED_MANA_LOSS_PER_TICK); - mmForcedGravity = cmp.getFloat(TAG_FORCED_GRAVITY); - mmForcedVelocityMultiplier = cmp.getFloat(TAG_FORCED_VELOCITY_MULTIPLIER); - - if (cmp.hasKey(TAG_KNOWN_MANA)) knownMana = cmp.getInteger(TAG_KNOWN_MANA); - if (cmp.hasKey(TAG_PADDING_COLOR)) paddingColor = cmp.getInteger(TAG_PADDING_COLOR); - if (cmp.hasKey(TAG_CAN_SHOOT_BURST)) canShootBurst = cmp.getBoolean(TAG_CAN_SHOOT_BURST); - - pingbackTicks = cmp.getInteger(TAG_PINGBACK_TICKS); - lastPingbackX = cmp.getDouble(TAG_LAST_PINGBACK_X); - lastPingbackY = cmp.getDouble(TAG_LAST_PINGBACK_Y); - lastPingbackZ = cmp.getDouble(TAG_LAST_PINGBACK_Z); - - if (requestsClientUpdate && worldObj != null) { - int x = cmp.getInteger(TAG_FORCE_CLIENT_BINDING_X); - int y = cmp.getInteger(TAG_FORCE_CLIENT_BINDING_Y); - int z = cmp.getInteger(TAG_FORCE_CLIENT_BINDING_Z); - if (y != -1) { - TileEntity tile = worldObj.getTileEntity(x, y, z); - if (tile instanceof IManaReceiver) receiver = (IManaReceiver) tile; - else receiver = null; - } else receiver = null; - } - - if (worldObj != null && worldObj.isRemote) hasReceivedInitialPacket = true; - } - - @Override - public boolean canRecieveManaFromBursts() { - return true; - } - - @Override - public int getCurrentMana() { - return mana; - } - - public void onWanded(EntityPlayer player, ItemStack wand) { - if (player == null) return; - - if (!player.isSneaking()) { - if (!worldObj.isRemote) { - NBTTagCompound nbttagcompound = new NBTTagCompound(); - writeCustomNBT(nbttagcompound); - nbttagcompound.setInteger(TAG_KNOWN_MANA, mana); - if (player instanceof EntityPlayerMP) - ((EntityPlayerMP) player) - .playerNetServerHandler.sendPacket( - new S35PacketUpdateTileEntity(xCoord, yCoord, zCoord, -999, nbttagcompound)); - } - worldObj.playSoundAtEntity(player, "botania:ding", 0.1F, 1F); - } else { - MovingObjectPosition pos = raytraceFromEntity(worldObj, player, true, 5); - if (pos != null && pos.hitVec != null && !worldObj.isRemote) { - double x = pos.hitVec.xCoord - xCoord - 0.5; - double y = pos.hitVec.yCoord - yCoord - 0.5; - double z = pos.hitVec.zCoord - zCoord - 0.5; - - if (pos.sideHit != 0 && pos.sideHit != 1) { - Vector3 clickVector = new Vector3(x, 0, z); - Vector3 relative = new Vector3(-0.5, 0, 0); - double angle = Math.acos(clickVector.dotProduct(relative) / (relative.mag() * clickVector.mag())) - * 180D - / Math.PI; - - rotationX = (float) angle + 180F; - if (clickVector.z < 0) rotationX = 360 - rotationX; - } - - double angle = y * 180; - rotationY = -(float) angle; - - checkForReceiver(); - requestsClientUpdate = true; - VanillaPacketDispatcher.dispatchTEToNearbyPlayers(worldObj, xCoord, yCoord, zCoord); - } - } - } - - private boolean needsNewBurstSimulation() { - if (worldObj.isRemote && !hasReceivedInitialPacket) return false; - - if (lastTentativeBurst == null) return true; - - for (PositionProperties props : lastTentativeBurst) - if (!props.contentsEqual(worldObj)) { - invalidTentativeBurst = props.invalid; - return !invalidTentativeBurst; - } - - return false; - } - - public void tryShootBurst() { - if ((receiver != null || isRedstone()) && !invalidTentativeBurst) { - if (canShootBurst && (isRedstone() || receiver.canRecieveManaFromBursts() && !receiver.isFull())) { - EntityManaBurst burst = getBurst(false); - if (burst != null) { - if (!worldObj.isRemote) { - mana -= burst.getStartingMana(); - burst.setShooterUUID(getIdentifier()); - worldObj.spawnEntityInWorld(burst); - burst.ping(); - if (!ConfigHandler.silentSpreaders) - worldObj.playSoundEffect( - xCoord, - yCoord, - zCoord, - "botania:spreaderFire", - 0.05F * (paddingColor != -1 ? 0.2F : 1F), - 0.7F + 0.3F * (float) Math.random()); - } - } - } - } - } - - public boolean isRedstone() { - return worldObj == null ? staticRedstone : getBlockMetadata() == 1; - } - - public boolean isDreamwood() { - return worldObj == null ? staticDreamwood : getBlockMetadata() == 2 || getBlockMetadata() == 3; - } - - public boolean isULTRA_SPREADER() { - return worldObj == null ? staticUltra : getBlockMetadata() == 3; - } - - public void checkForReceiver() { - ItemStack stack = getStackInSlot(0); - ILensControl control = getLensController(stack); - if (control != null && !control.allowBurstShooting(stack, this, false)) return; - - EntityManaBurst fakeBurst = getBurst(true); - fakeBurst.setScanBeam(); - TileEntity receiver = fakeBurst.getCollidedTile(true); - - if (receiver != null && receiver instanceof IManaReceiver) this.receiver = (IManaReceiver) receiver; - else this.receiver = null; - lastTentativeBurst = fakeBurst.propsList; - } - - public EntityManaBurst getBurst(boolean fake) { - EntityManaBurst burst = new EntityManaBurst(this, fake); - - boolean dreamwood = isDreamwood(); - boolean ultra = isULTRA_SPREADER(); - int maxMana = ultra ? 640 : dreamwood ? 240 : 160; - int color = isRedstone() ? 0xFF2020 : dreamwood ? 0xFF45C4 : 0x20FF20; - int ticksBeforeManaLoss = ultra ? 120 : dreamwood ? 80 : 60; - float manaLossPerTick = ultra ? 20F : 4F; - float motionModifier = ultra ? 2F : dreamwood ? 1.25F : 1F; - float gravity = 0F; - BurstProperties props = - new BurstProperties(maxMana, ticksBeforeManaLoss, manaLossPerTick, gravity, motionModifier, color); - - ItemStack lens = getStackInSlot(0); - if (lens != null && lens.getItem() instanceof ILensEffect) ((ILensEffect) lens.getItem()).apply(lens, props); - - burst.setSourceLens(lens); - if (getCurrentMana() >= props.maxMana || fake) { - if (mapmakerOverride) { - burst.setColor(mmForcedColor); - burst.setMana(mmForcedManaPayload); - burst.setStartingMana(mmForcedManaPayload); - burst.setMinManaLoss(mmForcedTicksBeforeManaLoss); - burst.setManaLossPerTick(mmForcedManaLossPerTick); - burst.setGravity(mmForcedGravity); - burst.setMotion( - burst.motionX * mmForcedVelocityMultiplier, - burst.motionY * mmForcedVelocityMultiplier, - burst.motionZ * mmForcedVelocityMultiplier); - } else { - burst.setColor(props.color); - burst.setMana(props.maxMana); - burst.setStartingMana(props.maxMana); - burst.setMinManaLoss(props.ticksBeforeManaLoss); - burst.setManaLossPerTick(props.manaLossPerTick); - burst.setGravity(props.gravity); - burst.setMotion( - burst.motionX * props.motionModifier, - burst.motionY * props.motionModifier, - burst.motionZ * props.motionModifier); - } - - return burst; - } - return null; - } - - public ILensControl getLensController(ItemStack stack) { - if (stack != null && stack.getItem() instanceof ILensControl) { - ILensControl control = (ILensControl) stack.getItem(); - if (control.isControlLens(stack)) return control; - } - - return null; - } - - public static MovingObjectPosition raytraceFromEntity(World world, Entity player, boolean par3, double range) { - float f = 1.0F; - float f1 = player.prevRotationPitch + (player.rotationPitch - player.prevRotationPitch) * f; - float f2 = player.prevRotationYaw + (player.rotationYaw - player.prevRotationYaw) * f; - double d0 = player.prevPosX + (player.posX - player.prevPosX) * f; - double d1 = player.prevPosY + (player.posY - player.prevPosY) * f; - if (!world.isRemote && player instanceof EntityPlayer) d1 += 1.62D; - double d2 = player.prevPosZ + (player.posZ - player.prevPosZ) * f; - Vec3 vec3 = Vec3.createVectorHelper(d0, d1, d2); - float f3 = MathHelper.cos(-f2 * 0.017453292F - (float) Math.PI); - float f4 = MathHelper.sin(-f2 * 0.017453292F - (float) Math.PI); - float f5 = -MathHelper.cos(-f1 * 0.017453292F); - float f6 = MathHelper.sin(-f1 * 0.017453292F); - float f7 = f4 * f5; - float f8 = f3 * f5; - double d3 = range; - if (player instanceof EntityPlayerMP) - d3 = ((EntityPlayerMP) player).theItemInWorldManager.getBlockReachDistance(); - Vec3 vec31 = vec3.addVector(f7 * d3, f6 * d3, f8 * d3); - return world.func_147447_a(vec3, vec31, par3, !par3, par3); - } - - public void renderHUD(Minecraft mc, ScaledResolution res) { - String name = StatCollector.translateToLocal(new ItemStack(ModBlocks.spreader, 1, getBlockMetadata()) - .getUnlocalizedName() - .replaceAll("tile.", "tile." + LibResources.PREFIX_MOD) - + ".name"); - int color = isRedstone() ? 0xFF0000 : isDreamwood() ? 0xFF00AE : 0x00FF00; - HUDHandler.drawSimpleManaHUD(color, knownMana, getMaxMana(), name, res); - - ItemStack lens = getStackInSlot(0); - if (lens != null) { - GL11.glEnable(GL11.GL_BLEND); - GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); - String lensName = lens.getDisplayName(); - int width = 16 + mc.fontRenderer.getStringWidth(lensName) / 2; - int x = res.getScaledWidth() / 2 - width; - int y = res.getScaledHeight() / 2 + 50; - - mc.fontRenderer.drawStringWithShadow(lensName, x + 20, y + 5, color); - RenderHelper.enableGUIStandardItemLighting(); - RenderItem.getInstance().renderItemAndEffectIntoGUI(mc.fontRenderer, mc.renderEngine, lens, x, y); - RenderHelper.disableStandardItemLighting(); - GL11.glDisable(GL11.GL_LIGHTING); - GL11.glDisable(GL11.GL_BLEND); - } - - if (receiver != null) { - TileEntity receiverTile = (TileEntity) receiver; - ItemStack recieverStack = new ItemStack( - worldObj.getBlock(receiverTile.xCoord, receiverTile.yCoord, receiverTile.zCoord), - 1, - receiverTile.getBlockMetadata()); - GL11.glEnable(GL11.GL_BLEND); - GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); - if (recieverStack != null && recieverStack.getItem() != null) { - String stackName = recieverStack.getDisplayName(); - int width = 16 + mc.fontRenderer.getStringWidth(stackName) / 2; - int x = res.getScaledWidth() / 2 - width; - int y = res.getScaledHeight() / 2 + 30; - - mc.fontRenderer.drawStringWithShadow(stackName, x + 20, y + 5, color); - RenderHelper.enableGUIStandardItemLighting(); - RenderItem.getInstance() - .renderItemAndEffectIntoGUI(mc.fontRenderer, mc.renderEngine, recieverStack, x, y); - RenderHelper.disableStandardItemLighting(); - } - - GL11.glDisable(GL11.GL_LIGHTING); - GL11.glDisable(GL11.GL_BLEND); - } - - GL11.glColor4f(1F, 1F, 1F, 1F); - } - - @Override - public void onClientDisplayTick() { - if (worldObj != null) { - EntityManaBurst burst = getBurst(true); - burst.getCollidedTile(false); - } - } - - @Override - public float getManaYieldMultiplier(IManaBurst burst) { - return burst.getMana() < 16 ? 0F : 0.95F; - } - - @Override - public int getSizeInventory() { - return 1; - } - - @Override - public String getInventoryName() { - return LibBlockNames.SPREADER; - } - - @Override - public int getInventoryStackLimit() { - return 1; - } - - @Override - public boolean isItemValidForSlot(int i, ItemStack itemstack) { - return itemstack.getItem() instanceof ILens; - } - - @Override - public void markDirty() { - checkForReceiver(); - VanillaPacketDispatcher.dispatchTEToNearbyPlayers(worldObj, xCoord, yCoord, zCoord); - } - - @Override - public ChunkCoordinates getBinding() { - if (receiver == null) return null; - - TileEntity tile = (TileEntity) receiver; - return new ChunkCoordinates(tile.xCoord, tile.yCoord, tile.zCoord); - } - - @Override - public int getMaxMana() { - return isULTRA_SPREADER() ? ULTRA_MAX_MANA : MAX_MANA; - } - - @Override - public String getInputKey() { - return inputKey; - } - - @Override - public String getOutputKey() { - return outputKey; - } - - @Override - public boolean canSelect(EntityPlayer player, ItemStack wand, int x, int y, int z, int side) { - return true; - } - - @Override - public boolean bindTo(EntityPlayer player, ItemStack wand, int x, int y, int z, int side) { - Vector3 thisVec = Vector3.fromTileEntityCenter(this); - Vector3 blockVec = new Vector3(x + 0.5, y + 0.5, z + 0.5); - - AxisAlignedBB axis = - player.worldObj.getBlock(x, y, z).getCollisionBoundingBoxFromPool(player.worldObj, x, y, z); - if (axis == null) axis = AxisAlignedBB.getBoundingBox(x, y, z, x + 1, y + 1, z + 1); - - if (!blockVec.isInside(axis)) - blockVec = new Vector3( - axis.minX + (axis.maxX - axis.minX) / 2, - axis.minY + (axis.maxY - axis.minY) / 2, - axis.minZ + (axis.maxZ - axis.minZ) / 2); - - Vector3 diffVec = blockVec.copy().sub(thisVec); - Vector3 diffVec2D = new Vector3(diffVec.x, diffVec.z, 0); - Vector3 rotVec = new Vector3(0, 1, 0); - double angle = rotVec.angle(diffVec2D) / Math.PI * 180.0; - - if (blockVec.x < thisVec.x) angle = -angle; - - rotationX = (float) angle + 90; - - rotVec = new Vector3(diffVec.x, 0, diffVec.z); - angle = diffVec.angle(rotVec) * 180F / Math.PI; - if (blockVec.y < thisVec.y) angle = -angle; - rotationY = (float) angle; - - checkForReceiver(); - return true; - } - - @Override - public void markDispatchable() { - // NO-OP - } - - @Override - public float getRotationX() { - return rotationX; - } - - @Override - public float getRotationY() { - return rotationY; - } - - @Override - public void setRotationX(float rot) { - rotationX = rot; - } - - @Override - public void setRotationY(float rot) { - rotationY = rot; - } - - @Override - public void commitRedirection() { - checkForReceiver(); - } - - @Override - public void setCanShoot(boolean canShoot) { - canShootBurst = canShoot; - } - - @Override - public int getBurstParticleTick() { - return burstParticleTick; - } - - @Override - public void setBurstParticleTick(int i) { - burstParticleTick = i; - } - - @Override - public int getLastBurstDeathTick() { - return lastBurstDeathTick; - } - - @Override - public void setLastBurstDeathTick(int i) { - lastBurstDeathTick = i; - } - - @Override - public void pingback(IManaBurst burst, UUID expectedIdentity) { - if (getIdentifier().equals(expectedIdentity)) { - pingbackTicks = TICKS_ALLOWED_WITHOUT_PINGBACK; - Entity e = (Entity) burst; - lastPingbackX = e.posX; - lastPingbackY = e.posY; - lastPingbackZ = e.posZ; - setCanShoot(false); - } - } - - @Override - public UUID getIdentifier() { - if (identity == null) identity = UUID.randomUUID(); - return identity; - } - - public UUID getIdentifierUnsafe() { - return identity; - } +public class TileSpreader extends TileSimpleInventory implements IManaCollector, IWandBindable, IKeyLocked, IThrottledPacket, IManaSpreader, IRedirectable { + + private static final int MAX_MANA = 1000; + private static final int ULTRA_MAX_MANA = 6400; + private static final int TICKS_ALLOWED_WITHOUT_PINGBACK = 20; + private static final double PINGBACK_EXPIRED_SEARCH_DISTANCE = 0.5; + + private static final String TAG_HAS_IDENTITY = "hasIdentity"; + private static final String TAG_UUID_MOST = "uuidMost"; + private static final String TAG_UUID_LEAST = "uuidLeast"; + private static final String TAG_MANA = "mana"; + private static final String TAG_KNOWN_MANA = "knownMana"; + private static final String TAG_REQUEST_UPDATE = "requestUpdate"; + private static final String TAG_ROTATION_X = "rotationX"; + private static final String TAG_ROTATION_Y = "rotationY"; + private static final String TAG_PADDING_COLOR = "paddingColor"; + private static final String TAG_CAN_SHOOT_BURST = "canShootBurst"; + private static final String TAG_PINGBACK_TICKS = "pingbackTicks"; + private static final String TAG_LAST_PINGBACK_X = "lastPingbackX"; + private static final String TAG_LAST_PINGBACK_Y = "lastPingbackY"; + private static final String TAG_LAST_PINGBACK_Z = "lastPingbackZ"; + + private static final String TAG_FORCE_CLIENT_BINDING_X = "forceClientBindingX"; + private static final String TAG_FORCE_CLIENT_BINDING_Y = "forceClientBindingY"; + private static final String TAG_FORCE_CLIENT_BINDING_Z = "forceClientBindingZ"; + + // Map Maker Tags + + private static final String TAG_INPUT_KEY = "inputKey"; + private static final String TAG_OUTPUT_KEY = "outputKey"; + + private static final String TAG_MAPMAKER_OVERRIDE = "mapmakerOverrideEnabled"; + private static final String TAG_FORCED_COLOR = "mmForcedColor"; + private static final String TAG_FORCED_MANA_PAYLOAD = "mmForcedManaPayload"; + private static final String TAG_FORCED_TICKS_BEFORE_MANA_LOSS = "mmForcedTicksBeforeManaLoss"; + private static final String TAG_FORCED_MANA_LOSS_PER_TICK = "mmForcedManaLossPerTick"; + private static final String TAG_FORCED_GRAVITY = "mmForcedGravity"; + private static final String TAG_FORCED_VELOCITY_MULTIPLIER = "mmForcedVelocityMultiplier"; + + boolean mapmakerOverride = false; + int mmForcedColor = 0x20FF20; + int mmForcedManaPayload = 160; + int mmForcedTicksBeforeManaLoss = 60; + float mmForcedManaLossPerTick = 4F; + float mmForcedGravity = 0F; + float mmForcedVelocityMultiplier = 1F; + + String inputKey = ""; + String outputKey = ""; + + // End Map Maker Tags + + public static boolean staticRedstone = false; + public static boolean staticDreamwood = false; + public static boolean staticUltra = false; + + UUID identity; + + int mana; + int knownMana = -1; + public float rotationX, rotationY; + public int paddingColor = -1; + + boolean requestsClientUpdate = false; + boolean hasReceivedInitialPacket = false; + + IManaReceiver receiver = null; + IManaReceiver receiverLastTick = null; + + boolean redstoneLastTick = true; + public boolean canShootBurst = true; + public int lastBurstDeathTick = -1; + public int burstParticleTick = 0; + + public int pingbackTicks = 0; + public double lastPingbackX = 0; + public double lastPingbackY = -1; + public double lastPingbackZ = 0; + + List lastTentativeBurst; + boolean invalidTentativeBurst = false; + + @Override + public boolean isFull() { + return mana >= getMaxMana(); + } + + @Override + public void recieveMana(int mana) { + this.mana = Math.min(this.mana + mana, getMaxMana()); + } + + @Override + public void invalidate() { + super.invalidate(); + ManaNetworkEvent.removeCollector(this); + } + + @Override + public void onChunkUnload() { + super.onChunkUnload(); + invalidate(); + } + + @Override + public void updateEntity() { + boolean inNetwork = ManaNetworkHandler.instance.isCollectorIn(this); + boolean wasInNetwork = inNetwork; + if(!inNetwork && !isInvalid()) { + ManaNetworkEvent.addCollector(this); + inNetwork = true; + } + + boolean redstone = false; + + for(ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS) { + TileEntity tileAt = worldObj.getTileEntity(xCoord + dir.offsetX, yCoord + dir.offsetY, zCoord + dir.offsetZ); + if(tileAt instanceof IManaPool) { + IManaPool pool = (IManaPool) tileAt; + if(wasInNetwork && (pool != receiver || isRedstone())) { + if(pool instanceof IKeyLocked && !((IKeyLocked) pool).getOutputKey().equals(getInputKey())) + continue; + + int manaInPool = pool.getCurrentMana(); + if(manaInPool > 0 && !isFull()) { + int manaMissing = getMaxMana() - mana; + int manaToRemove = Math.min(manaInPool, manaMissing); + pool.recieveMana(-manaToRemove); + recieveMana(manaToRemove); + } + } + } + + int redstoneSide = worldObj.getIndirectPowerLevelTo(xCoord + dir.offsetX, yCoord + dir.offsetY, zCoord + dir.offsetZ, dir.ordinal()); + if(redstoneSide > 0) + redstone = true; + } + + if(needsNewBurstSimulation()) + checkForReceiver(); + + if(!canShootBurst) + if(pingbackTicks <= 0) { + double x = lastPingbackX; + double y = lastPingbackY; + double z = lastPingbackZ; + AxisAlignedBB aabb = AxisAlignedBB.getBoundingBox(x, y, z, x, y, z).expand(PINGBACK_EXPIRED_SEARCH_DISTANCE, PINGBACK_EXPIRED_SEARCH_DISTANCE, PINGBACK_EXPIRED_SEARCH_DISTANCE); + List bursts = worldObj.getEntitiesWithinAABB(IManaBurst.class, aabb); + IManaBurst found = null; + UUID identity = getIdentifier(); + for(IManaBurst burst : bursts) + if(burst != null && identity.equals(burst.getShooterUIID())) { + found = burst; + break; + } + + if(found != null) + found.ping(); + else setCanShoot(true); + } else pingbackTicks--; + + boolean shouldShoot = !redstone; + + boolean isredstone = isRedstone(); + if(isredstone) + shouldShoot = redstone && !redstoneLastTick; + + if(shouldShoot && receiver != null && receiver instanceof IKeyLocked) + shouldShoot = ((IKeyLocked) receiver).getInputKey().equals(getOutputKey()); + + ItemStack lens = getStackInSlot(0); + ILensControl control = getLensController(lens); + if(control != null) { + if(isredstone) { + if(shouldShoot) + control.onControlledSpreaderPulse(lens, this, redstone); + } else control.onControlledSpreaderTick(lens, this, redstone); + + shouldShoot &= control.allowBurstShooting(lens, this, redstone); + } + + if(shouldShoot) + tryShootBurst(); + + if(receiverLastTick != receiver && !worldObj.isRemote) { + requestsClientUpdate = true; + VanillaPacketDispatcher.dispatchTEToNearbyPlayers(worldObj, xCoord, yCoord, zCoord); + } + + redstoneLastTick = redstone; + receiverLastTick = receiver; + } + + @Override + public void writeCustomNBT(NBTTagCompound cmp) { + super.writeCustomNBT(cmp); + + UUID identity = getIdentifier(); + cmp.setBoolean(TAG_HAS_IDENTITY, true); + cmp.setLong(TAG_UUID_MOST, identity.getMostSignificantBits()); + cmp.setLong(TAG_UUID_LEAST, identity.getLeastSignificantBits()); + + cmp.setInteger(TAG_MANA, mana); + cmp.setFloat(TAG_ROTATION_X, rotationX); + cmp.setFloat(TAG_ROTATION_Y, rotationY); + cmp.setBoolean(TAG_REQUEST_UPDATE, requestsClientUpdate); + cmp.setInteger(TAG_PADDING_COLOR, paddingColor); + cmp.setBoolean(TAG_CAN_SHOOT_BURST, canShootBurst); + + cmp.setInteger(TAG_PINGBACK_TICKS, pingbackTicks); + cmp.setDouble(TAG_LAST_PINGBACK_X, lastPingbackX); + cmp.setDouble(TAG_LAST_PINGBACK_Y, lastPingbackY); + cmp.setDouble(TAG_LAST_PINGBACK_Z, lastPingbackZ); + + cmp.setString(TAG_INPUT_KEY, inputKey); + cmp.setString(TAG_OUTPUT_KEY, outputKey); + + cmp.setInteger(TAG_FORCE_CLIENT_BINDING_X, receiver == null ? 0 : ((TileEntity) receiver).xCoord); + cmp.setInteger(TAG_FORCE_CLIENT_BINDING_Y, receiver == null ? -1 : ((TileEntity) receiver).yCoord); + cmp.setInteger(TAG_FORCE_CLIENT_BINDING_Z, receiver == null ? 0 : ((TileEntity) receiver).zCoord); + + cmp.setBoolean(TAG_MAPMAKER_OVERRIDE, mapmakerOverride); + cmp.setInteger(TAG_FORCED_COLOR, mmForcedColor); + cmp.setInteger(TAG_FORCED_MANA_PAYLOAD, mmForcedManaPayload); + cmp.setInteger(TAG_FORCED_TICKS_BEFORE_MANA_LOSS, mmForcedTicksBeforeManaLoss); + cmp.setFloat(TAG_FORCED_MANA_LOSS_PER_TICK, mmForcedManaLossPerTick); + cmp.setFloat(TAG_FORCED_GRAVITY, mmForcedGravity); + cmp.setFloat(TAG_FORCED_VELOCITY_MULTIPLIER, mmForcedVelocityMultiplier); + + requestsClientUpdate = false; + } + + @Override + public void readCustomNBT(NBTTagCompound cmp) { + super.readCustomNBT(cmp); + + if(cmp.getBoolean(TAG_HAS_IDENTITY)) { + long most = cmp.getLong(TAG_UUID_MOST); + long least = cmp.getLong(TAG_UUID_LEAST); + UUID identity = getIdentifierUnsafe(); + if(identity == null || most != identity.getMostSignificantBits() || least != identity.getLeastSignificantBits()) + identity = new UUID(most, least); + } else getIdentifier(); + + mana = cmp.getInteger(TAG_MANA); + rotationX = cmp.getFloat(TAG_ROTATION_X); + rotationY = cmp.getFloat(TAG_ROTATION_Y); + requestsClientUpdate = cmp.getBoolean(TAG_REQUEST_UPDATE); + + if(cmp.hasKey(TAG_INPUT_KEY)) + inputKey = cmp.getString(TAG_INPUT_KEY); + if(cmp.hasKey(TAG_OUTPUT_KEY)) + inputKey = cmp.getString(TAG_OUTPUT_KEY); + + mapmakerOverride = cmp.getBoolean(TAG_MAPMAKER_OVERRIDE); + mmForcedColor = cmp.getInteger(TAG_FORCED_COLOR); + mmForcedManaPayload = cmp.getInteger(TAG_FORCED_MANA_PAYLOAD); + mmForcedTicksBeforeManaLoss = cmp.getInteger(TAG_FORCED_TICKS_BEFORE_MANA_LOSS); + mmForcedManaLossPerTick = cmp.getFloat(TAG_FORCED_MANA_LOSS_PER_TICK); + mmForcedGravity = cmp.getFloat(TAG_FORCED_GRAVITY); + mmForcedVelocityMultiplier = cmp.getFloat(TAG_FORCED_VELOCITY_MULTIPLIER); + + if(cmp.hasKey(TAG_KNOWN_MANA)) + knownMana = cmp.getInteger(TAG_KNOWN_MANA); + if(cmp.hasKey(TAG_PADDING_COLOR)) + paddingColor = cmp.getInteger(TAG_PADDING_COLOR); + if(cmp.hasKey(TAG_CAN_SHOOT_BURST)) + canShootBurst = cmp.getBoolean(TAG_CAN_SHOOT_BURST); + + pingbackTicks = cmp.getInteger(TAG_PINGBACK_TICKS); + lastPingbackX = cmp.getDouble(TAG_LAST_PINGBACK_X); + lastPingbackY = cmp.getDouble(TAG_LAST_PINGBACK_Y); + lastPingbackZ = cmp.getDouble(TAG_LAST_PINGBACK_Z); + + if(requestsClientUpdate && worldObj != null) { + int x = cmp.getInteger(TAG_FORCE_CLIENT_BINDING_X); + int y = cmp.getInteger(TAG_FORCE_CLIENT_BINDING_Y); + int z = cmp.getInteger(TAG_FORCE_CLIENT_BINDING_Z); + if(y != -1) { + TileEntity tile = worldObj.getTileEntity(x, y, z); + if(tile instanceof IManaReceiver) + receiver = (IManaReceiver) tile; + else receiver = null; + } else receiver = null; + } + + if(worldObj != null && worldObj.isRemote) + hasReceivedInitialPacket = true; + } + + @Override + public boolean canRecieveManaFromBursts() { + return true; + } + + @Override + public int getCurrentMana() { + return mana; + } + + public void onWanded(EntityPlayer player, ItemStack wand) { + if(player == null) + return; + + if(!player.isSneaking()) { + if(!worldObj.isRemote) { + NBTTagCompound nbttagcompound = new NBTTagCompound(); + writeCustomNBT(nbttagcompound); + nbttagcompound.setInteger(TAG_KNOWN_MANA, mana); + if(player instanceof EntityPlayerMP) + ((EntityPlayerMP) player).playerNetServerHandler.sendPacket(new S35PacketUpdateTileEntity(xCoord, yCoord, zCoord, -999, nbttagcompound)); + } + worldObj.playSoundAtEntity(player, "botania:ding", 0.1F, 1F); + } else { + MovingObjectPosition pos = raytraceFromEntity(worldObj, player, true, 5); + if(pos != null && pos.hitVec != null && !worldObj.isRemote) { + double x = pos.hitVec.xCoord - xCoord - 0.5; + double y = pos.hitVec.yCoord - yCoord - 0.5; + double z = pos.hitVec.zCoord - zCoord - 0.5; + + if(pos.sideHit != 0 && pos.sideHit != 1) { + Vector3 clickVector = new Vector3(x, 0, z); + Vector3 relative = new Vector3(-0.5, 0, 0); + double angle = Math.acos(clickVector.dotProduct(relative) / (relative.mag() * clickVector.mag())) * 180D / Math.PI; + + rotationX = (float) angle + 180F; + if(clickVector.z < 0) + rotationX = 360 - rotationX; + } + + double angle = y * 180; + rotationY = -(float) angle; + + checkForReceiver(); + requestsClientUpdate = true; + VanillaPacketDispatcher.dispatchTEToNearbyPlayers(worldObj, xCoord, yCoord, zCoord); + } + } + } + + private boolean needsNewBurstSimulation() { + if(worldObj.isRemote && !hasReceivedInitialPacket) + return false; + + if(lastTentativeBurst == null) + return true; + + for(PositionProperties props : lastTentativeBurst) + if(!props.contentsEqual(worldObj)) { + invalidTentativeBurst = props.invalid; + return !invalidTentativeBurst; + } + + return false; + } + + public void tryShootBurst() { + if((receiver != null || isRedstone()) && !invalidTentativeBurst) { + if(canShootBurst && (isRedstone() || receiver.canRecieveManaFromBursts() && !receiver.isFull())) { + EntityManaBurst burst = getBurst(false); + if(burst != null) { + if(!worldObj.isRemote) { + mana -= burst.getStartingMana(); + burst.setShooterUUID(getIdentifier()); + worldObj.spawnEntityInWorld(burst); + burst.ping(); + if(!ConfigHandler.silentSpreaders) + worldObj.playSoundEffect(xCoord, yCoord, zCoord, "botania:spreaderFire", 0.05F * (paddingColor != -1 ? 0.2F : 1F), 0.7F + 0.3F * (float) Math.random()); + } + } + } + } + } + + public boolean isRedstone() { + return worldObj == null ? staticRedstone : getBlockMetadata() == 1; + } + + public boolean isDreamwood() { + return worldObj == null ? staticDreamwood : getBlockMetadata() == 2 || getBlockMetadata() == 3; + } + + public boolean isULTRA_SPREADER() { + return worldObj == null ? staticUltra : getBlockMetadata() == 3; + } + + public void checkForReceiver() { + ItemStack stack = getStackInSlot(0); + ILensControl control = getLensController(stack); + if(control != null && !control.allowBurstShooting(stack, this, false)) + return; + + EntityManaBurst fakeBurst = getBurst(true); + fakeBurst.setScanBeam(); + TileEntity receiver = fakeBurst.getCollidedTile(true); + + if(receiver != null && receiver instanceof IManaReceiver) + this.receiver = (IManaReceiver) receiver; + else this.receiver = null; + lastTentativeBurst = fakeBurst.propsList; + } + + public EntityManaBurst getBurst(boolean fake) { + EntityManaBurst burst = new EntityManaBurst(this, fake); + + boolean dreamwood = isDreamwood(); + boolean ultra = isULTRA_SPREADER(); + int maxMana = ultra ? 640 : dreamwood ? 240 : 160; + int color = isRedstone() ? 0xFF2020 : dreamwood ? 0xFF45C4 : 0x20FF20; + int ticksBeforeManaLoss = ultra ? 120 : dreamwood ? 80 : 60; + float manaLossPerTick = ultra ? 20F : 4F; + float motionModifier = ultra ? 2F : dreamwood ? 1.25F : 1F; + float gravity = 0F; + BurstProperties props = new BurstProperties(maxMana, ticksBeforeManaLoss, manaLossPerTick, gravity, motionModifier, color); + + ItemStack lens = getStackInSlot(0); + if(lens != null && lens.getItem() instanceof ILensEffect) + ((ILensEffect) lens.getItem()).apply(lens, props); + + burst.setSourceLens(lens); + if(getCurrentMana() >= props.maxMana || fake) { + if(mapmakerOverride) { + burst.setColor(mmForcedColor); + burst.setMana(mmForcedManaPayload); + burst.setStartingMana(mmForcedManaPayload); + burst.setMinManaLoss(mmForcedTicksBeforeManaLoss); + burst.setManaLossPerTick(mmForcedManaLossPerTick); + burst.setGravity(mmForcedGravity); + burst.setMotion(burst.motionX * mmForcedVelocityMultiplier, burst.motionY * mmForcedVelocityMultiplier, burst.motionZ * mmForcedVelocityMultiplier); + } else { + burst.setColor(props.color); + burst.setMana(props.maxMana); + burst.setStartingMana(props.maxMana); + burst.setMinManaLoss(props.ticksBeforeManaLoss); + burst.setManaLossPerTick(props.manaLossPerTick); + burst.setGravity(props.gravity); + burst.setMotion(burst.motionX * props.motionModifier, burst.motionY * props.motionModifier, burst.motionZ * props.motionModifier); + } + + return burst; + } + return null; + } + + public ILensControl getLensController(ItemStack stack) { + if(stack != null && stack.getItem() instanceof ILensControl) { + ILensControl control = (ILensControl) stack.getItem(); + if(control.isControlLens(stack)) + return control; + } + + return null; + } + + public static MovingObjectPosition raytraceFromEntity(World world, Entity player, boolean par3, double range) { + float f = 1.0F; + float f1 = player.prevRotationPitch + (player.rotationPitch - player.prevRotationPitch) * f; + float f2 = player.prevRotationYaw + (player.rotationYaw - player.prevRotationYaw) * f; + double d0 = player.prevPosX + (player.posX - player.prevPosX) * f; + double d1 = player.prevPosY + (player.posY - player.prevPosY) * f; + if (!world.isRemote && player instanceof EntityPlayer) + d1 += 1.62D; + double d2 = player.prevPosZ + (player.posZ - player.prevPosZ) * f; + Vec3 vec3 = Vec3.createVectorHelper(d0, d1, d2); + float f3 = MathHelper.cos(-f2 * 0.017453292F - (float) Math.PI); + float f4 = MathHelper.sin(-f2 * 0.017453292F - (float) Math.PI); + float f5 = -MathHelper.cos(-f1 * 0.017453292F); + float f6 = MathHelper.sin(-f1 * 0.017453292F); + float f7 = f4 * f5; + float f8 = f3 * f5; + double d3 = range; + if (player instanceof EntityPlayerMP) + d3 = ((EntityPlayerMP) player).theItemInWorldManager.getBlockReachDistance(); + Vec3 vec31 = vec3.addVector(f7 * d3, f6 * d3, f8 * d3); + return world.func_147447_a(vec3, vec31, par3, !par3, par3); + } + + public void renderHUD(Minecraft mc, ScaledResolution res) { + String name = StatCollector.translateToLocal(new ItemStack(ModBlocks.spreader, 1, getBlockMetadata()).getUnlocalizedName().replaceAll("tile.", "tile." + LibResources.PREFIX_MOD) + ".name"); + int color = isRedstone() ? 0xFF0000 : isDreamwood() ? 0xFF00AE : 0x00FF00; + HUDHandler.drawSimpleManaHUD(color, knownMana, getMaxMana(), name, res); + + ItemStack lens = getStackInSlot(0); + if(lens != null) { + GL11.glEnable(GL11.GL_BLEND); + GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); + String lensName = lens.getDisplayName(); + int width = 16 + mc.fontRenderer.getStringWidth(lensName) / 2; + int x = res.getScaledWidth() / 2 - width; + int y = res.getScaledHeight() / 2 + 50; + + mc.fontRenderer.drawStringWithShadow(lensName, x + 20, y + 5, color); + RenderHelper.enableGUIStandardItemLighting(); + RenderItem.getInstance().renderItemAndEffectIntoGUI(mc.fontRenderer, mc.renderEngine, lens, x, y); + RenderHelper.disableStandardItemLighting(); + GL11.glDisable(GL11.GL_LIGHTING); + GL11.glDisable(GL11.GL_BLEND); + } + + if(receiver != null) { + TileEntity receiverTile = (TileEntity) receiver; + ItemStack recieverStack = new ItemStack(worldObj.getBlock(receiverTile.xCoord, receiverTile.yCoord, receiverTile.zCoord), 1, receiverTile.getBlockMetadata()); + GL11.glEnable(GL11.GL_BLEND); + GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); + if(recieverStack != null && recieverStack.getItem() != null) { + String stackName = recieverStack.getDisplayName(); + int width = 16 + mc.fontRenderer.getStringWidth(stackName) / 2; + int x = res.getScaledWidth() / 2 - width; + int y = res.getScaledHeight() / 2 + 30; + + mc.fontRenderer.drawStringWithShadow(stackName, x + 20, y + 5, color); + RenderHelper.enableGUIStandardItemLighting(); + RenderItem.getInstance().renderItemAndEffectIntoGUI(mc.fontRenderer, mc.renderEngine, recieverStack, x, y); + RenderHelper.disableStandardItemLighting(); + } + + GL11.glDisable(GL11.GL_LIGHTING); + GL11.glDisable(GL11.GL_BLEND); + } + + GL11.glColor4f(1F, 1F, 1F, 1F); + } + + @Override + public void onClientDisplayTick() { + if(worldObj != null) { + EntityManaBurst burst = getBurst(true); + burst.getCollidedTile(false); + } + } + + @Override + public float getManaYieldMultiplier(IManaBurst burst) { + return burst.getMana() < 16 ? 0F : 0.95F; + } + + @Override + public int getSizeInventory() { + return 1; + } + + @Override + public String getInventoryName() { + return LibBlockNames.SPREADER; + } + + @Override + public int getInventoryStackLimit() { + return 1; + } + + @Override + public boolean isItemValidForSlot(int i, ItemStack itemstack) { + return itemstack.getItem() instanceof ILens; + } + + @Override + public void markDirty() { + checkForReceiver(); + VanillaPacketDispatcher.dispatchTEToNearbyPlayers(worldObj, xCoord, yCoord, zCoord); + } + + @Override + public ChunkCoordinates getBinding() { + if(receiver == null) + return null; + + TileEntity tile = (TileEntity) receiver; + return new ChunkCoordinates(tile.xCoord, tile.yCoord, tile.zCoord); + } + + @Override + public int getMaxMana() { + return isULTRA_SPREADER() ? ULTRA_MAX_MANA : MAX_MANA; + } + + @Override + public String getInputKey() { + return inputKey; + } + + @Override + public String getOutputKey() { + return outputKey; + } + + @Override + public boolean canSelect(EntityPlayer player, ItemStack wand, int x, int y, int z, int side) { + return true; + } + + @Override + public boolean bindTo(EntityPlayer player, ItemStack wand, int x, int y, int z, int side) { + Vector3 thisVec = Vector3.fromTileEntityCenter(this); + Vector3 blockVec = new Vector3(x + 0.5, y + 0.5, z + 0.5); + + AxisAlignedBB axis = player.worldObj.getBlock(x, y, z).getCollisionBoundingBoxFromPool(player.worldObj, x, y, z); + if(axis == null) + axis = AxisAlignedBB.getBoundingBox(x, y, z, x + 1, y + 1, z + 1); + + if(!blockVec.isInside(axis)) + blockVec = new Vector3(axis.minX + (axis.maxX - axis.minX) / 2, axis.minY + (axis.maxY - axis.minY) / 2, axis.minZ + (axis.maxZ - axis.minZ) / 2); + + Vector3 diffVec = blockVec.copy().sub(thisVec); + Vector3 diffVec2D = new Vector3(diffVec.x, diffVec.z, 0); + Vector3 rotVec = new Vector3(0, 1, 0); + double angle = rotVec.angle(diffVec2D) / Math.PI * 180.0; + + if(blockVec.x < thisVec.x) + angle = -angle; + + rotationX = (float) angle + 90; + + rotVec = new Vector3(diffVec.x, 0, diffVec.z); + angle = diffVec.angle(rotVec) * 180F / Math.PI; + if(blockVec.y < thisVec.y) + angle = -angle; + rotationY = (float) angle; + + checkForReceiver(); + return true; + } + + @Override + public void markDispatchable() { + // NO-OP + } + + @Override + public float getRotationX() { + return rotationX; + } + + @Override + public float getRotationY() { + return rotationY; + } + + @Override + public void setRotationX(float rot) { + rotationX = rot; + } + + @Override + public void setRotationY(float rot) { + rotationY = rot; + } + + @Override + public void commitRedirection() { + checkForReceiver(); + } + + @Override + public void setCanShoot(boolean canShoot) { + canShootBurst = canShoot; + } + + @Override + public int getBurstParticleTick() { + return burstParticleTick; + } + + @Override + public void setBurstParticleTick(int i) { + burstParticleTick = i; + } + + @Override + public int getLastBurstDeathTick() { + return lastBurstDeathTick; + } + + @Override + public void setLastBurstDeathTick(int i) { + lastBurstDeathTick = i; + } + + @Override + public void pingback(IManaBurst burst, UUID expectedIdentity) { + if(getIdentifier().equals(expectedIdentity)) { + pingbackTicks = TICKS_ALLOWED_WITHOUT_PINGBACK; + Entity e = (Entity) burst; + lastPingbackX = e.posX; + lastPingbackY = e.posY; + lastPingbackZ = e.posZ; + setCanShoot(false); + } + } + + @Override + public UUID getIdentifier() { + if(identity == null) + identity = UUID.randomUUID(); + return identity; + } + + public UUID getIdentifierUnsafe() { + return identity; + } + } diff --git a/src/main/java/vazkii/botania/common/block/tile/mana/TileTurntable.java b/src/main/java/vazkii/botania/common/block/tile/mana/TileTurntable.java index 6ab7cc5a18..23a0b14265 100644 --- a/src/main/java/vazkii/botania/common/block/tile/mana/TileTurntable.java +++ b/src/main/java/vazkii/botania/common/block/tile/mana/TileTurntable.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Mar 16, 2014, 10:15:05 PM (GMT)] */ package vazkii.botania.common.block.tile.mana; @@ -18,71 +18,78 @@ import net.minecraft.tileentity.TileEntity; import net.minecraft.util.EnumChatFormatting; import net.minecraftforge.common.util.ForgeDirection; + import org.lwjgl.opengl.GL11; + import vazkii.botania.api.internal.VanillaPacketDispatcher; import vazkii.botania.common.block.tile.TileMod; public class TileTurntable extends TileMod { - private static final String TAG_SPEED = "speed"; - private static final String TAG_BACKWARDS = "backwards"; - - int speed = 1; - boolean backwards = false; - - @Override - public void updateEntity() { - boolean redstone = false; - - for (ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS) { - int redstoneSide = worldObj.getIndirectPowerLevelTo( - xCoord + dir.offsetX, yCoord + dir.offsetY, zCoord + dir.offsetZ, dir.ordinal()); - if (redstoneSide > 0) redstone = true; - } - - if (!redstone) { - TileEntity tile = worldObj.getTileEntity(xCoord, yCoord + 1, zCoord); - if (tile instanceof TileSpreader) { - TileSpreader spreader = (TileSpreader) tile; - spreader.rotationX += speed * (backwards ? -1 : 1); - if (spreader.rotationX >= 360F) spreader.rotationX -= 360F; - spreader.checkForReceiver(); - } - } - } - - @Override - public void writeCustomNBT(NBTTagCompound cmp) { - cmp.setInteger(TAG_SPEED, speed); - cmp.setBoolean(TAG_BACKWARDS, backwards); - } - - @Override - public void readCustomNBT(NBTTagCompound cmp) { - speed = cmp.getInteger(TAG_SPEED); - backwards = cmp.getBoolean(TAG_BACKWARDS); - } - - public void onWanded(EntityPlayer player, ItemStack wand) { - if (player == null) return; - - if (player.isSneaking()) backwards = !backwards; - else speed = speed == 6 ? 1 : speed + 1; - VanillaPacketDispatcher.dispatchTEToNearbyPlayers(worldObj, xCoord, yCoord, zCoord); - } - - public void renderHUD(Minecraft mc, ScaledResolution res) { - int color = 0xAA006600; - - char motion = backwards ? '<' : '>'; - String speed = EnumChatFormatting.BOLD + ""; - for (int i = 0; i < this.speed; i++) speed = speed + motion; - - int x = res.getScaledWidth() / 2 - mc.fontRenderer.getStringWidth(speed) / 2; - int y = res.getScaledHeight() / 2 - 15; - GL11.glEnable(GL11.GL_BLEND); - GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); - mc.fontRenderer.drawStringWithShadow(speed, x, y, color); - GL11.glDisable(GL11.GL_BLEND); - } + private static final String TAG_SPEED = "speed"; + private static final String TAG_BACKWARDS = "backwards"; + + int speed = 1; + boolean backwards = false; + + @Override + public void updateEntity() { + boolean redstone = false; + + for(ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS) { + int redstoneSide = worldObj.getIndirectPowerLevelTo(xCoord + dir.offsetX, yCoord + dir.offsetY, zCoord + dir.offsetZ, dir.ordinal()); + if(redstoneSide > 0) + redstone = true; + } + + if(!redstone) { + TileEntity tile = worldObj.getTileEntity(xCoord, yCoord + 1, zCoord); + if(tile instanceof TileSpreader) { + TileSpreader spreader = (TileSpreader) tile; + spreader.rotationX += speed * (backwards ? -1 : 1); + if(spreader.rotationX >= 360F) + spreader.rotationX -= 360F; + spreader.checkForReceiver(); + } + } + } + + @Override + public void writeCustomNBT(NBTTagCompound cmp) { + cmp.setInteger(TAG_SPEED, speed); + cmp.setBoolean(TAG_BACKWARDS, backwards); + } + + @Override + public void readCustomNBT(NBTTagCompound cmp) { + speed = cmp.getInteger(TAG_SPEED); + backwards = cmp.getBoolean(TAG_BACKWARDS); + } + + public void onWanded(EntityPlayer player, ItemStack wand) { + if(player == null) + return; + + if(player.isSneaking()) + backwards = !backwards; + else speed = speed == 6 ? 1 : speed + 1; + VanillaPacketDispatcher.dispatchTEToNearbyPlayers(worldObj, xCoord, yCoord, zCoord); + } + + public void renderHUD(Minecraft mc, ScaledResolution res) { + int color = 0xAA006600; + + char motion = backwards ? '<' : '>'; + String speed = EnumChatFormatting.BOLD + ""; + for(int i = 0; i < this.speed; i++) + speed = speed + motion; + + int x = res.getScaledWidth() / 2 - mc.fontRenderer.getStringWidth(speed) / 2; + int y = res.getScaledHeight() / 2 - 15; + GL11.glEnable(GL11.GL_BLEND); + GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); + mc.fontRenderer.drawStringWithShadow(speed, x, y, color); + GL11.glDisable(GL11.GL_BLEND); + } + } diff --git a/src/main/java/vazkii/botania/common/block/tile/string/TileRedString.java b/src/main/java/vazkii/botania/common/block/tile/string/TileRedString.java index 226ce38c96..2d386a6e1e 100644 --- a/src/main/java/vazkii/botania/common/block/tile/string/TileRedString.java +++ b/src/main/java/vazkii/botania/common/block/tile/string/TileRedString.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Nov 14, 2014, 5:04:22 PM (GMT)] */ package vazkii.botania.common.block.tile.string; @@ -21,71 +21,74 @@ public abstract class TileRedString extends TileMod implements ITileBound { - private ChunkCoordinates binding; - - @Override - public void updateEntity() { - ForgeDirection dir = getOrientation(); - int x = xCoord; - int y = yCoord; - int z = zCoord; - int range = getRange(); - ChunkCoordinates currBinding = getBinding(); - setBinding(null); - - for (int i = 0; i < range; i++) { - x += dir.offsetX; - y += dir.offsetY; - z += dir.offsetZ; - if (worldObj.isAirBlock(x, y, z)) continue; - - TileEntity tile = worldObj.getTileEntity(x, y, z); - if (tile instanceof TileRedString) continue; - - if (acceptBlock(x, y, z)) { - setBinding(new ChunkCoordinates(x, y, z)); - if (currBinding == null || currBinding.posX != x || currBinding.posY != y || currBinding.posZ != z) - onBound(x, y, z); - break; - } - } - } - - public int getRange() { - return 8; - } - - public abstract boolean acceptBlock(int x, int y, int z); - - public void onBound(int x, int y, int z) { - // NO-OP - } - - @Override - public AxisAlignedBB getRenderBoundingBox() { - return INFINITE_EXTENT_AABB; - } - - @Override - public ChunkCoordinates getBinding() { - return binding; - } - - public void setBinding(ChunkCoordinates binding) { - this.binding = binding; - } - - public ForgeDirection getOrientation() { - return ForgeDirection.getOrientation(getBlockMetadata()); - } - - public TileEntity getTileAtBinding() { - ChunkCoordinates binding = getBinding(); - return binding == null ? null : worldObj.getTileEntity(binding.posX, binding.posY, binding.posZ); - } - - public Block getBlockAtBinding() { - ChunkCoordinates binding = getBinding(); - return binding == null ? Blocks.air : worldObj.getBlock(binding.posX, binding.posY, binding.posZ); - } + private ChunkCoordinates binding; + + @Override + public void updateEntity() { + ForgeDirection dir = getOrientation(); + int x = xCoord; + int y = yCoord; + int z = zCoord; + int range = getRange(); + ChunkCoordinates currBinding = getBinding(); + setBinding(null); + + for(int i = 0; i < range; i++) { + x += dir.offsetX; + y += dir.offsetY; + z += dir.offsetZ; + if(worldObj.isAirBlock(x, y, z)) + continue; + + TileEntity tile = worldObj.getTileEntity(x, y, z); + if(tile instanceof TileRedString) + continue; + + if(acceptBlock(x, y, z)) { + setBinding(new ChunkCoordinates(x, y, z)); + if(currBinding == null || currBinding.posX != x || currBinding.posY != y || currBinding.posZ != z) + onBound(x, y, z); + break; + } + } + } + + public int getRange() { + return 8; + } + + public abstract boolean acceptBlock(int x, int y, int z); + + public void onBound(int x, int y, int z) { + // NO-OP + } + + @Override + public AxisAlignedBB getRenderBoundingBox() { + return INFINITE_EXTENT_AABB; + } + + @Override + public ChunkCoordinates getBinding() { + return binding; + } + + public void setBinding(ChunkCoordinates binding) { + this.binding = binding; + } + + public ForgeDirection getOrientation() { + return ForgeDirection.getOrientation(getBlockMetadata()); + } + + public TileEntity getTileAtBinding() { + ChunkCoordinates binding = getBinding(); + return binding == null ? null : worldObj.getTileEntity(binding.posX, binding.posY, binding.posZ); + } + + public Block getBlockAtBinding() { + ChunkCoordinates binding = getBinding(); + return binding == null ? Blocks.air : worldObj.getBlock(binding.posX, binding.posY, binding.posZ); + } + } diff --git a/src/main/java/vazkii/botania/common/block/tile/string/TileRedStringComparator.java b/src/main/java/vazkii/botania/common/block/tile/string/TileRedStringComparator.java index 3434f9aa60..ca519437eb 100644 --- a/src/main/java/vazkii/botania/common/block/tile/string/TileRedStringComparator.java +++ b/src/main/java/vazkii/botania/common/block/tile/string/TileRedStringComparator.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Nov 16, 2014, 10:22:01 PM (GMT)] */ package vazkii.botania.common.block.tile.string; @@ -16,38 +16,34 @@ public class TileRedStringComparator extends TileRedString { - int comparatorValue = 0; - - @Override - public void updateEntity() { - super.updateEntity(); - - ChunkCoordinates binding = getBinding(); - ForgeDirection dir = getOrientation(); - Block block = getBlockAtBinding(); - int origVal = comparatorValue; - - if (block.hasComparatorInputOverride()) { - int val = block.getComparatorInputOverride( - worldObj, - binding.posX, - binding.posY, - binding.posZ, - dir.getOpposite().ordinal()); - comparatorValue = val; - } else comparatorValue = 0; - - if (origVal != comparatorValue) - worldObj.func_147453_f(xCoord, yCoord, zCoord, worldObj.getBlock(xCoord, yCoord, zCoord)); - } - - public int getComparatorValue() { - return comparatorValue; - } - - @Override - public boolean acceptBlock(int x, int y, int z) { - Block block = worldObj.getBlock(x, y, z); - return block.hasComparatorInputOverride(); - } + int comparatorValue = 0; + + @Override + public void updateEntity() { + super.updateEntity(); + + ChunkCoordinates binding = getBinding(); + ForgeDirection dir = getOrientation(); + Block block = getBlockAtBinding(); + int origVal = comparatorValue; + + if(block.hasComparatorInputOverride()) { + int val = block.getComparatorInputOverride(worldObj, binding.posX, binding.posY, binding.posZ, dir.getOpposite().ordinal()); + comparatorValue = val; + } else comparatorValue = 0; + + if(origVal != comparatorValue) + worldObj.func_147453_f(xCoord, yCoord, zCoord, worldObj.getBlock(xCoord, yCoord, zCoord)); + } + + public int getComparatorValue() { + return comparatorValue; + } + + @Override + public boolean acceptBlock(int x, int y, int z) { + Block block = worldObj.getBlock(x, y, z); + return block.hasComparatorInputOverride(); + } + } diff --git a/src/main/java/vazkii/botania/common/block/tile/string/TileRedStringContainer.java b/src/main/java/vazkii/botania/common/block/tile/string/TileRedStringContainer.java index 4066fddd29..6759394fb9 100644 --- a/src/main/java/vazkii/botania/common/block/tile/string/TileRedStringContainer.java +++ b/src/main/java/vazkii/botania/common/block/tile/string/TileRedStringContainer.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Nov 14, 2014, 5:26:39 PM (GMT)] */ package vazkii.botania.common.block.tile.string; @@ -20,126 +20,132 @@ public class TileRedStringContainer extends TileRedString implements ISidedInventory { - @Override - public boolean acceptBlock(int x, int y, int z) { - TileEntity tile = worldObj.getTileEntity(x, y, z); - if (tile != null && tile instanceof IInventory) { - IInventory inv = (IInventory) tile; - if (inv instanceof ISidedInventory) { - ISidedInventory sidedInv = (ISidedInventory) inv; - for (int i = 0; i < 6; i++) if (sidedInv.getAccessibleSlotsFromSide(i).length != 0) return true; - return false; - } - - return true; - } - - return false; - } - - @Override - public int getSizeInventory() { - IInventory inv = getInventory(); - return inv != null ? inv.getSizeInventory() : 0; - } - - @Override - public ItemStack getStackInSlot(int slot) { - IInventory inv = getInventory(); - return inv != null ? inv.getStackInSlot(slot) : null; - } - - @Override - public ItemStack decrStackSize(int slot, int count) { - IInventory inv = getInventory(); - return inv != null ? inv.decrStackSize(slot, count) : null; - } - - @Override - public ItemStack getStackInSlotOnClosing(int slot) { - IInventory inv = getInventory(); - return inv != null ? inv.getStackInSlotOnClosing(slot) : null; - } - - @Override - public void setInventorySlotContents(int slot, ItemStack stack) { - IInventory inv = getInventory(); - if (inv != null) inv.setInventorySlotContents(slot, stack); - } - - @Override - public String getInventoryName() { - IInventory inv = getInventory(); - return inv != null ? inv.getInventoryName() : LibBlockNames.RED_STRING_CONTAINER; - } - - @Override - public boolean hasCustomInventoryName() { - IInventory inv = getInventory(); - return inv != null ? inv.hasCustomInventoryName() : false; - } - - @Override - public int getInventoryStackLimit() { - IInventory inv = getInventory(); - return inv != null ? inv.getInventoryStackLimit() : 0; - } - - @Override - public boolean isUseableByPlayer(EntityPlayer player) { - IInventory inv = getInventory(); - return inv != null ? inv.isUseableByPlayer(player) : false; - } - - @Override - public void openInventory() { - IInventory inv = getInventory(); - if (inv != null) inv.openInventory(); - } - - @Override - public void closeInventory() { - IInventory inv = getInventory(); - if (inv != null) inv.closeInventory(); - } - - @Override - public boolean isItemValidForSlot(int slot, ItemStack stack) { - IInventory inv = getInventory(); - return inv != null ? inv.isItemValidForSlot(slot, stack) : false; - } - - @Override - public int[] getAccessibleSlotsFromSide(int side) { - IInventory inv = getInventory(); - return inv instanceof ISidedInventory - ? ((ISidedInventory) inv).getAccessibleSlotsFromSide(side) - : inv instanceof IInventory ? InventoryHelper.buildSlotsForLinearInventory(inv) : new int[0]; - } - - @Override - public boolean canInsertItem(int slot, ItemStack stack, int side) { - IInventory inv = getInventory(); - return inv instanceof ISidedInventory ? ((ISidedInventory) inv).canInsertItem(slot, stack, side) : true; - } - - @Override - public boolean canExtractItem(int slot, ItemStack stack, int side) { - IInventory inv = getInventory(); - return inv instanceof ISidedInventory ? ((ISidedInventory) inv).canExtractItem(slot, stack, side) : true; - } - - @Override - public void markDirty() { - super.markDirty(); - TileEntity tile = getTileAtBinding(); - if (tile != null) tile.markDirty(); - } - - IInventory getInventory() { - TileEntity tile = getTileAtBinding(); - if (tile == null || !(tile instanceof IInventory)) return null; - - return InventoryHelper.getInventory((IInventory) tile); - } + @Override + public boolean acceptBlock(int x, int y, int z) { + TileEntity tile = worldObj.getTileEntity(x, y, z); + if(tile != null && tile instanceof IInventory) { + IInventory inv = (IInventory) tile; + if(inv instanceof ISidedInventory) { + ISidedInventory sidedInv = (ISidedInventory) inv; + for(int i = 0; i < 6; i++) + if(sidedInv.getAccessibleSlotsFromSide(i).length != 0) + return true; + return false; + } + + return true; + } + + return false; + } + + @Override + public int getSizeInventory() { + IInventory inv = getInventory(); + return inv != null ? inv.getSizeInventory() : 0; + } + + @Override + public ItemStack getStackInSlot(int slot) { + IInventory inv = getInventory(); + return inv != null ? inv.getStackInSlot(slot) : null; + } + + @Override + public ItemStack decrStackSize(int slot, int count) { + IInventory inv = getInventory(); + return inv != null ? inv.decrStackSize(slot, count) : null; + } + + @Override + public ItemStack getStackInSlotOnClosing(int slot) { + IInventory inv = getInventory(); + return inv != null ? inv.getStackInSlotOnClosing(slot) : null; + } + + @Override + public void setInventorySlotContents(int slot, ItemStack stack) { + IInventory inv = getInventory(); + if(inv != null) + inv.setInventorySlotContents(slot, stack); + } + + @Override + public String getInventoryName() { + IInventory inv = getInventory(); + return inv != null ? inv.getInventoryName() : LibBlockNames.RED_STRING_CONTAINER; + } + + @Override + public boolean hasCustomInventoryName() { + IInventory inv = getInventory(); + return inv != null ? inv.hasCustomInventoryName() : false; + } + + @Override + public int getInventoryStackLimit() { + IInventory inv = getInventory(); + return inv != null ? inv.getInventoryStackLimit() : 0; + } + + @Override + public boolean isUseableByPlayer(EntityPlayer player) { + IInventory inv = getInventory(); + return inv != null ? inv.isUseableByPlayer(player) : false; + } + + @Override + public void openInventory() { + IInventory inv = getInventory(); + if(inv != null) + inv.openInventory(); + } + + @Override + public void closeInventory() { + IInventory inv = getInventory(); + if(inv != null) + inv.closeInventory(); + } + + @Override + public boolean isItemValidForSlot(int slot, ItemStack stack) { + IInventory inv = getInventory(); + return inv != null ? inv.isItemValidForSlot(slot, stack) : false; + } + + @Override + public int[] getAccessibleSlotsFromSide(int side) { + IInventory inv = getInventory(); + return inv instanceof ISidedInventory ? ((ISidedInventory) inv).getAccessibleSlotsFromSide(side) : inv instanceof IInventory ? InventoryHelper.buildSlotsForLinearInventory(inv) : new int[0]; + } + + @Override + public boolean canInsertItem(int slot, ItemStack stack, int side) { + IInventory inv = getInventory(); + return inv instanceof ISidedInventory ? ((ISidedInventory) inv).canInsertItem(slot, stack, side) : true; + } + + @Override + public boolean canExtractItem(int slot, ItemStack stack, int side) { + IInventory inv = getInventory(); + return inv instanceof ISidedInventory ? ((ISidedInventory) inv).canExtractItem(slot, stack, side) : true; + } + + @Override + public void markDirty() { + super.markDirty(); + TileEntity tile = getTileAtBinding(); + if(tile != null) + tile.markDirty(); + } + + IInventory getInventory() { + TileEntity tile = getTileAtBinding(); + if(tile == null || !(tile instanceof IInventory)) + return null; + + return InventoryHelper.getInventory((IInventory) tile); + } + } diff --git a/src/main/java/vazkii/botania/common/block/tile/string/TileRedStringDispenser.java b/src/main/java/vazkii/botania/common/block/tile/string/TileRedStringDispenser.java index 9ec0011974..6d1b5875df 100644 --- a/src/main/java/vazkii/botania/common/block/tile/string/TileRedStringDispenser.java +++ b/src/main/java/vazkii/botania/common/block/tile/string/TileRedStringDispenser.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Nov 14, 2014, 11:00:16 PM (GMT)] */ package vazkii.botania.common.block.tile.string; @@ -16,23 +16,19 @@ public class TileRedStringDispenser extends TileRedStringContainer { - @Override - public boolean acceptBlock(int x, int y, int z) { - TileEntity tile = worldObj.getTileEntity(x, y, z); - return tile != null && tile instanceof TileEntityDispenser; - } + @Override + public boolean acceptBlock(int x, int y, int z) { + TileEntity tile = worldObj.getTileEntity(x, y, z); + return tile != null && tile instanceof TileEntityDispenser; + } + + public void tickDispenser() { + ChunkCoordinates bind = getBinding(); + if(bind != null) { + TileEntity tile = worldObj.getTileEntity(bind.posX, bind.posY, bind.posZ); + if(tile instanceof TileEntityDispenser) + worldObj.scheduleBlockUpdate(bind.posX, bind.posY, bind.posZ, tile.getBlockType(), tile.getBlockType().tickRate(worldObj)); + } + } - public void tickDispenser() { - ChunkCoordinates bind = getBinding(); - if (bind != null) { - TileEntity tile = worldObj.getTileEntity(bind.posX, bind.posY, bind.posZ); - if (tile instanceof TileEntityDispenser) - worldObj.scheduleBlockUpdate( - bind.posX, - bind.posY, - bind.posZ, - tile.getBlockType(), - tile.getBlockType().tickRate(worldObj)); - } - } } diff --git a/src/main/java/vazkii/botania/common/block/tile/string/TileRedStringFertilizer.java b/src/main/java/vazkii/botania/common/block/tile/string/TileRedStringFertilizer.java index b47d9402fe..463a37805b 100644 --- a/src/main/java/vazkii/botania/common/block/tile/string/TileRedStringFertilizer.java +++ b/src/main/java/vazkii/botania/common/block/tile/string/TileRedStringFertilizer.java @@ -2,15 +2,16 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Nov 16, 2014, 7:17:16 PM (GMT)] */ package vazkii.botania.common.block.tile.string; import java.util.Random; + import net.minecraft.block.Block; import net.minecraft.block.IGrowable; import net.minecraft.util.ChunkCoordinates; @@ -18,32 +19,29 @@ public class TileRedStringFertilizer extends TileRedString { - public boolean func_149851_a(World p_149851_1_, boolean p_149851_5_) { - ChunkCoordinates binding = getBinding(); - Block block = getBlockAtBinding(); - - return block instanceof IGrowable - ? ((IGrowable) block).func_149851_a(p_149851_1_, binding.posX, binding.posY, binding.posZ, p_149851_5_) - : false; - } - - public boolean func_149852_a(World p_149852_1_, Random p_149852_2_) { - ChunkCoordinates binding = getBinding(); - Block block = getBlockAtBinding(); - return block instanceof IGrowable - ? ((IGrowable) block).func_149852_a(p_149852_1_, p_149852_2_, binding.posX, binding.posY, binding.posZ) - : false; - } - - public void func_149853_b(World p_149853_1_, Random p_149853_2_) { - ChunkCoordinates binding = getBinding(); - Block block = getBlockAtBinding(); - if (block instanceof IGrowable) - ((IGrowable) block).func_149853_b(p_149853_1_, p_149853_2_, binding.posX, binding.posY, binding.posZ); - } - - @Override - public boolean acceptBlock(int x, int y, int z) { - return worldObj.getBlock(x, y, z) instanceof IGrowable; - } + public boolean func_149851_a(World p_149851_1_, boolean p_149851_5_) { + ChunkCoordinates binding = getBinding(); + Block block = getBlockAtBinding(); + + return block instanceof IGrowable ? ((IGrowable) block).func_149851_a(p_149851_1_, binding.posX, binding.posY, binding.posZ, p_149851_5_) : false; + } + + public boolean func_149852_a(World p_149852_1_, Random p_149852_2_) { + ChunkCoordinates binding = getBinding(); + Block block = getBlockAtBinding(); + return block instanceof IGrowable ? ((IGrowable) block).func_149852_a(p_149852_1_, p_149852_2_, binding.posX, binding.posY, binding.posZ) : false; + } + + public void func_149853_b(World p_149853_1_, Random p_149853_2_) { + ChunkCoordinates binding = getBinding(); + Block block = getBlockAtBinding(); + if(block instanceof IGrowable) + ((IGrowable) block).func_149853_b(p_149853_1_, p_149853_2_, binding.posX, binding.posY, binding.posZ); + } + + @Override + public boolean acceptBlock(int x, int y, int z) { + return worldObj.getBlock(x, y, z) instanceof IGrowable; + } + } diff --git a/src/main/java/vazkii/botania/common/block/tile/string/TileRedStringInterceptor.java b/src/main/java/vazkii/botania/common/block/tile/string/TileRedStringInterceptor.java index 061ba7fe47..39d0c375b0 100644 --- a/src/main/java/vazkii/botania/common/block/tile/string/TileRedStringInterceptor.java +++ b/src/main/java/vazkii/botania/common/block/tile/string/TileRedStringInterceptor.java @@ -2,16 +2,17 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Sep 21, 2015, 4:58:20 PM (GMT)] */ package vazkii.botania.common.block.tile.string; import java.util.ArrayList; import java.util.List; + import net.minecraft.block.Block; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.util.ChunkCoordinates; @@ -19,57 +20,59 @@ public class TileRedStringInterceptor extends TileRedString { - public static List interceptors = new ArrayList(); + public static List interceptors = new ArrayList(); - @Override - public void updateEntity() { - super.updateEntity(); + @Override + public void updateEntity() { + super.updateEntity(); - if (!interceptors.contains(this)) interceptors.add(this); - } + if(!interceptors.contains(this)) + interceptors.add(this); + } - @Override - public boolean acceptBlock(int x, int y, int z) { - return worldObj.getTileEntity(x, y, z) != null; - } + @Override + public boolean acceptBlock(int x, int y, int z) { + return worldObj.getTileEntity(x, y, z) != null; + } - public boolean removeFromList() { - return !tileEntityInvalid && worldObj.getTileEntity(xCoord, yCoord, zCoord) == this; - } + public boolean removeFromList() { + return !tileEntityInvalid && worldObj.getTileEntity(xCoord, yCoord, zCoord) == this; + } - public static void onInteract(EntityPlayer player, World world, int x, int y, int z) { - List remove = new ArrayList(); - boolean did = false; + public static void onInteract(EntityPlayer player, World world, int x, int y, int z) { + List remove = new ArrayList(); + boolean did = false; - // CMEs are amazing - List interceptorsCopy = new ArrayList(interceptors); + // CMEs are amazing + List interceptorsCopy = new ArrayList(interceptors); + + for(TileRedStringInterceptor inter : interceptorsCopy) { + if(!inter.removeFromList()) { + remove.add(inter); + continue; + } - for (TileRedStringInterceptor inter : interceptorsCopy) { - if (!inter.removeFromList()) { - remove.add(inter); - continue; - } + if(inter.worldObj == world) { + ChunkCoordinates coords = inter.getBinding(); + if(coords != null && coords.posX == x && coords.posY == y && coords.posZ == z) { + if(!world.isRemote) { + Block block = inter.getBlockType(); + int meta = inter.getBlockMetadata(); + world.setBlockMetadataWithNotify(inter.xCoord, inter.yCoord, inter.zCoord, meta | 8, 1 | 2); + world.scheduleBlockUpdate(inter.xCoord, inter.yCoord, inter.zCoord, block, block.tickRate(world)); + } - if (inter.worldObj == world) { - ChunkCoordinates coords = inter.getBinding(); - if (coords != null && coords.posX == x && coords.posY == y && coords.posZ == z) { - if (!world.isRemote) { - Block block = inter.getBlockType(); - int meta = inter.getBlockMetadata(); - world.setBlockMetadataWithNotify(inter.xCoord, inter.yCoord, inter.zCoord, meta | 8, 1 | 2); - world.scheduleBlockUpdate( - inter.xCoord, inter.yCoord, inter.zCoord, block, block.tickRate(world)); - } + did = true; + } + } + } - did = true; - } - } - } + interceptors.removeAll(remove); + if(did) { + if(world.isRemote) + player.swingItem(); + else world.playSoundEffect(x + 0.5, y + 0.5, z + 0.5, "random.click", 0.3F, 0.6F); + } + } - interceptors.removeAll(remove); - if (did) { - if (world.isRemote) player.swingItem(); - else world.playSoundEffect(x + 0.5, y + 0.5, z + 0.5, "random.click", 0.3F, 0.6F); - } - } } diff --git a/src/main/java/vazkii/botania/common/block/tile/string/TileRedStringRelay.java b/src/main/java/vazkii/botania/common/block/tile/string/TileRedStringRelay.java index 56b498cf57..825deabf7d 100644 --- a/src/main/java/vazkii/botania/common/block/tile/string/TileRedStringRelay.java +++ b/src/main/java/vazkii/botania/common/block/tile/string/TileRedStringRelay.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Nov 16, 2014, 10:52:21 PM (GMT)] */ package vazkii.botania.common.block.tile.string; @@ -19,13 +19,14 @@ public class TileRedStringRelay extends TileRedString { - @Override - public boolean acceptBlock(int x, int y, int z) { - if (x == xCoord && y == yCoord + 1 && z == zCoord) return false; + @Override + public boolean acceptBlock(int x, int y, int z) { + if(x == xCoord && y == yCoord + 1 && z == zCoord) + return false; + + Block block = worldObj.getBlock(x, y, z); + TileEntity tile = worldObj.getTileEntity(x, y, z); + return (block instanceof BlockFlower || block instanceof BlockMushroom || block instanceof BlockDoublePlant) && (tile == null || !(tile instanceof ISubTileContainer)); + } - Block block = worldObj.getBlock(x, y, z); - TileEntity tile = worldObj.getTileEntity(x, y, z); - return (block instanceof BlockFlower || block instanceof BlockMushroom || block instanceof BlockDoublePlant) - && (tile == null || !(tile instanceof ISubTileContainer)); - } } diff --git a/src/main/java/vazkii/botania/common/brew/BrewMod.java b/src/main/java/vazkii/botania/common/brew/BrewMod.java index d257fc7485..765c957c1b 100644 --- a/src/main/java/vazkii/botania/common/brew/BrewMod.java +++ b/src/main/java/vazkii/botania/common/brew/BrewMod.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Nov 1, 2014, 7:02:29 PM (GMT)] */ package vazkii.botania.common.brew; @@ -16,13 +16,14 @@ public class BrewMod extends Brew { - public BrewMod(String key, int color, int cost, PotionEffect... effects) { - super(key, key, color, cost, effects); - BotaniaAPI.registerBrew(this); - } + public BrewMod(String key, int color, int cost, PotionEffect... effects) { + super(key, key, color, cost, effects); + BotaniaAPI.registerBrew(this); + } + + @Override + public String getUnlocalizedName() { + return "botania.brew." + super.getUnlocalizedName(); + } - @Override - public String getUnlocalizedName() { - return "botania.brew." + super.getUnlocalizedName(); - } } diff --git a/src/main/java/vazkii/botania/common/brew/BrewModPotion.java b/src/main/java/vazkii/botania/common/brew/BrewModPotion.java index fc7c6e9e21..3ec9f03bf6 100644 --- a/src/main/java/vazkii/botania/common/brew/BrewModPotion.java +++ b/src/main/java/vazkii/botania/common/brew/BrewModPotion.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Nov 2, 2014, 10:37:12 PM (GMT)] */ package vazkii.botania.common.brew; @@ -15,7 +15,8 @@ public class BrewModPotion extends BrewMod { - public BrewModPotion(String key, int cost, PotionEffect... effects) { - super(key, Potion.potionTypes[effects[0].getPotionID()].getLiquidColor(), cost, effects); - } + public BrewModPotion(String key, int cost, PotionEffect... effects) { + super(key, Potion.potionTypes[effects[0].getPotionID()].getLiquidColor(), cost, effects); + } + } diff --git a/src/main/java/vazkii/botania/common/brew/ModBrews.java b/src/main/java/vazkii/botania/common/brew/ModBrews.java index 5f7d7e3787..b30edbfc6b 100644 --- a/src/main/java/vazkii/botania/common/brew/ModBrews.java +++ b/src/main/java/vazkii/botania/common/brew/ModBrews.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Nov 1, 2014, 7:00:33 PM (GMT)] */ package vazkii.botania.common.brew; @@ -17,85 +17,63 @@ public class ModBrews { - public static Brew speed; - public static Brew strength; - public static Brew haste; - public static Brew healing; - public static Brew jumpBoost; - public static Brew regen; - public static Brew regenWeak; - public static Brew resistance; - public static Brew fireResistance; - public static Brew waterBreathing; - public static Brew invisibility; - public static Brew nightVision; - public static Brew absorption; + public static Brew speed; + public static Brew strength; + public static Brew haste; + public static Brew healing; + public static Brew jumpBoost; + public static Brew regen; + public static Brew regenWeak; + public static Brew resistance; + public static Brew fireResistance; + public static Brew waterBreathing; + public static Brew invisibility; + public static Brew nightVision; + public static Brew absorption; - public static Brew allure; - public static Brew soulCross; - public static Brew featherfeet; - public static Brew emptiness; - public static Brew bloodthirst; - public static Brew overload; - public static Brew clear; + public static Brew allure; + public static Brew soulCross; + public static Brew featherfeet; + public static Brew emptiness; + public static Brew bloodthirst; + public static Brew overload; + public static Brew clear; - public static Brew warpWard; + public static Brew warpWard; - public static void init() { - speed = new BrewMod(LibBrewNames.SPEED, 0x59B7FF, 4000, new PotionEffect(Potion.moveSpeed.id, 1800, 1)); - strength = new BrewMod(LibBrewNames.STRENGTH, 0xEE3F3F, 4000, new PotionEffect(Potion.damageBoost.id, 1800, 1)); - haste = new BrewMod(LibBrewNames.HASTE, 0xF4A432, 4000, new PotionEffect(Potion.digSpeed.id, 1800, 1)); - healing = new BrewMod(LibBrewNames.HEALING, 0xFF5ECC, 6000, new PotionEffect(Potion.heal.id, 1, 1)); - jumpBoost = new BrewMod(LibBrewNames.JUMP_BOOST, 0x32F46D, 4000, new PotionEffect(Potion.jump.id, 1800, 1)); - regen = new BrewMod(LibBrewNames.REGEN, 0xFD6488, 7000, new PotionEffect(Potion.regeneration.id, 500, 1)); - regenWeak = - new BrewMod(LibBrewNames.REGEN_WEAK, 0xFD6488, 9000, new PotionEffect(Potion.regeneration.id, 2400, 0)); - resistance = - new BrewMod(LibBrewNames.RESISTANCE, 0xB44E17, 4000, new PotionEffect(Potion.resistance.id, 1800, 1)); - fireResistance = new BrewMod( - LibBrewNames.FIRE_RESISTANCE, 0xF86900, 4000, new PotionEffect(Potion.fireResistance.id, 9600, 0)); - waterBreathing = new BrewMod( - LibBrewNames.WATER_BREATHING, 0x84A7CF, 4000, new PotionEffect(Potion.waterBreathing.id, 9600, 0)); - invisibility = new BrewMod( - LibBrewNames.INVISIBILITY, 0xAEAEAE, 8000, new PotionEffect(Potion.invisibility.id, 9600, 0)); - nightVision = new BrewMod( - LibBrewNames.NIGHT_VISION, 0x7C4BEB, 4000, new PotionEffect(Potion.nightVision.id, 9600, 0)); - absorption = new BrewMod( - LibBrewNames.ABSORPTION, 0xF2EB23, 7000, new PotionEffect(Potion.field_76444_x.id, 1800, 3)) - .setNotBloodPendantInfusable() - .setNotIncenseInfusable(); + public static void init() { + speed = new BrewMod(LibBrewNames.SPEED, 0x59B7FF, 4000, new PotionEffect(Potion.moveSpeed.id, 1800, 1)); + strength = new BrewMod(LibBrewNames.STRENGTH, 0xEE3F3F, 4000, new PotionEffect(Potion.damageBoost.id, 1800, 1)); + haste = new BrewMod(LibBrewNames.HASTE, 0xF4A432, 4000, new PotionEffect(Potion.digSpeed.id, 1800, 1)); + healing = new BrewMod(LibBrewNames.HEALING, 0xFF5ECC, 6000, new PotionEffect(Potion.heal.id, 1, 1)); + jumpBoost = new BrewMod(LibBrewNames.JUMP_BOOST, 0x32F46D, 4000, new PotionEffect(Potion.jump.id, 1800, 1)); + regen = new BrewMod(LibBrewNames.REGEN, 0xFD6488, 7000, new PotionEffect(Potion.regeneration.id, 500, 1)); + regenWeak = new BrewMod(LibBrewNames.REGEN_WEAK, 0xFD6488, 9000, new PotionEffect(Potion.regeneration.id, 2400, 0)); + resistance = new BrewMod(LibBrewNames.RESISTANCE, 0xB44E17, 4000, new PotionEffect(Potion.resistance.id, 1800, 1)); + fireResistance = new BrewMod(LibBrewNames.FIRE_RESISTANCE, 0xF86900, 4000, new PotionEffect(Potion.fireResistance.id, 9600, 0)); + waterBreathing = new BrewMod(LibBrewNames.WATER_BREATHING, 0x84A7CF, 4000, new PotionEffect(Potion.waterBreathing.id, 9600, 0)); + invisibility = new BrewMod(LibBrewNames.INVISIBILITY, 0xAEAEAE, 8000, new PotionEffect(Potion.invisibility.id, 9600, 0)); + nightVision = new BrewMod(LibBrewNames.NIGHT_VISION, 0x7C4BEB, 4000, new PotionEffect(Potion.nightVision.id, 9600, 0)); + absorption = new BrewMod(LibBrewNames.ABSORPTION, 0xF2EB23, 7000, new PotionEffect(Potion.field_76444_x.id, 1800, 3)).setNotBloodPendantInfusable().setNotIncenseInfusable(); - overload = new BrewMod( - LibBrewNames.OVERLOAD, - 0x232323, - 12000, - new PotionEffect(Potion.damageBoost.id, 1800, 3), - new PotionEffect(Potion.moveSpeed.id, 1800, 2), - new PotionEffect(Potion.weakness.id, 3600, 2), - new PotionEffect(Potion.hunger.id, 200, 2)); - soulCross = - new BrewModPotion(LibBrewNames.SOUL_CROSS, 10000, new PotionEffect(ModPotions.soulCross.id, 1800, 0)); - featherfeet = new BrewModPotion( - LibBrewNames.FEATHER_FEET, 7000, new PotionEffect(ModPotions.featherfeet.id, 1800, 0)); - emptiness = - new BrewModPotion(LibBrewNames.EMPTINESS, 30000, new PotionEffect(ModPotions.emptiness.id, 7200, 0)); - bloodthirst = - new BrewModPotion(LibBrewNames.BLOODTHIRST, 20000, new PotionEffect(ModPotions.bloodthrst.id, 7200, 0)); - allure = new BrewModPotion(LibBrewNames.ALLURE, 2000, new PotionEffect(ModPotions.allure.id, 4800, 0)); - clear = new BrewModPotion(LibBrewNames.CLEAR, 4000, new PotionEffect(ModPotions.clear.id, 0, 0)); - } + overload = new BrewMod(LibBrewNames.OVERLOAD, 0x232323, 12000, new PotionEffect(Potion.damageBoost.id, 1800, 3), new PotionEffect(Potion.moveSpeed.id, 1800, 2), new PotionEffect(Potion.weakness.id, 3600, 2), new PotionEffect(Potion.hunger.id, 200, 2)); + soulCross = new BrewModPotion(LibBrewNames.SOUL_CROSS, 10000, new PotionEffect(ModPotions.soulCross.id, 1800, 0)); + featherfeet = new BrewModPotion(LibBrewNames.FEATHER_FEET, 7000, new PotionEffect(ModPotions.featherfeet.id, 1800, 0)); + emptiness = new BrewModPotion(LibBrewNames.EMPTINESS, 30000, new PotionEffect(ModPotions.emptiness.id, 7200, 0)); + bloodthirst = new BrewModPotion(LibBrewNames.BLOODTHIRST, 20000, new PotionEffect(ModPotions.bloodthrst.id, 7200, 0)); + allure = new BrewModPotion(LibBrewNames.ALLURE, 2000, new PotionEffect(ModPotions.allure.id, 4800, 0)); + clear = new BrewModPotion(LibBrewNames.CLEAR, 4000, new PotionEffect(ModPotions.clear.id, 0, 0)); + } - public static void initTC() { - Potion warpWardPotion = null; - for (Potion potion : Potion.potionTypes) - if (potion != null && potion.getName().equals("potion.warpward")) { - warpWardPotion = potion; - break; - } + public static void initTC() { + Potion warpWardPotion = null; + for(Potion potion : Potion.potionTypes) + if(potion != null && potion.getName().equals("potion.warpward")) { + warpWardPotion = potion; + break; + } - if (warpWardPotion != null) - warpWard = new BrewMod( - LibBrewNames.WARP_WARD, 0xFBBDFF, 25000, new PotionEffect(warpWardPotion.id, 12000, 0)) - .setNotBloodPendantInfusable(); - } + if(warpWardPotion != null) + warpWard = new BrewMod(LibBrewNames.WARP_WARD, 0xFBBDFF, 25000, new PotionEffect(warpWardPotion.id, 12000, 0)).setNotBloodPendantInfusable(); + } } diff --git a/src/main/java/vazkii/botania/common/brew/ModPotions.java b/src/main/java/vazkii/botania/common/brew/ModPotions.java index d66fef8a18..f6cbffe312 100644 --- a/src/main/java/vazkii/botania/common/brew/ModPotions.java +++ b/src/main/java/vazkii/botania/common/brew/ModPotions.java @@ -2,16 +2,17 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Nov 1, 2014, 7:00:29 PM (GMT)] */ package vazkii.botania.common.brew; import java.lang.reflect.Field; import java.lang.reflect.Modifier; + import net.minecraft.potion.Potion; import vazkii.botania.common.brew.potion.PotionAllure; import vazkii.botania.common.brew.potion.PotionBloodthirst; @@ -22,44 +23,46 @@ public class ModPotions { - public static Potion soulCross; - public static Potion featherfeet; - public static Potion emptiness; - public static Potion bloodthrst; - public static Potion allure; - public static Potion clear; + public static Potion soulCross; + public static Potion featherfeet; + public static Potion emptiness; + public static Potion bloodthrst; + public static Potion allure; + public static Potion clear; + + public static void init() { + if(Potion.potionTypes.length < 256) + extendPotionArray(); - public static void init() { - if (Potion.potionTypes.length < 256) extendPotionArray(); + soulCross = new PotionSoulCross(); + featherfeet = new PotionFeatherfeet(); + emptiness = new PotionEmptiness(); + bloodthrst = new PotionBloodthirst(); + allure = new PotionAllure(); + clear = new PotionClear(); + } - soulCross = new PotionSoulCross(); - featherfeet = new PotionFeatherfeet(); - emptiness = new PotionEmptiness(); - bloodthrst = new PotionBloodthirst(); - allure = new PotionAllure(); - clear = new PotionClear(); - } + private static void extendPotionArray() { + Potion[] potionTypes = null; - private static void extendPotionArray() { - Potion[] potionTypes = null; + for (Field f : Potion.class.getDeclaredFields()) { + f.setAccessible(true); + try { + if (f.getName().equals("potionTypes") || f.getName().equals("field_76425_a")) { + Field modfield = Field.class.getDeclaredField("modifiers"); + modfield.setAccessible(true); + modfield.setInt(f, f.getModifiers() & ~Modifier.FINAL); - for (Field f : Potion.class.getDeclaredFields()) { - f.setAccessible(true); - try { - if (f.getName().equals("potionTypes") || f.getName().equals("field_76425_a")) { - Field modfield = Field.class.getDeclaredField("modifiers"); - modfield.setAccessible(true); - modfield.setInt(f, f.getModifiers() & ~Modifier.FINAL); + potionTypes = (Potion[])f.get(null); + final Potion[] newPotionTypes = new Potion[256]; + System.arraycopy(potionTypes, 0, newPotionTypes, 0, potionTypes.length); + f.set(null, newPotionTypes); + } + } catch (Exception e) { + System.err.println("Severe error, please report this to the mod author:"); + System.err.println(e); + } + } + } - potionTypes = (Potion[]) f.get(null); - final Potion[] newPotionTypes = new Potion[256]; - System.arraycopy(potionTypes, 0, newPotionTypes, 0, potionTypes.length); - f.set(null, newPotionTypes); - } - } catch (Exception e) { - System.err.println("Severe error, please report this to the mod author:"); - System.err.println(e); - } - } - } } diff --git a/src/main/java/vazkii/botania/common/brew/potion/PotionAllure.java b/src/main/java/vazkii/botania/common/brew/potion/PotionAllure.java index e1c59b0152..4f856911e6 100644 --- a/src/main/java/vazkii/botania/common/brew/potion/PotionAllure.java +++ b/src/main/java/vazkii/botania/common/brew/potion/PotionAllure.java @@ -2,15 +2,14 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Nov 3, 2014, 12:15:09 AM (GMT)] */ package vazkii.botania.common.brew.potion; -import cpw.mods.fml.common.eventhandler.SubscribeEvent; import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.projectile.EntityFishHook; @@ -18,20 +17,23 @@ import net.minecraftforge.event.entity.living.LivingEvent.LivingUpdateEvent; import vazkii.botania.common.core.handler.ConfigHandler; import vazkii.botania.common.lib.LibPotionNames; +import cpw.mods.fml.common.eventhandler.SubscribeEvent; public class PotionAllure extends PotionMod { - public PotionAllure() { - super(ConfigHandler.potionIDAllure, LibPotionNames.ALLURE, false, 0x0034E4, 5); - MinecraftForge.EVENT_BUS.register(this); - } + public PotionAllure() { + super(ConfigHandler.potionIDAllure, LibPotionNames.ALLURE, false, 0x0034E4, 5); + MinecraftForge.EVENT_BUS.register(this); + } + + @SubscribeEvent + public void onEntityUpdate(LivingUpdateEvent event) { + EntityLivingBase e = event.entityLiving; + if(e instanceof EntityPlayer && hasEffect(e)) { + EntityFishHook hook = ((EntityPlayer) e).fishEntity; + if(hook != null) + hook.onUpdate(); + } + } - @SubscribeEvent - public void onEntityUpdate(LivingUpdateEvent event) { - EntityLivingBase e = event.entityLiving; - if (e instanceof EntityPlayer && hasEffect(e)) { - EntityFishHook hook = ((EntityPlayer) e).fishEntity; - if (hook != null) hook.onUpdate(); - } - } } diff --git a/src/main/java/vazkii/botania/common/brew/potion/PotionBloodthirst.java b/src/main/java/vazkii/botania/common/brew/potion/PotionBloodthirst.java index d71167f582..44eadad2b9 100644 --- a/src/main/java/vazkii/botania/common/brew/potion/PotionBloodthirst.java +++ b/src/main/java/vazkii/botania/common/brew/potion/PotionBloodthirst.java @@ -2,17 +2,16 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Nov 3, 2014, 12:13:09 AM (GMT)] */ package vazkii.botania.common.brew.potion; -import cpw.mods.fml.common.eventhandler.Event.Result; -import cpw.mods.fml.common.eventhandler.SubscribeEvent; import java.util.List; + import net.minecraft.entity.monster.IMob; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.util.AxisAlignedBB; @@ -21,33 +20,28 @@ import vazkii.botania.common.brew.ModPotions; import vazkii.botania.common.core.handler.ConfigHandler; import vazkii.botania.common.lib.LibPotionNames; +import cpw.mods.fml.common.eventhandler.Event.Result; +import cpw.mods.fml.common.eventhandler.SubscribeEvent; public class PotionBloodthirst extends PotionMod { - private static final int RANGE = 64; + private static final int RANGE = 64; + + public PotionBloodthirst() { + super(ConfigHandler.potionIDBloodthirst, LibPotionNames.BLOODTHIRST, false, 0xC30000, 3); + MinecraftForge.EVENT_BUS.register(this); + } - public PotionBloodthirst() { - super(ConfigHandler.potionIDBloodthirst, LibPotionNames.BLOODTHIRST, false, 0xC30000, 3); - MinecraftForge.EVENT_BUS.register(this); - } + @SubscribeEvent + public void onSpawn(LivingSpawnEvent.CheckSpawn event) { + if(event.getResult() != Result.ALLOW && event.entityLiving instanceof IMob) { + List players = event.world.getEntitiesWithinAABB(EntityPlayer.class, AxisAlignedBB.getBoundingBox(event.x - RANGE, event.y - RANGE, event.z - RANGE, event.x + RANGE, event.y + RANGE, event.z + RANGE)); + for(EntityPlayer player : players) + if(hasEffect(player) && !hasEffect(player, ModPotions.emptiness)) { + event.setResult(Result.ALLOW); + return; + } + } + } - @SubscribeEvent - public void onSpawn(LivingSpawnEvent.CheckSpawn event) { - if (event.getResult() != Result.ALLOW && event.entityLiving instanceof IMob) { - List players = event.world.getEntitiesWithinAABB( - EntityPlayer.class, - AxisAlignedBB.getBoundingBox( - event.x - RANGE, - event.y - RANGE, - event.z - RANGE, - event.x + RANGE, - event.y + RANGE, - event.z + RANGE)); - for (EntityPlayer player : players) - if (hasEffect(player) && !hasEffect(player, ModPotions.emptiness)) { - event.setResult(Result.ALLOW); - return; - } - } - } } diff --git a/src/main/java/vazkii/botania/common/brew/potion/PotionClear.java b/src/main/java/vazkii/botania/common/brew/potion/PotionClear.java index 3c9198a04d..26e76aa3fb 100644 --- a/src/main/java/vazkii/botania/common/brew/potion/PotionClear.java +++ b/src/main/java/vazkii/botania/common/brew/potion/PotionClear.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jul 25, 2015, 6:08:52 PM (GMT)] */ package vazkii.botania.common.brew.potion; @@ -18,17 +18,18 @@ public class PotionClear extends PotionMod { - public PotionClear() { - super(ConfigHandler.potionIDClear, LibPotionNames.CLEAR, false, 0xFFFFFF, 0); - } + public PotionClear() { + super(ConfigHandler.potionIDClear, LibPotionNames.CLEAR, false, 0xFFFFFF, 0); + } - @Override - public boolean isInstant() { - return true; - } + @Override + public boolean isInstant() { + return true; + } + + @Override + public void affectEntity(EntityLivingBase e, EntityLivingBase e1, int t, double d) { + e1.curePotionEffects(new ItemStack(Items.milk_bucket)); + } - @Override - public void affectEntity(EntityLivingBase e, EntityLivingBase e1, int t, double d) { - e1.curePotionEffects(new ItemStack(Items.milk_bucket)); - } } diff --git a/src/main/java/vazkii/botania/common/brew/potion/PotionEmptiness.java b/src/main/java/vazkii/botania/common/brew/potion/PotionEmptiness.java index 95541fd074..6d2b77ea0c 100644 --- a/src/main/java/vazkii/botania/common/brew/potion/PotionEmptiness.java +++ b/src/main/java/vazkii/botania/common/brew/potion/PotionEmptiness.java @@ -2,17 +2,16 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Nov 3, 2014, 12:12:36 AM (GMT)] */ package vazkii.botania.common.brew.potion; -import cpw.mods.fml.common.eventhandler.Event.Result; -import cpw.mods.fml.common.eventhandler.SubscribeEvent; import java.util.List; + import net.minecraft.entity.monster.IMob; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.util.AxisAlignedBB; @@ -20,33 +19,28 @@ import net.minecraftforge.event.entity.living.LivingSpawnEvent; import vazkii.botania.common.core.handler.ConfigHandler; import vazkii.botania.common.lib.LibPotionNames; +import cpw.mods.fml.common.eventhandler.Event.Result; +import cpw.mods.fml.common.eventhandler.SubscribeEvent; public class PotionEmptiness extends PotionMod { - private static final int RANGE = 128; + private static final int RANGE = 128; + + public PotionEmptiness() { + super(ConfigHandler.potionIDEmptiness, LibPotionNames.EMPTINESS, false, 0xFACFFF, 2); + MinecraftForge.EVENT_BUS.register(this); + } - public PotionEmptiness() { - super(ConfigHandler.potionIDEmptiness, LibPotionNames.EMPTINESS, false, 0xFACFFF, 2); - MinecraftForge.EVENT_BUS.register(this); - } + @SubscribeEvent + public void onSpawn(LivingSpawnEvent.CheckSpawn event) { + if(event.getResult() != Result.ALLOW && event.entityLiving instanceof IMob) { + List players = event.world.getEntitiesWithinAABB(EntityPlayer.class, AxisAlignedBB.getBoundingBox(event.x - RANGE, event.y - RANGE, event.z - RANGE, event.x + RANGE, event.y + RANGE, event.z + RANGE)); + for(EntityPlayer player : players) + if(hasEffect(player)) { + event.setResult(Result.DENY); + return; + } + } + } - @SubscribeEvent - public void onSpawn(LivingSpawnEvent.CheckSpawn event) { - if (event.getResult() != Result.ALLOW && event.entityLiving instanceof IMob) { - List players = event.world.getEntitiesWithinAABB( - EntityPlayer.class, - AxisAlignedBB.getBoundingBox( - event.x - RANGE, - event.y - RANGE, - event.z - RANGE, - event.x + RANGE, - event.y + RANGE, - event.z + RANGE)); - for (EntityPlayer player : players) - if (hasEffect(player)) { - event.setResult(Result.DENY); - return; - } - } - } } diff --git a/src/main/java/vazkii/botania/common/brew/potion/PotionFeatherfeet.java b/src/main/java/vazkii/botania/common/brew/potion/PotionFeatherfeet.java index 098c4f13af..0a3fff1248 100644 --- a/src/main/java/vazkii/botania/common/brew/potion/PotionFeatherfeet.java +++ b/src/main/java/vazkii/botania/common/brew/potion/PotionFeatherfeet.java @@ -2,31 +2,33 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Nov 3, 2014, 12:12:04 AM (GMT)] */ package vazkii.botania.common.brew.potion; -import cpw.mods.fml.common.eventhandler.SubscribeEvent; import net.minecraft.entity.EntityLivingBase; import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.event.entity.living.LivingEvent.LivingUpdateEvent; import vazkii.botania.common.core.handler.ConfigHandler; import vazkii.botania.common.lib.LibPotionNames; +import cpw.mods.fml.common.eventhandler.SubscribeEvent; public class PotionFeatherfeet extends PotionMod { - public PotionFeatherfeet() { - super(ConfigHandler.potionIDFeatherfeet, LibPotionNames.FEATHER_FEET, false, 0x26ADFF, 1); - MinecraftForge.EVENT_BUS.register(this); - } + public PotionFeatherfeet() { + super(ConfigHandler.potionIDFeatherfeet, LibPotionNames.FEATHER_FEET, false, 0x26ADFF, 1); + MinecraftForge.EVENT_BUS.register(this); + } + + @SubscribeEvent + public void onEntityUpdate(LivingUpdateEvent event) { + EntityLivingBase e = event.entityLiving; + if(hasEffect(e)) + e.fallDistance = 2.5F; + } - @SubscribeEvent - public void onEntityUpdate(LivingUpdateEvent event) { - EntityLivingBase e = event.entityLiving; - if (hasEffect(e)) e.fallDistance = 2.5F; - } } diff --git a/src/main/java/vazkii/botania/common/brew/potion/PotionMod.java b/src/main/java/vazkii/botania/common/brew/potion/PotionMod.java index 90457010d0..1cf8dcfe2f 100644 --- a/src/main/java/vazkii/botania/common/brew/potion/PotionMod.java +++ b/src/main/java/vazkii/botania/common/brew/potion/PotionMod.java @@ -2,45 +2,46 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Nov 2, 2014, 10:12:45 PM (GMT)] */ package vazkii.botania.common.brew.potion; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; import net.minecraft.client.Minecraft; import net.minecraft.entity.EntityLivingBase; import net.minecraft.potion.Potion; import net.minecraft.util.ResourceLocation; import vazkii.botania.client.lib.LibResources; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; public class PotionMod extends Potion { - private static final ResourceLocation resource = new ResourceLocation(LibResources.GUI_POTIONS); + private static final ResourceLocation resource = new ResourceLocation(LibResources.GUI_POTIONS); + + public PotionMod(int id, String name, boolean badEffect, int color, int iconIndex) { + super(id, badEffect, color); + setPotionName("botania.potion." + name); + setIconIndex(iconIndex % 8, iconIndex / 8); + } - public PotionMod(int id, String name, boolean badEffect, int color, int iconIndex) { - super(id, badEffect, color); - setPotionName("botania.potion." + name); - setIconIndex(iconIndex % 8, iconIndex / 8); - } + @Override + @SideOnly(Side.CLIENT) + public int getStatusIconIndex() { + Minecraft.getMinecraft().renderEngine.bindTexture(resource); - @Override - @SideOnly(Side.CLIENT) - public int getStatusIconIndex() { - Minecraft.getMinecraft().renderEngine.bindTexture(resource); + return super.getStatusIconIndex(); + } - return super.getStatusIconIndex(); - } + public boolean hasEffect(EntityLivingBase entity) { + return hasEffect(entity, this); + } - public boolean hasEffect(EntityLivingBase entity) { - return hasEffect(entity, this); - } + public boolean hasEffect(EntityLivingBase entity, Potion potion) { + return entity.getActivePotionEffect(potion) != null; + } - public boolean hasEffect(EntityLivingBase entity, Potion potion) { - return entity.getActivePotionEffect(potion) != null; - } } diff --git a/src/main/java/vazkii/botania/common/brew/potion/PotionSoulCross.java b/src/main/java/vazkii/botania/common/brew/potion/PotionSoulCross.java index b1e8fac734..8498a68001 100644 --- a/src/main/java/vazkii/botania/common/brew/potion/PotionSoulCross.java +++ b/src/main/java/vazkii/botania/common/brew/potion/PotionSoulCross.java @@ -2,35 +2,37 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Nov 2, 2014, 10:31:48 PM (GMT)] */ package vazkii.botania.common.brew.potion; -import cpw.mods.fml.common.eventhandler.SubscribeEvent; import net.minecraft.entity.Entity; import net.minecraft.entity.EntityLivingBase; import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.event.entity.living.LivingDeathEvent; import vazkii.botania.common.core.handler.ConfigHandler; import vazkii.botania.common.lib.LibPotionNames; +import cpw.mods.fml.common.eventhandler.SubscribeEvent; public class PotionSoulCross extends PotionMod { - public PotionSoulCross() { - super(ConfigHandler.potionIDSoulCross, LibPotionNames.SOUL_CROSS, false, 0x47453d, 0); - MinecraftForge.EVENT_BUS.register(this); - } + public PotionSoulCross() { + super(ConfigHandler.potionIDSoulCross, LibPotionNames.SOUL_CROSS, false, 0x47453d, 0); + MinecraftForge.EVENT_BUS.register(this); + } + + @SubscribeEvent + public void onEntityKill(LivingDeathEvent event) { + Entity e = event.source.getEntity(); + if(e != null && e instanceof EntityLivingBase) { + EntityLivingBase living = (EntityLivingBase) e; + if(hasEffect(living)) + living.heal(event.entityLiving.getMaxHealth() / 20); + } + } - @SubscribeEvent - public void onEntityKill(LivingDeathEvent event) { - Entity e = event.source.getEntity(); - if (e != null && e instanceof EntityLivingBase) { - EntityLivingBase living = (EntityLivingBase) e; - if (hasEffect(living)) living.heal(event.entityLiving.getMaxHealth() / 20); - } - } } diff --git a/src/main/java/vazkii/botania/common/core/BotaniaCreativeTab.java b/src/main/java/vazkii/botania/common/core/BotaniaCreativeTab.java index 1830125278..7e7bdfee77 100644 --- a/src/main/java/vazkii/botania/common/core/BotaniaCreativeTab.java +++ b/src/main/java/vazkii/botania/common/core/BotaniaCreativeTab.java @@ -2,15 +2,16 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jan 14, 2014, 5:20:53 PM (GMT)] */ package vazkii.botania.common.core; import java.util.List; + import net.minecraft.block.Block; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.init.Blocks; @@ -26,392 +27,403 @@ public final class BotaniaCreativeTab extends CreativeTabs { - public static BotaniaCreativeTab INSTANCE = new BotaniaCreativeTab(); - List list; - - public BotaniaCreativeTab() { - super(LibMisc.MOD_ID); - setNoTitle(); - setBackgroundImageName(LibResources.GUI_CREATIVE); - } - - @Override - public ItemStack getIconItemStack() { - return new ItemStack(ModItems.lexicon); - } - - @Override - public Item getTabIconItem() { - return getIconItemStack().getItem(); - } - - @Override - public boolean hasSearchBar() { - return true; - } - - @Override - public void displayAllReleventItems(List list) { - this.list = list; - - addItem(ModItems.lexicon); - - addBlock(ModBlocks.flower); - addBlock(ModBlocks.specialFlower); - addItem(ModItems.petal); - addItem(ModItems.pestleAndMortar); - addItem(ModItems.dye); - addItem(ModItems.fertilizer); - addItem(ModItems.flowerBag); - addItem(ModItems.blackLotus); - addItem(ModItems.twigWand); - addItem(ModItems.obedienceStick); - addItem(ModItems.manaResource); - addBlock(ModBlocks.storage); - addItem(ModItems.manaCookie); - addItem(ModItems.rune); - - addBlock(ModBlocks.avatar); - addItem(ModItems.dirtRod); - addItem(ModItems.skyDirtRod); - addItem(ModItems.cobbleRod); - addItem(ModItems.terraformRod); - addItem(ModItems.laputaShard); - addItem(ModItems.grassHorn); - addItem(ModItems.waterRod); - addItem(ModItems.openBucket); - addItem(ModItems.rainbowRod); - addBlock(ModBlocks.bifrostPerm); - addBlock(ModFluffBlocks.bifrostPane); - addBlock(ModBlocks.shimmerrock); - addBlock(ModBlocks.shimmerwoodPlanks); - addItem(ModItems.tornadoRod); - addItem(ModItems.fireRod); - addItem(ModItems.smeltRod); - addItem(ModItems.exchangeRod); - addItem(ModItems.diviningRod); - addItem(ModItems.gravityRod); - addItem(ModItems.missileRod); - addItem(ModItems.virus); - addItem(ModItems.slingshot); - addItem(ModItems.vineBall); - addItem(ModItems.regenIvy); - addItem(ModItems.keepIvy); - addItem(ModItems.worldSeed); - addItem(ModItems.overgrowthSeed); - addBlock(ModBlocks.enchantedSoil); - addItem(ModItems.grassSeeds); - addBlock(ModBlocks.altGrass); - if (Botania.thaumcraftLoaded) addItem(ModItems.manaInkwell); - addBlock(ModBlocks.forestDrum); - addBlock(ModBlocks.forestEye); - addBlock(ModBlocks.enderEye); - addItem(ModItems.enderHand); - addItem(ModItems.spellCloth); - addItem(ModItems.craftingHalo); - addItem(ModItems.autocraftingHalo); - addItem(ModItems.spawnerMover); - addBlock(ModBlocks.spawnerClaw); - addBlock(ModBlocks.cocoon); - addBlock(ModBlocks.teruTeruBozu); - addItem(ModItems.slimeBottle); - addItem(ModItems.sextant); - addItem(ModItems.blackHoleTalisman); - - if (Botania.gardenOfGlassLoaded) { - addBlock(ModBlocks.root); - addItem(ModItems.waterBowl); - } - - addBlock(ModBlocks.livingrock); - addBlock(ModBlocks.livingwood); - addBlock(ModBlocks.openCrate); - addItem(ModItems.craftPattern); - addBlock(ModBlocks.platform); - addBlock(ModBlocks.alfPortal); - addBlock(ModBlocks.altar); - addBlock(ModBlocks.runeAltar); - addBlock(ModBlocks.terraPlate); - addBlock(ModBlocks.brewery); - addItem(ModItems.vial); - addItem(ModItems.brewVial); - addItem(ModItems.brewFlask); - addBlock(ModBlocks.incensePlate); - addItem(ModItems.incenseStick); - addItem(ModItems.bloodPendant); - addBlock(ModBlocks.felPumpkin); - addBlock(ModBlocks.pylon); - addBlock(ModBlocks.pistonRelay); - addBlock(ModBlocks.hourglass); - - addBlock(ModBlocks.redStringContainer); - addBlock(ModBlocks.redStringDispenser); - addBlock(ModBlocks.redStringFertilizer); - addBlock(ModBlocks.redStringComparator); - addBlock(ModBlocks.redStringRelay); - addBlock(ModBlocks.redStringInterceptor); - - addBlock(ModBlocks.tinyPotato); - addBlock(ModBlocks.starfield); - - addBlock(ModBlocks.dreamwood); - addBlock(ModBlocks.manaGlass); - addBlock(ModFluffBlocks.managlassPane); - addBlock(ModBlocks.elfGlass); - addBlock(ModFluffBlocks.alfglassPane); - - addItem(ModItems.glassPick); - addItem(ModItems.manasteelPick); - addItem(ModItems.manasteelShovel); - addItem(ModItems.manasteelAxe); - addItem(ModItems.manasteelShears); - addItem(ModItems.manasteelSword); - addItem(ModItems.enderDagger); - addItem(ModItems.livingwoodBow); - addItem(ModItems.manasteelHelm); - if (Botania.thaumcraftLoaded) addItem(ModItems.manasteelHelmRevealing); - addItem(ModItems.manasteelChest); - addItem(ModItems.manasteelLegs); - addItem(ModItems.manasteelBoots); - addItem(ModItems.manaweaveHelm); - addItem(ModItems.manaweaveChest); - addItem(ModItems.manaweaveLegs); - addItem(ModItems.manaweaveBoots); - addItem(ModItems.elementiumPick); - addItem(ModItems.elementiumShovel); - addItem(ModItems.elementiumAxe); - addItem(ModItems.elementiumShears); - addItem(ModItems.elementiumSword); - addItem(ModItems.starSword); - addItem(ModItems.thunderSword); - addItem(ModItems.crystalBow); - addItem(ModItems.elementiumHelm); - if (Botania.thaumcraftLoaded) addItem(ModItems.elementiumHelmRevealing); - addItem(ModItems.elementiumChest); - addItem(ModItems.elementiumLegs); - addItem(ModItems.elementiumBoots); - addItem(ModItems.terraSword); - addItem(ModItems.thornChakram); - addItem(ModItems.terraPick); - addItem(ModItems.terraAxe); - addItem(ModItems.temperanceStone); - addItem(ModItems.terrasteelHelm); - if (Botania.thaumcraftLoaded) addItem(ModItems.terrasteelHelmRevealing); - addItem(ModItems.terrasteelChest); - addItem(ModItems.terrasteelLegs); - addItem(ModItems.terrasteelBoots); - addItem(ModItems.phantomInk); - addItem(ModItems.cacophonium); - addItem(ModItems.recordGaia1); - addItem(ModItems.recordGaia2); - addItem(ModItems.ancientWill); - addItem(ModItems.pinkinator); - addItem(ModItems.gaiaHead); - if (ConfigHandler.relicsEnabled) { - addItem(ModItems.dice); - addItem(ModItems.infiniteFruit); - addItem(ModItems.kingKey); - addItem(ModItems.flugelEye); - addItem(ModItems.thorRing); - addItem(ModItems.odinRing); - addItem(ModItems.lokiRing); - addItem(ModItems.aesirRing); - } - - addItem(ModItems.baubleBox); - addItem(ModItems.tinyPlanet); - addBlock(ModBlocks.tinyPlanet); - addItem(ModItems.manaRing); - addItem(ModItems.auraRing); - addItem(ModItems.manaRingGreater); - addItem(ModItems.auraRingGreater); - addItem(ModItems.waterRing); - addItem(ModItems.miningRing); - addItem(ModItems.magnetRing); - addItem(ModItems.magnetRingGreater); - addItem(ModItems.swapRing); - addItem(ModItems.reachRing); - addItem(ModItems.pixieRing); - addItem(ModItems.travelBelt); - addItem(ModItems.superTravelBelt); - addItem(ModItems.speedUpBelt); - addItem(ModItems.knockbackBelt); - addItem(ModItems.itemFinder); - addItem(ModItems.monocle); - addItem(ModItems.icePendant); - addItem(ModItems.lavaPendant); - addItem(ModItems.superLavaPendant); - addItem(ModItems.holyCloak); - addItem(ModItems.unholyCloak); - addItem(ModItems.goldLaurel); - addItem(ModItems.divaCharm); - addItem(ModItems.flightTiara); - - addItem(ModItems.manaTablet); - addItem(ModItems.manaMirror); - addItem(ModItems.manaBottle); - addBlock(ModBlocks.pool); - addBlock(ModBlocks.alchemyCatalyst); - addBlock(ModBlocks.conjurationCatalyst); - addBlock(ModBlocks.distributor); - addBlock(ModBlocks.manaVoid); - addBlock(ModBlocks.bellows); - addBlock(ModBlocks.manaDetector); - addBlock(ModBlocks.manaBomb); - addBlock(ModBlocks.ghostRail); - addItem(ModItems.poolMinecart); - addBlock(ModBlocks.pump); - addBlock(ModBlocks.rfGenerator); - addBlock(ModBlocks.spreader); - addBlock(ModBlocks.turntable); - addBlock(ModBlocks.prism); - addItem(ModItems.lens); - addItem(ModItems.manaGun); - addItem(ModItems.clip); - addItem(ModItems.spark); - addItem(ModItems.sparkUpgrade); - addBlock(ModBlocks.sparkChanger); - addItem(ModItems.corporeaSpark); - addBlock(ModBlocks.corporeaIndex); - addBlock(ModBlocks.corporeaFunnel); - addBlock(ModBlocks.corporeaInterceptor); - addBlock(ModBlocks.corporeaRetainer); - addBlock(ModBlocks.corporeaCrystalCube); - addBlock(ModBlocks.lightRelay); - addBlock(ModBlocks.lightLauncher); - addBlock(ModBlocks.cellBlock); - - // FLUFF - - addBlock(ModBlocks.doubleFlower1); - addBlock(ModBlocks.doubleFlower2); - addBlock(ModBlocks.shinyFlower); - addBlock(ModBlocks.floatingFlower); - addBlock(ModBlocks.floatingSpecialFlower); - addBlock(ModBlocks.petalBlock); - addBlock(ModBlocks.mushroom); - addBlock(ModBlocks.unstableBlock); - addBlock(ModBlocks.manaBeacon); - addItem(ModItems.signalFlare); - - addStack(new ItemStack(Blocks.dirt, 1, 1)); - addBlock(ModBlocks.dirtPath); - addBlock(ModFluffBlocks.dirtPathSlab); - - addBlock(ModBlocks.prismarine); - addBlock(ModBlocks.seaLamp); - addBlock(ModFluffBlocks.prismarineStairs); - addBlock(ModFluffBlocks.prismarineSlab); - addBlock(ModFluffBlocks.prismarineWall); - addBlock(ModFluffBlocks.prismarineBrickStairs); - addBlock(ModFluffBlocks.prismarineBrickSlab); - addBlock(ModFluffBlocks.darkPrismarineStairs); - addBlock(ModFluffBlocks.darkPrismarineSlab); - - addBlock(ModBlocks.blazeBlock); - - addBlock(ModBlocks.reedBlock); - addBlock(ModFluffBlocks.reedStairs); - addBlock(ModFluffBlocks.reedSlab); - addBlock(ModFluffBlocks.reedWall); - addBlock(ModBlocks.thatch); - addBlock(ModFluffBlocks.thatchStairs); - addBlock(ModFluffBlocks.thatchSlab); - - addBlock(ModBlocks.customBrick); - addBlock(ModFluffBlocks.netherBrickStairs); - addBlock(ModFluffBlocks.netherBrickSlab); - addBlock(ModFluffBlocks.soulBrickStairs); - addBlock(ModFluffBlocks.soulBrickSlab); - addBlock(ModFluffBlocks.snowBrickStairs); - addBlock(ModFluffBlocks.snowBrickSlab); - addBlock(ModFluffBlocks.tileStairs); - addBlock(ModFluffBlocks.tileSlab); - - addBlock(ModFluffBlocks.livingwoodStairs); - addBlock(ModFluffBlocks.livingwoodSlab); - addBlock(ModFluffBlocks.livingwoodWall); - addBlock(ModFluffBlocks.livingwoodPlankStairs); - addBlock(ModFluffBlocks.livingwoodPlankSlab); - addBlock(ModFluffBlocks.livingrockStairs); - addBlock(ModFluffBlocks.livingrockSlab); - addBlock(ModFluffBlocks.livingrockWall); - addBlock(ModFluffBlocks.livingrockBrickStairs); - addBlock(ModFluffBlocks.livingrockBrickSlab); - addBlock(ModFluffBlocks.dreamwoodStairs); - addBlock(ModFluffBlocks.dreamwoodSlab); - addBlock(ModFluffBlocks.dreamwoodWall); - addBlock(ModFluffBlocks.dreamwoodPlankStairs); - addBlock(ModFluffBlocks.dreamwoodPlankSlab); - addBlock(ModFluffBlocks.shimmerwoodPlankStairs); - addBlock(ModFluffBlocks.shimmerwoodPlankSlab); - addBlock(ModFluffBlocks.shimmerrockStairs); - addBlock(ModFluffBlocks.shimmerrockSlab); - - addItem(ModItems.quartz); - if (ConfigHandler.darkQuartzEnabled) { - addBlock(ModFluffBlocks.darkQuartz); - addBlock(ModFluffBlocks.darkQuartzSlab); - addBlock(ModFluffBlocks.darkQuartzStairs); - } - - addBlock(ModFluffBlocks.manaQuartz); - addBlock(ModFluffBlocks.manaQuartzSlab); - addBlock(ModFluffBlocks.manaQuartzStairs); - addBlock(ModFluffBlocks.blazeQuartz); - addBlock(ModFluffBlocks.blazeQuartzSlab); - addBlock(ModFluffBlocks.blazeQuartzStairs); - addBlock(ModFluffBlocks.lavenderQuartz); - addBlock(ModFluffBlocks.lavenderQuartzSlab); - addBlock(ModFluffBlocks.lavenderQuartzStairs); - addBlock(ModFluffBlocks.redQuartz); - addBlock(ModFluffBlocks.redQuartzSlab); - addBlock(ModFluffBlocks.redQuartzStairs); - addBlock(ModFluffBlocks.elfQuartz); - addBlock(ModFluffBlocks.elfQuartzSlab); - addBlock(ModFluffBlocks.elfQuartzStairs); - addBlock(ModFluffBlocks.sunnyQuartz); - addBlock(ModFluffBlocks.sunnyQuartzSlab); - addBlock(ModFluffBlocks.sunnyQuartzStairs); - - if (ConfigHandler.stones18Enabled) { - addBlock(ModFluffBlocks.stone); - for (int i = 0; i < 8; i++) addBlock(ModFluffBlocks.stoneStairs[i]); - for (int i = 0; i < 8; i++) addBlock(ModFluffBlocks.stoneSlabs[i]); - addBlock(ModFluffBlocks.stoneWall); - } - - addBlock(ModFluffBlocks.biomeStoneA); - addBlock(ModFluffBlocks.biomeStoneB); - for (int i = 0; i < 24; i++) addBlock(ModFluffBlocks.biomeStoneStairs[i]); - for (int i = 0; i < 24; i++) addBlock(ModFluffBlocks.biomeStoneSlabs[i]); - addBlock(ModFluffBlocks.biomeStoneWall); - - addBlock(ModFluffBlocks.pavement); - for (Block pavementStair : ModFluffBlocks.pavementStairs) addBlock(pavementStair); - for (Block pavementSlab : ModFluffBlocks.pavementSlabs) addBlock(pavementSlab); - - if (ConfigHandler.enderStuff19Enabled) { - addBlock(ModBlocks.endStoneBrick); - addBlock(ModFluffBlocks.endStoneSlab); - addBlock(ModFluffBlocks.endStoneStairs); - addBlock(ModFluffBlocks.enderBrickSlab); - addBlock(ModFluffBlocks.enderBrickStairs); - } - - addItem(ModItems.cosmetic); - } - - private void addItem(Item item) { - item.getSubItems(item, this, list); - } - - private void addBlock(Block block) { - ItemStack stack = new ItemStack(block); - block.getSubBlocks(stack.getItem(), this, list); - } - - private void addStack(ItemStack stack) { - list.add(stack); - } -} + public static BotaniaCreativeTab INSTANCE = new BotaniaCreativeTab(); + List list; + + public BotaniaCreativeTab() { + super(LibMisc.MOD_ID); + setNoTitle(); + setBackgroundImageName(LibResources.GUI_CREATIVE); + } + + @Override + public ItemStack getIconItemStack() { + return new ItemStack(ModItems.lexicon); + } + + @Override + public Item getTabIconItem() { + return getIconItemStack().getItem(); + } + + @Override + public boolean hasSearchBar() { + return true; + } + + @Override + public void displayAllReleventItems(List list) { + this.list = list; + + addItem(ModItems.lexicon); + + addBlock(ModBlocks.flower); + addBlock(ModBlocks.specialFlower); + addItem(ModItems.petal); + addItem(ModItems.pestleAndMortar); + addItem(ModItems.dye); + addItem(ModItems.fertilizer); + addItem(ModItems.flowerBag); + addItem(ModItems.blackLotus); + addItem(ModItems.twigWand); + addItem(ModItems.obedienceStick); + addItem(ModItems.manaResource); + addBlock(ModBlocks.storage); + addItem(ModItems.manaCookie); + addItem(ModItems.rune); + + addBlock(ModBlocks.avatar); + addItem(ModItems.dirtRod); + addItem(ModItems.skyDirtRod); + addItem(ModItems.cobbleRod); + addItem(ModItems.terraformRod); + addItem(ModItems.laputaShard); + addItem(ModItems.grassHorn); + addItem(ModItems.waterRod); + addItem(ModItems.openBucket); + addItem(ModItems.rainbowRod); + addBlock(ModBlocks.bifrostPerm); + addBlock(ModFluffBlocks.bifrostPane); + addBlock(ModBlocks.shimmerrock); + addBlock(ModBlocks.shimmerwoodPlanks); + addItem(ModItems.tornadoRod); + addItem(ModItems.fireRod); + addItem(ModItems.smeltRod); + addItem(ModItems.exchangeRod); + addItem(ModItems.diviningRod); + addItem(ModItems.gravityRod); + addItem(ModItems.missileRod); + addItem(ModItems.virus); + addItem(ModItems.slingshot); + addItem(ModItems.vineBall); + addItem(ModItems.regenIvy); + addItem(ModItems.keepIvy); + addItem(ModItems.worldSeed); + addItem(ModItems.overgrowthSeed); + addBlock(ModBlocks.enchantedSoil); + addItem(ModItems.grassSeeds); + addBlock(ModBlocks.altGrass); + if(Botania.thaumcraftLoaded) + addItem(ModItems.manaInkwell); + addBlock(ModBlocks.forestDrum); + addBlock(ModBlocks.forestEye); + addBlock(ModBlocks.enderEye); + addItem(ModItems.enderHand); + addItem(ModItems.spellCloth); + addItem(ModItems.craftingHalo); + addItem(ModItems.autocraftingHalo); + addItem(ModItems.spawnerMover); + addBlock(ModBlocks.spawnerClaw); + addBlock(ModBlocks.cocoon); + addBlock(ModBlocks.teruTeruBozu); + addItem(ModItems.slimeBottle); + addItem(ModItems.sextant); + addItem(ModItems.blackHoleTalisman); + + if(Botania.gardenOfGlassLoaded) { + addBlock(ModBlocks.root); + addItem(ModItems.waterBowl); + } + + addBlock(ModBlocks.livingrock); + addBlock(ModBlocks.livingwood); + addBlock(ModBlocks.openCrate); + addItem(ModItems.craftPattern); + addBlock(ModBlocks.platform); + addBlock(ModBlocks.alfPortal); + addBlock(ModBlocks.altar); + addBlock(ModBlocks.runeAltar); + addBlock(ModBlocks.terraPlate); + addBlock(ModBlocks.brewery); + addItem(ModItems.vial); + addItem(ModItems.brewVial); + addItem(ModItems.brewFlask); + addBlock(ModBlocks.incensePlate); + addItem(ModItems.incenseStick); + addItem(ModItems.bloodPendant); + addBlock(ModBlocks.felPumpkin); + addBlock(ModBlocks.pylon); + addBlock(ModBlocks.pistonRelay); + addBlock(ModBlocks.hourglass); + + addBlock(ModBlocks.redStringContainer); + addBlock(ModBlocks.redStringDispenser); + addBlock(ModBlocks.redStringFertilizer); + addBlock(ModBlocks.redStringComparator); + addBlock(ModBlocks.redStringRelay); + addBlock(ModBlocks.redStringInterceptor); + + addBlock(ModBlocks.tinyPotato); + addBlock(ModBlocks.starfield); + + addBlock(ModBlocks.dreamwood); + addBlock(ModBlocks.manaGlass); + addBlock(ModFluffBlocks.managlassPane); + addBlock(ModBlocks.elfGlass); + addBlock(ModFluffBlocks.alfglassPane); + + addItem(ModItems.glassPick); + addItem(ModItems.manasteelPick); + addItem(ModItems.manasteelShovel); + addItem(ModItems.manasteelAxe); + addItem(ModItems.manasteelShears); + addItem(ModItems.manasteelSword); + addItem(ModItems.enderDagger); + addItem(ModItems.livingwoodBow); + addItem(ModItems.manasteelHelm); + if(Botania.thaumcraftLoaded) + addItem(ModItems.manasteelHelmRevealing); + addItem(ModItems.manasteelChest); + addItem(ModItems.manasteelLegs); + addItem(ModItems.manasteelBoots); + addItem(ModItems.manaweaveHelm); + addItem(ModItems.manaweaveChest); + addItem(ModItems.manaweaveLegs); + addItem(ModItems.manaweaveBoots); + addItem(ModItems.elementiumPick); + addItem(ModItems.elementiumShovel); + addItem(ModItems.elementiumAxe); + addItem(ModItems.elementiumShears); + addItem(ModItems.elementiumSword); + addItem(ModItems.starSword); + addItem(ModItems.thunderSword); + addItem(ModItems.crystalBow); + addItem(ModItems.elementiumHelm); + if(Botania.thaumcraftLoaded) + addItem(ModItems.elementiumHelmRevealing); + addItem(ModItems.elementiumChest); + addItem(ModItems.elementiumLegs); + addItem(ModItems.elementiumBoots); + addItem(ModItems.terraSword); + addItem(ModItems.thornChakram); + addItem(ModItems.terraPick); + addItem(ModItems.terraAxe); + addItem(ModItems.temperanceStone); + addItem(ModItems.terrasteelHelm); + if(Botania.thaumcraftLoaded) + addItem(ModItems.terrasteelHelmRevealing); + addItem(ModItems.terrasteelChest); + addItem(ModItems.terrasteelLegs); + addItem(ModItems.terrasteelBoots); + addItem(ModItems.phantomInk); + addItem(ModItems.cacophonium); + addItem(ModItems.recordGaia1); + addItem(ModItems.recordGaia2); + addItem(ModItems.ancientWill); + addItem(ModItems.pinkinator); + addItem(ModItems.gaiaHead); + if(ConfigHandler.relicsEnabled) { + addItem(ModItems.dice); + addItem(ModItems.infiniteFruit); + addItem(ModItems.kingKey); + addItem(ModItems.flugelEye); + addItem(ModItems.thorRing); + addItem(ModItems.odinRing); + addItem(ModItems.lokiRing); + addItem(ModItems.aesirRing); + } + + addItem(ModItems.baubleBox); + addItem(ModItems.tinyPlanet); + addBlock(ModBlocks.tinyPlanet); + addItem(ModItems.manaRing); + addItem(ModItems.auraRing); + addItem(ModItems.manaRingGreater); + addItem(ModItems.auraRingGreater); + addItem(ModItems.waterRing); + addItem(ModItems.miningRing); + addItem(ModItems.magnetRing); + addItem(ModItems.magnetRingGreater); + addItem(ModItems.swapRing); + addItem(ModItems.reachRing); + addItem(ModItems.pixieRing); + addItem(ModItems.travelBelt); + addItem(ModItems.superTravelBelt); + addItem(ModItems.speedUpBelt); + addItem(ModItems.knockbackBelt); + addItem(ModItems.itemFinder); + addItem(ModItems.monocle); + addItem(ModItems.icePendant); + addItem(ModItems.lavaPendant); + addItem(ModItems.superLavaPendant); + addItem(ModItems.holyCloak); + addItem(ModItems.unholyCloak); + addItem(ModItems.goldLaurel); + addItem(ModItems.divaCharm); + addItem(ModItems.flightTiara); + + addItem(ModItems.manaTablet); + addItem(ModItems.manaMirror); + addItem(ModItems.manaBottle); + addBlock(ModBlocks.pool); + addBlock(ModBlocks.alchemyCatalyst); + addBlock(ModBlocks.conjurationCatalyst); + addBlock(ModBlocks.distributor); + addBlock(ModBlocks.manaVoid); + addBlock(ModBlocks.bellows); + addBlock(ModBlocks.manaDetector); + addBlock(ModBlocks.manaBomb); + addBlock(ModBlocks.ghostRail); + addItem(ModItems.poolMinecart); + addBlock(ModBlocks.pump); + addBlock(ModBlocks.rfGenerator); + addBlock(ModBlocks.spreader); + addBlock(ModBlocks.turntable); + addBlock(ModBlocks.prism); + addItem(ModItems.lens); + addItem(ModItems.manaGun); + addItem(ModItems.clip); + addItem(ModItems.spark); + addItem(ModItems.sparkUpgrade); + addBlock(ModBlocks.sparkChanger); + addItem(ModItems.corporeaSpark); + addBlock(ModBlocks.corporeaIndex); + addBlock(ModBlocks.corporeaFunnel); + addBlock(ModBlocks.corporeaInterceptor); + addBlock(ModBlocks.corporeaRetainer); + addBlock(ModBlocks.corporeaCrystalCube); + addBlock(ModBlocks.lightRelay); + addBlock(ModBlocks.lightLauncher); + addBlock(ModBlocks.cellBlock); + + // FLUFF + + addBlock(ModBlocks.doubleFlower1); + addBlock(ModBlocks.doubleFlower2); + addBlock(ModBlocks.shinyFlower); + addBlock(ModBlocks.floatingFlower); + addBlock(ModBlocks.floatingSpecialFlower); + addBlock(ModBlocks.petalBlock); + addBlock(ModBlocks.mushroom); + addBlock(ModBlocks.unstableBlock); + addBlock(ModBlocks.manaBeacon); + addItem(ModItems.signalFlare); + + addStack(new ItemStack(Blocks.dirt, 1, 1)); + addBlock(ModBlocks.dirtPath); + addBlock(ModFluffBlocks.dirtPathSlab); + + addBlock(ModBlocks.prismarine); + addBlock(ModBlocks.seaLamp); + addBlock(ModFluffBlocks.prismarineStairs); + addBlock(ModFluffBlocks.prismarineSlab); + addBlock(ModFluffBlocks.prismarineWall); + addBlock(ModFluffBlocks.prismarineBrickStairs); + addBlock(ModFluffBlocks.prismarineBrickSlab); + addBlock(ModFluffBlocks.darkPrismarineStairs); + addBlock(ModFluffBlocks.darkPrismarineSlab); + + addBlock(ModBlocks.blazeBlock); + + addBlock(ModBlocks.reedBlock); + addBlock(ModFluffBlocks.reedStairs); + addBlock(ModFluffBlocks.reedSlab); + addBlock(ModFluffBlocks.reedWall); + addBlock(ModBlocks.thatch); + addBlock(ModFluffBlocks.thatchStairs); + addBlock(ModFluffBlocks.thatchSlab); + + addBlock(ModBlocks.customBrick); + addBlock(ModFluffBlocks.netherBrickStairs); + addBlock(ModFluffBlocks.netherBrickSlab); + addBlock(ModFluffBlocks.soulBrickStairs); + addBlock(ModFluffBlocks.soulBrickSlab); + addBlock(ModFluffBlocks.snowBrickStairs); + addBlock(ModFluffBlocks.snowBrickSlab); + addBlock(ModFluffBlocks.tileStairs); + addBlock(ModFluffBlocks.tileSlab); + + addBlock(ModFluffBlocks.livingwoodStairs); + addBlock(ModFluffBlocks.livingwoodSlab); + addBlock(ModFluffBlocks.livingwoodWall); + addBlock(ModFluffBlocks.livingwoodPlankStairs); + addBlock(ModFluffBlocks.livingwoodPlankSlab); + addBlock(ModFluffBlocks.livingrockStairs); + addBlock(ModFluffBlocks.livingrockSlab); + addBlock(ModFluffBlocks.livingrockWall); + addBlock(ModFluffBlocks.livingrockBrickStairs); + addBlock(ModFluffBlocks.livingrockBrickSlab); + addBlock(ModFluffBlocks.dreamwoodStairs); + addBlock(ModFluffBlocks.dreamwoodSlab); + addBlock(ModFluffBlocks.dreamwoodWall); + addBlock(ModFluffBlocks.dreamwoodPlankStairs); + addBlock(ModFluffBlocks.dreamwoodPlankSlab); + addBlock(ModFluffBlocks.shimmerwoodPlankStairs); + addBlock(ModFluffBlocks.shimmerwoodPlankSlab); + addBlock(ModFluffBlocks.shimmerrockStairs); + addBlock(ModFluffBlocks.shimmerrockSlab); + + addItem(ModItems.quartz); + if(ConfigHandler.darkQuartzEnabled) { + addBlock(ModFluffBlocks.darkQuartz); + addBlock(ModFluffBlocks.darkQuartzSlab); + addBlock(ModFluffBlocks.darkQuartzStairs); + } + + addBlock(ModFluffBlocks.manaQuartz); + addBlock(ModFluffBlocks.manaQuartzSlab); + addBlock(ModFluffBlocks.manaQuartzStairs); + addBlock(ModFluffBlocks.blazeQuartz); + addBlock(ModFluffBlocks.blazeQuartzSlab); + addBlock(ModFluffBlocks.blazeQuartzStairs); + addBlock(ModFluffBlocks.lavenderQuartz); + addBlock(ModFluffBlocks.lavenderQuartzSlab); + addBlock(ModFluffBlocks.lavenderQuartzStairs); + addBlock(ModFluffBlocks.redQuartz); + addBlock(ModFluffBlocks.redQuartzSlab); + addBlock(ModFluffBlocks.redQuartzStairs); + addBlock(ModFluffBlocks.elfQuartz); + addBlock(ModFluffBlocks.elfQuartzSlab); + addBlock(ModFluffBlocks.elfQuartzStairs); + addBlock(ModFluffBlocks.sunnyQuartz); + addBlock(ModFluffBlocks.sunnyQuartzSlab); + addBlock(ModFluffBlocks.sunnyQuartzStairs); + + if(ConfigHandler.stones18Enabled) { + addBlock(ModFluffBlocks.stone); + for(int i = 0; i < 8; i++) + addBlock(ModFluffBlocks.stoneStairs[i]); + for(int i = 0; i < 8; i++) + addBlock(ModFluffBlocks.stoneSlabs[i]); + addBlock(ModFluffBlocks.stoneWall); + } + + addBlock(ModFluffBlocks.biomeStoneA); + addBlock(ModFluffBlocks.biomeStoneB); + for(int i = 0; i < 24; i++) + addBlock(ModFluffBlocks.biomeStoneStairs[i]); + for(int i = 0; i < 24; i++) + addBlock(ModFluffBlocks.biomeStoneSlabs[i]); + addBlock(ModFluffBlocks.biomeStoneWall); + + addBlock(ModFluffBlocks.pavement); + for (Block pavementStair : ModFluffBlocks.pavementStairs) + addBlock(pavementStair); + for (Block pavementSlab : ModFluffBlocks.pavementSlabs) + addBlock(pavementSlab); + + if(ConfigHandler.enderStuff19Enabled) { + addBlock(ModBlocks.endStoneBrick); + addBlock(ModFluffBlocks.endStoneSlab); + addBlock(ModFluffBlocks.endStoneStairs); + addBlock(ModFluffBlocks.enderBrickSlab); + addBlock(ModFluffBlocks.enderBrickStairs); + } + + addItem(ModItems.cosmetic); + } + + private void addItem(Item item) { + item.getSubItems(item, this, list); + } + + private void addBlock(Block block) { + ItemStack stack = new ItemStack(block); + block.getSubBlocks(stack.getItem(), this, list); + } + + private void addStack(ItemStack stack) { + list.add(stack); + } + +} \ No newline at end of file diff --git a/src/main/java/vazkii/botania/common/core/command/CommandOpen.java b/src/main/java/vazkii/botania/common/core/command/CommandOpen.java index 5038170bc4..6e6b3b2bc4 100644 --- a/src/main/java/vazkii/botania/common/core/command/CommandOpen.java +++ b/src/main/java/vazkii/botania/common/core/command/CommandOpen.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Sep 23, 2014, 9:50:14 PM (GMT)] */ package vazkii.botania.common.core.command; @@ -21,37 +21,37 @@ public class CommandOpen extends CommandBase { - @Override - public String getCommandName() { - return "botania-open"; - } - - @Override - public String getCommandUsage(ICommandSender p_71518_1_) { - return ""; - } - - @Override - public void processCommand(ICommandSender sender, String[] args) { - if (sender instanceof EntityPlayer) { - EntityPlayer player = (EntityPlayer) sender; - ItemStack stack = player.getCurrentEquippedItem(); - if (stack != null && stack.getItem() instanceof ItemLexicon) { - ItemLexicon.setForcedPage(stack, args[0]); - ItemLexicon.setQueueTicks(stack, 5); - } else - sender.addChatMessage(new ChatComponentTranslation("botaniamisc.noLexicon") - .setChatStyle(new ChatStyle().setColor(EnumChatFormatting.RED))); - } - } - - @Override - public int getRequiredPermissionLevel() { - return 0; - } - - @Override - public boolean canCommandSenderUseCommand(ICommandSender p_71519_1_) { - return p_71519_1_ instanceof EntityPlayer; - } + @Override + public String getCommandName() { + return "botania-open"; + } + + @Override + public String getCommandUsage(ICommandSender p_71518_1_) { + return ""; + } + + @Override + public void processCommand(ICommandSender sender, String[] args) { + if(sender instanceof EntityPlayer) { + EntityPlayer player = (EntityPlayer) sender; + ItemStack stack = player.getCurrentEquippedItem(); + if(stack != null && stack.getItem() instanceof ItemLexicon) { + ItemLexicon.setForcedPage(stack, args[0]); + ItemLexicon.setQueueTicks(stack, 5); + } else sender.addChatMessage(new ChatComponentTranslation("botaniamisc.noLexicon").setChatStyle(new ChatStyle().setColor(EnumChatFormatting.RED))); + } + } + + + @Override + public int getRequiredPermissionLevel() { + return 0; + } + + @Override + public boolean canCommandSenderUseCommand(ICommandSender p_71519_1_) { + return p_71519_1_ instanceof EntityPlayer; + } + } diff --git a/src/main/java/vazkii/botania/common/core/command/CommandShare.java b/src/main/java/vazkii/botania/common/core/command/CommandShare.java index 7d30e79d25..ef90019662 100644 --- a/src/main/java/vazkii/botania/common/core/command/CommandShare.java +++ b/src/main/java/vazkii/botania/common/core/command/CommandShare.java @@ -19,34 +19,35 @@ public class CommandShare extends CommandBase { - @Override - public String getCommandName() { - return "botania-share"; - } - - @Override - public String getCommandUsage(ICommandSender p_71518_1_) { - return ""; - } - - @Override - public void processCommand(ICommandSender sender, String[] args) { - String json = StatCollector.translateToLocal("botaniamisc.shareMsg"); - json = json.replaceAll("%name%", sender.getCommandSenderName()); - json = json.replaceAll("%entry%", args[0]); - json = json.replaceAll("%entryname%", StatCollector.translateToLocal(args[0])); - - IChatComponent component = IChatComponent.Serializer.func_150699_a(json); - MinecraftServer.getServer().getConfigurationManager().sendChatMsg(component); - } - - @Override - public int getRequiredPermissionLevel() { - return 0; - } - - @Override - public boolean canCommandSenderUseCommand(ICommandSender p_71519_1_) { - return p_71519_1_ instanceof EntityPlayer; - } + @Override + public String getCommandName() { + return "botania-share"; + } + + @Override + public String getCommandUsage(ICommandSender p_71518_1_) { + return ""; + } + + @Override + public void processCommand(ICommandSender sender, String[] args) { + String json = StatCollector.translateToLocal("botaniamisc.shareMsg"); + json = json.replaceAll("%name%", sender.getCommandSenderName()); + json = json.replaceAll("%entry%", args[0]); + json = json.replaceAll("%entryname%", StatCollector.translateToLocal(args[0])); + + IChatComponent component = IChatComponent.Serializer.func_150699_a(json); + MinecraftServer.getServer().getConfigurationManager().sendChatMsg(component); + } + + + @Override + public int getRequiredPermissionLevel() { + return 0; + } + + @Override + public boolean canCommandSenderUseCommand(ICommandSender p_71519_1_) { + return p_71519_1_ instanceof EntityPlayer; + } } diff --git a/src/main/java/vazkii/botania/common/core/command/CommandSkyblockSpread.java b/src/main/java/vazkii/botania/common/core/command/CommandSkyblockSpread.java index ea6d61f6b7..3be7ca0743 100644 --- a/src/main/java/vazkii/botania/common/core/command/CommandSkyblockSpread.java +++ b/src/main/java/vazkii/botania/common/core/command/CommandSkyblockSpread.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jul 17, 2015, 5:13:06 PM (GMT)] */ package vazkii.botania.common.core.command; @@ -21,45 +21,48 @@ public class CommandSkyblockSpread extends CommandBase { - @Override - public String getCommandName() { - return "botania-skyblock-spread"; - } + @Override + public String getCommandName() { + return "botania-skyblock-spread"; + } - @Override - public String getCommandUsage(ICommandSender p_71518_1_) { - return " []"; - } + @Override + public String getCommandUsage(ICommandSender p_71518_1_) { + return " []"; + } - @Override - public int getRequiredPermissionLevel() { - return 2; - } + @Override + public int getRequiredPermissionLevel() { + return 2; + } - @Override - public void processCommand(ICommandSender sender, String[] args) { - int maxAllowed = 1000000; - int minAllowed = 250; - int minDist = 100; + @Override + public void processCommand(ICommandSender sender, String[] args) { + int maxAllowed = 1000000; + int minAllowed = 250; + int minDist = 100; - int maxrange = 200000; - if (args.length == 2) maxrange = parseInt(sender, args[1]); + int maxrange = 200000; + if(args.length == 2) + maxrange = parseInt(sender, args[1]); - if (maxrange > maxAllowed) throw new CommandException("botaniamisc.skyblockRangeTooHigh"); - if (maxrange < minAllowed) - throw new CommandException(StatCollector.translateToLocal("botaniamisc.skyblockRangeTooLow")); + if(maxrange > maxAllowed) + throw new CommandException("botaniamisc.skyblockRangeTooHigh"); + if(maxrange < minAllowed) + throw new CommandException(StatCollector.translateToLocal("botaniamisc.skyblockRangeTooLow")); - EntityPlayer player = getPlayer(sender, args[0]); - if (player != null) { - ChunkCoordinates spawn = player.worldObj.getSpawnPoint(); - int x, z; + EntityPlayer player = getPlayer(sender, args[0]); + if(player != null) { + ChunkCoordinates spawn = player.worldObj.getSpawnPoint(); + int x, z; - do { - x = player.worldObj.rand.nextInt(maxrange) - maxrange / 2 + spawn.posX; - z = player.worldObj.rand.nextInt(maxrange) - maxrange / 2 + spawn.posZ; - } while (MathHelper.pointDistancePlane(x, z, spawn.posX, spawn.posZ) < minDist); + do { + x = player.worldObj.rand.nextInt(maxrange) - maxrange / 2 + spawn.posX; + z = player.worldObj.rand.nextInt(maxrange) - maxrange / 2 + spawn.posZ; + } while(MathHelper.pointDistancePlane(x, z, spawn.posX, spawn.posZ) < minDist); + + SkyblockWorldEvents.spawnPlayer(player, x, spawn.posY, z, true); + } + } - SkyblockWorldEvents.spawnPlayer(player, x, spawn.posY, z, true); - } - } } diff --git a/src/main/java/vazkii/botania/common/core/handler/AliasHandler.java b/src/main/java/vazkii/botania/common/core/handler/AliasHandler.java index cfb7d3e53e..aad356ac81 100644 --- a/src/main/java/vazkii/botania/common/core/handler/AliasHandler.java +++ b/src/main/java/vazkii/botania/common/core/handler/AliasHandler.java @@ -2,57 +2,63 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [May 16, 2014, 6:24:12 PM (GMT)] */ package vazkii.botania.common.core.handler; -import cpw.mods.fml.common.event.FMLMissingMappingsEvent; -import cpw.mods.fml.common.event.FMLMissingMappingsEvent.MissingMapping; -import cpw.mods.fml.common.registry.GameRegistry.Type; import java.util.List; + import net.minecraft.block.Block; import net.minecraft.item.Item; import vazkii.botania.client.lib.LibResources; +import cpw.mods.fml.common.event.FMLMissingMappingsEvent; +import cpw.mods.fml.common.event.FMLMissingMappingsEvent.MissingMapping; +import cpw.mods.fml.common.registry.GameRegistry.Type; public final class AliasHandler { - public static void onMissingMappings(FMLMissingMappingsEvent event) { - List mappings = event.get(); - for (MissingMapping mapping : mappings) { - String name = mapping.name.substring(LibResources.PREFIX_MOD.length() * 2); - - if (mapping.type == Type.ITEM) remapItem(mapping, getItem(name)); - else remapBlock(mapping, getBlock(name)); - } - } - - private static void remapItem(MissingMapping mapping, Item item) { - if (item != null) mapping.remap(item); - } - - private static void remapBlock(MissingMapping mapping, Block block) { - if (block != null) mapping.remap(block); - } - - private static Item getItem(String name) { - for (Object o : Item.itemRegistry.getKeys()) { - Item i = (Item) Item.itemRegistry.getObject(o); - if (i.getUnlocalizedName().substring("item.".length()).equals(name)) return i; - } - - return null; - } - - private static Block getBlock(String name) { - for (Object o : Block.blockRegistry.getKeys()) { - Block b = (Block) Block.blockRegistry.getObject(o); - if (b.getUnlocalizedName().substring("tile.".length()).equals(name)) return b; - } - - return null; - } + public static void onMissingMappings(FMLMissingMappingsEvent event) { + List mappings = event.get(); + for(MissingMapping mapping : mappings) { + String name = mapping.name.substring(LibResources.PREFIX_MOD.length() * 2); + + if(mapping.type == Type.ITEM) + remapItem(mapping, getItem(name)); + else remapBlock(mapping, getBlock(name)); + } + } + + private static void remapItem(MissingMapping mapping, Item item) { + if(item != null) + mapping.remap(item); + } + + private static void remapBlock(MissingMapping mapping, Block block) { + if(block != null) + mapping.remap(block); + } + + private static Item getItem(String name) { + for(Object o : Item.itemRegistry.getKeys()) { + Item i = (Item) Item.itemRegistry.getObject(o); + if(i.getUnlocalizedName().substring("item.".length()).equals(name)) + return i; + } + + return null; + } + + private static Block getBlock(String name) { + for(Object o : Block.blockRegistry.getKeys()) { + Block b = (Block) Block.blockRegistry.getObject(o); + if(b.getUnlocalizedName().substring("tile.".length()).equals(name)) + return b; + } + + return null; + } } diff --git a/src/main/java/vazkii/botania/common/core/handler/BiomeDecorationHandler.java b/src/main/java/vazkii/botania/common/core/handler/BiomeDecorationHandler.java index be9cc23fc5..af6a76ac69 100644 --- a/src/main/java/vazkii/botania/common/core/handler/BiomeDecorationHandler.java +++ b/src/main/java/vazkii/botania/common/core/handler/BiomeDecorationHandler.java @@ -2,18 +2,14 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jan 19, 2014, 10:16:49 PM (GMT)] */ package vazkii.botania.common.core.handler; -import cpw.mods.fml.common.eventhandler.Event.Result; -import cpw.mods.fml.common.eventhandler.EventPriority; -import cpw.mods.fml.common.eventhandler.SubscribeEvent; -import java.util.Arrays; import net.minecraftforge.event.terraingen.DecorateBiomeEvent; import net.minecraftforge.event.terraingen.DecorateBiomeEvent.Decorate.EventType; import vazkii.botania.api.item.IFlowerlessBiome; @@ -23,92 +19,93 @@ import vazkii.botania.common.block.subtile.generating.SubTileDaybloom; import vazkii.botania.common.block.tile.TileSpecialFlower; import vazkii.botania.common.lib.LibBlockNames; +import cpw.mods.fml.common.eventhandler.Event.Result; +import cpw.mods.fml.common.eventhandler.EventPriority; +import cpw.mods.fml.common.eventhandler.SubscribeEvent; + +import java.util.Arrays; public class BiomeDecorationHandler { - @SubscribeEvent(priority = EventPriority.LOWEST) - public void onWorldDecoration(DecorateBiomeEvent.Decorate event) { - if ((event.getResult() == Result.ALLOW || event.getResult() == Result.DEFAULT) - && event.type == EventType.FLOWERS) { - boolean flowers = true; - if (event.world.provider instanceof IFlowerlessWorld) - flowers = ((IFlowerlessWorld) event.world.provider).generateFlowers(event.world); - else if (event.world.getBiomeGenForCoords(event.chunkX, event.chunkZ) instanceof IFlowerlessBiome) - flowers = ((IFlowerlessBiome) event.world.getBiomeGenForCoords(event.chunkX, event.chunkZ)) - .canGenerateFlowers(event.world, event.chunkX, event.chunkZ); + @SubscribeEvent(priority = EventPriority.LOWEST) + public void onWorldDecoration(DecorateBiomeEvent.Decorate event) { + if((event.getResult() == Result.ALLOW || event.getResult() == Result.DEFAULT) && event.type == EventType.FLOWERS) { + boolean flowers = true; + if(event.world.provider instanceof IFlowerlessWorld) + flowers = ((IFlowerlessWorld) event.world.provider).generateFlowers(event.world); + else if(event.world.getBiomeGenForCoords(event.chunkX, event.chunkZ) instanceof IFlowerlessBiome) + flowers = ((IFlowerlessBiome) event.world.getBiomeGenForCoords(event.chunkX, event.chunkZ)).canGenerateFlowers(event.world, event.chunkX, event.chunkZ); - if (!flowers) return; + if(!flowers) + return; - if (ConfigHandler.flowerDimensionWhitelist.length == 0 - || Arrays.stream(ConfigHandler.flowerDimensionWhitelist) - .anyMatch(d -> d == event.world.provider.dimensionId)) { - if (Arrays.stream(ConfigHandler.flowerDimensionBlacklist) - .noneMatch(d -> d == event.world.provider.dimensionId)) { - generateFlowers(event); - } - } + if (ConfigHandler.flowerDimensionWhitelist.length == 0 + || Arrays.stream(ConfigHandler.flowerDimensionWhitelist).anyMatch( + d -> d == event.world.provider.dimensionId + )) { + if (Arrays.stream(ConfigHandler.flowerDimensionBlacklist).noneMatch( + d -> d == event.world.provider.dimensionId + )) { + generateFlowers(event); + } + } - if (ConfigHandler.mushroomDimensionWhitelist.length == 0 - || Arrays.stream(ConfigHandler.mushroomDimensionWhitelist) - .anyMatch(d -> d == event.world.provider.dimensionId)) { - if (Arrays.stream(ConfigHandler.mushroomDimensionBlacklist) - .noneMatch(d -> d == event.world.provider.dimensionId)) { - generateMushrooms(event); - } - } - } - } + if (ConfigHandler.mushroomDimensionWhitelist.length == 0 + || Arrays.stream(ConfigHandler.mushroomDimensionWhitelist).anyMatch( + d -> d == event.world.provider.dimensionId + )) { + if (Arrays.stream(ConfigHandler.mushroomDimensionBlacklist).noneMatch( + d -> d == event.world.provider.dimensionId + )) { + generateMushrooms(event); + } + } + } + } - private void generateFlowers(DecorateBiomeEvent.Decorate event) { - int dist = Math.min(8, Math.max(1, ConfigHandler.flowerPatchSize)); - for (int i = 0; i < ConfigHandler.flowerQuantity; i++) { - if (event.rand.nextInt(ConfigHandler.flowerPatchChance) == 0) { - int x = event.chunkX + event.rand.nextInt(16) + 8; - int z = event.chunkZ + event.rand.nextInt(16) + 8; - int y = event.world.getTopSolidOrLiquidBlock(x, z); + private void generateFlowers(DecorateBiomeEvent.Decorate event) { + int dist = Math.min(8, Math.max(1, ConfigHandler.flowerPatchSize)); + for(int i = 0; i < ConfigHandler.flowerQuantity; i++) { + if(event.rand.nextInt(ConfigHandler.flowerPatchChance) == 0) { + int x = event.chunkX + event.rand.nextInt(16) + 8; + int z = event.chunkZ + event.rand.nextInt(16) + 8; + int y = event.world.getTopSolidOrLiquidBlock(x, z); - int color = event.rand.nextInt(16); - boolean primus = event.rand.nextInt(380) == 0; + int color = event.rand.nextInt(16); + boolean primus = event.rand.nextInt(380) == 0; - for (int j = 0; j < ConfigHandler.flowerDensity * ConfigHandler.flowerPatchChance; j++) { - int x1 = x + event.rand.nextInt(dist * 2) - dist; - int y1 = y + event.rand.nextInt(4) - event.rand.nextInt(4); - int z1 = z + event.rand.nextInt(dist * 2) - dist; + for(int j = 0; j < ConfigHandler.flowerDensity * ConfigHandler.flowerPatchChance; j++) { + int x1 = x + event.rand.nextInt(dist * 2) - dist; + int y1 = y + event.rand.nextInt(4) - event.rand.nextInt(4); + int z1 = z + event.rand.nextInt(dist * 2) - dist; - if (event.world.isAirBlock(x1, y1, z1) - && (!event.world.provider.hasNoSky || y1 < 127) - && ModBlocks.flower.canBlockStay(event.world, x1, y1, z1)) { - if (primus) { - event.world.setBlock(x1, y1, z1, ModBlocks.specialFlower, 0, 2); - TileSpecialFlower flower = (TileSpecialFlower) event.world.getTileEntity(x1, y1, z1); - flower.setSubTile( - event.rand.nextBoolean() - ? LibBlockNames.SUBTILE_NIGHTSHADE_PRIME - : LibBlockNames.SUBTILE_DAYBLOOM_PRIME); - SubTileDaybloom subtile = (SubTileDaybloom) flower.getSubTile(); - subtile.setPrimusPosition(); - } else { - event.world.setBlock(x1, y1, z1, ModBlocks.flower, color, 2); - if (event.rand.nextDouble() < ConfigHandler.flowerTallChance - && ((BlockModFlower) ModBlocks.flower) - .func_149851_a(event.world, x1, y1, z1, false)) - BlockModFlower.placeDoubleFlower(event.world, x1, y1, z1, color, 0); - } - } - } - } - } - } + if(event.world.isAirBlock(x1, y1, z1) && (!event.world.provider.hasNoSky || y1 < 127) && ModBlocks.flower.canBlockStay(event.world, x1, y1, z1)) { + if(primus) { + event.world.setBlock(x1, y1, z1, ModBlocks.specialFlower, 0, 2); + TileSpecialFlower flower = (TileSpecialFlower) event.world.getTileEntity(x1, y1, z1); + flower.setSubTile(event.rand.nextBoolean() ? LibBlockNames.SUBTILE_NIGHTSHADE_PRIME : LibBlockNames.SUBTILE_DAYBLOOM_PRIME); + SubTileDaybloom subtile = (SubTileDaybloom) flower.getSubTile(); + subtile.setPrimusPosition(); + } else { + event.world.setBlock(x1, y1, z1, ModBlocks.flower, color, 2); + if(event.rand.nextDouble() < ConfigHandler.flowerTallChance && ((BlockModFlower) ModBlocks.flower).func_149851_a(event.world, x1, y1, z1, false)) + BlockModFlower.placeDoubleFlower(event.world, x1, y1, z1, color, 0); + } + } + } + } + } + } - private void generateMushrooms(DecorateBiomeEvent.Decorate event) { - for (int i = 0; i < ConfigHandler.mushroomQuantity; i++) { - int x = event.chunkX + event.rand.nextInt(16) + 8; - int z = event.chunkZ + event.rand.nextInt(16) + 8; - int y = event.rand.nextInt(26) + 4; + private void generateMushrooms(DecorateBiomeEvent.Decorate event) { + for(int i = 0; i < ConfigHandler.mushroomQuantity; i++) { + int x = event.chunkX + event.rand.nextInt(16) + 8; + int z = event.chunkZ + event.rand.nextInt(16) + 8; + int y = event.rand.nextInt(26) + 4; - int color = event.rand.nextInt(16); - if (event.world.isAirBlock(x, y, z) && ModBlocks.mushroom.canBlockStay(event.world, x, y, z)) - event.world.setBlock(x, y, z, ModBlocks.mushroom, color, 2); - } - } -} + int color = event.rand.nextInt(16); + if(event.world.isAirBlock(x, y, z) && ModBlocks.mushroom.canBlockStay(event.world, x, y, z)) + event.world.setBlock(x, y, z, ModBlocks.mushroom, color, 2); + } + } +} \ No newline at end of file diff --git a/src/main/java/vazkii/botania/common/core/handler/ChestGenHandler.java b/src/main/java/vazkii/botania/common/core/handler/ChestGenHandler.java index 6fab64744e..b5b1315d9a 100644 --- a/src/main/java/vazkii/botania/common/core/handler/ChestGenHandler.java +++ b/src/main/java/vazkii/botania/common/core/handler/ChestGenHandler.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jul 15, 2014, 3:17:00 PM (GMT)] */ package vazkii.botania.common.core.handler; @@ -17,37 +17,38 @@ public final class ChestGenHandler { - public static void init() { - String c = ChestGenHooks.BONUS_CHEST; - ChestGenHooks.addItem(c, new WeightedRandomChestContent(new ItemStack(ModItems.lexicon), 1, 1, 7)); - ChestGenHooks.addItem(c, new WeightedRandomChestContent(new ItemStack(ModItems.blackLotus), 1, 1, 1)); - - c = ChestGenHooks.STRONGHOLD_CORRIDOR; - ChestGenHooks.addItem(c, new WeightedRandomChestContent(new ItemStack(ModItems.manaResource, 1, 1), 1, 1, 8)); - ChestGenHooks.addItem(c, new WeightedRandomChestContent(new ItemStack(ModItems.manaResource, 1, 1), 1, 3, 2)); - ChestGenHooks.addItem(c, new WeightedRandomChestContent(new ItemStack(ModItems.blackLotus), 1, 1, 6)); - ChestGenHooks.addItem(c, new WeightedRandomChestContent(new ItemStack(ModItems.overgrowthSeed), 1, 1, 2)); - - c = ChestGenHooks.DUNGEON_CHEST; - ChestGenHooks.addItem(c, new WeightedRandomChestContent(new ItemStack(ModItems.manaResource, 1, 0), 1, 5, 9)); - ChestGenHooks.addItem(c, new WeightedRandomChestContent(new ItemStack(ModItems.lexicon), 1, 1, 6)); - ChestGenHooks.addItem(c, new WeightedRandomChestContent(new ItemStack(ModItems.manaBottle), 1, 1, 5)); - ChestGenHooks.addItem(c, new WeightedRandomChestContent(new ItemStack(ModItems.blackLotus), 1, 1, 6)); - ChestGenHooks.addItem(c, new WeightedRandomChestContent(new ItemStack(ModItems.overgrowthSeed), 1, 1, 2)); - - c = ChestGenHooks.PYRAMID_DESERT_CHEST; - ChestGenHooks.addItem(c, new WeightedRandomChestContent(new ItemStack(ModItems.blackLotus), 1, 1, 6)); - ChestGenHooks.addItem(c, new WeightedRandomChestContent(new ItemStack(ModItems.overgrowthSeed), 1, 1, 2)); - - c = ChestGenHooks.MINESHAFT_CORRIDOR; - ChestGenHooks.addItem(c, new WeightedRandomChestContent(new ItemStack(ModItems.blackLotus), 1, 1, 6)); - ChestGenHooks.addItem(c, new WeightedRandomChestContent(new ItemStack(ModItems.overgrowthSeed), 1, 1, 2)); - - c = ChestGenHooks.PYRAMID_JUNGLE_CHEST; - ChestGenHooks.addItem(c, new WeightedRandomChestContent(new ItemStack(ModItems.blackLotus), 1, 1, 6)); - ChestGenHooks.addItem(c, new WeightedRandomChestContent(new ItemStack(ModItems.overgrowthSeed), 1, 1, 2)); - - c = ChestGenHooks.VILLAGE_BLACKSMITH; - ChestGenHooks.addItem(c, new WeightedRandomChestContent(new ItemStack(ModItems.blackLotus), 1, 1, 6)); - } + public static void init() { + String c = ChestGenHooks.BONUS_CHEST; + ChestGenHooks.addItem(c, new WeightedRandomChestContent(new ItemStack(ModItems.lexicon), 1, 1, 7)); + ChestGenHooks.addItem(c, new WeightedRandomChestContent(new ItemStack(ModItems.blackLotus), 1, 1, 1)); + + c = ChestGenHooks.STRONGHOLD_CORRIDOR; + ChestGenHooks.addItem(c, new WeightedRandomChestContent(new ItemStack(ModItems.manaResource, 1, 1), 1, 1, 8)); + ChestGenHooks.addItem(c, new WeightedRandomChestContent(new ItemStack(ModItems.manaResource, 1, 1), 1, 3, 2)); + ChestGenHooks.addItem(c, new WeightedRandomChestContent(new ItemStack(ModItems.blackLotus), 1, 1, 6)); + ChestGenHooks.addItem(c, new WeightedRandomChestContent(new ItemStack(ModItems.overgrowthSeed), 1, 1, 2)); + + c = ChestGenHooks.DUNGEON_CHEST; + ChestGenHooks.addItem(c, new WeightedRandomChestContent(new ItemStack(ModItems.manaResource, 1, 0), 1, 5, 9)); + ChestGenHooks.addItem(c, new WeightedRandomChestContent(new ItemStack(ModItems.lexicon), 1, 1, 6)); + ChestGenHooks.addItem(c, new WeightedRandomChestContent(new ItemStack(ModItems.manaBottle), 1, 1, 5)); + ChestGenHooks.addItem(c, new WeightedRandomChestContent(new ItemStack(ModItems.blackLotus), 1, 1, 6)); + ChestGenHooks.addItem(c, new WeightedRandomChestContent(new ItemStack(ModItems.overgrowthSeed), 1, 1, 2)); + + c = ChestGenHooks.PYRAMID_DESERT_CHEST; + ChestGenHooks.addItem(c, new WeightedRandomChestContent(new ItemStack(ModItems.blackLotus), 1, 1, 6)); + ChestGenHooks.addItem(c, new WeightedRandomChestContent(new ItemStack(ModItems.overgrowthSeed), 1, 1, 2)); + + c = ChestGenHooks.MINESHAFT_CORRIDOR; + ChestGenHooks.addItem(c, new WeightedRandomChestContent(new ItemStack(ModItems.blackLotus), 1, 1, 6)); + ChestGenHooks.addItem(c, new WeightedRandomChestContent(new ItemStack(ModItems.overgrowthSeed), 1, 1, 2)); + + c = ChestGenHooks.PYRAMID_JUNGLE_CHEST; + ChestGenHooks.addItem(c, new WeightedRandomChestContent(new ItemStack(ModItems.blackLotus), 1, 1, 6)); + ChestGenHooks.addItem(c, new WeightedRandomChestContent(new ItemStack(ModItems.overgrowthSeed), 1, 1, 2)); + + c = ChestGenHooks.VILLAGE_BLACKSMITH; + ChestGenHooks.addItem(c, new WeightedRandomChestContent(new ItemStack(ModItems.blackLotus), 1, 1, 6)); + } + } diff --git a/src/main/java/vazkii/botania/common/core/handler/CommonTickHandler.java b/src/main/java/vazkii/botania/common/core/handler/CommonTickHandler.java index 96818ff975..5ebadc9691 100644 --- a/src/main/java/vazkii/botania/common/core/handler/CommonTickHandler.java +++ b/src/main/java/vazkii/botania/common/core/handler/CommonTickHandler.java @@ -2,49 +2,50 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Apr 14, 2014, 5:10:16 PM (GMT)] */ package vazkii.botania.common.core.handler; +import vazkii.botania.api.corporea.CorporeaHelper; import cpw.mods.fml.common.eventhandler.SubscribeEvent; import cpw.mods.fml.common.gameevent.TickEvent.ClientTickEvent; import cpw.mods.fml.common.gameevent.TickEvent.Phase; import cpw.mods.fml.common.gameevent.TickEvent.WorldTickEvent; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; -import vazkii.botania.api.corporea.CorporeaHelper; public final class CommonTickHandler { - @SubscribeEvent - public void onTick(WorldTickEvent event) { - if (event.phase == Phase.END) { - /*List entities = new ArrayList(event.world.loadedEntityList); - for(Entity entity : entities) - if(entity instanceof EntityItem) - TerrasteelCraftingHandler.onEntityUpdate((EntityItem) entity);*/ + @SubscribeEvent + public void onTick(WorldTickEvent event) { + if(event.phase == Phase.END) { + /*List entities = new ArrayList(event.world.loadedEntityList); + for(Entity entity : entities) + if(entity instanceof EntityItem) + TerrasteelCraftingHandler.onEntityUpdate((EntityItem) entity);*/ + + CorporeaHelper.clearCache(); + } + } - CorporeaHelper.clearCache(); - } - } + @SideOnly(Side.CLIENT) + @SubscribeEvent + public void onTick(ClientTickEvent event) { + if(event.phase == Phase.END) { + /*World world = Minecraft.getMinecraft().theWorld; + if(world != null) { + List entities = new ArrayList(world.loadedEntityList); + for(Entity entity : entities) + if(entity instanceof EntityItem) + TerrasteelCraftingHandler.onEntityUpdate((EntityItem) entity); + }*/ - @SideOnly(Side.CLIENT) - @SubscribeEvent - public void onTick(ClientTickEvent event) { - if (event.phase == Phase.END) { - /*World world = Minecraft.getMinecraft().theWorld; - if(world != null) { - List entities = new ArrayList(world.loadedEntityList); - for(Entity entity : entities) - if(entity instanceof EntityItem) - TerrasteelCraftingHandler.onEntityUpdate((EntityItem) entity); - }*/ + CorporeaHelper.clearCache(); + } + } - CorporeaHelper.clearCache(); - } - } } diff --git a/src/main/java/vazkii/botania/common/core/handler/ConfigHandler.java b/src/main/java/vazkii/botania/common/core/handler/ConfigHandler.java index 404f30fc88..ef734af58f 100644 --- a/src/main/java/vazkii/botania/common/core/handler/ConfigHandler.java +++ b/src/main/java/vazkii/botania/common/core/handler/ConfigHandler.java @@ -2,23 +2,20 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jan 13, 2014, 9:01:32 PM (GMT)] */ package vazkii.botania.common.core.handler; -import cpw.mods.fml.client.event.ConfigChangedEvent; -import cpw.mods.fml.common.FMLCommonHandler; -import cpw.mods.fml.common.Loader; -import cpw.mods.fml.common.eventhandler.SubscribeEvent; import java.io.File; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; + import net.minecraft.entity.player.EntityPlayer; import net.minecraft.potion.Potion; import net.minecraft.util.ChatComponentText; @@ -27,502 +24,491 @@ import net.minecraft.util.EnumChatFormatting; import net.minecraftforge.common.config.Configuration; import net.minecraftforge.common.config.Property; +import vazkii.botania.common.Botania; import vazkii.botania.common.lib.LibMisc; import vazkii.botania.common.lib.LibPotionNames; +import cpw.mods.fml.client.event.ConfigChangedEvent; +import cpw.mods.fml.common.FMLCommonHandler; +import cpw.mods.fml.common.Loader; +import cpw.mods.fml.common.eventhandler.SubscribeEvent; public final class ConfigHandler { - public static Configuration config; - public static ConfigAdaptor adaptor; - - private static final String CATEGORY_POTIONS = "potions"; - - public static int hardcorePassiveGeneration = 72000; - - public static boolean useAdaptativeConfig = true; - - public static boolean enableDefaultRecipes = false; - - public static boolean useShaders = true; - public static boolean lexiconRotatingItems = true; - public static boolean lexiconJustifiedText = false; - public static boolean subtlePowerSystem = false; - public static boolean staticWandBeam = false; - public static boolean boundBlockWireframe = true; - public static boolean lexicon3dModel = true; - public static boolean oldPylonModel = false; - public static double flowerParticleFrequency = 0.75F; - public static boolean blockBreakParticles = true; - public static boolean blockBreakParticlesTool = true; - public static boolean elfPortalParticlesEnabled = true; - public static boolean chargingAnimationEnabled = true; - public static boolean useVanillaParticleLimiter = true; - public static boolean silentSpreaders = false; - public static boolean renderBaubles = true; - public static boolean enableSeasonalFeatures = true; - public static boolean useShiftForQuickLookup = false; - public static boolean enableArmorModels = true; - public static boolean enableFancySkybox = true; - public static boolean enableFancySkyboxInNormalWorlds = false; - - public static int manaBarHeight = 29; - public static int flightBarHeight = 49; - public static int flightBarBreathHeight = 59; - public static int glSecondaryTextureUnit = 7; - - public static boolean altFlowerTextures = false; - public static boolean matrixMode = false; - public static boolean referencesEnabled = true; - - public static int spreaderPositionShift = 1; - public static boolean flowerForceCheck = true; - public static boolean enderPickpocketEnabled = true; - - public static boolean fallenKanadeEnabled = true; - public static boolean darkQuartzEnabled = true; - public static boolean enchanterEnabled = true; - public static boolean fluxfieldEnabled = true; - public static boolean relicsEnabled = true; - public static boolean stones18Enabled = true; - public static boolean ringOfOdinFireResist = true; - public static boolean enderStuff19Enabled = true; - public static boolean invertMagnetRing = false; - public static boolean enableThaumcraftStablizers = true; - - public static int harvestLevelWeight = 2; - public static int harvestLevelBore = 3; - - public static int flowerQuantity = 0; - public static int flowerDensity = 2; - public static int flowerPatchSize = 6; - public static int flowerPatchChance = 16; - public static double flowerTallChance = 0.05; - public static int mushroomQuantity = 40; - - public static int[] flowerDimensionWhitelist = new int[] {}; - public static int[] flowerDimensionBlacklist = new int[] {}; - public static int[] mushroomDimensionWhitelist = new int[] {}; - public static int[] mushroomDimensionBlacklist = new int[] {}; - - private static boolean verifiedPotionArray = false; - private static int potionArrayLimit = 0; - - public static int potionIDSoulCross = 91; - public static int potionIDFeatherfeet = 92; - public static int potionIDEmptiness = 93; - public static int potionIDBloodthirst = 94; - public static int potionIDAllure = 95; - public static int potionIDClear = 96; - - public static void loadConfig(File configFile) { - config = new Configuration(configFile); - - config.load(); - load(); - - FMLCommonHandler.instance().bus().register(new ChangeListener()); - } - - public static void load() { - String desc; - - desc = - "Set this to false to disable the Adaptative Config. Adaptative Config changes any default config values from old versions to the new defaults to make sure you aren't missing out on changes because of old configs. It will not touch any values that were changed manually."; - useAdaptativeConfig = loadPropBool("adaptativeConfig.enabled", desc, useAdaptativeConfig); - adaptor = new ConfigAdaptor(useAdaptativeConfig); - - desc = "Set this to false to disable the use of shaders for some of the mod's renders."; - useShaders = loadPropBool("shaders.enabled", desc, useShaders); - - desc = "Set this to false to disable the rotating items in the petal and rune entries in the Lexica Botania."; - lexiconRotatingItems = loadPropBool("lexicon.enable.rotatingItems", desc, lexiconRotatingItems); - - desc = "Set this to true to enable justified text in the Lexica Botania's text pages."; - lexiconJustifiedText = loadPropBool("lexicon.enable.justifiedText", desc, lexiconJustifiedText); - - desc = - "Set this to true to set the power system's particles to be a lot more subtle. Good for low-end systems, if the particles are causing lag."; - subtlePowerSystem = loadPropBool("powerSystem.subtle", desc, subtlePowerSystem); - - desc = - "Set this to true to use a static wand beam that shows every single position of the burst, similar to the way it used to work on old Botania versions. Warning: Disabled by default because it may be laggy."; - staticWandBeam = loadPropBool("wandBeam.static", desc, staticWandBeam); - - desc = - "Set this to false to disable the wireframe when looking a block bound to something (spreaders, flowers, etc)."; - boundBlockWireframe = loadPropBool("boundBlock.wireframe.enabled", desc, boundBlockWireframe); - - desc = "Set this to false to disable the animated 3D render for the Lexica Botania."; - lexicon3dModel = loadPropBool("lexicon.render.3D", desc, lexicon3dModel); - - desc = "Set this to true to use the old (non-.obj, pre beta18) pylon model"; - oldPylonModel = loadPropBool("pylonModel.old", desc, oldPylonModel); - - desc = "The frequency in which particles spawn from normal (worldgen) mystical flowers"; - flowerParticleFrequency = loadPropDouble("flowerParticles.frequency", desc, flowerParticleFrequency); - - desc = "Set this to false to remove the block breaking particles from the flowers and other items in the mod."; - blockBreakParticles = loadPropBool("blockBreakingParticles.enabled", desc, blockBreakParticles); - - desc = - "Set this to false to remove the block breaking particles from the Mana Shatterer, as there can be a good amount in higher levels."; - blockBreakParticlesTool = loadPropBool("blockBreakingParticlesTool.enabled", desc, blockBreakParticlesTool); - - desc = "Set this to false to disable the particles in the elven portal."; - elfPortalParticlesEnabled = loadPropBool("elfPortal.particles.enabled", desc, elfPortalParticlesEnabled); - - desc = "Set this to false to disable the animation when an item is charging on top of a mana pool."; - chargingAnimationEnabled = loadPropBool("chargeAnimation.enabled", desc, chargingAnimationEnabled); - - desc = - "Set this to false to always display all particles regardless of the \"Particles\" setting in the Vanilla options menu."; - useVanillaParticleLimiter = loadPropBool("vanillaParticleConfig.enabled", desc, useVanillaParticleLimiter); - - desc = "Set this to true to disable the mana spreader shooting sound."; - silentSpreaders = loadPropBool("manaSpreaders.silent", desc, silentSpreaders); - - desc = "Set this to false to disable rendering of baubles in the player."; - renderBaubles = loadPropBool("baubleRender.enabled", desc, renderBaubles); - - desc = "Set this to false to disable seasonal features, such as halloween and christmas."; - enableSeasonalFeatures = loadPropBool("seasonalFeatures.enabled", desc, enableSeasonalFeatures); - - desc = "Set this to true to use Shift instead of Ctrl for the inventory lexica botania quick lookup feature."; - useShiftForQuickLookup = loadPropBool("quickLookup.useShift", desc, useShiftForQuickLookup); - - desc = "Set this to false to disable custom armor models."; - enableArmorModels = loadPropBool("armorModels.enable", desc, enableArmorModels); - - desc = "Set this to false to disable the fancy skybox in Garden of Glass."; - enableFancySkybox = loadPropBool("fancySkybox.enable", desc, enableFancySkybox); - - desc = - "Set this to true to enable the fancy skybox in non Garden of Glass worlds. (Does not require Garden of Glass loaded to use, needs 'fancySkybox.enable' to be true as well)"; - enableFancySkyboxInNormalWorlds = - loadPropBool("fancySkybox.normalWorlds", desc, enableFancySkyboxInNormalWorlds); - - desc = - "The height of the mana display bar in above the XP bar. You can change this if you have a mod that changes where the XP bar is."; - manaBarHeight = loadPropInt("manaBar.height", desc, manaBarHeight); - - desc = - "The height of the Flugel Tiara flight bar. You can change this if you have a mod that adds a bar in that spot."; - flightBarHeight = loadPropInt("flightBar.height", desc, flightBarHeight); - - desc = - "The height of the Flugel Tiara flight bar if your breath bar is shown. You can change this if you have a mod that adds a bar in that spot."; - flightBarBreathHeight = loadPropInt("flightBarBreath.height", desc, flightBarBreathHeight); - - desc = - "The GL Texture Unit to use for the secondary sampler passed in to the Lexica Botania's category button shader. DO NOT TOUCH THIS IF YOU DON'T KNOW WHAT YOU'RE DOING"; - glSecondaryTextureUnit = loadPropInt("shaders.secondaryUnit", desc, glSecondaryTextureUnit); - - desc = - "Set this to true to use alternate flower textures by Futureazoo, not all flowers are textured. http://redd.it/2b3o3f"; - altFlowerTextures = loadPropBool("flowerTextures.alt", desc, altFlowerTextures); - - desc = "Set this to true if you are the chosen one. For lovers of glitch art and just general mad people."; - matrixMode = loadPropBool("matrixMode.enabled", desc, matrixMode); - - desc = "Set this to false to disable the references in the flower tooltips. (You monster D:)"; - referencesEnabled = loadPropBool("references.enabled", desc, referencesEnabled); - - desc = - "Do not ever touch this value if not asked to. Possible symptoms of doing so include your head turning backwards, the appearance of Titans near the walls or you being trapped in a game of Sword Art Online."; - spreaderPositionShift = loadPropInt("spreader.posShift", desc, spreaderPositionShift); - - desc = - "Turn this off ONLY IF you're on an extremely large world with an exaggerated count of Mana Spreaders/Mana Pools and are experiencing TPS lag. This toggles whether flowers are strict with their checking for connecting to pools/spreaders or just check whenever possible."; - flowerForceCheck = loadPropBool("flower.forceCheck", desc, flowerForceCheck); - - desc = "Set to false to disable the ability for the Hand of Ender to pickpocket other players' ender chests."; - enderPickpocketEnabled = loadPropBool("enderPickpocket.enabled", desc, enderPickpocketEnabled); - - desc = - "Set this to false to disable the Fallen Kanade flower (gives Regeneration). This config option is here for those using Blood Magic. Note: Turning this off will not remove ones already in the world, it'll simply prevent the crafting."; - fallenKanadeEnabled = loadPropBool("fallenKanade.enabled", desc, fallenKanadeEnabled); - - desc = - "Set this to false to disable the Smokey Quartz blocks. This config option is here for those using Thaumic Tinkerer"; - darkQuartzEnabled = loadPropBool("darkQuartz.enabled", desc, darkQuartzEnabled); - - desc = - "Set this to false to disable the Mana Enchanter. Since some people find it OP or something. This only disables the entry and creation. Old ones that are already in the world will stay."; - enchanterEnabled = loadPropBool("manaEnchanter.enabled", desc, enchanterEnabled); - - desc = - "Set this to false to disable the Mana Fluxfield (generates RF from mana). This only disables the entry and creation. Old ones that are already in the world will stay."; - fluxfieldEnabled = loadPropBool("manaFluxfield.enabled", desc, fluxfieldEnabled); - - desc = - "Set this to false to disable the Relic System. This only disables the entries, drops and achievements. Old ones that are already in the world will stay."; - relicsEnabled = loadPropBool("relics.enabled", desc, relicsEnabled); - - desc = - "Set this to false to disable the 1.8 Stones available as mana alchemy recipes. This only disables the recipes and entries. Old ones that are already in the world will stay."; - stones18Enabled = loadPropBool("18stones.enabled", desc, stones18Enabled); - - desc = - "Set this to false to make the Ring of Odin not apply fire resistance. Mostly for people who use Witchery transformations."; - ringOfOdinFireResist = loadPropBool("ringOfOdin.fireResist", desc, ringOfOdinFireResist); - - desc = - "Set this to false to disable the 1.9 Ender features available as recipes. This only disables the recipes and entries. Old ones that are already in the world will stay."; - enderStuff19Enabled = loadPropBool("19enderStuff.enabled", desc, enderStuff19Enabled); - - desc = "Set this to true to invert the Ring of Magnetization's controls (from shift to stop to shift to work)"; - invertMagnetRing = loadPropBool("magnetRing.invert", desc, invertMagnetRing); - - desc = "Set this to false to disable Thaumcraft Infusion Stabilizing in botania blocks"; - enableThaumcraftStablizers = loadPropBool("thaumraftStabilizers.enabled", desc, enableThaumcraftStablizers); - - desc = "The harvest level of the Mana Lens: Weight. 3 is diamond level. Defaults to 2 (iron level)"; - harvestLevelWeight = loadPropInt("harvestLevel.weightLens", desc, harvestLevelWeight); - - desc = "The harvest level of the Mana Lens: Bore. 3 is diamond level. Defaults to 3"; - harvestLevelBore = loadPropInt("harvestLevel.boreLens", desc, harvestLevelBore); - - desc = - "The quantity of Botania flower patches to generate in the world, defaults to 2, the lower the number the less patches generate."; - flowerQuantity = loadPropInt("worldgen.flower.quantity", desc, flowerQuantity); - - desc = - "The amount of time it takes a Passive flower to decay and turn into a dead bush. Defaults to 72000, 60 minutes. Setting this to -1 disables the feature altogether."; - hardcorePassiveGeneration = loadPropInt("passiveDecay.time", desc, hardcorePassiveGeneration); - - desc = - "The density of each Botania flower patch generated, defaults to 2, the lower the number, the less each patch will have."; - adaptor.addMappingInt(0, "worldgen.flower.density", 16); - adaptor.addMappingInt(238, "worldgen.flower.density", 2); - flowerDensity = loadPropInt("worldgen.flower.density", desc, flowerDensity); - - desc = - "The size of each Botania flower patch, defaults to 6. The larger this is the farther the each patch can spread"; - flowerPatchSize = loadPropInt("worldgen.flower.patchSize", desc, flowerPatchSize); - - desc = - "The inverse chance for a Botania flower patch to be generated, defaults to 16. The higher this value is the less patches will exist and the more flower each will have."; - adaptor.addMappingInt(0, "worldgen.flower.patchChance", 4); - adaptor.addMappingInt(238, "worldgen.flower.patchChance", 16); - flowerPatchChance = loadPropInt("worldgen.flower.patchChance", desc, flowerPatchChance); - - desc = - "The chance for a Botania flower generated in a patch to be a tall flower. 0.1 is 10%, 1 is 100%. Defaults to 0.05"; - adaptor.addMappingDouble(0, "worldgen.flower.tallChance", 0.1); - adaptor.addMappingDouble(238, "worldgen.flower.tallChance", 0.05); - flowerTallChance = loadPropDouble("worldgen.flower.tallChance", desc, flowerTallChance); - - desc = - "The quantity of Botania mushrooms to generate underground, in the world, defaults to 40, the lower the number the less patches generate."; - mushroomQuantity = loadPropInt("worldgen.mushroom.quantity", desc, mushroomQuantity); + public static Configuration config; + public static ConfigAdaptor adaptor; + + private static final String CATEGORY_POTIONS = "potions"; + + public static int hardcorePassiveGeneration = 72000; + + public static boolean useAdaptativeConfig = true; + + public static boolean enableDefaultRecipes = false; + + public static boolean useShaders = true; + public static boolean lexiconRotatingItems = true; + public static boolean lexiconJustifiedText = false; + public static boolean subtlePowerSystem = false; + public static boolean staticWandBeam = false; + public static boolean boundBlockWireframe = true; + public static boolean lexicon3dModel = true; + public static boolean oldPylonModel = false; + public static double flowerParticleFrequency = 0.75F; + public static boolean blockBreakParticles = true; + public static boolean blockBreakParticlesTool = true; + public static boolean elfPortalParticlesEnabled = true; + public static boolean chargingAnimationEnabled = true; + public static boolean useVanillaParticleLimiter = true; + public static boolean silentSpreaders = false; + public static boolean renderBaubles = true; + public static boolean enableSeasonalFeatures = true; + public static boolean useShiftForQuickLookup = false; + public static boolean enableArmorModels = true; + public static boolean enableFancySkybox = true; + public static boolean enableFancySkyboxInNormalWorlds = false; + + public static int manaBarHeight = 29; + public static int flightBarHeight = 49; + public static int flightBarBreathHeight = 59; + public static int glSecondaryTextureUnit = 7; + + public static boolean altFlowerTextures = false; + public static boolean matrixMode = false; + public static boolean referencesEnabled = true; + + public static int spreaderPositionShift = 1; + public static boolean flowerForceCheck = true; + public static boolean enderPickpocketEnabled = true; + + public static boolean fallenKanadeEnabled = true; + public static boolean darkQuartzEnabled = true; + public static boolean enchanterEnabled = true; + public static boolean fluxfieldEnabled = true; + public static boolean relicsEnabled = true; + public static boolean stones18Enabled = true; + public static boolean ringOfOdinFireResist = true; + public static boolean enderStuff19Enabled = true; + public static boolean invertMagnetRing = false; + public static boolean enableThaumcraftStablizers = true; + + public static int harvestLevelWeight = 2; + public static int harvestLevelBore = 3; + + public static int flowerQuantity = 0; + public static int flowerDensity = 2; + public static int flowerPatchSize = 6; + public static int flowerPatchChance = 16; + public static double flowerTallChance = 0.05; + public static int mushroomQuantity = 40; + + public static int[] flowerDimensionWhitelist = new int[]{}; + public static int[] flowerDimensionBlacklist = new int[]{}; + public static int[] mushroomDimensionWhitelist = new int[]{}; + public static int[] mushroomDimensionBlacklist = new int[]{}; + + private static boolean verifiedPotionArray = false; + private static int potionArrayLimit = 0; + + public static int potionIDSoulCross = 91; + public static int potionIDFeatherfeet = 92; + public static int potionIDEmptiness = 93; + public static int potionIDBloodthirst = 94; + public static int potionIDAllure = 95; + public static int potionIDClear = 96; + + public static void loadConfig(File configFile) { + config = new Configuration(configFile); + + config.load(); + load(); + + FMLCommonHandler.instance().bus().register(new ChangeListener()); + } + + public static void load() { + String desc; - desc = "Enables all built-in recipes. This can be false for expert modpacks that wish to supply their own."; - enableDefaultRecipes = loadPropBool("recipes.enabled", desc, enableDefaultRecipes); + desc = "Set this to false to disable the Adaptative Config. Adaptative Config changes any default config values from old versions to the new defaults to make sure you aren't missing out on changes because of old configs. It will not touch any values that were changed manually."; + useAdaptativeConfig = loadPropBool("adaptativeConfig.enabled", desc, useAdaptativeConfig); + adaptor = new ConfigAdaptor(useAdaptativeConfig); - desc = "Whitelist of which dimension generates Botania flowers. Empty means any dimension can."; - flowerDimensionWhitelist = - loadPropIntArray("worldgen.flower.dimensionWhitelist", desc, flowerDimensionWhitelist); + desc = "Set this to false to disable the use of shaders for some of the mod's renders."; + useShaders = loadPropBool("shaders.enabled", desc, useShaders); + + desc = "Set this to false to disable the rotating items in the petal and rune entries in the Lexica Botania."; + lexiconRotatingItems = loadPropBool("lexicon.enable.rotatingItems", desc, lexiconRotatingItems); + + desc = "Set this to true to enable justified text in the Lexica Botania's text pages."; + lexiconJustifiedText = loadPropBool("lexicon.enable.justifiedText", desc, lexiconJustifiedText); + + desc = "Set this to true to set the power system's particles to be a lot more subtle. Good for low-end systems, if the particles are causing lag."; + subtlePowerSystem = loadPropBool("powerSystem.subtle", desc, subtlePowerSystem); + + desc = "Set this to true to use a static wand beam that shows every single position of the burst, similar to the way it used to work on old Botania versions. Warning: Disabled by default because it may be laggy."; + staticWandBeam = loadPropBool("wandBeam.static", desc, staticWandBeam); + + desc = "Set this to false to disable the wireframe when looking a block bound to something (spreaders, flowers, etc)."; + boundBlockWireframe = loadPropBool("boundBlock.wireframe.enabled", desc, boundBlockWireframe); + + desc = "Set this to false to disable the animated 3D render for the Lexica Botania."; + lexicon3dModel = loadPropBool("lexicon.render.3D", desc, lexicon3dModel); - desc = "Blacklist of which dimension generates Botania flowers."; - flowerDimensionBlacklist = - loadPropIntArray("worldgen.flower.dimensionBlacklist", desc, flowerDimensionBlacklist); + desc = "Set this to true to use the old (non-.obj, pre beta18) pylon model"; + oldPylonModel = loadPropBool("pylonModel.old", desc, oldPylonModel); - desc = "Whitelist of which dimension generates Botania mushrooms. Empty means any dimension can."; - mushroomDimensionWhitelist = - loadPropIntArray("worldgen.mushroom.dimensionWhitelist", desc, mushroomDimensionWhitelist); + desc = "The frequency in which particles spawn from normal (worldgen) mystical flowers"; + flowerParticleFrequency = loadPropDouble("flowerParticles.frequency", desc, flowerParticleFrequency); - desc = "Blacklist of which dimension generates Botania mushrooms."; - mushroomDimensionBlacklist = - loadPropIntArray("worldgen.mushroom.dimensionBlacklist", desc, mushroomDimensionBlacklist); + desc = "Set this to false to remove the block breaking particles from the flowers and other items in the mod."; + blockBreakParticles = loadPropBool("blockBreakingParticles.enabled", desc, blockBreakParticles); - potionIDSoulCross = loadPropPotionId(LibPotionNames.SOUL_CROSS, potionIDSoulCross); - potionIDFeatherfeet = loadPropPotionId(LibPotionNames.FEATHER_FEET, potionIDFeatherfeet); - potionIDEmptiness = loadPropPotionId(LibPotionNames.EMPTINESS, potionIDEmptiness); - potionIDBloodthirst = loadPropPotionId(LibPotionNames.BLOODTHIRST, potionIDBloodthirst); - potionIDAllure = loadPropPotionId(LibPotionNames.ALLURE, potionIDAllure); - potionIDClear = loadPropPotionId(LibPotionNames.CLEAR, potionIDClear); + desc = "Set this to false to remove the block breaking particles from the Mana Shatterer, as there can be a good amount in higher levels."; + blockBreakParticlesTool = loadPropBool("blockBreakingParticlesTool.enabled", desc, blockBreakParticlesTool); - if (config.hasChanged()) config.save(); - } + desc = "Set this to false to disable the particles in the elven portal."; + elfPortalParticlesEnabled = loadPropBool("elfPortal.particles.enabled", desc, elfPortalParticlesEnabled); - public static void loadPostInit() { - SheddingHandler.loadFromConfig(config); + desc = "Set this to false to disable the animation when an item is charging on top of a mana pool."; + chargingAnimationEnabled = loadPropBool("chargeAnimation.enabled", desc, chargingAnimationEnabled); - if (config.hasChanged()) config.save(); - } + desc = "Set this to false to always display all particles regardless of the \"Particles\" setting in the Vanilla options menu."; + useVanillaParticleLimiter = loadPropBool("vanillaParticleConfig.enabled", desc, useVanillaParticleLimiter); - public static int loadPropInt(String propName, String desc, int default_) { - Property prop = config.get(Configuration.CATEGORY_GENERAL, propName, default_); - prop.comment = desc; + desc = "Set this to true to disable the mana spreader shooting sound."; + silentSpreaders = loadPropBool("manaSpreaders.silent", desc, silentSpreaders); - if (adaptor != null) adaptor.adaptPropertyInt(prop, prop.getInt(default_)); + desc = "Set this to false to disable rendering of baubles in the player."; + renderBaubles = loadPropBool("baubleRender.enabled", desc, renderBaubles); - return prop.getInt(default_); - } + desc = "Set this to false to disable seasonal features, such as halloween and christmas."; + enableSeasonalFeatures = loadPropBool("seasonalFeatures.enabled", desc, enableSeasonalFeatures); - public static double loadPropDouble(String propName, String desc, double default_) { - Property prop = config.get(Configuration.CATEGORY_GENERAL, propName, default_); - prop.comment = desc; + desc = "Set this to true to use Shift instead of Ctrl for the inventory lexica botania quick lookup feature."; + useShiftForQuickLookup = loadPropBool("quickLookup.useShift", desc, useShiftForQuickLookup); - if (adaptor != null) adaptor.adaptPropertyDouble(prop, prop.getDouble(default_)); + desc = "Set this to false to disable custom armor models."; + enableArmorModels = loadPropBool("armorModels.enable", desc, enableArmorModels); - return prop.getDouble(default_); - } + desc = "Set this to false to disable the fancy skybox in Garden of Glass."; + enableFancySkybox = loadPropBool("fancySkybox.enable", desc, enableFancySkybox); + + desc = "Set this to true to enable the fancy skybox in non Garden of Glass worlds. (Does not require Garden of Glass loaded to use, needs 'fancySkybox.enable' to be true as well)"; + enableFancySkyboxInNormalWorlds = loadPropBool("fancySkybox.normalWorlds", desc, enableFancySkyboxInNormalWorlds); + + desc = "The height of the mana display bar in above the XP bar. You can change this if you have a mod that changes where the XP bar is."; + manaBarHeight = loadPropInt("manaBar.height", desc, manaBarHeight); - public static boolean loadPropBool(String propName, String desc, boolean default_) { - Property prop = config.get(Configuration.CATEGORY_GENERAL, propName, default_); - prop.comment = desc; + desc = "The height of the Flugel Tiara flight bar. You can change this if you have a mod that adds a bar in that spot."; + flightBarHeight = loadPropInt("flightBar.height", desc, flightBarHeight); - if (adaptor != null) adaptor.adaptPropertyBool(prop, prop.getBoolean(default_)); + desc = "The height of the Flugel Tiara flight bar if your breath bar is shown. You can change this if you have a mod that adds a bar in that spot."; + flightBarBreathHeight = loadPropInt("flightBarBreath.height", desc, flightBarBreathHeight); + + desc = "The GL Texture Unit to use for the secondary sampler passed in to the Lexica Botania's category button shader. DO NOT TOUCH THIS IF YOU DON'T KNOW WHAT YOU'RE DOING"; + glSecondaryTextureUnit = loadPropInt("shaders.secondaryUnit", desc, glSecondaryTextureUnit); - return prop.getBoolean(default_); - } + desc = "Set this to true to use alternate flower textures by Futureazoo, not all flowers are textured. http://redd.it/2b3o3f"; + altFlowerTextures = loadPropBool("flowerTextures.alt", desc, altFlowerTextures); - public static int[] loadPropIntArray(String propName, String desc, int[] intArray) { - Property prop = config.get(Configuration.CATEGORY_GENERAL, propName, intArray); - prop.comment = desc; + desc = "Set this to true if you are the chosen one. For lovers of glitch art and just general mad people."; + matrixMode = loadPropBool("matrixMode.enabled", desc, matrixMode); - if (adaptor != null) adaptor.adaptPropertyIntArray(prop, prop.getIntList()); + desc = "Set this to false to disable the references in the flower tooltips. (You monster D:)"; + referencesEnabled = loadPropBool("references.enabled", desc, referencesEnabled); - return prop.getIntList(); - } + desc = "Do not ever touch this value if not asked to. Possible symptoms of doing so include your head turning backwards, the appearance of Titans near the walls or you being trapped in a game of Sword Art Online."; + spreaderPositionShift = loadPropInt("spreader.posShift", desc, spreaderPositionShift); - public static int loadPropPotionId(String propName, int default_) { - if (!verifiedPotionArray) verifyPotionArray(); + desc = "Turn this off ONLY IF you're on an extremely large world with an exaggerated count of Mana Spreaders/Mana Pools and are experiencing TPS lag. This toggles whether flowers are strict with their checking for connecting to pools/spreaders or just check whenever possible."; + flowerForceCheck = loadPropBool("flower.forceCheck", desc, flowerForceCheck); - Property prop = config.get(CATEGORY_POTIONS, propName, default_); - int val = prop.getInt(default_); - if (val > potionArrayLimit) { - val = default_; - prop.set(default_); - } + desc = "Set to false to disable the ability for the Hand of Ender to pickpocket other players' ender chests."; + enderPickpocketEnabled = loadPropBool("enderPickpocket.enabled", desc, enderPickpocketEnabled); - return val; - } + desc = "Set this to false to disable the Fallen Kanade flower (gives Regeneration). This config option is here for those using Blood Magic. Note: Turning this off will not remove ones already in the world, it'll simply prevent the crafting."; + fallenKanadeEnabled = loadPropBool("fallenKanade.enabled", desc, fallenKanadeEnabled); - private static void verifyPotionArray() { - if (Loader.isModLoaded("DragonAPI")) potionArrayLimit = Potion.potionTypes.length; - else if (Loader.isModLoaded("hodgepodge")) potionArrayLimit = 255; - else potionArrayLimit = 127; + desc = "Set this to false to disable the Smokey Quartz blocks. This config option is here for those using Thaumic Tinkerer"; + darkQuartzEnabled = loadPropBool("darkQuartz.enabled", desc, darkQuartzEnabled); - verifiedPotionArray = true; - } + desc = "Set this to false to disable the Mana Enchanter. Since some people find it OP or something. This only disables the entry and creation. Old ones that are already in the world will stay."; + enchanterEnabled = loadPropBool("manaEnchanter.enabled", desc, enchanterEnabled); - public static class ConfigAdaptor { + desc = "Set this to false to disable the Mana Fluxfield (generates RF from mana). This only disables the entry and creation. Old ones that are already in the world will stay."; + fluxfieldEnabled = loadPropBool("manaFluxfield.enabled", desc, fluxfieldEnabled); - private boolean enabled; + desc = "Set this to false to disable the Relic System. This only disables the entries, drops and achievements. Old ones that are already in the world will stay."; + relicsEnabled = loadPropBool("relics.enabled", desc, relicsEnabled); - private Map> adaptableValues = new HashMap(); - private List changes = new ArrayList(); + desc = "Set this to false to disable the 1.8 Stones available as mana alchemy recipes. This only disables the recipes and entries. Old ones that are already in the world will stay."; + stones18Enabled = loadPropBool("18stones.enabled", desc, stones18Enabled); - public ConfigAdaptor(boolean enabled) { - this.enabled = enabled; - } + desc = "Set this to false to make the Ring of Odin not apply fire resistance. Mostly for people who use Witchery transformations."; + ringOfOdinFireResist = loadPropBool("ringOfOdin.fireResist", desc, ringOfOdinFireResist); - public void adaptProperty(Property prop, T val) { - if (!enabled) return; + desc = "Set this to false to disable the 1.9 Ender features available as recipes. This only disables the recipes and entries. Old ones that are already in the world will stay."; + enderStuff19Enabled = loadPropBool("19enderStuff.enabled", desc, enderStuff19Enabled); - String name = prop.getName(); + desc = "Set this to true to invert the Ring of Magnetization's controls (from shift to stop to shift to work)"; + invertMagnetRing = loadPropBool("magnetRing.invert", desc, invertMagnetRing); - if (!adaptableValues.containsKey(name)) return; + desc = "Set this to false to disable Thaumcraft Infusion Stabilizing in botania blocks"; + enableThaumcraftStablizers = loadPropBool("thaumraftStabilizers.enabled", desc, enableThaumcraftStablizers); + + desc = "The harvest level of the Mana Lens: Weight. 3 is diamond level. Defaults to 2 (iron level)"; + harvestLevelWeight = loadPropInt("harvestLevel.weightLens", desc, harvestLevelWeight); - AdaptableValue bestValue = null; - for (AdaptableValue value : adaptableValues.get(name)) { - if (bestValue == null || value.version > bestValue.version) bestValue = value; - } + desc = "The harvest level of the Mana Lens: Bore. 3 is diamond level. Defaults to 3"; + harvestLevelBore = loadPropInt("harvestLevel.boreLens", desc, harvestLevelBore); + + desc = "The quantity of Botania flower patches to generate in the world, defaults to 2, the lower the number the less patches generate."; + flowerQuantity = loadPropInt("worldgen.flower.quantity", desc, flowerQuantity); - if (bestValue != null) { - T expected = bestValue.value; - T def = (T) prop.getDefault(); + desc = "The amount of time it takes a Passive flower to decay and turn into a dead bush. Defaults to 72000, 60 minutes. Setting this to -1 disables the feature altogether."; + hardcorePassiveGeneration = loadPropInt("passiveDecay.time", desc, hardcorePassiveGeneration); + + desc = "The density of each Botania flower patch generated, defaults to 2, the lower the number, the less each patch will have."; + adaptor.addMappingInt(0, "worldgen.flower.density", 16); + adaptor.addMappingInt(238, "worldgen.flower.density", 2); + flowerDensity = loadPropInt("worldgen.flower.density", desc, flowerDensity); - if (areEqualNumbers(val, expected) && !areEqualNumbers(val, def)) { - prop.setValue(def.toString()); - changes.add(" " + prop.getName() + ": " + val + " -> " + def); - } - } - } + desc = "The size of each Botania flower patch, defaults to 6. The larger this is the farther the each patch can spread"; + flowerPatchSize = loadPropInt("worldgen.flower.patchSize", desc, flowerPatchSize); - public void addMapping(int version, String key, T val) { - if (!enabled) return; + desc = "The inverse chance for a Botania flower patch to be generated, defaults to 16. The higher this value is the less patches will exist and the more flower each will have."; + adaptor.addMappingInt(0, "worldgen.flower.patchChance", 4); + adaptor.addMappingInt(238, "worldgen.flower.patchChance", 16); + flowerPatchChance = loadPropInt("worldgen.flower.patchChance", desc, flowerPatchChance); - AdaptableValue adapt = new AdaptableValue(version, val); - if (!adaptableValues.containsKey(key)) { - ArrayList list = new ArrayList(); - adaptableValues.put(key, list); - } + desc = "The chance for a Botania flower generated in a patch to be a tall flower. 0.1 is 10%, 1 is 100%. Defaults to 0.05"; + adaptor.addMappingDouble(0, "worldgen.flower.tallChance", 0.1); + adaptor.addMappingDouble(238, "worldgen.flower.tallChance", 0.05); + flowerTallChance = loadPropDouble("worldgen.flower.tallChance", desc, flowerTallChance); - List list = adaptableValues.get(key); - list.add(adapt); - } + desc = "The quantity of Botania mushrooms to generate underground, in the world, defaults to 40, the lower the number the less patches generate."; + mushroomQuantity = loadPropInt("worldgen.mushroom.quantity", desc, mushroomQuantity); - public boolean areEqualNumbers(Object v1, Object v2) { - double epsilon = 1.0E-6; - float v1f = ((Number) v1).floatValue(); - float v2f; + desc = "Enables all built-in recipes. This can be false for expert modpacks that wish to supply their own."; + enableDefaultRecipes = loadPropBool("recipes.enabled", desc, enableDefaultRecipes); - if (v2 instanceof String) v2f = Float.parseFloat((String) v2); - else v2f = ((Number) v2).floatValue(); + desc = "Whitelist of which dimension generates Botania flowers. Empty means any dimension can."; + flowerDimensionWhitelist = loadPropIntArray("worldgen.flower.dimensionWhitelist", desc, flowerDimensionWhitelist); - return Math.abs(v1f - v2f) < epsilon; - } + desc = "Blacklist of which dimension generates Botania flowers."; + flowerDimensionBlacklist = loadPropIntArray("worldgen.flower.dimensionBlacklist", desc, flowerDimensionBlacklist); - public void tellChanges(EntityPlayer player) { - if (changes.size() == 0) return; + desc = "Whitelist of which dimension generates Botania mushrooms. Empty means any dimension can."; + mushroomDimensionWhitelist = loadPropIntArray("worldgen.mushroom.dimensionWhitelist", desc, mushroomDimensionWhitelist); - player.addChatComponentMessage(new ChatComponentTranslation("botaniamisc.adaptativeConfigChanges") - .setChatStyle(new ChatStyle().setColor(EnumChatFormatting.GOLD))); - for (String change : changes) - player.addChatMessage(new ChatComponentText(change) - .setChatStyle(new ChatStyle().setColor(EnumChatFormatting.LIGHT_PURPLE))); - } + desc = "Blacklist of which dimension generates Botania mushrooms."; + mushroomDimensionBlacklist = loadPropIntArray("worldgen.mushroom.dimensionBlacklist", desc, mushroomDimensionBlacklist); - public void addMappingInt(int version, String key, int val) { - this.addMapping(version, key, val); - } + potionIDSoulCross = loadPropPotionId(LibPotionNames.SOUL_CROSS, potionIDSoulCross); + potionIDFeatherfeet = loadPropPotionId(LibPotionNames.FEATHER_FEET, potionIDFeatherfeet); + potionIDEmptiness = loadPropPotionId(LibPotionNames.EMPTINESS, potionIDEmptiness); + potionIDBloodthirst = loadPropPotionId(LibPotionNames.BLOODTHIRST, potionIDBloodthirst); + potionIDAllure = loadPropPotionId(LibPotionNames.ALLURE, potionIDAllure); + potionIDClear = loadPropPotionId(LibPotionNames.CLEAR, potionIDClear); - public void addMappingDouble(int version, String key, double val) { - this.addMapping(version, key, val); - } + if(config.hasChanged()) + config.save(); + } - public void addMappingBool(int version, String key, boolean val) { - this.addMapping(version, key, val); - } + public static void loadPostInit() { + SheddingHandler.loadFromConfig(config); - public void adaptPropertyInt(Property prop, int val) { - this.adaptProperty(prop, val); - } + if(config.hasChanged()) + config.save(); + } - public void adaptPropertyDouble(Property prop, double val) { - this.adaptProperty(prop, val); - } + public static int loadPropInt(String propName, String desc, int default_) { + Property prop = config.get(Configuration.CATEGORY_GENERAL, propName, default_); + prop.comment = desc; - public void adaptPropertyBool(Property prop, boolean val) { - this.adaptProperty(prop, val); - } + if(adaptor != null) + adaptor.adaptPropertyInt(prop, prop.getInt(default_)); - public void adaptPropertyIntArray(Property prop, int[] val) { - this.adaptProperty(prop, val); - } + return prop.getInt(default_); + } - public static class AdaptableValue { + public static double loadPropDouble(String propName, String desc, double default_) { + Property prop = config.get(Configuration.CATEGORY_GENERAL, propName, default_); + prop.comment = desc; - public final int version; - public final T value; - public final Class valueType; + if(adaptor != null) + adaptor.adaptPropertyDouble(prop, prop.getDouble(default_)); + + return prop.getDouble(default_); + } + + public static boolean loadPropBool(String propName, String desc, boolean default_) { + Property prop = config.get(Configuration.CATEGORY_GENERAL, propName, default_); + prop.comment = desc; + + if(adaptor != null) + adaptor.adaptPropertyBool(prop, prop.getBoolean(default_)); + + return prop.getBoolean(default_); + } + + public static int[] loadPropIntArray(String propName, String desc, int[] intArray) { + Property prop = config.get(Configuration.CATEGORY_GENERAL, propName, intArray); + prop.comment = desc; + + if(adaptor != null) + adaptor.adaptPropertyIntArray(prop, prop.getIntList()); + + return prop.getIntList(); + } + + public static int loadPropPotionId(String propName, int default_) { + if(!verifiedPotionArray) + verifyPotionArray(); + + Property prop = config.get(CATEGORY_POTIONS, propName, default_); + int val = prop.getInt(default_); + if(val > potionArrayLimit) { + val = default_; + prop.set(default_); + } + + return val; + } + + private static void verifyPotionArray() { + if(Loader.isModLoaded("DragonAPI")) + potionArrayLimit = Potion.potionTypes.length; + else if(Loader.isModLoaded("hodgepodge")) + potionArrayLimit = 255; + else + potionArrayLimit = 127; + + verifiedPotionArray = true; + } + + public static class ConfigAdaptor { - public AdaptableValue(int version, T value) { - this.version = version; - this.value = value; - valueType = (Class) value.getClass(); - } - } - } - - public static class ChangeListener { - - @SubscribeEvent - public void onConfigChanged(ConfigChangedEvent.OnConfigChangedEvent eventArgs) { - if (eventArgs.modID.equals(LibMisc.MOD_ID)) load(); - } - } + private boolean enabled; + + private Map> adaptableValues = new HashMap(); + private List changes = new ArrayList(); + + public ConfigAdaptor(boolean enabled) { + this.enabled = enabled; + } + + public void adaptProperty(Property prop, T val) { + if(!enabled) + return; + + String name = prop.getName(); + + if(!adaptableValues.containsKey(name)) + return; + + AdaptableValue bestValue = null; + for(AdaptableValue value : adaptableValues.get(name)) { + if(bestValue == null || value.version > bestValue.version) + bestValue = value; + } + + if(bestValue != null) { + T expected = bestValue.value; + T def = (T) prop.getDefault(); + + if(areEqualNumbers(val, expected) && !areEqualNumbers(val, def)) { + prop.setValue(def.toString()); + changes.add(" " + prop.getName() + ": " + val + " -> " + def); + } + } + } + + public void addMapping(int version, String key, T val) { + if(!enabled) + return; + + AdaptableValue adapt = new AdaptableValue(version, val); + if(!adaptableValues.containsKey(key)) { + ArrayList list = new ArrayList(); + adaptableValues.put(key, list); + } + + List list = adaptableValues.get(key); + list.add(adapt); + } + + public boolean areEqualNumbers(Object v1, Object v2) { + double epsilon = 1.0E-6; + float v1f = ((Number) v1).floatValue(); + float v2f; + + if(v2 instanceof String) + v2f = Float.parseFloat((String) v2); + else v2f = ((Number) v2).floatValue(); + + return Math.abs(v1f - v2f) < epsilon; + } + + public void tellChanges(EntityPlayer player) { + if(changes.size() == 0) + return; + + player.addChatComponentMessage(new ChatComponentTranslation("botaniamisc.adaptativeConfigChanges").setChatStyle(new ChatStyle().setColor(EnumChatFormatting.GOLD))); + for(String change : changes) + player.addChatMessage(new ChatComponentText(change).setChatStyle(new ChatStyle().setColor(EnumChatFormatting.LIGHT_PURPLE))); + } + + public void addMappingInt(int version, String key, int val) { + this.addMapping(version, key, val); + } + + public void addMappingDouble(int version, String key, double val) { + this.addMapping(version, key, val); + } + + public void addMappingBool(int version, String key, boolean val) { + this.addMapping(version, key, val); + } + + public void adaptPropertyInt(Property prop, int val) { + this.adaptProperty(prop, val); + } + + public void adaptPropertyDouble(Property prop, double val) { + this.adaptProperty(prop, val); + } + + public void adaptPropertyBool(Property prop, boolean val) { + this.adaptProperty(prop, val); + } + + public void adaptPropertyIntArray(Property prop, int[] val) { + this.adaptProperty(prop, val); + } + + public static class AdaptableValue { + + public final int version; + public final T value; + public final Class valueType; + + public AdaptableValue(int version, T value) { + this.version = version; + this.value = value; + valueType = (Class) value.getClass(); + } + + } + + } + + public static class ChangeListener { + + @SubscribeEvent + public void onConfigChanged(ConfigChangedEvent.OnConfigChangedEvent eventArgs) { + if(eventArgs.modID.equals(LibMisc.MOD_ID)) + load(); + } + + } } diff --git a/src/main/java/vazkii/botania/common/core/handler/IMCHandler.java b/src/main/java/vazkii/botania/common/core/handler/IMCHandler.java index cd7769b92c..a12ad98f9f 100644 --- a/src/main/java/vazkii/botania/common/core/handler/IMCHandler.java +++ b/src/main/java/vazkii/botania/common/core/handler/IMCHandler.java @@ -1,24 +1,24 @@ package vazkii.botania.common.core.handler; -import com.google.common.collect.ImmutableList; -import cpw.mods.fml.common.event.FMLInterModComms.IMCMessage; import java.util.Iterator; + import vazkii.botania.common.item.equipment.bauble.ItemMagnetRing; import vazkii.botania.common.lib.LibMisc; +import com.google.common.collect.ImmutableList; + +import cpw.mods.fml.common.event.FMLInterModComms.IMCMessage; + public final class IMCHandler { - public static void processMessages(ImmutableList messageList) { - Iterator iterator = messageList.iterator(); - while (iterator.hasNext()) { - IMCMessage message = iterator.next(); - if (message != null - && message.key != null - && message.key.equals(LibMisc.BLACKLIST_ITEM) - && message.isStringMessage()) { - String value = message.getStringValue(); - ItemMagnetRing.addItemToBlackList(value); - } - } - } + public static void processMessages(ImmutableList messageList) { + Iterator iterator = messageList.iterator(); + while(iterator.hasNext()) { + IMCMessage message = iterator.next(); + if(message != null && message.key != null && message.key.equals(LibMisc.BLACKLIST_ITEM) && message.isStringMessage()) { + String value = message.getStringValue(); + ItemMagnetRing.addItemToBlackList(value); + } + } + } } diff --git a/src/main/java/vazkii/botania/common/core/handler/InternalMethodHandler.java b/src/main/java/vazkii/botania/common/core/handler/InternalMethodHandler.java index 9197fa06e3..d157b494ff 100644 --- a/src/main/java/vazkii/botania/common/core/handler/InternalMethodHandler.java +++ b/src/main/java/vazkii/botania/common/core/handler/InternalMethodHandler.java @@ -2,21 +2,17 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jan 14, 2014, 6:44:59 PM (GMT)] */ package vazkii.botania.common.core.handler; -import baubles.common.lib.PlayerHandler; -import baubles.common.network.PacketHandler; -import baubles.common.network.PacketSyncBauble; -import buildcraft.api.transport.IPipeTile; -import cpw.mods.fml.common.Optional; import java.util.ArrayList; import java.util.List; + import net.minecraft.block.Block; import net.minecraft.client.gui.ScaledResolution; import net.minecraft.client.renderer.texture.IIconRegister; @@ -72,231 +68,227 @@ import vazkii.botania.common.lexicon.page.PagePetalRecipe; import vazkii.botania.common.lexicon.page.PageRuneRecipe; import vazkii.botania.common.lexicon.page.PageText; +import baubles.common.lib.PlayerHandler; +import baubles.common.network.PacketHandler; +import baubles.common.network.PacketSyncBauble; +import buildcraft.api.transport.IPipeTile; +import cpw.mods.fml.common.Optional; public class InternalMethodHandler extends DummyMethodHandler { - @Override - public LexiconPage textPage(String key) { - return new PageText(key); - } - - @Override - public LexiconPage elfPaperTextPage(String key) { - return new PageLoreText(key); - } - - @Override - public LexiconPage imagePage(String key, String resource) { - return new PageImage(key, resource); - } - - @Override - public LexiconPage craftingRecipesPage(String key, List recipes) { - return new PageCraftingRecipe(key, recipes); - } - - @Override - public LexiconPage craftingRecipePage(String key, IRecipe recipe) { - return new PageCraftingRecipe(key, recipe); - } - - @Override - public IIcon getSubTileIconForName(String name) { - IIcon icon = - (ConfigHandler.altFlowerTextures ? BlockSpecialFlower.iconsAlt : BlockSpecialFlower.icons).get(name); - return icon == null ? Blocks.red_flower.getIcon(0, 0) : icon; - } - - @Override - public void registerBasicSignatureIcons(String name, IIconRegister register) { - IIcon normal = IconHelper.forName(register, name); - IIcon alt = IconHelper.forName(register, BlockModFlower.ALT_DIR + "/" + name); - BlockSpecialFlower.icons.put(name, normal); - BlockSpecialFlower.iconsAlt.put(name, alt == null ? normal : alt); - } - - @Override - public LexiconPage petalRecipesPage(String key, List recipes) { - return new PagePetalRecipe(key, recipes); - } - - @Override - public LexiconPage petalRecipePage(String key, RecipePetals recipe) { - return new PagePetalRecipe(key, recipe); - } - - @Override - public LexiconPage runeRecipesPage(String key, List recipes) { - return new PageRuneRecipe(key, recipes); - } - - @Override - public LexiconPage runeRecipePage(String key, RecipeRuneAltar recipe) { - return new PageRuneRecipe(key, recipe); - } - - @Override - public LexiconPage manaInfusionRecipesPage(String key, List recipes) { - return new PageManaInfusionRecipe(key, recipes); - } - - @Override - public LexiconPage manaInfusionRecipePage(String key, RecipeManaInfusion recipe) { - return new PageManaInfusionRecipe(key, recipe); - } - - @Override - public LexiconPage elvenTradePage(String key, List recipes) { - return new PageElvenRecipe(key, recipes); - } - - @Override - public LexiconPage elvenTradesPage(String key, RecipeElvenTrade recipe) { - return new PageElvenRecipe(key, recipe); - } - - @Override - public LexiconPage brewPage(String key, String bottomText, RecipeBrew recipe) { - return new PageBrew(recipe, key, bottomText); - } - - @Override - public LexiconPage multiblockPage(String key, MultiblockSet mb) { - return new PageMultiblock(key, mb); - } - - @Override - public ItemStack getSubTileAsStack(String subTile) { - return ItemBlockSpecialFlower.ofType(subTile); - } - - @Override - public ItemStack getSubTileAsFloatingFlowerStack(String subTile) { - return ItemBlockSpecialFlower.ofType(new ItemStack(ModBlocks.floatingSpecialFlower), subTile); - } - - @Override - public String getStackSubTileKey(ItemStack stack) { - return ItemBlockSpecialFlower.getType(stack); - } - - @Override - public IManaNetwork getManaNetworkInstance() { - return ManaNetworkHandler.instance; - } - - @Override - public IInventory getBaublesInventory(EntityPlayer player) { - return PlayerHandler.getPlayerBaubles(player); - } - - @Override - public void drawSimpleManaHUD(int color, int mana, int maxMana, String name, ScaledResolution res) { - HUDHandler.drawSimpleManaHUD(color, mana, maxMana, name, res); - } - - @Override - public void drawComplexManaHUD( - int color, - int mana, - int maxMana, - String name, - ScaledResolution res, - ItemStack bindDisplay, - boolean properlyBound) { - HUDHandler.drawComplexManaHUD(color, mana, maxMana, name, res, bindDisplay, properlyBound); - } - - @Override - public ItemStack getBindDisplayForFlowerType(SubTileEntity e) { - return e instanceof SubTileGenerating - ? new ItemStack(ModBlocks.spreader) - : e instanceof SubTileFunctional ? new ItemStack(ModBlocks.pool) : new ItemStack(ModItems.twigWand); - } - - @Override - public void renderLexiconText(int x, int y, int width, int height, String unlocalizedText) { - PageText.renderText(x, y, width, height, unlocalizedText); - } - - @Override - public void sparkleFX(World world, double x, double y, double z, float r, float g, float b, float size, int m) { - Botania.proxy.sparkleFX(world, x, y, z, r, g, b, size, m); - } - - @Override - public ResourceLocation getDefaultBossBarTexture() { - return BossBarHandler.defaultBossBar; - } - - @Override - public void setBossStatus(IBotaniaBoss status) { - BossBarHandler.setCurrentBoss(status); - } - - @Override - public boolean shouldForceCheck() { - return ConfigHandler.flowerForceCheck; - } - - @Override - public int getPassiveFlowerDecay() { - return ConfigHandler.hardcorePassiveGeneration; - } - - @Override - @Optional.Method(modid = "BuildCraft|Transport") - public boolean isBuildcraftPipe(TileEntity tile) { - return tile instanceof IPipeTile; - } - - @Override - public void breakOnAllCursors(EntityPlayer player, Item item, ItemStack stack, int x, int y, int z, int side) { - ItemLokiRing.breakOnAllCursors(player, item, stack, x, y, z, side); - } - - @Override - public boolean hasSolegnoliaAround(Entity e) { - return SubTileSolegnolia.hasSolegnoliaAround(e); - } - - @Override - public long getWorldElapsedTicks() { - return Botania.proxy.getWorldElapsedTicks(); - } - - @Override - public boolean isBotaniaFlower(World world, int x, int y, int z) { - Block block = world.getBlock(x, y, z); - return block == ModBlocks.flower || block == ModBlocks.shinyFlower || block == ModBlocks.specialFlower; - } - - @Override - public void sendBaubleUpdatePacket(EntityPlayer player, int slot) { - if (player instanceof EntityPlayerMP) - PacketHandler.INSTANCE.sendTo(new PacketSyncBauble(player, slot), (EntityPlayerMP) player); - } - - @Override - public List wrapInventory(List inventories) { - ArrayList arrayList = new ArrayList(); - for (IInventory inv : inventories) { - ICorporeaSpark spark = CorporeaHelper.getSparkForInventory(inv); - IWrappedInventory wrapped = null; - // try StorageDrawers integration - if (Botania.storageDrawersLoaded) { - wrapped = WrappedStorageDrawers.wrap(inv, spark); - } - // try DeepStorageUnit - if (wrapped == null) { - wrapped = WrappedDeepStorage.wrap(inv, spark); - } - // last chance - this will always work - if (wrapped == null) { - wrapped = WrappedIInventory.wrap(inv, spark); - } - arrayList.add(wrapped); - } - return arrayList; - } + @Override + public LexiconPage textPage(String key) { + return new PageText(key); + } + + @Override + public LexiconPage elfPaperTextPage(String key) { + return new PageLoreText(key); + } + + @Override + public LexiconPage imagePage(String key, String resource) { + return new PageImage(key, resource); + } + + @Override + public LexiconPage craftingRecipesPage(String key, List recipes) { + return new PageCraftingRecipe(key, recipes); + } + + @Override + public LexiconPage craftingRecipePage(String key, IRecipe recipe) { + return new PageCraftingRecipe(key, recipe); + } + + @Override + public IIcon getSubTileIconForName(String name) { + IIcon icon = (ConfigHandler.altFlowerTextures ? BlockSpecialFlower.iconsAlt : BlockSpecialFlower.icons).get(name); + return icon == null ? Blocks.red_flower.getIcon(0, 0) : icon; + } + + @Override + public void registerBasicSignatureIcons(String name, IIconRegister register) { + IIcon normal = IconHelper.forName(register, name); + IIcon alt = IconHelper.forName(register, BlockModFlower.ALT_DIR + "/" + name); + BlockSpecialFlower.icons.put(name, normal); + BlockSpecialFlower.iconsAlt.put(name, alt == null ? normal : alt); + } + + @Override + public LexiconPage petalRecipesPage(String key, List recipes) { + return new PagePetalRecipe(key, recipes); + } + + @Override + public LexiconPage petalRecipePage(String key, RecipePetals recipe) { + return new PagePetalRecipe(key, recipe); + } + + @Override + public LexiconPage runeRecipesPage(String key, List recipes) { + return new PageRuneRecipe(key, recipes); + } + + @Override + public LexiconPage runeRecipePage(String key, RecipeRuneAltar recipe) { + return new PageRuneRecipe(key, recipe); + } + + @Override + public LexiconPage manaInfusionRecipesPage(String key, List recipes) { + return new PageManaInfusionRecipe(key, recipes); + } + + @Override + public LexiconPage manaInfusionRecipePage(String key, RecipeManaInfusion recipe) { + return new PageManaInfusionRecipe(key, recipe); + } + + @Override + public LexiconPage elvenTradePage(String key, List recipes) { + return new PageElvenRecipe(key, recipes); + } + + @Override + public LexiconPage elvenTradesPage(String key, RecipeElvenTrade recipe) { + return new PageElvenRecipe(key, recipe); + } + + @Override + public LexiconPage brewPage(String key, String bottomText, RecipeBrew recipe) { + return new PageBrew(recipe, key, bottomText); + } + + @Override + public LexiconPage multiblockPage(String key, MultiblockSet mb) { + return new PageMultiblock(key, mb); + } + + @Override + public ItemStack getSubTileAsStack(String subTile) { + return ItemBlockSpecialFlower.ofType(subTile); + } + + @Override + public ItemStack getSubTileAsFloatingFlowerStack(String subTile) { + return ItemBlockSpecialFlower.ofType(new ItemStack(ModBlocks.floatingSpecialFlower), subTile); + } + + @Override + public String getStackSubTileKey(ItemStack stack) { + return ItemBlockSpecialFlower.getType(stack); + } + + @Override + public IManaNetwork getManaNetworkInstance() { + return ManaNetworkHandler.instance; + } + + @Override + public IInventory getBaublesInventory(EntityPlayer player) { + return PlayerHandler.getPlayerBaubles(player); + } + + @Override + public void drawSimpleManaHUD(int color, int mana, int maxMana, String name, ScaledResolution res) { + HUDHandler.drawSimpleManaHUD(color, mana, maxMana, name, res); + } + + @Override + public void drawComplexManaHUD(int color, int mana, int maxMana, String name, ScaledResolution res, ItemStack bindDisplay, boolean properlyBound) { + HUDHandler.drawComplexManaHUD(color, mana, maxMana, name, res, bindDisplay, properlyBound); + } + + @Override + public ItemStack getBindDisplayForFlowerType(SubTileEntity e) { + return e instanceof SubTileGenerating ? new ItemStack(ModBlocks.spreader) : e instanceof SubTileFunctional ? new ItemStack(ModBlocks.pool) : new ItemStack(ModItems.twigWand); + } + + @Override + public void renderLexiconText(int x, int y, int width, int height, String unlocalizedText) { + PageText.renderText(x, y, width, height, unlocalizedText); + } + + @Override + public void sparkleFX(World world, double x, double y, double z, float r, float g, float b, float size, int m) { + Botania.proxy.sparkleFX(world, x, y, z, r, g, b, size, m); + } + + @Override + public ResourceLocation getDefaultBossBarTexture() { + return BossBarHandler.defaultBossBar; + } + + @Override + public void setBossStatus(IBotaniaBoss status) { + BossBarHandler.setCurrentBoss(status); + } + + @Override + public boolean shouldForceCheck() { + return ConfigHandler.flowerForceCheck; + } + + @Override + public int getPassiveFlowerDecay() { + return ConfigHandler.hardcorePassiveGeneration; + } + + @Override + @Optional.Method(modid = "BuildCraft|Transport") + public boolean isBuildcraftPipe(TileEntity tile) { + return tile instanceof IPipeTile; + } + + @Override + public void breakOnAllCursors(EntityPlayer player, Item item, ItemStack stack, int x, int y, int z, int side) { + ItemLokiRing.breakOnAllCursors(player, item, stack, x, y, z, side); + } + + @Override + public boolean hasSolegnoliaAround(Entity e) { + return SubTileSolegnolia.hasSolegnoliaAround(e); + } + + @Override + public long getWorldElapsedTicks() { + return Botania.proxy.getWorldElapsedTicks(); + } + + @Override + public boolean isBotaniaFlower(World world, int x, int y, int z) { + Block block = world.getBlock(x, y, z); + return block == ModBlocks.flower || block == ModBlocks.shinyFlower || block == ModBlocks.specialFlower; + } + + @Override + public void sendBaubleUpdatePacket(EntityPlayer player, int slot) { + if(player instanceof EntityPlayerMP) + PacketHandler.INSTANCE.sendTo(new PacketSyncBauble(player, slot), (EntityPlayerMP) player); + } + + + @Override + public List wrapInventory(List inventories) { + ArrayList arrayList = new ArrayList(); + for(IInventory inv : inventories) { + ICorporeaSpark spark = CorporeaHelper.getSparkForInventory(inv); + IWrappedInventory wrapped = null; + // try StorageDrawers integration + if(Botania.storageDrawersLoaded) { + wrapped = WrappedStorageDrawers.wrap(inv, spark); + } + // try DeepStorageUnit + if(wrapped == null) { + wrapped = WrappedDeepStorage.wrap(inv, spark); + } + // last chance - this will always work + if(wrapped == null) { + wrapped = WrappedIInventory.wrap(inv, spark); + } + arrayList.add(wrapped); + } + return arrayList; + } } diff --git a/src/main/java/vazkii/botania/common/core/handler/ManaNetworkHandler.java b/src/main/java/vazkii/botania/common/core/handler/ManaNetworkHandler.java index 9f9f3afb09..54608e1c45 100644 --- a/src/main/java/vazkii/botania/common/core/handler/ManaNetworkHandler.java +++ b/src/main/java/vazkii/botania/common/core/handler/ManaNetworkHandler.java @@ -2,19 +2,19 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jan 22, 2014, 5:35:10 PM (GMT)] */ package vazkii.botania.common.core.handler; -import cpw.mods.fml.common.eventhandler.SubscribeEvent; import java.util.ArrayList; import java.util.List; import java.util.Map; import java.util.WeakHashMap; + import net.minecraft.tileentity.TileEntity; import net.minecraft.util.ChunkCoordinates; import net.minecraft.world.World; @@ -24,116 +24,130 @@ import vazkii.botania.api.mana.ManaNetworkEvent.ManaBlockType; import vazkii.botania.api.mana.TileSignature; import vazkii.botania.common.core.helper.MathHelper; +import cpw.mods.fml.common.eventhandler.SubscribeEvent; public final class ManaNetworkHandler implements IManaNetwork { - public static final ManaNetworkHandler instance = new ManaNetworkHandler(); - - public WeakHashMap> manaPools = new WeakHashMap(); - public WeakHashMap> manaCollectors = new WeakHashMap(); - - @SubscribeEvent - public void onNetworkEvent(ManaNetworkEvent event) { - Map> map = event.type == ManaBlockType.COLLECTOR ? manaCollectors : manaPools; - if (event.action == Action.ADD) add(map, event.tile); - else remove(map, event.tile); - } - - @Override - public void clear() { - manaPools.clear(); - manaCollectors.clear(); - } - - @Override - public TileEntity getClosestPool(ChunkCoordinates pos, World world, int limit) { - if (manaPools.containsKey(world)) return getClosest(manaPools.get(world), pos, world.isRemote, limit); - return null; - } - - @Override - public TileEntity getClosestCollector(ChunkCoordinates pos, World world, int limit) { - if (manaCollectors.containsKey(world)) return getClosest(manaCollectors.get(world), pos, world.isRemote, limit); - return null; - } - - public boolean isCollectorIn(TileEntity tile) { - return isIn(tile, manaCollectors); - } - - public boolean isPoolIn(TileEntity tile) { - return isIn(tile, manaPools); - } - - private synchronized boolean isIn(TileEntity tile, Map> map) { - List list = map.get(tile.getWorldObj()); - if (list == null) return false; - - for (TileSignature sig : list) if (sig.tile == tile) return true; - - return false; - } - - private synchronized TileEntity getClosest( - List tiles, ChunkCoordinates pos, boolean remoteCheck, int limit) { - float closest = Float.MAX_VALUE; - TileEntity closestTile = null; - - for (TileSignature sig : tiles) { - if (sig.remoteWorld != remoteCheck) continue; - - TileEntity tile = sig.tile; - if (tile.isInvalid()) continue; - float distance = - MathHelper.pointDistanceSpace(tile.xCoord, tile.yCoord, tile.zCoord, pos.posX, pos.posY, pos.posZ); - if (distance > limit) continue; - - if (distance < closest) { - closest = distance; - closestTile = tile; - } - } - - return closestTile; - } - - private synchronized void remove(Map> map, TileEntity tile) { - World world = tile.getWorldObj(); - - if (!map.containsKey(world)) return; - - List sigs = map.get(world); - for (TileSignature sig : sigs) - if (sig.tile.equals(tile)) { - sigs.remove(sig); - break; - } - } - - private synchronized void add(Map> map, TileEntity tile) { - World world = tile.getWorldObj(); - - List tiles; - if (!map.containsKey(world)) map.put(world, new ArrayList()); - - tiles = map.get(world); - - if (!tiles.contains(tile)) tiles.add(new TileSignature(tile, tile.getWorldObj().isRemote)); - } + public static final ManaNetworkHandler instance = new ManaNetworkHandler(); + + public WeakHashMap> manaPools = new WeakHashMap(); + public WeakHashMap> manaCollectors = new WeakHashMap(); + + @SubscribeEvent + public void onNetworkEvent(ManaNetworkEvent event) { + Map> map = event.type == ManaBlockType.COLLECTOR ? manaCollectors : manaPools; + if(event.action == Action.ADD) + add(map, event.tile); + else remove(map, event.tile); + } + + @Override + public void clear() { + manaPools.clear(); + manaCollectors.clear(); + } + + @Override + public TileEntity getClosestPool(ChunkCoordinates pos, World world, int limit) { + if(manaPools.containsKey(world)) + return getClosest(manaPools.get(world), pos, world.isRemote, limit); + return null; + } + + @Override + public TileEntity getClosestCollector(ChunkCoordinates pos, World world, int limit) { + if(manaCollectors.containsKey(world)) + return getClosest(manaCollectors.get(world), pos, world.isRemote, limit); + return null; + } + + public boolean isCollectorIn(TileEntity tile) { + return isIn(tile, manaCollectors); + } + + public boolean isPoolIn(TileEntity tile) { + return isIn(tile, manaPools); + } + + private synchronized boolean isIn(TileEntity tile, Map> map) { + List list = map.get(tile.getWorldObj()); + if(list == null) + return false; + + for(TileSignature sig : list) + if(sig.tile == tile) + return true; + + return false; + } + + private synchronized TileEntity getClosest(List tiles, ChunkCoordinates pos, boolean remoteCheck, int limit) { + float closest = Float.MAX_VALUE; + TileEntity closestTile = null; + + for(TileSignature sig : tiles) { + if(sig.remoteWorld != remoteCheck) + continue; + + TileEntity tile = sig.tile; + if(tile.isInvalid()) + continue; + float distance = MathHelper.pointDistanceSpace(tile.xCoord, tile.yCoord, tile.zCoord, pos.posX, pos.posY, pos.posZ); + if(distance > limit) + continue; + + if(distance < closest) { + closest = distance; + closestTile = tile; + } + } + + return closestTile; + } + + private synchronized void remove(Map> map, TileEntity tile) { + World world = tile.getWorldObj(); + + if(!map.containsKey(world)) + return; + + List sigs = map.get(world); + for(TileSignature sig : sigs) + if(sig.tile.equals(tile)) { + sigs.remove(sig); + break; + } + } + + private synchronized void add(Map> map, TileEntity tile) { + World world = tile.getWorldObj(); + + List tiles; + if(!map.containsKey(world)) + map.put(world, new ArrayList()); + + tiles = map.get(world); + + if(!tiles.contains(tile)) + tiles.add(new TileSignature(tile, tile.getWorldObj().isRemote)); + } + + @Override + public List getAllCollectorsInWorld(World world) { + return getAllInWorld(manaCollectors, world); + } + + @Override + public List getAllPoolsInWorld(World world) { + return getAllInWorld(manaPools, world); + } + + private List getAllInWorld(Map> map, World world) { + if(!map.containsKey(world)) + return new ArrayList(); + + return map.get(world); + } - @Override - public List getAllCollectorsInWorld(World world) { - return getAllInWorld(manaCollectors, world); - } - @Override - public List getAllPoolsInWorld(World world) { - return getAllInWorld(manaPools, world); - } - - private List getAllInWorld(Map> map, World world) { - if (!map.containsKey(world)) return new ArrayList(); - - return map.get(world); - } } diff --git a/src/main/java/vazkii/botania/common/core/handler/PixieHandler.java b/src/main/java/vazkii/botania/common/core/handler/PixieHandler.java index 08cb5495ce..bccd71985e 100644 --- a/src/main/java/vazkii/botania/common/core/handler/PixieHandler.java +++ b/src/main/java/vazkii/botania/common/core/handler/PixieHandler.java @@ -1,8 +1,5 @@ package vazkii.botania.common.core.handler; -import baubles.common.container.InventoryBaubles; -import baubles.common.lib.PlayerHandler; -import cpw.mods.fml.common.eventhandler.SubscribeEvent; import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.Item; @@ -14,51 +11,59 @@ import vazkii.botania.common.entity.EntityPixie; import vazkii.botania.common.item.ModItems; import vazkii.botania.common.item.equipment.armor.elementium.ItemElementiumHelm; +import baubles.common.container.InventoryBaubles; +import baubles.common.lib.PlayerHandler; +import cpw.mods.fml.common.eventhandler.SubscribeEvent; public class PixieHandler { - @SubscribeEvent - public void onDamageTaken(LivingHurtEvent event) { - if (!event.entityLiving.worldObj.isRemote - && event.entityLiving instanceof EntityPlayer - && event.source.getEntity() != null - && event.source.getEntity() instanceof EntityLivingBase) { - EntityPlayer player = (EntityPlayer) event.entityLiving; - ItemStack stack = player.getCurrentEquippedItem(); + @SubscribeEvent + public void onDamageTaken(LivingHurtEvent event) { + if(!event.entityLiving.worldObj.isRemote && event.entityLiving instanceof EntityPlayer && event.source.getEntity() != null && event.source.getEntity() instanceof EntityLivingBase) { + EntityPlayer player = (EntityPlayer) event.entityLiving; + ItemStack stack = player.getCurrentEquippedItem(); + + float chance = getChance(stack); + for (ItemStack element : player.inventory.armorInventory) + chance += getChance(element); - float chance = getChance(stack); - for (ItemStack element : player.inventory.armorInventory) chance += getChance(element); + InventoryBaubles baubles = PlayerHandler.getPlayerBaubles(player); + for(int i = 0; i < baubles.getSizeInventory(); i++) + chance += getChance(baubles.getStackInSlot(i)); - InventoryBaubles baubles = PlayerHandler.getPlayerBaubles(player); - for (int i = 0; i < baubles.getSizeInventory(); i++) chance += getChance(baubles.getStackInSlot(i)); + if(Math.random() < chance) { + EntityPixie pixie = new EntityPixie(player.worldObj); + pixie.setPosition(player.posX, player.posY + 2, player.posZ); - if (Math.random() < chance) { - EntityPixie pixie = new EntityPixie(player.worldObj); - pixie.setPosition(player.posX, player.posY + 2, player.posZ); + if(((ItemElementiumHelm) ModItems.elementiumHelm).hasArmorSet(player)) { + int[] potions = new int[] { + Potion.blindness.id, + Potion.wither.id, + Potion.moveSlowdown.id, + Potion.weakness.id + }; + pixie.setApplyPotionEffect(new PotionEffect(potions[event.entity.worldObj.rand.nextInt(potions.length)], 40, 0)); + } - if (((ItemElementiumHelm) ModItems.elementiumHelm).hasArmorSet(player)) { - int[] potions = - new int[] {Potion.blindness.id, Potion.wither.id, Potion.moveSlowdown.id, Potion.weakness.id - }; - pixie.setApplyPotionEffect( - new PotionEffect(potions[event.entity.worldObj.rand.nextInt(potions.length)], 40, 0)); - } + float dmg = 4; + if(stack != null && stack.getItem() == ModItems.elementiumSword) + dmg += 2; - float dmg = 4; - if (stack != null && stack.getItem() == ModItems.elementiumSword) dmg += 2; + pixie.setProps((EntityLivingBase) event.source.getEntity(), player, 0, dmg); + player.worldObj.spawnEntityInWorld(pixie); + } + } + } - pixie.setProps((EntityLivingBase) event.source.getEntity(), player, 0, dmg); - player.worldObj.spawnEntityInWorld(pixie); - } - } - } + float getChance(ItemStack stack) { + if(stack == null) + return 0F; - float getChance(ItemStack stack) { - if (stack == null) return 0F; + Item item = stack.getItem(); + if(item instanceof IPixieSpawner) + return ((IPixieSpawner) item).getPixieChance(stack); - Item item = stack.getItem(); - if (item instanceof IPixieSpawner) return ((IPixieSpawner) item).getPixieChance(stack); + return 0F; + } - return 0F; - } } diff --git a/src/main/java/vazkii/botania/common/core/handler/SheddingHandler.java b/src/main/java/vazkii/botania/common/core/handler/SheddingHandler.java index 6dc6a19d65..aef3cbdd61 100644 --- a/src/main/java/vazkii/botania/common/core/handler/SheddingHandler.java +++ b/src/main/java/vazkii/botania/common/core/handler/SheddingHandler.java @@ -2,17 +2,17 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jul 4, 2014, 10:38:50 PM (GMT)] */ package vazkii.botania.common.core.handler; -import cpw.mods.fml.common.eventhandler.SubscribeEvent; import java.util.ArrayList; import java.util.Map.Entry; + import net.minecraft.entity.Entity; import net.minecraft.entity.EntityList; import net.minecraft.entity.EntityLiving; @@ -32,129 +32,125 @@ import net.minecraftforge.event.entity.living.LivingEvent.LivingUpdateEvent; import vazkii.botania.common.lexicon.LexiconData; import vazkii.botania.common.lexicon.page.PageShedding; +import cpw.mods.fml.common.eventhandler.SubscribeEvent; public final class SheddingHandler { - public static ArrayList patterns = new ArrayList(); - public static ArrayList defaultPatterns = new ArrayList(); - - @SubscribeEvent - public void onLivingUpdate(LivingUpdateEvent event) { - if (event.entity.worldObj.isRemote) return; - - ShedPattern pattern = getShedPattern(event.entity); - - if (pattern != null) { - if (event.entity.worldObj.rand.nextInt(pattern.getRate()) == 0) - event.entity.entityDropItem(pattern.getItemStack(), 0.0F); - } - } - - public static ShedPattern getShedPattern(Entity entity) { - for (ShedPattern pattern : patterns) if (pattern.EntityClass.isInstance(entity)) return pattern; - - return null; - } - - public static boolean hasShedding() { - return patterns.size() > 0; - } - - public static void addToLexicon() { - if (!hasShedding()) return; - - int i = 1; - for (ShedPattern pattern : patterns) { - PageShedding page = new PageShedding( - String.valueOf(i), - (String) EntityList.classToStringMapping.get(pattern.EntityClass), - pattern.lexiconSize, - pattern.getItemStack()); - LexiconData.shedding.addPage(page); - } - } - - public static void loadFromConfig(Configuration config) { - defaultPatterns.add(new ShedPattern(EntityChicken.class, new ItemStack(Items.feather), 26000, 20)); - defaultPatterns.add(new ShedPattern(EntitySquid.class, new ItemStack(Items.dye), 18000, 20)); - defaultPatterns.add(new ShedPattern(EntityVillager.class, new ItemStack(Items.emerald), 226000, 40)); - defaultPatterns.add(new ShedPattern(EntitySpider.class, new ItemStack(Items.string), 12000, 40)); - defaultPatterns.add(new ShedPattern(EntityBlaze.class, new ItemStack(Items.blaze_powder), 8000, 40)); - defaultPatterns.add(new ShedPattern(EntityGhast.class, new ItemStack(Items.ghast_tear), 9001, 30)); - defaultPatterns.add(new ShedPattern(EntitySkeleton.class, new ItemStack(Items.bone), 36000, 40)); - defaultPatterns.add(new ShedPattern(EntitySlime.class, new ItemStack(Items.slime_ball), 21000, 40)); - - ArrayList defaultNames = new ArrayList(); - - for (ShedPattern pattern : defaultPatterns) { - loadFromConfig(config, pattern.getEntityString(), pattern); - defaultNames.add(pattern.getEntityString()); - } - - for (Object o : EntityList.stringToClassMapping.entrySet()) { - Entry entry = (Entry) o; - - if (EntityLiving.class.isAssignableFrom(entry.getValue())) { - String name = entry.getKey(); - if (!defaultNames.contains(name)) loadFromConfig(config, name, null); - } - } - } - - public static void loadFromConfig(Configuration config, String key, ShedPattern defaultPattern) { - String itemName = ""; - int metadata = 0; - int rate = -1; - int lexiconSize = 40; - - if (defaultPattern != null) { - itemName = Item.itemRegistry.getNameForObject( - defaultPattern.getItemStack().getItem()); - metadata = defaultPattern.getItemStack().getItemDamage(); - rate = defaultPattern.rate; - lexiconSize = defaultPattern.lexiconSize; - } - - Property prop = config.get("Shedding", key + ".item", itemName); - prop.comment = "Configuration of Shedding for " + key; - itemName = prop.getString(); - rate = config.get("Shedding", key + ".rate", rate).getInt(); - metadata = config.get("Shedding", key + ".metadata", metadata).getInt(); - lexiconSize = - config.get("Shedding", key + ".lexiconDisplaySize", lexiconSize).getInt(); - - if (itemName != null && !itemName.isEmpty() && rate != -1) - patterns.add(new ShedPattern( - (Class) EntityList.stringToClassMapping.get(key), - new ItemStack((Item) Item.itemRegistry.getObject(itemName), 1, metadata), - rate, - lexiconSize)); - } - - public static class ShedPattern { - - Class EntityClass; - ItemStack itemStack; - int rate; - int lexiconSize; - - public ShedPattern(Class EntityClass, ItemStack itemStack, int rate, int lexiconSize) { - this.EntityClass = EntityClass; - this.itemStack = itemStack; - this.rate = rate; - this.lexiconSize = lexiconSize; - } - - public ItemStack getItemStack() { - return itemStack.copy(); - } - - public int getRate() { - return rate; - } - - public String getEntityString() { - return (String) EntityList.classToStringMapping.get(EntityClass); - } - } + public static ArrayList patterns = new ArrayList(); + public static ArrayList defaultPatterns = new ArrayList(); + + @SubscribeEvent + public void onLivingUpdate(LivingUpdateEvent event) { + if(event.entity.worldObj.isRemote) + return; + + ShedPattern pattern = getShedPattern(event.entity); + + if(pattern != null) { + if(event.entity.worldObj.rand.nextInt(pattern.getRate()) == 0) + event.entity.entityDropItem(pattern.getItemStack(), 0.0F); + } + } + + public static ShedPattern getShedPattern(Entity entity) { + for(ShedPattern pattern : patterns) + if(pattern.EntityClass.isInstance(entity)) + return pattern; + + return null; + } + + public static boolean hasShedding() { + return patterns.size() > 0; + } + + public static void addToLexicon() { + if(!hasShedding()) + return; + + int i = 1; + for(ShedPattern pattern : patterns) { + PageShedding page = new PageShedding(String.valueOf(i), (String)EntityList.classToStringMapping.get(pattern.EntityClass), pattern.lexiconSize, pattern.getItemStack()); + LexiconData.shedding.addPage(page); + } + } + + public static void loadFromConfig(Configuration config) { + defaultPatterns.add(new ShedPattern(EntityChicken.class, new ItemStack(Items.feather), 26000, 20)); + defaultPatterns.add(new ShedPattern(EntitySquid.class, new ItemStack(Items.dye), 18000, 20)); + defaultPatterns.add(new ShedPattern(EntityVillager.class, new ItemStack(Items.emerald), 226000, 40)); + defaultPatterns.add(new ShedPattern(EntitySpider.class, new ItemStack(Items.string), 12000, 40)); + defaultPatterns.add(new ShedPattern(EntityBlaze.class, new ItemStack(Items.blaze_powder), 8000, 40)); + defaultPatterns.add(new ShedPattern(EntityGhast.class, new ItemStack(Items.ghast_tear), 9001, 30)); + defaultPatterns.add(new ShedPattern(EntitySkeleton.class, new ItemStack(Items.bone), 36000, 40)); + defaultPatterns.add(new ShedPattern(EntitySlime.class, new ItemStack(Items.slime_ball), 21000, 40)); + + ArrayList defaultNames = new ArrayList(); + + for(ShedPattern pattern : defaultPatterns) { + loadFromConfig(config, pattern.getEntityString(), pattern); + defaultNames.add(pattern.getEntityString()); + } + + for(Object o : EntityList.stringToClassMapping.entrySet()) { + Entry entry = (Entry) o; + + if(EntityLiving.class.isAssignableFrom(entry.getValue())) { + String name = entry.getKey(); + if(!defaultNames.contains(name)) + loadFromConfig(config, name, null); + } + } + } + + public static void loadFromConfig(Configuration config, String key, ShedPattern defaultPattern) { + String itemName = ""; + int metadata = 0; + int rate = -1; + int lexiconSize = 40; + + if(defaultPattern != null) { + itemName = Item.itemRegistry.getNameForObject(defaultPattern.getItemStack().getItem()); + metadata = defaultPattern.getItemStack().getItemDamage(); + rate = defaultPattern.rate; + lexiconSize = defaultPattern.lexiconSize; + } + + Property prop = config.get("Shedding", key + ".item", itemName); + prop.comment = "Configuration of Shedding for "+key; + itemName = prop.getString(); + rate = config.get("Shedding", key + ".rate", rate).getInt(); + metadata = config.get("Shedding", key + ".metadata", metadata).getInt(); + lexiconSize = config.get("Shedding", key + ".lexiconDisplaySize", lexiconSize).getInt(); + + if(itemName != null && !itemName.isEmpty() && rate != -1) + patterns.add(new ShedPattern((Class) EntityList.stringToClassMapping.get(key), new ItemStack((Item) Item.itemRegistry.getObject(itemName), 1, metadata), rate, lexiconSize)); + } + + public static class ShedPattern { + + Class EntityClass; + ItemStack itemStack; + int rate; + int lexiconSize; + + public ShedPattern(Class EntityClass, ItemStack itemStack, int rate, int lexiconSize) { + this.EntityClass = EntityClass; + this.itemStack = itemStack; + this.rate = rate; + this.lexiconSize = lexiconSize; + } + public ItemStack getItemStack() { + return itemStack.copy(); + } + + public int getRate() { + return rate; + } + + public String getEntityString() { + return (String) EntityList.classToStringMapping.get(EntityClass); + } + } + } diff --git a/src/main/java/vazkii/botania/common/core/handler/SpawnerChangingHandler.java b/src/main/java/vazkii/botania/common/core/handler/SpawnerChangingHandler.java index 0ea91ec0ce..338bcaa744 100644 --- a/src/main/java/vazkii/botania/common/core/handler/SpawnerChangingHandler.java +++ b/src/main/java/vazkii/botania/common/core/handler/SpawnerChangingHandler.java @@ -2,15 +2,14 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jul 30, 2014, 12:37:24 PM (GMT)] */ package vazkii.botania.common.core.handler; -import cpw.mods.fml.common.eventhandler.SubscribeEvent; import net.minecraft.entity.EntityList; import net.minecraft.init.Items; import net.minecraft.item.ItemStack; @@ -18,28 +17,27 @@ import net.minecraft.tileentity.TileEntityMobSpawner; import net.minecraftforge.event.entity.player.PlayerInteractEvent; import net.minecraftforge.event.entity.player.PlayerInteractEvent.Action; +import cpw.mods.fml.common.eventhandler.SubscribeEvent; public final class SpawnerChangingHandler { - @SubscribeEvent - public void onInteract(PlayerInteractEvent event) { - if (event.entityPlayer == null || event.entityPlayer.capabilities == null || event.world == null) - return; // Cauldron breaks stuff + @SubscribeEvent + public void onInteract(PlayerInteractEvent event) { + if(event.entityPlayer == null || event.entityPlayer.capabilities == null || event.world == null) + return; // Cauldron breaks stuff + + if(event.entityPlayer.capabilities.isCreativeMode && !event.world.isRemote && event.action == Action.RIGHT_CLICK_BLOCK && !event.entityPlayer.isSneaking()) { + ItemStack stack = event.entityPlayer.getCurrentEquippedItem(); + if(stack != null && stack.getItem() == Items.spawn_egg) { + TileEntity tile = event.world.getTileEntity(event.x, event.y, event.z); + if(tile instanceof TileEntityMobSpawner) { + TileEntityMobSpawner spawner = (TileEntityMobSpawner) tile; + spawner.func_145881_a().setEntityName(EntityList.getStringFromID(stack.getItemDamage())); + event.world.markBlockForUpdate(event.x, event.y, event.z); + event.setCanceled(true); + } + } + } + } - if (event.entityPlayer.capabilities.isCreativeMode - && !event.world.isRemote - && event.action == Action.RIGHT_CLICK_BLOCK - && !event.entityPlayer.isSneaking()) { - ItemStack stack = event.entityPlayer.getCurrentEquippedItem(); - if (stack != null && stack.getItem() == Items.spawn_egg) { - TileEntity tile = event.world.getTileEntity(event.x, event.y, event.z); - if (tile instanceof TileEntityMobSpawner) { - TileEntityMobSpawner spawner = (TileEntityMobSpawner) tile; - spawner.func_145881_a().setEntityName(EntityList.getStringFromID(stack.getItemDamage())); - event.world.markBlockForUpdate(event.x, event.y, event.z); - event.setCanceled(true); - } - } - } - } } diff --git a/src/main/java/vazkii/botania/common/core/handler/TerrasteelCraftingHandler.java b/src/main/java/vazkii/botania/common/core/handler/TerrasteelCraftingHandler.java index dd80d39eeb..59150bbccd 100644 --- a/src/main/java/vazkii/botania/common/core/handler/TerrasteelCraftingHandler.java +++ b/src/main/java/vazkii/botania/common/core/handler/TerrasteelCraftingHandler.java @@ -2,15 +2,16 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Apr 14, 2014, 4:30:40 PM (GMT)] */ package vazkii.botania.common.core.handler; import java.util.List; + import net.minecraft.entity.item.EntityItem; import net.minecraft.init.Blocks; import net.minecraft.item.ItemStack; @@ -27,177 +28,161 @@ // This is legacy code and is no longer used. Check out TileTerraPlate instead. public final class TerrasteelCraftingHandler { - private static final String TAG_TIME = "Botania-CraftingTime"; - private static final int TIME = 100; - private static final int MANA_PER_TICK = (int) (TilePool.MAX_MANA / 2 / TIME * 0.9); - - public static void onEntityUpdate(EntityItem item) { - ItemStack stack = item.getEntityItem(); - if (stack != null && stack.getItem() == ModItems.manaResource && stack.getItemDamage() == 0) { - int time = validateCraftingItem(item); - - if (time != -1) { - doParticles(item, time); - if (time == TIME) item.worldObj.playSoundAtEntity(item, "botania:terrasteelCraft", 1F, 1F); - - getManaFromPools: - { - int x = MathHelper.floor_double(item.posX); - int y = MathHelper.floor_double(item.posY); - int z = MathHelper.floor_double(item.posZ); - - int range = 12; - - for (int i = -range; i < range + 1; i++) - for (int j = -range; j < range + 1; j++) - for (int k = -range; k < range + 1; k++) { - TileEntity tile = item.worldObj.getTileEntity(x + i, y + j, z + k); - - if (tile instanceof IManaPool) { - IManaPool pool = (IManaPool) tile; - - if (!item.worldObj.isRemote && pool.getCurrentMana() >= MANA_PER_TICK) { - pool.recieveMana(-MANA_PER_TICK); - item.worldObj.markBlockForUpdate(tile.xCoord, tile.yCoord, tile.zCoord); - incrementCraftingTime(item, time); - break getManaFromPools; - } - } - } - } - } - } - } - - static int validateCraftingItem(EntityItem item) { - ItemStack estack = item.getEntityItem(); - if (estack.stackSize != 1) return -1; - - int x = MathHelper.floor_double(item.posX); - int y = MathHelper.floor_double(item.posY); - int z = MathHelper.floor_double(item.posZ); - - if (item.worldObj.getBlock(x, y - 1, z) != Blocks.beacon) return -1; - - TileEntityBeacon beacon = (TileEntityBeacon) item.worldObj.getTileEntity(x, y - 1, z); - if (beacon.getLevels() <= 0) return -1; - - List items = item.worldObj.getEntitiesWithinAABB( - EntityItem.class, AxisAlignedBB.getBoundingBox(x, y, z, x + 1, y + 1, z + 1)); - - EntityItem diamond = null; - EntityItem pearl = null; - - for (EntityItem otherItem : items) { - if (otherItem == item) continue; - - ItemStack stack = otherItem.getEntityItem(); - if (stack.getItem() == ModItems.manaResource && stack.stackSize == 1) { - int meta = stack.getItemDamage(); - if (meta == 1) { - if (pearl == null) { - pearl = otherItem; - continue; - } else return -1; - } else if (meta == 2) { - if (diamond == null) { - diamond = otherItem; - continue; - } else return -1; - } else return -1; - } else return -1; - } - - if (diamond != null && pearl != null) { - int time = getTimeInCrafting(item); - if (time > 0) { - diamond.delayBeforeCanPickup = 1; - diamond.age = 0; - pearl.delayBeforeCanPickup = 1; - pearl.age = 0; - item.delayBeforeCanPickup = 1; - item.age = 0; - } - - return time; - } - return -1; - } - - static int getTimeInCrafting(EntityItem item) { - ItemStack stack = item.getEntityItem(); - return ItemNBTHelper.getInt(stack, TAG_TIME, 0); - } - - static void doParticles(EntityItem item, int ticks) { - if (item.worldObj.isRemote) { - int totalSpiritCount = 3; - double tickIncrement = 360D / totalSpiritCount; - - int speed = 5; - double wticks = ticks * speed - tickIncrement; - - double r = Math.sin((ticks - TIME) / 10D) * 2; - double g = Math.sin(wticks * Math.PI / 180 * 0.55); - - for (int i = 0; i < totalSpiritCount; i++) { - double x = (int) item.posX + Math.sin(wticks * Math.PI / 180) * r + 0.5; - double y = (int) item.posY + 0.25; - double z = (int) item.posZ + Math.cos(wticks * Math.PI / 180) * r + 0.5; - - wticks += tickIncrement; - float[] colorsfx = new float[] {0F, (float) ticks / (float) TIME, 1F - (float) ticks / (float) TIME}; - Botania.proxy.wispFX( - item.worldObj, x, y, z, colorsfx[0], colorsfx[1], colorsfx[2], 0.85F, (float) g * 0.05F, 0.25F); - Botania.proxy.wispFX( - item.worldObj, - x, - y, - z, - colorsfx[0], - colorsfx[1], - colorsfx[2], - (float) Math.random() * 0.1F + 0.1F, - (float) (Math.random() - 0.5) * 0.05F, - (float) (Math.random() - 0.5) * 0.05F, - (float) (Math.random() - 0.5) * 0.05F, - 0.9F); - - if (ticks == TIME) - for (int j = 0; j < 15; j++) - Botania.proxy.wispFX( - item.worldObj, - item.posX, - item.posY, - item.posZ, - colorsfx[0], - colorsfx[1], - colorsfx[2], - (float) Math.random() * 0.15F + 0.15F, - (float) (Math.random() - 0.5F) * 0.125F, - (float) (Math.random() - 0.5F) * 0.125F, - (float) (Math.random() - 0.5F) * 0.125F); - } - } - } - - static void incrementCraftingTime(EntityItem item, int time) { - if (time >= TIME) finalizeCraftingRecipe(item); - else { - ItemStack stack = item.getEntityItem(); - ItemNBTHelper.setInt(stack, TAG_TIME, time + 1); - } - } - - static void finalizeCraftingRecipe(EntityItem item) { - int x = MathHelper.floor_double(item.posX); - int y = MathHelper.floor_double(item.posY); - int z = MathHelper.floor_double(item.posZ); - - List items = item.worldObj.getEntitiesWithinAABB( - EntityItem.class, AxisAlignedBB.getBoundingBox(x, y, z, x + 1, y + 1, z + 1)); - for (EntityItem otherItem : items) - if (otherItem != item) otherItem.setDead(); - else item.setEntityItemStack(new ItemStack(ModItems.manaResource, 1, 4)); - } + private static final String TAG_TIME = "Botania-CraftingTime"; + private static final int TIME = 100; + private static final int MANA_PER_TICK = (int) (TilePool.MAX_MANA / 2 / TIME * 0.9); + + public static void onEntityUpdate(EntityItem item) { + ItemStack stack = item.getEntityItem(); + if(stack != null && stack.getItem() == ModItems.manaResource && stack.getItemDamage() == 0) { + int time = validateCraftingItem(item); + + if(time != -1) { + doParticles(item, time); + if(time == TIME) + item.worldObj.playSoundAtEntity(item, "botania:terrasteelCraft", 1F, 1F); + + getManaFromPools : { + int x = MathHelper.floor_double(item.posX); + int y = MathHelper.floor_double(item.posY); + int z = MathHelper.floor_double(item.posZ); + + int range = 12; + + for(int i = -range; i < range + 1; i++) + for(int j = -range; j < range + 1; j++) + for(int k = - range; k < range + 1; k++) { + TileEntity tile = item.worldObj.getTileEntity(x + i, y + j, z + k); + + if(tile instanceof IManaPool) { + IManaPool pool = (IManaPool) tile; + + if(!item.worldObj.isRemote && pool.getCurrentMana() >= MANA_PER_TICK) { + pool.recieveMana(-MANA_PER_TICK); + item.worldObj.markBlockForUpdate(tile.xCoord, tile.yCoord, tile.zCoord); + incrementCraftingTime(item, time); + break getManaFromPools; + } + } + } + } + } + } + } + + static int validateCraftingItem(EntityItem item) { + ItemStack estack = item.getEntityItem(); + if(estack.stackSize != 1) + return -1; + + int x = MathHelper.floor_double(item.posX); + int y = MathHelper.floor_double(item.posY); + int z = MathHelper.floor_double(item.posZ); + + if(item.worldObj.getBlock(x, y - 1, z) != Blocks.beacon) + return -1; + + TileEntityBeacon beacon = (TileEntityBeacon) item.worldObj.getTileEntity(x, y - 1, z); + if(beacon.getLevels() <= 0) + return -1; + + List items = item.worldObj.getEntitiesWithinAABB(EntityItem.class, AxisAlignedBB.getBoundingBox(x, y, z, x + 1, y + 1, z + 1)); + + EntityItem diamond = null; + EntityItem pearl = null; + + for(EntityItem otherItem : items) { + if(otherItem == item) + continue; + + ItemStack stack = otherItem.getEntityItem(); + if(stack.getItem() == ModItems.manaResource && stack.stackSize == 1) { + int meta = stack.getItemDamage(); + if(meta == 1) { + if(pearl == null) { + pearl = otherItem; + continue; + } else return -1; + } else if(meta == 2) { + if(diamond == null) { + diamond = otherItem; + continue; + } else return -1; + } else return -1; + } else return -1; + } + + if(diamond != null && pearl != null) { + int time = getTimeInCrafting(item); + if(time > 0) { + diamond.delayBeforeCanPickup = 1; + diamond.age = 0; + pearl.delayBeforeCanPickup = 1; + pearl.age = 0; + item.delayBeforeCanPickup = 1; + item.age = 0; + } + + return time; + } + return -1; + } + + static int getTimeInCrafting(EntityItem item) { + ItemStack stack = item.getEntityItem(); + return ItemNBTHelper.getInt(stack, TAG_TIME, 0); + } + + static void doParticles(EntityItem item, int ticks) { + if(item.worldObj.isRemote) { + int totalSpiritCount = 3; + double tickIncrement = 360D / totalSpiritCount; + + int speed = 5; + double wticks = ticks * speed - tickIncrement; + + double r = Math.sin((ticks - TIME) / 10D) * 2; + double g = Math.sin(wticks * Math.PI / 180 * 0.55); + + for(int i = 0; i < totalSpiritCount; i++) { + double x = (int) item.posX + Math.sin(wticks * Math.PI / 180) * r + 0.5; + double y = (int) item.posY + 0.25; + double z = (int) item.posZ + Math.cos(wticks * Math.PI / 180) * r + 0.5; + + wticks += tickIncrement; + float[] colorsfx = new float[] { + 0F, (float) ticks / (float) TIME, 1F - (float) ticks / (float) TIME + }; + Botania.proxy.wispFX(item.worldObj, x, y, z, colorsfx[0], colorsfx[1], colorsfx[2], 0.85F, (float)g * 0.05F, 0.25F); + Botania.proxy.wispFX(item.worldObj, x, y, z, colorsfx[0], colorsfx[1], colorsfx[2], (float) Math.random() * 0.1F + 0.1F, (float) (Math.random() - 0.5) * 0.05F, (float) (Math.random() - 0.5) * 0.05F, (float) (Math.random() - 0.5) * 0.05F, 0.9F); + + if(ticks == TIME) + for(int j = 0; j < 15; j++) + Botania.proxy.wispFX(item.worldObj, item.posX, item.posY, item.posZ, colorsfx[0], colorsfx[1], colorsfx[2], (float) Math.random() * 0.15F + 0.15F, (float) (Math.random() - 0.5F) * 0.125F, (float) (Math.random() - 0.5F) * 0.125F, (float) (Math.random() - 0.5F) * 0.125F); + } + } + } + + static void incrementCraftingTime(EntityItem item, int time) { + if(time >= TIME) + finalizeCraftingRecipe(item); + + else { + ItemStack stack = item.getEntityItem(); + ItemNBTHelper.setInt(stack, TAG_TIME, time + 1); + } + } + + static void finalizeCraftingRecipe(EntityItem item) { + int x = MathHelper.floor_double(item.posX); + int y = MathHelper.floor_double(item.posY); + int z = MathHelper.floor_double(item.posZ); + + List items = item.worldObj.getEntitiesWithinAABB(EntityItem.class, AxisAlignedBB.getBoundingBox(x, y, z, x + 1, y + 1, z + 1)); + for(EntityItem otherItem : items) + if(otherItem != item) + otherItem.setDead(); + else item.setEntityItemStack(new ItemStack(ModItems.manaResource, 1, 4)); + } + } diff --git a/src/main/java/vazkii/botania/common/core/helper/ExperienceHelper.java b/src/main/java/vazkii/botania/common/core/helper/ExperienceHelper.java index ed07861c5d..7e04748a98 100644 --- a/src/main/java/vazkii/botania/common/core/helper/ExperienceHelper.java +++ b/src/main/java/vazkii/botania/common/core/helper/ExperienceHelper.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [? (GMT)] */ package vazkii.botania.common.core.helper; @@ -15,35 +15,40 @@ // From OpenBlocksLib: https://github.com/OpenMods/OpenModsLib public class ExperienceHelper { - public static int getPlayerXP(EntityPlayer player) { - return (int) (getExperienceForLevel(player.experienceLevel) + player.experience * player.xpBarCap()); - } - - public static void drainPlayerXP(EntityPlayer player, int amount) { - addPlayerXP(player, -amount); - } - - public static void addPlayerXP(EntityPlayer player, int amount) { - int experience = getPlayerXP(player) + amount; - player.experienceTotal = experience; - player.experienceLevel = getLevelForExperience(experience); - int expForLevel = getExperienceForLevel(player.experienceLevel); - player.experience = (float) (experience - expForLevel) / (float) player.xpBarCap(); - } - - public static int getExperienceForLevel(int level) { - if (level == 0) return 0; - - if (level > 0 && level < 16) return level * 17; - else if (level > 15 && level < 31) return (int) (1.5 * level * level - 29.5 * level + 360); - else return (int) (3.5 * level * level - 151.5 * level + 2220); - } - - public static int getLevelForExperience(int experience) { - int i = 0; - while (getExperienceForLevel(i) <= experience) { - i++; - } - return i - 1; - } + public static int getPlayerXP(EntityPlayer player) { + return (int)(getExperienceForLevel(player.experienceLevel) + player.experience * player.xpBarCap()); + } + + public static void drainPlayerXP(EntityPlayer player, int amount) { + addPlayerXP(player, -amount); + } + + public static void addPlayerXP(EntityPlayer player, int amount) { + int experience = getPlayerXP(player) + amount; + player.experienceTotal = experience; + player.experienceLevel = getLevelForExperience(experience); + int expForLevel = getExperienceForLevel(player.experienceLevel); + player.experience = (float)(experience - expForLevel) / (float)player.xpBarCap(); + } + + public static int getExperienceForLevel(int level) { + if (level == 0) + return 0; + + if (level > 0 && level < 16) + return level * 17; + else if (level > 15 && level < 31) + return (int) (1.5 * level * level - 29.5 * level + 360); + else + return (int) (3.5 * level * level - 151.5 * level + 2220); + } + + public static int getLevelForExperience(int experience) { + int i = 0; + while (getExperienceForLevel(i) <= experience) { + i++; + } + return i - 1; + } + } diff --git a/src/main/java/vazkii/botania/common/core/helper/InventoryHelper.java b/src/main/java/vazkii/botania/common/core/helper/InventoryHelper.java index 24e94f78ed..d553eda949 100644 --- a/src/main/java/vazkii/botania/common/core/helper/InventoryHelper.java +++ b/src/main/java/vazkii/botania/common/core/helper/InventoryHelper.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [? (GMT)] */ package vazkii.botania.common.core.helper; @@ -14,6 +14,7 @@ import java.util.HashSet; import java.util.List; import java.util.Set; + import net.minecraft.block.Block; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.inventory.IInventory; @@ -28,337 +29,335 @@ import net.minecraft.world.World; import net.minecraftforge.common.util.ForgeDirection; -// From OpenBlocksLib: https://github.com/OpenMods/OpenModsLib +//From OpenBlocksLib: https://github.com/OpenMods/OpenModsLib public class InventoryHelper { - public static void tryInsertStack(IInventory targetInventory, int slot, ItemStack stack, boolean canMerge) { - if (targetInventory.isItemValidForSlot(slot, stack)) { - ItemStack targetStack = targetInventory.getStackInSlot(slot); - if (targetStack == null) { - int space = targetInventory.getInventoryStackLimit(); - int mergeAmount = Math.min(space, stack.stackSize); - - ItemStack copy = stack.copy(); - copy.stackSize = mergeAmount; - targetInventory.setInventorySlotContents(slot, copy); - stack.stackSize -= mergeAmount; - } else if (canMerge) { - if (targetInventory.isItemValidForSlot(slot, stack) && areMergeCandidates(stack, targetStack)) { - int space = Math.min(targetInventory.getInventoryStackLimit(), targetStack.getMaxStackSize()) - - targetStack.stackSize; - int mergeAmount = Math.min(space, stack.stackSize); - - ItemStack copy = targetStack.copy(); - copy.stackSize += mergeAmount; - targetInventory.setInventorySlotContents(slot, copy); - stack.stackSize -= mergeAmount; - } - } - } - } - - protected static boolean areMergeCandidates(ItemStack source, ItemStack target) { - return source.isItemEqual(target) - && ItemStack.areItemStackTagsEqual(source, target) - && target.stackSize < target.getMaxStackSize(); - } - - public static void insertItemIntoInventory(IInventory inventory, ItemStack stack) { - insertItemIntoInventory(inventory, stack, ForgeDirection.UNKNOWN, -1); - } - - public static void insertItemIntoInventory( - IInventory inventory, ItemStack stack, ForgeDirection side, int intoSlot) { - insertItemIntoInventory(inventory, stack, side, intoSlot, true); - } - - public static void insertItemIntoInventory( - IInventory inventory, ItemStack stack, ForgeDirection side, int intoSlot, boolean doMove) { - insertItemIntoInventory(inventory, stack, side, intoSlot, doMove, true); - } - - public static void insertItemIntoInventory( - IInventory inventory, - ItemStack stack, - ForgeDirection side, - int intoSlot, - boolean doMove, - boolean canStack) { - if (stack == null) return; - - IInventory targetInventory = inventory; - - if (!doMove) { - targetInventory = new GenericInventory("temporary.inventory", false, targetInventory.getSizeInventory()); - ((GenericInventory) targetInventory).copyFrom(inventory); - } - - int i = 0; - int[] attemptSlots; - - if (inventory instanceof ISidedInventory && side != ForgeDirection.UNKNOWN) { - attemptSlots = ((ISidedInventory) inventory).getAccessibleSlotsFromSide(side.ordinal()); - if (attemptSlots == null) attemptSlots = new int[0]; - } else { - attemptSlots = new int[inventory.getSizeInventory()]; - for (int a = 0; a < inventory.getSizeInventory(); a++) attemptSlots[a] = a; - } - if (intoSlot > -1) { - Set x = new HashSet(); - for (int attemptedSlot : attemptSlots) x.add(attemptedSlot); - - if (x.contains(intoSlot)) attemptSlots = new int[] {intoSlot}; - else attemptSlots = new int[0]; - } - while (stack.stackSize > 0 && i < attemptSlots.length) { - if (side != ForgeDirection.UNKNOWN && inventory instanceof ISidedInventory) - if (!((ISidedInventory) inventory).canInsertItem(attemptSlots[i], stack, side.ordinal())) { - i++; - continue; - } - - tryInsertStack(targetInventory, attemptSlots[i], stack, canStack); - i++; - } - } - - public static int testInventoryInsertion(IInventory inventory, ItemStack item, ForgeDirection side) { - if (item == null || item.stackSize == 0) return 0; - item = item.copy(); - - if (inventory == null) return 0; - - inventory.getSizeInventory(); - - int itemSizeCounter = item.stackSize; - int[] availableSlots; - - if (inventory instanceof ISidedInventory) - availableSlots = ((ISidedInventory) inventory).getAccessibleSlotsFromSide(side.ordinal()); - else { - availableSlots = buildSlotsForLinearInventory(inventory); - } - - for (int i : availableSlots) { - if (itemSizeCounter <= 0) break; - - if (!inventory.isItemValidForSlot(i, item)) continue; - - if (side != ForgeDirection.UNKNOWN && inventory instanceof ISidedInventory) - if (!((ISidedInventory) inventory).canInsertItem(i, item, side.ordinal())) continue; - - ItemStack inventorySlot = inventory.getStackInSlot(i); - if (inventorySlot == null) - itemSizeCounter -= - Math.min(Math.min(itemSizeCounter, inventory.getInventoryStackLimit()), item.getMaxStackSize()); - else if (areMergeCandidates(item, inventorySlot)) { - int space = Math.min(inventory.getInventoryStackLimit(), inventorySlot.getMaxStackSize()) - - inventorySlot.stackSize; - itemSizeCounter -= Math.min(itemSizeCounter, space); - } - } - - if (itemSizeCounter != item.stackSize) { - itemSizeCounter = Math.max(itemSizeCounter, 0); - return item.stackSize - itemSizeCounter; - } - - return 0; - } - - public static IInventory getInventory(World world, int x, int y, int z) { - TileEntity tileEntity = world.getTileEntity(x, y, z); - if (tileEntity instanceof TileEntityChest) { - Block chestBlock = world.getBlock(x, y, z); - if (world.getBlock(x - 1, y, z) == chestBlock) - return new InventoryLargeChest( - "Large chest", (IInventory) world.getTileEntity(x - 1, y, z), (IInventory) tileEntity); - if (world.getBlock(x + 1, y, z) == chestBlock) - return new InventoryLargeChest( - "Large chest", (IInventory) tileEntity, (IInventory) world.getTileEntity(x + 1, y, z)); - if (world.getBlock(x, y, z - 1) == chestBlock) - return new InventoryLargeChest( - "Large chest", (IInventory) world.getTileEntity(x, y, z - 1), (IInventory) tileEntity); - if (world.getBlock(x, y, z + 1) == chestBlock) - return new InventoryLargeChest( - "Large chest", (IInventory) tileEntity, (IInventory) world.getTileEntity(x, y, z + 1)); - } - return tileEntity instanceof IInventory ? (IInventory) tileEntity : null; - } - - public static IInventory getInventory(World world, int x, int y, int z, ForgeDirection direction) { - if (direction != null && direction != ForgeDirection.UNKNOWN) { - x += direction.offsetX; - y += direction.offsetY; - z += direction.offsetZ; - } - return getInventory(world, x, y, z); - } - - public static IInventory getInventory(IInventory inventory) { - if (inventory instanceof TileEntityChest) { - TileEntity te = (TileEntity) inventory; - return getInventory(te.getWorldObj(), te.xCoord, te.yCoord, te.zCoord); - } - return inventory; - } - - public static int[] buildSlotsForLinearInventory(IInventory inv) { - int[] slots = new int[inv.getSizeInventory()]; - for (int i = 0; i < slots.length; i++) slots[i] = i; - - return slots; - } - - public static class GenericInventory implements IInventory { - - protected String inventoryTitle; - protected int slotsCount; - protected ItemStack[] inventoryContents; - protected boolean isInvNameLocalized; - - public GenericInventory(String name, boolean isInvNameLocalized, int size) { - this.isInvNameLocalized = isInvNameLocalized; - slotsCount = size; - inventoryTitle = name; - inventoryContents = new ItemStack[size]; - } - - @Override - public ItemStack decrStackSize(int par1, int par2) { - if (inventoryContents[par1] != null) { - ItemStack itemstack; - - if (inventoryContents[par1].stackSize <= par2) { - itemstack = inventoryContents[par1]; - inventoryContents[par1] = null; - return itemstack; - } - - itemstack = inventoryContents[par1].splitStack(par2); - if (inventoryContents[par1].stackSize == 0) inventoryContents[par1] = null; - - return itemstack; - } - return null; - } - - @Override - public int getInventoryStackLimit() { - return 64; - } - - @Override - public int getSizeInventory() { - return slotsCount; - } - - @Override - public ItemStack getStackInSlot(int i) { - return inventoryContents[i]; - } - - public ItemStack getStackInSlot(Enum i) { - return getStackInSlot(i.ordinal()); - } - - @Override - public ItemStack getStackInSlotOnClosing(int i) { - if (i >= inventoryContents.length) return null; - - if (inventoryContents[i] != null) { - ItemStack itemstack = inventoryContents[i]; - inventoryContents[i] = null; - return itemstack; - } - - return null; - } - - public boolean isItem(int slot, Item item) { - return inventoryContents[slot] != null && inventoryContents[slot].getItem() == item; - } - - @Override - public boolean isItemValidForSlot(int i, ItemStack itemstack) { - return true; - } - - @Override - public boolean isUseableByPlayer(EntityPlayer entityplayer) { - return true; - } - - public void clearAndSetSlotCount(int amount) { - slotsCount = amount; - inventoryContents = new ItemStack[amount]; - } - - public void readFromNBT(NBTTagCompound tag) { - if (tag.hasKey("size")) slotsCount = tag.getInteger("size"); - - NBTTagList nbttaglist = tag.getTagList("Items", 10); - inventoryContents = new ItemStack[slotsCount]; - for (int i = 0; i < nbttaglist.tagCount(); i++) { - NBTTagCompound stacktag = nbttaglist.getCompoundTagAt(i); - int j = stacktag.getByte("Slot"); - if (j >= 0 && j < inventoryContents.length) - inventoryContents[j] = ItemStack.loadItemStackFromNBT(stacktag); - } - } - - @Override - public void setInventorySlotContents(int i, ItemStack itemstack) { - inventoryContents[i] = itemstack; - - if (itemstack != null && itemstack.stackSize > getInventoryStackLimit()) - itemstack.stackSize = getInventoryStackLimit(); - } - - public void writeToNBT(NBTTagCompound tag) { - tag.setInteger("size", getSizeInventory()); - NBTTagList nbttaglist = new NBTTagList(); - for (int i = 0; i < inventoryContents.length; i++) { - if (inventoryContents[i] != null) { - NBTTagCompound stacktag = new NBTTagCompound(); - stacktag.setByte("Slot", (byte) i); - inventoryContents[i].writeToNBT(stacktag); - nbttaglist.appendTag(stacktag); - } - } - tag.setTag("Items", nbttaglist); - } - - public void copyFrom(IInventory inventory) { - for (int i = 0; i < inventory.getSizeInventory(); i++) - if (i < getSizeInventory()) { - ItemStack stack = inventory.getStackInSlot(i); - if (stack != null) setInventorySlotContents(i, stack.copy()); - else setInventorySlotContents(i, null); - } - } - - public List contents() { - return Arrays.asList(inventoryContents); - } - - @Override - public String getInventoryName() { - return null; - } - - @Override - public boolean hasCustomInventoryName() { - return false; - } - - @Override - public void markDirty() {} - - @Override - public void openInventory() {} - - @Override - public void closeInventory() {} - } + public static void tryInsertStack(IInventory targetInventory, int slot, ItemStack stack, boolean canMerge) { + if(targetInventory.isItemValidForSlot(slot, stack)) { + ItemStack targetStack = targetInventory.getStackInSlot(slot); + if(targetStack == null) { + int space = targetInventory.getInventoryStackLimit(); + int mergeAmount = Math.min(space, stack.stackSize); + + ItemStack copy = stack.copy(); + copy.stackSize = mergeAmount; + targetInventory.setInventorySlotContents(slot, copy); + stack.stackSize -= mergeAmount; + } else if(canMerge) { + if(targetInventory.isItemValidForSlot(slot, stack) && areMergeCandidates(stack, targetStack)) { + int space = Math.min(targetInventory.getInventoryStackLimit(), targetStack.getMaxStackSize()) - targetStack.stackSize; + int mergeAmount = Math.min(space, stack.stackSize); + + ItemStack copy = targetStack.copy(); + copy.stackSize += mergeAmount; + targetInventory.setInventorySlotContents(slot, copy); + stack.stackSize -= mergeAmount; + } + } + } + } + + protected static boolean areMergeCandidates(ItemStack source, ItemStack target) { + return source.isItemEqual(target) && ItemStack.areItemStackTagsEqual(source, target) && target.stackSize < target.getMaxStackSize(); + } + + public static void insertItemIntoInventory(IInventory inventory, ItemStack stack) { + insertItemIntoInventory(inventory, stack, ForgeDirection.UNKNOWN, -1); + } + + public static void insertItemIntoInventory(IInventory inventory, ItemStack stack, ForgeDirection side, int intoSlot) { + insertItemIntoInventory(inventory, stack, side, intoSlot, true); + } + + public static void insertItemIntoInventory(IInventory inventory, ItemStack stack, ForgeDirection side, int intoSlot, boolean doMove) { + insertItemIntoInventory(inventory, stack, side, intoSlot, doMove, true); + } + + public static void insertItemIntoInventory(IInventory inventory, ItemStack stack, ForgeDirection side, int intoSlot, boolean doMove, boolean canStack) { + if(stack == null) return; + + IInventory targetInventory = inventory; + + if(!doMove) { + targetInventory = new GenericInventory("temporary.inventory", false, targetInventory.getSizeInventory()); + ((GenericInventory)targetInventory).copyFrom(inventory); + } + + int i = 0; + int[] attemptSlots; + + if(inventory instanceof ISidedInventory && side != ForgeDirection.UNKNOWN) { + attemptSlots = ((ISidedInventory)inventory).getAccessibleSlotsFromSide(side.ordinal()); + if(attemptSlots == null) + attemptSlots = new int[0]; + } else { + attemptSlots = new int[inventory.getSizeInventory()]; + for(int a = 0; a < inventory.getSizeInventory(); a++) + attemptSlots[a] = a; + } + if(intoSlot > -1) { + Set x = new HashSet(); + for(int attemptedSlot : attemptSlots) + x.add(attemptedSlot); + + if(x.contains(intoSlot)) + attemptSlots = new int[] { intoSlot }; + else attemptSlots = new int[0]; + } + while(stack.stackSize > 0 && i < attemptSlots.length) { + if(side != ForgeDirection.UNKNOWN && inventory instanceof ISidedInventory) + if(!((ISidedInventory)inventory).canInsertItem(attemptSlots[i], stack, side.ordinal())) { + i++; + continue; + } + + tryInsertStack(targetInventory, attemptSlots[i], stack, canStack); + i++; + } + } + + public static int testInventoryInsertion(IInventory inventory, ItemStack item, ForgeDirection side) { + if(item == null || item.stackSize == 0) + return 0; + item = item.copy(); + + if(inventory == null) + return 0; + + inventory.getSizeInventory(); + + int itemSizeCounter = item.stackSize; + int[] availableSlots; + + if(inventory instanceof ISidedInventory) + availableSlots = ((ISidedInventory) inventory).getAccessibleSlotsFromSide(side.ordinal()); + else { + availableSlots = buildSlotsForLinearInventory(inventory); + } + + for(int i : availableSlots) { + if(itemSizeCounter <= 0) + break; + + if (!inventory.isItemValidForSlot(i, item)) + continue; + + if(side != ForgeDirection.UNKNOWN && inventory instanceof ISidedInventory) + if(!((ISidedInventory)inventory).canInsertItem(i, item, side.ordinal())) + continue; + + ItemStack inventorySlot = inventory.getStackInSlot(i); + if(inventorySlot == null) + itemSizeCounter -= Math.min(Math.min(itemSizeCounter, inventory.getInventoryStackLimit()), item.getMaxStackSize()); + else if(areMergeCandidates(item, inventorySlot)) { + int space = Math.min(inventory.getInventoryStackLimit(), inventorySlot.getMaxStackSize()) - inventorySlot.stackSize; + itemSizeCounter -= Math.min(itemSizeCounter, space); + } + } + + if(itemSizeCounter != item.stackSize) { + itemSizeCounter = Math.max(itemSizeCounter, 0); + return item.stackSize - itemSizeCounter; + } + + return 0; + } + + public static IInventory getInventory(World world, int x, int y, int z) { + TileEntity tileEntity = world.getTileEntity(x, y, z); + if(tileEntity instanceof TileEntityChest) { + Block chestBlock = world.getBlock(x, y, z); + if(world.getBlock(x - 1, y, z) == chestBlock) + return new InventoryLargeChest("Large chest", (IInventory)world.getTileEntity(x - 1, y, z), (IInventory)tileEntity); + if(world.getBlock(x + 1, y, z) == chestBlock) + return new InventoryLargeChest("Large chest", (IInventory)tileEntity, (IInventory)world.getTileEntity(x + 1, y, z)); + if(world.getBlock(x, y, z - 1) == chestBlock) + return new InventoryLargeChest("Large chest", (IInventory)world.getTileEntity(x, y, z - 1), (IInventory)tileEntity); + if(world.getBlock(x, y, z + 1) == chestBlock) + return new InventoryLargeChest("Large chest", (IInventory)tileEntity, (IInventory)world.getTileEntity(x, y, z + 1)); + } + return tileEntity instanceof IInventory ? (IInventory)tileEntity : null; + } + + public static IInventory getInventory(World world, int x, int y, int z, ForgeDirection direction) { + if(direction != null && direction != ForgeDirection.UNKNOWN) { + x += direction.offsetX; + y += direction.offsetY; + z += direction.offsetZ; + } + return getInventory(world, x, y, z); + + } + + public static IInventory getInventory(IInventory inventory) { + if(inventory instanceof TileEntityChest) { + TileEntity te = (TileEntity)inventory; + return getInventory(te.getWorldObj(), te.xCoord, te.yCoord, te.zCoord); + } + return inventory; + } + + public static int[] buildSlotsForLinearInventory(IInventory inv) { + int[] slots = new int[inv.getSizeInventory()]; + for (int i = 0; i < slots.length; i++) + slots[i] = i; + + return slots; + } + + public static class GenericInventory implements IInventory { + + protected String inventoryTitle; + protected int slotsCount; + protected ItemStack[] inventoryContents; + protected boolean isInvNameLocalized; + + public GenericInventory(String name, boolean isInvNameLocalized, int size) { + this.isInvNameLocalized = isInvNameLocalized; + slotsCount = size; + inventoryTitle = name; + inventoryContents = new ItemStack[size]; + } + + @Override + public ItemStack decrStackSize(int par1, int par2) { + if(inventoryContents[par1] != null) { + ItemStack itemstack; + + if(inventoryContents[par1].stackSize <= par2) { + itemstack = inventoryContents[par1]; + inventoryContents[par1] = null; + return itemstack; + } + + itemstack = inventoryContents[par1].splitStack(par2); + if(inventoryContents[par1].stackSize == 0) + inventoryContents[par1] = null; + + return itemstack; + } + return null; + } + + @Override + public int getInventoryStackLimit() { + return 64; + } + + @Override + public int getSizeInventory() { + return slotsCount; + } + + @Override + public ItemStack getStackInSlot(int i) { + return inventoryContents[i]; + } + + public ItemStack getStackInSlot(Enum i) { + return getStackInSlot(i.ordinal()); + } + + @Override + public ItemStack getStackInSlotOnClosing(int i) { + if(i >= inventoryContents.length) + return null; + + if(inventoryContents[i] != null) { + ItemStack itemstack = inventoryContents[i]; + inventoryContents[i] = null; + return itemstack; + } + + return null; + } + + public boolean isItem(int slot, Item item) { + return inventoryContents[slot] != null && inventoryContents[slot].getItem() == item; + } + + @Override + public boolean isItemValidForSlot(int i, ItemStack itemstack) { + return true; + } + + @Override + public boolean isUseableByPlayer(EntityPlayer entityplayer) { + return true; + } + + public void clearAndSetSlotCount(int amount) { + slotsCount = amount; + inventoryContents = new ItemStack[amount]; + } + + public void readFromNBT(NBTTagCompound tag) { + if(tag.hasKey("size")) + slotsCount = tag.getInteger("size"); + + NBTTagList nbttaglist = tag.getTagList("Items", 10); + inventoryContents = new ItemStack[slotsCount]; + for(int i = 0; i < nbttaglist.tagCount(); i++) { + NBTTagCompound stacktag = nbttaglist.getCompoundTagAt(i); + int j = stacktag.getByte("Slot"); + if(j >= 0 && j < inventoryContents.length) + inventoryContents[j] = ItemStack.loadItemStackFromNBT(stacktag); + } + } + + @Override + public void setInventorySlotContents(int i, ItemStack itemstack) { + inventoryContents[i] = itemstack; + + if(itemstack != null && itemstack.stackSize > getInventoryStackLimit()) + itemstack.stackSize = getInventoryStackLimit(); + } + + public void writeToNBT(NBTTagCompound tag) { + tag.setInteger("size", getSizeInventory()); + NBTTagList nbttaglist = new NBTTagList(); + for(int i = 0; i < inventoryContents.length; i++) { + if(inventoryContents[i] != null) { + NBTTagCompound stacktag = new NBTTagCompound(); + stacktag.setByte("Slot", (byte)i); + inventoryContents[i].writeToNBT(stacktag); + nbttaglist.appendTag(stacktag); + } + } + tag.setTag("Items", nbttaglist); + } + + public void copyFrom(IInventory inventory) { + for(int i = 0; i < inventory.getSizeInventory(); i++) + if(i < getSizeInventory()) { + ItemStack stack = inventory.getStackInSlot(i); + if(stack != null) + setInventorySlotContents(i, stack.copy()); + else setInventorySlotContents(i, null); + } + } + + public List contents() { + return Arrays.asList(inventoryContents); + } + + @Override + public String getInventoryName() { + return null; + } + + @Override + public boolean hasCustomInventoryName() { + return false; + } + + @Override + public void markDirty() { } + + @Override + public void openInventory() { } + + @Override + public void closeInventory() { } + } } diff --git a/src/main/java/vazkii/botania/common/core/helper/ItemNBTHelper.java b/src/main/java/vazkii/botania/common/core/helper/ItemNBTHelper.java index 8ae9bf477c..5a0f33421a 100644 --- a/src/main/java/vazkii/botania/common/core/helper/ItemNBTHelper.java +++ b/src/main/java/vazkii/botania/common/core/helper/ItemNBTHelper.java @@ -14,226 +14,229 @@ package vazkii.botania.common.core.helper; import codechicken.nei.PositionedStack; -import java.util.Collection; -import java.util.Set; -import javax.annotation.Nullable; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTBase; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagList; import net.minecraftforge.oredict.OreDictionary; +import javax.annotation.Nullable; +import java.util.Collection; +import java.util.Set; + public final class ItemNBTHelper { - /** Checks if an ItemStack has a Tag Compound **/ - public static boolean detectNBT(ItemStack stack) { - return stack.hasTagCompound(); - } - - /** Tries to initialize an NBT Tag Compound in an ItemStack, - * this will not do anything if the stack already has a tag - * compound **/ - public static void initNBT(ItemStack stack) { - if (!detectNBT(stack)) injectNBT(stack, new NBTTagCompound()); - } - - /** Injects an NBT Tag Compound to an ItemStack, no checks - * are made previously **/ - public static void injectNBT(ItemStack stack, NBTTagCompound nbt) { - stack.setTagCompound(nbt); - } - - /** Gets the NBTTagCompound in an ItemStack. Tries to init it - * previously in case there isn't one present **/ - public static NBTTagCompound getNBT(ItemStack stack) { - initNBT(stack); - return stack.getTagCompound(); - } - - // SETTERS /////////////////////////////////////////////////////////////////// - - public static void setBoolean(ItemStack stack, String tag, boolean b) { - getNBT(stack).setBoolean(tag, b); - } - - public static void setByte(ItemStack stack, String tag, byte b) { - getNBT(stack).setByte(tag, b); - } - - public static void setShort(ItemStack stack, String tag, short s) { - getNBT(stack).setShort(tag, s); - } - - public static void setInt(ItemStack stack, String tag, int i) { - getNBT(stack).setInteger(tag, i); - } - - public static void setLong(ItemStack stack, String tag, long l) { - getNBT(stack).setLong(tag, l); - } - - public static void setFloat(ItemStack stack, String tag, float f) { - getNBT(stack).setFloat(tag, f); - } - - public static void setDouble(ItemStack stack, String tag, double d) { - getNBT(stack).setDouble(tag, d); - } - - public static void setCompound(ItemStack stack, String tag, NBTTagCompound cmp) { - if (!tag.equalsIgnoreCase("ench")) // not override the enchantments - getNBT(stack).setTag(tag, cmp); - } - - public static void setString(ItemStack stack, String tag, String s) { - getNBT(stack).setString(tag, s); - } - - public static void setList(ItemStack stack, String tag, NBTTagList list) { - getNBT(stack).setTag(tag, list); - } - - // GETTERS /////////////////////////////////////////////////////////////////// - - public static boolean verifyExistance(ItemStack stack, String tag) { - return stack != null && getNBT(stack).hasKey(tag); - } - - public static boolean getBoolean(ItemStack stack, String tag, boolean defaultExpected) { - return verifyExistance(stack, tag) ? getNBT(stack).getBoolean(tag) : defaultExpected; - } - - public static byte getByte(ItemStack stack, String tag, byte defaultExpected) { - return verifyExistance(stack, tag) ? getNBT(stack).getByte(tag) : defaultExpected; - } - - public static short getShort(ItemStack stack, String tag, short defaultExpected) { - return verifyExistance(stack, tag) ? getNBT(stack).getShort(tag) : defaultExpected; - } - - public static int getInt(ItemStack stack, String tag, int defaultExpected) { - return verifyExistance(stack, tag) ? getNBT(stack).getInteger(tag) : defaultExpected; - } - - public static long getLong(ItemStack stack, String tag, long defaultExpected) { - return verifyExistance(stack, tag) ? getNBT(stack).getLong(tag) : defaultExpected; - } - - public static float getFloat(ItemStack stack, String tag, float defaultExpected) { - return verifyExistance(stack, tag) ? getNBT(stack).getFloat(tag) : defaultExpected; - } - - public static double getDouble(ItemStack stack, String tag, double defaultExpected) { - return verifyExistance(stack, tag) ? getNBT(stack).getDouble(tag) : defaultExpected; - } - - /** If nullifyOnFail is true it'll return null if it doesn't find any - * compounds, otherwise it'll return a new one. **/ - public static NBTTagCompound getCompound(ItemStack stack, String tag, boolean nullifyOnFail) { - return verifyExistance(stack, tag) - ? getNBT(stack).getCompoundTag(tag) - : nullifyOnFail ? null : new NBTTagCompound(); - } - - public static String getString(ItemStack stack, String tag, String defaultExpected) { - return verifyExistance(stack, tag) ? getNBT(stack).getString(tag) : defaultExpected; - } - - public static NBTTagList getList(ItemStack stack, String tag, int objtype, boolean nullifyOnFail) { - return verifyExistance(stack, tag) - ? getNBT(stack).getTagList(tag, objtype) - : nullifyOnFail ? null : new NBTTagList(); - } - - // Utils /////////////////////////////////////////////////////////////////// - - /** - * NBT-friendly version of {@link codechicken.nei.NEIServerUtils#areStacksSameType(ItemStack, ItemStack)} - * @param stack1 The {@link ItemStack} being compared. - * @param stack2 The {@link ItemStack} to compare to. - * @return whether the two items are the same in terms of itemID, damage and NBT. - */ - public static boolean areStacksSameTypeWithNBT(ItemStack stack1, ItemStack stack2) { - return stack1 != null - && stack2 != null - && stack1.getItem() == stack2.getItem() - && (!stack2.getHasSubtypes() || stack2.getItemDamage() == stack1.getItemDamage()) - && matchTag(stack1.getTagCompound(), stack2.getTagCompound()); - } - - /** - * NBT-friendly version of {@link codechicken.nei.NEIServerUtils#areStacksSameTypeCrafting(ItemStack, ItemStack)} - * @param stack1 The {@link ItemStack} being compared. - * @param stack2 The {@link ItemStack} to compare to. - * @return whether the two items are the same from the perspective of a crafting inventory. - */ - public static boolean areStacksSameTypeCraftingWithNBT(ItemStack stack1, ItemStack stack2) { - return stack1 != null - && stack2 != null - && stack1.getItem() == stack2.getItem() - && (stack1.getItemDamage() == stack2.getItemDamage() - || stack1.getItemDamage() == OreDictionary.WILDCARD_VALUE - || stack2.getItemDamage() == OreDictionary.WILDCARD_VALUE - || stack1.getItem().isDamageable()) - && matchTag(stack1.getTagCompound(), stack2.getTagCompound()); - } - - /** - * Returns true if the `target` tag contains all of the tags and values present in the `template` tag. Recurses into - * compound tags and matches all template keys and values; recurses into list tags and matches the template against - * the first elements of target. Empty lists and compounds in the template will match target lists and compounds of - * any size. - */ - public static boolean matchTag(@Nullable NBTBase template, @Nullable NBTBase target) { - if (template instanceof NBTTagCompound && target instanceof NBTTagCompound) { - return matchTagCompound((NBTTagCompound) template, (NBTTagCompound) target); - } else if (template instanceof NBTTagList && target instanceof NBTTagList) { - return matchTagList((NBTTagList) template, (NBTTagList) target); - } else { - return template == null || (target != null && target.equals(template)); - } - } - - private static boolean matchTagCompound(NBTTagCompound template, NBTTagCompound target) { - if (template.tagMap.size() > target.tagMap.size()) return false; - - //noinspection unchecked - for (String key : (Set) template.func_150296_c()) { - if (!matchTag(template.getTag(key), target.getTag(key))) return false; - } - - return true; - } - - private static boolean matchTagList(NBTTagList template, NBTTagList target) { - if (template.tagCount() > target.tagCount()) return false; - - for (int i = 0; i < template.tagCount(); i++) { - if (!matchTag(get(template, i), get(target, i))) return false; - } - - return true; - } - - private static NBTBase get(NBTTagList tag, int idx) { - return idx >= 0 && idx < tag.tagList.size() ? (NBTBase) tag.tagList.get(idx) : null; - } - - /** - * NBT-friendly version of {@link codechicken.nei.recipe.TemplateRecipeHandler.CachedRecipe#contains(Collection, ItemStack)} - */ - public static boolean cachedRecipeContainsWithNBT(Collection ingredients, ItemStack ingredient) { - for (PositionedStack stack : ingredients) if (positionedStackContainsWithNBT(stack, ingredient)) return true; - - return false; - } - - /** - * NBT-friendly version of {@link codechicken.nei.PositionedStack#contains(ItemStack)} - */ - public static boolean positionedStackContainsWithNBT(PositionedStack stack, ItemStack ingredient) { - for (ItemStack item : stack.items) if (areStacksSameTypeCraftingWithNBT(item, ingredient)) return true; - - return false; - } + /** Checks if an ItemStack has a Tag Compound **/ + public static boolean detectNBT(ItemStack stack) { + return stack.hasTagCompound(); + } + + /** Tries to initialize an NBT Tag Compound in an ItemStack, + * this will not do anything if the stack already has a tag + * compound **/ + public static void initNBT(ItemStack stack) { + if(!detectNBT(stack)) + injectNBT(stack, new NBTTagCompound()); + } + + /** Injects an NBT Tag Compound to an ItemStack, no checks + * are made previously **/ + public static void injectNBT(ItemStack stack, NBTTagCompound nbt) { + stack.setTagCompound(nbt); + } + + /** Gets the NBTTagCompound in an ItemStack. Tries to init it + * previously in case there isn't one present **/ + public static NBTTagCompound getNBT(ItemStack stack) { + initNBT(stack); + return stack.getTagCompound(); + } + + // SETTERS /////////////////////////////////////////////////////////////////// + + public static void setBoolean(ItemStack stack, String tag, boolean b) { + getNBT(stack).setBoolean(tag, b); + } + + public static void setByte(ItemStack stack, String tag, byte b) { + getNBT(stack).setByte(tag, b); + } + + public static void setShort(ItemStack stack, String tag, short s) { + getNBT(stack).setShort(tag, s); + } + + public static void setInt(ItemStack stack, String tag, int i) { + getNBT(stack).setInteger(tag, i); + } + + public static void setLong(ItemStack stack, String tag, long l) { + getNBT(stack).setLong(tag, l); + } + + public static void setFloat(ItemStack stack, String tag, float f) { + getNBT(stack).setFloat(tag, f); + } + + public static void setDouble(ItemStack stack, String tag, double d) { + getNBT(stack).setDouble(tag, d); + } + + public static void setCompound(ItemStack stack, String tag, NBTTagCompound cmp) { + if(!tag.equalsIgnoreCase("ench")) // not override the enchantments + getNBT(stack).setTag(tag, cmp); + } + + public static void setString(ItemStack stack, String tag, String s) { + getNBT(stack).setString(tag, s); + } + + public static void setList(ItemStack stack, String tag, NBTTagList list) { + getNBT(stack).setTag(tag, list); + } + + // GETTERS /////////////////////////////////////////////////////////////////// + + public static boolean verifyExistance(ItemStack stack, String tag) { + return stack != null && getNBT(stack).hasKey(tag); + } + + public static boolean getBoolean(ItemStack stack, String tag, boolean defaultExpected) { + return verifyExistance(stack, tag) ? getNBT(stack).getBoolean(tag) : defaultExpected; + } + + public static byte getByte(ItemStack stack, String tag, byte defaultExpected) { + return verifyExistance(stack, tag) ? getNBT(stack).getByte(tag) : defaultExpected; + } + + public static short getShort(ItemStack stack, String tag, short defaultExpected) { + return verifyExistance(stack, tag) ? getNBT(stack).getShort(tag) : defaultExpected; + } + + public static int getInt(ItemStack stack, String tag, int defaultExpected) { + return verifyExistance(stack, tag) ? getNBT(stack).getInteger(tag) : defaultExpected; + } + + public static long getLong(ItemStack stack, String tag, long defaultExpected) { + return verifyExistance(stack, tag) ? getNBT(stack).getLong(tag) : defaultExpected; + } + + public static float getFloat(ItemStack stack, String tag, float defaultExpected) { + return verifyExistance(stack, tag) ? getNBT(stack).getFloat(tag) : defaultExpected; + } + + public static double getDouble(ItemStack stack, String tag, double defaultExpected) { + return verifyExistance(stack, tag) ? getNBT(stack).getDouble(tag) : defaultExpected; + } + + /** If nullifyOnFail is true it'll return null if it doesn't find any + * compounds, otherwise it'll return a new one. **/ + public static NBTTagCompound getCompound(ItemStack stack, String tag, boolean nullifyOnFail) { + return verifyExistance(stack, tag) ? getNBT(stack).getCompoundTag(tag) : nullifyOnFail ? null : new NBTTagCompound(); + } + + public static String getString(ItemStack stack, String tag, String defaultExpected) { + return verifyExistance(stack, tag) ? getNBT(stack).getString(tag) : defaultExpected; + } + + public static NBTTagList getList(ItemStack stack, String tag, int objtype, boolean nullifyOnFail) { + return verifyExistance(stack, tag) ? getNBT(stack).getTagList(tag, objtype) : nullifyOnFail ? null : new NBTTagList(); + } + + // Utils /////////////////////////////////////////////////////////////////// + + /** + * NBT-friendly version of {@link codechicken.nei.NEIServerUtils#areStacksSameType(ItemStack, ItemStack)} + * @param stack1 The {@link ItemStack} being compared. + * @param stack2 The {@link ItemStack} to compare to. + * @return whether the two items are the same in terms of itemID, damage and NBT. + */ + public static boolean areStacksSameTypeWithNBT(ItemStack stack1, ItemStack stack2) { + return stack1 != null && stack2 != null && + stack1.getItem() == stack2.getItem() && + (!stack2.getHasSubtypes() || stack2.getItemDamage() == stack1.getItemDamage()) && + matchTag(stack1.getTagCompound(), stack2.getTagCompound()); + } + + /** + * NBT-friendly version of {@link codechicken.nei.NEIServerUtils#areStacksSameTypeCrafting(ItemStack, ItemStack)} + * @param stack1 The {@link ItemStack} being compared. + * @param stack2 The {@link ItemStack} to compare to. + * @return whether the two items are the same from the perspective of a crafting inventory. + */ + public static boolean areStacksSameTypeCraftingWithNBT(ItemStack stack1, ItemStack stack2) { + return stack1 != null && stack2 != null && + stack1.getItem() == stack2.getItem() && + ( + stack1.getItemDamage() == stack2.getItemDamage() || + stack1.getItemDamage() == OreDictionary.WILDCARD_VALUE || + stack2.getItemDamage() == OreDictionary.WILDCARD_VALUE || + stack1.getItem().isDamageable() + ) && + matchTag(stack1.getTagCompound(), stack2.getTagCompound()); + } + + /** + * Returns true if the `target` tag contains all of the tags and values present in the `template` tag. Recurses into + * compound tags and matches all template keys and values; recurses into list tags and matches the template against + * the first elements of target. Empty lists and compounds in the template will match target lists and compounds of + * any size. + */ + public static boolean matchTag(@Nullable NBTBase template, @Nullable NBTBase target) { + if (template instanceof NBTTagCompound && target instanceof NBTTagCompound) { + return matchTagCompound((NBTTagCompound) template, (NBTTagCompound) target); + } else if (template instanceof NBTTagList && target instanceof NBTTagList) { + return matchTagList((NBTTagList) template, (NBTTagList) target); + } else { + return template == null || (target != null && target.equals(template)); + } + } + + private static boolean matchTagCompound(NBTTagCompound template, NBTTagCompound target) { + if (template.tagMap.size() > target.tagMap.size()) return false; + + //noinspection unchecked + for (String key : (Set) template.func_150296_c()) { + if (!matchTag(template.getTag(key), target.getTag(key))) return false; + } + + return true; + } + + private static boolean matchTagList(NBTTagList template, NBTTagList target) { + if (template.tagCount() > target.tagCount()) return false; + + for (int i = 0; i < template.tagCount(); i++) { + if (!matchTag(get(template, i), get(target, i))) return false; + } + + return true; + } + + private static NBTBase get(NBTTagList tag, int idx) + { + return idx >= 0 && idx < tag.tagList.size() ? (NBTBase)tag.tagList.get(idx) : null; + } + + /** + * NBT-friendly version of {@link codechicken.nei.recipe.TemplateRecipeHandler.CachedRecipe#contains(Collection, ItemStack)} + */ + public static boolean cachedRecipeContainsWithNBT(Collection ingredients, ItemStack ingredient) { + for (PositionedStack stack : ingredients) + if (positionedStackContainsWithNBT(stack, ingredient)) + return true; + + return false; + } + + /** + * NBT-friendly version of {@link codechicken.nei.PositionedStack#contains(ItemStack)} + */ + public static boolean positionedStackContainsWithNBT(PositionedStack stack, ItemStack ingredient) { + for(ItemStack item : stack.items) + if(areStacksSameTypeCraftingWithNBT(item, ingredient)) + return true; + + return false; + } } diff --git a/src/main/java/vazkii/botania/common/core/helper/MathHelper.java b/src/main/java/vazkii/botania/common/core/helper/MathHelper.java index 01101a2c9e..e31af70427 100644 --- a/src/main/java/vazkii/botania/common/core/helper/MathHelper.java +++ b/src/main/java/vazkii/botania/common/core/helper/MathHelper.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jan 22, 2014, 5:49:50 PM (GMT)] */ package vazkii.botania.common.core.helper; @@ -15,30 +15,30 @@ public final class MathHelper { - public static float pointDistanceSpace(double x1, double y1, double z1, double x2, double y2, double z2) { - return (float) Math.sqrt(Math.pow(x1 - x2, 2) + Math.pow(y1 - y2, 2) + Math.pow(z1 - z2, 2)); - } + public static float pointDistanceSpace(double x1, double y1, double z1, double x2, double y2, double z2) { + return (float) Math.sqrt(Math.pow(x1 - x2, 2) + Math.pow(y1 - y2, 2) + Math.pow(z1 - z2, 2)); + } - // Backwards compatibility - public static float pointDistancePlane(double x1, double y1, double x2, double y2) { - return VanillaPacketDispatcher.pointDistancePlane(x1, y1, x2, y2); - } + // Backwards compatibility + public static float pointDistancePlane(double x1, double y1, double x2, double y2) { + return VanillaPacketDispatcher.pointDistancePlane(x1, y1, x2, y2); + } - public static void setEntityMotionFromVector(Entity entity, Vector3 originalPosVector, float modifier) { - Vector3 entityVector = Vector3.fromEntityCenter(entity); - Vector3 finalVector = originalPosVector.copy().subtract(entityVector); + public static void setEntityMotionFromVector(Entity entity, Vector3 originalPosVector, float modifier) { + Vector3 entityVector = Vector3.fromEntityCenter(entity); + Vector3 finalVector = originalPosVector.copy().subtract(entityVector); - if (finalVector.mag() > 1) finalVector.normalize(); + if(finalVector.mag() > 1) + finalVector.normalize(); - entity.motionX = finalVector.x * modifier; - entity.motionY = finalVector.y * modifier; - entity.motionZ = finalVector.z * modifier; - } + entity.motionX = finalVector.x * modifier; + entity.motionY = finalVector.y * modifier; + entity.motionZ = finalVector.z * modifier; + } - private static final String[] ORDINAL_SUFFIXES = - new String[] {"th", "st", "nd", "rd", "th", "th", "th", "th", "th", "th"}; + private static final String[] ORDINAL_SUFFIXES = new String[]{ "th", "st", "nd", "rd", "th", "th", "th", "th", "th", "th" }; + public static String numberToOrdinal(int i) { + return i % 100 == 11 || i % 100 == 12 || i % 100 == 13 ? i + "th" : i + ORDINAL_SUFFIXES[i % 10]; + } - public static String numberToOrdinal(int i) { - return i % 100 == 11 || i % 100 == 12 || i % 100 == 13 ? i + "th" : i + ORDINAL_SUFFIXES[i % 10]; - } } diff --git a/src/main/java/vazkii/botania/common/core/helper/ObfuscationHelper.java b/src/main/java/vazkii/botania/common/core/helper/ObfuscationHelper.java index 17c5ef9dd3..8bc4782b0a 100644 --- a/src/main/java/vazkii/botania/common/core/helper/ObfuscationHelper.java +++ b/src/main/java/vazkii/botania/common/core/helper/ObfuscationHelper.java @@ -2,22 +2,22 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jan 17, 2014, 4:52:37 PM (GMT)] */ package vazkii.botania.common.core.helper; -import cpw.mods.fml.relauncher.ReflectionHelper; import net.minecraft.client.particle.EffectRenderer; import net.minecraft.util.ResourceLocation; import vazkii.botania.common.lib.LibObfuscation; +import cpw.mods.fml.relauncher.ReflectionHelper; public class ObfuscationHelper { - public static ResourceLocation getParticleTexture() { - return ReflectionHelper.getPrivateValue(EffectRenderer.class, null, LibObfuscation.PARTICLE_TEXTURES); - } + public static ResourceLocation getParticleTexture() { + return ReflectionHelper.getPrivateValue(EffectRenderer.class, null, LibObfuscation.PARTICLE_TEXTURES); + } } diff --git a/src/main/java/vazkii/botania/common/core/helper/Quat.java b/src/main/java/vazkii/botania/common/core/helper/Quat.java index 7ab949c562..c3268e4707 100644 --- a/src/main/java/vazkii/botania/common/core/helper/Quat.java +++ b/src/main/java/vazkii/botania/common/core/helper/Quat.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [? (GMT)] */ package vazkii.botania.common.core.helper; @@ -15,107 +15,107 @@ public class Quat { - public double x; - public double y; - public double z; - public double s; - - public Quat() { - s = 1.0D; - x = 0.0D; - y = 0.0D; - z = 0.0D; - } - - public Quat(Quat quat) { - x = quat.x; - y = quat.y; - z = quat.z; - s = quat.s; - } - - public Quat(double d, double d1, double d2, double d3) { - x = d1; - y = d2; - z = d3; - s = d; - } - - public void set(Quat quat) { - x = quat.x; - y = quat.y; - z = quat.z; - s = quat.s; - } - - public static Quat aroundAxis(double ax, double ay, double az, double angle) { - angle *= 0.5D; - double d4 = Math.sin(angle); - return new Quat(Math.cos(angle), ax * d4, ay * d4, az * d4); - } - - public void multiply(Quat quat) { - double d = s * quat.s - x * quat.x - y * quat.y - z * quat.z; - double d1 = s * quat.x + x * quat.s - y * quat.z + z * quat.y; - double d2 = s * quat.y + x * quat.z + y * quat.s - z * quat.x; - double d3 = s * quat.z - x * quat.y + y * quat.x + z * quat.s; - s = d; - x = d1; - y = d2; - z = d3; - } - - public void rightMultiply(Quat quat) { - double d = s * quat.s - x * quat.x - y * quat.y - z * quat.z; - double d1 = s * quat.x + x * quat.s + y * quat.z - z * quat.y; - double d2 = s * quat.y - x * quat.z + y * quat.s + z * quat.x; - double d3 = s * quat.z + x * quat.y - y * quat.x + z * quat.s; - s = d; - x = d1; - y = d2; - z = d3; - } - - public double mag() { - return Math.sqrt(x * x + y * y + z * z + s * s); - } - - public void normalize() { - double d = mag(); - if (d == 0.0D) { - return; - } else { - d = 1.0D / d; - x *= d; - y *= d; - z *= d; - s *= d; - return; - } - } - - public void rotate(Vector3 vec) { - double d = -x * vec.x - y * vec.y - z * vec.z; - double d1 = s * vec.x + y * vec.z - z * vec.y; - double d2 = s * vec.y - x * vec.z + z * vec.x; - double d3 = s * vec.z + x * vec.y - y * vec.x; - vec.x = d1 * s - d * x - d2 * z + d3 * y; - vec.y = d2 * s - d * y + d1 * z - d3 * x; - vec.z = d3 * s - d * z - d1 * y + d2 * x; - } - - @Override - public String toString() { - StringBuilder stringbuilder = new StringBuilder(); - Formatter formatter = new Formatter(stringbuilder, Locale.US); - formatter.format("Quaternion:\n", new Object[0]); - formatter.format( - " < %f %f %f %f >\n", Double.valueOf(s), Double.valueOf(x), Double.valueOf(y), Double.valueOf(z)); - formatter.close(); - return stringbuilder.toString(); - } - - public static Quat aroundAxis(Vector3 axis, double angle) { - return aroundAxis(axis.x, axis.y, axis.z, angle); - } -} + public double x; + public double y; + public double z; + public double s; + + public Quat() { + s = 1.0D; + x = 0.0D; + y = 0.0D; + z = 0.0D; + } + + public Quat(Quat quat) { + x = quat.x; + y = quat.y; + z = quat.z; + s = quat.s; + } + + public Quat(double d, double d1, double d2, double d3) { + x = d1; + y = d2; + z = d3; + s = d; + } + + public void set(Quat quat) { + x = quat.x; + y = quat.y; + z = quat.z; + s = quat.s; + } + + public static Quat aroundAxis(double ax, double ay, double az, double angle) { + angle *= 0.5D; + double d4 = Math.sin(angle); + return new Quat(Math.cos(angle), ax * d4, ay * d4, az * d4); + } + + public void multiply(Quat quat) { + double d = s * quat.s - x * quat.x - y * quat.y - z * quat.z; + double d1 = s * quat.x + x * quat.s - y * quat.z + z * quat.y; + double d2 = s * quat.y + x * quat.z + y * quat.s - z * quat.x; + double d3 = s * quat.z - x * quat.y + y * quat.x + z * quat.s; + s = d; + x = d1; + y = d2; + z = d3; + } + + public void rightMultiply(Quat quat) { + double d = s * quat.s - x * quat.x - y * quat.y - z * quat.z; + double d1 = s * quat.x + x * quat.s + y * quat.z - z * quat.y; + double d2 = s * quat.y - x * quat.z + y * quat.s + z * quat.x; + double d3 = s * quat.z + x * quat.y - y * quat.x + z * quat.s; + s = d; + x = d1; + y = d2; + z = d3; + } + + public double mag() { + return Math.sqrt(x * x + y * y + z * z + s * s); + } + + public void normalize() { + double d = mag(); + if (d == 0.0D) { + return; + } else { + d = 1.0D / d; + x *= d; + y *= d; + z *= d; + s *= d; + return; + } + } + + public void rotate(Vector3 vec) { + double d = -x * vec.x - y * vec.y - z * vec.z; + double d1 = s * vec.x + y * vec.z - z * vec.y; + double d2 = s * vec.y - x * vec.z + z * vec.x; + double d3 = s * vec.z + x * vec.y - y * vec.x; + vec.x = d1 * s - d * x - d2 * z + d3 * y; + vec.y = d2 * s - d * y + d1 * z - d3 * x; + vec.z = d3 * s - d * z - d1 * y + d2 * x; + } + + @Override + public String toString() { + StringBuilder stringbuilder = new StringBuilder(); + Formatter formatter = new Formatter(stringbuilder, Locale.US); + formatter.format("Quaternion:\n", new Object[0]); + formatter.format(" < %f %f %f %f >\n", Double.valueOf(s), Double.valueOf(x), Double.valueOf(y), Double.valueOf(z)); + formatter.close(); + return stringbuilder.toString(); + } + + public static Quat aroundAxis(Vector3 axis, double angle) { + return aroundAxis(axis.x, axis.y, axis.z, angle); + } + +} \ No newline at end of file diff --git a/src/main/java/vazkii/botania/common/core/helper/Vector3.java b/src/main/java/vazkii/botania/common/core/helper/Vector3.java index 0cb0306538..02c47ba543 100644 --- a/src/main/java/vazkii/botania/common/core/helper/Vector3.java +++ b/src/main/java/vazkii/botania/common/core/helper/Vector3.java @@ -2,293 +2,302 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [? (GMT)] */ package vazkii.botania.common.core.helper; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; import java.math.BigDecimal; import java.math.MathContext; import java.math.RoundingMode; + import net.minecraft.entity.Entity; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.AxisAlignedBB; import net.minecraft.util.Vec3; + import org.lwjgl.opengl.GL11; import org.lwjgl.util.vector.Vector3f; import org.lwjgl.util.vector.Vector4f; -public class Vector3 { - public static Vector3 zero = new Vector3(); - public static Vector3 one = new Vector3(1, 1, 1); - public static Vector3 center = new Vector3(0.5, 0.5, 0.5); - - public double x; - public double y; - public double z; - - public Vector3() {} - - public Vector3(double d, double d1, double d2) { - x = d; - y = d1; - z = d2; - } - - public Vector3(Vector3 vec) { - x = vec.x; - y = vec.y; - z = vec.z; - } - - public Vector3(Vec3 vec) { - x = vec.xCoord; - y = vec.yCoord; - z = vec.zCoord; - } - - public Vector3 copy() { - return new Vector3(this); - } - - public static Vector3 fromEntity(Entity e) { - return new Vector3(e.posX, e.posY, e.posZ); - } - - public static Vector3 fromEntityCenter(Entity e) { - return new Vector3(e.posX, e.posY - e.yOffset + e.height / 2, e.posZ); - } - - public static Vector3 fromTileEntity(TileEntity e) { - return new Vector3(e.xCoord, e.yCoord, e.zCoord); - } - - public static Vector3 fromTileEntityCenter(TileEntity e) { - return new Vector3(e.xCoord + 0.5, e.yCoord + 0.5, e.zCoord + 0.5); - } - - public Vector3 set(double d, double d1, double d2) { - x = d; - y = d1; - z = d2; - return this; - } - - public Vector3 set(Vector3 vec) { - x = vec.x; - y = vec.y; - z = vec.z; - return this; - } - - public double dotProduct(Vector3 vec) { - double d = vec.x * x + vec.y * y + vec.z * z; - - if (d > 1 && d < 1.00001) d = 1; - else if (d < -1 && d > -1.00001) d = -1; - return d; - } - - public double dotProduct(double d, double d1, double d2) { - return d * x + d1 * y + d2 * z; - } - - public Vector3 crossProduct(Vector3 vec) { - double d = y * vec.z - z * vec.y; - double d1 = z * vec.x - x * vec.z; - double d2 = x * vec.y - y * vec.x; - x = d; - y = d1; - z = d2; - return this; - } - - public Vector3 add(double d, double d1, double d2) { - x += d; - y += d1; - z += d2; - return this; - } - - public Vector3 add(Vector3 vec) { - x += vec.x; - y += vec.y; - z += vec.z; - return this; - } - - public Vector3 add(double d) { - return add(d, d, d); - } - - public Vector3 sub(Vector3 vec) { - return subtract(vec); - } - - public Vector3 subtract(Vector3 vec) { - x -= vec.x; - y -= vec.y; - z -= vec.z; - return this; - } - - public Vector3 negate(Vector3 vec) { - x = -x; - y = -y; - z = -z; - return this; - } - - public Vector3 multiply(double d) { - x *= d; - y *= d; - z *= d; - return this; - } - - public Vector3 multiply(Vector3 f) { - x *= f.x; - y *= f.y; - z *= f.z; - return this; - } - - public Vector3 multiply(double fx, double fy, double fz) { - x *= fx; - y *= fy; - z *= fz; - return this; - } - - public double mag() { - return Math.sqrt(x * x + y * y + z * z); - } - - public double magSquared() { - return x * x + y * y + z * z; - } - - public Vector3 normalize() { - double d = mag(); - if (d != 0) multiply(1 / d); - - return this; - } - - @Override - public String toString() { - MathContext cont = new MathContext(4, RoundingMode.HALF_UP); - return "Vector3(" + new BigDecimal(x, cont) + ", " + new BigDecimal(y, cont) + ", " + new BigDecimal(z, cont) - + ")"; - } - - public Vector3 perpendicular() { - if (z == 0) return zCrossProduct(); - return xCrossProduct(); - } - - public Vector3 xCrossProduct() { - double d = z; - double d1 = -y; - x = 0; - y = d; - z = d1; - return this; - } - - public Vector3 zCrossProduct() { - double d = y; - - double d1 = -x; - x = d; - y = d1; - z = 0; - return this; - } - - public Vector3 yCrossProduct() { - double d = -z; - double d1 = x; - x = d; - y = 0; - z = d1; - return this; - } - - public Vec3 toVec3D() { - return Vec3.createVectorHelper(x, y, z); - } - - public double angle(Vector3 vec) { - return Math.acos(copy().normalize().dotProduct(vec.copy().normalize())); - } - - public boolean isInside(AxisAlignedBB aabb) { - return x >= aabb.minX && y >= aabb.maxY && z >= aabb.minZ && x < aabb.maxX && y < aabb.maxY && z < aabb.maxZ; - } - - public boolean isZero() { - return x == 0 && y == 0 && z == 0; - } - - public boolean isAxial() { - return x == 0 ? y == 0 || z == 0 : y == 0 && z == 0; - } - - @SideOnly(Side.CLIENT) - public Vector3f vector3f() { - return new Vector3f((float) x, (float) y, (float) z); - } - - @SideOnly(Side.CLIENT) - public Vector4f vector4f() { - return new Vector4f((float) x, (float) y, (float) z, 1); - } - - @SideOnly(Side.CLIENT) - public void glVertex() { - GL11.glVertex3d(x, y, z); - } - - public Vector3 negate() { - x = -x; - y = -y; - z = -z; - return this; - } - - public double scalarProject(Vector3 b) { - double l = b.mag(); - return l == 0 ? 0 : dotProduct(b) / l; - } - - public Vector3 project(Vector3 b) { - double l = b.magSquared(); - if (l == 0) { - set(0, 0, 0); - return this; - } - - double m = dotProduct(b) / l; - set(b).multiply(m); - return this; - } - - public Vector3 rotate(double angle, Vector3 axis) { - Quat.aroundAxis(axis.copy().normalize(), angle).rotate(this); - return this; - } - - @Override - public boolean equals(Object o) { - if (!(o instanceof Vector3)) return false; - - Vector3 v = (Vector3) o; - return x == v.x && y == v.y && z == v.z; - } -} +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +public class Vector3 +{ + public static Vector3 zero = new Vector3(); + public static Vector3 one = new Vector3(1, 1, 1); + public static Vector3 center = new Vector3(0.5, 0.5, 0.5); + + public double x; + public double y; + public double z; + + public Vector3() { + } + + public Vector3(double d, double d1, double d2) { + x = d; + y = d1; + z = d2; + } + + public Vector3(Vector3 vec) { + x = vec.x; + y = vec.y; + z = vec.z; + } + + public Vector3(Vec3 vec) { + x = vec.xCoord; + y = vec.yCoord; + z = vec.zCoord; + } + + public Vector3 copy() { + return new Vector3(this); + } + + public static Vector3 fromEntity(Entity e) { + return new Vector3(e.posX, e.posY, e.posZ); + } + + public static Vector3 fromEntityCenter(Entity e) { + return new Vector3(e.posX, e.posY - e.yOffset + e.height / 2, e.posZ); + } + + public static Vector3 fromTileEntity(TileEntity e) { + return new Vector3(e.xCoord, e.yCoord, e.zCoord); + } + + public static Vector3 fromTileEntityCenter(TileEntity e) { + return new Vector3(e.xCoord + 0.5, e.yCoord + 0.5, e.zCoord + 0.5); + } + + public Vector3 set(double d, double d1, double d2) { + x = d; + y = d1; + z = d2; + return this; + } + + public Vector3 set(Vector3 vec) { + x = vec.x; + y = vec.y; + z = vec.z; + return this; + } + + public double dotProduct(Vector3 vec) { + double d = vec.x * x + vec.y * y + vec.z * z; + + if(d > 1 && d < 1.00001) + d = 1; + else if(d < -1 && d > -1.00001) + d = -1; + return d; + } + + public double dotProduct(double d, double d1, double d2) { + return d * x + d1 * y + d2 * z; + } + + public Vector3 crossProduct(Vector3 vec) { + double d = y * vec.z - z * vec.y; + double d1 = z * vec.x - x * vec.z; + double d2 = x * vec.y - y * vec.x; + x = d; + y = d1; + z = d2; + return this; + } + + public Vector3 add(double d, double d1, double d2) { + x += d; + y += d1; + z += d2; + return this; + } + + public Vector3 add(Vector3 vec) { + x += vec.x; + y += vec.y; + z += vec.z; + return this; + } + + public Vector3 add(double d) { + return add(d, d, d); + } + + public Vector3 sub(Vector3 vec) { + return subtract(vec); + } + + public Vector3 subtract(Vector3 vec) { + x -= vec.x; + y -= vec.y; + z -= vec.z; + return this; + } + + public Vector3 negate(Vector3 vec) { + x = -x; + y = -y; + z = -z; + return this; + } + + public Vector3 multiply(double d) { + x *= d; + y *= d; + z *= d; + return this; + } + + public Vector3 multiply(Vector3 f) { + x *= f.x; + y *= f.y; + z *= f.z; + return this; + } + + public Vector3 multiply(double fx, double fy, double fz) { + x *= fx; + y *= fy; + z *= fz; + return this; + } + + public double mag() { + return Math.sqrt(x * x + y * y + z * z); + } + + public double magSquared() { + return x * x + y * y + z * z; + } + + public Vector3 normalize() { + double d = mag(); + if(d != 0) + multiply(1 / d); + + return this; + } + + @Override + public String toString() { + MathContext cont = new MathContext(4, RoundingMode.HALF_UP); + return "Vector3(" + new BigDecimal(x, cont) + ", " +new BigDecimal(y, cont) + ", " + new BigDecimal(z, cont) + ")"; + } + + public Vector3 perpendicular() { + if(z == 0) + return zCrossProduct(); + return xCrossProduct(); + } + + public Vector3 xCrossProduct() { + double d = z; + double d1 = -y; + x = 0; + y = d; + z = d1; + return this; + } + + public Vector3 zCrossProduct() { + double d = y; + + double d1 = -x; + x = d; + y = d1; + z = 0; + return this; + } + + public Vector3 yCrossProduct() { + double d = -z; + double d1 = x; + x = d; + y = 0; + z = d1; + return this; + } + + public Vec3 toVec3D() { + return Vec3.createVectorHelper(x, y, z); + } + + public double angle(Vector3 vec) { + return Math.acos(copy().normalize().dotProduct(vec.copy().normalize())); + } + + public boolean isInside(AxisAlignedBB aabb) { + return x >= aabb.minX && y >= aabb.maxY && z >= aabb.minZ && x < aabb.maxX && y < aabb.maxY && z < aabb.maxZ; + } + + public boolean isZero() { + return x == 0 && y == 0 && z == 0; + } + + public boolean isAxial() { + return x == 0 ? y == 0 || z == 0 : y == 0 && z == 0; + } + + @SideOnly(Side.CLIENT) + public Vector3f vector3f() { + return new Vector3f((float)x, (float)y, (float)z); + } + + @SideOnly(Side.CLIENT) + public Vector4f vector4f() { + return new Vector4f((float)x, (float)y, (float)z, 1); + } + + @SideOnly(Side.CLIENT) + public void glVertex() { + GL11.glVertex3d(x, y, z); + } + + public Vector3 negate() { + x = -x; + y = -y; + z = -z; + return this; + } + + public double scalarProject(Vector3 b) { + double l = b.mag(); + return l == 0 ? 0 : dotProduct(b)/l; + } + + public Vector3 project(Vector3 b) { + double l = b.magSquared(); + if(l == 0) { + set(0, 0, 0); + return this; + } + + double m = dotProduct(b)/l; + set(b).multiply(m); + return this; + } + + public Vector3 rotate(double angle, Vector3 axis) { + Quat.aroundAxis(axis.copy().normalize(), angle).rotate(this); + return this; + } + + @Override + public boolean equals(Object o) { + if(!(o instanceof Vector3)) + return false; + + Vector3 v = (Vector3)o; + return x == v.x && y == v.y && z == v.z; + } +} \ No newline at end of file diff --git a/src/main/java/vazkii/botania/common/core/proxy/CommonProxy.java b/src/main/java/vazkii/botania/common/core/proxy/CommonProxy.java index d11ceccf08..e441a92b52 100644 --- a/src/main/java/vazkii/botania/common/core/proxy/CommonProxy.java +++ b/src/main/java/vazkii/botania/common/core/proxy/CommonProxy.java @@ -10,15 +10,6 @@ */ package vazkii.botania.common.core.proxy; -import cpw.mods.fml.common.FMLCommonHandler; -import cpw.mods.fml.common.FMLLog; -import cpw.mods.fml.common.event.FMLInitializationEvent; -import cpw.mods.fml.common.event.FMLInterModComms; -import cpw.mods.fml.common.event.FMLPostInitializationEvent; -import cpw.mods.fml.common.event.FMLPreInitializationEvent; -import cpw.mods.fml.common.event.FMLServerAboutToStartEvent; -import cpw.mods.fml.common.event.FMLServerStartingEvent; -import cpw.mods.fml.common.network.NetworkRegistry; import net.minecraft.block.Block; import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.boss.EntityDragon; @@ -35,7 +26,9 @@ import net.minecraft.util.StatCollector; import net.minecraft.world.World; import net.minecraftforge.common.MinecraftForge; + import org.apache.logging.log4j.Level; + import vazkii.botania.api.BotaniaAPI; import vazkii.botania.api.lexicon.ITwoNamedPage; import vazkii.botania.api.lexicon.LexiconEntry; @@ -88,280 +81,248 @@ import vazkii.botania.common.network.GuiHandler; import vazkii.botania.common.world.SkyblockWorldEvents; import vazkii.botania.common.world.WorldTypeSkyblock; +import cpw.mods.fml.common.FMLCommonHandler; +import cpw.mods.fml.common.FMLLog; +import cpw.mods.fml.common.event.FMLInitializationEvent; +import cpw.mods.fml.common.event.FMLInterModComms; +import cpw.mods.fml.common.event.FMLPostInitializationEvent; +import cpw.mods.fml.common.event.FMLPreInitializationEvent; +import cpw.mods.fml.common.event.FMLServerAboutToStartEvent; +import cpw.mods.fml.common.event.FMLServerStartingEvent; +import cpw.mods.fml.common.network.NetworkRegistry; public class CommonProxy { - public void preInit(FMLPreInitializationEvent event) { - BotaniaAPI.internalHandler = new InternalMethodHandler(); - - ConfigHandler.loadConfig(event.getSuggestedConfigurationFile()); - - ModBlocks.init(); - ModItems.init(); - ModEntities.init(); - ModPotions.init(); - ModBrews.init(); - - ModCraftingRecipes.init(); - ModPetalRecipes.init(); - ModPureDaisyRecipes.init(); - ModRuneRecipes.init(); - ModManaAlchemyRecipes.init(); - ModManaConjurationRecipes.init(); - ModManaInfusionRecipes.init(); - ModElvenTradeRecipes.init(); - ModBrewRecipes.init(); - ModAchievements.init(); - ModMultiblocks.init(); - - if (Botania.etFuturumLoaded) ModBanners.init(); - - ChestGenHandler.init(); - - if (Botania.gardenOfGlassLoaded) new WorldTypeSkyblock(); - - LexiconData.preInit(); - } - - public void init(FMLInitializationEvent event) { - NetworkRegistry.INSTANCE.registerGuiHandler(Botania.instance, new GuiHandler()); - - MinecraftForge.TERRAIN_GEN_BUS.register(new BiomeDecorationHandler()); - MinecraftForge.EVENT_BUS.register(ManaNetworkHandler.instance); - MinecraftForge.EVENT_BUS.register(new PixieHandler()); - MinecraftForge.EVENT_BUS.register(new SheddingHandler()); - MinecraftForge.EVENT_BUS.register(new SpawnerChangingHandler()); - MinecraftForge.EVENT_BUS.register(new SubTileNarslimmus.SpawnIntercepter()); - MinecraftForge.EVENT_BUS.register(TileCorporeaIndex.getInputHandler()); - - if (Botania.gardenOfGlassLoaded) MinecraftForge.EVENT_BUS.register(new SkyblockWorldEvents()); - - FMLCommonHandler.instance().bus().register(new CommonTickHandler()); - - FMLInterModComms.sendMessage("ProjectE", "interdictionblacklist", EntityManaBurst.class.getCanonicalName()); - - if (Botania.bcTriggersLoaded) new StatementAPIPlugin(); - - LexiconData.init(); - } - - public void postInit(FMLPostInitializationEvent event) { - if (Botania.thaumcraftLoaded) { - ModBrews.initTC(); - ModBrewRecipes.initTC(); - } - - ModBlocks.addDispenserBehaviours(); - ModBlocks.registerMultiparts(); - ConfigHandler.loadPostInit(); - LexiconData.postInit(); - - registerNEIStuff(); - - int words = 0; - for (LexiconEntry entry : BotaniaAPI.getAllEntries()) - for (LexiconPage page : entry.pages) { - words += countWords(page.getUnlocalizedName()); - if (page instanceof ITwoNamedPage) - words += countWords(((ITwoNamedPage) page).getSecondUnlocalizedName()); - } - FMLLog.log(Level.INFO, "[Botania] The Lexica Botania has %d words.", words); - - registerDefaultEntityBlacklist(); - } - - private int countWords(String s) { - String s1 = StatCollector.translateToLocal(s); - return s1.split(" ").length; - } - - private void registerDefaultEntityBlacklist() { - // Vanilla - BotaniaAPI.blacklistEntityFromGravityRod(EntityDragon.class); - BotaniaAPI.blacklistEntityFromGravityRod(EntityDragonPart.class); - BotaniaAPI.blacklistEntityFromGravityRod(EntityWither.class); - BotaniaAPI.blacklistEntityFromGravityRod(EntityItemFrame.class); - BotaniaAPI.blacklistEntityFromGravityRod(EntityEnderCrystal.class); - BotaniaAPI.blacklistEntityFromGravityRod(EntityPainting.class); - - // Botania - BotaniaAPI.blacklistEntityFromGravityRod(EntityCorporeaSpark.class); - BotaniaAPI.blacklistEntityFromGravityRod(EntityDoppleganger.class); - BotaniaAPI.blacklistEntityFromGravityRod(EntityFlameRing.class); - BotaniaAPI.blacklistEntityFromGravityRod(EntityMagicLandmine.class); - BotaniaAPI.blacklistEntityFromGravityRod(EntityMagicMissile.class); - BotaniaAPI.blacklistEntityFromGravityRod(EntityManaBurst.class); - BotaniaAPI.blacklistEntityFromGravityRod(EntityPinkWither.class); - BotaniaAPI.blacklistEntityFromGravityRod(EntitySignalFlare.class); - BotaniaAPI.blacklistEntityFromGravityRod(EntitySpark.class); - BotaniaAPI.blacklistEntityFromGravityRod(EntityPlayerMover.class); - } - - // Overriding the internal method handler will break everything as it changes regularly. - // So just don't be a moron and don't override it. Thanks. - public void serverAboutToStart(FMLServerAboutToStartEvent event) { - String clname = BotaniaAPI.internalHandler.getClass().getName(); - String expect = "vazkii.botania.common.core.handler.InternalMethodHandler"; - if (!clname.equals(expect)) { - new IllegalAccessError("The Botania API internal method handler has been overriden. " - + "This will cause crashes and compatibility issues, and that's why it's marked as" - + " \"Do not Override\". Whoever had the brilliant idea of overriding it needs to go" - + " back to elementary school and learn to read. (Expected classname: " + expect - + ", Actual classname: " + clname + ")") - .printStackTrace(); - FMLCommonHandler.instance().exitJava(1, true); - } - } - - public void serverStarting(FMLServerStartingEvent event) { - event.registerServerCommand(new CommandShare()); - event.registerServerCommand(new CommandOpen()); - if (Botania.gardenOfGlassLoaded) event.registerServerCommand(new CommandSkyblockSpread()); - } - - public void registerNEIStuff() { - // NO-OP - } - - public void setEntryToOpen(LexiconEntry entry) { - // NO-OP - } - - public void setToTutorialIfFirstLaunch() { - // NO-OP - } - - public void setLexiconStack(ItemStack stack) { - // NO-OP - } - - public boolean isTheClientPlayer(EntityLivingBase entity) { - return false; - } - - public boolean isClientPlayerWearingMonocle() { - return false; - } - - public void setExtraReach(EntityLivingBase entity, float reach) { - if (entity instanceof EntityPlayerMP) - ((EntityPlayerMP) entity) - .theItemInWorldManager.setBlockReachDistance(Math.max( - 5, ((EntityPlayerMP) entity).theItemInWorldManager.getBlockReachDistance() + reach)); - } - - public boolean openWikiPage(World world, Block block, MovingObjectPosition pos) { - return false; - } - - public void playRecordClientSided(World world, int x, int y, int z, ItemRecord record) { - // NO-OP - } - - public void setMultiblock(World world, int x, int y, int z, double radius, Block block) { - // NO-OP - } - - public void removeSextantMultiblock() { - // NO-OP - } - - public long getWorldElapsedTicks() { - return MinecraftServer.getServer().worldServers[0].getTotalWorldTime(); - } - - public void setSparkleFXNoClip(boolean noclip) { - // NO-OP - } - - public void setSparkleFXCorrupt(boolean corrupt) { - // NO-OP - } - - public void sparkleFX(World world, double x, double y, double z, float r, float g, float b, float size, int m) { - sparkleFX(world, x, y, z, r, g, b, size, m, false); - } - - public void sparkleFX( - World world, double x, double y, double z, float r, float g, float b, float size, int m, boolean fake) { - // NO-OP - } - - public void setWispFXDistanceLimit(boolean limit) { - // NO-OP - } - - public void setWispFXDepthTest(boolean depth) { - // NO-OP - } - - public void wispFX(World world, double x, double y, double z, float r, float g, float b, float size) { - wispFX(world, x, y, z, r, g, b, size, 0F); - } - - public void wispFX( - World world, double x, double y, double z, float r, float g, float b, float size, float gravity) { - wispFX(world, x, y, z, r, g, b, size, gravity, 1F); - } - - public void wispFX( - World world, - double x, - double y, - double z, - float r, - float g, - float b, - float size, - float gravity, - float maxAgeMul) { - wispFX(world, x, y, z, r, g, b, size, 0, -gravity, 0, maxAgeMul); - } - - public void wispFX( - World world, - double x, - double y, - double z, - float r, - float g, - float b, - float size, - float motionx, - float motiony, - float motionz) { - wispFX(world, x, y, z, r, g, b, size, motionx, motiony, motionz, 1F); - } - - public void wispFX( - World world, - double x, - double y, - double z, - float r, - float g, - float b, - float size, - float motionx, - float motiony, - float motionz, - float maxAgeMul) { - // NO-OP - } - - public void lightningFX( - World world, Vector3 vectorStart, Vector3 vectorEnd, float ticksPerMeter, int colorOuter, int colorInner) { - lightningFX(world, vectorStart, vectorEnd, ticksPerMeter, System.nanoTime(), colorOuter, colorInner); - } - - public void lightningFX( - World world, - Vector3 vectorStart, - Vector3 vectorEnd, - float ticksPerMeter, - long seed, - int colorOuter, - int colorInner) { - // NO-OP - } + public void preInit(FMLPreInitializationEvent event) { + BotaniaAPI.internalHandler = new InternalMethodHandler(); + + ConfigHandler.loadConfig(event.getSuggestedConfigurationFile()); + + ModBlocks.init(); + ModItems.init(); + ModEntities.init(); + ModPotions.init(); + ModBrews.init(); + + ModCraftingRecipes.init(); + ModPetalRecipes.init(); + ModPureDaisyRecipes.init(); + ModRuneRecipes.init(); + ModManaAlchemyRecipes.init(); + ModManaConjurationRecipes.init(); + ModManaInfusionRecipes.init(); + ModElvenTradeRecipes.init(); + ModBrewRecipes.init(); + ModAchievements.init(); + ModMultiblocks.init(); + + if(Botania.etFuturumLoaded) + ModBanners.init(); + + ChestGenHandler.init(); + + if(Botania.gardenOfGlassLoaded) + new WorldTypeSkyblock(); + + LexiconData.preInit(); + } + + public void init(FMLInitializationEvent event) { + NetworkRegistry.INSTANCE.registerGuiHandler(Botania.instance, new GuiHandler()); + + MinecraftForge.TERRAIN_GEN_BUS.register(new BiomeDecorationHandler()); + MinecraftForge.EVENT_BUS.register(ManaNetworkHandler.instance); + MinecraftForge.EVENT_BUS.register(new PixieHandler()); + MinecraftForge.EVENT_BUS.register(new SheddingHandler()); + MinecraftForge.EVENT_BUS.register(new SpawnerChangingHandler()); + MinecraftForge.EVENT_BUS.register(new SubTileNarslimmus.SpawnIntercepter()); + MinecraftForge.EVENT_BUS.register(TileCorporeaIndex.getInputHandler()); + + if(Botania.gardenOfGlassLoaded) + MinecraftForge.EVENT_BUS.register(new SkyblockWorldEvents()); + + FMLCommonHandler.instance().bus().register(new CommonTickHandler()); + + FMLInterModComms.sendMessage("ProjectE", "interdictionblacklist", EntityManaBurst.class.getCanonicalName()); + + if(Botania.bcTriggersLoaded) + new StatementAPIPlugin(); + + LexiconData.init(); + } + + public void postInit(FMLPostInitializationEvent event) { + if(Botania.thaumcraftLoaded) { + ModBrews.initTC(); + ModBrewRecipes.initTC(); + } + + ModBlocks.addDispenserBehaviours(); + ModBlocks.registerMultiparts(); + ConfigHandler.loadPostInit(); + LexiconData.postInit(); + + registerNEIStuff(); + + int words = 0; + for(LexiconEntry entry : BotaniaAPI.getAllEntries()) + for(LexiconPage page : entry.pages) { + words += countWords(page.getUnlocalizedName()); + if(page instanceof ITwoNamedPage) + words += countWords(((ITwoNamedPage) page).getSecondUnlocalizedName()); + } + FMLLog.log(Level.INFO, "[Botania] The Lexica Botania has %d words.", words); + + registerDefaultEntityBlacklist(); + } + + private int countWords(String s) { + String s1 = StatCollector.translateToLocal(s); + return s1.split(" ").length; + } + + private void registerDefaultEntityBlacklist() { + // Vanilla + BotaniaAPI.blacklistEntityFromGravityRod(EntityDragon.class); + BotaniaAPI.blacklistEntityFromGravityRod(EntityDragonPart.class); + BotaniaAPI.blacklistEntityFromGravityRod(EntityWither.class); + BotaniaAPI.blacklistEntityFromGravityRod(EntityItemFrame.class); + BotaniaAPI.blacklistEntityFromGravityRod(EntityEnderCrystal.class); + BotaniaAPI.blacklistEntityFromGravityRod(EntityPainting.class); + + // Botania + BotaniaAPI.blacklistEntityFromGravityRod(EntityCorporeaSpark.class); + BotaniaAPI.blacklistEntityFromGravityRod(EntityDoppleganger.class); + BotaniaAPI.blacklistEntityFromGravityRod(EntityFlameRing.class); + BotaniaAPI.blacklistEntityFromGravityRod(EntityMagicLandmine.class); + BotaniaAPI.blacklistEntityFromGravityRod(EntityMagicMissile.class); + BotaniaAPI.blacklistEntityFromGravityRod(EntityManaBurst.class); + BotaniaAPI.blacklistEntityFromGravityRod(EntityPinkWither.class); + BotaniaAPI.blacklistEntityFromGravityRod(EntitySignalFlare.class); + BotaniaAPI.blacklistEntityFromGravityRod(EntitySpark.class); + BotaniaAPI.blacklistEntityFromGravityRod(EntityPlayerMover.class); + } + + // Overriding the internal method handler will break everything as it changes regularly. + // So just don't be a moron and don't override it. Thanks. + public void serverAboutToStart(FMLServerAboutToStartEvent event) { + String clname = BotaniaAPI.internalHandler.getClass().getName(); + String expect = "vazkii.botania.common.core.handler.InternalMethodHandler"; + if(!clname.equals(expect)) { + new IllegalAccessError("The Botania API internal method handler has been overriden. " + + "This will cause crashes and compatibility issues, and that's why it's marked as" + + " \"Do not Override\". Whoever had the brilliant idea of overriding it needs to go" + + " back to elementary school and learn to read. (Expected classname: " + expect + ", Actual classname: " + clname + ")").printStackTrace(); + FMLCommonHandler.instance().exitJava(1, true); + } + } + + public void serverStarting(FMLServerStartingEvent event) { + event.registerServerCommand(new CommandShare()); + event.registerServerCommand(new CommandOpen()); + if(Botania.gardenOfGlassLoaded) + event.registerServerCommand(new CommandSkyblockSpread()); + } + + public void registerNEIStuff() { + // NO-OP + } + + public void setEntryToOpen(LexiconEntry entry) { + // NO-OP + } + + public void setToTutorialIfFirstLaunch() { + // NO-OP + } + + public void setLexiconStack(ItemStack stack) { + // NO-OP + } + + public boolean isTheClientPlayer(EntityLivingBase entity) { + return false; + } + + public boolean isClientPlayerWearingMonocle() { + return false; + } + + public void setExtraReach(EntityLivingBase entity, float reach) { + if(entity instanceof EntityPlayerMP) + ((EntityPlayerMP) entity).theItemInWorldManager.setBlockReachDistance(Math.max(5, ((EntityPlayerMP) entity).theItemInWorldManager.getBlockReachDistance() + reach)); + } + + public boolean openWikiPage(World world, Block block, MovingObjectPosition pos) { + return false; + } + + public void playRecordClientSided(World world, int x, int y, int z, ItemRecord record) { + // NO-OP + } + + public void setMultiblock(World world, int x, int y, int z, double radius, Block block) { + // NO-OP + } + + public void removeSextantMultiblock() { + // NO-OP + } + + public long getWorldElapsedTicks() { + return MinecraftServer.getServer().worldServers[0].getTotalWorldTime(); + } + + public void setSparkleFXNoClip(boolean noclip) { + // NO-OP + } + + public void setSparkleFXCorrupt(boolean corrupt) { + // NO-OP + } + + public void sparkleFX(World world, double x, double y, double z, float r, float g, float b, float size, int m) { + sparkleFX(world, x, y, z, r, g, b, size, m, false); + } + + public void sparkleFX(World world, double x, double y, double z, float r, float g, float b, float size, int m, boolean fake) { + // NO-OP + } + + public void setWispFXDistanceLimit(boolean limit) { + // NO-OP + } + + public void setWispFXDepthTest(boolean depth) { + // NO-OP + } + + public void wispFX(World world, double x, double y, double z, float r, float g, float b, float size) { + wispFX(world, x, y, z, r, g, b, size, 0F); + } + + public void wispFX(World world, double x, double y, double z, float r, float g, float b, float size, float gravity) { + wispFX(world, x, y, z, r, g, b, size, gravity, 1F); + } + + public void wispFX(World world, double x, double y, double z, float r, float g, float b, float size, float gravity, float maxAgeMul) { + wispFX(world, x, y, z, r, g, b, size, 0, -gravity, 0, maxAgeMul); + } + + public void wispFX(World world, double x, double y, double z, float r, float g, float b, float size, float motionx, float motiony, float motionz) { + wispFX(world, x, y, z, r, g, b, size, motionx, motiony, motionz, 1F); + } + + public void wispFX(World world, double x, double y, double z, float r, float g, float b, float size, float motionx, float motiony, float motionz, float maxAgeMul) { + // NO-OP + } + + public void lightningFX(World world, Vector3 vectorStart, Vector3 vectorEnd, float ticksPerMeter, int colorOuter, int colorInner) { + lightningFX(world, vectorStart, vectorEnd, ticksPerMeter, System.nanoTime(), colorOuter, colorInner); + } + + public void lightningFX(World world, Vector3 vectorStart, Vector3 vectorEnd, float ticksPerMeter, long seed, int colorOuter, int colorInner) { + // NO-OP + } + } diff --git a/src/main/java/vazkii/botania/common/crafting/ModBrewRecipes.java b/src/main/java/vazkii/botania/common/crafting/ModBrewRecipes.java index 6fdf12e04c..866ffa3366 100644 --- a/src/main/java/vazkii/botania/common/crafting/ModBrewRecipes.java +++ b/src/main/java/vazkii/botania/common/crafting/ModBrewRecipes.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Nov 1, 2014, 9:15:15 PM (GMT)] */ package vazkii.botania.common.crafting; @@ -22,158 +22,62 @@ public class ModBrewRecipes { - public static RecipeBrew speedBrew; - public static RecipeBrew strengthBrew; - public static RecipeBrew hasteBrew; - public static RecipeBrew healingBrew; - public static RecipeBrew jumpBoostBrew; - public static RecipeBrew regenerationBrew; - public static RecipeBrew weakRegenerationBrew; - public static RecipeBrew resistanceBrew; - public static RecipeBrew fireResistanceBrew; - public static RecipeBrew waterBreathingBrew; - public static RecipeBrew invisibilityBrew; - public static RecipeBrew nightVisionBrew; - public static RecipeBrew absorptionBrew; + public static RecipeBrew speedBrew; + public static RecipeBrew strengthBrew; + public static RecipeBrew hasteBrew; + public static RecipeBrew healingBrew; + public static RecipeBrew jumpBoostBrew; + public static RecipeBrew regenerationBrew; + public static RecipeBrew weakRegenerationBrew; + public static RecipeBrew resistanceBrew; + public static RecipeBrew fireResistanceBrew; + public static RecipeBrew waterBreathingBrew; + public static RecipeBrew invisibilityBrew; + public static RecipeBrew nightVisionBrew; + public static RecipeBrew absorptionBrew; - public static RecipeBrew overloadBrew; - public static RecipeBrew soulCrossBrew; - public static RecipeBrew featherFeetBrew; - public static RecipeBrew emptinessBrew; - public static RecipeBrew bloodthirstBrew; - public static RecipeBrew allureBrew; - public static RecipeBrew clearBrew; + public static RecipeBrew overloadBrew; + public static RecipeBrew soulCrossBrew; + public static RecipeBrew featherFeetBrew; + public static RecipeBrew emptinessBrew; + public static RecipeBrew bloodthirstBrew; + public static RecipeBrew allureBrew; + public static RecipeBrew clearBrew; - public static RecipeBrew warpWardBrew; + public static RecipeBrew warpWardBrew; - public static void init() { - if (!ConfigHandler.enableDefaultRecipes) return; + public static void init() { + if (!ConfigHandler.enableDefaultRecipes) return; - speedBrew = BotaniaAPI.registerBrewRecipe( - ModBrews.speed, - new ItemStack(Items.nether_wart), - new ItemStack(Items.sugar), - new ItemStack(Items.redstone)); - strengthBrew = BotaniaAPI.registerBrewRecipe( - ModBrews.strength, - new ItemStack(Items.nether_wart), - new ItemStack(Items.blaze_powder), - new ItemStack(Items.glowstone_dust)); - hasteBrew = BotaniaAPI.registerBrewRecipe( - ModBrews.haste, - new ItemStack(Items.nether_wart), - new ItemStack(Items.sugar), - new ItemStack(Items.gold_nugget)); - healingBrew = BotaniaAPI.registerBrewRecipe( - ModBrews.healing, - new ItemStack(Items.nether_wart), - new ItemStack(Items.speckled_melon), - new ItemStack(Items.potato)); - jumpBoostBrew = BotaniaAPI.registerBrewRecipe( - ModBrews.jumpBoost, - new ItemStack(Items.nether_wart), - new ItemStack(Items.feather), - new ItemStack(Items.carrot)); - regenerationBrew = BotaniaAPI.registerBrewRecipe( - ModBrews.regen, - new ItemStack(Items.nether_wart), - new ItemStack(Items.ghast_tear), - new ItemStack(Items.glowstone_dust)); - weakRegenerationBrew = BotaniaAPI.registerBrewRecipe( - ModBrews.regenWeak, - new ItemStack(Items.nether_wart), - new ItemStack(Items.ghast_tear), - new ItemStack(Items.redstone)); - resistanceBrew = BotaniaAPI.registerBrewRecipe( - ModBrews.resistance, - new ItemStack(Items.nether_wart), - new ItemStack(Items.iron_ingot), - new ItemStack(Items.leather)); - fireResistanceBrew = BotaniaAPI.registerBrewRecipe( - ModBrews.fireResistance, - new ItemStack(Items.nether_wart), - new ItemStack(Items.magma_cream), - new ItemStack(Blocks.netherrack)); - waterBreathingBrew = BotaniaAPI.registerBrewRecipe( - ModBrews.waterBreathing, - new ItemStack(Items.nether_wart), - new ItemStack(ModItems.manaResource, 1, 10), - new ItemStack(Items.glowstone_dust)); - invisibilityBrew = BotaniaAPI.registerBrewRecipe( - ModBrews.invisibility, - new ItemStack(Items.nether_wart), - new ItemStack(Items.snowball), - new ItemStack(Items.glowstone_dust)); - nightVisionBrew = BotaniaAPI.registerBrewRecipe( - ModBrews.nightVision, - new ItemStack(Items.nether_wart), - new ItemStack(Items.spider_eye), - new ItemStack(Items.golden_carrot)); - absorptionBrew = BotaniaAPI.registerBrewRecipe( - ModBrews.absorption, - new ItemStack(Items.nether_wart), - new ItemStack(Items.golden_apple), - new ItemStack(Items.potato)); + speedBrew = BotaniaAPI.registerBrewRecipe(ModBrews.speed, new ItemStack(Items.nether_wart), new ItemStack(Items.sugar), new ItemStack(Items.redstone)); + strengthBrew = BotaniaAPI.registerBrewRecipe(ModBrews.strength, new ItemStack(Items.nether_wart), new ItemStack(Items.blaze_powder), new ItemStack(Items.glowstone_dust)); + hasteBrew = BotaniaAPI.registerBrewRecipe(ModBrews.haste, new ItemStack(Items.nether_wart), new ItemStack(Items.sugar), new ItemStack(Items.gold_nugget)); + healingBrew = BotaniaAPI.registerBrewRecipe(ModBrews.healing, new ItemStack(Items.nether_wart), new ItemStack(Items.speckled_melon), new ItemStack(Items.potato)); + jumpBoostBrew = BotaniaAPI.registerBrewRecipe(ModBrews.jumpBoost, new ItemStack(Items.nether_wart), new ItemStack(Items.feather), new ItemStack(Items.carrot)); + regenerationBrew = BotaniaAPI.registerBrewRecipe(ModBrews.regen, new ItemStack(Items.nether_wart), new ItemStack(Items.ghast_tear), new ItemStack(Items.glowstone_dust)); + weakRegenerationBrew = BotaniaAPI.registerBrewRecipe(ModBrews.regenWeak, new ItemStack(Items.nether_wart), new ItemStack(Items.ghast_tear), new ItemStack(Items.redstone)); + resistanceBrew = BotaniaAPI.registerBrewRecipe(ModBrews.resistance, new ItemStack(Items.nether_wart), new ItemStack(Items.iron_ingot), new ItemStack(Items.leather)); + fireResistanceBrew = BotaniaAPI.registerBrewRecipe(ModBrews.fireResistance, new ItemStack(Items.nether_wart), new ItemStack(Items.magma_cream), new ItemStack(Blocks.netherrack)); + waterBreathingBrew = BotaniaAPI.registerBrewRecipe(ModBrews.waterBreathing, new ItemStack(Items.nether_wart), new ItemStack(ModItems.manaResource, 1, 10), new ItemStack(Items.glowstone_dust)); + invisibilityBrew = BotaniaAPI.registerBrewRecipe(ModBrews.invisibility, new ItemStack(Items.nether_wart), new ItemStack(Items.snowball), new ItemStack(Items.glowstone_dust)); + nightVisionBrew = BotaniaAPI.registerBrewRecipe(ModBrews.nightVision, new ItemStack(Items.nether_wart), new ItemStack(Items.spider_eye), new ItemStack(Items.golden_carrot)); + absorptionBrew = BotaniaAPI.registerBrewRecipe(ModBrews.absorption, new ItemStack(Items.nether_wart), new ItemStack(Items.golden_apple), new ItemStack(Items.potato)); - overloadBrew = BotaniaAPI.registerBrewRecipe( - ModBrews.overload, - new ItemStack(Items.nether_wart), - new ItemStack(Items.blaze_powder), - new ItemStack(Items.sugar), - new ItemStack(Items.glowstone_dust), - new ItemStack(ModItems.manaResource), - new ItemStack(Items.spider_eye)); - soulCrossBrew = BotaniaAPI.registerBrewRecipe( - ModBrews.soulCross, - new ItemStack(Items.nether_wart), - new ItemStack(Blocks.soul_sand), - new ItemStack(Items.paper), - new ItemStack(Items.apple), - new ItemStack(Items.bone)); - featherFeetBrew = BotaniaAPI.registerBrewRecipe( - ModBrews.featherfeet, - new ItemStack(Items.nether_wart), - new ItemStack(Items.feather), - new ItemStack(Items.leather), - new ItemStack(Blocks.wool, 1, -1)); - emptinessBrew = BotaniaAPI.registerBrewRecipe( - ModBrews.emptiness, - new ItemStack(Items.nether_wart), - new ItemStack(Items.gunpowder), - new ItemStack(Items.rotten_flesh), - new ItemStack(Items.bone), - new ItemStack(Items.string), - new ItemStack(Items.ender_pearl)); - bloodthirstBrew = BotaniaAPI.registerBrewRecipe( - ModBrews.bloodthirst, - new ItemStack(Items.nether_wart), - new ItemStack(Items.fermented_spider_eye), - new ItemStack(Items.dye, 1, 4), - new ItemStack(Items.fire_charge), - new ItemStack(Items.iron_ingot)); - allureBrew = BotaniaAPI.registerBrewRecipe( - ModBrews.allure, - new ItemStack(Items.nether_wart), - new ItemStack(Items.fish), - new ItemStack(Items.quartz), - new ItemStack(Items.golden_carrot)); - clearBrew = BotaniaAPI.registerBrewRecipe( - ModBrews.clear, - new ItemStack(Items.nether_wart), - new ItemStack(Items.quartz), - new ItemStack(Items.emerald), - new ItemStack(Items.melon)); - } + overloadBrew = BotaniaAPI.registerBrewRecipe(ModBrews.overload, new ItemStack(Items.nether_wart), new ItemStack(Items.blaze_powder), new ItemStack(Items.sugar), new ItemStack(Items.glowstone_dust), new ItemStack(ModItems.manaResource), new ItemStack(Items.spider_eye)); + soulCrossBrew = BotaniaAPI.registerBrewRecipe(ModBrews.soulCross, new ItemStack(Items.nether_wart), new ItemStack(Blocks.soul_sand), new ItemStack(Items.paper), new ItemStack(Items.apple), new ItemStack(Items.bone)); + featherFeetBrew = BotaniaAPI.registerBrewRecipe(ModBrews.featherfeet, new ItemStack(Items.nether_wart), new ItemStack(Items.feather), new ItemStack(Items.leather), new ItemStack(Blocks.wool, 1, -1)); + emptinessBrew = BotaniaAPI.registerBrewRecipe(ModBrews.emptiness, new ItemStack(Items.nether_wart), new ItemStack(Items.gunpowder), new ItemStack(Items.rotten_flesh), new ItemStack(Items.bone), new ItemStack(Items.string), new ItemStack(Items.ender_pearl)); + bloodthirstBrew = BotaniaAPI.registerBrewRecipe(ModBrews.bloodthirst, new ItemStack(Items.nether_wart), new ItemStack(Items.fermented_spider_eye), new ItemStack(Items.dye, 1, 4), new ItemStack(Items.fire_charge), new ItemStack(Items.iron_ingot)); + allureBrew = BotaniaAPI.registerBrewRecipe(ModBrews.allure, new ItemStack(Items.nether_wart), new ItemStack(Items.fish), new ItemStack(Items.quartz), new ItemStack(Items.golden_carrot)); + clearBrew = BotaniaAPI.registerBrewRecipe(ModBrews.clear, new ItemStack(Items.nether_wart), new ItemStack(Items.quartz), new ItemStack(Items.emerald), new ItemStack(Items.melon)); + } + + public static void initTC() { + Item resource = (Item) Item.itemRegistry.getObject("Thaumcraft:ItemResource"); + Item bathSalts = (Item) Item.itemRegistry.getObject("Thaumcraft:ItemBathSalts"); + + warpWardBrew = BotaniaAPI.registerBrewRecipe(ModBrews.warpWard, new ItemStack(Items.nether_wart), new ItemStack(resource, 1, 14), new ItemStack(bathSalts), new ItemStack(resource, 1, 6)); + } - public static void initTC() { - Item resource = (Item) Item.itemRegistry.getObject("Thaumcraft:ItemResource"); - Item bathSalts = (Item) Item.itemRegistry.getObject("Thaumcraft:ItemBathSalts"); - warpWardBrew = BotaniaAPI.registerBrewRecipe( - ModBrews.warpWard, - new ItemStack(Items.nether_wart), - new ItemStack(resource, 1, 14), - new ItemStack(bathSalts), - new ItemStack(resource, 1, 6)); - } } diff --git a/src/main/java/vazkii/botania/common/crafting/ModCraftingRecipes.java b/src/main/java/vazkii/botania/common/crafting/ModCraftingRecipes.java index 33001ca516..1737229cee 100644 --- a/src/main/java/vazkii/botania/common/crafting/ModCraftingRecipes.java +++ b/src/main/java/vazkii/botania/common/crafting/ModCraftingRecipes.java @@ -2,19 +2,18 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jan 19, 2014, 3:54:48 PM (GMT)] */ package vazkii.botania.common.crafting; -import cpw.mods.fml.common.FMLLog; -import cpw.mods.fml.common.registry.GameRegistry; import java.util.ArrayList; import java.util.Arrays; import java.util.List; + import net.minecraft.block.Block; import net.minecraft.init.Blocks; import net.minecraft.init.Items; @@ -25,7 +24,9 @@ import net.minecraftforge.oredict.OreDictionary; import net.minecraftforge.oredict.ShapedOreRecipe; import net.minecraftforge.oredict.ShapelessOreRecipe; + import org.apache.logging.log4j.Level; + import vazkii.botania.api.BotaniaAPI; import vazkii.botania.common.Botania; import vazkii.botania.common.block.ModBlocks; @@ -36,3524 +37,2320 @@ import vazkii.botania.common.item.ItemTwigWand; import vazkii.botania.common.item.ModItems; import vazkii.botania.common.lib.LibOreDict; +import cpw.mods.fml.common.FMLLog; +import cpw.mods.fml.common.registry.GameRegistry; public final class ModCraftingRecipes { - public static IRecipe recipeLexicon; - public static List recipesPetals; - public static List recipesDyes; - public static List recipesPetalBlocks; - public static IRecipe recipePestleAndMortar; - public static List recipesTwigWand; - public static List recipesApothecary; - public static List recipesSpreader; - public static List recipesManaLens; - public static IRecipe recipePool; - public static IRecipe recipePoolDiluted; - public static IRecipe recipePoolFabulous; - public static List recipesRuneAltar; - public static IRecipe recipeLensVelocity; - public static IRecipe recipeLensPotency; - public static IRecipe recipeLensResistance; - public static IRecipe recipeLensEfficiency; - public static IRecipe recipeLensBounce; - public static IRecipe recipeLensGravity; - public static IRecipe recipeLensBore; - public static IRecipe recipeLensDamaging; - public static IRecipe recipeLensPhantom; - public static IRecipe recipeLensMagnet; - public static IRecipe recipeLensExplosive; - public static List recipesUnstableBlocks; - public static IRecipe recipePylon; - public static IRecipe recipeDistributor; - public static IRecipe recipeLivingrockDecor1; - public static IRecipe recipeLivingrockDecor2; - public static IRecipe recipeLivingrockDecor3; - public static IRecipe recipeLivingrockDecor4; - public static IRecipe recipeLivingwoodDecor1; - public static IRecipe recipeLivingwoodDecor2; - public static IRecipe recipeLivingwoodDecor3; - public static IRecipe recipeLivingwoodDecor4; - public static IRecipe recipeLivingwoodDecor5; - public static List recipesManaBeacons; - public static List recipesSignalFlares; - public static IRecipe recipeManaVoid; - public static List recipesManaTablet; - public static IRecipe recipeManaDetector; - public static IRecipe recipeManaBlaster; - public static IRecipe recipeTurntable; - public static IRecipe recipeFertilizerPowder; - public static IRecipe recipeFerilizerDye; - public static IRecipe recipeLivingwoodTwig; - public static IRecipe recipeDirtRod; - public static IRecipe recipeTerraformRod; - public static IRecipe recipeRedstoneSpreader; - public static IRecipe recipeManaMirror; - public static IRecipe recipeManasteelHelm; - public static IRecipe recipeManasteelChest; - public static IRecipe recipeManasteelLegs; - public static IRecipe recipeManasteelBoots; - public static IRecipe recipeManasteelPick; - public static IRecipe recipeManasteelShovel; - public static IRecipe recipeManasteelAxe; - public static IRecipe recipeManasteelShears; - public static IRecipe recipeManasteelSword; - public static IRecipe recipeGrassHorn; - public static IRecipe recipeTerrasteelHelm; - public static IRecipe recipeTerrasteelChest; - public static IRecipe recipeTerrasteelLegs; - public static IRecipe recipeTerrasteelBoots; - public static IRecipe recipeTerraSword; - public static IRecipe recipeTinyPlanet; - public static IRecipe recipeManaRing; - public static IRecipe recipeAuraRing; - public static IRecipe recipeGreaterManaRing; - public static IRecipe recipeGreaterAuraRing; - public static IRecipe recipeTravelBelt; - public static IRecipe recipeKnocbackBelt; - public static IRecipe recipeIcePendant; - public static IRecipe recipeFirePendant; - public static IRecipe recipeGoldenLaurel; - public static IRecipe recipeTinyPlanetBlock; - public static IRecipe recipeAlchemyCatalyst; - public static IRecipe recipeOpenCrate; - public static IRecipe recipeForestEye; - public static IRecipe recipeRedstoneRoot; - public static IRecipe recipeForestDrum; - public static IRecipe recipeWaterRing; - public static IRecipe recipeMiningRing; - public static IRecipe recipeMagnetRing; - public static IRecipe recipeTerraPick; - public static IRecipe recipeDivaCharm; - public static IRecipe recipeFlightTiara; - public static List recipesShinyFlowers; - public static IRecipe recipePlatform; - public static IRecipe recipeEnderDagger; - public static IRecipe recipeDarkQuartz; - public static IRecipe recipeBlazeQuartz; - public static List recipesLavenderQuartz; - public static IRecipe recipeRedQuartz; - public static IRecipe recipeSunnyQuartz; - public static IRecipe recipeAlfPortal; - public static IRecipe recipeNaturaPylon; - public static IRecipe recipeWaterRod; - public static IRecipe recipeElementiumHelm; - public static IRecipe recipeElementiumChest; - public static IRecipe recipeElementiumLegs; - public static IRecipe recipeElementiumBoots; - public static IRecipe recipeElementiumPick; - public static IRecipe recipeElementiumShovel; - public static IRecipe recipeElementiumAxe; - public static IRecipe recipeElementiumShears; - public static IRecipe recipeElementiumSword; - public static IRecipe recipeOpenBucket; - public static IRecipe recipeConjurationCatalyst; - public static IRecipe recipeSpawnerMover; - public static IRecipe recipePixieRing; - public static IRecipe recipeSuperTravelBelt; - public static IRecipe recipeRainbowRod; - public static IRecipe recipeSpectralPlatform; - public static List recipesDreamwoodSpreader; - public static IRecipe recipeTornadoRod; - public static IRecipe recipeFireRod; - public static IRecipe recipeVineBall; - public static IRecipe recipeSlingshot; - public static IRecipe recipeMossStone; - public static IRecipe recipePrismarine; - public static IRecipe recipePrismarineBrick; - public static IRecipe recipeDarkPrismarine; - public static IRecipe recipeSeaLamp; - public static IRecipe recipeLensInfluence; - public static IRecipe recipeLensWeight; - public static IRecipe recipeLensPaint; - public static IRecipe recipeLensWarp; - public static IRecipe recipeLensRedirect; - public static IRecipe recipeLensFirework; - public static IRecipe recipeLensFlare; - public static List recipesMiniIsland; - public static IRecipe recipeGaiaPylon; - public static IRecipe recipeGatherDrum; - public static IRecipe recipeLensFire; - public static IRecipe recipeLensPiston; - public static List recipesLaputaShard; - public static List recipesLaputaShardUpgrade; - public static IRecipe recipeVirusZombie; - public static IRecipe recipeVirusSkeleton; - public static IRecipe recipeReachRing; - public static IRecipe recipeSkyDirtRod; - public static IRecipe recipeSpawnerClaw; - public static IRecipe recipeCraftCrate; - public static IRecipe recipePlaceholder; - public static IRecipe recipeReedBlock; - public static IRecipe recipeThatch; - public static IRecipe recipeNetherBrick; - public static IRecipe recipeSoulBrick; - public static IRecipe recipeSnowBrick; - public static IRecipe recipeRoofTile; - public static IRecipe recipeAzulejo; - public static List recipesAzulejoCycling; - public static IRecipe recipeEnderEyeBlock; - public static IRecipe recipeItemFinder; - public static IRecipe recipeSuperLavaPendant; - public static IRecipe recipeEnderHand; - public static IRecipe recipeGlassPick; - public static IRecipe recipeStarfield; - public static List recipesSpark; - public static List recipesSparkUpgrades; - public static IRecipe recipeLeafHorn; - public static IRecipe recipeDiviningRod; - public static List recipesWings; - public static IRecipe recipeRFGenerator; - public static IRecipe recipeGravityRod; - public static IRecipe recipeRegenIvy; - public static IRecipe recipeUltraSpreader; - public static IRecipe recipeHelmetOfRevealing; - public static IRecipe recipeVial; - public static IRecipe recipeFlask; - public static IRecipe recipeBrewery; - public static IRecipe recipeBloodPendant; - public static IRecipe recipeTerraPlate; - public static IRecipe recipeRedString; - public static IRecipe recipeRedStringContainer; - public static IRecipe recipeRedStringDispenser; - public static IRecipe recipeRedStringFertilizer; - public static IRecipe recipeRedStringComparator; - public static IRecipe recipeRedStringRelay; - public static IRecipe recipeRedStringInterceptor; - public static IRecipe recipeMissileRod; - public static IRecipe recipeHolyCloak; - public static IRecipe recipeUnholyCloak; - public static IRecipe recipeCraftingHalo; - public static List recipesLensFlash; - public static IRecipe recipePrism; - public static IRecipe recipeDirtPath; - public static IRecipe recipeDreamwoodTwig; - public static IRecipe recipeMonocle; - public static IRecipe recipeClip; - public static IRecipe recipeCobbleRod; - public static IRecipe recipeSmeltRod; - public static IRecipe recipeWorldSeed; - public static IRecipe recipeSpellCloth; - public static IRecipe recipeThornChakram; - public static IRecipe recipeDirtPathSlab; - public static List recipesPatterns; - public static IRecipe recipeGaiaIngot; - public static IRecipe recipeCorporeaSpark; - public static IRecipe recipeMasterCorporeaSpark; - public static IRecipe recipeCorporeaIndex; - public static IRecipe recipeCorporeaFunnel; - public static IRecipe recipeCorporeaInterceptor; - public static IRecipe recipeEndStoneBricks; - public static IRecipe recipeEndStoneChiseledBricks; - public static IRecipe recipeEnderBricks; - public static IRecipe recipePillarEnderBricks; - public static IRecipe recipeLivingwoodBow; - public static IRecipe recipeCrystalBow; - public static List recipesCosmeticItems; - public static List recipesMushrooms; - public static IRecipe recipeSwapRing; - public static IRecipe recipeSnowHorn; - public static IRecipe recipeFlowerBag; - public static IRecipe recipePhantomInk; - public static IRecipe recipePoolCart; - public static IRecipe recipePump; - public static List recipesPetalsDouble; - public static IRecipe recipeKeepIvy; - public static IRecipe recipeBlackHoleTalisman; - public static List recipe18StonePolish; - public static List recipe18StoneBrick; - public static List recipe18StoneChisel; - public static IRecipe recipeBlazeBlock; - public static List recipesAltarMeta; - public static IRecipe recipeCorporeaCrystalCube; - public static IRecipe recipeTemperanceStone; - public static IRecipe recipeIncenseStick; - public static IRecipe recipeIncensePlate; - public static IRecipe recipeTerraAxe; - public static IRecipe recipeHourglass; - public static IRecipe recipeGhostRail; - public static IRecipe recipeCanopyDrum; - public static IRecipe recipeSparkChanger; - public static IRecipe recipeCocoon; - public static IRecipe recipeLuminizer; - public static IRecipe recipeDetectorLuminizer; - public static IRecipe recipeLuminizerLauncher; - public static IRecipe recipeObedienceStick; - public static IRecipe recipeCacophonium; - public static IRecipe recipeManaBomb; - public static IRecipe recipeCobweb; - public static IRecipe recipeSlimeBottle; - public static IRecipe recipeStarSword; - public static IRecipe recipeExchangeRod; - public static IRecipe recipeGreaterMagnetRing; - public static IRecipe recipeFireChakram; - public static IRecipe recipeThunderSword; - public static IRecipe recipeBellows; - public static IRecipe recipeManaweaveCloth; - public static IRecipe recipeManaweaveHelm; - public static IRecipe recipeManaweaveChest; - public static IRecipe recipeManaweaveLegs; - public static IRecipe recipeManaweaveBoots; - public static IRecipe recipeBifrost; - public static IRecipe recipeShimmerrock; - public static IRecipe recipeShimmerwoodPlanks; - public static IRecipe recipeAutocraftingHalo; - public static List recipesPavement; - public static IRecipe recipeCellBlock; - public static IRecipe recipeCorporeaRetainer; - public static IRecipe recipeTeruTeruBozu; - public static IRecipe recipeAvatar; - public static IRecipe recipeSextant; - public static List recipesAltGrassSeeds; - public static IRecipe recipeSpeedUpBelt; - public static IRecipe recipeBaubleCase; - - // Garden of Glass - public static IRecipe recipeRootToSapling; - public static IRecipe recipeRootToFertilizer; - public static IRecipe recipePebbleCobblestone; - public static IRecipe recipeMagmaToSlimeball; - public static IRecipe recipeFelPumpkin; - public static IRecipe recipeEndPortal; - - public static void init() { - if (!ConfigHandler.enableDefaultRecipes) return; - - int recipeListSize = CraftingManager.getInstance().getRecipeList().size(); - - // Lexicon Recipe - addShapelessOreDictRecipe(new ItemStack(ModItems.lexicon), "treeSapling", Items.book); - recipeLexicon = BotaniaAPI.getLatestAddedRecipe(); - - // Petal/Dye Recipes - for (int i = 0; i < 16; i++) - addShapelessOreDictRecipe(new ItemStack(ModItems.petal, 2, i), LibOreDict.FLOWER[i]); - recipesPetals = BotaniaAPI.getLatestAddedRecipes(16); - - for (int i = 0; i < 16; i++) - addShapelessOreDictRecipe( - new ItemStack(ModItems.dye, 1, i), LibOreDict.PETAL[i], LibOreDict.PESTLE_AND_MORTAR); - recipesDyes = BotaniaAPI.getLatestAddedRecipes(16); - - // Petal Block Recipes - for (int i = 0; i < 16; i++) - addOreDictRecipe( - new ItemStack(ModBlocks.petalBlock, 1, i), - "PPP", - "PPP", - "PPP", // PPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPP - 'P', - LibOreDict.PETAL[i]); - recipesPetalBlocks = BotaniaAPI.getLatestAddedRecipes(16); - - // Pestle and Mortar Recipe - addOreDictRecipe( - new ItemStack(ModItems.pestleAndMortar), - " S", - "W ", - "B ", - 'S', - "stickWood", - 'W', - "plankWood", - 'B', - Items.bowl); - recipePestleAndMortar = BotaniaAPI.getLatestAddedRecipe(); - - // Wand of the Forest Recipes - for (int i = 0; i < 16; i++) - for (int j = 0; j < 16; j++) { - addOreDictRecipe( - ItemTwigWand.forColors(i, j), - " AS", - " SB", - "S ", - 'A', - LibOreDict.PETAL[i], - 'B', - LibOreDict.PETAL[j], - 'S', - LibOreDict.LIVINGWOOD_TWIG); - } - recipesTwigWand = BotaniaAPI.getLatestAddedRecipes(256); - - // Petal Apothecary Recipes - for (int i = 0; i < 16; i++) - addOreDictRecipe( - new ItemStack(ModBlocks.altar), - "SPS", - " C ", - "CCC", - 'S', - "slabCobblestone", - 'P', - LibOreDict.PETAL[i], - 'C', - "cobblestone"); - recipesApothecary = BotaniaAPI.getLatestAddedRecipes(16); - - // Mana Spreader Recipes - for (int i = 0; i < 16; i++) - addOreDictRecipe( - new ItemStack(ModBlocks.spreader), - "WWW", - "GP ", - "WWW", - 'W', - LibOreDict.LIVING_WOOD, - 'P', - LibOreDict.PETAL[i], - 'G', - Botania.gardenOfGlassLoaded ? LibOreDict.LIVING_WOOD : "ingotGold"); - recipesSpreader = BotaniaAPI.getLatestAddedRecipes(16); - - // Mana Lens Recipe - addOreDictRecipe( - new ItemStack(ModItems.lens), - " S ", - "SGS", - " S ", - 'S', - LibOreDict.MANA_STEEL, - 'G', - "paneGlassColorless"); - addOreDictRecipe( - new ItemStack(ModItems.lens), - " S ", - "SGS", - " S ", - 'S', - LibOreDict.MANA_STEEL, - 'G', - "blockGlassColorless"); - recipesManaLens = BotaniaAPI.getLatestAddedRecipes(2); - - // Mana Pool Recipe - addOreDictRecipe(new ItemStack(ModBlocks.pool), "R R", "RRR", 'R', LibOreDict.LIVING_ROCK); - recipePool = BotaniaAPI.getLatestAddedRecipe(); - - // Diluted Mana Pool Recipe - addOreDictRecipe( - new ItemStack(ModBlocks.pool, 1, 2), "R R", "RRR", 'R', new ItemStack(ModFluffBlocks.livingrockSlab)); - recipePoolDiluted = BotaniaAPI.getLatestAddedRecipe(); - - // Fabulous Mana Pool Recipe - addOreDictRecipe(new ItemStack(ModBlocks.pool, 1, 3), "R R", "RRR", 'R', new ItemStack(ModBlocks.shimmerrock)); - recipePoolFabulous = BotaniaAPI.getLatestAddedRecipe(); - - // Runic Altar Recipe - addOreDictRecipe( - new ItemStack(ModBlocks.runeAltar), - "SSS", - "SPS", - 'S', - LibOreDict.LIVING_ROCK, - 'P', - LibOreDict.MANA_PEARL); - addOreDictRecipe( - new ItemStack(ModBlocks.runeAltar), - "SSS", - "SDS", - 'S', - LibOreDict.LIVING_ROCK, - 'D', - LibOreDict.MANA_DIAMOND); - recipesRuneAltar = BotaniaAPI.getLatestAddedRecipes(2); - - // Lens Recipes - addShapelessOreDictRecipe(new ItemStack(ModItems.lens, 1, 1), new ItemStack(ModItems.lens), LibOreDict.RUNE[3]); - recipeLensVelocity = BotaniaAPI.getLatestAddedRecipe(); - - addShapelessOreDictRecipe(new ItemStack(ModItems.lens, 1, 2), new ItemStack(ModItems.lens), LibOreDict.RUNE[1]); - recipeLensPotency = BotaniaAPI.getLatestAddedRecipe(); - - addShapelessOreDictRecipe(new ItemStack(ModItems.lens, 1, 3), new ItemStack(ModItems.lens), LibOreDict.RUNE[2]); - recipeLensResistance = BotaniaAPI.getLatestAddedRecipe(); - - addShapelessOreDictRecipe(new ItemStack(ModItems.lens, 1, 4), new ItemStack(ModItems.lens), LibOreDict.RUNE[0]); - recipeLensEfficiency = BotaniaAPI.getLatestAddedRecipe(); - - addShapelessOreDictRecipe(new ItemStack(ModItems.lens, 1, 5), new ItemStack(ModItems.lens), LibOreDict.RUNE[5]); - recipeLensBounce = BotaniaAPI.getLatestAddedRecipe(); - - addShapelessOreDictRecipe(new ItemStack(ModItems.lens, 1, 6), new ItemStack(ModItems.lens), LibOreDict.RUNE[7]); - recipeLensGravity = BotaniaAPI.getLatestAddedRecipe(); - - addOreDictRecipe( - new ItemStack(ModItems.lens, 1, 7), - " P ", - "ALA", - " R ", - 'P', - new ItemStack(Blocks.piston), - 'R', - "dustRedstone", - 'A', - "gemLapis", - 'L', - new ItemStack(ModItems.lens)); - recipeLensBore = BotaniaAPI.getLatestAddedRecipe(); - - addShapelessOreDictRecipe( - new ItemStack(ModItems.lens, 1, 8), new ItemStack(ModItems.lens), LibOreDict.RUNE[13]); - recipeLensDamaging = BotaniaAPI.getLatestAddedRecipe(); - - addShapelessOreDictRecipe( - new ItemStack(ModItems.lens, 1, 9), new ItemStack(ModItems.lens), new ItemStack(ModBlocks.platform)); - recipeLensPhantom = BotaniaAPI.getLatestAddedRecipe(); - - addShapelessOreDictRecipe( - new ItemStack(ModItems.lens, 1, 10), new ItemStack(ModItems.lens), "ingotIron", "ingotGold"); - recipeLensMagnet = BotaniaAPI.getLatestAddedRecipe(); - - addShapelessOreDictRecipe( - new ItemStack(ModItems.lens, 1, 11), new ItemStack(ModItems.lens), LibOreDict.RUNE[14]); - recipeLensExplosive = BotaniaAPI.getLatestAddedRecipe(); - - // Unstable Block Recipes - for (int i = 0; i < 16; i++) - addOreDictRecipe( - new ItemStack(ModBlocks.unstableBlock, 2, i), - "OPO", - "PMP", - "OPO", - 'O', - new ItemStack(Blocks.obsidian), - 'P', - LibOreDict.PETAL[i], - 'M', - new ItemStack(Items.ender_pearl)); - recipesUnstableBlocks = BotaniaAPI.getLatestAddedRecipes(16); - - // Mana Pylon Recipe - addOreDictRecipe( - new ItemStack(ModBlocks.pylon), - " G ", - "MDM", - " G ", - 'G', - "ingotGold", - 'M', - LibOreDict.MANA_STEEL, - 'D', - LibOreDict.MANA_DIAMOND); - recipePylon = BotaniaAPI.getLatestAddedRecipe(); - - // Mana Distributor - addOreDictRecipe( - new ItemStack(ModBlocks.distributor), - "RRR", - "S S", - "RRR", - 'R', - LibOreDict.LIVING_ROCK, - 'S', - LibOreDict.MANA_STEEL); - recipeDistributor = BotaniaAPI.getLatestAddedRecipe(); - - // Livingrock Decorative Blocks - addOreDictRecipe(new ItemStack(ModBlocks.livingrock, 4, 1), "RR", "RR", 'R', LibOreDict.LIVING_ROCK); - recipeLivingrockDecor1 = BotaniaAPI.getLatestAddedRecipe(); - addShapelessOreDictRecipe( - new ItemStack(ModBlocks.livingrock, 1, 2), - new ItemStack(ModBlocks.livingrock, 1, 1), - new ItemStack(Items.wheat_seeds)); - recipeLivingrockDecor2 = BotaniaAPI.getLatestAddedRecipe(); - addShapelessOreDictRecipe( - new ItemStack(ModBlocks.livingrock, 2, 3), new ItemStack(ModBlocks.livingrock, 1, 1), "cobblestone"); - recipeLivingrockDecor3 = BotaniaAPI.getLatestAddedRecipe(); - addOreDictRecipe( - new ItemStack(ModBlocks.livingrock, 4, 4), "RR", "RR", 'R', new ItemStack(ModBlocks.livingrock, 1, 1)); - recipeLivingrockDecor4 = BotaniaAPI.getLatestAddedRecipe(); - - // Livingwood Decorative Blocks - addShapelessOreDictRecipe(new ItemStack(ModBlocks.livingwood, 4, 1), LibOreDict.LIVING_WOOD); - recipeLivingwoodDecor1 = BotaniaAPI.getLatestAddedRecipe(); - addShapelessOreDictRecipe( - new ItemStack(ModBlocks.livingwood, 1, 2), - new ItemStack(ModBlocks.livingwood, 1, 1), - new ItemStack(Items.wheat_seeds)); - recipeLivingwoodDecor2 = BotaniaAPI.getLatestAddedRecipe(); - addOreDictRecipe( - new ItemStack(ModBlocks.livingwood, 4, 3), "WW", "WW", 'W', new ItemStack(ModBlocks.livingwood, 1, 1)); - recipeLivingwoodDecor3 = BotaniaAPI.getLatestAddedRecipe(); - addOreDictRecipe( - new ItemStack(ModBlocks.livingwood, 4, 4), - " W ", - "W W", - " W ", - 'W', - new ItemStack(ModBlocks.livingwood, 1, 1)); - recipeLivingwoodDecor4 = BotaniaAPI.getLatestAddedRecipe(); - addShapelessOreDictRecipe(new ItemStack(ModBlocks.livingwood, 1, 5), LibOreDict.LIVING_WOOD, "dustGlowstone"); - recipeLivingwoodDecor5 = BotaniaAPI.getLatestAddedRecipe(); - - // Dreamwood Decorative Blocks - addShapelessOreDictRecipe(new ItemStack(ModBlocks.dreamwood, 4, 1), LibOreDict.DREAM_WOOD); - addShapelessOreDictRecipe( - new ItemStack(ModBlocks.dreamwood, 1, 2), - new ItemStack(ModBlocks.dreamwood, 1, 1), - new ItemStack(Items.wheat_seeds)); - addOreDictRecipe( - new ItemStack(ModBlocks.dreamwood, 4, 3), "WW", "WW", 'W', new ItemStack(ModBlocks.dreamwood, 1, 1)); - addOreDictRecipe( - new ItemStack(ModBlocks.dreamwood, 4, 4), - " W ", - "W W", - " W ", - 'W', - new ItemStack(ModBlocks.dreamwood, 1, 1)); - addShapelessOreDictRecipe(new ItemStack(ModBlocks.dreamwood, 1, 5), LibOreDict.DREAM_WOOD, "dustGlowstone"); - - // Mana Beacon Recipe - for (int i = 0; i < 16; i++) - addOreDictRecipe( - new ItemStack(ModBlocks.manaBeacon, 1, i), - " B ", - "BPB", - " B ", - 'B', - new ItemStack(ModBlocks.unstableBlock, 1, i), - 'P', - LibOreDict.MANA_PEARL); - recipesManaBeacons = BotaniaAPI.getLatestAddedRecipes(16); - - // Signal Flare Recipe - for (int i = 0; i < 16; i++) - addOreDictRecipe( - ItemSignalFlare.forColor(i), - "I ", - " B", - "W ", - 'B', - new ItemStack(ModBlocks.manaBeacon, 1, i), - 'I', - "ingotIron", - 'W', - LibOreDict.LIVING_WOOD); - recipesSignalFlares = BotaniaAPI.getLatestAddedRecipes(16); - - // Mana Void Recipe - addOreDictRecipe( - new ItemStack(ModBlocks.manaVoid), - "SSS", - "O O", - "SSS", - 'S', - LibOreDict.LIVING_ROCK, - 'O', - new ItemStack(Blocks.obsidian)); - recipeManaVoid = BotaniaAPI.getLatestAddedRecipe(); - - // Mana Tablet Recipe - addOreDictRecipe( - new ItemStack(ModItems.manaTablet, 1, 10000), - "SSS", - "SPS", - "SSS", - 'S', - LibOreDict.LIVING_ROCK, - 'P', - LibOreDict.MANA_PEARL); - addOreDictRecipe( - new ItemStack(ModItems.manaTablet, 1, 10000), - "SSS", - "SDS", - "SSS", - 'S', - LibOreDict.LIVING_ROCK, - 'D', - LibOreDict.MANA_DIAMOND); - recipesManaTablet = BotaniaAPI.getLatestAddedRecipes(2); - - // Mana Detector Recipe - addOreDictRecipe( - new ItemStack(ModBlocks.manaDetector), - "RSR", - "SCS", - "RSR", - 'R', - "dustRedstone", - 'C', - new ItemStack(Items.comparator), - 'S', - LibOreDict.LIVING_ROCK); - recipeManaDetector = BotaniaAPI.getLatestAddedRecipe(); - - // Mana Blaster Recipe - addOreDictRecipe( - new ItemStack(ModItems.manaGun), - "SMD", - " WT", - " W", - 'S', - new ItemStack(ModBlocks.spreader, 1, 1), - 'M', - LibOreDict.RUNE[8], - 'D', - LibOreDict.MANA_DIAMOND, - 'T', - new ItemStack(Blocks.tnt), - 'W', - LibOreDict.LIVING_WOOD); - recipeManaBlaster = BotaniaAPI.getLatestAddedRecipe(); - - // Spreader Turntable Recipe - addOreDictRecipe( - new ItemStack(ModBlocks.turntable), - "WWW", - "WPW", - "WWW", - 'W', - LibOreDict.LIVING_WOOD, - 'P', - Blocks.sticky_piston); - recipeTurntable = BotaniaAPI.getLatestAddedRecipe(); - - // Fertilizer Recipes - GameRegistry.addShapelessRecipe( - new ItemStack(ModItems.fertilizer, Botania.gardenOfGlassLoaded ? 3 : 1), - new ItemStack(Items.dye, 1, 15), - new ItemStack(ModItems.dye, 1, Short.MAX_VALUE), - new ItemStack(ModItems.dye, 1, Short.MAX_VALUE), - new ItemStack(ModItems.dye, 1, Short.MAX_VALUE), - new ItemStack(ModItems.dye, 1, Short.MAX_VALUE)); - recipeFertilizerPowder = BotaniaAPI.getLatestAddedRecipe(); - GameRegistry.addShapelessRecipe( - new ItemStack(ModItems.fertilizer), - new ItemStack(Items.dye, 1, 15), - new ItemStack(Items.dye, 1, 11), - new ItemStack(Items.dye, 1, 11), - new ItemStack(Items.dye, 1, 1), - new ItemStack(Items.dye, 1, 1)); - recipeFerilizerDye = BotaniaAPI.getLatestAddedRecipe(); - - // Livingwood Twig Recipe - addOreDictRecipe(new ItemStack(ModItems.manaResource, 1, 3), "W", "W", 'W', LibOreDict.LIVING_WOOD); - recipeLivingwoodTwig = BotaniaAPI.getLatestAddedRecipe(); - - // Rod of the Lands Recipe - addOreDictRecipe( - new ItemStack(ModItems.dirtRod), - " D", - " T ", - "E ", - 'D', - new ItemStack(Blocks.dirt), - 'T', - LibOreDict.LIVINGWOOD_TWIG, - 'E', - LibOreDict.RUNE[2]); - recipeDirtRod = BotaniaAPI.getLatestAddedRecipe(); - - // Terra Firma Rod Recipe - addOreDictRecipe( - new ItemStack(ModItems.terraformRod), - " WT", - "ARS", - "GM ", - 'T', - LibOreDict.TERRA_STEEL, - 'R', - new ItemStack(ModItems.dirtRod), - 'G', - new ItemStack(ModItems.grassSeeds), - 'W', - LibOreDict.RUNE[7], - 'S', - LibOreDict.RUNE[4], - 'M', - LibOreDict.RUNE[5], - 'A', - LibOreDict.RUNE[6]); - recipeTerraformRod = BotaniaAPI.getLatestAddedRecipe(); - - // Redstone Mana Spreader Recipe - GameRegistry.addRecipe(new ShapelessOreRecipe( - new ItemStack(ModBlocks.spreader, 1, 1), new ItemStack(ModBlocks.spreader), "dustRedstone")); - recipeRedstoneSpreader = BotaniaAPI.getLatestAddedRecipe(); - - // Mana Miror Recipe - addOreDictRecipe( - new ItemStack(ModItems.manaMirror), - " PR", - " SI", - "T ", - 'P', - LibOreDict.MANA_PEARL, - 'R', - LibOreDict.LIVING_ROCK, - 'S', - LibOreDict.LIVINGWOOD_TWIG, - 'I', - LibOreDict.TERRA_STEEL, - 'T', - new ItemStack(ModItems.manaTablet, 1, Short.MAX_VALUE)); - recipeManaMirror = BotaniaAPI.getLatestAddedRecipe(); - - // Mana Armor & Tools Recipes - addOreDictRecipe(new ItemStack(ModItems.manasteelHelm), "SSS", "S S", 'S', LibOreDict.MANA_STEEL); - recipeManasteelHelm = BotaniaAPI.getLatestAddedRecipe(); - addOreDictRecipe(new ItemStack(ModItems.manasteelChest), "S S", "SSS", "SSS", 'S', LibOreDict.MANA_STEEL); - recipeManasteelChest = BotaniaAPI.getLatestAddedRecipe(); - addOreDictRecipe(new ItemStack(ModItems.manasteelLegs), "SSS", "S S", "S S", 'S', LibOreDict.MANA_STEEL); - recipeManasteelLegs = BotaniaAPI.getLatestAddedRecipe(); - addOreDictRecipe(new ItemStack(ModItems.manasteelBoots), "S S", "S S", 'S', LibOreDict.MANA_STEEL); - recipeManasteelBoots = BotaniaAPI.getLatestAddedRecipe(); - addOreDictRecipe( - new ItemStack(ModItems.manasteelPick), - "SSS", - " T ", - " T ", - 'S', - LibOreDict.MANA_STEEL, - 'T', - LibOreDict.LIVINGWOOD_TWIG); - recipeManasteelPick = BotaniaAPI.getLatestAddedRecipe(); - addOreDictRecipe( - new ItemStack(ModItems.manasteelShovel), - "S", - "T", - "T", - 'S', - LibOreDict.MANA_STEEL, - 'T', - LibOreDict.LIVINGWOOD_TWIG); - recipeManasteelShovel = BotaniaAPI.getLatestAddedRecipe(); - addOreDictRecipe( - new ItemStack(ModItems.manasteelAxe), - "SS", - "TS", - "T ", - 'S', - LibOreDict.MANA_STEEL, - 'T', - LibOreDict.LIVINGWOOD_TWIG); - recipeManasteelAxe = BotaniaAPI.getLatestAddedRecipe(); - addOreDictRecipe( - new ItemStack(ModItems.manasteelSword), - "S", - "S", - "T", - 'S', - LibOreDict.MANA_STEEL, - 'T', - LibOreDict.LIVINGWOOD_TWIG); - recipeManasteelSword = BotaniaAPI.getLatestAddedRecipe(); - addOreDictRecipe(new ItemStack(ModItems.manasteelShears), "S ", " S", 'S', LibOreDict.MANA_STEEL); - recipeManasteelShears = BotaniaAPI.getLatestAddedRecipe(); - - // Horn of the Wild Recipe - addOreDictRecipe( - new ItemStack(ModItems.grassHorn), - " W ", - "WSW", - "WW ", - 'W', - LibOreDict.LIVING_WOOD, - 'S', - new ItemStack(ModItems.grassSeeds)); - recipeGrassHorn = BotaniaAPI.getLatestAddedRecipe(); - - // Terrasteel Armor Recipes - addOreDictRecipe( - new ItemStack(ModItems.terrasteelHelmRevealing), - "TRT", - "SAS", - " S ", - 'T', - LibOreDict.LIVINGWOOD_TWIG, - 'S', - LibOreDict.TERRA_STEEL, - 'R', - LibOreDict.RUNE[4], - 'A', - new ItemStack(ModItems.manasteelHelmRevealing)); - addOreDictRecipe( - new ItemStack(ModItems.terrasteelHelm), - "TRT", - "SAS", - " S ", - 'T', - LibOreDict.LIVINGWOOD_TWIG, - 'S', - LibOreDict.TERRA_STEEL, - 'R', - LibOreDict.RUNE[4], - 'A', - new ItemStack(ModItems.manasteelHelm)); - recipeTerrasteelHelm = BotaniaAPI.getLatestAddedRecipe(); - addOreDictRecipe( - new ItemStack(ModItems.terrasteelChest), - "TRT", - "SAS", - " S ", - 'T', - LibOreDict.LIVINGWOOD_TWIG, - 'S', - LibOreDict.TERRA_STEEL, - 'R', - LibOreDict.RUNE[5], - 'A', - new ItemStack(ModItems.manasteelChest)); - recipeTerrasteelChest = BotaniaAPI.getLatestAddedRecipe(); - addOreDictRecipe( - new ItemStack(ModItems.terrasteelLegs), - "TRT", - "SAS", - " S ", - 'T', - LibOreDict.LIVINGWOOD_TWIG, - 'S', - LibOreDict.TERRA_STEEL, - 'R', - LibOreDict.RUNE[6], - 'A', - new ItemStack(ModItems.manasteelLegs)); - recipeTerrasteelLegs = BotaniaAPI.getLatestAddedRecipe(); - addOreDictRecipe( - new ItemStack(ModItems.terrasteelBoots), - "TRT", - "SAS", - " S ", - 'T', - LibOreDict.LIVINGWOOD_TWIG, - 'S', - LibOreDict.TERRA_STEEL, - 'R', - LibOreDict.RUNE[7], - 'A', - new ItemStack(ModItems.manasteelBoots)); - recipeTerrasteelBoots = BotaniaAPI.getLatestAddedRecipe(); - - // Terra Blade Recipe - addOreDictRecipe( - new ItemStack(ModItems.terraSword), - "I", - "I", - "S", - 'I', - LibOreDict.TERRA_STEEL, - 'S', - LibOreDict.LIVINGWOOD_TWIG); - recipeTerraSword = BotaniaAPI.getLatestAddedRecipe(); - - // Tiny Planet Recipe - addOreDictRecipe( - new ItemStack(ModItems.tinyPlanet), - "LSL", - "SPS", - "LSL", - 'S', - "stone", - 'L', - LibOreDict.LIVING_ROCK, - 'P', - LibOreDict.MANA_PEARL); - recipeTinyPlanet = BotaniaAPI.getLatestAddedRecipe(); - - // Mana Band Recipe - addOreDictRecipe( - new ItemStack(ModItems.manaRing), - "TI ", - "I I", - " I ", - 'T', - new ItemStack(ModItems.manaTablet, 1, Short.MAX_VALUE), - 'I', - LibOreDict.MANA_STEEL); - recipeManaRing = BotaniaAPI.getLatestAddedRecipe(); - - // Aura Band Recipe - addOreDictRecipe( - new ItemStack(ModItems.auraRing), - "RI ", - "I I", - " I ", - 'R', - LibOreDict.RUNE[8], - 'I', - LibOreDict.MANA_STEEL); - recipeAuraRing = BotaniaAPI.getLatestAddedRecipe(); - - // Greater Mana Band Recipe - addShapelessOreDictRecipe( - new ItemStack(ModItems.manaRingGreater), LibOreDict.TERRA_STEEL, new ItemStack(ModItems.manaRing)); - recipeGreaterManaRing = BotaniaAPI.getLatestAddedRecipe(); - - // Greater Aura Band Recipe - addShapelessOreDictRecipe( - new ItemStack(ModItems.auraRingGreater), LibOreDict.TERRA_STEEL, new ItemStack(ModItems.auraRing)); - recipeGreaterAuraRing = BotaniaAPI.getLatestAddedRecipe(); - - // Soujourner's Belt Recipe - addOreDictRecipe( - new ItemStack(ModItems.travelBelt), - "EL ", - "L L", - "SLA", - 'E', - LibOreDict.RUNE[2], - 'A', - LibOreDict.RUNE[3], - 'S', - LibOreDict.MANA_STEEL, - 'L', - new ItemStack(Items.leather)); - recipeTravelBelt = BotaniaAPI.getLatestAddedRecipe(); - - // Tectonic Girdle Recipe - addOreDictRecipe( - new ItemStack(ModItems.knockbackBelt), - "AL ", - "L L", - "SLE", - 'E', - LibOreDict.RUNE[2], - 'A', - LibOreDict.RUNE[1], - 'S', - LibOreDict.MANA_STEEL, - 'L', - new ItemStack(Items.leather)); - recipeKnocbackBelt = BotaniaAPI.getLatestAddedRecipe(); - - // Snowflake Pendant Recipe - addOreDictRecipe( - new ItemStack(ModItems.icePendant), - "WS ", - "S S", - "MSR", - 'S', - new ItemStack(Items.string), - 'M', - LibOreDict.MANA_STEEL, - 'R', - LibOreDict.RUNE[0], - 'W', - LibOreDict.RUNE[7]); - recipeIcePendant = BotaniaAPI.getLatestAddedRecipe(); - - // Pyroclast Pendant Recipe - addOreDictRecipe( - new ItemStack(ModItems.lavaPendant), - "MS ", - "S S", - "DSF", - 'S', - new ItemStack(Items.string), - 'D', - LibOreDict.MANA_STEEL, - 'M', - LibOreDict.RUNE[5], - 'F', - LibOreDict.RUNE[1]); - recipeFirePendant = BotaniaAPI.getLatestAddedRecipe(); - - // Golden Laurel Crown Recipe - addOreDictRecipe( - new ItemStack(ModItems.goldLaurel), - "G G", - "LEL", - "LLL", - 'G', - "ingotGold", - 'L', - "treeLeaves", - 'E', - LibOreDict.LIFE_ESSENCE); - recipeGoldenLaurel = BotaniaAPI.getLatestAddedRecipe(); - - // Tiny Planet Block Recipe - addOreDictRecipe( - new ItemStack(ModBlocks.tinyPlanet), "SSS", "SPS", "SSS", 'S', "stone", 'P', ModItems.tinyPlanet); - recipeTinyPlanetBlock = BotaniaAPI.getLatestAddedRecipe(); - - // Alchemy Catalyst Recipe - addOreDictRecipe( - new ItemStack(ModBlocks.alchemyCatalyst), - "SGS", - "BPB", - "SGS", - 'S', - LibOreDict.LIVING_ROCK, - 'G', - "ingotGold", - 'B', - new ItemStack(Items.brewing_stand), - 'P', - LibOreDict.MANA_PEARL); - recipeAlchemyCatalyst = BotaniaAPI.getLatestAddedRecipe(); - - // Open Crate Recipe - GameRegistry.addRecipe( - new ItemStack(ModBlocks.openCrate), - "WWW", - "W W", - "W W", - 'W', - new ItemStack(ModBlocks.livingwood, 1, 1)); - recipeOpenCrate = BotaniaAPI.getLatestAddedRecipe(); - - // Eye of the Ancients Recipe - addOreDictRecipe( - new ItemStack(ModBlocks.forestEye), - "MSM", - "SES", - "MSM", - 'M', - LibOreDict.MANA_STEEL, - 'S', - LibOreDict.LIVING_ROCK, - 'E', - new ItemStack(Items.ender_eye)); - recipeForestEye = BotaniaAPI.getLatestAddedRecipe(); - - // Redstone Root Recipe - GameRegistry.addRecipe(new ShapelessOreRecipe( - new ItemStack(ModItems.manaResource, 1, 6), "dustRedstone", new ItemStack(Blocks.tallgrass, 1, 1))); - recipeRedstoneRoot = BotaniaAPI.getLatestAddedRecipe(); - - // Drum of the Wild Recipe - addOreDictRecipe( - new ItemStack(ModBlocks.forestDrum), - "WLW", - "WHW", - "WLW", - 'W', - LibOreDict.LIVING_WOOD, - 'L', - new ItemStack(Items.leather), - 'H', - new ItemStack(ModItems.grassHorn)); - recipeForestDrum = BotaniaAPI.getLatestAddedRecipe(); - - // Ring of Chordata Recipe - addOreDictRecipe( - new ItemStack(ModItems.waterRing), - "WMP", - "M M", - "SM ", - 'W', - LibOreDict.RUNE[0], - 'M', - LibOreDict.MANA_STEEL, - 'P', - new ItemStack(Items.fish, 1, 3), - 'S', - new ItemStack(Items.fish, 1, 1)); - recipeWaterRing = BotaniaAPI.getLatestAddedRecipe(); - - // Ring of the Mantle Recipe - addOreDictRecipe( - new ItemStack(ModItems.miningRing), - "EMP", - "M M", - " M ", - 'E', - LibOreDict.RUNE[2], - 'M', - LibOreDict.MANA_STEEL, - 'P', - new ItemStack(Items.golden_pickaxe)); - recipeMiningRing = BotaniaAPI.getLatestAddedRecipe(); - - // Ring of Magnetization Recipe - addOreDictRecipe( - new ItemStack(ModItems.magnetRing), - "LM ", - "M M", - " M ", - 'L', - new ItemStack(ModItems.lens, 1, 10), - 'M', - LibOreDict.MANA_STEEL); - recipeMagnetRing = BotaniaAPI.getLatestAddedRecipe(); - - // Terra Shatterer Recipe - addOreDictRecipe( - new ItemStack(ModItems.terraPick), - "ITI", - "ILI", - " L ", - 'T', - new ItemStack(ModItems.manaTablet, 1, Short.MAX_VALUE), - 'I', - LibOreDict.TERRA_STEEL, - 'L', - LibOreDict.LIVINGWOOD_TWIG); - recipeTerraPick = BotaniaAPI.getLatestAddedRecipe(); - - // Charm of the Diva Recipe - addOreDictRecipe( - new ItemStack(ModItems.divaCharm), - "LGP", - " HG", - " GL", - 'L', - LibOreDict.LIFE_ESSENCE, - 'G', - "ingotGold", - 'H', - LibOreDict.RUNE[15], - 'P', - new ItemStack(ModItems.tinyPlanet)); - recipeDivaCharm = BotaniaAPI.getLatestAddedRecipe(); - - // Flugel Tiara Recipe - addOreDictRecipe( - new ItemStack(ModItems.flightTiara), - "LLL", - "ILI", - "FEF", - 'L', - LibOreDict.LIFE_ESSENCE, - 'I', - LibOreDict.ELEMENTIUM, - 'F', - new ItemStack(Items.feather), - 'E', - LibOreDict.ENDER_AIR_BOTTLE); - recipeFlightTiara = BotaniaAPI.getLatestAddedRecipe(); - - // Glimmering Flowers Recipes - for (int i = 0; i < 16; i++) - addShapelessOreDictRecipe( - new ItemStack(ModBlocks.shinyFlower, 1, i), "dustGlowstone", "dustGlowstone", LibOreDict.FLOWER[i]); - recipesShinyFlowers = BotaniaAPI.getLatestAddedRecipes(16); - - // Abstruse Platform Recipe - addOreDictRecipe( - new ItemStack(ModBlocks.platform, 2), - "343", - "0P0", - '0', - new ItemStack(ModBlocks.livingwood, 1, 0), - '3', - new ItemStack(ModBlocks.livingwood, 1, 3), - '4', - new ItemStack(ModBlocks.livingwood, 1, 4), - 'P', - LibOreDict.MANA_PEARL); - recipePlatform = BotaniaAPI.getLatestAddedRecipe(); - - // Soulscribe Recipe - addOreDictRecipe( - new ItemStack(ModItems.enderDagger), - "P", - "S", - "T", - 'P', - LibOreDict.MANA_PEARL, - 'S', - LibOreDict.MANA_STEEL, - 'T', - LibOreDict.LIVINGWOOD_TWIG); - recipeEnderDagger = BotaniaAPI.getLatestAddedRecipe(); - - // Quartz Recipes - if (ConfigHandler.darkQuartzEnabled) - recipeDarkQuartz = addQuartzRecipes( - 0, - Items.coal, - ModFluffBlocks.darkQuartz, - ModFluffBlocks.darkQuartzStairs, - ModFluffBlocks.darkQuartzSlab); - addQuartzRecipes( - 1, null, ModFluffBlocks.manaQuartz, ModFluffBlocks.manaQuartzStairs, ModFluffBlocks.manaQuartzSlab); - recipeBlazeQuartz = addQuartzRecipes( - 2, - Items.blaze_powder, - ModFluffBlocks.blazeQuartz, - ModFluffBlocks.blazeQuartzStairs, - ModFluffBlocks.blazeQuartzSlab); - - GameRegistry.addRecipe(new ShapedOreRecipe( - new ItemStack(ModItems.quartz, 8, 3), - "QQQ", - "QCQ", - "QQQ", - 'Q', - "gemQuartz", - 'C', - new ItemStack(Blocks.red_flower, 1, 2))); - GameRegistry.addRecipe(new ShapedOreRecipe( - new ItemStack(ModItems.quartz, 8, 3), - "QQQ", - "QCQ", - "QQQ", - 'Q', - "gemQuartz", - 'C', - new ItemStack(Blocks.red_flower, 1, 7))); - GameRegistry.addRecipe(new ShapedOreRecipe( - new ItemStack(ModItems.quartz, 8, 3), - "QQQ", - "QCQ", - "QQQ", - 'Q', - "gemQuartz", - 'C', - new ItemStack(Blocks.double_plant, 1, 1))); - GameRegistry.addRecipe(new ShapedOreRecipe( - new ItemStack(ModItems.quartz, 8, 3), - "QQQ", - "QCQ", - "QQQ", - 'Q', - "gemQuartz", - 'C', - new ItemStack(Blocks.double_plant, 1, 5))); - recipesLavenderQuartz = BotaniaAPI.getLatestAddedRecipes(4); - addQuartzRecipes( - 3, - null, - ModFluffBlocks.lavenderQuartz, - ModFluffBlocks.lavenderQuartzStairs, - ModFluffBlocks.lavenderQuartzSlab); - - recipeRedQuartz = addQuartzRecipes( - 4, - Items.redstone, - ModFluffBlocks.redQuartz, - ModFluffBlocks.redQuartzStairs, - ModFluffBlocks.redQuartzSlab); - addQuartzRecipes( - 5, null, ModFluffBlocks.elfQuartz, ModFluffBlocks.elfQuartzStairs, ModFluffBlocks.elfQuartzSlab); - - recipeSunnyQuartz = addQuartzRecipes( - 6, - Item.getItemFromBlock(Blocks.double_plant), - ModFluffBlocks.sunnyQuartz, - ModFluffBlocks.sunnyQuartzStairs, - ModFluffBlocks.sunnyQuartzSlab); - - // Alfheim Portal Recipe - addOreDictRecipe( - new ItemStack(ModBlocks.alfPortal), - "WTW", - "WTW", - "WTW", - 'W', - LibOreDict.LIVING_WOOD, - 'T', - LibOreDict.TERRASTEEL_NUGGET); - recipeAlfPortal = BotaniaAPI.getLatestAddedRecipe(); - - // Natura Pylon Recipe - addOreDictRecipe( - new ItemStack(ModBlocks.pylon, 1, 1), - " T ", - "TPT", - " E ", - 'T', - LibOreDict.TERRASTEEL_NUGGET, - 'P', - new ItemStack(ModBlocks.pylon), - 'E', - new ItemStack(Items.ender_eye)); - recipeNaturaPylon = BotaniaAPI.getLatestAddedRecipe(); - - // Rod of the Seas Recipe - addOreDictRecipe( - new ItemStack(ModItems.waterRod), - " B", - " T ", - "R ", - 'B', - new ItemStack(Items.potionitem), - 'T', - LibOreDict.LIVINGWOOD_TWIG, - 'R', - LibOreDict.RUNE[0]); - recipeWaterRod = BotaniaAPI.getLatestAddedRecipe(); - - // Elementium Armor & Tools Recipes - addOreDictRecipe(new ItemStack(ModItems.elementiumHelm), "SSS", "S S", 'S', LibOreDict.ELEMENTIUM); - recipeElementiumHelm = BotaniaAPI.getLatestAddedRecipe(); - addOreDictRecipe(new ItemStack(ModItems.elementiumChest), "S S", "SSS", "SSS", 'S', LibOreDict.ELEMENTIUM); - recipeElementiumChest = BotaniaAPI.getLatestAddedRecipe(); - addOreDictRecipe(new ItemStack(ModItems.elementiumLegs), "SSS", "S S", "S S", 'S', LibOreDict.ELEMENTIUM); - recipeElementiumLegs = BotaniaAPI.getLatestAddedRecipe(); - addOreDictRecipe(new ItemStack(ModItems.elementiumBoots), "S S", "S S", 'S', LibOreDict.ELEMENTIUM); - recipeElementiumBoots = BotaniaAPI.getLatestAddedRecipe(); - addOreDictRecipe( - new ItemStack(ModItems.elementiumPick), - "SSS", - " T ", - " T ", - 'S', - LibOreDict.ELEMENTIUM, - 'T', - LibOreDict.DREAMWOOD_TWIG); - recipeElementiumPick = BotaniaAPI.getLatestAddedRecipe(); - addOreDictRecipe( - new ItemStack(ModItems.elementiumShovel), - "S", - "T", - "T", - 'S', - LibOreDict.ELEMENTIUM, - 'T', - LibOreDict.DREAMWOOD_TWIG); - recipeElementiumShovel = BotaniaAPI.getLatestAddedRecipe(); - addOreDictRecipe( - new ItemStack(ModItems.elementiumAxe), - "SS", - "TS", - "T ", - 'S', - LibOreDict.ELEMENTIUM, - 'T', - LibOreDict.DREAMWOOD_TWIG); - recipeElementiumAxe = BotaniaAPI.getLatestAddedRecipe(); - addOreDictRecipe( - new ItemStack(ModItems.elementiumSword), - "S", - "S", - "T", - 'S', - LibOreDict.ELEMENTIUM, - 'T', - LibOreDict.DREAMWOOD_TWIG); - recipeElementiumSword = BotaniaAPI.getLatestAddedRecipe(); - addOreDictRecipe(new ItemStack(ModItems.elementiumShears), "S ", " S", 'S', LibOreDict.ELEMENTIUM); - recipeElementiumShears = BotaniaAPI.getLatestAddedRecipe(); - - // Extrapolated Bucket Recipe - addOreDictRecipe(new ItemStack(ModItems.openBucket), "E E", " E ", 'E', LibOreDict.ELEMENTIUM); - recipeOpenBucket = BotaniaAPI.getLatestAddedRecipe(); - - // Conjuration Catalyst Recipe - addOreDictRecipe( - new ItemStack(ModBlocks.conjurationCatalyst), - "SBS", - "GPG", - "SGS", - 'S', - LibOreDict.LIVING_ROCK, - 'G', - LibOreDict.ELEMENTIUM, - 'B', - LibOreDict.PIXIE_DUST, - 'P', - new ItemStack(ModBlocks.alchemyCatalyst)); - recipeConjurationCatalyst = BotaniaAPI.getLatestAddedRecipe(); - - // Life Aggregator Recipe - addOreDictRecipe( - new ItemStack(ModItems.spawnerMover), - "EIE", - "ADA", - "EIE", - 'E', - LibOreDict.LIFE_ESSENCE, - 'I', - LibOreDict.ELEMENTIUM, - 'A', - LibOreDict.ENDER_AIR_BOTTLE, - 'D', - LibOreDict.DRAGONSTONE); - recipeSpawnerMover = BotaniaAPI.getLatestAddedRecipe(); - - // Great Fairy Ring Recipe - addOreDictRecipe( - new ItemStack(ModItems.pixieRing), - "DE ", - "E E", - " E ", - 'D', - LibOreDict.PIXIE_DUST, - 'E', - LibOreDict.ELEMENTIUM); - recipePixieRing = BotaniaAPI.getLatestAddedRecipe(); - - // Globetrotter's Sash Recipe - addOreDictRecipe( - new ItemStack(ModItems.superTravelBelt), - "E ", - " S ", - "L E", - 'E', - LibOreDict.ELEMENTIUM, - 'L', - LibOreDict.LIFE_ESSENCE, - 'S', - new ItemStack(ModItems.travelBelt)); - recipeSuperTravelBelt = BotaniaAPI.getLatestAddedRecipe(); - - // Rod of Bifrost Recipe - addOreDictRecipe( - new ItemStack(ModItems.rainbowRod), - " PD", - " EP", - "E ", - 'P', - LibOreDict.PIXIE_DUST, - 'E', - LibOreDict.ELEMENTIUM, - 'D', - LibOreDict.DRAGONSTONE); - recipeRainbowRod = BotaniaAPI.getLatestAddedRecipe(); - - // Spectral Platform Recipe - addOreDictRecipe( - new ItemStack(ModBlocks.platform, 2, 1), - "343", - "0D0", - '0', - new ItemStack(ModBlocks.dreamwood, 1, 0), - '3', - new ItemStack(ModBlocks.dreamwood, 1, 3), - '4', - new ItemStack(ModBlocks.dreamwood, 1, 4), - 'D', - LibOreDict.PIXIE_DUST); - recipeSpectralPlatform = BotaniaAPI.getLatestAddedRecipe(); - - // Elven Mana Spreader Recipes - for (int i = 0; i < 16; i++) - addOreDictRecipe( - new ItemStack(ModBlocks.spreader, 1, 2), - "WWW", - "EP ", - "WWW", - 'W', - LibOreDict.DREAM_WOOD, - 'P', - LibOreDict.PETAL[i], - 'E', - LibOreDict.ELEMENTIUM); - recipesDreamwoodSpreader = BotaniaAPI.getLatestAddedRecipes(16); - - // Rod of the Skies Recipe - addOreDictRecipe( - new ItemStack(ModItems.tornadoRod), - " F", - " T ", - "R ", - 'F', - new ItemStack(Items.feather), - 'T', - LibOreDict.LIVINGWOOD_TWIG, - 'R', - LibOreDict.RUNE[3]); - recipeTornadoRod = BotaniaAPI.getLatestAddedRecipe(); - - // Rod of the Hells Recipe - addOreDictRecipe( - new ItemStack(ModItems.fireRod), - " F", - " T ", - "R ", - 'F', - new ItemStack(Items.blaze_powder), - 'T', - LibOreDict.LIVINGWOOD_TWIG, - 'R', - LibOreDict.RUNE[1]); - recipeFireRod = BotaniaAPI.getLatestAddedRecipe(); - - // Vine Ball Recipe - addOreDictRecipe(new ItemStack(ModItems.vineBall), "VVV", "VVV", "VVV", 'V', new ItemStack(Blocks.vine)); - recipeVineBall = BotaniaAPI.getLatestAddedRecipe(); - - // Livingwood Slingshot Recipe - addOreDictRecipe( - new ItemStack(ModItems.slingshot), - " TA", - " TT", - "T ", - 'T', - LibOreDict.LIVINGWOOD_TWIG, - 'A', - LibOreDict.RUNE[3]); - recipeSlingshot = BotaniaAPI.getLatestAddedRecipe(); - - // Moss Stone Recipe - addShapelessOreDictRecipe( - new ItemStack(Blocks.mossy_cobblestone), "cobblestone", new ItemStack(ModItems.vineBall)); - recipeMossStone = BotaniaAPI.getLatestAddedRecipe(); - - // Prismarine Recipe - addOreDictRecipe( - new ItemStack(ModBlocks.prismarine, 1, 0), - " S ", - "SBS", - " S ", - 'S', - LibOreDict.PRISMARINE_SHARD, - 'B', - "cobblestone"); - recipePrismarine = BotaniaAPI.getLatestAddedRecipe(); - - // Prismarine Brick Recipe - addOreDictRecipe( - new ItemStack(ModBlocks.prismarine, 1, 1), - " S ", - "SBS", - " S ", - 'S', - LibOreDict.PRISMARINE_SHARD, - 'B', - new ItemStack(Blocks.stonebrick)); - recipePrismarineBrick = BotaniaAPI.getLatestAddedRecipe(); - - // Dark Prismarine Recipe - addOreDictRecipe( - new ItemStack(ModBlocks.prismarine, 1, 2), - " S ", - "SBS", - " S ", - 'S', - LibOreDict.PRISMARINE_SHARD, - 'B', - new ItemStack(Blocks.nether_brick)); - recipeDarkPrismarine = BotaniaAPI.getLatestAddedRecipe(); - - // Sea Lantern Recipe - addOreDictRecipe( - new ItemStack(ModBlocks.seaLamp), - " S ", - "SBS", - " S ", - 'S', - LibOreDict.PRISMARINE_SHARD, - 'B', - "glowstone"); - recipeSeaLamp = BotaniaAPI.getLatestAddedRecipe(); - - // Influence Lens Recipe - addOreDictRecipe( - new ItemStack(ModItems.lens, 1, 12), - "PRP", - "PLP", - "PPP", - 'P', - LibOreDict.PRISMARINE_SHARD, - 'R', - LibOreDict.RUNE[3], - 'L', - new ItemStack(ModItems.lens)); - recipeLensInfluence = BotaniaAPI.getLatestAddedRecipe(); - - // Weight Lens Recipe - addOreDictRecipe( - new ItemStack(ModItems.lens, 1, 13), - "PPP", - "PLP", - "PRP", - 'P', - LibOreDict.PRISMARINE_SHARD, - 'R', - LibOreDict.RUNE[0], - 'L', - new ItemStack(ModItems.lens)); - recipeLensWeight = BotaniaAPI.getLatestAddedRecipe(); - - // Paintslinger Lens Recipe - addOreDictRecipe( - new ItemStack(ModItems.lens, 1, 14), - " E ", - "WLW", - " E ", - 'E', - LibOreDict.ELEMENTIUM, - 'W', - new ItemStack(Blocks.wool, 1, Short.MAX_VALUE), - 'L', - new ItemStack(ModItems.lens)); - recipeLensPaint = BotaniaAPI.getLatestAddedRecipe(); - - // Warp Lens Recipe - addShapelessOreDictRecipe( - new ItemStack(ModItems.lens, 1, 18), new ItemStack(ModItems.lens), LibOreDict.PIXIE_DUST); - recipeLensWarp = BotaniaAPI.getLatestAddedRecipe(); - - // Redirective Lens Recipe - addShapelessOreDictRecipe( - new ItemStack(ModItems.lens, 1, 19), - new ItemStack(ModItems.lens), - LibOreDict.LIVING_WOOD, - LibOreDict.ELEMENTIUM); - recipeLensRedirect = BotaniaAPI.getLatestAddedRecipe(); - - // Celebratory Lens Recipe - addShapelessOreDictRecipe( - new ItemStack(ModItems.lens, 1, 20), - new ItemStack(ModItems.lens), - new ItemStack(Items.fireworks), - LibOreDict.ELEMENTIUM); - recipeLensFirework = BotaniaAPI.getLatestAddedRecipe(); - - // Flare Lens Recipe - addShapelessOreDictRecipe( - new ItemStack(ModItems.lens, 1, 21), - new ItemStack(ModItems.lens), - new ItemStack(ModBlocks.elfGlass), - LibOreDict.ELEMENTIUM); - recipeLensFlare = BotaniaAPI.getLatestAddedRecipe(); - - // Mini Island Recipes - for (int i = 0; i < 16; i++) - GameRegistry.addRecipe( - new ItemStack(ModBlocks.floatingFlower, 1, i), - "F", - "S", - "D", - 'F', - new ItemStack(ModBlocks.shinyFlower, 1, i), - 'S', - new ItemStack(ModItems.grassSeeds), - 'D', - new ItemStack(Blocks.dirt)); - recipesMiniIsland = BotaniaAPI.getLatestAddedRecipes(16); - - // Gaia Pylon Recipe - addOreDictRecipe( - new ItemStack(ModBlocks.pylon, 1, 2), - " D ", - "EPE", - " D ", - 'D', - LibOreDict.PIXIE_DUST, - 'E', - LibOreDict.ELEMENTIUM, - 'P', - new ItemStack(ModBlocks.pylon)); - recipeGaiaPylon = BotaniaAPI.getLatestAddedRecipe(); - - // Drum of the Gathering Recipe - addOreDictRecipe( - new ItemStack(ModBlocks.forestDrum, 1, 1), - "WLW", - "WEW", - "WLW", - 'W', - LibOreDict.DREAM_WOOD, - 'L', - new ItemStack(Items.leather), - 'E', - LibOreDict.ELEMENTIUM); - recipeGatherDrum = BotaniaAPI.getLatestAddedRecipe(); - - // Mana Lens: Kindle Recipe - addShapelessOreDictRecipe( - new ItemStack(ModItems.lens, 1, 15), new ItemStack(ModItems.lens), new ItemStack(Items.fire_charge)); - recipeLensFire = BotaniaAPI.getLatestAddedRecipe(); - - // Mana Lens: Piston Recipe - addShapelessOreDictRecipe( - new ItemStack(ModItems.lens, 1, 16), - new ItemStack(ModItems.lens), - new ItemStack(ModBlocks.pistonRelay)); - recipeLensPiston = BotaniaAPI.getLatestAddedRecipe(); - - // Shard of Laputa Recipe - for (int i = 0; i < 16; i++) - addOreDictRecipe( - new ItemStack(ModItems.laputaShard), - "SFS", - "PDP", - "ASE", - 'S', - LibOreDict.LIFE_ESSENCE, - 'D', - LibOreDict.DRAGONSTONE, - 'F', - new ItemStack(ModBlocks.floatingFlower, 1, i), - 'P', - LibOreDict.PRISMARINE_SHARD, - 'A', - LibOreDict.RUNE[3], - 'E', - LibOreDict.RUNE[2]); - recipesLaputaShard = BotaniaAPI.getLatestAddedRecipes(16); - - for (int i = 1; i < 20; i++) - addShapelessOreDictRecipe( - new ItemStack(ModItems.laputaShard, 1, i), - LibOreDict.LIFE_ESSENCE, - new ItemStack(ModItems.laputaShard, 1, i - 1)); - recipesLaputaShardUpgrade = BotaniaAPI.getLatestAddedRecipes(19); - - // Necrodermal Virus Recipe - addShapelessOreDictRecipe( - new ItemStack(ModItems.virus), - LibOreDict.PIXIE_DUST, - new ItemStack(ModItems.vineBall), - new ItemStack(Items.magma_cream), - new ItemStack(Items.fermented_spider_eye), - new ItemStack(Items.ender_eye), - new ItemStack(Items.skull, 1, 2)); - recipeVirusZombie = BotaniaAPI.getLatestAddedRecipe(); - - // Nullodermal Virus Recipe - addShapelessOreDictRecipe( - new ItemStack(ModItems.virus, 1, 1), - LibOreDict.PIXIE_DUST, - new ItemStack(ModItems.vineBall), - new ItemStack(Items.magma_cream), - new ItemStack(Items.fermented_spider_eye), - new ItemStack(Items.ender_eye), - new ItemStack(Items.skull)); - recipeVirusSkeleton = BotaniaAPI.getLatestAddedRecipe(); - - // Ring of Far Reach Recipe - addOreDictRecipe( - new ItemStack(ModItems.reachRing), - "RE ", - "E E", - " E ", - 'R', - LibOreDict.RUNE[15], - 'E', - LibOreDict.ELEMENTIUM); - recipeReachRing = BotaniaAPI.getLatestAddedRecipe(); - - // Rod of the Highlands Recipe - addShapelessOreDictRecipe( - new ItemStack(ModItems.skyDirtRod), - new ItemStack(ModItems.dirtRod), - LibOreDict.PIXIE_DUST, - LibOreDict.RUNE[3]); - recipeSkyDirtRod = BotaniaAPI.getLatestAddedRecipe(); - - // Life Imbuer Recipe - addOreDictRecipe( - new ItemStack(ModBlocks.spawnerClaw), - "BSB", - "PMP", - "PEP", - 'B', - new ItemStack(Items.blaze_rod), - 'S', - LibOreDict.ELEMENTIUM, - 'P', - new ItemStack(ModBlocks.prismarine, 1, 2), - 'M', - new ItemStack(ModBlocks.storage), - 'E', - LibOreDict.ENDER_AIR_BOTTLE); - recipeSpawnerClaw = BotaniaAPI.getLatestAddedRecipe(); - - // Crafty Crate Recipe - GameRegistry.addRecipe(new ShapedOreRecipe( - new ItemStack(ModBlocks.openCrate, 1, 1), - "WCW", - "W W", - "W W", - 'C', - "craftingTableWood", - 'W', - new ItemStack(ModBlocks.dreamwood, 1, 1))); - recipeCraftCrate = BotaniaAPI.getLatestAddedRecipe(); - - // Crafting Placeholder Recipe - addShapelessOreDictRecipe( - new ItemStack(ModItems.manaResource, 32, 11), "craftingTableWood", LibOreDict.LIVING_ROCK); - recipePlaceholder = BotaniaAPI.getLatestAddedRecipe(); - - // Reed Block Recipe - GameRegistry.addRecipe( - new ItemStack(ModBlocks.reedBlock), "rrr", "rrr", "rrr", 'r', new ItemStack(Items.reeds)); - recipeReedBlock = BotaniaAPI.getLatestAddedRecipe(); - - // Thatch Recipe - GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(ModBlocks.thatch), "ww", "ww", 'w', "cropWheat")); - recipeThatch = BotaniaAPI.getLatestAddedRecipe(); - - // Nether Brick Recipe - GameRegistry.addRecipe( - new ItemStack(ModBlocks.customBrick, 4, 0), - " B ", - "BSB", - " B ", - 'B', - new ItemStack(Blocks.netherrack), - 'S', - new ItemStack(Blocks.stonebrick)); - recipeNetherBrick = BotaniaAPI.getLatestAddedRecipe(); - - // Soul Brick Recipe - GameRegistry.addRecipe( - new ItemStack(ModBlocks.customBrick, 4, 1), - " B ", - "BSB", - " B ", - 'B', - new ItemStack(Blocks.soul_sand), - 'S', - new ItemStack(Blocks.stonebrick)); - recipeSoulBrick = BotaniaAPI.getLatestAddedRecipe(); - - // Snow Brick Recipe - GameRegistry.addRecipe( - new ItemStack(ModBlocks.customBrick, 4, 2), - " B ", - "BSB", - " B ", - 'B', - new ItemStack(Blocks.snow), - 'S', - new ItemStack(Blocks.stonebrick)); - recipeSnowBrick = BotaniaAPI.getLatestAddedRecipe(); - - // Roof Tile Recipe - GameRegistry.addRecipe( - new ShapedOreRecipe(new ItemStack(ModBlocks.customBrick, 4, 3), "BB", "BB", "BB", 'B', "ingotBrick")); - recipeRoofTile = BotaniaAPI.getLatestAddedRecipe(); - - // Azulejo Recipe - GameRegistry.addRecipe( - new ShapelessOreRecipe(new ItemStack(ModBlocks.customBrick, 1, 4), "gemLapis", "blockQuartz")); - recipeAzulejo = BotaniaAPI.getLatestAddedRecipe(); - - // Azulejo Cycling Recipes - for (int i = 0; i < 12; i++) - GameRegistry.addShapelessRecipe( - new ItemStack(ModBlocks.customBrick, 1, 4 + (i == 11 ? 0 : i + 1)), - new ItemStack(ModBlocks.customBrick, 1, 4 + i)); - recipesAzulejoCycling = BotaniaAPI.getLatestAddedRecipes(12); - - // Ender Overseer Recipe - GameRegistry.addRecipe(new ShapedOreRecipe( - new ItemStack(ModBlocks.enderEye), - "RER", - "EOE", - "RER", - 'R', - "dustRedstone", - 'E', - new ItemStack(Items.ender_eye), - 'O', - new ItemStack(Blocks.obsidian))); - recipeEnderEyeBlock = BotaniaAPI.getLatestAddedRecipe(); - - // The Spectator Recipe - addOreDictRecipe( - new ItemStack(ModItems.itemFinder), - " I ", - "IYI", - "IEI", - 'I', - "ingotIron", - 'Y', - new ItemStack(Items.ender_eye), - 'E', - "gemEmerald"); - recipeItemFinder = BotaniaAPI.getLatestAddedRecipe(); - - // Crimson Pendant Recipe - addOreDictRecipe( - new ItemStack(ModItems.superLavaPendant), - "BBB", - "BPB", - "NGN", - 'B', - new ItemStack(Items.blaze_rod), - 'P', - new ItemStack(ModItems.lavaPendant), - 'N', - new ItemStack(Blocks.nether_brick), - 'G', - LibOreDict.LIFE_ESSENCE); - recipeSuperLavaPendant = BotaniaAPI.getLatestAddedRecipe(); - - // Hand of Ender Recipe - addOreDictRecipe( - new ItemStack(ModItems.enderHand), - "PLO", - "LEL", - "OL ", - 'P', - LibOreDict.MANA_PEARL, - 'L', - new ItemStack(Items.leather), - 'E', - new ItemStack(Blocks.ender_chest), - 'O', - new ItemStack(Blocks.obsidian)); - recipeEnderHand = BotaniaAPI.getLatestAddedRecipe(); - - // Vitreous Pickaxe Recipe - addOreDictRecipe( - new ItemStack(ModItems.glassPick), - "GIG", - " T ", - " T ", - 'G', - "blockGlassColorless", - 'I', - LibOreDict.MANA_STEEL, - 'T', - LibOreDict.LIVINGWOOD_TWIG); - recipeGlassPick = BotaniaAPI.getLatestAddedRecipe(); - - // Starfield Creator Recipe - addOreDictRecipe( - new ItemStack(ModBlocks.starfield), - "EPE", - "EOE", - 'E', - LibOreDict.ELEMENTIUM, - 'P', - LibOreDict.PIXIE_DUST, - 'O', - new ItemStack(Blocks.obsidian)); - recipeStarfield = BotaniaAPI.getLatestAddedRecipe(); - - // Spark Recipe - for (int i = 0; i < 16; i++) - addOreDictRecipe( - new ItemStack(ModItems.spark), - " P ", - "BNB", - " P ", - 'B', - new ItemStack(Items.blaze_powder), - 'P', - LibOreDict.PETAL[i], - 'N', - "nuggetGold"); - recipesSpark = BotaniaAPI.getLatestAddedRecipes(16); - - // Spark Augment Recipes - for (int i = 0; i < 4; i++) - addShapelessOreDictRecipe( - new ItemStack(ModItems.sparkUpgrade, 1, i), - LibOreDict.PIXIE_DUST, - LibOreDict.MANA_STEEL, - LibOreDict.RUNE[i]); - recipesSparkUpgrades = BotaniaAPI.getLatestAddedRecipes(4); - - // Horn of the Canopy Recipe - addShapelessOreDictRecipe( - new ItemStack(ModItems.grassHorn, 1, 1), new ItemStack(ModItems.grassHorn), "treeLeaves"); - recipeLeafHorn = BotaniaAPI.getLatestAddedRecipe(); - - // Rod of Divining Recipe - addOreDictRecipe( - new ItemStack(ModItems.diviningRod), - " TD", - " TT", - "T ", - 'T', - LibOreDict.LIVINGWOOD_TWIG, - 'D', - LibOreDict.MANA_DIAMOND); - recipeDiviningRod = BotaniaAPI.getLatestAddedRecipe(); - - // Rod of the Black Mesa Recipe - addOreDictRecipe( - new ItemStack(ModItems.gravityRod), - " TD", - " WT", - "T ", - 'T', - LibOreDict.DREAMWOOD_TWIG, - 'W', - "cropWheat", - 'D', - LibOreDict.DRAGONSTONE); - recipeGravityRod = BotaniaAPI.getLatestAddedRecipe(); - - // Timeless Ivy Recipe - addShapelessOreDictRecipe( - new ItemStack(ModItems.regenIvy), - new ItemStack(Blocks.vine), - LibOreDict.LIFE_ESSENCE, - LibOreDict.ELEMENTIUM); - recipeRegenIvy = BotaniaAPI.getLatestAddedRecipe(); - - // Gaia Mana Spreader Recipe - addOreDictRecipe( - new ItemStack(ModBlocks.spreader, 1, 3), - "ESD", - 'E', - LibOreDict.LIFE_ESSENCE, - 'S', - new ItemStack(ModBlocks.spreader, 1, 2), - 'D', - LibOreDict.DRAGONSTONE); - recipeUltraSpreader = BotaniaAPI.getLatestAddedRecipe(); - - // Wing Recipes - GameRegistry.addRecipe(new ShapelessOreRecipe( - new ItemStack(ModItems.flightTiara, 1, 1), - new ItemStack(ModItems.flightTiara, 1, Short.MAX_VALUE), - "gemQuartz")); - for (int i = 0; i < 7; i++) - GameRegistry.addRecipe(new ShapelessOreRecipe( - new ItemStack(ModItems.flightTiara, 1, 2 + i), - new ItemStack(ModItems.flightTiara, 1, Short.MAX_VALUE), - LibOreDict.QUARTZ[i])); - recipesWings = BotaniaAPI.getLatestAddedRecipes(8); - - // Mana Fluxfield Recipe - if (ConfigHandler.fluxfieldEnabled) { - addOreDictRecipe( - new ItemStack(ModBlocks.rfGenerator), - "SRS", - "RMR", - "SRS", - 'S', - LibOreDict.LIVING_ROCK, - 'M', - LibOreDict.MANA_STEEL, - 'R', - "blockRedstone"); - recipeRFGenerator = BotaniaAPI.getLatestAddedRecipe(); - } - - // Vial Recipe - GameRegistry.addRecipe( - new ItemStack(ModItems.vial, 3, 0), "G G", " G ", 'G', new ItemStack(ModBlocks.manaGlass)); - recipeVial = BotaniaAPI.getLatestAddedRecipe(); - - // Flask Recipe - GameRegistry.addRecipe( - new ItemStack(ModItems.vial, 3, 1), "G G", " G ", 'G', new ItemStack(ModBlocks.elfGlass)); - recipeFlask = BotaniaAPI.getLatestAddedRecipe(); - - // Botanical Brewery Recipe - addOreDictRecipe( - new ItemStack(ModBlocks.brewery), - "RSR", - "RAR", - "RMR", - 'R', - LibOreDict.LIVING_ROCK, - 'S', - new ItemStack(Items.brewing_stand), - 'A', - LibOreDict.RUNE[8], - 'M', - new ItemStack(ModBlocks.storage)); - recipeBrewery = BotaniaAPI.getLatestAddedRecipe(); - - // Tainted Blood Pendant Recipe - addOreDictRecipe( - new ItemStack(ModItems.bloodPendant), - " P ", - "PGP", - "DP ", - 'P', - LibOreDict.PRISMARINE_SHARD, - 'G', - new ItemStack(Items.ghast_tear), - 'D', - LibOreDict.MANA_DIAMOND); - recipeBloodPendant = BotaniaAPI.getLatestAddedRecipe(); - - // Terrestrial Agglomeration Plate Recipe - addOreDictRecipe( - new ItemStack(ModBlocks.terraPlate), - "LLL", - "0M1", - "283", - 'L', - "blockLapis", - 'M', - new ItemStack(ModBlocks.storage), - '0', - LibOreDict.RUNE[0], - '1', - LibOreDict.RUNE[1], - '2', - LibOreDict.RUNE[2], - '3', - LibOreDict.RUNE[3], - '8', - LibOreDict.RUNE[8]); - recipeTerraPlate = BotaniaAPI.getLatestAddedRecipe(); - - // Red String Recipe - addShapelessOreDictRecipe( - new ItemStack(ModItems.manaResource, 1, 12), - new ItemStack(Items.string), - "blockRedstone", - LibOreDict.PIXIE_DUST, - LibOreDict.ENDER_AIR_BOTTLE); - recipeRedString = BotaniaAPI.getLatestAddedRecipe(); - // Are you in a pinch? - addShapelessOreDictRecipe( - new ItemStack(ModItems.manaResource, 1, 12), - new ItemStack(Items.string), - "blockRedstone", - LibOreDict.PIXIE_DUST, - LibOreDict.ENDER_AIR_BOTTLE, - new ItemStack(Blocks.pumpkin)); - - // Red String Container Recipe - addOreDictRecipe( - new ItemStack(ModBlocks.redStringContainer), - "RRR", - "RCS", - "RRR", - 'R', - LibOreDict.LIVING_ROCK, - 'S', - LibOreDict.RED_STRING, - 'C', - "chestWood"); - recipeRedStringContainer = BotaniaAPI.getLatestAddedRecipe(); - - // Red String Dispenser Recipe - addOreDictRecipe( - new ItemStack(ModBlocks.redStringDispenser), - "RRR", - "RDS", - "RRR", - 'R', - LibOreDict.LIVING_ROCK, - 'S', - LibOreDict.RED_STRING, - 'D', - new ItemStack(Blocks.dispenser)); - recipeRedStringDispenser = BotaniaAPI.getLatestAddedRecipe(); - - // Red String Fertilizer Recipe - addOreDictRecipe( - new ItemStack(ModBlocks.redStringFertilizer), - "RRR", - "RBS", - "RRR", - 'R', - LibOreDict.LIVING_ROCK, - 'S', - LibOreDict.RED_STRING, - 'B', - new ItemStack(ModItems.fertilizer)); - recipeRedStringFertilizer = BotaniaAPI.getLatestAddedRecipe(); - - // Red String Comparator Recipe - addOreDictRecipe( - new ItemStack(ModBlocks.redStringComparator), - "RRR", - "RCS", - "RRR", - 'R', - LibOreDict.LIVING_ROCK, - 'S', - LibOreDict.RED_STRING, - 'C', - new ItemStack(Items.comparator)); - recipeRedStringComparator = BotaniaAPI.getLatestAddedRecipe(); - - // Red String Spoofer Recipe - addOreDictRecipe( - new ItemStack(ModBlocks.redStringRelay), - "RRR", - "RMS", - "RRR", - 'R', - LibOreDict.LIVING_ROCK, - 'S', - LibOreDict.RED_STRING, - 'M', - new ItemStack(ModBlocks.spreader)); - recipeRedStringRelay = BotaniaAPI.getLatestAddedRecipe(); - - // Red String Interceptor Recipe - addOreDictRecipe( - new ItemStack(ModBlocks.redStringInterceptor), - "RRR", - "RMS", - "RRR", - 'R', - LibOreDict.LIVING_ROCK, - 'S', - LibOreDict.RED_STRING, - 'M', - new ItemStack(Blocks.stone_button)); - recipeRedStringInterceptor = BotaniaAPI.getLatestAddedRecipe(); - - // Rod of the Arcane Barrage Recipe - addOreDictRecipe( - new ItemStack(ModItems.missileRod), - "GDD", - " TD", - "T G", - 'G', - LibOreDict.LIFE_ESSENCE, - 'D', - LibOreDict.DRAGONSTONE, - 'T', - LibOreDict.DREAMWOOD_TWIG); - recipeMissileRod = BotaniaAPI.getLatestAddedRecipe(); - - // Cloak of Virtue Recipe - addOreDictRecipe( - new ItemStack(ModItems.holyCloak), - "WWW", - "GWG", - "GSG", - 'W', - new ItemStack(Blocks.wool), - 'G', - "dustGlowstone", - 'S', - LibOreDict.LIFE_ESSENCE); - recipeHolyCloak = BotaniaAPI.getLatestAddedRecipe(); - - // Cloak of Sin Recipe - addOreDictRecipe( - new ItemStack(ModItems.unholyCloak), - "WWW", - "RWR", - "RSR", - 'W', - new ItemStack(Blocks.wool, 1, 15), - 'R', - "dustRedstone", - 'S', - LibOreDict.LIFE_ESSENCE); - recipeUnholyCloak = BotaniaAPI.getLatestAddedRecipe(); - - // Assembly Halo Recipe - addOreDictRecipe( - new ItemStack(ModItems.craftingHalo), - " P ", - "ICI", - " I ", - 'P', - LibOreDict.MANA_PEARL, - 'I', - LibOreDict.MANA_STEEL, - 'C', - "craftingTableWood"); - recipeCraftingHalo = BotaniaAPI.getLatestAddedRecipe(); - - // Mana Lens: Flash Recipe - GameRegistry.addRecipe(new ShapedOreRecipe( - new ItemStack(ModItems.lens, 1, 17), - "GFG", - "FLF", - "GFG", - 'G', - "glowstone", - 'F', - new ItemStack(Items.fire_charge), - 'L', - new ItemStack(ModItems.lens))); - GameRegistry.addRecipe(new ShapedOreRecipe( - new ItemStack(ModItems.lens, 1, 17), - "FGF", - "GLG", - "FGF", - 'G', - "glowstone", - 'F', - new ItemStack(Items.fire_charge), - 'L', - new ItemStack(ModItems.lens))); - recipesLensFlash = BotaniaAPI.getLatestAddedRecipes(2); - - // Mana Prism Recipe - addOreDictRecipe( - new ItemStack(ModBlocks.prism), - "GPG", - "GSG", - "GPG", - 'G', - "blockGlassColorless", - 'P', - LibOreDict.PRISMARINE_SHARD, - 'S', - new ItemStack(ModBlocks.platform, 1, 1)); - recipePrism = BotaniaAPI.getLatestAddedRecipe(); - - // Trodden Dirt Recipe - GameRegistry.addRecipe(new ShapelessOreRecipe( - new ItemStack(ModBlocks.dirtPath, 4), - new ItemStack(Blocks.dirt, 1, 1), - new ItemStack(Blocks.dirt, 1, 1), - new ItemStack(Blocks.dirt, 1, 1), - "sand")); - recipeDirtPath = BotaniaAPI.getLatestAddedRecipe(); - - // Dreamwood Twig Recipe - addOreDictRecipe(new ItemStack(ModItems.manaResource, 1, 13), "W", "W", 'W', LibOreDict.DREAM_WOOD); - recipeDreamwoodTwig = BotaniaAPI.getLatestAddedRecipe(); - - // Manaseer Monocle Recipe - addOreDictRecipe( - new ItemStack(ModItems.monocle), - "GN", - "IN", - " N", - 'G', - new ItemStack(ModBlocks.manaGlass), - 'I', - LibOreDict.MANA_STEEL, - 'N', - new ItemStack(Items.gold_nugget)); - recipeMonocle = BotaniaAPI.getLatestAddedRecipe(); - - // Lens Clip Recipe - addOreDictRecipe(new ItemStack(ModItems.clip), " D ", "D D", "DD ", 'D', LibOreDict.DREAM_WOOD); - recipeClip = BotaniaAPI.getLatestAddedRecipe(); - - // Rod of the Depths Recipe - addOreDictRecipe( - new ItemStack(ModItems.cobbleRod), - " FC", - " TW", - "T ", - 'F', - LibOreDict.RUNE[1], - 'W', - LibOreDict.RUNE[0], - 'T', - LibOreDict.LIVINGWOOD_TWIG, - 'C', - "cobblestone"); - recipeCobbleRod = BotaniaAPI.getLatestAddedRecipe(); - - // Rod of the Molten Core Recipe - addOreDictRecipe( - new ItemStack(ModItems.smeltRod), - " BF", - " TB", - "T ", - 'B', - new ItemStack(Items.blaze_rod), - 'F', - LibOreDict.RUNE[1], - 'T', - LibOreDict.LIVINGWOOD_TWIG); - recipeSmeltRod = BotaniaAPI.getLatestAddedRecipe(); - - // World Seed Recipe - addOreDictRecipe( - new ItemStack(ModItems.worldSeed, 4), - "G", - "S", - "D", - 'G', - new ItemStack(Blocks.grass), - 'S', - new ItemStack(Items.wheat_seeds), - 'D', - LibOreDict.DRAGONSTONE); - recipeWorldSeed = BotaniaAPI.getLatestAddedRecipe(); - - // Spellbinding Cloth Recipe - addOreDictRecipe( - new ItemStack(ModItems.spellCloth), - " C ", - "CPC", - " C ", - 'C', - LibOreDict.MANAWEAVE_CLOTH, - 'P', - LibOreDict.MANA_PEARL); - recipeSpellCloth = BotaniaAPI.getLatestAddedRecipe(); - - // Thorn Chakram Recipe - addOreDictRecipe( - new ItemStack(ModItems.thornChakram, 2), - "VVV", - "VTV", - "VVV", - 'V', - new ItemStack(Blocks.vine), - 'T', - LibOreDict.TERRA_STEEL); - recipeThornChakram = BotaniaAPI.getLatestAddedRecipe(); - - // Trodden Dirt Slab - GameRegistry.addRecipe( - new ItemStack(ModFluffBlocks.dirtPathSlab, 6), "DDD", 'D', new ItemStack(ModBlocks.dirtPath)); - recipeDirtPathSlab = BotaniaAPI.getLatestAddedRecipe(); - - // Pattern Recipes - { - int count = TileCraftCrate.PATTERNS.length; - List recipeObjects = Arrays.asList(new Object[] {'R', "dustRedstone", 'P', LibOreDict.PLACEHOLDER}); - - for (int i = 0; i < count; i++) { - List recipe = new ArrayList(); - for (int j = 0; j < 3; j++) { - String s = ""; - for (int k = 0; k < 3; k++) s += TileCraftCrate.PATTERNS[i][j * 3 + k] ? "R" : "P"; - recipe.add(s); - } - recipe.addAll(recipeObjects); - - addOreDictRecipe(new ItemStack(ModItems.craftPattern, 1, i), recipe.toArray(new Object[recipe.size()])); - } - - recipesPatterns = BotaniaAPI.getLatestAddedRecipes(count); - } - - // Gaia Spirit Ingot Recipe - addOreDictRecipe( - new ItemStack(ModItems.manaResource, 1, 14), - " S ", - "SIS", - " S ", - 'S', - LibOreDict.LIFE_ESSENCE, - 'I', - LibOreDict.TERRA_STEEL); - recipeGaiaIngot = BotaniaAPI.getLatestAddedRecipe(); - - // Corporea Spark Recipe - addShapelessOreDictRecipe( - new ItemStack(ModItems.corporeaSpark), - new ItemStack(ModItems.spark), - LibOreDict.PIXIE_DUST, - LibOreDict.ENDER_AIR_BOTTLE); - recipeCorporeaSpark = BotaniaAPI.getLatestAddedRecipe(); - - // Master Corporea Spark Recipe - addShapelessOreDictRecipe( - new ItemStack(ModItems.corporeaSpark, 1, 1), - new ItemStack(ModItems.corporeaSpark), - LibOreDict.DRAGONSTONE); - recipeMasterCorporeaSpark = BotaniaAPI.getLatestAddedRecipe(); - - // Corporea Index Recipe - addOreDictRecipe( - new ItemStack(ModBlocks.corporeaIndex), - "AOA", - "OSO", - "DOD", - 'A', - LibOreDict.ENDER_AIR_BOTTLE, - 'O', - new ItemStack(Blocks.obsidian), - 'S', - new ItemStack(ModItems.corporeaSpark), - 'D', - LibOreDict.DRAGONSTONE); - recipeCorporeaIndex = BotaniaAPI.getLatestAddedRecipe(); - - // Corporea Funnel Recipe - addShapelessOreDictRecipe( - new ItemStack(ModBlocks.corporeaFunnel), - new ItemStack(Blocks.dropper), - new ItemStack(ModItems.corporeaSpark)); - recipeCorporeaFunnel = BotaniaAPI.getLatestAddedRecipe(); - - // Corporea Interceptor Recipe - addShapelessOreDictRecipe( - new ItemStack(ModBlocks.corporeaInterceptor), "blockRedstone", new ItemStack(ModItems.corporeaSpark)); - recipeCorporeaInterceptor = BotaniaAPI.getLatestAddedRecipe(); - - // End Stone Brick Recipes - if (ConfigHandler.enderStuff19Enabled) { - GameRegistry.addRecipe( - new ItemStack(ModBlocks.endStoneBrick, 4), "SS", "SS", 'S', new ItemStack(Blocks.end_stone)); - recipeEndStoneBricks = BotaniaAPI.getLatestAddedRecipe(); - - GameRegistry.addRecipe( - new ItemStack(ModBlocks.endStoneBrick, 1, 1), - "S", - "S", - 'S', - new ItemStack(ModFluffBlocks.endStoneSlab)); - recipeEndStoneChiseledBricks = BotaniaAPI.getLatestAddedRecipe(); - - GameRegistry.addRecipe( - new ItemStack(ModBlocks.endStoneBrick, 4, 2), - " B ", - "BPB", - " B ", - 'B', - new ItemStack(ModBlocks.endStoneBrick), - 'P', - new ItemStack(Items.ender_pearl)); - recipeEnderBricks = BotaniaAPI.getLatestAddedRecipe(); - - GameRegistry.addRecipe( - new ItemStack(ModBlocks.endStoneBrick, 2, 3), - "B", - "B", - 'B', - new ItemStack(ModBlocks.endStoneBrick, 1, 2)); - recipePillarEnderBricks = BotaniaAPI.getLatestAddedRecipe(); - } - - // Livingwood Bow Recipe - addOreDictRecipe( - new ItemStack(ModItems.livingwoodBow), - " TS", - "T S", - " TS", - 'T', - LibOreDict.LIVINGWOOD_TWIG, - 'S', - LibOreDict.MANA_STRING); - recipeLivingwoodBow = BotaniaAPI.getLatestAddedRecipe(); - - // Crystal Bow Recipe - addOreDictRecipe( - new ItemStack(ModItems.crystalBow), - " DS", - "T S", - " DS", - 'T', - LibOreDict.LIVINGWOOD_TWIG, - 'D', - LibOreDict.DRAGONSTONE, - 'S', - LibOreDict.MANA_STRING); - recipeCrystalBow = BotaniaAPI.getLatestAddedRecipe(); - - // Cosmetic Items Recipes - for (int i = 0; i < 32; i++) - addOreDictRecipe( - new ItemStack(ModItems.cosmetic, 1, i), - "PPP", - "PSP", - "PPP", - 'P', - new ItemStack(i < 16 ? ModItems.petal : ModItems.dye, 1, i % 16), - 'S', - LibOreDict.MANA_STRING); - recipesCosmeticItems = BotaniaAPI.getLatestAddedRecipes(32); - - // Shimmering Mushroom Recipes - for (int i = 0; i < 16; i++) { - GameRegistry.addShapelessRecipe( - new ItemStack(ModBlocks.mushroom, 1, i), - new ItemStack(Blocks.red_mushroom), - new ItemStack(ModItems.dye, 1, i)); - GameRegistry.addShapelessRecipe( - new ItemStack(ModBlocks.mushroom, 1, i), - new ItemStack(Blocks.brown_mushroom), - new ItemStack(ModItems.dye, 1, i)); - } - recipesMushrooms = BotaniaAPI.getLatestAddedRecipes(32); - GameRegistry.addShapelessRecipe( - new ItemStack(Items.mushroom_stew), - new ItemStack(ModBlocks.mushroom, 1, Short.MAX_VALUE), - new ItemStack(ModBlocks.mushroom, 1, Short.MAX_VALUE), - new ItemStack(Items.bowl)); - - // Ring of Correction Recipe - addOreDictRecipe( - new ItemStack(ModItems.swapRing), - "CM ", - "M M", - " M ", - 'C', - new ItemStack(Blocks.clay), - 'M', - LibOreDict.MANA_STEEL); - recipeSwapRing = BotaniaAPI.getLatestAddedRecipe(); - - // Horn of the Covering Recipe - addShapelessOreDictRecipe( - new ItemStack(ModItems.grassHorn, 1, 2), - new ItemStack(ModItems.grassHorn), - new ItemStack(Items.snowball)); - recipeSnowHorn = BotaniaAPI.getLatestAddedRecipe(); - - // Flower Pouch Recipe - GameRegistry.addShapedRecipe( - new ItemStack(ModItems.flowerBag), - "WPW", - "W W", - " W ", - 'P', - new ItemStack(ModItems.petal, 1, Short.MAX_VALUE), - 'W', - new ItemStack(Blocks.wool, 1, Short.MAX_VALUE)); - recipeFlowerBag = BotaniaAPI.getLatestAddedRecipe(); - - // Phantom Ink Recipe - addShapelessOreDictRecipe( - new ItemStack(ModItems.phantomInk, 4), - LibOreDict.MANA_PEARL, - "dye", - "blockGlass", - new ItemStack(Items.glass_bottle), - new ItemStack(Items.glass_bottle), - new ItemStack(Items.glass_bottle), - new ItemStack(Items.glass_bottle)); - recipePhantomInk = BotaniaAPI.getLatestAddedRecipe(); - - // Minecart with Mana Pool Recipe - GameRegistry.addShapelessRecipe( - new ItemStack(ModItems.poolMinecart), new ItemStack(Items.minecart), new ItemStack(ModBlocks.pool)); - recipePoolCart = BotaniaAPI.getLatestAddedRecipe(); - - // Mana Pump Recipe - addOreDictRecipe( - new ItemStack(ModBlocks.pump), - "SSS", - "IBI", - "SSS", - 'S', - LibOreDict.LIVING_ROCK, - 'I', - LibOreDict.MANA_STEEL, - 'B', - new ItemStack(Items.bucket)); - recipePump = BotaniaAPI.getLatestAddedRecipe(); - - // Double Petal Recipes - for (int i = 0; i < 16; i++) - addShapelessOreDictRecipe(new ItemStack(ModItems.petal, 4, i), LibOreDict.DOUBLE_FLOWER[i]); - recipesPetalsDouble = BotaniaAPI.getLatestAddedRecipes(16); - - // Resolute Ivy Recipe - addShapelessOreDictRecipe( - new ItemStack(ModItems.keepIvy), - LibOreDict.PIXIE_DUST, - new ItemStack(Blocks.vine), - LibOreDict.ENDER_AIR_BOTTLE); - recipeKeepIvy = BotaniaAPI.getLatestAddedRecipe(); - - // Black Hole Talisman Recipe - addOreDictRecipe( - new ItemStack(ModItems.blackHoleTalisman), - " G ", - "EAE", - " E ", - 'G', - LibOreDict.LIFE_ESSENCE, - 'E', - LibOreDict.ELEMENTIUM, - 'A', - LibOreDict.ENDER_AIR_BOTTLE); - recipeBlackHoleTalisman = BotaniaAPI.getLatestAddedRecipe(); - - // 1.8 Stone Recipes - recipe18StonePolish = new ArrayList(); - recipe18StoneBrick = new ArrayList(); - recipe18StoneChisel = new ArrayList(); - for (int i = 0; i < 4; i++) { - addOreDictRecipe( - new ItemStack(ModFluffBlocks.stone, 8, i + 4), - "SSS", - "S S", - "SSS", - 'S', - LibOreDict.STONE_18_VARIANTS[i]); - recipe18StonePolish.add(BotaniaAPI.getLatestAddedRecipe()); - - addOreDictRecipe( - new ItemStack(ModFluffBlocks.stone, 4, i + 8), "SS", "SS", 'S', LibOreDict.STONE_18_VARIANTS[i]); - recipe18StoneBrick.add(BotaniaAPI.getLatestAddedRecipe()); - - addOreDictRecipe( - new ItemStack(ModFluffBlocks.stone, 1, i + 12), - "S", - "S", - 'S', - new ItemStack(ModFluffBlocks.stoneSlabs[i + 4], 1, 0)); - recipe18StoneChisel.add(BotaniaAPI.getLatestAddedRecipe()); - } - - // Blaze Light Recipe - addOreDictRecipe( - new ItemStack(ModBlocks.blazeBlock), - "BBB", - "BBB", - "BBB", - 'B', - Botania.gardenOfGlassLoaded ? "powderBlaze" : "rodBlaze"); - recipeBlazeBlock = BotaniaAPI.getLatestAddedRecipe(); - addShapelessOreDictRecipe( - new ItemStack(Botania.gardenOfGlassLoaded ? Items.blaze_powder : Items.blaze_rod, 9), - LibOreDict.BLAZE_BLOCK); - - // Metamorphic Petal Apothecary Recipes - for (int i = 0; i < 8; i++) - GameRegistry.addRecipe( - new ItemStack(ModBlocks.altar, 1, i + 1), - "SSS", - "SAS", - "SSS", - 'S', - new ItemStack(ModFluffBlocks.biomeStoneA, 1, i + 8), - 'A', - new ItemStack(ModBlocks.altar)); - recipesAltarMeta = BotaniaAPI.getLatestAddedRecipes(8); - - // Corporea Crystal Cube Recipe - addOreDictRecipe( - new ItemStack(ModBlocks.corporeaCrystalCube), - "C", - "G", - "W", - 'C', - new ItemStack(ModItems.corporeaSpark), - 'G', - new ItemStack(ModBlocks.elfGlass), - 'W', - LibOreDict.DREAM_WOOD); - recipeCorporeaCrystalCube = BotaniaAPI.getLatestAddedRecipe(); - - // Stone of Temperance Recipe - addOreDictRecipe( - new ItemStack(ModItems.temperanceStone), " S ", "SRS", " S ", 'S', "stone", 'R', LibOreDict.RUNE[2]); - recipeTemperanceStone = BotaniaAPI.getLatestAddedRecipe(); - - // Incense Stick Recipe - addOreDictRecipe( - new ItemStack(ModItems.incenseStick), - " G", - " B ", - "T ", - 'G', - new ItemStack(Items.ghast_tear), - 'B', - new ItemStack(Items.blaze_powder), - 'T', - LibOreDict.LIVINGWOOD_TWIG); - recipeIncenseStick = BotaniaAPI.getLatestAddedRecipe(); - - // Incense Plate Recipe - addOreDictRecipe( - new ItemStack(ModBlocks.incensePlate), - "WSS", - 'W', - LibOreDict.LIVING_WOOD, - 'S', - new ItemStack(ModFluffBlocks.livingwoodSlab)); - recipeIncensePlate = BotaniaAPI.getLatestAddedRecipe(); - - // Terra Truncator Recipe - addOreDictRecipe( - new ItemStack(ModItems.terraAxe), - "TTG", - "TST", - " S ", - 'T', - LibOreDict.TERRA_STEEL, - 'G', - "glowstone", - 'S', - LibOreDict.LIVINGWOOD_TWIG); - recipeTerraAxe = BotaniaAPI.getLatestAddedRecipe(); - - // Hovering Hourglass Recipe - addOreDictRecipe( - new ItemStack(ModBlocks.hourglass), - "GMG", - "RSR", - "GMG", - 'G', - "ingotGold", - 'M', - new ItemStack(ModBlocks.manaGlass), - 'R', - "dustRedstone", - 'S', - LibOreDict.MANA_STEEL); - recipeHourglass = BotaniaAPI.getLatestAddedRecipe(); - - // Spectral Rail Recipe - GameRegistry.addShapelessRecipe( - new ItemStack(ModBlocks.ghostRail), - new ItemStack(Blocks.rail), - new ItemStack(ModBlocks.platform, 1, 1)); - recipeGhostRail = BotaniaAPI.getLatestAddedRecipe(); - - // Drum of the Canopy Recipe - addOreDictRecipe( - new ItemStack(ModBlocks.forestDrum, 1, 2), - "WLW", - "WHW", - "WLW", - 'W', - LibOreDict.LIVING_WOOD, - 'L', - new ItemStack(Items.leather), - 'H', - new ItemStack(ModItems.grassHorn, 1, 1)); - recipeCanopyDrum = BotaniaAPI.getLatestAddedRecipe(); - - // Spark Changer Recipe - addOreDictRecipe( - new ItemStack(ModBlocks.sparkChanger), - "ESE", - "SRS", - 'S', - LibOreDict.LIVING_ROCK, - 'E', - LibOreDict.ELEMENTIUM, - 'R', - "dustRedstone"); - recipeSparkChanger = BotaniaAPI.getLatestAddedRecipe(); - - // Cocoon of Caprice Recipe - if (Botania.gardenOfGlassLoaded) - addOreDictRecipe( - new ItemStack(ModBlocks.cocoon), - "SSS", - "SFS", - "SIS", - 'S', - new ItemStack(Items.string), - 'F', - new ItemStack(ModBlocks.felPumpkin), - 'I', - LibOreDict.MANA_STEEL); - else - addOreDictRecipe( - new ItemStack(ModBlocks.cocoon), - "SSS", - "SPS", - "SDS", - 'S', - new ItemStack(Items.string), - 'P', - LibOreDict.PIXIE_DUST, - 'D', - LibOreDict.DRAGONSTONE); - recipeCocoon = BotaniaAPI.getLatestAddedRecipe(); - - // Fel Pumpkin - GameRegistry.addRecipe( - new ItemStack(ModBlocks.felPumpkin), - " S ", - "BPF", - " G ", - 'S', - new ItemStack(Items.string), - 'B', - new ItemStack(Items.bone), - 'P', - new ItemStack(Blocks.pumpkin), - 'F', - new ItemStack(Items.rotten_flesh), - 'G', - new ItemStack(Items.gunpowder)); - recipeFelPumpkin = BotaniaAPI.getLatestAddedRecipe(); - - // Luminizer Recipe - addShapelessOreDictRecipe( - new ItemStack(ModBlocks.lightRelay), - LibOreDict.RED_STRING, - LibOreDict.DRAGONSTONE, - "dustGlowstone", - "dustGlowstone"); - recipeLuminizer = BotaniaAPI.getLatestAddedRecipe(); - - // Detector Luminizer Recipe - addShapelessOreDictRecipe( - new ItemStack(ModBlocks.lightRelay, 1, 1), new ItemStack(ModBlocks.lightRelay), "dustRedstone"); - recipeDetectorLuminizer = BotaniaAPI.getLatestAddedRecipe(); - - // Luminizer Launcher Recipe - addOreDictRecipe( - new ItemStack(ModBlocks.lightLauncher), - "DDD", - "DLD", - 'D', - LibOreDict.DREAM_WOOD, - 'L', - new ItemStack(ModBlocks.lightRelay)); - recipeLuminizerLauncher = BotaniaAPI.getLatestAddedRecipe(); - - // Floral Obedience Stick Recipe - addOreDictRecipe( - new ItemStack(ModItems.obedienceStick), - " M", - " T ", - "T ", - 'M', - LibOreDict.MANA_STEEL, - 'T', - LibOreDict.LIVINGWOOD_TWIG); - recipeObedienceStick = BotaniaAPI.getLatestAddedRecipe(); - - // Cacophonium Recipe - if (OreDictionary.getOres("ingotBrass").isEmpty()) - addOreDictRecipe( - new ItemStack(ModItems.cacophonium), - " G ", - "GNG", - "GG ", - 'G', - "ingotGold", - 'N', - new ItemStack(Blocks.noteblock)); - else - addOreDictRecipe( - new ItemStack(ModItems.cacophonium), - " G ", - "GNG", - "GG ", - 'G', - "ingotBrass", - 'N', - new ItemStack(Blocks.noteblock)); - recipeCacophonium = BotaniaAPI.getLatestAddedRecipe(); - - // Manastorm Charge Recipe - addOreDictRecipe( - new ItemStack(ModBlocks.manaBomb), - "LTL", - "TGT", - "LTL", - 'L', - LibOreDict.LIVING_WOOD, - 'T', - new ItemStack(Blocks.tnt), - 'G', - LibOreDict.LIFE_ESSENCE); - recipeManaBomb = BotaniaAPI.getLatestAddedRecipe(); - - // Cobweb Recipe - addOreDictRecipe( - new ItemStack(Blocks.web), - "S S", - " M ", - "S S", - 'S', - new ItemStack(Items.string), - 'M', - LibOreDict.MANA_STRING); - recipeCobweb = BotaniaAPI.getLatestAddedRecipe(); - - // Slime in a Bottle Recipe - addOreDictRecipe( - new ItemStack(ModItems.slimeBottle), - "EGE", - "ESE", - " E ", - 'E', - LibOreDict.ELEMENTIUM, - 'G', - new ItemStack(ModBlocks.elfGlass), - 'S', - "slimeball"); - recipeSlimeBottle = BotaniaAPI.getLatestAddedRecipe(); - - // Starcaller Recipe - addOreDictRecipe( - new ItemStack(ModItems.starSword), - " I", - "AD ", - "TA ", - 'I', - LibOreDict.ELEMENTIUM, - 'D', - LibOreDict.DRAGONSTONE, - 'A', - LibOreDict.ENDER_AIR_BOTTLE, - 'T', - new ItemStack(ModItems.terraSword)); - recipeStarSword = BotaniaAPI.getLatestAddedRecipe(); - - // Rod of the Shifting Crust Recipe - addOreDictRecipe( - new ItemStack(ModItems.exchangeRod), - " SR", - " TS", - "T ", - 'T', - LibOreDict.LIVINGWOOD_TWIG, - 'S', - "stone", - 'R', - LibOreDict.RUNE[12]); - recipeExchangeRod = BotaniaAPI.getLatestAddedRecipe(); - - // Greater Ring of Magnetization Recipe - addShapelessOreDictRecipe( - new ItemStack(ModItems.magnetRingGreater), LibOreDict.TERRA_STEEL, new ItemStack(ModItems.magnetRing)); - recipeGreaterMagnetRing = BotaniaAPI.getLatestAddedRecipe(); - - // Flare Chakram Recipe - addOreDictRecipe( - new ItemStack(ModItems.thornChakram, 2, 1), - "BBB", - "CPC", - "BBB", - 'B', - new ItemStack(Items.blaze_powder), - 'P', - LibOreDict.PIXIE_DUST, - 'C', - new ItemStack(ModItems.thornChakram)); - recipeFireChakram = BotaniaAPI.getLatestAddedRecipe(); - - // Thundercaller Recipe - addOreDictRecipe( - new ItemStack(ModItems.thunderSword), - " I", - "AD ", - "TA ", - 'I', - LibOreDict.ELEMENTIUM, - 'D', - LibOreDict.MANA_DIAMOND, - 'A', - LibOreDict.ENDER_AIR_BOTTLE, - 'T', - new ItemStack(ModItems.terraSword)); - recipeThunderSword = BotaniaAPI.getLatestAddedRecipe(); - - // Manatide Bellows Recipe - addOreDictRecipe( - new ItemStack(ModBlocks.bellows), - "SSS", - "RL ", - "SSS", - 'S', - new ItemStack(ModFluffBlocks.livingwoodSlab), - 'R', - LibOreDict.RUNE[3], - 'L', - new ItemStack(Items.leather)); - recipeBellows = BotaniaAPI.getLatestAddedRecipe(); - - // Manaweave Cloth Recipe - addOreDictRecipe(new ItemStack(ModItems.manaResource, 1, 22), "SS", "SS", 'S', LibOreDict.MANA_STRING); - recipeManaweaveCloth = BotaniaAPI.getLatestAddedRecipe(); - - // Manaweave Armor Recipes - addOreDictRecipe(new ItemStack(ModItems.manaweaveHelm), "SSS", "S S", 'S', LibOreDict.MANAWEAVE_CLOTH); - recipeManaweaveHelm = BotaniaAPI.getLatestAddedRecipe(); - addOreDictRecipe(new ItemStack(ModItems.manaweaveChest), "S S", "SSS", "SSS", 'S', LibOreDict.MANAWEAVE_CLOTH); - recipeManaweaveChest = BotaniaAPI.getLatestAddedRecipe(); - addOreDictRecipe(new ItemStack(ModItems.manaweaveLegs), "SSS", "S S", "S S", 'S', LibOreDict.MANAWEAVE_CLOTH); - recipeManaweaveLegs = BotaniaAPI.getLatestAddedRecipe(); - addOreDictRecipe(new ItemStack(ModItems.manaweaveBoots), "S S", "S S", 'S', LibOreDict.MANAWEAVE_CLOTH); - recipeManaweaveBoots = BotaniaAPI.getLatestAddedRecipe(); - - // Bifrost Blocks Recipe - addShapelessOreDictRecipe( - new ItemStack(ModBlocks.bifrostPerm), - new ItemStack(ModItems.rainbowRod), - new ItemStack(ModBlocks.elfGlass)); - recipeBifrost = BotaniaAPI.getLatestAddedRecipe(); - addShapelessOreDictRecipe( - new ItemStack(ModBlocks.shimmerrock), LibOreDict.LIVING_ROCK, new ItemStack(ModBlocks.bifrostPerm)); - recipeShimmerrock = BotaniaAPI.getLatestAddedRecipe(); - addShapelessOreDictRecipe( - new ItemStack(ModBlocks.shimmerwoodPlanks), - new ItemStack(ModBlocks.dreamwood, 1, 1), - new ItemStack(ModBlocks.bifrostPerm)); - recipeShimmerwoodPlanks = BotaniaAPI.getLatestAddedRecipe(); - - // Manufactory Halo Recipe - addShapelessOreDictRecipe( - new ItemStack(ModItems.autocraftingHalo), - new ItemStack(ModItems.craftingHalo), - LibOreDict.MANA_DIAMOND); - recipeAutocraftingHalo = BotaniaAPI.getLatestAddedRecipe(); - - // Pavement Recipes - addShapelessOreDictRecipe( - new ItemStack(ModFluffBlocks.pavement, 3, 0), LibOreDict.LIVING_ROCK, "cobblestone", "gravel"); - addShapelessOreDictRecipe( - new ItemStack(ModFluffBlocks.pavement, 3, 1), - LibOreDict.LIVING_ROCK, - "cobblestone", - "gravel", - new ItemStack(Items.coal)); - addShapelessOreDictRecipe( - new ItemStack(ModFluffBlocks.pavement, 3, 2), - LibOreDict.LIVING_ROCK, - "cobblestone", - "gravel", - new ItemStack(Items.dye, 1, 4)); - addShapelessOreDictRecipe( - new ItemStack(ModFluffBlocks.pavement, 3, 3), - LibOreDict.LIVING_ROCK, - "cobblestone", - "gravel", - new ItemStack(Items.redstone)); - addShapelessOreDictRecipe( - new ItemStack(ModFluffBlocks.pavement, 3, 4), - LibOreDict.LIVING_ROCK, - "cobblestone", - "gravel", - new ItemStack(Items.wheat)); - addShapelessOreDictRecipe( - new ItemStack(ModFluffBlocks.pavement, 3, 5), - LibOreDict.LIVING_ROCK, - "cobblestone", - "gravel", - new ItemStack(Items.slime_ball)); - recipesPavement = BotaniaAPI.getLatestAddedRecipes(6); - - // Cellular Block Recipe - GameRegistry.addShapelessRecipe( - new ItemStack(ModBlocks.cellBlock, 3), - new ItemStack(Blocks.cactus), - new ItemStack(Blocks.cactus), - new ItemStack(Blocks.cactus), - new ItemStack(Blocks.cactus), - new ItemStack(Items.carrot), - new ItemStack(Items.potato)); - recipeCellBlock = BotaniaAPI.getLatestAddedRecipe(); - - // Corporea Retainer Recipe - addShapelessOreDictRecipe( - new ItemStack(ModBlocks.corporeaRetainer), - new ItemStack(Blocks.chest), - new ItemStack(ModItems.corporeaSpark)); - recipeCorporeaRetainer = BotaniaAPI.getLatestAddedRecipe(); - - // Teru Teru Bozu Recipe - addOreDictRecipe( - new ItemStack(ModBlocks.teruTeruBozu), - "C", - "C", - "S", - 'C', - LibOreDict.MANAWEAVE_CLOTH, - 'S', - new ItemStack(Blocks.double_plant)); - recipeTeruTeruBozu = BotaniaAPI.getLatestAddedRecipe(); - - // Livingwood Avatar Recipe - addOreDictRecipe( - new ItemStack(ModBlocks.avatar), - " W ", - "WDW", - "W W", - 'W', - LibOreDict.LIVING_WOOD, - 'D', - LibOreDict.MANA_DIAMOND); - recipeAvatar = BotaniaAPI.getLatestAddedRecipe(); - - // Worldshaper's Sextant Recipe - addOreDictRecipe( - new ItemStack(ModItems.sextant), - " TI", - " TT", - "III", - 'T', - LibOreDict.LIVINGWOOD_TWIG, - 'I', - LibOreDict.MANA_STEEL); - recipeSextant = BotaniaAPI.getLatestAddedRecipe(); - - // Alternate Pasture Seed Recipes - GameRegistry.addShapelessRecipe( - new ItemStack(ModItems.grassSeeds, 1, 3), - new ItemStack(ModItems.grassSeeds), - new ItemStack(Blocks.deadbush)); - GameRegistry.addShapelessRecipe( - new ItemStack(ModItems.grassSeeds, 1, 4), - new ItemStack(ModItems.grassSeeds), - new ItemStack(Items.wheat)); - GameRegistry.addShapelessRecipe( - new ItemStack(ModItems.grassSeeds, 1, 5), - new ItemStack(ModItems.grassSeeds), - new ItemStack(Items.dye, 1, 2)); - GameRegistry.addShapelessRecipe( - new ItemStack(ModItems.grassSeeds, 1, 6), - new ItemStack(ModItems.grassSeeds), - new ItemStack(Items.blaze_powder)); - GameRegistry.addShapelessRecipe( - new ItemStack(ModItems.grassSeeds, 1, 7), - new ItemStack(ModItems.grassSeeds), - new ItemStack(ModItems.manaResource, 1, 10)); - GameRegistry.addShapelessRecipe( - new ItemStack(ModItems.grassSeeds, 1, 8), - new ItemStack(ModItems.grassSeeds), - new ItemStack(Items.spider_eye)); - recipesAltGrassSeeds = BotaniaAPI.getLatestAddedRecipes(6); - - // Planestrider's Sash Recipe - GameRegistry.addRecipe( - new ItemStack(ModItems.speedUpBelt), - " M ", - "PBP", - " S ", - 'M', - new ItemStack(Items.filled_map, 1, Short.MAX_VALUE), - 'P', - new ItemStack(ModItems.grassSeeds), - 'B', - new ItemStack(ModItems.travelBelt), - 'S', - new ItemStack(Items.sugar)); - recipeSpeedUpBelt = BotaniaAPI.getLatestAddedRecipe(); - - // Bauble Case Recipe - addOreDictRecipe( - new ItemStack(ModItems.baubleBox), - " M ", - "MCG", - " M ", - 'M', - LibOreDict.MANA_STEEL, - 'C', - new ItemStack(Blocks.chest), - 'G', - "ingotGold"); - recipeBaubleCase = BotaniaAPI.getLatestAddedRecipe(); - - /////////////////////////////////////////////////////////////////////////////////////////////////////////// - - // Storage Block/Nugget Recipes - addOreDictRecipe(new ItemStack(ModBlocks.storage, 1, 0), "III", "III", "III", 'I', LibOreDict.MANA_STEEL); - addOreDictRecipe(new ItemStack(ModBlocks.storage, 1, 1), "III", "III", "III", 'I', LibOreDict.TERRA_STEEL); - addOreDictRecipe(new ItemStack(ModBlocks.storage, 1, 2), "III", "III", "III", 'I', LibOreDict.ELEMENTIUM); - addOreDictRecipe(new ItemStack(ModBlocks.storage, 1, 3), "III", "III", "III", 'I', LibOreDict.MANA_DIAMOND); - addOreDictRecipe(new ItemStack(ModBlocks.storage, 1, 4), "III", "III", "III", 'I', LibOreDict.DRAGONSTONE); - GameRegistry.addShapelessRecipe( - new ItemStack(ModItems.manaResource, 9, 0), new ItemStack(ModBlocks.storage, 1, 0)); - GameRegistry.addShapelessRecipe( - new ItemStack(ModItems.manaResource, 9, 4), new ItemStack(ModBlocks.storage, 1, 1)); - GameRegistry.addShapelessRecipe( - new ItemStack(ModItems.manaResource, 9, 7), new ItemStack(ModBlocks.storage, 1, 2)); - GameRegistry.addShapelessRecipe( - new ItemStack(ModItems.manaResource, 9, 2), new ItemStack(ModBlocks.storage, 1, 3)); - GameRegistry.addShapelessRecipe( - new ItemStack(ModItems.manaResource, 9, 9), new ItemStack(ModBlocks.storage, 1, 4)); - - addOreDictRecipe( - new ItemStack(ModItems.manaResource, 1, 0), "III", "III", "III", 'I', LibOreDict.MANASTEEL_NUGGET); - addOreDictRecipe( - new ItemStack(ModItems.manaResource, 1, 4), "III", "III", "III", 'I', LibOreDict.TERRASTEEL_NUGGET); - addOreDictRecipe( - new ItemStack(ModItems.manaResource, 1, 7), "III", "III", "III", 'I', LibOreDict.ELEMENTIUM_NUGGET); - addShapelessOreDictRecipe(new ItemStack(ModItems.manaResource, 9, 17), LibOreDict.MANA_STEEL); - addShapelessOreDictRecipe(new ItemStack(ModItems.manaResource, 9, 18), LibOreDict.TERRA_STEEL); - addShapelessOreDictRecipe(new ItemStack(ModItems.manaResource, 9, 19), LibOreDict.ELEMENTIUM); - - // Revealing Helmet Recipes - if (Botania.thaumcraftLoaded) { - Item goggles = (Item) Item.itemRegistry.getObject("Thaumcraft:ItemGoggles"); - GameRegistry.addShapelessRecipe( - new ItemStack(ModItems.manasteelHelmRevealing), new ItemStack(ModItems.manasteelHelm), goggles); - recipeHelmetOfRevealing = BotaniaAPI.getLatestAddedRecipe(); // We want manasteel to show in the Lexicon - GameRegistry.addShapelessRecipe( - new ItemStack(ModItems.terrasteelHelmRevealing), new ItemStack(ModItems.terrasteelHelm), goggles); - GameRegistry.addShapelessRecipe( - new ItemStack(ModItems.elementiumHelmRevealing), new ItemStack(ModItems.elementiumHelm), goggles); - } - - // Slab & Stair Recipes - addStairsAndSlabs(ModBlocks.livingwood, 0, ModFluffBlocks.livingwoodStairs, ModFluffBlocks.livingwoodSlab); - addStairsAndSlabs( - ModBlocks.livingwood, 1, ModFluffBlocks.livingwoodPlankStairs, ModFluffBlocks.livingwoodPlankSlab); - addStairsAndSlabs(ModBlocks.livingrock, 0, ModFluffBlocks.livingrockStairs, ModFluffBlocks.livingrockSlab); - addStairsAndSlabs( - ModBlocks.livingrock, 1, ModFluffBlocks.livingrockBrickStairs, ModFluffBlocks.livingrockBrickSlab); - addStairsAndSlabs(ModBlocks.dreamwood, 0, ModFluffBlocks.dreamwoodStairs, ModFluffBlocks.dreamwoodSlab); - addStairsAndSlabs( - ModBlocks.dreamwood, 1, ModFluffBlocks.dreamwoodPlankStairs, ModFluffBlocks.dreamwoodPlankSlab); - addStairsAndSlabs(ModBlocks.prismarine, 0, ModFluffBlocks.prismarineStairs, ModFluffBlocks.prismarineSlab); - addStairsAndSlabs( - ModBlocks.prismarine, 1, ModFluffBlocks.prismarineBrickStairs, ModFluffBlocks.prismarineBrickSlab); - addStairsAndSlabs( - ModBlocks.prismarine, 2, ModFluffBlocks.darkPrismarineStairs, ModFluffBlocks.darkPrismarineSlab); - addStairsAndSlabs(ModBlocks.reedBlock, 0, ModFluffBlocks.reedStairs, ModFluffBlocks.reedSlab); - addStairsAndSlabs(ModBlocks.thatch, 0, ModFluffBlocks.thatchStairs, ModFluffBlocks.thatchSlab); - addStairsAndSlabs(ModBlocks.customBrick, 0, ModFluffBlocks.netherBrickStairs, ModFluffBlocks.netherBrickSlab); - addStairsAndSlabs(ModBlocks.customBrick, 1, ModFluffBlocks.soulBrickStairs, ModFluffBlocks.soulBrickSlab); - addStairsAndSlabs(ModBlocks.customBrick, 2, ModFluffBlocks.snowBrickStairs, ModFluffBlocks.snowBrickSlab); - addStairsAndSlabs(ModBlocks.customBrick, 3, ModFluffBlocks.tileStairs, ModFluffBlocks.tileSlab); - addStairsAndSlabs(ModBlocks.endStoneBrick, 0, ModFluffBlocks.endStoneStairs, ModFluffBlocks.endStoneSlab); - addStairsAndSlabs(ModBlocks.shimmerrock, 0, ModFluffBlocks.shimmerrockStairs, ModFluffBlocks.shimmerrockSlab); - addStairsAndSlabs( - ModBlocks.shimmerwoodPlanks, - 0, - ModFluffBlocks.shimmerwoodPlankStairs, - ModFluffBlocks.shimmerwoodPlankSlab); - - // Wall Recipes - addWall(ModBlocks.livingrock, 0, ModFluffBlocks.livingrockWall, 0); - addWall(ModBlocks.livingwood, 0, ModFluffBlocks.livingwoodWall, 0); - addWall(ModBlocks.dreamwood, 0, ModFluffBlocks.dreamwoodWall, 0); - addWall(ModBlocks.prismarine, 0, ModFluffBlocks.prismarineWall, 0); - addWall(ModBlocks.reedBlock, 0, ModFluffBlocks.reedWall, 0); - for (int i = 0; i < 8; i++) addWall(ModFluffBlocks.biomeStoneA, i + 8, ModFluffBlocks.biomeStoneWall, i); - for (int i = 0; i < 4; i++) addWall(ModFluffBlocks.stone, i, ModFluffBlocks.stoneWall, i); - - // Pane Recipes - addPane(ModBlocks.manaGlass, ModFluffBlocks.managlassPane); - addPane(ModBlocks.elfGlass, ModFluffBlocks.alfglassPane); - addPane(ModBlocks.bifrostPerm, ModFluffBlocks.bifrostPane); - - // Biome Stone Recipes - for (int i = 0; i < 8; i++) { - GameRegistry.addSmelting( - new ItemStack(ModFluffBlocks.biomeStoneA, 1, i + 8), - new ItemStack(ModFluffBlocks.biomeStoneA, 1, i), - 0.1F); - GameRegistry.addRecipe( - new ItemStack(ModFluffBlocks.biomeStoneB, 4, i), - "SS", - "SS", - 'S', - new ItemStack(ModFluffBlocks.biomeStoneA, 1, i)); - GameRegistry.addRecipe( - new ItemStack(ModFluffBlocks.biomeStoneB, 1, i + 8), - "S", - "S", - 'S', - new ItemStack(ModFluffBlocks.biomeStoneSlabs[i + 16])); - addStairsAndSlabs( - ModFluffBlocks.biomeStoneA, - i, - ModFluffBlocks.biomeStoneStairs[i], - ModFluffBlocks.biomeStoneSlabs[i]); - addStairsAndSlabs( - ModFluffBlocks.biomeStoneA, - i + 8, - ModFluffBlocks.biomeStoneStairs[i + 8], - ModFluffBlocks.biomeStoneSlabs[i + 8]); - addStairsAndSlabs( - ModFluffBlocks.biomeStoneB, - i, - ModFluffBlocks.biomeStoneStairs[i + 16], - ModFluffBlocks.biomeStoneSlabs[i + 16]); - } - - // 1.8 Block Stone Stairs & Slabs - for (int i = 0; i < 4; i++) { - addOreDictRecipe( - new ItemStack(ModFluffBlocks.stoneSlabs[i], 6), "QQQ", 'Q', LibOreDict.STONE_18_VARIANTS[i]); - addOreDictRecipe( - new ItemStack(ModFluffBlocks.stoneStairs[i], 4), - " Q", - " QQ", - "QQQ", - 'Q', - LibOreDict.STONE_18_VARIANTS[i]); - addOreDictRecipe( - new ItemStack(ModFluffBlocks.stoneStairs[i], 4), - "Q ", - "QQ ", - "QQQ", - 'Q', - LibOreDict.STONE_18_VARIANTS[i]); - addOreDictRecipe( - new ItemStack(ModFluffBlocks.stone, 1, i), - "Q", - "Q", - 'Q', - new ItemStack(ModFluffBlocks.stoneSlabs[i])); - - addOreDictRecipe( - new ItemStack(ModFluffBlocks.stoneSlabs[i + 4], 6), - "QQQ", - 'Q', - LibOreDict.STONE_18_VARIANTS[i + 8]); - addOreDictRecipe( - new ItemStack(ModFluffBlocks.stoneStairs[i + 4], 4), - " Q", - " QQ", - "QQQ", - 'Q', - LibOreDict.STONE_18_VARIANTS[i + 8]); - addOreDictRecipe( - new ItemStack(ModFluffBlocks.stoneStairs[i + 4], 4), - "Q ", - "QQ ", - "QQQ", - 'Q', - LibOreDict.STONE_18_VARIANTS[i + 8]); - addOreDictRecipe( - new ItemStack(ModFluffBlocks.stone, 1, i + 8), // VERY VERY - "Q", - "Q", // BIG BIG - 'Q', - new ItemStack(ModFluffBlocks.stoneSlabs[i + 4])); // PROBLEM PROBLEM - } - - // Pavement Stairsm & Stairs - for (int i = 0; i < ModFluffBlocks.pavementStairs.length; i++) - addStairsAndSlabs( - ModFluffBlocks.pavement, i, ModFluffBlocks.pavementStairs[i], ModFluffBlocks.pavementSlabs[i]); - - // Misc Recipes - GameRegistry.addShapelessRecipe(new ItemStack(Items.reeds, 9, 0), new ItemStack(ModBlocks.reedBlock)); - GameRegistry.addShapelessRecipe(new ItemStack(Items.wheat, 4, 0), new ItemStack(ModBlocks.thatch)); - - if (Botania.gardenOfGlassLoaded) initGardenOfGlass(); - - int newRecipeListSize = CraftingManager.getInstance().getRecipeList().size(); - FMLLog.log(Level.INFO, "[Botania] Registered %d recipes.", newRecipeListSize - recipeListSize); - } - - private static void initGardenOfGlass() { - // Root to Sapling - addShapelessOreDictRecipe( - new ItemStack(Blocks.sapling), LibOreDict.ROOT, LibOreDict.ROOT, LibOreDict.ROOT, LibOreDict.ROOT); - recipeRootToSapling = BotaniaAPI.getLatestAddedRecipe(); - - // Root to Fertilizer - addShapelessOreDictRecipe(new ItemStack(ModItems.fertilizer), LibOreDict.ROOT); - recipeRootToFertilizer = BotaniaAPI.getLatestAddedRecipe(); - - // Pebble to Cobble - addShapelessOreDictRecipe( - new ItemStack(Blocks.cobblestone), - LibOreDict.PEBBLE, - LibOreDict.PEBBLE, - LibOreDict.PEBBLE, - LibOreDict.PEBBLE); - recipePebbleCobblestone = BotaniaAPI.getLatestAddedRecipe(); - - // Magma Pearl to Slimeball - addShapelessOreDictRecipe( - new ItemStack(Items.slime_ball), new ItemStack(Items.magma_cream), new ItemStack(Items.water_bucket)); - recipeMagmaToSlimeball = BotaniaAPI.getLatestAddedRecipe(); - - // Ender Portal - addOreDictRecipe( - new ItemStack(Blocks.end_portal_frame), - "OGO", - 'O', - new ItemStack(Blocks.obsidian), - 'G', - LibOreDict.LIFE_ESSENCE); - recipeEndPortal = BotaniaAPI.getLatestAddedRecipe(); - } - - private static void addStairsAndSlabs(Block block, int meta, Block stairs, Block slab) { - GameRegistry.addRecipe(new ItemStack(slab, 6), "QQQ", 'Q', new ItemStack(block, 1, meta)); - GameRegistry.addRecipe(new ItemStack(stairs, 4), " Q", " QQ", "QQQ", 'Q', new ItemStack(block, 1, meta)); - GameRegistry.addRecipe(new ItemStack(stairs, 4), "Q ", "QQ ", "QQQ", 'Q', new ItemStack(block, 1, meta)); - GameRegistry.addRecipe(new ItemStack(block, 1, meta), "Q", "Q", 'Q', new ItemStack(slab)); - } - - private static void addWall(Block block, int blockMeta, Block wall, int wallMeta) { - GameRegistry.addRecipe(new ItemStack(wall, 6, wallMeta), "BBB", "BBB", 'B', new ItemStack(block, 1, blockMeta)); - } - - private static void addPane(Block block, Block pane) { - GameRegistry.addRecipe(new ItemStack(pane, 16), "BBB", "BBB", 'B', new ItemStack(block, 1)); - } - - private static IRecipe addQuartzRecipes(int meta, Item req, Block block, Block stairs, Block slab) { - GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(block), "QQ", "QQ", 'Q', LibOreDict.QUARTZ[meta])); - GameRegistry.addRecipe(new ItemStack(block, 2, 2), "Q", "Q", 'Q', block); - GameRegistry.addRecipe(new ItemStack(block, 1, 1), "Q", "Q", 'Q', slab); - addStairsAndSlabs(block, 0, stairs, slab); - - if (req != null) { - if (req == Items.coal) - GameRegistry.addRecipe(new ShapedOreRecipe( - new ItemStack(ModItems.quartz, 8, meta), - "QQQ", - "QCQ", - "QQQ", - 'Q', - "gemQuartz", - 'C', - new ItemStack(req, 1, 1))); - GameRegistry.addRecipe(new ShapedOreRecipe( - new ItemStack(ModItems.quartz, 8, meta), "QQQ", "QCQ", "QQQ", 'Q', "gemQuartz", 'C', req)); - return BotaniaAPI.getLatestAddedRecipe(); - } - return null; - } - - private static void addOreDictRecipe(ItemStack output, Object... recipe) { - CraftingManager.getInstance().getRecipeList().add(new ShapedOreRecipe(output, recipe)); - } - - private static void addShapelessOreDictRecipe(ItemStack output, Object... recipe) { - CraftingManager.getInstance().getRecipeList().add(new ShapelessOreRecipe(output, recipe)); - } + public static IRecipe recipeLexicon; + public static List recipesPetals; + public static List recipesDyes; + public static List recipesPetalBlocks; + public static IRecipe recipePestleAndMortar; + public static List recipesTwigWand; + public static List recipesApothecary; + public static List recipesSpreader; + public static List recipesManaLens; + public static IRecipe recipePool; + public static IRecipe recipePoolDiluted; + public static IRecipe recipePoolFabulous; + public static List recipesRuneAltar; + public static IRecipe recipeLensVelocity; + public static IRecipe recipeLensPotency; + public static IRecipe recipeLensResistance; + public static IRecipe recipeLensEfficiency; + public static IRecipe recipeLensBounce; + public static IRecipe recipeLensGravity; + public static IRecipe recipeLensBore; + public static IRecipe recipeLensDamaging; + public static IRecipe recipeLensPhantom; + public static IRecipe recipeLensMagnet; + public static IRecipe recipeLensExplosive; + public static List recipesUnstableBlocks; + public static IRecipe recipePylon; + public static IRecipe recipeDistributor; + public static IRecipe recipeLivingrockDecor1; + public static IRecipe recipeLivingrockDecor2; + public static IRecipe recipeLivingrockDecor3; + public static IRecipe recipeLivingrockDecor4; + public static IRecipe recipeLivingwoodDecor1; + public static IRecipe recipeLivingwoodDecor2; + public static IRecipe recipeLivingwoodDecor3; + public static IRecipe recipeLivingwoodDecor4; + public static IRecipe recipeLivingwoodDecor5; + public static List recipesManaBeacons; + public static List recipesSignalFlares; + public static IRecipe recipeManaVoid; + public static List recipesManaTablet; + public static IRecipe recipeManaDetector; + public static IRecipe recipeManaBlaster; + public static IRecipe recipeTurntable; + public static IRecipe recipeFertilizerPowder; + public static IRecipe recipeFerilizerDye; + public static IRecipe recipeLivingwoodTwig; + public static IRecipe recipeDirtRod; + public static IRecipe recipeTerraformRod; + public static IRecipe recipeRedstoneSpreader; + public static IRecipe recipeManaMirror; + public static IRecipe recipeManasteelHelm; + public static IRecipe recipeManasteelChest; + public static IRecipe recipeManasteelLegs; + public static IRecipe recipeManasteelBoots; + public static IRecipe recipeManasteelPick; + public static IRecipe recipeManasteelShovel; + public static IRecipe recipeManasteelAxe; + public static IRecipe recipeManasteelShears; + public static IRecipe recipeManasteelSword; + public static IRecipe recipeGrassHorn; + public static IRecipe recipeTerrasteelHelm; + public static IRecipe recipeTerrasteelChest; + public static IRecipe recipeTerrasteelLegs; + public static IRecipe recipeTerrasteelBoots; + public static IRecipe recipeTerraSword; + public static IRecipe recipeTinyPlanet; + public static IRecipe recipeManaRing; + public static IRecipe recipeAuraRing; + public static IRecipe recipeGreaterManaRing; + public static IRecipe recipeGreaterAuraRing; + public static IRecipe recipeTravelBelt; + public static IRecipe recipeKnocbackBelt; + public static IRecipe recipeIcePendant; + public static IRecipe recipeFirePendant; + public static IRecipe recipeGoldenLaurel; + public static IRecipe recipeTinyPlanetBlock; + public static IRecipe recipeAlchemyCatalyst; + public static IRecipe recipeOpenCrate; + public static IRecipe recipeForestEye; + public static IRecipe recipeRedstoneRoot; + public static IRecipe recipeForestDrum; + public static IRecipe recipeWaterRing; + public static IRecipe recipeMiningRing; + public static IRecipe recipeMagnetRing; + public static IRecipe recipeTerraPick; + public static IRecipe recipeDivaCharm; + public static IRecipe recipeFlightTiara; + public static List recipesShinyFlowers; + public static IRecipe recipePlatform; + public static IRecipe recipeEnderDagger; + public static IRecipe recipeDarkQuartz; + public static IRecipe recipeBlazeQuartz; + public static List recipesLavenderQuartz; + public static IRecipe recipeRedQuartz; + public static IRecipe recipeSunnyQuartz; + public static IRecipe recipeAlfPortal; + public static IRecipe recipeNaturaPylon; + public static IRecipe recipeWaterRod; + public static IRecipe recipeElementiumHelm; + public static IRecipe recipeElementiumChest; + public static IRecipe recipeElementiumLegs; + public static IRecipe recipeElementiumBoots; + public static IRecipe recipeElementiumPick; + public static IRecipe recipeElementiumShovel; + public static IRecipe recipeElementiumAxe; + public static IRecipe recipeElementiumShears; + public static IRecipe recipeElementiumSword; + public static IRecipe recipeOpenBucket; + public static IRecipe recipeConjurationCatalyst; + public static IRecipe recipeSpawnerMover; + public static IRecipe recipePixieRing; + public static IRecipe recipeSuperTravelBelt; + public static IRecipe recipeRainbowRod; + public static IRecipe recipeSpectralPlatform; + public static List recipesDreamwoodSpreader; + public static IRecipe recipeTornadoRod; + public static IRecipe recipeFireRod; + public static IRecipe recipeVineBall; + public static IRecipe recipeSlingshot; + public static IRecipe recipeMossStone; + public static IRecipe recipePrismarine; + public static IRecipe recipePrismarineBrick; + public static IRecipe recipeDarkPrismarine; + public static IRecipe recipeSeaLamp; + public static IRecipe recipeLensInfluence; + public static IRecipe recipeLensWeight; + public static IRecipe recipeLensPaint; + public static IRecipe recipeLensWarp; + public static IRecipe recipeLensRedirect; + public static IRecipe recipeLensFirework; + public static IRecipe recipeLensFlare; + public static List recipesMiniIsland; + public static IRecipe recipeGaiaPylon; + public static IRecipe recipeGatherDrum; + public static IRecipe recipeLensFire; + public static IRecipe recipeLensPiston; + public static List recipesLaputaShard; + public static List recipesLaputaShardUpgrade; + public static IRecipe recipeVirusZombie; + public static IRecipe recipeVirusSkeleton; + public static IRecipe recipeReachRing; + public static IRecipe recipeSkyDirtRod; + public static IRecipe recipeSpawnerClaw; + public static IRecipe recipeCraftCrate; + public static IRecipe recipePlaceholder; + public static IRecipe recipeReedBlock; + public static IRecipe recipeThatch; + public static IRecipe recipeNetherBrick; + public static IRecipe recipeSoulBrick; + public static IRecipe recipeSnowBrick; + public static IRecipe recipeRoofTile; + public static IRecipe recipeAzulejo; + public static List recipesAzulejoCycling; + public static IRecipe recipeEnderEyeBlock; + public static IRecipe recipeItemFinder; + public static IRecipe recipeSuperLavaPendant; + public static IRecipe recipeEnderHand; + public static IRecipe recipeGlassPick; + public static IRecipe recipeStarfield; + public static List recipesSpark; + public static List recipesSparkUpgrades; + public static IRecipe recipeLeafHorn; + public static IRecipe recipeDiviningRod; + public static List recipesWings; + public static IRecipe recipeRFGenerator; + public static IRecipe recipeGravityRod; + public static IRecipe recipeRegenIvy; + public static IRecipe recipeUltraSpreader; + public static IRecipe recipeHelmetOfRevealing; + public static IRecipe recipeVial; + public static IRecipe recipeFlask; + public static IRecipe recipeBrewery; + public static IRecipe recipeBloodPendant; + public static IRecipe recipeTerraPlate; + public static IRecipe recipeRedString; + public static IRecipe recipeRedStringContainer; + public static IRecipe recipeRedStringDispenser; + public static IRecipe recipeRedStringFertilizer; + public static IRecipe recipeRedStringComparator; + public static IRecipe recipeRedStringRelay; + public static IRecipe recipeRedStringInterceptor; + public static IRecipe recipeMissileRod; + public static IRecipe recipeHolyCloak; + public static IRecipe recipeUnholyCloak; + public static IRecipe recipeCraftingHalo; + public static List recipesLensFlash; + public static IRecipe recipePrism; + public static IRecipe recipeDirtPath; + public static IRecipe recipeDreamwoodTwig; + public static IRecipe recipeMonocle; + public static IRecipe recipeClip; + public static IRecipe recipeCobbleRod; + public static IRecipe recipeSmeltRod; + public static IRecipe recipeWorldSeed; + public static IRecipe recipeSpellCloth; + public static IRecipe recipeThornChakram; + public static IRecipe recipeDirtPathSlab; + public static List recipesPatterns; + public static IRecipe recipeGaiaIngot; + public static IRecipe recipeCorporeaSpark; + public static IRecipe recipeMasterCorporeaSpark; + public static IRecipe recipeCorporeaIndex; + public static IRecipe recipeCorporeaFunnel; + public static IRecipe recipeCorporeaInterceptor; + public static IRecipe recipeEndStoneBricks; + public static IRecipe recipeEndStoneChiseledBricks; + public static IRecipe recipeEnderBricks; + public static IRecipe recipePillarEnderBricks; + public static IRecipe recipeLivingwoodBow; + public static IRecipe recipeCrystalBow; + public static List recipesCosmeticItems; + public static List recipesMushrooms; + public static IRecipe recipeSwapRing; + public static IRecipe recipeSnowHorn; + public static IRecipe recipeFlowerBag; + public static IRecipe recipePhantomInk; + public static IRecipe recipePoolCart; + public static IRecipe recipePump; + public static List recipesPetalsDouble; + public static IRecipe recipeKeepIvy; + public static IRecipe recipeBlackHoleTalisman; + public static List recipe18StonePolish; + public static List recipe18StoneBrick; + public static List recipe18StoneChisel; + public static IRecipe recipeBlazeBlock; + public static List recipesAltarMeta; + public static IRecipe recipeCorporeaCrystalCube; + public static IRecipe recipeTemperanceStone; + public static IRecipe recipeIncenseStick; + public static IRecipe recipeIncensePlate; + public static IRecipe recipeTerraAxe; + public static IRecipe recipeHourglass; + public static IRecipe recipeGhostRail; + public static IRecipe recipeCanopyDrum; + public static IRecipe recipeSparkChanger; + public static IRecipe recipeCocoon; + public static IRecipe recipeLuminizer; + public static IRecipe recipeDetectorLuminizer; + public static IRecipe recipeLuminizerLauncher; + public static IRecipe recipeObedienceStick; + public static IRecipe recipeCacophonium; + public static IRecipe recipeManaBomb; + public static IRecipe recipeCobweb; + public static IRecipe recipeSlimeBottle; + public static IRecipe recipeStarSword; + public static IRecipe recipeExchangeRod; + public static IRecipe recipeGreaterMagnetRing; + public static IRecipe recipeFireChakram; + public static IRecipe recipeThunderSword; + public static IRecipe recipeBellows; + public static IRecipe recipeManaweaveCloth; + public static IRecipe recipeManaweaveHelm; + public static IRecipe recipeManaweaveChest; + public static IRecipe recipeManaweaveLegs; + public static IRecipe recipeManaweaveBoots; + public static IRecipe recipeBifrost; + public static IRecipe recipeShimmerrock; + public static IRecipe recipeShimmerwoodPlanks; + public static IRecipe recipeAutocraftingHalo; + public static List recipesPavement; + public static IRecipe recipeCellBlock; + public static IRecipe recipeCorporeaRetainer; + public static IRecipe recipeTeruTeruBozu; + public static IRecipe recipeAvatar; + public static IRecipe recipeSextant; + public static List recipesAltGrassSeeds; + public static IRecipe recipeSpeedUpBelt; + public static IRecipe recipeBaubleCase; + + // Garden of Glass + public static IRecipe recipeRootToSapling; + public static IRecipe recipeRootToFertilizer; + public static IRecipe recipePebbleCobblestone; + public static IRecipe recipeMagmaToSlimeball; + public static IRecipe recipeFelPumpkin; + public static IRecipe recipeEndPortal; + + public static void init() { + if (!ConfigHandler.enableDefaultRecipes) return; + + int recipeListSize = CraftingManager.getInstance().getRecipeList().size(); + + // Lexicon Recipe + addShapelessOreDictRecipe(new ItemStack(ModItems.lexicon), "treeSapling", Items.book); + recipeLexicon = BotaniaAPI.getLatestAddedRecipe(); + + // Petal/Dye Recipes + for(int i = 0; i < 16; i++) + addShapelessOreDictRecipe(new ItemStack(ModItems.petal, 2, i), LibOreDict.FLOWER[i]); + recipesPetals = BotaniaAPI.getLatestAddedRecipes(16); + + for(int i = 0; i < 16; i++) + addShapelessOreDictRecipe(new ItemStack(ModItems.dye, 1, i), LibOreDict.PETAL[i], LibOreDict.PESTLE_AND_MORTAR); + recipesDyes = BotaniaAPI.getLatestAddedRecipes(16); + + // Petal Block Recipes + for(int i = 0; i < 16; i++) + addOreDictRecipe(new ItemStack(ModBlocks.petalBlock, 1, i), + "PPP", "PPP", "PPP", // PPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPP + 'P', LibOreDict.PETAL[i]); + recipesPetalBlocks = BotaniaAPI.getLatestAddedRecipes(16); + + // Pestle and Mortar Recipe + addOreDictRecipe(new ItemStack(ModItems.pestleAndMortar), + " S", "W ", "B ", + 'S', "stickWood", + 'W', "plankWood", + 'B', Items.bowl); + recipePestleAndMortar = BotaniaAPI.getLatestAddedRecipe(); + + // Wand of the Forest Recipes + for(int i = 0; i < 16; i++) + for(int j = 0; j < 16; j++) { + addOreDictRecipe(ItemTwigWand.forColors(i, j), + " AS", " SB", "S ", + 'A', LibOreDict.PETAL[i], + 'B', LibOreDict.PETAL[j], + 'S', LibOreDict.LIVINGWOOD_TWIG); + } + recipesTwigWand = BotaniaAPI.getLatestAddedRecipes(256); + + // Petal Apothecary Recipes + for(int i = 0; i < 16; i++) + addOreDictRecipe(new ItemStack(ModBlocks.altar), + "SPS", " C ", "CCC", + 'S', "slabCobblestone", + 'P', LibOreDict.PETAL[i], + 'C', "cobblestone"); + recipesApothecary = BotaniaAPI.getLatestAddedRecipes(16); + + // Mana Spreader Recipes + for(int i = 0; i < 16; i++) + addOreDictRecipe(new ItemStack(ModBlocks.spreader), + "WWW", "GP ", "WWW", + 'W', LibOreDict.LIVING_WOOD, + 'P', LibOreDict.PETAL[i], + 'G', Botania.gardenOfGlassLoaded ? LibOreDict.LIVING_WOOD : "ingotGold"); + recipesSpreader = BotaniaAPI.getLatestAddedRecipes(16); + + // Mana Lens Recipe + addOreDictRecipe(new ItemStack(ModItems.lens), + " S ", "SGS", " S ", + 'S', LibOreDict.MANA_STEEL, + 'G', "paneGlassColorless"); + addOreDictRecipe(new ItemStack(ModItems.lens), + " S ", "SGS", " S ", + 'S', LibOreDict.MANA_STEEL, + 'G', "blockGlassColorless"); + recipesManaLens = BotaniaAPI.getLatestAddedRecipes(2); + + // Mana Pool Recipe + addOreDictRecipe(new ItemStack(ModBlocks.pool), + "R R", "RRR", + 'R', LibOreDict.LIVING_ROCK); + recipePool = BotaniaAPI.getLatestAddedRecipe(); + + // Diluted Mana Pool Recipe + addOreDictRecipe(new ItemStack(ModBlocks.pool, 1, 2), + "R R", "RRR", + 'R', new ItemStack(ModFluffBlocks.livingrockSlab)); + recipePoolDiluted = BotaniaAPI.getLatestAddedRecipe(); + + // Fabulous Mana Pool Recipe + addOreDictRecipe(new ItemStack(ModBlocks.pool, 1, 3), + "R R", "RRR", + 'R', new ItemStack(ModBlocks.shimmerrock)); + recipePoolFabulous = BotaniaAPI.getLatestAddedRecipe(); + + // Runic Altar Recipe + addOreDictRecipe(new ItemStack(ModBlocks.runeAltar), + "SSS", "SPS", + 'S', LibOreDict.LIVING_ROCK, + 'P', LibOreDict.MANA_PEARL); + addOreDictRecipe(new ItemStack(ModBlocks.runeAltar), + "SSS", "SDS", + 'S', LibOreDict.LIVING_ROCK, + 'D', LibOreDict.MANA_DIAMOND); + recipesRuneAltar = BotaniaAPI.getLatestAddedRecipes(2); + + // Lens Recipes + addShapelessOreDictRecipe(new ItemStack(ModItems.lens, 1, 1), new ItemStack(ModItems.lens), LibOreDict.RUNE[3]); + recipeLensVelocity = BotaniaAPI.getLatestAddedRecipe(); + + addShapelessOreDictRecipe(new ItemStack(ModItems.lens, 1, 2), new ItemStack(ModItems.lens), LibOreDict.RUNE[1]); + recipeLensPotency = BotaniaAPI.getLatestAddedRecipe(); + + addShapelessOreDictRecipe(new ItemStack(ModItems.lens, 1, 3), new ItemStack(ModItems.lens), LibOreDict.RUNE[2]); + recipeLensResistance = BotaniaAPI.getLatestAddedRecipe(); + + addShapelessOreDictRecipe(new ItemStack(ModItems.lens, 1, 4), new ItemStack(ModItems.lens), LibOreDict.RUNE[0]); + recipeLensEfficiency = BotaniaAPI.getLatestAddedRecipe(); + + addShapelessOreDictRecipe(new ItemStack(ModItems.lens, 1, 5), new ItemStack(ModItems.lens), LibOreDict.RUNE[5]); + recipeLensBounce = BotaniaAPI.getLatestAddedRecipe(); + + addShapelessOreDictRecipe(new ItemStack(ModItems.lens, 1, 6), new ItemStack(ModItems.lens), LibOreDict.RUNE[7]); + recipeLensGravity = BotaniaAPI.getLatestAddedRecipe(); + + addOreDictRecipe(new ItemStack(ModItems.lens, 1, 7), + " P ", "ALA", " R ", + 'P', new ItemStack(Blocks.piston), + 'R', "dustRedstone", + 'A', "gemLapis", + 'L', new ItemStack(ModItems.lens)); + recipeLensBore = BotaniaAPI.getLatestAddedRecipe(); + + addShapelessOreDictRecipe(new ItemStack(ModItems.lens, 1, 8), new ItemStack(ModItems.lens), LibOreDict.RUNE[13]); + recipeLensDamaging = BotaniaAPI.getLatestAddedRecipe(); + + addShapelessOreDictRecipe(new ItemStack(ModItems.lens, 1, 9), new ItemStack(ModItems.lens), new ItemStack(ModBlocks.platform)); + recipeLensPhantom = BotaniaAPI.getLatestAddedRecipe(); + + addShapelessOreDictRecipe(new ItemStack(ModItems.lens, 1, 10), new ItemStack(ModItems.lens), "ingotIron", "ingotGold"); + recipeLensMagnet = BotaniaAPI.getLatestAddedRecipe(); + + addShapelessOreDictRecipe(new ItemStack(ModItems.lens, 1, 11), new ItemStack(ModItems.lens), LibOreDict.RUNE[14]); + recipeLensExplosive = BotaniaAPI.getLatestAddedRecipe(); + + // Unstable Block Recipes + for(int i = 0; i < 16; i++) + addOreDictRecipe(new ItemStack(ModBlocks.unstableBlock, 2, i), + "OPO", "PMP", "OPO", + 'O', new ItemStack(Blocks.obsidian), + 'P', LibOreDict.PETAL[i], + 'M', new ItemStack(Items.ender_pearl)); + recipesUnstableBlocks = BotaniaAPI.getLatestAddedRecipes(16); + + // Mana Pylon Recipe + addOreDictRecipe(new ItemStack(ModBlocks.pylon), + " G ", "MDM", " G ", + 'G', "ingotGold", + 'M', LibOreDict.MANA_STEEL, + 'D', LibOreDict.MANA_DIAMOND); + recipePylon = BotaniaAPI.getLatestAddedRecipe(); + + // Mana Distributor + addOreDictRecipe(new ItemStack(ModBlocks.distributor), + "RRR", "S S", "RRR", + 'R', LibOreDict.LIVING_ROCK, + 'S', LibOreDict.MANA_STEEL); + recipeDistributor = BotaniaAPI.getLatestAddedRecipe(); + + // Livingrock Decorative Blocks + addOreDictRecipe(new ItemStack(ModBlocks.livingrock, 4, 1), + "RR", "RR", + 'R', LibOreDict.LIVING_ROCK); + recipeLivingrockDecor1 = BotaniaAPI.getLatestAddedRecipe(); + addShapelessOreDictRecipe(new ItemStack(ModBlocks.livingrock, 1, 2), new ItemStack(ModBlocks.livingrock, 1, 1), new ItemStack(Items.wheat_seeds)); + recipeLivingrockDecor2 = BotaniaAPI.getLatestAddedRecipe(); + addShapelessOreDictRecipe(new ItemStack(ModBlocks.livingrock, 2, 3), new ItemStack(ModBlocks.livingrock, 1, 1), "cobblestone"); + recipeLivingrockDecor3 = BotaniaAPI.getLatestAddedRecipe(); + addOreDictRecipe(new ItemStack(ModBlocks.livingrock, 4, 4), + "RR", "RR", + 'R', new ItemStack(ModBlocks.livingrock, 1, 1)); + recipeLivingrockDecor4 = BotaniaAPI.getLatestAddedRecipe(); + + // Livingwood Decorative Blocks + addShapelessOreDictRecipe(new ItemStack(ModBlocks.livingwood, 4, 1), LibOreDict.LIVING_WOOD); + recipeLivingwoodDecor1 = BotaniaAPI.getLatestAddedRecipe(); + addShapelessOreDictRecipe(new ItemStack(ModBlocks.livingwood, 1, 2), new ItemStack(ModBlocks.livingwood, 1, 1), new ItemStack(Items.wheat_seeds)); + recipeLivingwoodDecor2 = BotaniaAPI.getLatestAddedRecipe(); + addOreDictRecipe(new ItemStack(ModBlocks.livingwood, 4, 3), + "WW", "WW", + 'W', new ItemStack(ModBlocks.livingwood, 1, 1)); + recipeLivingwoodDecor3 = BotaniaAPI.getLatestAddedRecipe(); + addOreDictRecipe(new ItemStack(ModBlocks.livingwood, 4, 4), + " W ", "W W", " W ", + 'W', new ItemStack(ModBlocks.livingwood, 1, 1)); + recipeLivingwoodDecor4 = BotaniaAPI.getLatestAddedRecipe(); + addShapelessOreDictRecipe(new ItemStack(ModBlocks.livingwood, 1, 5), LibOreDict.LIVING_WOOD, "dustGlowstone"); + recipeLivingwoodDecor5 = BotaniaAPI.getLatestAddedRecipe(); + + // Dreamwood Decorative Blocks + addShapelessOreDictRecipe(new ItemStack(ModBlocks.dreamwood, 4, 1), LibOreDict.DREAM_WOOD); + addShapelessOreDictRecipe(new ItemStack(ModBlocks.dreamwood, 1, 2), new ItemStack(ModBlocks.dreamwood, 1, 1), new ItemStack(Items.wheat_seeds)); + addOreDictRecipe(new ItemStack(ModBlocks.dreamwood, 4, 3), + "WW", "WW", + 'W', new ItemStack(ModBlocks.dreamwood, 1, 1)); + addOreDictRecipe(new ItemStack(ModBlocks.dreamwood, 4, 4), + " W ", "W W", " W ", + 'W', new ItemStack(ModBlocks.dreamwood, 1, 1)); + addShapelessOreDictRecipe(new ItemStack(ModBlocks.dreamwood, 1, 5), LibOreDict.DREAM_WOOD, "dustGlowstone"); + + // Mana Beacon Recipe + for(int i = 0; i < 16; i++) + addOreDictRecipe(new ItemStack(ModBlocks.manaBeacon, 1, i), + " B ", "BPB", " B ", + 'B', new ItemStack(ModBlocks.unstableBlock, 1, i), + 'P', LibOreDict.MANA_PEARL); + recipesManaBeacons = BotaniaAPI.getLatestAddedRecipes(16); + + // Signal Flare Recipe + for(int i = 0; i < 16; i++) + addOreDictRecipe(ItemSignalFlare.forColor(i), + "I ", " B", "W ", + 'B', new ItemStack(ModBlocks.manaBeacon, 1, i), + 'I', "ingotIron", + 'W', LibOreDict.LIVING_WOOD); + recipesSignalFlares = BotaniaAPI.getLatestAddedRecipes(16); + + // Mana Void Recipe + addOreDictRecipe(new ItemStack(ModBlocks.manaVoid), + "SSS", "O O", "SSS", + 'S', LibOreDict.LIVING_ROCK, + 'O', new ItemStack(Blocks.obsidian)); + recipeManaVoid = BotaniaAPI.getLatestAddedRecipe(); + + // Mana Tablet Recipe + addOreDictRecipe(new ItemStack(ModItems.manaTablet, 1, 10000), + "SSS", "SPS", "SSS", + 'S', LibOreDict.LIVING_ROCK, + 'P', LibOreDict.MANA_PEARL); + addOreDictRecipe(new ItemStack(ModItems.manaTablet, 1, 10000), + "SSS", "SDS", "SSS", + 'S', LibOreDict.LIVING_ROCK, + 'D', LibOreDict.MANA_DIAMOND); + recipesManaTablet = BotaniaAPI.getLatestAddedRecipes(2); + + // Mana Detector Recipe + addOreDictRecipe(new ItemStack(ModBlocks.manaDetector), + "RSR", "SCS", "RSR", + 'R', "dustRedstone", + 'C', new ItemStack(Items.comparator), + 'S', LibOreDict.LIVING_ROCK); + recipeManaDetector = BotaniaAPI.getLatestAddedRecipe(); + + // Mana Blaster Recipe + addOreDictRecipe(new ItemStack(ModItems.manaGun), + "SMD", " WT", " W", + 'S', new ItemStack(ModBlocks.spreader, 1, 1), + 'M', LibOreDict.RUNE[8], + 'D', LibOreDict.MANA_DIAMOND, + 'T', new ItemStack(Blocks.tnt), + 'W', LibOreDict.LIVING_WOOD); + recipeManaBlaster = BotaniaAPI.getLatestAddedRecipe(); + + // Spreader Turntable Recipe + addOreDictRecipe(new ItemStack(ModBlocks.turntable), + "WWW", "WPW", "WWW", + 'W', LibOreDict.LIVING_WOOD, + 'P', Blocks.sticky_piston); + recipeTurntable = BotaniaAPI.getLatestAddedRecipe(); + + // Fertilizer Recipes + GameRegistry.addShapelessRecipe(new ItemStack(ModItems.fertilizer, Botania.gardenOfGlassLoaded ? 3 : 1), new ItemStack(Items.dye, 1, 15), new ItemStack(ModItems.dye, 1, Short.MAX_VALUE), new ItemStack(ModItems.dye, 1, Short.MAX_VALUE), new ItemStack(ModItems.dye, 1, Short.MAX_VALUE), new ItemStack(ModItems.dye, 1, Short.MAX_VALUE)); + recipeFertilizerPowder = BotaniaAPI.getLatestAddedRecipe(); + GameRegistry.addShapelessRecipe(new ItemStack(ModItems.fertilizer), new ItemStack(Items.dye, 1, 15), new ItemStack(Items.dye, 1, 11), new ItemStack(Items.dye, 1, 11), new ItemStack(Items.dye, 1, 1), new ItemStack(Items.dye, 1, 1)); + recipeFerilizerDye = BotaniaAPI.getLatestAddedRecipe(); + + // Livingwood Twig Recipe + addOreDictRecipe(new ItemStack(ModItems.manaResource, 1, 3), + "W", "W", + 'W', LibOreDict.LIVING_WOOD); + recipeLivingwoodTwig = BotaniaAPI.getLatestAddedRecipe(); + + // Rod of the Lands Recipe + addOreDictRecipe(new ItemStack(ModItems.dirtRod), + " D", " T ", "E ", + 'D', new ItemStack(Blocks.dirt), + 'T', LibOreDict.LIVINGWOOD_TWIG, + 'E', LibOreDict.RUNE[2]); + recipeDirtRod = BotaniaAPI.getLatestAddedRecipe(); + + // Terra Firma Rod Recipe + addOreDictRecipe(new ItemStack(ModItems.terraformRod), + " WT", "ARS", "GM ", + 'T', LibOreDict.TERRA_STEEL, + 'R', new ItemStack(ModItems.dirtRod), + 'G', new ItemStack(ModItems.grassSeeds), + 'W', LibOreDict.RUNE[7], + 'S', LibOreDict.RUNE[4], + 'M', LibOreDict.RUNE[5], + 'A', LibOreDict.RUNE[6]); + recipeTerraformRod = BotaniaAPI.getLatestAddedRecipe(); + + // Redstone Mana Spreader Recipe + GameRegistry.addRecipe(new ShapelessOreRecipe(new ItemStack(ModBlocks.spreader, 1, 1), + new ItemStack(ModBlocks.spreader), "dustRedstone")); + recipeRedstoneSpreader = BotaniaAPI.getLatestAddedRecipe(); + + // Mana Miror Recipe + addOreDictRecipe(new ItemStack(ModItems.manaMirror), + " PR", " SI", "T ", + 'P', LibOreDict.MANA_PEARL, + 'R', LibOreDict.LIVING_ROCK, + 'S', LibOreDict.LIVINGWOOD_TWIG, + 'I', LibOreDict.TERRA_STEEL, + 'T', new ItemStack(ModItems.manaTablet, 1, Short.MAX_VALUE)); + recipeManaMirror = BotaniaAPI.getLatestAddedRecipe(); + + // Mana Armor & Tools Recipes + addOreDictRecipe(new ItemStack(ModItems.manasteelHelm), + "SSS", "S S", + 'S', LibOreDict.MANA_STEEL); + recipeManasteelHelm = BotaniaAPI.getLatestAddedRecipe(); + addOreDictRecipe(new ItemStack(ModItems.manasteelChest), + "S S", "SSS", "SSS", + 'S', LibOreDict.MANA_STEEL); + recipeManasteelChest = BotaniaAPI.getLatestAddedRecipe(); + addOreDictRecipe(new ItemStack(ModItems.manasteelLegs), + "SSS", "S S", "S S", + 'S', LibOreDict.MANA_STEEL); + recipeManasteelLegs = BotaniaAPI.getLatestAddedRecipe(); + addOreDictRecipe(new ItemStack(ModItems.manasteelBoots), + "S S", "S S", + 'S', LibOreDict.MANA_STEEL); + recipeManasteelBoots = BotaniaAPI.getLatestAddedRecipe(); + addOreDictRecipe(new ItemStack(ModItems.manasteelPick), + "SSS", " T ", " T ", + 'S', LibOreDict.MANA_STEEL, + 'T', LibOreDict.LIVINGWOOD_TWIG); + recipeManasteelPick = BotaniaAPI.getLatestAddedRecipe(); + addOreDictRecipe(new ItemStack(ModItems.manasteelShovel), + "S", "T", "T", + 'S', LibOreDict.MANA_STEEL, + 'T', LibOreDict.LIVINGWOOD_TWIG); + recipeManasteelShovel = BotaniaAPI.getLatestAddedRecipe(); + addOreDictRecipe(new ItemStack(ModItems.manasteelAxe), + "SS", "TS", "T ", + 'S', LibOreDict.MANA_STEEL, + 'T', LibOreDict.LIVINGWOOD_TWIG); + recipeManasteelAxe = BotaniaAPI.getLatestAddedRecipe(); + addOreDictRecipe(new ItemStack(ModItems.manasteelSword), + "S", "S", "T", + 'S', LibOreDict.MANA_STEEL, + 'T', LibOreDict.LIVINGWOOD_TWIG); + recipeManasteelSword = BotaniaAPI.getLatestAddedRecipe(); + addOreDictRecipe(new ItemStack(ModItems.manasteelShears), + "S ", " S", + 'S', LibOreDict.MANA_STEEL); + recipeManasteelShears = BotaniaAPI.getLatestAddedRecipe(); + + // Horn of the Wild Recipe + addOreDictRecipe(new ItemStack(ModItems.grassHorn), + " W ", "WSW", "WW ", + 'W', LibOreDict.LIVING_WOOD, + 'S', new ItemStack(ModItems.grassSeeds)); + recipeGrassHorn = BotaniaAPI.getLatestAddedRecipe(); + + // Terrasteel Armor Recipes + addOreDictRecipe(new ItemStack(ModItems.terrasteelHelmRevealing), + "TRT", "SAS", " S ", + 'T', LibOreDict.LIVINGWOOD_TWIG, + 'S', LibOreDict.TERRA_STEEL, + 'R', LibOreDict.RUNE[4], + 'A', new ItemStack(ModItems.manasteelHelmRevealing)); + addOreDictRecipe(new ItemStack(ModItems.terrasteelHelm), + "TRT", "SAS", " S ", + 'T', LibOreDict.LIVINGWOOD_TWIG, + 'S', LibOreDict.TERRA_STEEL, + 'R', LibOreDict.RUNE[4], + 'A', new ItemStack(ModItems.manasteelHelm)); + recipeTerrasteelHelm = BotaniaAPI.getLatestAddedRecipe(); + addOreDictRecipe(new ItemStack(ModItems.terrasteelChest), + "TRT", "SAS", " S ", + 'T', LibOreDict.LIVINGWOOD_TWIG, + 'S', LibOreDict.TERRA_STEEL, + 'R', LibOreDict.RUNE[5], + 'A', new ItemStack(ModItems.manasteelChest)); + recipeTerrasteelChest = BotaniaAPI.getLatestAddedRecipe(); + addOreDictRecipe(new ItemStack(ModItems.terrasteelLegs), + "TRT", "SAS", " S ", + 'T', LibOreDict.LIVINGWOOD_TWIG, + 'S', LibOreDict.TERRA_STEEL, + 'R', LibOreDict.RUNE[6], + 'A', new ItemStack(ModItems.manasteelLegs)); + recipeTerrasteelLegs = BotaniaAPI.getLatestAddedRecipe(); + addOreDictRecipe(new ItemStack(ModItems.terrasteelBoots), + "TRT", "SAS", " S ", + 'T', LibOreDict.LIVINGWOOD_TWIG, + 'S', LibOreDict.TERRA_STEEL, + 'R', LibOreDict.RUNE[7], + 'A', new ItemStack(ModItems.manasteelBoots)); + recipeTerrasteelBoots = BotaniaAPI.getLatestAddedRecipe(); + + // Terra Blade Recipe + addOreDictRecipe(new ItemStack(ModItems.terraSword), + "I", "I", "S", + 'I', LibOreDict.TERRA_STEEL, + 'S', LibOreDict.LIVINGWOOD_TWIG); + recipeTerraSword = BotaniaAPI.getLatestAddedRecipe(); + + // Tiny Planet Recipe + addOreDictRecipe(new ItemStack(ModItems.tinyPlanet), + "LSL", "SPS", "LSL", + 'S', "stone", + 'L', LibOreDict.LIVING_ROCK, + 'P', LibOreDict.MANA_PEARL); + recipeTinyPlanet = BotaniaAPI.getLatestAddedRecipe(); + + // Mana Band Recipe + addOreDictRecipe(new ItemStack(ModItems.manaRing), + "TI ", "I I", " I ", + 'T', new ItemStack(ModItems.manaTablet, 1, Short.MAX_VALUE), + 'I', LibOreDict.MANA_STEEL); + recipeManaRing = BotaniaAPI.getLatestAddedRecipe(); + + // Aura Band Recipe + addOreDictRecipe(new ItemStack(ModItems.auraRing), + "RI ", "I I", " I ", + 'R', LibOreDict.RUNE[8], + 'I', LibOreDict.MANA_STEEL); + recipeAuraRing = BotaniaAPI.getLatestAddedRecipe(); + + // Greater Mana Band Recipe + addShapelessOreDictRecipe(new ItemStack(ModItems.manaRingGreater), LibOreDict.TERRA_STEEL, new ItemStack(ModItems.manaRing)); + recipeGreaterManaRing = BotaniaAPI.getLatestAddedRecipe(); + + // Greater Aura Band Recipe + addShapelessOreDictRecipe(new ItemStack(ModItems.auraRingGreater), LibOreDict.TERRA_STEEL, new ItemStack(ModItems.auraRing)); + recipeGreaterAuraRing = BotaniaAPI.getLatestAddedRecipe(); + + // Soujourner's Belt Recipe + addOreDictRecipe(new ItemStack(ModItems.travelBelt), + "EL ", "L L", "SLA", + 'E', LibOreDict.RUNE[2], + 'A', LibOreDict.RUNE[3], + 'S', LibOreDict.MANA_STEEL, + 'L', new ItemStack(Items.leather)); + recipeTravelBelt = BotaniaAPI.getLatestAddedRecipe(); + + // Tectonic Girdle Recipe + addOreDictRecipe(new ItemStack(ModItems.knockbackBelt), + "AL ", "L L", "SLE", + 'E', LibOreDict.RUNE[2], + 'A', LibOreDict.RUNE[1], + 'S', LibOreDict.MANA_STEEL, + 'L', new ItemStack(Items.leather)); + recipeKnocbackBelt = BotaniaAPI.getLatestAddedRecipe(); + + // Snowflake Pendant Recipe + addOreDictRecipe(new ItemStack(ModItems.icePendant), + "WS ", "S S", "MSR", + 'S', new ItemStack(Items.string), + 'M', LibOreDict.MANA_STEEL, + 'R', LibOreDict.RUNE[0], + 'W', LibOreDict.RUNE[7]); + recipeIcePendant = BotaniaAPI.getLatestAddedRecipe(); + + // Pyroclast Pendant Recipe + addOreDictRecipe(new ItemStack(ModItems.lavaPendant), + "MS ", "S S", "DSF", + 'S', new ItemStack(Items.string), + 'D', LibOreDict.MANA_STEEL, + 'M', LibOreDict.RUNE[5], + 'F', LibOreDict.RUNE[1]); + recipeFirePendant = BotaniaAPI.getLatestAddedRecipe(); + + // Golden Laurel Crown Recipe + addOreDictRecipe(new ItemStack(ModItems.goldLaurel), + "G G", "LEL", "LLL", + 'G', "ingotGold", + 'L', "treeLeaves", + 'E', LibOreDict.LIFE_ESSENCE); + recipeGoldenLaurel = BotaniaAPI.getLatestAddedRecipe(); + + // Tiny Planet Block Recipe + addOreDictRecipe(new ItemStack(ModBlocks.tinyPlanet), + "SSS", "SPS", "SSS", + 'S', "stone", + 'P', ModItems.tinyPlanet); + recipeTinyPlanetBlock = BotaniaAPI.getLatestAddedRecipe(); + + // Alchemy Catalyst Recipe + addOreDictRecipe(new ItemStack(ModBlocks.alchemyCatalyst), + "SGS", "BPB", "SGS", + 'S', LibOreDict.LIVING_ROCK, + 'G', "ingotGold", + 'B', new ItemStack(Items.brewing_stand), + 'P', LibOreDict.MANA_PEARL); + recipeAlchemyCatalyst = BotaniaAPI.getLatestAddedRecipe(); + + // Open Crate Recipe + GameRegistry.addRecipe(new ItemStack(ModBlocks.openCrate), + "WWW", "W W", "W W", + 'W', new ItemStack(ModBlocks.livingwood, 1, 1)); + recipeOpenCrate = BotaniaAPI.getLatestAddedRecipe(); + + // Eye of the Ancients Recipe + addOreDictRecipe(new ItemStack(ModBlocks.forestEye), + "MSM", "SES", "MSM", + 'M', LibOreDict.MANA_STEEL, + 'S', LibOreDict.LIVING_ROCK, + 'E', new ItemStack(Items.ender_eye)); + recipeForestEye = BotaniaAPI.getLatestAddedRecipe(); + + // Redstone Root Recipe + GameRegistry.addRecipe(new ShapelessOreRecipe(new ItemStack(ModItems.manaResource, 1, 6), "dustRedstone", new ItemStack(Blocks.tallgrass, 1, 1))); + recipeRedstoneRoot = BotaniaAPI.getLatestAddedRecipe(); + + // Drum of the Wild Recipe + addOreDictRecipe(new ItemStack(ModBlocks.forestDrum), + "WLW", "WHW", "WLW", + 'W', LibOreDict.LIVING_WOOD, + 'L', new ItemStack(Items.leather), + 'H', new ItemStack(ModItems.grassHorn)); + recipeForestDrum = BotaniaAPI.getLatestAddedRecipe(); + + // Ring of Chordata Recipe + addOreDictRecipe(new ItemStack(ModItems.waterRing), + "WMP", "M M", "SM ", + 'W', LibOreDict.RUNE[0], + 'M', LibOreDict.MANA_STEEL, + 'P', new ItemStack(Items.fish, 1, 3), + 'S', new ItemStack(Items.fish, 1, 1)); + recipeWaterRing = BotaniaAPI.getLatestAddedRecipe(); + + // Ring of the Mantle Recipe + addOreDictRecipe(new ItemStack(ModItems.miningRing), + "EMP", "M M", " M ", + 'E', LibOreDict.RUNE[2], + 'M', LibOreDict.MANA_STEEL, + 'P', new ItemStack(Items.golden_pickaxe)); + recipeMiningRing = BotaniaAPI.getLatestAddedRecipe(); + + // Ring of Magnetization Recipe + addOreDictRecipe(new ItemStack(ModItems.magnetRing), + "LM ", "M M", " M ", + 'L', new ItemStack(ModItems.lens, 1, 10), + 'M', LibOreDict.MANA_STEEL); + recipeMagnetRing = BotaniaAPI.getLatestAddedRecipe(); + + // Terra Shatterer Recipe + addOreDictRecipe(new ItemStack(ModItems.terraPick), + "ITI", "ILI", " L ", + 'T', new ItemStack(ModItems.manaTablet, 1, Short.MAX_VALUE), + 'I', LibOreDict.TERRA_STEEL, + 'L', LibOreDict.LIVINGWOOD_TWIG); + recipeTerraPick = BotaniaAPI.getLatestAddedRecipe(); + + // Charm of the Diva Recipe + addOreDictRecipe(new ItemStack(ModItems.divaCharm), + "LGP", " HG", " GL", + 'L', LibOreDict.LIFE_ESSENCE, + 'G', "ingotGold", + 'H', LibOreDict.RUNE[15], + 'P', new ItemStack(ModItems.tinyPlanet)); + recipeDivaCharm = BotaniaAPI.getLatestAddedRecipe(); + + // Flugel Tiara Recipe + addOreDictRecipe(new ItemStack(ModItems.flightTiara), + "LLL", "ILI", "FEF", + 'L', LibOreDict.LIFE_ESSENCE, + 'I', LibOreDict.ELEMENTIUM, + 'F', new ItemStack(Items.feather), + 'E', LibOreDict.ENDER_AIR_BOTTLE); + recipeFlightTiara = BotaniaAPI.getLatestAddedRecipe(); + + // Glimmering Flowers Recipes + for(int i = 0; i < 16; i++) + addShapelessOreDictRecipe(new ItemStack(ModBlocks.shinyFlower, 1, i), "dustGlowstone", "dustGlowstone", LibOreDict.FLOWER[i]); + recipesShinyFlowers = BotaniaAPI.getLatestAddedRecipes(16); + + // Abstruse Platform Recipe + addOreDictRecipe(new ItemStack(ModBlocks.platform, 2), + "343", "0P0", + '0', new ItemStack(ModBlocks.livingwood, 1, 0), + '3', new ItemStack(ModBlocks.livingwood, 1, 3), + '4', new ItemStack(ModBlocks.livingwood, 1, 4), + 'P', LibOreDict.MANA_PEARL); + recipePlatform = BotaniaAPI.getLatestAddedRecipe(); + + // Soulscribe Recipe + addOreDictRecipe(new ItemStack(ModItems.enderDagger), + "P", "S", "T", + 'P', LibOreDict.MANA_PEARL, + 'S', LibOreDict.MANA_STEEL, + 'T', LibOreDict.LIVINGWOOD_TWIG); + recipeEnderDagger = BotaniaAPI.getLatestAddedRecipe(); + + // Quartz Recipes + if(ConfigHandler.darkQuartzEnabled) + recipeDarkQuartz = addQuartzRecipes(0, Items.coal, ModFluffBlocks.darkQuartz, ModFluffBlocks.darkQuartzStairs, ModFluffBlocks.darkQuartzSlab); + addQuartzRecipes(1, null, ModFluffBlocks.manaQuartz, ModFluffBlocks.manaQuartzStairs, ModFluffBlocks.manaQuartzSlab); + recipeBlazeQuartz = addQuartzRecipes(2, Items.blaze_powder, ModFluffBlocks.blazeQuartz, ModFluffBlocks.blazeQuartzStairs, ModFluffBlocks.blazeQuartzSlab); + + GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(ModItems.quartz, 8, 3), + "QQQ", "QCQ", "QQQ", + 'Q', "gemQuartz", + 'C', new ItemStack(Blocks.red_flower, 1, 2))); + GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(ModItems.quartz, 8, 3), + "QQQ", "QCQ", "QQQ", + 'Q', "gemQuartz", + 'C', new ItemStack(Blocks.red_flower, 1, 7))); + GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(ModItems.quartz, 8, 3), + "QQQ", "QCQ", "QQQ", + 'Q', "gemQuartz", + 'C', new ItemStack(Blocks.double_plant, 1, 1))); + GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(ModItems.quartz, 8, 3), + "QQQ", "QCQ", "QQQ", + 'Q', "gemQuartz", + 'C', new ItemStack(Blocks.double_plant, 1, 5))); + recipesLavenderQuartz = BotaniaAPI.getLatestAddedRecipes(4); + addQuartzRecipes(3, null, ModFluffBlocks.lavenderQuartz, ModFluffBlocks.lavenderQuartzStairs, ModFluffBlocks.lavenderQuartzSlab); + + recipeRedQuartz = addQuartzRecipes(4, Items.redstone, ModFluffBlocks.redQuartz, ModFluffBlocks.redQuartzStairs, ModFluffBlocks.redQuartzSlab); + addQuartzRecipes(5, null, ModFluffBlocks.elfQuartz, ModFluffBlocks.elfQuartzStairs, ModFluffBlocks.elfQuartzSlab); + + recipeSunnyQuartz = addQuartzRecipes(6, Item.getItemFromBlock(Blocks.double_plant), ModFluffBlocks.sunnyQuartz, ModFluffBlocks.sunnyQuartzStairs, ModFluffBlocks.sunnyQuartzSlab); + + // Alfheim Portal Recipe + addOreDictRecipe(new ItemStack(ModBlocks.alfPortal), + "WTW", "WTW", "WTW", + 'W', LibOreDict.LIVING_WOOD, + 'T', LibOreDict.TERRASTEEL_NUGGET); + recipeAlfPortal = BotaniaAPI.getLatestAddedRecipe(); + + // Natura Pylon Recipe + addOreDictRecipe(new ItemStack(ModBlocks.pylon, 1, 1), + " T ", "TPT", " E ", + 'T', LibOreDict.TERRASTEEL_NUGGET, + 'P', new ItemStack(ModBlocks.pylon), + 'E', new ItemStack(Items.ender_eye)); + recipeNaturaPylon = BotaniaAPI.getLatestAddedRecipe(); + + // Rod of the Seas Recipe + addOreDictRecipe(new ItemStack(ModItems.waterRod), + " B", " T ", "R ", + 'B', new ItemStack(Items.potionitem), + 'T', LibOreDict.LIVINGWOOD_TWIG, + 'R', LibOreDict.RUNE[0]); + recipeWaterRod = BotaniaAPI.getLatestAddedRecipe(); + + // Elementium Armor & Tools Recipes + addOreDictRecipe(new ItemStack(ModItems.elementiumHelm), + "SSS", "S S", + 'S', LibOreDict.ELEMENTIUM); + recipeElementiumHelm = BotaniaAPI.getLatestAddedRecipe(); + addOreDictRecipe(new ItemStack(ModItems.elementiumChest), + "S S", "SSS", "SSS", + 'S', LibOreDict.ELEMENTIUM); + recipeElementiumChest = BotaniaAPI.getLatestAddedRecipe(); + addOreDictRecipe(new ItemStack(ModItems.elementiumLegs), + "SSS", "S S", "S S", + 'S', LibOreDict.ELEMENTIUM); + recipeElementiumLegs = BotaniaAPI.getLatestAddedRecipe(); + addOreDictRecipe(new ItemStack(ModItems.elementiumBoots), + "S S", "S S", + 'S', LibOreDict.ELEMENTIUM); + recipeElementiumBoots = BotaniaAPI.getLatestAddedRecipe(); + addOreDictRecipe(new ItemStack(ModItems.elementiumPick), + "SSS", " T ", " T ", + 'S', LibOreDict.ELEMENTIUM, + 'T', LibOreDict.DREAMWOOD_TWIG); + recipeElementiumPick = BotaniaAPI.getLatestAddedRecipe(); + addOreDictRecipe(new ItemStack(ModItems.elementiumShovel), + "S", "T", "T", + 'S', LibOreDict.ELEMENTIUM, + 'T', LibOreDict.DREAMWOOD_TWIG); + recipeElementiumShovel = BotaniaAPI.getLatestAddedRecipe(); + addOreDictRecipe(new ItemStack(ModItems.elementiumAxe), + "SS", "TS", "T ", + 'S', LibOreDict.ELEMENTIUM, + 'T', LibOreDict.DREAMWOOD_TWIG); + recipeElementiumAxe = BotaniaAPI.getLatestAddedRecipe(); + addOreDictRecipe(new ItemStack(ModItems.elementiumSword), + "S", "S", "T", + 'S', LibOreDict.ELEMENTIUM, + 'T', LibOreDict.DREAMWOOD_TWIG); + recipeElementiumSword = BotaniaAPI.getLatestAddedRecipe(); + addOreDictRecipe(new ItemStack(ModItems.elementiumShears), + "S ", " S", + 'S', LibOreDict.ELEMENTIUM); + recipeElementiumShears = BotaniaAPI.getLatestAddedRecipe(); + + // Extrapolated Bucket Recipe + addOreDictRecipe(new ItemStack(ModItems.openBucket), + "E E", " E ", + 'E', LibOreDict.ELEMENTIUM); + recipeOpenBucket = BotaniaAPI.getLatestAddedRecipe(); + + // Conjuration Catalyst Recipe + addOreDictRecipe(new ItemStack(ModBlocks.conjurationCatalyst), + "SBS", "GPG", "SGS", + 'S', LibOreDict.LIVING_ROCK, + 'G', LibOreDict.ELEMENTIUM, + 'B',LibOreDict.PIXIE_DUST, + 'P', new ItemStack(ModBlocks.alchemyCatalyst)); + recipeConjurationCatalyst = BotaniaAPI.getLatestAddedRecipe(); + + // Life Aggregator Recipe + addOreDictRecipe(new ItemStack(ModItems.spawnerMover), + "EIE", "ADA", "EIE", + 'E', LibOreDict.LIFE_ESSENCE, + 'I', LibOreDict.ELEMENTIUM, + 'A', LibOreDict.ENDER_AIR_BOTTLE, + 'D', LibOreDict.DRAGONSTONE); + recipeSpawnerMover = BotaniaAPI.getLatestAddedRecipe(); + + // Great Fairy Ring Recipe + addOreDictRecipe(new ItemStack(ModItems.pixieRing), + "DE ", "E E", " E ", + 'D', LibOreDict.PIXIE_DUST, + 'E', LibOreDict.ELEMENTIUM); + recipePixieRing = BotaniaAPI.getLatestAddedRecipe(); + + // Globetrotter's Sash Recipe + addOreDictRecipe(new ItemStack(ModItems.superTravelBelt), + "E ", " S ", "L E", + 'E', LibOreDict.ELEMENTIUM, + 'L', LibOreDict.LIFE_ESSENCE, + 'S', new ItemStack(ModItems.travelBelt)); + recipeSuperTravelBelt = BotaniaAPI.getLatestAddedRecipe(); + + // Rod of Bifrost Recipe + addOreDictRecipe(new ItemStack(ModItems.rainbowRod), + " PD", " EP", "E ", + 'P', LibOreDict.PIXIE_DUST, + 'E', LibOreDict.ELEMENTIUM, + 'D', LibOreDict.DRAGONSTONE); + recipeRainbowRod = BotaniaAPI.getLatestAddedRecipe(); + + // Spectral Platform Recipe + addOreDictRecipe(new ItemStack(ModBlocks.platform, 2, 1), + "343", "0D0", + '0', new ItemStack(ModBlocks.dreamwood, 1, 0), + '3', new ItemStack(ModBlocks.dreamwood, 1, 3), + '4', new ItemStack(ModBlocks.dreamwood, 1, 4), + 'D', LibOreDict.PIXIE_DUST); + recipeSpectralPlatform = BotaniaAPI.getLatestAddedRecipe(); + + // Elven Mana Spreader Recipes + for(int i = 0; i < 16; i++) + addOreDictRecipe(new ItemStack(ModBlocks.spreader, 1, 2), + "WWW", "EP ", "WWW", + 'W', LibOreDict.DREAM_WOOD, + 'P', LibOreDict.PETAL[i], + 'E', LibOreDict.ELEMENTIUM); + recipesDreamwoodSpreader = BotaniaAPI.getLatestAddedRecipes(16); + + // Rod of the Skies Recipe + addOreDictRecipe(new ItemStack(ModItems.tornadoRod), + " F", " T ", "R ", + 'F', new ItemStack(Items.feather), + 'T', LibOreDict.LIVINGWOOD_TWIG, + 'R', LibOreDict.RUNE[3]); + recipeTornadoRod = BotaniaAPI.getLatestAddedRecipe(); + + // Rod of the Hells Recipe + addOreDictRecipe(new ItemStack(ModItems.fireRod), + " F", " T ", "R ", + 'F', new ItemStack(Items.blaze_powder), + 'T', LibOreDict.LIVINGWOOD_TWIG, + 'R', LibOreDict.RUNE[1]); + recipeFireRod = BotaniaAPI.getLatestAddedRecipe(); + + // Vine Ball Recipe + addOreDictRecipe(new ItemStack(ModItems.vineBall), + "VVV", "VVV", "VVV", + 'V', new ItemStack(Blocks.vine)); + recipeVineBall = BotaniaAPI.getLatestAddedRecipe(); + + // Livingwood Slingshot Recipe + addOreDictRecipe(new ItemStack(ModItems.slingshot), + " TA", " TT", "T ", + 'T', LibOreDict.LIVINGWOOD_TWIG, + 'A', LibOreDict.RUNE[3]); + recipeSlingshot = BotaniaAPI.getLatestAddedRecipe(); + + // Moss Stone Recipe + addShapelessOreDictRecipe(new ItemStack(Blocks.mossy_cobblestone), "cobblestone", new ItemStack(ModItems.vineBall)); + recipeMossStone = BotaniaAPI.getLatestAddedRecipe(); + + // Prismarine Recipe + addOreDictRecipe(new ItemStack(ModBlocks.prismarine, 1, 0), + " S ", "SBS", " S ", + 'S', LibOreDict.PRISMARINE_SHARD, + 'B', "cobblestone"); + recipePrismarine = BotaniaAPI.getLatestAddedRecipe(); + + // Prismarine Brick Recipe + addOreDictRecipe(new ItemStack(ModBlocks.prismarine, 1, 1), + " S ", "SBS", " S ", + 'S', LibOreDict.PRISMARINE_SHARD, + 'B', new ItemStack(Blocks.stonebrick)); + recipePrismarineBrick = BotaniaAPI.getLatestAddedRecipe(); + + // Dark Prismarine Recipe + addOreDictRecipe(new ItemStack(ModBlocks.prismarine, 1, 2), + " S ", "SBS", " S ", + 'S', LibOreDict.PRISMARINE_SHARD, + 'B', new ItemStack(Blocks.nether_brick)); + recipeDarkPrismarine = BotaniaAPI.getLatestAddedRecipe(); + + // Sea Lantern Recipe + addOreDictRecipe(new ItemStack(ModBlocks.seaLamp), + " S ", "SBS", " S ", + 'S', LibOreDict.PRISMARINE_SHARD, + 'B', "glowstone"); + recipeSeaLamp = BotaniaAPI.getLatestAddedRecipe(); + + // Influence Lens Recipe + addOreDictRecipe(new ItemStack(ModItems.lens, 1, 12), + "PRP", "PLP", "PPP", + 'P', LibOreDict.PRISMARINE_SHARD, + 'R', LibOreDict.RUNE[3], + 'L', new ItemStack(ModItems.lens)); + recipeLensInfluence = BotaniaAPI.getLatestAddedRecipe(); + + // Weight Lens Recipe + addOreDictRecipe(new ItemStack(ModItems.lens, 1, 13), + "PPP", "PLP", "PRP", + 'P', LibOreDict.PRISMARINE_SHARD, + 'R', LibOreDict.RUNE[0], + 'L', new ItemStack(ModItems.lens)); + recipeLensWeight = BotaniaAPI.getLatestAddedRecipe(); + + // Paintslinger Lens Recipe + addOreDictRecipe(new ItemStack(ModItems.lens, 1, 14), + " E ", "WLW", " E ", + 'E', LibOreDict.ELEMENTIUM, + 'W', new ItemStack(Blocks.wool, 1, Short.MAX_VALUE), + 'L', new ItemStack(ModItems.lens)); + recipeLensPaint = BotaniaAPI.getLatestAddedRecipe(); + + // Warp Lens Recipe + addShapelessOreDictRecipe(new ItemStack(ModItems.lens, 1, 18), new ItemStack(ModItems.lens), LibOreDict.PIXIE_DUST); + recipeLensWarp = BotaniaAPI.getLatestAddedRecipe(); + + // Redirective Lens Recipe + addShapelessOreDictRecipe(new ItemStack(ModItems.lens, 1, 19), new ItemStack(ModItems.lens), LibOreDict.LIVING_WOOD, LibOreDict.ELEMENTIUM); + recipeLensRedirect = BotaniaAPI.getLatestAddedRecipe(); + + // Celebratory Lens Recipe + addShapelessOreDictRecipe(new ItemStack(ModItems.lens, 1, 20), new ItemStack(ModItems.lens), new ItemStack(Items.fireworks), LibOreDict.ELEMENTIUM); + recipeLensFirework = BotaniaAPI.getLatestAddedRecipe(); + + // Flare Lens Recipe + addShapelessOreDictRecipe(new ItemStack(ModItems.lens, 1, 21), new ItemStack(ModItems.lens), new ItemStack(ModBlocks.elfGlass), LibOreDict.ELEMENTIUM); + recipeLensFlare = BotaniaAPI.getLatestAddedRecipe(); + + // Mini Island Recipes + for(int i = 0; i < 16; i++) + GameRegistry.addRecipe(new ItemStack(ModBlocks.floatingFlower, 1, i), + "F", "S", "D", + 'F', new ItemStack(ModBlocks.shinyFlower, 1, i), + 'S', new ItemStack(ModItems.grassSeeds), + 'D', new ItemStack(Blocks.dirt)); + recipesMiniIsland = BotaniaAPI.getLatestAddedRecipes(16); + + // Gaia Pylon Recipe + addOreDictRecipe(new ItemStack(ModBlocks.pylon, 1, 2), + " D ", "EPE", " D ", + 'D', LibOreDict.PIXIE_DUST, + 'E', LibOreDict.ELEMENTIUM, + 'P', new ItemStack(ModBlocks.pylon)); + recipeGaiaPylon = BotaniaAPI.getLatestAddedRecipe(); + + // Drum of the Gathering Recipe + addOreDictRecipe(new ItemStack(ModBlocks.forestDrum, 1, 1), + "WLW", "WEW", "WLW", + 'W', LibOreDict.DREAM_WOOD, + 'L', new ItemStack(Items.leather), + 'E', LibOreDict.ELEMENTIUM); + recipeGatherDrum = BotaniaAPI.getLatestAddedRecipe(); + + // Mana Lens: Kindle Recipe + addShapelessOreDictRecipe(new ItemStack(ModItems.lens, 1, 15), new ItemStack(ModItems.lens), new ItemStack(Items.fire_charge)); + recipeLensFire = BotaniaAPI.getLatestAddedRecipe(); + + // Mana Lens: Piston Recipe + addShapelessOreDictRecipe(new ItemStack(ModItems.lens, 1, 16), new ItemStack(ModItems.lens), new ItemStack(ModBlocks.pistonRelay)); + recipeLensPiston = BotaniaAPI.getLatestAddedRecipe(); + + // Shard of Laputa Recipe + for(int i = 0; i < 16; i++) + addOreDictRecipe(new ItemStack(ModItems.laputaShard), + "SFS", "PDP", "ASE", + 'S', LibOreDict.LIFE_ESSENCE, + 'D', LibOreDict.DRAGONSTONE, + 'F', new ItemStack(ModBlocks.floatingFlower, 1, i), + 'P', LibOreDict.PRISMARINE_SHARD, + 'A', LibOreDict.RUNE[3], + 'E', LibOreDict.RUNE[2]); + recipesLaputaShard = BotaniaAPI.getLatestAddedRecipes(16); + + for(int i = 1; i < 20; i++) + addShapelessOreDictRecipe(new ItemStack(ModItems.laputaShard, 1, i), LibOreDict.LIFE_ESSENCE,new ItemStack(ModItems.laputaShard, 1, i - 1)); + recipesLaputaShardUpgrade = BotaniaAPI.getLatestAddedRecipes(19); + + // Necrodermal Virus Recipe + addShapelessOreDictRecipe(new ItemStack(ModItems.virus), LibOreDict.PIXIE_DUST, new ItemStack(ModItems.vineBall), new ItemStack(Items.magma_cream), new ItemStack(Items.fermented_spider_eye), new ItemStack(Items.ender_eye), new ItemStack(Items.skull, 1, 2)); + recipeVirusZombie = BotaniaAPI.getLatestAddedRecipe(); + + // Nullodermal Virus Recipe + addShapelessOreDictRecipe(new ItemStack(ModItems.virus, 1, 1), LibOreDict.PIXIE_DUST, new ItemStack(ModItems.vineBall), new ItemStack(Items.magma_cream), new ItemStack(Items.fermented_spider_eye), new ItemStack(Items.ender_eye), new ItemStack(Items.skull)); + recipeVirusSkeleton = BotaniaAPI.getLatestAddedRecipe(); + + // Ring of Far Reach Recipe + addOreDictRecipe(new ItemStack(ModItems.reachRing), + "RE ", "E E", " E ", + 'R', LibOreDict.RUNE[15], + 'E', LibOreDict.ELEMENTIUM); + recipeReachRing = BotaniaAPI.getLatestAddedRecipe(); + + // Rod of the Highlands Recipe + addShapelessOreDictRecipe(new ItemStack(ModItems.skyDirtRod), new ItemStack(ModItems.dirtRod), LibOreDict.PIXIE_DUST, LibOreDict.RUNE[3]); + recipeSkyDirtRod = BotaniaAPI.getLatestAddedRecipe(); + + // Life Imbuer Recipe + addOreDictRecipe(new ItemStack(ModBlocks.spawnerClaw), + "BSB", "PMP", "PEP", + 'B', new ItemStack(Items.blaze_rod), + 'S', LibOreDict.ELEMENTIUM, + 'P', new ItemStack(ModBlocks.prismarine, 1, 2), + 'M', new ItemStack(ModBlocks.storage), + 'E', LibOreDict.ENDER_AIR_BOTTLE); + recipeSpawnerClaw = BotaniaAPI.getLatestAddedRecipe(); + + // Crafty Crate Recipe + GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(ModBlocks.openCrate, 1, 1), + "WCW", "W W", "W W", + 'C', "craftingTableWood", + 'W', new ItemStack(ModBlocks.dreamwood, 1, 1))); + recipeCraftCrate = BotaniaAPI.getLatestAddedRecipe(); + + // Crafting Placeholder Recipe + addShapelessOreDictRecipe(new ItemStack(ModItems.manaResource, 32, 11), "craftingTableWood", LibOreDict.LIVING_ROCK); + recipePlaceholder = BotaniaAPI.getLatestAddedRecipe(); + + // Reed Block Recipe + GameRegistry.addRecipe(new ItemStack(ModBlocks.reedBlock), + "rrr", "rrr", "rrr", + 'r', new ItemStack(Items.reeds)); + recipeReedBlock = BotaniaAPI.getLatestAddedRecipe(); + + // Thatch Recipe + GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(ModBlocks.thatch), + "ww", "ww", + 'w', "cropWheat")); + recipeThatch = BotaniaAPI.getLatestAddedRecipe(); + + // Nether Brick Recipe + GameRegistry.addRecipe(new ItemStack(ModBlocks.customBrick, 4, 0), + " B ", "BSB", " B ", + 'B', new ItemStack(Blocks.netherrack), + 'S', new ItemStack(Blocks.stonebrick)); + recipeNetherBrick = BotaniaAPI.getLatestAddedRecipe(); + + // Soul Brick Recipe + GameRegistry.addRecipe(new ItemStack(ModBlocks.customBrick, 4, 1), + " B ", "BSB", " B ", + 'B', new ItemStack(Blocks.soul_sand), + 'S', new ItemStack(Blocks.stonebrick)); + recipeSoulBrick = BotaniaAPI.getLatestAddedRecipe(); + + // Snow Brick Recipe + GameRegistry.addRecipe(new ItemStack(ModBlocks.customBrick, 4, 2), + " B ", "BSB", " B ", + 'B', new ItemStack(Blocks.snow), + 'S', new ItemStack(Blocks.stonebrick)); + recipeSnowBrick = BotaniaAPI.getLatestAddedRecipe(); + + // Roof Tile Recipe + GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(ModBlocks.customBrick, 4, 3), + "BB", "BB", "BB", + 'B', "ingotBrick")); + recipeRoofTile = BotaniaAPI.getLatestAddedRecipe(); + + // Azulejo Recipe + GameRegistry.addRecipe(new ShapelessOreRecipe(new ItemStack(ModBlocks.customBrick, 1, 4), "gemLapis", "blockQuartz")); + recipeAzulejo = BotaniaAPI.getLatestAddedRecipe(); + + // Azulejo Cycling Recipes + for(int i = 0; i < 12; i++) + GameRegistry.addShapelessRecipe(new ItemStack(ModBlocks.customBrick, 1, 4 + (i == 11 ? 0 : i + 1)), new ItemStack(ModBlocks.customBrick, 1, 4 + i)); + recipesAzulejoCycling = BotaniaAPI.getLatestAddedRecipes(12); + + // Ender Overseer Recipe + GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(ModBlocks.enderEye), + "RER", "EOE", "RER", + 'R', "dustRedstone", + 'E', new ItemStack(Items.ender_eye), + 'O', new ItemStack(Blocks.obsidian))); + recipeEnderEyeBlock = BotaniaAPI.getLatestAddedRecipe(); + + // The Spectator Recipe + addOreDictRecipe(new ItemStack(ModItems.itemFinder), + " I ", "IYI", "IEI", + 'I', "ingotIron", + 'Y', new ItemStack(Items.ender_eye), + 'E', "gemEmerald"); + recipeItemFinder = BotaniaAPI.getLatestAddedRecipe(); + + // Crimson Pendant Recipe + addOreDictRecipe(new ItemStack(ModItems.superLavaPendant), + "BBB", "BPB", "NGN", + 'B', new ItemStack(Items.blaze_rod), + 'P', new ItemStack(ModItems.lavaPendant), + 'N', new ItemStack(Blocks.nether_brick), + 'G', LibOreDict.LIFE_ESSENCE); + recipeSuperLavaPendant = BotaniaAPI.getLatestAddedRecipe(); + + // Hand of Ender Recipe + addOreDictRecipe(new ItemStack(ModItems.enderHand), + "PLO", "LEL", "OL ", + 'P', LibOreDict.MANA_PEARL, + 'L', new ItemStack(Items.leather), + 'E', new ItemStack(Blocks.ender_chest), + 'O', new ItemStack(Blocks.obsidian)); + recipeEnderHand = BotaniaAPI.getLatestAddedRecipe(); + + // Vitreous Pickaxe Recipe + addOreDictRecipe(new ItemStack(ModItems.glassPick), + "GIG", " T ", " T ", + 'G', "blockGlassColorless", + 'I', LibOreDict.MANA_STEEL, + 'T', LibOreDict.LIVINGWOOD_TWIG); + recipeGlassPick = BotaniaAPI.getLatestAddedRecipe(); + + // Starfield Creator Recipe + addOreDictRecipe(new ItemStack(ModBlocks.starfield), + "EPE", "EOE", + 'E', LibOreDict.ELEMENTIUM, + 'P', LibOreDict.PIXIE_DUST, + 'O', new ItemStack(Blocks.obsidian)); + recipeStarfield = BotaniaAPI.getLatestAddedRecipe(); + + // Spark Recipe + for(int i = 0; i < 16; i++) + addOreDictRecipe(new ItemStack(ModItems.spark), + " P ", "BNB", " P ", + 'B', new ItemStack(Items.blaze_powder), + 'P', LibOreDict.PETAL[i], + 'N', "nuggetGold"); + recipesSpark = BotaniaAPI.getLatestAddedRecipes(16); + + // Spark Augment Recipes + for(int i = 0; i < 4; i++) + addShapelessOreDictRecipe(new ItemStack(ModItems.sparkUpgrade, 1, i), + LibOreDict.PIXIE_DUST, LibOreDict.MANA_STEEL, LibOreDict.RUNE[i]); + recipesSparkUpgrades = BotaniaAPI.getLatestAddedRecipes(4); + + // Horn of the Canopy Recipe + addShapelessOreDictRecipe(new ItemStack(ModItems.grassHorn, 1, 1), new ItemStack(ModItems.grassHorn), "treeLeaves"); + recipeLeafHorn = BotaniaAPI.getLatestAddedRecipe(); + + // Rod of Divining Recipe + addOreDictRecipe(new ItemStack(ModItems.diviningRod), + " TD", " TT", "T ", + 'T', LibOreDict.LIVINGWOOD_TWIG, + 'D', LibOreDict.MANA_DIAMOND); + recipeDiviningRod = BotaniaAPI.getLatestAddedRecipe(); + + // Rod of the Black Mesa Recipe + addOreDictRecipe(new ItemStack(ModItems.gravityRod), + " TD", " WT", "T ", + 'T', LibOreDict.DREAMWOOD_TWIG, + 'W', "cropWheat", + 'D', LibOreDict.DRAGONSTONE); + recipeGravityRod = BotaniaAPI.getLatestAddedRecipe(); + + // Timeless Ivy Recipe + addShapelessOreDictRecipe(new ItemStack(ModItems.regenIvy), new ItemStack(Blocks.vine), LibOreDict.LIFE_ESSENCE, LibOreDict.ELEMENTIUM); + recipeRegenIvy = BotaniaAPI.getLatestAddedRecipe(); + + // Gaia Mana Spreader Recipe + addOreDictRecipe(new ItemStack(ModBlocks.spreader, 1, 3), + "ESD", + 'E', LibOreDict.LIFE_ESSENCE, + 'S', new ItemStack(ModBlocks.spreader, 1, 2), + 'D', LibOreDict.DRAGONSTONE); + recipeUltraSpreader = BotaniaAPI.getLatestAddedRecipe(); + + // Wing Recipes + GameRegistry.addRecipe(new ShapelessOreRecipe(new ItemStack(ModItems.flightTiara, 1, 1), new ItemStack(ModItems.flightTiara, 1, Short.MAX_VALUE), "gemQuartz")); + for(int i = 0; i < 7; i++) + GameRegistry.addRecipe(new ShapelessOreRecipe(new ItemStack(ModItems.flightTiara, 1, 2 + i), new ItemStack(ModItems.flightTiara, 1, Short.MAX_VALUE), LibOreDict.QUARTZ[i])); + recipesWings = BotaniaAPI.getLatestAddedRecipes(8); + + // Mana Fluxfield Recipe + if(ConfigHandler.fluxfieldEnabled) { + addOreDictRecipe(new ItemStack(ModBlocks.rfGenerator), + "SRS", "RMR", "SRS", + 'S', LibOreDict.LIVING_ROCK, + 'M', LibOreDict.MANA_STEEL, + 'R', "blockRedstone"); + recipeRFGenerator = BotaniaAPI.getLatestAddedRecipe(); + } + + // Vial Recipe + GameRegistry.addRecipe(new ItemStack(ModItems.vial, 3, 0), + "G G", " G ", + 'G', new ItemStack(ModBlocks.manaGlass)); + recipeVial = BotaniaAPI.getLatestAddedRecipe(); + + // Flask Recipe + GameRegistry.addRecipe(new ItemStack(ModItems.vial, 3, 1), + "G G", " G ", + 'G', new ItemStack(ModBlocks.elfGlass)); + recipeFlask = BotaniaAPI.getLatestAddedRecipe(); + + // Botanical Brewery Recipe + addOreDictRecipe(new ItemStack(ModBlocks.brewery), + "RSR", "RAR", "RMR", + 'R', LibOreDict.LIVING_ROCK, + 'S', new ItemStack(Items.brewing_stand), + 'A', LibOreDict.RUNE[8], + 'M', new ItemStack(ModBlocks.storage)); + recipeBrewery = BotaniaAPI.getLatestAddedRecipe(); + + // Tainted Blood Pendant Recipe + addOreDictRecipe(new ItemStack(ModItems.bloodPendant), + " P ", "PGP", "DP ", + 'P', LibOreDict.PRISMARINE_SHARD, + 'G', new ItemStack(Items.ghast_tear), + 'D', LibOreDict.MANA_DIAMOND); + recipeBloodPendant = BotaniaAPI.getLatestAddedRecipe(); + + // Terrestrial Agglomeration Plate Recipe + addOreDictRecipe(new ItemStack(ModBlocks.terraPlate), + "LLL", "0M1", "283", + 'L', "blockLapis", + 'M', new ItemStack(ModBlocks.storage), + '0', LibOreDict.RUNE[0], + '1', LibOreDict.RUNE[1], + '2', LibOreDict.RUNE[2], + '3', LibOreDict.RUNE[3], + '8', LibOreDict.RUNE[8]); + recipeTerraPlate = BotaniaAPI.getLatestAddedRecipe(); + + // Red String Recipe + addShapelessOreDictRecipe(new ItemStack(ModItems.manaResource, 1, 12), new ItemStack(Items.string), "blockRedstone", LibOreDict.PIXIE_DUST, LibOreDict.ENDER_AIR_BOTTLE); + recipeRedString = BotaniaAPI.getLatestAddedRecipe(); + // Are you in a pinch? + addShapelessOreDictRecipe(new ItemStack(ModItems.manaResource, 1, 12), new ItemStack(Items.string), "blockRedstone", LibOreDict.PIXIE_DUST, LibOreDict.ENDER_AIR_BOTTLE, new ItemStack(Blocks.pumpkin)); + + // Red String Container Recipe + addOreDictRecipe(new ItemStack(ModBlocks.redStringContainer), + "RRR", "RCS", "RRR", + 'R', LibOreDict.LIVING_ROCK, + 'S', LibOreDict.RED_STRING, + 'C', "chestWood"); + recipeRedStringContainer = BotaniaAPI.getLatestAddedRecipe(); + + // Red String Dispenser Recipe + addOreDictRecipe(new ItemStack(ModBlocks.redStringDispenser), + "RRR", "RDS", "RRR", + 'R', LibOreDict.LIVING_ROCK, + 'S', LibOreDict.RED_STRING, + 'D', new ItemStack(Blocks.dispenser)); + recipeRedStringDispenser = BotaniaAPI.getLatestAddedRecipe(); + + // Red String Fertilizer Recipe + addOreDictRecipe(new ItemStack(ModBlocks.redStringFertilizer), + "RRR", "RBS", "RRR", + 'R', LibOreDict.LIVING_ROCK, + 'S', LibOreDict.RED_STRING, + 'B', new ItemStack(ModItems.fertilizer)); + recipeRedStringFertilizer = BotaniaAPI.getLatestAddedRecipe(); + + // Red String Comparator Recipe + addOreDictRecipe(new ItemStack(ModBlocks.redStringComparator), + "RRR", "RCS", "RRR", + 'R', LibOreDict.LIVING_ROCK, + 'S', LibOreDict.RED_STRING, + 'C', new ItemStack(Items.comparator)); + recipeRedStringComparator = BotaniaAPI.getLatestAddedRecipe(); + + // Red String Spoofer Recipe + addOreDictRecipe(new ItemStack(ModBlocks.redStringRelay), + "RRR", "RMS", "RRR", + 'R', LibOreDict.LIVING_ROCK, + 'S', LibOreDict.RED_STRING, + 'M', new ItemStack(ModBlocks.spreader)); + recipeRedStringRelay = BotaniaAPI.getLatestAddedRecipe(); + + // Red String Interceptor Recipe + addOreDictRecipe(new ItemStack(ModBlocks.redStringInterceptor), + "RRR", "RMS", "RRR", + 'R', LibOreDict.LIVING_ROCK, + 'S', LibOreDict.RED_STRING, + 'M', new ItemStack(Blocks.stone_button)); + recipeRedStringInterceptor = BotaniaAPI.getLatestAddedRecipe(); + + // Rod of the Arcane Barrage Recipe + addOreDictRecipe(new ItemStack(ModItems.missileRod), + "GDD", " TD", "T G", + 'G', LibOreDict.LIFE_ESSENCE, + 'D', LibOreDict.DRAGONSTONE, + 'T', LibOreDict.DREAMWOOD_TWIG); + recipeMissileRod = BotaniaAPI.getLatestAddedRecipe(); + + // Cloak of Virtue Recipe + addOreDictRecipe(new ItemStack(ModItems.holyCloak), + "WWW", "GWG", "GSG", + 'W', new ItemStack(Blocks.wool), + 'G', "dustGlowstone", + 'S', LibOreDict.LIFE_ESSENCE); + recipeHolyCloak = BotaniaAPI.getLatestAddedRecipe(); + + // Cloak of Sin Recipe + addOreDictRecipe(new ItemStack(ModItems.unholyCloak), + "WWW", "RWR", "RSR", + 'W', new ItemStack(Blocks.wool, 1, 15), + 'R', "dustRedstone", + 'S', LibOreDict.LIFE_ESSENCE); + recipeUnholyCloak = BotaniaAPI.getLatestAddedRecipe(); + + // Assembly Halo Recipe + addOreDictRecipe(new ItemStack(ModItems.craftingHalo), + " P ", "ICI", " I ", + 'P', LibOreDict.MANA_PEARL, + 'I', LibOreDict.MANA_STEEL, + 'C', "craftingTableWood"); + recipeCraftingHalo = BotaniaAPI.getLatestAddedRecipe(); + + // Mana Lens: Flash Recipe + GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(ModItems.lens, 1, 17), + "GFG", "FLF", "GFG", + 'G', "glowstone", + 'F', new ItemStack(Items.fire_charge), + 'L', new ItemStack(ModItems.lens))); + GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(ModItems.lens, 1, 17), + "FGF", "GLG", "FGF", + 'G', "glowstone", + 'F', new ItemStack(Items.fire_charge), + 'L', new ItemStack(ModItems.lens))); + recipesLensFlash = BotaniaAPI.getLatestAddedRecipes(2); + + // Mana Prism Recipe + addOreDictRecipe(new ItemStack(ModBlocks.prism), + "GPG", "GSG", "GPG", + 'G', "blockGlassColorless", + 'P', LibOreDict.PRISMARINE_SHARD, + 'S', new ItemStack(ModBlocks.platform, 1, 1)); + recipePrism = BotaniaAPI.getLatestAddedRecipe(); + + // Trodden Dirt Recipe + GameRegistry.addRecipe(new ShapelessOreRecipe(new ItemStack(ModBlocks.dirtPath, 4), new ItemStack(Blocks.dirt, 1, 1), new ItemStack(Blocks.dirt, 1, 1), new ItemStack(Blocks.dirt, 1, 1), "sand")); + recipeDirtPath = BotaniaAPI.getLatestAddedRecipe(); + + // Dreamwood Twig Recipe + addOreDictRecipe(new ItemStack(ModItems.manaResource, 1, 13), + "W", "W", + 'W', LibOreDict.DREAM_WOOD); + recipeDreamwoodTwig = BotaniaAPI.getLatestAddedRecipe(); + + // Manaseer Monocle Recipe + addOreDictRecipe(new ItemStack(ModItems.monocle), + "GN", "IN", " N", + 'G', new ItemStack(ModBlocks.manaGlass), + 'I', LibOreDict.MANA_STEEL, + 'N', new ItemStack(Items.gold_nugget)); + recipeMonocle = BotaniaAPI.getLatestAddedRecipe(); + + // Lens Clip Recipe + addOreDictRecipe(new ItemStack(ModItems.clip), + " D ", "D D", "DD ", + 'D', LibOreDict.DREAM_WOOD); + recipeClip = BotaniaAPI.getLatestAddedRecipe(); + + // Rod of the Depths Recipe + addOreDictRecipe(new ItemStack(ModItems.cobbleRod), + " FC", " TW", "T ", + 'F', LibOreDict.RUNE[1], + 'W', LibOreDict.RUNE[0], + 'T', LibOreDict.LIVINGWOOD_TWIG, + 'C', "cobblestone"); + recipeCobbleRod = BotaniaAPI.getLatestAddedRecipe(); + + // Rod of the Molten Core Recipe + addOreDictRecipe(new ItemStack(ModItems.smeltRod), + " BF", " TB", "T ", + 'B', new ItemStack(Items.blaze_rod), + 'F', LibOreDict.RUNE[1], + 'T', LibOreDict.LIVINGWOOD_TWIG); + recipeSmeltRod = BotaniaAPI.getLatestAddedRecipe(); + + // World Seed Recipe + addOreDictRecipe(new ItemStack(ModItems.worldSeed, 4), + "G", "S", "D", + 'G', new ItemStack(Blocks.grass), + 'S', new ItemStack(Items.wheat_seeds), + 'D', LibOreDict.DRAGONSTONE); + recipeWorldSeed = BotaniaAPI.getLatestAddedRecipe(); + + // Spellbinding Cloth Recipe + addOreDictRecipe(new ItemStack(ModItems.spellCloth), + " C ", "CPC", " C ", + 'C', LibOreDict.MANAWEAVE_CLOTH, + 'P', LibOreDict.MANA_PEARL); + recipeSpellCloth = BotaniaAPI.getLatestAddedRecipe(); + + // Thorn Chakram Recipe + addOreDictRecipe(new ItemStack(ModItems.thornChakram, 2), + "VVV", "VTV", "VVV", + 'V', new ItemStack(Blocks.vine), + 'T', LibOreDict.TERRA_STEEL); + recipeThornChakram = BotaniaAPI.getLatestAddedRecipe(); + + // Trodden Dirt Slab + GameRegistry.addRecipe(new ItemStack(ModFluffBlocks.dirtPathSlab, 6), + "DDD", + 'D', new ItemStack(ModBlocks.dirtPath)); + recipeDirtPathSlab = BotaniaAPI.getLatestAddedRecipe(); + + // Pattern Recipes + { + int count = TileCraftCrate.PATTERNS.length; + List recipeObjects = Arrays.asList(new Object[] { + 'R', "dustRedstone", + 'P', LibOreDict.PLACEHOLDER + }); + + for(int i = 0; i < count; i++) { + List recipe = new ArrayList(); + for(int j = 0; j < 3; j++) { + String s = ""; + for(int k = 0; k < 3; k++) + s += TileCraftCrate.PATTERNS[i][j * 3 + k] ? "R" : "P"; + recipe.add(s); + } + recipe.addAll(recipeObjects); + + addOreDictRecipe(new ItemStack(ModItems.craftPattern, 1, i), recipe.toArray(new Object[recipe.size()])); + } + + recipesPatterns = BotaniaAPI.getLatestAddedRecipes(count); + } + + // Gaia Spirit Ingot Recipe + addOreDictRecipe(new ItemStack(ModItems.manaResource, 1, 14), + " S ", "SIS", " S ", + 'S', LibOreDict.LIFE_ESSENCE, + 'I', LibOreDict.TERRA_STEEL); + recipeGaiaIngot = BotaniaAPI.getLatestAddedRecipe(); + + // Corporea Spark Recipe + addShapelessOreDictRecipe(new ItemStack(ModItems.corporeaSpark), new ItemStack(ModItems.spark), LibOreDict.PIXIE_DUST, LibOreDict.ENDER_AIR_BOTTLE); + recipeCorporeaSpark = BotaniaAPI.getLatestAddedRecipe(); + + // Master Corporea Spark Recipe + addShapelessOreDictRecipe(new ItemStack(ModItems.corporeaSpark, 1, 1), new ItemStack(ModItems.corporeaSpark), LibOreDict.DRAGONSTONE); + recipeMasterCorporeaSpark = BotaniaAPI.getLatestAddedRecipe(); + + // Corporea Index Recipe + addOreDictRecipe(new ItemStack(ModBlocks.corporeaIndex), + "AOA", "OSO", "DOD", + 'A', LibOreDict.ENDER_AIR_BOTTLE, + 'O', new ItemStack(Blocks.obsidian), + 'S', new ItemStack(ModItems.corporeaSpark), + 'D', LibOreDict.DRAGONSTONE); + recipeCorporeaIndex = BotaniaAPI.getLatestAddedRecipe(); + + // Corporea Funnel Recipe + addShapelessOreDictRecipe(new ItemStack(ModBlocks.corporeaFunnel), new ItemStack(Blocks.dropper), new ItemStack(ModItems.corporeaSpark)); + recipeCorporeaFunnel = BotaniaAPI.getLatestAddedRecipe(); + + // Corporea Interceptor Recipe + addShapelessOreDictRecipe(new ItemStack(ModBlocks.corporeaInterceptor), "blockRedstone", new ItemStack(ModItems.corporeaSpark)); + recipeCorporeaInterceptor = BotaniaAPI.getLatestAddedRecipe(); + + // End Stone Brick Recipes + if(ConfigHandler.enderStuff19Enabled) { + GameRegistry.addRecipe(new ItemStack(ModBlocks.endStoneBrick, 4), + "SS", "SS", + 'S', new ItemStack(Blocks.end_stone)); + recipeEndStoneBricks = BotaniaAPI.getLatestAddedRecipe(); + + GameRegistry.addRecipe(new ItemStack(ModBlocks.endStoneBrick, 1, 1), + "S", "S", + 'S', new ItemStack(ModFluffBlocks.endStoneSlab)); + recipeEndStoneChiseledBricks = BotaniaAPI.getLatestAddedRecipe(); + + GameRegistry.addRecipe(new ItemStack(ModBlocks.endStoneBrick, 4, 2), + " B ", "BPB", " B ", + 'B', new ItemStack(ModBlocks.endStoneBrick), + 'P', new ItemStack(Items.ender_pearl)); + recipeEnderBricks = BotaniaAPI.getLatestAddedRecipe(); + + GameRegistry.addRecipe(new ItemStack(ModBlocks.endStoneBrick, 2, 3), + "B", "B", + 'B', new ItemStack(ModBlocks.endStoneBrick, 1, 2)); + recipePillarEnderBricks = BotaniaAPI.getLatestAddedRecipe(); + } + + // Livingwood Bow Recipe + addOreDictRecipe(new ItemStack(ModItems.livingwoodBow), + " TS", "T S", " TS", + 'T', LibOreDict.LIVINGWOOD_TWIG, + 'S', LibOreDict.MANA_STRING); + recipeLivingwoodBow = BotaniaAPI.getLatestAddedRecipe(); + + // Crystal Bow Recipe + addOreDictRecipe(new ItemStack(ModItems.crystalBow), + " DS", "T S", " DS", + 'T', LibOreDict.LIVINGWOOD_TWIG, + 'D', LibOreDict.DRAGONSTONE, + 'S', LibOreDict.MANA_STRING); + recipeCrystalBow = BotaniaAPI.getLatestAddedRecipe(); + + // Cosmetic Items Recipes + for(int i = 0; i < 32; i++) + addOreDictRecipe(new ItemStack(ModItems.cosmetic, 1, i), + "PPP", "PSP", "PPP", + 'P', new ItemStack(i < 16 ? ModItems.petal : ModItems.dye, 1, i % 16), + 'S', LibOreDict.MANA_STRING); + recipesCosmeticItems = BotaniaAPI.getLatestAddedRecipes(32); + + // Shimmering Mushroom Recipes + for(int i = 0; i < 16; i++) { + GameRegistry.addShapelessRecipe(new ItemStack(ModBlocks.mushroom, 1, i), new ItemStack(Blocks.red_mushroom), new ItemStack(ModItems.dye, 1, i)); + GameRegistry.addShapelessRecipe(new ItemStack(ModBlocks.mushroom, 1, i), new ItemStack(Blocks.brown_mushroom), new ItemStack(ModItems.dye, 1, i)); + } + recipesMushrooms = BotaniaAPI.getLatestAddedRecipes(32); + GameRegistry.addShapelessRecipe(new ItemStack(Items.mushroom_stew), new ItemStack(ModBlocks.mushroom, 1, Short.MAX_VALUE), new ItemStack(ModBlocks.mushroom, 1, Short.MAX_VALUE), new ItemStack(Items.bowl)); + + // Ring of Correction Recipe + addOreDictRecipe(new ItemStack(ModItems.swapRing), + "CM ", "M M", " M ", + 'C', new ItemStack(Blocks.clay), + 'M', LibOreDict.MANA_STEEL); + recipeSwapRing = BotaniaAPI.getLatestAddedRecipe(); + + // Horn of the Covering Recipe + addShapelessOreDictRecipe(new ItemStack(ModItems.grassHorn, 1, 2), new ItemStack(ModItems.grassHorn), new ItemStack(Items.snowball)); + recipeSnowHorn = BotaniaAPI.getLatestAddedRecipe(); + + // Flower Pouch Recipe + GameRegistry.addShapedRecipe(new ItemStack(ModItems.flowerBag), + "WPW", "W W", " W ", + 'P', new ItemStack(ModItems.petal, 1, Short.MAX_VALUE), + 'W', new ItemStack(Blocks.wool, 1, Short.MAX_VALUE)); + recipeFlowerBag = BotaniaAPI.getLatestAddedRecipe(); + + // Phantom Ink Recipe + addShapelessOreDictRecipe(new ItemStack(ModItems.phantomInk, 4), LibOreDict.MANA_PEARL, "dye", "blockGlass", new ItemStack(Items.glass_bottle), new ItemStack(Items.glass_bottle), new ItemStack(Items.glass_bottle), new ItemStack(Items.glass_bottle)); + recipePhantomInk = BotaniaAPI.getLatestAddedRecipe(); + + // Minecart with Mana Pool Recipe + GameRegistry.addShapelessRecipe(new ItemStack(ModItems.poolMinecart), new ItemStack(Items.minecart), new ItemStack(ModBlocks.pool)); + recipePoolCart = BotaniaAPI.getLatestAddedRecipe(); + + // Mana Pump Recipe + addOreDictRecipe(new ItemStack(ModBlocks.pump), + "SSS", "IBI", "SSS", + 'S', LibOreDict.LIVING_ROCK, + 'I', LibOreDict.MANA_STEEL, + 'B', new ItemStack(Items.bucket)); + recipePump = BotaniaAPI.getLatestAddedRecipe(); + + // Double Petal Recipes + for(int i = 0; i < 16; i++) + addShapelessOreDictRecipe(new ItemStack(ModItems.petal, 4, i), LibOreDict.DOUBLE_FLOWER[i]); + recipesPetalsDouble = BotaniaAPI.getLatestAddedRecipes(16); + + // Resolute Ivy Recipe + addShapelessOreDictRecipe(new ItemStack(ModItems.keepIvy), LibOreDict.PIXIE_DUST, new ItemStack(Blocks.vine), LibOreDict.ENDER_AIR_BOTTLE); + recipeKeepIvy = BotaniaAPI.getLatestAddedRecipe(); + + // Black Hole Talisman Recipe + addOreDictRecipe(new ItemStack(ModItems.blackHoleTalisman), + " G ", "EAE", " E ", + 'G', LibOreDict.LIFE_ESSENCE, + 'E', LibOreDict.ELEMENTIUM, + 'A', LibOreDict.ENDER_AIR_BOTTLE); + recipeBlackHoleTalisman = BotaniaAPI.getLatestAddedRecipe(); + + // 1.8 Stone Recipes + recipe18StonePolish = new ArrayList(); + recipe18StoneBrick = new ArrayList(); + recipe18StoneChisel = new ArrayList(); + for(int i = 0; i < 4; i++) { + addOreDictRecipe(new ItemStack(ModFluffBlocks.stone, 8, i + 4), + "SSS", "S S", "SSS", + 'S', LibOreDict.STONE_18_VARIANTS[i]); + recipe18StonePolish.add(BotaniaAPI.getLatestAddedRecipe()); + + addOreDictRecipe(new ItemStack(ModFluffBlocks.stone, 4, i + 8), + "SS", "SS", + 'S', LibOreDict.STONE_18_VARIANTS[i]); + recipe18StoneBrick.add(BotaniaAPI.getLatestAddedRecipe()); + + addOreDictRecipe(new ItemStack(ModFluffBlocks.stone, 1, i + 12), + "S", "S", + 'S', new ItemStack(ModFluffBlocks.stoneSlabs[i + 4], 1, 0)); + recipe18StoneChisel.add(BotaniaAPI.getLatestAddedRecipe()); + } + + // Blaze Light Recipe + addOreDictRecipe(new ItemStack(ModBlocks.blazeBlock), + "BBB", "BBB", "BBB", + 'B', Botania.gardenOfGlassLoaded ? "powderBlaze" : "rodBlaze"); + recipeBlazeBlock = BotaniaAPI.getLatestAddedRecipe(); + addShapelessOreDictRecipe(new ItemStack(Botania.gardenOfGlassLoaded ? Items.blaze_powder : Items.blaze_rod, 9), LibOreDict.BLAZE_BLOCK); + + // Metamorphic Petal Apothecary Recipes + for(int i = 0; i < 8; i++) + GameRegistry.addRecipe(new ItemStack(ModBlocks.altar, 1, i + 1), + "SSS", "SAS", "SSS", + 'S', new ItemStack(ModFluffBlocks.biomeStoneA, 1, i + 8), + 'A', new ItemStack(ModBlocks.altar)); + recipesAltarMeta = BotaniaAPI.getLatestAddedRecipes(8); + + // Corporea Crystal Cube Recipe + addOreDictRecipe(new ItemStack(ModBlocks.corporeaCrystalCube), + "C", "G", "W", + 'C', new ItemStack(ModItems.corporeaSpark), + 'G', new ItemStack(ModBlocks.elfGlass), + 'W', LibOreDict.DREAM_WOOD); + recipeCorporeaCrystalCube = BotaniaAPI.getLatestAddedRecipe(); + + // Stone of Temperance Recipe + addOreDictRecipe(new ItemStack(ModItems.temperanceStone), + " S ", "SRS", " S ", + 'S', "stone", + 'R', LibOreDict.RUNE[2]); + recipeTemperanceStone = BotaniaAPI.getLatestAddedRecipe(); + + // Incense Stick Recipe + addOreDictRecipe(new ItemStack(ModItems.incenseStick), + " G", " B ", "T ", + 'G', new ItemStack(Items.ghast_tear), + 'B', new ItemStack(Items.blaze_powder), + 'T', LibOreDict.LIVINGWOOD_TWIG); + recipeIncenseStick = BotaniaAPI.getLatestAddedRecipe(); + + // Incense Plate Recipe + addOreDictRecipe(new ItemStack(ModBlocks.incensePlate), + "WSS", + 'W', LibOreDict.LIVING_WOOD, + 'S', new ItemStack(ModFluffBlocks.livingwoodSlab)); + recipeIncensePlate = BotaniaAPI.getLatestAddedRecipe(); + + // Terra Truncator Recipe + addOreDictRecipe(new ItemStack(ModItems.terraAxe), + "TTG", "TST", " S ", + 'T', LibOreDict.TERRA_STEEL, + 'G', "glowstone", + 'S', LibOreDict.LIVINGWOOD_TWIG); + recipeTerraAxe = BotaniaAPI.getLatestAddedRecipe(); + + // Hovering Hourglass Recipe + addOreDictRecipe(new ItemStack(ModBlocks.hourglass), + "GMG", "RSR", "GMG", + 'G', "ingotGold", + 'M', new ItemStack(ModBlocks.manaGlass), + 'R', "dustRedstone", + 'S', LibOreDict.MANA_STEEL); + recipeHourglass = BotaniaAPI.getLatestAddedRecipe(); + + // Spectral Rail Recipe + GameRegistry.addShapelessRecipe(new ItemStack(ModBlocks.ghostRail), new ItemStack(Blocks.rail), new ItemStack(ModBlocks.platform, 1, 1)); + recipeGhostRail = BotaniaAPI.getLatestAddedRecipe(); + + // Drum of the Canopy Recipe + addOreDictRecipe(new ItemStack(ModBlocks.forestDrum, 1, 2), + "WLW", "WHW", "WLW", + 'W', LibOreDict.LIVING_WOOD, + 'L', new ItemStack(Items.leather), + 'H', new ItemStack(ModItems.grassHorn, 1, 1)); + recipeCanopyDrum = BotaniaAPI.getLatestAddedRecipe(); + + // Spark Changer Recipe + addOreDictRecipe(new ItemStack(ModBlocks.sparkChanger), + "ESE", "SRS", + 'S', LibOreDict.LIVING_ROCK, + 'E', LibOreDict.ELEMENTIUM, + 'R', "dustRedstone"); + recipeSparkChanger = BotaniaAPI.getLatestAddedRecipe(); + + // Cocoon of Caprice Recipe + if(Botania.gardenOfGlassLoaded) + addOreDictRecipe(new ItemStack(ModBlocks.cocoon), + "SSS", "SFS", "SIS", + 'S', new ItemStack(Items.string), + 'F', new ItemStack(ModBlocks.felPumpkin), + 'I', LibOreDict.MANA_STEEL); + else addOreDictRecipe(new ItemStack(ModBlocks.cocoon), + "SSS", "SPS", "SDS", + 'S', new ItemStack(Items.string), + 'P', LibOreDict.PIXIE_DUST, + 'D', LibOreDict.DRAGONSTONE); + recipeCocoon = BotaniaAPI.getLatestAddedRecipe(); + + // Fel Pumpkin + GameRegistry.addRecipe(new ItemStack(ModBlocks.felPumpkin), + " S ", "BPF", " G ", + 'S', new ItemStack(Items.string), + 'B', new ItemStack(Items.bone), + 'P', new ItemStack(Blocks.pumpkin), + 'F', new ItemStack(Items.rotten_flesh), + 'G', new ItemStack(Items.gunpowder)); + recipeFelPumpkin = BotaniaAPI.getLatestAddedRecipe(); + + // Luminizer Recipe + addShapelessOreDictRecipe(new ItemStack(ModBlocks.lightRelay), LibOreDict.RED_STRING, LibOreDict.DRAGONSTONE, "dustGlowstone", "dustGlowstone"); + recipeLuminizer = BotaniaAPI.getLatestAddedRecipe(); + + // Detector Luminizer Recipe + addShapelessOreDictRecipe(new ItemStack(ModBlocks.lightRelay, 1, 1), new ItemStack(ModBlocks.lightRelay), "dustRedstone"); + recipeDetectorLuminizer = BotaniaAPI.getLatestAddedRecipe(); + + // Luminizer Launcher Recipe + addOreDictRecipe(new ItemStack(ModBlocks.lightLauncher), + "DDD", "DLD", + 'D', LibOreDict.DREAM_WOOD, + 'L', new ItemStack(ModBlocks.lightRelay)); + recipeLuminizerLauncher = BotaniaAPI.getLatestAddedRecipe(); + + // Floral Obedience Stick Recipe + addOreDictRecipe(new ItemStack(ModItems.obedienceStick), + " M", " T ", "T ", + 'M', LibOreDict.MANA_STEEL, + 'T', LibOreDict.LIVINGWOOD_TWIG); + recipeObedienceStick = BotaniaAPI.getLatestAddedRecipe(); + + // Cacophonium Recipe + if(OreDictionary.getOres("ingotBrass").isEmpty()) + addOreDictRecipe(new ItemStack(ModItems.cacophonium), + " G ", "GNG", "GG ", + 'G', "ingotGold", + 'N', new ItemStack(Blocks.noteblock)); + else addOreDictRecipe(new ItemStack(ModItems.cacophonium), + " G ", "GNG", "GG ", + 'G', "ingotBrass", + 'N', new ItemStack(Blocks.noteblock)); + recipeCacophonium = BotaniaAPI.getLatestAddedRecipe(); + + // Manastorm Charge Recipe + addOreDictRecipe(new ItemStack(ModBlocks.manaBomb), + "LTL", "TGT", "LTL", + 'L', LibOreDict.LIVING_WOOD, + 'T', new ItemStack(Blocks.tnt), + 'G', LibOreDict.LIFE_ESSENCE); + recipeManaBomb = BotaniaAPI.getLatestAddedRecipe(); + + // Cobweb Recipe + addOreDictRecipe(new ItemStack(Blocks.web), + "S S", " M ", "S S", + 'S', new ItemStack(Items.string), + 'M', LibOreDict.MANA_STRING); + recipeCobweb = BotaniaAPI.getLatestAddedRecipe(); + + // Slime in a Bottle Recipe + addOreDictRecipe(new ItemStack(ModItems.slimeBottle), + "EGE", "ESE", " E ", + 'E', LibOreDict.ELEMENTIUM, + 'G', new ItemStack(ModBlocks.elfGlass), + 'S', "slimeball"); + recipeSlimeBottle = BotaniaAPI.getLatestAddedRecipe(); + + // Starcaller Recipe + addOreDictRecipe(new ItemStack(ModItems.starSword), + " I", "AD ", "TA ", + 'I', LibOreDict.ELEMENTIUM, + 'D', LibOreDict.DRAGONSTONE, + 'A', LibOreDict.ENDER_AIR_BOTTLE, + 'T', new ItemStack(ModItems.terraSword)); + recipeStarSword = BotaniaAPI.getLatestAddedRecipe(); + + // Rod of the Shifting Crust Recipe + addOreDictRecipe(new ItemStack(ModItems.exchangeRod), + " SR", " TS", "T ", + 'T', LibOreDict.LIVINGWOOD_TWIG, + 'S', "stone", + 'R', LibOreDict.RUNE[12]); + recipeExchangeRod = BotaniaAPI.getLatestAddedRecipe(); + + // Greater Ring of Magnetization Recipe + addShapelessOreDictRecipe(new ItemStack(ModItems.magnetRingGreater), LibOreDict.TERRA_STEEL, new ItemStack(ModItems.magnetRing)); + recipeGreaterMagnetRing = BotaniaAPI.getLatestAddedRecipe(); + + // Flare Chakram Recipe + addOreDictRecipe(new ItemStack(ModItems.thornChakram, 2, 1), + "BBB", "CPC", "BBB", + 'B', new ItemStack(Items.blaze_powder), + 'P', LibOreDict.PIXIE_DUST, + 'C', new ItemStack(ModItems.thornChakram)); + recipeFireChakram = BotaniaAPI.getLatestAddedRecipe(); + + // Thundercaller Recipe + addOreDictRecipe(new ItemStack(ModItems.thunderSword), + " I", "AD ", "TA ", + 'I', LibOreDict.ELEMENTIUM, + 'D', LibOreDict.MANA_DIAMOND, + 'A', LibOreDict.ENDER_AIR_BOTTLE, + 'T', new ItemStack(ModItems.terraSword)); + recipeThunderSword = BotaniaAPI.getLatestAddedRecipe(); + + // Manatide Bellows Recipe + addOreDictRecipe(new ItemStack(ModBlocks.bellows), + "SSS", "RL ", "SSS", + 'S', new ItemStack(ModFluffBlocks.livingwoodSlab), + 'R', LibOreDict.RUNE[3], + 'L', new ItemStack(Items.leather)); + recipeBellows = BotaniaAPI.getLatestAddedRecipe(); + + // Manaweave Cloth Recipe + addOreDictRecipe(new ItemStack(ModItems.manaResource, 1, 22), + "SS", "SS", + 'S', LibOreDict.MANA_STRING); + recipeManaweaveCloth = BotaniaAPI.getLatestAddedRecipe(); + + // Manaweave Armor Recipes + addOreDictRecipe(new ItemStack(ModItems.manaweaveHelm), + "SSS", "S S", + 'S', LibOreDict.MANAWEAVE_CLOTH); + recipeManaweaveHelm = BotaniaAPI.getLatestAddedRecipe(); + addOreDictRecipe(new ItemStack(ModItems.manaweaveChest), + "S S", "SSS", "SSS", + 'S', LibOreDict.MANAWEAVE_CLOTH); + recipeManaweaveChest = BotaniaAPI.getLatestAddedRecipe(); + addOreDictRecipe(new ItemStack(ModItems.manaweaveLegs), + "SSS", "S S", "S S", + 'S', LibOreDict.MANAWEAVE_CLOTH); + recipeManaweaveLegs = BotaniaAPI.getLatestAddedRecipe(); + addOreDictRecipe(new ItemStack(ModItems.manaweaveBoots), + "S S", "S S", + 'S', LibOreDict.MANAWEAVE_CLOTH); + recipeManaweaveBoots = BotaniaAPI.getLatestAddedRecipe(); + + // Bifrost Blocks Recipe + addShapelessOreDictRecipe(new ItemStack(ModBlocks.bifrostPerm), new ItemStack(ModItems.rainbowRod), new ItemStack(ModBlocks.elfGlass)); + recipeBifrost = BotaniaAPI.getLatestAddedRecipe(); + addShapelessOreDictRecipe(new ItemStack(ModBlocks.shimmerrock), LibOreDict.LIVING_ROCK, new ItemStack(ModBlocks.bifrostPerm)); + recipeShimmerrock = BotaniaAPI.getLatestAddedRecipe(); + addShapelessOreDictRecipe(new ItemStack(ModBlocks.shimmerwoodPlanks), new ItemStack(ModBlocks.dreamwood, 1, 1), new ItemStack(ModBlocks.bifrostPerm)); + recipeShimmerwoodPlanks = BotaniaAPI.getLatestAddedRecipe(); + + // Manufactory Halo Recipe + addShapelessOreDictRecipe(new ItemStack(ModItems.autocraftingHalo), new ItemStack(ModItems.craftingHalo), LibOreDict.MANA_DIAMOND); + recipeAutocraftingHalo = BotaniaAPI.getLatestAddedRecipe(); + + // Pavement Recipes + addShapelessOreDictRecipe(new ItemStack(ModFluffBlocks.pavement, 3, 0), LibOreDict.LIVING_ROCK, "cobblestone", "gravel"); + addShapelessOreDictRecipe(new ItemStack(ModFluffBlocks.pavement, 3, 1), LibOreDict.LIVING_ROCK, "cobblestone", "gravel", new ItemStack(Items.coal)); + addShapelessOreDictRecipe(new ItemStack(ModFluffBlocks.pavement, 3, 2), LibOreDict.LIVING_ROCK, "cobblestone", "gravel", new ItemStack(Items.dye, 1, 4)); + addShapelessOreDictRecipe(new ItemStack(ModFluffBlocks.pavement, 3, 3), LibOreDict.LIVING_ROCK, "cobblestone", "gravel", new ItemStack(Items.redstone)); + addShapelessOreDictRecipe(new ItemStack(ModFluffBlocks.pavement, 3, 4), LibOreDict.LIVING_ROCK, "cobblestone", "gravel", new ItemStack(Items.wheat)); + addShapelessOreDictRecipe(new ItemStack(ModFluffBlocks.pavement, 3, 5), LibOreDict.LIVING_ROCK, "cobblestone", "gravel", new ItemStack(Items.slime_ball)); + recipesPavement = BotaniaAPI.getLatestAddedRecipes(6); + + // Cellular Block Recipe + GameRegistry.addShapelessRecipe(new ItemStack(ModBlocks.cellBlock, 3), new ItemStack(Blocks.cactus), new ItemStack(Blocks.cactus), new ItemStack(Blocks.cactus), new ItemStack(Blocks.cactus), new ItemStack(Items.carrot), new ItemStack(Items.potato)); + recipeCellBlock = BotaniaAPI.getLatestAddedRecipe(); + + // Corporea Retainer Recipe + addShapelessOreDictRecipe(new ItemStack(ModBlocks.corporeaRetainer), new ItemStack(Blocks.chest), new ItemStack(ModItems.corporeaSpark)); + recipeCorporeaRetainer = BotaniaAPI.getLatestAddedRecipe(); + + // Teru Teru Bozu Recipe + addOreDictRecipe(new ItemStack(ModBlocks.teruTeruBozu), + "C", "C", "S", + 'C', LibOreDict.MANAWEAVE_CLOTH, + 'S', new ItemStack(Blocks.double_plant)); + recipeTeruTeruBozu = BotaniaAPI.getLatestAddedRecipe(); + + // Livingwood Avatar Recipe + addOreDictRecipe(new ItemStack(ModBlocks.avatar), + " W ", "WDW", "W W", + 'W', LibOreDict.LIVING_WOOD, + 'D', LibOreDict.MANA_DIAMOND); + recipeAvatar = BotaniaAPI.getLatestAddedRecipe(); + + // Worldshaper's Sextant Recipe + addOreDictRecipe(new ItemStack(ModItems.sextant), + " TI", " TT", "III", + 'T', LibOreDict.LIVINGWOOD_TWIG, + 'I', LibOreDict.MANA_STEEL); + recipeSextant = BotaniaAPI.getLatestAddedRecipe(); + + // Alternate Pasture Seed Recipes + GameRegistry.addShapelessRecipe(new ItemStack(ModItems.grassSeeds, 1, 3), new ItemStack(ModItems.grassSeeds), new ItemStack(Blocks.deadbush)); + GameRegistry.addShapelessRecipe(new ItemStack(ModItems.grassSeeds, 1, 4), new ItemStack(ModItems.grassSeeds), new ItemStack(Items.wheat)); + GameRegistry.addShapelessRecipe(new ItemStack(ModItems.grassSeeds, 1, 5), new ItemStack(ModItems.grassSeeds), new ItemStack(Items.dye, 1, 2)); + GameRegistry.addShapelessRecipe(new ItemStack(ModItems.grassSeeds, 1, 6), new ItemStack(ModItems.grassSeeds), new ItemStack(Items.blaze_powder)); + GameRegistry.addShapelessRecipe(new ItemStack(ModItems.grassSeeds, 1, 7), new ItemStack(ModItems.grassSeeds), new ItemStack(ModItems.manaResource, 1, 10)); + GameRegistry.addShapelessRecipe(new ItemStack(ModItems.grassSeeds, 1, 8), new ItemStack(ModItems.grassSeeds), new ItemStack(Items.spider_eye)); + recipesAltGrassSeeds = BotaniaAPI.getLatestAddedRecipes(6); + + // Planestrider's Sash Recipe + GameRegistry.addRecipe(new ItemStack(ModItems.speedUpBelt), + " M ", "PBP", " S ", + 'M', new ItemStack(Items.filled_map, 1, Short.MAX_VALUE), + 'P', new ItemStack(ModItems.grassSeeds), + 'B', new ItemStack(ModItems.travelBelt), + 'S', new ItemStack(Items.sugar)); + recipeSpeedUpBelt = BotaniaAPI.getLatestAddedRecipe(); + + // Bauble Case Recipe + addOreDictRecipe(new ItemStack(ModItems.baubleBox), + " M ", "MCG", " M ", + 'M', LibOreDict.MANA_STEEL, + 'C', new ItemStack(Blocks.chest), + 'G', "ingotGold"); + recipeBaubleCase = BotaniaAPI.getLatestAddedRecipe(); + + /////////////////////////////////////////////////////////////////////////////////////////////////////////// + + // Storage Block/Nugget Recipes + addOreDictRecipe(new ItemStack(ModBlocks.storage, 1, 0), + "III", "III", "III", + 'I', LibOreDict.MANA_STEEL); + addOreDictRecipe(new ItemStack(ModBlocks.storage, 1, 1), + "III", "III", "III", + 'I', LibOreDict.TERRA_STEEL); + addOreDictRecipe(new ItemStack(ModBlocks.storage, 1, 2), + "III", "III", "III", + 'I', LibOreDict.ELEMENTIUM); + addOreDictRecipe(new ItemStack(ModBlocks.storage, 1, 3), + "III", "III", "III", + 'I', LibOreDict.MANA_DIAMOND); + addOreDictRecipe(new ItemStack(ModBlocks.storage, 1, 4), + "III", "III", "III", + 'I', LibOreDict.DRAGONSTONE); + GameRegistry.addShapelessRecipe(new ItemStack(ModItems.manaResource, 9, 0), new ItemStack(ModBlocks.storage, 1, 0)); + GameRegistry.addShapelessRecipe(new ItemStack(ModItems.manaResource, 9, 4), new ItemStack(ModBlocks.storage, 1, 1)); + GameRegistry.addShapelessRecipe(new ItemStack(ModItems.manaResource, 9, 7), new ItemStack(ModBlocks.storage, 1, 2)); + GameRegistry.addShapelessRecipe(new ItemStack(ModItems.manaResource, 9, 2), new ItemStack(ModBlocks.storage, 1, 3)); + GameRegistry.addShapelessRecipe(new ItemStack(ModItems.manaResource, 9, 9), new ItemStack(ModBlocks.storage, 1, 4)); + + addOreDictRecipe(new ItemStack(ModItems.manaResource, 1, 0), + "III", "III", "III", + 'I', LibOreDict.MANASTEEL_NUGGET); + addOreDictRecipe(new ItemStack(ModItems.manaResource, 1, 4), + "III", "III", "III", + 'I', LibOreDict.TERRASTEEL_NUGGET); + addOreDictRecipe(new ItemStack(ModItems.manaResource, 1, 7), + "III", "III", "III", + 'I', LibOreDict.ELEMENTIUM_NUGGET); + addShapelessOreDictRecipe(new ItemStack(ModItems.manaResource, 9, 17), LibOreDict.MANA_STEEL); + addShapelessOreDictRecipe(new ItemStack(ModItems.manaResource, 9, 18), LibOreDict.TERRA_STEEL); + addShapelessOreDictRecipe(new ItemStack(ModItems.manaResource, 9, 19), LibOreDict.ELEMENTIUM); + + // Revealing Helmet Recipes + if(Botania.thaumcraftLoaded) { + Item goggles = (Item) Item.itemRegistry.getObject("Thaumcraft:ItemGoggles"); + GameRegistry.addShapelessRecipe(new ItemStack(ModItems.manasteelHelmRevealing), new ItemStack(ModItems.manasteelHelm), goggles); + recipeHelmetOfRevealing = BotaniaAPI.getLatestAddedRecipe(); //We want manasteel to show in the Lexicon + GameRegistry.addShapelessRecipe(new ItemStack(ModItems.terrasteelHelmRevealing), new ItemStack(ModItems.terrasteelHelm), goggles); + GameRegistry.addShapelessRecipe(new ItemStack(ModItems.elementiumHelmRevealing), new ItemStack(ModItems.elementiumHelm), goggles); + } + + // Slab & Stair Recipes + addStairsAndSlabs(ModBlocks.livingwood, 0, ModFluffBlocks.livingwoodStairs, ModFluffBlocks.livingwoodSlab); + addStairsAndSlabs(ModBlocks.livingwood, 1, ModFluffBlocks.livingwoodPlankStairs, ModFluffBlocks.livingwoodPlankSlab); + addStairsAndSlabs(ModBlocks.livingrock, 0, ModFluffBlocks.livingrockStairs, ModFluffBlocks.livingrockSlab); + addStairsAndSlabs(ModBlocks.livingrock, 1, ModFluffBlocks.livingrockBrickStairs, ModFluffBlocks.livingrockBrickSlab); + addStairsAndSlabs(ModBlocks.dreamwood, 0, ModFluffBlocks.dreamwoodStairs, ModFluffBlocks.dreamwoodSlab); + addStairsAndSlabs(ModBlocks.dreamwood, 1, ModFluffBlocks.dreamwoodPlankStairs, ModFluffBlocks.dreamwoodPlankSlab); + addStairsAndSlabs(ModBlocks.prismarine, 0, ModFluffBlocks.prismarineStairs, ModFluffBlocks.prismarineSlab); + addStairsAndSlabs(ModBlocks.prismarine, 1, ModFluffBlocks.prismarineBrickStairs, ModFluffBlocks.prismarineBrickSlab); + addStairsAndSlabs(ModBlocks.prismarine, 2, ModFluffBlocks.darkPrismarineStairs, ModFluffBlocks.darkPrismarineSlab); + addStairsAndSlabs(ModBlocks.reedBlock, 0, ModFluffBlocks.reedStairs, ModFluffBlocks.reedSlab); + addStairsAndSlabs(ModBlocks.thatch, 0, ModFluffBlocks.thatchStairs, ModFluffBlocks.thatchSlab); + addStairsAndSlabs(ModBlocks.customBrick, 0, ModFluffBlocks.netherBrickStairs, ModFluffBlocks.netherBrickSlab); + addStairsAndSlabs(ModBlocks.customBrick, 1, ModFluffBlocks.soulBrickStairs, ModFluffBlocks.soulBrickSlab); + addStairsAndSlabs(ModBlocks.customBrick, 2, ModFluffBlocks.snowBrickStairs, ModFluffBlocks.snowBrickSlab); + addStairsAndSlabs(ModBlocks.customBrick, 3, ModFluffBlocks.tileStairs, ModFluffBlocks.tileSlab); + addStairsAndSlabs(ModBlocks.endStoneBrick, 0, ModFluffBlocks.endStoneStairs, ModFluffBlocks.endStoneSlab); + addStairsAndSlabs(ModBlocks.shimmerrock, 0, ModFluffBlocks.shimmerrockStairs, ModFluffBlocks.shimmerrockSlab); + addStairsAndSlabs(ModBlocks.shimmerwoodPlanks, 0, ModFluffBlocks.shimmerwoodPlankStairs, ModFluffBlocks.shimmerwoodPlankSlab); + + // Wall Recipes + addWall(ModBlocks.livingrock, 0, ModFluffBlocks.livingrockWall, 0); + addWall(ModBlocks.livingwood, 0, ModFluffBlocks.livingwoodWall, 0); + addWall(ModBlocks.dreamwood, 0, ModFluffBlocks.dreamwoodWall, 0); + addWall(ModBlocks.prismarine, 0, ModFluffBlocks.prismarineWall, 0); + addWall(ModBlocks.reedBlock, 0, ModFluffBlocks.reedWall, 0); + for(int i = 0; i < 8; i++) + addWall(ModFluffBlocks.biomeStoneA, i + 8, ModFluffBlocks.biomeStoneWall, i); + for(int i = 0; i < 4; i++) + addWall(ModFluffBlocks.stone, i, ModFluffBlocks.stoneWall, i); + + // Pane Recipes + addPane(ModBlocks.manaGlass, ModFluffBlocks.managlassPane); + addPane(ModBlocks.elfGlass, ModFluffBlocks.alfglassPane); + addPane(ModBlocks.bifrostPerm, ModFluffBlocks.bifrostPane); + + // Biome Stone Recipes + for(int i = 0; i < 8; i++) { + GameRegistry.addSmelting(new ItemStack(ModFluffBlocks.biomeStoneA, 1, i + 8), new ItemStack(ModFluffBlocks.biomeStoneA, 1, i), 0.1F); + GameRegistry.addRecipe(new ItemStack(ModFluffBlocks.biomeStoneB, 4, i), "SS", "SS", 'S', new ItemStack(ModFluffBlocks.biomeStoneA, 1, i)); + GameRegistry.addRecipe(new ItemStack(ModFluffBlocks.biomeStoneB, 1, i + 8), "S", "S", 'S', new ItemStack(ModFluffBlocks.biomeStoneSlabs[i + 16])); + addStairsAndSlabs(ModFluffBlocks.biomeStoneA, i, ModFluffBlocks.biomeStoneStairs[i], ModFluffBlocks.biomeStoneSlabs[i]); + addStairsAndSlabs(ModFluffBlocks.biomeStoneA, i + 8, ModFluffBlocks.biomeStoneStairs[i + 8], ModFluffBlocks.biomeStoneSlabs[i + 8]); + addStairsAndSlabs(ModFluffBlocks.biomeStoneB, i, ModFluffBlocks.biomeStoneStairs[i + 16], ModFluffBlocks.biomeStoneSlabs[i + 16]); + } + + // 1.8 Block Stone Stairs & Slabs + for(int i = 0; i < 4; i++) { + addOreDictRecipe(new ItemStack(ModFluffBlocks.stoneSlabs[i], 6), + "QQQ", + 'Q', LibOreDict.STONE_18_VARIANTS[i]); + addOreDictRecipe(new ItemStack(ModFluffBlocks.stoneStairs[i], 4), + " Q", " QQ", "QQQ", + 'Q', LibOreDict.STONE_18_VARIANTS[i]); + addOreDictRecipe(new ItemStack(ModFluffBlocks.stoneStairs[i], 4), + "Q ", "QQ ", "QQQ", + 'Q', LibOreDict.STONE_18_VARIANTS[i]); + addOreDictRecipe(new ItemStack(ModFluffBlocks.stone, 1, i), + "Q", "Q", + 'Q', new ItemStack(ModFluffBlocks.stoneSlabs[i])); + + addOreDictRecipe(new ItemStack(ModFluffBlocks.stoneSlabs[i + 4], 6), + "QQQ", + 'Q', LibOreDict.STONE_18_VARIANTS[i + 8]); + addOreDictRecipe(new ItemStack(ModFluffBlocks.stoneStairs[i + 4], 4), + " Q", " QQ", "QQQ", + 'Q', LibOreDict.STONE_18_VARIANTS[i + 8]); + addOreDictRecipe(new ItemStack(ModFluffBlocks.stoneStairs[i + 4], 4), + "Q ", "QQ ", "QQQ", + 'Q', LibOreDict.STONE_18_VARIANTS[i + 8]); + addOreDictRecipe(new ItemStack(ModFluffBlocks.stone, 1, i + 8), //VERY VERY + "Q", "Q", //BIG BIG + 'Q', new ItemStack(ModFluffBlocks.stoneSlabs[i + 4])); //PROBLEM PROBLEM + } + + // Pavement Stairsm & Stairs + for(int i = 0; i < ModFluffBlocks.pavementStairs.length; i++) + addStairsAndSlabs(ModFluffBlocks.pavement, i, ModFluffBlocks.pavementStairs[i], ModFluffBlocks.pavementSlabs[i]); + + // Misc Recipes + GameRegistry.addShapelessRecipe(new ItemStack(Items.reeds, 9, 0), new ItemStack(ModBlocks.reedBlock)); + GameRegistry.addShapelessRecipe(new ItemStack(Items.wheat, 4, 0), new ItemStack(ModBlocks.thatch)); + + if(Botania.gardenOfGlassLoaded) + initGardenOfGlass(); + + int newRecipeListSize = CraftingManager.getInstance().getRecipeList().size(); + FMLLog.log(Level.INFO, "[Botania] Registered %d recipes.", newRecipeListSize - recipeListSize); + } + + private static void initGardenOfGlass() { + // Root to Sapling + addShapelessOreDictRecipe(new ItemStack(Blocks.sapling), LibOreDict.ROOT, LibOreDict.ROOT, LibOreDict.ROOT, LibOreDict.ROOT); + recipeRootToSapling = BotaniaAPI.getLatestAddedRecipe(); + + // Root to Fertilizer + addShapelessOreDictRecipe(new ItemStack(ModItems.fertilizer), LibOreDict.ROOT); + recipeRootToFertilizer = BotaniaAPI.getLatestAddedRecipe(); + + // Pebble to Cobble + addShapelessOreDictRecipe(new ItemStack(Blocks.cobblestone), LibOreDict.PEBBLE, LibOreDict.PEBBLE, LibOreDict.PEBBLE, LibOreDict.PEBBLE); + recipePebbleCobblestone = BotaniaAPI.getLatestAddedRecipe(); + + // Magma Pearl to Slimeball + addShapelessOreDictRecipe(new ItemStack(Items.slime_ball), new ItemStack(Items.magma_cream), new ItemStack(Items.water_bucket)); + recipeMagmaToSlimeball = BotaniaAPI.getLatestAddedRecipe(); + + // Ender Portal + addOreDictRecipe(new ItemStack(Blocks.end_portal_frame), + "OGO", + 'O', new ItemStack(Blocks.obsidian), + 'G', LibOreDict.LIFE_ESSENCE); + recipeEndPortal = BotaniaAPI.getLatestAddedRecipe(); + } + + private static void addStairsAndSlabs(Block block, int meta, Block stairs, Block slab) { + GameRegistry.addRecipe(new ItemStack(slab, 6), + "QQQ", + 'Q', new ItemStack(block, 1, meta)); + GameRegistry.addRecipe(new ItemStack(stairs, 4), + " Q", " QQ", "QQQ", + 'Q', new ItemStack(block, 1, meta)); + GameRegistry.addRecipe(new ItemStack(stairs, 4), + "Q ", "QQ ", "QQQ", + 'Q', new ItemStack(block, 1, meta)); + GameRegistry.addRecipe(new ItemStack(block, 1, meta), + "Q", "Q", + 'Q', new ItemStack(slab)); + } + + private static void addWall(Block block, int blockMeta, Block wall, int wallMeta) { + GameRegistry.addRecipe(new ItemStack(wall, 6, wallMeta), + "BBB", "BBB", + 'B', new ItemStack(block, 1, blockMeta)); + } + + private static void addPane(Block block, Block pane) { + GameRegistry.addRecipe(new ItemStack(pane, 16), + "BBB", "BBB", + 'B', new ItemStack(block, 1)); + } + + private static IRecipe addQuartzRecipes(int meta, Item req, Block block, Block stairs, Block slab) { + GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(block), + "QQ", "QQ", + 'Q', LibOreDict.QUARTZ[meta])); + GameRegistry.addRecipe(new ItemStack(block, 2, 2), + "Q", "Q", + 'Q', block); + GameRegistry.addRecipe(new ItemStack(block, 1, 1), + "Q", "Q", + 'Q', slab); + addStairsAndSlabs(block, 0, stairs, slab); + + if(req != null) { + if(req == Items.coal) + GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(ModItems.quartz, 8, meta), + "QQQ", "QCQ", "QQQ", + 'Q', "gemQuartz", + 'C', new ItemStack(req, 1, 1))); + GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(ModItems.quartz, 8, meta), + "QQQ", "QCQ", "QQQ", + 'Q', "gemQuartz", + 'C', req)); + return BotaniaAPI.getLatestAddedRecipe(); + } + return null; + } + + private static void addOreDictRecipe(ItemStack output, Object... recipe) { + CraftingManager.getInstance().getRecipeList().add(new ShapedOreRecipe(output, recipe)); + } + + private static void addShapelessOreDictRecipe(ItemStack output, Object... recipe) { + CraftingManager.getInstance().getRecipeList().add(new ShapelessOreRecipe(output, recipe)); + } } diff --git a/src/main/java/vazkii/botania/common/crafting/ModElvenTradeRecipes.java b/src/main/java/vazkii/botania/common/crafting/ModElvenTradeRecipes.java index d839153f5d..c5dbb2c22d 100644 --- a/src/main/java/vazkii/botania/common/crafting/ModElvenTradeRecipes.java +++ b/src/main/java/vazkii/botania/common/crafting/ModElvenTradeRecipes.java @@ -2,6 +2,7 @@ import java.util.ArrayList; import java.util.List; + import net.minecraft.init.Blocks; import net.minecraft.init.Items; import net.minecraft.item.ItemStack; @@ -14,44 +15,35 @@ public class ModElvenTradeRecipes { - public static RecipeElvenTrade dreamwoodRecipe; - public static List elementiumRecipes; - public static RecipeElvenTrade pixieDustRecipe; - public static List dragonstoneRecipes; - public static RecipeElvenTrade elvenQuartzRecipe; - public static RecipeElvenTrade alfglassRecipe; - - public static void init() { - if (!ConfigHandler.enableDefaultRecipes) return; - - dreamwoodRecipe = - BotaniaAPI.registerElvenTradeRecipe(new ItemStack(ModBlocks.dreamwood), LibOreDict.LIVING_WOOD); - - elementiumRecipes = new ArrayList(); - elementiumRecipes.add(BotaniaAPI.registerElvenTradeRecipe( - new ItemStack(ModItems.manaResource, 1, 7), LibOreDict.MANA_STEEL, LibOreDict.MANA_STEEL)); - elementiumRecipes.add(BotaniaAPI.registerElvenTradeRecipe( - new ItemStack(ModBlocks.storage, 1, 2), - new ItemStack(ModBlocks.storage), - new ItemStack(ModBlocks.storage))); - - pixieDustRecipe = - BotaniaAPI.registerElvenTradeRecipe(new ItemStack(ModItems.manaResource, 1, 8), LibOreDict.MANA_PEARL); - dragonstoneRecipes = new ArrayList(); - dragonstoneRecipes.add(BotaniaAPI.registerElvenTradeRecipe( - new ItemStack(ModItems.manaResource, 1, 9), LibOreDict.MANA_DIAMOND)); - dragonstoneRecipes.add(BotaniaAPI.registerElvenTradeRecipe( - new ItemStack(ModBlocks.storage, 1, 4), new ItemStack(ModBlocks.storage, 1, 3))); - - elvenQuartzRecipe = - BotaniaAPI.registerElvenTradeRecipe(new ItemStack(ModItems.quartz, 1, 5), new ItemStack(Items.quartz)); - alfglassRecipe = BotaniaAPI.registerElvenTradeRecipe( - new ItemStack(ModBlocks.elfGlass), new ItemStack(ModBlocks.manaGlass)); - - BotaniaAPI.registerElvenTradeRecipe(new ItemStack(Items.iron_ingot), new ItemStack(Items.iron_ingot)); - BotaniaAPI.registerElvenTradeRecipe(new ItemStack(Blocks.iron_block), new ItemStack(Blocks.iron_block)); - BotaniaAPI.registerElvenTradeRecipe(new ItemStack(Items.ender_pearl), new ItemStack(Items.ender_pearl)); - BotaniaAPI.registerElvenTradeRecipe(new ItemStack(Items.diamond), new ItemStack(Items.diamond)); - BotaniaAPI.registerElvenTradeRecipe(new ItemStack(Blocks.diamond_block), new ItemStack(Blocks.diamond_block)); - } + public static RecipeElvenTrade dreamwoodRecipe; + public static List elementiumRecipes; + public static RecipeElvenTrade pixieDustRecipe; + public static List dragonstoneRecipes; + public static RecipeElvenTrade elvenQuartzRecipe; + public static RecipeElvenTrade alfglassRecipe; + + public static void init() { + if (!ConfigHandler.enableDefaultRecipes) return; + + dreamwoodRecipe = BotaniaAPI.registerElvenTradeRecipe(new ItemStack(ModBlocks.dreamwood), LibOreDict.LIVING_WOOD); + + elementiumRecipes = new ArrayList(); + elementiumRecipes.add(BotaniaAPI.registerElvenTradeRecipe(new ItemStack(ModItems.manaResource, 1, 7), LibOreDict.MANA_STEEL, LibOreDict.MANA_STEEL)); + elementiumRecipes.add(BotaniaAPI.registerElvenTradeRecipe(new ItemStack(ModBlocks.storage, 1, 2), new ItemStack(ModBlocks.storage), new ItemStack(ModBlocks.storage))); + + pixieDustRecipe = BotaniaAPI.registerElvenTradeRecipe(new ItemStack(ModItems.manaResource, 1, 8), LibOreDict.MANA_PEARL); + dragonstoneRecipes = new ArrayList(); + dragonstoneRecipes.add(BotaniaAPI.registerElvenTradeRecipe(new ItemStack(ModItems.manaResource, 1, 9), LibOreDict.MANA_DIAMOND)); + dragonstoneRecipes.add(BotaniaAPI.registerElvenTradeRecipe(new ItemStack(ModBlocks.storage, 1, 4), new ItemStack(ModBlocks.storage, 1, 3))); + + elvenQuartzRecipe = BotaniaAPI.registerElvenTradeRecipe(new ItemStack(ModItems.quartz, 1, 5), new ItemStack(Items.quartz)); + alfglassRecipe = BotaniaAPI.registerElvenTradeRecipe(new ItemStack(ModBlocks.elfGlass), new ItemStack(ModBlocks.manaGlass)); + + BotaniaAPI.registerElvenTradeRecipe(new ItemStack(Items.iron_ingot), new ItemStack(Items.iron_ingot)); + BotaniaAPI.registerElvenTradeRecipe(new ItemStack(Blocks.iron_block), new ItemStack(Blocks.iron_block)); + BotaniaAPI.registerElvenTradeRecipe(new ItemStack(Items.ender_pearl), new ItemStack(Items.ender_pearl)); + BotaniaAPI.registerElvenTradeRecipe(new ItemStack(Items.diamond), new ItemStack(Items.diamond)); + BotaniaAPI.registerElvenTradeRecipe(new ItemStack(Blocks.diamond_block), new ItemStack(Blocks.diamond_block)); + } + } diff --git a/src/main/java/vazkii/botania/common/crafting/ModManaAlchemyRecipes.java b/src/main/java/vazkii/botania/common/crafting/ModManaAlchemyRecipes.java index 7eb8384e5d..f2e9617a5f 100644 --- a/src/main/java/vazkii/botania/common/crafting/ModManaAlchemyRecipes.java +++ b/src/main/java/vazkii/botania/common/crafting/ModManaAlchemyRecipes.java @@ -2,16 +2,17 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [May 2, 2014, 7:50:07 PM (GMT)] */ package vazkii.botania.common.crafting; import java.util.ArrayList; import java.util.List; + import net.minecraft.block.Block; import net.minecraft.init.Blocks; import net.minecraft.init.Items; @@ -24,211 +25,140 @@ public final class ModManaAlchemyRecipes { - public static RecipeManaInfusion leatherRecipe; - public static List woodRecipes; - public static List saplingRecipes; - public static RecipeManaInfusion glowstoneDustRecipe; - public static List quartzRecipes; - public static RecipeManaInfusion chiseledBrickRecipe; - public static RecipeManaInfusion iceRecipe; - public static List swampFolliageRecipes; - public static List fishRecipes; - public static List cropRecipes; - public static RecipeManaInfusion potatoRecipe; - public static RecipeManaInfusion netherWartRecipe; - public static List gunpowderAndFlintRecipes; - public static RecipeManaInfusion nameTagRecipe; - public static List stringRecipes; - public static List slimeballCactusRecipes; - public static RecipeManaInfusion enderPearlRecipe; - public static List redstoneToGlowstoneRecipes; - public static RecipeManaInfusion sandRecipe; - public static RecipeManaInfusion redSandRecipe; - public static List clayBreakdownRecipes; - public static RecipeManaInfusion coarseDirtRecipe; - public static RecipeManaInfusion prismarineRecipe; - public static List stoneRecipes; - public static List tallgrassRecipes; - public static List flowersRecipes; - - public static void init() { - if (!ConfigHandler.enableDefaultRecipes) return; - - leatherRecipe = BotaniaAPI.registerManaAlchemyRecipe( - new ItemStack(Items.leather), new ItemStack(Items.rotten_flesh), 600); - - woodRecipes = new ArrayList(); - woodRecipes.add(BotaniaAPI.registerManaAlchemyRecipe( - new ItemStack(Blocks.log, 1, 0), new ItemStack(Blocks.log2, 1, 1), 40)); - woodRecipes.add(BotaniaAPI.registerManaAlchemyRecipe( - new ItemStack(Blocks.log, 1, 1), new ItemStack(Blocks.log, 1, 0), 40)); - woodRecipes.add(BotaniaAPI.registerManaAlchemyRecipe( - new ItemStack(Blocks.log, 1, 2), new ItemStack(Blocks.log, 1, 1), 40)); - woodRecipes.add(BotaniaAPI.registerManaAlchemyRecipe( - new ItemStack(Blocks.log, 1, 3), new ItemStack(Blocks.log, 1, 2), 40)); - woodRecipes.add(BotaniaAPI.registerManaAlchemyRecipe( - new ItemStack(Blocks.log2, 1, 0), new ItemStack(Blocks.log, 1, 3), 40)); - woodRecipes.add(BotaniaAPI.registerManaAlchemyRecipe( - new ItemStack(Blocks.log2, 1, 1), new ItemStack(Blocks.log2, 1, 0), 40)); - - saplingRecipes = new ArrayList(); - for (int i = 0; i < 6; i++) - saplingRecipes.add(BotaniaAPI.registerManaAlchemyRecipe( - new ItemStack(Blocks.sapling, 1, i == 5 ? 0 : i + 1), new ItemStack(Blocks.sapling, 1, i), 120)); - - glowstoneDustRecipe = BotaniaAPI.registerManaAlchemyRecipe( - new ItemStack(Items.glowstone_dust, 4), new ItemStack(Blocks.glowstone), 25); - quartzRecipes = new ArrayList(); - quartzRecipes.add(BotaniaAPI.registerManaAlchemyRecipe( - new ItemStack(Items.quartz, 4), new ItemStack(Blocks.quartz_block, 1, Short.MAX_VALUE), 25)); - if (ConfigHandler.darkQuartzEnabled) - quartzRecipes.add(BotaniaAPI.registerManaAlchemyRecipe( - new ItemStack(ModItems.quartz, 4, 0), - new ItemStack(ModFluffBlocks.darkQuartz, 1, Short.MAX_VALUE), - 25)); - quartzRecipes.add(BotaniaAPI.registerManaAlchemyRecipe( - new ItemStack(ModItems.quartz, 4, 1), - new ItemStack(ModFluffBlocks.manaQuartz, 1, Short.MAX_VALUE), - 25)); - quartzRecipes.add(BotaniaAPI.registerManaAlchemyRecipe( - new ItemStack(ModItems.quartz, 4, 2), - new ItemStack(ModFluffBlocks.blazeQuartz, 1, Short.MAX_VALUE), - 25)); - quartzRecipes.add(BotaniaAPI.registerManaAlchemyRecipe( - new ItemStack(ModItems.quartz, 4, 3), - new ItemStack(ModFluffBlocks.lavenderQuartz, 1, Short.MAX_VALUE), - 25)); - quartzRecipes.add(BotaniaAPI.registerManaAlchemyRecipe( - new ItemStack(ModItems.quartz, 4, 4), new ItemStack(ModFluffBlocks.redQuartz, 1, Short.MAX_VALUE), 25)); - quartzRecipes.add(BotaniaAPI.registerManaAlchemyRecipe( - new ItemStack(ModItems.quartz, 4, 5), new ItemStack(ModFluffBlocks.elfQuartz, 1, Short.MAX_VALUE), 25)); - - chiseledBrickRecipe = BotaniaAPI.registerManaAlchemyRecipe( - new ItemStack(Blocks.stonebrick, 1, 3), new ItemStack(Blocks.stonebrick), 150); - iceRecipe = BotaniaAPI.registerManaAlchemyRecipe(new ItemStack(Blocks.ice), new ItemStack(Blocks.snow), 2250); - - swampFolliageRecipes = new ArrayList(); - swampFolliageRecipes.add( - BotaniaAPI.registerManaAlchemyRecipe(new ItemStack(Blocks.waterlily), new ItemStack(Blocks.vine), 320)); - swampFolliageRecipes.add( - BotaniaAPI.registerManaAlchemyRecipe(new ItemStack(Blocks.vine), new ItemStack(Blocks.waterlily), 320)); - - fishRecipes = new ArrayList(); - for (int i = 0; i < 4; i++) - fishRecipes.add(BotaniaAPI.registerManaAlchemyRecipe( - new ItemStack(Items.fish, 1, i == 3 ? 0 : i + 1), new ItemStack(Items.fish, 1, i), 200)); - - cropRecipes = new ArrayList(); - cropRecipes.add(BotaniaAPI.registerManaAlchemyRecipe( - new ItemStack(Items.wheat_seeds), new ItemStack(Items.dye, 1, 3), 6000)); - cropRecipes.add( - BotaniaAPI.registerManaAlchemyRecipe(new ItemStack(Items.potato), new ItemStack(Items.wheat), 6000)); - cropRecipes.add( - BotaniaAPI.registerManaAlchemyRecipe(new ItemStack(Items.carrot), new ItemStack(Items.potato), 6000)); - cropRecipes.add(BotaniaAPI.registerManaAlchemyRecipe( - new ItemStack(Items.melon_seeds), new ItemStack(Items.carrot), 6000)); - cropRecipes.add(BotaniaAPI.registerManaAlchemyRecipe( - new ItemStack(Items.pumpkin_seeds), new ItemStack(Items.melon_seeds), 6000)); - cropRecipes.add(BotaniaAPI.registerManaAlchemyRecipe( - new ItemStack(Items.dye, 1, 3), new ItemStack(Items.pumpkin_seeds), 6000)); - - potatoRecipe = BotaniaAPI.registerManaAlchemyRecipe( - new ItemStack(Items.potato), new ItemStack(Items.poisonous_potato), 1200); - netherWartRecipe = BotaniaAPI.registerManaAlchemyRecipe( - new ItemStack(Items.nether_wart), new ItemStack(Items.blaze_rod), 4000); - - gunpowderAndFlintRecipes = new ArrayList(); - gunpowderAndFlintRecipes.add( - BotaniaAPI.registerManaAlchemyRecipe(new ItemStack(Items.flint), new ItemStack(Items.gunpowder), 200)); - gunpowderAndFlintRecipes.add( - BotaniaAPI.registerManaAlchemyRecipe(new ItemStack(Items.gunpowder), new ItemStack(Items.flint), 4000)); - - nameTagRecipe = BotaniaAPI.registerManaAlchemyRecipe( - new ItemStack(Items.name_tag), new ItemStack(Items.writable_book), 16000); - - stringRecipes = new ArrayList(); - for (int i = 0; i < 16; i++) - stringRecipes.add(BotaniaAPI.registerManaAlchemyRecipe( - new ItemStack(Items.string, 3), new ItemStack(Blocks.wool, 1, i), 100)); - - slimeballCactusRecipes = new ArrayList(); - slimeballCactusRecipes.add(BotaniaAPI.registerManaAlchemyRecipe( - new ItemStack(Items.slime_ball), new ItemStack(Blocks.cactus), 1200)); - slimeballCactusRecipes.add(BotaniaAPI.registerManaAlchemyRecipe( - new ItemStack(Blocks.cactus), new ItemStack(Items.slime_ball), 1200)); - - enderPearlRecipe = BotaniaAPI.registerManaAlchemyRecipe( - new ItemStack(Items.ender_pearl), new ItemStack(Items.ghast_tear), 28000); - - redstoneToGlowstoneRecipes = new ArrayList(); - redstoneToGlowstoneRecipes.add(BotaniaAPI.registerManaAlchemyRecipe( - new ItemStack(Items.redstone), new ItemStack(Items.glowstone_dust), 300)); - redstoneToGlowstoneRecipes.add(BotaniaAPI.registerManaAlchemyRecipe( - new ItemStack(Items.glowstone_dust), new ItemStack(Items.redstone), 300)); - - sandRecipe = BotaniaAPI.registerManaAlchemyRecipe( - new ItemStack(Block.getBlockFromName("sand")), new ItemStack(Blocks.cobblestone), 50); - redSandRecipe = BotaniaAPI.registerManaAlchemyRecipe( - new ItemStack(Block.getBlockFromName("sand"), 1, 1), new ItemStack(Blocks.hardened_clay), 50); - - clayBreakdownRecipes = new ArrayList(); - clayBreakdownRecipes.add(BotaniaAPI.registerManaAlchemyRecipe( - new ItemStack(Items.clay_ball, 4), new ItemStack(Blocks.clay), 25)); - clayBreakdownRecipes.add(BotaniaAPI.registerManaAlchemyRecipe( - new ItemStack(Items.brick, 4), new ItemStack(Blocks.brick_block), 25)); - - coarseDirtRecipe = - BotaniaAPI.registerManaAlchemyRecipe(new ItemStack(Blocks.dirt, 1, 1), new ItemStack(Blocks.dirt), 120); - - prismarineRecipe = BotaniaAPI.registerManaAlchemyRecipe( - new ItemStack(ModItems.manaResource, 1, 10), new ItemStack(Items.quartz), 200); - - if (ConfigHandler.stones18Enabled) { - stoneRecipes = new ArrayList(); - stoneRecipes.add(BotaniaAPI.registerManaAlchemyRecipe(new ItemStack(ModFluffBlocks.stone), "stone", 200)); - for (int i = 0; i < 4; i++) - stoneRecipes.add(BotaniaAPI.registerManaAlchemyRecipe( - new ItemStack(ModFluffBlocks.stone, 1, i), - new ItemStack(ModFluffBlocks.stone, 1, i == 0 ? 3 : i - 1), - 200)); - } - - tallgrassRecipes = new ArrayList(); - tallgrassRecipes.add(BotaniaAPI.registerManaAlchemyRecipe( - new ItemStack(Blocks.deadbush), new ItemStack(Blocks.tallgrass, 1, 2), 500)); - tallgrassRecipes.add(BotaniaAPI.registerManaAlchemyRecipe( - new ItemStack(Blocks.tallgrass, 1, 1), new ItemStack(Blocks.deadbush), 500)); - tallgrassRecipes.add(BotaniaAPI.registerManaAlchemyRecipe( - new ItemStack(Blocks.tallgrass, 1, 2), new ItemStack(Blocks.tallgrass, 1, 1), 500)); - - flowersRecipes = new ArrayList(); - flowersRecipes.add(BotaniaAPI.registerManaAlchemyRecipe( - new ItemStack(Blocks.red_flower), new ItemStack(Blocks.yellow_flower), 400)); - flowersRecipes.add(BotaniaAPI.registerManaAlchemyRecipe( - new ItemStack(Blocks.red_flower, 1, 1), new ItemStack(Blocks.red_flower), 400)); - flowersRecipes.add(BotaniaAPI.registerManaAlchemyRecipe( - new ItemStack(Blocks.red_flower, 1, 2), new ItemStack(Blocks.red_flower, 1, 1), 400)); - flowersRecipes.add(BotaniaAPI.registerManaAlchemyRecipe( - new ItemStack(Blocks.red_flower, 1, 3), new ItemStack(Blocks.red_flower, 1, 2), 400)); - flowersRecipes.add(BotaniaAPI.registerManaAlchemyRecipe( - new ItemStack(Blocks.red_flower, 1, 4), new ItemStack(Blocks.red_flower, 1, 3), 400)); - flowersRecipes.add(BotaniaAPI.registerManaAlchemyRecipe( - new ItemStack(Blocks.red_flower, 1, 5), new ItemStack(Blocks.red_flower, 1, 4), 400)); - flowersRecipes.add(BotaniaAPI.registerManaAlchemyRecipe( - new ItemStack(Blocks.red_flower, 1, 6), new ItemStack(Blocks.red_flower, 1, 5), 400)); - flowersRecipes.add(BotaniaAPI.registerManaAlchemyRecipe( - new ItemStack(Blocks.red_flower, 1, 7), new ItemStack(Blocks.red_flower, 1, 6), 400)); - flowersRecipes.add(BotaniaAPI.registerManaAlchemyRecipe( - new ItemStack(Blocks.red_flower, 1, 8), new ItemStack(Blocks.red_flower, 1, 7), 400)); - flowersRecipes.add(BotaniaAPI.registerManaAlchemyRecipe( - new ItemStack(Blocks.double_plant), new ItemStack(Blocks.red_flower, 1, 8), 400)); - flowersRecipes.add(BotaniaAPI.registerManaAlchemyRecipe( - new ItemStack(Blocks.double_plant, 1, 1), new ItemStack(Blocks.double_plant), 400)); - flowersRecipes.add(BotaniaAPI.registerManaAlchemyRecipe( - new ItemStack(Blocks.double_plant, 1, 4), new ItemStack(Blocks.double_plant, 1, 1), 400)); - flowersRecipes.add(BotaniaAPI.registerManaAlchemyRecipe( - new ItemStack(Blocks.double_plant, 1, 5), new ItemStack(Blocks.double_plant, 1, 4), 400)); - flowersRecipes.add(BotaniaAPI.registerManaAlchemyRecipe( - new ItemStack(Blocks.yellow_flower), new ItemStack(Blocks.double_plant, 1, 5), 400)); - } + public static RecipeManaInfusion leatherRecipe; + public static List woodRecipes; + public static List saplingRecipes; + public static RecipeManaInfusion glowstoneDustRecipe; + public static List quartzRecipes; + public static RecipeManaInfusion chiseledBrickRecipe; + public static RecipeManaInfusion iceRecipe; + public static List swampFolliageRecipes; + public static List fishRecipes; + public static List cropRecipes; + public static RecipeManaInfusion potatoRecipe; + public static RecipeManaInfusion netherWartRecipe; + public static List gunpowderAndFlintRecipes; + public static RecipeManaInfusion nameTagRecipe; + public static List stringRecipes; + public static List slimeballCactusRecipes; + public static RecipeManaInfusion enderPearlRecipe; + public static List redstoneToGlowstoneRecipes; + public static RecipeManaInfusion sandRecipe; + public static RecipeManaInfusion redSandRecipe; + public static List clayBreakdownRecipes; + public static RecipeManaInfusion coarseDirtRecipe; + public static RecipeManaInfusion prismarineRecipe; + public static List stoneRecipes; + public static List tallgrassRecipes; + public static List flowersRecipes; + + public static void init() { + if (!ConfigHandler.enableDefaultRecipes) return; + + leatherRecipe = BotaniaAPI.registerManaAlchemyRecipe(new ItemStack(Items.leather), new ItemStack(Items.rotten_flesh), 600); + + woodRecipes = new ArrayList(); + woodRecipes.add(BotaniaAPI.registerManaAlchemyRecipe(new ItemStack(Blocks.log, 1, 0), new ItemStack(Blocks.log2, 1, 1), 40)); + woodRecipes.add(BotaniaAPI.registerManaAlchemyRecipe(new ItemStack(Blocks.log, 1, 1), new ItemStack(Blocks.log, 1, 0), 40)); + woodRecipes.add(BotaniaAPI.registerManaAlchemyRecipe(new ItemStack(Blocks.log, 1, 2), new ItemStack(Blocks.log, 1, 1), 40)); + woodRecipes.add(BotaniaAPI.registerManaAlchemyRecipe(new ItemStack(Blocks.log, 1, 3), new ItemStack(Blocks.log, 1, 2), 40)); + woodRecipes.add(BotaniaAPI.registerManaAlchemyRecipe(new ItemStack(Blocks.log2, 1, 0), new ItemStack(Blocks.log, 1, 3), 40)); + woodRecipes.add(BotaniaAPI.registerManaAlchemyRecipe(new ItemStack(Blocks.log2, 1, 1), new ItemStack(Blocks.log2, 1, 0), 40)); + + saplingRecipes = new ArrayList(); + for(int i = 0; i < 6; i++) + saplingRecipes.add(BotaniaAPI.registerManaAlchemyRecipe(new ItemStack(Blocks.sapling, 1, i == 5 ? 0 : i + 1), new ItemStack(Blocks.sapling, 1, i), 120)); + + glowstoneDustRecipe = BotaniaAPI.registerManaAlchemyRecipe(new ItemStack(Items.glowstone_dust, 4), new ItemStack(Blocks.glowstone), 25); + quartzRecipes = new ArrayList(); + quartzRecipes.add(BotaniaAPI.registerManaAlchemyRecipe(new ItemStack(Items.quartz, 4), new ItemStack(Blocks.quartz_block, 1, Short.MAX_VALUE), 25)); + if(ConfigHandler.darkQuartzEnabled) + quartzRecipes.add(BotaniaAPI.registerManaAlchemyRecipe(new ItemStack(ModItems.quartz, 4, 0), new ItemStack(ModFluffBlocks.darkQuartz, 1, Short.MAX_VALUE), 25)); + quartzRecipes.add(BotaniaAPI.registerManaAlchemyRecipe(new ItemStack(ModItems.quartz, 4, 1), new ItemStack(ModFluffBlocks.manaQuartz, 1, Short.MAX_VALUE), 25)); + quartzRecipes.add(BotaniaAPI.registerManaAlchemyRecipe(new ItemStack(ModItems.quartz, 4, 2), new ItemStack(ModFluffBlocks.blazeQuartz, 1, Short.MAX_VALUE), 25)); + quartzRecipes.add(BotaniaAPI.registerManaAlchemyRecipe(new ItemStack(ModItems.quartz, 4, 3), new ItemStack(ModFluffBlocks.lavenderQuartz, 1, Short.MAX_VALUE), 25)); + quartzRecipes.add(BotaniaAPI.registerManaAlchemyRecipe(new ItemStack(ModItems.quartz, 4, 4), new ItemStack(ModFluffBlocks.redQuartz, 1, Short.MAX_VALUE), 25)); + quartzRecipes.add(BotaniaAPI.registerManaAlchemyRecipe(new ItemStack(ModItems.quartz, 4, 5), new ItemStack(ModFluffBlocks.elfQuartz, 1, Short.MAX_VALUE), 25)); + + chiseledBrickRecipe = BotaniaAPI.registerManaAlchemyRecipe(new ItemStack(Blocks.stonebrick, 1, 3), new ItemStack(Blocks.stonebrick), 150); + iceRecipe = BotaniaAPI.registerManaAlchemyRecipe(new ItemStack(Blocks.ice), new ItemStack(Blocks.snow), 2250); + + swampFolliageRecipes = new ArrayList(); + swampFolliageRecipes.add(BotaniaAPI.registerManaAlchemyRecipe(new ItemStack(Blocks.waterlily), new ItemStack(Blocks.vine), 320)); + swampFolliageRecipes.add(BotaniaAPI.registerManaAlchemyRecipe(new ItemStack(Blocks.vine), new ItemStack(Blocks.waterlily), 320)); + + fishRecipes = new ArrayList(); + for(int i = 0; i < 4; i++) + fishRecipes.add(BotaniaAPI.registerManaAlchemyRecipe(new ItemStack(Items.fish, 1, i == 3 ? 0 : i + 1), new ItemStack(Items.fish, 1, i), 200)); + + cropRecipes = new ArrayList(); + cropRecipes.add(BotaniaAPI.registerManaAlchemyRecipe(new ItemStack(Items.wheat_seeds), new ItemStack(Items.dye, 1, 3), 6000)); + cropRecipes.add(BotaniaAPI.registerManaAlchemyRecipe(new ItemStack(Items.potato), new ItemStack(Items.wheat), 6000)); + cropRecipes.add(BotaniaAPI.registerManaAlchemyRecipe(new ItemStack(Items.carrot), new ItemStack(Items.potato), 6000)); + cropRecipes.add(BotaniaAPI.registerManaAlchemyRecipe(new ItemStack(Items.melon_seeds), new ItemStack(Items.carrot), 6000)); + cropRecipes.add(BotaniaAPI.registerManaAlchemyRecipe(new ItemStack(Items.pumpkin_seeds), new ItemStack(Items.melon_seeds), 6000)); + cropRecipes.add(BotaniaAPI.registerManaAlchemyRecipe(new ItemStack(Items.dye, 1, 3), new ItemStack(Items.pumpkin_seeds), 6000)); + + potatoRecipe = BotaniaAPI.registerManaAlchemyRecipe(new ItemStack(Items.potato), new ItemStack(Items.poisonous_potato), 1200); + netherWartRecipe = BotaniaAPI.registerManaAlchemyRecipe(new ItemStack(Items.nether_wart), new ItemStack(Items.blaze_rod), 4000); + + gunpowderAndFlintRecipes = new ArrayList(); + gunpowderAndFlintRecipes.add(BotaniaAPI.registerManaAlchemyRecipe(new ItemStack(Items.flint), new ItemStack(Items.gunpowder), 200)); + gunpowderAndFlintRecipes.add(BotaniaAPI.registerManaAlchemyRecipe(new ItemStack(Items.gunpowder), new ItemStack(Items.flint), 4000)); + + nameTagRecipe = BotaniaAPI.registerManaAlchemyRecipe(new ItemStack(Items.name_tag), new ItemStack(Items.writable_book), 16000); + + stringRecipes = new ArrayList(); + for(int i = 0; i < 16; i++) + stringRecipes.add(BotaniaAPI.registerManaAlchemyRecipe(new ItemStack(Items.string, 3), new ItemStack(Blocks.wool, 1, i), 100)); + + slimeballCactusRecipes = new ArrayList(); + slimeballCactusRecipes.add(BotaniaAPI.registerManaAlchemyRecipe(new ItemStack(Items.slime_ball), new ItemStack(Blocks.cactus), 1200)); + slimeballCactusRecipes.add(BotaniaAPI.registerManaAlchemyRecipe(new ItemStack(Blocks.cactus), new ItemStack(Items.slime_ball), 1200)); + + enderPearlRecipe = BotaniaAPI.registerManaAlchemyRecipe(new ItemStack(Items.ender_pearl), new ItemStack(Items.ghast_tear), 28000); + + redstoneToGlowstoneRecipes = new ArrayList(); + redstoneToGlowstoneRecipes.add(BotaniaAPI.registerManaAlchemyRecipe(new ItemStack(Items.redstone), new ItemStack(Items.glowstone_dust), 300)); + redstoneToGlowstoneRecipes.add(BotaniaAPI.registerManaAlchemyRecipe(new ItemStack(Items.glowstone_dust), new ItemStack(Items.redstone), 300)); + + sandRecipe = BotaniaAPI.registerManaAlchemyRecipe(new ItemStack(Block.getBlockFromName("sand")), new ItemStack(Blocks.cobblestone), 50); + redSandRecipe = BotaniaAPI.registerManaAlchemyRecipe(new ItemStack(Block.getBlockFromName("sand"), 1, 1), new ItemStack(Blocks.hardened_clay), 50); + + clayBreakdownRecipes = new ArrayList(); + clayBreakdownRecipes.add(BotaniaAPI.registerManaAlchemyRecipe(new ItemStack(Items.clay_ball, 4), new ItemStack(Blocks.clay), 25)); + clayBreakdownRecipes.add(BotaniaAPI.registerManaAlchemyRecipe(new ItemStack(Items.brick, 4), new ItemStack(Blocks.brick_block), 25)); + + coarseDirtRecipe = BotaniaAPI.registerManaAlchemyRecipe(new ItemStack(Blocks.dirt, 1, 1), new ItemStack(Blocks.dirt), 120); + + prismarineRecipe = BotaniaAPI.registerManaAlchemyRecipe(new ItemStack(ModItems.manaResource, 1, 10), new ItemStack(Items.quartz), 200); + + if(ConfigHandler.stones18Enabled) { + stoneRecipes = new ArrayList(); + stoneRecipes.add(BotaniaAPI.registerManaAlchemyRecipe(new ItemStack(ModFluffBlocks.stone), "stone", 200)); + for(int i = 0; i < 4; i++) + stoneRecipes.add(BotaniaAPI.registerManaAlchemyRecipe(new ItemStack(ModFluffBlocks.stone, 1, i), new ItemStack(ModFluffBlocks.stone, 1, i == 0 ? 3 : i - 1), 200)); + } + + tallgrassRecipes = new ArrayList(); + tallgrassRecipes.add(BotaniaAPI.registerManaAlchemyRecipe(new ItemStack(Blocks.deadbush), new ItemStack(Blocks.tallgrass, 1, 2), 500)); + tallgrassRecipes.add(BotaniaAPI.registerManaAlchemyRecipe(new ItemStack(Blocks.tallgrass, 1, 1), new ItemStack(Blocks.deadbush), 500)); + tallgrassRecipes.add(BotaniaAPI.registerManaAlchemyRecipe(new ItemStack(Blocks.tallgrass, 1, 2), new ItemStack(Blocks.tallgrass, 1, 1), 500)); + + flowersRecipes = new ArrayList(); + flowersRecipes.add(BotaniaAPI.registerManaAlchemyRecipe(new ItemStack(Blocks.red_flower), new ItemStack(Blocks.yellow_flower), 400)); + flowersRecipes.add(BotaniaAPI.registerManaAlchemyRecipe(new ItemStack(Blocks.red_flower, 1, 1), new ItemStack(Blocks.red_flower), 400)); + flowersRecipes.add(BotaniaAPI.registerManaAlchemyRecipe(new ItemStack(Blocks.red_flower, 1, 2), new ItemStack(Blocks.red_flower, 1, 1), 400)); + flowersRecipes.add(BotaniaAPI.registerManaAlchemyRecipe(new ItemStack(Blocks.red_flower, 1, 3), new ItemStack(Blocks.red_flower, 1, 2), 400)); + flowersRecipes.add(BotaniaAPI.registerManaAlchemyRecipe(new ItemStack(Blocks.red_flower, 1, 4), new ItemStack(Blocks.red_flower, 1, 3), 400)); + flowersRecipes.add(BotaniaAPI.registerManaAlchemyRecipe(new ItemStack(Blocks.red_flower, 1, 5), new ItemStack(Blocks.red_flower, 1, 4), 400)); + flowersRecipes.add(BotaniaAPI.registerManaAlchemyRecipe(new ItemStack(Blocks.red_flower, 1, 6), new ItemStack(Blocks.red_flower, 1, 5), 400)); + flowersRecipes.add(BotaniaAPI.registerManaAlchemyRecipe(new ItemStack(Blocks.red_flower, 1, 7), new ItemStack(Blocks.red_flower, 1, 6), 400)); + flowersRecipes.add(BotaniaAPI.registerManaAlchemyRecipe(new ItemStack(Blocks.red_flower, 1, 8), new ItemStack(Blocks.red_flower, 1, 7), 400)); + flowersRecipes.add(BotaniaAPI.registerManaAlchemyRecipe(new ItemStack(Blocks.double_plant), new ItemStack(Blocks.red_flower, 1, 8), 400)); + flowersRecipes.add(BotaniaAPI.registerManaAlchemyRecipe(new ItemStack(Blocks.double_plant, 1, 1), new ItemStack(Blocks.double_plant), 400)); + flowersRecipes.add(BotaniaAPI.registerManaAlchemyRecipe(new ItemStack(Blocks.double_plant, 1, 4), new ItemStack(Blocks.double_plant, 1, 1), 400)); + flowersRecipes.add(BotaniaAPI.registerManaAlchemyRecipe(new ItemStack(Blocks.double_plant, 1, 5), new ItemStack(Blocks.double_plant, 1, 4), 400)); + flowersRecipes.add(BotaniaAPI.registerManaAlchemyRecipe(new ItemStack(Blocks.yellow_flower), new ItemStack(Blocks.double_plant, 1, 5), 400)); + } } diff --git a/src/main/java/vazkii/botania/common/crafting/ModManaConjurationRecipes.java b/src/main/java/vazkii/botania/common/crafting/ModManaConjurationRecipes.java index 6d6d3aa4b4..a25c4ac665 100644 --- a/src/main/java/vazkii/botania/common/crafting/ModManaConjurationRecipes.java +++ b/src/main/java/vazkii/botania/common/crafting/ModManaConjurationRecipes.java @@ -2,16 +2,17 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jun 20, 2014, 3:57:02 PM (GMT)] */ package vazkii.botania.common.crafting; import java.util.ArrayList; import java.util.List; + import net.minecraft.block.Block; import net.minecraft.init.Blocks; import net.minecraft.init.Items; @@ -22,48 +23,36 @@ public class ModManaConjurationRecipes { - public static RecipeManaInfusion redstoneRecipe; - public static RecipeManaInfusion glowstoneRecipe; - public static RecipeManaInfusion quartzRecipe; - public static RecipeManaInfusion coalRecipe; - public static RecipeManaInfusion snowballRecipe; - public static RecipeManaInfusion netherrackRecipe; - public static RecipeManaInfusion soulSandRecipe; - public static RecipeManaInfusion gravelRecipe; - public static List leavesRecipes; - public static RecipeManaInfusion grassRecipe; + public static RecipeManaInfusion redstoneRecipe; + public static RecipeManaInfusion glowstoneRecipe; + public static RecipeManaInfusion quartzRecipe; + public static RecipeManaInfusion coalRecipe; + public static RecipeManaInfusion snowballRecipe; + public static RecipeManaInfusion netherrackRecipe; + public static RecipeManaInfusion soulSandRecipe; + public static RecipeManaInfusion gravelRecipe; + public static List leavesRecipes; + public static RecipeManaInfusion grassRecipe; + + public static void init() { + if (!ConfigHandler.enableDefaultRecipes) return; - public static void init() { - if (!ConfigHandler.enableDefaultRecipes) return; + redstoneRecipe = BotaniaAPI.registerManaConjurationRecipe(new ItemStack(Items.redstone, 2), new ItemStack(Items.redstone), 5000); + glowstoneRecipe = BotaniaAPI.registerManaConjurationRecipe(new ItemStack(Items.glowstone_dust, 2), new ItemStack(Items.glowstone_dust), 5000); + quartzRecipe = BotaniaAPI.registerManaConjurationRecipe(new ItemStack(Items.quartz, 2), new ItemStack(Items.quartz), 2500); + coalRecipe = BotaniaAPI.registerManaConjurationRecipe(new ItemStack(Items.coal, 2), new ItemStack(Items.coal), 2100); + snowballRecipe = BotaniaAPI.registerManaConjurationRecipe(new ItemStack(Items.snowball, 2), new ItemStack(Items.snowball), 200); + netherrackRecipe = BotaniaAPI.registerManaConjurationRecipe(new ItemStack(Blocks.netherrack, 2), new ItemStack(Blocks.netherrack), 200); + soulSandRecipe = BotaniaAPI.registerManaConjurationRecipe(new ItemStack(Blocks.soul_sand, 2), new ItemStack(Blocks.soul_sand), 1500); + gravelRecipe = BotaniaAPI.registerManaConjurationRecipe(new ItemStack(Block.getBlockFromName("gravel"), 2), new ItemStack(Block.getBlockFromName("gravel")), 720); - redstoneRecipe = BotaniaAPI.registerManaConjurationRecipe( - new ItemStack(Items.redstone, 2), new ItemStack(Items.redstone), 5000); - glowstoneRecipe = BotaniaAPI.registerManaConjurationRecipe( - new ItemStack(Items.glowstone_dust, 2), new ItemStack(Items.glowstone_dust), 5000); - quartzRecipe = BotaniaAPI.registerManaConjurationRecipe( - new ItemStack(Items.quartz, 2), new ItemStack(Items.quartz), 2500); - coalRecipe = - BotaniaAPI.registerManaConjurationRecipe(new ItemStack(Items.coal, 2), new ItemStack(Items.coal), 2100); - snowballRecipe = BotaniaAPI.registerManaConjurationRecipe( - new ItemStack(Items.snowball, 2), new ItemStack(Items.snowball), 200); - netherrackRecipe = BotaniaAPI.registerManaConjurationRecipe( - new ItemStack(Blocks.netherrack, 2), new ItemStack(Blocks.netherrack), 200); - soulSandRecipe = BotaniaAPI.registerManaConjurationRecipe( - new ItemStack(Blocks.soul_sand, 2), new ItemStack(Blocks.soul_sand), 1500); - gravelRecipe = BotaniaAPI.registerManaConjurationRecipe( - new ItemStack(Block.getBlockFromName("gravel"), 2), - new ItemStack(Block.getBlockFromName("gravel")), - 720); + leavesRecipes = new ArrayList(); + for(int i = 0; i < 4; i++) + leavesRecipes.add(BotaniaAPI.registerManaConjurationRecipe(new ItemStack(Blocks.leaves, 2, i), new ItemStack(Blocks.leaves, 1, i), 2000)); + for(int i = 0; i < 2; i++) + leavesRecipes.add(BotaniaAPI.registerManaConjurationRecipe(new ItemStack(Blocks.leaves2, 2, i), new ItemStack(Blocks.leaves2, 1, i), 2000)); - leavesRecipes = new ArrayList(); - for (int i = 0; i < 4; i++) - leavesRecipes.add(BotaniaAPI.registerManaConjurationRecipe( - new ItemStack(Blocks.leaves, 2, i), new ItemStack(Blocks.leaves, 1, i), 2000)); - for (int i = 0; i < 2; i++) - leavesRecipes.add(BotaniaAPI.registerManaConjurationRecipe( - new ItemStack(Blocks.leaves2, 2, i), new ItemStack(Blocks.leaves2, 1, i), 2000)); + grassRecipe = BotaniaAPI.registerManaConjurationRecipe(new ItemStack(Blocks.tallgrass, 2, 1), new ItemStack(Blocks.tallgrass, 1, 1), 800); + } - grassRecipe = BotaniaAPI.registerManaConjurationRecipe( - new ItemStack(Blocks.tallgrass, 2, 1), new ItemStack(Blocks.tallgrass, 1, 1), 800); - } } diff --git a/src/main/java/vazkii/botania/common/crafting/ModManaInfusionRecipes.java b/src/main/java/vazkii/botania/common/crafting/ModManaInfusionRecipes.java index ae4af2f045..1fecfb04e8 100644 --- a/src/main/java/vazkii/botania/common/crafting/ModManaInfusionRecipes.java +++ b/src/main/java/vazkii/botania/common/crafting/ModManaInfusionRecipes.java @@ -2,16 +2,17 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jan 30, 2014, 6:10:48 PM (GMT)] */ package vazkii.botania.common.crafting; import java.util.ArrayList; import java.util.List; + import net.minecraft.init.Blocks; import net.minecraft.init.Items; import net.minecraft.item.Item; @@ -25,92 +26,68 @@ public final class ModManaInfusionRecipes { - public static List manasteelRecipes; - public static RecipeManaInfusion manaPearlRecipe; - public static List manaDiamondRecipes; - public static List manaPowderRecipes; - public static RecipeManaInfusion pistonRelayRecipe; - public static RecipeManaInfusion manaCookieRecipe; - public static RecipeManaInfusion grassSeedsRecipe; - public static RecipeManaInfusion podzolSeedsRecipe; - public static List mycelSeedsRecipes; - public static RecipeManaInfusion manaQuartzRecipe; - public static RecipeManaInfusion tinyPotatoRecipe; - public static RecipeManaInfusion manaInkwellRecipe; - public static RecipeManaInfusion managlassRecipe; - public static RecipeManaInfusion manaStringRecipe; - - public static RecipeManaInfusion sugarCaneRecipe; - - public static void init() { - if (!ConfigHandler.enableDefaultRecipes) return; - - manasteelRecipes = new ArrayList(); - manasteelRecipes.add( - BotaniaAPI.registerManaInfusionRecipe(new ItemStack(ModItems.manaResource, 1, 0), "ingotIron", 3000)); - manasteelRecipes.add(BotaniaAPI.registerManaInfusionRecipe( - new ItemStack(ModBlocks.storage, 1, 0), new ItemStack(Blocks.iron_block), 27000)); - - manaPearlRecipe = BotaniaAPI.registerManaInfusionRecipe( - new ItemStack(ModItems.manaResource, 1, 1), new ItemStack(Items.ender_pearl), 6000); - - manaDiamondRecipes = new ArrayList(); - manaDiamondRecipes.add( - BotaniaAPI.registerManaInfusionRecipe(new ItemStack(ModItems.manaResource, 1, 2), "gemDiamond", 10000)); - manaDiamondRecipes.add(BotaniaAPI.registerManaInfusionRecipe( - new ItemStack(ModBlocks.storage, 1, 3), new ItemStack(Blocks.diamond_block), 90000)); - - manaPowderRecipes = new ArrayList(); - manaPowderRecipes.add(BotaniaAPI.registerManaInfusionRecipe( - new ItemStack(ModItems.manaResource, 1, 23), new ItemStack(Items.gunpowder), 500)); - manaPowderRecipes.add(BotaniaAPI.registerManaInfusionRecipe( - new ItemStack(ModItems.manaResource, 1, 23), new ItemStack(Items.redstone), 500)); - manaPowderRecipes.add(BotaniaAPI.registerManaInfusionRecipe( - new ItemStack(ModItems.manaResource, 1, 23), new ItemStack(Items.glowstone_dust), 500)); - manaPowderRecipes.add(BotaniaAPI.registerManaInfusionRecipe( - new ItemStack(ModItems.manaResource, 1, 23), new ItemStack(Items.sugar), 500)); - for (int i = 0; i < 16; i++) - manaPowderRecipes.add(BotaniaAPI.registerManaInfusionRecipe( - new ItemStack(ModItems.manaResource, 1, 23), new ItemStack(ModItems.dye, 1, i), 400)); - - pistonRelayRecipe = BotaniaAPI.registerManaInfusionRecipe( - new ItemStack(ModBlocks.pistonRelay), new ItemStack(Blocks.piston), 15000); - manaCookieRecipe = BotaniaAPI.registerManaInfusionRecipe( - new ItemStack(ModItems.manaCookie), new ItemStack(Items.cookie), 20000); - grassSeedsRecipe = BotaniaAPI.registerManaInfusionRecipe( - new ItemStack(ModItems.grassSeeds), new ItemStack(Blocks.tallgrass, 1, 1), 2500); - podzolSeedsRecipe = BotaniaAPI.registerManaInfusionRecipe( - new ItemStack(ModItems.grassSeeds, 1, 1), new ItemStack(Blocks.deadbush), 2500); - - mycelSeedsRecipes = new ArrayList(); - mycelSeedsRecipes.add(BotaniaAPI.registerManaInfusionRecipe( - new ItemStack(ModItems.grassSeeds, 1, 2), new ItemStack(Blocks.red_mushroom), 6500)); - mycelSeedsRecipes.add(BotaniaAPI.registerManaInfusionRecipe( - new ItemStack(ModItems.grassSeeds, 1, 2), new ItemStack(Blocks.brown_mushroom), 6500)); - - manaQuartzRecipe = BotaniaAPI.registerManaInfusionRecipe( - new ItemStack(ModItems.quartz, 1, 1), new ItemStack(Items.quartz), 250); - tinyPotatoRecipe = BotaniaAPI.registerManaInfusionRecipe( - new ItemStack(ModBlocks.tinyPotato), new ItemStack(Items.potato), 1337); - - if (Botania.thaumcraftLoaded) { - Item inkwell = (Item) Item.itemRegistry.getObject("Thaumcraft:ItemInkwell"); - manaInkwellRecipe = BotaniaAPI.registerManaInfusionRecipe( - new ItemStack(ModItems.manaInkwell, 1, ModItems.manaInkwell.getMaxDamage()), - new ItemStack(inkwell), - 35000); - } - - managlassRecipe = BotaniaAPI.registerManaInfusionRecipe( - new ItemStack(ModBlocks.manaGlass), new ItemStack(Blocks.glass), 150); - manaStringRecipe = BotaniaAPI.registerManaInfusionRecipe( - new ItemStack(ModItems.manaResource, 1, 16), new ItemStack(Items.string), 5000); - - if (Botania.gardenOfGlassLoaded) - sugarCaneRecipe = BotaniaAPI.registerManaInfusionRecipe( - new ItemStack(Items.reeds), new ItemStack(Blocks.hay_block), 2000); - - BotaniaAPI.registerManaInfusionRecipe( - new ItemStack(ModItems.manaBottle), new ItemStack(Items.glass_bottle), 5000); - } + public static List manasteelRecipes; + public static RecipeManaInfusion manaPearlRecipe; + public static List manaDiamondRecipes; + public static List manaPowderRecipes; + public static RecipeManaInfusion pistonRelayRecipe; + public static RecipeManaInfusion manaCookieRecipe; + public static RecipeManaInfusion grassSeedsRecipe; + public static RecipeManaInfusion podzolSeedsRecipe; + public static List mycelSeedsRecipes; + public static RecipeManaInfusion manaQuartzRecipe; + public static RecipeManaInfusion tinyPotatoRecipe; + public static RecipeManaInfusion manaInkwellRecipe; + public static RecipeManaInfusion managlassRecipe; + public static RecipeManaInfusion manaStringRecipe; + + public static RecipeManaInfusion sugarCaneRecipe; + + public static void init() { + if (!ConfigHandler.enableDefaultRecipes) return; + + manasteelRecipes = new ArrayList(); + manasteelRecipes.add(BotaniaAPI.registerManaInfusionRecipe(new ItemStack(ModItems.manaResource, 1, 0), "ingotIron", 3000)); + manasteelRecipes.add(BotaniaAPI.registerManaInfusionRecipe(new ItemStack(ModBlocks.storage, 1, 0), new ItemStack(Blocks.iron_block), 27000)); + + manaPearlRecipe = BotaniaAPI.registerManaInfusionRecipe(new ItemStack(ModItems.manaResource, 1, 1), new ItemStack(Items.ender_pearl), 6000); + + manaDiamondRecipes = new ArrayList(); + manaDiamondRecipes.add(BotaniaAPI.registerManaInfusionRecipe(new ItemStack(ModItems.manaResource, 1, 2), "gemDiamond", 10000)); + manaDiamondRecipes.add(BotaniaAPI.registerManaInfusionRecipe(new ItemStack(ModBlocks.storage, 1, 3), new ItemStack(Blocks.diamond_block), 90000)); + + manaPowderRecipes = new ArrayList(); + manaPowderRecipes.add(BotaniaAPI.registerManaInfusionRecipe(new ItemStack(ModItems.manaResource, 1, 23), new ItemStack(Items.gunpowder), 500)); + manaPowderRecipes.add(BotaniaAPI.registerManaInfusionRecipe(new ItemStack(ModItems.manaResource, 1, 23), new ItemStack(Items.redstone), 500)); + manaPowderRecipes.add(BotaniaAPI.registerManaInfusionRecipe(new ItemStack(ModItems.manaResource, 1, 23), new ItemStack(Items.glowstone_dust), 500)); + manaPowderRecipes.add(BotaniaAPI.registerManaInfusionRecipe(new ItemStack(ModItems.manaResource, 1, 23), new ItemStack(Items.sugar), 500)); + for(int i = 0; i < 16; i++) + manaPowderRecipes.add(BotaniaAPI.registerManaInfusionRecipe(new ItemStack(ModItems.manaResource, 1, 23), new ItemStack(ModItems.dye, 1, i), 400)); + + pistonRelayRecipe = BotaniaAPI.registerManaInfusionRecipe(new ItemStack(ModBlocks.pistonRelay), new ItemStack(Blocks.piston), 15000); + manaCookieRecipe = BotaniaAPI.registerManaInfusionRecipe(new ItemStack(ModItems.manaCookie), new ItemStack(Items.cookie), 20000); + grassSeedsRecipe = BotaniaAPI.registerManaInfusionRecipe(new ItemStack(ModItems.grassSeeds), new ItemStack(Blocks.tallgrass, 1, 1), 2500); + podzolSeedsRecipe = BotaniaAPI.registerManaInfusionRecipe(new ItemStack(ModItems.grassSeeds, 1, 1), new ItemStack(Blocks.deadbush), 2500); + + mycelSeedsRecipes = new ArrayList(); + mycelSeedsRecipes.add(BotaniaAPI.registerManaInfusionRecipe(new ItemStack(ModItems.grassSeeds, 1, 2), new ItemStack(Blocks.red_mushroom), 6500)); + mycelSeedsRecipes.add(BotaniaAPI.registerManaInfusionRecipe(new ItemStack(ModItems.grassSeeds, 1, 2), new ItemStack(Blocks.brown_mushroom), 6500)); + + manaQuartzRecipe = BotaniaAPI.registerManaInfusionRecipe(new ItemStack(ModItems.quartz, 1, 1), new ItemStack(Items.quartz), 250); + tinyPotatoRecipe = BotaniaAPI.registerManaInfusionRecipe(new ItemStack(ModBlocks.tinyPotato), new ItemStack(Items.potato), 1337); + + if(Botania.thaumcraftLoaded) { + Item inkwell = (Item) Item.itemRegistry.getObject("Thaumcraft:ItemInkwell"); + manaInkwellRecipe = BotaniaAPI.registerManaInfusionRecipe(new ItemStack(ModItems.manaInkwell, 1, ModItems.manaInkwell.getMaxDamage()), new ItemStack(inkwell), 35000); + } + + managlassRecipe = BotaniaAPI.registerManaInfusionRecipe(new ItemStack(ModBlocks.manaGlass), new ItemStack(Blocks.glass), 150); + manaStringRecipe = BotaniaAPI.registerManaInfusionRecipe(new ItemStack(ModItems.manaResource, 1, 16), new ItemStack(Items.string), 5000); + + if(Botania.gardenOfGlassLoaded) + sugarCaneRecipe = BotaniaAPI.registerManaInfusionRecipe(new ItemStack(Items.reeds), new ItemStack(Blocks.hay_block), 2000); + + BotaniaAPI.registerManaInfusionRecipe(new ItemStack(ModItems.manaBottle), new ItemStack(Items.glass_bottle), 5000); + } + } diff --git a/src/main/java/vazkii/botania/common/crafting/ModPetalRecipes.java b/src/main/java/vazkii/botania/common/crafting/ModPetalRecipes.java index c85008f369..f1cb020709 100644 --- a/src/main/java/vazkii/botania/common/crafting/ModPetalRecipes.java +++ b/src/main/java/vazkii/botania/common/crafting/ModPetalRecipes.java @@ -2,15 +2,16 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jan 22], 2014], 2:22:21 PM (GMT)] */ package vazkii.botania.common.crafting; import java.util.Arrays; + import net.minecraft.init.Items; import net.minecraft.item.ItemStack; import vazkii.botania.api.BotaniaAPI; @@ -24,437 +25,113 @@ public final class ModPetalRecipes { - public static final String white = LibOreDict.PETAL[0], - orange = LibOreDict.PETAL[1], - magenta = LibOreDict.PETAL[2], - lightBlue = LibOreDict.PETAL[3], - yellow = LibOreDict.PETAL[4], - lime = LibOreDict.PETAL[5], - pink = LibOreDict.PETAL[6], - gray = LibOreDict.PETAL[7], - lightGray = LibOreDict.PETAL[8], - cyan = LibOreDict.PETAL[9], - purple = LibOreDict.PETAL[10], - blue = LibOreDict.PETAL[11], - brown = LibOreDict.PETAL[12], - green = LibOreDict.PETAL[13], - red = LibOreDict.PETAL[14], - black = LibOreDict.PETAL[15]; - public static final String runeWater = LibOreDict.RUNE[0], - runeFire = LibOreDict.RUNE[1], - runeEarth = LibOreDict.RUNE[2], - runeAir = LibOreDict.RUNE[3], - runeSpring = LibOreDict.RUNE[4], - runeSummer = LibOreDict.RUNE[5], - runeAutumn = LibOreDict.RUNE[6], - runeWinter = LibOreDict.RUNE[7], - runeMana = LibOreDict.RUNE[8], - runeLust = LibOreDict.RUNE[9], - runeGluttony = LibOreDict.RUNE[10], - runeGreed = LibOreDict.RUNE[11], - runeSloth = LibOreDict.RUNE[12], - runeWrath = LibOreDict.RUNE[13], - runeEnvy = LibOreDict.RUNE[14], - runePride = LibOreDict.RUNE[15]; - public static final String redstoneRoot = LibOreDict.REDSTONE_ROOT; - public static final String pixieDust = LibOreDict.PIXIE_DUST; - public static final String gaiaSpirit = LibOreDict.LIFE_ESSENCE; - public static final String manaPowder = LibOreDict.MANA_POWDER; + public static final String white = LibOreDict.PETAL[0], orange = LibOreDict.PETAL[1], magenta = LibOreDict.PETAL[2], lightBlue = LibOreDict.PETAL[3], yellow = LibOreDict.PETAL[4], lime = LibOreDict.PETAL[5], pink = LibOreDict.PETAL[6], gray = LibOreDict.PETAL[7], lightGray = LibOreDict.PETAL[8], cyan = LibOreDict.PETAL[9], purple = LibOreDict.PETAL[10], blue = LibOreDict.PETAL[11], brown = LibOreDict.PETAL[12], green = LibOreDict.PETAL[13], red = LibOreDict.PETAL[14], black = LibOreDict.PETAL[15]; + public static final String runeWater = LibOreDict.RUNE[0], runeFire = LibOreDict.RUNE[1], runeEarth = LibOreDict.RUNE[2], runeAir = LibOreDict.RUNE[3], runeSpring = LibOreDict.RUNE[4], runeSummer = LibOreDict.RUNE[5], runeAutumn = LibOreDict.RUNE[6], runeWinter = LibOreDict.RUNE[7], runeMana = LibOreDict.RUNE[8], runeLust = LibOreDict.RUNE[9], runeGluttony = LibOreDict.RUNE[10], runeGreed = LibOreDict.RUNE[11], runeSloth = LibOreDict.RUNE[12], runeWrath = LibOreDict.RUNE[13], runeEnvy = LibOreDict.RUNE[14], runePride = LibOreDict.RUNE[15]; + public static final String redstoneRoot = LibOreDict.REDSTONE_ROOT; + public static final String pixieDust = LibOreDict.PIXIE_DUST; + public static final String gaiaSpirit = LibOreDict.LIFE_ESSENCE; + public static final String manaPowder = LibOreDict.MANA_POWDER; - public static RecipePetals pureDaisyRecipe; - public static RecipePetals manastarRecipe; + public static RecipePetals pureDaisyRecipe; + public static RecipePetals manastarRecipe; - public static RecipePetals daybloomRecipe; - public static RecipePetals nightshadeRecipe; - public static RecipePetals endoflameRecipe; - public static RecipePetals hydroangeasRecipe; - public static RecipePetals thermalilyRecipe; - public static RecipePetals arcaneRoseRecipe; - public static RecipePetals munchdewRecipe; - public static RecipePetals entropinnyumRecipe; - public static RecipePetals kekimurusRecipe; - public static RecipePetals gourmaryllisRecipe; - public static RecipePetals narslimmusRecipe; - public static RecipePetals spectrolusRecipe; - public static RecipePetals rafflowsiaRecipe; - public static RecipePetals dandelifeonRecipe; + public static RecipePetals daybloomRecipe; + public static RecipePetals nightshadeRecipe; + public static RecipePetals endoflameRecipe; + public static RecipePetals hydroangeasRecipe; + public static RecipePetals thermalilyRecipe; + public static RecipePetals arcaneRoseRecipe; + public static RecipePetals munchdewRecipe; + public static RecipePetals entropinnyumRecipe; + public static RecipePetals kekimurusRecipe; + public static RecipePetals gourmaryllisRecipe; + public static RecipePetals narslimmusRecipe; + public static RecipePetals spectrolusRecipe; + public static RecipePetals rafflowsiaRecipe; + public static RecipePetals dandelifeonRecipe; - public static RecipePetals jadedAmaranthusRecipe; - public static RecipePetals bellethorneRecipe; - public static RecipePetals dreadthorneRecipe; - public static RecipePetals heiseiDreamRecipe; - public static RecipePetals tigerseyeRecipe; - public static RecipePetals orechidRecipe; - public static RecipePetals orechidIgnemRecipe; - public static RecipePetals fallenKanadeRecipe; - public static RecipePetals exoflameRecipe; - public static RecipePetals agricarnationRecipe; - public static RecipePetals hopperhockRecipe; - public static RecipePetals tangleberrieRecipe; - public static RecipePetals jiyuuliaRecipe; - public static RecipePetals rannuncarpusRecipe; - public static RecipePetals hyacidusRecipe; - public static RecipePetals pollidisiacRecipe; - public static RecipePetals clayconiaRecipe; - public static RecipePetals looniumRecipe; - public static RecipePetals daffomillRecipe; - public static RecipePetals vinculotusRecipe; - public static RecipePetals spectranthemumRecipe; - public static RecipePetals medumoneRecipe; - public static RecipePetals marimorphosisRecipe; - public static RecipePetals bubbellRecipe; - public static RecipePetals solegnoliaRecipe; + public static RecipePetals jadedAmaranthusRecipe; + public static RecipePetals bellethorneRecipe; + public static RecipePetals dreadthorneRecipe; + public static RecipePetals heiseiDreamRecipe; + public static RecipePetals tigerseyeRecipe; + public static RecipePetals orechidRecipe; + public static RecipePetals orechidIgnemRecipe; + public static RecipePetals fallenKanadeRecipe; + public static RecipePetals exoflameRecipe; + public static RecipePetals agricarnationRecipe; + public static RecipePetals hopperhockRecipe; + public static RecipePetals tangleberrieRecipe; + public static RecipePetals jiyuuliaRecipe; + public static RecipePetals rannuncarpusRecipe; + public static RecipePetals hyacidusRecipe; + public static RecipePetals pollidisiacRecipe; + public static RecipePetals clayconiaRecipe; + public static RecipePetals looniumRecipe; + public static RecipePetals daffomillRecipe; + public static RecipePetals vinculotusRecipe; + public static RecipePetals spectranthemumRecipe; + public static RecipePetals medumoneRecipe; + public static RecipePetals marimorphosisRecipe; + public static RecipePetals bubbellRecipe; + public static RecipePetals solegnoliaRecipe; - public static void init() { - if (!ConfigHandler.enableDefaultRecipes) return; + public static void init() { + if (!ConfigHandler.enableDefaultRecipes) return; - pureDaisyRecipe = BotaniaAPI.registerPetalRecipe( - ItemBlockSpecialFlower.ofType(LibBlockNames.SUBTILE_PUREDAISY), white, white, white, white); - manastarRecipe = BotaniaAPI.registerPetalRecipe( - ItemBlockSpecialFlower.ofType(LibBlockNames.SUBTILE_MANASTAR), lightBlue, green, red, cyan); + pureDaisyRecipe = BotaniaAPI.registerPetalRecipe(ItemBlockSpecialFlower.ofType(LibBlockNames.SUBTILE_PUREDAISY), white, white, white, white); + manastarRecipe = BotaniaAPI.registerPetalRecipe(ItemBlockSpecialFlower.ofType(LibBlockNames.SUBTILE_MANASTAR), lightBlue, green, red, cyan); - daybloomRecipe = BotaniaAPI.registerPetalRecipe( - ItemBlockSpecialFlower.ofType(LibBlockNames.SUBTILE_DAYBLOOM), yellow, yellow, orange, lightBlue); - nightshadeRecipe = BotaniaAPI.registerPetalRecipe( - ItemBlockSpecialFlower.ofType(LibBlockNames.SUBTILE_NIGHTSHADE), black, black, purple, gray); - endoflameRecipe = BotaniaAPI.registerPetalRecipe( - ItemBlockSpecialFlower.ofType(LibBlockNames.SUBTILE_ENDOFLAME), - brown, - brown, - red, - lightGray, - manaPowder); - hydroangeasRecipe = BotaniaAPI.registerPetalRecipe( - ItemBlockSpecialFlower.ofType(LibBlockNames.SUBTILE_HYDROANGEAS), blue, blue, cyan, cyan, manaPowder); - thermalilyRecipe = BotaniaAPI.registerPetalRecipe( - ItemBlockSpecialFlower.ofType(LibBlockNames.SUBTILE_THERMALILY), - red, - orange, - orange, - runeEarth, - runeFire); - arcaneRoseRecipe = BotaniaAPI.registerPetalRecipe( - ItemBlockSpecialFlower.ofType(LibBlockNames.SUBTILE_ARCANE_ROSE), - pink, - pink, - purple, - purple, - lime, - runeMana); - munchdewRecipe = BotaniaAPI.registerPetalRecipe( - ItemBlockSpecialFlower.ofType(LibBlockNames.SUBTILE_MUNCHDEW), - lime, - lime, - red, - red, - green, - runeGluttony); - entropinnyumRecipe = BotaniaAPI.registerPetalRecipe( - ItemBlockSpecialFlower.ofType(LibBlockNames.SUBTILE_ENTROPINNYUM), - red, - red, - gray, - gray, - white, - white, - runeWrath, - runeFire); - kekimurusRecipe = BotaniaAPI.registerPetalRecipe( - ItemBlockSpecialFlower.ofType(LibBlockNames.SUBTILE_KEKIMURUS), - white, - white, - orange, - orange, - brown, - brown, - runeGluttony, - pixieDust); - gourmaryllisRecipe = BotaniaAPI.registerPetalRecipe( - ItemBlockSpecialFlower.ofType(LibBlockNames.SUBTILE_GOURMARYLLIS), - lightGray, - lightGray, - yellow, - yellow, - red, - runeFire, - runeSummer); - narslimmusRecipe = BotaniaAPI.registerPetalRecipe( - ItemBlockSpecialFlower.ofType(LibBlockNames.SUBTILE_NARSLIMMUS), - lime, - lime, - green, - green, - black, - runeSummer, - runeWater); - spectrolusRecipe = BotaniaAPI.registerPetalRecipe( - ItemBlockSpecialFlower.ofType(LibBlockNames.SUBTILE_SPECTROLUS), - red, - red, - green, - green, - blue, - blue, - white, - white, - runeWinter, - runeAir, - pixieDust); - rafflowsiaRecipe = BotaniaAPI.registerPetalRecipe( - ItemBlockSpecialFlower.ofType(LibBlockNames.SUBTILE_RAFFLOWSIA), - purple, - purple, - green, - green, - black, - runeEarth, - runePride, - pixieDust); - dandelifeonRecipe = BotaniaAPI.registerPetalRecipe( - ItemBlockSpecialFlower.ofType(LibBlockNames.SUBTILE_DANDELIFEON), - purple, - purple, - lime, - green, - runeWater, - runeFire, - runeEarth, - runeAir, - gaiaSpirit); + daybloomRecipe = BotaniaAPI.registerPetalRecipe(ItemBlockSpecialFlower.ofType(LibBlockNames.SUBTILE_DAYBLOOM), yellow, yellow, orange, lightBlue); + nightshadeRecipe = BotaniaAPI.registerPetalRecipe(ItemBlockSpecialFlower.ofType(LibBlockNames.SUBTILE_NIGHTSHADE), black, black, purple, gray); + endoflameRecipe = BotaniaAPI.registerPetalRecipe(ItemBlockSpecialFlower.ofType(LibBlockNames.SUBTILE_ENDOFLAME), brown, brown, red, lightGray, manaPowder); + hydroangeasRecipe = BotaniaAPI.registerPetalRecipe(ItemBlockSpecialFlower.ofType(LibBlockNames.SUBTILE_HYDROANGEAS), blue, blue, cyan, cyan, manaPowder); + thermalilyRecipe = BotaniaAPI.registerPetalRecipe(ItemBlockSpecialFlower.ofType(LibBlockNames.SUBTILE_THERMALILY), red, orange, orange, runeEarth, runeFire); + arcaneRoseRecipe = BotaniaAPI.registerPetalRecipe(ItemBlockSpecialFlower.ofType(LibBlockNames.SUBTILE_ARCANE_ROSE), pink, pink, purple, purple, lime, runeMana); + munchdewRecipe = BotaniaAPI.registerPetalRecipe(ItemBlockSpecialFlower.ofType(LibBlockNames.SUBTILE_MUNCHDEW), lime, lime, red, red, green, runeGluttony); + entropinnyumRecipe = BotaniaAPI.registerPetalRecipe(ItemBlockSpecialFlower.ofType(LibBlockNames.SUBTILE_ENTROPINNYUM), red, red, gray, gray, white, white, runeWrath, runeFire); + kekimurusRecipe = BotaniaAPI.registerPetalRecipe(ItemBlockSpecialFlower.ofType(LibBlockNames.SUBTILE_KEKIMURUS), white, white, orange, orange, brown, brown,runeGluttony, pixieDust); + gourmaryllisRecipe = BotaniaAPI.registerPetalRecipe(ItemBlockSpecialFlower.ofType(LibBlockNames.SUBTILE_GOURMARYLLIS), lightGray, lightGray, yellow, yellow, red, runeFire, runeSummer); + narslimmusRecipe = BotaniaAPI.registerPetalRecipe(ItemBlockSpecialFlower.ofType(LibBlockNames.SUBTILE_NARSLIMMUS), lime, lime, green, green, black, runeSummer, runeWater); + spectrolusRecipe = BotaniaAPI.registerPetalRecipe(ItemBlockSpecialFlower.ofType(LibBlockNames.SUBTILE_SPECTROLUS), red, red, green, green, blue, blue, white, white, runeWinter, runeAir, pixieDust); + rafflowsiaRecipe = BotaniaAPI.registerPetalRecipe(ItemBlockSpecialFlower.ofType(LibBlockNames.SUBTILE_RAFFLOWSIA), purple, purple, green, green, black, runeEarth, runePride, pixieDust); + dandelifeonRecipe = BotaniaAPI.registerPetalRecipe(ItemBlockSpecialFlower.ofType(LibBlockNames.SUBTILE_DANDELIFEON), purple, purple, lime, green, runeWater, runeFire, runeEarth, runeAir, gaiaSpirit); - jadedAmaranthusRecipe = BotaniaAPI.registerPetalRecipe( - ItemBlockSpecialFlower.ofType(LibBlockNames.SUBTILE_JADED_AMARANTHUS), - purple, - lime, - green, - runeSpring, - redstoneRoot); - bellethorneRecipe = BotaniaAPI.registerPetalRecipe( - ItemBlockSpecialFlower.ofType(LibBlockNames.SUBTILE_BELLETHORN), - red, - red, - red, - cyan, - cyan, - redstoneRoot); - dreadthorneRecipe = BotaniaAPI.registerPetalRecipe( - ItemBlockSpecialFlower.ofType(LibBlockNames.SUBTILE_DREADTHORN), - black, - black, - black, - cyan, - cyan, - redstoneRoot); - heiseiDreamRecipe = BotaniaAPI.registerPetalRecipe( - ItemBlockSpecialFlower.ofType(LibBlockNames.SUBTILE_HEISEI_DREAM), - magenta, - magenta, - purple, - pink, - runeWrath, - pixieDust); - tigerseyeRecipe = BotaniaAPI.registerPetalRecipe( - ItemBlockSpecialFlower.ofType(LibBlockNames.SUBTILE_TIGERSEYE), - yellow, - brown, - orange, - lime, - runeAutumn); + jadedAmaranthusRecipe = BotaniaAPI.registerPetalRecipe(ItemBlockSpecialFlower.ofType(LibBlockNames.SUBTILE_JADED_AMARANTHUS), purple, lime, green, runeSpring, redstoneRoot); + bellethorneRecipe = BotaniaAPI.registerPetalRecipe(ItemBlockSpecialFlower.ofType(LibBlockNames.SUBTILE_BELLETHORN), red, red, red, cyan, cyan, redstoneRoot); + dreadthorneRecipe = BotaniaAPI.registerPetalRecipe(ItemBlockSpecialFlower.ofType(LibBlockNames.SUBTILE_DREADTHORN), black, black, black, cyan, cyan, redstoneRoot); + heiseiDreamRecipe = BotaniaAPI.registerPetalRecipe(ItemBlockSpecialFlower.ofType(LibBlockNames.SUBTILE_HEISEI_DREAM), magenta, magenta, purple, pink, runeWrath, pixieDust); + tigerseyeRecipe = BotaniaAPI.registerPetalRecipe(ItemBlockSpecialFlower.ofType(LibBlockNames.SUBTILE_TIGERSEYE), yellow, brown, orange, lime, runeAutumn); - if (Botania.gardenOfGlassLoaded) - orechidRecipe = BotaniaAPI.registerPetalRecipe( - ItemBlockSpecialFlower.ofType(LibBlockNames.SUBTILE_ORECHID), - gray, - gray, - yellow, - yellow, - green, - green, - red, - red); - else - orechidRecipe = BotaniaAPI.registerPetalRecipe( - ItemBlockSpecialFlower.ofType(LibBlockNames.SUBTILE_ORECHID), - gray, - gray, - yellow, - green, - red, - runePride, - runeGreed, - redstoneRoot, - pixieDust); + if(Botania.gardenOfGlassLoaded) + orechidRecipe = BotaniaAPI.registerPetalRecipe(ItemBlockSpecialFlower.ofType(LibBlockNames.SUBTILE_ORECHID), gray, gray, yellow, yellow, green, green, red, red); + else orechidRecipe = BotaniaAPI.registerPetalRecipe(ItemBlockSpecialFlower.ofType(LibBlockNames.SUBTILE_ORECHID), gray, gray, yellow, green, red, runePride, runeGreed, redstoneRoot, pixieDust); - orechidIgnemRecipe = BotaniaAPI.registerPetalRecipe( - ItemBlockSpecialFlower.ofType(LibBlockNames.SUBTILE_ORECHID_IGNEM), - red, - red, - white, - white, - pink, - runePride, - runeGreed, - redstoneRoot, - pixieDust); - if (ConfigHandler.fallenKanadeEnabled) - fallenKanadeRecipe = BotaniaAPI.registerPetalRecipe( - ItemBlockSpecialFlower.ofType(LibBlockNames.SUBTILE_FALLEN_KANADE), - white, - white, - yellow, - yellow, - orange, - runeSpring); - exoflameRecipe = BotaniaAPI.registerPetalRecipe( - ItemBlockSpecialFlower.ofType(LibBlockNames.SUBTILE_EXOFLAME), - red, - red, - gray, - lightGray, - runeFire, - runeSummer); - agricarnationRecipe = BotaniaAPI.registerPetalRecipe( - ItemBlockSpecialFlower.ofType(LibBlockNames.SUBTILE_AGRICARNATION), - lime, - lime, - green, - yellow, - runeSpring, - redstoneRoot); - hopperhockRecipe = BotaniaAPI.registerPetalRecipe( - ItemBlockSpecialFlower.ofType(LibBlockNames.SUBTILE_HOPPERHOCK), - gray, - gray, - lightGray, - lightGray, - runeAir, - redstoneRoot); - tangleberrieRecipe = BotaniaAPI.registerPetalRecipe( - ItemBlockSpecialFlower.ofType(LibBlockNames.SUBTILE_TANGLEBERRIE), - cyan, - cyan, - gray, - lightGray, - runeAir, - runeEarth); - jiyuuliaRecipe = BotaniaAPI.registerPetalRecipe( - ItemBlockSpecialFlower.ofType(LibBlockNames.SUBTILE_JIYUULIA), - pink, - pink, - purple, - lightGray, - runeWater, - runeAir); - rannuncarpusRecipe = BotaniaAPI.registerPetalRecipe( - ItemBlockSpecialFlower.ofType(LibBlockNames.SUBTILE_RANNUNCARPUS), - orange, - orange, - yellow, - runeEarth, - redstoneRoot); - hyacidusRecipe = BotaniaAPI.registerPetalRecipe( - ItemBlockSpecialFlower.ofType(LibBlockNames.SUBTILE_HYACIDUS), - purple, - purple, - magenta, - magenta, - green, - runeWater, - runeAutumn, - redstoneRoot); - pollidisiacRecipe = BotaniaAPI.registerPetalRecipe( - ItemBlockSpecialFlower.ofType(LibBlockNames.SUBTILE_POLLIDISIAC), - red, - red, - pink, - pink, - orange, - runeLust, - runeFire); - clayconiaRecipe = BotaniaAPI.registerPetalRecipe( - ItemBlockSpecialFlower.ofType(LibBlockNames.SUBTILE_CLAYCONIA), - lightGray, - lightGray, - gray, - cyan, - runeEarth); - looniumRecipe = BotaniaAPI.registerPetalRecipe( - ItemBlockSpecialFlower.ofType(LibBlockNames.SUBTILE_LOONIUM), - green, - green, - green, - green, - gray, - runeSloth, - runeGluttony, - runeEnvy, - redstoneRoot, - pixieDust); - daffomillRecipe = BotaniaAPI.registerPetalRecipe( - ItemBlockSpecialFlower.ofType(LibBlockNames.SUBTILE_DAFFOMILL), - white, - white, - brown, - yellow, - runeAir, - redstoneRoot); - vinculotusRecipe = BotaniaAPI.registerPetalRecipe( - ItemBlockSpecialFlower.ofType(LibBlockNames.SUBTILE_VINCULOTUS), - black, - black, - purple, - purple, - green, - runeWater, - runeSloth, - runeLust, - redstoneRoot); - spectranthemumRecipe = BotaniaAPI.registerPetalRecipe( - ItemBlockSpecialFlower.ofType(LibBlockNames.SUBTILE_SPECTRANTHEMUM), - white, - white, - lightGray, - lightGray, - cyan, - runeEnvy, - runeWater, - redstoneRoot, - pixieDust); - medumoneRecipe = BotaniaAPI.registerPetalRecipe( - ItemBlockSpecialFlower.ofType(LibBlockNames.SUBTILE_MEDUMONE), - brown, - brown, - gray, - gray, - runeEarth, - redstoneRoot); - marimorphosisRecipe = BotaniaAPI.registerPetalRecipe( - ItemBlockSpecialFlower.ofType(LibBlockNames.SUBTILE_MARIMORPHOSIS), - gray, - yellow, - green, - red, - runeEarth, - runeFire, - redstoneRoot); - bubbellRecipe = BotaniaAPI.registerPetalRecipe( - ItemBlockSpecialFlower.ofType(LibBlockNames.SUBTILE_BUBBELL), - cyan, - cyan, - lightBlue, - lightBlue, - blue, - blue, - runeWater, - runeSummer, - pixieDust); - solegnoliaRecipe = BotaniaAPI.registerPetalRecipe( - ItemBlockSpecialFlower.ofType(LibBlockNames.SUBTILE_SOLEGNOLIA), brown, brown, red, blue, redstoneRoot); + orechidIgnemRecipe = BotaniaAPI.registerPetalRecipe(ItemBlockSpecialFlower.ofType(LibBlockNames.SUBTILE_ORECHID_IGNEM), red, red, white, white, pink, runePride, runeGreed, redstoneRoot, pixieDust); + if(ConfigHandler.fallenKanadeEnabled) + fallenKanadeRecipe = BotaniaAPI.registerPetalRecipe(ItemBlockSpecialFlower.ofType(LibBlockNames.SUBTILE_FALLEN_KANADE), white, white, yellow, yellow, orange, runeSpring); + exoflameRecipe = BotaniaAPI.registerPetalRecipe(ItemBlockSpecialFlower.ofType(LibBlockNames.SUBTILE_EXOFLAME), red, red, gray, lightGray, runeFire, runeSummer); + agricarnationRecipe = BotaniaAPI.registerPetalRecipe(ItemBlockSpecialFlower.ofType(LibBlockNames.SUBTILE_AGRICARNATION), lime, lime, green, yellow, runeSpring, redstoneRoot); + hopperhockRecipe = BotaniaAPI.registerPetalRecipe(ItemBlockSpecialFlower.ofType(LibBlockNames.SUBTILE_HOPPERHOCK), gray, gray, lightGray, lightGray, runeAir, redstoneRoot); + tangleberrieRecipe = BotaniaAPI.registerPetalRecipe(ItemBlockSpecialFlower.ofType(LibBlockNames.SUBTILE_TANGLEBERRIE), cyan, cyan, gray, lightGray, runeAir, runeEarth); + jiyuuliaRecipe = BotaniaAPI.registerPetalRecipe(ItemBlockSpecialFlower.ofType(LibBlockNames.SUBTILE_JIYUULIA), pink, pink, purple, lightGray, runeWater, runeAir); + rannuncarpusRecipe = BotaniaAPI.registerPetalRecipe(ItemBlockSpecialFlower.ofType(LibBlockNames.SUBTILE_RANNUNCARPUS), orange, orange, yellow, runeEarth, redstoneRoot); + hyacidusRecipe = BotaniaAPI.registerPetalRecipe(ItemBlockSpecialFlower.ofType(LibBlockNames.SUBTILE_HYACIDUS), purple, purple, magenta, magenta, green, runeWater, runeAutumn, redstoneRoot); + pollidisiacRecipe = BotaniaAPI.registerPetalRecipe(ItemBlockSpecialFlower.ofType(LibBlockNames.SUBTILE_POLLIDISIAC), red, red, pink, pink, orange, runeLust, runeFire); + clayconiaRecipe = BotaniaAPI.registerPetalRecipe(ItemBlockSpecialFlower.ofType(LibBlockNames.SUBTILE_CLAYCONIA), lightGray, lightGray, gray, cyan, runeEarth); + looniumRecipe = BotaniaAPI.registerPetalRecipe(ItemBlockSpecialFlower.ofType(LibBlockNames.SUBTILE_LOONIUM), green, green, green, green, gray, runeSloth, runeGluttony, runeEnvy, redstoneRoot, pixieDust); + daffomillRecipe = BotaniaAPI.registerPetalRecipe(ItemBlockSpecialFlower.ofType(LibBlockNames.SUBTILE_DAFFOMILL), white, white, brown, yellow, runeAir, redstoneRoot); + vinculotusRecipe = BotaniaAPI.registerPetalRecipe(ItemBlockSpecialFlower.ofType(LibBlockNames.SUBTILE_VINCULOTUS), black, black, purple, purple, green, runeWater, runeSloth, runeLust, redstoneRoot); + spectranthemumRecipe = BotaniaAPI.registerPetalRecipe(ItemBlockSpecialFlower.ofType(LibBlockNames.SUBTILE_SPECTRANTHEMUM), white, white, lightGray, lightGray, cyan, runeEnvy, runeWater, redstoneRoot, pixieDust); + medumoneRecipe = BotaniaAPI.registerPetalRecipe(ItemBlockSpecialFlower.ofType(LibBlockNames.SUBTILE_MEDUMONE), brown, brown, gray, gray, runeEarth, redstoneRoot); + marimorphosisRecipe = BotaniaAPI.registerPetalRecipe(ItemBlockSpecialFlower.ofType(LibBlockNames.SUBTILE_MARIMORPHOSIS), gray, yellow, green, red, runeEarth, runeFire, redstoneRoot); + bubbellRecipe = BotaniaAPI.registerPetalRecipe(ItemBlockSpecialFlower.ofType(LibBlockNames.SUBTILE_BUBBELL), cyan, cyan, lightBlue, lightBlue, blue, blue, runeWater, runeSummer, pixieDust); + solegnoliaRecipe = BotaniaAPI.registerPetalRecipe(ItemBlockSpecialFlower.ofType(LibBlockNames.SUBTILE_SOLEGNOLIA), brown, brown, red, blue, redstoneRoot); - ItemStack stack = new ItemStack(Items.skull, 1, 3); - ItemNBTHelper.setString(stack, "SkullOwner", "Vazkii"); - Object[] inputs = new Object[16]; - Arrays.fill(inputs, pink); - BotaniaAPI.registerPetalRecipe(stack, inputs); - } + ItemStack stack = new ItemStack(Items.skull, 1, 3); + ItemNBTHelper.setString(stack, "SkullOwner", "Vazkii"); + Object[] inputs = new Object[16]; + Arrays.fill(inputs, pink); + BotaniaAPI.registerPetalRecipe(stack, inputs); + } } diff --git a/src/main/java/vazkii/botania/common/crafting/ModPureDaisyRecipes.java b/src/main/java/vazkii/botania/common/crafting/ModPureDaisyRecipes.java index 4d21bb61da..3c39ed963e 100644 --- a/src/main/java/vazkii/botania/common/crafting/ModPureDaisyRecipes.java +++ b/src/main/java/vazkii/botania/common/crafting/ModPureDaisyRecipes.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Apr 17, 2015, 5:18:06 PM (GMT)] */ package vazkii.botania.common.crafting; @@ -18,16 +18,17 @@ public final class ModPureDaisyRecipes { - public static void init() { - if (!ConfigHandler.enableDefaultRecipes) return; + public static void init() { + if (!ConfigHandler.enableDefaultRecipes) return; - BotaniaAPI.registerPureDaisyRecipe("stone", ModBlocks.livingrock, 0); - BotaniaAPI.registerPureDaisyRecipe("logWood", ModBlocks.livingwood, 0); + BotaniaAPI.registerPureDaisyRecipe("stone", ModBlocks.livingrock, 0); + BotaniaAPI.registerPureDaisyRecipe("logWood", ModBlocks.livingwood, 0); + + BotaniaAPI.registerPureDaisyRecipe("netherrack", Blocks.cobblestone, 0); + BotaniaAPI.registerPureDaisyRecipe("soulSand", Blocks.sand, 0); + BotaniaAPI.registerPureDaisyRecipe("ice", Blocks.packed_ice, 0); + BotaniaAPI.registerPureDaisyRecipe(LibOreDict.BLAZE_BLOCK, Blocks.obsidian, 0); + BotaniaAPI.registerPureDaisyRecipe(Blocks.water, Blocks.snow, 0); + } - BotaniaAPI.registerPureDaisyRecipe("netherrack", Blocks.cobblestone, 0); - BotaniaAPI.registerPureDaisyRecipe("soulSand", Blocks.sand, 0); - BotaniaAPI.registerPureDaisyRecipe("ice", Blocks.packed_ice, 0); - BotaniaAPI.registerPureDaisyRecipe(LibOreDict.BLAZE_BLOCK, Blocks.obsidian, 0); - BotaniaAPI.registerPureDaisyRecipe(Blocks.water, Blocks.snow, 0); - } } diff --git a/src/main/java/vazkii/botania/common/crafting/ModRuneRecipes.java b/src/main/java/vazkii/botania/common/crafting/ModRuneRecipes.java index 15c60e23d3..11510020e5 100644 --- a/src/main/java/vazkii/botania/common/crafting/ModRuneRecipes.java +++ b/src/main/java/vazkii/botania/common/crafting/ModRuneRecipes.java @@ -2,16 +2,17 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Feb 6, 2014, 5:59:28 PM (GMT)] */ package vazkii.botania.common.crafting; import java.util.ArrayList; import java.util.List; + import net.minecraft.block.Block; import net.minecraft.init.Blocks; import net.minecraft.init.Items; @@ -25,186 +26,62 @@ public final class ModRuneRecipes { - public static RecipeRuneAltar recipeWaterRune; - public static RecipeRuneAltar recipeFireRune; - public static List recipesEarthRune; - public static List recipesAirRune; - public static RecipeRuneAltar recipeSpringRune; - public static RecipeRuneAltar recipeSummerRune; - public static RecipeRuneAltar recipeAutumnRune; - public static List recipesWinterRune; - public static RecipeRuneAltar recipeManaRune; - public static RecipeRuneAltar recipeLustRune; - public static RecipeRuneAltar recipeGluttonyRune; - public static RecipeRuneAltar recipeGreedRune; - public static RecipeRuneAltar recipeSlothRune; - public static RecipeRuneAltar recipeWrathRune; - public static RecipeRuneAltar recipeEnvyRune; - public static RecipeRuneAltar recipePrideRune; + public static RecipeRuneAltar recipeWaterRune; + public static RecipeRuneAltar recipeFireRune; + public static List recipesEarthRune; + public static List recipesAirRune; + public static RecipeRuneAltar recipeSpringRune; + public static RecipeRuneAltar recipeSummerRune; + public static RecipeRuneAltar recipeAutumnRune; + public static List recipesWinterRune; + public static RecipeRuneAltar recipeManaRune; + public static RecipeRuneAltar recipeLustRune; + public static RecipeRuneAltar recipeGluttonyRune; + public static RecipeRuneAltar recipeGreedRune; + public static RecipeRuneAltar recipeSlothRune; + public static RecipeRuneAltar recipeWrathRune; + public static RecipeRuneAltar recipeEnvyRune; + public static RecipeRuneAltar recipePrideRune; - public static RecipeRuneAltar recipeHead; + public static RecipeRuneAltar recipeHead; - public static void init() { - if (!ConfigHandler.enableDefaultRecipes) return; + public static void init() { + if (!ConfigHandler.enableDefaultRecipes) return; - final int costTier1 = 5200; - final int costTier2 = 8000; - final int costTier3 = 12000; + final int costTier1 = 5200; + final int costTier2 = 8000; + final int costTier3 = 12000; - recipeWaterRune = BotaniaAPI.registerRuneAltarRecipe( - new ItemStack(ModItems.rune, 2, 0), - costTier1, - LibOreDict.MANA_POWDER, - LibOreDict.MANA_STEEL, - new ItemStack(Items.dye, 1, 15), - new ItemStack(Items.reeds), - new ItemStack(Items.fishing_rod)); - recipeFireRune = BotaniaAPI.registerRuneAltarRecipe( - new ItemStack(ModItems.rune, 2, 1), - costTier1, - LibOreDict.MANA_POWDER, - LibOreDict.MANA_STEEL, - new ItemStack(Items.netherbrick), - new ItemStack(Items.gunpowder), - new ItemStack(Items.nether_wart)); + recipeWaterRune = BotaniaAPI.registerRuneAltarRecipe(new ItemStack(ModItems.rune, 2, 0), costTier1, LibOreDict.MANA_POWDER, LibOreDict.MANA_STEEL, new ItemStack(Items.dye, 1, 15), new ItemStack(Items.reeds), new ItemStack(Items.fishing_rod)); + recipeFireRune = BotaniaAPI.registerRuneAltarRecipe(new ItemStack(ModItems.rune, 2, 1), costTier1, LibOreDict.MANA_POWDER, LibOreDict.MANA_STEEL, new ItemStack(Items.netherbrick), new ItemStack(Items.gunpowder), new ItemStack(Items.nether_wart)); - recipesEarthRune = new ArrayList(); - recipesEarthRune.add(BotaniaAPI.registerRuneAltarRecipe( - new ItemStack(ModItems.rune, 2, 2), - costTier1, - LibOreDict.MANA_POWDER, - LibOreDict.MANA_STEEL, - "stone", - new ItemStack(Blocks.coal_block), - new ItemStack(Blocks.brown_mushroom))); - recipesEarthRune.add(BotaniaAPI.registerRuneAltarRecipe( - new ItemStack(ModItems.rune, 2, 2), - costTier1, - LibOreDict.MANA_POWDER, - LibOreDict.MANA_STEEL, - "stone", - new ItemStack(Blocks.coal_block), - new ItemStack(Blocks.red_mushroom))); + recipesEarthRune = new ArrayList(); + recipesEarthRune.add(BotaniaAPI.registerRuneAltarRecipe(new ItemStack(ModItems.rune, 2, 2), costTier1, LibOreDict.MANA_POWDER, LibOreDict.MANA_STEEL, "stone", new ItemStack(Blocks.coal_block), new ItemStack(Blocks.brown_mushroom))); + recipesEarthRune.add(BotaniaAPI.registerRuneAltarRecipe(new ItemStack(ModItems.rune, 2, 2), costTier1, LibOreDict.MANA_POWDER, LibOreDict.MANA_STEEL, "stone", new ItemStack(Blocks.coal_block), new ItemStack(Blocks.red_mushroom))); - recipesAirRune = new ArrayList(); - for (int i = 0; i < 16; i++) - recipesAirRune.add(BotaniaAPI.registerRuneAltarRecipe( - new ItemStack(ModItems.rune, 2, 3), - costTier1, - LibOreDict.MANA_POWDER, - LibOreDict.MANA_STEEL, - new ItemStack(Blocks.carpet, 1, i), - new ItemStack(Items.feather), - new ItemStack(Items.string))); + recipesAirRune = new ArrayList(); + for(int i = 0; i < 16; i++) + recipesAirRune.add(BotaniaAPI.registerRuneAltarRecipe(new ItemStack(ModItems.rune, 2, 3), costTier1, LibOreDict.MANA_POWDER, LibOreDict.MANA_STEEL, new ItemStack(Blocks.carpet, 1, i), new ItemStack(Items.feather), new ItemStack(Items.string))); - recipeSpringRune = BotaniaAPI.registerRuneAltarRecipe( - new ItemStack(ModItems.rune, 1, 4), - costTier2, - LibOreDict.RUNE[0], - LibOreDict.RUNE[1], - "treeSapling", - "treeSapling", - "treeSapling", - new ItemStack(Items.wheat)); - recipeSummerRune = BotaniaAPI.registerRuneAltarRecipe( - new ItemStack(ModItems.rune, 1, 5), - costTier2, - LibOreDict.RUNE[2], - LibOreDict.RUNE[3], - new ItemStack(Block.getBlockFromName("sand")), - new ItemStack(Block.getBlockFromName("sand")), - new ItemStack(Items.slime_ball), - new ItemStack(Items.melon)); - recipeAutumnRune = BotaniaAPI.registerRuneAltarRecipe( - new ItemStack(ModItems.rune, 1, 6), - costTier2, - LibOreDict.RUNE[1], - LibOreDict.RUNE[3], - "treeLeaves", - "treeLeaves", - "treeLeaves", - new ItemStack(Items.spider_eye)); + recipeSpringRune = BotaniaAPI.registerRuneAltarRecipe(new ItemStack(ModItems.rune, 1, 4), costTier2, LibOreDict.RUNE[0], LibOreDict.RUNE[1], "treeSapling", "treeSapling", "treeSapling", new ItemStack(Items.wheat)); + recipeSummerRune = BotaniaAPI.registerRuneAltarRecipe(new ItemStack(ModItems.rune, 1, 5), costTier2, LibOreDict.RUNE[2], LibOreDict.RUNE[3], new ItemStack(Block.getBlockFromName("sand")), new ItemStack(Block.getBlockFromName("sand")), new ItemStack(Items.slime_ball), new ItemStack(Items.melon)); + recipeAutumnRune = BotaniaAPI.registerRuneAltarRecipe(new ItemStack(ModItems.rune, 1, 6), costTier2, LibOreDict.RUNE[1], LibOreDict.RUNE[3], "treeLeaves", "treeLeaves", "treeLeaves", new ItemStack(Items.spider_eye)); - recipesWinterRune = new ArrayList(); - for (int i = 0; i < 16; i++) - recipesWinterRune.add(BotaniaAPI.registerRuneAltarRecipe( - new ItemStack(ModItems.rune, 1, 7), - costTier2, - LibOreDict.RUNE[0], - LibOreDict.RUNE[2], - new ItemStack(Blocks.snow), - new ItemStack(Blocks.snow), - new ItemStack(Blocks.wool, 1, i), - new ItemStack(Items.cake))); + recipesWinterRune = new ArrayList(); + for(int i = 0; i < 16; i++) + recipesWinterRune.add(BotaniaAPI.registerRuneAltarRecipe(new ItemStack(ModItems.rune, 1, 7), costTier2, LibOreDict.RUNE[0], LibOreDict.RUNE[2], new ItemStack(Blocks.snow), new ItemStack(Blocks.snow), new ItemStack(Blocks.wool, 1, i), new ItemStack(Items.cake))); - recipeManaRune = BotaniaAPI.registerRuneAltarRecipe( - new ItemStack(ModItems.rune, 1, 8), - costTier2, - LibOreDict.MANA_STEEL, - LibOreDict.MANA_STEEL, - LibOreDict.MANA_STEEL, - LibOreDict.MANA_STEEL, - LibOreDict.MANA_STEEL, - LibOreDict.MANA_PEARL); + recipeManaRune = BotaniaAPI.registerRuneAltarRecipe(new ItemStack(ModItems.rune, 1, 8), costTier2, LibOreDict.MANA_STEEL, LibOreDict.MANA_STEEL, LibOreDict.MANA_STEEL, LibOreDict.MANA_STEEL, LibOreDict.MANA_STEEL, LibOreDict.MANA_PEARL); - recipeLustRune = BotaniaAPI.registerRuneAltarRecipe( - new ItemStack(ModItems.rune, 1, 9), - costTier3, - LibOreDict.MANA_DIAMOND, - LibOreDict.MANA_DIAMOND, - LibOreDict.RUNE[5], - LibOreDict.RUNE[3]); - recipeGluttonyRune = BotaniaAPI.registerRuneAltarRecipe( - new ItemStack(ModItems.rune, 1, 10), - costTier3, - LibOreDict.MANA_DIAMOND, - LibOreDict.MANA_DIAMOND, - LibOreDict.RUNE[7], - LibOreDict.RUNE[1]); - recipeGreedRune = BotaniaAPI.registerRuneAltarRecipe( - new ItemStack(ModItems.rune, 1, 11), - costTier3, - LibOreDict.MANA_DIAMOND, - LibOreDict.MANA_DIAMOND, - LibOreDict.RUNE[4], - LibOreDict.RUNE[0]); - recipeSlothRune = BotaniaAPI.registerRuneAltarRecipe( - new ItemStack(ModItems.rune, 1, 12), - costTier3, - LibOreDict.MANA_DIAMOND, - LibOreDict.MANA_DIAMOND, - LibOreDict.RUNE[6], - LibOreDict.RUNE[3]); - recipeWrathRune = BotaniaAPI.registerRuneAltarRecipe( - new ItemStack(ModItems.rune, 1, 13), - costTier3, - LibOreDict.MANA_DIAMOND, - LibOreDict.MANA_DIAMOND, - LibOreDict.RUNE[7], - LibOreDict.RUNE[2]); - recipeEnvyRune = BotaniaAPI.registerRuneAltarRecipe( - new ItemStack(ModItems.rune, 1, 14), - costTier3, - LibOreDict.MANA_DIAMOND, - LibOreDict.MANA_DIAMOND, - LibOreDict.RUNE[7], - LibOreDict.RUNE[0]); - recipePrideRune = BotaniaAPI.registerRuneAltarRecipe( - new ItemStack(ModItems.rune, 1, 15), - costTier3, - LibOreDict.MANA_DIAMOND, - LibOreDict.MANA_DIAMOND, - LibOreDict.RUNE[5], - LibOreDict.RUNE[1]); + recipeLustRune = BotaniaAPI.registerRuneAltarRecipe(new ItemStack(ModItems.rune, 1, 9), costTier3, LibOreDict.MANA_DIAMOND, LibOreDict.MANA_DIAMOND, LibOreDict.RUNE[5], LibOreDict.RUNE[3]); + recipeGluttonyRune = BotaniaAPI.registerRuneAltarRecipe(new ItemStack(ModItems.rune, 1, 10), costTier3, LibOreDict.MANA_DIAMOND, LibOreDict.MANA_DIAMOND, LibOreDict.RUNE[7], LibOreDict.RUNE[1]); + recipeGreedRune = BotaniaAPI.registerRuneAltarRecipe(new ItemStack(ModItems.rune, 1, 11), costTier3, LibOreDict.MANA_DIAMOND, LibOreDict.MANA_DIAMOND, LibOreDict.RUNE[4], LibOreDict.RUNE[0]); + recipeSlothRune = BotaniaAPI.registerRuneAltarRecipe(new ItemStack(ModItems.rune, 1, 12), costTier3, LibOreDict.MANA_DIAMOND, LibOreDict.MANA_DIAMOND, LibOreDict.RUNE[6], LibOreDict.RUNE[3]); + recipeWrathRune = BotaniaAPI.registerRuneAltarRecipe(new ItemStack(ModItems.rune, 1, 13), costTier3, LibOreDict.MANA_DIAMOND, LibOreDict.MANA_DIAMOND, LibOreDict.RUNE[7], LibOreDict.RUNE[2]); + recipeEnvyRune = BotaniaAPI.registerRuneAltarRecipe(new ItemStack(ModItems.rune, 1, 14), costTier3, LibOreDict.MANA_DIAMOND, LibOreDict.MANA_DIAMOND, LibOreDict.RUNE[7], LibOreDict.RUNE[0]); + recipePrideRune = BotaniaAPI.registerRuneAltarRecipe(new ItemStack(ModItems.rune, 1, 15), costTier3, LibOreDict.MANA_DIAMOND, LibOreDict.MANA_DIAMOND, LibOreDict.RUNE[5], LibOreDict.RUNE[1]); - recipeHead = new HeadRecipe( - new ItemStack(Items.skull, 1, 3), - 22500, - new ItemStack(Items.skull), - LibOreDict.PIXIE_DUST, - LibOreDict.PRISMARINE_SHARD, - new ItemStack(Items.name_tag), - new ItemStack(Items.golden_apple)); - BotaniaAPI.runeAltarRecipes.add(recipeHead); - } + recipeHead = new HeadRecipe(new ItemStack(Items.skull, 1, 3), 22500, new ItemStack(Items.skull), LibOreDict.PIXIE_DUST, LibOreDict.PRISMARINE_SHARD, new ItemStack(Items.name_tag), new ItemStack(Items.golden_apple)); + BotaniaAPI.runeAltarRecipes.add(recipeHead); + } } diff --git a/src/main/java/vazkii/botania/common/crafting/recipe/AesirRingRecipe.java b/src/main/java/vazkii/botania/common/crafting/recipe/AesirRingRecipe.java index 9013451375..5f784a6856 100644 --- a/src/main/java/vazkii/botania/common/crafting/recipe/AesirRingRecipe.java +++ b/src/main/java/vazkii/botania/common/crafting/recipe/AesirRingRecipe.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Mar 31, 2015, 10:39:58 PM (GMT)] */ package vazkii.botania.common.crafting.recipe; @@ -19,52 +19,58 @@ public class AesirRingRecipe implements IRecipe { - @Override - public boolean matches(InventoryCrafting var1, World var2) { - boolean foundThorRing = false; - boolean foundOdinRing = false; - boolean foundLokiRing = false; + @Override + public boolean matches(InventoryCrafting var1, World var2) { + boolean foundThorRing = false; + boolean foundOdinRing = false; + boolean foundLokiRing = false; - for (int i = 0; i < var1.getSizeInventory(); i++) { - ItemStack stack = var1.getStackInSlot(i); - if (stack != null) { - if (stack.getItem() == ModItems.thorRing && !foundThorRing) foundThorRing = true; - else if (stack.getItem() == ModItems.odinRing && !foundOdinRing) foundOdinRing = true; - else if (stack.getItem() == ModItems.lokiRing && !foundLokiRing) foundLokiRing = true; - else return false; // Found an invalid item, breaking the recipe - } - } + for(int i = 0; i < var1.getSizeInventory(); i++) { + ItemStack stack = var1.getStackInSlot(i); + if(stack != null) { + if(stack.getItem() == ModItems.thorRing && !foundThorRing) + foundThorRing = true; + else if(stack.getItem() == ModItems.odinRing && !foundOdinRing) + foundOdinRing = true; + else if(stack.getItem() == ModItems.lokiRing && !foundLokiRing) + foundLokiRing = true; + else return false; // Found an invalid item, breaking the recipe + } + } - return foundThorRing && foundOdinRing && foundLokiRing; - } + return foundThorRing && foundOdinRing && foundLokiRing; + } - @Override - public ItemStack getCraftingResult(InventoryCrafting var1) { - String soulbind = null; + @Override + public ItemStack getCraftingResult(InventoryCrafting var1) { + String soulbind = null; - for (int i = 0; i < var1.getSizeInventory(); i++) { - ItemStack stack = var1.getStackInSlot(i); - if (stack != null) { - if (stack.getItem() instanceof IRelic) { - String bind = ((IRelic) stack.getItem()).getSoulbindUsername(stack); - if (soulbind == null) soulbind = bind; - else if (!soulbind.equals(bind)) return null; - } else return null; - } - } + for(int i = 0; i < var1.getSizeInventory(); i++) { + ItemStack stack = var1.getStackInSlot(i); + if(stack != null) { + if(stack.getItem() instanceof IRelic) { + String bind = ((IRelic) stack.getItem()).getSoulbindUsername(stack); + if(soulbind == null) + soulbind = bind; + else if(!soulbind.equals(bind)) + return null; + } else return null; + } + } - ItemStack stack = new ItemStack(ModItems.aesirRing); - ((IRelic) ModItems.aesirRing).bindToUsername(soulbind, stack); - return stack; - } + ItemStack stack = new ItemStack(ModItems.aesirRing); + ((IRelic) ModItems.aesirRing).bindToUsername(soulbind, stack); + return stack; + } - @Override - public int getRecipeSize() { - return 10; - } + @Override + public int getRecipeSize() { + return 10; + } + + @Override + public ItemStack getRecipeOutput() { + return null; + } - @Override - public ItemStack getRecipeOutput() { - return null; - } } diff --git a/src/main/java/vazkii/botania/common/crafting/recipe/AncientWillRecipe.java b/src/main/java/vazkii/botania/common/crafting/recipe/AncientWillRecipe.java index 017cdaa40f..15a972168e 100644 --- a/src/main/java/vazkii/botania/common/crafting/recipe/AncientWillRecipe.java +++ b/src/main/java/vazkii/botania/common/crafting/recipe/AncientWillRecipe.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jan 30, 2015, 11:24:08 PM (GMT)] */ package vazkii.botania.common.crafting.recipe; @@ -19,53 +19,58 @@ public class AncientWillRecipe implements IRecipe { - @Override - public boolean matches(InventoryCrafting var1, World var2) { - boolean foundWill = false; - boolean foundItem = false; + @Override + public boolean matches(InventoryCrafting var1, World var2) { + boolean foundWill = false; + boolean foundItem = false; - for (int i = 0; i < var1.getSizeInventory(); i++) { - ItemStack stack = var1.getStackInSlot(i); - if (stack != null) { - if (stack.getItem() == ModItems.ancientWill && !foundWill) foundWill = true; - else if (!foundItem) { - if (stack.getItem() instanceof IAncientWillContainer) foundItem = true; - else return false; - } - } - } + for(int i = 0; i < var1.getSizeInventory(); i++) { + ItemStack stack = var1.getStackInSlot(i); + if(stack != null) { + if(stack.getItem() == ModItems.ancientWill && !foundWill) + foundWill = true; + else if(!foundItem) { + if(stack.getItem() instanceof IAncientWillContainer) + foundItem = true; + else return false; + } + } + } - return foundWill && foundItem; - } + return foundWill && foundItem; + } - @Override - public ItemStack getCraftingResult(InventoryCrafting var1) { - ItemStack item = null; - int will = -1; + @Override + public ItemStack getCraftingResult(InventoryCrafting var1) { + ItemStack item = null; + int will = -1; - for (int i = 0; i < var1.getSizeInventory(); i++) { - ItemStack stack = var1.getStackInSlot(i); - if (stack != null) { - if (stack.getItem() instanceof IAncientWillContainer && item == null) item = stack; - else will = stack.getItemDamage(); - } - } + for(int i = 0; i < var1.getSizeInventory(); i++) { + ItemStack stack = var1.getStackInSlot(i); + if(stack != null) { + if(stack.getItem() instanceof IAncientWillContainer && item == null) + item = stack; + else will = stack.getItemDamage(); + } + } - IAncientWillContainer container = (IAncientWillContainer) item.getItem(); - if (container.hasAncientWill(item, will)) return null; + IAncientWillContainer container = (IAncientWillContainer) item.getItem(); + if(container.hasAncientWill(item, will)) + return null; - ItemStack copy = item.copy(); - container.addAncientWill(copy, will); - return copy; - } + ItemStack copy = item.copy(); + container.addAncientWill(copy, will); + return copy; + } - @Override - public int getRecipeSize() { - return 10; - } + @Override + public int getRecipeSize() { + return 10; + } + + @Override + public ItemStack getRecipeOutput() { + return null; + } - @Override - public ItemStack getRecipeOutput() { - return null; - } } diff --git a/src/main/java/vazkii/botania/common/crafting/recipe/BlackHoleTalismanExtractRecipe.java b/src/main/java/vazkii/botania/common/crafting/recipe/BlackHoleTalismanExtractRecipe.java index 6510aaa0ee..294001effd 100644 --- a/src/main/java/vazkii/botania/common/crafting/recipe/BlackHoleTalismanExtractRecipe.java +++ b/src/main/java/vazkii/botania/common/crafting/recipe/BlackHoleTalismanExtractRecipe.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Apr 9, 2015, 7:48:00 PM (GMT)] */ package vazkii.botania.common.crafting.recipe; @@ -20,47 +20,50 @@ public class BlackHoleTalismanExtractRecipe implements IRecipe { - @Override - public boolean matches(InventoryCrafting var1, World var2) { - boolean foundTalisman = false; + @Override + public boolean matches(InventoryCrafting var1, World var2) { + boolean foundTalisman = false; - for (int i = 0; i < var1.getSizeInventory(); i++) { - ItemStack stack = var1.getStackInSlot(i); - if (stack != null) { - if (stack.getItem() == ModItems.blackHoleTalisman && !foundTalisman) foundTalisman = true; - else return false; - } - } + for(int i = 0; i < var1.getSizeInventory(); i++) { + ItemStack stack = var1.getStackInSlot(i); + if(stack != null) { + if(stack.getItem() == ModItems.blackHoleTalisman && !foundTalisman) + foundTalisman = true; + else return false; + } + } - return foundTalisman; - } + return foundTalisman; + } - @Override - public ItemStack getCraftingResult(InventoryCrafting var1) { - ItemStack talisman = null; + @Override + public ItemStack getCraftingResult(InventoryCrafting var1) { + ItemStack talisman = null; - for (int i = 0; i < var1.getSizeInventory(); i++) { - ItemStack stack = var1.getStackInSlot(i); - if (stack != null) talisman = stack; - } + for(int i = 0; i < var1.getSizeInventory(); i++) { + ItemStack stack = var1.getStackInSlot(i); + if(stack != null) + talisman = stack; + } - int count = ItemBlackHoleTalisman.getBlockCount(talisman); - if (count > 0) { - Block block = ItemBlackHoleTalisman.getBlock(talisman); - int meta = ItemBlackHoleTalisman.getBlockMeta(talisman); - return new ItemStack(block, Math.min(64, count), meta); - } + int count = ItemBlackHoleTalisman.getBlockCount(talisman); + if(count > 0) { + Block block = ItemBlackHoleTalisman.getBlock(talisman); + int meta = ItemBlackHoleTalisman.getBlockMeta(talisman); + return new ItemStack(block, Math.min(64, count), meta); + } - return null; - } + return null; + } - @Override - public int getRecipeSize() { - return 10; - } + @Override + public int getRecipeSize() { + return 10; + } + + @Override + public ItemStack getRecipeOutput() { + return null; + } - @Override - public ItemStack getRecipeOutput() { - return null; - } } diff --git a/src/main/java/vazkii/botania/common/crafting/recipe/CompositeLensRecipe.java b/src/main/java/vazkii/botania/common/crafting/recipe/CompositeLensRecipe.java index a223846a5e..7fc42916bd 100644 --- a/src/main/java/vazkii/botania/common/crafting/recipe/CompositeLensRecipe.java +++ b/src/main/java/vazkii/botania/common/crafting/recipe/CompositeLensRecipe.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Mar 17, 2014, 8:30:41 PM (GMT)] */ package vazkii.botania.common.crafting.recipe; @@ -21,63 +21,64 @@ public class CompositeLensRecipe implements IRecipe { - @Override - public boolean matches(InventoryCrafting var1, World var2) { - boolean foundLens = false; - boolean foundSecondLens = false; - boolean foundSlimeball = false; + @Override + public boolean matches(InventoryCrafting var1, World var2) { + boolean foundLens = false; + boolean foundSecondLens = false; + boolean foundSlimeball = false; - for (int i = 0; i < var1.getSizeInventory(); i++) { - ItemStack stack = var1.getStackInSlot(i); - if (stack != null) { - if (stack.getItem() instanceof ICompositableLens && !foundSecondLens) { - if (foundLens) foundSecondLens = true; - else foundLens = true; - } else if (stack.getItem() == Items.slime_ball) foundSlimeball = true; - else return false; // Found an invalid item, breaking the recipe - } - } + for(int i = 0; i < var1.getSizeInventory(); i++) { + ItemStack stack = var1.getStackInSlot(i); + if(stack != null) { + if(stack.getItem() instanceof ICompositableLens && !foundSecondLens) { + if(foundLens) + foundSecondLens = true; + else foundLens = true; + } else if(stack.getItem() == Items.slime_ball) + foundSlimeball = true; + else return false; // Found an invalid item, breaking the recipe + } + } - return foundSecondLens && foundSlimeball; - } + return foundSecondLens && foundSlimeball; + } - @Override - public ItemStack getCraftingResult(InventoryCrafting var1) { - ItemStack lens = null; - ItemStack secondLens = null; + @Override + public ItemStack getCraftingResult(InventoryCrafting var1) { + ItemStack lens = null; + ItemStack secondLens = null; - for (int i = 0; i < var1.getSizeInventory(); i++) { - ItemStack stack = var1.getStackInSlot(i); - if (stack != null) { - if (stack.getItem() instanceof ICompositableLens) - if (lens == null) lens = stack; - else secondLens = stack; - } - } + for(int i = 0; i < var1.getSizeInventory(); i++) { + ItemStack stack = var1.getStackInSlot(i); + if(stack != null) { + if(stack.getItem() instanceof ICompositableLens) + if(lens == null) + lens = stack; + else secondLens = stack; + } + } - if (lens.getItem() instanceof ICompositableLens) { - ICompositableLens lensItem = (ICompositableLens) lens.getItem(); - if (secondLens == null - || !lensItem.canCombineLenses(lens, secondLens) - || lensItem.getCompositeLens(lens) != null - || lensItem.getCompositeLens(secondLens) != null) return null; + if(lens.getItem() instanceof ICompositableLens) { + ICompositableLens lensItem = (ICompositableLens) lens.getItem(); + if(secondLens == null || !lensItem.canCombineLenses(lens, secondLens) || lensItem.getCompositeLens(lens) != null || lensItem.getCompositeLens(secondLens) != null) + return null; - ItemStack lensCopy = lens.copy(); - ((ItemLens) ModItems.lens).setCompositeLens(lensCopy, secondLens); + ItemStack lensCopy = lens.copy(); + ((ItemLens) ModItems.lens).setCompositeLens(lensCopy, secondLens); - return lensCopy; - } + return lensCopy; + } - return null; - } + return null; + } - @Override - public int getRecipeSize() { - return 10; - } + @Override + public int getRecipeSize() { + return 10; + } - @Override - public ItemStack getRecipeOutput() { - return null; - } -} + @Override + public ItemStack getRecipeOutput() { + return null; + } +} \ No newline at end of file diff --git a/src/main/java/vazkii/botania/common/crafting/recipe/CosmeticAttachRecipe.java b/src/main/java/vazkii/botania/common/crafting/recipe/CosmeticAttachRecipe.java index e02c2a7e64..3803e08b12 100644 --- a/src/main/java/vazkii/botania/common/crafting/recipe/CosmeticAttachRecipe.java +++ b/src/main/java/vazkii/botania/common/crafting/recipe/CosmeticAttachRecipe.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Feb 22, 2015, 8:49:53 PM (GMT)] */ package vazkii.botania.common.crafting.recipe; @@ -19,56 +19,57 @@ public class CosmeticAttachRecipe implements IRecipe { - @Override - public boolean matches(InventoryCrafting var1, World var2) { - boolean foundCosmetic = false; - boolean foundAttachable = false; + @Override + public boolean matches(InventoryCrafting var1, World var2) { + boolean foundCosmetic = false; + boolean foundAttachable = false; - for (int i = 0; i < var1.getSizeInventory(); i++) { - ItemStack stack = var1.getStackInSlot(i); - if (stack != null) { - if (stack.getItem() instanceof ICosmeticBauble && !foundCosmetic) foundCosmetic = true; - else if (!foundAttachable) { - if (stack.getItem() instanceof ICosmeticAttachable - && !(stack.getItem() instanceof ICosmeticBauble) - && ((ICosmeticAttachable) stack.getItem()).getCosmeticItem(stack) == null) - foundAttachable = true; - else return false; - } - } - } + for(int i = 0; i < var1.getSizeInventory(); i++) { + ItemStack stack = var1.getStackInSlot(i); + if(stack != null) { + if(stack.getItem() instanceof ICosmeticBauble && !foundCosmetic) + foundCosmetic = true; + else if(!foundAttachable) { + if(stack.getItem() instanceof ICosmeticAttachable && !(stack.getItem() instanceof ICosmeticBauble) && ((ICosmeticAttachable) stack.getItem()).getCosmeticItem(stack) == null) + foundAttachable = true; + else return false; + } + } + } - return foundCosmetic && foundAttachable; - } + return foundCosmetic && foundAttachable; + } - @Override - public ItemStack getCraftingResult(InventoryCrafting var1) { - ItemStack cosmeticItem = null; - ItemStack attachableItem = null; + @Override + public ItemStack getCraftingResult(InventoryCrafting var1) { + ItemStack cosmeticItem = null; + ItemStack attachableItem = null; - for (int i = 0; i < var1.getSizeInventory(); i++) { - ItemStack stack = var1.getStackInSlot(i); - if (stack != null) { - if (stack.getItem() instanceof ICosmeticBauble && cosmeticItem == null) cosmeticItem = stack; - else attachableItem = stack; - } - } + for(int i = 0; i < var1.getSizeInventory(); i++) { + ItemStack stack = var1.getStackInSlot(i); + if(stack != null) { + if(stack.getItem() instanceof ICosmeticBauble && cosmeticItem == null) + cosmeticItem = stack; + else attachableItem = stack; + } + } - ICosmeticAttachable attachable = (ICosmeticAttachable) attachableItem.getItem(); - if (attachable.getCosmeticItem(attachableItem) != null) return null; + ICosmeticAttachable attachable = (ICosmeticAttachable) attachableItem.getItem(); + if(attachable.getCosmeticItem(attachableItem) != null) + return null; - ItemStack copy = attachableItem.copy(); - attachable.setCosmeticItem(copy, cosmeticItem); - return copy; - } + ItemStack copy = attachableItem.copy(); + attachable.setCosmeticItem(copy, cosmeticItem); + return copy; + } - @Override - public int getRecipeSize() { - return 10; - } + @Override + public int getRecipeSize() { + return 10; + } - @Override - public ItemStack getRecipeOutput() { - return null; - } + @Override + public ItemStack getRecipeOutput() { + return null; + } } diff --git a/src/main/java/vazkii/botania/common/crafting/recipe/CosmeticRemoveRecipe.java b/src/main/java/vazkii/botania/common/crafting/recipe/CosmeticRemoveRecipe.java index 8b0cc9c2eb..af26d305f8 100644 --- a/src/main/java/vazkii/botania/common/crafting/recipe/CosmeticRemoveRecipe.java +++ b/src/main/java/vazkii/botania/common/crafting/recipe/CosmeticRemoveRecipe.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Feb 22, 2015, 8:55:03 PM (GMT)] */ package vazkii.botania.common.crafting.recipe; @@ -19,48 +19,49 @@ public class CosmeticRemoveRecipe implements IRecipe { - @Override - public boolean matches(InventoryCrafting var1, World var2) { - boolean foundAttachable = false; + @Override + public boolean matches(InventoryCrafting var1, World var2) { + boolean foundAttachable = false; - for (int i = 0; i < var1.getSizeInventory(); i++) { - ItemStack stack = var1.getStackInSlot(i); - if (stack != null) { - if (stack.getItem() instanceof ICosmeticAttachable - && !(stack.getItem() instanceof ICosmeticBauble) - && ((ICosmeticAttachable) stack.getItem()).getCosmeticItem(stack) != null) - foundAttachable = true; - else return false; - } - } + for(int i = 0; i < var1.getSizeInventory(); i++) { + ItemStack stack = var1.getStackInSlot(i); + if(stack != null) { + if(stack.getItem() instanceof ICosmeticAttachable && !(stack.getItem() instanceof ICosmeticBauble) && ((ICosmeticAttachable) stack.getItem()).getCosmeticItem(stack) != null) + foundAttachable = true; + else return false; + } + } - return foundAttachable; - } + return foundAttachable; + } - @Override - public ItemStack getCraftingResult(InventoryCrafting var1) { - ItemStack attachableItem = null; + @Override + public ItemStack getCraftingResult(InventoryCrafting var1) { + ItemStack attachableItem = null; - for (int i = 0; i < var1.getSizeInventory(); i++) { - ItemStack stack = var1.getStackInSlot(i); - if (stack != null) attachableItem = stack; - } + for(int i = 0; i < var1.getSizeInventory(); i++) { + ItemStack stack = var1.getStackInSlot(i); + if(stack != null) + attachableItem = stack; + } - ICosmeticAttachable attachable = (ICosmeticAttachable) attachableItem.getItem(); - if (attachable.getCosmeticItem(attachableItem) == null) return null; + ICosmeticAttachable attachable = (ICosmeticAttachable) attachableItem.getItem(); + if(attachable.getCosmeticItem(attachableItem) == null) + return null; - ItemStack copy = attachableItem.copy(); - attachable.setCosmeticItem(copy, null); - return copy; - } + ItemStack copy = attachableItem.copy(); + attachable.setCosmeticItem(copy, null); + return copy; + } - @Override - public int getRecipeSize() { - return 10; - } + @Override + public int getRecipeSize() { + return 10; + } + + @Override + public ItemStack getRecipeOutput() { + return null; + } - @Override - public ItemStack getRecipeOutput() { - return null; - } } diff --git a/src/main/java/vazkii/botania/common/crafting/recipe/HeadRecipe.java b/src/main/java/vazkii/botania/common/crafting/recipe/HeadRecipe.java index 09bf1eca0b..5472e75ad9 100644 --- a/src/main/java/vazkii/botania/common/crafting/recipe/HeadRecipe.java +++ b/src/main/java/vazkii/botania/common/crafting/recipe/HeadRecipe.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jul 23, 2014, 3:02:17 PM (GMT)] */ package vazkii.botania.common.crafting.recipe; @@ -19,35 +19,39 @@ public class HeadRecipe extends RecipeRuneAltar { - String name = ""; - - public HeadRecipe(ItemStack output, int mana, Object... inputs) { - super(output, mana, inputs); - } - - @Override - public boolean matches(IInventory inv) { - boolean matches = super.matches(inv); - - if (matches) { - for (int i = 0; i < inv.getSizeInventory(); i++) { - ItemStack stack = inv.getStackInSlot(i); - if (stack == null) break; - - if (stack.getItem() == Items.name_tag) { - name = stack.getDisplayName(); - if (name.equals(StatCollector.translateToLocal("item.nameTag.name"))) return false; - } - } - } - - return matches; - } - - @Override - public ItemStack getOutput() { - ItemStack stack = new ItemStack(Items.skull, 1, 3); - if (!name.isEmpty()) ItemNBTHelper.setString(stack, "SkullOwner", name); - return stack; - } + String name = ""; + + public HeadRecipe(ItemStack output, int mana, Object... inputs) { + super(output, mana, inputs); + } + + @Override + public boolean matches(IInventory inv) { + boolean matches = super.matches(inv); + + if(matches) { + for(int i = 0; i < inv.getSizeInventory(); i++) { + ItemStack stack = inv.getStackInSlot(i); + if(stack == null) + break; + + if(stack.getItem() == Items.name_tag) { + name = stack.getDisplayName(); + if(name.equals(StatCollector.translateToLocal("item.nameTag.name"))) + return false; + } + } + } + + return matches; + } + + @Override + public ItemStack getOutput() { + ItemStack stack = new ItemStack(Items.skull, 1, 3); + if(!name.isEmpty()) + ItemNBTHelper.setString(stack, "SkullOwner", name); + return stack; + } + } diff --git a/src/main/java/vazkii/botania/common/crafting/recipe/HelmRevealingRecipe.java b/src/main/java/vazkii/botania/common/crafting/recipe/HelmRevealingRecipe.java index 952568878f..0ac847be8f 100644 --- a/src/main/java/vazkii/botania/common/crafting/recipe/HelmRevealingRecipe.java +++ b/src/main/java/vazkii/botania/common/crafting/recipe/HelmRevealingRecipe.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [May 6, 2015, 9:45:56 PM (GMT)] */ package vazkii.botania.common.crafting.recipe; @@ -21,75 +21,83 @@ public class HelmRevealingRecipe implements IRecipe { - @Override - public boolean matches(InventoryCrafting var1, World var2) { - Item goggles = (Item) Item.itemRegistry.getObject("Thaumcraft:ItemGoggles"); - if (goggles == null) return false; // NO TC loaded - - boolean foundGoggles = false; - boolean foundHelm = false; - for (int i = 0; i < var1.getSizeInventory(); i++) { - ItemStack stack = var1.getStackInSlot(i); - if (stack != null) { - if (checkHelm(stack)) foundHelm = true; - else if (stack.getItem() == goggles) foundGoggles = true; - else return false; // Found an invalid item, breaking the recipe - } - } - return foundGoggles && foundHelm; - } - - @Override - public ItemStack getCraftingResult(InventoryCrafting var1) { - ItemStack helm = null; - - for (int i = 0; i < var1.getSizeInventory(); i++) { - ItemStack stack = var1.getStackInSlot(i); - if (stack != null && checkHelm(stack)) helm = stack; - } - - if (helm == null) return null; - - ItemStack helmCopy = helm.copy(); - Item helmItem = helmCopy.getItem(); - - ItemStack newHelm; - - if (helmItem == ModItems.manasteelHelm) newHelm = new ItemStack(ModItems.manasteelHelmRevealing); - else if (helmItem == ModItems.terrasteelHelm) newHelm = new ItemStack(ModItems.terrasteelHelmRevealing); - else if (helmItem == ModItems.elementiumHelm) newHelm = new ItemStack(ModItems.elementiumHelmRevealing); - else return null; - - // Copy Ancient Wills - for (int i = 0; i < 6; i++) - if (ItemNBTHelper.getBoolean(helmCopy, "AncientWill" + i, false)) - ItemNBTHelper.setBoolean(newHelm, "AncientWill" + i, true); - - // Copy Enchantments - NBTTagList enchList = ItemNBTHelper.getList(helmCopy, "ench", 10, true); - if (enchList != null) ItemNBTHelper.setList(newHelm, "ench", enchList); - - // Copy Runic Hardening - byte runicHardening = ItemNBTHelper.getByte(helmCopy, "RS.HARDEN", (byte) 0); - ItemNBTHelper.setByte(newHelm, "RS.HARDEN", runicHardening); - - return newHelm; - } - - @Override - public int getRecipeSize() { - return 10; - } - - @Override - public ItemStack getRecipeOutput() { - return new ItemStack(ModItems.manasteelHelmRevealing); - } - - private boolean checkHelm(ItemStack helmStack) { - Item helmItem = helmStack.getItem(); - return helmItem == ModItems.manasteelHelm - || helmItem == ModItems.terrasteelHelm - || helmItem == ModItems.elementiumHelm; - } -} + @Override + public boolean matches(InventoryCrafting var1, World var2) { + Item goggles = (Item) Item.itemRegistry.getObject("Thaumcraft:ItemGoggles"); + if(goggles == null) + return false; // NO TC loaded + + boolean foundGoggles = false; + boolean foundHelm = false; + for(int i = 0; i < var1.getSizeInventory(); i++) { + ItemStack stack = var1.getStackInSlot(i); + if(stack != null) { + if(checkHelm(stack)) + foundHelm = true; + else if(stack.getItem() == goggles) + foundGoggles = true; + else return false; // Found an invalid item, breaking the recipe + } + } + return foundGoggles && foundHelm; + } + + @Override + public ItemStack getCraftingResult(InventoryCrafting var1) { + ItemStack helm = null; + + for(int i = 0; i < var1.getSizeInventory(); i++) { + ItemStack stack = var1.getStackInSlot(i); + if(stack != null && checkHelm(stack)) + helm = stack; + } + + if(helm == null) + return null; + + ItemStack helmCopy = helm.copy(); + Item helmItem = helmCopy.getItem(); + + ItemStack newHelm; + + if(helmItem == ModItems.manasteelHelm) + newHelm = new ItemStack(ModItems.manasteelHelmRevealing); + else if(helmItem == ModItems.terrasteelHelm) + newHelm = new ItemStack(ModItems.terrasteelHelmRevealing); + else if(helmItem == ModItems.elementiumHelm) + newHelm = new ItemStack(ModItems.elementiumHelmRevealing); + else return null; + + //Copy Ancient Wills + for(int i = 0; i < 6; i++) + if(ItemNBTHelper.getBoolean(helmCopy, "AncientWill" + i, false)) + ItemNBTHelper.setBoolean(newHelm, "AncientWill" + i, true); + + //Copy Enchantments + NBTTagList enchList = ItemNBTHelper.getList(helmCopy, "ench", 10, true); + if(enchList != null) + ItemNBTHelper.setList(newHelm, "ench", enchList); + + //Copy Runic Hardening + byte runicHardening = ItemNBTHelper.getByte(helmCopy, "RS.HARDEN", (byte)0); + ItemNBTHelper.setByte(newHelm, "RS.HARDEN", runicHardening); + + return newHelm; + } + + @Override + public int getRecipeSize() { + return 10; + } + + @Override + public ItemStack getRecipeOutput() { + return new ItemStack(ModItems.manasteelHelmRevealing); + } + + private boolean checkHelm(ItemStack helmStack) { + Item helmItem = helmStack.getItem(); + return helmItem == ModItems.manasteelHelm || helmItem == ModItems.terrasteelHelm || helmItem == ModItems.elementiumHelm; + } + +} \ No newline at end of file diff --git a/src/main/java/vazkii/botania/common/crafting/recipe/KeepIvyRecipe.java b/src/main/java/vazkii/botania/common/crafting/recipe/KeepIvyRecipe.java index 592fc1ea31..6b60ef83be 100644 --- a/src/main/java/vazkii/botania/common/crafting/recipe/KeepIvyRecipe.java +++ b/src/main/java/vazkii/botania/common/crafting/recipe/KeepIvyRecipe.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Mar 31, 2015, 9:23:22 PM (GMT)] */ package vazkii.botania.common.crafting.recipe; @@ -20,48 +20,49 @@ public class KeepIvyRecipe implements IRecipe { - @Override - public boolean matches(InventoryCrafting var1, World var2) { - boolean foundIvy = false; - boolean foundItem = false; + @Override + public boolean matches(InventoryCrafting var1, World var2) { + boolean foundIvy = false; + boolean foundItem = false; - for (int i = 0; i < var1.getSizeInventory(); i++) { - ItemStack stack = var1.getStackInSlot(i); - if (stack != null) { - if (stack.getItem() == ModItems.keepIvy) foundIvy = true; - else if (!foundItem - && !(ItemNBTHelper.detectNBT(stack) - && ItemNBTHelper.getBoolean(stack, ItemKeepIvy.TAG_KEEP, false)) - && !stack.getItem().hasContainerItem(stack)) foundItem = true; - else return false; - } - } + for(int i = 0; i < var1.getSizeInventory(); i++) { + ItemStack stack = var1.getStackInSlot(i); + if(stack != null) { + if(stack.getItem() == ModItems.keepIvy) + foundIvy = true; + else if(!foundItem && !(ItemNBTHelper.detectNBT(stack) && ItemNBTHelper.getBoolean(stack, ItemKeepIvy.TAG_KEEP, false)) && !stack.getItem().hasContainerItem(stack)) + foundItem = true; + else return false; + } + } - return foundIvy && foundItem; - } + return foundIvy && foundItem; + } - @Override - public ItemStack getCraftingResult(InventoryCrafting var1) { - ItemStack item = null; + @Override + public ItemStack getCraftingResult(InventoryCrafting var1) { + ItemStack item = null; - for (int i = 0; i < var1.getSizeInventory(); i++) { - ItemStack stack = var1.getStackInSlot(i); - if (stack != null && stack.getItem() != ModItems.keepIvy) item = stack; - } + for(int i = 0; i < var1.getSizeInventory(); i++) { + ItemStack stack = var1.getStackInSlot(i); + if(stack != null && stack.getItem() != ModItems.keepIvy) + item = stack; + } - ItemStack copy = item.copy(); - ItemNBTHelper.setBoolean(copy, ItemKeepIvy.TAG_KEEP, true); - copy.stackSize = 1; - return copy; - } + ItemStack copy = item.copy(); + ItemNBTHelper.setBoolean(copy, ItemKeepIvy.TAG_KEEP, true); + copy.stackSize = 1; + return copy; + } - @Override - public int getRecipeSize() { - return 10; - } + @Override + public int getRecipeSize() { + return 10; + } + + @Override + public ItemStack getRecipeOutput() { + return null; + } - @Override - public ItemStack getRecipeOutput() { - return null; - } } diff --git a/src/main/java/vazkii/botania/common/crafting/recipe/LensDyeingRecipe.java b/src/main/java/vazkii/botania/common/crafting/recipe/LensDyeingRecipe.java index 0bb5c28882..4f1fab8f91 100644 --- a/src/main/java/vazkii/botania/common/crafting/recipe/LensDyeingRecipe.java +++ b/src/main/java/vazkii/botania/common/crafting/recipe/LensDyeingRecipe.java @@ -2,16 +2,17 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jan 23, 2015, 4:10:24 PM (GMT)] */ package vazkii.botania.common.crafting.recipe; import java.util.Arrays; import java.util.List; + import net.minecraft.inventory.InventoryCrafting; import net.minecraft.item.ItemStack; import net.minecraft.item.crafting.IRecipe; @@ -23,89 +24,77 @@ public class LensDyeingRecipe implements IRecipe { - private static final List DYES = Arrays.asList(new String[] { - "dyeWhite", - "dyeOrange", - "dyeMagenta", - "dyeLightBlue", - "dyeYellow", - "dyeLime", - "dyePink", - "dyeGray", - "dyeLightGray", - "dyeCyan", - "dyePurple", - "dyeBlue", - "dyeBrown", - "dyeGreen", - "dyeRed", - "dyeBlack", - LibOreDict.MANA_PEARL - }); - - @Override - public boolean matches(InventoryCrafting var1, World var2) { - boolean foundLens = false; - boolean foundDye = false; - - for (int i = 0; i < var1.getSizeInventory(); i++) { - ItemStack stack = var1.getStackInSlot(i); - if (stack != null) { - if (stack.getItem() instanceof ILens && !foundLens) foundLens = true; - else if (!foundDye) { - int color = getStackColor(stack); - if (color > -1) foundDye = true; - else return false; - } else return false; // This means we have an additional item in the recipe after the lens and dye - } - } - - return foundLens && foundDye; - } - - @Override - public ItemStack getCraftingResult(InventoryCrafting var1) { - ItemStack lens = null; - int color = -1; - - for (int i = 0; i < var1.getSizeInventory(); i++) { - ItemStack stack = var1.getStackInSlot(i); - if (stack != null) { - if (stack.getItem() instanceof ILens && lens == null) lens = stack; - else - color = getStackColor( - stack); // We can assume if its not a lens its a dye because we checked it in matches() - } - } - - if (lens.getItem() instanceof ILens) { - lens.getItem(); - ItemStack lensCopy = lens.copy(); - ItemLens.setLensColor(lensCopy, color); - - return lensCopy; - } - - return null; - } - - @Override - public int getRecipeSize() { - return 10; - } - - @Override - public ItemStack getRecipeOutput() { - return null; - } - - int getStackColor(ItemStack stack) { - int[] ids = OreDictionary.getOreIDs(stack); - for (int i : ids) { - int index = DYES.indexOf(OreDictionary.getOreName(i)); - if (index >= 0) return index; - } - - return -1; - } + private static final List DYES = Arrays.asList(new String[] { + "dyeWhite", "dyeOrange", "dyeMagenta", "dyeLightBlue", "dyeYellow", "dyeLime", "dyePink", "dyeGray", "dyeLightGray", "dyeCyan", "dyePurple", "dyeBlue", "dyeBrown", "dyeGreen", "dyeRed", "dyeBlack", LibOreDict.MANA_PEARL + }); + + @Override + public boolean matches(InventoryCrafting var1, World var2) { + boolean foundLens = false; + boolean foundDye = false; + + for(int i = 0; i < var1.getSizeInventory(); i++) { + ItemStack stack = var1.getStackInSlot(i); + if(stack != null) { + if(stack.getItem() instanceof ILens && !foundLens) + foundLens = true; + else if(!foundDye) { + int color = getStackColor(stack); + if(color > -1) + foundDye = true; + else return false; + } + else return false;//This means we have an additional item in the recipe after the lens and dye + } + } + + return foundLens && foundDye; + } + + @Override + public ItemStack getCraftingResult(InventoryCrafting var1) { + ItemStack lens = null; + int color = -1; + + for(int i = 0; i < var1.getSizeInventory(); i++) { + ItemStack stack = var1.getStackInSlot(i); + if(stack != null) { + if(stack.getItem() instanceof ILens && lens == null) + lens = stack; + else color = getStackColor(stack);//We can assume if its not a lens its a dye because we checked it in matches() + } + } + + if(lens.getItem() instanceof ILens) { + lens.getItem(); + ItemStack lensCopy = lens.copy(); + ItemLens.setLensColor(lensCopy, color); + + return lensCopy; + } + + return null; + } + + @Override + public int getRecipeSize() { + return 10; + } + + @Override + public ItemStack getRecipeOutput() { + return null; + } + + int getStackColor(ItemStack stack) { + int[] ids = OreDictionary.getOreIDs(stack); + for(int i : ids) { + int index = DYES.indexOf(OreDictionary.getOreName(i)); + if(index >= 0) + return index; + } + + return -1; + } + } diff --git a/src/main/java/vazkii/botania/common/crafting/recipe/ManaGunClipRecipe.java b/src/main/java/vazkii/botania/common/crafting/recipe/ManaGunClipRecipe.java index 5fa7b8f080..7403daaf81 100644 --- a/src/main/java/vazkii/botania/common/crafting/recipe/ManaGunClipRecipe.java +++ b/src/main/java/vazkii/botania/common/crafting/recipe/ManaGunClipRecipe.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jan 24, 2015, 8:37:33 PM (GMT)] */ package vazkii.botania.common.crafting.recipe; @@ -17,51 +17,59 @@ import vazkii.botania.common.item.ItemManaGun; import vazkii.botania.common.item.ModItems; -public class ManaGunClipRecipe implements IRecipe { +public class ManaGunClipRecipe implements IRecipe { - @Override - public boolean matches(InventoryCrafting var1, World var2) { - boolean foundGun = false; - boolean foundClip = false; + @Override + public boolean matches(InventoryCrafting var1, World var2) { + boolean foundGun = false; + boolean foundClip = false; - for (int i = 0; i < var1.getSizeInventory(); i++) { - ItemStack stack = var1.getStackInSlot(i); - if (stack != null) { - if (stack.getItem() instanceof ItemManaGun && !ItemManaGun.hasClip(stack)) foundGun = true; - else if (stack.getItem() == ModItems.clip) foundClip = true; - else return false; // Found an invalid item, breaking the recipe - } - } + for(int i = 0; i < var1.getSizeInventory(); i++) { + ItemStack stack = var1.getStackInSlot(i); + if(stack != null) { + if(stack.getItem() instanceof ItemManaGun && !ItemManaGun.hasClip(stack)) + foundGun = true; - return foundGun && foundClip; - } + else if(stack.getItem() == ModItems.clip) + foundClip = true; - @Override - public ItemStack getCraftingResult(InventoryCrafting var1) { - ItemStack gun = null; + else return false; // Found an invalid item, breaking the recipe + } + } - for (int i = 0; i < var1.getSizeInventory(); i++) { - ItemStack stack = var1.getStackInSlot(i); - if (stack != null && stack.getItem() instanceof ItemManaGun) gun = stack; - } + return foundGun && foundClip; + } - if (gun == null) return null; + @Override + public ItemStack getCraftingResult(InventoryCrafting var1) { + ItemStack gun = null; - ItemStack lens = ItemManaGun.getLens(gun); - ItemManaGun.setLens(gun, null); - ItemStack gunCopy = gun.copy(); - ItemManaGun.setClip(gunCopy, true); - ItemManaGun.setLensAtPos(gunCopy, lens, 0); - return gunCopy; - } + for(int i = 0; i < var1.getSizeInventory(); i++) { + ItemStack stack = var1.getStackInSlot(i); + if(stack != null && stack.getItem() instanceof ItemManaGun) + gun = stack; + } + + if(gun == null) + return null; + + ItemStack lens = ItemManaGun.getLens(gun); + ItemManaGun.setLens(gun, null); + ItemStack gunCopy = gun.copy(); + ItemManaGun.setClip(gunCopy, true); + ItemManaGun.setLensAtPos(gunCopy, lens, 0); + return gunCopy; + } + + @Override + public int getRecipeSize() { + return 10; + } + + @Override + public ItemStack getRecipeOutput() { + return null; + } - @Override - public int getRecipeSize() { - return 10; - } - @Override - public ItemStack getRecipeOutput() { - return null; - } } diff --git a/src/main/java/vazkii/botania/common/crafting/recipe/ManaGunLensRecipe.java b/src/main/java/vazkii/botania/common/crafting/recipe/ManaGunLensRecipe.java index f4a15cc7bb..38b6a15f2b 100644 --- a/src/main/java/vazkii/botania/common/crafting/recipe/ManaGunLensRecipe.java +++ b/src/main/java/vazkii/botania/common/crafting/recipe/ManaGunLensRecipe.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Mar 13, 2014, 8:01:14 PM (GMT)] */ package vazkii.botania.common.crafting.recipe; @@ -20,54 +20,63 @@ public class ManaGunLensRecipe implements IRecipe { - @Override - public boolean matches(InventoryCrafting var1, World var2) { - boolean foundLens = false; - boolean foundGun = false; - - for (int i = 0; i < var1.getSizeInventory(); i++) { - ItemStack stack = var1.getStackInSlot(i); - if (stack != null) { - if (stack.getItem() instanceof ItemManaGun && ItemManaGun.getLens(stack) == null) foundGun = true; - else if (stack.getItem() instanceof ILens) { - if (!(stack.getItem() instanceof ILensControl) - || !((ILensControl) stack.getItem()).isControlLens(stack)) foundLens = true; - else return false; - } else return false; // Found an invalid item, breaking the recipe - } - } - - return foundLens && foundGun; - } - - @Override - public ItemStack getCraftingResult(InventoryCrafting var1) { - ItemStack lens = null; - ItemStack gun = null; - - for (int i = 0; i < var1.getSizeInventory(); i++) { - ItemStack stack = var1.getStackInSlot(i); - if (stack != null) { - if (stack.getItem() instanceof ItemManaGun) gun = stack; - else if (stack.getItem() instanceof ILens) lens = stack; - } - } - - if (lens == null || gun == null) return null; - - ItemStack gunCopy = gun.copy(); - ItemManaGun.setLens(gunCopy, lens); - - return gunCopy; - } - - @Override - public int getRecipeSize() { - return 10; - } - - @Override - public ItemStack getRecipeOutput() { - return null; - } + @Override + public boolean matches(InventoryCrafting var1, World var2) { + boolean foundLens = false; + boolean foundGun = false; + + for(int i = 0; i < var1.getSizeInventory(); i++) { + ItemStack stack = var1.getStackInSlot(i); + if(stack != null) { + if(stack.getItem() instanceof ItemManaGun && ItemManaGun.getLens(stack) == null) + foundGun = true; + + else if(stack.getItem() instanceof ILens) { + if(!(stack.getItem() instanceof ILensControl) || !((ILensControl) stack.getItem()).isControlLens(stack)) + foundLens = true; + else return false; + } + + else return false; // Found an invalid item, breaking the recipe + } + } + + return foundLens && foundGun; + } + + @Override + public ItemStack getCraftingResult(InventoryCrafting var1) { + ItemStack lens = null; + ItemStack gun = null; + + for(int i = 0; i < var1.getSizeInventory(); i++) { + ItemStack stack = var1.getStackInSlot(i); + if(stack != null) { + if(stack.getItem() instanceof ItemManaGun) + gun = stack; + else if(stack.getItem() instanceof ILens) + lens = stack; + } + } + + if(lens == null || gun == null) + return null; + + ItemStack gunCopy = gun.copy(); + ItemManaGun.setLens(gunCopy, lens); + + return gunCopy; + } + + + @Override + public int getRecipeSize() { + return 10; + } + + @Override + public ItemStack getRecipeOutput() { + return null; + } + } diff --git a/src/main/java/vazkii/botania/common/crafting/recipe/ManaGunRemoveLensRecipe.java b/src/main/java/vazkii/botania/common/crafting/recipe/ManaGunRemoveLensRecipe.java index 4d011ebed1..b926d525d1 100644 --- a/src/main/java/vazkii/botania/common/crafting/recipe/ManaGunRemoveLensRecipe.java +++ b/src/main/java/vazkii/botania/common/crafting/recipe/ManaGunRemoveLensRecipe.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Oct 6, 2014, 5:56:24 PM (GMT)] */ package vazkii.botania.common.crafting.recipe; @@ -18,45 +18,49 @@ public class ManaGunRemoveLensRecipe implements IRecipe { - @Override - public boolean matches(InventoryCrafting var1, World var2) { - boolean foundGun = false; - - for (int i = 0; i < var1.getSizeInventory(); i++) { - ItemStack stack = var1.getStackInSlot(i); - if (stack != null) { - if (stack.getItem() instanceof ItemManaGun && ItemManaGun.getLens(stack) != null) foundGun = true; - else return false; // Found an invalid item, breaking the recipe - } - } - - return foundGun; - } - - @Override - public ItemStack getCraftingResult(InventoryCrafting var1) { - ItemStack gun = null; - - for (int i = 0; i < var1.getSizeInventory(); i++) { - ItemStack stack = var1.getStackInSlot(i); - if (stack != null) { - if (stack.getItem() instanceof ItemManaGun) gun = stack; - } - } - - ItemStack gunCopy = gun.copy(); - ItemManaGun.setLens(gunCopy, null); - - return gunCopy; - } - - @Override - public int getRecipeSize() { - return 10; - } - - @Override - public ItemStack getRecipeOutput() { - return null; - } + @Override + public boolean matches(InventoryCrafting var1, World var2) { + boolean foundGun = false; + + for(int i = 0; i < var1.getSizeInventory(); i++) { + ItemStack stack = var1.getStackInSlot(i); + if(stack != null) { + if(stack.getItem() instanceof ItemManaGun && ItemManaGun.getLens(stack) != null) + foundGun = true; + + else return false; // Found an invalid item, breaking the recipe + } + } + + return foundGun; + } + + @Override + public ItemStack getCraftingResult(InventoryCrafting var1) { + ItemStack gun = null; + + for(int i = 0; i < var1.getSizeInventory(); i++) { + ItemStack stack = var1.getStackInSlot(i); + if(stack != null) { + if(stack.getItem() instanceof ItemManaGun) + gun = stack; + } + } + + ItemStack gunCopy = gun.copy(); + ItemManaGun.setLens(gunCopy, null); + + return gunCopy; + } + + @Override + public int getRecipeSize() { + return 10; + } + + @Override + public ItemStack getRecipeOutput() { + return null; + } + } diff --git a/src/main/java/vazkii/botania/common/crafting/recipe/PhantomInkRecipe.java b/src/main/java/vazkii/botania/common/crafting/recipe/PhantomInkRecipe.java index 2f4b740307..fd510dffeb 100644 --- a/src/main/java/vazkii/botania/common/crafting/recipe/PhantomInkRecipe.java +++ b/src/main/java/vazkii/botania/common/crafting/recipe/PhantomInkRecipe.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Mar 17, 2015, 5:21:07 PM (GMT)] */ package vazkii.botania.common.crafting.recipe; @@ -19,48 +19,51 @@ public class PhantomInkRecipe implements IRecipe { - @Override - public boolean matches(InventoryCrafting var1, World var2) { - boolean foundInk = false; - boolean foundItem = false; + @Override + public boolean matches(InventoryCrafting var1, World var2) { + boolean foundInk = false; + boolean foundItem = false; - for (int i = 0; i < var1.getSizeInventory(); i++) { - ItemStack stack = var1.getStackInSlot(i); - if (stack != null) { - if (stack.getItem() == ModItems.phantomInk && !foundInk) foundInk = true; - else if (!foundItem) { - if (stack.getItem() instanceof IPhantomInkable - && stack.getItem().getContainerItem(stack) == null) foundItem = true; - else return false; - } else return false; - } - } + for(int i = 0; i < var1.getSizeInventory(); i++) { + ItemStack stack = var1.getStackInSlot(i); + if(stack != null) { + if(stack.getItem() == ModItems.phantomInk && !foundInk) + foundInk = true; + else if(!foundItem) { + if(stack.getItem() instanceof IPhantomInkable && stack.getItem().getContainerItem(stack) == null) + foundItem = true; + else return false; + } else return false; + } + } - return foundInk && foundItem; - } + return foundInk && foundItem; + } - @Override - public ItemStack getCraftingResult(InventoryCrafting var1) { - ItemStack item = null; + @Override + public ItemStack getCraftingResult(InventoryCrafting var1) { + ItemStack item = null; - for (int i = 0; i < var1.getSizeInventory(); i++) { - ItemStack stack = var1.getStackInSlot(i); - if (stack != null && stack.getItem() instanceof IPhantomInkable && item == null) item = stack; - } + for(int i = 0; i < var1.getSizeInventory(); i++) { + ItemStack stack = var1.getStackInSlot(i); + if(stack != null && stack.getItem() instanceof IPhantomInkable && item == null) + item = stack; + } - IPhantomInkable inkable = (IPhantomInkable) item.getItem(); - ItemStack copy = item.copy(); - inkable.setPhantomInk(copy, !inkable.hasPhantomInk(item)); - return copy; - } + IPhantomInkable inkable = (IPhantomInkable) item.getItem(); + ItemStack copy = item.copy(); + inkable.setPhantomInk(copy, !inkable.hasPhantomInk(item)); + return copy; + } - @Override - public int getRecipeSize() { - return 10; - } + @Override + public int getRecipeSize() { + return 10; + } + + @Override + public ItemStack getRecipeOutput() { + return null; + } - @Override - public ItemStack getRecipeOutput() { - return null; - } } diff --git a/src/main/java/vazkii/botania/common/crafting/recipe/RegenIvyRecipe.java b/src/main/java/vazkii/botania/common/crafting/recipe/RegenIvyRecipe.java index 3925943000..3f763b36f7 100644 --- a/src/main/java/vazkii/botania/common/crafting/recipe/RegenIvyRecipe.java +++ b/src/main/java/vazkii/botania/common/crafting/recipe/RegenIvyRecipe.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Sep 3, 2014, 6:54:18 PM (GMT)] */ package vazkii.botania.common.crafting.recipe; @@ -21,57 +21,65 @@ public class RegenIvyRecipe implements IRecipe { - @Override - public boolean matches(InventoryCrafting var1, World var2) { - ItemStack tool = null; - boolean foundIvy = false; - int materialsFound = 0; - for (int i = 0; i < var1.getSizeInventory(); i++) { - ItemStack stack = var1.getStackInSlot(i); - if (stack != null) { - Item item = stack.getItem(); - if (item.isRepairable() - && !(ItemNBTHelper.detectNBT(stack) - && ItemNBTHelper.getBoolean(stack, ItemRegenIvy.TAG_REGEN, false))) tool = stack; - else if (item == ModItems.regenIvy) foundIvy = true; - } - } - for (int i = 0; i < var1.getSizeInventory(); i++) { - ItemStack stack = var1.getStackInSlot(i); - if (stack != null) { - Item item = stack.getItem(); + @Override + public boolean matches(InventoryCrafting var1, World var2) { + ItemStack tool = null; + boolean foundIvy = false; + int materialsFound = 0; + for(int i = 0; i < var1.getSizeInventory(); i++) { + ItemStack stack = var1.getStackInSlot(i); + if(stack != null) { + Item item = stack.getItem(); + if(item.isRepairable() && !(ItemNBTHelper.detectNBT(stack) && ItemNBTHelper.getBoolean(stack, ItemRegenIvy.TAG_REGEN, false))) + tool = stack; - if (tool != null && tool.getItem().getIsRepairable(tool, stack)) materialsFound++; - else if (stack != tool && item != ModItems.regenIvy) return false; - } - } + else if(item == ModItems.regenIvy) + foundIvy = true; - return tool != null && foundIvy && materialsFound == 3; - } + } + } + for(int i = 0; i < var1.getSizeInventory(); i++) { + ItemStack stack = var1.getStackInSlot(i); + if(stack != null) { + Item item = stack.getItem(); - @Override - public ItemStack getCraftingResult(InventoryCrafting var1) { - ItemStack tool = null; + if(tool != null && tool.getItem().getIsRepairable(tool, stack)) + materialsFound++; - for (int i = 0; i < var1.getSizeInventory(); i++) { - ItemStack stack = var1.getStackInSlot(i); - if (stack != null && stack.getItem().isDamageable()) tool = stack; - } + else if(stack != tool && item != ModItems.regenIvy) + return false; + } + } - if (tool == null) return null; + return tool != null && foundIvy && materialsFound == 3; + } - ItemStack toolCopy = tool.copy(); - ItemNBTHelper.setBoolean(toolCopy, ItemRegenIvy.TAG_REGEN, true); - return toolCopy; - } + @Override + public ItemStack getCraftingResult(InventoryCrafting var1) { + ItemStack tool = null; - @Override - public int getRecipeSize() { - return 10; - } + for(int i = 0; i < var1.getSizeInventory(); i++) { + ItemStack stack = var1.getStackInSlot(i); + if(stack != null && stack.getItem().isDamageable()) + tool = stack; + } + + if(tool == null) + return null; + + ItemStack toolCopy = tool.copy(); + ItemNBTHelper.setBoolean(toolCopy, ItemRegenIvy.TAG_REGEN, true); + return toolCopy; + } + + @Override + public int getRecipeSize() { + return 10; + } + + @Override + public ItemStack getRecipeOutput() { + return null; + } - @Override - public ItemStack getRecipeOutput() { - return null; - } } diff --git a/src/main/java/vazkii/botania/common/crafting/recipe/SpecialFloatingFlowerRecipe.java b/src/main/java/vazkii/botania/common/crafting/recipe/SpecialFloatingFlowerRecipe.java index 3bdcc3e8b9..2958c526cc 100644 --- a/src/main/java/vazkii/botania/common/crafting/recipe/SpecialFloatingFlowerRecipe.java +++ b/src/main/java/vazkii/botania/common/crafting/recipe/SpecialFloatingFlowerRecipe.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Nov 17, 2014, 6:34:36 PM (GMT)] */ package vazkii.botania.common.crafting.recipe; @@ -20,46 +20,51 @@ public class SpecialFloatingFlowerRecipe implements IRecipe { - @Override - public boolean matches(InventoryCrafting var1, World var2) { - boolean foundFloatingFlower = false; - boolean foundSpecialFlower = false; + @Override + public boolean matches(InventoryCrafting var1, World var2) { + boolean foundFloatingFlower = false; + boolean foundSpecialFlower = false; - for (int i = 0; i < var1.getSizeInventory(); i++) { - ItemStack stack = var1.getStackInSlot(i); - if (stack != null) { - if (stack.getItem() == Item.getItemFromBlock(ModBlocks.floatingFlower)) foundFloatingFlower = true; - else if (stack.getItem() == Item.getItemFromBlock(ModBlocks.specialFlower)) foundSpecialFlower = true; - else return false; // Found an invalid item, breaking the recipe - } - } + for(int i = 0; i < var1.getSizeInventory(); i++) { + ItemStack stack = var1.getStackInSlot(i); + if(stack != null) { + if(stack.getItem() == Item.getItemFromBlock(ModBlocks.floatingFlower)) + foundFloatingFlower = true; - return foundFloatingFlower && foundSpecialFlower; - } + else if(stack.getItem() == Item.getItemFromBlock(ModBlocks.specialFlower)) + foundSpecialFlower = true; - @Override - public ItemStack getCraftingResult(InventoryCrafting var1) { - ItemStack specialFlower = null; + else return false; // Found an invalid item, breaking the recipe + } + } - for (int i = 0; i < var1.getSizeInventory(); i++) { - ItemStack stack = var1.getStackInSlot(i); - if (stack != null && stack.getItem() == Item.getItemFromBlock(ModBlocks.specialFlower)) - specialFlower = stack; - } + return foundFloatingFlower && foundSpecialFlower; + } - if (specialFlower == null) return null; + @Override + public ItemStack getCraftingResult(InventoryCrafting var1) { + ItemStack specialFlower = null; - return ItemBlockSpecialFlower.ofType( - new ItemStack(ModBlocks.floatingSpecialFlower), ItemBlockSpecialFlower.getType(specialFlower)); - } + for(int i = 0; i < var1.getSizeInventory(); i++) { + ItemStack stack = var1.getStackInSlot(i); + if(stack != null && stack.getItem() == Item.getItemFromBlock(ModBlocks.specialFlower)) + specialFlower = stack; + } - @Override - public int getRecipeSize() { - return 10; - } + if(specialFlower == null) + return null; + + return ItemBlockSpecialFlower.ofType(new ItemStack(ModBlocks.floatingSpecialFlower), ItemBlockSpecialFlower.getType(specialFlower)); + } + + @Override + public int getRecipeSize() { + return 10; + } + + @Override + public ItemStack getRecipeOutput() { + return null; + } - @Override - public ItemStack getRecipeOutput() { - return null; - } } diff --git a/src/main/java/vazkii/botania/common/crafting/recipe/SpellClothRecipe.java b/src/main/java/vazkii/botania/common/crafting/recipe/SpellClothRecipe.java index c65fc16057..f0aeb8f23e 100644 --- a/src/main/java/vazkii/botania/common/crafting/recipe/SpellClothRecipe.java +++ b/src/main/java/vazkii/botania/common/crafting/recipe/SpellClothRecipe.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jan 25, 2015, 6:16:13 PM (GMT)] */ package vazkii.botania.common.crafting.recipe; @@ -19,50 +19,56 @@ public class SpellClothRecipe implements IRecipe { - @Override - public boolean matches(InventoryCrafting var1, World var2) { - boolean foundCloth = false; - boolean foundEnchanted = false; + @Override + public boolean matches(InventoryCrafting var1, World var2) { + boolean foundCloth = false; + boolean foundEnchanted = false; - for (int i = 0; i < var1.getSizeInventory(); i++) { - ItemStack stack = var1.getStackInSlot(i); - if (stack != null) { - if (stack.isItemEnchanted() && !foundEnchanted) foundEnchanted = true; - else if (stack.getItem() == ModItems.spellCloth && !foundCloth) foundCloth = true; - else return false; // Found an invalid item, breaking the recipe - } - } + for(int i = 0; i < var1.getSizeInventory(); i++) { + ItemStack stack = var1.getStackInSlot(i); + if(stack != null) { + if(stack.isItemEnchanted() && !foundEnchanted) + foundEnchanted = true; - return foundCloth && foundEnchanted; - } + else if(stack.getItem() == ModItems.spellCloth && !foundCloth) + foundCloth = true; - @Override - public ItemStack getCraftingResult(InventoryCrafting var1) { - ItemStack stackToDisenchant = null; - for (int i = 0; i < var1.getSizeInventory(); i++) { - ItemStack stack = var1.getStackInSlot(i); - if (stack != null && stack.isItemEnchanted()) { - stackToDisenchant = stack.copy(); - break; - } - } + else return false; // Found an invalid item, breaking the recipe + } + } - if (stackToDisenchant == null) return null; + return foundCloth && foundEnchanted; + } - NBTTagCompound cmp = (NBTTagCompound) stackToDisenchant.getTagCompound().copy(); - cmp.removeTag("ench"); // Remove enchantments - stackToDisenchant.setTagCompound(cmp); + @Override + public ItemStack getCraftingResult(InventoryCrafting var1) { + ItemStack stackToDisenchant = null; + for(int i = 0; i < var1.getSizeInventory(); i++) { + ItemStack stack = var1.getStackInSlot(i); + if(stack != null && stack.isItemEnchanted()) { + stackToDisenchant = stack.copy(); + break; + } + } - return stackToDisenchant; - } + if(stackToDisenchant == null) + return null; - @Override - public int getRecipeSize() { - return 10; - } + NBTTagCompound cmp = (NBTTagCompound) stackToDisenchant.getTagCompound().copy(); + cmp.removeTag("ench"); // Remove enchantments + stackToDisenchant.setTagCompound(cmp); + + return stackToDisenchant; + } + + @Override + public int getRecipeSize() { + return 10; + } + + @Override + public ItemStack getRecipeOutput() { + return null; + } - @Override - public ItemStack getRecipeOutput() { - return null; - } } diff --git a/src/main/java/vazkii/botania/common/crafting/recipe/TerraPickTippingRecipe.java b/src/main/java/vazkii/botania/common/crafting/recipe/TerraPickTippingRecipe.java index d13deb8454..733367684d 100644 --- a/src/main/java/vazkii/botania/common/crafting/recipe/TerraPickTippingRecipe.java +++ b/src/main/java/vazkii/botania/common/crafting/recipe/TerraPickTippingRecipe.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Aug 22, 2014, 7:45:56 PM (GMT)] */ package vazkii.botania.common.crafting.recipe; @@ -19,46 +19,53 @@ public class TerraPickTippingRecipe implements IRecipe { - @Override - public boolean matches(InventoryCrafting var1, World var2) { - boolean foundTerraPick = false; - boolean foundElementiumPick = false; + @Override + public boolean matches(InventoryCrafting var1, World var2) { + boolean foundTerraPick = false; + boolean foundElementiumPick = false; - for (int i = 0; i < var1.getSizeInventory(); i++) { - ItemStack stack = var1.getStackInSlot(i); - if (stack != null) { - if (stack.getItem() instanceof ItemTerraPick && !ItemTerraPick.isTipped(stack)) foundTerraPick = true; - else if (stack.getItem() == ModItems.elementiumPick) foundElementiumPick = true; - else return false; // Found an invalid item, breaking the recipe - } - } + for(int i = 0; i < var1.getSizeInventory(); i++) { + ItemStack stack = var1.getStackInSlot(i); + if(stack != null) { + if(stack.getItem() instanceof ItemTerraPick && !ItemTerraPick.isTipped(stack)) + foundTerraPick = true; - return foundTerraPick && foundElementiumPick; - } + else if(stack.getItem() == ModItems.elementiumPick) + foundElementiumPick = true; - @Override - public ItemStack getCraftingResult(InventoryCrafting var1) { - ItemStack terraPick = null; + else return false; // Found an invalid item, breaking the recipe + } + } - for (int i = 0; i < var1.getSizeInventory(); i++) { - ItemStack stack = var1.getStackInSlot(i); - if (stack != null && stack.getItem() instanceof ItemTerraPick) terraPick = stack; - } + return foundTerraPick && foundElementiumPick; + } - if (terraPick == null) return null; + @Override + public ItemStack getCraftingResult(InventoryCrafting var1) { + ItemStack terraPick = null; - ItemStack terraPickCopy = terraPick.copy(); - ItemTerraPick.setTipped(terraPickCopy); - return terraPickCopy; - } + for(int i = 0; i < var1.getSizeInventory(); i++) { + ItemStack stack = var1.getStackInSlot(i); + if(stack != null && stack.getItem() instanceof ItemTerraPick) + terraPick = stack; + } - @Override - public int getRecipeSize() { - return 10; - } + if(terraPick == null) + return null; + + ItemStack terraPickCopy = terraPick.copy(); + ItemTerraPick.setTipped(terraPickCopy); + return terraPickCopy; + } + + @Override + public int getRecipeSize() { + return 10; + } + + @Override + public ItemStack getRecipeOutput() { + return null; + } - @Override - public ItemStack getRecipeOutput() { - return null; - } } diff --git a/src/main/java/vazkii/botania/common/entity/EntityBabylonWeapon.java b/src/main/java/vazkii/botania/common/entity/EntityBabylonWeapon.java index 97f1c880a9..5dd088788b 100644 --- a/src/main/java/vazkii/botania/common/entity/EntityBabylonWeapon.java +++ b/src/main/java/vazkii/botania/common/entity/EntityBabylonWeapon.java @@ -2,15 +2,16 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Aug 16, 2015, 3:56:14 PM (GMT)] */ package vazkii.botania.common.entity; import java.util.List; + import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; @@ -27,203 +28,206 @@ public class EntityBabylonWeapon extends EntityThrowableCopy { - private static final String TAG_CHARGING = "charging"; - private static final String TAG_VARIETY = "variety"; - private static final String TAG_CHARGE_TICKS = "chargeTicks"; - private static final String TAG_LIVE_TICKS = "liveTicks"; - private static final String TAG_DELAY = "delay"; - private static final String TAG_ROTATION = "rotation"; - - public EntityBabylonWeapon(World world) { - super(world); - } - - public EntityBabylonWeapon(World world, EntityLivingBase thrower) { - super(world, thrower); - } - - @Override - protected void entityInit() { - setSize(0F, 0F); - - dataWatcher.addObject(20, (byte) 0); - dataWatcher.addObject(21, 0); - dataWatcher.addObject(22, 0); - dataWatcher.addObject(23, 0); - dataWatcher.addObject(24, 0); - dataWatcher.addObject(25, 0F); - - dataWatcher.setObjectWatched(20); - dataWatcher.setObjectWatched(21); - dataWatcher.setObjectWatched(22); - dataWatcher.setObjectWatched(23); - dataWatcher.setObjectWatched(24); - dataWatcher.setObjectWatched(25); - } - - @Override - public void onUpdate() { - EntityLivingBase thrower = getThrower(); - if (!worldObj.isRemote && (thrower == null || !(thrower instanceof EntityPlayer) || thrower.isDead)) { - setDead(); - return; - } - EntityPlayer player = (EntityPlayer) thrower; - boolean charging = isCharging(); - if (!worldObj.isRemote) { - ItemStack stack = player == null ? null : player.getCurrentEquippedItem(); - boolean newCharging = stack != null && stack.getItem() == ModItems.kingKey && ItemKingKey.isCharging(stack); - if (charging != newCharging) { - setCharging(newCharging); - charging = newCharging; - } - } - - double x = motionX; - double y = motionY; - double z = motionZ; - - int liveTime = getLiveTicks(); - int delay = getDelay(); - charging &= liveTime == 0; - - if (charging) { - motionX = 0; - motionY = 0; - motionZ = 0; - - int chargeTime = getChargeTicks(); - setChargeTicks(chargeTime + 1); - - if (worldObj.rand.nextInt(20) == 0) - worldObj.playSoundAtEntity(this, "botania:babylonSpawn", 0.1F, 1F + worldObj.rand.nextFloat() * 3F); - } else { - if (liveTime < delay) { - motionX = 0; - motionY = 0; - motionZ = 0; - } else if (liveTime == delay && player != null) { - Vector3 playerLook = null; - MovingObjectPosition lookat = ToolCommons.raytraceFromEntity(worldObj, player, true, 64); - if (lookat == null) - playerLook = new Vector3(player.getLookVec()).multiply(64).add(Vector3.fromEntity(player)); - else playerLook = new Vector3(lookat.blockX + 0.5, lookat.blockY + 0.5, lookat.blockZ + 0.5); - - Vector3 thisVec = Vector3.fromEntityCenter(this); - Vector3 motionVec = playerLook.sub(thisVec).normalize().multiply(2); - - x = motionVec.x; - y = motionVec.y; - z = motionVec.z; - worldObj.playSoundAtEntity(this, "botania:babylonAttack", 2F, 0.1F + worldObj.rand.nextFloat() * 3F); - } - setLiveTicks(liveTime + 1); - - if (!worldObj.isRemote) { - AxisAlignedBB axis = AxisAlignedBB.getBoundingBox( - posX, posY, posZ, lastTickPosX, lastTickPosY, lastTickPosZ) - .expand(2, 2, 2); - List entities = worldObj.getEntitiesWithinAABB(EntityLivingBase.class, axis); - for (EntityLivingBase living : entities) { - if (living == thrower) continue; - - if (living.hurtTime == 0) { - if (player != null) living.attackEntityFrom(DamageSource.causePlayerDamage(player), 20); - else living.attackEntityFrom(DamageSource.generic, 20); - onImpact(new MovingObjectPosition(living)); - return; - } - } - } - } - - super.onUpdate(); - - motionX = x; - motionY = y; - motionZ = z; - - if (liveTime > delay) Botania.proxy.wispFX(worldObj, posX, posY, posZ, 1F, 1F, 0F, 0.3F, 0F); - - if (liveTime > 200 + delay) setDead(); - } - - @Override - protected void onImpact(MovingObjectPosition pos) { - EntityLivingBase thrower = getThrower(); - if (pos.entityHit == null || pos.entityHit != thrower) { - worldObj.createExplosion(this, posX, posY, posZ, 3F, false); - setDead(); - } - } - - @Override - public void writeEntityToNBT(NBTTagCompound cmp) { - super.writeEntityToNBT(cmp); - cmp.setBoolean(TAG_CHARGING, isCharging()); - cmp.setInteger(TAG_VARIETY, getVariety()); - cmp.setInteger(TAG_CHARGE_TICKS, getChargeTicks()); - cmp.setInteger(TAG_LIVE_TICKS, getLiveTicks()); - cmp.setInteger(TAG_DELAY, getDelay()); - cmp.setFloat(TAG_ROTATION, getRotation()); - } - - @Override - public void readEntityFromNBT(NBTTagCompound cmp) { - super.readEntityFromNBT(cmp); - setCharging(cmp.getBoolean(TAG_CHARGING)); - setVariety(cmp.getInteger(TAG_VARIETY)); - setChargeTicks(cmp.getInteger(TAG_CHARGE_TICKS)); - setLiveTicks(cmp.getInteger(TAG_LIVE_TICKS)); - setDelay(cmp.getInteger(TAG_DELAY)); - setRotation(cmp.getFloat(TAG_ROTATION)); - } - - public boolean isCharging() { - return dataWatcher.getWatchableObjectByte(20) == 1; - } - - public void setCharging(boolean charging) { - dataWatcher.updateObject(20, (byte) (charging ? 1 : 0)); - } - - public int getVariety() { - return dataWatcher.getWatchableObjectInt(21); - } - - public void setVariety(int var) { - dataWatcher.updateObject(21, var); - } - - public int getChargeTicks() { - return dataWatcher.getWatchableObjectInt(22); - } - - public void setChargeTicks(int ticks) { - dataWatcher.updateObject(22, ticks); - } - - public int getLiveTicks() { - return dataWatcher.getWatchableObjectInt(23); - } - - public void setLiveTicks(int ticks) { - dataWatcher.updateObject(23, ticks); - } - - public int getDelay() { - return dataWatcher.getWatchableObjectInt(24); - } - - public void setDelay(int delay) { - dataWatcher.updateObject(24, delay); - } - - public float getRotation() { - return dataWatcher.getWatchableObjectFloat(25); - } - - public void setRotation(float rot) { - dataWatcher.updateObject(25, rot); - } + private static final String TAG_CHARGING = "charging"; + private static final String TAG_VARIETY = "variety"; + private static final String TAG_CHARGE_TICKS = "chargeTicks"; + private static final String TAG_LIVE_TICKS = "liveTicks"; + private static final String TAG_DELAY = "delay"; + private static final String TAG_ROTATION = "rotation"; + + public EntityBabylonWeapon(World world) { + super(world); + } + + public EntityBabylonWeapon(World world, EntityLivingBase thrower) { + super(world, thrower); + } + + @Override + protected void entityInit() { + setSize(0F, 0F); + + dataWatcher.addObject(20, (byte) 0); + dataWatcher.addObject(21, 0); + dataWatcher.addObject(22, 0); + dataWatcher.addObject(23, 0); + dataWatcher.addObject(24, 0); + dataWatcher.addObject(25, 0F); + + dataWatcher.setObjectWatched(20); + dataWatcher.setObjectWatched(21); + dataWatcher.setObjectWatched(22); + dataWatcher.setObjectWatched(23); + dataWatcher.setObjectWatched(24); + dataWatcher.setObjectWatched(25); + } + + @Override + public void onUpdate() { + EntityLivingBase thrower = getThrower(); + if(!worldObj.isRemote && (thrower == null || !(thrower instanceof EntityPlayer) || thrower.isDead)) { + setDead(); + return; + } + EntityPlayer player = (EntityPlayer) thrower; + boolean charging = isCharging(); + if(!worldObj.isRemote) { + ItemStack stack = player == null ? null : player.getCurrentEquippedItem(); + boolean newCharging = stack != null && stack.getItem() == ModItems.kingKey && ItemKingKey.isCharging(stack); + if(charging != newCharging) { + setCharging(newCharging); + charging = newCharging; + } + } + + double x = motionX; + double y = motionY; + double z = motionZ; + + int liveTime = getLiveTicks(); + int delay = getDelay(); + charging &= liveTime == 0; + + if(charging) { + motionX = 0; + motionY = 0; + motionZ = 0; + + int chargeTime = getChargeTicks(); + setChargeTicks(chargeTime + 1); + + if(worldObj.rand.nextInt(20) == 0) + worldObj.playSoundAtEntity(this, "botania:babylonSpawn", 0.1F, 1F + worldObj.rand.nextFloat() * 3F); + } else { + if(liveTime < delay) { + motionX = 0; + motionY = 0; + motionZ = 0; + } else if (liveTime == delay && player != null) { + Vector3 playerLook = null; + MovingObjectPosition lookat = ToolCommons.raytraceFromEntity(worldObj, player, true, 64); + if(lookat == null) + playerLook = new Vector3(player.getLookVec()).multiply(64).add(Vector3.fromEntity(player)); + else playerLook = new Vector3(lookat.blockX + 0.5, lookat.blockY + 0.5, lookat.blockZ + 0.5); + + Vector3 thisVec = Vector3.fromEntityCenter(this); + Vector3 motionVec = playerLook.sub(thisVec).normalize().multiply(2); + + x = motionVec.x; + y = motionVec.y; + z = motionVec.z; + worldObj.playSoundAtEntity(this, "botania:babylonAttack", 2F, 0.1F + worldObj.rand.nextFloat() * 3F); + } + setLiveTicks(liveTime + 1); + + if(!worldObj.isRemote) { + AxisAlignedBB axis = AxisAlignedBB.getBoundingBox(posX, posY, posZ, lastTickPosX, lastTickPosY, lastTickPosZ).expand(2, 2, 2); + List entities = worldObj.getEntitiesWithinAABB(EntityLivingBase.class, axis); + for(EntityLivingBase living : entities) { + if(living == thrower) + continue; + + if(living.hurtTime == 0) { + if(player != null) + living.attackEntityFrom(DamageSource.causePlayerDamage(player), 20); + else living.attackEntityFrom(DamageSource.generic, 20); + onImpact(new MovingObjectPosition(living)); + return; + } + } + } + } + + super.onUpdate(); + + motionX = x; + motionY = y; + motionZ = z; + + if(liveTime > delay) + Botania.proxy.wispFX(worldObj, posX, posY, posZ, 1F, 1F, 0F, 0.3F, 0F); + + if(liveTime > 200 + delay) + setDead(); + } + + @Override + protected void onImpact(MovingObjectPosition pos) { + EntityLivingBase thrower = getThrower(); + if(pos.entityHit == null || pos.entityHit != thrower) { + worldObj.createExplosion(this, posX, posY, posZ, 3F, false); + setDead(); + } + } + + @Override + public void writeEntityToNBT(NBTTagCompound cmp) { + super.writeEntityToNBT(cmp); + cmp.setBoolean(TAG_CHARGING, isCharging()); + cmp.setInteger(TAG_VARIETY, getVariety()); + cmp.setInteger(TAG_CHARGE_TICKS, getChargeTicks()); + cmp.setInteger(TAG_LIVE_TICKS, getLiveTicks()); + cmp.setInteger(TAG_DELAY, getDelay()); + cmp.setFloat(TAG_ROTATION, getRotation()); + } + + @Override + public void readEntityFromNBT(NBTTagCompound cmp) { + super.readEntityFromNBT(cmp); + setCharging(cmp.getBoolean(TAG_CHARGING)); + setVariety(cmp.getInteger(TAG_VARIETY)); + setChargeTicks(cmp.getInteger(TAG_CHARGE_TICKS)); + setLiveTicks(cmp.getInteger(TAG_LIVE_TICKS)); + setDelay(cmp.getInteger(TAG_DELAY)); + setRotation(cmp.getFloat(TAG_ROTATION)); + } + + public boolean isCharging() { + return dataWatcher.getWatchableObjectByte(20) == 1; + } + + public void setCharging(boolean charging) { + dataWatcher.updateObject(20, (byte) (charging ? 1 : 0)); + } + + public int getVariety() { + return dataWatcher.getWatchableObjectInt(21); + } + + public void setVariety(int var) { + dataWatcher.updateObject(21, var); + } + + public int getChargeTicks() { + return dataWatcher.getWatchableObjectInt(22); + } + + public void setChargeTicks(int ticks) { + dataWatcher.updateObject(22, ticks); + } + + public int getLiveTicks() { + return dataWatcher.getWatchableObjectInt(23); + } + + public void setLiveTicks(int ticks) { + dataWatcher.updateObject(23, ticks); + } + + public int getDelay() { + return dataWatcher.getWatchableObjectInt(24); + } + + public void setDelay(int delay) { + dataWatcher.updateObject(24, delay); + } + + public float getRotation() { + return dataWatcher.getWatchableObjectFloat(25); + } + + public void setRotation(float rot) { + dataWatcher.updateObject(25, rot); + } + } diff --git a/src/main/java/vazkii/botania/common/entity/EntityCorporeaSpark.java b/src/main/java/vazkii/botania/common/entity/EntityCorporeaSpark.java index 3c80075335..62f89441be 100644 --- a/src/main/java/vazkii/botania/common/entity/EntityCorporeaSpark.java +++ b/src/main/java/vazkii/botania/common/entity/EntityCorporeaSpark.java @@ -2,16 +2,17 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Feb 13, 2015, 10:52:40 PM (GMT)] */ package vazkii.botania.common.entity; import java.util.ArrayList; import java.util.List; + import net.minecraft.entity.Entity; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.init.Blocks; @@ -27,280 +28,285 @@ public class EntityCorporeaSpark extends Entity implements ICorporeaSpark { - private static final int SCAN_RANGE = 8; - - private static final String TAG_MASTER = "master"; - private static final String TAG_NETWORK = "network"; - private static final String TAG_INVIS = "invis"; - - ICorporeaSpark master; - List connections = new ArrayList(); - List connectionsClient = new ArrayList(); - List relatives = new ArrayList(); - boolean firstUpdateClient = true; - boolean firstUpdateServer = true; - - public EntityCorporeaSpark(World world) { - super(world); - isImmuneToFire = true; - } - - @Override - protected void entityInit() { - setSize(0.1F, 0.5F); - dataWatcher.addObject(EntitySpark.INVISIBILITY_DATA_WATCHER_KEY, 0); - dataWatcher.addObject(28, 0); - dataWatcher.addObject(29, 0); - dataWatcher.addObject(30, 0); - dataWatcher.addObject(31, new ItemStack(Blocks.stone, 0, 0)); - - dataWatcher.setObjectWatched(EntitySpark.INVISIBILITY_DATA_WATCHER_KEY); - dataWatcher.setObjectWatched(28); - dataWatcher.setObjectWatched(29); - dataWatcher.setObjectWatched(30); - dataWatcher.setObjectWatched(31); - } - - @Override - public boolean canBeCollidedWith() { - return true; - } - - @Override - public void onUpdate() { - super.onUpdate(); - IInventory inv = getInventory(); - if (inv == null) { - if (!worldObj.isRemote) setDead(); - return; - } - - if (isMaster()) master = this; - - if (worldObj.isRemote ? firstUpdateClient : firstUpdateServer) { - if (isMaster()) restartNetwork(); - else findNetwork(); - - if (worldObj.isRemote) firstUpdateClient = false; - else firstUpdateServer = false; - } - - if (master != null && (((Entity) master).isDead || master.getNetwork() != getNetwork())) master = null; - - int displayTicks = getItemDisplayTicks(); - if (displayTicks > 0) setItemDisplayTicks(displayTicks - 1); - else if (displayTicks < 0) setItemDisplayTicks(displayTicks + 1); - } - - @Override - public void setDead() { - super.setDead(); - if (!worldObj.isRemote) entityDropItem(new ItemStack(ModItems.corporeaSpark, 1, isMaster() ? 1 : 0), 0F); - connections.remove(this); - connectionsClient.remove(this); - restartNetwork(); - } - - @Override - public void registerConnections(ICorporeaSpark master, ICorporeaSpark referrer, List connections) { - List sparks = getNearbySparks(); - relatives.clear(); - for (ICorporeaSpark spark : sparks) { - if (spark == null - || connections.contains(spark) - || spark.getNetwork() != getNetwork() - || spark.isMaster() - || ((Entity) spark).isDead) continue; - - connections.add(spark); - relatives.add(spark); - spark.registerConnections(master, this, connections); - } - - this.master = master; - if (worldObj.isRemote) connectionsClient = connections; - else this.connections = connections; - } - - List getNearbySparks() { - return worldObj.getEntitiesWithinAABB( - ICorporeaSpark.class, - AxisAlignedBB.getBoundingBox( - posX - SCAN_RANGE, - posY - SCAN_RANGE, - posZ - SCAN_RANGE, - posX + SCAN_RANGE, - posY + SCAN_RANGE, - posZ + SCAN_RANGE)); - } - - void restartNetwork() { - if (worldObj.isRemote) connectionsClient = new ArrayList(); - else connections = new ArrayList(); - relatives = new ArrayList(); - - if (master != null) { - ICorporeaSpark oldMaster = master; - master = null; - - oldMaster.registerConnections(oldMaster, this, new ArrayList()); - } - } - - void findNetwork() { - List sparks = getNearbySparks(); - if (sparks.size() > 0) { - for (ICorporeaSpark spark : sparks) - if (spark.getNetwork() == getNetwork() && !((Entity) spark).isDead) { - ICorporeaSpark master = spark.getMaster(); - if (master != null) { - this.master = master; - restartNetwork(); - - break; - } - } - } - } - - void displayRelatives(ArrayList checked, ICorporeaSpark spark) { - if (spark == null) return; - - List sparks = spark.getRelatives(); - if (sparks.isEmpty()) EntitySpark.particleBeam((Entity) spark, (Entity) spark.getMaster()); - else - for (ICorporeaSpark endSpark : sparks) { - if (!checked.contains(endSpark)) { - EntitySpark.particleBeam((Entity) spark, (Entity) endSpark); - checked.add(endSpark); - displayRelatives(checked, endSpark); - } - } - } - - @Override - public IInventory getInventory() { - int x = MathHelper.floor_double(posX); - int y = MathHelper.floor_double(posY - 1); - int z = MathHelper.floor_double(posZ); - return InventoryHelper.getInventory(worldObj, x, y, z); - } - - @Override - public List getConnections() { - return worldObj.isRemote ? connectionsClient : connections; - } - - @Override - public List getRelatives() { - return relatives; - } - - @Override - public void onItemExtracted(ItemStack stack) { - setItemDisplayTicks(10); - setDisplayedItem(stack); - } - - @Override - public void onItemsRequested(List stacks) { - if (!stacks.isEmpty()) { - setItemDisplayTicks(-10); - setDisplayedItem(stacks.get(0)); - } - } - - @Override - public ICorporeaSpark getMaster() { - return master; - } - - public void setMaster(boolean master) { - dataWatcher.updateObject(28, master ? 1 : 0); - } - - @Override - public boolean isMaster() { - return dataWatcher.getWatchableObjectInt(28) == 1; - } - - public void setNetwork(int network) { - dataWatcher.updateObject(29, network); - } - - @Override - public int getNetwork() { - return dataWatcher.getWatchableObjectInt(29); - } - - public int getItemDisplayTicks() { - return dataWatcher.getWatchableObjectInt(30); - } - - public void setItemDisplayTicks(int ticks) { - dataWatcher.updateObject(30, ticks); - } - - public ItemStack getDisplayedItem() { - return dataWatcher.getWatchableObjectItemStack(31); - } - - public void setDisplayedItem(ItemStack stack) { - dataWatcher.updateObject(31, stack); - } - - @Override - public boolean interactFirst(EntityPlayer player) { - ItemStack stack = player.getCurrentEquippedItem(); - if (stack != null) { - if (stack.getItem() == ModItems.twigWand) { - if (player.isSneaking()) { - setDead(); - if (isMaster()) restartNetwork(); - if (player.worldObj.isRemote) player.swingItem(); - return true; - } else { - displayRelatives(new ArrayList(), master); - return true; - } - } else if (stack.getItem() == ModItems.dye) { - int color = stack.getItemDamage(); - if (color != getNetwork()) { - setNetwork(color); - - if (master != null) restartNetwork(); - else findNetwork(); - - stack.stackSize--; - if (player.worldObj.isRemote) player.swingItem(); - } - } - } - - return doPhantomInk(stack); - } - - public boolean doPhantomInk(ItemStack stack) { - if (stack != null && stack.getItem() == ModItems.phantomInk && !worldObj.isRemote) { - int invis = dataWatcher.getWatchableObjectInt(EntitySpark.INVISIBILITY_DATA_WATCHER_KEY); - dataWatcher.updateObject(EntitySpark.INVISIBILITY_DATA_WATCHER_KEY, ~invis & 1); - return true; - } - - return false; - } - - @Override - protected void readEntityFromNBT(NBTTagCompound cmp) { - setMaster(cmp.getBoolean(TAG_MASTER)); - setNetwork(cmp.getInteger(TAG_NETWORK)); - dataWatcher.updateObject(EntitySpark.INVISIBILITY_DATA_WATCHER_KEY, cmp.getInteger(TAG_INVIS)); - } - - @Override - protected void writeEntityToNBT(NBTTagCompound cmp) { - cmp.setBoolean(TAG_MASTER, isMaster()); - cmp.setInteger(TAG_NETWORK, getNetwork()); - cmp.setInteger(TAG_INVIS, dataWatcher.getWatchableObjectInt(EntitySpark.INVISIBILITY_DATA_WATCHER_KEY)); - } + private static final int SCAN_RANGE = 8; + + private static final String TAG_MASTER = "master"; + private static final String TAG_NETWORK = "network"; + private static final String TAG_INVIS = "invis"; + + ICorporeaSpark master; + List connections = new ArrayList(); + List connectionsClient = new ArrayList(); + List relatives = new ArrayList(); + boolean firstUpdateClient = true; + boolean firstUpdateServer = true; + + public EntityCorporeaSpark(World world) { + super(world); + isImmuneToFire = true; + } + + @Override + protected void entityInit() { + setSize(0.1F, 0.5F); + dataWatcher.addObject(EntitySpark.INVISIBILITY_DATA_WATCHER_KEY, 0); + dataWatcher.addObject(28, 0); + dataWatcher.addObject(29, 0); + dataWatcher.addObject(30, 0); + dataWatcher.addObject(31, new ItemStack(Blocks.stone, 0, 0)); + + dataWatcher.setObjectWatched(EntitySpark.INVISIBILITY_DATA_WATCHER_KEY); + dataWatcher.setObjectWatched(28); + dataWatcher.setObjectWatched(29); + dataWatcher.setObjectWatched(30); + dataWatcher.setObjectWatched(31); + } + + @Override + public boolean canBeCollidedWith() { + return true; + } + + @Override + public void onUpdate() { + super.onUpdate(); + IInventory inv = getInventory(); + if(inv == null) { + if(!worldObj.isRemote) + setDead(); + return; + } + + if(isMaster()) + master = this; + + if(worldObj.isRemote ? firstUpdateClient : firstUpdateServer) { + if(isMaster()) + restartNetwork(); + else findNetwork(); + + if(worldObj.isRemote) + firstUpdateClient = false; + else firstUpdateServer = false; + } + + if(master != null && (((Entity) master).isDead || master.getNetwork() != getNetwork())) + master = null; + + int displayTicks = getItemDisplayTicks(); + if(displayTicks > 0) + setItemDisplayTicks(displayTicks - 1); + else if(displayTicks < 0) + setItemDisplayTicks(displayTicks + 1); + } + + @Override + public void setDead() { + super.setDead(); + if(!worldObj.isRemote) + entityDropItem(new ItemStack(ModItems.corporeaSpark, 1, isMaster() ? 1 : 0), 0F); + connections.remove(this); + connectionsClient.remove(this); + restartNetwork(); + } + + @Override + public void registerConnections(ICorporeaSpark master, ICorporeaSpark referrer, List connections) { + List sparks = getNearbySparks(); + relatives.clear(); + for(ICorporeaSpark spark : sparks) { + if(spark == null || connections.contains(spark) || spark.getNetwork() != getNetwork() || spark.isMaster() || ((Entity) spark).isDead) + continue; + + connections.add(spark); + relatives.add(spark); + spark.registerConnections(master, this, connections); + } + + this.master = master; + if(worldObj.isRemote) + connectionsClient = connections; + else this.connections = connections; + } + + List getNearbySparks() { + return worldObj.getEntitiesWithinAABB(ICorporeaSpark.class, AxisAlignedBB.getBoundingBox(posX - SCAN_RANGE, posY - SCAN_RANGE, posZ - SCAN_RANGE, posX + SCAN_RANGE, posY + SCAN_RANGE, posZ + SCAN_RANGE)); + } + + void restartNetwork() { + if(worldObj.isRemote) + connectionsClient = new ArrayList(); + else connections = new ArrayList(); + relatives = new ArrayList(); + + if(master != null) { + ICorporeaSpark oldMaster = master; + master = null; + + oldMaster.registerConnections(oldMaster, this, new ArrayList()); + } + } + + void findNetwork() { + List sparks = getNearbySparks(); + if(sparks.size() > 0) { + for(ICorporeaSpark spark : sparks) + if(spark.getNetwork() == getNetwork() && !((Entity) spark).isDead) { + ICorporeaSpark master = spark.getMaster(); + if(master != null) { + this.master = master; + restartNetwork(); + + break; + } + } + } + } + + void displayRelatives(ArrayList checked, ICorporeaSpark spark) { + if(spark == null) + return; + + List sparks = spark.getRelatives(); + if(sparks.isEmpty()) + EntitySpark.particleBeam((Entity) spark, (Entity) spark.getMaster()); + else for(ICorporeaSpark endSpark : sparks) { + if(!checked.contains(endSpark)) { + EntitySpark.particleBeam((Entity) spark, (Entity) endSpark); + checked.add(endSpark); + displayRelatives(checked, endSpark); + } + } + } + + @Override + public IInventory getInventory() { + int x = MathHelper.floor_double(posX); + int y = MathHelper.floor_double(posY - 1); + int z = MathHelper.floor_double(posZ); + return InventoryHelper.getInventory(worldObj, x, y, z); + } + + @Override + public List getConnections() { + return worldObj.isRemote ? connectionsClient : connections; + } + + @Override + public List getRelatives() { + return relatives; + } + + @Override + public void onItemExtracted(ItemStack stack) { + setItemDisplayTicks(10); + setDisplayedItem(stack); + } + + @Override + public void onItemsRequested(List stacks) { + if(!stacks.isEmpty()) { + setItemDisplayTicks(-10); + setDisplayedItem(stacks.get(0)); + } + } + + @Override + public ICorporeaSpark getMaster() { + return master; + } + + public void setMaster(boolean master) { + dataWatcher.updateObject(28, master ? 1 : 0); + } + + @Override + public boolean isMaster() { + return dataWatcher.getWatchableObjectInt(28) == 1; + } + + public void setNetwork(int network) { + dataWatcher.updateObject(29, network); + } + + @Override + public int getNetwork() { + return dataWatcher.getWatchableObjectInt(29); + } + + public int getItemDisplayTicks() { + return dataWatcher.getWatchableObjectInt(30); + } + + public void setItemDisplayTicks(int ticks) { + dataWatcher.updateObject(30, ticks); + } + + public ItemStack getDisplayedItem() { + return dataWatcher.getWatchableObjectItemStack(31); + } + + public void setDisplayedItem(ItemStack stack) { + dataWatcher.updateObject(31, stack); + } + + @Override + public boolean interactFirst(EntityPlayer player) { + ItemStack stack = player.getCurrentEquippedItem(); + if(stack != null) { + if(stack.getItem() == ModItems.twigWand) { + if(player.isSneaking()) { + setDead(); + if(isMaster()) + restartNetwork(); + if(player.worldObj.isRemote) + player.swingItem(); + return true; + } else { + displayRelatives(new ArrayList(), master); + return true; + } + } else if(stack.getItem() == ModItems.dye) { + int color = stack.getItemDamage(); + if(color != getNetwork()) { + setNetwork(color); + + if(master != null) + restartNetwork(); + else findNetwork(); + + stack.stackSize--; + if(player.worldObj.isRemote) + player.swingItem(); + } + } + } + + return doPhantomInk(stack); + } + + public boolean doPhantomInk(ItemStack stack) { + if(stack != null && stack.getItem() == ModItems.phantomInk && !worldObj.isRemote) { + int invis = dataWatcher.getWatchableObjectInt(EntitySpark.INVISIBILITY_DATA_WATCHER_KEY); + dataWatcher.updateObject(EntitySpark.INVISIBILITY_DATA_WATCHER_KEY, ~invis & 1); + return true; + } + + return false; + } + + @Override + protected void readEntityFromNBT(NBTTagCompound cmp) { + setMaster(cmp.getBoolean(TAG_MASTER)); + setNetwork(cmp.getInteger(TAG_NETWORK)); + dataWatcher.updateObject(EntitySpark.INVISIBILITY_DATA_WATCHER_KEY, cmp.getInteger(TAG_INVIS)); + } + + @Override + protected void writeEntityToNBT(NBTTagCompound cmp) { + cmp.setBoolean(TAG_MASTER, isMaster()); + cmp.setInteger(TAG_NETWORK, getNetwork()); + cmp.setInteger(TAG_INVIS, dataWatcher.getWatchableObjectInt(EntitySpark.INVISIBILITY_DATA_WATCHER_KEY)); + } + } diff --git a/src/main/java/vazkii/botania/common/entity/EntityDoppleganger.java b/src/main/java/vazkii/botania/common/entity/EntityDoppleganger.java index 6eae7a0ca8..fcf87b3400 100644 --- a/src/main/java/vazkii/botania/common/entity/EntityDoppleganger.java +++ b/src/main/java/vazkii/botania/common/entity/EntityDoppleganger.java @@ -2,23 +2,21 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jul 12, 2014, 3:47:45 PM (GMT)] */ package vazkii.botania.common.entity; -import cpw.mods.fml.relauncher.ReflectionHelper; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; import java.awt.Rectangle; import java.util.ArrayList; import java.util.Arrays; import java.util.Collection; import java.util.List; import java.util.regex.Pattern; + import net.minecraft.block.Block; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.ScaledResolution; @@ -56,9 +54,11 @@ import net.minecraft.world.EnumDifficulty; import net.minecraft.world.World; import net.minecraftforge.common.util.FakePlayer; + import org.lwjgl.opengl.ARBShaderObjects; import org.lwjgl.opengl.GL11; import org.lwjgl.opengl.GL12; + import vazkii.botania.api.boss.IBotaniaBossWithShader; import vazkii.botania.api.internal.ShaderCallback; import vazkii.botania.api.lexicon.multiblock.Multiblock; @@ -74,958 +74,891 @@ import vazkii.botania.common.item.ModItems; import vazkii.botania.common.item.relic.ItemRelic; import vazkii.botania.common.lib.LibObfuscation; +import cpw.mods.fml.relauncher.ReflectionHelper; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; public class EntityDoppleganger extends EntityCreature implements IBotaniaBossWithShader { - public static final int SPAWN_TICKS = 160; - private static final float RANGE = 12F; - private static final float MAX_HP = 800F; - - public static final int MOB_SPAWN_START_TICKS = 20; - public static final int MOB_SPAWN_END_TICKS = 80; - public static final int MOB_SPAWN_BASE_TICKS = 800; - public static final int MOB_SPAWN_TICKS = MOB_SPAWN_BASE_TICKS + MOB_SPAWN_START_TICKS + MOB_SPAWN_END_TICKS; - public static final int MOB_SPAWN_WAVES = 10; - public static final int MOB_SPAWN_WAVE_TIME = MOB_SPAWN_BASE_TICKS / MOB_SPAWN_WAVES; - - private static final String TAG_INVUL_TIME = "invulTime"; - private static final String TAG_AGGRO = "aggro"; - private static final String TAG_SOURCE_X = "sourceX"; - private static final String TAG_SOURCE_Y = "sourceY"; - private static final String TAG_SOURCE_Z = "sourcesZ"; - private static final String TAG_MOB_SPAWN_TICKS = "mobSpawnTicks"; - private static final String TAG_HARD_MODE = "hardMode"; - private static final String TAG_PLAYER_COUNT = "playerCount"; - - private static final int[][] PYLON_LOCATIONS = new int[][] { - {4, 1, 4}, - {4, 1, -4}, - {-4, 1, 4}, - {-4, 1, -4} - }; - - private static final List CHEATY_BLOCKS = - Arrays.asList(new String[] {"OpenBlocks:beartrap", "ThaumicTinkerer:magnet"}); - - boolean spawnLandmines = false; - boolean spawnPixies = false; - boolean anyWithArmor = false; - - List playersWhoAttacked = new ArrayList(); - - private static boolean isPlayingMusic = false; - - public EntityDoppleganger(World par1World) { - super(par1World); - setSize(0.6F, 1.8F); - getNavigator().setCanSwim(true); - tasks.addTask(0, new EntityAISwimming(this)); - tasks.addTask(1, new EntityAIWatchClosest(this, EntityPlayer.class, Float.MAX_VALUE)); - isImmuneToFire = true; - experienceValue = 825; - } - - public static MultiblockSet makeMultiblockSet() { - Multiblock mb = new Multiblock(); - - for (int[] p : PYLON_LOCATIONS) mb.addComponent(p[0], p[1] + 1, p[2], ModBlocks.pylon, 2); - - for (int i = 0; i < 3; i++) - for (int j = 0; j < 3; j++) mb.addComponent(new BeaconComponent(new ChunkCoordinates(i - 1, 0, j - 1))); - - mb.addComponent(new BeaconBeamComponent(new ChunkCoordinates(0, 1, 0))); - mb.setRenderOffset(0, -1, 0); - - return mb.makeSet(); - } - - public static boolean spawn( - EntityPlayer player, ItemStack par1ItemStack, World par3World, int par4, int par5, int par6, boolean hard) { - if (par3World.getTileEntity(par4, par5, par6) instanceof TileEntityBeacon && isTruePlayer(player)) { - if (par3World.difficultySetting == EnumDifficulty.PEACEFUL) { - if (!par3World.isRemote) - player.addChatMessage(new ChatComponentTranslation("botaniamisc.peacefulNoob") - .setChatStyle(new ChatStyle().setColor(EnumChatFormatting.RED))); - return false; - } - - for (int[] coords : PYLON_LOCATIONS) { - int x = par4 + coords[0]; - int y = par5 + coords[1]; - int z = par6 + coords[2]; - - Block blockat = par3World.getBlock(x, y, z); - int meta = par3World.getBlockMetadata(x, y, z); - if (blockat != ModBlocks.pylon || meta != 2) { - if (!par3World.isRemote) - player.addChatMessage(new ChatComponentTranslation("botaniamisc.needsCatalysts") - .setChatStyle(new ChatStyle().setColor(EnumChatFormatting.RED))); - return false; - } - } - - if (!hasProperArena(par3World, par4, par5, par6)) { - for (int i = 0; i < 360; i += 8) { - float r = 1F; - float g = 0F; - float b = 1F; - float rad = i * (float) Math.PI / 180F; - double x = par4 + 0.5 - Math.cos(rad) * RANGE; - double y = par5 + 0.5; - double z = par6 + 0.5 - Math.sin(rad) * RANGE; - - Botania.proxy.sparkleFX(par3World, x, y, z, r, g, b, 5F, 120); - } - - if (!par3World.isRemote) - player.addChatMessage(new ChatComponentTranslation("botaniamisc.badArena") - .setChatStyle(new ChatStyle().setColor(EnumChatFormatting.RED))); - return false; - } - - par1ItemStack.stackSize--; - - if (par3World.isRemote) return true; - - EntityDoppleganger e = new EntityDoppleganger(par3World); - e.setPosition(par4 + 0.5, par5 + 3, par6 + 0.5); - e.setInvulTime(SPAWN_TICKS); - e.setHealth(1F); - e.setSource(par4, par5, par6); - e.setMobSpawnTicks(MOB_SPAWN_TICKS); - e.setHardMode(hard); - - List players = e.getPlayersAround(); - int playerCount = 0; - for (EntityPlayer p : players) if (isTruePlayer(p)) playerCount++; - - e.setPlayerCount(playerCount); - e.getAttributeMap() - .getAttributeInstance(SharedMonsterAttributes.maxHealth) - .setBaseValue(MAX_HP * playerCount); - - par3World.playSoundAtEntity(e, "mob.enderdragon.growl", 10F, 0.1F); - par3World.spawnEntityInWorld(e); - return true; - } - - return false; - } - - private static boolean hasProperArena(World world, int sx, int sy, int sz) { - int heightCheck = 3; - int heightMin = 2; - int range = (int) Math.ceil(RANGE); - for (int i = -range; i < range + 1; i++) - for (int j = -range; j < range + 1; j++) { - if (Math.abs(i) == 4 && Math.abs(j) == 4 - || vazkii.botania.common.core.helper.MathHelper.pointDistancePlane(i, j, 0, 0) > RANGE) - continue; // Ignore pylons and out of circle - - int x = sx + i; - int z = sz + j; - int air = 0; - - yCheck: - { - for (int k = heightCheck + heightMin + 1; k >= -heightCheck; k--) { - int y = sy + k; - boolean isAir = world.getBlock(x, y, z).getCollisionBoundingBoxFromPool(world, x, y, z) == null; - if (isAir) air++; - else { - if (k > heightCheck) continue; - else if (air > 2) break yCheck; - air = 0; - } - } - - return false; - } - } - - return true; - } - - @Override - protected boolean isAIEnabled() { - return true; - } - - @Override - protected void entityInit() { - super.entityInit(); - dataWatcher.addObject(20, 0); // Invul Time - dataWatcher.addObject(21, (byte) 0); // Aggro - dataWatcher.addObject(22, 0); // TP Delay - dataWatcher.addObject(23, 0); // Source X - dataWatcher.addObject(24, 0); // Source Y - dataWatcher.addObject(25, 0); // Source Z - dataWatcher.addObject(26, 0); // Ticks spawning mobs - dataWatcher.addObject(27, (byte) 0); // Hard Mode - dataWatcher.addObject(28, 0); // Player count - } - - public int getInvulTime() { - return dataWatcher.getWatchableObjectInt(20); - } - - public boolean isAggored() { - return dataWatcher.getWatchableObjectByte(21) == 1; - } - - public int getTPDelay() { - return dataWatcher.getWatchableObjectInt(22); - } - - public ChunkCoordinates getSource() { - int x = dataWatcher.getWatchableObjectInt(23); - int y = dataWatcher.getWatchableObjectInt(24); - int z = dataWatcher.getWatchableObjectInt(25); - return new ChunkCoordinates(x, y, z); - } - - public int getMobSpawnTicks() { - return dataWatcher.getWatchableObjectInt(26); - } - - public boolean isHardMode() { - return dataWatcher.getWatchableObjectByte(27) == 1; - } - - public int getPlayerCount() { - return dataWatcher.getWatchableObjectInt(28); - } - - public void setInvulTime(int time) { - dataWatcher.updateObject(20, time); - } - - public void setAggroed(boolean aggored) { - dataWatcher.updateObject(21, (byte) (aggored ? 1 : 0)); - } - - public void setTPDelay(int delay) { - dataWatcher.updateObject(22, delay); - } - - public void setSource(int x, int y, int z) { - dataWatcher.updateObject(23, x); - dataWatcher.updateObject(24, y); - dataWatcher.updateObject(25, z); - } - - public void setMobSpawnTicks(int ticks) { - dataWatcher.updateObject(26, ticks); - } - - public void setHardMode(boolean hardMode) { - dataWatcher.updateObject(27, (byte) (hardMode ? 1 : 0)); - } - - public void setPlayerCount(int count) { - dataWatcher.updateObject(28, count); - } - - @Override - public void writeEntityToNBT(NBTTagCompound par1nbtTagCompound) { - super.writeEntityToNBT(par1nbtTagCompound); - par1nbtTagCompound.setInteger(TAG_INVUL_TIME, getInvulTime()); - par1nbtTagCompound.setBoolean(TAG_AGGRO, isAggored()); - par1nbtTagCompound.setInteger(TAG_MOB_SPAWN_TICKS, getMobSpawnTicks()); - - ChunkCoordinates source = getSource(); - par1nbtTagCompound.setInteger(TAG_SOURCE_X, source.posX); - par1nbtTagCompound.setInteger(TAG_SOURCE_Y, source.posY); - par1nbtTagCompound.setInteger(TAG_SOURCE_Z, source.posZ); - - par1nbtTagCompound.setBoolean(TAG_HARD_MODE, isHardMode()); - par1nbtTagCompound.setInteger(TAG_PLAYER_COUNT, getPlayerCount()); - } - - @Override - public void readEntityFromNBT(NBTTagCompound par1nbtTagCompound) { - super.readEntityFromNBT(par1nbtTagCompound); - setInvulTime(par1nbtTagCompound.getInteger(TAG_INVUL_TIME)); - setAggroed(par1nbtTagCompound.getBoolean(TAG_AGGRO)); - setMobSpawnTicks(par1nbtTagCompound.getInteger(TAG_MOB_SPAWN_TICKS)); - - int x = par1nbtTagCompound.getInteger(TAG_SOURCE_X); - int y = par1nbtTagCompound.getInteger(TAG_SOURCE_Y); - int z = par1nbtTagCompound.getInteger(TAG_SOURCE_Z); - setSource(x, y, z); - - setHardMode(par1nbtTagCompound.getBoolean(TAG_HARD_MODE)); - if (par1nbtTagCompound.hasKey(TAG_PLAYER_COUNT)) - setPlayerCount(par1nbtTagCompound.getInteger(TAG_PLAYER_COUNT)); - else setPlayerCount(1); - } - - @Override - public boolean attackEntityFrom(DamageSource par1DamageSource, float par2) { - Entity e = par1DamageSource.getEntity(); - if ((par1DamageSource.damageType.equals("player") || e instanceof EntityPixie) - && e != null - && isTruePlayer(e) - && getInvulTime() == 0) { - EntityPlayer player = (EntityPlayer) e; - if (!playersWhoAttacked.contains(player.getCommandSenderName())) - playersWhoAttacked.add(player.getCommandSenderName()); - - float dmg = par2; - boolean crit = false; - if (e instanceof EntityPlayer) { - EntityPlayer p = (EntityPlayer) e; - crit = p.fallDistance > 0.0F - && !p.onGround - && !p.isOnLadder() - && !p.isInWater() - && !p.isPotionActive(Potion.blindness) - && p.ridingEntity == null; - } - - int cap = crit ? 60 : 40; - return super.attackEntityFrom(par1DamageSource, Math.min(cap, dmg) * (isHardMode() ? 0.6F : 1F)); - } - return false; - } - - private static final Pattern FAKE_PLAYER_PATTERN = Pattern.compile("^(?:\\[.*\\])|(?:ComputerCraft)$"); - - public static boolean isTruePlayer(Entity e) { - if (!(e instanceof EntityPlayer)) return false; - - EntityPlayer player = (EntityPlayer) e; - - String name = player.getCommandSenderName(); - return !(player instanceof FakePlayer - || FAKE_PLAYER_PATTERN.matcher(name).matches()); - } - - @Override - protected void damageEntity(DamageSource par1DamageSource, float par2) { - super.damageEntity(par1DamageSource, par2); - - Entity attacker = par1DamageSource.getEntity(); - if (attacker != null) { - Vector3 thisVector = Vector3.fromEntityCenter(this); - Vector3 playerVector = Vector3.fromEntityCenter(attacker); - Vector3 motionVector = - thisVector.copy().sub(playerVector).copy().normalize().multiply(0.75); - - if (getHealth() > 0) { - motionX = -motionVector.x; - motionY = 0.5; - motionZ = -motionVector.z; - setTPDelay(4); - spawnPixies = isAggored(); - } - - setAggroed(true); - } - } - - @Override - public void onDeath(DamageSource p_70645_1_) { - super.onDeath(p_70645_1_); - EntityLivingBase entitylivingbase = func_94060_bK(); - if (entitylivingbase instanceof EntityPlayer) { - ((EntityPlayer) entitylivingbase).addStat(ModAchievements.gaiaGuardianKill, 1); - if (!anyWithArmor) ((EntityPlayer) entitylivingbase).addStat(ModAchievements.gaiaGuardianNoArmor, 1); - } - - worldObj.playSoundAtEntity( - this, - "random.explode", - 20F, - (1F + (worldObj.rand.nextFloat() - worldObj.rand.nextFloat()) * 0.2F) * 0.7F); - worldObj.spawnParticle("hugeexplosion", posX, posY, posZ, 1D, 0D, 0D); - } - - @Override - protected void applyEntityAttributes() { - super.applyEntityAttributes(); - getEntityAttribute(SharedMonsterAttributes.movementSpeed).setBaseValue(0.4); - getEntityAttribute(SharedMonsterAttributes.maxHealth).setBaseValue(MAX_HP); - getEntityAttribute(SharedMonsterAttributes.knockbackResistance).setBaseValue(1.0); - } - - @Override - protected boolean canDespawn() { - return false; - } - - @Override - protected void dropFewItems(boolean par1, int par2) { - if (par1) { - for (int pl = 0; pl < playersWhoAttacked.size(); pl++) { - boolean hard = isHardMode(); - entityDropItem(new ItemStack(ModItems.manaResource, pl == 0 ? hard ? 16 : 8 : hard ? 10 : 6, 5), 1F); - boolean droppedRecord = false; - - if (hard) { - entityDropItem(new ItemStack(ModItems.ancientWill, 1, rand.nextInt(6)), 1F); - if (ConfigHandler.relicsEnabled) { - ItemStack dice = new ItemStack(ModItems.dice); - ItemRelic.bindToUsernameS(playersWhoAttacked.get(pl), dice); - entityDropItem(dice, 1F); - } - - if (Math.random() < 0.25) - entityDropItem(new ItemStack(ModItems.overgrowthSeed, rand.nextInt(3) + 1), 1F); - if (Math.random() < 0.5) { - boolean voidLotus = Math.random() < 0.3F; - entityDropItem( - new ItemStack( - ModItems.blackLotus, voidLotus ? 1 : rand.nextInt(3) + 1, voidLotus ? 1 : 0), - 1F); - } - if (Math.random() < 0.9) - entityDropItem(new ItemStack(ModItems.manaResource, 16 + rand.nextInt(12)), 1F); - if (Math.random() < 0.7) - entityDropItem(new ItemStack(ModItems.manaResource, 8 + rand.nextInt(6), 1), 1F); - if (Math.random() < 0.5) - entityDropItem(new ItemStack(ModItems.manaResource, 4 + rand.nextInt(3), 2), 1F); - - int runes = rand.nextInt(6) + 1; - for (int i = 0; i < runes; i++) - if (Math.random() < 0.3) - entityDropItem(new ItemStack(ModItems.rune, 2 + rand.nextInt(3), rand.nextInt(16)), 1F); - - if (Math.random() < 0.2) entityDropItem(new ItemStack(ModItems.pinkinator), 1F); - if (Math.random() < 0.3) { - int i = Item.getIdFromItem(Items.record_13); - int j = Item.getIdFromItem(Items.record_wait); - int k = i + rand.nextInt(j - i + 1); - entityDropItem(new ItemStack(Item.getItemById(k)), 1F); - droppedRecord = true; - } - } - - if (!droppedRecord && Math.random() < 0.2) - entityDropItem(new ItemStack(hard ? ModItems.recordGaia2 : ModItems.recordGaia1), 1F); - } - } - } - - @Override - public void setDead() { - ChunkCoordinates source = getSource(); - Botania.proxy.playRecordClientSided(worldObj, source.posX, source.posY, source.posZ, null); - isPlayingMusic = false; - super.setDead(); - } - - public List getPlayersAround() { - ChunkCoordinates source = getSource(); - float range = 15F; - List players = worldObj.getEntitiesWithinAABB( - EntityPlayer.class, - AxisAlignedBB.getBoundingBox( - source.posX + 0.5 - range, - source.posY + 0.5 - range, - source.posZ + 0.5 - range, - source.posX + 0.5 + range, - source.posY + 0.5 + range, - source.posZ + 0.5 + range)); - return players; - } - - @Override - public void onLivingUpdate() { - super.onLivingUpdate(); - - if (ridingEntity != null) { - if (ridingEntity.riddenByEntity != null) ridingEntity.riddenByEntity = null; - ridingEntity = null; - } - - boolean peaceful = worldObj.difficultySetting == EnumDifficulty.PEACEFUL; - if (!worldObj.isRemote && peaceful) setDead(); - - if (!worldObj.isRemote) { - int radius = 1; - int posXInt = MathHelper.floor_double(posX); - int posYInt = MathHelper.floor_double(posY); - int posZInt = MathHelper.floor_double(posZ); - for (int i = -radius; i < radius + 1; i++) - for (int j = -radius; j < radius + 1; j++) - for (int k = -radius; k < radius + 1; k++) { - int xp = posXInt + i; - int yp = posYInt + j; - int zp = posZInt + k; - if (isCheatyBlock(worldObj, xp, yp, zp)) { - Block block = worldObj.getBlock(xp, yp, zp); - List items = block.getDrops(worldObj, xp, yp, zp, 0, 0); - for (ItemStack stack : items) { - if (ConfigHandler.blockBreakParticles) - worldObj.playAuxSFX( - 2001, - xp, - yp, - zp, - Block.getIdFromBlock(block) - + (worldObj.getBlockMetadata(xp, yp, zp) << 12)); - worldObj.spawnEntityInWorld( - new EntityItem(worldObj, xp + 0.5, yp + 0.5, zp + 0.5, stack)); - } - worldObj.setBlockToAir(xp, yp, zp); - } - } - } - - ChunkCoordinates source = getSource(); - boolean hard = isHardMode(); - float range = RANGE + 3F; - List players = getPlayersAround(); - int playerCount = getPlayerCount(); - - if (worldObj.isRemote && !isPlayingMusic && !isDead && !players.isEmpty()) { - Botania.proxy.playRecordClientSided(worldObj, source.posX, source.posY, source.posZ, (ItemRecord) - (hard ? ModItems.recordGaia2 : ModItems.recordGaia1)); - isPlayingMusic = true; - } - - range = RANGE; - for (int i = 0; i < 360; i += 8) { - float r = 0.6F; - float g = 0F; - float b = 0.2F; - float m = 0.15F; - float mv = 0.35F; - - float rad = i * (float) Math.PI / 180F; - double x = source.posX + 0.5 - Math.cos(rad) * range; - double y = source.posY + 0.5; - double z = source.posZ + 0.5 - Math.sin(rad) * range; - - Botania.proxy.wispFX( - worldObj, - x, - y, - z, - r, - g, - b, - 0.5F, - (float) (Math.random() - 0.5F) * m, - (float) (Math.random() - 0.5F) * mv, - (float) (Math.random() - 0.5F) * m); - } - - if (players.isEmpty() && !worldObj.playerEntities.isEmpty()) setDead(); - else { - for (EntityPlayer player : players) { - if (player.inventory.armorInventory[0] != null - || player.inventory.armorInventory[1] != null - || player.inventory.armorInventory[2] != null - || player.inventory.armorInventory[3] != null) anyWithArmor = true; - - List remove = new ArrayList(); - Collection active = player.getActivePotionEffects(); - for (PotionEffect effect : active) - if (effect.getDuration() < 200 - && effect.getIsAmbient() - && !ReflectionHelper.getPrivateValue( - Potion.class, - Potion.potionTypes[effect.getPotionID()], - LibObfuscation.IS_BAD_EFFECT)) remove.add(effect); - - active.removeAll(remove); - - player.capabilities.isFlying = player.capabilities.isFlying && player.capabilities.isCreativeMode; - - if (vazkii.botania.common.core.helper.MathHelper.pointDistanceSpace( - player.posX, - player.posY, - player.posZ, - source.posX + 0.5, - source.posY + 0.5, - source.posZ + 0.5) - >= range) { - Vector3 sourceVector = new Vector3(source.posX + 0.5, source.posY + 0.5, source.posZ + 0.5); - Vector3 playerVector = Vector3.fromEntityCenter(player); - Vector3 motion = - sourceVector.copy().sub(playerVector).copy().normalize(); - - player.motionX = motion.x; - player.motionY = 0.2; - player.motionZ = motion.z; - } - } - } - - if (isDead) return; - - int invul = getInvulTime(); - int mobTicks = getMobSpawnTicks(); - boolean spawnMissiles = hard && ticksExisted % 15 < 4; - - if (invul > 10) { - Vector3 pos = Vector3.fromEntityCenter(this).subtract(new Vector3(0, 0.2, 0)); - for (int i = 0; i < PYLON_LOCATIONS.length; i++) { - int[] arr = PYLON_LOCATIONS[i]; - int x = arr[0]; - int y = arr[1]; - int z = arr[2]; - - Vector3 pylonPos = new Vector3(source.posX + x, source.posY + y, source.posZ + z); - double worldTime = ticksExisted; - worldTime /= 5; - - float rad = 0.75F + (float) Math.random() * 0.05F; - double xp = pylonPos.x + 0.5 + Math.cos(worldTime) * rad; - double zp = pylonPos.z + 0.5 + Math.sin(worldTime) * rad; - - Vector3 partPos = new Vector3(xp, pylonPos.y, zp); - Vector3 mot = pos.copy().sub(partPos).multiply(0.04); - - float r = 0.7F + (float) Math.random() * 0.3F; - float g = (float) Math.random() * 0.3F; - float b = 0.7F + (float) Math.random() * 0.3F; - - Botania.proxy.wispFX( - worldObj, - partPos.x, - partPos.y, - partPos.z, - r, - g, - b, - 0.25F + (float) Math.random() * 0.1F, - -0.075F - (float) Math.random() * 0.015F); - Botania.proxy.wispFX( - worldObj, partPos.x, partPos.y, partPos.z, r, g, b, 0.4F, (float) mot.x, (float) mot.y, (float) - mot.z); - } - } - - if (invul > 0 && mobTicks == MOB_SPAWN_TICKS) { - if (invul < SPAWN_TICKS) { - if (invul > SPAWN_TICKS / 2 && worldObj.rand.nextInt(SPAWN_TICKS - invul + 1) == 0) - for (int i = 0; i < 2; i++) spawnExplosionParticle(); - } - - if (!worldObj.isRemote) { - setHealth(getHealth() + (getMaxHealth() - 1F) / SPAWN_TICKS); - setInvulTime(invul - 1); - } - motionY = 0; - } else { - if (isAggored()) { - boolean dying = getHealth() / getMaxHealth() < 0.2; - if (dying && mobTicks > 0) { - motionX = 0; - motionY = 0; - motionZ = 0; - - int reverseTicks = MOB_SPAWN_TICKS - mobTicks; - if (reverseTicks < MOB_SPAWN_START_TICKS) { - motionY = 0.2; - setInvulTime(invul + 1); - } - - if (reverseTicks > MOB_SPAWN_START_TICKS * 2 - && mobTicks > MOB_SPAWN_END_TICKS - && mobTicks % MOB_SPAWN_WAVE_TIME == 0 - && !worldObj.isRemote) { - for (int pl = 0; pl < playerCount; pl++) - for (int i = 0; i < 3 + worldObj.rand.nextInt(2); i++) { - EntityLiving entity = null; - switch (worldObj.rand.nextInt(2)) { - case 0: { - entity = new EntityZombie(worldObj); - if (worldObj.rand.nextInt(hard ? 3 : 12) == 0) - entity = new EntityWitch(worldObj); - - break; - } - case 1: { - entity = new EntitySkeleton(worldObj); - ((EntitySkeleton) entity).setCurrentItemOrArmor(0, new ItemStack(Items.bow)); - if (worldObj.rand.nextInt(8) == 0) { - ((EntitySkeleton) entity).setSkeletonType(1); - ((EntitySkeleton) entity) - .setCurrentItemOrArmor( - 0, - new ItemStack( - hard - ? ModItems.elementiumSword - : Items.stone_sword)); - } - break; - } - case 3: { - if (!players.isEmpty()) - for (int j = 0; j < 1 + worldObj.rand.nextInt(hard ? 8 : 5); j++) { - EntityPixie pixie = new EntityPixie(worldObj); - pixie.setProps(players.get(rand.nextInt(players.size())), this, 1, 8); - pixie.setPosition(posX + width / 2, posY + 2, posZ + width / 2); - worldObj.spawnEntityInWorld(pixie); - } - } - } - - if (entity != null) { - range = 6F; - entity.setPosition( - posX + 0.5 + Math.random() * range - range / 2, - posY - 1, - posZ + 0.5 + Math.random() * range - range / 2); - worldObj.spawnEntityInWorld(entity); - } - } - - if (hard && ticksExisted % 3 < 2) { - for (int i = 0; i < playerCount; i++) spawnMissile(); - spawnMissiles = false; - } - } - - setMobSpawnTicks(mobTicks - 1); - setTPDelay(10); - } else if (getTPDelay() > 0 && !worldObj.isRemote) { - if (invul > 0) setInvulTime(invul - 1); - - setTPDelay(getTPDelay() - 1); - if (getTPDelay() == 0 && getHealth() > 0) { - int tries = 0; - while (!teleportRandomly() && tries < 50) tries++; - if (tries >= 50) teleportTo(source.posX + 0.5, source.posY + 1.6, source.posZ + 0.5); - - if (spawnLandmines) { - int count = dying && hard ? 7 : 6; - for (int i = 0; i < count; i++) { - int x = source.posX - 10 + rand.nextInt(20); - int z = source.posZ - 10 + rand.nextInt(20); - int y = worldObj.getTopSolidOrLiquidBlock(x, z); - - EntityMagicLandmine landmine = new EntityMagicLandmine(worldObj); - landmine.setPosition(x + 0.5, y, z + 0.5); - landmine.summoner = this; - worldObj.spawnEntityInWorld(landmine); - } - } - - if (!players.isEmpty()) - for (int pl = 0; pl < playerCount; pl++) - for (int i = 0; i < (spawnPixies ? worldObj.rand.nextInt(hard ? 6 : 3) : 1); i++) { - EntityPixie pixie = new EntityPixie(worldObj); - pixie.setProps(players.get(rand.nextInt(players.size())), this, 1, 8); - pixie.setPosition(posX + width / 2, posY + 2, posZ + width / 2); - worldObj.spawnEntityInWorld(pixie); - } - - setTPDelay(hard ? (dying ? 35 : 45) : (dying ? 40 : 60)); - spawnLandmines = true; - spawnPixies = false; - } - } - - if (spawnMissiles) spawnMissile(); - } else { - range = 3F; - players = worldObj.getEntitiesWithinAABB( - EntityPlayer.class, - AxisAlignedBB.getBoundingBox( - posX - range, posY - range, posZ - range, posX + range, posY + range, posZ + range)); - if (!players.isEmpty()) damageEntity(DamageSource.causePlayerDamage(players.get(0)), 0); - } - } - } - - void spawnMissile() { - if (!worldObj.isRemote) { - EntityMagicMissile missile = new EntityMagicMissile(this, true); - missile.setPosition( - posX + (Math.random() - 0.5 * 0.1), - posY + 2.4 + (Math.random() - 0.5 * 0.1), - posZ + (Math.random() - 0.5 * 0.1)); - if (missile.getTarget()) { - worldObj.playSoundAtEntity(this, "botania:missile", 0.6F, 0.8F + (float) Math.random() * 0.2F); - worldObj.spawnEntityInWorld(missile); - } - } - } - - public static boolean isCheatyBlock(World world, int x, int y, int z) { - Block block = world.getBlock(x, y, z); - String name = Block.blockRegistry.getNameForObject(block); - return CHEATY_BLOCKS.contains(name); - } - - // EntityEnderman code below ============================================================================ - - protected boolean teleportRandomly() { - double d0 = posX + (rand.nextDouble() - 0.5D) * 64.0D; - double d1 = posY + (rand.nextInt(64) - 32); - double d2 = posZ + (rand.nextDouble() - 0.5D) * 64.0D; - return teleportTo(d0, d1, d2); - } - - protected boolean teleportTo(double par1, double par3, double par5) { - double d3 = posX; - double d4 = posY; - double d5 = posZ; - posX = par1; - posY = par3; - posZ = par5; - boolean flag = false; - int i = MathHelper.floor_double(posX); - int j = MathHelper.floor_double(posY); - int k = MathHelper.floor_double(posZ); - - if (worldObj.blockExists(i, j, k)) { - boolean flag1 = false; - - while (!flag1 && j > 0) { - Block block = worldObj.getBlock(i, j - 1, k); - - if (block.getMaterial().blocksMovement()) flag1 = true; - else { - --posY; - --j; - } - } - - if (flag1) { - setPosition(posX, posY, posZ); - - if (worldObj.getCollidingBoundingBoxes(this, boundingBox).isEmpty() - && !worldObj.isAnyLiquid(boundingBox)) flag = true; - - // Prevent out of bounds teleporting - ChunkCoordinates source = getSource(); - if (vazkii.botania.common.core.helper.MathHelper.pointDistanceSpace( - posX, posY, posZ, source.posX, source.posY, source.posZ) - > 12) flag = false; - } - } - - if (!flag) { - setPosition(d3, d4, d5); - return false; - } else { - short short1 = 128; - - for (int l = 0; l < short1; ++l) { - double d6 = l / (short1 - 1.0D); - float f = (rand.nextFloat() - 0.5F) * 0.2F; - float f1 = (rand.nextFloat() - 0.5F) * 0.2F; - float f2 = (rand.nextFloat() - 0.5F) * 0.2F; - double d7 = d3 + (posX - d3) * d6 + (rand.nextDouble() - 0.5D) * width * 2.0D; - double d8 = d4 + (posY - d4) * d6 + rand.nextDouble() * height; - double d9 = d5 + (posZ - d5) * d6 + (rand.nextDouble() - 0.5D) * width * 2.0D; - worldObj.spawnParticle("portal", d7, d8, d9, f, f1, f2); - } - - worldObj.playSoundEffect(d3, d4, d5, "mob.endermen.portal", 1.0F, 1.0F); - playSound("mob.endermen.portal", 1.0F, 1.0F); - return true; - } - } - - @Override - @SideOnly(Side.CLIENT) - public ResourceLocation getBossBarTexture() { - return BossBarHandler.defaultBossBar; - } - - @SideOnly(Side.CLIENT) - private static Rectangle barRect; - - @SideOnly(Side.CLIENT) - private static Rectangle hpBarRect; - - @Override - @SideOnly(Side.CLIENT) - public Rectangle getBossBarTextureRect() { - if (barRect == null) barRect = new Rectangle(0, 0, 185, 15); - return barRect; - } - - @Override - @SideOnly(Side.CLIENT) - public Rectangle getBossBarHPTextureRect() { - if (hpBarRect == null) hpBarRect = new Rectangle(0, barRect.y + barRect.height, 181, 7); - return hpBarRect; - } - - @Override - @SideOnly(Side.CLIENT) - public void bossBarRenderCallback(ScaledResolution res, int x, int y) { - GL11.glPushMatrix(); - int px = x + 160; - int py = y + 12; - - Minecraft mc = Minecraft.getMinecraft(); - ItemStack stack = new ItemStack(Items.skull, 1, 3); - mc.renderEngine.bindTexture(TextureMap.locationItemsTexture); - net.minecraft.client.renderer.RenderHelper.enableGUIStandardItemLighting(); - GL11.glEnable(GL12.GL_RESCALE_NORMAL); - RenderItem.getInstance().renderItemIntoGUI(mc.fontRenderer, mc.renderEngine, stack, px, py); - net.minecraft.client.renderer.RenderHelper.disableStandardItemLighting(); - - boolean unicode = mc.fontRenderer.getUnicodeFlag(); - mc.fontRenderer.setUnicodeFlag(true); - mc.fontRenderer.drawStringWithShadow("" + getPlayerCount(), px + 15, py + 4, 0xFFFFFF); - mc.fontRenderer.setUnicodeFlag(unicode); - GL11.glPopMatrix(); - } - - @Override - @SideOnly(Side.CLIENT) - public int getBossBarShaderProgram(boolean background) { - return background ? 0 : ShaderHelper.dopplegangerBar; - } - - @SideOnly(Side.CLIENT) - private ShaderCallback shaderCallback; - - @Override - @SideOnly(Side.CLIENT) - public ShaderCallback getBossBarShaderCallback(boolean background, int shader) { - if (shaderCallback == null) - shaderCallback = new ShaderCallback() { - - @Override - public void call(int shader) { - int grainIntensityUniform = ARBShaderObjects.glGetUniformLocationARB(shader, "grainIntensity"); - int hpFractUniform = ARBShaderObjects.glGetUniformLocationARB(shader, "hpFract"); - - float time = getInvulTime(); - float grainIntensity = time > 20 ? 1F : Math.max(isHardMode() ? 0.5F : 0F, time / 20F); - - ARBShaderObjects.glUniform1fARB(grainIntensityUniform, grainIntensity); - ARBShaderObjects.glUniform1fARB(hpFractUniform, getHealth() / getMaxHealth()); - } - }; - - return background ? null : shaderCallback; - } - - public static class BeaconComponent extends MultiblockComponent { - - public BeaconComponent(ChunkCoordinates relPos) { - super(relPos, Blocks.iron_block, 0); - } - - @Override - public boolean matches(World world, int x, int y, int z) { - return world.getBlock(x, y, z) - .isBeaconBase(world, x, y, z, x - relPos.posX, y - relPos.posY, z - relPos.posZ); - } - ; - } - - public static class BeaconBeamComponent extends MultiblockComponent { - - public BeaconBeamComponent(ChunkCoordinates relPos) { - super(relPos, Blocks.beacon, 0); - } - - @Override - public boolean matches(World world, int x, int y, int z) { - return world.getTileEntity(x, y, z) instanceof TileEntityBeacon; - } - } + public static final int SPAWN_TICKS = 160; + private static final float RANGE = 12F; + private static final float MAX_HP = 800F; + + public static final int MOB_SPAWN_START_TICKS = 20; + public static final int MOB_SPAWN_END_TICKS = 80; + public static final int MOB_SPAWN_BASE_TICKS = 800; + public static final int MOB_SPAWN_TICKS = MOB_SPAWN_BASE_TICKS + MOB_SPAWN_START_TICKS + MOB_SPAWN_END_TICKS; + public static final int MOB_SPAWN_WAVES = 10; + public static final int MOB_SPAWN_WAVE_TIME = MOB_SPAWN_BASE_TICKS / MOB_SPAWN_WAVES; + + private static final String TAG_INVUL_TIME = "invulTime"; + private static final String TAG_AGGRO = "aggro"; + private static final String TAG_SOURCE_X = "sourceX"; + private static final String TAG_SOURCE_Y = "sourceY"; + private static final String TAG_SOURCE_Z = "sourcesZ"; + private static final String TAG_MOB_SPAWN_TICKS = "mobSpawnTicks"; + private static final String TAG_HARD_MODE = "hardMode"; + private static final String TAG_PLAYER_COUNT = "playerCount"; + + private static final int[][] PYLON_LOCATIONS = new int[][] { + { 4, 1, 4 }, + { 4, 1, -4 }, + { -4, 1, 4 }, + { -4, 1, -4 } + }; + + private static final List CHEATY_BLOCKS = Arrays.asList(new String[] { + "OpenBlocks:beartrap", + "ThaumicTinkerer:magnet" + }); + + boolean spawnLandmines = false; + boolean spawnPixies = false; + boolean anyWithArmor = false; + + List playersWhoAttacked = new ArrayList(); + + private static boolean isPlayingMusic = false; + + public EntityDoppleganger(World par1World) { + super(par1World); + setSize(0.6F, 1.8F); + getNavigator().setCanSwim(true); + tasks.addTask(0, new EntityAISwimming(this)); + tasks.addTask(1, new EntityAIWatchClosest(this, EntityPlayer.class, Float.MAX_VALUE)); + isImmuneToFire = true; + experienceValue = 825; + } + + public static MultiblockSet makeMultiblockSet() { + Multiblock mb = new Multiblock(); + + for(int[] p : PYLON_LOCATIONS) + mb.addComponent(p[0], p[1] + 1, p[2], ModBlocks.pylon, 2); + + for(int i = 0; i < 3; i++) + for(int j = 0; j < 3; j++) + mb.addComponent(new BeaconComponent(new ChunkCoordinates(i - 1, 0, j - 1))); + + mb.addComponent(new BeaconBeamComponent(new ChunkCoordinates(0, 1, 0))); + mb.setRenderOffset(0, -1, 0); + + return mb.makeSet(); + } + + public static boolean spawn(EntityPlayer player, ItemStack par1ItemStack, World par3World, int par4, int par5, int par6, boolean hard) { + if(par3World.getTileEntity(par4, par5, par6) instanceof TileEntityBeacon && isTruePlayer(player)) { + if(par3World.difficultySetting == EnumDifficulty.PEACEFUL) { + if(!par3World.isRemote) + player.addChatMessage(new ChatComponentTranslation("botaniamisc.peacefulNoob").setChatStyle(new ChatStyle().setColor(EnumChatFormatting.RED))); + return false; + } + + for(int[] coords : PYLON_LOCATIONS) { + int x = par4 + coords[0]; + int y = par5 + coords[1]; + int z = par6 + coords[2]; + + Block blockat = par3World.getBlock(x, y, z); + int meta = par3World.getBlockMetadata(x, y, z); + if(blockat != ModBlocks.pylon || meta != 2) { + if(!par3World.isRemote) + player.addChatMessage(new ChatComponentTranslation("botaniamisc.needsCatalysts").setChatStyle(new ChatStyle().setColor(EnumChatFormatting.RED))); + return false; + } + } + + if(!hasProperArena(par3World, par4, par5, par6)) { + for(int i = 0; i < 360; i += 8) { + float r = 1F; + float g = 0F; + float b = 1F; + float rad = i * (float) Math.PI / 180F; + double x = par4 + 0.5 - Math.cos(rad) * RANGE; + double y = par5 + 0.5; + double z = par6 + 0.5 - Math.sin(rad) * RANGE; + + Botania.proxy.sparkleFX(par3World, x, y, z, r, g, b, 5F, 120); + } + + if(!par3World.isRemote) + player.addChatMessage(new ChatComponentTranslation("botaniamisc.badArena").setChatStyle(new ChatStyle().setColor(EnumChatFormatting.RED))); + return false; + } + + par1ItemStack.stackSize--; + + if(par3World.isRemote) + return true; + + EntityDoppleganger e = new EntityDoppleganger(par3World); + e.setPosition(par4 + 0.5, par5 + 3, par6 + 0.5); + e.setInvulTime(SPAWN_TICKS); + e.setHealth(1F); + e.setSource(par4, par5, par6); + e.setMobSpawnTicks(MOB_SPAWN_TICKS); + e.setHardMode(hard); + + List players = e.getPlayersAround(); + int playerCount = 0; + for(EntityPlayer p : players) + if(isTruePlayer(p)) + playerCount++; + + e.setPlayerCount(playerCount); + e.getAttributeMap().getAttributeInstance(SharedMonsterAttributes.maxHealth).setBaseValue(MAX_HP * playerCount); + + par3World.playSoundAtEntity(e, "mob.enderdragon.growl", 10F, 0.1F); + par3World.spawnEntityInWorld(e); + return true; + } + + return false; + } + + private static boolean hasProperArena(World world, int sx, int sy, int sz) { + int heightCheck = 3; + int heightMin = 2; + int range = (int) Math.ceil(RANGE); + for(int i = -range; i < range + 1; i++) + for(int j = -range; j < range + 1; j++) { + if(Math.abs(i) == 4 && Math.abs(j) == 4 || vazkii.botania.common.core.helper.MathHelper.pointDistancePlane(i, j, 0, 0) > RANGE) + continue; // Ignore pylons and out of circle + + int x = sx + i; + int z = sz + j; + int air = 0; + + yCheck: { + for(int k = heightCheck + heightMin + 1; k >= -heightCheck; k--) { + int y = sy + k; + boolean isAir = world.getBlock(x, y, z).getCollisionBoundingBoxFromPool(world, x, y, z) == null; + if(isAir) + air++; + else { + if(k > heightCheck) + continue; + else if(air > 2) + break yCheck; + air = 0; + } + } + + return false; + } + } + + return true; + } + + @Override + protected boolean isAIEnabled() { + return true; + } + + @Override + protected void entityInit() { + super.entityInit(); + dataWatcher.addObject(20, 0); // Invul Time + dataWatcher.addObject(21, (byte) 0); // Aggro + dataWatcher.addObject(22, 0); // TP Delay + dataWatcher.addObject(23, 0); // Source X + dataWatcher.addObject(24, 0); // Source Y + dataWatcher.addObject(25, 0); // Source Z + dataWatcher.addObject(26, 0); // Ticks spawning mobs + dataWatcher.addObject(27, (byte) 0); // Hard Mode + dataWatcher.addObject(28, 0); // Player count + } + + public int getInvulTime() { + return dataWatcher.getWatchableObjectInt(20); + } + + public boolean isAggored() { + return dataWatcher.getWatchableObjectByte(21) == 1; + } + + public int getTPDelay() { + return dataWatcher.getWatchableObjectInt(22); + } + + public ChunkCoordinates getSource() { + int x = dataWatcher.getWatchableObjectInt(23); + int y = dataWatcher.getWatchableObjectInt(24); + int z = dataWatcher.getWatchableObjectInt(25); + return new ChunkCoordinates(x, y, z); + } + + public int getMobSpawnTicks() { + return dataWatcher.getWatchableObjectInt(26); + } + + public boolean isHardMode() { + return dataWatcher.getWatchableObjectByte(27) == 1; + } + + public int getPlayerCount() { + return dataWatcher.getWatchableObjectInt(28); + } + + public void setInvulTime(int time) { + dataWatcher.updateObject(20, time); + } + + public void setAggroed(boolean aggored) { + dataWatcher.updateObject(21, (byte) (aggored ? 1 : 0)); + } + + public void setTPDelay(int delay) { + dataWatcher.updateObject(22, delay); + } + + public void setSource(int x, int y, int z) { + dataWatcher.updateObject(23, x); + dataWatcher.updateObject(24, y); + dataWatcher.updateObject(25, z); + } + + public void setMobSpawnTicks(int ticks) { + dataWatcher.updateObject(26, ticks); + } + + public void setHardMode(boolean hardMode) { + dataWatcher.updateObject(27, (byte) (hardMode ? 1 : 0)); + } + + public void setPlayerCount(int count) { + dataWatcher.updateObject(28, count); + } + + @Override + public void writeEntityToNBT(NBTTagCompound par1nbtTagCompound) { + super.writeEntityToNBT(par1nbtTagCompound); + par1nbtTagCompound.setInteger(TAG_INVUL_TIME, getInvulTime()); + par1nbtTagCompound.setBoolean(TAG_AGGRO, isAggored()); + par1nbtTagCompound.setInteger(TAG_MOB_SPAWN_TICKS, getMobSpawnTicks()); + + ChunkCoordinates source = getSource(); + par1nbtTagCompound.setInteger(TAG_SOURCE_X, source.posX); + par1nbtTagCompound.setInteger(TAG_SOURCE_Y, source.posY); + par1nbtTagCompound.setInteger(TAG_SOURCE_Z, source.posZ); + + par1nbtTagCompound.setBoolean(TAG_HARD_MODE, isHardMode()); + par1nbtTagCompound.setInteger(TAG_PLAYER_COUNT, getPlayerCount()); + } + + @Override + public void readEntityFromNBT(NBTTagCompound par1nbtTagCompound) { + super.readEntityFromNBT(par1nbtTagCompound); + setInvulTime(par1nbtTagCompound.getInteger(TAG_INVUL_TIME)); + setAggroed(par1nbtTagCompound.getBoolean(TAG_AGGRO)); + setMobSpawnTicks(par1nbtTagCompound.getInteger(TAG_MOB_SPAWN_TICKS)); + + int x = par1nbtTagCompound.getInteger(TAG_SOURCE_X); + int y = par1nbtTagCompound.getInteger(TAG_SOURCE_Y); + int z = par1nbtTagCompound.getInteger(TAG_SOURCE_Z); + setSource(x, y, z); + + setHardMode(par1nbtTagCompound.getBoolean(TAG_HARD_MODE)); + if(par1nbtTagCompound.hasKey(TAG_PLAYER_COUNT)) + setPlayerCount(par1nbtTagCompound.getInteger(TAG_PLAYER_COUNT)); + else setPlayerCount(1); + } + + @Override + public boolean attackEntityFrom(DamageSource par1DamageSource, float par2) { + Entity e = par1DamageSource.getEntity(); + if((par1DamageSource.damageType.equals("player") || e instanceof EntityPixie) && e != null && isTruePlayer(e) && getInvulTime() == 0) { + EntityPlayer player = (EntityPlayer) e; + if(!playersWhoAttacked.contains(player.getCommandSenderName())) + playersWhoAttacked.add(player.getCommandSenderName()); + + float dmg = par2; + boolean crit = false; + if(e instanceof EntityPlayer) { + EntityPlayer p = (EntityPlayer) e; + crit = p.fallDistance > 0.0F && !p.onGround && !p.isOnLadder() && !p.isInWater() && !p.isPotionActive(Potion.blindness) && p.ridingEntity == null; + } + + int cap = crit ? 60 : 40; + return super.attackEntityFrom(par1DamageSource, Math.min(cap, dmg) * (isHardMode() ? 0.6F : 1F)); + } + return false; + } + + private static final Pattern FAKE_PLAYER_PATTERN = Pattern.compile("^(?:\\[.*\\])|(?:ComputerCraft)$"); + public static boolean isTruePlayer(Entity e) { + if(!(e instanceof EntityPlayer)) + return false; + + EntityPlayer player = (EntityPlayer) e; + + String name = player.getCommandSenderName(); + return !(player instanceof FakePlayer || FAKE_PLAYER_PATTERN.matcher(name).matches()); + } + + @Override + protected void damageEntity(DamageSource par1DamageSource, float par2) { + super.damageEntity(par1DamageSource, par2); + + Entity attacker = par1DamageSource.getEntity(); + if(attacker != null) { + Vector3 thisVector = Vector3.fromEntityCenter(this); + Vector3 playerVector = Vector3.fromEntityCenter(attacker); + Vector3 motionVector = thisVector.copy().sub(playerVector).copy().normalize().multiply(0.75); + + if(getHealth() > 0) { + motionX = -motionVector.x; + motionY = 0.5; + motionZ = -motionVector.z; + setTPDelay(4); + spawnPixies = isAggored(); + } + + setAggroed(true); + } + } + + @Override + public void onDeath(DamageSource p_70645_1_) { + super.onDeath(p_70645_1_); + EntityLivingBase entitylivingbase = func_94060_bK(); + if(entitylivingbase instanceof EntityPlayer) { + ((EntityPlayer) entitylivingbase).addStat(ModAchievements.gaiaGuardianKill, 1); + if(!anyWithArmor) + ((EntityPlayer) entitylivingbase).addStat(ModAchievements.gaiaGuardianNoArmor, 1); + } + + worldObj.playSoundAtEntity(this, "random.explode", 20F, (1F + (worldObj.rand.nextFloat() - worldObj.rand.nextFloat()) * 0.2F) * 0.7F); + worldObj.spawnParticle("hugeexplosion", posX, posY, posZ, 1D, 0D, 0D); + } + + @Override + protected void applyEntityAttributes() { + super.applyEntityAttributes(); + getEntityAttribute(SharedMonsterAttributes.movementSpeed).setBaseValue(0.4); + getEntityAttribute(SharedMonsterAttributes.maxHealth).setBaseValue(MAX_HP); + getEntityAttribute(SharedMonsterAttributes.knockbackResistance).setBaseValue(1.0); + } + + @Override + protected boolean canDespawn() { + return false; + } + + @Override + protected void dropFewItems(boolean par1, int par2) { + if(par1) { + for(int pl = 0; pl < playersWhoAttacked.size(); pl++) { + boolean hard = isHardMode(); + entityDropItem(new ItemStack(ModItems.manaResource, pl == 0 ? hard ? 16 : 8 : hard ? 10 : 6, 5), 1F); + boolean droppedRecord = false; + + if(hard) { + entityDropItem(new ItemStack(ModItems.ancientWill, 1, rand.nextInt(6)), 1F); + if(ConfigHandler.relicsEnabled) { + ItemStack dice = new ItemStack(ModItems.dice); + ItemRelic.bindToUsernameS(playersWhoAttacked.get(pl), dice); + entityDropItem(dice, 1F); + } + + if(Math.random() < 0.25) + entityDropItem(new ItemStack(ModItems.overgrowthSeed, rand.nextInt(3) + 1), 1F); + if(Math.random() < 0.5) { + boolean voidLotus = Math.random() < 0.3F; + entityDropItem(new ItemStack(ModItems.blackLotus, voidLotus ? 1 : rand.nextInt(3) + 1, voidLotus ? 1 : 0), 1F); + } + if(Math.random() < 0.9) + entityDropItem(new ItemStack(ModItems.manaResource, 16 + rand.nextInt(12)), 1F); + if(Math.random() < 0.7) + entityDropItem(new ItemStack(ModItems.manaResource, 8 + rand.nextInt(6), 1), 1F); + if(Math.random() < 0.5) + entityDropItem(new ItemStack(ModItems.manaResource, 4 + rand.nextInt(3), 2), 1F); + + int runes = rand.nextInt(6) + 1; + for(int i = 0; i < runes; i++) + if(Math.random() < 0.3) + entityDropItem(new ItemStack(ModItems.rune, 2 + rand.nextInt(3), rand.nextInt(16)), 1F); + + if(Math.random() < 0.2) + entityDropItem(new ItemStack(ModItems.pinkinator), 1F); + if(Math.random() < 0.3) { + int i = Item.getIdFromItem(Items.record_13); + int j = Item.getIdFromItem(Items.record_wait); + int k = i + rand.nextInt(j - i + 1); + entityDropItem(new ItemStack(Item.getItemById(k)), 1F); + droppedRecord = true; + } + } + + if(!droppedRecord && Math.random() < 0.2) + entityDropItem(new ItemStack(hard ? ModItems.recordGaia2 : ModItems.recordGaia1), 1F); + } + } + } + + @Override + public void setDead() { + ChunkCoordinates source = getSource(); + Botania.proxy.playRecordClientSided(worldObj, source.posX, source.posY, source.posZ, null); + isPlayingMusic = false; + super.setDead(); + } + + public List getPlayersAround() { + ChunkCoordinates source = getSource(); + float range = 15F; + List players = worldObj.getEntitiesWithinAABB(EntityPlayer.class, AxisAlignedBB.getBoundingBox(source.posX + 0.5 - range, source.posY + 0.5 - range, source.posZ + 0.5 - range, source.posX + 0.5 + range, source.posY + 0.5 + range, source.posZ + 0.5 + range)); + return players; + } + + @Override + public void onLivingUpdate() { + super.onLivingUpdate(); + + if(ridingEntity != null) { + if(ridingEntity.riddenByEntity != null) + ridingEntity.riddenByEntity = null; + ridingEntity = null; + } + + boolean peaceful = worldObj.difficultySetting == EnumDifficulty.PEACEFUL; + if(!worldObj.isRemote && peaceful) + setDead(); + + if(!worldObj.isRemote) { + int radius = 1; + int posXInt = MathHelper.floor_double(posX); + int posYInt = MathHelper.floor_double(posY); + int posZInt = MathHelper.floor_double(posZ); + for(int i = -radius; i < radius + 1; i++) + for(int j = -radius; j < radius + 1; j++) + for(int k = -radius; k < radius + 1; k++) { + int xp = posXInt + i; + int yp = posYInt + j; + int zp = posZInt + k; + if(isCheatyBlock(worldObj, xp, yp, zp)) { + Block block = worldObj.getBlock(xp, yp, zp); + List items = block.getDrops(worldObj, xp, yp, zp, 0, 0); + for(ItemStack stack : items) { + if(ConfigHandler.blockBreakParticles) + worldObj.playAuxSFX(2001, xp, yp, zp, Block.getIdFromBlock(block) + (worldObj.getBlockMetadata(xp, yp, zp) << 12)); + worldObj.spawnEntityInWorld(new EntityItem(worldObj, xp + 0.5, yp + 0.5, zp + 0.5, stack)); + } + worldObj.setBlockToAir(xp, yp, zp); + } + } + } + + ChunkCoordinates source = getSource(); + boolean hard = isHardMode(); + float range = RANGE + 3F; + List players = getPlayersAround(); + int playerCount = getPlayerCount(); + + if(worldObj.isRemote && !isPlayingMusic && !isDead && !players.isEmpty()) { + Botania.proxy.playRecordClientSided(worldObj, source.posX, source.posY, source.posZ, (ItemRecord) (hard ? ModItems.recordGaia2 : ModItems.recordGaia1)); + isPlayingMusic = true; + } + + range = RANGE; + for(int i = 0; i < 360; i += 8) { + float r = 0.6F; + float g = 0F; + float b = 0.2F; + float m = 0.15F; + float mv = 0.35F; + + float rad = i * (float) Math.PI / 180F; + double x = source.posX + 0.5 - Math.cos(rad) * range; + double y = source.posY + 0.5; + double z = source.posZ + 0.5 - Math.sin(rad) * range; + + Botania.proxy.wispFX(worldObj, x, y, z, r, g, b, 0.5F, (float) (Math.random() - 0.5F) * m, (float) (Math.random() - 0.5F) * mv, (float) (Math.random() - 0.5F) * m); + } + + if(players.isEmpty() && !worldObj.playerEntities.isEmpty()) + setDead(); + else { + for(EntityPlayer player : players) { + if(player.inventory.armorInventory[0] != null || player.inventory.armorInventory[1] != null || player.inventory.armorInventory[2] != null || player.inventory.armorInventory[3] != null) + anyWithArmor = true; + + List remove = new ArrayList(); + Collection active = player.getActivePotionEffects(); + for(PotionEffect effect : active) + if(effect.getDuration() < 200 && effect.getIsAmbient() && !ReflectionHelper.getPrivateValue(Potion.class, Potion.potionTypes[effect.getPotionID()], LibObfuscation.IS_BAD_EFFECT)) + remove.add(effect); + + active.removeAll(remove); + + player.capabilities.isFlying = player.capabilities.isFlying && player.capabilities.isCreativeMode; + + if(vazkii.botania.common.core.helper.MathHelper.pointDistanceSpace(player.posX, player.posY, player.posZ, source.posX + 0.5, source.posY + 0.5, source.posZ + 0.5) >= range) { + Vector3 sourceVector = new Vector3(source.posX + 0.5, source.posY + 0.5, source.posZ + 0.5); + Vector3 playerVector = Vector3.fromEntityCenter(player); + Vector3 motion = sourceVector.copy().sub(playerVector).copy().normalize(); + + player.motionX = motion.x; + player.motionY = 0.2; + player.motionZ = motion.z; + } + } + } + + if(isDead) + return; + + int invul = getInvulTime(); + int mobTicks = getMobSpawnTicks(); + boolean spawnMissiles = hard && ticksExisted % 15 < 4; + + if(invul > 10) { + Vector3 pos = Vector3.fromEntityCenter(this).subtract(new Vector3(0, 0.2, 0)); + for(int i = 0; i < PYLON_LOCATIONS.length; i++) { + int[] arr = PYLON_LOCATIONS[i]; + int x = arr[0]; + int y = arr[1]; + int z = arr[2]; + + Vector3 pylonPos = new Vector3(source.posX + x, source.posY + y, source.posZ + z); + double worldTime = ticksExisted; + worldTime /= 5; + + float rad = 0.75F + (float) Math.random() * 0.05F; + double xp = pylonPos.x + 0.5 + Math.cos(worldTime) * rad; + double zp = pylonPos.z + 0.5 + Math.sin(worldTime) * rad; + + Vector3 partPos = new Vector3(xp, pylonPos.y, zp); + Vector3 mot = pos.copy().sub(partPos).multiply(0.04); + + float r = 0.7F + (float) Math.random() * 0.3F; + float g = (float) Math.random() * 0.3F; + float b = 0.7F + (float) Math.random() * 0.3F; + + Botania.proxy.wispFX(worldObj, partPos.x, partPos.y, partPos.z, r, g, b, 0.25F + (float) Math.random() * 0.1F, -0.075F - (float) Math.random() * 0.015F); + Botania.proxy.wispFX(worldObj, partPos.x, partPos.y, partPos.z, r, g, b, 0.4F, (float) mot.x, (float) mot.y, (float) mot.z); + } + } + + if(invul > 0 && mobTicks == MOB_SPAWN_TICKS) { + if(invul < SPAWN_TICKS) { + if(invul > SPAWN_TICKS / 2 && worldObj.rand.nextInt(SPAWN_TICKS - invul + 1) == 0) + for(int i = 0; i < 2; i++) + spawnExplosionParticle(); + } + + if(!worldObj.isRemote) { + setHealth(getHealth() + (getMaxHealth() - 1F) / SPAWN_TICKS); + setInvulTime(invul - 1); + } + motionY = 0; + } else { + if(isAggored()) { + boolean dying = getHealth() / getMaxHealth() < 0.2; + if(dying && mobTicks > 0) { + motionX = 0; + motionY = 0; + motionZ = 0; + + int reverseTicks = MOB_SPAWN_TICKS - mobTicks; + if(reverseTicks < MOB_SPAWN_START_TICKS) { + motionY = 0.2; + setInvulTime(invul + 1); + } + + if(reverseTicks > MOB_SPAWN_START_TICKS * 2 && mobTicks > MOB_SPAWN_END_TICKS && mobTicks % MOB_SPAWN_WAVE_TIME == 0 && !worldObj.isRemote) { + for(int pl = 0; pl < playerCount; pl++) + for(int i = 0; i < 3 + worldObj.rand.nextInt(2); i++) { + EntityLiving entity = null; + switch(worldObj.rand.nextInt(2)) { + case 0 : { + entity = new EntityZombie(worldObj); + if(worldObj.rand.nextInt(hard ? 3 : 12) == 0) + entity = new EntityWitch(worldObj); + + break; + } + case 1 : { + entity = new EntitySkeleton(worldObj); + ((EntitySkeleton) entity).setCurrentItemOrArmor(0, new ItemStack(Items.bow)); + if(worldObj.rand.nextInt(8) == 0) { + ((EntitySkeleton) entity).setSkeletonType(1); + ((EntitySkeleton) entity).setCurrentItemOrArmor(0, new ItemStack(hard ? ModItems.elementiumSword : Items.stone_sword)); + } + break; + } + case 3 : { + if(!players.isEmpty()) + for(int j = 0; j < 1 + worldObj.rand.nextInt(hard ? 8 : 5); j++) { + EntityPixie pixie = new EntityPixie(worldObj); + pixie.setProps(players.get(rand.nextInt(players.size())), this, 1, 8); + pixie.setPosition(posX + width / 2, posY + 2, posZ + width / 2); + worldObj.spawnEntityInWorld(pixie); + } + } + } + + if(entity != null) { + range = 6F; + entity.setPosition(posX + 0.5 + Math.random() * range - range / 2, posY - 1, posZ + 0.5 + Math.random() * range - range / 2); + worldObj.spawnEntityInWorld(entity); + } + } + + if(hard && ticksExisted % 3 < 2) { + for(int i = 0; i < playerCount; i++) + spawnMissile(); + spawnMissiles = false; + } + } + + setMobSpawnTicks(mobTicks - 1); + setTPDelay(10); + } else if(getTPDelay() > 0 && !worldObj.isRemote) { + if(invul > 0) + setInvulTime(invul - 1); + + setTPDelay(getTPDelay() - 1); + if(getTPDelay() == 0 && getHealth() > 0) { + int tries = 0; + while(!teleportRandomly() && tries < 50) + tries++; + if(tries >= 50) + teleportTo(source.posX + 0.5, source.posY + 1.6, source.posZ + 0.5); + + if(spawnLandmines) { + int count = dying && hard ? 7 : 6; + for(int i = 0; i < count; i++) { + int x = source.posX - 10 + rand.nextInt(20); + int z = source.posZ - 10 + rand.nextInt(20); + int y = worldObj.getTopSolidOrLiquidBlock(x, z); + + EntityMagicLandmine landmine = new EntityMagicLandmine(worldObj); + landmine.setPosition(x + 0.5, y, z + 0.5); + landmine.summoner = this; + worldObj.spawnEntityInWorld(landmine); + } + + } + + if(!players.isEmpty()) + for(int pl = 0; pl < playerCount; pl++) + for(int i = 0; i < (spawnPixies ? worldObj.rand.nextInt(hard ? 6 : 3) : 1); i++) { + EntityPixie pixie = new EntityPixie(worldObj); + pixie.setProps(players.get(rand.nextInt(players.size())), this, 1, 8); + pixie.setPosition(posX + width / 2, posY + 2, posZ + width / 2); + worldObj.spawnEntityInWorld(pixie); + } + + setTPDelay(hard ? (dying ? 35 : 45) : (dying ? 40 : 60)); + spawnLandmines = true; + spawnPixies = false; + } + } + + if(spawnMissiles) + spawnMissile(); + } else { + range = 3F; + players = worldObj.getEntitiesWithinAABB(EntityPlayer.class, AxisAlignedBB.getBoundingBox(posX - range, posY - range, posZ - range, posX + range, posY + range, posZ + range)); + if(!players.isEmpty()) + damageEntity(DamageSource.causePlayerDamage(players.get(0)), 0); + } + } + } + + void spawnMissile() { + if(!worldObj.isRemote) { + EntityMagicMissile missile = new EntityMagicMissile(this, true); + missile.setPosition(posX + (Math.random() - 0.5 * 0.1), posY + 2.4 + (Math.random() - 0.5 * 0.1), posZ + (Math.random() - 0.5 * 0.1)); + if(missile.getTarget()) { + worldObj.playSoundAtEntity(this, "botania:missile", 0.6F, 0.8F + (float) Math.random() * 0.2F); + worldObj.spawnEntityInWorld(missile); + } + } + } + + public static boolean isCheatyBlock(World world, int x, int y, int z) { + Block block = world.getBlock(x, y, z); + String name = Block.blockRegistry.getNameForObject(block); + return CHEATY_BLOCKS.contains(name); + } + + // EntityEnderman code below ============================================================================ + + protected boolean teleportRandomly() { + double d0 = posX + (rand.nextDouble() - 0.5D) * 64.0D; + double d1 = posY + (rand.nextInt(64) - 32); + double d2 = posZ + (rand.nextDouble() - 0.5D) * 64.0D; + return teleportTo(d0, d1, d2); + } + + protected boolean teleportTo(double par1, double par3, double par5) { + double d3 = posX; + double d4 = posY; + double d5 = posZ; + posX = par1; + posY = par3; + posZ = par5; + boolean flag = false; + int i = MathHelper.floor_double(posX); + int j = MathHelper.floor_double(posY); + int k = MathHelper.floor_double(posZ); + + if(worldObj.blockExists(i, j, k)) { + boolean flag1 = false; + + while(!flag1 && j > 0) { + Block block = worldObj.getBlock(i, j - 1, k); + + if(block.getMaterial().blocksMovement()) + flag1 = true; + else { + --posY; + --j; + } + } + + if(flag1) { + setPosition(posX, posY, posZ); + + if(worldObj.getCollidingBoundingBoxes(this, boundingBox).isEmpty() && !worldObj.isAnyLiquid(boundingBox)) + flag = true; + + // Prevent out of bounds teleporting + ChunkCoordinates source = getSource(); + if(vazkii.botania.common.core.helper.MathHelper.pointDistanceSpace(posX, posY, posZ, source.posX, source.posY, source.posZ) > 12) + flag = false; + } + } + + if (!flag) { + setPosition(d3, d4, d5); + return false; + } else { + short short1 = 128; + + for(int l = 0; l < short1; ++l) { + double d6 = l / (short1 - 1.0D); + float f = (rand.nextFloat() - 0.5F) * 0.2F; + float f1 = (rand.nextFloat() - 0.5F) * 0.2F; + float f2 = (rand.nextFloat() - 0.5F) * 0.2F; + double d7 = d3 + (posX - d3) * d6 + (rand.nextDouble() - 0.5D) * width * 2.0D; + double d8 = d4 + (posY - d4) * d6 + rand.nextDouble() * height; + double d9 = d5 + (posZ - d5) * d6 + (rand.nextDouble() - 0.5D) * width * 2.0D; + worldObj.spawnParticle("portal", d7, d8, d9, f, f1, f2); + } + + worldObj.playSoundEffect(d3, d4, d5, "mob.endermen.portal", 1.0F, 1.0F); + playSound("mob.endermen.portal", 1.0F, 1.0F); + return true; + } + } + + @Override + @SideOnly(Side.CLIENT) + public ResourceLocation getBossBarTexture() { + return BossBarHandler.defaultBossBar; + } + + @SideOnly(Side.CLIENT) + private static Rectangle barRect; + @SideOnly(Side.CLIENT) + private static Rectangle hpBarRect; + + @Override + @SideOnly(Side.CLIENT) + public Rectangle getBossBarTextureRect() { + if(barRect == null) + barRect = new Rectangle(0, 0, 185, 15); + return barRect; + } + + @Override + @SideOnly(Side.CLIENT) + public Rectangle getBossBarHPTextureRect() { + if(hpBarRect == null) + hpBarRect = new Rectangle(0, barRect.y + barRect.height, 181, 7); + return hpBarRect; + } + + @Override + @SideOnly(Side.CLIENT) + public void bossBarRenderCallback(ScaledResolution res, int x, int y) { + GL11.glPushMatrix(); + int px = x + 160; + int py = y + 12; + + Minecraft mc = Minecraft.getMinecraft(); + ItemStack stack = new ItemStack(Items.skull, 1, 3); + mc.renderEngine.bindTexture(TextureMap.locationItemsTexture); + net.minecraft.client.renderer.RenderHelper.enableGUIStandardItemLighting(); + GL11.glEnable(GL12.GL_RESCALE_NORMAL); + RenderItem.getInstance().renderItemIntoGUI(mc.fontRenderer, mc.renderEngine, stack, px, py); + net.minecraft.client.renderer.RenderHelper.disableStandardItemLighting(); + + boolean unicode = mc.fontRenderer.getUnicodeFlag(); + mc.fontRenderer.setUnicodeFlag(true); + mc.fontRenderer.drawStringWithShadow("" + getPlayerCount(), px + 15, py + 4, 0xFFFFFF); + mc.fontRenderer.setUnicodeFlag(unicode); + GL11.glPopMatrix(); + } + + @Override + @SideOnly(Side.CLIENT) + public int getBossBarShaderProgram(boolean background) { + return background ? 0 : ShaderHelper.dopplegangerBar; + } + + @SideOnly(Side.CLIENT) + private ShaderCallback shaderCallback; + + @Override + @SideOnly(Side.CLIENT) + public ShaderCallback getBossBarShaderCallback(boolean background, int shader) { + if(shaderCallback == null) + shaderCallback = new ShaderCallback() { + + @Override + public void call(int shader) { + int grainIntensityUniform = ARBShaderObjects.glGetUniformLocationARB(shader, "grainIntensity"); + int hpFractUniform = ARBShaderObjects.glGetUniformLocationARB(shader, "hpFract"); + + float time = getInvulTime(); + float grainIntensity = time > 20 ? 1F : Math.max(isHardMode() ? 0.5F : 0F, time / 20F); + + ARBShaderObjects.glUniform1fARB(grainIntensityUniform, grainIntensity); + ARBShaderObjects.glUniform1fARB(hpFractUniform, getHealth() / getMaxHealth()); + } + + }; + + return background ? null : shaderCallback; + } + + public static class BeaconComponent extends MultiblockComponent { + + public BeaconComponent(ChunkCoordinates relPos) { + super(relPos, Blocks.iron_block, 0); + } + + @Override + public boolean matches(World world, int x, int y, int z) { + return world.getBlock(x, y, z).isBeaconBase(world, x, y, z, x - relPos.posX, y - relPos.posY, z - relPos.posZ); + }; + + } + + public static class BeaconBeamComponent extends MultiblockComponent { + + public BeaconBeamComponent(ChunkCoordinates relPos) { + super(relPos, Blocks.beacon, 0); + } + + @Override + public boolean matches(World world, int x, int y, int z) { + return world.getTileEntity(x, y, z) instanceof TileEntityBeacon; + } + } } diff --git a/src/main/java/vazkii/botania/common/entity/EntityEnderAirBottle.java b/src/main/java/vazkii/botania/common/entity/EntityEnderAirBottle.java index 73d37f66bf..0a470bc235 100644 --- a/src/main/java/vazkii/botania/common/entity/EntityEnderAirBottle.java +++ b/src/main/java/vazkii/botania/common/entity/EntityEnderAirBottle.java @@ -2,16 +2,17 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Feb 16, 2015, 5:15:31 PM (GMT)] */ package vazkii.botania.common.entity; import java.util.ArrayList; import java.util.List; + import net.minecraft.block.Block; import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.projectile.EntityThrowable; @@ -22,54 +23,54 @@ public class EntityEnderAirBottle extends EntityThrowable { - public EntityEnderAirBottle(World world) { - super(world); - } + public EntityEnderAirBottle(World world) { + super(world); + } + + public EntityEnderAirBottle(World world, EntityLivingBase entity) { + super(world, entity); + } - public EntityEnderAirBottle(World world, EntityLivingBase entity) { - super(world, entity); - } + @Override + protected void onImpact(MovingObjectPosition pos) { + if(pos.entityHit == null && !worldObj.isRemote) { + List coordsList = getCoordsToPut(pos.blockX, pos.blockY, pos.blockZ); + worldObj.playAuxSFX(2002, (int)Math.round(posX), (int)Math.round(posY), (int)Math.round(posZ), 8); - @Override - protected void onImpact(MovingObjectPosition pos) { - if (pos.entityHit == null && !worldObj.isRemote) { - List coordsList = getCoordsToPut(pos.blockX, pos.blockY, pos.blockZ); - worldObj.playAuxSFX(2002, (int) Math.round(posX), (int) Math.round(posY), (int) Math.round(posZ), 8); + for(ChunkCoordinates coords : coordsList) { + worldObj.setBlock(coords.posX, coords.posY, coords.posZ, Blocks.end_stone); + if(Math.random() < 0.1) + worldObj.playAuxSFX(2001, coords.posX, coords.posY, coords.posZ, Block.getIdFromBlock(Blocks.end_stone)); + } + setDead(); + } + } - for (ChunkCoordinates coords : coordsList) { - worldObj.setBlock(coords.posX, coords.posY, coords.posZ, Blocks.end_stone); - if (Math.random() < 0.1) - worldObj.playAuxSFX( - 2001, coords.posX, coords.posY, coords.posZ, Block.getIdFromBlock(Blocks.end_stone)); - } - setDead(); - } - } + public List getCoordsToPut(int xCoord, int yCoord, int zCoord) { + List possibleCoords = new ArrayList(); + List selectedCoords = new ArrayList(); + int range = 4; + int rangeY = 4; - public List getCoordsToPut(int xCoord, int yCoord, int zCoord) { - List possibleCoords = new ArrayList(); - List selectedCoords = new ArrayList(); - int range = 4; - int rangeY = 4; + for(int i = -range; i < range + 1; i++) + for(int j = -rangeY; j < rangeY; j++) + for(int k = -range; k < range + 1; k++) { + int x = xCoord + i; + int y = yCoord + j; + int z = zCoord + k; + Block block = worldObj.getBlock(x, y, z); + if(block != null && block.isReplaceableOreGen(worldObj, x, y, z, Blocks.stone)) + possibleCoords.add(new ChunkCoordinates(x, y, z)); + } - for (int i = -range; i < range + 1; i++) - for (int j = -rangeY; j < rangeY; j++) - for (int k = -range; k < range + 1; k++) { - int x = xCoord + i; - int y = yCoord + j; - int z = zCoord + k; - Block block = worldObj.getBlock(x, y, z); - if (block != null && block.isReplaceableOreGen(worldObj, x, y, z, Blocks.stone)) - possibleCoords.add(new ChunkCoordinates(x, y, z)); - } + int count = 64; + while(!possibleCoords.isEmpty() && count > 0) { + ChunkCoordinates coords = possibleCoords.get(worldObj.rand.nextInt(possibleCoords.size())); + possibleCoords.remove(coords); + selectedCoords.add(coords); + count--; + } + return selectedCoords; + } - int count = 64; - while (!possibleCoords.isEmpty() && count > 0) { - ChunkCoordinates coords = possibleCoords.get(worldObj.rand.nextInt(possibleCoords.size())); - possibleCoords.remove(coords); - selectedCoords.add(coords); - count--; - } - return selectedCoords; - } } diff --git a/src/main/java/vazkii/botania/common/entity/EntityFallingStar.java b/src/main/java/vazkii/botania/common/entity/EntityFallingStar.java index da48cdd5ca..82d1f4c0b5 100644 --- a/src/main/java/vazkii/botania/common/entity/EntityFallingStar.java +++ b/src/main/java/vazkii/botania/common/entity/EntityFallingStar.java @@ -2,15 +2,16 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Aug 17, 2015, 4:19:52 PM (GMT)] */ package vazkii.botania.common.entity; import java.util.List; + import net.minecraft.block.Block; import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.player.EntityPlayer; @@ -23,66 +24,62 @@ public class EntityFallingStar extends EntityThrowableCopy { - public EntityFallingStar(World world) { - super(world); - setSize(0F, 0F); - } + public EntityFallingStar(World world) { + super(world); + setSize(0F, 0F); + } + + public EntityFallingStar(World world, EntityLivingBase e) { + super(world, e); + setSize(0F, 0F); + } - public EntityFallingStar(World world, EntityLivingBase e) { - super(world, e); - setSize(0F, 0F); - } + @Override + public void onUpdate() { + super.onUpdate(); - @Override - public void onUpdate() { - super.onUpdate(); + float dist = 1.5F; + for(int i = 0; i < 10; i++) { + float xs = (float) (Math.random() - 0.5) * dist; + float ys = (float) (Math.random() - 0.5) * dist; + float zs = (float) (Math.random() - 0.5) * dist; + Botania.proxy.sparkleFX(worldObj, posX + xs, posY + ys, posZ + zs, 1F, 0.4F, 1F, 2F, 6); + } - float dist = 1.5F; - for (int i = 0; i < 10; i++) { - float xs = (float) (Math.random() - 0.5) * dist; - float ys = (float) (Math.random() - 0.5) * dist; - float zs = (float) (Math.random() - 0.5) * dist; - Botania.proxy.sparkleFX(worldObj, posX + xs, posY + ys, posZ + zs, 1F, 0.4F, 1F, 2F, 6); - } + EntityLivingBase thrower = getThrower(); + if(!worldObj.isRemote && thrower != null) { + AxisAlignedBB axis = AxisAlignedBB.getBoundingBox(posX, posY, posZ, lastTickPosX, lastTickPosY, lastTickPosZ).expand(2, 2, 2); + List entities = worldObj.getEntitiesWithinAABB(EntityLivingBase.class, axis); + for(EntityLivingBase living : entities) { + if(living == thrower) + continue; - EntityLivingBase thrower = getThrower(); - if (!worldObj.isRemote && thrower != null) { - AxisAlignedBB axis = AxisAlignedBB.getBoundingBox( - posX, posY, posZ, lastTickPosX, lastTickPosY, lastTickPosZ) - .expand(2, 2, 2); - List entities = worldObj.getEntitiesWithinAABB(EntityLivingBase.class, axis); - for (EntityLivingBase living : entities) { - if (living == thrower) continue; + if(living.hurtTime == 0) { + onImpact(new MovingObjectPosition(living)); + return; + } + } + } - if (living.hurtTime == 0) { - onImpact(new MovingObjectPosition(living)); - return; - } - } - } + if(ticksExisted > 200) + setDead(); + } - if (ticksExisted > 200) setDead(); - } + @Override + protected void onImpact(MovingObjectPosition pos) { + EntityLivingBase thrower = getThrower(); + if(pos.entityHit != null && thrower != null && pos.entityHit != thrower && !pos.entityHit.isDead) { + if(thrower instanceof EntityPlayer) + pos.entityHit.attackEntityFrom(DamageSource.causePlayerDamage((EntityPlayer) thrower), 10); + else pos.entityHit.attackEntityFrom(DamageSource.generic, 10); + } - @Override - protected void onImpact(MovingObjectPosition pos) { - EntityLivingBase thrower = getThrower(); - if (pos.entityHit != null && thrower != null && pos.entityHit != thrower && !pos.entityHit.isDead) { - if (thrower instanceof EntityPlayer) - pos.entityHit.attackEntityFrom(DamageSource.causePlayerDamage((EntityPlayer) thrower), 10); - else pos.entityHit.attackEntityFrom(DamageSource.generic, 10); - } + Block block = worldObj.getBlock(pos.blockX, pos.blockY, pos.blockZ); + if(ConfigHandler.blockBreakParticles && !block.isAir(worldObj, pos.blockX, pos.blockY, pos.blockZ)) + worldObj.playAuxSFX(2001, pos.blockX, pos.blockY, pos.blockZ, Block.getIdFromBlock(block) + (worldObj.getBlockMetadata(pos.blockX, pos.blockY, pos.blockZ) << 12)); - Block block = worldObj.getBlock(pos.blockX, pos.blockY, pos.blockZ); - if (ConfigHandler.blockBreakParticles && !block.isAir(worldObj, pos.blockX, pos.blockY, pos.blockZ)) - worldObj.playAuxSFX( - 2001, - pos.blockX, - pos.blockY, - pos.blockZ, - Block.getIdFromBlock(block) - + (worldObj.getBlockMetadata(pos.blockX, pos.blockY, pos.blockZ) << 12)); + setDead(); + } - setDead(); - } } + diff --git a/src/main/java/vazkii/botania/common/entity/EntityFlameRing.java b/src/main/java/vazkii/botania/common/entity/EntityFlameRing.java index e5350cc306..b77f34f00a 100644 --- a/src/main/java/vazkii/botania/common/entity/EntityFlameRing.java +++ b/src/main/java/vazkii/botania/common/entity/EntityFlameRing.java @@ -2,15 +2,17 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jun 26, 2014, 12:31:10 AM (GMT)] */ package vazkii.botania.common.entity; + import java.util.List; + import net.minecraft.entity.Entity; import net.minecraft.entity.EntityLivingBase; import net.minecraft.nbt.NBTTagCompound; @@ -20,100 +22,86 @@ import vazkii.botania.common.Botania; import vazkii.botania.common.core.helper.MathHelper; + public class EntityFlameRing extends Entity { - public EntityFlameRing(World world) { - super(world); - } - - @Override - protected void entityInit() { - setSize(0F, 0F); - } - - @Override - public void onEntityUpdate() { - super.onEntityUpdate(); - - float radius = 5F; - float renderRadius = (float) (radius - Math.random()); - - for (int i = 0; i < Math.min(90, ticksExisted); i++) { - float a = i; - if (a % 2 == 0) a = 45 + a; - - if (worldObj.rand.nextInt(ticksExisted < 90 ? 8 : 20) == 0) { - float rad = (float) (a * 4 * Math.PI / 180F); - double x = Math.cos(rad) * renderRadius; - double z = Math.sin(rad) * renderRadius; - - Botania.proxy.wispFX( - worldObj, - posX + x, - posY - 0.2, - posZ + z, - 1F, - (float) Math.random() * 0.25F, - (float) Math.random() * 0.25F, - 0.65F + (float) Math.random() * 0.45F, - (float) (Math.random() - 0.5F) * 0.15F, - 0.055F + (float) Math.random() * 0.025F, - (float) (Math.random() - 0.5F) * 0.15F); - - float gs = (float) Math.random() * 0.15F; - float smokeRadius = (float) (renderRadius - Math.random() * renderRadius * 0.9); - x = Math.cos(rad) * smokeRadius; - z = Math.sin(rad) * smokeRadius; - Botania.proxy.wispFX( - worldObj, - posX + x, - posY - 0.2, - posZ + z, - gs, - gs, - gs, - 0.65F + (float) Math.random() * 0.45F, - -0.155F - (float) Math.random() * 0.025F); - } - } - - if (worldObj.rand.nextInt(20) == 0) worldObj.playSoundAtEntity(this, "fire.fire", 1F, 1F); - - if (worldObj.isRemote) return; - - if (ticksExisted >= 300) { - setDead(); - return; - } - - if (ticksExisted > 45) { - AxisAlignedBB boundingBox = AxisAlignedBB.getBoundingBox(posX, posY, posZ, posX, posY, posZ) - .expand(radius, radius, radius); - List entities = worldObj.getEntitiesWithinAABB(EntityLivingBase.class, boundingBox); - - if (entities.isEmpty()) return; - - for (EntityLivingBase entity : entities) { - if (entity == null || MathHelper.pointDistancePlane(posX, posY, entity.posX, entity.posY) > radius) - continue; - - entity.setFire(4); - } - } - } - - @Override - public boolean attackEntityFrom(DamageSource par1DamageSource, float par2) { - return false; - } - - @Override - protected void readEntityFromNBT(NBTTagCompound var1) { - // NO-OP - } - - @Override - protected void writeEntityToNBT(NBTTagCompound var1) { - // NO-OP - } -} + public EntityFlameRing(World world) { + super(world); + } + + @Override + protected void entityInit() { + setSize(0F, 0F); + } + + @Override + public void onEntityUpdate() { + super.onEntityUpdate(); + + float radius = 5F; + float renderRadius = (float) (radius - Math.random()); + + for(int i = 0; i < Math.min(90, ticksExisted); i++) { + float a = i; + if(a % 2 == 0) + a = 45 + a; + + if(worldObj.rand.nextInt(ticksExisted < 90 ? 8 : 20) == 0) { + float rad = (float) (a * 4 * Math.PI / 180F); + double x = Math.cos(rad) * renderRadius; + double z = Math.sin(rad) * renderRadius; + + Botania.proxy.wispFX(worldObj, posX + x, posY - 0.2, posZ + z, 1F, (float) Math.random() * 0.25F, (float) Math.random() * 0.25F, 0.65F + (float) Math.random() * 0.45F, (float) (Math.random() - 0.5F) * 0.15F, 0.055F + (float) Math.random() * 0.025F, (float) (Math.random() - 0.5F) * 0.15F); + + float gs = (float) Math.random() * 0.15F; + float smokeRadius = (float) (renderRadius - Math.random() * renderRadius * 0.9); + x = Math.cos(rad) * smokeRadius; + z = Math.sin(rad) * smokeRadius; + Botania.proxy.wispFX(worldObj, posX + x, posY - 0.2, posZ + z, gs, gs, gs, 0.65F + (float) Math.random() * 0.45F, -0.155F - (float) Math.random() * 0.025F); + } + } + + if(worldObj.rand.nextInt(20) == 0) + worldObj.playSoundAtEntity(this, "fire.fire", 1F, 1F); + + if(worldObj.isRemote) + return; + + if(ticksExisted >= 300) { + setDead(); + return; + } + + if(ticksExisted > 45) { + AxisAlignedBB boundingBox = AxisAlignedBB.getBoundingBox(posX, posY, posZ, posX, posY, posZ).expand(radius, radius, radius); + List entities = worldObj.getEntitiesWithinAABB(EntityLivingBase.class, boundingBox); + + if(entities.isEmpty()) + return; + + for(EntityLivingBase entity : entities) { + if(entity == null || MathHelper.pointDistancePlane(posX, posY, entity.posX, entity.posY) > radius) + continue; + + entity.setFire(4); + } + } + } + + @Override + public boolean attackEntityFrom(DamageSource par1DamageSource, float par2) { + return false; + } + + + @Override + protected void readEntityFromNBT(NBTTagCompound var1) { + // NO-OP + } + + + @Override + protected void writeEntityToNBT(NBTTagCompound var1) { + // NO-OP + } +} \ No newline at end of file diff --git a/src/main/java/vazkii/botania/common/entity/EntityFlyingCreature.java b/src/main/java/vazkii/botania/common/entity/EntityFlyingCreature.java index d20d9d9965..b9c27de8c4 100644 --- a/src/main/java/vazkii/botania/common/entity/EntityFlyingCreature.java +++ b/src/main/java/vazkii/botania/common/entity/EntityFlyingCreature.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [? (GMT)] */ package vazkii.botania.common.entity; @@ -17,78 +17,73 @@ public class EntityFlyingCreature extends EntityAmbientCreature { - public EntityFlyingCreature(World par1World) { - super(par1World); - } + public EntityFlyingCreature(World par1World) { + super(par1World); + } - @Override - protected void fall(float par1) { - // NO-OP - } + @Override + protected void fall(float par1) { + // NO-OP + } - @Override - protected void updateFallState(double par1, boolean par3) { - // NO-OP - } + @Override + protected void updateFallState(double par1, boolean par3) { + // NO-OP + } - @Override - public void moveEntityWithHeading(float par1, float par2) { - if (isInWater()) { - moveFlying(par1, par2, 0.02F); - moveEntity(motionX, motionY, motionZ); - motionX *= 0.800000011920929D; - motionY *= 0.800000011920929D; - motionZ *= 0.800000011920929D; - } else if (handleLavaMovement()) { - moveFlying(par1, par2, 0.02F); - moveEntity(motionX, motionY, motionZ); - motionX *= 0.5D; - motionY *= 0.5D; - motionZ *= 0.5D; - } else { - float f2 = 0.91F; + @Override + public void moveEntityWithHeading(float par1, float par2) { + if(isInWater()) { + moveFlying(par1, par2, 0.02F); + moveEntity(motionX, motionY, motionZ); + motionX *= 0.800000011920929D; + motionY *= 0.800000011920929D; + motionZ *= 0.800000011920929D; + } else if(handleLavaMovement()) { + moveFlying(par1, par2, 0.02F); + moveEntity(motionX, motionY, motionZ); + motionX *= 0.5D; + motionY *= 0.5D; + motionZ *= 0.5D; + } else { + float f2 = 0.91F; - if (onGround) { - f2 = 0.54600006F; - Block block = worldObj.getBlock( - MathHelper.floor_double(posX), - MathHelper.floor_double(boundingBox.minY) - 1, - MathHelper.floor_double(posZ)); - f2 = block.slipperiness * 0.91F; - } + if (onGround) { + f2 = 0.54600006F; + Block block = worldObj.getBlock(MathHelper.floor_double(posX), MathHelper.floor_double(boundingBox.minY) - 1, MathHelper.floor_double(posZ)); + f2 = block.slipperiness * 0.91F; + } - float f3 = 0.16277136F / (f2 * f2 * f2); - moveFlying(par1, par2, onGround ? 0.1F * f3 : 0.02F); - f2 = 0.91F; + float f3 = 0.16277136F / (f2 * f2 * f2); + moveFlying(par1, par2, onGround ? 0.1F * f3 : 0.02F); + f2 = 0.91F; - if (onGround) { - f2 = 0.54600006F; - Block block = worldObj.getBlock( - MathHelper.floor_double(posX), - MathHelper.floor_double(boundingBox.minY) - 1, - MathHelper.floor_double(posZ)); - f2 = block.slipperiness * 0.91F; - } + if (onGround) { + f2 = 0.54600006F; + Block block = worldObj.getBlock(MathHelper.floor_double(posX), MathHelper.floor_double(boundingBox.minY) - 1, MathHelper.floor_double(posZ)); + f2 = block.slipperiness * 0.91F; + } - moveEntity(motionX, motionY, motionZ); - motionX *= f2; - motionY *= f2; - motionZ *= f2; - } + moveEntity(motionX, motionY, motionZ); + motionX *= f2; + motionY *= f2; + motionZ *= f2; + } - prevLimbSwingAmount = limbSwingAmount; - double d0 = posX - prevPosX; - double d1 = posZ - prevPosZ; - float f4 = MathHelper.sqrt_double(d0 * d0 + d1 * d1) * 4.0F; + prevLimbSwingAmount = limbSwingAmount; + double d0 = posX - prevPosX; + double d1 = posZ - prevPosZ; + float f4 = MathHelper.sqrt_double(d0 * d0 + d1 * d1) * 4.0F; - if (f4 > 1.0F) f4 = 1.0F; + if(f4 > 1.0F) + f4 = 1.0F; - limbSwingAmount += (f4 - limbSwingAmount) * 0.4F; - limbSwing += limbSwingAmount; - } + limbSwingAmount += (f4 - limbSwingAmount) * 0.4F; + limbSwing += limbSwingAmount; + } - @Override - public boolean isOnLadder() { - return false; - } -} + @Override + public boolean isOnLadder() { + return false; + } +} \ No newline at end of file diff --git a/src/main/java/vazkii/botania/common/entity/EntityMagicLandmine.java b/src/main/java/vazkii/botania/common/entity/EntityMagicLandmine.java index ab6304449a..8d56c4336a 100644 --- a/src/main/java/vazkii/botania/common/entity/EntityMagicLandmine.java +++ b/src/main/java/vazkii/botania/common/entity/EntityMagicLandmine.java @@ -2,15 +2,16 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jul 12, 2014, 7:59:00 PM (GMT)] */ package vazkii.botania.common.entity; import java.util.List; + import net.minecraft.entity.Entity; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.nbt.NBTTagCompound; @@ -23,84 +24,63 @@ public class EntityMagicLandmine extends Entity { - public EntityDoppleganger summoner; - - public EntityMagicLandmine(World par1World) { - super(par1World); - setSize(0F, 0F); - } - - @Override - public void onUpdate() { - motionX = 0; - motionY = 0; - motionZ = 0; - super.onUpdate(); - - float range = 2.5F; - - float r = 0.2F; - float g = 0F; - float b = 0.2F; - - // Botania.proxy.wispFX(worldObj, posX, posY, posZ, r, g, b, 0.6F, -0.2F, 1); - for (int i = 0; i < 6; i++) - Botania.proxy.wispFX( - worldObj, - posX - range + Math.random() * range * 2, - posY, - posZ - range + Math.random() * range * 2, - r, - g, - b, - 0.4F, - -0.015F, - 1); - - if (ticksExisted >= 55) { - worldObj.playSoundEffect(posX, posY, posZ, "botania:gaiaTrap", 0.3F, 1F); - - float m = 0.35F; - g = 0.4F; - for (int i = 0; i < 25; i++) - Botania.proxy.wispFX( - worldObj, - posX, - posY + 1, - posZ, - r, - g, - b, - 0.5F, - (float) (Math.random() - 0.5F) * m, - (float) (Math.random() - 0.5F) * m, - (float) (Math.random() - 0.5F) * m); - - if (!worldObj.isRemote) { - List players = worldObj.getEntitiesWithinAABB( - EntityPlayer.class, - AxisAlignedBB.getBoundingBox( - posX - range, posY - range, posZ - range, posX + range, posY + range, posZ + range)); - for (EntityPlayer player : players) { - player.attackEntityFrom( - summoner == null ? DamageSource.generic : DamageSource.causeMobDamage(summoner), 10); - player.addPotionEffect(new PotionEffect(Potion.blindness.id, 25, 0)); - PotionEffect wither = new PotionEffect(Potion.wither.id, 70, 3); - wither.getCurativeItems().clear(); - player.addPotionEffect(wither); - } - } - - setDead(); - } - } - - @Override - protected void entityInit() {} - - @Override - protected void readEntityFromNBT(NBTTagCompound var1) {} - - @Override - protected void writeEntityToNBT(NBTTagCompound var1) {} + public EntityDoppleganger summoner; + + public EntityMagicLandmine(World par1World) { + super(par1World); + setSize(0F, 0F); + } + + @Override + public void onUpdate() { + motionX = 0; + motionY = 0; + motionZ = 0; + super.onUpdate(); + + float range = 2.5F; + + float r = 0.2F; + float g = 0F; + float b = 0.2F; + + //Botania.proxy.wispFX(worldObj, posX, posY, posZ, r, g, b, 0.6F, -0.2F, 1); + for(int i = 0; i < 6; i++) + Botania.proxy.wispFX(worldObj, posX - range + Math.random() * range * 2, posY, posZ - range + Math.random() * range * 2, r, g, b, 0.4F, -0.015F, 1); + + if(ticksExisted >= 55) { + worldObj.playSoundEffect(posX, posY, posZ, "botania:gaiaTrap", 0.3F, 1F); + + float m = 0.35F; + g = 0.4F; + for(int i = 0; i < 25; i++) + Botania.proxy.wispFX(worldObj, posX, posY + 1, posZ, r, g, b, 0.5F, (float) (Math.random() - 0.5F) * m, (float) (Math.random() - 0.5F) * m, (float) (Math.random() - 0.5F) * m); + + if(!worldObj.isRemote) { + List players = worldObj.getEntitiesWithinAABB(EntityPlayer.class, AxisAlignedBB.getBoundingBox(posX - range, posY - range, posZ - range, posX + range, posY + range, posZ + range)); + for(EntityPlayer player : players) { + player.attackEntityFrom(summoner == null ? DamageSource.generic : DamageSource.causeMobDamage(summoner), 10); + player.addPotionEffect(new PotionEffect(Potion.blindness.id, 25, 0)); + PotionEffect wither = new PotionEffect(Potion.wither.id, 70, 3); + wither.getCurativeItems().clear(); + player.addPotionEffect(wither); + } + } + + setDead(); + } + } + + @Override + protected void entityInit() { + } + + @Override + protected void readEntityFromNBT(NBTTagCompound var1) { + } + + @Override + protected void writeEntityToNBT(NBTTagCompound var1) { + } + } diff --git a/src/main/java/vazkii/botania/common/entity/EntityMagicMissile.java b/src/main/java/vazkii/botania/common/entity/EntityMagicMissile.java index a232768b25..88fda7c892 100644 --- a/src/main/java/vazkii/botania/common/entity/EntityMagicMissile.java +++ b/src/main/java/vazkii/botania/common/entity/EntityMagicMissile.java @@ -2,16 +2,16 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Nov 24, 2014, 5:58:22 PM (GMT)] */ package vazkii.botania.common.entity; -import cpw.mods.fml.relauncher.ReflectionHelper; import java.util.List; + import net.minecraft.block.Block; import net.minecraft.block.BlockBush; import net.minecraft.block.BlockLeaves; @@ -28,176 +28,162 @@ import vazkii.botania.common.Botania; import vazkii.botania.common.core.helper.Vector3; import vazkii.botania.common.lib.LibObfuscation; +import cpw.mods.fml.relauncher.ReflectionHelper; public class EntityMagicMissile extends EntityThrowable { - private static final String TAG_TIME = "time"; - - double lockX, lockY = -1, lockZ; - int time = 0; - - public EntityMagicMissile(World world) { - super(world); - setSize(0F, 0F); - } - - public EntityMagicMissile(EntityLivingBase thrower, boolean evil) { - this(thrower.worldObj); - ReflectionHelper.setPrivateValue(EntityThrowable.class, this, thrower, LibObfuscation.THROWER); - setEvil(evil); - } - - @Override - protected void entityInit() { - dataWatcher.addObject(25, (byte) 0); - dataWatcher.addObject(26, 0); - } - - public void setEvil(boolean evil) { - dataWatcher.updateObject(25, (byte) (evil ? 1 : 0)); - } - - public boolean isEvil() { - return dataWatcher.getWatchableObjectByte(25) == 1; - } - - public void setTarget(EntityLivingBase e) { - dataWatcher.updateObject(26, e == null ? -1 : e.getEntityId()); - } - - public EntityLivingBase getTargetEntity() { - int id = dataWatcher.getWatchableObjectInt(26); - Entity e = worldObj.getEntityByID(id); - if (e != null && e instanceof EntityLivingBase) return (EntityLivingBase) e; - - return null; - } - - @Override - public void onUpdate() { - double lastTickPosX = this.lastTickPosX; - double lastTickPosY = this.lastTickPosY; - double lastTickPosZ = this.lastTickPosZ; - - super.onUpdate(); - - if (!worldObj.isRemote && (!getTarget() || time > 40)) { - setDead(); - return; - } - - boolean evil = isEvil(); - Vector3 thisVec = Vector3.fromEntityCenter(this); - Vector3 oldPos = new Vector3(lastTickPosX, lastTickPosY, lastTickPosZ); - Vector3 diff = thisVec.copy().sub(oldPos); - Vector3 step = diff.copy().normalize().multiply(0.05); - int steps = (int) (diff.mag() / step.mag()); - Vector3 particlePos = oldPos.copy(); - - Botania.proxy.setSparkleFXCorrupt(evil); - for (int i = 0; i < steps; i++) { - Botania.proxy.sparkleFX( - worldObj, particlePos.x, particlePos.y, particlePos.z, 1F, evil ? 0F : 0.4F, 1F, 0.8F, 2); - if (worldObj.rand.nextInt(steps) <= 1) - Botania.proxy.sparkleFX( - worldObj, - particlePos.x + (Math.random() - 0.5) * 0.4, - particlePos.y + (Math.random() - 0.5) * 0.4, - particlePos.z + (Math.random() - 0.5) * 0.4, - 1F, - evil ? 0F : 0.4F, - 1F, - 0.8F, - 2); - - particlePos.add(step); - } - Botania.proxy.setSparkleFXCorrupt(false); - - EntityLivingBase target = getTargetEntity(); - if (target != null) { - if (lockY == -1) { - lockX = target.posX; - lockY = target.posY; - lockZ = target.posZ; - } - - Vector3 targetVec = evil ? new Vector3(lockX, lockY, lockZ) : Vector3.fromEntityCenter(target); - Vector3 diffVec = targetVec.copy().sub(thisVec); - Vector3 motionVec = diffVec.copy().normalize().multiply(evil ? 0.5 : 0.6); - motionX = motionVec.x; - motionY = motionVec.y; - if (time < 10) motionY = Math.abs(motionY); - motionZ = motionVec.z; - - List targetList = worldObj.getEntitiesWithinAABB( - EntityLivingBase.class, - AxisAlignedBB.getBoundingBox( - posX - 0.5, posY - 0.5, posZ - 0.5, posX + 0.5, posY + 0.5, posZ + 0.5)); - if (targetList.contains(target) && target != null) { - EntityLivingBase thrower = getThrower(); - if (thrower != null) { - EntityPlayer player = thrower instanceof EntityPlayer ? (EntityPlayer) thrower : null; - target.attackEntityFrom( - player == null - ? DamageSource.causeMobDamage(thrower) - : DamageSource.causePlayerDamage(player), - evil ? 12 : 7); - } else target.attackEntityFrom(DamageSource.generic, evil ? 12 : 7); - - setDead(); - } - - if (evil && diffVec.mag() < 1) setDead(); - } - - time++; - } - - @Override - public void writeEntityToNBT(NBTTagCompound cmp) { - super.writeEntityToNBT(cmp); - cmp.setInteger(TAG_TIME, time); - } - - @Override - public void readEntityFromNBT(NBTTagCompound cmp) { - super.readEntityFromNBT(cmp); - time = cmp.getInteger(TAG_TIME); - } - - public boolean getTarget() { - EntityLivingBase target = getTargetEntity(); - if (target != null && target.getHealth() > 0 && !target.isDead && worldObj.loadedEntityList.contains(target)) - return true; - if (target != null) setTarget(null); - - double range = 12; - List entities = worldObj.getEntitiesWithinAABB( - isEvil() ? EntityPlayer.class : IMob.class, - AxisAlignedBB.getBoundingBox( - posX - range, posY - range, posZ - range, posX + range, posY + range, posZ + range)); - while (entities.size() > 0) { - Entity e = (Entity) entities.get(worldObj.rand.nextInt(entities.size())); - if (!(e instanceof EntityLivingBase) || e.isDead) { // Just in case... - entities.remove(e); - continue; - } - - target = (EntityLivingBase) e; - setTarget(target); - break; - } - - return target != null; - } - - @Override - protected void onImpact(MovingObjectPosition pos) { - Block block = worldObj.getBlock(pos.blockX, pos.blockY, pos.blockZ); - - if (!(block instanceof BlockBush) - && !(block instanceof BlockLeaves) - && (pos.entityHit == null || getTargetEntity() == pos.entityHit)) setDead(); - } + private static final String TAG_TIME = "time"; + + double lockX, lockY = -1, lockZ; + int time = 0; + + public EntityMagicMissile(World world) { + super(world); + setSize(0F, 0F); + } + + public EntityMagicMissile(EntityLivingBase thrower, boolean evil) { + this(thrower.worldObj); + ReflectionHelper.setPrivateValue(EntityThrowable.class, this, thrower, LibObfuscation.THROWER); + setEvil(evil); + } + + @Override + protected void entityInit() { + dataWatcher.addObject(25, (byte) 0); + dataWatcher.addObject(26, 0); + } + + public void setEvil(boolean evil) { + dataWatcher.updateObject(25, (byte) (evil ? 1 : 0)); + } + + public boolean isEvil() { + return dataWatcher.getWatchableObjectByte(25) == 1; + } + + public void setTarget(EntityLivingBase e) { + dataWatcher.updateObject(26, e == null ? -1 : e.getEntityId()); + } + + public EntityLivingBase getTargetEntity() { + int id = dataWatcher.getWatchableObjectInt(26); + Entity e = worldObj.getEntityByID(id); + if(e != null && e instanceof EntityLivingBase) + return (EntityLivingBase) e; + + return null; + } + + @Override + public void onUpdate() { + double lastTickPosX = this.lastTickPosX; + double lastTickPosY = this.lastTickPosY; + double lastTickPosZ = this.lastTickPosZ; + + super.onUpdate(); + + if(!worldObj.isRemote && (!getTarget() || time > 40)) { + setDead(); + return; + } + + boolean evil = isEvil(); + Vector3 thisVec = Vector3.fromEntityCenter(this); + Vector3 oldPos = new Vector3(lastTickPosX, lastTickPosY, lastTickPosZ); + Vector3 diff = thisVec.copy().sub(oldPos); + Vector3 step = diff.copy().normalize().multiply(0.05); + int steps = (int) (diff.mag() / step.mag()); + Vector3 particlePos = oldPos.copy(); + + Botania.proxy.setSparkleFXCorrupt(evil); + for(int i = 0; i < steps; i++) { + Botania.proxy.sparkleFX(worldObj, particlePos.x, particlePos.y, particlePos.z, 1F, evil ? 0F : 0.4F, 1F, 0.8F, 2); + if(worldObj.rand.nextInt(steps) <= 1) + Botania.proxy.sparkleFX(worldObj, particlePos.x + (Math.random() - 0.5) * 0.4, particlePos.y + (Math.random() - 0.5) * 0.4, particlePos.z + (Math.random() - 0.5) * 0.4, 1F, evil ? 0F : 0.4F, 1F, 0.8F, 2); + + particlePos.add(step); + } + Botania.proxy.setSparkleFXCorrupt(false); + + EntityLivingBase target = getTargetEntity(); + if(target != null) { + if(lockY == -1) { + lockX = target.posX; + lockY = target.posY; + lockZ = target.posZ; + } + + Vector3 targetVec = evil ? new Vector3(lockX, lockY, lockZ) : Vector3.fromEntityCenter(target); + Vector3 diffVec = targetVec.copy().sub(thisVec); + Vector3 motionVec = diffVec.copy().normalize().multiply(evil ? 0.5 : 0.6); + motionX = motionVec.x; + motionY = motionVec.y; + if(time < 10) + motionY = Math.abs(motionY); + motionZ = motionVec.z; + + List targetList = worldObj.getEntitiesWithinAABB(EntityLivingBase.class, AxisAlignedBB.getBoundingBox(posX - 0.5, posY - 0.5, posZ - 0.5, posX + 0.5, posY + 0.5, posZ + 0.5)); + if(targetList.contains(target) && target != null) { + EntityLivingBase thrower = getThrower(); + if(thrower != null) { + EntityPlayer player = thrower instanceof EntityPlayer ? (EntityPlayer) thrower : null; + target.attackEntityFrom(player == null ? DamageSource.causeMobDamage(thrower) : DamageSource.causePlayerDamage(player), evil ? 12 : 7); + } else target.attackEntityFrom(DamageSource.generic, evil ? 12 : 7); + + setDead(); + } + + if(evil && diffVec.mag() < 1) + setDead(); + } + + time++; + } + + @Override + public void writeEntityToNBT(NBTTagCompound cmp) { + super.writeEntityToNBT(cmp); + cmp.setInteger(TAG_TIME, time); + } + + @Override + public void readEntityFromNBT(NBTTagCompound cmp) { + super.readEntityFromNBT(cmp); + time = cmp.getInteger(TAG_TIME); + } + + + public boolean getTarget() { + EntityLivingBase target = getTargetEntity(); + if(target != null && target.getHealth() > 0 && !target.isDead && worldObj.loadedEntityList.contains(target)) + return true; + if(target != null) + setTarget(null); + + double range = 12; + List entities = worldObj.getEntitiesWithinAABB(isEvil() ? EntityPlayer.class : IMob.class, AxisAlignedBB.getBoundingBox(posX - range, posY - range, posZ - range, posX + range, posY + range, posZ + range)); + while(entities.size() > 0) { + Entity e = (Entity) entities.get(worldObj.rand.nextInt(entities.size())); + if(!(e instanceof EntityLivingBase) || e.isDead) { // Just in case... + entities.remove(e); + continue; + } + + target = (EntityLivingBase) e; + setTarget(target); + break; + } + + return target != null; + } + + @Override + protected void onImpact(MovingObjectPosition pos) { + Block block = worldObj.getBlock(pos.blockX, pos.blockY, pos.blockZ); + + if(!(block instanceof BlockBush) && !(block instanceof BlockLeaves) && (pos.entityHit == null || getTargetEntity() == pos.entityHit)) + setDead(); + } + } diff --git a/src/main/java/vazkii/botania/common/entity/EntityManaBurst.java b/src/main/java/vazkii/botania/common/entity/EntityManaBurst.java index b05119e940..c51478a19b 100644 --- a/src/main/java/vazkii/botania/common/entity/EntityManaBurst.java +++ b/src/main/java/vazkii/botania/common/entity/EntityManaBurst.java @@ -2,21 +2,20 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jan 26, 2014, 5:09:12 PM (GMT)] */ package vazkii.botania.common.entity; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; import java.awt.Color; import java.util.ArrayList; import java.util.List; import java.util.Random; import java.util.UUID; + import net.minecraft.block.Block; import net.minecraft.block.BlockBush; import net.minecraft.block.BlockLeaves; @@ -50,914 +49,846 @@ import vazkii.botania.common.core.handler.ConfigHandler; import vazkii.botania.common.core.helper.Vector3; import vazkii.botania.common.item.equipment.bauble.ItemTinyPlanet; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; public class EntityManaBurst extends EntityThrowable implements IManaBurst { - private static final String TAG_TICKS_EXISTED = "ticksExisted"; - private static final String TAG_COLOR = "color"; - private static final String TAG_MANA = "mana"; - private static final String TAG_STARTING_MANA = "startingMana"; - private static final String TAG_MIN_MANA_LOSS = "minManaLoss"; - private static final String TAG_TICK_MANA_LOSS = "manaLossTick"; - private static final String TAG_SPREADER_X = "spreaderX"; - private static final String TAG_SPREADER_Y = "spreaderY"; - private static final String TAG_SPREADER_Z = "spreaderZ"; - private static final String TAG_GRAVITY = "gravity"; - private static final String TAG_LENS_STACK = "lensStack"; - private static final String TAG_LAST_MOTION_X = "lastMotionX"; - private static final String TAG_LAST_MOTION_Y = "lastMotionY"; - private static final String TAG_LAST_MOTION_Z = "lastMotionZ"; - private static final String TAG_HAS_SHOOTER = "hasShooter"; - private static final String TAG_SHOOTER_UUID_MOST = "shooterUUIDMost"; - private static final String TAG_SHOOTER_UUID_LEAST = "shooterUUIDLeast"; - - boolean fake = false; - - final int dataWatcherEntries = 10; - final int dataWatcherStart = 32 - dataWatcherEntries; - - List alreadyCollidedAt = new ArrayList(); - - boolean fullManaLastTick = true; - - UUID shooterIdentity = null; - int _ticksExisted = 0; - boolean scanBeam = false; - public List propsList = new ArrayList(); - - public EntityManaBurst(World world) { - super(world); - setSize(0F, 0F); - for (int i = 0; i < dataWatcherEntries; i++) { - int j = dataWatcherStart + i; - if (i == 4 || i == 5) dataWatcher.addObject(j, 0F); - else if (i == 9) dataWatcher.addObject(j, new ItemStack(Blocks.stone, 0, 0)); - else dataWatcher.addObject(j, 0); - - dataWatcher.setObjectWatched(j); - } - } - - public EntityManaBurst(IManaSpreader spreader, boolean fake) { - this(((TileEntity) spreader).getWorldObj()); - - TileEntity tile = (TileEntity) spreader; - - this.fake = fake; - - setBurstSourceCoords(tile.xCoord, tile.yCoord, tile.zCoord); - setLocationAndAngles(tile.xCoord + 0.5, tile.yCoord + 0.5, tile.zCoord + 0.5, 0, 0); - rotationYaw = -(spreader.getRotationX() + 90F); - rotationPitch = spreader.getRotationY(); - - float f = 0.4F; - double mx = MathHelper.sin(rotationYaw / 180.0F * (float) Math.PI) - * MathHelper.cos(rotationPitch / 180.0F * (float) Math.PI) - * f - / 2D; - double mz = -(MathHelper.cos(rotationYaw / 180.0F * (float) Math.PI) - * MathHelper.cos(rotationPitch / 180.0F * (float) Math.PI) - * f) - / 2D; - double my = MathHelper.sin((rotationPitch + func_70183_g()) / 180.0F * (float) Math.PI) * f / 2D; - setMotion(mx, my, mz); - } - - public EntityManaBurst(EntityPlayer player) { - this(player.worldObj); - - setBurstSourceCoords(0, -1, 0); - setLocationAndAngles( - player.posX, - player.posY + player.getEyeHeight(), - player.posZ, - player.rotationYaw + 180, - -player.rotationPitch); - - posX -= MathHelper.cos((rotationYaw + 180) / 180.0F * (float) Math.PI) * 0.16F; - posY -= 0.10000000149011612D; - posZ -= MathHelper.sin((rotationYaw + 180) / 180.0F * (float) Math.PI) * 0.16F; - - setPosition(posX, posY, posZ); - yOffset = 0.0F; - float f = 0.4F; - double mx = MathHelper.sin(rotationYaw / 180.0F * (float) Math.PI) - * MathHelper.cos(rotationPitch / 180.0F * (float) Math.PI) - * f - / 2D; - double mz = -(MathHelper.cos(rotationYaw / 180.0F * (float) Math.PI) - * MathHelper.cos(rotationPitch / 180.0F * (float) Math.PI) - * f) - / 2D; - double my = MathHelper.sin((rotationPitch + func_70183_g()) / 180.0F * (float) Math.PI) * f / 2D; - setMotion(mx, my, mz); - } - - float accumulatedManaLoss = 0; - - private int ticksInAir; - - // Hacked code copied from super.onUpdate, to use Vector3 rather than the world vector pool - public void superUpdate() { - lastTickPosX = posX; - lastTickPosY = posY; - lastTickPosZ = posZ; - onEntityUpdate(); - - if (throwableShake > 0) --throwableShake; - - Vec3 vec3 = new Vector3(posX, posY, posZ).toVec3D(); - Vec3 vec31 = new Vector3(posX + motionX, posY + motionY, posZ + motionZ).toVec3D(); - MovingObjectPosition movingobjectposition = clip(vec3, vec31); - - if (movingobjectposition != null) - vec31 = new Vector3( - movingobjectposition.hitVec.xCoord, - movingobjectposition.hitVec.yCoord, - movingobjectposition.hitVec.zCoord) - .toVec3D(); - - if (!worldObj.isRemote) { - Entity entity = null; - List list = worldObj.getEntitiesWithinAABBExcludingEntity( - this, boundingBox.addCoord(motionX, motionY, motionZ).expand(1.0D, 1.0D, 1.0D)); - double d0 = 0.0D; - EntityLivingBase entitylivingbase = getThrower(); - - for (int j = 0; j < list.size(); ++j) { - Entity entity1 = (Entity) list.get(j); - - if (entity1.canBeCollidedWith() && (entity1 != entitylivingbase || ticksInAir >= 5)) { - float f = 0.3F; - AxisAlignedBB axisalignedbb = entity1.boundingBox.expand(f, f, f); - MovingObjectPosition movingobjectposition1 = axisalignedbb.calculateIntercept(vec3, vec31); - - if (movingobjectposition1 != null) { - double d1 = vec3.distanceTo(movingobjectposition1.hitVec); - - if (d1 < d0 || d0 == 0.0D) { - entity = entity1; - d0 = d1; - } - } - } - } - - if (entity != null) movingobjectposition = new MovingObjectPosition(entity); - } - - if (movingobjectposition != null) onImpact(movingobjectposition); - - posX += motionX; - posY += motionY; - posZ += motionZ; - float f1 = MathHelper.sqrt_double(motionX * motionX + motionZ * motionZ); - rotationYaw = (float) (Math.atan2(motionX, motionZ) * 180.0D / Math.PI); - - for (rotationPitch = (float) (Math.atan2(motionY, f1) * 180.0D / Math.PI); - rotationPitch - prevRotationPitch < -180.0F; - prevRotationPitch -= 360.0F) - ; - - while (rotationPitch - prevRotationPitch >= 180.0F) prevRotationPitch += 360.0F; - - while (rotationYaw - prevRotationYaw < -180.0F) prevRotationYaw -= 360.0F; - - while (rotationYaw - prevRotationYaw >= 180.0F) prevRotationYaw += 360.0F; - - rotationPitch = prevRotationPitch + (rotationPitch - prevRotationPitch) * 0.2F; - rotationYaw = prevRotationYaw + (rotationYaw - prevRotationYaw) * 0.2F; - float f3 = getGravityVelocity(); - - motionY -= f3; - setPosition(posX, posY, posZ); - } - - public MovingObjectPosition clip(Vec3 par1Vec3, Vec3 par2Vec3) { - boolean par3 = false; - boolean par4 = false; - if (!Double.isNaN(par1Vec3.xCoord) && !Double.isNaN(par1Vec3.yCoord) && !Double.isNaN(par1Vec3.zCoord)) { - if (!Double.isNaN(par2Vec3.xCoord) && !Double.isNaN(par2Vec3.yCoord) && !Double.isNaN(par2Vec3.zCoord)) { - int i = MathHelper.floor_double(par2Vec3.xCoord); - int j = MathHelper.floor_double(par2Vec3.yCoord); - int k = MathHelper.floor_double(par2Vec3.zCoord); - int l = MathHelper.floor_double(par1Vec3.xCoord); - int i1 = MathHelper.floor_double(par1Vec3.yCoord); - int j1 = MathHelper.floor_double(par1Vec3.zCoord); - Block block = worldObj.getBlock(l, i1, j1); - int l1 = worldObj.getBlockMetadata(l, i1, j1); - - if (block != null - && (!par4 - || block == null - || block.getCollisionBoundingBoxFromPool(worldObj, l, i1, j1) != null) - && block != Blocks.air - && block.canCollideCheck(l1, par3)) { - MovingObjectPosition movingobjectposition = - block.collisionRayTrace(worldObj, l, i1, j1, par1Vec3, par2Vec3); - - if (movingobjectposition != null) return movingobjectposition; - } - - int k1 = 200; - - while (k1-- >= 0) { - if (Double.isNaN(par1Vec3.xCoord) || Double.isNaN(par1Vec3.yCoord) || Double.isNaN(par1Vec3.zCoord)) - return null; - - if (l == i && i1 == j && j1 == k) return null; - - boolean flag2 = true; - boolean flag3 = true; - boolean flag4 = true; - double d0 = 999.0D; - double d1 = 999.0D; - double d2 = 999.0D; - - if (i > l) d0 = l + 1.0D; - else if (i < l) d0 = l + 0.0D; - else flag2 = false; - - if (j > i1) d1 = i1 + 1.0D; - else if (j < i1) d1 = i1 + 0.0D; - else flag3 = false; - - if (k > j1) d2 = j1 + 1.0D; - else if (k < j1) d2 = j1 + 0.0D; - else flag4 = false; - - double d3 = 999.0D; - double d4 = 999.0D; - double d5 = 999.0D; - double d6 = par2Vec3.xCoord - par1Vec3.xCoord; - double d7 = par2Vec3.yCoord - par1Vec3.yCoord; - double d8 = par2Vec3.zCoord - par1Vec3.zCoord; - - if (flag2) d3 = (d0 - par1Vec3.xCoord) / d6; - - if (flag3) d4 = (d1 - par1Vec3.yCoord) / d7; - - if (flag4) d5 = (d2 - par1Vec3.zCoord) / d8; - - byte b0; - - if (d3 < d4 && d3 < d5) { - if (i > l) b0 = 4; - else b0 = 5; - - par1Vec3.xCoord = d0; - par1Vec3.yCoord += d7 * d3; - par1Vec3.zCoord += d8 * d3; - } else if (d4 < d5) { - if (j > i1) b0 = 0; - else b0 = 1; - - par1Vec3.xCoord += d6 * d4; - par1Vec3.yCoord = d1; - par1Vec3.zCoord += d8 * d4; - } else { - if (k > j1) b0 = 2; - else b0 = 3; - - par1Vec3.xCoord += d6 * d5; - par1Vec3.yCoord += d7 * d5; - par1Vec3.zCoord = d2; - } - - Vec3 vec32 = new Vector3(par1Vec3.xCoord, par1Vec3.yCoord, par1Vec3.zCoord).toVec3D(); - l = (int) (vec32.xCoord = MathHelper.floor_double(par1Vec3.xCoord)); - - if (b0 == 5) { - --l; - ++vec32.xCoord; - } - - i1 = (int) (vec32.yCoord = MathHelper.floor_double(par1Vec3.yCoord)); - - if (b0 == 1) { - --i1; - ++vec32.yCoord; - } - - j1 = (int) (vec32.zCoord = MathHelper.floor_double(par1Vec3.zCoord)); - - if (b0 == 3) { - --j1; - ++vec32.zCoord; - } - - Block block1 = worldObj.getBlock(l, i1, j1); - int j2 = worldObj.getBlockMetadata(l, i1, j1); - - if ((!par4 || block1 == null || block1.getCollisionBoundingBoxFromPool(worldObj, l, i1, j1) != null) - && block1 != Blocks.air - && block1.canCollideCheck(j2, par3)) { - MovingObjectPosition movingobjectposition1 = - block1.collisionRayTrace(worldObj, l, i1, j1, par1Vec3, par2Vec3); - - if (movingobjectposition1 != null) return movingobjectposition1; - } - } - - return null; - } else return null; - } else return null; - } - - @Override - public void onUpdate() { - setTicksExisted(getTicksExisted() + 1); - superUpdate(); - - if (!fake && !isDead) ping(); - - ILensEffect lens = getLensInstance(); - if (lens != null) lens.updateBurst(this, getSourceLens()); - - int mana = getMana(); - if (getTicksExisted() >= getMinManaLoss()) { - accumulatedManaLoss += getManaLossPerTick(); - int loss = (int) accumulatedManaLoss; - setMana(mana - loss); - accumulatedManaLoss -= loss; - - if (getMana() <= 0) setDead(); - } - - particles(); - - setMotion(motionX, motionY, motionZ); - - fullManaLastTick = getMana() == getStartingMana(); - - if (scanBeam) { - PositionProperties props = new PositionProperties(this); - if (propsList.isEmpty()) propsList.add(props); - else { - PositionProperties lastProps = propsList.get(propsList.size() - 1); - if (!props.coordsEqual(lastProps)) propsList.add(props); - } - } - } - - @Override - @SideOnly(Side.CLIENT) - public void setPositionAndRotation2( - double p_70056_1_, - double p_70056_3_, - double p_70056_5_, - float p_70056_7_, - float p_70056_8_, - int p_70056_9_) { - setPosition(p_70056_1_, p_70056_3_, p_70056_5_); - setRotation(p_70056_7_, p_70056_8_); - } - - @Override - public boolean handleWaterMovement() { - return false; - } - - public TileEntity collidedTile = null; - public boolean noParticles = false; - - public TileEntity getCollidedTile(boolean noParticles) { - this.noParticles = noParticles; - - while (!isDead) onUpdate(); - - if (fake) incrementFakeParticleTick(); - - return collidedTile; - } - - @Override - public void writeEntityToNBT(NBTTagCompound par1nbtTagCompound) { - super.writeEntityToNBT(par1nbtTagCompound); - par1nbtTagCompound.setInteger(TAG_TICKS_EXISTED, getTicksExisted()); - par1nbtTagCompound.setInteger(TAG_COLOR, getColor()); - par1nbtTagCompound.setInteger(TAG_MANA, getMana()); - par1nbtTagCompound.setInteger(TAG_STARTING_MANA, getStartingMana()); - par1nbtTagCompound.setInteger(TAG_MIN_MANA_LOSS, getMinManaLoss()); - par1nbtTagCompound.setFloat(TAG_TICK_MANA_LOSS, getManaLossPerTick()); - par1nbtTagCompound.setFloat(TAG_GRAVITY, getGravity()); - - ItemStack stack = getSourceLens(); - NBTTagCompound lensCmp = new NBTTagCompound(); - if (stack != null) stack.writeToNBT(lensCmp); - par1nbtTagCompound.setTag(TAG_LENS_STACK, lensCmp); - - ChunkCoordinates coords = getBurstSourceChunkCoordinates(); - par1nbtTagCompound.setInteger(TAG_SPREADER_X, coords.posX); - par1nbtTagCompound.setInteger(TAG_SPREADER_Y, coords.posY); - par1nbtTagCompound.setInteger(TAG_SPREADER_Z, coords.posZ); - - par1nbtTagCompound.setDouble(TAG_LAST_MOTION_X, motionX); - par1nbtTagCompound.setDouble(TAG_LAST_MOTION_Y, motionY); - par1nbtTagCompound.setDouble(TAG_LAST_MOTION_Z, motionZ); - - UUID identity = getShooterUIID(); - boolean hasShooter = identity != null; - par1nbtTagCompound.setBoolean(TAG_HAS_SHOOTER, hasShooter); - if (hasShooter) { - par1nbtTagCompound.setLong(TAG_SHOOTER_UUID_MOST, identity.getMostSignificantBits()); - par1nbtTagCompound.setLong(TAG_SHOOTER_UUID_LEAST, identity.getLeastSignificantBits()); - } - } - - @Override - public void readEntityFromNBT(NBTTagCompound par1nbtTagCompound) { - super.readEntityFromNBT(par1nbtTagCompound); - setTicksExisted(par1nbtTagCompound.getInteger(TAG_TICKS_EXISTED)); - setColor(par1nbtTagCompound.getInteger(TAG_COLOR)); - setMana(par1nbtTagCompound.getInteger(TAG_MANA)); - setStartingMana(par1nbtTagCompound.getInteger(TAG_STARTING_MANA)); - setMinManaLoss(par1nbtTagCompound.getInteger(TAG_MIN_MANA_LOSS)); - setManaLossPerTick(par1nbtTagCompound.getFloat(TAG_TICK_MANA_LOSS)); - setGravity(par1nbtTagCompound.getFloat(TAG_GRAVITY)); - - NBTTagCompound lensCmp = par1nbtTagCompound.getCompoundTag(TAG_LENS_STACK); - ItemStack stack = ItemStack.loadItemStackFromNBT(lensCmp); - if (stack != null) setSourceLens(stack); - else setSourceLens(new ItemStack(Blocks.stone, 0, 0)); - - int x = par1nbtTagCompound.getInteger(TAG_SPREADER_X); - int y = par1nbtTagCompound.getInteger(TAG_SPREADER_Y); - int z = par1nbtTagCompound.getInteger(TAG_SPREADER_Z); - - setBurstSourceCoords(x, y, z); - - double lastMotionX = par1nbtTagCompound.getDouble(TAG_LAST_MOTION_X); - double lastMotionY = par1nbtTagCompound.getDouble(TAG_LAST_MOTION_Y); - double lastMotionZ = par1nbtTagCompound.getDouble(TAG_LAST_MOTION_Z); - - setMotion(lastMotionX, lastMotionY, lastMotionZ); - - boolean hasShooter = par1nbtTagCompound.getBoolean(TAG_HAS_SHOOTER); - if (hasShooter) { - long most = par1nbtTagCompound.getLong(TAG_SHOOTER_UUID_MOST); - long least = par1nbtTagCompound.getLong(TAG_SHOOTER_UUID_LEAST); - UUID identity = getShooterUIID(); - if (identity == null - || most != identity.getMostSignificantBits() - || least != identity.getLeastSignificantBits()) shooterIdentity = new UUID(most, least); - } - } - - public void particles() { - if (isDead || !worldObj.isRemote) return; - - ILensEffect lens = getLensInstance(); - if (lens != null && !lens.doParticles(this, getSourceLens())) return; - - Color color = new Color(getColor()); - float r = color.getRed() / 255F; - float g = color.getGreen() / 255F; - float b = color.getBlue() / 255F; - - int mana = getMana(); - int maxMana = getStartingMana(); - float osize = (float) mana / (float) maxMana; - float size = osize; - - if (fake) { - if (getMana() == getStartingMana()) size = 2F; - else if (fullManaLastTick) size = 4F; - - if (!noParticles && shouldDoFakeParticles()) - Botania.proxy.sparkleFX(worldObj, posX, posY, posZ, r, g, b, 0.4F * size, 1, true); - } else { - boolean monocle = Botania.proxy.isClientPlayerWearingMonocle(); - if (monocle) Botania.proxy.setWispFXDepthTest(false); - - if (ConfigHandler.subtlePowerSystem) - Botania.proxy.wispFX( - worldObj, - posX, - posY, - posZ, - r, - g, - b, - 0.1F * size, - (float) (Math.random() - 0.5F) * 0.02F, - (float) (Math.random() - 0.5F) * 0.02F, - (float) (Math.random() - 0.5F) * 0.01F); - else { - float or = r; - float og = g; - float ob = b; - - double savedPosX = posX; - double savedPosY = posY; - double savedPosZ = posZ; - - Vector3 currentPos = Vector3.fromEntity(this); - Vector3 oldPos = new Vector3(prevPosX, prevPosY, prevPosZ); - Vector3 diffVec = oldPos.copy().sub(currentPos); - Vector3 diffVecNorm = diffVec.copy().normalize(); - - double distance = 0.095; - - do { - r = or + ((float) Math.random() - 0.5F) * 0.25F; - g = og + ((float) Math.random() - 0.5F) * 0.25F; - b = ob + ((float) Math.random() - 0.5F) * 0.25F; - size = osize - + ((float) Math.random() - 0.5F) * 0.065F - + (float) Math.sin(new Random(entityUniqueID.getMostSignificantBits()).nextInt(9001)) - * 0.4F; - Botania.proxy.wispFX( - worldObj, - posX, - posY, - posZ, - r, - g, - b, - 0.2F * size, - (float) -motionX * 0.01F, - (float) -motionY * 0.01F, - (float) -motionZ * 0.01F); - - posX += diffVecNorm.x * distance; - posY += diffVecNorm.y * distance; - posZ += diffVecNorm.z * distance; - - currentPos = Vector3.fromEntity(this); - diffVec = oldPos.copy().sub(currentPos); - if (getEntityData().hasKey(ItemTinyPlanet.TAG_ORBIT)) break; - } while (Math.abs(diffVec.mag()) > distance); - - Botania.proxy.wispFX( - worldObj, - posX, - posY, - posZ, - r, - g, - b, - 0.1F * size, - (float) (Math.random() - 0.5F) * 0.06F, - (float) (Math.random() - 0.5F) * 0.06F, - (float) (Math.random() - 0.5F) * 0.06F); - - posX = savedPosX; - posY = savedPosY; - posZ = savedPosZ; - } - - if (monocle) Botania.proxy.setWispFXDepthTest(true); - } - } - - @Override - protected void onImpact(MovingObjectPosition movingobjectposition) { - boolean collided = false; - boolean dead = false; - - if (movingobjectposition.entityHit == null) { - TileEntity tile = worldObj.getTileEntity( - movingobjectposition.blockX, movingobjectposition.blockY, movingobjectposition.blockZ); - Block block = worldObj.getBlock( - movingobjectposition.blockX, movingobjectposition.blockY, movingobjectposition.blockZ); - - if (tile instanceof IManaCollisionGhost - && ((IManaCollisionGhost) tile).isGhost() - && !(block instanceof IManaTrigger) - || block instanceof BlockBush - || block instanceof BlockLeaves) return; - - if (BotaniaAPI.internalHandler.isBuildcraftPipe(tile)) return; - - ChunkCoordinates coords = getBurstSourceChunkCoordinates(); - if (tile != null - && (tile.xCoord != coords.posX || tile.yCoord != coords.posY || tile.zCoord != coords.posZ)) - collidedTile = tile; - - if (tile == null - || tile.xCoord != coords.posX - || tile.yCoord != coords.posY - || tile.zCoord != coords.posZ) { - if (!fake - && !noParticles - && (!worldObj.isRemote || tile instanceof IClientManaHandler) - && tile != null - && tile instanceof IManaReceiver - && ((IManaReceiver) tile).canRecieveManaFromBursts()) - onRecieverImpact((IManaReceiver) tile, tile.xCoord, tile.yCoord, tile.zCoord); - - if (block instanceof IManaTrigger) - ((IManaTrigger) block) - .onBurstCollision( - this, - worldObj, - movingobjectposition.blockX, - movingobjectposition.blockY, - movingobjectposition.blockZ); - - boolean ghost = tile instanceof IManaCollisionGhost; - dead = !ghost; - if (ghost) return; - } - - collided = true; - } - - ILensEffect lens = getLensInstance(); - if (lens != null) - dead = lens.collideBurst( - this, - movingobjectposition, - collidedTile != null - && collidedTile instanceof IManaReceiver - && ((IManaReceiver) collidedTile).canRecieveManaFromBursts(), - dead, - getSourceLens()); - - if (collided - && !hasAlreadyCollidedAt( - movingobjectposition.blockX, movingobjectposition.blockY, movingobjectposition.blockZ)) - alreadyCollidedAt.add(getCollisionLocString( - movingobjectposition.blockX, movingobjectposition.blockY, movingobjectposition.blockZ)); - - if (dead && !isDead) { - if (!fake) { - Color color = new Color(getColor()); - float r = color.getRed() / 255F; - float g = color.getGreen() / 255F; - float b = color.getBlue() / 255F; - - int mana = getMana(); - int maxMana = getStartingMana(); - float size = (float) mana / (float) maxMana; - - if (!ConfigHandler.subtlePowerSystem) - for (int i = 0; i < 4; i++) - Botania.proxy.wispFX( - worldObj, - posX, - posY, - posZ, - r, - g, - b, - 0.15F * size, - (float) (Math.random() - 0.5F) * 0.04F, - (float) (Math.random() - 0.5F) * 0.04F, - (float) (Math.random() - 0.5F) * 0.04F); - Botania.proxy.sparkleFX(worldObj, (float) posX, (float) posY, (float) posZ, r, g, b, 4, 2); - } - - setDead(); - } - } - - protected void onRecieverImpact(IManaReceiver tile, int x, int y, int z) { - int mana = getMana(); - if (tile instanceof IManaCollector) mana *= ((IManaCollector) tile).getManaYieldMultiplier(this); - - tile.recieveMana(mana); - if (tile instanceof IThrottledPacket) ((IThrottledPacket) tile).markDispatchable(); - else VanillaPacketDispatcher.dispatchTEToNearbyPlayers(worldObj, x, y, z); - } - - @Override - public void setDead() { - super.setDead(); - - if (!fake) { - TileEntity tile = getShooter(); - if (tile != null && tile instanceof IManaSpreader) ((IManaSpreader) tile).setCanShoot(true); - } else setDeathTicksForFakeParticle(); - } - - public TileEntity getShooter() { - ChunkCoordinates coords = getBurstSourceChunkCoordinates(); - TileEntity tile = worldObj.getTileEntity(coords.posX, coords.posY, coords.posZ); - return tile; - } - - @Override - protected float getGravityVelocity() { - return getGravity(); - } - - @Override - public boolean isFake() { - return fake; - } - - @Override - public void setFake(boolean fake) { - this.fake = fake; - } - - public void setScanBeam() { - scanBeam = true; - } - - @Override - public int getColor() { - return dataWatcher.getWatchableObjectInt(dataWatcherStart); - } - - @Override - public void setColor(int color) { - dataWatcher.updateObject(dataWatcherStart, color); - } - - @Override - public int getMana() { - return dataWatcher.getWatchableObjectInt(dataWatcherStart + 1); - } - - @Override - public void setMana(int mana) { - dataWatcher.updateObject(dataWatcherStart + 1, mana); - } - - @Override - public int getStartingMana() { - return dataWatcher.getWatchableObjectInt(dataWatcherStart + 2); - } - - @Override - public void setStartingMana(int mana) { - dataWatcher.updateObject(dataWatcherStart + 2, mana); - } - - @Override - public int getMinManaLoss() { - return dataWatcher.getWatchableObjectInt(dataWatcherStart + 3); - } - - @Override - public void setMinManaLoss(int minManaLoss) { - dataWatcher.updateObject(dataWatcherStart + 3, minManaLoss); - } - - @Override - public float getManaLossPerTick() { - return dataWatcher.getWatchableObjectFloat(dataWatcherStart + 4); - } - - @Override - public void setManaLossPerTick(float mana) { - dataWatcher.updateObject(dataWatcherStart + 4, mana); - } - - @Override - public float getGravity() { - return dataWatcher.getWatchableObjectFloat(dataWatcherStart + 5); - } - - @Override - public void setGravity(float gravity) { - dataWatcher.updateObject(dataWatcherStart + 5, gravity); - } - - final int coordsStart = dataWatcherStart + 6; - - @Override - public ChunkCoordinates getBurstSourceChunkCoordinates() { - int x = dataWatcher.getWatchableObjectInt(coordsStart); - int y = dataWatcher.getWatchableObjectInt(coordsStart + 1); - int z = dataWatcher.getWatchableObjectInt(coordsStart + 2); - - return new ChunkCoordinates(x, y, z); - } - - @Override - public void setBurstSourceCoords(int x, int y, int z) { - dataWatcher.updateObject(coordsStart, x); - dataWatcher.updateObject(coordsStart + 1, y); - dataWatcher.updateObject(coordsStart + 2, z); - } - - @Override - public ItemStack getSourceLens() { - return dataWatcher.getWatchableObjectItemStack(dataWatcherStart + 9); - } - - @Override - public void setSourceLens(ItemStack lens) { - dataWatcher.updateObject(dataWatcherStart + 9, lens == null ? new ItemStack(Blocks.stone, 0, 0) : lens); - } - - @Override - public int getTicksExisted() { - return _ticksExisted; - } - - public void setTicksExisted(int ticks) { - _ticksExisted = ticks; - } - - public ILensEffect getLensInstance() { - ItemStack lens = getSourceLens(); - if (lens != null && lens.getItem() instanceof ILensEffect) return (ILensEffect) lens.getItem(); - - return null; - } - - final int motionStart = dataWatcherStart + 10; - - @Override - public void setMotion(double x, double y, double z) { - motionX = x; - motionY = y; - motionZ = z; - } - - @Override - public boolean hasAlreadyCollidedAt(int x, int y, int z) { - return alreadyCollidedAt.contains(getCollisionLocString(x, y, z)); - } - - @Override - public void setCollidedAt(int x, int y, int z) { - if (!hasAlreadyCollidedAt(x, y, z)) alreadyCollidedAt.add(getCollisionLocString(x, y, z)); - } - - private String getCollisionLocString(int x, int y, int z) { - return x + ":" + y + ":" + z; - } - - @Override - public void setShooterUUID(UUID uuid) { - shooterIdentity = uuid; - } - - @Override - public UUID getShooterUIID() { - return shooterIdentity; - } - - @Override - public void ping() { - TileEntity tile = getShooter(); - if (tile != null && tile instanceof IPingable) ((IPingable) tile).pingback(this, getShooterUIID()); - } - - public boolean shouldDoFakeParticles() { - if (ConfigHandler.staticWandBeam) return true; - - TileEntity tile = getShooter(); - if (tile != null && tile instanceof IManaSpreader) - return getMana() != getStartingMana() && fullManaLastTick - || Math.abs(((IManaSpreader) tile).getBurstParticleTick() - getTicksExisted()) < 4; - return false; - } - - public void incrementFakeParticleTick() { - TileEntity tile = getShooter(); - if (tile != null && tile instanceof IManaSpreader) { - IManaSpreader spreader = (IManaSpreader) tile; - spreader.setBurstParticleTick(spreader.getBurstParticleTick() + 2); - if (spreader.getLastBurstDeathTick() != -1 - && spreader.getBurstParticleTick() > spreader.getLastBurstDeathTick()) - spreader.setBurstParticleTick(0); - } - } - - public void setDeathTicksForFakeParticle() { - ChunkCoordinates coords = getBurstSourceChunkCoordinates(); - TileEntity tile = worldObj.getTileEntity(coords.posX, coords.posY, coords.posZ); - if (tile != null && tile instanceof IManaSpreader) - ((IManaSpreader) tile).setLastBurstDeathTick(getTicksExisted()); - } - - public static class PositionProperties { - - public final ChunkCoordinates coords; - public final Block block; - public final int meta; - - public boolean invalid = false; - - public PositionProperties(Entity entity) { - int x = MathHelper.floor_double(entity.posX); - int y = MathHelper.floor_double(entity.posY); - int z = MathHelper.floor_double(entity.posZ); - coords = new ChunkCoordinates(x, y, z); - block = entity.worldObj.getBlock(x, y, z); - meta = entity.worldObj.getBlockMetadata(x, y, z); - } - - public boolean coordsEqual(PositionProperties props) { - return coords.equals(props.coords); - } - - public boolean contentsEqual(World world) { - if (!world.blockExists(coords.posX, coords.posY, coords.posZ)) { - invalid = true; - return false; - } - - Block block = world.getBlock(coords.posX, coords.posY, coords.posZ); - int meta = world.getBlockMetadata(coords.posX, coords.posY, coords.posZ); - return block == this.block && meta == this.meta; - } - } + private static final String TAG_TICKS_EXISTED = "ticksExisted"; + private static final String TAG_COLOR = "color"; + private static final String TAG_MANA = "mana"; + private static final String TAG_STARTING_MANA = "startingMana"; + private static final String TAG_MIN_MANA_LOSS = "minManaLoss"; + private static final String TAG_TICK_MANA_LOSS = "manaLossTick"; + private static final String TAG_SPREADER_X = "spreaderX"; + private static final String TAG_SPREADER_Y = "spreaderY"; + private static final String TAG_SPREADER_Z = "spreaderZ"; + private static final String TAG_GRAVITY = "gravity"; + private static final String TAG_LENS_STACK = "lensStack"; + private static final String TAG_LAST_MOTION_X = "lastMotionX"; + private static final String TAG_LAST_MOTION_Y = "lastMotionY"; + private static final String TAG_LAST_MOTION_Z = "lastMotionZ"; + private static final String TAG_HAS_SHOOTER = "hasShooter"; + private static final String TAG_SHOOTER_UUID_MOST = "shooterUUIDMost"; + private static final String TAG_SHOOTER_UUID_LEAST = "shooterUUIDLeast"; + + boolean fake = false; + + final int dataWatcherEntries = 10; + final int dataWatcherStart = 32 - dataWatcherEntries; + + List alreadyCollidedAt = new ArrayList(); + + boolean fullManaLastTick = true; + + UUID shooterIdentity = null; + int _ticksExisted = 0; + boolean scanBeam = false; + public List propsList = new ArrayList(); + + public EntityManaBurst(World world) { + super(world); + setSize(0F, 0F); + for(int i = 0; i < dataWatcherEntries; i++) { + int j = dataWatcherStart + i; + if(i == 4 || i == 5) + dataWatcher.addObject(j, 0F); + else if(i == 9) + dataWatcher.addObject(j, new ItemStack(Blocks.stone, 0, 0)); + else dataWatcher.addObject(j, 0); + + dataWatcher.setObjectWatched(j); + } + } + + public EntityManaBurst(IManaSpreader spreader, boolean fake) { + this(((TileEntity)spreader).getWorldObj()); + + TileEntity tile = (TileEntity) spreader; + + this.fake = fake; + + setBurstSourceCoords(tile.xCoord, tile.yCoord, tile.zCoord); + setLocationAndAngles(tile.xCoord + 0.5, tile.yCoord + 0.5, tile.zCoord + 0.5, 0, 0); + rotationYaw = -(spreader.getRotationX() + 90F); + rotationPitch = spreader.getRotationY(); + + float f = 0.4F; + double mx = MathHelper.sin(rotationYaw / 180.0F * (float) Math.PI) * MathHelper.cos(rotationPitch / 180.0F * (float) Math.PI) * f / 2D; + double mz = -(MathHelper.cos(rotationYaw / 180.0F * (float) Math.PI) * MathHelper.cos(rotationPitch / 180.0F * (float) Math.PI) * f) / 2D; + double my = MathHelper.sin((rotationPitch + func_70183_g()) / 180.0F * (float) Math.PI) * f / 2D; + setMotion(mx, my, mz); + } + + public EntityManaBurst(EntityPlayer player) { + this(player.worldObj); + + setBurstSourceCoords(0, -1, 0); + setLocationAndAngles(player.posX, player.posY + player.getEyeHeight(), player.posZ, player.rotationYaw + 180, -player.rotationPitch); + + posX -= MathHelper.cos((rotationYaw + 180) / 180.0F * (float) Math.PI) * 0.16F; + posY -= 0.10000000149011612D; + posZ -= MathHelper.sin((rotationYaw + 180) / 180.0F * (float) Math.PI) * 0.16F; + + setPosition(posX, posY, posZ); + yOffset = 0.0F; + float f = 0.4F; + double mx = MathHelper.sin(rotationYaw / 180.0F * (float) Math.PI) * MathHelper.cos(rotationPitch / 180.0F * (float) Math.PI) * f / 2D; + double mz = -(MathHelper.cos(rotationYaw / 180.0F * (float) Math.PI) * MathHelper.cos(rotationPitch / 180.0F * (float) Math.PI) * f) / 2D; + double my = MathHelper.sin((rotationPitch + func_70183_g()) / 180.0F * (float) Math.PI) * f / 2D; + setMotion(mx, my, mz); + } + + float accumulatedManaLoss = 0; + + private int ticksInAir; + + // Hacked code copied from super.onUpdate, to use Vector3 rather than the world vector pool + public void superUpdate() { + lastTickPosX = posX; + lastTickPosY = posY; + lastTickPosZ = posZ; + onEntityUpdate(); + + if(throwableShake > 0) + --throwableShake; + + Vec3 vec3 = new Vector3(posX, posY, posZ).toVec3D(); + Vec3 vec31 = new Vector3(posX + motionX, posY + motionY, posZ + motionZ).toVec3D(); + MovingObjectPosition movingobjectposition = clip(vec3, vec31); + + if(movingobjectposition != null) + vec31 = new Vector3(movingobjectposition.hitVec.xCoord, movingobjectposition.hitVec.yCoord, movingobjectposition.hitVec.zCoord).toVec3D(); + + if(!worldObj.isRemote) { + Entity entity = null; + List list = worldObj.getEntitiesWithinAABBExcludingEntity(this, boundingBox.addCoord(motionX, motionY, motionZ).expand(1.0D, 1.0D, 1.0D)); + double d0 = 0.0D; + EntityLivingBase entitylivingbase = getThrower(); + + for(int j = 0; j < list.size(); ++j) { + Entity entity1 = (Entity) list.get(j); + + if(entity1.canBeCollidedWith() && (entity1 != entitylivingbase || ticksInAir >= 5)) { + float f = 0.3F; + AxisAlignedBB axisalignedbb = entity1.boundingBox.expand(f, f, f); + MovingObjectPosition movingobjectposition1 = axisalignedbb.calculateIntercept(vec3, vec31); + + if(movingobjectposition1 != null) { + double d1 = vec3.distanceTo(movingobjectposition1.hitVec); + + if (d1 < d0 || d0 == 0.0D) { + entity = entity1; + d0 = d1; + } + } + } + } + + if(entity != null) + movingobjectposition = new MovingObjectPosition(entity); + } + + if(movingobjectposition != null) + onImpact(movingobjectposition); + + posX += motionX; + posY += motionY; + posZ += motionZ; + float f1 = MathHelper.sqrt_double(motionX * motionX + motionZ * motionZ); + rotationYaw = (float)(Math.atan2(motionX, motionZ) * 180.0D / Math.PI); + + for(rotationPitch = (float)(Math.atan2(motionY, f1) * 180.0D / Math.PI); rotationPitch - prevRotationPitch < -180.0F; prevRotationPitch -= 360.0F); + + while(rotationPitch - prevRotationPitch >= 180.0F) + prevRotationPitch += 360.0F; + + while(rotationYaw - prevRotationYaw < -180.0F) + prevRotationYaw -= 360.0F; + + while(rotationYaw - prevRotationYaw >= 180.0F) + prevRotationYaw += 360.0F; + + rotationPitch = prevRotationPitch + (rotationPitch - prevRotationPitch) * 0.2F; + rotationYaw = prevRotationYaw + (rotationYaw - prevRotationYaw) * 0.2F; + float f3 = getGravityVelocity(); + + motionY -= f3; + setPosition(posX, posY, posZ); + } + + public MovingObjectPosition clip(Vec3 par1Vec3, Vec3 par2Vec3) { + boolean par3 = false; + boolean par4 = false; + if (!Double.isNaN(par1Vec3.xCoord) && !Double.isNaN(par1Vec3.yCoord) && !Double.isNaN(par1Vec3.zCoord)) { + if (!Double.isNaN(par2Vec3.xCoord) && !Double.isNaN(par2Vec3.yCoord) && !Double.isNaN(par2Vec3.zCoord)) { + int i = MathHelper.floor_double(par2Vec3.xCoord); + int j = MathHelper.floor_double(par2Vec3.yCoord); + int k = MathHelper.floor_double(par2Vec3.zCoord); + int l = MathHelper.floor_double(par1Vec3.xCoord); + int i1 = MathHelper.floor_double(par1Vec3.yCoord); + int j1 = MathHelper.floor_double(par1Vec3.zCoord); + Block block = worldObj.getBlock(l, i1, j1); + int l1 = worldObj.getBlockMetadata(l, i1, j1); + + if (block != null && (!par4 || block == null || block.getCollisionBoundingBoxFromPool(worldObj, l, i1, j1) != null) && block != Blocks.air && block.canCollideCheck(l1, par3)) { + MovingObjectPosition movingobjectposition = block.collisionRayTrace(worldObj, l, i1, j1, par1Vec3, par2Vec3); + + if (movingobjectposition != null) + return movingobjectposition; + } + + int k1 = 200; + + while (k1-- >= 0) { + if (Double.isNaN(par1Vec3.xCoord) || Double.isNaN(par1Vec3.yCoord) || Double.isNaN(par1Vec3.zCoord)) + return null; + + if (l == i && i1 == j && j1 == k) + return null; + + boolean flag2 = true; + boolean flag3 = true; + boolean flag4 = true; + double d0 = 999.0D; + double d1 = 999.0D; + double d2 = 999.0D; + + if (i > l) + d0 = l + 1.0D; + else if (i < l) + d0 = l + 0.0D; + else flag2 = false; + + if (j > i1) + d1 = i1 + 1.0D; + else if (j < i1) + d1 = i1 + 0.0D; + else flag3 = false; + + if (k > j1) + d2 = j1 + 1.0D; + else if (k < j1) + d2 = j1 + 0.0D; + else flag4 = false; + + double d3 = 999.0D; + double d4 = 999.0D; + double d5 = 999.0D; + double d6 = par2Vec3.xCoord - par1Vec3.xCoord; + double d7 = par2Vec3.yCoord - par1Vec3.yCoord; + double d8 = par2Vec3.zCoord - par1Vec3.zCoord; + + if (flag2) + d3 = (d0 - par1Vec3.xCoord) / d6; + + if (flag3) + d4 = (d1 - par1Vec3.yCoord) / d7; + + if (flag4) + d5 = (d2 - par1Vec3.zCoord) / d8; + + byte b0; + + if (d3 < d4 && d3 < d5) { + if (i > l) + b0 = 4; + else b0 = 5; + + par1Vec3.xCoord = d0; + par1Vec3.yCoord += d7 * d3; + par1Vec3.zCoord += d8 * d3; + } else if (d4 < d5) { + if (j > i1) + b0 = 0; + else b0 = 1; + + par1Vec3.xCoord += d6 * d4; + par1Vec3.yCoord = d1; + par1Vec3.zCoord += d8 * d4; + } else { + if (k > j1) + b0 = 2; + else b0 = 3; + + par1Vec3.xCoord += d6 * d5; + par1Vec3.yCoord += d7 * d5; + par1Vec3.zCoord = d2; + } + + Vec3 vec32 = new Vector3(par1Vec3.xCoord, par1Vec3.yCoord, par1Vec3.zCoord).toVec3D(); + l = (int)(vec32.xCoord = MathHelper.floor_double(par1Vec3.xCoord)); + + if (b0 == 5) { + --l; + ++vec32.xCoord; + } + + i1 = (int)(vec32.yCoord = MathHelper.floor_double(par1Vec3.yCoord)); + + if (b0 == 1) { + --i1; + ++vec32.yCoord; + } + + j1 = (int)(vec32.zCoord = MathHelper.floor_double(par1Vec3.zCoord)); + + if (b0 == 3) { + --j1; + ++vec32.zCoord; + } + + Block block1 = worldObj.getBlock(l, i1, j1); + int j2 = worldObj.getBlockMetadata(l, i1, j1); + + if ((!par4 || block1 == null || block1.getCollisionBoundingBoxFromPool(worldObj, l, i1, j1) != null) && block1 != Blocks.air && block1.canCollideCheck(j2, par3)) { + MovingObjectPosition movingobjectposition1 = block1.collisionRayTrace(worldObj, l, i1, j1, par1Vec3, par2Vec3); + + if (movingobjectposition1 != null) + return movingobjectposition1; + } + } + + return null; + } + else return null; + } else return null; + } + + @Override + public void onUpdate() { + setTicksExisted(getTicksExisted() + 1); + superUpdate(); + + if(!fake && !isDead) + ping(); + + ILensEffect lens = getLensInstance(); + if(lens != null) + lens.updateBurst(this, getSourceLens()); + + int mana = getMana(); + if(getTicksExisted() >= getMinManaLoss()) { + accumulatedManaLoss += getManaLossPerTick(); + int loss = (int) accumulatedManaLoss; + setMana(mana - loss); + accumulatedManaLoss -= loss; + + if(getMana() <= 0) + setDead(); + } + + particles(); + + setMotion(motionX, motionY, motionZ); + + fullManaLastTick = getMana() == getStartingMana(); + + if(scanBeam) { + PositionProperties props = new PositionProperties(this); + if(propsList.isEmpty()) + propsList.add(props); + else { + PositionProperties lastProps = propsList.get(propsList.size() - 1); + if(!props.coordsEqual(lastProps)) + propsList.add(props); + } + } + } + + @Override + @SideOnly(Side.CLIENT) + public void setPositionAndRotation2(double p_70056_1_, double p_70056_3_, double p_70056_5_, float p_70056_7_, float p_70056_8_, int p_70056_9_) { + setPosition(p_70056_1_, p_70056_3_, p_70056_5_); + setRotation(p_70056_7_, p_70056_8_); + } + + @Override + public boolean handleWaterMovement() { + return false; + } + + public TileEntity collidedTile = null; + public boolean noParticles = false; + + public TileEntity getCollidedTile(boolean noParticles) { + this.noParticles = noParticles; + + while(!isDead) + onUpdate(); + + if(fake) + incrementFakeParticleTick(); + + return collidedTile; + } + + @Override + public void writeEntityToNBT(NBTTagCompound par1nbtTagCompound) { + super.writeEntityToNBT(par1nbtTagCompound); + par1nbtTagCompound.setInteger(TAG_TICKS_EXISTED, getTicksExisted()); + par1nbtTagCompound.setInteger(TAG_COLOR, getColor()); + par1nbtTagCompound.setInteger(TAG_MANA, getMana()); + par1nbtTagCompound.setInteger(TAG_STARTING_MANA, getStartingMana()); + par1nbtTagCompound.setInteger(TAG_MIN_MANA_LOSS, getMinManaLoss()); + par1nbtTagCompound.setFloat(TAG_TICK_MANA_LOSS, getManaLossPerTick()); + par1nbtTagCompound.setFloat(TAG_GRAVITY, getGravity()); + + ItemStack stack = getSourceLens(); + NBTTagCompound lensCmp = new NBTTagCompound(); + if(stack != null) + stack.writeToNBT(lensCmp); + par1nbtTagCompound.setTag(TAG_LENS_STACK, lensCmp); + + ChunkCoordinates coords = getBurstSourceChunkCoordinates(); + par1nbtTagCompound.setInteger(TAG_SPREADER_X, coords.posX); + par1nbtTagCompound.setInteger(TAG_SPREADER_Y, coords.posY); + par1nbtTagCompound.setInteger(TAG_SPREADER_Z, coords.posZ); + + par1nbtTagCompound.setDouble(TAG_LAST_MOTION_X, motionX); + par1nbtTagCompound.setDouble(TAG_LAST_MOTION_Y, motionY); + par1nbtTagCompound.setDouble(TAG_LAST_MOTION_Z, motionZ); + + UUID identity = getShooterUIID(); + boolean hasShooter = identity != null; + par1nbtTagCompound.setBoolean(TAG_HAS_SHOOTER, hasShooter); + if(hasShooter) { + par1nbtTagCompound.setLong(TAG_SHOOTER_UUID_MOST, identity.getMostSignificantBits()); + par1nbtTagCompound.setLong(TAG_SHOOTER_UUID_LEAST, identity.getLeastSignificantBits()); + } + } + + @Override + public void readEntityFromNBT(NBTTagCompound par1nbtTagCompound) { + super.readEntityFromNBT(par1nbtTagCompound); + setTicksExisted(par1nbtTagCompound.getInteger(TAG_TICKS_EXISTED)); + setColor(par1nbtTagCompound.getInteger(TAG_COLOR)); + setMana(par1nbtTagCompound.getInteger(TAG_MANA)); + setStartingMana(par1nbtTagCompound.getInteger(TAG_STARTING_MANA)); + setMinManaLoss(par1nbtTagCompound.getInteger(TAG_MIN_MANA_LOSS)); + setManaLossPerTick(par1nbtTagCompound.getFloat(TAG_TICK_MANA_LOSS)); + setGravity(par1nbtTagCompound.getFloat(TAG_GRAVITY)); + + NBTTagCompound lensCmp = par1nbtTagCompound.getCompoundTag(TAG_LENS_STACK); + ItemStack stack = ItemStack.loadItemStackFromNBT(lensCmp); + if(stack != null) + setSourceLens(stack); + else setSourceLens(new ItemStack(Blocks.stone, 0, 0)); + + int x = par1nbtTagCompound.getInteger(TAG_SPREADER_X); + int y = par1nbtTagCompound.getInteger(TAG_SPREADER_Y); + int z = par1nbtTagCompound.getInteger(TAG_SPREADER_Z); + + setBurstSourceCoords(x, y, z); + + double lastMotionX = par1nbtTagCompound.getDouble(TAG_LAST_MOTION_X); + double lastMotionY = par1nbtTagCompound.getDouble(TAG_LAST_MOTION_Y); + double lastMotionZ = par1nbtTagCompound.getDouble(TAG_LAST_MOTION_Z); + + setMotion(lastMotionX, lastMotionY, lastMotionZ); + + boolean hasShooter = par1nbtTagCompound.getBoolean(TAG_HAS_SHOOTER); + if(hasShooter) { + long most = par1nbtTagCompound.getLong(TAG_SHOOTER_UUID_MOST); + long least = par1nbtTagCompound.getLong(TAG_SHOOTER_UUID_LEAST); + UUID identity = getShooterUIID(); + if(identity == null || most != identity.getMostSignificantBits() || least != identity.getLeastSignificantBits()) + shooterIdentity = new UUID(most, least); + } + } + + public void particles() { + if(isDead || !worldObj.isRemote) + return; + + ILensEffect lens = getLensInstance(); + if(lens != null && !lens.doParticles(this, getSourceLens())) + return; + + Color color = new Color(getColor()); + float r = color.getRed() / 255F; + float g = color.getGreen() / 255F; + float b = color.getBlue() / 255F; + + int mana = getMana(); + int maxMana = getStartingMana(); + float osize = (float) mana / (float) maxMana; + float size = osize; + + if(fake) { + if(getMana() == getStartingMana()) + size = 2F; + else if(fullManaLastTick) + size = 4F; + + if(!noParticles && shouldDoFakeParticles()) + Botania.proxy.sparkleFX(worldObj, posX, posY, posZ, r, g, b, 0.4F * size, 1, true); + } else { + boolean monocle = Botania.proxy.isClientPlayerWearingMonocle(); + if(monocle) + Botania.proxy.setWispFXDepthTest(false); + + if(ConfigHandler.subtlePowerSystem) + Botania.proxy.wispFX(worldObj, posX, posY, posZ, r, g, b, 0.1F * size, (float) (Math.random() - 0.5F) * 0.02F, (float) (Math.random() - 0.5F) * 0.02F, (float) (Math.random() - 0.5F) * 0.01F); + else { + float or = r; + float og = g; + float ob = b; + + double savedPosX = posX; + double savedPosY = posY; + double savedPosZ = posZ; + + Vector3 currentPos = Vector3.fromEntity(this); + Vector3 oldPos = new Vector3(prevPosX, prevPosY, prevPosZ); + Vector3 diffVec = oldPos.copy().sub(currentPos); + Vector3 diffVecNorm = diffVec.copy().normalize(); + + double distance = 0.095; + + do { + r = or + ((float) Math.random() - 0.5F) * 0.25F; + g = og + ((float) Math.random() - 0.5F) * 0.25F; + b = ob + ((float) Math.random() - 0.5F) * 0.25F; + size = osize + ((float) Math.random() - 0.5F) * 0.065F + (float) Math.sin(new Random(entityUniqueID.getMostSignificantBits()).nextInt(9001)) * 0.4F; + Botania.proxy.wispFX(worldObj, posX, posY, posZ, r, g, b, 0.2F * size, (float) -motionX * 0.01F, (float) -motionY * 0.01F, (float) -motionZ * 0.01F); + + posX += diffVecNorm.x * distance; + posY += diffVecNorm.y * distance; + posZ += diffVecNorm.z * distance; + + currentPos = Vector3.fromEntity(this); + diffVec = oldPos.copy().sub(currentPos); + if(getEntityData().hasKey(ItemTinyPlanet.TAG_ORBIT)) + break; + } while(Math.abs(diffVec.mag()) > distance); + + Botania.proxy.wispFX(worldObj, posX, posY, posZ, r, g, b, 0.1F * size, (float) (Math.random() - 0.5F) * 0.06F, (float) (Math.random() - 0.5F) * 0.06F, (float) (Math.random() - 0.5F) * 0.06F); + + posX = savedPosX; + posY = savedPosY; + posZ = savedPosZ; + } + + if(monocle) + Botania.proxy.setWispFXDepthTest(true); + } + } + + @Override + protected void onImpact(MovingObjectPosition movingobjectposition) { + boolean collided = false; + boolean dead = false; + + if(movingobjectposition.entityHit == null) { + TileEntity tile = worldObj.getTileEntity(movingobjectposition.blockX, movingobjectposition.blockY, movingobjectposition.blockZ); + Block block = worldObj.getBlock(movingobjectposition.blockX, movingobjectposition.blockY, movingobjectposition.blockZ); + + if(tile instanceof IManaCollisionGhost && ((IManaCollisionGhost) tile).isGhost() && !(block instanceof IManaTrigger) || block instanceof BlockBush || block instanceof BlockLeaves) + return; + + if(BotaniaAPI.internalHandler.isBuildcraftPipe(tile)) + return; + + ChunkCoordinates coords = getBurstSourceChunkCoordinates(); + if(tile != null && (tile.xCoord != coords.posX || tile.yCoord != coords.posY || tile.zCoord != coords.posZ)) + collidedTile = tile; + + if(tile == null || tile.xCoord != coords.posX || tile.yCoord != coords.posY || tile.zCoord != coords.posZ) { + if(!fake && !noParticles && (!worldObj.isRemote || tile instanceof IClientManaHandler) && tile != null && tile instanceof IManaReceiver && ((IManaReceiver) tile).canRecieveManaFromBursts()) + onRecieverImpact((IManaReceiver) tile, tile.xCoord, tile.yCoord, tile.zCoord); + + if(block instanceof IManaTrigger) + ((IManaTrigger) block).onBurstCollision(this, worldObj, movingobjectposition.blockX, movingobjectposition.blockY, movingobjectposition.blockZ); + + boolean ghost = tile instanceof IManaCollisionGhost; + dead = !ghost; + if(ghost) + return; + } + + collided = true; + } + + ILensEffect lens = getLensInstance(); + if(lens != null) + dead = lens.collideBurst(this, movingobjectposition, collidedTile != null && collidedTile instanceof IManaReceiver && ((IManaReceiver) collidedTile).canRecieveManaFromBursts(), dead, getSourceLens()); + + if(collided && !hasAlreadyCollidedAt(movingobjectposition.blockX, movingobjectposition.blockY, movingobjectposition.blockZ)) + alreadyCollidedAt.add(getCollisionLocString(movingobjectposition.blockX, movingobjectposition.blockY, movingobjectposition.blockZ)); + + if(dead && !isDead) { + if(!fake) { + Color color = new Color(getColor()); + float r = color.getRed() / 255F; + float g = color.getGreen() / 255F; + float b = color.getBlue() / 255F; + + int mana = getMana(); + int maxMana = getStartingMana(); + float size = (float) mana / (float) maxMana; + + if(!ConfigHandler.subtlePowerSystem) + for(int i = 0; i < 4; i++) + Botania.proxy.wispFX(worldObj, posX, posY, posZ, r, g, b, 0.15F * size, (float) (Math.random() - 0.5F) * 0.04F, (float) (Math.random() - 0.5F) * 0.04F, (float) (Math.random() - 0.5F) * 0.04F); + Botania.proxy.sparkleFX(worldObj, (float) posX, (float) posY, (float) posZ, r, g, b, 4, 2); + } + + setDead(); + } + } + + protected void onRecieverImpact(IManaReceiver tile, int x, int y, int z) { + int mana = getMana(); + if(tile instanceof IManaCollector) + mana *= ((IManaCollector) tile).getManaYieldMultiplier(this); + + tile.recieveMana(mana); + if(tile instanceof IThrottledPacket) + ((IThrottledPacket) tile).markDispatchable(); + else VanillaPacketDispatcher.dispatchTEToNearbyPlayers(worldObj, x, y, z); + } + + @Override + public void setDead() { + super.setDead(); + + if(!fake) { + TileEntity tile = getShooter(); + if(tile != null && tile instanceof IManaSpreader) + ((IManaSpreader) tile).setCanShoot(true); + } else setDeathTicksForFakeParticle(); + } + + public TileEntity getShooter() { + ChunkCoordinates coords = getBurstSourceChunkCoordinates(); + TileEntity tile = worldObj.getTileEntity(coords.posX, coords.posY, coords.posZ); + return tile; + } + + @Override + protected float getGravityVelocity() { + return getGravity(); + } + + @Override + public boolean isFake() { + return fake; + } + + @Override + public void setFake(boolean fake) { + this.fake = fake; + } + + public void setScanBeam() { + scanBeam = true; + } + + @Override + public int getColor() { + return dataWatcher.getWatchableObjectInt(dataWatcherStart); + } + + @Override + public void setColor(int color) { + dataWatcher.updateObject(dataWatcherStart, color); + } + + @Override + public int getMana() { + return dataWatcher.getWatchableObjectInt(dataWatcherStart + 1); + } + + @Override + public void setMana(int mana) { + dataWatcher.updateObject(dataWatcherStart + 1, mana); + } + + @Override + public int getStartingMana() { + return dataWatcher.getWatchableObjectInt(dataWatcherStart + 2); + } + + @Override + public void setStartingMana(int mana) { + dataWatcher.updateObject(dataWatcherStart + 2, mana); + } + + @Override + public int getMinManaLoss() { + return dataWatcher.getWatchableObjectInt(dataWatcherStart + 3); + } + + @Override + public void setMinManaLoss(int minManaLoss) { + dataWatcher.updateObject(dataWatcherStart + 3, minManaLoss); + } + + @Override + public float getManaLossPerTick() { + return dataWatcher.getWatchableObjectFloat(dataWatcherStart + 4); + } + + @Override + public void setManaLossPerTick(float mana) { + dataWatcher.updateObject(dataWatcherStart + 4, mana); + } + + @Override + public float getGravity() { + return dataWatcher.getWatchableObjectFloat(dataWatcherStart + 5); + } + + @Override + public void setGravity(float gravity) { + dataWatcher.updateObject(dataWatcherStart + 5, gravity); + } + + final int coordsStart = dataWatcherStart + 6; + + @Override + public ChunkCoordinates getBurstSourceChunkCoordinates() { + int x = dataWatcher.getWatchableObjectInt(coordsStart); + int y = dataWatcher.getWatchableObjectInt(coordsStart + 1); + int z = dataWatcher.getWatchableObjectInt(coordsStart + 2); + + return new ChunkCoordinates(x, y, z); + } + + @Override + public void setBurstSourceCoords(int x, int y, int z) { + dataWatcher.updateObject(coordsStart, x); + dataWatcher.updateObject(coordsStart + 1, y); + dataWatcher.updateObject(coordsStart + 2, z); + } + + @Override + public ItemStack getSourceLens() { + return dataWatcher.getWatchableObjectItemStack(dataWatcherStart + 9); + } + + @Override + public void setSourceLens(ItemStack lens) { + dataWatcher.updateObject(dataWatcherStart + 9, lens == null ? new ItemStack(Blocks.stone, 0, 0) : lens); + } + + @Override + public int getTicksExisted() { + return _ticksExisted; + } + + public void setTicksExisted(int ticks) { + _ticksExisted = ticks; + } + + public ILensEffect getLensInstance() { + ItemStack lens = getSourceLens(); + if(lens != null && lens.getItem() instanceof ILensEffect) + return (ILensEffect) lens.getItem(); + + return null; + } + + final int motionStart = dataWatcherStart + 10; + + @Override + public void setMotion(double x, double y, double z) { + motionX = x; + motionY = y; + motionZ = z; + } + + @Override + public boolean hasAlreadyCollidedAt(int x, int y, int z) { + return alreadyCollidedAt.contains(getCollisionLocString(x, y, z)); + } + + @Override + public void setCollidedAt(int x, int y, int z) { + if(!hasAlreadyCollidedAt(x, y, z)) + alreadyCollidedAt.add(getCollisionLocString(x, y, z)); + } + + private String getCollisionLocString(int x, int y, int z) { + return x + ":" + y + ":" + z; + } + + @Override + public void setShooterUUID(UUID uuid) { + shooterIdentity = uuid; + } + + @Override + public UUID getShooterUIID() { + return shooterIdentity; + } + + @Override + public void ping() { + TileEntity tile = getShooter(); + if(tile != null && tile instanceof IPingable) + ((IPingable) tile).pingback(this, getShooterUIID()); + } + + public boolean shouldDoFakeParticles() { + if(ConfigHandler.staticWandBeam) + return true; + + TileEntity tile = getShooter(); + if(tile != null && tile instanceof IManaSpreader) + return getMana() != getStartingMana() && fullManaLastTick || Math.abs(((IManaSpreader) tile).getBurstParticleTick() - getTicksExisted()) < 4; + return false; + } + + public void incrementFakeParticleTick() { + TileEntity tile = getShooter(); + if(tile != null && tile instanceof IManaSpreader) { + IManaSpreader spreader = (IManaSpreader) tile; + spreader.setBurstParticleTick(spreader.getBurstParticleTick()+2); + if(spreader.getLastBurstDeathTick() != -1 && spreader.getBurstParticleTick() > spreader.getLastBurstDeathTick()) + spreader.setBurstParticleTick(0); + } + } + + public void setDeathTicksForFakeParticle() { + ChunkCoordinates coords = getBurstSourceChunkCoordinates(); + TileEntity tile = worldObj.getTileEntity(coords.posX, coords.posY, coords.posZ); + if(tile != null && tile instanceof IManaSpreader) + ((IManaSpreader) tile).setLastBurstDeathTick(getTicksExisted()); + } + + public static class PositionProperties { + + public final ChunkCoordinates coords; + public final Block block; + public final int meta; + + public boolean invalid = false; + + public PositionProperties(Entity entity) { + int x = MathHelper.floor_double(entity.posX); + int y = MathHelper.floor_double(entity.posY); + int z = MathHelper.floor_double(entity.posZ); + coords = new ChunkCoordinates(x, y, z); + block = entity.worldObj.getBlock(x, y, z); + meta = entity.worldObj.getBlockMetadata(x, y, z); + } + + public boolean coordsEqual(PositionProperties props) { + return coords.equals(props.coords); + } + + public boolean contentsEqual(World world) { + if(!world.blockExists(coords.posX, coords.posY, coords.posZ)) { + invalid = true; + return false; + } + + Block block = world.getBlock(coords.posX , coords.posY, coords.posZ); + int meta = world.getBlockMetadata(coords.posX, coords.posY, coords.posZ); + return block == this.block && meta == this.meta; + } + } + } diff --git a/src/main/java/vazkii/botania/common/entity/EntityManaStorm.java b/src/main/java/vazkii/botania/common/entity/EntityManaStorm.java index 47a7153f5a..4343aad6cf 100644 --- a/src/main/java/vazkii/botania/common/entity/EntityManaStorm.java +++ b/src/main/java/vazkii/botania/common/entity/EntityManaStorm.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jul 25, 2015, 12:35:51 AM (GMT)] */ package vazkii.botania.common.entity; @@ -20,79 +20,79 @@ public class EntityManaStorm extends Entity { - private static final String TAG_TIME = "time"; - private static final String TAG_BURSTS_FIRED = "burstsFired"; - private static final String TAG_DEATH_TIME = "deathTime"; - - public static final int TOTAL_BURSTS = 250; - public static final int DEATH_TIME = 200; - - public int liveTime; - public int burstsFired; - public int deathTime; - - public EntityManaStorm(World p_i1582_1_) { - super(p_i1582_1_); - } - - @Override - protected void entityInit() { - // NO-OP - } - - @Override - public void onUpdate() { - super.onUpdate(); - liveTime++; - - int diffTime = Math.max(1, 30 - (int) (liveTime / 45f)); - if (burstsFired < TOTAL_BURSTS && liveTime % diffTime == 0) { - if (!worldObj.isRemote) spawnBurst(); - burstsFired++; - } - - if (burstsFired >= TOTAL_BURSTS) { - deathTime++; - if (deathTime >= DEATH_TIME) { - setDead(); - worldObj.newExplosion(this, posX, posY, posZ, 8F, true, true); - } - } - } - - public void spawnBurst() { - EntityManaBurst burst = new EntityManaBurst(worldObj); - burst.setPosition(posX, posY, posZ); - - float motionModifier = 0.5F; - burst.setColor(0x20FF20); - burst.setMana(120); - burst.setStartingMana(340); - burst.setMinManaLoss(50); - burst.setManaLossPerTick(1F); - burst.setGravity(0F); - - ItemStack lens = new ItemStack(ModItems.lens, 1, ItemLens.STORM); - burst.setSourceLens(lens); - - Vector3 motion = new Vector3(Math.random() - 0.5, Math.random() - 0.5, Math.random() - 0.5) - .normalize() - .multiply(motionModifier); - burst.setMotion(motion.x, motion.y, motion.z); - worldObj.spawnEntityInWorld(burst); - } - - @Override - protected void readEntityFromNBT(NBTTagCompound cmp) { - liveTime = cmp.getInteger(TAG_TIME); - burstsFired = cmp.getInteger(TAG_BURSTS_FIRED); - deathTime = cmp.getInteger(TAG_DEATH_TIME); - } - - @Override - protected void writeEntityToNBT(NBTTagCompound cmp) { - cmp.setInteger(TAG_TIME, liveTime); - cmp.setInteger(TAG_BURSTS_FIRED, burstsFired); - cmp.setInteger(TAG_DEATH_TIME, deathTime); - } + private static final String TAG_TIME = "time"; + private static final String TAG_BURSTS_FIRED = "burstsFired"; + private static final String TAG_DEATH_TIME = "deathTime"; + + public static final int TOTAL_BURSTS = 250; + public static final int DEATH_TIME = 200; + + public int liveTime; + public int burstsFired; + public int deathTime; + + public EntityManaStorm(World p_i1582_1_) { + super(p_i1582_1_); + } + + @Override + protected void entityInit() { + // NO-OP + } + + @Override + public void onUpdate() { + super.onUpdate(); + liveTime++; + + int diffTime = Math.max(1, 30 - (int) (liveTime / 45f)); + if(burstsFired < TOTAL_BURSTS && liveTime % diffTime == 0) { + if(!worldObj.isRemote) + spawnBurst(); + burstsFired++; + } + + if(burstsFired >= TOTAL_BURSTS) { + deathTime++; + if(deathTime >= DEATH_TIME) { + setDead(); + worldObj.newExplosion(this, posX, posY, posZ, 8F, true, true); + } + } + } + + public void spawnBurst() { + EntityManaBurst burst = new EntityManaBurst(worldObj); + burst.setPosition(posX, posY, posZ); + + float motionModifier = 0.5F; + burst.setColor(0x20FF20); + burst.setMana(120); + burst.setStartingMana(340); + burst.setMinManaLoss(50); + burst.setManaLossPerTick(1F); + burst.setGravity(0F); + + ItemStack lens = new ItemStack(ModItems.lens, 1, ItemLens.STORM); + burst.setSourceLens(lens); + + Vector3 motion = new Vector3(Math.random() - 0.5, Math.random() - 0.5, Math.random() - 0.5).normalize().multiply(motionModifier); + burst.setMotion(motion.x, motion.y, motion.z); + worldObj.spawnEntityInWorld(burst); + } + + @Override + protected void readEntityFromNBT(NBTTagCompound cmp) { + liveTime = cmp.getInteger(TAG_TIME); + burstsFired = cmp.getInteger(TAG_BURSTS_FIRED); + deathTime = cmp.getInteger(TAG_DEATH_TIME); + } + + @Override + protected void writeEntityToNBT(NBTTagCompound cmp) { + cmp.setInteger(TAG_TIME, liveTime); + cmp.setInteger(TAG_BURSTS_FIRED, burstsFired); + cmp.setInteger(TAG_DEATH_TIME, deathTime); + } + } diff --git a/src/main/java/vazkii/botania/common/entity/EntityPinkWither.java b/src/main/java/vazkii/botania/common/entity/EntityPinkWither.java index 3baa2e4763..8d050076eb 100644 --- a/src/main/java/vazkii/botania/common/entity/EntityPinkWither.java +++ b/src/main/java/vazkii/botania/common/entity/EntityPinkWither.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Mar 25, 2015, 5:49:28 PM (GMT)] */ package vazkii.botania.common.entity; @@ -19,87 +19,89 @@ public class EntityPinkWither extends EntityWither { - public EntityPinkWither(World p_i1701_1_) { - super(p_i1701_1_); - } + public EntityPinkWither(World p_i1701_1_) { + super(p_i1701_1_); + } - @Override - public void onLivingUpdate() { - super.onLivingUpdate(); + @Override + public void onLivingUpdate() { + super.onLivingUpdate(); - if (Math.random() < 0.1) - for (int j = 0; j < 3; ++j) { - double d10 = func_82214_u(j); - double d2 = func_82208_v(j); - double d4 = func_82213_w(j); - worldObj.spawnParticle( - "heart", - d10 + rand.nextGaussian() * 0.30000001192092896D, - d2 + rand.nextGaussian() * 0.30000001192092896D, - d4 + rand.nextGaussian() * 0.30000001192092896D, - 0.0D, - 0.0D, - 0.0D); - } - } + if(Math.random() < 0.1) + for(int j = 0; j < 3; ++j) { + double d10 = func_82214_u(j); + double d2 = func_82208_v(j); + double d4 = func_82213_w(j); + worldObj.spawnParticle("heart", d10 + rand.nextGaussian() * 0.30000001192092896D, d2 + rand.nextGaussian() * 0.30000001192092896D, d4 + rand.nextGaussian() * 0.30000001192092896D, 0.0D, 0.0D, 0.0D); + } + } - @Override - public void setAttackTarget(EntityLivingBase p_70624_1_) { - // NO-OP - } + @Override + public void setAttackTarget(EntityLivingBase p_70624_1_) { + // NO-OP + } - @Override - protected void attackEntity(Entity p_70785_1_, float p_70785_2_) { - // NO-OP - } + @Override + protected void attackEntity(Entity p_70785_1_, float p_70785_2_) { + // NO-OP + } - @Override - public boolean attackEntityAsMob(Entity p_70652_1_) { - return false; - } + @Override + public boolean attackEntityAsMob(Entity p_70652_1_) { + return false; + } - @Override - protected boolean interact(EntityPlayer player) { - if (!player.isSneaking()) { - player.mountEntity(this); - return true; - } - return false; - } + @Override + protected boolean interact(EntityPlayer player) { + if(!player.isSneaking()) { + player.mountEntity(this); + return true; + } + return false; + } - @Override - protected boolean isAIEnabled() { - return false; - } + @Override + protected boolean isAIEnabled() { + return false; + } - @Override - protected void dropFewItems(boolean p_70628_1_, int p_70628_2_) { - // NO-OP - } + @Override + protected void dropFewItems(boolean p_70628_1_, int p_70628_2_) { + // NO-OP + } - // COPYPASTA + // COPYPASTA - private double func_82214_u(int p_82214_1_) { - if (p_82214_1_ <= 0) { - return posX; - } else { - float f = (renderYawOffset + 180 * (p_82214_1_ - 1)) / 180.0F * (float) Math.PI; - float f1 = MathHelper.cos(f); - return posX + f1 * 1.3D; - } - } + private double func_82214_u(int p_82214_1_) + { + if (p_82214_1_ <= 0) + { + return posX; + } + else + { + float f = (renderYawOffset + 180 * (p_82214_1_ - 1)) / 180.0F * (float)Math.PI; + float f1 = MathHelper.cos(f); + return posX + f1 * 1.3D; + } + } - private double func_82208_v(int p_82208_1_) { - return p_82208_1_ <= 0 ? posY + 3.0D : posY + 2.2D; - } + private double func_82208_v(int p_82208_1_) + { + return p_82208_1_ <= 0 ? posY + 3.0D : posY + 2.2D; + } - private double func_82213_w(int p_82213_1_) { - if (p_82213_1_ <= 0) { - return posZ; - } else { - float f = (renderYawOffset + 180 * (p_82213_1_ - 1)) / 180.0F * (float) Math.PI; - float f1 = MathHelper.sin(f); - return posZ + f1 * 1.3D; - } - } + private double func_82213_w(int p_82213_1_) + { + if (p_82213_1_ <= 0) + { + return posZ; + } + else + { + float f = (renderYawOffset + 180 * (p_82213_1_ - 1)) / 180.0F * (float)Math.PI; + float f1 = MathHelper.sin(f); + return posZ + f1 * 1.3D; + } + } } diff --git a/src/main/java/vazkii/botania/common/entity/EntityPixie.java b/src/main/java/vazkii/botania/common/entity/EntityPixie.java index 850b4b0243..870a13f720 100644 --- a/src/main/java/vazkii/botania/common/entity/EntityPixie.java +++ b/src/main/java/vazkii/botania/common/entity/EntityPixie.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [? (GMT)] */ package vazkii.botania.common.entity; @@ -20,126 +20,111 @@ public class EntityPixie extends EntityFlyingCreature { - EntityLivingBase summoner = null; - float damage = 0; - PotionEffect effect = null; - - public EntityPixie(World world) { - super(world); - setSize(1.0F, 1.0F); - } - - @Override - protected void entityInit() { - super.entityInit(); - dataWatcher.addObject(20, 0); - } - - @Override - protected void applyEntityAttributes() { - super.applyEntityAttributes(); - getEntityAttribute(SharedMonsterAttributes.maxHealth).setBaseValue(2.0); - } - - public void setType(int type) { - dataWatcher.updateObject(20, type); - } - - public int getType() { - return dataWatcher.getWatchableObjectInt(20); - } - - public void setProps(EntityLivingBase target, EntityLivingBase summoner, int type, float damage) { - setAttackTarget(target); - this.summoner = summoner; - this.damage = damage; - setType(type); - } - - public void setApplyPotionEffect(PotionEffect effect) { - this.effect = effect; - } - - @Override - protected void updateEntityActionState() { - EntityLivingBase target = getAttackTarget(); - if (target != null) { - double d0 = target.posX + target.width / 2 - posX; - double d1 = target.posY + target.height / 2 - posY; - double d2 = target.posZ + target.width / 2 - posZ; - double d3 = d0 * d0 + d1 * d1 + d2 * d2; - - float mod = 0.45F; - if (getType() == 1) mod = 0.1F; - - motionX += d0 / d3 * mod; - motionY += d1 / d3 * mod; - motionZ += d2 / d3 * mod; - - if (Math.sqrt(d3) < 1F) { - if (summoner != null) { - if (summoner instanceof EntityPlayer) - target.attackEntityFrom(DamageSource.causePlayerDamage((EntityPlayer) summoner), damage); - else { - target.attackEntityFrom(DamageSource.causeMobDamage(summoner), damage); - } - } else target.attackEntityFrom(DamageSource.causeMobDamage(this), damage); - if (effect != null && !(target instanceof EntityPlayer)) target.addPotionEffect(effect); - die(); - } - } - - renderYawOffset = rotationYaw = -((float) Math.atan2(motionX, motionZ)) * 180.0F / (float) Math.PI; - } - - @Override - public boolean attackEntityFrom(DamageSource par1DamageSource, float par2) { - if (getType() == 0 && par1DamageSource.getEntity() != summoner - || getType() == 1 && par1DamageSource.getEntity() instanceof EntityPlayer) - return super.attackEntityFrom(par1DamageSource, par2); - return false; - } - - @Override - public void onEntityUpdate() { - super.onEntityUpdate(); - - if (getAttackTarget() == null || ticksExisted > 200) die(); - - boolean dark = getType() == 1; - if (worldObj.isRemote) - for (int i = 0; i < 4; i++) - Botania.proxy.sparkleFX( - worldObj, - posX + (Math.random() - 0.5) * 0.25, - posY + 0.5 + (Math.random() - 0.5) * 0.25, - posZ + (Math.random() - 0.5) * 0.25, - dark ? 0.1F : 1F, - dark ? 0.025F : 0.25F, - dark ? 0.09F : 0.9F, - 0.1F + (float) Math.random() * 0.25F, - 12); - } - - public void die() { - setDead(); - - if (worldObj.isRemote && getType() == 0) - for (int i = 0; i < 12; i++) - Botania.proxy.sparkleFX( - worldObj, - posX + (Math.random() - 0.5) * 0.25, - posY + 0.5 + (Math.random() - 0.5) * 0.25, - posZ + (Math.random() - 0.5) * 0.25, - 1F, - 0.25F, - 0.9F, - 1F + (float) Math.random() * 0.25F, - 5); - } - - @Override - protected boolean canDespawn() { - return false; - } -} + EntityLivingBase summoner = null; + float damage = 0; + PotionEffect effect = null; + + public EntityPixie(World world) { + super(world); + setSize(1.0F, 1.0F); + } + + @Override + protected void entityInit() { + super.entityInit(); + dataWatcher.addObject(20, 0); + } + + @Override + protected void applyEntityAttributes() { + super.applyEntityAttributes(); + getEntityAttribute(SharedMonsterAttributes.maxHealth).setBaseValue(2.0); + } + + public void setType(int type) { + dataWatcher.updateObject(20, type); + } + + public int getType() { + return dataWatcher.getWatchableObjectInt(20); + } + + public void setProps(EntityLivingBase target, EntityLivingBase summoner, int type, float damage) { + setAttackTarget(target); + this.summoner = summoner; + this.damage = damage; + setType(type); + } + + public void setApplyPotionEffect(PotionEffect effect) { + this.effect = effect; + } + + @Override + protected void updateEntityActionState() { + EntityLivingBase target = getAttackTarget(); + if(target != null) { + double d0 = target.posX + target.width / 2 - posX; + double d1 = target.posY + target.height / 2 - posY; + double d2 = target.posZ + target.width / 2 - posZ; + double d3 = d0 * d0 + d1 * d1 + d2 * d2; + + float mod = 0.45F; + if(getType() == 1) + mod = 0.1F; + + motionX += d0 / d3 * mod; + motionY += d1 / d3 * mod; + motionZ += d2 / d3 * mod; + + if(Math.sqrt(d3) < 1F) { + if(summoner != null) { + if(summoner instanceof EntityPlayer) + target.attackEntityFrom(DamageSource.causePlayerDamage((EntityPlayer) summoner), damage); + else { + target.attackEntityFrom(DamageSource.causeMobDamage(summoner), damage); + } + } else target.attackEntityFrom(DamageSource.causeMobDamage(this), damage); + if(effect != null && !(target instanceof EntityPlayer)) + target.addPotionEffect(effect); + die(); + } + } + + renderYawOffset = rotationYaw = -((float)Math.atan2(motionX, motionZ)) * 180.0F / (float)Math.PI; + } + + @Override + public boolean attackEntityFrom(DamageSource par1DamageSource, float par2) { + if(getType() == 0 && par1DamageSource.getEntity() != summoner || getType() == 1 && par1DamageSource.getEntity() instanceof EntityPlayer) + return super.attackEntityFrom(par1DamageSource, par2); + return false; + } + + @Override + public void onEntityUpdate() { + super.onEntityUpdate(); + + if(getAttackTarget() == null || ticksExisted > 200) + die(); + + boolean dark = getType() == 1; + if(worldObj.isRemote) + for(int i = 0; i < 4; i++) + Botania.proxy.sparkleFX(worldObj, posX + (Math.random() - 0.5) * 0.25, posY + 0.5 + (Math.random() - 0.5) * 0.25, posZ + (Math.random() - 0.5) * 0.25, dark ? 0.1F : 1F, dark ? 0.025F : 0.25F, dark ? 0.09F : 0.9F, 0.1F + (float) Math.random() * 0.25F, 12); + } + + public void die() { + setDead(); + + if(worldObj.isRemote && getType() == 0) + for(int i = 0; i < 12; i++) + Botania.proxy.sparkleFX(worldObj, posX + (Math.random() - 0.5) * 0.25, posY + 0.5 + (Math.random() - 0.5) * 0.25, posZ + (Math.random() - 0.5) * 0.25, 1F, 0.25F, 0.9F, 1F + (float) Math.random() * 0.25F, 5); + } + + @Override + protected boolean canDespawn() { + return false; + } + +} \ No newline at end of file diff --git a/src/main/java/vazkii/botania/common/entity/EntityPoolMinecart.java b/src/main/java/vazkii/botania/common/entity/EntityPoolMinecart.java index a3107a256a..1c5c260d8c 100644 --- a/src/main/java/vazkii/botania/common/entity/EntityPoolMinecart.java +++ b/src/main/java/vazkii/botania/common/entity/EntityPoolMinecart.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Mar 17, 2015, 6:36:43 PM (GMT)] */ package vazkii.botania.common.entity; @@ -29,127 +29,130 @@ public class EntityPoolMinecart extends EntityMinecart { - private static final int TRANSFER_RATE = 10000; - private static final String TAG_MANA = "mana"; - - public EntityPoolMinecart(World p_i1712_1_) { - super(p_i1712_1_); - } - - public EntityPoolMinecart(World p_i1715_1_, double p_i1715_2_, double p_i1715_4_, double p_i1715_6_) { - super(p_i1715_1_, p_i1715_2_, p_i1715_4_, p_i1715_6_); - } - - @Override - protected void entityInit() { - super.entityInit(); - dataWatcher.addObject(16, 0); - } - - @Override - public Block func_145817_o() { - return ModBlocks.pool; - } - - @Override - public ItemStack getCartItem() { - return new ItemStack(ModItems.poolMinecart); - } - - @Override - public int getMinecartType() { - return 0; - } - - @Override - public void killMinecart(DamageSource p_94095_1_) { - super.killMinecart(p_94095_1_); - func_145778_a(Item.getItemFromBlock(ModBlocks.pool), 1, 0.0F); - } - - @Override - public int getDefaultDisplayTileOffset() { - return 8; - } - - @Override - public void moveMinecartOnRail(int x, int y, int z, double par4) { - super.moveMinecartOnRail(x, y, z, par4); - - for (ForgeDirection dir : LibMisc.CARDINAL_DIRECTIONS) { - int xp = x + dir.offsetX; - int zp = z + dir.offsetZ; - Block block = worldObj.getBlock(xp, y, zp); - if (block == ModBlocks.pump) { - int xp_ = xp + dir.offsetX; - int zp_ = zp + dir.offsetZ; - int meta = worldObj.getBlockMetadata(xp, y, zp); - TileEntity tile = worldObj.getTileEntity(xp_, y, zp_); - TileEntity tile_ = worldObj.getTileEntity(xp, y, zp); - TilePump pump = (TilePump) tile_; - - if (tile != null && tile instanceof IManaPool && !pump.hasRedstone) { - IManaPool pool = (IManaPool) tile; - ForgeDirection pumpDir = ForgeDirection.getOrientation(meta); - boolean did = false; - boolean can = false; - - if (pumpDir == dir) { // Pool -> Cart - can = true; - int cartMana = getMana(); - int poolMana = pool.getCurrentMana(); - int transfer = Math.min(TRANSFER_RATE, poolMana); - int actualTransfer = Math.min(TilePool.MAX_MANA - cartMana, transfer); - if (actualTransfer > 0) { - pool.recieveMana(-transfer); - setMana(cartMana + actualTransfer); - did = true; - } - } else if (pumpDir == dir.getOpposite()) { // Cart -> Pool - can = true; - if (!pool.isFull()) { - int cartMana = getMana(); - int transfer = Math.min(TRANSFER_RATE, cartMana); - if (transfer > 0) { - pool.recieveMana(transfer); - setMana(cartMana - transfer); - did = true; - } - } - } - - if (did) { - VanillaPacketDispatcher.dispatchTEToNearbyPlayers(worldObj, xp_, y, zp_); - pump.hasCart = true; - if (!pump.active) pump.setActive(true); - } - - if (can) { - pump.hasCartOnTop = true; - pump.comparator = (int) ((double) getMana() / (double) TilePool.MAX_MANA * 15); - } - } - } - } - } - - @Override - protected void writeEntityToNBT(NBTTagCompound p_70014_1_) { - super.writeEntityToNBT(p_70014_1_); - p_70014_1_.setInteger(TAG_MANA, getMana()); - } - - @Override - protected void readEntityFromNBT(NBTTagCompound p_70037_1_) { - super.readEntityFromNBT(p_70037_1_); - setMana(p_70037_1_.getInteger(TAG_MANA)); - } - - public int getMana() { - return dataWatcher.getWatchableObjectInt(16); - } - - public void setMana(int mana) { - dataWatcher.updateObject(16, mana); - } + private static final int TRANSFER_RATE = 10000; + private static final String TAG_MANA = "mana"; + + public EntityPoolMinecart(World p_i1712_1_) { + super(p_i1712_1_); + } + + public EntityPoolMinecart(World p_i1715_1_, double p_i1715_2_, double p_i1715_4_, double p_i1715_6_) { + super(p_i1715_1_, p_i1715_2_, p_i1715_4_, p_i1715_6_); + } + + @Override + protected void entityInit() { + super.entityInit(); + dataWatcher.addObject(16, 0); + } + + @Override + public Block func_145817_o() { + return ModBlocks.pool; + } + + @Override + public ItemStack getCartItem() { + return new ItemStack(ModItems.poolMinecart); + } + + @Override + public int getMinecartType() { + return 0; + } + + @Override + public void killMinecart(DamageSource p_94095_1_) { + super.killMinecart(p_94095_1_); + func_145778_a(Item.getItemFromBlock(ModBlocks.pool), 1, 0.0F); + } + + @Override + public int getDefaultDisplayTileOffset() { + return 8; + } + + @Override + public void moveMinecartOnRail(int x, int y, int z, double par4) { + super.moveMinecartOnRail(x, y, z, par4); + + for(ForgeDirection dir : LibMisc.CARDINAL_DIRECTIONS) { + int xp = x + dir.offsetX; + int zp = z + dir.offsetZ; + Block block = worldObj.getBlock(xp, y, zp); + if(block == ModBlocks.pump) { + int xp_ = xp + dir.offsetX; + int zp_ = zp + dir.offsetZ; + int meta = worldObj.getBlockMetadata(xp, y, zp); + TileEntity tile = worldObj.getTileEntity(xp_, y, zp_); + TileEntity tile_ = worldObj.getTileEntity(xp, y, zp); + TilePump pump = (TilePump) tile_; + + if(tile != null && tile instanceof IManaPool && !pump.hasRedstone) { + IManaPool pool = (IManaPool) tile; + ForgeDirection pumpDir = ForgeDirection.getOrientation(meta); + boolean did = false; + boolean can = false; + + if(pumpDir == dir) { // Pool -> Cart + can = true; + int cartMana = getMana(); + int poolMana = pool.getCurrentMana(); + int transfer = Math.min(TRANSFER_RATE, poolMana); + int actualTransfer = Math.min(TilePool.MAX_MANA - cartMana, transfer); + if(actualTransfer > 0) { + pool.recieveMana(-transfer); + setMana(cartMana + actualTransfer); + did = true; + } + } else if(pumpDir == dir.getOpposite()) { // Cart -> Pool + can = true; + if(!pool.isFull()) { + int cartMana = getMana(); + int transfer = Math.min(TRANSFER_RATE, cartMana); + if(transfer > 0) { + pool.recieveMana(transfer); + setMana(cartMana - transfer); + did = true; + } + } + } + + if(did) { + VanillaPacketDispatcher.dispatchTEToNearbyPlayers(worldObj, xp_, y, zp_); + pump.hasCart = true; + if(!pump.active) + pump.setActive(true); + } + + if(can) { + pump.hasCartOnTop = true; + pump.comparator = (int) ((double) getMana() / (double) TilePool.MAX_MANA * 15); + } + + } + } + } + } + + @Override + protected void writeEntityToNBT(NBTTagCompound p_70014_1_) { + super.writeEntityToNBT(p_70014_1_); + p_70014_1_.setInteger(TAG_MANA, getMana()); + } + + @Override + protected void readEntityFromNBT(NBTTagCompound p_70037_1_) { + super.readEntityFromNBT(p_70037_1_); + setMana(p_70037_1_.getInteger(TAG_MANA)); + } + + public int getMana() { + return dataWatcher.getWatchableObjectInt(16); + } + + public void setMana(int mana) { + dataWatcher.updateObject(16, mana); + } + } diff --git a/src/main/java/vazkii/botania/common/entity/EntitySignalFlare.java b/src/main/java/vazkii/botania/common/entity/EntitySignalFlare.java index 00d34a04ef..bcecb6ffbf 100644 --- a/src/main/java/vazkii/botania/common/entity/EntitySignalFlare.java +++ b/src/main/java/vazkii/botania/common/entity/EntitySignalFlare.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Mar 3, 2014, 7:10:32 PM (GMT)] */ package vazkii.botania.common.entity; @@ -18,80 +18,61 @@ public class EntitySignalFlare extends Entity { - private static final String COLOR_TAG = "color"; + private static final String COLOR_TAG = "color"; - public EntitySignalFlare(World par1World) { - super(par1World); - setSize(0F, 0F); - dataWatcher.addObject(30, 0); - dataWatcher.setObjectWatched(30); - } + public EntitySignalFlare(World par1World) { + super(par1World); + setSize(0F, 0F); + dataWatcher.addObject(30, 0); + dataWatcher.setObjectWatched(30); + } - @Override - protected void entityInit() { - // NO-OP - } + @Override + protected void entityInit() { + // NO-OP + } - @Override - public void onEntityUpdate() { - super.onEntityUpdate(); - if (ticksExisted++ >= 100) setDead(); + @Override + public void onEntityUpdate() { + super.onEntityUpdate(); + if(ticksExisted++ >= 100) + setDead(); - if (!isDead) { - if (ticksExisted % 10 == 0) playSound("creeper.primed", 1F, 1F); + if(!isDead) { + if(ticksExisted % 10 == 0) + playSound("creeper.primed", 1F, 1F); - int color = getColor(); - if (color < 16 && color >= 0) { - float[] colorArray = EntitySheep.fleeceColorTable[color]; + int color = getColor(); + if(color < 16 && color >= 0) { + float[] colorArray = EntitySheep.fleeceColorTable[color]; - Botania.proxy.setWispFXDistanceLimit(false); - for (int i = 0; i < 3; i++) - Botania.proxy.wispFX( - worldObj, - posX, - posY, - posZ + 0.5, - colorArray[0], - colorArray[1], - colorArray[2], - (float) Math.random() * 5 + 1F, - (float) (Math.random() - 0.5F), - 10F * (float) Math.sqrt(256F / (256F - (float) posY)), - (float) (Math.random() - 0.5F)); + Botania.proxy.setWispFXDistanceLimit(false); + for(int i = 0; i < 3; i++) + Botania.proxy.wispFX(worldObj, posX, posY, posZ + 0.5, colorArray[0], colorArray[1], colorArray[2], (float) Math.random() * 5 + 1F, (float) (Math.random() - 0.5F), 10F * (float) Math.sqrt(256F / (256F - (float) posY)), (float) (Math.random() - 0.5F)); - for (int i = 0; i < 4; i++) - Botania.proxy.wispFX( - worldObj, - posX + 0.5, - 256, - posZ + 0.5, - colorArray[0], - colorArray[1], - colorArray[2], - (float) Math.random() * 15 + 8F, - (float) (Math.random() - 0.5F) * 8F, - 0F, - (float) (Math.random() - 0.5F) * 8F); - Botania.proxy.setWispFXDistanceLimit(true); - } - } - } + for(int i = 0; i < 4; i++) + Botania.proxy.wispFX(worldObj, posX + 0.5, 256, posZ + 0.5, colorArray[0], colorArray[1], colorArray[2], (float) Math.random() * 15 + 8F, (float) (Math.random() - 0.5F) * 8F, 0F, (float) (Math.random() - 0.5F) * 8F); + Botania.proxy.setWispFXDistanceLimit(true); + } + } + } - @Override - protected void readEntityFromNBT(NBTTagCompound nbttagcompound) { - setColor(nbttagcompound.getInteger(COLOR_TAG)); - } + @Override + protected void readEntityFromNBT(NBTTagCompound nbttagcompound) { + setColor(nbttagcompound.getInteger(COLOR_TAG)); + } - @Override - protected void writeEntityToNBT(NBTTagCompound nbttagcompound) { - nbttagcompound.setInteger(COLOR_TAG, getColor()); - } + @Override + protected void writeEntityToNBT(NBTTagCompound nbttagcompound) { + nbttagcompound.setInteger(COLOR_TAG, getColor()); + } - public void setColor(int color) { - dataWatcher.updateObject(30, color); - } + public void setColor(int color) { + dataWatcher.updateObject(30, color); + } + + public int getColor() { + return dataWatcher.getWatchableObjectInt(30); + } - public int getColor() { - return dataWatcher.getWatchableObjectInt(30); - } } diff --git a/src/main/java/vazkii/botania/common/entity/EntitySpark.java b/src/main/java/vazkii/botania/common/entity/EntitySpark.java index add6d91d35..e89206d3e7 100644 --- a/src/main/java/vazkii/botania/common/entity/EntitySpark.java +++ b/src/main/java/vazkii/botania/common/entity/EntitySpark.java @@ -2,15 +2,14 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Aug 21, 2014, 5:43:44 PM (GMT)] */ package vazkii.botania.common.entity; -import baubles.common.lib.PlayerHandler; import java.awt.Color; import java.util.ArrayList; import java.util.Arrays; @@ -21,6 +20,7 @@ import java.util.Map; import java.util.Set; import java.util.WeakHashMap; + import net.minecraft.entity.Entity; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; @@ -36,339 +36,348 @@ import vazkii.botania.common.Botania; import vazkii.botania.common.core.helper.Vector3; import vazkii.botania.common.item.ModItems; +import baubles.common.lib.PlayerHandler; public class EntitySpark extends Entity implements ISparkEntity { - private static final int TRANSFER_RATE = 1000; - private static final String TAG_UPGRADE = "upgrade"; - private static final String TAG_INVIS = "invis"; - public static final int INVISIBILITY_DATA_WATCHER_KEY = 27; - - Set transfers = Collections.newSetFromMap(new WeakHashMap()); - - int removeTransferants = 2; - boolean firstTick = false; - - public EntitySpark(World world) { - super(world); - isImmuneToFire = true; - } - - @Override - protected void entityInit() { - setSize(0.1F, 0.5F); - dataWatcher.addObject(INVISIBILITY_DATA_WATCHER_KEY, 0); - dataWatcher.addObject(28, 0); - dataWatcher.setObjectWatched(INVISIBILITY_DATA_WATCHER_KEY); - dataWatcher.setObjectWatched(28); - } - - @Override - public void onUpdate() { - super.onUpdate(); - - ISparkAttachable tile = getAttachedTile(); - if (tile == null) { - if (!worldObj.isRemote) setDead(); - return; - } - - boolean first = worldObj.isRemote && !firstTick; - int upgrade = getUpgrade(); - List allSparks = null; - if (first || upgrade == 2 || upgrade == 3) allSparks = SparkHelper.getSparksAround(worldObj, posX, posY, posZ); - - if (first) first = true; - - Collection transfers = getTransfers(); - - if (upgrade != 0) { - switch (upgrade) { - case 1: { // Dispersive - List players = - SparkHelper.getEntitiesAround(EntityPlayer.class, worldObj, posX, posY, posZ); - - Map> receivingPlayers = new HashMap(); - - ItemStack input = new ItemStack(ModItems.spark); - for (EntityPlayer player : players) { - List stacks = new ArrayList(); - stacks.addAll(Arrays.asList(player.inventory.mainInventory)); - stacks.addAll(Arrays.asList(player.inventory.armorInventory)); - stacks.addAll(Arrays.asList(PlayerHandler.getPlayerBaubles(player).stackList)); - - for (ItemStack stack : stacks) { - if (stack == null || !(stack.getItem() instanceof IManaItem)) continue; - - IManaItem manaItem = (IManaItem) stack.getItem(); - if (manaItem.canReceiveManaFromItem(stack, input)) { - Map receivingStacks; - boolean add = false; - if (!receivingPlayers.containsKey(player)) { - add = true; - receivingStacks = new HashMap(); - } else receivingStacks = receivingPlayers.get(player); - - int recv = Math.min( - getAttachedTile().getCurrentMana(), - Math.min(TRANSFER_RATE, manaItem.getMaxMana(stack) - manaItem.getMana(stack))); - if (recv > 0) { - receivingStacks.put(stack, recv); - if (add) receivingPlayers.put(player, receivingStacks); - } - } - } - } - - if (!receivingPlayers.isEmpty()) { - List keys = new ArrayList(receivingPlayers.keySet()); - Collections.shuffle(keys); - EntityPlayer player = keys.iterator().next(); - - Map items = receivingPlayers.get(player); - ItemStack stack = items.keySet().iterator().next(); - int cost = items.get(stack); - int manaToPut = Math.min(getAttachedTile().getCurrentMana(), cost); - ((IManaItem) stack.getItem()).addMana(stack, manaToPut); - getAttachedTile().recieveMana(-manaToPut); - particlesTowards(player); - } - - break; - } - case 2: { // Dominant - List validSparks = new ArrayList(); - for (ISparkEntity spark : allSparks) { - if (spark == this) continue; - - int upgrade_ = spark.getUpgrade(); - if (upgrade_ == 0 && spark.getAttachedTile() instanceof IManaPool) validSparks.add(spark); - } - if (validSparks.size() > 0) - validSparks - .get(worldObj.rand.nextInt(validSparks.size())) - .registerTransfer(this); - - break; - } - case 3: { // Recessive - for (ISparkEntity spark : allSparks) { - if (spark == this) continue; - - int upgrade_ = spark.getUpgrade(); - if (upgrade_ != 2 && upgrade_ != 3 && upgrade_ != 4) transfers.add(spark); - } - break; - } - } - } - - if (!transfers.isEmpty()) { - int manaTotal = Math.min(TRANSFER_RATE * transfers.size(), tile.getCurrentMana()); - int manaForEach = manaTotal / transfers.size(); - int manaSpent = 0; - - if (manaForEach > transfers.size()) { - for (ISparkEntity spark : transfers) { - if (spark.getAttachedTile() == null - || spark.getAttachedTile().isFull() - || spark.areIncomingTransfersDone()) { - manaTotal -= manaForEach; - continue; - } - - ISparkAttachable attached = spark.getAttachedTile(); - int spend = Math.min(attached.getAvailableSpaceForMana(), manaForEach); - attached.recieveMana(spend); - manaSpent += spend; - - particlesTowards((Entity) spark); - } - tile.recieveMana(-manaSpent); - } - } - - if (removeTransferants > 0) removeTransferants--; - getTransfers(); - } - - void particlesTowards(Entity e) { - Vector3 thisVec = Vector3.fromEntityCenter(this).add(0, 0, 0); - Vector3 receiverVec = Vector3.fromEntityCenter(e).add(0, 0, 0); - - double rc = 0.45; - thisVec.add((Math.random() - 0.5) * rc, (Math.random() - 0.5) * rc, (Math.random() - 0.5) * rc); - receiverVec.add((Math.random() - 0.5) * rc, (Math.random() - 0.5) * rc, (Math.random() - 0.5) * rc); - - Vector3 motion = receiverVec.copy().sub(thisVec); - motion.multiply(0.04F); - float r = 0.4F + 0.3F * (float) Math.random(); - float g = 0.4F + 0.3F * (float) Math.random(); - float b = 0.4F + 0.3F * (float) Math.random(); - float size = 0.125F + 0.125F * (float) Math.random(); - - Botania.proxy.wispFX( - worldObj, thisVec.x, thisVec.y, thisVec.z, r, g, b, size, (float) motion.x, (float) motion.y, (float) - motion.z); - } - - public static void particleBeam(Entity e1, Entity e2) { - if (e1 == null || e2 == null) return; - - Vector3 orig = new Vector3(e1.posX, e1.posY + 0.25, e1.posZ); - Vector3 end = new Vector3(e2.posX, e2.posY + 0.25, e2.posZ); - Vector3 diff = end.copy().sub(orig); - Vector3 movement = diff.copy().normalize().multiply(0.1); - int iters = (int) (diff.mag() / movement.mag()); - float huePer = 1F / iters; - float hueSum = (float) Math.random(); - - Vector3 currentPos = orig.copy(); - for (int i = 0; i < iters; i++) { - float hue = i * huePer + hueSum; - Color color = Color.getHSBColor(hue, 1F, 1F); - float r = Math.min(1F, color.getRed() / 255F + 0.4F); - float g = Math.min(1F, color.getGreen() / 255F + 0.4F); - float b = Math.min(1F, color.getBlue() / 255F + 0.4F); - - Botania.proxy.setSparkleFXNoClip(true); - Botania.proxy.sparkleFX(e1.worldObj, currentPos.x, currentPos.y, currentPos.z, r, g, b, 1F, 12); - Botania.proxy.setSparkleFXNoClip(false); - currentPos.add(movement); - } - } - - @Override - public boolean canBeCollidedWith() { - return true; - } - - @Override - public boolean interactFirst(EntityPlayer player) { - ItemStack stack = player.getCurrentEquippedItem(); - if (stack != null) { - int upgrade = getUpgrade(); - if (stack.getItem() == ModItems.twigWand) { - if (player.isSneaking()) { - if (upgrade > 0) { - if (!worldObj.isRemote) - entityDropItem(new ItemStack(ModItems.sparkUpgrade, 1, upgrade - 1), 0F); - setUpgrade(0); - - transfers.clear(); - removeTransferants = 2; - } else setDead(); - if (player.worldObj.isRemote) player.swingItem(); - return true; - } else { - List allSparks = SparkHelper.getSparksAround(worldObj, posX, posY, posZ); - for (ISparkEntity spark : allSparks) particleBeam(this, (Entity) spark); - return true; - } - } else if (stack.getItem() == ModItems.sparkUpgrade && upgrade == 0) { - int newUpgrade = stack.getItemDamage() + 1; - setUpgrade(newUpgrade); - stack.stackSize--; - if (player.worldObj.isRemote) player.swingItem(); - return true; - } - } - - return doPhantomInk(stack); - } - - public boolean doPhantomInk(ItemStack stack) { - if (stack != null && stack.getItem() == ModItems.phantomInk && !worldObj.isRemote) { - int invis = dataWatcher.getWatchableObjectInt(INVISIBILITY_DATA_WATCHER_KEY); - dataWatcher.updateObject(INVISIBILITY_DATA_WATCHER_KEY, ~invis & 1); - return true; - } - - return false; - } - - @Override - protected void readEntityFromNBT(NBTTagCompound cmp) { - setUpgrade(cmp.getInteger(TAG_UPGRADE)); - dataWatcher.updateObject(INVISIBILITY_DATA_WATCHER_KEY, cmp.getInteger(TAG_INVIS)); - } - - @Override - protected void writeEntityToNBT(NBTTagCompound cmp) { - cmp.setInteger(TAG_UPGRADE, getUpgrade()); - cmp.setInteger(TAG_INVIS, dataWatcher.getWatchableObjectInt(INVISIBILITY_DATA_WATCHER_KEY)); - } - - @Override - public void setDead() { - super.setDead(); - if (!worldObj.isRemote) { - int upgrade = getUpgrade(); - entityDropItem(new ItemStack(ModItems.spark), 0F); - if (upgrade > 0) entityDropItem(new ItemStack(ModItems.sparkUpgrade, 1, upgrade - 1), 0F); - } - } - - @Override - public ISparkAttachable getAttachedTile() { - int x = MathHelper.floor_double(posX); - int y = MathHelper.floor_double(posY) - 1; - int z = MathHelper.floor_double(posZ); - TileEntity tile = worldObj.getTileEntity(x, y, z); - if (tile != null && tile instanceof ISparkAttachable) return (ISparkAttachable) tile; - - return null; - } - - @Override - public Collection getTransfers() { - Collection removals = new ArrayList(); - - for (ISparkEntity e : transfers) { - ISparkEntity spark = e; - int upgr = getUpgrade(); - int supgr = spark.getUpgrade(); - ISparkAttachable atile = spark.getAttachedTile(); - - if (!(spark != this - && !spark.areIncomingTransfersDone() - && atile != null - && !atile.isFull() - && (upgr == 0 && supgr == 2 - || upgr == 3 && (supgr == 0 || supgr == 1) - || !(atile instanceof IManaPool)))) removals.add(e); - } - - if (!removals.isEmpty()) transfers.removeAll(removals); - - return transfers; - } - - private boolean hasTransfer(ISparkEntity entity) { - return transfers.contains(entity); - } - - @Override - public void registerTransfer(ISparkEntity entity) { - if (hasTransfer(entity)) return; - transfers.add(entity); - } - - @Override - public int getUpgrade() { - return dataWatcher.getWatchableObjectInt(28); - } - - @Override - public void setUpgrade(int upgrade) { - dataWatcher.updateObject(28, upgrade); - } - - @Override - public boolean areIncomingTransfersDone() { - ISparkAttachable tile = getAttachedTile(); - if (tile instanceof IManaPool) return removeTransferants > 0; - - return tile != null && tile.areIncomingTranfersDone(); - } + private static final int TRANSFER_RATE = 1000; + private static final String TAG_UPGRADE = "upgrade"; + private static final String TAG_INVIS = "invis"; + public static final int INVISIBILITY_DATA_WATCHER_KEY = 27; + + Set transfers = Collections.newSetFromMap(new WeakHashMap()); + + int removeTransferants = 2; + boolean firstTick = false; + + public EntitySpark(World world) { + super(world); + isImmuneToFire = true; + } + + @Override + protected void entityInit() { + setSize(0.1F, 0.5F); + dataWatcher.addObject(INVISIBILITY_DATA_WATCHER_KEY, 0); + dataWatcher.addObject(28, 0); + dataWatcher.setObjectWatched(INVISIBILITY_DATA_WATCHER_KEY); + dataWatcher.setObjectWatched(28); + } + + @Override + public void onUpdate() { + super.onUpdate(); + + ISparkAttachable tile = getAttachedTile(); + if(tile == null) { + if(!worldObj.isRemote) + setDead(); + return; + } + + boolean first = worldObj.isRemote && !firstTick; + int upgrade = getUpgrade(); + List allSparks = null; + if(first || upgrade == 2 || upgrade == 3) + allSparks = SparkHelper.getSparksAround(worldObj, posX, posY, posZ); + + if(first) + first = true; + + Collection transfers = getTransfers(); + + + if(upgrade != 0) { + switch(upgrade) { + case 1 : { // Dispersive + List players = SparkHelper.getEntitiesAround(EntityPlayer.class, worldObj, posX, posY, posZ); + + Map> receivingPlayers = new HashMap(); + + ItemStack input = new ItemStack(ModItems.spark); + for(EntityPlayer player : players) { + List stacks = new ArrayList(); + stacks.addAll(Arrays.asList(player.inventory.mainInventory)); + stacks.addAll(Arrays.asList(player.inventory.armorInventory)); + stacks.addAll(Arrays.asList(PlayerHandler.getPlayerBaubles(player).stackList)); + + for(ItemStack stack : stacks) { + if(stack == null || !(stack.getItem() instanceof IManaItem)) + continue; + + IManaItem manaItem = (IManaItem) stack.getItem(); + if(manaItem.canReceiveManaFromItem(stack, input)) { + Map receivingStacks; + boolean add = false; + if(!receivingPlayers.containsKey(player)) { + add = true; + receivingStacks = new HashMap(); + } else receivingStacks = receivingPlayers.get(player); + + int recv = Math.min(getAttachedTile().getCurrentMana(), Math.min(TRANSFER_RATE, manaItem.getMaxMana(stack) - manaItem.getMana(stack))); + if(recv > 0) { + receivingStacks.put(stack, recv); + if(add) + receivingPlayers.put(player, receivingStacks); + } + } + } + } + + if(!receivingPlayers.isEmpty()) { + List keys = new ArrayList(receivingPlayers.keySet()); + Collections.shuffle(keys); + EntityPlayer player = keys.iterator().next(); + + Map items = receivingPlayers.get(player); + ItemStack stack = items.keySet().iterator().next(); + int cost = items.get(stack); + int manaToPut = Math.min(getAttachedTile().getCurrentMana(), cost); + ((IManaItem) stack.getItem()).addMana(stack, manaToPut); + getAttachedTile().recieveMana(-manaToPut); + particlesTowards(player); + } + + break; + } + case 2 : { // Dominant + List validSparks = new ArrayList(); + for(ISparkEntity spark : allSparks) { + if(spark == this) + continue; + + int upgrade_ = spark.getUpgrade(); + if(upgrade_ == 0 && spark.getAttachedTile() instanceof IManaPool) + validSparks.add(spark); + } + if(validSparks.size() > 0) + validSparks.get(worldObj.rand.nextInt(validSparks.size())).registerTransfer(this); + + break; + } + case 3 : { // Recessive + for(ISparkEntity spark : allSparks) { + if(spark == this) + continue; + + int upgrade_ = spark.getUpgrade(); + if(upgrade_ != 2 && upgrade_ != 3 && upgrade_ != 4) + transfers.add(spark); + } + break; + } + } + } + + if(!transfers.isEmpty()) { + int manaTotal = Math.min(TRANSFER_RATE * transfers.size(), tile.getCurrentMana()); + int manaForEach = manaTotal / transfers.size(); + int manaSpent = 0; + + if(manaForEach > transfers.size()) { + for(ISparkEntity spark : transfers) { + if(spark.getAttachedTile() == null || spark.getAttachedTile().isFull() || spark.areIncomingTransfersDone()) { + manaTotal -= manaForEach; + continue; + } + + ISparkAttachable attached = spark.getAttachedTile(); + int spend = Math.min(attached.getAvailableSpaceForMana(), manaForEach); + attached.recieveMana(spend); + manaSpent += spend; + + particlesTowards((Entity) spark); + } + tile.recieveMana(-manaSpent); + } + } + + if(removeTransferants > 0) + removeTransferants--; + getTransfers(); + } + + void particlesTowards(Entity e) { + Vector3 thisVec = Vector3.fromEntityCenter(this).add(0, 0, 0); + Vector3 receiverVec = Vector3.fromEntityCenter(e).add(0, 0, 0); + + double rc = 0.45; + thisVec.add((Math.random() - 0.5) * rc, (Math.random() - 0.5) * rc, (Math.random() - 0.5) * rc); + receiverVec.add((Math.random() - 0.5) * rc, (Math.random() - 0.5) * rc, (Math.random() - 0.5) * rc); + + Vector3 motion = receiverVec.copy().sub(thisVec); + motion.multiply(0.04F); + float r = 0.4F + 0.3F * (float) Math.random(); + float g = 0.4F + 0.3F * (float) Math.random(); + float b = 0.4F + 0.3F * (float) Math.random(); + float size = 0.125F + 0.125F * (float) Math.random(); + + Botania.proxy.wispFX(worldObj, thisVec.x, thisVec.y, thisVec.z, r, g, b, size, (float) motion.x, (float) motion.y, (float) motion.z); + } + + public static void particleBeam(Entity e1, Entity e2) { + if(e1 == null || e2 == null) + return; + + Vector3 orig = new Vector3(e1.posX , e1.posY + 0.25, e1.posZ); + Vector3 end = new Vector3(e2.posX, e2.posY + 0.25, e2.posZ); + Vector3 diff = end.copy().sub(orig); + Vector3 movement = diff.copy().normalize().multiply(0.1); + int iters = (int) (diff.mag() / movement.mag()); + float huePer = 1F / iters; + float hueSum = (float) Math.random(); + + Vector3 currentPos = orig.copy(); + for(int i = 0; i < iters; i++) { + float hue = i * huePer + hueSum; + Color color = Color.getHSBColor(hue, 1F, 1F); + float r = Math.min(1F, color.getRed() / 255F + 0.4F); + float g = Math.min(1F, color.getGreen() / 255F + 0.4F); + float b = Math.min(1F, color.getBlue() / 255F + 0.4F); + + Botania.proxy.setSparkleFXNoClip(true); + Botania.proxy.sparkleFX(e1.worldObj, currentPos.x, currentPos.y, currentPos.z, r, g, b, 1F, 12); + Botania.proxy.setSparkleFXNoClip(false); + currentPos.add(movement); + } + } + + @Override + public boolean canBeCollidedWith() { + return true; + } + + @Override + public boolean interactFirst(EntityPlayer player) { + ItemStack stack = player.getCurrentEquippedItem(); + if(stack != null) { + int upgrade = getUpgrade(); + if(stack.getItem() == ModItems.twigWand) { + if(player.isSneaking()) { + if(upgrade > 0) { + if(!worldObj.isRemote) + entityDropItem(new ItemStack(ModItems.sparkUpgrade, 1, upgrade - 1), 0F); + setUpgrade(0); + + transfers.clear(); + removeTransferants = 2; + } else setDead(); + if(player.worldObj.isRemote) + player.swingItem(); + return true; + } else { + List allSparks = SparkHelper.getSparksAround(worldObj, posX, posY, posZ); + for(ISparkEntity spark : allSparks) + particleBeam(this, (Entity) spark); + return true; + } + } else if(stack.getItem() == ModItems.sparkUpgrade && upgrade == 0) { + int newUpgrade = stack.getItemDamage() + 1; + setUpgrade(newUpgrade); + stack.stackSize--; + if(player.worldObj.isRemote) + player.swingItem(); + return true; + } + } + + return doPhantomInk(stack); + } + + public boolean doPhantomInk(ItemStack stack) { + if(stack != null && stack.getItem() == ModItems.phantomInk && !worldObj.isRemote) { + int invis = dataWatcher.getWatchableObjectInt(INVISIBILITY_DATA_WATCHER_KEY); + dataWatcher.updateObject(INVISIBILITY_DATA_WATCHER_KEY, ~invis & 1); + return true; + } + + return false; + } + + @Override + protected void readEntityFromNBT(NBTTagCompound cmp) { + setUpgrade(cmp.getInteger(TAG_UPGRADE)); + dataWatcher.updateObject(INVISIBILITY_DATA_WATCHER_KEY, cmp.getInteger(TAG_INVIS)); + } + + @Override + protected void writeEntityToNBT(NBTTagCompound cmp) { + cmp.setInteger(TAG_UPGRADE, getUpgrade()); + cmp.setInteger(TAG_INVIS, dataWatcher.getWatchableObjectInt(INVISIBILITY_DATA_WATCHER_KEY)); + } + + @Override + public void setDead() { + super.setDead(); + if(!worldObj.isRemote) { + int upgrade = getUpgrade(); + entityDropItem(new ItemStack(ModItems.spark), 0F); + if(upgrade > 0) + entityDropItem(new ItemStack(ModItems.sparkUpgrade, 1, upgrade - 1), 0F); + } + } + + @Override + public ISparkAttachable getAttachedTile() { + int x = MathHelper.floor_double(posX); + int y = MathHelper.floor_double(posY) - 1; + int z = MathHelper.floor_double(posZ); + TileEntity tile = worldObj.getTileEntity(x, y, z); + if(tile != null && tile instanceof ISparkAttachable) + return (ISparkAttachable) tile; + + return null; + } + + + @Override + public Collection getTransfers() { + Collection removals = new ArrayList(); + + for(ISparkEntity e : transfers) { + ISparkEntity spark = e; + int upgr = getUpgrade(); + int supgr = spark.getUpgrade(); + ISparkAttachable atile = spark.getAttachedTile(); + + if(!(spark != this && !spark.areIncomingTransfersDone() && atile != null && !atile.isFull() && (upgr == 0 && supgr == 2 || upgr == 3 && (supgr == 0 || supgr == 1) || !(atile instanceof IManaPool)))) + removals.add(e); + } + + if(!removals.isEmpty()) + transfers.removeAll(removals); + + return transfers; + } + + private boolean hasTransfer(ISparkEntity entity) { + return transfers.contains(entity); + } + + @Override + public void registerTransfer(ISparkEntity entity) { + if(hasTransfer(entity)) + return; + transfers.add(entity); + } + + @Override + public int getUpgrade() { + return dataWatcher.getWatchableObjectInt(28); + } + + @Override + public void setUpgrade(int upgrade) { + dataWatcher.updateObject(28, upgrade); + } + + @Override + public boolean areIncomingTransfersDone() { + ISparkAttachable tile = getAttachedTile(); + if(tile instanceof IManaPool) + return removeTransferants > 0; + + return tile != null && tile.areIncomingTranfersDone(); + } + } diff --git a/src/main/java/vazkii/botania/common/entity/EntityThornChakram.java b/src/main/java/vazkii/botania/common/entity/EntityThornChakram.java index c6d432f4fd..5fea972290 100644 --- a/src/main/java/vazkii/botania/common/entity/EntityThornChakram.java +++ b/src/main/java/vazkii/botania/common/entity/EntityThornChakram.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jan 25, 2015, 6:47:35 PM (GMT)] */ package vazkii.botania.common.entity; @@ -30,148 +30,134 @@ public class EntityThornChakram extends EntityThrowable { - private static final int MAX_BOUNCES = 16; - boolean bounced = false; - - public EntityThornChakram(World world) { - super(world); - } - - public EntityThornChakram(World world, EntityLivingBase e) { - super(world, e); - } - - @Override - protected void entityInit() { - dataWatcher.addObject(30, 0); - dataWatcher.addObject(31, (byte) 0); - - dataWatcher.setObjectWatched(30); - dataWatcher.setObjectWatched(31); - } - - @Override - public void onUpdate() { - double mx = motionX; - double my = motionY; - double mz = motionZ; - - super.onUpdate(); - - if (isFire()) { - double r = 0.1; - double m = 0.1; - for (int i = 0; i < 3; i++) - worldObj.spawnParticle( - "flame", - posX + r * (Math.random() - 0.5), - posY + r * (Math.random() - 0.5), - posZ + r * (Math.random() - 0.5), - m * (Math.random() - 0.5), - m * (Math.random() - 0.5), - m * (Math.random() - 0.5)); - } - - int bounces = getTimesBounced(); - if (bounces >= MAX_BOUNCES || ticksExisted > 60) { - EntityLivingBase thrower = getThrower(); - noClip = true; - if (thrower == null) dropAndKill(); - else { - Vector3 motion = Vector3.fromEntityCenter(thrower) - .sub(Vector3.fromEntityCenter(this)) - .normalize(); - motionX = motion.x; - motionY = motion.y; - motionZ = motion.z; - if (MathHelper.pointDistanceSpace(posX, posY, posZ, thrower.posX, thrower.posY, thrower.posZ) < 1) - if (!(thrower instanceof EntityPlayer - && (((EntityPlayer) thrower).capabilities.isCreativeMode - || ((EntityPlayer) thrower).inventory.addItemStackToInventory(getItemStack())))) - dropAndKill(); - else if (!worldObj.isRemote) setDead(); - } - } else { - if (!bounced) { - motionX = mx; - motionY = my; - motionZ = mz; - } - bounced = false; - } - } - - private void dropAndKill() { - if (!worldObj.isRemote) { - ItemStack stack = getItemStack(); - EntityItem item = new EntityItem(worldObj, posX, posY, posZ, stack); - worldObj.spawnEntityInWorld(item); - setDead(); - } - } - - private ItemStack getItemStack() { - return new ItemStack(ModItems.thornChakram, 1, isFire() ? 1 : 0); - } - - @Override - protected void onImpact(MovingObjectPosition pos) { - if (noClip) return; - - Block block = worldObj.getBlock(pos.blockX, pos.blockY, pos.blockZ); - worldObj.getTileEntity(pos.blockX, pos.blockY, pos.blockZ); - if (block instanceof BlockBush || block instanceof BlockLeaves) return; - - boolean fire = isFire(); - EntityLivingBase thrower = getThrower(); - if (pos.entityHit != null && pos.entityHit instanceof EntityLivingBase && pos.entityHit != thrower) { - ((EntityLivingBase) pos.entityHit) - .attackEntityFrom( - thrower != null - ? thrower instanceof EntityPlayer - ? DamageSource.causePlayerDamage((EntityPlayer) thrower) - : DamageSource.causeMobDamage(thrower) - : DamageSource.generic, - 12); - if (fire) ((EntityLivingBase) pos.entityHit).setFire(5); - else if (worldObj.rand.nextInt(3) == 0) - ((EntityLivingBase) pos.entityHit).addPotionEffect(new PotionEffect(Potion.poison.id, 60, 0)); - } else { - int bounces = getTimesBounced(); - if (bounces < MAX_BOUNCES) { - Vector3 currentMovementVec = new Vector3(motionX, motionY, motionZ); - ForgeDirection dir = ForgeDirection.getOrientation(pos.sideHit); - Vector3 normalVector = new Vector3(dir.offsetX, dir.offsetY, dir.offsetZ).normalize(); - Vector3 movementVec = normalVector - .multiply(-2 * currentMovementVec.dotProduct(normalVector)) - .add(currentMovementVec); - - motionX = movementVec.x; - motionY = movementVec.y; - motionZ = movementVec.z; - bounced = true; - } - } - } - - @Override - protected float getGravityVelocity() { - return 0F; - } - - public int getTimesBounced() { - return dataWatcher.getWatchableObjectInt(30); - } - - public void setTimesBounced(int times) { - dataWatcher.updateObject(30, times); - } - - public boolean isFire() { - return dataWatcher.getWatchableObjectByte(31) != 0; - } - - public void setFire(boolean fire) { - dataWatcher.updateObject(31, (byte) (fire ? 1 : 0)); - } + private static final int MAX_BOUNCES = 16; + boolean bounced = false; + + public EntityThornChakram(World world) { + super(world); + } + + public EntityThornChakram(World world, EntityLivingBase e) { + super(world, e); + } + + @Override + protected void entityInit() { + dataWatcher.addObject(30, 0); + dataWatcher.addObject(31, (byte) 0); + + dataWatcher.setObjectWatched(30); + dataWatcher.setObjectWatched(31); + } + + @Override + public void onUpdate() { + double mx = motionX; + double my = motionY; + double mz = motionZ; + + super.onUpdate(); + + if(isFire()) { + double r = 0.1; + double m = 0.1; + for(int i = 0; i < 3; i++) + worldObj.spawnParticle("flame", posX + r * (Math.random() - 0.5), posY + r * (Math.random() - 0.5), posZ + r * (Math.random() - 0.5), m * (Math.random() - 0.5), m * (Math.random() - 0.5), m * (Math.random() - 0.5)); + } + + int bounces = getTimesBounced(); + if(bounces >= MAX_BOUNCES || ticksExisted > 60) { + EntityLivingBase thrower = getThrower(); + noClip = true; + if(thrower == null) + dropAndKill(); + else { + Vector3 motion = Vector3.fromEntityCenter(thrower).sub(Vector3.fromEntityCenter(this)).normalize(); + motionX = motion.x; + motionY = motion.y; + motionZ = motion.z; + if(MathHelper.pointDistanceSpace(posX, posY, posZ, thrower.posX, thrower.posY, thrower.posZ) < 1) + if(!(thrower instanceof EntityPlayer && (((EntityPlayer) thrower).capabilities.isCreativeMode || ((EntityPlayer) thrower).inventory.addItemStackToInventory(getItemStack())))) + dropAndKill(); + else if(!worldObj.isRemote) + setDead(); + } + } else { + if(!bounced) { + motionX = mx; + motionY = my; + motionZ = mz; + } + bounced = false; + } + } + + private void dropAndKill() { + if(!worldObj.isRemote) { + ItemStack stack = getItemStack(); + EntityItem item = new EntityItem(worldObj, posX, posY, posZ, stack); + worldObj.spawnEntityInWorld(item); + setDead(); + } + } + + private ItemStack getItemStack() { + return new ItemStack(ModItems.thornChakram, 1, isFire() ? 1 : 0); + } + + @Override + protected void onImpact(MovingObjectPosition pos) { + if(noClip) + return; + + Block block = worldObj.getBlock(pos.blockX, pos.blockY, pos.blockZ); + worldObj.getTileEntity(pos.blockX, pos.blockY, pos.blockZ); + if(block instanceof BlockBush || block instanceof BlockLeaves) + return; + + boolean fire = isFire(); + EntityLivingBase thrower = getThrower(); + if(pos.entityHit != null && pos.entityHit instanceof EntityLivingBase && pos.entityHit != thrower) { + ((EntityLivingBase) pos.entityHit).attackEntityFrom(thrower != null ? thrower instanceof EntityPlayer ? DamageSource.causePlayerDamage((EntityPlayer) thrower) : DamageSource.causeMobDamage(thrower) : DamageSource.generic, 12); + if(fire) + ((EntityLivingBase) pos.entityHit).setFire(5); + else if(worldObj.rand.nextInt(3) == 0) + ((EntityLivingBase) pos.entityHit).addPotionEffect(new PotionEffect(Potion.poison.id, 60, 0)); + } else { + int bounces = getTimesBounced(); + if(bounces < MAX_BOUNCES) { + Vector3 currentMovementVec = new Vector3(motionX, motionY, motionZ); + ForgeDirection dir = ForgeDirection.getOrientation(pos.sideHit); + Vector3 normalVector = new Vector3(dir.offsetX, dir.offsetY, dir.offsetZ).normalize(); + Vector3 movementVec = normalVector.multiply(-2 * currentMovementVec.dotProduct(normalVector)).add(currentMovementVec); + + motionX = movementVec.x; + motionY = movementVec.y; + motionZ = movementVec.z; + bounced = true; + } + } + } + + @Override + protected float getGravityVelocity() { + return 0F; + } + + public int getTimesBounced() { + return dataWatcher.getWatchableObjectInt(30); + } + + public void setTimesBounced(int times) { + dataWatcher.updateObject(30, times); + } + + public boolean isFire() { + return dataWatcher.getWatchableObjectByte(31) != 0; + } + + public void setFire(boolean fire) { + dataWatcher.updateObject(31, (byte) (fire ? 1 : 0)); + } + } diff --git a/src/main/java/vazkii/botania/common/entity/EntityThrowableCopy.java b/src/main/java/vazkii/botania/common/entity/EntityThrowableCopy.java index 4b98d5a800..38202c607a 100644 --- a/src/main/java/vazkii/botania/common/entity/EntityThrowableCopy.java +++ b/src/main/java/vazkii/botania/common/entity/EntityThrowableCopy.java @@ -2,17 +2,16 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Aug 16, 2015, 4:01:43 PM (GMT)] */ package vazkii.botania.common.entity; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; import java.util.List; + import net.minecraft.block.Block; import net.minecraft.entity.Entity; import net.minecraft.entity.EntityLivingBase; @@ -25,332 +24,345 @@ import net.minecraft.util.MovingObjectPosition; import net.minecraft.util.Vec3; import net.minecraft.world.World; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; // A copy of the vanilla EntityThrowable class // Doing this because if I didn't do this it'd be an EntityThrowable // And we all know how much mods like deflecting EntityThrowables public abstract class EntityThrowableCopy extends Entity implements IProjectile { - private int field_145788_c = -1; - private int field_145786_d = -1; - private int field_145787_e = -1; - private Block field_145785_f; - protected boolean inGround; - public int throwableShake; - /** The entity that threw this throwable item. */ - private EntityLivingBase thrower; - - private String throwerName; - private int ticksInGround; - private int ticksInAir; - - public EntityThrowableCopy(World p_i1776_1_) { - super(p_i1776_1_); - setSize(0.25F, 0.25F); - } - - @Override - protected void entityInit() {} - - /** - * Checks if the entity is in range to render by using the past in distance and comparing it to its average edge - * length * 64 * renderDistanceWeight Args: distance - */ - @Override - @SideOnly(Side.CLIENT) - public boolean isInRangeToRenderDist(double p_70112_1_) { - double d1 = boundingBox.getAverageEdgeLength() * 4.0D; - d1 *= 64.0D; - return p_70112_1_ < d1 * d1; - } - - public EntityThrowableCopy(World p_i1777_1_, EntityLivingBase p_i1777_2_) { - super(p_i1777_1_); - thrower = p_i1777_2_; - setSize(0.25F, 0.25F); - setLocationAndAngles( - p_i1777_2_.posX, - p_i1777_2_.posY + p_i1777_2_.getEyeHeight(), - p_i1777_2_.posZ, - p_i1777_2_.rotationYaw, - p_i1777_2_.rotationPitch); - posX -= MathHelper.cos(rotationYaw / 180.0F * (float) Math.PI) * 0.16F; - posY -= 0.10000000149011612D; - posZ -= MathHelper.sin(rotationYaw / 180.0F * (float) Math.PI) * 0.16F; - setPosition(posX, posY, posZ); - yOffset = 0.0F; - float f = 0.4F; - motionX = -MathHelper.sin(rotationYaw / 180.0F * (float) Math.PI) - * MathHelper.cos(rotationPitch / 180.0F * (float) Math.PI) - * f; - motionZ = MathHelper.cos(rotationYaw / 180.0F * (float) Math.PI) - * MathHelper.cos(rotationPitch / 180.0F * (float) Math.PI) - * f; - motionY = -MathHelper.sin((rotationPitch + func_70183_g()) / 180.0F * (float) Math.PI) * f; - setThrowableHeading(motionX, motionY, motionZ, func_70182_d(), 1.0F); - } - - public EntityThrowableCopy(World p_i1778_1_, double p_i1778_2_, double p_i1778_4_, double p_i1778_6_) { - super(p_i1778_1_); - ticksInGround = 0; - setSize(0.25F, 0.25F); - setPosition(p_i1778_2_, p_i1778_4_, p_i1778_6_); - yOffset = 0.0F; - } - - protected float func_70182_d() { - return 1.5F; - } - - protected float func_70183_g() { - return 0.0F; - } - - /** - * Similar to setArrowHeading, it's point the throwable entity to a x, y, z direction. - */ - @Override - public void setThrowableHeading( - double p_70186_1_, double p_70186_3_, double p_70186_5_, float p_70186_7_, float p_70186_8_) { - float f2 = MathHelper.sqrt_double(p_70186_1_ * p_70186_1_ + p_70186_3_ * p_70186_3_ + p_70186_5_ * p_70186_5_); - p_70186_1_ /= f2; - p_70186_3_ /= f2; - p_70186_5_ /= f2; - p_70186_1_ += rand.nextGaussian() * 0.007499999832361937D * p_70186_8_; - p_70186_3_ += rand.nextGaussian() * 0.007499999832361937D * p_70186_8_; - p_70186_5_ += rand.nextGaussian() * 0.007499999832361937D * p_70186_8_; - p_70186_1_ *= p_70186_7_; - p_70186_3_ *= p_70186_7_; - p_70186_5_ *= p_70186_7_; - motionX = p_70186_1_; - motionY = p_70186_3_; - motionZ = p_70186_5_; - float f3 = MathHelper.sqrt_double(p_70186_1_ * p_70186_1_ + p_70186_5_ * p_70186_5_); - prevRotationYaw = rotationYaw = (float) (Math.atan2(p_70186_1_, p_70186_5_) * 180.0D / Math.PI); - prevRotationPitch = rotationPitch = (float) (Math.atan2(p_70186_3_, f3) * 180.0D / Math.PI); - ticksInGround = 0; - } - - /** - * Sets the velocity to the args. Args: x, y, z - */ - @Override - @SideOnly(Side.CLIENT) - public void setVelocity(double p_70016_1_, double p_70016_3_, double p_70016_5_) { - motionX = p_70016_1_; - motionY = p_70016_3_; - motionZ = p_70016_5_; - - if (prevRotationPitch == 0.0F && prevRotationYaw == 0.0F) { - float f = MathHelper.sqrt_double(p_70016_1_ * p_70016_1_ + p_70016_5_ * p_70016_5_); - prevRotationYaw = rotationYaw = (float) (Math.atan2(p_70016_1_, p_70016_5_) * 180.0D / Math.PI); - prevRotationPitch = rotationPitch = (float) (Math.atan2(p_70016_3_, f) * 180.0D / Math.PI); - } - } - - /** - * Called to update the entity's position/logic. - */ - @Override - public void onUpdate() { - lastTickPosX = posX; - lastTickPosY = posY; - lastTickPosZ = posZ; - super.onUpdate(); - - if (throwableShake > 0) { - --throwableShake; - } - - if (inGround) { - if (worldObj.getBlock(field_145788_c, field_145786_d, field_145787_e) == field_145785_f) { - ++ticksInGround; - - if (ticksInGround == 1200) { - setDead(); - } - - return; - } - - inGround = false; - motionX *= rand.nextFloat() * 0.2F; - motionY *= rand.nextFloat() * 0.2F; - motionZ *= rand.nextFloat() * 0.2F; - ticksInGround = 0; - ticksInAir = 0; - } else { - ++ticksInAir; - } - - Vec3 vec3 = Vec3.createVectorHelper(posX, posY, posZ); - Vec3 vec31 = Vec3.createVectorHelper(posX + motionX, posY + motionY, posZ + motionZ); - MovingObjectPosition movingobjectposition = worldObj.rayTraceBlocks(vec3, vec31); - vec3 = Vec3.createVectorHelper(posX, posY, posZ); - vec31 = Vec3.createVectorHelper(posX + motionX, posY + motionY, posZ + motionZ); - - if (movingobjectposition != null) { - vec31 = Vec3.createVectorHelper( - movingobjectposition.hitVec.xCoord, - movingobjectposition.hitVec.yCoord, - movingobjectposition.hitVec.zCoord); - } - - if (!worldObj.isRemote) { - Entity entity = null; - List list = worldObj.getEntitiesWithinAABBExcludingEntity( - this, boundingBox.addCoord(motionX, motionY, motionZ).expand(1.0D, 1.0D, 1.0D)); - double d0 = 0.0D; - EntityLivingBase entitylivingbase = getThrower(); - - for (int j = 0; j < list.size(); ++j) { - Entity entity1 = (Entity) list.get(j); - - if (entity1.canBeCollidedWith() && (entity1 != entitylivingbase || ticksInAir >= 5)) { - float f = 0.3F; - AxisAlignedBB axisalignedbb = entity1.boundingBox.expand(f, f, f); - MovingObjectPosition movingobjectposition1 = axisalignedbb.calculateIntercept(vec3, vec31); - - if (movingobjectposition1 != null) { - double d1 = vec3.distanceTo(movingobjectposition1.hitVec); - - if (d1 < d0 || d0 == 0.0D) { - entity = entity1; - d0 = d1; - } - } - } - } - - if (entity != null) { - movingobjectposition = new MovingObjectPosition(entity); - } - } - - if (movingobjectposition != null) { - if (movingobjectposition.typeOfHit == MovingObjectPosition.MovingObjectType.BLOCK - && worldObj.getBlock( - movingobjectposition.blockX, - movingobjectposition.blockY, - movingobjectposition.blockZ) - == Blocks.portal) { - setInPortal(); - } else { - onImpact(movingobjectposition); - } - } - - posX += motionX; - posY += motionY; - posZ += motionZ; - float f1 = MathHelper.sqrt_double(motionX * motionX + motionZ * motionZ); - rotationYaw = (float) (Math.atan2(motionX, motionZ) * 180.0D / Math.PI); - - for (rotationPitch = (float) (Math.atan2(motionY, f1) * 180.0D / Math.PI); - rotationPitch - prevRotationPitch < -180.0F; - prevRotationPitch -= 360.0F) { - ; - } - - while (rotationPitch - prevRotationPitch >= 180.0F) { - prevRotationPitch += 360.0F; - } - - while (rotationYaw - prevRotationYaw < -180.0F) { - prevRotationYaw -= 360.0F; - } - - while (rotationYaw - prevRotationYaw >= 180.0F) { - prevRotationYaw += 360.0F; - } - - rotationPitch = prevRotationPitch + (rotationPitch - prevRotationPitch) * 0.2F; - rotationYaw = prevRotationYaw + (rotationYaw - prevRotationYaw) * 0.2F; - float f2 = 0.99F; - float f3 = getGravityVelocity(); - - if (isInWater()) { - for (int i = 0; i < 4; ++i) { - float f4 = 0.25F; - worldObj.spawnParticle( - "bubble", - posX - motionX * f4, - posY - motionY * f4, - posZ - motionZ * f4, - motionX, - motionY, - motionZ); - } - - f2 = 0.8F; - } - - motionX *= f2; - motionY *= f2; - motionZ *= f2; - motionY -= f3; - setPosition(posX, posY, posZ); - } - - /** - * Gets the amount of gravity to apply to the thrown entity with each tick. - */ - protected float getGravityVelocity() { - return 0.03F; - } - - /** - * Called when this EntityThrowable hits a block or entity. - */ - protected abstract void onImpact(MovingObjectPosition p_70184_1_); - - /** - * (abstract) Protected helper method to write subclass entity data to NBT. - */ - @Override - public void writeEntityToNBT(NBTTagCompound p_70014_1_) { - p_70014_1_.setShort("xTile", (short) field_145788_c); - p_70014_1_.setShort("yTile", (short) field_145786_d); - p_70014_1_.setShort("zTile", (short) field_145787_e); - p_70014_1_.setByte("inTile", (byte) Block.getIdFromBlock(field_145785_f)); - p_70014_1_.setByte("shake", (byte) throwableShake); - p_70014_1_.setByte("inGround", (byte) (inGround ? 1 : 0)); - - if ((throwerName == null || throwerName.length() == 0) && thrower != null && thrower instanceof EntityPlayer) { - throwerName = thrower.getCommandSenderName(); - } - - p_70014_1_.setString("ownerName", throwerName == null ? "" : throwerName); - } - - /** - * (abstract) Protected helper method to read subclass entity data from NBT. - */ - @Override - public void readEntityFromNBT(NBTTagCompound p_70037_1_) { - field_145788_c = p_70037_1_.getShort("xTile"); - field_145786_d = p_70037_1_.getShort("yTile"); - field_145787_e = p_70037_1_.getShort("zTile"); - field_145785_f = Block.getBlockById(p_70037_1_.getByte("inTile") & 255); - throwableShake = p_70037_1_.getByte("shake") & 255; - inGround = p_70037_1_.getByte("inGround") == 1; - throwerName = p_70037_1_.getString("ownerName"); - - if (throwerName != null && throwerName.length() == 0) { - throwerName = null; - } - } - - @Override - @SideOnly(Side.CLIENT) - public float getShadowSize() { - return 0.0F; - } - - public EntityLivingBase getThrower() { - if (thrower == null && throwerName != null && throwerName.length() > 0) { - thrower = worldObj.getPlayerEntityByName(throwerName); - } - - return thrower; - } -} + private int field_145788_c = -1; + private int field_145786_d = -1; + private int field_145787_e = -1; + private Block field_145785_f; + protected boolean inGround; + public int throwableShake; + /** The entity that threw this throwable item. */ + private EntityLivingBase thrower; + private String throwerName; + private int ticksInGround; + private int ticksInAir; + public EntityThrowableCopy(World p_i1776_1_) + { + super(p_i1776_1_); + setSize(0.25F, 0.25F); + } + + @Override + protected void entityInit() {} + + /** + * Checks if the entity is in range to render by using the past in distance and comparing it to its average edge + * length * 64 * renderDistanceWeight Args: distance + */ + @Override + @SideOnly(Side.CLIENT) + public boolean isInRangeToRenderDist(double p_70112_1_) + { + double d1 = boundingBox.getAverageEdgeLength() * 4.0D; + d1 *= 64.0D; + return p_70112_1_ < d1 * d1; + } + + public EntityThrowableCopy(World p_i1777_1_, EntityLivingBase p_i1777_2_) + { + super(p_i1777_1_); + thrower = p_i1777_2_; + setSize(0.25F, 0.25F); + setLocationAndAngles(p_i1777_2_.posX, p_i1777_2_.posY + p_i1777_2_.getEyeHeight(), p_i1777_2_.posZ, p_i1777_2_.rotationYaw, p_i1777_2_.rotationPitch); + posX -= MathHelper.cos(rotationYaw / 180.0F * (float)Math.PI) * 0.16F; + posY -= 0.10000000149011612D; + posZ -= MathHelper.sin(rotationYaw / 180.0F * (float)Math.PI) * 0.16F; + setPosition(posX, posY, posZ); + yOffset = 0.0F; + float f = 0.4F; + motionX = -MathHelper.sin(rotationYaw / 180.0F * (float)Math.PI) * MathHelper.cos(rotationPitch / 180.0F * (float)Math.PI) * f; + motionZ = MathHelper.cos(rotationYaw / 180.0F * (float)Math.PI) * MathHelper.cos(rotationPitch / 180.0F * (float)Math.PI) * f; + motionY = -MathHelper.sin((rotationPitch + func_70183_g()) / 180.0F * (float)Math.PI) * f; + setThrowableHeading(motionX, motionY, motionZ, func_70182_d(), 1.0F); + } + + public EntityThrowableCopy(World p_i1778_1_, double p_i1778_2_, double p_i1778_4_, double p_i1778_6_) + { + super(p_i1778_1_); + ticksInGround = 0; + setSize(0.25F, 0.25F); + setPosition(p_i1778_2_, p_i1778_4_, p_i1778_6_); + yOffset = 0.0F; + } + + protected float func_70182_d() + { + return 1.5F; + } + + protected float func_70183_g() + { + return 0.0F; + } + + /** + * Similar to setArrowHeading, it's point the throwable entity to a x, y, z direction. + */ + @Override + public void setThrowableHeading(double p_70186_1_, double p_70186_3_, double p_70186_5_, float p_70186_7_, float p_70186_8_) + { + float f2 = MathHelper.sqrt_double(p_70186_1_ * p_70186_1_ + p_70186_3_ * p_70186_3_ + p_70186_5_ * p_70186_5_); + p_70186_1_ /= f2; + p_70186_3_ /= f2; + p_70186_5_ /= f2; + p_70186_1_ += rand.nextGaussian() * 0.007499999832361937D * p_70186_8_; + p_70186_3_ += rand.nextGaussian() * 0.007499999832361937D * p_70186_8_; + p_70186_5_ += rand.nextGaussian() * 0.007499999832361937D * p_70186_8_; + p_70186_1_ *= p_70186_7_; + p_70186_3_ *= p_70186_7_; + p_70186_5_ *= p_70186_7_; + motionX = p_70186_1_; + motionY = p_70186_3_; + motionZ = p_70186_5_; + float f3 = MathHelper.sqrt_double(p_70186_1_ * p_70186_1_ + p_70186_5_ * p_70186_5_); + prevRotationYaw = rotationYaw = (float)(Math.atan2(p_70186_1_, p_70186_5_) * 180.0D / Math.PI); + prevRotationPitch = rotationPitch = (float)(Math.atan2(p_70186_3_, f3) * 180.0D / Math.PI); + ticksInGround = 0; + } + + /** + * Sets the velocity to the args. Args: x, y, z + */ + @Override + @SideOnly(Side.CLIENT) + public void setVelocity(double p_70016_1_, double p_70016_3_, double p_70016_5_) + { + motionX = p_70016_1_; + motionY = p_70016_3_; + motionZ = p_70016_5_; + + if (prevRotationPitch == 0.0F && prevRotationYaw == 0.0F) + { + float f = MathHelper.sqrt_double(p_70016_1_ * p_70016_1_ + p_70016_5_ * p_70016_5_); + prevRotationYaw = rotationYaw = (float)(Math.atan2(p_70016_1_, p_70016_5_) * 180.0D / Math.PI); + prevRotationPitch = rotationPitch = (float)(Math.atan2(p_70016_3_, f) * 180.0D / Math.PI); + } + } + + /** + * Called to update the entity's position/logic. + */ + @Override + public void onUpdate() + { + lastTickPosX = posX; + lastTickPosY = posY; + lastTickPosZ = posZ; + super.onUpdate(); + + if (throwableShake > 0) + { + --throwableShake; + } + + if (inGround) + { + if (worldObj.getBlock(field_145788_c, field_145786_d, field_145787_e) == field_145785_f) + { + ++ticksInGround; + + if (ticksInGround == 1200) + { + setDead(); + } + + return; + } + + inGround = false; + motionX *= rand.nextFloat() * 0.2F; + motionY *= rand.nextFloat() * 0.2F; + motionZ *= rand.nextFloat() * 0.2F; + ticksInGround = 0; + ticksInAir = 0; + } + else + { + ++ticksInAir; + } + + Vec3 vec3 = Vec3.createVectorHelper(posX, posY, posZ); + Vec3 vec31 = Vec3.createVectorHelper(posX + motionX, posY + motionY, posZ + motionZ); + MovingObjectPosition movingobjectposition = worldObj.rayTraceBlocks(vec3, vec31); + vec3 = Vec3.createVectorHelper(posX, posY, posZ); + vec31 = Vec3.createVectorHelper(posX + motionX, posY + motionY, posZ + motionZ); + + if (movingobjectposition != null) + { + vec31 = Vec3.createVectorHelper(movingobjectposition.hitVec.xCoord, movingobjectposition.hitVec.yCoord, movingobjectposition.hitVec.zCoord); + } + + if (!worldObj.isRemote) + { + Entity entity = null; + List list = worldObj.getEntitiesWithinAABBExcludingEntity(this, boundingBox.addCoord(motionX, motionY, motionZ).expand(1.0D, 1.0D, 1.0D)); + double d0 = 0.0D; + EntityLivingBase entitylivingbase = getThrower(); + + for (int j = 0; j < list.size(); ++j) + { + Entity entity1 = (Entity)list.get(j); + + if (entity1.canBeCollidedWith() && (entity1 != entitylivingbase || ticksInAir >= 5)) + { + float f = 0.3F; + AxisAlignedBB axisalignedbb = entity1.boundingBox.expand(f, f, f); + MovingObjectPosition movingobjectposition1 = axisalignedbb.calculateIntercept(vec3, vec31); + + if (movingobjectposition1 != null) + { + double d1 = vec3.distanceTo(movingobjectposition1.hitVec); + + if (d1 < d0 || d0 == 0.0D) + { + entity = entity1; + d0 = d1; + } + } + } + } + + if (entity != null) + { + movingobjectposition = new MovingObjectPosition(entity); + } + } + + if (movingobjectposition != null) + { + if (movingobjectposition.typeOfHit == MovingObjectPosition.MovingObjectType.BLOCK && worldObj.getBlock(movingobjectposition.blockX, movingobjectposition.blockY, movingobjectposition.blockZ) == Blocks.portal) + { + setInPortal(); + } + else + { + onImpact(movingobjectposition); + } + } + + posX += motionX; + posY += motionY; + posZ += motionZ; + float f1 = MathHelper.sqrt_double(motionX * motionX + motionZ * motionZ); + rotationYaw = (float)(Math.atan2(motionX, motionZ) * 180.0D / Math.PI); + + for (rotationPitch = (float)(Math.atan2(motionY, f1) * 180.0D / Math.PI); rotationPitch - prevRotationPitch < -180.0F; prevRotationPitch -= 360.0F) + { + ; + } + + while (rotationPitch - prevRotationPitch >= 180.0F) + { + prevRotationPitch += 360.0F; + } + + while (rotationYaw - prevRotationYaw < -180.0F) + { + prevRotationYaw -= 360.0F; + } + + while (rotationYaw - prevRotationYaw >= 180.0F) + { + prevRotationYaw += 360.0F; + } + + rotationPitch = prevRotationPitch + (rotationPitch - prevRotationPitch) * 0.2F; + rotationYaw = prevRotationYaw + (rotationYaw - prevRotationYaw) * 0.2F; + float f2 = 0.99F; + float f3 = getGravityVelocity(); + + if (isInWater()) + { + for (int i = 0; i < 4; ++i) + { + float f4 = 0.25F; + worldObj.spawnParticle("bubble", posX - motionX * f4, posY - motionY * f4, posZ - motionZ * f4, motionX, motionY, motionZ); + } + + f2 = 0.8F; + } + + motionX *= f2; + motionY *= f2; + motionZ *= f2; + motionY -= f3; + setPosition(posX, posY, posZ); + } + + /** + * Gets the amount of gravity to apply to the thrown entity with each tick. + */ + protected float getGravityVelocity() + { + return 0.03F; + } + + /** + * Called when this EntityThrowable hits a block or entity. + */ + protected abstract void onImpact(MovingObjectPosition p_70184_1_); + + /** + * (abstract) Protected helper method to write subclass entity data to NBT. + */ + @Override + public void writeEntityToNBT(NBTTagCompound p_70014_1_) + { + p_70014_1_.setShort("xTile", (short)field_145788_c); + p_70014_1_.setShort("yTile", (short)field_145786_d); + p_70014_1_.setShort("zTile", (short)field_145787_e); + p_70014_1_.setByte("inTile", (byte)Block.getIdFromBlock(field_145785_f)); + p_70014_1_.setByte("shake", (byte)throwableShake); + p_70014_1_.setByte("inGround", (byte)(inGround ? 1 : 0)); + + if ((throwerName == null || throwerName.length() == 0) && thrower != null && thrower instanceof EntityPlayer) + { + throwerName = thrower.getCommandSenderName(); + } + + p_70014_1_.setString("ownerName", throwerName == null ? "" : throwerName); + } + + /** + * (abstract) Protected helper method to read subclass entity data from NBT. + */ + @Override + public void readEntityFromNBT(NBTTagCompound p_70037_1_) + { + field_145788_c = p_70037_1_.getShort("xTile"); + field_145786_d = p_70037_1_.getShort("yTile"); + field_145787_e = p_70037_1_.getShort("zTile"); + field_145785_f = Block.getBlockById(p_70037_1_.getByte("inTile") & 255); + throwableShake = p_70037_1_.getByte("shake") & 255; + inGround = p_70037_1_.getByte("inGround") == 1; + throwerName = p_70037_1_.getString("ownerName"); + + if (throwerName != null && throwerName.length() == 0) + { + throwerName = null; + } + } + + @Override + @SideOnly(Side.CLIENT) + public float getShadowSize() + { + return 0.0F; + } + + public EntityLivingBase getThrower() + { + if (thrower == null && throwerName != null && throwerName.length() > 0) + { + thrower = worldObj.getPlayerEntityByName(throwerName); + } + + return thrower; + } +} \ No newline at end of file diff --git a/src/main/java/vazkii/botania/common/entity/EntityThrownItem.java b/src/main/java/vazkii/botania/common/entity/EntityThrownItem.java index 44df684c31..dff1c91c69 100644 --- a/src/main/java/vazkii/botania/common/entity/EntityThrownItem.java +++ b/src/main/java/vazkii/botania/common/entity/EntityThrownItem.java @@ -2,15 +2,16 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [? (GMT)] */ package vazkii.botania.common.entity; import java.util.List; + import net.minecraft.entity.Entity; import net.minecraft.entity.item.EntityItem; import net.minecraft.entity.player.EntityPlayer; @@ -24,112 +25,121 @@ public class EntityThrownItem extends EntityItem { - public EntityThrownItem(World par1World) { - super(par1World); - } - - public EntityThrownItem( - World p_i1710_1_, double p_i1710_2_, double p_i1710_4_, double p_i1710_6_, EntityItem item) { - super(p_i1710_1_, p_i1710_2_, p_i1710_4_, p_i1710_6_, item.getEntityItem()); - - delayBeforeCanPickup = item.delayBeforeCanPickup; - motionX = item.motionX; - motionY = item.motionY; - motionZ = item.motionZ; - } - - @Override - public boolean isEntityInvulnerable() { - return true; - } - - @Override - public void onUpdate() { - super.onUpdate(); - Vec3 vec3 = Vec3.createVectorHelper(posX, posY, posZ); - Vec3 vec31 = Vec3.createVectorHelper(posX + motionX, posY + motionY, posZ + motionZ); - - MovingObjectPosition movingobjectposition = worldObj.rayTraceBlocks(vec3, vec31); - - if (!worldObj.isRemote) { - Entity entity = null; - List list = worldObj.getEntitiesWithinAABBExcludingEntity( - this, - boundingBox.addCoord(motionX * 2, motionY * 2, motionZ * 2).expand(2.0D, 2.0D, 2.0D)); - double d0 = 0.0D; - - for (int j = 0; j < list.size(); ++j) { - Entity entity1 = (Entity) list.get(j); - - if (entity1.canBeCollidedWith() && (!(entity1 instanceof EntityPlayer) || delayBeforeCanPickup == 0)) { - float f = 1.0F; - AxisAlignedBB axisalignedbb = entity1.boundingBox.expand(f, f, f); - MovingObjectPosition movingobjectposition1 = axisalignedbb.calculateIntercept(vec3, vec31); - - if (movingobjectposition1 != null) { - double d1 = vec3.distanceTo(movingobjectposition1.hitVec); - - if (d1 < d0 || d0 == 0.0D) { - entity = entity1; - d0 = d1; - } - } - } - } - - if (entity != null) { - movingobjectposition = new MovingObjectPosition(entity); - } - } - - if (movingobjectposition != null) { - if (movingobjectposition.typeOfHit == MovingObjectPosition.MovingObjectType.BLOCK - && worldObj.getBlock( - movingobjectposition.blockX, - movingobjectposition.blockY, - movingobjectposition.blockZ) - == Blocks.portal) { - setInPortal(); - } else { - if (movingobjectposition.entityHit != null) { - movingobjectposition.entityHit.attackEntityFrom(DamageSource.magic, 2.0F); - if (!worldObj.isRemote) { - Entity item = getEntityItem().getItem().createEntity(worldObj, this, getEntityItem()); - if (item == null) { - item = new EntityItem(worldObj, posX, posY, posZ, getEntityItem()); - worldObj.spawnEntityInWorld(item); - item.motionX = motionX * 0.25F; - item.motionY = motionY * 0.25F; - item.motionZ = motionZ * 0.25F; - - } else { - item.motionX = motionX * 0.25F; - item.motionY = motionY * 0.25F; - item.motionZ = motionZ * 0.25F; - } - } - setDead(); - } - } - } - - Vector3 vec3m = new Vector3(motionX, motionY, motionZ); - if (vec3m.mag() < 1.0F) { - if (!worldObj.isRemote) { - Entity item = getEntityItem().getItem().createEntity(worldObj, this, getEntityItem()); - if (item == null) { - item = new EntityItem(worldObj, posX, posY, posZ, getEntityItem()); - worldObj.spawnEntityInWorld(item); - item.motionX = motionX; - item.motionY = motionY; - item.motionZ = motionZ; - } else { - item.motionX = motionX; - item.motionY = motionY; - item.motionZ = motionZ; - } - } - setDead(); - } - } + public EntityThrownItem(World par1World) { + super(par1World); + } + + public EntityThrownItem(World p_i1710_1_, double p_i1710_2_, + double p_i1710_4_, double p_i1710_6_, EntityItem item) { + super(p_i1710_1_, p_i1710_2_, p_i1710_4_, p_i1710_6_, item.getEntityItem()); + + delayBeforeCanPickup = item.delayBeforeCanPickup; + motionX = item.motionX; + motionY = item.motionY; + motionZ = item.motionZ; + } + + @Override + public boolean isEntityInvulnerable() { + return true; + } + + @Override + public void onUpdate() { + super.onUpdate(); + Vec3 vec3 = Vec3.createVectorHelper(posX, posY, posZ); + Vec3 vec31 = Vec3.createVectorHelper(posX + motionX, posY + motionY, posZ + motionZ); + + MovingObjectPosition movingobjectposition = worldObj.rayTraceBlocks(vec3, vec31); + + + if (!worldObj.isRemote) + { + Entity entity = null; + List list = worldObj.getEntitiesWithinAABBExcludingEntity(this, boundingBox.addCoord(motionX*2, motionY*2, motionZ*2).expand(2.0D, 2.0D, 2.0D)); + double d0 = 0.0D; + + for (int j = 0; j < list.size(); ++j) + { + Entity entity1 = (Entity)list.get(j); + + if (entity1.canBeCollidedWith() && (!(entity1 instanceof EntityPlayer) || delayBeforeCanPickup == 0)) + { + float f = 1.0F; + AxisAlignedBB axisalignedbb = entity1.boundingBox.expand(f, f, f); + MovingObjectPosition movingobjectposition1 = axisalignedbb.calculateIntercept(vec3, vec31); + + if (movingobjectposition1 != null) + { + double d1 = vec3.distanceTo(movingobjectposition1.hitVec); + + if (d1 < d0 || d0 == 0.0D) + { + entity = entity1; + d0 = d1; + } + } + } + } + + if (entity != null) + { + movingobjectposition = new MovingObjectPosition(entity); + } + } + + if (movingobjectposition != null) + { + if (movingobjectposition.typeOfHit == MovingObjectPosition.MovingObjectType.BLOCK && worldObj.getBlock(movingobjectposition.blockX, movingobjectposition.blockY, movingobjectposition.blockZ) == Blocks.portal) + { + setInPortal(); + } + else + { + if (movingobjectposition.entityHit != null) { + movingobjectposition.entityHit.attackEntityFrom(DamageSource.magic, 2.0F); + if (!worldObj.isRemote) { + Entity item = getEntityItem().getItem().createEntity(worldObj, this, getEntityItem()); + if (item == null) { + item = new EntityItem(worldObj, posX, posY, posZ, getEntityItem()); + worldObj.spawnEntityInWorld(item); + item.motionX = motionX*0.25F; + item.motionY = motionY*0.25F; + item.motionZ = motionZ*0.25F; + + } + else + { + item.motionX = motionX*0.25F; + item.motionY = motionY*0.25F; + item.motionZ = motionZ*0.25F; + } + } + setDead(); + + } + } + } + + Vector3 vec3m = new Vector3(motionX, motionY, motionZ); + if (vec3m.mag() < 1.0F) { + if (!worldObj.isRemote) { + Entity item = getEntityItem().getItem().createEntity(worldObj, this, getEntityItem()); + if (item == null) { + item = new EntityItem(worldObj, posX, posY, posZ, getEntityItem()); + worldObj.spawnEntityInWorld(item); + item.motionX = motionX; + item.motionY = motionY; + item.motionZ = motionZ; + } + else + { + item.motionX = motionX; + item.motionY = motionY; + item.motionZ = motionZ; + } + } + setDead(); + } + } } diff --git a/src/main/java/vazkii/botania/common/entity/EntityVineBall.java b/src/main/java/vazkii/botania/common/entity/EntityVineBall.java index 75a307aadc..cfeadd7231 100644 --- a/src/main/java/vazkii/botania/common/entity/EntityVineBall.java +++ b/src/main/java/vazkii/botania/common/entity/EntityVineBall.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jun 26, 2014, 7:32:16 PM (GMT)] */ package vazkii.botania.common.entity; @@ -20,50 +20,49 @@ public class EntityVineBall extends EntityThrowable { - public EntityVineBall(World par1World) { - super(par1World); - dataWatcher.addObject(30, 0F); - dataWatcher.setObjectWatched(30); - } + public EntityVineBall(World par1World) { + super(par1World); + dataWatcher.addObject(30, 0F); + dataWatcher.setObjectWatched(30); + } - public EntityVineBall(EntityPlayer player, boolean gravity) { - super(player.worldObj, player); - dataWatcher.addObject(30, gravity ? 0.03F : 0F); - dataWatcher.setObjectWatched(30); - } + public EntityVineBall(EntityPlayer player, boolean gravity) { + super(player.worldObj, player); + dataWatcher.addObject(30, gravity ? 0.03F : 0F); + dataWatcher.setObjectWatched(30); + } - @Override - protected void onImpact(MovingObjectPosition var1) { - if (var1 != null) { - int meta = var1.sideHit; - int[] metaPlace = new int[] {1, 4, 8, 2}; + @Override + protected void onImpact(MovingObjectPosition var1) { + if(var1 != null) { + int meta = var1.sideHit; + int[] metaPlace = new int[] { + 1, 4, 8, 2 + }; - if (meta > 1 && meta < 6) { - ForgeDirection dir = ForgeDirection.getOrientation(meta); - int x = var1.blockX + dir.offsetX; - int y = var1.blockY + dir.offsetY; - int z = var1.blockZ + dir.offsetZ; - while (y > 0) { - Block block = worldObj.getBlock(x, y, z); - if (block.isAir(worldObj, x, y, z)) { - worldObj.setBlock(x, y, z, ModBlocks.solidVines, metaPlace[meta - 2], 1 | 2); - worldObj.playAuxSFX( - 2001, - x, - y, - z, - Block.getIdFromBlock(ModBlocks.solidVines) + (metaPlace[meta - 2] << 12)); - y--; - } else break; - } - } - } + if(meta > 1 && meta < 6) { + ForgeDirection dir = ForgeDirection.getOrientation(meta); + int x = var1.blockX + dir.offsetX; + int y = var1.blockY + dir.offsetY; + int z = var1.blockZ + dir.offsetZ; + while(y > 0) { + Block block = worldObj.getBlock(x, y, z); + if(block.isAir(worldObj, x, y, z)) { + worldObj.setBlock(x, y, z, ModBlocks.solidVines, metaPlace[meta - 2], 1 | 2); + worldObj.playAuxSFX(2001, x, y, z, Block.getIdFromBlock(ModBlocks.solidVines) + (metaPlace[meta - 2] << 12)); + y--; + } else break; + } + } - setDead(); - } + } + + setDead(); + } + + @Override + protected float getGravityVelocity() { + return dataWatcher.getWatchableObjectFloat(30); + } - @Override - protected float getGravityVelocity() { - return dataWatcher.getWatchableObjectFloat(30); - } } diff --git a/src/main/java/vazkii/botania/common/entity/ModEntities.java b/src/main/java/vazkii/botania/common/entity/ModEntities.java index 43ecd498d3..ad4625bc8b 100644 --- a/src/main/java/vazkii/botania/common/entity/ModEntities.java +++ b/src/main/java/vazkii/botania/common/entity/ModEntities.java @@ -2,60 +2,43 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jan 26, 2014, 4:11:03 PM (GMT)] */ package vazkii.botania.common.entity; -import cpw.mods.fml.common.registry.EntityRegistry; import vazkii.botania.common.Botania; import vazkii.botania.common.block.tile.TileLightRelay.EntityPlayerMover; import vazkii.botania.common.lib.LibEntityNames; +import cpw.mods.fml.common.registry.EntityRegistry; public final class ModEntities { - public static void init() { - int id = 0; + public static void init() { + int id = 0; + + EntityRegistry.registerModEntity(EntityManaBurst.class, LibEntityNames.MANA_BURST, id++, Botania.instance, 64, 10, true); + EntityRegistry.registerModEntity(EntitySignalFlare.class, LibEntityNames.SIGNAL_FLARE, id++, Botania.instance, 2048, 10, false); + EntityRegistry.registerModEntity(EntityPixie.class, LibEntityNames.PIXIE, id++, Botania.instance, 16, 3, true); + EntityRegistry.registerModEntity(EntityFlameRing.class, LibEntityNames.FLAME_RING, id++, Botania.instance, 32, 40, false); + EntityRegistry.registerModEntity(EntityVineBall.class, LibEntityNames.VINE_BALL, id++, Botania.instance, 64, 10, true); + EntityRegistry.registerModEntity(EntityDoppleganger.class, LibEntityNames.DOPPLEGANGER, id++, Botania.instance, 128, 3, true); + EntityRegistry.registerModEntity(EntityMagicLandmine.class, LibEntityNames.MAGIC_LANDMINE, id++, Botania.instance, 128, 40, false); + EntityRegistry.registerModEntity(EntitySpark.class, LibEntityNames.SPARK, id++, Botania.instance, 64, 10, false); + EntityRegistry.registerModEntity(EntityThrownItem.class, LibEntityNames.THROWN_ITEM, id++, Botania.instance, 64, 20, true); + EntityRegistry.registerModEntity(EntityMagicMissile.class, LibEntityNames.MAGIC_MISSILE, id++, Botania.instance, 64, 2, true); + EntityRegistry.registerModEntity(EntityThornChakram.class, LibEntityNames.THORN_CHAKRAM, id++, Botania.instance, 64, 10, true); + EntityRegistry.registerModEntity(EntityCorporeaSpark.class, LibEntityNames.CORPOREA_SPARK, id++, Botania.instance, 64, 10, false); + EntityRegistry.registerModEntity(EntityEnderAirBottle.class, LibEntityNames.ENDER_AIR_BOTTLE, id++, Botania.instance, 64, 10, true); + EntityRegistry.registerModEntity(EntityPoolMinecart.class, LibEntityNames.POOL_MINECART, id++, Botania.instance, 80, 3, true); + EntityRegistry.registerModEntity(EntityPinkWither.class, LibEntityNames.PINK_WITHER, id++, Botania.instance, 80, 3, false); + EntityRegistry.registerModEntity(EntityPlayerMover.class, LibEntityNames.PLAYER_MOVER, id++, Botania.instance, 40, 3, true); + EntityRegistry.registerModEntity(EntityManaStorm.class, LibEntityNames.MANA_STORM, id++, Botania.instance, 64, 10, false); + EntityRegistry.registerModEntity(EntityBabylonWeapon.class, LibEntityNames.BABYLON_WEAPON, id++, Botania.instance, 64, 10, true); + EntityRegistry.registerModEntity(EntityFallingStar.class, LibEntityNames.FALLING_STAR, id++, Botania.instance, 64, 10, true); + } - EntityRegistry.registerModEntity( - EntityManaBurst.class, LibEntityNames.MANA_BURST, id++, Botania.instance, 64, 10, true); - EntityRegistry.registerModEntity( - EntitySignalFlare.class, LibEntityNames.SIGNAL_FLARE, id++, Botania.instance, 2048, 10, false); - EntityRegistry.registerModEntity(EntityPixie.class, LibEntityNames.PIXIE, id++, Botania.instance, 16, 3, true); - EntityRegistry.registerModEntity( - EntityFlameRing.class, LibEntityNames.FLAME_RING, id++, Botania.instance, 32, 40, false); - EntityRegistry.registerModEntity( - EntityVineBall.class, LibEntityNames.VINE_BALL, id++, Botania.instance, 64, 10, true); - EntityRegistry.registerModEntity( - EntityDoppleganger.class, LibEntityNames.DOPPLEGANGER, id++, Botania.instance, 128, 3, true); - EntityRegistry.registerModEntity( - EntityMagicLandmine.class, LibEntityNames.MAGIC_LANDMINE, id++, Botania.instance, 128, 40, false); - EntityRegistry.registerModEntity( - EntitySpark.class, LibEntityNames.SPARK, id++, Botania.instance, 64, 10, false); - EntityRegistry.registerModEntity( - EntityThrownItem.class, LibEntityNames.THROWN_ITEM, id++, Botania.instance, 64, 20, true); - EntityRegistry.registerModEntity( - EntityMagicMissile.class, LibEntityNames.MAGIC_MISSILE, id++, Botania.instance, 64, 2, true); - EntityRegistry.registerModEntity( - EntityThornChakram.class, LibEntityNames.THORN_CHAKRAM, id++, Botania.instance, 64, 10, true); - EntityRegistry.registerModEntity( - EntityCorporeaSpark.class, LibEntityNames.CORPOREA_SPARK, id++, Botania.instance, 64, 10, false); - EntityRegistry.registerModEntity( - EntityEnderAirBottle.class, LibEntityNames.ENDER_AIR_BOTTLE, id++, Botania.instance, 64, 10, true); - EntityRegistry.registerModEntity( - EntityPoolMinecart.class, LibEntityNames.POOL_MINECART, id++, Botania.instance, 80, 3, true); - EntityRegistry.registerModEntity( - EntityPinkWither.class, LibEntityNames.PINK_WITHER, id++, Botania.instance, 80, 3, false); - EntityRegistry.registerModEntity( - EntityPlayerMover.class, LibEntityNames.PLAYER_MOVER, id++, Botania.instance, 40, 3, true); - EntityRegistry.registerModEntity( - EntityManaStorm.class, LibEntityNames.MANA_STORM, id++, Botania.instance, 64, 10, false); - EntityRegistry.registerModEntity( - EntityBabylonWeapon.class, LibEntityNames.BABYLON_WEAPON, id++, Botania.instance, 64, 10, true); - EntityRegistry.registerModEntity( - EntityFallingStar.class, LibEntityNames.FALLING_STAR, id++, Botania.instance, 64, 10, true); - } } diff --git a/src/main/java/vazkii/botania/common/integration/buildcraft/StatementAPIPlugin.java b/src/main/java/vazkii/botania/common/integration/buildcraft/StatementAPIPlugin.java index 5c0c69871e..49b424d97a 100644 --- a/src/main/java/vazkii/botania/common/integration/buildcraft/StatementAPIPlugin.java +++ b/src/main/java/vazkii/botania/common/integration/buildcraft/StatementAPIPlugin.java @@ -1,62 +1,63 @@ package vazkii.botania.common.integration.buildcraft; -import buildcraft.api.statements.IStatementContainer; -import buildcraft.api.statements.ITriggerExternal; -import buildcraft.api.statements.ITriggerInternal; -import buildcraft.api.statements.ITriggerProvider; -import buildcraft.api.statements.StatementManager; import java.util.ArrayList; import java.util.Collection; + import net.minecraft.tileentity.TileEntity; import net.minecraftforge.common.util.ForgeDirection; import vazkii.botania.api.mana.IManaBlock; import vazkii.botania.api.mana.IManaReceiver; import vazkii.botania.common.block.tile.TileRuneAltar; +import buildcraft.api.statements.IStatementContainer; +import buildcraft.api.statements.ITriggerExternal; +import buildcraft.api.statements.ITriggerInternal; +import buildcraft.api.statements.ITriggerProvider; +import buildcraft.api.statements.StatementManager; public class StatementAPIPlugin implements ITriggerProvider { - public static final ITriggerExternal triggerManaEmpty = new TriggerManaLevel(TriggerManaLevel.State.EMPTY); - public static final ITriggerExternal triggerManaContains = new TriggerManaLevel(TriggerManaLevel.State.CONTAINS); - public static final ITriggerExternal triggerManaSpace = new TriggerManaLevel(TriggerManaLevel.State.SPACE); - public static final ITriggerExternal triggerManaFull = new TriggerManaLevel(TriggerManaLevel.State.FULL); - public static final ITriggerInternal triggerManaDetector = new TriggerManaDetector(); - - public static final ITriggerExternal triggerRuneAltarCanCraft = new TriggerRuneAltarCanCraft(); - - public StatementAPIPlugin() { - StatementManager.registerStatement(triggerManaEmpty); - StatementManager.registerStatement(triggerManaContains); - StatementManager.registerStatement(triggerManaSpace); - StatementManager.registerStatement(triggerManaFull); - StatementManager.registerStatement(triggerManaDetector); - - StatementManager.registerStatement(triggerRuneAltarCanCraft); - - StatementManager.registerTriggerProvider(this); - } - - @Override - public Collection getInternalTriggers(IStatementContainer container) { - ArrayList list = new ArrayList(); - list.add(triggerManaDetector); - return list; - } - - @Override - public Collection getExternalTriggers(ForgeDirection side, TileEntity tile) { - ArrayList list = new ArrayList(); - - if (tile instanceof IManaBlock) { - list.add(triggerManaEmpty); - list.add(triggerManaContains); - if (tile instanceof IManaReceiver) { - list.add(triggerManaSpace); - list.add(triggerManaFull); - } - } - - if (tile instanceof TileRuneAltar) list.add(triggerRuneAltarCanCraft); - - return list; - } + public static final ITriggerExternal triggerManaEmpty = new TriggerManaLevel(TriggerManaLevel.State.EMPTY); + public static final ITriggerExternal triggerManaContains = new TriggerManaLevel(TriggerManaLevel.State.CONTAINS); + public static final ITriggerExternal triggerManaSpace = new TriggerManaLevel(TriggerManaLevel.State.SPACE); + public static final ITriggerExternal triggerManaFull = new TriggerManaLevel(TriggerManaLevel.State.FULL); + public static final ITriggerInternal triggerManaDetector = new TriggerManaDetector(); + + public static final ITriggerExternal triggerRuneAltarCanCraft = new TriggerRuneAltarCanCraft(); + + public StatementAPIPlugin() { + StatementManager.registerStatement(triggerManaEmpty); + StatementManager.registerStatement(triggerManaContains); + StatementManager.registerStatement(triggerManaSpace); + StatementManager.registerStatement(triggerManaFull); + StatementManager.registerStatement(triggerManaDetector); + + StatementManager.registerStatement(triggerRuneAltarCanCraft); + + StatementManager.registerTriggerProvider(this); + } + + @Override + public Collection getInternalTriggers(IStatementContainer container) { + ArrayList list = new ArrayList(); + list.add(triggerManaDetector); + return list; + } + + @Override + public Collection getExternalTriggers(ForgeDirection side, TileEntity tile) { + ArrayList list = new ArrayList(); + + if (tile instanceof IManaBlock) { + list.add(triggerManaEmpty); + list.add(triggerManaContains); + if (tile instanceof IManaReceiver) { + list.add(triggerManaSpace); + list.add(triggerManaFull); + } + } + + if (tile instanceof TileRuneAltar) list.add(triggerRuneAltarCanCraft); + + return list; + } } diff --git a/src/main/java/vazkii/botania/common/integration/buildcraft/StatementBase.java b/src/main/java/vazkii/botania/common/integration/buildcraft/StatementBase.java index e6a463ee01..cbf7993572 100644 --- a/src/main/java/vazkii/botania/common/integration/buildcraft/StatementBase.java +++ b/src/main/java/vazkii/botania/common/integration/buildcraft/StatementBase.java @@ -1,34 +1,34 @@ package vazkii.botania.common.integration.buildcraft; +import net.minecraft.util.IIcon; import buildcraft.api.statements.IStatement; import buildcraft.api.statements.IStatementParameter; -import net.minecraft.util.IIcon; public abstract class StatementBase implements IStatement { - protected IIcon icon; + protected IIcon icon; - @Override - public IIcon getIcon() { - return icon; - } + @Override + public IIcon getIcon() { + return icon; + } - @Override - public int maxParameters() { - return 0; - } + @Override + public int maxParameters() { + return 0; + } - @Override - public int minParameters() { - return 0; - } + @Override + public int minParameters() { + return 0; + } - @Override - public IStatementParameter createParameter(int index) { - return null; - } + @Override + public IStatementParameter createParameter(int index) { + return null; + } - @Override - public IStatement rotateLeft() { - return this; - } + @Override + public IStatement rotateLeft() { + return this; + } } diff --git a/src/main/java/vazkii/botania/common/integration/buildcraft/TriggerManaDetector.java b/src/main/java/vazkii/botania/common/integration/buildcraft/TriggerManaDetector.java index 138c7eaf4b..4210c9da8e 100644 --- a/src/main/java/vazkii/botania/common/integration/buildcraft/TriggerManaDetector.java +++ b/src/main/java/vazkii/botania/common/integration/buildcraft/TriggerManaDetector.java @@ -1,8 +1,5 @@ package vazkii.botania.common.integration.buildcraft; -import buildcraft.api.statements.IStatementContainer; -import buildcraft.api.statements.IStatementParameter; -import buildcraft.api.statements.ITriggerInternal; import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.util.AxisAlignedBB; import net.minecraft.util.StatCollector; @@ -11,47 +8,38 @@ import vazkii.botania.client.core.helper.IconHelper; import vazkii.botania.common.Botania; import vazkii.botania.common.lib.LibTriggerNames; +import buildcraft.api.statements.IStatementContainer; +import buildcraft.api.statements.IStatementParameter; +import buildcraft.api.statements.ITriggerInternal; public class TriggerManaDetector extends StatementBase implements ITriggerInternal { - @Override - public String getUniqueTag() { - return "botania:manaDetector"; - } - - @Override - public void registerIcons(IIconRegister iconRegister) { - icon = IconHelper.forName(iconRegister, "triggers/manaDetector"); - } - - @Override - public String getDescription() { - return StatCollector.translateToLocal(LibTriggerNames.TRIGGER_MANA_DETECTOR); - } - - @Override - public boolean isTriggerActive(IStatementContainer source, IStatementParameter[] parameters) { - World world = source.getTile().getWorldObj(); - int x = source.getTile().xCoord, y = source.getTile().yCoord, z = source.getTile().zCoord; - - boolean output = world.getEntitiesWithinAABB( - IManaBurst.class, AxisAlignedBB.getBoundingBox(x, y, z, x + 1, y + 1, z + 1)) - .size() - != 0; - - if (output) - for (int i = 0; i < 4; i++) - Botania.proxy.sparkleFX( - world, - x + Math.random(), - y + Math.random(), - z + Math.random(), - 1F, - 0.2F, - 0.2F, - 0.7F + 0.5F * (float) Math.random(), - 5); - - return output; - } + @Override + public String getUniqueTag() { + return "botania:manaDetector"; + } + + @Override + public void registerIcons(IIconRegister iconRegister) { + icon = IconHelper.forName(iconRegister, "triggers/manaDetector"); + } + + @Override + public String getDescription() { + return StatCollector.translateToLocal(LibTriggerNames.TRIGGER_MANA_DETECTOR); + } + + @Override + public boolean isTriggerActive(IStatementContainer source, IStatementParameter[] parameters) { + World world = source.getTile().getWorldObj(); + int x = source.getTile().xCoord, y = source.getTile().yCoord, z = source.getTile().zCoord; + + boolean output = world.getEntitiesWithinAABB(IManaBurst.class, AxisAlignedBB.getBoundingBox(x, y, z, x + 1, y + 1, z + 1)).size() != 0; + + if(output) for(int i = 0; i < 4; i++) + Botania.proxy.sparkleFX(world, x + Math.random(), y + Math.random(), z + Math.random(), 1F, 0.2F, 0.2F, 0.7F + 0.5F * (float) Math.random(), 5); + + return output; + } + } diff --git a/src/main/java/vazkii/botania/common/integration/buildcraft/TriggerManaLevel.java b/src/main/java/vazkii/botania/common/integration/buildcraft/TriggerManaLevel.java index 2e14aa26a1..f655d56aff 100644 --- a/src/main/java/vazkii/botania/common/integration/buildcraft/TriggerManaLevel.java +++ b/src/main/java/vazkii/botania/common/integration/buildcraft/TriggerManaLevel.java @@ -1,60 +1,60 @@ package vazkii.botania.common.integration.buildcraft; -import buildcraft.api.statements.IStatementContainer; -import buildcraft.api.statements.IStatementParameter; -import buildcraft.api.statements.ITriggerExternal; import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.StatCollector; import net.minecraftforge.common.util.ForgeDirection; + import org.apache.commons.lang3.text.WordUtils; + import vazkii.botania.api.mana.IManaBlock; import vazkii.botania.api.mana.IManaReceiver; import vazkii.botania.client.core.helper.IconHelper; import vazkii.botania.common.lib.LibTriggerNames; +import buildcraft.api.statements.IStatementContainer; +import buildcraft.api.statements.IStatementParameter; +import buildcraft.api.statements.ITriggerExternal; public class TriggerManaLevel extends StatementBase implements ITriggerExternal { - public enum State { - EMPTY, - CONTAINS, - SPACE, - FULL - }; - - private State state; - - public TriggerManaLevel(State state) { - this.state = state; - } - - @Override - public String getUniqueTag() { - return "botania:mana" + state.name(); - } - - @Override - public void registerIcons(IIconRegister iconRegister) { - icon = IconHelper.forName(iconRegister, "triggers/mana" + WordUtils.capitalizeFully(state.name())); - } - - @Override - public String getDescription() { - return StatCollector.translateToLocal( - LibTriggerNames.TRIGGER_MANA_PREFIX + WordUtils.capitalizeFully(state.name())); - } - - @Override - public boolean isTriggerActive( - TileEntity target, ForgeDirection side, IStatementContainer source, IStatementParameter[] parameters) { - if (target instanceof IManaBlock) { - if (state == State.EMPTY) return ((IManaBlock) target).getCurrentMana() == 0; - else if (state == State.CONTAINS) return ((IManaBlock) target).getCurrentMana() > 0; - else if (target instanceof IManaReceiver) { - if (state == State.SPACE) return !((IManaReceiver) target).isFull(); - else if (state == State.FULL) return ((IManaReceiver) target).isFull(); - } - } - - return false; - } + public enum State { + EMPTY, + CONTAINS, + SPACE, + FULL + }; + + private State state; + + public TriggerManaLevel(State state) { + this.state = state; + } + + @Override + public String getUniqueTag() { + return "botania:mana" + state.name(); + } + + @Override + public void registerIcons(IIconRegister iconRegister) { + icon = IconHelper.forName(iconRegister, "triggers/mana" + WordUtils.capitalizeFully(state.name())); + } + + @Override + public String getDescription() { + return StatCollector.translateToLocal(LibTriggerNames.TRIGGER_MANA_PREFIX + WordUtils.capitalizeFully(state.name())); + } + + @Override + public boolean isTriggerActive(TileEntity target, ForgeDirection side, IStatementContainer source, IStatementParameter[] parameters) { + if(target instanceof IManaBlock) { + if(state == State.EMPTY) return ((IManaBlock) target).getCurrentMana() == 0; + else if(state == State.CONTAINS) return ((IManaBlock) target).getCurrentMana() > 0; + else if(target instanceof IManaReceiver) { + if(state == State.SPACE) return !((IManaReceiver) target).isFull(); + else if(state == State.FULL) return ((IManaReceiver) target).isFull(); + } + } + + return false; + } } diff --git a/src/main/java/vazkii/botania/common/integration/buildcraft/TriggerRuneAltarCanCraft.java b/src/main/java/vazkii/botania/common/integration/buildcraft/TriggerRuneAltarCanCraft.java index fe2ddfb20a..cbad8aa769 100644 --- a/src/main/java/vazkii/botania/common/integration/buildcraft/TriggerRuneAltarCanCraft.java +++ b/src/main/java/vazkii/botania/common/integration/buildcraft/TriggerRuneAltarCanCraft.java @@ -1,8 +1,5 @@ package vazkii.botania.common.integration.buildcraft; -import buildcraft.api.statements.IStatementContainer; -import buildcraft.api.statements.IStatementParameter; -import buildcraft.api.statements.ITriggerExternal; import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.StatCollector; @@ -10,28 +7,31 @@ import vazkii.botania.client.core.helper.IconHelper; import vazkii.botania.common.block.tile.TileRuneAltar; import vazkii.botania.common.lib.LibTriggerNames; +import buildcraft.api.statements.IStatementContainer; +import buildcraft.api.statements.IStatementParameter; +import buildcraft.api.statements.ITriggerExternal; public class TriggerRuneAltarCanCraft extends StatementBase implements ITriggerExternal { - @Override - public String getUniqueTag() { - return "botania:runeAltarCanCraft"; - } + @Override + public String getUniqueTag() { + return "botania:runeAltarCanCraft"; + } + + @Override + public void registerIcons(IIconRegister iconRegister) { + icon = IconHelper.forName(iconRegister, "triggers/runeAltarCanCraft"); + } - @Override - public void registerIcons(IIconRegister iconRegister) { - icon = IconHelper.forName(iconRegister, "triggers/runeAltarCanCraft"); - } + @Override + public String getDescription() { + return StatCollector.translateToLocal(LibTriggerNames.TRIGGER_RUNE_ALTAR_CAN_CRAFT); + } - @Override - public String getDescription() { - return StatCollector.translateToLocal(LibTriggerNames.TRIGGER_RUNE_ALTAR_CAN_CRAFT); - } + @Override + public boolean isTriggerActive(TileEntity target, ForgeDirection side, IStatementContainer source, IStatementParameter[] parameters) { + if(target instanceof TileRuneAltar) return ((TileRuneAltar) target).hasValidRecipe(); + return false; + } - @Override - public boolean isTriggerActive( - TileEntity target, ForgeDirection side, IStatementContainer source, IStatementParameter[] parameters) { - if (target instanceof TileRuneAltar) return ((TileRuneAltar) target).hasValidRecipe(); - return false; - } } diff --git a/src/main/java/vazkii/botania/common/integration/coloredlights/ColoredLightHelper.java b/src/main/java/vazkii/botania/common/integration/coloredlights/ColoredLightHelper.java index d17457dc6d..46786e3694 100644 --- a/src/main/java/vazkii/botania/common/integration/coloredlights/ColoredLightHelper.java +++ b/src/main/java/vazkii/botania/common/integration/coloredlights/ColoredLightHelper.java @@ -2,58 +2,67 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Dec 26, 2014, 7:26:31 PM (GMT)] */ package vazkii.botania.common.integration.coloredlights; + /* * This class is presentto help with the Colored Lights mod without needing to package * the API or hold a dependency, please understand. */ public class ColoredLightHelper { - // Begin API Copypasta - // https://github.com/CptSpaceToaster/CptsModdingLight/blob/1.7.2/src/main/java/coloredlightscore/src/api/CLApi.java + // Begin API Copypasta + // https://github.com/CptSpaceToaster/CptsModdingLight/blob/1.7.2/src/main/java/coloredlightscore/src/api/CLApi.java + + public static int r[] = new int[] { 0, 15, 0, 8, 0, 10, 0, 10, 5, 15, 8, 15, 0, 15, 15, 15 }; + public static int g[] = new int[] { 0, 0, 15, 3, 0, 0, 15, 10, 5, 10, 15, 15, 8, 0, 12, 15 }; + public static int b[] = new int[] { 0, 0, 0, 0, 15, 15, 15, 10, 5, 13, 0, 0, 15, 15, 10, 15 }; - public static int r[] = new int[] {0, 15, 0, 8, 0, 10, 0, 10, 5, 15, 8, 15, 0, 15, 15, 15}; - public static int g[] = new int[] {0, 0, 15, 3, 0, 0, 15, 10, 5, 10, 15, 15, 8, 0, 12, 15}; - public static int b[] = new int[] {0, 0, 0, 0, 15, 15, 15, 10, 5, 13, 0, 0, 15, 15, 10, 15}; + public static int makeRGBLightValue(float r, float g, float b, float currentLightValue) { + // Clamp color channels + if (r < 0.0f) + r = 0.0f; + else if (r > 1.0f) + r = 1.0f; - public static int makeRGBLightValue(float r, float g, float b, float currentLightValue) { - // Clamp color channels - if (r < 0.0f) r = 0.0f; - else if (r > 1.0f) r = 1.0f; + if (g < 0.0f) + g = 0.0f; + else if (g > 1.0f) + g = 1.0f; - if (g < 0.0f) g = 0.0f; - else if (g > 1.0f) g = 1.0f; + if (b < 0.0f) + b = 0.0f; + else if (b > 1.0f) + b = 1.0f; - if (b < 0.0f) b = 0.0f; - else if (b > 1.0f) b = 1.0f; + int brightness = (int) (currentLightValue * 15.0f); + brightness &= 0xf; - int brightness = (int) (currentLightValue * 15.0f); - brightness &= 0xf; + return brightness | ((int) (15.0F * b) << 15) + ((int) (15.0F * g) << 10) + ((int) (15.0F * r) << 5); + } - return brightness | ((int) (15.0F * b) << 15) + ((int) (15.0F * g) << 10) + ((int) (15.0F * r) << 5); - } + // End API Copypasta - // End API Copypasta + private static int packedColors[][] = null; - private static int packedColors[][] = null; + public static int getPackedColor(int meta, int light) { + if(packedColors == null) + initPackedColors(); - public static int getPackedColor(int meta, int light) { - if (packedColors == null) initPackedColors(); + return packedColors[meta][light]; + } - return packedColors[meta][light]; - } + private static void initPackedColors() { + packedColors = new int[16][16]; + for(int i = 0; i < 16; i++) + for(int j = 0; j < 16; j++) + packedColors[i][j] = makeRGBLightValue(r[15 - i], g[15 - i], b[15 - i], j / 16F); + } - private static void initPackedColors() { - packedColors = new int[16][16]; - for (int i = 0; i < 16; i++) - for (int j = 0; j < 16; j++) - packedColors[i][j] = makeRGBLightValue(r[15 - i], g[15 - i], b[15 - i], j / 16F); - } } diff --git a/src/main/java/vazkii/botania/common/integration/coloredlights/ILightHelper.java b/src/main/java/vazkii/botania/common/integration/coloredlights/ILightHelper.java index adc9f14521..e813b51324 100644 --- a/src/main/java/vazkii/botania/common/integration/coloredlights/ILightHelper.java +++ b/src/main/java/vazkii/botania/common/integration/coloredlights/ILightHelper.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [May 16, 2015, 8:30:41 PM (GMT)] */ package vazkii.botania.common.integration.coloredlights; @@ -16,7 +16,6 @@ */ public interface ILightHelper { - public int makeRGBLightValue(float r, float g, float b, int currentLightValue); - - public int getPackedColor(int meta, int light); + public int makeRGBLightValue(float r, float g, float b, int currentLightValue); + public int getPackedColor(int meta, int light); } diff --git a/src/main/java/vazkii/botania/common/integration/coloredlights/LightHelper.java b/src/main/java/vazkii/botania/common/integration/coloredlights/LightHelper.java index 1adaf91f7e..a2788419ee 100644 --- a/src/main/java/vazkii/botania/common/integration/coloredlights/LightHelper.java +++ b/src/main/java/vazkii/botania/common/integration/coloredlights/LightHelper.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [May 16, 2015, 8:30:41 PM (GMT)] */ package vazkii.botania.common.integration.coloredlights; @@ -17,11 +17,11 @@ */ public class LightHelper { - public static int makeRGBLightValue(float r, float g, float b, float currentLightValue) { - return Botania.lightHelper.makeRGBLightValue(r, g, b, (int) currentLightValue); - } + public static int makeRGBLightValue(float r, float g, float b, float currentLightValue) { + return Botania.lightHelper.makeRGBLightValue(r, g, b, (int) currentLightValue); + } - public static int getPackedColor(int meta, int light) { - return Botania.lightHelper.getPackedColor(meta, light); - } + public static int getPackedColor(int meta, int light) { + return Botania.lightHelper.getPackedColor(meta, light); + } } diff --git a/src/main/java/vazkii/botania/common/integration/coloredlights/LightHelperColored.java b/src/main/java/vazkii/botania/common/integration/coloredlights/LightHelperColored.java index 81731056ac..9b9f4580c7 100644 --- a/src/main/java/vazkii/botania/common/integration/coloredlights/LightHelperColored.java +++ b/src/main/java/vazkii/botania/common/integration/coloredlights/LightHelperColored.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [May 16, 2015, 8:30:41 PM (GMT)] */ package vazkii.botania.common.integration.coloredlights; @@ -15,13 +15,14 @@ */ public class LightHelperColored implements ILightHelper { - @Override - public int makeRGBLightValue(float r, float g, float b, int currentLightValue) { - return ColoredLightHelper.makeRGBLightValue(r, g, b, currentLightValue); - } + @Override + public int makeRGBLightValue(float r, float g, float b, int currentLightValue) { + return ColoredLightHelper.makeRGBLightValue(r, g, b, currentLightValue); + } + + @Override + public int getPackedColor(int meta, int light) { + return ColoredLightHelper.getPackedColor(meta, light); + } - @Override - public int getPackedColor(int meta, int light) { - return ColoredLightHelper.getPackedColor(meta, light); - } } diff --git a/src/main/java/vazkii/botania/common/integration/coloredlights/LightHelperVanilla.java b/src/main/java/vazkii/botania/common/integration/coloredlights/LightHelperVanilla.java index 89baa25ef4..441d0dd578 100644 --- a/src/main/java/vazkii/botania/common/integration/coloredlights/LightHelperVanilla.java +++ b/src/main/java/vazkii/botania/common/integration/coloredlights/LightHelperVanilla.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [May 16, 2015, 8:30:41 PM (GMT)] */ package vazkii.botania.common.integration.coloredlights; @@ -15,13 +15,14 @@ */ public class LightHelperVanilla implements ILightHelper { - @Override - public int makeRGBLightValue(float r, float g, float b, int currentLightValue) { - return currentLightValue; - } + @Override + public int makeRGBLightValue(float r, float g, float b, int currentLightValue) { + return currentLightValue; + } + + @Override + public int getPackedColor(int meta, int light) { + return light; + } - @Override - public int getPackedColor(int meta, int light) { - return light; - } } diff --git a/src/main/java/vazkii/botania/common/integration/corporea/WrappedDeepStorage.java b/src/main/java/vazkii/botania/common/integration/corporea/WrappedDeepStorage.java index 5980a690e5..b15b3097fe 100644 --- a/src/main/java/vazkii/botania/common/integration/corporea/WrappedDeepStorage.java +++ b/src/main/java/vazkii/botania/common/integration/corporea/WrappedDeepStorage.java @@ -2,19 +2,21 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * */ package vazkii.botania.common.integration.corporea; -import cpw.mods.fml.common.FMLLog; import java.util.ArrayList; import java.util.List; + +import org.apache.logging.log4j.Level; + +import cpw.mods.fml.common.FMLLog; import net.minecraft.inventory.IInventory; import net.minecraft.item.ItemStack; -import org.apache.logging.log4j.Level; import powercrystals.minefactoryreloaded.api.IDeepStorageUnit; import vazkii.botania.api.corporea.CorporeaRequest; import vazkii.botania.api.corporea.ICorporeaSpark; @@ -26,107 +28,109 @@ */ public class WrappedDeepStorage extends WrappedInventoryBase { - private static boolean checkedInterface = false; - private static boolean deepStoragePresent = false; - - private IDeepStorageUnit inv; - - private WrappedDeepStorage(IDeepStorageUnit inv, ICorporeaSpark spark) { - this.inv = inv; - this.spark = spark; - } - - @Override - public IInventory getWrappedObject() { - return (IInventory) inv; - } - - @Override - public List countItems(CorporeaRequest request) { - return iterateOverStacks(request, false); - } - - @Override - public List extractItems(CorporeaRequest request) { - return iterateOverStacks(request, true); - } - - private List iterateOverStacks(CorporeaRequest request, boolean doit) { - List stacks = new ArrayList(); - boolean removedAny = false; - - ItemStack prototype = inv.getStoredItemType(); - if (prototype == null) { - // for the case of barrel without contents set - return stacks; - } - int storedCount = prototype.stackSize; - - // WARNING: this code is very similar in all implementations of - // IWrappedInventory - keep it synch - // this code is also near duplicate to WrappedStorageDrawers - keep it - // synchronized - if (isMatchingItemStack(request.matcher, request.checkNBT, prototype)) { - int rem = Math.min(storedCount, request.count == -1 ? storedCount : request.count); - - if (rem > 0) { - ItemStack copy = prototype.copy(); - copy.stackSize = rem; - if (doit) { - stacks.addAll(breakDownBigStack(copy)); - } else { - stacks.add(copy); - } - } - - request.foundItems += storedCount; - request.extractedItems += rem; - - if (doit && rem > 0) { - decreaseStoredCount(inv, rem); - - removedAny = true; - if (spark != null) spark.onItemExtracted(prototype); - } - if (request.count != -1) request.count -= rem; - } - if (removedAny) { - // inv.markDirtyIfNeeded(); - } - return stacks; - } - - private void decreaseStoredCount(IDeepStorageUnit inventory, int rem) { - inventory.setStoredItemCount(inventory.getStoredItemType().stackSize - rem); - } - - /** - * Creates {@link WrappedDeepStorage} if specified inv can be wrapped. - * - * @return wrapped inventory or null if it has incompatible type. - */ - public static IWrappedInventory wrap(IInventory inv, ICorporeaSpark spark) { - if (!isDeepStorageNeeded()) { - return null; - } - return inv instanceof IDeepStorageUnit ? new WrappedDeepStorage((IDeepStorageUnit) inv, spark) : null; - } - - /** - * This method checks for presence of Deep Storage API in the pack - if some - * other mod provides IDeepStorageUnit, support for Deep Storage will be - * used. This way we don't have to ship IDeepStorageUnit in Botania jar. - */ - private static boolean isDeepStorageNeeded() { - if (!checkedInterface) { - try { - deepStoragePresent = (Class.forName("powercrystals.minefactoryreloaded.api.IDeepStorageUnit") != null); - } catch (ClassNotFoundException e) { - deepStoragePresent = false; - } - checkedInterface = true; - FMLLog.log(Level.INFO, "[Botania] Corporea support for Deep Storage: %b", deepStoragePresent); - } - return deepStoragePresent; - } + private static boolean checkedInterface = false; + private static boolean deepStoragePresent = false; + + private IDeepStorageUnit inv; + + private WrappedDeepStorage(IDeepStorageUnit inv, ICorporeaSpark spark) { + this.inv = inv; + this.spark = spark; + } + + @Override + public IInventory getWrappedObject() { + return (IInventory) inv; + } + + @Override + public List countItems(CorporeaRequest request) { + return iterateOverStacks(request, false); + } + + @Override + public List extractItems(CorporeaRequest request) { + return iterateOverStacks(request, true); + } + + private List iterateOverStacks(CorporeaRequest request, boolean doit) { + List stacks = new ArrayList(); + boolean removedAny = false; + + ItemStack prototype = inv.getStoredItemType(); + if(prototype == null) { + // for the case of barrel without contents set + return stacks; + } + int storedCount = prototype.stackSize; + + // WARNING: this code is very similar in all implementations of + // IWrappedInventory - keep it synch + // this code is also near duplicate to WrappedStorageDrawers - keep it + // synchronized + if(isMatchingItemStack(request.matcher, request.checkNBT, prototype)) { + int rem = Math.min(storedCount, request.count == -1 ? storedCount : request.count); + + if(rem > 0) { + ItemStack copy = prototype.copy(); + copy.stackSize = rem; + if(doit) { + stacks.addAll(breakDownBigStack(copy)); + } else { + stacks.add(copy); + } + } + + request.foundItems += storedCount; + request.extractedItems += rem; + + if(doit && rem > 0) { + decreaseStoredCount(inv, rem); + + removedAny = true; + if(spark != null) + spark.onItemExtracted(prototype); + } + if(request.count != -1) + request.count -= rem; + } + if(removedAny) { + // inv.markDirtyIfNeeded(); + } + return stacks; + } + + private void decreaseStoredCount(IDeepStorageUnit inventory, int rem) { + inventory.setStoredItemCount(inventory.getStoredItemType().stackSize - rem); + } + + /** + * Creates {@link WrappedDeepStorage} if specified inv can be wrapped. + * + * @return wrapped inventory or null if it has incompatible type. + */ + public static IWrappedInventory wrap(IInventory inv, ICorporeaSpark spark) { + if(!isDeepStorageNeeded()) { + return null; + } + return inv instanceof IDeepStorageUnit ? new WrappedDeepStorage((IDeepStorageUnit) inv, spark) : null; + } + + /** + * This method checks for presence of Deep Storage API in the pack - if some + * other mod provides IDeepStorageUnit, support for Deep Storage will be + * used. This way we don't have to ship IDeepStorageUnit in Botania jar. + */ + private static boolean isDeepStorageNeeded() { + if(!checkedInterface) { + try { + deepStoragePresent = (Class.forName("powercrystals.minefactoryreloaded.api.IDeepStorageUnit") != null); + } catch (ClassNotFoundException e) { + deepStoragePresent = false; + } + checkedInterface = true; + FMLLog.log(Level.INFO, "[Botania] Corporea support for Deep Storage: %b", deepStoragePresent); + } + return deepStoragePresent; + } } diff --git a/src/main/java/vazkii/botania/common/integration/corporea/WrappedIInventory.java b/src/main/java/vazkii/botania/common/integration/corporea/WrappedIInventory.java index 8da375f34b..837df4b9cf 100644 --- a/src/main/java/vazkii/botania/common/integration/corporea/WrappedIInventory.java +++ b/src/main/java/vazkii/botania/common/integration/corporea/WrappedIInventory.java @@ -2,15 +2,16 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * */ package vazkii.botania.common.integration.corporea; import java.util.ArrayList; import java.util.List; + import net.minecraft.inventory.IInventory; import net.minecraft.item.ItemStack; import vazkii.botania.api.corporea.CorporeaHelper; @@ -18,69 +19,74 @@ import vazkii.botania.api.corporea.ICorporeaSpark; import vazkii.botania.api.corporea.IWrappedInventory; -public class WrappedIInventory extends WrappedInventoryBase { - - private IInventory inv; - - private WrappedIInventory(IInventory inv, ICorporeaSpark spark) { - this.inv = inv; - this.spark = spark; - } - - @Override - public IInventory getWrappedObject() { - return inv; - } - - @Override - public List countItems(CorporeaRequest request) { - return iterateOverSlots(request, false); - } - - @Override - public List extractItems(CorporeaRequest request) { - return iterateOverSlots(request, true); - } - - private List iterateOverSlots(CorporeaRequest request, boolean doit) { - List stacks = new ArrayList(); - - boolean removedAny = false; - for (int i = inv.getSizeInventory() - 1; i >= 0; i--) { - if (!CorporeaHelper.isValidSlot(inv, i)) continue; - - ItemStack stackAt = inv.getStackInSlot(i); - // WARNING: this code is very similar in all implementations of - // IWrappedInventory - keep it synch - if (isMatchingItemStack(request.matcher, request.checkNBT, stackAt)) { - int rem = Math.min(stackAt.stackSize, request.count == -1 ? stackAt.stackSize : request.count); - - if (rem > 0) { - ItemStack copy = stackAt.copy(); - if (rem < copy.stackSize) copy.stackSize = rem; - stacks.add(copy); - } - - request.foundItems += stackAt.stackSize; - request.extractedItems += rem; - - if (doit && rem > 0) { - inv.decrStackSize(i, rem); - removedAny = true; - if (spark != null) spark.onItemExtracted(stackAt); - } - if (request.count != -1) request.count -= rem; - } - } - - if (removedAny) { - inv.markDirty(); - } - - return stacks; - } - - public static IWrappedInventory wrap(IInventory inv, ICorporeaSpark spark) { - return new WrappedIInventory(inv, spark); - } +public class WrappedIInventory extends WrappedInventoryBase{ + + private IInventory inv; + + private WrappedIInventory(IInventory inv, ICorporeaSpark spark) { + this.inv = inv; + this.spark = spark; + } + + @Override + public IInventory getWrappedObject() { + return inv; + } + + @Override + public List countItems(CorporeaRequest request) { + return iterateOverSlots(request, false); + } + + @Override + public List extractItems(CorporeaRequest request) { + return iterateOverSlots(request, true); + } + + private List iterateOverSlots(CorporeaRequest request, boolean doit) { + List stacks = new ArrayList(); + + boolean removedAny = false; + for (int i = inv.getSizeInventory() - 1; i >= 0; i--) { + if(!CorporeaHelper.isValidSlot(inv, i)) + continue; + + ItemStack stackAt = inv.getStackInSlot(i); + // WARNING: this code is very similar in all implementations of + // IWrappedInventory - keep it synch + if(isMatchingItemStack(request.matcher, request.checkNBT, stackAt)) { + int rem = Math.min(stackAt.stackSize, request.count == -1 ? stackAt.stackSize : request.count); + + if(rem > 0) { + ItemStack copy = stackAt.copy(); + if(rem < copy.stackSize) + copy.stackSize = rem; + stacks.add(copy); + } + + request.foundItems += stackAt.stackSize; + request.extractedItems += rem; + + if(doit && rem > 0) { + inv.decrStackSize(i, rem); + removedAny = true; + if(spark != null) + spark.onItemExtracted(stackAt); + } + if(request.count != -1) + request.count -= rem; + } + } + + if(removedAny) { + inv.markDirty(); + } + + return stacks; + } + + public static IWrappedInventory wrap(IInventory inv, ICorporeaSpark spark) { + return new WrappedIInventory(inv, spark); + } + } diff --git a/src/main/java/vazkii/botania/common/integration/corporea/WrappedInventoryBase.java b/src/main/java/vazkii/botania/common/integration/corporea/WrappedInventoryBase.java index 34230b80c1..9ff62e35ea 100644 --- a/src/main/java/vazkii/botania/common/integration/corporea/WrappedInventoryBase.java +++ b/src/main/java/vazkii/botania/common/integration/corporea/WrappedInventoryBase.java @@ -2,16 +2,17 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * */ package vazkii.botania.common.integration.corporea; import java.util.ArrayList; import java.util.Collection; import java.util.List; + import net.minecraft.item.ItemStack; import vazkii.botania.api.corporea.CorporeaHelper; import vazkii.botania.api.corporea.ICorporeaSpark; @@ -19,34 +20,33 @@ public abstract class WrappedInventoryBase implements IWrappedInventory { - protected ICorporeaSpark spark; - - @Override - public ICorporeaSpark getSpark() { - return spark; - } - - protected boolean isMatchingItemStack(Object matcher, boolean checkNBT, ItemStack stackAt) { - return matcher instanceof ItemStack - ? CorporeaHelper.stacksMatch((ItemStack) matcher, stackAt, checkNBT) - : matcher instanceof String ? CorporeaHelper.stacksMatch(stackAt, (String) matcher) : false; - } - - protected Collection breakDownBigStack(ItemStack stack) { - List stacks = new ArrayList(); - int additionalStacks = stack.stackSize / stack.getMaxStackSize(); - int lastStackSize = stack.stackSize % stack.getMaxStackSize(); - if (additionalStacks > 0) { - ItemStack fullStack = stack.copy(); - fullStack.stackSize = stack.getMaxStackSize(); - for (int i = 0; i < additionalStacks; i++) { - stacks.add(fullStack.copy()); - } - } - ItemStack lastStack = stack.copy(); - lastStack.stackSize = lastStackSize; - stacks.add(lastStack); - - return stacks; - } + protected ICorporeaSpark spark; + + @Override + public ICorporeaSpark getSpark() { + return spark; + } + + protected boolean isMatchingItemStack(Object matcher, boolean checkNBT, ItemStack stackAt) { + return matcher instanceof ItemStack ? CorporeaHelper.stacksMatch((ItemStack) matcher, stackAt, checkNBT) + : matcher instanceof String ? CorporeaHelper.stacksMatch(stackAt, (String) matcher) : false; + } + + protected Collection breakDownBigStack(ItemStack stack) { + List stacks = new ArrayList(); + int additionalStacks = stack.stackSize / stack.getMaxStackSize(); + int lastStackSize = stack.stackSize % stack.getMaxStackSize(); + if(additionalStacks > 0) { + ItemStack fullStack = stack.copy(); + fullStack.stackSize = stack.getMaxStackSize(); + for (int i = 0; i < additionalStacks; i++) { + stacks.add(fullStack.copy()); + } + } + ItemStack lastStack = stack.copy(); + lastStack.stackSize = lastStackSize; + stacks.add(lastStack); + + return stacks; + } } diff --git a/src/main/java/vazkii/botania/common/integration/corporea/WrappedStorageDrawers.java b/src/main/java/vazkii/botania/common/integration/corporea/WrappedStorageDrawers.java index 617155b77b..2ee27ce9cb 100644 --- a/src/main/java/vazkii/botania/common/integration/corporea/WrappedStorageDrawers.java +++ b/src/main/java/vazkii/botania/common/integration/corporea/WrappedStorageDrawers.java @@ -2,17 +2,19 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * */ package vazkii.botania.common.integration.corporea; -import com.jaquadro.minecraft.storagedrawers.api.storage.IDrawer; -import com.jaquadro.minecraft.storagedrawers.api.storage.IDrawerGroup; import java.util.ArrayList; import java.util.List; + +import com.jaquadro.minecraft.storagedrawers.api.storage.IDrawer; +import com.jaquadro.minecraft.storagedrawers.api.storage.IDrawerGroup; + import net.minecraft.inventory.IInventory; import net.minecraft.item.ItemStack; import vazkii.botania.api.corporea.CorporeaRequest; @@ -25,85 +27,87 @@ */ public class WrappedStorageDrawers extends WrappedInventoryBase { - private IDrawerGroup inv; - - private WrappedStorageDrawers(IDrawerGroup inv, ICorporeaSpark spark) { - this.inv = inv; - this.spark = spark; - } - - @Override - public IInventory getWrappedObject() { - return (IInventory) inv; - } - - @Override - public List countItems(CorporeaRequest request) { - return iterateOverStacks(request, false); - } - - @Override - public List extractItems(CorporeaRequest request) { - return iterateOverStacks(request, true); - } - - private List iterateOverStacks(CorporeaRequest request, boolean doit) { - List stacks = new ArrayList(); - boolean removedAny = false; - - for (int i = 0; i < inv.getDrawerCount(); i++) { - IDrawer drawer = inv.getDrawer(i); - if (drawer == null) { - continue; - } - ItemStack prototype = drawer.getStoredItemPrototype(); - int storedCount = drawer.getStoredItemCount(); - - // WARNING: this code is very similar in all implementations of - // IWrappedInventory - keep it synch - // also this code is near duplicate to WrappedDeepStorage - keep it - // synchronized - if (isMatchingItemStack(request.matcher, request.checkNBT, prototype)) { - int rem = Math.min(storedCount, request.count == -1 ? storedCount : request.count); - - if (rem > 0) { - ItemStack copy = prototype.copy(); - copy.stackSize = rem; - if (doit) { - stacks.addAll(breakDownBigStack(copy)); - } else { - stacks.add(copy); - } - } - - request.foundItems += storedCount; - request.extractedItems += rem; - - if (doit && rem > 0) { - decreaseStoredCount(drawer, rem); - - removedAny = true; - if (spark != null) spark.onItemExtracted(prototype); - } - if (request.count != -1) request.count -= rem; - } - } - if (removedAny) { - inv.markDirtyIfNeeded(); - } - return stacks; - } - - private void decreaseStoredCount(IDrawer drawer, int rem) { - drawer.setStoredItemCount(drawer.getStoredItemCount() - rem); - } - - /** - * Creates {@link WrappedStorageDrawers} if specified inv can be wrapped. - * - * @return wrapped inventory or null if it has incompatible type. - */ - public static IWrappedInventory wrap(IInventory inv, ICorporeaSpark spark) { - return inv instanceof IDrawerGroup ? new WrappedStorageDrawers((IDrawerGroup) inv, spark) : null; - } + private IDrawerGroup inv; + + private WrappedStorageDrawers(IDrawerGroup inv, ICorporeaSpark spark) { + this.inv = inv; + this.spark = spark; + } + + @Override + public IInventory getWrappedObject() { + return (IInventory) inv; + } + + @Override + public List countItems(CorporeaRequest request) { + return iterateOverStacks(request, false); + } + + @Override + public List extractItems(CorporeaRequest request) { + return iterateOverStacks(request, true); + } + + private List iterateOverStacks(CorporeaRequest request, boolean doit) { + List stacks = new ArrayList(); + boolean removedAny = false; + + for(int i = 0; i < inv.getDrawerCount(); i++) { + IDrawer drawer = inv.getDrawer(i); + if(drawer == null) { + continue; + } + ItemStack prototype = drawer.getStoredItemPrototype(); + int storedCount = drawer.getStoredItemCount(); + + // WARNING: this code is very similar in all implementations of + // IWrappedInventory - keep it synch + // also this code is near duplicate to WrappedDeepStorage - keep it + // synchronized + if(isMatchingItemStack(request.matcher, request.checkNBT, prototype)) { + int rem = Math.min(storedCount, request.count == -1 ? storedCount : request.count); + + if(rem > 0) { + ItemStack copy = prototype.copy(); + copy.stackSize = rem; + if(doit) { + stacks.addAll(breakDownBigStack(copy)); + } else { + stacks.add(copy); + } + } + + request.foundItems += storedCount; + request.extractedItems += rem; + + if(doit && rem > 0) { + decreaseStoredCount(drawer, rem); + + removedAny = true; + if(spark != null) + spark.onItemExtracted(prototype); + } + if(request.count != -1) + request.count -= rem; + } + } + if(removedAny) { + inv.markDirtyIfNeeded(); + } + return stacks; + } + + private void decreaseStoredCount(IDrawer drawer, int rem) { + drawer.setStoredItemCount(drawer.getStoredItemCount() - rem); + } + + /** + * Creates {@link WrappedStorageDrawers} if specified inv can be wrapped. + * + * @return wrapped inventory or null if it has incompatible type. + */ + public static IWrappedInventory wrap(IInventory inv, ICorporeaSpark spark) { + return inv instanceof IDrawerGroup ? new WrappedStorageDrawers((IDrawerGroup) inv, spark) : null; + } } diff --git a/src/main/java/vazkii/botania/common/integration/etfuturum/ModBanners.java b/src/main/java/vazkii/botania/common/integration/etfuturum/ModBanners.java index d78cd6c2ff..8b140b780b 100644 --- a/src/main/java/vazkii/botania/common/integration/etfuturum/ModBanners.java +++ b/src/main/java/vazkii/botania/common/integration/etfuturum/ModBanners.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Aug 25, 2015, 7:11:35 PM (GMT)] */ package vazkii.botania.common.integration.etfuturum; @@ -18,38 +18,34 @@ public final class ModBanners { - public static void init() { - try { - Class> clazz = (Class>) - Class.forName("ganymedes01.etfuturum.tileentities.TileEntityBanner$EnumBannerPattern"); - addPattern(clazz, "flower", "flr", new ItemStack(ModItems.manaResource, 1, 3)); - addPattern(clazz, "lexicon", "lex", new ItemStack(ModItems.lexicon)); - addPattern(clazz, "logo", "lgo", new ItemStack(ModItems.manaResource, 1, 4)); - addPattern(clazz, "sapling", "spl", new ItemStack(ModItems.manaResource, 1, 13)); - addPattern(clazz, "tiny_potato", "tpt", new ItemStack(ModBlocks.tinyPotato)); + public static void init() { + try { + Class> clazz = (Class>) Class.forName("ganymedes01.etfuturum.tileentities.TileEntityBanner$EnumBannerPattern"); + addPattern(clazz, "flower", "flr", new ItemStack(ModItems.manaResource, 1, 3)); + addPattern(clazz, "lexicon", "lex", new ItemStack(ModItems.lexicon)); + addPattern(clazz, "logo", "lgo", new ItemStack(ModItems.manaResource, 1, 4)); + addPattern(clazz, "sapling", "spl", new ItemStack(ModItems.manaResource, 1, 13)); + addPattern(clazz, "tiny_potato", "tpt", new ItemStack(ModBlocks.tinyPotato)); - addPattern(clazz, "spark_dispersive", "sds", new ItemStack(ModItems.sparkUpgrade, 1, 0)); - addPattern(clazz, "spark_dominant", "sdm", new ItemStack(ModItems.sparkUpgrade, 1, 1)); - addPattern(clazz, "spark_recessive", "src", new ItemStack(ModItems.sparkUpgrade, 1, 2)); - addPattern(clazz, "spark_isolated", "sis", new ItemStack(ModItems.sparkUpgrade, 1, 3)); + addPattern(clazz, "spark_dispersive", "sds", new ItemStack(ModItems.sparkUpgrade, 1, 0)); + addPattern(clazz, "spark_dominant", "sdm", new ItemStack(ModItems.sparkUpgrade, 1, 1)); + addPattern(clazz, "spark_recessive", "src", new ItemStack(ModItems.sparkUpgrade, 1, 2)); + addPattern(clazz, "spark_isolated", "sis", new ItemStack(ModItems.sparkUpgrade, 1, 3)); - addPattern(clazz, "fish", "fis", new ItemStack(Items.fish)); - addPattern(clazz, "axe", "axe", new ItemStack(Items.iron_axe)); - addPattern(clazz, "hoe", "hoe", new ItemStack(Items.iron_hoe)); - addPattern(clazz, "pickaxe", "pik", new ItemStack(Items.iron_pickaxe)); - addPattern(clazz, "shovel", "shv", new ItemStack(Items.iron_shovel)); - addPattern(clazz, "sword", "srd", new ItemStack(Items.iron_sword)); - } catch (ClassNotFoundException e) { - // Looks like we don't have EtFuturum around, let's not do any of this nonsense then - } - } + addPattern(clazz, "fish", "fis", new ItemStack(Items.fish)); + addPattern(clazz, "axe", "axe", new ItemStack(Items.iron_axe)); + addPattern(clazz, "hoe", "hoe", new ItemStack(Items.iron_hoe)); + addPattern(clazz, "pickaxe", "pik", new ItemStack(Items.iron_pickaxe)); + addPattern(clazz, "shovel", "shv", new ItemStack(Items.iron_shovel)); + addPattern(clazz, "sword", "srd", new ItemStack(Items.iron_sword)); + } catch (ClassNotFoundException e) { + // Looks like we don't have EtFuturum around, let's not do any of this nonsense then + } + } - public static void addPattern(Class> clazz, String name, String id, ItemStack craftingItem) { - name = "botania_" + name; - id = "bt_" + id; - EnumHelper.addEnum( - clazz, name.toUpperCase(), new Class[] {String.class, String.class, ItemStack.class}, new Object[] { - name, id, craftingItem - }); - } + public static void addPattern(Class> clazz, String name, String id, ItemStack craftingItem) { + name = "botania_" + name; + id = "bt_" + id; + EnumHelper.addEnum(clazz, name.toUpperCase(), new Class[] { String.class, String.class, ItemStack.class }, new Object[] { name, id, craftingItem }); + } } diff --git a/src/main/java/vazkii/botania/common/integration/multipart/MultipartHandler.java b/src/main/java/vazkii/botania/common/integration/multipart/MultipartHandler.java index b249b021d1..de6ef54c6f 100644 --- a/src/main/java/vazkii/botania/common/integration/multipart/MultipartHandler.java +++ b/src/main/java/vazkii/botania/common/integration/multipart/MultipartHandler.java @@ -2,65 +2,70 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Sep 1, 2015, 5:32:15 PM (GMT)] */ package vazkii.botania.common.integration.multipart; -import codechicken.microblock.BlockMicroMaterial; -import codechicken.microblock.MicroMaterialRegistry; +import java.util.ArrayList; +import java.util.List; + import net.minecraft.block.Block; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; import vazkii.botania.common.block.ModBlocks; import vazkii.botania.common.block.ModFluffBlocks; +import codechicken.microblock.BlockMicroMaterial; +import codechicken.microblock.MicroMaterialRegistry; public class MultipartHandler { - public MultipartHandler() { - registerMultiparts(ModBlocks.livingrock, 0, 4); - registerMultiparts(ModBlocks.livingwood, 0, 5); - registerMultiparts(ModBlocks.storage, 0, 4); - registerMultiparts(ModBlocks.dreamwood, 0, 4); - registerMultiparts(ModBlocks.prismarine, 0, 2); - registerMultiparts(ModBlocks.seaLamp); - registerMultiparts(ModBlocks.reedBlock); - registerMultiparts(ModBlocks.thatch); - registerMultiparts(ModBlocks.customBrick, 0, 15); - registerMultiparts(ModBlocks.elfGlass); - registerMultiparts(ModBlocks.manaGlass); - registerMultiparts(ModBlocks.endStoneBrick, 0, 3); - registerMultiparts(ModBlocks.blazeBlock); - registerMultiparts(ModBlocks.bifrostPerm); - registerMultiparts(ModBlocks.shimmerrock); - registerMultiparts(ModBlocks.shimmerwoodPlanks); + public MultipartHandler() { + registerMultiparts(ModBlocks.livingrock, 0, 4); + registerMultiparts(ModBlocks.livingwood, 0, 5); + registerMultiparts(ModBlocks.storage, 0, 4); + registerMultiparts(ModBlocks.dreamwood, 0, 4); + registerMultiparts(ModBlocks.prismarine, 0, 2); + registerMultiparts(ModBlocks.seaLamp); + registerMultiparts(ModBlocks.reedBlock); + registerMultiparts(ModBlocks.thatch); + registerMultiparts(ModBlocks.customBrick, 0, 15); + registerMultiparts(ModBlocks.elfGlass); + registerMultiparts(ModBlocks.manaGlass); + registerMultiparts(ModBlocks.endStoneBrick, 0, 3); + registerMultiparts(ModBlocks.blazeBlock); + registerMultiparts(ModBlocks.bifrostPerm); + registerMultiparts(ModBlocks.shimmerrock); + registerMultiparts(ModBlocks.shimmerwoodPlanks); + + registerMultiparts(ModFluffBlocks.darkQuartz, 0, 2); + registerMultiparts(ModFluffBlocks.manaQuartz, 0, 2); + registerMultiparts(ModFluffBlocks.blazeQuartz, 0, 2); + registerMultiparts(ModFluffBlocks.lavenderQuartz, 0, 2); + registerMultiparts(ModFluffBlocks.redQuartz, 0, 2); + registerMultiparts(ModFluffBlocks.elfQuartz, 0, 2); + registerMultiparts(ModFluffBlocks.sunnyQuartz, 0, 2); + registerMultiparts(ModFluffBlocks.biomeStoneA, 0, 15); + registerMultiparts(ModFluffBlocks.biomeStoneB, 0, 15); + registerMultiparts(ModFluffBlocks.stone, 0, 15); + registerMultiparts(ModFluffBlocks.pavement, 0, 5); + } - registerMultiparts(ModFluffBlocks.darkQuartz, 0, 2); - registerMultiparts(ModFluffBlocks.manaQuartz, 0, 2); - registerMultiparts(ModFluffBlocks.blazeQuartz, 0, 2); - registerMultiparts(ModFluffBlocks.lavenderQuartz, 0, 2); - registerMultiparts(ModFluffBlocks.redQuartz, 0, 2); - registerMultiparts(ModFluffBlocks.elfQuartz, 0, 2); - registerMultiparts(ModFluffBlocks.sunnyQuartz, 0, 2); - registerMultiparts(ModFluffBlocks.biomeStoneA, 0, 15); - registerMultiparts(ModFluffBlocks.biomeStoneB, 0, 15); - registerMultiparts(ModFluffBlocks.stone, 0, 15); - registerMultiparts(ModFluffBlocks.pavement, 0, 5); - } + private static void registerMultiparts(Block block) { + registerMultiparts(block, 0); + } - private static void registerMultiparts(Block block) { - registerMultiparts(block, 0); - } + private static void registerMultiparts(Block block, int meta) { + MicroMaterialRegistry.registerMaterial(new BlockMicroMaterial(block, meta), block.getUnlocalizedName() + (meta == 0 ? "" : "_" + meta)); + } - private static void registerMultiparts(Block block, int meta) { - MicroMaterialRegistry.registerMaterial( - new BlockMicroMaterial(block, meta), block.getUnlocalizedName() + (meta == 0 ? "" : "_" + meta)); - } + private static void registerMultiparts(Block block, int metamin, int metamax) { + for (int i = metamin; i <= metamax; i++) { + registerMultiparts(block, i); + } + } - private static void registerMultiparts(Block block, int metamin, int metamax) { - for (int i = metamin; i <= metamax; i++) { - registerMultiparts(block, i); - } - } } diff --git a/src/main/java/vazkii/botania/common/item/Item16Colors.java b/src/main/java/vazkii/botania/common/item/Item16Colors.java index b572d56cd8..5abafdc6cd 100644 --- a/src/main/java/vazkii/botania/common/item/Item16Colors.java +++ b/src/main/java/vazkii/botania/common/item/Item16Colors.java @@ -2,16 +2,17 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jan 19, 2014, 4:09:57 PM (GMT)] */ package vazkii.botania.common.item; import java.awt.Color; import java.util.List; + import net.minecraft.creativetab.CreativeTabs; import net.minecraft.entity.passive.EntitySheep; import net.minecraft.item.Item; @@ -19,31 +20,34 @@ public class Item16Colors extends ItemMod { - public Item16Colors(String name) { - super(); - setHasSubtypes(true); - setUnlocalizedName(name); - } - - @Override - public int getColorFromItemStack(ItemStack par1ItemStack, int par2) { - if (par1ItemStack.getItemDamage() >= EntitySheep.fleeceColorTable.length) return 0xFFFFFF; - - float[] color = EntitySheep.fleeceColorTable[par1ItemStack.getItemDamage()]; - return new Color(color[0], color[1], color[2]).getRGB(); - } - - @Override - public void getSubItems(Item item, CreativeTabs par2CreativeTabs, List par3List) { - for (int i = 0; i < 16; i++) par3List.add(new ItemStack(item, 1, i)); - } - - @Override - public String getUnlocalizedName(ItemStack par1ItemStack) { - return getUnlocalizedNameLazy(par1ItemStack) + par1ItemStack.getItemDamage(); - } - - String getUnlocalizedNameLazy(ItemStack par1ItemStack) { - return super.getUnlocalizedName(par1ItemStack); - } + public Item16Colors(String name) { + super(); + setHasSubtypes(true); + setUnlocalizedName(name); + } + + @Override + public int getColorFromItemStack(ItemStack par1ItemStack, int par2) { + if(par1ItemStack.getItemDamage() >= EntitySheep.fleeceColorTable.length) + return 0xFFFFFF; + + float[] color = EntitySheep.fleeceColorTable[par1ItemStack.getItemDamage()]; + return new Color(color[0], color[1], color[2]).getRGB(); + } + + @Override + public void getSubItems(Item item, CreativeTabs par2CreativeTabs, List par3List) { + for(int i = 0; i < 16; i++) + par3List.add(new ItemStack(item, 1, i)); + } + + @Override + public String getUnlocalizedName(ItemStack par1ItemStack) { + return getUnlocalizedNameLazy(par1ItemStack) + par1ItemStack.getItemDamage(); + } + + String getUnlocalizedNameLazy(ItemStack par1ItemStack) { + return super.getUnlocalizedName(par1ItemStack); + } + } diff --git a/src/main/java/vazkii/botania/common/item/ItemAncientWill.java b/src/main/java/vazkii/botania/common/item/ItemAncientWill.java index f855acc71f..5001267dfe 100644 --- a/src/main/java/vazkii/botania/common/item/ItemAncientWill.java +++ b/src/main/java/vazkii/botania/common/item/ItemAncientWill.java @@ -2,16 +2,16 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jan 30, 2015, 10:59:45 PM (GMT)] */ package vazkii.botania.common.item; -import cpw.mods.fml.common.registry.GameRegistry; import java.util.List; + import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.entity.player.EntityPlayer; @@ -24,51 +24,55 @@ import vazkii.botania.client.core.helper.IconHelper; import vazkii.botania.common.crafting.recipe.AncientWillRecipe; import vazkii.botania.common.lib.LibItemNames; +import cpw.mods.fml.common.registry.GameRegistry; public class ItemAncientWill extends ItemMod { - private static final int SUBTYPES = 6; + private static final int SUBTYPES = 6; + + IIcon[] icons; + + public ItemAncientWill() { + setUnlocalizedName(LibItemNames.ANCIENT_WILL); + setHasSubtypes(true); + setMaxStackSize(1); - IIcon[] icons; + GameRegistry.addRecipe(new AncientWillRecipe()); + RecipeSorter.register("botania:ancientWill", AncientWillRecipe.class, Category.SHAPELESS, ""); + } - public ItemAncientWill() { - setUnlocalizedName(LibItemNames.ANCIENT_WILL); - setHasSubtypes(true); - setMaxStackSize(1); + @Override + public void getSubItems(Item item, CreativeTabs tab, List list) { + for(int i = 0; i < SUBTYPES; i++) + list.add(new ItemStack(item, 1, i)); + } - GameRegistry.addRecipe(new AncientWillRecipe()); - RecipeSorter.register("botania:ancientWill", AncientWillRecipe.class, Category.SHAPELESS, ""); - } + @Override + public void registerIcons(IIconRegister par1IconRegister) { + icons = new IIcon[SUBTYPES]; + for(int i = 0; i < icons.length; i++) + icons[i] = IconHelper.forItem(par1IconRegister, this, i); + } - @Override - public void getSubItems(Item item, CreativeTabs tab, List list) { - for (int i = 0; i < SUBTYPES; i++) list.add(new ItemStack(item, 1, i)); - } + @Override + public IIcon getIconFromDamage(int dmg) { + return icons[Math.min(icons.length - 1, dmg)]; + } - @Override - public void registerIcons(IIconRegister par1IconRegister) { - icons = new IIcon[SUBTYPES]; - for (int i = 0; i < icons.length; i++) icons[i] = IconHelper.forItem(par1IconRegister, this, i); - } + @Override + public void addInformation(ItemStack stack, EntityPlayer player, List list, boolean adv) { + addStringToTooltip(StatCollector.translateToLocal("botaniamisc.craftToAddWill"), list); + addStringToTooltip(StatCollector.translateToLocal("botania.armorset.will" + stack.getItemDamage() + ".shortDesc"), list); + } - @Override - public IIcon getIconFromDamage(int dmg) { - return icons[Math.min(icons.length - 1, dmg)]; - } + public void addStringToTooltip(String s, List tooltip) { + tooltip.add(s.replaceAll("&", "\u00a7")); + } - @Override - public void addInformation(ItemStack stack, EntityPlayer player, List list, boolean adv) { - addStringToTooltip(StatCollector.translateToLocal("botaniamisc.craftToAddWill"), list); - addStringToTooltip( - StatCollector.translateToLocal("botania.armorset.will" + stack.getItemDamage() + ".shortDesc"), list); - } + @Override + public String getUnlocalizedName(ItemStack par1ItemStack) { + return super.getUnlocalizedName(par1ItemStack) + par1ItemStack.getItemDamage(); + } - public void addStringToTooltip(String s, List tooltip) { - tooltip.add(s.replaceAll("&", "\u00a7")); - } - @Override - public String getUnlocalizedName(ItemStack par1ItemStack) { - return super.getUnlocalizedName(par1ItemStack) + par1ItemStack.getItemDamage(); - } } diff --git a/src/main/java/vazkii/botania/common/item/ItemAutocraftingHalo.java b/src/main/java/vazkii/botania/common/item/ItemAutocraftingHalo.java index 6da14d3b94..abafbe8c7e 100644 --- a/src/main/java/vazkii/botania/common/item/ItemAutocraftingHalo.java +++ b/src/main/java/vazkii/botania/common/item/ItemAutocraftingHalo.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Sep 1, 2015, 2:23:26 AM (GMT)] */ package vazkii.botania.common.item; @@ -21,26 +21,28 @@ public class ItemAutocraftingHalo extends ItemCraftingHalo { - private static final ResourceLocation glowTexture = new ResourceLocation(LibResources.MISC_GLOW_CYAN); + private static final ResourceLocation glowTexture = new ResourceLocation(LibResources.MISC_GLOW_CYAN); - public ItemAutocraftingHalo() { - super(LibItemNames.AUTOCRAFTING_HALO); - } + public ItemAutocraftingHalo() { + super(LibItemNames.AUTOCRAFTING_HALO); + } - @Override - public void onUpdate(ItemStack stack, World world, Entity entity, int pos, boolean equipped) { - super.onUpdate(stack, world, entity, pos, equipped); + @Override + public void onUpdate(ItemStack stack, World world, Entity entity, int pos, boolean equipped) { + super.onUpdate(stack, world, entity, pos, equipped); - if (entity instanceof EntityPlayer && !equipped) { - EntityPlayer player = (EntityPlayer) entity; - IInventory inv = getFakeInv(player); + if(entity instanceof EntityPlayer && !equipped) { + EntityPlayer player = (EntityPlayer) entity; + IInventory inv = getFakeInv(player); - for (int i = 1; i < SEGMENTS; i++) tryCraft(player, stack, i, false, inv, false); - } - } + for(int i = 1; i < SEGMENTS; i++) + tryCraft(player, stack, i, false, inv, false); + } + } + + @Override + public ResourceLocation getGlowResource() { + return glowTexture; + } - @Override - public ResourceLocation getGlowResource() { - return glowTexture; - } } diff --git a/src/main/java/vazkii/botania/common/item/ItemBaubleBox.java b/src/main/java/vazkii/botania/common/item/ItemBaubleBox.java index 21bf39189d..925627a2a5 100644 --- a/src/main/java/vazkii/botania/common/item/ItemBaubleBox.java +++ b/src/main/java/vazkii/botania/common/item/ItemBaubleBox.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [25/11/2015, 19:46:11 (GMT)] */ package vazkii.botania.common.item; @@ -22,42 +22,45 @@ public class ItemBaubleBox extends ItemMod { - private static final String TAG_ITEMS = "InvItems"; - private static final String TAG_SLOT = "Slot"; - - public ItemBaubleBox() { - setUnlocalizedName(LibItemNames.BAUBLE_BOX); - setMaxStackSize(1); - } - - @Override - public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer player) { - player.openGui(Botania.instance, LibGuiIDs.BAUBLE_BOX, world, 0, 0, 0); - return stack; - } - - public static ItemStack[] loadStacks(ItemStack stack) { - NBTTagList var2 = ItemNBTHelper.getList(stack, TAG_ITEMS, 10, false); - ItemStack[] inventorySlots = new ItemStack[36]; - for (int var3 = 0; var3 < var2.tagCount(); ++var3) { - NBTTagCompound var4 = var2.getCompoundTagAt(var3); - byte var5 = var4.getByte(TAG_SLOT); - if (var5 >= 0 && var5 < inventorySlots.length) inventorySlots[var5] = ItemStack.loadItemStackFromNBT(var4); - } - - return inventorySlots; - } - - public static void setStacks(ItemStack stack, ItemStack[] inventorySlots) { - NBTTagList var2 = new NBTTagList(); - for (int var3 = 0; var3 < inventorySlots.length; ++var3) - if (inventorySlots[var3] != null) { - NBTTagCompound var4 = new NBTTagCompound(); - var4.setByte(TAG_SLOT, (byte) var3); - inventorySlots[var3].writeToNBT(var4); - var2.appendTag(var4); - } - - ItemNBTHelper.setList(stack, TAG_ITEMS, var2); - } + private static final String TAG_ITEMS = "InvItems"; + private static final String TAG_SLOT = "Slot"; + + public ItemBaubleBox() { + setUnlocalizedName(LibItemNames.BAUBLE_BOX); + setMaxStackSize(1); + } + + @Override + public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer player) { + player.openGui(Botania.instance, LibGuiIDs.BAUBLE_BOX, world, 0, 0, 0); + return stack; + } + + + public static ItemStack[] loadStacks(ItemStack stack) { + NBTTagList var2 = ItemNBTHelper.getList(stack, TAG_ITEMS, 10, false); + ItemStack[] inventorySlots = new ItemStack[36]; + for(int var3 = 0; var3 < var2.tagCount(); ++var3) { + NBTTagCompound var4 = var2.getCompoundTagAt(var3); + byte var5 = var4.getByte(TAG_SLOT); + if(var5 >= 0 && var5 < inventorySlots.length) + inventorySlots[var5] = ItemStack.loadItemStackFromNBT(var4); + } + + return inventorySlots; + } + + public static void setStacks(ItemStack stack, ItemStack[] inventorySlots) { + NBTTagList var2 = new NBTTagList(); + for(int var3 = 0; var3 < inventorySlots.length; ++var3) + if(inventorySlots[var3] != null) { + NBTTagCompound var4 = new NBTTagCompound(); + var4.setByte(TAG_SLOT, (byte)var3); + inventorySlots[var3].writeToNBT(var4); + var2.appendTag(var4); + } + + ItemNBTHelper.setList(stack, TAG_ITEMS, var2); + } + } diff --git a/src/main/java/vazkii/botania/common/item/ItemBlackHoleTalisman.java b/src/main/java/vazkii/botania/common/item/ItemBlackHoleTalisman.java index 4375ab255c..98cd2cd1ca 100644 --- a/src/main/java/vazkii/botania/common/item/ItemBlackHoleTalisman.java +++ b/src/main/java/vazkii/botania/common/item/ItemBlackHoleTalisman.java @@ -2,19 +2,17 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Mar 31, 2015, 11:04:12 PM (GMT)] */ package vazkii.botania.common.item; -import cpw.mods.fml.common.registry.GameRegistry; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; import java.util.Arrays; import java.util.List; + import net.minecraft.block.Block; import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.entity.Entity; @@ -41,314 +39,285 @@ import vazkii.botania.common.core.helper.ItemNBTHelper; import vazkii.botania.common.crafting.recipe.BlackHoleTalismanExtractRecipe; import vazkii.botania.common.lib.LibItemNames; +import cpw.mods.fml.common.registry.GameRegistry; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; public class ItemBlackHoleTalisman extends ItemMod implements IBlockProvider { - private static final String TAG_BLOCK_NAME = "blockName"; - private static final String TAG_BLOCK_META = "blockMeta"; - private static final String TAG_BLOCK_COUNT = "blockCount"; - - IIcon enabledIcon; - - public ItemBlackHoleTalisman() { - setUnlocalizedName(LibItemNames.BLACK_HOLE_TALISMAN); - setMaxStackSize(1); - setHasSubtypes(true); - - GameRegistry.addRecipe(new BlackHoleTalismanExtractRecipe()); - RecipeSorter.register( - "botania:blackHoleTalismanExtract", BlackHoleTalismanExtractRecipe.class, Category.SHAPELESS, ""); - } - - @Override - public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer) { - if (getBlock(par1ItemStack) != Blocks.air && par3EntityPlayer.isSneaking()) { - int dmg = par1ItemStack.getItemDamage(); - par1ItemStack.setItemDamage(~dmg & 1); - par2World.playSoundAtEntity(par3EntityPlayer, "random.orb", 0.3F, 0.1F); - } - - return par1ItemStack; - } - - @Override - public boolean onItemUse( - ItemStack par1ItemStack, - EntityPlayer par2EntityPlayer, - World par3World, - int par4, - int par5, - int par6, - int par7, - float par8, - float par9, - float par10) { - Block block = par3World.getBlock(par4, par5, par6); - int meta = par3World.getBlockMetadata(par4, par5, par6); - boolean set = setBlock(par1ItemStack, block, meta); - - if (!set) { - Block bBlock = getBlock(par1ItemStack); - int bmeta = getBlockMeta(par1ItemStack); - - TileEntity tile = par3World.getTileEntity(par4, par5, par6); - if (tile != null && tile instanceof IInventory) { - IInventory inv = (IInventory) tile; - int[] slots = inv instanceof ISidedInventory - ? ((ISidedInventory) inv).getAccessibleSlotsFromSide(par7) - : InventoryHelper.buildSlotsForLinearInventory(inv); - for (int slot : slots) { - ItemStack stackInSlot = inv.getStackInSlot(slot); - if (stackInSlot == null) { - ItemStack stack = new ItemStack(bBlock, 1, bmeta); - int maxSize = stack.getMaxStackSize(); - stack.stackSize = remove(par1ItemStack, maxSize); - if (stack.stackSize != 0) { - if (inv.isItemValidForSlot(slot, stack) - && (!(inv instanceof ISidedInventory) - || ((ISidedInventory) inv).canInsertItem(slot, stack, par7))) { - inv.setInventorySlotContents(slot, stack); - inv.markDirty(); - set = true; - } - } - } else if (stackInSlot.getItem() == Item.getItemFromBlock(bBlock) - && stackInSlot.getItemDamage() == bmeta) { - int maxSize = stackInSlot.getMaxStackSize(); - int missing = maxSize - stackInSlot.stackSize; - if (inv.isItemValidForSlot(slot, stackInSlot) - && (!(inv instanceof ISidedInventory) - || ((ISidedInventory) inv).canInsertItem(slot, stackInSlot, par7))) { - stackInSlot.stackSize += remove(par1ItemStack, missing); - inv.markDirty(); - set = true; - } - } - } - } else { - ForgeDirection dir = ForgeDirection.getOrientation(par7); - int entities = par3World - .getEntitiesWithinAABB( - EntityLivingBase.class, - AxisAlignedBB.getBoundingBox( - par4 + dir.offsetX, - par5 + dir.offsetY, - par6 + dir.offsetZ, - par4 + dir.offsetX + 1, - par5 + dir.offsetY + 1, - par6 + dir.offsetZ + 1)) - .size(); - - if (entities == 0) { - int remove = par2EntityPlayer.capabilities.isCreativeMode ? 1 : remove(par1ItemStack, 1); - if (remove > 0) { - ItemStack stack = new ItemStack(bBlock, 1, bmeta); - ItemsRemainingRenderHandler.set(stack, getBlockCount(par1ItemStack)); - - Item.getItemFromBlock(bBlock) - .onItemUse( - stack, par2EntityPlayer, par3World, par4, par5, par6, par7, par8, par9, par10); - set = true; - } - } - } - } - - par2EntityPlayer.setCurrentItemOrArmor(0, par1ItemStack); - return set; - } - - @Override - public void onUpdate(ItemStack itemstack, World p_77663_2_, Entity entity, int p_77663_4_, boolean p_77663_5_) { - Block block = getBlock(itemstack); - if (!entity.worldObj.isRemote - && itemstack.getItemDamage() == 1 - && block != Blocks.air - && entity instanceof EntityPlayer) { - EntityPlayer player = (EntityPlayer) entity; - int meta = getBlockMeta(itemstack); - - int highest = -1; - int[] counts = new int[player.inventory.getSizeInventory() - player.inventory.armorInventory.length]; - Arrays.fill(counts, 0); - - for (int i = 0; i < counts.length; i++) { - ItemStack stack = player.inventory.getStackInSlot(i); - if (stack == null) { - continue; - } - - if (Item.getItemFromBlock(block) == stack.getItem() && stack.getItemDamage() == meta) { - counts[i] = stack.stackSize; - if (highest == -1) highest = i; - else highest = counts[i] > counts[highest] && highest > 8 ? i : highest; - } - } - - if (highest == -1) { - /*ItemStack heldItem = player.inventory.getItemStack(); - if(hasFreeSlot && (heldItem == null || Item.getItemFromBlock(block) == heldItem.getItem() || heldItem.getItemDamage() != meta)) { - ItemStack stack = new ItemStack(block, remove(itemstack, 64), meta); - if(stack.stackSize != 0) - player.inventory.addItemStackToInventory(stack); - }*/ - // Used to keep one stack, disabled for now - } else { - for (int i = 0; i < counts.length; i++) { - int count = counts[i]; - - // highest is used to keep one stack, disabled for now - if (/*i == highest || */ count == 0) continue; - - add(itemstack, count); - player.inventory.setInventorySlotContents(i, null); - } - - /*int countInHighest = counts[highest]; - int maxSize = new ItemStack(block, 1, meta).getMaxStackSize(); - if(countInHighest < maxSize) { - int missing = maxSize - countInHighest; - ItemStack stackInHighest = player.inventory.getStackInSlot(highest); - stackInHighest.stackSize += remove(itemstack, missing); - }*/ - // Used to keep one stack, disabled for now - } - } - } - - @Override - public String getItemStackDisplayName(ItemStack par1ItemStack) { - Block block = getBlock(par1ItemStack); - int meta = getBlockMeta(par1ItemStack); - ItemStack stack = new ItemStack(block, 1, meta); - - return super.getItemStackDisplayName(par1ItemStack) - + (stack == null || stack.getItem() == null - ? "" - : " (" + EnumChatFormatting.GREEN + stack.getDisplayName() + EnumChatFormatting.RESET + ")"); - } - - @Override - public ItemStack getContainerItem(ItemStack itemStack) { - int count = getBlockCount(itemStack); - if (count == 0) return null; - - int extract = Math.min(64, count); - ItemStack copy = itemStack.copy(); - remove(copy, extract); - - int dmg = copy.getItemDamage(); - if (dmg == 1) copy.setItemDamage(0); - - return copy; - } - - @Override - public boolean hasContainerItem(ItemStack stack) { - return getContainerItem(stack) != null; - } - - @Override - public boolean doesContainerItemLeaveCraftingGrid(ItemStack p_77630_1_) { - return false; - } - - private boolean setBlock(ItemStack stack, Block block, int meta) { - if (getBlock(stack) == Blocks.air || getBlockCount(stack) == 0) { - ItemNBTHelper.setString(stack, TAG_BLOCK_NAME, Block.blockRegistry.getNameForObject(block)); - ItemNBTHelper.setInt(stack, TAG_BLOCK_META, meta); - return true; - } - return false; - } - - private void add(ItemStack stack, int count) { - int current = getBlockCount(stack); - setCount(stack, current + count); - } - - @Override - @SideOnly(Side.CLIENT) - public void registerIcons(IIconRegister par1IconRegister) { - itemIcon = IconHelper.forItem(par1IconRegister, this, 0); - enabledIcon = IconHelper.forItem(par1IconRegister, this, 1); - } - - @Override - @SideOnly(Side.CLIENT) - public IIcon getIconFromDamage(int par1) { - return par1 == 1 ? enabledIcon : itemIcon; - } - - @Override - @SideOnly(Side.CLIENT) - public void addInformation(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, List par3List, boolean par4) { - Block block = getBlock(par1ItemStack); - if (block != null && block != Blocks.air) { - int count = getBlockCount(par1ItemStack); - par3List.add(count + " " - + StatCollector.translateToLocal( - new ItemStack(block, 1, getBlockMeta(par1ItemStack)).getUnlocalizedName() + ".name")); - } - - if (par1ItemStack.getItemDamage() == 1) - addStringToTooltip(StatCollector.translateToLocal("botaniamisc.active"), par3List); - else addStringToTooltip(StatCollector.translateToLocal("botaniamisc.inactive"), par3List); - } - - void addStringToTooltip(String s, List tooltip) { - tooltip.add(s.replaceAll("&", "\u00a7")); - } - - private static void setCount(ItemStack stack, int count) { - ItemNBTHelper.setInt(stack, TAG_BLOCK_COUNT, count); - } - - public static int remove(ItemStack stack, int count) { - int current = getBlockCount(stack); - setCount(stack, Math.max(current - count, 0)); - - return Math.min(current, count); - } - - public static String getBlockName(ItemStack stack) { - return ItemNBTHelper.getString(stack, TAG_BLOCK_NAME, ""); - } - - public static Block getBlock(ItemStack stack) { - Block block = Block.getBlockFromName(getBlockName(stack)); - return block; - } - - public static int getBlockMeta(ItemStack stack) { - return ItemNBTHelper.getInt(stack, TAG_BLOCK_META, 0); - } - - public static int getBlockCount(ItemStack stack) { - return ItemNBTHelper.getInt(stack, TAG_BLOCK_COUNT, 0); - } - - @Override - public boolean provideBlock( - EntityPlayer player, ItemStack requestor, ItemStack stack, Block block, int meta, boolean doit) { - Block stored = getBlock(stack); - int storedMeta = getBlockMeta(stack); - if (stored == block && storedMeta == meta) { - int count = getBlockCount(stack); - if (count > 0) { - if (doit) setCount(stack, count - 1); - return true; - } - } - - return false; - } - - @Override - public int getBlockCount(EntityPlayer player, ItemStack requestor, ItemStack stack, Block block, int meta) { - Block stored = getBlock(stack); - int storedMeta = getBlockMeta(stack); - if (stored == block && storedMeta == meta) return getBlockCount(stack); - return 0; - } + private static final String TAG_BLOCK_NAME = "blockName"; + private static final String TAG_BLOCK_META = "blockMeta"; + private static final String TAG_BLOCK_COUNT = "blockCount"; + + IIcon enabledIcon; + + public ItemBlackHoleTalisman() { + setUnlocalizedName(LibItemNames.BLACK_HOLE_TALISMAN); + setMaxStackSize(1); + setHasSubtypes(true); + + GameRegistry.addRecipe(new BlackHoleTalismanExtractRecipe()); + RecipeSorter.register("botania:blackHoleTalismanExtract", BlackHoleTalismanExtractRecipe.class, Category.SHAPELESS, ""); + } + + @Override + public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer) { + if(getBlock(par1ItemStack) != Blocks.air && par3EntityPlayer.isSneaking()) { + int dmg = par1ItemStack.getItemDamage(); + par1ItemStack.setItemDamage(~dmg & 1); + par2World.playSoundAtEntity(par3EntityPlayer, "random.orb", 0.3F, 0.1F); + } + + return par1ItemStack; + } + + @Override + public boolean onItemUse(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, World par3World, int par4, int par5, int par6, int par7, float par8, float par9, float par10) { + Block block = par3World.getBlock(par4, par5, par6); + int meta = par3World.getBlockMetadata(par4, par5, par6); + boolean set = setBlock(par1ItemStack, block, meta); + + if(!set) { + Block bBlock = getBlock(par1ItemStack); + int bmeta = getBlockMeta(par1ItemStack); + + TileEntity tile = par3World.getTileEntity(par4, par5, par6); + if(tile != null && tile instanceof IInventory) { + IInventory inv = (IInventory) tile; + int[] slots = inv instanceof ISidedInventory ? ((ISidedInventory) inv).getAccessibleSlotsFromSide(par7) : InventoryHelper.buildSlotsForLinearInventory(inv); + for(int slot : slots) { + ItemStack stackInSlot = inv.getStackInSlot(slot); + if(stackInSlot == null) { + ItemStack stack = new ItemStack(bBlock, 1, bmeta); + int maxSize = stack.getMaxStackSize(); + stack.stackSize = remove(par1ItemStack, maxSize); + if(stack.stackSize != 0) { + if(inv.isItemValidForSlot(slot, stack) && (!(inv instanceof ISidedInventory) || ((ISidedInventory) inv).canInsertItem(slot, stack, par7))) { + inv.setInventorySlotContents(slot, stack); + inv.markDirty(); + set = true; + } + } + } else if(stackInSlot.getItem() == Item.getItemFromBlock(bBlock) && stackInSlot.getItemDamage() == bmeta) { + int maxSize = stackInSlot.getMaxStackSize(); + int missing = maxSize - stackInSlot.stackSize; + if(inv.isItemValidForSlot(slot, stackInSlot) && (!(inv instanceof ISidedInventory) || ((ISidedInventory) inv).canInsertItem(slot, stackInSlot, par7))) { + stackInSlot.stackSize += remove(par1ItemStack, missing); + inv.markDirty(); + set = true; + } + } + } + } else { + ForgeDirection dir = ForgeDirection.getOrientation(par7); + int entities = par3World.getEntitiesWithinAABB(EntityLivingBase.class, AxisAlignedBB.getBoundingBox(par4 + dir.offsetX, par5 + dir.offsetY, par6 + dir.offsetZ, par4 + dir.offsetX + 1, par5 + dir.offsetY + 1, par6 + dir.offsetZ + 1)).size(); + + if(entities == 0) { + int remove = par2EntityPlayer.capabilities.isCreativeMode ? 1 : remove(par1ItemStack, 1); + if(remove > 0) { + ItemStack stack = new ItemStack(bBlock, 1, bmeta); + ItemsRemainingRenderHandler.set(stack, getBlockCount(par1ItemStack)); + + Item.getItemFromBlock(bBlock).onItemUse(stack, par2EntityPlayer, par3World, par4, par5, par6, par7, par8, par9, par10); + set = true; + } + } + } + } + + par2EntityPlayer.setCurrentItemOrArmor(0, par1ItemStack); + return set; + } + + @Override + public void onUpdate(ItemStack itemstack, World p_77663_2_, Entity entity, int p_77663_4_, boolean p_77663_5_) { + Block block = getBlock(itemstack); + if(!entity.worldObj.isRemote && itemstack.getItemDamage() == 1 && block != Blocks.air && entity instanceof EntityPlayer) { + EntityPlayer player = (EntityPlayer) entity; + int meta = getBlockMeta(itemstack); + + int highest = -1; + int[] counts = new int[player.inventory.getSizeInventory() - player.inventory.armorInventory.length]; + Arrays.fill(counts, 0); + + for(int i = 0; i < counts.length; i++) { + ItemStack stack = player.inventory.getStackInSlot(i); + if(stack == null) { + continue; + } + + if(Item.getItemFromBlock(block) == stack.getItem() && stack.getItemDamage() == meta) { + counts[i] = stack.stackSize; + if(highest == -1) + highest = i; + else highest = counts[i] > counts[highest] && highest > 8 ? i : highest; + } + } + + if(highest == -1) { + /*ItemStack heldItem = player.inventory.getItemStack(); + if(hasFreeSlot && (heldItem == null || Item.getItemFromBlock(block) == heldItem.getItem() || heldItem.getItemDamage() != meta)) { + ItemStack stack = new ItemStack(block, remove(itemstack, 64), meta); + if(stack.stackSize != 0) + player.inventory.addItemStackToInventory(stack); + }*/ + // Used to keep one stack, disabled for now + } else { + for(int i = 0; i < counts.length; i++) { + int count = counts[i]; + + // highest is used to keep one stack, disabled for now + if(/*i == highest || */count == 0) + continue; + + add(itemstack, count); + player.inventory.setInventorySlotContents(i, null); + } + + /*int countInHighest = counts[highest]; + int maxSize = new ItemStack(block, 1, meta).getMaxStackSize(); + if(countInHighest < maxSize) { + int missing = maxSize - countInHighest; + ItemStack stackInHighest = player.inventory.getStackInSlot(highest); + stackInHighest.stackSize += remove(itemstack, missing); + }*/ + // Used to keep one stack, disabled for now + } + } + } + + @Override + public String getItemStackDisplayName(ItemStack par1ItemStack) { + Block block = getBlock(par1ItemStack); + int meta = getBlockMeta(par1ItemStack); + ItemStack stack = new ItemStack(block, 1, meta); + + return super.getItemStackDisplayName(par1ItemStack) + (stack == null || stack.getItem() == null ? "" : " (" + EnumChatFormatting.GREEN + stack.getDisplayName() + EnumChatFormatting.RESET + ")"); + } + + @Override + public ItemStack getContainerItem(ItemStack itemStack) { + int count = getBlockCount(itemStack); + if(count == 0) + return null; + + int extract = Math.min(64, count); + ItemStack copy = itemStack.copy(); + remove(copy, extract); + + int dmg = copy.getItemDamage(); + if(dmg == 1) + copy.setItemDamage(0); + + return copy; + } + + @Override + public boolean hasContainerItem(ItemStack stack) { + return getContainerItem(stack) != null; + } + + @Override + public boolean doesContainerItemLeaveCraftingGrid(ItemStack p_77630_1_) { + return false; + } + + private boolean setBlock(ItemStack stack, Block block, int meta) { + if(getBlock(stack) == Blocks.air || getBlockCount(stack) == 0) { + ItemNBTHelper.setString(stack, TAG_BLOCK_NAME, Block.blockRegistry.getNameForObject(block)); + ItemNBTHelper.setInt(stack, TAG_BLOCK_META, meta); + return true; + } + return false; + } + + private void add(ItemStack stack, int count) { + int current = getBlockCount(stack); + setCount(stack, current + count); + } + + @Override + @SideOnly(Side.CLIENT) + public void registerIcons(IIconRegister par1IconRegister) { + itemIcon = IconHelper.forItem(par1IconRegister, this, 0); + enabledIcon = IconHelper.forItem(par1IconRegister, this, 1); + } + + @Override + @SideOnly(Side.CLIENT) + public IIcon getIconFromDamage(int par1) { + return par1 == 1 ? enabledIcon : itemIcon; + } + + @Override + @SideOnly(Side.CLIENT) + public void addInformation(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, List par3List, boolean par4) { + Block block = getBlock(par1ItemStack); + if(block != null && block != Blocks.air) { + int count = getBlockCount(par1ItemStack); + par3List.add(count + " " + StatCollector.translateToLocal(new ItemStack(block, 1, getBlockMeta(par1ItemStack)).getUnlocalizedName() + ".name")); + } + + if(par1ItemStack.getItemDamage() == 1) + addStringToTooltip(StatCollector.translateToLocal("botaniamisc.active"), par3List); + else addStringToTooltip(StatCollector.translateToLocal("botaniamisc.inactive"), par3List); + } + + void addStringToTooltip(String s, List tooltip) { + tooltip.add(s.replaceAll("&", "\u00a7")); + } + + private static void setCount(ItemStack stack, int count) { + ItemNBTHelper.setInt(stack, TAG_BLOCK_COUNT, count); + } + + public static int remove(ItemStack stack, int count) { + int current = getBlockCount(stack); + setCount(stack, Math.max(current - count, 0)); + + return Math.min(current, count); + } + + public static String getBlockName(ItemStack stack) { + return ItemNBTHelper.getString(stack, TAG_BLOCK_NAME, ""); + } + + public static Block getBlock(ItemStack stack) { + Block block = Block.getBlockFromName(getBlockName(stack)); + return block; + } + + public static int getBlockMeta(ItemStack stack) { + return ItemNBTHelper.getInt(stack, TAG_BLOCK_META, 0); + } + + public static int getBlockCount(ItemStack stack) { + return ItemNBTHelper.getInt(stack, TAG_BLOCK_COUNT, 0); + } + + @Override + public boolean provideBlock(EntityPlayer player, ItemStack requestor, ItemStack stack, Block block, int meta, boolean doit) { + Block stored = getBlock(stack); + int storedMeta = getBlockMeta(stack); + if(stored == block && storedMeta == meta) { + int count = getBlockCount(stack); + if(count > 0) { + if(doit) + setCount(stack, count - 1); + return true; + } + } + + return false; + } + + @Override + public int getBlockCount(EntityPlayer player, ItemStack requestor, ItemStack stack, Block block, int meta) { + Block stored = getBlock(stack); + int storedMeta = getBlockMeta(stack); + if(stored == block && storedMeta == meta) + return getBlockCount(stack); + return 0; + } + } diff --git a/src/main/java/vazkii/botania/common/item/ItemBlackLotus.java b/src/main/java/vazkii/botania/common/item/ItemBlackLotus.java index fcebed6c3f..69002fd3dd 100644 --- a/src/main/java/vazkii/botania/common/item/ItemBlackLotus.java +++ b/src/main/java/vazkii/botania/common/item/ItemBlackLotus.java @@ -2,15 +2,16 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jan 18, 2015, 12:17:10 AM (GMT)] */ package vazkii.botania.common.item; import java.util.List; + import net.minecraft.creativetab.CreativeTabs; import net.minecraft.entity.item.EntityItem; import net.minecraft.entity.player.EntityPlayer; @@ -26,60 +27,63 @@ public class ItemBlackLotus extends ItemMod implements IManaDissolvable { - private static final int MANA_PER = 8000; - private static final int MANA_PER_T2 = 100000; - - public ItemBlackLotus() { - setUnlocalizedName(LibItemNames.BLACK_LOTUS); - setHasSubtypes(true); - } - - @Override - public void getSubItems(Item item, CreativeTabs tab, List list) { - for (int i = 0; i < 2; i++) list.add(new ItemStack(item, 1, i)); - } - - @Override - public boolean hasEffect(ItemStack par1ItemStack, int pass) { - return par1ItemStack.getItemDamage() > 0; - } - - @Override - public String getUnlocalizedName(ItemStack par1ItemStack) { - return super.getUnlocalizedName(par1ItemStack) + par1ItemStack.getItemDamage(); - } - - @Override - public void onDissolveTick(IManaPool pool, ItemStack stack, EntityItem item) { - if (pool.isFull() || pool.getCurrentMana() == 0) return; - - TileEntity tile = (TileEntity) pool; - boolean t2 = stack.getItemDamage() > 0; - - if (!item.worldObj.isRemote) { - pool.recieveMana(t2 ? MANA_PER_T2 : MANA_PER); - stack.stackSize--; - VanillaPacketDispatcher.dispatchTEToNearbyPlayers(item.worldObj, tile.xCoord, tile.yCoord, tile.zCoord); - } - - for (int i = 0; i < 50; i++) { - float r = (float) Math.random() * 0.25F; - float g = 0F; - float b = (float) Math.random() * 0.25F; - float s = 0.45F * (float) Math.random() * 0.25F; - - float m = 0.045F; - float mx = ((float) Math.random() - 0.5F) * m; - float my = (float) Math.random() * m; - float mz = ((float) Math.random() - 0.5F) * m; - - Botania.proxy.wispFX(item.worldObj, item.posX, tile.yCoord + 0.5F, item.posZ, r, g, b, s, mx, my, mz); - } - item.worldObj.playSoundAtEntity(item, "botania:blackLotus", 0.5F, t2 ? 0.1F : 1F); - } - - @Override - public void addInformation(ItemStack stack, EntityPlayer player, List list, boolean adv) { - list.add(StatCollector.translateToLocal("botaniamisc.lotusDesc")); - } + private static final int MANA_PER = 8000; + private static final int MANA_PER_T2 = 100000; + + public ItemBlackLotus() { + setUnlocalizedName(LibItemNames.BLACK_LOTUS); + setHasSubtypes(true); + } + + @Override + public void getSubItems(Item item, CreativeTabs tab, List list) { + for(int i = 0; i < 2; i++) + list.add(new ItemStack(item, 1, i)); + } + + @Override + public boolean hasEffect(ItemStack par1ItemStack, int pass) { + return par1ItemStack.getItemDamage() > 0; + } + + @Override + public String getUnlocalizedName(ItemStack par1ItemStack) { + return super.getUnlocalizedName(par1ItemStack) + par1ItemStack.getItemDamage(); + } + + @Override + public void onDissolveTick(IManaPool pool, ItemStack stack, EntityItem item) { + if(pool.isFull() || pool.getCurrentMana() == 0) + return; + + TileEntity tile = (TileEntity) pool; + boolean t2 = stack.getItemDamage() > 0; + + if(!item.worldObj.isRemote) { + pool.recieveMana(t2 ? MANA_PER_T2 : MANA_PER); + stack.stackSize--; + VanillaPacketDispatcher.dispatchTEToNearbyPlayers(item.worldObj, tile.xCoord, tile.yCoord, tile.zCoord); + } + + for(int i = 0; i < 50; i++) { + float r = (float) Math.random() * 0.25F; + float g = 0F; + float b = (float) Math.random() * 0.25F; + float s = 0.45F * (float) Math.random() * 0.25F; + + float m = 0.045F; + float mx = ((float) Math.random() - 0.5F) * m; + float my = (float) Math.random() * m; + float mz = ((float) Math.random() - 0.5F) * m; + + Botania.proxy.wispFX(item.worldObj, item.posX, tile.yCoord + 0.5F, item.posZ, r, g, b, s, mx, my, mz); + } + item.worldObj.playSoundAtEntity(item, "botania:blackLotus", 0.5F, t2 ? 0.1F : 1F); + } + + @Override + public void addInformation(ItemStack stack, EntityPlayer player, List list, boolean adv) { + list.add(StatCollector.translateToLocal("botaniamisc.lotusDesc")); + } + } diff --git a/src/main/java/vazkii/botania/common/item/ItemBottledMana.java b/src/main/java/vazkii/botania/common/item/ItemBottledMana.java index d82f9e7310..a2bec1876a 100644 --- a/src/main/java/vazkii/botania/common/item/ItemBottledMana.java +++ b/src/main/java/vazkii/botania/common/item/ItemBottledMana.java @@ -2,16 +2,17 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jun 27, 2014, 2:41:19 AM (GMT)] */ package vazkii.botania.common.item; import java.util.List; import java.util.Random; + import net.minecraft.block.Block; import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.entity.Entity; @@ -39,223 +40,211 @@ public class ItemBottledMana extends ItemMod { - IIcon[] icons; - private static final String TAG_SEED = "randomSeed"; - - public ItemBottledMana() { - setUnlocalizedName(LibItemNames.MANA_BOTTLE); - setMaxStackSize(1); - setMaxDamage(6); - } - - public void effect(EntityPlayer player, int id) { - switch (id) { - case 0: { // Random motion - player.motionX = (Math.random() - 0.5) * 3; - player.motionZ = (Math.random() - 0.5) * 3; - break; - } - case 1: { // Water - if (!player.worldObj.isRemote && !player.worldObj.provider.isHellWorld) - player.worldObj.setBlock( - MathHelper.floor_double(player.posX), - MathHelper.floor_double(player.posY), - MathHelper.floor_double(player.posZ), - Blocks.flowing_water); - break; - } - case 2: { // Set on Fire - if (!player.worldObj.isRemote) player.setFire(4); - break; - } - case 3: { // Mini Explosion - if (!player.worldObj.isRemote) - player.worldObj.createExplosion(null, player.posX, player.posY, player.posZ, 0.25F, false); - break; - } - case 4: { // Mega Jump - if (!player.worldObj.provider.isHellWorld) { - if (!player.worldObj.isRemote) - player.addPotionEffect(new PotionEffect(Potion.resistance.id, 300, 5)); - player.motionY = 6; - } - - break; - } - case 5: { // Randomly set HP - if (!player.worldObj.isRemote) player.setHealth(player.worldObj.rand.nextInt(19) + 1); - break; - } - case 6: { // Lots O' Hearts - if (!player.worldObj.isRemote) - player.addPotionEffect(new PotionEffect(Potion.field_76444_x.id, 20 * 60 * 2, 9)); - break; - } - case 7: { // All your inventory is belong to us - if (!player.worldObj.isRemote) - for (int i = 0; i < player.inventory.getSizeInventory(); i++) - if (i != player.inventory.currentItem) { - ItemStack stackAt = player.inventory.getStackInSlot(i); - if (stackAt != null) player.dropPlayerItemWithRandomChoice(stackAt, true); - player.inventory.setInventorySlotContents(i, null); - } - - break; - } - case 8: { // Break your neck - player.rotationPitch = (float) Math.random() * 360F; - player.rotationYaw = (float) Math.random() * 180F; - - break; - } - case 9: { // Highest Possible - int x = MathHelper.floor_double(player.posX); - MathHelper.floor_double(player.posY); - int z = MathHelper.floor_double(player.posZ); - for (int i = 256; i > 0; i--) { - Block block = player.worldObj.getBlock(x, i, z); - if (!block.isAir(player.worldObj, x, i, z)) { - if (player instanceof EntityPlayerMP) { - EntityPlayerMP mp = (EntityPlayerMP) player; - mp.playerNetServerHandler.setPlayerLocation( - player.posX, i + 1.6, player.posZ, player.rotationYaw, player.rotationPitch); - } - break; - } - } - - break; - } - case 10: { // HYPERSPEEEEEED - if (!player.worldObj.isRemote) player.addPotionEffect(new PotionEffect(Potion.moveSpeed.id, 60, 200)); - break; - } - case 11: { // Night Vision - if (!player.worldObj.isRemote) player.addPotionEffect(new PotionEffect(Potion.nightVision.id, 6000, 0)); - break; - } - case 12: { // Flare - if (!player.worldObj.isRemote) { - EntitySignalFlare flare = new EntitySignalFlare(player.worldObj); - flare.setPosition(player.posX, player.posY, player.posZ); - flare.setColor(player.worldObj.rand.nextInt(16)); - player.worldObj.playSoundAtEntity( - player, - "random.explode", - 40F, - (1.0F + (player.worldObj.rand.nextFloat() - player.worldObj.rand.nextFloat()) * 0.2F) - * 0.7F); - - player.worldObj.spawnEntityInWorld(flare); - - int range = 5; - List entities = player.worldObj.getEntitiesWithinAABB( - EntityLivingBase.class, - AxisAlignedBB.getBoundingBox( - player.posX - range, - player.posY - range, - player.posZ - range, - player.posX + range, - player.posY + range, - player.posZ + range)); - for (EntityLivingBase entity : entities) - if (entity != player - && (!(entity instanceof EntityPlayer) - || MinecraftServer.getServer() == null - || MinecraftServer.getServer().isPVPEnabled())) - entity.addPotionEffect(new PotionEffect(Potion.moveSlowdown.id, 50, 5)); - } - - break; - } - case 13: { // Pixie Friend - if (!player.worldObj.isRemote) { - EntityPixie pixie = new EntityPixie(player.worldObj); - pixie.setPosition(player.posX, player.posY + 1.5, player.posZ); - player.worldObj.spawnEntityInWorld(pixie); - } - break; - } - case 14: { // Nausea + Blindness :3 - if (!player.worldObj.isRemote) { - player.addPotionEffect(new PotionEffect(Potion.confusion.id, 160, 3)); - player.addPotionEffect(new PotionEffect(Potion.blindness.id, 160, 0)); - } - - break; - } - case 15: { // Drop own Head - if (!player.worldObj.isRemote) { - player.attackEntityFrom(DamageSource.magic, player.getHealth() - 1); - ItemStack stack = new ItemStack(Items.skull, 1, 3); - ItemNBTHelper.setString(stack, "SkullOwner", player.getCommandSenderName()); - player.dropPlayerItemWithRandomChoice(stack, true); - } - break; - } - } - } - - @Override - public void onUpdate(ItemStack par1ItemStack, World par2World, Entity par3Entity, int par4, boolean par5) { - getSeed(par1ItemStack); - } - - public void randomEffect(EntityPlayer player, ItemStack stack) { - effect(player, new Random(getSeed(stack)).nextInt(16)); - } - - long getSeed(ItemStack stack) { - long seed = ItemNBTHelper.getLong(stack, TAG_SEED, -1); - if (seed == -1) return randomSeed(stack); - return seed; - } - - long randomSeed(ItemStack stack) { - long seed = Math.abs(itemRand.nextLong()); - ItemNBTHelper.setLong(stack, TAG_SEED, seed); - return seed; - } - - @Override - public void addInformation(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, List par3List, boolean par4) { - par3List.add(StatCollector.translateToLocal("botaniamisc.bottleTooltip")); - } - - @Override - public void registerIcons(IIconRegister par1IconRegister) { - icons = new IIcon[6]; - for (int i = 0; i < icons.length; i++) icons[i] = IconHelper.forItem(par1IconRegister, this, i); - } - - @Override - public IIcon getIconFromDamage(int par1) { - return icons[Math.min(icons.length - 1, par1)]; - } - - @Override - public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer) { - par3EntityPlayer.setItemInUse(par1ItemStack, getMaxItemUseDuration(par1ItemStack)); - return par1ItemStack; - } - - @Override - public ItemStack onEaten(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer) { - randomEffect(par3EntityPlayer, par1ItemStack); - par1ItemStack.setItemDamage(par1ItemStack.getItemDamage() + 1); - randomSeed(par1ItemStack); - - if (par1ItemStack.getItemDamage() == 6) return new ItemStack(Items.glass_bottle); - return par1ItemStack; - } - - @Override - public int getMaxItemUseDuration(ItemStack par1ItemStack) { - return 20; - } + IIcon[] icons; + private static final String TAG_SEED = "randomSeed"; + + public ItemBottledMana() { + setUnlocalizedName(LibItemNames.MANA_BOTTLE); + setMaxStackSize(1); + setMaxDamage(6); + } + + public void effect(EntityPlayer player, int id) { + switch(id) { + case 0 : { // Random motion + player.motionX = (Math.random() - 0.5) * 3; + player.motionZ = (Math.random() - 0.5) * 3; + break; + } + case 1 : { // Water + if(!player.worldObj.isRemote && !player.worldObj.provider.isHellWorld) + player.worldObj.setBlock(MathHelper.floor_double(player.posX), MathHelper.floor_double(player.posY), MathHelper.floor_double(player.posZ), Blocks.flowing_water); + break; + } + case 2 : { // Set on Fire + if(!player.worldObj.isRemote) + player.setFire(4); + break; + } + case 3 : { // Mini Explosion + if(!player.worldObj.isRemote) + player.worldObj.createExplosion(null, player.posX, player.posY, player.posZ, 0.25F, false); + break; + } + case 4 : { // Mega Jump + if(!player.worldObj.provider.isHellWorld) { + if(!player.worldObj.isRemote) + player.addPotionEffect(new PotionEffect(Potion.resistance.id, 300, 5)); + player.motionY = 6; + } + + break; + } + case 5 : { // Randomly set HP + if(!player.worldObj.isRemote) + player.setHealth(player.worldObj.rand.nextInt(19) + 1); + break; + } + case 6 : { // Lots O' Hearts + if(!player.worldObj.isRemote) + player.addPotionEffect(new PotionEffect(Potion.field_76444_x.id, 20 * 60 * 2, 9)); + break; + } + case 7 : { // All your inventory is belong to us + if(!player.worldObj.isRemote) + for(int i = 0; i < player.inventory.getSizeInventory(); i++) + if(i != player.inventory.currentItem) { + ItemStack stackAt = player.inventory.getStackInSlot(i); + if(stackAt != null) + player.dropPlayerItemWithRandomChoice(stackAt, true); + player.inventory.setInventorySlotContents(i, null); + } + + break; + } + case 8 : { // Break your neck + player.rotationPitch = (float) Math.random() * 360F; + player.rotationYaw = (float) Math.random() * 180F; + + break; + } + case 9 : { // Highest Possible + int x = MathHelper.floor_double(player.posX); + MathHelper.floor_double(player.posY); + int z = MathHelper.floor_double(player.posZ); + for(int i = 256; i > 0; i--) { + Block block = player.worldObj.getBlock(x, i, z); + if(!block.isAir(player.worldObj, x, i, z)) { + if(player instanceof EntityPlayerMP) { + EntityPlayerMP mp = (EntityPlayerMP) player; + mp.playerNetServerHandler.setPlayerLocation(player.posX, i + 1.6, player.posZ, player.rotationYaw, player.rotationPitch); + } + break; + } + } + + break; + } + case 10 : { // HYPERSPEEEEEED + if(!player.worldObj.isRemote) + player.addPotionEffect(new PotionEffect(Potion.moveSpeed.id, 60, 200)); + break; + } + case 11 : { // Night Vision + if(!player.worldObj.isRemote) + player.addPotionEffect(new PotionEffect(Potion.nightVision.id, 6000, 0)); + break; + } + case 12 : { // Flare + if(!player.worldObj.isRemote) { + EntitySignalFlare flare = new EntitySignalFlare(player.worldObj); + flare.setPosition(player.posX, player.posY, player.posZ); + flare.setColor(player.worldObj.rand.nextInt(16)); + player.worldObj.playSoundAtEntity(player, "random.explode", 40F, (1.0F + (player.worldObj.rand.nextFloat() - player.worldObj.rand.nextFloat()) * 0.2F) * 0.7F); + + player.worldObj.spawnEntityInWorld(flare); + + int range = 5; + List entities = player.worldObj.getEntitiesWithinAABB(EntityLivingBase.class, AxisAlignedBB.getBoundingBox(player.posX - range, player.posY - range, player.posZ - range, player.posX + range, player.posY + range, player.posZ + range)); + for(EntityLivingBase entity : entities) + if(entity != player && (!(entity instanceof EntityPlayer) || MinecraftServer.getServer() == null || MinecraftServer.getServer().isPVPEnabled())) + entity.addPotionEffect(new PotionEffect(Potion.moveSlowdown.id, 50, 5)); + } + + break; + } + case 13 : { // Pixie Friend + if(!player.worldObj.isRemote) { + EntityPixie pixie = new EntityPixie(player.worldObj); + pixie.setPosition(player.posX, player.posY + 1.5, player.posZ); + player.worldObj.spawnEntityInWorld(pixie); + } + break; + } + case 14 : { // Nausea + Blindness :3 + if(!player.worldObj.isRemote) { + player.addPotionEffect(new PotionEffect(Potion.confusion.id, 160, 3)); + player.addPotionEffect(new PotionEffect(Potion.blindness.id, 160, 0)); + } + + break; + } + case 15 : { // Drop own Head + if(!player.worldObj.isRemote) { + player.attackEntityFrom(DamageSource.magic, player.getHealth() - 1); + ItemStack stack = new ItemStack(Items.skull, 1, 3); + ItemNBTHelper.setString(stack, "SkullOwner", player.getCommandSenderName()); + player.dropPlayerItemWithRandomChoice(stack, true); + } + break; + } + } + } + + @Override + public void onUpdate(ItemStack par1ItemStack, World par2World, Entity par3Entity, int par4, boolean par5) { + getSeed(par1ItemStack); + } + + public void randomEffect(EntityPlayer player, ItemStack stack) { + effect(player, new Random(getSeed(stack)).nextInt(16)); + } + + long getSeed(ItemStack stack) { + long seed = ItemNBTHelper.getLong(stack, TAG_SEED, -1); + if(seed == -1) + return randomSeed(stack); + return seed; + } + + long randomSeed(ItemStack stack) { + long seed = Math.abs(itemRand.nextLong()); + ItemNBTHelper.setLong(stack, TAG_SEED, seed); + return seed; + } + + @Override + public void addInformation(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, List par3List, boolean par4) { + par3List.add(StatCollector.translateToLocal("botaniamisc.bottleTooltip")); + } + + @Override + public void registerIcons(IIconRegister par1IconRegister) { + icons = new IIcon[6]; + for(int i = 0; i < icons.length; i++) + icons[i] = IconHelper.forItem(par1IconRegister, this, i); + } + + @Override + public IIcon getIconFromDamage(int par1) { + return icons[Math.min(icons.length - 1, par1)]; + } + + @Override + public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer) { + par3EntityPlayer.setItemInUse(par1ItemStack, getMaxItemUseDuration(par1ItemStack)); + return par1ItemStack; + } + + @Override + public ItemStack onEaten(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer) { + randomEffect(par3EntityPlayer, par1ItemStack); + par1ItemStack.setItemDamage(par1ItemStack.getItemDamage() + 1); + randomSeed(par1ItemStack); + + if(par1ItemStack.getItemDamage() == 6) + return new ItemStack(Items.glass_bottle); + return par1ItemStack; + } + + @Override + public int getMaxItemUseDuration(ItemStack par1ItemStack) { + return 20; + } + + @Override + public EnumAction getItemUseAction(ItemStack par1ItemStack) { + return EnumAction.drink; + } - @Override - public EnumAction getItemUseAction(ItemStack par1ItemStack) { - return EnumAction.drink; - } } diff --git a/src/main/java/vazkii/botania/common/item/ItemCacophonium.java b/src/main/java/vazkii/botania/common/item/ItemCacophonium.java index b509825ed1..e5c52b05e2 100644 --- a/src/main/java/vazkii/botania/common/item/ItemCacophonium.java +++ b/src/main/java/vazkii/botania/common/item/ItemCacophonium.java @@ -2,16 +2,16 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jul 20, 2015, 9:53:57 PM (GMT)] */ package vazkii.botania.common.item; -import cpw.mods.fml.relauncher.ReflectionHelper; import java.util.List; + import net.minecraft.block.Block; import net.minecraft.entity.EntityList; import net.minecraft.entity.EntityLiving; @@ -33,138 +33,127 @@ import vazkii.botania.common.core.helper.ItemNBTHelper; import vazkii.botania.common.lib.LibItemNames; import vazkii.botania.common.lib.LibObfuscation; +import cpw.mods.fml.relauncher.ReflectionHelper; public class ItemCacophonium extends ItemMod implements ICraftAchievement { - private static final String TAG_SOUND = "sound"; - private static final String TAG_SOUND_NAME = "soundName"; - private static final String TAG_HAS_SOUND = "hasSound"; - - public ItemCacophonium() { - setMaxStackSize(1); - setUnlocalizedName(LibItemNames.CACOPHONIUM); - } - - @Override - public boolean itemInteractionForEntity(ItemStack stack, EntityPlayer player, EntityLivingBase entity) { - if (entity instanceof EntityLiving) { - EntityLiving living = (EntityLiving) entity; - String sound = null; - try { - if (living instanceof EntityCreeper) sound = "creeper.primed"; - else if (living instanceof EntitySlime) - sound = "mob.slime." + (((EntitySlime) living).getSlimeSize() > 1 ? "big" : "small"); - else - sound = (String) - ReflectionHelper.findMethod(EntityLiving.class, living, LibObfuscation.GET_LIVING_SOUND) - .invoke(living); - - if (sound != null) { - String s = EntityList.getEntityString(entity); - if (s == null) s = "generic"; - - ItemNBTHelper.setString(stack, TAG_SOUND, sound); - ItemNBTHelper.setString(stack, TAG_SOUND_NAME, "entity." + s + ".name"); - ItemNBTHelper.setBoolean(stack, TAG_HAS_SOUND, true); - player.inventory.setInventorySlotContents(player.inventory.currentItem, stack.copy()); - - if (player.worldObj.isRemote) player.swingItem(); - - return true; - } - } catch (Exception e) { - e.printStackTrace(); - } - } - - return false; - } - - @Override - public boolean onItemUse( - ItemStack stack, - EntityPlayer player, - World world, - int x, - int y, - int z, - int s, - float xs, - float ys, - float zs) { - boolean can = isDOIT(stack); - if (!can) { - String sound = ItemNBTHelper.getString(stack, TAG_SOUND, ""); - isDOIT(stack); - if (sound != null && !sound.isEmpty()) can = true; - } - - if (can) { - Block block = world.getBlock(x, y, z); - if (block == Blocks.noteblock) { - world.setBlock(x, y, z, ModBlocks.cacophonium); - ((TileCacophonium) world.getTileEntity(x, y, z)).stack = stack.copy(); - stack.stackSize--; - return true; - } - } - - return false; - } - - @Override - public void addInformation(ItemStack stack, EntityPlayer player, List list, boolean adv) { - if (isDOIT(stack)) list.add(StatCollector.translateToLocal("botaniamisc.justDoIt")); - else if (ItemNBTHelper.getBoolean(stack, TAG_HAS_SOUND, false)) - list.add(StatCollector.translateToLocal(ItemNBTHelper.getString(stack, TAG_SOUND_NAME, ""))); - } - - @Override - public EnumAction getItemUseAction(ItemStack par1ItemStack) { - return EnumAction.block; - } - - @Override - public int getMaxItemUseDuration(ItemStack par1ItemStack) { - return 72000; - } - - @Override - public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer) { - if (ItemNBTHelper.getBoolean(par1ItemStack, TAG_HAS_SOUND, false) || isDOIT(par1ItemStack)) - par3EntityPlayer.setItemInUse(par1ItemStack, 72000); - return par1ItemStack; - } - - @Override - public void onUsingTick(ItemStack stack, EntityPlayer player, int count) { - if (count % (isDOIT(stack) ? 20 : 6) == 0) - playSound(player.worldObj, stack, player.posX, player.posY, player.posZ, 0.9F); - } - - public static void playSound(World world, ItemStack stack, double x, double y, double z, float volume) { - if (stack == null) return; - - String sound = ItemNBTHelper.getString(stack, TAG_SOUND, ""); - boolean doit = isDOIT(stack); - if (doit) sound = "botania:doit"; - - if (sound != null && !sound.isEmpty()) - world.playSoundEffect( - x, - y, - z, - sound, - volume, - doit ? 1F : (world.rand.nextFloat() - world.rand.nextFloat()) * 0.2F + 1.0F); - } - - private static boolean isDOIT(ItemStack stack) { - return stack != null && stack.getDisplayName().equalsIgnoreCase("shia labeouf"); - } - - @Override - public Achievement getAchievementOnCraft(ItemStack stack, EntityPlayer player, IInventory matrix) { - return ModAchievements.cacophoniumCraft; - } + private static final String TAG_SOUND = "sound"; + private static final String TAG_SOUND_NAME = "soundName"; + private static final String TAG_HAS_SOUND = "hasSound"; + + public ItemCacophonium() { + setMaxStackSize(1); + setUnlocalizedName(LibItemNames.CACOPHONIUM); + } + + @Override + public boolean itemInteractionForEntity(ItemStack stack, EntityPlayer player, EntityLivingBase entity) { + if(entity instanceof EntityLiving) { + EntityLiving living = (EntityLiving) entity; + String sound = null; + try { + if(living instanceof EntityCreeper) + sound = "creeper.primed"; + else if(living instanceof EntitySlime) + sound = "mob.slime." + (((EntitySlime) living).getSlimeSize() > 1 ? "big" : "small"); + else sound = (String) ReflectionHelper.findMethod(EntityLiving.class, living, LibObfuscation.GET_LIVING_SOUND).invoke(living); + + if(sound != null) { + String s = EntityList.getEntityString(entity); + if(s == null) + s = "generic"; + + ItemNBTHelper.setString(stack, TAG_SOUND, sound); + ItemNBTHelper.setString(stack, TAG_SOUND_NAME, "entity." + s + ".name"); + ItemNBTHelper.setBoolean(stack, TAG_HAS_SOUND, true); + player.inventory.setInventorySlotContents(player.inventory.currentItem, stack.copy()); + + if(player.worldObj.isRemote) + player.swingItem(); + + return true; + } + } catch (Exception e) { + e.printStackTrace(); + } + } + + return false; + } + + @Override + public boolean onItemUse(ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int s, float xs, float ys, float zs) { + boolean can = isDOIT(stack); + if(!can) { + String sound = ItemNBTHelper.getString(stack, TAG_SOUND, ""); + isDOIT(stack); + if(sound != null && !sound.isEmpty()) + can = true; + } + + if(can) { + Block block = world.getBlock(x, y, z); + if(block == Blocks.noteblock) { + world.setBlock(x, y, z, ModBlocks.cacophonium); + ((TileCacophonium) world.getTileEntity(x, y, z)).stack = stack.copy(); + stack.stackSize--; + return true; + } + } + + return false; + } + + @Override + public void addInformation(ItemStack stack, EntityPlayer player, List list, boolean adv) { + if(isDOIT(stack)) + list.add(StatCollector.translateToLocal("botaniamisc.justDoIt")); + else if(ItemNBTHelper.getBoolean(stack, TAG_HAS_SOUND, false)) + list.add(StatCollector.translateToLocal(ItemNBTHelper.getString(stack, TAG_SOUND_NAME, ""))); + } + + @Override + public EnumAction getItemUseAction(ItemStack par1ItemStack) { + return EnumAction.block; + } + + @Override + public int getMaxItemUseDuration(ItemStack par1ItemStack) { + return 72000; + } + + @Override + public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer) { + if(ItemNBTHelper.getBoolean(par1ItemStack, TAG_HAS_SOUND, false) || isDOIT(par1ItemStack)) + par3EntityPlayer.setItemInUse(par1ItemStack, 72000); + return par1ItemStack; + } + + @Override + public void onUsingTick(ItemStack stack, EntityPlayer player, int count) { + if(count % (isDOIT(stack) ? 20 : 6) == 0) + playSound(player.worldObj, stack, player.posX, player.posY, player.posZ, 0.9F); + } + + public static void playSound(World world, ItemStack stack, double x, double y, double z, float volume) { + if(stack == null) + return; + + String sound = ItemNBTHelper.getString(stack, TAG_SOUND, ""); + boolean doit = isDOIT(stack); + if(doit) + sound = "botania:doit"; + + if(sound != null && !sound.isEmpty()) + world.playSoundEffect(x, y, z, sound, volume, doit ? 1F : (world.rand.nextFloat() - world.rand.nextFloat()) * 0.2F + 1.0F); + } + + private static boolean isDOIT(ItemStack stack) { + return stack != null && stack.getDisplayName().equalsIgnoreCase("shia labeouf"); + } + + @Override + public Achievement getAchievementOnCraft(ItemStack stack, EntityPlayer player, IInventory matrix) { + return ModAchievements.cacophoniumCraft; + } } diff --git a/src/main/java/vazkii/botania/common/item/ItemClip.java b/src/main/java/vazkii/botania/common/item/ItemClip.java index bab097e8fc..6f3ac2b502 100644 --- a/src/main/java/vazkii/botania/common/item/ItemClip.java +++ b/src/main/java/vazkii/botania/common/item/ItemClip.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jan 24, 2015, 7:56:38 PM (GMT)] */ package vazkii.botania.common.item; @@ -14,8 +14,9 @@ public class ItemClip extends ItemMod { - public ItemClip() { - setMaxStackSize(1); - setUnlocalizedName(LibItemNames.CLIP); - } + public ItemClip() { + setMaxStackSize(1); + setUnlocalizedName(LibItemNames.CLIP); + } + } diff --git a/src/main/java/vazkii/botania/common/item/ItemCorporeaSpark.java b/src/main/java/vazkii/botania/common/item/ItemCorporeaSpark.java index 221123793c..2efd3a7e76 100644 --- a/src/main/java/vazkii/botania/common/item/ItemCorporeaSpark.java +++ b/src/main/java/vazkii/botania/common/item/ItemCorporeaSpark.java @@ -2,15 +2,16 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Feb 13, 2015, 10:25:32 PM (GMT)] */ package vazkii.botania.common.item; import java.util.List; + import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.entity.player.EntityPlayer; @@ -27,61 +28,54 @@ public class ItemCorporeaSpark extends ItemMod { - public static IIcon invIcon, worldIcon, invIconMaster, worldIconMaster, iconColorStar; + public static IIcon invIcon, worldIcon, invIconMaster, worldIconMaster, iconColorStar; + + public ItemCorporeaSpark() { + setUnlocalizedName(LibItemNames.CORPOREA_SPARK); + setHasSubtypes(true); + } - public ItemCorporeaSpark() { - setUnlocalizedName(LibItemNames.CORPOREA_SPARK); - setHasSubtypes(true); - } + @Override + public void getSubItems(Item item, CreativeTabs tab, List list) { + for(int i = 0; i < 2; i++) + list.add(new ItemStack(item, 1, i)); + } - @Override - public void getSubItems(Item item, CreativeTabs tab, List list) { - for (int i = 0; i < 2; i++) list.add(new ItemStack(item, 1, i)); - } + @Override + public boolean onItemUse(ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int side, float xv, float yv, float zv) { + TileEntity tile = world.getTileEntity(x, y, z); + if(tile instanceof IInventory && !CorporeaHelper.doesBlockHaveSpark(world, x, y, z)) { + stack.stackSize--; + if(!world.isRemote) { + EntityCorporeaSpark spark = new EntityCorporeaSpark(world); + if(stack.getItemDamage() == 1) + spark.setMaster(true); + spark.setPosition(x + 0.5, y + 1.5, z + 0.5); + world.spawnEntityInWorld(spark); + world.markBlockForUpdate(x, y, z); + } + return true; + } + return false; + } - @Override - public boolean onItemUse( - ItemStack stack, - EntityPlayer player, - World world, - int x, - int y, - int z, - int side, - float xv, - float yv, - float zv) { - TileEntity tile = world.getTileEntity(x, y, z); - if (tile instanceof IInventory && !CorporeaHelper.doesBlockHaveSpark(world, x, y, z)) { - stack.stackSize--; - if (!world.isRemote) { - EntityCorporeaSpark spark = new EntityCorporeaSpark(world); - if (stack.getItemDamage() == 1) spark.setMaster(true); - spark.setPosition(x + 0.5, y + 1.5, z + 0.5); - world.spawnEntityInWorld(spark); - world.markBlockForUpdate(x, y, z); - } - return true; - } - return false; - } + @Override + public void registerIcons(IIconRegister par1IconRegister) { + invIcon = IconHelper.forItem(par1IconRegister, this, 0); + worldIcon = IconHelper.forItem(par1IconRegister, this, 1); + invIconMaster = IconHelper.forItem(par1IconRegister, this, 2); + worldIconMaster = IconHelper.forItem(par1IconRegister, this, 3); + iconColorStar = IconHelper.forItem(par1IconRegister, this, "Star"); + } - @Override - public void registerIcons(IIconRegister par1IconRegister) { - invIcon = IconHelper.forItem(par1IconRegister, this, 0); - worldIcon = IconHelper.forItem(par1IconRegister, this, 1); - invIconMaster = IconHelper.forItem(par1IconRegister, this, 2); - worldIconMaster = IconHelper.forItem(par1IconRegister, this, 3); - iconColorStar = IconHelper.forItem(par1IconRegister, this, "Star"); - } + @Override + public String getUnlocalizedName(ItemStack par1ItemStack) { + return super.getUnlocalizedName(par1ItemStack) + par1ItemStack.getItemDamage(); + } - @Override - public String getUnlocalizedName(ItemStack par1ItemStack) { - return super.getUnlocalizedName(par1ItemStack) + par1ItemStack.getItemDamage(); - } + @Override + public IIcon getIconFromDamage(int meta) { + return meta == 0 ? invIcon : invIconMaster; + } - @Override - public IIcon getIconFromDamage(int meta) { - return meta == 0 ? invIcon : invIconMaster; - } } diff --git a/src/main/java/vazkii/botania/common/item/ItemCraftPattern.java b/src/main/java/vazkii/botania/common/item/ItemCraftPattern.java index 55bd5e93a7..d799748f6f 100644 --- a/src/main/java/vazkii/botania/common/item/ItemCraftPattern.java +++ b/src/main/java/vazkii/botania/common/item/ItemCraftPattern.java @@ -2,15 +2,16 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jan 28, 2015, 2:59:06 PM (GMT)] */ package vazkii.botania.common.item; import java.util.List; + import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.entity.player.EntityPlayer; @@ -25,44 +26,46 @@ public class ItemCraftPattern extends ItemMod { - IIcon[] icons; + IIcon[] icons; + + public ItemCraftPattern() { + setHasSubtypes(true); + setUnlocalizedName(LibItemNames.CRAFT_PATTERN); + setMaxStackSize(1); + } - public ItemCraftPattern() { - setHasSubtypes(true); - setUnlocalizedName(LibItemNames.CRAFT_PATTERN); - setMaxStackSize(1); - } + @Override + public boolean onItemUse(ItemStack stack, EntityPlayer p, World world, int x, int y, int z, int s, float xs, float ys, float zs) { + TileEntity tile = world.getTileEntity(x, y, z); + if(tile != null && tile instanceof TileCraftCrate && !world.isRemote) { + TileCraftCrate crate = (TileCraftCrate) tile; + crate.pattern = stack.getItemDamage(); + world.markBlockForUpdate(x, y, z); + } + return false; + } - @Override - public boolean onItemUse( - ItemStack stack, EntityPlayer p, World world, int x, int y, int z, int s, float xs, float ys, float zs) { - TileEntity tile = world.getTileEntity(x, y, z); - if (tile != null && tile instanceof TileCraftCrate && !world.isRemote) { - TileCraftCrate crate = (TileCraftCrate) tile; - crate.pattern = stack.getItemDamage(); - world.markBlockForUpdate(x, y, z); - } - return false; - } + @Override + public void getSubItems(Item item, CreativeTabs tab, List list) { + for(int i = 0; i < TileCraftCrate.PATTERNS.length; i++) + list.add(new ItemStack(item, 1, i)); + } - @Override - public void getSubItems(Item item, CreativeTabs tab, List list) { - for (int i = 0; i < TileCraftCrate.PATTERNS.length; i++) list.add(new ItemStack(item, 1, i)); - } + @Override + public void registerIcons(IIconRegister par1IconRegister) { + icons = new IIcon[TileCraftCrate.PATTERNS.length]; + for(int i = 0; i < icons.length; i++) + icons[i] = IconHelper.forItem(par1IconRegister, this, i); + } - @Override - public void registerIcons(IIconRegister par1IconRegister) { - icons = new IIcon[TileCraftCrate.PATTERNS.length]; - for (int i = 0; i < icons.length; i++) icons[i] = IconHelper.forItem(par1IconRegister, this, i); - } + @Override + public IIcon getIconFromDamage(int dmg) { + return icons[Math.min(icons.length - 1, dmg)]; + } - @Override - public IIcon getIconFromDamage(int dmg) { - return icons[Math.min(icons.length - 1, dmg)]; - } + @Override + public String getUnlocalizedName(ItemStack par1ItemStack) { + return super.getUnlocalizedName(par1ItemStack) + par1ItemStack.getItemDamage(); + } - @Override - public String getUnlocalizedName(ItemStack par1ItemStack) { - return super.getUnlocalizedName(par1ItemStack) + par1ItemStack.getItemDamage(); - } } diff --git a/src/main/java/vazkii/botania/common/item/ItemCraftingHalo.java b/src/main/java/vazkii/botania/common/item/ItemCraftingHalo.java index ea0a9c6d2e..d393f213a3 100644 --- a/src/main/java/vazkii/botania/common/item/ItemCraftingHalo.java +++ b/src/main/java/vazkii/botania/common/item/ItemCraftingHalo.java @@ -2,20 +2,16 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Dec 15, 2014, 3:53:30 PM (GMT)] */ package vazkii.botania.common.item; -import cpw.mods.fml.common.FMLCommonHandler; -import cpw.mods.fml.common.eventhandler.SubscribeEvent; -import cpw.mods.fml.common.gameevent.PlayerEvent.ItemCraftedEvent; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; import java.awt.Color; + import net.minecraft.block.Block; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.Gui; @@ -48,8 +44,10 @@ import net.minecraftforge.client.event.RenderWorldLastEvent; import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.common.util.ForgeDirection; + import org.lwjgl.opengl.GL11; import org.lwjgl.opengl.GL12; + import vazkii.botania.client.core.handler.ClientTickHandler; import vazkii.botania.client.gui.crafting.InventoryCraftingHalo; import vazkii.botania.client.lib.LibResources; @@ -62,562 +60,547 @@ import vazkii.botania.common.core.helper.Vector3; import vazkii.botania.common.lib.LibGuiIDs; import vazkii.botania.common.lib.LibItemNames; +import cpw.mods.fml.common.FMLCommonHandler; +import cpw.mods.fml.common.eventhandler.SubscribeEvent; +import cpw.mods.fml.common.gameevent.PlayerEvent.ItemCraftedEvent; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; public class ItemCraftingHalo extends ItemMod implements ICraftAchievement { - private static final ResourceLocation glowTexture = new ResourceLocation(LibResources.MISC_GLOW_GREEN); - private static final ItemStack craftingTable = new ItemStack(Blocks.crafting_table); - - public static final int SEGMENTS = 12; - - private static final String TAG_LAST_CRAFTING = "lastCrafting"; - private static final String TAG_STORED_RECIPE_PREFIX = "storedRecipe"; - private static final String TAG_ITEM_PREFIX = "item"; - private static final String TAG_EQUIPPED = "equipped"; - private static final String TAG_ROTATION_BASE = "rotationBase"; - - public ItemCraftingHalo() { - this(LibItemNames.CRAFTING_HALO); - MinecraftForge.EVENT_BUS.register(this); - FMLCommonHandler.instance().bus().register(this); - } - - public ItemCraftingHalo(String name) { - setUnlocalizedName(name); - setMaxStackSize(1); - } - - @Override - public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer player) { - int segment = getSegmentLookedAt(stack, player); - ItemStack itemForPos = getItemForSlot(stack, segment); - - if (segment == 0) player.openGui(Botania.instance, LibGuiIDs.CRAFTING_HALO, world, 0, 0, 0); - else { - if (itemForPos == null) assignRecipe(stack, itemForPos, segment); - else tryCraft(player, stack, segment, true, getFakeInv(player), true); - } - - return stack; - } - - public static IInventory getFakeInv(EntityPlayer player) { - GenericInventory tempInv = new GenericInventory("temp", false, player.inventory.getSizeInventory() - 4); - tempInv.copyFrom(player.inventory); - return tempInv; - } - - @Override - public void onUpdate(ItemStack stack, World world, Entity entity, int pos, boolean equipped) { - boolean eqLastTick = wasEquipped(stack); - if (eqLastTick != equipped) setEquipped(stack, equipped); - - if (!equipped && entity instanceof EntityLivingBase) { - int angles = 360; - int segAngles = angles / SEGMENTS; - float shift = segAngles / 2; - setRotationBase(stack, getCheckingAngle((EntityLivingBase) entity) - shift); - } - } - - void tryCraft(EntityPlayer player, ItemStack stack, int slot, boolean particles, IInventory inv, boolean validate) { - ItemStack itemForPos = getItemForSlot(stack, slot); - if (itemForPos == null) return; - - ItemStack[] recipe = getCraftingItems(stack, slot); - if (validate) recipe = validateRecipe(player, stack, recipe, slot); - - if (canCraft(player, recipe, inv)) doCraft(player, recipe, particles); - } - - private static ItemStack[] validateRecipe(EntityPlayer player, ItemStack stack, ItemStack[] recipe, int slot) { - InventoryCrafting fakeInv = - new InventoryCrafting(new ContainerWorkbench(player.inventory, player.worldObj, 0, 0, 0), 3, 3); - for (int i = 0; i < 9; i++) fakeInv.setInventorySlotContents(i, recipe[i]); - - ItemStack result = CraftingManager.getInstance().findMatchingRecipe(fakeInv, player.worldObj); - if (result == null) { - assignRecipe(stack, recipe[9], slot); - return null; - } - - if (!result.isItemEqual(recipe[9]) - || result.stackSize != recipe[9].stackSize - || !ItemStack.areItemStackTagsEqual(recipe[9], result)) { - assignRecipe(stack, recipe[9], slot); - return null; - } - - return recipe; - } - - private static boolean canCraft(EntityPlayer player, ItemStack[] recipe, IInventory inv) { - if (recipe == null) return false; - - if (recipe[9].stackSize != InventoryHelper.testInventoryInsertion(inv, recipe[9], ForgeDirection.UNKNOWN)) - return false; - - return consumeRecipeIngredients(recipe, inv, null); - } - - private static void doCraft(EntityPlayer player, ItemStack[] recipe, boolean particles) { - consumeRecipeIngredients(recipe, player.inventory, player); - if (!player.inventory.addItemStackToInventory(recipe[9])) - player.dropPlayerItemWithRandomChoice(recipe[9], false); - - if (!particles) return; - - Vec3 lookVec3 = player.getLookVec(); - Vector3 centerVector = Vector3.fromEntityCenter(player).add(lookVec3.xCoord * 3, 1.3, lookVec3.zCoord * 3); - float m = 0.1F; - for (int i = 0; i < 4; i++) - Botania.proxy.wispFX( - player.worldObj, - centerVector.x, - centerVector.y, - centerVector.z, - 1F, - 0F, - 1F, - 0.2F + 0.2F * (float) Math.random(), - ((float) Math.random() - 0.5F) * m, - ((float) Math.random() - 0.5F) * m, - ((float) Math.random() - 0.5F) * m); - } - - private static boolean consumeRecipeIngredients(ItemStack[] recipe, IInventory inv, EntityPlayer player) { - for (int i = 0; i < 9; i++) { - ItemStack ingredient = recipe[i]; - if (ingredient != null && !consumeFromInventory(ingredient, inv, player)) return false; - } - - return true; - } - - private static boolean consumeFromInventory(ItemStack stack, IInventory inv, EntityPlayer player) { - for (int i = 0; i < inv.getSizeInventory(); i++) { - ItemStack stackAt = inv.getStackInSlot(i); - if (stackAt != null && stack.isItemEqual(stackAt) && ItemStack.areItemStackTagsEqual(stack, stackAt)) { - boolean consume = true; - - ItemStack container = stackAt.getItem().getContainerItem(stackAt); - if (container != null) { - if (container == stackAt) consume = false; - else { - InventoryHelper.insertItemIntoInventory(inv, container); - if (container.stackSize != 0 && player != null) - player.dropPlayerItemWithRandomChoice(container, false); - } - } - - if (consume) { - stackAt.stackSize--; - if (stackAt.stackSize == 0) inv.setInventorySlotContents(i, null); - } - - return true; - } - } - - return false; - } - - @Override - public boolean onEntitySwing(EntityLivingBase player, ItemStack stack) { - int segment = getSegmentLookedAt(stack, player); - if (segment == 0) return false; - - ItemStack itemForPos = getItemForSlot(stack, segment); - - if (itemForPos != null && player.isSneaking()) { - assignRecipe(stack, itemForPos, segment); - return true; - } - - return false; - } - - private static int getSegmentLookedAt(ItemStack stack, EntityLivingBase player) { - getRotationBase(stack); - float yaw = getCheckingAngle(player, getRotationBase(stack)); - - int angles = 360; - int segAngles = angles / SEGMENTS; - for (int seg = 0; seg < SEGMENTS; seg++) { - float calcAngle = (float) seg * segAngles; - if (yaw >= calcAngle && yaw < calcAngle + segAngles) return seg; - } - return -1; - } - - private static float getCheckingAngle(EntityLivingBase player) { - return getCheckingAngle(player, 0F); - } - - // Screw the way minecraft handles rotation - // Really... - private static float getCheckingAngle(EntityLivingBase player, float base) { - float yaw = MathHelper.wrapAngleTo180_float(player.rotationYaw) + 90F; - int angles = 360; - int segAngles = angles / SEGMENTS; - float shift = segAngles / 2; - - if (yaw < 0) yaw = 180F + (180F + yaw); - yaw -= 360F - base; - float angle = 360F - yaw + shift; - - if (angle < 0) angle = 360F + angle; - - return angle; - } - - public static ItemStack getItemForSlot(ItemStack stack, int slot) { - if (slot == 0) return craftingTable; - else if (slot >= SEGMENTS) return null; - else { - NBTTagCompound cmp = getStoredRecipeCompound(stack, slot); - - if (cmp != null) { - ItemStack cmpStack = getLastCraftingItem(cmp, 9); - return cmpStack; - } else return null; - } - } - - public static void assignRecipe(ItemStack stack, ItemStack itemForPos, int pos) { - if (itemForPos != null) ItemNBTHelper.setCompound(stack, TAG_STORED_RECIPE_PREFIX + pos, new NBTTagCompound()); - else ItemNBTHelper.setCompound(stack, TAG_STORED_RECIPE_PREFIX + pos, getLastCraftingCompound(stack, false)); - } - - @SubscribeEvent - public void onItemCrafted(ItemCraftedEvent event) { - if (!(event.craftMatrix instanceof InventoryCraftingHalo)) return; - - for (int i = 0; i < event.player.inventory.getSizeInventory(); i++) { - ItemStack stack = event.player.inventory.getStackInSlot(i); - if (stack != null && stack.getItem() instanceof ItemCraftingHalo) saveRecipeToStack(event, stack); - } - } - - private void saveRecipeToStack(ItemCraftedEvent event, ItemStack stack) { - NBTTagCompound cmp = new NBTTagCompound(); - NBTTagCompound cmp1 = new NBTTagCompound(); - - ItemStack result = CraftingManager.getInstance() - .findMatchingRecipe((InventoryCrafting) event.craftMatrix, event.player.worldObj); - if (result != null) { - result.writeToNBT(cmp1); - cmp.setTag(TAG_ITEM_PREFIX + 9, cmp1); - - for (int i = 0; i < 9; i++) { - cmp1 = new NBTTagCompound(); - ItemStack stackSlot = event.craftMatrix.getStackInSlot(i); - - if (stackSlot != null) { - ItemStack writeStack = stackSlot.copy(); - writeStack.stackSize = 1; - writeStack.writeToNBT(cmp1); - } - cmp.setTag(TAG_ITEM_PREFIX + i, cmp1); - } - } - - ItemNBTHelper.setCompound(stack, TAG_LAST_CRAFTING, cmp); - } - - public static ItemStack[] getLastCraftingItems(ItemStack stack) { - return getCraftingItems(stack, SEGMENTS); - } - - public static ItemStack[] getCraftingItems(ItemStack stack, int slot) { - ItemStack[] stackArray = new ItemStack[10]; - - NBTTagCompound cmp = getStoredRecipeCompound(stack, slot); - if (cmp != null) for (int i = 0; i < stackArray.length; i++) stackArray[i] = getLastCraftingItem(cmp, i); - - return stackArray; - } - - public static NBTTagCompound getLastCraftingCompound(ItemStack stack, boolean nullify) { - return ItemNBTHelper.getCompound(stack, TAG_LAST_CRAFTING, nullify); - } - - public static NBTTagCompound getStoredRecipeCompound(ItemStack stack, int slot) { - return slot == SEGMENTS - ? getLastCraftingCompound(stack, true) - : ItemNBTHelper.getCompound(stack, TAG_STORED_RECIPE_PREFIX + slot, true); - } - - public static ItemStack getLastCraftingItem(ItemStack stack, int pos) { - return getLastCraftingItem(getLastCraftingCompound(stack, true), pos); - } - - public static ItemStack getLastCraftingItem(NBTTagCompound cmp, int pos) { - if (cmp == null) return null; - - NBTTagCompound cmp1 = cmp.getCompoundTag(TAG_ITEM_PREFIX + pos); - if (cmp1 == null) return null; - - return ItemStack.loadItemStackFromNBT(cmp1); - } - - public static boolean wasEquipped(ItemStack stack) { - return ItemNBTHelper.getBoolean(stack, TAG_EQUIPPED, false); - } - - public static void setEquipped(ItemStack stack, boolean equipped) { - ItemNBTHelper.setBoolean(stack, TAG_EQUIPPED, equipped); - } - - public static float getRotationBase(ItemStack stack) { - return ItemNBTHelper.getFloat(stack, TAG_ROTATION_BASE, 0F); - } - - public static void setRotationBase(ItemStack stack, float rotation) { - ItemNBTHelper.setFloat(stack, TAG_ROTATION_BASE, rotation); - } - - @SideOnly(Side.CLIENT) - @SubscribeEvent - public void onRenderWorldLast(RenderWorldLastEvent event) { - EntityPlayer player = Minecraft.getMinecraft().thePlayer; - ItemStack stack = player.getCurrentEquippedItem(); - if (stack != null && stack.getItem() instanceof ItemCraftingHalo) render(stack, player, event.partialTicks); - } - - @SideOnly(Side.CLIENT) - public void render(ItemStack stack, EntityPlayer player, float partialTicks) { - Minecraft mc = Minecraft.getMinecraft(); - Tessellator tess = Tessellator.instance; - Tessellator.renderingWorldRenderer = false; - - GL11.glPushMatrix(); - GL11.glEnable(GL11.GL_BLEND); - GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); - float alpha = - ((float) Math.sin((ClientTickHandler.ticksInGame + partialTicks) * 0.2F) * 0.5F + 0.5F) * 0.4F + 0.3F; - - double posX = player.prevPosX + (player.posX - player.prevPosX) * partialTicks; - double posY = player.prevPosY + (player.posY - player.prevPosY) * partialTicks; - double posZ = player.prevPosZ + (player.posZ - player.prevPosZ) * partialTicks; - - GL11.glTranslated( - posX - RenderManager.renderPosX, posY - RenderManager.renderPosY, posZ - RenderManager.renderPosZ); - - float base = getRotationBase(stack); - int angles = 360; - int segAngles = angles / SEGMENTS; - float shift = base - segAngles / 2; - - float u = 1F; - float v = 0.25F; - - float s = 3F; - float m = 0.8F; - float y = v * s * 2; - float y0 = 0; - - int segmentLookedAt = getSegmentLookedAt(stack, player); - - for (int seg = 0; seg < SEGMENTS; seg++) { - boolean inside = false; - float rotationAngle = (seg + 0.5F) * segAngles + shift; - GL11.glPushMatrix(); - GL11.glRotatef(rotationAngle, 0F, 1F, 0F); - GL11.glTranslatef(s * m, -0.75F, 0F); - - if (segmentLookedAt == seg) inside = true; - - ItemStack slotStack = getItemForSlot(stack, seg); - if (slotStack != null) { - mc.renderEngine.bindTexture( - slotStack.getItem() instanceof ItemBlock - ? TextureMap.locationBlocksTexture - : TextureMap.locationItemsTexture); - - if (slotStack.getItem() instanceof ItemBlock - && RenderBlocks.renderItemIn3d( - Block.getBlockFromItem(slotStack.getItem()).getRenderType())) { - float scale = seg == 0 ? 0.75F : 0.6F; - GL11.glScalef(scale, scale, scale); - GL11.glRotatef(180F, 0F, 1F, 0F); - GL11.glTranslatef(seg == 0 ? 0.5F : 0F, seg == 0 ? -0.1F : 0.6F, 0F); - - RenderBlocks.getInstance() - .renderBlockAsItem( - Block.getBlockFromItem(slotStack.getItem()), slotStack.getItemDamage(), 1F); - } else { - GL11.glScalef(0.75F, 0.75F, 0.75F); - GL11.glTranslatef(0F, 0F, 0.5F); - GL11.glRotatef(90F, 0F, 1F, 0F); - int renderPass = 0; - do { - IIcon icon = slotStack.getItem().getIcon(slotStack, renderPass); - if (icon != null) { - Color color = new Color(slotStack.getItem().getColorFromItemStack(slotStack, renderPass)); - GL11.glColor3ub((byte) color.getRed(), (byte) color.getGreen(), (byte) color.getBlue()); - float f = icon.getMinU(); - float f1 = icon.getMaxU(); - float f2 = icon.getMinV(); - float f3 = icon.getMaxV(); - ItemRenderer.renderItemIn2D( - Tessellator.instance, - f1, - f2, - f, - f3, - icon.getIconWidth(), - icon.getIconHeight(), - 1F / 16F); - GL11.glColor3f(1F, 1F, 1F); - } - renderPass++; - } while (renderPass < slotStack.getItem().getRenderPasses(slotStack.getItemDamage())); - } - } - GL11.glPopMatrix(); - - GL11.glPushMatrix(); - GL11.glRotatef(180F, 1F, 0F, 0F); - float a = alpha; - if (inside) { - a += 0.3F; - y0 = -y; - } - - if (seg % 2 == 0) GL11.glColor4f(0.6F, 0.6F, 0.6F, a); - else GL11.glColor4f(1F, 1F, 1F, a); - - GL11.glDisable(GL11.GL_CULL_FACE); - ItemCraftingHalo item = (ItemCraftingHalo) stack.getItem(); - mc.renderEngine.bindTexture(item.getGlowResource()); - tess.startDrawingQuads(); - for (int i = 0; i < segAngles; i++) { - float ang = i + seg * segAngles + shift; - double xp = Math.cos(ang * Math.PI / 180F) * s; - double zp = Math.sin(ang * Math.PI / 180F) * s; - - tess.addVertexWithUV(xp * m, y, zp * m, u, v); - tess.addVertexWithUV(xp, y0, zp, u, 0); - - xp = Math.cos((ang + 1) * Math.PI / 180F) * s; - zp = Math.sin((ang + 1) * Math.PI / 180F) * s; - - tess.addVertexWithUV(xp, y0, zp, 0, 0); - tess.addVertexWithUV(xp * m, y, zp * m, 0, v); - } - y0 = 0; - tess.draw(); - GL11.glEnable(GL11.GL_CULL_FACE); - GL11.glPopMatrix(); - } - GL11.glPopMatrix(); - } - - @SideOnly(Side.CLIENT) - public ResourceLocation getGlowResource() { - return glowTexture; - } - - @SideOnly(Side.CLIENT) - public static void renderHUD(ScaledResolution resolution, EntityPlayer player, ItemStack stack) { - Minecraft mc = Minecraft.getMinecraft(); - int slot = getSegmentLookedAt(stack, player); - GL11.glEnable(GL11.GL_BLEND); - GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); - - if (slot == 0) { - String name = craftingTable.getDisplayName(); - int l = mc.fontRenderer.getStringWidth(name); - int x = resolution.getScaledWidth() / 2 - l / 2; - int y = resolution.getScaledHeight() / 2 - 65; - - Gui.drawRect(x - 6, y - 6, x + l + 6, y + 37, 0x22000000); - Gui.drawRect(x - 4, y - 4, x + l + 4, y + 35, 0x22000000); - net.minecraft.client.renderer.RenderHelper.enableGUIStandardItemLighting(); - GL11.glEnable(GL12.GL_RESCALE_NORMAL); - RenderItem.getInstance() - .renderItemAndEffectIntoGUI( - mc.fontRenderer, - mc.renderEngine, - craftingTable, - resolution.getScaledWidth() / 2 - 8, - resolution.getScaledHeight() / 2 - 52); - net.minecraft.client.renderer.RenderHelper.disableStandardItemLighting(); - - mc.fontRenderer.drawStringWithShadow(name, x, y, 0xFFFFFF); - } else { - ItemStack[] recipe = getCraftingItems(stack, slot); - String label = StatCollector.translateToLocal("botaniamisc.unsetRecipe"); - boolean setRecipe = false; - - if (recipe[9] == null) recipe = getCraftingItems(stack, SEGMENTS); - else { - label = recipe[9].getDisplayName(); - setRecipe = true; - } - - renderRecipe(resolution, label, recipe, player, setRecipe); - } - } - - @SideOnly(Side.CLIENT) - public static void renderRecipe( - ScaledResolution resolution, String label, ItemStack[] recipe, EntityPlayer player, boolean setRecipe) { - Minecraft mc = Minecraft.getMinecraft(); - - if (recipe[9] != null) { - int x = resolution.getScaledWidth() / 2 - 45; - int y = resolution.getScaledHeight() / 2 - 90; - - Gui.drawRect(x - 6, y - 6, x + 90 + 6, y + 60, 0x22000000); - Gui.drawRect(x - 4, y - 4, x + 90 + 4, y + 58, 0x22000000); - - Gui.drawRect(x + 66, y + 14, x + 92, y + 40, 0x22000000); - Gui.drawRect(x - 2, y - 2, x + 56, y + 56, 0x22000000); - - net.minecraft.client.renderer.RenderHelper.enableGUIStandardItemLighting(); - GL11.glEnable(GL12.GL_RESCALE_NORMAL); - for (int i = 0; i < 9; i++) { - ItemStack stack = recipe[i]; - if (stack != null) { - int xpos = x + i % 3 * 18; - int ypos = y + i / 3 * 18; - Gui.drawRect(xpos, ypos, xpos + 16, ypos + 16, 0x22000000); - - RenderItem.getInstance() - .renderItemAndEffectIntoGUI(mc.fontRenderer, mc.renderEngine, stack, xpos, ypos); - } - } - - RenderItem.getInstance() - .renderItemAndEffectIntoGUI(mc.fontRenderer, mc.renderEngine, recipe[9], x + 72, y + 18); - RenderItem.getInstance() - .renderItemOverlayIntoGUI(mc.fontRenderer, mc.renderEngine, recipe[9], x + 72, y + 18); - - net.minecraft.client.renderer.RenderHelper.disableStandardItemLighting(); - } - - int yoff = 110; - if (setRecipe && !canCraft(player, recipe, getFakeInv(player))) { - String warning = EnumChatFormatting.RED + StatCollector.translateToLocal("botaniamisc.cantCraft"); - mc.fontRenderer.drawStringWithShadow( - warning, - resolution.getScaledWidth() / 2 - mc.fontRenderer.getStringWidth(warning) / 2, - resolution.getScaledHeight() / 2 - yoff, - 0xFFFFFF); - yoff += 12; - } - - mc.fontRenderer.drawStringWithShadow( - label, - resolution.getScaledWidth() / 2 - mc.fontRenderer.getStringWidth(label) / 2, - resolution.getScaledHeight() / 2 - yoff, - 0xFFFFFF); - } - - @Override - public Achievement getAchievementOnCraft(ItemStack stack, EntityPlayer player, IInventory matrix) { - return ModAchievements.craftingHaloCraft; - } + private static final ResourceLocation glowTexture = new ResourceLocation(LibResources.MISC_GLOW_GREEN); + private static final ItemStack craftingTable = new ItemStack(Blocks.crafting_table); + + public static final int SEGMENTS = 12; + + private static final String TAG_LAST_CRAFTING = "lastCrafting"; + private static final String TAG_STORED_RECIPE_PREFIX = "storedRecipe"; + private static final String TAG_ITEM_PREFIX = "item"; + private static final String TAG_EQUIPPED = "equipped"; + private static final String TAG_ROTATION_BASE = "rotationBase"; + + public ItemCraftingHalo() { + this(LibItemNames.CRAFTING_HALO); + MinecraftForge.EVENT_BUS.register(this); + FMLCommonHandler.instance().bus().register(this); + } + + public ItemCraftingHalo(String name) { + setUnlocalizedName(name); + setMaxStackSize(1); + } + + @Override + public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer player) { + int segment = getSegmentLookedAt(stack, player); + ItemStack itemForPos = getItemForSlot(stack, segment); + + if(segment == 0) + player.openGui(Botania.instance, LibGuiIDs.CRAFTING_HALO, world, 0, 0, 0); + else { + if(itemForPos == null) + assignRecipe(stack, itemForPos, segment); + else tryCraft(player, stack, segment, true, getFakeInv(player), true); + } + + return stack; + } + + public static IInventory getFakeInv(EntityPlayer player) { + GenericInventory tempInv = new GenericInventory("temp", false, player.inventory.getSizeInventory() - 4); + tempInv.copyFrom(player.inventory); + return tempInv; + } + + @Override + public void onUpdate(ItemStack stack, World world, Entity entity, int pos, boolean equipped) { + boolean eqLastTick = wasEquipped(stack); + if(eqLastTick != equipped) + setEquipped(stack, equipped); + + if(!equipped && entity instanceof EntityLivingBase) { + int angles = 360; + int segAngles = angles / SEGMENTS; + float shift = segAngles / 2; + setRotationBase(stack, getCheckingAngle((EntityLivingBase) entity) - shift); + } + } + + void tryCraft(EntityPlayer player, ItemStack stack, int slot, boolean particles, IInventory inv, boolean validate) { + ItemStack itemForPos = getItemForSlot(stack, slot); + if(itemForPos == null) + return; + + ItemStack[] recipe = getCraftingItems(stack, slot); + if(validate) + recipe = validateRecipe(player, stack, recipe, slot); + + if(canCraft(player, recipe, inv)) + doCraft(player, recipe, particles); + } + + private static ItemStack[] validateRecipe(EntityPlayer player, ItemStack stack, ItemStack[] recipe, int slot) { + InventoryCrafting fakeInv = new InventoryCrafting(new ContainerWorkbench(player.inventory, player.worldObj, 0, 0, 0), 3, 3); + for(int i = 0; i < 9; i++) + fakeInv.setInventorySlotContents(i, recipe[i]); + + ItemStack result = CraftingManager.getInstance().findMatchingRecipe(fakeInv, player.worldObj); + if(result == null) { + assignRecipe(stack, recipe[9], slot); + return null; + } + + if(!result.isItemEqual(recipe[9]) || result.stackSize != recipe[9].stackSize || !ItemStack.areItemStackTagsEqual(recipe[9], result)) { + assignRecipe(stack, recipe[9], slot); + return null; + } + + return recipe; + } + + private static boolean canCraft(EntityPlayer player, ItemStack[] recipe, IInventory inv) { + if(recipe == null) + return false; + + if(recipe[9].stackSize != InventoryHelper.testInventoryInsertion(inv, recipe[9], ForgeDirection.UNKNOWN)) + return false; + + return consumeRecipeIngredients(recipe, inv, null); + } + + private static void doCraft(EntityPlayer player, ItemStack[] recipe, boolean particles) { + consumeRecipeIngredients(recipe, player.inventory, player); + if(!player.inventory.addItemStackToInventory(recipe[9])) + player.dropPlayerItemWithRandomChoice(recipe[9], false); + + if(!particles) + return; + + Vec3 lookVec3 = player.getLookVec(); + Vector3 centerVector = Vector3.fromEntityCenter(player).add(lookVec3.xCoord * 3, 1.3, lookVec3.zCoord * 3); + float m = 0.1F; + for(int i = 0; i < 4; i++) + Botania.proxy.wispFX(player.worldObj, centerVector.x, centerVector.y, centerVector.z, 1F, 0F, 1F, 0.2F + 0.2F * (float) Math.random(), ((float) Math.random() - 0.5F) * m, ((float) Math.random() - 0.5F) * m, ((float) Math.random() - 0.5F) * m); + } + + private static boolean consumeRecipeIngredients(ItemStack[] recipe, IInventory inv, EntityPlayer player) { + for(int i = 0; i < 9; i++) { + ItemStack ingredient = recipe[i]; + if(ingredient != null && !consumeFromInventory(ingredient, inv, player)) + return false; + } + + return true; + } + + private static boolean consumeFromInventory(ItemStack stack, IInventory inv, EntityPlayer player) { + for(int i = 0; i < inv.getSizeInventory(); i++) { + ItemStack stackAt = inv.getStackInSlot(i); + if(stackAt != null && stack.isItemEqual(stackAt) && ItemStack.areItemStackTagsEqual(stack, stackAt)) { + boolean consume = true; + + ItemStack container = stackAt.getItem().getContainerItem(stackAt); + if(container != null) { + if(container == stackAt) + consume = false; + else { + InventoryHelper.insertItemIntoInventory(inv, container); + if(container.stackSize != 0 && player != null) + player.dropPlayerItemWithRandomChoice(container, false); + } + } + + if(consume) { + stackAt.stackSize--; + if(stackAt.stackSize == 0) + inv.setInventorySlotContents(i, null); + } + + return true; + } + } + + return false; + } + + @Override + public boolean onEntitySwing(EntityLivingBase player, ItemStack stack) { + int segment = getSegmentLookedAt(stack, player); + if(segment == 0) + return false; + + ItemStack itemForPos = getItemForSlot(stack, segment); + + if(itemForPos != null && player.isSneaking()) { + assignRecipe(stack, itemForPos, segment); + return true; + } + + return false; + } + + private static int getSegmentLookedAt(ItemStack stack, EntityLivingBase player) { + getRotationBase(stack); + float yaw = getCheckingAngle(player, getRotationBase(stack)); + + int angles = 360; + int segAngles = angles / SEGMENTS; + for(int seg = 0; seg < SEGMENTS; seg++) { + float calcAngle = (float) seg * segAngles; + if(yaw >= calcAngle && yaw < calcAngle + segAngles) + return seg; + } + return -1; + } + + private static float getCheckingAngle(EntityLivingBase player) { + return getCheckingAngle(player, 0F); + } + + // Screw the way minecraft handles rotation + // Really... + private static float getCheckingAngle(EntityLivingBase player, float base) { + float yaw = MathHelper.wrapAngleTo180_float(player.rotationYaw) + 90F; + int angles = 360; + int segAngles = angles / SEGMENTS; + float shift = segAngles / 2; + + if(yaw < 0) + yaw = 180F + (180F + yaw); + yaw -= 360F - base; + float angle = 360F - yaw + shift; + + if(angle < 0) + angle = 360F + angle; + + return angle; + } + + public static ItemStack getItemForSlot(ItemStack stack, int slot) { + if(slot == 0) + return craftingTable; + else if(slot >= SEGMENTS) + return null; + else { + NBTTagCompound cmp = getStoredRecipeCompound(stack, slot); + + if(cmp != null) { + ItemStack cmpStack = getLastCraftingItem(cmp, 9); + return cmpStack; + } else return null; + } + } + + public static void assignRecipe(ItemStack stack, ItemStack itemForPos, int pos) { + if(itemForPos != null) + ItemNBTHelper.setCompound(stack, TAG_STORED_RECIPE_PREFIX + pos, new NBTTagCompound()); + else + ItemNBTHelper.setCompound(stack, TAG_STORED_RECIPE_PREFIX + pos, getLastCraftingCompound(stack, false)); + } + + @SubscribeEvent + public void onItemCrafted(ItemCraftedEvent event) { + if(!(event.craftMatrix instanceof InventoryCraftingHalo)) + return; + + for(int i = 0; i < event.player.inventory.getSizeInventory(); i++) { + ItemStack stack = event.player.inventory.getStackInSlot(i); + if(stack != null && stack.getItem() instanceof ItemCraftingHalo) + saveRecipeToStack(event, stack); + } + } + + private void saveRecipeToStack(ItemCraftedEvent event, ItemStack stack) { + NBTTagCompound cmp = new NBTTagCompound(); + NBTTagCompound cmp1 = new NBTTagCompound(); + + ItemStack result = CraftingManager.getInstance().findMatchingRecipe((InventoryCrafting) event.craftMatrix, event.player.worldObj); + if(result != null) { + result.writeToNBT(cmp1); + cmp.setTag(TAG_ITEM_PREFIX + 9, cmp1); + + for(int i = 0; i < 9; i++) { + cmp1 = new NBTTagCompound(); + ItemStack stackSlot = event.craftMatrix.getStackInSlot(i); + + if(stackSlot != null) { + ItemStack writeStack = stackSlot.copy(); + writeStack.stackSize = 1; + writeStack.writeToNBT(cmp1); + } + cmp.setTag(TAG_ITEM_PREFIX + i, cmp1); + } + } + + ItemNBTHelper.setCompound(stack, TAG_LAST_CRAFTING, cmp); + } + + public static ItemStack[] getLastCraftingItems(ItemStack stack) { + return getCraftingItems(stack, SEGMENTS); + } + + public static ItemStack[] getCraftingItems(ItemStack stack, int slot) { + ItemStack[] stackArray = new ItemStack[10]; + + NBTTagCompound cmp = getStoredRecipeCompound(stack, slot); + if(cmp != null) + for(int i = 0; i < stackArray.length; i++) + stackArray[i] = getLastCraftingItem(cmp, i); + + return stackArray; + } + + public static NBTTagCompound getLastCraftingCompound(ItemStack stack, boolean nullify) { + return ItemNBTHelper.getCompound(stack, TAG_LAST_CRAFTING, nullify); + } + + public static NBTTagCompound getStoredRecipeCompound(ItemStack stack, int slot) { + return slot == SEGMENTS ? getLastCraftingCompound(stack, true) : ItemNBTHelper.getCompound(stack, TAG_STORED_RECIPE_PREFIX + slot, true); + } + + public static ItemStack getLastCraftingItem(ItemStack stack, int pos) { + return getLastCraftingItem(getLastCraftingCompound(stack, true), pos); + } + + public static ItemStack getLastCraftingItem(NBTTagCompound cmp, int pos) { + if(cmp == null) + return null; + + NBTTagCompound cmp1 = cmp.getCompoundTag(TAG_ITEM_PREFIX + pos); + if(cmp1 == null) + return null; + + return ItemStack.loadItemStackFromNBT(cmp1); + } + + public static boolean wasEquipped(ItemStack stack) { + return ItemNBTHelper.getBoolean(stack, TAG_EQUIPPED, false); + } + + public static void setEquipped(ItemStack stack, boolean equipped) { + ItemNBTHelper.setBoolean(stack, TAG_EQUIPPED, equipped); + } + + public static float getRotationBase(ItemStack stack) { + return ItemNBTHelper.getFloat(stack, TAG_ROTATION_BASE, 0F); + } + + public static void setRotationBase(ItemStack stack, float rotation) { + ItemNBTHelper.setFloat(stack, TAG_ROTATION_BASE, rotation); + } + + @SideOnly(Side.CLIENT) + @SubscribeEvent + public void onRenderWorldLast(RenderWorldLastEvent event) { + EntityPlayer player = Minecraft.getMinecraft().thePlayer; + ItemStack stack = player.getCurrentEquippedItem(); + if(stack != null && stack.getItem() instanceof ItemCraftingHalo) + render(stack, player, event.partialTicks); + } + + @SideOnly(Side.CLIENT) + public void render(ItemStack stack, EntityPlayer player, float partialTicks) { + Minecraft mc = Minecraft.getMinecraft(); + Tessellator tess = Tessellator.instance; + Tessellator.renderingWorldRenderer = false; + + GL11.glPushMatrix(); + GL11.glEnable(GL11.GL_BLEND); + GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); + float alpha = ((float) Math.sin((ClientTickHandler.ticksInGame + partialTicks) * 0.2F) * 0.5F + 0.5F) * 0.4F + 0.3F; + + double posX = player.prevPosX + (player.posX - player.prevPosX) * partialTicks; + double posY = player.prevPosY + (player.posY - player.prevPosY) * partialTicks; + double posZ = player.prevPosZ + (player.posZ - player.prevPosZ) * partialTicks; + + GL11.glTranslated(posX - RenderManager.renderPosX, posY - RenderManager.renderPosY, posZ - RenderManager.renderPosZ); + + + float base = getRotationBase(stack); + int angles = 360; + int segAngles = angles / SEGMENTS; + float shift = base - segAngles / 2; + + float u = 1F; + float v = 0.25F; + + float s = 3F; + float m = 0.8F; + float y = v * s * 2; + float y0 = 0; + + int segmentLookedAt = getSegmentLookedAt(stack, player); + + for(int seg = 0; seg < SEGMENTS; seg++) { + boolean inside = false; + float rotationAngle = (seg + 0.5F) * segAngles + shift; + GL11.glPushMatrix(); + GL11.glRotatef(rotationAngle, 0F, 1F, 0F); + GL11.glTranslatef(s * m, -0.75F, 0F); + + if(segmentLookedAt == seg) + inside = true; + + ItemStack slotStack = getItemForSlot(stack, seg); + if(slotStack != null) { + mc.renderEngine.bindTexture(slotStack.getItem() instanceof ItemBlock ? TextureMap.locationBlocksTexture : TextureMap.locationItemsTexture); + + if(slotStack.getItem() instanceof ItemBlock && RenderBlocks.renderItemIn3d(Block.getBlockFromItem(slotStack.getItem()).getRenderType())) { + float scale = seg == 0 ? 0.75F : 0.6F; + GL11.glScalef(scale, scale, scale); + GL11.glRotatef(180F, 0F, 1F, 0F); + GL11.glTranslatef(seg == 0 ? 0.5F : 0F, seg == 0 ? -0.1F : 0.6F, 0F); + + RenderBlocks.getInstance().renderBlockAsItem(Block.getBlockFromItem(slotStack.getItem()), slotStack.getItemDamage(), 1F); + } else { + GL11.glScalef(0.75F, 0.75F, 0.75F); + GL11.glTranslatef(0F, 0F, 0.5F); + GL11.glRotatef(90F, 0F, 1F, 0F); + int renderPass = 0; + do { + IIcon icon = slotStack.getItem().getIcon(slotStack, renderPass); + if(icon != null) { + Color color = new Color(slotStack.getItem().getColorFromItemStack(slotStack, renderPass)); + GL11.glColor3ub((byte) color.getRed(), (byte) color.getGreen(), (byte) color.getBlue()); + float f = icon.getMinU(); + float f1 = icon.getMaxU(); + float f2 = icon.getMinV(); + float f3 = icon.getMaxV(); + ItemRenderer.renderItemIn2D(Tessellator.instance, f1, f2, f, f3, icon.getIconWidth(), icon.getIconHeight(), 1F / 16F); + GL11.glColor3f(1F, 1F, 1F); + } + renderPass++; + } while(renderPass < slotStack.getItem().getRenderPasses(slotStack.getItemDamage())); + } + } + GL11.glPopMatrix(); + + GL11.glPushMatrix(); + GL11.glRotatef(180F, 1F, 0F, 0F); + float a = alpha; + if(inside) { + a += 0.3F; + y0 = -y; + } + + if(seg % 2 == 0) + GL11.glColor4f(0.6F, 0.6F, 0.6F, a); + else GL11.glColor4f(1F, 1F, 1F, a); + + GL11.glDisable(GL11.GL_CULL_FACE); + ItemCraftingHalo item = (ItemCraftingHalo) stack.getItem(); + mc.renderEngine.bindTexture(item.getGlowResource()); + tess.startDrawingQuads(); + for(int i = 0; i < segAngles; i++) { + float ang = i + seg * segAngles + shift; + double xp = Math.cos(ang * Math.PI / 180F) * s; + double zp = Math.sin(ang * Math.PI / 180F) * s; + + tess.addVertexWithUV(xp * m, y, zp * m, u, v); + tess.addVertexWithUV(xp, y0, zp, u, 0); + + xp = Math.cos((ang + 1) * Math.PI / 180F) * s; + zp = Math.sin((ang + 1) * Math.PI / 180F) * s; + + tess.addVertexWithUV(xp, y0, zp, 0, 0); + tess.addVertexWithUV(xp * m, y, zp * m, 0, v); + } + y0 = 0; + tess.draw(); + GL11.glEnable(GL11.GL_CULL_FACE); + GL11.glPopMatrix(); + } + GL11.glPopMatrix(); + } + + @SideOnly(Side.CLIENT) + public ResourceLocation getGlowResource() { + return glowTexture; + } + + @SideOnly(Side.CLIENT) + public static void renderHUD(ScaledResolution resolution, EntityPlayer player, ItemStack stack) { + Minecraft mc = Minecraft.getMinecraft(); + int slot = getSegmentLookedAt(stack, player); + GL11.glEnable(GL11.GL_BLEND); + GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); + + if(slot == 0) { + String name = craftingTable.getDisplayName(); + int l = mc.fontRenderer.getStringWidth(name); + int x = resolution.getScaledWidth() / 2 - l / 2; + int y = resolution.getScaledHeight() / 2 - 65; + + Gui.drawRect(x - 6, y - 6, x + l + 6, y + 37, 0x22000000); + Gui.drawRect(x - 4, y - 4, x + l + 4, y + 35, 0x22000000); + net.minecraft.client.renderer.RenderHelper.enableGUIStandardItemLighting(); + GL11.glEnable(GL12.GL_RESCALE_NORMAL); + RenderItem.getInstance().renderItemAndEffectIntoGUI(mc.fontRenderer, mc.renderEngine, craftingTable, resolution.getScaledWidth() / 2 - 8, resolution.getScaledHeight() / 2 - 52); + net.minecraft.client.renderer.RenderHelper.disableStandardItemLighting(); + + mc.fontRenderer.drawStringWithShadow(name, x, y, 0xFFFFFF); + } else { + ItemStack[] recipe = getCraftingItems(stack, slot); + String label = StatCollector.translateToLocal("botaniamisc.unsetRecipe"); + boolean setRecipe = false; + + if(recipe[9] == null) + recipe = getCraftingItems(stack, SEGMENTS); + else { + label = recipe[9].getDisplayName(); + setRecipe = true; + } + + renderRecipe(resolution, label, recipe, player, setRecipe); + } + } + + @SideOnly(Side.CLIENT) + public static void renderRecipe(ScaledResolution resolution, String label, ItemStack[] recipe, EntityPlayer player, boolean setRecipe) { + Minecraft mc = Minecraft.getMinecraft(); + + if(recipe[9] != null) { + int x = resolution.getScaledWidth() / 2 - 45; + int y = resolution.getScaledHeight() / 2 - 90; + + Gui.drawRect(x - 6, y - 6, x + 90 + 6, y + 60, 0x22000000); + Gui.drawRect(x - 4, y - 4, x + 90 + 4, y + 58, 0x22000000); + + Gui.drawRect(x + 66, y + 14, x + 92, y + 40, 0x22000000); + Gui.drawRect(x - 2, y - 2, x + 56, y + 56, 0x22000000); + + net.minecraft.client.renderer.RenderHelper.enableGUIStandardItemLighting(); + GL11.glEnable(GL12.GL_RESCALE_NORMAL); + for(int i = 0; i < 9; i++) { + ItemStack stack = recipe[i]; + if(stack != null) { + int xpos = x + i % 3 * 18; + int ypos = y + i / 3 * 18; + Gui.drawRect(xpos, ypos, xpos + 16, ypos + 16, 0x22000000); + + RenderItem.getInstance().renderItemAndEffectIntoGUI(mc.fontRenderer, mc.renderEngine, stack, xpos, ypos); + } + } + + RenderItem.getInstance().renderItemAndEffectIntoGUI(mc.fontRenderer, mc.renderEngine, recipe[9], x + 72, y + 18); + RenderItem.getInstance().renderItemOverlayIntoGUI(mc.fontRenderer, mc.renderEngine, recipe[9], x + 72, y + 18); + + net.minecraft.client.renderer.RenderHelper.disableStandardItemLighting(); + } + + int yoff = 110; + if(setRecipe && !canCraft(player, recipe, getFakeInv(player))) { + String warning = EnumChatFormatting.RED + StatCollector.translateToLocal("botaniamisc.cantCraft"); + mc.fontRenderer.drawStringWithShadow(warning, resolution.getScaledWidth() / 2 - mc.fontRenderer.getStringWidth(warning) / 2, resolution.getScaledHeight() / 2 - yoff, 0xFFFFFF); + yoff += 12; + } + + mc.fontRenderer.drawStringWithShadow(label, resolution.getScaledWidth() / 2 - mc.fontRenderer.getStringWidth(label) / 2, resolution.getScaledHeight() / 2 - yoff, 0xFFFFFF); + } + + @Override + public Achievement getAchievementOnCraft(ItemStack stack, EntityPlayer player, IInventory matrix) { + return ModAchievements.craftingHaloCraft; + } + } diff --git a/src/main/java/vazkii/botania/common/item/ItemEnderHand.java b/src/main/java/vazkii/botania/common/item/ItemEnderHand.java index fe44cfc3f6..f6ef375a56 100644 --- a/src/main/java/vazkii/botania/common/item/ItemEnderHand.java +++ b/src/main/java/vazkii/botania/common/item/ItemEnderHand.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jul 31, 2014, 7:19:26 PM (GMT)] */ package vazkii.botania.common.item; @@ -24,71 +24,69 @@ public class ItemEnderHand extends ItemMod implements IManaUsingItem, IBlockProvider { - private static final int COST_PROVIDE = 5; - private static final int COST_SELF = 250; - private static final int COST_OTHER = 5000; + private static final int COST_PROVIDE = 5; + private static final int COST_SELF = 250; + private static final int COST_OTHER = 5000; - public ItemEnderHand() { - setMaxStackSize(1); - setUnlocalizedName(LibItemNames.ENDER_HAND); - } + public ItemEnderHand() { + setMaxStackSize(1); + setUnlocalizedName(LibItemNames.ENDER_HAND); + } - @Override - public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer player) { - if (ManaItemHandler.requestManaExact(stack, player, COST_SELF, false)) { - player.displayGUIChest(player.getInventoryEnderChest()); - ManaItemHandler.requestManaExact(stack, player, COST_SELF, true); - world.playSoundAtEntity(player, "mob.endermen.portal", 1F, 1F); - } - return stack; - } + @Override + public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer player) { + if(ManaItemHandler.requestManaExact(stack, player, COST_SELF, false)) { + player.displayGUIChest(player.getInventoryEnderChest()); + ManaItemHandler.requestManaExact(stack, player, COST_SELF, true); + world.playSoundAtEntity(player, "mob.endermen.portal", 1F, 1F); + } + return stack; + } - @Override - public boolean itemInteractionForEntity(ItemStack stack, EntityPlayer iplayer, EntityLivingBase entity) { - if (ConfigHandler.enderPickpocketEnabled - && entity instanceof EntityPlayer - && ManaItemHandler.requestManaExact(stack, iplayer, COST_OTHER, false)) { - iplayer.displayGUIChest(((EntityPlayer) entity).getInventoryEnderChest()); - ManaItemHandler.requestManaExact(stack, iplayer, COST_OTHER, true); - iplayer.worldObj.playSoundAtEntity(iplayer, "mob.endermen.portal", 1F, 1F); - return true; - } + @Override + public boolean itemInteractionForEntity(ItemStack stack, EntityPlayer iplayer, EntityLivingBase entity) { + if(ConfigHandler.enderPickpocketEnabled && entity instanceof EntityPlayer && ManaItemHandler.requestManaExact(stack, iplayer, COST_OTHER, false)) { + iplayer.displayGUIChest(((EntityPlayer) entity).getInventoryEnderChest()); + ManaItemHandler.requestManaExact(stack, iplayer, COST_OTHER, true); + iplayer.worldObj.playSoundAtEntity(iplayer, "mob.endermen.portal", 1F, 1F); + return true; + } - return false; - } + return false; + } - @Override - public boolean usesMana(ItemStack stack) { - return true; - } + @Override + public boolean usesMana(ItemStack stack) { + return true; + } - @Override - public boolean provideBlock( - EntityPlayer player, ItemStack requestor, ItemStack stack, Block block, int meta, boolean doit) { - if (requestor != null && requestor.getItem() == this) return false; + @Override + public boolean provideBlock(EntityPlayer player, ItemStack requestor, ItemStack stack, Block block, int meta, boolean doit) { + if(requestor != null && requestor.getItem() == this) + return false; - ItemStack istack = - ItemExchangeRod.removeFromInventory(player, player.getInventoryEnderChest(), stack, block, meta, false); - if (istack != null) { - boolean mana = ManaItemHandler.requestManaExact(stack, player, COST_PROVIDE, false); - if (mana) { - if (doit) { - ManaItemHandler.requestManaExact(stack, player, COST_PROVIDE, true); - ItemExchangeRod.removeFromInventory( - player, player.getInventoryEnderChest(), stack, block, meta, true); - } + ItemStack istack = ItemExchangeRod.removeFromInventory(player, player.getInventoryEnderChest(), stack, block, meta, false); + if(istack != null) { + boolean mana = ManaItemHandler.requestManaExact(stack, player, COST_PROVIDE, false); + if(mana) { + if(doit) { + ManaItemHandler.requestManaExact(stack, player, COST_PROVIDE, true); + ItemExchangeRod.removeFromInventory(player, player.getInventoryEnderChest(), stack, block, meta, true); + } - return true; - } - } + return true; + } + } - return false; - } + return false; + } - @Override - public int getBlockCount(EntityPlayer player, ItemStack requestor, ItemStack stack, Block block, int meta) { - if (requestor != null && requestor.getItem() == this) return 0; + @Override + public int getBlockCount(EntityPlayer player, ItemStack requestor, ItemStack stack, Block block, int meta) { + if(requestor != null && requestor.getItem() == this) + return 0; + + return ItemExchangeRod.getInventoryItemCount(player, player.getInventoryEnderChest(), stack, block, meta); + } - return ItemExchangeRod.getInventoryItemCount(player, player.getInventoryEnderChest(), stack, block, meta); - } } diff --git a/src/main/java/vazkii/botania/common/item/ItemFertilizer.java b/src/main/java/vazkii/botania/common/item/ItemFertilizer.java index 5501210e03..6940d2d046 100644 --- a/src/main/java/vazkii/botania/common/item/ItemFertilizer.java +++ b/src/main/java/vazkii/botania/common/item/ItemFertilizer.java @@ -2,16 +2,17 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Mar 29, 2014, 10:41:52 PM (GMT)] */ package vazkii.botania.common.item; import java.util.ArrayList; import java.util.List; + import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; import net.minecraft.util.ChunkCoordinates; @@ -22,69 +23,47 @@ public class ItemFertilizer extends ItemMod { - public ItemFertilizer() { - super(); - setUnlocalizedName(LibItemNames.FERTILIZER); - } + public ItemFertilizer() { + super(); + setUnlocalizedName(LibItemNames.FERTILIZER); + } - @Override - public boolean onItemUse( - ItemStack par1ItemStack, - EntityPlayer par2EntityPlayer, - World par3World, - int par4, - int par5, - int par6, - int par7, - float par8, - float par9, - float par10) { - final int range = 3; - if (!par3World.isRemote) { - List validCoords = new ArrayList(); + @Override + public boolean onItemUse(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, World par3World, int par4, int par5, int par6, int par7, float par8, float par9, float par10) { + final int range = 3; + if(!par3World.isRemote) { + List validCoords = new ArrayList(); - for (int i = -range - 1; i < range; i++) - for (int j = -range - 1; j < range; j++) { - for (int k = 2; k >= -2; k--) { - int x = par4 + i + 1; - int y = par5 + k + 1; - int z = par6 + j + 1; - if (par3World.isAirBlock(x, y, z) - && (!par3World.provider.hasNoSky || y < 255) - && ModBlocks.flower.canBlockStay(par3World, x, y, z)) - validCoords.add(new ChunkCoordinates(x, y, z)); - } - } + for(int i = -range - 1; i < range; i++) + for(int j = -range - 1; j < range; j++) { + for(int k = 2; k >= -2; k--) { + int x = par4 + i + 1; + int y = par5 + k + 1; + int z = par6 + j + 1; + if(par3World.isAirBlock(x, y, z) && (!par3World.provider.hasNoSky || y < 255) && ModBlocks.flower.canBlockStay(par3World, x, y, z)) + validCoords.add(new ChunkCoordinates(x, y, z)); + } + } - int flowerCount = Math.min(validCoords.size(), par3World.rand.nextBoolean() ? 3 : 4); - for (int i = 0; i < flowerCount; i++) { - ChunkCoordinates coords = validCoords.get(par3World.rand.nextInt(validCoords.size())); - validCoords.remove(coords); - par3World.setBlock( - coords.posX, coords.posY, coords.posZ, ModBlocks.flower, par3World.rand.nextInt(16), 1 | 2); - } - par1ItemStack.stackSize--; - } else { - for (int i = 0; i < 15; i++) { - double x = par4 - range + par3World.rand.nextInt(range * 2 + 1) + Math.random(); - double y = par5 + 1; - double z = par6 - range + par3World.rand.nextInt(range * 2 + 1) + Math.random(); - float red = (float) Math.random(); - float green = (float) Math.random(); - float blue = (float) Math.random(); - Botania.proxy.wispFX( - par3World, - x, - y, - z, - red, - green, - blue, - 0.15F + (float) Math.random() * 0.25F, - -(float) Math.random() * 0.1F - 0.05F); - } - } + int flowerCount = Math.min(validCoords.size(), par3World.rand.nextBoolean() ? 3 : 4); + for(int i = 0; i < flowerCount; i++) { + ChunkCoordinates coords = validCoords.get(par3World.rand.nextInt(validCoords.size())); + validCoords.remove(coords); + par3World.setBlock(coords.posX, coords.posY, coords.posZ, ModBlocks.flower, par3World.rand.nextInt(16), 1 | 2); + } + par1ItemStack.stackSize--; + } else { + for(int i = 0; i < 15; i++) { + double x = par4 - range + par3World.rand.nextInt(range * 2 + 1) + Math.random(); + double y = par5 + 1; + double z = par6 - range + par3World.rand.nextInt(range * 2 + 1) + Math.random(); + float red = (float) Math.random(); + float green = (float) Math.random(); + float blue = (float) Math.random(); + Botania.proxy.wispFX(par3World, x, y, z, red, green, blue, 0.15F + (float) Math.random() * 0.25F, -(float) Math.random() * 0.1F - 0.05F); + } + } - return true; - } + return true; + } } diff --git a/src/main/java/vazkii/botania/common/item/ItemFlowerBag.java b/src/main/java/vazkii/botania/common/item/ItemFlowerBag.java index 1fee5adac4..a57e00bfbb 100644 --- a/src/main/java/vazkii/botania/common/item/ItemFlowerBag.java +++ b/src/main/java/vazkii/botania/common/item/ItemFlowerBag.java @@ -2,15 +2,14 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Mar 16, 2015, 6:43:33 PM (GMT)] */ package vazkii.botania.common.item; -import cpw.mods.fml.common.eventhandler.SubscribeEvent; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.inventory.IInventory; import net.minecraft.item.Item; @@ -29,134 +28,132 @@ import vazkii.botania.common.core.helper.ItemNBTHelper; import vazkii.botania.common.lib.LibGuiIDs; import vazkii.botania.common.lib.LibItemNames; +import cpw.mods.fml.common.eventhandler.SubscribeEvent; public class ItemFlowerBag extends ItemMod { - private static final String TAG_ITEMS = "InvItems"; - private static final String TAG_SLOT = "Slot"; - - public ItemFlowerBag() { - setUnlocalizedName(LibItemNames.FLOWER_BAG); - setMaxStackSize(1); - MinecraftForge.EVENT_BUS.register(this); - } - - @SubscribeEvent - public void onPickupItem(EntityItemPickupEvent event) { - ItemStack stack = event.item.getEntityItem(); - if (stack.getItem() == Item.getItemFromBlock(ModBlocks.flower) && stack.stackSize > 0) { - int color = stack.getItemDamage(); - if (color > 15) return; - - for (int i = 0; i < event.entityPlayer.inventory.getSizeInventory(); i++) { - if (i == event.entityPlayer.inventory.currentItem) continue; // prevent item deletion - - ItemStack invStack = event.entityPlayer.inventory.getStackInSlot(i); - if (invStack != null && invStack.getItem() == this) { - ItemStack[] bagInv = loadStacks(invStack); - ItemStack stackAt = bagInv[color]; - boolean didChange = false; - if (stackAt == null) { - bagInv[color] = stack.copy(); - stack.stackSize = 0; - didChange = true; - } else { - int stackAtSize = stackAt.stackSize; - int stackSize = stack.stackSize; - int spare = 64 - stackAtSize; - int pass = Math.min(spare, stackSize); - if (pass > 0) { - stackAt.stackSize += pass; - stack.stackSize -= pass; - didChange = true; - } - } - - if (didChange) setStacks(invStack, bagInv); - } - - if (stack.stackSize == 0) return; - } - } - } - - @Override - public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer player) { - player.openGui(Botania.instance, LibGuiIDs.FLOWER_BAG, world, 0, 0, 0); - return stack; - } - - @Override - public boolean onItemUse( - ItemStack stack, - EntityPlayer player, - World world, - int x, - int y, - int z, - int s, - float xs, - float ys, - float zs) { - TileEntity tile = world.getTileEntity(x, y, z); - if (tile != null && tile instanceof IInventory) { - if (!world.isRemote) { - ForgeDirection side = ForgeDirection.getOrientation(s); - IInventory inv = (IInventory) tile; - ItemStack[] stacks = loadStacks(stack); - ItemStack[] newStacks = new ItemStack[stacks.length]; - boolean putAny = false; - - int i = 0; - for (ItemStack petal : stacks) { - if (petal != null) { - int count = InventoryHelper.testInventoryInsertion(inv, petal, side); - InventoryHelper.insertItemIntoInventory(inv, petal, side, -1); - - ItemStack newPetal = petal.copy(); - if (newPetal.stackSize == 0) newPetal = null; - - newStacks[i] = newPetal; - putAny |= count > 0; - } - - i++; - } - - setStacks(stack, newStacks); - if (putAny && inv instanceof TileEntityChest) { - inv = InventoryHelper.getInventory(inv); - player.displayGUIChest(inv); - } - } - - return true; - } - return false; - } - - public static ItemStack[] loadStacks(ItemStack stack) { - NBTTagList var2 = ItemNBTHelper.getList(stack, TAG_ITEMS, 10, false); - ItemStack[] inventorySlots = new ItemStack[16]; - for (int var3 = 0; var3 < var2.tagCount(); ++var3) { - NBTTagCompound var4 = var2.getCompoundTagAt(var3); - byte var5 = var4.getByte(TAG_SLOT); - if (var5 >= 0 && var5 < inventorySlots.length) inventorySlots[var5] = ItemStack.loadItemStackFromNBT(var4); - } - - return inventorySlots; - } - - public static void setStacks(ItemStack stack, ItemStack[] inventorySlots) { - NBTTagList var2 = new NBTTagList(); - for (int var3 = 0; var3 < inventorySlots.length; ++var3) - if (inventorySlots[var3] != null) { - NBTTagCompound var4 = new NBTTagCompound(); - var4.setByte(TAG_SLOT, (byte) var3); - inventorySlots[var3].writeToNBT(var4); - var2.appendTag(var4); - } - - ItemNBTHelper.setList(stack, TAG_ITEMS, var2); - } + private static final String TAG_ITEMS = "InvItems"; + private static final String TAG_SLOT = "Slot"; + + public ItemFlowerBag() { + setUnlocalizedName(LibItemNames.FLOWER_BAG); + setMaxStackSize(1); + MinecraftForge.EVENT_BUS.register(this); + } + + @SubscribeEvent + public void onPickupItem(EntityItemPickupEvent event) { + ItemStack stack = event.item.getEntityItem(); + if(stack.getItem() == Item.getItemFromBlock(ModBlocks.flower) && stack.stackSize > 0) { + int color = stack.getItemDamage(); + if(color > 15) + return; + + for(int i = 0; i < event.entityPlayer.inventory.getSizeInventory(); i++) { + if(i == event.entityPlayer.inventory.currentItem) + continue; // prevent item deletion + + ItemStack invStack = event.entityPlayer.inventory.getStackInSlot(i); + if(invStack != null && invStack.getItem() == this) { + ItemStack[] bagInv = loadStacks(invStack); + ItemStack stackAt = bagInv[color]; + boolean didChange = false; + if(stackAt == null) { + bagInv[color] = stack.copy(); + stack.stackSize = 0; + didChange = true; + } else { + int stackAtSize = stackAt.stackSize; + int stackSize = stack.stackSize; + int spare = 64 - stackAtSize; + int pass = Math.min(spare, stackSize); + if(pass > 0) { + stackAt.stackSize += pass; + stack.stackSize -= pass; + didChange = true; + } + } + + if(didChange) + setStacks(invStack, bagInv); + } + + if(stack.stackSize == 0) + return; + } + } + } + + @Override + public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer player) { + player.openGui(Botania.instance, LibGuiIDs.FLOWER_BAG, world, 0, 0, 0); + return stack; + } + + @Override + public boolean onItemUse(ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int s, float xs, float ys, float zs) { + TileEntity tile = world.getTileEntity(x, y, z); + if(tile != null && tile instanceof IInventory) { + if(!world.isRemote) { + ForgeDirection side = ForgeDirection.getOrientation(s); + IInventory inv = (IInventory) tile; + ItemStack[] stacks = loadStacks(stack); + ItemStack[] newStacks = new ItemStack[stacks.length]; + boolean putAny = false; + + int i = 0; + for(ItemStack petal : stacks) { + if(petal != null) { + int count = InventoryHelper.testInventoryInsertion(inv, petal, side); + InventoryHelper.insertItemIntoInventory(inv, petal, side, -1); + + ItemStack newPetal = petal.copy(); + if(newPetal.stackSize == 0) + newPetal = null; + + newStacks[i] = newPetal; + putAny |= count > 0; + } + + i++; + } + + setStacks(stack, newStacks); + if(putAny && inv instanceof TileEntityChest) { + inv = InventoryHelper.getInventory(inv); + player.displayGUIChest(inv); + } + } + + return true; + } + return false; + } + + public static ItemStack[] loadStacks(ItemStack stack) { + NBTTagList var2 = ItemNBTHelper.getList(stack, TAG_ITEMS, 10, false); + ItemStack[] inventorySlots = new ItemStack[16]; + for(int var3 = 0; var3 < var2.tagCount(); ++var3) { + NBTTagCompound var4 = var2.getCompoundTagAt(var3); + byte var5 = var4.getByte(TAG_SLOT); + if(var5 >= 0 && var5 < inventorySlots.length) + inventorySlots[var5] = ItemStack.loadItemStackFromNBT(var4); + } + + return inventorySlots; + } + + public static void setStacks(ItemStack stack, ItemStack[] inventorySlots) { + NBTTagList var2 = new NBTTagList(); + for(int var3 = 0; var3 < inventorySlots.length; ++var3) + if(inventorySlots[var3] != null) { + NBTTagCompound var4 = new NBTTagCompound(); + var4.setByte(TAG_SLOT, (byte)var3); + inventorySlots[var3].writeToNBT(var4); + var2.appendTag(var4); + } + + ItemNBTHelper.setList(stack, TAG_ITEMS, var2); + } + } diff --git a/src/main/java/vazkii/botania/common/item/ItemGaiaHead.java b/src/main/java/vazkii/botania/common/item/ItemGaiaHead.java index 41de83f119..ec8205310f 100644 --- a/src/main/java/vazkii/botania/common/item/ItemGaiaHead.java +++ b/src/main/java/vazkii/botania/common/item/ItemGaiaHead.java @@ -24,88 +24,72 @@ public class ItemGaiaHead extends ItemMod { - public ItemGaiaHead() { - setUnlocalizedName(LibItemNames.GAIA_HEAD); - } - - // I couldn't deal with it. - @Override - public boolean onItemUse( - ItemStack stack, - EntityPlayer player, - World world, - int x, - int y, - int z, - int side, - float sideX, - float sideY, - float sideZ) { - // The side of the wall the head is being used on. - ForgeDirection sideDir = ForgeDirection.getOrientation(side); - - // If we can replace the block we're clicking on, then we'll go ahead - // and replace it (eg, snow). - if (world.getBlock(x, y, z).isReplaceable(world, x, y, z) && sideDir != ForgeDirection.DOWN) { - sideDir = ForgeDirection.UP; - y--; - } - - // Skulls can't be placed on the bottom side of a block. - if (sideDir == ForgeDirection.DOWN) return false; - - // If the side we're trying to place the skull on isn't solid, then - // we can't place it either. - if (!world.isSideSolid(x, y, z, sideDir)) return false; - - // Figure out where the skull actually goes based on the side we're placing it against. - switch (sideDir) { - case UP: - y++; - break; // If we're placing it on the top, then the skull goes 1 block above. - case NORTH: - z--; - break; // Placing it on the north side (Z- axis). - case SOUTH: - z++; - break; // Placing it on the south side (Z+ axis). - case WEST: - x--; - break; // Placing it on the west side (X- axis). - case EAST: - x++; - break; // Placing it on the east side (X+ axis). - default: - return false; // Oops, this shouldn't happen. - } - - // We can't place blocks as a measly client. - if (world.isRemote) return true; - - // If the skull says no, who are we to argue? - if (!ModBlocks.gaiaHead.canPlaceBlockOnSide(world, x, y, z, side)) return false; - - // Gaia head, instead of skull - world.setBlock(x, y, z, ModBlocks.gaiaHead, sideDir.ordinal(), 2); - int headAngle = 0; - - // If we place the skull on top of a block, we should also make it - // face the player by rotating it. - if (sideDir == ForgeDirection.UP) - headAngle = MathHelper.floor_double(player.rotationYaw * 16.0F / 360.0F + 0.5D) & 15; - - // Update the skull's orientation if it lets us. - TileEntity tileentity = world.getTileEntity(x, y, z); - - if (tileentity != null && tileentity instanceof TileEntitySkull) { - ((TileEntitySkull) tileentity).func_145903_a(headAngle); - ((BlockSkull) Blocks.skull).func_149965_a(world, x, y, z, (TileEntitySkull) tileentity); - } - - // Remove a head from the stack. - --stack.stackSize; - - // Call it a success and leave. - return true; - } + public ItemGaiaHead() { + setUnlocalizedName(LibItemNames.GAIA_HEAD); + } + + // I couldn't deal with it. + @Override + public boolean onItemUse(ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int side, float sideX, float sideY, float sideZ) { + // The side of the wall the head is being used on. + ForgeDirection sideDir = ForgeDirection.getOrientation(side); + + // If we can replace the block we're clicking on, then we'll go ahead + // and replace it (eg, snow). + if (world.getBlock(x, y, z).isReplaceable(world, x, y, z) && sideDir != ForgeDirection.DOWN) { + sideDir = ForgeDirection.UP; + y--; + } + + // Skulls can't be placed on the bottom side of a block. + if (sideDir == ForgeDirection.DOWN) + return false; + + // If the side we're trying to place the skull on isn't solid, then + // we can't place it either. + if (!world.isSideSolid(x, y, z, sideDir)) + return false; + + // Figure out where the skull actually goes based on the side we're placing it against. + switch(sideDir) { + case UP: y++; break; // If we're placing it on the top, then the skull goes 1 block above. + case NORTH: z--; break; // Placing it on the north side (Z- axis). + case SOUTH: z++; break; // Placing it on the south side (Z+ axis). + case WEST: x--; break; // Placing it on the west side (X- axis). + case EAST: x++; break; // Placing it on the east side (X+ axis). + default: return false; // Oops, this shouldn't happen. + } + + // We can't place blocks as a measly client. + if(world.isRemote) + return true; + + // If the skull says no, who are we to argue? + if (!ModBlocks.gaiaHead.canPlaceBlockOnSide(world, x, y, z, side)) + return false; + + // Gaia head, instead of skull + world.setBlock(x, y, z, ModBlocks.gaiaHead, sideDir.ordinal(), 2); + int headAngle = 0; + + // If we place the skull on top of a block, we should also make it + // face the player by rotating it. + if (sideDir == ForgeDirection.UP) + headAngle = MathHelper.floor_double(player.rotationYaw * 16.0F / 360.0F + 0.5D) & 15; + + // Update the skull's orientation if it lets us. + TileEntity tileentity = world.getTileEntity(x, y, z); + + if (tileentity != null && tileentity instanceof TileEntitySkull) { + ((TileEntitySkull) tileentity).func_145903_a(headAngle); + ((BlockSkull) Blocks.skull).func_149965_a(world, x, y, z, (TileEntitySkull) tileentity); + } + + // Remove a head from the stack. + --stack.stackSize; + + // Call it a success and leave. + return true; + } + } diff --git a/src/main/java/vazkii/botania/common/item/ItemGrassHorn.java b/src/main/java/vazkii/botania/common/item/ItemGrassHorn.java index f56edf2e8a..dec75518f9 100644 --- a/src/main/java/vazkii/botania/common/item/ItemGrassHorn.java +++ b/src/main/java/vazkii/botania/common/item/ItemGrassHorn.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Apr 11, 2014, 2:57:30 PM (GMT)] */ package vazkii.botania.common.item; @@ -14,6 +14,7 @@ import java.util.Collections; import java.util.List; import java.util.Random; + import net.minecraft.block.Block; import net.minecraft.block.BlockBush; import net.minecraft.client.renderer.texture.IIconRegister; @@ -37,142 +38,124 @@ public class ItemGrassHorn extends ItemMod { - private static final int SUBTYPES = 3; - IIcon[] icons; - IIcon vuvuzelaIcon; - - public ItemGrassHorn() { - super(); - setMaxStackSize(1); - setUnlocalizedName(LibItemNames.GRASS_HORN); - setHasSubtypes(true); - } - - @Override - public void getSubItems(Item item, CreativeTabs tab, List list) { - for (int i = 0; i < SUBTYPES; i++) list.add(new ItemStack(item, 1, i)); - } - - @Override - public void registerIcons(IIconRegister par1IconRegister) { - icons = new IIcon[SUBTYPES]; - for (int i = 0; i < icons.length; i++) icons[i] = IconHelper.forItem(par1IconRegister, this, i); - vuvuzelaIcon = IconHelper.forName(par1IconRegister, "vuvuzela"); - } - - @Override - public IIcon getIconIndex(ItemStack par1ItemStack) { - return par1ItemStack.getDisplayName().toLowerCase().contains("vuvuzela") - ? vuvuzelaIcon - : super.getIconIndex(par1ItemStack); - } - - @Override - public IIcon getIcon(ItemStack stack, int pass) { - return getIconIndex(stack); - } - - @Override - public IIcon getIconFromDamage(int par1) { - return icons[Math.min(icons.length - 1, par1)]; - } - - @Override - public String getUnlocalizedName(ItemStack par1ItemStack) { - return getUnlocalizedNameLazy(par1ItemStack) + par1ItemStack.getItemDamage(); - } - - String getUnlocalizedNameLazy(ItemStack par1ItemStack) { - return super.getUnlocalizedName(par1ItemStack); - } - - @Override - public EnumAction getItemUseAction(ItemStack par1ItemStack) { - return EnumAction.bow; - } - - @Override - public int getMaxItemUseDuration(ItemStack par1ItemStack) { - return 72000; - } - - @Override - public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer) { - par3EntityPlayer.setItemInUse(par1ItemStack, getMaxItemUseDuration(par1ItemStack)); - return par1ItemStack; - } - - @Override - public void onUsingTick(ItemStack stack, EntityPlayer player, int time) { - if (time != getMaxItemUseDuration(stack) && time % 5 == 0) - breakGrass(player.worldObj, stack, stack.getItemDamage(), (int) player.posX, (int) player.posY, (int) - player.posZ); - - if (!player.worldObj.isRemote) player.worldObj.playSoundAtEntity(player, "note.bassattack", 1F, 0.001F); - } - - public static void breakGrass(World world, ItemStack stack, int stackDmg, int srcx, int srcy, int srcz) { - EnumHornType type = EnumHornType.getTypeForMeta(stackDmg); - Random rand = new Random(srcx ^ srcy ^ srcz); - int range = 12 - stackDmg * 3; - int rangeY = 3 + stackDmg * 4; - List coords = new ArrayList(); - - for (int i = -range; i < range + 1; i++) - for (int j = -range; j < range + 1; j++) - for (int k = -rangeY; k < rangeY + 1; k++) { - int x = srcx + i; - int y = srcy + k; - int z = srcz + j; - - Block block = world.getBlock(x, y, z); - if (block instanceof IHornHarvestable - ? ((IHornHarvestable) block).canHornHarvest(world, x, y, z, stack, type) - : stackDmg == 0 - && block instanceof BlockBush - && !(block instanceof ISpecialFlower) - && (!(block instanceof IGrassHornExcempt) - || ((IGrassHornExcempt) block).canUproot(world, x, y, z)) - || stackDmg == 1 && block.isLeaves(world, x, y, z) - || stackDmg == 2 && block == Blocks.snow_layer) - coords.add(new ChunkCoordinates(x, y, z)); - } - - Collections.shuffle(coords, rand); - - int count = Math.min(coords.size(), 32 + stackDmg * 16); - for (int i = 0; i < count; i++) { - ChunkCoordinates currCoords = coords.get(i); - List items = new ArrayList(); - Block block = world.getBlock(currCoords.posX, currCoords.posY, currCoords.posZ); - int meta = world.getBlockMetadata(currCoords.posX, currCoords.posY, currCoords.posZ); - items.addAll(block.getDrops(world, currCoords.posX, currCoords.posY, currCoords.posZ, meta, 0)); - - if (block instanceof IHornHarvestable - && ((IHornHarvestable) block) - .hasSpecialHornHarvest( - world, currCoords.posX, currCoords.posY, currCoords.posZ, stack, type)) - ((IHornHarvestable) block) - .harvestByHorn(world, currCoords.posX, currCoords.posY, currCoords.posZ, stack, type); - else if (!world.isRemote) { - world.setBlockToAir(currCoords.posX, currCoords.posY, currCoords.posZ); - if (ConfigHandler.blockBreakParticles) - world.playAuxSFX( - 2001, - currCoords.posX, - currCoords.posY, - currCoords.posZ, - Block.getIdFromBlock(block) + (meta << 12)); - - for (ItemStack stack_ : items) - world.spawnEntityInWorld(new EntityItem( - world, currCoords.posX + 0.5, currCoords.posY + 0.5, currCoords.posZ + 0.5, stack_)); - } - } - } - - @Override - public boolean isFull3D() { - return true; - } + private static final int SUBTYPES = 3; + IIcon[] icons; + IIcon vuvuzelaIcon; + + public ItemGrassHorn() { + super(); + setMaxStackSize(1); + setUnlocalizedName(LibItemNames.GRASS_HORN); + setHasSubtypes(true); + } + + @Override + public void getSubItems(Item item, CreativeTabs tab, List list) { + for(int i = 0; i < SUBTYPES; i++) + list.add(new ItemStack(item, 1, i)); + } + + @Override + public void registerIcons(IIconRegister par1IconRegister) { + icons = new IIcon[SUBTYPES]; + for(int i = 0; i < icons.length; i++) + icons[i] = IconHelper.forItem(par1IconRegister, this, i); + vuvuzelaIcon = IconHelper.forName(par1IconRegister, "vuvuzela"); + } + + @Override + public IIcon getIconIndex(ItemStack par1ItemStack) { + return par1ItemStack.getDisplayName().toLowerCase().contains("vuvuzela") ? vuvuzelaIcon : super.getIconIndex(par1ItemStack); + } + + @Override + public IIcon getIcon(ItemStack stack, int pass) { + return getIconIndex(stack); + } + + @Override + public IIcon getIconFromDamage(int par1) { + return icons[Math.min(icons.length - 1, par1)]; + } + + @Override + public String getUnlocalizedName(ItemStack par1ItemStack) { + return getUnlocalizedNameLazy(par1ItemStack) + par1ItemStack.getItemDamage(); + } + + String getUnlocalizedNameLazy(ItemStack par1ItemStack) { + return super.getUnlocalizedName(par1ItemStack); + } + + @Override + public EnumAction getItemUseAction(ItemStack par1ItemStack) { + return EnumAction.bow; + } + + @Override + public int getMaxItemUseDuration(ItemStack par1ItemStack) { + return 72000; + } + + @Override + public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer) { + par3EntityPlayer.setItemInUse(par1ItemStack, getMaxItemUseDuration(par1ItemStack)); + return par1ItemStack; + } + + @Override + public void onUsingTick(ItemStack stack, EntityPlayer player, int time) { + if(time != getMaxItemUseDuration(stack) && time % 5 == 0) + breakGrass(player.worldObj, stack, stack.getItemDamage(), (int) player.posX, (int) player.posY, (int) player.posZ); + + if(!player.worldObj.isRemote) + player.worldObj.playSoundAtEntity(player, "note.bassattack", 1F, 0.001F); + } + + public static void breakGrass(World world, ItemStack stack, int stackDmg, int srcx, int srcy, int srcz) { + EnumHornType type = EnumHornType.getTypeForMeta(stackDmg); + Random rand = new Random(srcx ^ srcy ^ srcz); + int range = 12 - stackDmg * 3; + int rangeY = 3 + stackDmg * 4; + List coords = new ArrayList(); + + for(int i = -range; i < range + 1; i++) + for(int j = -range; j < range + 1; j++) + for(int k = -rangeY; k < rangeY + 1; k++) { + int x = srcx + i; + int y = srcy + k; + int z = srcz + j; + + Block block = world.getBlock(x, y, z); + if(block instanceof IHornHarvestable ? ((IHornHarvestable) block).canHornHarvest(world, x, y, z, stack, type) : stackDmg == 0 && block instanceof BlockBush && !(block instanceof ISpecialFlower) && (!(block instanceof IGrassHornExcempt) || ((IGrassHornExcempt) block).canUproot(world, x, y, z)) || stackDmg == 1 && block.isLeaves(world, x, y, z) || stackDmg == 2 && block == Blocks.snow_layer) + coords.add(new ChunkCoordinates(x, y, z)); + } + + Collections.shuffle(coords, rand); + + int count = Math.min(coords.size(), 32 + stackDmg * 16); + for(int i = 0; i < count; i++) { + ChunkCoordinates currCoords = coords.get(i); + List items = new ArrayList(); + Block block = world.getBlock(currCoords.posX, currCoords.posY, currCoords.posZ); + int meta = world.getBlockMetadata(currCoords.posX, currCoords.posY, currCoords.posZ); + items.addAll(block.getDrops(world, currCoords.posX, currCoords.posY, currCoords.posZ, meta, 0)); + + if(block instanceof IHornHarvestable && ((IHornHarvestable) block).hasSpecialHornHarvest(world, currCoords.posX, currCoords.posY, currCoords.posZ, stack, type)) + ((IHornHarvestable) block).harvestByHorn(world, currCoords.posX, currCoords.posY, currCoords.posZ, stack, type); + else if(!world.isRemote) { + world.setBlockToAir(currCoords.posX, currCoords.posY, currCoords.posZ); + if(ConfigHandler.blockBreakParticles) + world.playAuxSFX(2001, currCoords.posX, currCoords.posY, currCoords.posZ, Block.getIdFromBlock(block) + (meta << 12)); + + for(ItemStack stack_ : items) + world.spawnEntityInWorld(new EntityItem(world, currCoords.posX + 0.5, currCoords.posY + 0.5, currCoords.posZ + 0.5, stack_)); + } + } + } + + @Override + public boolean isFull3D() { + return true; + } } diff --git a/src/main/java/vazkii/botania/common/item/ItemGrassSeeds.java b/src/main/java/vazkii/botania/common/item/ItemGrassSeeds.java index 3ad3289cbd..b63033154d 100644 --- a/src/main/java/vazkii/botania/common/item/ItemGrassSeeds.java +++ b/src/main/java/vazkii/botania/common/item/ItemGrassSeeds.java @@ -2,20 +2,14 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Apr 9, 2014, 5:11:34 PM (GMT)] */ package vazkii.botania.common.item; -import cpw.mods.fml.common.FMLCommonHandler; -import cpw.mods.fml.common.eventhandler.SubscribeEvent; -import cpw.mods.fml.common.gameevent.TickEvent; -import cpw.mods.fml.common.gameevent.TickEvent.Phase; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; import java.util.ArrayList; import java.util.HashMap; import java.util.HashSet; @@ -24,6 +18,7 @@ import java.util.Map; import java.util.Random; import java.util.Set; + import net.minecraft.block.Block; import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.creativetab.CreativeTabs; @@ -39,361 +34,344 @@ import vazkii.botania.common.block.ModBlocks; import vazkii.botania.common.block.decor.IFloatingFlower.IslandType; import vazkii.botania.common.lib.LibItemNames; +import cpw.mods.fml.common.FMLCommonHandler; +import cpw.mods.fml.common.eventhandler.SubscribeEvent; +import cpw.mods.fml.common.gameevent.TickEvent; +import cpw.mods.fml.common.gameevent.TickEvent.Phase; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; public class ItemGrassSeeds extends ItemMod implements IFloatingFlowerVariant { - /** - * Represents a map of dimension IDs to a set of all block swappers - * active in that dimension. - */ - private static Map> blockSwappers = new HashMap>(); - - private static final IslandType[] ISLAND_TYPES = { - IslandType.GRASS, IslandType.PODZOL, IslandType.MYCEL, - IslandType.DRY, IslandType.GOLDEN, IslandType.VIVID, - IslandType.SCORCHED, IslandType.INFUSED, IslandType.MUTATED - }; - - private static final int SUBTYPES = 9; - IIcon[] icons; - - public ItemGrassSeeds() { - super(); - setUnlocalizedName(LibItemNames.GRASS_SEEDS); - setHasSubtypes(true); - FMLCommonHandler.instance().bus().register(this); - } - - @Override - public void getSubItems(Item par1, CreativeTabs par2, List par3) { - for (int i = 0; i < SUBTYPES; i++) par3.add(new ItemStack(par1, 1, i)); - } - - @Override - @SideOnly(Side.CLIENT) - public void registerIcons(IIconRegister par1IconRegister) { - icons = new IIcon[SUBTYPES]; - for (int i = 0; i < SUBTYPES; i++) icons[i] = IconHelper.forItem(par1IconRegister, this, i); - } - - @Override - @SideOnly(Side.CLIENT) - public IIcon getIconFromDamage(int par1) { - return icons[Math.min(icons.length - 1, par1)]; - } - - @Override - public String getUnlocalizedName(ItemStack stack) { - return super.getUnlocalizedName() + stack.getItemDamage(); - } - - @Override - public boolean onItemUse( - ItemStack par1ItemStack, - EntityPlayer par2EntityPlayer, - World par3World, - int par4, - int par5, - int par6, - int par7, - float par8, - float par9, - float par10) { - Block block = par3World.getBlock(par4, par5, par6); - int bmeta = par3World.getBlockMetadata(par4, par5, par6); - - if ((block == Blocks.dirt || block == Blocks.grass && par1ItemStack.getItemDamage() != 0) && bmeta == 0) { - int meta = par1ItemStack.getItemDamage(); - - BlockSwapper swapper = addBlockSwapper(par3World, par4, par5, par6, meta); - par3World.setBlock(par4, par5, par6, swapper.blockToSet, swapper.metaToSet, 1 | 2); - for (int i = 0; i < 50; i++) { - double x = (Math.random() - 0.5) * 3; - double y = Math.random() - 0.5 + 1; - double z = (Math.random() - 0.5) * 3; - - float r = 0F; - float g = 0.4F; - float b = 0F; - switch (meta) { - case 1: { - r = 0.5F; - g = 0.37F; - b = 0F; - break; - } - case 2: { - r = 0.27F; - g = 0F; - b = 0.33F; - break; - } - case 3: { - r = 0.4F; - g = 0.5F; - b = 0.05F; - break; - } - case 4: { - r = 0.75F; - g = 0.7F; - b = 0F; - break; - } - case 5: { - r = 0F; - g = 0.5F; - b = 0.1F; - break; - } - case 6: { - r = 0.75F; - g = 0F; - b = 0F; - break; - } - case 7: { - r = 0F; - g = 0.55F; - b = 0.55F; - break; - } - case 8: { - r = 0.4F; - g = 0.1F; - b = 0.4F; - break; - } - } - - float velMul = 0.025F; - - Botania.proxy.wispFX( - par3World, - par4 + 0.5 + x, - par5 + 0.5 + y, - par6 + 0.5 + z, - r, - g, - b, - (float) Math.random() * 0.15F + 0.15F, - (float) -x * velMul, - (float) -y * velMul, - (float) -z * velMul); - } - - par1ItemStack.stackSize--; - } - - return true; - } - - @SubscribeEvent - public void onTickEnd(TickEvent.WorldTickEvent event) { - // Block swapper updates should only occur on the server - if (event.world.isRemote) return; - - if (event.phase == Phase.END) { - int dim = event.world.provider.dimensionId; - if (blockSwappers.containsKey(dim)) { - Set swappers = blockSwappers.get(dim); - - Iterator iter = swappers.iterator(); - - while (iter.hasNext()) { - BlockSwapper next = iter.next(); - if (next == null || !next.tick()) iter.remove(); - } - } - } - } - - /** - * Adds a grass seed block swapper to the world at the provided positiona - * and with the provided meta (which designates the type of the grass - * being spread). - * - * Block swappers are only actually created on the server, so a client - * calling this method will recieve a marker block swapper which contains - * the provided information but is not ticked. - * @param world The world the swapper will be in. - * @param x The x-position of the swapper. - * @param y The y-position of the swapper. - * @param z The z-position of the swapper. - * @param meta The meta value representing the type of block being swapped. - * @return The created block swapper. - */ - private static BlockSwapper addBlockSwapper(World world, int x, int y, int z, int meta) { - BlockSwapper swapper = swapperFromMeta(world, x, y, z, meta); - - // Block swappers are only registered on the server - if (world.isRemote) return swapper; - - // If a set for the dimension doesn't exist, create it. - int dim = world.provider.dimensionId; - if (!blockSwappers.containsKey(dim)) blockSwappers.put(dim, new HashSet()); - - // Add the block swapper - blockSwappers.get(dim).add(swapper); - - return swapper; - } - - private static BlockSwapper swapperFromMeta(World world, int x, int y, int z, int meta) { - switch (meta) { - case 1: - return new BlockSwapper(world, new ChunkCoordinates(x, y, z), Blocks.dirt, 2); - case 2: - return new BlockSwapper(world, new ChunkCoordinates(x, y, z), Blocks.mycelium, 0); - case 3: - return new BlockSwapper(world, new ChunkCoordinates(x, y, z), ModBlocks.altGrass, 0); - case 4: - return new BlockSwapper(world, new ChunkCoordinates(x, y, z), ModBlocks.altGrass, 1); - case 5: - return new BlockSwapper(world, new ChunkCoordinates(x, y, z), ModBlocks.altGrass, 2); - case 6: - return new BlockSwapper(world, new ChunkCoordinates(x, y, z), ModBlocks.altGrass, 3); - case 7: - return new BlockSwapper(world, new ChunkCoordinates(x, y, z), ModBlocks.altGrass, 4); - case 8: - return new BlockSwapper(world, new ChunkCoordinates(x, y, z), ModBlocks.altGrass, 5); - default: - return new BlockSwapper(world, new ChunkCoordinates(x, y, z), Blocks.grass, 0); - } - } - - /** - * A block swapper for the Pasture Seeds, which swaps dirt and grass blocks - * centered around a provided point to a provided block/metadata. - */ - private static class BlockSwapper { - - /** - * The range of the block swapper, in blocks. - */ - public static final int RANGE = 3; - - /** - * The range around which a block can spread in a single tick. - */ - public static final int TICK_RANGE = 1; - - private final World world; - private final Random rand; - private final Block blockToSet; - private final int metaToSet; - - private ChunkCoordinates startCoords; - private int ticksExisted = 0; - - /** - * Constructs a new block swapper with the provided world, starting - * coordinates, target block, and target metadata. - * @param world The world to swap blocks in. - * @param coords The central coordinates to swap blocks around. - * @param block The target block to swap dirt and grass to. - * @param meta The metadata of the target block to swap dirt and grass to. - */ - public BlockSwapper(World world, ChunkCoordinates coords, Block block, int meta) { - this.world = world; - this.blockToSet = block; - this.metaToSet = meta; - this.rand = new Random(coords.posX ^ coords.posY ^ coords.posZ); - this.startCoords = coords; - } - - /** - * Ticks this block swapper, allowing it to make an action during - * this game tick. This method should return "false" when the swapper - * has finished operation and should be removed from the world. - * @return true if the swapper should continue to exist, false if it - * should be removed. - */ - public boolean tick() { - ++ticksExisted; - - // Go through all blocks in the specified RANGE, and then - // try and spread around that block if it is our target block already - for (int i = -RANGE; i <= RANGE; i++) { - for (int j = -RANGE; j <= RANGE; j++) { - int x = startCoords.posX + i; - int y = startCoords.posY; - int z = startCoords.posZ + j; - Block block = world.getBlock(x, y, z); - int meta = world.getBlockMetadata(x, y, z); - - if (block == blockToSet && meta == metaToSet) { - // Only make changes every 20 ticks - if (ticksExisted % 20 != 0) continue; - - tickBlock(x, y, z); - } - } - } - - // This swapper should exist for 80 ticks - return ticksExisted < 80; - } - - /** - * Tick a specific block position, finding the valid blocks - * immediately adjacent to it and then replacing one at random. - * @param x The x-coordinate to use. - * @param y The y-coordinate to use. - * @param z The z-coordinate to use. - */ - public void tickBlock(int x, int y, int z) { - List validCoords = new ArrayList(); - - // Go around this block and aggregate valid blocks. - for (int xOffset = -TICK_RANGE; xOffset <= TICK_RANGE; xOffset++) { - for (int zOffset = -TICK_RANGE; zOffset <= TICK_RANGE; zOffset++) { - // Skip the current block - if (xOffset == 0 && zOffset == 0) continue; - - if (isValidSwapPosition(x + xOffset, y, z + zOffset)) - validCoords.add(new ChunkCoordinates(x + xOffset, y, z + zOffset)); - } - } - - // If we can make changes, and have at least 1 block to swap, - // then swap a random block from the valid blocks we could swap. - if (!validCoords.isEmpty() && !world.isRemote) { - ChunkCoordinates toSwap = validCoords.get(rand.nextInt(validCoords.size())); - - world.setBlock(toSwap.posX, toSwap.posY, toSwap.posZ, blockToSet, metaToSet, 1 | 2); - } - } - - /** - * Determines if a given position is a valid location to spread to, which - * means that the block must be either dirt or grass (with meta 0), - * and have a block above it which does not block grass growth. - * @param x The x-coordinate to check. - * @param y The y-coordinate to check. - * @param z The z-coordinate to check. - * @return True if the position is valid to swap, false otherwise. - */ - public boolean isValidSwapPosition(int x, int y, int z) { - Block block = world.getBlock(x, y, z); - int meta = world.getBlockMetadata(x, y, z); - - Block aboveBlock = world.getBlock(x, y + 1, z); - - // Valid blocks to spread to are either dirt or grass, and do not - // have blocks which block grass growth. - - // See http://minecraft.gamepedia.com/Grass_Block - // The major rule is that a block which reduces light - // levels by 2 or more blocks grass growth. - - return (block == Blocks.dirt || block == Blocks.grass) - && (meta == 0) - && (aboveBlock.getLightOpacity(world, x, y, z) <= 1); - } - } - - public IslandType getIslandType(ItemStack stack) { - return ISLAND_TYPES[Math.min(stack.getItemDamage(), ISLAND_TYPES.length - 1)]; - } + /** + * Represents a map of dimension IDs to a set of all block swappers + * active in that dimension. + */ + private static Map> blockSwappers = new HashMap>(); + + private static final IslandType[] ISLAND_TYPES = { + IslandType.GRASS, IslandType.PODZOL, IslandType.MYCEL, + IslandType.DRY, IslandType.GOLDEN, IslandType.VIVID, + IslandType.SCORCHED, IslandType.INFUSED, IslandType.MUTATED + }; + + private static final int SUBTYPES = 9; + IIcon[] icons; + + public ItemGrassSeeds() { + super(); + setUnlocalizedName(LibItemNames.GRASS_SEEDS); + setHasSubtypes(true); + FMLCommonHandler.instance().bus().register(this); + } + + @Override + public void getSubItems(Item par1, CreativeTabs par2, List par3) { + for(int i = 0; i < SUBTYPES; i++) + par3.add(new ItemStack(par1, 1, i)); + } + + @Override + @SideOnly(Side.CLIENT) + public void registerIcons(IIconRegister par1IconRegister) { + icons = new IIcon[SUBTYPES]; + for(int i = 0; i < SUBTYPES; i++) + icons[i] = IconHelper.forItem(par1IconRegister, this, i); + } + + @Override + @SideOnly(Side.CLIENT) + public IIcon getIconFromDamage(int par1) { + return icons[Math.min(icons.length - 1, par1)]; + } + + @Override + public String getUnlocalizedName(ItemStack stack) { + return super.getUnlocalizedName() + stack.getItemDamage(); + } + + @Override + public boolean onItemUse(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, World par3World, int par4, int par5, int par6, int par7, float par8, float par9, float par10) { + Block block = par3World.getBlock(par4, par5, par6); + int bmeta = par3World.getBlockMetadata(par4, par5, par6); + + if((block == Blocks.dirt || block == Blocks.grass && par1ItemStack.getItemDamage() != 0) && bmeta == 0) { + int meta = par1ItemStack.getItemDamage(); + + BlockSwapper swapper = addBlockSwapper(par3World, par4, par5, par6, meta); + par3World.setBlock(par4, par5, par6, swapper.blockToSet, swapper.metaToSet, 1 | 2); + for(int i = 0; i < 50; i++) { + double x = (Math.random() - 0.5) * 3; + double y = Math.random() - 0.5 + 1; + double z = (Math.random() - 0.5) * 3; + + float r = 0F; + float g = 0.4F; + float b = 0F; + switch(meta) { + case 1: { + r = 0.5F; + g = 0.37F; + b = 0F; + break; + } + case 2: { + r = 0.27F; + g = 0F; + b = 0.33F; + break; + } + case 3: { + r = 0.4F; + g = 0.5F; + b = 0.05F; + break; + } + case 4: { + r = 0.75F; + g = 0.7F; + b = 0F; + break; + } + case 5: { + r = 0F; + g = 0.5F; + b = 0.1F; + break; + } + case 6: { + r = 0.75F; + g = 0F; + b = 0F; + break; + } + case 7: { + r = 0F; + g = 0.55F; + b = 0.55F; + break; + } + case 8: { + r = 0.4F; + g = 0.1F; + b = 0.4F; + break; + } + } + + float velMul = 0.025F; + + Botania.proxy.wispFX(par3World, par4 + 0.5 + x, par5 + 0.5 + y, par6 + 0.5 + z, r, g, b, (float) Math.random() * 0.15F + 0.15F, (float) -x * velMul, (float) -y * velMul, (float) -z * velMul); + } + + par1ItemStack.stackSize--; + } + + return true; + } + + @SubscribeEvent + public void onTickEnd(TickEvent.WorldTickEvent event) { + // Block swapper updates should only occur on the server + if(event.world.isRemote) + return; + + if(event.phase == Phase.END) { + int dim = event.world.provider.dimensionId; + if(blockSwappers.containsKey(dim)) { + Set swappers = blockSwappers.get(dim); + + Iterator iter = swappers.iterator(); + + while(iter.hasNext()) { + BlockSwapper next = iter.next(); + if(next == null || !next.tick()) + iter.remove(); + } + } + } + } + + /** + * Adds a grass seed block swapper to the world at the provided positiona + * and with the provided meta (which designates the type of the grass + * being spread). + * + * Block swappers are only actually created on the server, so a client + * calling this method will recieve a marker block swapper which contains + * the provided information but is not ticked. + * @param world The world the swapper will be in. + * @param x The x-position of the swapper. + * @param y The y-position of the swapper. + * @param z The z-position of the swapper. + * @param meta The meta value representing the type of block being swapped. + * @return The created block swapper. + */ + private static BlockSwapper addBlockSwapper(World world, int x, int y, int z, int meta) { + BlockSwapper swapper = swapperFromMeta(world, x, y, z, meta); + + // Block swappers are only registered on the server + if(world.isRemote) + return swapper; + + // If a set for the dimension doesn't exist, create it. + int dim = world.provider.dimensionId; + if(!blockSwappers.containsKey(dim)) + blockSwappers.put(dim, new HashSet()); + + // Add the block swapper + blockSwappers.get(dim).add(swapper); + + return swapper; + } + + private static BlockSwapper swapperFromMeta(World world, int x, int y, int z, int meta) { + switch(meta) { + case 1 : return new BlockSwapper(world, new ChunkCoordinates(x, y, z), Blocks.dirt, 2); + case 2 : return new BlockSwapper(world, new ChunkCoordinates(x, y, z), Blocks.mycelium, 0); + case 3 : return new BlockSwapper(world, new ChunkCoordinates(x, y, z), ModBlocks.altGrass, 0); + case 4 : return new BlockSwapper(world, new ChunkCoordinates(x, y, z), ModBlocks.altGrass, 1); + case 5 : return new BlockSwapper(world, new ChunkCoordinates(x, y, z), ModBlocks.altGrass, 2); + case 6 : return new BlockSwapper(world, new ChunkCoordinates(x, y, z), ModBlocks.altGrass, 3); + case 7 : return new BlockSwapper(world, new ChunkCoordinates(x, y, z), ModBlocks.altGrass, 4); + case 8 : return new BlockSwapper(world, new ChunkCoordinates(x, y, z), ModBlocks.altGrass, 5); + default : return new BlockSwapper(world, new ChunkCoordinates(x, y, z), Blocks.grass, 0); + } + } + + /** + * A block swapper for the Pasture Seeds, which swaps dirt and grass blocks + * centered around a provided point to a provided block/metadata. + */ + private static class BlockSwapper { + + /** + * The range of the block swapper, in blocks. + */ + public static final int RANGE = 3; + + /** + * The range around which a block can spread in a single tick. + */ + public static final int TICK_RANGE = 1; + + private final World world; + private final Random rand; + private final Block blockToSet; + private final int metaToSet; + + private ChunkCoordinates startCoords; + private int ticksExisted = 0; + + /** + * Constructs a new block swapper with the provided world, starting + * coordinates, target block, and target metadata. + * @param world The world to swap blocks in. + * @param coords The central coordinates to swap blocks around. + * @param block The target block to swap dirt and grass to. + * @param meta The metadata of the target block to swap dirt and grass to. + */ + public BlockSwapper(World world, ChunkCoordinates coords, Block block, int meta) { + this.world = world; + this.blockToSet = block; + this.metaToSet = meta; + this.rand = new Random(coords.posX ^ coords.posY ^ coords.posZ); + this.startCoords = coords; + } + + /** + * Ticks this block swapper, allowing it to make an action during + * this game tick. This method should return "false" when the swapper + * has finished operation and should be removed from the world. + * @return true if the swapper should continue to exist, false if it + * should be removed. + */ + public boolean tick() { + ++ticksExisted; + + // Go through all blocks in the specified RANGE, and then + // try and spread around that block if it is our target block already + for(int i = -RANGE; i <= RANGE; i++) { + for(int j = -RANGE; j <= RANGE; j++) { + int x = startCoords.posX + i; + int y = startCoords.posY; + int z = startCoords.posZ + j; + Block block = world.getBlock(x, y, z); + int meta = world.getBlockMetadata(x, y, z); + + if(block == blockToSet && meta == metaToSet) { + // Only make changes every 20 ticks + if(ticksExisted % 20 != 0) continue; + + tickBlock(x, y, z); + } + } + } + + // This swapper should exist for 80 ticks + return ticksExisted < 80; + } + + /** + * Tick a specific block position, finding the valid blocks + * immediately adjacent to it and then replacing one at random. + * @param x The x-coordinate to use. + * @param y The y-coordinate to use. + * @param z The z-coordinate to use. + */ + public void tickBlock(int x, int y, int z) { + List validCoords = new ArrayList(); + + // Go around this block and aggregate valid blocks. + for(int xOffset = -TICK_RANGE; xOffset <= TICK_RANGE; xOffset++) { + for(int zOffset = -TICK_RANGE; zOffset <= TICK_RANGE; zOffset++) { + // Skip the current block + if(xOffset == 0 && zOffset == 0) continue; + + if(isValidSwapPosition(x + xOffset, y, z + zOffset)) + validCoords.add(new ChunkCoordinates(x + xOffset, y, z + zOffset)); + } + } + + // If we can make changes, and have at least 1 block to swap, + // then swap a random block from the valid blocks we could swap. + if(!validCoords.isEmpty() && !world.isRemote) { + ChunkCoordinates toSwap = validCoords.get(rand.nextInt(validCoords.size())); + + world.setBlock(toSwap.posX, toSwap.posY, toSwap.posZ, blockToSet, metaToSet, 1 | 2); + } + } + + /** + * Determines if a given position is a valid location to spread to, which + * means that the block must be either dirt or grass (with meta 0), + * and have a block above it which does not block grass growth. + * @param x The x-coordinate to check. + * @param y The y-coordinate to check. + * @param z The z-coordinate to check. + * @return True if the position is valid to swap, false otherwise. + */ + public boolean isValidSwapPosition(int x, int y, int z) { + Block block = world.getBlock(x, y, z); + int meta = world.getBlockMetadata(x, y, z); + + Block aboveBlock = world.getBlock(x, y + 1, z); + + // Valid blocks to spread to are either dirt or grass, and do not + // have blocks which block grass growth. + + // See http://minecraft.gamepedia.com/Grass_Block + // The major rule is that a block which reduces light + // levels by 2 or more blocks grass growth. + + return (block == Blocks.dirt || block == Blocks.grass) + && (meta == 0) + && (aboveBlock.getLightOpacity(world, x, y, z) <= 1); + } + } + + public IslandType getIslandType(ItemStack stack) { + return ISLAND_TYPES[Math.min(stack.getItemDamage(), ISLAND_TYPES.length - 1)]; + } + } diff --git a/src/main/java/vazkii/botania/common/item/ItemKeepIvy.java b/src/main/java/vazkii/botania/common/item/ItemKeepIvy.java index b48bbe2fcd..663dd323a0 100644 --- a/src/main/java/vazkii/botania/common/item/ItemKeepIvy.java +++ b/src/main/java/vazkii/botania/common/item/ItemKeepIvy.java @@ -2,20 +2,17 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Mar 31, 2015, 9:11:23 PM (GMT)] */ package vazkii.botania.common.item; -import cpw.mods.fml.common.FMLCommonHandler; -import cpw.mods.fml.common.eventhandler.SubscribeEvent; -import cpw.mods.fml.common.gameevent.PlayerEvent.PlayerRespawnEvent; -import cpw.mods.fml.common.registry.GameRegistry; import java.util.ArrayList; import java.util.List; + import net.minecraft.entity.item.EntityItem; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; @@ -27,75 +24,81 @@ import vazkii.botania.common.core.helper.ItemNBTHelper; import vazkii.botania.common.crafting.recipe.KeepIvyRecipe; import vazkii.botania.common.lib.LibItemNames; +import cpw.mods.fml.common.FMLCommonHandler; +import cpw.mods.fml.common.eventhandler.SubscribeEvent; +import cpw.mods.fml.common.gameevent.PlayerEvent.PlayerRespawnEvent; +import cpw.mods.fml.common.registry.GameRegistry; public class ItemKeepIvy extends ItemMod { - public static final String TAG_KEEP = "Botania_keepIvy"; - - private static final String TAG_PLAYER_KEPT_DROPS = "Botania_playerKeptDrops"; - private static final String TAG_DROP_COUNT = "dropCount"; - private static final String TAG_DROP_PREFIX = "dropPrefix"; - - public ItemKeepIvy() { - setUnlocalizedName(LibItemNames.KEEP_IVY); - GameRegistry.addRecipe(new KeepIvyRecipe()); - RecipeSorter.register("botania:keepIvy", KeepIvyRecipe.class, Category.SHAPELESS, ""); - MinecraftForge.EVENT_BUS.register(this); - FMLCommonHandler.instance().bus().register(this); - } - - @SubscribeEvent - public void onPlayerDrops(PlayerDropsEvent event) { - List keeps = new ArrayList(); - for (EntityItem item : event.drops) { - ItemStack stack = item.getEntityItem(); - if (stack != null && ItemNBTHelper.detectNBT(stack) && ItemNBTHelper.getBoolean(stack, TAG_KEEP, false)) - keeps.add(item); - } - - if (keeps.size() > 0) { - event.drops.removeAll(keeps); - - NBTTagCompound cmp = new NBTTagCompound(); - cmp.setInteger(TAG_DROP_COUNT, keeps.size()); - - int i = 0; - for (EntityItem keep : keeps) { - ItemStack stack = keep.getEntityItem(); - NBTTagCompound cmp1 = new NBTTagCompound(); - stack.writeToNBT(cmp1); - cmp.setTag(TAG_DROP_PREFIX + i, cmp1); - i++; - } - - NBTTagCompound data = event.entityPlayer.getEntityData(); - if (!data.hasKey(EntityPlayer.PERSISTED_NBT_TAG)) - data.setTag(EntityPlayer.PERSISTED_NBT_TAG, new NBTTagCompound()); - - NBTTagCompound persist = data.getCompoundTag(EntityPlayer.PERSISTED_NBT_TAG); - persist.setTag(TAG_PLAYER_KEPT_DROPS, cmp); - } - } - - @SubscribeEvent - public void onPlayerRespawn(PlayerRespawnEvent event) { - NBTTagCompound data = event.player.getEntityData(); - if (data.hasKey(EntityPlayer.PERSISTED_NBT_TAG)) { - NBTTagCompound cmp = data.getCompoundTag(EntityPlayer.PERSISTED_NBT_TAG); - NBTTagCompound cmp1 = cmp.getCompoundTag(TAG_PLAYER_KEPT_DROPS); - - int count = cmp1.getInteger(TAG_DROP_COUNT); - for (int i = 0; i < count; i++) { - NBTTagCompound cmp2 = cmp1.getCompoundTag(TAG_DROP_PREFIX + i); - ItemStack stack = ItemStack.loadItemStackFromNBT(cmp2); - if (stack != null) { - ItemStack copy = stack.copy(); - ItemNBTHelper.setBoolean(copy, TAG_KEEP, false); - event.player.inventory.addItemStackToInventory(copy); - } - } - - cmp.setTag(TAG_PLAYER_KEPT_DROPS, new NBTTagCompound()); - } - } + public static final String TAG_KEEP = "Botania_keepIvy"; + + private static final String TAG_PLAYER_KEPT_DROPS = "Botania_playerKeptDrops"; + private static final String TAG_DROP_COUNT = "dropCount"; + private static final String TAG_DROP_PREFIX = "dropPrefix"; + + public ItemKeepIvy() { + setUnlocalizedName(LibItemNames.KEEP_IVY); + GameRegistry.addRecipe(new KeepIvyRecipe()); + RecipeSorter.register("botania:keepIvy", KeepIvyRecipe.class, Category.SHAPELESS, ""); + MinecraftForge.EVENT_BUS.register(this); + FMLCommonHandler.instance().bus().register(this); + } + + @SubscribeEvent + public void onPlayerDrops(PlayerDropsEvent event) { + List keeps = new ArrayList(); + for(EntityItem item : event.drops) { + ItemStack stack = item.getEntityItem(); + if(stack != null && ItemNBTHelper.detectNBT(stack) && ItemNBTHelper.getBoolean(stack, TAG_KEEP, false)) + keeps.add(item); + } + + if(keeps.size() > 0) { + event.drops.removeAll(keeps); + + + NBTTagCompound cmp = new NBTTagCompound(); + cmp.setInteger(TAG_DROP_COUNT, keeps.size()); + + int i = 0; + for(EntityItem keep : keeps) { + ItemStack stack = keep.getEntityItem(); + NBTTagCompound cmp1 = new NBTTagCompound(); + stack.writeToNBT(cmp1); + cmp.setTag(TAG_DROP_PREFIX + i, cmp1); + i++; + } + + NBTTagCompound data = event.entityPlayer.getEntityData(); + if(!data.hasKey(EntityPlayer.PERSISTED_NBT_TAG)) + data.setTag(EntityPlayer.PERSISTED_NBT_TAG, new NBTTagCompound()); + + NBTTagCompound persist = data.getCompoundTag(EntityPlayer.PERSISTED_NBT_TAG); + persist.setTag(TAG_PLAYER_KEPT_DROPS, cmp); + } + } + + @SubscribeEvent + public void onPlayerRespawn(PlayerRespawnEvent event) { + NBTTagCompound data = event.player.getEntityData(); + if(data.hasKey(EntityPlayer.PERSISTED_NBT_TAG)) { + NBTTagCompound cmp = data.getCompoundTag(EntityPlayer.PERSISTED_NBT_TAG); + NBTTagCompound cmp1 = cmp.getCompoundTag(TAG_PLAYER_KEPT_DROPS); + + int count = cmp1.getInteger(TAG_DROP_COUNT); + for(int i = 0; i < count; i++) { + NBTTagCompound cmp2 = cmp1.getCompoundTag(TAG_DROP_PREFIX + i); + ItemStack stack = ItemStack.loadItemStackFromNBT(cmp2); + if(stack != null) { + ItemStack copy = stack.copy(); + ItemNBTHelper.setBoolean(copy, TAG_KEEP, false); + event.player.inventory.addItemStackToInventory(copy); + } + } + + cmp.setTag(TAG_PLAYER_KEPT_DROPS, new NBTTagCompound()); + } + } + } diff --git a/src/main/java/vazkii/botania/common/item/ItemLaputaShard.java b/src/main/java/vazkii/botania/common/item/ItemLaputaShard.java index 0b11999fc8..fa7504baf2 100644 --- a/src/main/java/vazkii/botania/common/item/ItemLaputaShard.java +++ b/src/main/java/vazkii/botania/common/item/ItemLaputaShard.java @@ -2,15 +2,16 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jul 19, 2014, 10:46:14 PM (GMT)] */ package vazkii.botania.common.item; import java.util.List; + import net.minecraft.block.Block; import net.minecraft.block.BlockFalling; import net.minecraft.creativetab.CreativeTabs; @@ -36,258 +37,233 @@ public class ItemLaputaShard extends ItemMod implements ILensEffect, ITinyPlanetExcempt { - private static final String TAG_BLOCK = "_block"; - private static final String TAG_META = "_meta"; - private static final String TAG_TILE = "_tile"; - private static final String TAG_X = "_x"; - private static final String TAG_Y = "_y"; - private static final String TAG_Y_START = "_yStart"; - private static final String TAG_Z = "_z"; - private static final String TAG_POINTY = "_pointy"; - private static final String TAG_HEIGHTSCALE = "_heightscale"; - private static final String TAG_ITERATION_I = "iterationI"; - private static final String TAG_ITERATION_J = "iterationJ"; - private static final String TAG_ITERATION_K = "iterationK"; - - private static final int BASE_RANGE = 14; - private static final int BASE_OFFSET = 42; - - public ItemLaputaShard() { - setUnlocalizedName(LibItemNames.LAPUTA_SHARD); - setHasSubtypes(true); - } - - @Override - public void getSubItems(Item item, CreativeTabs tab, List list) { - super.getSubItems(item, tab, list); - for (int i = 0; i < 4; i++) list.add(new ItemStack(item, 1, (i + 1) * 5 - 1)); - } - - @Override - public void addInformation(ItemStack stack, EntityPlayer player, List list, boolean adv) { - list.add(String.format( - StatCollector.translateToLocal("botaniamisc.shardLevel"), - StatCollector.translateToLocal("botania.roman" + (stack.getItemDamage() + 1)))); - } - - @Override - public boolean onItemUse( - ItemStack par1ItemStack, - EntityPlayer par2EntityPlayer, - World par3World, - int par4, - int par5, - int par6, - int par7, - float par8, - float par9, - float par10) { - if (par5 < 160 && !par3World.provider.isHellWorld) { - par3World.playSound( - par4 + 0.5D, - par5 + 0.5D, - par6 + 0.5D, - "botania:laputaStart", - 1.0F + par3World.rand.nextFloat(), - par3World.rand.nextFloat() * 0.7F + 1.3F, - false); - spawnBurstFirst(par3World, par4, par5, par6, par1ItemStack); - par1ItemStack.stackSize--; - if (par1ItemStack.getItemDamage() == 19) par2EntityPlayer.addStat(ModAchievements.l20ShardUse, 1); - } - - return true; - } - - public void spawnBurstFirst(World world, int srcx, int srcy, int srcz, ItemStack lens) { - int range = BASE_RANGE + lens.getItemDamage(); - boolean pointy = world.rand.nextDouble() < 0.25; - double heightscale = (world.rand.nextDouble() + 0.5) * ((double) BASE_RANGE / (double) range); - spawnBurst(world, srcx, srcy, srcz, lens, pointy, heightscale); - } - - public void spawnBurst(World world, int srcx, int srcy, int srcz, ItemStack lens) { - boolean pointy = ItemNBTHelper.getBoolean(lens, TAG_POINTY, false); - double heightscale = ItemNBTHelper.getDouble(lens, TAG_HEIGHTSCALE, 1); - - spawnBurst(world, srcx, srcy, srcz, lens, pointy, heightscale); - } - - public void spawnBurst( - World world, int srcx, int srcy, int srcz, ItemStack lens, boolean pointy, double heightscale) { - int range = BASE_RANGE + lens.getItemDamage(); - - int i = ItemNBTHelper.getInt(lens, TAG_ITERATION_I, 0); - int j = ItemNBTHelper.getInt(lens, TAG_ITERATION_J, BASE_OFFSET - BASE_RANGE / 2); - int k = ItemNBTHelper.getInt(lens, TAG_ITERATION_K, 0); - - if (j <= -BASE_RANGE * 2) j = BASE_OFFSET - BASE_RANGE / 2; - if (k >= range * 2 + 1) k = 0; - - if (!world.isRemote) { - for (; i < range * 2 + 1; i++) { - for (; j > -BASE_RANGE * 2; j--) { - for (; k < range * 2 + 1; k++) { - int x = srcx - range + i; - int y = srcy - BASE_RANGE + j; - int z = srcz - range + k; - - if (inRange(x, y, z, srcx, srcy, srcz, range, heightscale, pointy)) { - Block block = world.getBlock(x, y, z); - if (!block.isAir(world, x, y, z) - && !block.isReplaceable(world, x, y, z) - && !(block instanceof BlockFalling) - && (!(block instanceof ILaputaImmobile) - || ((ILaputaImmobile) block).canMove(world, x, y, z)) - && block.getBlockHardness(world, x, y, z) != -1) { - int id = Block.getIdFromBlock(block); - int meta = world.getBlockMetadata(x, y, z); - TileEntity tile = world.getTileEntity(x, y, z); - - if (tile != null) { - TileEntity newTile = block.createTileEntity(world, meta); - world.setTileEntity(x, y, z, newTile); - } - world.setBlockToAir(x, y, z); - world.playAuxSFX(2001, x, y, z, id + (meta << 12)); - - ItemStack copyLens = new ItemStack(this, 1, lens.getItemDamage()); - ItemNBTHelper.setInt(copyLens, TAG_BLOCK, id); - ItemNBTHelper.setInt(copyLens, TAG_META, meta); - NBTTagCompound cmp = new NBTTagCompound(); - if (tile != null) tile.writeToNBT(cmp); - ItemNBTHelper.setCompound(copyLens, TAG_TILE, cmp); - ItemNBTHelper.setInt(copyLens, TAG_X, srcx); - ItemNBTHelper.setInt(copyLens, TAG_Y, srcy); - ItemNBTHelper.setInt(copyLens, TAG_Y_START, y); - ItemNBTHelper.setInt(copyLens, TAG_Z, srcz); - ItemNBTHelper.setBoolean(copyLens, TAG_POINTY, pointy); - ItemNBTHelper.setDouble(copyLens, TAG_HEIGHTSCALE, heightscale); - ItemNBTHelper.setInt(copyLens, TAG_ITERATION_I, i); - ItemNBTHelper.setInt(copyLens, TAG_ITERATION_J, j); - ItemNBTHelper.setInt(copyLens, TAG_ITERATION_K, k); - - EntityManaBurst burst = getBurst(world, x, y, z, copyLens); - world.spawnEntityInWorld(burst); - return; - } - } - } - k = 0; - } - j = BASE_OFFSET - BASE_RANGE / 2; - } - } - } - - private boolean inRange( - int x, int y, int z, int srcx, int srcy, int srcz, int range, double heightscale, boolean pointy) { - if (y >= srcy) return MathHelper.pointDistanceSpace(x, 0, z, srcx, 0, srcz) < range; - else if (!pointy) - return MathHelper.pointDistanceSpace(x, y / heightscale, z, srcx, srcy / heightscale, srcz) < range; - else return MathHelper.pointDistanceSpace(x, 0, z, srcx, 0, srcz) < range - (srcy - y) / heightscale; - } - - public EntityManaBurst getBurst(World world, int x, int y, int z, ItemStack stack) { - EntityManaBurst burst = new EntityManaBurst(world); - burst.posX = x + 0.5; - burst.posY = y + 0.5; - burst.posZ = z + 0.5; - - burst.setColor(0x00EAFF); - burst.setMana(1); - burst.setStartingMana(1); - burst.setMinManaLoss(0); - burst.setManaLossPerTick(0F); - burst.setGravity(0F); - burst.setMotion(0, 0.5, 0); - - burst.setSourceLens(stack); - return burst; - } - - @Override - public void apply(ItemStack stack, BurstProperties props) { - // NO-OP - } - - @Override - public boolean collideBurst( - IManaBurst burst, MovingObjectPosition pos, boolean isManaBlock, boolean dead, ItemStack stack) { - return false; - } - - @Override - public void updateBurst(IManaBurst burst, ItemStack stack) { - double speed = 0.35; - int targetDistance = BASE_OFFSET; - EntityThrowable entity = (EntityThrowable) burst; - if (!entity.worldObj.isRemote) { - entity.motionX = 0; - entity.motionY = speed; - entity.motionZ = 0; - - final int spawnTicks = 2; - final int placeTicks = net.minecraft.util.MathHelper.floor_double(targetDistance / speed); - - ItemStack lens = burst.getSourceLens(); - - if (burst.getTicksExisted() == spawnTicks) { - int x = ItemNBTHelper.getInt(lens, TAG_X, 0); - int y = ItemNBTHelper.getInt(lens, TAG_Y, -1); - int z = ItemNBTHelper.getInt(lens, TAG_Z, 0); - - if (y != -1) spawnBurst(entity.worldObj, x, y, z, lens); - } else if (burst.getTicksExisted() == placeTicks) { - int x = net.minecraft.util.MathHelper.floor_double(entity.posX); - int y = ItemNBTHelper.getInt(lens, TAG_Y_START, -1) + targetDistance; - int z = net.minecraft.util.MathHelper.floor_double(entity.posZ); - - if (entity.worldObj.isAirBlock(x, y, z)) { - int id = ItemNBTHelper.getInt(lens, TAG_BLOCK, 0); - Block block = Block.getBlockById(id); - int meta = ItemNBTHelper.getInt(lens, TAG_META, 0); - - TileEntity tile = null; - NBTTagCompound tilecmp = ItemNBTHelper.getCompound(lens, TAG_TILE, false); - if (tilecmp.hasKey("id")) tile = TileEntity.createAndLoadEntity(tilecmp); - - entity.worldObj.setBlock(x, y, z, block, meta, 1 | 2); - entity.worldObj.playAuxSFX(2001, x, y, z, id + (meta << 12)); - if (tile != null) { - tile.xCoord = x; - tile.yCoord = y; - tile.zCoord = z; - entity.worldObj.setTileEntity(x, y, z, tile); - } - } - - entity.setDead(); - } - } - } - - @Override - public boolean doParticles(IManaBurst burst, ItemStack stack) { - EntityThrowable entity = (EntityThrowable) burst; - ItemStack lens = burst.getSourceLens(); - int id = ItemNBTHelper.getInt(lens, TAG_BLOCK, 0); - Block.getBlockById(id); - int meta = ItemNBTHelper.getInt(lens, TAG_META, 0); - entity.worldObj.spawnParticle( - "blockcrack_" + id + "_" + meta, - entity.posX, - entity.posY, - entity.posZ, - entity.motionX, - entity.motionY, - entity.motionZ); - - return true; - } - - @Override - public boolean shouldPull(ItemStack stack) { - return false; - } + private static final String TAG_BLOCK = "_block"; + private static final String TAG_META = "_meta"; + private static final String TAG_TILE = "_tile"; + private static final String TAG_X = "_x"; + private static final String TAG_Y = "_y"; + private static final String TAG_Y_START = "_yStart"; + private static final String TAG_Z = "_z"; + private static final String TAG_POINTY = "_pointy"; + private static final String TAG_HEIGHTSCALE = "_heightscale"; + private static final String TAG_ITERATION_I = "iterationI"; + private static final String TAG_ITERATION_J = "iterationJ"; + private static final String TAG_ITERATION_K = "iterationK"; + + private static final int BASE_RANGE = 14; + private static final int BASE_OFFSET = 42; + + public ItemLaputaShard() { + setUnlocalizedName(LibItemNames.LAPUTA_SHARD); + setHasSubtypes(true); + } + + @Override + public void getSubItems(Item item, CreativeTabs tab, List list) { + super.getSubItems(item, tab, list); + for(int i = 0; i < 4; i++) + list.add(new ItemStack(item, 1, (i + 1) * 5 - 1)); + } + + @Override + public void addInformation(ItemStack stack, EntityPlayer player, List list, boolean adv) { + list.add(String.format(StatCollector.translateToLocal("botaniamisc.shardLevel"), StatCollector.translateToLocal("botania.roman" + (stack.getItemDamage() + 1)))); + } + + @Override + public boolean onItemUse(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, World par3World, int par4, int par5, int par6, int par7, float par8, float par9, float par10) { + if(par5 < 160 && !par3World.provider.isHellWorld) { + par3World.playSound(par4 + 0.5D, par5 + 0.5D, par6 + 0.5D, "botania:laputaStart", 1.0F + par3World.rand.nextFloat(), par3World.rand.nextFloat() * 0.7F + 1.3F, false); + spawnBurstFirst(par3World, par4, par5, par6, par1ItemStack); + par1ItemStack.stackSize--; + if(par1ItemStack.getItemDamage() == 19) + par2EntityPlayer.addStat(ModAchievements.l20ShardUse, 1); + } + + return true; + } + + public void spawnBurstFirst(World world, int srcx, int srcy, int srcz, ItemStack lens) { + int range = BASE_RANGE + lens.getItemDamage(); + boolean pointy = world.rand.nextDouble() < 0.25; + double heightscale = (world.rand.nextDouble() + 0.5) * ((double)BASE_RANGE / (double)range); + spawnBurst(world, srcx, srcy, srcz, lens, pointy, heightscale); + } + + public void spawnBurst(World world, int srcx, int srcy, int srcz, ItemStack lens) { + boolean pointy = ItemNBTHelper.getBoolean(lens, TAG_POINTY, false); + double heightscale = ItemNBTHelper.getDouble(lens, TAG_HEIGHTSCALE, 1); + + spawnBurst(world, srcx, srcy, srcz, lens, pointy, heightscale); + } + + public void spawnBurst(World world, int srcx, int srcy, int srcz, ItemStack lens, boolean pointy, double heightscale) { + int range = BASE_RANGE + lens.getItemDamage(); + + int i = ItemNBTHelper.getInt(lens, TAG_ITERATION_I, 0); + int j = ItemNBTHelper.getInt(lens, TAG_ITERATION_J, BASE_OFFSET - BASE_RANGE / 2); + int k = ItemNBTHelper.getInt(lens, TAG_ITERATION_K, 0); + + if(j <= -BASE_RANGE * 2) + j = BASE_OFFSET - BASE_RANGE / 2; + if(k >= range * 2 + 1) + k = 0; + + if(!world.isRemote) { + for(; i < range * 2 + 1; i++) { + for(; j > -BASE_RANGE * 2; j--) { + for(; k < range * 2 + 1; k++) { + int x = srcx - range + i; + int y = srcy - BASE_RANGE + j; + int z = srcz - range + k; + + if(inRange(x, y, z, srcx, srcy, srcz, range, heightscale, pointy)) { + Block block = world.getBlock(x, y, z); + if(!block.isAir(world, x, y, z) && !block.isReplaceable(world, x, y, z) && !(block instanceof BlockFalling) && (!(block instanceof ILaputaImmobile) || ((ILaputaImmobile) block).canMove(world, x, y, z)) && block.getBlockHardness(world, x, y, z) != -1) { + int id = Block.getIdFromBlock(block); + int meta = world.getBlockMetadata(x, y, z); + TileEntity tile = world.getTileEntity(x, y, z); + + if(tile != null) { + TileEntity newTile = block.createTileEntity(world, meta); + world.setTileEntity(x, y, z, newTile); + } + world.setBlockToAir(x, y, z); + world.playAuxSFX(2001, x, y, z, id + (meta << 12)); + + ItemStack copyLens = new ItemStack(this, 1, lens.getItemDamage()); + ItemNBTHelper.setInt(copyLens, TAG_BLOCK, id); + ItemNBTHelper.setInt(copyLens, TAG_META, meta); + NBTTagCompound cmp = new NBTTagCompound(); + if(tile != null) + tile.writeToNBT(cmp); + ItemNBTHelper.setCompound(copyLens, TAG_TILE, cmp); + ItemNBTHelper.setInt(copyLens, TAG_X, srcx); + ItemNBTHelper.setInt(copyLens, TAG_Y, srcy); + ItemNBTHelper.setInt(copyLens, TAG_Y_START, y); + ItemNBTHelper.setInt(copyLens, TAG_Z, srcz); + ItemNBTHelper.setBoolean(copyLens, TAG_POINTY, pointy); + ItemNBTHelper.setDouble(copyLens, TAG_HEIGHTSCALE, heightscale); + ItemNBTHelper.setInt(copyLens, TAG_ITERATION_I, i); + ItemNBTHelper.setInt(copyLens, TAG_ITERATION_J, j); + ItemNBTHelper.setInt(copyLens, TAG_ITERATION_K, k); + + EntityManaBurst burst = getBurst(world, x, y, z, copyLens); + world.spawnEntityInWorld(burst); + return; + } + } + } + k = 0; + } + j = BASE_OFFSET - BASE_RANGE / 2; + } + } + } + + private boolean inRange(int x, int y, int z, int srcx, int srcy, int srcz, int range, double heightscale, boolean pointy) { + if(y >= srcy) + return MathHelper.pointDistanceSpace(x, 0, z, srcx, 0, srcz) < range; + else if(!pointy) + return MathHelper.pointDistanceSpace(x, y / heightscale, z, srcx, srcy / heightscale, srcz) < range; + else return MathHelper.pointDistanceSpace(x, 0, z, srcx, 0, srcz) < range - (srcy - y) / heightscale; + } + + public EntityManaBurst getBurst(World world, int x, int y, int z, ItemStack stack) { + EntityManaBurst burst = new EntityManaBurst(world); + burst.posX = x + 0.5; + burst.posY = y + 0.5; + burst.posZ = z + 0.5; + + burst.setColor(0x00EAFF); + burst.setMana(1); + burst.setStartingMana(1); + burst.setMinManaLoss(0); + burst.setManaLossPerTick(0F); + burst.setGravity(0F); + burst.setMotion(0, 0.5, 0); + + burst.setSourceLens(stack); + return burst; + } + + @Override + public void apply(ItemStack stack, BurstProperties props) { + // NO-OP + } + + @Override + public boolean collideBurst(IManaBurst burst, MovingObjectPosition pos, boolean isManaBlock, boolean dead, ItemStack stack) { + return false; + } + + @Override + public void updateBurst(IManaBurst burst, ItemStack stack) { + double speed = 0.35; + int targetDistance = BASE_OFFSET; + EntityThrowable entity = (EntityThrowable) burst; + if(!entity.worldObj.isRemote) { + entity.motionX = 0; + entity.motionY = speed; + entity.motionZ = 0; + + final int spawnTicks = 2; + final int placeTicks = net.minecraft.util.MathHelper.floor_double(targetDistance / speed); + + ItemStack lens = burst.getSourceLens(); + + if(burst.getTicksExisted() == spawnTicks) { + int x = ItemNBTHelper.getInt(lens, TAG_X, 0); + int y = ItemNBTHelper.getInt(lens, TAG_Y, -1); + int z = ItemNBTHelper.getInt(lens, TAG_Z, 0); + + if(y != -1) + spawnBurst(entity.worldObj, x, y, z, lens); + } else if(burst.getTicksExisted() == placeTicks) { + int x = net.minecraft.util.MathHelper.floor_double(entity.posX); + int y = ItemNBTHelper.getInt(lens, TAG_Y_START, -1) + targetDistance; + int z = net.minecraft.util.MathHelper.floor_double(entity.posZ); + + if(entity.worldObj.isAirBlock(x, y, z)) { + int id = ItemNBTHelper.getInt(lens, TAG_BLOCK, 0); + Block block = Block.getBlockById(id); + int meta = ItemNBTHelper.getInt(lens, TAG_META, 0); + + TileEntity tile = null; + NBTTagCompound tilecmp = ItemNBTHelper.getCompound(lens, TAG_TILE, false); + if(tilecmp.hasKey("id")) + tile = TileEntity.createAndLoadEntity(tilecmp); + + entity.worldObj.setBlock(x, y, z, block, meta, 1 | 2); + entity.worldObj.playAuxSFX(2001, x, y, z, id + (meta << 12)); + if(tile != null) { + tile.xCoord = x; + tile.yCoord = y; + tile.zCoord = z; + entity.worldObj.setTileEntity(x, y, z, tile); + } + } + + entity.setDead(); + } + } + } + + @Override + public boolean doParticles(IManaBurst burst, ItemStack stack) { + EntityThrowable entity = (EntityThrowable) burst; + ItemStack lens = burst.getSourceLens(); + int id = ItemNBTHelper.getInt(lens, TAG_BLOCK, 0); + Block.getBlockById(id); + int meta = ItemNBTHelper.getInt(lens, TAG_META, 0); + entity.worldObj.spawnParticle("blockcrack_" + id + "_" + meta, entity.posX, entity.posY, entity.posZ, entity.motionX, entity.motionY, entity.motionZ); + + return true; + } + + @Override + public boolean shouldPull(ItemStack stack) { + return false; + } + } diff --git a/src/main/java/vazkii/botania/common/item/ItemLexicon.java b/src/main/java/vazkii/botania/common/item/ItemLexicon.java index f8245e6d88..a2a442868c 100644 --- a/src/main/java/vazkii/botania/common/item/ItemLexicon.java +++ b/src/main/java/vazkii/botania/common/item/ItemLexicon.java @@ -12,6 +12,7 @@ import java.util.ArrayList; import java.util.List; + import net.minecraft.block.Block; import net.minecraft.client.gui.GuiScreen; import net.minecraft.creativetab.CreativeTabs; @@ -36,197 +37,187 @@ import vazkii.botania.common.Botania; import vazkii.botania.common.achievement.ModAchievements; import vazkii.botania.common.core.helper.ItemNBTHelper; +import vazkii.botania.common.core.helper.MathHelper; import vazkii.botania.common.item.relic.ItemDice; import vazkii.botania.common.lib.LibGuiIDs; import vazkii.botania.common.lib.LibItemNames; +import vazkii.botania.common.lib.LibMisc; public class ItemLexicon extends ItemMod implements ILexicon, IElvenItem { - private static final String TAG_KNOWLEDGE_PREFIX = "knowledge."; - private static final String TAG_FORCED_MESSAGE = "forcedMessage"; - private static final String TAG_QUEUE_TICKS = "queueTicks"; - boolean skipSound = false; - - public ItemLexicon() { - super(); - setMaxStackSize(1); - setUnlocalizedName(LibItemNames.LEXICON); - } - - @Override - public boolean onItemUse( - ItemStack par1ItemStack, - EntityPlayer par2EntityPlayer, - World par3World, - int par4, - int par5, - int par6, - int par7, - float par8, - float par9, - float par10) { - if (par2EntityPlayer.isSneaking()) { - Block block = par3World.getBlock(par4, par5, par6); - - if (block != null) { - if (block instanceof ILexiconable) { - LexiconEntry entry = ((ILexiconable) block) - .getEntry(par3World, par4, par5, par6, par2EntityPlayer, par1ItemStack); - if (entry != null && isKnowledgeUnlocked(par1ItemStack, entry.getKnowledgeType())) { - Botania.proxy.setEntryToOpen(entry); - Botania.proxy.setLexiconStack(par1ItemStack); - - openBook(par2EntityPlayer, par1ItemStack, par3World, false); - return true; - } - } else if (par3World.isRemote) { - MovingObjectPosition pos = new MovingObjectPosition( - par4, par5, par6, par7, Vec3.createVectorHelper(par8, par9, par10)); - return Botania.proxy.openWikiPage(par3World, block, pos); - } - } - } - - return false; - } - - @Override - public void getSubItems(Item item, CreativeTabs tab, List list) { - list.add(new ItemStack(item)); - ItemStack creative = new ItemStack(item); - for (String s : BotaniaAPI.knowledgeTypes.keySet()) { - KnowledgeType type = BotaniaAPI.knowledgeTypes.get(s); - unlockKnowledge(creative, type); - } - list.add(creative); - } - - @Override - public void addInformation(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, List par3List, boolean par4) { - if (GuiScreen.isShiftKeyDown()) { - String edition = EnumChatFormatting.GOLD - + String.format(StatCollector.translateToLocal("botaniamisc.edition"), getEdition()); - if (!edition.isEmpty()) par3List.add(edition); - - List typesKnown = new ArrayList(); - for (String s : BotaniaAPI.knowledgeTypes.keySet()) { - KnowledgeType type = BotaniaAPI.knowledgeTypes.get(s); - if (isKnowledgeUnlocked(par1ItemStack, type)) typesKnown.add(type); - } - - String format = - typesKnown.size() == 1 ? "botaniamisc.knowledgeTypesSingular" : "botaniamisc.knowledgeTypesPlural"; - addStringToTooltip(String.format(StatCollector.translateToLocal(format), typesKnown.size()), par3List); - - for (KnowledgeType type : typesKnown) - addStringToTooltip(" \u2022 " + StatCollector.translateToLocal(type.getUnlocalizedName()), par3List); - - } else addStringToTooltip(StatCollector.translateToLocal("botaniamisc.shiftinfo"), par3List); - } - - private void addStringToTooltip(String s, List tooltip) { - tooltip.add(s.replaceAll("&", "\u00a7")); - } - - public static String getEdition() { - return "GTNH"; - } - - @Override - public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer) { - String force = getForcedPage(par1ItemStack); - if (force != null && !force.isEmpty()) { - LexiconEntry entry = getEntryFromForce(par1ItemStack); - if (entry != null) Botania.proxy.setEntryToOpen(entry); - else - par3EntityPlayer.addChatMessage(new ChatComponentTranslation("botaniamisc.cantOpen") - .setChatStyle(new ChatStyle().setColor(EnumChatFormatting.RED))); - setForcedPage(par1ItemStack, ""); - } - - openBook(par3EntityPlayer, par1ItemStack, par2World, skipSound); - skipSound = false; - - return par1ItemStack; - } - - public static void openBook(EntityPlayer player, ItemStack stack, World world, boolean skipSound) { - ILexicon l = (ILexicon) stack.getItem(); - - Botania.proxy.setToTutorialIfFirstLaunch(); - - if (!l.isKnowledgeUnlocked(stack, BotaniaAPI.relicKnowledge) - && l.isKnowledgeUnlocked(stack, BotaniaAPI.elvenKnowledge)) - for (ItemStack rstack : ItemDice.relicStacks) { - Item item = rstack.getItem(); - if (player.inventory.hasItem(item)) { - l.unlockKnowledge(stack, BotaniaAPI.relicKnowledge); - break; - } - } - - Botania.proxy.setLexiconStack(stack); - player.addStat(ModAchievements.lexiconUse, 1); - player.openGui(Botania.instance, LibGuiIDs.LEXICON, world, 0, 0, 0); - if (!world.isRemote && !skipSound) world.playSoundAtEntity(player, "botania:lexiconOpen", 0.5F, 1F); - } - - @Override - public void onUpdate(ItemStack stack, World world, Entity entity, int idk, boolean something) { - int ticks = getQueueTicks(stack); - if (ticks > 0 && entity instanceof EntityPlayer) { - skipSound = ticks < 5; - if (ticks == 1) onItemRightClick(stack, world, (EntityPlayer) entity); - - setQueueTicks(stack, ticks - 1); - } - } - - @Override - public EnumRarity getRarity(ItemStack par1ItemStack) { - return EnumRarity.uncommon; - } - - @Override - public boolean isKnowledgeUnlocked(ItemStack stack, KnowledgeType knowledge) { - return knowledge.autoUnlock || ItemNBTHelper.getBoolean(stack, TAG_KNOWLEDGE_PREFIX + knowledge.id, false); - } - - @Override - public void unlockKnowledge(ItemStack stack, KnowledgeType knowledge) { - ItemNBTHelper.setBoolean(stack, TAG_KNOWLEDGE_PREFIX + knowledge.id, true); - } - - public static void setForcedPage(ItemStack stack, String forced) { - ItemNBTHelper.setString(stack, TAG_FORCED_MESSAGE, forced); - } - - public static String getForcedPage(ItemStack stack) { - return ItemNBTHelper.getString(stack, TAG_FORCED_MESSAGE, ""); - } - - private static LexiconEntry getEntryFromForce(ItemStack stack) { - String force = getForcedPage(stack); - - for (LexiconEntry entry : BotaniaAPI.getAllEntries()) - if (entry.getUnlocalizedName().equals(force)) - if (entry != null - && ((ItemLexicon) stack.getItem()).isKnowledgeUnlocked(stack, entry.getKnowledgeType())) - return entry; - - return null; - } - - public static int getQueueTicks(ItemStack stack) { - return ItemNBTHelper.getInt(stack, TAG_QUEUE_TICKS, 0); - } - - public static void setQueueTicks(ItemStack stack, int ticks) { - ItemNBTHelper.setInt(stack, TAG_QUEUE_TICKS, ticks); - } - - @Override - public boolean isElvenItem(ItemStack stack) { - return isKnowledgeUnlocked(stack, BotaniaAPI.elvenKnowledge); - } + private static final String TAG_KNOWLEDGE_PREFIX = "knowledge."; + private static final String TAG_FORCED_MESSAGE = "forcedMessage"; + private static final String TAG_QUEUE_TICKS = "queueTicks"; + boolean skipSound = false; + + public ItemLexicon() { + super(); + setMaxStackSize(1); + setUnlocalizedName(LibItemNames.LEXICON); + } + + @Override + public boolean onItemUse(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, World par3World, int par4, int par5, int par6, int par7, float par8, float par9, float par10) { + if(par2EntityPlayer.isSneaking()) { + Block block = par3World.getBlock(par4, par5, par6); + + if(block != null) { + if(block instanceof ILexiconable) { + LexiconEntry entry = ((ILexiconable) block).getEntry(par3World, par4, par5, par6, par2EntityPlayer, par1ItemStack); + if(entry != null && isKnowledgeUnlocked(par1ItemStack, entry.getKnowledgeType())) { + Botania.proxy.setEntryToOpen(entry); + Botania.proxy.setLexiconStack(par1ItemStack); + + openBook(par2EntityPlayer, par1ItemStack, par3World, false); + return true; + } + } else if(par3World.isRemote) { + MovingObjectPosition pos = new MovingObjectPosition(par4, par5, par6, par7, Vec3.createVectorHelper(par8, par9, par10)); + return Botania.proxy.openWikiPage(par3World, block, pos); + } + } + } + + return false; + } + + @Override + public void getSubItems(Item item, CreativeTabs tab, List list) { + list.add(new ItemStack(item)); + ItemStack creative = new ItemStack(item); + for(String s : BotaniaAPI.knowledgeTypes.keySet()) { + KnowledgeType type = BotaniaAPI.knowledgeTypes.get(s); + unlockKnowledge(creative, type); + } + list.add(creative); + } + + @Override + public void addInformation(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, List par3List, boolean par4) { + if(GuiScreen.isShiftKeyDown()) { + String edition = EnumChatFormatting.GOLD + String.format(StatCollector.translateToLocal("botaniamisc.edition"), getEdition()); + if(!edition.isEmpty()) + par3List.add(edition); + + List typesKnown = new ArrayList(); + for(String s : BotaniaAPI.knowledgeTypes.keySet()) { + KnowledgeType type = BotaniaAPI.knowledgeTypes.get(s); + if(isKnowledgeUnlocked(par1ItemStack, type)) + typesKnown.add(type); + } + + String format = typesKnown.size() == 1 ? "botaniamisc.knowledgeTypesSingular" : "botaniamisc.knowledgeTypesPlural"; + addStringToTooltip(String.format(StatCollector.translateToLocal(format), typesKnown.size()), par3List); + + for(KnowledgeType type : typesKnown) + addStringToTooltip(" \u2022 " + StatCollector.translateToLocal(type.getUnlocalizedName()), par3List); + + } else addStringToTooltip(StatCollector.translateToLocal("botaniamisc.shiftinfo"), par3List); + } + + private void addStringToTooltip(String s, List tooltip) { + tooltip.add(s.replaceAll("&", "\u00a7")); + } + + public static String getEdition() { + return "GTNH"; + } + + @Override + public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer) { + String force = getForcedPage(par1ItemStack); + if(force != null && !force.isEmpty()) { + LexiconEntry entry = getEntryFromForce(par1ItemStack); + if(entry != null) + Botania.proxy.setEntryToOpen(entry); + else par3EntityPlayer.addChatMessage(new ChatComponentTranslation("botaniamisc.cantOpen").setChatStyle(new ChatStyle().setColor(EnumChatFormatting.RED))); + setForcedPage(par1ItemStack, ""); + } + + openBook(par3EntityPlayer, par1ItemStack, par2World, skipSound); + skipSound = false; + + return par1ItemStack; + } + + public static void openBook(EntityPlayer player, ItemStack stack, World world, boolean skipSound) { + ILexicon l = (ILexicon) stack.getItem(); + + Botania.proxy.setToTutorialIfFirstLaunch(); + + if(!l.isKnowledgeUnlocked(stack, BotaniaAPI.relicKnowledge) && l.isKnowledgeUnlocked(stack, BotaniaAPI.elvenKnowledge)) + for(ItemStack rstack : ItemDice.relicStacks) { + Item item = rstack.getItem(); + if(player.inventory.hasItem(item)) { + l.unlockKnowledge(stack, BotaniaAPI.relicKnowledge); + break; + } + } + + Botania.proxy.setLexiconStack(stack); + player.addStat(ModAchievements.lexiconUse, 1); + player.openGui(Botania.instance, LibGuiIDs.LEXICON, world, 0, 0, 0); + if(!world.isRemote && !skipSound) + world.playSoundAtEntity(player, "botania:lexiconOpen", 0.5F, 1F); + } + + @Override + public void onUpdate(ItemStack stack, World world, Entity entity, int idk, boolean something) { + int ticks = getQueueTicks(stack); + if(ticks > 0 && entity instanceof EntityPlayer) { + skipSound = ticks < 5; + if(ticks == 1) + onItemRightClick(stack, world, (EntityPlayer) entity); + + setQueueTicks(stack, ticks - 1); + } + } + + @Override + public EnumRarity getRarity(ItemStack par1ItemStack) { + return EnumRarity.uncommon; + } + + @Override + public boolean isKnowledgeUnlocked(ItemStack stack, KnowledgeType knowledge) { + return knowledge.autoUnlock || ItemNBTHelper.getBoolean(stack, TAG_KNOWLEDGE_PREFIX + knowledge.id, false); + } + + @Override + public void unlockKnowledge(ItemStack stack, KnowledgeType knowledge) { + ItemNBTHelper.setBoolean(stack, TAG_KNOWLEDGE_PREFIX + knowledge.id, true); + } + + public static void setForcedPage(ItemStack stack, String forced) { + ItemNBTHelper.setString(stack, TAG_FORCED_MESSAGE, forced); + } + + public static String getForcedPage(ItemStack stack) { + return ItemNBTHelper.getString(stack, TAG_FORCED_MESSAGE, ""); + } + + private static LexiconEntry getEntryFromForce(ItemStack stack) { + String force = getForcedPage(stack); + + for(LexiconEntry entry : BotaniaAPI.getAllEntries()) + if(entry.getUnlocalizedName().equals(force)) + if(entry != null && ((ItemLexicon) stack.getItem()).isKnowledgeUnlocked(stack, entry.getKnowledgeType())) + return entry; + + return null; + } + + public static int getQueueTicks(ItemStack stack) { + return ItemNBTHelper.getInt(stack, TAG_QUEUE_TICKS, 0); + } + + public static void setQueueTicks(ItemStack stack, int ticks) { + ItemNBTHelper.setInt(stack, TAG_QUEUE_TICKS, ticks); + } + + @Override + public boolean isElvenItem(ItemStack stack) { + return isKnowledgeUnlocked(stack, BotaniaAPI.elvenKnowledge); + } + } diff --git a/src/main/java/vazkii/botania/common/item/ItemManaCookie.java b/src/main/java/vazkii/botania/common/item/ItemManaCookie.java index 21d3c155d1..04aa146209 100644 --- a/src/main/java/vazkii/botania/common/item/ItemManaCookie.java +++ b/src/main/java/vazkii/botania/common/item/ItemManaCookie.java @@ -2,17 +2,14 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Mar 21, 2014, 8:44:35 PM (GMT)] */ package vazkii.botania.common.item; -import cpw.mods.fml.common.registry.GameRegistry; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.Item; @@ -26,52 +23,53 @@ import vazkii.botania.common.achievement.ModAchievements; import vazkii.botania.common.core.BotaniaCreativeTab; import vazkii.botania.common.lib.LibItemNames; +import cpw.mods.fml.common.registry.GameRegistry; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; public class ItemManaCookie extends ItemFood { - private IIcon totalBiscuitIcon; + private IIcon totalBiscuitIcon; + + public ItemManaCookie() { + super(0, 0.1F, false); + setPotionEffect(Potion.field_76443_y.id, 1, 0, 1F); + setCreativeTab(BotaniaCreativeTab.INSTANCE); + setUnlocalizedName(LibItemNames.MANA_COOKIE); + } - public ItemManaCookie() { - super(0, 0.1F, false); - setPotionEffect(Potion.field_76443_y.id, 1, 0, 1F); - setCreativeTab(BotaniaCreativeTab.INSTANCE); - setUnlocalizedName(LibItemNames.MANA_COOKIE); - } + @Override + protected void onFoodEaten(ItemStack p_77849_1_, World p_77849_2_, EntityPlayer p_77849_3_) { + super.onFoodEaten(p_77849_1_, p_77849_2_, p_77849_3_); + p_77849_3_.addStat(ModAchievements.manaCookieEat, 1); + } - @Override - protected void onFoodEaten(ItemStack p_77849_1_, World p_77849_2_, EntityPlayer p_77849_3_) { - super.onFoodEaten(p_77849_1_, p_77849_2_, p_77849_3_); - p_77849_3_.addStat(ModAchievements.manaCookieEat, 1); - } + @Override + public Item setUnlocalizedName(String par1Str) { + GameRegistry.registerItem(this, par1Str); + return super.setUnlocalizedName(par1Str); + } - @Override - public Item setUnlocalizedName(String par1Str) { - GameRegistry.registerItem(this, par1Str); - return super.setUnlocalizedName(par1Str); - } + @Override + public String getUnlocalizedNameInefficiently(ItemStack par1ItemStack) { + return super.getUnlocalizedNameInefficiently(par1ItemStack).replaceAll("item.", "item." + LibResources.PREFIX_MOD); + } - @Override - public String getUnlocalizedNameInefficiently(ItemStack par1ItemStack) { - return super.getUnlocalizedNameInefficiently(par1ItemStack) - .replaceAll("item.", "item." + LibResources.PREFIX_MOD); - } + @Override + public IIcon getIcon(ItemStack stack, int pass) { + return getIconIndex(stack); + } - @Override - public IIcon getIcon(ItemStack stack, int pass) { - return getIconIndex(stack); - } + @Override + public IIcon getIconIndex(ItemStack stack) { + return stack.getDisplayName().toLowerCase().equals("totalbiscuit") ? totalBiscuitIcon : super.getIconIndex(stack); + } - @Override - public IIcon getIconIndex(ItemStack stack) { - return stack.getDisplayName().toLowerCase().equals("totalbiscuit") - ? totalBiscuitIcon - : super.getIconIndex(stack); - } + @Override + @SideOnly(Side.CLIENT) + public void registerIcons(IIconRegister par1IconRegister) { + itemIcon = IconHelper.forItem(par1IconRegister, this); + totalBiscuitIcon = IconHelper.forName(par1IconRegister, "totalBiscuit"); + } - @Override - @SideOnly(Side.CLIENT) - public void registerIcons(IIconRegister par1IconRegister) { - itemIcon = IconHelper.forItem(par1IconRegister, this); - totalBiscuitIcon = IconHelper.forName(par1IconRegister, "totalBiscuit"); - } } diff --git a/src/main/java/vazkii/botania/common/item/ItemManaGun.java b/src/main/java/vazkii/botania/common/item/ItemManaGun.java index e7006db1e0..30a8c2ef37 100644 --- a/src/main/java/vazkii/botania/common/item/ItemManaGun.java +++ b/src/main/java/vazkii/botania/common/item/ItemManaGun.java @@ -2,19 +2,17 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Mar 13, 2014, 4:30:27 PM (GMT)] */ package vazkii.botania.common.item; -import cpw.mods.fml.common.registry.GameRegistry; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; import java.awt.Color; import java.util.List; + import net.minecraft.client.Minecraft; import net.minecraft.client.gui.GuiScreen; import net.minecraft.client.renderer.texture.IIconRegister; @@ -44,307 +42,306 @@ import vazkii.botania.common.crafting.recipe.ManaGunRemoveLensRecipe; import vazkii.botania.common.entity.EntityManaBurst; import vazkii.botania.common.lib.LibItemNames; +import cpw.mods.fml.common.registry.GameRegistry; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; public class ItemManaGun extends ItemMod implements IManaUsingItem { - private static final String TAG_LENS = "lens"; - private static final String TAG_CLIP = "clip"; - private static final String TAG_CLIP_POS = "clipPos"; - - private static final int CLIP_SLOTS = 6; - private static final int COOLDOWN = 30; - - IIcon[] icons; - - public ItemManaGun() { - super(); - setMaxDamage(COOLDOWN); - setMaxStackSize(1); - setNoRepair(); - setUnlocalizedName(LibItemNames.MANA_GUN); - - GameRegistry.addRecipe(new ManaGunLensRecipe()); - GameRegistry.addRecipe(new ManaGunRemoveLensRecipe()); - GameRegistry.addRecipe(new ManaGunClipRecipe()); - RecipeSorter.register("botania:manaGunLens", ManaGunLensRecipe.class, Category.SHAPELESS, ""); - RecipeSorter.register("botania:manaGunRemoveLens", ManaGunRemoveLensRecipe.class, Category.SHAPELESS, ""); - RecipeSorter.register("botania:manaGunClip", ManaGunClipRecipe.class, Category.SHAPELESS, ""); - } - - @Override - public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer) { - int effCd = COOLDOWN; - PotionEffect effect = par3EntityPlayer.getActivePotionEffect(Potion.digSpeed); - if (effect != null) effCd -= (effect.getAmplifier() + 1) * 8; - - if (par3EntityPlayer.isSneaking() && hasClip(par1ItemStack)) { - rotatePos(par1ItemStack); - par2World.playSoundAtEntity( - par3EntityPlayer, - "random.click", - 0.6F, - (1.0F + (par2World.rand.nextFloat() - par2World.rand.nextFloat()) * 0.2F) * 0.7F); - if (par2World.isRemote) par3EntityPlayer.swingItem(); - ItemStack lens = getLens(par1ItemStack); - ItemsRemainingRenderHandler.set(lens, -2); - par1ItemStack.setItemDamage(effCd); - } else if (par1ItemStack.getItemDamage() == 0) { - EntityManaBurst burst = getBurst(par3EntityPlayer, par1ItemStack, true); - if (burst != null - && ManaItemHandler.requestManaExact(par1ItemStack, par3EntityPlayer, burst.getMana(), true)) { - if (!par2World.isRemote) { - par2World.playSoundAtEntity(par3EntityPlayer, "botania:manaBlaster", 0.6F, 1F); - par3EntityPlayer.addStat(ModAchievements.manaBlasterShoot, 1); - if (isSugoiKawaiiDesuNe(par1ItemStack)) par3EntityPlayer.addStat(ModAchievements.desuGun, 1); - par2World.spawnEntityInWorld(burst); - } else { - par3EntityPlayer.swingItem(); - par3EntityPlayer.motionX -= burst.motionX * 0.1; - par3EntityPlayer.motionY -= burst.motionY * 0.3; - par3EntityPlayer.motionZ -= burst.motionZ * 0.1; - } - par1ItemStack.setItemDamage(effCd); - } else if (!par2World.isRemote) - par2World.playSoundAtEntity( - par3EntityPlayer, - "random.click", - 0.6F, - (1.0F + (par2World.rand.nextFloat() - par2World.rand.nextFloat()) * 0.2F) * 0.7F); - } - - return par1ItemStack; - } - - @Override - public void registerIcons(IIconRegister par1IconRegister) { - int states = 3; - icons = new IIcon[states * 2]; - - for (int i = 0; i < states; i++) { - icons[i] = IconHelper.forItem(par1IconRegister, this, i); - icons[states + i] = IconHelper.forName(par1IconRegister, "desuGun" + i); - } - } - - @Override - public boolean requiresMultipleRenderPasses() { - return true; - } - - @Override - public IIcon getIcon(ItemStack stack, int pass) { - boolean desu = isSugoiKawaiiDesuNe(stack); - int index = pass; - if (index == 0 && hasClip(stack)) index = 2; - - return icons[Math.min(2, index) + (desu ? 3 : 0)]; - } - - // ASADA-SAN ASADA-SAN ASADA-SAN ASADA-SAN ASADA-SAN ASADA-SAN ASADA-SAN ASADA-SAN - // ASADA-SAN ASADA-SAN ASADA-SAN ASADA-SAN ASADA-SAN ASADA-SAN ASADA-SAN ASADA-SAN - // ASADA-SAN ASADA-SAN ASADA-SAN ASADA-SAN ASADA-SAN ASADA-SAN ASADA-SAN ASADA-SAN - // ASADA-SAN ASADA-SAN ASADA-SAN ASADA-SAN ASADA-SAN ASADA-SAN ASADA-SAN ASADA-SAN - // ASADA-SAN ASADA-SAN ASADA-SAN ASADA-SAN ASADA-SAN ASADA-SAN ASADA-SAN ASADA-SAN - // ASADA-SAN ASADA-SAN ASADA-SAN ASADA-SAN ASADA-SAN ASADA-SAN ASADA-SAN ASADA-SAN - // ASADA-SAN ASADA-SAN ASADA-SAN ASADA-SAN ASADA-SAN ASADA-SAN ASADA-SAN ASADA-SAN - // ASADA-SAN ASADA-SAN ASADA-SAN ASADA-SAN ASADA-SAN ASADA-SAN ASADA-SAN ASADA-SAN - // ASADA-SAN ASADA-SAN ASADA-SAN ASADA-SAN ASADA-SAN ASADA-SAN ASADA-SAN ASADA-SAN - // ASADA-SAN ASADA-SAN ASADA-SAN ASADA-SAN ASADA-SAN ASADA-SAN ASADA-SAN ASADA-SAN - // ASADA-SAN ASADA-SAN ASADA-SAN ASADA-SAN ASADA-SAN ASADA-SAN ASADA-SAN ASADA-SAN - // ASADA-SAN ASADA-SAN ASADA-SAN ASADA-SAN ASADA-SAN ASADA-SAN ASADA-SAN ASADA-SAN - // ASADA-SAN ASADA-SAN ASADA-SAN ASADA-SAN ASADA-SAN ASADA-SAN ASADA-SAN ASADA-SAN - // ASADA-SAN ASADA-SAN ASADA-SAN ASADA-SAN ASADA-SAN ASADA-SAN ASADA-SAN ASADA-SAN - private boolean isSugoiKawaiiDesuNe(ItemStack stack) { - return stack.getDisplayName().equalsIgnoreCase("desu gun"); - } - - @Override - @SideOnly(Side.CLIENT) - public int getColorFromItemStack(ItemStack par1ItemStack, int par2) { - if (par2 == 0) return 0xFFFFFF; - - EntityManaBurst burst = getBurst(Minecraft.getMinecraft().thePlayer, par1ItemStack, false); - Color color = new Color(burst == null ? 0x20FF20 : burst.getColor()); - - float mul = (float) (Math.sin((double) ClientTickHandler.ticksInGame / 5) * 0.15F); - int c = (int) (255 * mul); - - return new Color( - Math.max(0, Math.min(255, color.getRed() + c)), - Math.max(0, Math.min(255, color.getGreen() + c)), - Math.max(0, Math.min(255, color.getBlue() + c))) - .getRGB(); - } - - @Override - public boolean hasContainerItem(ItemStack stack) { - return getLens(stack) != null; - } - - @Override - public ItemStack getContainerItem(ItemStack itemStack) { - return getLens(itemStack); - } - - @Override - public boolean doesContainerItemLeaveCraftingGrid(ItemStack p_77630_1_) { - return false; - } - - public EntityManaBurst getBurst(EntityPlayer player, ItemStack stack, boolean request) { - EntityManaBurst burst = new EntityManaBurst(player); - - int maxMana = 120; - int color = 0x20FF20; - int ticksBeforeManaLoss = 60; - float manaLossPerTick = 4F; - float motionModifier = 5F; - float gravity = 0F; - BurstProperties props = - new BurstProperties(maxMana, ticksBeforeManaLoss, manaLossPerTick, gravity, motionModifier, color); - - ItemStack lens = getLens(stack); - if (lens != null) ((ILens) lens.getItem()).apply(lens, props); - - burst.setSourceLens(lens); - if (!request || ManaItemHandler.requestManaExact(stack, player, props.maxMana, false)) { - burst.setColor(props.color); - burst.setMana(props.maxMana); - burst.setStartingMana(props.maxMana); - burst.setMinManaLoss(props.ticksBeforeManaLoss); - burst.setManaLossPerTick(props.manaLossPerTick); - burst.setGravity(props.gravity); - burst.setMotion( - burst.motionX * props.motionModifier, - burst.motionY * props.motionModifier, - burst.motionZ * props.motionModifier); - - return burst; - } - return null; - } - - @Override - public void addInformation(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, List par3List, boolean par4) { - boolean clip = hasClip(par1ItemStack); - if (clip && !GuiScreen.isShiftKeyDown()) { - addStringToTooltip(StatCollector.translateToLocal("botaniamisc.shiftinfo"), par3List); - return; - } - - ItemStack lens = getLens(par1ItemStack); - if (lens != null) { - List tooltip = lens.getTooltip(par2EntityPlayer, false); - if (tooltip.size() > 1) par3List.addAll(tooltip.subList(1, tooltip.size())); - } - - if (clip) { - int pos = getClipPos(par1ItemStack); - addStringToTooltip(StatCollector.translateToLocal("botaniamisc.hasClip"), par3List); - for (int i = 0; i < CLIP_SLOTS; i++) { - String name = ""; - EnumChatFormatting formatting = i == pos ? EnumChatFormatting.GREEN : EnumChatFormatting.GRAY; - ItemStack lensAt = getLensAtPos(par1ItemStack, i); - if (lensAt == null) name = StatCollector.translateToLocal("botaniamisc.clipEmpty"); - else name = lensAt.getDisplayName(); - addStringToTooltip(formatting + " - " + name, par3List); - } - } - } - - private void addStringToTooltip(String s, List tooltip) { - tooltip.add(s.replaceAll("&", "\u00a7")); - } - - @Override - public String getItemStackDisplayName(ItemStack par1ItemStack) { - ItemStack lens = getLens(par1ItemStack); - return super.getItemStackDisplayName(par1ItemStack) - + (lens == null - ? "" - : " (" + EnumChatFormatting.GREEN + lens.getDisplayName() + EnumChatFormatting.RESET + ")"); - } - - public static boolean hasClip(ItemStack stack) { - return ItemNBTHelper.getBoolean(stack, TAG_CLIP, false); - } - - public static void setClip(ItemStack stack, boolean clip) { - ItemNBTHelper.setBoolean(stack, TAG_CLIP, clip); - } - - public static int getClipPos(ItemStack stack) { - return ItemNBTHelper.getInt(stack, TAG_CLIP_POS, 0); - } - - public static void setClipPos(ItemStack stack, int pos) { - ItemNBTHelper.setInt(stack, TAG_CLIP_POS, pos); - } - - public static void rotatePos(ItemStack stack) { - int currPos = getClipPos(stack); - boolean acceptEmpty = getLensAtPos(stack, currPos) != null; - int[] slots = new int[CLIP_SLOTS - 1]; - - int index = 0; - for (int i = currPos + 1; i < CLIP_SLOTS; i++, index++) slots[index] = i; - for (int i = 0; i < currPos; i++, index++) slots[index] = i; - - for (int i : slots) { - ItemStack lensAt = getLensAtPos(stack, i); - if (acceptEmpty || lensAt != null) { - setClipPos(stack, i); - return; - } - } - } - - public static ItemStack getLensAtPos(ItemStack stack, int pos) { - NBTTagCompound cmp = ItemNBTHelper.getCompound(stack, TAG_LENS + pos, true); - if (cmp != null) { - ItemStack lens = ItemStack.loadItemStackFromNBT(cmp); - return lens; - } - return null; - } - - public static void setLensAtPos(ItemStack stack, ItemStack lens, int pos) { - NBTTagCompound cmp = new NBTTagCompound(); - if (lens != null) lens.writeToNBT(cmp); - ItemNBTHelper.setCompound(stack, TAG_LENS + pos, cmp); - } - - public static void setLens(ItemStack stack, ItemStack lens) { - if (hasClip(stack)) setLensAtPos(stack, lens, getClipPos(stack)); - - NBTTagCompound cmp = new NBTTagCompound(); - if (lens != null) lens.writeToNBT(cmp); - ItemNBTHelper.setCompound(stack, TAG_LENS, cmp); - } - - public static ItemStack getLens(ItemStack stack) { - if (hasClip(stack)) return getLensAtPos(stack, getClipPos(stack)); - - NBTTagCompound cmp = ItemNBTHelper.getCompound(stack, TAG_LENS, true); - if (cmp != null) { - ItemStack lens = ItemStack.loadItemStackFromNBT(cmp); - return lens; - } - return null; - } - - @Override - public boolean isFull3D() { - return true; - } - - @Override - public void onUpdate(ItemStack par1ItemStack, World par2World, Entity par3Entity, int par4, boolean par5) { - if (par1ItemStack.isItemDamaged()) par1ItemStack.setItemDamage(par1ItemStack.getItemDamage() - 1); - } - - @Override - public boolean usesMana(ItemStack stack) { - return true; - } + private static final String TAG_LENS = "lens"; + private static final String TAG_CLIP = "clip"; + private static final String TAG_CLIP_POS = "clipPos"; + + private static final int CLIP_SLOTS = 6; + private static final int COOLDOWN = 30; + + IIcon[] icons; + + public ItemManaGun() { + super(); + setMaxDamage(COOLDOWN); + setMaxStackSize(1); + setNoRepair(); + setUnlocalizedName(LibItemNames.MANA_GUN); + + GameRegistry.addRecipe(new ManaGunLensRecipe()); + GameRegistry.addRecipe(new ManaGunRemoveLensRecipe()); + GameRegistry.addRecipe(new ManaGunClipRecipe()); + RecipeSorter.register("botania:manaGunLens", ManaGunLensRecipe.class, Category.SHAPELESS, ""); + RecipeSorter.register("botania:manaGunRemoveLens", ManaGunRemoveLensRecipe.class, Category.SHAPELESS, ""); + RecipeSorter.register("botania:manaGunClip", ManaGunClipRecipe.class, Category.SHAPELESS, ""); + } + + @Override + public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer) { + int effCd = COOLDOWN; + PotionEffect effect = par3EntityPlayer.getActivePotionEffect(Potion.digSpeed); + if(effect != null) + effCd -= (effect.getAmplifier() + 1) * 8; + + if(par3EntityPlayer.isSneaking() && hasClip(par1ItemStack)) { + rotatePos(par1ItemStack); + par2World.playSoundAtEntity(par3EntityPlayer, "random.click", 0.6F, (1.0F + (par2World.rand.nextFloat() - par2World.rand.nextFloat()) * 0.2F) * 0.7F); + if(par2World.isRemote) + par3EntityPlayer.swingItem(); + ItemStack lens = getLens(par1ItemStack); + ItemsRemainingRenderHandler.set(lens, -2); + par1ItemStack.setItemDamage(effCd); + } else if(par1ItemStack.getItemDamage() == 0) { + EntityManaBurst burst = getBurst(par3EntityPlayer, par1ItemStack, true); + if(burst != null && ManaItemHandler.requestManaExact(par1ItemStack, par3EntityPlayer, burst.getMana(), true)) { + if(!par2World.isRemote) { + par2World.playSoundAtEntity(par3EntityPlayer, "botania:manaBlaster", 0.6F, 1F); + par3EntityPlayer.addStat(ModAchievements.manaBlasterShoot, 1); + if(isSugoiKawaiiDesuNe(par1ItemStack)) + par3EntityPlayer.addStat(ModAchievements.desuGun, 1); + par2World.spawnEntityInWorld(burst); + } else { + par3EntityPlayer.swingItem(); + par3EntityPlayer.motionX -= burst.motionX * 0.1; + par3EntityPlayer.motionY -= burst.motionY * 0.3; + par3EntityPlayer.motionZ -= burst.motionZ * 0.1; + } + par1ItemStack.setItemDamage(effCd); + } else if(!par2World.isRemote) + par2World.playSoundAtEntity(par3EntityPlayer, "random.click", 0.6F, (1.0F + (par2World.rand.nextFloat() - par2World.rand.nextFloat()) * 0.2F) * 0.7F); + } + + return par1ItemStack; + } + + @Override + public void registerIcons(IIconRegister par1IconRegister) { + int states = 3; + icons = new IIcon[states * 2]; + + for(int i = 0; i < states; i++) { + icons[i] = IconHelper.forItem(par1IconRegister, this, i); + icons[states + i] = IconHelper.forName(par1IconRegister, "desuGun" + i); + } + } + + @Override + public boolean requiresMultipleRenderPasses() { + return true; + } + + @Override + public IIcon getIcon(ItemStack stack, int pass) { + boolean desu = isSugoiKawaiiDesuNe(stack); + int index = pass; + if(index == 0 && hasClip(stack)) + index = 2; + + return icons[Math.min(2, index) + (desu ? 3 : 0)]; + } + + // ASADA-SAN ASADA-SAN ASADA-SAN ASADA-SAN ASADA-SAN ASADA-SAN ASADA-SAN ASADA-SAN + // ASADA-SAN ASADA-SAN ASADA-SAN ASADA-SAN ASADA-SAN ASADA-SAN ASADA-SAN ASADA-SAN + // ASADA-SAN ASADA-SAN ASADA-SAN ASADA-SAN ASADA-SAN ASADA-SAN ASADA-SAN ASADA-SAN + // ASADA-SAN ASADA-SAN ASADA-SAN ASADA-SAN ASADA-SAN ASADA-SAN ASADA-SAN ASADA-SAN + // ASADA-SAN ASADA-SAN ASADA-SAN ASADA-SAN ASADA-SAN ASADA-SAN ASADA-SAN ASADA-SAN + // ASADA-SAN ASADA-SAN ASADA-SAN ASADA-SAN ASADA-SAN ASADA-SAN ASADA-SAN ASADA-SAN + // ASADA-SAN ASADA-SAN ASADA-SAN ASADA-SAN ASADA-SAN ASADA-SAN ASADA-SAN ASADA-SAN + // ASADA-SAN ASADA-SAN ASADA-SAN ASADA-SAN ASADA-SAN ASADA-SAN ASADA-SAN ASADA-SAN + // ASADA-SAN ASADA-SAN ASADA-SAN ASADA-SAN ASADA-SAN ASADA-SAN ASADA-SAN ASADA-SAN + // ASADA-SAN ASADA-SAN ASADA-SAN ASADA-SAN ASADA-SAN ASADA-SAN ASADA-SAN ASADA-SAN + // ASADA-SAN ASADA-SAN ASADA-SAN ASADA-SAN ASADA-SAN ASADA-SAN ASADA-SAN ASADA-SAN + // ASADA-SAN ASADA-SAN ASADA-SAN ASADA-SAN ASADA-SAN ASADA-SAN ASADA-SAN ASADA-SAN + // ASADA-SAN ASADA-SAN ASADA-SAN ASADA-SAN ASADA-SAN ASADA-SAN ASADA-SAN ASADA-SAN + // ASADA-SAN ASADA-SAN ASADA-SAN ASADA-SAN ASADA-SAN ASADA-SAN ASADA-SAN ASADA-SAN + private boolean isSugoiKawaiiDesuNe(ItemStack stack) { + return stack.getDisplayName().equalsIgnoreCase("desu gun"); + } + + @Override + @SideOnly(Side.CLIENT) + public int getColorFromItemStack(ItemStack par1ItemStack, int par2) { + if(par2 == 0) + return 0xFFFFFF; + + EntityManaBurst burst = getBurst(Minecraft.getMinecraft().thePlayer, par1ItemStack, false); + Color color = new Color(burst == null ? 0x20FF20 : burst.getColor()); + + float mul = (float) (Math.sin((double) ClientTickHandler.ticksInGame / 5) * 0.15F); + int c = (int) (255 * mul); + + return new Color(Math.max(0, Math.min(255, color.getRed() + c)), Math.max(0, Math.min(255, color.getGreen() + c)), Math.max(0, Math.min(255, color.getBlue() + c))).getRGB(); + } + + @Override + public boolean hasContainerItem(ItemStack stack) { + return getLens(stack) != null; + } + + @Override + public ItemStack getContainerItem(ItemStack itemStack) { + return getLens(itemStack); + } + + @Override + public boolean doesContainerItemLeaveCraftingGrid(ItemStack p_77630_1_) { + return false; + } + + public EntityManaBurst getBurst(EntityPlayer player, ItemStack stack, boolean request) { + EntityManaBurst burst = new EntityManaBurst(player); + + int maxMana = 120; + int color = 0x20FF20; + int ticksBeforeManaLoss = 60; + float manaLossPerTick = 4F; + float motionModifier = 5F; + float gravity = 0F; + BurstProperties props = new BurstProperties(maxMana, ticksBeforeManaLoss, manaLossPerTick, gravity, motionModifier, color); + + ItemStack lens = getLens(stack); + if(lens != null) + ((ILens) lens.getItem()).apply(lens, props); + + + burst.setSourceLens(lens); + if(!request || ManaItemHandler.requestManaExact(stack, player, props.maxMana, false)) { + burst.setColor(props.color); + burst.setMana(props.maxMana); + burst.setStartingMana(props.maxMana); + burst.setMinManaLoss(props.ticksBeforeManaLoss); + burst.setManaLossPerTick(props.manaLossPerTick); + burst.setGravity(props.gravity); + burst.setMotion(burst.motionX * props.motionModifier, burst.motionY * props.motionModifier, burst.motionZ * props.motionModifier); + + return burst; + } + return null; + } + + @Override + public void addInformation(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, List par3List, boolean par4) { + boolean clip = hasClip(par1ItemStack); + if(clip && !GuiScreen.isShiftKeyDown()) { + addStringToTooltip(StatCollector.translateToLocal("botaniamisc.shiftinfo"), par3List); + return; + } + + ItemStack lens = getLens(par1ItemStack); + if(lens != null) { + List tooltip = lens.getTooltip(par2EntityPlayer, false); + if(tooltip.size() > 1) + par3List.addAll(tooltip.subList(1, tooltip.size())); + } + + if(clip) { + int pos = getClipPos(par1ItemStack); + addStringToTooltip(StatCollector.translateToLocal("botaniamisc.hasClip"), par3List); + for(int i = 0; i < CLIP_SLOTS; i++) { + String name = ""; + EnumChatFormatting formatting = i == pos ? EnumChatFormatting.GREEN : EnumChatFormatting.GRAY; + ItemStack lensAt = getLensAtPos(par1ItemStack, i); + if(lensAt == null) + name = StatCollector.translateToLocal("botaniamisc.clipEmpty"); + else name = lensAt.getDisplayName(); + addStringToTooltip(formatting + " - " + name, par3List); + } + } + } + + private void addStringToTooltip(String s, List tooltip) { + tooltip.add(s.replaceAll("&", "\u00a7")); + } + + @Override + public String getItemStackDisplayName(ItemStack par1ItemStack) { + ItemStack lens = getLens(par1ItemStack); + return super.getItemStackDisplayName(par1ItemStack) + (lens == null ? "" : " (" + EnumChatFormatting.GREEN + lens.getDisplayName() + EnumChatFormatting.RESET + ")"); + } + + public static boolean hasClip(ItemStack stack) { + return ItemNBTHelper.getBoolean(stack, TAG_CLIP, false); + } + + public static void setClip(ItemStack stack, boolean clip) { + ItemNBTHelper.setBoolean(stack, TAG_CLIP, clip); + } + + public static int getClipPos(ItemStack stack) { + return ItemNBTHelper.getInt(stack, TAG_CLIP_POS, 0); + } + + public static void setClipPos(ItemStack stack, int pos) { + ItemNBTHelper.setInt(stack, TAG_CLIP_POS, pos); + } + + public static void rotatePos(ItemStack stack) { + int currPos = getClipPos(stack); + boolean acceptEmpty = getLensAtPos(stack, currPos) != null; + int[] slots = new int[CLIP_SLOTS - 1]; + + int index = 0; + for(int i = currPos + 1; i < CLIP_SLOTS; i++, index++) + slots[index] = i; + for(int i = 0; i < currPos; i++, index++) + slots[index] = i; + + for(int i : slots) { + ItemStack lensAt = getLensAtPos(stack, i); + if(acceptEmpty || lensAt != null) { + setClipPos(stack, i); + return; + } + } + } + + public static ItemStack getLensAtPos(ItemStack stack, int pos) { + NBTTagCompound cmp = ItemNBTHelper.getCompound(stack, TAG_LENS + pos, true); + if(cmp != null) { + ItemStack lens = ItemStack.loadItemStackFromNBT(cmp); + return lens; + } + return null; + } + + public static void setLensAtPos(ItemStack stack, ItemStack lens, int pos) { + NBTTagCompound cmp = new NBTTagCompound(); + if(lens != null) + lens.writeToNBT(cmp); + ItemNBTHelper.setCompound(stack, TAG_LENS + pos, cmp); + } + + public static void setLens(ItemStack stack, ItemStack lens) { + if(hasClip(stack)) + setLensAtPos(stack, lens, getClipPos(stack)); + + NBTTagCompound cmp = new NBTTagCompound(); + if(lens != null) + lens.writeToNBT(cmp); + ItemNBTHelper.setCompound(stack, TAG_LENS, cmp); + } + + public static ItemStack getLens(ItemStack stack) { + if(hasClip(stack)) + return getLensAtPos(stack, getClipPos(stack)); + + NBTTagCompound cmp = ItemNBTHelper.getCompound(stack, TAG_LENS, true); + if(cmp != null) { + ItemStack lens = ItemStack.loadItemStackFromNBT(cmp); + return lens; + } + return null; + } + + @Override + public boolean isFull3D() { + return true; + } + + @Override + public void onUpdate(ItemStack par1ItemStack, World par2World, Entity par3Entity, int par4, boolean par5) { + if(par1ItemStack.isItemDamaged()) + par1ItemStack.setItemDamage(par1ItemStack.getItemDamage() - 1); + } + + @Override + public boolean usesMana(ItemStack stack) { + return true; + } } diff --git a/src/main/java/vazkii/botania/common/item/ItemManaMirror.java b/src/main/java/vazkii/botania/common/item/ItemManaMirror.java index 6490fb5ace..27d99c709b 100644 --- a/src/main/java/vazkii/botania/common/item/ItemManaMirror.java +++ b/src/main/java/vazkii/botania/common/item/ItemManaMirror.java @@ -2,15 +2,16 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Apr 13, 2014, 5:39:24 PM (GMT)] */ package vazkii.botania.common.item; import java.awt.Color; + import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.entity.Entity; import net.minecraft.entity.player.EntityPlayer; @@ -31,248 +32,246 @@ public class ItemManaMirror extends ItemMod implements IManaItem, ICoordBoundItem, IManaTooltipDisplay { - IIcon[] icons; - - private static final String TAG_MANA = "mana"; - private static final String TAG_MANA_BACKLOG = "manaBacklog"; - - private static final String TAG_POS_X = "posX"; - private static final String TAG_POS_Y = "posY"; - private static final String TAG_POS_Z = "posZ"; - private static final String TAG_DIM = "dim"; - - private static final DummyPool fallbackPool = new DummyPool(); - - public ItemManaMirror() { - super(); - setMaxStackSize(1); - setMaxDamage(1000); - setUnlocalizedName(LibItemNames.MANA_MIRROR); - setNoRepair(); - } - - @Override - public int getColorFromItemStack(ItemStack par1ItemStack, int par2) { - float mana = getMana(par1ItemStack); - return par2 == 1 ? Color.HSBtoRGB(0.528F, mana / TilePool.MAX_MANA, 1F) : 0xFFFFFF; - } - - @Override - public int getDamage(ItemStack stack) { - float mana = getMana(stack); - return 1000 - (int) (mana / TilePool.MAX_MANA * 1000); - } - - @Override - public int getDisplayDamage(ItemStack stack) { - return getDamage(stack); - } - - @Override - public void registerIcons(IIconRegister par1IconRegister) { - icons = new IIcon[2]; - for (int i = 0; i < icons.length; i++) icons[i] = IconHelper.forItem(par1IconRegister, this, i); - } - - @Override - public IIcon getIcon(ItemStack stack, int pass) { - return icons[Math.min(1, pass)]; - } - - @Override - public boolean isFull3D() { - return true; - } - - @Override - public void onUpdate(ItemStack par1ItemStack, World par2World, Entity par3Entity, int par4, boolean par5) { - if (par2World.isRemote) return; - - IManaPool pool = getManaPool(par1ItemStack); - if (!(pool instanceof DummyPool)) { - if (pool == null) setMana(par1ItemStack, 0); - else { - pool.recieveMana(getManaBacklog(par1ItemStack)); - setManaBacklog(par1ItemStack, 0); - setMana(par1ItemStack, pool.getCurrentMana()); - } - } - } - - @Override - public boolean onItemUse( - ItemStack par1ItemStack, - EntityPlayer par2EntityPlayer, - World par3World, - int par4, - int par5, - int par6, - int par7, - float par8, - float par9, - float par10) { - if (par2EntityPlayer.isSneaking() && !par3World.isRemote) { - TileEntity tile = par3World.getTileEntity(par4, par5, par6); - if (tile != null && tile instanceof IManaPool) { - bindPool(par1ItemStack, tile); - par3World.playSoundAtEntity(par2EntityPlayer, "botania:ding", 1F, 1F); - return true; - } - } - - return false; - } - - @Override - public boolean requiresMultipleRenderPasses() { - return true; - } - - /*public int getMana(ItemStack stack) { - IManaPool pool = getManaPool(stack); - return pool == null ? 0 : pool.getCurrentMana(); - }*/ - - @Override - public int getMana(ItemStack stack) { - return ItemNBTHelper.getInt(stack, TAG_MANA, 0); - } - - public void setMana(ItemStack stack, int mana) { - ItemNBTHelper.setInt(stack, TAG_MANA, Math.max(0, mana)); - } - - public int getManaBacklog(ItemStack stack) { - return ItemNBTHelper.getInt(stack, TAG_MANA_BACKLOG, 0); - } - - public void setManaBacklog(ItemStack stack, int backlog) { - ItemNBTHelper.setInt(stack, TAG_MANA_BACKLOG, backlog); - } - - @Override - public int getMaxMana(ItemStack stack) { - return TilePool.MAX_MANA; - } - - @Override - public void addMana(ItemStack stack, int mana) { - setMana(stack, getMana(stack) + mana); - setManaBacklog(stack, getManaBacklog(stack) + mana); - } - - /*public void addMana(ItemStack stack, int mana) { - IManaPool pool = getManaPool(stack); - if(pool != null) { - pool.recieveMana(mana); - TileEntity tile = (TileEntity) pool; - tile.getWorldObj().func_147453_f(tile.xCoord, tile.yCoord, tile.zCoord, tile.getWorldObj().getBlock(tile.xCoord, tile.yCoord, tile.zCoord)); - } - }*/ - - public void bindPool(ItemStack stack, TileEntity pool) { - ItemNBTHelper.setInt(stack, TAG_POS_X, pool == null ? 0 : pool.xCoord); - ItemNBTHelper.setInt(stack, TAG_POS_Y, pool == null ? -1 : pool.yCoord); - ItemNBTHelper.setInt(stack, TAG_POS_Z, pool == null ? 0 : pool.zCoord); - ItemNBTHelper.setInt(stack, TAG_DIM, pool == null ? 0 : pool.getWorldObj().provider.dimensionId); - } - - public ChunkCoordinates getPoolCoords(ItemStack stack) { - int x = ItemNBTHelper.getInt(stack, TAG_POS_X, 0); - int y = ItemNBTHelper.getInt(stack, TAG_POS_Y, -1); - int z = ItemNBTHelper.getInt(stack, TAG_POS_Z, 0); - return new ChunkCoordinates(x, y, z); - } - - public int getDimension(ItemStack stack) { - return ItemNBTHelper.getInt(stack, TAG_DIM, 0); - } - - public IManaPool getManaPool(ItemStack stack) { - MinecraftServer server = MinecraftServer.getServer(); - if (server == null) return fallbackPool; - - ChunkCoordinates coords = getPoolCoords(stack); - if (coords.posY == -1) return null; - - int dim = getDimension(stack); - World world = null; - for (World w : server.worldServers) - if (w.provider.dimensionId == dim) { - world = w; - break; - } - - if (world != null) { - TileEntity tile = world.getTileEntity(coords.posX, coords.posY, coords.posZ); - if (tile != null && tile instanceof IManaPool) return (IManaPool) tile; - } - - return null; - } - - @Override - public boolean canReceiveManaFromPool(ItemStack stack, TileEntity pool) { - return false; - } - - @Override - public boolean canReceiveManaFromItem(ItemStack stack, ItemStack otherStack) { - return false; - } - - @Override - public boolean canExportManaToPool(ItemStack stack, TileEntity pool) { - return false; - } - - @Override - public boolean canExportManaToItem(ItemStack stack, ItemStack otherStack) { - return true; - } - - private static class DummyPool implements IManaPool { - - @Override - public boolean isFull() { - return false; - } - - @Override - public void recieveMana(int mana) { - // NO-OP - } - - @Override - public boolean canRecieveManaFromBursts() { - return false; - } - - @Override - public int getCurrentMana() { - return 0; - } - - @Override - public boolean isOutputtingPower() { - return false; - } - } - - @Override - public boolean isNoExport(ItemStack stack) { - return false; - } - - @Override - public ChunkCoordinates getBinding(ItemStack stack) { - IManaPool pool = getManaPool(stack); - - return pool == null || pool instanceof DummyPool ? null : getPoolCoords(stack); - } - - @Override - public float getManaFractionForDisplay(ItemStack stack) { - return (float) getMana(stack) / (float) getMaxMana(stack); - } + IIcon[] icons; + + private static final String TAG_MANA = "mana"; + private static final String TAG_MANA_BACKLOG = "manaBacklog"; + + private static final String TAG_POS_X = "posX"; + private static final String TAG_POS_Y = "posY"; + private static final String TAG_POS_Z = "posZ"; + private static final String TAG_DIM = "dim"; + + private static final DummyPool fallbackPool = new DummyPool(); + + public ItemManaMirror() { + super(); + setMaxStackSize(1); + setMaxDamage(1000); + setUnlocalizedName(LibItemNames.MANA_MIRROR); + setNoRepair(); + } + + @Override + public int getColorFromItemStack(ItemStack par1ItemStack, int par2) { + float mana = getMana(par1ItemStack); + return par2 == 1 ? Color.HSBtoRGB(0.528F, mana / TilePool.MAX_MANA, 1F) : 0xFFFFFF; + } + + @Override + public int getDamage(ItemStack stack) { + float mana = getMana(stack); + return 1000 - (int) (mana / TilePool.MAX_MANA * 1000); + } + + @Override + public int getDisplayDamage(ItemStack stack) { + return getDamage(stack); + } + + @Override + public void registerIcons(IIconRegister par1IconRegister) { + icons = new IIcon[2]; + for(int i = 0; i < icons.length; i++) + icons[i] = IconHelper.forItem(par1IconRegister, this, i); + } + + @Override + public IIcon getIcon(ItemStack stack, int pass) { + return icons[Math.min(1, pass)]; + } + + @Override + public boolean isFull3D() { + return true; + } + + @Override + public void onUpdate(ItemStack par1ItemStack, World par2World, Entity par3Entity, int par4, boolean par5) { + if(par2World.isRemote) + return; + + IManaPool pool = getManaPool(par1ItemStack); + if(!(pool instanceof DummyPool)) { + if(pool == null) + setMana(par1ItemStack, 0); + else { + pool.recieveMana(getManaBacklog(par1ItemStack)); + setManaBacklog(par1ItemStack, 0); + setMana(par1ItemStack, pool.getCurrentMana()); + } + } + } + + @Override + public boolean onItemUse(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, World par3World, int par4, int par5, int par6, int par7, float par8, float par9, float par10) { + if(par2EntityPlayer.isSneaking() && !par3World.isRemote) { + TileEntity tile = par3World.getTileEntity(par4, par5, par6); + if(tile != null && tile instanceof IManaPool) { + bindPool(par1ItemStack, tile); + par3World.playSoundAtEntity(par2EntityPlayer, "botania:ding", 1F, 1F); + return true; + } + } + + return false; + } + + @Override + public boolean requiresMultipleRenderPasses() { + return true; + } + + /*public int getMana(ItemStack stack) { + IManaPool pool = getManaPool(stack); + return pool == null ? 0 : pool.getCurrentMana(); + }*/ + + @Override + public int getMana(ItemStack stack) { + return ItemNBTHelper.getInt(stack, TAG_MANA, 0); + } + + public void setMana(ItemStack stack, int mana) { + ItemNBTHelper.setInt(stack, TAG_MANA, Math.max(0, mana)); + } + + public int getManaBacklog(ItemStack stack) { + return ItemNBTHelper.getInt(stack, TAG_MANA_BACKLOG, 0); + } + + public void setManaBacklog(ItemStack stack, int backlog) { + ItemNBTHelper.setInt(stack, TAG_MANA_BACKLOG, backlog); + } + + @Override + public int getMaxMana(ItemStack stack) { + return TilePool.MAX_MANA; + } + + @Override + public void addMana(ItemStack stack, int mana) { + setMana(stack, getMana(stack) + mana); + setManaBacklog(stack, getManaBacklog(stack) + mana); + } + + /*public void addMana(ItemStack stack, int mana) { + IManaPool pool = getManaPool(stack); + if(pool != null) { + pool.recieveMana(mana); + TileEntity tile = (TileEntity) pool; + tile.getWorldObj().func_147453_f(tile.xCoord, tile.yCoord, tile.zCoord, tile.getWorldObj().getBlock(tile.xCoord, tile.yCoord, tile.zCoord)); + } + }*/ + + public void bindPool(ItemStack stack, TileEntity pool) { + ItemNBTHelper.setInt(stack, TAG_POS_X, pool == null ? 0 : pool.xCoord); + ItemNBTHelper.setInt(stack, TAG_POS_Y, pool == null ? -1 : pool.yCoord); + ItemNBTHelper.setInt(stack, TAG_POS_Z, pool == null ? 0 : pool.zCoord); + ItemNBTHelper.setInt(stack, TAG_DIM, pool == null ? 0 : pool.getWorldObj().provider.dimensionId); + } + + public ChunkCoordinates getPoolCoords(ItemStack stack) { + int x = ItemNBTHelper.getInt(stack, TAG_POS_X, 0); + int y = ItemNBTHelper.getInt(stack, TAG_POS_Y, -1); + int z = ItemNBTHelper.getInt(stack, TAG_POS_Z, 0); + return new ChunkCoordinates(x, y, z); + } + + public int getDimension(ItemStack stack) { + return ItemNBTHelper.getInt(stack, TAG_DIM, 0); + } + + public IManaPool getManaPool(ItemStack stack) { + MinecraftServer server = MinecraftServer.getServer(); + if(server == null) + return fallbackPool; + + ChunkCoordinates coords = getPoolCoords(stack); + if(coords.posY == -1) + return null; + + int dim = getDimension(stack); + World world = null; + for(World w : server.worldServers) + if(w.provider.dimensionId == dim) { + world = w; + break; + } + + if(world != null) { + TileEntity tile = world.getTileEntity(coords.posX, coords.posY, coords.posZ); + if(tile != null && tile instanceof IManaPool) + return (IManaPool) tile; + } + + return null; + } + + @Override + public boolean canReceiveManaFromPool(ItemStack stack, TileEntity pool) { + return false; + } + + @Override + public boolean canReceiveManaFromItem(ItemStack stack, ItemStack otherStack) { + return false; + } + + @Override + public boolean canExportManaToPool(ItemStack stack, TileEntity pool) { + return false; + } + + @Override + public boolean canExportManaToItem(ItemStack stack, ItemStack otherStack) { + return true; + } + + private static class DummyPool implements IManaPool { + + @Override + public boolean isFull() { + return false; + } + + @Override + public void recieveMana(int mana) { + // NO-OP + } + + @Override + public boolean canRecieveManaFromBursts() { + return false; + } + + @Override + public int getCurrentMana() { + return 0; + } + + @Override + public boolean isOutputtingPower() { + return false; + } + + } + + @Override + public boolean isNoExport(ItemStack stack) { + return false; + } + + @Override + public ChunkCoordinates getBinding(ItemStack stack) { + IManaPool pool = getManaPool(stack); + + return pool == null || pool instanceof DummyPool ? null : getPoolCoords(stack); + } + + @Override + public float getManaFractionForDisplay(ItemStack stack) { + return (float) getMana(stack) / (float) getMaxMana(stack); + } + } diff --git a/src/main/java/vazkii/botania/common/item/ItemManaTablet.java b/src/main/java/vazkii/botania/common/item/ItemManaTablet.java index af8be9962e..f66cab2a8d 100644 --- a/src/main/java/vazkii/botania/common/item/ItemManaTablet.java +++ b/src/main/java/vazkii/botania/common/item/ItemManaTablet.java @@ -2,16 +2,17 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Mar 7, 2014, 7:06:20 PM (GMT)] */ package vazkii.botania.common.item; import java.awt.Color; import java.util.List; + import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.entity.player.EntityPlayer; @@ -30,152 +31,157 @@ public class ItemManaTablet extends ItemMod implements IManaItem, ICreativeManaProvider, IManaTooltipDisplay { - IIcon[] icons; - - private static final int MAX_MANA = 500000; - - private static final String TAG_MANA = "mana"; - private static final String TAG_CREATIVE = "creative"; - private static final String TAG_ONE_USE = "oneUse"; - - public ItemManaTablet() { - super(); - setMaxStackSize(1); - setMaxDamage(1000); - setUnlocalizedName(LibItemNames.MANA_TABLET); - setNoRepair(); - } - - @Override - public void getSubItems(Item par1, CreativeTabs par2CreativeTabs, List par3List) { - // Empty tablet - par3List.add(new ItemStack(par1, 1)); - - // Full tablet - ItemStack fullPower = new ItemStack(par1, 1); - setMana(fullPower, MAX_MANA); - par3List.add(fullPower); - - // Creative Tablet - ItemStack creative = new ItemStack(par1, 1); - setMana(creative, MAX_MANA); - setStackCreative(creative); - par3List.add(creative); - } - - @Override - public int getColorFromItemStack(ItemStack par1ItemStack, int par2) { - float mana = getMana(par1ItemStack); - return par2 == 1 ? Color.HSBtoRGB(0.528F, mana / MAX_MANA, 1F) : 0xFFFFFF; - } - - @Override - public int getDamage(ItemStack stack) { - // Compatibility shim, so tablets from previous versions of botania - // stack right in barrels and so forth - if (super.getDamage(stack) != 0) super.setDamage(stack, 0); - - return 0; - } - - @Override - public void registerIcons(IIconRegister par1IconRegister) { - icons = new IIcon[2]; - for (int i = 0; i < icons.length; i++) icons[i] = IconHelper.forItem(par1IconRegister, this, i); - } - - @Override - public IIcon getIcon(ItemStack stack, int pass) { - return icons[Math.min(1, pass)]; - } - - @Override - public void addInformation(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, List par3List, boolean par4) { - if (isStackCreative(par1ItemStack)) par3List.add(StatCollector.translateToLocal("botaniamisc.creative")); - } - - @Override - public boolean requiresMultipleRenderPasses() { - return true; - } - - @Override - public int getEntityLifespan(ItemStack itemStack, World world) { - return Integer.MAX_VALUE; - } - - public static void setMana(ItemStack stack, int mana) { - ItemNBTHelper.setInt(stack, TAG_MANA, mana); - } - - public static void setStackCreative(ItemStack stack) { - ItemNBTHelper.setBoolean(stack, TAG_CREATIVE, true); - } - - public static boolean isStackCreative(ItemStack stack) { - return ItemNBTHelper.getBoolean(stack, TAG_CREATIVE, false); - } - - @Override - public int getMana(ItemStack stack) { - return ItemNBTHelper.getInt(stack, TAG_MANA, 0); - } - - @Override - public int getMaxMana(ItemStack stack) { - return isStackCreative(stack) ? MAX_MANA + 1000 : MAX_MANA; - } - - @Override - public void addMana(ItemStack stack, int mana) { - if (!isStackCreative(stack)) setMana(stack, Math.min(getMana(stack) + mana, MAX_MANA)); - } - - @Override - public boolean canReceiveManaFromPool(ItemStack stack, TileEntity pool) { - return !ItemNBTHelper.getBoolean(stack, TAG_ONE_USE, false); - } - - @Override - public boolean canReceiveManaFromItem(ItemStack stack, ItemStack otherStack) { - return !isCreative(stack); - } - - @Override - public boolean canExportManaToPool(ItemStack stack, TileEntity pool) { - return true; - } - - @Override - public boolean canExportManaToItem(ItemStack stack, ItemStack otherStack) { - return true; - } - - @Override - public boolean isNoExport(ItemStack stack) { - return false; - } - - @Override - public boolean isCreative(ItemStack stack) { - return isStackCreative(stack); - } - - @Override - public float getManaFractionForDisplay(ItemStack stack) { - return (float) getMana(stack) / (float) getMaxMana(stack); - } - - @Override - public boolean showDurabilityBar(ItemStack stack) { - // If the stack is not creative, show the durability bar. - return !isStackCreative(stack); - } - - @Override - public double getDurabilityForDisplay(ItemStack stack) { - // I believe Forge has their durability values swapped, hence the (1.0 -). - // This will probably be fixed soon. - return 1.0 - getManaFractionForDisplay(stack); - } + IIcon[] icons; + + private static final int MAX_MANA = 500000; + + private static final String TAG_MANA = "mana"; + private static final String TAG_CREATIVE = "creative"; + private static final String TAG_ONE_USE = "oneUse"; + + public ItemManaTablet() { + super(); + setMaxStackSize(1); + setMaxDamage(1000); + setUnlocalizedName(LibItemNames.MANA_TABLET); + setNoRepair(); + } + + @Override + public void getSubItems(Item par1, CreativeTabs par2CreativeTabs, List par3List) { + // Empty tablet + par3List.add(new ItemStack(par1, 1)); + + // Full tablet + ItemStack fullPower = new ItemStack(par1, 1); + setMana(fullPower, MAX_MANA); + par3List.add(fullPower); + + // Creative Tablet + ItemStack creative = new ItemStack(par1, 1); + setMana(creative, MAX_MANA); + setStackCreative(creative); + par3List.add(creative); + } + + @Override + public int getColorFromItemStack(ItemStack par1ItemStack, int par2) { + float mana = getMana(par1ItemStack); + return par2 == 1 ? Color.HSBtoRGB(0.528F, mana / MAX_MANA, 1F) : 0xFFFFFF; + } + + @Override + public int getDamage(ItemStack stack) { + // Compatibility shim, so tablets from previous versions of botania + // stack right in barrels and so forth + if(super.getDamage(stack) != 0) + super.setDamage(stack, 0); + + return 0; + } + + @Override + public void registerIcons(IIconRegister par1IconRegister) { + icons = new IIcon[2]; + for(int i = 0; i < icons.length; i++) + icons[i] = IconHelper.forItem(par1IconRegister, this, i); + } + + @Override + public IIcon getIcon(ItemStack stack, int pass) { + return icons[Math.min(1, pass)]; + } + + @Override + public void addInformation(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, List par3List, boolean par4) { + if(isStackCreative(par1ItemStack)) + par3List.add(StatCollector.translateToLocal("botaniamisc.creative")); + } + + @Override + public boolean requiresMultipleRenderPasses() { + return true; + } + + @Override + public int getEntityLifespan(ItemStack itemStack, World world) { + return Integer.MAX_VALUE; + } + + public static void setMana(ItemStack stack, int mana) { + ItemNBTHelper.setInt(stack, TAG_MANA, mana); + } + + public static void setStackCreative(ItemStack stack) { + ItemNBTHelper.setBoolean(stack, TAG_CREATIVE, true); + } + + public static boolean isStackCreative(ItemStack stack) { + return ItemNBTHelper.getBoolean(stack, TAG_CREATIVE, false); + } + + @Override + public int getMana(ItemStack stack) { + return ItemNBTHelper.getInt(stack, TAG_MANA, 0); + } + + @Override + public int getMaxMana(ItemStack stack) { + return isStackCreative(stack) ? MAX_MANA + 1000 : MAX_MANA; + } + + @Override + public void addMana(ItemStack stack, int mana) { + if(!isStackCreative(stack)) + setMana(stack, Math.min(getMana(stack) + mana, MAX_MANA)); + } + + @Override + public boolean canReceiveManaFromPool(ItemStack stack, TileEntity pool) { + return !ItemNBTHelper.getBoolean(stack, TAG_ONE_USE, false); + } + + @Override + public boolean canReceiveManaFromItem(ItemStack stack, ItemStack otherStack) { + return !isCreative(stack); + } + + @Override + public boolean canExportManaToPool(ItemStack stack, TileEntity pool) { + return true; + } + + @Override + public boolean canExportManaToItem(ItemStack stack, ItemStack otherStack) { + return true; + } + + @Override + public boolean isNoExport(ItemStack stack) { + return false; + } + + @Override + public boolean isCreative(ItemStack stack) { + return isStackCreative(stack); + } + + @Override + public float getManaFractionForDisplay(ItemStack stack) { + return (float) getMana(stack) / (float) getMaxMana(stack); + } + + + @Override + public boolean showDurabilityBar(ItemStack stack) { + // If the stack is not creative, show the durability bar. + return !isStackCreative(stack); + } + + @Override + public double getDurabilityForDisplay(ItemStack stack) { + // I believe Forge has their durability values swapped, hence the (1.0 -). + // This will probably be fixed soon. + return 1.0 - getManaFractionForDisplay(stack); + } } diff --git a/src/main/java/vazkii/botania/common/item/ItemMod.java b/src/main/java/vazkii/botania/common/item/ItemMod.java index 41868acf79..4e20174df1 100644 --- a/src/main/java/vazkii/botania/common/item/ItemMod.java +++ b/src/main/java/vazkii/botania/common/item/ItemMod.java @@ -2,46 +2,45 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jan 14, 2014, 5:30:18 PM (GMT)] */ package vazkii.botania.common.item; -import cpw.mods.fml.common.registry.GameRegistry; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import vazkii.botania.client.core.helper.IconHelper; import vazkii.botania.client.lib.LibResources; import vazkii.botania.common.core.BotaniaCreativeTab; +import cpw.mods.fml.common.registry.GameRegistry; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; public class ItemMod extends Item { - public ItemMod() { - super(); - setCreativeTab(BotaniaCreativeTab.INSTANCE); - } + public ItemMod() { + super(); + setCreativeTab(BotaniaCreativeTab.INSTANCE); + } - @Override - public Item setUnlocalizedName(String par1Str) { - GameRegistry.registerItem(this, par1Str); - return super.setUnlocalizedName(par1Str); - } + @Override + public Item setUnlocalizedName(String par1Str) { + GameRegistry.registerItem(this, par1Str); + return super.setUnlocalizedName(par1Str); + } - @Override - public String getUnlocalizedNameInefficiently(ItemStack par1ItemStack) { - return super.getUnlocalizedNameInefficiently(par1ItemStack) - .replaceAll("item\\.", "item." + LibResources.PREFIX_MOD); - } + @Override + public String getUnlocalizedNameInefficiently(ItemStack par1ItemStack) { + return super.getUnlocalizedNameInefficiently(par1ItemStack).replaceAll("item\\.", "item." + LibResources.PREFIX_MOD); + } - @Override - @SideOnly(Side.CLIENT) - public void registerIcons(IIconRegister par1IconRegister) { - itemIcon = IconHelper.forItem(par1IconRegister, this); - } -} + @Override + @SideOnly(Side.CLIENT) + public void registerIcons(IIconRegister par1IconRegister) { + itemIcon = IconHelper.forItem(par1IconRegister, this); + } +} \ No newline at end of file diff --git a/src/main/java/vazkii/botania/common/item/ItemObedienceStick.java b/src/main/java/vazkii/botania/common/item/ItemObedienceStick.java index 43b0570006..acce895e6b 100644 --- a/src/main/java/vazkii/botania/common/item/ItemObedienceStick.java +++ b/src/main/java/vazkii/botania/common/item/ItemObedienceStick.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jul 20, 2015, 7:26:14 PM (GMT)] */ package vazkii.botania.common.item; @@ -26,78 +26,74 @@ public class ItemObedienceStick extends ItemMod { - public ItemObedienceStick() { - setMaxStackSize(1); - setUnlocalizedName(LibItemNames.OBEDIENCE_STICK); - } - - @Override - public boolean onItemUse( - ItemStack stack, - EntityPlayer player, - World world, - int x, - int y, - int z, - int s, - float xs, - float ys, - float zs) { - TileEntity tileAt = world.getTileEntity(x, y, z); - if (tileAt != null && (tileAt instanceof IManaPool || tileAt instanceof IManaCollector)) { - boolean pool = tileAt instanceof IManaPool; - Actuator act = pool ? Actuator.functionalActuator : Actuator.generatingActuator; - int range = pool ? SubTileFunctional.RANGE : SubTileGenerating.RANGE; - - for (int i = -range; i < range + 1; i++) - for (int j = -range; j < range + 1; j++) - for (int k = -range; k < range + 1; k++) { - int xp = x + i; - int yp = y + j; - int zp = z + k; - if (MathHelper.pointDistanceSpace(xp, yp, zp, x, y, z) > range) continue; - - TileEntity tile = world.getTileEntity(xp, yp, zp); - if (tile instanceof ISubTileContainer) { - SubTileEntity subtile = ((ISubTileContainer) tile).getSubTile(); - if (act.actuate(subtile, tileAt)) { - Vector3 orig = new Vector3(xp + 0.5, yp + 0.5, zp + 0.5); - Vector3 end = new Vector3(x + 0.5, y + 0.5, z + 0.5); - ItemTwigWand.doParticleBeam(world, orig, end); - } - } - } - - if (player.worldObj.isRemote) player.swingItem(); - } - return false; - } - - public abstract static class Actuator { - public static final Actuator generatingActuator = new Actuator() { - - @Override - public boolean actuate(SubTileEntity flower, TileEntity tile) { - if (flower instanceof SubTileGenerating) { - ((SubTileGenerating) flower).linkToForcefully(tile); - return true; - } - return false; - } - }; - - public static final Actuator functionalActuator = new Actuator() { - - @Override - public boolean actuate(SubTileEntity flower, TileEntity tile) { - if (flower instanceof SubTileFunctional) { - ((SubTileFunctional) flower).linkToForcefully(tile); - return true; - } - return false; - } - }; - - public abstract boolean actuate(SubTileEntity flower, TileEntity tile); - } + public ItemObedienceStick() { + setMaxStackSize(1); + setUnlocalizedName(LibItemNames.OBEDIENCE_STICK); + } + + @Override + public boolean onItemUse(ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int s, float xs, float ys, float zs) { + TileEntity tileAt = world.getTileEntity(x, y, z); + if(tileAt != null && (tileAt instanceof IManaPool || tileAt instanceof IManaCollector)) { + boolean pool = tileAt instanceof IManaPool; + Actuator act = pool ? Actuator.functionalActuator : Actuator.generatingActuator; + int range = pool ? SubTileFunctional.RANGE : SubTileGenerating.RANGE; + + for(int i = -range; i < range + 1; i++) + for(int j = -range; j < range + 1; j++) + for(int k = -range; k < range + 1; k++) { + int xp = x + i; + int yp = y + j; + int zp = z + k; + if(MathHelper.pointDistanceSpace(xp, yp, zp, x, y, z) > range) + continue; + + TileEntity tile = world.getTileEntity(xp, yp, zp); + if(tile instanceof ISubTileContainer) { + SubTileEntity subtile = ((ISubTileContainer) tile).getSubTile(); + if(act.actuate(subtile, tileAt)) { + Vector3 orig = new Vector3(xp + 0.5, yp + 0.5, zp + 0.5); + Vector3 end = new Vector3(x + 0.5, y + 0.5, z + 0.5); + ItemTwigWand.doParticleBeam(world, orig, end); + } + } + } + + if(player.worldObj.isRemote) + player.swingItem(); + } + return false; + } + + public static abstract class Actuator { + public static final Actuator generatingActuator = new Actuator() { + + @Override + public boolean actuate(SubTileEntity flower, TileEntity tile) { + if(flower instanceof SubTileGenerating) { + ((SubTileGenerating) flower).linkToForcefully(tile); + return true; + } + return false; + } + + }; + + public static final Actuator functionalActuator = new Actuator() { + + @Override + public boolean actuate(SubTileEntity flower, TileEntity tile) { + if(flower instanceof SubTileFunctional) { + ((SubTileFunctional) flower).linkToForcefully(tile); + return true; + } + return false; + } + + }; + + public abstract boolean actuate(SubTileEntity flower, TileEntity tile); + + } + } diff --git a/src/main/java/vazkii/botania/common/item/ItemOpenBucket.java b/src/main/java/vazkii/botania/common/item/ItemOpenBucket.java index 75474346f8..8acc06d907 100644 --- a/src/main/java/vazkii/botania/common/item/ItemOpenBucket.java +++ b/src/main/java/vazkii/botania/common/item/ItemOpenBucket.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jun 20, 2014, 12:12:58 AM (GMT)] */ package vazkii.botania.common.item; @@ -15,47 +15,49 @@ import net.minecraft.item.ItemStack; import net.minecraft.util.MovingObjectPosition; import net.minecraft.world.World; +import vazkii.botania.common.block.subtile.functional.SubTileSpectranthemum; import vazkii.botania.common.lib.LibItemNames; public class ItemOpenBucket extends ItemMod { - public ItemOpenBucket() { - setMaxStackSize(1); - setUnlocalizedName(LibItemNames.OPEN_BUCKET); - } + public ItemOpenBucket() { + setMaxStackSize(1); + setUnlocalizedName(LibItemNames.OPEN_BUCKET); + } + + @Override + public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer) { + MovingObjectPosition movingobjectposition = getMovingObjectPositionFromPlayer(par2World, par3EntityPlayer, true); + + if(movingobjectposition == null) + return par1ItemStack; + else { + if(movingobjectposition.typeOfHit == MovingObjectPosition.MovingObjectType.BLOCK) { + int i = movingobjectposition.blockX; + int j = movingobjectposition.blockY; + int k = movingobjectposition.blockZ; + + if(!par2World.canMineBlock(par3EntityPlayer, i, j, k)) + return par1ItemStack; + + if(!par3EntityPlayer.canPlayerEdit(i, j, k, movingobjectposition.sideHit, par1ItemStack)) + return par1ItemStack; + + Material material = par2World.getBlock(i, j, k).getMaterial(); + int l = par2World.getBlockMetadata(i, j, k); + + if((material == Material.lava || material == Material.water) && l == 0) { + par2World.setBlockToAir(i, j, k); + + for(int x = 0; x < 5; x++) + par2World.spawnParticle("explode", i + Math.random(), j + Math.random(), k + Math.random(), 0, 0, 0); + + return par1ItemStack; + } + } + + return par1ItemStack; + } + } - @Override - public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer) { - MovingObjectPosition movingobjectposition = - getMovingObjectPositionFromPlayer(par2World, par3EntityPlayer, true); - - if (movingobjectposition == null) return par1ItemStack; - else { - if (movingobjectposition.typeOfHit == MovingObjectPosition.MovingObjectType.BLOCK) { - int i = movingobjectposition.blockX; - int j = movingobjectposition.blockY; - int k = movingobjectposition.blockZ; - - if (!par2World.canMineBlock(par3EntityPlayer, i, j, k)) return par1ItemStack; - - if (!par3EntityPlayer.canPlayerEdit(i, j, k, movingobjectposition.sideHit, par1ItemStack)) - return par1ItemStack; - - Material material = par2World.getBlock(i, j, k).getMaterial(); - int l = par2World.getBlockMetadata(i, j, k); - - if ((material == Material.lava || material == Material.water) && l == 0) { - par2World.setBlockToAir(i, j, k); - - for (int x = 0; x < 5; x++) - par2World.spawnParticle( - "explode", i + Math.random(), j + Math.random(), k + Math.random(), 0, 0, 0); - - return par1ItemStack; - } - } - - return par1ItemStack; - } - } } diff --git a/src/main/java/vazkii/botania/common/item/ItemOvergrowthSeed.java b/src/main/java/vazkii/botania/common/item/ItemOvergrowthSeed.java index e5975274f5..fd9c25a08c 100644 --- a/src/main/java/vazkii/botania/common/item/ItemOvergrowthSeed.java +++ b/src/main/java/vazkii/botania/common/item/ItemOvergrowthSeed.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jan 26, 2015, 5:59:21 PM (GMT)] */ package vazkii.botania.common.item; @@ -20,35 +20,26 @@ public class ItemOvergrowthSeed extends ItemMod { - public ItemOvergrowthSeed() { - setUnlocalizedName(LibItemNames.OVERGROWTH_SEED); - } + public ItemOvergrowthSeed() { + setUnlocalizedName(LibItemNames.OVERGROWTH_SEED); + } - @Override - public boolean onItemUse( - ItemStack stack, - EntityPlayer player, - World world, - int x, - int y, - int z, - int s, - float xs, - float ys, - float zs) { - Block block = world.getBlock(x, y, z); - ItemStack blockStack = new ItemStack(block); - int[] ids = OreDictionary.getOreIDs(blockStack); - for (int i : ids) { - String name = OreDictionary.getOreName(i); - if (name.equals("grass")) { - world.playAuxSFX(2001, x, y, z, Block.getIdFromBlock(block)); - world.setBlock(x, y, z, ModBlocks.enchantedSoil); - stack.stackSize--; + @Override + public boolean onItemUse(ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int s, float xs, float ys, float zs) { + Block block = world.getBlock(x, y, z); + ItemStack blockStack = new ItemStack(block); + int[] ids = OreDictionary.getOreIDs(blockStack); + for(int i : ids) { + String name = OreDictionary.getOreName(i); + if(name.equals("grass")) { + world.playAuxSFX(2001, x, y, z, Block.getIdFromBlock(block)); + world.setBlock(x, y, z, ModBlocks.enchantedSoil); + stack.stackSize--; + + return true; + } + } + return false; + } - return true; - } - } - return false; - } } diff --git a/src/main/java/vazkii/botania/common/item/ItemPhantomInk.java b/src/main/java/vazkii/botania/common/item/ItemPhantomInk.java index eff12a9530..c3a90547b0 100644 --- a/src/main/java/vazkii/botania/common/item/ItemPhantomInk.java +++ b/src/main/java/vazkii/botania/common/item/ItemPhantomInk.java @@ -2,25 +2,26 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Mar 17, 2015, 4:46:36 PM (GMT)] */ package vazkii.botania.common.item; -import cpw.mods.fml.common.registry.GameRegistry; import net.minecraftforge.oredict.RecipeSorter; import net.minecraftforge.oredict.RecipeSorter.Category; import vazkii.botania.common.crafting.recipe.PhantomInkRecipe; import vazkii.botania.common.lib.LibItemNames; +import cpw.mods.fml.common.registry.GameRegistry; public class ItemPhantomInk extends ItemMod { - public ItemPhantomInk() { - setUnlocalizedName(LibItemNames.PHANTOM_INK); - GameRegistry.addRecipe(new PhantomInkRecipe()); - RecipeSorter.register("botania:phantomInk", PhantomInkRecipe.class, Category.SHAPELESS, ""); - } + public ItemPhantomInk() { + setUnlocalizedName(LibItemNames.PHANTOM_INK); + GameRegistry.addRecipe(new PhantomInkRecipe()); + RecipeSorter.register("botania:phantomInk", PhantomInkRecipe.class, Category.SHAPELESS, ""); + } + } diff --git a/src/main/java/vazkii/botania/common/item/ItemPinkinator.java b/src/main/java/vazkii/botania/common/item/ItemPinkinator.java index e6bf2536c4..d684432db1 100644 --- a/src/main/java/vazkii/botania/common/item/ItemPinkinator.java +++ b/src/main/java/vazkii/botania/common/item/ItemPinkinator.java @@ -2,15 +2,16 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Mar 25, 2015, 6:03:28 PM (GMT)] */ package vazkii.botania.common.item; import java.util.List; + import net.minecraft.entity.boss.EntityWither; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; @@ -23,50 +24,38 @@ public class ItemPinkinator extends ItemMod { - public ItemPinkinator() { - setUnlocalizedName(LibItemNames.PINKINATOR); - setMaxStackSize(1); - setFull3D(); - } + public ItemPinkinator() { + setUnlocalizedName(LibItemNames.PINKINATOR); + setMaxStackSize(1); + setFull3D(); + } + + @Override + public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer player) { + int range = 16; + List withers = world.getEntitiesWithinAABB(EntityWither.class, AxisAlignedBB.getBoundingBox(player.posX - range, player.posY - range, player.posZ - range, player.posX + range, player.posY + range, player.posZ + range)); + for(EntityWither wither : withers) + if(!wither.isDead && !(wither instanceof EntityPinkWither)) { + if(!world.isRemote) { + wither.setDead(); + EntityPinkWither pink = new EntityPinkWither(world); + pink.setLocationAndAngles(wither.posX, wither.posY, wither.posZ, wither.rotationYaw, wither.rotationPitch); + world.spawnEntityInWorld(pink); + world.playSoundAtEntity(wither, "random.explode", 4F, (1F + (world.rand.nextFloat() - world.rand.nextFloat()) * 0.2F) * 0.7F); + } + player.addStat(ModAchievements.pinkinator, 1); - @Override - public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer player) { - int range = 16; - List withers = world.getEntitiesWithinAABB( - EntityWither.class, - AxisAlignedBB.getBoundingBox( - player.posX - range, - player.posY - range, - player.posZ - range, - player.posX + range, - player.posY + range, - player.posZ + range)); - for (EntityWither wither : withers) - if (!wither.isDead && !(wither instanceof EntityPinkWither)) { - if (!world.isRemote) { - wither.setDead(); - EntityPinkWither pink = new EntityPinkWither(world); - pink.setLocationAndAngles( - wither.posX, wither.posY, wither.posZ, wither.rotationYaw, wither.rotationPitch); - world.spawnEntityInWorld(pink); - world.playSoundAtEntity( - wither, - "random.explode", - 4F, - (1F + (world.rand.nextFloat() - world.rand.nextFloat()) * 0.2F) * 0.7F); - } - player.addStat(ModAchievements.pinkinator, 1); + world.spawnParticle("hugeexplosion", wither.posX, wither.posY, wither.posZ, 1D, 0D, 0D); + stack.stackSize--; + return stack; + } - world.spawnParticle("hugeexplosion", wither.posX, wither.posY, wither.posZ, 1D, 0D, 0D); - stack.stackSize--; - return stack; - } + return stack; + } - return stack; - } + @Override + public void addInformation(ItemStack p_77624_1_, EntityPlayer p_77624_2_, List p_77624_3_, boolean p_77624_4_) { + p_77624_3_.add(StatCollector.translateToLocal("botaniamisc.pinkinatorDesc")); + } - @Override - public void addInformation(ItemStack p_77624_1_, EntityPlayer p_77624_2_, List p_77624_3_, boolean p_77624_4_) { - p_77624_3_.add(StatCollector.translateToLocal("botaniamisc.pinkinatorDesc")); - } } diff --git a/src/main/java/vazkii/botania/common/item/ItemPoolMinecart.java b/src/main/java/vazkii/botania/common/item/ItemPoolMinecart.java index 43f6409934..248d72917c 100644 --- a/src/main/java/vazkii/botania/common/item/ItemPoolMinecart.java +++ b/src/main/java/vazkii/botania/common/item/ItemPoolMinecart.java @@ -2,16 +2,14 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Mar 17, 2015, 6:48:29 PM (GMT)] */ package vazkii.botania.common.item; -import com.mojang.authlib.GameProfile; -import cpw.mods.fml.common.Optional; import mods.railcraft.api.core.items.IMinecartItem; import net.minecraft.block.BlockRailBase; import net.minecraft.entity.item.EntityMinecart; @@ -25,64 +23,61 @@ import vazkii.botania.common.entity.EntityPoolMinecart; import vazkii.botania.common.lib.LibItemNames; +import com.mojang.authlib.GameProfile; + +import cpw.mods.fml.common.Optional; + @Optional.Interface(modid = "Railcraft", iface = "mods.railcraft.api.core.items.IMinecartItem", striprefs = true) public class ItemPoolMinecart extends ItemMod implements ICraftAchievement, IMinecartItem { - public ItemPoolMinecart() { - setMaxStackSize(1); - setUnlocalizedName(LibItemNames.POOL_MINECART); - } - - @Override - public boolean onItemUse( - ItemStack p_77648_1_, - EntityPlayer p_77648_2_, - World p_77648_3_, - int p_77648_4_, - int p_77648_5_, - int p_77648_6_, - int p_77648_7_, - float p_77648_8_, - float p_77648_9_, - float p_77648_10_) { - if (BlockRailBase.func_150051_a(p_77648_3_.getBlock(p_77648_4_, p_77648_5_, p_77648_6_))) { - if (!p_77648_3_.isRemote) { - EntityMinecart entityminecart = - new EntityPoolMinecart(p_77648_3_, p_77648_4_ + 0.5, p_77648_5_ + 0.5, p_77648_6_ + 0.5); - - if (p_77648_1_.hasDisplayName()) entityminecart.setMinecartName(p_77648_1_.getDisplayName()); - - p_77648_3_.spawnEntityInWorld(entityminecart); - } - - --p_77648_1_.stackSize; - return true; - } - - return false; - } - - @Override - public Achievement getAchievementOnCraft(ItemStack stack, EntityPlayer player, IInventory matrix) { - return ModAchievements.manaCartCraft; - } - - @Override - public boolean canBePlacedByNonPlayer(ItemStack cart) { - return true; - } - - @Override - public EntityMinecart placeCart(GameProfile owner, ItemStack cart, World world, int i, int j, int k) { - if (BlockRailBase.func_150051_a(world.getBlock(i, j, k))) { - if (!world.isRemote) { - EntityMinecart entityminecart = new EntityPoolMinecart(world, i + 0.5, j + 0.5, k + 0.5); - - if (cart.hasDisplayName()) entityminecart.setMinecartName(cart.getDisplayName()); - - if (world.spawnEntityInWorld(entityminecart)) return entityminecart; - } - } - return null; - } + public ItemPoolMinecart() { + setMaxStackSize(1); + setUnlocalizedName(LibItemNames.POOL_MINECART); + } + + @Override + public boolean onItemUse(ItemStack p_77648_1_, EntityPlayer p_77648_2_, World p_77648_3_, int p_77648_4_, int p_77648_5_, int p_77648_6_, int p_77648_7_, float p_77648_8_, float p_77648_9_, float p_77648_10_) { + if(BlockRailBase.func_150051_a(p_77648_3_.getBlock(p_77648_4_, p_77648_5_, p_77648_6_))) { + if(!p_77648_3_.isRemote) { + EntityMinecart entityminecart = new EntityPoolMinecart(p_77648_3_, p_77648_4_ + 0.5, p_77648_5_ + 0.5, p_77648_6_ + 0.5); + + if(p_77648_1_.hasDisplayName()) + entityminecart.setMinecartName(p_77648_1_.getDisplayName()); + + p_77648_3_.spawnEntityInWorld(entityminecart); + } + + --p_77648_1_.stackSize; + return true; + } + + return false; + } + + @Override + public Achievement getAchievementOnCraft(ItemStack stack, EntityPlayer player, IInventory matrix) { + return ModAchievements.manaCartCraft; + } + + @Override + public boolean canBePlacedByNonPlayer(ItemStack cart) { + return true; + } + + @Override + public EntityMinecart placeCart(GameProfile owner, ItemStack cart, World world, int i, int j, int k) { + if(BlockRailBase.func_150051_a(world.getBlock(i, j, k))) { + if(!world.isRemote) { + EntityMinecart entityminecart = new EntityPoolMinecart(world, i + 0.5,j + 0.5, k + 0.5); + + if(cart.hasDisplayName()) + entityminecart.setMinecartName(cart.getDisplayName()); + + if(world.spawnEntityInWorld(entityminecart)) + return entityminecart; + } + } + return null; + } + } diff --git a/src/main/java/vazkii/botania/common/item/ItemRegenIvy.java b/src/main/java/vazkii/botania/common/item/ItemRegenIvy.java index 2a0f8091b6..20d7254304 100644 --- a/src/main/java/vazkii/botania/common/item/ItemRegenIvy.java +++ b/src/main/java/vazkii/botania/common/item/ItemRegenIvy.java @@ -2,20 +2,14 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Sep 3, 2014, 6:31:10 PM (GMT)] */ package vazkii.botania.common.item; -import cpw.mods.fml.common.FMLCommonHandler; -import cpw.mods.fml.common.eventhandler.EventPriority; -import cpw.mods.fml.common.eventhandler.SubscribeEvent; -import cpw.mods.fml.common.gameevent.TickEvent.Phase; -import cpw.mods.fml.common.gameevent.TickEvent.PlayerTickEvent; -import cpw.mods.fml.common.registry.GameRegistry; import net.minecraft.item.ItemStack; import net.minecraftforge.oredict.RecipeSorter; import net.minecraftforge.oredict.RecipeSorter.Category; @@ -23,30 +17,32 @@ import vazkii.botania.common.core.helper.ItemNBTHelper; import vazkii.botania.common.crafting.recipe.RegenIvyRecipe; import vazkii.botania.common.lib.LibItemNames; +import cpw.mods.fml.common.FMLCommonHandler; +import cpw.mods.fml.common.eventhandler.EventPriority; +import cpw.mods.fml.common.eventhandler.SubscribeEvent; +import cpw.mods.fml.common.gameevent.TickEvent.Phase; +import cpw.mods.fml.common.gameevent.TickEvent.PlayerTickEvent; +import cpw.mods.fml.common.registry.GameRegistry; public class ItemRegenIvy extends ItemMod { - public static final String TAG_REGEN = "Botania_regenIvy"; - private static final int MANA_PER_DAMAGE = 200; + public static final String TAG_REGEN = "Botania_regenIvy"; + private static final int MANA_PER_DAMAGE = 200; - public ItemRegenIvy() { - setUnlocalizedName(LibItemNames.REGEN_IVY); - GameRegistry.addRecipe(new RegenIvyRecipe()); - RecipeSorter.register("botania:regenIvy", RegenIvyRecipe.class, Category.SHAPELESS, ""); - FMLCommonHandler.instance().bus().register(this); - } + public ItemRegenIvy() { + setUnlocalizedName(LibItemNames.REGEN_IVY); + GameRegistry.addRecipe(new RegenIvyRecipe()); + RecipeSorter.register("botania:regenIvy", RegenIvyRecipe.class, Category.SHAPELESS, ""); + FMLCommonHandler.instance().bus().register(this); + } - @SubscribeEvent(priority = EventPriority.LOWEST) - public void onTick(PlayerTickEvent event) { - if (event.phase == Phase.END && !event.player.worldObj.isRemote) - for (int i = 0; i < event.player.inventory.getSizeInventory(); i++) { - ItemStack stack = event.player.inventory.getStackInSlot(i); - if (stack != null - && ItemNBTHelper.detectNBT(stack) - && ItemNBTHelper.getBoolean(stack, TAG_REGEN, false) - && stack.getItemDamage() > 0 - && ManaItemHandler.requestManaExact(stack, event.player, MANA_PER_DAMAGE, true)) - stack.setItemDamage(stack.getItemDamage() - 1); - } - } + @SubscribeEvent(priority = EventPriority.LOWEST) + public void onTick(PlayerTickEvent event) { + if(event.phase == Phase.END && !event.player.worldObj.isRemote) + for(int i = 0; i < event.player.inventory.getSizeInventory(); i++) { + ItemStack stack = event.player.inventory.getStackInSlot(i); + if(stack != null && ItemNBTHelper.detectNBT(stack) && ItemNBTHelper.getBoolean(stack, TAG_REGEN, false) && stack.getItemDamage() > 0 && ManaItemHandler.requestManaExact(stack, event.player, MANA_PER_DAMAGE, true)) + stack.setItemDamage(stack.getItemDamage() - 1); + } + } } diff --git a/src/main/java/vazkii/botania/common/item/ItemSextant.java b/src/main/java/vazkii/botania/common/item/ItemSextant.java index 14ec92f04a..fff78921f6 100644 --- a/src/main/java/vazkii/botania/common/item/ItemSextant.java +++ b/src/main/java/vazkii/botania/common/item/ItemSextant.java @@ -2,16 +2,14 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [01/11/2015, 18:25:54 (GMT)] */ package vazkii.botania.common.item; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.FontRenderer; import net.minecraft.client.gui.ScaledResolution; @@ -21,7 +19,9 @@ import net.minecraft.item.ItemStack; import net.minecraft.util.MovingObjectPosition; import net.minecraft.world.World; + import org.lwjgl.opengl.GL11; + import vazkii.botania.api.lexicon.multiblock.Multiblock; import vazkii.botania.common.Botania; import vazkii.botania.common.core.helper.ItemNBTHelper; @@ -29,139 +29,145 @@ import vazkii.botania.common.core.helper.Vector3; import vazkii.botania.common.item.equipment.tool.ToolCommons; import vazkii.botania.common.lib.LibItemNames; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; public class ItemSextant extends ItemMod { - private static final String TAG_SOURCE_X = "sourceX"; - private static final String TAG_SOURCE_Y = "sourceY"; - private static final String TAG_SOURCE_Z = "sourceZ"; - - public ItemSextant() { - setUnlocalizedName(LibItemNames.SEXTANT); - setMaxStackSize(1); - } - - @Override - public EnumAction getItemUseAction(ItemStack par1ItemStack) { - return EnumAction.bow; - } - - @Override - public int getMaxItemUseDuration(ItemStack par1ItemStack) { - return 72000; - } - - @Override - public void onUsingTick(ItemStack stack, EntityPlayer player, int count) { - if (getMaxItemUseDuration(stack) - count < 10) return; - - int x = ItemNBTHelper.getInt(stack, TAG_SOURCE_X, 0); - int y = ItemNBTHelper.getInt(stack, TAG_SOURCE_Y, -1); - int z = ItemNBTHelper.getInt(stack, TAG_SOURCE_Z, 0); - if (y != -1) { - World world = player.worldObj; - Vector3 source = new Vector3(x, y, z); - - double radius = calculateRadius(stack, player); - - if (count % 10 == 0) - for (int i = 0; i < 360; i++) { - float radian = (float) (i * Math.PI / 180); - double xp = x + Math.cos(radian) * radius; - double zp = z + Math.sin(radian) * radius; - Botania.proxy.wispFX(world, xp + 0.5, source.y + 1, zp + 0.5, 0F, 1F, 1F, 0.3F, -0.01F); - } - } - } - - @Override - public void onPlayerStoppedUsing(ItemStack stack, World world, EntityPlayer player, int time) { - double radius = calculateRadius(stack, player); - if (radius > 1) { - int x = ItemNBTHelper.getInt(stack, TAG_SOURCE_X, 0); - int y = ItemNBTHelper.getInt(stack, TAG_SOURCE_Y, -1); - int z = ItemNBTHelper.getInt(stack, TAG_SOURCE_Z, 0); - if (y != -1) Botania.proxy.setMultiblock(world, x, y, z, radius, Blocks.cobblestone); - } - } - - @Override - public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer) { - Botania.proxy.removeSextantMultiblock(); - - if (!par3EntityPlayer.isSneaking()) { - MovingObjectPosition pos = ToolCommons.raytraceFromEntity(par2World, par3EntityPlayer, false, 128); - if (pos != null && pos.entityHit == null) { - if (!par2World.isRemote) { - ItemNBTHelper.setInt(par1ItemStack, TAG_SOURCE_X, pos.blockX); - ItemNBTHelper.setInt(par1ItemStack, TAG_SOURCE_Y, pos.blockY); - ItemNBTHelper.setInt(par1ItemStack, TAG_SOURCE_Z, pos.blockZ); - } - } else ItemNBTHelper.setInt(par1ItemStack, TAG_SOURCE_Y, -1); - - par3EntityPlayer.setItemInUse(par1ItemStack, getMaxItemUseDuration(par1ItemStack)); - } - - return par1ItemStack; - } - - public static double calculateRadius(ItemStack stack, EntityPlayer player) { - int x = ItemNBTHelper.getInt(stack, TAG_SOURCE_X, 0); - int y = ItemNBTHelper.getInt(stack, TAG_SOURCE_Y, -1); - int z = ItemNBTHelper.getInt(stack, TAG_SOURCE_Z, 0); - World world = player.worldObj; - Vector3 source = new Vector3(x, y, z); - Botania.proxy.wispFX(world, source.x + 0.5, source.y + 1, source.z + 0.5, 1F, 0F, 0F, 0.2F, -0.1F); - - Vector3 centerVec = Vector3.fromEntityCenter(player); - Vector3 diffVec = source.copy().subtract(centerVec); - Vector3 lookVec = new Vector3(player.getLookVec()); - double mul = diffVec.y / lookVec.y; - lookVec.multiply(mul).add(centerVec); - - lookVec.x = net.minecraft.util.MathHelper.floor_double(lookVec.x); - lookVec.z = net.minecraft.util.MathHelper.floor_double(lookVec.z); - - return MathHelper.pointDistancePlane(source.x, source.z, lookVec.x, lookVec.z); - } - - @SideOnly(Side.CLIENT) - public static void renderHUD(ScaledResolution resolution, EntityPlayer player, ItemStack stack) { - ItemStack onUse = player.getItemInUse(); - int time = player.getItemInUseCount(); - - if (onUse == stack && stack.getItem().getMaxItemUseDuration(stack) - time >= 10) { - double radius = calculateRadius(stack, player); - FontRenderer font = Minecraft.getMinecraft().fontRenderer; - int x = resolution.getScaledWidth() / 2 + 30; - int y = resolution.getScaledHeight() / 2; - - String s = "" + (int) radius; - font.drawStringWithShadow(s, x - font.getStringWidth(s) / 2, y - 4, 0xFFFFFF); - - if (radius > 0) { - radius += 4; - GL11.glDisable(GL11.GL_TEXTURE_2D); - GL11.glLineWidth(3F); - GL11.glBegin(GL11.GL_LINE_STRIP); - GL11.glColor4f(0F, 1F, 1F, 1F); - for (int i = 0; i < 361; i++) { - float radian = (float) (i * Math.PI / 180); - double xp = x + Math.cos(radian) * radius; - double yp = y + Math.sin(radian) * radius; - GL11.glVertex2d(xp, yp); - } - GL11.glEnd(); - GL11.glEnable(GL11.GL_TEXTURE_2D); - } - } - } - - public static class MultiblockSextant extends Multiblock { - - @Override - public Multiblock[] createRotations() { - return new Multiblock[] {this}; - } - } + private static final String TAG_SOURCE_X = "sourceX"; + private static final String TAG_SOURCE_Y = "sourceY"; + private static final String TAG_SOURCE_Z = "sourceZ"; + + public ItemSextant() { + setUnlocalizedName(LibItemNames.SEXTANT); + setMaxStackSize(1); + } + + @Override + public EnumAction getItemUseAction(ItemStack par1ItemStack) { + return EnumAction.bow; + } + + @Override + public int getMaxItemUseDuration(ItemStack par1ItemStack) { + return 72000; + } + + @Override + public void onUsingTick(ItemStack stack, EntityPlayer player, int count) { + if(getMaxItemUseDuration(stack) - count < 10) + return; + + int x = ItemNBTHelper.getInt(stack, TAG_SOURCE_X, 0); + int y = ItemNBTHelper.getInt(stack, TAG_SOURCE_Y, -1); + int z = ItemNBTHelper.getInt(stack, TAG_SOURCE_Z, 0); + if(y != -1) { + World world = player.worldObj; + Vector3 source = new Vector3(x, y, z); + + double radius = calculateRadius(stack, player); + + if(count % 10 == 0) + for(int i = 0; i < 360; i++) { + float radian = (float) (i * Math.PI / 180); + double xp = x + Math.cos(radian) * radius; + double zp = z + Math.sin(radian) * radius; + Botania.proxy.wispFX(world, xp + 0.5, source.y + 1, zp + 0.5, 0F, 1F, 1F, 0.3F, -0.01F); + } + } + } + + @Override + public void onPlayerStoppedUsing(ItemStack stack, World world, EntityPlayer player, int time) { + double radius = calculateRadius(stack, player); + if(radius > 1) { + int x = ItemNBTHelper.getInt(stack, TAG_SOURCE_X, 0); + int y = ItemNBTHelper.getInt(stack, TAG_SOURCE_Y, -1); + int z = ItemNBTHelper.getInt(stack, TAG_SOURCE_Z, 0); + if(y != -1) + Botania.proxy.setMultiblock(world, x, y, z, radius, Blocks.cobblestone); + } + } + + @Override + public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer) { + Botania.proxy.removeSextantMultiblock(); + + if(!par3EntityPlayer.isSneaking()) { + MovingObjectPosition pos = ToolCommons.raytraceFromEntity(par2World, par3EntityPlayer, false, 128); + if(pos != null && pos.entityHit == null) { + if(!par2World.isRemote) { + ItemNBTHelper.setInt(par1ItemStack, TAG_SOURCE_X, pos.blockX); + ItemNBTHelper.setInt(par1ItemStack, TAG_SOURCE_Y, pos.blockY); + ItemNBTHelper.setInt(par1ItemStack, TAG_SOURCE_Z, pos.blockZ); + } + } else ItemNBTHelper.setInt(par1ItemStack, TAG_SOURCE_Y, -1); + + par3EntityPlayer.setItemInUse(par1ItemStack, getMaxItemUseDuration(par1ItemStack)); + } + + return par1ItemStack; + } + + public static double calculateRadius(ItemStack stack, EntityPlayer player) { + int x = ItemNBTHelper.getInt(stack, TAG_SOURCE_X, 0); + int y = ItemNBTHelper.getInt(stack, TAG_SOURCE_Y, -1); + int z = ItemNBTHelper.getInt(stack, TAG_SOURCE_Z, 0); + World world = player.worldObj; + Vector3 source = new Vector3(x, y, z); + Botania.proxy.wispFX(world, source.x + 0.5, source.y + 1, source.z + 0.5, 1F, 0F, 0F, 0.2F, -0.1F); + + Vector3 centerVec = Vector3.fromEntityCenter(player); + Vector3 diffVec = source.copy().subtract(centerVec); + Vector3 lookVec = new Vector3(player.getLookVec()); + double mul = diffVec.y / lookVec.y; + lookVec.multiply(mul).add(centerVec); + + lookVec.x = net.minecraft.util.MathHelper.floor_double(lookVec.x); + lookVec.z = net.minecraft.util.MathHelper.floor_double(lookVec.z); + + return MathHelper.pointDistancePlane(source.x, source.z, lookVec.x, lookVec.z); + } + + @SideOnly(Side.CLIENT) + public static void renderHUD(ScaledResolution resolution, EntityPlayer player, ItemStack stack) { + ItemStack onUse = player.getItemInUse(); + int time = player.getItemInUseCount(); + + if(onUse == stack && stack.getItem().getMaxItemUseDuration(stack) - time >= 10) { + double radius = calculateRadius(stack, player); + FontRenderer font = Minecraft.getMinecraft().fontRenderer; + int x = resolution.getScaledWidth() / 2 + 30; + int y = resolution.getScaledHeight() / 2; + + String s = "" + (int) radius; + font.drawStringWithShadow(s, x - font.getStringWidth(s) / 2, y - 4, 0xFFFFFF); + + if(radius > 0) { + radius += 4; + GL11.glDisable(GL11.GL_TEXTURE_2D); + GL11.glLineWidth(3F); + GL11.glBegin(GL11.GL_LINE_STRIP); + GL11.glColor4f(0F, 1F, 1F, 1F); + for(int i = 0; i < 361; i++) { + float radian = (float) (i * Math.PI / 180); + double xp = x + Math.cos(radian) * radius; + double yp = y + Math.sin(radian) * radius; + GL11.glVertex2d(xp, yp); + } + GL11.glEnd(); + GL11.glEnable(GL11.GL_TEXTURE_2D); + } + } + } + + public static class MultiblockSextant extends Multiblock { + + @Override + public Multiblock[] createRotations() { + return new Multiblock[] { this }; + } + + } + } diff --git a/src/main/java/vazkii/botania/common/item/ItemSignalFlare.java b/src/main/java/vazkii/botania/common/item/ItemSignalFlare.java index 2ee9dbabe5..c7a86d197b 100644 --- a/src/main/java/vazkii/botania/common/item/ItemSignalFlare.java +++ b/src/main/java/vazkii/botania/common/item/ItemSignalFlare.java @@ -2,16 +2,17 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Mar 3, 2014, 6:49:15 PM (GMT)] */ package vazkii.botania.common.item; import java.awt.Color; import java.util.List; + import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.entity.Entity; @@ -35,120 +36,110 @@ public class ItemSignalFlare extends ItemMod { - IIcon[] icons; - - private static final String TAG_COLOR = "color"; - - public ItemSignalFlare() { - super(); - setMaxStackSize(1); - setNoRepair(); - setMaxDamage(200); - setUnlocalizedName(LibItemNames.SIGNAL_FLARE); - } - - @Override - public boolean isFull3D() { - return true; - } - - @Override - public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer) { - if (par1ItemStack.getItemDamage() == 0) { - if (par2World.isRemote) par3EntityPlayer.swingItem(); - else { - EntitySignalFlare flare = new EntitySignalFlare(par2World); - flare.setPosition(par3EntityPlayer.posX, par3EntityPlayer.posY, par3EntityPlayer.posZ); - flare.setColor(getColor(par1ItemStack)); - par2World.playSoundAtEntity( - par3EntityPlayer, - "random.explode", - 40F, - (1.0F + (par2World.rand.nextFloat() - par2World.rand.nextFloat()) * 0.2F) * 0.7F); - - par2World.spawnEntityInWorld(flare); - - int stunned = 0; - int range = 5; - List entities = par2World.getEntitiesWithinAABB( - EntityLivingBase.class, - AxisAlignedBB.getBoundingBox( - par3EntityPlayer.posX - range, - par3EntityPlayer.posY - range, - par3EntityPlayer.posZ - range, - par3EntityPlayer.posX + range, - par3EntityPlayer.posY + range, - par3EntityPlayer.posZ + range)); - for (EntityLivingBase entity : entities) - if (entity != par3EntityPlayer - && (!(entity instanceof EntityPlayer) - || MinecraftServer.getServer() == null - || MinecraftServer.getServer().isPVPEnabled())) { - entity.addPotionEffect(new PotionEffect(Potion.moveSlowdown.id, 50, 5)); - stunned++; - } - - if (stunned >= 100) par3EntityPlayer.addStat(ModAchievements.signalFlareStun, 1); - } - par1ItemStack.damageItem(200, par3EntityPlayer); - } - - return par1ItemStack; - } - - @Override - public void onUpdate(ItemStack par1ItemStack, World par2World, Entity par3Entity, int par4, boolean par5) { - if (par1ItemStack.isItemDamaged()) par1ItemStack.setItemDamage(par1ItemStack.getItemDamage() - 1); - } - - @Override - public void registerIcons(IIconRegister par1IconRegister) { - icons = new IIcon[2]; - for (int i = 0; i < icons.length; i++) icons[i] = IconHelper.forItem(par1IconRegister, this, i); - } - - @Override - public IIcon getIcon(ItemStack stack, int pass) { - return icons[Math.min(1, pass)]; - } - - @Override - public int getColorFromItemStack(ItemStack par1ItemStack, int par2) { - if (par2 == 0) return 0xFFFFFF; - - int colorv = getColor(par1ItemStack); - if (colorv >= EntitySheep.fleeceColorTable.length || colorv < 0) return 0xFFFFFF; - - float[] color = EntitySheep.fleeceColorTable[getColor(par1ItemStack)]; - return new Color(color[0], color[1], color[2]).getRGB(); - } - - @Override - public void getSubItems(Item par1, CreativeTabs par2CreativeTabs, List par3List) { - for (int i = 0; i < 16; i++) par3List.add(forColor(i)); - } - - @Override - public boolean requiresMultipleRenderPasses() { - return true; - } - - @Override - public void addInformation(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, List par3List, boolean par4) { - int storedColor = getColor(par1ItemStack); - par3List.add(String.format( - StatCollector.translateToLocal("botaniamisc.flareColor"), - StatCollector.translateToLocal("botania.color" + storedColor))); - } - - public static ItemStack forColor(int color) { - ItemStack stack = new ItemStack(ModItems.signalFlare); - ItemNBTHelper.setInt(stack, TAG_COLOR, color); - - return stack; - } - - public static int getColor(ItemStack stack) { - return ItemNBTHelper.getInt(stack, TAG_COLOR, 0xFFFFFF); - } -} + IIcon[] icons; + + private static final String TAG_COLOR = "color"; + + public ItemSignalFlare() { + super(); + setMaxStackSize(1); + setNoRepair(); + setMaxDamage(200); + setUnlocalizedName(LibItemNames.SIGNAL_FLARE); + } + + @Override + public boolean isFull3D() { + return true; + } + + @Override + public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer) { + if(par1ItemStack.getItemDamage() == 0) { + if(par2World.isRemote) + par3EntityPlayer.swingItem(); + else { + EntitySignalFlare flare = new EntitySignalFlare(par2World); + flare.setPosition(par3EntityPlayer.posX, par3EntityPlayer.posY, par3EntityPlayer.posZ); + flare.setColor(getColor(par1ItemStack)); + par2World.playSoundAtEntity(par3EntityPlayer, "random.explode", 40F, (1.0F + (par2World.rand.nextFloat() - par2World.rand.nextFloat()) * 0.2F) * 0.7F); + + par2World.spawnEntityInWorld(flare); + + int stunned = 0; + int range = 5; + List entities = par2World.getEntitiesWithinAABB(EntityLivingBase.class, AxisAlignedBB.getBoundingBox(par3EntityPlayer.posX - range, par3EntityPlayer.posY - range, par3EntityPlayer.posZ - range, par3EntityPlayer.posX + range, par3EntityPlayer.posY + range, par3EntityPlayer.posZ + range)); + for(EntityLivingBase entity : entities) + if(entity != par3EntityPlayer && (!(entity instanceof EntityPlayer) || MinecraftServer.getServer() == null || MinecraftServer.getServer().isPVPEnabled())) { + entity.addPotionEffect(new PotionEffect(Potion.moveSlowdown.id, 50, 5)); + stunned++; + } + + if(stunned >= 100) + par3EntityPlayer.addStat(ModAchievements.signalFlareStun, 1); + } + par1ItemStack.damageItem(200, par3EntityPlayer); + } + + return par1ItemStack; + } + + @Override + public void onUpdate(ItemStack par1ItemStack, World par2World, Entity par3Entity, int par4, boolean par5) { + if(par1ItemStack.isItemDamaged()) + par1ItemStack.setItemDamage(par1ItemStack.getItemDamage() - 1); + } + + @Override + public void registerIcons(IIconRegister par1IconRegister) { + icons = new IIcon[2]; + for(int i = 0; i < icons.length; i++) + icons[i] = IconHelper.forItem(par1IconRegister, this, i); + } + + @Override + public IIcon getIcon(ItemStack stack, int pass) { + return icons[Math.min(1, pass)]; + } + + @Override + public int getColorFromItemStack(ItemStack par1ItemStack, int par2) { + if(par2 == 0) + return 0xFFFFFF; + + int colorv = getColor(par1ItemStack); + if(colorv >= EntitySheep.fleeceColorTable.length || colorv < 0) + return 0xFFFFFF; + + float[] color = EntitySheep.fleeceColorTable[getColor(par1ItemStack)]; + return new Color(color[0], color[1], color[2]).getRGB(); + } + + @Override + public void getSubItems(Item par1, CreativeTabs par2CreativeTabs, List par3List) { + for(int i = 0; i < 16; i++) + par3List.add(forColor(i)); + } + + @Override + public boolean requiresMultipleRenderPasses() { + return true; + } + + @Override + public void addInformation(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, List par3List, boolean par4) { + int storedColor = getColor(par1ItemStack); + par3List.add(String.format(StatCollector.translateToLocal("botaniamisc.flareColor"), StatCollector.translateToLocal("botania.color" + storedColor))); + } + + public static ItemStack forColor(int color) { + ItemStack stack = new ItemStack(ModItems.signalFlare); + ItemNBTHelper.setInt(stack, TAG_COLOR, color); + + return stack; + } + + public static int getColor(ItemStack stack) { + return ItemNBTHelper.getInt(stack, TAG_COLOR, 0xFFFFFF); + } +} \ No newline at end of file diff --git a/src/main/java/vazkii/botania/common/item/ItemSlimeBottle.java b/src/main/java/vazkii/botania/common/item/ItemSlimeBottle.java index 29295e84af..3a9b374205 100644 --- a/src/main/java/vazkii/botania/common/item/ItemSlimeBottle.java +++ b/src/main/java/vazkii/botania/common/item/ItemSlimeBottle.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Aug 17, 2015, 1:32:58 AM (GMT)] */ package vazkii.botania.common.item; @@ -22,34 +22,36 @@ public class ItemSlimeBottle extends ItemMod { - IIcon activeIcon; - - public ItemSlimeBottle() { - setUnlocalizedName(LibItemNames.SLIME_BOTTLE); - setMaxStackSize(1); - setHasSubtypes(true); - } - - @Override - public void registerIcons(IIconRegister par1IconRegister) { - itemIcon = IconHelper.forItem(par1IconRegister, this, 0); - activeIcon = IconHelper.forItem(par1IconRegister, this, 1); - } - - @Override - public IIcon getIconFromDamage(int dmg) { - return dmg == 0 ? itemIcon : activeIcon; - } - - @Override - public void onUpdate(ItemStack stack, World world, Entity entity, int something, boolean somethingelse) { - if (!world.isRemote) { - int x = MathHelper.floor_double(entity.posX); - int z = MathHelper.floor_double(entity.posZ); - boolean slime = SubTileNarslimmus.SpawnIntercepter.isSlimeChunk(world, x, z); - int meta = stack.getItemDamage(); - int newMeta = slime ? 1 : 0; - if (meta != newMeta) stack.setItemDamage(newMeta); - } - } + IIcon activeIcon; + + public ItemSlimeBottle() { + setUnlocalizedName(LibItemNames.SLIME_BOTTLE); + setMaxStackSize(1); + setHasSubtypes(true); + } + + @Override + public void registerIcons(IIconRegister par1IconRegister) { + itemIcon = IconHelper.forItem(par1IconRegister, this, 0); + activeIcon = IconHelper.forItem(par1IconRegister, this, 1); + } + + @Override + public IIcon getIconFromDamage(int dmg) { + return dmg == 0 ? itemIcon : activeIcon; + } + + @Override + public void onUpdate(ItemStack stack, World world, Entity entity, int something, boolean somethingelse) { + if(!world.isRemote) { + int x = MathHelper.floor_double(entity.posX); + int z = MathHelper.floor_double(entity.posZ); + boolean slime = SubTileNarslimmus.SpawnIntercepter.isSlimeChunk(world, x, z); + int meta = stack.getItemDamage(); + int newMeta = slime ? 1 : 0; + if(meta != newMeta) + stack.setItemDamage(newMeta); + } + } + } diff --git a/src/main/java/vazkii/botania/common/item/ItemSlingshot.java b/src/main/java/vazkii/botania/common/item/ItemSlingshot.java index baf49afd67..cd52a80f49 100644 --- a/src/main/java/vazkii/botania/common/item/ItemSlingshot.java +++ b/src/main/java/vazkii/botania/common/item/ItemSlingshot.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jun 27, 2014, 12:38:58 AM (GMT)] */ package vazkii.botania.common.item; @@ -19,55 +19,56 @@ public class ItemSlingshot extends ItemMod { - public ItemSlingshot() { - setMaxStackSize(1); - setUnlocalizedName(LibItemNames.SLINGSHOT); - } + public ItemSlingshot() { + setMaxStackSize(1); + setUnlocalizedName(LibItemNames.SLINGSHOT); + } - @Override - public void onPlayerStoppedUsing( - ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer, int par4) { - int j = getMaxItemUseDuration(par1ItemStack) - par4; + @Override + public void onPlayerStoppedUsing(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer, int par4) { + int j = getMaxItemUseDuration(par1ItemStack) - par4; - if (par3EntityPlayer.capabilities.isCreativeMode || par3EntityPlayer.inventory.hasItem(ModItems.vineBall)) { - float f = j / 20.0F; - f = (f * f + f * 2.0F) / 3.0F; + if(par3EntityPlayer.capabilities.isCreativeMode || par3EntityPlayer.inventory.hasItem(ModItems.vineBall)) { + float f = j / 20.0F; + f = (f * f + f * 2.0F) / 3.0F; - if (f < 1F) return; + if(f < 1F) + return; - if (!par3EntityPlayer.capabilities.isCreativeMode) - par3EntityPlayer.inventory.consumeInventoryItem(ModItems.vineBall); + if(!par3EntityPlayer.capabilities.isCreativeMode) + par3EntityPlayer.inventory.consumeInventoryItem(ModItems.vineBall); - if (!par2World.isRemote) { - EntityVineBall ball = new EntityVineBall(par3EntityPlayer, false); - ball.motionX *= 1.6; - ball.motionY *= 1.6; - ball.motionZ *= 1.6; - par2World.spawnEntityInWorld(ball); - } - } - } + if(!par2World.isRemote) { + EntityVineBall ball = new EntityVineBall(par3EntityPlayer, false); + ball.motionX *= 1.6; + ball.motionY *= 1.6; + ball.motionZ *= 1.6; + par2World.spawnEntityInWorld(ball); + } + } + } - @Override - public ItemStack onEaten(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer) { - return par1ItemStack; - } + @Override + public ItemStack onEaten(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer) { + return par1ItemStack; + } - @Override - public int getMaxItemUseDuration(ItemStack par1ItemStack) { - return 72000; - } + @Override + public int getMaxItemUseDuration(ItemStack par1ItemStack) { + return 72000; + } - @Override - public EnumAction getItemUseAction(ItemStack par1ItemStack) { - return EnumAction.bow; - } + @Override + public EnumAction getItemUseAction(ItemStack par1ItemStack) { + return EnumAction.bow; + } - @Override - public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer) { - if (par3EntityPlayer.capabilities.isCreativeMode || par3EntityPlayer.inventory.hasItem(ModItems.vineBall)) - par3EntityPlayer.setItemInUse(par1ItemStack, getMaxItemUseDuration(par1ItemStack)); + @Override + public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer) { + if(par3EntityPlayer.capabilities.isCreativeMode || par3EntityPlayer.inventory.hasItem(ModItems.vineBall)) + par3EntityPlayer.setItemInUse(par1ItemStack, getMaxItemUseDuration(par1ItemStack)); + + return par1ItemStack; + } - return par1ItemStack; - } } diff --git a/src/main/java/vazkii/botania/common/item/ItemSpark.java b/src/main/java/vazkii/botania/common/item/ItemSpark.java index fd35fdcb56..c017efc98a 100644 --- a/src/main/java/vazkii/botania/common/item/ItemSpark.java +++ b/src/main/java/vazkii/botania/common/item/ItemSpark.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Aug 21, 2014, 5:24:55 PM (GMT)] */ package vazkii.botania.common.item; @@ -29,55 +29,46 @@ public class ItemSpark extends ItemMod implements ICraftAchievement, IManaGivingItem { - public static IIcon invIcon, worldIcon; + public static IIcon invIcon, worldIcon; - public ItemSpark() { - setUnlocalizedName(LibItemNames.SPARK); - } + public ItemSpark() { + setUnlocalizedName(LibItemNames.SPARK); + } - @Override - public boolean onItemUse( - ItemStack stack, - EntityPlayer player, - World world, - int x, - int y, - int z, - int side, - float xv, - float yv, - float zv) { - TileEntity tile = world.getTileEntity(x, y, z); - if (tile instanceof ISparkAttachable) { - ISparkAttachable attach = (ISparkAttachable) tile; - if (attach.canAttachSpark(stack) && attach.getAttachedSpark() == null) { - stack.stackSize--; - if (!world.isRemote) { - EntitySpark spark = new EntitySpark(world); - spark.setPosition(x + 0.5, y + 1.5, z + 0.5); - world.spawnEntityInWorld(spark); - attach.attachSpark(spark); - VanillaPacketDispatcher.dispatchTEToNearbyPlayers(world, x, y, z); - } - return true; - } - } - return false; - } + @Override + public boolean onItemUse(ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int side, float xv, float yv, float zv) { + TileEntity tile = world.getTileEntity(x, y, z); + if(tile instanceof ISparkAttachable) { + ISparkAttachable attach = (ISparkAttachable) tile; + if(attach.canAttachSpark(stack) && attach.getAttachedSpark() == null) { + stack.stackSize--; + if(!world.isRemote) { + EntitySpark spark = new EntitySpark(world); + spark.setPosition(x + 0.5, y + 1.5, z + 0.5); + world.spawnEntityInWorld(spark); + attach.attachSpark(spark); + VanillaPacketDispatcher.dispatchTEToNearbyPlayers(world, x, y, z); + } + return true; + } + } + return false; + } - @Override - public void registerIcons(IIconRegister par1IconRegister) { - invIcon = IconHelper.forItem(par1IconRegister, this, 0); - worldIcon = IconHelper.forItem(par1IconRegister, this, 1); - } + @Override + public void registerIcons(IIconRegister par1IconRegister) { + invIcon = IconHelper.forItem(par1IconRegister, this, 0); + worldIcon = IconHelper.forItem(par1IconRegister, this, 1); + } - @Override - public IIcon getIconFromDamage(int p_77617_1_) { - return invIcon; - } + @Override + public IIcon getIconFromDamage(int p_77617_1_) { + return invIcon; + } + + @Override + public Achievement getAchievementOnCraft(ItemStack stack, EntityPlayer player, IInventory matrix) { + return ModAchievements.sparkCraft; + } - @Override - public Achievement getAchievementOnCraft(ItemStack stack, EntityPlayer player, IInventory matrix) { - return ModAchievements.sparkCraft; - } } diff --git a/src/main/java/vazkii/botania/common/item/ItemSparkUpgrade.java b/src/main/java/vazkii/botania/common/item/ItemSparkUpgrade.java index 336a4f709c..20b3f1e810 100644 --- a/src/main/java/vazkii/botania/common/item/ItemSparkUpgrade.java +++ b/src/main/java/vazkii/botania/common/item/ItemSparkUpgrade.java @@ -2,15 +2,16 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Aug 21, 2014, 5:32:06 PM (GMT)] */ package vazkii.botania.common.item; import java.util.List; + import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.item.Item; @@ -21,42 +22,43 @@ public class ItemSparkUpgrade extends ItemMod { - private static final int VARIANTS = 4; - - public static IIcon[] worldIcons; - IIcon[] invIcons; - - public ItemSparkUpgrade() { - setUnlocalizedName(LibItemNames.SPARK_UPGRADE); - setHasSubtypes(true); - } - - @Override - public void registerIcons(IIconRegister par1IconRegister) { - worldIcons = new IIcon[VARIANTS]; - invIcons = new IIcon[VARIANTS]; - for (int i = 0; i < VARIANTS; i++) { - worldIcons[i] = IconHelper.forItem(par1IconRegister, this, "L" + i); - invIcons[i] = IconHelper.forItem(par1IconRegister, this, i); - } - } - - @Override - public IIcon getIconFromDamage(int meta) { - return invIcons[Math.min(invIcons.length - 1, meta)]; - } - - @Override - public void getSubItems(Item item, CreativeTabs tab, List list) { - for (int i = 0; i < VARIANTS; i++) list.add(new ItemStack(item, 1, i)); - } - - @Override - public String getUnlocalizedName(ItemStack par1ItemStack) { - return getUnlocalizedNameLazy(par1ItemStack) + par1ItemStack.getItemDamage(); - } - - String getUnlocalizedNameLazy(ItemStack par1ItemStack) { - return super.getUnlocalizedName(par1ItemStack); - } + private static final int VARIANTS = 4; + + public static IIcon[] worldIcons; + IIcon[] invIcons; + + public ItemSparkUpgrade() { + setUnlocalizedName(LibItemNames.SPARK_UPGRADE); + setHasSubtypes(true); + } + + @Override + public void registerIcons(IIconRegister par1IconRegister) { + worldIcons = new IIcon[VARIANTS]; + invIcons = new IIcon[VARIANTS]; + for(int i = 0; i < VARIANTS; i++) { + worldIcons[i] = IconHelper.forItem(par1IconRegister, this, "L" + i); + invIcons[i] = IconHelper.forItem(par1IconRegister, this, i); + } + } + + @Override + public IIcon getIconFromDamage(int meta) { + return invIcons[Math.min(invIcons.length - 1, meta)]; + } + + @Override + public void getSubItems(Item item, CreativeTabs tab, List list) { + for(int i = 0; i < VARIANTS; i++) + list.add(new ItemStack(item, 1, i)); + } + + @Override + public String getUnlocalizedName(ItemStack par1ItemStack) { + return getUnlocalizedNameLazy(par1ItemStack) + par1ItemStack.getItemDamage(); + } + + String getUnlocalizedNameLazy(ItemStack par1ItemStack) { + return super.getUnlocalizedName(par1ItemStack); + } } diff --git a/src/main/java/vazkii/botania/common/item/ItemSpawnerMover.java b/src/main/java/vazkii/botania/common/item/ItemSpawnerMover.java index dfefb6f7be..981d009a40 100644 --- a/src/main/java/vazkii/botania/common/item/ItemSpawnerMover.java +++ b/src/main/java/vazkii/botania/common/item/ItemSpawnerMover.java @@ -2,15 +2,16 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [? (GMT)] */ package vazkii.botania.common.item; import java.util.List; + import net.minecraft.block.Block; import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.entity.Entity; @@ -30,222 +31,174 @@ public class ItemSpawnerMover extends ItemMod { - public static final String TAG_SPAWNER = "spawner"; - private static final String TAG_PLACE_DELAY = "placeDelay"; - - IIcon iconNormal, iconSpawner; - - public ItemSpawnerMover() { - setUnlocalizedName(LibItemNames.SPAWNER_MOVER); - setMaxStackSize(1); - } - - @Override - public void registerIcons(IIconRegister par1IconRegister) { - iconNormal = IconHelper.forItem(par1IconRegister, this, 0); - iconSpawner = IconHelper.forItem(par1IconRegister, this, 1); - } - - @Override - public IIcon getIcon(ItemStack stack, int pass) { - return getIconIndex(stack); - } - - @Override - public IIcon getIconIndex(ItemStack par1ItemStack) { - return hasData(par1ItemStack) ? iconSpawner : iconNormal; - } - - public static NBTTagCompound getSpawnerTag(ItemStack stack) { - NBTTagCompound tag = stack.getTagCompound(); - if (tag != null) { - if (tag.hasKey(TAG_SPAWNER)) return tag.getCompoundTag(TAG_SPAWNER); - if (tag.hasKey("EntityId")) return tag; - } - - return null; - } - - private static String getEntityId(ItemStack stack) { - NBTTagCompound tag = getSpawnerTag(stack); - if (tag != null) return tag.getString("EntityId"); - - return null; - } - - public static boolean hasData(ItemStack stack) { - return getEntityId(stack) != null; - } - - private static int getDelay(ItemStack stack) { - NBTTagCompound tag = stack.getTagCompound(); - if (tag != null) return tag.getInteger(TAG_PLACE_DELAY); - - return 0; - } - - @Override - public void addInformation(ItemStack stack, EntityPlayer player, List infoList, boolean advancedTooltips) { - String id = getEntityId(stack); - if (id != null) infoList.add(StatCollector.translateToLocal("entity." + id + ".name")); - } - - @Override - public void onUpdate(ItemStack stack, World world, Entity entity, int par4, boolean par5) { - NBTTagCompound tag = stack.getTagCompound(); - if (tag != null && tag.hasKey(TAG_PLACE_DELAY) && tag.getInteger(TAG_PLACE_DELAY) > 0) - tag.setInteger(TAG_PLACE_DELAY, tag.getInteger(TAG_PLACE_DELAY) - 1); - } - - @Override - public boolean onItemUse( - ItemStack itemstack, - EntityPlayer player, - World world, - int x, - int y, - int z, - int side, - float xOffset, - float yOffset, - float zOffset) { - if (getEntityId(itemstack) == null) { - if (world.getBlock(x, y, z).equals(Blocks.mob_spawner)) { - TileEntity te = world.getTileEntity(x, y, z); - NBTTagCompound tag = new NBTTagCompound(); - tag.setTag(TAG_SPAWNER, new NBTTagCompound()); - te.writeToNBT(tag.getCompoundTag(TAG_SPAWNER)); - tag.setInteger(TAG_PLACE_DELAY, 20); - itemstack.setTagCompound(tag); - world.setBlockToAir(x, y, z); - player.renderBrokenItemStack(itemstack); - for (int i = 0; i < 50; i++) { - float red = (float) Math.random(); - float green = (float) Math.random(); - float blue = (float) Math.random(); - Botania.proxy.wispFX( - world, - x + 0.5, - y + 0.5, - z + 0.5, - red, - green, - blue, - (float) Math.random() * 0.1F + 0.05F, - (float) (Math.random() - 0.5F) * 0.15F, - (float) (Math.random() - 0.5F) * 0.15F, - (float) (Math.random() - 0.5F) * 0.15F); - } - return true; - } else return false; - } else { - if (getDelay(itemstack) <= 0 - && placeBlock(itemstack, player, world, x, y, z, side, xOffset, yOffset, zOffset)) return true; - return false; - } - } - - private boolean placeBlock( - ItemStack itemstack, - EntityPlayer player, - World world, - int x, - int y, - int z, - int side, - float xOffset, - float yOffset, - float zOffset) { - Block block = world.getBlock(x, y, z); - - if (block == Blocks.snow_layer) side = 1; - else if (block != Blocks.vine - && block != Blocks.tallgrass - && block != Blocks.deadbush - && !block.isReplaceable(world, x, y, z)) { - switch (side) { - case 0: - --y; - break; - case 1: - ++y; - break; - case 2: - --z; - break; - case 3: - ++z; - break; - case 4: - --x; - break; - case 5: - ++x; - break; - } - } - - if (itemstack.stackSize == 0) return false; - else if (!player.canPlayerEdit(x, y, z, side, itemstack)) return false; - else if (y == 255 && block.getMaterial().isSolid()) return false; - else if (world.canPlaceEntityOnSide(Blocks.mob_spawner, x, y, z, false, side, player, itemstack)) { - int meta = block.onBlockPlaced(world, x, y, z, side, xOffset, yOffset, zOffset, 0); - - if (placeBlockAt(itemstack, player, world, x, y, z, side, xOffset, yOffset, zOffset, meta)) { - world.playSoundEffect( - x + 0.5F, - y + 0.5F, - z + 0.5F, - block.stepSound.func_150496_b(), - (block.stepSound.getVolume() + 1.0F) / 2.0F, - block.stepSound.getPitch() * 0.8F); - player.renderBrokenItemStack(itemstack); - player.addStat(ModAchievements.spawnerMoverUse, 1); - for (int i = 0; i < 100; i++) - Botania.proxy.sparkleFX( - world, - x + Math.random(), - y + Math.random(), - z + Math.random(), - (float) Math.random(), - (float) Math.random(), - (float) Math.random(), - 0.45F + 0.2F * (float) Math.random(), - 6); - - --itemstack.stackSize; - } - - return true; - } else return false; - } - - private boolean placeBlockAt( - ItemStack stack, - EntityPlayer player, - World world, - int x, - int y, - int z, - int side, - float hitX, - float hitY, - float hitZ, - int metadata) { - if (!world.setBlock(x, y, z, Blocks.mob_spawner, metadata, 3)) return false; - - Block block = world.getBlock(x, y, z); - if (block.equals(Blocks.mob_spawner)) { - TileEntity te = world.getTileEntity(x, y, z); - NBTTagCompound tag = stack.getTagCompound(); - if (tag.hasKey(TAG_SPAWNER)) tag = tag.getCompoundTag(TAG_SPAWNER); - tag.setInteger("x", x); - tag.setInteger("y", y); - tag.setInteger("z", z); - te.readFromNBT(tag); - VanillaPacketDispatcher.dispatchTEToNearbyPlayers(world, x, y, z); - } - - return true; - } + public static final String TAG_SPAWNER = "spawner"; + private static final String TAG_PLACE_DELAY = "placeDelay"; + + IIcon iconNormal, iconSpawner; + + public ItemSpawnerMover() { + setUnlocalizedName(LibItemNames.SPAWNER_MOVER); + setMaxStackSize(1); + } + + @Override + public void registerIcons(IIconRegister par1IconRegister) { + iconNormal = IconHelper.forItem(par1IconRegister, this, 0); + iconSpawner = IconHelper.forItem(par1IconRegister, this, 1); + } + + @Override + public IIcon getIcon(ItemStack stack, int pass) { + return getIconIndex(stack); + } + + @Override + public IIcon getIconIndex(ItemStack par1ItemStack) { + return hasData(par1ItemStack) ? iconSpawner : iconNormal; + } + + public static NBTTagCompound getSpawnerTag(ItemStack stack) { + NBTTagCompound tag = stack.getTagCompound(); + if(tag != null) { + if(tag.hasKey(TAG_SPAWNER)) + return tag.getCompoundTag(TAG_SPAWNER); + if(tag.hasKey("EntityId")) + return tag; + } + + return null; + } + + private static String getEntityId(ItemStack stack) { + NBTTagCompound tag = getSpawnerTag(stack); + if(tag != null) + return tag.getString("EntityId"); + + return null; + } + + public static boolean hasData(ItemStack stack) { + return getEntityId(stack) != null; + } + + private static int getDelay(ItemStack stack) { + NBTTagCompound tag = stack.getTagCompound(); + if(tag != null) + return tag.getInteger(TAG_PLACE_DELAY); + + return 0; + } + + @Override + public void addInformation(ItemStack stack, EntityPlayer player, List infoList, boolean advancedTooltips) { + String id = getEntityId(stack); + if (id != null) + infoList.add(StatCollector.translateToLocal("entity." + id + ".name")); + } + + @Override + public void onUpdate(ItemStack stack, World world, Entity entity, int par4, boolean par5) { + NBTTagCompound tag = stack.getTagCompound(); + if(tag != null && tag.hasKey(TAG_PLACE_DELAY) && tag.getInteger(TAG_PLACE_DELAY) > 0) + tag.setInteger(TAG_PLACE_DELAY, tag.getInteger(TAG_PLACE_DELAY) - 1); + } + + @Override + public boolean onItemUse(ItemStack itemstack, EntityPlayer player, World world, int x, int y, int z, int side, float xOffset, float yOffset, float zOffset) { + if(getEntityId(itemstack) == null) { + if(world.getBlock(x, y, z).equals(Blocks.mob_spawner)) { + TileEntity te = world.getTileEntity(x, y, z); + NBTTagCompound tag = new NBTTagCompound(); + tag.setTag(TAG_SPAWNER, new NBTTagCompound()); + te.writeToNBT(tag.getCompoundTag(TAG_SPAWNER)); + tag.setInteger(TAG_PLACE_DELAY, 20); + itemstack.setTagCompound(tag); + world.setBlockToAir(x, y, z); + player.renderBrokenItemStack(itemstack); + for(int i = 0; i < 50; i++) { + float red = (float) Math.random(); + float green = (float) Math.random(); + float blue = (float) Math.random(); + Botania.proxy.wispFX(world, x + 0.5, y + 0.5, z + 0.5, red, green, blue, (float) Math.random() * 0.1F + 0.05F, (float) (Math.random() - 0.5F) * 0.15F, (float) (Math.random() - 0.5F) * 0.15F, (float) (Math.random() - 0.5F) * 0.15F); + } + return true; + } else return false; + } else { + if(getDelay(itemstack) <= 0 && placeBlock(itemstack, player, world, x, y, z, side, xOffset, yOffset, zOffset)) + return true; + return false; + } + } + + private boolean placeBlock(ItemStack itemstack, EntityPlayer player, World world, int x, int y, int z, int side, float xOffset, float yOffset, float zOffset) { + Block block = world.getBlock(x, y, z); + + if(block == Blocks.snow_layer) + side = 1; + else if(block != Blocks.vine && block != Blocks.tallgrass && block != Blocks.deadbush && !block.isReplaceable(world, x, y, z)) { + switch (side) { + case 0: + --y; + break; + case 1: + ++y; + break; + case 2: + --z; + break; + case 3: + ++z; + break; + case 4: + --x; + break; + case 5: + ++x; + break; + } + } + + if(itemstack.stackSize == 0) + return false; + else if(!player.canPlayerEdit(x, y, z, side, itemstack)) + return false; + else if(y == 255 && block.getMaterial().isSolid()) + return false; + else if(world.canPlaceEntityOnSide(Blocks.mob_spawner, x, y, z, false, side, player, itemstack)) { + int meta = block.onBlockPlaced(world, x, y, z, side, xOffset, yOffset, zOffset, 0); + + if(placeBlockAt(itemstack, player, world, x, y, z, side, xOffset, yOffset, zOffset, meta)) { + world.playSoundEffect(x + 0.5F, y + 0.5F, z + 0.5F, block.stepSound.func_150496_b(), (block.stepSound.getVolume() + 1.0F) / 2.0F, block.stepSound.getPitch() * 0.8F); + player.renderBrokenItemStack(itemstack); + player.addStat(ModAchievements.spawnerMoverUse, 1); + for(int i = 0; i < 100; i++) + Botania.proxy.sparkleFX(world, x + Math.random(), y + Math.random(), z + Math.random(), (float) Math.random(), (float) Math.random(), (float) Math.random(), 0.45F + 0.2F * (float) Math.random(), 6); + + --itemstack.stackSize; + } + + return true; + } + else return false; + } + + private boolean placeBlockAt(ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int side, float hitX, float hitY, float hitZ, int metadata) { + if (!world.setBlock(x, y, z, Blocks.mob_spawner, metadata, 3)) + return false; + + Block block = world.getBlock(x, y, z); + if(block.equals(Blocks.mob_spawner)) { + TileEntity te = world.getTileEntity(x, y, z); + NBTTagCompound tag = stack.getTagCompound(); + if (tag.hasKey(TAG_SPAWNER)) + tag = tag.getCompoundTag(TAG_SPAWNER); + tag.setInteger("x", x); + tag.setInteger("y", y); + tag.setInteger("z", z); + te.readFromNBT(tag); + VanillaPacketDispatcher.dispatchTEToNearbyPlayers(world, x, y, z); + } + + return true; + } } diff --git a/src/main/java/vazkii/botania/common/item/ItemSpellCloth.java b/src/main/java/vazkii/botania/common/item/ItemSpellCloth.java index 08b3ca7897..d8782f5d54 100644 --- a/src/main/java/vazkii/botania/common/item/ItemSpellCloth.java +++ b/src/main/java/vazkii/botania/common/item/ItemSpellCloth.java @@ -2,61 +2,58 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jan 25, 2015, 6:14:13 PM (GMT)] */ package vazkii.botania.common.item; -import cpw.mods.fml.common.registry.GameRegistry; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; import java.awt.Color; + import net.minecraft.item.ItemStack; import net.minecraftforge.oredict.RecipeSorter; import net.minecraftforge.oredict.RecipeSorter.Category; import vazkii.botania.common.crafting.recipe.SpellClothRecipe; import vazkii.botania.common.lib.LibItemNames; +import cpw.mods.fml.common.registry.GameRegistry; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; public class ItemSpellCloth extends ItemMod { - public ItemSpellCloth() { - setMaxDamage(35); - setMaxStackSize(1); - setNoRepair(); - setUnlocalizedName(LibItemNames.SPELL_CLOTH); - - GameRegistry.addRecipe(new SpellClothRecipe()); - RecipeSorter.register("botania:spellCloth", SpellClothRecipe.class, Category.SHAPELESS, ""); - } - - @Override - @SideOnly(Side.CLIENT) - public int getColorFromItemStack(ItemStack par1ItemStack, int par2) { - return Color.HSBtoRGB( - 0.55F, - ((float) par1ItemStack.getMaxDamage() - (float) par1ItemStack.getItemDamage()) - / par1ItemStack.getMaxDamage() - * 0.5F, - 1F); - } - - @Override - public boolean hasContainerItem() { - return true; - } - - @Override - public ItemStack getContainerItem(ItemStack itemStack) { - ItemStack stack = itemStack.copy(); - stack.setItemDamage(stack.getItemDamage() + 1); - return stack; - } - - @Override - public boolean doesContainerItemLeaveCraftingGrid(ItemStack par1ItemStack) { - return false; - } + public ItemSpellCloth() { + setMaxDamage(35); + setMaxStackSize(1); + setNoRepair(); + setUnlocalizedName(LibItemNames.SPELL_CLOTH); + + GameRegistry.addRecipe(new SpellClothRecipe()); + RecipeSorter.register("botania:spellCloth", SpellClothRecipe.class, Category.SHAPELESS, ""); + } + + @Override + @SideOnly(Side.CLIENT) + public int getColorFromItemStack(ItemStack par1ItemStack, int par2) { + return Color.HSBtoRGB(0.55F, ((float) par1ItemStack.getMaxDamage() - (float) par1ItemStack.getItemDamage()) / par1ItemStack.getMaxDamage() * 0.5F, 1F); + } + + @Override + public boolean hasContainerItem() { + return true; + } + + @Override + public ItemStack getContainerItem(ItemStack itemStack) { + ItemStack stack = itemStack.copy(); + stack.setItemDamage(stack.getItemDamage() + 1); + return stack; + } + + @Override + public boolean doesContainerItemLeaveCraftingGrid(ItemStack par1ItemStack) { + return false; + } + } diff --git a/src/main/java/vazkii/botania/common/item/ItemTemperanceStone.java b/src/main/java/vazkii/botania/common/item/ItemTemperanceStone.java index 09a919690e..371d5a089a 100644 --- a/src/main/java/vazkii/botania/common/item/ItemTemperanceStone.java +++ b/src/main/java/vazkii/botania/common/item/ItemTemperanceStone.java @@ -2,17 +2,16 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [May 12, 2015, 5:56:45 PM (GMT)] */ package vazkii.botania.common.item; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; import java.util.List; + import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.inventory.IInventory; @@ -22,58 +21,62 @@ import net.minecraft.world.World; import vazkii.botania.client.core.helper.IconHelper; import vazkii.botania.common.lib.LibItemNames; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; public class ItemTemperanceStone extends ItemMod { - IIcon enabledIcon; + IIcon enabledIcon; + + public ItemTemperanceStone() { + setUnlocalizedName(LibItemNames.TEMPERANCE_STONE); + setMaxStackSize(1); + setHasSubtypes(true); + } - public ItemTemperanceStone() { - setUnlocalizedName(LibItemNames.TEMPERANCE_STONE); - setMaxStackSize(1); - setHasSubtypes(true); - } + @Override + public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer) { + int dmg = par1ItemStack.getItemDamage(); + par1ItemStack.setItemDamage(~dmg & 1); + par2World.playSoundAtEntity(par3EntityPlayer, "random.orb", 0.3F, 0.1F); - @Override - public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer) { - int dmg = par1ItemStack.getItemDamage(); - par1ItemStack.setItemDamage(~dmg & 1); - par2World.playSoundAtEntity(par3EntityPlayer, "random.orb", 0.3F, 0.1F); + return par1ItemStack; + } - return par1ItemStack; - } + @Override + @SideOnly(Side.CLIENT) + public void registerIcons(IIconRegister par1IconRegister) { + itemIcon = IconHelper.forItem(par1IconRegister, this, 0); + enabledIcon = IconHelper.forItem(par1IconRegister, this, 1); + } - @Override - @SideOnly(Side.CLIENT) - public void registerIcons(IIconRegister par1IconRegister) { - itemIcon = IconHelper.forItem(par1IconRegister, this, 0); - enabledIcon = IconHelper.forItem(par1IconRegister, this, 1); - } + @Override + @SideOnly(Side.CLIENT) + public IIcon getIconFromDamage(int par1) { + return par1 == 1 ? enabledIcon : itemIcon; + } - @Override - @SideOnly(Side.CLIENT) - public IIcon getIconFromDamage(int par1) { - return par1 == 1 ? enabledIcon : itemIcon; - } + @Override + @SideOnly(Side.CLIENT) + public void addInformation(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, List par3List, boolean par4) { + if(par1ItemStack.getItemDamage() == 1) + addStringToTooltip(StatCollector.translateToLocal("botaniamisc.active"), par3List); + else addStringToTooltip(StatCollector.translateToLocal("botaniamisc.inactive"), par3List); + } - @Override - @SideOnly(Side.CLIENT) - public void addInformation(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, List par3List, boolean par4) { - if (par1ItemStack.getItemDamage() == 1) - addStringToTooltip(StatCollector.translateToLocal("botaniamisc.active"), par3List); - else addStringToTooltip(StatCollector.translateToLocal("botaniamisc.inactive"), par3List); - } + void addStringToTooltip(String s, List tooltip) { + tooltip.add(s.replaceAll("&", "\u00a7")); + } - void addStringToTooltip(String s, List tooltip) { - tooltip.add(s.replaceAll("&", "\u00a7")); - } + public static boolean hasTemperanceActive(EntityPlayer player) { + IInventory inv = player.inventory; + for(int i = 0; i < inv.getSizeInventory(); i++) { + ItemStack stack = inv.getStackInSlot(i); + if(stack != null && stack.getItem() == ModItems.temperanceStone && stack.getItemDamage() == 1) + return true; + } - public static boolean hasTemperanceActive(EntityPlayer player) { - IInventory inv = player.inventory; - for (int i = 0; i < inv.getSizeInventory(); i++) { - ItemStack stack = inv.getStackInSlot(i); - if (stack != null && stack.getItem() == ModItems.temperanceStone && stack.getItemDamage() == 1) return true; - } + return false; + } - return false; - } } diff --git a/src/main/java/vazkii/botania/common/item/ItemThornChakram.java b/src/main/java/vazkii/botania/common/item/ItemThornChakram.java index 6bcd670851..1d790d9ae0 100644 --- a/src/main/java/vazkii/botania/common/item/ItemThornChakram.java +++ b/src/main/java/vazkii/botania/common/item/ItemThornChakram.java @@ -2,15 +2,15 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jan 25, 2015, 6:42:47 PM (GMT)] */ package vazkii.botania.common.item; - import java.util.List; + import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.entity.player.EntityPlayer; @@ -28,52 +28,55 @@ public class ItemThornChakram extends ItemMod implements ICraftAchievement { - IIcon iconFire; + IIcon iconFire; + + public ItemThornChakram() { + setUnlocalizedName(LibItemNames.THORN_CHAKRAM); + setMaxStackSize(6); + setHasSubtypes(true); + } + + @Override + public void getSubItems(Item item, CreativeTabs tab, List list) { + for(int i = 0; i < 2; i++) + list.add(new ItemStack(item, 1, i)); + } - public ItemThornChakram() { - setUnlocalizedName(LibItemNames.THORN_CHAKRAM); - setMaxStackSize(6); - setHasSubtypes(true); - } + @Override + public void registerIcons(IIconRegister par1IconRegister) { + itemIcon = IconHelper.forItem(par1IconRegister, this, 0); + iconFire = IconHelper.forItem(par1IconRegister, this, 1); + } - @Override - public void getSubItems(Item item, CreativeTabs tab, List list) { - for (int i = 0; i < 2; i++) list.add(new ItemStack(item, 1, i)); - } + @Override + public IIcon getIconFromDamage(int dmg) { + return dmg == 0 ? itemIcon : iconFire; + } - @Override - public void registerIcons(IIconRegister par1IconRegister) { - itemIcon = IconHelper.forItem(par1IconRegister, this, 0); - iconFire = IconHelper.forItem(par1IconRegister, this, 1); - } + @Override + public String getUnlocalizedName(ItemStack stack) { + return super.getUnlocalizedName() + stack.getItemDamage(); + } - @Override - public IIcon getIconFromDamage(int dmg) { - return dmg == 0 ? itemIcon : iconFire; - } + @Override + public ItemStack onItemRightClick(ItemStack p_77659_1_, World p_77659_2_, EntityPlayer p_77659_3_) { + --p_77659_1_.stackSize; - @Override - public String getUnlocalizedName(ItemStack stack) { - return super.getUnlocalizedName() + stack.getItemDamage(); - } + p_77659_2_.playSoundAtEntity(p_77659_3_, "random.bow", 0.5F, 0.4F / (itemRand.nextFloat() * 0.4F + 0.8F)); - @Override - public ItemStack onItemRightClick(ItemStack p_77659_1_, World p_77659_2_, EntityPlayer p_77659_3_) { - --p_77659_1_.stackSize; + if(!p_77659_2_.isRemote) { + EntityThornChakram c = new EntityThornChakram(p_77659_2_, p_77659_3_); + c.setFire(p_77659_1_.getItemDamage() != 0); + p_77659_2_.spawnEntityInWorld(c); + } - p_77659_2_.playSoundAtEntity(p_77659_3_, "random.bow", 0.5F, 0.4F / (itemRand.nextFloat() * 0.4F + 0.8F)); - if (!p_77659_2_.isRemote) { - EntityThornChakram c = new EntityThornChakram(p_77659_2_, p_77659_3_); - c.setFire(p_77659_1_.getItemDamage() != 0); - p_77659_2_.spawnEntityInWorld(c); - } + return p_77659_1_; + } - return p_77659_1_; - } + @Override + public Achievement getAchievementOnCraft(ItemStack stack, EntityPlayer player, IInventory matrix) { + return ModAchievements.terrasteelWeaponCraft; + } - @Override - public Achievement getAchievementOnCraft(ItemStack stack, EntityPlayer player, IInventory matrix) { - return ModAchievements.terrasteelWeaponCraft; - } } diff --git a/src/main/java/vazkii/botania/common/item/ItemTwigWand.java b/src/main/java/vazkii/botania/common/item/ItemTwigWand.java index bb62a0005f..de32dd143c 100644 --- a/src/main/java/vazkii/botania/common/item/ItemTwigWand.java +++ b/src/main/java/vazkii/botania/common/item/ItemTwigWand.java @@ -2,16 +2,17 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jan 20, 2014, 7:42:46 PM (GMT)] */ package vazkii.botania.common.item; import java.awt.Color; import java.util.List; + import net.minecraft.block.Block; import net.minecraft.client.Minecraft; import net.minecraft.client.renderer.texture.IIconRegister; @@ -48,282 +49,266 @@ public class ItemTwigWand extends Item16Colors implements ICoordBoundItem { - IIcon[] icons; - - private static final String TAG_COLOR1 = "color1"; - private static final String TAG_COLOR2 = "color2"; - private static final String TAG_BOUND_TILE_X = "boundTileX"; - private static final String TAG_BOUND_TILE_Y = "boundTileY"; - private static final String TAG_BOUND_TILE_Z = "boundTileZ"; - private static final String TAG_BIND_MODE = "bindMode"; - - public ItemTwigWand() { - super(LibItemNames.TWIG_WAND); - setMaxStackSize(1); - } - - @Override - public boolean onItemUse( - ItemStack par1ItemStack, - EntityPlayer par2EntityPlayer, - World par3World, - int par4, - int par5, - int par6, - int par7, - float par8, - float par9, - float par10) { - Block block = par3World.getBlock(par4, par5, par6); - ChunkCoordinates boundTile = getBoundTile(par1ItemStack); - - if (boundTile.posY != -1 - && par2EntityPlayer.isSneaking() - && (boundTile.posX != par4 || boundTile.posY != par5 || boundTile.posZ != par6)) { - TileEntity tile = par3World.getTileEntity(boundTile.posX, boundTile.posY, boundTile.posZ); - if (tile instanceof IWandBindable) { - if (((IWandBindable) tile).bindTo(par2EntityPlayer, par1ItemStack, par4, par5, par6, par7)) { - Vector3 orig = new Vector3(boundTile.posX + 0.5, boundTile.posY + 0.5, boundTile.posZ + 0.5); - Vector3 end = new Vector3(par4 + 0.5, par5 + 0.5, par6 + 0.5); - doParticleBeam(par3World, orig, end); - - VanillaPacketDispatcher.dispatchTEToNearbyPlayers( - par3World, boundTile.posX, boundTile.posY, boundTile.posZ); - setBoundTile(par1ItemStack, 0, -1, 0); - } - - return true; - } else setBoundTile(par1ItemStack, 0, -1, 0); - } else if (par2EntityPlayer.isSneaking()) { - block.rotateBlock(par3World, par4, par5, par6, ForgeDirection.getOrientation(par7)); - if (par3World.isRemote) par2EntityPlayer.swingItem(); - } - - if (block == Blocks.lapis_block && ConfigHandler.enchanterEnabled) { - int meta = -1; - if (TileEnchanter.canEnchanterExist(par3World, par4, par5, par6, 0)) meta = 0; - else if (TileEnchanter.canEnchanterExist(par3World, par4, par5, par6, 1)) meta = 1; - - if (meta != -1 && !par3World.isRemote) { - par3World.setBlock(par4, par5, par6, ModBlocks.enchanter, meta, 1 | 2); - par2EntityPlayer.addStat(ModAchievements.enchanterMake, 1); - par3World.playSoundEffect(par4, par5, par6, "botania:enchanterBlock", 0.5F, 0.6F); - for (int i = 0; i < 50; i++) { - float red = (float) Math.random(); - float green = (float) Math.random(); - float blue = (float) Math.random(); - - double x = (Math.random() - 0.5) * 6; - double y = (Math.random() - 0.5) * 6; - double z = (Math.random() - 0.5) * 6; - - float velMul = 0.07F; - - Botania.proxy.wispFX( - par3World, - par4 + 0.5 + x, - par5 + 0.5 + y, - par6 + 0.5 + z, - red, - green, - blue, - (float) Math.random() * 0.15F + 0.15F, - (float) -x * velMul, - (float) -y * velMul, - (float) -z * velMul); - } - } - } else if (block instanceof IWandable) { - TileEntity tile = par3World.getTileEntity(par4, par5, par6); - boolean bindable = tile instanceof IWandBindable; - - boolean wanded = false; - if (getBindMode(par1ItemStack) - && bindable - && par2EntityPlayer.isSneaking() - && ((IWandBindable) tile).canSelect(par2EntityPlayer, par1ItemStack, par4, par5, par6, par7)) { - if (boundTile.posX == par4 && boundTile.posY == par5 && boundTile.posZ == par6) - setBoundTile(par1ItemStack, 0, -1, 0); - else setBoundTile(par1ItemStack, par4, par5, par6); - - if (par3World.isRemote) par2EntityPlayer.swingItem(); - par3World.playSoundAtEntity(par2EntityPlayer, "botania:ding", 0.1F, 1F); - - wanded = true; - } else { - wanded = ((IWandable) block) - .onUsedByWand(par2EntityPlayer, par1ItemStack, par3World, par4, par5, par6, par7); - if (wanded && par3World.isRemote) par2EntityPlayer.swingItem(); - } - - return wanded; - } else if (BlockPistonRelay.playerPositions.containsKey(par2EntityPlayer.getCommandSenderName()) - && !par3World.isRemote) { - String bindPos = BlockPistonRelay.playerPositions.get(par2EntityPlayer.getCommandSenderName()); - String currentPos = BlockPistonRelay.getCoordsAsString(par3World.provider.dimensionId, par4, par5, par6); - - BlockPistonRelay.playerPositions.remove(par2EntityPlayer.getCommandSenderName()); - BlockPistonRelay.mappedPositions.put(bindPos, currentPos); - BlockPistonRelay.WorldData.get(par3World).markDirty(); - - par3World.playSoundAtEntity(par2EntityPlayer, "botania:ding", 1F, 1F); - } - - return false; - } - - public static void doParticleBeam(World world, Vector3 orig, Vector3 end) { - if (!world.isRemote) return; - - Vector3 diff = end.copy().sub(orig); - Vector3 movement = diff.copy().normalize().multiply(0.05); - int iters = (int) (diff.mag() / movement.mag()); - float huePer = 1F / iters; - float hueSum = (float) Math.random(); - - Vector3 currentPos = orig.copy(); - for (int i = 0; i < iters; i++) { - float hue = i * huePer + hueSum; - Color color = Color.getHSBColor(hue, 1F, 1F); - float r = color.getRed() / 255F; - float g = color.getGreen() / 255F; - float b = color.getBlue() / 255F; - - Botania.proxy.setSparkleFXNoClip(true); - Botania.proxy.sparkleFX(world, currentPos.x, currentPos.y, currentPos.z, r, g, b, 0.5F, 4); - Botania.proxy.setSparkleFXNoClip(false); - currentPos.add(movement); - } - } - - @Override - public void onUpdate(ItemStack par1ItemStack, World par2World, Entity par3Entity, int par4, boolean par5) { - ChunkCoordinates coords = getBoundTile(par1ItemStack); - TileEntity tile = par2World.getTileEntity(coords.posX, coords.posY, coords.posZ); - if (tile == null || !(tile instanceof IWandBindable)) setBoundTile(par1ItemStack, 0, -1, 0); - } - - @Override - public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer player) { - if (!world.isRemote && player.isSneaking()) { - setBindMode(stack, !getBindMode(stack)); - world.playSoundAtEntity(player, "botania:ding", 0.1F, 1F); - } - - return stack; - } - - @Override - public boolean isFull3D() { - return true; - } - - @Override - public void registerIcons(IIconRegister par1IconRegister) { - icons = new IIcon[4]; - for (int i = 0; i < icons.length; i++) icons[i] = IconHelper.forItem(par1IconRegister, this, i); - } - - @Override - public IIcon getIcon(ItemStack stack, int pass) { - if (pass == 3 && !getBindMode(stack)) pass = 0; - - return icons[Math.min(icons.length - 1, pass)]; - } - - @Override - public int getColorFromItemStack(ItemStack par1ItemStack, int par2) { - if (par2 == 0 || par2 == 3) return 0xFFFFFF; - - float[] color = EntitySheep.fleeceColorTable[par2 == 1 ? getColor1(par1ItemStack) : getColor2(par1ItemStack)]; - return new Color(color[0], color[1], color[2]).getRGB(); - } - - @Override - public boolean requiresMultipleRenderPasses() { - return true; - } - - @Override - public int getRenderPasses(int metadata) { - return 4; - } - - @Override - public void getSubItems(Item par1, CreativeTabs par2CreativeTabs, List par3List) { - for (int i = 0; i < 16; i++) par3List.add(forColors(i, i)); - } - - @Override - public String getUnlocalizedName(ItemStack par1ItemStack) { - return getUnlocalizedNameLazy(par1ItemStack); - } - - @Override - public void addInformation(ItemStack stack, EntityPlayer p, List list, boolean adv) { - list.add(StatCollector.translateToLocal(getModeString(stack))); - } - - @Override - public EnumRarity getRarity(ItemStack par1ItemStack) { - return EnumRarity.rare; - } - - public static ItemStack forColors(int color1, int color2) { - ItemStack stack = new ItemStack(ModItems.twigWand); - ItemNBTHelper.setInt(stack, TAG_COLOR1, color1); - ItemNBTHelper.setInt(stack, TAG_COLOR2, color2); - - return stack; - } - - public static int getColor1(ItemStack stack) { - return ItemNBTHelper.getInt(stack, TAG_COLOR1, 0); - } - - public static int getColor2(ItemStack stack) { - return ItemNBTHelper.getInt(stack, TAG_COLOR2, 0); - } - - public static void setBoundTile(ItemStack stack, int x, int y, int z) { - ItemNBTHelper.setInt(stack, TAG_BOUND_TILE_X, x); - ItemNBTHelper.setInt(stack, TAG_BOUND_TILE_Y, y); - ItemNBTHelper.setInt(stack, TAG_BOUND_TILE_Z, z); - } - - public static ChunkCoordinates getBoundTile(ItemStack stack) { - int x = ItemNBTHelper.getInt(stack, TAG_BOUND_TILE_X, 0); - int y = ItemNBTHelper.getInt(stack, TAG_BOUND_TILE_Y, -1); - int z = ItemNBTHelper.getInt(stack, TAG_BOUND_TILE_Z, 0); - return new ChunkCoordinates(x, y, z); - } - - public static boolean getBindMode(ItemStack stack) { - return ItemNBTHelper.getBoolean(stack, TAG_BIND_MODE, true); - } - - public static void setBindMode(ItemStack stack, boolean bindMode) { - ItemNBTHelper.setBoolean(stack, TAG_BIND_MODE, bindMode); - } - - public static String getModeString(ItemStack stack) { - return "botaniamisc.wandMode." + (getBindMode(stack) ? "bind" : "function"); - } - - @Override - public ChunkCoordinates getBinding(ItemStack stack) { - ChunkCoordinates bound = getBoundTile(stack); - if (bound.posY != -1) return bound; - - MovingObjectPosition pos = Minecraft.getMinecraft().objectMouseOver; - if (pos != null) { - TileEntity tile = Minecraft.getMinecraft().theWorld.getTileEntity(pos.blockX, pos.blockY, pos.blockZ); - if (tile != null && tile instanceof ITileBound) { - ChunkCoordinates coords = ((ITileBound) tile).getBinding(); - return coords; - } - } - - return null; - } + IIcon[] icons; + + private static final String TAG_COLOR1 = "color1"; + private static final String TAG_COLOR2 = "color2"; + private static final String TAG_BOUND_TILE_X = "boundTileX"; + private static final String TAG_BOUND_TILE_Y = "boundTileY"; + private static final String TAG_BOUND_TILE_Z = "boundTileZ"; + private static final String TAG_BIND_MODE = "bindMode"; + + public ItemTwigWand() { + super(LibItemNames.TWIG_WAND); + setMaxStackSize(1); + } + + @Override + public boolean onItemUse(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, World par3World, int par4, int par5, int par6, int par7, float par8, float par9, float par10) { + Block block = par3World.getBlock(par4, par5, par6); + ChunkCoordinates boundTile = getBoundTile(par1ItemStack); + + if(boundTile.posY != -1 && par2EntityPlayer.isSneaking() && (boundTile.posX != par4 || boundTile.posY != par5 || boundTile.posZ != par6)) { + TileEntity tile = par3World.getTileEntity(boundTile.posX, boundTile.posY, boundTile.posZ); + if(tile instanceof IWandBindable) { + if(((IWandBindable) tile).bindTo(par2EntityPlayer, par1ItemStack, par4, par5, par6, par7)) { + Vector3 orig = new Vector3(boundTile.posX + 0.5, boundTile.posY + 0.5, boundTile.posZ + 0.5); + Vector3 end = new Vector3(par4 + 0.5, par5 + 0.5, par6 + 0.5); + doParticleBeam(par3World, orig, end); + + VanillaPacketDispatcher.dispatchTEToNearbyPlayers(par3World, boundTile.posX, boundTile.posY, boundTile.posZ); + setBoundTile(par1ItemStack, 0, -1, 0); + } + + return true; + } else setBoundTile(par1ItemStack, 0, -1, 0); + } else if(par2EntityPlayer.isSneaking()) { + block.rotateBlock(par3World, par4, par5, par6, ForgeDirection.getOrientation(par7)); + if(par3World.isRemote) + par2EntityPlayer.swingItem(); + } + + if(block == Blocks.lapis_block && ConfigHandler.enchanterEnabled) { + int meta = -1; + if(TileEnchanter.canEnchanterExist(par3World, par4, par5, par6, 0)) + meta = 0; + else if(TileEnchanter.canEnchanterExist(par3World, par4, par5, par6, 1)) + meta = 1; + + if(meta != -1 && !par3World.isRemote) { + par3World.setBlock(par4, par5, par6, ModBlocks.enchanter, meta, 1 | 2); + par2EntityPlayer.addStat(ModAchievements.enchanterMake, 1); + par3World.playSoundEffect(par4, par5, par6, "botania:enchanterBlock", 0.5F, 0.6F); + for(int i = 0; i < 50; i++) { + float red = (float) Math.random(); + float green = (float) Math.random(); + float blue = (float) Math.random(); + + double x = (Math.random() - 0.5) * 6; + double y = (Math.random() - 0.5) * 6; + double z = (Math.random() - 0.5) * 6; + + float velMul = 0.07F; + + Botania.proxy.wispFX(par3World, par4 + 0.5 + x, par5 + 0.5 + y, par6 + 0.5 + z, red, green, blue, (float) Math.random() * 0.15F + 0.15F, (float) -x * velMul, (float) -y * velMul, (float) -z * velMul); + } + } + } else if(block instanceof IWandable) { + TileEntity tile = par3World.getTileEntity(par4, par5, par6); + boolean bindable = tile instanceof IWandBindable; + + boolean wanded = false; + if(getBindMode(par1ItemStack) && bindable && par2EntityPlayer.isSneaking() && ((IWandBindable) tile).canSelect(par2EntityPlayer, par1ItemStack, par4, par5, par6, par7)) { + if(boundTile.posX == par4 && boundTile.posY == par5 && boundTile.posZ == par6) + setBoundTile(par1ItemStack, 0, -1, 0); + else setBoundTile(par1ItemStack, par4, par5, par6); + + if(par3World.isRemote) + par2EntityPlayer.swingItem(); + par3World.playSoundAtEntity(par2EntityPlayer, "botania:ding", 0.1F, 1F); + + wanded = true; + } else { + wanded = ((IWandable) block).onUsedByWand(par2EntityPlayer, par1ItemStack, par3World, par4, par5, par6, par7); + if(wanded && par3World.isRemote) + par2EntityPlayer.swingItem(); + } + + return wanded; + } else if(BlockPistonRelay.playerPositions.containsKey(par2EntityPlayer.getCommandSenderName()) && !par3World.isRemote) { + String bindPos = BlockPistonRelay.playerPositions.get(par2EntityPlayer.getCommandSenderName()); + String currentPos = BlockPistonRelay.getCoordsAsString(par3World.provider.dimensionId, par4, par5, par6); + + BlockPistonRelay.playerPositions.remove(par2EntityPlayer.getCommandSenderName()); + BlockPistonRelay.mappedPositions.put(bindPos, currentPos); + BlockPistonRelay.WorldData.get(par3World).markDirty(); + + par3World.playSoundAtEntity(par2EntityPlayer, "botania:ding", 1F, 1F); + } + + return false; + } + + public static void doParticleBeam(World world, Vector3 orig, Vector3 end) { + if(!world.isRemote) + return; + + Vector3 diff = end.copy().sub(orig); + Vector3 movement = diff.copy().normalize().multiply(0.05); + int iters = (int) (diff.mag() / movement.mag()); + float huePer = 1F / iters; + float hueSum = (float) Math.random(); + + Vector3 currentPos = orig.copy(); + for(int i = 0; i < iters; i++) { + float hue = i * huePer + hueSum; + Color color = Color.getHSBColor(hue, 1F, 1F); + float r = color.getRed() / 255F; + float g = color.getGreen() / 255F; + float b = color.getBlue() / 255F; + + Botania.proxy.setSparkleFXNoClip(true); + Botania.proxy.sparkleFX(world, currentPos.x, currentPos.y, currentPos.z, r, g, b, 0.5F, 4); + Botania.proxy.setSparkleFXNoClip(false); + currentPos.add(movement); + } + } + + @Override + public void onUpdate(ItemStack par1ItemStack, World par2World, Entity par3Entity, int par4, boolean par5) { + ChunkCoordinates coords = getBoundTile(par1ItemStack); + TileEntity tile = par2World.getTileEntity(coords.posX, coords.posY, coords.posZ); + if(tile == null || !(tile instanceof IWandBindable)) + setBoundTile(par1ItemStack, 0, -1, 0); + } + + @Override + public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer player) { + if(!world.isRemote && player.isSneaking()) { + setBindMode(stack, !getBindMode(stack)); + world.playSoundAtEntity(player, "botania:ding", 0.1F, 1F); + } + + return stack; + } + + @Override + public boolean isFull3D() { + return true; + } + + @Override + public void registerIcons(IIconRegister par1IconRegister) { + icons = new IIcon[4]; + for(int i = 0; i < icons.length; i++) + icons[i] = IconHelper.forItem(par1IconRegister, this, i); + } + + @Override + public IIcon getIcon(ItemStack stack, int pass) { + if(pass == 3 && !getBindMode(stack)) + pass = 0; + + return icons[Math.min(icons.length - 1, pass)]; + } + + @Override + public int getColorFromItemStack(ItemStack par1ItemStack, int par2) { + if(par2 == 0 || par2 == 3) + return 0xFFFFFF; + + float[] color = EntitySheep.fleeceColorTable[par2 == 1 ? getColor1(par1ItemStack) : getColor2(par1ItemStack)]; + return new Color(color[0], color[1], color[2]).getRGB(); + } + + @Override + public boolean requiresMultipleRenderPasses() { + return true; + } + + @Override + public int getRenderPasses(int metadata) { + return 4; + } + + @Override + public void getSubItems(Item par1, CreativeTabs par2CreativeTabs, List par3List) { + for(int i = 0; i < 16; i++) + par3List.add(forColors(i, i)); + } + + @Override + public String getUnlocalizedName(ItemStack par1ItemStack) { + return getUnlocalizedNameLazy(par1ItemStack); + } + + @Override + public void addInformation(ItemStack stack, EntityPlayer p, List list, boolean adv) { + list.add(StatCollector.translateToLocal(getModeString(stack))); + } + + @Override + public EnumRarity getRarity(ItemStack par1ItemStack) { + return EnumRarity.rare; + } + + public static ItemStack forColors(int color1, int color2) { + ItemStack stack = new ItemStack(ModItems.twigWand); + ItemNBTHelper.setInt(stack, TAG_COLOR1, color1); + ItemNBTHelper.setInt(stack, TAG_COLOR2, color2); + + return stack; + } + + public static int getColor1(ItemStack stack) { + return ItemNBTHelper.getInt(stack, TAG_COLOR1, 0); + } + + public static int getColor2(ItemStack stack) { + return ItemNBTHelper.getInt(stack, TAG_COLOR2, 0); + } + + public static void setBoundTile(ItemStack stack, int x, int y, int z) { + ItemNBTHelper.setInt(stack, TAG_BOUND_TILE_X, x); + ItemNBTHelper.setInt(stack, TAG_BOUND_TILE_Y, y); + ItemNBTHelper.setInt(stack, TAG_BOUND_TILE_Z, z); + } + + public static ChunkCoordinates getBoundTile(ItemStack stack) { + int x = ItemNBTHelper.getInt(stack, TAG_BOUND_TILE_X, 0); + int y = ItemNBTHelper.getInt(stack, TAG_BOUND_TILE_Y, -1); + int z = ItemNBTHelper.getInt(stack, TAG_BOUND_TILE_Z, 0); + return new ChunkCoordinates(x, y, z); + } + + public static boolean getBindMode(ItemStack stack) { + return ItemNBTHelper.getBoolean(stack, TAG_BIND_MODE, true); + } + + public static void setBindMode(ItemStack stack, boolean bindMode) { + ItemNBTHelper.setBoolean(stack, TAG_BIND_MODE, bindMode); + } + + public static String getModeString(ItemStack stack) { + return "botaniamisc.wandMode." + (getBindMode(stack) ? "bind" : "function"); + } + + @Override + public ChunkCoordinates getBinding(ItemStack stack) { + ChunkCoordinates bound = getBoundTile(stack); + if(bound.posY != -1) + return bound; + + MovingObjectPosition pos = Minecraft.getMinecraft().objectMouseOver; + if(pos != null) { + TileEntity tile = Minecraft.getMinecraft().theWorld.getTileEntity(pos.blockX, pos.blockY, pos.blockZ); + if(tile != null && tile instanceof ITileBound) { + ChunkCoordinates coords = ((ITileBound) tile).getBinding(); + return coords; + } + } + + return null; + } + } diff --git a/src/main/java/vazkii/botania/common/item/ItemVineBall.java b/src/main/java/vazkii/botania/common/item/ItemVineBall.java index f2bf6c4685..0c871586e6 100644 --- a/src/main/java/vazkii/botania/common/item/ItemVineBall.java +++ b/src/main/java/vazkii/botania/common/item/ItemVineBall.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jun 26, 2014, 7:50:37 PM (GMT)] */ package vazkii.botania.common.item; @@ -18,19 +18,21 @@ public class ItemVineBall extends ItemMod { - public ItemVineBall() { - setUnlocalizedName(LibItemNames.VINE_BALL); - } + public ItemVineBall() { + setUnlocalizedName(LibItemNames.VINE_BALL); + } - @Override - public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer) { - if (!par3EntityPlayer.capabilities.isCreativeMode) --par1ItemStack.stackSize; + @Override + public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer) { + if(!par3EntityPlayer.capabilities.isCreativeMode) + --par1ItemStack.stackSize; - par2World.playSoundAtEntity( - par3EntityPlayer, "random.bow", 0.5F, 0.4F / (par2World.rand.nextFloat() * 0.4F + 0.8F)); + par2World.playSoundAtEntity(par3EntityPlayer, "random.bow", 0.5F, 0.4F / (par2World.rand.nextFloat() * 0.4F + 0.8F)); - if (!par2World.isRemote) par2World.spawnEntityInWorld(new EntityVineBall(par3EntityPlayer, true)); + if(!par2World.isRemote) + par2World.spawnEntityInWorld(new EntityVineBall(par3EntityPlayer, true)); + + return par1ItemStack; + } - return par1ItemStack; - } } diff --git a/src/main/java/vazkii/botania/common/item/ItemVirus.java b/src/main/java/vazkii/botania/common/item/ItemVirus.java index 85b71c5b91..1ccca7d495 100644 --- a/src/main/java/vazkii/botania/common/item/ItemVirus.java +++ b/src/main/java/vazkii/botania/common/item/ItemVirus.java @@ -2,19 +2,16 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jul 21, 2014, 4:46:17 PM (GMT)] */ package vazkii.botania.common.item; -import cpw.mods.fml.common.eventhandler.SubscribeEvent; -import cpw.mods.fml.relauncher.ReflectionHelper; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; import java.util.List; + import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.entity.EntityLivingBase; @@ -34,91 +31,86 @@ import vazkii.botania.client.core.helper.IconHelper; import vazkii.botania.common.lib.LibItemNames; import vazkii.botania.common.lib.LibObfuscation; +import cpw.mods.fml.common.eventhandler.SubscribeEvent; +import cpw.mods.fml.relauncher.ReflectionHelper; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; public class ItemVirus extends ItemMod { - IIcon[] icons; - - private static final int SUBTYPES = 2; - - public ItemVirus() { - setUnlocalizedName(LibItemNames.VIRUS); - setHasSubtypes(true); - MinecraftForge.EVENT_BUS.register(this); - } - - @Override - public boolean itemInteractionForEntity( - ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, EntityLivingBase par3EntityLivingBase) { - if (par3EntityLivingBase instanceof EntityHorse) { - EntityHorse horse = (EntityHorse) par3EntityLivingBase; - if (horse.getHorseType() != 3 && horse.getHorseType() != 4 && horse.isTame()) { - horse.setHorseType(3 + par1ItemStack.getItemDamage()); - BaseAttributeMap attributes = horse.getAttributeMap(); - IAttributeInstance movementSpeed = - attributes.getAttributeInstance(SharedMonsterAttributes.movementSpeed); - IAttributeInstance health = attributes.getAttributeInstance(SharedMonsterAttributes.maxHealth); - health.applyModifier(new AttributeModifier("Ermergerd Virus D:", health.getBaseValue(), 0)); - movementSpeed.applyModifier( - new AttributeModifier("Ermergerd Virus D:", movementSpeed.getBaseValue(), 0)); - IAttributeInstance jumpHeight = - attributes.getAttributeInstance(ReflectionHelper.getPrivateValue( - EntityHorse.class, null, LibObfuscation.HORSE_JUMP_STRENGTH)); - jumpHeight.applyModifier( - new AttributeModifier("Ermergerd Virus D:", jumpHeight.getBaseValue() * 0.5, 0)); - par2EntityPlayer.worldObj.playSound( - par3EntityLivingBase.posX + 0.5D, - par3EntityLivingBase.posY + 0.5D, - par3EntityLivingBase.posZ + 0.5D, - "mob.zombie.remedy", - 1.0F + par3EntityLivingBase.worldObj.rand.nextFloat(), - par3EntityLivingBase.worldObj.rand.nextFloat() * 0.7F + 1.3F, - false); - - par1ItemStack.stackSize--; - return true; - } - } - return false; - } - - @SubscribeEvent - public void onLivingHurt(LivingHurtEvent event) { - EntityLivingBase entity = event.entityLiving; - if (entity.ridingEntity != null && entity.ridingEntity instanceof EntityLivingBase) - entity = (EntityLivingBase) entity.ridingEntity; - - if (entity instanceof EntityHorse && event.source == DamageSource.fall) { - EntityHorse horse = (EntityHorse) entity; - if ((horse.getHorseType() == 3 || horse.getHorseType() == 4) && horse.isTame()) event.setCanceled(true); - } - } - - @Override - @SideOnly(Side.CLIENT) - public void getSubItems(Item item, CreativeTabs tab, List list) { - for (int i = 0; i < SUBTYPES; i++) list.add(new ItemStack(item, 1, i)); - } - - @Override - @SideOnly(Side.CLIENT) - public IIcon getIconFromDamage(int par1) { - return icons[Math.min(icons.length - 1, par1)]; - } - - @Override - public String getUnlocalizedName(ItemStack par1ItemStack) { - return getUnlocalizedNameLazy(par1ItemStack) + par1ItemStack.getItemDamage(); - } - - String getUnlocalizedNameLazy(ItemStack par1ItemStack) { - return super.getUnlocalizedName(par1ItemStack); - } - - @Override - @SideOnly(Side.CLIENT) - public void registerIcons(IIconRegister par1IconRegister) { - icons = new IIcon[SUBTYPES]; - for (int i = 0; i < SUBTYPES; i++) icons[i] = IconHelper.forItem(par1IconRegister, this, i); - } + IIcon[] icons; + + private static final int SUBTYPES = 2; + + public ItemVirus() { + setUnlocalizedName(LibItemNames.VIRUS); + setHasSubtypes(true); + MinecraftForge.EVENT_BUS.register(this); + } + + @Override + public boolean itemInteractionForEntity(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, EntityLivingBase par3EntityLivingBase) { + if(par3EntityLivingBase instanceof EntityHorse) { + EntityHorse horse = (EntityHorse) par3EntityLivingBase; + if(horse.getHorseType() != 3 && horse.getHorseType() != 4 && horse.isTame()) { + horse.setHorseType(3 + par1ItemStack.getItemDamage()); + BaseAttributeMap attributes = horse.getAttributeMap(); + IAttributeInstance movementSpeed = attributes.getAttributeInstance(SharedMonsterAttributes.movementSpeed); + IAttributeInstance health = attributes.getAttributeInstance(SharedMonsterAttributes.maxHealth); + health.applyModifier(new AttributeModifier("Ermergerd Virus D:", health.getBaseValue(), 0)); + movementSpeed.applyModifier(new AttributeModifier("Ermergerd Virus D:", movementSpeed.getBaseValue(), 0)); + IAttributeInstance jumpHeight = attributes.getAttributeInstance(ReflectionHelper.getPrivateValue(EntityHorse.class, null, LibObfuscation.HORSE_JUMP_STRENGTH)); + jumpHeight.applyModifier(new AttributeModifier("Ermergerd Virus D:", jumpHeight.getBaseValue() * 0.5, 0)); + par2EntityPlayer.worldObj.playSound(par3EntityLivingBase.posX + 0.5D, par3EntityLivingBase.posY + 0.5D, par3EntityLivingBase.posZ + 0.5D, "mob.zombie.remedy", 1.0F + par3EntityLivingBase.worldObj.rand.nextFloat(), par3EntityLivingBase.worldObj.rand.nextFloat() * 0.7F + 1.3F, false); + + par1ItemStack.stackSize--; + return true; + } + } + return false; + } + + @SubscribeEvent + public void onLivingHurt(LivingHurtEvent event) { + EntityLivingBase entity = event.entityLiving; + if(entity.ridingEntity != null && entity.ridingEntity instanceof EntityLivingBase) + entity = (EntityLivingBase) entity.ridingEntity; + + if(entity instanceof EntityHorse && event.source == DamageSource.fall) { + EntityHorse horse = (EntityHorse) entity; + if((horse.getHorseType() == 3 || horse.getHorseType() == 4) && horse.isTame()) + event.setCanceled(true); + } + } + + @Override + @SideOnly(Side.CLIENT) + public void getSubItems(Item item, CreativeTabs tab, List list) { + for(int i = 0; i < SUBTYPES; i++) + list.add(new ItemStack(item, 1, i)); + } + + @Override + @SideOnly(Side.CLIENT) + public IIcon getIconFromDamage(int par1) { + return icons[Math.min(icons.length - 1, par1)]; + } + + @Override + public String getUnlocalizedName(ItemStack par1ItemStack) { + return getUnlocalizedNameLazy(par1ItemStack) + par1ItemStack.getItemDamage(); + } + + String getUnlocalizedNameLazy(ItemStack par1ItemStack) { + return super.getUnlocalizedName(par1ItemStack); + } + + @Override + @SideOnly(Side.CLIENT) + public void registerIcons(IIconRegister par1IconRegister) { + icons = new IIcon[SUBTYPES]; + for(int i = 0; i < SUBTYPES; i++) + icons[i] = IconHelper.forItem(par1IconRegister, this, i); + } + } diff --git a/src/main/java/vazkii/botania/common/item/ItemWaterBowl.java b/src/main/java/vazkii/botania/common/item/ItemWaterBowl.java index bcd109934a..a873f5258e 100644 --- a/src/main/java/vazkii/botania/common/item/ItemWaterBowl.java +++ b/src/main/java/vazkii/botania/common/item/ItemWaterBowl.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jul 8, 2015, 9:07:35 PM (GMT)] */ package vazkii.botania.common.item; @@ -14,8 +14,9 @@ public class ItemWaterBowl extends ItemMod { - public ItemWaterBowl() { - setMaxStackSize(1); - setUnlocalizedName(LibItemNames.WATER_BOWL); - } + public ItemWaterBowl() { + setMaxStackSize(1); + setUnlocalizedName(LibItemNames.WATER_BOWL); + } + } diff --git a/src/main/java/vazkii/botania/common/item/ItemWorldSeed.java b/src/main/java/vazkii/botania/common/item/ItemWorldSeed.java index 6d0f3aa3ee..9d1fc7f545 100644 --- a/src/main/java/vazkii/botania/common/item/ItemWorldSeed.java +++ b/src/main/java/vazkii/botania/common/item/ItemWorldSeed.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jan 25, 2015, 12:27:31 AM (GMT)] */ package vazkii.botania.common.item; @@ -20,40 +20,30 @@ public class ItemWorldSeed extends ItemMod { - public ItemWorldSeed() { - setUnlocalizedName(LibItemNames.WORLD_SEED); - } - - @Override - public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer player) { - ChunkCoordinates coords = world.getSpawnPoint(); - - if (MathHelper.pointDistanceSpace( - coords.posX + 0.5, coords.posY + 0.5, coords.posZ + 0.5, player.posX, player.posY, player.posZ) - > 24) { - player.rotationPitch = 0F; - player.rotationYaw = 0F; - player.setPositionAndUpdate(coords.posX + 0.5, coords.posY + 1.6, coords.posZ + 0.5); - - while (!world.getCollidingBoundingBoxes(player, player.boundingBox).isEmpty()) - player.setPositionAndUpdate(player.posX, player.posY + 1, player.posZ); - - world.playSoundAtEntity(player, "mob.endermen.portal", 1F, 1F); - for (int i = 0; i < 50; i++) - Botania.proxy.sparkleFX( - world, - player.posX + Math.random() * player.width, - player.posY - 1.6 + Math.random() * player.height, - player.posZ + Math.random() * player.width, - 0.25F, - 1F, - 0.25F, - 1F, - 10); - - stack.stackSize--; - } - - return stack; - } + public ItemWorldSeed() { + setUnlocalizedName(LibItemNames.WORLD_SEED); + } + + @Override + public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer player) { + ChunkCoordinates coords = world.getSpawnPoint(); + + if(MathHelper.pointDistanceSpace(coords.posX + 0.5, coords.posY + 0.5, coords.posZ + 0.5, player.posX, player.posY, player.posZ) > 24) { + player.rotationPitch = 0F; + player.rotationYaw = 0F; + player.setPositionAndUpdate(coords.posX + 0.5, coords.posY + 1.6, coords.posZ + 0.5); + + while(!world.getCollidingBoundingBoxes(player, player.boundingBox).isEmpty()) + player.setPositionAndUpdate(player.posX, player.posY + 1, player.posZ); + + world.playSoundAtEntity(player, "mob.endermen.portal", 1F, 1F); + for(int i = 0; i < 50; i++) + Botania.proxy.sparkleFX(world, player.posX + Math.random() * player.width, player.posY - 1.6 + Math.random() * player.height, player.posZ + Math.random() * player.width, 0.25F, 1F, 0.25F, 1F, 10); + + stack.stackSize--; + } + + return stack; + } + } diff --git a/src/main/java/vazkii/botania/common/item/ModItems.java b/src/main/java/vazkii/botania/common/item/ModItems.java index ea65f58b30..d029d5a931 100644 --- a/src/main/java/vazkii/botania/common/item/ModItems.java +++ b/src/main/java/vazkii/botania/common/item/ModItems.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jan 14, 2014, 5:17:47 PM (GMT)] */ package vazkii.botania.common.item; @@ -120,348 +120,350 @@ public final class ModItems { - public static Item lexicon; - public static Item petal; - public static Item dye; - public static Item pestleAndMortar; - public static Item twigWand; - public static Item manaResource; - public static Item lens; - public static Item rune; - public static Item signalFlare; - public static Item manaTablet; - public static Item manaGun; - public static Item manaCookie; - public static Item fertilizer; - public static Item grassSeeds; - public static Item dirtRod; - public static Item terraformRod; - public static Item grassHorn; - public static Item manaMirror; - public static Item manasteelHelm; - public static Item manasteelHelmRevealing; - public static Item manasteelChest; - public static Item manasteelLegs; - public static Item manasteelBoots; - public static Item manasteelPick; - public static Item manasteelShovel; - public static Item manasteelAxe; - public static Item manasteelSword; - public static Item manasteelShears; - public static Item terrasteelHelm; - public static Item terrasteelHelmRevealing; - public static Item terrasteelChest; - public static Item terrasteelLegs; - public static Item terrasteelBoots; - public static Item terraSword; - public static Item tinyPlanet; - public static Item manaRing; - public static Item auraRing; - public static Item manaRingGreater; - public static Item auraRingGreater; - public static Item travelBelt; - public static Item knockbackBelt; - public static Item icePendant; - public static Item lavaPendant; - public static Item goldLaurel; - public static Item magnetRing; - public static Item waterRing; - public static Item miningRing; - public static Item terraPick; - public static Item divaCharm; - public static Item flightTiara; - public static Item enderDagger; - public static Item quartz; - public static Item waterRod; - public static Item elementiumHelm; - public static Item elementiumHelmRevealing; - public static Item elementiumChest; - public static Item elementiumLegs; - public static Item elementiumBoots; - public static Item elementiumPick; - public static Item elementiumShovel; - public static Item elementiumAxe; - public static Item elementiumSword; - public static Item elementiumShears; - public static Item openBucket; - public static Item spawnerMover; - public static Item pixieRing; - public static Item superTravelBelt; - public static Item rainbowRod; - public static Item tornadoRod; - public static Item fireRod; - public static Item vineBall; - public static Item slingshot; - public static Item manaBottle; - public static Item laputaShard; - public static Item virus; - public static Item reachRing; - public static Item skyDirtRod; - public static Item itemFinder; - public static Item superLavaPendant; - public static Item enderHand; - public static Item glassPick; - public static Item spark; - public static Item sparkUpgrade; - public static Item diviningRod; - public static Item gravityRod; - public static Item regenIvy; - public static Item manaInkwell; - public static Item vial; - public static Item brewVial; - public static Item brewFlask; - public static Item bloodPendant; - public static Item missileRod; - public static Item holyCloak; - public static Item unholyCloak; - public static Item craftingHalo; - public static Item blackLotus; - public static Item monocle; - public static Item clip; - public static Item cobbleRod; - public static Item smeltRod; - public static Item worldSeed; - public static Item spellCloth; - public static Item thornChakram; - public static Item overgrowthSeed; - public static Item craftPattern; - public static Item ancientWill; - public static Item corporeaSpark; - public static Item livingwoodBow; - public static Item crystalBow; - public static Item cosmetic; - public static Item swapRing; - public static Item flowerBag; - public static Item phantomInk; - public static Item poolMinecart; - public static Item pinkinator; - public static Item infiniteFruit; - public static Item kingKey; - public static Item flugelEye; - public static Item thorRing; - public static Item odinRing; - public static Item lokiRing; - public static Item aesirRing; - public static Item dice; - public static Item keepIvy; - public static Item blackHoleTalisman; - public static Item recordGaia1; - public static Item recordGaia2; - public static Item temperanceStone; - public static Item incenseStick; - public static Item terraAxe; - public static Item waterBowl; - public static Item obedienceStick; - public static Item cacophonium; - public static Item slimeBottle; - public static Item starSword; - public static Item exchangeRod; - public static Item magnetRingGreater; - public static Item thunderSword; - public static Item manaweaveHelm; - public static Item manaweaveChest; - public static Item manaweaveLegs; - public static Item manaweaveBoots; - public static Item autocraftingHalo; - public static Item gaiaHead; - public static Item sextant; - public static Item speedUpBelt; - public static Item baubleBox; + public static Item lexicon; + public static Item petal; + public static Item dye; + public static Item pestleAndMortar; + public static Item twigWand; + public static Item manaResource; + public static Item lens; + public static Item rune; + public static Item signalFlare; + public static Item manaTablet; + public static Item manaGun; + public static Item manaCookie; + public static Item fertilizer; + public static Item grassSeeds; + public static Item dirtRod; + public static Item terraformRod; + public static Item grassHorn; + public static Item manaMirror; + public static Item manasteelHelm; + public static Item manasteelHelmRevealing; + public static Item manasteelChest; + public static Item manasteelLegs; + public static Item manasteelBoots; + public static Item manasteelPick; + public static Item manasteelShovel; + public static Item manasteelAxe; + public static Item manasteelSword; + public static Item manasteelShears; + public static Item terrasteelHelm; + public static Item terrasteelHelmRevealing; + public static Item terrasteelChest; + public static Item terrasteelLegs; + public static Item terrasteelBoots; + public static Item terraSword; + public static Item tinyPlanet; + public static Item manaRing; + public static Item auraRing; + public static Item manaRingGreater; + public static Item auraRingGreater; + public static Item travelBelt; + public static Item knockbackBelt; + public static Item icePendant; + public static Item lavaPendant; + public static Item goldLaurel; + public static Item magnetRing; + public static Item waterRing; + public static Item miningRing; + public static Item terraPick; + public static Item divaCharm; + public static Item flightTiara; + public static Item enderDagger; + public static Item quartz; + public static Item waterRod; + public static Item elementiumHelm; + public static Item elementiumHelmRevealing; + public static Item elementiumChest; + public static Item elementiumLegs; + public static Item elementiumBoots; + public static Item elementiumPick; + public static Item elementiumShovel; + public static Item elementiumAxe; + public static Item elementiumSword; + public static Item elementiumShears; + public static Item openBucket; + public static Item spawnerMover; + public static Item pixieRing; + public static Item superTravelBelt; + public static Item rainbowRod; + public static Item tornadoRod; + public static Item fireRod; + public static Item vineBall; + public static Item slingshot; + public static Item manaBottle; + public static Item laputaShard; + public static Item virus; + public static Item reachRing; + public static Item skyDirtRod; + public static Item itemFinder; + public static Item superLavaPendant; + public static Item enderHand; + public static Item glassPick; + public static Item spark; + public static Item sparkUpgrade; + public static Item diviningRod; + public static Item gravityRod; + public static Item regenIvy; + public static Item manaInkwell; + public static Item vial; + public static Item brewVial; + public static Item brewFlask; + public static Item bloodPendant; + public static Item missileRod; + public static Item holyCloak; + public static Item unholyCloak; + public static Item craftingHalo; + public static Item blackLotus; + public static Item monocle; + public static Item clip; + public static Item cobbleRod; + public static Item smeltRod; + public static Item worldSeed; + public static Item spellCloth; + public static Item thornChakram; + public static Item overgrowthSeed; + public static Item craftPattern; + public static Item ancientWill; + public static Item corporeaSpark; + public static Item livingwoodBow; + public static Item crystalBow; + public static Item cosmetic; + public static Item swapRing; + public static Item flowerBag; + public static Item phantomInk; + public static Item poolMinecart; + public static Item pinkinator; + public static Item infiniteFruit; + public static Item kingKey; + public static Item flugelEye; + public static Item thorRing; + public static Item odinRing; + public static Item lokiRing; + public static Item aesirRing; + public static Item dice; + public static Item keepIvy; + public static Item blackHoleTalisman; + public static Item recordGaia1; + public static Item recordGaia2; + public static Item temperanceStone; + public static Item incenseStick; + public static Item terraAxe; + public static Item waterBowl; + public static Item obedienceStick; + public static Item cacophonium; + public static Item slimeBottle; + public static Item starSword; + public static Item exchangeRod; + public static Item magnetRingGreater; + public static Item thunderSword; + public static Item manaweaveHelm; + public static Item manaweaveChest; + public static Item manaweaveLegs; + public static Item manaweaveBoots; + public static Item autocraftingHalo; + public static Item gaiaHead; + public static Item sextant; + public static Item speedUpBelt; + public static Item baubleBox; - public static void init() { - lexicon = new ItemLexicon(); - petal = new ItemPetal(); - dye = new ItemDye(); - pestleAndMortar = new ItemPestleAndMortar(); - twigWand = new ItemTwigWand(); - manaResource = new ItemManaResource(); - lens = new ItemLens(); - rune = new ItemRune(); - signalFlare = new ItemSignalFlare(); - manaTablet = new ItemManaTablet(); - manaGun = new ItemManaGun(); - manaCookie = new ItemManaCookie(); - fertilizer = new ItemFertilizer(); - grassSeeds = new ItemGrassSeeds(); - dirtRod = new ItemDirtRod(); - terraformRod = new ItemTerraformRod(); - grassHorn = new ItemGrassHorn(); - manaMirror = new ItemManaMirror(); - manasteelHelm = new ItemManasteelHelm(); - manasteelHelmRevealing = new ItemManasteelHelmRevealing(); - manasteelChest = new ItemManasteelChest(); - manasteelLegs = new ItemManasteelLegs(); - manasteelBoots = new ItemManasteelBoots(); - manasteelPick = new ItemManasteelPick(); - manasteelShovel = new ItemManasteelShovel(); - manasteelAxe = new ItemManasteelAxe(); - manasteelSword = new ItemManasteelSword(); - manasteelShears = new ItemManasteelShears(); - terrasteelHelm = new ItemTerrasteelHelm(); - terrasteelHelmRevealing = new ItemTerrasteelHelmRevealing(); - terrasteelChest = new ItemTerrasteelChest(); - terrasteelLegs = new ItemTerrasteelLegs(); - terrasteelBoots = new ItemTerrasteelBoots(); - terraSword = new ItemTerraSword(); - tinyPlanet = new ItemTinyPlanet(); - manaRing = new ItemManaRing(); - auraRing = new ItemAuraRing(); - manaRingGreater = new ItemGreaterManaRing(); - auraRingGreater = new ItemGreaterAuraRing(); - travelBelt = new ItemTravelBelt(); - knockbackBelt = new ItemKnockbackBelt(); - icePendant = new ItemIcePendant(); - lavaPendant = new ItemLavaPendant(); - goldLaurel = new ItemGoldenLaurel(); - magnetRing = new ItemMagnetRing(); - waterRing = new ItemWaterRing(); - miningRing = new ItemMiningRing(); - terraPick = new ItemTerraPick(); - divaCharm = new ItemDivaCharm(); - flightTiara = new ItemFlightTiara(); - enderDagger = new ItemEnderDagger(); - quartz = new ItemQuartz(); - waterRod = new ItemWaterRod(); - elementiumHelm = new ItemElementiumHelm(); - elementiumHelmRevealing = new ItemElementiumHelmRevealing(); - elementiumChest = new ItemElementiumChest(); - elementiumLegs = new ItemElementiumLegs(); - elementiumBoots = new ItemElementiumBoots(); - elementiumPick = new ItemElementiumPick(); - elementiumShovel = new ItemElementiumShovel(); - elementiumAxe = new ItemElementiumAxe(); - elementiumSword = new ItemElementiumSword(); - elementiumShears = new ItemElementiumShears(); - openBucket = new ItemOpenBucket(); - spawnerMover = new ItemSpawnerMover(); - pixieRing = new ItemPixieRing(); - superTravelBelt = new ItemSuperTravelBelt(); - rainbowRod = new ItemRainbowRod(); - tornadoRod = new ItemTornadoRod(); - fireRod = new ItemFireRod(); - vineBall = new ItemVineBall(); - slingshot = new ItemSlingshot(); - manaBottle = new ItemBottledMana(); - laputaShard = new ItemLaputaShard(); - virus = new ItemVirus(); - reachRing = new ItemReachRing(); - skyDirtRod = new ItemSkyDirtRod(); - itemFinder = new ItemItemFinder(); - superLavaPendant = new ItemSuperLavaPendant(); - enderHand = new ItemEnderHand(); - glassPick = new ItemGlassPick(); - spark = new ItemSpark(); - sparkUpgrade = new ItemSparkUpgrade(); - diviningRod = new ItemDiviningRod(); - gravityRod = new ItemGravityRod(); - regenIvy = new ItemRegenIvy(); - manaInkwell = new ItemManaInkwell(); - vial = new ItemVial(); - brewVial = new ItemBrewVial(); - brewFlask = new ItemBrewFlask(); - bloodPendant = new ItemBloodPendant(); - missileRod = new ItemMissileRod(); - holyCloak = new ItemHolyCloak(); - unholyCloak = new ItemUnholyCloak(); - craftingHalo = new ItemCraftingHalo(); - blackLotus = new ItemBlackLotus(); - monocle = new ItemMonocle(); - clip = new ItemClip(); - cobbleRod = new ItemCobbleRod(); - smeltRod = new ItemSmeltRod(); - worldSeed = new ItemWorldSeed(); - spellCloth = new ItemSpellCloth(); - thornChakram = new ItemThornChakram(); - overgrowthSeed = new ItemOvergrowthSeed(); - craftPattern = new ItemCraftPattern(); - ancientWill = new ItemAncientWill(); - corporeaSpark = new ItemCorporeaSpark(); - livingwoodBow = new ItemLivingwoodBow(); - crystalBow = new ItemCrystalBow(); - cosmetic = new ItemBaubleCosmetic(); - swapRing = new ItemSwapRing(); - flowerBag = new ItemFlowerBag(); - phantomInk = new ItemPhantomInk(); - poolMinecart = new ItemPoolMinecart(); - pinkinator = new ItemPinkinator(); - infiniteFruit = new ItemInfiniteFruit(); - kingKey = new ItemKingKey(); - flugelEye = new ItemFlugelEye(); - thorRing = new ItemThorRing(); - odinRing = new ItemOdinRing(); - lokiRing = new ItemLokiRing(); - aesirRing = new ItemAesirRing(); - dice = new ItemDice(); - keepIvy = new ItemKeepIvy(); - blackHoleTalisman = new ItemBlackHoleTalisman(); - recordGaia1 = new ItemRecordGaia1(); - recordGaia2 = new ItemRecordGaia2(); - temperanceStone = new ItemTemperanceStone(); - incenseStick = new ItemIncenseStick(); - terraAxe = new ItemTerraAxe(); - waterBowl = new ItemWaterBowl(); - obedienceStick = new ItemObedienceStick(); - cacophonium = new ItemCacophonium(); - slimeBottle = new ItemSlimeBottle(); - starSword = new ItemStarSword(); - exchangeRod = new ItemExchangeRod(); - magnetRingGreater = new ItemGreaterMagnetRing(); - thunderSword = new ItemThunderSword(); - manaweaveHelm = new ItemManaweaveHelm(); - manaweaveLegs = new ItemManaweaveLegs(); - manaweaveChest = new ItemManaweaveChest(); - manaweaveBoots = new ItemManaweaveBoots(); - autocraftingHalo = new ItemAutocraftingHalo(); - gaiaHead = new ItemGaiaHead(); - sextant = new ItemSextant(); - speedUpBelt = new ItemSpeedUpBelt(); - baubleBox = new ItemBaubleBox(); + public static void init() { + lexicon = new ItemLexicon(); + petal = new ItemPetal(); + dye = new ItemDye(); + pestleAndMortar = new ItemPestleAndMortar(); + twigWand = new ItemTwigWand(); + manaResource = new ItemManaResource(); + lens = new ItemLens(); + rune = new ItemRune(); + signalFlare = new ItemSignalFlare(); + manaTablet = new ItemManaTablet(); + manaGun = new ItemManaGun(); + manaCookie = new ItemManaCookie(); + fertilizer = new ItemFertilizer(); + grassSeeds = new ItemGrassSeeds(); + dirtRod = new ItemDirtRod(); + terraformRod = new ItemTerraformRod(); + grassHorn = new ItemGrassHorn(); + manaMirror = new ItemManaMirror(); + manasteelHelm = new ItemManasteelHelm(); + manasteelHelmRevealing = new ItemManasteelHelmRevealing(); + manasteelChest = new ItemManasteelChest(); + manasteelLegs = new ItemManasteelLegs(); + manasteelBoots = new ItemManasteelBoots(); + manasteelPick = new ItemManasteelPick(); + manasteelShovel = new ItemManasteelShovel(); + manasteelAxe = new ItemManasteelAxe(); + manasteelSword = new ItemManasteelSword(); + manasteelShears = new ItemManasteelShears(); + terrasteelHelm = new ItemTerrasteelHelm(); + terrasteelHelmRevealing = new ItemTerrasteelHelmRevealing(); + terrasteelChest = new ItemTerrasteelChest(); + terrasteelLegs = new ItemTerrasteelLegs(); + terrasteelBoots = new ItemTerrasteelBoots(); + terraSword = new ItemTerraSword(); + tinyPlanet = new ItemTinyPlanet(); + manaRing = new ItemManaRing(); + auraRing = new ItemAuraRing(); + manaRingGreater = new ItemGreaterManaRing(); + auraRingGreater = new ItemGreaterAuraRing(); + travelBelt = new ItemTravelBelt(); + knockbackBelt = new ItemKnockbackBelt(); + icePendant = new ItemIcePendant(); + lavaPendant = new ItemLavaPendant(); + goldLaurel = new ItemGoldenLaurel(); + magnetRing = new ItemMagnetRing(); + waterRing = new ItemWaterRing(); + miningRing = new ItemMiningRing(); + terraPick = new ItemTerraPick(); + divaCharm = new ItemDivaCharm(); + flightTiara = new ItemFlightTiara(); + enderDagger = new ItemEnderDagger(); + quartz = new ItemQuartz(); + waterRod = new ItemWaterRod(); + elementiumHelm = new ItemElementiumHelm(); + elementiumHelmRevealing = new ItemElementiumHelmRevealing(); + elementiumChest = new ItemElementiumChest(); + elementiumLegs = new ItemElementiumLegs(); + elementiumBoots = new ItemElementiumBoots(); + elementiumPick = new ItemElementiumPick(); + elementiumShovel = new ItemElementiumShovel(); + elementiumAxe = new ItemElementiumAxe(); + elementiumSword = new ItemElementiumSword(); + elementiumShears = new ItemElementiumShears(); + openBucket = new ItemOpenBucket(); + spawnerMover = new ItemSpawnerMover(); + pixieRing = new ItemPixieRing(); + superTravelBelt = new ItemSuperTravelBelt(); + rainbowRod = new ItemRainbowRod(); + tornadoRod = new ItemTornadoRod(); + fireRod = new ItemFireRod(); + vineBall = new ItemVineBall(); + slingshot = new ItemSlingshot(); + manaBottle = new ItemBottledMana(); + laputaShard = new ItemLaputaShard(); + virus = new ItemVirus(); + reachRing = new ItemReachRing(); + skyDirtRod = new ItemSkyDirtRod(); + itemFinder = new ItemItemFinder(); + superLavaPendant = new ItemSuperLavaPendant(); + enderHand = new ItemEnderHand(); + glassPick = new ItemGlassPick(); + spark = new ItemSpark(); + sparkUpgrade = new ItemSparkUpgrade(); + diviningRod = new ItemDiviningRod(); + gravityRod = new ItemGravityRod(); + regenIvy = new ItemRegenIvy(); + manaInkwell = new ItemManaInkwell(); + vial = new ItemVial(); + brewVial = new ItemBrewVial(); + brewFlask = new ItemBrewFlask(); + bloodPendant = new ItemBloodPendant(); + missileRod = new ItemMissileRod(); + holyCloak = new ItemHolyCloak(); + unholyCloak = new ItemUnholyCloak(); + craftingHalo = new ItemCraftingHalo(); + blackLotus = new ItemBlackLotus(); + monocle = new ItemMonocle(); + clip = new ItemClip(); + cobbleRod = new ItemCobbleRod(); + smeltRod = new ItemSmeltRod(); + worldSeed = new ItemWorldSeed(); + spellCloth = new ItemSpellCloth(); + thornChakram = new ItemThornChakram(); + overgrowthSeed = new ItemOvergrowthSeed(); + craftPattern = new ItemCraftPattern(); + ancientWill = new ItemAncientWill(); + corporeaSpark = new ItemCorporeaSpark(); + livingwoodBow = new ItemLivingwoodBow(); + crystalBow = new ItemCrystalBow(); + cosmetic = new ItemBaubleCosmetic(); + swapRing = new ItemSwapRing(); + flowerBag = new ItemFlowerBag(); + phantomInk = new ItemPhantomInk(); + poolMinecart = new ItemPoolMinecart(); + pinkinator = new ItemPinkinator(); + infiniteFruit = new ItemInfiniteFruit(); + kingKey = new ItemKingKey(); + flugelEye = new ItemFlugelEye(); + thorRing = new ItemThorRing(); + odinRing = new ItemOdinRing(); + lokiRing = new ItemLokiRing(); + aesirRing = new ItemAesirRing(); + dice = new ItemDice(); + keepIvy = new ItemKeepIvy(); + blackHoleTalisman = new ItemBlackHoleTalisman(); + recordGaia1 = new ItemRecordGaia1(); + recordGaia2 = new ItemRecordGaia2(); + temperanceStone = new ItemTemperanceStone(); + incenseStick = new ItemIncenseStick(); + terraAxe = new ItemTerraAxe(); + waterBowl = new ItemWaterBowl(); + obedienceStick = new ItemObedienceStick(); + cacophonium = new ItemCacophonium(); + slimeBottle = new ItemSlimeBottle(); + starSword = new ItemStarSword(); + exchangeRod = new ItemExchangeRod(); + magnetRingGreater = new ItemGreaterMagnetRing(); + thunderSword = new ItemThunderSword(); + manaweaveHelm = new ItemManaweaveHelm(); + manaweaveLegs = new ItemManaweaveLegs(); + manaweaveChest = new ItemManaweaveChest(); + manaweaveBoots = new ItemManaweaveBoots(); + autocraftingHalo = new ItemAutocraftingHalo(); + gaiaHead = new ItemGaiaHead(); + sextant = new ItemSextant(); + speedUpBelt = new ItemSpeedUpBelt(); + baubleBox = new ItemBaubleBox(); - OreDictionary.registerOre(LibOreDict.LEXICON, lexicon); - for (int i = 0; i < 16; i++) { - OreDictionary.registerOre(LibOreDict.PETAL[i], new ItemStack(petal, 1, i)); - OreDictionary.registerOre(LibOreDict.DYE[i], new ItemStack(dye, 1, i)); - OreDictionary.registerOre(LibOreDict.RUNE[i], new ItemStack(rune, 1, i)); - } - for (int i = 0; i < 7; i++) OreDictionary.registerOre(LibOreDict.QUARTZ[i], new ItemStack(quartz, 1, i)); + OreDictionary.registerOre(LibOreDict.LEXICON, lexicon); + for(int i = 0; i < 16; i++) { + OreDictionary.registerOre(LibOreDict.PETAL[i], new ItemStack(petal, 1, i)); + OreDictionary.registerOre(LibOreDict.DYE[i], new ItemStack(dye, 1, i)); + OreDictionary.registerOre(LibOreDict.RUNE[i], new ItemStack(rune, 1, i)); + } + for(int i = 0; i < 7; i++) + OreDictionary.registerOre(LibOreDict.QUARTZ[i], new ItemStack(quartz, 1, i)); - OreDictionary.registerOre(LibOreDict.PESTLE_AND_MORTAR, pestleAndMortar); - OreDictionary.registerOre(LibOreDict.MANA_STEEL, new ItemStack(manaResource, 1, 0)); - OreDictionary.registerOre(LibOreDict.MANA_PEARL, new ItemStack(manaResource, 1, 1)); - OreDictionary.registerOre(LibOreDict.MANA_DIAMOND, new ItemStack(manaResource, 1, 2)); - OreDictionary.registerOre(LibOreDict.LIVINGWOOD_TWIG, new ItemStack(manaResource, 1, 3)); - OreDictionary.registerOre(LibOreDict.TERRA_STEEL, new ItemStack(manaResource, 1, 4)); - OreDictionary.registerOre(LibOreDict.LIFE_ESSENCE, new ItemStack(manaResource, 1, 5)); - OreDictionary.registerOre(LibOreDict.REDSTONE_ROOT, new ItemStack(manaResource, 1, 6)); - OreDictionary.registerOre(LibOreDict.ELEMENTIUM, new ItemStack(manaResource, 1, 7)); - OreDictionary.registerOre(LibOreDict.PIXIE_DUST, new ItemStack(manaResource, 1, 8)); - OreDictionary.registerOre(LibOreDict.DRAGONSTONE, new ItemStack(manaResource, 1, 9)); - OreDictionary.registerOre(LibOreDict.PRISMARINE_SHARD, new ItemStack(manaResource, 1, 10)); - OreDictionary.registerOre(LibOreDict.PLACEHOLDER, new ItemStack(manaResource, 1, 11)); - OreDictionary.registerOre(LibOreDict.RED_STRING, new ItemStack(manaResource, 1, 12)); - OreDictionary.registerOre(LibOreDict.DREAMWOOD_TWIG, new ItemStack(manaResource, 1, 13)); - OreDictionary.registerOre(LibOreDict.GAIA_INGOT, new ItemStack(manaResource, 1, 14)); - OreDictionary.registerOre(LibOreDict.ENDER_AIR_BOTTLE, new ItemStack(manaResource, 1, 15)); - OreDictionary.registerOre(LibOreDict.MANA_STRING, new ItemStack(manaResource, 1, 16)); - OreDictionary.registerOre(LibOreDict.MANASTEEL_NUGGET, new ItemStack(manaResource, 1, 17)); - OreDictionary.registerOre(LibOreDict.TERRASTEEL_NUGGET, new ItemStack(manaResource, 1, 18)); - OreDictionary.registerOre(LibOreDict.ELEMENTIUM_NUGGET, new ItemStack(manaResource, 1, 19)); - OreDictionary.registerOre(LibOreDict.ROOT, new ItemStack(manaResource, 1, 20)); - OreDictionary.registerOre(LibOreDict.PEBBLE, new ItemStack(manaResource, 1, 21)); - OreDictionary.registerOre(LibOreDict.MANAWEAVE_CLOTH, new ItemStack(manaResource, 1, 22)); - OreDictionary.registerOre(LibOreDict.MANA_POWDER, new ItemStack(manaResource, 1, 23)); + OreDictionary.registerOre(LibOreDict.PESTLE_AND_MORTAR, pestleAndMortar); + OreDictionary.registerOre(LibOreDict.MANA_STEEL, new ItemStack(manaResource, 1, 0)); + OreDictionary.registerOre(LibOreDict.MANA_PEARL, new ItemStack(manaResource, 1, 1)); + OreDictionary.registerOre(LibOreDict.MANA_DIAMOND, new ItemStack(manaResource, 1, 2)); + OreDictionary.registerOre(LibOreDict.LIVINGWOOD_TWIG, new ItemStack(manaResource, 1, 3)); + OreDictionary.registerOre(LibOreDict.TERRA_STEEL, new ItemStack(manaResource, 1, 4)); + OreDictionary.registerOre(LibOreDict.LIFE_ESSENCE, new ItemStack(manaResource, 1, 5)); + OreDictionary.registerOre(LibOreDict.REDSTONE_ROOT, new ItemStack(manaResource, 1, 6)); + OreDictionary.registerOre(LibOreDict.ELEMENTIUM, new ItemStack(manaResource, 1, 7)); + OreDictionary.registerOre(LibOreDict.PIXIE_DUST, new ItemStack(manaResource, 1, 8)); + OreDictionary.registerOre(LibOreDict.DRAGONSTONE, new ItemStack(manaResource, 1, 9)); + OreDictionary.registerOre(LibOreDict.PRISMARINE_SHARD, new ItemStack(manaResource, 1, 10)); + OreDictionary.registerOre(LibOreDict.PLACEHOLDER, new ItemStack(manaResource, 1, 11)); + OreDictionary.registerOre(LibOreDict.RED_STRING, new ItemStack(manaResource, 1, 12)); + OreDictionary.registerOre(LibOreDict.DREAMWOOD_TWIG, new ItemStack(manaResource, 1, 13)); + OreDictionary.registerOre(LibOreDict.GAIA_INGOT, new ItemStack(manaResource, 1, 14)); + OreDictionary.registerOre(LibOreDict.ENDER_AIR_BOTTLE, new ItemStack(manaResource, 1, 15)); + OreDictionary.registerOre(LibOreDict.MANA_STRING, new ItemStack(manaResource, 1, 16)); + OreDictionary.registerOre(LibOreDict.MANASTEEL_NUGGET, new ItemStack(manaResource, 1, 17)); + OreDictionary.registerOre(LibOreDict.TERRASTEEL_NUGGET, new ItemStack(manaResource, 1, 18)); + OreDictionary.registerOre(LibOreDict.ELEMENTIUM_NUGGET, new ItemStack(manaResource, 1, 19)); + OreDictionary.registerOre(LibOreDict.ROOT, new ItemStack(manaResource, 1, 20)); + OreDictionary.registerOre(LibOreDict.PEBBLE, new ItemStack(manaResource, 1, 21)); + OreDictionary.registerOre(LibOreDict.MANAWEAVE_CLOTH, new ItemStack(manaResource, 1, 22)); + OreDictionary.registerOre(LibOreDict.MANA_POWDER, new ItemStack(manaResource, 1, 23)); - OreDictionary.registerOre(LibOreDict.VIAL, new ItemStack(vial, 1, 0)); - OreDictionary.registerOre(LibOreDict.FLASK, new ItemStack(vial, 1, 1)); + OreDictionary.registerOre(LibOreDict.VIAL, new ItemStack(vial, 1, 0)); + OreDictionary.registerOre(LibOreDict.FLASK, new ItemStack(vial, 1, 1)); - BotaniaAPI.blackListItemFromLoonium(lexicon); - BotaniaAPI.blackListItemFromLoonium(overgrowthSeed); - BotaniaAPI.blackListItemFromLoonium(blackLotus); - int min = Item.getIdFromItem(Items.record_13); - int max = Item.getIdFromItem(Items.record_wait); - for (int i = min; i <= max; i++) BotaniaAPI.blackListItemFromLoonium(Item.getItemById(i)); + BotaniaAPI.blackListItemFromLoonium(lexicon); + BotaniaAPI.blackListItemFromLoonium(overgrowthSeed); + BotaniaAPI.blackListItemFromLoonium(blackLotus); + int min = Item.getIdFromItem(Items.record_13); + int max = Item.getIdFromItem(Items.record_wait); + for(int i = min; i <= max; i++) + BotaniaAPI.blackListItemFromLoonium(Item.getItemById(i)); - OreDictionary.registerOre("rodBlaze", Items.blaze_rod); - OreDictionary.registerOre("powderBlaze", Items.blaze_powder); - } + OreDictionary.registerOre("rodBlaze", Items.blaze_rod); + OreDictionary.registerOre("powderBlaze", Items.blaze_powder); + } } diff --git a/src/main/java/vazkii/botania/common/item/block/IRarityBlock.java b/src/main/java/vazkii/botania/common/item/block/IRarityBlock.java index 1ce1dc3fee..d404d084d3 100644 --- a/src/main/java/vazkii/botania/common/item/block/IRarityBlock.java +++ b/src/main/java/vazkii/botania/common/item/block/IRarityBlock.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Mar 31, 2015, 9:00:38 PM (GMT)] */ package vazkii.botania.common.item.block; @@ -15,5 +15,6 @@ public interface IRarityBlock { - public EnumRarity getRarity(ItemStack stack); + public EnumRarity getRarity(ItemStack stack); + } diff --git a/src/main/java/vazkii/botania/common/item/block/ItemBlockDreamwood.java b/src/main/java/vazkii/botania/common/item/block/ItemBlockDreamwood.java index 6cdde35e1b..eec1ada5e0 100644 --- a/src/main/java/vazkii/botania/common/item/block/ItemBlockDreamwood.java +++ b/src/main/java/vazkii/botania/common/item/block/ItemBlockDreamwood.java @@ -6,12 +6,13 @@ public class ItemBlockDreamwood extends ItemBlockWithMetadataAndName implements IElvenItem { - public ItemBlockDreamwood(Block block) { - super(block); - } + public ItemBlockDreamwood(Block block) { + super(block); + } + + @Override + public boolean isElvenItem(ItemStack stack) { + return true; + } - @Override - public boolean isElvenItem(ItemStack stack) { - return true; - } } diff --git a/src/main/java/vazkii/botania/common/item/block/ItemBlockElven.java b/src/main/java/vazkii/botania/common/item/block/ItemBlockElven.java index ab8ac722d3..8fad997dda 100644 --- a/src/main/java/vazkii/botania/common/item/block/ItemBlockElven.java +++ b/src/main/java/vazkii/botania/common/item/block/ItemBlockElven.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Sep 9, 2014, 5:02:06 PM (GMT)] */ package vazkii.botania.common.item.block; @@ -16,12 +16,13 @@ public class ItemBlockElven extends ItemBlockMod implements IElvenItem { - public ItemBlockElven(Block block) { - super(block); - } + public ItemBlockElven(Block block) { + super(block); + } + + @Override + public boolean isElvenItem(ItemStack stack) { + return ((IElvenItem) field_150939_a).isElvenItem(stack); + } - @Override - public boolean isElvenItem(ItemStack stack) { - return ((IElvenItem) field_150939_a).isElvenItem(stack); - } } diff --git a/src/main/java/vazkii/botania/common/item/block/ItemBlockFloatingSpecialFlower.java b/src/main/java/vazkii/botania/common/item/block/ItemBlockFloatingSpecialFlower.java index 8b2d9ccb78..f6ef345a2b 100644 --- a/src/main/java/vazkii/botania/common/item/block/ItemBlockFloatingSpecialFlower.java +++ b/src/main/java/vazkii/botania/common/item/block/ItemBlockFloatingSpecialFlower.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Nov 17, 2014, 5:39:08 PM (GMT)] */ package vazkii.botania.common.item.block; @@ -16,15 +16,14 @@ public class ItemBlockFloatingSpecialFlower extends ItemBlockSpecialFlower { - public ItemBlockFloatingSpecialFlower(Block block1) { - super(block1); - } + public ItemBlockFloatingSpecialFlower(Block block1) { + super(block1); + } + + @Override + public String getItemStackDisplayName(ItemStack stack) { + String flowerName = getUnlocalizedName(stack) + ".name"; + return String.format(StatCollector.translateToLocal("botaniamisc.floatingPrefix"), StatCollector.translateToLocal(flowerName)); + } - @Override - public String getItemStackDisplayName(ItemStack stack) { - String flowerName = getUnlocalizedName(stack) + ".name"; - return String.format( - StatCollector.translateToLocal("botaniamisc.floatingPrefix"), - StatCollector.translateToLocal(flowerName)); - } } diff --git a/src/main/java/vazkii/botania/common/item/block/ItemBlockMod.java b/src/main/java/vazkii/botania/common/item/block/ItemBlockMod.java index 6a790a6bc6..a3491afb0a 100644 --- a/src/main/java/vazkii/botania/common/item/block/ItemBlockMod.java +++ b/src/main/java/vazkii/botania/common/item/block/ItemBlockMod.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [May 16, 2014, 7:00:36 PM (GMT)] */ package vazkii.botania.common.item.block; @@ -23,30 +23,27 @@ public class ItemBlockMod extends ItemBlock implements IPickupAchievement, ICraftAchievement { - public ItemBlockMod(Block block) { - super(block); - } - - @Override - public String getUnlocalizedNameInefficiently(ItemStack par1ItemStack) { - return getUnlocalizedNameInefficiently_(par1ItemStack).replaceAll("tile.", "tile." + LibResources.PREFIX_MOD); - } - - public String getUnlocalizedNameInefficiently_(ItemStack stack) { - return super.getUnlocalizedNameInefficiently(stack); - } - - @Override - public Achievement getAchievementOnCraft(ItemStack stack, EntityPlayer player, IInventory matrix) { - return field_150939_a instanceof ICraftAchievement - ? ((ICraftAchievement) field_150939_a).getAchievementOnCraft(stack, player, matrix) - : null; - } - - @Override - public Achievement getAchievementOnPickup(ItemStack stack, EntityPlayer player, EntityItem item) { - return field_150939_a instanceof IPickupAchievement - ? ((IPickupAchievement) field_150939_a).getAchievementOnPickup(stack, player, item) - : null; - } + public ItemBlockMod(Block block) { + super(block); + } + + @Override + public String getUnlocalizedNameInefficiently(ItemStack par1ItemStack) { + return getUnlocalizedNameInefficiently_(par1ItemStack).replaceAll("tile.", "tile." + LibResources.PREFIX_MOD); + } + + public String getUnlocalizedNameInefficiently_(ItemStack stack) { + return super.getUnlocalizedNameInefficiently(stack); + } + + @Override + public Achievement getAchievementOnCraft(ItemStack stack, EntityPlayer player, IInventory matrix) { + return field_150939_a instanceof ICraftAchievement ? ((ICraftAchievement) field_150939_a).getAchievementOnCraft(stack, player, matrix) : null; + } + + @Override + public Achievement getAchievementOnPickup(ItemStack stack, EntityPlayer player, EntityItem item) { + return field_150939_a instanceof IPickupAchievement ? ((IPickupAchievement) field_150939_a).getAchievementOnPickup(stack, player, item) : null; + } + } diff --git a/src/main/java/vazkii/botania/common/item/block/ItemBlockModSlab.java b/src/main/java/vazkii/botania/common/item/block/ItemBlockModSlab.java index a483eb1247..0883b4a592 100644 --- a/src/main/java/vazkii/botania/common/item/block/ItemBlockModSlab.java +++ b/src/main/java/vazkii/botania/common/item/block/ItemBlockModSlab.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jun 11, 2014, 1:16:59 AM (GMT)] */ package vazkii.botania.common.item.block; @@ -17,12 +17,13 @@ public class ItemBlockModSlab extends ItemSlab { - public ItemBlockModSlab(Block par1) { - super(par1, ((BlockModSlab) par1).getSingleBlock(), ((BlockModSlab) par1).getFullBlock(), false); - } + public ItemBlockModSlab(Block par1) { + super(par1, ((BlockModSlab)par1).getSingleBlock(), ((BlockModSlab)par1).getFullBlock(), false); + } + + @Override + public String getUnlocalizedName(ItemStack par1ItemStack) { + return field_150939_a.getUnlocalizedName().replaceAll("tile.", "tile.botania:"); + } - @Override - public String getUnlocalizedName(ItemStack par1ItemStack) { - return field_150939_a.getUnlocalizedName().replaceAll("tile.", "tile.botania:"); - } } diff --git a/src/main/java/vazkii/botania/common/item/block/ItemBlockPool.java b/src/main/java/vazkii/botania/common/item/block/ItemBlockPool.java index 7a19970b2e..7c399f9625 100644 --- a/src/main/java/vazkii/botania/common/item/block/ItemBlockPool.java +++ b/src/main/java/vazkii/botania/common/item/block/ItemBlockPool.java @@ -2,15 +2,16 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Apr 27, 2014, 8:32:52 PM (GMT)] */ package vazkii.botania.common.item.block; import java.util.List; + import net.minecraft.block.Block; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; @@ -18,13 +19,15 @@ public class ItemBlockPool extends ItemBlockWithMetadataAndName { - public ItemBlockPool(Block par2Block) { - super(par2Block); - } + public ItemBlockPool(Block par2Block) { + super(par2Block); + } + + @Override + public void addInformation(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, List par3List, boolean par4) { + if(par1ItemStack.getItemDamage() == 1) + for(int i = 0; i < 2; i++) + par3List.add(StatCollector.translateToLocal("botaniamisc.creativePool" + i)); + } - @Override - public void addInformation(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, List par3List, boolean par4) { - if (par1ItemStack.getItemDamage() == 1) - for (int i = 0; i < 2; i++) par3List.add(StatCollector.translateToLocal("botaniamisc.creativePool" + i)); - } } diff --git a/src/main/java/vazkii/botania/common/item/block/ItemBlockSpecialFlower.java b/src/main/java/vazkii/botania/common/item/block/ItemBlockSpecialFlower.java index 79d557c17e..7c3074bfc5 100644 --- a/src/main/java/vazkii/botania/common/item/block/ItemBlockSpecialFlower.java +++ b/src/main/java/vazkii/botania/common/item/block/ItemBlockSpecialFlower.java @@ -2,15 +2,16 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jan 25, 2014, 2:04:15 PM (GMT)] */ package vazkii.botania.common.item.block; import java.util.List; + import net.minecraft.block.Block; import net.minecraft.entity.item.EntityItem; import net.minecraft.entity.player.EntityPlayer; @@ -35,105 +36,107 @@ public class ItemBlockSpecialFlower extends ItemBlockMod implements IRecipeKeyProvider { - public ItemBlockSpecialFlower(Block block1) { - super(block1); - } - - @Override - public IIcon getIconIndex(ItemStack stack) { - return BotaniaAPI.getSignatureForName(getType(stack)).getIconForStack(stack); - } - - @Override - public IIcon getIcon(ItemStack stack, int pass) { - return getIconIndex(stack); - } - - @Override - public boolean placeBlockAt( - ItemStack stack, - EntityPlayer player, - World world, - int x, - int y, - int z, - int side, - float hitX, - float hitY, - float hitZ, - int metadata) { - boolean placed = super.placeBlockAt(stack, player, world, x, y, z, side, hitX, hitY, hitZ, metadata); - if (placed) { - String type = getType(stack); - TileEntity te = world.getTileEntity(x, y, z); - if (te instanceof TileSpecialFlower) { - TileSpecialFlower tile = (TileSpecialFlower) te; - tile.setSubTile(type); - tile.onBlockAdded(world, x, y, z); - tile.onBlockPlacedBy(world, x, y, z, player, stack); - if (!world.isRemote) world.markBlockForUpdate(x, y, z); - } - } - - return placed; - } - - @Override - public String getUnlocalizedName(ItemStack stack) { - return BotaniaAPI.getSignatureForName(getType(stack)).getUnlocalizedNameForStack(stack); - } - - @Override - public String getUnlocalizedNameInefficiently(ItemStack par1ItemStack) { - return getUnlocalizedNameInefficiently_(par1ItemStack); - } - - @Override - public void addInformation(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, List par3List, boolean par4) { - String type = getType(par1ItemStack); - SubTileSignature sig = BotaniaAPI.getSignatureForName(type); - - sig.addTooltip(par1ItemStack, par2EntityPlayer, par3List); - - if (ConfigHandler.referencesEnabled) { - String refUnlocalized = sig.getUnlocalizedLoreTextForStack(par1ItemStack); - String refLocalized = StatCollector.translateToLocal(refUnlocalized); - if (!refLocalized.equals(refUnlocalized)) par3List.add(EnumChatFormatting.ITALIC + refLocalized); - } - - String mod = BotaniaAPI.subTileMods.get(type); - if (!mod.equals(LibMisc.MOD_ID)) par3List.add(EnumChatFormatting.ITALIC + "[" + mod + "]"); - } - - public static String getType(ItemStack stack) { - return ItemNBTHelper.detectNBT(stack) ? ItemNBTHelper.getString(stack, SubTileEntity.TAG_TYPE, "") : ""; - } - - public static ItemStack ofType(String type) { - return ofType(new ItemStack(ModBlocks.specialFlower), type); - } - - public static ItemStack ofType(ItemStack stack, String type) { - ItemNBTHelper.setString(stack, SubTileEntity.TAG_TYPE, type); - return stack; - } - - @Override - public String getKey(ItemStack stack) { - return "flower." + getType(stack); - } - - @Override - public Achievement getAchievementOnPickup(ItemStack stack, EntityPlayer player, EntityItem item) { - String type = getType(stack); - if (type.equals(LibBlockNames.SUBTILE_DAYBLOOM)) return ModAchievements.daybloomPickup; - else if (type.equals(LibBlockNames.SUBTILE_ENDOFLAME)) return ModAchievements.endoflamePickup; - else if (type.equals(LibBlockNames.SUBTILE_KEKIMURUS)) return ModAchievements.kekimurusPickup; - else if (type.equals(LibBlockNames.SUBTILE_HEISEI_DREAM)) return ModAchievements.heiseiDreamPickup; - else if (type.equals(LibBlockNames.SUBTILE_POLLIDISIAC)) return ModAchievements.pollidisiacPickup; - else if (type.equals(LibBlockNames.SUBTILE_BUBBELL)) return ModAchievements.bubbellPickup; - else if (type.equals(LibBlockNames.SUBTILE_DANDELIFEON)) return ModAchievements.dandelifeonPickup; - else if (type.equals("")) return ModAchievements.nullFlower; - return null; - } + public ItemBlockSpecialFlower(Block block1) { + super(block1); + } + + @Override + public IIcon getIconIndex(ItemStack stack) { + return BotaniaAPI.getSignatureForName(getType(stack)).getIconForStack(stack); + } + + @Override + public IIcon getIcon(ItemStack stack, int pass) { + return getIconIndex(stack); + } + + @Override + public boolean placeBlockAt(ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int side, float hitX, float hitY, float hitZ, int metadata) { + boolean placed = super.placeBlockAt(stack, player, world, x, y, z, side, hitX, hitY, hitZ, metadata); + if(placed) { + String type = getType(stack); + TileEntity te = world.getTileEntity(x, y, z); + if(te instanceof TileSpecialFlower) { + TileSpecialFlower tile = (TileSpecialFlower) te; + tile.setSubTile(type); + tile.onBlockAdded(world, x, y, z); + tile.onBlockPlacedBy(world, x, y, z, player, stack); + if(!world.isRemote) + world.markBlockForUpdate(x, y, z); + } + } + + return placed; + } + + @Override + public String getUnlocalizedName(ItemStack stack) { + return BotaniaAPI.getSignatureForName(getType(stack)).getUnlocalizedNameForStack(stack); + } + + @Override + public String getUnlocalizedNameInefficiently(ItemStack par1ItemStack) { + return getUnlocalizedNameInefficiently_(par1ItemStack); + } + + @Override + public void addInformation(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, List par3List, boolean par4) { + String type = getType(par1ItemStack); + SubTileSignature sig = BotaniaAPI.getSignatureForName(type); + + sig.addTooltip(par1ItemStack, par2EntityPlayer, par3List); + + if(ConfigHandler.referencesEnabled) { + String refUnlocalized = sig.getUnlocalizedLoreTextForStack(par1ItemStack); + String refLocalized = StatCollector.translateToLocal(refUnlocalized); + if(!refLocalized.equals(refUnlocalized)) + par3List.add(EnumChatFormatting.ITALIC + refLocalized); + } + + String mod = BotaniaAPI.subTileMods.get(type); + if(!mod.equals(LibMisc.MOD_ID)) + par3List.add(EnumChatFormatting.ITALIC + "[" + mod + "]"); + } + + public static String getType(ItemStack stack) { + return ItemNBTHelper.detectNBT(stack) ? ItemNBTHelper.getString(stack, SubTileEntity.TAG_TYPE, "") : ""; + } + + public static ItemStack ofType(String type) { + return ofType(new ItemStack(ModBlocks.specialFlower), type); + } + + public static ItemStack ofType(ItemStack stack, String type) { + ItemNBTHelper.setString(stack, SubTileEntity.TAG_TYPE, type); + return stack; + } + + @Override + public String getKey(ItemStack stack) { + return "flower." + getType(stack); + } + + @Override + public Achievement getAchievementOnPickup(ItemStack stack, EntityPlayer player, EntityItem item) { + String type = getType(stack); + if(type.equals(LibBlockNames.SUBTILE_DAYBLOOM)) + return ModAchievements.daybloomPickup; + else if(type.equals(LibBlockNames.SUBTILE_ENDOFLAME)) + return ModAchievements.endoflamePickup; + else if(type.equals(LibBlockNames.SUBTILE_KEKIMURUS)) + return ModAchievements.kekimurusPickup; + else if(type.equals(LibBlockNames.SUBTILE_HEISEI_DREAM)) + return ModAchievements.heiseiDreamPickup; + else if(type.equals(LibBlockNames.SUBTILE_POLLIDISIAC)) + return ModAchievements.pollidisiacPickup; + else if(type.equals(LibBlockNames.SUBTILE_BUBBELL)) + return ModAchievements.bubbellPickup; + else if(type.equals(LibBlockNames.SUBTILE_DANDELIFEON)) + return ModAchievements.dandelifeonPickup; + else if(type.equals("")) + return ModAchievements.nullFlower; + return null; + } + } + diff --git a/src/main/java/vazkii/botania/common/item/block/ItemBlockSpecialQuartz.java b/src/main/java/vazkii/botania/common/item/block/ItemBlockSpecialQuartz.java index 1832ef626c..7f104d0cf8 100644 --- a/src/main/java/vazkii/botania/common/item/block/ItemBlockSpecialQuartz.java +++ b/src/main/java/vazkii/botania/common/item/block/ItemBlockSpecialQuartz.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jun 11, 2014, 1:13:36 AM (GMT)] */ package vazkii.botania.common.item.block; @@ -17,14 +17,12 @@ public class ItemBlockSpecialQuartz extends ItemMultiTexture { - public ItemBlockSpecialQuartz(Block par1) { - super(par1, par1, new String[] {""}); - } + public ItemBlockSpecialQuartz(Block par1) { + super(par1, par1, new String[]{ "" }); + } - @Override - public String getUnlocalizedName(ItemStack par1ItemStack) { - return par1ItemStack.getItemDamage() >= 3 - ? "" - : ((BlockSpecialQuartz) field_150939_a).getNames()[par1ItemStack.getItemDamage()]; - } -} + @Override + public String getUnlocalizedName(ItemStack par1ItemStack) { + return par1ItemStack.getItemDamage() >= 3 ? "" : ((BlockSpecialQuartz) field_150939_a).getNames()[par1ItemStack.getItemDamage()]; + } +} \ No newline at end of file diff --git a/src/main/java/vazkii/botania/common/item/block/ItemBlockStorage.java b/src/main/java/vazkii/botania/common/item/block/ItemBlockStorage.java index 2d5ecaa339..1b196bd36e 100644 --- a/src/main/java/vazkii/botania/common/item/block/ItemBlockStorage.java +++ b/src/main/java/vazkii/botania/common/item/block/ItemBlockStorage.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jun 22, 2014, 1:04:55 AM (GMT)] */ package vazkii.botania.common.item.block; @@ -16,12 +16,12 @@ public class ItemBlockStorage extends ItemBlockWithMetadataAndName implements IElvenItem { - public ItemBlockStorage(Block block) { - super(block); - } + public ItemBlockStorage(Block block) { + super(block); + } - @Override - public boolean isElvenItem(ItemStack stack) { - return stack.getItemDamage() == 2; - } + @Override + public boolean isElvenItem(ItemStack stack) { + return stack.getItemDamage() == 2; + } } diff --git a/src/main/java/vazkii/botania/common/item/block/ItemBlockTinyPotato.java b/src/main/java/vazkii/botania/common/item/block/ItemBlockTinyPotato.java index 3cab84459e..0484dc766c 100644 --- a/src/main/java/vazkii/botania/common/item/block/ItemBlockTinyPotato.java +++ b/src/main/java/vazkii/botania/common/item/block/ItemBlockTinyPotato.java @@ -2,16 +2,17 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jan 27, 2015, 3:44:10 PM (GMT)] */ package vazkii.botania.common.item.block; import java.util.Arrays; import java.util.List; + import net.minecraft.block.Block; import net.minecraft.entity.Entity; import net.minecraft.entity.player.EntityPlayer; @@ -23,49 +24,46 @@ public class ItemBlockTinyPotato extends ItemBlockMod { - private static final List TYPOS = Arrays.asList(new String[] { - "vaskii", "vazki", "voskii", "vazkkii", "vazkki", "vazzki", "vaskki", "vozkii", "vazkil", "vaskil", "vazkill", - "vaskill", "vaski" - }); + private static final List TYPOS = Arrays.asList(new String[] { + "vaskii", "vazki", "voskii", "vazkkii", "vazkki", "vazzki", "vaskki", "vozkii", "vazkil", "vaskil", "vazkill", "vaskill", "vaski" + }); + + private static final String NOT_MY_NAME[] = { + "Six letter word just to get me along", + "It's a intricacy and I'm coding on my mod and I,", + "I keep fixin', and keepin' it together", + "People around gotta find something to play now", + "Holding back, every mod's the same", + "Don't wanna be a loser", + "Listen to me, oh no, I don't break anything at all", + "But with nothing to consider they forget my name", + "'ame, 'ame, 'ame", + "They call me Vaskii", + "They call me Vazki", + "They call me Voskii", + "They call me Vazkki", + "That's not my name", + "That's not my name", + "That's not my name", + "That's not my name" + }; - private static final String NOT_MY_NAME[] = { - "Six letter word just to get me along", - "It's a intricacy and I'm coding on my mod and I,", - "I keep fixin', and keepin' it together", - "People around gotta find something to play now", - "Holding back, every mod's the same", - "Don't wanna be a loser", - "Listen to me, oh no, I don't break anything at all", - "But with nothing to consider they forget my name", - "'ame, 'ame, 'ame", - "They call me Vaskii", - "They call me Vazki", - "They call me Voskii", - "They call me Vazkki", - "That's not my name", - "That's not my name", - "That's not my name", - "That's not my name" - }; + private static final String TAG_TICKS = "notMyNameTicks"; - private static final String TAG_TICKS = "notMyNameTicks"; + public ItemBlockTinyPotato(Block block) { + super(block); + } - public ItemBlockTinyPotato(Block block) { - super(block); - } + @Override + public void onUpdate(ItemStack stack, World world, Entity e, int t, boolean idunno) { + if(!world.isRemote && e instanceof EntityPlayer && e.ticksExisted % 30 == 0 && TYPOS.contains(stack.getDisplayName().toLowerCase())) { + EntityPlayer player = (EntityPlayer) e; + int ticks = ItemNBTHelper.getInt(stack, TAG_TICKS, 0); + if(ticks < NOT_MY_NAME.length) { + player.addChatMessage(new ChatComponentText(EnumChatFormatting.RED + NOT_MY_NAME[ticks])); + ItemNBTHelper.setInt(stack, TAG_TICKS, ticks + 1); + } + } + } - @Override - public void onUpdate(ItemStack stack, World world, Entity e, int t, boolean idunno) { - if (!world.isRemote - && e instanceof EntityPlayer - && e.ticksExisted % 30 == 0 - && TYPOS.contains(stack.getDisplayName().toLowerCase())) { - EntityPlayer player = (EntityPlayer) e; - int ticks = ItemNBTHelper.getInt(stack, TAG_TICKS, 0); - if (ticks < NOT_MY_NAME.length) { - player.addChatMessage(new ChatComponentText(EnumChatFormatting.RED + NOT_MY_NAME[ticks])); - ItemNBTHelper.setInt(stack, TAG_TICKS, ticks + 1); - } - } - } } diff --git a/src/main/java/vazkii/botania/common/item/block/ItemBlockWithMetadataAndName.java b/src/main/java/vazkii/botania/common/item/block/ItemBlockWithMetadataAndName.java index 85980cf7a9..e9bad65fdf 100644 --- a/src/main/java/vazkii/botania/common/item/block/ItemBlockWithMetadataAndName.java +++ b/src/main/java/vazkii/botania/common/item/block/ItemBlockWithMetadataAndName.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jan 16, 2014, 5:54:06 PM (GMT)] */ package vazkii.botania.common.item.block; @@ -21,35 +21,30 @@ import vazkii.botania.common.achievement.ICraftAchievement; import vazkii.botania.common.achievement.IPickupAchievement; -public class ItemBlockWithMetadataAndName extends ItemBlockWithMetadata - implements IPickupAchievement, ICraftAchievement { - - public ItemBlockWithMetadataAndName(Block par2Block) { - super(par2Block, par2Block); - } - - @Override - public String getUnlocalizedNameInefficiently(ItemStack par1ItemStack) { - return super.getUnlocalizedNameInefficiently(par1ItemStack) - .replaceAll("tile.", "tile." + LibResources.PREFIX_MOD); - } - - @Override - public String getUnlocalizedName(ItemStack par1ItemStack) { - return super.getUnlocalizedName(par1ItemStack) + par1ItemStack.getItemDamage(); - } - - @Override - public Achievement getAchievementOnCraft(ItemStack stack, EntityPlayer player, IInventory matrix) { - return field_150939_a instanceof ICraftAchievement - ? ((ICraftAchievement) field_150939_a).getAchievementOnCraft(stack, player, matrix) - : null; - } - - @Override - public Achievement getAchievementOnPickup(ItemStack stack, EntityPlayer player, EntityItem item) { - return field_150939_a instanceof IPickupAchievement - ? ((IPickupAchievement) field_150939_a).getAchievementOnPickup(stack, player, item) - : null; - } +public class ItemBlockWithMetadataAndName extends ItemBlockWithMetadata implements IPickupAchievement, ICraftAchievement { + + public ItemBlockWithMetadataAndName(Block par2Block) { + super(par2Block, par2Block); + } + + @Override + public String getUnlocalizedNameInefficiently(ItemStack par1ItemStack) { + return super.getUnlocalizedNameInefficiently(par1ItemStack).replaceAll("tile.", "tile." + LibResources.PREFIX_MOD); + } + + @Override + public String getUnlocalizedName(ItemStack par1ItemStack) { + return super.getUnlocalizedName(par1ItemStack) + par1ItemStack.getItemDamage(); + } + + @Override + public Achievement getAchievementOnCraft(ItemStack stack, EntityPlayer player, IInventory matrix) { + return field_150939_a instanceof ICraftAchievement ? ((ICraftAchievement) field_150939_a).getAchievementOnCraft(stack, player, matrix) : null; + } + + @Override + public Achievement getAchievementOnPickup(ItemStack stack, EntityPlayer player, EntityItem item) { + return field_150939_a instanceof IPickupAchievement ? ((IPickupAchievement) field_150939_a).getAchievementOnPickup(stack, player, item) : null; + } + } diff --git a/src/main/java/vazkii/botania/common/item/brew/ItemBrewBase.java b/src/main/java/vazkii/botania/common/item/brew/ItemBrewBase.java index edd2fa4cb8..8c565500e2 100644 --- a/src/main/java/vazkii/botania/common/item/brew/ItemBrewBase.java +++ b/src/main/java/vazkii/botania/common/item/brew/ItemBrewBase.java @@ -2,16 +2,17 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Nov 1, 2014, 5:45:58 PM (GMT)] */ package vazkii.botania.common.item.brew; import java.awt.Color; import java.util.List; + import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.entity.item.EntityItem; @@ -38,162 +39,159 @@ public abstract class ItemBrewBase extends ItemMod implements IBrewItem, IPickupAchievement { - private static final String TAG_BREW_KEY = "brewKey"; - private static final String TAG_SWIGS_LEFT = "swigsLeft"; - - String name; - String texName; - int swigs; - int drinkSpeed; - ItemStack baseItem; - - IIcon[] icons; - - public ItemBrewBase(String name, String texName, int swigs, int drinkSpeed, ItemStack baseItem) { - this.name = name; - this.texName = texName; - this.swigs = swigs; - this.drinkSpeed = drinkSpeed; - this.baseItem = baseItem; - setMaxStackSize(1); - setMaxDamage(swigs); - setUnlocalizedName(name); - setNoRepair(); - } - - @Override - public int getMaxItemUseDuration(ItemStack p_77626_1_) { - return drinkSpeed; - } - - @Override - public EnumAction getItemUseAction(ItemStack p_77661_1_) { - return EnumAction.drink; - } - - @Override - public ItemStack onItemRightClick(ItemStack p_77659_1_, World p_77659_2_, EntityPlayer p_77659_3_) { - p_77659_3_.setItemInUse(p_77659_1_, getMaxItemUseDuration(p_77659_1_)); - return p_77659_1_; - } - - @Override - public ItemStack onEaten(ItemStack stack, World world, EntityPlayer player) { - if (!world.isRemote) { - for (PotionEffect effect : getBrew(stack).getPotionEffects(stack)) { - PotionEffect newEffect = - new PotionEffect(effect.getPotionID(), effect.getDuration(), effect.getAmplifier(), true); - Potion potion = Potion.potionTypes[newEffect.getPotionID()]; - if (potion.isInstant()) potion.affectEntity(player, player, newEffect.getAmplifier(), 1F); - else player.addPotionEffect(newEffect); - } - - if (world.rand.nextBoolean()) world.playSoundAtEntity(player, "random.burp", 1F, 1F); - - int swigs = getSwigsLeft(stack); - if (!player.capabilities.isCreativeMode) { - if (swigs == 1) { - ItemStack copy = baseItem.copy(); - if (!player.inventory.addItemStackToInventory(copy)) return baseItem.copy(); - return null; - } - - setSwigsLeft(stack, swigs - 1); - } - } - - return stack; - } - - @Override - public void getSubItems(Item item, CreativeTabs tab, List list) { - for (String s : BotaniaAPI.brewMap.keySet()) { - ItemStack stack = new ItemStack(item); - setBrew(stack, s); - list.add(stack); - } - } - - @Override - public void registerIcons(IIconRegister par1IconRegister) { - itemIcon = IconHelper.forName(par1IconRegister, texName + "0"); - - icons = new IIcon[swigs]; - for (int i = 0; i < swigs; i++) icons[i] = IconHelper.forName(par1IconRegister, texName + "1_" + i); - } - - @Override - public boolean requiresMultipleRenderPasses() { - return true; - } - - @Override - public IIcon getIcon(ItemStack stack, int pass) { - return pass == 0 ? itemIcon : icons[Math.max(0, Math.min(icons.length - 1, swigs - getSwigsLeft(stack)))]; - } - - @Override - public int getColorFromItemStack(ItemStack stack, int pass) { - if (pass == 0) return 0xFFFFFF; - - Color color = new Color(getBrew(stack).getColor(stack)); - int add = (int) (Math.sin(ClientTickHandler.ticksInGame * 0.1) * 16); - - int r = Math.max(0, Math.min(255, color.getRed() + add)); - int g = Math.max(0, Math.min(255, color.getGreen() + add)); - int b = Math.max(0, Math.min(255, color.getBlue() + add)); - - return r << 16 | g << 8 | b; - } - - @Override - public String getItemStackDisplayName(ItemStack stack) { - return String.format( - StatCollector.translateToLocal(getUnlocalizedNameInefficiently(stack) + ".name"), - StatCollector.translateToLocal(getBrew(stack).getUnlocalizedName(stack)), - EnumChatFormatting.BOLD + "" + getSwigsLeft(stack) + EnumChatFormatting.RESET); - } - - @Override - public void addInformation(ItemStack stack, EntityPlayer player, List list, boolean adv) { - Brew brew = getBrew(stack); - for (PotionEffect effect : brew.getPotionEffects(stack)) { - Potion potion = Potion.potionTypes[effect.getPotionID()]; - EnumChatFormatting format = potion.isBadEffect() ? EnumChatFormatting.RED : EnumChatFormatting.GRAY; - list.add(format - + StatCollector.translateToLocal(effect.getEffectName()) - + (effect.getAmplifier() == 0 - ? "" - : " " + StatCollector.translateToLocal("botania.roman" + (effect.getAmplifier() + 1))) - + EnumChatFormatting.GRAY - + (potion.isInstant() ? "" : " (" + Potion.getDurationString(effect) + ")")); - } - } - - @Override - public Brew getBrew(ItemStack stack) { - String key = ItemNBTHelper.getString(stack, TAG_BREW_KEY, ""); - return BotaniaAPI.getBrewFromKey(key); - } - - public static void setBrew(ItemStack stack, Brew brew) { - setBrew(stack, (brew == null ? BotaniaAPI.fallbackBrew : brew).getKey()); - } - - public static void setBrew(ItemStack stack, String brew) { - ItemNBTHelper.setString(stack, TAG_BREW_KEY, brew); - } - - public int getSwigsLeft(ItemStack stack) { - return ItemNBTHelper.getInt(stack, TAG_SWIGS_LEFT, swigs); - } - - public void setSwigsLeft(ItemStack stack, int swigs) { - ItemNBTHelper.setInt(stack, TAG_SWIGS_LEFT, swigs); - } - - @Override - public Achievement getAchievementOnPickup(ItemStack stack, EntityPlayer player, EntityItem item) { - return ModAchievements.brewPickup; - } + private static final String TAG_BREW_KEY = "brewKey"; + private static final String TAG_SWIGS_LEFT = "swigsLeft"; + + String name; + String texName; + int swigs; + int drinkSpeed; + ItemStack baseItem; + + IIcon[] icons; + + public ItemBrewBase(String name, String texName, int swigs, int drinkSpeed, ItemStack baseItem) { + this.name = name; + this.texName = texName; + this.swigs = swigs; + this.drinkSpeed = drinkSpeed; + this.baseItem = baseItem; + setMaxStackSize(1); + setMaxDamage(swigs); + setUnlocalizedName(name); + setNoRepair(); + } + + @Override + public int getMaxItemUseDuration(ItemStack p_77626_1_) { + return drinkSpeed; + } + + @Override + public EnumAction getItemUseAction(ItemStack p_77661_1_) { + return EnumAction.drink; + } + + @Override + public ItemStack onItemRightClick(ItemStack p_77659_1_, World p_77659_2_, EntityPlayer p_77659_3_) { + p_77659_3_.setItemInUse(p_77659_1_, getMaxItemUseDuration(p_77659_1_)); + return p_77659_1_; + } + + @Override + public ItemStack onEaten(ItemStack stack, World world, EntityPlayer player) { + if(!world.isRemote) { + for(PotionEffect effect : getBrew(stack).getPotionEffects(stack)) { + PotionEffect newEffect = new PotionEffect(effect.getPotionID(), effect.getDuration(), effect.getAmplifier(), true); + Potion potion = Potion.potionTypes[newEffect.getPotionID()]; + if(potion.isInstant()) + potion.affectEntity(player, player, newEffect.getAmplifier(), 1F); + else player.addPotionEffect(newEffect); + } + + if(world.rand.nextBoolean()) + world.playSoundAtEntity(player, "random.burp", 1F, 1F); + + int swigs = getSwigsLeft(stack); + if(!player.capabilities.isCreativeMode) { + if(swigs == 1) { + ItemStack copy = baseItem.copy(); + if(!player.inventory.addItemStackToInventory(copy)) + return baseItem.copy(); + return null; + } + + + setSwigsLeft(stack, swigs - 1); + } + } + + return stack; + } + + @Override + public void getSubItems(Item item, CreativeTabs tab, List list) { + for(String s : BotaniaAPI.brewMap.keySet()) { + ItemStack stack = new ItemStack(item); + setBrew(stack, s); + list.add(stack); + } + } + + @Override + public void registerIcons(IIconRegister par1IconRegister) { + itemIcon = IconHelper.forName(par1IconRegister, texName + "0"); + + icons = new IIcon[swigs]; + for(int i = 0; i < swigs; i++) + icons[i] = IconHelper.forName(par1IconRegister, texName + "1_" + i); + } + + @Override + public boolean requiresMultipleRenderPasses() { + return true; + } + + @Override + public IIcon getIcon(ItemStack stack, int pass) { + return pass == 0 ? itemIcon : icons[Math.max(0, Math.min(icons.length - 1, swigs - getSwigsLeft(stack)))]; + } + + @Override + public int getColorFromItemStack(ItemStack stack, int pass) { + if(pass == 0) + return 0xFFFFFF; + + Color color = new Color(getBrew(stack).getColor(stack)); + int add = (int) (Math.sin(ClientTickHandler.ticksInGame * 0.1) * 16); + + int r = Math.max(0, Math.min(255, color.getRed() + add)); + int g = Math.max(0, Math.min(255, color.getGreen() + add)); + int b = Math.max(0, Math.min(255, color.getBlue() + add)); + + return r << 16 | g << 8 | b; + } + + @Override + public String getItemStackDisplayName(ItemStack stack) { + return String.format(StatCollector.translateToLocal(getUnlocalizedNameInefficiently(stack) + ".name"), StatCollector.translateToLocal(getBrew(stack).getUnlocalizedName(stack)), EnumChatFormatting.BOLD + "" + getSwigsLeft(stack) + EnumChatFormatting.RESET); + } + + @Override + public void addInformation(ItemStack stack, EntityPlayer player, List list, boolean adv) { + Brew brew = getBrew(stack); + for(PotionEffect effect : brew.getPotionEffects(stack)) { + Potion potion = Potion.potionTypes[effect.getPotionID()]; + EnumChatFormatting format = potion.isBadEffect() ? EnumChatFormatting.RED : EnumChatFormatting.GRAY; + list.add(format + StatCollector.translateToLocal(effect.getEffectName()) + (effect.getAmplifier() == 0 ? "" : " " + StatCollector.translateToLocal("botania.roman" + (effect.getAmplifier() + 1))) + EnumChatFormatting.GRAY + (potion.isInstant() ? "" : " (" + Potion.getDurationString(effect) + ")")); + } + } + + @Override + public Brew getBrew(ItemStack stack) { + String key = ItemNBTHelper.getString(stack, TAG_BREW_KEY, ""); + return BotaniaAPI.getBrewFromKey(key); + } + + public static void setBrew(ItemStack stack, Brew brew) { + setBrew(stack, (brew == null ? BotaniaAPI.fallbackBrew : brew).getKey()); + } + + public static void setBrew(ItemStack stack, String brew) { + ItemNBTHelper.setString(stack, TAG_BREW_KEY, brew); + } + + public int getSwigsLeft(ItemStack stack) { + return ItemNBTHelper.getInt(stack, TAG_SWIGS_LEFT, swigs); + } + + public void setSwigsLeft(ItemStack stack, int swigs) { + ItemNBTHelper.setInt(stack, TAG_SWIGS_LEFT, swigs); + } + + @Override + public Achievement getAchievementOnPickup(ItemStack stack, EntityPlayer player, EntityItem item) { + return ModAchievements.brewPickup; + } + } diff --git a/src/main/java/vazkii/botania/common/item/brew/ItemBrewFlask.java b/src/main/java/vazkii/botania/common/item/brew/ItemBrewFlask.java index 3062d07416..5bded703a0 100644 --- a/src/main/java/vazkii/botania/common/item/brew/ItemBrewFlask.java +++ b/src/main/java/vazkii/botania/common/item/brew/ItemBrewFlask.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Nov 1, 2014, 7:34:30 PM (GMT)] */ package vazkii.botania.common.item.brew; @@ -16,7 +16,8 @@ public class ItemBrewFlask extends ItemBrewBase { - public ItemBrewFlask() { - super(LibItemNames.BREW_FLASK, LibItemNames.FLASK, 6, 24, new ItemStack(ModItems.vial, 1, 1)); - } + public ItemBrewFlask() { + super(LibItemNames.BREW_FLASK, LibItemNames.FLASK, 6, 24, new ItemStack(ModItems.vial, 1, 1)); + } + } diff --git a/src/main/java/vazkii/botania/common/item/brew/ItemBrewVial.java b/src/main/java/vazkii/botania/common/item/brew/ItemBrewVial.java index 1eb8fbb31d..6ebfeeec37 100644 --- a/src/main/java/vazkii/botania/common/item/brew/ItemBrewVial.java +++ b/src/main/java/vazkii/botania/common/item/brew/ItemBrewVial.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Nov 1, 2014, 7:33:24 PM (GMT)] */ package vazkii.botania.common.item.brew; @@ -16,7 +16,8 @@ public class ItemBrewVial extends ItemBrewBase { - public ItemBrewVial() { - super(LibItemNames.BREW_VIAL, LibItemNames.VIAL, 4, 32, new ItemStack(ModItems.vial)); - } + public ItemBrewVial() { + super(LibItemNames.BREW_VIAL, LibItemNames.VIAL, 4, 32, new ItemStack(ModItems.vial)); + } + } diff --git a/src/main/java/vazkii/botania/common/item/brew/ItemIncenseStick.java b/src/main/java/vazkii/botania/common/item/brew/ItemIncenseStick.java index 4fd2382f38..42c1eafd35 100644 --- a/src/main/java/vazkii/botania/common/item/brew/ItemIncenseStick.java +++ b/src/main/java/vazkii/botania/common/item/brew/ItemIncenseStick.java @@ -2,16 +2,17 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [May 15, 2015, 3:13:43 PM (GMT)] */ package vazkii.botania.common.item.brew; import java.awt.Color; import java.util.List; + import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.entity.player.EntityPlayer; @@ -34,122 +35,109 @@ public class ItemIncenseStick extends ItemMod implements IBrewItem, IBrewContainer { - private static final String TAG_BREW_KEY = "brewKey"; - public static final int TIME_MULTIPLIER = 60; - - IIcon[] icons; - - public ItemIncenseStick() { - setUnlocalizedName(LibItemNames.INCENSE_STICK); - setMaxStackSize(1); - } - - @Override - public void getSubItems(Item item, CreativeTabs tab, List list) { - super.getSubItems(item, tab, list); - for (String s : BotaniaAPI.brewMap.keySet()) { - ItemStack brewStack = getItemForBrew(BotaniaAPI.brewMap.get(s), new ItemStack(this)); - if (brewStack != null) list.add(brewStack); - } - } - - @Override - public void registerIcons(IIconRegister par1IconRegister) { - icons = new IIcon[2]; - for (int i = 0; i < icons.length; i++) icons[i] = IconHelper.forItem(par1IconRegister, this, i); - } - - @Override - public boolean requiresMultipleRenderPasses() { - return true; - } - - @Override - public IIcon getIcon(ItemStack stack, int pass) { - return icons[pass]; - } - - @Override - public int getColorFromItemStack(ItemStack stack, int pass) { - if (pass == 0) return 0xFFFFFF; - - Brew brew = getBrew(stack); - if (brew == BotaniaAPI.fallbackBrew) return 0x989898; - - Color color = new Color(brew.getColor(stack)); - int add = (int) (Math.sin(ClientTickHandler.ticksInGame * 0.2) * 24); - - int r = Math.max(0, Math.min(255, color.getRed() + add)); - int g = Math.max(0, Math.min(255, color.getGreen() + add)); - int b = Math.max(0, Math.min(255, color.getBlue() + add)); - - return r << 16 | g << 8 | b; - } - - @Override - public void addInformation(ItemStack stack, EntityPlayer player, List list, boolean adv) { - Brew brew = getBrew(stack); - if (brew == BotaniaAPI.fallbackBrew) { - addStringToTooltip( - EnumChatFormatting.LIGHT_PURPLE + StatCollector.translateToLocal("botaniamisc.notInfused"), list); - return; - } - - addStringToTooltip( - EnumChatFormatting.LIGHT_PURPLE - + String.format( - StatCollector.translateToLocal("botaniamisc.brewOf"), - StatCollector.translateToLocal(brew.getUnlocalizedName(stack))), - list); - for (PotionEffect effect : brew.getPotionEffects(stack)) { - Potion potion = Potion.potionTypes[effect.getPotionID()]; - EnumChatFormatting format = potion.isBadEffect() ? EnumChatFormatting.RED : EnumChatFormatting.GRAY; - PotionEffect longEffect = new PotionEffect( - effect.getPotionID(), effect.getDuration() * TIME_MULTIPLIER, effect.getAmplifier(), false); - addStringToTooltip( - " " + format + StatCollector.translateToLocal(effect.getEffectName()) - + (effect.getAmplifier() == 0 - ? "" - : " " - + StatCollector.translateToLocal( - "botania.roman" + (effect.getAmplifier() + 1))) - + EnumChatFormatting.GRAY - + (potion.isInstant() ? "" : " (" + Potion.getDurationString(longEffect) + ")"), - list); - } - } - - void addStringToTooltip(String s, List tooltip) { - tooltip.add(s.replaceAll("&", "\u00a7")); - } - - @Override - public Brew getBrew(ItemStack stack) { - String key = ItemNBTHelper.getString(stack, TAG_BREW_KEY, ""); - return BotaniaAPI.getBrewFromKey(key); - } - - public static void setBrew(ItemStack stack, Brew brew) { - setBrew(stack, brew.getKey()); - } - - public static void setBrew(ItemStack stack, String brew) { - ItemNBTHelper.setString(stack, TAG_BREW_KEY, brew); - } - - @Override - public ItemStack getItemForBrew(Brew brew, ItemStack stack) { - if (!brew.canInfuseIncense() - || brew.getPotionEffects(stack).size() != 1 - || Potion.potionTypes[brew.getPotionEffects(stack).get(0).getPotionID()].isInstant()) return null; - - ItemStack brewStack = new ItemStack(this); - setBrew(brewStack, brew); - return brewStack; - } - - @Override - public int getManaCost(Brew brew, ItemStack stack) { - return brew.getManaCost() * 10; - } + private static final String TAG_BREW_KEY = "brewKey"; + public static final int TIME_MULTIPLIER = 60; + + IIcon[] icons; + + public ItemIncenseStick() { + setUnlocalizedName(LibItemNames.INCENSE_STICK); + setMaxStackSize(1); + } + + @Override + public void getSubItems(Item item, CreativeTabs tab, List list) { + super.getSubItems(item, tab, list); + for(String s : BotaniaAPI.brewMap.keySet()) { + ItemStack brewStack = getItemForBrew(BotaniaAPI.brewMap.get(s), new ItemStack(this)); + if(brewStack != null) + list.add(brewStack); + } + } + + @Override + public void registerIcons(IIconRegister par1IconRegister) { + icons = new IIcon[2]; + for(int i = 0; i < icons.length; i++) + icons[i] = IconHelper.forItem(par1IconRegister, this, i); + } + + @Override + public boolean requiresMultipleRenderPasses() { + return true; + } + + @Override + public IIcon getIcon(ItemStack stack, int pass) { + return icons[pass]; + } + + @Override + public int getColorFromItemStack(ItemStack stack, int pass) { + if(pass == 0) + return 0xFFFFFF; + + Brew brew = getBrew(stack); + if(brew == BotaniaAPI.fallbackBrew) + return 0x989898; + + Color color = new Color(brew.getColor(stack)); + int add = (int) (Math.sin(ClientTickHandler.ticksInGame * 0.2) * 24); + + int r = Math.max(0, Math.min(255, color.getRed() + add)); + int g = Math.max(0, Math.min(255, color.getGreen() + add)); + int b = Math.max(0, Math.min(255, color.getBlue() + add)); + + return r << 16 | g << 8 | b; + } + + @Override + public void addInformation(ItemStack stack, EntityPlayer player, List list, boolean adv) { + Brew brew = getBrew(stack); + if(brew == BotaniaAPI.fallbackBrew) { + addStringToTooltip(EnumChatFormatting.LIGHT_PURPLE + StatCollector.translateToLocal("botaniamisc.notInfused"), list); + return; + } + + addStringToTooltip(EnumChatFormatting.LIGHT_PURPLE + String.format(StatCollector.translateToLocal("botaniamisc.brewOf"), StatCollector.translateToLocal(brew.getUnlocalizedName(stack))), list); + for(PotionEffect effect : brew.getPotionEffects(stack)) { + Potion potion = Potion.potionTypes[effect.getPotionID()]; + EnumChatFormatting format = potion.isBadEffect() ? EnumChatFormatting.RED : EnumChatFormatting.GRAY; + PotionEffect longEffect = new PotionEffect(effect.getPotionID(), effect.getDuration() * TIME_MULTIPLIER, effect.getAmplifier(), false); + addStringToTooltip(" " + format + StatCollector.translateToLocal(effect.getEffectName()) + (effect.getAmplifier() == 0 ? "" : " " + StatCollector.translateToLocal("botania.roman" + (effect.getAmplifier() + 1))) + EnumChatFormatting.GRAY + (potion.isInstant() ? "" : " (" + Potion.getDurationString(longEffect) + ")"), list); + } + } + + void addStringToTooltip(String s, List tooltip) { + tooltip.add(s.replaceAll("&", "\u00a7")); + } + + @Override + public Brew getBrew(ItemStack stack) { + String key = ItemNBTHelper.getString(stack, TAG_BREW_KEY, ""); + return BotaniaAPI.getBrewFromKey(key); + } + + public static void setBrew(ItemStack stack, Brew brew) { + setBrew(stack, brew.getKey()); + } + + public static void setBrew(ItemStack stack, String brew) { + ItemNBTHelper.setString(stack, TAG_BREW_KEY, brew); + } + + @Override + public ItemStack getItemForBrew(Brew brew, ItemStack stack) { + if(!brew.canInfuseIncense() || brew.getPotionEffects(stack).size() != 1 || Potion.potionTypes[brew.getPotionEffects(stack).get(0).getPotionID()].isInstant()) + return null; + + ItemStack brewStack = new ItemStack(this); + setBrew(brewStack, brew); + return brewStack; + } + + @Override + public int getManaCost(Brew brew, ItemStack stack) { + return brew.getManaCost() * 10; + } } diff --git a/src/main/java/vazkii/botania/common/item/brew/ItemVial.java b/src/main/java/vazkii/botania/common/item/brew/ItemVial.java index 3f9ae09f3b..81e3aed7a4 100644 --- a/src/main/java/vazkii/botania/common/item/brew/ItemVial.java +++ b/src/main/java/vazkii/botania/common/item/brew/ItemVial.java @@ -2,15 +2,16 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Nov 1, 2014, 5:45:50 PM (GMT)] */ package vazkii.botania.common.item.brew; import java.util.List; + import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.item.Item; @@ -25,47 +26,49 @@ public class ItemVial extends ItemMod implements IBrewContainer { - public static IIcon flaskIcon, vialIcon; + public static IIcon flaskIcon, vialIcon; + + public ItemVial() { + this(LibItemNames.VIAL); + } - public ItemVial() { - this(LibItemNames.VIAL); - } + public ItemVial(String name) { + setHasSubtypes(true); + setUnlocalizedName(name); + } - public ItemVial(String name) { - setHasSubtypes(true); - setUnlocalizedName(name); - } + @Override + public void registerIcons(IIconRegister par1IconRegister) { + vialIcon = IconHelper.forName(par1IconRegister, LibItemNames.VIAL + "0"); + flaskIcon = IconHelper.forName(par1IconRegister, LibItemNames.FLASK + "0"); + } - @Override - public void registerIcons(IIconRegister par1IconRegister) { - vialIcon = IconHelper.forName(par1IconRegister, LibItemNames.VIAL + "0"); - flaskIcon = IconHelper.forName(par1IconRegister, LibItemNames.FLASK + "0"); - } + @Override + public IIcon getIconFromDamage(int i) { + return i == 0 ? vialIcon : flaskIcon; + } - @Override - public IIcon getIconFromDamage(int i) { - return i == 0 ? vialIcon : flaskIcon; - } + @Override + public void getSubItems(Item item, CreativeTabs tab, List list) { + for(int i = 0; i < 2; i++) + list.add(new ItemStack(item, 1, i)); + } - @Override - public void getSubItems(Item item, CreativeTabs tab, List list) { - for (int i = 0; i < 2; i++) list.add(new ItemStack(item, 1, i)); - } + @Override + public String getUnlocalizedName(ItemStack par1ItemStack) { + return super.getUnlocalizedName(par1ItemStack) + par1ItemStack.getItemDamage(); + } - @Override - public String getUnlocalizedName(ItemStack par1ItemStack) { - return super.getUnlocalizedName(par1ItemStack) + par1ItemStack.getItemDamage(); - } + @Override + public ItemStack getItemForBrew(Brew brew, ItemStack stack) { + ItemStack brewStack = new ItemStack(stack.getItemDamage() == 1 ? ModItems.brewFlask : ModItems.brewVial); + ItemBrewBase.setBrew(brewStack, brew); + return brewStack; + } - @Override - public ItemStack getItemForBrew(Brew brew, ItemStack stack) { - ItemStack brewStack = new ItemStack(stack.getItemDamage() == 1 ? ModItems.brewFlask : ModItems.brewVial); - ItemBrewBase.setBrew(brewStack, brew); - return brewStack; - } + @Override + public int getManaCost(Brew brew, ItemStack stack) { + return brew.getManaCost() * (stack.getItemDamage() + 1); + } - @Override - public int getManaCost(Brew brew, ItemStack stack) { - return brew.getManaCost() * (stack.getItemDamage() + 1); - } } diff --git a/src/main/java/vazkii/botania/common/item/equipment/armor/elementium/ItemElementiumArmor.java b/src/main/java/vazkii/botania/common/item/equipment/armor/elementium/ItemElementiumArmor.java index ece410df6b..96980869cc 100644 --- a/src/main/java/vazkii/botania/common/item/equipment/armor/elementium/ItemElementiumArmor.java +++ b/src/main/java/vazkii/botania/common/item/equipment/armor/elementium/ItemElementiumArmor.java @@ -1,8 +1,7 @@ package vazkii.botania.common.item.equipment.armor.elementium; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; import java.util.List; + import net.minecraft.client.model.ModelBiped; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; @@ -14,77 +13,72 @@ import vazkii.botania.common.core.handler.ConfigHandler; import vazkii.botania.common.item.ModItems; import vazkii.botania.common.item.equipment.armor.manasteel.ItemManasteelArmor; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; public abstract class ItemElementiumArmor extends ItemManasteelArmor implements IPixieSpawner { - public ItemElementiumArmor(int type, String name) { - super(type, name, BotaniaAPI.elementiumArmorMaterial); - } - - @Override - @SideOnly(Side.CLIENT) - public ModelBiped provideArmorModelForSlot(ItemStack stack, int slot) { - models[slot] = new ModelArmorElementium(slot); - return models[slot]; - } - - @Override - public String getArmorTextureAfterInk(ItemStack stack, int slot) { - return ConfigHandler.enableArmorModels - ? LibResources.MODEL_ELEMENTIUM_NEW - : slot == 2 ? LibResources.MODEL_ELEMENTIUM_1 : LibResources.MODEL_ELEMENTIUM_0; - } - - @Override - public boolean getIsRepairable(ItemStack par1ItemStack, ItemStack par2ItemStack) { - return par2ItemStack.getItem() == ModItems.manaResource && par2ItemStack.getItemDamage() == 7 - ? true - : super.getIsRepairable(par1ItemStack, par2ItemStack); - } - - static ItemStack[] armorset; - - @Override - public ItemStack[] getArmorSetStacks() { - if (armorset == null) - armorset = new ItemStack[] { - new ItemStack(ModItems.elementiumHelm), - new ItemStack(ModItems.elementiumChest), - new ItemStack(ModItems.elementiumLegs), - new ItemStack(ModItems.elementiumBoots) - }; - - return armorset; - } - - @Override - public boolean hasArmorSetItem(EntityPlayer player, int i) { - ItemStack stack = player.inventory.armorInventory[3 - i]; - if (stack == null) return false; - - switch (i) { - case 0: - return stack.getItem() == ModItems.elementiumHelm - || stack.getItem() == ModItems.elementiumHelmRevealing; - case 1: - return stack.getItem() == ModItems.elementiumChest; - case 2: - return stack.getItem() == ModItems.elementiumLegs; - case 3: - return stack.getItem() == ModItems.elementiumBoots; - } - - return false; - } - - @Override - public String getArmorSetName() { - return StatCollector.translateToLocal("botania.armorset.elementium.name"); - } - - @Override - public void addArmorSetDescription(ItemStack stack, List list) { - super.addArmorSetDescription(stack, list); - addStringToTooltip(StatCollector.translateToLocal("botania.armorset.elementium.desc"), list); - } + public ItemElementiumArmor(int type, String name) { + super(type, name, BotaniaAPI.elementiumArmorMaterial); + } + + @Override + @SideOnly(Side.CLIENT) + public ModelBiped provideArmorModelForSlot(ItemStack stack, int slot) { + models[slot] = new ModelArmorElementium(slot); + return models[slot]; + } + + @Override + public String getArmorTextureAfterInk(ItemStack stack, int slot) { + return ConfigHandler.enableArmorModels ? LibResources.MODEL_ELEMENTIUM_NEW : slot == 2 ? LibResources.MODEL_ELEMENTIUM_1 : LibResources.MODEL_ELEMENTIUM_0; + } + + @Override + public boolean getIsRepairable(ItemStack par1ItemStack, ItemStack par2ItemStack) { + return par2ItemStack.getItem() == ModItems.manaResource && par2ItemStack.getItemDamage() == 7 ? true : super.getIsRepairable(par1ItemStack, par2ItemStack); + } + + static ItemStack[] armorset; + + @Override + public ItemStack[] getArmorSetStacks() { + if(armorset == null) + armorset = new ItemStack[] { + new ItemStack(ModItems.elementiumHelm), + new ItemStack(ModItems.elementiumChest), + new ItemStack(ModItems.elementiumLegs), + new ItemStack(ModItems.elementiumBoots) + }; + + return armorset; + } + + @Override + public boolean hasArmorSetItem(EntityPlayer player, int i) { + ItemStack stack = player.inventory.armorInventory[3 - i]; + if(stack == null) + return false; + + switch(i) { + case 0: return stack.getItem() == ModItems.elementiumHelm || stack.getItem() == ModItems.elementiumHelmRevealing; + case 1: return stack.getItem() == ModItems.elementiumChest; + case 2: return stack.getItem() == ModItems.elementiumLegs; + case 3: return stack.getItem() == ModItems.elementiumBoots; + } + + return false; + } + + @Override + public String getArmorSetName() { + return StatCollector.translateToLocal("botania.armorset.elementium.name"); + } + + @Override + public void addArmorSetDescription(ItemStack stack, List list) { + super.addArmorSetDescription(stack, list); + addStringToTooltip(StatCollector.translateToLocal("botania.armorset.elementium.desc"), list); + } + } diff --git a/src/main/java/vazkii/botania/common/item/equipment/armor/elementium/ItemElementiumBoots.java b/src/main/java/vazkii/botania/common/item/equipment/armor/elementium/ItemElementiumBoots.java index 073d2ecb92..d37f6b7edd 100644 --- a/src/main/java/vazkii/botania/common/item/equipment/armor/elementium/ItemElementiumBoots.java +++ b/src/main/java/vazkii/botania/common/item/equipment/armor/elementium/ItemElementiumBoots.java @@ -5,12 +5,13 @@ public class ItemElementiumBoots extends ItemElementiumArmor { - public ItemElementiumBoots() { - super(3, LibItemNames.ELEMENTIUM_BOOTS); - } + public ItemElementiumBoots() { + super(3, LibItemNames.ELEMENTIUM_BOOTS); + } + + @Override + public float getPixieChance(ItemStack stack) { + return 0.09F; + } - @Override - public float getPixieChance(ItemStack stack) { - return 0.09F; - } } diff --git a/src/main/java/vazkii/botania/common/item/equipment/armor/elementium/ItemElementiumChest.java b/src/main/java/vazkii/botania/common/item/equipment/armor/elementium/ItemElementiumChest.java index ccd426fe61..2994a3ca2c 100644 --- a/src/main/java/vazkii/botania/common/item/equipment/armor/elementium/ItemElementiumChest.java +++ b/src/main/java/vazkii/botania/common/item/equipment/armor/elementium/ItemElementiumChest.java @@ -5,12 +5,13 @@ public class ItemElementiumChest extends ItemElementiumArmor { - public ItemElementiumChest() { - super(1, LibItemNames.ELEMENTIUM_CHEST); - } + public ItemElementiumChest() { + super(1, LibItemNames.ELEMENTIUM_CHEST); + } + + @Override + public float getPixieChance(ItemStack stack) { + return 0.17F; + } - @Override - public float getPixieChance(ItemStack stack) { - return 0.17F; - } } diff --git a/src/main/java/vazkii/botania/common/item/equipment/armor/elementium/ItemElementiumHelm.java b/src/main/java/vazkii/botania/common/item/equipment/armor/elementium/ItemElementiumHelm.java index 88e10db0f6..ef357ddb8c 100644 --- a/src/main/java/vazkii/botania/common/item/equipment/armor/elementium/ItemElementiumHelm.java +++ b/src/main/java/vazkii/botania/common/item/equipment/armor/elementium/ItemElementiumHelm.java @@ -7,21 +7,22 @@ public class ItemElementiumHelm extends ItemElementiumArmor implements IManaDiscountArmor { - public ItemElementiumHelm() { - this(LibItemNames.ELEMENTIUM_HELM); - } + public ItemElementiumHelm() { + this(LibItemNames.ELEMENTIUM_HELM); + } - public ItemElementiumHelm(String name) { - super(0, name); - } + public ItemElementiumHelm(String name) { + super(0, name); + } - @Override - public float getPixieChance(ItemStack stack) { - return 0.11F; - } + @Override + public float getPixieChance(ItemStack stack) { + return 0.11F; + } + + @Override + public float getDiscount(ItemStack stack, int slot, EntityPlayer player) { + return hasArmorSet(player) ? 0.1F : 0F; + } - @Override - public float getDiscount(ItemStack stack, int slot, EntityPlayer player) { - return hasArmorSet(player) ? 0.1F : 0F; - } } diff --git a/src/main/java/vazkii/botania/common/item/equipment/armor/elementium/ItemElementiumLegs.java b/src/main/java/vazkii/botania/common/item/equipment/armor/elementium/ItemElementiumLegs.java index 0513b5cff5..d221f4e7f5 100644 --- a/src/main/java/vazkii/botania/common/item/equipment/armor/elementium/ItemElementiumLegs.java +++ b/src/main/java/vazkii/botania/common/item/equipment/armor/elementium/ItemElementiumLegs.java @@ -5,12 +5,13 @@ public class ItemElementiumLegs extends ItemElementiumArmor { - public ItemElementiumLegs() { - super(2, LibItemNames.ELEMENTIUM_LEGS); - } + public ItemElementiumLegs() { + super(2, LibItemNames.ELEMENTIUM_LEGS); + } + + @Override + public float getPixieChance(ItemStack stack) { + return 0.15F; + } - @Override - public float getPixieChance(ItemStack stack) { - return 0.15F; - } } diff --git a/src/main/java/vazkii/botania/common/item/equipment/armor/manasteel/ItemManasteelArmor.java b/src/main/java/vazkii/botania/common/item/equipment/armor/manasteel/ItemManasteelArmor.java index 26b13021d8..b73a63f8e3 100644 --- a/src/main/java/vazkii/botania/common/item/equipment/armor/manasteel/ItemManasteelArmor.java +++ b/src/main/java/vazkii/botania/common/item/equipment/armor/manasteel/ItemManasteelArmor.java @@ -2,19 +2,16 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Apr 13, 2014, 6:38:21 PM (GMT)] */ package vazkii.botania.common.item.equipment.armor.manasteel; -import cpw.mods.fml.common.Optional; -import cpw.mods.fml.common.registry.GameRegistry; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; import java.util.List; + import net.minecraft.client.gui.GuiScreen; import net.minecraft.client.model.ModelBiped; import net.minecraft.client.renderer.texture.IIconRegister; @@ -42,219 +39,214 @@ import vazkii.botania.common.core.helper.ItemNBTHelper; import vazkii.botania.common.item.ModItems; import vazkii.botania.common.item.equipment.tool.ToolCommons; +import cpw.mods.fml.common.Optional; +import cpw.mods.fml.common.registry.GameRegistry; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; @Optional.Interface(modid = "Thaumcraft", iface = "thaumcraft.api.IRunicArmor") -public class ItemManasteelArmor extends ItemArmor - implements ISpecialArmor, IManaUsingItem, IPhantomInkable, IRunicArmor { - - private static final int MANA_PER_DAMAGE = 70; - - private static final String TAG_PHANTOM_INK = "phantomInk"; - - protected ModelBiped[] models = null; - public int type; - - public ItemManasteelArmor(int type, String name) { - this(type, name, BotaniaAPI.manasteelArmorMaterial); - } - - public ItemManasteelArmor(int type, String name, ArmorMaterial mat) { - super(mat, 0, type); - this.type = type; - setCreativeTab(BotaniaCreativeTab.INSTANCE); - setUnlocalizedName(name); - } - - @Override - public Item setUnlocalizedName(String par1Str) { - GameRegistry.registerItem(this, par1Str); - return super.setUnlocalizedName(par1Str); - } - - @Override - public String getUnlocalizedNameInefficiently(ItemStack par1ItemStack) { - return super.getUnlocalizedNameInefficiently(par1ItemStack) - .replaceAll("item.", "item." + LibResources.PREFIX_MOD); - } - - @Override - @SideOnly(Side.CLIENT) - public void registerIcons(IIconRegister par1IconRegister) { - itemIcon = IconHelper.forItem(par1IconRegister, this); - } - - @Override - public ArmorProperties getProperties( - EntityLivingBase player, ItemStack armor, DamageSource source, double damage, int slot) { - if (source.isUnblockable()) return new ArmorProperties(0, 0, 0); - return new ArmorProperties(0, damageReduceAmount / 25D, armor.getMaxDamage() + 1 - armor.getItemDamage()); - } - - @Override - public int getArmorDisplay(EntityPlayer player, ItemStack armor, int slot) { - return damageReduceAmount; - } - - @Override - public void onUpdate(ItemStack stack, World world, Entity player, int par4, boolean par5) { - if (player instanceof EntityPlayer) onArmorTick(world, (EntityPlayer) player, stack); - } - - @Override - public void onArmorTick(World world, EntityPlayer player, ItemStack stack) { - if (!world.isRemote - && stack.getItemDamage() > 0 - && ManaItemHandler.requestManaExact(stack, player, MANA_PER_DAMAGE * 2, true)) - stack.setItemDamage(stack.getItemDamage() - 1); - } - - @Override - public void damageArmor(EntityLivingBase entity, ItemStack stack, DamageSource source, int damage, int slot) { - ToolCommons.damageItem(stack, damage, entity, MANA_PER_DAMAGE); - } - - @Override - public final String getArmorTexture(ItemStack stack, Entity entity, int slot, String type) { - return hasPhantomInk(stack) ? LibResources.MODEL_INVISIBLE_ARMOR : getArmorTextureAfterInk(stack, slot); - } - - public String getArmorTextureAfterInk(ItemStack stack, int slot) { - return ConfigHandler.enableArmorModels - ? LibResources.MODEL_MANASTEEL_NEW - : slot == 2 ? LibResources.MODEL_MANASTEEL_1 : LibResources.MODEL_MANASTEEL_0; - } - - @Override - @SideOnly(Side.CLIENT) - public ModelBiped getArmorModel(EntityLivingBase entityLiving, ItemStack itemStack, int armorSlot) { - if (ConfigHandler.enableArmorModels) { - ModelBiped model = getArmorModelForSlot(entityLiving, itemStack, armorSlot); - if (model == null) model = provideArmorModelForSlot(itemStack, armorSlot); - - if (model != null) return model; - } - - return super.getArmorModel(entityLiving, itemStack, armorSlot); - } - - @SideOnly(Side.CLIENT) - public ModelBiped getArmorModelForSlot(EntityLivingBase entity, ItemStack stack, int slot) { - if (models == null) models = new ModelBiped[4]; - - return models[slot]; - } - - @SideOnly(Side.CLIENT) - public ModelBiped provideArmorModelForSlot(ItemStack stack, int slot) { - models[slot] = new ModelArmorManasteel(slot); - return models[slot]; - } - - @Override - public boolean getIsRepairable(ItemStack par1ItemStack, ItemStack par2ItemStack) { - return par2ItemStack.getItem() == ModItems.manaResource && par2ItemStack.getItemDamage() == 0 - ? true - : super.getIsRepairable(par1ItemStack, par2ItemStack); - } - - @Override - public boolean usesMana(ItemStack stack) { - return true; - } - - @Override - public void addInformation(ItemStack stack, EntityPlayer player, List list, boolean adv) { - if (GuiScreen.isShiftKeyDown()) addInformationAfterShift(stack, player, list, adv); - else addStringToTooltip(StatCollector.translateToLocal("botaniamisc.shiftinfo"), list); - } - - public void addInformationAfterShift(ItemStack stack, EntityPlayer player, List list, boolean adv) { - addStringToTooltip(getArmorSetTitle(player), list); - addArmorSetDescription(stack, list); - ItemStack[] stacks = getArmorSetStacks(); - for (int i = 0; i < stacks.length; i++) - addStringToTooltip( - (hasArmorSetItem(player, i) ? EnumChatFormatting.GREEN : "") + " - " + stacks[i].getDisplayName(), - list); - if (hasPhantomInk(stack)) addStringToTooltip(StatCollector.translateToLocal("botaniamisc.hasPhantomInk"), list); - } - - public void addStringToTooltip(String s, List tooltip) { - tooltip.add(s.replaceAll("&", "\u00a7")); - } - - static ItemStack[] armorset; - - public ItemStack[] getArmorSetStacks() { - if (armorset == null) - armorset = new ItemStack[] { - new ItemStack(ModItems.manasteelHelm), - new ItemStack(ModItems.manasteelChest), - new ItemStack(ModItems.manasteelLegs), - new ItemStack(ModItems.manasteelBoots) - }; - - return armorset; - } - - public boolean hasArmorSet(EntityPlayer player) { - return hasArmorSetItem(player, 0) - && hasArmorSetItem(player, 1) - && hasArmorSetItem(player, 2) - && hasArmorSetItem(player, 3); - } - - public boolean hasArmorSetItem(EntityPlayer player, int i) { - ItemStack stack = player.inventory.armorInventory[3 - i]; - if (stack == null) return false; - - switch (i) { - case 0: - return stack.getItem() == ModItems.manasteelHelm || stack.getItem() == ModItems.manasteelHelmRevealing; - case 1: - return stack.getItem() == ModItems.manasteelChest; - case 2: - return stack.getItem() == ModItems.manasteelLegs; - case 3: - return stack.getItem() == ModItems.manasteelBoots; - } - - return false; - } - - public int getSetPiecesEquipped(EntityPlayer player) { - int pieces = 0; - for (int i = 0; i < 4; i++) if (hasArmorSetItem(player, i)) pieces++; - - return pieces; - } - - public String getArmorSetName() { - return StatCollector.translateToLocal("botania.armorset.manasteel.name"); - } - - public String getArmorSetTitle(EntityPlayer player) { - return StatCollector.translateToLocal("botaniamisc.armorset") + " " + getArmorSetName() + " (" - + getSetPiecesEquipped(player) + "/" + getArmorSetStacks().length + ")"; - } - - public void addArmorSetDescription(ItemStack stack, List list) { - addStringToTooltip(StatCollector.translateToLocal("botania.armorset.manasteel.desc"), list); - } - - @Override - public boolean hasPhantomInk(ItemStack stack) { - return ItemNBTHelper.getBoolean(stack, TAG_PHANTOM_INK, false); - } - - @Override - public void setPhantomInk(ItemStack stack, boolean ink) { - ItemNBTHelper.setBoolean(stack, TAG_PHANTOM_INK, ink); - } - - @Override - @Optional.Method(modid = "Thaumcraft") - public int getRunicCharge(ItemStack itemstack) { - return 0; - } +public class ItemManasteelArmor extends ItemArmor implements ISpecialArmor, IManaUsingItem, IPhantomInkable, IRunicArmor { + + private static final int MANA_PER_DAMAGE = 70; + + private static final String TAG_PHANTOM_INK = "phantomInk"; + + protected ModelBiped[] models = null; + public int type; + + public ItemManasteelArmor(int type, String name) { + this(type, name, BotaniaAPI.manasteelArmorMaterial); + } + + public ItemManasteelArmor(int type, String name, ArmorMaterial mat) { + super(mat, 0, type); + this.type = type; + setCreativeTab(BotaniaCreativeTab.INSTANCE); + setUnlocalizedName(name); + } + + @Override + public Item setUnlocalizedName(String par1Str) { + GameRegistry.registerItem(this, par1Str); + return super.setUnlocalizedName(par1Str); + } + + @Override + public String getUnlocalizedNameInefficiently(ItemStack par1ItemStack) { + return super.getUnlocalizedNameInefficiently(par1ItemStack).replaceAll("item.", "item." + LibResources.PREFIX_MOD); + } + + @Override + @SideOnly(Side.CLIENT) + public void registerIcons(IIconRegister par1IconRegister) { + itemIcon = IconHelper.forItem(par1IconRegister, this); + } + + @Override + public ArmorProperties getProperties(EntityLivingBase player, ItemStack armor, DamageSource source, double damage, int slot) { + if(source.isUnblockable()) + return new ArmorProperties(0, 0, 0); + return new ArmorProperties(0, damageReduceAmount / 25D, armor.getMaxDamage() + 1 - armor.getItemDamage()); + } + + @Override + public int getArmorDisplay(EntityPlayer player, ItemStack armor, int slot) { + return damageReduceAmount; + } + + @Override + public void onUpdate(ItemStack stack, World world, Entity player, int par4, boolean par5) { + if(player instanceof EntityPlayer) + onArmorTick(world, (EntityPlayer) player, stack); + } + + @Override + public void onArmorTick(World world, EntityPlayer player, ItemStack stack) { + if(!world.isRemote && stack.getItemDamage() > 0 && ManaItemHandler.requestManaExact(stack, player, MANA_PER_DAMAGE * 2, true)) + stack.setItemDamage(stack.getItemDamage() - 1); + } + + @Override + public void damageArmor(EntityLivingBase entity, ItemStack stack, DamageSource source, int damage, int slot) { + ToolCommons.damageItem(stack, damage, entity, MANA_PER_DAMAGE); + } + + @Override + public final String getArmorTexture(ItemStack stack, Entity entity, int slot, String type) { + return hasPhantomInk(stack) ? LibResources.MODEL_INVISIBLE_ARMOR : getArmorTextureAfterInk(stack, slot); + } + + public String getArmorTextureAfterInk(ItemStack stack, int slot) { + return ConfigHandler.enableArmorModels ? LibResources.MODEL_MANASTEEL_NEW : slot == 2 ? LibResources.MODEL_MANASTEEL_1 : LibResources.MODEL_MANASTEEL_0; + } + + @Override + @SideOnly(Side.CLIENT) + public ModelBiped getArmorModel(EntityLivingBase entityLiving, ItemStack itemStack, int armorSlot) { + if(ConfigHandler.enableArmorModels) { + ModelBiped model = getArmorModelForSlot(entityLiving, itemStack, armorSlot); + if(model == null) + model = provideArmorModelForSlot(itemStack, armorSlot); + + if(model != null) + return model; + } + + return super.getArmorModel(entityLiving, itemStack, armorSlot); + } + + @SideOnly(Side.CLIENT) + public ModelBiped getArmorModelForSlot(EntityLivingBase entity, ItemStack stack, int slot) { + if(models == null) + models = new ModelBiped[4]; + + return models[slot]; + } + + @SideOnly(Side.CLIENT) + public ModelBiped provideArmorModelForSlot(ItemStack stack, int slot) { + models[slot] = new ModelArmorManasteel(slot); + return models[slot]; + } + + @Override + public boolean getIsRepairable(ItemStack par1ItemStack, ItemStack par2ItemStack) { + return par2ItemStack.getItem() == ModItems.manaResource && par2ItemStack.getItemDamage() == 0 ? true : super.getIsRepairable(par1ItemStack, par2ItemStack); + } + + @Override + public boolean usesMana(ItemStack stack) { + return true; + } + + @Override + public void addInformation(ItemStack stack, EntityPlayer player, List list, boolean adv) { + if(GuiScreen.isShiftKeyDown()) + addInformationAfterShift(stack, player, list, adv); + else addStringToTooltip(StatCollector.translateToLocal("botaniamisc.shiftinfo"), list); + } + + public void addInformationAfterShift(ItemStack stack, EntityPlayer player, List list, boolean adv) { + addStringToTooltip(getArmorSetTitle(player), list); + addArmorSetDescription(stack, list); + ItemStack[] stacks = getArmorSetStacks(); + for(int i = 0; i < stacks.length; i++) + addStringToTooltip((hasArmorSetItem(player, i) ? EnumChatFormatting.GREEN : "") + " - " + stacks[i].getDisplayName(), list); + if(hasPhantomInk(stack)) + addStringToTooltip(StatCollector.translateToLocal("botaniamisc.hasPhantomInk"), list); + } + + public void addStringToTooltip(String s, List tooltip) { + tooltip.add(s.replaceAll("&", "\u00a7")); + } + + static ItemStack[] armorset; + + public ItemStack[] getArmorSetStacks() { + if(armorset == null) + armorset = new ItemStack[] { + new ItemStack(ModItems.manasteelHelm), + new ItemStack(ModItems.manasteelChest), + new ItemStack(ModItems.manasteelLegs), + new ItemStack(ModItems.manasteelBoots) + }; + + return armorset; + } + + public boolean hasArmorSet(EntityPlayer player) { + return hasArmorSetItem(player, 0) && hasArmorSetItem(player, 1) && hasArmorSetItem(player, 2) && hasArmorSetItem(player, 3); + } + + public boolean hasArmorSetItem(EntityPlayer player, int i) { + ItemStack stack = player.inventory.armorInventory[3 - i]; + if(stack == null) + return false; + + switch(i) { + case 0: return stack.getItem() == ModItems.manasteelHelm || stack.getItem() == ModItems.manasteelHelmRevealing; + case 1: return stack.getItem() == ModItems.manasteelChest; + case 2: return stack.getItem() == ModItems.manasteelLegs; + case 3: return stack.getItem() == ModItems.manasteelBoots; + } + + return false; + } + + public int getSetPiecesEquipped(EntityPlayer player) { + int pieces = 0; + for(int i = 0; i < 4; i++) + if(hasArmorSetItem(player, i)) + pieces++; + + return pieces; + } + + public String getArmorSetName() { + return StatCollector.translateToLocal("botania.armorset.manasteel.name"); + } + + public String getArmorSetTitle(EntityPlayer player) { + return StatCollector.translateToLocal("botaniamisc.armorset") + " " + getArmorSetName() + " (" + getSetPiecesEquipped(player) + "/" + getArmorSetStacks().length + ")"; + } + + public void addArmorSetDescription(ItemStack stack, List list) { + addStringToTooltip(StatCollector.translateToLocal("botania.armorset.manasteel.desc"), list); + } + + @Override + public boolean hasPhantomInk(ItemStack stack) { + return ItemNBTHelper.getBoolean(stack, TAG_PHANTOM_INK, false); + } + + @Override + public void setPhantomInk(ItemStack stack, boolean ink) { + ItemNBTHelper.setBoolean(stack, TAG_PHANTOM_INK, ink); + } + + @Override + @Optional.Method(modid = "Thaumcraft") + public int getRunicCharge(ItemStack itemstack) { + return 0; + } } diff --git a/src/main/java/vazkii/botania/common/item/equipment/armor/manasteel/ItemManasteelBoots.java b/src/main/java/vazkii/botania/common/item/equipment/armor/manasteel/ItemManasteelBoots.java index 9c5ac006ba..3711be8e82 100644 --- a/src/main/java/vazkii/botania/common/item/equipment/armor/manasteel/ItemManasteelBoots.java +++ b/src/main/java/vazkii/botania/common/item/equipment/armor/manasteel/ItemManasteelBoots.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Apr 13, 2014, 10:24:08 PM (GMT)] */ package vazkii.botania.common.item.equipment.armor.manasteel; @@ -14,7 +14,8 @@ public class ItemManasteelBoots extends ItemManasteelArmor { - public ItemManasteelBoots() { - super(3, LibItemNames.MANASTEEL_BOOTS); - } + public ItemManasteelBoots() { + super(3, LibItemNames.MANASTEEL_BOOTS); + } + } diff --git a/src/main/java/vazkii/botania/common/item/equipment/armor/manasteel/ItemManasteelChest.java b/src/main/java/vazkii/botania/common/item/equipment/armor/manasteel/ItemManasteelChest.java index 9879ed798a..000ef254f4 100644 --- a/src/main/java/vazkii/botania/common/item/equipment/armor/manasteel/ItemManasteelChest.java +++ b/src/main/java/vazkii/botania/common/item/equipment/armor/manasteel/ItemManasteelChest.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Apr 13, 2014, 10:22:57 PM (GMT)] */ package vazkii.botania.common.item.equipment.armor.manasteel; @@ -14,7 +14,8 @@ public class ItemManasteelChest extends ItemManasteelArmor { - public ItemManasteelChest() { - super(1, LibItemNames.MANASTEEL_CHEST); - } + public ItemManasteelChest() { + super(1, LibItemNames.MANASTEEL_CHEST); + } + } diff --git a/src/main/java/vazkii/botania/common/item/equipment/armor/manasteel/ItemManasteelHelm.java b/src/main/java/vazkii/botania/common/item/equipment/armor/manasteel/ItemManasteelHelm.java index 2fecec9c6b..e06815638d 100644 --- a/src/main/java/vazkii/botania/common/item/equipment/armor/manasteel/ItemManasteelHelm.java +++ b/src/main/java/vazkii/botania/common/item/equipment/armor/manasteel/ItemManasteelHelm.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Apr 13, 2014, 10:22:24 PM (GMT)] */ package vazkii.botania.common.item.equipment.armor.manasteel; @@ -17,16 +17,17 @@ public class ItemManasteelHelm extends ItemManasteelArmor implements IManaDiscountArmor { - public ItemManasteelHelm() { - this(LibItemNames.MANASTEEL_HELM); - } + public ItemManasteelHelm() { + this(LibItemNames.MANASTEEL_HELM); + } - public ItemManasteelHelm(String name) { - super(0, name); - } + public ItemManasteelHelm(String name) { + super(0, name); + } + + @Override + public float getDiscount(ItemStack stack, int slot, EntityPlayer player) { + return hasArmorSet(player) ? 0.1F : 0F; + } - @Override - public float getDiscount(ItemStack stack, int slot, EntityPlayer player) { - return hasArmorSet(player) ? 0.1F : 0F; - } } diff --git a/src/main/java/vazkii/botania/common/item/equipment/armor/manasteel/ItemManasteelLegs.java b/src/main/java/vazkii/botania/common/item/equipment/armor/manasteel/ItemManasteelLegs.java index 3737ff9253..0538d979de 100644 --- a/src/main/java/vazkii/botania/common/item/equipment/armor/manasteel/ItemManasteelLegs.java +++ b/src/main/java/vazkii/botania/common/item/equipment/armor/manasteel/ItemManasteelLegs.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Apr 13, 2014, 10:23:28 PM (GMT)] */ package vazkii.botania.common.item.equipment.armor.manasteel; @@ -14,7 +14,8 @@ public class ItemManasteelLegs extends ItemManasteelArmor { - public ItemManasteelLegs() { - super(2, LibItemNames.MANASTEEL_LEGS); - } + public ItemManasteelLegs() { + super(2, LibItemNames.MANASTEEL_LEGS); + } + } diff --git a/src/main/java/vazkii/botania/common/item/equipment/armor/manaweave/ItemManaweaveArmor.java b/src/main/java/vazkii/botania/common/item/equipment/armor/manaweave/ItemManaweaveArmor.java index 09cd9448c0..97fec9a4da 100644 --- a/src/main/java/vazkii/botania/common/item/equipment/armor/manaweave/ItemManaweaveArmor.java +++ b/src/main/java/vazkii/botania/common/item/equipment/armor/manaweave/ItemManaweaveArmor.java @@ -2,17 +2,16 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Aug 28, 2015, 8:30:19 PM (GMT)] */ package vazkii.botania.common.item.equipment.armor.manaweave; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; import java.util.List; + import net.minecraft.client.model.ModelBiped; import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.entity.player.EntityPlayer; @@ -31,114 +30,109 @@ import vazkii.botania.common.core.handler.ConfigHandler; import vazkii.botania.common.item.ModItems; import vazkii.botania.common.item.equipment.armor.manasteel.ItemManasteelArmor; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; public class ItemManaweaveArmor extends ItemManasteelArmor implements ICraftAchievement { - IIcon iconChristmas; - - public ItemManaweaveArmor(int type, String name) { - super(type, name, BotaniaAPI.manaweaveArmorMaterial); - } - - @Override - @SideOnly(Side.CLIENT) - public ModelBiped provideArmorModelForSlot(ItemStack stack, int slot) { - models[slot] = new ModelArmorManaweave(slot); - return models[slot]; - } - - @Override - public void registerIcons(IIconRegister par1IconRegister) { - super.registerIcons(par1IconRegister); - iconChristmas = IconHelper.forItem(par1IconRegister, this, "Holiday"); - } - - @Override - public String getArmorTextureAfterInk(ItemStack stack, int slot) { - return ConfigHandler.enableArmorModels - ? (ClientProxy.jingleTheBells - ? LibResources.MODEL_MANAWEAVE_NEW_HOLIDAY - : LibResources.MODEL_MANAWEAVE_NEW) - : slot == 2 ? LibResources.MODEL_MANAWEAVE_1 : LibResources.MODEL_MANAWEAVE_0; - } - - @Override - public IIcon getIconFromDamage(int dmg) { - return ClientProxy.jingleTheBells ? iconChristmas : super.getIconFromDamage(dmg); - } - - @Override - @SideOnly(Side.CLIENT) - public String getUnlocalizedName(ItemStack p_77667_1_) { - String name = super.getUnlocalizedName(p_77667_1_); - if (ClientProxy.jingleTheBells) name = name.replaceAll("manaweave", "santaweave"); - return name; - } - - @Override - public boolean getIsRepairable(ItemStack par1ItemStack, ItemStack par2ItemStack) { - return par2ItemStack.getItem() == ModItems.manaResource && par2ItemStack.getItemDamage() == 22 - ? true - : super.getIsRepairable(par1ItemStack, par2ItemStack); - } - - static ItemStack[] armorset; - - @Override - public ItemStack[] getArmorSetStacks() { - if (armorset == null) - armorset = new ItemStack[] { - new ItemStack(ModItems.manaweaveHelm), - new ItemStack(ModItems.manaweaveChest), - new ItemStack(ModItems.manaweaveLegs), - new ItemStack(ModItems.manaweaveBoots) - }; - - return armorset; - } - - @Override - public boolean hasArmorSetItem(EntityPlayer player, int i) { - ItemStack stack = player.inventory.armorInventory[3 - i]; - if (stack == null) return false; - - switch (i) { - case 0: - return stack.getItem() == ModItems.manaweaveHelm; - case 1: - return stack.getItem() == ModItems.manaweaveChest; - case 2: - return stack.getItem() == ModItems.manaweaveLegs; - case 3: - return stack.getItem() == ModItems.manaweaveBoots; - } - - return false; - } - - @Override - public String getArmorSetName() { - return StatCollector.translateToLocal("botania.armorset.manaweave.name"); - } - - @Override - public void addInformationAfterShift(ItemStack stack, EntityPlayer player, List list, boolean adv) { - if (ClientProxy.jingleTheBells) { - addStringToTooltip(StatCollector.translateToLocal("botaniamisc.santaweaveInfo"), list); - addStringToTooltip("", list); - } - - super.addInformationAfterShift(stack, player, list, adv); - } - - @Override - public void addArmorSetDescription(ItemStack stack, List list) { - addStringToTooltip(StatCollector.translateToLocal("botania.armorset.manaweave.desc0"), list); - addStringToTooltip(StatCollector.translateToLocal("botania.armorset.manaweave.desc1"), list); - } + IIcon iconChristmas; + + public ItemManaweaveArmor(int type, String name) { + super(type, name, BotaniaAPI.manaweaveArmorMaterial); + } + + @Override + @SideOnly(Side.CLIENT) + public ModelBiped provideArmorModelForSlot(ItemStack stack, int slot) { + models[slot] = new ModelArmorManaweave(slot); + return models[slot]; + } + + @Override + public void registerIcons(IIconRegister par1IconRegister) { + super.registerIcons(par1IconRegister); + iconChristmas = IconHelper.forItem(par1IconRegister, this, "Holiday"); + } + + @Override + public String getArmorTextureAfterInk(ItemStack stack, int slot) { + return ConfigHandler.enableArmorModels ? (ClientProxy.jingleTheBells ? LibResources.MODEL_MANAWEAVE_NEW_HOLIDAY : LibResources.MODEL_MANAWEAVE_NEW) : slot == 2 ? LibResources.MODEL_MANAWEAVE_1 : LibResources.MODEL_MANAWEAVE_0; + } + + @Override + public IIcon getIconFromDamage(int dmg) { + return ClientProxy.jingleTheBells ? iconChristmas : super.getIconFromDamage(dmg); + } + + @Override + @SideOnly(Side.CLIENT) + public String getUnlocalizedName(ItemStack p_77667_1_) { + String name = super.getUnlocalizedName(p_77667_1_); + if(ClientProxy.jingleTheBells) + name = name.replaceAll("manaweave", "santaweave"); + return name; + } + + @Override + public boolean getIsRepairable(ItemStack par1ItemStack, ItemStack par2ItemStack) { + return par2ItemStack.getItem() == ModItems.manaResource && par2ItemStack.getItemDamage() == 22 ? true : super.getIsRepairable(par1ItemStack, par2ItemStack); + } + + static ItemStack[] armorset; + + @Override + public ItemStack[] getArmorSetStacks() { + if(armorset == null) + armorset = new ItemStack[] { + new ItemStack(ModItems.manaweaveHelm), + new ItemStack(ModItems.manaweaveChest), + new ItemStack(ModItems.manaweaveLegs), + new ItemStack(ModItems.manaweaveBoots) + }; + + return armorset; + } + + @Override + public boolean hasArmorSetItem(EntityPlayer player, int i) { + ItemStack stack = player.inventory.armorInventory[3 - i]; + if(stack == null) + return false; + + switch(i) { + case 0: return stack.getItem() == ModItems.manaweaveHelm; + case 1: return stack.getItem() == ModItems.manaweaveChest; + case 2: return stack.getItem() == ModItems.manaweaveLegs; + case 3: return stack.getItem() == ModItems.manaweaveBoots; + } + + return false; + } + + @Override + public String getArmorSetName() { + return StatCollector.translateToLocal("botania.armorset.manaweave.name"); + } + + @Override + public void addInformationAfterShift(ItemStack stack, EntityPlayer player, List list, boolean adv) { + if(ClientProxy.jingleTheBells) { + addStringToTooltip(StatCollector.translateToLocal("botaniamisc.santaweaveInfo"), list); + addStringToTooltip("", list); + } + + super.addInformationAfterShift(stack, player, list, adv); + } + + @Override + public void addArmorSetDescription(ItemStack stack, List list) { + addStringToTooltip(StatCollector.translateToLocal("botania.armorset.manaweave.desc0"), list); + addStringToTooltip(StatCollector.translateToLocal("botania.armorset.manaweave.desc1"), list); + } + + @Override + public Achievement getAchievementOnCraft(ItemStack stack, EntityPlayer player, IInventory matrix) { + return ModAchievements.manaweaveArmorCraft; + } - @Override - public Achievement getAchievementOnCraft(ItemStack stack, EntityPlayer player, IInventory matrix) { - return ModAchievements.manaweaveArmorCraft; - } } diff --git a/src/main/java/vazkii/botania/common/item/equipment/armor/manaweave/ItemManaweaveBoots.java b/src/main/java/vazkii/botania/common/item/equipment/armor/manaweave/ItemManaweaveBoots.java index ddc59b60ec..35d18e0ebc 100644 --- a/src/main/java/vazkii/botania/common/item/equipment/armor/manaweave/ItemManaweaveBoots.java +++ b/src/main/java/vazkii/botania/common/item/equipment/armor/manaweave/ItemManaweaveBoots.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Aug 28, 2015, 8:48:58 PM (GMT)] */ package vazkii.botania.common.item.equipment.armor.manaweave; @@ -14,7 +14,8 @@ public class ItemManaweaveBoots extends ItemManaweaveArmor { - public ItemManaweaveBoots() { - super(3, LibItemNames.MANAWEAVE_BOOTS); - } + public ItemManaweaveBoots() { + super(3, LibItemNames.MANAWEAVE_BOOTS); + } + } diff --git a/src/main/java/vazkii/botania/common/item/equipment/armor/manaweave/ItemManaweaveChest.java b/src/main/java/vazkii/botania/common/item/equipment/armor/manaweave/ItemManaweaveChest.java index 2bd0e22a70..98f4391f20 100644 --- a/src/main/java/vazkii/botania/common/item/equipment/armor/manaweave/ItemManaweaveChest.java +++ b/src/main/java/vazkii/botania/common/item/equipment/armor/manaweave/ItemManaweaveChest.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Aug 28, 2015, 8:48:17 PM (GMT)] */ package vazkii.botania.common.item.equipment.armor.manaweave; @@ -14,7 +14,9 @@ public class ItemManaweaveChest extends ItemManaweaveArmor { - public ItemManaweaveChest() { - super(1, LibItemNames.MANAWEAVE_CHEST); - } + public ItemManaweaveChest() { + super(1, LibItemNames.MANAWEAVE_CHEST); + } + + } diff --git a/src/main/java/vazkii/botania/common/item/equipment/armor/manaweave/ItemManaweaveHelm.java b/src/main/java/vazkii/botania/common/item/equipment/armor/manaweave/ItemManaweaveHelm.java index e81c807381..06ab5cd4a3 100644 --- a/src/main/java/vazkii/botania/common/item/equipment/armor/manaweave/ItemManaweaveHelm.java +++ b/src/main/java/vazkii/botania/common/item/equipment/armor/manaweave/ItemManaweaveHelm.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Aug 28, 2015, 8:47:04 PM (GMT)] */ package vazkii.botania.common.item.equipment.armor.manaweave; @@ -23,32 +23,31 @@ public class ItemManaweaveHelm extends ItemManaweaveArmor implements IManaDiscountArmor, IManaProficiencyArmor { - private static final int MANA_PER_DAMAGE = 30; - - public ItemManaweaveHelm() { - super(0, LibItemNames.MANAWEAVE_HELM); - } - - @Override - public float getDiscount(ItemStack stack, int slot, EntityPlayer player) { - return hasArmorSet(player) ? 0.35F : 0F; - } - - @Override - public boolean shouldGiveProficiency(ItemStack stack, int slot, EntityPlayer player) { - return hasArmorSet(player); - } - - @Override - public void onArmorTick(World world, EntityPlayer player, ItemStack stack) { - if (!world.isRemote - && stack.getItemDamage() > 0 - && ManaItemHandler.requestManaExact(stack, player, MANA_PER_DAMAGE * 2, true)) - stack.setItemDamage(stack.getItemDamage() - 1); - } - - @Override - public void damageArmor(EntityLivingBase entity, ItemStack stack, DamageSource source, int damage, int slot) { - ToolCommons.damageItem(stack, damage, entity, MANA_PER_DAMAGE); - } + private static final int MANA_PER_DAMAGE = 30; + + public ItemManaweaveHelm() { + super(0, LibItemNames.MANAWEAVE_HELM); + } + + @Override + public float getDiscount(ItemStack stack, int slot, EntityPlayer player) { + return hasArmorSet(player) ? 0.35F : 0F; + } + + @Override + public boolean shouldGiveProficiency(ItemStack stack, int slot, EntityPlayer player) { + return hasArmorSet(player); + } + + @Override + public void onArmorTick(World world, EntityPlayer player, ItemStack stack) { + if(!world.isRemote && stack.getItemDamage() > 0 && ManaItemHandler.requestManaExact(stack, player, MANA_PER_DAMAGE * 2, true)) + stack.setItemDamage(stack.getItemDamage() - 1); + } + + @Override + public void damageArmor(EntityLivingBase entity, ItemStack stack, DamageSource source, int damage, int slot) { + ToolCommons.damageItem(stack, damage, entity, MANA_PER_DAMAGE); + } + } diff --git a/src/main/java/vazkii/botania/common/item/equipment/armor/manaweave/ItemManaweaveLegs.java b/src/main/java/vazkii/botania/common/item/equipment/armor/manaweave/ItemManaweaveLegs.java index 78bb20c78f..63d61d161f 100644 --- a/src/main/java/vazkii/botania/common/item/equipment/armor/manaweave/ItemManaweaveLegs.java +++ b/src/main/java/vazkii/botania/common/item/equipment/armor/manaweave/ItemManaweaveLegs.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Aug 28, 2015, 8:48:36 PM (GMT)] */ package vazkii.botania.common.item.equipment.armor.manaweave; @@ -14,7 +14,8 @@ public class ItemManaweaveLegs extends ItemManaweaveArmor { - public ItemManaweaveLegs() { - super(2, LibItemNames.MANAWEAVE_LEGS); - } + public ItemManaweaveLegs() { + super(2, LibItemNames.MANAWEAVE_LEGS); + } + } diff --git a/src/main/java/vazkii/botania/common/item/equipment/armor/terrasteel/ItemTerrasteelArmor.java b/src/main/java/vazkii/botania/common/item/equipment/armor/terrasteel/ItemTerrasteelArmor.java index 243767044e..7dcb7b24e1 100644 --- a/src/main/java/vazkii/botania/common/item/equipment/armor/terrasteel/ItemTerrasteelArmor.java +++ b/src/main/java/vazkii/botania/common/item/equipment/armor/terrasteel/ItemTerrasteelArmor.java @@ -2,20 +2,17 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Apr 14, 2014, 2:58:13 PM (GMT)] */ package vazkii.botania.common.item.equipment.armor.terrasteel; -import com.google.common.collect.HashMultimap; -import com.google.common.collect.Multimap; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; import java.util.List; import java.util.UUID; + import net.minecraft.client.model.ModelBiped; import net.minecraft.entity.SharedMonsterAttributes; import net.minecraft.entity.ai.attributes.AttributeModifier; @@ -29,91 +26,84 @@ import vazkii.botania.common.item.ModItems; import vazkii.botania.common.item.equipment.armor.manasteel.ItemManasteelArmor; +import com.google.common.collect.HashMultimap; +import com.google.common.collect.Multimap; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + public class ItemTerrasteelArmor extends ItemManasteelArmor { - public ItemTerrasteelArmor(int type, String name) { - super(type, name, BotaniaAPI.terrasteelArmorMaterial); - } - - @Override - @SideOnly(Side.CLIENT) - public ModelBiped provideArmorModelForSlot(ItemStack stack, int slot) { - models[slot] = new ModelArmorTerrasteel(slot); - return models[slot]; - } - - @Override - public String getArmorTextureAfterInk(ItemStack stack, int slot) { - return ConfigHandler.enableArmorModels - ? LibResources.MODEL_TERRASTEEL_NEW - : slot == 2 ? LibResources.MODEL_TERRASTEEL_1 : LibResources.MODEL_TERRASTEEL_0; - } - - @Override - public boolean getIsRepairable(ItemStack par1ItemStack, ItemStack par2ItemStack) { - return par2ItemStack.getItem() == ModItems.manaResource && par2ItemStack.getItemDamage() == 4 - ? true - : super.getIsRepairable(par1ItemStack, par2ItemStack); - } - - @Override - public Multimap getItemAttributeModifiers() { - Multimap multimap = HashMultimap.create(); - UUID uuid = new UUID(getUnlocalizedName().hashCode(), 0); - multimap.put( - SharedMonsterAttributes.knockbackResistance.getAttributeUnlocalizedName(), - new AttributeModifier( - uuid, - "Terrasteel modifier " + type, - (double) getArmorDisplay(null, new ItemStack(this), type) / 20, - 0)); - return multimap; - } - - static ItemStack[] armorset; - - @Override - public ItemStack[] getArmorSetStacks() { - if (armorset == null) - armorset = new ItemStack[] { - new ItemStack(ModItems.terrasteelHelm), - new ItemStack(ModItems.terrasteelChest), - new ItemStack(ModItems.terrasteelLegs), - new ItemStack(ModItems.terrasteelBoots) - }; - - return armorset; - } - - @Override - public boolean hasArmorSetItem(EntityPlayer player, int i) { - ItemStack stack = player.inventory.armorInventory[3 - i]; - if (stack == null) return false; - - switch (i) { - case 0: - return stack.getItem() == ModItems.terrasteelHelm - || stack.getItem() == ModItems.terrasteelHelmRevealing; - case 1: - return stack.getItem() == ModItems.terrasteelChest; - case 2: - return stack.getItem() == ModItems.terrasteelLegs; - case 3: - return stack.getItem() == ModItems.terrasteelBoots; - } - - return false; - } - - @Override - public String getArmorSetName() { - return StatCollector.translateToLocal("botania.armorset.terrasteel.name"); - } - - @Override - public void addArmorSetDescription(ItemStack stack, List list) { - addStringToTooltip(StatCollector.translateToLocal("botania.armorset.terrasteel.desc0"), list); - addStringToTooltip(StatCollector.translateToLocal("botania.armorset.terrasteel.desc1"), list); - addStringToTooltip(StatCollector.translateToLocal("botania.armorset.terrasteel.desc2"), list); - } + public ItemTerrasteelArmor(int type, String name) { + super(type, name, BotaniaAPI.terrasteelArmorMaterial); + } + + @Override + @SideOnly(Side.CLIENT) + public ModelBiped provideArmorModelForSlot(ItemStack stack, int slot) { + models[slot] = new ModelArmorTerrasteel(slot); + return models[slot]; + } + + @Override + public String getArmorTextureAfterInk(ItemStack stack, int slot) { + return ConfigHandler.enableArmorModels ? LibResources.MODEL_TERRASTEEL_NEW : slot == 2 ? LibResources.MODEL_TERRASTEEL_1 : LibResources.MODEL_TERRASTEEL_0; + } + + @Override + public boolean getIsRepairable(ItemStack par1ItemStack, ItemStack par2ItemStack) { + return par2ItemStack.getItem() == ModItems.manaResource && par2ItemStack.getItemDamage() == 4 ? true : super.getIsRepairable(par1ItemStack, par2ItemStack); + } + + @Override + public Multimap getItemAttributeModifiers() { + Multimap multimap = HashMultimap.create(); + UUID uuid = new UUID(getUnlocalizedName().hashCode(), 0); + multimap.put(SharedMonsterAttributes.knockbackResistance.getAttributeUnlocalizedName(), new AttributeModifier(uuid, "Terrasteel modifier " + type, (double) getArmorDisplay(null, new ItemStack(this), type) / 20, 0)); + return multimap; + } + + static ItemStack[] armorset; + + @Override + public ItemStack[] getArmorSetStacks() { + if(armorset == null) + armorset = new ItemStack[] { + new ItemStack(ModItems.terrasteelHelm), + new ItemStack(ModItems.terrasteelChest), + new ItemStack(ModItems.terrasteelLegs), + new ItemStack(ModItems.terrasteelBoots) + }; + + return armorset; + } + + @Override + public boolean hasArmorSetItem(EntityPlayer player, int i) { + ItemStack stack = player.inventory.armorInventory[3 - i]; + if(stack == null) + return false; + + switch(i) { + case 0: return stack.getItem() == ModItems.terrasteelHelm || stack.getItem() == ModItems.terrasteelHelmRevealing; + case 1: return stack.getItem() == ModItems.terrasteelChest; + case 2: return stack.getItem() == ModItems.terrasteelLegs; + case 3: return stack.getItem() == ModItems.terrasteelBoots; + } + + return false; + } + + @Override + public String getArmorSetName() { + return StatCollector.translateToLocal("botania.armorset.terrasteel.name"); + } + + @Override + public void addArmorSetDescription(ItemStack stack, List list) { + addStringToTooltip(StatCollector.translateToLocal("botania.armorset.terrasteel.desc0"), list); + addStringToTooltip(StatCollector.translateToLocal("botania.armorset.terrasteel.desc1"), list); + addStringToTooltip(StatCollector.translateToLocal("botania.armorset.terrasteel.desc2"), list); + } + } diff --git a/src/main/java/vazkii/botania/common/item/equipment/armor/terrasteel/ItemTerrasteelBoots.java b/src/main/java/vazkii/botania/common/item/equipment/armor/terrasteel/ItemTerrasteelBoots.java index 48ffc5b684..5ff5aedda1 100644 --- a/src/main/java/vazkii/botania/common/item/equipment/armor/terrasteel/ItemTerrasteelBoots.java +++ b/src/main/java/vazkii/botania/common/item/equipment/armor/terrasteel/ItemTerrasteelBoots.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Apr 14, 2014, 3:14:11 PM (GMT)] */ package vazkii.botania.common.item.equipment.armor.terrasteel; @@ -14,7 +14,8 @@ public class ItemTerrasteelBoots extends ItemTerrasteelArmor { - public ItemTerrasteelBoots() { - super(3, LibItemNames.TERRASTEEL_BOOTS); - } + public ItemTerrasteelBoots() { + super(3, LibItemNames.TERRASTEEL_BOOTS); + } + } diff --git a/src/main/java/vazkii/botania/common/item/equipment/armor/terrasteel/ItemTerrasteelChest.java b/src/main/java/vazkii/botania/common/item/equipment/armor/terrasteel/ItemTerrasteelChest.java index d44849fd90..4f4a7b6a3a 100644 --- a/src/main/java/vazkii/botania/common/item/equipment/armor/terrasteel/ItemTerrasteelChest.java +++ b/src/main/java/vazkii/botania/common/item/equipment/armor/terrasteel/ItemTerrasteelChest.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Apr 14, 2014, 3:13:36 PM (GMT)] */ package vazkii.botania.common.item.equipment.armor.terrasteel; @@ -14,7 +14,8 @@ public class ItemTerrasteelChest extends ItemTerrasteelArmor { - public ItemTerrasteelChest() { - super(1, LibItemNames.TERRASTEEL_CHEST); - } + public ItemTerrasteelChest() { + super(1, LibItemNames.TERRASTEEL_CHEST); + } + } diff --git a/src/main/java/vazkii/botania/common/item/equipment/armor/terrasteel/ItemTerrasteelHelm.java b/src/main/java/vazkii/botania/common/item/equipment/armor/terrasteel/ItemTerrasteelHelm.java index a2786bdb5e..213e84f020 100644 --- a/src/main/java/vazkii/botania/common/item/equipment/armor/terrasteel/ItemTerrasteelHelm.java +++ b/src/main/java/vazkii/botania/common/item/equipment/armor/terrasteel/ItemTerrasteelHelm.java @@ -2,18 +2,16 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Apr 14, 2014, 3:13:05 PM (GMT)] */ package vazkii.botania.common.item.equipment.armor.terrasteel; -import cpw.mods.fml.common.eventhandler.SubscribeEvent; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; import java.util.List; + import net.minecraft.client.Minecraft; import net.minecraft.client.renderer.ItemRenderer; import net.minecraft.client.renderer.Tessellator; @@ -30,7 +28,9 @@ import net.minecraftforge.client.event.RenderPlayerEvent; import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.event.entity.living.LivingHurtEvent; + import org.lwjgl.opengl.GL11; + import vazkii.botania.api.item.IAncientWillContainer; import vazkii.botania.api.item.IBaubleRender.Helper; import vazkii.botania.api.mana.IManaDiscountArmor; @@ -39,122 +39,128 @@ import vazkii.botania.client.core.helper.IconHelper; import vazkii.botania.common.core.helper.ItemNBTHelper; import vazkii.botania.common.lib.LibItemNames; +import cpw.mods.fml.common.eventhandler.SubscribeEvent; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +public class ItemTerrasteelHelm extends ItemTerrasteelArmor implements IManaDiscountArmor, IAncientWillContainer, IManaGivingItem { + + private static final String TAG_ANCIENT_WILL = "AncientWill"; + static IIcon willIcon; + + public ItemTerrasteelHelm() { + this(LibItemNames.TERRASTEEL_HELM); + MinecraftForge.EVENT_BUS.register(this); + } + + public ItemTerrasteelHelm(String name) { + super(0, name); + } + + @Override + @SideOnly(Side.CLIENT) + public void registerIcons(IIconRegister par1IconRegister) { + super.registerIcons(par1IconRegister); + willIcon = IconHelper.forName(par1IconRegister, "willFlame"); + } + + @Override + public void onArmorTick(World world, EntityPlayer player, ItemStack stack) { + super.onArmorTick(world, player, stack); + if(hasArmorSet(player)) { + int food = player.getFoodStats().getFoodLevel(); + if(food > 0 && food < 18 && player.shouldHeal() && player.ticksExisted % 80 == 0) + player.heal(1F); + ManaItemHandler.dispatchManaExact(stack, player, 1, true); + } + } + + @Override + public float getDiscount(ItemStack stack, int slot, EntityPlayer player) { + return hasArmorSet(player) ? 0.2F : 0F; + } + + @Override + public void addAncientWill(ItemStack stack, int will) { + ItemNBTHelper.setBoolean(stack, TAG_ANCIENT_WILL + will, true); + } + + @Override + public boolean hasAncientWill(ItemStack stack, int will) { + return hasAncientWill_(stack, will); + } + + public static boolean hasAncientWill_(ItemStack stack, int will) { + return ItemNBTHelper.getBoolean(stack, TAG_ANCIENT_WILL + will, false); + } + + @Override + @SideOnly(Side.CLIENT) + public void addArmorSetDescription(ItemStack stack, List list) { + super.addArmorSetDescription(stack, list); + for(int i = 0; i < 6; i++) + if(hasAncientWill(stack, i)) + addStringToTooltip(StatCollector.translateToLocal("botania.armorset.will" + i + ".desc"), list); + } + + public static boolean hasAnyWill(ItemStack stack) { + for(int i = 0; i < 6; i++) + if(hasAncientWill_(stack, i)) + return true; + + return false; + } + + @SideOnly(Side.CLIENT) + public static void renderOnPlayer(ItemStack stack, RenderPlayerEvent event) { + if(hasAnyWill(stack) && !((ItemTerrasteelArmor) stack.getItem()).hasPhantomInk(stack)) { + GL11.glPushMatrix(); + float f = willIcon.getMinU(); + float f1 = willIcon.getMaxU(); + float f2 = willIcon.getMinV(); + float f3 = willIcon.getMaxV(); + Helper.translateToHeadLevel(event.entityPlayer); + Minecraft.getMinecraft().renderEngine.bindTexture(TextureMap.locationItemsTexture); + GL11.glRotatef(90F, 0F, 1F, 0F); + GL11.glRotatef(180F, 1F, 0F, 0F); + GL11.glTranslatef(-0.26F, 0.15F, -0.39F); + GL11.glScalef(0.5F, 0.5F, 0.5F); + ItemRenderer.renderItemIn2D(Tessellator.instance, f1, f2, f, f3, willIcon.getIconWidth(), willIcon.getIconHeight(), 1F / 16F); + GL11.glPopMatrix(); + } + } + + @SubscribeEvent + public void onEntityAttacked(LivingHurtEvent event) { + Entity attacker = event.source.getEntity(); + if(attacker instanceof EntityPlayer) { + EntityPlayer player = (EntityPlayer) attacker; + if(hasArmorSet(player)) { + boolean crit = player.fallDistance > 0.0F && !player.onGround && !player.isOnLadder() && !player.isInWater() && !player.isPotionActive(Potion.blindness) && player.ridingEntity == null; + ItemStack stack = player.inventory.armorItemInSlot(3); + if(crit && stack != null && stack.getItem() instanceof ItemTerrasteelHelm) { + boolean ahrim = hasAncientWill(stack, 0); + boolean dharok = hasAncientWill(stack, 1); + boolean guthan = hasAncientWill(stack, 2); + boolean torag = hasAncientWill(stack, 3); + boolean verac = hasAncientWill(stack, 4); + boolean karil = hasAncientWill(stack, 5); + + if(ahrim) + event.entityLiving.addPotionEffect(new PotionEffect(Potion.weakness.id, 20, 1)); + if(dharok) + event.ammount *= 1F + (1F - player.getHealth() / player.getMaxHealth()) * 0.5F; + if(guthan) + player.heal(event.ammount * 0.25F); + if(torag) + event.entityLiving.addPotionEffect(new PotionEffect(Potion.moveSlowdown.id, 60, 1)); + if(verac) + event.source.setDamageBypassesArmor(); + if(karil) + event.entityLiving.addPotionEffect(new PotionEffect(Potion.wither.id, 60, 1)); + } + } + } + } -public class ItemTerrasteelHelm extends ItemTerrasteelArmor - implements IManaDiscountArmor, IAncientWillContainer, IManaGivingItem { - - private static final String TAG_ANCIENT_WILL = "AncientWill"; - static IIcon willIcon; - - public ItemTerrasteelHelm() { - this(LibItemNames.TERRASTEEL_HELM); - MinecraftForge.EVENT_BUS.register(this); - } - - public ItemTerrasteelHelm(String name) { - super(0, name); - } - - @Override - @SideOnly(Side.CLIENT) - public void registerIcons(IIconRegister par1IconRegister) { - super.registerIcons(par1IconRegister); - willIcon = IconHelper.forName(par1IconRegister, "willFlame"); - } - - @Override - public void onArmorTick(World world, EntityPlayer player, ItemStack stack) { - super.onArmorTick(world, player, stack); - if (hasArmorSet(player)) { - int food = player.getFoodStats().getFoodLevel(); - if (food > 0 && food < 18 && player.shouldHeal() && player.ticksExisted % 80 == 0) player.heal(1F); - ManaItemHandler.dispatchManaExact(stack, player, 1, true); - } - } - - @Override - public float getDiscount(ItemStack stack, int slot, EntityPlayer player) { - return hasArmorSet(player) ? 0.2F : 0F; - } - - @Override - public void addAncientWill(ItemStack stack, int will) { - ItemNBTHelper.setBoolean(stack, TAG_ANCIENT_WILL + will, true); - } - - @Override - public boolean hasAncientWill(ItemStack stack, int will) { - return hasAncientWill_(stack, will); - } - - public static boolean hasAncientWill_(ItemStack stack, int will) { - return ItemNBTHelper.getBoolean(stack, TAG_ANCIENT_WILL + will, false); - } - - @Override - @SideOnly(Side.CLIENT) - public void addArmorSetDescription(ItemStack stack, List list) { - super.addArmorSetDescription(stack, list); - for (int i = 0; i < 6; i++) - if (hasAncientWill(stack, i)) - addStringToTooltip(StatCollector.translateToLocal("botania.armorset.will" + i + ".desc"), list); - } - - public static boolean hasAnyWill(ItemStack stack) { - for (int i = 0; i < 6; i++) if (hasAncientWill_(stack, i)) return true; - - return false; - } - - @SideOnly(Side.CLIENT) - public static void renderOnPlayer(ItemStack stack, RenderPlayerEvent event) { - if (hasAnyWill(stack) && !((ItemTerrasteelArmor) stack.getItem()).hasPhantomInk(stack)) { - GL11.glPushMatrix(); - float f = willIcon.getMinU(); - float f1 = willIcon.getMaxU(); - float f2 = willIcon.getMinV(); - float f3 = willIcon.getMaxV(); - Helper.translateToHeadLevel(event.entityPlayer); - Minecraft.getMinecraft().renderEngine.bindTexture(TextureMap.locationItemsTexture); - GL11.glRotatef(90F, 0F, 1F, 0F); - GL11.glRotatef(180F, 1F, 0F, 0F); - GL11.glTranslatef(-0.26F, 0.15F, -0.39F); - GL11.glScalef(0.5F, 0.5F, 0.5F); - ItemRenderer.renderItemIn2D( - Tessellator.instance, f1, f2, f, f3, willIcon.getIconWidth(), willIcon.getIconHeight(), 1F / 16F); - GL11.glPopMatrix(); - } - } - - @SubscribeEvent - public void onEntityAttacked(LivingHurtEvent event) { - Entity attacker = event.source.getEntity(); - if (attacker instanceof EntityPlayer) { - EntityPlayer player = (EntityPlayer) attacker; - if (hasArmorSet(player)) { - boolean crit = player.fallDistance > 0.0F - && !player.onGround - && !player.isOnLadder() - && !player.isInWater() - && !player.isPotionActive(Potion.blindness) - && player.ridingEntity == null; - ItemStack stack = player.inventory.armorItemInSlot(3); - if (crit && stack != null && stack.getItem() instanceof ItemTerrasteelHelm) { - boolean ahrim = hasAncientWill(stack, 0); - boolean dharok = hasAncientWill(stack, 1); - boolean guthan = hasAncientWill(stack, 2); - boolean torag = hasAncientWill(stack, 3); - boolean verac = hasAncientWill(stack, 4); - boolean karil = hasAncientWill(stack, 5); - - if (ahrim) event.entityLiving.addPotionEffect(new PotionEffect(Potion.weakness.id, 20, 1)); - if (dharok) event.ammount *= 1F + (1F - player.getHealth() / player.getMaxHealth()) * 0.5F; - if (guthan) player.heal(event.ammount * 0.25F); - if (torag) event.entityLiving.addPotionEffect(new PotionEffect(Potion.moveSlowdown.id, 60, 1)); - if (verac) event.source.setDamageBypassesArmor(); - if (karil) event.entityLiving.addPotionEffect(new PotionEffect(Potion.wither.id, 60, 1)); - } - } - } - } } diff --git a/src/main/java/vazkii/botania/common/item/equipment/armor/terrasteel/ItemTerrasteelLegs.java b/src/main/java/vazkii/botania/common/item/equipment/armor/terrasteel/ItemTerrasteelLegs.java index 030c13be03..536819909b 100644 --- a/src/main/java/vazkii/botania/common/item/equipment/armor/terrasteel/ItemTerrasteelLegs.java +++ b/src/main/java/vazkii/botania/common/item/equipment/armor/terrasteel/ItemTerrasteelLegs.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Apr 14, 2014, 3:13:49 PM (GMT)] */ package vazkii.botania.common.item.equipment.armor.terrasteel; @@ -14,7 +14,8 @@ public class ItemTerrasteelLegs extends ItemTerrasteelArmor { - public ItemTerrasteelLegs() { - super(2, LibItemNames.TERRASTEEL_LEGS); - } + public ItemTerrasteelLegs() { + super(2, LibItemNames.TERRASTEEL_LEGS); + } + } diff --git a/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemAuraRing.java b/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemAuraRing.java index 7c52285a39..6365a3bccf 100644 --- a/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemAuraRing.java +++ b/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemAuraRing.java @@ -2,45 +2,46 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Apr 24, 2014, 4:43:47 PM (GMT)] */ package vazkii.botania.common.item.equipment.bauble; -import baubles.api.BaubleType; import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; import vazkii.botania.api.mana.IManaGivingItem; import vazkii.botania.api.mana.ManaItemHandler; import vazkii.botania.common.lib.LibItemNames; +import baubles.api.BaubleType; public class ItemAuraRing extends ItemBauble implements IManaGivingItem { - public ItemAuraRing(String name) { - super(name); - } - - public ItemAuraRing() { - this(LibItemNames.AURA_RING); - } - - @Override - public void onWornTick(ItemStack stack, EntityLivingBase player) { - super.onWornTick(stack, player); - if (player instanceof EntityPlayer && player.ticksExisted % getDelay() == 0) - ManaItemHandler.dispatchManaExact(stack, (EntityPlayer) player, 1, true); - } - - int getDelay() { - return 10; - } - - @Override - public BaubleType getBaubleType(ItemStack itemstack) { - return BaubleType.RING; - } + public ItemAuraRing(String name) { + super(name); + } + + public ItemAuraRing() { + this(LibItemNames.AURA_RING); + } + + @Override + public void onWornTick(ItemStack stack, EntityLivingBase player) { + super.onWornTick(stack, player); + if(player instanceof EntityPlayer && player.ticksExisted % getDelay() == 0) + ManaItemHandler.dispatchManaExact(stack, (EntityPlayer) player, 1, true); + } + + int getDelay() { + return 10; + } + + @Override + public BaubleType getBaubleType(ItemStack itemstack) { + return BaubleType.RING; + } + } diff --git a/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemBauble.java b/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemBauble.java index c645e5e3b3..f8d75a8912 100644 --- a/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemBauble.java +++ b/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemBauble.java @@ -10,15 +10,9 @@ */ package vazkii.botania.common.item.equipment.bauble; -import baubles.api.BaubleType; -import baubles.api.IBauble; -import baubles.common.container.InventoryBaubles; -import baubles.common.lib.PlayerHandler; -import cpw.mods.fml.common.Optional; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; import java.util.List; import java.util.UUID; + import net.minecraft.client.gui.GuiScreen; import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.player.EntityPlayer; @@ -33,189 +27,194 @@ import vazkii.botania.common.core.helper.ItemNBTHelper; import vazkii.botania.common.entity.EntityDoppleganger; import vazkii.botania.common.item.ItemMod; +import baubles.api.BaubleType; +import baubles.api.IBauble; +import baubles.common.container.InventoryBaubles; +import baubles.common.lib.PlayerHandler; +import cpw.mods.fml.common.Optional; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; @Optional.Interface(modid = "Thaumcraft", iface = "thaumcraft.api.IRunicArmor") public abstract class ItemBauble extends ItemMod implements IBauble, ICosmeticAttachable, IPhantomInkable, IRunicArmor { - private static final String TAG_HASHCODE = "playerHashcode"; - private static final String TAG_BAUBLE_UUID_MOST = "baubleUUIDMost"; - private static final String TAG_BAUBLE_UUID_LEAST = "baubleUUIDLeast"; - private static final String TAG_COSMETIC_ITEM = "cosmeticItem"; - private static final String TAG_PHANTOM_INK = "phantomInk"; - - public ItemBauble(String name) { - super(); - setMaxStackSize(1); - setUnlocalizedName(name); - } - - @Override - public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer) { - if (!EntityDoppleganger.isTruePlayer(par3EntityPlayer)) return par1ItemStack; - - if (canEquip(par1ItemStack, par3EntityPlayer)) { - InventoryBaubles baubles = PlayerHandler.getPlayerBaubles(par3EntityPlayer); - for (int i = 0; i < baubles.getSizeInventory(); i++) { - if (baubles.isItemValidForSlot(i, par1ItemStack)) { - ItemStack stackInSlot = baubles.getStackInSlot(i); - if (stackInSlot == null - || ((IBauble) stackInSlot.getItem()).canUnequip(stackInSlot, par3EntityPlayer)) { - if (!par2World.isRemote) { - baubles.setInventorySlotContents(i, par1ItemStack.copy()); - if (!par3EntityPlayer.capabilities.isCreativeMode) - par3EntityPlayer.inventory.setInventorySlotContents( - par3EntityPlayer.inventory.currentItem, null); - } - - if (stackInSlot != null) { - ((IBauble) stackInSlot.getItem()).onUnequipped(stackInSlot, par3EntityPlayer); - return stackInSlot.copy(); - } - break; - } - } - } - } - - return par1ItemStack; - } - - @Override - @SideOnly(Side.CLIENT) - public void addInformation(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, List par3List, boolean par4) { - if (GuiScreen.isShiftKeyDown()) addHiddenTooltip(par1ItemStack, par2EntityPlayer, par3List, par4); - else addStringToTooltip(StatCollector.translateToLocal("botaniamisc.shiftinfo"), par3List); - } - - public void addHiddenTooltip(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, List par3List, boolean par4) { - BaubleType type = getBaubleType(par1ItemStack); - addStringToTooltip( - StatCollector.translateToLocal( - "botania.baubletype." + type.name().toLowerCase()), - par3List); - - String key = vazkii.botania.client.core.helper.RenderHelper.getKeyDisplayString("Baubles Inventory"); - - if (key != null) - addStringToTooltip( - StatCollector.translateToLocal("botania.baubletooltip").replaceAll("%key%", key), par3List); - - ItemStack cosmetic = getCosmeticItem(par1ItemStack); - if (cosmetic != null) - addStringToTooltip( - String.format(StatCollector.translateToLocal("botaniamisc.hasCosmetic"), cosmetic.getDisplayName()), - par3List); - - if (hasPhantomInk(par1ItemStack)) - addStringToTooltip(StatCollector.translateToLocal("botaniamisc.hasPhantomInk"), par3List); - } - - void addStringToTooltip(String s, List tooltip) { - tooltip.add(s.replaceAll("&", "\u00a7")); - } - - @Override - public boolean canEquip(ItemStack stack, EntityLivingBase player) { - return true; - } - - @Override - public boolean canUnequip(ItemStack stack, EntityLivingBase player) { - return true; - } - - @Override - public void onWornTick(ItemStack stack, EntityLivingBase player) { - if (getLastPlayerHashcode(stack) != player.hashCode()) { - onEquippedOrLoadedIntoWorld(stack, player); - setLastPlayerHashcode(stack, player.hashCode()); - } - } - - @Override - public void onEquipped(ItemStack stack, EntityLivingBase player) { - if (player != null) { - if (!player.worldObj.isRemote) player.worldObj.playSoundAtEntity(player, "botania:equipBauble", 0.1F, 1.3F); - - if (player instanceof EntityPlayer) ((EntityPlayer) player).addStat(ModAchievements.baubleWear, 1); - - onEquippedOrLoadedIntoWorld(stack, player); - setLastPlayerHashcode(stack, player.hashCode()); - } - } - - public void onEquippedOrLoadedIntoWorld(ItemStack stack, EntityLivingBase player) { - // NO-OP - } - - @Override - public void onUnequipped(ItemStack stack, EntityLivingBase player) { - // NO-OP - } - - @Override - public ItemStack getCosmeticItem(ItemStack stack) { - NBTTagCompound cmp = ItemNBTHelper.getCompound(stack, TAG_COSMETIC_ITEM, true); - if (cmp == null) return null; - return ItemStack.loadItemStackFromNBT(cmp); - } - - @Override - public void setCosmeticItem(ItemStack stack, ItemStack cosmetic) { - NBTTagCompound cmp = new NBTTagCompound(); - if (cosmetic != null) cosmetic.writeToNBT(cmp); - ItemNBTHelper.setCompound(stack, TAG_COSMETIC_ITEM, cmp); - } - - @Override - public boolean hasContainerItem(ItemStack stack) { - return getContainerItem(stack) != null; - } - - @Override - public ItemStack getContainerItem(ItemStack itemStack) { - return getCosmeticItem(itemStack); - } - - @Override - public boolean doesContainerItemLeaveCraftingGrid(ItemStack p_77630_1_) { - return false; - } - - public static UUID getBaubleUUID(ItemStack stack) { - long most = ItemNBTHelper.getLong(stack, TAG_BAUBLE_UUID_MOST, 0); - if (most == 0) { - UUID uuid = UUID.randomUUID(); - ItemNBTHelper.setLong(stack, TAG_BAUBLE_UUID_MOST, uuid.getMostSignificantBits()); - ItemNBTHelper.setLong(stack, TAG_BAUBLE_UUID_LEAST, uuid.getLeastSignificantBits()); - return getBaubleUUID(stack); - } - - long least = ItemNBTHelper.getLong(stack, TAG_BAUBLE_UUID_LEAST, 0); - return new UUID(most, least); - } - - public static int getLastPlayerHashcode(ItemStack stack) { - return ItemNBTHelper.getInt(stack, TAG_HASHCODE, 0); - } - - public static void setLastPlayerHashcode(ItemStack stack, int hash) { - ItemNBTHelper.setInt(stack, TAG_HASHCODE, hash); - } - - @Override - public boolean hasPhantomInk(ItemStack stack) { - return ItemNBTHelper.getBoolean(stack, TAG_PHANTOM_INK, false); - } - - @Override - public void setPhantomInk(ItemStack stack, boolean ink) { - ItemNBTHelper.setBoolean(stack, TAG_PHANTOM_INK, ink); - } - - @Override - @Optional.Method(modid = "Thaumcraft") - public int getRunicCharge(ItemStack itemstack) { - return 0; - } + private static final String TAG_HASHCODE = "playerHashcode"; + private static final String TAG_BAUBLE_UUID_MOST = "baubleUUIDMost"; + private static final String TAG_BAUBLE_UUID_LEAST = "baubleUUIDLeast"; + private static final String TAG_COSMETIC_ITEM = "cosmeticItem"; + private static final String TAG_PHANTOM_INK = "phantomInk"; + + public ItemBauble(String name) { + super(); + setMaxStackSize(1); + setUnlocalizedName(name); + } + + @Override + public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer) { + if(!EntityDoppleganger.isTruePlayer(par3EntityPlayer)) + return par1ItemStack; + + if(canEquip(par1ItemStack, par3EntityPlayer)) { + InventoryBaubles baubles = PlayerHandler.getPlayerBaubles(par3EntityPlayer); + for(int i = 0; i < baubles.getSizeInventory(); i++) { + if(baubles.isItemValidForSlot(i, par1ItemStack)) { + ItemStack stackInSlot = baubles.getStackInSlot(i); + if(stackInSlot == null || ((IBauble) stackInSlot.getItem()).canUnequip(stackInSlot, par3EntityPlayer)) { + if(!par2World.isRemote) { + baubles.setInventorySlotContents(i, par1ItemStack.copy()); + if(!par3EntityPlayer.capabilities.isCreativeMode) + par3EntityPlayer.inventory.setInventorySlotContents(par3EntityPlayer.inventory.currentItem, null); + } + + if(stackInSlot != null) { + ((IBauble) stackInSlot.getItem()).onUnequipped(stackInSlot, par3EntityPlayer); + return stackInSlot.copy(); + } + break; + } + } + } + } + + return par1ItemStack; + } + + @Override + @SideOnly(Side.CLIENT) + public void addInformation(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, List par3List, boolean par4) { + if(GuiScreen.isShiftKeyDown()) + addHiddenTooltip(par1ItemStack, par2EntityPlayer, par3List, par4); + else addStringToTooltip(StatCollector.translateToLocal("botaniamisc.shiftinfo"), par3List); + } + + public void addHiddenTooltip(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, List par3List, boolean par4) { + BaubleType type = getBaubleType(par1ItemStack); + addStringToTooltip(StatCollector.translateToLocal("botania.baubletype." + type.name().toLowerCase()), par3List); + + String key = vazkii.botania.client.core.helper.RenderHelper.getKeyDisplayString("Baubles Inventory"); + + if(key != null) + addStringToTooltip(StatCollector.translateToLocal("botania.baubletooltip").replaceAll("%key%", key), par3List); + + ItemStack cosmetic = getCosmeticItem(par1ItemStack); + if(cosmetic != null) + addStringToTooltip(String.format(StatCollector.translateToLocal("botaniamisc.hasCosmetic"), cosmetic.getDisplayName()), par3List); + + if(hasPhantomInk(par1ItemStack)) + addStringToTooltip(StatCollector.translateToLocal("botaniamisc.hasPhantomInk"), par3List); + } + + void addStringToTooltip(String s, List tooltip) { + tooltip.add(s.replaceAll("&", "\u00a7")); + } + + @Override + public boolean canEquip(ItemStack stack, EntityLivingBase player) { + return true; + } + + @Override + public boolean canUnequip(ItemStack stack, EntityLivingBase player) { + return true; + } + + @Override + public void onWornTick(ItemStack stack, EntityLivingBase player) { + if(getLastPlayerHashcode(stack) != player.hashCode()) { + onEquippedOrLoadedIntoWorld(stack, player); + setLastPlayerHashcode(stack, player.hashCode()); + } + } + + @Override + public void onEquipped(ItemStack stack, EntityLivingBase player) { + if(player != null) { + if(!player.worldObj.isRemote) + player.worldObj.playSoundAtEntity(player, "botania:equipBauble", 0.1F, 1.3F); + + if(player instanceof EntityPlayer) + ((EntityPlayer) player).addStat(ModAchievements.baubleWear, 1); + + onEquippedOrLoadedIntoWorld(stack, player); + setLastPlayerHashcode(stack, player.hashCode()); + } + } + + public void onEquippedOrLoadedIntoWorld(ItemStack stack, EntityLivingBase player) { + // NO-OP + } + + @Override + public void onUnequipped(ItemStack stack, EntityLivingBase player) { + // NO-OP + } + + @Override + public ItemStack getCosmeticItem(ItemStack stack) { + NBTTagCompound cmp = ItemNBTHelper.getCompound(stack, TAG_COSMETIC_ITEM, true); + if(cmp == null) + return null; + return ItemStack.loadItemStackFromNBT(cmp); + } + + @Override + public void setCosmeticItem(ItemStack stack, ItemStack cosmetic) { + NBTTagCompound cmp = new NBTTagCompound(); + if(cosmetic != null) + cosmetic.writeToNBT(cmp); + ItemNBTHelper.setCompound(stack, TAG_COSMETIC_ITEM, cmp); + } + + @Override + public boolean hasContainerItem(ItemStack stack) { + return getContainerItem(stack) != null; + } + + @Override + public ItemStack getContainerItem(ItemStack itemStack) { + return getCosmeticItem(itemStack); + } + + @Override + public boolean doesContainerItemLeaveCraftingGrid(ItemStack p_77630_1_) { + return false; + } + + public static UUID getBaubleUUID(ItemStack stack) { + long most = ItemNBTHelper.getLong(stack, TAG_BAUBLE_UUID_MOST, 0); + if(most == 0) { + UUID uuid = UUID.randomUUID(); + ItemNBTHelper.setLong(stack, TAG_BAUBLE_UUID_MOST, uuid.getMostSignificantBits()); + ItemNBTHelper.setLong(stack, TAG_BAUBLE_UUID_LEAST, uuid.getLeastSignificantBits()); + return getBaubleUUID(stack); + } + + long least = ItemNBTHelper.getLong(stack, TAG_BAUBLE_UUID_LEAST, 0); + return new UUID(most, least); + } + + public static int getLastPlayerHashcode(ItemStack stack) { + return ItemNBTHelper.getInt(stack, TAG_HASHCODE, 0); + } + + public static void setLastPlayerHashcode(ItemStack stack, int hash) { + ItemNBTHelper.setInt(stack, TAG_HASHCODE, hash); + } + + @Override + public boolean hasPhantomInk(ItemStack stack) { + return ItemNBTHelper.getBoolean(stack, TAG_PHANTOM_INK, false); + } + + @Override + public void setPhantomInk(ItemStack stack, boolean ink) { + ItemNBTHelper.setBoolean(stack, TAG_PHANTOM_INK, ink); + } + + @Override + @Optional.Method(modid = "Thaumcraft") + public int getRunicCharge(ItemStack itemstack) { + return 0; + } } diff --git a/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemBaubleCosmetic.java b/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemBaubleCosmetic.java index 368228babb..6cf98d16b1 100644 --- a/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemBaubleCosmetic.java +++ b/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemBaubleCosmetic.java @@ -2,17 +2,16 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Feb 22, 2015, 2:01:01 PM (GMT)] */ package vazkii.botania.common.item.equipment.bauble; -import baubles.api.BaubleType; -import cpw.mods.fml.common.registry.GameRegistry; import java.util.List; + import net.minecraft.client.Minecraft; import net.minecraft.client.renderer.ItemRenderer; import net.minecraft.client.renderer.Tessellator; @@ -27,311 +26,316 @@ import net.minecraftforge.client.event.RenderPlayerEvent; import net.minecraftforge.oredict.RecipeSorter; import net.minecraftforge.oredict.RecipeSorter.Category; + import org.lwjgl.opengl.GL11; + import vazkii.botania.api.item.ICosmeticBauble; import vazkii.botania.client.core.helper.IconHelper; import vazkii.botania.common.crafting.recipe.CosmeticAttachRecipe; import vazkii.botania.common.crafting.recipe.CosmeticRemoveRecipe; import vazkii.botania.common.lib.LibItemNames; +import baubles.api.BaubleType; +import cpw.mods.fml.common.registry.GameRegistry; public class ItemBaubleCosmetic extends ItemBauble implements ICosmeticBauble { - private static final int SUBTYPES = 32; - IIcon[] icons; + private static final int SUBTYPES = 32; + IIcon[] icons; - public ItemBaubleCosmetic() { - super(LibItemNames.COSMETIC); - setHasSubtypes(true); + public ItemBaubleCosmetic() { + super(LibItemNames.COSMETIC); + setHasSubtypes(true); - GameRegistry.addRecipe(new CosmeticAttachRecipe()); - GameRegistry.addRecipe(new CosmeticRemoveRecipe()); - RecipeSorter.register("botania:cosmeticAttach", CosmeticAttachRecipe.class, Category.SHAPELESS, ""); - RecipeSorter.register("botania:cosmeticRemove", CosmeticRemoveRecipe.class, Category.SHAPELESS, ""); - } + GameRegistry.addRecipe(new CosmeticAttachRecipe()); + GameRegistry.addRecipe(new CosmeticRemoveRecipe()); + RecipeSorter.register("botania:cosmeticAttach", CosmeticAttachRecipe.class, Category.SHAPELESS, ""); + RecipeSorter.register("botania:cosmeticRemove", CosmeticRemoveRecipe.class, Category.SHAPELESS, ""); + } - @Override - public void registerIcons(IIconRegister par1IconRegister) { - icons = new IIcon[SUBTYPES]; - for (int i = 0; i < SUBTYPES; i++) icons[i] = IconHelper.forItem(par1IconRegister, this, i); - } + @Override + public void registerIcons(IIconRegister par1IconRegister) { + icons = new IIcon[SUBTYPES]; + for(int i = 0; i < SUBTYPES; i++) + icons[i] = IconHelper.forItem(par1IconRegister, this, i); + } - @Override - public void getSubItems(Item item, CreativeTabs tab, List list) { - for (int i = 0; i < SUBTYPES; i++) list.add(new ItemStack(item, 1, i)); - } + @Override + public void getSubItems(Item item, CreativeTabs tab, List list) { + for(int i = 0; i < SUBTYPES; i++) + list.add(new ItemStack(item, 1, i)); + } - @Override - public IIcon getIconFromDamage(int dmg) { - return icons[Math.min(SUBTYPES - 1, dmg)]; - } + @Override + public IIcon getIconFromDamage(int dmg) { + return icons[Math.min(SUBTYPES - 1, dmg)]; + } - @Override - public String getUnlocalizedName(ItemStack par1ItemStack) { - return super.getUnlocalizedName(par1ItemStack) + par1ItemStack.getItemDamage(); - } + @Override + public String getUnlocalizedName(ItemStack par1ItemStack) { + return super.getUnlocalizedName(par1ItemStack) + par1ItemStack.getItemDamage(); + } - @Override - public void addHiddenTooltip(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, List par3List, boolean par4) { - addStringToTooltip(StatCollector.translateToLocal("botaniamisc.cosmeticBauble"), par3List); - super.addHiddenTooltip(par1ItemStack, par2EntityPlayer, par3List, par4); - } + @Override + public void addHiddenTooltip(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, List par3List, boolean par4) { + addStringToTooltip(StatCollector.translateToLocal("botaniamisc.cosmeticBauble"), par3List); + super.addHiddenTooltip(par1ItemStack, par2EntityPlayer, par3List, par4); + } - @Override - public BaubleType getBaubleType(ItemStack arg0) { - return BaubleType.AMULET; - } + @Override + public BaubleType getBaubleType(ItemStack arg0) { + return BaubleType.AMULET; + } - @Override - public void onPlayerBaubleRender(ItemStack stack, RenderPlayerEvent event, RenderType type) { - Minecraft.getMinecraft().renderEngine.bindTexture(TextureMap.locationItemsTexture); - if (type == RenderType.HEAD) { - Helper.translateToHeadLevel(event.entityPlayer); - switch (stack.getItemDamage()) { - case 2: - faceTranslate(); - scale(0.75F); - GL11.glTranslatef(0.04F, -0.5F, 0F); - renderIcon(2); - break; - case 4: - faceTranslate(); - scale(0.75F); - GL11.glTranslatef(0.04F, -0.5F, 0F); - renderIcon(4); - break; - case 5: - faceTranslate(); - scale(0.35F); - GL11.glTranslatef(0.3F, -0.5F, 0F); - renderIcon(5); - break; - case 6: - faceTranslate(); - scale(0.35F); - GL11.glTranslatef(0.9F, -0.5F, 0F); - renderIcon(6); - break; - case 7: - faceTranslate(); - scale(0.6F); - GL11.glTranslatef(0.2F, 0.3F, 0.6F); - renderIcon(7); - break; - case 8: - faceTranslate(); - GL11.glRotatef(90F, 0F, 1F, 0F); - scale(0.6F); - GL11.glTranslatef(-0.9F, 0F, 0.2F); - renderIcon(8); - break; - case 9: - faceTranslate(); - GL11.glRotatef(90F, 0F, 1F, 0F); - scale(0.6F); - GL11.glTranslatef(-0.9F, -0.2F, 0.2F); - renderIcon(9); - GL11.glTranslatef(0F, 0F, 1F); - renderIcon(9); - break; - case 10: - faceTranslate(); - GL11.glRotatef(90F, 0F, 1F, 0F); - scale(0.4F); - GL11.glTranslatef(-0.5F, -0.1F, 0.3F); - GL11.glRotatef(120F, 0F, 1F, 0F); - renderIcon(10); - GL11.glRotatef(-100F, 0F, 1F, 0F); - renderIcon(10); - break; - case 11: - faceTranslate(); - scale(0.6F); - GL11.glTranslatef(0.2F, -0.1F, 0.6F); - renderIcon(11); - break; - case 15: - faceTranslate(); - GL11.glTranslatef(-0.1F, -0.55F, 0F); - renderIcon(15); - break; - case 17: - faceTranslate(); - scale(0.35F); - GL11.glTranslatef(0.3F, -0.6F, 0F); - renderIcon(17); - break; - case 18: - faceTranslate(); - scale(0.75F); - GL11.glRotatef(90F, 0F, 1F, 0F); - GL11.glTranslatef(-0.3F, 0.1F, 0.55F); - renderIcon(18); - break; - case 19: - faceTranslate(); - scale(0.6F); - GL11.glTranslatef(0.2F, -0.2F, 0.1F); - renderIcon(19); - break; - case 20: - faceTranslate(); - scale(0.25F); - GL11.glTranslatef(0.4F, 0.5F, -0.1F); - renderIcon(20); - GL11.glTranslatef(1.4F, 0F, 0F); - renderIcon(20); - break; - case 22: - faceTranslate(); - scale(0.75F); - GL11.glTranslatef(0.04F, -0.4F, 0F); - renderIcon(22); - break; - case 23: - faceTranslate(); - scale(0.75F); - GL11.glTranslatef(0.04F, -0.4F, 0F); - renderIcon(23); - break; - case 24: - faceTranslate(); - scale(0.6F); - GL11.glTranslatef(0.5F, 0F, 0.1F); - GL11.glRotatef(60F, 0F, 0F, 1F); - renderIcon(24); - break; - case 25: - faceTranslate(); - scale(0.75F); - GL11.glTranslatef(0.04F, -0.5F, 0F); - renderIcon(25); - break; - case 26: - faceTranslate(); - GL11.glTranslatef(-0.1F, -0.4F, 0F); - GL11.glEnable(GL11.GL_BLEND); - GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); - GL11.glColor4f(1F, 1F, 1F, 0.7F); - renderIcon(26); - break; - case 27: - faceTranslate(); - scale(0.75F); - GL11.glTranslatef(0.04F, -0.65F, 0F); - renderIcon(27); - break; - case 28: - faceTranslate(); - scale(0.25F); - GL11.glTranslatef(1.55F, -0.2F, -0.1F); - renderIcon(28); - GL11.glRotatef(180F, 0F, 1F, 0F); - GL11.glTranslatef(-0.1F, 0F, 0.1F); - renderIcon(28); - break; - case 30: - faceTranslate(); - scale(0.75F); - GL11.glTranslatef(0.04F, -0.4F, 0F); - renderIcon(30); - break; - case 31: - faceTranslate(); - scale(0.5F); - GL11.glTranslatef(0.3F, 0.7F, 0.5F); - renderIcon(31); - break; - } - } else { - Helper.rotateIfSneaking(event.entityPlayer); - switch (stack.getItemDamage()) { - case 0: - chestTranslate(); - scale(0.5F); - GL11.glTranslatef(0.5F, 0.7F, 0F); - renderIcon(0); - break; - case 1: - chestTranslate(); - scale(0.75F); - GL11.glTranslatef(0.15F, -0.1F, 0F); - renderIcon(1); - break; - case 3: - chestTranslate(); - scale(0.6F); - GL11.glTranslatef(0.35F, 0.3F, 0F); - renderIcon(3); - break; - case 12: - chestTranslate(); - scale(0.225F); - GL11.glTranslatef(1.2F, 1.9F, 0F); - renderIcon(12); - break; - case 13: - chestTranslate(); - GL11.glRotatef(-90F, 0F, 1F, 0F); - scale(0.5F); - GL11.glTranslatef(-1.3F, -0.4F, -1F); - renderIcon(13); - break; - case 14: - chestTranslate(); - scale(0.5F); - GL11.glTranslatef(2.3F, 1F, -0.05F); - GL11.glRotatef(180F, 0F, 1F, 0F); - renderIcon(14); - GL11.glRotatef(180F, 0F, 1F, 0F); - GL11.glColor4f(0F, 0F, 0.3F, 1F); - GL11.glTranslatef(-2.6F, 0F, 0.05F); - renderIcon(14); - break; - case 16: - chestTranslate(); - scale(0.225F); - GL11.glTranslatef(2.3F, 1.9F, 0F); - renderIcon(16); - break; - case 21: - chestTranslate(); - scale(0.3F); - GL11.glTranslatef(1.2F, 0.5F, 0F); - renderIcon(21); - break; - case 29: - chestTranslate(); - scale(0.8F); - GL11.glTranslatef(0.2F, -0.2F, -0.35F); - GL11.glRotatef(10F, 0F, 0F, 1F); - renderIcon(29); - break; - } - } - } + @Override + public void onPlayerBaubleRender(ItemStack stack, RenderPlayerEvent event, RenderType type) { + Minecraft.getMinecraft().renderEngine.bindTexture(TextureMap.locationItemsTexture); + if(type == RenderType.HEAD) { + Helper.translateToHeadLevel(event.entityPlayer); + switch(stack.getItemDamage()) { + case 2: + faceTranslate(); + scale(0.75F); + GL11.glTranslatef(0.04F, -0.5F, 0F); + renderIcon(2); + break; + case 4: + faceTranslate(); + scale(0.75F); + GL11.glTranslatef(0.04F, -0.5F, 0F); + renderIcon(4); + break; + case 5: + faceTranslate(); + scale(0.35F); + GL11.glTranslatef(0.3F, -0.5F, 0F); + renderIcon(5); + break; + case 6: + faceTranslate(); + scale(0.35F); + GL11.glTranslatef(0.9F, -0.5F, 0F); + renderIcon(6); + break; + case 7: + faceTranslate(); + scale(0.6F); + GL11.glTranslatef(0.2F, 0.3F, 0.6F); + renderIcon(7); + break; + case 8: + faceTranslate(); + GL11.glRotatef(90F, 0F, 1F, 0F); + scale(0.6F); + GL11.glTranslatef(-0.9F, 0F, 0.2F); + renderIcon(8); + break; + case 9: + faceTranslate(); + GL11.glRotatef(90F, 0F, 1F, 0F); + scale(0.6F); + GL11.glTranslatef(-0.9F, -0.2F, 0.2F); + renderIcon(9); + GL11.glTranslatef(0F, 0F, 1F); + renderIcon(9); + break; + case 10: + faceTranslate(); + GL11.glRotatef(90F, 0F, 1F, 0F); + scale(0.4F); + GL11.glTranslatef(-0.5F, -0.1F, 0.3F); + GL11.glRotatef(120F, 0F, 1F, 0F); + renderIcon(10); + GL11.glRotatef(-100F, 0F, 1F, 0F); + renderIcon(10); + break; + case 11: + faceTranslate(); + scale(0.6F); + GL11.glTranslatef(0.2F, -0.1F, 0.6F); + renderIcon(11); + break; + case 15: + faceTranslate(); + GL11.glTranslatef(-0.1F, -0.55F, 0F); + renderIcon(15); + break; + case 17: + faceTranslate(); + scale(0.35F); + GL11.glTranslatef(0.3F, -0.6F, 0F); + renderIcon(17); + break; + case 18: + faceTranslate(); + scale(0.75F); + GL11.glRotatef(90F, 0F, 1F, 0F); + GL11.glTranslatef(-0.3F, 0.1F, 0.55F); + renderIcon(18); + break; + case 19: + faceTranslate(); + scale(0.6F); + GL11.glTranslatef(0.2F, -0.2F, 0.1F); + renderIcon(19); + break; + case 20: + faceTranslate(); + scale(0.25F); + GL11.glTranslatef(0.4F, 0.5F, -0.1F); + renderIcon(20); + GL11.glTranslatef(1.4F, 0F, 0F); + renderIcon(20); + break; + case 22: + faceTranslate(); + scale(0.75F); + GL11.glTranslatef(0.04F, -0.4F, 0F); + renderIcon(22); + break; + case 23: + faceTranslate(); + scale(0.75F); + GL11.glTranslatef(0.04F, -0.4F, 0F); + renderIcon(23); + break; + case 24: + faceTranslate(); + scale(0.6F); + GL11.glTranslatef(0.5F, 0F, 0.1F); + GL11.glRotatef(60F, 0F, 0F, 1F); + renderIcon(24); + break; + case 25: + faceTranslate(); + scale(0.75F); + GL11.glTranslatef(0.04F, -0.5F, 0F); + renderIcon(25); + break; + case 26: + faceTranslate(); + GL11.glTranslatef(-0.1F, -0.4F, 0F); + GL11.glEnable(GL11.GL_BLEND); + GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); + GL11.glColor4f(1F, 1F, 1F, 0.7F); + renderIcon(26); + break; + case 27: + faceTranslate(); + scale(0.75F); + GL11.glTranslatef(0.04F, -0.65F, 0F); + renderIcon(27); + break; + case 28: + faceTranslate(); + scale(0.25F); + GL11.glTranslatef(1.55F, -0.2F, -0.1F); + renderIcon(28); + GL11.glRotatef(180F, 0F, 1F, 0F); + GL11.glTranslatef(-0.1F, 0F, 0.1F); + renderIcon(28); + break; + case 30: + faceTranslate(); + scale(0.75F); + GL11.glTranslatef(0.04F, -0.4F, 0F); + renderIcon(30); + break; + case 31: + faceTranslate(); + scale(0.5F); + GL11.glTranslatef(0.3F, 0.7F, 0.5F); + renderIcon(31); + break; + } + } else { + Helper.rotateIfSneaking(event.entityPlayer); + switch(stack.getItemDamage()) { + case 0: + chestTranslate(); + scale(0.5F); + GL11.glTranslatef(0.5F, 0.7F, 0F); + renderIcon(0); + break; + case 1: + chestTranslate(); + scale(0.75F); + GL11.glTranslatef(0.15F, -0.1F, 0F); + renderIcon(1); + break; + case 3: + chestTranslate(); + scale(0.6F); + GL11.glTranslatef(0.35F, 0.3F, 0F); + renderIcon(3); + break; + case 12: + chestTranslate(); + scale(0.225F); + GL11.glTranslatef(1.2F, 1.9F, 0F); + renderIcon(12); + break; + case 13: + chestTranslate(); + GL11.glRotatef(-90F, 0F, 1F, 0F); + scale(0.5F); + GL11.glTranslatef(-1.3F, -0.4F, -1F); + renderIcon(13); + break; + case 14: + chestTranslate(); + scale(0.5F); + GL11.glTranslatef(2.3F, 1F, -0.05F); + GL11.glRotatef(180F, 0F, 1F, 0F); + renderIcon(14); + GL11.glRotatef(180F, 0F, 1F, 0F); + GL11.glColor4f(0F, 0F, 0.3F, 1F); + GL11.glTranslatef(-2.6F, 0F, 0.05F); + renderIcon(14); + break; + case 16: + chestTranslate(); + scale(0.225F); + GL11.glTranslatef(2.3F, 1.9F, 0F); + renderIcon(16); + break; + case 21: + chestTranslate(); + scale(0.3F); + GL11.glTranslatef(1.2F, 0.5F, 0F); + renderIcon(21); + break; + case 29: + chestTranslate(); + scale(0.8F); + GL11.glTranslatef(0.2F, -0.2F, -0.35F); + GL11.glRotatef(10F, 0F, 0F, 1F); + renderIcon(29); + break; + } + } + } - public void faceTranslate() { - GL11.glRotatef(90F, 0F, 1F, 0F); - GL11.glRotatef(180F, 1F, 0F, 0F); - GL11.glTranslatef(-0.4F, 0.1F, -0.25F); - } + public void faceTranslate() { + GL11.glRotatef(90F, 0F, 1F, 0F); + GL11.glRotatef(180F, 1F, 0F, 0F); + GL11.glTranslatef(-0.4F, 0.1F, -0.25F); + } - public void chestTranslate() { - GL11.glRotatef(180F, 1F, 0F, 0F); - GL11.glTranslatef(-0.5F, -0.7F, 0.15F); - } + public void chestTranslate() { + GL11.glRotatef(180F, 1F, 0F, 0F); + GL11.glTranslatef(-0.5F, -0.7F, 0.15F); + } - public void scale(float f) { - GL11.glScalef(f, f, f); - } + public void scale(float f) { + GL11.glScalef(f, f, f); + } - public void renderIcon(int i) { - IIcon icon = icons[i]; - float f = icon.getMinU(); - float f1 = icon.getMaxU(); - float f2 = icon.getMinV(); - float f3 = icon.getMaxV(); - ItemRenderer.renderItemIn2D( - Tessellator.instance, f1, f2, f, f3, icon.getIconWidth(), icon.getIconHeight(), 1F / 16F); - } + public void renderIcon(int i) { + IIcon icon = icons[i]; + float f = icon.getMinU(); + float f1 = icon.getMaxU(); + float f2 = icon.getMinV(); + float f3 = icon.getMaxV(); + ItemRenderer.renderItemIn2D(Tessellator.instance, f1, f2, f, f3, icon.getIconWidth(), icon.getIconHeight(), 1F / 16F); + } } diff --git a/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemBaubleModifier.java b/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemBaubleModifier.java index b2695a1f24..d920e453e5 100644 --- a/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemBaubleModifier.java +++ b/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemBaubleModifier.java @@ -2,41 +2,43 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Apr 26, 2014, 10:28:39 PM (GMT)] */ package vazkii.botania.common.item.equipment.bauble; -import com.google.common.collect.HashMultimap; -import com.google.common.collect.Multimap; import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.ai.attributes.AttributeModifier; import net.minecraft.item.ItemStack; +import com.google.common.collect.HashMultimap; +import com.google.common.collect.Multimap; + public abstract class ItemBaubleModifier extends ItemBauble { - Multimap attributes = HashMultimap.create(); + Multimap attributes = HashMultimap.create(); + + public ItemBaubleModifier(String name) { + super(name); + } - public ItemBaubleModifier(String name) { - super(name); - } + @Override + public void onEquippedOrLoadedIntoWorld(ItemStack stack, EntityLivingBase player) { + attributes.clear(); + fillModifiers(attributes, stack); + player.getAttributeMap().applyAttributeModifiers(attributes); + } - @Override - public void onEquippedOrLoadedIntoWorld(ItemStack stack, EntityLivingBase player) { - attributes.clear(); - fillModifiers(attributes, stack); - player.getAttributeMap().applyAttributeModifiers(attributes); - } + @Override + public void onUnequipped(ItemStack stack, EntityLivingBase player) { + attributes.clear(); + fillModifiers(attributes, stack); + player.getAttributeMap().removeAttributeModifiers(attributes); + } - @Override - public void onUnequipped(ItemStack stack, EntityLivingBase player) { - attributes.clear(); - fillModifiers(attributes, stack); - player.getAttributeMap().removeAttributeModifiers(attributes); - } + abstract void fillModifiers(Multimap attributes, ItemStack stack); - abstract void fillModifiers(Multimap attributes, ItemStack stack); } diff --git a/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemBloodPendant.java b/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemBloodPendant.java index ad46339b75..5a7dcd66b9 100644 --- a/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemBloodPendant.java +++ b/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemBloodPendant.java @@ -2,17 +2,17 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Nov 6, 2014, 5:11:23 PM (GMT)] */ package vazkii.botania.common.item.equipment.bauble; -import baubles.api.BaubleType; import java.awt.Color; import java.util.List; + import net.minecraft.client.Minecraft; import net.minecraft.client.renderer.ItemRenderer; import net.minecraft.client.renderer.OpenGlHelper; @@ -30,7 +30,9 @@ import net.minecraft.util.IIcon; import net.minecraft.util.StatCollector; import net.minecraftforge.client.event.RenderPlayerEvent; + import org.lwjgl.opengl.GL11; + import vazkii.botania.api.BotaniaAPI; import vazkii.botania.api.brew.Brew; import vazkii.botania.api.brew.IBrewContainer; @@ -42,180 +44,170 @@ import vazkii.botania.client.core.helper.IconHelper; import vazkii.botania.common.core.helper.ItemNBTHelper; import vazkii.botania.common.lib.LibItemNames; +import baubles.api.BaubleType; public class ItemBloodPendant extends ItemBauble implements IBrewContainer, IBrewItem, IManaUsingItem, IBaubleRender { - private static final String TAG_BREW_KEY = "brewKey"; - - IIcon[] icons; - - public ItemBloodPendant() { - super(LibItemNames.BLOOD_PENDANT); - setMaxStackSize(1); - } - - @Override - public void getSubItems(Item item, CreativeTabs tab, List list) { - super.getSubItems(item, tab, list); - for (String s : BotaniaAPI.brewMap.keySet()) { - ItemStack brewStack = getItemForBrew(BotaniaAPI.brewMap.get(s), new ItemStack(this)); - if (brewStack != null) list.add(brewStack); - } - } - - @Override - public void registerIcons(IIconRegister par1IconRegister) { - icons = new IIcon[4]; - for (int i = 0; i < 4; i++) icons[i] = IconHelper.forItem(par1IconRegister, this, i); - } - - @Override - public boolean requiresMultipleRenderPasses() { - return true; - } - - @Override - public IIcon getIcon(ItemStack stack, int pass) { - return icons[pass]; - } - - @Override - public int getColorFromItemStack(ItemStack stack, int pass) { - if (pass == 0) return 0xFFFFFF; - - Brew brew = getBrew(stack); - if (brew == BotaniaAPI.fallbackBrew) return 0xC6000E; - - Color color = new Color(brew.getColor(stack)); - int add = (int) (Math.sin(ClientTickHandler.ticksInGame * 0.2) * 24); - - int r = Math.max(0, Math.min(255, color.getRed() + add)); - int g = Math.max(0, Math.min(255, color.getGreen() + add)); - int b = Math.max(0, Math.min(255, color.getBlue() + add)); - - return r << 16 | g << 8 | b; - } - - @Override - public void addHiddenTooltip(ItemStack stack, EntityPlayer player, List list, boolean adv) { - super.addHiddenTooltip(stack, player, list, adv); - - Brew brew = getBrew(stack); - if (brew == BotaniaAPI.fallbackBrew) { - addStringToTooltip( - EnumChatFormatting.LIGHT_PURPLE + StatCollector.translateToLocal("botaniamisc.notInfused"), list); - return; - } - - addStringToTooltip( - EnumChatFormatting.LIGHT_PURPLE - + String.format( - StatCollector.translateToLocal("botaniamisc.brewOf"), - StatCollector.translateToLocal(brew.getUnlocalizedName(stack))), - list); - for (PotionEffect effect : brew.getPotionEffects(stack)) { - Potion potion = Potion.potionTypes[effect.getPotionID()]; - EnumChatFormatting format = potion.isBadEffect() ? EnumChatFormatting.RED : EnumChatFormatting.GRAY; - addStringToTooltip( - " " + format + StatCollector.translateToLocal(effect.getEffectName()) - + (effect.getAmplifier() == 0 - ? "" - : " " - + StatCollector.translateToLocal( - "botania.roman" + (effect.getAmplifier() + 1))), - list); - } - } - - @Override - public BaubleType getBaubleType(ItemStack arg0) { - return BaubleType.AMULET; - } - - @Override - public void onWornTick(ItemStack stack, EntityLivingBase player) { - Brew brew = getBrew(stack); - if (brew != BotaniaAPI.fallbackBrew && player instanceof EntityPlayer && !player.worldObj.isRemote) { - EntityPlayer eplayer = (EntityPlayer) player; - PotionEffect effect = brew.getPotionEffects(stack).get(0); - float cost = (float) brew.getManaCost(stack) / effect.getDuration() / (1 + effect.getAmplifier()) * 2.5F; - boolean doRand = cost < 1; - if (ManaItemHandler.requestManaExact(stack, eplayer, (int) Math.ceil(cost), false)) { - PotionEffect currentEffect = player.getActivePotionEffect(Potion.potionTypes[effect.getPotionID()]); - boolean nightVision = effect.getPotionID() == Potion.nightVision.id; - if (currentEffect == null || currentEffect.getDuration() < (nightVision ? 205 : 3)) { - PotionEffect applyEffect = - new PotionEffect(effect.getPotionID(), nightVision ? 285 : 80, effect.getAmplifier(), true); - player.addPotionEffect(applyEffect); - } - - if (!doRand || Math.random() < cost) - ManaItemHandler.requestManaExact(stack, eplayer, (int) Math.ceil(cost), true); - } - } - } - - @Override - public Brew getBrew(ItemStack stack) { - String key = ItemNBTHelper.getString(stack, TAG_BREW_KEY, ""); - return BotaniaAPI.getBrewFromKey(key); - } - - public static void setBrew(ItemStack stack, Brew brew) { - setBrew(stack, brew.getKey()); - } - - public static void setBrew(ItemStack stack, String brew) { - ItemNBTHelper.setString(stack, TAG_BREW_KEY, brew); - } - - @Override - public ItemStack getItemForBrew(Brew brew, ItemStack stack) { - if (!brew.canInfuseBloodPendant() - || brew.getPotionEffects(stack).size() != 1 - || Potion.potionTypes[brew.getPotionEffects(stack).get(0).getPotionID()].isInstant()) return null; - - ItemStack brewStack = new ItemStack(this); - setBrew(brewStack, brew); - return brewStack; - } - - @Override - public int getManaCost(Brew brew, ItemStack stack) { - return brew.getManaCost() * 10; - } - - @Override - public boolean usesMana(ItemStack stack) { - return getBrew(stack) != BotaniaAPI.fallbackBrew; - } - - @Override - public void onPlayerBaubleRender(ItemStack stack, RenderPlayerEvent event, RenderType type) { - if (type == RenderType.BODY) { - Minecraft.getMinecraft().renderEngine.bindTexture(TextureMap.locationItemsTexture); - Helper.rotateIfSneaking(event.entityPlayer); - boolean armor = event.entityPlayer.getCurrentArmor(2) != null; - GL11.glRotatef(180F, 1F, 0F, 0F); - GL11.glTranslatef(-0.26F, -0.4F, armor ? 0.2F : 0.15F); - GL11.glScalef(0.5F, 0.5F, 0.5F); - - for (int i = 2; i < 4; i++) { - IIcon icon = icons[i]; - float f = icon.getMinU(); - float f1 = icon.getMaxU(); - float f2 = icon.getMinV(); - float f3 = icon.getMaxV(); - ItemRenderer.renderItemIn2D( - Tessellator.instance, f1, f2, f, f3, icon.getIconWidth(), icon.getIconHeight(), 1F / 32F); - - Color color = new Color(getColorFromItemStack(stack, 1)); - GL11.glColor3ub((byte) color.getRed(), (byte) color.getGreen(), (byte) color.getBlue()); - int light = 15728880; - int lightmapX = light % 65536; - int lightmapY = light / 65536; - OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, lightmapX, lightmapY); - } - } - } + private static final String TAG_BREW_KEY = "brewKey"; + + IIcon[] icons; + + public ItemBloodPendant() { + super(LibItemNames.BLOOD_PENDANT); + setMaxStackSize(1); + } + + @Override + public void getSubItems(Item item, CreativeTabs tab, List list) { + super.getSubItems(item, tab, list); + for(String s : BotaniaAPI.brewMap.keySet()) { + ItemStack brewStack = getItemForBrew(BotaniaAPI.brewMap.get(s), new ItemStack(this)); + if(brewStack != null) + list.add(brewStack); + } + } + + @Override + public void registerIcons(IIconRegister par1IconRegister) { + icons = new IIcon[4]; + for(int i = 0; i < 4; i++) + icons[i] = IconHelper.forItem(par1IconRegister, this, i); + } + + @Override + public boolean requiresMultipleRenderPasses() { + return true; + } + + @Override + public IIcon getIcon(ItemStack stack, int pass) { + return icons[pass]; + } + + @Override + public int getColorFromItemStack(ItemStack stack, int pass) { + if(pass == 0) + return 0xFFFFFF; + + Brew brew = getBrew(stack); + if(brew == BotaniaAPI.fallbackBrew) + return 0xC6000E; + + Color color = new Color(brew.getColor(stack)); + int add = (int) (Math.sin(ClientTickHandler.ticksInGame * 0.2) * 24); + + int r = Math.max(0, Math.min(255, color.getRed() + add)); + int g = Math.max(0, Math.min(255, color.getGreen() + add)); + int b = Math.max(0, Math.min(255, color.getBlue() + add)); + + return r << 16 | g << 8 | b; + } + + @Override + public void addHiddenTooltip(ItemStack stack, EntityPlayer player, List list, boolean adv) { + super.addHiddenTooltip(stack, player, list, adv); + + Brew brew = getBrew(stack); + if(brew == BotaniaAPI.fallbackBrew) { + addStringToTooltip(EnumChatFormatting.LIGHT_PURPLE + StatCollector.translateToLocal("botaniamisc.notInfused"), list); + return; + } + + addStringToTooltip(EnumChatFormatting.LIGHT_PURPLE + String.format(StatCollector.translateToLocal("botaniamisc.brewOf"), StatCollector.translateToLocal(brew.getUnlocalizedName(stack))), list); + for(PotionEffect effect : brew.getPotionEffects(stack)) { + Potion potion = Potion.potionTypes[effect.getPotionID()]; + EnumChatFormatting format = potion.isBadEffect() ? EnumChatFormatting.RED : EnumChatFormatting.GRAY; + addStringToTooltip(" " + format + StatCollector.translateToLocal(effect.getEffectName()) + (effect.getAmplifier() == 0 ? "" : " " + StatCollector.translateToLocal("botania.roman" + (effect.getAmplifier() + 1))), list); + } + } + + @Override + public BaubleType getBaubleType(ItemStack arg0) { + return BaubleType.AMULET; + } + + @Override + public void onWornTick(ItemStack stack, EntityLivingBase player) { + Brew brew = getBrew(stack); + if(brew != BotaniaAPI.fallbackBrew && player instanceof EntityPlayer && !player.worldObj.isRemote) { + EntityPlayer eplayer = (EntityPlayer) player; + PotionEffect effect = brew.getPotionEffects(stack).get(0); + float cost = (float) brew.getManaCost(stack) / effect.getDuration() / (1 + effect.getAmplifier()) * 2.5F; + boolean doRand = cost < 1; + if(ManaItemHandler.requestManaExact(stack, eplayer, (int) Math.ceil(cost), false)) { + PotionEffect currentEffect = player.getActivePotionEffect(Potion.potionTypes[effect.getPotionID()]); + boolean nightVision = effect.getPotionID() == Potion.nightVision.id; + if(currentEffect == null || currentEffect.getDuration() < (nightVision ? 205 : 3)) { + PotionEffect applyEffect = new PotionEffect(effect.getPotionID(), nightVision ? 285 : 80, effect.getAmplifier(), true); + player.addPotionEffect(applyEffect); + } + + if(!doRand || Math.random() < cost) + ManaItemHandler.requestManaExact(stack, eplayer, (int) Math.ceil(cost), true); + } + } + } + + @Override + public Brew getBrew(ItemStack stack) { + String key = ItemNBTHelper.getString(stack, TAG_BREW_KEY, ""); + return BotaniaAPI.getBrewFromKey(key); + } + + public static void setBrew(ItemStack stack, Brew brew) { + setBrew(stack, brew.getKey()); + } + + public static void setBrew(ItemStack stack, String brew) { + ItemNBTHelper.setString(stack, TAG_BREW_KEY, brew); + } + + @Override + public ItemStack getItemForBrew(Brew brew, ItemStack stack) { + if(!brew.canInfuseBloodPendant() || brew.getPotionEffects(stack).size() != 1 || Potion.potionTypes[brew.getPotionEffects(stack).get(0).getPotionID()].isInstant()) + return null; + + ItemStack brewStack = new ItemStack(this); + setBrew(brewStack, brew); + return brewStack; + } + + @Override + public int getManaCost(Brew brew, ItemStack stack) { + return brew.getManaCost() * 10; + } + + @Override + public boolean usesMana(ItemStack stack) { + return getBrew(stack) != BotaniaAPI.fallbackBrew; + } + + @Override + public void onPlayerBaubleRender(ItemStack stack, RenderPlayerEvent event, RenderType type) { + if(type == RenderType.BODY) { + Minecraft.getMinecraft().renderEngine.bindTexture(TextureMap.locationItemsTexture); + Helper.rotateIfSneaking(event.entityPlayer); + boolean armor = event.entityPlayer.getCurrentArmor(2) != null; + GL11.glRotatef(180F, 1F, 0F, 0F); + GL11.glTranslatef(-0.26F, -0.4F, armor ? 0.2F : 0.15F); + GL11.glScalef(0.5F, 0.5F, 0.5F); + + for(int i = 2; i < 4; i++) { + IIcon icon = icons[i]; + float f = icon.getMinU(); + float f1 = icon.getMaxU(); + float f2 = icon.getMinV(); + float f3 = icon.getMaxV(); + ItemRenderer.renderItemIn2D(Tessellator.instance, f1, f2, f, f3, icon.getIconWidth(), icon.getIconHeight(), 1F / 32F); + + Color color = new Color(getColorFromItemStack(stack, 1)); + GL11.glColor3ub((byte) color.getRed(), (byte) color.getGreen(), (byte) color.getBlue()); + int light = 15728880; + int lightmapX = light % 65536; + int lightmapY = light / 65536; + OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, lightmapX, lightmapY); + } + } + } + } diff --git a/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemDivaCharm.java b/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemDivaCharm.java index 51df5cba15..f0a21d180a 100644 --- a/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemDivaCharm.java +++ b/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemDivaCharm.java @@ -2,21 +2,16 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [May 25, 2014, 10:30:39 PM (GMT)] */ package vazkii.botania.common.item.equipment.bauble; -import baubles.api.BaubleType; -import baubles.common.lib.PlayerHandler; -import cpw.mods.fml.common.eventhandler.SubscribeEvent; -import cpw.mods.fml.relauncher.ReflectionHelper; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; import java.util.List; + import net.minecraft.client.Minecraft; import net.minecraft.client.renderer.ItemRenderer; import net.minecraft.client.renderer.Tessellator; @@ -30,7 +25,9 @@ import net.minecraftforge.client.event.RenderPlayerEvent; import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.event.entity.living.LivingHurtEvent; + import org.lwjgl.opengl.GL11; + import vazkii.botania.api.item.IBaubleRender; import vazkii.botania.api.mana.IManaUsingItem; import vazkii.botania.api.mana.ManaItemHandler; @@ -38,99 +35,82 @@ import vazkii.botania.common.block.subtile.functional.SubTileHeiseiDream; import vazkii.botania.common.lib.LibItemNames; import vazkii.botania.common.lib.LibObfuscation; +import baubles.api.BaubleType; +import baubles.common.lib.PlayerHandler; +import cpw.mods.fml.common.eventhandler.SubscribeEvent; +import cpw.mods.fml.relauncher.ReflectionHelper; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; public class ItemDivaCharm extends ItemBauble implements IManaUsingItem, IBaubleRender { - public ItemDivaCharm() { - super(LibItemNames.DIVA_CHARM); - MinecraftForge.EVENT_BUS.register(this); - } + public ItemDivaCharm() { + super(LibItemNames.DIVA_CHARM); + MinecraftForge.EVENT_BUS.register(this); + } + + @SubscribeEvent + public void onEntityDamaged(LivingHurtEvent event) { + if(event.source.getEntity() instanceof EntityPlayer && event.entityLiving instanceof EntityLiving && !event.entityLiving.worldObj.isRemote && Math.random() < 0.6F) { + EntityPlayer player = (EntityPlayer) event.source.getEntity(); + ItemStack amulet = PlayerHandler.getPlayerBaubles(player).getStackInSlot(0); + if(amulet != null && amulet.getItem() == this) { + final int cost = 250; + if(ManaItemHandler.requestManaExact(amulet, player, cost, false)) { + final int range = 20; - @SubscribeEvent - public void onEntityDamaged(LivingHurtEvent event) { - if (event.source.getEntity() instanceof EntityPlayer - && event.entityLiving instanceof EntityLiving - && !event.entityLiving.worldObj.isRemote - && Math.random() < 0.6F) { - EntityPlayer player = (EntityPlayer) event.source.getEntity(); - ItemStack amulet = PlayerHandler.getPlayerBaubles(player).getStackInSlot(0); - if (amulet != null && amulet.getItem() == this) { - final int cost = 250; - if (ManaItemHandler.requestManaExact(amulet, player, cost, false)) { - final int range = 20; + List mobs = player.worldObj.getEntitiesWithinAABB(IMob.class, AxisAlignedBB.getBoundingBox(event.entity.posX - range, event.entity.posY - range, event.entity.posZ - range, event.entity.posX + range, event.entity.posY + range, event.entity.posZ + range)); + if(mobs.size() > 1) { + if(SubTileHeiseiDream.brainwashEntity((EntityLiving) event.entityLiving, mobs)) { + if(event.entityLiving instanceof EntityCreeper) + ReflectionHelper.setPrivateValue(EntityCreeper.class, (EntityCreeper) event.entityLiving, 2, LibObfuscation.TIME_SINCE_IGNITED); + event.entityLiving.heal(event.entityLiving.getMaxHealth()); + if(event.entityLiving.isDead) + event.entityLiving.isDead = false; - List mobs = player.worldObj.getEntitiesWithinAABB( - IMob.class, - AxisAlignedBB.getBoundingBox( - event.entity.posX - range, - event.entity.posY - range, - event.entity.posZ - range, - event.entity.posX + range, - event.entity.posY + range, - event.entity.posZ + range)); - if (mobs.size() > 1) { - if (SubTileHeiseiDream.brainwashEntity((EntityLiving) event.entityLiving, mobs)) { - if (event.entityLiving instanceof EntityCreeper) - ReflectionHelper.setPrivateValue( - EntityCreeper.class, - (EntityCreeper) event.entityLiving, - 2, - LibObfuscation.TIME_SINCE_IGNITED); - event.entityLiving.heal(event.entityLiving.getMaxHealth()); - if (event.entityLiving.isDead) event.entityLiving.isDead = false; + ManaItemHandler.requestManaExact(amulet, player, cost, true); + player.worldObj.playSoundAtEntity(player, "botania:divaCharm", 1F, 1F); - ManaItemHandler.requestManaExact(amulet, player, cost, true); - player.worldObj.playSoundAtEntity(player, "botania:divaCharm", 1F, 1F); + double x = event.entityLiving.posX; + double y = event.entityLiving.posY; + double z = event.entityLiving.posZ; - double x = event.entityLiving.posX; - double y = event.entityLiving.posY; - double z = event.entityLiving.posZ; + for(int i = 0; i < 50; i++) + Botania.proxy.sparkleFX(event.entityLiving.worldObj, x + Math.random() * event.entityLiving.width, y + Math.random() * event.entityLiving.height, z + Math.random() * event.entityLiving.width, 1F, 1F, 0.25F, 1F, 3); + } + } + } + } + } + } - for (int i = 0; i < 50; i++) - Botania.proxy.sparkleFX( - event.entityLiving.worldObj, - x + Math.random() * event.entityLiving.width, - y + Math.random() * event.entityLiving.height, - z + Math.random() * event.entityLiving.width, - 1F, - 1F, - 0.25F, - 1F, - 3); - } - } - } - } - } - } + @Override + public BaubleType getBaubleType(ItemStack arg0) { + return BaubleType.AMULET; + } - @Override - public BaubleType getBaubleType(ItemStack arg0) { - return BaubleType.AMULET; - } + @Override + public boolean usesMana(ItemStack stack) { + return true; + } - @Override - public boolean usesMana(ItemStack stack) { - return true; - } + @Override + @SideOnly(Side.CLIENT) + public void onPlayerBaubleRender(ItemStack stack, RenderPlayerEvent event, RenderType type) { + if(type == RenderType.HEAD) { + float f = itemIcon.getMinU(); + float f1 = itemIcon.getMaxU(); + float f2 = itemIcon.getMinV(); + float f3 = itemIcon.getMaxV(); + boolean armor = event.entityPlayer.getCurrentArmor(3) != null; + Helper.translateToHeadLevel(event.entityPlayer); + Minecraft.getMinecraft().renderEngine.bindTexture(TextureMap.locationItemsTexture); + GL11.glRotatef(90F, 0F, 1F, 0F); + GL11.glRotatef(180F, 1F, 0F, 0F); + GL11.glTranslatef(-0.4F, 0.1F, armor ? -0.35F : -0.3F); + GL11.glScalef(0.5F, 0.5F, 0.5F); + ItemRenderer.renderItemIn2D(Tessellator.instance, f1, f2, f, f3, itemIcon.getIconWidth(), itemIcon.getIconHeight(), 1F / 16F); + } + } - @Override - @SideOnly(Side.CLIENT) - public void onPlayerBaubleRender(ItemStack stack, RenderPlayerEvent event, RenderType type) { - if (type == RenderType.HEAD) { - float f = itemIcon.getMinU(); - float f1 = itemIcon.getMaxU(); - float f2 = itemIcon.getMinV(); - float f3 = itemIcon.getMaxV(); - boolean armor = event.entityPlayer.getCurrentArmor(3) != null; - Helper.translateToHeadLevel(event.entityPlayer); - Minecraft.getMinecraft().renderEngine.bindTexture(TextureMap.locationItemsTexture); - GL11.glRotatef(90F, 0F, 1F, 0F); - GL11.glRotatef(180F, 1F, 0F, 0F); - GL11.glTranslatef(-0.4F, 0.1F, armor ? -0.35F : -0.3F); - GL11.glScalef(0.5F, 0.5F, 0.5F); - ItemRenderer.renderItemIn2D( - Tessellator.instance, f1, f2, f, f3, itemIcon.getIconWidth(), itemIcon.getIconHeight(), 1F / 16F); - } - } } diff --git a/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemFlightTiara.java b/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemFlightTiara.java index 9d8d8e1d8d..af3b711b4b 100644 --- a/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemFlightTiara.java +++ b/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemFlightTiara.java @@ -2,27 +2,22 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [May 26, 2014, 4:05:50 PM (GMT)] */ package vazkii.botania.common.item.equipment.bauble; -import baubles.api.BaubleType; -import baubles.common.lib.PlayerHandler; -import cpw.mods.fml.common.FMLCommonHandler; -import cpw.mods.fml.common.eventhandler.SubscribeEvent; -import cpw.mods.fml.common.gameevent.PlayerEvent; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; import java.security.MessageDigest; import java.security.NoSuchAlgorithmException; import java.security.SecureRandom; import java.util.ArrayList; import java.util.List; + import javax.xml.bind.annotation.adapters.HexBinaryAdapter; + import net.minecraft.client.Minecraft; import net.minecraft.client.gui.Gui; import net.minecraft.client.gui.ScaledResolution; @@ -45,7 +40,9 @@ import net.minecraftforge.client.event.RenderPlayerEvent; import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.event.entity.living.LivingEvent.LivingUpdateEvent; + import org.lwjgl.opengl.GL11; + import vazkii.botania.api.BotaniaAPI; import vazkii.botania.api.item.IBaubleRender; import vazkii.botania.api.mana.IManaUsingItem; @@ -62,514 +59,494 @@ import vazkii.botania.common.core.helper.Vector3; import vazkii.botania.common.item.ModItems; import vazkii.botania.common.lib.LibItemNames; +import baubles.api.BaubleType; +import baubles.common.lib.PlayerHandler; +import cpw.mods.fml.common.FMLCommonHandler; +import cpw.mods.fml.common.eventhandler.SubscribeEvent; +import cpw.mods.fml.common.gameevent.PlayerEvent; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; public class ItemFlightTiara extends ItemBauble implements IManaUsingItem, IBaubleRender, ICraftAchievement { - private static ResourceLocation textureHud = new ResourceLocation(LibResources.GUI_HUD_ICONS); - private static ResourceLocation textureHalo = new ResourceLocation(LibResources.MISC_HALO); - - private static final String TAG_FLYING = "flying"; - private static final String TAG_TIME_LEFT = "timeLeft"; - private static final String TAG_INFINITE_FLIGHT = "infiniteFlight"; - private static final String TAG_DASH_COOLDOWN = "dashCooldown"; - private static final String TAG_IS_SPRINTING = "isSprinting"; - - public static List playersWithFlight = new ArrayList(); - private static final int COST = 35; - private static final int COST_OVERKILL = COST * 3; - private static final int MAX_FLY_TIME = 1200; - - public static IIcon[] wingIcons; - private static final int SUBTYPES = 8; - private static final int WING_TYPES = 9; - - public ItemFlightTiara() { - super(LibItemNames.FLIGHT_TIARA); - MinecraftForge.EVENT_BUS.register(this); - FMLCommonHandler.instance().bus().register(this); - setHasSubtypes(true); - } - - @Override - public BaubleType getBaubleType(ItemStack arg0) { - return BaubleType.AMULET; - } - - @Override - @SideOnly(Side.CLIENT) - public void registerIcons(IIconRegister par1IconRegister) { - itemIcon = IconHelper.forItem(par1IconRegister, this, 0); - wingIcons = new IIcon[WING_TYPES]; - for (int i = 0; i < WING_TYPES; i++) wingIcons[i] = IconHelper.forItem(par1IconRegister, this, i + 1); - } - - @Override - public void getSubItems(Item item, CreativeTabs tab, List list) { - for (int i = 0; i < SUBTYPES + 1; i++) list.add(new ItemStack(item, 1, i)); - } - - @Override - public void addHiddenTooltip(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, List par3List, boolean par4) { - super.addHiddenTooltip(par1ItemStack, par2EntityPlayer, par3List, par4); - par3List.add(StatCollector.translateToLocal("botania.wings" + par1ItemStack.getItemDamage())); - } - - @Override - public void onEquipped(ItemStack stack, EntityLivingBase player) { - super.onEquipped(stack, player); - if (stack.getItemDamage() != WING_TYPES - && hash(stack.getDisplayName()) - .equals("16E1BDFD1D6AE1A954C9C5E1B2D9099780F3E1724541F1F2F77310B769CFFBAC")) { - stack.setItemDamage(WING_TYPES); - stack.getTagCompound().removeTag("display"); - } - } - - String hash(String str) { - if (str != null) - try { - MessageDigest md = MessageDigest.getInstance("SHA-256"); - return new HexBinaryAdapter().marshal(md.digest(salt(str).getBytes())); - } catch (NoSuchAlgorithmException e) { - e.printStackTrace(); - } - return ""; - } - - // Might as well be called sugar given it's not secure at all :D - String salt(String str) { - str = str += "wowsuchsaltmuchsecurityverywow"; - SecureRandom rand = new SecureRandom(str.getBytes()); - int l = str.length(); - int steps = rand.nextInt(l); - char[] chrs = str.toCharArray(); - for (int i = 0; i < steps; i++) { - int indA = rand.nextInt(l); - int indB; - do { - indB = rand.nextInt(l); - } while (indB == indA); - char c = (char) (chrs[indA] ^ chrs[indB]); - chrs[indA] = c; - } - - return String.copyValueOf(chrs); - } - - @Override - public void onWornTick(ItemStack stack, EntityLivingBase player) { - super.onWornTick(stack, player); - - if (player instanceof EntityPlayer) { - EntityPlayer p = (EntityPlayer) player; - boolean flying = p.capabilities.isFlying; - - boolean wasSprting = ItemNBTHelper.getBoolean(stack, TAG_IS_SPRINTING, false); - boolean isSprinting = p.isSprinting(); - if (isSprinting != wasSprting) ItemNBTHelper.setBoolean(stack, TAG_IS_SPRINTING, isSprinting); - - int time = ItemNBTHelper.getInt(stack, TAG_TIME_LEFT, MAX_FLY_TIME); - int newTime = time; - Vector3 look = new Vector3(p.getLookVec()); - look.y = 0; - look.normalize(); - - if (flying) { - if (time > 0 && !ItemNBTHelper.getBoolean(stack, TAG_INFINITE_FLIGHT, false)) newTime--; - final int maxCd = 80; - int cooldown = ItemNBTHelper.getInt(stack, TAG_DASH_COOLDOWN, 0); - if (!wasSprting && isSprinting && cooldown == 0) { - p.motionX += look.x; - p.motionZ += look.z; - p.worldObj.playSoundAtEntity(p, "botania:dash", 1F, 1F); - ItemNBTHelper.setInt(stack, TAG_DASH_COOLDOWN, maxCd); - } else if (cooldown > 0) { - if (maxCd - cooldown < 2) player.moveFlying(0F, 1F, 5F); - else if (maxCd - cooldown < 10) player.setSprinting(false); - ItemNBTHelper.setInt(stack, TAG_DASH_COOLDOWN, cooldown - 2); - if (player instanceof EntityPlayerMP) - BotaniaAPI.internalHandler.sendBaubleUpdatePacket((EntityPlayerMP) player, 0); - } - } else if (!flying) { - boolean doGlide = player.isSneaking() && !player.onGround && player.fallDistance >= 2F; - if (time < MAX_FLY_TIME && player.ticksExisted % (doGlide ? 6 : 2) == 0) newTime++; - - if (doGlide) { - player.motionY = Math.max(-0.15F, player.motionY); - float mul = 0.6F; - player.motionX = look.x * mul; - player.motionZ = look.z * mul; - player.fallDistance = 2F; - } - } - - ItemNBTHelper.setBoolean(stack, TAG_FLYING, flying); - if (newTime != time) ItemNBTHelper.setInt(stack, TAG_TIME_LEFT, newTime); - } - } - - @SubscribeEvent - public void updatePlayerFlyStatus(LivingUpdateEvent event) { - if (event.entityLiving instanceof EntityPlayer) { - EntityPlayer player = (EntityPlayer) event.entityLiving; - ItemStack tiara = PlayerHandler.getPlayerBaubles(player).getStackInSlot(0); - int left = ItemNBTHelper.getInt(tiara, TAG_TIME_LEFT, MAX_FLY_TIME); - - if (playersWithFlight.contains(playerStr(player))) { - if (shouldPlayerHaveFlight(player)) { - player.capabilities.allowFlying = true; - if (player.capabilities.isFlying) { - if (!player.worldObj.isRemote) - ManaItemHandler.requestManaExact(tiara, player, getCost(tiara, left), true); - else if (Math.abs(player.motionX) > 0.1 || Math.abs(player.motionZ) > 0.1) { - double x = event.entityLiving.posX - 0.5; - double y = event.entityLiving.posY - 1.7; - double z = event.entityLiving.posZ - 0.5; - - player.getGameProfile().getName(); - float r = 1F; - float g = 1F; - float b = 1F; - - switch (tiara.getItemDamage()) { - case 2: { - r = 0.1F; - g = 0.1F; - b = 0.1F; - break; - } - case 3: { - r = 0F; - g = 0.6F; - break; - } - case 4: { - g = 0.3F; - b = 0.3F; - break; - } - case 5: { - r = 0.6F; - g = 0F; - b = 0.6F; - break; - } - case 6: { - r = 0.4F; - g = 0F; - b = 0F; - break; - } - case 7: { - r = 0.2F; - g = 0.6F; - b = 0.2F; - break; - } - case 8: { - r = 0.85F; - g = 0.85F; - b = 0F; - break; - } - case 9: { - r = 0F; - b = 0F; - break; - } - } - - for (int i = 0; i < 2; i++) - Botania.proxy.sparkleFX( - event.entityLiving.worldObj, - x + Math.random() * event.entityLiving.width, - y + Math.random() * 0.4, - z + Math.random() * event.entityLiving.width, - r, - g, - b, - 2F * (float) Math.random(), - 20); - } - } - } else { - if (!player.capabilities.isCreativeMode) { - player.capabilities.allowFlying = false; - player.capabilities.isFlying = false; - player.capabilities.disableDamage = false; - } - playersWithFlight.remove(playerStr(player)); - } - } else if (shouldPlayerHaveFlight(player)) { - playersWithFlight.add(playerStr(player)); - player.capabilities.allowFlying = true; - } - } - } - - @SubscribeEvent - public void playerLoggedOut(PlayerEvent.PlayerLoggedOutEvent event) { - String username = event.player.getGameProfile().getName(); - playersWithFlight.remove(username + ":false"); - playersWithFlight.remove(username + ":true"); - } - - public static String playerStr(EntityPlayer player) { - return player.getGameProfile().getName() + ":" + player.worldObj.isRemote; - } - - private boolean shouldPlayerHaveFlight(EntityPlayer player) { - ItemStack armor = PlayerHandler.getPlayerBaubles(player).getStackInSlot(0); - if (armor != null && armor.getItem() == this) { - int left = ItemNBTHelper.getInt(armor, TAG_TIME_LEFT, MAX_FLY_TIME); - boolean flying = ItemNBTHelper.getBoolean(armor, TAG_FLYING, false); - return (left > (flying ? 0 : MAX_FLY_TIME / 10) || player.inventory.hasItem(ModItems.flugelEye)) - && ManaItemHandler.requestManaExact(armor, player, getCost(armor, left), false); - } - - return false; - } - - public int getCost(ItemStack stack, int timeLeft) { - return timeLeft <= 0 ? COST_OVERKILL : COST; - } - - @Override - public boolean usesMana(ItemStack stack) { - return true; - } - - @Override - @SideOnly(Side.CLIENT) - public void onPlayerBaubleRender(ItemStack stack, RenderPlayerEvent event, RenderType type) { - int meta = stack.getItemDamage(); - if (type == RenderType.BODY) { - if (meta > 0 && meta <= ItemFlightTiara.wingIcons.length) { - IIcon icon = ItemFlightTiara.wingIcons[meta - 1]; - Minecraft.getMinecraft().renderEngine.bindTexture(TextureMap.locationItemsTexture); - - boolean flying = event.entityPlayer.capabilities.isFlying; - - float rz = 120F; - float rx = 20F - + (float) ((Math.sin((double) (event.entityPlayer.ticksExisted + event.partialRenderTick) - * (flying ? 0.4F : 0.2F)) - + 0.5F) - * (flying ? 30F : 5F)); - float ry = 0F; - float h = 0.2F; - float i = 0.15F; - float s = 1F; - - GL11.glPushMatrix(); - GL11.glEnable(GL11.GL_BLEND); - GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); - GL11.glColor4f(1F, 1F, 1F, 1F); - - int light = 15728880; - int lightmapX = light % 65536; - int lightmapY = light / 65536; - switch (meta) { - case 1: { // Jibril - h = 0.4F; - break; - } - case 2: { // Sephiroth - s = 1.3F; - break; - } - case 3: { // Cirno - h = -0.1F; - rz = 0F; - rx = 0F; - i = 0.3F; - break; - } - case 4: { // Phoenix - rz = 180F; - h = 0.5F; - rx = 20F; - ry = -(float) ((Math.sin((double) (event.entityPlayer.ticksExisted + event.partialRenderTick) - * (flying ? 0.4F : 0.2F)) - + 0.6F) - * (flying ? 30F : 5F)); - OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, lightmapX, lightmapY); - break; - } - case 5: { // Kuroyukihime - h = 0.8F; - rz = 180F; - ry = -rx; - rx = 0F; - s = 2F; - break; - } - case 6: { // Random Devil - rz = 150F; - break; - } - case 7: { // Lyfa - h = -0.1F; - rz = 0F; - ry = -rx; - rx = 0F; - GL11.glColor4f( - 1F, - 1F, - 1F, - 0.5F - + (float) Math.cos((double) (event.entityPlayer.ticksExisted - + event.partialRenderTick) - * 0.3F) - * 0.2F); - break; - } - case 8: { // Mega Ultra Chicken - h = 0.1F; - break; - } - case 9: { // The One - OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, lightmapX, lightmapY); - rz = 180F; - rx = 0F; - s = 1.5F; - h = 1.2F; - GL11.glColor4f( - 1F, - 1F, - 1F, - 0.5F - + (flying - ? (float) Math.cos((double) (event.entityPlayer.ticksExisted - + event.partialRenderTick) - * 0.3F) - * 0.25F - + 0.25F - : 0F)); - } - } - - float f = icon.getMinU(); - float f1 = icon.getMaxU(); - float f2 = icon.getMinV(); - float f3 = icon.getMaxV(); - float sr = 1F / s; - - Helper.rotateIfSneaking(event.entityPlayer); - - GL11.glTranslatef(0F, h, i); - - GL11.glRotatef(rz, 0F, 0F, 1F); - GL11.glRotatef(rx, 1F, 0F, 0F); - GL11.glRotatef(ry, 0F, 1F, 0F); - GL11.glScalef(s, s, s); - ItemRenderer.renderItemIn2D( - Tessellator.instance, f1, f2, f, f3, icon.getIconWidth(), icon.getIconHeight(), 1F / 32F); - GL11.glScalef(sr, sr, sr); - GL11.glRotatef(-ry, 0F, 1F, 0F); - GL11.glRotatef(-rx, 1F, 0F, 0F); - GL11.glRotatef(-rz, 0F, 0F, 1F); - - if (meta != 2) { // Sephiroth - GL11.glScalef(-1F, 1F, 1F); - GL11.glRotatef(rz, 0F, 0F, 1F); - GL11.glRotatef(rx, 1F, 0F, 0F); - GL11.glRotatef(ry, 0F, 1F, 0F); - GL11.glScalef(s, s, s); - ItemRenderer.renderItemIn2D( - Tessellator.instance, f1, f2, f, f3, icon.getIconWidth(), icon.getIconHeight(), 1F / 32F); - GL11.glScalef(sr, sr, sr); - GL11.glRotatef(-ry, 1F, 0F, 0F); - GL11.glRotatef(-rx, 1F, 0F, 0F); - GL11.glRotatef(-rz, 0F, 0F, 1F); - } - - GL11.glColor3f(1F, 1F, 1F); - GL11.glPopMatrix(); - } - } else if (meta == 1) // Jibril's Halo - renderHalo(event.entityPlayer, event.partialRenderTick); - } - - @SideOnly(Side.CLIENT) - public static void renderHalo(EntityPlayer player, float partialTicks) { - GL11.glEnable(GL11.GL_BLEND); - GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); - GL11.glShadeModel(GL11.GL_SMOOTH); - OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, 240, 240); - GL11.glDisable(GL11.GL_LIGHTING); - GL11.glDisable(GL11.GL_CULL_FACE); - GL11.glColor4f(1F, 1F, 1F, 1F); - - Minecraft.getMinecraft().renderEngine.bindTexture(textureHalo); - - if (player != null) Helper.translateToHeadLevel(player); - GL11.glRotated(30, 1, 0, -1); - GL11.glTranslatef(-0.1F, -0.5F, -0.1F); - if (player != null) GL11.glRotatef(player.ticksExisted + partialTicks, 0, 1, 0); - else GL11.glRotatef(Botania.proxy.getWorldElapsedTicks(), 0, 1, 0); - - Tessellator tes = Tessellator.instance; - ShaderHelper.useShader(ShaderHelper.halo); - tes.startDrawingQuads(); - tes.addVertexWithUV(-0.75, 0, -0.75, 0, 0); - tes.addVertexWithUV(-0.75, 0, 0.75, 0, 1); - tes.addVertexWithUV(0.75, 0, 0.75, 1, 1); - tes.addVertexWithUV(0.75, 0, -0.75, 1, 0); - tes.draw(); - ShaderHelper.releaseShader(); - - GL11.glEnable(GL11.GL_LIGHTING); - GL11.glShadeModel(GL11.GL_FLAT); - GL11.glEnable(GL11.GL_CULL_FACE); - } - - @SideOnly(Side.CLIENT) - public static void renderHUD(ScaledResolution resolution, EntityPlayer player, ItemStack stack) { - int u = Math.max(1, stack.getItemDamage()) * 9 - 9; - int v = 0; - - Minecraft mc = Minecraft.getMinecraft(); - mc.renderEngine.bindTexture(textureHud); - int xo = resolution.getScaledWidth() / 2 + 10; - int x = xo; - int y = resolution.getScaledHeight() - ConfigHandler.flightBarHeight; - if (player.getAir() < 300) y = resolution.getScaledHeight() - ConfigHandler.flightBarBreathHeight; - - int left = ItemNBTHelper.getInt(stack, TAG_TIME_LEFT, MAX_FLY_TIME); - - int segTime = MAX_FLY_TIME / 10; - int segs = left / segTime + 1; - int last = left % segTime; - - for (int i = 0; i < segs; i++) { - float trans = 1F; - if (i == segs - 1) { - trans = (float) last / (float) segTime; - GL11.glEnable(GL11.GL_BLEND); - GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); - GL11.glDisable(GL11.GL_ALPHA_TEST); - } - - GL11.glColor4f(1F, 1F, 1F, trans); - RenderHelper.drawTexturedModalRect(x, y, 0, u, v, 9, 9); - x += 8; - } - - if (player.capabilities.isFlying) { - int width = ItemNBTHelper.getInt(stack, TAG_DASH_COOLDOWN, 0); - GL11.glColor4f(1F, 1F, 1F, 1F); - if (width > 0) Gui.drawRect(xo, y - 2, xo + 80, y - 1, 0x88000000); - Gui.drawRect(xo, y - 2, xo + width, y - 1, 0xFFFFFFFF); - } - - GL11.glEnable(GL11.GL_ALPHA_TEST); - GL11.glColor4f(1F, 1F, 1F, 1F); - mc.renderEngine.bindTexture(Gui.icons); - } - - @Override - public Achievement getAchievementOnCraft(ItemStack stack, EntityPlayer player, IInventory matrix) { - return stack.getItemDamage() == 1 ? ModAchievements.tiaraWings : null; - } + private static ResourceLocation textureHud = new ResourceLocation(LibResources.GUI_HUD_ICONS); + private static ResourceLocation textureHalo = new ResourceLocation(LibResources.MISC_HALO); + + private static final String TAG_FLYING = "flying"; + private static final String TAG_TIME_LEFT = "timeLeft"; + private static final String TAG_INFINITE_FLIGHT = "infiniteFlight"; + private static final String TAG_DASH_COOLDOWN = "dashCooldown"; + private static final String TAG_IS_SPRINTING = "isSprinting"; + + public static List playersWithFlight = new ArrayList(); + private static final int COST = 35; + private static final int COST_OVERKILL = COST * 3; + private static final int MAX_FLY_TIME = 1200; + + public static IIcon[] wingIcons; + private static final int SUBTYPES = 8; + private static final int WING_TYPES = 9; + + public ItemFlightTiara() { + super(LibItemNames.FLIGHT_TIARA); + MinecraftForge.EVENT_BUS.register(this); + FMLCommonHandler.instance().bus().register(this); + setHasSubtypes(true); + } + + @Override + public BaubleType getBaubleType(ItemStack arg0) { + return BaubleType.AMULET; + } + + @Override + @SideOnly(Side.CLIENT) + public void registerIcons(IIconRegister par1IconRegister) { + itemIcon = IconHelper.forItem(par1IconRegister, this, 0); + wingIcons = new IIcon[WING_TYPES]; + for(int i = 0; i < WING_TYPES; i++) + wingIcons[i] = IconHelper.forItem(par1IconRegister, this, i + 1); + } + + @Override + public void getSubItems(Item item, CreativeTabs tab, List list) { + for(int i = 0; i < SUBTYPES + 1; i++) + list.add(new ItemStack(item, 1, i)); + } + + @Override + public void addHiddenTooltip(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, List par3List, boolean par4) { + super.addHiddenTooltip(par1ItemStack, par2EntityPlayer, par3List, par4); + par3List.add(StatCollector.translateToLocal("botania.wings" + par1ItemStack.getItemDamage())); + } + + @Override + public void onEquipped(ItemStack stack, EntityLivingBase player) { + super.onEquipped(stack, player); + if(stack.getItemDamage() != WING_TYPES && hash(stack.getDisplayName()).equals("16E1BDFD1D6AE1A954C9C5E1B2D9099780F3E1724541F1F2F77310B769CFFBAC")) { + stack.setItemDamage(WING_TYPES); + stack.getTagCompound().removeTag("display"); + } + } + + String hash(String str) { + if(str != null) + try { + MessageDigest md = MessageDigest.getInstance("SHA-256"); + return new HexBinaryAdapter().marshal(md.digest(salt(str).getBytes())); + } catch (NoSuchAlgorithmException e) { + e.printStackTrace(); + } + return ""; + } + + // Might as well be called sugar given it's not secure at all :D + String salt(String str) { + str = str += "wowsuchsaltmuchsecurityverywow"; + SecureRandom rand = new SecureRandom(str.getBytes()); + int l = str.length(); + int steps = rand.nextInt(l); + char[] chrs = str.toCharArray(); + for(int i = 0; i < steps; i++) { + int indA = rand.nextInt(l); + int indB; + do { + indB = rand.nextInt(l); + } while(indB == indA); + char c = (char) (chrs[indA] ^ chrs[indB]); + chrs[indA] = c; + } + + return String.copyValueOf(chrs); + } + + @Override + public void onWornTick(ItemStack stack, EntityLivingBase player) { + super.onWornTick(stack, player); + + if(player instanceof EntityPlayer) { + EntityPlayer p = (EntityPlayer) player; + boolean flying = p.capabilities.isFlying; + + boolean wasSprting = ItemNBTHelper.getBoolean(stack, TAG_IS_SPRINTING, false); + boolean isSprinting = p.isSprinting(); + if(isSprinting != wasSprting) + ItemNBTHelper.setBoolean(stack, TAG_IS_SPRINTING, isSprinting); + + int time = ItemNBTHelper.getInt(stack, TAG_TIME_LEFT, MAX_FLY_TIME); + int newTime = time; + Vector3 look = new Vector3(p.getLookVec()); + look.y = 0; + look.normalize(); + + if(flying) { + if(time > 0 && !ItemNBTHelper.getBoolean(stack, TAG_INFINITE_FLIGHT, false)) + newTime--; + final int maxCd = 80; + int cooldown = ItemNBTHelper.getInt(stack, TAG_DASH_COOLDOWN, 0); + if(!wasSprting && isSprinting && cooldown == 0) { + p.motionX += look.x; + p.motionZ += look.z; + p.worldObj.playSoundAtEntity(p, "botania:dash", 1F, 1F); + ItemNBTHelper.setInt(stack, TAG_DASH_COOLDOWN, maxCd); + } else if(cooldown > 0) { + if(maxCd - cooldown < 2) + player.moveFlying(0F, 1F, 5F); + else if(maxCd - cooldown < 10) + player.setSprinting(false); + ItemNBTHelper.setInt(stack, TAG_DASH_COOLDOWN, cooldown - 2); + if(player instanceof EntityPlayerMP) + BotaniaAPI.internalHandler.sendBaubleUpdatePacket((EntityPlayerMP) player, 0); + } + } else if(!flying) { + boolean doGlide = player.isSneaking() && !player.onGround && player.fallDistance >= 2F; + if(time < MAX_FLY_TIME && player.ticksExisted % (doGlide ? 6 : 2) == 0) + newTime++; + + if(doGlide) { + player.motionY = Math.max(-0.15F, player.motionY); + float mul = 0.6F; + player.motionX = look.x * mul; + player.motionZ = look.z * mul; + player.fallDistance = 2F; + } + } + + ItemNBTHelper.setBoolean(stack, TAG_FLYING, flying); + if(newTime != time) + ItemNBTHelper.setInt(stack, TAG_TIME_LEFT, newTime); + } + } + + @SubscribeEvent + public void updatePlayerFlyStatus(LivingUpdateEvent event) { + if(event.entityLiving instanceof EntityPlayer) { + EntityPlayer player = (EntityPlayer) event.entityLiving; + ItemStack tiara = PlayerHandler.getPlayerBaubles(player).getStackInSlot(0); + int left = ItemNBTHelper.getInt(tiara, TAG_TIME_LEFT, MAX_FLY_TIME); + + if(playersWithFlight.contains(playerStr(player))) { + if(shouldPlayerHaveFlight(player)) { + player.capabilities.allowFlying = true; + if(player.capabilities.isFlying) { + if(!player.worldObj.isRemote) + ManaItemHandler.requestManaExact(tiara, player, getCost(tiara, left), true); + else if(Math.abs(player.motionX) > 0.1 || Math.abs(player.motionZ) > 0.1) { + double x = event.entityLiving.posX - 0.5; + double y = event.entityLiving.posY - 1.7; + double z = event.entityLiving.posZ - 0.5; + + player.getGameProfile().getName(); + float r = 1F; + float g = 1F; + float b = 1F; + + switch(tiara.getItemDamage()) { + case 2 : { + r = 0.1F; + g = 0.1F; + b = 0.1F; + break; + } + case 3 : { + r = 0F; + g = 0.6F; + break; + } + case 4 : { + g = 0.3F; + b = 0.3F; + break; + } + case 5 : { + r = 0.6F; + g = 0F; + b = 0.6F; + break; + } + case 6 : { + r = 0.4F; + g = 0F; + b = 0F; + break; + } + case 7 : { + r = 0.2F; + g = 0.6F; + b = 0.2F; + break; + } + case 8 : { + r = 0.85F; + g = 0.85F; + b = 0F; + break; + } + case 9 : { + r = 0F; + b = 0F; + break; + } + } + + for(int i = 0; i < 2; i++) + Botania.proxy.sparkleFX(event.entityLiving.worldObj, x + Math.random() * event.entityLiving.width, y + Math.random() * 0.4, z + Math.random() * event.entityLiving.width, r, g, b, 2F * (float) Math.random(), 20); + } + } + } else { + if(!player.capabilities.isCreativeMode) { + player.capabilities.allowFlying = false; + player.capabilities.isFlying = false; + player.capabilities.disableDamage = false; + } + playersWithFlight.remove(playerStr(player)); + } + } else if(shouldPlayerHaveFlight(player)) { + playersWithFlight.add(playerStr(player)); + player.capabilities.allowFlying = true; + } + } + } + + @SubscribeEvent + public void playerLoggedOut(PlayerEvent.PlayerLoggedOutEvent event) { + String username = event.player.getGameProfile().getName(); + playersWithFlight.remove(username + ":false"); + playersWithFlight.remove(username + ":true"); + } + + public static String playerStr(EntityPlayer player) { + return player.getGameProfile().getName() + ":" + player.worldObj.isRemote; + } + + private boolean shouldPlayerHaveFlight(EntityPlayer player) { + ItemStack armor = PlayerHandler.getPlayerBaubles(player).getStackInSlot(0); + if(armor != null && armor.getItem() == this) { + int left = ItemNBTHelper.getInt(armor, TAG_TIME_LEFT, MAX_FLY_TIME); + boolean flying = ItemNBTHelper.getBoolean(armor, TAG_FLYING, false); + return (left > (flying ? 0 : MAX_FLY_TIME / 10) || player.inventory.hasItem(ModItems.flugelEye)) && ManaItemHandler.requestManaExact(armor, player, getCost(armor, left), false); + } + + return false; + } + + public int getCost(ItemStack stack, int timeLeft) { + return timeLeft <= 0 ? COST_OVERKILL : COST; + } + + @Override + public boolean usesMana(ItemStack stack) { + return true; + } + + @Override + @SideOnly(Side.CLIENT) + public void onPlayerBaubleRender(ItemStack stack, RenderPlayerEvent event, RenderType type) { + int meta = stack.getItemDamage(); + if(type == RenderType.BODY) { + if(meta > 0 && meta <= ItemFlightTiara.wingIcons.length) { + IIcon icon = ItemFlightTiara.wingIcons[meta - 1]; + Minecraft.getMinecraft().renderEngine.bindTexture(TextureMap.locationItemsTexture); + + boolean flying = event.entityPlayer.capabilities.isFlying; + + float rz = 120F; + float rx = 20F + (float) ((Math.sin((double) (event.entityPlayer.ticksExisted + event.partialRenderTick) * (flying ? 0.4F : 0.2F)) + 0.5F) * (flying ? 30F : 5F)); + float ry = 0F; + float h = 0.2F; + float i = 0.15F; + float s = 1F; + + GL11.glPushMatrix(); + GL11.glEnable(GL11.GL_BLEND); + GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); + GL11.glColor4f(1F, 1F, 1F, 1F); + + int light = 15728880; + int lightmapX = light % 65536; + int lightmapY = light / 65536; + switch(meta) { + case 1 : { // Jibril + h = 0.4F; + break; + } + case 2 : { // Sephiroth + s = 1.3F; + break; + } + case 3 : { // Cirno + h = -0.1F; + rz = 0F; + rx = 0F; + i = 0.3F; + break; + } + case 4 : { // Phoenix + rz = 180F; + h = 0.5F; + rx = 20F; + ry = -(float) ((Math.sin((double) (event.entityPlayer.ticksExisted + event.partialRenderTick) * (flying ? 0.4F : 0.2F)) + 0.6F) * (flying ? 30F : 5F)); + OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, lightmapX, lightmapY); + break; + } + case 5 : { // Kuroyukihime + h = 0.8F; + rz = 180F; + ry = -rx; + rx = 0F; + s = 2F; + break; + } + case 6 : { // Random Devil + rz = 150F; + break; + } + case 7 : { // Lyfa + h = -0.1F; + rz = 0F; + ry = -rx; + rx = 0F; + GL11.glColor4f(1F, 1F, 1F, 0.5F + (float) Math.cos((double) (event.entityPlayer.ticksExisted + event.partialRenderTick) * 0.3F) * 0.2F); + break; + } + case 8 : { // Mega Ultra Chicken + h = 0.1F; + break; + } + case 9 : { // The One + OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, lightmapX, lightmapY); + rz = 180F; + rx = 0F; + s = 1.5F; + h = 1.2F; + GL11.glColor4f(1F, 1F, 1F, 0.5F + (flying ? (float) Math.cos((double) (event.entityPlayer.ticksExisted + event.partialRenderTick) * 0.3F) * 0.25F + 0.25F : 0F)); + } + } + + float f = icon.getMinU(); + float f1 = icon.getMaxU(); + float f2 = icon.getMinV(); + float f3 = icon.getMaxV(); + float sr = 1F / s; + + Helper.rotateIfSneaking(event.entityPlayer); + + GL11.glTranslatef(0F, h, i); + + GL11.glRotatef(rz, 0F, 0F, 1F); + GL11.glRotatef(rx, 1F, 0F, 0F); + GL11.glRotatef(ry, 0F, 1F, 0F); + GL11.glScalef(s, s, s); + ItemRenderer.renderItemIn2D(Tessellator.instance, f1, f2, f, f3, icon.getIconWidth(), icon.getIconHeight(), 1F / 32F); + GL11.glScalef(sr, sr, sr); + GL11.glRotatef(-ry, 0F, 1F, 0F); + GL11.glRotatef(-rx, 1F, 0F, 0F); + GL11.glRotatef(-rz, 0F, 0F, 1F); + + if(meta != 2) { // Sephiroth + GL11.glScalef(-1F, 1F, 1F); + GL11.glRotatef(rz, 0F, 0F, 1F); + GL11.glRotatef(rx, 1F, 0F, 0F); + GL11.glRotatef(ry, 0F, 1F, 0F); + GL11.glScalef(s, s, s); + ItemRenderer.renderItemIn2D(Tessellator.instance, f1, f2, f, f3, icon.getIconWidth(), icon.getIconHeight(), 1F / 32F); + GL11.glScalef(sr, sr, sr); + GL11.glRotatef(-ry, 1F, 0F, 0F); + GL11.glRotatef(-rx, 1F, 0F, 0F); + GL11.glRotatef(-rz, 0F, 0F, 1F); + } + + GL11.glColor3f(1F, 1F, 1F); + GL11.glPopMatrix(); + } + } else if(meta == 1) // Jibril's Halo + renderHalo(event.entityPlayer, event.partialRenderTick); + } + + @SideOnly(Side.CLIENT) + public static void renderHalo(EntityPlayer player, float partialTicks) { + GL11.glEnable(GL11.GL_BLEND); + GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); + GL11.glShadeModel(GL11.GL_SMOOTH); + OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, 240, 240); + GL11.glDisable(GL11.GL_LIGHTING); + GL11.glDisable(GL11.GL_CULL_FACE); + GL11.glColor4f(1F, 1F, 1F, 1F); + + Minecraft.getMinecraft().renderEngine.bindTexture(textureHalo); + + if(player != null) + Helper.translateToHeadLevel(player); + GL11.glRotated(30, 1, 0, -1); + GL11.glTranslatef(-0.1F, -0.5F, -0.1F); + if(player != null) + GL11.glRotatef(player.ticksExisted + partialTicks, 0, 1, 0); + else GL11.glRotatef(Botania.proxy.getWorldElapsedTicks(), 0, 1, 0); + + Tessellator tes = Tessellator.instance; + ShaderHelper.useShader(ShaderHelper.halo); + tes.startDrawingQuads(); + tes.addVertexWithUV(-0.75, 0, -0.75, 0, 0); + tes.addVertexWithUV(-0.75, 0, 0.75, 0, 1); + tes.addVertexWithUV(0.75, 0, 0.75, 1, 1); + tes.addVertexWithUV(0.75, 0, -0.75, 1, 0); + tes.draw(); + ShaderHelper.releaseShader(); + + GL11.glEnable(GL11.GL_LIGHTING); + GL11.glShadeModel(GL11.GL_FLAT); + GL11.glEnable(GL11.GL_CULL_FACE); + } + + @SideOnly(Side.CLIENT) + public static void renderHUD(ScaledResolution resolution, EntityPlayer player, ItemStack stack) { + int u = Math.max(1, stack.getItemDamage()) * 9 - 9; + int v = 0; + + Minecraft mc = Minecraft.getMinecraft(); + mc.renderEngine.bindTexture(textureHud); + int xo = resolution.getScaledWidth() / 2 + 10; + int x = xo; + int y = resolution.getScaledHeight() - ConfigHandler.flightBarHeight; + if(player.getAir() < 300) + y = resolution.getScaledHeight() - ConfigHandler.flightBarBreathHeight; + + int left = ItemNBTHelper.getInt(stack, TAG_TIME_LEFT, MAX_FLY_TIME); + + int segTime = MAX_FLY_TIME / 10; + int segs = left / segTime + 1; + int last = left % segTime; + + for(int i = 0; i < segs; i++) { + float trans = 1F; + if(i == segs - 1) { + trans = (float) last / (float) segTime; + GL11.glEnable(GL11.GL_BLEND); + GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); + GL11.glDisable(GL11.GL_ALPHA_TEST); + } + + GL11.glColor4f(1F, 1F, 1F, trans); + RenderHelper.drawTexturedModalRect(x, y, 0, u, v, 9, 9); + x += 8; + } + + if(player.capabilities.isFlying) { + int width = ItemNBTHelper.getInt(stack, TAG_DASH_COOLDOWN, 0); + GL11.glColor4f(1F, 1F, 1F, 1F); + if(width > 0) + Gui.drawRect(xo, y - 2, xo + 80, y - 1, 0x88000000); + Gui.drawRect(xo, y - 2, xo + width, y - 1, 0xFFFFFFFF); + } + + GL11.glEnable(GL11.GL_ALPHA_TEST); + GL11.glColor4f(1F, 1F, 1F, 1F); + mc.renderEngine.bindTexture(Gui.icons); + } + + @Override + public Achievement getAchievementOnCraft(ItemStack stack, EntityPlayer player, IInventory matrix) { + return stack.getItemDamage() == 1 ? ModAchievements.tiaraWings : null; + } + } diff --git a/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemGoldenLaurel.java b/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemGoldenLaurel.java index facb5998b4..278d9e2857 100644 --- a/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemGoldenLaurel.java +++ b/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemGoldenLaurel.java @@ -2,20 +2,14 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Apr 27, 2014, 8:49:01 PM (GMT)] */ package vazkii.botania.common.item.equipment.bauble; -import baubles.api.BaubleType; -import baubles.common.lib.PlayerHandler; -import cpw.mods.fml.common.eventhandler.EventPriority; -import cpw.mods.fml.common.eventhandler.SubscribeEvent; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; import net.minecraft.client.Minecraft; import net.minecraft.client.renderer.ItemRenderer; import net.minecraft.client.renderer.Tessellator; @@ -28,60 +22,67 @@ import net.minecraftforge.client.event.RenderPlayerEvent; import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.event.entity.living.LivingDeathEvent; + import org.lwjgl.opengl.GL11; + import vazkii.botania.api.item.IBaubleRender; import vazkii.botania.common.lib.LibItemNames; +import baubles.api.BaubleType; +import baubles.common.lib.PlayerHandler; +import cpw.mods.fml.common.eventhandler.EventPriority; +import cpw.mods.fml.common.eventhandler.SubscribeEvent; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; public class ItemGoldenLaurel extends ItemBauble implements IBaubleRender { - public ItemGoldenLaurel() { - super(LibItemNames.GOLDEN_LAUREL); - MinecraftForge.EVENT_BUS.register(this); - } + public ItemGoldenLaurel() { + super(LibItemNames.GOLDEN_LAUREL); + MinecraftForge.EVENT_BUS.register(this); + } - @SubscribeEvent(priority = EventPriority.HIGHEST) - public void onPlayerDeath(LivingDeathEvent event) { - if (event.entity instanceof EntityPlayer) { - EntityPlayer player = (EntityPlayer) event.entity; - ItemStack amulet = PlayerHandler.getPlayerBaubles(player).getStackInSlot(0); + @SubscribeEvent(priority = EventPriority.HIGHEST) + public void onPlayerDeath(LivingDeathEvent event) { + if(event.entity instanceof EntityPlayer) { + EntityPlayer player = (EntityPlayer) event.entity; + ItemStack amulet = PlayerHandler.getPlayerBaubles(player).getStackInSlot(0); - if (amulet != null && amulet.getItem() == this) { - event.setCanceled(true); - player.setHealth(player.getMaxHealth()); - player.addPotionEffect(new PotionEffect(Potion.resistance.id, 300, 6)); - player.addChatMessage(new ChatComponentTranslation("botaniamisc.savedByLaurel")); - player.worldObj.playSoundAtEntity(player, "botania:goldenLaurel", 1F, 0.3F); - PlayerHandler.getPlayerBaubles(player).setInventorySlotContents(0, null); - } - } - } + if(amulet != null && amulet.getItem() == this) { + event.setCanceled(true); + player.setHealth(player.getMaxHealth()); + player.addPotionEffect(new PotionEffect(Potion.resistance.id, 300, 6)); + player.addChatMessage(new ChatComponentTranslation("botaniamisc.savedByLaurel")); + player.worldObj.playSoundAtEntity(player, "botania:goldenLaurel", 1F, 0.3F); + PlayerHandler.getPlayerBaubles(player).setInventorySlotContents(0, null); + } + } + } - @Override - public BaubleType getBaubleType(ItemStack itemstack) { - return BaubleType.AMULET; - } + @Override + public BaubleType getBaubleType(ItemStack itemstack) { + return BaubleType.AMULET; + } - @Override - @SideOnly(Side.CLIENT) - public void onPlayerBaubleRender(ItemStack stack, RenderPlayerEvent event, RenderType type) { - if (type == RenderType.HEAD) { - float f = itemIcon.getMinU(); - float f1 = itemIcon.getMaxU(); - float f2 = itemIcon.getMinV(); - float f3 = itemIcon.getMaxV(); - boolean armor = event.entityPlayer.getCurrentArmor(3) != null; - Helper.translateToHeadLevel(event.entityPlayer); - Minecraft.getMinecraft().renderEngine.bindTexture(TextureMap.locationItemsTexture); - GL11.glRotatef(180F, 0F, 0F, 1F); - GL11.glRotatef(90F, 0F, 1F, 0F); - GL11.glRotatef(-100F, 1F, 0F, 0F); - GL11.glTranslatef(-0.5F, -0.55F, 0.3F); - if (armor) { - GL11.glScalef(1.1F, 1.1F, 1F); - GL11.glTranslatef(-0.05F, -0.1F, 0F); - } - ItemRenderer.renderItemIn2D( - Tessellator.instance, f1, f2, f, f3, itemIcon.getIconWidth(), itemIcon.getIconHeight(), 1F / 32F); - } - } + @Override + @SideOnly(Side.CLIENT) + public void onPlayerBaubleRender(ItemStack stack, RenderPlayerEvent event, RenderType type) { + if(type == RenderType.HEAD) { + float f = itemIcon.getMinU(); + float f1 = itemIcon.getMaxU(); + float f2 = itemIcon.getMinV(); + float f3 = itemIcon.getMaxV(); + boolean armor = event.entityPlayer.getCurrentArmor(3) != null; + Helper.translateToHeadLevel(event.entityPlayer); + Minecraft.getMinecraft().renderEngine.bindTexture(TextureMap.locationItemsTexture); + GL11.glRotatef(180F, 0F, 0F, 1F); + GL11.glRotatef(90F, 0F, 1F, 0F); + GL11.glRotatef(-100F, 1F, 0F, 0F); + GL11.glTranslatef(-0.5F, -0.55F, 0.3F); + if(armor) { + GL11.glScalef(1.1F, 1.1F, 1F); + GL11.glTranslatef(-0.05F, -0.1F, 0F); + } + ItemRenderer.renderItemIn2D(Tessellator.instance, f1, f2, f, f3, itemIcon.getIconWidth(), itemIcon.getIconHeight(), 1F / 32F); + } + } } diff --git a/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemGreaterAuraRing.java b/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemGreaterAuraRing.java index fff95e532d..6a94b5843d 100644 --- a/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemGreaterAuraRing.java +++ b/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemGreaterAuraRing.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Apr 24, 2014, 5:12:53 PM (GMT)] */ package vazkii.botania.common.item.equipment.bauble; @@ -14,12 +14,12 @@ public class ItemGreaterAuraRing extends ItemAuraRing { - public ItemGreaterAuraRing() { - super(LibItemNames.AURA_RING_GREATER); - } + public ItemGreaterAuraRing() { + super(LibItemNames.AURA_RING_GREATER); + } - @Override - int getDelay() { - return 2; - } + @Override + int getDelay() { + return 2; + } } diff --git a/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemGreaterMagnetRing.java b/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemGreaterMagnetRing.java index 4426c76e59..8a19839598 100644 --- a/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemGreaterMagnetRing.java +++ b/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemGreaterMagnetRing.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Aug 21, 2015, 9:00:04 PM (GMT)] */ package vazkii.botania.common.item.equipment.bauble; @@ -14,7 +14,8 @@ public class ItemGreaterMagnetRing extends ItemMagnetRing { - public ItemGreaterMagnetRing() { - super(LibItemNames.MAGNET_RING_GREATER, 16); - } + public ItemGreaterMagnetRing() { + super(LibItemNames.MAGNET_RING_GREATER, 16); + } + } diff --git a/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemGreaterManaRing.java b/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemGreaterManaRing.java index cd14330c9c..c680da8f33 100644 --- a/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemGreaterManaRing.java +++ b/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemGreaterManaRing.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Apr 24, 2014, 5:20:54 PM (GMT)] */ package vazkii.botania.common.item.equipment.bauble; @@ -15,14 +15,15 @@ public class ItemGreaterManaRing extends ItemManaRing { - private static final int MAX_MANA = ItemManaRing.MAX_MANA * 4; + private static final int MAX_MANA = ItemManaRing.MAX_MANA * 4; - public ItemGreaterManaRing() { - super(LibItemNames.MANA_RING_GREATER); - } + public ItemGreaterManaRing() { + super(LibItemNames.MANA_RING_GREATER); + } + + @Override + public int getMaxMana(ItemStack stack) { + return MAX_MANA; + } - @Override - public int getMaxMana(ItemStack stack) { - return MAX_MANA; - } } diff --git a/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemHolyCloak.java b/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemHolyCloak.java index 7a004a7dbe..50776abf6a 100644 --- a/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemHolyCloak.java +++ b/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemHolyCloak.java @@ -2,20 +2,14 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Dec 4, 2014, 11:03:13 PM (GMT)] */ package vazkii.botania.common.item.equipment.bauble; -import baubles.api.BaubleType; -import baubles.common.container.InventoryBaubles; -import baubles.common.lib.PlayerHandler; -import cpw.mods.fml.common.eventhandler.SubscribeEvent; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; import net.minecraft.client.Minecraft; import net.minecraft.client.model.ModelBiped; import net.minecraft.entity.EntityLivingBase; @@ -25,127 +19,129 @@ import net.minecraftforge.client.event.RenderPlayerEvent; import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.event.entity.living.LivingHurtEvent; + import org.lwjgl.opengl.GL11; + import vazkii.botania.api.item.IBaubleRender; import vazkii.botania.client.lib.LibResources; import vazkii.botania.common.Botania; import vazkii.botania.common.core.helper.ItemNBTHelper; import vazkii.botania.common.lib.LibItemNames; +import baubles.api.BaubleType; +import baubles.common.container.InventoryBaubles; +import baubles.common.lib.PlayerHandler; +import cpw.mods.fml.common.eventhandler.SubscribeEvent; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; public class ItemHolyCloak extends ItemBauble implements IBaubleRender { - private static final ResourceLocation texture = new ResourceLocation(LibResources.MODEL_HOLY_CLOAK); - - @SideOnly(Side.CLIENT) - private static ModelBiped model; - - private static final String TAG_COOLDOWN = "cooldown"; - private static final String TAG_IN_EFFECT = "inEffect"; - - public ItemHolyCloak() { - this(LibItemNames.HOLY_CLOAK); - MinecraftForge.EVENT_BUS.register(this); - } - - public ItemHolyCloak(String name) { - super(name); - } - - @SubscribeEvent - public void onPlayerDamage(LivingHurtEvent event) { - if (event.entityLiving instanceof EntityPlayer) { - EntityPlayer player = (EntityPlayer) event.entityLiving; - InventoryBaubles baubles = PlayerHandler.getPlayerBaubles(player); - ItemStack belt = baubles.getStackInSlot(3); - if (belt != null && belt.getItem() instanceof ItemHolyCloak && !isInEffect(belt)) { - ItemHolyCloak cloak = (ItemHolyCloak) belt.getItem(); - int cooldown = getCooldown(belt); - - // Used to prevent StackOverflows with mobs that deal damage when damaged - setInEffect(belt, true); - if (cooldown == 0 && cloak.effectOnDamage(event, player, belt)) - setCooldown(belt, cloak.getCooldownTime(belt)); - setInEffect(belt, false); - } - } - } - - @Override - public void onWornTick(ItemStack stack, EntityLivingBase player) { - int cooldown = getCooldown(stack); - if (cooldown > 0) setCooldown(stack, cooldown - 1); - } - - public boolean effectOnDamage(LivingHurtEvent event, EntityPlayer player, ItemStack stack) { - if (!event.source.isMagicDamage()) { - event.setCanceled(true); - player.worldObj.playSoundAtEntity(player, "botania:holyCloak", 1F, 1F); - for (int i = 0; i < 30; i++) { - double x = player.posX + Math.random() * player.width * 2 - player.width; - double y = player.posY + Math.random() * player.height; - double z = player.posZ + Math.random() * player.width * 2 - player.width; - boolean yellow = Math.random() > 0.5; - Botania.proxy.sparkleFX( - player.worldObj, - x, - y, - z, - yellow ? 1F : 0.3F, - yellow ? 1F : 0.3F, - yellow ? 0.3F : 1F, - 0.8F + (float) Math.random() * 0.4F, - 3); - } - return true; - } - - return false; - } - - public int getCooldownTime(ItemStack stack) { - return 200; - } - - @Override - public BaubleType getBaubleType(ItemStack arg0) { - return BaubleType.BELT; - } - - public static int getCooldown(ItemStack stack) { - return ItemNBTHelper.getInt(stack, TAG_COOLDOWN, 0); - } - - public static void setCooldown(ItemStack stack, int cooldown) { - ItemNBTHelper.setInt(stack, TAG_COOLDOWN, cooldown); - } - - public static boolean isInEffect(ItemStack stack) { - return ItemNBTHelper.getBoolean(stack, TAG_IN_EFFECT, false); - } - - public static void setInEffect(ItemStack stack, boolean effect) { - ItemNBTHelper.setBoolean(stack, TAG_IN_EFFECT, effect); - } - - @SideOnly(Side.CLIENT) - ResourceLocation getRenderTexture() { - return texture; - } - - @Override - @SideOnly(Side.CLIENT) - public void onPlayerBaubleRender(ItemStack stack, RenderPlayerEvent event, RenderType type) { - if (type == RenderType.BODY) { - Minecraft.getMinecraft().renderEngine.bindTexture(getRenderTexture()); - Helper.rotateIfSneaking(event.entityPlayer); - boolean armor = event.entityPlayer.getCurrentArmor(2) != null; - GL11.glTranslatef(0F, armor ? -0.07F : -0.01F, 0F); - - float s = 0.1F; - GL11.glScalef(s, s, s); - if (model == null) model = new ModelBiped(); - - model.bipedBody.render(1F); - } - } + private static final ResourceLocation texture = new ResourceLocation(LibResources.MODEL_HOLY_CLOAK); + @SideOnly(Side.CLIENT) + private static ModelBiped model; + + private static final String TAG_COOLDOWN = "cooldown"; + private static final String TAG_IN_EFFECT = "inEffect"; + + public ItemHolyCloak() { + this(LibItemNames.HOLY_CLOAK); + MinecraftForge.EVENT_BUS.register(this); + } + + public ItemHolyCloak(String name) { + super(name); + } + + @SubscribeEvent + public void onPlayerDamage(LivingHurtEvent event) { + if(event.entityLiving instanceof EntityPlayer) { + EntityPlayer player = (EntityPlayer) event.entityLiving; + InventoryBaubles baubles = PlayerHandler.getPlayerBaubles(player); + ItemStack belt = baubles.getStackInSlot(3); + if(belt != null && belt.getItem() instanceof ItemHolyCloak && !isInEffect(belt)) { + ItemHolyCloak cloak = (ItemHolyCloak) belt.getItem(); + int cooldown = getCooldown(belt); + + // Used to prevent StackOverflows with mobs that deal damage when damaged + setInEffect(belt, true); + if(cooldown == 0 && cloak.effectOnDamage(event, player, belt)) + setCooldown(belt, cloak.getCooldownTime(belt)); + setInEffect(belt, false); + } + } + } + + @Override + public void onWornTick(ItemStack stack, EntityLivingBase player) { + int cooldown = getCooldown(stack); + if(cooldown > 0) + setCooldown(stack, cooldown - 1); + } + + public boolean effectOnDamage(LivingHurtEvent event, EntityPlayer player, ItemStack stack) { + if(!event.source.isMagicDamage()) { + event.setCanceled(true); + player.worldObj.playSoundAtEntity(player, "botania:holyCloak", 1F, 1F); + for(int i = 0; i < 30; i++) { + double x = player.posX + Math.random() * player.width * 2 - player.width; + double y = player.posY + Math.random() * player.height; + double z = player.posZ + Math.random() * player.width * 2 - player.width; + boolean yellow = Math.random() > 0.5; + Botania.proxy.sparkleFX(player.worldObj, x, y, z, yellow ? 1F : 0.3F, yellow ? 1F : 0.3F, yellow ? 0.3F : 1F, 0.8F + (float) Math.random() * 0.4F, 3); + } + return true; + } + + return false; + } + + public int getCooldownTime(ItemStack stack) { + return 200; + } + + @Override + public BaubleType getBaubleType(ItemStack arg0) { + return BaubleType.BELT; + } + + public static int getCooldown(ItemStack stack) { + return ItemNBTHelper.getInt(stack, TAG_COOLDOWN, 0); + } + + public static void setCooldown(ItemStack stack, int cooldown) { + ItemNBTHelper.setInt(stack, TAG_COOLDOWN, cooldown); + } + + public static boolean isInEffect(ItemStack stack) { + return ItemNBTHelper.getBoolean(stack, TAG_IN_EFFECT, false); + } + + public static void setInEffect(ItemStack stack, boolean effect) { + ItemNBTHelper.setBoolean(stack, TAG_IN_EFFECT, effect); + } + + @SideOnly(Side.CLIENT) + ResourceLocation getRenderTexture() { + return texture; + } + + @Override + @SideOnly(Side.CLIENT) + public void onPlayerBaubleRender(ItemStack stack, RenderPlayerEvent event, RenderType type) { + if(type == RenderType.BODY) { + Minecraft.getMinecraft().renderEngine.bindTexture(getRenderTexture()); + Helper.rotateIfSneaking(event.entityPlayer); + boolean armor = event.entityPlayer.getCurrentArmor(2) != null; + GL11.glTranslatef(0F, armor ? -0.07F : -0.01F, 0F); + + float s = 0.1F; + GL11.glScalef(s, s, s); + if(model == null) + model = new ModelBiped(); + + model.bipedBody.render(1F); + } + } + } + diff --git a/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemIcePendant.java b/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemIcePendant.java index df3a28100e..881113eaff 100644 --- a/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemIcePendant.java +++ b/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemIcePendant.java @@ -2,19 +2,19 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Apr 26, 2014, 2:06:17 PM (GMT)] */ package vazkii.botania.common.item.equipment.bauble; -import baubles.api.BaubleType; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; + import net.minecraft.block.material.Material; import net.minecraft.client.Minecraft; import net.minecraft.client.renderer.ItemRenderer; @@ -30,113 +30,120 @@ import net.minecraft.util.MathHelper; import net.minecraft.world.World; import net.minecraftforge.client.event.RenderPlayerEvent; + import org.lwjgl.opengl.GL11; + import vazkii.botania.api.item.IBaubleRender; import vazkii.botania.client.core.helper.IconHelper; import vazkii.botania.common.lib.LibItemNames; +import baubles.api.BaubleType; public class ItemIcePendant extends ItemBauble implements IBaubleRender { - IIcon gemIcon; - public static Map> playerIceBlocks = new HashMap(); - - public ItemIcePendant() { - super(LibItemNames.ICE_PENDANT); - } - - @Override - public BaubleType getBaubleType(ItemStack itemstack) { - return BaubleType.AMULET; - } - - @Override - public void registerIcons(IIconRegister par1IconRegister) { - super.registerIcons(par1IconRegister); - gemIcon = IconHelper.forItem(par1IconRegister, this, "Gem"); - } - - @Override - public void onWornTick(ItemStack stack, EntityLivingBase entity) { - super.onWornTick(stack, entity); - - if (entity instanceof EntityPlayer) { - EntityPlayer player = (EntityPlayer) entity; - - if (!player.worldObj.isRemote) tickIceRemovers(player); - - if (!player.isSneaking() && !player.isInsideOfMaterial(Material.water) && !player.worldObj.isRemote) { - int x = MathHelper.floor_double(player.posX); - int y = MathHelper.floor_double(player.posY - (player.isInWater() ? 0 : 1)); - int z = MathHelper.floor_double(player.posZ); - - int range = 3; - for (int i = -range; i < range + 1; i++) - for (int j = -range; j < range + 1; j++) { - int x1 = x + i; - int z1 = z + j; - - addIceBlock(player, new ChunkCoordinates(x1, y, z1)); - } - } - } - } - - private void addIceBlock(EntityPlayer player, ChunkCoordinates coords) { - String user = player.getCommandSenderName(); - if (!playerIceBlocks.containsKey(user)) playerIceBlocks.put(user, new ArrayList()); - - List ice = playerIceBlocks.get(user); - if (player.worldObj.getBlock(coords.posX, coords.posY, coords.posZ) == Blocks.water - && player.worldObj.getBlockMetadata(coords.posX, coords.posY, coords.posZ) == 0) { - player.worldObj.setBlock(coords.posX, coords.posY, coords.posZ, Blocks.ice); - - if (!player.worldObj.isRemote) ice.add(new IceRemover(coords)); - } - } - - private void tickIceRemovers(EntityPlayer player) { - String user = player.getCommandSenderName(); - if (!playerIceBlocks.containsKey(user)) return; - - List removers = playerIceBlocks.get(user); - for (IceRemover ice : new ArrayList(removers)) ice.tick(player.worldObj, removers); - } - - @Override - public void onPlayerBaubleRender(ItemStack stack, RenderPlayerEvent event, RenderType type) { - if (type == RenderType.BODY) { - Minecraft.getMinecraft().renderEngine.bindTexture(TextureMap.locationItemsTexture); - Helper.rotateIfSneaking(event.entityPlayer); - boolean armor = event.entityPlayer.getCurrentArmor(2) != null; - GL11.glRotatef(180F, 1F, 0F, 0F); - GL11.glTranslatef(-0.36F, -0.3F, armor ? 0.2F : 0.15F); - GL11.glRotatef(-45F, 0F, 0F, 1F); - GL11.glScalef(0.5F, 0.5F, 0.5F); - - float f = gemIcon.getMinU(); - float f1 = gemIcon.getMaxU(); - float f2 = gemIcon.getMinV(); - float f3 = gemIcon.getMaxV(); - ItemRenderer.renderItemIn2D( - Tessellator.instance, f1, f2, f, f3, gemIcon.getIconWidth(), gemIcon.getIconHeight(), 1F / 32F); - } - } - - class IceRemover { - - int time = 30; - final ChunkCoordinates coords; - - public IceRemover(ChunkCoordinates coords) { - this.coords = coords; - } - - public void tick(World world, List list) { - if (world.getBlock(coords.posX, coords.posY, coords.posZ) == Blocks.ice) { - if (time-- == 0) world.setBlock(coords.posX, coords.posY, coords.posZ, Blocks.water, 0, 1 | 2); - else return; - list.remove(this); - } - } - } + IIcon gemIcon; + public static Map> playerIceBlocks = new HashMap(); + + public ItemIcePendant() { + super(LibItemNames.ICE_PENDANT); + } + + @Override + public BaubleType getBaubleType(ItemStack itemstack) { + return BaubleType.AMULET; + } + + @Override + public void registerIcons(IIconRegister par1IconRegister) { + super.registerIcons(par1IconRegister); + gemIcon = IconHelper.forItem(par1IconRegister, this, "Gem"); + } + + @Override + public void onWornTick(ItemStack stack, EntityLivingBase entity) { + super.onWornTick(stack, entity); + + if(entity instanceof EntityPlayer) { + EntityPlayer player = (EntityPlayer) entity; + + if(!player.worldObj.isRemote) + tickIceRemovers(player); + + if(!player.isSneaking() && !player.isInsideOfMaterial(Material.water) && !player.worldObj.isRemote) { + int x = MathHelper.floor_double(player.posX); + int y = MathHelper.floor_double(player.posY - (player.isInWater() ? 0 : 1)); + int z = MathHelper.floor_double(player.posZ); + + int range = 3; + for(int i = -range; i < range + 1; i++) + for(int j = -range; j < range + 1; j++) { + int x1 = x + i; + int z1 = z + j; + + addIceBlock(player, new ChunkCoordinates(x1, y, z1)); + } + } + } + } + + private void addIceBlock(EntityPlayer player, ChunkCoordinates coords) { + String user = player.getCommandSenderName(); + if(!playerIceBlocks.containsKey(user)) + playerIceBlocks.put(user, new ArrayList()); + + List ice = playerIceBlocks.get(user); + if(player.worldObj.getBlock(coords.posX, coords.posY, coords.posZ) == Blocks.water && player.worldObj.getBlockMetadata(coords.posX, coords.posY, coords.posZ) == 0) { + player.worldObj.setBlock(coords.posX, coords.posY, coords.posZ, Blocks.ice); + + if(!player.worldObj.isRemote) + ice.add(new IceRemover(coords)); + } + } + + private void tickIceRemovers(EntityPlayer player) { + String user = player.getCommandSenderName(); + if(!playerIceBlocks.containsKey(user)) + return; + + List removers = playerIceBlocks.get(user); + for(IceRemover ice : new ArrayList(removers)) + ice.tick(player.worldObj, removers); + } + + @Override + public void onPlayerBaubleRender(ItemStack stack, RenderPlayerEvent event, RenderType type) { + if(type == RenderType.BODY) { + Minecraft.getMinecraft().renderEngine.bindTexture(TextureMap.locationItemsTexture); + Helper.rotateIfSneaking(event.entityPlayer); + boolean armor = event.entityPlayer.getCurrentArmor(2) != null; + GL11.glRotatef(180F, 1F, 0F, 0F); + GL11.glTranslatef(-0.36F, -0.3F, armor ? 0.2F : 0.15F); + GL11.glRotatef(-45F, 0F, 0F, 1F); + GL11.glScalef(0.5F, 0.5F, 0.5F); + + float f = gemIcon.getMinU(); + float f1 = gemIcon.getMaxU(); + float f2 = gemIcon.getMinV(); + float f3 = gemIcon.getMaxV(); + ItemRenderer.renderItemIn2D(Tessellator.instance, f1, f2, f, f3, gemIcon.getIconWidth(), gemIcon.getIconHeight(), 1F / 32F); + } + } + + class IceRemover { + + int time = 30; + final ChunkCoordinates coords; + + public IceRemover(ChunkCoordinates coords) { + this.coords = coords; + } + + public void tick(World world, List list) { + if(world.getBlock(coords.posX, coords.posY, coords.posZ) == Blocks.ice) { + if(time-- == 0) + world.setBlock(coords.posX, coords.posY, coords.posZ, Blocks.water, 0, 1 | 2); + else return; + list.remove(this); + } + } + } } diff --git a/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemItemFinder.java b/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemItemFinder.java index a44a77c9b5..2acf57719e 100644 --- a/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemItemFinder.java +++ b/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemItemFinder.java @@ -2,24 +2,17 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jul 31, 2014, 12:59:16 AM (GMT)] */ package vazkii.botania.common.item.equipment.bauble; -import baubles.api.BaubleType; -import baubles.common.container.InventoryBaubles; -import baubles.common.lib.PlayerHandler; -import baubles.common.network.PacketHandler; -import baubles.common.network.PacketSyncBauble; -import cpw.mods.fml.relauncher.ReflectionHelper; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; import java.util.ArrayList; import java.util.List; + import net.minecraft.client.Minecraft; import net.minecraft.client.renderer.ItemRenderer; import net.minecraft.client.renderer.Tessellator; @@ -41,225 +34,203 @@ import net.minecraft.util.MathHelper; import net.minecraft.village.MerchantRecipe; import net.minecraftforge.client.event.RenderPlayerEvent; + import org.lwjgl.opengl.GL11; + import vazkii.botania.api.item.IBaubleRender; import vazkii.botania.client.core.helper.IconHelper; import vazkii.botania.common.Botania; import vazkii.botania.common.core.helper.ItemNBTHelper; import vazkii.botania.common.lib.LibItemNames; import vazkii.botania.common.lib.LibObfuscation; +import baubles.api.BaubleType; +import baubles.common.container.InventoryBaubles; +import baubles.common.lib.PlayerHandler; +import baubles.common.network.PacketHandler; +import baubles.common.network.PacketSyncBauble; +import cpw.mods.fml.relauncher.ReflectionHelper; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; public class ItemItemFinder extends ItemBauble implements IBaubleRender { - IIcon gemIcon; - private static final String TAG_POSITIONS = "highlightPositions"; - - public ItemItemFinder() { - super(LibItemNames.ITEM_FINDER); - } - - @Override - public void registerIcons(IIconRegister par1IconRegister) { - super.registerIcons(par1IconRegister); - gemIcon = IconHelper.forItem(par1IconRegister, this, "Gem"); - } - - @Override - public void onWornTick(ItemStack stack, EntityLivingBase player) { - super.onWornTick(stack, player); - - if (!(player instanceof EntityPlayer)) return; - - if (player.worldObj.isRemote) tickClient(stack, (EntityPlayer) player); - else tickServer(stack, (EntityPlayer) player); - } - - public void tickClient(ItemStack stack, EntityPlayer player) { - if (!Botania.proxy.isTheClientPlayer(player)) return; - - String pos = ItemNBTHelper.getString(stack, TAG_POSITIONS, ""); - String[] tokens = pos.split(";"); - - for (String token : tokens) { - if (token.isEmpty()) continue; - - if (token.contains(",")) { - String[] tokens_ = token.split(","); - int x = Integer.parseInt(tokens_[0]); - int y = Integer.parseInt(tokens_[1]); - int z = Integer.parseInt(tokens_[2]); - float m = 0.02F; - Botania.proxy.setWispFXDepthTest(false); - Botania.proxy.wispFX( - player.worldObj, - x + (float) Math.random(), - y + (float) Math.random(), - z + (float) Math.random(), - (float) Math.random(), - (float) Math.random(), - (float) Math.random(), - 0.15F + 0.05F * (float) Math.random(), - m * (float) (Math.random() - 0.5), - m * (float) (Math.random() - 0.5), - m * (float) (Math.random() - 0.5)); - } else { - int id = Integer.parseInt(token); - Entity e = player.worldObj.getEntityByID(id); - - if (e != null && Math.random() < 0.6) { - Botania.proxy.setWispFXDepthTest(Math.random() < 0.6); - Botania.proxy.wispFX( - player.worldObj, - e.posX + (float) (Math.random() * 0.5 - 0.25) * 0.45F, - e.posY + e.height, - e.posZ + (float) (Math.random() * 0.5 - 0.25) * 0.45F, - (float) Math.random(), - (float) Math.random(), - (float) Math.random(), - 0.15F + 0.05F * (float) Math.random(), - -0.05F - 0.03F * (float) Math.random()); - } - } - } - Botania.proxy.setWispFXDepthTest(true); - } - - public void tickServer(ItemStack stack, EntityPlayer player) { - ItemStack pstack = player.getCurrentEquippedItem(); - StringBuilder positionsBuilder = new StringBuilder(); - - if (pstack != null || player.isSneaking()) { - int range = 24; - - List entities = player.worldObj.getEntitiesWithinAABB( - Entity.class, - AxisAlignedBB.getBoundingBox( - player.posX - range, - player.posY - range, - player.posZ - range, - player.posX + range, - player.posY + range, - player.posZ + range)); - for (Entity e : entities) { - if (e == player) continue; - - if (e instanceof EntityItem) { - EntityItem item = (EntityItem) e; - ItemStack istack = item.getEntityItem(); - if (player.isSneaking() - || istack.isItemEqual(pstack) && ItemStack.areItemStackTagsEqual(istack, pstack)) - positionsBuilder.append(item.getEntityId()).append(";"); - - } else if (e instanceof IInventory) { - IInventory inv = (IInventory) e; - if (scanInventory(inv, pstack)) - positionsBuilder.append(e.getEntityId()).append(";"); - - } else if (e instanceof EntityHorse) { - EntityHorse horse = (EntityHorse) e; - AnimalChest chest = - ReflectionHelper.getPrivateValue(EntityHorse.class, horse, LibObfuscation.HORSE_CHEST); - if (scanInventory(chest, pstack)) - positionsBuilder.append(horse.getEntityId()).append(";"); - - } else if (e instanceof EntityPlayer) { - EntityPlayer player_ = (EntityPlayer) e; - InventoryPlayer inv = player_.inventory; - InventoryBaubles binv = PlayerHandler.getPlayerBaubles(player_); - if (scanInventory(inv, pstack) || scanInventory(binv, pstack)) - positionsBuilder.append(player_.getEntityId()).append(";"); - - } else if (e instanceof EntityVillager) { - EntityVillager villager = (EntityVillager) e; - ArrayList recipes = villager.getRecipes(player); - if (pstack != null && recipes != null) - for (MerchantRecipe recipe : recipes) - if (recipe != null - && !recipe.isRecipeDisabled() - && (equalStacks(pstack, recipe.getItemToBuy()) - || equalStacks(pstack, recipe.getItemToSell()))) - positionsBuilder.append(villager.getEntityId()).append(";"); - - } else if (e instanceof EntityLivingBase) { - EntityLivingBase living = (EntityLivingBase) e; - ItemStack estack = living.getEquipmentInSlot(0); - if (pstack != null && estack != null && equalStacks(estack, pstack)) - positionsBuilder.append(living.getEntityId()).append(";"); - } - } - - if (pstack != null) { - range = 12; - int x = MathHelper.floor_double(player.posX); - int y = MathHelper.floor_double(player.posY); - int z = MathHelper.floor_double(player.posZ); - for (int i = -range; i < range + 1; i++) - for (int j = -range; j < range + 1; j++) - for (int k = -range; k < range + 1; k++) { - int xp = x + i; - int yp = y + j; - int zp = z + k; - TileEntity tile = player.worldObj.getTileEntity(xp, yp, zp); - if (tile != null && tile instanceof IInventory) { - IInventory inv = (IInventory) tile; - if (scanInventory(inv, pstack)) - positionsBuilder - .append(xp) - .append(",") - .append(yp) - .append(",") - .append(zp) - .append(";"); - } - } - } - } - - String current = ItemNBTHelper.getString(stack, TAG_POSITIONS, ""); - String positions = positionsBuilder.toString(); - if (!current.equals(positions)) { - ItemNBTHelper.setString(stack, TAG_POSITIONS, positions); - PacketHandler.INSTANCE.sendToAll(new PacketSyncBauble(player, 0)); - } - } - - boolean equalStacks(ItemStack stack1, ItemStack stack2) { - return stack1.isItemEqual(stack2) && ItemStack.areItemStackTagsEqual(stack1, stack2); - } - - boolean scanInventory(IInventory inv, ItemStack pstack) { - if (pstack == null) return false; - - for (int l = 0; l < inv.getSizeInventory(); l++) { - ItemStack istack = inv.getStackInSlot(l); - if (istack != null && equalStacks(istack, pstack)) return true; - } - - return false; - } - - @Override - public BaubleType getBaubleType(ItemStack arg0) { - return BaubleType.AMULET; - } - - @Override - @SideOnly(Side.CLIENT) - public void onPlayerBaubleRender(ItemStack stack, RenderPlayerEvent event, RenderType type) { - if (type == RenderType.HEAD) { - float f = gemIcon.getMinU(); - float f1 = gemIcon.getMaxU(); - float f2 = gemIcon.getMinV(); - float f3 = gemIcon.getMaxV(); - boolean armor = event.entityPlayer.getCurrentArmor(3) != null; - Helper.translateToHeadLevel(event.entityPlayer); - Minecraft.getMinecraft().renderEngine.bindTexture(TextureMap.locationItemsTexture); - GL11.glRotatef(90F, 0F, 1F, 0F); - GL11.glRotatef(180F, 1F, 0F, 0F); - GL11.glTranslatef(-0.4F, 0.1F, armor ? -0.3F : -0.25F); - GL11.glScalef(0.75F, 0.75F, 0.75F); - ItemRenderer.renderItemIn2D( - Tessellator.instance, f1, f2, f, f3, gemIcon.getIconWidth(), gemIcon.getIconHeight(), 1F / 16F); - } - } + IIcon gemIcon; + private static final String TAG_POSITIONS = "highlightPositions"; + + public ItemItemFinder() { + super(LibItemNames.ITEM_FINDER); + } + + @Override + public void registerIcons(IIconRegister par1IconRegister) { + super.registerIcons(par1IconRegister); + gemIcon = IconHelper.forItem(par1IconRegister, this, "Gem"); + } + + @Override + public void onWornTick(ItemStack stack, EntityLivingBase player) { + super.onWornTick(stack, player); + + if(!(player instanceof EntityPlayer)) + return; + + if(player.worldObj.isRemote) + tickClient(stack, (EntityPlayer) player); + else tickServer(stack, (EntityPlayer) player); + } + + public void tickClient(ItemStack stack, EntityPlayer player) { + if(!Botania.proxy.isTheClientPlayer(player)) + return; + + String pos = ItemNBTHelper.getString(stack, TAG_POSITIONS, ""); + String[] tokens = pos.split(";"); + + for(String token : tokens) { + if(token.isEmpty()) + continue; + + if(token.contains(",")) { + String[] tokens_ = token.split(","); + int x = Integer.parseInt(tokens_[0]); + int y = Integer.parseInt(tokens_[1]); + int z = Integer.parseInt(tokens_[2]); + float m = 0.02F; + Botania.proxy.setWispFXDepthTest(false); + Botania.proxy.wispFX(player.worldObj, x + (float) Math.random(), y + (float) Math.random(), z + (float) Math.random(), (float) Math.random(), (float) Math.random(), (float) Math.random(), 0.15F + 0.05F * (float) Math.random(), m * (float) (Math.random() - 0.5), m * (float) (Math.random() - 0.5), m * (float) (Math.random() - 0.5)); + } else { + int id = Integer.parseInt(token); + Entity e = player.worldObj.getEntityByID(id); + + if(e != null && Math.random() < 0.6) { + Botania.proxy.setWispFXDepthTest(Math.random() < 0.6); + Botania.proxy.wispFX(player.worldObj, e.posX + (float) (Math.random() * 0.5 - 0.25) * 0.45F, e.posY + e.height, e.posZ + (float) (Math.random() * 0.5 - 0.25) * 0.45F, (float) Math.random(), (float) Math.random(), (float) Math.random(), 0.15F + 0.05F * (float) Math.random(), -0.05F - 0.03F * (float) Math.random()); + } + } + } + Botania.proxy.setWispFXDepthTest(true); + } + + public void tickServer(ItemStack stack, EntityPlayer player) { + ItemStack pstack = player.getCurrentEquippedItem(); + StringBuilder positionsBuilder = new StringBuilder(); + + if(pstack != null || player.isSneaking()) { + int range = 24; + + List entities = player.worldObj.getEntitiesWithinAABB(Entity.class, AxisAlignedBB.getBoundingBox(player.posX - range, player.posY - range, player.posZ - range, player.posX + range, player.posY + range, player.posZ + range)); + for(Entity e : entities) { + if(e == player) + continue; + + if(e instanceof EntityItem) { + EntityItem item = (EntityItem) e; + ItemStack istack = item.getEntityItem(); + if(player.isSneaking() || istack.isItemEqual(pstack) && ItemStack.areItemStackTagsEqual(istack, pstack)) + positionsBuilder.append(item.getEntityId()).append(";"); + + } else if(e instanceof IInventory) { + IInventory inv = (IInventory) e; + if(scanInventory(inv, pstack)) + positionsBuilder.append(e.getEntityId()).append(";"); + + } else if(e instanceof EntityHorse) { + EntityHorse horse = (EntityHorse) e; + AnimalChest chest = ReflectionHelper.getPrivateValue(EntityHorse.class, horse, LibObfuscation.HORSE_CHEST); + if(scanInventory(chest, pstack)) + positionsBuilder.append(horse.getEntityId()).append(";"); + + } else if(e instanceof EntityPlayer) { + EntityPlayer player_ = (EntityPlayer) e; + InventoryPlayer inv = player_.inventory; + InventoryBaubles binv = PlayerHandler.getPlayerBaubles(player_); + if(scanInventory(inv, pstack) || scanInventory(binv, pstack)) + positionsBuilder.append(player_.getEntityId()).append(";"); + + } else if(e instanceof EntityVillager) { + EntityVillager villager = (EntityVillager) e; + ArrayList recipes = villager.getRecipes(player); + if(pstack != null && recipes != null) + for(MerchantRecipe recipe : recipes) + if(recipe != null && !recipe.isRecipeDisabled() && (equalStacks(pstack, recipe.getItemToBuy()) || equalStacks(pstack, recipe.getItemToSell()))) + positionsBuilder.append(villager.getEntityId()).append(";"); + + } else if(e instanceof EntityLivingBase) { + EntityLivingBase living = (EntityLivingBase) e; + ItemStack estack = living.getEquipmentInSlot(0); + if(pstack != null && estack != null && equalStacks(estack, pstack)) + positionsBuilder.append(living.getEntityId()).append(";"); + } + } + + if(pstack != null) { + range = 12; + int x = MathHelper.floor_double(player.posX); + int y = MathHelper.floor_double(player.posY); + int z = MathHelper.floor_double(player.posZ); + for(int i = -range; i < range + 1; i++) + for(int j = -range; j < range + 1; j++) + for(int k = -range; k < range + 1; k++) { + int xp = x + i; + int yp = y + j; + int zp = z + k; + TileEntity tile = player.worldObj.getTileEntity(xp, yp, zp); + if(tile != null && tile instanceof IInventory) { + IInventory inv = (IInventory) tile; + if(scanInventory(inv, pstack)) + positionsBuilder.append(xp).append(",").append(yp).append(",").append(zp).append(";"); + } + } + } + } + + String current = ItemNBTHelper.getString(stack, TAG_POSITIONS, ""); + String positions = positionsBuilder.toString(); + if(!current.equals(positions)) { + ItemNBTHelper.setString(stack, TAG_POSITIONS, positions); + PacketHandler.INSTANCE.sendToAll(new PacketSyncBauble(player, 0)); + } + } + + boolean equalStacks(ItemStack stack1, ItemStack stack2) { + return stack1.isItemEqual(stack2) && ItemStack.areItemStackTagsEqual(stack1, stack2); + } + + boolean scanInventory(IInventory inv, ItemStack pstack) { + if(pstack == null) + return false; + + for(int l = 0; l < inv.getSizeInventory(); l++) { + ItemStack istack = inv.getStackInSlot(l); + if(istack != null && equalStacks(istack, pstack)) + return true; + } + + return false; + } + + @Override + public BaubleType getBaubleType(ItemStack arg0) { + return BaubleType.AMULET; + } + + @Override + @SideOnly(Side.CLIENT) + public void onPlayerBaubleRender(ItemStack stack, RenderPlayerEvent event, RenderType type) { + if(type == RenderType.HEAD) { + float f = gemIcon.getMinU(); + float f1 = gemIcon.getMaxU(); + float f2 = gemIcon.getMinV(); + float f3 = gemIcon.getMaxV(); + boolean armor = event.entityPlayer.getCurrentArmor(3) != null; + Helper.translateToHeadLevel(event.entityPlayer); + Minecraft.getMinecraft().renderEngine.bindTexture(TextureMap.locationItemsTexture); + GL11.glRotatef(90F, 0F, 1F, 0F); + GL11.glRotatef(180F, 1F, 0F, 0F); + GL11.glTranslatef(-0.4F, 0.1F, armor ? -0.3F : -0.25F); + GL11.glScalef(0.75F, 0.75F, 0.75F); + ItemRenderer.renderItemIn2D(Tessellator.instance, f1, f2, f, f3, gemIcon.getIconWidth(), gemIcon.getIconHeight(), 1F / 16F); + } + } + } diff --git a/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemKnockbackBelt.java b/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemKnockbackBelt.java index ebcdc93b1d..78952e3127 100644 --- a/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemKnockbackBelt.java +++ b/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemKnockbackBelt.java @@ -2,18 +2,14 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Apr 26, 2014, 7:08:53 PM (GMT)] */ package vazkii.botania.common.item.equipment.bauble; -import baubles.api.BaubleType; -import com.google.common.collect.Multimap; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; import net.minecraft.client.Minecraft; import net.minecraft.client.model.ModelBiped; import net.minecraft.entity.SharedMonsterAttributes; @@ -21,46 +17,54 @@ import net.minecraft.item.ItemStack; import net.minecraft.util.ResourceLocation; import net.minecraftforge.client.event.RenderPlayerEvent; + import org.lwjgl.opengl.GL11; + import vazkii.botania.api.item.IBaubleRender; import vazkii.botania.client.lib.LibResources; import vazkii.botania.common.lib.LibItemNames; +import baubles.api.BaubleType; + +import com.google.common.collect.Multimap; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; public class ItemKnockbackBelt extends ItemBaubleModifier implements IBaubleRender { - private static final ResourceLocation texture = new ResourceLocation(LibResources.MODEL_KNOCKBACK_BELT); - private static ModelBiped model; + private static final ResourceLocation texture = new ResourceLocation(LibResources.MODEL_KNOCKBACK_BELT); + private static ModelBiped model; + + public ItemKnockbackBelt() { + super(LibItemNames.KNOCKBACK_BELT); + } - public ItemKnockbackBelt() { - super(LibItemNames.KNOCKBACK_BELT); - } + @Override + public BaubleType getBaubleType(ItemStack itemstack) { + return BaubleType.BELT; + } - @Override - public BaubleType getBaubleType(ItemStack itemstack) { - return BaubleType.BELT; - } + @Override + void fillModifiers(Multimap attributes, ItemStack stack) { + attributes.put(SharedMonsterAttributes.knockbackResistance.getAttributeUnlocalizedName(), new AttributeModifier(getBaubleUUID(stack), "Bauble modifier", 1, 0)); + } - @Override - void fillModifiers(Multimap attributes, ItemStack stack) { - attributes.put( - SharedMonsterAttributes.knockbackResistance.getAttributeUnlocalizedName(), - new AttributeModifier(getBaubleUUID(stack), "Bauble modifier", 1, 0)); - } + @Override + @SideOnly(Side.CLIENT) + public void onPlayerBaubleRender(ItemStack stack, RenderPlayerEvent event, RenderType type) { + if(type == RenderType.BODY) { + Minecraft.getMinecraft().renderEngine.bindTexture(texture); + Helper.rotateIfSneaking(event.entityPlayer); + GL11.glTranslatef(0F, 0.2F, 0F); - @Override - @SideOnly(Side.CLIENT) - public void onPlayerBaubleRender(ItemStack stack, RenderPlayerEvent event, RenderType type) { - if (type == RenderType.BODY) { - Minecraft.getMinecraft().renderEngine.bindTexture(texture); - Helper.rotateIfSneaking(event.entityPlayer); - GL11.glTranslatef(0F, 0.2F, 0F); + float s = 1.05F / 16F; + GL11.glScalef(s, s, s); - float s = 1.05F / 16F; - GL11.glScalef(s, s, s); + if(model == null) + model = new ModelBiped(); - if (model == null) model = new ModelBiped(); + model.bipedBody.render(1F); + } + } - model.bipedBody.render(1F); - } - } } diff --git a/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemLavaPendant.java b/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemLavaPendant.java index 8eaeff356c..f07540b22d 100644 --- a/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemLavaPendant.java +++ b/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemLavaPendant.java @@ -2,15 +2,14 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Apr 26, 2014, 11:23:27 PM (GMT)] */ package vazkii.botania.common.item.equipment.bauble; -import baubles.api.BaubleType; import net.minecraft.client.Minecraft; import net.minecraft.client.renderer.ItemRenderer; import net.minecraft.client.renderer.Tessellator; @@ -20,52 +19,56 @@ import net.minecraft.item.ItemStack; import net.minecraft.util.IIcon; import net.minecraftforge.client.event.RenderPlayerEvent; + import org.lwjgl.opengl.GL11; + import vazkii.botania.api.item.IBaubleRender; import vazkii.botania.client.core.helper.IconHelper; import vazkii.botania.common.lib.LibItemNames; +import baubles.api.BaubleType; public class ItemLavaPendant extends ItemBauble implements IBaubleRender { - IIcon gemIcon; + IIcon gemIcon; + + public ItemLavaPendant() { + super(LibItemNames.LAVA_PENDANT); + } - public ItemLavaPendant() { - super(LibItemNames.LAVA_PENDANT); - } + @Override + public void onWornTick(ItemStack stack, EntityLivingBase player) { + if(player.isBurning()) + player.extinguish(); + } - @Override - public void onWornTick(ItemStack stack, EntityLivingBase player) { - if (player.isBurning()) player.extinguish(); - } + @Override + public BaubleType getBaubleType(ItemStack itemstack) { + return BaubleType.AMULET; + } - @Override - public BaubleType getBaubleType(ItemStack itemstack) { - return BaubleType.AMULET; - } + @Override + public void registerIcons(IIconRegister par1IconRegister) { + super.registerIcons(par1IconRegister); + gemIcon = IconHelper.forItem(par1IconRegister, this, "Gem"); + } - @Override - public void registerIcons(IIconRegister par1IconRegister) { - super.registerIcons(par1IconRegister); - gemIcon = IconHelper.forItem(par1IconRegister, this, "Gem"); - } + @Override + public void onPlayerBaubleRender(ItemStack stack, RenderPlayerEvent event, RenderType type) { + if(type == RenderType.BODY) { + Minecraft.getMinecraft().renderEngine.bindTexture(TextureMap.locationItemsTexture); + Helper.rotateIfSneaking(event.entityPlayer); + boolean armor = event.entityPlayer.getCurrentArmor(2) != null; + GL11.glRotatef(180F, 1F, 0F, 0F); + GL11.glTranslatef(-0.36F, -0.24F, armor ? 0.2F : 0.15F); + GL11.glRotatef(-45F, 0F, 0F, 1F); + GL11.glScalef(0.5F, 0.5F, 0.5F); - @Override - public void onPlayerBaubleRender(ItemStack stack, RenderPlayerEvent event, RenderType type) { - if (type == RenderType.BODY) { - Minecraft.getMinecraft().renderEngine.bindTexture(TextureMap.locationItemsTexture); - Helper.rotateIfSneaking(event.entityPlayer); - boolean armor = event.entityPlayer.getCurrentArmor(2) != null; - GL11.glRotatef(180F, 1F, 0F, 0F); - GL11.glTranslatef(-0.36F, -0.24F, armor ? 0.2F : 0.15F); - GL11.glRotatef(-45F, 0F, 0F, 1F); - GL11.glScalef(0.5F, 0.5F, 0.5F); + float f = gemIcon.getMinU(); + float f1 = gemIcon.getMaxU(); + float f2 = gemIcon.getMinV(); + float f3 = gemIcon.getMaxV(); + ItemRenderer.renderItemIn2D(Tessellator.instance, f1, f2, f, f3, gemIcon.getIconWidth(), gemIcon.getIconHeight(), 1F / 32F); + } + } - float f = gemIcon.getMinU(); - float f1 = gemIcon.getMaxU(); - float f2 = gemIcon.getMinV(); - float f3 = gemIcon.getMaxV(); - ItemRenderer.renderItemIn2D( - Tessellator.instance, f1, f2, f, f3, gemIcon.getIconWidth(), gemIcon.getIconHeight(), 1F / 32F); - } - } } diff --git a/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemMagnetRing.java b/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemMagnetRing.java index 96051606e0..6fab1bdb9c 100644 --- a/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemMagnetRing.java +++ b/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemMagnetRing.java @@ -2,22 +2,17 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [May 17, 2014, 3:16:36 PM (GMT)] */ package vazkii.botania.common.item.equipment.bauble; -import baubles.api.BaubleType; -import baubles.common.container.InventoryBaubles; -import baubles.common.lib.PlayerHandler; -import cpw.mods.fml.common.eventhandler.SubscribeEvent; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; import java.util.Arrays; import java.util.List; + import net.minecraft.block.Block; import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.entity.EntityLivingBase; @@ -38,139 +33,138 @@ import vazkii.botania.common.core.helper.MathHelper; import vazkii.botania.common.core.helper.Vector3; import vazkii.botania.common.lib.LibItemNames; +import baubles.api.BaubleType; +import baubles.common.container.InventoryBaubles; +import baubles.common.lib.PlayerHandler; +import cpw.mods.fml.common.eventhandler.SubscribeEvent; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; public class ItemMagnetRing extends ItemBauble { - IIcon iconOff; - - private static final String TAG_COOLDOWN = "cooldown"; - - private static final List BLACKLIST = Arrays.asList(new String[] { - "appliedenergistics2:item.ItemCrystalSeed", - }); - - int range; - - public ItemMagnetRing() { - this(LibItemNames.MAGNET_RING, 6); - MinecraftForge.EVENT_BUS.register(this); - } - - public ItemMagnetRing(String name, int range) { - super(name); - this.range = range; - } - - @Override - @SideOnly(Side.CLIENT) - public void registerIcons(IIconRegister par1IconRegister) { - itemIcon = IconHelper.forItem(par1IconRegister, this, 0); - iconOff = IconHelper.forItem(par1IconRegister, this, 1); - } - - @Override - @SideOnly(Side.CLIENT) - public IIcon getIconIndex(ItemStack stack) { - return getCooldown(stack) <= 0 ? itemIcon : iconOff; - } - - @SubscribeEvent - public void onTossItem(ItemTossEvent event) { - InventoryBaubles inv = PlayerHandler.getPlayerBaubles(event.player); - for (int i = 0; i < inv.getSizeInventory(); i++) { - ItemStack stack = inv.getStackInSlot(i); - if (stack != null && stack.getItem() instanceof ItemMagnetRing) { - setCooldown(stack, 100); - BotaniaAPI.internalHandler.sendBaubleUpdatePacket(event.player, i); - } - } - } - - @Override - public void onWornTick(ItemStack stack, EntityLivingBase player) { - super.onWornTick(stack, player); - - int cooldown = getCooldown(stack); - - if (SubTileSolegnolia.hasSolegnoliaAround(player)) { - if (cooldown < 0) setCooldown(stack, 2); - return; - } - - if (cooldown <= 0) { - if (player.isSneaking() == ConfigHandler.invertMagnetRing) { - double x = player.posX; - double y = player.posY - (player.worldObj.isRemote ? 1.62 : 0) + 0.75; - double z = player.posZ; - - List items = player.worldObj.getEntitiesWithinAABB( - EntityItem.class, - AxisAlignedBB.getBoundingBox(x - range, y - range, z - range, x + range, y + range, z + range)); - int pulled = 0; - for (EntityItem item : items) - if (canPullItem(item)) { - if (pulled > 200) break; - - MathHelper.setEntityMotionFromVector(item, new Vector3(x, y, z), 0.45F); - if (player.worldObj.isRemote) { - boolean red = player.worldObj.rand.nextBoolean(); - Botania.proxy.sparkleFX( - player.worldObj, - item.posX, - item.posY, - item.posZ, - red ? 1F : 0F, - 0F, - red ? 0F : 1F, - 1F, - 3); - } - pulled++; - } - } - } else setCooldown(stack, cooldown - 1); - } - - private boolean canPullItem(EntityItem item) { - if (item.isDead || SubTileSolegnolia.hasSolegnoliaAround(item)) return false; - - ItemStack stack = item.getEntityItem(); - if (stack == null - || stack.getItem() instanceof IManaItem - || stack.getItem() instanceof IRelic - || BLACKLIST.contains(itemRegistry.getNameForObject(stack.getItem())) - || BotaniaAPI.isItemBlacklistedFromMagnet(stack)) return false; - - int x = net.minecraft.util.MathHelper.floor_double(item.posX); - int y = (int) Math.floor(item.posY); - int z = net.minecraft.util.MathHelper.floor_double(item.posZ); - Block block = item.worldObj.getBlock(x, y, z); - int meta = item.worldObj.getBlockMetadata(x, y, z); - - if (BotaniaAPI.isBlockBlacklistedFromMagnet(block, meta)) return false; - - block = item.worldObj.getBlock(x, y - 1, z); - meta = item.worldObj.getBlockMetadata(x, y - 1, z); - - if (BotaniaAPI.isBlockBlacklistedFromMagnet(block, meta)) return false; - - return true; - } - - public static int getCooldown(ItemStack stack) { - return ItemNBTHelper.getInt(stack, TAG_COOLDOWN, 0); - } - - public static void setCooldown(ItemStack stack, int cooldown) { - ItemNBTHelper.setInt(stack, TAG_COOLDOWN, cooldown); - } - - public static void addItemToBlackList(String item) { - BLACKLIST.add(item); - } - - @Override - public BaubleType getBaubleType(ItemStack arg0) { - return BaubleType.RING; - } + IIcon iconOff; + + private static final String TAG_COOLDOWN = "cooldown"; + + private static final List BLACKLIST = Arrays.asList(new String[] { + "appliedenergistics2:item.ItemCrystalSeed", + }); + + int range; + + public ItemMagnetRing() { + this(LibItemNames.MAGNET_RING, 6); + MinecraftForge.EVENT_BUS.register(this); + } + + public ItemMagnetRing(String name, int range) { + super(name); + this.range = range; + } + + @Override + @SideOnly(Side.CLIENT) + public void registerIcons(IIconRegister par1IconRegister) { + itemIcon = IconHelper.forItem(par1IconRegister, this, 0); + iconOff = IconHelper.forItem(par1IconRegister, this, 1); + } + + @Override + @SideOnly(Side.CLIENT) + public IIcon getIconIndex(ItemStack stack) { + return getCooldown(stack) <= 0 ? itemIcon : iconOff; + } + + @SubscribeEvent + public void onTossItem(ItemTossEvent event) { + InventoryBaubles inv = PlayerHandler.getPlayerBaubles(event.player); + for(int i = 0; i < inv.getSizeInventory(); i++) { + ItemStack stack = inv.getStackInSlot(i); + if(stack != null && stack.getItem() instanceof ItemMagnetRing) { + setCooldown(stack, 100); + BotaniaAPI.internalHandler.sendBaubleUpdatePacket(event.player, i); + } + } + } + + @Override + public void onWornTick(ItemStack stack, EntityLivingBase player) { + super.onWornTick(stack, player); + + int cooldown = getCooldown(stack); + + if(SubTileSolegnolia.hasSolegnoliaAround(player)) { + if(cooldown < 0) + setCooldown(stack, 2); + return; + } + + if(cooldown <= 0) { + if(player.isSneaking() == ConfigHandler.invertMagnetRing) { + double x = player.posX; + double y = player.posY -(player.worldObj.isRemote ? 1.62 : 0) + 0.75; + double z = player.posZ; + + List items = player.worldObj.getEntitiesWithinAABB(EntityItem.class, AxisAlignedBB.getBoundingBox(x - range, y - range, z - range, x + range, y + range, z + range)); + int pulled = 0; + for(EntityItem item : items) + if(canPullItem(item)) { + if(pulled > 200) + break; + + MathHelper.setEntityMotionFromVector(item, new Vector3(x, y, z), 0.45F); + if(player.worldObj.isRemote) { + boolean red = player.worldObj.rand.nextBoolean(); + Botania.proxy.sparkleFX(player.worldObj, item.posX, item.posY, item.posZ, red ? 1F : 0F, 0F, red ? 0F : 1F, 1F, 3); + } + pulled++; + } + } + } else setCooldown(stack, cooldown - 1); + } + + private boolean canPullItem(EntityItem item) { + if(item.isDead || SubTileSolegnolia.hasSolegnoliaAround(item)) + return false; + + ItemStack stack = item.getEntityItem(); + if(stack == null || stack.getItem() instanceof IManaItem || stack.getItem() instanceof IRelic || BLACKLIST.contains(itemRegistry.getNameForObject(stack.getItem())) || BotaniaAPI.isItemBlacklistedFromMagnet(stack)) + return false; + + int x = net.minecraft.util.MathHelper.floor_double(item.posX); + int y = (int) Math.floor(item.posY); + int z = net.minecraft.util.MathHelper.floor_double(item.posZ); + Block block = item.worldObj.getBlock(x, y, z); + int meta = item.worldObj.getBlockMetadata(x, y, z); + + if(BotaniaAPI.isBlockBlacklistedFromMagnet(block, meta)) + return false; + + block = item.worldObj.getBlock(x, y - 1, z); + meta = item.worldObj.getBlockMetadata(x, y - 1, z); + + if(BotaniaAPI.isBlockBlacklistedFromMagnet(block, meta)) + return false; + + return true; + } + + public static int getCooldown(ItemStack stack) { + return ItemNBTHelper.getInt(stack, TAG_COOLDOWN, 0); + } + + public static void setCooldown(ItemStack stack, int cooldown) { + ItemNBTHelper.setInt(stack, TAG_COOLDOWN, cooldown); + } + + public static void addItemToBlackList(String item) { + BLACKLIST.add(item); + } + + @Override + public BaubleType getBaubleType(ItemStack arg0) { + return BaubleType.RING; + } + + } diff --git a/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemManaRing.java b/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemManaRing.java index cd3894bfc5..b5f3665e87 100644 --- a/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemManaRing.java +++ b/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemManaRing.java @@ -2,16 +2,16 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Apr 24, 2014, 2:55:28 PM (GMT)] */ package vazkii.botania.common.item.equipment.bauble; -import baubles.api.BaubleType; import java.util.List; + import net.minecraft.creativetab.CreativeTabs; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; @@ -21,97 +21,99 @@ import vazkii.botania.api.mana.IManaTooltipDisplay; import vazkii.botania.common.core.helper.ItemNBTHelper; import vazkii.botania.common.lib.LibItemNames; +import baubles.api.BaubleType; public class ItemManaRing extends ItemBauble implements IManaItem, IManaTooltipDisplay { - protected static final int MAX_MANA = 500000; - - private static final String TAG_MANA = "mana"; - - public ItemManaRing() { - this(LibItemNames.MANA_RING); - setMaxDamage(1000); - setNoRepair(); - } - - public ItemManaRing(String name) { - super(name); - setMaxDamage(1000); - } - - @Override - public BaubleType getBaubleType(ItemStack itemstack) { - return BaubleType.RING; - } - - @Override - public void getSubItems(Item par1, CreativeTabs par2CreativeTabs, List par3List) { - par3List.add(new ItemStack(par1, 1, 10000)); - } - - @Override - public int getDamage(ItemStack stack) { - float mana = getMana(stack); - return 1000 - (int) (mana / getMaxMana(stack) * 1000); - } - - @Override - public int getDisplayDamage(ItemStack stack) { - return getDamage(stack); - } - - @Override - public int getEntityLifespan(ItemStack itemStack, World world) { - return Integer.MAX_VALUE; - } - - public static void setMana(ItemStack stack, int mana) { - ItemNBTHelper.setInt(stack, TAG_MANA, mana); - } - - @Override - public int getMana(ItemStack stack) { - return ItemNBTHelper.getInt(stack, TAG_MANA, 0); - } - - @Override - public int getMaxMana(ItemStack stack) { - return MAX_MANA; - } - - @Override - public void addMana(ItemStack stack, int mana) { - setMana(stack, Math.min(getMana(stack) + mana, getMaxMana(stack))); - stack.setItemDamage(getDamage(stack)); - } - - @Override - public boolean canReceiveManaFromPool(ItemStack stack, TileEntity pool) { - return true; - } - - @Override - public boolean canReceiveManaFromItem(ItemStack stack, ItemStack otherStack) { - return true; - } - - @Override - public boolean canExportManaToPool(ItemStack stack, TileEntity pool) { - return true; - } - - @Override - public boolean canExportManaToItem(ItemStack stack, ItemStack otherStack) { - return true; - } - - @Override - public boolean isNoExport(ItemStack stack) { - return false; - } - - @Override - public float getManaFractionForDisplay(ItemStack stack) { - return (float) getMana(stack) / (float) getMaxMana(stack); - } + protected static final int MAX_MANA = 500000; + + private static final String TAG_MANA = "mana"; + + public ItemManaRing() { + this(LibItemNames.MANA_RING); + setMaxDamage(1000); + setNoRepair(); + } + + public ItemManaRing(String name) { + super(name); + setMaxDamage(1000); + } + + @Override + public BaubleType getBaubleType(ItemStack itemstack) { + return BaubleType.RING; + } + + @Override + public void getSubItems(Item par1, CreativeTabs par2CreativeTabs, List par3List) { + par3List.add(new ItemStack(par1, 1, 10000)); + } + + @Override + public int getDamage(ItemStack stack) { + float mana = getMana(stack); + return 1000 - (int) (mana / getMaxMana(stack) * 1000); + } + + @Override + public int getDisplayDamage(ItemStack stack) { + return getDamage(stack); + } + + @Override + public int getEntityLifespan(ItemStack itemStack, World world) { + return Integer.MAX_VALUE; + } + + public static void setMana(ItemStack stack, int mana) { + ItemNBTHelper.setInt(stack, TAG_MANA, mana); + } + + @Override + public int getMana(ItemStack stack) { + return ItemNBTHelper.getInt(stack, TAG_MANA, 0); + } + + @Override + public int getMaxMana(ItemStack stack) { + return MAX_MANA; + } + + @Override + public void addMana(ItemStack stack, int mana) { + setMana(stack, Math.min(getMana(stack) + mana, getMaxMana(stack))); + stack.setItemDamage(getDamage(stack)); + } + + @Override + public boolean canReceiveManaFromPool(ItemStack stack, TileEntity pool) { + return true; + } + + @Override + public boolean canReceiveManaFromItem(ItemStack stack, ItemStack otherStack) { + return true; + } + + @Override + public boolean canExportManaToPool(ItemStack stack, TileEntity pool) { + return true; + } + + @Override + public boolean canExportManaToItem(ItemStack stack, ItemStack otherStack) { + return true; + } + + @Override + public boolean isNoExport(ItemStack stack) { + return false; + } + + @Override + public float getManaFractionForDisplay(ItemStack stack) { + return (float) getMana(stack) / (float) getMaxMana(stack); + } + } diff --git a/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemMiningRing.java b/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemMiningRing.java index 8a95e26af5..0a6f6f8c4f 100644 --- a/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemMiningRing.java +++ b/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemMiningRing.java @@ -2,15 +2,14 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [May 17, 2014, 4:12:46 PM (GMT)] */ package vazkii.botania.common.item.equipment.bauble; -import baubles.api.BaubleType; import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; @@ -19,46 +18,50 @@ import vazkii.botania.api.mana.IManaUsingItem; import vazkii.botania.api.mana.ManaItemHandler; import vazkii.botania.common.lib.LibItemNames; +import baubles.api.BaubleType; public class ItemMiningRing extends ItemBauble implements IManaUsingItem { - public ItemMiningRing() { - super(LibItemNames.MINING_RING); - } + public ItemMiningRing() { + super(LibItemNames.MINING_RING); + } + + @Override + public void onWornTick(ItemStack stack, EntityLivingBase player) { + super.onWornTick(stack, player); - @Override - public void onWornTick(ItemStack stack, EntityLivingBase player) { - super.onWornTick(stack, player); + if(player instanceof EntityPlayer && !player.worldObj.isRemote) { + int manaCost = 5; + boolean hasMana = ManaItemHandler.requestManaExact(stack, (EntityPlayer) player, manaCost, false); + if(!hasMana) + onUnequipped(stack, player); + else { + if(player.getActivePotionEffect(Potion.digSpeed) != null) + player.removePotionEffect(Potion.digSpeed.id); - if (player instanceof EntityPlayer && !player.worldObj.isRemote) { - int manaCost = 5; - boolean hasMana = ManaItemHandler.requestManaExact(stack, (EntityPlayer) player, manaCost, false); - if (!hasMana) onUnequipped(stack, player); - else { - if (player.getActivePotionEffect(Potion.digSpeed) != null) - player.removePotionEffect(Potion.digSpeed.id); + player.addPotionEffect(new PotionEffect(Potion.digSpeed.id, Integer.MAX_VALUE, 1, true)); + } - player.addPotionEffect(new PotionEffect(Potion.digSpeed.id, Integer.MAX_VALUE, 1, true)); - } + if(player.swingProgress == 0.25F) + ManaItemHandler.requestManaExact(stack, (EntityPlayer) player, manaCost, true); + } + } - if (player.swingProgress == 0.25F) - ManaItemHandler.requestManaExact(stack, (EntityPlayer) player, manaCost, true); - } - } + @Override + public void onUnequipped(ItemStack stack, EntityLivingBase player) { + PotionEffect effect = player.getActivePotionEffect(Potion.digSpeed); + if(effect != null && effect.getAmplifier() == 1) + player.removePotionEffect(Potion.digSpeed.id); + } - @Override - public void onUnequipped(ItemStack stack, EntityLivingBase player) { - PotionEffect effect = player.getActivePotionEffect(Potion.digSpeed); - if (effect != null && effect.getAmplifier() == 1) player.removePotionEffect(Potion.digSpeed.id); - } + @Override + public BaubleType getBaubleType(ItemStack arg0) { + return BaubleType.RING; + } - @Override - public BaubleType getBaubleType(ItemStack arg0) { - return BaubleType.RING; - } + @Override + public boolean usesMana(ItemStack stack) { + return true; + } - @Override - public boolean usesMana(ItemStack stack) { - return true; - } } diff --git a/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemMonocle.java b/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemMonocle.java index 68f4851de2..f2af5e85e6 100644 --- a/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemMonocle.java +++ b/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemMonocle.java @@ -2,18 +2,14 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jan 24, 2015, 3:03:18 PM (GMT)] */ package vazkii.botania.common.item.equipment.bauble; -import baubles.api.BaubleType; -import baubles.common.lib.PlayerHandler; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; import net.minecraft.block.Block; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.ScaledResolution; @@ -29,92 +25,102 @@ import net.minecraft.util.EnumChatFormatting; import net.minecraft.util.MovingObjectPosition; import net.minecraftforge.client.event.RenderPlayerEvent; + import org.lwjgl.opengl.GL11; + import vazkii.botania.api.item.IBurstViewerBauble; import vazkii.botania.api.item.ICosmeticAttachable; import vazkii.botania.api.item.ICosmeticBauble; import vazkii.botania.common.lib.LibItemNames; +import baubles.api.BaubleType; +import baubles.common.lib.PlayerHandler; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; public class ItemMonocle extends ItemBauble implements IBurstViewerBauble, ICosmeticBauble { - public ItemMonocle() { - super(LibItemNames.MONOCLE); - } - - @Override - public BaubleType getBaubleType(ItemStack arg0) { - return BaubleType.AMULET; - } - - @Override - public void onPlayerBaubleRender(ItemStack stack, RenderPlayerEvent event, RenderType type) { - if (type == RenderType.HEAD) { - float f = itemIcon.getMinU(); - float f1 = itemIcon.getMaxU(); - float f2 = itemIcon.getMinV(); - float f3 = itemIcon.getMaxV(); - boolean armor = event.entityPlayer.getCurrentArmor(3) != null; - Helper.translateToHeadLevel(event.entityPlayer); - Minecraft.getMinecraft().renderEngine.bindTexture(TextureMap.locationItemsTexture); - GL11.glRotatef(90F, 0F, 1F, 0F); - GL11.glRotatef(180F, 1F, 0F, 0F); - GL11.glTranslatef(-0.35F, -0.1F, armor ? -0.3F : -0.25F); - GL11.glScalef(0.35F, 0.35F, 0.35F); - ItemRenderer.renderItemIn2D( - Tessellator.instance, f1, f2, f, f3, itemIcon.getIconWidth(), itemIcon.getIconHeight(), 1F / 16F); - } - } - - @SideOnly(Side.CLIENT) - public static void renderHUD(ScaledResolution resolution, EntityPlayer player) { - Minecraft mc = Minecraft.getMinecraft(); - MovingObjectPosition pos = mc.objectMouseOver; - if (pos == null) return; - Block block = player.worldObj.getBlock(pos.blockX, pos.blockY, pos.blockZ); - int meta = player.worldObj.getBlockMetadata(pos.blockX, pos.blockY, pos.blockZ); - player.worldObj.getTileEntity(pos.blockX, pos.blockY, pos.blockZ); - - ItemStack dispStack = null; - String text = ""; - - if (block == Blocks.redstone_wire) { - dispStack = new ItemStack(Items.redstone); - text = EnumChatFormatting.RED + "" + meta; - } else if (block == Blocks.unpowered_repeater || block == Blocks.powered_repeater) { - dispStack = new ItemStack(Items.repeater); - text = "" + (((meta & 12) >> 2) + 1); - } else if (block == Blocks.unpowered_comparator || block == Blocks.powered_comparator) { - dispStack = new ItemStack(Items.comparator); - text = (meta & 4) == 4 ? "-" : "+"; - } - - if (dispStack == null) return; - - int x = resolution.getScaledWidth() / 2 + 15; - int y = resolution.getScaledHeight() / 2 - 8; - - net.minecraft.client.renderer.RenderHelper.enableGUIStandardItemLighting(); - RenderItem.getInstance().renderItemAndEffectIntoGUI(mc.fontRenderer, mc.renderEngine, dispStack, x, y); - net.minecraft.client.renderer.RenderHelper.disableStandardItemLighting(); - - mc.fontRenderer.drawStringWithShadow(text, x + 20, y + 4, 0xFFFFFF); - } - - public static boolean hasMonocle(EntityPlayer player) { - for (int i = 0; i < 4; i++) { - ItemStack stack = PlayerHandler.getPlayerBaubles(player).getStackInSlot(i); - if (stack != null) { - Item item = stack.getItem(); - if (item instanceof IBurstViewerBauble) return true; - - if (item instanceof ICosmeticAttachable) { - ICosmeticAttachable attach = (ICosmeticAttachable) item; - ItemStack cosmetic = attach.getCosmeticItem(stack); - if (cosmetic != null && cosmetic.getItem() instanceof IBurstViewerBauble) return true; - } - } - } - - return false; - } + public ItemMonocle() { + super(LibItemNames.MONOCLE); + } + + @Override + public BaubleType getBaubleType(ItemStack arg0) { + return BaubleType.AMULET; + } + + @Override + public void onPlayerBaubleRender(ItemStack stack, RenderPlayerEvent event, RenderType type) { + if(type == RenderType.HEAD) { + float f = itemIcon.getMinU(); + float f1 = itemIcon.getMaxU(); + float f2 = itemIcon.getMinV(); + float f3 = itemIcon.getMaxV(); + boolean armor = event.entityPlayer.getCurrentArmor(3) != null; + Helper.translateToHeadLevel(event.entityPlayer); + Minecraft.getMinecraft().renderEngine.bindTexture(TextureMap.locationItemsTexture); + GL11.glRotatef(90F, 0F, 1F, 0F); + GL11.glRotatef(180F, 1F, 0F, 0F); + GL11.glTranslatef(-0.35F, -0.1F, armor ? -0.3F : -0.25F); + GL11.glScalef(0.35F, 0.35F, 0.35F); + ItemRenderer.renderItemIn2D(Tessellator.instance, f1, f2, f, f3, itemIcon.getIconWidth(), itemIcon.getIconHeight(), 1F / 16F); + } + } + + @SideOnly(Side.CLIENT) + public static void renderHUD(ScaledResolution resolution, EntityPlayer player) { + Minecraft mc = Minecraft.getMinecraft(); + MovingObjectPosition pos = mc.objectMouseOver; + if(pos == null) + return; + Block block = player.worldObj.getBlock(pos.blockX, pos.blockY, pos.blockZ); + int meta = player.worldObj.getBlockMetadata(pos.blockX, pos.blockY, pos.blockZ); + player.worldObj.getTileEntity(pos.blockX, pos.blockY, pos.blockZ); + + ItemStack dispStack = null; + String text = ""; + + if(block == Blocks.redstone_wire) { + dispStack = new ItemStack(Items.redstone); + text = EnumChatFormatting.RED + "" + meta; + } else if(block == Blocks.unpowered_repeater || block == Blocks.powered_repeater) { + dispStack = new ItemStack(Items.repeater); + text = "" + (((meta & 12) >> 2) + 1); + } else if(block == Blocks.unpowered_comparator || block == Blocks.powered_comparator) { + dispStack = new ItemStack(Items.comparator); + text = (meta & 4) == 4 ? "-" : "+"; + } + + if(dispStack == null) + return; + + int x = resolution.getScaledWidth() / 2 + 15; + int y = resolution.getScaledHeight() / 2 - 8; + + net.minecraft.client.renderer.RenderHelper.enableGUIStandardItemLighting(); + RenderItem.getInstance().renderItemAndEffectIntoGUI(mc.fontRenderer, mc.renderEngine, dispStack, x, y); + net.minecraft.client.renderer.RenderHelper.disableStandardItemLighting(); + + mc.fontRenderer.drawStringWithShadow(text, x + 20, y + 4, 0xFFFFFF); + } + + public static boolean hasMonocle(EntityPlayer player) { + for(int i = 0; i < 4; i++) { + ItemStack stack = PlayerHandler.getPlayerBaubles(player).getStackInSlot(i); + if(stack != null) { + Item item = stack.getItem(); + if(item instanceof IBurstViewerBauble) + return true; + + if(item instanceof ICosmeticAttachable) { + ICosmeticAttachable attach = (ICosmeticAttachable) item; + ItemStack cosmetic = attach.getCosmeticItem(stack); + if(cosmetic != null && cosmetic.getItem() instanceof IBurstViewerBauble) + return true; + } + } + } + + return false; + } + } diff --git a/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemPixieRing.java b/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemPixieRing.java index 62827f6e75..d3055c7d36 100644 --- a/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemPixieRing.java +++ b/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemPixieRing.java @@ -2,32 +2,33 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jun 20, 2014, 6:13:45 PM (GMT)] */ package vazkii.botania.common.item.equipment.bauble; -import baubles.api.BaubleType; import net.minecraft.item.ItemStack; import vazkii.botania.api.item.IPixieSpawner; import vazkii.botania.common.lib.LibItemNames; +import baubles.api.BaubleType; public class ItemPixieRing extends ItemBauble implements IPixieSpawner { - public ItemPixieRing() { - super(LibItemNames.PIXIE_RING); - } + public ItemPixieRing() { + super(LibItemNames.PIXIE_RING); + } + + @Override + public BaubleType getBaubleType(ItemStack arg0) { + return BaubleType.RING; + } - @Override - public BaubleType getBaubleType(ItemStack arg0) { - return BaubleType.RING; - } + @Override + public float getPixieChance(ItemStack stack) { + return 0.075F; + } - @Override - public float getPixieChance(ItemStack stack) { - return 0.075F; - } } diff --git a/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemReachRing.java b/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemReachRing.java index 08609ae867..6d9fa50a91 100644 --- a/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemReachRing.java +++ b/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemReachRing.java @@ -2,38 +2,39 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jul 22, 2014, 3:00:09 PM (GMT)] */ package vazkii.botania.common.item.equipment.bauble; -import baubles.api.BaubleType; import net.minecraft.entity.EntityLivingBase; import net.minecraft.item.ItemStack; import vazkii.botania.common.Botania; import vazkii.botania.common.lib.LibItemNames; +import baubles.api.BaubleType; public class ItemReachRing extends ItemBauble { - public ItemReachRing() { - super(LibItemNames.REACH_RING); - } + public ItemReachRing() { + super(LibItemNames.REACH_RING); + } + + @Override + public void onEquippedOrLoadedIntoWorld(ItemStack stack, EntityLivingBase player) { + Botania.proxy.setExtraReach(player, 3.5F); + } - @Override - public void onEquippedOrLoadedIntoWorld(ItemStack stack, EntityLivingBase player) { - Botania.proxy.setExtraReach(player, 3.5F); - } + @Override + public void onUnequipped(ItemStack stack, EntityLivingBase player) { + Botania.proxy.setExtraReach(player, -3.5F); + } - @Override - public void onUnequipped(ItemStack stack, EntityLivingBase player) { - Botania.proxy.setExtraReach(player, -3.5F); - } + @Override + public BaubleType getBaubleType(ItemStack arg0) { + return BaubleType.RING; + } - @Override - public BaubleType getBaubleType(ItemStack arg0) { - return BaubleType.RING; - } } diff --git a/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemSpeedUpBelt.java b/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemSpeedUpBelt.java index 8c7903358c..36022a24d6 100644 --- a/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemSpeedUpBelt.java +++ b/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemSpeedUpBelt.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [24/11/2015, 22:50:29 (GMT)] */ package vazkii.botania.common.item.equipment.bauble; @@ -19,51 +19,52 @@ public class ItemSpeedUpBelt extends ItemTravelBelt { - private static final ResourceLocation texture = new ResourceLocation(LibResources.MODEL_SPEED_UP_BELT); + private static final ResourceLocation texture = new ResourceLocation(LibResources.MODEL_SPEED_UP_BELT); - private static final String TAG_SPEED = "speed"; - private static final String TAG_OLD_X = "oldX"; - private static final String TAG_OLD_Y = "oldY"; - private static final String TAG_OLD_Z = "oldZ"; + private static final String TAG_SPEED = "speed"; + private static final String TAG_OLD_X = "oldX"; + private static final String TAG_OLD_Y = "oldY"; + private static final String TAG_OLD_Z = "oldZ"; - public ItemSpeedUpBelt() { - super(LibItemNames.SPEED_UP_BELT, 0F, 0.2F, 2F); - } + public ItemSpeedUpBelt() { + super(LibItemNames.SPEED_UP_BELT, 0F, 0.2F, 2F); + } - @Override - public ResourceLocation getRenderTexture() { - return texture; - } + @Override + public ResourceLocation getRenderTexture() { + return texture; + } - @Override - public float getSpeed(ItemStack stack) { - return ItemNBTHelper.getFloat(stack, TAG_SPEED, 0F); - } + @Override + public float getSpeed(ItemStack stack) { + return ItemNBTHelper.getFloat(stack, TAG_SPEED, 0F); + } - @Override - public void onMovedTick(ItemStack stack, EntityPlayer player) { - float speed = getSpeed(stack); - float newspeed = Math.min(0.25F, speed + 0.00035F); - ItemNBTHelper.setFloat(stack, TAG_SPEED, newspeed); - commitPositionAndCompare(stack, player); - } + @Override + public void onMovedTick(ItemStack stack, EntityPlayer player) { + float speed = getSpeed(stack); + float newspeed = Math.min(0.25F, speed + 0.00035F); + ItemNBTHelper.setFloat(stack, TAG_SPEED, newspeed); + commitPositionAndCompare(stack, player); + } - @Override - public void onNotMovingTick(ItemStack stack, EntityPlayer player) { - if (!commitPositionAndCompare(stack, player)) ItemNBTHelper.setFloat(stack, TAG_SPEED, 0F); - } + @Override + public void onNotMovingTick(ItemStack stack, EntityPlayer player) { + if(!commitPositionAndCompare(stack, player)) + ItemNBTHelper.setFloat(stack, TAG_SPEED, 0F); + } - public boolean commitPositionAndCompare(ItemStack stack, EntityPlayer player) { - double oldX = ItemNBTHelper.getDouble(stack, TAG_OLD_X, 0); - double oldY = ItemNBTHelper.getDouble(stack, TAG_OLD_Y, 0); - double oldZ = ItemNBTHelper.getDouble(stack, TAG_OLD_Z, 0); + public boolean commitPositionAndCompare(ItemStack stack, EntityPlayer player) { + double oldX = ItemNBTHelper.getDouble(stack, TAG_OLD_X, 0); + double oldY = ItemNBTHelper.getDouble(stack, TAG_OLD_Y, 0); + double oldZ = ItemNBTHelper.getDouble(stack, TAG_OLD_Z, 0); - ItemNBTHelper.setDouble(stack, TAG_OLD_X, player.posX); - ItemNBTHelper.setDouble(stack, TAG_OLD_Y, player.posY); - ItemNBTHelper.setDouble(stack, TAG_OLD_Z, player.posZ); + ItemNBTHelper.setDouble(stack, TAG_OLD_X, player.posX); + ItemNBTHelper.setDouble(stack, TAG_OLD_Y, player.posY); + ItemNBTHelper.setDouble(stack, TAG_OLD_Z, player.posZ); + + return Math.abs(oldX - player.posX) > 0.001 || Math.abs(oldY - player.posY) > 0.001 || Math.abs(oldZ - player.posZ) > 0.001; + } - return Math.abs(oldX - player.posX) > 0.001 - || Math.abs(oldY - player.posY) > 0.001 - || Math.abs(oldZ - player.posZ) > 0.001; - } } + diff --git a/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemSuperLavaPendant.java b/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemSuperLavaPendant.java index c9eb381348..dc776b4ca9 100644 --- a/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemSuperLavaPendant.java +++ b/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemSuperLavaPendant.java @@ -2,16 +2,14 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jul 31, 2014, 6:09:17 PM (GMT)] */ package vazkii.botania.common.item.equipment.bauble; -import baubles.api.BaubleType; -import cpw.mods.fml.relauncher.ReflectionHelper; import net.minecraft.client.Minecraft; import net.minecraft.client.renderer.ItemRenderer; import net.minecraft.client.renderer.Tessellator; @@ -22,62 +20,65 @@ import net.minecraft.item.ItemStack; import net.minecraft.util.IIcon; import net.minecraftforge.client.event.RenderPlayerEvent; + import org.lwjgl.opengl.GL11; + import vazkii.botania.api.item.IBaubleRender; import vazkii.botania.client.core.helper.IconHelper; import vazkii.botania.common.lib.LibItemNames; import vazkii.botania.common.lib.LibObfuscation; +import baubles.api.BaubleType; +import cpw.mods.fml.relauncher.ReflectionHelper; public class ItemSuperLavaPendant extends ItemBauble implements IBaubleRender { - IIcon gemIcon; + IIcon gemIcon; - public ItemSuperLavaPendant() { - super(LibItemNames.SUPER_LAVA_PENDANT); - } + public ItemSuperLavaPendant() { + super(LibItemNames.SUPER_LAVA_PENDANT); + } - @Override - public void onWornTick(ItemStack stack, EntityLivingBase player) { - setImmunity(player, true); - } + @Override + public void onWornTick(ItemStack stack, EntityLivingBase player) { + setImmunity(player, true); + } - @Override - public void onUnequipped(ItemStack stack, EntityLivingBase player) { - setImmunity(player, false); - } + @Override + public void onUnequipped(ItemStack stack, EntityLivingBase player) { + setImmunity(player, false); + } - private void setImmunity(Entity entity, boolean immune) { - ReflectionHelper.setPrivateValue(Entity.class, entity, immune, LibObfuscation.IS_IMMUNE_TO_FIRE); - } + private void setImmunity(Entity entity, boolean immune) { + ReflectionHelper.setPrivateValue(Entity.class, entity, immune, LibObfuscation.IS_IMMUNE_TO_FIRE); + } - @Override - public BaubleType getBaubleType(ItemStack itemstack) { - return BaubleType.AMULET; - } + @Override + public BaubleType getBaubleType(ItemStack itemstack) { + return BaubleType.AMULET; + } - @Override - public void registerIcons(IIconRegister par1IconRegister) { - super.registerIcons(par1IconRegister); - gemIcon = IconHelper.forItem(par1IconRegister, this, "Gem"); - } + @Override + public void registerIcons(IIconRegister par1IconRegister) { + super.registerIcons(par1IconRegister); + gemIcon = IconHelper.forItem(par1IconRegister, this, "Gem"); + } - @Override - public void onPlayerBaubleRender(ItemStack stack, RenderPlayerEvent event, RenderType type) { - if (type == RenderType.BODY) { - Minecraft.getMinecraft().renderEngine.bindTexture(TextureMap.locationItemsTexture); - Helper.rotateIfSneaking(event.entityPlayer); - boolean armor = event.entityPlayer.getCurrentArmor(2) != null; - GL11.glRotatef(180F, 1F, 0F, 0F); - GL11.glTranslatef(-0.36F, -0.24F, armor ? 0.2F : 0.15F); - GL11.glRotatef(-45F, 0F, 0F, 1F); - GL11.glScalef(0.5F, 0.5F, 0.5F); + @Override + public void onPlayerBaubleRender(ItemStack stack, RenderPlayerEvent event, RenderType type) { + if(type == RenderType.BODY) { + Minecraft.getMinecraft().renderEngine.bindTexture(TextureMap.locationItemsTexture); + Helper.rotateIfSneaking(event.entityPlayer); + boolean armor = event.entityPlayer.getCurrentArmor(2) != null; + GL11.glRotatef(180F, 1F, 0F, 0F); + GL11.glTranslatef(-0.36F, -0.24F, armor ? 0.2F : 0.15F); + GL11.glRotatef(-45F, 0F, 0F, 1F); + GL11.glScalef(0.5F, 0.5F, 0.5F); - float f = gemIcon.getMinU(); - float f1 = gemIcon.getMaxU(); - float f2 = gemIcon.getMinV(); - float f3 = gemIcon.getMaxV(); - ItemRenderer.renderItemIn2D( - Tessellator.instance, f1, f2, f, f3, gemIcon.getIconWidth(), gemIcon.getIconHeight(), 1F / 32F); - } - } + float f = gemIcon.getMinU(); + float f1 = gemIcon.getMaxU(); + float f2 = gemIcon.getMinV(); + float f3 = gemIcon.getMaxV(); + ItemRenderer.renderItemIn2D(Tessellator.instance, f1, f2, f, f3, gemIcon.getIconWidth(), gemIcon.getIconHeight(), 1F / 32F); + } + } } diff --git a/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemSuperTravelBelt.java b/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemSuperTravelBelt.java index b15aa0c3b3..f884e615bd 100644 --- a/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemSuperTravelBelt.java +++ b/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemSuperTravelBelt.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jun 20, 2014, 6:26:40 PM (GMT)] */ package vazkii.botania.common.item.equipment.bauble; @@ -16,14 +16,14 @@ public class ItemSuperTravelBelt extends ItemTravelBelt { - private static final ResourceLocation texture = new ResourceLocation(LibResources.MODEL_SUPER_TRAVEL_BELT); + private static final ResourceLocation texture = new ResourceLocation(LibResources.MODEL_SUPER_TRAVEL_BELT); - public ItemSuperTravelBelt() { - super(LibItemNames.SUPER_TRAVEL_BELT, 0.085F, 0.3F, 4F); - } + public ItemSuperTravelBelt() { + super(LibItemNames.SUPER_TRAVEL_BELT, 0.085F, 0.3F, 4F); + } - @Override - public ResourceLocation getRenderTexture() { - return texture; - } + @Override + public ResourceLocation getRenderTexture() { + return texture; + } } diff --git a/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemSwapRing.java b/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemSwapRing.java index 367e643734..423b2feeb7 100644 --- a/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemSwapRing.java +++ b/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemSwapRing.java @@ -2,15 +2,14 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Feb 23, 2015, 7:21:52 PM (GMT)] */ package vazkii.botania.common.item.equipment.bauble; -import baubles.api.BaubleType; import net.minecraft.block.Block; import net.minecraft.block.material.Material; import net.minecraft.entity.EntityLivingBase; @@ -21,67 +20,74 @@ import vazkii.botania.api.item.ISortableTool.ToolType; import vazkii.botania.common.item.equipment.tool.ToolCommons; import vazkii.botania.common.lib.LibItemNames; +import baubles.api.BaubleType; public class ItemSwapRing extends ItemBauble { - public ItemSwapRing() { - super(LibItemNames.SWAP_RING); - } + public ItemSwapRing() { + super(LibItemNames.SWAP_RING); + } + + @Override + public void onWornTick(ItemStack stack, EntityLivingBase entity) { + if(!(entity instanceof EntityPlayer)) + return; - @Override - public void onWornTick(ItemStack stack, EntityLivingBase entity) { - if (!(entity instanceof EntityPlayer)) return; + EntityPlayer player = (EntityPlayer) entity; + ItemStack currentStack = player.getCurrentEquippedItem(); + if(currentStack == null || !(currentStack.getItem() instanceof ISortableTool)) + return; - EntityPlayer player = (EntityPlayer) entity; - ItemStack currentStack = player.getCurrentEquippedItem(); - if (currentStack == null || !(currentStack.getItem() instanceof ISortableTool)) return; + ISortableTool tool = (ISortableTool) currentStack.getItem(); - ISortableTool tool = (ISortableTool) currentStack.getItem(); + MovingObjectPosition pos = ToolCommons.raytraceFromEntity(entity.worldObj, entity, true, 4.5F); + ToolType typeToFind = null; - MovingObjectPosition pos = ToolCommons.raytraceFromEntity(entity.worldObj, entity, true, 4.5F); - ToolType typeToFind = null; + if(player.isSwingInProgress && pos != null) { + Block block = entity.worldObj.getBlock(pos.blockX, pos.blockY, pos.blockZ); - if (player.isSwingInProgress && pos != null) { - Block block = entity.worldObj.getBlock(pos.blockX, pos.blockY, pos.blockZ); + if(block != null) { + Material mat = block.getMaterial(); + if(ToolCommons.isRightMaterial(mat, ToolCommons.materialsPick)) + typeToFind = ToolType.PICK; + else if(ToolCommons.isRightMaterial(mat, ToolCommons.materialsShovel)) + typeToFind = ToolType.SHOVEL; + else if(ToolCommons.isRightMaterial(mat, ToolCommons.materialsAxe)) + typeToFind = ToolType.AXE; + } + } - if (block != null) { - Material mat = block.getMaterial(); - if (ToolCommons.isRightMaterial(mat, ToolCommons.materialsPick)) typeToFind = ToolType.PICK; - else if (ToolCommons.isRightMaterial(mat, ToolCommons.materialsShovel)) typeToFind = ToolType.SHOVEL; - else if (ToolCommons.isRightMaterial(mat, ToolCommons.materialsAxe)) typeToFind = ToolType.AXE; - } - } + if(typeToFind == null) + return; - if (typeToFind == null) return; + ItemStack bestTool = currentStack; + int bestToolPriority = tool.getSortingType(currentStack) == typeToFind ? tool.getSortingPriority(currentStack) : -1; + int bestSlot = -1; - ItemStack bestTool = currentStack; - int bestToolPriority = - tool.getSortingType(currentStack) == typeToFind ? tool.getSortingPriority(currentStack) : -1; - int bestSlot = -1; + for(int i = 0; i < player.inventory.getSizeInventory(); i++) { + ItemStack stackInSlot = player.inventory.getStackInSlot(i); + if (stackInSlot != null && stackInSlot.getItem() instanceof ISortableTool && stackInSlot != currentStack) { + ISortableTool toolInSlot = (ISortableTool) stackInSlot.getItem(); + if(toolInSlot.getSortingType(stackInSlot).equals(typeToFind)) { + int priority = toolInSlot.getSortingPriority(stackInSlot); + if(priority > bestToolPriority) { + bestTool = stackInSlot; + bestToolPriority = priority; + bestSlot = i; + } + } + } + } - for (int i = 0; i < player.inventory.getSizeInventory(); i++) { - ItemStack stackInSlot = player.inventory.getStackInSlot(i); - if (stackInSlot != null && stackInSlot.getItem() instanceof ISortableTool && stackInSlot != currentStack) { - ISortableTool toolInSlot = (ISortableTool) stackInSlot.getItem(); - if (toolInSlot.getSortingType(stackInSlot).equals(typeToFind)) { - int priority = toolInSlot.getSortingPriority(stackInSlot); - if (priority > bestToolPriority) { - bestTool = stackInSlot; - bestToolPriority = priority; - bestSlot = i; - } - } - } - } + if(bestSlot != -1) { + player.inventory.setInventorySlotContents(player.inventory.currentItem, bestTool); + player.inventory.setInventorySlotContents(bestSlot, currentStack); + } + } - if (bestSlot != -1) { - player.inventory.setInventorySlotContents(player.inventory.currentItem, bestTool); - player.inventory.setInventorySlotContents(bestSlot, currentStack); - } - } + @Override + public BaubleType getBaubleType(ItemStack arg0) { + return BaubleType.RING; + } - @Override - public BaubleType getBaubleType(ItemStack arg0) { - return BaubleType.RING; - } } diff --git a/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemTinyPlanet.java b/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemTinyPlanet.java index 24969c05d4..7b03ea5dce 100644 --- a/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemTinyPlanet.java +++ b/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemTinyPlanet.java @@ -2,16 +2,16 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Apr 20, 2014, 10:58:00 PM (GMT)] */ package vazkii.botania.common.item.equipment.bauble; -import baubles.api.BaubleType; import java.util.List; + import net.minecraft.client.Minecraft; import net.minecraft.client.renderer.RenderBlocks; import net.minecraft.client.renderer.texture.TextureMap; @@ -22,90 +22,94 @@ import net.minecraft.util.AxisAlignedBB; import net.minecraft.world.World; import net.minecraftforge.client.event.RenderPlayerEvent; + import org.lwjgl.opengl.GL11; + import vazkii.botania.api.internal.IManaBurst; import vazkii.botania.api.item.IBaubleRender; import vazkii.botania.api.mana.ITinyPlanetExcempt; import vazkii.botania.common.block.ModBlocks; import vazkii.botania.common.core.helper.Vector3; import vazkii.botania.common.lib.LibItemNames; +import baubles.api.BaubleType; public class ItemTinyPlanet extends ItemBauble implements IBaubleRender { - public static final String TAG_ORBIT = "orbit"; - - public ItemTinyPlanet() { - super(LibItemNames.TINY_PLANET); - } - - @Override - public BaubleType getBaubleType(ItemStack itemstack) { - return BaubleType.AMULET; - } - - @Override - public void onWornTick(ItemStack stack, EntityLivingBase player) { - super.onWornTick(stack, player); - - double x = player.posX; - double y = player.posY + 1.2F; - double z = player.posZ; - if (player.worldObj.isRemote) y -= 1.62F; - - applyEffect(player.worldObj, x, y, z); - } - - public static void applyEffect(World world, double x, double y, double z) { - int range = 8; - List entities = world.getEntitiesWithinAABB( - IManaBurst.class, - AxisAlignedBB.getBoundingBox(x - range, y - range, z - range, x + range, y + range, z + range)); - for (Entity entity : entities) { - IManaBurst burst = (IManaBurst) entity; - ItemStack lens = burst.getSourceLens(); - if (lens != null - && lens.getItem() instanceof ITinyPlanetExcempt - && !((ITinyPlanetExcempt) lens.getItem()).shouldPull(lens)) continue; - - int orbitTime = getEntityOrbitTime(entity); - if (orbitTime == 0) burst.setMinManaLoss(burst.getMinManaLoss() * 3); - - float radius = Math.min(7.5F, (Math.max(40, orbitTime) - 40) / 40F + 1.5F); - int angle = orbitTime % 360; - - float xTarget = (float) (x + Math.cos(angle * 10 * Math.PI / 180F) * radius); - float yTarget = (float) y; - float zTarget = (float) (z + Math.sin(angle * 10 * Math.PI / 180F) * radius); - - Vector3 targetVec = new Vector3(xTarget, yTarget, zTarget); - Vector3 currentVec = new Vector3(entity.posX, entity.posY, entity.posZ); - Vector3 moveVector = targetVec.copy().sub(currentVec); - - burst.setMotion(moveVector.x, moveVector.y, moveVector.z); - - incrementOrbitTime(entity); - } - } - - public static int getEntityOrbitTime(Entity entity) { - NBTTagCompound cmp = entity.getEntityData(); - if (cmp.hasKey(TAG_ORBIT)) return cmp.getInteger(TAG_ORBIT); - else return 0; - } - - public static void incrementOrbitTime(Entity entity) { - NBTTagCompound cmp = entity.getEntityData(); - int time = getEntityOrbitTime(entity); - cmp.setInteger(TAG_ORBIT, time + 1); - } - - @Override - public void onPlayerBaubleRender(ItemStack stack, RenderPlayerEvent event, RenderType type) { - if (type == RenderType.HEAD) { - Minecraft.getMinecraft().renderEngine.bindTexture(TextureMap.locationBlocksTexture); - GL11.glTranslatef(0.25F, -0.5F, 0F); - GL11.glScalef(0.5F, 0.5F, 0.5F); - RenderBlocks.getInstance().renderBlockAsItem(ModBlocks.tinyPlanet, 0, 1F); - } - } + public static final String TAG_ORBIT = "orbit"; + + public ItemTinyPlanet() { + super(LibItemNames.TINY_PLANET); + } + + @Override + public BaubleType getBaubleType(ItemStack itemstack) { + return BaubleType.AMULET; + } + + @Override + public void onWornTick(ItemStack stack, EntityLivingBase player) { + super.onWornTick(stack, player); + + double x = player.posX; + double y = player.posY + 1.2F; + double z = player.posZ; + if(player.worldObj.isRemote) + y -= 1.62F; + + applyEffect(player.worldObj, x, y, z); + } + + public static void applyEffect(World world, double x, double y, double z) { + int range = 8; + List entities = world.getEntitiesWithinAABB(IManaBurst.class, AxisAlignedBB.getBoundingBox(x - range, y - range, z - range, x + range, y + range, z + range)); + for(Entity entity : entities) { + IManaBurst burst = (IManaBurst) entity; + ItemStack lens = burst.getSourceLens(); + if(lens != null && lens.getItem() instanceof ITinyPlanetExcempt && !((ITinyPlanetExcempt) lens.getItem()).shouldPull(lens)) + continue; + + int orbitTime = getEntityOrbitTime(entity); + if(orbitTime == 0) + burst.setMinManaLoss(burst.getMinManaLoss() * 3); + + float radius = Math.min(7.5F, (Math.max(40, orbitTime) - 40) / 40F + 1.5F); + int angle = orbitTime % 360; + + float xTarget = (float) (x + Math.cos(angle * 10 * Math.PI / 180F) * radius); + float yTarget = (float) y; + float zTarget = (float) (z + Math.sin(angle * 10 * Math.PI / 180F) * radius); + + Vector3 targetVec = new Vector3(xTarget, yTarget, zTarget); + Vector3 currentVec = new Vector3(entity.posX, entity.posY, entity.posZ); + Vector3 moveVector = targetVec.copy().sub(currentVec); + + burst.setMotion(moveVector.x, moveVector.y, moveVector.z); + + incrementOrbitTime(entity); + } + } + + public static int getEntityOrbitTime(Entity entity) { + NBTTagCompound cmp = entity.getEntityData(); + if(cmp.hasKey(TAG_ORBIT)) + return cmp.getInteger(TAG_ORBIT); + else return 0; + } + + public static void incrementOrbitTime(Entity entity) { + NBTTagCompound cmp = entity.getEntityData(); + int time = getEntityOrbitTime(entity); + cmp.setInteger(TAG_ORBIT, time + 1); + } + + @Override + public void onPlayerBaubleRender(ItemStack stack, RenderPlayerEvent event, RenderType type) { + if(type == RenderType.HEAD) { + Minecraft.getMinecraft().renderEngine.bindTexture(TextureMap.locationBlocksTexture); + GL11.glTranslatef(0.25F, -0.5F, 0F); + GL11.glScalef(0.5F, 0.5F, 0.5F); + RenderBlocks.getInstance().renderBlockAsItem(ModBlocks.tinyPlanet, 0, 1F); + } + } + } diff --git a/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemTravelBelt.java b/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemTravelBelt.java index da80653f3c..1cae596c8f 100644 --- a/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemTravelBelt.java +++ b/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemTravelBelt.java @@ -2,22 +2,17 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Apr 24, 2014, 11:14:57 PM (GMT)] */ package vazkii.botania.common.item.equipment.bauble; -import baubles.api.BaubleType; -import baubles.common.lib.PlayerHandler; -import cpw.mods.fml.common.eventhandler.SubscribeEvent; -import cpw.mods.fml.common.gameevent.PlayerEvent; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; import java.util.ArrayList; import java.util.List; + import net.minecraft.block.material.Material; import net.minecraft.client.Minecraft; import net.minecraft.client.model.ModelBiped; @@ -28,150 +23,154 @@ import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.event.entity.living.LivingEvent.LivingJumpEvent; import net.minecraftforge.event.entity.living.LivingEvent.LivingUpdateEvent; + import org.lwjgl.opengl.GL11; + import vazkii.botania.api.item.IBaubleRender; import vazkii.botania.api.mana.IManaUsingItem; import vazkii.botania.api.mana.ManaItemHandler; import vazkii.botania.client.lib.LibResources; import vazkii.botania.common.lib.LibItemNames; +import baubles.api.BaubleType; +import baubles.common.lib.PlayerHandler; +import cpw.mods.fml.common.eventhandler.SubscribeEvent; +import cpw.mods.fml.common.gameevent.PlayerEvent; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; public class ItemTravelBelt extends ItemBauble implements IBaubleRender, IManaUsingItem { - private static final ResourceLocation texture = new ResourceLocation(LibResources.MODEL_TRAVEL_BELT); - - @SideOnly(Side.CLIENT) - private static ModelBiped model; - - private static final int COST = 1; - private static final int COST_INTERVAL = 10; - - public static List playersWithStepup = new ArrayList(); - - final float speed; - final float jump; - final float fallBuffer; - - public ItemTravelBelt() { - this(LibItemNames.TRAVEL_BELT, 0.035F, 0.2F, 2F); - MinecraftForge.EVENT_BUS.register(this); - } - - public ItemTravelBelt(String name, float speed, float jump, float fallBuffer) { - super(name); - this.speed = speed; - this.jump = jump; - this.fallBuffer = fallBuffer; - } - - @Override - public BaubleType getBaubleType(ItemStack itemstack) { - return BaubleType.BELT; - } - - @SubscribeEvent - public void updatePlayerStepStatus(LivingUpdateEvent event) { - if (event.entityLiving instanceof EntityPlayer) { - EntityPlayer player = (EntityPlayer) event.entityLiving; - String s = playerStr(player); - - ItemStack belt = PlayerHandler.getPlayerBaubles(player).getStackInSlot(3); - if (playersWithStepup.contains(s)) { - if (shouldPlayerHaveStepup(player)) { - ItemTravelBelt beltItem = (ItemTravelBelt) belt.getItem(); - - if ((player.onGround || player.capabilities.isFlying) - && player.moveForward > 0F - && !player.isInsideOfMaterial(Material.water)) { - float speed = beltItem.getSpeed(belt); - player.moveFlying(0F, 1F, player.capabilities.isFlying ? speed : speed); - beltItem.onMovedTick(belt, player); - - if (player.ticksExisted % COST_INTERVAL == 0) - ManaItemHandler.requestManaExact(belt, player, COST, true); - } else beltItem.onNotMovingTick(belt, player); - - if (player.isSneaking()) player.stepHeight = 0.50001F; // Not 0.5F because that is the default - else player.stepHeight = 1F; - - } else { - player.stepHeight = 0.5F; - playersWithStepup.remove(s); - } - } else if (shouldPlayerHaveStepup(player)) { - playersWithStepup.add(s); - player.stepHeight = 1F; - } - } - } - - public float getSpeed(ItemStack stack) { - return speed; - } - - public void onMovedTick(ItemStack stack, EntityPlayer player) { - // NO-OP - } - - public void onNotMovingTick(ItemStack stack, EntityPlayer player) { - // NO-OP - } - - @SubscribeEvent - public void onPlayerJump(LivingJumpEvent event) { - if (event.entityLiving instanceof EntityPlayer) { - EntityPlayer player = (EntityPlayer) event.entityLiving; - ItemStack belt = PlayerHandler.getPlayerBaubles(player).getStackInSlot(3); - - if (belt != null - && belt.getItem() instanceof ItemTravelBelt - && ManaItemHandler.requestManaExact(belt, player, COST, false)) { - player.motionY += ((ItemTravelBelt) belt.getItem()).jump; - player.fallDistance = -((ItemTravelBelt) belt.getItem()).fallBuffer; - } - } - } - - private boolean shouldPlayerHaveStepup(EntityPlayer player) { - ItemStack armor = PlayerHandler.getPlayerBaubles(player).getStackInSlot(3); - return armor != null - && armor.getItem() instanceof ItemTravelBelt - && ManaItemHandler.requestManaExact(armor, player, COST, false); - } - - @SubscribeEvent - public void playerLoggedOut(PlayerEvent.PlayerLoggedOutEvent event) { - String username = event.player.getGameProfile().getName(); - playersWithStepup.remove(username + ":false"); - playersWithStepup.remove(username + ":true"); - } - - public static String playerStr(EntityPlayer player) { - return player.getGameProfile().getName() + ":" + player.worldObj.isRemote; - } - - @SideOnly(Side.CLIENT) - ResourceLocation getRenderTexture() { - return texture; - } - - @Override - @SideOnly(Side.CLIENT) - public void onPlayerBaubleRender(ItemStack stack, RenderPlayerEvent event, RenderType type) { - if (type == RenderType.BODY) { - Minecraft.getMinecraft().renderEngine.bindTexture(getRenderTexture()); - Helper.rotateIfSneaking(event.entityPlayer); - GL11.glTranslatef(0F, 0.2F, 0F); - - float s = 1.05F / 16F; - GL11.glScalef(s, s, s); - if (model == null) model = new ModelBiped(); - - model.bipedBody.render(1F); - } - } - - @Override - public boolean usesMana(ItemStack stack) { - return true; - } + private static final ResourceLocation texture = new ResourceLocation(LibResources.MODEL_TRAVEL_BELT); + @SideOnly(Side.CLIENT) + private static ModelBiped model; + + private static final int COST = 1; + private static final int COST_INTERVAL = 10; + + public static List playersWithStepup = new ArrayList(); + + final float speed; + final float jump; + final float fallBuffer; + + public ItemTravelBelt() { + this(LibItemNames.TRAVEL_BELT, 0.035F, 0.2F, 2F); + MinecraftForge.EVENT_BUS.register(this); + } + + public ItemTravelBelt(String name, float speed, float jump, float fallBuffer) { + super(name); + this.speed = speed; + this.jump = jump; + this.fallBuffer = fallBuffer; + } + + @Override + public BaubleType getBaubleType(ItemStack itemstack) { + return BaubleType.BELT; + } + + @SubscribeEvent + public void updatePlayerStepStatus(LivingUpdateEvent event) { + if(event.entityLiving instanceof EntityPlayer) { + EntityPlayer player = (EntityPlayer) event.entityLiving; + String s = playerStr(player); + + ItemStack belt = PlayerHandler.getPlayerBaubles(player).getStackInSlot(3); + if(playersWithStepup.contains(s)) { + if(shouldPlayerHaveStepup(player)) { + ItemTravelBelt beltItem = (ItemTravelBelt) belt.getItem(); + + if((player.onGround || player.capabilities.isFlying) && player.moveForward > 0F && !player.isInsideOfMaterial(Material.water)) { + float speed = beltItem.getSpeed(belt); + player.moveFlying(0F, 1F, player.capabilities.isFlying ? speed : speed); + beltItem.onMovedTick(belt, player); + + if(player.ticksExisted % COST_INTERVAL == 0) + ManaItemHandler.requestManaExact(belt, player, COST, true); + } else beltItem.onNotMovingTick(belt, player); + + if(player.isSneaking()) + player.stepHeight = 0.50001F; // Not 0.5F because that is the default + else player.stepHeight = 1F; + + } else { + player.stepHeight = 0.5F; + playersWithStepup.remove(s); + } + } else if(shouldPlayerHaveStepup(player)) { + playersWithStepup.add(s); + player.stepHeight = 1F; + } + } + } + + public float getSpeed(ItemStack stack) { + return speed; + } + + public void onMovedTick(ItemStack stack, EntityPlayer player) { + // NO-OP + } + + public void onNotMovingTick(ItemStack stack, EntityPlayer player) { + // NO-OP + } + + @SubscribeEvent + public void onPlayerJump(LivingJumpEvent event) { + if(event.entityLiving instanceof EntityPlayer) { + EntityPlayer player = (EntityPlayer) event.entityLiving; + ItemStack belt = PlayerHandler.getPlayerBaubles(player).getStackInSlot(3); + + if(belt != null && belt.getItem() instanceof ItemTravelBelt && ManaItemHandler.requestManaExact(belt, player, COST, false)) { + player.motionY += ((ItemTravelBelt) belt.getItem()).jump; + player.fallDistance = -((ItemTravelBelt) belt.getItem()).fallBuffer; + } + } + } + + private boolean shouldPlayerHaveStepup(EntityPlayer player) { + ItemStack armor = PlayerHandler.getPlayerBaubles(player).getStackInSlot(3); + return armor != null && armor.getItem() instanceof ItemTravelBelt && ManaItemHandler.requestManaExact(armor, player, COST, false); + } + + @SubscribeEvent + public void playerLoggedOut(PlayerEvent.PlayerLoggedOutEvent event) { + String username = event.player.getGameProfile().getName(); + playersWithStepup.remove(username + ":false"); + playersWithStepup.remove(username + ":true"); + } + + public static String playerStr(EntityPlayer player) { + return player.getGameProfile().getName() + ":" + player.worldObj.isRemote; + } + + @SideOnly(Side.CLIENT) + ResourceLocation getRenderTexture() { + return texture; + } + + @Override + @SideOnly(Side.CLIENT) + public void onPlayerBaubleRender(ItemStack stack, RenderPlayerEvent event, RenderType type) { + if(type == RenderType.BODY) { + Minecraft.getMinecraft().renderEngine.bindTexture(getRenderTexture()); + Helper.rotateIfSneaking(event.entityPlayer); + GL11.glTranslatef(0F, 0.2F, 0F); + + float s = 1.05F / 16F; + GL11.glScalef(s, s, s); + if(model == null) + model = new ModelBiped(); + + model.bipedBody.render(1F); + } + } + + @Override + public boolean usesMana(ItemStack stack) { + return true; + } + } diff --git a/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemUnholyCloak.java b/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemUnholyCloak.java index e58e4de8f7..1dbd14b56e 100644 --- a/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemUnholyCloak.java +++ b/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemUnholyCloak.java @@ -2,15 +2,16 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Dec 4, 2014, 11:12:51 PM (GMT)] */ package vazkii.botania.common.item.equipment.bauble; import java.util.List; + import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.monster.IMob; import net.minecraft.entity.player.EntityPlayer; @@ -25,58 +26,40 @@ public class ItemUnholyCloak extends ItemHolyCloak { - private static final ResourceLocation texture = new ResourceLocation(LibResources.MODEL_UNHOLY_CLOAK); + private static final ResourceLocation texture = new ResourceLocation(LibResources.MODEL_UNHOLY_CLOAK); + + public ItemUnholyCloak() { + super(LibItemNames.UNHOLY_CLOAK); + } - public ItemUnholyCloak() { - super(LibItemNames.UNHOLY_CLOAK); - } + @Override + public boolean effectOnDamage(LivingHurtEvent event, EntityPlayer player, ItemStack stack) { + if(!event.source.isUnblockable()) { + int range = 6; + List mobs = player.worldObj.getEntitiesWithinAABB(IMob.class, AxisAlignedBB.getBoundingBox(player.posX - range, player.posY - range, player.posZ - range, player.posX + range, player.posY + range, player.posZ + range)); + for(IMob mob : mobs) + if(mob instanceof EntityLivingBase) { + EntityLivingBase entity = (EntityLivingBase) mob; + entity.attackEntityFrom(DamageSource.causePlayerDamage(player), event.ammount); + } - @Override - public boolean effectOnDamage(LivingHurtEvent event, EntityPlayer player, ItemStack stack) { - if (!event.source.isUnblockable()) { - int range = 6; - List mobs = player.worldObj.getEntitiesWithinAABB( - IMob.class, - AxisAlignedBB.getBoundingBox( - player.posX - range, - player.posY - range, - player.posZ - range, - player.posX + range, - player.posY + range, - player.posZ + range)); - for (IMob mob : mobs) - if (mob instanceof EntityLivingBase) { - EntityLivingBase entity = (EntityLivingBase) mob; - entity.attackEntityFrom(DamageSource.causePlayerDamage(player), event.ammount); - } + player.worldObj.playSoundAtEntity(player, "botania:unholyCloak", 1F, 1F); + for(int i = 0; i < 90; i++) { + float rad = i * 4F * (float) Math.PI / 180F; + float xMotion = (float) Math.cos(rad) * 0.2F; + float zMotion = (float) Math.sin(rad) * 0.2F; + Botania.proxy.wispFX(player.worldObj, player.posX, player.posY + 0.5, player.posZ, 0.4F + (float) Math.random() + 0.25F, 0F, 0F, 0.6F + (float) Math.random() * 0.2F, xMotion, 0F, zMotion); + } - player.worldObj.playSoundAtEntity(player, "botania:unholyCloak", 1F, 1F); - for (int i = 0; i < 90; i++) { - float rad = i * 4F * (float) Math.PI / 180F; - float xMotion = (float) Math.cos(rad) * 0.2F; - float zMotion = (float) Math.sin(rad) * 0.2F; - Botania.proxy.wispFX( - player.worldObj, - player.posX, - player.posY + 0.5, - player.posZ, - 0.4F + (float) Math.random() + 0.25F, - 0F, - 0F, - 0.6F + (float) Math.random() * 0.2F, - xMotion, - 0F, - zMotion); - } + return true; + } - return true; - } + return false; + } - return false; - } + @Override + ResourceLocation getRenderTexture() { + return texture; + } - @Override - ResourceLocation getRenderTexture() { - return texture; - } } diff --git a/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemWaterRing.java b/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemWaterRing.java index c43ecae48c..3b3c5d6454 100644 --- a/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemWaterRing.java +++ b/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemWaterRing.java @@ -2,15 +2,14 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [May 17, 2014, 3:44:24 PM (GMT)] */ package vazkii.botania.common.item.equipment.bauble; -import baubles.api.BaubleType; import net.minecraft.block.material.Material; import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.player.EntityPlayer; @@ -20,60 +19,66 @@ import vazkii.botania.api.mana.IManaUsingItem; import vazkii.botania.api.mana.ManaItemHandler; import vazkii.botania.common.lib.LibItemNames; +import baubles.api.BaubleType; public class ItemWaterRing extends ItemBauble implements IManaUsingItem { - public ItemWaterRing() { - super(LibItemNames.WATER_RING); - } + public ItemWaterRing() { + super(LibItemNames.WATER_RING); + } + + @Override + public void onWornTick(ItemStack stack, EntityLivingBase player) { + super.onWornTick(stack, player); - @Override - public void onWornTick(ItemStack stack, EntityLivingBase player) { - super.onWornTick(stack, player); + if(player.isInsideOfMaterial(Material.water)) { + double motionX = player.motionX * 1.2; + double motionY = player.motionY * 1.2; + double motionZ = player.motionZ * 1.2; - if (player.isInsideOfMaterial(Material.water)) { - double motionX = player.motionX * 1.2; - double motionY = player.motionY * 1.2; - double motionZ = player.motionZ * 1.2; + boolean changeX = Math.min(1.3, Math.abs(motionX)) == Math.abs(motionX); + boolean changeY = Math.min(1.3, Math.abs(motionY)) == Math.abs(motionY); + boolean changeZ = Math.min(1.3, Math.abs(motionZ)) == Math.abs(motionZ); - boolean changeX = Math.min(1.3, Math.abs(motionX)) == Math.abs(motionX); - boolean changeY = Math.min(1.3, Math.abs(motionY)) == Math.abs(motionY); - boolean changeZ = Math.min(1.3, Math.abs(motionZ)) == Math.abs(motionZ); + if(player instanceof EntityPlayer && ((EntityPlayer) player).capabilities.isFlying) + changeX = changeY = changeZ = false; - if (player instanceof EntityPlayer && ((EntityPlayer) player).capabilities.isFlying) - changeX = changeY = changeZ = false; + if(changeX) + player.motionX = motionX; + if(changeY) + player.motionY = motionY; + if(changeZ) + player.motionZ = motionZ; - if (changeX) player.motionX = motionX; - if (changeY) player.motionY = motionY; - if (changeZ) player.motionZ = motionZ; + PotionEffect effect = player.getActivePotionEffect(Potion.nightVision); + if(effect == null) { + PotionEffect neweffect = new PotionEffect(Potion.nightVision.id, Integer.MAX_VALUE, -42, true); + player.addPotionEffect(neweffect); + } - PotionEffect effect = player.getActivePotionEffect(Potion.nightVision); - if (effect == null) { - PotionEffect neweffect = new PotionEffect(Potion.nightVision.id, Integer.MAX_VALUE, -42, true); - player.addPotionEffect(neweffect); - } + if(player.getAir() <= 1 && player instanceof EntityPlayer) { + int mana = ManaItemHandler.requestMana(stack, (EntityPlayer) player, 300, true); + if(mana > 0) // If zero gets in the player has no air but won't drown. + player.setAir(mana); + } + } else onUnequipped(stack, player); + } - if (player.getAir() <= 1 && player instanceof EntityPlayer) { - int mana = ManaItemHandler.requestMana(stack, (EntityPlayer) player, 300, true); - if (mana > 0) // If zero gets in the player has no air but won't drown. - player.setAir(mana); - } - } else onUnequipped(stack, player); - } + @Override + public void onUnequipped(ItemStack stack, EntityLivingBase player) { + PotionEffect effect = player.getActivePotionEffect(Potion.nightVision); + if(effect != null && effect.getAmplifier() == -42) + player.removePotionEffect(Potion.nightVision.id); + } - @Override - public void onUnequipped(ItemStack stack, EntityLivingBase player) { - PotionEffect effect = player.getActivePotionEffect(Potion.nightVision); - if (effect != null && effect.getAmplifier() == -42) player.removePotionEffect(Potion.nightVision.id); - } + @Override + public BaubleType getBaubleType(ItemStack arg0) { + return BaubleType.RING; + } - @Override - public BaubleType getBaubleType(ItemStack arg0) { - return BaubleType.RING; - } + @Override + public boolean usesMana(ItemStack stack) { + return true; + } - @Override - public boolean usesMana(ItemStack stack) { - return true; - } } diff --git a/src/main/java/vazkii/botania/common/item/equipment/tool/ItemEnderDagger.java b/src/main/java/vazkii/botania/common/item/equipment/tool/ItemEnderDagger.java index db5fb376f9..e7102c7f08 100644 --- a/src/main/java/vazkii/botania/common/item/equipment/tool/ItemEnderDagger.java +++ b/src/main/java/vazkii/botania/common/item/equipment/tool/ItemEnderDagger.java @@ -2,15 +2,16 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jun 10, 2014, 11:48:12 PM (GMT)] */ package vazkii.botania.common.item.equipment.tool; import java.awt.Color; + import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.entity.Entity; import net.minecraft.entity.EntityLivingBase; @@ -28,60 +29,59 @@ public class ItemEnderDagger extends ItemManasteelSword { - IIcon iconFront, iconOverlay; + IIcon iconFront, iconOverlay; + + public ItemEnderDagger() { + super(BotaniaAPI.manasteelToolMaterial, LibItemNames.ENDER_DAGGER); + setMaxDamage(69); // What you looking at? + setNoRepair(); + } - public ItemEnderDagger() { - super(BotaniaAPI.manasteelToolMaterial, LibItemNames.ENDER_DAGGER); - setMaxDamage(69); // What you looking at? - setNoRepair(); - } + @Override + public void registerIcons(IIconRegister par1IconRegister) { + iconFront = IconHelper.forItem(par1IconRegister, this, 0); + iconOverlay = IconHelper.forItem(par1IconRegister, this, 1); + } - @Override - public void registerIcons(IIconRegister par1IconRegister) { - iconFront = IconHelper.forItem(par1IconRegister, this, 0); - iconOverlay = IconHelper.forItem(par1IconRegister, this, 1); - } + @Override + public boolean requiresMultipleRenderPasses() { + return true; + } - @Override - public boolean requiresMultipleRenderPasses() { - return true; - } + @Override + public IIcon getIcon(ItemStack stack, int pass) { + return pass == 0 ? iconFront : iconOverlay; + } - @Override - public IIcon getIcon(ItemStack stack, int pass) { - return pass == 0 ? iconFront : iconOverlay; - } + @Override + public int getColorFromItemStack(ItemStack par1ItemStack, int par2) { + if(par2 == 0) + return 0xFFFFFF; - @Override - public int getColorFromItemStack(ItemStack par1ItemStack, int par2) { - if (par2 == 0) return 0xFFFFFF; + return Color.HSBtoRGB(0.75F, 1F, 1.5F - (float) Math.min(1F, Math.sin(System.currentTimeMillis() / 100D) * 0.5 + 1.2F)); + } - return Color.HSBtoRGB( - 0.75F, 1F, 1.5F - (float) Math.min(1F, Math.sin(System.currentTimeMillis() / 100D) * 0.5 + 1.2F)); - } + @Override + public EnumAction getItemUseAction(ItemStack par1ItemStack) { + return EnumAction.none; + } - @Override - public EnumAction getItemUseAction(ItemStack par1ItemStack) { - return EnumAction.none; - } + @Override + public boolean hitEntity(ItemStack par1ItemStack, EntityLivingBase par2EntityLivingBase, EntityLivingBase par3EntityLivingBase) { + if(par2EntityLivingBase instanceof EntityEnderman && par3EntityLivingBase instanceof EntityPlayer) + par2EntityLivingBase.attackEntityFrom(DamageSource.causePlayerDamage((EntityPlayer) par3EntityLivingBase), 20); + par1ItemStack.damageItem(1, par3EntityLivingBase); + return true; + } - @Override - public boolean hitEntity( - ItemStack par1ItemStack, EntityLivingBase par2EntityLivingBase, EntityLivingBase par3EntityLivingBase) { - if (par2EntityLivingBase instanceof EntityEnderman && par3EntityLivingBase instanceof EntityPlayer) - par2EntityLivingBase.attackEntityFrom( - DamageSource.causePlayerDamage((EntityPlayer) par3EntityLivingBase), 20); - par1ItemStack.damageItem(1, par3EntityLivingBase); - return true; - } + @Override + public void onUpdate(ItemStack stack, World world, Entity player, int par4, boolean par5) { + // NO-OP + } - @Override - public void onUpdate(ItemStack stack, World world, Entity player, int par4, boolean par5) { - // NO-OP - } + @Override + public boolean usesMana(ItemStack stack) { + return false; + } - @Override - public boolean usesMana(ItemStack stack) { - return false; - } } diff --git a/src/main/java/vazkii/botania/common/item/equipment/tool/ItemGlassPick.java b/src/main/java/vazkii/botania/common/item/equipment/tool/ItemGlassPick.java index 74f9b02aea..f651eb9770 100644 --- a/src/main/java/vazkii/botania/common/item/equipment/tool/ItemGlassPick.java +++ b/src/main/java/vazkii/botania/common/item/equipment/tool/ItemGlassPick.java @@ -2,15 +2,14 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Aug 6, 2014, 9:55:23 PM (GMT)] */ package vazkii.botania.common.item.equipment.tool; -import cpw.mods.fml.common.eventhandler.SubscribeEvent; import net.minecraft.block.material.Material; import net.minecraft.init.Blocks; import net.minecraft.item.Item; @@ -20,44 +19,37 @@ import net.minecraftforge.event.world.BlockEvent.HarvestDropsEvent; import vazkii.botania.common.item.equipment.tool.manasteel.ItemManasteelPick; import vazkii.botania.common.lib.LibItemNames; +import cpw.mods.fml.common.eventhandler.SubscribeEvent; public class ItemGlassPick extends ItemManasteelPick { - private static final int MANA_PER_DAMAGE = 160; - private static final ToolMaterial MATERIAL = EnumHelper.addToolMaterial("MANASTEEL_GLASS", 0, 125, 4.8F, 1F, 10); - - public ItemGlassPick() { - super(MATERIAL, LibItemNames.GLASS_PICK); - MinecraftForge.EVENT_BUS.register(this); - } - - @SubscribeEvent - public void onBlockDrops(HarvestDropsEvent event) { - if (event.harvester != null - && event.block != null - && event.drops.isEmpty() - && event.harvester.getCurrentEquippedItem() != null - && event.harvester.getCurrentEquippedItem().getItem() == this - && event.block.getMaterial() == Material.glass - && event.block.canSilkHarvest( - event.world, event.harvester, event.x, event.y, event.z, event.blockMetadata)) - event.drops.add(new ItemStack(event.block, 1, event.blockMetadata)); - } - - @Override - public int getManaPerDmg() { - return MANA_PER_DAMAGE; - } - - @Override - public boolean getIsRepairable(ItemStack par1ItemStack, ItemStack par2ItemStack) { - return par2ItemStack.getItem() == Item.getItemFromBlock(Blocks.glass) - ? true - : super.getIsRepairable(par1ItemStack, par2ItemStack); - } - - @Override - public int getSortingPriority(ItemStack stack) { - return 0; - } + private static final int MANA_PER_DAMAGE = 160; + private static final ToolMaterial MATERIAL = EnumHelper.addToolMaterial("MANASTEEL_GLASS", 0, 125, 4.8F, 1F, 10); + + public ItemGlassPick() { + super(MATERIAL, LibItemNames.GLASS_PICK); + MinecraftForge.EVENT_BUS.register(this); + } + + @SubscribeEvent + public void onBlockDrops(HarvestDropsEvent event) { + if(event.harvester != null && event.block != null && event.drops.isEmpty() && event.harvester.getCurrentEquippedItem() != null && event.harvester.getCurrentEquippedItem().getItem() == this && event.block.getMaterial() == Material.glass && event.block.canSilkHarvest(event.world, event.harvester, event.x, event.y, event.z, event.blockMetadata)) + event.drops.add(new ItemStack(event.block, 1, event.blockMetadata)); + } + + @Override + public int getManaPerDmg() { + return MANA_PER_DAMAGE; + } + + @Override + public boolean getIsRepairable(ItemStack par1ItemStack, ItemStack par2ItemStack) { + return par2ItemStack.getItem() == Item.getItemFromBlock(Blocks.glass) ? true : super.getIsRepairable(par1ItemStack, par2ItemStack); + } + + @Override + public int getSortingPriority(ItemStack stack) { + return 0; + } + } diff --git a/src/main/java/vazkii/botania/common/item/equipment/tool/ItemStarSword.java b/src/main/java/vazkii/botania/common/item/equipment/tool/ItemStarSword.java index 33071d8b12..fa1e78b214 100644 --- a/src/main/java/vazkii/botania/common/item/equipment/tool/ItemStarSword.java +++ b/src/main/java/vazkii/botania/common/item/equipment/tool/ItemStarSword.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Aug 17, 2015, 3:55:52 PM (GMT)] */ package vazkii.botania.common.item.equipment.tool; @@ -30,59 +30,56 @@ public class ItemStarSword extends ItemManasteelSword implements ICraftAchievement { - private static final int MANA_PER_DAMAGE = 120; + private static final int MANA_PER_DAMAGE = 120; - public ItemStarSword() { - super(BotaniaAPI.terrasteelToolMaterial, LibItemNames.STAR_SWORD); - } + public ItemStarSword() { + super(BotaniaAPI.terrasteelToolMaterial, LibItemNames.STAR_SWORD); + } - @Override - public void onUpdate(ItemStack par1ItemStack, World par2World, Entity par3Entity, int par4, boolean par5) { - super.onUpdate(par1ItemStack, par2World, par3Entity, par4, par5); - if (par3Entity instanceof EntityPlayer) { - EntityPlayer player = (EntityPlayer) par3Entity; - PotionEffect haste = player.getActivePotionEffect(Potion.digSpeed); - float check = haste == null ? 0.16666667F : haste.getAmplifier() == 1 ? 0.5F : 0.4F; + @Override + public void onUpdate(ItemStack par1ItemStack, World par2World, Entity par3Entity, int par4, boolean par5) { + super.onUpdate(par1ItemStack, par2World, par3Entity, par4, par5); + if(par3Entity instanceof EntityPlayer) { + EntityPlayer player = (EntityPlayer) par3Entity; + PotionEffect haste = player.getActivePotionEffect(Potion.digSpeed); + float check = haste == null ? 0.16666667F : haste.getAmplifier() == 1 ? 0.5F : 0.4F; - if (player.getCurrentEquippedItem() == par1ItemStack - && player.swingProgress == check - && !par2World.isRemote - && par2World.rand.nextInt(2) == 0) { - MovingObjectPosition pos = ToolCommons.raytraceFromEntity(par2World, par3Entity, true, 48); - if (pos != null) { - Vector3 posVec = new Vector3(pos.blockX, pos.blockY, pos.blockZ); - Vector3 motVec = new Vector3((Math.random() - 0.5) * 18, 24, (Math.random() - 0.5) * 18); - posVec.add(motVec); - motVec.normalize().negate().multiply(1.5); + if(player.getCurrentEquippedItem() == par1ItemStack && player.swingProgress == check && !par2World.isRemote && par2World.rand.nextInt(2) == 0) { + MovingObjectPosition pos = ToolCommons.raytraceFromEntity(par2World, par3Entity, true, 48); + if(pos != null) { + Vector3 posVec = new Vector3(pos.blockX, pos.blockY, pos.blockZ); + Vector3 motVec = new Vector3((Math.random() - 0.5) * 18, 24, (Math.random() - 0.5) * 18); + posVec.add(motVec); + motVec.normalize().negate().multiply(1.5); - EntityFallingStar star = new EntityFallingStar(par2World, player); - star.setPosition(posVec.x, posVec.y, posVec.z); - star.motionX = motVec.x; - star.motionY = motVec.y; - star.motionZ = motVec.z; - par2World.spawnEntityInWorld(star); + EntityFallingStar star = new EntityFallingStar(par2World, player); + star.setPosition(posVec.x, posVec.y, posVec.z); + star.motionX = motVec.x; + star.motionY = motVec.y; + star.motionZ = motVec.z; + par2World.spawnEntityInWorld(star); - ToolCommons.damageItem(par1ItemStack, 1, player, MANA_PER_DAMAGE); - par2World.playSoundAtEntity(player, "botania:starcaller", 0.4F, 1.4F); - } - } - } - } + ToolCommons.damageItem(par1ItemStack, 1, player, MANA_PER_DAMAGE); + par2World.playSoundAtEntity(player, "botania:starcaller", 0.4F, 1.4F); + } + } + } + } - @Override - public int getManaPerDamage() { - return MANA_PER_DAMAGE; - } + @Override + public int getManaPerDamage() { + return MANA_PER_DAMAGE; + } + + @Override + public boolean getIsRepairable(ItemStack par1ItemStack, ItemStack par2ItemStack) { + return par2ItemStack.getItem() == ModItems.manaResource && par2ItemStack.getItemDamage() == 4 ? true : super.getIsRepairable(par1ItemStack, par2ItemStack); + } + + @Override + public Achievement getAchievementOnCraft(ItemStack stack, EntityPlayer player, IInventory matrix) { + return ModAchievements.terrasteelWeaponCraft; + } - @Override - public boolean getIsRepairable(ItemStack par1ItemStack, ItemStack par2ItemStack) { - return par2ItemStack.getItem() == ModItems.manaResource && par2ItemStack.getItemDamage() == 4 - ? true - : super.getIsRepairable(par1ItemStack, par2ItemStack); - } - @Override - public Achievement getAchievementOnCraft(ItemStack stack, EntityPlayer player, IInventory matrix) { - return ModAchievements.terrasteelWeaponCraft; - } } diff --git a/src/main/java/vazkii/botania/common/item/equipment/tool/ItemThunderSword.java b/src/main/java/vazkii/botania/common/item/equipment/tool/ItemThunderSword.java index 709c3ec45b..27d6d41f4e 100644 --- a/src/main/java/vazkii/botania/common/item/equipment/tool/ItemThunderSword.java +++ b/src/main/java/vazkii/botania/common/item/equipment/tool/ItemThunderSword.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Aug 27, 2015, 10:38:50 PM (GMT)] */ package vazkii.botania.common.item.equipment.tool; @@ -13,6 +13,7 @@ import java.util.ArrayList; import java.util.List; import java.util.Random; + import net.minecraft.command.IEntitySelector; import net.minecraft.entity.Entity; import net.minecraft.entity.EntityLivingBase; @@ -34,73 +35,60 @@ public class ItemThunderSword extends ItemManasteelSword implements ICraftAchievement { - private static final String TAG_LIGHTNING_SEED = "lightningSeed"; - - public ItemThunderSword() { - super(BotaniaAPI.terrasteelToolMaterial, LibItemNames.THUNDER_SWORD); - } - - @Override - public boolean hitEntity(ItemStack stack, EntityLivingBase entity, EntityLivingBase attacker) { - if (!(entity instanceof EntityPlayer) && entity != null) { - double range = 8; - final List alreadyTargetedEntities = new ArrayList(); - int dmg = 5; - long lightningSeed = ItemNBTHelper.getLong(stack, TAG_LIGHTNING_SEED, 0); - - IEntitySelector selector = new IEntitySelector() { - - @Override - public boolean isEntityApplicable(Entity e) { - return e instanceof EntityLivingBase - && e instanceof IMob - && !(e instanceof EntityPlayer) - && !alreadyTargetedEntities.contains(e); - } - }; - - Random rand = new Random(lightningSeed); - EntityLivingBase lightningSource = entity; - for (int i = 0; i < 4; i++) { - List entities = entity.worldObj.getEntitiesWithinAABBExcludingEntity( - lightningSource, - AxisAlignedBB.getBoundingBox( - lightningSource.posX - range, - lightningSource.posY - range, - lightningSource.posZ - range, - lightningSource.posX + range, - lightningSource.posY + range, - lightningSource.posZ + range), - selector); - if (entities.isEmpty()) break; - - EntityLivingBase target = entities.get(rand.nextInt(entities.size())); - if (attacker instanceof EntityPlayer) - target.attackEntityFrom(DamageSource.causePlayerDamage((EntityPlayer) attacker), dmg); - else target.attackEntityFrom(DamageSource.causeMobDamage(attacker), dmg); - - Botania.proxy.lightningFX( - entity.worldObj, - Vector3.fromEntityCenter(lightningSource), - Vector3.fromEntityCenter(target), - 1, - 0x0179C4, - 0xAADFFF); - - alreadyTargetedEntities.add(target); - lightningSource = target; - dmg--; - } - - if (!entity.worldObj.isRemote) - ItemNBTHelper.setLong(stack, TAG_LIGHTNING_SEED, entity.worldObj.rand.nextLong()); - } - - return super.hitEntity(stack, entity, attacker); - } - - @Override - public Achievement getAchievementOnCraft(ItemStack stack, EntityPlayer player, IInventory matrix) { - return ModAchievements.terrasteelWeaponCraft; - } + private static final String TAG_LIGHTNING_SEED = "lightningSeed"; + + public ItemThunderSword() { + super(BotaniaAPI.terrasteelToolMaterial, LibItemNames.THUNDER_SWORD); + } + + @Override + public boolean hitEntity(ItemStack stack, EntityLivingBase entity, EntityLivingBase attacker) { + if(!(entity instanceof EntityPlayer) && entity != null) { + double range = 8; + final List alreadyTargetedEntities = new ArrayList(); + int dmg = 5; + long lightningSeed = ItemNBTHelper.getLong(stack, TAG_LIGHTNING_SEED, 0); + + IEntitySelector selector = new IEntitySelector() { + + @Override + public boolean isEntityApplicable(Entity e) { + return e instanceof EntityLivingBase && e instanceof IMob && !(e instanceof EntityPlayer) && !alreadyTargetedEntities.contains(e); + } + + }; + + Random rand = new Random(lightningSeed); + EntityLivingBase lightningSource = entity; + for(int i = 0; i < 4; i++) { + List entities = entity.worldObj.getEntitiesWithinAABBExcludingEntity(lightningSource, AxisAlignedBB.getBoundingBox(lightningSource.posX - range, lightningSource.posY - range, lightningSource.posZ - range, lightningSource.posX + range, lightningSource.posY + range, lightningSource.posZ + range), selector); + if(entities.isEmpty()) + break; + + EntityLivingBase target = entities.get(rand.nextInt(entities.size())); + if(attacker instanceof EntityPlayer) + target.attackEntityFrom(DamageSource.causePlayerDamage((EntityPlayer) attacker), dmg); + else target.attackEntityFrom(DamageSource.causeMobDamage(attacker), dmg); + + Botania.proxy.lightningFX(entity.worldObj, Vector3.fromEntityCenter(lightningSource), Vector3.fromEntityCenter(target), 1, 0x0179C4, 0xAADFFF); + + alreadyTargetedEntities.add(target); + lightningSource = target; + dmg--; + } + + if(!entity.worldObj.isRemote) + ItemNBTHelper.setLong(stack, TAG_LIGHTNING_SEED, entity.worldObj.rand.nextLong()); + } + + + return super.hitEntity(stack, entity, attacker); + } + + @Override + public Achievement getAchievementOnCraft(ItemStack stack, EntityPlayer player, IInventory matrix) { + return ModAchievements.terrasteelWeaponCraft; + } + + } diff --git a/src/main/java/vazkii/botania/common/item/equipment/tool/ToolCommons.java b/src/main/java/vazkii/botania/common/item/equipment/tool/ToolCommons.java index f8792d93b0..c6346db91b 100644 --- a/src/main/java/vazkii/botania/common/item/equipment/tool/ToolCommons.java +++ b/src/main/java/vazkii/botania/common/item/equipment/tool/ToolCommons.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Apr 13, 2014, 7:13:04 PM (GMT)] */ package vazkii.botania.common.item.equipment.tool; @@ -34,199 +34,121 @@ public final class ToolCommons { - public static Material[] materialsPick = - new Material[] {Material.rock, Material.iron, Material.ice, Material.glass, Material.piston, Material.anvil - }; - public static Material[] materialsShovel = new Material[] { - Material.grass, Material.ground, Material.sand, Material.snow, Material.craftedSnow, Material.clay - }; - public static Material[] materialsAxe = - new Material[] {Material.coral, Material.leaves, Material.plants, Material.wood, Material.gourd}; - - public static void damageItem(ItemStack stack, int dmg, EntityLivingBase entity, int manaPerDamage) { - int manaToRequest = dmg * manaPerDamage; - boolean manaRequested = entity instanceof EntityPlayer - ? ManaItemHandler.requestManaExactForTool(stack, (EntityPlayer) entity, manaToRequest, true) - : false; - - if (!manaRequested) stack.damageItem(dmg, entity); - } - - public static void removeBlocksInIteration( - EntityPlayer player, - ItemStack stack, - World world, - int x, - int y, - int z, - int xs, - int ys, - int zs, - int xe, - int ye, - int ze, - Block block, - Material[] materialsListing, - boolean silk, - int fortune, - boolean dispose) { - float blockHardness = block == null ? 1F : block.getBlockHardness(world, x, y, z); - - for (int x1 = xs; x1 < xe; x1++) - for (int y1 = ys; y1 < ye; y1++) - for (int z1 = zs; z1 < ze; z1++) - removeBlockWithDrops( - player, - stack, - world, - x1 + x, - y1 + y, - z1 + z, - x, - y, - z, - block, - materialsListing, - silk, - fortune, - blockHardness, - dispose); - } - - public static boolean isRightMaterial(Material material, Material[] materialsListing) { - for (Material mat : materialsListing) if (material == mat) return true; - - return false; - } - - public static void removeBlockWithDrops( - EntityPlayer player, - ItemStack stack, - World world, - int x, - int y, - int z, - int bx, - int by, - int bz, - Block block, - Material[] materialsListing, - boolean silk, - int fortune, - float blockHardness, - boolean dispose) { - removeBlockWithDrops( - player, - stack, - world, - x, - y, - z, - bx, - by, - bz, - block, - materialsListing, - silk, - fortune, - blockHardness, - dispose, - true); - } - - public static void removeBlockWithDrops( - EntityPlayer player, - ItemStack stack, - World world, - int x, - int y, - int z, - int bx, - int by, - int bz, - Block block, - Material[] materialsListing, - boolean silk, - int fortune, - float blockHardness, - boolean dispose, - boolean particles) { - if (!world.blockExists(x, y, z)) return; - - Block blk = world.getBlock(x, y, z); - int meta = world.getBlockMetadata(x, y, z); - - if (block != null && blk != block) return; - - Material mat = world.getBlock(x, y, z).getMaterial(); - if (!world.isRemote - && blk != null - && !blk.isAir(world, x, y, z) - && blk.getPlayerRelativeBlockHardness(player, world, x, y, z) > 0) { - if (!blk.canHarvestBlock(player, meta) || !isRightMaterial(mat, materialsListing)) return; - - if (!player.capabilities.isCreativeMode) { - int localMeta = world.getBlockMetadata(x, y, z); - blk.onBlockHarvested(world, x, y, z, localMeta, player); - - if (blk.removedByPlayer(world, player, x, y, z, true)) { - blk.onBlockDestroyedByPlayer(world, x, y, z, localMeta); - - if (!dispose || !ItemElementiumPick.isDisposable(blk)) - blk.harvestBlock(world, player, x, y, z, localMeta); - } - - damageItem(stack, 1, player, 80); - } else world.setBlockToAir(x, y, z); - - if (particles - && !world.isRemote - && ConfigHandler.blockBreakParticles - && ConfigHandler.blockBreakParticlesTool) - world.playAuxSFX(2001, x, y, z, Block.getIdFromBlock(blk) + (meta << 12)); - } - } - - public static int getToolPriority(ItemStack stack) { - if (stack == null) return 0; - - Item item = stack.getItem(); - if (!(item instanceof ItemTool)) return 0; - - ItemTool tool = (ItemTool) item; - ToolMaterial material = tool.func_150913_i(); - int materialLevel = 0; - if (material == BotaniaAPI.manasteelToolMaterial) materialLevel = 10; - if (material == BotaniaAPI.elementiumToolMaterial) materialLevel = 11; - if (material == BotaniaAPI.terrasteelToolMaterial) materialLevel = 20; - - int modifier = 0; - if (item == ModItems.terraPick) modifier = ItemTerraPick.getLevel(stack); - - int efficiency = EnchantmentHelper.getEnchantmentLevel(Enchantment.efficiency.effectId, stack); - return materialLevel * 100 + modifier * 10 + efficiency; - } - - /** - * @author mDiyo - */ - public static MovingObjectPosition raytraceFromEntity(World world, Entity player, boolean par3, double range) { - float f = 1.0F; - float f1 = player.prevRotationPitch + (player.rotationPitch - player.prevRotationPitch) * f; - float f2 = player.prevRotationYaw + (player.rotationYaw - player.prevRotationYaw) * f; - double d0 = player.prevPosX + (player.posX - player.prevPosX) * f; - double d1 = player.prevPosY + (player.posY - player.prevPosY) * f; - if (!world.isRemote && player instanceof EntityPlayer) d1 += ((EntityPlayer) player).eyeHeight; - double d2 = player.prevPosZ + (player.posZ - player.prevPosZ) * f; - Vec3 vec3 = Vec3.createVectorHelper(d0, d1, d2); - float f3 = MathHelper.cos(-f2 * 0.017453292F - (float) Math.PI); - float f4 = MathHelper.sin(-f2 * 0.017453292F - (float) Math.PI); - float f5 = -MathHelper.cos(-f1 * 0.017453292F); - float f6 = MathHelper.sin(-f1 * 0.017453292F); - float f7 = f4 * f5; - float f8 = f3 * f5; - double d3 = range; - Vec3 vec31 = vec3.addVector(f7 * d3, f6 * d3, f8 * d3); - return world.rayTraceBlocks(vec3, vec31, par3); - } + public static Material[] materialsPick = new Material[]{ Material.rock, Material.iron, Material.ice, Material.glass, Material.piston, Material.anvil }; + public static Material[] materialsShovel = new Material[]{ Material.grass, Material.ground, Material.sand, Material.snow, Material.craftedSnow, Material.clay }; + public static Material[] materialsAxe = new Material[]{ Material.coral, Material.leaves, Material.plants, Material.wood, Material.gourd }; + + public static void damageItem(ItemStack stack, int dmg, EntityLivingBase entity, int manaPerDamage) { + int manaToRequest = dmg * manaPerDamage; + boolean manaRequested = entity instanceof EntityPlayer ? ManaItemHandler.requestManaExactForTool(stack, (EntityPlayer) entity, manaToRequest, true) : false; + + if(!manaRequested) + stack.damageItem(dmg, entity); + } + + public static void removeBlocksInIteration(EntityPlayer player, ItemStack stack, World world, int x, int y, int z, int xs, int ys, int zs, int xe, int ye, int ze, Block block, Material[] materialsListing, boolean silk, int fortune, boolean dispose) { + float blockHardness = block == null ? 1F : block.getBlockHardness(world, x, y, z); + + for(int x1 = xs; x1 < xe; x1++) + for(int y1 = ys; y1 < ye; y1++) + for(int z1 = zs; z1 < ze; z1++) + removeBlockWithDrops(player, stack, world, x1 + x, y1 + y, z1 + z, x, y, z, block, materialsListing, silk, fortune, blockHardness, dispose); + } + + public static boolean isRightMaterial(Material material, Material[] materialsListing) { + for(Material mat : materialsListing) + if(material == mat) + return true; + + return false; + } + + public static void removeBlockWithDrops(EntityPlayer player, ItemStack stack, World world, int x, int y, int z, int bx, int by, int bz, Block block, Material[] materialsListing, boolean silk, int fortune, float blockHardness, boolean dispose) { + removeBlockWithDrops(player, stack, world, x, y, z, bx, by, bz, block, materialsListing, silk, fortune, blockHardness, dispose, true); + } + + public static void removeBlockWithDrops(EntityPlayer player, ItemStack stack, World world, int x, int y, int z, int bx, int by, int bz, Block block, Material[] materialsListing, boolean silk, int fortune, float blockHardness, boolean dispose, boolean particles) { + if(!world.blockExists(x, y, z)) + return; + + Block blk = world.getBlock(x, y, z); + int meta = world.getBlockMetadata(x, y, z); + + if(block != null && blk != block) + return; + + Material mat = world.getBlock(x, y, z).getMaterial(); + if(!world.isRemote && blk != null && !blk.isAir(world, x, y, z) && blk.getPlayerRelativeBlockHardness(player, world, x, y, z) > 0) { + if(!blk.canHarvestBlock(player, meta) || !isRightMaterial(mat, materialsListing)) + return; + + if(!player.capabilities.isCreativeMode) { + int localMeta = world.getBlockMetadata(x, y, z); + blk.onBlockHarvested(world, x, y, z, localMeta, player); + + if(blk.removedByPlayer(world, player, x, y, z, true)) { + blk.onBlockDestroyedByPlayer(world, x, y, z, localMeta); + + if(!dispose || !ItemElementiumPick.isDisposable(blk)) + blk.harvestBlock(world, player, x, y, z, localMeta); + } + + damageItem(stack, 1, player, 80); + } else world.setBlockToAir(x, y, z); + + if(particles && !world.isRemote && ConfigHandler.blockBreakParticles && ConfigHandler.blockBreakParticlesTool) + world.playAuxSFX(2001, x, y, z, Block.getIdFromBlock(blk) + (meta << 12)); + } + } + + public static int getToolPriority(ItemStack stack) { + if(stack == null) + return 0; + + Item item = stack.getItem(); + if(!(item instanceof ItemTool)) + return 0; + + ItemTool tool = (ItemTool) item; + ToolMaterial material = tool.func_150913_i(); + int materialLevel = 0; + if(material == BotaniaAPI.manasteelToolMaterial) + materialLevel = 10; + if(material == BotaniaAPI.elementiumToolMaterial) + materialLevel = 11; + if(material == BotaniaAPI.terrasteelToolMaterial) + materialLevel = 20; + + int modifier = 0; + if(item == ModItems.terraPick) + modifier = ItemTerraPick.getLevel(stack); + + int efficiency = EnchantmentHelper.getEnchantmentLevel(Enchantment.efficiency.effectId, stack); + return materialLevel * 100 + modifier * 10 + efficiency; + } + + /** + * @author mDiyo + */ + public static MovingObjectPosition raytraceFromEntity(World world, Entity player, boolean par3, double range) { + float f = 1.0F; + float f1 = player.prevRotationPitch + (player.rotationPitch - player.prevRotationPitch) * f; + float f2 = player.prevRotationYaw + (player.rotationYaw - player.prevRotationYaw) * f; + double d0 = player.prevPosX + (player.posX - player.prevPosX) * f; + double d1 = player.prevPosY + (player.posY - player.prevPosY) * f; + if (!world.isRemote && player instanceof EntityPlayer) + d1 += ((EntityPlayer) player).eyeHeight; + double d2 = player.prevPosZ + (player.posZ - player.prevPosZ) * f; + Vec3 vec3 = Vec3.createVectorHelper(d0, d1, d2); + float f3 = MathHelper.cos(-f2 * 0.017453292F - (float) Math.PI); + float f4 = MathHelper.sin(-f2 * 0.017453292F - (float) Math.PI); + float f5 = -MathHelper.cos(-f1 * 0.017453292F); + float f6 = MathHelper.sin(-f1 * 0.017453292F); + float f7 = f4 * f5; + float f8 = f3 * f5; + double d3 = range; + Vec3 vec31 = vec3.addVector(f7 * d3, f6 * d3, f8 * d3); + return world.rayTraceBlocks(vec3, vec31, par3); + } + } diff --git a/src/main/java/vazkii/botania/common/item/equipment/tool/bow/ItemCrystalBow.java b/src/main/java/vazkii/botania/common/item/equipment/tool/bow/ItemCrystalBow.java index 28bdaa0a6f..541b15fd49 100644 --- a/src/main/java/vazkii/botania/common/item/equipment/tool/bow/ItemCrystalBow.java +++ b/src/main/java/vazkii/botania/common/item/equipment/tool/bow/ItemCrystalBow.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Feb 21, 2015, 6:33:40 PM (GMT)] */ package vazkii.botania.common.item.equipment.tool.bow; @@ -21,37 +21,32 @@ public class ItemCrystalBow extends ItemLivingwoodBow { - private final int ARROW_COST = 200; - - public ItemCrystalBow() { - super(LibItemNames.CRYSTAL_BOW); - } - - @Override - float chargeVelocityMultiplier() { - return 2F; - } - - @Override - boolean postsEvent() { - return false; - } - - @Override - boolean canFire(ItemStack p_77615_1_, World p_77615_2_, EntityPlayer p_77615_3_, int p_77615_4_) { - int infinity = EnchantmentHelper.getEnchantmentLevel(Enchantment.infinity.effectId, p_77615_1_); - return ManaItemHandler.requestManaExactForTool(p_77615_1_, p_77615_3_, ARROW_COST / (infinity + 1), false); - } - - @Override - void onFire( - ItemStack p_77615_1_, - World p_77615_2_, - EntityPlayer p_77615_3_, - int p_77615_4_, - boolean infinity, - EntityArrow arrow) { - arrow.canBePickedUp = 2; - ManaItemHandler.requestManaExactForTool(p_77615_1_, p_77615_3_, ARROW_COST / (infinity ? 2 : 1), false); - } + private final int ARROW_COST = 200; + + public ItemCrystalBow() { + super(LibItemNames.CRYSTAL_BOW); + } + + @Override + float chargeVelocityMultiplier() { + return 2F; + } + + @Override + boolean postsEvent() { + return false; + } + + @Override + boolean canFire(ItemStack p_77615_1_, World p_77615_2_, EntityPlayer p_77615_3_, int p_77615_4_) { + int infinity = EnchantmentHelper.getEnchantmentLevel(Enchantment.infinity.effectId, p_77615_1_); + return ManaItemHandler.requestManaExactForTool(p_77615_1_, p_77615_3_, ARROW_COST / (infinity + 1), false); + } + + @Override + void onFire(ItemStack p_77615_1_, World p_77615_2_, EntityPlayer p_77615_3_, int p_77615_4_, boolean infinity, EntityArrow arrow) { + arrow.canBePickedUp = 2; + ManaItemHandler.requestManaExactForTool(p_77615_1_, p_77615_3_, ARROW_COST / (infinity ? 2 : 1), false); + } + } diff --git a/src/main/java/vazkii/botania/common/item/equipment/tool/bow/ItemLivingwoodBow.java b/src/main/java/vazkii/botania/common/item/equipment/tool/bow/ItemLivingwoodBow.java index c830135ffc..c5ea853b9b 100644 --- a/src/main/java/vazkii/botania/common/item/equipment/tool/bow/ItemLivingwoodBow.java +++ b/src/main/java/vazkii/botania/common/item/equipment/tool/bow/ItemLivingwoodBow.java @@ -2,17 +2,14 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Feb 21, 2015, 4:58:45 PM (GMT)] */ package vazkii.botania.common.item.equipment.tool.bow; -import cpw.mods.fml.common.registry.GameRegistry; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.enchantment.Enchantment; import net.minecraft.enchantment.EnchantmentHelper; @@ -36,160 +33,163 @@ import vazkii.botania.common.item.ModItems; import vazkii.botania.common.item.equipment.tool.ToolCommons; import vazkii.botania.common.lib.LibItemNames; +import cpw.mods.fml.common.registry.GameRegistry; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; public class ItemLivingwoodBow extends ItemBow implements IManaUsingItem { - public static final int MANA_PER_DAMAGE = 40; - IIcon[] pullIcons = new IIcon[3]; + public static final int MANA_PER_DAMAGE = 40; + IIcon[] pullIcons = new IIcon[3]; + + public ItemLivingwoodBow() { + this(LibItemNames.LIVINGWOOD_BOW); + } + + public ItemLivingwoodBow(String name) { + super(); + setCreativeTab(BotaniaCreativeTab.INSTANCE); + setUnlocalizedName(name); + setMaxDamage(500); + setFull3D(); + } + + @Override + public Item setUnlocalizedName(String par1Str) { + GameRegistry.registerItem(this, par1Str); + return super.setUnlocalizedName(par1Str); + } + + @Override + public String getUnlocalizedNameInefficiently(ItemStack par1ItemStack) { + return super.getUnlocalizedNameInefficiently(par1ItemStack).replaceAll("item.", "item." + LibResources.PREFIX_MOD); + } + + @Override + public ItemStack onItemRightClick(ItemStack p_77659_1_, World p_77659_2_, EntityPlayer p_77659_3_) { + ArrowNockEvent event = new ArrowNockEvent(p_77659_3_, p_77659_1_); + MinecraftForge.EVENT_BUS.post(event); + if(event.isCanceled()) + return event.result; + + if(canFire(p_77659_1_, p_77659_2_, p_77659_3_, 0)) + p_77659_3_.setItemInUse(p_77659_1_, getMaxItemUseDuration(p_77659_1_)); + + return p_77659_1_; + } + + @Override + public void onPlayerStoppedUsing(ItemStack p_77615_1_, World p_77615_2_, EntityPlayer p_77615_3_, int p_77615_4_) { + int j = (int) ((getMaxItemUseDuration(p_77615_1_) - p_77615_4_) * chargeVelocityMultiplier()); + + ArrowLooseEvent event = new ArrowLooseEvent(p_77615_3_, p_77615_1_, j); + MinecraftForge.EVENT_BUS.post(event); + if(event.isCanceled()) + return; + j = event.charge; + + boolean flag = canFire(p_77615_1_, p_77615_2_, p_77615_3_, p_77615_4_); + boolean infinity = EnchantmentHelper.getEnchantmentLevel(Enchantment.infinity.effectId, p_77615_1_) > 0; + + if(flag) { + float f = j / 20.0F; + f = (f * f + f * 2.0F) / 3.0F; + + if(f < 0.1D) + return; + + if(f > 1.0F) + f = 1.0F; + + EntityArrow entityarrow = makeArrow(p_77615_1_, p_77615_2_, p_77615_3_, p_77615_4_, f); + + if(f == 1.0F) + entityarrow.setIsCritical(true); + + int k = EnchantmentHelper.getEnchantmentLevel(Enchantment.power.effectId, p_77615_1_); + + if(k > 0) + entityarrow.setDamage(entityarrow.getDamage() + k * 0.5D + 0.5D); + + int l = EnchantmentHelper.getEnchantmentLevel(Enchantment.punch.effectId, p_77615_1_); + + if(l > 0) + entityarrow.setKnockbackStrength(l); + + if(EnchantmentHelper.getEnchantmentLevel(Enchantment.flame.effectId, p_77615_1_) > 0) + entityarrow.setFire(100); + + ToolCommons.damageItem(p_77615_1_, 1, p_77615_3_, MANA_PER_DAMAGE); + p_77615_2_.playSoundAtEntity(p_77615_3_, "random.bow", 1.0F, 1.0F / (itemRand.nextFloat() * 0.4F + 1.2F) + f * 0.5F); + + onFire(p_77615_1_, p_77615_2_, p_77615_3_, p_77615_4_, infinity, entityarrow); + + if(!p_77615_2_.isRemote) + p_77615_2_.spawnEntityInWorld(entityarrow); + } + } + + float chargeVelocityMultiplier() { + return 1F; + } - public ItemLivingwoodBow() { - this(LibItemNames.LIVINGWOOD_BOW); - } + boolean postsEvent() { + return true; + } - public ItemLivingwoodBow(String name) { - super(); - setCreativeTab(BotaniaCreativeTab.INSTANCE); - setUnlocalizedName(name); - setMaxDamage(500); - setFull3D(); - } + EntityArrow makeArrow(ItemStack p_77615_1_, World p_77615_2_, EntityPlayer p_77615_3_, int p_77615_4_, float f) { + return new EntityArrow(p_77615_2_, p_77615_3_, f * 2.0F); + } + + boolean canFire(ItemStack p_77615_1_, World p_77615_2_, EntityPlayer p_77615_3_, int p_77615_4_) { + return p_77615_3_.capabilities.isCreativeMode || EnchantmentHelper.getEnchantmentLevel(Enchantment.infinity.effectId, p_77615_1_) > 0 || p_77615_3_.inventory.hasItem(Items.arrow); + } + + void onFire(ItemStack p_77615_1_, World p_77615_2_, EntityPlayer p_77615_3_, int p_77615_4_, boolean infinity, EntityArrow arrow) { + if(infinity) + arrow.canBePickedUp = 2; + else p_77615_3_.inventory.consumeInventoryItem(Items.arrow); + } - @Override - public Item setUnlocalizedName(String par1Str) { - GameRegistry.registerItem(this, par1Str); - return super.setUnlocalizedName(par1Str); - } + @Override + @SideOnly(Side.CLIENT) + public void registerIcons(IIconRegister par1IconRegister) { + itemIcon = IconHelper.forItem(par1IconRegister, this, 0); + for(int i = 0; i < 3; i++) + pullIcons[i] = IconHelper.forItem(par1IconRegister, this, i + 1); + } - @Override - public String getUnlocalizedNameInefficiently(ItemStack par1ItemStack) { - return super.getUnlocalizedNameInefficiently(par1ItemStack) - .replaceAll("item.", "item." + LibResources.PREFIX_MOD); - } - - @Override - public ItemStack onItemRightClick(ItemStack p_77659_1_, World p_77659_2_, EntityPlayer p_77659_3_) { - ArrowNockEvent event = new ArrowNockEvent(p_77659_3_, p_77659_1_); - MinecraftForge.EVENT_BUS.post(event); - if (event.isCanceled()) return event.result; - - if (canFire(p_77659_1_, p_77659_2_, p_77659_3_, 0)) - p_77659_3_.setItemInUse(p_77659_1_, getMaxItemUseDuration(p_77659_1_)); - - return p_77659_1_; - } - - @Override - public void onPlayerStoppedUsing(ItemStack p_77615_1_, World p_77615_2_, EntityPlayer p_77615_3_, int p_77615_4_) { - int j = (int) ((getMaxItemUseDuration(p_77615_1_) - p_77615_4_) * chargeVelocityMultiplier()); - - ArrowLooseEvent event = new ArrowLooseEvent(p_77615_3_, p_77615_1_, j); - MinecraftForge.EVENT_BUS.post(event); - if (event.isCanceled()) return; - j = event.charge; - - boolean flag = canFire(p_77615_1_, p_77615_2_, p_77615_3_, p_77615_4_); - boolean infinity = EnchantmentHelper.getEnchantmentLevel(Enchantment.infinity.effectId, p_77615_1_) > 0; - - if (flag) { - float f = j / 20.0F; - f = (f * f + f * 2.0F) / 3.0F; - - if (f < 0.1D) return; - - if (f > 1.0F) f = 1.0F; - - EntityArrow entityarrow = makeArrow(p_77615_1_, p_77615_2_, p_77615_3_, p_77615_4_, f); - - if (f == 1.0F) entityarrow.setIsCritical(true); - - int k = EnchantmentHelper.getEnchantmentLevel(Enchantment.power.effectId, p_77615_1_); - - if (k > 0) entityarrow.setDamage(entityarrow.getDamage() + k * 0.5D + 0.5D); - - int l = EnchantmentHelper.getEnchantmentLevel(Enchantment.punch.effectId, p_77615_1_); - - if (l > 0) entityarrow.setKnockbackStrength(l); - - if (EnchantmentHelper.getEnchantmentLevel(Enchantment.flame.effectId, p_77615_1_) > 0) - entityarrow.setFire(100); - - ToolCommons.damageItem(p_77615_1_, 1, p_77615_3_, MANA_PER_DAMAGE); - p_77615_2_.playSoundAtEntity( - p_77615_3_, "random.bow", 1.0F, 1.0F / (itemRand.nextFloat() * 0.4F + 1.2F) + f * 0.5F); - - onFire(p_77615_1_, p_77615_2_, p_77615_3_, p_77615_4_, infinity, entityarrow); - - if (!p_77615_2_.isRemote) p_77615_2_.spawnEntityInWorld(entityarrow); - } - } - - float chargeVelocityMultiplier() { - return 1F; - } - - boolean postsEvent() { - return true; - } - - EntityArrow makeArrow(ItemStack p_77615_1_, World p_77615_2_, EntityPlayer p_77615_3_, int p_77615_4_, float f) { - return new EntityArrow(p_77615_2_, p_77615_3_, f * 2.0F); - } - - boolean canFire(ItemStack p_77615_1_, World p_77615_2_, EntityPlayer p_77615_3_, int p_77615_4_) { - return p_77615_3_.capabilities.isCreativeMode - || EnchantmentHelper.getEnchantmentLevel(Enchantment.infinity.effectId, p_77615_1_) > 0 - || p_77615_3_.inventory.hasItem(Items.arrow); - } - - void onFire( - ItemStack p_77615_1_, - World p_77615_2_, - EntityPlayer p_77615_3_, - int p_77615_4_, - boolean infinity, - EntityArrow arrow) { - if (infinity) arrow.canBePickedUp = 2; - else p_77615_3_.inventory.consumeInventoryItem(Items.arrow); - } - - @Override - @SideOnly(Side.CLIENT) - public void registerIcons(IIconRegister par1IconRegister) { - itemIcon = IconHelper.forItem(par1IconRegister, this, 0); - for (int i = 0; i < 3; i++) pullIcons[i] = IconHelper.forItem(par1IconRegister, this, i + 1); - } + @Override + public void onUpdate(ItemStack stack, World world, Entity player, int par4, boolean par5) { + if(!world.isRemote && player instanceof EntityPlayer && stack.getItemDamage() > 0 && ManaItemHandler.requestManaExactForTool(stack, (EntityPlayer) player, MANA_PER_DAMAGE * 2, true)) + stack.setItemDamage(stack.getItemDamage() - 1); + } - @Override - public void onUpdate(ItemStack stack, World world, Entity player, int par4, boolean par5) { - if (!world.isRemote - && player instanceof EntityPlayer - && stack.getItemDamage() > 0 - && ManaItemHandler.requestManaExactForTool(stack, (EntityPlayer) player, MANA_PER_DAMAGE * 2, true)) - stack.setItemDamage(stack.getItemDamage() - 1); - } + @Override + public boolean getIsRepairable(ItemStack par1ItemStack, ItemStack par2ItemStack) { + return par2ItemStack.getItem() == ModItems.manaResource && par2ItemStack.getItemDamage() == 3 ? true : super.getIsRepairable(par1ItemStack, par2ItemStack); + } - @Override - public boolean getIsRepairable(ItemStack par1ItemStack, ItemStack par2ItemStack) { - return par2ItemStack.getItem() == ModItems.manaResource && par2ItemStack.getItemDamage() == 3 - ? true - : super.getIsRepairable(par1ItemStack, par2ItemStack); - } + @Override + public boolean usesMana(ItemStack stack) { + return true; + } - @Override - public boolean usesMana(ItemStack stack) { - return true; - } + @Override + public IIcon getIcon(ItemStack stack, int renderPass, EntityPlayer player, ItemStack usingItem, int useRemaining) { + if(stack != usingItem) + return itemIcon; - @Override - public IIcon getIcon(ItemStack stack, int renderPass, EntityPlayer player, ItemStack usingItem, int useRemaining) { - if (stack != usingItem) return itemIcon; + int j = (int) ((getMaxItemUseDuration(stack) - useRemaining) * chargeVelocityMultiplier()); - int j = (int) ((getMaxItemUseDuration(stack) - useRemaining) * chargeVelocityMultiplier()); + if(j >= 18) + return pullIcons[2]; + if(j > 13) + return pullIcons[1]; + if(j > 0) + return pullIcons[0]; - if (j >= 18) return pullIcons[2]; - if (j > 13) return pullIcons[1]; - if (j > 0) return pullIcons[0]; + return itemIcon; + } - return itemIcon; - } } diff --git a/src/main/java/vazkii/botania/common/item/equipment/tool/elementium/ItemElementiumAxe.java b/src/main/java/vazkii/botania/common/item/equipment/tool/elementium/ItemElementiumAxe.java index 129de75f1d..0357892a39 100644 --- a/src/main/java/vazkii/botania/common/item/equipment/tool/elementium/ItemElementiumAxe.java +++ b/src/main/java/vazkii/botania/common/item/equipment/tool/elementium/ItemElementiumAxe.java @@ -1,7 +1,7 @@ package vazkii.botania.common.item.equipment.tool.elementium; -import cpw.mods.fml.common.eventhandler.SubscribeEvent; import java.util.Random; + import net.minecraft.enchantment.Enchantment; import net.minecraft.enchantment.EnchantmentHelper; import net.minecraft.entity.item.EntityItem; @@ -20,53 +20,46 @@ import vazkii.botania.common.item.ModItems; import vazkii.botania.common.item.equipment.tool.manasteel.ItemManasteelAxe; import vazkii.botania.common.lib.LibItemNames; +import cpw.mods.fml.common.eventhandler.SubscribeEvent; public class ItemElementiumAxe extends ItemManasteelAxe { - public ItemElementiumAxe() { - super(BotaniaAPI.elementiumToolMaterial, LibItemNames.ELEMENTIUM_AXE); - MinecraftForge.EVENT_BUS.register(this); - } + public ItemElementiumAxe() { + super(BotaniaAPI.elementiumToolMaterial, LibItemNames.ELEMENTIUM_AXE); + MinecraftForge.EVENT_BUS.register(this); + } + + // Thanks to SpitefulFox for the drop rates + // https://github.com/SpitefulFox/ForbiddenMagic/blob/master/src/com/spiteful/forbidden/FMEventHandler.java - // Thanks to SpitefulFox for the drop rates - // https://github.com/SpitefulFox/ForbiddenMagic/blob/master/src/com/spiteful/forbidden/FMEventHandler.java + @SubscribeEvent + public void onEntityDrops(LivingDropsEvent event) { + if(event.recentlyHit && event.source.getEntity() != null && event.source.getEntity() instanceof EntityPlayer) { + ItemStack weapon = ((EntityPlayer) event.source.getEntity()).getCurrentEquippedItem(); + if(weapon != null && weapon.getItem() == this) { + Random rand = event.entity.worldObj.rand; + int looting = EnchantmentHelper.getEnchantmentLevel(Enchantment.fortune.effectId, weapon); - @SubscribeEvent - public void onEntityDrops(LivingDropsEvent event) { - if (event.recentlyHit && event.source.getEntity() != null && event.source.getEntity() instanceof EntityPlayer) { - ItemStack weapon = ((EntityPlayer) event.source.getEntity()).getCurrentEquippedItem(); - if (weapon != null && weapon.getItem() == this) { - Random rand = event.entity.worldObj.rand; - int looting = EnchantmentHelper.getEnchantmentLevel(Enchantment.fortune.effectId, weapon); + if(event.entityLiving instanceof EntitySkeleton && rand.nextInt(26) <= 3 + looting) + addDrop(event, new ItemStack(Items.skull, 1, ((EntitySkeleton)event.entityLiving).getSkeletonType())); + else if(event.entityLiving instanceof EntityZombie && !(event.entityLiving instanceof EntityPigZombie) && rand.nextInt(26) <= 2 + 2 * looting) + addDrop(event, new ItemStack(Items.skull, 1, 2)); + else if(event.entityLiving instanceof EntityCreeper && rand.nextInt(26) <= 2 + 2 * looting) + addDrop(event, new ItemStack(Items.skull, 1, 4)); + else if(event.entityLiving instanceof EntityPlayer && rand.nextInt(11) <= 1 + looting) { + ItemStack stack = new ItemStack(Items.skull, 1, 3); + ItemNBTHelper.setString(stack, "SkullOwner", ((EntityPlayer)event.entityLiving).getCommandSenderName()); + addDrop(event, stack); + } else if(event.entityLiving instanceof EntityDoppleganger && rand.nextInt(13) < 1 + looting) + addDrop(event, new ItemStack(ModItems.gaiaHead)); + } + } + } - if (event.entityLiving instanceof EntitySkeleton && rand.nextInt(26) <= 3 + looting) - addDrop( - event, - new ItemStack(Items.skull, 1, ((EntitySkeleton) event.entityLiving).getSkeletonType())); - else if (event.entityLiving instanceof EntityZombie - && !(event.entityLiving instanceof EntityPigZombie) - && rand.nextInt(26) <= 2 + 2 * looting) addDrop(event, new ItemStack(Items.skull, 1, 2)); - else if (event.entityLiving instanceof EntityCreeper && rand.nextInt(26) <= 2 + 2 * looting) - addDrop(event, new ItemStack(Items.skull, 1, 4)); - else if (event.entityLiving instanceof EntityPlayer && rand.nextInt(11) <= 1 + looting) { - ItemStack stack = new ItemStack(Items.skull, 1, 3); - ItemNBTHelper.setString( - stack, "SkullOwner", ((EntityPlayer) event.entityLiving).getCommandSenderName()); - addDrop(event, stack); - } else if (event.entityLiving instanceof EntityDoppleganger && rand.nextInt(13) < 1 + looting) - addDrop(event, new ItemStack(ModItems.gaiaHead)); - } - } - } + private void addDrop(LivingDropsEvent event, ItemStack drop) { + EntityItem entityitem = new EntityItem(event.entityLiving.worldObj, event.entityLiving.posX, event.entityLiving.posY, event.entityLiving.posZ, drop); + entityitem.delayBeforeCanPickup = 10; + event.drops.add(entityitem); + } - private void addDrop(LivingDropsEvent event, ItemStack drop) { - EntityItem entityitem = new EntityItem( - event.entityLiving.worldObj, - event.entityLiving.posX, - event.entityLiving.posY, - event.entityLiving.posZ, - drop); - entityitem.delayBeforeCanPickup = 10; - event.drops.add(entityitem); - } } diff --git a/src/main/java/vazkii/botania/common/item/equipment/tool/elementium/ItemElementiumPick.java b/src/main/java/vazkii/botania/common/item/equipment/tool/elementium/ItemElementiumPick.java index ad0a54d88a..bead2f8fcc 100644 --- a/src/main/java/vazkii/botania/common/item/equipment/tool/elementium/ItemElementiumPick.java +++ b/src/main/java/vazkii/botania/common/item/equipment/tool/elementium/ItemElementiumPick.java @@ -1,6 +1,8 @@ package vazkii.botania.common.item.equipment.tool.elementium; -import cpw.mods.fml.common.eventhandler.SubscribeEvent; +import java.util.Arrays; +import java.util.List; + import net.minecraft.block.Block; import net.minecraft.item.ItemStack; import net.minecraftforge.common.MinecraftForge; @@ -11,48 +13,49 @@ import vazkii.botania.common.item.equipment.tool.manasteel.ItemManasteelPick; import vazkii.botania.common.item.equipment.tool.terrasteel.ItemTerraPick; import vazkii.botania.common.lib.LibItemNames; +import cpw.mods.fml.common.eventhandler.SubscribeEvent; public class ItemElementiumPick extends ItemManasteelPick { - public ItemElementiumPick() { - super(BotaniaAPI.elementiumToolMaterial, LibItemNames.ELEMENTIUM_PICK); - MinecraftForge.EVENT_BUS.register(this); - } - - @SubscribeEvent - public void onHarvestDrops(HarvestDropsEvent event) { - if (event.harvester != null) { - ItemStack stack = event.harvester.getCurrentEquippedItem(); - if (stack != null - && (stack.getItem() == this - || stack.getItem() == ModItems.terraPick && ItemTerraPick.isTipped(stack))) { - for (int i = 0; i < event.drops.size(); i++) { - ItemStack drop = event.drops.get(i); - if (drop != null) { - Block block = Block.getBlockFromItem(drop.getItem()); - if (block != null) { - if (isDisposable(block) || (isSemiDisposable(block) && !event.harvester.isSneaking())) - event.drops.remove(i); - } - } - } - } - } - } + public ItemElementiumPick() { + super(BotaniaAPI.elementiumToolMaterial, LibItemNames.ELEMENTIUM_PICK); + MinecraftForge.EVENT_BUS.register(this); + } - public static boolean isDisposable(Block block) { - for (int id : OreDictionary.getOreIDs(new ItemStack(block))) { - String name = OreDictionary.getOreName(id); - if (BotaniaAPI.disposableBlocks.contains(name)) return true; - } - return false; - } + @SubscribeEvent + public void onHarvestDrops(HarvestDropsEvent event) { + if(event.harvester != null) { + ItemStack stack = event.harvester.getCurrentEquippedItem(); + if(stack != null && (stack.getItem() == this || stack.getItem() == ModItems.terraPick && ItemTerraPick.isTipped(stack))) { + for(int i = 0; i < event.drops.size(); i++) { + ItemStack drop = event.drops.get(i); + if(drop != null) { + Block block = Block.getBlockFromItem(drop.getItem()); + if(block != null){ + if(isDisposable(block) || (isSemiDisposable(block) && !event.harvester.isSneaking())) + event.drops.remove(i); + } + } + } + } + } + } - public static boolean isSemiDisposable(Block block) { - for (int id : OreDictionary.getOreIDs(new ItemStack(block))) { - String name = OreDictionary.getOreName(id); - if (BotaniaAPI.semiDisposableBlocks.contains(name)) return true; - } - return false; - } + public static boolean isDisposable(Block block) { + for(int id : OreDictionary.getOreIDs(new ItemStack(block))) { + String name = OreDictionary.getOreName(id); + if(BotaniaAPI.disposableBlocks.contains(name)) + return true; + } + return false; + } + + public static boolean isSemiDisposable(Block block) { + for(int id : OreDictionary.getOreIDs(new ItemStack(block))) { + String name = OreDictionary.getOreName(id); + if(BotaniaAPI.semiDisposableBlocks.contains(name)) + return true; + } + return false; + } } diff --git a/src/main/java/vazkii/botania/common/item/equipment/tool/elementium/ItemElementiumShears.java b/src/main/java/vazkii/botania/common/item/equipment/tool/elementium/ItemElementiumShears.java index 117f6ddaa7..00d373f295 100644 --- a/src/main/java/vazkii/botania/common/item/equipment/tool/elementium/ItemElementiumShears.java +++ b/src/main/java/vazkii/botania/common/item/equipment/tool/elementium/ItemElementiumShears.java @@ -1,10 +1,9 @@ package vazkii.botania.common.item.equipment.tool.elementium; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; import java.util.ArrayList; import java.util.List; import java.util.Random; + import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.enchantment.Enchantment; import net.minecraft.enchantment.EnchantmentHelper; @@ -21,86 +20,73 @@ import vazkii.botania.common.item.equipment.tool.ToolCommons; import vazkii.botania.common.item.equipment.tool.manasteel.ItemManasteelShears; import vazkii.botania.common.lib.LibItemNames; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; public class ItemElementiumShears extends ItemManasteelShears { - IIcon dammitReddit; + IIcon dammitReddit; + + public ItemElementiumShears() { + super(LibItemNames.ELEMENTIUM_SHEARS); + } - public ItemElementiumShears() { - super(LibItemNames.ELEMENTIUM_SHEARS); - } + @Override + public EnumAction getItemUseAction(ItemStack par1ItemStack) { + return EnumAction.bow; + } - @Override - public EnumAction getItemUseAction(ItemStack par1ItemStack) { - return EnumAction.bow; - } + @Override + public int getMaxItemUseDuration(ItemStack par1ItemStack) { + return 72000; + } - @Override - public int getMaxItemUseDuration(ItemStack par1ItemStack) { - return 72000; - } + @Override + public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer) { + par3EntityPlayer.setItemInUse(par1ItemStack, getMaxItemUseDuration(par1ItemStack)); + return par1ItemStack; + } - @Override - public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer) { - par3EntityPlayer.setItemInUse(par1ItemStack, getMaxItemUseDuration(par1ItemStack)); - return par1ItemStack; - } + @Override + @SideOnly(Side.CLIENT) + public void registerIcons(IIconRegister par1IconRegister) { + super.registerIcons(par1IconRegister); + dammitReddit = IconHelper.forName(par1IconRegister, "dammitReddit"); + } - @Override - @SideOnly(Side.CLIENT) - public void registerIcons(IIconRegister par1IconRegister) { - super.registerIcons(par1IconRegister); - dammitReddit = IconHelper.forName(par1IconRegister, "dammitReddit"); - } + @Override + public IIcon getIconIndex(ItemStack par1ItemStack) { + return par1ItemStack.getDisplayName().equalsIgnoreCase("dammit reddit") ? dammitReddit : super.getIconIndex(par1ItemStack); + } - @Override - public IIcon getIconIndex(ItemStack par1ItemStack) { - return par1ItemStack.getDisplayName().equalsIgnoreCase("dammit reddit") - ? dammitReddit - : super.getIconIndex(par1ItemStack); - } + @Override + public void onUsingTick(ItemStack stack, EntityPlayer player, int count) { + if(player.worldObj.isRemote) + return; - @Override - public void onUsingTick(ItemStack stack, EntityPlayer player, int count) { - if (player.worldObj.isRemote) return; + if(count != getMaxItemUseDuration(stack) && count % 5 == 0) { + int range = 12; + List sheep = player.worldObj.getEntitiesWithinAABB(IShearable.class, AxisAlignedBB.getBoundingBox(player.posX - range, player.posY - range, player.posZ - range, player.posX + range, player.posY + range, player.posZ + range)); + if(sheep.size() > 0) { + for(IShearable target : sheep) { + Entity entity = (Entity) target; + if(target.isShearable(stack, entity.worldObj, (int)entity.posX, (int)entity.posY, (int)entity.posZ)) { + ArrayList drops = target.onSheared(stack, entity.worldObj, (int)entity.posX, (int)entity.posY, (int)entity.posZ, EnchantmentHelper.getEnchantmentLevel(Enchantment.fortune.effectId, stack)); - if (count != getMaxItemUseDuration(stack) && count % 5 == 0) { - int range = 12; - List sheep = player.worldObj.getEntitiesWithinAABB( - IShearable.class, - AxisAlignedBB.getBoundingBox( - player.posX - range, - player.posY - range, - player.posZ - range, - player.posX + range, - player.posY + range, - player.posZ + range)); - if (sheep.size() > 0) { - for (IShearable target : sheep) { - Entity entity = (Entity) target; - if (target.isShearable( - stack, entity.worldObj, (int) entity.posX, (int) entity.posY, (int) entity.posZ)) { - ArrayList drops = target.onSheared( - stack, - entity.worldObj, - (int) entity.posX, - (int) entity.posY, - (int) entity.posZ, - EnchantmentHelper.getEnchantmentLevel(Enchantment.fortune.effectId, stack)); + Random rand = new Random(); + for(ItemStack drop : drops) { + EntityItem ent = entity.entityDropItem(drop, 1.0F); + ent.motionY += rand.nextFloat() * 0.05F; + ent.motionX += (rand.nextFloat() - rand.nextFloat()) * 0.1F; + ent.motionZ += (rand.nextFloat() - rand.nextFloat()) * 0.1F; + } - Random rand = new Random(); - for (ItemStack drop : drops) { - EntityItem ent = entity.entityDropItem(drop, 1.0F); - ent.motionY += rand.nextFloat() * 0.05F; - ent.motionX += (rand.nextFloat() - rand.nextFloat()) * 0.1F; - ent.motionZ += (rand.nextFloat() - rand.nextFloat()) * 0.1F; - } + ToolCommons.damageItem(stack, 1, player, MANA_PER_DAMAGE); + break; + } + } + } + } + } - ToolCommons.damageItem(stack, 1, player, MANA_PER_DAMAGE); - break; - } - } - } - } - } } diff --git a/src/main/java/vazkii/botania/common/item/equipment/tool/elementium/ItemElementiumShovel.java b/src/main/java/vazkii/botania/common/item/equipment/tool/elementium/ItemElementiumShovel.java index eb6b1d2070..1c2ca7df05 100644 --- a/src/main/java/vazkii/botania/common/item/equipment/tool/elementium/ItemElementiumShovel.java +++ b/src/main/java/vazkii/botania/common/item/equipment/tool/elementium/ItemElementiumShovel.java @@ -16,32 +16,32 @@ public class ItemElementiumShovel extends ItemManasteelShovel { - public static Material[] materialsShovel = new Material[] { - Material.grass, Material.ground, Material.sand, Material.snow, Material.craftedSnow, Material.clay - }; - - public ItemElementiumShovel() { - super(BotaniaAPI.elementiumToolMaterial, LibItemNames.ELEMENTIUM_SHOVEL); - } - - @Override - public boolean onBlockStartBreak(ItemStack stack, int x, int y, int z, EntityPlayer player) { - World world = player.worldObj; - Material mat = world.getBlock(x, y, z).getMaterial(); - if (!ToolCommons.isRightMaterial(mat, materialsShovel)) return false; - - MovingObjectPosition block = ToolCommons.raytraceFromEntity(world, player, true, 10); - if (block == null) return false; - - ForgeDirection.getOrientation(block.sideHit); - int fortune = EnchantmentHelper.getFortuneModifier(player); - boolean silk = EnchantmentHelper.getSilkTouchModifier(player); - - Block blk = world.getBlock(x, y, z); - if (blk instanceof BlockFalling) - ToolCommons.removeBlocksInIteration( - player, stack, world, x, y, z, 0, -12, 0, 1, 12, 1, blk, materialsShovel, silk, fortune, false); - - return false; - } + public static Material[] materialsShovel = new Material[]{ Material.grass, Material.ground, Material.sand, Material.snow, Material.craftedSnow, Material.clay }; + + public ItemElementiumShovel() { + super(BotaniaAPI.elementiumToolMaterial, LibItemNames.ELEMENTIUM_SHOVEL); + } + + @Override + public boolean onBlockStartBreak(ItemStack stack, int x, int y, int z, EntityPlayer player) { + World world = player.worldObj; + Material mat = world.getBlock(x, y, z).getMaterial(); + if (!ToolCommons.isRightMaterial(mat, materialsShovel)) + return false; + + MovingObjectPosition block = ToolCommons.raytraceFromEntity(world, player, true, 10); + if (block == null) + return false; + + ForgeDirection.getOrientation(block.sideHit); + int fortune = EnchantmentHelper.getFortuneModifier(player); + boolean silk = EnchantmentHelper.getSilkTouchModifier(player); + + Block blk = world.getBlock(x, y, z); + if(blk instanceof BlockFalling) + ToolCommons.removeBlocksInIteration(player, stack, world, x, y, z, 0, -12, 0, 1, 12, 1, blk, materialsShovel, silk, fortune, false); + + return false; + } + } diff --git a/src/main/java/vazkii/botania/common/item/equipment/tool/elementium/ItemElementiumSword.java b/src/main/java/vazkii/botania/common/item/equipment/tool/elementium/ItemElementiumSword.java index 4fa8051250..6e089c34be 100644 --- a/src/main/java/vazkii/botania/common/item/equipment/tool/elementium/ItemElementiumSword.java +++ b/src/main/java/vazkii/botania/common/item/equipment/tool/elementium/ItemElementiumSword.java @@ -8,12 +8,13 @@ public class ItemElementiumSword extends ItemManasteelSword implements IPixieSpawner { - public ItemElementiumSword() { - super(BotaniaAPI.elementiumToolMaterial, LibItemNames.ELEMENTIUM_SWORD); - } + public ItemElementiumSword() { + super(BotaniaAPI.elementiumToolMaterial, LibItemNames.ELEMENTIUM_SWORD); + } + + @Override + public float getPixieChance(ItemStack stack) { + return 0.05F; + } - @Override - public float getPixieChance(ItemStack stack) { - return 0.05F; - } } diff --git a/src/main/java/vazkii/botania/common/item/equipment/tool/manasteel/ItemManasteelAxe.java b/src/main/java/vazkii/botania/common/item/equipment/tool/manasteel/ItemManasteelAxe.java index 725317e814..6d673dd6dd 100644 --- a/src/main/java/vazkii/botania/common/item/equipment/tool/manasteel/ItemManasteelAxe.java +++ b/src/main/java/vazkii/botania/common/item/equipment/tool/manasteel/ItemManasteelAxe.java @@ -2,18 +2,16 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Apr 13, 2014, 7:15:39 PM (GMT)] */ package vazkii.botania.common.item.equipment.tool.manasteel; -import cpw.mods.fml.common.registry.GameRegistry; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; import java.util.regex.Pattern; + import net.minecraft.block.Block; import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.entity.Entity; @@ -35,118 +33,103 @@ import vazkii.botania.common.item.ModItems; import vazkii.botania.common.item.equipment.tool.ToolCommons; import vazkii.botania.common.lib.LibItemNames; +import cpw.mods.fml.common.registry.GameRegistry; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; public class ItemManasteelAxe extends ItemAxe implements IManaUsingItem, ISortableTool { - private static final Pattern SAPLING_PATTERN = - Pattern.compile("(?:(?:(?:[A-Z-_.:]|^)sapling)|(?:(?:[a-z-_.:]|^)Sapling))(?:[A-Z-_.:]|$)"); - - private static final int MANA_PER_DAMAGE = 60; - - public ItemManasteelAxe() { - this(BotaniaAPI.manasteelToolMaterial, LibItemNames.MANASTEEL_AXE); - } - - public ItemManasteelAxe(ToolMaterial mat, String name) { - super(mat); - setCreativeTab(BotaniaCreativeTab.INSTANCE); - setUnlocalizedName(name); - } - - @Override - public Item setUnlocalizedName(String par1Str) { - GameRegistry.registerItem(this, par1Str); - return super.setUnlocalizedName(par1Str); - } - - @Override - public String getUnlocalizedNameInefficiently(ItemStack par1ItemStack) { - return super.getUnlocalizedNameInefficiently(par1ItemStack) - .replaceAll("item.", "item." + LibResources.PREFIX_MOD); - } - - @Override - @SideOnly(Side.CLIENT) - public void registerIcons(IIconRegister par1IconRegister) { - itemIcon = IconHelper.forItem(par1IconRegister, this); - } - - @Override - public boolean hitEntity( - ItemStack par1ItemStack, EntityLivingBase par2EntityLivingBase, EntityLivingBase par3EntityLivingBase) { - ToolCommons.damageItem(par1ItemStack, 1, par3EntityLivingBase, getManaPerDamage()); - return true; - } - - @Override - public boolean onBlockDestroyed( - ItemStack stack, World world, Block block, int x, int y, int z, EntityLivingBase entity) { - if (block.getBlockHardness(world, x, y, z) != 0F) ToolCommons.damageItem(stack, 1, entity, getManaPerDamage()); - - return true; - } - - public int getManaPerDamage() { - return MANA_PER_DAMAGE; - } - - @Override - public boolean onItemUse( - ItemStack stack, - EntityPlayer player, - World world, - int x, - int y, - int z, - int s, - float sx, - float sy, - float sz) { - for (int i = 0; i < player.inventory.getSizeInventory(); i++) { - ItemStack stackAt = player.inventory.getStackInSlot(i); - if (stackAt != null - && SAPLING_PATTERN - .matcher(stackAt.getItem().getUnlocalizedName()) - .find()) { - boolean did = stackAt.getItem().onItemUse(stackAt, player, world, x, y, z, s, sx, sy, sz); - if (stackAt.stackSize == 0) player.inventory.setInventorySlotContents(i, null); - - ItemsRemainingRenderHandler.set(player, new ItemStack(Blocks.sapling), SAPLING_PATTERN); - return did; - } - } - - return false; - } - - @Override - public void onUpdate(ItemStack stack, World world, Entity player, int par4, boolean par5) { - if (!world.isRemote - && player instanceof EntityPlayer - && stack.getItemDamage() > 0 - && ManaItemHandler.requestManaExactForTool(stack, (EntityPlayer) player, getManaPerDamage() * 2, true)) - stack.setItemDamage(stack.getItemDamage() - 1); - } - - @Override - public boolean getIsRepairable(ItemStack par1ItemStack, ItemStack par2ItemStack) { - return par2ItemStack.getItem() == ModItems.manaResource && par2ItemStack.getItemDamage() == 0 - ? true - : super.getIsRepairable(par1ItemStack, par2ItemStack); - } - - @Override - public boolean usesMana(ItemStack stack) { - return true; - } - - @Override - public ToolType getSortingType(ItemStack stack) { - return ToolType.AXE; - } - - @Override - public int getSortingPriority(ItemStack stack) { - return ToolCommons.getToolPriority(stack); - } -} + private static final Pattern SAPLING_PATTERN = Pattern.compile("(?:(?:(?:[A-Z-_.:]|^)sapling)|(?:(?:[a-z-_.:]|^)Sapling))(?:[A-Z-_.:]|$)"); + + private static final int MANA_PER_DAMAGE = 60; + + public ItemManasteelAxe() { + this(BotaniaAPI.manasteelToolMaterial, LibItemNames.MANASTEEL_AXE); + } + + public ItemManasteelAxe(ToolMaterial mat, String name) { + super(mat); + setCreativeTab(BotaniaCreativeTab.INSTANCE); + setUnlocalizedName(name); + } + + @Override + public Item setUnlocalizedName(String par1Str) { + GameRegistry.registerItem(this, par1Str); + return super.setUnlocalizedName(par1Str); + } + + @Override + public String getUnlocalizedNameInefficiently(ItemStack par1ItemStack) { + return super.getUnlocalizedNameInefficiently(par1ItemStack).replaceAll("item.", "item." + LibResources.PREFIX_MOD); + } + + @Override + @SideOnly(Side.CLIENT) + public void registerIcons(IIconRegister par1IconRegister) { + itemIcon = IconHelper.forItem(par1IconRegister, this); + } + + @Override + public boolean hitEntity(ItemStack par1ItemStack, EntityLivingBase par2EntityLivingBase, EntityLivingBase par3EntityLivingBase) { + ToolCommons.damageItem(par1ItemStack, 1, par3EntityLivingBase, getManaPerDamage()); + return true; + } + + @Override + public boolean onBlockDestroyed(ItemStack stack, World world, Block block, int x, int y, int z, EntityLivingBase entity) { + if (block.getBlockHardness(world, x, y, z) != 0F) + ToolCommons.damageItem(stack, 1, entity, getManaPerDamage()); + + return true; + } + + public int getManaPerDamage() { + return MANA_PER_DAMAGE; + } + + @Override + public boolean onItemUse(ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int s, float sx, float sy, float sz) { + for(int i = 0; i < player.inventory.getSizeInventory(); i++) { + ItemStack stackAt = player.inventory.getStackInSlot(i); + if(stackAt != null && SAPLING_PATTERN.matcher(stackAt.getItem().getUnlocalizedName()).find()) { + boolean did = stackAt.getItem().onItemUse(stackAt, player, world, x, y, z, s, sx, sy, sz); + if(stackAt.stackSize == 0) + player.inventory.setInventorySlotContents(i, null); + + ItemsRemainingRenderHandler.set(player, new ItemStack(Blocks.sapling), SAPLING_PATTERN); + return did; + } + } + + return false; + } + + + @Override + public void onUpdate(ItemStack stack, World world, Entity player, int par4, boolean par5) { + if(!world.isRemote && player instanceof EntityPlayer && stack.getItemDamage() > 0 && ManaItemHandler.requestManaExactForTool(stack, (EntityPlayer) player, getManaPerDamage() * 2, true)) + stack.setItemDamage(stack.getItemDamage() - 1); + } + + @Override + public boolean getIsRepairable(ItemStack par1ItemStack, ItemStack par2ItemStack) { + return par2ItemStack.getItem() == ModItems.manaResource && par2ItemStack.getItemDamage() == 0 ? true : super.getIsRepairable(par1ItemStack, par2ItemStack); + } + + @Override + public boolean usesMana(ItemStack stack) { + return true; + } + + @Override + public ToolType getSortingType(ItemStack stack) { + return ToolType.AXE; + } + + @Override + public int getSortingPriority(ItemStack stack) { + return ToolCommons.getToolPriority(stack); + } + +} \ No newline at end of file diff --git a/src/main/java/vazkii/botania/common/item/equipment/tool/manasteel/ItemManasteelPick.java b/src/main/java/vazkii/botania/common/item/equipment/tool/manasteel/ItemManasteelPick.java index 5d2f89409a..0682455c18 100644 --- a/src/main/java/vazkii/botania/common/item/equipment/tool/manasteel/ItemManasteelPick.java +++ b/src/main/java/vazkii/botania/common/item/equipment/tool/manasteel/ItemManasteelPick.java @@ -2,18 +2,16 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Apr 13, 2014, 7:05:58 PM (GMT)] */ package vazkii.botania.common.item.equipment.tool.manasteel; -import cpw.mods.fml.common.registry.GameRegistry; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; import java.util.regex.Pattern; + import net.minecraft.block.Block; import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.entity.Entity; @@ -35,118 +33,102 @@ import vazkii.botania.common.item.ModItems; import vazkii.botania.common.item.equipment.tool.ToolCommons; import vazkii.botania.common.lib.LibItemNames; +import cpw.mods.fml.common.registry.GameRegistry; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; public class ItemManasteelPick extends ItemPickaxe implements IManaUsingItem, ISortableTool { - private static final Pattern TORCH_PATTERN = - Pattern.compile("(?:(?:(?:[A-Z-_.:]|^)torch)|(?:(?:[a-z-_.:]|^)Torch))(?:[A-Z-_.:]|$)"); - - private static final int MANA_PER_DAMAGE = 60; - - public ItemManasteelPick() { - this(BotaniaAPI.manasteelToolMaterial, LibItemNames.MANASTEEL_PICK); - } - - public ItemManasteelPick(ToolMaterial mat, String name) { - super(mat); - setCreativeTab(BotaniaCreativeTab.INSTANCE); - setUnlocalizedName(name); - } - - @Override - public Item setUnlocalizedName(String par1Str) { - GameRegistry.registerItem(this, par1Str); - return super.setUnlocalizedName(par1Str); - } - - @Override - public String getUnlocalizedNameInefficiently(ItemStack par1ItemStack) { - return super.getUnlocalizedNameInefficiently(par1ItemStack) - .replaceAll("item.", "item." + LibResources.PREFIX_MOD); - } - - @Override - @SideOnly(Side.CLIENT) - public void registerIcons(IIconRegister par1IconRegister) { - itemIcon = IconHelper.forItem(par1IconRegister, this); - } - - @Override - public boolean hitEntity( - ItemStack par1ItemStack, EntityLivingBase par2EntityLivingBase, EntityLivingBase par3EntityLivingBase) { - ToolCommons.damageItem(par1ItemStack, 1, par3EntityLivingBase, getManaPerDmg()); - return true; - } - - @Override - public boolean onBlockDestroyed( - ItemStack stack, World world, Block block, int x, int y, int z, EntityLivingBase entity) { - if (block.getBlockHardness(world, x, y, z) != 0F) ToolCommons.damageItem(stack, 1, entity, getManaPerDmg()); - - return true; - } - - @Override - public boolean onItemUse( - ItemStack stack, - EntityPlayer player, - World world, - int x, - int y, - int z, - int s, - float sx, - float sy, - float sz) { - for (int i = 0; i < player.inventory.getSizeInventory(); i++) { - ItemStack stackAt = player.inventory.getStackInSlot(i); - if (stackAt != null - && TORCH_PATTERN - .matcher(stackAt.getItem().getUnlocalizedName()) - .find()) { - boolean did = stackAt.getItem().onItemUse(stackAt, player, world, x, y, z, s, sx, sy, sz); - if (stackAt.stackSize == 0) player.inventory.setInventorySlotContents(i, null); - - ItemsRemainingRenderHandler.set(player, new ItemStack(Blocks.torch), TORCH_PATTERN); - return did; - } - } - - return false; - } - - public int getManaPerDmg() { - return MANA_PER_DAMAGE; - } - - @Override - public void onUpdate(ItemStack stack, World world, Entity player, int par4, boolean par5) { - if (!world.isRemote - && player instanceof EntityPlayer - && stack.getItemDamage() > 0 - && ManaItemHandler.requestManaExactForTool(stack, (EntityPlayer) player, MANA_PER_DAMAGE * 2, true)) - stack.setItemDamage(stack.getItemDamage() - 1); - } - - @Override - public boolean getIsRepairable(ItemStack par1ItemStack, ItemStack par2ItemStack) { - return par2ItemStack.getItem() == ModItems.manaResource && par2ItemStack.getItemDamage() == 0 - ? true - : super.getIsRepairable(par1ItemStack, par2ItemStack); - } - - @Override - public boolean usesMana(ItemStack stack) { - return true; - } - - @Override - public ToolType getSortingType(ItemStack stack) { - return ToolType.PICK; - } - - @Override - public int getSortingPriority(ItemStack stack) { - return ToolCommons.getToolPriority(stack); - } + private static final Pattern TORCH_PATTERN = Pattern.compile("(?:(?:(?:[A-Z-_.:]|^)torch)|(?:(?:[a-z-_.:]|^)Torch))(?:[A-Z-_.:]|$)"); + + private static final int MANA_PER_DAMAGE = 60; + + public ItemManasteelPick() { + this(BotaniaAPI.manasteelToolMaterial, LibItemNames.MANASTEEL_PICK); + } + + public ItemManasteelPick(ToolMaterial mat, String name) { + super(mat); + setCreativeTab(BotaniaCreativeTab.INSTANCE); + setUnlocalizedName(name); + } + + @Override + public Item setUnlocalizedName(String par1Str) { + GameRegistry.registerItem(this, par1Str); + return super.setUnlocalizedName(par1Str); + } + + @Override + public String getUnlocalizedNameInefficiently(ItemStack par1ItemStack) { + return super.getUnlocalizedNameInefficiently(par1ItemStack).replaceAll("item.", "item." + LibResources.PREFIX_MOD); + } + + @Override + @SideOnly(Side.CLIENT) + public void registerIcons(IIconRegister par1IconRegister) { + itemIcon = IconHelper.forItem(par1IconRegister, this); + } + + @Override + public boolean hitEntity(ItemStack par1ItemStack, EntityLivingBase par2EntityLivingBase, EntityLivingBase par3EntityLivingBase) { + ToolCommons.damageItem(par1ItemStack, 1, par3EntityLivingBase, getManaPerDmg()); + return true; + } + + @Override + public boolean onBlockDestroyed(ItemStack stack, World world, Block block, int x, int y, int z, EntityLivingBase entity) { + if(block.getBlockHardness(world, x, y, z) != 0F) + ToolCommons.damageItem(stack, 1, entity, getManaPerDmg()); + + return true; + } + + @Override + public boolean onItemUse(ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int s, float sx, float sy, float sz) { + for(int i = 0; i < player.inventory.getSizeInventory(); i++) { + ItemStack stackAt = player.inventory.getStackInSlot(i); + if(stackAt != null && TORCH_PATTERN.matcher(stackAt.getItem().getUnlocalizedName()).find()) { + boolean did = stackAt.getItem().onItemUse(stackAt, player, world, x, y, z, s, sx, sy, sz); + if(stackAt.stackSize == 0) + player.inventory.setInventorySlotContents(i, null); + + ItemsRemainingRenderHandler.set(player, new ItemStack(Blocks.torch), TORCH_PATTERN); + return did; + } + } + + return false; + } + + public int getManaPerDmg() { + return MANA_PER_DAMAGE; + } + + @Override + public void onUpdate(ItemStack stack, World world, Entity player, int par4, boolean par5) { + if(!world.isRemote && player instanceof EntityPlayer && stack.getItemDamage() > 0 && ManaItemHandler.requestManaExactForTool(stack, (EntityPlayer) player, MANA_PER_DAMAGE * 2, true)) + stack.setItemDamage(stack.getItemDamage() - 1); + } + + @Override + public boolean getIsRepairable(ItemStack par1ItemStack, ItemStack par2ItemStack) { + return par2ItemStack.getItem() == ModItems.manaResource && par2ItemStack.getItemDamage() == 0 ? true : super.getIsRepairable(par1ItemStack, par2ItemStack); + } + + @Override + public boolean usesMana(ItemStack stack) { + return true; + } + + @Override + public ToolType getSortingType(ItemStack stack) { + return ToolType.PICK; + } + + @Override + public int getSortingPriority(ItemStack stack) { + return ToolCommons.getToolPriority(stack); + } + } diff --git a/src/main/java/vazkii/botania/common/item/equipment/tool/manasteel/ItemManasteelShears.java b/src/main/java/vazkii/botania/common/item/equipment/tool/manasteel/ItemManasteelShears.java index 150660c204..17a2c650eb 100644 --- a/src/main/java/vazkii/botania/common/item/equipment/tool/manasteel/ItemManasteelShears.java +++ b/src/main/java/vazkii/botania/common/item/equipment/tool/manasteel/ItemManasteelShears.java @@ -2,19 +2,17 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Apr 13, 2014, 7:28:35 PM (GMT)] */ package vazkii.botania.common.item.equipment.tool.manasteel; -import cpw.mods.fml.common.registry.GameRegistry; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; import java.util.ArrayList; import java.util.Random; + import net.minecraft.block.Block; import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.enchantment.Enchantment; @@ -37,125 +35,111 @@ import vazkii.botania.common.item.ModItems; import vazkii.botania.common.item.equipment.tool.ToolCommons; import vazkii.botania.common.lib.LibItemNames; +import cpw.mods.fml.common.registry.GameRegistry; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; public class ItemManasteelShears extends ItemShears implements IManaUsingItem { - public static final int MANA_PER_DAMAGE = 30; - - public ItemManasteelShears() { - this(LibItemNames.MANASTEEL_SHEARS); - } - - public ItemManasteelShears(String name) { - setCreativeTab(BotaniaCreativeTab.INSTANCE); - setUnlocalizedName(name); - } - - @Override - public Item setUnlocalizedName(String par1Str) { - GameRegistry.registerItem(this, par1Str); - return super.setUnlocalizedName(par1Str); - } - - @Override - public String getUnlocalizedNameInefficiently(ItemStack par1ItemStack) { - return super.getUnlocalizedNameInefficiently(par1ItemStack) - .replaceAll("item.", "item." + LibResources.PREFIX_MOD); - } - - @Override - @SideOnly(Side.CLIENT) - public void registerIcons(IIconRegister par1IconRegister) { - itemIcon = IconHelper.forItem(par1IconRegister, this); - } - - @Override - public boolean itemInteractionForEntity(ItemStack itemstack, EntityPlayer player, EntityLivingBase entity) { - if (entity.worldObj.isRemote) return false; - - if (entity instanceof IShearable) { - IShearable target = (IShearable) entity; - if (target.isShearable( - itemstack, entity.worldObj, (int) entity.posX, (int) entity.posY, (int) entity.posZ)) { - ArrayList drops = target.onSheared( - itemstack, - entity.worldObj, - (int) entity.posX, - (int) entity.posY, - (int) entity.posZ, - EnchantmentHelper.getEnchantmentLevel(Enchantment.fortune.effectId, itemstack)); - - Random rand = new Random(); - for (ItemStack stack : drops) { - EntityItem ent = entity.entityDropItem(stack, 1.0F); - ent.motionY += rand.nextFloat() * 0.05F; - ent.motionX += (rand.nextFloat() - rand.nextFloat()) * 0.1F; - ent.motionZ += (rand.nextFloat() - rand.nextFloat()) * 0.1F; - } - - ToolCommons.damageItem(itemstack, 1, player, MANA_PER_DAMAGE); - } - - return true; - } - - return false; - } - - @Override - public boolean onBlockStartBreak(ItemStack itemstack, int x, int y, int z, EntityPlayer player) { - if (player.worldObj.isRemote) return false; - - Block block = player.worldObj.getBlock(x, y, z); - if (block instanceof IShearable) { - IShearable target = (IShearable) block; - if (target.isShearable(itemstack, player.worldObj, x, y, z)) { - ArrayList drops = target.onSheared( - itemstack, - player.worldObj, - x, - y, - z, - EnchantmentHelper.getEnchantmentLevel(Enchantment.fortune.effectId, itemstack)); - Random rand = new Random(); - - for (ItemStack stack : drops) { - float f = 0.7F; - double d = rand.nextFloat() * f + (1D - f) * 0.5; - double d1 = rand.nextFloat() * f + (1D - f) * 0.5; - double d2 = rand.nextFloat() * f + (1D - f) * 0.5; - - EntityItem entityitem = new EntityItem(player.worldObj, x + d, y + d1, z + d2, stack); - entityitem.delayBeforeCanPickup = 10; - player.worldObj.spawnEntityInWorld(entityitem); - } - - ToolCommons.damageItem(itemstack, 1, player, MANA_PER_DAMAGE); - player.addStat(StatList.mineBlockStatArray[Block.getIdFromBlock(block)], 1); - } - } - - return false; - } - - @Override - public void onUpdate(ItemStack stack, World world, Entity player, int par4, boolean par5) { - if (!world.isRemote - && player instanceof EntityPlayer - && stack.getItemDamage() > 0 - && ManaItemHandler.requestManaExactForTool(stack, (EntityPlayer) player, MANA_PER_DAMAGE * 2, true)) - stack.setItemDamage(stack.getItemDamage() - 1); - } - - @Override - public boolean getIsRepairable(ItemStack par1ItemStack, ItemStack par2ItemStack) { - return par2ItemStack.getItem() == ModItems.manaResource && par2ItemStack.getItemDamage() == 0 - ? true - : super.getIsRepairable(par1ItemStack, par2ItemStack); - } - - @Override - public boolean usesMana(ItemStack stack) { - return true; - } + public static final int MANA_PER_DAMAGE = 30; + + public ItemManasteelShears() { + this(LibItemNames.MANASTEEL_SHEARS); + } + + public ItemManasteelShears(String name) { + setCreativeTab(BotaniaCreativeTab.INSTANCE); + setUnlocalizedName(name); + } + + @Override + public Item setUnlocalizedName(String par1Str) { + GameRegistry.registerItem(this, par1Str); + return super.setUnlocalizedName(par1Str); + } + + @Override + public String getUnlocalizedNameInefficiently(ItemStack par1ItemStack) { + return super.getUnlocalizedNameInefficiently(par1ItemStack).replaceAll("item.", "item." + LibResources.PREFIX_MOD); + } + + @Override + @SideOnly(Side.CLIENT) + public void registerIcons(IIconRegister par1IconRegister) { + itemIcon = IconHelper.forItem(par1IconRegister, this); + } + + @Override + public boolean itemInteractionForEntity(ItemStack itemstack, EntityPlayer player, EntityLivingBase entity) { + if(entity.worldObj.isRemote) + return false; + + if(entity instanceof IShearable) { + IShearable target = (IShearable)entity; + if(target.isShearable(itemstack, entity.worldObj, (int) entity.posX, (int) entity.posY, (int) entity.posZ)) { + ArrayList drops = target.onSheared(itemstack, entity.worldObj, (int) entity.posX, (int) entity.posY, (int) entity.posZ, EnchantmentHelper.getEnchantmentLevel(Enchantment.fortune.effectId, itemstack)); + + Random rand = new Random(); + for(ItemStack stack : drops) { + EntityItem ent = entity.entityDropItem(stack, 1.0F); + ent.motionY += rand.nextFloat() * 0.05F; + ent.motionX += (rand.nextFloat() - rand.nextFloat()) * 0.1F; + ent.motionZ += (rand.nextFloat() - rand.nextFloat()) * 0.1F; + } + + ToolCommons.damageItem(itemstack, 1, player, MANA_PER_DAMAGE); + } + + return true; + } + + return false; + } + + @Override + public boolean onBlockStartBreak(ItemStack itemstack, int x, int y, int z, EntityPlayer player) { + if (player.worldObj.isRemote) + return false; + + Block block = player.worldObj.getBlock(x, y, z); + if(block instanceof IShearable) { + IShearable target = (IShearable)block; + if(target.isShearable(itemstack, player.worldObj, x, y, z)) { + ArrayList drops = target.onSheared(itemstack, player.worldObj, x, y, z, EnchantmentHelper.getEnchantmentLevel(Enchantment.fortune.effectId, itemstack)); + Random rand = new Random(); + + for(ItemStack stack : drops) { + float f = 0.7F; + double d = rand.nextFloat() * f + (1D - f) * 0.5; + double d1 = rand.nextFloat() * f + (1D - f) * 0.5; + double d2 = rand.nextFloat() * f + (1D - f) * 0.5; + + EntityItem entityitem = new EntityItem(player.worldObj, x + d, y + d1, z + d2, stack); + entityitem.delayBeforeCanPickup = 10; + player.worldObj.spawnEntityInWorld(entityitem); + } + + ToolCommons.damageItem(itemstack, 1, player, MANA_PER_DAMAGE); + player.addStat(StatList.mineBlockStatArray[Block.getIdFromBlock(block)], 1); + } + } + + return false; + } + + @Override + public void onUpdate(ItemStack stack, World world, Entity player, int par4, boolean par5) { + if(!world.isRemote && player instanceof EntityPlayer && stack.getItemDamage() > 0 && ManaItemHandler.requestManaExactForTool(stack, (EntityPlayer) player, MANA_PER_DAMAGE * 2, true)) + stack.setItemDamage(stack.getItemDamage() - 1); + } + + @Override + public boolean getIsRepairable(ItemStack par1ItemStack, ItemStack par2ItemStack) { + return par2ItemStack.getItem() == ModItems.manaResource && par2ItemStack.getItemDamage() == 0 ? true : super.getIsRepairable(par1ItemStack, par2ItemStack); + } + + @Override + public boolean usesMana(ItemStack stack) { + return true; + } } diff --git a/src/main/java/vazkii/botania/common/item/equipment/tool/manasteel/ItemManasteelShovel.java b/src/main/java/vazkii/botania/common/item/equipment/tool/manasteel/ItemManasteelShovel.java index 8bfd5c1c97..985a84a573 100644 --- a/src/main/java/vazkii/botania/common/item/equipment/tool/manasteel/ItemManasteelShovel.java +++ b/src/main/java/vazkii/botania/common/item/equipment/tool/manasteel/ItemManasteelShovel.java @@ -2,18 +2,14 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Apr 13, 2014, 7:14:54 PM (GMT)] */ package vazkii.botania.common.item.equipment.tool.manasteel; -import cpw.mods.fml.common.eventhandler.Event.Result; -import cpw.mods.fml.common.registry.GameRegistry; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; import net.minecraft.block.Block; import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.entity.Entity; @@ -36,132 +32,113 @@ import vazkii.botania.common.item.ModItems; import vazkii.botania.common.item.equipment.tool.ToolCommons; import vazkii.botania.common.lib.LibItemNames; +import cpw.mods.fml.common.eventhandler.Event.Result; +import cpw.mods.fml.common.registry.GameRegistry; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; public class ItemManasteelShovel extends ItemSpade implements IManaUsingItem, ISortableTool { - private static final int MANA_PER_DAMAGE = 60; - - public ItemManasteelShovel() { - this(BotaniaAPI.manasteelToolMaterial, LibItemNames.MANASTEEL_SHOVEL); - } - - public ItemManasteelShovel(ToolMaterial mat, String name) { - super(mat); - setCreativeTab(BotaniaCreativeTab.INSTANCE); - setUnlocalizedName(name); - } - - @Override - public Item setUnlocalizedName(String par1Str) { - GameRegistry.registerItem(this, par1Str); - return super.setUnlocalizedName(par1Str); - } - - @Override - public String getUnlocalizedNameInefficiently(ItemStack par1ItemStack) { - return super.getUnlocalizedNameInefficiently(par1ItemStack) - .replaceAll("item.", "item." + LibResources.PREFIX_MOD); - } - - @Override - @SideOnly(Side.CLIENT) - public void registerIcons(IIconRegister par1IconRegister) { - itemIcon = IconHelper.forItem(par1IconRegister, this); - } - - @Override - public boolean hitEntity( - ItemStack par1ItemStack, EntityLivingBase par2EntityLivingBase, EntityLivingBase par3EntityLivingBase) { - ToolCommons.damageItem(par1ItemStack, 1, par3EntityLivingBase, MANA_PER_DAMAGE); - return true; - } - - @Override - public boolean onBlockDestroyed( - ItemStack stack, World world, Block block, int x, int y, int z, EntityLivingBase entity) { - if (block.getBlockHardness(world, x, y, z) != 0F) ToolCommons.damageItem(stack, 1, entity, MANA_PER_DAMAGE); - - return true; - } - - @Override - public boolean onItemUse( - ItemStack p_77648_1_, - EntityPlayer p_77648_2_, - World p_77648_3_, - int p_77648_4_, - int p_77648_5_, - int p_77648_6_, - int p_77648_7_, - float p_77648_8_, - float p_77648_9_, - float p_77648_10_) { - if (!p_77648_2_.canPlayerEdit(p_77648_4_, p_77648_5_, p_77648_6_, p_77648_7_, p_77648_1_)) return false; - else { - UseHoeEvent event = new UseHoeEvent(p_77648_2_, p_77648_1_, p_77648_3_, p_77648_4_, p_77648_5_, p_77648_6_); - if (MinecraftForge.EVENT_BUS.post(event)) return false; - - if (event.getResult() == Result.ALLOW) { - ToolCommons.damageItem(p_77648_1_, 1, p_77648_2_, MANA_PER_DAMAGE); - return true; - } - - Block block = p_77648_3_.getBlock(p_77648_4_, p_77648_5_, p_77648_6_); - - if (p_77648_7_ != 0 - && p_77648_3_ - .getBlock(p_77648_4_, p_77648_5_ + 1, p_77648_6_) - .isAir(p_77648_3_, p_77648_4_, p_77648_5_ + 1, p_77648_6_) - && (block == Blocks.grass || block == Blocks.dirt)) { - Block block1 = Blocks.farmland; - p_77648_3_.playSoundEffect( - p_77648_4_ + 0.5F, - p_77648_5_ + 0.5F, - p_77648_6_ + 0.5F, - block1.stepSound.getStepResourcePath(), - (block1.stepSound.getVolume() + 1.0F) / 2.0F, - block1.stepSound.getPitch() * 0.8F); - - if (p_77648_3_.isRemote) return true; - else { - p_77648_3_.setBlock(p_77648_4_, p_77648_5_, p_77648_6_, block1); - ToolCommons.damageItem(p_77648_1_, 1, p_77648_2_, MANA_PER_DAMAGE); - return true; - } - } - - return false; - } - } - - @Override - public void onUpdate(ItemStack stack, World world, Entity player, int par4, boolean par5) { - if (!world.isRemote - && player instanceof EntityPlayer - && stack.getItemDamage() > 0 - && ManaItemHandler.requestManaExactForTool(stack, (EntityPlayer) player, MANA_PER_DAMAGE * 2, true)) - stack.setItemDamage(stack.getItemDamage() - 1); - } - - @Override - public boolean getIsRepairable(ItemStack par1ItemStack, ItemStack par2ItemStack) { - return par2ItemStack.getItem() == ModItems.manaResource && par2ItemStack.getItemDamage() == 0 - ? true - : super.getIsRepairable(par1ItemStack, par2ItemStack); - } - - @Override - public boolean usesMana(ItemStack stack) { - return true; - } - - @Override - public ToolType getSortingType(ItemStack stack) { - return ToolType.SHOVEL; - } - - @Override - public int getSortingPriority(ItemStack stack) { - return ToolCommons.getToolPriority(stack); - } + private static final int MANA_PER_DAMAGE = 60; + + public ItemManasteelShovel() { + this(BotaniaAPI.manasteelToolMaterial, LibItemNames.MANASTEEL_SHOVEL); + } + + public ItemManasteelShovel(ToolMaterial mat, String name) { + super(mat); + setCreativeTab(BotaniaCreativeTab.INSTANCE); + setUnlocalizedName(name); + } + + @Override + public Item setUnlocalizedName(String par1Str) { + GameRegistry.registerItem(this, par1Str); + return super.setUnlocalizedName(par1Str); + } + + @Override + public String getUnlocalizedNameInefficiently(ItemStack par1ItemStack) { + return super.getUnlocalizedNameInefficiently(par1ItemStack).replaceAll("item.", "item." + LibResources.PREFIX_MOD); + } + + @Override + @SideOnly(Side.CLIENT) + public void registerIcons(IIconRegister par1IconRegister) { + itemIcon = IconHelper.forItem(par1IconRegister, this); + } + + @Override + public boolean hitEntity(ItemStack par1ItemStack, EntityLivingBase par2EntityLivingBase, EntityLivingBase par3EntityLivingBase) { + ToolCommons.damageItem(par1ItemStack, 1, par3EntityLivingBase, MANA_PER_DAMAGE); + return true; + } + + @Override + public boolean onBlockDestroyed(ItemStack stack, World world, Block block, int x, int y, int z, EntityLivingBase entity) { + if (block.getBlockHardness(world, x, y, z) != 0F) + ToolCommons.damageItem(stack, 1, entity, MANA_PER_DAMAGE); + + return true; + } + + @Override + public boolean onItemUse(ItemStack p_77648_1_, EntityPlayer p_77648_2_, World p_77648_3_, int p_77648_4_, int p_77648_5_, int p_77648_6_, int p_77648_7_, float p_77648_8_, float p_77648_9_, float p_77648_10_) { + if(!p_77648_2_.canPlayerEdit(p_77648_4_, p_77648_5_, p_77648_6_, p_77648_7_, p_77648_1_)) + return false; + else { + UseHoeEvent event = new UseHoeEvent(p_77648_2_, p_77648_1_, p_77648_3_, p_77648_4_, p_77648_5_, p_77648_6_); + if(MinecraftForge.EVENT_BUS.post(event)) + return false; + + if(event.getResult() == Result.ALLOW) { + ToolCommons.damageItem(p_77648_1_, 1, p_77648_2_, MANA_PER_DAMAGE); + return true; + } + + Block block = p_77648_3_.getBlock(p_77648_4_, p_77648_5_, p_77648_6_); + + if(p_77648_7_ != 0 && p_77648_3_.getBlock(p_77648_4_, p_77648_5_ + 1, p_77648_6_).isAir(p_77648_3_, p_77648_4_, p_77648_5_ + 1, p_77648_6_) && (block == Blocks.grass || block == Blocks.dirt)) { + Block block1 = Blocks.farmland; + p_77648_3_.playSoundEffect(p_77648_4_ + 0.5F, p_77648_5_ + 0.5F, p_77648_6_ + 0.5F, block1.stepSound.getStepResourcePath(), (block1.stepSound.getVolume() + 1.0F) / 2.0F, block1.stepSound.getPitch() * 0.8F); + + if (p_77648_3_.isRemote) + return true; + else { + p_77648_3_.setBlock(p_77648_4_, p_77648_5_, p_77648_6_, block1); + ToolCommons.damageItem(p_77648_1_, 1, p_77648_2_, MANA_PER_DAMAGE); + return true; + } + } + + return false; + } + } + + @Override + public void onUpdate(ItemStack stack, World world, Entity player, int par4, boolean par5) { + if(!world.isRemote && player instanceof EntityPlayer && stack.getItemDamage() > 0 && ManaItemHandler.requestManaExactForTool(stack, (EntityPlayer) player, MANA_PER_DAMAGE * 2, true)) + stack.setItemDamage(stack.getItemDamage() - 1); + } + + @Override + public boolean getIsRepairable(ItemStack par1ItemStack, ItemStack par2ItemStack) { + return par2ItemStack.getItem() == ModItems.manaResource && par2ItemStack.getItemDamage() == 0 ? true : super.getIsRepairable(par1ItemStack, par2ItemStack); + } + + @Override + public boolean usesMana(ItemStack stack) { + return true; + } + + @Override + public ToolType getSortingType(ItemStack stack) { + return ToolType.SHOVEL; + } + + @Override + public int getSortingPriority(ItemStack stack) { + return ToolCommons.getToolPriority(stack); + } + } diff --git a/src/main/java/vazkii/botania/common/item/equipment/tool/manasteel/ItemManasteelSword.java b/src/main/java/vazkii/botania/common/item/equipment/tool/manasteel/ItemManasteelSword.java index bf0e6ebf8a..dc7a7d2265 100644 --- a/src/main/java/vazkii/botania/common/item/equipment/tool/manasteel/ItemManasteelSword.java +++ b/src/main/java/vazkii/botania/common/item/equipment/tool/manasteel/ItemManasteelSword.java @@ -2,17 +2,14 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Apr 13, 2014, 7:21:32 PM (GMT)] */ package vazkii.botania.common.item.equipment.tool.manasteel; -import cpw.mods.fml.common.registry.GameRegistry; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; import net.minecraft.block.Block; import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.entity.Entity; @@ -32,91 +29,88 @@ import vazkii.botania.common.item.ModItems; import vazkii.botania.common.item.equipment.tool.ToolCommons; import vazkii.botania.common.lib.LibItemNames; +import cpw.mods.fml.common.registry.GameRegistry; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; public class ItemManasteelSword extends ItemSword implements IManaUsingItem { - public static final int MANA_PER_DAMAGE = 60; - - public static IIcon elucidatorIcon; - - public ItemManasteelSword() { - this(BotaniaAPI.manasteelToolMaterial, LibItemNames.MANASTEEL_SWORD); - } - - public ItemManasteelSword(ToolMaterial mat, String name) { - super(mat); - setCreativeTab(BotaniaCreativeTab.INSTANCE); - setUnlocalizedName(name); - } - - @Override - public Item setUnlocalizedName(String par1Str) { - GameRegistry.registerItem(this, par1Str); - return super.setUnlocalizedName(par1Str); - } - - @Override - public String getUnlocalizedNameInefficiently(ItemStack par1ItemStack) { - return super.getUnlocalizedNameInefficiently(par1ItemStack) - .replaceAll("item.", "item." + LibResources.PREFIX_MOD); - } - - @Override - @SideOnly(Side.CLIENT) - public void registerIcons(IIconRegister par1IconRegister) { - itemIcon = IconHelper.forItem(par1IconRegister, this); - elucidatorIcon = IconHelper.forName(par1IconRegister, "elucidator"); - } - - @Override - public boolean hitEntity( - ItemStack par1ItemStack, EntityLivingBase par2EntityLivingBase, EntityLivingBase par3EntityLivingBase) { - if (usesMana(par1ItemStack)) ToolCommons.damageItem(par1ItemStack, 1, par3EntityLivingBase, getManaPerDamage()); - return true; - } - - @Override - public IIcon getIconIndex(ItemStack par1ItemStack) { - String name = par1ItemStack.getDisplayName().toLowerCase().trim(); - return name.equals("the elucidator") ? elucidatorIcon : super.getIconIndex(par1ItemStack); - } - - @Override - public IIcon getIcon(ItemStack stack, int pass) { - return getIconIndex(stack); - } - - @Override - public boolean onBlockDestroyed( - ItemStack stack, World world, Block block, int x, int y, int z, EntityLivingBase entity) { - if (usesMana(stack) && block.getBlockHardness(world, x, y, z) != 0F) - ToolCommons.damageItem(stack, 1, entity, getManaPerDamage()); - - return true; - } - - @Override - public void onUpdate(ItemStack stack, World world, Entity player, int par4, boolean par5) { - if (!world.isRemote - && player instanceof EntityPlayer - && stack.getItemDamage() > 0 - && ManaItemHandler.requestManaExactForTool(stack, (EntityPlayer) player, getManaPerDamage() * 2, true)) - stack.setItemDamage(stack.getItemDamage() - 1); - } - - public int getManaPerDamage() { - return MANA_PER_DAMAGE; - } - - @Override - public boolean getIsRepairable(ItemStack par1ItemStack, ItemStack par2ItemStack) { - return par2ItemStack.getItem() == ModItems.manaResource && par2ItemStack.getItemDamage() == 0 - ? true - : super.getIsRepairable(par1ItemStack, par2ItemStack); - } - - @Override - public boolean usesMana(ItemStack stack) { - return true; - } + public static final int MANA_PER_DAMAGE = 60; + + public static IIcon elucidatorIcon; + + public ItemManasteelSword() { + this(BotaniaAPI.manasteelToolMaterial, LibItemNames.MANASTEEL_SWORD); + } + + public ItemManasteelSword(ToolMaterial mat, String name) { + super(mat); + setCreativeTab(BotaniaCreativeTab.INSTANCE); + setUnlocalizedName(name); + } + + @Override + public Item setUnlocalizedName(String par1Str) { + GameRegistry.registerItem(this, par1Str); + return super.setUnlocalizedName(par1Str); + } + + @Override + public String getUnlocalizedNameInefficiently(ItemStack par1ItemStack) { + return super.getUnlocalizedNameInefficiently(par1ItemStack).replaceAll("item.", "item." + LibResources.PREFIX_MOD); + } + + @Override + @SideOnly(Side.CLIENT) + public void registerIcons(IIconRegister par1IconRegister) { + itemIcon = IconHelper.forItem(par1IconRegister, this); + elucidatorIcon = IconHelper.forName(par1IconRegister, "elucidator"); + } + + @Override + public boolean hitEntity(ItemStack par1ItemStack, EntityLivingBase par2EntityLivingBase, EntityLivingBase par3EntityLivingBase) { + if(usesMana(par1ItemStack)) + ToolCommons.damageItem(par1ItemStack, 1, par3EntityLivingBase, getManaPerDamage()); + return true; + } + + @Override + public IIcon getIconIndex(ItemStack par1ItemStack) { + String name = par1ItemStack.getDisplayName().toLowerCase().trim(); + return name.equals("the elucidator") ? elucidatorIcon : super.getIconIndex(par1ItemStack); + } + + @Override + public IIcon getIcon(ItemStack stack, int pass) { + return getIconIndex(stack); + } + + @Override + public boolean onBlockDestroyed(ItemStack stack, World world, Block block, int x, int y, int z, EntityLivingBase entity) { + if(usesMana(stack) && block.getBlockHardness(world, x, y, z) != 0F) + ToolCommons.damageItem(stack, 1, entity, getManaPerDamage()); + + return true; + } + + @Override + public void onUpdate(ItemStack stack, World world, Entity player, int par4, boolean par5) { + if(!world.isRemote && player instanceof EntityPlayer && stack.getItemDamage() > 0 && ManaItemHandler.requestManaExactForTool(stack, (EntityPlayer) player, getManaPerDamage() * 2, true)) + stack.setItemDamage(stack.getItemDamage() - 1); + } + + public int getManaPerDamage() { + return MANA_PER_DAMAGE; + } + + @Override + public boolean getIsRepairable(ItemStack par1ItemStack, ItemStack par2ItemStack) { + return par2ItemStack.getItem() == ModItems.manaResource && par2ItemStack.getItemDamage() == 0 ? true : super.getIsRepairable(par1ItemStack, par2ItemStack); + } + + @Override + public boolean usesMana(ItemStack stack) { + return true; + } + } diff --git a/src/main/java/vazkii/botania/common/item/equipment/tool/terrasteel/ItemTerraAxe.java b/src/main/java/vazkii/botania/common/item/equipment/tool/terrasteel/ItemTerraAxe.java index 506031b07c..11ad6a5bf6 100644 --- a/src/main/java/vazkii/botania/common/item/equipment/tool/terrasteel/ItemTerraAxe.java +++ b/src/main/java/vazkii/botania/common/item/equipment/tool/terrasteel/ItemTerraAxe.java @@ -2,20 +2,14 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [May 15, 2015, 6:55:34 PM (GMT)] */ package vazkii.botania.common.item.equipment.tool.terrasteel; -import cpw.mods.fml.common.FMLCommonHandler; -import cpw.mods.fml.common.eventhandler.SubscribeEvent; -import cpw.mods.fml.common.gameevent.TickEvent; -import cpw.mods.fml.common.gameevent.TickEvent.Phase; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; import java.util.ArrayList; import java.util.HashMap; import java.util.HashSet; @@ -24,6 +18,7 @@ import java.util.Map; import java.util.PriorityQueue; import java.util.Set; + import net.minecraft.block.Block; import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.enchantment.Enchantment; @@ -42,385 +37,378 @@ import vazkii.botania.common.item.equipment.tool.manasteel.ItemManasteelAxe; import vazkii.botania.common.item.relic.ItemLokiRing; import vazkii.botania.common.lib.LibItemNames; +import cpw.mods.fml.common.FMLCommonHandler; +import cpw.mods.fml.common.eventhandler.SubscribeEvent; +import cpw.mods.fml.common.gameevent.TickEvent; +import cpw.mods.fml.common.gameevent.TickEvent.Phase; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; public class ItemTerraAxe extends ItemManasteelAxe implements ISequentialBreaker { + + + /** + * The number of blocks per tick which the Terra Truncator will + * collect. + */ + public static final int BLOCK_SWAP_RATE = 10; + + /** + * The maximum radius (in blocks) which the Terra Truncator will go + * in order to try and murder/cut down the tree. + */ + public static final int BLOCK_RANGE = 32; + + /** + * The maximum number of leaf blocks which the Terra Truncator will chew/go + * through once a leaf block is encountered. + */ + public static final int LEAF_BLOCK_RANGE = 3; + + /** + * The amount of mana required to restore 1 point of damage. + */ + private static final int MANA_PER_DAMAGE = 100; + + /** + * Represents a map of dimension IDs to a set of all block swappers + * active in that dimension. + */ + private static Map> blockSwappers = new HashMap>(); + + IIcon iconOn, iconOff; + + public ItemTerraAxe() { + super(BotaniaAPI.terrasteelToolMaterial, LibItemNames.TERRA_AXE); + FMLCommonHandler.instance().bus().register(this); + } + + @Override + @SideOnly(Side.CLIENT) + public void registerIcons(IIconRegister par1IconRegister) { + iconOn = IconHelper.forItem(par1IconRegister, this, 0); + iconOff = IconHelper.forItem(par1IconRegister, this, 1); + } + + @Override + public IIcon getIconFromDamage(int p_77617_1_) { + return iconOn; + } + + @Override + public IIcon getIcon(ItemStack stack, int renderPass, EntityPlayer player, ItemStack usingItem, int useRemaining) { + return shouldBreak(player) ? iconOn : iconOff; + } + + public boolean shouldBreak(EntityPlayer player) { + return !player.isSneaking() && !ItemTemperanceStone.hasTemperanceActive(player); + } + + @Override + public boolean onBlockStartBreak(ItemStack stack, int x, int y, int z, EntityPlayer player) { + MovingObjectPosition raycast = ToolCommons.raytraceFromEntity(player.worldObj, player, true, 10); + if(raycast != null) { + breakOtherBlock(player, stack, x, y, z, x, y, z, raycast.sideHit); + ItemLokiRing.breakOnAllCursors(player, this, stack, x, y, z, raycast.sideHit); + } + + return false; + } + + @Override + public int getManaPerDamage() { + return MANA_PER_DAMAGE; + } + + @Override + public void breakOtherBlock(EntityPlayer player, ItemStack stack, int x, int y, int z, int originX, int originY, int originZ, int side) { + if(shouldBreak(player)) { + ChunkCoordinates coords = new ChunkCoordinates(x, y, z); + addBlockSwapper(player.worldObj, player, stack, coords, 32, true); + } + } + + @Override + public boolean disposeOfTrashBlocks(ItemStack stack) { + return false; + } + + @SubscribeEvent + public void onTickEnd(TickEvent.WorldTickEvent event) { + // Block Swapping ticking should only occur on the server + if(event.world.isRemote) + return; + + if(event.phase == Phase.END) { + int dim = event.world.provider.dimensionId; + if(blockSwappers.containsKey(dim)) { + Set swappers = blockSwappers.get(dim); + + // Iterate through all of our swappers, removing any + // which no longer need to tick. + Iterator swapper = swappers.iterator(); + while(swapper.hasNext()) { + BlockSwapper next = swapper.next(); + + // If a null sneaks in or the swapper is done, remove it + if(next == null || !next.tick()) + swapper.remove(); + } + } + } + } + + /** + * Adds a new block swapper to the provided world as the provided player. + * Block swappers are only added on the server, and a marker instance + * which is not actually ticked but contains the proper passed in + * information will be returned to the client. + * + * @param world The world to add the swapper to. + * @param player The player who is responsible for this swapper. + * @param stack The Terra Truncator which caused this block swapper. + * @param origCoords The original coordinates the swapper should start at. + * @param steps The range of the block swapper, in blocks. + * @param leaves If true, will treat leaves specially (see the BlockSwapper + * documentation). + * @return The created block swapper. + */ + private static BlockSwapper addBlockSwapper(World world, EntityPlayer player, ItemStack stack, ChunkCoordinates origCoords, int steps, boolean leaves) { + BlockSwapper swapper = new BlockSwapper(world, player, stack, origCoords, steps, leaves); + + // Block swapper registration should only occur on the server + if(world.isRemote) + return swapper; + + // If the mapping for this dimension doesn't exist, create it. + int dim = world.provider.dimensionId; + if(!blockSwappers.containsKey(dim)) + blockSwappers.put(dim, new HashSet()); + + // Add the swapper + blockSwappers.get(dim).add(swapper); + + return swapper; + } + + /** + * A block swapper for the Terra Truncator, which uses a standard + * Breadth First Search to try and murder/cut down trees. + * + * The Terra Truncator will look up to BLOCK_RANGE blocks to find wood + * to cut down (only cutting down adjacent pieces of wood, so it doesn't + * jump through the air). However, the truncator will only go through + * LEAF_BLOCK_RANGE leave blocks in order to prevent adjacent trees which + * are connected only by leaves from being devoured as well. + * + * The leaf restriction is implemented by reducing the number of remaining + * steps to the min of LEAF_BLOCK_RANGE and the current range. The restriction + * can be removed entirely by setting the "leaves" variable to true, in which + * case leaves will be treated normally. + */ + private static class BlockSwapper { + + /** + * Represents the range which a single block will scan when looking + * for the next candidates for swapping. 1 is a good default. + */ + public static final int SINGLE_BLOCK_RADIUS = 1; + + + /** + * The world the block swapper is doing the swapping in. + */ + private final World world; + + /** + * The player the swapper is swapping for. + */ + private final EntityPlayer player; + + /** + * The Terra Truncator which created this swapper. + */ + private final ItemStack truncator; + + /** + * The origin of the swapper (eg, where it started). + */ + private final ChunkCoordinates origin; + + /** + * Denotes whether leaves should be treated specially. + */ + private final boolean treatLeavesSpecial; + + /** + * The initial range which this block swapper starts with. + */ + private final int range; + + /** + * The priority queue of all possible candidates for swapping. + */ + private PriorityQueue candidateQueue; + + /** + * The set of already swaps coordinates which do not have + * to be revisited. + */ + private Set completedCoords; + + /** + * Creates a new block swapper with the provided parameters. + * @param world The world the swapper is in. + * @param player The player responsible for creating this swapper. + * @param truncator The Terra Truncator responsible for creating this swapper. + * @param origCoords The original coordinates this swapper should start at. + * @param range The range this swapper should swap in. + * @param leaves If true, leaves will be treated specially and + * severely reduce the radius of further spreading when encountered. + */ + public BlockSwapper(World world, EntityPlayer player, ItemStack truncator, ChunkCoordinates origCoords, int range, boolean leaves) { + this.world = world; + this.player = player; + this.truncator = truncator; + this.origin = origCoords; + this.range = range; + this.treatLeavesSpecial = leaves; + + this.candidateQueue = new PriorityQueue(); + this.completedCoords = new HashSet(); + + // Add the origin to our candidate queue with the original range + candidateQueue.offer(new SwapCandidate(this.origin, this.range)); + } + + /** + * Ticks this Block Swapper, which allows it to swap BLOCK_SWAP_RATE + * further blocks and expands the breadth first search. The return + * value signifies whether or not the block swapper has more blocks + * to swap, or if it has finished swapping. + * @return True if the block swapper has more blocks to swap, false + * otherwise (implying it can be safely removed). + */ + public boolean tick() { + // If empty, this swapper is done. + if(candidateQueue.isEmpty()) + return false; + + int remainingSwaps = BLOCK_SWAP_RATE; + while(remainingSwaps > 0 && !candidateQueue.isEmpty()) { + SwapCandidate cand = candidateQueue.poll(); + + // If we've already completed this location, move along, as this + // is just a suboptimal one. + if(completedCoords.contains(cand.coordinates)) + continue; + + // If this candidate is out of range, discard it. + if(cand.range <= 0) + continue; + + // Otherwise, perform the break and then look at the adjacent tiles. + // This is a ridiculous function call here. + ToolCommons.removeBlockWithDrops(player, truncator, world, + cand.coordinates.posX, cand.coordinates.posY, cand.coordinates.posZ, + origin.posX, origin.posY, origin.posZ, + null, ToolCommons.materialsAxe, + EnchantmentHelper.getEnchantmentLevel(Enchantment.silkTouch.effectId, truncator) > 0, + EnchantmentHelper.getEnchantmentLevel(Enchantment.fortune.effectId, truncator), + 0F, false, treatLeavesSpecial); + + remainingSwaps--; + + completedCoords.add(cand.coordinates); + + // Then, go through all of the adjacent blocks and look if + // any of them are any good. + for(ChunkCoordinates adj : adjacent(cand.coordinates)) { + Block block = world.getBlock(adj.posX, adj.posY, adj.posZ); + + boolean isWood = block.isWood(world, adj.posX, adj.posY, adj.posZ); + boolean isLeaf = block.isLeaves(world, adj.posX, adj.posY, adj.posZ); + + // If it's not wood or a leaf, we aren't interested. + if(!isWood && !isLeaf) + continue; + + // If we treat leaves specially and this is a leaf, it gets + // the minimum of the leaf range and the current range - 1. + // Otherwise, it gets the standard range - 1. + int newRange = treatLeavesSpecial && isLeaf ? + Math.min(LEAF_BLOCK_RANGE, cand.range - 1) : + cand.range - 1; + + candidateQueue.offer(new SwapCandidate(adj, newRange)); + } + } + + // If we did any iteration, then hang around until next tick. + return true; + } + + public List adjacent(ChunkCoordinates original) { + List coords = new ArrayList(); + // Visit all the surrounding blocks in the provided radius. + // Gotta love these nested loops, right? + for(int dx = -SINGLE_BLOCK_RADIUS; dx <= SINGLE_BLOCK_RADIUS; dx++) + for(int dy = -SINGLE_BLOCK_RADIUS; dy <= SINGLE_BLOCK_RADIUS; dy++) + for(int dz = -SINGLE_BLOCK_RADIUS; dz <= SINGLE_BLOCK_RADIUS; dz++) { + // Skip the central tile. + if(dx == 0 && dy == 0 && dz == 0) + continue; + + coords.add(new ChunkCoordinates(original.posX + dx, original.posY + dy, original.posZ + dz)); + } + + return coords; + } + + /** + * Represents a potential candidate for swapping/removal. Sorted by + * range (where a larger range is more preferable). As we're using + * a priority queue, which is a min-heap internally, larger ranges + * are considered "smaller" than smaller ranges (so they show up in the + * min-heap first). + */ + public static final class SwapCandidate implements Comparable { + /** + * The location of this swap candidate. + */ + public ChunkCoordinates coordinates; + + /** + * The remaining range of this swap candidate. + */ + public int range; + + /** + * Constructs a new Swap Candidate with the provided + * coordinates and range. + * @param coordinates The coordinates of this candidate. + * @param range The remaining range of this candidate. + */ + public SwapCandidate(ChunkCoordinates coordinates, int range) { + this.coordinates = coordinates; + this.range = range; + } + + @Override + public int compareTo(SwapCandidate other) { + // Aka, a bigger range implies a smaller value, meaning + // bigger ranges will be preferred in a min-heap + return other.range - range; + } + + @Override + public boolean equals(Object other) { + if(!(other instanceof SwapCandidate)) return false; + + SwapCandidate cand = (SwapCandidate) other; + return coordinates.equals(cand.coordinates) && range == cand.range; + } + } + } - /** - * The number of blocks per tick which the Terra Truncator will - * collect. - */ - public static final int BLOCK_SWAP_RATE = 10; - - /** - * The maximum radius (in blocks) which the Terra Truncator will go - * in order to try and murder/cut down the tree. - */ - public static final int BLOCK_RANGE = 32; - - /** - * The maximum number of leaf blocks which the Terra Truncator will chew/go - * through once a leaf block is encountered. - */ - public static final int LEAF_BLOCK_RANGE = 3; - - /** - * The amount of mana required to restore 1 point of damage. - */ - private static final int MANA_PER_DAMAGE = 100; - - /** - * Represents a map of dimension IDs to a set of all block swappers - * active in that dimension. - */ - private static Map> blockSwappers = new HashMap>(); - - IIcon iconOn, iconOff; - - public ItemTerraAxe() { - super(BotaniaAPI.terrasteelToolMaterial, LibItemNames.TERRA_AXE); - FMLCommonHandler.instance().bus().register(this); - } - - @Override - @SideOnly(Side.CLIENT) - public void registerIcons(IIconRegister par1IconRegister) { - iconOn = IconHelper.forItem(par1IconRegister, this, 0); - iconOff = IconHelper.forItem(par1IconRegister, this, 1); - } - - @Override - public IIcon getIconFromDamage(int p_77617_1_) { - return iconOn; - } - - @Override - public IIcon getIcon(ItemStack stack, int renderPass, EntityPlayer player, ItemStack usingItem, int useRemaining) { - return shouldBreak(player) ? iconOn : iconOff; - } - - public boolean shouldBreak(EntityPlayer player) { - return !player.isSneaking() && !ItemTemperanceStone.hasTemperanceActive(player); - } - - @Override - public boolean onBlockStartBreak(ItemStack stack, int x, int y, int z, EntityPlayer player) { - MovingObjectPosition raycast = ToolCommons.raytraceFromEntity(player.worldObj, player, true, 10); - if (raycast != null) { - breakOtherBlock(player, stack, x, y, z, x, y, z, raycast.sideHit); - ItemLokiRing.breakOnAllCursors(player, this, stack, x, y, z, raycast.sideHit); - } - - return false; - } - - @Override - public int getManaPerDamage() { - return MANA_PER_DAMAGE; - } - - @Override - public void breakOtherBlock( - EntityPlayer player, - ItemStack stack, - int x, - int y, - int z, - int originX, - int originY, - int originZ, - int side) { - if (shouldBreak(player)) { - ChunkCoordinates coords = new ChunkCoordinates(x, y, z); - addBlockSwapper(player.worldObj, player, stack, coords, 32, true); - } - } - - @Override - public boolean disposeOfTrashBlocks(ItemStack stack) { - return false; - } - - @SubscribeEvent - public void onTickEnd(TickEvent.WorldTickEvent event) { - // Block Swapping ticking should only occur on the server - if (event.world.isRemote) return; - - if (event.phase == Phase.END) { - int dim = event.world.provider.dimensionId; - if (blockSwappers.containsKey(dim)) { - Set swappers = blockSwappers.get(dim); - - // Iterate through all of our swappers, removing any - // which no longer need to tick. - Iterator swapper = swappers.iterator(); - while (swapper.hasNext()) { - BlockSwapper next = swapper.next(); - - // If a null sneaks in or the swapper is done, remove it - if (next == null || !next.tick()) swapper.remove(); - } - } - } - } - - /** - * Adds a new block swapper to the provided world as the provided player. - * Block swappers are only added on the server, and a marker instance - * which is not actually ticked but contains the proper passed in - * information will be returned to the client. - * - * @param world The world to add the swapper to. - * @param player The player who is responsible for this swapper. - * @param stack The Terra Truncator which caused this block swapper. - * @param origCoords The original coordinates the swapper should start at. - * @param steps The range of the block swapper, in blocks. - * @param leaves If true, will treat leaves specially (see the BlockSwapper - * documentation). - * @return The created block swapper. - */ - private static BlockSwapper addBlockSwapper( - World world, EntityPlayer player, ItemStack stack, ChunkCoordinates origCoords, int steps, boolean leaves) { - BlockSwapper swapper = new BlockSwapper(world, player, stack, origCoords, steps, leaves); - - // Block swapper registration should only occur on the server - if (world.isRemote) return swapper; - - // If the mapping for this dimension doesn't exist, create it. - int dim = world.provider.dimensionId; - if (!blockSwappers.containsKey(dim)) blockSwappers.put(dim, new HashSet()); - - // Add the swapper - blockSwappers.get(dim).add(swapper); - - return swapper; - } - - /** - * A block swapper for the Terra Truncator, which uses a standard - * Breadth First Search to try and murder/cut down trees. - * - * The Terra Truncator will look up to BLOCK_RANGE blocks to find wood - * to cut down (only cutting down adjacent pieces of wood, so it doesn't - * jump through the air). However, the truncator will only go through - * LEAF_BLOCK_RANGE leave blocks in order to prevent adjacent trees which - * are connected only by leaves from being devoured as well. - * - * The leaf restriction is implemented by reducing the number of remaining - * steps to the min of LEAF_BLOCK_RANGE and the current range. The restriction - * can be removed entirely by setting the "leaves" variable to true, in which - * case leaves will be treated normally. - */ - private static class BlockSwapper { - - /** - * Represents the range which a single block will scan when looking - * for the next candidates for swapping. 1 is a good default. - */ - public static final int SINGLE_BLOCK_RADIUS = 1; - - /** - * The world the block swapper is doing the swapping in. - */ - private final World world; - - /** - * The player the swapper is swapping for. - */ - private final EntityPlayer player; - - /** - * The Terra Truncator which created this swapper. - */ - private final ItemStack truncator; - - /** - * The origin of the swapper (eg, where it started). - */ - private final ChunkCoordinates origin; - - /** - * Denotes whether leaves should be treated specially. - */ - private final boolean treatLeavesSpecial; - - /** - * The initial range which this block swapper starts with. - */ - private final int range; - - /** - * The priority queue of all possible candidates for swapping. - */ - private PriorityQueue candidateQueue; - - /** - * The set of already swaps coordinates which do not have - * to be revisited. - */ - private Set completedCoords; - - /** - * Creates a new block swapper with the provided parameters. - * @param world The world the swapper is in. - * @param player The player responsible for creating this swapper. - * @param truncator The Terra Truncator responsible for creating this swapper. - * @param origCoords The original coordinates this swapper should start at. - * @param range The range this swapper should swap in. - * @param leaves If true, leaves will be treated specially and - * severely reduce the radius of further spreading when encountered. - */ - public BlockSwapper( - World world, - EntityPlayer player, - ItemStack truncator, - ChunkCoordinates origCoords, - int range, - boolean leaves) { - this.world = world; - this.player = player; - this.truncator = truncator; - this.origin = origCoords; - this.range = range; - this.treatLeavesSpecial = leaves; - - this.candidateQueue = new PriorityQueue(); - this.completedCoords = new HashSet(); - - // Add the origin to our candidate queue with the original range - candidateQueue.offer(new SwapCandidate(this.origin, this.range)); - } - - /** - * Ticks this Block Swapper, which allows it to swap BLOCK_SWAP_RATE - * further blocks and expands the breadth first search. The return - * value signifies whether or not the block swapper has more blocks - * to swap, or if it has finished swapping. - * @return True if the block swapper has more blocks to swap, false - * otherwise (implying it can be safely removed). - */ - public boolean tick() { - // If empty, this swapper is done. - if (candidateQueue.isEmpty()) return false; - - int remainingSwaps = BLOCK_SWAP_RATE; - while (remainingSwaps > 0 && !candidateQueue.isEmpty()) { - SwapCandidate cand = candidateQueue.poll(); - - // If we've already completed this location, move along, as this - // is just a suboptimal one. - if (completedCoords.contains(cand.coordinates)) continue; - - // If this candidate is out of range, discard it. - if (cand.range <= 0) continue; - - // Otherwise, perform the break and then look at the adjacent tiles. - // This is a ridiculous function call here. - ToolCommons.removeBlockWithDrops( - player, - truncator, - world, - cand.coordinates.posX, - cand.coordinates.posY, - cand.coordinates.posZ, - origin.posX, - origin.posY, - origin.posZ, - null, - ToolCommons.materialsAxe, - EnchantmentHelper.getEnchantmentLevel(Enchantment.silkTouch.effectId, truncator) > 0, - EnchantmentHelper.getEnchantmentLevel(Enchantment.fortune.effectId, truncator), - 0F, - false, - treatLeavesSpecial); - - remainingSwaps--; - - completedCoords.add(cand.coordinates); - - // Then, go through all of the adjacent blocks and look if - // any of them are any good. - for (ChunkCoordinates adj : adjacent(cand.coordinates)) { - Block block = world.getBlock(adj.posX, adj.posY, adj.posZ); - - boolean isWood = block.isWood(world, adj.posX, adj.posY, adj.posZ); - boolean isLeaf = block.isLeaves(world, adj.posX, adj.posY, adj.posZ); - - // If it's not wood or a leaf, we aren't interested. - if (!isWood && !isLeaf) continue; - - // If we treat leaves specially and this is a leaf, it gets - // the minimum of the leaf range and the current range - 1. - // Otherwise, it gets the standard range - 1. - int newRange = - treatLeavesSpecial && isLeaf ? Math.min(LEAF_BLOCK_RANGE, cand.range - 1) : cand.range - 1; - - candidateQueue.offer(new SwapCandidate(adj, newRange)); - } - } - - // If we did any iteration, then hang around until next tick. - return true; - } - - public List adjacent(ChunkCoordinates original) { - List coords = new ArrayList(); - // Visit all the surrounding blocks in the provided radius. - // Gotta love these nested loops, right? - for (int dx = -SINGLE_BLOCK_RADIUS; dx <= SINGLE_BLOCK_RADIUS; dx++) - for (int dy = -SINGLE_BLOCK_RADIUS; dy <= SINGLE_BLOCK_RADIUS; dy++) - for (int dz = -SINGLE_BLOCK_RADIUS; dz <= SINGLE_BLOCK_RADIUS; dz++) { - // Skip the central tile. - if (dx == 0 && dy == 0 && dz == 0) continue; - - coords.add(new ChunkCoordinates(original.posX + dx, original.posY + dy, original.posZ + dz)); - } - - return coords; - } - - /** - * Represents a potential candidate for swapping/removal. Sorted by - * range (where a larger range is more preferable). As we're using - * a priority queue, which is a min-heap internally, larger ranges - * are considered "smaller" than smaller ranges (so they show up in the - * min-heap first). - */ - public static final class SwapCandidate implements Comparable { - /** - * The location of this swap candidate. - */ - public ChunkCoordinates coordinates; - - /** - * The remaining range of this swap candidate. - */ - public int range; - - /** - * Constructs a new Swap Candidate with the provided - * coordinates and range. - * @param coordinates The coordinates of this candidate. - * @param range The remaining range of this candidate. - */ - public SwapCandidate(ChunkCoordinates coordinates, int range) { - this.coordinates = coordinates; - this.range = range; - } - - @Override - public int compareTo(SwapCandidate other) { - // Aka, a bigger range implies a smaller value, meaning - // bigger ranges will be preferred in a min-heap - return other.range - range; - } - - @Override - public boolean equals(Object other) { - if (!(other instanceof SwapCandidate)) return false; - - SwapCandidate cand = (SwapCandidate) other; - return coordinates.equals(cand.coordinates) && range == cand.range; - } - } - } } diff --git a/src/main/java/vazkii/botania/common/item/equipment/tool/terrasteel/ItemTerraPick.java b/src/main/java/vazkii/botania/common/item/equipment/tool/terrasteel/ItemTerraPick.java index dbe118357e..58f01a2c36 100644 --- a/src/main/java/vazkii/botania/common/item/equipment/tool/terrasteel/ItemTerraPick.java +++ b/src/main/java/vazkii/botania/common/item/equipment/tool/terrasteel/ItemTerraPick.java @@ -2,19 +2,17 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [May 20, 2014, 10:56:14 PM (GMT)] */ package vazkii.botania.common.item.equipment.tool.terrasteel; -import cpw.mods.fml.common.registry.GameRegistry; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; import java.awt.Color; import java.util.List; + import net.minecraft.block.material.Material; import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.creativetab.CreativeTabs; @@ -40,302 +38,272 @@ import vazkii.botania.common.achievement.ModAchievements; import vazkii.botania.common.core.helper.ItemNBTHelper; import vazkii.botania.common.crafting.recipe.TerraPickTippingRecipe; +import vazkii.botania.common.item.ItemSpark; import vazkii.botania.common.item.ItemTemperanceStone; import vazkii.botania.common.item.ModItems; +import vazkii.botania.common.item.equipment.bauble.ItemAuraRing; +import vazkii.botania.common.item.equipment.bauble.ItemGreaterAuraRing; import vazkii.botania.common.item.equipment.tool.ToolCommons; import vazkii.botania.common.item.equipment.tool.manasteel.ItemManasteelPick; import vazkii.botania.common.item.relic.ItemLokiRing; import vazkii.botania.common.item.relic.ItemThorRing; import vazkii.botania.common.lib.LibItemNames; +import cpw.mods.fml.common.registry.GameRegistry; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; public class ItemTerraPick extends ItemManasteelPick implements IManaItem, ISequentialBreaker { - private static final String TAG_ENABLED = "enabled"; - private static final String TAG_MANA = "mana"; - private static final String TAG_TIPPED = "tipped"; - - private static final int MAX_MANA = Integer.MAX_VALUE; - private static final int MANA_PER_DAMAGE = 100; - - private static final Material[] MATERIALS = new Material[] { - Material.rock, - Material.iron, - Material.ice, - Material.glass, - Material.piston, - Material.anvil, - Material.grass, - Material.ground, - Material.sand, - Material.snow, - Material.craftedSnow, - Material.clay - }; - - public static final int[] LEVELS = new int[] {0, 10000, 1000000, 10000000, 100000000, 1000000000}; - - private static final int[] CREATIVE_MANA = - new int[] {10000 - 1, 1000000 - 1, 10000000 - 1, 100000000 - 1, 1000000000 - 1, MAX_MANA - 1}; - - IIcon iconTool, iconOverlay, iconTipped; - - public ItemTerraPick() { - super(BotaniaAPI.terrasteelToolMaterial, LibItemNames.TERRA_PICK); - GameRegistry.addRecipe(new TerraPickTippingRecipe()); - RecipeSorter.register("botania:terraPickTipping", TerraPickTippingRecipe.class, Category.SHAPELESS, ""); - } - - @Override - public void getSubItems(Item item, CreativeTabs tab, List list) { - for (int mana : CREATIVE_MANA) { - ItemStack stack = new ItemStack(item); - setMana(stack, mana); - list.add(stack); - } - } - - @Override - public void addInformation(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, List par3List, boolean par4) { - String rankFormat = StatCollector.translateToLocal("botaniamisc.toolRank"); - String rank = StatCollector.translateToLocal("botania.rank" + getLevel(par1ItemStack)); - par3List.add(String.format(rankFormat, rank).replaceAll("&", "\u00a7")); - if (getMana(par1ItemStack) == Integer.MAX_VALUE) - par3List.add(EnumChatFormatting.RED + StatCollector.translateToLocal("botaniamisc.getALife")); - } - - @Override - public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer) { - getMana(par1ItemStack); - int level = getLevel(par1ItemStack); - - if (level != 0) { - setEnabled(par1ItemStack, !isEnabled(par1ItemStack)); - if (!par2World.isRemote) par2World.playSoundAtEntity(par3EntityPlayer, "botania:terraPickMode", 0.5F, 0.4F); - } - - return par1ItemStack; - } - - @Override - public boolean onItemUse( - ItemStack stack, - EntityPlayer player, - World world, - int x, - int y, - int z, - int s, - float sx, - float sy, - float sz) { - return player.isSneaking() && super.onItemUse(stack, player, world, x, y, z, s, sx, sy, sz); - } - - @Override - public void onUpdate(ItemStack par1ItemStack, World par2World, Entity par3Entity, int par4, boolean par5) { - super.onUpdate(par1ItemStack, par2World, par3Entity, par4, par5); - if (isEnabled(par1ItemStack)) { - int level = getLevel(par1ItemStack); - - if (level == 0) setEnabled(par1ItemStack, false); - else if (par3Entity instanceof EntityPlayer && !((EntityPlayer) par3Entity).isSwingInProgress) - addMana(par1ItemStack, -level); - } - } - - @Override - public boolean onBlockStartBreak(ItemStack stack, int x, int y, int z, EntityPlayer player) { - MovingObjectPosition raycast = ToolCommons.raytraceFromEntity(player.worldObj, player, true, 10); - if (raycast != null) { - breakOtherBlock(player, stack, x, y, z, x, y, z, raycast.sideHit); - ItemLokiRing.breakOnAllCursors(player, this, stack, x, y, z, raycast.sideHit); - // ^ Doable with API access through the IInternalMethodHandler. - } - - return false; - } - - @Override - public int getManaPerDmg() { - return MANA_PER_DAMAGE; - } - - @Override - public void breakOtherBlock( - EntityPlayer player, - ItemStack stack, - int x, - int y, - int z, - int originX, - int originY, - int originZ, - int side) { - if (!isEnabled(stack)) return; - - World world = player.worldObj; - Material mat = world.getBlock(x, y, z).getMaterial(); - if (!ToolCommons.isRightMaterial(mat, MATERIALS)) return; - - if (world.isAirBlock(x, y, z)) return; - - ForgeDirection direction = ForgeDirection.getOrientation(side); - int fortune = EnchantmentHelper.getFortuneModifier(player); - boolean silk = EnchantmentHelper.getSilkTouchModifier(player); - boolean thor = ItemThorRing.getThorRing(player) != null; - boolean doX = thor || direction.offsetX == 0; - boolean doY = thor || direction.offsetY == 0; - boolean doZ = thor || direction.offsetZ == 0; - - int origLevel = getLevel(stack); - int level = origLevel + (thor ? 1 : 0); - if (ItemTemperanceStone.hasTemperanceActive(player) && level > 2) level = 2; - - int range = Math.max(0, level - 1); - int rangeY = Math.max(1, range); - - if (range == 0 && level != 1) return; - - ToolCommons.removeBlocksInIteration( - player, - stack, - world, - x, - y, - z, - doX ? -range : 0, - doY ? -1 : 0, - doZ ? -range : 0, - doX ? range + 1 : 1, - doY ? rangeY * 2 : 1, - doZ ? range + 1 : 1, - null, - MATERIALS, - silk, - fortune, - isTipped(stack)); - if (origLevel == 5) player.addStat(ModAchievements.rankSSPick, 1); - } - - @Override - public int getEntityLifespan(ItemStack itemStack, World world) { - return Integer.MAX_VALUE; - } - - @Override - public void registerIcons(IIconRegister par1IconRegister) { - iconTool = IconHelper.forItem(par1IconRegister, this, 0); - iconOverlay = IconHelper.forItem(par1IconRegister, this, 1); - iconTipped = IconHelper.forItem(par1IconRegister, this, 2); - } - - @Override - public boolean requiresMultipleRenderPasses() { - return true; - } - - @Override - public IIcon getIcon(ItemStack stack, int pass) { - return pass == 1 && isEnabled(stack) ? iconOverlay : isTipped(stack) ? iconTipped : iconTool; - } - - @Override - public int getHarvestLevel(ItemStack stack, String toolClass) { - if (!"pickaxe".equals(toolClass)) { - return super.getHarvestLevel(stack, toolClass); - } - // Rank S -> level 8 (Manyullyn) - return getLevel(stack) + 4; - } - - public static boolean isTipped(ItemStack stack) { - return ItemNBTHelper.getBoolean(stack, TAG_TIPPED, false); - } - - public static void setTipped(ItemStack stack) { - ItemNBTHelper.setBoolean(stack, TAG_TIPPED, true); - } - - @Override - @SideOnly(Side.CLIENT) - public int getColorFromItemStack(ItemStack par1ItemStack, int par2) { - if (par2 == 0 || !isEnabled(par1ItemStack)) return 0xFFFFFF; - - return Color.HSBtoRGB(0.375F, (float) Math.min(1F, Math.sin(System.currentTimeMillis() / 200D) * 0.5 + 1F), 1F); - } - - boolean isEnabled(ItemStack stack) { - return ItemNBTHelper.getBoolean(stack, TAG_ENABLED, false); - } - - void setEnabled(ItemStack stack, boolean enabled) { - ItemNBTHelper.setBoolean(stack, TAG_ENABLED, enabled); - } - - public static void setMana(ItemStack stack, int mana) { - ItemNBTHelper.setInt(stack, TAG_MANA, mana); - } - - @Override - public int getMana(ItemStack stack) { - return getMana_(stack); - } - - public static int getMana_(ItemStack stack) { - return ItemNBTHelper.getInt(stack, TAG_MANA, 0); - } - - public static int getLevel(ItemStack stack) { - int mana = getMana_(stack); - for (int i = LEVELS.length - 1; i > 0; i--) if (mana >= LEVELS[i]) return i; - - return 0; - } - - @Override - public int getMaxMana(ItemStack stack) { - return MAX_MANA; - } - - @Override - public void addMana(ItemStack stack, int mana) { - setMana(stack, Math.min(getMana(stack) + mana, MAX_MANA)); - } - - @Override - public boolean canReceiveManaFromPool(ItemStack stack, TileEntity pool) { - return true; - } - - @Override - public boolean canReceiveManaFromItem(ItemStack stack, ItemStack otherStack) { - return !(otherStack.getItem() instanceof IManaGivingItem); - } - - @Override - public boolean canExportManaToPool(ItemStack stack, TileEntity pool) { - return false; - } - - @Override - public boolean canExportManaToItem(ItemStack stack, ItemStack otherStack) { - return false; - } - - @Override - public boolean isNoExport(ItemStack stack) { - return true; - } - - @Override - public boolean getIsRepairable(ItemStack par1ItemStack, ItemStack par2ItemStack) { - return par2ItemStack.getItem() == ModItems.manaResource && par2ItemStack.getItemDamage() == 4 - ? true - : super.getIsRepairable(par1ItemStack, par2ItemStack); - } - - @Override - public boolean disposeOfTrashBlocks(ItemStack stack) { - return isTipped(stack); - } + private static final String TAG_ENABLED = "enabled"; + private static final String TAG_MANA = "mana"; + private static final String TAG_TIPPED = "tipped"; + + private static final int MAX_MANA = Integer.MAX_VALUE; + private static final int MANA_PER_DAMAGE = 100; + + private static final Material[] MATERIALS = new Material[] { Material.rock, Material.iron, Material.ice, Material.glass, Material.piston, Material.anvil, Material.grass, Material.ground, Material.sand, Material.snow, Material.craftedSnow, Material.clay }; + + public static final int[] LEVELS = new int[] { + 0, 10000, 1000000, 10000000, 100000000, 1000000000 + }; + + private static final int[] CREATIVE_MANA = new int[] { + 10000 - 1, 1000000 - 1, 10000000 - 1, 100000000 - 1, 1000000000 - 1, MAX_MANA - 1 + }; + + IIcon iconTool, iconOverlay, iconTipped; + + public ItemTerraPick() { + super(BotaniaAPI.terrasteelToolMaterial, LibItemNames.TERRA_PICK); + GameRegistry.addRecipe(new TerraPickTippingRecipe()); + RecipeSorter.register("botania:terraPickTipping", TerraPickTippingRecipe.class, Category.SHAPELESS, ""); + } + + @Override + public void getSubItems(Item item, CreativeTabs tab, List list) { + for(int mana : CREATIVE_MANA) { + ItemStack stack = new ItemStack(item); + setMana(stack, mana); + list.add(stack); + } + } + + @Override + public void addInformation(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, List par3List, boolean par4) { + String rankFormat = StatCollector.translateToLocal("botaniamisc.toolRank"); + String rank = StatCollector.translateToLocal("botania.rank" + getLevel(par1ItemStack)); + par3List.add(String.format(rankFormat, rank).replaceAll("&", "\u00a7")); + if(getMana(par1ItemStack) == Integer.MAX_VALUE) + par3List.add(EnumChatFormatting.RED + StatCollector.translateToLocal("botaniamisc.getALife")); + } + + @Override + public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer) { + getMana(par1ItemStack); + int level = getLevel(par1ItemStack); + + if(level != 0) { + setEnabled(par1ItemStack, !isEnabled(par1ItemStack)); + if(!par2World.isRemote) + par2World.playSoundAtEntity(par3EntityPlayer, "botania:terraPickMode", 0.5F, 0.4F); + } + + return par1ItemStack; + } + + @Override + public boolean onItemUse(ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int s, float sx, float sy, float sz) { + return player.isSneaking() && super.onItemUse(stack, player, world, x, y, z, s, sx, sy, sz); + } + + @Override + public void onUpdate(ItemStack par1ItemStack, World par2World, Entity par3Entity, int par4, boolean par5) { + super.onUpdate(par1ItemStack, par2World, par3Entity, par4, par5); + if(isEnabled(par1ItemStack)) { + int level = getLevel(par1ItemStack); + + if(level == 0) + setEnabled(par1ItemStack, false); + else if(par3Entity instanceof EntityPlayer && !((EntityPlayer) par3Entity).isSwingInProgress) + addMana(par1ItemStack, -level); + } + } + + @Override + public boolean onBlockStartBreak(ItemStack stack, int x, int y, int z, EntityPlayer player) { + MovingObjectPosition raycast = ToolCommons.raytraceFromEntity(player.worldObj, player, true, 10); + if(raycast != null) { + breakOtherBlock(player, stack, x, y, z, x, y, z, raycast.sideHit); + ItemLokiRing.breakOnAllCursors(player, this, stack, x, y, z, raycast.sideHit); + // ^ Doable with API access through the IInternalMethodHandler. + } + + return false; + } + + @Override + public int getManaPerDmg() { + return MANA_PER_DAMAGE; + } + + @Override + public void breakOtherBlock(EntityPlayer player, ItemStack stack, int x, int y, int z, int originX, int originY, int originZ, int side) { + if(!isEnabled(stack)) + return; + + World world = player.worldObj; + Material mat = world.getBlock(x, y, z).getMaterial(); + if(!ToolCommons.isRightMaterial(mat, MATERIALS)) + return; + + if(world.isAirBlock(x, y, z)) + return; + + ForgeDirection direction = ForgeDirection.getOrientation(side); + int fortune = EnchantmentHelper.getFortuneModifier(player); + boolean silk = EnchantmentHelper.getSilkTouchModifier(player); + boolean thor = ItemThorRing.getThorRing(player) != null; + boolean doX = thor || direction.offsetX == 0; + boolean doY = thor || direction.offsetY == 0; + boolean doZ = thor || direction.offsetZ == 0; + + int origLevel = getLevel(stack); + int level = origLevel + (thor ? 1 : 0); + if(ItemTemperanceStone.hasTemperanceActive(player) && level > 2) + level = 2; + + int range = Math.max(0, level - 1); + int rangeY = Math.max(1, range); + + if(range == 0 && level != 1) + return; + + ToolCommons.removeBlocksInIteration(player, stack, world, x, y, z, doX ? -range : 0, doY ? -1 : 0, doZ ? -range : 0, doX ? range + 1 : 1, doY ? rangeY * 2 : 1, doZ ? range + 1 : 1, null, MATERIALS, silk, fortune, isTipped(stack)); + if(origLevel == 5) + player.addStat(ModAchievements.rankSSPick, 1); + } + + @Override + public int getEntityLifespan(ItemStack itemStack, World world) { + return Integer.MAX_VALUE; + } + + @Override + public void registerIcons(IIconRegister par1IconRegister) { + iconTool = IconHelper.forItem(par1IconRegister, this, 0); + iconOverlay = IconHelper.forItem(par1IconRegister, this, 1); + iconTipped = IconHelper.forItem(par1IconRegister, this, 2); + } + + @Override + public boolean requiresMultipleRenderPasses() { + return true; + } + + @Override + public IIcon getIcon(ItemStack stack, int pass) { + return pass == 1 && isEnabled(stack) ? iconOverlay : isTipped(stack) ? iconTipped : iconTool; + } + + @Override + public int getHarvestLevel(ItemStack stack, String toolClass) { + if (!"pickaxe".equals(toolClass)) { + return super.getHarvestLevel(stack, toolClass); + } + // Rank S -> level 8 (Manyullyn) + return getLevel(stack) + 4; + } + + public static boolean isTipped(ItemStack stack) { + return ItemNBTHelper.getBoolean(stack, TAG_TIPPED, false); + } + + public static void setTipped(ItemStack stack) { + ItemNBTHelper.setBoolean(stack, TAG_TIPPED, true); + } + + @Override + @SideOnly(Side.CLIENT) + public int getColorFromItemStack(ItemStack par1ItemStack, int par2) { + if(par2 == 0 || !isEnabled(par1ItemStack)) + return 0xFFFFFF; + + return Color.HSBtoRGB(0.375F, (float) Math.min(1F, Math.sin(System.currentTimeMillis() / 200D) * 0.5 + 1F), 1F); + } + + boolean isEnabled(ItemStack stack) { + return ItemNBTHelper.getBoolean(stack, TAG_ENABLED, false); + } + + void setEnabled(ItemStack stack, boolean enabled) { + ItemNBTHelper.setBoolean(stack, TAG_ENABLED, enabled); + } + + public static void setMana(ItemStack stack, int mana) { + ItemNBTHelper.setInt(stack, TAG_MANA, mana); + } + + @Override + public int getMana(ItemStack stack) { + return getMana_(stack); + } + + public static int getMana_(ItemStack stack) { + return ItemNBTHelper.getInt(stack, TAG_MANA, 0); + } + + public static int getLevel(ItemStack stack) { + int mana = getMana_(stack); + for(int i = LEVELS.length - 1; i > 0; i--) + if(mana >= LEVELS[i]) + return i; + + return 0; + } + + @Override + public int getMaxMana(ItemStack stack) { + return MAX_MANA; + } + + @Override + public void addMana(ItemStack stack, int mana) { + setMana(stack, Math.min(getMana(stack) + mana, MAX_MANA)); + } + + @Override + public boolean canReceiveManaFromPool(ItemStack stack, TileEntity pool) { + return true; + } + + @Override + public boolean canReceiveManaFromItem(ItemStack stack, ItemStack otherStack) { + return !(otherStack.getItem() instanceof IManaGivingItem); + } + + @Override + public boolean canExportManaToPool(ItemStack stack, TileEntity pool) { + return false; + } + + @Override + public boolean canExportManaToItem(ItemStack stack, ItemStack otherStack) { + return false; + } + + @Override + public boolean isNoExport(ItemStack stack) { + return true; + } + + @Override + public boolean getIsRepairable(ItemStack par1ItemStack, ItemStack par2ItemStack) { + return par2ItemStack.getItem() == ModItems.manaResource && par2ItemStack.getItemDamage() == 4 ? true : super.getIsRepairable(par1ItemStack, par2ItemStack); + } + + @Override + public boolean disposeOfTrashBlocks(ItemStack stack) { + return isTipped(stack); + } + } diff --git a/src/main/java/vazkii/botania/common/item/equipment/tool/terrasteel/ItemTerraSword.java b/src/main/java/vazkii/botania/common/item/equipment/tool/terrasteel/ItemTerraSword.java index d8a654c40d..4865193ec5 100644 --- a/src/main/java/vazkii/botania/common/item/equipment/tool/terrasteel/ItemTerraSword.java +++ b/src/main/java/vazkii/botania/common/item/equipment/tool/terrasteel/ItemTerraSword.java @@ -2,15 +2,16 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Apr 14, 2014, 7:34:56 PM (GMT)] */ package vazkii.botania.common.item.equipment.tool.terrasteel; import java.util.List; + import net.minecraft.entity.Entity; import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.player.EntityPlayer; @@ -40,121 +41,106 @@ public class ItemTerraSword extends ItemManasteelSword implements ILensEffect, ICraftAchievement { - private static final String TAG_ATTACKER_USERNAME = "attackerUsername"; - - private static final int MANA_PER_DAMAGE = 100; - - public ItemTerraSword() { - super(BotaniaAPI.terrasteelToolMaterial, LibItemNames.TERRA_SWORD); - } - - @Override - public void onUpdate(ItemStack par1ItemStack, World par2World, Entity par3Entity, int par4, boolean par5) { - super.onUpdate(par1ItemStack, par2World, par3Entity, par4, par5); - if (par3Entity instanceof EntityPlayer) { - EntityPlayer player = (EntityPlayer) par3Entity; - PotionEffect haste = player.getActivePotionEffect(Potion.digSpeed); - float check = haste == null ? 0.16666667F : haste.getAmplifier() == 1 ? 0.5F : 0.4F; - - if (player.getCurrentEquippedItem() == par1ItemStack - && player.swingProgress == check - && !par2World.isRemote - && par2World.rand.nextInt(2) == 0) { - EntityManaBurst burst = getBurst(player, par1ItemStack); - par2World.spawnEntityInWorld(burst); - ToolCommons.damageItem(par1ItemStack, 1, player, MANA_PER_DAMAGE); - par2World.playSoundAtEntity(player, "botania:terraBlade", 0.4F, 1.4F); - } - } - } - - @Override - public int getManaPerDamage() { - return MANA_PER_DAMAGE; - } - - public EntityManaBurst getBurst(EntityPlayer player, ItemStack stack) { - EntityManaBurst burst = new EntityManaBurst(player); - - float motionModifier = 7F; - - burst.setColor(0x20FF20); - burst.setMana(MANA_PER_DAMAGE); - burst.setStartingMana(MANA_PER_DAMAGE); - burst.setMinManaLoss(40); - burst.setManaLossPerTick(4F); - burst.setGravity(0F); - burst.setMotion(burst.motionX * motionModifier, burst.motionY * motionModifier, burst.motionZ * motionModifier); - - ItemStack lens = stack.copy(); - ItemNBTHelper.setString(lens, TAG_ATTACKER_USERNAME, player.getCommandSenderName()); - burst.setSourceLens(lens); - return burst; - } - - @Override - public void apply(ItemStack stack, BurstProperties props) { - // NO-OP - } - - @Override - public boolean collideBurst( - IManaBurst burst, MovingObjectPosition pos, boolean isManaBlock, boolean dead, ItemStack stack) { - return dead; - } - - @Override - public void updateBurst(IManaBurst burst, ItemStack stack) { - EntityThrowable entity = (EntityThrowable) burst; - AxisAlignedBB axis = AxisAlignedBB.getBoundingBox( - entity.posX, - entity.posY, - entity.posZ, - entity.lastTickPosX, - entity.lastTickPosY, - entity.lastTickPosZ) - .expand(1, 1, 1); - List entities = entity.worldObj.getEntitiesWithinAABB(EntityLivingBase.class, axis); - String attacker = ItemNBTHelper.getString(burst.getSourceLens(), TAG_ATTACKER_USERNAME, ""); - - for (EntityLivingBase living : entities) { - if (living instanceof EntityPlayer - && (((EntityPlayer) living).getCommandSenderName().equals(attacker) - || MinecraftServer.getServer() != null - && !MinecraftServer.getServer().isPVPEnabled())) continue; - - if (living.hurtTime == 0) { - int cost = MANA_PER_DAMAGE / 3; - int mana = burst.getMana(); - if (mana >= cost) { - burst.setMana(mana - cost); - float damage = 4F + BotaniaAPI.terrasteelToolMaterial.getDamageVsEntity(); - if (!burst.isFake() && !entity.worldObj.isRemote) { - EntityPlayer player = living.worldObj.getPlayerEntityByName(attacker); - living.attackEntityFrom( - player == null ? DamageSource.magic : DamageSource.causePlayerDamage(player), damage); - entity.setDead(); - break; - } - } - } - } - } - - @Override - public boolean doParticles(IManaBurst burst, ItemStack stack) { - return true; - } - - @Override - public boolean getIsRepairable(ItemStack par1ItemStack, ItemStack par2ItemStack) { - return par2ItemStack.getItem() == ModItems.manaResource && par2ItemStack.getItemDamage() == 4 - ? true - : super.getIsRepairable(par1ItemStack, par2ItemStack); - } - - @Override - public Achievement getAchievementOnCraft(ItemStack stack, EntityPlayer player, IInventory matrix) { - return ModAchievements.terrasteelWeaponCraft; - } + private static final String TAG_ATTACKER_USERNAME = "attackerUsername"; + + private static final int MANA_PER_DAMAGE = 100; + + public ItemTerraSword() { + super(BotaniaAPI.terrasteelToolMaterial, LibItemNames.TERRA_SWORD); + } + + @Override + public void onUpdate(ItemStack par1ItemStack, World par2World, Entity par3Entity, int par4, boolean par5) { + super.onUpdate(par1ItemStack, par2World, par3Entity, par4, par5); + if(par3Entity instanceof EntityPlayer) { + EntityPlayer player = (EntityPlayer) par3Entity; + PotionEffect haste = player.getActivePotionEffect(Potion.digSpeed); + float check = haste == null ? 0.16666667F : haste.getAmplifier() == 1 ? 0.5F : 0.4F; + + if(player.getCurrentEquippedItem() == par1ItemStack && player.swingProgress == check && !par2World.isRemote && par2World.rand.nextInt(2) == 0) { + EntityManaBurst burst = getBurst(player, par1ItemStack); + par2World.spawnEntityInWorld(burst); + ToolCommons.damageItem(par1ItemStack, 1, player, MANA_PER_DAMAGE); + par2World.playSoundAtEntity(player, "botania:terraBlade", 0.4F, 1.4F); + } + } + } + + @Override + public int getManaPerDamage() { + return MANA_PER_DAMAGE; + } + + public EntityManaBurst getBurst(EntityPlayer player, ItemStack stack) { + EntityManaBurst burst = new EntityManaBurst(player); + + float motionModifier = 7F; + + burst.setColor(0x20FF20); + burst.setMana(MANA_PER_DAMAGE); + burst.setStartingMana(MANA_PER_DAMAGE); + burst.setMinManaLoss(40); + burst.setManaLossPerTick(4F); + burst.setGravity(0F); + burst.setMotion(burst.motionX * motionModifier, burst.motionY * motionModifier, burst.motionZ * motionModifier); + + ItemStack lens = stack.copy(); + ItemNBTHelper.setString(lens, TAG_ATTACKER_USERNAME, player.getCommandSenderName()); + burst.setSourceLens(lens); + return burst; + } + + @Override + public void apply(ItemStack stack, BurstProperties props) { + // NO-OP + } + + @Override + public boolean collideBurst(IManaBurst burst, MovingObjectPosition pos, boolean isManaBlock, boolean dead, ItemStack stack) { + return dead; + } + + @Override + public void updateBurst(IManaBurst burst, ItemStack stack) { + EntityThrowable entity = (EntityThrowable) burst; + AxisAlignedBB axis = AxisAlignedBB.getBoundingBox(entity.posX, entity.posY, entity.posZ, entity.lastTickPosX, entity.lastTickPosY, entity.lastTickPosZ).expand(1, 1, 1); + List entities = entity.worldObj.getEntitiesWithinAABB(EntityLivingBase.class, axis); + String attacker = ItemNBTHelper.getString(burst.getSourceLens(), TAG_ATTACKER_USERNAME, ""); + + for(EntityLivingBase living : entities) { + if(living instanceof EntityPlayer && (((EntityPlayer) living).getCommandSenderName().equals(attacker) || MinecraftServer.getServer() != null && !MinecraftServer.getServer().isPVPEnabled())) + continue; + + if(living.hurtTime == 0) { + int cost = MANA_PER_DAMAGE / 3; + int mana = burst.getMana(); + if(mana >= cost) { + burst.setMana(mana - cost); + float damage = 4F + BotaniaAPI.terrasteelToolMaterial.getDamageVsEntity(); + if(!burst.isFake() && !entity.worldObj.isRemote) { + EntityPlayer player = living.worldObj.getPlayerEntityByName(attacker); + living.attackEntityFrom(player == null ? DamageSource.magic : DamageSource.causePlayerDamage(player), damage); + entity.setDead(); + break; + } + } + } + } + } + + @Override + public boolean doParticles(IManaBurst burst, ItemStack stack) { + return true; + } + + @Override + public boolean getIsRepairable(ItemStack par1ItemStack, ItemStack par2ItemStack) { + return par2ItemStack.getItem() == ModItems.manaResource && par2ItemStack.getItemDamage() == 4 ? true : super.getIsRepairable(par1ItemStack, par2ItemStack); + } + + @Override + public Achievement getAchievementOnCraft(ItemStack stack, EntityPlayer player, IInventory matrix) { + return ModAchievements.terrasteelWeaponCraft; + } + } diff --git a/src/main/java/vazkii/botania/common/item/interaction/thaumcraft/ItemElementiumHelmRevealing.java b/src/main/java/vazkii/botania/common/item/interaction/thaumcraft/ItemElementiumHelmRevealing.java index f47eae9e58..7fdb8e56c3 100644 --- a/src/main/java/vazkii/botania/common/item/interaction/thaumcraft/ItemElementiumHelmRevealing.java +++ b/src/main/java/vazkii/botania/common/item/interaction/thaumcraft/ItemElementiumHelmRevealing.java @@ -2,15 +2,14 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jul 28, 2014, 6:16:24 PM (GMT)] */ package vazkii.botania.common.item.interaction.thaumcraft; -import cpw.mods.fml.common.Optional; import net.minecraft.entity.EntityLivingBase; import net.minecraft.item.ItemStack; import thaumcraft.api.IGoggles; @@ -19,29 +18,30 @@ import vazkii.botania.common.core.handler.ConfigHandler; import vazkii.botania.common.item.equipment.armor.elementium.ItemElementiumHelm; import vazkii.botania.common.lib.LibItemNames; +import cpw.mods.fml.common.Optional; @Optional.InterfaceList({ - @Optional.Interface(modid = "Thaumcraft", iface = "thaumcraft.api.IGoggles", striprefs = true), - @Optional.Interface(modid = "Thaumcraft", iface = "thaumcraft.api.nodes.IRevealer", striprefs = true) -}) + @Optional.Interface(modid = "Thaumcraft", iface = "thaumcraft.api.IGoggles", striprefs = true), + @Optional.Interface(modid = "Thaumcraft", iface = "thaumcraft.api.nodes.IRevealer", striprefs = true)}) public class ItemElementiumHelmRevealing extends ItemElementiumHelm implements IGoggles, IRevealer { - public ItemElementiumHelmRevealing() { - super(LibItemNames.ELEMENTIUM_HELM_R); - } + public ItemElementiumHelmRevealing() { + super(LibItemNames.ELEMENTIUM_HELM_R); + } + + @Override + public boolean showNodes(ItemStack itemstack, EntityLivingBase player) { + return true; + } - @Override - public boolean showNodes(ItemStack itemstack, EntityLivingBase player) { - return true; - } + @Override + public boolean showIngamePopups(ItemStack itemstack, EntityLivingBase player) { + return true; + } - @Override - public boolean showIngamePopups(ItemStack itemstack, EntityLivingBase player) { - return true; - } + @Override + public String getArmorTextureAfterInk(ItemStack stack, int slot) { + return ConfigHandler.enableArmorModels ? LibResources.MODEL_ELEMENTIUM_NEW : LibResources.MODEL_ELEMENTIUM_2; + } - @Override - public String getArmorTextureAfterInk(ItemStack stack, int slot) { - return ConfigHandler.enableArmorModels ? LibResources.MODEL_ELEMENTIUM_NEW : LibResources.MODEL_ELEMENTIUM_2; - } } diff --git a/src/main/java/vazkii/botania/common/item/interaction/thaumcraft/ItemManaInkwell.java b/src/main/java/vazkii/botania/common/item/interaction/thaumcraft/ItemManaInkwell.java index 28740d4b1f..b7c1cea9f6 100644 --- a/src/main/java/vazkii/botania/common/item/interaction/thaumcraft/ItemManaInkwell.java +++ b/src/main/java/vazkii/botania/common/item/interaction/thaumcraft/ItemManaInkwell.java @@ -2,16 +2,16 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Sep 26, 2014, 5:39:07 PM (GMT)] */ package vazkii.botania.common.item.interaction.thaumcraft; -import cpw.mods.fml.common.Optional; import java.util.List; + import net.minecraft.creativetab.CreativeTabs; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; @@ -22,101 +22,103 @@ import vazkii.botania.common.core.helper.ItemNBTHelper; import vazkii.botania.common.item.ItemMod; import vazkii.botania.common.lib.LibItemNames; +import cpw.mods.fml.common.Optional; @Optional.Interface(modid = "Thaumcraft", iface = "thaumcraft.api.IScribeTools") public class ItemManaInkwell extends ItemMod implements IManaItem, IScribeTools { - private static final int COST_PER_USE = 50; - private static final int USES = 150; - protected static final int MAX_MANA = COST_PER_USE * USES; - - private static final String TAG_MANA = "mana"; - - public ItemManaInkwell() { - setUnlocalizedName(LibItemNames.MANA_INKWELL); - setMaxDamage(USES); - setMaxStackSize(1); - setNoRepair(); - } - - @Override - public void getSubItems(Item item, CreativeTabs tab, List list) { - list.add(new ItemStack(item, 1, USES)); - list.add(new ItemStack(item)); - } - - @Override - public int getDamage(ItemStack stack) { - float mana = getMana(stack); - return USES - (int) (mana / getMaxMana(stack) * USES); - } - - @Override - public void setDamage(ItemStack stack, int damage) { - int currentDamage = stack.getItemDamage(); - if (damage > currentDamage) { - int cost = (damage - currentDamage) * COST_PER_USE; - int mana = getMana(stack); - if (mana >= cost) { - addMana(stack, -cost); - return; - } - } - super.setDamage(stack, damage); - } - - @Override - public int getDisplayDamage(ItemStack stack) { - return getDamage(stack); - } - - @Override - public int getEntityLifespan(ItemStack itemStack, World world) { - return Integer.MAX_VALUE; - } - - public static void setMana(ItemStack stack, int mana) { - ItemNBTHelper.setInt(stack, TAG_MANA, mana); - } - - @Override - public int getMana(ItemStack stack) { - return ItemNBTHelper.getInt(stack, TAG_MANA, 0); - } - - @Override - public int getMaxMana(ItemStack stack) { - return MAX_MANA; - } - - @Override - public void addMana(ItemStack stack, int mana) { - setMana(stack, Math.min(getMana(stack) + mana, getMaxMana(stack))); - stack.setItemDamage(getDamage(stack)); - } - - @Override - public boolean canReceiveManaFromPool(ItemStack stack, TileEntity pool) { - return true; - } - - @Override - public boolean canReceiveManaFromItem(ItemStack stack, ItemStack otherStack) { - return false; - } - - @Override - public boolean canExportManaToPool(ItemStack stack, TileEntity pool) { - return false; - } - - @Override - public boolean canExportManaToItem(ItemStack stack, ItemStack otherStack) { - return false; - } - - @Override - public boolean isNoExport(ItemStack stack) { - return true; - } + private static final int COST_PER_USE = 50; + private static final int USES = 150; + protected static final int MAX_MANA = COST_PER_USE * USES; + + private static final String TAG_MANA = "mana"; + + public ItemManaInkwell() { + setUnlocalizedName(LibItemNames.MANA_INKWELL); + setMaxDamage(USES); + setMaxStackSize(1); + setNoRepair(); + } + + @Override + public void getSubItems(Item item, CreativeTabs tab, List list) { + list.add(new ItemStack(item, 1, USES)); + list.add(new ItemStack(item)); + } + + @Override + public int getDamage(ItemStack stack) { + float mana = getMana(stack); + return USES - (int) (mana / getMaxMana(stack) * USES); + } + + @Override + public void setDamage(ItemStack stack, int damage) { + int currentDamage = stack.getItemDamage(); + if(damage > currentDamage) { + int cost = (damage - currentDamage) * COST_PER_USE; + int mana = getMana(stack); + if(mana >= cost) { + addMana(stack, -cost); + return; + } + } + super.setDamage(stack, damage); + } + + @Override + public int getDisplayDamage(ItemStack stack) { + return getDamage(stack); + } + + @Override + public int getEntityLifespan(ItemStack itemStack, World world) { + return Integer.MAX_VALUE; + } + + public static void setMana(ItemStack stack, int mana) { + ItemNBTHelper.setInt(stack, TAG_MANA, mana); + } + + @Override + public int getMana(ItemStack stack) { + return ItemNBTHelper.getInt(stack, TAG_MANA, 0); + } + + @Override + public int getMaxMana(ItemStack stack) { + return MAX_MANA; + } + + @Override + public void addMana(ItemStack stack, int mana) { + setMana(stack, Math.min(getMana(stack) + mana, getMaxMana(stack))); + stack.setItemDamage(getDamage(stack)); + } + + @Override + public boolean canReceiveManaFromPool(ItemStack stack, TileEntity pool) { + return true; + } + + @Override + public boolean canReceiveManaFromItem(ItemStack stack, ItemStack otherStack) { + return false; + } + + @Override + public boolean canExportManaToPool(ItemStack stack, TileEntity pool) { + return false; + } + + @Override + public boolean canExportManaToItem(ItemStack stack, ItemStack otherStack) { + return false; + } + + @Override + public boolean isNoExport(ItemStack stack) { + return true; + } + } diff --git a/src/main/java/vazkii/botania/common/item/interaction/thaumcraft/ItemManasteelHelmRevealing.java b/src/main/java/vazkii/botania/common/item/interaction/thaumcraft/ItemManasteelHelmRevealing.java index e36c476404..dd9b80dea8 100644 --- a/src/main/java/vazkii/botania/common/item/interaction/thaumcraft/ItemManasteelHelmRevealing.java +++ b/src/main/java/vazkii/botania/common/item/interaction/thaumcraft/ItemManasteelHelmRevealing.java @@ -2,16 +2,14 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jul 28, 2014, 6:18:05 PM (GMT)] */ package vazkii.botania.common.item.interaction.thaumcraft; -import cpw.mods.fml.common.Optional; -import cpw.mods.fml.common.registry.GameRegistry; import net.minecraft.entity.EntityLivingBase; import net.minecraft.item.ItemStack; import net.minecraftforge.oredict.RecipeSorter; @@ -23,33 +21,33 @@ import vazkii.botania.common.crafting.recipe.HelmRevealingRecipe; import vazkii.botania.common.item.equipment.armor.manasteel.ItemManasteelHelm; import vazkii.botania.common.lib.LibItemNames; +import cpw.mods.fml.common.Optional; +import cpw.mods.fml.common.registry.GameRegistry; @Optional.InterfaceList({ - @Optional.Interface(modid = "Thaumcraft", iface = "thaumcraft.api.IGoggles", striprefs = true), - @Optional.Interface(modid = "Thaumcraft", iface = "thaumcraft.api.nodes.IRevealer", striprefs = true) -}) + @Optional.Interface(modid = "Thaumcraft", iface = "thaumcraft.api.IGoggles", striprefs = true), + @Optional.Interface(modid = "Thaumcraft", iface = "thaumcraft.api.nodes.IRevealer", striprefs = true)}) public class ItemManasteelHelmRevealing extends ItemManasteelHelm implements IGoggles, IRevealer { - public ItemManasteelHelmRevealing() { - super(LibItemNames.MANASTEEL_HELM_R); - GameRegistry.addRecipe( - new HelmRevealingRecipe()); // Manasteel is the base so it gets the recipe added in its constructor so - // that ModItems can call it - RecipeSorter.register("botania:helmRevealing", HelmRevealingRecipe.class, Category.SHAPELESS, ""); - } + public ItemManasteelHelmRevealing() { + super(LibItemNames.MANASTEEL_HELM_R); + GameRegistry.addRecipe(new HelmRevealingRecipe()); //Manasteel is the base so it gets the recipe added in its constructor so that ModItems can call it + RecipeSorter.register("botania:helmRevealing", HelmRevealingRecipe.class, Category.SHAPELESS, ""); + } + + @Override + public boolean showNodes(ItemStack itemstack, EntityLivingBase player) { + return true; + } - @Override - public boolean showNodes(ItemStack itemstack, EntityLivingBase player) { - return true; - } + @Override + public boolean showIngamePopups(ItemStack itemstack, EntityLivingBase player) { + return true; + } - @Override - public boolean showIngamePopups(ItemStack itemstack, EntityLivingBase player) { - return true; - } + @Override + public String getArmorTextureAfterInk(ItemStack stack, int slot) { + return ConfigHandler.enableArmorModels ? LibResources.MODEL_MANASTEEL_NEW : LibResources.MODEL_MANASTEEL_2; + } - @Override - public String getArmorTextureAfterInk(ItemStack stack, int slot) { - return ConfigHandler.enableArmorModels ? LibResources.MODEL_MANASTEEL_NEW : LibResources.MODEL_MANASTEEL_2; - } -} +} \ No newline at end of file diff --git a/src/main/java/vazkii/botania/common/item/interaction/thaumcraft/ItemTerrasteelHelmRevealing.java b/src/main/java/vazkii/botania/common/item/interaction/thaumcraft/ItemTerrasteelHelmRevealing.java index 9634961dbb..c266bfad02 100644 --- a/src/main/java/vazkii/botania/common/item/interaction/thaumcraft/ItemTerrasteelHelmRevealing.java +++ b/src/main/java/vazkii/botania/common/item/interaction/thaumcraft/ItemTerrasteelHelmRevealing.java @@ -2,15 +2,14 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jul 28, 2014, 6:22:51 PM (GMT)] */ package vazkii.botania.common.item.interaction.thaumcraft; -import cpw.mods.fml.common.Optional; import net.minecraft.entity.EntityLivingBase; import net.minecraft.item.ItemStack; import thaumcraft.api.IGoggles; @@ -19,29 +18,30 @@ import vazkii.botania.common.core.handler.ConfigHandler; import vazkii.botania.common.item.equipment.armor.terrasteel.ItemTerrasteelHelm; import vazkii.botania.common.lib.LibItemNames; +import cpw.mods.fml.common.Optional; @Optional.InterfaceList({ - @Optional.Interface(modid = "Thaumcraft", iface = "thaumcraft.api.IGoggles", striprefs = true), - @Optional.Interface(modid = "Thaumcraft", iface = "thaumcraft.api.nodes.IRevealer", striprefs = true) -}) + @Optional.Interface(modid = "Thaumcraft", iface = "thaumcraft.api.IGoggles", striprefs = true), + @Optional.Interface(modid = "Thaumcraft", iface = "thaumcraft.api.nodes.IRevealer", striprefs = true)}) public class ItemTerrasteelHelmRevealing extends ItemTerrasteelHelm implements IGoggles, IRevealer { - public ItemTerrasteelHelmRevealing() { - super(LibItemNames.TERRASTEEL_HELM_R); - } + public ItemTerrasteelHelmRevealing() { + super(LibItemNames.TERRASTEEL_HELM_R); + } + + @Override + public boolean showNodes(ItemStack itemstack, EntityLivingBase player) { + return true; + } - @Override - public boolean showNodes(ItemStack itemstack, EntityLivingBase player) { - return true; - } + @Override + public boolean showIngamePopups(ItemStack itemstack, EntityLivingBase player) { + return true; + } - @Override - public boolean showIngamePopups(ItemStack itemstack, EntityLivingBase player) { - return true; - } + @Override + public String getArmorTextureAfterInk(ItemStack stack, int slot) { + return ConfigHandler.enableArmorModels ? LibResources.MODEL_TERRASTEEL_NEW : LibResources.MODEL_TERRASTEEL_2; + } - @Override - public String getArmorTextureAfterInk(ItemStack stack, int slot) { - return ConfigHandler.enableArmorModels ? LibResources.MODEL_TERRASTEEL_NEW : LibResources.MODEL_TERRASTEEL_2; - } -} +} \ No newline at end of file diff --git a/src/main/java/vazkii/botania/common/item/lens/ItemLens.java b/src/main/java/vazkii/botania/common/item/lens/ItemLens.java index 335cbcda8a..5c58ed735d 100644 --- a/src/main/java/vazkii/botania/common/item/lens/ItemLens.java +++ b/src/main/java/vazkii/botania/common/item/lens/ItemLens.java @@ -2,17 +2,17 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jan 31, 2014, 3:02:58 PM (GMT)] */ package vazkii.botania.common.item.lens; -import cpw.mods.fml.common.registry.GameRegistry; import java.awt.Color; import java.util.List; + import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.entity.passive.EntitySheep; @@ -40,327 +40,332 @@ import vazkii.botania.common.crafting.recipe.LensDyeingRecipe; import vazkii.botania.common.item.ItemMod; import vazkii.botania.common.lib.LibItemNames; +import cpw.mods.fml.common.registry.GameRegistry; public class ItemLens extends ItemMod implements ILensControl, ICompositableLens, ITinyPlanetExcempt { - public static final int SUBTYPES = 22; - - public static final int NORMAL = 0, - SPEED = 1, - POWER = 2, - TIME = 3, - EFFICIENCY = 4, - BOUNCE = 5, - GRAVITY = 6, - MINE = 7, - DAMAGE = 8, - PHANTOM = 9, - MAGNET = 10, - EXPLOSIVE = 11, - INFLUENCE = 12, - WEIGHT = 13, - PAINT = 14, - FIRE = 15, - PISTON = 16, - LIGHT = 17, - WARP = 18, - REDIRECT = 19, - FIREWORK = 20, - FLARE = 21; - - public static final int STORM = 5000; - - private static final int PROP_NONE = 0, - PROP_POWER = 1, - PROP_ORIENTATION = 1 << 1, - PROP_TOUCH = 1 << 2, - PROP_INTERACTION = 1 << 3, - PROP_DAMAGE = 1 << 4, - PROP_CONTROL = 1 << 5; - - private static final int[] props = new int[SUBTYPES]; - private static final Lens[] lenses = new Lens[SUBTYPES]; - private static Lens fallbackLens = new Lens(); - private static Lens stormLens = new LensStorm(); - - static { - setProps(NORMAL, PROP_NONE); - setProps(SPEED, PROP_NONE); - setProps(POWER, PROP_POWER); - setProps(TIME, PROP_NONE); - setProps(EFFICIENCY, PROP_NONE); - setProps(BOUNCE, PROP_TOUCH); - setProps(GRAVITY, PROP_ORIENTATION); - setProps(MINE, PROP_TOUCH | PROP_INTERACTION); - setProps(DAMAGE, PROP_DAMAGE); - setProps(PHANTOM, PROP_TOUCH); - setProps(MAGNET, PROP_ORIENTATION); - setProps(EXPLOSIVE, PROP_DAMAGE | PROP_TOUCH | PROP_INTERACTION); - setProps(INFLUENCE, PROP_NONE); - setProps(WEIGHT, PROP_TOUCH | PROP_INTERACTION); - setProps(PAINT, PROP_TOUCH | PROP_INTERACTION); - setProps(FIRE, PROP_DAMAGE | PROP_TOUCH | PROP_INTERACTION); - setProps(PISTON, PROP_TOUCH | PROP_INTERACTION); - setProps(LIGHT, PROP_TOUCH | PROP_INTERACTION); - setProps(WARP, PROP_NONE); - setProps(REDIRECT, PROP_TOUCH | PROP_INTERACTION); - setProps(FIREWORK, PROP_TOUCH); - setProps(FLARE, PROP_CONTROL); - - setLens(NORMAL, fallbackLens); - setLens(SPEED, new LensSpeed()); - setLens(POWER, new LensPower()); - setLens(TIME, new LensTime()); - setLens(EFFICIENCY, new LensEfficiency()); - setLens(BOUNCE, new LensBounce()); - setLens(GRAVITY, new LensGravity()); - setLens(MINE, new LensMine()); - setLens(DAMAGE, new LensDamage()); - setLens(PHANTOM, new LensPhantom()); - setLens(MAGNET, new LensMagnet()); - setLens(EXPLOSIVE, new LensExplosive()); - setLens(INFLUENCE, new LensInfluence()); - setLens(WEIGHT, new LensWeight()); - setLens(PAINT, new LensPaint()); - setLens(FIRE, new LensFire()); - setLens(PISTON, new LensPiston()); - setLens(LIGHT, new LensLight()); - setLens(WARP, new LensWarp()); - setLens(REDIRECT, new LensRedirect()); - setLens(FIREWORK, new LensFirework()); - setLens(FLARE, new LensFlare()); - } - - private static final String TAG_COLOR = "color"; - private static final String TAG_COMPOSITE_LENS = "compositeLens"; - - public static IIcon iconGlass; - - IIcon[] ringIcons; - - public ItemLens() { - super(); - setUnlocalizedName(LibItemNames.LENS); - setMaxStackSize(1); - setHasSubtypes(true); - - GameRegistry.addRecipe(new CompositeLensRecipe()); - GameRegistry.addRecipe(new LensDyeingRecipe()); - RecipeSorter.register("botania:compositeLens", CompositeLensRecipe.class, Category.SHAPELESS, ""); - RecipeSorter.register("botania:lensDying", LensDyeingRecipe.class, Category.SHAPELESS, ""); - } - - @Override - public void registerIcons(IIconRegister par1IconRegister) { - iconGlass = IconHelper.forName(par1IconRegister, "lensInside"); - - ringIcons = new IIcon[SUBTYPES]; - for (int i = 0; i < ringIcons.length; i++) - ringIcons[i] = IconHelper.forName(par1IconRegister, LibItemNames.LENS_NAMES[i]); - } - - @Override - public void getSubItems(Item par1, CreativeTabs par2CreativeTabs, List par3List) { - for (int i = 0; i < SUBTYPES; i++) par3List.add(new ItemStack(par1, 1, i)); - } - - @Override - public boolean requiresMultipleRenderPasses() { - return true; - } - - @Override - public IIcon getIconFromDamageForRenderPass(int par1, int par2) { - return par2 == 1 ? ringIcons[Math.min(SUBTYPES - 1, par1)] : iconGlass; - } - - @Override - public IIcon getIconFromDamage(int par1) { - return getIconFromDamageForRenderPass(par1, 0); - } - - @Override - public int getColorFromItemStack(ItemStack par1ItemStack, int par2) { - return par2 == 0 ? getLensColor(par1ItemStack) : 0xFFFFFF; - } - - @Override - public String getUnlocalizedName(ItemStack par1ItemStack) { - return "item." + LibItemNames.LENS_NAMES[Math.min(SUBTYPES - 1, par1ItemStack.getItemDamage())]; - } - - @Override - public void addInformation(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, List par3List, boolean par4) { - int storedColor = getStoredColor(par1ItemStack); - if (storedColor != -1) - par3List.add(String.format( - StatCollector.translateToLocal("botaniamisc.color"), - StatCollector.translateToLocal("botania.color" + storedColor))); - } - - public String getItemShortTermName(ItemStack stack) { - return StatCollector.translateToLocal( - stack.getUnlocalizedName().replaceAll("item.", "item.botania:") + ".short"); - } - - @Override - public String getItemStackDisplayName(ItemStack stack) { - ItemStack compositeLens = getCompositeLens(stack); - if (compositeLens == null) return super.getItemStackDisplayName(stack); - return String.format( - StatCollector.translateToLocal("item.botania:compositeLens.name"), - getItemShortTermName(stack), - getItemShortTermName(compositeLens)); - } - - @Override - public void apply(ItemStack stack, BurstProperties props) { - int storedColor = getStoredColor(stack); - if (storedColor != -1) props.color = getLensColor(stack); - - getLens(stack.getItemDamage()).apply(stack, props); - - ItemStack compositeLens = getCompositeLens(stack); - if (compositeLens != null && compositeLens.getItem() instanceof ILens) - ((ILens) compositeLens.getItem()).apply(compositeLens, props); - } - - @Override - public boolean collideBurst( - IManaBurst burst, MovingObjectPosition pos, boolean isManaBlock, boolean dead, ItemStack stack) { - EntityThrowable entity = (EntityThrowable) burst; - - dead = getLens(stack.getItemDamage()).collideBurst(burst, entity, pos, isManaBlock, dead, stack); - - ItemStack compositeLens = getCompositeLens(stack); - if (compositeLens != null && compositeLens.getItem() instanceof ILens) - dead = ((ILens) compositeLens.getItem()).collideBurst(burst, pos, isManaBlock, dead, compositeLens); - - return dead; - } - - @Override - public void updateBurst(IManaBurst burst, ItemStack stack) { - EntityThrowable entity = (EntityThrowable) burst; - int storedColor = getStoredColor(stack); - - if (storedColor == 16 && entity.worldObj.isRemote) burst.setColor(getLensColor(stack)); - - getLens(stack.getItemDamage()).updateBurst(burst, entity, stack); - - ItemStack compositeLens = getCompositeLens(stack); - if (compositeLens != null && compositeLens.getItem() instanceof ILens) - ((ILens) compositeLens.getItem()).updateBurst(burst, compositeLens); - } - - @Override - public int getLensColor(ItemStack stack) { - int storedColor = getStoredColor(stack); - - if (storedColor == -1) return 0xFFFFFF; - - if (storedColor == 16) return Color.HSBtoRGB(Botania.proxy.getWorldElapsedTicks() * 2 % 360 / 360F, 1F, 1F); - - float[] color = EntitySheep.fleeceColorTable[storedColor]; - return new Color(color[0], color[1], color[2]).getRGB(); - } - - public static int getStoredColor(ItemStack stack) { - return ItemNBTHelper.getInt(stack, TAG_COLOR, -1); - } - - public static ItemStack setLensColor(ItemStack stack, int color) { - ItemNBTHelper.setInt(stack, TAG_COLOR, color); - return stack; - } - - @Override - public boolean doParticles(IManaBurst burst, ItemStack stack) { - return true; - } - - public static void setProps(int lens, int props_) { - props[lens] = props_; - } - - public static void setLens(int index, Lens lens) { - lenses[index] = lens; - } - - public static boolean isBlacklisted(ItemStack lens1, ItemStack lens2) { - ICompositableLens item1 = (ICompositableLens) lens1.getItem(); - ICompositableLens item2 = (ICompositableLens) lens2.getItem(); - return (item1.getProps(lens1) & item2.getProps(lens2)) != 0; - } - - public static Lens getLens(int index) { - if (index == STORM) return stormLens; - - Lens lens = lenses[index]; - return lens == null ? fallbackLens : lens; - } - - @Override - public boolean canCombineLenses(ItemStack sourceLens, ItemStack compositeLens) { - ICompositableLens sourceItem = (ICompositableLens) sourceLens.getItem(); - ICompositableLens compositeItem = (ICompositableLens) compositeLens.getItem(); - if (sourceItem == compositeItem && sourceLens.getItemDamage() == compositeLens.getItemDamage()) return false; - - if (!sourceItem.isCombinable(sourceLens) || !compositeItem.isCombinable(compositeLens)) return false; - - if (isBlacklisted(sourceLens, compositeLens)) return false; - - return true; - } - - @Override - public ItemStack getCompositeLens(ItemStack stack) { - NBTTagCompound cmp = ItemNBTHelper.getCompound(stack, TAG_COMPOSITE_LENS, false); - ItemStack lens = ItemStack.loadItemStackFromNBT(cmp); - return lens; - } - - @Override - public ItemStack setCompositeLens(ItemStack sourceLens, ItemStack compositeLens) { - NBTTagCompound cmp = new NBTTagCompound(); - compositeLens.writeToNBT(cmp); - ItemNBTHelper.setCompound(sourceLens, TAG_COMPOSITE_LENS, cmp); - - return sourceLens; - } - - @Override - public boolean shouldPull(ItemStack stack) { - return stack.getItemDamage() != STORM; - } - - @Override - public boolean isControlLens(ItemStack stack) { - return (getProps(stack) & PROP_CONTROL) != 0; - } - - @Override - public boolean allowBurstShooting(ItemStack stack, IManaSpreader spreader, boolean redstone) { - return lenses[stack.getItemDamage()].allowBurstShooting(stack, spreader, redstone); - } - - @Override - public void onControlledSpreaderTick(ItemStack stack, IManaSpreader spreader, boolean redstone) { - lenses[stack.getItemDamage()].onControlledSpreaderTick(stack, spreader, redstone); - } - - @Override - public void onControlledSpreaderPulse(ItemStack stack, IManaSpreader spreader, boolean redstone) { - lenses[stack.getItemDamage()].onControlledSpreaderPulse(stack, spreader, redstone); - } - - @Override - public int getProps(ItemStack stack) { - return props[stack.getItemDamage()]; - } - - @Override - public boolean isCombinable(ItemStack stack) { - return stack.getItemDamage() != NORMAL; - } + public static final int SUBTYPES = 22; + + public static final int NORMAL = 0, + SPEED = 1, + POWER = 2, + TIME = 3, + EFFICIENCY = 4, + BOUNCE = 5, + GRAVITY = 6, + MINE = 7, + DAMAGE = 8, + PHANTOM = 9, + MAGNET = 10, + EXPLOSIVE = 11, + INFLUENCE = 12, + WEIGHT = 13, + PAINT = 14, + FIRE = 15, + PISTON = 16, + LIGHT = 17, + WARP = 18, + REDIRECT = 19, + FIREWORK = 20, + FLARE = 21; + + public static final int STORM = 5000; + + private static final int PROP_NONE = 0, + PROP_POWER = 1, + PROP_ORIENTATION = 1 << 1, + PROP_TOUCH = 1 << 2, + PROP_INTERACTION = 1 << 3, + PROP_DAMAGE = 1 << 4, + PROP_CONTROL = 1 << 5; + + private static final int[] props = new int[SUBTYPES]; + private static final Lens[] lenses = new Lens[SUBTYPES]; + private static Lens fallbackLens = new Lens(); + private static Lens stormLens = new LensStorm(); + + static { + setProps(NORMAL, PROP_NONE); + setProps(SPEED, PROP_NONE); + setProps(POWER, PROP_POWER); + setProps(TIME, PROP_NONE); + setProps(EFFICIENCY, PROP_NONE); + setProps(BOUNCE, PROP_TOUCH); + setProps(GRAVITY, PROP_ORIENTATION); + setProps(MINE, PROP_TOUCH | PROP_INTERACTION); + setProps(DAMAGE, PROP_DAMAGE); + setProps(PHANTOM, PROP_TOUCH); + setProps(MAGNET, PROP_ORIENTATION); + setProps(EXPLOSIVE, PROP_DAMAGE | PROP_TOUCH | PROP_INTERACTION); + setProps(INFLUENCE, PROP_NONE); + setProps(WEIGHT, PROP_TOUCH | PROP_INTERACTION); + setProps(PAINT, PROP_TOUCH | PROP_INTERACTION); + setProps(FIRE, PROP_DAMAGE | PROP_TOUCH | PROP_INTERACTION); + setProps(PISTON, PROP_TOUCH | PROP_INTERACTION); + setProps(LIGHT, PROP_TOUCH | PROP_INTERACTION); + setProps(WARP, PROP_NONE); + setProps(REDIRECT, PROP_TOUCH | PROP_INTERACTION); + setProps(FIREWORK, PROP_TOUCH); + setProps(FLARE, PROP_CONTROL); + + setLens(NORMAL, fallbackLens); + setLens(SPEED, new LensSpeed()); + setLens(POWER, new LensPower()); + setLens(TIME, new LensTime()); + setLens(EFFICIENCY, new LensEfficiency()); + setLens(BOUNCE, new LensBounce()); + setLens(GRAVITY, new LensGravity()); + setLens(MINE, new LensMine()); + setLens(DAMAGE, new LensDamage()); + setLens(PHANTOM, new LensPhantom()); + setLens(MAGNET, new LensMagnet()); + setLens(EXPLOSIVE, new LensExplosive()); + setLens(INFLUENCE, new LensInfluence()); + setLens(WEIGHT, new LensWeight()); + setLens(PAINT, new LensPaint()); + setLens(FIRE, new LensFire()); + setLens(PISTON, new LensPiston()); + setLens(LIGHT, new LensLight()); + setLens(WARP, new LensWarp()); + setLens(REDIRECT, new LensRedirect()); + setLens(FIREWORK, new LensFirework()); + setLens(FLARE, new LensFlare()); + } + + private static final String TAG_COLOR = "color"; + private static final String TAG_COMPOSITE_LENS = "compositeLens"; + + public static IIcon iconGlass; + + IIcon[] ringIcons; + + public ItemLens() { + super(); + setUnlocalizedName(LibItemNames.LENS); + setMaxStackSize(1); + setHasSubtypes(true); + + GameRegistry.addRecipe(new CompositeLensRecipe()); + GameRegistry.addRecipe(new LensDyeingRecipe()); + RecipeSorter.register("botania:compositeLens", CompositeLensRecipe.class, Category.SHAPELESS, ""); + RecipeSorter.register("botania:lensDying", LensDyeingRecipe.class, Category.SHAPELESS, ""); + } + + @Override + public void registerIcons(IIconRegister par1IconRegister) { + iconGlass = IconHelper.forName(par1IconRegister, "lensInside"); + + ringIcons = new IIcon[SUBTYPES]; + for(int i = 0; i < ringIcons.length; i++) + ringIcons[i] = IconHelper.forName(par1IconRegister, LibItemNames.LENS_NAMES[i]); + } + + @Override + public void getSubItems(Item par1, CreativeTabs par2CreativeTabs, List par3List) { + for(int i = 0; i < SUBTYPES; i++) + par3List.add(new ItemStack(par1, 1, i)); + } + + @Override + public boolean requiresMultipleRenderPasses() { + return true; + } + + @Override + public IIcon getIconFromDamageForRenderPass(int par1, int par2) { + return par2 == 1 ? ringIcons[Math.min(SUBTYPES - 1, par1)] : iconGlass; + } + + @Override + public IIcon getIconFromDamage(int par1) { + return getIconFromDamageForRenderPass(par1, 0); + } + + @Override + public int getColorFromItemStack(ItemStack par1ItemStack, int par2) { + return par2 == 0 ? getLensColor(par1ItemStack) : 0xFFFFFF; + } + + @Override + public String getUnlocalizedName(ItemStack par1ItemStack) { + return "item." + LibItemNames.LENS_NAMES[Math.min(SUBTYPES - 1, par1ItemStack.getItemDamage())]; + } + + @Override + public void addInformation(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, List par3List, boolean par4) { + int storedColor = getStoredColor(par1ItemStack); + if(storedColor != -1) + par3List.add(String.format(StatCollector.translateToLocal("botaniamisc.color"), StatCollector.translateToLocal("botania.color" + storedColor))); + } + + + public String getItemShortTermName(ItemStack stack) { + return StatCollector.translateToLocal(stack.getUnlocalizedName().replaceAll("item.", "item.botania:") + ".short"); + } + + @Override + public String getItemStackDisplayName(ItemStack stack) { + ItemStack compositeLens = getCompositeLens(stack); + if(compositeLens == null) + return super.getItemStackDisplayName(stack); + return String.format(StatCollector.translateToLocal("item.botania:compositeLens.name"), getItemShortTermName(stack), getItemShortTermName(compositeLens)); + } + + @Override + public void apply(ItemStack stack, BurstProperties props) { + int storedColor = getStoredColor(stack); + if(storedColor != -1) + props.color = getLensColor(stack); + + getLens(stack.getItemDamage()).apply(stack, props); + + ItemStack compositeLens = getCompositeLens(stack); + if(compositeLens != null && compositeLens.getItem() instanceof ILens) + ((ILens) compositeLens.getItem()).apply(compositeLens, props); + } + + @Override + public boolean collideBurst(IManaBurst burst, MovingObjectPosition pos, boolean isManaBlock, boolean dead, ItemStack stack) { + EntityThrowable entity = (EntityThrowable) burst; + + dead = getLens(stack.getItemDamage()).collideBurst(burst, entity, pos, isManaBlock, dead, stack); + + ItemStack compositeLens = getCompositeLens(stack); + if(compositeLens != null && compositeLens.getItem() instanceof ILens) + dead = ((ILens) compositeLens.getItem()).collideBurst(burst, pos, isManaBlock, dead, compositeLens); + + return dead; + } + + @Override + public void updateBurst(IManaBurst burst, ItemStack stack) { + EntityThrowable entity = (EntityThrowable) burst; + int storedColor = getStoredColor(stack); + + if(storedColor == 16 && entity.worldObj.isRemote) + burst.setColor(getLensColor(stack)); + + getLens(stack.getItemDamage()).updateBurst(burst, entity, stack); + + ItemStack compositeLens = getCompositeLens(stack); + if(compositeLens != null && compositeLens.getItem() instanceof ILens) + ((ILens) compositeLens.getItem()).updateBurst(burst, compositeLens); + } + + @Override + public int getLensColor(ItemStack stack) { + int storedColor = getStoredColor(stack); + + if(storedColor == -1) + return 0xFFFFFF; + + if(storedColor == 16) + return Color.HSBtoRGB(Botania.proxy.getWorldElapsedTicks() * 2 % 360 / 360F, 1F, 1F); + + float[] color = EntitySheep.fleeceColorTable[storedColor]; + return new Color(color[0], color[1], color[2]).getRGB(); + } + + public static int getStoredColor(ItemStack stack) { + return ItemNBTHelper.getInt(stack, TAG_COLOR, -1); + } + + public static ItemStack setLensColor(ItemStack stack, int color) { + ItemNBTHelper.setInt(stack, TAG_COLOR, color); + return stack; + } + + @Override + public boolean doParticles(IManaBurst burst, ItemStack stack) { + return true; + } + + public static void setProps(int lens, int props_) { + props[lens] = props_; + } + + public static void setLens(int index, Lens lens) { + lenses[index] = lens; + } + + public static boolean isBlacklisted(ItemStack lens1, ItemStack lens2) { + ICompositableLens item1 = (ICompositableLens) lens1.getItem(); + ICompositableLens item2 = (ICompositableLens) lens2.getItem(); + return (item1.getProps(lens1) & item2.getProps(lens2)) != 0; + } + + public static Lens getLens(int index) { + if(index == STORM) + return stormLens; + + Lens lens = lenses[index]; + return lens == null ? fallbackLens : lens; + } + + @Override + public boolean canCombineLenses(ItemStack sourceLens, ItemStack compositeLens) { + ICompositableLens sourceItem = (ICompositableLens) sourceLens.getItem(); + ICompositableLens compositeItem = (ICompositableLens) compositeLens.getItem(); + if(sourceItem == compositeItem && sourceLens.getItemDamage() == compositeLens.getItemDamage()) + return false; + + if(!sourceItem.isCombinable(sourceLens) || !compositeItem.isCombinable(compositeLens)) + return false; + + if(isBlacklisted(sourceLens, compositeLens)) + return false; + + return true; + } + + @Override + public ItemStack getCompositeLens(ItemStack stack) { + NBTTagCompound cmp = ItemNBTHelper.getCompound(stack, TAG_COMPOSITE_LENS, false); + ItemStack lens = ItemStack.loadItemStackFromNBT(cmp); + return lens; + } + + @Override + public ItemStack setCompositeLens(ItemStack sourceLens, ItemStack compositeLens) { + NBTTagCompound cmp = new NBTTagCompound(); + compositeLens.writeToNBT(cmp); + ItemNBTHelper.setCompound(sourceLens, TAG_COMPOSITE_LENS, cmp); + + return sourceLens; + } + + @Override + public boolean shouldPull(ItemStack stack) { + return stack.getItemDamage() != STORM; + } + + @Override + public boolean isControlLens(ItemStack stack) { + return (getProps(stack) & PROP_CONTROL) != 0; + } + + @Override + public boolean allowBurstShooting(ItemStack stack, IManaSpreader spreader, boolean redstone) { + return lenses[stack.getItemDamage()].allowBurstShooting(stack, spreader, redstone); + } + + @Override + public void onControlledSpreaderTick(ItemStack stack, IManaSpreader spreader, boolean redstone) { + lenses[stack.getItemDamage()].onControlledSpreaderTick(stack, spreader, redstone); + } + + @Override + public void onControlledSpreaderPulse(ItemStack stack, IManaSpreader spreader, boolean redstone) { + lenses[stack.getItemDamage()].onControlledSpreaderPulse(stack, spreader, redstone); + } + + @Override + public int getProps(ItemStack stack) { + return props[stack.getItemDamage()]; + } + + @Override + public boolean isCombinable(ItemStack stack) { + return stack.getItemDamage() != NORMAL; + } } diff --git a/src/main/java/vazkii/botania/common/item/lens/Lens.java b/src/main/java/vazkii/botania/common/item/lens/Lens.java index 09f75845b8..96cf391c1f 100644 --- a/src/main/java/vazkii/botania/common/item/lens/Lens.java +++ b/src/main/java/vazkii/botania/common/item/lens/Lens.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jan 24, 2015, 4:31:16 PM (GMT)] */ package vazkii.botania.common.item.lens; @@ -17,35 +17,31 @@ import vazkii.botania.api.mana.BurstProperties; import vazkii.botania.api.mana.IManaSpreader; -public class Lens { - - public void apply(ItemStack stack, BurstProperties props) { - // NO-OP - } - - public boolean collideBurst( - IManaBurst burst, - EntityThrowable entity, - MovingObjectPosition pos, - boolean isManaBlock, - boolean dead, - ItemStack stack) { - return dead; - } - - public void updateBurst(IManaBurst burst, EntityThrowable entity, ItemStack stack) { - // NO-OP - } - - public boolean allowBurstShooting(ItemStack stack, IManaSpreader spreader, boolean redstone) { - return true; - } - - public void onControlledSpreaderTick(ItemStack stack, IManaSpreader spreader, boolean redstone) { - // NO-OP - } - - public void onControlledSpreaderPulse(ItemStack stack, IManaSpreader spreader, boolean redstone) { - // NO-OP - } +public class Lens { + + public void apply(ItemStack stack, BurstProperties props) { + // NO-OP + } + + public boolean collideBurst(IManaBurst burst, EntityThrowable entity, MovingObjectPosition pos, boolean isManaBlock, boolean dead, ItemStack stack) { + return dead; + } + + public void updateBurst(IManaBurst burst, EntityThrowable entity, ItemStack stack) { + // NO-OP + } + + public boolean allowBurstShooting(ItemStack stack, IManaSpreader spreader, boolean redstone) { + return true; + } + + public void onControlledSpreaderTick(ItemStack stack, IManaSpreader spreader, boolean redstone) { + // NO-OP + } + + public void onControlledSpreaderPulse(ItemStack stack, IManaSpreader spreader, boolean redstone) { + // NO-OP + } + + } diff --git a/src/main/java/vazkii/botania/common/item/lens/LensBounce.java b/src/main/java/vazkii/botania/common/item/lens/LensBounce.java index b50dc3d78e..28148f7361 100644 --- a/src/main/java/vazkii/botania/common/item/lens/LensBounce.java +++ b/src/main/java/vazkii/botania/common/item/lens/LensBounce.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jan 24, 2015, 4:34:29 PM (GMT)] */ package vazkii.botania.common.item.lens; @@ -20,29 +20,22 @@ public class LensBounce extends Lens { - @Override - public boolean collideBurst( - IManaBurst burst, - EntityThrowable entity, - MovingObjectPosition pos, - boolean isManaBlock, - boolean dead, - ItemStack stack) { - if (!isManaBlock && pos.entityHit == null) { - ChunkCoordinates coords = burst.getBurstSourceChunkCoordinates(); - if (coords.posX != pos.blockX || coords.posY != pos.blockY || coords.posZ != pos.blockZ) { - Vector3 currentMovementVec = new Vector3(entity.motionX, entity.motionY, entity.motionZ); - ForgeDirection dir = ForgeDirection.getOrientation(pos.sideHit); - Vector3 normalVector = new Vector3(dir.offsetX, dir.offsetY, dir.offsetZ).normalize(); - Vector3 movementVec = normalVector - .multiply(-2 * currentMovementVec.dotProduct(normalVector)) - .add(currentMovementVec); + @Override + public boolean collideBurst(IManaBurst burst, EntityThrowable entity, MovingObjectPosition pos, boolean isManaBlock, boolean dead, ItemStack stack) { + if(!isManaBlock && pos.entityHit == null) { + ChunkCoordinates coords = burst.getBurstSourceChunkCoordinates(); + if(coords.posX != pos.blockX || coords.posY != pos.blockY || coords.posZ != pos.blockZ) { + Vector3 currentMovementVec = new Vector3(entity.motionX, entity.motionY, entity.motionZ); + ForgeDirection dir = ForgeDirection.getOrientation(pos.sideHit); + Vector3 normalVector = new Vector3(dir.offsetX, dir.offsetY, dir.offsetZ).normalize(); + Vector3 movementVec = normalVector.multiply(-2 * currentMovementVec.dotProduct(normalVector)).add(currentMovementVec); - burst.setMotion(movementVec.x, movementVec.y, movementVec.z); - dead = false; - } - } + burst.setMotion(movementVec.x, movementVec.y, movementVec.z); + dead = false; + } + } + + return dead; + } - return dead; - } } diff --git a/src/main/java/vazkii/botania/common/item/lens/LensDamage.java b/src/main/java/vazkii/botania/common/item/lens/LensDamage.java index 341e3dd9a2..f1a2689012 100644 --- a/src/main/java/vazkii/botania/common/item/lens/LensDamage.java +++ b/src/main/java/vazkii/botania/common/item/lens/LensDamage.java @@ -2,15 +2,16 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jan 24, 2015, 4:37:33 PM (GMT)] */ package vazkii.botania.common.item.lens; import java.util.List; + import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.projectile.EntityThrowable; @@ -21,28 +22,24 @@ public class LensDamage extends Lens { - @Override - public void updateBurst(IManaBurst burst, EntityThrowable entity, ItemStack stack) { - AxisAlignedBB axis = AxisAlignedBB.getBoundingBox( - entity.posX, - entity.posY, - entity.posZ, - entity.lastTickPosX, - entity.lastTickPosY, - entity.lastTickPosZ) - .expand(1, 1, 1); - List entities = entity.worldObj.getEntitiesWithinAABB(EntityLivingBase.class, axis); - for (EntityLivingBase living : entities) { - if (living instanceof EntityPlayer) continue; + @Override + public void updateBurst(IManaBurst burst, EntityThrowable entity, ItemStack stack) { + AxisAlignedBB axis = AxisAlignedBB.getBoundingBox(entity.posX, entity.posY, entity.posZ, entity.lastTickPosX, entity.lastTickPosY, entity.lastTickPosZ).expand(1, 1, 1); + List entities = entity.worldObj.getEntitiesWithinAABB(EntityLivingBase.class, axis); + for(EntityLivingBase living : entities) { + if(living instanceof EntityPlayer) + continue; + + if(living.hurtTime == 0) { + int mana = burst.getMana(); + if(mana >= 16) { + burst.setMana(mana - 16); + if(!burst.isFake() && !entity.worldObj.isRemote) + living.attackEntityFrom(DamageSource.magic, 8); + break; + } + } + } + } - if (living.hurtTime == 0) { - int mana = burst.getMana(); - if (mana >= 16) { - burst.setMana(mana - 16); - if (!burst.isFake() && !entity.worldObj.isRemote) living.attackEntityFrom(DamageSource.magic, 8); - break; - } - } - } - } } diff --git a/src/main/java/vazkii/botania/common/item/lens/LensEfficiency.java b/src/main/java/vazkii/botania/common/item/lens/LensEfficiency.java index cad72d1d4d..6e5b6eaf8c 100644 --- a/src/main/java/vazkii/botania/common/item/lens/LensEfficiency.java +++ b/src/main/java/vazkii/botania/common/item/lens/LensEfficiency.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jan 24, 2015, 4:34:06 PM (GMT)] */ package vazkii.botania.common.item.lens; @@ -15,9 +15,10 @@ public class LensEfficiency extends Lens { - @Override - public void apply(ItemStack stack, BurstProperties props) { - props.manaLossPerTick /= 5F; - props.ticksBeforeManaLoss *= 1.1F; - } + @Override + public void apply(ItemStack stack, BurstProperties props) { + props.manaLossPerTick /= 5F; + props.ticksBeforeManaLoss *= 1.1F; + } + } diff --git a/src/main/java/vazkii/botania/common/item/lens/LensExplosive.java b/src/main/java/vazkii/botania/common/item/lens/LensExplosive.java index 0d2e437fa2..6d4f8eb10f 100644 --- a/src/main/java/vazkii/botania/common/item/lens/LensExplosive.java +++ b/src/main/java/vazkii/botania/common/item/lens/LensExplosive.java @@ -1,12 +1,12 @@ /** * This class was created by - * . It's distributed as + . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jan 24, 2015, 4:41:44 PM (GMT)] */ package vazkii.botania.common.item.lens; @@ -19,24 +19,15 @@ public class LensExplosive extends Lens { - @Override - public boolean collideBurst( - IManaBurst burst, - EntityThrowable entity, - MovingObjectPosition pos, - boolean isManaBlock, - boolean dead, - ItemStack stack) { - if (!burst.isFake()) { - ChunkCoordinates coords = burst.getBurstSourceChunkCoordinates(); - if (!entity.worldObj.isRemote - && pos.entityHit == null - && !isManaBlock - && (pos.blockX != coords.posX || pos.blockY != coords.posY || pos.blockZ != coords.posZ)) - entity.worldObj.createExplosion( - entity, entity.posX, entity.posY, entity.posZ, burst.getMana() / 50F, true); - } else dead = false; + @Override + public boolean collideBurst(IManaBurst burst, EntityThrowable entity, MovingObjectPosition pos, boolean isManaBlock, boolean dead, ItemStack stack) { + if(!burst.isFake()) { + ChunkCoordinates coords = burst.getBurstSourceChunkCoordinates(); + if(!entity.worldObj.isRemote && pos.entityHit == null && !isManaBlock && (pos.blockX != coords.posX || pos.blockY != coords.posY || pos.blockZ != coords.posZ)) + entity.worldObj.createExplosion(entity, entity.posX, entity.posY, entity.posZ, burst.getMana() / 50F, true); + } else dead = false; + + return dead; + } - return dead; - } } diff --git a/src/main/java/vazkii/botania/common/item/lens/LensFire.java b/src/main/java/vazkii/botania/common/item/lens/LensFire.java index 23ba1895a9..19ed86c740 100644 --- a/src/main/java/vazkii/botania/common/item/lens/LensFire.java +++ b/src/main/java/vazkii/botania/common/item/lens/LensFire.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jan 24, 2015, 4:46:03 PM (GMT)] */ package vazkii.botania.common.item.lens; @@ -23,35 +23,29 @@ public class LensFire extends Lens { - @Override - public boolean collideBurst( - IManaBurst burst, - EntityThrowable entity, - MovingObjectPosition pos, - boolean isManaBlock, - boolean dead, - ItemStack stack) { - ChunkCoordinates coords = burst.getBurstSourceChunkCoordinates(); - if ((coords.posX != pos.blockX || coords.posY != pos.blockY || coords.posZ != pos.blockZ) - && !burst.isFake() - && !isManaBlock) { - ForgeDirection dir = ForgeDirection.getOrientation(pos.sideHit); - - int x = pos.blockX + dir.offsetX; - int y = pos.blockY + dir.offsetY; - int z = pos.blockZ + dir.offsetZ; - - Block blockAt = entity.worldObj.getBlock(pos.blockX, pos.blockY, pos.blockZ); - Block blockAt_ = entity.worldObj.getBlock(x, y, z); - - if (blockAt == Blocks.portal) entity.worldObj.setBlock(pos.blockX, pos.blockY, pos.blockZ, Blocks.air); - else if (blockAt == ModBlocks.incensePlate) { - TileIncensePlate plate = - (TileIncensePlate) entity.worldObj.getTileEntity(pos.blockX, pos.blockY, pos.blockZ); - plate.ignite(); - } else if (blockAt_.isAir(entity.worldObj, x, y, z)) entity.worldObj.setBlock(x, y, z, Blocks.fire); - } - - return dead; - } + @Override + public boolean collideBurst(IManaBurst burst, EntityThrowable entity, MovingObjectPosition pos, boolean isManaBlock, boolean dead, ItemStack stack) { + ChunkCoordinates coords = burst.getBurstSourceChunkCoordinates(); + if((coords.posX != pos.blockX || coords.posY != pos.blockY || coords.posZ != pos.blockZ) && !burst.isFake() && !isManaBlock) { + ForgeDirection dir = ForgeDirection.getOrientation(pos.sideHit); + + int x = pos.blockX + dir.offsetX; + int y = pos.blockY + dir.offsetY; + int z = pos.blockZ + dir.offsetZ; + + Block blockAt = entity.worldObj.getBlock(pos.blockX, pos.blockY, pos.blockZ); + Block blockAt_ = entity.worldObj.getBlock(x, y, z); + + if(blockAt == Blocks.portal) + entity.worldObj.setBlock(pos.blockX, pos.blockY, pos.blockZ, Blocks.air); + else if(blockAt == ModBlocks.incensePlate) { + TileIncensePlate plate = (TileIncensePlate) entity.worldObj.getTileEntity(pos.blockX, pos.blockY, pos.blockZ); + plate.ignite(); + } else if(blockAt_.isAir(entity.worldObj, x, y, z)) + entity.worldObj.setBlock(x, y, z, Blocks.fire); + } + + return dead; + } + } diff --git a/src/main/java/vazkii/botania/common/item/lens/LensFirework.java b/src/main/java/vazkii/botania/common/item/lens/LensFirework.java index dbf7d89de9..a81ef35539 100644 --- a/src/main/java/vazkii/botania/common/item/lens/LensFirework.java +++ b/src/main/java/vazkii/botania/common/item/lens/LensFirework.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [15/11/2015, 19:12:41 (GMT)] */ package vazkii.botania.common.item.lens; @@ -23,60 +23,53 @@ public class LensFirework extends Lens { - @Override - public boolean collideBurst( - IManaBurst burst, - EntityThrowable entity, - MovingObjectPosition pos, - boolean isManaBlock, - boolean dead, - ItemStack stack) { - if (!burst.isFake()) { - ChunkCoordinates coords = burst.getBurstSourceChunkCoordinates(); - if (!entity.worldObj.isRemote - && pos.entityHit == null - && !isManaBlock - && (pos.blockX != coords.posX || pos.blockY != coords.posY || pos.blockZ != coords.posZ)) { - ItemStack fireworkStack = generateFirework(burst.getColor()); + @Override + public boolean collideBurst(IManaBurst burst, EntityThrowable entity, MovingObjectPosition pos, boolean isManaBlock, boolean dead, ItemStack stack) { + if(!burst.isFake()) { + ChunkCoordinates coords = burst.getBurstSourceChunkCoordinates(); + if(!entity.worldObj.isRemote && pos.entityHit == null && !isManaBlock && (pos.blockX != coords.posX || pos.blockY != coords.posY || pos.blockZ != coords.posZ)) { + ItemStack fireworkStack = generateFirework(burst.getColor()); - EntityFireworkRocket rocket = - new EntityFireworkRocket(entity.worldObj, entity.posX, entity.posY, entity.posZ, fireworkStack); - entity.worldObj.spawnEntityInWorld(rocket); - } - } else dead = false; + EntityFireworkRocket rocket = new EntityFireworkRocket(entity.worldObj, entity.posX, entity.posY, entity.posZ, fireworkStack); + entity.worldObj.spawnEntityInWorld(rocket); + } + } else dead = false; - return dead; - } + return dead; + } - public ItemStack generateFirework(int color) { - ItemStack stack = new ItemStack(Items.fireworks); - NBTTagCompound explosion = new NBTTagCompound(); - explosion.setIntArray("Colors", new int[] {color}); + public ItemStack generateFirework(int color) { + ItemStack stack = new ItemStack(Items.fireworks); + NBTTagCompound explosion = new NBTTagCompound(); + explosion.setIntArray("Colors", new int[] { color }); - int type = 1; - double rand = Math.random(); - if (rand > 0.25) { - if (rand > 0.9) type = 2; - else type = 0; - } + int type = 1; + double rand = Math.random(); + if(rand > 0.25) { + if(rand > 0.9) + type = 2; + else type = 0; + } - explosion.setInteger("Type", type); + explosion.setInteger("Type", type); - if (Math.random() < 0.05) - if (Math.random() < 0.5) explosion.setBoolean("Flicker", true); - else explosion.setBoolean("Trail", true); + if(Math.random() < 0.05) + if(Math.random() < 0.5) + explosion.setBoolean("Flicker", true); + else explosion.setBoolean("Trail", true); - ItemNBTHelper.setCompound(stack, "Explosion", explosion); + ItemNBTHelper.setCompound(stack, "Explosion", explosion); - NBTTagCompound fireworks = new NBTTagCompound(); - fireworks.setInteger("Flight", (int) Math.random() * 3 + 2); + NBTTagCompound fireworks = new NBTTagCompound(); + fireworks.setInteger("Flight", (int) Math.random() * 3 + 2); - NBTTagList explosions = new NBTTagList(); - explosions.appendTag(explosion); - fireworks.setTag("Explosions", explosions); + NBTTagList explosions = new NBTTagList(); + explosions.appendTag(explosion); + fireworks.setTag("Explosions", explosions); - ItemNBTHelper.setCompound(stack, "Fireworks", fireworks); + ItemNBTHelper.setCompound(stack, "Fireworks", fireworks); + + return stack; + } - return stack; - } } diff --git a/src/main/java/vazkii/botania/common/item/lens/LensFlare.java b/src/main/java/vazkii/botania/common/item/lens/LensFlare.java index da0025230a..96345bf7ad 100644 --- a/src/main/java/vazkii/botania/common/item/lens/LensFlare.java +++ b/src/main/java/vazkii/botania/common/item/lens/LensFlare.java @@ -2,15 +2,16 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [15/11/2015, 19:13:10 (GMT)] */ package vazkii.botania.common.item.lens; import java.awt.Color; + import net.minecraft.entity.passive.EntitySheep; import net.minecraft.item.ItemStack; import net.minecraft.tileentity.TileEntity; @@ -20,54 +21,49 @@ public class LensFlare extends Lens { - @Override - public boolean allowBurstShooting(ItemStack stack, IManaSpreader spreader, boolean redstone) { - return false; - } + @Override + public boolean allowBurstShooting(ItemStack stack, IManaSpreader spreader, boolean redstone) { + return false; + } + + @Override + public void onControlledSpreaderTick(ItemStack stack, IManaSpreader spreader, boolean redstone) { + if(!redstone) + emitParticles(stack, spreader, redstone); + } - @Override - public void onControlledSpreaderTick(ItemStack stack, IManaSpreader spreader, boolean redstone) { - if (!redstone) emitParticles(stack, spreader, redstone); - } + @Override + public void onControlledSpreaderPulse(ItemStack stack, IManaSpreader spreader, boolean redstone) { + emitParticles(stack, spreader, redstone); + } - @Override - public void onControlledSpreaderPulse(ItemStack stack, IManaSpreader spreader, boolean redstone) { - emitParticles(stack, spreader, redstone); - } + private void emitParticles(ItemStack stack, IManaSpreader spreader, boolean redstone) { + float rotationYaw = -(spreader.getRotationX() + 90F); + float rotationPitch = spreader.getRotationY(); - private void emitParticles(ItemStack stack, IManaSpreader spreader, boolean redstone) { - float rotationYaw = -(spreader.getRotationX() + 90F); - float rotationPitch = spreader.getRotationY(); + // Lots of EntityThrowable copypasta + float f = 0.3F; + float mx = (float) (MathHelper.sin(rotationYaw / 180.0F * (float) Math.PI) * MathHelper.cos(rotationPitch / 180.0F * (float) Math.PI) * f / 2D); + float mz = (float) (-(MathHelper.cos(rotationYaw / 180.0F * (float) Math.PI) * MathHelper.cos(rotationPitch / 180.0F * (float) Math.PI) * f) / 2D); + float my = (float) (MathHelper.sin(rotationPitch / 180.0F * (float) Math.PI) * f / 2D); - // Lots of EntityThrowable copypasta - float f = 0.3F; - float mx = (float) (MathHelper.sin(rotationYaw / 180.0F * (float) Math.PI) - * MathHelper.cos(rotationPitch / 180.0F * (float) Math.PI) - * f - / 2D); - float mz = (float) (-(MathHelper.cos(rotationYaw / 180.0F * (float) Math.PI) - * MathHelper.cos(rotationPitch / 180.0F * (float) Math.PI) - * f) - / 2D); - float my = (float) (MathHelper.sin(rotationPitch / 180.0F * (float) Math.PI) * f / 2D); + int storedColor = ItemLens.getStoredColor(stack); + float r = 1, g = 1, b = 1; - int storedColor = ItemLens.getStoredColor(stack); - float r = 1, g = 1, b = 1; + TileEntity tile = (TileEntity) spreader; + if(storedColor == 16) { + Color c = Color.getHSBColor(tile.getWorldObj().getTotalWorldTime() * 2 % 360 / 360F, 1F, 1F); + r = c.getRed() / 255F; + g = c.getGreen() / 255F; + b = c.getBlue() / 255F; + } else if(storedColor >= 0) { + float[] colortable = EntitySheep.fleeceColorTable[storedColor]; + r = colortable[0]; + g = colortable[1]; + b = colortable[2]; + } - TileEntity tile = (TileEntity) spreader; - if (storedColor == 16) { - Color c = Color.getHSBColor(tile.getWorldObj().getTotalWorldTime() * 2 % 360 / 360F, 1F, 1F); - r = c.getRed() / 255F; - g = c.getGreen() / 255F; - b = c.getBlue() / 255F; - } else if (storedColor >= 0) { - float[] colortable = EntitySheep.fleeceColorTable[storedColor]; - r = colortable[0]; - g = colortable[1]; - b = colortable[2]; - } + Botania.proxy.wispFX(tile.getWorldObj(), tile.xCoord + 0.5, tile.yCoord + 0.5, tile.zCoord + 0.5, r, g, b, 0.4F, mx, my, mz); + } - Botania.proxy.wispFX( - tile.getWorldObj(), tile.xCoord + 0.5, tile.yCoord + 0.5, tile.zCoord + 0.5, r, g, b, 0.4F, mx, my, mz); - } } diff --git a/src/main/java/vazkii/botania/common/item/lens/LensGravity.java b/src/main/java/vazkii/botania/common/item/lens/LensGravity.java index 1fb0e1bf23..ae7a684b1e 100644 --- a/src/main/java/vazkii/botania/common/item/lens/LensGravity.java +++ b/src/main/java/vazkii/botania/common/item/lens/LensGravity.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jan 24, 2015, 4:35:52 PM (GMT)] */ package vazkii.botania.common.item.lens; @@ -15,9 +15,10 @@ public class LensGravity extends Lens { - @Override - public void apply(ItemStack stack, BurstProperties props) { - props.gravity = 0.0015F; - props.ticksBeforeManaLoss *= 1.2F; - } + @Override + public void apply(ItemStack stack, BurstProperties props) { + props.gravity = 0.0015F; + props.ticksBeforeManaLoss *= 1.2F; + } + } diff --git a/src/main/java/vazkii/botania/common/item/lens/LensInfluence.java b/src/main/java/vazkii/botania/common/item/lens/LensInfluence.java index 3d7c4add2c..43c4fa01c0 100644 --- a/src/main/java/vazkii/botania/common/item/lens/LensInfluence.java +++ b/src/main/java/vazkii/botania/common/item/lens/LensInfluence.java @@ -2,15 +2,16 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jan 24, 2015, 4:42:33 PM (GMT)] */ package vazkii.botania.common.item.lens; import java.util.List; + import net.minecraft.entity.Entity; import net.minecraft.entity.item.EntityFallingBlock; import net.minecraft.entity.item.EntityItem; @@ -24,72 +25,34 @@ public class LensInfluence extends Lens { - @Override - public void updateBurst(IManaBurst burst, EntityThrowable entity, ItemStack stack) { - if (!burst.isFake()) { - double range = 3.5; - List movables = entity.worldObj.getEntitiesWithinAABB( - EntityItem.class, - AxisAlignedBB.getBoundingBox( - entity.posX - range, - entity.posY - range, - entity.posZ - range, - entity.posX + range, - entity.posY + range, - entity.posZ + range)); - movables.addAll(entity.worldObj.getEntitiesWithinAABB( - EntityXPOrb.class, - AxisAlignedBB.getBoundingBox( - entity.posX - range, - entity.posY - range, - entity.posZ - range, - entity.posX + range, - entity.posY + range, - entity.posZ + range))); - movables.addAll(entity.worldObj.getEntitiesWithinAABB( - EntityArrow.class, - AxisAlignedBB.getBoundingBox( - entity.posX - range, - entity.posY - range, - entity.posZ - range, - entity.posX + range, - entity.posY + range, - entity.posZ + range))); - movables.addAll(entity.worldObj.getEntitiesWithinAABB( - EntityFallingBlock.class, - AxisAlignedBB.getBoundingBox( - entity.posX - range, - entity.posY - range, - entity.posZ - range, - entity.posX + range, - entity.posY + range, - entity.posZ + range))); - movables.addAll(entity.worldObj.getEntitiesWithinAABB( - IManaBurst.class, - AxisAlignedBB.getBoundingBox( - entity.posX - range, - entity.posY - range, - entity.posZ - range, - entity.posX + range, - entity.posY + range, - entity.posZ + range))); + @Override + public void updateBurst(IManaBurst burst, EntityThrowable entity, ItemStack stack) { + if(!burst.isFake()) { + double range = 3.5; + List movables = entity.worldObj.getEntitiesWithinAABB(EntityItem.class, AxisAlignedBB.getBoundingBox(entity.posX - range, entity.posY - range, entity.posZ - range, entity.posX + range, entity.posY + range, entity.posZ + range)); + movables.addAll(entity.worldObj.getEntitiesWithinAABB(EntityXPOrb.class, AxisAlignedBB.getBoundingBox(entity.posX - range, entity.posY - range, entity.posZ - range, entity.posX + range, entity.posY + range, entity.posZ + range))); + movables.addAll(entity.worldObj.getEntitiesWithinAABB(EntityArrow.class, AxisAlignedBB.getBoundingBox(entity.posX - range, entity.posY - range, entity.posZ - range, entity.posX + range, entity.posY + range, entity.posZ + range))); + movables.addAll(entity.worldObj.getEntitiesWithinAABB(EntityFallingBlock.class, AxisAlignedBB.getBoundingBox(entity.posX - range, entity.posY - range, entity.posZ - range, entity.posX + range, entity.posY + range, entity.posZ + range))); + movables.addAll(entity.worldObj.getEntitiesWithinAABB(IManaBurst.class, AxisAlignedBB.getBoundingBox(entity.posX - range, entity.posY - range, entity.posZ - range, entity.posX + range, entity.posY + range, entity.posZ + range))); + + for(Entity movable : movables) { + if(movable == burst) + continue; - for (Entity movable : movables) { - if (movable == burst) continue; + if(movable instanceof IManaBurst) { + IManaBurst otherBurst = (IManaBurst) movable; + ItemStack lens = otherBurst.getSourceLens(); + if(lens != null && lens.getItem() == ModItems.lens && lens.getItemDamage() == ItemLens.INFLUENCE) + continue; - if (movable instanceof IManaBurst) { - IManaBurst otherBurst = (IManaBurst) movable; - ItemStack lens = otherBurst.getSourceLens(); - if (lens != null && lens.getItem() == ModItems.lens && lens.getItemDamage() == ItemLens.INFLUENCE) - continue; + ((IManaBurst) movable).setMotion(entity.motionX, entity.motionY, entity.motionZ); + } else { + movable.motionX = entity.motionX; + movable.motionY = entity.motionY; + movable.motionZ = entity.motionZ; + } + } + } + } - ((IManaBurst) movable).setMotion(entity.motionX, entity.motionY, entity.motionZ); - } else { - movable.motionX = entity.motionX; - movable.motionY = entity.motionY; - movable.motionZ = entity.motionZ; - } - } - } - } } diff --git a/src/main/java/vazkii/botania/common/item/lens/LensLight.java b/src/main/java/vazkii/botania/common/item/lens/LensLight.java index 96de521725..3d11335648 100644 --- a/src/main/java/vazkii/botania/common/item/lens/LensLight.java +++ b/src/main/java/vazkii/botania/common/item/lens/LensLight.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jan 24, 2015, 4:47:20 PM (GMT)] */ package vazkii.botania.common.item.lens; @@ -24,37 +24,31 @@ public class LensLight extends Lens { - @Override - public boolean collideBurst( - IManaBurst burst, - EntityThrowable entity, - MovingObjectPosition pos, - boolean isManaBlock, - boolean dead, - ItemStack stack) { - ChunkCoordinates coords = burst.getBurstSourceChunkCoordinates(); - if ((coords.posX != pos.blockX || coords.posY != pos.blockY || coords.posZ != pos.blockZ) - && !burst.isFake() - && !isManaBlock) { - ForgeDirection dir = ForgeDirection.getOrientation(pos.sideHit); - - int x = pos.blockX + dir.offsetX; - int y = pos.blockY + dir.offsetY; - int z = pos.blockZ + dir.offsetZ; - - Block blockAt = entity.worldObj.getBlock(pos.blockX, pos.blockY, pos.blockZ); - Block blockAt_ = entity.worldObj.getBlock(x, y, z); - - if (blockAt == ModBlocks.manaFlame) - entity.worldObj.setBlock(pos.blockX, pos.blockY, pos.blockZ, Blocks.air); - else if (blockAt_.isAir(entity.worldObj, x, y, z) || blockAt_.isReplaceable(entity.worldObj, x, y, z)) { - entity.worldObj.setBlock(x, y, z, ModBlocks.manaFlame); - TileEntity tile = entity.worldObj.getTileEntity(x, y, z); - - if (tile instanceof TileManaFlame) ((TileManaFlame) tile).setColor(burst.getColor()); - } - } - - return dead; - } + @Override + public boolean collideBurst(IManaBurst burst, EntityThrowable entity, MovingObjectPosition pos, boolean isManaBlock, boolean dead, ItemStack stack) { + ChunkCoordinates coords = burst.getBurstSourceChunkCoordinates(); + if((coords.posX != pos.blockX || coords.posY != pos.blockY || coords.posZ != pos.blockZ) && !burst.isFake() && !isManaBlock) { + ForgeDirection dir = ForgeDirection.getOrientation(pos.sideHit); + + int x = pos.blockX + dir.offsetX; + int y = pos.blockY + dir.offsetY; + int z = pos.blockZ + dir.offsetZ; + + Block blockAt = entity.worldObj.getBlock(pos.blockX, pos.blockY, pos.blockZ); + Block blockAt_ = entity.worldObj.getBlock(x, y, z); + + if(blockAt == ModBlocks.manaFlame) + entity.worldObj.setBlock(pos.blockX, pos.blockY, pos.blockZ, Blocks.air); + else if(blockAt_.isAir(entity.worldObj, x, y, z) || blockAt_.isReplaceable(entity.worldObj, x, y, z)) { + entity.worldObj.setBlock(x, y, z, ModBlocks.manaFlame); + TileEntity tile = entity.worldObj.getTileEntity(x, y, z); + + if(tile instanceof TileManaFlame) + ((TileManaFlame) tile).setColor(burst.getColor()); + } + } + + return dead; + } + } diff --git a/src/main/java/vazkii/botania/common/item/lens/LensMagnet.java b/src/main/java/vazkii/botania/common/item/lens/LensMagnet.java index 0c9a6431a3..983e46cd5a 100644 --- a/src/main/java/vazkii/botania/common/item/lens/LensMagnet.java +++ b/src/main/java/vazkii/botania/common/item/lens/LensMagnet.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jan 24, 2015, 4:39:58 PM (GMT)] */ package vazkii.botania.common.item.lens; @@ -21,71 +21,61 @@ public class LensMagnet extends Lens { - private static final String TAG_MAGNETIZED = "Botania:Magnetized"; - private static final String TAG_MAGNETIZED_X = "Botania:MagnetizedX"; - private static final String TAG_MAGNETIZED_Y = "Botania:MagnetizedY"; - private static final String TAG_MAGNETIZED_Z = "Botania:MagnetizedZ"; + private static final String TAG_MAGNETIZED = "Botania:Magnetized"; + private static final String TAG_MAGNETIZED_X = "Botania:MagnetizedX"; + private static final String TAG_MAGNETIZED_Y = "Botania:MagnetizedY"; + private static final String TAG_MAGNETIZED_Z = "Botania:MagnetizedZ"; - @Override - public void updateBurst(IManaBurst burst, EntityThrowable entity, ItemStack stack) { - int x = (int) entity.posX; - int y = (int) entity.posY; - int z = (int) entity.posZ; - boolean magnetized = entity.getEntityData().hasKey(TAG_MAGNETIZED); - int range = 3; + @Override + public void updateBurst(IManaBurst burst, EntityThrowable entity, ItemStack stack) { + int x = (int) entity.posX; + int y = (int) entity.posY; + int z = (int) entity.posZ; + boolean magnetized = entity.getEntityData().hasKey(TAG_MAGNETIZED); + int range = 3; - magnetize: - { - for (int i = -range; i < range; i++) - for (int j = -range; j < range; j++) - for (int k = -range; k < range; k++) - if (entity.worldObj.getTileEntity(i + x, j + y, k + z) instanceof IManaReceiver) { - TileEntity tile = entity.worldObj.getTileEntity(i + x, j + y, k + z); + magnetize : { + for(int i = -range; i < range; i++) + for(int j = -range; j < range; j++) + for(int k = -range; k < range; k++) + if(entity.worldObj.getTileEntity(i + x, j + y, k + z) instanceof IManaReceiver) { + TileEntity tile = entity.worldObj.getTileEntity(i + x, j + y, k + z); - if (magnetized) { - int magX = entity.getEntityData().getInteger(TAG_MAGNETIZED_X); - int magY = entity.getEntityData().getInteger(TAG_MAGNETIZED_Y); - int magZ = entity.getEntityData().getInteger(TAG_MAGNETIZED_Z); - if (tile.xCoord != magX || tile.yCoord != magY || tile.zCoord != magZ) continue; - } + if(magnetized) { + int magX = entity.getEntityData().getInteger(TAG_MAGNETIZED_X); + int magY = entity.getEntityData().getInteger(TAG_MAGNETIZED_Y); + int magZ = entity.getEntityData().getInteger(TAG_MAGNETIZED_Z); + if(tile.xCoord != magX || tile.yCoord != magY || tile.zCoord != magZ) + continue; + } - IManaReceiver receiver = (IManaReceiver) tile; + IManaReceiver receiver = (IManaReceiver) tile; - ChunkCoordinates srcCoords = burst.getBurstSourceChunkCoordinates(); + ChunkCoordinates srcCoords = burst.getBurstSourceChunkCoordinates(); - if (MathHelper.pointDistanceSpace( - tile.xCoord, - tile.yCoord, - tile.zCoord, - srcCoords.posX, - srcCoords.posY, - srcCoords.posZ) - > 3 - && receiver.canRecieveManaFromBursts() - && !receiver.isFull()) { - Vector3 burstVec = Vector3.fromEntity(entity); - Vector3 tileVec = - Vector3.fromTileEntityCenter(tile).add(0, -0.1, 0); - Vector3 motionVec = new Vector3(entity.motionX, entity.motionY, entity.motionZ); + if(MathHelper.pointDistanceSpace(tile.xCoord, tile.yCoord, tile.zCoord, srcCoords.posX, srcCoords.posY, srcCoords.posZ) > 3 && receiver.canRecieveManaFromBursts() && !receiver.isFull()) { + Vector3 burstVec = Vector3.fromEntity(entity); + Vector3 tileVec = Vector3.fromTileEntityCenter(tile).add(0, -0.1, 0); + Vector3 motionVec = new Vector3(entity.motionX, entity.motionY, entity.motionZ); - Vector3 normalMotionVec = motionVec.copy().normalize(); - Vector3 magnetVec = tileVec.sub(burstVec).normalize(); - Vector3 differenceVec = - normalMotionVec.sub(magnetVec).multiply(motionVec.mag() * 0.1); + Vector3 normalMotionVec = motionVec.copy().normalize(); + Vector3 magnetVec = tileVec.sub(burstVec).normalize(); + Vector3 differenceVec = normalMotionVec.sub(magnetVec).multiply(motionVec.mag() * 0.1); - Vector3 finalMotionVec = motionVec.sub(differenceVec); - if (!magnetized) { - finalMotionVec.multiply(0.75); - entity.getEntityData().setBoolean(TAG_MAGNETIZED, true); - entity.getEntityData().setInteger(TAG_MAGNETIZED_X, tile.xCoord); - entity.getEntityData().setInteger(TAG_MAGNETIZED_Y, tile.yCoord); - entity.getEntityData().setInteger(TAG_MAGNETIZED_Z, tile.zCoord); - } + Vector3 finalMotionVec = motionVec.sub(differenceVec); + if(!magnetized) { + finalMotionVec.multiply(0.75); + entity.getEntityData().setBoolean(TAG_MAGNETIZED, true); + entity.getEntityData().setInteger(TAG_MAGNETIZED_X, tile.xCoord); + entity.getEntityData().setInteger(TAG_MAGNETIZED_Y, tile.yCoord); + entity.getEntityData().setInteger(TAG_MAGNETIZED_Z, tile.zCoord); + } + + burst.setMotion(finalMotionVec.x, finalMotionVec.y, finalMotionVec.z); + break magnetize; + } + } + } + } - burst.setMotion(finalMotionVec.x, finalMotionVec.y, finalMotionVec.z); - break magnetize; - } - } - } - } } diff --git a/src/main/java/vazkii/botania/common/item/lens/LensMine.java b/src/main/java/vazkii/botania/common/item/lens/LensMine.java index 9ed89f99df..72020182f4 100644 --- a/src/main/java/vazkii/botania/common/item/lens/LensMine.java +++ b/src/main/java/vazkii/botania/common/item/lens/LensMine.java @@ -2,16 +2,17 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jan 24, 2015, 4:36:20 PM (GMT)] */ package vazkii.botania.common.item.lens; import java.util.ArrayList; import java.util.List; + import net.minecraft.block.Block; import net.minecraft.entity.item.EntityItem; import net.minecraft.entity.projectile.EntityThrowable; @@ -29,71 +30,57 @@ public class LensMine extends Lens { - @Override - public boolean collideBurst( - IManaBurst burst, - EntityThrowable entity, - MovingObjectPosition pos, - boolean isManaBlock, - boolean dead, - ItemStack stack) { - World world = entity.worldObj; - int x = pos.blockX; - int y = pos.blockY; - int z = pos.blockZ; - Block block = world.getBlock(x, y, z); - int meta = world.getBlockMetadata(x, y, z); - ItemStack composite = ((ItemLens) ModItems.lens).getCompositeLens(stack); - boolean warp = - composite != null && composite.getItem() == ModItems.lens && composite.getItemDamage() == ItemLens.WARP; - - if (warp - && (block == ModBlocks.pistonRelay - || block == Blocks.piston - || block == Blocks.piston_extension - || block == Blocks.piston_head)) return false; + @Override + public boolean collideBurst(IManaBurst burst, EntityThrowable entity, MovingObjectPosition pos, boolean isManaBlock, boolean dead, ItemStack stack) { + World world = entity.worldObj; + int x = pos.blockX; + int y = pos.blockY; + int z = pos.blockZ; + Block block = world.getBlock(x, y, z); + int meta = world.getBlockMetadata(x, y, z); + ItemStack composite = ((ItemLens) ModItems.lens).getCompositeLens(stack); + boolean warp = composite != null && composite.getItem() == ModItems.lens && composite.getItemDamage() == ItemLens.WARP; + + if(warp && (block == ModBlocks.pistonRelay || block == Blocks.piston || block == Blocks.piston_extension || block == Blocks.piston_head)) + return false; - int harvestLevel = ConfigHandler.harvestLevelBore; + int harvestLevel = ConfigHandler.harvestLevelBore; + + TileEntity tile = world.getTileEntity(x, y, z); - TileEntity tile = world.getTileEntity(x, y, z); + float hardness = block.getBlockHardness(world, x, y, z); + int neededHarvestLevel = block.getHarvestLevel(meta); + int mana = burst.getMana(); - float hardness = block.getBlockHardness(world, x, y, z); - int neededHarvestLevel = block.getHarvestLevel(meta); - int mana = burst.getMana(); + ChunkCoordinates coords = burst.getBurstSourceChunkCoordinates(); + if((coords.posX != x || coords.posY != y || coords.posZ != z) && !(tile instanceof IManaBlock) && neededHarvestLevel <= harvestLevel && hardness != -1 && hardness < 50F && (burst.isFake() || mana >= 24)) { + List items = new ArrayList(); - ChunkCoordinates coords = burst.getBurstSourceChunkCoordinates(); - if ((coords.posX != x || coords.posY != y || coords.posZ != z) - && !(tile instanceof IManaBlock) - && neededHarvestLevel <= harvestLevel - && hardness != -1 - && hardness < 50F - && (burst.isFake() || mana >= 24)) { - List items = new ArrayList(); + items.addAll(block.getDrops(world, x, y, z, meta, 0)); - items.addAll(block.getDrops(world, x, y, z, meta, 0)); + if(!burst.hasAlreadyCollidedAt(x, y, z)) { + if(!burst.isFake() && !entity.worldObj.isRemote) { + world.setBlockToAir(x, y, z); + if(ConfigHandler.blockBreakParticles) + entity.worldObj.playAuxSFX(2001, x, y, z, Block.getIdFromBlock(block) + (meta << 12)); - if (!burst.hasAlreadyCollidedAt(x, y, z)) { - if (!burst.isFake() && !entity.worldObj.isRemote) { - world.setBlockToAir(x, y, z); - if (ConfigHandler.blockBreakParticles) - entity.worldObj.playAuxSFX(2001, x, y, z, Block.getIdFromBlock(block) + (meta << 12)); + boolean offBounds = coords.posY < 0; + boolean doWarp = warp && !offBounds; + int dropX = doWarp ? coords.posX : x; + int dropY = doWarp ? coords.posY : y; + int dropZ = doWarp ? coords.posZ : z; - boolean offBounds = coords.posY < 0; - boolean doWarp = warp && !offBounds; - int dropX = doWarp ? coords.posX : x; - int dropY = doWarp ? coords.posY : y; - int dropZ = doWarp ? coords.posZ : z; + for(ItemStack stack_ : items) + world.spawnEntityInWorld(new EntityItem(world, dropX + 0.5, dropY + 0.5, dropZ + 0.5, stack_)); - for (ItemStack stack_ : items) - world.spawnEntityInWorld(new EntityItem(world, dropX + 0.5, dropY + 0.5, dropZ + 0.5, stack_)); + burst.setMana(mana - 24); + } + } - burst.setMana(mana - 24); - } - } + dead = false; + } - dead = false; - } + return dead; + } - return dead; - } } diff --git a/src/main/java/vazkii/botania/common/item/lens/LensPaint.java b/src/main/java/vazkii/botania/common/item/lens/LensPaint.java index 2fe3c86c29..03afaeb110 100644 --- a/src/main/java/vazkii/botania/common/item/lens/LensPaint.java +++ b/src/main/java/vazkii/botania/common/item/lens/LensPaint.java @@ -2,16 +2,17 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jan 24, 2015, 4:44:01 PM (GMT)] */ package vazkii.botania.common.item.lens; import java.util.ArrayList; import java.util.List; + import net.minecraft.block.Block; import net.minecraft.entity.passive.EntitySheep; import net.minecraft.entity.projectile.EntityThrowable; @@ -26,99 +27,66 @@ public class LensPaint extends Lens { - @Override - public boolean collideBurst( - IManaBurst burst, - EntityThrowable entity, - MovingObjectPosition pos, - boolean isManaBlock, - boolean dead, - ItemStack stack) { - int storedColor = ItemLens.getStoredColor(stack); - if (!burst.isFake() && storedColor > -1 && storedColor < 17) { - if (pos.entityHit != null && pos.entityHit instanceof EntitySheep) { - int r = 20; - int sheepColor = ((EntitySheep) pos.entityHit).getFleeceColor(); - List sheepList = entity.worldObj.getEntitiesWithinAABB( - EntitySheep.class, - AxisAlignedBB.getBoundingBox( - pos.entityHit.posX - r, - pos.entityHit.posY - r, - pos.entityHit.posZ - r, - pos.entityHit.posX + r, - pos.entityHit.posY + r, - pos.entityHit.posZ + r)); - for (EntitySheep sheep : sheepList) { - if (sheep.getFleeceColor() == sheepColor) - sheep.setFleeceColor(storedColor == 16 ? sheep.worldObj.rand.nextInt(16) : storedColor); - } - dead = true; - } else { - Block block = entity.worldObj.getBlock(pos.blockX, pos.blockY, pos.blockZ); - if (BotaniaAPI.paintableBlocks.contains(block)) { - int meta = entity.worldObj.getBlockMetadata(pos.blockX, pos.blockY, pos.blockZ); - List coordsToPaint = new ArrayList(); - List coordsFound = new ArrayList(); + @Override + public boolean collideBurst(IManaBurst burst, EntityThrowable entity, MovingObjectPosition pos, boolean isManaBlock, boolean dead, ItemStack stack) { + int storedColor = ItemLens.getStoredColor(stack); + if(!burst.isFake() && storedColor > -1 && storedColor < 17) { + if(pos.entityHit != null && pos.entityHit instanceof EntitySheep) { + int r = 20; + int sheepColor = ((EntitySheep) pos.entityHit).getFleeceColor(); + List sheepList = entity.worldObj.getEntitiesWithinAABB(EntitySheep.class, AxisAlignedBB.getBoundingBox(pos.entityHit.posX - r, pos.entityHit.posY - r, pos.entityHit.posZ - r, pos.entityHit.posX + r, pos.entityHit.posY + r, pos.entityHit.posZ + r)); + for(EntitySheep sheep : sheepList) { + if(sheep.getFleeceColor() == sheepColor) + sheep.setFleeceColor(storedColor == 16 ? sheep.worldObj.rand.nextInt(16) : storedColor); + } + dead = true; + } else { + Block block = entity.worldObj.getBlock(pos.blockX, pos.blockY, pos.blockZ); + if(BotaniaAPI.paintableBlocks.contains(block)) { + int meta = entity.worldObj.getBlockMetadata(pos.blockX, pos.blockY, pos.blockZ); + List coordsToPaint = new ArrayList(); + List coordsFound = new ArrayList(); + + ChunkCoordinates theseCoords = new ChunkCoordinates(pos.blockX, pos.blockY, pos.blockZ); + coordsFound.add(theseCoords); + + do { + List iterCoords = new ArrayList(coordsFound); + for(ChunkCoordinates coords : iterCoords) { + coordsFound.remove(coords); + coordsToPaint.add(coords); - ChunkCoordinates theseCoords = new ChunkCoordinates(pos.blockX, pos.blockY, pos.blockZ); - coordsFound.add(theseCoords); + for(ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS) { + Block block_ = entity.worldObj.getBlock(coords.posX + dir.offsetX, coords.posY + dir.offsetY, coords.posZ + dir.offsetZ); + int meta_ = entity.worldObj.getBlockMetadata(coords.posX + dir.offsetX, coords.posY + dir.offsetY, coords.posZ + dir.offsetZ); + ChunkCoordinates coords_ = new ChunkCoordinates(coords.posX + dir.offsetX, coords.posY + dir.offsetY, coords.posZ + dir.offsetZ); + if(block_ == block && meta_ == meta && !coordsFound.contains(coords_) && !coordsToPaint.contains(coords_)) + coordsFound.add(coords_); + } + } + } while(!coordsFound.isEmpty() && coordsToPaint.size() < 1000); - do { - List iterCoords = new ArrayList(coordsFound); - for (ChunkCoordinates coords : iterCoords) { - coordsFound.remove(coords); - coordsToPaint.add(coords); + for(ChunkCoordinates coords : coordsToPaint) { + int placeColor = storedColor == 16 ? entity.worldObj.rand.nextInt(16) : storedColor; + int metaThere = entity.worldObj.getBlockMetadata(coords.posX, coords.posY, coords.posZ); - for (ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS) { - Block block_ = entity.worldObj.getBlock( - coords.posX + dir.offsetX, - coords.posY + dir.offsetY, - coords.posZ + dir.offsetZ); - int meta_ = entity.worldObj.getBlockMetadata( - coords.posX + dir.offsetX, - coords.posY + dir.offsetY, - coords.posZ + dir.offsetZ); - ChunkCoordinates coords_ = new ChunkCoordinates( - coords.posX + dir.offsetX, - coords.posY + dir.offsetY, - coords.posZ + dir.offsetZ); - if (block_ == block - && meta_ == meta - && !coordsFound.contains(coords_) - && !coordsToPaint.contains(coords_)) coordsFound.add(coords_); - } - } - } while (!coordsFound.isEmpty() && coordsToPaint.size() < 1000); + if(metaThere != placeColor) { + if(!entity.worldObj.isRemote) + entity.worldObj.setBlockMetadataWithNotify(coords.posX, coords.posY, coords.posZ, placeColor, 2); + float[] color = EntitySheep.fleeceColorTable[placeColor]; + float r = color[0]; + float g = color[1]; + float b = color[2]; + for(int i = 0; i < 4; i++) + Botania.proxy.sparkleFX(entity.worldObj, coords.posX + (float) Math.random(), coords.posY + (float) Math.random(), coords.posZ + (float) Math.random(), r, g, b, 0.6F + (float) Math.random() * 0.3F, 5); - for (ChunkCoordinates coords : coordsToPaint) { - int placeColor = storedColor == 16 ? entity.worldObj.rand.nextInt(16) : storedColor; - int metaThere = entity.worldObj.getBlockMetadata(coords.posX, coords.posY, coords.posZ); + } + } + } + } + } - if (metaThere != placeColor) { - if (!entity.worldObj.isRemote) - entity.worldObj.setBlockMetadataWithNotify( - coords.posX, coords.posY, coords.posZ, placeColor, 2); - float[] color = EntitySheep.fleeceColorTable[placeColor]; - float r = color[0]; - float g = color[1]; - float b = color[2]; - for (int i = 0; i < 4; i++) - Botania.proxy.sparkleFX( - entity.worldObj, - coords.posX + (float) Math.random(), - coords.posY + (float) Math.random(), - coords.posZ + (float) Math.random(), - r, - g, - b, - 0.6F + (float) Math.random() * 0.3F, - 5); - } - } - } - } - } + return dead; + } - return dead; - } } diff --git a/src/main/java/vazkii/botania/common/item/lens/LensPhantom.java b/src/main/java/vazkii/botania/common/item/lens/LensPhantom.java index f23fb38c08..1bcff6ec5a 100644 --- a/src/main/java/vazkii/botania/common/item/lens/LensPhantom.java +++ b/src/main/java/vazkii/botania/common/item/lens/LensPhantom.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jan 24, 2015, 4:39:24 PM (GMT)] */ package vazkii.botania.common.item.lens; @@ -17,19 +17,14 @@ public class LensPhantom extends Lens { - @Override - public boolean collideBurst( - IManaBurst burst, - EntityThrowable entity, - MovingObjectPosition pos, - boolean isManaBlock, - boolean dead, - ItemStack stack) { - if (!isManaBlock) { - dead = false; - burst.setMinManaLoss(Math.max(0, burst.getMinManaLoss() - 4)); - } + @Override + public boolean collideBurst(IManaBurst burst, EntityThrowable entity, MovingObjectPosition pos, boolean isManaBlock, boolean dead, ItemStack stack) { + if(!isManaBlock) { + dead = false; + burst.setMinManaLoss(Math.max(0, burst.getMinManaLoss() - 4)); + } + + return dead; + } - return dead; - } } diff --git a/src/main/java/vazkii/botania/common/item/lens/LensPiston.java b/src/main/java/vazkii/botania/common/item/lens/LensPiston.java index 013753dd31..afedaee185 100644 --- a/src/main/java/vazkii/botania/common/item/lens/LensPiston.java +++ b/src/main/java/vazkii/botania/common/item/lens/LensPiston.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jan 24, 2015, 4:46:39 PM (GMT)] */ package vazkii.botania.common.item.lens; @@ -22,42 +22,29 @@ public class LensPiston extends Lens { - @Override - public boolean collideBurst( - IManaBurst burst, - EntityThrowable entity, - MovingObjectPosition pos, - boolean isManaBlock, - boolean dead, - ItemStack stack) { - ChunkCoordinates coords = burst.getBurstSourceChunkCoordinates(); - if ((coords.posX != pos.blockX || coords.posY != pos.blockY || coords.posZ != pos.blockZ) - && !burst.isFake() - && !isManaBlock - && !entity.worldObj.isRemote) { - ForgeDirection dir = ForgeDirection.getOrientation(pos.sideHit).getOpposite(); - int x = pos.blockX + dir.offsetX; - int y = pos.blockY + dir.offsetY; - int z = pos.blockZ + dir.offsetZ; + @Override + public boolean collideBurst(IManaBurst burst, EntityThrowable entity, MovingObjectPosition pos, boolean isManaBlock, boolean dead, ItemStack stack) { + ChunkCoordinates coords = burst.getBurstSourceChunkCoordinates(); + if((coords.posX != pos.blockX || coords.posY != pos.blockY || coords.posZ != pos.blockZ) && !burst.isFake() && !isManaBlock && !entity.worldObj.isRemote) { + ForgeDirection dir = ForgeDirection.getOrientation(pos.sideHit).getOpposite(); + int x = pos.blockX + dir.offsetX; + int y = pos.blockY + dir.offsetY; + int z = pos.blockZ + dir.offsetZ; - if (entity.worldObj.isAirBlock(x, y, z) - || entity.worldObj.getBlock(x, y, z).isReplaceable(entity.worldObj, x, y, z)) { - Block block = entity.worldObj.getBlock(pos.blockX, pos.blockY, pos.blockZ); - int meta = entity.worldObj.getBlockMetadata(pos.blockX, pos.blockY, pos.blockZ); - TileEntity tile = entity.worldObj.getTileEntity(pos.blockX, pos.blockY, pos.blockZ); + if(entity.worldObj.isAirBlock(x, y, z) || entity.worldObj.getBlock(x, y, z).isReplaceable(entity.worldObj, x, y, z)) { + Block block = entity.worldObj.getBlock(pos.blockX, pos.blockY, pos.blockZ); + int meta = entity.worldObj.getBlockMetadata(pos.blockX, pos.blockY, pos.blockZ); + TileEntity tile = entity.worldObj.getTileEntity(pos.blockX, pos.blockY, pos.blockZ); - if (block.getMobilityFlag() == 0 - && block != Blocks.obsidian - && block.getBlockHardness(entity.worldObj, pos.blockX, pos.blockY, pos.blockZ) >= 0 - && tile == null) { - entity.worldObj.setBlockToAir(pos.blockX, pos.blockY, pos.blockZ); - entity.worldObj.setBlock(x, y, z, block, meta, 1 | 2); - entity.worldObj.playAuxSFX( - 2001, pos.blockX, pos.blockY, pos.blockZ, Block.getIdFromBlock(block) + (meta << 12)); - } - } - } + if(block.getMobilityFlag() == 0 && block != Blocks.obsidian && block.getBlockHardness(entity.worldObj, pos.blockX, pos.blockY, pos.blockZ) >= 0 && tile == null) { + entity.worldObj.setBlockToAir(pos.blockX, pos.blockY, pos.blockZ); + entity.worldObj.setBlock(x, y, z, block, meta, 1 | 2); + entity.worldObj.playAuxSFX(2001, pos.blockX, pos.blockY, pos.blockZ, Block.getIdFromBlock(block) + (meta << 12)); + } + } + } + + return dead; + } - return dead; - } } diff --git a/src/main/java/vazkii/botania/common/item/lens/LensPower.java b/src/main/java/vazkii/botania/common/item/lens/LensPower.java index 30126d8048..84ac6d9fbc 100644 --- a/src/main/java/vazkii/botania/common/item/lens/LensPower.java +++ b/src/main/java/vazkii/botania/common/item/lens/LensPower.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jan 24, 2015, 4:33:14 PM (GMT)] */ package vazkii.botania.common.item.lens; @@ -15,10 +15,11 @@ public class LensPower extends Lens { - @Override - public void apply(ItemStack stack, BurstProperties props) { - props.maxMana *= 2; - props.motionModifier *= 0.85F; - props.manaLossPerTick *= 2F; - } + @Override + public void apply(ItemStack stack, BurstProperties props) { + props.maxMana *= 2; + props.motionModifier *= 0.85F; + props.manaLossPerTick *= 2F; + } + } diff --git a/src/main/java/vazkii/botania/common/item/lens/LensRedirect.java b/src/main/java/vazkii/botania/common/item/lens/LensRedirect.java index 62de3ae2c7..d4a37bb6ae 100644 --- a/src/main/java/vazkii/botania/common/item/lens/LensRedirect.java +++ b/src/main/java/vazkii/botania/common/item/lens/LensRedirect.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [15/11/2015, 19:13:03 (GMT)] */ package vazkii.botania.common.item.lens; @@ -23,69 +23,53 @@ public class LensRedirect extends Lens { - @Override - public boolean collideBurst( - IManaBurst burst, - EntityThrowable entity, - MovingObjectPosition pos, - boolean isManaBlock, - boolean dead, - ItemStack stack) { - ChunkCoordinates coords = burst.getBurstSourceChunkCoordinates(); - if (!entity.worldObj.isRemote - && pos.entityHit == null - && coords.posY != -1 - && (pos.blockX != coords.posX || pos.blockY != coords.posY || pos.blockZ != coords.posZ)) { - TileEntity tile = entity.worldObj.getTileEntity(pos.blockX, pos.blockY, pos.blockZ); - if (tile != null && tile instanceof IRedirectable) { - if (!burst.isFake()) { - IRedirectable redir = (IRedirectable) tile; - Vector3 tileVec = Vector3.fromTileEntityCenter(tile); - Vector3 sourceVec = new Vector3(coords.posX + 0.5, coords.posY + 0.5, coords.posZ + 0.5); + @Override + public boolean collideBurst(IManaBurst burst, EntityThrowable entity, MovingObjectPosition pos, boolean isManaBlock, boolean dead, ItemStack stack) { + ChunkCoordinates coords = burst.getBurstSourceChunkCoordinates(); + if(!entity.worldObj.isRemote && pos.entityHit == null && coords.posY != -1 && (pos.blockX != coords.posX || pos.blockY != coords.posY || pos.blockZ != coords.posZ)) { + TileEntity tile = entity.worldObj.getTileEntity(pos.blockX, pos.blockY, pos.blockZ); + if(tile != null && tile instanceof IRedirectable) { + if(!burst.isFake()) { + IRedirectable redir = (IRedirectable) tile; + Vector3 tileVec = Vector3.fromTileEntityCenter(tile); + Vector3 sourceVec = new Vector3(coords.posX + 0.5, coords.posY + 0.5, coords.posZ + 0.5); - AxisAlignedBB axis = entity.worldObj - .getBlock(coords.posX, coords.posY, coords.posZ) - .getCollisionBoundingBoxFromPool(entity.worldObj, coords.posX, coords.posY, coords.posZ); - if (axis == null) - axis = AxisAlignedBB.getBoundingBox( - coords.posX, - coords.posY, - coords.posZ, - coords.posX + 1, - coords.posY + 1, - coords.posZ + 1); + AxisAlignedBB axis = entity.worldObj.getBlock(coords.posX, coords.posY, coords.posZ).getCollisionBoundingBoxFromPool(entity.worldObj, coords.posX, coords.posY, coords.posZ); + if(axis == null) + axis = AxisAlignedBB.getBoundingBox(coords.posX, coords.posY, coords.posZ, coords.posX + 1, coords.posY + 1, coords.posZ + 1); - if (!sourceVec.isInside(axis)) - sourceVec = new Vector3( - axis.minX + (axis.maxX - axis.minX) / 2, - axis.minY + (axis.maxY - axis.minY) / 2, - axis.minZ + (axis.maxZ - axis.minZ) / 2); + if(!sourceVec.isInside(axis)) + sourceVec = new Vector3(axis.minX + (axis.maxX - axis.minX) / 2, axis.minY + (axis.maxY - axis.minY) / 2, axis.minZ + (axis.maxZ - axis.minZ) / 2); - Vector3 diffVec = sourceVec.copy().sub(tileVec); - Vector3 diffVec2D = new Vector3(diffVec.x, diffVec.z, 0); - Vector3 rotVec = new Vector3(0, 1, 0); - double angle = rotVec.angle(diffVec2D) / Math.PI * 180.0; + Vector3 diffVec = sourceVec.copy().sub(tileVec); + Vector3 diffVec2D = new Vector3(diffVec.x, diffVec.z, 0); + Vector3 rotVec = new Vector3(0, 1, 0); + double angle = rotVec.angle(diffVec2D) / Math.PI * 180.0; - if (sourceVec.x < tileVec.x) angle = -angle; + if(sourceVec.x < tileVec.x) + angle = -angle; - redir.setRotationX((float) angle + 90F); + redir.setRotationX((float) angle + 90F); - rotVec = new Vector3(diffVec.x, 0, diffVec.z); - angle = diffVec.angle(rotVec) * 180F / Math.PI; - if (sourceVec.y < tileVec.y) angle = -angle; - redir.setRotationY((float) angle); + rotVec = new Vector3(diffVec.x, 0, diffVec.z); + angle = diffVec.angle(rotVec) * 180F / Math.PI; + if(sourceVec.y < tileVec.y) + angle = -angle; + redir.setRotationY((float) angle); - redir.commitRedirection(); - if (redir instanceof IThrottledPacket) ((IThrottledPacket) redir).markDispatchable(); - } - } - } + redir.commitRedirection(); + if(redir instanceof IThrottledPacket) + ((IThrottledPacket) redir).markDispatchable(); + } + } + } - if (!isManaBlock) { - dead = false; - burst.setMinManaLoss(Math.max(0, burst.getMinManaLoss() - 4)); - } + if(!isManaBlock) { + dead = false; + burst.setMinManaLoss(Math.max(0, burst.getMinManaLoss() - 4)); + } + + return dead; + } - return dead; - } } diff --git a/src/main/java/vazkii/botania/common/item/lens/LensSpeed.java b/src/main/java/vazkii/botania/common/item/lens/LensSpeed.java index fb96b4ed67..d7ada90f5b 100644 --- a/src/main/java/vazkii/botania/common/item/lens/LensSpeed.java +++ b/src/main/java/vazkii/botania/common/item/lens/LensSpeed.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jan 24, 2015, 4:32:47 PM (GMT)] */ package vazkii.botania.common.item.lens; @@ -15,11 +15,12 @@ public class LensSpeed extends Lens { - @Override - public void apply(ItemStack stack, BurstProperties props) { - props.motionModifier *= 2F; - props.maxMana *= 0.75F; - props.ticksBeforeManaLoss /= 3F; - props.manaLossPerTick *= 2F; - } + @Override + public void apply(ItemStack stack, BurstProperties props) { + props.motionModifier *= 2F; + props.maxMana *= 0.75F; + props.ticksBeforeManaLoss /= 3F; + props.manaLossPerTick *= 2F; + } + } diff --git a/src/main/java/vazkii/botania/common/item/lens/LensStorm.java b/src/main/java/vazkii/botania/common/item/lens/LensStorm.java index bc33a2bd90..cfbbe061da 100644 --- a/src/main/java/vazkii/botania/common/item/lens/LensStorm.java +++ b/src/main/java/vazkii/botania/common/item/lens/LensStorm.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jul 25, 2015, 2:10:26 AM (GMT)] */ package vazkii.botania.common.item.lens; @@ -18,23 +18,15 @@ public class LensStorm extends Lens { - @Override - public boolean collideBurst( - IManaBurst burst, - EntityThrowable entity, - MovingObjectPosition pos, - boolean isManaBlock, - boolean dead, - ItemStack stack) { - if (!burst.isFake()) { - ChunkCoordinates coords = burst.getBurstSourceChunkCoordinates(); - if (!entity.worldObj.isRemote - && pos.entityHit == null - && !isManaBlock - && (pos.blockX != coords.posX || pos.blockY != coords.posY || pos.blockZ != coords.posZ)) - entity.worldObj.createExplosion(entity, entity.posX, entity.posY, entity.posZ, 5F, true); - } else dead = false; + @Override + public boolean collideBurst(IManaBurst burst, EntityThrowable entity, MovingObjectPosition pos, boolean isManaBlock, boolean dead, ItemStack stack) { + if(!burst.isFake()) { + ChunkCoordinates coords = burst.getBurstSourceChunkCoordinates(); + if(!entity.worldObj.isRemote && pos.entityHit == null && !isManaBlock && (pos.blockX != coords.posX || pos.blockY != coords.posY || pos.blockZ != coords.posZ)) + entity.worldObj.createExplosion(entity, entity.posX, entity.posY, entity.posZ, 5F, true); + } else dead = false; + + return dead; + } - return dead; - } } diff --git a/src/main/java/vazkii/botania/common/item/lens/LensTime.java b/src/main/java/vazkii/botania/common/item/lens/LensTime.java index f5615b7154..14aa471f4c 100644 --- a/src/main/java/vazkii/botania/common/item/lens/LensTime.java +++ b/src/main/java/vazkii/botania/common/item/lens/LensTime.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jan 24, 2015, 4:33:41 PM (GMT)] */ package vazkii.botania.common.item.lens; @@ -15,9 +15,10 @@ public class LensTime extends Lens { - @Override - public void apply(ItemStack stack, BurstProperties props) { - props.ticksBeforeManaLoss *= 2.25F; - props.motionModifier *= 0.8F; - } + @Override + public void apply(ItemStack stack, BurstProperties props) { + props.ticksBeforeManaLoss *= 2.25F; + props.motionModifier *= 0.8F; + } + } diff --git a/src/main/java/vazkii/botania/common/item/lens/LensWarp.java b/src/main/java/vazkii/botania/common/item/lens/LensWarp.java index 9dceb985fe..34f4d0dd83 100644 --- a/src/main/java/vazkii/botania/common/item/lens/LensWarp.java +++ b/src/main/java/vazkii/botania/common/item/lens/LensWarp.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Feb 8, 2015, 2:17:01 PM (GMT)] */ package vazkii.botania.common.item.lens; @@ -20,33 +20,25 @@ public class LensWarp extends Lens { - @Override - public boolean collideBurst( - IManaBurst burst, - EntityThrowable entity, - MovingObjectPosition pos, - boolean isManaBlock, - boolean dead, - ItemStack stack) { - if (burst.isFake()) return dead; + @Override + public boolean collideBurst(IManaBurst burst, EntityThrowable entity, MovingObjectPosition pos, boolean isManaBlock, boolean dead, ItemStack stack) { + if(burst.isFake()) + return dead; + + Block block = entity.worldObj.getBlock(pos.blockX, pos.blockY, pos.blockZ); + if(block == ModBlocks.pistonRelay) { + String key = BlockPistonRelay.mappedPositions.get(BlockPistonRelay.getCoordsAsString(entity.worldObj.provider.dimensionId, pos.blockX, pos.blockY, pos.blockZ)); + if(key != null) { + String[] tokens = key.split(":"); + int worldId = Integer.parseInt(tokens[0]), x = Integer.parseInt(tokens[1]), y = Integer.parseInt(tokens[2]), z = Integer.parseInt(tokens[3]); + if(worldId == entity.worldObj.provider.dimensionId) { + entity.setPosition(x + 0.5, y + 0.5, z + 0.5); + burst.setCollidedAt(x, y, z); + return false; + } + } + } + return dead; + } - Block block = entity.worldObj.getBlock(pos.blockX, pos.blockY, pos.blockZ); - if (block == ModBlocks.pistonRelay) { - String key = BlockPistonRelay.mappedPositions.get(BlockPistonRelay.getCoordsAsString( - entity.worldObj.provider.dimensionId, pos.blockX, pos.blockY, pos.blockZ)); - if (key != null) { - String[] tokens = key.split(":"); - int worldId = Integer.parseInt(tokens[0]), - x = Integer.parseInt(tokens[1]), - y = Integer.parseInt(tokens[2]), - z = Integer.parseInt(tokens[3]); - if (worldId == entity.worldObj.provider.dimensionId) { - entity.setPosition(x + 0.5, y + 0.5, z + 0.5); - burst.setCollidedAt(x, y, z); - return false; - } - } - } - return dead; - } } diff --git a/src/main/java/vazkii/botania/common/item/lens/LensWeight.java b/src/main/java/vazkii/botania/common/item/lens/LensWeight.java index 88789ca141..205d92ac9e 100644 --- a/src/main/java/vazkii/botania/common/item/lens/LensWeight.java +++ b/src/main/java/vazkii/botania/common/item/lens/LensWeight.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jan 24, 2015, 4:43:16 PM (GMT)] */ package vazkii.botania.common.item.lens; @@ -20,36 +20,27 @@ public class LensWeight extends Lens { - @Override - public boolean collideBurst( - IManaBurst burst, - EntityThrowable entity, - MovingObjectPosition pos, - boolean isManaBlock, - boolean dead, - ItemStack stack) { - if (!burst.isFake()) { - int x = pos.blockX; - int y = pos.blockY; - int z = pos.blockZ; - int harvestLevel = ConfigHandler.harvestLevelWeight; + @Override + public boolean collideBurst(IManaBurst burst, EntityThrowable entity, MovingObjectPosition pos, boolean isManaBlock, boolean dead, ItemStack stack) { + if(!burst.isFake()) { + int x = pos.blockX; + int y = pos.blockY; + int z = pos.blockZ; + int harvestLevel = ConfigHandler.harvestLevelWeight; + + Block block = entity.worldObj.getBlock(x, y, z); + Block blockBelow = entity.worldObj.getBlock(x, y - 1, z); + int meta = entity.worldObj.getBlockMetadata(x, y, z); + int neededHarvestLevel = block.getHarvestLevel(meta); + + if(blockBelow.isAir(entity.worldObj, x, y - 1, z) && block.getBlockHardness(entity.worldObj, x, y, z) != -1 && neededHarvestLevel <= harvestLevel && entity.worldObj.getTileEntity(x, y, z) == null && block.canSilkHarvest(entity.worldObj, null, x, y, z, meta)) { + EntityFallingBlock falling = new EntityFallingBlock(entity.worldObj, x + 0.5, y + 0.5, z + 0.5, block, meta); + if(!entity.worldObj.isRemote) + entity.worldObj.spawnEntityInWorld(falling); + } + } - Block block = entity.worldObj.getBlock(x, y, z); - Block blockBelow = entity.worldObj.getBlock(x, y - 1, z); - int meta = entity.worldObj.getBlockMetadata(x, y, z); - int neededHarvestLevel = block.getHarvestLevel(meta); + return dead; + } - if (blockBelow.isAir(entity.worldObj, x, y - 1, z) - && block.getBlockHardness(entity.worldObj, x, y, z) != -1 - && neededHarvestLevel <= harvestLevel - && entity.worldObj.getTileEntity(x, y, z) == null - && block.canSilkHarvest(entity.worldObj, null, x, y, z, meta)) { - EntityFallingBlock falling = - new EntityFallingBlock(entity.worldObj, x + 0.5, y + 0.5, z + 0.5, block, meta); - if (!entity.worldObj.isRemote) entity.worldObj.spawnEntityInWorld(falling); - } - } - - return dead; - } } diff --git a/src/main/java/vazkii/botania/common/item/material/ItemDye.java b/src/main/java/vazkii/botania/common/item/material/ItemDye.java index bc7db227ba..c209a0a83d 100644 --- a/src/main/java/vazkii/botania/common/item/material/ItemDye.java +++ b/src/main/java/vazkii/botania/common/item/material/ItemDye.java @@ -2,80 +2,74 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jan 19, 2014, 4:10:47 PM (GMT)] */ package vazkii.botania.common.item.material; import net.minecraft.block.Block; import net.minecraft.entity.EntityLivingBase; +import net.minecraft.entity.item.EntityItem; import net.minecraft.entity.passive.EntitySheep; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.init.Blocks; import net.minecraft.item.ItemStack; import net.minecraft.tileentity.TileEntity; import net.minecraft.world.World; +import vazkii.botania.api.internal.VanillaPacketDispatcher; import vazkii.botania.api.item.IDyablePool; +import vazkii.botania.api.item.IManaDissolvable; +import vazkii.botania.api.mana.IManaPool; import vazkii.botania.common.item.Item16Colors; import vazkii.botania.common.lib.LibItemNames; public class ItemDye extends Item16Colors { - public ItemDye() { - super(LibItemNames.DYE); - } + public ItemDye() { + super(LibItemNames.DYE); + } - @Override - public boolean onItemUse( - ItemStack par1ItemStack, - EntityPlayer par2EntityPlayer, - World par3World, - int par4, - int par5, - int par6, - int par7, - float par8, - float par9, - float par10) { - Block block = par3World.getBlock(par4, par5, par6); - int meta = par1ItemStack.getItemDamage(); - if (meta != par3World.getBlockMetadata(par4, par5, par6) && (block == Blocks.wool || block == Blocks.carpet)) { - par3World.setBlockMetadataWithNotify(par4, par5, par6, meta, 1 | 2); - par1ItemStack.stackSize--; - return true; - } + @Override + public boolean onItemUse(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, World par3World, int par4, int par5, int par6, int par7, float par8, float par9, float par10) { + Block block = par3World.getBlock(par4, par5, par6); + int meta = par1ItemStack.getItemDamage(); + if(meta != par3World.getBlockMetadata(par4, par5, par6) && (block == Blocks.wool || block == Blocks.carpet)) { + par3World.setBlockMetadataWithNotify(par4, par5, par6, meta, 1 | 2); + par1ItemStack.stackSize--; + return true; + } + + TileEntity tile = par3World.getTileEntity(par4, par5, par6); + if(tile instanceof IDyablePool) { + IDyablePool dyable = (IDyablePool) tile; + int itemMeta = par1ItemStack.getItemDamage(); + if(meta != dyable.getColor()) { + dyable.setColor(meta); + par1ItemStack.stackSize--; + return true; + } + } + + return false; + } - TileEntity tile = par3World.getTileEntity(par4, par5, par6); - if (tile instanceof IDyablePool) { - IDyablePool dyable = (IDyablePool) tile; - int itemMeta = par1ItemStack.getItemDamage(); - if (meta != dyable.getColor()) { - dyable.setColor(meta); - par1ItemStack.stackSize--; - return true; - } - } + @Override + public boolean itemInteractionForEntity(ItemStack p_111207_1_, EntityPlayer p_111207_2_, EntityLivingBase p_111207_3_) { + if(p_111207_3_ instanceof EntitySheep) { + EntitySheep entitysheep = (EntitySheep)p_111207_3_; + int i = p_111207_1_.getItemDamage(); - return false; - } + if(!entitysheep.getSheared() && entitysheep.getFleeceColor() != i) { + entitysheep.setFleeceColor(i); + --p_111207_1_.stackSize; + } - @Override - public boolean itemInteractionForEntity( - ItemStack p_111207_1_, EntityPlayer p_111207_2_, EntityLivingBase p_111207_3_) { - if (p_111207_3_ instanceof EntitySheep) { - EntitySheep entitysheep = (EntitySheep) p_111207_3_; - int i = p_111207_1_.getItemDamage(); + return true; + } + return false; + } - if (!entitysheep.getSheared() && entitysheep.getFleeceColor() != i) { - entitysheep.setFleeceColor(i); - --p_111207_1_.stackSize; - } - - return true; - } - return false; - } } diff --git a/src/main/java/vazkii/botania/common/item/material/ItemManaPetal.java b/src/main/java/vazkii/botania/common/item/material/ItemManaPetal.java index 3183e64697..0c35bf25a2 100644 --- a/src/main/java/vazkii/botania/common/item/material/ItemManaPetal.java +++ b/src/main/java/vazkii/botania/common/item/material/ItemManaPetal.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Feb 2, 2014, 12:57:22 PM (GMT)] */ package vazkii.botania.common.item.material; @@ -18,17 +18,17 @@ public class ItemManaPetal extends Item16Colors implements IFlowerComponent { - public ItemManaPetal() { - super(LibItemNames.MANA_PETAL); - } + public ItemManaPetal() { + super(LibItemNames.MANA_PETAL); + } - @Override - public boolean canFit(ItemStack stack, IInventory apothecary) { - return true; - } + @Override + public boolean canFit(ItemStack stack, IInventory apothecary) { + return true; + } - @Override - public int getParticleColor(ItemStack stack) { - return getColorFromItemStack(stack, 0); - } + @Override + public int getParticleColor(ItemStack stack) { + return getColorFromItemStack(stack, 0); + } } diff --git a/src/main/java/vazkii/botania/common/item/material/ItemManaResource.java b/src/main/java/vazkii/botania/common/item/material/ItemManaResource.java index 9e727fce97..c3693a99a0 100644 --- a/src/main/java/vazkii/botania/common/item/material/ItemManaResource.java +++ b/src/main/java/vazkii/botania/common/item/material/ItemManaResource.java @@ -2,19 +2,17 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jan 30, 2014, 4:49:16 PM (GMT)] */ package vazkii.botania.common.item.material; -import cpw.mods.fml.common.eventhandler.SubscribeEvent; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; import java.awt.Color; import java.util.List; + import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.entity.item.EntityItem; @@ -41,160 +39,153 @@ import vazkii.botania.common.item.ItemMod; import vazkii.botania.common.item.equipment.tool.ToolCommons; import vazkii.botania.common.lib.LibItemNames; +import cpw.mods.fml.common.eventhandler.SubscribeEvent; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; public class ItemManaResource extends ItemMod implements IFlowerComponent, IElvenItem, IPickupAchievement { - final int types = 24; - IIcon[] icons; - - // begin dank_memes - public IIcon tailIcon = null; - public IIcon phiFlowerIcon = null; - public IIcon goldfishIcon = null; - public IIcon nerfBatIcon = null; - // end dank_memes - - public ItemManaResource() { - super(); - setUnlocalizedName(LibItemNames.MANA_RESOURCE); - setHasSubtypes(true); - MinecraftForge.EVENT_BUS.register(this); - } - - @SubscribeEvent - public void onPlayerInteract(PlayerInteractEvent event) { - boolean rightEvent = event.action == Action.RIGHT_CLICK_AIR; - ItemStack stack = event.entityPlayer.getCurrentEquippedItem(); - boolean correctStack = stack != null && stack.getItem() == Items.glass_bottle; - boolean ender = event.world.provider.dimensionId == 1; - - if (rightEvent && correctStack && ender) { - MovingObjectPosition pos = ToolCommons.raytraceFromEntity(event.world, event.entityPlayer, false, 5F); - - if (pos == null) { - ItemStack stack1 = new ItemStack(this, 1, 15); - event.entityPlayer.addStat(ModAchievements.enderAirMake, 1); - - if (!event.entityPlayer.inventory.addItemStackToInventory(stack1)) - event.entityPlayer.dropPlayerItemWithRandomChoice(stack1, true); - - stack.stackSize--; - if (stack.stackSize == 0) - event.entityPlayer.inventory.setInventorySlotContents( - event.entityPlayer.inventory.currentItem, null); - - if (event.world.isRemote) event.entityPlayer.swingItem(); - else event.world.playSoundAtEntity(event.entityPlayer, "random.pop", 0.5F, 1F); - } - } - } - - @Override - public boolean onItemUse( - ItemStack par1ItemStack, - EntityPlayer par2EntityPlayer, - World par3World, - int par4, - int par5, - int par6, - int par7, - float par8, - float par9, - float par10) { - if (par1ItemStack.getItemDamage() == 4 || par1ItemStack.getItemDamage() == 14) - return EntityDoppleganger.spawn( - par2EntityPlayer, par1ItemStack, par3World, par4, par5, par6, par1ItemStack.getItemDamage() == 14); - else if (par1ItemStack.getItemDamage() == 20 - && net.minecraft.item.ItemDye.applyBonemeal( - par1ItemStack, par3World, par4, par5, par6, par2EntityPlayer)) { - if (!par3World.isRemote) par3World.playAuxSFX(2005, par4, par5, par6, 0); - - return true; - } - - return super.onItemUse(par1ItemStack, par2EntityPlayer, par3World, par4, par5, par6, par7, par8, par9, par10); - } - - @Override - public ItemStack onItemRightClick(ItemStack par1ItemStack, World par3World, EntityPlayer par2EntityPlayer) { - if (par1ItemStack.getItemDamage() == 15) { - if (!par2EntityPlayer.capabilities.isCreativeMode) --par1ItemStack.stackSize; - - par3World.playSoundAtEntity( - par2EntityPlayer, "random.bow", 0.5F, 0.4F / (itemRand.nextFloat() * 0.4F + 0.8F)); - - if (!par3World.isRemote) - par3World.spawnEntityInWorld(new EntityEnderAirBottle(par3World, par2EntityPlayer)); - else par2EntityPlayer.swingItem(); - } - - return par1ItemStack; - } - - @Override - @SideOnly(Side.CLIENT) - public void getSubItems(Item par1, CreativeTabs par2CreativeTabs, List par3List) { - for (int i = 0; i < types; i++) - if (Botania.gardenOfGlassLoaded || i != 20 && i != 21) par3List.add(new ItemStack(par1, 1, i)); - } - - @Override - @SideOnly(Side.CLIENT) - public void registerIcons(IIconRegister par1IconRegister) { - icons = new IIcon[types]; - for (int i = 0; i < icons.length; i++) - icons[i] = IconHelper.forName(par1IconRegister, LibItemNames.MANA_RESOURCE_NAMES[i]); - - tailIcon = IconHelper.forName(par1IconRegister, "tail"); - phiFlowerIcon = IconHelper.forName(par1IconRegister, "phiFlower"); - goldfishIcon = IconHelper.forName(par1IconRegister, "goldfish"); - nerfBatIcon = IconHelper.forName(par1IconRegister, "nerfBat"); - } - - @Override - @SideOnly(Side.CLIENT) - public int getColorFromItemStack(ItemStack par1ItemStack, int par2) { - if (par1ItemStack.getItemDamage() == 5 || par1ItemStack.getItemDamage() == 14) - return Color.HSBtoRGB(Botania.proxy.getWorldElapsedTicks() * 2 % 360 / 360F, 0.25F, 1F); - - return 0xFFFFFF; - } - - @Override - public String getUnlocalizedName(ItemStack par1ItemStack) { - return "item." + LibItemNames.MANA_RESOURCE_NAMES[Math.min(types - 1, par1ItemStack.getItemDamage())]; - } - - @Override - @SideOnly(Side.CLIENT) - public IIcon getIconFromDamage(int par1) { - return icons[Math.min(icons.length - 1, par1)]; - } - - @Override - public boolean canFit(ItemStack stack, IInventory apothecary) { - int meta = stack.getItemDamage(); - return meta == 6 || meta == 8 || meta == 5 || meta == 23; - } - - @Override - public int getParticleColor(ItemStack stack) { - return 0x9b0000; - } - - @Override - public boolean isElvenItem(ItemStack stack) { - int meta = stack.getItemDamage(); - return meta == 7 || meta == 8 || meta == 9; - } - - @Override - public ItemStack getContainerItem(ItemStack itemStack) { - return itemStack.getItemDamage() == 11 ? itemStack.copy() : null; - } - - @Override - public Achievement getAchievementOnPickup(ItemStack stack, EntityPlayer player, EntityItem item) { - return stack.getItemDamage() == 4 ? ModAchievements.terrasteelPickup : null; - } + final int types = 24; + IIcon[] icons; + + // begin dank_memes + public IIcon tailIcon = null; + public IIcon phiFlowerIcon = null; + public IIcon goldfishIcon = null; + public IIcon nerfBatIcon = null; + // end dank_memes + + public ItemManaResource() { + super(); + setUnlocalizedName(LibItemNames.MANA_RESOURCE); + setHasSubtypes(true); + MinecraftForge.EVENT_BUS.register(this); + } + + @SubscribeEvent + public void onPlayerInteract(PlayerInteractEvent event) { + boolean rightEvent = event.action == Action.RIGHT_CLICK_AIR; + ItemStack stack = event.entityPlayer.getCurrentEquippedItem(); + boolean correctStack = stack != null && stack.getItem() == Items.glass_bottle; + boolean ender = event.world.provider.dimensionId == 1; + + if(rightEvent && correctStack && ender) { + MovingObjectPosition pos = ToolCommons.raytraceFromEntity(event.world, event.entityPlayer, false, 5F); + + if(pos == null) { + ItemStack stack1 = new ItemStack(this, 1, 15); + event.entityPlayer.addStat(ModAchievements.enderAirMake, 1); + + if(!event.entityPlayer.inventory.addItemStackToInventory(stack1)) + event.entityPlayer.dropPlayerItemWithRandomChoice(stack1, true); + + stack.stackSize--; + if(stack.stackSize == 0) + event.entityPlayer.inventory.setInventorySlotContents(event.entityPlayer.inventory.currentItem, null); + + if(event.world.isRemote) + event.entityPlayer.swingItem(); + else event.world.playSoundAtEntity(event.entityPlayer, "random.pop", 0.5F, 1F); + } + } + } + + @Override + public boolean onItemUse(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, World par3World, int par4, int par5, int par6, int par7, float par8, float par9, float par10) { + if(par1ItemStack.getItemDamage() == 4 || par1ItemStack.getItemDamage() == 14) + return EntityDoppleganger.spawn(par2EntityPlayer, par1ItemStack, par3World, par4, par5, par6, par1ItemStack.getItemDamage() == 14); + else if(par1ItemStack.getItemDamage() == 20 && net.minecraft.item.ItemDye.applyBonemeal(par1ItemStack, par3World, par4, par5, par6, par2EntityPlayer)) { + if(!par3World.isRemote) + par3World.playAuxSFX(2005, par4, par5, par6, 0); + + return true; + } + + return super.onItemUse(par1ItemStack, par2EntityPlayer, par3World, par4, par5, par6, par7, par8, par9, par10); + } + + @Override + public ItemStack onItemRightClick(ItemStack par1ItemStack, World par3World, EntityPlayer par2EntityPlayer) { + if(par1ItemStack.getItemDamage() == 15) { + if(!par2EntityPlayer.capabilities.isCreativeMode) + --par1ItemStack.stackSize; + + par3World.playSoundAtEntity(par2EntityPlayer, "random.bow", 0.5F, 0.4F / (itemRand.nextFloat() * 0.4F + 0.8F)); + + if(!par3World.isRemote) + par3World.spawnEntityInWorld(new EntityEnderAirBottle(par3World, par2EntityPlayer)); + else par2EntityPlayer.swingItem(); + } + + return par1ItemStack; + } + + @Override + @SideOnly(Side.CLIENT) + public void getSubItems(Item par1, CreativeTabs par2CreativeTabs, List par3List) { + for(int i = 0; i < types; i++) + if(Botania.gardenOfGlassLoaded || i != 20 && i != 21) + par3List.add(new ItemStack(par1, 1, i)); + } + + @Override + @SideOnly(Side.CLIENT) + public void registerIcons(IIconRegister par1IconRegister) { + icons = new IIcon[types]; + for(int i = 0; i < icons.length; i++) + icons[i] = IconHelper.forName(par1IconRegister, LibItemNames.MANA_RESOURCE_NAMES[i]); + + tailIcon = IconHelper.forName(par1IconRegister, "tail"); + phiFlowerIcon = IconHelper.forName(par1IconRegister, "phiFlower"); + goldfishIcon = IconHelper.forName(par1IconRegister, "goldfish"); + nerfBatIcon = IconHelper.forName(par1IconRegister, "nerfBat"); + } + + @Override + @SideOnly(Side.CLIENT) + public int getColorFromItemStack(ItemStack par1ItemStack, int par2) { + if(par1ItemStack.getItemDamage() == 5 || par1ItemStack.getItemDamage() == 14) + return Color.HSBtoRGB(Botania.proxy.getWorldElapsedTicks() * 2 % 360 / 360F, 0.25F, 1F); + + return 0xFFFFFF; + } + + @Override + public String getUnlocalizedName(ItemStack par1ItemStack) { + return "item." + LibItemNames.MANA_RESOURCE_NAMES[Math.min(types - 1, par1ItemStack.getItemDamage())]; + } + + @Override + @SideOnly(Side.CLIENT) + public IIcon getIconFromDamage(int par1) { + return icons[Math.min(icons.length - 1, par1)]; + } + + @Override + public boolean canFit(ItemStack stack, IInventory apothecary) { + int meta = stack.getItemDamage(); + return meta == 6 || meta == 8 || meta == 5 || meta == 23; + } + + @Override + public int getParticleColor(ItemStack stack) { + return 0x9b0000; + } + + @Override + public boolean isElvenItem(ItemStack stack) { + int meta = stack.getItemDamage(); + return meta == 7 || meta == 8 || meta == 9; + } + + @Override + public ItemStack getContainerItem(ItemStack itemStack) { + return itemStack.getItemDamage() == 11 ? itemStack.copy() : null; + } + + @Override + public Achievement getAchievementOnPickup(ItemStack stack, EntityPlayer player, EntityItem item) { + return stack.getItemDamage() == 4 ? ModAchievements.terrasteelPickup : null; + } + } diff --git a/src/main/java/vazkii/botania/common/item/material/ItemPestleAndMortar.java b/src/main/java/vazkii/botania/common/item/material/ItemPestleAndMortar.java index 69f4d14ace..23e8365376 100644 --- a/src/main/java/vazkii/botania/common/item/material/ItemPestleAndMortar.java +++ b/src/main/java/vazkii/botania/common/item/material/ItemPestleAndMortar.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jan 19, 2014, 7:00:34 PM (GMT)] */ package vazkii.botania.common.item.material; @@ -16,15 +16,16 @@ public class ItemPestleAndMortar extends ItemMod { - public ItemPestleAndMortar() { - super(); - setMaxStackSize(1); - setContainerItem(this); - setUnlocalizedName(LibItemNames.PESTLE_AND_MORTAR); - } + public ItemPestleAndMortar() { + super(); + setMaxStackSize(1); + setContainerItem(this); + setUnlocalizedName(LibItemNames.PESTLE_AND_MORTAR); + } + + @Override + public boolean doesContainerItemLeaveCraftingGrid(ItemStack par1ItemStack) { + return false; + } - @Override - public boolean doesContainerItemLeaveCraftingGrid(ItemStack par1ItemStack) { - return false; - } } diff --git a/src/main/java/vazkii/botania/common/item/material/ItemPetal.java b/src/main/java/vazkii/botania/common/item/material/ItemPetal.java index e5224fbf86..4f11fbec43 100644 --- a/src/main/java/vazkii/botania/common/item/material/ItemPetal.java +++ b/src/main/java/vazkii/botania/common/item/material/ItemPetal.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jan 19, 2014, 3:28:21 PM (GMT)] */ package vazkii.botania.common.item.material; @@ -21,40 +21,31 @@ public class ItemPetal extends Item16Colors implements IFlowerComponent { - public ItemPetal() { - super(LibItemNames.PETAL); - } - - @Override - public boolean onItemUse( - ItemStack par1ItemStack, - EntityPlayer par2EntityPlayer, - World par3World, - int par4, - int par5, - int par6, - int par7, - float par8, - float par9, - float par10) { - ItemStack stackToPlace = new ItemStack(ModBlocks.buriedPetals, 1, par1ItemStack.getItemDamage()); - stackToPlace.tryPlaceItemIntoWorld(par2EntityPlayer, par3World, par4, par5, par6, par7, par8, par9, par10); - - if (stackToPlace.stackSize == 0) { - if (!par2EntityPlayer.capabilities.isCreativeMode) par1ItemStack.stackSize--; - - return true; - } - return false; - } - - @Override - public boolean canFit(ItemStack stack, IInventory apothecary) { - return true; - } - - @Override - public int getParticleColor(ItemStack stack) { - return getColorFromItemStack(stack, 0); - } + public ItemPetal() { + super(LibItemNames.PETAL); + } + + @Override + public boolean onItemUse(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, World par3World, int par4, int par5, int par6, int par7, float par8, float par9, float par10) { + ItemStack stackToPlace = new ItemStack(ModBlocks.buriedPetals, 1, par1ItemStack.getItemDamage()); + stackToPlace.tryPlaceItemIntoWorld(par2EntityPlayer, par3World, par4, par5, par6, par7, par8, par9, par10); + + if(stackToPlace.stackSize == 0) { + if(!par2EntityPlayer.capabilities.isCreativeMode) + par1ItemStack.stackSize--; + + return true; + } + return false; + } + + @Override + public boolean canFit(ItemStack stack, IInventory apothecary) { + return true; + } + + @Override + public int getParticleColor(ItemStack stack) { + return getColorFromItemStack(stack, 0); + } } diff --git a/src/main/java/vazkii/botania/common/item/material/ItemQuartz.java b/src/main/java/vazkii/botania/common/item/material/ItemQuartz.java index a7660227ec..0ab289299a 100644 --- a/src/main/java/vazkii/botania/common/item/material/ItemQuartz.java +++ b/src/main/java/vazkii/botania/common/item/material/ItemQuartz.java @@ -2,15 +2,16 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jun 11, 2014, 2:16:47 AM (GMT)] */ package vazkii.botania.common.item.material; import java.util.List; + import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.item.Item; @@ -24,41 +25,43 @@ public class ItemQuartz extends ItemMod implements IElvenItem { - private static final int SUBTYPES = 7; - IIcon[] icons; + private static final int SUBTYPES = 7; + IIcon[] icons; - public ItemQuartz() { - setUnlocalizedName(LibItemNames.QUARTZ); - setHasSubtypes(true); - } + public ItemQuartz() { + setUnlocalizedName(LibItemNames.QUARTZ); + setHasSubtypes(true); + } - @Override - public void getSubItems(Item item, CreativeTabs tab, List list) { - for (int i = ConfigHandler.darkQuartzEnabled ? 0 : 1; i < SUBTYPES; i++) list.add(new ItemStack(item, 1, i)); - } + @Override + public void getSubItems(Item item, CreativeTabs tab, List list) { + for(int i = ConfigHandler.darkQuartzEnabled ? 0 : 1; i < SUBTYPES; i++) + list.add(new ItemStack(item, 1, i)); + } - @Override - public void registerIcons(IIconRegister par1IconRegister) { - icons = new IIcon[SUBTYPES]; - for (int i = 0; i < icons.length; i++) icons[i] = IconHelper.forItem(par1IconRegister, this, i); - } + @Override + public void registerIcons(IIconRegister par1IconRegister) { + icons = new IIcon[SUBTYPES]; + for(int i = 0; i < icons.length; i++) + icons[i] = IconHelper.forItem(par1IconRegister, this, i); + } - @Override - public IIcon getIconFromDamage(int par1) { - return icons[Math.min(icons.length - 1, par1)]; - } + @Override + public IIcon getIconFromDamage(int par1) { + return icons[Math.min(icons.length - 1, par1)]; + } - @Override - public String getUnlocalizedName(ItemStack par1ItemStack) { - return getUnlocalizedNameLazy(par1ItemStack) + par1ItemStack.getItemDamage(); - } + @Override + public String getUnlocalizedName(ItemStack par1ItemStack) { + return getUnlocalizedNameLazy(par1ItemStack) + par1ItemStack.getItemDamage(); + } - String getUnlocalizedNameLazy(ItemStack par1ItemStack) { - return super.getUnlocalizedName(par1ItemStack); - } + String getUnlocalizedNameLazy(ItemStack par1ItemStack) { + return super.getUnlocalizedName(par1ItemStack); + } - @Override - public boolean isElvenItem(ItemStack stack) { - return stack.getItemDamage() == 5; - } + @Override + public boolean isElvenItem(ItemStack stack) { + return stack.getItemDamage() == 5; + } } diff --git a/src/main/java/vazkii/botania/common/item/material/ItemRune.java b/src/main/java/vazkii/botania/common/item/material/ItemRune.java index d6eab95e3b..e678f36762 100644 --- a/src/main/java/vazkii/botania/common/item/material/ItemRune.java +++ b/src/main/java/vazkii/botania/common/item/material/ItemRune.java @@ -2,15 +2,16 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Feb 7, 2014, 9:46:24 PM (GMT)] */ package vazkii.botania.common.item.material; import java.util.List; + import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.entity.item.EntityItem; @@ -29,51 +30,54 @@ public class ItemRune extends ItemMod implements IFlowerComponent, IPickupAchievement { - IIcon[] icons; + IIcon[] icons; + + public ItemRune() { + super(); + setHasSubtypes(true); + setUnlocalizedName(LibItemNames.RUNE); + } - public ItemRune() { - super(); - setHasSubtypes(true); - setUnlocalizedName(LibItemNames.RUNE); - } + @Override + public void registerIcons(IIconRegister par1IconRegister) { + icons = new IIcon[16]; + for(int i = 0; i < icons.length; i++) + icons[i] = IconHelper.forItem(par1IconRegister, this, i); + } - @Override - public void registerIcons(IIconRegister par1IconRegister) { - icons = new IIcon[16]; - for (int i = 0; i < icons.length; i++) icons[i] = IconHelper.forItem(par1IconRegister, this, i); - } + @Override + public IIcon getIconFromDamage(int par1) { + return icons[Math.min(icons.length - 1, par1)]; + } - @Override - public IIcon getIconFromDamage(int par1) { - return icons[Math.min(icons.length - 1, par1)]; - } + @Override + public void getSubItems(Item par1, CreativeTabs par2CreativeTabs, List par3List) { + for(int i = 0; i < 16; i++) + par3List.add(new ItemStack(par1, 1, i)); + } - @Override - public void getSubItems(Item par1, CreativeTabs par2CreativeTabs, List par3List) { - for (int i = 0; i < 16; i++) par3List.add(new ItemStack(par1, 1, i)); - } + @Override + public String getUnlocalizedName(ItemStack par1ItemStack) { + return getUnlocalizedNameLazy(par1ItemStack) + par1ItemStack.getItemDamage(); + } - @Override - public String getUnlocalizedName(ItemStack par1ItemStack) { - return getUnlocalizedNameLazy(par1ItemStack) + par1ItemStack.getItemDamage(); - } + String getUnlocalizedNameLazy(ItemStack par1ItemStack) { + return super.getUnlocalizedName(par1ItemStack); + } - String getUnlocalizedNameLazy(ItemStack par1ItemStack) { - return super.getUnlocalizedName(par1ItemStack); - } + @Override + public boolean canFit(ItemStack stack, IInventory apothecary) { + return true; + } - @Override - public boolean canFit(ItemStack stack, IInventory apothecary) { - return true; - } + @Override + public int getParticleColor(ItemStack stack) { + return 0xA8A8A8; + } - @Override - public int getParticleColor(ItemStack stack) { - return 0xA8A8A8; - } + @Override + public Achievement getAchievementOnPickup(ItemStack stack, EntityPlayer player, EntityItem item) { + return ModAchievements.runePickup; + } - @Override - public Achievement getAchievementOnPickup(ItemStack stack, EntityPlayer player, EntityItem item) { - return ModAchievements.runePickup; - } } diff --git a/src/main/java/vazkii/botania/common/item/record/ItemModRecord.java b/src/main/java/vazkii/botania/common/item/record/ItemModRecord.java index 3eb397bb97..793dd4d7ea 100644 --- a/src/main/java/vazkii/botania/common/item/record/ItemModRecord.java +++ b/src/main/java/vazkii/botania/common/item/record/ItemModRecord.java @@ -2,17 +2,14 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Apr 11, 2015, 9:56:00 PM (GMT)] */ package vazkii.botania.common.item.record; -import cpw.mods.fml.common.registry.GameRegistry; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.item.Item; import net.minecraft.item.ItemRecord; @@ -21,38 +18,41 @@ import vazkii.botania.client.core.helper.IconHelper; import vazkii.botania.client.lib.LibResources; import vazkii.botania.common.core.BotaniaCreativeTab; +import cpw.mods.fml.common.registry.GameRegistry; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; public class ItemModRecord extends ItemRecord { - private final String file; - - public ItemModRecord(String record, String name) { - super("botania:" + record); - setCreativeTab(BotaniaCreativeTab.INSTANCE); - setUnlocalizedName(name); - file = "botania:music." + record; - } - - @Override - public Item setUnlocalizedName(String par1Str) { - GameRegistry.registerItem(this, par1Str); - return super.setUnlocalizedName(par1Str); - } - - @Override - public String getUnlocalizedNameInefficiently(ItemStack par1ItemStack) { - return super.getUnlocalizedNameInefficiently(par1ItemStack) - .replaceAll("item\\.", "item." + LibResources.PREFIX_MOD); - } - - @Override - @SideOnly(Side.CLIENT) - public void registerIcons(IIconRegister par1IconRegister) { - itemIcon = IconHelper.forItem(par1IconRegister, this); - } - - @Override - public ResourceLocation getRecordResource(String name) { - return new ResourceLocation(file); - } + private final String file; + + public ItemModRecord(String record, String name) { + super("botania:" + record); + setCreativeTab(BotaniaCreativeTab.INSTANCE); + setUnlocalizedName(name); + file = "botania:music." + record; + } + + @Override + public Item setUnlocalizedName(String par1Str) { + GameRegistry.registerItem(this, par1Str); + return super.setUnlocalizedName(par1Str); + } + + @Override + public String getUnlocalizedNameInefficiently(ItemStack par1ItemStack) { + return super.getUnlocalizedNameInefficiently(par1ItemStack).replaceAll("item\\.", "item." + LibResources.PREFIX_MOD); + } + + @Override + @SideOnly(Side.CLIENT) + public void registerIcons(IIconRegister par1IconRegister) { + itemIcon = IconHelper.forItem(par1IconRegister, this); + } + + @Override + public ResourceLocation getRecordResource(String name) { + return new ResourceLocation(file); + } + } diff --git a/src/main/java/vazkii/botania/common/item/record/ItemRecordGaia1.java b/src/main/java/vazkii/botania/common/item/record/ItemRecordGaia1.java index 221a298a8f..c1c5d4b9be 100644 --- a/src/main/java/vazkii/botania/common/item/record/ItemRecordGaia1.java +++ b/src/main/java/vazkii/botania/common/item/record/ItemRecordGaia1.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Apr 11, 2015, 10:03:46 PM (GMT)] */ package vazkii.botania.common.item.record; @@ -14,7 +14,8 @@ public class ItemRecordGaia1 extends ItemModRecord { - public ItemRecordGaia1() { - super("gaia1", LibItemNames.RECORD_GAIA1); - } + public ItemRecordGaia1() { + super("gaia1", LibItemNames.RECORD_GAIA1); + } + } diff --git a/src/main/java/vazkii/botania/common/item/record/ItemRecordGaia2.java b/src/main/java/vazkii/botania/common/item/record/ItemRecordGaia2.java index bfa68158ee..2f1f1f6ca7 100644 --- a/src/main/java/vazkii/botania/common/item/record/ItemRecordGaia2.java +++ b/src/main/java/vazkii/botania/common/item/record/ItemRecordGaia2.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Apr 11, 2015, 10:06:28 PM (GMT)] */ package vazkii.botania.common.item.record; @@ -14,7 +14,8 @@ public class ItemRecordGaia2 extends ItemModRecord { - public ItemRecordGaia2() { - super("gaia2", LibItemNames.RECORD_GAIA2); - } + public ItemRecordGaia2() { + super("gaia2", LibItemNames.RECORD_GAIA2); + } + } diff --git a/src/main/java/vazkii/botania/common/item/relic/ItemAesirRing.java b/src/main/java/vazkii/botania/common/item/relic/ItemAesirRing.java index f606d4afdc..c523bb087a 100644 --- a/src/main/java/vazkii/botania/common/item/relic/ItemAesirRing.java +++ b/src/main/java/vazkii/botania/common/item/relic/ItemAesirRing.java @@ -2,20 +2,16 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Mar 29, 2015, 10:16:29 PM (GMT)] */ package vazkii.botania.common.item.relic; -import baubles.api.BaubleType; -import com.google.common.collect.HashMultimap; -import com.google.common.collect.Multimap; -import cpw.mods.fml.common.eventhandler.SubscribeEvent; -import cpw.mods.fml.common.registry.GameRegistry; import java.util.List; + import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.SharedMonsterAttributes; import net.minecraft.entity.ai.attributes.AttributeModifier; @@ -37,91 +33,90 @@ import vazkii.botania.common.crafting.recipe.AesirRingRecipe; import vazkii.botania.common.item.ModItems; import vazkii.botania.common.lib.LibItemNames; +import baubles.api.BaubleType; + +import com.google.common.collect.HashMultimap; +import com.google.common.collect.Multimap; + +import cpw.mods.fml.common.eventhandler.SubscribeEvent; +import cpw.mods.fml.common.registry.GameRegistry; + +public class ItemAesirRing extends ItemRelicBauble implements IExtendedWireframeCoordinateListProvider, ICraftAchievement { + + Multimap attributes = HashMultimap.create(); + + public ItemAesirRing() { + super(LibItemNames.AESIR_RING); + GameRegistry.addRecipe(new AesirRingRecipe()); + RecipeSorter.register("botania:aesirRing", AesirRingRecipe.class, Category.SHAPELESS, ""); + MinecraftForge.EVENT_BUS.register(this); + } + + @SubscribeEvent + public void onDropped(ItemTossEvent event) { + if(event.entityItem != null && event.entityItem.getEntityItem() != null && !event.entityItem.worldObj.isRemote) { + ItemStack stack = event.entityItem.getEntityItem(); + if(stack.getItem() != null && stack.getItem() == this) { + event.entityItem.setDead(); + + String user = getSoulbindUsername(stack); + for(Item item : new Item[] { ModItems.thorRing, ModItems.lokiRing, ModItems.odinRing }) { + ItemStack stack1 = new ItemStack(item); + bindToUsername(user, stack1); + EntityItem entity = new EntityItem(event.entityItem.worldObj, event.entityItem.posX, event.entityItem.posY, event.entityItem.posZ, stack1); + entity.motionX = event.entityItem.motionX; + entity.motionY = event.entityItem.motionY; + entity.motionZ = event.entityItem.motionZ; + entity.age = event.entityItem.age; + entity.delayBeforeCanPickup = event.entityItem.delayBeforeCanPickup; + entity.worldObj.spawnEntityInWorld(entity); + } + } + } + } + + @Override + public void onValidPlayerWornTick(ItemStack stack, EntityPlayer player) { + ((ItemOdinRing) ModItems.odinRing).onValidPlayerWornTick(stack, player); + } + + @Override + public BaubleType getBaubleType(ItemStack arg0) { + return BaubleType.RING; + } + + @Override + public List getWireframesToDraw(EntityPlayer player, ItemStack stack) { + return ((IWireframeCoordinateListProvider) ModItems.lokiRing).getWireframesToDraw(player, stack); + } + + @Override + public ChunkCoordinates getSourceWireframe(EntityPlayer player, ItemStack stack) { + return ((IExtendedWireframeCoordinateListProvider) ModItems.lokiRing).getSourceWireframe(player, stack); + } + + @Override + public void onEquippedOrLoadedIntoWorld(ItemStack stack, EntityLivingBase player) { + attributes.clear(); + fillModifiers(attributes, stack); + player.getAttributeMap().applyAttributeModifiers(attributes); + } + + @Override + public void onUnequipped(ItemStack stack, EntityLivingBase player) { + attributes.clear(); + fillModifiers(attributes, stack); + player.getAttributeMap().removeAttributeModifiers(attributes); + } + + + void fillModifiers(Multimap attributes, ItemStack stack) { + attributes.put(SharedMonsterAttributes.maxHealth.getAttributeUnlocalizedName(), new AttributeModifier(getBaubleUUID(stack), "Bauble modifier", 20, 0)); + } + + @Override + public Achievement getAchievementOnCraft(ItemStack stack, EntityPlayer player, IInventory matrix) { + return ModAchievements.relicAesirRing; + } -public class ItemAesirRing extends ItemRelicBauble - implements IExtendedWireframeCoordinateListProvider, ICraftAchievement { - - Multimap attributes = HashMultimap.create(); - - public ItemAesirRing() { - super(LibItemNames.AESIR_RING); - GameRegistry.addRecipe(new AesirRingRecipe()); - RecipeSorter.register("botania:aesirRing", AesirRingRecipe.class, Category.SHAPELESS, ""); - MinecraftForge.EVENT_BUS.register(this); - } - - @SubscribeEvent - public void onDropped(ItemTossEvent event) { - if (event.entityItem != null - && event.entityItem.getEntityItem() != null - && !event.entityItem.worldObj.isRemote) { - ItemStack stack = event.entityItem.getEntityItem(); - if (stack.getItem() != null && stack.getItem() == this) { - event.entityItem.setDead(); - - String user = getSoulbindUsername(stack); - for (Item item : new Item[] {ModItems.thorRing, ModItems.lokiRing, ModItems.odinRing}) { - ItemStack stack1 = new ItemStack(item); - bindToUsername(user, stack1); - EntityItem entity = new EntityItem( - event.entityItem.worldObj, - event.entityItem.posX, - event.entityItem.posY, - event.entityItem.posZ, - stack1); - entity.motionX = event.entityItem.motionX; - entity.motionY = event.entityItem.motionY; - entity.motionZ = event.entityItem.motionZ; - entity.age = event.entityItem.age; - entity.delayBeforeCanPickup = event.entityItem.delayBeforeCanPickup; - entity.worldObj.spawnEntityInWorld(entity); - } - } - } - } - - @Override - public void onValidPlayerWornTick(ItemStack stack, EntityPlayer player) { - ((ItemOdinRing) ModItems.odinRing).onValidPlayerWornTick(stack, player); - } - - @Override - public BaubleType getBaubleType(ItemStack arg0) { - return BaubleType.RING; - } - - @Override - public List getWireframesToDraw(EntityPlayer player, ItemStack stack) { - return ((IWireframeCoordinateListProvider) ModItems.lokiRing).getWireframesToDraw(player, stack); - } - - @Override - public ChunkCoordinates getSourceWireframe(EntityPlayer player, ItemStack stack) { - return ((IExtendedWireframeCoordinateListProvider) ModItems.lokiRing).getSourceWireframe(player, stack); - } - - @Override - public void onEquippedOrLoadedIntoWorld(ItemStack stack, EntityLivingBase player) { - attributes.clear(); - fillModifiers(attributes, stack); - player.getAttributeMap().applyAttributeModifiers(attributes); - } - - @Override - public void onUnequipped(ItemStack stack, EntityLivingBase player) { - attributes.clear(); - fillModifiers(attributes, stack); - player.getAttributeMap().removeAttributeModifiers(attributes); - } - - void fillModifiers(Multimap attributes, ItemStack stack) { - attributes.put( - SharedMonsterAttributes.maxHealth.getAttributeUnlocalizedName(), - new AttributeModifier(getBaubleUUID(stack), "Bauble modifier", 20, 0)); - } - - @Override - public Achievement getAchievementOnCraft(ItemStack stack, EntityPlayer player, IInventory matrix) { - return ModAchievements.relicAesirRing; - } } diff --git a/src/main/java/vazkii/botania/common/item/relic/ItemDice.java b/src/main/java/vazkii/botania/common/item/relic/ItemDice.java index e3d4b970a6..a0594132b5 100644 --- a/src/main/java/vazkii/botania/common/item/relic/ItemDice.java +++ b/src/main/java/vazkii/botania/common/item/relic/ItemDice.java @@ -2,16 +2,17 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Mar 30, 2015, 6:52:35 PM (GMT)] */ package vazkii.botania.common.item.relic; import java.util.ArrayList; import java.util.List; + import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayerMP; import net.minecraft.item.Item; @@ -27,69 +28,73 @@ public class ItemDice extends ItemRelic { - private static final int[] SIDES_FOR_MOON_PHASES = new int[] {-1, 0, 1, 2, -1, 2, 3, 4}; - - public static ItemStack[] relicStacks; - - public ItemDice() { - super(LibItemNames.DICE); - - relicStacks = new ItemStack[] { - new ItemStack(ModItems.infiniteFruit), - new ItemStack(ModItems.kingKey), - new ItemStack(ModItems.flugelEye), - new ItemStack(ModItems.thorRing), - new ItemStack(ModItems.odinRing), - new ItemStack(ModItems.lokiRing) - }; - } - - @Override - public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer player) { - if (isRightPlayer(player, stack) && !player.worldObj.isRemote) { - int moonPhase = world.provider.getMoonPhase(world.getWorldTime()); - int side = SIDES_FOR_MOON_PHASES[moonPhase]; - int relic = side; - if (hasRelicAlready(player, relic)) { - List possible = new ArrayList(); - List alreadyHas = new ArrayList(); - for (int i = 0; i < 6; i++) - if (hasRelicAlready(player, i)) alreadyHas.add(i); - else possible.add(i); - - if (alreadyHas.size() > 0) possible.add(alreadyHas.get(world.rand.nextInt(alreadyHas.size()))); - relic = possible.get(world.rand.nextInt(possible.size())); - } - - world.playSoundAtEntity(player, "random.bow", 0.5F, 0.4F / (world.rand.nextFloat() * 0.4F + 0.8F)); - - if (hasRelicAlready(player, relic)) { - player.addChatMessage(new ChatComponentTranslation("botaniamisc.dudDiceRoll", relic + 1) - .setChatStyle(new ChatStyle().setColor(EnumChatFormatting.DARK_GREEN))); - stack.stackSize--; - return stack; - } - - player.addChatMessage(new ChatComponentTranslation("botaniamisc.diceRoll", relic + 1) - .setChatStyle(new ChatStyle().setColor(EnumChatFormatting.DARK_GREEN))); - return relicStacks[relic].copy(); - } - - return stack; - } - - @Override - public boolean shouldDamageWrongPlayer() { - return false; - } - - boolean hasRelicAlready(EntityPlayer player, int relic) { - if (relic < 0 || relic > 5 || !(player instanceof EntityPlayerMP)) return true; - - EntityPlayerMP mpPlayer = (EntityPlayerMP) player; - Item item = relicStacks[relic].getItem(); - IRelic irelic = (IRelic) item; - Achievement achievement = irelic.getBindAchievement(); - return mpPlayer.func_147099_x().hasAchievementUnlocked(achievement); - } + private static final int[] SIDES_FOR_MOON_PHASES = new int[] { + -1, 0, 1, 2, -1, 2, 3, 4 + }; + + public static ItemStack[] relicStacks; + + public ItemDice() { + super(LibItemNames.DICE); + + relicStacks = new ItemStack[] { + new ItemStack(ModItems.infiniteFruit), + new ItemStack(ModItems.kingKey), + new ItemStack(ModItems.flugelEye), + new ItemStack(ModItems.thorRing), + new ItemStack(ModItems.odinRing), + new ItemStack(ModItems.lokiRing) + }; + } + + @Override + public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer player) { + if(isRightPlayer(player, stack) && !player.worldObj.isRemote) { + int moonPhase = world.provider.getMoonPhase(world.getWorldTime()); + int side = SIDES_FOR_MOON_PHASES[moonPhase]; + int relic = side; + if(hasRelicAlready(player, relic)) { + List possible = new ArrayList(); + List alreadyHas = new ArrayList(); + for(int i = 0; i < 6; i++) + if(hasRelicAlready(player, i)) + alreadyHas.add(i); + else possible.add(i); + + if(alreadyHas.size() > 0) + possible.add(alreadyHas.get(world.rand.nextInt(alreadyHas.size()))); + relic = possible.get(world.rand.nextInt(possible.size())); + } + + world.playSoundAtEntity(player, "random.bow", 0.5F, 0.4F / (world.rand.nextFloat() * 0.4F + 0.8F)); + + if(hasRelicAlready(player, relic)) { + player.addChatMessage(new ChatComponentTranslation("botaniamisc.dudDiceRoll", relic + 1).setChatStyle(new ChatStyle().setColor(EnumChatFormatting.DARK_GREEN))); + stack.stackSize--; + return stack; + } + + player.addChatMessage(new ChatComponentTranslation("botaniamisc.diceRoll", relic + 1).setChatStyle(new ChatStyle().setColor(EnumChatFormatting.DARK_GREEN))); + return relicStacks[relic].copy(); + } + + return stack; + } + + @Override + public boolean shouldDamageWrongPlayer() { + return false; + } + + boolean hasRelicAlready(EntityPlayer player, int relic) { + if(relic < 0 || relic > 5 || !(player instanceof EntityPlayerMP)) + return true; + + EntityPlayerMP mpPlayer = (EntityPlayerMP) player; + Item item = relicStacks[relic].getItem(); + IRelic irelic = (IRelic) item; + Achievement achievement = irelic.getBindAchievement(); + return mpPlayer.func_147099_x().hasAchievementUnlocked(achievement); + } + } diff --git a/src/main/java/vazkii/botania/common/item/relic/ItemExcaliber.java b/src/main/java/vazkii/botania/common/item/relic/ItemExcaliber.java index 40a1f2f5f7..471f677e70 100644 --- a/src/main/java/vazkii/botania/common/item/relic/ItemExcaliber.java +++ b/src/main/java/vazkii/botania/common/item/relic/ItemExcaliber.java @@ -2,14 +2,48 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Mar 29, 2015, 10:12:50 PM (GMT)] */ /*package vazkii.botania.common.item.relic; +import java.util.List; + +import net.minecraft.entity.Entity; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.entity.SharedMonsterAttributes; +import net.minecraft.entity.ai.attributes.AttributeModifier; +import net.minecraft.entity.boss.IBossDisplayData; +import net.minecraft.entity.monster.IMob; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.projectile.EntityThrowable; +import net.minecraft.item.EnumRarity; +import net.minecraft.item.ItemStack; +import net.minecraft.potion.Potion; +import net.minecraft.potion.PotionEffect; +import net.minecraft.server.MinecraftServer; +import net.minecraft.stats.Achievement; +import net.minecraft.util.AxisAlignedBB; +import net.minecraft.util.DamageSource; +import net.minecraft.util.MovingObjectPosition; +import net.minecraft.world.World; +import net.minecraftforge.common.util.EnumHelper; +import vazkii.botania.api.BotaniaAPI; +import vazkii.botania.api.internal.IManaBurst; +import vazkii.botania.api.item.IRelic; +import vazkii.botania.api.mana.BurstProperties; +import vazkii.botania.api.mana.ILensEffect; +import vazkii.botania.common.core.helper.ItemNBTHelper; +import vazkii.botania.common.core.helper.Vector3; +import vazkii.botania.common.entity.EntityManaBurst; +import vazkii.botania.common.item.equipment.tool.manasteel.ItemManasteelSword; +import vazkii.botania.common.lib.LibItemNames; + +import com.google.common.collect.HashMultimap; +import com.google.common.collect.Multimap; public class ItemExcaliber extends ItemManasteelSword implements IRelic, ILensEffect { @@ -186,4 +220,4 @@ public EnumRarity getRarity(ItemStack p_77613_1_) { } } - */ + */ \ No newline at end of file diff --git a/src/main/java/vazkii/botania/common/item/relic/ItemFlugelEye.java b/src/main/java/vazkii/botania/common/item/relic/ItemFlugelEye.java index a029e3b250..d6f9e20f60 100644 --- a/src/main/java/vazkii/botania/common/item/relic/ItemFlugelEye.java +++ b/src/main/java/vazkii/botania/common/item/relic/ItemFlugelEye.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Mar 29, 2015, 10:13:26 PM (GMT)] */ package vazkii.botania.common.item.relic; @@ -27,454 +27,413 @@ public class ItemFlugelEye extends ItemRelic implements ICoordBoundItem, IManaUsingItem { - public ItemFlugelEye() { - super(LibItemNames.FLUGEL_EYE); - } - - private static final String TAG_X = "x"; - private static final String TAG_Y = "y"; - private static final String TAG_Z = "z"; - private static final String TAG_DIMENSION = "dim"; - - @Override - public boolean onItemUse( - ItemStack stack, - EntityPlayer player, - World world, - int x, - int y, - int z, - int side, - float hitX, - float hitY, - float hitZ) { - if (player.isSneaking()) { - if (world.isRemote) { - player.swingItem(); - for (int i = 0; i < 10; i++) { - float x1 = (float) (x + Math.random()); - float y1 = y + 1; - float z1 = (float) (z + Math.random()); - Botania.proxy.wispFX( - player.worldObj, - x1, - y1, - z1, - (float) Math.random(), - (float) Math.random(), - (float) Math.random(), - (float) Math.random() * 0.5F, - -0.05F + (float) Math.random() * 0.05F); - } - } else { - ItemNBTHelper.setInt(stack, TAG_X, x); - ItemNBTHelper.setInt(stack, TAG_Y, y); - ItemNBTHelper.setInt(stack, TAG_Z, z); - ItemNBTHelper.setInt(stack, TAG_DIMENSION, world.provider.dimensionId); - world.playSoundAtEntity(player, "mob.endermen.portal", 1F, 5F); - } - } - - return true; - } - - @Override - public void onUsingTick(ItemStack stack, EntityPlayer player, int count) { - float x = (float) (player.posX - Math.random() * player.width); - float y = (float) (player.posY - 1.6 + Math.random()); - float z = (float) (player.posZ - Math.random() * player.width); - Botania.proxy.wispFX( - player.worldObj, - x, - y, - z, - (float) Math.random(), - (float) Math.random(), - (float) Math.random(), - (float) Math.random() * 0.7F, - -0.05F - (float) Math.random() * 0.05F); - } - - @Override - public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer) { - par3EntityPlayer.setItemInUse(par1ItemStack, getMaxItemUseDuration(par1ItemStack)); - return par1ItemStack; - } - - @Override - public ItemStack onEaten(ItemStack stack, World world, EntityPlayer player) { - int x = ItemNBTHelper.getInt(stack, TAG_X, 0); - int y = ItemNBTHelper.getInt(stack, TAG_Y, -1); - int z = ItemNBTHelper.getInt(stack, TAG_Z, 0); - int dim = ItemNBTHelper.getInt(stack, TAG_DIMENSION, 0); - - int cost = (int) - (MathHelper.pointDistanceSpace(x + 0.5, y + 0.5, z + 0.5, player.posX, player.posY, player.posZ) * 10); - - if (y > -1 - && dim == world.provider.dimensionId - && ManaItemHandler.requestManaExact(stack, player, cost, true)) { - moveParticlesAndSound(player); - if (player instanceof EntityPlayerMP && !world.isRemote) - ((EntityPlayerMP) player) - .playerNetServerHandler.setPlayerLocation( - x + 0.5, y + 1.6, z + 0.5, player.rotationYaw, player.rotationPitch); - moveParticlesAndSound(player); - } - - return stack; - } - - private static void moveParticlesAndSound(Entity entity) { - for (int i = 0; i < 15; i++) { - float x = (float) (entity.posX + Math.random()); - float y = (float) (entity.posY - 1.6 + Math.random()); - float z = (float) (entity.posZ + Math.random()); - Botania.proxy.wispFX( - entity.worldObj, - x, - y, - z, - (float) Math.random(), - (float) Math.random(), - (float) Math.random(), - (float) Math.random(), - -0.3F + (float) Math.random() * 0.2F); - } - if (!entity.worldObj.isRemote) entity.worldObj.playSoundAtEntity(entity, "mob.endermen.portal", 1F, 1F); - } - - @Override - public int getMaxItemUseDuration(ItemStack par1ItemStack) { - return 40; - } - - @Override - public EnumAction getItemUseAction(ItemStack par1ItemStack) { - return EnumAction.block; - } - - @Override - public ChunkCoordinates getBinding(ItemStack stack) { - int x = ItemNBTHelper.getInt(stack, TAG_X, 0); - int y = ItemNBTHelper.getInt(stack, TAG_Y, -1); - int z = ItemNBTHelper.getInt(stack, TAG_Z, 0); - return y == -1 ? null : new ChunkCoordinates(x, y, z); - } - - @Override - public boolean usesMana(ItemStack stack) { - return true; - } - - /* - // Code from the older iteration of this item: - - private static final ResourceLocation glowTexture = new ResourceLocation(LibResources.MISC_GLOW_CYAN); - - private static final int SEGMENTS = 12; - private static final MultiversePosition FALLBACK_POSITION = new MultiversePosition(0, -1, 0, 0); - - private static final String TAG_EQUIPPED = "equipped"; - private static final String TAG_ROTATION_BASE = "rotationBase"; - private static final String TAG_WARP_PREFIX = "warp"; - private static final String TAG_POS_X = "posX"; - private static final String TAG_POS_Y = "posY"; - private static final String TAG_POS_Z = "posZ"; - private static final String TAG_DIMENSION = "dim"; - private static final String TAG_FIRST_TICK = "firstTick"; - - IIcon[] signs; - - public ItemFlugelEye() { - super(LibItemNames.FLUGEL_EYE); - MinecraftForge.EVENT_BUS.register(this); - } - - @Override - @SideOnly(Side.CLIENT) - public void registerIcons(IIconRegister par1IconRegister) { - super.registerIcons(par1IconRegister); - signs = new IIcon[12]; - for(int i = 0; i < 12; i++) - signs[i] = IconHelper.forName(par1IconRegister, "sign" + i); - } - - @Override - public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer player) { - if(isRightPlayer(player, stack)) { - int segment = getSegmentLookedAt(stack, player); - MultiversePosition pos = getWarpPoint(stack, segment); - if(pos.isValid()) { - if(pos.dim == world.provider.dimensionId && player instanceof EntityPlayerMP) { - ((EntityPlayerMP) player).playerNetServerHandler.setPlayerLocation(pos.x, pos.y, pos.z, player.rotationYaw, player.rotationPitch); - world.playSoundAtEntity(player, "mob.endermen.portal", 1F, 1F); - } - } else setWarpPoint(stack, segment, player.posX, player.posY, player.posZ, world.provider.dimensionId); - } - - return stack; - } - - @Override - public boolean onEntitySwing(EntityLivingBase player, ItemStack stack) { - if(player.isSneaking() && player instanceof EntityPlayer && isRightPlayer((EntityPlayer) player, stack)) { - int segment = getSegmentLookedAt(stack, player); - MultiversePosition pos = getWarpPoint(stack, segment); - if(pos.isValid()) { - setWarpPoint(stack, segment, 0, -1, 0, 0); - return true; - } - } - - return false; - } - - @Override - public void onUpdate(ItemStack stack, World world, Entity entity, int pos, boolean equipped) { - super.onUpdate(stack, world, entity, pos, equipped); - boolean eqLastTick = wasEquipped(stack); - boolean firstTick = isFirstTick(stack); - if(eqLastTick != equipped) - setEquipped(stack, equipped); - - if((!equipped || firstTick) && entity instanceof EntityLivingBase) { - int angles = 360; - int segAngles = angles / SEGMENTS; - float shift = segAngles / 2; - setRotationBase(stack, getCheckingAngle((EntityLivingBase) entity) - shift); - if(firstTick) - tickFirst(stack); - } - } - - private static int getSegmentLookedAt(ItemStack stack, EntityLivingBase player) { - float yaw = getCheckingAngle(player, getRotationBase(stack)); - - int angles = 360; - int segAngles = angles / SEGMENTS; - for(int seg = 0; seg < SEGMENTS; seg++) { - float calcAngle = (float) seg * segAngles; - if(yaw >= calcAngle && yaw < calcAngle + segAngles) - return seg; - } - return 0; - } - - private static float getCheckingAngle(EntityLivingBase player) { - return getCheckingAngle(player, 0F); - } - - // Screw the way minecraft handles rotation - // Really... - private static float getCheckingAngle(EntityLivingBase player, float base) { - float yaw = MathHelper.wrapAngleTo180_float(player.rotationYaw) + 90F; - int angles = 360; - int segAngles = angles / SEGMENTS; - float shift = segAngles / 2; - - if(yaw < 0) - yaw = 180F + (180F + yaw); - yaw -= 360F - base; - float angle = 360F - yaw + shift; - - if(angle < 0) - angle = 360F + angle; - - return angle; - } - - public static boolean isFirstTick(ItemStack stack) { - return ItemNBTHelper.getBoolean(stack, TAG_FIRST_TICK, true); - } - - public static void tickFirst(ItemStack stack) { - ItemNBTHelper.setBoolean(stack, TAG_FIRST_TICK, false); - } - - public static boolean wasEquipped(ItemStack stack) { - return ItemNBTHelper.getBoolean(stack, TAG_EQUIPPED, false); - } - - public static void setEquipped(ItemStack stack, boolean equipped) { - ItemNBTHelper.setBoolean(stack, TAG_EQUIPPED, equipped); - } - - public static float getRotationBase(ItemStack stack) { - return ItemNBTHelper.getFloat(stack, TAG_ROTATION_BASE, 0F); - } - - public static void setRotationBase(ItemStack stack, float rotation) { - ItemNBTHelper.setFloat(stack, TAG_ROTATION_BASE, rotation); - } - - public static void setWarpPoint(ItemStack stack, int warp, double x, double y, double z, int dim) { - NBTTagCompound cmp = new NBTTagCompound(); - cmp.setDouble(TAG_POS_X, x); - cmp.setDouble(TAG_POS_Y, y); - cmp.setDouble(TAG_POS_Z, z); - cmp.setInteger(TAG_DIMENSION, dim); - ItemNBTHelper.setCompound(stack, TAG_WARP_PREFIX + warp, cmp); - } - - public static MultiversePosition getWarpPoint(ItemStack stack, int warp) { - NBTTagCompound cmp = ItemNBTHelper.getCompound(stack, TAG_WARP_PREFIX + warp, true); - if(cmp == null) - return FALLBACK_POSITION; - - double x = cmp.getDouble(TAG_POS_X); - double y = cmp.getDouble(TAG_POS_Y); - double z = cmp.getDouble(TAG_POS_Z); - int dim = cmp.getInteger(TAG_DIMENSION); - return new MultiversePosition(x, y, z, dim); - } - - @SideOnly(Side.CLIENT) - @SubscribeEvent - public void onRenderWorldLast(RenderWorldLastEvent event) { - EntityPlayer player = Minecraft.getMinecraft().thePlayer; - ItemStack stack = player.getCurrentEquippedItem(); - if(stack != null && stack.getItem() == this) - render(stack, player, event.partialTicks); - } - - @SideOnly(Side.CLIENT) - public void render(ItemStack stack, EntityPlayer player, float partialTicks) { - Minecraft mc = Minecraft.getMinecraft(); - Tessellator tess = Tessellator.instance; - Tessellator.renderingWorldRenderer = false; - - GL11.glPushMatrix(); - GL11.glEnable(GL11.GL_BLEND); - GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); - float alpha = ((float) Math.sin((ClientTickHandler.ticksInGame + partialTicks) * 0.2F) * 0.5F + 0.5F) * 0.4F + 0.3F; - - double posX = player.prevPosX + (player.posX - player.prevPosX) * partialTicks; - double posY = player.prevPosY + (player.posY - player.prevPosY) * partialTicks; - double posZ = player.prevPosZ + (player.posZ - player.prevPosZ) * partialTicks; - - GL11.glTranslated(posX - RenderManager.renderPosX, posY - RenderManager.renderPosY, posZ - RenderManager.renderPosZ); - - float base = getRotationBase(stack); - int angles = 360; - int segAngles = angles / SEGMENTS; - float shift = base - segAngles / 2; - - float u = 1F; - float v = 0.25F; - - float s = 3F; - float m = 0.8F; - float y = v * s * 2; - float y0 = 0; - - int segmentLookedAt = getSegmentLookedAt(stack, player); - - for(int seg = 0; seg < SEGMENTS; seg++) { - boolean inside = false; - float rotationAngle = (seg + 0.5F) * segAngles + shift; - if(segmentLookedAt == seg) - inside = true; - - GL11.glPushMatrix(); - GL11.glRotatef(rotationAngle, 0F, 1F, 0F); - GL11.glTranslatef(s * m, -0.75F, 0F); - - mc.renderEngine.bindTexture(TextureMap.locationItemsTexture); - GL11.glScalef(0.75F, 0.75F, 0.75F); - GL11.glTranslatef(0F, 0F, 0.5F); - IIcon icon = signs[seg]; - GL11.glRotatef(90F, 0F, 1F, 0F); - GL11.glColor4f(1F, 1F, 1F, getWarpPoint(stack, seg).isValid() ? 1F : 0.2F); - float f = icon.getMinU(); - float f1 = icon.getMaxU(); - float f2 = icon.getMinV(); - float f3 = icon.getMaxV(); - ItemRenderer.renderItemIn2D(Tessellator.instance, f1, f2, f, f3, icon.getIconWidth(), icon.getIconHeight(), 1F / 16F); - - GL11.glColor3f(1F, 1F, 1F); - GL11.glPopMatrix(); - - GL11.glPushMatrix(); - GL11.glRotatef(180F, 1F, 0F, 0F); - float a = alpha; - if(inside) { - a += 0.3F; - y0 = -y; - } - - if(seg % 2 == 0) - GL11.glColor4f(0.6F, 0.6F, 0.6F, a); - else GL11.glColor4f(1F, 1F, 1F, a); - - mc.renderEngine.bindTexture(glowTexture); - tess.startDrawingQuads(); - for(int i = 0; i < segAngles; i++) { - float ang = i + seg * segAngles + shift; - double xp = Math.cos(ang * Math.PI / 180F) * s; - double zp = Math.sin(ang * Math.PI / 180F) * s; - - tess.addVertexWithUV(xp * m, y, zp * m, u, v); - tess.addVertexWithUV(xp, y0, zp, u, 0); - - xp = Math.cos((ang + 1) * Math.PI / 180F) * s; - zp = Math.sin((ang + 1) * Math.PI / 180F) * s; - - tess.addVertexWithUV(xp, y0, zp, 0, 0); - tess.addVertexWithUV(xp * m, y, zp * m, 0, v); - } - y0 = 0; - tess.draw(); - - GL11.glPopMatrix(); - } - GL11.glPopMatrix(); - } - - @SideOnly(Side.CLIENT) - public static void renderHUD(ScaledResolution resolution, EntityPlayer player, ItemStack stack) { - Minecraft.getMinecraft(); - int slot = getSegmentLookedAt(stack, player); - MultiversePosition pos = getWarpPoint(stack, slot); - - FontRenderer font = Minecraft.getMinecraft().fontRenderer; - String s = StatCollector.translateToLocal("botania.sign" + slot); - font.drawStringWithShadow(s, resolution.getScaledWidth() / 2 - font.getStringWidth(s) / 2, resolution.getScaledHeight() / 2 - 55, 0xFFD409); - - if(pos.isValid()) { - int dist = (int) vazkii.botania.common.core.helper.MathHelper.pointDistanceSpace(pos.x, pos.y, pos.z, player.posX, player.posY - 1.6, player.posZ); - - s = dist == 1 ? StatCollector.translateToLocal("botaniamisc.blockAway") : String.format(StatCollector.translateToLocal("botaniamisc.blocksAway"), dist); - font.drawStringWithShadow(s, resolution.getScaledWidth() / 2 - font.getStringWidth(s) / 2, resolution.getScaledHeight() / 2 - 40, 0x9999FF); - s = StatCollector.translateToLocal("botaniamisc.clickToTeleport"); - font.drawStringWithShadow(s, resolution.getScaledWidth() / 2 - font.getStringWidth(s) / 2, resolution.getScaledHeight() / 2 - 30, 0xFFFFFF); - s = StatCollector.translateToLocal("botaniamisc.clickToRemoveWarp"); - font.drawStringWithShadow(s, resolution.getScaledWidth() / 2 - font.getStringWidth(s) / 2, resolution.getScaledHeight() / 2 - 20, 0xFFFFFF); - } else { - s = StatCollector.translateToLocal("botaniamisc.unboundWarp"); - font.drawStringWithShadow(s, resolution.getScaledWidth() / 2 - font.getStringWidth(s) / 2, resolution.getScaledHeight() / 2 - 40, 0xFFFFFF); - s = StatCollector.translateToLocal("botaniamisc.clickToAddWarp"); - font.drawStringWithShadow(s, resolution.getScaledWidth() / 2 - font.getStringWidth(s) / 2, resolution.getScaledHeight() / 2 - 30, 0xFFFFFF); - } - } - - private static class MultiversePosition { - - public final double x, y, z; - public final int dim; - - public MultiversePosition(double x, double y, double z, int dim) { - this.x = x; - this.y = y; - this.z = z; - this.dim = dim; - } - - boolean isValid() { - return y > 0; - } - - } - */ + public ItemFlugelEye() { + super(LibItemNames.FLUGEL_EYE); + } + + private static final String TAG_X = "x"; + private static final String TAG_Y = "y"; + private static final String TAG_Z = "z"; + private static final String TAG_DIMENSION = "dim"; + + @Override + public boolean onItemUse(ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int side, float hitX, float hitY, float hitZ) { + if(player.isSneaking()) { + if(world.isRemote) { + player.swingItem(); + for(int i = 0; i < 10; i++) { + float x1 = (float) (x + Math.random()); + float y1 = y + 1; + float z1 = (float) (z + Math.random()); + Botania.proxy.wispFX(player.worldObj, x1, y1, z1, (float) Math.random(), (float) Math.random(), (float) Math.random(), (float) Math.random() * 0.5F, -0.05F + (float) Math.random() * 0.05F); + } + } else { + ItemNBTHelper.setInt(stack, TAG_X, x); + ItemNBTHelper.setInt(stack, TAG_Y, y); + ItemNBTHelper.setInt(stack, TAG_Z, z); + ItemNBTHelper.setInt(stack, TAG_DIMENSION, world.provider.dimensionId); + world.playSoundAtEntity(player, "mob.endermen.portal", 1F, 5F); + } + } + + return true; + } + + @Override + public void onUsingTick(ItemStack stack, EntityPlayer player, int count) { + float x = (float) (player.posX - Math.random() * player.width); + float y = (float) (player.posY - 1.6 + Math.random()); + float z = (float) (player.posZ - Math.random() * player.width); + Botania.proxy.wispFX(player.worldObj, x, y, z, (float) Math.random(), (float) Math.random(), (float) Math.random(), (float) Math.random() * 0.7F, -0.05F - (float) Math.random() * 0.05F); + } + + @Override + public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer) { + par3EntityPlayer.setItemInUse(par1ItemStack, getMaxItemUseDuration(par1ItemStack)); + return par1ItemStack; + } + + @Override + public ItemStack onEaten(ItemStack stack, World world, EntityPlayer player) { + int x = ItemNBTHelper.getInt(stack, TAG_X, 0); + int y = ItemNBTHelper.getInt(stack, TAG_Y, -1); + int z = ItemNBTHelper.getInt(stack, TAG_Z, 0); + int dim = ItemNBTHelper.getInt(stack, TAG_DIMENSION, 0); + + int cost = (int) (MathHelper.pointDistanceSpace(x + 0.5, y + 0.5, z + 0.5, player.posX, player.posY, player.posZ) * 10); + + if(y > -1 && dim == world.provider.dimensionId && ManaItemHandler.requestManaExact(stack, player, cost, true)) { + moveParticlesAndSound(player); + if(player instanceof EntityPlayerMP && !world.isRemote) + ((EntityPlayerMP) player).playerNetServerHandler.setPlayerLocation(x + 0.5, y + 1.6, z + 0.5, player.rotationYaw, player.rotationPitch); + moveParticlesAndSound(player); + } + + return stack; + } + + private static void moveParticlesAndSound(Entity entity) { + for(int i = 0; i < 15; i++) { + float x = (float) (entity.posX + Math.random()); + float y = (float) (entity.posY - 1.6 + Math.random()); + float z = (float) (entity.posZ + Math.random()); + Botania.proxy.wispFX(entity.worldObj, x, y, z, (float) Math.random(), (float) Math.random(), (float) Math.random(), (float) Math.random(), -0.3F + (float) Math.random() * 0.2F); + } + if(!entity.worldObj.isRemote) + entity.worldObj.playSoundAtEntity(entity, "mob.endermen.portal", 1F, 1F); + } + + @Override + public int getMaxItemUseDuration(ItemStack par1ItemStack) { + return 40; + } + + @Override + public EnumAction getItemUseAction(ItemStack par1ItemStack) { + return EnumAction.block; + } + + @Override + public ChunkCoordinates getBinding(ItemStack stack) { + int x = ItemNBTHelper.getInt(stack, TAG_X, 0); + int y = ItemNBTHelper.getInt(stack, TAG_Y, -1); + int z = ItemNBTHelper.getInt(stack, TAG_Z, 0); + return y == -1 ? null : new ChunkCoordinates(x, y, z); + } + + @Override + public boolean usesMana(ItemStack stack) { + return true; + } + + /* + // Code from the older iteration of this item: + + private static final ResourceLocation glowTexture = new ResourceLocation(LibResources.MISC_GLOW_CYAN); + + private static final int SEGMENTS = 12; + private static final MultiversePosition FALLBACK_POSITION = new MultiversePosition(0, -1, 0, 0); + + private static final String TAG_EQUIPPED = "equipped"; + private static final String TAG_ROTATION_BASE = "rotationBase"; + private static final String TAG_WARP_PREFIX = "warp"; + private static final String TAG_POS_X = "posX"; + private static final String TAG_POS_Y = "posY"; + private static final String TAG_POS_Z = "posZ"; + private static final String TAG_DIMENSION = "dim"; + private static final String TAG_FIRST_TICK = "firstTick"; + + IIcon[] signs; + + public ItemFlugelEye() { + super(LibItemNames.FLUGEL_EYE); + MinecraftForge.EVENT_BUS.register(this); + } + + @Override + @SideOnly(Side.CLIENT) + public void registerIcons(IIconRegister par1IconRegister) { + super.registerIcons(par1IconRegister); + signs = new IIcon[12]; + for(int i = 0; i < 12; i++) + signs[i] = IconHelper.forName(par1IconRegister, "sign" + i); + } + + @Override + public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer player) { + if(isRightPlayer(player, stack)) { + int segment = getSegmentLookedAt(stack, player); + MultiversePosition pos = getWarpPoint(stack, segment); + if(pos.isValid()) { + if(pos.dim == world.provider.dimensionId && player instanceof EntityPlayerMP) { + ((EntityPlayerMP) player).playerNetServerHandler.setPlayerLocation(pos.x, pos.y, pos.z, player.rotationYaw, player.rotationPitch); + world.playSoundAtEntity(player, "mob.endermen.portal", 1F, 1F); + } + } else setWarpPoint(stack, segment, player.posX, player.posY, player.posZ, world.provider.dimensionId); + } + + return stack; + } + + @Override + public boolean onEntitySwing(EntityLivingBase player, ItemStack stack) { + if(player.isSneaking() && player instanceof EntityPlayer && isRightPlayer((EntityPlayer) player, stack)) { + int segment = getSegmentLookedAt(stack, player); + MultiversePosition pos = getWarpPoint(stack, segment); + if(pos.isValid()) { + setWarpPoint(stack, segment, 0, -1, 0, 0); + return true; + } + } + + return false; + } + + @Override + public void onUpdate(ItemStack stack, World world, Entity entity, int pos, boolean equipped) { + super.onUpdate(stack, world, entity, pos, equipped); + boolean eqLastTick = wasEquipped(stack); + boolean firstTick = isFirstTick(stack); + if(eqLastTick != equipped) + setEquipped(stack, equipped); + + if((!equipped || firstTick) && entity instanceof EntityLivingBase) { + int angles = 360; + int segAngles = angles / SEGMENTS; + float shift = segAngles / 2; + setRotationBase(stack, getCheckingAngle((EntityLivingBase) entity) - shift); + if(firstTick) + tickFirst(stack); + } + } + + private static int getSegmentLookedAt(ItemStack stack, EntityLivingBase player) { + float yaw = getCheckingAngle(player, getRotationBase(stack)); + + int angles = 360; + int segAngles = angles / SEGMENTS; + for(int seg = 0; seg < SEGMENTS; seg++) { + float calcAngle = (float) seg * segAngles; + if(yaw >= calcAngle && yaw < calcAngle + segAngles) + return seg; + } + return 0; + } + + private static float getCheckingAngle(EntityLivingBase player) { + return getCheckingAngle(player, 0F); + } + + // Screw the way minecraft handles rotation + // Really... + private static float getCheckingAngle(EntityLivingBase player, float base) { + float yaw = MathHelper.wrapAngleTo180_float(player.rotationYaw) + 90F; + int angles = 360; + int segAngles = angles / SEGMENTS; + float shift = segAngles / 2; + + if(yaw < 0) + yaw = 180F + (180F + yaw); + yaw -= 360F - base; + float angle = 360F - yaw + shift; + + if(angle < 0) + angle = 360F + angle; + + return angle; + } + + public static boolean isFirstTick(ItemStack stack) { + return ItemNBTHelper.getBoolean(stack, TAG_FIRST_TICK, true); + } + + public static void tickFirst(ItemStack stack) { + ItemNBTHelper.setBoolean(stack, TAG_FIRST_TICK, false); + } + + public static boolean wasEquipped(ItemStack stack) { + return ItemNBTHelper.getBoolean(stack, TAG_EQUIPPED, false); + } + + public static void setEquipped(ItemStack stack, boolean equipped) { + ItemNBTHelper.setBoolean(stack, TAG_EQUIPPED, equipped); + } + + public static float getRotationBase(ItemStack stack) { + return ItemNBTHelper.getFloat(stack, TAG_ROTATION_BASE, 0F); + } + + public static void setRotationBase(ItemStack stack, float rotation) { + ItemNBTHelper.setFloat(stack, TAG_ROTATION_BASE, rotation); + } + + public static void setWarpPoint(ItemStack stack, int warp, double x, double y, double z, int dim) { + NBTTagCompound cmp = new NBTTagCompound(); + cmp.setDouble(TAG_POS_X, x); + cmp.setDouble(TAG_POS_Y, y); + cmp.setDouble(TAG_POS_Z, z); + cmp.setInteger(TAG_DIMENSION, dim); + ItemNBTHelper.setCompound(stack, TAG_WARP_PREFIX + warp, cmp); + } + + public static MultiversePosition getWarpPoint(ItemStack stack, int warp) { + NBTTagCompound cmp = ItemNBTHelper.getCompound(stack, TAG_WARP_PREFIX + warp, true); + if(cmp == null) + return FALLBACK_POSITION; + + double x = cmp.getDouble(TAG_POS_X); + double y = cmp.getDouble(TAG_POS_Y); + double z = cmp.getDouble(TAG_POS_Z); + int dim = cmp.getInteger(TAG_DIMENSION); + return new MultiversePosition(x, y, z, dim); + } + + @SideOnly(Side.CLIENT) + @SubscribeEvent + public void onRenderWorldLast(RenderWorldLastEvent event) { + EntityPlayer player = Minecraft.getMinecraft().thePlayer; + ItemStack stack = player.getCurrentEquippedItem(); + if(stack != null && stack.getItem() == this) + render(stack, player, event.partialTicks); + } + + @SideOnly(Side.CLIENT) + public void render(ItemStack stack, EntityPlayer player, float partialTicks) { + Minecraft mc = Minecraft.getMinecraft(); + Tessellator tess = Tessellator.instance; + Tessellator.renderingWorldRenderer = false; + + GL11.glPushMatrix(); + GL11.glEnable(GL11.GL_BLEND); + GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); + float alpha = ((float) Math.sin((ClientTickHandler.ticksInGame + partialTicks) * 0.2F) * 0.5F + 0.5F) * 0.4F + 0.3F; + + double posX = player.prevPosX + (player.posX - player.prevPosX) * partialTicks; + double posY = player.prevPosY + (player.posY - player.prevPosY) * partialTicks; + double posZ = player.prevPosZ + (player.posZ - player.prevPosZ) * partialTicks; + + GL11.glTranslated(posX - RenderManager.renderPosX, posY - RenderManager.renderPosY, posZ - RenderManager.renderPosZ); + + float base = getRotationBase(stack); + int angles = 360; + int segAngles = angles / SEGMENTS; + float shift = base - segAngles / 2; + + float u = 1F; + float v = 0.25F; + + float s = 3F; + float m = 0.8F; + float y = v * s * 2; + float y0 = 0; + + int segmentLookedAt = getSegmentLookedAt(stack, player); + + for(int seg = 0; seg < SEGMENTS; seg++) { + boolean inside = false; + float rotationAngle = (seg + 0.5F) * segAngles + shift; + if(segmentLookedAt == seg) + inside = true; + + GL11.glPushMatrix(); + GL11.glRotatef(rotationAngle, 0F, 1F, 0F); + GL11.glTranslatef(s * m, -0.75F, 0F); + + mc.renderEngine.bindTexture(TextureMap.locationItemsTexture); + GL11.glScalef(0.75F, 0.75F, 0.75F); + GL11.glTranslatef(0F, 0F, 0.5F); + IIcon icon = signs[seg]; + GL11.glRotatef(90F, 0F, 1F, 0F); + GL11.glColor4f(1F, 1F, 1F, getWarpPoint(stack, seg).isValid() ? 1F : 0.2F); + float f = icon.getMinU(); + float f1 = icon.getMaxU(); + float f2 = icon.getMinV(); + float f3 = icon.getMaxV(); + ItemRenderer.renderItemIn2D(Tessellator.instance, f1, f2, f, f3, icon.getIconWidth(), icon.getIconHeight(), 1F / 16F); + + GL11.glColor3f(1F, 1F, 1F); + GL11.glPopMatrix(); + + GL11.glPushMatrix(); + GL11.glRotatef(180F, 1F, 0F, 0F); + float a = alpha; + if(inside) { + a += 0.3F; + y0 = -y; + } + + if(seg % 2 == 0) + GL11.glColor4f(0.6F, 0.6F, 0.6F, a); + else GL11.glColor4f(1F, 1F, 1F, a); + + mc.renderEngine.bindTexture(glowTexture); + tess.startDrawingQuads(); + for(int i = 0; i < segAngles; i++) { + float ang = i + seg * segAngles + shift; + double xp = Math.cos(ang * Math.PI / 180F) * s; + double zp = Math.sin(ang * Math.PI / 180F) * s; + + tess.addVertexWithUV(xp * m, y, zp * m, u, v); + tess.addVertexWithUV(xp, y0, zp, u, 0); + + xp = Math.cos((ang + 1) * Math.PI / 180F) * s; + zp = Math.sin((ang + 1) * Math.PI / 180F) * s; + + tess.addVertexWithUV(xp, y0, zp, 0, 0); + tess.addVertexWithUV(xp * m, y, zp * m, 0, v); + } + y0 = 0; + tess.draw(); + + GL11.glPopMatrix(); + } + GL11.glPopMatrix(); + } + + @SideOnly(Side.CLIENT) + public static void renderHUD(ScaledResolution resolution, EntityPlayer player, ItemStack stack) { + Minecraft.getMinecraft(); + int slot = getSegmentLookedAt(stack, player); + MultiversePosition pos = getWarpPoint(stack, slot); + + FontRenderer font = Minecraft.getMinecraft().fontRenderer; + String s = StatCollector.translateToLocal("botania.sign" + slot); + font.drawStringWithShadow(s, resolution.getScaledWidth() / 2 - font.getStringWidth(s) / 2, resolution.getScaledHeight() / 2 - 55, 0xFFD409); + + if(pos.isValid()) { + int dist = (int) vazkii.botania.common.core.helper.MathHelper.pointDistanceSpace(pos.x, pos.y, pos.z, player.posX, player.posY - 1.6, player.posZ); + + s = dist == 1 ? StatCollector.translateToLocal("botaniamisc.blockAway") : String.format(StatCollector.translateToLocal("botaniamisc.blocksAway"), dist); + font.drawStringWithShadow(s, resolution.getScaledWidth() / 2 - font.getStringWidth(s) / 2, resolution.getScaledHeight() / 2 - 40, 0x9999FF); + s = StatCollector.translateToLocal("botaniamisc.clickToTeleport"); + font.drawStringWithShadow(s, resolution.getScaledWidth() / 2 - font.getStringWidth(s) / 2, resolution.getScaledHeight() / 2 - 30, 0xFFFFFF); + s = StatCollector.translateToLocal("botaniamisc.clickToRemoveWarp"); + font.drawStringWithShadow(s, resolution.getScaledWidth() / 2 - font.getStringWidth(s) / 2, resolution.getScaledHeight() / 2 - 20, 0xFFFFFF); + } else { + s = StatCollector.translateToLocal("botaniamisc.unboundWarp"); + font.drawStringWithShadow(s, resolution.getScaledWidth() / 2 - font.getStringWidth(s) / 2, resolution.getScaledHeight() / 2 - 40, 0xFFFFFF); + s = StatCollector.translateToLocal("botaniamisc.clickToAddWarp"); + font.drawStringWithShadow(s, resolution.getScaledWidth() / 2 - font.getStringWidth(s) / 2, resolution.getScaledHeight() / 2 - 30, 0xFFFFFF); + } + } + + private static class MultiversePosition { + + public final double x, y, z; + public final int dim; + + public MultiversePosition(double x, double y, double z, int dim) { + this.x = x; + this.y = y; + this.z = z; + this.dim = dim; + } + + boolean isValid() { + return y > 0; + } + + } + */ } diff --git a/src/main/java/vazkii/botania/common/item/relic/ItemInfiniteFruit.java b/src/main/java/vazkii/botania/common/item/relic/ItemInfiniteFruit.java index efb3991b5f..1e24a9fc5c 100644 --- a/src/main/java/vazkii/botania/common/item/relic/ItemInfiniteFruit.java +++ b/src/main/java/vazkii/botania/common/item/relic/ItemInfiniteFruit.java @@ -2,17 +2,14 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Mar 29, 2015, 10:12:55 PM (GMT)] */ package vazkii.botania.common.item.relic; -import cpw.mods.fml.relauncher.ReflectionHelper; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.EnumAction; @@ -24,64 +21,70 @@ import vazkii.botania.client.core.helper.IconHelper; import vazkii.botania.common.lib.LibItemNames; import vazkii.botania.common.lib.LibObfuscation; +import cpw.mods.fml.relauncher.ReflectionHelper; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; public class ItemInfiniteFruit extends ItemRelic implements IManaUsingItem { - public static IIcon dasBootIcon; - - public ItemInfiniteFruit() { - super(LibItemNames.INFINITE_FRUIT); - } - - @Override - public int getMaxItemUseDuration(ItemStack p_77626_1_) { - return 32; - } - - @Override - public EnumAction getItemUseAction(ItemStack p_77661_1_) { - return isBoot(p_77661_1_) ? EnumAction.drink : EnumAction.eat; - } - - @Override - public ItemStack onItemRightClick(ItemStack p_77659_1_, World p_77659_2_, EntityPlayer p_77659_3_) { - if (p_77659_3_.canEat(false) && isRightPlayer(p_77659_3_, p_77659_1_)) - p_77659_3_.setItemInUse(p_77659_1_, getMaxItemUseDuration(p_77659_1_)); - return p_77659_1_; - } - - @Override - public void onUsingTick(ItemStack stack, EntityPlayer player, int count) { - super.onUsingTick(stack, player, count); - - if (ManaItemHandler.requestManaExact(stack, player, 500, true)) { - if (count % 5 == 0) player.getFoodStats().addStats(1, 1F); - - if (count == 5) - if (player.canEat(false)) - ReflectionHelper.setPrivateValue(EntityPlayer.class, player, 20, LibObfuscation.ITEM_IN_USE_COUNT); - } - } - - @Override - @SideOnly(Side.CLIENT) - public void registerIcons(IIconRegister par1IconRegister) { - itemIcon = IconHelper.forItem(par1IconRegister, this); - dasBootIcon = IconHelper.forName(par1IconRegister, "dasBoot"); - } - - @Override - public IIcon getIconIndex(ItemStack par1ItemStack) { - return isBoot(par1ItemStack) ? dasBootIcon : super.getIconIndex(par1ItemStack); - } - - private boolean isBoot(ItemStack par1ItemStack) { - String name = par1ItemStack.getDisplayName().toLowerCase().trim(); - return name.equals("das boot"); - } - - @Override - public boolean usesMana(ItemStack stack) { - return true; - } + public static IIcon dasBootIcon; + + public ItemInfiniteFruit() { + super(LibItemNames.INFINITE_FRUIT); + } + + @Override + public int getMaxItemUseDuration(ItemStack p_77626_1_) { + return 32; + } + + @Override + public EnumAction getItemUseAction(ItemStack p_77661_1_) { + return isBoot(p_77661_1_) ? EnumAction.drink : EnumAction.eat; + } + + @Override + public ItemStack onItemRightClick(ItemStack p_77659_1_, World p_77659_2_, EntityPlayer p_77659_3_) { + if(p_77659_3_.canEat(false) && isRightPlayer(p_77659_3_, p_77659_1_)) + p_77659_3_.setItemInUse(p_77659_1_, getMaxItemUseDuration(p_77659_1_)); + return p_77659_1_; + } + + @Override + public void onUsingTick(ItemStack stack, EntityPlayer player, int count) { + super.onUsingTick(stack, player, count); + + if(ManaItemHandler.requestManaExact(stack, player, 500, true)) { + if(count % 5 == 0) + player.getFoodStats().addStats(1, 1F); + + if(count == 5) + if(player.canEat(false)) + ReflectionHelper.setPrivateValue(EntityPlayer.class, player, 20, LibObfuscation.ITEM_IN_USE_COUNT); + } + } + + + @Override + @SideOnly(Side.CLIENT) + public void registerIcons(IIconRegister par1IconRegister) { + itemIcon = IconHelper.forItem(par1IconRegister, this); + dasBootIcon = IconHelper.forName(par1IconRegister, "dasBoot"); + } + + @Override + public IIcon getIconIndex(ItemStack par1ItemStack) { + return isBoot(par1ItemStack) ? dasBootIcon : super.getIconIndex(par1ItemStack); + } + + private boolean isBoot(ItemStack par1ItemStack) { + String name = par1ItemStack.getDisplayName().toLowerCase().trim(); + return name.equals("das boot"); + } + + @Override + public boolean usesMana(ItemStack stack) { + return true; + } + } diff --git a/src/main/java/vazkii/botania/common/item/relic/ItemKingKey.java b/src/main/java/vazkii/botania/common/item/relic/ItemKingKey.java index af89187021..2dc32c505f 100644 --- a/src/main/java/vazkii/botania/common/item/relic/ItemKingKey.java +++ b/src/main/java/vazkii/botania/common/item/relic/ItemKingKey.java @@ -2,15 +2,16 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Aug 16, 2015, 2:54:35 PM (GMT)] */ package vazkii.botania.common.item.relic; import java.util.Random; + import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.EnumAction; @@ -28,117 +29,116 @@ public class ItemKingKey extends ItemRelic implements IManaUsingItem { - private static final String TAG_WEAPONS_SPAWNED = "weaponsSpawned"; - private static final String TAG_CHARGING = "charging"; - - private static final int WEAPON_TYPES = 12; - public static IIcon[] weaponIcons; - - public ItemKingKey() { - super(LibItemNames.KING_KEY); - } - - @Override - public void registerIcons(IIconRegister par1IconRegister) { - super.registerIcons(par1IconRegister); - - weaponIcons = new IIcon[WEAPON_TYPES]; - for (int i = 0; i < WEAPON_TYPES; i++) weaponIcons[i] = IconHelper.forName(par1IconRegister, "gateWeapon" + i); - } - - @Override - public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer) { - par3EntityPlayer.setItemInUse(par1ItemStack, getMaxItemUseDuration(par1ItemStack)); - setCharging(par1ItemStack, true); - return par1ItemStack; - } - - @Override - public void onPlayerStoppedUsing(ItemStack stack, World world, EntityPlayer player, int time) { - int spawned = getWeaponsSpawned(stack); - if (spawned == 20) { - setCharging(stack, false); - setWeaponsSpawned(stack, 0); - } - } - - @Override - public void onUsingTick(ItemStack stack, EntityPlayer player, int count) { - int spawned = getWeaponsSpawned(stack); - - if (count != getMaxItemUseDuration(stack) - && spawned < 20 - && !player.worldObj.isRemote - && ManaItemHandler.requestManaExact(stack, player, 150, true)) { - Vector3 look = new Vector3(player.getLookVec()); - look.y = 0; - look.normalize().negate().multiply(2); - int div = spawned / 5; - int mod = spawned % 5; - - Vector3 pl = look.copy().add(Vector3.fromEntityCenter(player)).add(0, 1.6, div * 0.1); - - Random rand = player.worldObj.rand; - Vector3 axis = - look.copy().normalize().crossProduct(new Vector3(-1, 0, -1)).normalize(); - Vector3 axis1 = axis.copy(); - - double rot = mod * Math.PI / 4 - Math.PI / 2; - - axis1.multiply(div * 3.5 + 5).rotate(rot, look); - if (axis1.y < 0) axis1.y = -axis1.y; - - Vector3 end = pl.copy().add(axis1); - - EntityBabylonWeapon weapon = new EntityBabylonWeapon(player.worldObj, player); - weapon.posX = end.x; - weapon.posY = end.y; - weapon.posZ = end.z; - weapon.rotationYaw = player.rotationYaw; - weapon.setVariety(rand.nextInt(WEAPON_TYPES)); - weapon.setDelay(spawned); - weapon.setRotation(MathHelper.wrapAngleTo180_float(-player.rotationYaw + 180)); - - player.worldObj.spawnEntityInWorld(weapon); - player.worldObj.playSoundAtEntity( - weapon, "botania:babylonSpawn", 1F, 1F + player.worldObj.rand.nextFloat() * 3F); - setWeaponsSpawned(stack, spawned + 1); - } - } - - @Override - public EnumAction getItemUseAction(ItemStack par1ItemStack) { - return EnumAction.bow; - } - - @Override - public int getMaxItemUseDuration(ItemStack par1ItemStack) { - return 72000; - } - - public static boolean isCharging(ItemStack stack) { - return ItemNBTHelper.getBoolean(stack, TAG_CHARGING, false); - } - - public static int getWeaponsSpawned(ItemStack stack) { - return ItemNBTHelper.getInt(stack, TAG_WEAPONS_SPAWNED, 0); - } - - public static void setCharging(ItemStack stack, boolean charging) { - ItemNBTHelper.setBoolean(stack, TAG_CHARGING, charging); - } - - public static void setWeaponsSpawned(ItemStack stack, int count) { - ItemNBTHelper.setInt(stack, TAG_WEAPONS_SPAWNED, count); - } - - @Override - public boolean isFull3D() { - return true; - } - - @Override - public boolean usesMana(ItemStack stack) { - return true; - } + private static final String TAG_WEAPONS_SPAWNED = "weaponsSpawned"; + private static final String TAG_CHARGING = "charging"; + + private static final int WEAPON_TYPES = 12; + public static IIcon[] weaponIcons; + + public ItemKingKey() { + super(LibItemNames.KING_KEY); + } + + @Override + public void registerIcons(IIconRegister par1IconRegister) { + super.registerIcons(par1IconRegister); + + weaponIcons = new IIcon[WEAPON_TYPES]; + for(int i = 0; i < WEAPON_TYPES; i++) + weaponIcons[i] = IconHelper.forName(par1IconRegister, "gateWeapon" + i); + } + + @Override + public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer) { + par3EntityPlayer.setItemInUse(par1ItemStack, getMaxItemUseDuration(par1ItemStack)); + setCharging(par1ItemStack, true); + return par1ItemStack; + } + + @Override + public void onPlayerStoppedUsing(ItemStack stack, World world, EntityPlayer player, int time) { + int spawned = getWeaponsSpawned(stack); + if(spawned == 20) { + setCharging(stack, false); + setWeaponsSpawned(stack, 0); + } + } + + @Override + public void onUsingTick(ItemStack stack, EntityPlayer player, int count) { + int spawned = getWeaponsSpawned(stack); + + if(count != getMaxItemUseDuration(stack) && spawned < 20 && !player.worldObj.isRemote && ManaItemHandler.requestManaExact(stack, player, 150, true)) { + Vector3 look = new Vector3(player.getLookVec()); + look.y = 0; + look.normalize().negate().multiply(2); + int div = spawned / 5; + int mod = spawned % 5; + + Vector3 pl = look.copy().add(Vector3.fromEntityCenter(player)).add(0, 1.6, div * 0.1); + + Random rand = player.worldObj.rand; + Vector3 axis = look.copy().normalize().crossProduct(new Vector3(-1, 0, -1)).normalize(); + Vector3 axis1 = axis.copy(); + + double rot = mod * Math.PI / 4 - Math.PI / 2; + + axis1.multiply(div * 3.5 + 5).rotate(rot, look); + if(axis1.y < 0) + axis1.y = -axis1.y; + + Vector3 end = pl.copy().add(axis1); + + EntityBabylonWeapon weapon = new EntityBabylonWeapon(player.worldObj, player); + weapon.posX = end.x; + weapon.posY = end.y; + weapon.posZ = end.z; + weapon.rotationYaw = player.rotationYaw; + weapon.setVariety(rand.nextInt(WEAPON_TYPES)); + weapon.setDelay(spawned); + weapon.setRotation(MathHelper.wrapAngleTo180_float(-player.rotationYaw + 180)); + + player.worldObj.spawnEntityInWorld(weapon); + player.worldObj.playSoundAtEntity(weapon, "botania:babylonSpawn", 1F, 1F + player.worldObj.rand.nextFloat() * 3F); + setWeaponsSpawned(stack, spawned + 1); + } + } + + @Override + public EnumAction getItemUseAction(ItemStack par1ItemStack) { + return EnumAction.bow; + } + + @Override + public int getMaxItemUseDuration(ItemStack par1ItemStack) { + return 72000; + } + + + public static boolean isCharging(ItemStack stack) { + return ItemNBTHelper.getBoolean(stack, TAG_CHARGING, false); + } + + public static int getWeaponsSpawned(ItemStack stack) { + return ItemNBTHelper.getInt(stack, TAG_WEAPONS_SPAWNED, 0); + } + + public static void setCharging(ItemStack stack, boolean charging) { + ItemNBTHelper.setBoolean(stack, TAG_CHARGING, charging); + } + + public static void setWeaponsSpawned(ItemStack stack, int count) { + ItemNBTHelper.setInt(stack, TAG_WEAPONS_SPAWNED, count); + } + + @Override + public boolean isFull3D() { + return true; + } + + @Override + public boolean usesMana(ItemStack stack) { + return true; + } + } diff --git a/src/main/java/vazkii/botania/common/item/relic/ItemLokiRing.java b/src/main/java/vazkii/botania/common/item/relic/ItemLokiRing.java index 0084bef3ba..5f77e56350 100644 --- a/src/main/java/vazkii/botania/common/item/relic/ItemLokiRing.java +++ b/src/main/java/vazkii/botania/common/item/relic/ItemLokiRing.java @@ -2,24 +2,17 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Mar 29, 2015, 10:13:32 PM (GMT)] */ package vazkii.botania.common.item.relic; -import baubles.api.BaubleType; -import baubles.common.container.InventoryBaubles; -import baubles.common.lib.PlayerHandler; -import baubles.common.network.PacketHandler; -import baubles.common.network.PacketSyncBauble; -import cpw.mods.fml.common.eventhandler.SubscribeEvent; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; import java.util.ArrayList; import java.util.List; + import net.minecraft.block.Block; import net.minecraft.block.material.Material; import net.minecraft.client.Minecraft; @@ -45,273 +38,249 @@ import vazkii.botania.common.item.ModItems; import vazkii.botania.common.item.equipment.tool.ToolCommons; import vazkii.botania.common.lib.LibItemNames; +import baubles.api.BaubleType; +import baubles.common.container.InventoryBaubles; +import baubles.common.lib.PlayerHandler; +import baubles.common.network.PacketHandler; +import baubles.common.network.PacketSyncBauble; +import cpw.mods.fml.common.eventhandler.SubscribeEvent; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; public class ItemLokiRing extends ItemRelicBauble implements IExtendedWireframeCoordinateListProvider, IManaUsingItem { - private static final String TAG_CURSOR_LIST = "cursorList"; - private static final String TAG_CURSOR_PREFIX = "cursor"; - private static final String TAG_CURSOR_COUNT = "cursorCount"; - private static final String TAG_X_OFFSET = "xOffset"; - private static final String TAG_Y_OFFSET = "yOffset"; - private static final String TAG_Z_OFFSET = "zOffset"; - private static final String TAG_X_ORIGIN = "xOrigin"; - private static final String TAG_Y_ORIGIN = "yOrigin"; - private static final String TAG_Z_ORIGIN = "zOrigin"; - - public ItemLokiRing() { - super(LibItemNames.LOKI_RING); - MinecraftForge.EVENT_BUS.register(this); - } - - @SubscribeEvent - public void onPlayerInteract(PlayerInteractEvent event) { - EntityPlayer player = event.entityPlayer; - ItemStack lokiRing = getLokiRing(player); - if (lokiRing == null || player.worldObj.isRemote) return; - - int slot = -1; - InventoryBaubles inv = PlayerHandler.getPlayerBaubles(player); - for (int i = 0; i < inv.getSizeInventory(); i++) { - ItemStack stack = inv.getStackInSlot(i); - if (stack == lokiRing) { - slot = i; - break; - } - } - - ItemStack heldItemStack = player.getCurrentEquippedItem(); - ChunkCoordinates originCoords = getOriginPos(lokiRing); - MovingObjectPosition lookPos = ToolCommons.raytraceFromEntity(player.worldObj, player, true, 10F); - List cursors = getCursorList(lokiRing); - int cursorCount = cursors.size(); - - int cost = Math.min(cursorCount, (int) Math.pow(Math.E, cursorCount * 0.25)); - - if (heldItemStack == null && event.action == Action.RIGHT_CLICK_BLOCK && player.isSneaking()) { - if (originCoords.posY == -1 && lookPos != null) { - setOriginPos(lokiRing, lookPos.blockX, lookPos.blockY, lookPos.blockZ); - setCursorList(lokiRing, null); - if (player instanceof EntityPlayerMP) - PacketHandler.INSTANCE.sendTo(new PacketSyncBauble(player, slot), (EntityPlayerMP) player); - } else if (lookPos != null) { - if (originCoords.posX == lookPos.blockX - && originCoords.posY == lookPos.blockY - && originCoords.posZ == lookPos.blockZ) { - setOriginPos(lokiRing, 0, -1, 0); - if (player instanceof EntityPlayerMP) - PacketHandler.INSTANCE.sendTo(new PacketSyncBauble(player, slot), (EntityPlayerMP) player); - } else { - addCursor: - { - int relX = lookPos.blockX - originCoords.posX; - int relY = lookPos.blockY - originCoords.posY; - int relZ = lookPos.blockZ - originCoords.posZ; - - for (ChunkCoordinates cursor : cursors) - if (cursor.posX == relX && cursor.posY == relY && cursor.posZ == relZ) { - cursors.remove(cursor); - setCursorList(lokiRing, cursors); - if (player instanceof EntityPlayerMP) - PacketHandler.INSTANCE.sendTo( - new PacketSyncBauble(player, slot), (EntityPlayerMP) player); - break addCursor; - } - - addCursor(lokiRing, relX, relY, relZ); - if (player instanceof EntityPlayerMP) - PacketHandler.INSTANCE.sendTo(new PacketSyncBauble(player, slot), (EntityPlayerMP) player); - } - } - } - } else if (heldItemStack != null - && event.action == Action.RIGHT_CLICK_BLOCK - && lookPos != null - && player.isSneaking()) { - for (ChunkCoordinates cursor : cursors) { - int x = lookPos.blockX + cursor.posX; - int y = lookPos.blockY + cursor.posY; - int z = lookPos.blockZ + cursor.posZ; - Item item = heldItemStack.getItem(); - if (!player.worldObj.isAirBlock(x, y, z) - && ManaItemHandler.requestManaExact(lokiRing, player, cost, true)) { - item.onItemUse( - player.capabilities.isCreativeMode ? heldItemStack.copy() : heldItemStack, - player, - player.worldObj, - x, - y, - z, - lookPos.sideHit, - (float) lookPos.hitVec.xCoord - x, - (float) lookPos.hitVec.yCoord - y, - (float) lookPos.hitVec.zCoord - z); - if (heldItemStack.stackSize == 0) { - event.setCanceled(true); - return; - } - } - } - } - } - - public static void breakOnAllCursors( - EntityPlayer player, Item item, ItemStack stack, int x, int y, int z, int side) { - ItemStack lokiRing = getLokiRing(player); - if (lokiRing == null || player.worldObj.isRemote || !(item instanceof ISequentialBreaker)) return; - - List cursors = getCursorList(lokiRing); - ISequentialBreaker breaker = (ISequentialBreaker) item; - World world = player.worldObj; - boolean silk = EnchantmentHelper.getEnchantmentLevel(Enchantment.silkTouch.effectId, stack) > 0; - int fortune = EnchantmentHelper.getEnchantmentLevel(Enchantment.fortune.effectId, stack); - boolean dispose = breaker.disposeOfTrashBlocks(stack); - - for (int i = 0; i < cursors.size(); i++) { - ChunkCoordinates coords = cursors.get(i); - int xp = x + coords.posX; - int yp = y + coords.posY; - int zp = z + coords.posZ; - Block block = world.getBlock(xp, yp, zp); - breaker.breakOtherBlock(player, stack, xp, yp, zp, x, y, z, side); - ToolCommons.removeBlockWithDrops( - player, - stack, - player.worldObj, - xp, - yp, - zp, - x, - y, - z, - block, - new Material[] {block.getMaterial()}, - silk, - fortune, - block.getBlockHardness(world, xp, yp, zp), - dispose); - } - } - - @Override - public BaubleType getBaubleType(ItemStack arg0) { - return BaubleType.RING; - } - - @Override - public void onUnequipped(ItemStack stack, EntityLivingBase player) { - setCursorList(stack, null); - } - - @Override - @SideOnly(Side.CLIENT) - public List getWireframesToDraw(EntityPlayer player, ItemStack stack) { - if (getLokiRing(player) != stack) return null; - - MovingObjectPosition lookPos = Minecraft.getMinecraft().objectMouseOver; - - if (lookPos != null - && !player.worldObj.isAirBlock(lookPos.blockX, lookPos.blockY, lookPos.blockZ) - && lookPos.entityHit == null) { - List list = getCursorList(stack); - ChunkCoordinates origin = getOriginPos(stack); - - if (origin.posY != -1) { - for (ChunkCoordinates coords : list) { - coords.posX += origin.posX; - coords.posY += origin.posY; - coords.posZ += origin.posZ; - } - } else - for (ChunkCoordinates coords : list) { - coords.posX += lookPos.blockX; - coords.posY += lookPos.blockY; - coords.posZ += lookPos.blockZ; - } - - return list; - } - - return null; - } - - @Override - public ChunkCoordinates getSourceWireframe(EntityPlayer player, ItemStack stack) { - return getLokiRing(player) == stack ? getOriginPos(stack) : null; - } - - private static ItemStack getLokiRing(EntityPlayer player) { - InventoryBaubles baubles = PlayerHandler.getPlayerBaubles(player); - ItemStack stack1 = baubles.getStackInSlot(1); - ItemStack stack2 = baubles.getStackInSlot(2); - return isLokiRing(stack1) ? stack1 : isLokiRing(stack2) ? stack2 : null; - } - - private static boolean isLokiRing(ItemStack stack) { - return stack != null && (stack.getItem() == ModItems.lokiRing || stack.getItem() == ModItems.aesirRing); - } - - private static ChunkCoordinates getOriginPos(ItemStack stack) { - int x = ItemNBTHelper.getInt(stack, TAG_X_ORIGIN, 0); - int y = ItemNBTHelper.getInt(stack, TAG_Y_ORIGIN, -1); - int z = ItemNBTHelper.getInt(stack, TAG_Z_ORIGIN, 0); - return new ChunkCoordinates(x, y, z); - } - - private static void setOriginPos(ItemStack stack, int x, int y, int z) { - ItemNBTHelper.setInt(stack, TAG_X_ORIGIN, x); - ItemNBTHelper.setInt(stack, TAG_Y_ORIGIN, y); - ItemNBTHelper.setInt(stack, TAG_Z_ORIGIN, z); - } - - private static List getCursorList(ItemStack stack) { - NBTTagCompound cmp = ItemNBTHelper.getCompound(stack, TAG_CURSOR_LIST, false); - List cursors = new ArrayList(); - - int count = cmp.getInteger(TAG_CURSOR_COUNT); - for (int i = 0; i < count; i++) { - NBTTagCompound cursorCmp = cmp.getCompoundTag(TAG_CURSOR_PREFIX + i); - int x = cursorCmp.getInteger(TAG_X_OFFSET); - int y = cursorCmp.getInteger(TAG_Y_OFFSET); - int z = cursorCmp.getInteger(TAG_Z_OFFSET); - cursors.add(new ChunkCoordinates(x, y, z)); - } - - return cursors; - } - - private static void setCursorList(ItemStack stack, List cursors) { - NBTTagCompound cmp = new NBTTagCompound(); - if (cursors != null) { - int i = 0; - for (ChunkCoordinates cursor : cursors) { - NBTTagCompound cursorCmp = cursorToCmp(cursor.posX, cursor.posY, cursor.posZ); - cmp.setTag(TAG_CURSOR_PREFIX + i, cursorCmp); - i++; - } - cmp.setInteger(TAG_CURSOR_COUNT, i); - } - - ItemNBTHelper.setCompound(stack, TAG_CURSOR_LIST, cmp); - } - - private static NBTTagCompound cursorToCmp(int x, int y, int z) { - NBTTagCompound cmp = new NBTTagCompound(); - cmp.setInteger(TAG_X_OFFSET, x); - cmp.setInteger(TAG_Y_OFFSET, y); - cmp.setInteger(TAG_Z_OFFSET, z); - return cmp; - } - - private static void addCursor(ItemStack stack, int x, int y, int z) { - NBTTagCompound cmp = ItemNBTHelper.getCompound(stack, TAG_CURSOR_LIST, false); - int count = cmp.getInteger(TAG_CURSOR_COUNT); - cmp.setTag(TAG_CURSOR_PREFIX + count, cursorToCmp(x, y, z)); - cmp.setInteger(TAG_CURSOR_COUNT, count + 1); - ItemNBTHelper.setCompound(stack, TAG_CURSOR_LIST, cmp); - } - - @Override - public boolean usesMana(ItemStack stack) { - return true; - } + private static final String TAG_CURSOR_LIST = "cursorList"; + private static final String TAG_CURSOR_PREFIX = "cursor"; + private static final String TAG_CURSOR_COUNT = "cursorCount"; + private static final String TAG_X_OFFSET = "xOffset"; + private static final String TAG_Y_OFFSET = "yOffset"; + private static final String TAG_Z_OFFSET = "zOffset"; + private static final String TAG_X_ORIGIN = "xOrigin"; + private static final String TAG_Y_ORIGIN = "yOrigin"; + private static final String TAG_Z_ORIGIN = "zOrigin"; + + public ItemLokiRing() { + super(LibItemNames.LOKI_RING); + MinecraftForge.EVENT_BUS.register(this); + } + + @SubscribeEvent + public void onPlayerInteract(PlayerInteractEvent event) { + EntityPlayer player = event.entityPlayer; + ItemStack lokiRing = getLokiRing(player); + if(lokiRing == null || player.worldObj.isRemote) + return; + + int slot = -1; + InventoryBaubles inv = PlayerHandler.getPlayerBaubles(player); + for(int i = 0; i < inv.getSizeInventory(); i++) { + ItemStack stack = inv.getStackInSlot(i); + if(stack == lokiRing) { + slot = i; + break; + } + } + + ItemStack heldItemStack = player.getCurrentEquippedItem(); + ChunkCoordinates originCoords = getOriginPos(lokiRing); + MovingObjectPosition lookPos = ToolCommons.raytraceFromEntity(player.worldObj, player, true, 10F); + List cursors = getCursorList(lokiRing); + int cursorCount = cursors.size(); + + int cost = Math.min(cursorCount, (int) Math.pow(Math.E, cursorCount * 0.25)); + + if(heldItemStack == null && event.action == Action.RIGHT_CLICK_BLOCK && player.isSneaking()) { + if(originCoords.posY == -1 && lookPos != null) { + setOriginPos(lokiRing, lookPos.blockX, lookPos.blockY, lookPos.blockZ); + setCursorList(lokiRing, null); + if(player instanceof EntityPlayerMP) + PacketHandler.INSTANCE.sendTo(new PacketSyncBauble(player, slot), (EntityPlayerMP) player); + } else if(lookPos != null) { + if(originCoords.posX == lookPos.blockX && originCoords.posY == lookPos.blockY && originCoords.posZ == lookPos.blockZ) { + setOriginPos(lokiRing, 0, -1, 0); + if(player instanceof EntityPlayerMP) + PacketHandler.INSTANCE.sendTo(new PacketSyncBauble(player, slot), (EntityPlayerMP) player); + } else { + addCursor : { + int relX = lookPos.blockX - originCoords.posX; + int relY = lookPos.blockY - originCoords.posY; + int relZ = lookPos.blockZ - originCoords.posZ; + + for(ChunkCoordinates cursor : cursors) + if(cursor.posX == relX && cursor.posY == relY && cursor.posZ == relZ) { + cursors.remove(cursor); + setCursorList(lokiRing, cursors); + if(player instanceof EntityPlayerMP) + PacketHandler.INSTANCE.sendTo(new PacketSyncBauble(player, slot), (EntityPlayerMP) player); + break addCursor; + } + + addCursor(lokiRing, relX, relY, relZ); + if(player instanceof EntityPlayerMP) + PacketHandler.INSTANCE.sendTo(new PacketSyncBauble(player, slot), (EntityPlayerMP) player); + } + } + } + } else if(heldItemStack != null && event.action == Action.RIGHT_CLICK_BLOCK && lookPos != null && player.isSneaking()) { + for(ChunkCoordinates cursor : cursors) { + int x = lookPos.blockX + cursor.posX; + int y = lookPos.blockY + cursor.posY; + int z = lookPos.blockZ + cursor.posZ; + Item item = heldItemStack.getItem(); + if(!player.worldObj.isAirBlock(x, y, z) && ManaItemHandler.requestManaExact(lokiRing, player, cost, true)) { + item.onItemUse(player.capabilities.isCreativeMode ? heldItemStack.copy() : heldItemStack, player, player.worldObj, x, y, z, lookPos.sideHit, (float) lookPos.hitVec.xCoord - x, (float) lookPos.hitVec.yCoord - y, (float) lookPos.hitVec.zCoord - z); + if(heldItemStack.stackSize == 0) { + event.setCanceled(true); + return; + } + } + } + } + } + + public static void breakOnAllCursors(EntityPlayer player, Item item, ItemStack stack, int x, int y, int z, int side) { + ItemStack lokiRing = getLokiRing(player); + if(lokiRing == null || player.worldObj.isRemote || !(item instanceof ISequentialBreaker)) + return; + + List cursors = getCursorList(lokiRing); + ISequentialBreaker breaker = (ISequentialBreaker) item; + World world = player.worldObj; + boolean silk = EnchantmentHelper.getEnchantmentLevel(Enchantment.silkTouch.effectId, stack) > 0; + int fortune = EnchantmentHelper.getEnchantmentLevel(Enchantment.fortune.effectId, stack); + boolean dispose = breaker.disposeOfTrashBlocks(stack); + + for(int i = 0; i < cursors.size(); i++) { + ChunkCoordinates coords = cursors.get(i); + int xp = x + coords.posX; + int yp = y + coords.posY; + int zp = z + coords.posZ; + Block block = world.getBlock(xp, yp, zp); + breaker.breakOtherBlock(player, stack, xp, yp, zp, x, y, z, side); + ToolCommons.removeBlockWithDrops(player, stack, player.worldObj, xp, yp, zp, x, y, z, block, new Material[] { block.getMaterial() }, silk, fortune, block.getBlockHardness(world, xp, yp, zp), dispose); + } + } + + @Override + public BaubleType getBaubleType(ItemStack arg0) { + return BaubleType.RING; + } + + @Override + public void onUnequipped(ItemStack stack, EntityLivingBase player) { + setCursorList(stack, null); + } + + @Override + @SideOnly(Side.CLIENT) + public List getWireframesToDraw(EntityPlayer player, ItemStack stack) { + if(getLokiRing(player) != stack) + return null; + + MovingObjectPosition lookPos = Minecraft.getMinecraft().objectMouseOver; + + if(lookPos != null && !player.worldObj.isAirBlock(lookPos.blockX, lookPos.blockY, lookPos.blockZ) && lookPos.entityHit == null) { + List list = getCursorList(stack); + ChunkCoordinates origin = getOriginPos(stack); + + if(origin.posY != -1) { + for(ChunkCoordinates coords : list) { + coords.posX += origin.posX; + coords.posY += origin.posY; + coords.posZ += origin.posZ; + } + } else for(ChunkCoordinates coords : list) { + coords.posX += lookPos.blockX; + coords.posY += lookPos.blockY; + coords.posZ += lookPos.blockZ; + } + + return list; + } + + return null; + } + + @Override + public ChunkCoordinates getSourceWireframe(EntityPlayer player, ItemStack stack) { + return getLokiRing(player) == stack ? getOriginPos(stack) : null; + } + + private static ItemStack getLokiRing(EntityPlayer player) { + InventoryBaubles baubles = PlayerHandler.getPlayerBaubles(player); + ItemStack stack1 = baubles.getStackInSlot(1); + ItemStack stack2 = baubles.getStackInSlot(2); + return isLokiRing(stack1) ? stack1 : isLokiRing(stack2) ? stack2 : null; + } + + private static boolean isLokiRing(ItemStack stack) { + return stack != null && (stack.getItem() == ModItems.lokiRing || stack.getItem() == ModItems.aesirRing); + } + + private static ChunkCoordinates getOriginPos(ItemStack stack) { + int x = ItemNBTHelper.getInt(stack, TAG_X_ORIGIN, 0); + int y = ItemNBTHelper.getInt(stack, TAG_Y_ORIGIN, -1); + int z = ItemNBTHelper.getInt(stack, TAG_Z_ORIGIN, 0); + return new ChunkCoordinates(x, y, z); + } + + private static void setOriginPos(ItemStack stack, int x, int y, int z) { + ItemNBTHelper.setInt(stack, TAG_X_ORIGIN, x); + ItemNBTHelper.setInt(stack, TAG_Y_ORIGIN, y); + ItemNBTHelper.setInt(stack, TAG_Z_ORIGIN, z); + } + + private static List getCursorList(ItemStack stack) { + NBTTagCompound cmp = ItemNBTHelper.getCompound(stack, TAG_CURSOR_LIST, false); + List cursors = new ArrayList(); + + int count = cmp.getInteger(TAG_CURSOR_COUNT); + for(int i = 0; i < count; i++) { + NBTTagCompound cursorCmp = cmp.getCompoundTag(TAG_CURSOR_PREFIX + i); + int x = cursorCmp.getInteger(TAG_X_OFFSET); + int y = cursorCmp.getInteger(TAG_Y_OFFSET); + int z = cursorCmp.getInteger(TAG_Z_OFFSET); + cursors.add(new ChunkCoordinates(x, y, z)); + } + + return cursors; + } + + private static void setCursorList(ItemStack stack, List cursors) { + NBTTagCompound cmp = new NBTTagCompound(); + if(cursors != null) { + int i = 0; + for(ChunkCoordinates cursor : cursors) { + NBTTagCompound cursorCmp = cursorToCmp(cursor.posX, cursor.posY, cursor.posZ); + cmp.setTag(TAG_CURSOR_PREFIX + i, cursorCmp); + i++; + } + cmp.setInteger(TAG_CURSOR_COUNT, i); + } + + ItemNBTHelper.setCompound(stack, TAG_CURSOR_LIST, cmp); + } + + private static NBTTagCompound cursorToCmp(int x, int y, int z) { + NBTTagCompound cmp = new NBTTagCompound(); + cmp.setInteger(TAG_X_OFFSET, x); + cmp.setInteger(TAG_Y_OFFSET, y); + cmp.setInteger(TAG_Z_OFFSET, z); + return cmp; + } + + private static void addCursor(ItemStack stack, int x, int y, int z) { + NBTTagCompound cmp = ItemNBTHelper.getCompound(stack, TAG_CURSOR_LIST, false); + int count = cmp.getInteger(TAG_CURSOR_COUNT); + cmp.setTag(TAG_CURSOR_PREFIX + count, cursorToCmp(x, y, z)); + cmp.setInteger(TAG_CURSOR_COUNT, count + 1); + ItemNBTHelper.setCompound(stack, TAG_CURSOR_LIST, cmp); + } + + @Override + public boolean usesMana(ItemStack stack) { + return true; + } + } + diff --git a/src/main/java/vazkii/botania/common/item/relic/ItemOdinRing.java b/src/main/java/vazkii/botania/common/item/relic/ItemOdinRing.java index 63f7db71f9..3eaa7da187 100644 --- a/src/main/java/vazkii/botania/common/item/relic/ItemOdinRing.java +++ b/src/main/java/vazkii/botania/common/item/relic/ItemOdinRing.java @@ -2,22 +2,17 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Mar 29, 2015, 10:13:41 PM (GMT)] */ package vazkii.botania.common.item.relic; -import baubles.api.BaubleType; -import baubles.common.container.InventoryBaubles; -import baubles.common.lib.PlayerHandler; -import com.google.common.collect.HashMultimap; -import com.google.common.collect.Multimap; -import cpw.mods.fml.common.eventhandler.SubscribeEvent; import java.util.ArrayList; import java.util.List; + import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.SharedMonsterAttributes; import net.minecraft.entity.ai.attributes.AttributeModifier; @@ -29,76 +24,86 @@ import vazkii.botania.common.core.handler.ConfigHandler; import vazkii.botania.common.item.ModItems; import vazkii.botania.common.lib.LibItemNames; +import baubles.api.BaubleType; +import baubles.common.container.InventoryBaubles; +import baubles.common.lib.PlayerHandler; + +import com.google.common.collect.HashMultimap; +import com.google.common.collect.Multimap; + +import cpw.mods.fml.common.eventhandler.SubscribeEvent; public class ItemOdinRing extends ItemRelicBauble { - public static List damageNegations = new ArrayList(); - - Multimap attributes = HashMultimap.create(); - - public ItemOdinRing() { - super(LibItemNames.ODIN_RING); - MinecraftForge.EVENT_BUS.register(this); - - damageNegations.add(DamageSource.drown.damageType); - damageNegations.add(DamageSource.fall.damageType); - damageNegations.add(DamageSource.lava.damageType); - if (ConfigHandler.ringOfOdinFireResist) { - damageNegations.add(DamageSource.inFire.damageType); - damageNegations.add(DamageSource.onFire.damageType); - } - - damageNegations.add(DamageSource.inWall.damageType); - damageNegations.add(DamageSource.starve.damageType); - } - - @Override - public void onValidPlayerWornTick(ItemStack stack, EntityPlayer player) { - if (player.isBurning() && ConfigHandler.ringOfOdinFireResist) player.extinguish(); - } - - @SubscribeEvent - public void onPlayerAttacked(LivingAttackEvent event) { - if (event.entityLiving instanceof EntityPlayer) { - EntityPlayer player = (EntityPlayer) event.entityLiving; - if (getOdinRing(player) != null && damageNegations.contains(event.source.damageType)) - event.setCanceled(true); - } - } - - @Override - public BaubleType getBaubleType(ItemStack arg0) { - return BaubleType.RING; - } - - public static ItemStack getOdinRing(EntityPlayer player) { - InventoryBaubles baubles = PlayerHandler.getPlayerBaubles(player); - ItemStack stack1 = baubles.getStackInSlot(1); - ItemStack stack2 = baubles.getStackInSlot(2); - return isOdinRing(stack1) ? stack1 : isOdinRing(stack2) ? stack2 : null; - } - - private static boolean isOdinRing(ItemStack stack) { - return stack != null && (stack.getItem() == ModItems.odinRing || stack.getItem() == ModItems.aesirRing); - } - - @Override - public void onEquippedOrLoadedIntoWorld(ItemStack stack, EntityLivingBase player) { - attributes.clear(); - fillModifiers(attributes, stack); - player.getAttributeMap().applyAttributeModifiers(attributes); - } - - @Override - public void onUnequipped(ItemStack stack, EntityLivingBase player) { - attributes.clear(); - fillModifiers(attributes, stack); - player.getAttributeMap().removeAttributeModifiers(attributes); - } - - void fillModifiers(Multimap attributes, ItemStack stack) { - attributes.put( - SharedMonsterAttributes.maxHealth.getAttributeUnlocalizedName(), - new AttributeModifier(getBaubleUUID(stack), "Bauble modifier", 20, 0)); - } + public static List damageNegations = new ArrayList(); + + Multimap attributes = HashMultimap.create(); + + public ItemOdinRing() { + super(LibItemNames.ODIN_RING); + MinecraftForge.EVENT_BUS.register(this); + + damageNegations.add(DamageSource.drown.damageType); + damageNegations.add(DamageSource.fall.damageType); + damageNegations.add(DamageSource.lava.damageType); + if(ConfigHandler.ringOfOdinFireResist) { + damageNegations.add(DamageSource.inFire.damageType); + damageNegations.add(DamageSource.onFire.damageType); + } + + damageNegations.add(DamageSource.inWall.damageType); + damageNegations.add(DamageSource.starve.damageType); + } + + @Override + public void onValidPlayerWornTick(ItemStack stack, EntityPlayer player) { + if(player.isBurning() && ConfigHandler.ringOfOdinFireResist) + player.extinguish(); + } + + @SubscribeEvent + public void onPlayerAttacked(LivingAttackEvent event) { + if(event.entityLiving instanceof EntityPlayer) { + EntityPlayer player = (EntityPlayer) event.entityLiving; + if(getOdinRing(player) != null && damageNegations.contains(event.source.damageType)) + event.setCanceled(true); + } + } + + @Override + public BaubleType getBaubleType(ItemStack arg0) { + return BaubleType.RING; + } + + public static ItemStack getOdinRing(EntityPlayer player) { + InventoryBaubles baubles = PlayerHandler.getPlayerBaubles(player); + ItemStack stack1 = baubles.getStackInSlot(1); + ItemStack stack2 = baubles.getStackInSlot(2); + return isOdinRing(stack1) ? stack1 : isOdinRing(stack2) ? stack2 : null; + } + + private static boolean isOdinRing(ItemStack stack) { + return stack != null && (stack.getItem() == ModItems.odinRing || stack.getItem() == ModItems.aesirRing); + } + + @Override + public void onEquippedOrLoadedIntoWorld(ItemStack stack, EntityLivingBase player) { + attributes.clear(); + fillModifiers(attributes, stack); + player.getAttributeMap().applyAttributeModifiers(attributes); + } + + @Override + public void onUnequipped(ItemStack stack, EntityLivingBase player) { + attributes.clear(); + fillModifiers(attributes, stack); + player.getAttributeMap().removeAttributeModifiers(attributes); + } + + + void fillModifiers(Multimap attributes, ItemStack stack) { + attributes.put(SharedMonsterAttributes.maxHealth.getAttributeUnlocalizedName(), new AttributeModifier(getBaubleUUID(stack), "Bauble modifier", 20, 0)); + } + } + diff --git a/src/main/java/vazkii/botania/common/item/relic/ItemRelic.java b/src/main/java/vazkii/botania/common/item/relic/ItemRelic.java index e3e8e9330e..0285c8f7a5 100644 --- a/src/main/java/vazkii/botania/common/item/relic/ItemRelic.java +++ b/src/main/java/vazkii/botania/common/item/relic/ItemRelic.java @@ -2,15 +2,16 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Mar 29, 2015, 7:54:40 PM (GMT)] */ package vazkii.botania.common.item.relic; import java.util.List; + import net.minecraft.client.gui.GuiScreen; import net.minecraft.entity.Entity; import net.minecraft.entity.player.EntityPlayer; @@ -29,126 +30,124 @@ public class ItemRelic extends ItemMod implements IRelic { - private static final String TAG_SOULBIND = "soulbind"; - - Achievement achievement; - - public ItemRelic(String name) { - setUnlocalizedName(name); - setMaxStackSize(1); - } - - @Override - public void onUpdate( - ItemStack p_77663_1_, World p_77663_2_, Entity p_77663_3_, int p_77663_4_, boolean p_77663_5_) { - if (p_77663_3_ instanceof EntityPlayer) updateRelic(p_77663_1_, (EntityPlayer) p_77663_3_); - } - - @Override - public void addInformation(ItemStack p_77624_1_, EntityPlayer p_77624_2_, List p_77624_3_, boolean p_77624_4_) { - addBindInfo(p_77624_3_, p_77624_1_, p_77624_2_); - } - - public static void addBindInfo(List list, ItemStack stack, EntityPlayer player) { - if (GuiScreen.isShiftKeyDown()) { - String bind = getSoulbindUsernameS(stack); - if (bind.isEmpty()) addStringToTooltip(StatCollector.translateToLocal("botaniamisc.relicUnbound"), list); - else { - addStringToTooltip( - String.format(StatCollector.translateToLocal("botaniamisc.relicSoulbound"), bind), list); - if (!isRightPlayer(player, stack)) - addStringToTooltip( - String.format(StatCollector.translateToLocal("botaniamisc.notYourSagittarius"), bind), - list); - } - - if (stack.getItem() == ModItems.aesirRing) - addStringToTooltip(StatCollector.translateToLocal("botaniamisc.dropIkea"), list); - - if (stack.getItem() == ModItems.dice) { - addStringToTooltip("", list); - String name = stack.getUnlocalizedName() + ".poem"; - for (int i = 0; i < 4; i++) - addStringToTooltip(EnumChatFormatting.ITALIC + StatCollector.translateToLocal(name + i), list); - } - } else addStringToTooltip(StatCollector.translateToLocal("botaniamisc.shiftinfo"), list); - } - - public boolean shouldDamageWrongPlayer() { - return true; - } - - @Override - public int getEntityLifespan(ItemStack itemStack, World world) { - return Integer.MAX_VALUE; - } - - static void addStringToTooltip(String s, List tooltip) { - tooltip.add(s.replaceAll("&", "\u00a7")); - } - - public static String getSoulbindUsernameS(ItemStack stack) { - return ItemNBTHelper.getString(stack, TAG_SOULBIND, ""); - } - - public static void updateRelic(ItemStack stack, EntityPlayer player) { - if (stack == null || !(stack.getItem() instanceof IRelic)) return; - - String soulbind = getSoulbindUsernameS(stack); - if (soulbind.isEmpty()) { - player.addStat(((IRelic) stack.getItem()).getBindAchievement(), 1); - bindToPlayer(player, stack); - soulbind = getSoulbindUsernameS(stack); - } - - if (!isRightPlayer(player, stack) - && player.ticksExisted % 10 == 0 - && (!(stack.getItem() instanceof ItemRelic) || ((ItemRelic) stack.getItem()).shouldDamageWrongPlayer())) - player.attackEntityFrom(damageSource(), 2); - } - - public static void bindToPlayer(EntityPlayer player, ItemStack stack) { - bindToUsernameS(player.getCommandSenderName(), stack); - } - - public static void bindToUsernameS(String username, ItemStack stack) { - ItemNBTHelper.setString(stack, TAG_SOULBIND, username); - } - - public static boolean isRightPlayer(EntityPlayer player, ItemStack stack) { - return isRightPlayer(player.getCommandSenderName(), stack); - } - - public static boolean isRightPlayer(String player, ItemStack stack) { - return getSoulbindUsernameS(stack).equals(player); - } - - public static DamageSource damageSource() { - return new DamageSource("botania-relic"); - } - - @Override - public void bindToUsername(String playerName, ItemStack stack) { - bindToUsernameS(playerName, stack); - } - - @Override - public String getSoulbindUsername(ItemStack stack) { - return getSoulbindUsernameS(stack); - } - - @Override - public Achievement getBindAchievement() { - return achievement; - } - - @Override - public void setBindAchievement(Achievement achievement) { - this.achievement = achievement; - } - - @Override - public EnumRarity getRarity(ItemStack p_77613_1_) { - return BotaniaAPI.rarityRelic; - } + private static final String TAG_SOULBIND = "soulbind"; + + Achievement achievement; + + public ItemRelic(String name) { + setUnlocalizedName(name); + setMaxStackSize(1); + } + + @Override + public void onUpdate(ItemStack p_77663_1_, World p_77663_2_, Entity p_77663_3_, int p_77663_4_, boolean p_77663_5_) { + if(p_77663_3_ instanceof EntityPlayer) + updateRelic(p_77663_1_, (EntityPlayer) p_77663_3_); + } + + @Override + public void addInformation(ItemStack p_77624_1_, EntityPlayer p_77624_2_, List p_77624_3_, boolean p_77624_4_) { + addBindInfo(p_77624_3_, p_77624_1_, p_77624_2_); + } + + public static void addBindInfo(List list, ItemStack stack, EntityPlayer player) { + if(GuiScreen.isShiftKeyDown()) { + String bind = getSoulbindUsernameS(stack); + if(bind.isEmpty()) + addStringToTooltip(StatCollector.translateToLocal("botaniamisc.relicUnbound"), list); + else { + addStringToTooltip(String.format(StatCollector.translateToLocal("botaniamisc.relicSoulbound"), bind), list); + if(!isRightPlayer(player, stack)) + addStringToTooltip(String.format(StatCollector.translateToLocal("botaniamisc.notYourSagittarius"), bind), list); + } + + if(stack.getItem() == ModItems.aesirRing) + addStringToTooltip(StatCollector.translateToLocal("botaniamisc.dropIkea"), list); + + if(stack.getItem() == ModItems.dice) { + addStringToTooltip("", list); + String name = stack.getUnlocalizedName() + ".poem"; + for(int i = 0; i < 4; i++) + addStringToTooltip(EnumChatFormatting.ITALIC + StatCollector.translateToLocal(name + i), list); + } + } else addStringToTooltip(StatCollector.translateToLocal("botaniamisc.shiftinfo"), list); + } + + public boolean shouldDamageWrongPlayer() { + return true; + } + + @Override + public int getEntityLifespan(ItemStack itemStack, World world) { + return Integer.MAX_VALUE; + } + + static void addStringToTooltip(String s, List tooltip) { + tooltip.add(s.replaceAll("&", "\u00a7")); + } + + public static String getSoulbindUsernameS(ItemStack stack) { + return ItemNBTHelper.getString(stack, TAG_SOULBIND, ""); + } + + public static void updateRelic(ItemStack stack, EntityPlayer player) { + if(stack == null || !(stack.getItem() instanceof IRelic)) + return; + + String soulbind = getSoulbindUsernameS(stack); + if(soulbind.isEmpty()) { + player.addStat(((IRelic) stack.getItem()).getBindAchievement(), 1); + bindToPlayer(player, stack); + soulbind = getSoulbindUsernameS(stack); + } + + if(!isRightPlayer(player, stack) && player.ticksExisted % 10 == 0 && (!(stack.getItem() instanceof ItemRelic) || ((ItemRelic) stack.getItem()).shouldDamageWrongPlayer())) + player.attackEntityFrom(damageSource(), 2); + } + + public static void bindToPlayer(EntityPlayer player, ItemStack stack) { + bindToUsernameS(player.getCommandSenderName(), stack); + } + + public static void bindToUsernameS(String username, ItemStack stack) { + ItemNBTHelper.setString(stack, TAG_SOULBIND, username); + } + + public static boolean isRightPlayer(EntityPlayer player, ItemStack stack) { + return isRightPlayer(player.getCommandSenderName(), stack); + } + + public static boolean isRightPlayer(String player, ItemStack stack) { + return getSoulbindUsernameS(stack).equals(player); + } + + public static DamageSource damageSource() { + return new DamageSource("botania-relic"); + } + + @Override + public void bindToUsername(String playerName, ItemStack stack) { + bindToUsernameS(playerName, stack); + } + + @Override + public String getSoulbindUsername(ItemStack stack) { + return getSoulbindUsernameS(stack); + } + + @Override + public Achievement getBindAchievement() { + return achievement; + } + + @Override + public void setBindAchievement(Achievement achievement) { + this.achievement = achievement; + } + + @Override + public EnumRarity getRarity(ItemStack p_77613_1_) { + return BotaniaAPI.rarityRelic; + } + } diff --git a/src/main/java/vazkii/botania/common/item/relic/ItemRelicBauble.java b/src/main/java/vazkii/botania/common/item/relic/ItemRelicBauble.java index 7a90ce34c4..6d735743b6 100644 --- a/src/main/java/vazkii/botania/common/item/relic/ItemRelicBauble.java +++ b/src/main/java/vazkii/botania/common/item/relic/ItemRelicBauble.java @@ -2,15 +2,16 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Mar 29, 2015, 7:56:27 PM (GMT)] */ package vazkii.botania.common.item.relic; import java.util.List; + import net.minecraft.entity.Entity; import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.player.EntityPlayer; @@ -24,70 +25,72 @@ public abstract class ItemRelicBauble extends ItemBauble implements IRelic { - Achievement achievement; - - public ItemRelicBauble(String name) { - super(name); - } - - @Override - public void onUpdate( - ItemStack p_77663_1_, World p_77663_2_, Entity p_77663_3_, int p_77663_4_, boolean p_77663_5_) { - if (p_77663_3_ instanceof EntityPlayer) ItemRelic.updateRelic(p_77663_1_, (EntityPlayer) p_77663_3_); - } - - @Override - public void onWornTick(ItemStack stack, EntityLivingBase player) { - super.onWornTick(stack, player); - if (player instanceof EntityPlayer) { - EntityPlayer ePlayer = (EntityPlayer) player; - ItemRelic.updateRelic(stack, ePlayer); - if (ItemRelic.isRightPlayer(ePlayer, stack)) onValidPlayerWornTick(stack, ePlayer); - } - } - - @Override - public void addHiddenTooltip(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, List par3List, boolean par4) { - super.addHiddenTooltip(par1ItemStack, par2EntityPlayer, par3List, par4); - ItemRelic.addBindInfo(par3List, par1ItemStack, par2EntityPlayer); - } - - public void onValidPlayerWornTick(ItemStack stack, EntityPlayer player) { - // NO-OP - } - - @Override - public boolean canEquip(ItemStack stack, EntityLivingBase player) { - return player instanceof EntityPlayer && ItemRelic.isRightPlayer((EntityPlayer) player, stack); - } - - @Override - public void bindToUsername(String playerName, ItemStack stack) { - ItemRelic.bindToUsernameS(playerName, stack); - } - - @Override - public String getSoulbindUsername(ItemStack stack) { - return ItemRelic.getSoulbindUsernameS(stack); - } - - @Override - public Achievement getBindAchievement() { - return achievement; - } - - @Override - public void setBindAchievement(Achievement achievement) { - this.achievement = achievement; - } - - @Override - public EnumRarity getRarity(ItemStack p_77613_1_) { - return BotaniaAPI.rarityRelic; - } - - @Override - public int getEntityLifespan(ItemStack itemStack, World world) { - return Integer.MAX_VALUE; - } + Achievement achievement; + + public ItemRelicBauble(String name) { + super(name); + } + + @Override + public void onUpdate(ItemStack p_77663_1_, World p_77663_2_, Entity p_77663_3_, int p_77663_4_, boolean p_77663_5_) { + if(p_77663_3_ instanceof EntityPlayer) + ItemRelic.updateRelic(p_77663_1_, (EntityPlayer) p_77663_3_); + } + + @Override + public void onWornTick(ItemStack stack, EntityLivingBase player) { + super.onWornTick(stack, player); + if(player instanceof EntityPlayer) { + EntityPlayer ePlayer = (EntityPlayer) player; + ItemRelic.updateRelic(stack, ePlayer); + if(ItemRelic.isRightPlayer(ePlayer, stack)) + onValidPlayerWornTick(stack, ePlayer); + } + } + + @Override + public void addHiddenTooltip(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, List par3List, boolean par4) { + super.addHiddenTooltip(par1ItemStack, par2EntityPlayer, par3List, par4); + ItemRelic.addBindInfo(par3List, par1ItemStack, par2EntityPlayer); + } + + public void onValidPlayerWornTick(ItemStack stack, EntityPlayer player) { + // NO-OP + } + + @Override + public boolean canEquip(ItemStack stack, EntityLivingBase player) { + return player instanceof EntityPlayer && ItemRelic.isRightPlayer((EntityPlayer) player, stack); + } + + @Override + public void bindToUsername(String playerName, ItemStack stack) { + ItemRelic.bindToUsernameS(playerName, stack); + } + + @Override + public String getSoulbindUsername(ItemStack stack) { + return ItemRelic.getSoulbindUsernameS(stack); + } + + @Override + public Achievement getBindAchievement() { + return achievement; + } + + @Override + public void setBindAchievement(Achievement achievement) { + this.achievement = achievement; + } + + @Override + public EnumRarity getRarity(ItemStack p_77613_1_) { + return BotaniaAPI.rarityRelic; + } + + @Override + public int getEntityLifespan(ItemStack itemStack, World world) { + return Integer.MAX_VALUE; + } + } diff --git a/src/main/java/vazkii/botania/common/item/relic/ItemThorRing.java b/src/main/java/vazkii/botania/common/item/relic/ItemThorRing.java index 689801f441..78dd94da2a 100644 --- a/src/main/java/vazkii/botania/common/item/relic/ItemThorRing.java +++ b/src/main/java/vazkii/botania/common/item/relic/ItemThorRing.java @@ -2,41 +2,42 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Mar 29, 2015, 10:13:37 PM (GMT)] */ package vazkii.botania.common.item.relic; -import baubles.api.BaubleType; -import baubles.common.container.InventoryBaubles; -import baubles.common.lib.PlayerHandler; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; import vazkii.botania.common.item.ModItems; import vazkii.botania.common.lib.LibItemNames; +import baubles.api.BaubleType; +import baubles.common.container.InventoryBaubles; +import baubles.common.lib.PlayerHandler; public class ItemThorRing extends ItemRelicBauble { - public ItemThorRing() { - super(LibItemNames.THOR_RING); - } + public ItemThorRing() { + super(LibItemNames.THOR_RING); + } + + @Override + public BaubleType getBaubleType(ItemStack arg0) { + return BaubleType.RING; + } - @Override - public BaubleType getBaubleType(ItemStack arg0) { - return BaubleType.RING; - } + public static ItemStack getThorRing(EntityPlayer player) { + InventoryBaubles baubles = PlayerHandler.getPlayerBaubles(player); + ItemStack stack1 = baubles.getStackInSlot(1); + ItemStack stack2 = baubles.getStackInSlot(2); + return isThorRing(stack1) ? stack1 : isThorRing(stack2) ? stack2 : null; + } - public static ItemStack getThorRing(EntityPlayer player) { - InventoryBaubles baubles = PlayerHandler.getPlayerBaubles(player); - ItemStack stack1 = baubles.getStackInSlot(1); - ItemStack stack2 = baubles.getStackInSlot(2); - return isThorRing(stack1) ? stack1 : isThorRing(stack2) ? stack2 : null; - } + private static boolean isThorRing(ItemStack stack) { + return stack != null && (stack.getItem() == ModItems.thorRing || stack.getItem() == ModItems.aesirRing); + } - private static boolean isThorRing(ItemStack stack) { - return stack != null && (stack.getItem() == ModItems.thorRing || stack.getItem() == ModItems.aesirRing); - } } diff --git a/src/main/java/vazkii/botania/common/item/rod/ItemCobbleRod.java b/src/main/java/vazkii/botania/common/item/rod/ItemCobbleRod.java index bbbc48adcc..0a5df3c44f 100644 --- a/src/main/java/vazkii/botania/common/item/rod/ItemCobbleRod.java +++ b/src/main/java/vazkii/botania/common/item/rod/ItemCobbleRod.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jan 24, 2015, 10:28:03 PM (GMT)] */ package vazkii.botania.common.item.rod; @@ -23,64 +23,40 @@ public class ItemCobbleRod extends ItemMod implements IManaUsingItem, IBlockProvider { - static final int COST = 150; + static final int COST = 150; + + public ItemCobbleRod() { + setMaxStackSize(1); + setUnlocalizedName(LibItemNames.COBBLE_ROD); + } + + @Override + public boolean onItemUse(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, World par3World, int par4, int par5, int par6, int par7, float par8, float par9, float par10) { + return ItemDirtRod.place(par1ItemStack, par2EntityPlayer, par3World, par4, par5, par6, par7, par8, par9, par10, Blocks.cobblestone, COST, 0.3F, 0.3F, 0.3F); + } + + @Override + public boolean isFull3D() { + return true; + } + + @Override + public boolean usesMana(ItemStack stack) { + return true; + } + + @Override + public boolean provideBlock(EntityPlayer player, ItemStack requestor, ItemStack stack, Block block, int meta, boolean doit) { + if(block == Blocks.cobblestone && meta == 0) + return !doit || ManaItemHandler.requestManaExactForTool(requestor, player, COST, true); + return false; + } + + @Override + public int getBlockCount(EntityPlayer player, ItemStack requestor, ItemStack stack, Block block, int meta) { + if(block == Blocks.cobblestone && meta == 0) + return -1; + return 0; + } - public ItemCobbleRod() { - setMaxStackSize(1); - setUnlocalizedName(LibItemNames.COBBLE_ROD); - } - - @Override - public boolean onItemUse( - ItemStack par1ItemStack, - EntityPlayer par2EntityPlayer, - World par3World, - int par4, - int par5, - int par6, - int par7, - float par8, - float par9, - float par10) { - return ItemDirtRod.place( - par1ItemStack, - par2EntityPlayer, - par3World, - par4, - par5, - par6, - par7, - par8, - par9, - par10, - Blocks.cobblestone, - COST, - 0.3F, - 0.3F, - 0.3F); - } - - @Override - public boolean isFull3D() { - return true; - } - - @Override - public boolean usesMana(ItemStack stack) { - return true; - } - - @Override - public boolean provideBlock( - EntityPlayer player, ItemStack requestor, ItemStack stack, Block block, int meta, boolean doit) { - if (block == Blocks.cobblestone && meta == 0) - return !doit || ManaItemHandler.requestManaExactForTool(requestor, player, COST, true); - return false; - } - - @Override - public int getBlockCount(EntityPlayer player, ItemStack requestor, ItemStack stack, Block block, int meta) { - if (block == Blocks.cobblestone && meta == 0) return -1; - return 0; - } } diff --git a/src/main/java/vazkii/botania/common/item/rod/ItemDirtRod.java b/src/main/java/vazkii/botania/common/item/rod/ItemDirtRod.java index 5c5f9ee2c1..d09ca7b671 100644 --- a/src/main/java/vazkii/botania/common/item/rod/ItemDirtRod.java +++ b/src/main/java/vazkii/botania/common/item/rod/ItemDirtRod.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Apr 11, 2014, 2:53:41 PM (GMT)] */ package vazkii.botania.common.item.rod; @@ -31,129 +31,71 @@ public class ItemDirtRod extends ItemMod implements IManaUsingItem, ICraftAchievement, IBlockProvider { - static final int COST = 75; - - public ItemDirtRod() { - this(LibItemNames.DIRT_ROD); - } - - public ItemDirtRod(String name) { - super(); - setMaxStackSize(1); - setUnlocalizedName(name); - } - - @Override - public boolean onItemUse( - ItemStack par1ItemStack, - EntityPlayer par2EntityPlayer, - World par3World, - int par4, - int par5, - int par6, - int par7, - float par8, - float par9, - float par10) { - return place( - par1ItemStack, - par2EntityPlayer, - par3World, - par4, - par5, - par6, - par7, - par8, - par9, - par10, - Blocks.dirt, - COST, - 0.35F, - 0.2F, - 0.05F); - } - - public static boolean place( - ItemStack par1ItemStack, - EntityPlayer par2EntityPlayer, - World par3World, - int par4, - int par5, - int par6, - int par7, - float par8, - float par9, - float par10, - Block block, - int cost, - float r, - float g, - float b) { - if (ManaItemHandler.requestManaExactForTool(par1ItemStack, par2EntityPlayer, cost, false)) { - ForgeDirection dir = ForgeDirection.getOrientation(par7); - int entities = par3World - .getEntitiesWithinAABB( - EntityLivingBase.class, - AxisAlignedBB.getBoundingBox( - par4 + dir.offsetX, - par5 + dir.offsetY, - par6 + dir.offsetZ, - par4 + dir.offsetX + 1, - par5 + dir.offsetY + 1, - par6 + dir.offsetZ + 1)) - .size(); - - if (entities == 0) { - ItemStack stackToPlace = new ItemStack(block); - stackToPlace.tryPlaceItemIntoWorld( - par2EntityPlayer, par3World, par4, par5, par6, par7, par8, par9, par10); - - if (stackToPlace.stackSize == 0) { - ManaItemHandler.requestManaExactForTool(par1ItemStack, par2EntityPlayer, cost, true); - for (int i = 0; i < 6; i++) - Botania.proxy.sparkleFX( - par3World, - par4 + dir.offsetX + Math.random(), - par5 + dir.offsetY + Math.random(), - par6 + dir.offsetZ + Math.random(), - r, - g, - b, - 1F, - 5); - } - } - } - - return true; - } - - @Override - public boolean isFull3D() { - return true; - } - - @Override - public boolean usesMana(ItemStack stack) { - return true; - } - - @Override - public Achievement getAchievementOnCraft(ItemStack stack, EntityPlayer player, IInventory matrix) { - return ModAchievements.dirtRodCraft; - } - - @Override - public boolean provideBlock( - EntityPlayer player, ItemStack requestor, ItemStack stack, Block block, int meta, boolean doit) { - if (block == Blocks.dirt && meta == 0) - return !doit || ManaItemHandler.requestManaExactForTool(requestor, player, COST, true); - return false; - } - - @Override - public int getBlockCount(EntityPlayer player, ItemStack requestor, ItemStack stack, Block block, int meta) { - if (block == Blocks.dirt && meta == 0) return -1; - return 0; - } -} + static final int COST = 75; + + public ItemDirtRod() { + this(LibItemNames.DIRT_ROD); + } + + public ItemDirtRod(String name) { + super(); + setMaxStackSize(1); + setUnlocalizedName(name); + } + + @Override + public boolean onItemUse(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, World par3World, int par4, int par5, int par6, int par7, float par8, float par9, float par10) { + return place(par1ItemStack, par2EntityPlayer, par3World, par4, par5, par6, par7, par8, par9, par10, Blocks.dirt, COST, 0.35F, 0.2F, 0.05F); + } + + public static boolean place(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, World par3World, int par4, int par5, int par6, int par7, float par8, float par9, float par10, Block block, int cost, float r, float g, float b) { + if(ManaItemHandler.requestManaExactForTool(par1ItemStack, par2EntityPlayer, cost, false)) { + ForgeDirection dir = ForgeDirection.getOrientation(par7); + int entities = par3World.getEntitiesWithinAABB(EntityLivingBase.class, AxisAlignedBB.getBoundingBox(par4 + dir.offsetX, par5 + dir.offsetY, par6 + dir.offsetZ, par4 + dir.offsetX + 1, par5 + dir.offsetY + 1, par6 + dir.offsetZ + 1)).size(); + + if(entities == 0) { + ItemStack stackToPlace = new ItemStack(block); + stackToPlace.tryPlaceItemIntoWorld(par2EntityPlayer, par3World, par4, par5, par6, par7, par8, par9, par10); + + if(stackToPlace.stackSize == 0) { + ManaItemHandler.requestManaExactForTool(par1ItemStack, par2EntityPlayer, cost, true); + for(int i = 0; i < 6; i++) + Botania.proxy.sparkleFX(par3World, par4 + dir.offsetX + Math.random(), par5 + dir.offsetY + Math.random(), par6 + dir.offsetZ + Math.random(), r, g, b, 1F, 5); + } + } + } + + return true; + } + + @Override + public boolean isFull3D() { + return true; + } + + @Override + public boolean usesMana(ItemStack stack) { + return true; + } + + @Override + public Achievement getAchievementOnCraft(ItemStack stack, EntityPlayer player, IInventory matrix) { + return ModAchievements.dirtRodCraft; + } + + @Override + public boolean provideBlock(EntityPlayer player, ItemStack requestor, ItemStack stack, Block block, int meta, boolean doit) { + if(block == Blocks.dirt && meta == 0) + return !doit || ManaItemHandler.requestManaExactForTool(requestor, player, COST, true); + return false; + } + + @Override + public int getBlockCount(EntityPlayer player, ItemStack requestor, ItemStack stack, Block block, int meta) { + if(block == Blocks.dirt && meta == 0) + return -1; + return 0; + } + + +} \ No newline at end of file diff --git a/src/main/java/vazkii/botania/common/item/rod/ItemDiviningRod.java b/src/main/java/vazkii/botania/common/item/rod/ItemDiviningRod.java index 1e2158cf0a..c8bfde267b 100644 --- a/src/main/java/vazkii/botania/common/item/rod/ItemDiviningRod.java +++ b/src/main/java/vazkii/botania/common/item/rod/ItemDiviningRod.java @@ -2,15 +2,16 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Aug 25, 2014, 2:57:16 PM (GMT)] */ package vazkii.botania.common.item.rod; import java.util.Random; + import net.minecraft.block.Block; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; @@ -31,82 +32,72 @@ public class ItemDiviningRod extends ItemMod implements IManaUsingItem, IAvatarWieldable { - private static final ResourceLocation avatarOverlay = new ResourceLocation(LibResources.MODEL_AVATAR_DIVINING); + private static final ResourceLocation avatarOverlay = new ResourceLocation(LibResources.MODEL_AVATAR_DIVINING); - static final int COST = 3000; + static final int COST = 3000; - public ItemDiviningRod() { - setMaxStackSize(1); - setUnlocalizedName(LibItemNames.DIVINING_ROD); - } + public ItemDiviningRod() { + setMaxStackSize(1); + setUnlocalizedName(LibItemNames.DIVINING_ROD); + } - @Override - public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer p) { - if (ManaItemHandler.requestManaExactForTool(stack, p, COST, true)) { - if (world.isRemote) { - int x = MathHelper.floor_double(p.posX); - int y = MathHelper.floor_double(p.posY); - int z = MathHelper.floor_double(p.posZ); - int range = IManaProficiencyArmor.Helper.hasProficiency(p) ? 20 : 15; - long seedxor = world.rand.nextLong(); - doHighlight(world, x, y, z, range, seedxor); - p.swingItem(); - } else world.playSoundAtEntity(p, "botania:divinationRod", 1F, 1F); - } + @Override + public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer p) { + if(ManaItemHandler.requestManaExactForTool(stack, p, COST, true)) { + if(world.isRemote) { + int x = MathHelper.floor_double(p.posX); + int y = MathHelper.floor_double(p.posY); + int z = MathHelper.floor_double(p.posZ); + int range = IManaProficiencyArmor.Helper.hasProficiency(p) ? 20 : 15; + long seedxor = world.rand.nextLong(); + doHighlight(world, x, y, z, range, seedxor); + p.swingItem(); + } else world.playSoundAtEntity(p, "botania:divinationRod", 1F, 1F); + } - return stack; - } + return stack; + } - public void doHighlight(World world, int x, int y, int z, int range, long seedxor) { - Botania.proxy.setWispFXDepthTest(false); - for (int i = -range; i < range + 1; i++) - for (int j = -range; j < range + 1; j++) - for (int k = -range; k < range + 1; k++) { - int xp = x + i; - int yp = y + j; - int zp = z + k; - Block block = world.getBlock(xp, yp, zp); - int meta = world.getBlockMetadata(xp, yp, zp); - ItemStack orestack = new ItemStack(block, 1, meta); - for (int id : OreDictionary.getOreIDs(orestack)) { - String s = OreDictionary.getOreName(id); - if (s.matches("^ore[A-Z].+")) { - Random rand = new Random(s.hashCode() ^ seedxor); - Botania.proxy.wispFX( - world, - xp + world.rand.nextFloat(), - yp + world.rand.nextFloat(), - zp + world.rand.nextFloat(), - rand.nextFloat(), - rand.nextFloat(), - rand.nextFloat(), - 0.25F, - 0F, - 8); - break; - } - } - } - Botania.proxy.setWispFXDepthTest(true); - } + public void doHighlight(World world, int x, int y, int z, int range, long seedxor) { + Botania.proxy.setWispFXDepthTest(false); + for(int i = -range; i < range + 1; i++) + for(int j = -range; j < range + 1; j++) + for(int k = -range; k < range + 1; k++) { + int xp = x + i; + int yp = y + j; + int zp = z + k; + Block block = world.getBlock(xp, yp, zp); + int meta = world.getBlockMetadata(xp, yp, zp); + ItemStack orestack = new ItemStack(block, 1, meta); + for(int id : OreDictionary.getOreIDs(orestack)) { + String s = OreDictionary.getOreName(id); + if(s.matches("^ore[A-Z].+")) { + Random rand = new Random(s.hashCode() ^ seedxor); + Botania.proxy.wispFX(world, xp + world.rand.nextFloat(), yp + world.rand.nextFloat(), zp + world.rand.nextFloat(), rand.nextFloat(), rand.nextFloat(), rand.nextFloat(), 0.25F, 0F, 8); + break; + } + } + } + Botania.proxy.setWispFXDepthTest(true); + } - @Override - public boolean usesMana(ItemStack stack) { - return true; - } + @Override + public boolean usesMana(ItemStack stack) { + return true; + } - @Override - public void onAvatarUpdate(IAvatarTile tile, ItemStack stack) { - TileEntity te = (TileEntity) tile; - World world = te.getWorldObj(); - if (tile.getCurrentMana() >= COST && tile.getElapsedFunctionalTicks() % 200 == 0 && tile.isEnabled()) { - doHighlight(world, te.xCoord, te.yCoord, te.zCoord, 18, te.xCoord ^ te.yCoord ^ te.zCoord); - tile.recieveMana(-COST); - } - } + @Override + public void onAvatarUpdate(IAvatarTile tile, ItemStack stack) { + TileEntity te = (TileEntity) tile; + World world = te.getWorldObj(); + if(tile.getCurrentMana() >= COST && tile.getElapsedFunctionalTicks() % 200 == 0 && tile.isEnabled()) { + doHighlight(world, te.xCoord, te.yCoord, te.zCoord, 18, te.xCoord ^ te.yCoord ^ te.zCoord); + tile.recieveMana(-COST); + } + } - @Override - public ResourceLocation getOverlayResource(IAvatarTile tile, ItemStack stack) { - return avatarOverlay; - } -} + @Override + public ResourceLocation getOverlayResource(IAvatarTile tile, ItemStack stack) { + return avatarOverlay; + } +} \ No newline at end of file diff --git a/src/main/java/vazkii/botania/common/item/rod/ItemExchangeRod.java b/src/main/java/vazkii/botania/common/item/rod/ItemExchangeRod.java index 305a79c513..01369ff1c8 100644 --- a/src/main/java/vazkii/botania/common/item/rod/ItemExchangeRod.java +++ b/src/main/java/vazkii/botania/common/item/rod/ItemExchangeRod.java @@ -2,19 +2,17 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Aug 20, 2015, 8:08:34 PM (GMT)] */ package vazkii.botania.common.item.rod; -import cpw.mods.fml.common.eventhandler.SubscribeEvent; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; import java.util.ArrayList; import java.util.List; + import net.minecraft.block.Block; import net.minecraft.client.Minecraft; import net.minecraft.entity.Entity; @@ -44,407 +42,389 @@ import vazkii.botania.common.core.helper.ItemNBTHelper; import vazkii.botania.common.item.ItemMod; import vazkii.botania.common.lib.LibItemNames; +import cpw.mods.fml.common.eventhandler.SubscribeEvent; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; public class ItemExchangeRod extends ItemMod implements IManaUsingItem, IWireframeCoordinateListProvider { - private static final int RANGE = 3; - private static final int COST = 40; - - private static final String TAG_BLOCK_NAME = "blockName"; - private static final String TAG_BLOCK_META = "blockMeta"; - private static final String TAG_TARGET_BLOCK_NAME = "targetBlockName"; - private static final String TAG_TARGET_BLOCK_META = "targetBlockMeta"; - private static final String TAG_SWAPPING = "swapping"; - private static final String TAG_SELECT_X = "selectX"; - private static final String TAG_SELECT_Y = "selectY"; - private static final String TAG_SELECT_Z = "selectZ"; - private static final String TAG_EXTRA_RANGE = "extraRange"; - - public ItemExchangeRod() { - setMaxStackSize(1); - setUnlocalizedName(LibItemNames.EXCHANGE_ROD); - MinecraftForge.EVENT_BUS.register(this); - } - - @Override - public boolean onItemUse( - ItemStack par1ItemStack, - EntityPlayer par2EntityPlayer, - World par3World, - int par4, - int par5, - int par6, - int par7, - float par8, - float par9, - float par10) { - Block wblock = par3World.getBlock(par4, par5, par6); - int wmeta = par3World.getBlockMetadata(par4, par5, par6); - - if (par2EntityPlayer.isSneaking()) { - TileEntity tile = par3World.getTileEntity(par4, par5, par6); - if (tile == null) { - if (BlockCamo.isValidBlock(wblock)) { - Item item = Item.getItemFromBlock(wblock); - if (!item.getHasSubtypes()) wmeta = 0; - - boolean set = setBlock(par1ItemStack, wblock, wmeta); - par2EntityPlayer.setCurrentItemOrArmor(0, par1ItemStack); - - displayRemainderCounter(par2EntityPlayer, par1ItemStack); - return set; - } - } - } else if (canExchange(par1ItemStack) && !ItemNBTHelper.getBoolean(par1ItemStack, TAG_SWAPPING, false)) { - Block block = getBlock(par1ItemStack); - int meta = getBlockMeta(par1ItemStack); - List swap = - getBlocksToSwap(par3World, par1ItemStack, block, meta, par4, par5, par6, null, 0); - if (swap.size() > 0) { - ItemNBTHelper.setBoolean(par1ItemStack, TAG_SWAPPING, true); - ItemNBTHelper.setInt(par1ItemStack, TAG_SELECT_X, par4); - ItemNBTHelper.setInt(par1ItemStack, TAG_SELECT_Y, par5); - ItemNBTHelper.setInt(par1ItemStack, TAG_SELECT_Z, par6); - setTargetBlock(par1ItemStack, wblock, wmeta); - if (par3World.isRemote) par2EntityPlayer.swingItem(); - } - } - - return false; - } - - @SubscribeEvent - public void onLeftClick(PlayerInteractEvent event) { - if (event.action == Action.LEFT_CLICK_BLOCK) { - ItemStack stack = event.entityPlayer.getCurrentEquippedItem(); - if (stack != null - && stack.getItem() == this - && canExchange(stack) - && ManaItemHandler.requestManaExactForTool(stack, event.entityPlayer, COST, false)) { - if (exchange( - event.world, - event.entityPlayer, - event.x, - event.y, - event.z, - stack, - getBlock(stack), - getBlockMeta(stack))) - ManaItemHandler.requestManaExactForTool(stack, event.entityPlayer, COST, true); - } - } - } - - @Override - public void onUpdate(ItemStack stack, World world, Entity entity, int something, boolean somethingelse) { - if (!canExchange(stack) || !(entity instanceof EntityPlayer)) return; - - EntityPlayer player = (EntityPlayer) entity; - - int extraRange = ItemNBTHelper.getInt(stack, TAG_EXTRA_RANGE, 1); - int extraRangeNew = IManaProficiencyArmor.Helper.hasProficiency(player) ? 3 : 1; - if (extraRange != extraRangeNew) ItemNBTHelper.setInt(stack, TAG_EXTRA_RANGE, extraRangeNew); - - Block block = getBlock(stack); - int meta = getBlockMeta(stack); - if (ItemNBTHelper.getBoolean(stack, TAG_SWAPPING, false)) { - if (!ManaItemHandler.requestManaExactForTool(stack, player, COST, false)) { - ItemNBTHelper.setBoolean(stack, TAG_SWAPPING, false); - return; - } - - int x = ItemNBTHelper.getInt(stack, TAG_SELECT_X, 0); - int y = ItemNBTHelper.getInt(stack, TAG_SELECT_Y, 0); - int z = ItemNBTHelper.getInt(stack, TAG_SELECT_Z, 0); - Block targetBlock = getTargetBlock(stack); - int targetMeta = getTargetBlockMeta(stack); - List swap = getBlocksToSwap(world, stack, block, meta, x, y, z, targetBlock, targetMeta); - if (swap.size() == 0) { - ItemNBTHelper.setBoolean(stack, TAG_SWAPPING, false); - return; - } - - ChunkCoordinates coords = swap.get(world.rand.nextInt(swap.size())); - boolean exchange = exchange(world, player, coords.posX, coords.posY, coords.posZ, stack, block, meta); - if (exchange) ManaItemHandler.requestManaExactForTool(stack, player, COST, true); - else ItemNBTHelper.setBoolean(stack, TAG_SWAPPING, false); - } - } - - public List getBlocksToSwap( - World world, - ItemStack stack, - Block blockToSwap, - int metaToSwap, - int xc, - int yc, - int zc, - Block targetBlock, - int targetMeta) { - // If we have no target block passed in, infer it to be - // the block which the swapping is centered on (presumably the block - // which the player is looking at) - if (targetBlock == null) { - targetBlock = world.getBlock(xc, yc, zc); - targetMeta = world.getBlockMetadata(xc, yc, zc); - } - - // Our result list - List coordsList = new ArrayList(); - - // We subtract 1 from the effective range as the center tile is included - // So, with a range of 3, we are visiting tiles at -2, -1, 0, 1, 2 - int effRange = RANGE + ItemNBTHelper.getInt(stack, TAG_EXTRA_RANGE, 1) - 1; - - // Iterate in all 3 dimensions through our possible positions. - for (int offsetX = -effRange; offsetX <= effRange; offsetX++) - for (int offsetY = -effRange; offsetY <= effRange; offsetY++) - for (int offsetZ = -effRange; offsetZ <= effRange; offsetZ++) { - int x = xc + offsetX, y = yc + offsetY, z = zc + offsetZ; - - Block currentBlock = world.getBlock(x, y, z); - int currentMeta = world.getBlockMetadata(x, y, z); - - // If this block is not our target, ignore it, as we don't need - // to consider replacing it - if (currentBlock != targetBlock || currentMeta != targetMeta) continue; - - // If this block is already the block we're swapping to, - // we don't need to swap again - if (currentBlock == blockToSwap && currentMeta == metaToSwap) continue; - - // Check to see if the block is visible on any side: - for (ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS) { - int adjX = x + dir.offsetX, adjY = y + dir.offsetY, adjZ = z + dir.offsetZ; - Block adjBlock = world.getBlock(adjX, adjY, adjZ); - - // If the side of the adjacent block facing this block is - // _not_ solid, then this block is considered "visible" - // and should be replaced. - - // If there is a rendering-specific way to check for this, - // that should be placed in preference to this. - if (!adjBlock.isSideSolid(world, adjX, adjY, adjZ, dir.getOpposite())) { - coordsList.add(new ChunkCoordinates(x, y, z)); - break; - } - } - } - - return coordsList; - } - - public boolean exchange( - World world, EntityPlayer player, int x, int y, int z, ItemStack stack, Block blockToSet, int metaToSet) { - TileEntity tile = world.getTileEntity(x, y, z); - if (tile != null) return false; - - ItemStack placeStack = removeFromInventory(player, stack, blockToSet, metaToSet, false); - if (placeStack != null) { - Block blockAt = world.getBlock(x, y, z); - int meta = world.getBlockMetadata(x, y, z); - if (!blockAt.isAir(world, x, y, z) - && blockAt.getPlayerRelativeBlockHardness(player, world, x, y, z) > 0 - && (blockAt != blockToSet || meta != metaToSet)) { - if (!world.isRemote) { - if (!player.capabilities.isCreativeMode) { - List drops = blockAt.getDrops(world, x, y, z, meta, 0); - for (ItemStack drop : drops) - world.spawnEntityInWorld(new EntityItem(world, x + 0.5, y + 0.5, z + 0.5, drop)); - removeFromInventory(player, stack, blockToSet, metaToSet, true); - } - world.playAuxSFX(2001, x, y, z, Block.getIdFromBlock(blockAt) + (meta << 12)); - world.setBlock(x, y, z, blockToSet, metaToSet, 1 | 2); - blockToSet.onBlockPlacedBy(world, x, y, z, player, placeStack); - } - displayRemainderCounter(player, stack); - return true; - } - } - - return false; - } - - public boolean canExchange(ItemStack stack) { - Block block = getBlock(stack); - return block != null && block != Blocks.air; - } - - public static ItemStack removeFromInventory( - EntityPlayer player, IInventory inv, ItemStack stack, Block block, int meta, boolean doit) { - List providers = new ArrayList(); - for (int i = inv.getSizeInventory() - 1; i >= 0; i--) { - ItemStack invStack = inv.getStackInSlot(i); - if (invStack == null) continue; - - Item item = invStack.getItem(); - if (item == Item.getItemFromBlock(block) && invStack.getItemDamage() == meta) { - ItemStack retStack = invStack.copy(); - if (doit) { - invStack.stackSize--; - if (invStack.stackSize == 0) inv.setInventorySlotContents(i, null); - } - return retStack; - } - - if (item instanceof IBlockProvider) providers.add(invStack); - } - - for (ItemStack provStack : providers) { - IBlockProvider prov = (IBlockProvider) provStack.getItem(); - if (prov.provideBlock(player, stack, provStack, block, meta, doit)) return new ItemStack(block, 1, meta); - } - - return null; - } - - public static ItemStack removeFromInventory( - EntityPlayer player, ItemStack stack, Block block, int meta, boolean doit) { - if (player.capabilities.isCreativeMode) return new ItemStack(block, 1, meta); - - ItemStack outStack = removeFromInventory( - player, BotaniaAPI.internalHandler.getBaublesInventory(player), stack, block, meta, doit); - if (outStack == null) outStack = removeFromInventory(player, player.inventory, stack, block, meta, doit); - return outStack; - } - - public static int getInventoryItemCount(EntityPlayer player, ItemStack stack, Block block, int meta) { - if (player.capabilities.isCreativeMode) return -1; - - int baubleCount = getInventoryItemCount( - player, BotaniaAPI.internalHandler.getBaublesInventory(player), stack, block, meta); - if (baubleCount == -1) return -1; - - int count = getInventoryItemCount(player, player.inventory, stack, block, meta); - if (count == -1) return -1; - - return count + baubleCount; - } - - public static int getInventoryItemCount( - EntityPlayer player, IInventory inv, ItemStack stack, Block block, int meta) { - if (player.capabilities.isCreativeMode) return -1; - - int count = 0; - for (int i = 0; i < inv.getSizeInventory(); i++) { - ItemStack invStack = inv.getStackInSlot(i); - if (invStack == null) continue; - - Item item = invStack.getItem(); - if (item == Item.getItemFromBlock(block) && invStack.getItemDamage() == meta) count += invStack.stackSize; - - if (item instanceof IBlockProvider) { - IBlockProvider prov = (IBlockProvider) item; - int provCount = prov.getBlockCount(player, stack, invStack, block, meta); - if (provCount == -1) return -1; - count += provCount; - } - } - - return count; - } - - public void displayRemainderCounter(EntityPlayer player, ItemStack stack) { - Block block = getBlock(stack); - int meta = getBlockMeta(stack); - int count = getInventoryItemCount(player, stack, block, meta); - if (!player.worldObj.isRemote) ItemsRemainingRenderHandler.set(new ItemStack(block, 1, meta), count); - } - - @Override - public boolean isFull3D() { - return true; - } - - @Override - public boolean usesMana(ItemStack stack) { - return true; - } - - private boolean setBlock(ItemStack stack, Block block, int meta) { - ItemNBTHelper.setString(stack, TAG_BLOCK_NAME, Block.blockRegistry.getNameForObject(block)); - ItemNBTHelper.setInt(stack, TAG_BLOCK_META, meta); - return true; - } - - @Override - public String getItemStackDisplayName(ItemStack par1ItemStack) { - Block block = getBlock(par1ItemStack); - int meta = getBlockMeta(par1ItemStack); - return super.getItemStackDisplayName(par1ItemStack) - + (block == null - ? "" - : " (" + EnumChatFormatting.GREEN + new ItemStack(block, 1, meta).getDisplayName() - + EnumChatFormatting.RESET + ")"); - } - - public static String getBlockName(ItemStack stack) { - return ItemNBTHelper.getString(stack, TAG_BLOCK_NAME, ""); - } - - public static Block getBlock(ItemStack stack) { - Block block = Block.getBlockFromName(getBlockName(stack)); - return block; - } - - public static int getBlockMeta(ItemStack stack) { - return ItemNBTHelper.getInt(stack, TAG_BLOCK_META, 0); - } - - private boolean setTargetBlock(ItemStack stack, Block block, int meta) { - ItemNBTHelper.setString(stack, TAG_TARGET_BLOCK_NAME, Block.blockRegistry.getNameForObject(block)); - ItemNBTHelper.setInt(stack, TAG_TARGET_BLOCK_META, meta); - return true; - } - - public static String getTargetBlockName(ItemStack stack) { - return ItemNBTHelper.getString(stack, TAG_TARGET_BLOCK_NAME, ""); - } - - public static Block getTargetBlock(ItemStack stack) { - Block block = Block.getBlockFromName(getTargetBlockName(stack)); - return block; - } - - public static int getTargetBlockMeta(ItemStack stack) { - return ItemNBTHelper.getInt(stack, TAG_TARGET_BLOCK_META, 0); - } - - @Override - @SideOnly(Side.CLIENT) - public List getWireframesToDraw(EntityPlayer player, ItemStack stack) { - ItemStack holding = player.getCurrentEquippedItem(); - if (holding != stack || !canExchange(stack)) return null; - - Block block = getBlock(stack); - int meta = getBlockMeta(stack); - - MovingObjectPosition pos = Minecraft.getMinecraft().objectMouseOver; - if (pos != null) { - int x = pos.blockX; - int y = pos.blockY; - int z = pos.blockZ; - Block targetBlock = null; - int targetMeta = 0; - if (ItemNBTHelper.getBoolean(stack, TAG_SWAPPING, false)) { - x = ItemNBTHelper.getInt(stack, TAG_SELECT_X, 0); - y = ItemNBTHelper.getInt(stack, TAG_SELECT_Y, 0); - z = ItemNBTHelper.getInt(stack, TAG_SELECT_Z, 0); - targetBlock = getTargetBlock(stack); - targetMeta = getTargetBlockMeta(stack); - } - - if (!player.worldObj.isAirBlock(x, y, z)) { - List coordsList = - getBlocksToSwap(player.worldObj, stack, block, meta, x, y, z, targetBlock, targetMeta); - for (ChunkCoordinates coords : coordsList) - if (coords.posX == x && coords.posY == y && coords.posZ == z) { - coordsList.remove(coords); - break; - } - return coordsList; - } - } - return null; - } + private static final int RANGE = 3; + private static final int COST = 40; + + private static final String TAG_BLOCK_NAME = "blockName"; + private static final String TAG_BLOCK_META = "blockMeta"; + private static final String TAG_TARGET_BLOCK_NAME = "targetBlockName"; + private static final String TAG_TARGET_BLOCK_META = "targetBlockMeta"; + private static final String TAG_SWAPPING = "swapping"; + private static final String TAG_SELECT_X = "selectX"; + private static final String TAG_SELECT_Y = "selectY"; + private static final String TAG_SELECT_Z = "selectZ"; + private static final String TAG_EXTRA_RANGE = "extraRange"; + + public ItemExchangeRod() { + setMaxStackSize(1); + setUnlocalizedName(LibItemNames.EXCHANGE_ROD); + MinecraftForge.EVENT_BUS.register(this); + } + + @Override + public boolean onItemUse(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, World par3World, int par4, int par5, int par6, int par7, float par8, float par9, float par10) { + Block wblock = par3World.getBlock(par4, par5, par6); + int wmeta = par3World.getBlockMetadata(par4, par5, par6); + + if(par2EntityPlayer.isSneaking()) { + TileEntity tile = par3World.getTileEntity(par4, par5, par6); + if(tile == null) { + if(BlockCamo.isValidBlock(wblock)) { + Item item = Item.getItemFromBlock(wblock); + if(!item.getHasSubtypes()) + wmeta = 0; + + boolean set = setBlock(par1ItemStack, wblock, wmeta); + par2EntityPlayer.setCurrentItemOrArmor(0, par1ItemStack); + + displayRemainderCounter(par2EntityPlayer, par1ItemStack); + return set; + } + } + } else if(canExchange(par1ItemStack) && !ItemNBTHelper.getBoolean(par1ItemStack, TAG_SWAPPING, false)) { + Block block = getBlock(par1ItemStack); + int meta = getBlockMeta(par1ItemStack); + List swap = getBlocksToSwap(par3World, par1ItemStack, block, meta, par4, par5, par6, null, 0); + if(swap.size() > 0) { + ItemNBTHelper.setBoolean(par1ItemStack, TAG_SWAPPING, true); + ItemNBTHelper.setInt(par1ItemStack, TAG_SELECT_X, par4); + ItemNBTHelper.setInt(par1ItemStack, TAG_SELECT_Y, par5); + ItemNBTHelper.setInt(par1ItemStack, TAG_SELECT_Z, par6); + setTargetBlock(par1ItemStack, wblock, wmeta); + if(par3World.isRemote) + par2EntityPlayer.swingItem(); + } + } + + return false; + } + + @SubscribeEvent + public void onLeftClick(PlayerInteractEvent event) { + if(event.action == Action.LEFT_CLICK_BLOCK) { + ItemStack stack = event.entityPlayer.getCurrentEquippedItem(); + if(stack != null && stack.getItem() == this && canExchange(stack) && ManaItemHandler.requestManaExactForTool(stack, event.entityPlayer, COST, false)) { + if(exchange(event.world, event.entityPlayer, event.x, event.y, event.z, stack, getBlock(stack), getBlockMeta(stack))) + ManaItemHandler.requestManaExactForTool(stack, event.entityPlayer, COST, true); + } + } + } + + @Override + public void onUpdate(ItemStack stack, World world, Entity entity, int something, boolean somethingelse) { + if(!canExchange(stack) || !(entity instanceof EntityPlayer)) + return; + + EntityPlayer player = (EntityPlayer) entity; + + int extraRange = ItemNBTHelper.getInt(stack, TAG_EXTRA_RANGE, 1); + int extraRangeNew = IManaProficiencyArmor.Helper.hasProficiency(player) ? 3 : 1; + if(extraRange != extraRangeNew) + ItemNBTHelper.setInt(stack, TAG_EXTRA_RANGE, extraRangeNew); + + Block block = getBlock(stack); + int meta = getBlockMeta(stack); + if(ItemNBTHelper.getBoolean(stack, TAG_SWAPPING, false)) { + if(!ManaItemHandler.requestManaExactForTool(stack, player, COST, false)) { + ItemNBTHelper.setBoolean(stack, TAG_SWAPPING, false); + return; + } + + int x = ItemNBTHelper.getInt(stack, TAG_SELECT_X, 0); + int y = ItemNBTHelper.getInt(stack, TAG_SELECT_Y, 0); + int z = ItemNBTHelper.getInt(stack, TAG_SELECT_Z, 0); + Block targetBlock = getTargetBlock(stack); + int targetMeta = getTargetBlockMeta(stack); + List swap = getBlocksToSwap(world, stack, block, meta, x, y, z, targetBlock, targetMeta); + if(swap.size() == 0) { + ItemNBTHelper.setBoolean(stack, TAG_SWAPPING, false); + return; + } + + ChunkCoordinates coords = swap.get(world.rand.nextInt(swap.size())); + boolean exchange = exchange(world, player, coords.posX, coords.posY, coords.posZ, stack, block, meta); + if(exchange) + ManaItemHandler.requestManaExactForTool(stack, player, COST, true); + else ItemNBTHelper.setBoolean(stack, TAG_SWAPPING, false); + } + } + + public List getBlocksToSwap(World world, ItemStack stack, Block blockToSwap, int metaToSwap, int xc, int yc, int zc, Block targetBlock, int targetMeta) { + // If we have no target block passed in, infer it to be + // the block which the swapping is centered on (presumably the block + // which the player is looking at) + if(targetBlock == null) { + targetBlock = world.getBlock(xc, yc, zc); + targetMeta = world.getBlockMetadata(xc, yc, zc); + } + + // Our result list + List coordsList = new ArrayList(); + + // We subtract 1 from the effective range as the center tile is included + // So, with a range of 3, we are visiting tiles at -2, -1, 0, 1, 2 + int effRange = RANGE + ItemNBTHelper.getInt(stack, TAG_EXTRA_RANGE, 1) - 1; + + // Iterate in all 3 dimensions through our possible positions. + for(int offsetX = -effRange; offsetX <= effRange; offsetX++) + for(int offsetY = -effRange; offsetY <= effRange; offsetY++) + for(int offsetZ = -effRange; offsetZ <= effRange; offsetZ++) { + int x = xc + offsetX, y = yc + offsetY, z = zc + offsetZ; + + Block currentBlock = world.getBlock(x, y, z); + int currentMeta = world.getBlockMetadata(x, y, z); + + // If this block is not our target, ignore it, as we don't need + // to consider replacing it + if(currentBlock != targetBlock || currentMeta != targetMeta) + continue; + + // If this block is already the block we're swapping to, + // we don't need to swap again + if(currentBlock == blockToSwap && currentMeta == metaToSwap) + continue; + + // Check to see if the block is visible on any side: + for(ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS) { + int adjX = x + dir.offsetX, adjY = y + dir.offsetY, adjZ = z + dir.offsetZ; + Block adjBlock = world.getBlock(adjX, adjY, adjZ); + + // If the side of the adjacent block facing this block is + // _not_ solid, then this block is considered "visible" + // and should be replaced. + + // If there is a rendering-specific way to check for this, + // that should be placed in preference to this. + if(!adjBlock.isSideSolid(world, adjX, adjY, adjZ, dir.getOpposite())) { + coordsList.add(new ChunkCoordinates(x, y, z)); + break; + } + } + } + + return coordsList; + } + + public boolean exchange(World world, EntityPlayer player, int x, int y, int z, ItemStack stack, Block blockToSet, int metaToSet) { + TileEntity tile = world.getTileEntity(x, y, z); + if(tile != null) + return false; + + ItemStack placeStack = removeFromInventory(player, stack, blockToSet, metaToSet, false); + if(placeStack != null) { + Block blockAt = world.getBlock(x, y, z); + int meta = world.getBlockMetadata(x, y, z); + if(!blockAt.isAir(world, x, y, z) && blockAt.getPlayerRelativeBlockHardness(player, world, x, y, z) > 0 && (blockAt != blockToSet || meta != metaToSet)) { + if(!world.isRemote) { + if(!player.capabilities.isCreativeMode) { + List drops = blockAt.getDrops(world, x, y, z, meta, 0); + for(ItemStack drop : drops) + world.spawnEntityInWorld(new EntityItem(world, x + 0.5, y + 0.5, z + 0.5, drop)); + removeFromInventory(player, stack, blockToSet, metaToSet, true); + } + world.playAuxSFX(2001, x, y, z, Block.getIdFromBlock(blockAt) + (meta << 12)); + world.setBlock(x, y, z, blockToSet, metaToSet, 1 | 2); + blockToSet.onBlockPlacedBy(world, x, y, z, player, placeStack); + } + displayRemainderCounter(player, stack); + return true; + } + } + + return false; + } + + public boolean canExchange(ItemStack stack) { + Block block = getBlock(stack); + return block != null && block != Blocks.air; + } + + public static ItemStack removeFromInventory(EntityPlayer player, IInventory inv, ItemStack stack, Block block, int meta, boolean doit) { + List providers = new ArrayList(); + for(int i = inv.getSizeInventory() - 1; i >= 0; i--) { + ItemStack invStack = inv.getStackInSlot(i); + if(invStack == null) + continue; + + Item item = invStack.getItem(); + if(item == Item.getItemFromBlock(block) && invStack.getItemDamage() == meta) { + ItemStack retStack = invStack.copy(); + if(doit) { + invStack.stackSize--; + if(invStack.stackSize == 0) + inv.setInventorySlotContents(i, null); + } + return retStack; + } + + if(item instanceof IBlockProvider) + providers.add(invStack); + } + + for(ItemStack provStack : providers) { + IBlockProvider prov = (IBlockProvider) provStack.getItem(); + if(prov.provideBlock(player, stack, provStack, block, meta, doit)) + return new ItemStack(block, 1, meta); + } + + return null; + } + + public static ItemStack removeFromInventory(EntityPlayer player, ItemStack stack, Block block, int meta, boolean doit) { + if(player.capabilities.isCreativeMode) + return new ItemStack(block, 1, meta); + + ItemStack outStack = removeFromInventory(player, BotaniaAPI.internalHandler.getBaublesInventory(player), stack, block, meta, doit); + if (outStack == null) + outStack = removeFromInventory(player, player.inventory, stack, block, meta, doit); + return outStack; + } + + public static int getInventoryItemCount(EntityPlayer player, ItemStack stack, Block block, int meta) { + if(player.capabilities.isCreativeMode) + return -1; + + int baubleCount = getInventoryItemCount(player, BotaniaAPI.internalHandler.getBaublesInventory(player), stack, block, meta); + if (baubleCount == -1) return -1; + + int count = getInventoryItemCount(player, player.inventory, stack, block, meta); + if (count == -1) return -1; + + return count+baubleCount; + } + + public static int getInventoryItemCount(EntityPlayer player, IInventory inv, ItemStack stack, Block block, int meta) { + if(player.capabilities.isCreativeMode) + return -1; + + int count = 0; + for(int i = 0; i < inv.getSizeInventory(); i++) { + ItemStack invStack = inv.getStackInSlot(i); + if(invStack == null) + continue; + + Item item = invStack.getItem(); + if(item == Item.getItemFromBlock(block) && invStack.getItemDamage() == meta) + count += invStack.stackSize; + + if(item instanceof IBlockProvider) { + IBlockProvider prov = (IBlockProvider) item; + int provCount = prov.getBlockCount(player, stack, invStack, block, meta); + if(provCount == -1) + return -1; + count += provCount; + } + } + + return count; + } + + public void displayRemainderCounter(EntityPlayer player, ItemStack stack) { + Block block = getBlock(stack); + int meta = getBlockMeta(stack); + int count = getInventoryItemCount(player, stack, block, meta); + if(!player.worldObj.isRemote) + ItemsRemainingRenderHandler.set(new ItemStack(block, 1, meta), count); + } + + @Override + public boolean isFull3D() { + return true; + } + + @Override + public boolean usesMana(ItemStack stack) { + return true; + } + + private boolean setBlock(ItemStack stack, Block block, int meta) { + ItemNBTHelper.setString(stack, TAG_BLOCK_NAME, Block.blockRegistry.getNameForObject(block)); + ItemNBTHelper.setInt(stack, TAG_BLOCK_META, meta); + return true; + } + + @Override + public String getItemStackDisplayName(ItemStack par1ItemStack) { + Block block = getBlock(par1ItemStack); + int meta = getBlockMeta(par1ItemStack); + return super.getItemStackDisplayName(par1ItemStack) + (block == null ? "" : " (" + EnumChatFormatting.GREEN + new ItemStack(block, 1, meta).getDisplayName() + EnumChatFormatting.RESET + ")"); + } + + public static String getBlockName(ItemStack stack) { + return ItemNBTHelper.getString(stack, TAG_BLOCK_NAME, ""); + } + + public static Block getBlock(ItemStack stack) { + Block block = Block.getBlockFromName(getBlockName(stack)); + return block; + } + + public static int getBlockMeta(ItemStack stack) { + return ItemNBTHelper.getInt(stack, TAG_BLOCK_META, 0); + } + + private boolean setTargetBlock(ItemStack stack, Block block, int meta) { + ItemNBTHelper.setString(stack, TAG_TARGET_BLOCK_NAME, Block.blockRegistry.getNameForObject(block)); + ItemNBTHelper.setInt(stack, TAG_TARGET_BLOCK_META, meta); + return true; + } + + public static String getTargetBlockName(ItemStack stack) { + return ItemNBTHelper.getString(stack, TAG_TARGET_BLOCK_NAME, ""); + } + + public static Block getTargetBlock(ItemStack stack) { + Block block = Block.getBlockFromName(getTargetBlockName(stack)); + return block; + } + + public static int getTargetBlockMeta(ItemStack stack) { + return ItemNBTHelper.getInt(stack, TAG_TARGET_BLOCK_META, 0); + } + + @Override + @SideOnly(Side.CLIENT) + public List getWireframesToDraw(EntityPlayer player, ItemStack stack) { + ItemStack holding = player.getCurrentEquippedItem(); + if(holding != stack || !canExchange(stack)) + return null; + + Block block = getBlock(stack); + int meta = getBlockMeta(stack); + + MovingObjectPosition pos = Minecraft.getMinecraft().objectMouseOver; + if(pos != null) { + int x = pos.blockX; + int y = pos.blockY; + int z = pos.blockZ; + Block targetBlock = null; + int targetMeta = 0; + if(ItemNBTHelper.getBoolean(stack, TAG_SWAPPING, false)) { + x = ItemNBTHelper.getInt(stack, TAG_SELECT_X, 0); + y = ItemNBTHelper.getInt(stack, TAG_SELECT_Y, 0); + z = ItemNBTHelper.getInt(stack, TAG_SELECT_Z, 0); + targetBlock = getTargetBlock(stack); + targetMeta = getTargetBlockMeta(stack); + } + + if(!player.worldObj.isAirBlock(x, y, z)) { + List coordsList = getBlocksToSwap(player.worldObj, stack, block, meta, x, y, z, targetBlock, targetMeta); + for(ChunkCoordinates coords : coordsList) + if(coords.posX == x && coords.posY == y && coords.posZ == z) { + coordsList.remove(coords); + break; + } + return coordsList; + } + + } + return null; + } + } diff --git a/src/main/java/vazkii/botania/common/item/rod/ItemFireRod.java b/src/main/java/vazkii/botania/common/item/rod/ItemFireRod.java index 516fb99534..32f3b0ffd6 100644 --- a/src/main/java/vazkii/botania/common/item/rod/ItemFireRod.java +++ b/src/main/java/vazkii/botania/common/item/rod/ItemFireRod.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jun 26, 2014, 12:08:06 AM (GMT)] */ package vazkii.botania.common.item.rod; @@ -28,79 +28,64 @@ public class ItemFireRod extends ItemMod implements IManaUsingItem, IAvatarWieldable { - private static final ResourceLocation avatarOverlay = new ResourceLocation(LibResources.MODEL_AVATAR_FIRE); + private static final ResourceLocation avatarOverlay = new ResourceLocation(LibResources.MODEL_AVATAR_FIRE); - private static final int COST = 900; - private static final int COOLDOWN = 1200; + private static final int COST = 900; + private static final int COOLDOWN = 1200; - public ItemFireRod() { - setUnlocalizedName(LibItemNames.FIRE_ROD); - setMaxStackSize(1); - setMaxDamage(COOLDOWN); - } + public ItemFireRod() { + setUnlocalizedName(LibItemNames.FIRE_ROD); + setMaxStackSize(1); + setMaxDamage(COOLDOWN); + } - @Override - public boolean onItemUse( - ItemStack par1ItemStack, - EntityPlayer player, - World par3World, - int x, - int y, - int z, - int par7, - float par8, - float par9, - float par10) { - if (!par3World.isRemote - && par1ItemStack.getItemDamage() == 0 - && ManaItemHandler.requestManaExactForTool(par1ItemStack, player, COST, false)) { - EntityFlameRing entity = new EntityFlameRing(player.worldObj); - entity.setPosition(x + 0.5, y + 1, z + 0.5); - player.worldObj.spawnEntityInWorld(entity); + @Override + public boolean onItemUse(ItemStack par1ItemStack, EntityPlayer player, World par3World, int x, int y, int z, int par7, float par8, float par9, float par10) { + if(!par3World.isRemote && par1ItemStack.getItemDamage() == 0 && ManaItemHandler.requestManaExactForTool(par1ItemStack, player, COST, false)) { + EntityFlameRing entity = new EntityFlameRing(player.worldObj); + entity.setPosition(x + 0.5, y + 1, z + 0.5); + player.worldObj.spawnEntityInWorld(entity); - par1ItemStack.setItemDamage(COOLDOWN); - ManaItemHandler.requestManaExactForTool(par1ItemStack, player, COST, true); - par3World.playSoundAtEntity(player, "mob.blaze.breathe", 1F, 1F); - } + par1ItemStack.setItemDamage(COOLDOWN); + ManaItemHandler.requestManaExactForTool(par1ItemStack, player, COST, true); + par3World.playSoundAtEntity(player, "mob.blaze.breathe", 1F, 1F); + } - return true; - } + return true; + } - @Override - public void onUpdate(ItemStack par1ItemStack, World par2World, Entity par3Entity, int par4, boolean par5) { - if (par1ItemStack.isItemDamaged() && par3Entity instanceof EntityPlayer) - par1ItemStack.setItemDamage(par1ItemStack.getItemDamage() - - (IManaProficiencyArmor.Helper.hasProficiency((EntityPlayer) par3Entity) ? 2 : 1)); - } + @Override + public void onUpdate(ItemStack par1ItemStack, World par2World, Entity par3Entity, int par4, boolean par5) { + if(par1ItemStack.isItemDamaged() && par3Entity instanceof EntityPlayer) + par1ItemStack.setItemDamage(par1ItemStack.getItemDamage() - (IManaProficiencyArmor.Helper.hasProficiency((EntityPlayer) par3Entity) ? 2 : 1)); + } - @Override - public boolean isFull3D() { - return true; - } + @Override + public boolean isFull3D() { + return true; + } - @Override - public boolean usesMana(ItemStack stack) { - return true; - } + @Override + public boolean usesMana(ItemStack stack) { + return true; + } - @Override - public void onAvatarUpdate(IAvatarTile tile, ItemStack stack) { - TileEntity te = (TileEntity) tile; - World world = te.getWorldObj(); + @Override + public void onAvatarUpdate(IAvatarTile tile, ItemStack stack) { + TileEntity te = (TileEntity) tile; + World world = te.getWorldObj(); - if (!world.isRemote - && tile.getCurrentMana() >= COST - && tile.getElapsedFunctionalTicks() % 300 == 0 - && tile.isEnabled()) { - EntityFlameRing entity = new EntityFlameRing(world); - entity.setPosition(te.xCoord + 0.5, te.yCoord, te.zCoord + 0.5); - world.spawnEntityInWorld(entity); - tile.recieveMana(-COST); - } - } + if(!world.isRemote && tile.getCurrentMana() >= COST && tile.getElapsedFunctionalTicks() % 300 == 0 && tile.isEnabled()) { + EntityFlameRing entity = new EntityFlameRing(world); + entity.setPosition(te.xCoord + 0.5, te.yCoord, te.zCoord + 0.5); + world.spawnEntityInWorld(entity); + tile.recieveMana(-COST); + } + } + + @Override + public ResourceLocation getOverlayResource(IAvatarTile tile, ItemStack stack) { + return avatarOverlay; + } - @Override - public ResourceLocation getOverlayResource(IAvatarTile tile, ItemStack stack) { - return avatarOverlay; - } } diff --git a/src/main/java/vazkii/botania/common/item/rod/ItemGravityRod.java b/src/main/java/vazkii/botania/common/item/rod/ItemGravityRod.java index 7f11338f89..08e2b8f136 100644 --- a/src/main/java/vazkii/botania/common/item/rod/ItemGravityRod.java +++ b/src/main/java/vazkii/botania/common/item/rod/ItemGravityRod.java @@ -2,16 +2,17 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Aug 25, 2014, 2:57:16 PM (GMT)] */ package vazkii.botania.common.item.rod; import java.util.ArrayList; import java.util.List; + import net.minecraft.entity.Entity; import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.item.EntityItem; @@ -35,230 +36,205 @@ public class ItemGravityRod extends ItemMod implements IManaUsingItem { - private static final float RANGE = 3F; - private static final int COST = 2; - - private static final String TAG_TICKS_TILL_EXPIRE = "ticksTillExpire"; - private static final String TAG_TICKS_COOLDOWN = "ticksCooldown"; - private static final String TAG_TARGET = "target"; - private static final String TAG_DIST = "dist"; - - public ItemGravityRod() { - setMaxStackSize(1); - setUnlocalizedName(LibItemNames.GRAVITY_ROD); - } - - @Override - public void onUpdate(ItemStack stack, World world, Entity par3Entity, int p_77663_4_, boolean p_77663_5_) { - if (!(par3Entity instanceof EntityPlayer)) return; - - int ticksTillExpire = ItemNBTHelper.getInt(stack, TAG_TICKS_TILL_EXPIRE, 0); - int ticksCooldown = ItemNBTHelper.getInt(stack, TAG_TICKS_COOLDOWN, 0); - - if (ticksTillExpire == 0) { - ItemNBTHelper.setInt(stack, TAG_TARGET, -1); - ItemNBTHelper.setDouble(stack, TAG_DIST, -1); - } - - if (ticksCooldown > 0) ticksCooldown--; - - ticksTillExpire--; - ItemNBTHelper.setInt(stack, TAG_TICKS_TILL_EXPIRE, ticksTillExpire); - ItemNBTHelper.setInt(stack, TAG_TICKS_COOLDOWN, ticksCooldown); - - EntityPlayer player = (EntityPlayer) par3Entity; - PotionEffect haste = player.getActivePotionEffect(Potion.digSpeed); - float check = haste == null ? 0.16666667F : haste.getAmplifier() == 1 ? 0.5F : 0.4F; - if (player.getCurrentEquippedItem() == stack && player.swingProgress == check && !world.isRemote) - leftClick(player); - } - - @Override - public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer player) { - int targetID = ItemNBTHelper.getInt(stack, TAG_TARGET, -1); - int ticksCooldown = ItemNBTHelper.getInt(stack, TAG_TICKS_COOLDOWN, 0); - double length = ItemNBTHelper.getDouble(stack, TAG_DIST, -1); - - if (ticksCooldown == 0) { - Entity item = null; - if (targetID != -1 && player.worldObj.getEntityByID(targetID) != null) { - Entity taritem = player.worldObj.getEntityByID(targetID); - - boolean found = false; - Vector3 target = Vector3.fromEntityCenter(player); - List entities = new ArrayList(); - int distance = 1; - while (entities.size() == 0 && distance < 25) { - target.add(new Vector3(player.getLookVec()).multiply(distance)); - - target.y += 0.5; - entities = player.worldObj.getEntitiesWithinAABBExcludingEntity( - player, - AxisAlignedBB.getBoundingBox( - target.x - RANGE, - target.y - RANGE, - target.z - RANGE, - target.x + RANGE, - target.y + RANGE, - target.z + RANGE)); - distance++; - if (entities.contains(taritem)) found = true; - } - - if (found) item = player.worldObj.getEntityByID(targetID); - } - - if (item == null) { - Vector3 target = Vector3.fromEntityCenter(player); - List entities = new ArrayList(); - int distance = 1; - while (entities.size() == 0 && distance < 25) { - target.add(new Vector3(player.getLookVec()).multiply(distance)); - - target.y += 0.5; - entities = player.worldObj.getEntitiesWithinAABBExcludingEntity( - player, - AxisAlignedBB.getBoundingBox( - target.x - RANGE, - target.y - RANGE, - target.z - RANGE, - target.x + RANGE, - target.y + RANGE, - target.z + RANGE)); - distance++; - } - - if (entities.size() > 0) { - item = entities.get(0); - length = 5.5D; - if (item instanceof EntityItem) length = 2.0D; - } - } - - if (item != null) { - if (BotaniaAPI.isEntityBlacklistedFromGravityRod(item.getClass())) return stack; - - if (ManaItemHandler.requestManaExactForTool(stack, player, COST, true)) { - if (item instanceof EntityItem) ((EntityItem) item).delayBeforeCanPickup = 5; - - if (item instanceof EntityLivingBase) { - EntityLivingBase targetEntity = (EntityLivingBase) item; - targetEntity.fallDistance = 0.0F; - if (targetEntity.getActivePotionEffect(Potion.moveSlowdown) == null) - targetEntity.addPotionEffect(new PotionEffect(Potion.moveSlowdown.id, 2, 3, true)); - } - - Vector3 target3 = Vector3.fromEntityCenter(player); - target3.add(new Vector3(player.getLookVec()).multiply(length)); - target3.y += 0.5; - if (item instanceof EntityItem) target3.y += 0.25; - - for (int i = 0; i < 4; i++) { - float r = 0.5F + (float) Math.random() * 0.5F; - float b = 0.5F + (float) Math.random() * 0.5F; - float s = 0.2F + (float) Math.random() * 0.1F; - float m = 0.1F; - float xm = ((float) Math.random() - 0.5F) * m; - float ym = ((float) Math.random() - 0.5F) * m; - float zm = ((float) Math.random() - 0.5F) * m; - Botania.proxy.wispFX( - world, - item.posX + item.width / 2, - item.posY + item.height / 2, - item.posZ + item.width / 2, - r, - 0F, - b, - s, - xm, - ym, - zm); - } - - setEntityMotionFromVector(item, target3, 0.3333333F); - - ItemNBTHelper.setInt(stack, TAG_TARGET, item.getEntityId()); - ItemNBTHelper.setDouble(stack, TAG_DIST, length); - } - } - - if (item != null) ItemNBTHelper.setInt(stack, TAG_TICKS_TILL_EXPIRE, 5); - } - return stack; - } - - public static void setEntityMotionFromVector(Entity entity, Vector3 originalPosVector, float modifier) { - Vector3 entityVector = Vector3.fromEntityCenter(entity); - Vector3 finalVector = originalPosVector.copy().subtract(entityVector); - - if (finalVector.mag() > 1) finalVector.normalize(); - - entity.motionX = finalVector.x * modifier; - entity.motionY = finalVector.y * modifier; - entity.motionZ = finalVector.z * modifier; - } - - @Override - public boolean usesMana(ItemStack stack) { - return true; - } - - public static void leftClick(EntityPlayer player) { - ItemStack stack = player.getHeldItem(); - if (stack != null && stack.getItem() == ModItems.gravityRod) { - int targetID = ItemNBTHelper.getInt(stack, TAG_TARGET, -1); - ItemNBTHelper.getDouble(stack, TAG_DIST, -1); - Entity item = null; - - if (targetID != -1 && player.worldObj.getEntityByID(targetID) != null) { - Entity taritem = player.worldObj.getEntityByID(targetID); - - boolean found = false; - Vector3 target = Vector3.fromEntityCenter(player); - List entities = new ArrayList(); - int distance = 1; - while (entities.size() == 0 && distance < 25) { - target.add(new Vector3(player.getLookVec()).multiply(distance)); - - target.y += 0.5; - entities = player.worldObj.getEntitiesWithinAABBExcludingEntity( - player, - AxisAlignedBB.getBoundingBox( - target.x - RANGE, - target.y - RANGE, - target.z - RANGE, - target.x + RANGE, - target.y + RANGE, - target.z + RANGE)); - distance++; - if (entities.contains(taritem)) found = true; - } - - if (found) { - item = player.worldObj.getEntityByID(targetID); - ItemNBTHelper.setInt(stack, TAG_TARGET, -1); - ItemNBTHelper.setDouble(stack, TAG_DIST, -1); - Vector3 moveVector = new Vector3(player.getLookVec().normalize()); - if (item instanceof EntityItem) { - ((EntityItem) item).delayBeforeCanPickup = 20; - float mot = IManaProficiencyArmor.Helper.hasProficiency(player) ? 2.25F : 1.5F; - item.motionX = moveVector.x * mot; - item.motionY = moveVector.y; - item.motionZ = moveVector.z * mot; - if (!player.worldObj.isRemote) { - EntityThrownItem thrown = new EntityThrownItem( - item.worldObj, item.posX, item.posY, item.posZ, (EntityItem) item); - item.worldObj.spawnEntityInWorld(thrown); - } - item.setDead(); - } else { - item.motionX = moveVector.x * 3.0F; - item.motionY = moveVector.y * 1.5F; - item.motionZ = moveVector.z * 3.0F; - } - ItemNBTHelper.setInt(stack, TAG_TICKS_COOLDOWN, 10); - } - } - } - } -} + private static final float RANGE = 3F; + private static final int COST = 2; + + private static final String TAG_TICKS_TILL_EXPIRE = "ticksTillExpire"; + private static final String TAG_TICKS_COOLDOWN = "ticksCooldown"; + private static final String TAG_TARGET = "target"; + private static final String TAG_DIST = "dist"; + + public ItemGravityRod() { + setMaxStackSize(1); + setUnlocalizedName(LibItemNames.GRAVITY_ROD); + } + + @Override + public void onUpdate(ItemStack stack, World world, Entity par3Entity, int p_77663_4_, boolean p_77663_5_) { + if(!(par3Entity instanceof EntityPlayer)) + return; + + int ticksTillExpire = ItemNBTHelper.getInt(stack, TAG_TICKS_TILL_EXPIRE, 0); + int ticksCooldown = ItemNBTHelper.getInt(stack, TAG_TICKS_COOLDOWN, 0); + + if(ticksTillExpire == 0) { + ItemNBTHelper.setInt(stack, TAG_TARGET, -1); + ItemNBTHelper.setDouble(stack, TAG_DIST, -1); + } + + if(ticksCooldown > 0) + ticksCooldown--; + + ticksTillExpire--; + ItemNBTHelper.setInt(stack, TAG_TICKS_TILL_EXPIRE, ticksTillExpire); + ItemNBTHelper.setInt(stack, TAG_TICKS_COOLDOWN, ticksCooldown); + + EntityPlayer player = (EntityPlayer) par3Entity; + PotionEffect haste = player.getActivePotionEffect(Potion.digSpeed); + float check = haste == null ? 0.16666667F : haste.getAmplifier() == 1 ? 0.5F : 0.4F; + if(player.getCurrentEquippedItem() == stack && player.swingProgress == check && !world.isRemote) + leftClick(player); + } + + @Override + public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer player) { + int targetID = ItemNBTHelper.getInt(stack, TAG_TARGET, -1); + int ticksCooldown = ItemNBTHelper.getInt(stack, TAG_TICKS_COOLDOWN, 0); + double length = ItemNBTHelper.getDouble(stack, TAG_DIST, -1); + + if(ticksCooldown == 0) { + Entity item = null; + if(targetID != -1 && player.worldObj.getEntityByID(targetID) != null) { + Entity taritem = player.worldObj.getEntityByID(targetID); + + boolean found = false; + Vector3 target = Vector3.fromEntityCenter(player); + List entities = new ArrayList(); + int distance = 1; + while(entities.size() == 0 && distance < 25) { + target.add(new Vector3(player.getLookVec()).multiply(distance)); + + target.y += 0.5; + entities = player.worldObj.getEntitiesWithinAABBExcludingEntity(player, AxisAlignedBB.getBoundingBox(target.x - RANGE, target.y - RANGE, target.z - RANGE, target.x + RANGE, target.y + RANGE, target.z + RANGE)); + distance++; + if(entities.contains(taritem)) + found = true; + } + + if(found) + item = player.worldObj.getEntityByID(targetID); + } + + if(item == null) { + Vector3 target = Vector3.fromEntityCenter(player); + List entities = new ArrayList(); + int distance = 1; + while(entities.size() == 0 && distance < 25) { + target.add(new Vector3(player.getLookVec()).multiply(distance)); + + target.y += 0.5; + entities = player.worldObj.getEntitiesWithinAABBExcludingEntity(player, AxisAlignedBB.getBoundingBox(target.x - RANGE, target.y - RANGE, target.z - RANGE, target.x + RANGE, target.y + RANGE, target.z + RANGE)); + distance++; + } + + if(entities.size() > 0) { + item = entities.get(0); + length = 5.5D; + if(item instanceof EntityItem) + length = 2.0D; + } + } + + if(item != null) { + if(BotaniaAPI.isEntityBlacklistedFromGravityRod(item.getClass())) + return stack; + + if(ManaItemHandler.requestManaExactForTool(stack, player, COST, true)) { + if(item instanceof EntityItem) + ((EntityItem)item).delayBeforeCanPickup = 5; + + if(item instanceof EntityLivingBase) { + EntityLivingBase targetEntity = (EntityLivingBase)item; + targetEntity.fallDistance = 0.0F; + if(targetEntity.getActivePotionEffect(Potion.moveSlowdown) == null) + targetEntity.addPotionEffect(new PotionEffect(Potion.moveSlowdown.id, 2, 3, true)); + } + + Vector3 target3 = Vector3.fromEntityCenter(player); + target3.add(new Vector3(player.getLookVec()).multiply(length)); + target3.y += 0.5; + if(item instanceof EntityItem) + target3.y += 0.25; + + for(int i = 0; i < 4; i++) { + float r = 0.5F + (float) Math.random() * 0.5F; + float b = 0.5F + (float) Math.random() * 0.5F; + float s = 0.2F + (float) Math.random() * 0.1F; + float m = 0.1F; + float xm = ((float) Math.random() - 0.5F) * m; + float ym = ((float) Math.random() - 0.5F) * m; + float zm = ((float) Math.random() - 0.5F) * m; + Botania.proxy.wispFX(world, item.posX + item.width / 2, item.posY + item.height / 2, item.posZ + item.width / 2, r, 0F, b, s, xm, ym, zm); + } + + setEntityMotionFromVector(item, target3, 0.3333333F); + + ItemNBTHelper.setInt(stack, TAG_TARGET, item.getEntityId()); + ItemNBTHelper.setDouble(stack, TAG_DIST, length); + } + } + + if(item != null) + ItemNBTHelper.setInt(stack, TAG_TICKS_TILL_EXPIRE, 5); + } + return stack; + } + + public static void setEntityMotionFromVector(Entity entity, Vector3 originalPosVector, float modifier) { + Vector3 entityVector = Vector3.fromEntityCenter(entity); + Vector3 finalVector = originalPosVector.copy().subtract(entityVector); + + if(finalVector.mag() > 1) + finalVector.normalize(); + + entity.motionX = finalVector.x * modifier; + entity.motionY = finalVector.y * modifier; + entity.motionZ = finalVector.z * modifier; + } + + @Override + public boolean usesMana(ItemStack stack) { + return true; + } + + public static void leftClick(EntityPlayer player) { + ItemStack stack = player.getHeldItem(); + if(stack != null && stack.getItem() == ModItems.gravityRod) { + int targetID = ItemNBTHelper.getInt(stack, TAG_TARGET, -1); + ItemNBTHelper.getDouble(stack, TAG_DIST, -1); + Entity item = null; + + if(targetID != -1 && player.worldObj.getEntityByID(targetID) != null) { + Entity taritem = player.worldObj.getEntityByID(targetID); + + boolean found = false; + Vector3 target = Vector3.fromEntityCenter(player); + List entities = new ArrayList(); + int distance = 1; + while(entities.size() == 0 && distance < 25) { + target.add(new Vector3(player.getLookVec()).multiply(distance)); + + target.y += 0.5; + entities = player.worldObj.getEntitiesWithinAABBExcludingEntity(player, AxisAlignedBB.getBoundingBox(target.x - RANGE, target.y - RANGE, target.z - RANGE, target.x + RANGE, target.y + RANGE, target.z + RANGE)); + distance++; + if(entities.contains(taritem)) + found = true; + } + + if(found) { + item = player.worldObj.getEntityByID(targetID); + ItemNBTHelper.setInt(stack, TAG_TARGET, -1); + ItemNBTHelper.setDouble(stack, TAG_DIST, -1); + Vector3 moveVector = new Vector3(player.getLookVec().normalize()); + if(item instanceof EntityItem) { + ((EntityItem)item).delayBeforeCanPickup = 20; + float mot = IManaProficiencyArmor.Helper.hasProficiency(player) ? 2.25F : 1.5F; + item.motionX = moveVector.x * mot; + item.motionY = moveVector.y; + item.motionZ = moveVector.z * mot; + if(!player.worldObj.isRemote) { + EntityThrownItem thrown = new EntityThrownItem(item.worldObj, item.posX, item.posY, item.posZ, (EntityItem) item); + item.worldObj.spawnEntityInWorld(thrown); + } + item.setDead(); + } else { + item.motionX = moveVector.x * 3.0F; + item.motionY = moveVector.y * 1.5F; + item.motionZ = moveVector.z * 3.0F; + } + ItemNBTHelper.setInt(stack, TAG_TICKS_COOLDOWN, 10); + } + } + } + } +} \ No newline at end of file diff --git a/src/main/java/vazkii/botania/common/item/rod/ItemMissileRod.java b/src/main/java/vazkii/botania/common/item/rod/ItemMissileRod.java index f156951792..fd694ffdae 100644 --- a/src/main/java/vazkii/botania/common/item/rod/ItemMissileRod.java +++ b/src/main/java/vazkii/botania/common/item/rod/ItemMissileRod.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Nov 24, 2014, 5:58:16 PM (GMT)] */ package vazkii.botania.common.item.rod; @@ -30,96 +30,85 @@ public class ItemMissileRod extends ItemMod implements IManaUsingItem, IAvatarWieldable { - private static final ResourceLocation avatarOverlay = new ResourceLocation(LibResources.MODEL_AVATAR_MISSILE); - - private static final int COST_PER = 120; - private static final int COST_AVATAR = 40; - - public ItemMissileRod() { - super(); - setMaxStackSize(1); - setUnlocalizedName(LibItemNames.MISSILE_ROD); - } - - @Override - public EnumAction getItemUseAction(ItemStack par1ItemStack) { - return EnumAction.bow; - } - - @Override - public int getMaxItemUseDuration(ItemStack par1ItemStack) { - return 72000; - } - - @Override - public void onUsingTick(ItemStack stack, EntityPlayer player, int count) { - if (count != getMaxItemUseDuration(stack) - && count % (IManaProficiencyArmor.Helper.hasProficiency(player) ? 1 : 2) == 0 - && !player.worldObj.isRemote - && ManaItemHandler.requestManaExactForTool(stack, player, COST_PER, false)) { - if (spawnMissile( - player.worldObj, - player, - player.posX + (Math.random() - 0.5 * 0.1), - player.posY + 2.4 + (Math.random() - 0.5 * 0.1), - player.posZ + (Math.random() - 0.5 * 0.1))) - ManaItemHandler.requestManaExactForTool(stack, player, COST_PER, true); - - Botania.proxy.sparkleFX(player.worldObj, player.posX, player.posY + 2.4, player.posZ, 1F, 0.4F, 1F, 6F, 6); - } - } - - public boolean spawnMissile(World world, EntityLivingBase thrower, double x, double y, double z) { - EntityMagicMissile missile; - if (thrower != null) missile = new EntityMagicMissile(thrower, false); - else missile = new EntityMagicMissile(world); - - missile.setPosition(x, y, z); - if (missile.getTarget()) { - if (!world.isRemote) { - world.playSoundEffect(x, y, z, "botania:missile", 0.6F, 0.8F + (float) Math.random() * 0.2F); - world.spawnEntityInWorld(missile); - } - - return true; - } - return false; - } - - @Override - public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer) { - par3EntityPlayer.setItemInUse(par1ItemStack, getMaxItemUseDuration(par1ItemStack)); - return par1ItemStack; - } - - @Override - public boolean isFull3D() { - return true; - } - - @Override - public boolean usesMana(ItemStack stack) { - return true; - } - - @Override - public void onAvatarUpdate(IAvatarTile tile, ItemStack stack) { - TileEntity te = (TileEntity) tile; - World world = te.getWorldObj(); - if (tile.getCurrentMana() >= COST_AVATAR && tile.getElapsedFunctionalTicks() % 3 == 0 && tile.isEnabled()) - if (spawnMissile( - world, - null, - te.xCoord + 0.5 + (Math.random() - 0.5 * 0.1), - te.yCoord + 2.5 + (Math.random() - 0.5 * 0.1), - te.zCoord + (Math.random() - 0.5 * 0.1))) { - if (!world.isRemote) tile.recieveMana(-COST_AVATAR); - Botania.proxy.sparkleFX(world, te.xCoord + 0.5, te.yCoord + 2.5, te.zCoord + 0.5, 1F, 0.4F, 1F, 6F, 6); - } - } - - @Override - public ResourceLocation getOverlayResource(IAvatarTile tile, ItemStack stack) { - return avatarOverlay; - } + private static final ResourceLocation avatarOverlay = new ResourceLocation(LibResources.MODEL_AVATAR_MISSILE); + + private static final int COST_PER = 120; + private static final int COST_AVATAR = 40; + + public ItemMissileRod() { + super(); + setMaxStackSize(1); + setUnlocalizedName(LibItemNames.MISSILE_ROD); + } + + @Override + public EnumAction getItemUseAction(ItemStack par1ItemStack) { + return EnumAction.bow; + } + + @Override + public int getMaxItemUseDuration(ItemStack par1ItemStack) { + return 72000; + } + + @Override + public void onUsingTick(ItemStack stack, EntityPlayer player, int count) { + if(count != getMaxItemUseDuration(stack) && count % (IManaProficiencyArmor.Helper.hasProficiency(player) ? 1 : 2) == 0 && !player.worldObj.isRemote && ManaItemHandler.requestManaExactForTool(stack, player, COST_PER, false)) { + if(spawnMissile(player.worldObj, player, player.posX + (Math.random() - 0.5 * 0.1), player.posY + 2.4 + (Math.random() - 0.5 * 0.1), player.posZ + (Math.random() - 0.5 * 0.1))) + ManaItemHandler.requestManaExactForTool(stack, player, COST_PER, true); + + Botania.proxy.sparkleFX(player.worldObj, player.posX, player.posY + 2.4, player.posZ, 1F, 0.4F, 1F, 6F, 6); + } + } + + public boolean spawnMissile(World world, EntityLivingBase thrower, double x, double y, double z) { + EntityMagicMissile missile; + if(thrower != null) + missile = new EntityMagicMissile(thrower, false); + else missile = new EntityMagicMissile(world); + + missile.setPosition(x, y, z); + if(missile.getTarget()) { + if(!world.isRemote) { + world.playSoundEffect(x, y, z, "botania:missile", 0.6F, 0.8F + (float) Math.random() * 0.2F); + world.spawnEntityInWorld(missile); + } + + return true; + } + return false; + } + + @Override + public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer) { + par3EntityPlayer.setItemInUse(par1ItemStack, getMaxItemUseDuration(par1ItemStack)); + return par1ItemStack; + } + + @Override + public boolean isFull3D() { + return true; + } + + @Override + public boolean usesMana(ItemStack stack) { + return true; + } + + @Override + public void onAvatarUpdate(IAvatarTile tile, ItemStack stack) { + TileEntity te = (TileEntity) tile; + World world = te.getWorldObj(); + if(tile.getCurrentMana() >= COST_AVATAR && tile.getElapsedFunctionalTicks() % 3 == 0 && tile.isEnabled()) + if(spawnMissile(world, null, te.xCoord + 0.5 + (Math.random() - 0.5 * 0.1), te.yCoord + 2.5 + (Math.random() - 0.5 * 0.1), te.zCoord + (Math.random() - 0.5 * 0.1))) { + if(!world.isRemote) + tile.recieveMana(-COST_AVATAR); + Botania.proxy.sparkleFX(world, te.xCoord + 0.5, te.yCoord + 2.5, te.zCoord + 0.5, 1F, 0.4F, 1F, 6F, 6); + } + } + + @Override + public ResourceLocation getOverlayResource(IAvatarTile tile, ItemStack stack) { + return avatarOverlay; + } } diff --git a/src/main/java/vazkii/botania/common/item/rod/ItemRainbowRod.java b/src/main/java/vazkii/botania/common/item/rod/ItemRainbowRod.java index 07bb605c70..2c2ae87aaa 100644 --- a/src/main/java/vazkii/botania/common/item/rod/ItemRainbowRod.java +++ b/src/main/java/vazkii/botania/common/item/rod/ItemRainbowRod.java @@ -2,15 +2,16 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jun 20, 2014, 7:09:51 PM (GMT)] */ package vazkii.botania.common.item.rod; import java.util.List; + import net.minecraft.block.Block; import net.minecraft.entity.Entity; import net.minecraft.entity.player.EntityPlayer; @@ -36,182 +37,172 @@ public class ItemRainbowRod extends ItemMod implements IManaUsingItem, IAvatarWieldable { - private static final ResourceLocation avatarOverlay = new ResourceLocation(LibResources.MODEL_AVATAR_RAINBOW); - - private static final int MANA_COST = 750; - private static final int MANA_COST_AVATAR = 10; - private static final int TIME = 600; - - public ItemRainbowRod() { - setMaxDamage(TIME); - setUnlocalizedName(LibItemNames.RAINBOW_ROD); - setMaxStackSize(1); - } - - @Override - public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer) { - if (!par2World.isRemote - && par1ItemStack.getItemDamage() == 0 - && ManaItemHandler.requestManaExactForTool(par1ItemStack, par3EntityPlayer, MANA_COST, false)) { - Block place = ModBlocks.bifrost; - Vector3 vector = new Vector3(par3EntityPlayer.getLookVec()).normalize(); - - double x = par3EntityPlayer.posX; - double y = par3EntityPlayer.posY; - double z = par3EntityPlayer.posZ; - - double lx = 0; - double ly = -1; - double lz = 0; - - int count = 0; - boolean prof = IManaProficiencyArmor.Helper.hasProficiency(par3EntityPlayer); - int maxlen = prof ? 160 : 100; - int time = prof ? (int) (TIME * 1.6) : TIME; - - while (count < maxlen && (int) lx == (int) x && (int) ly == (int) y && (int) lz == (int) z - || count < 4 - || par2World.getBlock((int) x, (int) y, (int) z).isAir(par2World, (int) x, (int) y, (int) z) - || par2World.getBlock((int) x, (int) y, (int) z) == place) { - if (y >= 256 || y <= 0) break; - - for (int i = -2; i < 1; i++) - for (int j = -2; j < 1; j++) - if (par2World - .getBlock((int) x + i, (int) y, (int) z + j) - .isAir(par2World, (int) x + i, (int) y, (int) z + j) - || par2World.getBlock((int) x + i, (int) y, (int) z + j) == place) { - par2World.setBlock((int) x + i, (int) y, (int) z + j, place); - TileBifrost tile = (TileBifrost) par2World.getTileEntity((int) x + i, (int) y, (int) z + j); - if (tile != null) { - for (int k = 0; k < 4; k++) - Botania.proxy.sparkleFX( - par2World, - tile.xCoord + Math.random(), - tile.yCoord + Math.random(), - tile.zCoord + Math.random(), - (float) Math.random(), - (float) Math.random(), - (float) Math.random(), - 0.45F + 0.2F * (float) Math.random(), - 6); - tile.ticks = time; - } - } - - lx = x; - ly = y; - lz = z; - - x += vector.x; - y += vector.y; - z += vector.z; - count++; - } - - if (count > 0) { - par2World.playSoundAtEntity(par3EntityPlayer, "botania:bifrostRod", 0.5F, 0.25F); - ManaItemHandler.requestManaExactForTool(par1ItemStack, par3EntityPlayer, MANA_COST, false); - par1ItemStack.setItemDamage(TIME); - } - } - - return par1ItemStack; - } - - @Override - public ItemStack getContainerItem(ItemStack itemStack) { - return itemStack.copy(); - } - - @Override - public boolean hasContainerItem(ItemStack stack) { - return getContainerItem(stack) != null; - } - - @Override - public boolean doesContainerItemLeaveCraftingGrid(ItemStack par1ItemStack) { - return false; - } - - @Override - public void onUpdate(ItemStack par1ItemStack, World par2World, Entity par3Entity, int par4, boolean par5) { - if (par1ItemStack.isItemDamaged()) par1ItemStack.setItemDamage(par1ItemStack.getItemDamage() - 1); - } - - @Override - public boolean isFull3D() { - return true; - } - - @Override - public boolean usesMana(ItemStack stack) { - return true; - } - - @Override - public void onAvatarUpdate(IAvatarTile tile, ItemStack stack) { - TileEntity te = (TileEntity) tile; - World world = te.getWorldObj(); - - if (world.isRemote || tile.getCurrentMana() < MANA_COST_AVATAR * 25 || !tile.isEnabled()) return; - - int x = te.xCoord; - int y = te.yCoord; - int z = te.zCoord; - int w = 1; - int h = 1; - int l = 20; - - AxisAlignedBB axis = null; - switch (te.getBlockMetadata() - 2) { - case 0: - axis = AxisAlignedBB.getBoundingBox(x - w, y - h, z - l, x + w + 1, y + h, z); - break; - case 1: - axis = AxisAlignedBB.getBoundingBox(x - w, y - h, z + 1, x + w + 1, y + h, z + l + 1); - break; - case 2: - axis = AxisAlignedBB.getBoundingBox(x - l, y - h, z - w, x, y + h, z + w + 1); - break; - case 3: - axis = AxisAlignedBB.getBoundingBox(x + 1, y - h, z - w, x + l + 1, y + h, z + w + 1); - } - - List players = world.getEntitiesWithinAABB(EntityPlayer.class, axis); - for (EntityPlayer p : players) { - int px = MathHelper.floor_double(p.posX); - int py = MathHelper.floor_double(p.posY) - 1; - int pz = MathHelper.floor_double(p.posZ); - int dist = 5; - int diff = dist / 2; - - for (int i = 0; i < dist; i++) - for (int j = 0; j < dist; j++) { - int ex = px + i - diff; - int ez = pz + j - diff; - - if (!axis.isVecInside(Vec3.createVectorHelper(ex + 0.5, py + 1, ez + 0.5))) continue; - - Block block = world.getBlock(ex, py, ez); - if (block.isAir(world, ex, py, ez)) { - world.setBlock(ex, py, ez, ModBlocks.bifrost); - TileBifrost tileBifrost = (TileBifrost) world.getTileEntity(ex, py, ez); - tileBifrost.ticks = 10; - tile.recieveMana(-MANA_COST_AVATAR); - } else if (block == ModBlocks.bifrost) { - TileBifrost tileBifrost = (TileBifrost) world.getTileEntity(ex, py, ez); - if (tileBifrost.ticks < 2) { - tileBifrost.ticks = 10; - tile.recieveMana(-MANA_COST_AVATAR); - } - } - } - } - } - - @Override - public ResourceLocation getOverlayResource(IAvatarTile tile, ItemStack stack) { - return avatarOverlay; - } + private static final ResourceLocation avatarOverlay = new ResourceLocation(LibResources.MODEL_AVATAR_RAINBOW); + + private static final int MANA_COST = 750; + private static final int MANA_COST_AVATAR = 10; + private static final int TIME = 600; + + public ItemRainbowRod() { + setMaxDamage(TIME); + setUnlocalizedName(LibItemNames.RAINBOW_ROD); + setMaxStackSize(1); + } + + @Override + public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer) { + if(!par2World.isRemote && par1ItemStack.getItemDamage() == 0 && ManaItemHandler.requestManaExactForTool(par1ItemStack, par3EntityPlayer, MANA_COST, false)) { + Block place = ModBlocks.bifrost; + Vector3 vector = new Vector3(par3EntityPlayer.getLookVec()).normalize(); + + double x = par3EntityPlayer.posX; + double y = par3EntityPlayer.posY; + double z = par3EntityPlayer.posZ; + + double lx = 0; + double ly = -1; + double lz = 0; + + int count = 0; + boolean prof = IManaProficiencyArmor.Helper.hasProficiency(par3EntityPlayer); + int maxlen = prof ? 160 : 100; + int time = prof ? (int) (TIME * 1.6) : TIME; + + while(count < maxlen && (int) lx == (int) x && (int) ly == (int) y && (int) lz == (int) z || count < 4 || par2World.getBlock((int) x, (int) y, (int) z).isAir(par2World, (int) x, (int) y, (int) z) || par2World.getBlock((int) x, (int) y, (int) z) == place) { + if(y >= 256 || y <= 0) + break; + + for(int i = -2; i < 1; i++) + for(int j = -2; j < 1; j++) + if(par2World.getBlock((int) x + i, (int) y, (int) z + j).isAir(par2World, (int) x + i, (int) y, (int) z + j) || par2World.getBlock((int) x + i, (int) y, (int) z + j) == place) { + par2World.setBlock((int) x + i, (int) y, (int) z + j, place); + TileBifrost tile = (TileBifrost) par2World.getTileEntity((int) x + i, (int) y, (int) z + j); + if(tile != null) { + for(int k = 0; k < 4; k++) + Botania.proxy.sparkleFX(par2World, tile.xCoord + Math.random(), tile.yCoord + Math.random(), tile.zCoord + Math.random(), (float) Math.random(), (float) Math.random(), (float) Math.random(), 0.45F + 0.2F * (float) Math.random(), 6); + tile.ticks = time; + } + } + + lx = x; + ly = y; + lz = z; + + x += vector.x; + y += vector.y; + z += vector.z; + count++; + } + + if(count > 0) { + par2World.playSoundAtEntity(par3EntityPlayer, "botania:bifrostRod", 0.5F, 0.25F); + ManaItemHandler.requestManaExactForTool(par1ItemStack, par3EntityPlayer, MANA_COST, false); + par1ItemStack.setItemDamage(TIME); + } + } + + return par1ItemStack; + } + + @Override + public ItemStack getContainerItem(ItemStack itemStack) { + return itemStack.copy(); + } + + @Override + public boolean hasContainerItem(ItemStack stack) { + return getContainerItem(stack) != null; + } + + @Override + public boolean doesContainerItemLeaveCraftingGrid(ItemStack par1ItemStack) { + return false; + } + + @Override + public void onUpdate(ItemStack par1ItemStack, World par2World, Entity par3Entity, int par4, boolean par5) { + if(par1ItemStack.isItemDamaged()) + par1ItemStack.setItemDamage(par1ItemStack.getItemDamage() - 1); + } + + @Override + public boolean isFull3D() { + return true; + } + + @Override + public boolean usesMana(ItemStack stack) { + return true; + } + + @Override + public void onAvatarUpdate(IAvatarTile tile, ItemStack stack) { + TileEntity te = (TileEntity) tile; + World world = te.getWorldObj(); + + if(world.isRemote || tile.getCurrentMana() < MANA_COST_AVATAR * 25 || !tile.isEnabled()) + return; + + int x = te.xCoord; + int y = te.yCoord; + int z = te.zCoord; + int w = 1; + int h = 1; + int l = 20; + + AxisAlignedBB axis = null; + switch(te.getBlockMetadata() - 2) { + case 0 : + axis = AxisAlignedBB.getBoundingBox(x - w, y - h, z - l, x + w + 1, y + h, z); + break; + case 1 : + axis = AxisAlignedBB.getBoundingBox(x - w, y - h, z + 1, x + w + 1, y + h, z + l + 1); + break; + case 2 : + axis = AxisAlignedBB.getBoundingBox(x - l, y - h, z - w, x, y + h, z + w + 1); + break; + case 3 : + axis = AxisAlignedBB.getBoundingBox(x + 1, y - h, z - w, x + l + 1, y + h, z + w + 1); + } + + List players = world.getEntitiesWithinAABB(EntityPlayer.class, axis); + for(EntityPlayer p : players) { + int px = MathHelper.floor_double(p.posX); + int py = MathHelper.floor_double(p.posY) - 1; + int pz = MathHelper.floor_double(p.posZ); + int dist = 5; + int diff = dist / 2; + + for(int i = 0; i < dist; i++) + for(int j = 0; j < dist; j++) { + int ex = px + i - diff; + int ez = pz + j - diff; + + if(!axis.isVecInside(Vec3.createVectorHelper(ex + 0.5, py + 1, ez + 0.5))) + continue; + + Block block = world.getBlock(ex, py, ez); + if(block.isAir(world, ex, py, ez)) { + world.setBlock(ex, py, ez, ModBlocks.bifrost); + TileBifrost tileBifrost = (TileBifrost) world.getTileEntity(ex, py, ez); + tileBifrost.ticks = 10; + tile.recieveMana(-MANA_COST_AVATAR); + } else if(block == ModBlocks.bifrost) { + TileBifrost tileBifrost = (TileBifrost) world.getTileEntity(ex, py, ez); + if(tileBifrost.ticks < 2) { + tileBifrost.ticks = 10; + tile.recieveMana(-MANA_COST_AVATAR); + } + } + } + } + + + } + + @Override + public ResourceLocation getOverlayResource(IAvatarTile tile, ItemStack stack) { + return avatarOverlay; + } + } diff --git a/src/main/java/vazkii/botania/common/item/rod/ItemSkyDirtRod.java b/src/main/java/vazkii/botania/common/item/rod/ItemSkyDirtRod.java index d99c4a41f5..81b3909919 100644 --- a/src/main/java/vazkii/botania/common/item/rod/ItemSkyDirtRod.java +++ b/src/main/java/vazkii/botania/common/item/rod/ItemSkyDirtRod.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jul 23, 2014, 1:06:51 AM (GMT)] */ package vazkii.botania.common.item.rod; @@ -24,47 +24,38 @@ public class ItemSkyDirtRod extends ItemDirtRod { - public ItemSkyDirtRod() { - super(LibItemNames.SKY_DIRT_ROD); - } + public ItemSkyDirtRod() { + super(LibItemNames.SKY_DIRT_ROD); + } - @Override - public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer player) { - if (!world.isRemote && ManaItemHandler.requestManaExactForTool(stack, player, COST * 2, false)) { - Vector3 playerVec = Vector3.fromEntityCenter(player); - Vector3 lookVec = new Vector3(player.getLookVec()).multiply(3); - Vector3 placeVec = playerVec.copy().add(lookVec); + @Override + public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer player) { + if(!world.isRemote && ManaItemHandler.requestManaExactForTool(stack, player, COST * 2, false)) { + Vector3 playerVec = Vector3.fromEntityCenter(player); + Vector3 lookVec = new Vector3(player.getLookVec()).multiply(3); + Vector3 placeVec = playerVec.copy().add(lookVec); - int x = MathHelper.floor_double(placeVec.x); - int y = MathHelper.floor_double(placeVec.y) + 1; - int z = MathHelper.floor_double(placeVec.z); + int x = MathHelper.floor_double(placeVec.x); + int y = MathHelper.floor_double(placeVec.y) + 1; + int z = MathHelper.floor_double(placeVec.z); - int entities = world.getEntitiesWithinAABB( - EntityLivingBase.class, AxisAlignedBB.getBoundingBox(x, y, z, x + 1, y + 1, z + 1)) - .size(); + int entities = world.getEntitiesWithinAABB(EntityLivingBase.class, AxisAlignedBB.getBoundingBox(x, y, z, x + 1, y + 1, z + 1)).size(); - if (entities == 0) { - ItemStack stackToPlace = new ItemStack(Blocks.dirt); - stackToPlace.tryPlaceItemIntoWorld(player, world, x, y, z, 0, 0F, 0F, 0F); + if(entities == 0) { + ItemStack stackToPlace = new ItemStack(Blocks.dirt); + stackToPlace.tryPlaceItemIntoWorld(player, world, x, y, z, 0, 0F, 0F, 0F); - if (stackToPlace.stackSize == 0) { - ManaItemHandler.requestManaExactForTool(stack, player, COST * 2, true); - for (int i = 0; i < 6; i++) - Botania.proxy.sparkleFX( - world, - x + Math.random(), - y + Math.random(), - z + Math.random(), - 0.35F, - 0.2F, - 0.05F, - 1F, - 5); - } - } - } - if (world.isRemote) player.swingItem(); + if(stackToPlace.stackSize == 0) { + ManaItemHandler.requestManaExactForTool(stack, player, COST * 2, true); + for(int i = 0; i < 6; i++) + Botania.proxy.sparkleFX(world, x + Math.random(), y + Math.random(), z + Math.random(), 0.35F, 0.2F, 0.05F, 1F, 5); + } + } + } + if(world.isRemote) + player.swingItem(); + + return stack; + } - return stack; - } } diff --git a/src/main/java/vazkii/botania/common/item/rod/ItemSmeltRod.java b/src/main/java/vazkii/botania/common/item/rod/ItemSmeltRod.java index 415113ac27..6a72d46712 100644 --- a/src/main/java/vazkii/botania/common/item/rod/ItemSmeltRod.java +++ b/src/main/java/vazkii/botania/common/item/rod/ItemSmeltRod.java @@ -2,16 +2,17 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jan 24, 2015, 11:05:41 PM (GMT)] */ package vazkii.botania.common.item.rod; import java.util.Map; import java.util.WeakHashMap; + import net.minecraft.block.Block; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.EnumAction; @@ -30,124 +31,115 @@ public class ItemSmeltRod extends ItemMod implements IManaUsingItem { - private static final int TIME = 10; - private static final int COST = 300; - private static final int COST_PER_TICK = COST / TIME; - - public static Map playerData = new WeakHashMap(); - - public ItemSmeltRod() { - setUnlocalizedName(LibItemNames.SMELT_ROD); - setMaxStackSize(1); - } - - @Override - public EnumAction getItemUseAction(ItemStack par1ItemStack) { - return EnumAction.bow; - } - - @Override - public int getMaxItemUseDuration(ItemStack par1ItemStack) { - return 72000; - } - - @Override - public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer) { - par3EntityPlayer.setItemInUse(par1ItemStack, getMaxItemUseDuration(par1ItemStack)); - return par1ItemStack; - } - - @Override - public void onUsingTick(ItemStack stack, EntityPlayer p, int time) { - if (!ManaItemHandler.requestManaExactForTool(stack, p, COST_PER_TICK, false)) return; - - MovingObjectPosition pos = ToolCommons.raytraceFromEntity(p.worldObj, p, false, 32); - - if (pos != null) { - Block block = p.worldObj.getBlock(pos.blockX, pos.blockY, pos.blockZ); - int meta = p.worldObj.getBlockMetadata(pos.blockX, pos.blockY, pos.blockZ); - - ItemStack blockStack = new ItemStack(block, 1, meta); - ItemStack result = FurnaceRecipes.smelting().getSmeltingResult(blockStack); - - if (result != null && result.getItem() instanceof ItemBlock) { - boolean decremented = false; - - if (playerData.containsKey(p)) { - SmeltData data = playerData.get(p); - - if (data.equalPos(pos)) { - data.progress--; - decremented = true; - if (data.progress <= 0) { - if (!p.worldObj.isRemote) { - p.worldObj.setBlock( - pos.blockX, - pos.blockY, - pos.blockZ, - Block.getBlockFromItem(result.getItem()), - result.getItemDamage(), - 1 | 2); - p.worldObj.playSoundAtEntity(p, "fire.ignite", 0.6F, 1F); - p.worldObj.playSoundAtEntity(p, "fire.fire", 1F, 1F); - - ManaItemHandler.requestManaExactForTool(stack, p, COST_PER_TICK, true); - playerData.remove(p.getGameProfile().getName()); - decremented = false; - } - - for (int i = 0; i < 25; i++) { - double x = pos.blockX + Math.random(); - double y = pos.blockY + Math.random(); - double z = pos.blockZ + Math.random(); - - Botania.proxy.wispFX( - p.worldObj, x, y, z, 1F, 0.2F, 0.2F, 0.5F, (float) -Math.random() / 10F); - } - } - } - } - - if (!decremented) - playerData.put( - p, - new SmeltData( - pos, IManaProficiencyArmor.Helper.hasProficiency(p) ? (int) (TIME * 0.6) : TIME)); - else { - for (int i = 0; i < 2; i++) { - double x = pos.blockX + Math.random(); - double y = pos.blockY + Math.random(); - double z = pos.blockZ + Math.random(); - Botania.proxy.wispFX(p.worldObj, x, y, z, 1F, 0.2F, 0.2F, 0.5F, (float) -Math.random() / 10F); - } - if (time % 10 == 0) - p.worldObj.playSoundAtEntity(p, "fire.fire", (float) Math.random() / 2F + 0.5F, 1F); - } - } - } - } - - @Override - public boolean isFull3D() { - return true; - } - - @Override - public boolean usesMana(ItemStack stack) { - return true; - } - - static class SmeltData { - public MovingObjectPosition pos; - public int progress; - - public SmeltData(MovingObjectPosition pos, int progress) { - this.pos = pos; - this.progress = progress; - } - - public boolean equalPos(MovingObjectPosition pos) { - return pos.blockX == this.pos.blockX && pos.blockY == this.pos.blockY && pos.blockZ == this.pos.blockZ; - } - } + private static final int TIME = 10; + private static final int COST = 300; + private static final int COST_PER_TICK = COST / TIME; + + public static Map playerData = new WeakHashMap(); + + public ItemSmeltRod() { + setUnlocalizedName(LibItemNames.SMELT_ROD); + setMaxStackSize(1); + } + + @Override + public EnumAction getItemUseAction(ItemStack par1ItemStack) { + return EnumAction.bow; + } + + @Override + public int getMaxItemUseDuration(ItemStack par1ItemStack) { + return 72000; + } + + @Override + public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer) { + par3EntityPlayer.setItemInUse(par1ItemStack, getMaxItemUseDuration(par1ItemStack)); + return par1ItemStack; + } + + @Override + public void onUsingTick(ItemStack stack, EntityPlayer p, int time) { + if(!ManaItemHandler.requestManaExactForTool(stack, p, COST_PER_TICK, false)) + return; + + MovingObjectPosition pos = ToolCommons.raytraceFromEntity(p.worldObj, p, false, 32); + + if(pos != null) { + Block block = p.worldObj.getBlock(pos.blockX, pos.blockY, pos.blockZ); + int meta = p.worldObj.getBlockMetadata(pos.blockX, pos.blockY, pos.blockZ); + + ItemStack blockStack = new ItemStack(block, 1, meta); + ItemStack result = FurnaceRecipes.smelting().getSmeltingResult(blockStack); + + if(result != null && result.getItem() instanceof ItemBlock) { + boolean decremented = false; + + if(playerData.containsKey(p)) { + SmeltData data = playerData.get(p); + + if(data.equalPos(pos)) { + data.progress--; + decremented = true; + if(data.progress <= 0) { + if(!p.worldObj.isRemote) { + p.worldObj.setBlock(pos.blockX, pos.blockY, pos.blockZ, Block.getBlockFromItem(result.getItem()), result.getItemDamage(), 1 | 2); + p.worldObj.playSoundAtEntity(p, "fire.ignite", 0.6F, 1F); + p.worldObj.playSoundAtEntity(p, "fire.fire", 1F, 1F); + + ManaItemHandler.requestManaExactForTool(stack, p, COST_PER_TICK, true); + playerData.remove(p.getGameProfile().getName()); + decremented = false; + } + + for(int i = 0; i < 25; i++) { + double x = pos.blockX + Math.random(); + double y = pos.blockY + Math.random(); + double z = pos.blockZ + Math.random(); + + Botania.proxy.wispFX(p.worldObj, x, y, z, 1F, 0.2F, 0.2F, 0.5F, (float) -Math.random() / 10F); + } + } + } + } + + if(!decremented) + playerData.put(p, new SmeltData(pos, IManaProficiencyArmor.Helper.hasProficiency(p) ? (int) (TIME * 0.6) : TIME)); + else { + for(int i = 0; i < 2; i++) { + double x = pos.blockX + Math.random(); + double y = pos.blockY + Math.random(); + double z = pos.blockZ + Math.random(); + Botania.proxy.wispFX(p.worldObj, x, y, z, 1F, 0.2F, 0.2F, 0.5F, (float) -Math.random() / 10F); + } + if(time % 10 == 0) + p.worldObj.playSoundAtEntity(p, "fire.fire", (float) Math.random() / 2F + 0.5F, 1F); + } + } + } + } + + @Override + public boolean isFull3D() { + return true; + } + + @Override + public boolean usesMana(ItemStack stack) { + return true; + } + + static class SmeltData { + public MovingObjectPosition pos; + public int progress; + + public SmeltData(MovingObjectPosition pos, int progress) { + this.pos = pos; + this.progress = progress; + } + + public boolean equalPos(MovingObjectPosition pos) { + return pos.blockX == this.pos.blockX && pos.blockY == this.pos.blockY && pos.blockZ == this.pos.blockZ; + } + } } diff --git a/src/main/java/vazkii/botania/common/item/rod/ItemTerraformRod.java b/src/main/java/vazkii/botania/common/item/rod/ItemTerraformRod.java index 494b5a1779..c9e90d09d1 100644 --- a/src/main/java/vazkii/botania/common/item/rod/ItemTerraformRod.java +++ b/src/main/java/vazkii/botania/common/item/rod/ItemTerraformRod.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Apr 11, 2014, 2:56:39 PM (GMT)] */ package vazkii.botania.common.item.rod; @@ -13,6 +13,7 @@ import java.util.ArrayList; import java.util.Arrays; import java.util.List; + import net.minecraft.block.Block; import net.minecraft.block.BlockFlower; import net.minecraft.entity.player.EntityPlayer; @@ -37,186 +38,177 @@ import vazkii.botania.common.lib.LibItemNames; import vazkii.botania.common.lib.LibMisc; -public class ItemTerraformRod extends ItemMod implements IManaUsingItem, IBlockProvider, ICraftAchievement { - - private static final int COST_PER = 55; - - static final List validBlocks = Arrays.asList(new String[] { - "stone", - "dirt", - "grass", - "sand", - "gravel", - "hardenedClay", - "snowLayer", - "mycelium", - "podzol", - "sandstone", - - // Mod support - "blockDiorite", - "stoneDiorite", - "blockGranite", - "stoneGranite", - "blockAndesite", - "stoneAndesite", - "marble", - "blockMarble", - "limestone", - "blockLimestone" - }); - - public ItemTerraformRod() { - super(); - setMaxStackSize(1); - setUnlocalizedName(LibItemNames.TERRAFORM_ROD); - } - - @Override - public EnumAction getItemUseAction(ItemStack par1ItemStack) { - return EnumAction.bow; - } - - @Override - public int getMaxItemUseDuration(ItemStack par1ItemStack) { - return 72000; - } - - @Override - public void onUsingTick(ItemStack stack, EntityPlayer player, int count) { - if (count != getMaxItemUseDuration(stack) && count % 10 == 0) terraform(stack, player.worldObj, player); - } - - @Override - public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer) { - par3EntityPlayer.setItemInUse(par1ItemStack, getMaxItemUseDuration(par1ItemStack)); - return par1ItemStack; - } - - public void terraform(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer) { - int range = IManaProficiencyArmor.Helper.hasProficiency(par3EntityPlayer) ? 22 : 16; - - int xCenter = (int) par3EntityPlayer.posX; - int yCenter = (int) par3EntityPlayer.posY - (par2World.isRemote ? 2 : 1); - int zCenter = (int) par3EntityPlayer.posZ; - - if (yCenter < 62) // Not below sea level - return; - - int yStart = yCenter + range; - - List blocks = new ArrayList(); - - for (int i = -range; i < range + 1; i++) - for (int j = -range; j < range + 1; j++) { - int k = 0; - while (true) { - if (yStart + k < 0) break; - - int x = xCenter + i; - int y = yStart + k; - int z = zCenter + j; - - Block block = par2World.getBlock(x, y, z); - int meta = par2World.getBlockMetadata(x, y, z); - - int[] ids = OreDictionary.getOreIDs(new ItemStack(block, 1, meta)); - for (int id : ids) - if (validBlocks.contains(OreDictionary.getOreName(id))) { - boolean hasAir = false; - List airBlocks = new ArrayList(); - - for (ForgeDirection dir : LibMisc.CARDINAL_DIRECTIONS) { - int x_ = x + dir.offsetX; - int y_ = y + dir.offsetY; - int z_ = z + dir.offsetZ; - - Block block_ = par2World.getBlock(x_, y_, z_); - if (block_.isAir(par2World, x_, y_, z_) - || block_.isReplaceable(par2World, x_, y_, z_) - || block_ instanceof BlockFlower && !(block_ instanceof ISpecialFlower) - || block_ == Blocks.double_plant) { - airBlocks.add(new ChunkCoordinates(x_, y_, z_)); - hasAir = true; - } - } - - if (hasAir) { - if (y > yCenter) blocks.add(new CoordsWithBlock(x, y, z, Blocks.air)); - else - for (ChunkCoordinates coords : airBlocks) { - if (par2World.getBlock(coords.posX, coords.posY - 1, coords.posZ) != Blocks.air) - blocks.add(new CoordsWithBlock( - coords.posX, coords.posY, coords.posZ, Blocks.dirt)); - } - } - break; - } - --k; - } - } - - int cost = COST_PER * blocks.size(); - - if (par2World.isRemote - || ManaItemHandler.requestManaExactForTool(par1ItemStack, par3EntityPlayer, cost, true)) { - if (!par2World.isRemote) - for (CoordsWithBlock block : blocks) - par2World.setBlock(block.posX, block.posY, block.posZ, block.block); - - if (!blocks.isEmpty()) { - for (int i = 0; i < 10; i++) par2World.playSoundAtEntity(par3EntityPlayer, "step.sand", 1F, 0.4F); - for (int i = 0; i < 120; i++) - Botania.proxy.sparkleFX( - par2World, - xCenter - range + range * 2 * Math.random(), - yCenter + 2 + (Math.random() - 0.5) * 2, - zCenter - range + range * 2 * Math.random(), - 0.35F, - 0.2F, - 0.05F, - 2F, - 5); - } - } - } - - @Override - public boolean isFull3D() { - return true; - } - - class CoordsWithBlock extends ChunkCoordinates { - - final Block block; - - public CoordsWithBlock(int x, int y, int z, Block block) { - super(x, y, z); - this.block = block; - } - } - - @Override - public boolean usesMana(ItemStack stack) { - return true; - } - - @Override - public boolean provideBlock( - EntityPlayer player, ItemStack requestor, ItemStack stack, Block block, int meta, boolean doit) { - if (block == Blocks.dirt && meta == 0) - return !doit || ManaItemHandler.requestManaExactForTool(requestor, player, ItemDirtRod.COST, true); - return false; - } - - @Override - public int getBlockCount(EntityPlayer player, ItemStack requestor, ItemStack stack, Block block, int meta) { - if (block == Blocks.dirt && meta == 0) return -1; - return 0; - } - - @Override - public Achievement getAchievementOnCraft(ItemStack stack, EntityPlayer player, IInventory matrix) { - return ModAchievements.terraformRodCraft; - } +public class ItemTerraformRod extends ItemMod implements IManaUsingItem, IBlockProvider, ICraftAchievement{ + + private static final int COST_PER = 55; + + static final List validBlocks = Arrays.asList(new String[] { + "stone", + "dirt", + "grass", + "sand", + "gravel", + "hardenedClay", + "snowLayer", + "mycelium", + "podzol", + "sandstone", + + // Mod support + "blockDiorite", + "stoneDiorite", + "blockGranite", + "stoneGranite", + "blockAndesite", + "stoneAndesite", + "marble", + "blockMarble", + "limestone", + "blockLimestone" + }); + + public ItemTerraformRod() { + super(); + setMaxStackSize(1); + setUnlocalizedName(LibItemNames.TERRAFORM_ROD); + } + + @Override + public EnumAction getItemUseAction(ItemStack par1ItemStack) { + return EnumAction.bow; + } + + @Override + public int getMaxItemUseDuration(ItemStack par1ItemStack) { + return 72000; + } + + @Override + public void onUsingTick(ItemStack stack, EntityPlayer player, int count) { + if(count != getMaxItemUseDuration(stack) && count % 10 == 0) + terraform(stack, player.worldObj, player); + } + + @Override + public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer) { + par3EntityPlayer.setItemInUse(par1ItemStack, getMaxItemUseDuration(par1ItemStack)); + return par1ItemStack; + } + + public void terraform(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer) { + int range = IManaProficiencyArmor.Helper.hasProficiency(par3EntityPlayer) ? 22 : 16; + + int xCenter = (int) par3EntityPlayer.posX; + int yCenter = (int) par3EntityPlayer.posY - (par2World.isRemote ? 2 : 1); + int zCenter = (int) par3EntityPlayer.posZ; + + if(yCenter < 62) // Not below sea level + return; + + int yStart = yCenter + range; + + List blocks = new ArrayList(); + + for(int i = -range; i < range + 1; i++) + for(int j = -range; j < range + 1; j++) { + int k = 0; + while(true) { + if(yStart + k < 0) + break; + + int x = xCenter + i; + int y = yStart + k; + int z = zCenter + j; + + Block block = par2World.getBlock(x, y, z); + int meta = par2World.getBlockMetadata(x, y, z); + + int[] ids = OreDictionary.getOreIDs(new ItemStack(block, 1, meta)); + for(int id : ids) + if(validBlocks.contains(OreDictionary.getOreName(id))) { + boolean hasAir = false; + List airBlocks = new ArrayList(); + + for(ForgeDirection dir : LibMisc.CARDINAL_DIRECTIONS) { + int x_ = x + dir.offsetX; + int y_ = y + dir.offsetY; + int z_ = z + dir.offsetZ; + + Block block_ = par2World.getBlock(x_, y_, z_); + if(block_.isAir(par2World, x_, y_, z_) || block_.isReplaceable(par2World, x_, y_, z_) || block_ instanceof BlockFlower && !(block_ instanceof ISpecialFlower) || block_ == Blocks.double_plant) { + airBlocks.add(new ChunkCoordinates(x_, y_, z_)); + hasAir = true; + } + } + + if(hasAir) { + if(y > yCenter) + blocks.add(new CoordsWithBlock(x, y, z, Blocks.air)); + else for(ChunkCoordinates coords : airBlocks) { + if(par2World.getBlock(coords.posX, coords.posY - 1, coords.posZ) != Blocks.air) + blocks.add(new CoordsWithBlock(coords.posX, coords.posY, coords.posZ, Blocks.dirt)); + } + } + break; + } + --k; + } + } + + int cost = COST_PER * blocks.size(); + + if(par2World.isRemote || ManaItemHandler.requestManaExactForTool(par1ItemStack, par3EntityPlayer, cost, true)) { + if(!par2World.isRemote) + for(CoordsWithBlock block : blocks) + par2World.setBlock(block.posX, block.posY, block.posZ, block.block); + + if(!blocks.isEmpty()) { + for(int i = 0; i < 10; i++) + par2World.playSoundAtEntity(par3EntityPlayer, "step.sand", 1F, 0.4F); + for(int i = 0; i < 120; i++) + Botania.proxy.sparkleFX(par2World, xCenter - range + range * 2 * Math.random(), yCenter + 2 + (Math.random() - 0.5) * 2, zCenter - range + range * 2 * Math.random(), 0.35F, 0.2F, 0.05F, 2F, 5); + } + } + } + + @Override + public boolean isFull3D() { + return true; + } + + class CoordsWithBlock extends ChunkCoordinates { + + final Block block; + + public CoordsWithBlock(int x, int y, int z, Block block) { + super(x, y, z); + this.block = block; + } + + } + + @Override + public boolean usesMana(ItemStack stack) { + return true; + } + + @Override + public boolean provideBlock(EntityPlayer player, ItemStack requestor, ItemStack stack, Block block, int meta, boolean doit) { + if(block == Blocks.dirt && meta == 0) + return !doit || ManaItemHandler.requestManaExactForTool(requestor, player, ItemDirtRod.COST, true); + return false; + } + + @Override + public int getBlockCount(EntityPlayer player, ItemStack requestor, ItemStack stack, Block block, int meta) { + if(block == Blocks.dirt && meta == 0) + return -1; + return 0; + } + + @Override + public Achievement getAchievementOnCraft(ItemStack stack, EntityPlayer player, IInventory matrix) { + return ModAchievements.terraformRodCraft; + } + } diff --git a/src/main/java/vazkii/botania/common/item/rod/ItemTornadoRod.java b/src/main/java/vazkii/botania/common/item/rod/ItemTornadoRod.java index d70ed81e15..35df27b53b 100644 --- a/src/main/java/vazkii/botania/common/item/rod/ItemTornadoRod.java +++ b/src/main/java/vazkii/botania/common/item/rod/ItemTornadoRod.java @@ -2,15 +2,16 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jun 25, 2014, 4:36:13 PM (GMT)] */ package vazkii.botania.common.item.rod; import java.util.List; + import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.entity.Entity; import net.minecraft.entity.player.EntityPlayer; @@ -37,173 +38,149 @@ public class ItemTornadoRod extends ItemMod implements IManaUsingItem, IAvatarWieldable { - private static final ResourceLocation avatarOverlay = new ResourceLocation(LibResources.MODEL_AVATAR_TORNADO); - - private static final int FLY_TIME = 20; - private static final int FALL_MULTIPLIER = 3; - private static final int MAX_DAMAGE = FLY_TIME * FALL_MULTIPLIER; - private static final int COST = 350; - - private static final String TAG_FLYING = "flying"; - - IIcon iconIdle, iconFlying; - - public ItemTornadoRod() { - setMaxDamage(MAX_DAMAGE); - setUnlocalizedName(LibItemNames.TORNADO_ROD); - setMaxStackSize(1); - } - - @Override - public void onUpdate(ItemStack par1ItemStack, World par2World, Entity par3Entity, int par4, boolean holding) { - if (par3Entity instanceof EntityPlayer) { - EntityPlayer player = (EntityPlayer) par3Entity; - player.getCurrentEquippedItem(); - boolean damaged = par1ItemStack.getItemDamage() > 0; - - if (damaged && !isFlying(par1ItemStack)) par1ItemStack.setItemDamage(par1ItemStack.getItemDamage() - 1); - - int max = FALL_MULTIPLIER * FLY_TIME; - if (par1ItemStack.getItemDamage() >= max) { - setFlying(par1ItemStack, false); - player.stopUsingItem(); - } else if (isFlying(par1ItemStack)) { - if (holding) { - player.fallDistance = 0F; - player.motionY = IManaProficiencyArmor.Helper.hasProficiency(player) ? 1.6 : 1.25; - - player.worldObj.playSoundAtEntity(player, "botania:airRod", 0.1F, 0.25F); - for (int i = 0; i < 5; i++) - Botania.proxy.wispFX( - player.worldObj, - player.posX, - player.posY, - player.posZ, - 0.25F, - 0.25F, - 0.25F, - 0.35F + (float) Math.random() * 0.1F, - 0.2F * (float) (Math.random() - 0.5), - -0.01F * (float) Math.random(), - 0.2F * (float) (Math.random() - 0.5)); - } - - par1ItemStack.setItemDamage(Math.min(max, par1ItemStack.getItemDamage() + FALL_MULTIPLIER)); - if (par1ItemStack.getItemDamage() == MAX_DAMAGE) setFlying(par1ItemStack, false); - } - - if (damaged) player.fallDistance = 0; - } - } - - @Override - public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer) { - int meta = par1ItemStack.getItemDamage(); - if (meta != 0 || ManaItemHandler.requestManaExactForTool(par1ItemStack, par3EntityPlayer, COST, false)) { - par3EntityPlayer.setItemInUse(par1ItemStack, getMaxItemUseDuration(par1ItemStack)); - if (meta == 0) { - setFlying(par1ItemStack, true); - ManaItemHandler.requestManaExactForTool(par1ItemStack, par3EntityPlayer, COST, true); - } - } - - return par1ItemStack; - } - - @Override - public void onUsingTick(ItemStack stack, EntityPlayer player, int count) {} - - @Override - public IIcon getIconIndex(ItemStack par1ItemStack) { - return isFlying(par1ItemStack) ? iconFlying : iconIdle; - } - - @Override - public IIcon getIcon(ItemStack stack, int pass) { - return getIconIndex(stack); - } - - @Override - public EnumAction getItemUseAction(ItemStack par1ItemStack) { - return EnumAction.bow; - } - - @Override - public int getMaxItemUseDuration(ItemStack par1ItemStack) { - return 720000; - } - - @Override - public void registerIcons(IIconRegister par1IconRegister) { - iconIdle = IconHelper.forItem(par1IconRegister, this, 0); - iconFlying = IconHelper.forItem(par1IconRegister, this, 1); - } - - public boolean isFlying(ItemStack stack) { - return ItemNBTHelper.getBoolean(stack, TAG_FLYING, false); - } - - public void setFlying(ItemStack stack, boolean flying) { - ItemNBTHelper.setBoolean(stack, TAG_FLYING, flying); - } - - @Override - public boolean isFull3D() { - return true; - } - - @Override - public boolean usesMana(ItemStack stack) { - return true; - } - - @Override - public void onAvatarUpdate(IAvatarTile tile, ItemStack stack) { - TileEntity te = (TileEntity) tile; - World world = te.getWorldObj(); - if (tile.getCurrentMana() >= COST && tile.isEnabled()) { - int range = 5; - int rangeY = 3; - List players = world.getEntitiesWithinAABB( - EntityPlayer.class, - AxisAlignedBB.getBoundingBox( - te.xCoord + 0.5 - range, - te.yCoord + 0.5 - rangeY, - te.zCoord + 0.5 - range, - te.xCoord + 0.5 + range, - te.yCoord + 0.5 + rangeY, - te.zCoord + 0.5 + range)); - for (EntityPlayer p : players) { - if (p.motionY > 0.3 && p.motionY < 2 && !p.isSneaking()) { - p.motionY = 2.8; - - for (int i = 0; i < 20; i++) - for (int j = 0; j < 5; j++) - Botania.proxy.wispFX( - p.worldObj, - p.posX, - p.posY + i, - p.posZ, - 0.25F, - 0.25F, - 0.25F, - 0.35F + (float) Math.random() * 0.1F, - 0.2F * (float) (Math.random() - 0.5), - -0.01F * (float) Math.random(), - 0.2F * (float) (Math.random() - 0.5)); - - if (!world.isRemote) { - p.worldObj.playSoundAtEntity(p, "botania:dash", 1F, 1F); - p.addPotionEffect(new PotionEffect(ModPotions.featherfeet.id, 100, 0)); - tile.recieveMana(-COST); - } - } - } - } - } - - @Override - public ResourceLocation getOverlayResource(IAvatarTile tile, ItemStack stack) { - return avatarOverlay; - } + private static final ResourceLocation avatarOverlay = new ResourceLocation(LibResources.MODEL_AVATAR_TORNADO); + + private static final int FLY_TIME = 20; + private static final int FALL_MULTIPLIER = 3; + private static final int MAX_DAMAGE = FLY_TIME * FALL_MULTIPLIER; + private static final int COST = 350; + + private static final String TAG_FLYING = "flying"; + + IIcon iconIdle, iconFlying; + + public ItemTornadoRod() { + setMaxDamage(MAX_DAMAGE); + setUnlocalizedName(LibItemNames.TORNADO_ROD); + setMaxStackSize(1); + } + + @Override + public void onUpdate(ItemStack par1ItemStack, World par2World, Entity par3Entity, int par4, boolean holding) { + if(par3Entity instanceof EntityPlayer) { + EntityPlayer player = (EntityPlayer) par3Entity; + player.getCurrentEquippedItem(); + boolean damaged = par1ItemStack.getItemDamage() > 0; + + if(damaged && !isFlying(par1ItemStack)) + par1ItemStack.setItemDamage(par1ItemStack.getItemDamage() - 1); + + int max = FALL_MULTIPLIER * FLY_TIME; + if(par1ItemStack.getItemDamage() >= max) { + setFlying(par1ItemStack, false); + player.stopUsingItem(); + } else if(isFlying(par1ItemStack)) { + if(holding) { + player.fallDistance = 0F; + player.motionY = IManaProficiencyArmor.Helper.hasProficiency(player) ? 1.6 : 1.25; + + player.worldObj.playSoundAtEntity(player, "botania:airRod", 0.1F, 0.25F); + for(int i = 0; i < 5; i++) + Botania.proxy.wispFX(player.worldObj, player.posX, player.posY, player.posZ, 0.25F, 0.25F, 0.25F, 0.35F + (float) Math.random() * 0.1F, 0.2F * (float) (Math.random() - 0.5), -0.01F * (float) Math.random(), 0.2F * (float) (Math.random() - 0.5)); + } + + par1ItemStack.setItemDamage(Math.min(max, par1ItemStack.getItemDamage() + FALL_MULTIPLIER)); + if(par1ItemStack.getItemDamage() == MAX_DAMAGE) + setFlying(par1ItemStack, false); + } + + if(damaged) + player.fallDistance = 0; + } + } + + @Override + public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer) { + int meta = par1ItemStack.getItemDamage(); + if(meta != 0 || ManaItemHandler.requestManaExactForTool(par1ItemStack, par3EntityPlayer, COST, false)) { + par3EntityPlayer.setItemInUse(par1ItemStack, getMaxItemUseDuration(par1ItemStack)); + if(meta == 0) { + setFlying(par1ItemStack, true); + ManaItemHandler.requestManaExactForTool(par1ItemStack, par3EntityPlayer, COST, true); + } + } + + return par1ItemStack; + } + + @Override + public void onUsingTick(ItemStack stack, EntityPlayer player, int count) { + + } + + @Override + public IIcon getIconIndex(ItemStack par1ItemStack) { + return isFlying(par1ItemStack) ? iconFlying : iconIdle; + } + + @Override + public IIcon getIcon(ItemStack stack, int pass) { + return getIconIndex(stack); + } + + @Override + public EnumAction getItemUseAction(ItemStack par1ItemStack) { + return EnumAction.bow; + } + + @Override + public int getMaxItemUseDuration(ItemStack par1ItemStack) { + return 720000; + } + + @Override + public void registerIcons(IIconRegister par1IconRegister) { + iconIdle = IconHelper.forItem(par1IconRegister, this, 0); + iconFlying = IconHelper.forItem(par1IconRegister, this, 1); + } + + public boolean isFlying(ItemStack stack) { + return ItemNBTHelper.getBoolean(stack, TAG_FLYING, false); + } + + public void setFlying(ItemStack stack, boolean flying) { + ItemNBTHelper.setBoolean(stack, TAG_FLYING, flying); + } + + @Override + public boolean isFull3D() { + return true; + } + + @Override + public boolean usesMana(ItemStack stack) { + return true; + } + + @Override + public void onAvatarUpdate(IAvatarTile tile, ItemStack stack) { + TileEntity te = (TileEntity) tile; + World world = te.getWorldObj(); + if(tile.getCurrentMana() >= COST && tile.isEnabled()) { + int range = 5; + int rangeY = 3; + List players = world.getEntitiesWithinAABB(EntityPlayer.class, AxisAlignedBB.getBoundingBox(te.xCoord + 0.5 - range, te.yCoord + 0.5 - rangeY, te.zCoord + 0.5 - range, te.xCoord + 0.5 + range, te.yCoord + 0.5 + rangeY, te.zCoord + 0.5 + range)); + for(EntityPlayer p : players) { + if(p.motionY > 0.3 && p.motionY < 2 && !p.isSneaking()) { + p.motionY = 2.8; + + for(int i = 0; i < 20; i++) + for(int j = 0; j < 5; j++) + Botania.proxy.wispFX(p.worldObj, p.posX, p.posY + i, p.posZ, 0.25F, 0.25F, 0.25F, 0.35F + (float) Math.random() * 0.1F, 0.2F * (float) (Math.random() - 0.5), -0.01F * (float) Math.random(), 0.2F * (float) (Math.random() - 0.5)); + + if(!world.isRemote) { + p.worldObj.playSoundAtEntity(p, "botania:dash", 1F, 1F); + p.addPotionEffect(new PotionEffect(ModPotions.featherfeet.id, 100, 0)); + tile.recieveMana(-COST); + } + } + } + } + } + + @Override + public ResourceLocation getOverlayResource(IAvatarTile tile, ItemStack stack) { + return avatarOverlay; + } + } diff --git a/src/main/java/vazkii/botania/common/item/rod/ItemWaterRod.java b/src/main/java/vazkii/botania/common/item/rod/ItemWaterRod.java index 6f3ce8e577..3d8cf21836 100644 --- a/src/main/java/vazkii/botania/common/item/rod/ItemWaterRod.java +++ b/src/main/java/vazkii/botania/common/item/rod/ItemWaterRod.java @@ -13,58 +13,39 @@ public class ItemWaterRod extends ItemMod implements IManaUsingItem { - public static final int COST = 75; + public static final int COST = 75; + + public ItemWaterRod() { + super(); + setMaxStackSize(1); + setUnlocalizedName(LibItemNames.WATER_ROD); + } + + @Override + public boolean onItemUse(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, World par3World, int par4, int par5, int par6, int par7, float par8, float par9, float par10) { + if(ManaItemHandler.requestManaExactForTool(par1ItemStack, par2EntityPlayer, COST, false) && !par3World.provider.isHellWorld) { + ForgeDirection dir = ForgeDirection.getOrientation(par7); + + ItemStack stackToPlace = new ItemStack(Blocks.flowing_water); + stackToPlace.tryPlaceItemIntoWorld(par2EntityPlayer, par3World, par4, par5, par6, par7, par8, par9, par10); + + if(stackToPlace.stackSize == 0) { + ManaItemHandler.requestManaExactForTool(par1ItemStack, par2EntityPlayer, COST, true); + for(int i = 0; i < 6; i++) + Botania.proxy.sparkleFX(par3World, par4 + dir.offsetX + Math.random(), par5 + dir.offsetY + Math.random(), par6 + dir.offsetZ + Math.random(), 0.2F, 0.2F, 1F, 1F, 5); + } + } + return true; + } + + @Override + public boolean isFull3D() { + return true; + } + + @Override + public boolean usesMana(ItemStack stack) { + return true; + } - public ItemWaterRod() { - super(); - setMaxStackSize(1); - setUnlocalizedName(LibItemNames.WATER_ROD); - } - - @Override - public boolean onItemUse( - ItemStack par1ItemStack, - EntityPlayer par2EntityPlayer, - World par3World, - int par4, - int par5, - int par6, - int par7, - float par8, - float par9, - float par10) { - if (ManaItemHandler.requestManaExactForTool(par1ItemStack, par2EntityPlayer, COST, false) - && !par3World.provider.isHellWorld) { - ForgeDirection dir = ForgeDirection.getOrientation(par7); - - ItemStack stackToPlace = new ItemStack(Blocks.flowing_water); - stackToPlace.tryPlaceItemIntoWorld(par2EntityPlayer, par3World, par4, par5, par6, par7, par8, par9, par10); - - if (stackToPlace.stackSize == 0) { - ManaItemHandler.requestManaExactForTool(par1ItemStack, par2EntityPlayer, COST, true); - for (int i = 0; i < 6; i++) - Botania.proxy.sparkleFX( - par3World, - par4 + dir.offsetX + Math.random(), - par5 + dir.offsetY + Math.random(), - par6 + dir.offsetZ + Math.random(), - 0.2F, - 0.2F, - 1F, - 1F, - 5); - } - } - return true; - } - - @Override - public boolean isFull3D() { - return true; - } - - @Override - public boolean usesMana(ItemStack stack) { - return true; - } } diff --git a/src/main/java/vazkii/botania/common/lexicon/ALexiconEntry.java b/src/main/java/vazkii/botania/common/lexicon/ALexiconEntry.java index 6fc1ff96de..5ffc8b9893 100644 --- a/src/main/java/vazkii/botania/common/lexicon/ALexiconEntry.java +++ b/src/main/java/vazkii/botania/common/lexicon/ALexiconEntry.java @@ -5,8 +5,9 @@ public class ALexiconEntry extends BLexiconEntry { - public ALexiconEntry(String unlocalizedName, LexiconCategory category) { - super(unlocalizedName, category); - setKnowledgeType(BotaniaAPI.elvenKnowledge); - } + public ALexiconEntry(String unlocalizedName, LexiconCategory category) { + super(unlocalizedName, category); + setKnowledgeType(BotaniaAPI.elvenKnowledge); + } + } diff --git a/src/main/java/vazkii/botania/common/lexicon/BLexiconCategory.java b/src/main/java/vazkii/botania/common/lexicon/BLexiconCategory.java index 41bf3aa189..6e4bf200d5 100644 --- a/src/main/java/vazkii/botania/common/lexicon/BLexiconCategory.java +++ b/src/main/java/vazkii/botania/common/lexicon/BLexiconCategory.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Oct 18, 2014, 3:46:10 PM (GMT)] */ package vazkii.botania.common.lexicon; @@ -17,9 +17,11 @@ public class BLexiconCategory extends LexiconCategory { - public BLexiconCategory(String unlocalizedName, int priority) { - super(LibLexicon.CATEGORY_PREFIX + unlocalizedName); - setIcon(new ResourceLocation(LibResources.PREFIX_CATEGORIES + unlocalizedName + ".png")); - setPriority(priority); - } + public BLexiconCategory(String unlocalizedName, int priority) { + super(LibLexicon.CATEGORY_PREFIX + unlocalizedName); + setIcon(new ResourceLocation(LibResources.PREFIX_CATEGORIES + unlocalizedName + ".png")); + setPriority(priority); + } + } + diff --git a/src/main/java/vazkii/botania/common/lexicon/BLexiconEntry.java b/src/main/java/vazkii/botania/common/lexicon/BLexiconEntry.java index 620afe1224..ed320fb3b6 100644 --- a/src/main/java/vazkii/botania/common/lexicon/BLexiconEntry.java +++ b/src/main/java/vazkii/botania/common/lexicon/BLexiconEntry.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jan 14, 2014, 9:47:21 PM (GMT)] */ package vazkii.botania.common.lexicon; @@ -18,46 +18,46 @@ public class BLexiconEntry extends LexiconEntry { - public BLexiconEntry(String unlocalizedName, LexiconCategory category) { - super(unlocalizedName, category); - BotaniaAPI.addEntry(this, category); - } - - @Override - public LexiconEntry setLexiconPages(LexiconPage... pages) { - for (LexiconPage page : pages) { - page.unlocalizedName = "botania.page." + getLazyUnlocalizedName() + page.unlocalizedName; - if (page instanceof ITwoNamedPage) { - ITwoNamedPage dou = (ITwoNamedPage) page; - dou.setSecondUnlocalizedName( - "botania.page." + getLazyUnlocalizedName() + dou.getSecondUnlocalizedName()); - } - } - - return super.setLexiconPages(pages); - } - - @Override - public String getUnlocalizedName() { - return "botania.entry." + super.getUnlocalizedName(); - } - - @Override - public String getTagline() { - return "botania.tagline." + super.getUnlocalizedName(); - } - - public String getLazyUnlocalizedName() { - return super.getUnlocalizedName(); - } - - @Override - public String getWebLink() { - return "http://botaniamod.net/lexicon.php#" + unlocalizedName; - } - - @Override - public int compareTo(LexiconEntry o) { - return o instanceof WLexiconEntry ? 1 : super.compareTo(o); - } + public BLexiconEntry(String unlocalizedName, LexiconCategory category) { + super(unlocalizedName, category); + BotaniaAPI.addEntry(this, category); + } + + @Override + public LexiconEntry setLexiconPages(LexiconPage... pages) { + for(LexiconPage page : pages) { + page.unlocalizedName = "botania.page." + getLazyUnlocalizedName() + page.unlocalizedName; + if(page instanceof ITwoNamedPage) { + ITwoNamedPage dou = (ITwoNamedPage) page; + dou.setSecondUnlocalizedName("botania.page." + getLazyUnlocalizedName() + dou.getSecondUnlocalizedName()); + } + } + + return super.setLexiconPages(pages); + } + + @Override + public String getUnlocalizedName() { + return "botania.entry." + super.getUnlocalizedName(); + } + + @Override + public String getTagline() { + return "botania.tagline." + super.getUnlocalizedName(); + } + + public String getLazyUnlocalizedName() { + return super.getUnlocalizedName(); + } + + @Override + public String getWebLink() { + return "http://botaniamod.net/lexicon.php#" + unlocalizedName; + } + + @Override + public int compareTo(LexiconEntry o) { + return o instanceof WLexiconEntry ? 1 : super.compareTo(o); + } + } diff --git a/src/main/java/vazkii/botania/common/lexicon/CLexiconEntry.java b/src/main/java/vazkii/botania/common/lexicon/CLexiconEntry.java index 0783bec646..6a200cbffb 100644 --- a/src/main/java/vazkii/botania/common/lexicon/CLexiconEntry.java +++ b/src/main/java/vazkii/botania/common/lexicon/CLexiconEntry.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jun 24, 2015, 5:43:11 PM (GMT)] */ package vazkii.botania.common.lexicon; @@ -16,15 +16,16 @@ public class CLexiconEntry extends BLexiconEntry implements IAddonEntry { - String mod; + String mod; - public CLexiconEntry(String unlocalizedName, LexiconCategory category, String mod) { - super(unlocalizedName, category); - this.mod = mod; - } + public CLexiconEntry(String unlocalizedName, LexiconCategory category, String mod) { + super(unlocalizedName, category); + this.mod = mod; + } + + @Override + public String getSubtitle() { + return "[" + LibMisc.MOD_NAME + " x " + mod + "]"; + } - @Override - public String getSubtitle() { - return "[" + LibMisc.MOD_NAME + " x " + mod + "]"; - } } diff --git a/src/main/java/vazkii/botania/common/lexicon/DLexiconEntry.java b/src/main/java/vazkii/botania/common/lexicon/DLexiconEntry.java index d6c7ed6735..00a0fc499a 100644 --- a/src/main/java/vazkii/botania/common/lexicon/DLexiconEntry.java +++ b/src/main/java/vazkii/botania/common/lexicon/DLexiconEntry.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [16/12/2015, 20:38:33 (GMT)] */ package vazkii.botania.common.lexicon; @@ -15,12 +15,13 @@ public class DLexiconEntry extends BLexiconEntry { - public DLexiconEntry(String unlocalizedName, LexiconCategory category) { - super(unlocalizedName, category); - } + public DLexiconEntry(String unlocalizedName, LexiconCategory category) { + super(unlocalizedName, category); + } + + @Override + public boolean isVisible() { + return !PersistentVariableHelper.dog; + } - @Override - public boolean isVisible() { - return !PersistentVariableHelper.dog; - } } diff --git a/src/main/java/vazkii/botania/common/lexicon/HLexiconEntry.java b/src/main/java/vazkii/botania/common/lexicon/HLexiconEntry.java index 5746740ac0..099956394e 100644 --- a/src/main/java/vazkii/botania/common/lexicon/HLexiconEntry.java +++ b/src/main/java/vazkii/botania/common/lexicon/HLexiconEntry.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Aug 27, 2015, 7:34:43 PM (GMT)] */ package vazkii.botania.common.lexicon; @@ -14,12 +14,13 @@ public class HLexiconEntry extends ALexiconEntry { - public HLexiconEntry(String unlocalizedName, LexiconCategory category) { - super(unlocalizedName, category); - } + public HLexiconEntry(String unlocalizedName, LexiconCategory category) { + super(unlocalizedName, category); + } + + @Override + public String getWebLink() { + return "http://heads.freshcoal.com/usernames.php"; + } - @Override - public String getWebLink() { - return "http://heads.freshcoal.com/usernames.php"; - } } diff --git a/src/main/java/vazkii/botania/common/lexicon/LexiconData.java b/src/main/java/vazkii/botania/common/lexicon/LexiconData.java index 87f13f1a1a..2c291d353e 100644 --- a/src/main/java/vazkii/botania/common/lexicon/LexiconData.java +++ b/src/main/java/vazkii/botania/common/lexicon/LexiconData.java @@ -2,16 +2,18 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jan 14, 2014, 9:12:15 PM (GMT)] */ package vazkii.botania.common.lexicon; import java.util.ArrayList; import java.util.List; + +import baubles.common.Config; import net.minecraft.init.Blocks; import net.minecraft.init.Items; import net.minecraft.item.ItemStack; @@ -55,1802 +57,1438 @@ public final class LexiconData { - public static LexiconEntry welcome; - public static LexiconEntry tutorial; - - public static LexiconEntry flowers; - public static LexiconEntry apothecary; - public static LexiconEntry lexicon; - public static LexiconEntry wand; - public static LexiconEntry pureDaisy; - public static LexiconEntry runicAltar; - public static LexiconEntry terrasteel; - public static LexiconEntry blackLotus; - public static LexiconEntry flowerBag; - public static LexiconEntry gardenOfGlass; - - public static LexiconEntry manaIntro; - public static LexiconEntry spreader; - public static LexiconEntry pool; - public static LexiconEntry lenses; - public static LexiconEntry distributor; - public static LexiconEntry manaVoid; - public static LexiconEntry manaTablet; - public static LexiconEntry manaMirror; - public static LexiconEntry manaDetector; - public static LexiconEntry redstoneSpreader; - public static LexiconEntry manastar; - public static LexiconEntry dreamwoodSpreader; - public static LexiconEntry elvenLenses; - public static LexiconEntry sparks; - public static LexiconEntry sparkUpgrades; - public static LexiconEntry rfGenerator; - public static LexiconEntry prism; - public static LexiconEntry poolCart; - public static LexiconEntry sparkChanger; - public static LexiconEntry bellows; - - public static LexiconEntry functionalIntro; - public static LexiconEntry flowerShrinking; - public static LexiconEntry flowerSpeed; - public static LexiconEntry jadedAmaranthus; - public static LexiconEntry bellethorne; - public static LexiconEntry dreadthorne; - public static LexiconEntry heiseiDream; - public static LexiconEntry tigerseye; - public static LexiconEntry orechid; - public static LexiconEntry orechidIgnem; - public static LexiconEntry fallenKanade; - public static LexiconEntry exoflame; - public static LexiconEntry agricarnation; - public static LexiconEntry hopperhock; - public static LexiconEntry tangleberrie; - public static LexiconEntry jiyuulia; - public static LexiconEntry rannuncarpus; - public static LexiconEntry hyacidus; - public static LexiconEntry pollidisiac; - public static LexiconEntry clayconia; - public static LexiconEntry loonium; - public static LexiconEntry daffomill; - public static LexiconEntry vinculotus; - public static LexiconEntry spectranthemum; - public static LexiconEntry medumone; - public static LexiconEntry marimorphosis; - public static LexiconEntry bubbell; - public static LexiconEntry solegnolia; - - public static LexiconEntry generatingIntro; - public static LexiconEntry passiveGen; - public static LexiconEntry primusLoci; - public static LexiconEntry daybloom; - public static LexiconEntry nightshade; - public static LexiconEntry endoflame; - public static LexiconEntry hydroangeas; - public static LexiconEntry thermalily; - public static LexiconEntry arcaneRose; - public static LexiconEntry munchdew; - public static LexiconEntry entropinnyum; - public static LexiconEntry kekimurus; - public static LexiconEntry gourmaryllis; - public static LexiconEntry narslimmus; - public static LexiconEntry spectrolus; - public static LexiconEntry rafflowsia; - public static LexiconEntry dandelifeon; - - public static LexiconEntry pylon; - public static LexiconEntry manaEnchanting; - public static LexiconEntry turntable; - public static LexiconEntry alchemy; - public static LexiconEntry openCrate; - public static LexiconEntry forestEye; - public static LexiconEntry forestDrum; - public static LexiconEntry platform; - public static LexiconEntry conjurationCatalyst; - public static LexiconEntry spectralPlatform; - public static LexiconEntry gatherDrum; - public static LexiconEntry craftCrate; - public static LexiconEntry brewery; - public static LexiconEntry flasks; - public static LexiconEntry complexBrews; - public static LexiconEntry incense; - public static LexiconEntry hourglass; - public static LexiconEntry ghostRail; - public static LexiconEntry canopyDrum; - public static LexiconEntry cocoon; - public static LexiconEntry manaBomb; - public static LexiconEntry teruTeruBozu; - public static LexiconEntry avatar; - public static LexiconEntry felPumpkin; - - public static LexiconEntry manaBlaster; - public static LexiconEntry grassSeeds; - public static LexiconEntry dirtRod; - public static LexiconEntry terraformRod; - public static LexiconEntry manasteelGear; - public static LexiconEntry terrasteelArmor; - public static LexiconEntry grassHorn; - public static LexiconEntry terraBlade; - public static LexiconEntry terraPick; - public static LexiconEntry waterRod; - public static LexiconEntry elfGear; - public static LexiconEntry openBucket; - public static LexiconEntry rainbowRod; - public static LexiconEntry tornadoRod; - public static LexiconEntry fireRod; - public static LexiconEntry vineBall; - public static LexiconEntry laputaShard; - public static LexiconEntry virus; - public static LexiconEntry skyDirtRod; - public static LexiconEntry glassPick; - public static LexiconEntry diviningRod; - public static LexiconEntry gravityRod; - public static LexiconEntry regenIvy; - public static LexiconEntry missileRod; - public static LexiconEntry craftingHalo; - public static LexiconEntry clip; - public static LexiconEntry cobbleRod; - public static LexiconEntry smeltRod; - public static LexiconEntry worldSeed; - public static LexiconEntry spellCloth; - public static LexiconEntry thornChakram; - public static LexiconEntry fireChakram; - public static LexiconEntry overgrowthSeed; - public static LexiconEntry livingwoodBow; - public static LexiconEntry crystalBow; - public static LexiconEntry temperanceStone; - public static LexiconEntry terraAxe; - public static LexiconEntry obedienceStick; - public static LexiconEntry slimeBottle; - public static LexiconEntry exchangeRod; - public static LexiconEntry manaweave; - public static LexiconEntry autocraftingHalo; - public static LexiconEntry sextant; - - public static LexiconEntry enderAir; - public static LexiconEntry enderEyeBlock; - public static LexiconEntry pistonRelay; - public static LexiconEntry enderHand; - public static LexiconEntry enderDagger; - public static LexiconEntry spawnerClaw; - public static LexiconEntry redString; - public static LexiconEntry flightTiara; - public static LexiconEntry corporea; - public static LexiconEntry corporeaIndex; - public static LexiconEntry corporeaFunnel; - public static LexiconEntry corporeaInterceptor; - public static LexiconEntry endStoneDecor; - public static LexiconEntry spawnerMover; - public static LexiconEntry keepIvy; - public static LexiconEntry blackHoleTalisman; - public static LexiconEntry corporeaCrystalCube; - public static LexiconEntry luminizerTransport; - public static LexiconEntry starSword; - public static LexiconEntry thunderSword; - public static LexiconEntry corporeaRetainer; - - public static LexiconEntry baublesIntro; - public static LexiconEntry cosmeticBaubles; - public static LexiconEntry tinyPlanet; - public static LexiconEntry manaRing; - public static LexiconEntry auraRing; - public static LexiconEntry travelBelt; - public static LexiconEntry knockbacklBelt; - public static LexiconEntry icePendant; - public static LexiconEntry lavaPendant; - public static LexiconEntry goldLaurel; - public static LexiconEntry waterRing; - public static LexiconEntry miningRing; - public static LexiconEntry magnetRing; - public static LexiconEntry divaCharm; - public static LexiconEntry pixieRing; - public static LexiconEntry superTravelBelt; - public static LexiconEntry reachRing; - public static LexiconEntry itemFinder; - public static LexiconEntry superLavaPendant; - public static LexiconEntry bloodPendant; - public static LexiconEntry judgementCloaks; - public static LexiconEntry monocle; - public static LexiconEntry swapRing; - public static LexiconEntry speedUpBelt; - public static LexiconEntry baubleBox; - - public static LexiconEntry alfhomancyIntro; - public static LexiconEntry elvenMessage; - public static LexiconEntry elvenResources; - public static LexiconEntry gaiaRitual; - public static LexiconEntry gaiaRitualHardmode; - public static LexiconEntry elvenLore; - public static LexiconEntry relics; - public static LexiconEntry relicInfo; - public static LexiconEntry infiniteFruit; - public static LexiconEntry kingKey; - public static LexiconEntry flugelEye; - public static LexiconEntry thorRing; - public static LexiconEntry lokiRing; - public static LexiconEntry odinRing; - - public static LexiconEntry unstableBlocks; - public static LexiconEntry decorativeBlocks; - public static LexiconEntry dispenserTweaks; - public static LexiconEntry shinyFlowers; - public static LexiconEntry prismarine; - public static LexiconEntry shedding; - public static LexiconEntry tinyPotato; - public static LexiconEntry headCreating; - public static LexiconEntry azulejo; - public static LexiconEntry starfield; - public static LexiconEntry dirtPath; - public static LexiconEntry mushrooms; - public static LexiconEntry phantomInk; - public static LexiconEntry stoneAlchemy; - public static LexiconEntry blazeBlock; - public static LexiconEntry challenges; - public static LexiconEntry cacophonium; - public static LexiconEntry pavement; - public static LexiconEntry preventingDecay; - - public static LexiconEntry tcIntegration; - public static LexiconEntry bcIntegration; - public static LexiconEntry banners; - - public static void preInit() { - BotaniaAPI.addCategory(BotaniaAPI.categoryBasics = new BLexiconCategory(LibLexicon.CATEGORY_BASICS, 9)); - BotaniaAPI.addCategory(BotaniaAPI.categoryMana = new BLexiconCategory(LibLexicon.CATEGORY_MANA, 5)); - BotaniaAPI.addCategory( - BotaniaAPI.categoryGenerationFlowers = new BLexiconCategory(LibLexicon.CATEGORY_GENERATION_FLOWERS, 5)); - BotaniaAPI.addCategory( - BotaniaAPI.categoryFunctionalFlowers = new BLexiconCategory(LibLexicon.CATEGORY_FUNCTIONAL_FLOWERS, 5)); - BotaniaAPI.addCategory(BotaniaAPI.categoryDevices = new BLexiconCategory(LibLexicon.CATEGORY_DEVICES, 5)); - BotaniaAPI.addCategory(BotaniaAPI.categoryTools = new BLexiconCategory(LibLexicon.CATEGORY_TOOLS, 5)); - BotaniaAPI.addCategory(BotaniaAPI.categoryBaubles = new BLexiconCategory(LibLexicon.CATEGORY_BAUBLES, 5)); - BotaniaAPI.addCategory(BotaniaAPI.categoryEnder = new BLexiconCategory(LibLexicon.CATEGORY_ENDER, 5)); - BotaniaAPI.addCategory(BotaniaAPI.categoryAlfhomancy = new BLexiconCategory(LibLexicon.CATEGORY_ALFHOMANCY, 5)); - BotaniaAPI.addCategory(BotaniaAPI.categoryMisc = new BLexiconCategory(LibLexicon.CATEGORY_MISC, 0)); - } - - public static void init() { - LexiconCategory categoryBasics = BotaniaAPI.categoryBasics; - LexiconCategory categoryMana = BotaniaAPI.categoryMana; - LexiconCategory categoryGenerationFlowers = BotaniaAPI.categoryGenerationFlowers; - LexiconCategory categoryFunctionalFlowers = BotaniaAPI.categoryFunctionalFlowers; - LexiconCategory categoryDevices = BotaniaAPI.categoryDevices; - LexiconCategory categoryTools = BotaniaAPI.categoryTools; - LexiconCategory categoryBaubles = BotaniaAPI.categoryBaubles; - LexiconCategory categoryEnder = BotaniaAPI.categoryEnder; - LexiconCategory categoryAlfhomancy = BotaniaAPI.categoryAlfhomancy; - LexiconCategory categoryMisc = BotaniaAPI.categoryMisc; - - // BASICS ENTRIES - welcome = new WLexiconEntry(); - tutorial = new TLexiconEntry(); - - flowers = new BLexiconEntry(LibLexicon.BASICS_FLOWERS, categoryBasics); - flowers.setPriority() - .setLexiconPages( - new PageText("0"), - new PageImage("1", LibResources.ENTRY_FLOWERS), - new PageText("2"), - new PageCraftingRecipe("3", ModCraftingRecipes.recipesPetals), - new PageCraftingRecipe("4", ModCraftingRecipes.recipePestleAndMortar), - new PageCraftingRecipe("5", ModCraftingRecipes.recipesDyes), - new PageText("6"), - new PageCraftingRecipe("7", ModCraftingRecipes.recipeFertilizerPowder), - new PageCraftingRecipe("8", ModCraftingRecipes.recipeFerilizerDye), - new PageText("10"), - new PageText("12"), - new PageCraftingRecipe("11", ModCraftingRecipes.recipesPetalsDouble), - new PageCraftingRecipe("9", ModCraftingRecipes.recipesPetalBlocks)) - .setIcon(new ItemStack(ModBlocks.flower, 1, 6)); - - apothecary = new BLexiconEntry(LibLexicon.BASICS_APOTHECARY, categoryBasics); - apothecary - .setPriority() - .setLexiconPages( - new PageText("0"), - new PageImage("1", LibResources.ENTRY_APOTHECARY), - new PageText("2"), - new PageText("3"), - new PageText("4"), - new PageText("7"), - new PageText("6"), - new PageCraftingRecipe("5", ModCraftingRecipes.recipesApothecary)); - - lexicon = new BLexiconEntry(LibLexicon.BASICS_LEXICON, categoryBasics); - lexicon.setPriority() - .setLexiconPages( - new PageText("0"), - new PageText("3"), - new PageCraftingRecipe("1", ModCraftingRecipes.recipeLexicon), - new PageText("2")); - - wand = new BLexiconEntry(LibLexicon.BASICS_WAND, categoryBasics); - wand.setPriority() - .setLexiconPages( - new PageText("0"), - new PageText("1"), - new PageText("2"), - new PageCraftingRecipe("3", ModCraftingRecipes.recipesTwigWand)); - - pureDaisy = new BLexiconEntry(LibLexicon.BASICS_PURE_DAISY, categoryBasics); - pureDaisy - .setPriority() - .setLexiconPages( - new PageText("0"), - new PageImage("1", LibResources.ENTRY_PURE_DAISY), - new PageCraftingRecipe("2", ModCraftingRecipes.recipeLivingwoodTwig), - new PageText("4"), - new PagePetalRecipe("3", ModPetalRecipes.pureDaisyRecipe)) - .setIcon(ItemBlockSpecialFlower.ofType(LibBlockNames.SUBTILE_PUREDAISY)); - pureDaisy.addExtraDisplayedRecipe(new ItemStack(ModBlocks.livingwood)); - pureDaisy.addExtraDisplayedRecipe(new ItemStack(ModBlocks.livingrock)); - LexiconRecipeMappings.map(new ItemStack(ModBlocks.livingwood), pureDaisy, 1); - LexiconRecipeMappings.map(new ItemStack(ModBlocks.livingrock), pureDaisy, 1); - - runicAltar = new BLexiconEntry(LibLexicon.BASICS_RUNE_ALTAR, categoryBasics); - runicAltar - .setPriority() - .setLexiconPages( - new PageText("21"), - new PageText("0"), - new PageText("1"), - new PageCraftingRecipe("2", ModCraftingRecipes.recipesRuneAltar), - new PageText("3"), - new PageText("20"), - new PageText("22"), - new PageRuneRecipe("4", ModRuneRecipes.recipeWaterRune), - new PageRuneRecipe("5", ModRuneRecipes.recipesEarthRune), - new PageRuneRecipe("6", ModRuneRecipes.recipesAirRune), - new PageRuneRecipe("7", ModRuneRecipes.recipeFireRune), - new PageRuneRecipe("8", ModRuneRecipes.recipeSpringRune), - new PageRuneRecipe("9", ModRuneRecipes.recipeSummerRune), - new PageRuneRecipe("10", ModRuneRecipes.recipeAutumnRune), - new PageRuneRecipe("11", ModRuneRecipes.recipesWinterRune), - new PageRuneRecipe("12", ModRuneRecipes.recipeManaRune), - new PageRuneRecipe("13", ModRuneRecipes.recipeLustRune), - new PageRuneRecipe("14", ModRuneRecipes.recipeGluttonyRune), - new PageRuneRecipe("15", ModRuneRecipes.recipeGreedRune), - new PageRuneRecipe("16", ModRuneRecipes.recipeSlothRune), - new PageRuneRecipe("17", ModRuneRecipes.recipeWrathRune), - new PageRuneRecipe("18", ModRuneRecipes.recipeEnvyRune), - new PageRuneRecipe("19", ModRuneRecipes.recipePrideRune)); - - terrasteel = new BLexiconEntry(LibLexicon.BASICS_TERRASTEEL, categoryBasics); - terrasteel - .setLexiconPages( - new PageText("0"), - new PageCraftingRecipe("1", ModCraftingRecipes.recipeTerraPlate), - new PageText("2"), - new PageMultiblock("4", ModMultiblocks.terrasteelPlate), - new PageTerrasteel("3")) - .setIcon(new ItemStack(ModItems.manaResource, 1, 4)); - - blackLotus = new BLexiconEntry(LibLexicon.BASICS_BLACK_LOTUS, categoryBasics); - blackLotus.setLexiconPages(new PageText("0")).setIcon(new ItemStack(ModItems.blackLotus)); - blackLotus.addExtraDisplayedRecipe(new ItemStack(ModItems.blackLotus)); - - flowerBag = new BLexiconEntry(LibLexicon.BASICS_FLOWER_BAG, categoryBasics); - flowerBag.setLexiconPages( - new PageText("0"), new PageText("2"), new PageCraftingRecipe("1", ModCraftingRecipes.recipeFlowerBag)); - - if (Botania.gardenOfGlassLoaded) { - gardenOfGlass = new BLexiconEntry(LibLexicon.BASICS_GARDEN_OF_GLASS, categoryBasics); - gardenOfGlass.setLexiconPages( - new PageText("0"), - new PageText("1"), - new PageText("2"), - new PageCraftingRecipe("3", ModCraftingRecipes.recipeRootToSapling), - new PageCraftingRecipe("4", ModCraftingRecipes.recipeRootToFertilizer), - new PageCraftingRecipe("5", ModCraftingRecipes.recipePebbleCobblestone), - new PageText("6"), - new PageManaInfusionRecipe("7", ModManaInfusionRecipes.sugarCaneRecipe), - new PageCraftingRecipe("8", ModCraftingRecipes.recipeMagmaToSlimeball), - new PageText("9"), - new PageText("11"), - new PageCraftingRecipe("12", ModCraftingRecipes.recipeEndPortal)); - gardenOfGlass.setPriority().setIcon(new ItemStack(ModItems.manaResource, 1, 20)); - } - - if (Botania.thaumcraftLoaded) - new CLexiconEntry("wrap", categoryBasics, "Thaumcraft").setLexiconPages(new PageText("0")); // lel - - // MANA ENTRIES - manaIntro = new BLexiconEntry(LibLexicon.MANA_INTRO, categoryMana); - manaIntro.setPriority().setLexiconPages(new PageText("0"), new PageText("1"), new PageText("2")); - - spreader = new BLexiconEntry(LibLexicon.MANA_SPREADER, categoryMana); - spreader.setPriority() - .setLexiconPages( - new PageText("0"), - new PageImage("1", LibResources.ENTRY_SPREADER), - new PageText("2"), - new PageText("3"), - new PageText("4"), - new PageText("11"), - new PageCraftingRecipe("5", ModCraftingRecipes.recipesSpreader), - new PageText("10")); - - pool = new BLexiconEntry(LibLexicon.MANA_POOL, categoryMana); - pool.setPriority() - .setLexiconPages( - new PageText("0"), - new PageText("9"), - new PageCraftingRecipe("1", ModCraftingRecipes.recipePool), - new PageCraftingRecipe("10", ModCraftingRecipes.recipePoolDiluted), - new PageText("14"), - new PageText("2"), - new PageText("8"), - new PageManaInfusionRecipe("3", ModManaInfusionRecipes.manasteelRecipes), - new PageManaInfusionRecipe("4", ModManaInfusionRecipes.manaPearlRecipe), - new PageManaInfusionRecipe("5", ModManaInfusionRecipes.manaDiamondRecipes), - new PageManaInfusionRecipe("6", ModManaInfusionRecipes.manaPowderRecipes), - new PageManaInfusionRecipe("11", ModManaInfusionRecipes.managlassRecipe), - new PageManaInfusionRecipe("12", ModManaInfusionRecipes.manaStringRecipe), - new PageCraftingRecipe("13", ModCraftingRecipes.recipeCobweb), - new PageManaInfusionRecipe("7", ModManaInfusionRecipes.manaCookieRecipe)) - .setIcon(new ItemStack(ModBlocks.pool)); - - sparks = new BLexiconEntry(LibLexicon.MANA_SPARKS, categoryMana); - sparks.setPriority() - .setLexiconPages( - new PageText("0"), - new PageText("1"), - new PageText("3"), - new PageCraftingRecipe("2", ModCraftingRecipes.recipesSpark)); - - sparkUpgrades = new ALexiconEntry(LibLexicon.MANA_SPARK_UPGRADES, categoryMana); - sparkUpgrades.setLexiconPages( - new PageText("0"), - new PageText("1"), - new PageText("2"), - new PageText("3"), - new PageText("4"), - new PageCraftingRecipe("5", ModCraftingRecipes.recipesSparkUpgrades)); - - if (ConfigHandler.fluxfieldEnabled) { - rfGenerator = new BLexiconEntry(LibLexicon.MANA_RF_GENERATOR, categoryMana); - rfGenerator.setLexiconPages( - new PageText("0"), new PageCraftingRecipe("1", ModCraftingRecipes.recipeRFGenerator)); - } - - lenses = new BLexiconEntry(LibLexicon.MANA_LENSES, categoryMana); - lenses.setLexiconPages( - new PageText("0"), - new PageCraftingRecipe("1", ModCraftingRecipes.recipesManaLens), - new PageText("4"), - new PageText("5"), - new PageText("6"), - new PageCraftingRecipe("7", ModCraftingRecipes.recipeLensVelocity), - new PageText("8"), - new PageCraftingRecipe("9", ModCraftingRecipes.recipeLensPotency), - new PageText("10"), - new PageCraftingRecipe("11", ModCraftingRecipes.recipeLensResistance), - new PageText("12"), - new PageCraftingRecipe("13", ModCraftingRecipes.recipeLensEfficiency), - new PageText("14"), - new PageCraftingRecipe("15", ModCraftingRecipes.recipeLensBounce), - new PageText("16"), - new PageCraftingRecipe("17", ModCraftingRecipes.recipeLensGravity), - new PageText("18"), - new PageCraftingRecipe("19", ModCraftingRecipes.recipeLensBore), - new PageText("20"), - new PageCraftingRecipe("21", ModCraftingRecipes.recipeLensDamaging), - new PageText("22"), - new PageCraftingRecipe("23", ModCraftingRecipes.recipeLensPhantom), - new PageText("24"), - new PageCraftingRecipe("25", ModCraftingRecipes.recipeLensMagnet), - new PageText("26"), - new PageCraftingRecipe("27", ModCraftingRecipes.recipeLensExplosive), - new PageText("28"), - new PageCraftingRecipe("29", ModCraftingRecipes.recipeLensInfluence), - new PageText("30"), - new PageCraftingRecipe("31", ModCraftingRecipes.recipeLensWeight), - new PageText("32"), - new PageCraftingRecipe("33", ModCraftingRecipes.recipeLensFire), - new PageText("34"), - new PageCraftingRecipe("35", ModCraftingRecipes.recipeLensPiston), - new PageText("36"), - new PageCraftingRecipe("37", ModCraftingRecipes.recipesLensFlash)); - - distributor = new BLexiconEntry(LibLexicon.MANA_DISTRIBUTOR, categoryMana); - distributor.setLexiconPages( - new PageText("0"), new PageCraftingRecipe("1", ModCraftingRecipes.recipeDistributor)); - - manaVoid = new BLexiconEntry(LibLexicon.MANA_VOID, categoryMana); - manaVoid.setLexiconPages(new PageText("0"), new PageCraftingRecipe("1", ModCraftingRecipes.recipeManaVoid)); - - manaTablet = new BLexiconEntry(LibLexicon.MANA_TABLET, categoryMana); - manaTablet - .setPriority() - .setLexiconPages( - new PageText("0"), - new PageText("1"), - new PageCraftingRecipe("2", ModCraftingRecipes.recipesManaTablet)); - - manaMirror = new BLexiconEntry(LibLexicon.MANA_MIRROR, categoryMana); - manaMirror.setLexiconPages(new PageText("0"), new PageCraftingRecipe("1", ModCraftingRecipes.recipeManaMirror)); - - manaDetector = new BLexiconEntry(LibLexicon.MANA_DETECTOR, categoryMana); - manaDetector.setLexiconPages( - new PageText("0"), new PageCraftingRecipe("1", ModCraftingRecipes.recipeManaDetector)); - - redstoneSpreader = new BLexiconEntry(LibLexicon.MANA_REDSTONE_SPREADER, categoryMana); - redstoneSpreader - .setPriority() - .setLexiconPages( - new PageText("0"), new PageCraftingRecipe("1", ModCraftingRecipes.recipeRedstoneSpreader)); - - manastar = new BLexiconEntry(LibLexicon.MANA_MANASTAR, categoryMana); - manastar.setPriority() - .setLexiconPages(new PageText("0"), new PagePetalRecipe("1", ModPetalRecipes.manastarRecipe)); - - dreamwoodSpreader = new ALexiconEntry(LibLexicon.MANA_DREAMWOOD_SPREADER, categoryMana); - dreamwoodSpreader.setLexiconPages( - new PageText("0"), - new PageCraftingRecipe("1", ModCraftingRecipes.recipesDreamwoodSpreader), - new PageText("2"), - new PageCraftingRecipe("3", ModCraftingRecipes.recipeUltraSpreader)); - - elvenLenses = new ALexiconEntry(LibLexicon.MANA_ELVEN_LENSES, categoryMana); - elvenLenses.setLexiconPages( - new PageText("0"), - new PageText("1"), - new PageCraftingRecipe("2", ModCraftingRecipes.recipeLensPaint), - new PageText("3"), - new PageCraftingRecipe("4", ModCraftingRecipes.recipeLensWarp), - new PageText("5"), - new PageCraftingRecipe("6", ModCraftingRecipes.recipeLensRedirect), - new PageText("7"), - new PageCraftingRecipe("8", ModCraftingRecipes.recipeLensFirework), - new PageText("9"), - new PageCraftingRecipe("10", ModCraftingRecipes.recipeLensFlare)); - - prism = new ALexiconEntry(LibLexicon.MANA_PRISM, categoryMana); - prism.setLexiconPages( - new PageText("0"), - new PageText("1"), - new PageText("2"), - new PageCraftingRecipe("3", ModCraftingRecipes.recipePrism)); - - poolCart = new BLexiconEntry(LibLexicon.MANA_POOL_CART, categoryMana); - poolCart.setLexiconPages( - new PageText("0"), - new PageText("1"), - new PageText("2"), - new PageCraftingRecipe("3", ModCraftingRecipes.recipePoolCart), - new PageCraftingRecipe("4", ModCraftingRecipes.recipePump)); - - sparkChanger = new ALexiconEntry(LibLexicon.MANA_SPARK_CHANGER, categoryMana); - sparkChanger.setLexiconPages( - new PageText("0"), - new PageText("1"), - new PageCraftingRecipe("2", ModCraftingRecipes.recipeSparkChanger)); - - bellows = new BLexiconEntry(LibLexicon.MANA_BELLOWS, categoryMana); - bellows.setLexiconPages( - new PageText("0"), new PageText("1"), new PageCraftingRecipe("2", ModCraftingRecipes.recipeBellows)); - - // FUNCTIONAL FLOWERS ENTRIES - functionalIntro = new BLexiconEntry(LibLexicon.FFLOWER_INTRO, categoryFunctionalFlowers); - functionalIntro - .setPriority() - .setLexiconPages( - new PageText("0"), - new PageText("1"), - new PageText("2"), - new PageText("3"), - new PageCraftingRecipe("4", ModCraftingRecipes.recipeRedstoneRoot)) - .setIcon(null); - ; - - flowerShrinking = new BLexiconEntry(LibLexicon.FFLOWER_SHRINKING, categoryFunctionalFlowers); - flowerShrinking - .setPriority() - .setLexiconPages(new PageText("0"), new PageManaInfusionRecipe("1", BotaniaAPI.miniFlowerRecipes)) - .setIcon(ItemBlockSpecialFlower.ofType(LibBlockNames.SUBTILE_BELLETHORN + "Chibi")); - - flowerSpeed = new BLexiconEntry(LibLexicon.FFLOWER_SPEED, categoryFunctionalFlowers); - flowerSpeed.setPriority().setLexiconPages(new PageText("0"), new PageText("1")); - flowerSpeed.setIcon(new ItemStack(Blocks.dirt, 1, 2)); - - jadedAmaranthus = new BLexiconEntry(LibLexicon.FFLOWER_JADED_AMARANTHUS, categoryFunctionalFlowers); - jadedAmaranthus.setLexiconPages( - new PageText("0"), new PagePetalRecipe("1", ModPetalRecipes.jadedAmaranthusRecipe), new PageText("2")); - - bellethorne = new BLexiconEntry(LibLexicon.FFLOWER_BELLETHORNE, categoryFunctionalFlowers); - bellethorne.setLexiconPages(new PageText("0"), new PagePetalRecipe("1", ModPetalRecipes.bellethorneRecipe)); - - dreadthorne = new BLexiconEntry(LibLexicon.FFLOWER_DREADTHORNE, categoryFunctionalFlowers); - dreadthorne.setLexiconPages(new PageText("0"), new PagePetalRecipe("1", ModPetalRecipes.dreadthorneRecipe)); - - heiseiDream = new ALexiconEntry(LibLexicon.FFLOWER_HEISEI_DREAM, categoryFunctionalFlowers); - heiseiDream.setLexiconPages(new PageText("0"), new PagePetalRecipe("1", ModPetalRecipes.heiseiDreamRecipe)); - - tigerseye = new BLexiconEntry(LibLexicon.FFLOWER_TIGERSEYE, categoryFunctionalFlowers); - tigerseye.setLexiconPages(new PageText("0"), new PagePetalRecipe("1", ModPetalRecipes.tigerseyeRecipe)); - - orechid = Botania.gardenOfGlassLoaded - ? new BLexiconEntry(LibLexicon.FFLOWER_ORECHID, categoryFunctionalFlowers) - : new ALexiconEntry(LibLexicon.FFLOWER_ORECHID, categoryFunctionalFlowers); - orechid.setLexiconPages(new PageText("0"), new PagePetalRecipe("1", ModPetalRecipes.orechidRecipe)); - if (Botania.gardenOfGlassLoaded) orechid.setPriority(); - - orechidIgnem = new ALexiconEntry(LibLexicon.FFLOWER_ORECHID_IGNEM, categoryFunctionalFlowers); - orechidIgnem.setLexiconPages(new PageText("0"), new PagePetalRecipe("1", ModPetalRecipes.orechidIgnemRecipe)); - - if (ConfigHandler.fallenKanadeEnabled) { - fallenKanade = new BLexiconEntry(LibLexicon.FFLOWER_FALLEN_KANADE, categoryFunctionalFlowers); - fallenKanade.setLexiconPages( - new PageText(Botania.bloodMagicLoaded ? "0a" : "0"), - new PagePetalRecipe("1", ModPetalRecipes.fallenKanadeRecipe)); - } - - exoflame = new BLexiconEntry(LibLexicon.FFLOWER_EXOFLAME, categoryFunctionalFlowers); - exoflame.setLexiconPages(new PageText("0"), new PagePetalRecipe("1", ModPetalRecipes.exoflameRecipe)); - - agricarnation = new BLexiconEntry(LibLexicon.FFLOWER_AGRICARNATION, categoryFunctionalFlowers); - agricarnation.setLexiconPages(new PageText("0"), new PagePetalRecipe("1", ModPetalRecipes.agricarnationRecipe)); - - hopperhock = new BLexiconEntry(LibLexicon.FFLOWER_HOPPERHOCK, categoryFunctionalFlowers); - hopperhock.setLexiconPages( - new PageText("0"), new PageText("1"), new PagePetalRecipe("2", ModPetalRecipes.hopperhockRecipe)); - - tangleberrie = new BLexiconEntry(LibLexicon.FFLOWER_TANGLEBERRIE, categoryFunctionalFlowers); - tangleberrie.setLexiconPages(new PageText("0"), new PagePetalRecipe("1", ModPetalRecipes.tangleberrieRecipe)); - - jiyuulia = new BLexiconEntry(LibLexicon.FFLOWER_JIYUULIA, categoryFunctionalFlowers); - jiyuulia.setLexiconPages(new PageText("0"), new PagePetalRecipe("1", ModPetalRecipes.jiyuuliaRecipe)); - - rannuncarpus = new BLexiconEntry(LibLexicon.FFLOWER_RANNUNCARPUS, categoryFunctionalFlowers); - rannuncarpus.setLexiconPages( - new PageText("0"), new PageText("1"), new PagePetalRecipe("2", ModPetalRecipes.rannuncarpusRecipe)); - - hyacidus = new BLexiconEntry(LibLexicon.FFLOWER_HYACIDUS, categoryFunctionalFlowers); - hyacidus.setLexiconPages(new PageText("0"), new PagePetalRecipe("1", ModPetalRecipes.hyacidusRecipe)); - - pollidisiac = new BLexiconEntry(LibLexicon.FFLOWER_POLLIDISIAC, categoryFunctionalFlowers); - pollidisiac.setLexiconPages(new PageText("0"), new PagePetalRecipe("1", ModPetalRecipes.pollidisiacRecipe)); - - clayconia = new BLexiconEntry(LibLexicon.FFLOWER_CLAYCONIA, categoryFunctionalFlowers); - clayconia.setLexiconPages(new PageText("0"), new PagePetalRecipe("1", ModPetalRecipes.clayconiaRecipe)); - - loonium = new ALexiconEntry(LibLexicon.FFLOWER_LOONIUM, categoryFunctionalFlowers); - loonium.setLexiconPages(new PageText("0"), new PagePetalRecipe("1", ModPetalRecipes.looniumRecipe)); - - daffomill = new BLexiconEntry(LibLexicon.FFLOWER_DAFFOMILL, categoryFunctionalFlowers); - daffomill.setLexiconPages(new PageText("0"), new PagePetalRecipe("1", ModPetalRecipes.daffomillRecipe)); - - vinculotus = new BLexiconEntry(LibLexicon.FFLOWER_VINCULOTUS, categoryFunctionalFlowers); - vinculotus.setLexiconPages(new PageText("0"), new PagePetalRecipe("1", ModPetalRecipes.vinculotusRecipe)); - - spectranthemum = new ALexiconEntry(LibLexicon.FFLOWER_SPECTRANTHEMUN, categoryFunctionalFlowers); - spectranthemum.setLexiconPages( - new PageText("0"), - new PageText("1"), - new PageText("2"), - new PagePetalRecipe("3", ModPetalRecipes.spectranthemumRecipe)); - - medumone = new BLexiconEntry(LibLexicon.FFLOWER_MEDUMONE, categoryFunctionalFlowers); - medumone.setLexiconPages(new PageText("0"), new PagePetalRecipe("1", ModPetalRecipes.medumoneRecipe)); - - marimorphosis = new BLexiconEntry(LibLexicon.FFLOWER_MARIMORPHOSIS, categoryFunctionalFlowers); - marimorphosis.setLexiconPages( - new PageText("0"), - new PageImage("1", LibResources.ENTRY_METAMORPHIC_STONES), - new PagePetalRecipe("2", ModPetalRecipes.marimorphosisRecipe), - new PageCraftingRecipe("3", ModCraftingRecipes.recipesAltarMeta)); - - bubbell = new ALexiconEntry(LibLexicon.FFLOWER_BUBBELL, categoryFunctionalFlowers); - bubbell.setLexiconPages(new PageText("0"), new PagePetalRecipe("1", ModPetalRecipes.bubbellRecipe)); - - solegnolia = new BLexiconEntry(LibLexicon.FFLOWER_SOLEGNOLIA, categoryFunctionalFlowers); - solegnolia.setLexiconPages(new PageText("0"), new PagePetalRecipe("1", ModPetalRecipes.solegnoliaRecipe)); - - // GENERATING FLOWERS ENTRIES - if (ConfigHandler.hardcorePassiveGeneration > 0) { - generatingIntro = new BLexiconEntry(LibLexicon.GFLOWER_INTRO, categoryGenerationFlowers); - generatingIntro.setPriority().setLexiconPages(new PageText("0"), new PageText("1"), new PageText("2")); - } - - passiveGen = new BLexiconEntry(LibLexicon.GFLOWER_PASSIVE_GENERATION, categoryGenerationFlowers); - passiveGen - .setPriority() - .setLexiconPages(new PageText("0"), new PageText("1")) - .setIcon(new ItemStack(Blocks.deadbush)); - - primusLoci = new BLexiconEntry(LibLexicon.GFLOWER_PRIMUS_LOCI, categoryGenerationFlowers); - primusLoci.setPriority().setLexiconPages(new PageText("0"), new PageText("1")); - primusLoci.setIcon(ItemBlockSpecialFlower.ofType(LibBlockNames.SUBTILE_DAYBLOOM_PRIME)); - primusLoci.addExtraDisplayedRecipe(ItemBlockSpecialFlower.ofType(LibBlockNames.SUBTILE_DAYBLOOM_PRIME)); - primusLoci.addExtraDisplayedRecipe(ItemBlockSpecialFlower.ofType(LibBlockNames.SUBTILE_NIGHTSHADE_PRIME)); - - daybloom = new BLexiconEntry(LibLexicon.GFLOWER_DAYBLOOM, categoryGenerationFlowers); - daybloom.setPriority() - .setLexiconPages( - new PageText("0"), new PageText("1"), new PagePetalRecipe("2", ModPetalRecipes.daybloomRecipe)); - - nightshade = new BLexiconEntry(LibLexicon.GFLOWER_NIGHTSHADE, categoryGenerationFlowers); - nightshade.setLexiconPages(new PageText("0"), new PagePetalRecipe("1", ModPetalRecipes.nightshadeRecipe)); - - endoflame = new BLexiconEntry(LibLexicon.GFLOWER_ENDOFLAME, categoryGenerationFlowers); - endoflame.setLexiconPages( - new PageText("0"), - new PageText("1"), - new PageText("3"), - new PagePetalRecipe("2", ModPetalRecipes.endoflameRecipe)); - - hydroangeas = new BLexiconEntry(LibLexicon.GFLOWER_HYDROANGEAS, categoryGenerationFlowers); - hydroangeas.setLexiconPages( - new PageText("0"), - new PageImage("2", LibResources.ENTRY_HYDROANGEAS), - new PagePetalRecipe("1", ModPetalRecipes.hydroangeasRecipe)); - - thermalily = new BLexiconEntry(LibLexicon.GFLOWER_THERMALILY, categoryGenerationFlowers); - thermalily.setLexiconPages( - new PageText("0"), - new PageText("2"), - new PageText("3"), - new PagePetalRecipe("1", ModPetalRecipes.thermalilyRecipe)); - - arcaneRose = new BLexiconEntry(LibLexicon.GFLOWER_ARCANE_ROSE, categoryGenerationFlowers); - arcaneRose.setLexiconPages(new PageText("0"), new PagePetalRecipe("1", ModPetalRecipes.arcaneRoseRecipe)); - - munchdew = new BLexiconEntry(LibLexicon.GFLOWER_MUNCHDEW, categoryGenerationFlowers); - munchdew.setLexiconPages( - new PageText("0"), new PageText("1"), new PagePetalRecipe("2", ModPetalRecipes.munchdewRecipe)); - - entropinnyum = new BLexiconEntry(LibLexicon.GFLOWER_ENTROPINNYUM, categoryGenerationFlowers); - entropinnyum.setLexiconPages(new PageText("0"), new PagePetalRecipe("1", ModPetalRecipes.entropinnyumRecipe)); - - kekimurus = new ALexiconEntry(LibLexicon.GFLOWER_KEKIMURUS, categoryGenerationFlowers); - kekimurus.setLexiconPages(new PageText("0"), new PagePetalRecipe("1", ModPetalRecipes.kekimurusRecipe)); - - gourmaryllis = new BLexiconEntry(LibLexicon.GFLOWER_GOURMARYLLIS, categoryGenerationFlowers); - gourmaryllis.setLexiconPages( - new PageText("0"), - new PageText("1"), - new PageText("2"), - new PagePetalRecipe("3", ModPetalRecipes.gourmaryllisRecipe)); - - narslimmus = new BLexiconEntry(LibLexicon.GFLOWER_NARSLIMMUS, categoryGenerationFlowers); - narslimmus.setLexiconPages(new PageText("0"), new PagePetalRecipe("1", ModPetalRecipes.narslimmusRecipe)); - - spectrolus = new ALexiconEntry(LibLexicon.GFLOWER_SPECTROLUS, categoryGenerationFlowers); - spectrolus.setLexiconPages( - new PageText("0"), new PageText("1"), new PagePetalRecipe("2", ModPetalRecipes.spectrolusRecipe)); - - rafflowsia = new ALexiconEntry(LibLexicon.GFLOWER_RAFFLOWSIA, categoryGenerationFlowers); - rafflowsia.setLexiconPages( - new PageText("0"), - new PageText("1"), - new PageText("2"), - new PageText("3"), - new PagePetalRecipe("4", ModPetalRecipes.rafflowsiaRecipe)); - - dandelifeon = new ALexiconEntry(LibLexicon.GFLOWER_DANDELIFEON, categoryGenerationFlowers); - dandelifeon.setLexiconPages( - new PageText("_w"), - new PageText("0"), - new PageText("1"), - new PageText("2"), - new PageText("3"), - new PageText("4"), - new PageText("5"), - new PageText("6"), - new PageText("10"), - new PageText("7"), - new PagePetalRecipe("8", ModPetalRecipes.dandelifeonRecipe), - new PageCraftingRecipe("9", ModCraftingRecipes.recipeCellBlock)); - - // DEVICES ENTRIES - pylon = new BLexiconEntry(LibLexicon.DEVICE_PYLON, categoryDevices); - pylon.setLexiconPages(new PageText("0"), new PageCraftingRecipe("1", ModCraftingRecipes.recipePylon)); - - if (ConfigHandler.enchanterEnabled) { - manaEnchanting = new BLexiconEntry(LibLexicon.DEVICE_MANA_ENCHANTING, categoryDevices); - manaEnchanting - .setLexiconPages( - new PageText("0"), - new PageText("1"), - new PageMultiblock("2", ModMultiblocks.enchanter), - new PageText("5"), - new PageText("6"), - new PageText("7"), - new PageText("8"), - new PageText("9")) - .setIcon(new ItemStack(ModBlocks.enchanter)); - } - - turntable = new BLexiconEntry(LibLexicon.DEVICE_TURNTABLE, categoryDevices); - turntable.setLexiconPages(new PageText("0"), new PageCraftingRecipe("1", ModCraftingRecipes.recipeTurntable)); - - alchemy = new BLexiconEntry(LibLexicon.DEVICE_ALCHEMY, categoryDevices); - alchemy.setLexiconPages( - new PageText("0"), - new PageCraftingRecipe("1", ModCraftingRecipes.recipeAlchemyCatalyst), - new PageManaInfusionRecipe("2", ModManaAlchemyRecipes.leatherRecipe), - new PageManaInfusionRecipe("3", ModManaAlchemyRecipes.woodRecipes), - new PageManaInfusionRecipe("4", ModManaAlchemyRecipes.saplingRecipes), - new PageManaInfusionRecipe("5", ModManaAlchemyRecipes.glowstoneDustRecipe), - new PageManaInfusionRecipe("6", ModManaAlchemyRecipes.quartzRecipes).setSkipRegistry(), - new PageManaInfusionRecipe("7", ModManaAlchemyRecipes.chiseledBrickRecipe), - new PageManaInfusionRecipe("8", ModManaAlchemyRecipes.iceRecipe), - new PageManaInfusionRecipe("9", ModManaAlchemyRecipes.swampFolliageRecipes), - new PageManaInfusionRecipe("10", ModManaAlchemyRecipes.fishRecipes), - new PageManaInfusionRecipe("11", ModManaAlchemyRecipes.cropRecipes), - new PageManaInfusionRecipe("12", ModManaAlchemyRecipes.potatoRecipe), - new PageManaInfusionRecipe("13", ModManaAlchemyRecipes.netherWartRecipe), - new PageManaInfusionRecipe("14", ModManaAlchemyRecipes.gunpowderAndFlintRecipes), - new PageManaInfusionRecipe("15", ModManaAlchemyRecipes.nameTagRecipe), - new PageManaInfusionRecipe("16", ModManaAlchemyRecipes.stringRecipes), - new PageManaInfusionRecipe("17", ModManaAlchemyRecipes.slimeballCactusRecipes), - new PageManaInfusionRecipe("18", ModManaAlchemyRecipes.enderPearlRecipe), - new PageManaInfusionRecipe("19", ModManaAlchemyRecipes.redstoneToGlowstoneRecipes), - new PageManaInfusionRecipe("20", ModManaAlchemyRecipes.sandRecipe), - new PageManaInfusionRecipe("21", ModManaAlchemyRecipes.redSandRecipe), - new PageManaInfusionRecipe("22", ModManaAlchemyRecipes.clayBreakdownRecipes), - new PageManaInfusionRecipe("24", ModManaAlchemyRecipes.tallgrassRecipes), - new PageManaInfusionRecipe("25", ModManaAlchemyRecipes.flowersRecipes), - new PageManaInfusionRecipe("23", ModManaAlchemyRecipes.coarseDirtRecipe)); - - openCrate = new BLexiconEntry(LibLexicon.DEVICE_OPEN_CRATE, categoryDevices); - openCrate - .setPriority() - .setLexiconPages( - new PageText("0"), - new PageText("1"), - new PageCraftingRecipe("2", ModCraftingRecipes.recipeOpenCrate)); - - forestEye = new BLexiconEntry(LibLexicon.DEVICE_FOREST_EYE, categoryDevices); - forestEye.setLexiconPages( - new PageText("0"), new PageText("1"), new PageCraftingRecipe("2", ModCraftingRecipes.recipeForestEye)); - - forestDrum = new BLexiconEntry(LibLexicon.DEVICE_FOREST_DRUM, categoryDevices); - forestDrum.setLexiconPages( - new PageText("0"), new PageText("1"), new PageCraftingRecipe("2", ModCraftingRecipes.recipeForestDrum)); - - platform = new BLexiconEntry(LibLexicon.DEVICE_PLATFORM, categoryDevices); - platform.setLexiconPages( - new PageText("0"), new PageText("2"), new PageCraftingRecipe("1", ModCraftingRecipes.recipePlatform)); - - conjurationCatalyst = new ALexiconEntry(LibLexicon.DEVICE_MANA_CONJURATION, categoryDevices); - conjurationCatalyst.setLexiconPages( - new PageText("0"), - new PageCraftingRecipe("1", ModCraftingRecipes.recipeConjurationCatalyst), - new PageManaInfusionRecipe("2", ModManaConjurationRecipes.redstoneRecipe), - new PageManaInfusionRecipe("3", ModManaConjurationRecipes.glowstoneRecipe), - new PageManaInfusionRecipe("4", ModManaConjurationRecipes.quartzRecipe), - new PageManaInfusionRecipe("5", ModManaConjurationRecipes.coalRecipe), - new PageManaInfusionRecipe("6", ModManaConjurationRecipes.snowballRecipe), - new PageManaInfusionRecipe("7", ModManaConjurationRecipes.netherrackRecipe), - new PageManaInfusionRecipe("8", ModManaConjurationRecipes.soulSandRecipe), - new PageManaInfusionRecipe("9", ModManaConjurationRecipes.gravelRecipe), - new PageManaInfusionRecipe("10", ModManaConjurationRecipes.leavesRecipes), - new PageManaInfusionRecipe("11", ModManaConjurationRecipes.grassRecipe)); - - spectralPlatform = new ALexiconEntry(LibLexicon.DEVICE_SPECTRAL_PLATFORM, categoryDevices); - spectralPlatform.setLexiconPages( - new PageText("0"), new PageCraftingRecipe("1", ModCraftingRecipes.recipeSpectralPlatform)); - - gatherDrum = new ALexiconEntry(LibLexicon.DEVICE_GATHER_DRUM, categoryDevices); - gatherDrum.setLexiconPages(new PageText("0"), new PageCraftingRecipe("1", ModCraftingRecipes.recipeGatherDrum)); - - craftCrate = new ALexiconEntry(LibLexicon.DEVICE_CRAFT_CRATE, categoryDevices); - craftCrate - .setLexiconPages( - new PageText("0"), - new PageText("1"), - new PageCraftingRecipe("2", ModCraftingRecipes.recipePlaceholder), - new PageText("3"), - new PageText("4"), - new PageText("7"), - new PageImage("5", LibResources.ENTRY_CRAFT_CRATE), - new PageCraftingRecipe("6", ModCraftingRecipes.recipeCraftCrate), - new PageText("8"), - new PageCraftingRecipe("9", ModCraftingRecipes.recipesPatterns)) - .setIcon(new ItemStack(ModBlocks.openCrate, 1, 1)); - - brewery = new BLexiconEntry(LibLexicon.DEVICE_BREWERY, categoryDevices); - brewery.setLexiconPages( - new PageText("0"), - new PageText("1"), - new PageCraftingRecipe("2", ModCraftingRecipes.recipeBrewery), - new PageCraftingRecipe("3", ModCraftingRecipes.recipeVial), - new PageText("4"), - new PageBrew(ModBrewRecipes.speedBrew, "5a", "5b"), - new PageBrew(ModBrewRecipes.strengthBrew, "6a", "6b"), - new PageBrew(ModBrewRecipes.hasteBrew, "7a", "7b"), - new PageBrew(ModBrewRecipes.healingBrew, "8a", "8b"), - new PageBrew(ModBrewRecipes.jumpBoostBrew, "9a", "9b"), - new PageBrew(ModBrewRecipes.regenerationBrew, "10a", "10b"), - new PageBrew(ModBrewRecipes.weakRegenerationBrew, "17a", "17b"), - new PageBrew(ModBrewRecipes.resistanceBrew, "11a", "11b"), - new PageBrew(ModBrewRecipes.fireResistanceBrew, "12a", "12b"), - new PageBrew(ModBrewRecipes.waterBreathingBrew, "13a", "13b"), - new PageBrew(ModBrewRecipes.invisibilityBrew, "14a", "14b"), - new PageBrew(ModBrewRecipes.nightVisionBrew, "15a", "15b"), - new PageBrew(ModBrewRecipes.absorptionBrew, "16a", "16b")); - - flasks = new ALexiconEntry(LibLexicon.DEVICE_FLASKS, categoryDevices); - flasks.setLexiconPages( - new PageText("0"), new PageText("1"), new PageCraftingRecipe("2", ModCraftingRecipes.recipeFlask)); - - complexBrews = new BLexiconEntry(LibLexicon.DEVICE_COMPLEX_BREWS, categoryDevices); - complexBrews - .setLexiconPages( - new PageText("0"), - new PageBrew(ModBrewRecipes.overloadBrew, "1a", "1b"), - new PageBrew(ModBrewRecipes.soulCrossBrew, "2a", "2b"), - new PageBrew(ModBrewRecipes.featherFeetBrew, "3a", "3b"), - new PageBrew(ModBrewRecipes.emptinessBrew, "4a", "4b"), - new PageBrew(ModBrewRecipes.bloodthirstBrew, "5a", "5b"), - new PageBrew(ModBrewRecipes.allureBrew, "6a", "6b"), - new PageBrew(ModBrewRecipes.clearBrew, "7a", "7b")) - .setIcon(((IBrewContainer) ModItems.vial) - .getItemForBrew(ModBrews.jumpBoost, new ItemStack(ModItems.vial))); - - incense = new BLexiconEntry(LibLexicon.DEVICE_INCENSE, categoryDevices); - incense.setLexiconPages( - new PageText("0"), - new PageText("1"), - new PageText("2"), - new PageText("5"), - new PageCraftingRecipe("3", ModCraftingRecipes.recipeIncenseStick), - new PageCraftingRecipe("4", ModCraftingRecipes.recipeIncensePlate)); - - hourglass = new BLexiconEntry(LibLexicon.DEVICE_HOURGLASS, categoryDevices); - hourglass - .setPriority() - .setLexiconPages( - new PageText("0"), - new PageText("1"), - new PageText("2"), - new PageText("3"), - new PageText("4"), - new PageCraftingRecipe("5", ModCraftingRecipes.recipeHourglass)); - - ghostRail = new ALexiconEntry(LibLexicon.DEVICE_GHOST_RAIL, categoryDevices); - ghostRail.setLexiconPages(new PageText("0"), new PageCraftingRecipe("1", ModCraftingRecipes.recipeGhostRail)); - - canopyDrum = new BLexiconEntry(LibLexicon.DEVICE_CANOPY_DRUM, categoryDevices); - canopyDrum.setLexiconPages(new PageText("0"), new PageCraftingRecipe("1", ModCraftingRecipes.recipeCanopyDrum)); - - cocoon = Botania.gardenOfGlassLoaded - ? new BLexiconEntry(LibLexicon.DEVICE_COCOON, categoryDevices) - : new ALexiconEntry(LibLexicon.DEVICE_COCOON, categoryDevices); - cocoon.setLexiconPages( - new PageText("0"), new PageText("1"), new PageCraftingRecipe("2", ModCraftingRecipes.recipeCocoon)); - - manaBomb = new ALexiconEntry(LibLexicon.DEVICE_MANA_BOMB, categoryDevices); - manaBomb.setLexiconPages(new PageText("0"), new PageCraftingRecipe("1", ModCraftingRecipes.recipeManaBomb)); - - teruTeruBozu = new BLexiconEntry(LibLexicon.DEVICE_TERU_TERU_BOZU, categoryDevices); - teruTeruBozu.setLexiconPages( - new PageText("0"), new PageCraftingRecipe("1", ModCraftingRecipes.recipeTeruTeruBozu)); - - avatar = new BLexiconEntry(LibLexicon.DEVICE_AVATAR, categoryDevices); - avatar.setLexiconPages( - new PageText("0"), new PageText("1"), new PageCraftingRecipe("2", ModCraftingRecipes.recipeAvatar)); - - felPumpkin = new BLexiconEntry(LibLexicon.DEVICE_FEL_PUMPKIN, categoryDevices); - felPumpkin.setLexiconPages(new PageText("0"), new PageCraftingRecipe("1", ModCraftingRecipes.recipeFelPumpkin)); - - // TOOLS ENTRIES - manaBlaster = new BLexiconEntry(LibLexicon.TOOL_MANA_BLASTER, categoryTools); - manaBlaster.setLexiconPages( - new PageText("0"), - new PageText("1"), - new PageText("2"), - new PageCraftingRecipe("3", ModCraftingRecipes.recipeManaBlaster)); - - grassSeeds = new BLexiconEntry(LibLexicon.TOOL_GRASS_SEEDS, categoryTools); - grassSeeds.setLexiconPages( - new PageText("0"), - new PageManaInfusionRecipe("1", ModManaInfusionRecipes.grassSeedsRecipe), - new PageManaInfusionRecipe("2", ModManaInfusionRecipes.podzolSeedsRecipe), - new PageManaInfusionRecipe("3", ModManaInfusionRecipes.mycelSeedsRecipes), - new PageText("4"), - new PageCraftingRecipe("5", ModCraftingRecipes.recipesAltGrassSeeds)); - - dirtRod = new BLexiconEntry(LibLexicon.TOOL_DIRT_ROD, categoryTools); - dirtRod.setLexiconPages(new PageText("0"), new PageCraftingRecipe("1", ModCraftingRecipes.recipeDirtRod)); - - terraformRod = new BLexiconEntry(LibLexicon.TOOL_TERRAFORM_ROD, categoryTools); - terraformRod.setLexiconPages( - new PageText("0"), - new PageText("1"), - new PageText("2"), - new PageCraftingRecipe("3", ModCraftingRecipes.recipeTerraformRod)); - - manasteelGear = new BLexiconEntry(LibLexicon.TOOL_MANASTEEL_GEAR, categoryTools); - manasteelGear - .setPriority() - .setLexiconPages( - new PageText("0"), - new PageText("10"), - new PageCraftingRecipe("1", ModCraftingRecipes.recipeManasteelPick), - new PageCraftingRecipe("2", ModCraftingRecipes.recipeManasteelShovel), - new PageCraftingRecipe("3", ModCraftingRecipes.recipeManasteelAxe), - new PageCraftingRecipe("4", ModCraftingRecipes.recipeManasteelShears), - new PageCraftingRecipe("5", ModCraftingRecipes.recipeManasteelSword), - new PageCraftingRecipe("6", ModCraftingRecipes.recipeManasteelHelm), - new PageCraftingRecipe("7", ModCraftingRecipes.recipeManasteelChest), - new PageCraftingRecipe("8", ModCraftingRecipes.recipeManasteelLegs), - new PageCraftingRecipe("9", ModCraftingRecipes.recipeManasteelBoots)); - - terrasteelArmor = new BLexiconEntry(LibLexicon.TOOL_TERRASTEEL_ARMOR, categoryTools); - terrasteelArmor.setLexiconPages( - new PageText("0"), - new PageCraftingRecipe("1", ModCraftingRecipes.recipeTerrasteelHelm), - new PageCraftingRecipe("2", ModCraftingRecipes.recipeTerrasteelChest), - new PageCraftingRecipe("3", ModCraftingRecipes.recipeTerrasteelLegs), - new PageCraftingRecipe("4", ModCraftingRecipes.recipeTerrasteelBoots)); - - grassHorn = new BLexiconEntry(LibLexicon.TOOL_GRASS_HORN, categoryTools); - grassHorn.setLexiconPages( - new PageText("0"), - new PageCraftingRecipe("1", ModCraftingRecipes.recipeGrassHorn), - new PageCraftingRecipe("2", ModCraftingRecipes.recipeLeafHorn), - new PageCraftingRecipe("3", ModCraftingRecipes.recipeSnowHorn)); - - terraBlade = new BLexiconEntry(LibLexicon.TOOL_TERRA_SWORD, categoryTools); - terraBlade.setLexiconPages(new PageText("0"), new PageCraftingRecipe("1", ModCraftingRecipes.recipeTerraSword)); - - terraPick = new BLexiconEntry(LibLexicon.TOOL_TERRA_PICK, categoryTools); - terraPick.setLexiconPages( - new PageText("0"), - new PageText("1"), - new PageText("2"), - new PageText("3"), - new PageText("4"), - new PageCraftingRecipe("5", ModCraftingRecipes.recipeTerraPick)); - - waterRod = new BLexiconEntry(LibLexicon.TOOL_WATER_ROD, categoryTools); - waterRod.setLexiconPages(new PageText("0"), new PageCraftingRecipe("1", ModCraftingRecipes.recipeWaterRod)); - - elfGear = new ALexiconEntry(LibLexicon.TOOL_ELF_GEAR, categoryTools); - elfGear.setLexiconPages( - new PageText("0"), - new PageText("1"), - new PageText("2"), - new PageCraftingRecipe("3", ModCraftingRecipes.recipeElementiumPick), - new PageText("4"), - new PageCraftingRecipe("5", ModCraftingRecipes.recipeElementiumShovel), - new PageText("6"), - new PageCraftingRecipe("7", ModCraftingRecipes.recipeElementiumAxe), - new PageText("8"), - new PageCraftingRecipe("9", ModCraftingRecipes.recipeElementiumShears), - new PageText("10"), - new PageCraftingRecipe("11", ModCraftingRecipes.recipeElementiumSword), - new PageCraftingRecipe("12", ModCraftingRecipes.recipeElementiumHelm), - new PageCraftingRecipe("13", ModCraftingRecipes.recipeElementiumChest), - new PageCraftingRecipe("14", ModCraftingRecipes.recipeElementiumLegs), - new PageCraftingRecipe("15", ModCraftingRecipes.recipeElementiumBoots)); - - openBucket = new ALexiconEntry(LibLexicon.TOOL_OPEN_BUCKET, categoryTools); - openBucket.setLexiconPages(new PageText("0"), new PageCraftingRecipe("1", ModCraftingRecipes.recipeOpenBucket)); - - rainbowRod = new ALexiconEntry(LibLexicon.TOOL_RAINBOW_ROD, categoryTools); - rainbowRod.setLexiconPages( - new PageText("0"), - new PageText("1"), - new PageText("6"), - new PageCraftingRecipe("2", ModCraftingRecipes.recipeRainbowRod), - new PageCraftingRecipe("3", ModCraftingRecipes.recipeBifrost), - new PageCraftingRecipe("4", ModCraftingRecipes.recipeShimmerrock), - new PageCraftingRecipe("5", ModCraftingRecipes.recipeShimmerwoodPlanks), - new PageCraftingRecipe("7", ModCraftingRecipes.recipePoolFabulous)); - - tornadoRod = new BLexiconEntry(LibLexicon.TOOL_TORNADO_ROD, categoryTools); - tornadoRod.setLexiconPages( - new PageText("0"), new PageText("2"), new PageCraftingRecipe("1", ModCraftingRecipes.recipeTornadoRod)); - - fireRod = new BLexiconEntry(LibLexicon.TOOL_FIRE_ROD, categoryTools); - fireRod.setLexiconPages( - new PageText("0"), new PageText("2"), new PageCraftingRecipe("1", ModCraftingRecipes.recipeFireRod)); - - vineBall = new BLexiconEntry(LibLexicon.TOOL_VINE_BALL, categoryTools); - vineBall.setLexiconPages( - new PageText("0"), - new PageText("1"), - new PageCraftingRecipe("2", ModCraftingRecipes.recipeVineBall), - new PageCraftingRecipe("3", ModCraftingRecipes.recipeSlingshot), - new PageCraftingRecipe("4", ModCraftingRecipes.recipeMossStone)); - - laputaShard = new ALexiconEntry(LibLexicon.TOOL_LAPUTA_SHARD, categoryTools); - laputaShard.setLexiconPages( - new PageText("0"), - new PageText("2"), - new PageCraftingRecipe("1", ModCraftingRecipes.recipesLaputaShard), - new PageCraftingRecipe("3", ModCraftingRecipes.recipesLaputaShardUpgrade)); - - virus = new ALexiconEntry(LibLexicon.TOOL_VIRUS, categoryTools); - virus.setLexiconPages( - new PageText("0"), - new PageCraftingRecipe("1", ModCraftingRecipes.recipeVirusZombie), - new PageCraftingRecipe("2", ModCraftingRecipes.recipeVirusSkeleton)); - - skyDirtRod = new ALexiconEntry(LibLexicon.TOOL_SKY_DIRT_ROD, categoryTools); - skyDirtRod.setLexiconPages(new PageText("0"), new PageCraftingRecipe("1", ModCraftingRecipes.recipeSkyDirtRod)); - - glassPick = new BLexiconEntry(LibLexicon.TOOL_GLASS_PICK, categoryTools); - glassPick.setLexiconPages(new PageText("0"), new PageCraftingRecipe("1", ModCraftingRecipes.recipeGlassPick)); - - diviningRod = new BLexiconEntry(LibLexicon.TOOL_DIVINING_ROD, categoryTools); - diviningRod.setLexiconPages( - new PageText("0"), - new PageText("2"), - new PageCraftingRecipe("1", ModCraftingRecipes.recipeDiviningRod)); - - gravityRod = new ALexiconEntry(LibLexicon.TOOL_GRAVITY_ROD, categoryTools); - gravityRod.setLexiconPages( - new PageText("0"), new PageText("1"), new PageCraftingRecipe("2", ModCraftingRecipes.recipeGravityRod)); - - regenIvy = new ALexiconEntry(LibLexicon.TOOL_REGEN_IVY, categoryTools); - regenIvy.setLexiconPages( - new PageText("0"), new PageText("1"), new PageCraftingRecipe("2", ModCraftingRecipes.recipeRegenIvy)); - - missileRod = new ALexiconEntry(LibLexicon.TOOL_MISSILE_ROD, categoryTools); - missileRod.setLexiconPages( - new PageText("0"), new PageText("2"), new PageCraftingRecipe("1", ModCraftingRecipes.recipeMissileRod)); - - craftingHalo = new BLexiconEntry(LibLexicon.TOOL_CRAFTING_HALO, categoryTools); - craftingHalo.setLexiconPages( - new PageText("0"), - new PageText("1"), - new PageCraftingRecipe("2", ModCraftingRecipes.recipeCraftingHalo)); - - clip = new ALexiconEntry(LibLexicon.TOOL_CLIP, categoryTools); - clip.setLexiconPages( - new PageText("0"), new PageText("1"), new PageCraftingRecipe("2", ModCraftingRecipes.recipeClip)); - - cobbleRod = new BLexiconEntry(LibLexicon.TOOL_COBBLE_ROD, categoryTools); - cobbleRod.setLexiconPages(new PageText("0"), new PageCraftingRecipe("1", ModCraftingRecipes.recipeCobbleRod)); - - smeltRod = new BLexiconEntry(LibLexicon.TOOL_SMELT_ROD, categoryTools); - smeltRod.setLexiconPages(new PageText("0"), new PageCraftingRecipe("1", ModCraftingRecipes.recipeSmeltRod)); - - worldSeed = new ALexiconEntry(LibLexicon.TOOL_WORLD_SEED, categoryTools); - worldSeed.setLexiconPages(new PageText("0"), new PageCraftingRecipe("1", ModCraftingRecipes.recipeWorldSeed)); - - spellCloth = new BLexiconEntry(LibLexicon.TOOL_SPELL_CLOTH, categoryTools); - spellCloth.setLexiconPages(new PageText("0"), new PageCraftingRecipe("1", ModCraftingRecipes.recipeSpellCloth)); - - thornChakram = new BLexiconEntry(LibLexicon.TOOL_THORN_CHAKRAM, categoryTools); - thornChakram.setLexiconPages( - new PageText("0"), new PageCraftingRecipe("1", ModCraftingRecipes.recipeThornChakram)); - - fireChakram = new ALexiconEntry(LibLexicon.TOOL_FIRE_CHAKRAM, categoryTools); - fireChakram.setLexiconPages( - new PageText("0"), new PageCraftingRecipe("1", ModCraftingRecipes.recipeFireChakram)); - - overgrowthSeed = new BLexiconEntry(LibLexicon.TOOL_OVERGROWTH_SEED, categoryTools); - overgrowthSeed - .setPriority() - .setLexiconPages(new PageText("0"), new PageText("1")) - .setIcon(new ItemStack(ModItems.overgrowthSeed)); - overgrowthSeed.addExtraDisplayedRecipe(new ItemStack(ModItems.overgrowthSeed)); - overgrowthSeed.addExtraDisplayedRecipe(new ItemStack(ModBlocks.enchantedSoil)); - - livingwoodBow = new BLexiconEntry(LibLexicon.TOOL_LIVINGWOOD_BOW, categoryTools); - livingwoodBow.setLexiconPages( - new PageText("0"), new PageCraftingRecipe("1", ModCraftingRecipes.recipeLivingwoodBow)); - - crystalBow = new ALexiconEntry(LibLexicon.TOOL_CRYSTAL_BOW, categoryTools); - crystalBow.setLexiconPages(new PageText("0"), new PageCraftingRecipe("1", ModCraftingRecipes.recipeCrystalBow)); - - temperanceStone = new BLexiconEntry(LibLexicon.TOOL_TEMPERANCE_STONE, categoryTools); - temperanceStone.setLexiconPages( - new PageText("0"), new PageCraftingRecipe("1", ModCraftingRecipes.recipeTemperanceStone)); - - terraAxe = new BLexiconEntry(LibLexicon.TOOL_TERRA_AXE, categoryTools); - terraAxe.setLexiconPages(new PageText("0"), new PageCraftingRecipe("1", ModCraftingRecipes.recipeTerraAxe)); - - obedienceStick = new BLexiconEntry(LibLexicon.TOOL_OBEDIENCE_STICK, categoryTools); - obedienceStick - .setPriority() - .setLexiconPages( - new PageText("0"), new PageCraftingRecipe("1", ModCraftingRecipes.recipeObedienceStick)); - - slimeBottle = new ALexiconEntry(LibLexicon.TOOL_SLIME_BOTTLE, categoryTools); - slimeBottle.setLexiconPages( - new PageText("0"), new PageCraftingRecipe("1", ModCraftingRecipes.recipeSlimeBottle)); - - exchangeRod = new BLexiconEntry(LibLexicon.TOOL_EXCHANGE_ROD, categoryTools); - exchangeRod.setLexiconPages( - new PageText("0"), - new PageText("1"), - new PageText("2"), - new PageCraftingRecipe("3", ModCraftingRecipes.recipeExchangeRod)); - - manaweave = new BLexiconEntry(LibLexicon.TOOL_MANAWEAVE, categoryTools); - manaweave.setLexiconPages( - new PageText("0"), - new PageText("1"), - new PageCraftingRecipe("2", ModCraftingRecipes.recipeManaweaveCloth), - new PageCraftingRecipe("3", ModCraftingRecipes.recipeManaweaveHelm), - new PageCraftingRecipe("4", ModCraftingRecipes.recipeManaweaveChest), - new PageCraftingRecipe("5", ModCraftingRecipes.recipeManaweaveLegs), - new PageCraftingRecipe("6", ModCraftingRecipes.recipeManaweaveBoots)); - - autocraftingHalo = new BLexiconEntry(LibLexicon.TOOL_AUTOCRAFTING_HALO, categoryTools); - autocraftingHalo.setLexiconPages( - new PageText("0"), new PageCraftingRecipe("1", ModCraftingRecipes.recipeAutocraftingHalo)); - - sextant = new BLexiconEntry(LibLexicon.TOOL_SEXTANT, categoryTools); - sextant.setLexiconPages( - new PageText("0"), new PageText("1"), new PageCraftingRecipe("2", ModCraftingRecipes.recipeSextant)); - - // ENDER ENTRIES - enderAir = new BLexiconEntry(LibLexicon.ENDER_AIR, categoryEnder); - enderAir.setPriority().setLexiconPages(new PageText("0")); - enderAir.addExtraDisplayedRecipe(new ItemStack(ModItems.manaResource, 1, 15)); - LexiconRecipeMappings.map(new ItemStack(ModItems.manaResource, 1, 15), enderAir, 0); - - enderEyeBlock = new BLexiconEntry(LibLexicon.ENDER_ENDER_EYE_BLOCK, categoryEnder); - enderEyeBlock.setLexiconPages( - new PageText("0"), new PageCraftingRecipe("1", ModCraftingRecipes.recipeEnderEyeBlock)); - - pistonRelay = new BLexiconEntry(LibLexicon.ENDER_PISTON_RELAY, categoryEnder); - pistonRelay.setLexiconPages( - new PageText("0"), - new PageText("1"), - new PageManaInfusionRecipe("2", ModManaInfusionRecipes.pistonRelayRecipe)); - - enderHand = new BLexiconEntry(LibLexicon.ENDER_ENDER_HAND, categoryEnder); - enderHand.setLexiconPages( - new PageText(ConfigHandler.enderPickpocketEnabled ? "0" : "0a"), - new PageText("2"), - new PageCraftingRecipe( - ConfigHandler.enderPickpocketEnabled ? "1" : "1a", ModCraftingRecipes.recipeEnderHand)); - - enderDagger = new BLexiconEntry(LibLexicon.ENDER_ENDER_DAGGER, categoryEnder); - enderDagger.setLexiconPages( - new PageText("0"), - new PageText("1"), - new PageCraftingRecipe("2", ModCraftingRecipes.recipeEnderDagger)); - - spawnerClaw = new ALexiconEntry(LibLexicon.ENDER_SPAWNER_CLAW, categoryEnder); - spawnerClaw.setLexiconPages( - new PageText("0"), - new PageText("1"), - new PageCraftingRecipe("2", ModCraftingRecipes.recipeSpawnerClaw)); - - redString = new ALexiconEntry(LibLexicon.ENDER_RED_STRING, categoryEnder); - redString.setLexiconPages( - new PageText("0"), - new PageText("1"), - new PageCraftingRecipe("2", ModCraftingRecipes.recipeRedString), - new PageText("3"), - new PageCraftingRecipe("4", ModCraftingRecipes.recipeRedStringContainer), - new PageText("5"), - new PageCraftingRecipe("6", ModCraftingRecipes.recipeRedStringDispenser), - new PageText("7"), - new PageCraftingRecipe("8", ModCraftingRecipes.recipeRedStringFertilizer), - new PageText("9"), - new PageCraftingRecipe("10", ModCraftingRecipes.recipeRedStringComparator), - new PageText("11"), - new PageCraftingRecipe("12", ModCraftingRecipes.recipeRedStringRelay), - new PageText("13"), - new PageCraftingRecipe("14", ModCraftingRecipes.recipeRedStringInterceptor)); - - flightTiara = new ALexiconEntry(LibLexicon.ENDER_FLIGHT_TIARA, categoryEnder); - flightTiara.setLexiconPages( - new PageText("0"), - new PageText("4"), - new PageText("5"), - new PageText("6"), - new PageCraftingRecipe("1", ModCraftingRecipes.recipeFlightTiara), - new PageText("2"), - new PageCraftingRecipe("3", ModCraftingRecipes.recipesWings)); - - corporea = new ALexiconEntry(LibLexicon.ENDER_CORPOREA, categoryEnder); - corporea.setLexiconPages( - new PageText("0"), - new PageText("1"), - new PageText("2"), - new PageText("3"), - new PageText("4"), - new PageText("5"), - new PageText("6"), - new PageCraftingRecipe("7", ModCraftingRecipes.recipeCorporeaSpark), - new PageCraftingRecipe("8", ModCraftingRecipes.recipeMasterCorporeaSpark)); - - corporeaIndex = new ALexiconEntry(LibLexicon.ENDER_CORPOREA_INDEX, categoryEnder); - corporeaIndex.setLexiconPages( - new PageText("0"), - new PageText("1"), - new PageText("2"), - new PageText("3"), - new PageText("4"), - new PageText("5"), - new PageText("8"), - new PageText("6"), - new PageCraftingRecipe("7", ModCraftingRecipes.recipeCorporeaIndex)); - - corporeaFunnel = new ALexiconEntry(LibLexicon.ENDER_CORPOREA_FUNNEL, categoryEnder); - corporeaFunnel.setLexiconPages( - new PageText("0"), - new PageText("1"), - new PageCraftingRecipe("2", ModCraftingRecipes.recipeCorporeaFunnel)); - - corporeaInterceptor = new ALexiconEntry(LibLexicon.ENDER_CORPOREA_INTERCEPTOR, categoryEnder); - corporeaInterceptor.setLexiconPages( - new PageText("0"), - new PageText("1"), - new PageCraftingRecipe("2", ModCraftingRecipes.recipeCorporeaInterceptor)); - - if (ConfigHandler.enderStuff19Enabled) { - endStoneDecor = new BLexiconEntry(LibLexicon.ENDER_END_STONE_DECOR, categoryEnder); - endStoneDecor.setLexiconPages( - new PageText("0"), - new PageCraftingRecipe("1", ModCraftingRecipes.recipeEndStoneBricks), - new PageCraftingRecipe("2", ModCraftingRecipes.recipeEndStoneChiseledBricks), - new PageCraftingRecipe("3", ModCraftingRecipes.recipeEnderBricks), - new PageCraftingRecipe("4", ModCraftingRecipes.recipePillarEnderBricks)); - } - - spawnerMover = new ALexiconEntry(LibLexicon.ENDER_SPAWNER_MOVER, categoryEnder); - spawnerMover.setLexiconPages( - new PageText("0"), new PageCraftingRecipe("1", ModCraftingRecipes.recipeSpawnerMover)); - - keepIvy = new ALexiconEntry(LibLexicon.ENDER_KEEP_IVY, categoryEnder); - keepIvy.setLexiconPages( - new PageText("0"), new PageText("2"), new PageCraftingRecipe("1", ModCraftingRecipes.recipeKeepIvy)); - - blackHoleTalisman = new ALexiconEntry(LibLexicon.ENDER_BLACK_HOLE_TALISMAN, categoryEnder); - blackHoleTalisman.setLexiconPages( - new PageText("0"), - new PageText("1"), - new PageText("2"), - new PageCraftingRecipe("3", ModCraftingRecipes.recipeBlackHoleTalisman)); - - corporeaCrystalCube = new ALexiconEntry(LibLexicon.ENDER_CORPOREA_CRYSTAL_CUBE, categoryEnder); - corporeaCrystalCube.setLexiconPages( - new PageText("0"), - new PageText("1"), - new PageText("3"), - new PageCraftingRecipe("2", ModCraftingRecipes.recipeCorporeaCrystalCube)); - - luminizerTransport = new ALexiconEntry(LibLexicon.ENDER_LUMINIZER_TRANSPORT, categoryEnder); - luminizerTransport.setLexiconPages( - new PageText("0"), - new PageText("1"), - new PageCraftingRecipe("2", ModCraftingRecipes.recipeLuminizer), - new PageText("3"), - new PageCraftingRecipe("4", ModCraftingRecipes.recipeDetectorLuminizer), - new PageText("5"), - new PageCraftingRecipe("6", ModCraftingRecipes.recipeLuminizerLauncher)); - - starSword = new ALexiconEntry(LibLexicon.ENDER_STAR_SWORD, categoryEnder); - starSword.setLexiconPages(new PageText("0"), new PageCraftingRecipe("1", ModCraftingRecipes.recipeStarSword)); - - thunderSword = new ALexiconEntry(LibLexicon.ENDER_THUNDER_SWORD, categoryEnder); - thunderSword.setLexiconPages( - new PageText("0"), new PageCraftingRecipe("1", ModCraftingRecipes.recipeThunderSword)); - - corporeaRetainer = new ALexiconEntry(LibLexicon.ENDER_CORPOREA_RETAINER, categoryEnder); - corporeaRetainer.setLexiconPages( - new PageText("0"), - new PageText("1"), - new PageText("2"), - new PageCraftingRecipe("3", ModCraftingRecipes.recipeCorporeaRetainer)); - - // BAUBLES ENTRIES - baublesIntro = new BLexiconEntry(LibLexicon.BAUBLE_INTRO, categoryBaubles); - baublesIntro - .setPriority() - .setLexiconPages(new PageText("0"), new PageImage("1", LibResources.ENTRY_BAUBLES), new PageText("2")); - - cosmeticBaubles = new BLexiconEntry(LibLexicon.BAUBLE_COSMETIC, categoryBaubles); - { - List pages = new ArrayList(); - pages.add(new PageText("0")); - pages.add(new PageText("1")); - if (ModCraftingRecipes.recipesCosmeticItems != null) { - for (int i = 0; i < 32; i++) { - pages.add(new PageCraftingRecipe("" + (i + 2), ModCraftingRecipes.recipesCosmeticItems.get(i))); - } - } - cosmeticBaubles.setPriority().setLexiconPages(pages.toArray(new LexiconPage[pages.size()])); - } - - tinyPlanet = new BLexiconEntry(LibLexicon.BAUBLE_TINY_PLANET, categoryBaubles); - tinyPlanet.setLexiconPages( - new PageText("0"), - new PageCraftingRecipe("1", ModCraftingRecipes.recipeTinyPlanet), - new PageCraftingRecipe("2", ModCraftingRecipes.recipeTinyPlanetBlock)); - - manaRing = new BLexiconEntry(LibLexicon.BAUBLE_MANA_RING, categoryBaubles); - manaRing.setLexiconPages( - new PageText("0"), - new PageCraftingRecipe("1", ModCraftingRecipes.recipeManaRing), - new PageCraftingRecipe("2", ModCraftingRecipes.recipeGreaterManaRing)); - - auraRing = new BLexiconEntry(LibLexicon.BAUBLE_AURA_RING, categoryBaubles); - auraRing.setLexiconPages( - new PageText("0"), - new PageCraftingRecipe("1", ModCraftingRecipes.recipeAuraRing), - new PageCraftingRecipe("2", ModCraftingRecipes.recipeGreaterAuraRing)); - - travelBelt = new BLexiconEntry(LibLexicon.BAUBLE_TRAVEL_BELT, categoryBaubles); - travelBelt.setLexiconPages(new PageText("0"), new PageCraftingRecipe("1", ModCraftingRecipes.recipeTravelBelt)); - - knockbacklBelt = new BLexiconEntry(LibLexicon.BAUBLE_KNOCKBACK_BELT, categoryBaubles); - knockbacklBelt.setLexiconPages( - new PageText("0"), new PageCraftingRecipe("1", ModCraftingRecipes.recipeKnocbackBelt)); - - icePendant = new BLexiconEntry(LibLexicon.BAUBLE_ICE_PENDANT, categoryBaubles); - icePendant.setLexiconPages(new PageText("0"), new PageCraftingRecipe("1", ModCraftingRecipes.recipeIcePendant)); - - lavaPendant = new BLexiconEntry(LibLexicon.BAUBLE_LAVA_PENDANT, categoryBaubles); - lavaPendant.setLexiconPages( - new PageText("0"), new PageCraftingRecipe("1", ModCraftingRecipes.recipeFirePendant)); - - goldLaurel = new ALexiconEntry(LibLexicon.BAUBLE_GOLDEN_LAUREL, categoryBaubles); - goldLaurel.setLexiconPages( - new PageText("0"), new PageCraftingRecipe("1", ModCraftingRecipes.recipeGoldenLaurel)); - - waterRing = new BLexiconEntry(LibLexicon.BAUBLE_WATER_RING, categoryBaubles); - waterRing.setLexiconPages(new PageText("0"), new PageCraftingRecipe("1", ModCraftingRecipes.recipeWaterRing)); - - miningRing = new BLexiconEntry(LibLexicon.BAUBLE_MINING_RING, categoryBaubles); - miningRing.setLexiconPages(new PageText("0"), new PageCraftingRecipe("1", ModCraftingRecipes.recipeMiningRing)); - - magnetRing = new BLexiconEntry(LibLexicon.BAUBLE_MAGNET_RING, categoryBaubles); - magnetRing.setLexiconPages( - new PageText("0"), - new PageCraftingRecipe("1", ModCraftingRecipes.recipeMagnetRing), - new PageCraftingRecipe("2", ModCraftingRecipes.recipeGreaterMagnetRing)); - - divaCharm = new ALexiconEntry(LibLexicon.BAUBLE_DIVA_CHARM, categoryBaubles); - divaCharm.setLexiconPages(new PageText("0"), new PageCraftingRecipe("1", ModCraftingRecipes.recipeDivaCharm)); - - pixieRing = new ALexiconEntry(LibLexicon.BAUBLE_PIXIE_RING, categoryBaubles); - pixieRing.setLexiconPages(new PageText("0"), new PageCraftingRecipe("1", ModCraftingRecipes.recipePixieRing)); - - superTravelBelt = new ALexiconEntry(LibLexicon.BAUBLE_SUPER_TRAVEL_BELT, categoryBaubles); - superTravelBelt.setLexiconPages( - new PageText("0"), new PageCraftingRecipe("1", ModCraftingRecipes.recipeSuperTravelBelt)); - - reachRing = new ALexiconEntry(LibLexicon.BAUBLE_REACH_RING, categoryBaubles); - reachRing.setLexiconPages(new PageText("0"), new PageCraftingRecipe("1", ModCraftingRecipes.recipeReachRing)); - - itemFinder = new BLexiconEntry(LibLexicon.BAUBLE_ITEM_FINDER, categoryBaubles); - itemFinder.setLexiconPages( - new PageText("0"), new PageText("1"), new PageCraftingRecipe("2", ModCraftingRecipes.recipeItemFinder)); - - superLavaPendant = new ALexiconEntry(LibLexicon.BAUBLE_SUPER_LAVA_PENDANT, categoryBaubles); - superLavaPendant.setLexiconPages( - new PageText("0"), new PageCraftingRecipe("1", ModCraftingRecipes.recipeSuperLavaPendant)); - - bloodPendant = new BLexiconEntry(LibLexicon.BAUBLE_BLOOD_PENDANT, categoryBaubles); - bloodPendant.setLexiconPages( - new PageText("0"), - new PageText("1"), - new PageCraftingRecipe("2", ModCraftingRecipes.recipeBloodPendant)); - - judgementCloaks = new ALexiconEntry(LibLexicon.BAUBLE_JUDGEMENT_CLOAKS, categoryBaubles); - judgementCloaks.setLexiconPages( - new PageText("0"), - new PageText("1"), - new PageCraftingRecipe("2", ModCraftingRecipes.recipeHolyCloak), - new PageCraftingRecipe("3", ModCraftingRecipes.recipeUnholyCloak)); - - monocle = new BLexiconEntry(LibLexicon.BAUBLE_MONOCLE, categoryBaubles); - monocle.setPriority() - .setLexiconPages( - new PageText("0"), - new PageText("2"), - new PageCraftingRecipe("1", ModCraftingRecipes.recipeMonocle)); - - swapRing = new BLexiconEntry(LibLexicon.BAUBLE_SWAP_RING, categoryBaubles); - swapRing.setLexiconPages(new PageText("0"), new PageCraftingRecipe("1", ModCraftingRecipes.recipeSwapRing)); - - speedUpBelt = new BLexiconEntry(LibLexicon.BAUBLE_SPEED_UP_BELT, categoryBaubles); - speedUpBelt.setLexiconPages( - new PageText("0"), new PageCraftingRecipe("1", ModCraftingRecipes.recipeSpeedUpBelt)); - - baubleBox = new BLexiconEntry(LibLexicon.BAUBLE_BOX, categoryBaubles); - baubleBox - .setLexiconPages(new PageText("0"), new PageCraftingRecipe("1", ModCraftingRecipes.recipeBaubleCase)) - .setPriority(); - - // ALFHOMANCY ENTRIES - alfhomancyIntro = new BLexiconEntry(LibLexicon.ALF_INTRO, categoryAlfhomancy); - alfhomancyIntro - .setPriority() - .setLexiconPages( - new PageText("0"), - new PageText("1"), - new PageCraftingRecipe("2", ModCraftingRecipes.recipeAlfPortal), - new PageCraftingRecipe("3", ModCraftingRecipes.recipeNaturaPylon), - new PageMultiblock("4", ModMultiblocks.alfPortal), - new PageText("5"), - new PageText("6"), - new PageText("7")) - .setIcon(new ItemStack(ModItems.lexicon)); - - elvenMessage = new ALexiconEntry(LibLexicon.ALF_MESSAGE, categoryAlfhomancy); - elvenMessage - .setPriority() - .setLexiconPages( - new PageImage("0", LibResources.ENTRY_ELVEN_GARDE), - new PageLoreText("1"), - new PageLoreText("2"), - new PageLoreText("3"), - new PageLoreText("4"), - new PageLoreText("5"), - new PageLoreText("6")) - .setIcon(new ItemStack(Items.writable_book)); - - elvenResources = new ALexiconEntry(LibLexicon.ALF_RESOURCES, categoryAlfhomancy); - elvenResources - .setPriority() - .setLexiconPages( - new PageText("0"), - new PageElvenRecipe("1", ModElvenTradeRecipes.dreamwoodRecipe), - new PageText("2"), - new PageCraftingRecipe("10", ModCraftingRecipes.recipeDreamwoodTwig), - new PageElvenRecipe("3", ModElvenTradeRecipes.elementiumRecipes), - new PageElvenRecipe("4", ModElvenTradeRecipes.pixieDustRecipe), - new PageElvenRecipe("5", ModElvenTradeRecipes.dragonstoneRecipes), - new PageText("6"), - new PageElvenRecipe("7", ModElvenTradeRecipes.elvenQuartzRecipe), - new PageText("8"), - new PageElvenRecipe("9", ModElvenTradeRecipes.alfglassRecipe)) - .setIcon(new ItemStack(ModItems.manaResource, 1, 9)); - - gaiaRitual = new ALexiconEntry(LibLexicon.ALF_GAIA_RITUAL, categoryAlfhomancy); - gaiaRitual - .setLexiconPages( - new PageText("0"), - new PageCraftingRecipe("1", ModCraftingRecipes.recipeGaiaPylon), - new PageMultiblock("2", ModMultiblocks.gaiaRitual), - new PageText("3"), - new PageText("4"), - new PageText("5")) - .setIcon(new ItemStack(ModItems.manaResource, 1, 5)); - LexiconRecipeMappings.map(new ItemStack(ModItems.manaResource, 1, 5), gaiaRitual, 0); - - gaiaRitualHardmode = new ALexiconEntry(LibLexicon.ALF_GAIA_RITUAL_HARDMODE, categoryAlfhomancy); - gaiaRitualHardmode - .setLexiconPages( - new PageText("0"), - new PageText("1"), - new PageCraftingRecipe("2", ModCraftingRecipes.recipeGaiaIngot)) - .setIcon(new ItemStack(ModItems.manaResource, 1, 14)); - - elvenLore = new ALexiconEntry(LibLexicon.ALF_LORE, categoryAlfhomancy); - elvenLore - .setLexiconPages( - new PageText("0"), - new PageLoreText("1"), - new PageLoreText("2"), - new PageLoreText("3"), - new PageLoreText("4"), - new PageLoreText("5"), - new PageLoreText("6"), - new PageLoreText("7")) - .setIcon(new ItemStack(Items.writable_book)); - - if (ConfigHandler.relicsEnabled) { - relics = new ALexiconEntry(LibLexicon.ALF_RELICS, categoryAlfhomancy); - relics.setLexiconPages(new PageText("0")).setIcon(new ItemStack(ModItems.dice)); - - relicInfo = new RLexiconEntry(LibLexicon.ALF_RELIC_INFO, categoryAlfhomancy, null); - relicInfo.setLexiconPages(new PageText("0"), new PageText("1")).setIcon(new ItemStack(ModItems.dice)); - - infiniteFruit = new RLexiconEntry( - LibLexicon.ALF_INFINITE_FRUIT, categoryAlfhomancy, ModAchievements.relicInfiniteFruit); - infiniteFruit.setLexiconPages(new PageText("0")); - - kingKey = new RLexiconEntry(LibLexicon.ALF_KING_KEY, categoryAlfhomancy, ModAchievements.relicKingKey); - kingKey.setLexiconPages(new PageText("0")); - - flugelEye = - new RLexiconEntry(LibLexicon.ALF_FLUGEL_EYE, categoryAlfhomancy, ModAchievements.relicFlugelEye); - flugelEye.setLexiconPages(new PageText("0"), new PageText("1")); - - thorRing = new RLexiconEntry(LibLexicon.ALF_THOR_RING, categoryAlfhomancy, ModAchievements.relicThorRing); - thorRing.setLexiconPages(new PageText("0")); - - lokiRing = new RLexiconEntry(LibLexicon.ALF_LOKI_RING, categoryAlfhomancy, ModAchievements.relicLokiRing); - lokiRing.setLexiconPages(new PageText("0"), new PageText("1"), new PageText("2"), new PageText("3")); - - odinRing = new RLexiconEntry(LibLexicon.ALF_ODIN_RING, categoryAlfhomancy, ModAchievements.relicOdinRing); - odinRing.setLexiconPages(new PageText("0")); - } - - // MISCLENAEOUS ENTRIES - unstableBlocks = new BLexiconEntry(LibLexicon.MISC_UNSTABLE_BLOCKS, categoryMisc); - unstableBlocks.setLexiconPages( - new PageText("0"), - new PageImage("1", LibResources.ENTRY_UNSTABLE_BLOCK), - new PageCraftingRecipe("2", ModCraftingRecipes.recipesUnstableBlocks), - new PageText("3"), - new PageImage("4", LibResources.ENTRY_UNSTABLE_BEACON), - new PageCraftingRecipe("5", ModCraftingRecipes.recipesManaBeacons), - new PageText("6"), - new PageCraftingRecipe("7", ModCraftingRecipes.recipesSignalFlares)); - - decorativeBlocks = new BLexiconEntry(LibLexicon.MISC_DECORATIVE_BLOCKS, categoryMisc); - if (ConfigHandler.darkQuartzEnabled) - decorativeBlocks.setLexiconPages( - new PageText("0"), - new PageCraftingRecipe("1", ModCraftingRecipes.recipeLivingrockDecor1), - new PageCraftingRecipe("2", ModCraftingRecipes.recipeLivingrockDecor2), - new PageCraftingRecipe("3", ModCraftingRecipes.recipeLivingrockDecor3), - new PageCraftingRecipe("4", ModCraftingRecipes.recipeLivingrockDecor4), - new PageCraftingRecipe("5", ModCraftingRecipes.recipeLivingwoodDecor1), - new PageCraftingRecipe("6", ModCraftingRecipes.recipeLivingwoodDecor2), - new PageCraftingRecipe("7", ModCraftingRecipes.recipeLivingwoodDecor3), - new PageCraftingRecipe("8", ModCraftingRecipes.recipeLivingwoodDecor4), - new PageCraftingRecipe("9", ModCraftingRecipes.recipeLivingwoodDecor5), - new PageText("10"), - new PageCraftingRecipe("11", ModCraftingRecipes.recipeDarkQuartz), - new PageManaInfusionRecipe("12", ModManaInfusionRecipes.manaQuartzRecipe), - new PageCraftingRecipe("13", ModCraftingRecipes.recipeBlazeQuartz), - new PageCraftingRecipe("14", ModCraftingRecipes.recipesLavenderQuartz), - new PageCraftingRecipe("15", ModCraftingRecipes.recipeRedQuartz), - new PageCraftingRecipe("23", ModCraftingRecipes.recipeSunnyQuartz), - new PageText("16"), - new PageCraftingRecipe("17", ModCraftingRecipes.recipeReedBlock), - new PageCraftingRecipe("18", ModCraftingRecipes.recipeThatch), - new PageCraftingRecipe("19", ModCraftingRecipes.recipeRoofTile), - new PageCraftingRecipe("20", ModCraftingRecipes.recipeNetherBrick), - new PageCraftingRecipe("21", ModCraftingRecipes.recipeSoulBrick), - new PageCraftingRecipe("22", ModCraftingRecipes.recipeSnowBrick)); - else - decorativeBlocks.setLexiconPages( - new PageText("0"), - new PageCraftingRecipe("1", ModCraftingRecipes.recipeLivingrockDecor1), - new PageCraftingRecipe("2", ModCraftingRecipes.recipeLivingrockDecor2), - new PageCraftingRecipe("3", ModCraftingRecipes.recipeLivingrockDecor3), - new PageCraftingRecipe("4", ModCraftingRecipes.recipeLivingrockDecor4), - new PageCraftingRecipe("5", ModCraftingRecipes.recipeLivingwoodDecor1), - new PageCraftingRecipe("6", ModCraftingRecipes.recipeLivingwoodDecor2), - new PageCraftingRecipe("7", ModCraftingRecipes.recipeLivingwoodDecor3), - new PageCraftingRecipe("8", ModCraftingRecipes.recipeLivingwoodDecor4), - new PageCraftingRecipe("9", ModCraftingRecipes.recipeLivingwoodDecor5), - new PageText("10"), - new PageManaInfusionRecipe("12", ModManaInfusionRecipes.manaQuartzRecipe), - new PageCraftingRecipe("13", ModCraftingRecipes.recipeBlazeQuartz), - new PageCraftingRecipe("14", ModCraftingRecipes.recipesLavenderQuartz), - new PageCraftingRecipe("15", ModCraftingRecipes.recipeRedQuartz), - new PageCraftingRecipe("23", ModCraftingRecipes.recipeSunnyQuartz), - new PageText("16"), - new PageCraftingRecipe("17", ModCraftingRecipes.recipeReedBlock), - new PageCraftingRecipe("18", ModCraftingRecipes.recipeThatch), - new PageCraftingRecipe("19", ModCraftingRecipes.recipeRoofTile), - new PageCraftingRecipe("20", ModCraftingRecipes.recipeNetherBrick), - new PageCraftingRecipe("21", ModCraftingRecipes.recipeSoulBrick), - new PageCraftingRecipe("22", ModCraftingRecipes.recipeSnowBrick)); - - dispenserTweaks = new BLexiconEntry(LibLexicon.MISC_DISPENSER_TWEAKS, categoryMisc); - dispenserTweaks.setLexiconPages(new PageText("0")).setPriority().setIcon(new ItemStack(Blocks.dispenser)); - - shinyFlowers = new BLexiconEntry(LibLexicon.MISC_SHINY_FLOWERS, categoryMisc); - shinyFlowers.setLexiconPages( - new PageText("0"), - new PageText("3"), - new PageCraftingRecipe("1", ModCraftingRecipes.recipesShinyFlowers), - new PageCraftingRecipe("2", ModCraftingRecipes.recipesMiniIsland)); - - prismarine = new BLexiconEntry(LibLexicon.MISC_PRISMARINE, categoryMisc); - prismarine.setLexiconPages( - new PageText("0"), - new PageText("1"), - new PageManaInfusionRecipe("2", ModManaAlchemyRecipes.prismarineRecipe), - new PageCraftingRecipe("3", ModCraftingRecipes.recipePrismarine), - new PageCraftingRecipe("4", ModCraftingRecipes.recipePrismarineBrick), - new PageCraftingRecipe("5", ModCraftingRecipes.recipeDarkPrismarine), - new PageCraftingRecipe("6", ModCraftingRecipes.recipeSeaLamp)); - - tinyPotato = new BLexiconEntry(LibLexicon.MISC_TINY_POTATO, categoryMisc); - tinyPotato.setLexiconPages( - new PageText("0"), new PageManaInfusionRecipe("1", ModManaInfusionRecipes.tinyPotatoRecipe)); - - headCreating = new HLexiconEntry(LibLexicon.MISC_HEAD_CREATING, categoryMisc); - headCreating.setLexiconPages( - new PageText("0"), new PageText("2"), new PageRuneRecipe("1", ModRuneRecipes.recipeHead)); - - azulejo = new BLexiconEntry(LibLexicon.MISC_AZULEJO, categoryMisc); - azulejo.setLexiconPages( - new PageText("0"), - new PageImage("1", LibResources.ENTRY_AZULEJOS), - new PageCraftingRecipe("2", ModCraftingRecipes.recipeAzulejo), - new PageCraftingRecipe("3", ModCraftingRecipes.recipesAzulejoCycling)); - - starfield = new ALexiconEntry(LibLexicon.MISC_STARFIELD, categoryMisc); - starfield.setLexiconPages(new PageText("0"), new PageCraftingRecipe("1", ModCraftingRecipes.recipeStarfield)); - - dirtPath = new BLexiconEntry(LibLexicon.MISC_DIRT_PATH, categoryMisc); - dirtPath.setLexiconPages( - new PageText("0"), - new PageCraftingRecipe("1", ModCraftingRecipes.recipeDirtPath), - new PageCraftingRecipe("2", ModCraftingRecipes.recipeDirtPathSlab)); - - mushrooms = new BLexiconEntry(LibLexicon.MISC_MUSHROOMS, categoryMisc); - mushrooms.setLexiconPages(new PageText("0"), new PageCraftingRecipe("1", ModCraftingRecipes.recipesMushrooms)); - - phantomInk = new BLexiconEntry(LibLexicon.MISC_PHANTOM_INK, categoryMisc); - phantomInk.setLexiconPages(new PageText("0"), new PageCraftingRecipe("1", ModCraftingRecipes.recipePhantomInk)); - - if (ConfigHandler.stones18Enabled) { - stoneAlchemy = new BLexiconEntry(LibLexicon.MISC_STONE_ALCHEMY, categoryMisc); - stoneAlchemy.setLexiconPages( - new PageText("0"), - new PageManaInfusionRecipe("1", ModManaAlchemyRecipes.stoneRecipes), - new PageCraftingRecipe("2", ModCraftingRecipes.recipe18StonePolish), - new PageCraftingRecipe("3", ModCraftingRecipes.recipe18StoneBrick), - new PageCraftingRecipe("4", ModCraftingRecipes.recipe18StoneChisel)); - } - - blazeBlock = new BLexiconEntry(LibLexicon.MISC_BLAZE_BLOCK, categoryMisc); - blazeBlock.setLexiconPages(new PageText("0"), new PageCraftingRecipe("1", ModCraftingRecipes.recipeBlazeBlock)); - LexiconRecipeMappings.map(new ItemStack(Blocks.obsidian), blazeBlock, 0); - - challenges = new BLexiconEntry(LibLexicon.MISC_CHALLENGES, categoryMisc); - challenges - .setLexiconPages(new PageText("0"), new PageText("1"), new PageText("2")) - .setPriority() - .setIcon(new ItemStack(ModItems.cosmetic, 1, 31)); - - cacophonium = new BLexiconEntry(LibLexicon.MISC_CACOPHONIUM, categoryMisc); - cacophonium.setLexiconPages( - new PageText("0"), - new PageCraftingRecipe("1", ModCraftingRecipes.recipeCacophonium), - new PageText("2")); - - pavement = new BLexiconEntry(LibLexicon.MISC_PAVEMENT, categoryMisc); - pavement.setLexiconPages(new PageText("0"), new PageCraftingRecipe("1", ModCraftingRecipes.recipesPavement)); - - preventingDecay = new DLexiconEntry(LibLexicon.MISC_PRENTING_DECAY, categoryMisc); - preventingDecay.setLexiconPages(new PageText("0")).setIcon(new ItemStack(Blocks.deadbush)); - - if (Botania.bcTriggersLoaded) { - bcIntegration = new CLexiconEntry(LibLexicon.MISC_BC_INTEGRATION, categoryMisc, "BuildCraft"); - bcIntegration.setLexiconPages(new PageText("0")).setIcon(new ItemStack(Items.redstone)); - } - } - - public static void postInit() { - if (SheddingHandler.hasShedding()) { - shedding = new BLexiconEntry(LibLexicon.MISC_SHEDDING, BotaniaAPI.categoryMisc); - shedding.setLexiconPages(new PageText("0")).setPriority().setIcon(new ItemStack(Items.feather)); - SheddingHandler.addToLexicon(); - } - - if (Botania.thaumcraftLoaded) { - tcIntegration = new CLexiconEntry(LibLexicon.MISC_TC_INTEGRATION, BotaniaAPI.categoryMisc, "Thaumcraft"); - - if (ConfigHandler.enableThaumcraftStablizers) - tcIntegration - .setLexiconPages( - new PageText("0"), - new PageText("1"), - new PageCraftingRecipe("2", ModCraftingRecipes.recipeHelmetOfRevealing), - new PageText("3"), - new PageManaInfusionRecipe("4", ModManaInfusionRecipes.manaInkwellRecipe), - new PageText("5"), - new PageBrew(ModBrewRecipes.warpWardBrew, "6a", "6b")) - .setIcon(new ItemStack(ModItems.manaInkwell)); - else - tcIntegration - .setLexiconPages( - new PageText("0"), - new PageText("1"), - new PageCraftingRecipe("2", ModCraftingRecipes.recipeHelmetOfRevealing), - new PageText("3"), - new PageManaInfusionRecipe("4", ModManaInfusionRecipes.manaInkwellRecipe), - new PageBrew(ModBrewRecipes.warpWardBrew, "6a", "6b")) - .setIcon(new ItemStack(ModItems.manaInkwell)); - } - - if (Botania.etFuturumLoaded) { - banners = new CLexiconEntry(LibLexicon.MISC_BANNERS, BotaniaAPI.categoryMisc, "EtFuturum"); - banners.setLexiconPages(new PageText("0"), new PageImage("1", LibResources.ENTRY_BANNERS)) - .setIcon(new ItemStack(ModItems.lexicon)); - } - } + public static LexiconEntry welcome; + public static LexiconEntry tutorial; + + public static LexiconEntry flowers; + public static LexiconEntry apothecary; + public static LexiconEntry lexicon; + public static LexiconEntry wand; + public static LexiconEntry pureDaisy; + public static LexiconEntry runicAltar; + public static LexiconEntry terrasteel; + public static LexiconEntry blackLotus; + public static LexiconEntry flowerBag; + public static LexiconEntry gardenOfGlass; + + public static LexiconEntry manaIntro; + public static LexiconEntry spreader; + public static LexiconEntry pool; + public static LexiconEntry lenses; + public static LexiconEntry distributor; + public static LexiconEntry manaVoid; + public static LexiconEntry manaTablet; + public static LexiconEntry manaMirror; + public static LexiconEntry manaDetector; + public static LexiconEntry redstoneSpreader; + public static LexiconEntry manastar; + public static LexiconEntry dreamwoodSpreader; + public static LexiconEntry elvenLenses; + public static LexiconEntry sparks; + public static LexiconEntry sparkUpgrades; + public static LexiconEntry rfGenerator; + public static LexiconEntry prism; + public static LexiconEntry poolCart; + public static LexiconEntry sparkChanger; + public static LexiconEntry bellows; + + public static LexiconEntry functionalIntro; + public static LexiconEntry flowerShrinking; + public static LexiconEntry flowerSpeed; + public static LexiconEntry jadedAmaranthus; + public static LexiconEntry bellethorne; + public static LexiconEntry dreadthorne; + public static LexiconEntry heiseiDream; + public static LexiconEntry tigerseye; + public static LexiconEntry orechid; + public static LexiconEntry orechidIgnem; + public static LexiconEntry fallenKanade; + public static LexiconEntry exoflame; + public static LexiconEntry agricarnation; + public static LexiconEntry hopperhock; + public static LexiconEntry tangleberrie; + public static LexiconEntry jiyuulia; + public static LexiconEntry rannuncarpus; + public static LexiconEntry hyacidus; + public static LexiconEntry pollidisiac; + public static LexiconEntry clayconia; + public static LexiconEntry loonium; + public static LexiconEntry daffomill; + public static LexiconEntry vinculotus; + public static LexiconEntry spectranthemum; + public static LexiconEntry medumone; + public static LexiconEntry marimorphosis; + public static LexiconEntry bubbell; + public static LexiconEntry solegnolia; + + public static LexiconEntry generatingIntro; + public static LexiconEntry passiveGen; + public static LexiconEntry primusLoci; + public static LexiconEntry daybloom; + public static LexiconEntry nightshade; + public static LexiconEntry endoflame; + public static LexiconEntry hydroangeas; + public static LexiconEntry thermalily; + public static LexiconEntry arcaneRose; + public static LexiconEntry munchdew; + public static LexiconEntry entropinnyum; + public static LexiconEntry kekimurus; + public static LexiconEntry gourmaryllis; + public static LexiconEntry narslimmus; + public static LexiconEntry spectrolus; + public static LexiconEntry rafflowsia; + public static LexiconEntry dandelifeon; + + public static LexiconEntry pylon; + public static LexiconEntry manaEnchanting; + public static LexiconEntry turntable; + public static LexiconEntry alchemy; + public static LexiconEntry openCrate; + public static LexiconEntry forestEye; + public static LexiconEntry forestDrum; + public static LexiconEntry platform; + public static LexiconEntry conjurationCatalyst; + public static LexiconEntry spectralPlatform; + public static LexiconEntry gatherDrum; + public static LexiconEntry craftCrate; + public static LexiconEntry brewery; + public static LexiconEntry flasks; + public static LexiconEntry complexBrews; + public static LexiconEntry incense; + public static LexiconEntry hourglass; + public static LexiconEntry ghostRail; + public static LexiconEntry canopyDrum; + public static LexiconEntry cocoon; + public static LexiconEntry manaBomb; + public static LexiconEntry teruTeruBozu; + public static LexiconEntry avatar; + public static LexiconEntry felPumpkin; + + public static LexiconEntry manaBlaster; + public static LexiconEntry grassSeeds; + public static LexiconEntry dirtRod; + public static LexiconEntry terraformRod; + public static LexiconEntry manasteelGear; + public static LexiconEntry terrasteelArmor; + public static LexiconEntry grassHorn; + public static LexiconEntry terraBlade; + public static LexiconEntry terraPick; + public static LexiconEntry waterRod; + public static LexiconEntry elfGear; + public static LexiconEntry openBucket; + public static LexiconEntry rainbowRod; + public static LexiconEntry tornadoRod; + public static LexiconEntry fireRod; + public static LexiconEntry vineBall; + public static LexiconEntry laputaShard; + public static LexiconEntry virus; + public static LexiconEntry skyDirtRod; + public static LexiconEntry glassPick; + public static LexiconEntry diviningRod; + public static LexiconEntry gravityRod; + public static LexiconEntry regenIvy; + public static LexiconEntry missileRod; + public static LexiconEntry craftingHalo; + public static LexiconEntry clip; + public static LexiconEntry cobbleRod; + public static LexiconEntry smeltRod; + public static LexiconEntry worldSeed; + public static LexiconEntry spellCloth; + public static LexiconEntry thornChakram; + public static LexiconEntry fireChakram; + public static LexiconEntry overgrowthSeed; + public static LexiconEntry livingwoodBow; + public static LexiconEntry crystalBow; + public static LexiconEntry temperanceStone; + public static LexiconEntry terraAxe; + public static LexiconEntry obedienceStick; + public static LexiconEntry slimeBottle; + public static LexiconEntry exchangeRod; + public static LexiconEntry manaweave; + public static LexiconEntry autocraftingHalo; + public static LexiconEntry sextant; + + public static LexiconEntry enderAir; + public static LexiconEntry enderEyeBlock; + public static LexiconEntry pistonRelay; + public static LexiconEntry enderHand; + public static LexiconEntry enderDagger; + public static LexiconEntry spawnerClaw; + public static LexiconEntry redString; + public static LexiconEntry flightTiara; + public static LexiconEntry corporea; + public static LexiconEntry corporeaIndex; + public static LexiconEntry corporeaFunnel; + public static LexiconEntry corporeaInterceptor; + public static LexiconEntry endStoneDecor; + public static LexiconEntry spawnerMover; + public static LexiconEntry keepIvy; + public static LexiconEntry blackHoleTalisman; + public static LexiconEntry corporeaCrystalCube; + public static LexiconEntry luminizerTransport; + public static LexiconEntry starSword; + public static LexiconEntry thunderSword; + public static LexiconEntry corporeaRetainer; + + public static LexiconEntry baublesIntro; + public static LexiconEntry cosmeticBaubles; + public static LexiconEntry tinyPlanet; + public static LexiconEntry manaRing; + public static LexiconEntry auraRing; + public static LexiconEntry travelBelt; + public static LexiconEntry knockbacklBelt; + public static LexiconEntry icePendant; + public static LexiconEntry lavaPendant; + public static LexiconEntry goldLaurel; + public static LexiconEntry waterRing; + public static LexiconEntry miningRing; + public static LexiconEntry magnetRing; + public static LexiconEntry divaCharm; + public static LexiconEntry pixieRing; + public static LexiconEntry superTravelBelt; + public static LexiconEntry reachRing; + public static LexiconEntry itemFinder; + public static LexiconEntry superLavaPendant; + public static LexiconEntry bloodPendant; + public static LexiconEntry judgementCloaks; + public static LexiconEntry monocle; + public static LexiconEntry swapRing; + public static LexiconEntry speedUpBelt; + public static LexiconEntry baubleBox; + + public static LexiconEntry alfhomancyIntro; + public static LexiconEntry elvenMessage; + public static LexiconEntry elvenResources; + public static LexiconEntry gaiaRitual; + public static LexiconEntry gaiaRitualHardmode; + public static LexiconEntry elvenLore; + public static LexiconEntry relics; + public static LexiconEntry relicInfo; + public static LexiconEntry infiniteFruit; + public static LexiconEntry kingKey; + public static LexiconEntry flugelEye; + public static LexiconEntry thorRing; + public static LexiconEntry lokiRing; + public static LexiconEntry odinRing; + + public static LexiconEntry unstableBlocks; + public static LexiconEntry decorativeBlocks; + public static LexiconEntry dispenserTweaks; + public static LexiconEntry shinyFlowers; + public static LexiconEntry prismarine; + public static LexiconEntry shedding; + public static LexiconEntry tinyPotato; + public static LexiconEntry headCreating; + public static LexiconEntry azulejo; + public static LexiconEntry starfield; + public static LexiconEntry dirtPath; + public static LexiconEntry mushrooms; + public static LexiconEntry phantomInk; + public static LexiconEntry stoneAlchemy; + public static LexiconEntry blazeBlock; + public static LexiconEntry challenges; + public static LexiconEntry cacophonium; + public static LexiconEntry pavement; + public static LexiconEntry preventingDecay; + + public static LexiconEntry tcIntegration; + public static LexiconEntry bcIntegration; + public static LexiconEntry banners; + + public static void preInit() { + BotaniaAPI.addCategory(BotaniaAPI.categoryBasics = new BLexiconCategory(LibLexicon.CATEGORY_BASICS, 9)); + BotaniaAPI.addCategory(BotaniaAPI.categoryMana = new BLexiconCategory(LibLexicon.CATEGORY_MANA, 5)); + BotaniaAPI.addCategory( + BotaniaAPI.categoryGenerationFlowers = new BLexiconCategory(LibLexicon.CATEGORY_GENERATION_FLOWERS, 5)); + BotaniaAPI.addCategory( + BotaniaAPI.categoryFunctionalFlowers = new BLexiconCategory(LibLexicon.CATEGORY_FUNCTIONAL_FLOWERS, 5)); + BotaniaAPI.addCategory(BotaniaAPI.categoryDevices = new BLexiconCategory(LibLexicon.CATEGORY_DEVICES, 5)); + BotaniaAPI.addCategory(BotaniaAPI.categoryTools = new BLexiconCategory(LibLexicon.CATEGORY_TOOLS, 5)); + BotaniaAPI.addCategory(BotaniaAPI.categoryBaubles = new BLexiconCategory(LibLexicon.CATEGORY_BAUBLES, 5)); + BotaniaAPI.addCategory(BotaniaAPI.categoryEnder = new BLexiconCategory(LibLexicon.CATEGORY_ENDER, 5)); + BotaniaAPI.addCategory(BotaniaAPI.categoryAlfhomancy = new BLexiconCategory(LibLexicon.CATEGORY_ALFHOMANCY, 5)); + BotaniaAPI.addCategory(BotaniaAPI.categoryMisc = new BLexiconCategory(LibLexicon.CATEGORY_MISC, 0)); + } + + public static void init() { + LexiconCategory categoryBasics = BotaniaAPI.categoryBasics; + LexiconCategory categoryMana = BotaniaAPI.categoryMana; + LexiconCategory categoryGenerationFlowers = BotaniaAPI.categoryGenerationFlowers; + LexiconCategory categoryFunctionalFlowers = BotaniaAPI.categoryFunctionalFlowers; + LexiconCategory categoryDevices = BotaniaAPI.categoryDevices; + LexiconCategory categoryTools = BotaniaAPI.categoryTools; + LexiconCategory categoryBaubles = BotaniaAPI.categoryBaubles; + LexiconCategory categoryEnder = BotaniaAPI.categoryEnder; + LexiconCategory categoryAlfhomancy = BotaniaAPI.categoryAlfhomancy; + LexiconCategory categoryMisc = BotaniaAPI.categoryMisc; + + // BASICS ENTRIES + welcome = new WLexiconEntry(); + tutorial = new TLexiconEntry(); + + flowers = new BLexiconEntry(LibLexicon.BASICS_FLOWERS, categoryBasics); + flowers.setPriority() + .setLexiconPages(new PageText("0"), new PageImage("1", LibResources.ENTRY_FLOWERS), new PageText("2"), + new PageCraftingRecipe("3", ModCraftingRecipes.recipesPetals), + new PageCraftingRecipe("4", ModCraftingRecipes.recipePestleAndMortar), + new PageCraftingRecipe("5", ModCraftingRecipes.recipesDyes), new PageText("6"), + new PageCraftingRecipe("7", ModCraftingRecipes.recipeFertilizerPowder), + new PageCraftingRecipe("8", ModCraftingRecipes.recipeFerilizerDye), new PageText("10"), + new PageText("12"), new PageCraftingRecipe("11", ModCraftingRecipes.recipesPetalsDouble), + new PageCraftingRecipe("9", ModCraftingRecipes.recipesPetalBlocks)) + .setIcon(new ItemStack(ModBlocks.flower, 1, 6)); + + apothecary = new BLexiconEntry(LibLexicon.BASICS_APOTHECARY, categoryBasics); + apothecary.setPriority().setLexiconPages(new PageText("0"), new PageImage("1", LibResources.ENTRY_APOTHECARY), + new PageText("2"), new PageText("3"), new PageText("4"), new PageText("7"), new PageText("6"), + new PageCraftingRecipe("5", ModCraftingRecipes.recipesApothecary)); + + lexicon = new BLexiconEntry(LibLexicon.BASICS_LEXICON, categoryBasics); + lexicon.setPriority().setLexiconPages(new PageText("0"), new PageText("3"), + new PageCraftingRecipe("1", ModCraftingRecipes.recipeLexicon), new PageText("2")); + + wand = new BLexiconEntry(LibLexicon.BASICS_WAND, categoryBasics); + wand.setPriority().setLexiconPages(new PageText("0"), new PageText("1"), new PageText("2"), + new PageCraftingRecipe("3", ModCraftingRecipes.recipesTwigWand)); + + pureDaisy = new BLexiconEntry(LibLexicon.BASICS_PURE_DAISY, categoryBasics); + pureDaisy.setPriority() + .setLexiconPages(new PageText("0"), new PageImage("1", LibResources.ENTRY_PURE_DAISY), + new PageCraftingRecipe("2", ModCraftingRecipes.recipeLivingwoodTwig), new PageText("4"), + new PagePetalRecipe("3", ModPetalRecipes.pureDaisyRecipe)) + .setIcon(ItemBlockSpecialFlower.ofType(LibBlockNames.SUBTILE_PUREDAISY)); + pureDaisy.addExtraDisplayedRecipe(new ItemStack(ModBlocks.livingwood)); + pureDaisy.addExtraDisplayedRecipe(new ItemStack(ModBlocks.livingrock)); + LexiconRecipeMappings.map(new ItemStack(ModBlocks.livingwood), pureDaisy, 1); + LexiconRecipeMappings.map(new ItemStack(ModBlocks.livingrock), pureDaisy, 1); + + runicAltar = new BLexiconEntry(LibLexicon.BASICS_RUNE_ALTAR, categoryBasics); + runicAltar.setPriority().setLexiconPages(new PageText("21"), new PageText("0"), new PageText("1"), + new PageCraftingRecipe("2", ModCraftingRecipes.recipesRuneAltar), new PageText("3"), new PageText("20"), + new PageText("22"), new PageRuneRecipe("4", ModRuneRecipes.recipeWaterRune), + new PageRuneRecipe("5", ModRuneRecipes.recipesEarthRune), + new PageRuneRecipe("6", ModRuneRecipes.recipesAirRune), + new PageRuneRecipe("7", ModRuneRecipes.recipeFireRune), + new PageRuneRecipe("8", ModRuneRecipes.recipeSpringRune), + new PageRuneRecipe("9", ModRuneRecipes.recipeSummerRune), + new PageRuneRecipe("10", ModRuneRecipes.recipeAutumnRune), + new PageRuneRecipe("11", ModRuneRecipes.recipesWinterRune), + new PageRuneRecipe("12", ModRuneRecipes.recipeManaRune), + new PageRuneRecipe("13", ModRuneRecipes.recipeLustRune), + new PageRuneRecipe("14", ModRuneRecipes.recipeGluttonyRune), + new PageRuneRecipe("15", ModRuneRecipes.recipeGreedRune), + new PageRuneRecipe("16", ModRuneRecipes.recipeSlothRune), + new PageRuneRecipe("17", ModRuneRecipes.recipeWrathRune), + new PageRuneRecipe("18", ModRuneRecipes.recipeEnvyRune), + new PageRuneRecipe("19", ModRuneRecipes.recipePrideRune)); + + terrasteel = new BLexiconEntry(LibLexicon.BASICS_TERRASTEEL, categoryBasics); + terrasteel.setLexiconPages(new PageText("0"), new PageCraftingRecipe("1", ModCraftingRecipes.recipeTerraPlate), + new PageText("2"), new PageMultiblock("4", ModMultiblocks.terrasteelPlate), new PageTerrasteel("3")) + .setIcon(new ItemStack(ModItems.manaResource, 1, 4)); + + blackLotus = new BLexiconEntry(LibLexicon.BASICS_BLACK_LOTUS, categoryBasics); + blackLotus.setLexiconPages(new PageText("0")).setIcon(new ItemStack(ModItems.blackLotus)); + blackLotus.addExtraDisplayedRecipe(new ItemStack(ModItems.blackLotus)); + + flowerBag = new BLexiconEntry(LibLexicon.BASICS_FLOWER_BAG, categoryBasics); + flowerBag.setLexiconPages(new PageText("0"), new PageText("2"), + new PageCraftingRecipe("1", ModCraftingRecipes.recipeFlowerBag)); + + if (Botania.gardenOfGlassLoaded) { + gardenOfGlass = new BLexiconEntry(LibLexicon.BASICS_GARDEN_OF_GLASS, categoryBasics); + gardenOfGlass.setLexiconPages(new PageText("0"), new PageText("1"), new PageText("2"), + new PageCraftingRecipe("3", ModCraftingRecipes.recipeRootToSapling), + new PageCraftingRecipe("4", ModCraftingRecipes.recipeRootToFertilizer), + new PageCraftingRecipe("5", ModCraftingRecipes.recipePebbleCobblestone), new PageText("6"), + new PageManaInfusionRecipe("7", ModManaInfusionRecipes.sugarCaneRecipe), + new PageCraftingRecipe("8", ModCraftingRecipes.recipeMagmaToSlimeball), new PageText("9"), + new PageText("11"), new PageCraftingRecipe("12", ModCraftingRecipes.recipeEndPortal)); + gardenOfGlass.setPriority().setIcon(new ItemStack(ModItems.manaResource, 1, 20)); + } + + if (Botania.thaumcraftLoaded) + new CLexiconEntry("wrap", categoryBasics, "Thaumcraft").setLexiconPages(new PageText("0")); // lel + + // MANA ENTRIES + manaIntro = new BLexiconEntry(LibLexicon.MANA_INTRO, categoryMana); + manaIntro.setPriority().setLexiconPages(new PageText("0"), new PageText("1"), new PageText("2")); + + spreader = new BLexiconEntry(LibLexicon.MANA_SPREADER, categoryMana); + spreader.setPriority().setLexiconPages(new PageText("0"), new PageImage("1", LibResources.ENTRY_SPREADER), + new PageText("2"), new PageText("3"), new PageText("4"), new PageText("11"), + new PageCraftingRecipe("5", ModCraftingRecipes.recipesSpreader), new PageText("10")); + + pool = new BLexiconEntry(LibLexicon.MANA_POOL, categoryMana); + pool.setPriority() + .setLexiconPages(new PageText("0"), new PageText("9"), + new PageCraftingRecipe("1", ModCraftingRecipes.recipePool), + new PageCraftingRecipe("10", ModCraftingRecipes.recipePoolDiluted), new PageText("14"), + new PageText("2"), new PageText("8"), + new PageManaInfusionRecipe("3", ModManaInfusionRecipes.manasteelRecipes), + new PageManaInfusionRecipe("4", ModManaInfusionRecipes.manaPearlRecipe), + new PageManaInfusionRecipe("5", ModManaInfusionRecipes.manaDiamondRecipes), + new PageManaInfusionRecipe("6", ModManaInfusionRecipes.manaPowderRecipes), + new PageManaInfusionRecipe("11", ModManaInfusionRecipes.managlassRecipe), + new PageManaInfusionRecipe("12", ModManaInfusionRecipes.manaStringRecipe), + new PageCraftingRecipe("13", ModCraftingRecipes.recipeCobweb), + new PageManaInfusionRecipe("7", ModManaInfusionRecipes.manaCookieRecipe)) + .setIcon(new ItemStack(ModBlocks.pool)); + + sparks = new BLexiconEntry(LibLexicon.MANA_SPARKS, categoryMana); + sparks.setPriority().setLexiconPages(new PageText("0"), new PageText("1"), new PageText("3"), + new PageCraftingRecipe("2", ModCraftingRecipes.recipesSpark)); + + sparkUpgrades = new ALexiconEntry(LibLexicon.MANA_SPARK_UPGRADES, categoryMana); + sparkUpgrades.setLexiconPages(new PageText("0"), new PageText("1"), new PageText("2"), new PageText("3"), + new PageText("4"), new PageCraftingRecipe("5", ModCraftingRecipes.recipesSparkUpgrades)); + + if (ConfigHandler.fluxfieldEnabled) { + rfGenerator = new BLexiconEntry(LibLexicon.MANA_RF_GENERATOR, categoryMana); + rfGenerator.setLexiconPages(new PageText("0"), + new PageCraftingRecipe("1", ModCraftingRecipes.recipeRFGenerator)); + } + + lenses = new BLexiconEntry(LibLexicon.MANA_LENSES, categoryMana); + lenses.setLexiconPages(new PageText("0"), new PageCraftingRecipe("1", ModCraftingRecipes.recipesManaLens), + new PageText("4"), new PageText("5"), new PageText("6"), + new PageCraftingRecipe("7", ModCraftingRecipes.recipeLensVelocity), new PageText("8"), + new PageCraftingRecipe("9", ModCraftingRecipes.recipeLensPotency), new PageText("10"), + new PageCraftingRecipe("11", ModCraftingRecipes.recipeLensResistance), new PageText("12"), + new PageCraftingRecipe("13", ModCraftingRecipes.recipeLensEfficiency), new PageText("14"), + new PageCraftingRecipe("15", ModCraftingRecipes.recipeLensBounce), new PageText("16"), + new PageCraftingRecipe("17", ModCraftingRecipes.recipeLensGravity), new PageText("18"), + new PageCraftingRecipe("19", ModCraftingRecipes.recipeLensBore), new PageText("20"), + new PageCraftingRecipe("21", ModCraftingRecipes.recipeLensDamaging), new PageText("22"), + new PageCraftingRecipe("23", ModCraftingRecipes.recipeLensPhantom), new PageText("24"), + new PageCraftingRecipe("25", ModCraftingRecipes.recipeLensMagnet), new PageText("26"), + new PageCraftingRecipe("27", ModCraftingRecipes.recipeLensExplosive), new PageText("28"), + new PageCraftingRecipe("29", ModCraftingRecipes.recipeLensInfluence), new PageText("30"), + new PageCraftingRecipe("31", ModCraftingRecipes.recipeLensWeight), new PageText("32"), + new PageCraftingRecipe("33", ModCraftingRecipes.recipeLensFire), new PageText("34"), + new PageCraftingRecipe("35", ModCraftingRecipes.recipeLensPiston), new PageText("36"), + new PageCraftingRecipe("37", ModCraftingRecipes.recipesLensFlash)); + + distributor = new BLexiconEntry(LibLexicon.MANA_DISTRIBUTOR, categoryMana); + distributor.setLexiconPages(new PageText("0"), + new PageCraftingRecipe("1", ModCraftingRecipes.recipeDistributor)); + + manaVoid = new BLexiconEntry(LibLexicon.MANA_VOID, categoryMana); + manaVoid.setLexiconPages(new PageText("0"), new PageCraftingRecipe("1", ModCraftingRecipes.recipeManaVoid)); + + manaTablet = new BLexiconEntry(LibLexicon.MANA_TABLET, categoryMana); + manaTablet.setPriority().setLexiconPages(new PageText("0"), new PageText("1"), + new PageCraftingRecipe("2", ModCraftingRecipes.recipesManaTablet)); + + manaMirror = new BLexiconEntry(LibLexicon.MANA_MIRROR, categoryMana); + manaMirror.setLexiconPages(new PageText("0"), new PageCraftingRecipe("1", ModCraftingRecipes.recipeManaMirror)); + + manaDetector = new BLexiconEntry(LibLexicon.MANA_DETECTOR, categoryMana); + manaDetector.setLexiconPages(new PageText("0"), + new PageCraftingRecipe("1", ModCraftingRecipes.recipeManaDetector)); + + redstoneSpreader = new BLexiconEntry(LibLexicon.MANA_REDSTONE_SPREADER, categoryMana); + redstoneSpreader.setPriority().setLexiconPages(new PageText("0"), + new PageCraftingRecipe("1", ModCraftingRecipes.recipeRedstoneSpreader)); + + manastar = new BLexiconEntry(LibLexicon.MANA_MANASTAR, categoryMana); + manastar.setPriority().setLexiconPages(new PageText("0"), + new PagePetalRecipe("1", ModPetalRecipes.manastarRecipe)); + + dreamwoodSpreader = new ALexiconEntry(LibLexicon.MANA_DREAMWOOD_SPREADER, categoryMana); + dreamwoodSpreader.setLexiconPages(new PageText("0"), + new PageCraftingRecipe("1", ModCraftingRecipes.recipesDreamwoodSpreader), new PageText("2"), + new PageCraftingRecipe("3", ModCraftingRecipes.recipeUltraSpreader)); + + elvenLenses = new ALexiconEntry(LibLexicon.MANA_ELVEN_LENSES, categoryMana); + elvenLenses.setLexiconPages(new PageText("0"), new PageText("1"), + new PageCraftingRecipe("2", ModCraftingRecipes.recipeLensPaint), new PageText("3"), + new PageCraftingRecipe("4", ModCraftingRecipes.recipeLensWarp), new PageText("5"), + new PageCraftingRecipe("6", ModCraftingRecipes.recipeLensRedirect), new PageText("7"), + new PageCraftingRecipe("8", ModCraftingRecipes.recipeLensFirework), new PageText("9"), + new PageCraftingRecipe("10", ModCraftingRecipes.recipeLensFlare)); + + prism = new ALexiconEntry(LibLexicon.MANA_PRISM, categoryMana); + prism.setLexiconPages(new PageText("0"), new PageText("1"), new PageText("2"), + new PageCraftingRecipe("3", ModCraftingRecipes.recipePrism)); + + poolCart = new BLexiconEntry(LibLexicon.MANA_POOL_CART, categoryMana); + poolCart.setLexiconPages(new PageText("0"), new PageText("1"), new PageText("2"), + new PageCraftingRecipe("3", ModCraftingRecipes.recipePoolCart), + new PageCraftingRecipe("4", ModCraftingRecipes.recipePump)); + + sparkChanger = new ALexiconEntry(LibLexicon.MANA_SPARK_CHANGER, categoryMana); + sparkChanger.setLexiconPages(new PageText("0"), new PageText("1"), + new PageCraftingRecipe("2", ModCraftingRecipes.recipeSparkChanger)); + + bellows = new BLexiconEntry(LibLexicon.MANA_BELLOWS, categoryMana); + bellows.setLexiconPages(new PageText("0"), new PageText("1"), + new PageCraftingRecipe("2", ModCraftingRecipes.recipeBellows)); + + // FUNCTIONAL FLOWERS ENTRIES + functionalIntro = new BLexiconEntry(LibLexicon.FFLOWER_INTRO, categoryFunctionalFlowers); + functionalIntro + .setPriority().setLexiconPages(new PageText("0"), new PageText("1"), new PageText("2"), + new PageText("3"), new PageCraftingRecipe("4", ModCraftingRecipes.recipeRedstoneRoot)) + .setIcon(null); + ; + + flowerShrinking = new BLexiconEntry(LibLexicon.FFLOWER_SHRINKING, categoryFunctionalFlowers); + flowerShrinking.setPriority() + .setLexiconPages(new PageText("0"), new PageManaInfusionRecipe("1", BotaniaAPI.miniFlowerRecipes)) + .setIcon(ItemBlockSpecialFlower.ofType(LibBlockNames.SUBTILE_BELLETHORN + "Chibi")); + + flowerSpeed = new BLexiconEntry(LibLexicon.FFLOWER_SPEED, categoryFunctionalFlowers); + flowerSpeed.setPriority().setLexiconPages(new PageText("0"), new PageText("1")); + flowerSpeed.setIcon(new ItemStack(Blocks.dirt, 1, 2)); + + jadedAmaranthus = new BLexiconEntry(LibLexicon.FFLOWER_JADED_AMARANTHUS, categoryFunctionalFlowers); + jadedAmaranthus.setLexiconPages(new PageText("0"), + new PagePetalRecipe("1", ModPetalRecipes.jadedAmaranthusRecipe), new PageText("2")); + + bellethorne = new BLexiconEntry(LibLexicon.FFLOWER_BELLETHORNE, categoryFunctionalFlowers); + bellethorne.setLexiconPages(new PageText("0"), new PagePetalRecipe("1", ModPetalRecipes.bellethorneRecipe)); + + dreadthorne = new BLexiconEntry(LibLexicon.FFLOWER_DREADTHORNE, categoryFunctionalFlowers); + dreadthorne.setLexiconPages(new PageText("0"), new PagePetalRecipe("1", ModPetalRecipes.dreadthorneRecipe)); + + heiseiDream = new ALexiconEntry(LibLexicon.FFLOWER_HEISEI_DREAM, categoryFunctionalFlowers); + heiseiDream.setLexiconPages(new PageText("0"), new PagePetalRecipe("1", ModPetalRecipes.heiseiDreamRecipe)); + + tigerseye = new BLexiconEntry(LibLexicon.FFLOWER_TIGERSEYE, categoryFunctionalFlowers); + tigerseye.setLexiconPages(new PageText("0"), new PagePetalRecipe("1", ModPetalRecipes.tigerseyeRecipe)); + + orechid = Botania.gardenOfGlassLoaded ? new BLexiconEntry(LibLexicon.FFLOWER_ORECHID, categoryFunctionalFlowers) + : new ALexiconEntry(LibLexicon.FFLOWER_ORECHID, categoryFunctionalFlowers); + orechid.setLexiconPages(new PageText("0"), new PagePetalRecipe("1", ModPetalRecipes.orechidRecipe)); + if (Botania.gardenOfGlassLoaded) + orechid.setPriority(); + + orechidIgnem = new ALexiconEntry(LibLexicon.FFLOWER_ORECHID_IGNEM, categoryFunctionalFlowers); + orechidIgnem.setLexiconPages(new PageText("0"), new PagePetalRecipe("1", ModPetalRecipes.orechidIgnemRecipe)); + + if (ConfigHandler.fallenKanadeEnabled) { + fallenKanade = new BLexiconEntry(LibLexicon.FFLOWER_FALLEN_KANADE, categoryFunctionalFlowers); + fallenKanade.setLexiconPages(new PageText(Botania.bloodMagicLoaded ? "0a" : "0"), + new PagePetalRecipe("1", ModPetalRecipes.fallenKanadeRecipe)); + } + + exoflame = new BLexiconEntry(LibLexicon.FFLOWER_EXOFLAME, categoryFunctionalFlowers); + exoflame.setLexiconPages(new PageText("0"), new PagePetalRecipe("1", ModPetalRecipes.exoflameRecipe)); + + agricarnation = new BLexiconEntry(LibLexicon.FFLOWER_AGRICARNATION, categoryFunctionalFlowers); + agricarnation.setLexiconPages(new PageText("0"), new PagePetalRecipe("1", ModPetalRecipes.agricarnationRecipe)); + + hopperhock = new BLexiconEntry(LibLexicon.FFLOWER_HOPPERHOCK, categoryFunctionalFlowers); + hopperhock.setLexiconPages(new PageText("0"), new PageText("1"), + new PagePetalRecipe("2", ModPetalRecipes.hopperhockRecipe)); + + tangleberrie = new BLexiconEntry(LibLexicon.FFLOWER_TANGLEBERRIE, categoryFunctionalFlowers); + tangleberrie.setLexiconPages(new PageText("0"), new PagePetalRecipe("1", ModPetalRecipes.tangleberrieRecipe)); + + jiyuulia = new BLexiconEntry(LibLexicon.FFLOWER_JIYUULIA, categoryFunctionalFlowers); + jiyuulia.setLexiconPages(new PageText("0"), new PagePetalRecipe("1", ModPetalRecipes.jiyuuliaRecipe)); + + rannuncarpus = new BLexiconEntry(LibLexicon.FFLOWER_RANNUNCARPUS, categoryFunctionalFlowers); + rannuncarpus.setLexiconPages(new PageText("0"), new PageText("1"), + new PagePetalRecipe("2", ModPetalRecipes.rannuncarpusRecipe)); + + hyacidus = new BLexiconEntry(LibLexicon.FFLOWER_HYACIDUS, categoryFunctionalFlowers); + hyacidus.setLexiconPages(new PageText("0"), new PagePetalRecipe("1", ModPetalRecipes.hyacidusRecipe)); + + pollidisiac = new BLexiconEntry(LibLexicon.FFLOWER_POLLIDISIAC, categoryFunctionalFlowers); + pollidisiac.setLexiconPages(new PageText("0"), new PagePetalRecipe("1", ModPetalRecipes.pollidisiacRecipe)); + + clayconia = new BLexiconEntry(LibLexicon.FFLOWER_CLAYCONIA, categoryFunctionalFlowers); + clayconia.setLexiconPages(new PageText("0"), new PagePetalRecipe("1", ModPetalRecipes.clayconiaRecipe)); + + loonium = new ALexiconEntry(LibLexicon.FFLOWER_LOONIUM, categoryFunctionalFlowers); + loonium.setLexiconPages(new PageText("0"), new PagePetalRecipe("1", ModPetalRecipes.looniumRecipe)); + + daffomill = new BLexiconEntry(LibLexicon.FFLOWER_DAFFOMILL, categoryFunctionalFlowers); + daffomill.setLexiconPages(new PageText("0"), new PagePetalRecipe("1", ModPetalRecipes.daffomillRecipe)); + + vinculotus = new BLexiconEntry(LibLexicon.FFLOWER_VINCULOTUS, categoryFunctionalFlowers); + vinculotus.setLexiconPages(new PageText("0"), new PagePetalRecipe("1", ModPetalRecipes.vinculotusRecipe)); + + spectranthemum = new ALexiconEntry(LibLexicon.FFLOWER_SPECTRANTHEMUN, categoryFunctionalFlowers); + spectranthemum.setLexiconPages(new PageText("0"), new PageText("1"), new PageText("2"), + new PagePetalRecipe("3", ModPetalRecipes.spectranthemumRecipe)); + + medumone = new BLexiconEntry(LibLexicon.FFLOWER_MEDUMONE, categoryFunctionalFlowers); + medumone.setLexiconPages(new PageText("0"), new PagePetalRecipe("1", ModPetalRecipes.medumoneRecipe)); + + marimorphosis = new BLexiconEntry(LibLexicon.FFLOWER_MARIMORPHOSIS, categoryFunctionalFlowers); + marimorphosis.setLexiconPages(new PageText("0"), new PageImage("1", LibResources.ENTRY_METAMORPHIC_STONES), + new PagePetalRecipe("2", ModPetalRecipes.marimorphosisRecipe), + new PageCraftingRecipe("3", ModCraftingRecipes.recipesAltarMeta)); + + bubbell = new ALexiconEntry(LibLexicon.FFLOWER_BUBBELL, categoryFunctionalFlowers); + bubbell.setLexiconPages(new PageText("0"), new PagePetalRecipe("1", ModPetalRecipes.bubbellRecipe)); + + solegnolia = new BLexiconEntry(LibLexicon.FFLOWER_SOLEGNOLIA, categoryFunctionalFlowers); + solegnolia.setLexiconPages(new PageText("0"), new PagePetalRecipe("1", ModPetalRecipes.solegnoliaRecipe)); + + // GENERATING FLOWERS ENTRIES + if (ConfigHandler.hardcorePassiveGeneration > 0) { + generatingIntro = new BLexiconEntry(LibLexicon.GFLOWER_INTRO, categoryGenerationFlowers); + generatingIntro.setPriority().setLexiconPages(new PageText("0"), new PageText("1"), new PageText("2")); + } + + passiveGen = new BLexiconEntry(LibLexicon.GFLOWER_PASSIVE_GENERATION, categoryGenerationFlowers); + passiveGen.setPriority().setLexiconPages(new PageText("0"), new PageText("1")) + .setIcon(new ItemStack(Blocks.deadbush)); + + primusLoci = new BLexiconEntry(LibLexicon.GFLOWER_PRIMUS_LOCI, categoryGenerationFlowers); + primusLoci.setPriority().setLexiconPages(new PageText("0"), new PageText("1")); + primusLoci.setIcon(ItemBlockSpecialFlower.ofType(LibBlockNames.SUBTILE_DAYBLOOM_PRIME)); + primusLoci.addExtraDisplayedRecipe(ItemBlockSpecialFlower.ofType(LibBlockNames.SUBTILE_DAYBLOOM_PRIME)); + primusLoci.addExtraDisplayedRecipe(ItemBlockSpecialFlower.ofType(LibBlockNames.SUBTILE_NIGHTSHADE_PRIME)); + + daybloom = new BLexiconEntry(LibLexicon.GFLOWER_DAYBLOOM, categoryGenerationFlowers); + daybloom.setPriority().setLexiconPages(new PageText("0"), new PageText("1"), + new PagePetalRecipe("2", ModPetalRecipes.daybloomRecipe)); + + nightshade = new BLexiconEntry(LibLexicon.GFLOWER_NIGHTSHADE, categoryGenerationFlowers); + nightshade.setLexiconPages(new PageText("0"), new PagePetalRecipe("1", ModPetalRecipes.nightshadeRecipe)); + + endoflame = new BLexiconEntry(LibLexicon.GFLOWER_ENDOFLAME, categoryGenerationFlowers); + endoflame.setLexiconPages(new PageText("0"), new PageText("1"), new PageText("3"), + new PagePetalRecipe("2", ModPetalRecipes.endoflameRecipe)); + + hydroangeas = new BLexiconEntry(LibLexicon.GFLOWER_HYDROANGEAS, categoryGenerationFlowers); + hydroangeas.setLexiconPages(new PageText("0"), new PageImage("2", LibResources.ENTRY_HYDROANGEAS), + new PagePetalRecipe("1", ModPetalRecipes.hydroangeasRecipe)); + + thermalily = new BLexiconEntry(LibLexicon.GFLOWER_THERMALILY, categoryGenerationFlowers); + thermalily.setLexiconPages(new PageText("0"), new PageText("2"), new PageText("3"), + new PagePetalRecipe("1", ModPetalRecipes.thermalilyRecipe)); + + arcaneRose = new BLexiconEntry(LibLexicon.GFLOWER_ARCANE_ROSE, categoryGenerationFlowers); + arcaneRose.setLexiconPages(new PageText("0"), new PagePetalRecipe("1", ModPetalRecipes.arcaneRoseRecipe)); + + munchdew = new BLexiconEntry(LibLexicon.GFLOWER_MUNCHDEW, categoryGenerationFlowers); + munchdew.setLexiconPages(new PageText("0"), new PageText("1"), + new PagePetalRecipe("2", ModPetalRecipes.munchdewRecipe)); + + entropinnyum = new BLexiconEntry(LibLexicon.GFLOWER_ENTROPINNYUM, categoryGenerationFlowers); + entropinnyum.setLexiconPages(new PageText("0"), new PagePetalRecipe("1", ModPetalRecipes.entropinnyumRecipe)); + + kekimurus = new ALexiconEntry(LibLexicon.GFLOWER_KEKIMURUS, categoryGenerationFlowers); + kekimurus.setLexiconPages(new PageText("0"), new PagePetalRecipe("1", ModPetalRecipes.kekimurusRecipe)); + + gourmaryllis = new BLexiconEntry(LibLexicon.GFLOWER_GOURMARYLLIS, categoryGenerationFlowers); + gourmaryllis.setLexiconPages(new PageText("0"), new PageText("1"), new PageText("2"), + new PagePetalRecipe("3", ModPetalRecipes.gourmaryllisRecipe)); + + narslimmus = new BLexiconEntry(LibLexicon.GFLOWER_NARSLIMMUS, categoryGenerationFlowers); + narslimmus.setLexiconPages(new PageText("0"), new PagePetalRecipe("1", ModPetalRecipes.narslimmusRecipe)); + + spectrolus = new ALexiconEntry(LibLexicon.GFLOWER_SPECTROLUS, categoryGenerationFlowers); + spectrolus.setLexiconPages(new PageText("0"), new PageText("1"), + new PagePetalRecipe("2", ModPetalRecipes.spectrolusRecipe)); + + rafflowsia = new ALexiconEntry(LibLexicon.GFLOWER_RAFFLOWSIA, categoryGenerationFlowers); + rafflowsia.setLexiconPages(new PageText("0"), new PageText("1"), new PageText("2"), new PageText("3"), + new PagePetalRecipe("4", ModPetalRecipes.rafflowsiaRecipe)); + + dandelifeon = new ALexiconEntry(LibLexicon.GFLOWER_DANDELIFEON, categoryGenerationFlowers); + dandelifeon.setLexiconPages(new PageText("_w"), new PageText("0"), new PageText("1"), new PageText("2"), + new PageText("3"), new PageText("4"), new PageText("5"), new PageText("6"), new PageText("10"), + new PageText("7"), new PagePetalRecipe("8", ModPetalRecipes.dandelifeonRecipe), + new PageCraftingRecipe("9", ModCraftingRecipes.recipeCellBlock)); + + // DEVICES ENTRIES + pylon = new BLexiconEntry(LibLexicon.DEVICE_PYLON, categoryDevices); + pylon.setLexiconPages(new PageText("0"), new PageCraftingRecipe("1", ModCraftingRecipes.recipePylon)); + + if (ConfigHandler.enchanterEnabled) { + manaEnchanting = new BLexiconEntry(LibLexicon.DEVICE_MANA_ENCHANTING, categoryDevices); + manaEnchanting + .setLexiconPages(new PageText("0"), new PageText("1"), + new PageMultiblock("2", ModMultiblocks.enchanter), new PageText("5"), new PageText("6"), + new PageText("7"), new PageText("8"), new PageText("9")) + .setIcon(new ItemStack(ModBlocks.enchanter)); + } + + turntable = new BLexiconEntry(LibLexicon.DEVICE_TURNTABLE, categoryDevices); + turntable.setLexiconPages(new PageText("0"), new PageCraftingRecipe("1", ModCraftingRecipes.recipeTurntable)); + + alchemy = new BLexiconEntry(LibLexicon.DEVICE_ALCHEMY, categoryDevices); + alchemy.setLexiconPages(new PageText("0"), + new PageCraftingRecipe("1", ModCraftingRecipes.recipeAlchemyCatalyst), + new PageManaInfusionRecipe("2", ModManaAlchemyRecipes.leatherRecipe), + new PageManaInfusionRecipe("3", ModManaAlchemyRecipes.woodRecipes), + new PageManaInfusionRecipe("4", ModManaAlchemyRecipes.saplingRecipes), + new PageManaInfusionRecipe("5", ModManaAlchemyRecipes.glowstoneDustRecipe), + new PageManaInfusionRecipe("6", ModManaAlchemyRecipes.quartzRecipes).setSkipRegistry(), + new PageManaInfusionRecipe("7", ModManaAlchemyRecipes.chiseledBrickRecipe), + new PageManaInfusionRecipe("8", ModManaAlchemyRecipes.iceRecipe), + new PageManaInfusionRecipe("9", ModManaAlchemyRecipes.swampFolliageRecipes), + new PageManaInfusionRecipe("10", ModManaAlchemyRecipes.fishRecipes), + new PageManaInfusionRecipe("11", ModManaAlchemyRecipes.cropRecipes), + new PageManaInfusionRecipe("12", ModManaAlchemyRecipes.potatoRecipe), + new PageManaInfusionRecipe("13", ModManaAlchemyRecipes.netherWartRecipe), + new PageManaInfusionRecipe("14", ModManaAlchemyRecipes.gunpowderAndFlintRecipes), + new PageManaInfusionRecipe("15", ModManaAlchemyRecipes.nameTagRecipe), + new PageManaInfusionRecipe("16", ModManaAlchemyRecipes.stringRecipes), + new PageManaInfusionRecipe("17", ModManaAlchemyRecipes.slimeballCactusRecipes), + new PageManaInfusionRecipe("18", ModManaAlchemyRecipes.enderPearlRecipe), + new PageManaInfusionRecipe("19", ModManaAlchemyRecipes.redstoneToGlowstoneRecipes), + new PageManaInfusionRecipe("20", ModManaAlchemyRecipes.sandRecipe), + new PageManaInfusionRecipe("21", ModManaAlchemyRecipes.redSandRecipe), + new PageManaInfusionRecipe("22", ModManaAlchemyRecipes.clayBreakdownRecipes), + new PageManaInfusionRecipe("24", ModManaAlchemyRecipes.tallgrassRecipes), + new PageManaInfusionRecipe("25", ModManaAlchemyRecipes.flowersRecipes), + new PageManaInfusionRecipe("23", ModManaAlchemyRecipes.coarseDirtRecipe)); + + openCrate = new BLexiconEntry(LibLexicon.DEVICE_OPEN_CRATE, categoryDevices); + openCrate.setPriority().setLexiconPages(new PageText("0"), new PageText("1"), + new PageCraftingRecipe("2", ModCraftingRecipes.recipeOpenCrate)); + + forestEye = new BLexiconEntry(LibLexicon.DEVICE_FOREST_EYE, categoryDevices); + forestEye.setLexiconPages(new PageText("0"), new PageText("1"), + new PageCraftingRecipe("2", ModCraftingRecipes.recipeForestEye)); + + forestDrum = new BLexiconEntry(LibLexicon.DEVICE_FOREST_DRUM, categoryDevices); + forestDrum.setLexiconPages(new PageText("0"), new PageText("1"), + new PageCraftingRecipe("2", ModCraftingRecipes.recipeForestDrum)); + + platform = new BLexiconEntry(LibLexicon.DEVICE_PLATFORM, categoryDevices); + platform.setLexiconPages(new PageText("0"), new PageText("2"), + new PageCraftingRecipe("1", ModCraftingRecipes.recipePlatform)); + + conjurationCatalyst = new ALexiconEntry(LibLexicon.DEVICE_MANA_CONJURATION, categoryDevices); + conjurationCatalyst.setLexiconPages(new PageText("0"), + new PageCraftingRecipe("1", ModCraftingRecipes.recipeConjurationCatalyst), + new PageManaInfusionRecipe("2", ModManaConjurationRecipes.redstoneRecipe), + new PageManaInfusionRecipe("3", ModManaConjurationRecipes.glowstoneRecipe), + new PageManaInfusionRecipe("4", ModManaConjurationRecipes.quartzRecipe), + new PageManaInfusionRecipe("5", ModManaConjurationRecipes.coalRecipe), + new PageManaInfusionRecipe("6", ModManaConjurationRecipes.snowballRecipe), + new PageManaInfusionRecipe("7", ModManaConjurationRecipes.netherrackRecipe), + new PageManaInfusionRecipe("8", ModManaConjurationRecipes.soulSandRecipe), + new PageManaInfusionRecipe("9", ModManaConjurationRecipes.gravelRecipe), + new PageManaInfusionRecipe("10", ModManaConjurationRecipes.leavesRecipes), + new PageManaInfusionRecipe("11", ModManaConjurationRecipes.grassRecipe)); + + spectralPlatform = new ALexiconEntry(LibLexicon.DEVICE_SPECTRAL_PLATFORM, categoryDevices); + spectralPlatform.setLexiconPages(new PageText("0"), + new PageCraftingRecipe("1", ModCraftingRecipes.recipeSpectralPlatform)); + + gatherDrum = new ALexiconEntry(LibLexicon.DEVICE_GATHER_DRUM, categoryDevices); + gatherDrum.setLexiconPages(new PageText("0"), new PageCraftingRecipe("1", ModCraftingRecipes.recipeGatherDrum)); + + craftCrate = new ALexiconEntry(LibLexicon.DEVICE_CRAFT_CRATE, categoryDevices); + craftCrate + .setLexiconPages(new PageText("0"), new PageText("1"), + new PageCraftingRecipe("2", ModCraftingRecipes.recipePlaceholder), new PageText("3"), + new PageText("4"), new PageText("7"), new PageImage("5", LibResources.ENTRY_CRAFT_CRATE), + new PageCraftingRecipe("6", ModCraftingRecipes.recipeCraftCrate), new PageText("8"), + new PageCraftingRecipe("9", ModCraftingRecipes.recipesPatterns)) + .setIcon(new ItemStack(ModBlocks.openCrate, 1, 1)); + + brewery = new BLexiconEntry(LibLexicon.DEVICE_BREWERY, categoryDevices); + brewery.setLexiconPages(new PageText("0"), new PageText("1"), + new PageCraftingRecipe("2", ModCraftingRecipes.recipeBrewery), + new PageCraftingRecipe("3", ModCraftingRecipes.recipeVial), new PageText("4"), + new PageBrew(ModBrewRecipes.speedBrew, "5a", "5b"), + new PageBrew(ModBrewRecipes.strengthBrew, "6a", "6b"), + new PageBrew(ModBrewRecipes.hasteBrew, "7a", "7b"), + new PageBrew(ModBrewRecipes.healingBrew, "8a", "8b"), + new PageBrew(ModBrewRecipes.jumpBoostBrew, "9a", "9b"), + new PageBrew(ModBrewRecipes.regenerationBrew, "10a", "10b"), + new PageBrew(ModBrewRecipes.weakRegenerationBrew, "17a", "17b"), + new PageBrew(ModBrewRecipes.resistanceBrew, "11a", "11b"), + new PageBrew(ModBrewRecipes.fireResistanceBrew, "12a", "12b"), + new PageBrew(ModBrewRecipes.waterBreathingBrew, "13a", "13b"), + new PageBrew(ModBrewRecipes.invisibilityBrew, "14a", "14b"), + new PageBrew(ModBrewRecipes.nightVisionBrew, "15a", "15b"), + new PageBrew(ModBrewRecipes.absorptionBrew, "16a", "16b")); + + flasks = new ALexiconEntry(LibLexicon.DEVICE_FLASKS, categoryDevices); + flasks.setLexiconPages(new PageText("0"), new PageText("1"), + new PageCraftingRecipe("2", ModCraftingRecipes.recipeFlask)); + + complexBrews = new BLexiconEntry(LibLexicon.DEVICE_COMPLEX_BREWS, categoryDevices); + complexBrews.setLexiconPages(new PageText("0"), new PageBrew(ModBrewRecipes.overloadBrew, "1a", "1b"), + new PageBrew(ModBrewRecipes.soulCrossBrew, "2a", "2b"), + new PageBrew(ModBrewRecipes.featherFeetBrew, "3a", "3b"), + new PageBrew(ModBrewRecipes.emptinessBrew, "4a", "4b"), + new PageBrew(ModBrewRecipes.bloodthirstBrew, "5a", "5b"), + new PageBrew(ModBrewRecipes.allureBrew, "6a", "6b"), new PageBrew(ModBrewRecipes.clearBrew, "7a", "7b")) + .setIcon(((IBrewContainer) ModItems.vial).getItemForBrew(ModBrews.jumpBoost, + new ItemStack(ModItems.vial))); + + incense = new BLexiconEntry(LibLexicon.DEVICE_INCENSE, categoryDevices); + incense.setLexiconPages(new PageText("0"), new PageText("1"), new PageText("2"), new PageText("5"), + new PageCraftingRecipe("3", ModCraftingRecipes.recipeIncenseStick), + new PageCraftingRecipe("4", ModCraftingRecipes.recipeIncensePlate)); + + hourglass = new BLexiconEntry(LibLexicon.DEVICE_HOURGLASS, categoryDevices); + hourglass.setPriority().setLexiconPages(new PageText("0"), new PageText("1"), new PageText("2"), + new PageText("3"), new PageText("4"), new PageCraftingRecipe("5", ModCraftingRecipes.recipeHourglass)); + + ghostRail = new ALexiconEntry(LibLexicon.DEVICE_GHOST_RAIL, categoryDevices); + ghostRail.setLexiconPages(new PageText("0"), new PageCraftingRecipe("1", ModCraftingRecipes.recipeGhostRail)); + + canopyDrum = new BLexiconEntry(LibLexicon.DEVICE_CANOPY_DRUM, categoryDevices); + canopyDrum.setLexiconPages(new PageText("0"), new PageCraftingRecipe("1", ModCraftingRecipes.recipeCanopyDrum)); + + cocoon = Botania.gardenOfGlassLoaded ? new BLexiconEntry(LibLexicon.DEVICE_COCOON, categoryDevices) + : new ALexiconEntry(LibLexicon.DEVICE_COCOON, categoryDevices); + cocoon.setLexiconPages(new PageText("0"), new PageText("1"), + new PageCraftingRecipe("2", ModCraftingRecipes.recipeCocoon)); + + manaBomb = new ALexiconEntry(LibLexicon.DEVICE_MANA_BOMB, categoryDevices); + manaBomb.setLexiconPages(new PageText("0"), new PageCraftingRecipe("1", ModCraftingRecipes.recipeManaBomb)); + + teruTeruBozu = new BLexiconEntry(LibLexicon.DEVICE_TERU_TERU_BOZU, categoryDevices); + teruTeruBozu.setLexiconPages(new PageText("0"), + new PageCraftingRecipe("1", ModCraftingRecipes.recipeTeruTeruBozu)); + + avatar = new BLexiconEntry(LibLexicon.DEVICE_AVATAR, categoryDevices); + avatar.setLexiconPages(new PageText("0"), new PageText("1"), + new PageCraftingRecipe("2", ModCraftingRecipes.recipeAvatar)); + + felPumpkin = new BLexiconEntry(LibLexicon.DEVICE_FEL_PUMPKIN, categoryDevices); + felPumpkin.setLexiconPages(new PageText("0"), new PageCraftingRecipe("1", ModCraftingRecipes.recipeFelPumpkin)); + + // TOOLS ENTRIES + manaBlaster = new BLexiconEntry(LibLexicon.TOOL_MANA_BLASTER, categoryTools); + manaBlaster.setLexiconPages(new PageText("0"), new PageText("1"), new PageText("2"), + new PageCraftingRecipe("3", ModCraftingRecipes.recipeManaBlaster)); + + grassSeeds = new BLexiconEntry(LibLexicon.TOOL_GRASS_SEEDS, categoryTools); + grassSeeds.setLexiconPages(new PageText("0"), + new PageManaInfusionRecipe("1", ModManaInfusionRecipes.grassSeedsRecipe), + new PageManaInfusionRecipe("2", ModManaInfusionRecipes.podzolSeedsRecipe), + new PageManaInfusionRecipe("3", ModManaInfusionRecipes.mycelSeedsRecipes), new PageText("4"), + new PageCraftingRecipe("5", ModCraftingRecipes.recipesAltGrassSeeds)); + + dirtRod = new BLexiconEntry(LibLexicon.TOOL_DIRT_ROD, categoryTools); + dirtRod.setLexiconPages(new PageText("0"), new PageCraftingRecipe("1", ModCraftingRecipes.recipeDirtRod)); + + terraformRod = new BLexiconEntry(LibLexicon.TOOL_TERRAFORM_ROD, categoryTools); + terraformRod.setLexiconPages(new PageText("0"), new PageText("1"), new PageText("2"), + new PageCraftingRecipe("3", ModCraftingRecipes.recipeTerraformRod)); + + manasteelGear = new BLexiconEntry(LibLexicon.TOOL_MANASTEEL_GEAR, categoryTools); + manasteelGear.setPriority().setLexiconPages(new PageText("0"), new PageText("10"), + new PageCraftingRecipe("1", ModCraftingRecipes.recipeManasteelPick), + new PageCraftingRecipe("2", ModCraftingRecipes.recipeManasteelShovel), + new PageCraftingRecipe("3", ModCraftingRecipes.recipeManasteelAxe), + new PageCraftingRecipe("4", ModCraftingRecipes.recipeManasteelShears), + new PageCraftingRecipe("5", ModCraftingRecipes.recipeManasteelSword), + new PageCraftingRecipe("6", ModCraftingRecipes.recipeManasteelHelm), + new PageCraftingRecipe("7", ModCraftingRecipes.recipeManasteelChest), + new PageCraftingRecipe("8", ModCraftingRecipes.recipeManasteelLegs), + new PageCraftingRecipe("9", ModCraftingRecipes.recipeManasteelBoots)); + + terrasteelArmor = new BLexiconEntry(LibLexicon.TOOL_TERRASTEEL_ARMOR, categoryTools); + terrasteelArmor.setLexiconPages(new PageText("0"), + new PageCraftingRecipe("1", ModCraftingRecipes.recipeTerrasteelHelm), + new PageCraftingRecipe("2", ModCraftingRecipes.recipeTerrasteelChest), + new PageCraftingRecipe("3", ModCraftingRecipes.recipeTerrasteelLegs), + new PageCraftingRecipe("4", ModCraftingRecipes.recipeTerrasteelBoots)); + + grassHorn = new BLexiconEntry(LibLexicon.TOOL_GRASS_HORN, categoryTools); + grassHorn.setLexiconPages(new PageText("0"), new PageCraftingRecipe("1", ModCraftingRecipes.recipeGrassHorn), + new PageCraftingRecipe("2", ModCraftingRecipes.recipeLeafHorn), + new PageCraftingRecipe("3", ModCraftingRecipes.recipeSnowHorn)); + + terraBlade = new BLexiconEntry(LibLexicon.TOOL_TERRA_SWORD, categoryTools); + terraBlade.setLexiconPages(new PageText("0"), new PageCraftingRecipe("1", ModCraftingRecipes.recipeTerraSword)); + + terraPick = new BLexiconEntry(LibLexicon.TOOL_TERRA_PICK, categoryTools); + terraPick.setLexiconPages(new PageText("0"), new PageText("1"), new PageText("2"), new PageText("3"), + new PageText("4"), new PageCraftingRecipe("5", ModCraftingRecipes.recipeTerraPick)); + + waterRod = new BLexiconEntry(LibLexicon.TOOL_WATER_ROD, categoryTools); + waterRod.setLexiconPages(new PageText("0"), new PageCraftingRecipe("1", ModCraftingRecipes.recipeWaterRod)); + + elfGear = new ALexiconEntry(LibLexicon.TOOL_ELF_GEAR, categoryTools); + elfGear.setLexiconPages(new PageText("0"), new PageText("1"), new PageText("2"), + new PageCraftingRecipe("3", ModCraftingRecipes.recipeElementiumPick), new PageText("4"), + new PageCraftingRecipe("5", ModCraftingRecipes.recipeElementiumShovel), new PageText("6"), + new PageCraftingRecipe("7", ModCraftingRecipes.recipeElementiumAxe), new PageText("8"), + new PageCraftingRecipe("9", ModCraftingRecipes.recipeElementiumShears), new PageText("10"), + new PageCraftingRecipe("11", ModCraftingRecipes.recipeElementiumSword), + new PageCraftingRecipe("12", ModCraftingRecipes.recipeElementiumHelm), + new PageCraftingRecipe("13", ModCraftingRecipes.recipeElementiumChest), + new PageCraftingRecipe("14", ModCraftingRecipes.recipeElementiumLegs), + new PageCraftingRecipe("15", ModCraftingRecipes.recipeElementiumBoots)); + + openBucket = new ALexiconEntry(LibLexicon.TOOL_OPEN_BUCKET, categoryTools); + openBucket.setLexiconPages(new PageText("0"), new PageCraftingRecipe("1", ModCraftingRecipes.recipeOpenBucket)); + + rainbowRod = new ALexiconEntry(LibLexicon.TOOL_RAINBOW_ROD, categoryTools); + rainbowRod.setLexiconPages(new PageText("0"), new PageText("1"), new PageText("6"), + new PageCraftingRecipe("2", ModCraftingRecipes.recipeRainbowRod), + new PageCraftingRecipe("3", ModCraftingRecipes.recipeBifrost), + new PageCraftingRecipe("4", ModCraftingRecipes.recipeShimmerrock), + new PageCraftingRecipe("5", ModCraftingRecipes.recipeShimmerwoodPlanks), + new PageCraftingRecipe("7", ModCraftingRecipes.recipePoolFabulous)); + + tornadoRod = new BLexiconEntry(LibLexicon.TOOL_TORNADO_ROD, categoryTools); + tornadoRod.setLexiconPages(new PageText("0"), new PageText("2"), + new PageCraftingRecipe("1", ModCraftingRecipes.recipeTornadoRod)); + + fireRod = new BLexiconEntry(LibLexicon.TOOL_FIRE_ROD, categoryTools); + fireRod.setLexiconPages(new PageText("0"), new PageText("2"), + new PageCraftingRecipe("1", ModCraftingRecipes.recipeFireRod)); + + vineBall = new BLexiconEntry(LibLexicon.TOOL_VINE_BALL, categoryTools); + vineBall.setLexiconPages(new PageText("0"), new PageText("1"), + new PageCraftingRecipe("2", ModCraftingRecipes.recipeVineBall), + new PageCraftingRecipe("3", ModCraftingRecipes.recipeSlingshot), + new PageCraftingRecipe("4", ModCraftingRecipes.recipeMossStone)); + + laputaShard = new ALexiconEntry(LibLexicon.TOOL_LAPUTA_SHARD, categoryTools); + laputaShard.setLexiconPages(new PageText("0"), new PageText("2"), + new PageCraftingRecipe("1", ModCraftingRecipes.recipesLaputaShard), + new PageCraftingRecipe("3", ModCraftingRecipes.recipesLaputaShardUpgrade)); + + virus = new ALexiconEntry(LibLexicon.TOOL_VIRUS, categoryTools); + virus.setLexiconPages(new PageText("0"), new PageCraftingRecipe("1", ModCraftingRecipes.recipeVirusZombie), + new PageCraftingRecipe("2", ModCraftingRecipes.recipeVirusSkeleton)); + + skyDirtRod = new ALexiconEntry(LibLexicon.TOOL_SKY_DIRT_ROD, categoryTools); + skyDirtRod.setLexiconPages(new PageText("0"), new PageCraftingRecipe("1", ModCraftingRecipes.recipeSkyDirtRod)); + + glassPick = new BLexiconEntry(LibLexicon.TOOL_GLASS_PICK, categoryTools); + glassPick.setLexiconPages(new PageText("0"), new PageCraftingRecipe("1", ModCraftingRecipes.recipeGlassPick)); + + diviningRod = new BLexiconEntry(LibLexicon.TOOL_DIVINING_ROD, categoryTools); + diviningRod.setLexiconPages(new PageText("0"), new PageText("2"), + new PageCraftingRecipe("1", ModCraftingRecipes.recipeDiviningRod)); + + gravityRod = new ALexiconEntry(LibLexicon.TOOL_GRAVITY_ROD, categoryTools); + gravityRod.setLexiconPages(new PageText("0"), new PageText("1"), + new PageCraftingRecipe("2", ModCraftingRecipes.recipeGravityRod)); + + regenIvy = new ALexiconEntry(LibLexicon.TOOL_REGEN_IVY, categoryTools); + regenIvy.setLexiconPages(new PageText("0"), new PageText("1"), + new PageCraftingRecipe("2", ModCraftingRecipes.recipeRegenIvy)); + + missileRod = new ALexiconEntry(LibLexicon.TOOL_MISSILE_ROD, categoryTools); + missileRod.setLexiconPages(new PageText("0"), new PageText("2"), + new PageCraftingRecipe("1", ModCraftingRecipes.recipeMissileRod)); + + craftingHalo = new BLexiconEntry(LibLexicon.TOOL_CRAFTING_HALO, categoryTools); + craftingHalo.setLexiconPages(new PageText("0"), new PageText("1"), + new PageCraftingRecipe("2", ModCraftingRecipes.recipeCraftingHalo)); + + clip = new ALexiconEntry(LibLexicon.TOOL_CLIP, categoryTools); + clip.setLexiconPages(new PageText("0"), new PageText("1"), + new PageCraftingRecipe("2", ModCraftingRecipes.recipeClip)); + + cobbleRod = new BLexiconEntry(LibLexicon.TOOL_COBBLE_ROD, categoryTools); + cobbleRod.setLexiconPages(new PageText("0"), new PageCraftingRecipe("1", ModCraftingRecipes.recipeCobbleRod)); + + smeltRod = new BLexiconEntry(LibLexicon.TOOL_SMELT_ROD, categoryTools); + smeltRod.setLexiconPages(new PageText("0"), new PageCraftingRecipe("1", ModCraftingRecipes.recipeSmeltRod)); + + worldSeed = new ALexiconEntry(LibLexicon.TOOL_WORLD_SEED, categoryTools); + worldSeed.setLexiconPages(new PageText("0"), new PageCraftingRecipe("1", ModCraftingRecipes.recipeWorldSeed)); + + spellCloth = new BLexiconEntry(LibLexicon.TOOL_SPELL_CLOTH, categoryTools); + spellCloth.setLexiconPages(new PageText("0"), new PageCraftingRecipe("1", ModCraftingRecipes.recipeSpellCloth)); + + thornChakram = new BLexiconEntry(LibLexicon.TOOL_THORN_CHAKRAM, categoryTools); + thornChakram.setLexiconPages(new PageText("0"), + new PageCraftingRecipe("1", ModCraftingRecipes.recipeThornChakram)); + + fireChakram = new ALexiconEntry(LibLexicon.TOOL_FIRE_CHAKRAM, categoryTools); + fireChakram.setLexiconPages(new PageText("0"), + new PageCraftingRecipe("1", ModCraftingRecipes.recipeFireChakram)); + + overgrowthSeed = new BLexiconEntry(LibLexicon.TOOL_OVERGROWTH_SEED, categoryTools); + overgrowthSeed.setPriority().setLexiconPages(new PageText("0"), new PageText("1")) + .setIcon(new ItemStack(ModItems.overgrowthSeed)); + overgrowthSeed.addExtraDisplayedRecipe(new ItemStack(ModItems.overgrowthSeed)); + overgrowthSeed.addExtraDisplayedRecipe(new ItemStack(ModBlocks.enchantedSoil)); + + livingwoodBow = new BLexiconEntry(LibLexicon.TOOL_LIVINGWOOD_BOW, categoryTools); + livingwoodBow.setLexiconPages(new PageText("0"), + new PageCraftingRecipe("1", ModCraftingRecipes.recipeLivingwoodBow)); + + crystalBow = new ALexiconEntry(LibLexicon.TOOL_CRYSTAL_BOW, categoryTools); + crystalBow.setLexiconPages(new PageText("0"), new PageCraftingRecipe("1", ModCraftingRecipes.recipeCrystalBow)); + + temperanceStone = new BLexiconEntry(LibLexicon.TOOL_TEMPERANCE_STONE, categoryTools); + temperanceStone.setLexiconPages(new PageText("0"), + new PageCraftingRecipe("1", ModCraftingRecipes.recipeTemperanceStone)); + + terraAxe = new BLexiconEntry(LibLexicon.TOOL_TERRA_AXE, categoryTools); + terraAxe.setLexiconPages(new PageText("0"), new PageCraftingRecipe("1", ModCraftingRecipes.recipeTerraAxe)); + + obedienceStick = new BLexiconEntry(LibLexicon.TOOL_OBEDIENCE_STICK, categoryTools); + obedienceStick.setPriority().setLexiconPages(new PageText("0"), + new PageCraftingRecipe("1", ModCraftingRecipes.recipeObedienceStick)); + + slimeBottle = new ALexiconEntry(LibLexicon.TOOL_SLIME_BOTTLE, categoryTools); + slimeBottle.setLexiconPages(new PageText("0"), + new PageCraftingRecipe("1", ModCraftingRecipes.recipeSlimeBottle)); + + exchangeRod = new BLexiconEntry(LibLexicon.TOOL_EXCHANGE_ROD, categoryTools); + exchangeRod.setLexiconPages(new PageText("0"), new PageText("1"), new PageText("2"), + new PageCraftingRecipe("3", ModCraftingRecipes.recipeExchangeRod)); + + manaweave = new BLexiconEntry(LibLexicon.TOOL_MANAWEAVE, categoryTools); + manaweave.setLexiconPages(new PageText("0"), new PageText("1"), + new PageCraftingRecipe("2", ModCraftingRecipes.recipeManaweaveCloth), + new PageCraftingRecipe("3", ModCraftingRecipes.recipeManaweaveHelm), + new PageCraftingRecipe("4", ModCraftingRecipes.recipeManaweaveChest), + new PageCraftingRecipe("5", ModCraftingRecipes.recipeManaweaveLegs), + new PageCraftingRecipe("6", ModCraftingRecipes.recipeManaweaveBoots)); + + autocraftingHalo = new BLexiconEntry(LibLexicon.TOOL_AUTOCRAFTING_HALO, categoryTools); + autocraftingHalo.setLexiconPages(new PageText("0"), + new PageCraftingRecipe("1", ModCraftingRecipes.recipeAutocraftingHalo)); + + sextant = new BLexiconEntry(LibLexicon.TOOL_SEXTANT, categoryTools); + sextant.setLexiconPages(new PageText("0"), new PageText("1"), + new PageCraftingRecipe("2", ModCraftingRecipes.recipeSextant)); + + // ENDER ENTRIES + enderAir = new BLexiconEntry(LibLexicon.ENDER_AIR, categoryEnder); + enderAir.setPriority().setLexiconPages(new PageText("0")); + enderAir.addExtraDisplayedRecipe(new ItemStack(ModItems.manaResource, 1, 15)); + LexiconRecipeMappings.map(new ItemStack(ModItems.manaResource, 1, 15), enderAir, 0); + + enderEyeBlock = new BLexiconEntry(LibLexicon.ENDER_ENDER_EYE_BLOCK, categoryEnder); + enderEyeBlock.setLexiconPages(new PageText("0"), + new PageCraftingRecipe("1", ModCraftingRecipes.recipeEnderEyeBlock)); + + pistonRelay = new BLexiconEntry(LibLexicon.ENDER_PISTON_RELAY, categoryEnder); + pistonRelay.setLexiconPages(new PageText("0"), new PageText("1"), + new PageManaInfusionRecipe("2", ModManaInfusionRecipes.pistonRelayRecipe)); + + enderHand = new BLexiconEntry(LibLexicon.ENDER_ENDER_HAND, categoryEnder); + enderHand.setLexiconPages(new PageText(ConfigHandler.enderPickpocketEnabled ? "0" : "0a"), new PageText("2"), + new PageCraftingRecipe(ConfigHandler.enderPickpocketEnabled ? "1" : "1a", + ModCraftingRecipes.recipeEnderHand)); + + enderDagger = new BLexiconEntry(LibLexicon.ENDER_ENDER_DAGGER, categoryEnder); + enderDagger.setLexiconPages(new PageText("0"), new PageText("1"), + new PageCraftingRecipe("2", ModCraftingRecipes.recipeEnderDagger)); + + spawnerClaw = new ALexiconEntry(LibLexicon.ENDER_SPAWNER_CLAW, categoryEnder); + spawnerClaw.setLexiconPages(new PageText("0"), new PageText("1"), + new PageCraftingRecipe("2", ModCraftingRecipes.recipeSpawnerClaw)); + + redString = new ALexiconEntry(LibLexicon.ENDER_RED_STRING, categoryEnder); + redString.setLexiconPages(new PageText("0"), new PageText("1"), + new PageCraftingRecipe("2", ModCraftingRecipes.recipeRedString), new PageText("3"), + new PageCraftingRecipe("4", ModCraftingRecipes.recipeRedStringContainer), new PageText("5"), + new PageCraftingRecipe("6", ModCraftingRecipes.recipeRedStringDispenser), new PageText("7"), + new PageCraftingRecipe("8", ModCraftingRecipes.recipeRedStringFertilizer), new PageText("9"), + new PageCraftingRecipe("10", ModCraftingRecipes.recipeRedStringComparator), new PageText("11"), + new PageCraftingRecipe("12", ModCraftingRecipes.recipeRedStringRelay), new PageText("13"), + new PageCraftingRecipe("14", ModCraftingRecipes.recipeRedStringInterceptor)); + + flightTiara = new ALexiconEntry(LibLexicon.ENDER_FLIGHT_TIARA, categoryEnder); + flightTiara.setLexiconPages(new PageText("0"), new PageText("4"), new PageText("5"), new PageText("6"), + new PageCraftingRecipe("1", ModCraftingRecipes.recipeFlightTiara), new PageText("2"), + new PageCraftingRecipe("3", ModCraftingRecipes.recipesWings)); + + corporea = new ALexiconEntry(LibLexicon.ENDER_CORPOREA, categoryEnder); + corporea.setLexiconPages(new PageText("0"), new PageText("1"), new PageText("2"), new PageText("3"), + new PageText("4"), new PageText("5"), new PageText("6"), + new PageCraftingRecipe("7", ModCraftingRecipes.recipeCorporeaSpark), + new PageCraftingRecipe("8", ModCraftingRecipes.recipeMasterCorporeaSpark)); + + corporeaIndex = new ALexiconEntry(LibLexicon.ENDER_CORPOREA_INDEX, categoryEnder); + corporeaIndex.setLexiconPages(new PageText("0"), new PageText("1"), new PageText("2"), new PageText("3"), + new PageText("4"), new PageText("5"), new PageText("8"), new PageText("6"), + new PageCraftingRecipe("7", ModCraftingRecipes.recipeCorporeaIndex)); + + corporeaFunnel = new ALexiconEntry(LibLexicon.ENDER_CORPOREA_FUNNEL, categoryEnder); + corporeaFunnel.setLexiconPages(new PageText("0"), new PageText("1"), + new PageCraftingRecipe("2", ModCraftingRecipes.recipeCorporeaFunnel)); + + corporeaInterceptor = new ALexiconEntry(LibLexicon.ENDER_CORPOREA_INTERCEPTOR, categoryEnder); + corporeaInterceptor.setLexiconPages(new PageText("0"), new PageText("1"), + new PageCraftingRecipe("2", ModCraftingRecipes.recipeCorporeaInterceptor)); + + if (ConfigHandler.enderStuff19Enabled) { + endStoneDecor = new BLexiconEntry(LibLexicon.ENDER_END_STONE_DECOR, categoryEnder); + endStoneDecor.setLexiconPages(new PageText("0"), + new PageCraftingRecipe("1", ModCraftingRecipes.recipeEndStoneBricks), + new PageCraftingRecipe("2", ModCraftingRecipes.recipeEndStoneChiseledBricks), + new PageCraftingRecipe("3", ModCraftingRecipes.recipeEnderBricks), + new PageCraftingRecipe("4", ModCraftingRecipes.recipePillarEnderBricks)); + } + + spawnerMover = new ALexiconEntry(LibLexicon.ENDER_SPAWNER_MOVER, categoryEnder); + spawnerMover.setLexiconPages(new PageText("0"), + new PageCraftingRecipe("1", ModCraftingRecipes.recipeSpawnerMover)); + + keepIvy = new ALexiconEntry(LibLexicon.ENDER_KEEP_IVY, categoryEnder); + keepIvy.setLexiconPages(new PageText("0"), new PageText("2"), + new PageCraftingRecipe("1", ModCraftingRecipes.recipeKeepIvy)); + + blackHoleTalisman = new ALexiconEntry(LibLexicon.ENDER_BLACK_HOLE_TALISMAN, categoryEnder); + blackHoleTalisman.setLexiconPages(new PageText("0"), new PageText("1"), new PageText("2"), + new PageCraftingRecipe("3", ModCraftingRecipes.recipeBlackHoleTalisman)); + + corporeaCrystalCube = new ALexiconEntry(LibLexicon.ENDER_CORPOREA_CRYSTAL_CUBE, categoryEnder); + corporeaCrystalCube.setLexiconPages(new PageText("0"), new PageText("1"), new PageText("3"), + new PageCraftingRecipe("2", ModCraftingRecipes.recipeCorporeaCrystalCube)); + + luminizerTransport = new ALexiconEntry(LibLexicon.ENDER_LUMINIZER_TRANSPORT, categoryEnder); + luminizerTransport.setLexiconPages(new PageText("0"), new PageText("1"), + new PageCraftingRecipe("2", ModCraftingRecipes.recipeLuminizer), new PageText("3"), + new PageCraftingRecipe("4", ModCraftingRecipes.recipeDetectorLuminizer), new PageText("5"), + new PageCraftingRecipe("6", ModCraftingRecipes.recipeLuminizerLauncher)); + + starSword = new ALexiconEntry(LibLexicon.ENDER_STAR_SWORD, categoryEnder); + starSword.setLexiconPages(new PageText("0"), new PageCraftingRecipe("1", ModCraftingRecipes.recipeStarSword)); + + thunderSword = new ALexiconEntry(LibLexicon.ENDER_THUNDER_SWORD, categoryEnder); + thunderSword.setLexiconPages(new PageText("0"), + new PageCraftingRecipe("1", ModCraftingRecipes.recipeThunderSword)); + + corporeaRetainer = new ALexiconEntry(LibLexicon.ENDER_CORPOREA_RETAINER, categoryEnder); + corporeaRetainer.setLexiconPages(new PageText("0"), new PageText("1"), new PageText("2"), + new PageCraftingRecipe("3", ModCraftingRecipes.recipeCorporeaRetainer)); + + // BAUBLES ENTRIES + baublesIntro = new BLexiconEntry(LibLexicon.BAUBLE_INTRO, categoryBaubles); + baublesIntro.setPriority().setLexiconPages(new PageText("0"), new PageImage("1", LibResources.ENTRY_BAUBLES), + new PageText("2")); + + cosmeticBaubles = new BLexiconEntry(LibLexicon.BAUBLE_COSMETIC, categoryBaubles); + { + List pages = new ArrayList(); + pages.add(new PageText("0")); + pages.add(new PageText("1")); + if (ModCraftingRecipes.recipesCosmeticItems != null) { + for (int i = 0; i < 32; i++) { + pages.add(new PageCraftingRecipe("" + (i + 2), ModCraftingRecipes.recipesCosmeticItems.get(i))); + } + } + cosmeticBaubles.setPriority().setLexiconPages(pages.toArray(new LexiconPage[pages.size()])); + } + + tinyPlanet = new BLexiconEntry(LibLexicon.BAUBLE_TINY_PLANET, categoryBaubles); + tinyPlanet.setLexiconPages(new PageText("0"), new PageCraftingRecipe("1", ModCraftingRecipes.recipeTinyPlanet), + new PageCraftingRecipe("2", ModCraftingRecipes.recipeTinyPlanetBlock)); + + manaRing = new BLexiconEntry(LibLexicon.BAUBLE_MANA_RING, categoryBaubles); + manaRing.setLexiconPages(new PageText("0"), new PageCraftingRecipe("1", ModCraftingRecipes.recipeManaRing), + new PageCraftingRecipe("2", ModCraftingRecipes.recipeGreaterManaRing)); + + auraRing = new BLexiconEntry(LibLexicon.BAUBLE_AURA_RING, categoryBaubles); + auraRing.setLexiconPages(new PageText("0"), new PageCraftingRecipe("1", ModCraftingRecipes.recipeAuraRing), + new PageCraftingRecipe("2", ModCraftingRecipes.recipeGreaterAuraRing)); + + travelBelt = new BLexiconEntry(LibLexicon.BAUBLE_TRAVEL_BELT, categoryBaubles); + travelBelt.setLexiconPages(new PageText("0"), new PageCraftingRecipe("1", ModCraftingRecipes.recipeTravelBelt)); + + knockbacklBelt = new BLexiconEntry(LibLexicon.BAUBLE_KNOCKBACK_BELT, categoryBaubles); + knockbacklBelt.setLexiconPages(new PageText("0"), + new PageCraftingRecipe("1", ModCraftingRecipes.recipeKnocbackBelt)); + + icePendant = new BLexiconEntry(LibLexicon.BAUBLE_ICE_PENDANT, categoryBaubles); + icePendant.setLexiconPages(new PageText("0"), new PageCraftingRecipe("1", ModCraftingRecipes.recipeIcePendant)); + + lavaPendant = new BLexiconEntry(LibLexicon.BAUBLE_LAVA_PENDANT, categoryBaubles); + lavaPendant.setLexiconPages(new PageText("0"), + new PageCraftingRecipe("1", ModCraftingRecipes.recipeFirePendant)); + + goldLaurel = new ALexiconEntry(LibLexicon.BAUBLE_GOLDEN_LAUREL, categoryBaubles); + goldLaurel.setLexiconPages(new PageText("0"), + new PageCraftingRecipe("1", ModCraftingRecipes.recipeGoldenLaurel)); + + waterRing = new BLexiconEntry(LibLexicon.BAUBLE_WATER_RING, categoryBaubles); + waterRing.setLexiconPages(new PageText("0"), new PageCraftingRecipe("1", ModCraftingRecipes.recipeWaterRing)); + + miningRing = new BLexiconEntry(LibLexicon.BAUBLE_MINING_RING, categoryBaubles); + miningRing.setLexiconPages(new PageText("0"), new PageCraftingRecipe("1", ModCraftingRecipes.recipeMiningRing)); + + magnetRing = new BLexiconEntry(LibLexicon.BAUBLE_MAGNET_RING, categoryBaubles); + magnetRing.setLexiconPages(new PageText("0"), new PageCraftingRecipe("1", ModCraftingRecipes.recipeMagnetRing), + new PageCraftingRecipe("2", ModCraftingRecipes.recipeGreaterMagnetRing)); + + divaCharm = new ALexiconEntry(LibLexicon.BAUBLE_DIVA_CHARM, categoryBaubles); + divaCharm.setLexiconPages(new PageText("0"), new PageCraftingRecipe("1", ModCraftingRecipes.recipeDivaCharm)); + + pixieRing = new ALexiconEntry(LibLexicon.BAUBLE_PIXIE_RING, categoryBaubles); + pixieRing.setLexiconPages(new PageText("0"), new PageCraftingRecipe("1", ModCraftingRecipes.recipePixieRing)); + + superTravelBelt = new ALexiconEntry(LibLexicon.BAUBLE_SUPER_TRAVEL_BELT, categoryBaubles); + superTravelBelt.setLexiconPages(new PageText("0"), + new PageCraftingRecipe("1", ModCraftingRecipes.recipeSuperTravelBelt)); + + reachRing = new ALexiconEntry(LibLexicon.BAUBLE_REACH_RING, categoryBaubles); + reachRing.setLexiconPages(new PageText("0"), new PageCraftingRecipe("1", ModCraftingRecipes.recipeReachRing)); + + itemFinder = new BLexiconEntry(LibLexicon.BAUBLE_ITEM_FINDER, categoryBaubles); + itemFinder.setLexiconPages(new PageText("0"), new PageText("1"), + new PageCraftingRecipe("2", ModCraftingRecipes.recipeItemFinder)); + + superLavaPendant = new ALexiconEntry(LibLexicon.BAUBLE_SUPER_LAVA_PENDANT, categoryBaubles); + superLavaPendant.setLexiconPages(new PageText("0"), + new PageCraftingRecipe("1", ModCraftingRecipes.recipeSuperLavaPendant)); + + bloodPendant = new BLexiconEntry(LibLexicon.BAUBLE_BLOOD_PENDANT, categoryBaubles); + bloodPendant.setLexiconPages(new PageText("0"), new PageText("1"), + new PageCraftingRecipe("2", ModCraftingRecipes.recipeBloodPendant)); + + judgementCloaks = new ALexiconEntry(LibLexicon.BAUBLE_JUDGEMENT_CLOAKS, categoryBaubles); + judgementCloaks.setLexiconPages(new PageText("0"), new PageText("1"), + new PageCraftingRecipe("2", ModCraftingRecipes.recipeHolyCloak), + new PageCraftingRecipe("3", ModCraftingRecipes.recipeUnholyCloak)); + + monocle = new BLexiconEntry(LibLexicon.BAUBLE_MONOCLE, categoryBaubles); + monocle.setPriority().setLexiconPages(new PageText("0"), new PageText("2"), + new PageCraftingRecipe("1", ModCraftingRecipes.recipeMonocle)); + + swapRing = new BLexiconEntry(LibLexicon.BAUBLE_SWAP_RING, categoryBaubles); + swapRing.setLexiconPages(new PageText("0"), new PageCraftingRecipe("1", ModCraftingRecipes.recipeSwapRing)); + + speedUpBelt = new BLexiconEntry(LibLexicon.BAUBLE_SPEED_UP_BELT, categoryBaubles); + speedUpBelt.setLexiconPages(new PageText("0"), + new PageCraftingRecipe("1", ModCraftingRecipes.recipeSpeedUpBelt)); + + baubleBox = new BLexiconEntry(LibLexicon.BAUBLE_BOX, categoryBaubles); + baubleBox.setLexiconPages(new PageText("0"), new PageCraftingRecipe("1", ModCraftingRecipes.recipeBaubleCase)) + .setPriority(); + + // ALFHOMANCY ENTRIES + alfhomancyIntro = new BLexiconEntry(LibLexicon.ALF_INTRO, categoryAlfhomancy); + alfhomancyIntro.setPriority() + .setLexiconPages(new PageText("0"), new PageText("1"), + new PageCraftingRecipe("2", ModCraftingRecipes.recipeAlfPortal), + new PageCraftingRecipe("3", ModCraftingRecipes.recipeNaturaPylon), + new PageMultiblock("4", ModMultiblocks.alfPortal), new PageText("5"), new PageText("6"), + new PageText("7")) + .setIcon(new ItemStack(ModItems.lexicon)); + + elvenMessage = new ALexiconEntry(LibLexicon.ALF_MESSAGE, categoryAlfhomancy); + elvenMessage.setPriority() + .setLexiconPages(new PageImage("0", LibResources.ENTRY_ELVEN_GARDE), new PageLoreText("1"), + new PageLoreText("2"), new PageLoreText("3"), new PageLoreText("4"), new PageLoreText("5"), + new PageLoreText("6")) + .setIcon(new ItemStack(Items.writable_book)); + + elvenResources = new ALexiconEntry(LibLexicon.ALF_RESOURCES, categoryAlfhomancy); + elvenResources.setPriority() + .setLexiconPages(new PageText("0"), new PageElvenRecipe("1", ModElvenTradeRecipes.dreamwoodRecipe), + new PageText("2"), new PageCraftingRecipe("10", ModCraftingRecipes.recipeDreamwoodTwig), + new PageElvenRecipe("3", ModElvenTradeRecipes.elementiumRecipes), + new PageElvenRecipe("4", ModElvenTradeRecipes.pixieDustRecipe), + new PageElvenRecipe("5", ModElvenTradeRecipes.dragonstoneRecipes), new PageText("6"), + new PageElvenRecipe("7", ModElvenTradeRecipes.elvenQuartzRecipe), new PageText("8"), + new PageElvenRecipe("9", ModElvenTradeRecipes.alfglassRecipe)) + .setIcon(new ItemStack(ModItems.manaResource, 1, 9)); + + gaiaRitual = new ALexiconEntry(LibLexicon.ALF_GAIA_RITUAL, categoryAlfhomancy); + gaiaRitual.setLexiconPages(new PageText("0"), new PageCraftingRecipe("1", ModCraftingRecipes.recipeGaiaPylon), + new PageMultiblock("2", ModMultiblocks.gaiaRitual), new PageText("3"), new PageText("4"), + new PageText("5")).setIcon(new ItemStack(ModItems.manaResource, 1, 5)); + LexiconRecipeMappings.map(new ItemStack(ModItems.manaResource, 1, 5), gaiaRitual, 0); + + gaiaRitualHardmode = new ALexiconEntry(LibLexicon.ALF_GAIA_RITUAL_HARDMODE, categoryAlfhomancy); + gaiaRitualHardmode + .setLexiconPages(new PageText("0"), new PageText("1"), + new PageCraftingRecipe("2", ModCraftingRecipes.recipeGaiaIngot)) + .setIcon(new ItemStack(ModItems.manaResource, 1, 14)); + + elvenLore = new ALexiconEntry(LibLexicon.ALF_LORE, categoryAlfhomancy); + elvenLore + .setLexiconPages(new PageText("0"), new PageLoreText("1"), new PageLoreText("2"), new PageLoreText("3"), + new PageLoreText("4"), new PageLoreText("5"), new PageLoreText("6"), new PageLoreText("7")) + .setIcon(new ItemStack(Items.writable_book)); + + if (ConfigHandler.relicsEnabled) { + relics = new ALexiconEntry(LibLexicon.ALF_RELICS, categoryAlfhomancy); + relics.setLexiconPages(new PageText("0")).setIcon(new ItemStack(ModItems.dice)); + + relicInfo = new RLexiconEntry(LibLexicon.ALF_RELIC_INFO, categoryAlfhomancy, null); + relicInfo.setLexiconPages(new PageText("0"), new PageText("1")).setIcon(new ItemStack(ModItems.dice)); + + infiniteFruit = new RLexiconEntry(LibLexicon.ALF_INFINITE_FRUIT, categoryAlfhomancy, + ModAchievements.relicInfiniteFruit); + infiniteFruit.setLexiconPages(new PageText("0")); + + kingKey = new RLexiconEntry(LibLexicon.ALF_KING_KEY, categoryAlfhomancy, ModAchievements.relicKingKey); + kingKey.setLexiconPages(new PageText("0")); + + flugelEye = new RLexiconEntry(LibLexicon.ALF_FLUGEL_EYE, categoryAlfhomancy, + ModAchievements.relicFlugelEye); + flugelEye.setLexiconPages(new PageText("0"), new PageText("1")); + + thorRing = new RLexiconEntry(LibLexicon.ALF_THOR_RING, categoryAlfhomancy, ModAchievements.relicThorRing); + thorRing.setLexiconPages(new PageText("0")); + + lokiRing = new RLexiconEntry(LibLexicon.ALF_LOKI_RING, categoryAlfhomancy, ModAchievements.relicLokiRing); + lokiRing.setLexiconPages(new PageText("0"), new PageText("1"), new PageText("2"), new PageText("3")); + + odinRing = new RLexiconEntry(LibLexicon.ALF_ODIN_RING, categoryAlfhomancy, ModAchievements.relicOdinRing); + odinRing.setLexiconPages(new PageText("0")); + } + + // MISCLENAEOUS ENTRIES + unstableBlocks = new BLexiconEntry(LibLexicon.MISC_UNSTABLE_BLOCKS, categoryMisc); + unstableBlocks.setLexiconPages(new PageText("0"), new PageImage("1", LibResources.ENTRY_UNSTABLE_BLOCK), + new PageCraftingRecipe("2", ModCraftingRecipes.recipesUnstableBlocks), new PageText("3"), + new PageImage("4", LibResources.ENTRY_UNSTABLE_BEACON), + new PageCraftingRecipe("5", ModCraftingRecipes.recipesManaBeacons), new PageText("6"), + new PageCraftingRecipe("7", ModCraftingRecipes.recipesSignalFlares)); + + decorativeBlocks = new BLexiconEntry(LibLexicon.MISC_DECORATIVE_BLOCKS, categoryMisc); + if (ConfigHandler.darkQuartzEnabled) + decorativeBlocks.setLexiconPages(new PageText("0"), + new PageCraftingRecipe("1", ModCraftingRecipes.recipeLivingrockDecor1), + new PageCraftingRecipe("2", ModCraftingRecipes.recipeLivingrockDecor2), + new PageCraftingRecipe("3", ModCraftingRecipes.recipeLivingrockDecor3), + new PageCraftingRecipe("4", ModCraftingRecipes.recipeLivingrockDecor4), + new PageCraftingRecipe("5", ModCraftingRecipes.recipeLivingwoodDecor1), + new PageCraftingRecipe("6", ModCraftingRecipes.recipeLivingwoodDecor2), + new PageCraftingRecipe("7", ModCraftingRecipes.recipeLivingwoodDecor3), + new PageCraftingRecipe("8", ModCraftingRecipes.recipeLivingwoodDecor4), + new PageCraftingRecipe("9", ModCraftingRecipes.recipeLivingwoodDecor5), new PageText("10"), + new PageCraftingRecipe("11", ModCraftingRecipes.recipeDarkQuartz), + new PageManaInfusionRecipe("12", ModManaInfusionRecipes.manaQuartzRecipe), + new PageCraftingRecipe("13", ModCraftingRecipes.recipeBlazeQuartz), + new PageCraftingRecipe("14", ModCraftingRecipes.recipesLavenderQuartz), + new PageCraftingRecipe("15", ModCraftingRecipes.recipeRedQuartz), + new PageCraftingRecipe("23", ModCraftingRecipes.recipeSunnyQuartz), new PageText("16"), + new PageCraftingRecipe("17", ModCraftingRecipes.recipeReedBlock), + new PageCraftingRecipe("18", ModCraftingRecipes.recipeThatch), + new PageCraftingRecipe("19", ModCraftingRecipes.recipeRoofTile), + new PageCraftingRecipe("20", ModCraftingRecipes.recipeNetherBrick), + new PageCraftingRecipe("21", ModCraftingRecipes.recipeSoulBrick), + new PageCraftingRecipe("22", ModCraftingRecipes.recipeSnowBrick)); + else + decorativeBlocks.setLexiconPages(new PageText("0"), + new PageCraftingRecipe("1", ModCraftingRecipes.recipeLivingrockDecor1), + new PageCraftingRecipe("2", ModCraftingRecipes.recipeLivingrockDecor2), + new PageCraftingRecipe("3", ModCraftingRecipes.recipeLivingrockDecor3), + new PageCraftingRecipe("4", ModCraftingRecipes.recipeLivingrockDecor4), + new PageCraftingRecipe("5", ModCraftingRecipes.recipeLivingwoodDecor1), + new PageCraftingRecipe("6", ModCraftingRecipes.recipeLivingwoodDecor2), + new PageCraftingRecipe("7", ModCraftingRecipes.recipeLivingwoodDecor3), + new PageCraftingRecipe("8", ModCraftingRecipes.recipeLivingwoodDecor4), + new PageCraftingRecipe("9", ModCraftingRecipes.recipeLivingwoodDecor5), new PageText("10"), + new PageManaInfusionRecipe("12", ModManaInfusionRecipes.manaQuartzRecipe), + new PageCraftingRecipe("13", ModCraftingRecipes.recipeBlazeQuartz), + new PageCraftingRecipe("14", ModCraftingRecipes.recipesLavenderQuartz), + new PageCraftingRecipe("15", ModCraftingRecipes.recipeRedQuartz), + new PageCraftingRecipe("23", ModCraftingRecipes.recipeSunnyQuartz), new PageText("16"), + new PageCraftingRecipe("17", ModCraftingRecipes.recipeReedBlock), + new PageCraftingRecipe("18", ModCraftingRecipes.recipeThatch), + new PageCraftingRecipe("19", ModCraftingRecipes.recipeRoofTile), + new PageCraftingRecipe("20", ModCraftingRecipes.recipeNetherBrick), + new PageCraftingRecipe("21", ModCraftingRecipes.recipeSoulBrick), + new PageCraftingRecipe("22", ModCraftingRecipes.recipeSnowBrick)); + + dispenserTweaks = new BLexiconEntry(LibLexicon.MISC_DISPENSER_TWEAKS, categoryMisc); + dispenserTweaks.setLexiconPages(new PageText("0")).setPriority().setIcon(new ItemStack(Blocks.dispenser)); + + shinyFlowers = new BLexiconEntry(LibLexicon.MISC_SHINY_FLOWERS, categoryMisc); + shinyFlowers.setLexiconPages(new PageText("0"), new PageText("3"), + new PageCraftingRecipe("1", ModCraftingRecipes.recipesShinyFlowers), + new PageCraftingRecipe("2", ModCraftingRecipes.recipesMiniIsland)); + + prismarine = new BLexiconEntry(LibLexicon.MISC_PRISMARINE, categoryMisc); + prismarine.setLexiconPages(new PageText("0"), new PageText("1"), + new PageManaInfusionRecipe("2", ModManaAlchemyRecipes.prismarineRecipe), + new PageCraftingRecipe("3", ModCraftingRecipes.recipePrismarine), + new PageCraftingRecipe("4", ModCraftingRecipes.recipePrismarineBrick), + new PageCraftingRecipe("5", ModCraftingRecipes.recipeDarkPrismarine), + new PageCraftingRecipe("6", ModCraftingRecipes.recipeSeaLamp)); + + tinyPotato = new BLexiconEntry(LibLexicon.MISC_TINY_POTATO, categoryMisc); + tinyPotato.setLexiconPages(new PageText("0"), + new PageManaInfusionRecipe("1", ModManaInfusionRecipes.tinyPotatoRecipe)); + + headCreating = new HLexiconEntry(LibLexicon.MISC_HEAD_CREATING, categoryMisc); + headCreating.setLexiconPages(new PageText("0"), new PageText("2"), + new PageRuneRecipe("1", ModRuneRecipes.recipeHead)); + + azulejo = new BLexiconEntry(LibLexicon.MISC_AZULEJO, categoryMisc); + azulejo.setLexiconPages(new PageText("0"), new PageImage("1", LibResources.ENTRY_AZULEJOS), + new PageCraftingRecipe("2", ModCraftingRecipes.recipeAzulejo), + new PageCraftingRecipe("3", ModCraftingRecipes.recipesAzulejoCycling)); + + starfield = new ALexiconEntry(LibLexicon.MISC_STARFIELD, categoryMisc); + starfield.setLexiconPages(new PageText("0"), new PageCraftingRecipe("1", ModCraftingRecipes.recipeStarfield)); + + dirtPath = new BLexiconEntry(LibLexicon.MISC_DIRT_PATH, categoryMisc); + dirtPath.setLexiconPages(new PageText("0"), new PageCraftingRecipe("1", ModCraftingRecipes.recipeDirtPath), + new PageCraftingRecipe("2", ModCraftingRecipes.recipeDirtPathSlab)); + + mushrooms = new BLexiconEntry(LibLexicon.MISC_MUSHROOMS, categoryMisc); + mushrooms.setLexiconPages(new PageText("0"), new PageCraftingRecipe("1", ModCraftingRecipes.recipesMushrooms)); + + phantomInk = new BLexiconEntry(LibLexicon.MISC_PHANTOM_INK, categoryMisc); + phantomInk.setLexiconPages(new PageText("0"), new PageCraftingRecipe("1", ModCraftingRecipes.recipePhantomInk)); + + if (ConfigHandler.stones18Enabled) { + stoneAlchemy = new BLexiconEntry(LibLexicon.MISC_STONE_ALCHEMY, categoryMisc); + stoneAlchemy.setLexiconPages(new PageText("0"), + new PageManaInfusionRecipe("1", ModManaAlchemyRecipes.stoneRecipes), + new PageCraftingRecipe("2", ModCraftingRecipes.recipe18StonePolish), + new PageCraftingRecipe("3", ModCraftingRecipes.recipe18StoneBrick), + new PageCraftingRecipe("4", ModCraftingRecipes.recipe18StoneChisel)); + } + + blazeBlock = new BLexiconEntry(LibLexicon.MISC_BLAZE_BLOCK, categoryMisc); + blazeBlock.setLexiconPages(new PageText("0"), new PageCraftingRecipe("1", ModCraftingRecipes.recipeBlazeBlock)); + LexiconRecipeMappings.map(new ItemStack(Blocks.obsidian), blazeBlock, 0); + + challenges = new BLexiconEntry(LibLexicon.MISC_CHALLENGES, categoryMisc); + challenges.setLexiconPages(new PageText("0"), new PageText("1"), new PageText("2")).setPriority() + .setIcon(new ItemStack(ModItems.cosmetic, 1, 31)); + + cacophonium = new BLexiconEntry(LibLexicon.MISC_CACOPHONIUM, categoryMisc); + cacophonium.setLexiconPages(new PageText("0"), + new PageCraftingRecipe("1", ModCraftingRecipes.recipeCacophonium), new PageText("2")); + + pavement = new BLexiconEntry(LibLexicon.MISC_PAVEMENT, categoryMisc); + pavement.setLexiconPages(new PageText("0"), new PageCraftingRecipe("1", ModCraftingRecipes.recipesPavement)); + + preventingDecay = new DLexiconEntry(LibLexicon.MISC_PRENTING_DECAY, categoryMisc); + preventingDecay.setLexiconPages(new PageText("0")).setIcon(new ItemStack(Blocks.deadbush)); + + if (Botania.bcTriggersLoaded) { + bcIntegration = new CLexiconEntry(LibLexicon.MISC_BC_INTEGRATION, categoryMisc, "BuildCraft"); + bcIntegration.setLexiconPages(new PageText("0")).setIcon(new ItemStack(Items.redstone)); + } + } + + public static void postInit() { + if (SheddingHandler.hasShedding()) { + shedding = new BLexiconEntry(LibLexicon.MISC_SHEDDING, BotaniaAPI.categoryMisc); + shedding.setLexiconPages(new PageText("0")).setPriority().setIcon(new ItemStack(Items.feather)); + SheddingHandler.addToLexicon(); + } + + if (Botania.thaumcraftLoaded) { + tcIntegration = new CLexiconEntry(LibLexicon.MISC_TC_INTEGRATION, BotaniaAPI.categoryMisc, "Thaumcraft"); + + if (ConfigHandler.enableThaumcraftStablizers) + tcIntegration.setLexiconPages(new PageText("0"), new PageText("1"), + new PageCraftingRecipe("2", ModCraftingRecipes.recipeHelmetOfRevealing), new PageText("3"), + new PageManaInfusionRecipe("4", ModManaInfusionRecipes.manaInkwellRecipe), new PageText("5"), + new PageBrew(ModBrewRecipes.warpWardBrew, "6a", "6b")) + .setIcon(new ItemStack(ModItems.manaInkwell)); + else + tcIntegration.setLexiconPages(new PageText("0"), new PageText("1"), + new PageCraftingRecipe("2", ModCraftingRecipes.recipeHelmetOfRevealing), new PageText("3"), + new PageManaInfusionRecipe("4", ModManaInfusionRecipes.manaInkwellRecipe), + new PageBrew(ModBrewRecipes.warpWardBrew, "6a", "6b")) + .setIcon(new ItemStack(ModItems.manaInkwell)); + } + + if (Botania.etFuturumLoaded) { + banners = new CLexiconEntry(LibLexicon.MISC_BANNERS, BotaniaAPI.categoryMisc, "EtFuturum"); + banners.setLexiconPages(new PageText("0"), new PageImage("1", LibResources.ENTRY_BANNERS)) + .setIcon(new ItemStack(ModItems.lexicon)); + } + } } diff --git a/src/main/java/vazkii/botania/common/lexicon/RLexiconEntry.java b/src/main/java/vazkii/botania/common/lexicon/RLexiconEntry.java index f0176f7239..1980bbff5b 100644 --- a/src/main/java/vazkii/botania/common/lexicon/RLexiconEntry.java +++ b/src/main/java/vazkii/botania/common/lexicon/RLexiconEntry.java @@ -2,39 +2,39 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Aug 16, 2015, 10:52:36 PM (GMT)] */ package vazkii.botania.common.lexicon; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; import net.minecraft.client.Minecraft; import net.minecraft.client.entity.EntityClientPlayerMP; import net.minecraft.stats.Achievement; import vazkii.botania.api.BotaniaAPI; import vazkii.botania.api.lexicon.LexiconCategory; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +public class RLexiconEntry extends BLexiconEntry { -public class RLexiconEntry extends BLexiconEntry { + Achievement a; - Achievement a; + public RLexiconEntry(String unlocalizedName, LexiconCategory category, Achievement a) { + super(unlocalizedName, category); + setKnowledgeType(BotaniaAPI.relicKnowledge); + this.a = a; + if(a != null) + setIcon(a.theItemStack.copy()); + } - public RLexiconEntry(String unlocalizedName, LexiconCategory category, Achievement a) { - super(unlocalizedName, category); - setKnowledgeType(BotaniaAPI.relicKnowledge); - this.a = a; - if (a != null) setIcon(a.theItemStack.copy()); - } + @Override + @SideOnly(Side.CLIENT) + public boolean isVisible() { + EntityClientPlayerMP player = Minecraft.getMinecraft().thePlayer; + return a == null || player.capabilities.isCreativeMode || player.getStatFileWriter().hasAchievementUnlocked(a); + } - @Override - @SideOnly(Side.CLIENT) - public boolean isVisible() { - EntityClientPlayerMP player = Minecraft.getMinecraft().thePlayer; - return a == null - || player.capabilities.isCreativeMode - || player.getStatFileWriter().hasAchievementUnlocked(a); - } } diff --git a/src/main/java/vazkii/botania/common/lexicon/TLexiconEntry.java b/src/main/java/vazkii/botania/common/lexicon/TLexiconEntry.java index acc0195fc7..d03e649f58 100644 --- a/src/main/java/vazkii/botania/common/lexicon/TLexiconEntry.java +++ b/src/main/java/vazkii/botania/common/lexicon/TLexiconEntry.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Feb 16, 2015, 1:41:58 PM (GMT)] */ package vazkii.botania.common.lexicon; @@ -18,10 +18,12 @@ public class TLexiconEntry extends BLexiconEntry { - public TLexiconEntry() { - super(LibLexicon.BASICS_TUTORIAL, BotaniaAPI.categoryBasics); - setPriority(); - setIcon(new ItemStack(Items.book)); - setLexiconPages(new PageTutorial("0")); - } + public TLexiconEntry() { + super(LibLexicon.BASICS_TUTORIAL, BotaniaAPI.categoryBasics); + setPriority(); + setIcon(new ItemStack(Items.book)); + setLexiconPages(new PageTutorial("0")); + } + + } diff --git a/src/main/java/vazkii/botania/common/lexicon/WIPLexiconEntry.java b/src/main/java/vazkii/botania/common/lexicon/WIPLexiconEntry.java index 8bb2c82ec1..da8b7031f8 100644 --- a/src/main/java/vazkii/botania/common/lexicon/WIPLexiconEntry.java +++ b/src/main/java/vazkii/botania/common/lexicon/WIPLexiconEntry.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jun 8, 2014, 7:06:06 PM (GMT)] */ package vazkii.botania.common.lexicon; @@ -15,12 +15,13 @@ public class WIPLexiconEntry extends BLexiconEntry implements IAddonEntry { - public WIPLexiconEntry(String unlocalizedName, LexiconCategory category) { - super(unlocalizedName, category); - } + public WIPLexiconEntry(String unlocalizedName, LexiconCategory category) { + super(unlocalizedName, category); + } + + @Override + public String getSubtitle() { + return "botania.gui.lexicon.wip"; + } - @Override - public String getSubtitle() { - return "botania.gui.lexicon.wip"; - } } diff --git a/src/main/java/vazkii/botania/common/lexicon/WLexiconEntry.java b/src/main/java/vazkii/botania/common/lexicon/WLexiconEntry.java index ab938ee4e8..26d745ec61 100644 --- a/src/main/java/vazkii/botania/common/lexicon/WLexiconEntry.java +++ b/src/main/java/vazkii/botania/common/lexicon/WLexiconEntry.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [May 30, 2015, 10:54:30 PM (GMT)] */ package vazkii.botania.common.lexicon; @@ -20,20 +20,22 @@ public class WLexiconEntry extends BLexiconEntry { - private static final int PAGES = 7; + private static final int PAGES = 7; - public WLexiconEntry() { - super(LibLexicon.BASICS_WELCOME, BotaniaAPI.categoryBasics); - setPriority(); - setIcon(new ItemStack(ModItems.cosmetic, 1, 31)); + public WLexiconEntry() { + super(LibLexicon.BASICS_WELCOME, BotaniaAPI.categoryBasics); + setPriority(); + setIcon(new ItemStack(ModItems.cosmetic, 1, 31)); - LexiconPage[] pages = new LexiconPage[PAGES]; - for (int i = 0; i < PAGES; i++) pages[i] = new PageText("" + i); - setLexiconPages(pages); - } + LexiconPage[] pages = new LexiconPage[PAGES]; + for(int i = 0; i < PAGES; i++) + pages[i] = new PageText("" + i); + setLexiconPages(pages); + } + + @Override + public int compareTo(LexiconEntry o) { + return -1; + } - @Override - public int compareTo(LexiconEntry o) { - return -1; - } } diff --git a/src/main/java/vazkii/botania/common/lexicon/page/PageBrew.java b/src/main/java/vazkii/botania/common/lexicon/page/PageBrew.java index 5b330f2730..f064ad0deb 100644 --- a/src/main/java/vazkii/botania/common/lexicon/page/PageBrew.java +++ b/src/main/java/vazkii/botania/common/lexicon/page/PageBrew.java @@ -2,18 +2,17 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Nov 2, 2014, 5:17:46 PM (GMT)] */ package vazkii.botania.common.lexicon.page; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; import java.util.ArrayList; import java.util.List; + import net.minecraft.client.Minecraft; import net.minecraft.client.gui.FontRenderer; import net.minecraft.item.ItemStack; @@ -27,92 +26,93 @@ import vazkii.botania.api.lexicon.ITwoNamedPage; import vazkii.botania.api.recipe.RecipeBrew; import vazkii.botania.common.item.ModItems; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; public class PageBrew extends PageRecipe implements ITwoNamedPage { - RecipeBrew recipe; - String text; - - public PageBrew(RecipeBrew recipe, String unlocalizedName, String bottomText) { - super(bottomText); - this.recipe = recipe; - text = unlocalizedName; - } - - @Override - public void renderRecipe(IGuiLexiconEntry gui, int mx, int my) { - int width = gui.getWidth() - 30; - int height = gui.getHeight(); - int x = gui.getLeft() + 16; - int y = gui.getTop() + 12; - - Brew brew = recipe.getBrew(); - FontRenderer renderer = Minecraft.getMinecraft().fontRenderer; - boolean unicode = renderer.getUnicodeFlag(); - renderer.setUnicodeFlag(true); - String s = EnumChatFormatting.BOLD - + String.format( - StatCollector.translateToLocal("botaniamisc.brewOf"), - StatCollector.translateToLocal(brew.getUnlocalizedName())); - renderer.drawString(s, gui.getLeft() + gui.getWidth() / 2 - renderer.getStringWidth(s) / 2, y, 0x222222); - renderer.setUnicodeFlag(unicode); - PageText.renderText(x, y + 22, width, height, text); - - ItemStack book = Minecraft.getMinecraft().thePlayer.getCurrentEquippedItem(); - if (book != null - && book.getItem() instanceof ILexicon - && ((ILexicon) book.getItem()).isKnowledgeUnlocked(book, BotaniaAPI.elvenKnowledge)) { - renderItemAtLinePos(gui, 20, 2, y + 12, recipe.getOutput(new ItemStack(ModItems.vial))); - renderItemAtLinePos(gui, 20, 3, y + 12, recipe.getOutput(new ItemStack(ModItems.vial, 1, 1))); - } else renderItemAtLinePos(gui, 0, -1, y + 12, recipe.getOutput(new ItemStack(ModItems.vial))); - - int i = 0; - y = gui.getTop() + gui.getHeight() - 54; - List inputs = new ArrayList(recipe.getInputs()); - - int offset = gui.getWidth() / 2 - inputs.size() * 9; - for (Object input : inputs) { - if (input instanceof String) - input = OreDictionary.getOres((String) input).get(0); - - renderItemAtLinePos(gui, offset, i, y, (ItemStack) input); - i++; - } - - super.renderRecipe(gui, mx, my); - } - - @SideOnly(Side.CLIENT) - public void renderItemAtLinePos(IGuiLexiconEntry gui, int offset, int pos, int yPos, ItemStack stack) { - if (stack == null || stack.getItem() == null) return; - stack = stack.copy(); - - if (stack.getItemDamage() == Short.MAX_VALUE) stack.setItemDamage(0); - - int xPos = gui.getLeft() + (pos == -1 ? gui.getWidth() / 2 - 8 : pos * 18) + offset; - - ItemStack stack1 = stack.copy(); - if (stack1.getItemDamage() == -1) stack1.setItemDamage(0); - - renderItem(gui, xPos, yPos, stack1, false); - } - - @Override - public List getDisplayedRecipes() { - ArrayList list = new ArrayList(); - if (recipe != null) { - list.add(recipe.getOutput(new ItemStack(ModItems.vial))); - } - return list; - } - - @Override - public void setSecondUnlocalizedName(String name) { - text = name; - } - - @Override - public String getSecondUnlocalizedName() { - return text; - } + RecipeBrew recipe; + String text; + + public PageBrew(RecipeBrew recipe, String unlocalizedName, String bottomText) { + super(bottomText); + this.recipe = recipe; + text = unlocalizedName; + } + + @Override + public void renderRecipe(IGuiLexiconEntry gui, int mx, int my) { + int width = gui.getWidth() - 30; + int height = gui.getHeight(); + int x = gui.getLeft() + 16; + int y = gui.getTop() + 12; + + Brew brew = recipe.getBrew(); + FontRenderer renderer = Minecraft.getMinecraft().fontRenderer; + boolean unicode = renderer.getUnicodeFlag(); + renderer.setUnicodeFlag(true); + String s = EnumChatFormatting.BOLD + String.format(StatCollector.translateToLocal("botaniamisc.brewOf"), StatCollector.translateToLocal(brew.getUnlocalizedName())); + renderer.drawString(s, gui.getLeft() + gui.getWidth() / 2 - renderer.getStringWidth(s) / 2, y, 0x222222); + renderer.setUnicodeFlag(unicode); + PageText.renderText(x, y + 22, width, height, text); + + ItemStack book = Minecraft.getMinecraft().thePlayer.getCurrentEquippedItem(); + if(book != null && book.getItem() instanceof ILexicon && ((ILexicon) book.getItem()).isKnowledgeUnlocked(book, BotaniaAPI.elvenKnowledge)) { + renderItemAtLinePos(gui, 20, 2, y + 12, recipe.getOutput(new ItemStack(ModItems.vial))); + renderItemAtLinePos(gui, 20, 3, y + 12, recipe.getOutput(new ItemStack(ModItems.vial, 1, 1))); + } else renderItemAtLinePos(gui, 0, -1, y + 12, recipe.getOutput(new ItemStack(ModItems.vial))); + + int i = 0; + y = gui.getTop() + gui.getHeight() - 54; + List inputs = new ArrayList(recipe.getInputs()); + + int offset = gui.getWidth() / 2 - inputs.size() * 9; + for(Object input : inputs) { + if(input instanceof String) + input = OreDictionary.getOres((String) input).get(0); + + renderItemAtLinePos(gui, offset, i, y, (ItemStack) input); + i++; + } + + super.renderRecipe(gui, mx, my); + } + + @SideOnly(Side.CLIENT) + public void renderItemAtLinePos(IGuiLexiconEntry gui, int offset, int pos, int yPos, ItemStack stack) { + if(stack == null || stack.getItem() == null) + return; + stack = stack.copy(); + + if(stack.getItemDamage() == Short.MAX_VALUE) + stack.setItemDamage(0); + + int xPos = gui.getLeft() + (pos == -1 ? gui.getWidth() / 2 - 8 : pos * 18) + offset; + + ItemStack stack1 = stack.copy(); + if(stack1.getItemDamage() == -1) + stack1.setItemDamage(0); + + renderItem(gui, xPos, yPos, stack1, false); + } + + @Override + public List getDisplayedRecipes() { + ArrayList list = new ArrayList(); + if (recipe != null) { + list.add(recipe.getOutput(new ItemStack(ModItems.vial))); + } + return list; + } + + @Override + public void setSecondUnlocalizedName(String name) { + text = name; + } + + @Override + public String getSecondUnlocalizedName() { + return text; + } + } diff --git a/src/main/java/vazkii/botania/common/lexicon/page/PageCraftingRecipe.java b/src/main/java/vazkii/botania/common/lexicon/page/PageCraftingRecipe.java index f7ba24a95c..5957e097f6 100644 --- a/src/main/java/vazkii/botania/common/lexicon/page/PageCraftingRecipe.java +++ b/src/main/java/vazkii/botania/common/lexicon/page/PageCraftingRecipe.java @@ -2,20 +2,18 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jan 19, 2014, 4:58:19 PM (GMT)] */ package vazkii.botania.common.lexicon.page; -import cpw.mods.fml.relauncher.ReflectionHelper; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; import java.util.ArrayList; import java.util.Arrays; import java.util.List; + import net.minecraft.client.Minecraft; import net.minecraft.client.gui.GuiScreen; import net.minecraft.client.renderer.texture.TextureManager; @@ -27,176 +25,171 @@ import net.minecraft.util.StatCollector; import net.minecraftforge.oredict.ShapedOreRecipe; import net.minecraftforge.oredict.ShapelessOreRecipe; + import org.lwjgl.opengl.GL11; + import vazkii.botania.api.internal.IGuiLexiconEntry; import vazkii.botania.api.lexicon.LexiconEntry; import vazkii.botania.api.lexicon.LexiconRecipeMappings; import vazkii.botania.client.core.helper.RenderHelper; import vazkii.botania.client.lib.LibResources; +import cpw.mods.fml.relauncher.ReflectionHelper; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; public class PageCraftingRecipe extends PageRecipe { - private static final ResourceLocation craftingOverlay = new ResourceLocation(LibResources.GUI_CRAFTING_OVERLAY); + private static final ResourceLocation craftingOverlay = new ResourceLocation(LibResources.GUI_CRAFTING_OVERLAY); + + List recipes; + int ticksElapsed = 0; + int recipeAt = 0; + + boolean oreDictRecipe, shapelessRecipe; + + public PageCraftingRecipe(String unlocalizedName, List recipes) { + super(unlocalizedName); + this.recipes = filterRecipes(recipes); + } + + public PageCraftingRecipe(String unlocalizedName, IRecipe recipe) { + this(unlocalizedName, Arrays.asList(recipe)); + } + + @Override + public void onPageAdded(LexiconEntry entry, int index) { + for(IRecipe recipe : recipes) + if (recipe != null) + LexiconRecipeMappings.map(recipe.getRecipeOutput(), entry, index); + } + + @Override + @SideOnly(Side.CLIENT) + public void renderRecipe(IGuiLexiconEntry gui, int mx, int my) { + oreDictRecipe = shapelessRecipe = false; + + if (recipes.size() == 0) return; + IRecipe recipe = recipes.get(recipeAt); + + renderCraftingRecipe(gui, recipe); + + TextureManager render = Minecraft.getMinecraft().renderEngine; + render.bindTexture(craftingOverlay); + + GL11.glEnable(GL11.GL_BLEND); + GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); + GL11.glColor4f(1F, 1F, 1F, 1F); + ((GuiScreen) gui).drawTexturedModalRect(gui.getLeft(), gui.getTop(), 0, 0, gui.getWidth(), gui.getHeight()); + + int iconX = gui.getLeft() + 115; + int iconY = gui.getTop() + 12; - List recipes; - int ticksElapsed = 0; - int recipeAt = 0; - - boolean oreDictRecipe, shapelessRecipe; - - public PageCraftingRecipe(String unlocalizedName, List recipes) { - super(unlocalizedName); - this.recipes = filterRecipes(recipes); - } - - public PageCraftingRecipe(String unlocalizedName, IRecipe recipe) { - this(unlocalizedName, Arrays.asList(recipe)); - } - - @Override - public void onPageAdded(LexiconEntry entry, int index) { - for (IRecipe recipe : recipes) - if (recipe != null) LexiconRecipeMappings.map(recipe.getRecipeOutput(), entry, index); - } - - @Override - @SideOnly(Side.CLIENT) - public void renderRecipe(IGuiLexiconEntry gui, int mx, int my) { - oreDictRecipe = shapelessRecipe = false; - - if (recipes.size() == 0) return; - IRecipe recipe = recipes.get(recipeAt); - - renderCraftingRecipe(gui, recipe); - - TextureManager render = Minecraft.getMinecraft().renderEngine; - render.bindTexture(craftingOverlay); - - GL11.glEnable(GL11.GL_BLEND); - GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); - GL11.glColor4f(1F, 1F, 1F, 1F); - ((GuiScreen) gui).drawTexturedModalRect(gui.getLeft(), gui.getTop(), 0, 0, gui.getWidth(), gui.getHeight()); - - int iconX = gui.getLeft() + 115; - int iconY = gui.getTop() + 12; - - GL11.glEnable(GL11.GL_BLEND); - GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); - - if (shapelessRecipe) { - ((GuiScreen) gui).drawTexturedModalRect(iconX, iconY, 240, 0, 16, 16); - - if (mx >= iconX && my >= iconY && mx < iconX + 16 && my < iconY + 16) - RenderHelper.renderTooltip( - mx, my, Arrays.asList(StatCollector.translateToLocal("botaniamisc.shapeless"))); - - iconY += 20; - } - - render.bindTexture(craftingOverlay); - GL11.glEnable(GL11.GL_BLEND); - - if (oreDictRecipe) { - ((GuiScreen) gui).drawTexturedModalRect(iconX, iconY, 240, 16, 16, 16); - - if (mx >= iconX && my >= iconY && mx < iconX + 16 && my < iconY + 16) - RenderHelper.renderTooltip( - mx, my, Arrays.asList(StatCollector.translateToLocal("botaniamisc.oredict"))); - } - GL11.glDisable(GL11.GL_BLEND); - } - - @Override - @SideOnly(Side.CLIENT) - public void updateScreen() { - if (GuiScreen.isShiftKeyDown()) return; - - if (ticksElapsed % 20 == 0) { - recipeAt++; - - if (recipeAt == recipes.size()) recipeAt = 0; - } - ++ticksElapsed; - } - - @SideOnly(Side.CLIENT) - public void renderCraftingRecipe(IGuiLexiconEntry gui, IRecipe recipe) { - if (recipe instanceof ShapedRecipes) { - ShapedRecipes shaped = (ShapedRecipes) recipe; - - for (int y = 0; y < shaped.recipeHeight; y++) - for (int x = 0; x < shaped.recipeWidth; x++) - renderItemAtGridPos(gui, 1 + x, 1 + y, shaped.recipeItems[y * shaped.recipeWidth + x], true); - } else if (recipe instanceof ShapedOreRecipe) { - ShapedOreRecipe shaped = (ShapedOreRecipe) recipe; - int width = (Integer) ReflectionHelper.getPrivateValue(ShapedOreRecipe.class, shaped, 4); - int height = (Integer) ReflectionHelper.getPrivateValue(ShapedOreRecipe.class, shaped, 5); - - for (int y = 0; y < height; y++) - for (int x = 0; x < width; x++) { - Object input = shaped.getInput()[y * width + x]; - if (input != null) - renderItemAtGridPos( - gui, - 1 + x, - 1 + y, - input instanceof ItemStack ? (ItemStack) input : ((ArrayList) input).get(0), - true); - } - - oreDictRecipe = true; - } else if (recipe instanceof ShapelessRecipes) { - ShapelessRecipes shapeless = (ShapelessRecipes) recipe; - - drawGrid: - { - for (int y = 0; y < 3; y++) - for (int x = 0; x < 3; x++) { - int index = y * 3 + x; - - if (index >= shapeless.recipeItems.size()) break drawGrid; - - renderItemAtGridPos(gui, 1 + x, 1 + y, (ItemStack) shapeless.recipeItems.get(index), true); - } - } - - shapelessRecipe = true; - } else if (recipe instanceof ShapelessOreRecipe) { - ShapelessOreRecipe shapeless = (ShapelessOreRecipe) recipe; - - drawGrid: - { - for (int y = 0; y < 3; y++) - for (int x = 0; x < 3; x++) { - int index = y * 3 + x; - - if (index >= shapeless.getRecipeSize()) break drawGrid; - - Object input = shapeless.getInput().get(index); - if (input != null) - renderItemAtGridPos( - gui, - 1 + x, - 1 + y, - input instanceof ItemStack - ? (ItemStack) input - : ((ArrayList) input).get(0), - true); - } - } - - shapelessRecipe = true; - oreDictRecipe = true; - } - - renderItemAtGridPos(gui, 2, 0, recipe.getRecipeOutput(), false); - } - - @Override - public List getDisplayedRecipes() { - ArrayList list = new ArrayList(); - for (IRecipe r : recipes) list.add(r.getRecipeOutput()); - - return list; - } + GL11.glEnable(GL11.GL_BLEND); + GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); + + if(shapelessRecipe) { + ((GuiScreen) gui).drawTexturedModalRect(iconX, iconY, 240, 0, 16, 16); + + if(mx >= iconX && my >= iconY && mx < iconX + 16 && my < iconY + 16) + RenderHelper.renderTooltip(mx, my, Arrays.asList(StatCollector.translateToLocal("botaniamisc.shapeless"))); + + iconY += 20; + } + + render.bindTexture(craftingOverlay); + GL11.glEnable(GL11.GL_BLEND); + + if(oreDictRecipe) { + ((GuiScreen) gui).drawTexturedModalRect(iconX, iconY, 240, 16, 16, 16); + + if(mx >= iconX && my >= iconY && mx < iconX + 16 && my < iconY + 16) + RenderHelper.renderTooltip(mx, my, Arrays.asList(StatCollector.translateToLocal("botaniamisc.oredict"))); + } + GL11.glDisable(GL11.GL_BLEND); + } + + @Override + @SideOnly(Side.CLIENT) + public void updateScreen() { + if(GuiScreen.isShiftKeyDown()) + return; + + if(ticksElapsed % 20 == 0) { + recipeAt++; + + if(recipeAt == recipes.size()) + recipeAt = 0; + } + ++ticksElapsed; + } + + @SideOnly(Side.CLIENT) + public void renderCraftingRecipe(IGuiLexiconEntry gui, IRecipe recipe) { + if(recipe instanceof ShapedRecipes) { + ShapedRecipes shaped = (ShapedRecipes)recipe; + + for(int y = 0; y < shaped.recipeHeight; y++) + for(int x = 0; x < shaped.recipeWidth; x++) + renderItemAtGridPos(gui, 1 + x, 1 + y, shaped.recipeItems[y * shaped.recipeWidth + x], true); + } else if(recipe instanceof ShapedOreRecipe) { + ShapedOreRecipe shaped = (ShapedOreRecipe) recipe; + int width = (Integer) ReflectionHelper.getPrivateValue(ShapedOreRecipe.class, shaped, 4); + int height = (Integer) ReflectionHelper.getPrivateValue(ShapedOreRecipe.class, shaped, 5); + + for(int y = 0; y < height; y++) + for(int x = 0; x < width; x++) { + Object input = shaped.getInput()[y * width + x]; + if(input != null) + renderItemAtGridPos(gui, 1 + x, 1 + y, input instanceof ItemStack ? (ItemStack) input : ((ArrayList) input).get(0), true); + } + + oreDictRecipe = true; + } else if(recipe instanceof ShapelessRecipes) { + ShapelessRecipes shapeless = (ShapelessRecipes) recipe; + + drawGrid : { + for(int y = 0; y < 3; y++) + for(int x = 0; x < 3; x++) { + int index = y * 3 + x; + + if(index >= shapeless.recipeItems.size()) + break drawGrid; + + renderItemAtGridPos(gui, 1 + x, 1 + y, (ItemStack) shapeless.recipeItems.get(index), true); + } + } + + shapelessRecipe = true; + } else if(recipe instanceof ShapelessOreRecipe) { + ShapelessOreRecipe shapeless = (ShapelessOreRecipe) recipe; + + drawGrid : { + for(int y = 0; y < 3; y++) + for(int x = 0; x < 3; x++) { + int index = y * 3 + x; + + if(index >= shapeless.getRecipeSize()) + break drawGrid; + + Object input = shapeless.getInput().get(index); + if(input != null) + renderItemAtGridPos(gui, 1 + x, 1 + y, input instanceof ItemStack ? (ItemStack) input : ((ArrayList) input).get(0), true); + } + } + + shapelessRecipe = true; + oreDictRecipe = true; + } + + renderItemAtGridPos(gui, 2, 0, recipe.getRecipeOutput(), false); + } + + @Override + public List getDisplayedRecipes() { + ArrayList list = new ArrayList(); + for(IRecipe r : recipes) + list.add(r.getRecipeOutput()); + + return list; + } } diff --git a/src/main/java/vazkii/botania/common/lexicon/page/PageElvenRecipe.java b/src/main/java/vazkii/botania/common/lexicon/page/PageElvenRecipe.java index bdd8ff6435..86a5252644 100644 --- a/src/main/java/vazkii/botania/common/lexicon/page/PageElvenRecipe.java +++ b/src/main/java/vazkii/botania/common/lexicon/page/PageElvenRecipe.java @@ -1,10 +1,9 @@ package vazkii.botania.common.lexicon.page; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; import java.util.ArrayList; import java.util.Arrays; import java.util.List; + import net.minecraft.client.Minecraft; import net.minecraft.client.gui.GuiScreen; import net.minecraft.client.renderer.entity.RenderItem; @@ -14,103 +13,115 @@ import net.minecraft.util.IIcon; import net.minecraft.util.ResourceLocation; import net.minecraftforge.oredict.OreDictionary; + import org.lwjgl.opengl.GL11; + import vazkii.botania.api.internal.IGuiLexiconEntry; import vazkii.botania.api.lexicon.LexiconEntry; import vazkii.botania.api.lexicon.LexiconRecipeMappings; import vazkii.botania.api.recipe.RecipeElvenTrade; import vazkii.botania.client.lib.LibResources; import vazkii.botania.common.block.BlockAlfPortal; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; public class PageElvenRecipe extends PageRecipe { - private static final ResourceLocation elvenTradeOverlay = - new ResourceLocation(LibResources.GUI_ELVEN_TRADE_OVERLAY); - - List recipes; - int ticksElapsed = 0; - int recipeAt = 0; - - public PageElvenRecipe(String unlocalizedName, List recipes) { - super(unlocalizedName); - this.recipes = filterRecipes(recipes); - } - - public PageElvenRecipe(String unlocalizedName, RecipeElvenTrade recipe) { - this(unlocalizedName, Arrays.asList(recipe)); - } - - @Override - public void onPageAdded(LexiconEntry entry, int index) { - for (RecipeElvenTrade recipe : recipes) - if (recipe != null) LexiconRecipeMappings.map(recipe.getOutput(), entry, index); - } - - @Override - @SideOnly(Side.CLIENT) - public void renderRecipe(IGuiLexiconEntry gui, int mx, int my) { - if (recipes.size() == 0) return; - RecipeElvenTrade recipe = recipes.get(recipeAt); - - TextureManager render = Minecraft.getMinecraft().renderEngine; - render.bindTexture(elvenTradeOverlay); - GL11.glEnable(GL11.GL_BLEND); - GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); - GL11.glColor4f(1F, 1F, 1F, 1F); - ((GuiScreen) gui).drawTexturedModalRect(gui.getLeft(), gui.getTop(), 0, 0, gui.getWidth(), gui.getHeight()); - GL11.glDisable(GL11.GL_BLEND); - - renderItemAtGridPos(gui, 3, 1, recipe.getOutput(), false); - - List inputs = recipe.getInputs(); - int i = 0; - for (Object obj : inputs) { - Object input = obj; - if (input instanceof String) - input = OreDictionary.getOres((String) input).get(0); - - renderItemAtInputPos(gui, i, (ItemStack) input); - i++; - } - - IIcon portalIcon = BlockAlfPortal.portalTex; - Minecraft.getMinecraft().renderEngine.bindTexture(TextureMap.locationBlocksTexture); - RenderItem.getInstance().renderIcon(gui.getLeft() + 22, gui.getTop() + 36, portalIcon, 48, 48); - } - - @SideOnly(Side.CLIENT) - public void renderItemAtInputPos(IGuiLexiconEntry gui, int x, ItemStack stack) { - if (stack == null || stack.getItem() == null) return; - stack = stack.copy(); - - if (stack.getItemDamage() == Short.MAX_VALUE) stack.setItemDamage(0); - - int xPos = gui.getLeft() + x * 20 + 45; - int yPos = gui.getTop() + 14; - ItemStack stack1 = stack.copy(); - if (stack1.getItemDamage() == -1) stack1.setItemDamage(0); - - renderItem(gui, xPos, yPos, stack1, false); - } - - @Override - @SideOnly(Side.CLIENT) - public void updateScreen() { - if (GuiScreen.isShiftKeyDown()) return; - - if (ticksElapsed % 20 == 0) { - recipeAt++; - - if (recipeAt == recipes.size()) recipeAt = 0; - } - ++ticksElapsed; - } - - @Override - public List getDisplayedRecipes() { - ArrayList list = new ArrayList(); - for (RecipeElvenTrade r : recipes) list.add(r.getOutput()); - - return list; - } + private static final ResourceLocation elvenTradeOverlay = new ResourceLocation(LibResources.GUI_ELVEN_TRADE_OVERLAY); + + List recipes; + int ticksElapsed = 0; + int recipeAt = 0; + + public PageElvenRecipe(String unlocalizedName, List recipes) { + super(unlocalizedName); + this.recipes = filterRecipes(recipes); + } + + public PageElvenRecipe(String unlocalizedName, RecipeElvenTrade recipe) { + this(unlocalizedName, Arrays.asList(recipe)); + } + + @Override + public void onPageAdded(LexiconEntry entry, int index) { + for(RecipeElvenTrade recipe : recipes) + if (recipe != null) + LexiconRecipeMappings.map(recipe.getOutput(), entry, index); + } + + @Override + @SideOnly(Side.CLIENT) + public void renderRecipe(IGuiLexiconEntry gui, int mx, int my) { + if (recipes.size() == 0) return; + RecipeElvenTrade recipe = recipes.get(recipeAt); + + TextureManager render = Minecraft.getMinecraft().renderEngine; + render.bindTexture(elvenTradeOverlay); + GL11.glEnable(GL11.GL_BLEND); + GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); + GL11.glColor4f(1F, 1F, 1F, 1F); + ((GuiScreen) gui).drawTexturedModalRect(gui.getLeft(), gui.getTop(), 0, 0, gui.getWidth(), gui.getHeight()); + GL11.glDisable(GL11.GL_BLEND); + + renderItemAtGridPos(gui, 3, 1, recipe.getOutput(), false); + + List inputs = recipe.getInputs(); + int i = 0; + for(Object obj : inputs) { + Object input = obj; + if(input instanceof String) + input = OreDictionary.getOres((String) input).get(0); + + renderItemAtInputPos(gui, i, (ItemStack) input); + i++; + } + + IIcon portalIcon = BlockAlfPortal.portalTex; + Minecraft.getMinecraft().renderEngine.bindTexture(TextureMap.locationBlocksTexture); + RenderItem.getInstance().renderIcon(gui.getLeft() + 22, gui.getTop() + 36, portalIcon, 48, 48); + } + + @SideOnly(Side.CLIENT) + public void renderItemAtInputPos(IGuiLexiconEntry gui, int x, ItemStack stack) { + if(stack == null || stack.getItem() == null) + return; + stack = stack.copy(); + + if(stack.getItemDamage() == Short.MAX_VALUE) + stack.setItemDamage(0); + + int xPos = gui.getLeft() + x * 20 + 45; + int yPos = gui.getTop() + 14; + ItemStack stack1 = stack.copy(); + if(stack1.getItemDamage() == -1) + stack1.setItemDamage(0); + + renderItem(gui, xPos, yPos, stack1, false); + } + + + @Override + @SideOnly(Side.CLIENT) + public void updateScreen() { + if(GuiScreen.isShiftKeyDown()) + return; + + if(ticksElapsed % 20 == 0) { + recipeAt++; + + if(recipeAt == recipes.size()) + recipeAt = 0; + } + ++ticksElapsed; + } + + @Override + public List getDisplayedRecipes() { + ArrayList list = new ArrayList(); + for(RecipeElvenTrade r : recipes) + list.add(r.getOutput()); + + return list; + } + } diff --git a/src/main/java/vazkii/botania/common/lexicon/page/PageEntity.java b/src/main/java/vazkii/botania/common/lexicon/page/PageEntity.java index b1c70ba3db..89fba690d5 100644 --- a/src/main/java/vazkii/botania/common/lexicon/page/PageEntity.java +++ b/src/main/java/vazkii/botania/common/lexicon/page/PageEntity.java @@ -2,17 +2,16 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jul 4, 2014, 10:38:50 PM (GMT)] */ package vazkii.botania.common.lexicon.page; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; import java.lang.reflect.Constructor; + import net.minecraft.client.Minecraft; import net.minecraft.client.renderer.OpenGlHelper; import net.minecraft.client.renderer.RenderHelper; @@ -21,95 +20,98 @@ import net.minecraft.entity.EntityList; import net.minecraft.util.MathHelper; import net.minecraft.world.World; + import org.lwjgl.opengl.GL11; import org.lwjgl.opengl.GL12; + import vazkii.botania.api.internal.IGuiLexiconEntry; import vazkii.botania.api.lexicon.LexiconPage; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +public class PageEntity extends LexiconPage{ + + Entity dummyEntity; + int relativeMouseX, relativeMouseY; + boolean tooltipEntity; + int size; + Constructor entityConstructor; + + public PageEntity(String unlocalizedName, String entity, int size) { + super(unlocalizedName); + Class EntityClass = (Class) EntityList.stringToClassMapping.get(entity); + this.size = size; + try { + entityConstructor = EntityClass.getConstructor(new Class[] {World.class}); + } catch (Exception e) { + e.printStackTrace(); + } + } + + @Override + @SideOnly(Side.CLIENT) + public void renderScreen(IGuiLexiconEntry gui, int mx, int my) { + prepDummy(); + int text_x = gui.getLeft() + 16; + int text_y = gui.getTop() + gui.getHeight() - 40; + int entity_scale = getEntityScale(size); + int entity_x = gui.getLeft() + gui.getWidth() / 2; + int entity_y = gui.getTop() + gui.getHeight() / 2 + MathHelper.floor_float(dummyEntity.height * entity_scale / 2); + + renderEntity(gui, dummyEntity, entity_x, entity_y, entity_scale, dummyEntity.ticksExisted * 2); + + PageText.renderText(text_x, text_y, gui.getWidth() - 30, gui.getHeight(), getUnlocalizedName()); + } + + @SideOnly(Side.CLIENT) + public int getEntityScale(int targetSize) { + float entity_size = dummyEntity.width; + + if(dummyEntity.width < dummyEntity.height) + entity_size = dummyEntity.height; + + return MathHelper.floor_float(size / entity_size); + + } + + @Override + public void updateScreen() { + prepDummy(); + dummyEntity.ticksExisted++; + } + + @SideOnly(Side.CLIENT) + public void renderEntity(IGuiLexiconEntry gui, Entity entity, int x, int y, int scale, float rotation) { + dummyEntity.worldObj = Minecraft.getMinecraft() != null ? Minecraft.getMinecraft().theWorld : null; + + GL11.glEnable(GL11.GL_COLOR_MATERIAL); + GL11.glPushMatrix(); + GL11.glTranslatef(x, y, 50.0F); + GL11.glScalef(-scale, scale, scale); + GL11.glRotatef(180.0F, 0.0F, 0.0F, 1.0F); + GL11.glRotatef(rotation, 0.0F, 1.0F, 0.0F); + RenderHelper.enableStandardItemLighting(); + GL11.glTranslatef(0.0F, entity.yOffset, 0.0F); + RenderManager.instance.playerViewY = 180.0F; + RenderManager.instance.renderEntityWithPosYaw(entity, 0.0D, 0.0D, 0.0D, 0.0F, 1.0F); + GL11.glPopMatrix(); + RenderHelper.disableStandardItemLighting(); + GL11.glDisable(GL12.GL_RESCALE_NORMAL); + OpenGlHelper.setActiveTexture(OpenGlHelper.lightmapTexUnit); + GL11.glDisable(GL11.GL_TEXTURE_2D); + OpenGlHelper.setActiveTexture(OpenGlHelper.defaultTexUnit); + + if(relativeMouseX >= x - dummyEntity.width * scale / 2 - 10 && relativeMouseY >= y - dummyEntity.height * scale - 20 && relativeMouseX <= x + dummyEntity.width * scale / 2 + 10 && relativeMouseY <= y + 20) + tooltipEntity = true; + } -public class PageEntity extends LexiconPage { - - Entity dummyEntity; - int relativeMouseX, relativeMouseY; - boolean tooltipEntity; - int size; - Constructor entityConstructor; - - public PageEntity(String unlocalizedName, String entity, int size) { - super(unlocalizedName); - Class EntityClass = (Class) EntityList.stringToClassMapping.get(entity); - this.size = size; - try { - entityConstructor = EntityClass.getConstructor(new Class[] {World.class}); - } catch (Exception e) { - e.printStackTrace(); - } - } - - @Override - @SideOnly(Side.CLIENT) - public void renderScreen(IGuiLexiconEntry gui, int mx, int my) { - prepDummy(); - int text_x = gui.getLeft() + 16; - int text_y = gui.getTop() + gui.getHeight() - 40; - int entity_scale = getEntityScale(size); - int entity_x = gui.getLeft() + gui.getWidth() / 2; - int entity_y = - gui.getTop() + gui.getHeight() / 2 + MathHelper.floor_float(dummyEntity.height * entity_scale / 2); - - renderEntity(gui, dummyEntity, entity_x, entity_y, entity_scale, dummyEntity.ticksExisted * 2); - - PageText.renderText(text_x, text_y, gui.getWidth() - 30, gui.getHeight(), getUnlocalizedName()); - } - - @SideOnly(Side.CLIENT) - public int getEntityScale(int targetSize) { - float entity_size = dummyEntity.width; - - if (dummyEntity.width < dummyEntity.height) entity_size = dummyEntity.height; - - return MathHelper.floor_float(size / entity_size); - } - - @Override - public void updateScreen() { - prepDummy(); - dummyEntity.ticksExisted++; - } - - @SideOnly(Side.CLIENT) - public void renderEntity(IGuiLexiconEntry gui, Entity entity, int x, int y, int scale, float rotation) { - dummyEntity.worldObj = Minecraft.getMinecraft() != null ? Minecraft.getMinecraft().theWorld : null; - - GL11.glEnable(GL11.GL_COLOR_MATERIAL); - GL11.glPushMatrix(); - GL11.glTranslatef(x, y, 50.0F); - GL11.glScalef(-scale, scale, scale); - GL11.glRotatef(180.0F, 0.0F, 0.0F, 1.0F); - GL11.glRotatef(rotation, 0.0F, 1.0F, 0.0F); - RenderHelper.enableStandardItemLighting(); - GL11.glTranslatef(0.0F, entity.yOffset, 0.0F); - RenderManager.instance.playerViewY = 180.0F; - RenderManager.instance.renderEntityWithPosYaw(entity, 0.0D, 0.0D, 0.0D, 0.0F, 1.0F); - GL11.glPopMatrix(); - RenderHelper.disableStandardItemLighting(); - GL11.glDisable(GL12.GL_RESCALE_NORMAL); - OpenGlHelper.setActiveTexture(OpenGlHelper.lightmapTexUnit); - GL11.glDisable(GL11.GL_TEXTURE_2D); - OpenGlHelper.setActiveTexture(OpenGlHelper.defaultTexUnit); - - if (relativeMouseX >= x - dummyEntity.width * scale / 2 - 10 - && relativeMouseY >= y - dummyEntity.height * scale - 20 - && relativeMouseX <= x + dummyEntity.width * scale / 2 + 10 - && relativeMouseY <= y + 20) tooltipEntity = true; - } - - public void prepDummy() { - if (dummyEntity == null || dummyEntity.isDead) { - try { - dummyEntity = (Entity) entityConstructor.newInstance(new Object[] {Minecraft.getMinecraft().theWorld}); - } catch (Exception e) { - e.printStackTrace(); - } - } - } + public void prepDummy() { + if(dummyEntity == null || dummyEntity.isDead) { + try { + dummyEntity = (Entity) entityConstructor.newInstance(new Object[] {Minecraft.getMinecraft().theWorld}); + } catch (Exception e) { + e.printStackTrace(); + } + } + } } diff --git a/src/main/java/vazkii/botania/common/lexicon/page/PageGuide.java b/src/main/java/vazkii/botania/common/lexicon/page/PageGuide.java index 66456a4908..35ff293a9c 100644 --- a/src/main/java/vazkii/botania/common/lexicon/page/PageGuide.java +++ b/src/main/java/vazkii/botania/common/lexicon/page/PageGuide.java @@ -2,53 +2,48 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Sep 3, 2014, 9:41:47 PM (GMT)] */ package vazkii.botania.common.lexicon.page; import java.awt.Desktop; import java.net.URI; + import net.minecraft.client.gui.GuiButton; import net.minecraft.util.StatCollector; import vazkii.botania.api.internal.IGuiLexiconEntry; public class PageGuide extends PageText { - GuiButton button; - - public PageGuide(String unlocalizedName) { - super(unlocalizedName); - } - - @Override - public void onOpened(IGuiLexiconEntry gui) { - button = new GuiButton( - 101, - gui.getLeft() + 30, - gui.getTop() + gui.getHeight() - 50, - gui.getWidth() - 60, - 20, - StatCollector.translateToLocal("botaniamisc.playVideo")); - gui.getButtonList().add(button); - } - - @Override - public void onClosed(IGuiLexiconEntry gui) { - gui.getButtonList().remove(button); - } - - @Override - public void onActionPerformed(IGuiLexiconEntry gui, GuiButton button) { - if (button == this.button && Desktop.isDesktopSupported()) - try { - Desktop.getDesktop().browse(new URI("https://www.youtube.com/watch?v=rx0xyejC6fI")); - if (Math.random() < 0.01) - Desktop.getDesktop().browse(new URI("https://www.youtube.com/watch?v=dQw4w9WgXcQ")); - } catch (Exception e) { - } - } + GuiButton button; + + public PageGuide(String unlocalizedName) { + super(unlocalizedName); + } + + @Override + public void onOpened(IGuiLexiconEntry gui) { + button = new GuiButton(101, gui.getLeft() + 30, gui.getTop() + gui.getHeight() - 50, gui.getWidth() - 60, 20, StatCollector.translateToLocal("botaniamisc.playVideo")); + gui.getButtonList().add(button); + } + + @Override + public void onClosed(IGuiLexiconEntry gui) { + gui.getButtonList().remove(button); + } + + @Override + public void onActionPerformed(IGuiLexiconEntry gui, GuiButton button) { + if(button == this.button && Desktop.isDesktopSupported()) + try { + Desktop.getDesktop().browse(new URI("https://www.youtube.com/watch?v=rx0xyejC6fI")); + if(Math.random() < 0.01) + Desktop.getDesktop().browse(new URI("https://www.youtube.com/watch?v=dQw4w9WgXcQ")); + } catch(Exception e) { } + } + } diff --git a/src/main/java/vazkii/botania/common/lexicon/page/PageImage.java b/src/main/java/vazkii/botania/common/lexicon/page/PageImage.java index 59cc5169b9..c86a6004ad 100644 --- a/src/main/java/vazkii/botania/common/lexicon/page/PageImage.java +++ b/src/main/java/vazkii/botania/common/lexicon/page/PageImage.java @@ -2,49 +2,52 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jan 16, 2014, 6:13:08 PM (GMT)] */ package vazkii.botania.common.lexicon.page; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.GuiScreen; import net.minecraft.client.renderer.texture.TextureManager; import net.minecraft.util.ResourceLocation; + import org.lwjgl.opengl.GL11; + import vazkii.botania.api.internal.IGuiLexiconEntry; import vazkii.botania.api.lexicon.LexiconPage; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; public class PageImage extends LexiconPage { - ResourceLocation resource; - - public PageImage(String unlocalizedName, String resource) { - super(unlocalizedName); - this.resource = new ResourceLocation(resource); - } - - @Override - @SideOnly(Side.CLIENT) - public void renderScreen(IGuiLexiconEntry gui, int mx, int my) { - TextureManager render = Minecraft.getMinecraft().renderEngine; - render.bindTexture(resource); - - GL11.glEnable(GL11.GL_BLEND); - GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); - GL11.glColor4f(1F, 1F, 1F, 1F); - ((GuiScreen) gui).drawTexturedModalRect(gui.getLeft(), gui.getTop(), 0, 0, gui.getWidth(), gui.getHeight()); - GL11.glDisable(GL11.GL_BLEND); - - int width = gui.getWidth() - 30; - int height = gui.getHeight(); - int x = gui.getLeft() + 16; - int y = gui.getTop() + height - 40; - PageText.renderText(x, y, width, height, getUnlocalizedName()); - } + ResourceLocation resource; + + public PageImage(String unlocalizedName, String resource) { + super(unlocalizedName); + this.resource = new ResourceLocation(resource); + } + + @Override + @SideOnly(Side.CLIENT) + public void renderScreen(IGuiLexiconEntry gui, int mx, int my) { + TextureManager render = Minecraft.getMinecraft().renderEngine; + render.bindTexture(resource); + + GL11.glEnable(GL11.GL_BLEND); + GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); + GL11.glColor4f(1F, 1F, 1F, 1F); + ((GuiScreen) gui).drawTexturedModalRect(gui.getLeft(), gui.getTop(), 0, 0, gui.getWidth(), gui.getHeight()); + GL11.glDisable(GL11.GL_BLEND); + + int width = gui.getWidth() - 30; + int height = gui.getHeight(); + int x = gui.getLeft() + 16; + int y = gui.getTop() + height - 40; + PageText.renderText(x, y, width, height, getUnlocalizedName()); + } + } diff --git a/src/main/java/vazkii/botania/common/lexicon/page/PageLoreText.java b/src/main/java/vazkii/botania/common/lexicon/page/PageLoreText.java index 2262a79bb6..01b9e2788f 100644 --- a/src/main/java/vazkii/botania/common/lexicon/page/PageLoreText.java +++ b/src/main/java/vazkii/botania/common/lexicon/page/PageLoreText.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Nov 7, 2014, 11:46:21 PM (GMT)] */ package vazkii.botania.common.lexicon.page; @@ -13,27 +13,30 @@ import net.minecraft.client.Minecraft; import net.minecraft.client.gui.GuiScreen; import net.minecraft.util.ResourceLocation; + import org.lwjgl.opengl.GL11; + import vazkii.botania.api.internal.IGuiLexiconEntry; import vazkii.botania.client.lib.LibResources; public class PageLoreText extends PageText { - private static final ResourceLocation paperOverlay = new ResourceLocation(LibResources.GUI_PAPER); + private static final ResourceLocation paperOverlay = new ResourceLocation(LibResources.GUI_PAPER); + + public PageLoreText(String unlocalizedName) { + super(unlocalizedName); + } - public PageLoreText(String unlocalizedName) { - super(unlocalizedName); - } + @Override + public void renderScreen(IGuiLexiconEntry gui, int mx, int my) { + Minecraft.getMinecraft().renderEngine.bindTexture(paperOverlay); - @Override - public void renderScreen(IGuiLexiconEntry gui, int mx, int my) { - Minecraft.getMinecraft().renderEngine.bindTexture(paperOverlay); + GL11.glEnable(GL11.GL_BLEND); + GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); + GL11.glColor4f(1F, 1F, 1F, 1F); + ((GuiScreen) gui).drawTexturedModalRect(gui.getLeft(), gui.getTop(), 0, 0, gui.getWidth(), gui.getHeight()); + GL11.glDisable(GL11.GL_BLEND); + super.renderScreen(gui, mx, my); + } - GL11.glEnable(GL11.GL_BLEND); - GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); - GL11.glColor4f(1F, 1F, 1F, 1F); - ((GuiScreen) gui).drawTexturedModalRect(gui.getLeft(), gui.getTop(), 0, 0, gui.getWidth(), gui.getHeight()); - GL11.glDisable(GL11.GL_BLEND); - super.renderScreen(gui, mx, my); - } } diff --git a/src/main/java/vazkii/botania/common/lexicon/page/PageManaInfusionRecipe.java b/src/main/java/vazkii/botania/common/lexicon/page/PageManaInfusionRecipe.java index a76136a58e..0240a4e92b 100644 --- a/src/main/java/vazkii/botania/common/lexicon/page/PageManaInfusionRecipe.java +++ b/src/main/java/vazkii/botania/common/lexicon/page/PageManaInfusionRecipe.java @@ -2,19 +2,18 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Feb 8, 2014, 1:11:42 PM (GMT)] */ package vazkii.botania.common.lexicon.page; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; import java.util.ArrayList; import java.util.Arrays; import java.util.List; + import net.minecraft.client.Minecraft; import net.minecraft.client.gui.FontRenderer; import net.minecraft.client.gui.GuiScreen; @@ -25,7 +24,9 @@ import net.minecraft.util.ResourceLocation; import net.minecraft.util.StatCollector; import net.minecraftforge.oredict.OreDictionary; + import org.lwjgl.opengl.GL11; + import vazkii.botania.api.internal.IGuiLexiconEntry; import vazkii.botania.api.lexicon.LexiconEntry; import vazkii.botania.api.lexicon.LexiconRecipeMappings; @@ -36,135 +37,130 @@ import vazkii.botania.client.render.tile.RenderTilePool; import vazkii.botania.common.block.ModBlocks; import vazkii.botania.common.block.tile.mana.TilePool; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; public class PageManaInfusionRecipe extends PageRecipe { - private static final ResourceLocation manaInfusionOverlay = - new ResourceLocation(LibResources.GUI_MANA_INFUSION_OVERLAY); - - List recipes; - int ticksElapsed = 0; - int recipeAt = 0; - - public PageManaInfusionRecipe(String unlocalizedName, List recipes) { - super(unlocalizedName); - this.recipes = filterRecipes(recipes); - } - - public PageManaInfusionRecipe(String unlocalizedName, RecipeManaInfusion recipe) { - this(unlocalizedName, Arrays.asList(recipe)); - } - - @Override - public void onPageAdded(LexiconEntry entry, int index) { - for (RecipeManaInfusion recipe : recipes) - if (recipe != null) LexiconRecipeMappings.map(recipe.getOutput(), entry, index); - } - - @Override - @SideOnly(Side.CLIENT) - public void renderRecipe(IGuiLexiconEntry gui, int mx, int my) { - if (recipes.size() == 0) return; - RecipeManaInfusion recipe = recipes.get(recipeAt); - - TextureManager render = Minecraft.getMinecraft().renderEngine; - FontRenderer font = Minecraft.getMinecraft().fontRenderer; - - Object input = recipe.getInput(); - if (input instanceof String) - input = OreDictionary.getOres((String) input).get(0); - - renderItemAtGridPos(gui, 1, 1, (ItemStack) input, false); - - RenderTilePool.forceMana = true; - renderItemAtGridPos( - gui, - 2, - 1, - new ItemStack( - ModBlocks.pool, - 1, - recipe.getOutput().getItem() == Item.getItemFromBlock(ModBlocks.pool) ? 2 : 0), - false); - - renderItemAtGridPos(gui, 3, 1, recipe.getOutput(), false); - - if (recipe.isAlchemy()) renderItemAtGridPos(gui, 1, 2, new ItemStack(ModBlocks.alchemyCatalyst), false); - else if (recipe.isConjuration()) - renderItemAtGridPos(gui, 1, 2, new ItemStack(ModBlocks.conjurationCatalyst), false); - - GL11.glEnable(GL11.GL_BLEND); - GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); - String manaUsage = StatCollector.translateToLocal("botaniamisc.manaUsage"); - font.drawString( - manaUsage, - gui.getLeft() + gui.getWidth() / 2 - font.getStringWidth(manaUsage) / 2, - gui.getTop() + 105, - 0x66000000); - - int ratio = 10; - int x = gui.getLeft() + gui.getWidth() / 2 - 50; - int y = gui.getTop() + 115; - - if (mx > x + 1 && mx <= x + 101 && my > y - 14 && my <= y + 11) ratio = 1; - - HUDHandler.renderManaBar(x, y, 0x0000FF, 0.75F, recipe.getManaToConsume(), TilePool.MAX_MANA / ratio); - - String ratioString = String.format(StatCollector.translateToLocal("botaniamisc.ratio"), ratio); - String dropString = StatCollector.translateToLocal("botaniamisc.drop") + " " + EnumChatFormatting.BOLD + "(?)"; - - boolean hoveringOverDrop = false; - - boolean unicode = font.getUnicodeFlag(); - font.setUnicodeFlag(true); - int dw = font.getStringWidth(dropString); - int dx = x + 35 - dw / 2; - int dy = gui.getTop() + 30; - - if (mx > dx && mx <= dx + dw && my > dy && my <= dy + 10) hoveringOverDrop = true; - - font.drawString(dropString, dx, dy, 0x77000000); - font.drawString(ratioString, x + 50 - font.getStringWidth(ratioString) / 2, y + 5, 0x99000000); - font.setUnicodeFlag(unicode); - - GL11.glDisable(GL11.GL_BLEND); - - render.bindTexture(manaInfusionOverlay); - - GL11.glEnable(GL11.GL_BLEND); - GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); - GL11.glColor4f(1F, 1F, 1F, 1F); - ((GuiScreen) gui).drawTexturedModalRect(gui.getLeft(), gui.getTop(), 0, 0, gui.getWidth(), gui.getHeight()); - GL11.glDisable(GL11.GL_BLEND); - - if (hoveringOverDrop) { - String key = RenderHelper.getKeyDisplayString("key.drop"); - String tip0 = StatCollector.translateToLocal("botaniamisc.dropTip0") - .replaceAll("%key%", EnumChatFormatting.GREEN + key + EnumChatFormatting.WHITE); - String tip1 = StatCollector.translateToLocal("botaniamisc.dropTip1") - .replaceAll("%key%", EnumChatFormatting.GREEN + key + EnumChatFormatting.WHITE); - RenderHelper.renderTooltip(mx, my, Arrays.asList(tip0, tip1)); - } - } - - @Override - @SideOnly(Side.CLIENT) - public void updateScreen() { - if (GuiScreen.isShiftKeyDown()) return; - - if (ticksElapsed % 20 == 0) { - recipeAt++; - - if (recipeAt == recipes.size()) recipeAt = 0; - } - ++ticksElapsed; - } - - @Override - public List getDisplayedRecipes() { - ArrayList list = new ArrayList(); - for (RecipeManaInfusion r : recipes) list.add(r.getOutput()); - - return list; - } + private static final ResourceLocation manaInfusionOverlay = new ResourceLocation(LibResources.GUI_MANA_INFUSION_OVERLAY); + + List recipes; + int ticksElapsed = 0; + int recipeAt = 0; + + public PageManaInfusionRecipe(String unlocalizedName, List recipes) { + super(unlocalizedName); + this.recipes = filterRecipes(recipes); + } + + public PageManaInfusionRecipe(String unlocalizedName, RecipeManaInfusion recipe) { + this(unlocalizedName, Arrays.asList(recipe)); + } + + @Override + public void onPageAdded(LexiconEntry entry, int index) { + for(RecipeManaInfusion recipe : recipes) + if (recipe != null) + LexiconRecipeMappings.map(recipe.getOutput(), entry, index); + } + + @Override + @SideOnly(Side.CLIENT) + public void renderRecipe(IGuiLexiconEntry gui, int mx, int my) { + if (recipes.size() == 0) return; + RecipeManaInfusion recipe = recipes.get(recipeAt); + + TextureManager render = Minecraft.getMinecraft().renderEngine; + FontRenderer font = Minecraft.getMinecraft().fontRenderer; + + Object input = recipe.getInput(); + if(input instanceof String) + input = OreDictionary.getOres((String) input).get(0); + + renderItemAtGridPos(gui, 1, 1, (ItemStack) input, false); + + RenderTilePool.forceMana = true; + renderItemAtGridPos(gui, 2, 1, new ItemStack(ModBlocks.pool, 1, recipe.getOutput().getItem() == Item.getItemFromBlock(ModBlocks.pool) ? 2 : 0), false); + + renderItemAtGridPos(gui, 3, 1, recipe.getOutput(), false); + + if(recipe.isAlchemy()) + renderItemAtGridPos(gui, 1, 2, new ItemStack(ModBlocks.alchemyCatalyst), false); + else if(recipe.isConjuration()) + renderItemAtGridPos(gui, 1, 2, new ItemStack(ModBlocks.conjurationCatalyst), false); + + GL11.glEnable(GL11.GL_BLEND); + GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); + String manaUsage = StatCollector.translateToLocal("botaniamisc.manaUsage"); + font.drawString(manaUsage, gui.getLeft() + gui.getWidth() / 2 - font.getStringWidth(manaUsage) / 2, gui.getTop() + 105, 0x66000000); + + int ratio = 10; + int x = gui.getLeft() + gui.getWidth() / 2 - 50; + int y = gui.getTop() + 115; + + if(mx > x + 1 && mx <= x + 101 && my > y - 14 && my <= y + 11) + ratio = 1; + + HUDHandler.renderManaBar(x, y, 0x0000FF, 0.75F, recipe.getManaToConsume(), TilePool.MAX_MANA / ratio); + + String ratioString = String.format(StatCollector.translateToLocal("botaniamisc.ratio"), ratio); + String dropString = StatCollector.translateToLocal("botaniamisc.drop") + " " + EnumChatFormatting.BOLD + "(?)"; + + boolean hoveringOverDrop = false; + + boolean unicode = font.getUnicodeFlag(); + font.setUnicodeFlag(true); + int dw = font.getStringWidth(dropString); + int dx = x + 35 - dw / 2; + int dy = gui.getTop() + 30; + + if(mx > dx && mx <= dx + dw && my > dy && my <= dy + 10) + hoveringOverDrop = true; + + font.drawString(dropString, dx, dy, 0x77000000); + font.drawString(ratioString, x + 50 - font.getStringWidth(ratioString) / 2, y + 5, 0x99000000); + font.setUnicodeFlag(unicode); + + GL11.glDisable(GL11.GL_BLEND); + + render.bindTexture(manaInfusionOverlay); + + GL11.glEnable(GL11.GL_BLEND); + GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); + GL11.glColor4f(1F, 1F, 1F, 1F); + ((GuiScreen) gui).drawTexturedModalRect(gui.getLeft(), gui.getTop(), 0, 0, gui.getWidth(), gui.getHeight()); + GL11.glDisable(GL11.GL_BLEND); + + if(hoveringOverDrop) { + String key = RenderHelper.getKeyDisplayString("key.drop"); + String tip0 = StatCollector.translateToLocal("botaniamisc.dropTip0").replaceAll("%key%", EnumChatFormatting.GREEN + key + EnumChatFormatting.WHITE); + String tip1 = StatCollector.translateToLocal("botaniamisc.dropTip1").replaceAll("%key%", EnumChatFormatting.GREEN + key + EnumChatFormatting.WHITE); + RenderHelper.renderTooltip(mx, my, Arrays.asList(tip0, tip1)); + } + } + + @Override + @SideOnly(Side.CLIENT) + public void updateScreen() { + if(GuiScreen.isShiftKeyDown()) + return; + + if(ticksElapsed % 20 == 0) { + recipeAt++; + + if(recipeAt == recipes.size()) + recipeAt = 0; + } + ++ticksElapsed; + } + + @Override + public List getDisplayedRecipes() { + ArrayList list = new ArrayList(); + for(RecipeManaInfusion r : recipes) + list.add(r.getOutput()); + + return list; + } + } diff --git a/src/main/java/vazkii/botania/common/lexicon/page/PageMultiblock.java b/src/main/java/vazkii/botania/common/lexicon/page/PageMultiblock.java index ab75be5a54..e7a7a612d5 100644 --- a/src/main/java/vazkii/botania/common/lexicon/page/PageMultiblock.java +++ b/src/main/java/vazkii/botania/common/lexicon/page/PageMultiblock.java @@ -2,18 +2,17 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jun 28, 2015, 1:48:58 AM (GMT)] */ package vazkii.botania.common.lexicon.page; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; import java.util.ArrayList; import java.util.List; + import net.minecraft.client.Minecraft; import net.minecraft.client.gui.FontRenderer; import net.minecraft.client.gui.GuiButton; @@ -26,124 +25,128 @@ import net.minecraft.util.EnumChatFormatting; import net.minecraft.util.ResourceLocation; import net.minecraft.util.StatCollector; + import org.lwjgl.opengl.GL11; import org.lwjgl.opengl.GL12; + import vazkii.botania.api.internal.IGuiLexiconEntry; import vazkii.botania.api.lexicon.LexiconPage; import vazkii.botania.api.lexicon.multiblock.Multiblock; import vazkii.botania.api.lexicon.multiblock.MultiblockSet; import vazkii.botania.client.core.handler.MultiblockRenderHandler; import vazkii.botania.client.lib.LibResources; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; public class PageMultiblock extends LexiconPage { - private static final ResourceLocation multiblockOverlay = new ResourceLocation(LibResources.GUI_MULTIBLOCK_OVERLAY); - - GuiButton button; - MultiblockSet set; - Multiblock mb; - int ticksElapsed; - - public PageMultiblock(String unlocalizedName, MultiblockSet set) { - super(unlocalizedName); - mb = set.getForIndex(0); - this.set = set; - } - - @Override - @SideOnly(Side.CLIENT) - public void renderScreen(IGuiLexiconEntry gui, int mx, int my) { - TextureManager render = Minecraft.getMinecraft().renderEngine; - render.bindTexture(multiblockOverlay); - - GL11.glEnable(GL11.GL_BLEND); - GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); - GL11.glDisable(GL11.GL_ALPHA_TEST); - GL11.glColor4f(1F, 1F, 1F, 1F); - ((GuiScreen) gui).drawTexturedModalRect(gui.getLeft(), gui.getTop(), 0, 0, gui.getWidth(), gui.getHeight()); - GL11.glDisable(GL11.GL_BLEND); - GL11.glEnable(GL11.GL_ALPHA_TEST); - - final float maxX = 90, maxY = 60; - GL11.glPushMatrix(); - GL11.glTranslatef(gui.getLeft() + gui.getWidth() / 2, gui.getTop() + 90, gui.getZLevel() + 100F); - - float diag = (float) Math.sqrt(mb.getXSize() * mb.getXSize() + mb.getZSize() * mb.getZSize()); - float height = mb.getYSize(); - float scaleX = maxX / diag; - float scaleY = maxY / height; - float scale = -Math.min(scaleY, scaleX); - GL11.glScalef(scale, scale, scale); - - GL11.glRotatef(-20F, 1, 0, 0); - GL11.glRotatef(gui.getElapsedTicks(), 0, 1, 0); - - MultiblockRenderHandler.renderMultiblockOnPage(mb); - - GL11.glPopMatrix(); - - FontRenderer font = Minecraft.getMinecraft().fontRenderer; - boolean unicode = font.getUnicodeFlag(); - String s = EnumChatFormatting.BOLD + StatCollector.translateToLocal(getUnlocalizedName()); - font.setUnicodeFlag(true); - font.drawString( - s, gui.getLeft() + gui.getWidth() / 2 - font.getStringWidth(s) / 2, gui.getTop() + 16, 0x000000); - font.setUnicodeFlag(unicode); - - GL11.glEnable(GL12.GL_RESCALE_NORMAL); - RenderHelper.enableGUIStandardItemLighting(); - int x = gui.getLeft() + 15; - int y = gui.getTop() + 25; - RenderItem.getInstance().renderItemIntoGUI(font, render, new ItemStack(Blocks.stonebrick), x, y); - RenderHelper.disableStandardItemLighting(); - GL11.glDisable(GL12.GL_RESCALE_NORMAL); - - GL11.glPushMatrix(); - GL11.glTranslatef(0F, 0F, 200F); - if (mx >= x && mx < x + 16 && my >= y && my < y + 16) { - List mats = new ArrayList(); - mats.add(StatCollector.translateToLocal("botaniamisc.materialsRequired")); - for (ItemStack stack : mb.materials) { - String size = "" + stack.stackSize; - if (size.length() < 2) size = "0" + size; - mats.add(" " + EnumChatFormatting.AQUA + size + " " + EnumChatFormatting.GRAY + stack.getDisplayName()); - } - - vazkii.botania.client.core.helper.RenderHelper.renderTooltip(mx, my, mats); - } - GL11.glPopMatrix(); - } - - @Override - public void onOpened(IGuiLexiconEntry gui) { - button = new GuiButton( - 101, gui.getLeft() + 30, gui.getTop() + gui.getHeight() - 50, gui.getWidth() - 60, 20, getButtonStr()); - gui.getButtonList().add(button); - } - - String getButtonStr() { - return StatCollector.translateToLocal( - MultiblockRenderHandler.currentMultiblock == set ? "botaniamisc.unvisualize" : "botaniamisc.visualize"); - } - - @Override - public void onClosed(IGuiLexiconEntry gui) { - gui.getButtonList().remove(button); - } - - @Override - @SideOnly(Side.CLIENT) - public void onActionPerformed(IGuiLexiconEntry gui, GuiButton button) { - if (button == this.button) { - if (MultiblockRenderHandler.currentMultiblock == set) MultiblockRenderHandler.setMultiblock(null); - else MultiblockRenderHandler.setMultiblock(set); - button.displayString = getButtonStr(); - } - } - - @Override - @SideOnly(Side.CLIENT) - public void updateScreen() { - ++ticksElapsed; - } + private static final ResourceLocation multiblockOverlay = new ResourceLocation(LibResources.GUI_MULTIBLOCK_OVERLAY); + + GuiButton button; + MultiblockSet set; + Multiblock mb; + int ticksElapsed; + + public PageMultiblock(String unlocalizedName, MultiblockSet set) { + super(unlocalizedName); + mb = set.getForIndex(0); + this.set = set; + } + + @Override + @SideOnly(Side.CLIENT) + public void renderScreen(IGuiLexiconEntry gui, int mx, int my) { + TextureManager render = Minecraft.getMinecraft().renderEngine; + render.bindTexture(multiblockOverlay); + + GL11.glEnable(GL11.GL_BLEND); + GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); + GL11.glDisable(GL11.GL_ALPHA_TEST); + GL11.glColor4f(1F, 1F, 1F, 1F); + ((GuiScreen) gui).drawTexturedModalRect(gui.getLeft(), gui.getTop(), 0, 0, gui.getWidth(), gui.getHeight()); + GL11.glDisable(GL11.GL_BLEND); + GL11.glEnable(GL11.GL_ALPHA_TEST); + + final float maxX = 90, maxY = 60; + GL11.glPushMatrix(); + GL11.glTranslatef(gui.getLeft() + gui.getWidth() / 2, gui.getTop() + 90, gui.getZLevel() + 100F); + + float diag = (float) Math.sqrt(mb.getXSize() * mb.getXSize() + mb.getZSize() * mb.getZSize()); + float height = mb.getYSize(); + float scaleX = maxX / diag; + float scaleY = maxY / height; + float scale = -Math.min(scaleY, scaleX); + GL11.glScalef(scale, scale, scale); + + GL11.glRotatef(-20F, 1, 0, 0); + GL11.glRotatef(gui.getElapsedTicks(), 0, 1, 0); + + MultiblockRenderHandler.renderMultiblockOnPage(mb); + + GL11.glPopMatrix(); + + FontRenderer font = Minecraft.getMinecraft().fontRenderer; + boolean unicode = font.getUnicodeFlag(); + String s = EnumChatFormatting.BOLD + StatCollector.translateToLocal(getUnlocalizedName()); + font.setUnicodeFlag(true); + font.drawString(s, gui.getLeft() + gui.getWidth() / 2 - font.getStringWidth(s) / 2, gui.getTop() + 16, 0x000000); + font.setUnicodeFlag(unicode); + + GL11.glEnable(GL12.GL_RESCALE_NORMAL); + RenderHelper.enableGUIStandardItemLighting(); + int x = gui.getLeft() + 15; + int y = gui.getTop() + 25; + RenderItem.getInstance().renderItemIntoGUI(font, render, new ItemStack(Blocks.stonebrick), x, y); + RenderHelper.disableStandardItemLighting(); + GL11.glDisable(GL12.GL_RESCALE_NORMAL); + + GL11.glPushMatrix(); + GL11.glTranslatef(0F, 0F, 200F); + if(mx >= x && mx < x + 16 && my >= y && my < y + 16) { + List mats = new ArrayList(); + mats.add(StatCollector.translateToLocal("botaniamisc.materialsRequired")); + for(ItemStack stack : mb.materials) { + String size = "" + stack.stackSize; + if(size.length() < 2) + size = "0" + size; + mats.add(" " + EnumChatFormatting.AQUA + size + " " + EnumChatFormatting.GRAY + stack.getDisplayName()); + } + + vazkii.botania.client.core.helper.RenderHelper.renderTooltip(mx, my, mats); + } + GL11.glPopMatrix(); + } + + @Override + public void onOpened(IGuiLexiconEntry gui) { + button = new GuiButton(101, gui.getLeft() + 30, gui.getTop() + gui.getHeight() - 50, gui.getWidth() - 60, 20, getButtonStr()); + gui.getButtonList().add(button); + } + + String getButtonStr() { + return StatCollector.translateToLocal(MultiblockRenderHandler.currentMultiblock == set ? "botaniamisc.unvisualize" : "botaniamisc.visualize"); + } + + @Override + public void onClosed(IGuiLexiconEntry gui) { + gui.getButtonList().remove(button); + } + + @Override + @SideOnly(Side.CLIENT) + public void onActionPerformed(IGuiLexiconEntry gui, GuiButton button) { + if(button == this.button) { + if(MultiblockRenderHandler.currentMultiblock == set) + MultiblockRenderHandler.setMultiblock(null); + else MultiblockRenderHandler.setMultiblock(set); + button.displayString = getButtonStr(); + } + } + + @Override + @SideOnly(Side.CLIENT) + public void updateScreen() { + ++ticksElapsed; + } + } diff --git a/src/main/java/vazkii/botania/common/lexicon/page/PagePetalRecipe.java b/src/main/java/vazkii/botania/common/lexicon/page/PagePetalRecipe.java index 72c41ac89e..3b3b9b4828 100644 --- a/src/main/java/vazkii/botania/common/lexicon/page/PagePetalRecipe.java +++ b/src/main/java/vazkii/botania/common/lexicon/page/PagePetalRecipe.java @@ -2,19 +2,18 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Feb 8, 2014, 1:11:35 PM (GMT)] */ package vazkii.botania.common.lexicon.page; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; import java.util.ArrayList; import java.util.Arrays; import java.util.List; + import net.minecraft.client.Minecraft; import net.minecraft.client.gui.FontRenderer; import net.minecraft.client.gui.GuiScreen; @@ -23,7 +22,9 @@ import net.minecraft.util.ResourceLocation; import net.minecraft.util.StatCollector; import net.minecraftforge.oredict.OreDictionary; + import org.lwjgl.opengl.GL11; + import vazkii.botania.api.internal.IGuiLexiconEntry; import vazkii.botania.api.lexicon.LexiconEntry; import vazkii.botania.api.lexicon.LexiconRecipeMappings; @@ -32,113 +33,118 @@ import vazkii.botania.client.lib.LibResources; import vazkii.botania.common.block.ModBlocks; import vazkii.botania.common.core.handler.ConfigHandler; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; public class PagePetalRecipe extends PageRecipe { - private static final ResourceLocation petalOverlay = new ResourceLocation(LibResources.GUI_PETAL_OVERLAY); - - List recipes; - int ticksElapsed = 0; - int recipeAt = 0; - int oredictCounter = 0; - - public PagePetalRecipe(String unlocalizedName, List recipes) { - super(unlocalizedName); - this.recipes = filterRecipes(recipes); - } - - public PagePetalRecipe(String unlocalizedName, T recipe) { - this(unlocalizedName, Arrays.asList(recipe)); - } - - @Override - public void onPageAdded(LexiconEntry entry, int index) { - for (T recipe : recipes) if (recipe != null) LexiconRecipeMappings.map(recipe.getOutput(), entry, index); - } - - @Override - @SideOnly(Side.CLIENT) - public void renderRecipe(IGuiLexiconEntry gui, int mx, int my) { - if (recipes.size() == 0) return; - T recipe = recipes.get(recipeAt); - - TextureManager render = Minecraft.getMinecraft().renderEngine; - - renderItemAtGridPos(gui, 3, 0, recipe.getOutput(), false); - renderItemAtGridPos(gui, 2, 1, getMiddleStack(), false); - - List inputs = recipe.getInputs(); - int degreePerInput = (int) (360F / inputs.size()); - float currentDegree = ConfigHandler.lexiconRotatingItems - ? GuiScreen.isShiftKeyDown() ? ticksElapsed : (float) (ticksElapsed + ClientTickHandler.partialTicks) - : 0; - - for (Object obj : inputs) { - Object input = obj; - if (input instanceof String) { - List ores = OreDictionary.getOres((String) input); - input = ores.get(oredictCounter % ores.size()); - } - - renderItemAtAngle(gui, currentDegree, (ItemStack) input); - - currentDegree += degreePerInput; - } - - renderManaBar(gui, recipe, mx, my); - - render.bindTexture(petalOverlay); - - GL11.glEnable(GL11.GL_BLEND); - GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); - GL11.glColor4f(1F, 1F, 1F, 1F); - ((GuiScreen) gui).drawTexturedModalRect(gui.getLeft(), gui.getTop(), 0, 0, gui.getWidth(), gui.getHeight()); - GL11.glDisable(GL11.GL_BLEND); - } - - ItemStack getMiddleStack() { - return new ItemStack(ModBlocks.altar); - } - - @SideOnly(Side.CLIENT) - public void renderManaBar(IGuiLexiconEntry gui, T recipe, int mx, int my) { - FontRenderer font = Minecraft.getMinecraft().fontRenderer; - GL11.glEnable(GL11.GL_BLEND); - GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); - - int x = gui.getLeft() + gui.getWidth() / 2 - 50; - int y = gui.getTop() + 120; - - boolean unicode = font.getUnicodeFlag(); - font.setUnicodeFlag(true); - String stopStr = StatCollector.translateToLocal("botaniamisc.shiftToStopSpin"); - font.drawString(stopStr, x + 50 - font.getStringWidth(stopStr) / 2, y + 15, 0x99000000); - font.setUnicodeFlag(unicode); - - GL11.glDisable(GL11.GL_BLEND); - } - - @Override - @SideOnly(Side.CLIENT) - public void updateScreen() { - if (GuiScreen.isShiftKeyDown()) return; - - if (ticksElapsed % 20 == 0) { - recipeAt++; - - if (recipeAt == recipes.size()) { - recipeAt = 0; - oredictCounter++; - } - } - ++ticksElapsed; - } - - @Override - public List getDisplayedRecipes() { - ArrayList list = new ArrayList(); - for (T r : recipes) list.add(r.getOutput()); - - return list; - } + private static final ResourceLocation petalOverlay = new ResourceLocation(LibResources.GUI_PETAL_OVERLAY); + + List recipes; + int ticksElapsed = 0; + int recipeAt = 0; + int oredictCounter = 0; + + public PagePetalRecipe(String unlocalizedName, List recipes) { + super(unlocalizedName); + this.recipes = filterRecipes(recipes); + } + + public PagePetalRecipe(String unlocalizedName, T recipe) { + this(unlocalizedName, Arrays.asList(recipe)); + } + + @Override + public void onPageAdded(LexiconEntry entry, int index) { + for(T recipe : recipes) + if (recipe != null) + LexiconRecipeMappings.map(recipe.getOutput(), entry, index); + } + + @Override + @SideOnly(Side.CLIENT) + public void renderRecipe(IGuiLexiconEntry gui, int mx, int my) { + if (recipes.size() == 0) return; + T recipe = recipes.get(recipeAt); + + TextureManager render = Minecraft.getMinecraft().renderEngine; + + renderItemAtGridPos(gui, 3, 0, recipe.getOutput(), false); + renderItemAtGridPos(gui, 2, 1, getMiddleStack(), false); + + List inputs = recipe.getInputs(); + int degreePerInput = (int) (360F / inputs.size()); + float currentDegree = ConfigHandler.lexiconRotatingItems ? GuiScreen.isShiftKeyDown() ? ticksElapsed : (float) (ticksElapsed + ClientTickHandler.partialTicks) : 0; + + for(Object obj : inputs) { + Object input = obj; + if(input instanceof String) { + List ores = OreDictionary.getOres((String) input); + input = ores.get(oredictCounter % ores.size()); + } + + renderItemAtAngle(gui, currentDegree, (ItemStack) input); + + currentDegree += degreePerInput; + } + + renderManaBar(gui, recipe, mx, my); + + render.bindTexture(petalOverlay); + + GL11.glEnable(GL11.GL_BLEND); + GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); + GL11.glColor4f(1F, 1F, 1F, 1F); + ((GuiScreen) gui).drawTexturedModalRect(gui.getLeft(), gui.getTop(), 0, 0, gui.getWidth(), gui.getHeight()); + GL11.glDisable(GL11.GL_BLEND); + } + + ItemStack getMiddleStack() { + return new ItemStack(ModBlocks.altar); + } + + @SideOnly(Side.CLIENT) + public void renderManaBar(IGuiLexiconEntry gui, T recipe, int mx, int my) { + FontRenderer font = Minecraft.getMinecraft().fontRenderer; + GL11.glEnable(GL11.GL_BLEND); + GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); + + int x = gui.getLeft() + gui.getWidth() / 2 - 50; + int y = gui.getTop() + 120; + + boolean unicode = font.getUnicodeFlag(); + font.setUnicodeFlag(true); + String stopStr = StatCollector.translateToLocal("botaniamisc.shiftToStopSpin"); + font.drawString(stopStr, x + 50 - font.getStringWidth(stopStr) / 2, y + 15, 0x99000000); + font.setUnicodeFlag(unicode); + + GL11.glDisable(GL11.GL_BLEND); + } + + @Override + @SideOnly(Side.CLIENT) + public void updateScreen() { + if(GuiScreen.isShiftKeyDown()) + return; + + if(ticksElapsed % 20 == 0) { + recipeAt++; + + if(recipeAt == recipes.size()) { + recipeAt = 0; + oredictCounter++; + } + } + ++ticksElapsed; + } + + @Override + public List getDisplayedRecipes() { + ArrayList list = new ArrayList(); + for(T r : recipes) + list.add(r.getOutput()); + + return list; + } + } diff --git a/src/main/java/vazkii/botania/common/lexicon/page/PageRecipe.java b/src/main/java/vazkii/botania/common/lexicon/page/PageRecipe.java index d173db679c..76147e43c4 100644 --- a/src/main/java/vazkii/botania/common/lexicon/page/PageRecipe.java +++ b/src/main/java/vazkii/botania/common/lexicon/page/PageRecipe.java @@ -2,19 +2,18 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Feb 8, 2014, 2:46:36 PM (GMT)] */ package vazkii.botania.common.lexicon.page; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; import java.util.ArrayList; import java.util.Arrays; import java.util.List; + import net.minecraft.client.Minecraft; import net.minecraft.client.gui.GuiScreen; import net.minecraft.client.renderer.RenderHelper; @@ -22,181 +21,173 @@ import net.minecraft.item.ItemStack; import net.minecraft.util.EnumChatFormatting; import net.minecraft.util.StatCollector; + import org.lwjgl.input.Mouse; import org.lwjgl.opengl.GL11; import org.lwjgl.opengl.GL12; + import vazkii.botania.api.internal.IGuiLexiconEntry; import vazkii.botania.api.lexicon.ILexicon; import vazkii.botania.api.lexicon.LexiconPage; import vazkii.botania.api.lexicon.LexiconRecipeMappings; import vazkii.botania.api.lexicon.LexiconRecipeMappings.EntryData; import vazkii.botania.client.gui.lexicon.GuiLexiconEntry; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; public class PageRecipe extends LexiconPage { - int relativeMouseX, relativeMouseY; - ItemStack tooltipStack, tooltipContainerStack; - boolean tooltipEntry; - - static boolean mouseDownLastTick = false; - - public PageRecipe(String unlocalizedName) { - super(unlocalizedName); - } - - @Override - @SideOnly(Side.CLIENT) - public void renderScreen(IGuiLexiconEntry gui, int mx, int my) { - relativeMouseX = mx; - relativeMouseY = my; - - renderRecipe(gui, mx, my); - - int width = gui.getWidth() - 30; - int height = gui.getHeight(); - int x = gui.getLeft() + 16; - int y = gui.getTop() + height - 40; - PageText.renderText(x, y, width, height, getUnlocalizedName()); - - if (tooltipStack != null) { - List tooltipData = tooltipStack.getTooltip(Minecraft.getMinecraft().thePlayer, false); - List parsedTooltip = new ArrayList(); - boolean first = true; - - for (String s : tooltipData) { - String s_ = s; - if (!first) s_ = EnumChatFormatting.GRAY + s; - parsedTooltip.add(s_); - first = false; - } - - vazkii.botania.client.core.helper.RenderHelper.renderTooltip(mx, my, parsedTooltip); - - int tooltipY = 8 + tooltipData.size() * 11; - - if (tooltipEntry) { - vazkii.botania.client.core.helper.RenderHelper.renderTooltipOrange( - mx, - my + tooltipY, - Arrays.asList( - EnumChatFormatting.GRAY + StatCollector.translateToLocal("botaniamisc.clickToRecipe"))); - tooltipY += 18; - } - - if (tooltipContainerStack != null) - vazkii.botania.client.core.helper.RenderHelper.renderTooltipGreen( - mx, - my + tooltipY, - Arrays.asList( - EnumChatFormatting.AQUA - + StatCollector.translateToLocal("botaniamisc.craftingContainer"), - tooltipContainerStack.getDisplayName())); - } - - tooltipStack = tooltipContainerStack = null; - tooltipEntry = false; - GL11.glDisable(GL11.GL_BLEND); - mouseDownLastTick = Mouse.isButtonDown(0); - } - - @SideOnly(Side.CLIENT) - public void renderRecipe(IGuiLexiconEntry gui, int mx, int my) { - // NO-OP - } - - @SideOnly(Side.CLIENT) - public void renderItemAtAngle(IGuiLexiconEntry gui, float angle, ItemStack stack) { - if (stack == null || stack.getItem() == null) return; - - ItemStack workStack = stack.copy(); - - if (workStack.getItemDamage() == Short.MAX_VALUE || workStack.getItemDamage() == -1) workStack.setItemDamage(0); - - angle -= 90; - int radius = 32; - double xPos = gui.getLeft() + Math.cos(angle * Math.PI / 180D) * radius + gui.getWidth() / 2 - 8; - double yPos = gui.getTop() + Math.sin(angle * Math.PI / 180D) * radius + 53; - - renderItem(gui, xPos, yPos, workStack, false); - } - - @SideOnly(Side.CLIENT) - public void renderItemAtGridPos(IGuiLexiconEntry gui, int x, int y, ItemStack stack, boolean accountForContainer) { - if (stack == null || stack.getItem() == null) return; - stack = stack.copy(); - - if (stack.getItemDamage() == Short.MAX_VALUE) stack.setItemDamage(0); - - int xPos = gui.getLeft() + x * 29 + 7 + (y == 0 && x == 3 ? 10 : 0); - int yPos = gui.getTop() + y * 29 + 24 - (y == 0 ? 7 : 0); - ItemStack stack1 = stack.copy(); - if (stack1.getItemDamage() == -1) stack1.setItemDamage(0); - - renderItem(gui, xPos, yPos, stack1, accountForContainer); - } - - @SideOnly(Side.CLIENT) - public void renderItem( - IGuiLexiconEntry gui, double xPos, double yPos, ItemStack stack, boolean accountForContainer) { - RenderItem render = new RenderItem(); - boolean mouseDown = Mouse.isButtonDown(0); - - GL11.glPushMatrix(); - GL11.glEnable(GL11.GL_BLEND); - GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); - RenderHelper.enableGUIStandardItemLighting(); - GL11.glEnable(GL12.GL_RESCALE_NORMAL); - GL11.glEnable(GL11.GL_DEPTH_TEST); - GL11.glPushMatrix(); - GL11.glTranslated(xPos, yPos, 0); - render.renderItemAndEffectIntoGUI( - Minecraft.getMinecraft().fontRenderer, Minecraft.getMinecraft().getTextureManager(), stack, 0, 0); - render.renderItemOverlayIntoGUI( - Minecraft.getMinecraft().fontRenderer, Minecraft.getMinecraft().getTextureManager(), stack, 0, 0); - GL11.glPopMatrix(); - RenderHelper.disableStandardItemLighting(); - GL11.glPopMatrix(); - - int xpi = (int) xPos; - int ypi = (int) yPos; - if (relativeMouseX >= xpi - && relativeMouseY >= ypi - && relativeMouseX <= xpi + 16 - && relativeMouseY <= ypi + 16) { - tooltipStack = stack; - - EntryData data = LexiconRecipeMappings.getDataForStack(tooltipStack); - ItemStack book = Minecraft.getMinecraft().thePlayer.getCurrentEquippedItem(); - - if (data != null - && (data.entry != gui.getEntry() || data.page != gui.getPageOn()) - && book != null - && book.getItem() instanceof ILexicon - && ((ILexicon) book.getItem()).isKnowledgeUnlocked(book, data.entry.getKnowledgeType())) { - tooltipEntry = true; - - if (!mouseDownLastTick && mouseDown && GuiScreen.isShiftKeyDown()) { - GuiLexiconEntry newGui = new GuiLexiconEntry(data.entry, (GuiScreen) gui); - newGui.page = data.page; - Minecraft.getMinecraft().displayGuiScreen(newGui); - } - } else tooltipEntry = false; - - if (accountForContainer) { - ItemStack containerStack = stack.getItem().getContainerItem(stack); - if (containerStack != null && containerStack.getItem() != null) tooltipContainerStack = containerStack; - } - } - - GL11.glDisable(GL11.GL_LIGHTING); - } - - public static List filterRecipes(List list) { - if (list == null) return new ArrayList(); - ArrayList filtered = new ArrayList(); - for (T entry : list) { - if (entry != null) filtered.add(entry); - } - return filtered; - } + int relativeMouseX, relativeMouseY; + ItemStack tooltipStack, tooltipContainerStack; + boolean tooltipEntry; + + static boolean mouseDownLastTick = false; + + public PageRecipe(String unlocalizedName) { + super(unlocalizedName); + } + + @Override + @SideOnly(Side.CLIENT) + public void renderScreen(IGuiLexiconEntry gui, int mx, int my) { + relativeMouseX = mx; + relativeMouseY = my; + + renderRecipe(gui, mx, my); + + int width = gui.getWidth() - 30; + int height = gui.getHeight(); + int x = gui.getLeft() + 16; + int y = gui.getTop() + height - 40; + PageText.renderText(x, y, width, height, getUnlocalizedName()); + + if(tooltipStack != null) { + List tooltipData = tooltipStack.getTooltip(Minecraft.getMinecraft().thePlayer, false); + List parsedTooltip = new ArrayList(); + boolean first = true; + + for(String s : tooltipData) { + String s_ = s; + if(!first) + s_ = EnumChatFormatting.GRAY + s; + parsedTooltip.add(s_); + first = false; + } + + vazkii.botania.client.core.helper.RenderHelper.renderTooltip(mx, my, parsedTooltip); + + int tooltipY = 8 + tooltipData.size() * 11; + + if(tooltipEntry) { + vazkii.botania.client.core.helper.RenderHelper.renderTooltipOrange(mx, my + tooltipY, Arrays.asList(EnumChatFormatting.GRAY + StatCollector.translateToLocal("botaniamisc.clickToRecipe"))); + tooltipY += 18; + } + + if(tooltipContainerStack != null) + vazkii.botania.client.core.helper.RenderHelper.renderTooltipGreen(mx, my + tooltipY, Arrays.asList(EnumChatFormatting.AQUA + StatCollector.translateToLocal("botaniamisc.craftingContainer"), tooltipContainerStack.getDisplayName())); + } + + tooltipStack = tooltipContainerStack = null; + tooltipEntry = false; + GL11.glDisable(GL11.GL_BLEND); + mouseDownLastTick = Mouse.isButtonDown(0); + } + + @SideOnly(Side.CLIENT) + public void renderRecipe(IGuiLexiconEntry gui, int mx, int my) { + // NO-OP + } + + @SideOnly(Side.CLIENT) + public void renderItemAtAngle(IGuiLexiconEntry gui, float angle, ItemStack stack) { + if(stack == null || stack.getItem() == null) + return; + + ItemStack workStack = stack.copy(); + + if(workStack.getItemDamage() == Short.MAX_VALUE || workStack.getItemDamage() == -1) + workStack.setItemDamage(0); + + angle -= 90; + int radius = 32; + double xPos = gui.getLeft() + Math.cos(angle * Math.PI / 180D) * radius + gui.getWidth() / 2 - 8; + double yPos = gui.getTop() + Math.sin(angle * Math.PI / 180D) * radius + 53; + + renderItem(gui, xPos, yPos, workStack, false); + } + + @SideOnly(Side.CLIENT) + public void renderItemAtGridPos(IGuiLexiconEntry gui, int x, int y, ItemStack stack, boolean accountForContainer) { + if(stack == null || stack.getItem() == null) + return; + stack = stack.copy(); + + if(stack.getItemDamage() == Short.MAX_VALUE) + stack.setItemDamage(0); + + int xPos = gui.getLeft() + x * 29 + 7 + (y == 0 && x == 3 ? 10 : 0); + int yPos = gui.getTop() + y * 29 + 24 - (y == 0 ? 7 : 0); + ItemStack stack1 = stack.copy(); + if(stack1.getItemDamage() == -1) + stack1.setItemDamage(0); + + renderItem(gui, xPos, yPos, stack1, accountForContainer); + } + + @SideOnly(Side.CLIENT) + public void renderItem(IGuiLexiconEntry gui, double xPos, double yPos, ItemStack stack, boolean accountForContainer) { + RenderItem render = new RenderItem(); + boolean mouseDown = Mouse.isButtonDown(0); + + GL11.glPushMatrix(); + GL11.glEnable(GL11.GL_BLEND); + GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); + RenderHelper.enableGUIStandardItemLighting(); + GL11.glEnable(GL12.GL_RESCALE_NORMAL); + GL11.glEnable(GL11.GL_DEPTH_TEST); + GL11.glPushMatrix(); + GL11.glTranslated(xPos, yPos, 0); + render.renderItemAndEffectIntoGUI(Minecraft.getMinecraft().fontRenderer, Minecraft.getMinecraft().getTextureManager(), stack, 0, 0); + render.renderItemOverlayIntoGUI(Minecraft.getMinecraft().fontRenderer, Minecraft.getMinecraft().getTextureManager(), stack, 0, 0); + GL11.glPopMatrix(); + RenderHelper.disableStandardItemLighting(); + GL11.glPopMatrix(); + + int xpi = (int) xPos; + int ypi = (int) yPos; + if(relativeMouseX >= xpi && relativeMouseY >= ypi && relativeMouseX <= xpi + 16 && relativeMouseY <= ypi + 16) { + tooltipStack = stack; + + EntryData data = LexiconRecipeMappings.getDataForStack(tooltipStack); + ItemStack book = Minecraft.getMinecraft().thePlayer.getCurrentEquippedItem(); + + if(data != null && (data.entry != gui.getEntry() || data.page != gui.getPageOn()) && book != null && book.getItem() instanceof ILexicon && ((ILexicon) book.getItem()).isKnowledgeUnlocked(book, data.entry.getKnowledgeType())) { + tooltipEntry = true; + + if(!mouseDownLastTick && mouseDown && GuiScreen.isShiftKeyDown()) { + GuiLexiconEntry newGui = new GuiLexiconEntry(data.entry, (GuiScreen) gui); + newGui.page = data.page; + Minecraft.getMinecraft().displayGuiScreen(newGui); + } + } else tooltipEntry = false; + + if(accountForContainer) { + ItemStack containerStack = stack.getItem().getContainerItem(stack); + if(containerStack != null && containerStack.getItem() != null) + tooltipContainerStack = containerStack; + } + } + + GL11.glDisable(GL11.GL_LIGHTING); + } + + public static List filterRecipes(List list) { + if (list == null) return new ArrayList(); + ArrayList filtered = new ArrayList(); + for (T entry: list) { + if (entry != null) filtered.add(entry); + } + return filtered; + } + } diff --git a/src/main/java/vazkii/botania/common/lexicon/page/PageRuneRecipe.java b/src/main/java/vazkii/botania/common/lexicon/page/PageRuneRecipe.java index e0d446acae..752cd4190e 100644 --- a/src/main/java/vazkii/botania/common/lexicon/page/PageRuneRecipe.java +++ b/src/main/java/vazkii/botania/common/lexicon/page/PageRuneRecipe.java @@ -2,72 +2,73 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Feb 8, 2014, 1:11:48 PM (GMT)] */ package vazkii.botania.common.lexicon.page; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; import java.util.List; + import net.minecraft.client.Minecraft; import net.minecraft.client.gui.FontRenderer; import net.minecraft.item.ItemStack; import net.minecraft.util.StatCollector; + import org.lwjgl.opengl.GL11; + import vazkii.botania.api.internal.IGuiLexiconEntry; import vazkii.botania.api.recipe.RecipeRuneAltar; import vazkii.botania.client.core.handler.HUDHandler; import vazkii.botania.common.block.ModBlocks; import vazkii.botania.common.block.tile.mana.TilePool; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; public class PageRuneRecipe extends PagePetalRecipe { - public PageRuneRecipe(String unlocalizedName, List recipes) { - super(unlocalizedName, recipes); - } + public PageRuneRecipe(String unlocalizedName, List recipes) { + super(unlocalizedName, recipes); + } + + public PageRuneRecipe(String unlocalizedName, RecipeRuneAltar recipes) { + super(unlocalizedName, recipes); + } - public PageRuneRecipe(String unlocalizedName, RecipeRuneAltar recipes) { - super(unlocalizedName, recipes); - } + @Override + ItemStack getMiddleStack() { + return new ItemStack(ModBlocks.runeAltar); + } - @Override - ItemStack getMiddleStack() { - return new ItemStack(ModBlocks.runeAltar); - } + @Override + @SideOnly(Side.CLIENT) + public void renderManaBar(IGuiLexiconEntry gui, RecipeRuneAltar recipe, int mx, int my) { + FontRenderer font = Minecraft.getMinecraft().fontRenderer; + GL11.glEnable(GL11.GL_BLEND); + GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); + String manaUsage = StatCollector.translateToLocal("botaniamisc.manaUsage"); + font.drawString(manaUsage, gui.getLeft() + gui.getWidth() / 2 - font.getStringWidth(manaUsage) / 2, gui.getTop() + 110, 0x66000000); - @Override - @SideOnly(Side.CLIENT) - public void renderManaBar(IGuiLexiconEntry gui, RecipeRuneAltar recipe, int mx, int my) { - FontRenderer font = Minecraft.getMinecraft().fontRenderer; - GL11.glEnable(GL11.GL_BLEND); - GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); - String manaUsage = StatCollector.translateToLocal("botaniamisc.manaUsage"); - font.drawString( - manaUsage, - gui.getLeft() + gui.getWidth() / 2 - font.getStringWidth(manaUsage) / 2, - gui.getTop() + 110, - 0x66000000); + int ratio = 10; + int x = gui.getLeft() + gui.getWidth() / 2 - 50; + int y = gui.getTop() + 120; - int ratio = 10; - int x = gui.getLeft() + gui.getWidth() / 2 - 50; - int y = gui.getTop() + 120; + if(mx > x + 1 && mx <= x + 101 && my > y - 14 && my <= y + 11) + ratio = 1; - if (mx > x + 1 && mx <= x + 101 && my > y - 14 && my <= y + 11) ratio = 1; + HUDHandler.renderManaBar(x, y, 0x0000FF, 0.75F, recipe.getManaUsage(), TilePool.MAX_MANA / ratio); - HUDHandler.renderManaBar(x, y, 0x0000FF, 0.75F, recipe.getManaUsage(), TilePool.MAX_MANA / ratio); + String ratioString = String.format(StatCollector.translateToLocal("botaniamisc.ratio"), ratio); + String stopStr = StatCollector.translateToLocal("botaniamisc.shiftToStopSpin"); - String ratioString = String.format(StatCollector.translateToLocal("botaniamisc.ratio"), ratio); - String stopStr = StatCollector.translateToLocal("botaniamisc.shiftToStopSpin"); + boolean unicode = font.getUnicodeFlag(); + font.setUnicodeFlag(true); + font.drawString(stopStr, x + 50 - font.getStringWidth(stopStr) / 2, y + 15, 0x99000000); + font.drawString(ratioString, x + 50 - font.getStringWidth(ratioString) / 2, y + 5, 0x99000000); + font.setUnicodeFlag(unicode); + GL11.glDisable(GL11.GL_BLEND); + } - boolean unicode = font.getUnicodeFlag(); - font.setUnicodeFlag(true); - font.drawString(stopStr, x + 50 - font.getStringWidth(stopStr) / 2, y + 15, 0x99000000); - font.drawString(ratioString, x + 50 - font.getStringWidth(ratioString) / 2, y + 5, 0x99000000); - font.setUnicodeFlag(unicode); - GL11.glDisable(GL11.GL_BLEND); - } } diff --git a/src/main/java/vazkii/botania/common/lexicon/page/PageShedding.java b/src/main/java/vazkii/botania/common/lexicon/page/PageShedding.java index f85e47cf03..7ba683c6de 100644 --- a/src/main/java/vazkii/botania/common/lexicon/page/PageShedding.java +++ b/src/main/java/vazkii/botania/common/lexicon/page/PageShedding.java @@ -2,19 +2,18 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jul 4, 2014, 10:38:50 PM (GMT)] */ package vazkii.botania.common.lexicon.page; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; import java.util.ArrayList; import java.util.Arrays; import java.util.List; + import net.minecraft.client.Minecraft; import net.minecraft.client.gui.GuiScreen; import net.minecraft.client.renderer.RenderHelper; @@ -26,134 +25,131 @@ import net.minecraft.util.MathHelper; import net.minecraft.util.ResourceLocation; import net.minecraft.util.StatCollector; + import org.lwjgl.input.Mouse; import org.lwjgl.opengl.GL11; import org.lwjgl.opengl.GL12; + import vazkii.botania.api.internal.IGuiLexiconEntry; import vazkii.botania.api.lexicon.LexiconRecipeMappings; import vazkii.botania.api.lexicon.LexiconRecipeMappings.EntryData; import vazkii.botania.client.gui.lexicon.GuiLexiconEntry; import vazkii.botania.client.lib.LibResources; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; public class PageShedding extends PageEntity { - private static final ResourceLocation sheddingOverlay = new ResourceLocation(LibResources.GUI_SHEDDING_OVERLAY); - - ItemStack shedStack; - ItemStack tooltipStack; - boolean tooltipEntry; - - static boolean mouseDownLastTick = false; - - public PageShedding(String unlocalizedName, String entity, int size, ItemStack shedStack) { - super(unlocalizedName, entity, size); - this.shedStack = shedStack; - } - - @Override - @SideOnly(Side.CLIENT) - public void renderScreen(IGuiLexiconEntry gui, int mx, int my) { - prepDummy(); - relativeMouseX = mx; - relativeMouseY = my; - int stack_x = gui.getLeft() + gui.getWidth() / 2 - 8; - int stack_y = gui.getTop() + gui.getHeight() - 40 - 18 - 5; - int entity_scale = getEntityScale(size); - int entity_x = gui.getLeft() + gui.getWidth() / 2; - int entity_y = - gui.getTop() + gui.getHeight() / 2 + MathHelper.floor_float(dummyEntity.height * entity_scale / 2) - 29; - - renderEntity(gui, dummyEntity, entity_x, entity_y, entity_scale, dummyEntity.ticksExisted * 2); - - renderItem(gui, stack_x, stack_y, shedStack); - - TextureManager render = Minecraft.getMinecraft().renderEngine; - render.bindTexture(sheddingOverlay); - - GL11.glEnable(GL11.GL_BLEND); - GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); - GL11.glColor4f(1F, 1F, 1F, 1F); - ((GuiScreen) gui).drawTexturedModalRect(gui.getLeft(), gui.getTop(), 0, 0, gui.getWidth(), gui.getHeight()); - - if (tooltipStack != null) { - List tooltipData = tooltipStack.getTooltip(Minecraft.getMinecraft().thePlayer, false); - List parsedTooltip = new ArrayList(); - boolean first = true; - - for (String s : tooltipData) { - String s_ = s; - if (!first) s_ = EnumChatFormatting.GRAY + s; - parsedTooltip.add(s_); - first = false; - } - - vazkii.botania.client.core.helper.RenderHelper.renderTooltip(mx, my, parsedTooltip); - - int tooltipY = 8 + tooltipData.size() * 11; - - if (tooltipEntry) { - vazkii.botania.client.core.helper.RenderHelper.renderTooltipOrange( - mx, - my + tooltipY, - Arrays.asList( - EnumChatFormatting.GRAY + StatCollector.translateToLocal("botaniamisc.clickToRecipe"))); - tooltipY += 18; - } - } else if (tooltipEntity) { - List parsedTooltip = new ArrayList(); - parsedTooltip.add(EntityList.getEntityString(dummyEntity)); - vazkii.botania.client.core.helper.RenderHelper.renderTooltip(mx, my, parsedTooltip); - } - - tooltipStack = null; - tooltipEntry = tooltipEntity = false; - GL11.glDisable(GL11.GL_BLEND); - mouseDownLastTick = Mouse.isButtonDown(0); - } - - @SideOnly(Side.CLIENT) - public void renderItem(IGuiLexiconEntry gui, int xPos, int yPos, ItemStack stack) { - RenderItem render = new RenderItem(); - boolean mouseDown = Mouse.isButtonDown(0); - - GL11.glPushMatrix(); - GL11.glEnable(GL11.GL_BLEND); - GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); - RenderHelper.enableGUIStandardItemLighting(); - GL11.glEnable(GL12.GL_RESCALE_NORMAL); - GL11.glEnable(GL11.GL_DEPTH_TEST); - render.renderItemAndEffectIntoGUI( - Minecraft.getMinecraft().fontRenderer, Minecraft.getMinecraft().getTextureManager(), stack, xPos, yPos); - render.renderItemOverlayIntoGUI( - Minecraft.getMinecraft().fontRenderer, Minecraft.getMinecraft().getTextureManager(), stack, xPos, yPos); - RenderHelper.disableStandardItemLighting(); - GL11.glPopMatrix(); - - if (relativeMouseX >= xPos - && relativeMouseY >= yPos - && relativeMouseX <= xPos + 16 - && relativeMouseY <= yPos + 16) { - tooltipStack = stack; - - EntryData data = LexiconRecipeMappings.getDataForStack(tooltipStack); - if (data != null && (data.entry != gui.getEntry() || data.page != gui.getPageOn())) { - tooltipEntry = true; - - if (!mouseDownLastTick && mouseDown && GuiScreen.isShiftKeyDown()) { - GuiLexiconEntry newGui = new GuiLexiconEntry(data.entry, (GuiScreen) gui); - newGui.page = data.page; - Minecraft.getMinecraft().displayGuiScreen(newGui); - } - } - } - - GL11.glDisable(GL11.GL_LIGHTING); - } - - @Override - public List getDisplayedRecipes() { - ArrayList list = new ArrayList(); - list.add(shedStack); - return list; - } + private static final ResourceLocation sheddingOverlay = new ResourceLocation(LibResources.GUI_SHEDDING_OVERLAY); + + ItemStack shedStack; + ItemStack tooltipStack; + boolean tooltipEntry; + + static boolean mouseDownLastTick = false; + + public PageShedding(String unlocalizedName, String entity, int size, ItemStack shedStack) { + super(unlocalizedName, entity, size); + this.shedStack = shedStack; + } + + @Override + @SideOnly(Side.CLIENT) + public void renderScreen(IGuiLexiconEntry gui, int mx, int my) { + prepDummy(); + relativeMouseX = mx; + relativeMouseY = my; + int stack_x = gui.getLeft() + gui.getWidth() / 2 - 8; + int stack_y = gui.getTop() + gui.getHeight() - 40 - 18 - 5; + int entity_scale = getEntityScale(size); + int entity_x = gui.getLeft() + gui.getWidth() / 2; + int entity_y = gui.getTop() + gui.getHeight() / 2 + MathHelper.floor_float(dummyEntity.height * entity_scale / 2) - 29; + + renderEntity(gui, dummyEntity, entity_x, entity_y, entity_scale, dummyEntity.ticksExisted * 2); + + renderItem(gui, stack_x, stack_y, shedStack); + + TextureManager render = Minecraft.getMinecraft().renderEngine; + render.bindTexture(sheddingOverlay); + + GL11.glEnable(GL11.GL_BLEND); + GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); + GL11.glColor4f(1F, 1F, 1F, 1F); + ((GuiScreen) gui).drawTexturedModalRect(gui.getLeft(), gui.getTop(), 0, 0, gui.getWidth(), gui.getHeight()); + + if(tooltipStack != null) { + List tooltipData = tooltipStack.getTooltip(Minecraft.getMinecraft().thePlayer, false); + List parsedTooltip = new ArrayList(); + boolean first = true; + + for(String s : tooltipData) { + String s_ = s; + if(!first) + s_ = EnumChatFormatting.GRAY + s; + parsedTooltip.add(s_); + first = false; + } + + vazkii.botania.client.core.helper.RenderHelper.renderTooltip(mx, my, parsedTooltip); + + int tooltipY = 8 + tooltipData.size() * 11; + + if(tooltipEntry) { + vazkii.botania.client.core.helper.RenderHelper.renderTooltipOrange(mx, my + tooltipY, Arrays.asList(EnumChatFormatting.GRAY + StatCollector.translateToLocal("botaniamisc.clickToRecipe"))); + tooltipY += 18; + } + } + else if(tooltipEntity) { + List parsedTooltip = new ArrayList(); + parsedTooltip.add(EntityList.getEntityString(dummyEntity)); + vazkii.botania.client.core.helper.RenderHelper.renderTooltip(mx, my, parsedTooltip); + } + + tooltipStack = null; + tooltipEntry = tooltipEntity = false; + GL11.glDisable(GL11.GL_BLEND); + mouseDownLastTick = Mouse.isButtonDown(0); + } + + @SideOnly(Side.CLIENT) + public void renderItem(IGuiLexiconEntry gui, int xPos, int yPos, ItemStack stack) { + RenderItem render = new RenderItem(); + boolean mouseDown = Mouse.isButtonDown(0); + + GL11.glPushMatrix(); + GL11.glEnable(GL11.GL_BLEND); + GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); + RenderHelper.enableGUIStandardItemLighting(); + GL11.glEnable(GL12.GL_RESCALE_NORMAL); + GL11.glEnable(GL11.GL_DEPTH_TEST); + render.renderItemAndEffectIntoGUI(Minecraft.getMinecraft().fontRenderer, Minecraft.getMinecraft().getTextureManager(), stack, xPos, yPos); + render.renderItemOverlayIntoGUI(Minecraft.getMinecraft().fontRenderer, Minecraft.getMinecraft().getTextureManager(), stack, xPos, yPos); + RenderHelper.disableStandardItemLighting(); + GL11.glPopMatrix(); + + if(relativeMouseX >= xPos && relativeMouseY >= yPos && relativeMouseX <= xPos + 16 && relativeMouseY <= yPos + 16) { + tooltipStack = stack; + + EntryData data = LexiconRecipeMappings.getDataForStack(tooltipStack); + if(data != null && (data.entry != gui.getEntry() || data.page != gui.getPageOn())) { + tooltipEntry = true; + + if(!mouseDownLastTick && mouseDown && GuiScreen.isShiftKeyDown()) { + GuiLexiconEntry newGui = new GuiLexiconEntry(data.entry, (GuiScreen) gui); + newGui.page = data.page; + Minecraft.getMinecraft().displayGuiScreen(newGui); + } + } + } + + GL11.glDisable(GL11.GL_LIGHTING); + } + + @Override + public List getDisplayedRecipes() { + ArrayList list = new ArrayList(); + list.add(shedStack); + return list; + } + } diff --git a/src/main/java/vazkii/botania/common/lexicon/page/PageTerrasteel.java b/src/main/java/vazkii/botania/common/lexicon/page/PageTerrasteel.java index 580cedb7de..8f9d313ea8 100644 --- a/src/main/java/vazkii/botania/common/lexicon/page/PageTerrasteel.java +++ b/src/main/java/vazkii/botania/common/lexicon/page/PageTerrasteel.java @@ -2,113 +2,97 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Apr 14, 2014, 5:57:26 PM (GMT)] */ package vazkii.botania.common.lexicon.page; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; import java.util.ArrayList; import java.util.List; + import net.minecraft.block.Block; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.GuiScreen; import net.minecraft.init.Blocks; import net.minecraft.item.ItemStack; import net.minecraft.util.ResourceLocation; + import org.lwjgl.opengl.GL11; + import vazkii.botania.api.internal.IGuiLexiconEntry; import vazkii.botania.api.lexicon.LexiconEntry; import vazkii.botania.api.lexicon.LexiconRecipeMappings; import vazkii.botania.client.lib.LibResources; import vazkii.botania.common.block.ModBlocks; import vazkii.botania.common.item.ModItems; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; public class PageTerrasteel extends PageRecipe { - private static final ResourceLocation terrasteelOverlay = new ResourceLocation(LibResources.GUI_TERRASTEEL_OVERLAY); - - public PageTerrasteel(String unlocalizedName) { - super(unlocalizedName); - } - - @Override - @SideOnly(Side.CLIENT) - public void renderRecipe(IGuiLexiconEntry gui, int mx, int my) { - Block block1 = ModBlocks.livingrock; - Block block2 = Blocks.lapis_block; - Block block3 = ModBlocks.terraPlate; - - GL11.glTranslatef(0F, 0F, -10F); - renderItem(gui, gui.getLeft() + gui.getWidth() / 2 - 8, gui.getTop() + 103, new ItemStack(block1), false); - - GL11.glTranslatef(0F, 0F, 5F); - renderItem(gui, gui.getLeft() + gui.getWidth() / 2 - 8 + 7, gui.getTop() + 106, new ItemStack(block2), false); - renderItem(gui, gui.getLeft() + gui.getWidth() / 2 - 8 - 6, gui.getTop() + 106, new ItemStack(block2), false); - - GL11.glTranslatef(0F, 0F, 5F); - renderItem(gui, gui.getLeft() + gui.getWidth() / 2 - 8, gui.getTop() + 110, new ItemStack(block1), false); - renderItem(gui, gui.getLeft() + gui.getWidth() / 2 - 8 + 14, gui.getTop() + 110, new ItemStack(block1), false); - renderItem(gui, gui.getLeft() + gui.getWidth() / 2 - 8 - 13, gui.getTop() + 110, new ItemStack(block1), false); - - GL11.glTranslatef(0F, 0F, 5F); - renderItem(gui, gui.getLeft() + gui.getWidth() / 2 - 8 - 6, gui.getTop() + 114, new ItemStack(block2), false); - renderItem(gui, gui.getLeft() + gui.getWidth() / 2 - 8 + 7, gui.getTop() + 114, new ItemStack(block2), false); - - GL11.glTranslatef(0F, 0F, 5F); - renderItem(gui, gui.getLeft() + gui.getWidth() / 2 - 8 + 1, gui.getTop() + 117, new ItemStack(block1), false); - - GL11.glTranslatef(0F, 0F, 5F); - renderItem(gui, gui.getLeft() + gui.getWidth() / 2 - 8, gui.getTop() + 102, new ItemStack(block3), false); - GL11.glTranslatef(0F, 0F, -10F); - - renderItem( - gui, - gui.getLeft() + gui.getWidth() / 2 - 8, - gui.getTop() + 30, - new ItemStack(ModItems.manaResource, 1, 4), - false); - renderItem( - gui, - gui.getLeft() + gui.getWidth() / 2 - 8, - gui.getTop() + 80, - new ItemStack(ModItems.manaResource, 1, 0), - false); - renderItem( - gui, - gui.getLeft() + gui.getWidth() / 2 - 8 - 20, - gui.getTop() + 86, - new ItemStack(ModItems.manaResource, 1, 1), - false); - renderItem( - gui, - gui.getLeft() + gui.getWidth() / 2 - 8 + 19, - gui.getTop() + 86, - new ItemStack(ModItems.manaResource, 1, 2), - false); - - Minecraft.getMinecraft().renderEngine.bindTexture(terrasteelOverlay); - - GL11.glEnable(GL11.GL_BLEND); - GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); - GL11.glColor4f(1F, 1F, 1F, 1F); - ((GuiScreen) gui).drawTexturedModalRect(gui.getLeft(), gui.getTop(), 0, 0, gui.getWidth(), gui.getHeight()); - GL11.glDisable(GL11.GL_BLEND); - } - - @Override - public void onPageAdded(LexiconEntry entry, int index) { - LexiconRecipeMappings.map(new ItemStack(ModItems.manaResource, 1, 4), entry, index); - } - - @Override - public List getDisplayedRecipes() { - ArrayList list = new ArrayList(); - list.add(new ItemStack(ModItems.manaResource, 1, 4)); - return list; - } + private static final ResourceLocation terrasteelOverlay = new ResourceLocation(LibResources.GUI_TERRASTEEL_OVERLAY); + + public PageTerrasteel(String unlocalizedName) { + super(unlocalizedName); + } + + @Override + @SideOnly(Side.CLIENT) + public void renderRecipe(IGuiLexiconEntry gui, int mx, int my) { + Block block1 = ModBlocks.livingrock; + Block block2 = Blocks.lapis_block; + Block block3 = ModBlocks.terraPlate; + + GL11.glTranslatef(0F, 0F, -10F); + renderItem(gui, gui.getLeft() + gui.getWidth() / 2 - 8, gui.getTop() + 103, new ItemStack(block1), false); + + GL11.glTranslatef(0F, 0F, 5F); + renderItem(gui, gui.getLeft() + gui.getWidth() / 2 - 8 + 7, gui.getTop() + 106, new ItemStack(block2), false); + renderItem(gui, gui.getLeft() + gui.getWidth() / 2 - 8 - 6, gui.getTop() + 106, new ItemStack(block2), false); + + GL11.glTranslatef(0F, 0F, 5F); + renderItem(gui, gui.getLeft() + gui.getWidth() / 2 - 8, gui.getTop() + 110, new ItemStack(block1), false); + renderItem(gui, gui.getLeft() + gui.getWidth() / 2 - 8 + 14, gui.getTop() + 110, new ItemStack(block1), false); + renderItem(gui, gui.getLeft() + gui.getWidth() / 2 - 8 - 13, gui.getTop() + 110, new ItemStack(block1), false); + + GL11.glTranslatef(0F, 0F, 5F); + renderItem(gui, gui.getLeft() + gui.getWidth() / 2 - 8 - 6, gui.getTop() + 114, new ItemStack(block2), false); + renderItem(gui, gui.getLeft() + gui.getWidth() / 2 - 8 + 7, gui.getTop() + 114, new ItemStack(block2), false); + + GL11.glTranslatef(0F, 0F, 5F); + renderItem(gui, gui.getLeft() + gui.getWidth() / 2 - 8 + 1, gui.getTop() + 117, new ItemStack(block1), false); + + GL11.glTranslatef(0F, 0F, 5F); + renderItem(gui, gui.getLeft() + gui.getWidth() / 2 - 8, gui.getTop() + 102, new ItemStack(block3), false); + GL11.glTranslatef(0F, 0F, -10F); + + renderItem(gui, gui.getLeft() + gui.getWidth() / 2 - 8, gui.getTop() + 30, new ItemStack(ModItems.manaResource, 1, 4), false); + renderItem(gui, gui.getLeft() + gui.getWidth() / 2 - 8, gui.getTop() + 80, new ItemStack(ModItems.manaResource, 1, 0), false); + renderItem(gui, gui.getLeft() + gui.getWidth() / 2 - 8 - 20, gui.getTop() + 86, new ItemStack(ModItems.manaResource, 1, 1), false); + renderItem(gui, gui.getLeft() + gui.getWidth() / 2 - 8 + 19, gui.getTop() + 86, new ItemStack(ModItems.manaResource, 1, 2), false); + + Minecraft.getMinecraft().renderEngine.bindTexture(terrasteelOverlay); + + GL11.glEnable(GL11.GL_BLEND); + GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); + GL11.glColor4f(1F, 1F, 1F, 1F); + ((GuiScreen) gui).drawTexturedModalRect(gui.getLeft(), gui.getTop(), 0, 0, gui.getWidth(), gui.getHeight()); + GL11.glDisable(GL11.GL_BLEND); + } + + @Override + public void onPageAdded(LexiconEntry entry, int index) { + LexiconRecipeMappings.map(new ItemStack(ModItems.manaResource, 1, 4), entry, index); + } + + @Override + public List getDisplayedRecipes() { + ArrayList list = new ArrayList(); + list.add(new ItemStack(ModItems.manaResource, 1, 4)); + return list; + } + } diff --git a/src/main/java/vazkii/botania/common/lexicon/page/PageText.java b/src/main/java/vazkii/botania/common/lexicon/page/PageText.java index 73d2efdbba..a9a2214458 100644 --- a/src/main/java/vazkii/botania/common/lexicon/page/PageText.java +++ b/src/main/java/vazkii/botania/common/lexicon/page/PageText.java @@ -2,19 +2,17 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jan 14, 2014, 6:45:33 PM (GMT)] */ package vazkii.botania.common.lexicon.page; -import com.google.common.base.Joiner; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; import java.util.ArrayList; import java.util.List; + import net.minecraft.client.Minecraft; import net.minecraft.client.gui.FontRenderer; import net.minecraft.util.StatCollector; @@ -22,109 +20,113 @@ import vazkii.botania.api.lexicon.LexiconPage; import vazkii.botania.common.core.handler.ConfigHandler; +import com.google.common.base.Joiner; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + public class PageText extends LexiconPage { - public PageText(String unlocalizedName) { - super(unlocalizedName); - } - - @Override - @SideOnly(Side.CLIENT) - public void renderScreen(IGuiLexiconEntry gui, int mx, int my) { - int width = gui.getWidth() - 30; - int x = gui.getLeft() + 16; - int y = gui.getTop() + 2; - - renderText(x, y, width, gui.getHeight(), getUnlocalizedName()); - } - - public static void renderText(int x, int y, int width, int height, String unlocalizedText) { - renderText(x, y, width, height, 10, unlocalizedText); - } - - @SideOnly(Side.CLIENT) - public static void renderText(int x, int y, int width, int height, int paragraphSize, String unlocalizedText) { - x += 2; - y += 10; - width -= 4; - - FontRenderer font = Minecraft.getMinecraft().fontRenderer; - boolean unicode = font.getUnicodeFlag(); - font.setUnicodeFlag(true); - String text = StatCollector.translateToLocal(unlocalizedText).replaceAll("&", "\u00a7"); - String[] textEntries = text.split("
"); - - List> lines = new ArrayList(); - - String controlCodes = ""; - for (String s : textEntries) { - List words = new ArrayList(); - String lineStr = ""; - String[] tokens = s.split(" "); - for (String token : tokens) { - String prev = lineStr; - String spaced = token + " "; - lineStr += spaced; - - controlCodes = toControlCodes(getControlCodes(prev)); - if (font.getStringWidth(lineStr) > width) { - lines.add(words); - lineStr = controlCodes + spaced; - words = new ArrayList(); - } - - words.add(controlCodes + token); - } - - if (!lineStr.isEmpty()) lines.add(words); - lines.add(new ArrayList()); - } - - int i = 0; - for (List words : lines) { - words.size(); - int xi = x; - int spacing = 4; - int wcount = words.size(); - int compensationSpaces = 0; - boolean justify = ConfigHandler.lexiconJustifiedText - && wcount > 0 - && lines.size() > i - && !lines.get(i + 1).isEmpty(); - - if (justify) { - String s = Joiner.on("").join(words); - int swidth = font.getStringWidth(s); - int space = width - swidth; - - spacing = wcount == 1 ? 0 : space / (wcount - 1); - compensationSpaces = wcount == 1 ? 0 : space % (wcount - 1); - } - - for (String s : words) { - int extra = 0; - if (compensationSpaces > 0) { - compensationSpaces--; - extra++; - } - font.drawString(s, xi, y, 0); - xi += font.getStringWidth(s) + spacing + extra; - } - - y += words.isEmpty() ? paragraphSize : 10; - i++; - } - - font.setUnicodeFlag(unicode); - } - - public static String getControlCodes(String s) { - String controls = s.replaceAll("(?"); + + List> lines = new ArrayList(); + + String controlCodes = ""; + for(String s : textEntries) { + List words = new ArrayList(); + String lineStr = ""; + String[] tokens = s.split(" "); + for(String token : tokens) { + String prev = lineStr; + String spaced = token + " "; + lineStr += spaced; + + controlCodes = toControlCodes(getControlCodes(prev)); + if(font.getStringWidth(lineStr) > width) { + lines.add(words); + lineStr = controlCodes + spaced; + words = new ArrayList(); + } + + words.add(controlCodes + token); + } + + if(!lineStr.isEmpty()) + lines.add(words); + lines.add(new ArrayList()); + } + + int i = 0; + for(List words : lines) { + words.size(); + int xi = x; + int spacing = 4; + int wcount = words.size(); + int compensationSpaces = 0; + boolean justify = ConfigHandler.lexiconJustifiedText && wcount > 0 && lines.size() > i && !lines.get(i + 1).isEmpty(); + + if(justify) { + String s = Joiner.on("").join(words); + int swidth = font.getStringWidth(s); + int space = width - swidth; + + spacing = wcount == 1 ? 0 : space / (wcount - 1); + compensationSpaces = wcount == 1 ? 0 : space % (wcount - 1); + } + + for(String s : words) { + int extra = 0; + if(compensationSpaces > 0) { + compensationSpaces--; + extra++; + } + font.drawString(s, xi, y, 0); + xi += font.getStringWidth(s) + spacing + extra; + } + + y += words.isEmpty() ? paragraphSize : 10; + i++; + } + + font.setUnicodeFlag(unicode); + } + + public static String getControlCodes(String s) { + String controls = s.replaceAll("(?. It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Feb 16, 2015, 1:39:10 PM (GMT)] */ package vazkii.botania.common.lexicon.page; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; import java.awt.Desktop; import java.net.URI; + import net.minecraft.client.Minecraft; import net.minecraft.client.gui.GuiButton; import net.minecraft.util.ChatComponentTranslation; @@ -22,75 +21,60 @@ import net.minecraft.util.StatCollector; import vazkii.botania.api.internal.IGuiLexiconEntry; import vazkii.botania.client.gui.lexicon.GuiLexicon; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; public class PageTutorial extends PageText { - // Turn this on once we have an up to date video - private static final boolean VIDEO_ENABLED = false; + // Turn this on once we have an up to date video + private static final boolean VIDEO_ENABLED = false; + + GuiButton buttonText, buttonVideo; - GuiButton buttonText, buttonVideo; + public PageTutorial(String unlocalizedName) { + super(unlocalizedName); + } - public PageTutorial(String unlocalizedName) { - super(unlocalizedName); - } + @Override + public void onOpened(IGuiLexiconEntry gui) { + buttonText = new GuiButton(101, gui.getLeft() + 20, gui.getTop() + gui.getHeight() - 40, 50, 20, StatCollector.translateToLocal("botaniamisc.tutorialText")); + if(VIDEO_ENABLED) + buttonVideo = new GuiButton(101, gui.getLeft() + 75, gui.getTop() + gui.getHeight() - 40, 50, 20, StatCollector.translateToLocal("botaniamisc.tutorialVideo")); - @Override - public void onOpened(IGuiLexiconEntry gui) { - buttonText = new GuiButton( - 101, - gui.getLeft() + 20, - gui.getTop() + gui.getHeight() - 40, - 50, - 20, - StatCollector.translateToLocal("botaniamisc.tutorialText")); - if (VIDEO_ENABLED) - buttonVideo = new GuiButton( - 101, - gui.getLeft() + 75, - gui.getTop() + gui.getHeight() - 40, - 50, - 20, - StatCollector.translateToLocal("botaniamisc.tutorialVideo")); + gui.getButtonList().add(buttonText); + if(VIDEO_ENABLED) + gui.getButtonList().add(buttonVideo); + } - gui.getButtonList().add(buttonText); - if (VIDEO_ENABLED) gui.getButtonList().add(buttonVideo); - } + @Override + public void onClosed(IGuiLexiconEntry gui) { + gui.getButtonList().remove(buttonText); + if(VIDEO_ENABLED) + gui.getButtonList().remove(buttonVideo); + } - @Override - public void onClosed(IGuiLexiconEntry gui) { - gui.getButtonList().remove(buttonText); - if (VIDEO_ENABLED) gui.getButtonList().remove(buttonVideo); - } + @Override + public void renderScreen(IGuiLexiconEntry gui, int mx, int my) { + super.renderScreen(gui, mx, my); - @Override - public void renderScreen(IGuiLexiconEntry gui, int mx, int my) { - super.renderScreen(gui, mx, my); + if(!VIDEO_ENABLED) + PageText.renderText(buttonText.xPosition + buttonText.width + 4, buttonText.yPosition - 14, 65, 100, "botaniamisc.noVideo"); + } - if (!VIDEO_ENABLED) - PageText.renderText( - buttonText.xPosition + buttonText.width + 4, - buttonText.yPosition - 14, - 65, - 100, - "botaniamisc.noVideo"); - } + @Override + @SideOnly(Side.CLIENT) + public void onActionPerformed(IGuiLexiconEntry gui, GuiButton button) { + if(button == buttonText) { + GuiLexicon.startTutorial(); + Minecraft.getMinecraft().displayGuiScreen(new GuiLexicon()); + Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentTranslation("botaniamisc.tutorialStarted").setChatStyle(new ChatStyle().setColor(EnumChatFormatting.GREEN))); + } else if(button == buttonVideo && Desktop.isDesktopSupported()) { + try { + Desktop.getDesktop().browse(new URI("https://www.youtube.com/watch?v=rx0xyejC6fI")); + } catch(Exception e) { + e.printStackTrace(); + } + } + } - @Override - @SideOnly(Side.CLIENT) - public void onActionPerformed(IGuiLexiconEntry gui, GuiButton button) { - if (button == buttonText) { - GuiLexicon.startTutorial(); - Minecraft.getMinecraft().displayGuiScreen(new GuiLexicon()); - Minecraft.getMinecraft() - .thePlayer - .addChatMessage(new ChatComponentTranslation("botaniamisc.tutorialStarted") - .setChatStyle(new ChatStyle().setColor(EnumChatFormatting.GREEN))); - } else if (button == buttonVideo && Desktop.isDesktopSupported()) { - try { - Desktop.getDesktop().browse(new URI("https://www.youtube.com/watch?v=rx0xyejC6fI")); - } catch (Exception e) { - e.printStackTrace(); - } - } - } } diff --git a/src/main/java/vazkii/botania/common/lib/LibAchievementNames.java b/src/main/java/vazkii/botania/common/lib/LibAchievementNames.java index 1387b9ffdd..5372b364dd 100644 --- a/src/main/java/vazkii/botania/common/lib/LibAchievementNames.java +++ b/src/main/java/vazkii/botania/common/lib/LibAchievementNames.java @@ -2,66 +2,67 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jan 28, 2015, 4:44:34 PM (GMT)] */ package vazkii.botania.common.lib; public final class LibAchievementNames { - public static final String FLOWER_PICKUP = "flowerPickup"; - public static final String LEXICON_USE = "lexiconUse"; - public static final String DAYBLOOM_PICKUP = "daybloomPickup"; - public static final String MANA_POOL_PICKUP = "manaPoolPickup"; - public static final String ENDOFLAME_PICKUP = "endoflamePickup"; - public static final String TINY_POTATO_PET = "tinyPotatoPet"; - public static final String SPARK_CRAFT = "sparkCraft"; - public static final String BAUBLE_WEAR = "baubleWear"; - public static final String MANA_COOKIE_EAT = "manaCookieEat"; - public static final String RUNE_PICKUP = "runePickup"; - public static final String MANA_BLASTER_SHOOT = "manaBlasterShoot"; - public static final String TIARA_WINGS = "tiaraWings"; - public static final String TERRASTEEL_PICKUP = "terrasteelPickup"; - public static final String ELF_PORTAL_OPEN = "elfPortalOpen"; - public static final String GAIA_GUARDIAN_KILL = "gaiaGuardianKill"; - public static final String TERRASTEEL_WEAPON_CRAFT = "terrasteelWeaponCraft"; - public static final String KEKIMURUS_PICKUP = "kekimurusPickup"; - public static final String HEISEI_DREAM_PICKUP = "heiseiDreamPickup"; - public static final String DIRT_ROD_CRAFT = "dirtRodCraft"; - public static final String SPAWNER_MOVER_USE = "spawnerMoverUse"; - public static final String ENDER_AIR_MAKE = "enderAirMake"; - public static final String CORPOREA_CRAFT = "corporeaCraft"; - public static final String CACOPHONIUM_CRAFT = "cacophoniumCraft"; - public static final String MANA_CART_CRAFT = "manaCartCraft"; - public static final String CRAFTING_HALO_CRAFT = "craftingHaloCraft"; - public static final String MANAWEAVE_ARMOR_CRAFT = "manaweaveArmorCraft"; - public static final String ENCHANTER_MAKE = "enchanterMake"; - public static final String POLLIDISIAC_PICKUP = "pollidisiacPickup"; - public static final String BREW_PICKUP = "brewPickup"; - public static final String TERRAFORM_ROD_CRAFT = "terraformRodCraft"; - public static final String BUBBELL_PICKUP = "bubbellPickup"; - public static final String LUMINIZER_RIDE = "luminizerRide"; - public static final String MANA_BOMB_IGNITE = "manaBombIgnite"; - public static final String DANDELIFEON_PICKUP = "dandelifeonPickup"; + public static final String FLOWER_PICKUP = "flowerPickup"; + public static final String LEXICON_USE = "lexiconUse"; + public static final String DAYBLOOM_PICKUP = "daybloomPickup"; + public static final String MANA_POOL_PICKUP = "manaPoolPickup"; + public static final String ENDOFLAME_PICKUP = "endoflamePickup"; + public static final String TINY_POTATO_PET = "tinyPotatoPet"; + public static final String SPARK_CRAFT = "sparkCraft"; + public static final String BAUBLE_WEAR = "baubleWear"; + public static final String MANA_COOKIE_EAT = "manaCookieEat"; + public static final String RUNE_PICKUP = "runePickup"; + public static final String MANA_BLASTER_SHOOT = "manaBlasterShoot"; + public static final String TIARA_WINGS = "tiaraWings"; + public static final String TERRASTEEL_PICKUP = "terrasteelPickup"; + public static final String ELF_PORTAL_OPEN = "elfPortalOpen"; + public static final String GAIA_GUARDIAN_KILL = "gaiaGuardianKill"; + public static final String TERRASTEEL_WEAPON_CRAFT = "terrasteelWeaponCraft"; + public static final String KEKIMURUS_PICKUP = "kekimurusPickup"; + public static final String HEISEI_DREAM_PICKUP = "heiseiDreamPickup"; + public static final String DIRT_ROD_CRAFT = "dirtRodCraft"; + public static final String SPAWNER_MOVER_USE = "spawnerMoverUse"; + public static final String ENDER_AIR_MAKE = "enderAirMake"; + public static final String CORPOREA_CRAFT = "corporeaCraft"; + public static final String CACOPHONIUM_CRAFT = "cacophoniumCraft"; + public static final String MANA_CART_CRAFT = "manaCartCraft"; + public static final String CRAFTING_HALO_CRAFT = "craftingHaloCraft"; + public static final String MANAWEAVE_ARMOR_CRAFT = "manaweaveArmorCraft"; + public static final String ENCHANTER_MAKE = "enchanterMake"; + public static final String POLLIDISIAC_PICKUP = "pollidisiacPickup"; + public static final String BREW_PICKUP = "brewPickup"; + public static final String TERRAFORM_ROD_CRAFT = "terraformRodCraft"; + public static final String BUBBELL_PICKUP = "bubbellPickup"; + public static final String LUMINIZER_RIDE = "luminizerRide"; + public static final String MANA_BOMB_IGNITE = "manaBombIgnite"; + public static final String DANDELIFEON_PICKUP = "dandelifeonPickup"; - public static final String SIGNAL_FLARE_STUN = "signalFlareStun"; - public static final String L20_SHARD_USE = "l20ShardUse"; - public static final String GAIA_GUARDIAN_NO_ARMOR = "gaiaGuardianNoArmor"; - public static final String RANK_SS_PICK = "rankSSPick"; - public static final String SUPER_CORPOREA_REQUEST = "superCorporeaRequest"; - public static final String PINKINATOR = "pinkinator"; + public static final String SIGNAL_FLARE_STUN = "signalFlareStun"; + public static final String L20_SHARD_USE = "l20ShardUse"; + public static final String GAIA_GUARDIAN_NO_ARMOR = "gaiaGuardianNoArmor"; + public static final String RANK_SS_PICK = "rankSSPick"; + public static final String SUPER_CORPOREA_REQUEST = "superCorporeaRequest"; + public static final String PINKINATOR = "pinkinator"; - public static final String RELIC_INFINITE_FRUIT = "infiniteFruit"; - public static final String RELIC_KING_KEY = "kingKey"; - public static final String RELIC_FLUGEL_EYE = "flugelEye"; - public static final String RELIC_THOR_RING = "thorRing"; - public static final String RELIC_ODIN_RING = "odinRing"; - public static final String RELIC_LOKI_RING = "lokiRing"; - public static final String RELIC_AESIR_RING = "aesirRing"; + public static final String RELIC_INFINITE_FRUIT = "infiniteFruit"; + public static final String RELIC_KING_KEY = "kingKey"; + public static final String RELIC_FLUGEL_EYE = "flugelEye"; + public static final String RELIC_THOR_RING = "thorRing"; + public static final String RELIC_ODIN_RING = "odinRing"; + public static final String RELIC_LOKI_RING = "lokiRing"; + public static final String RELIC_AESIR_RING = "aesirRing"; + + public static final String NULL_FLOWER = "nullFlower"; + public static final String DESU_GUN = "desuGun"; - public static final String NULL_FLOWER = "nullFlower"; - public static final String DESU_GUN = "desuGun"; } diff --git a/src/main/java/vazkii/botania/common/lib/LibBlockNames.java b/src/main/java/vazkii/botania/common/lib/LibBlockNames.java index 3179bb752c..3d0992cb11 100644 --- a/src/main/java/vazkii/botania/common/lib/LibBlockNames.java +++ b/src/main/java/vazkii/botania/common/lib/LibBlockNames.java @@ -2,162 +2,163 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jan 16, 2014, 5:55:03 PM (GMT)] */ package vazkii.botania.common.lib; public final class LibBlockNames { - public static final String FLOWER = "flower"; - public static final String ALTAR = "altar"; - public static final String SPECIAL_FLOWER = "specialFlower"; - public static final String LIVING_ROCK = "livingrock"; - public static final String LIVING_WOOD = "livingwood"; - public static final String SPREADER = "spreader"; - public static final String POOL = "pool"; - public static final String RUNE_ALTAR = "runeAltar"; - public static final String UNSTABLE_BLOCK = "unstableBlock"; - public static final String PYLON = "pylon"; - public static final String PISTON_RELAY = "pistonRelay"; - public static final String DISTRIBUTOR = "distributor"; - public static final String MANA_BEACON = "manaBeacon"; - public static final String MANA_VOID = "manaVoid"; - public static final String MANA_DETECTOR = "manaDetector"; - public static final String ENCHANTER = "enchanter"; - public static final String TURNTABLE = "turntable"; - public static final String TINY_PLANET = "tinyPlanetBlock"; - public static final String ALCHEMY_CATALYST = "alchemyCatalyst"; - public static final String OPEN_CRATE = "openCrate"; - public static final String CRAFT_CRATE = "craftCrate"; - public static final String FOREST_EYE = "forestEye"; - public static final String STORAGE = "storage"; - public static final String FOREST_DRUM = "forestDrum"; - public static final String SHINY_FLOWER = "shinyFlower"; - public static final String PLATFORM = "platform"; - public static final String ALF_PORTAL = "alfheimPortal"; - public static final String DREAM_WOOD = "dreamwood"; - public static final String CONJURATION_CATALYST = "conjurationCatalyst"; - public static final String BIFROST = "bifrost"; - public static final String SOLID_VINE = "solidVine"; - public static final String BURIED_PETALS = "buriedPetals"; - public static final String PRISMARINE = "prismarine"; - public static final String SEA_LAMP = "seaLamp"; - public static final String MINI_ISLAND = "miniIsland"; - public static final String TINY_POTATO = "tinyPotato"; - public static final String SPAWNER_CLAW = "spawnerClaw"; - public static final String REED_BLOCK = "reedBlock"; - public static final String THATCH = "thatch"; - public static final String CUSTOM_BRICK = "customBrick"; - public static final String ENDER_EYE_BLOCK = "enderEyeBlock"; - public static final String STARFIELD = "starfield"; - public static final String RF_GENERATOR = "rfGenerator"; - public static final String ELF_GLASS = "elfGlass"; - public static final String BREWERY = "brewery"; - public static final String MANA_GLASS = "manaGlass"; - public static final String TERRA_PLATE = "terraPlate"; - public static final String RED_STRING_CONTAINER = "redStringContainer"; - public static final String RED_STRING_DISPENSER = "redStringDispenser"; - public static final String RED_STRING_FERTILIZER = "redStringFertilizer"; - public static final String RED_STRING_COMPARATOR = "redStringComparator"; - public static final String RED_STRING_RELAY = "redStringRelay"; - public static final String RED_STRING_INTERCEPTOR = "redStringInterceptor"; - public static final String FLOATING_SPECIAL_FLOWER = "floatingSpecialFlower"; - public static final String MANA_FLAME = "manaFlame"; - public static final String PRISM = "prism"; - public static final String DIRT_PATH = "dirtPath"; - public static final String ENCHANTED_SOIL = "enchantedSoil"; - public static final String BIOME_STONE_A = "biomeStoneA"; - public static final String BIOME_STONE_B = "biomeStoneB"; - public static final String PETAL_BLOCK = "petalBlock"; - public static final String CORPOREA_INDEX = "corporeaIndex"; - public static final String CORPOREA_FUNNEL = "corporeaFunnel"; - public static final String END_STONE_BRICK = "endStoneBrick"; - public static final String MUSHROOM = "mushroom"; - public static final String PUMP = "pump"; - public static final String DOUBLE_FLOWER = "doubleFlower"; - public static final String STONE = "stone"; - public static final String FAKE_AIR = "fakeAir"; - public static final String BLAZE_BLOCK = "blazeBlock"; - public static final String CORPOREA_INTERCEPTOR = "corporeaInterceptor"; - public static final String CORPOREA_CRYSTAL_CUBE = "corporeaCrystalCube"; - public static final String INCENSE_PLATE = "incensePlate"; - public static final String HOURGLASS = "hourglass"; - public static final String GHOST_RAIL = "ghostRail"; - public static final String SPARK_CHANGER = "sparkChanger"; - public static final String ROOT = "root"; - public static final String FEL_PUMPKIN = "felPumpkin"; - public static final String COCOON = "cocoon"; - public static final String LIGHT_RELAY = "lightRelay"; - public static final String LIGHT_LAUNCHER = "lightLauncher"; - public static final String MANA_BOMB = "manaBomb"; - public static final String CACOPHONIUM = "cacophoniumBlock"; - public static final String BELLOWS = "bellows"; - public static final String BIFROST_PERM = "bifrostPerm"; - public static final String PAVEMENT = "pavement"; - public static final String CELL_BLOCK = "cellBlock"; - public static final String GAIA_HEAD = "gaiaHeadBlock"; - public static final String CORPOREA_RETAINER = "corporeaRetainer"; - public static final String TERU_TERU_BOZU = "teruTeruBozu"; - public static final String SHIMMERROCK = "shimmerrock"; - public static final String SHIMMERWOOD_PLANKS = "shimmerwoodPlanks"; - public static final String AVATAR = "avatar"; - public static final String ALT_GRASS = "altGrass"; + public static final String FLOWER = "flower"; + public static final String ALTAR = "altar"; + public static final String SPECIAL_FLOWER = "specialFlower"; + public static final String LIVING_ROCK = "livingrock"; + public static final String LIVING_WOOD = "livingwood"; + public static final String SPREADER = "spreader"; + public static final String POOL = "pool"; + public static final String RUNE_ALTAR = "runeAltar"; + public static final String UNSTABLE_BLOCK = "unstableBlock"; + public static final String PYLON = "pylon"; + public static final String PISTON_RELAY = "pistonRelay"; + public static final String DISTRIBUTOR = "distributor"; + public static final String MANA_BEACON = "manaBeacon"; + public static final String MANA_VOID = "manaVoid"; + public static final String MANA_DETECTOR = "manaDetector"; + public static final String ENCHANTER = "enchanter"; + public static final String TURNTABLE = "turntable"; + public static final String TINY_PLANET = "tinyPlanetBlock"; + public static final String ALCHEMY_CATALYST = "alchemyCatalyst"; + public static final String OPEN_CRATE = "openCrate"; + public static final String CRAFT_CRATE = "craftCrate"; + public static final String FOREST_EYE = "forestEye"; + public static final String STORAGE = "storage"; + public static final String FOREST_DRUM = "forestDrum"; + public static final String SHINY_FLOWER = "shinyFlower"; + public static final String PLATFORM = "platform"; + public static final String ALF_PORTAL = "alfheimPortal"; + public static final String DREAM_WOOD = "dreamwood"; + public static final String CONJURATION_CATALYST = "conjurationCatalyst"; + public static final String BIFROST = "bifrost"; + public static final String SOLID_VINE = "solidVine"; + public static final String BURIED_PETALS = "buriedPetals"; + public static final String PRISMARINE = "prismarine"; + public static final String SEA_LAMP = "seaLamp"; + public static final String MINI_ISLAND = "miniIsland"; + public static final String TINY_POTATO = "tinyPotato"; + public static final String SPAWNER_CLAW = "spawnerClaw"; + public static final String REED_BLOCK = "reedBlock"; + public static final String THATCH = "thatch"; + public static final String CUSTOM_BRICK = "customBrick"; + public static final String ENDER_EYE_BLOCK = "enderEyeBlock"; + public static final String STARFIELD = "starfield"; + public static final String RF_GENERATOR = "rfGenerator"; + public static final String ELF_GLASS = "elfGlass"; + public static final String BREWERY = "brewery"; + public static final String MANA_GLASS = "manaGlass"; + public static final String TERRA_PLATE = "terraPlate"; + public static final String RED_STRING_CONTAINER = "redStringContainer"; + public static final String RED_STRING_DISPENSER = "redStringDispenser"; + public static final String RED_STRING_FERTILIZER = "redStringFertilizer"; + public static final String RED_STRING_COMPARATOR = "redStringComparator"; + public static final String RED_STRING_RELAY = "redStringRelay"; + public static final String RED_STRING_INTERCEPTOR = "redStringInterceptor"; + public static final String FLOATING_SPECIAL_FLOWER = "floatingSpecialFlower"; + public static final String MANA_FLAME = "manaFlame"; + public static final String PRISM = "prism"; + public static final String DIRT_PATH = "dirtPath"; + public static final String ENCHANTED_SOIL = "enchantedSoil"; + public static final String BIOME_STONE_A = "biomeStoneA"; + public static final String BIOME_STONE_B = "biomeStoneB"; + public static final String PETAL_BLOCK = "petalBlock"; + public static final String CORPOREA_INDEX = "corporeaIndex"; + public static final String CORPOREA_FUNNEL = "corporeaFunnel"; + public static final String END_STONE_BRICK = "endStoneBrick"; + public static final String MUSHROOM = "mushroom"; + public static final String PUMP = "pump"; + public static final String DOUBLE_FLOWER = "doubleFlower"; + public static final String STONE = "stone"; + public static final String FAKE_AIR = "fakeAir"; + public static final String BLAZE_BLOCK = "blazeBlock"; + public static final String CORPOREA_INTERCEPTOR = "corporeaInterceptor"; + public static final String CORPOREA_CRYSTAL_CUBE = "corporeaCrystalCube"; + public static final String INCENSE_PLATE = "incensePlate"; + public static final String HOURGLASS = "hourglass"; + public static final String GHOST_RAIL = "ghostRail"; + public static final String SPARK_CHANGER = "sparkChanger"; + public static final String ROOT = "root"; + public static final String FEL_PUMPKIN = "felPumpkin"; + public static final String COCOON = "cocoon"; + public static final String LIGHT_RELAY = "lightRelay"; + public static final String LIGHT_LAUNCHER = "lightLauncher"; + public static final String MANA_BOMB = "manaBomb"; + public static final String CACOPHONIUM = "cacophoniumBlock"; + public static final String BELLOWS = "bellows"; + public static final String BIFROST_PERM = "bifrostPerm"; + public static final String PAVEMENT = "pavement"; + public static final String CELL_BLOCK = "cellBlock"; + public static final String GAIA_HEAD = "gaiaHeadBlock"; + public static final String CORPOREA_RETAINER = "corporeaRetainer"; + public static final String TERU_TERU_BOZU = "teruTeruBozu"; + public static final String SHIMMERROCK = "shimmerrock"; + public static final String SHIMMERWOOD_PLANKS = "shimmerwoodPlanks"; + public static final String AVATAR = "avatar"; + public static final String ALT_GRASS = "altGrass"; - public static final String SUBTILE_PUREDAISY = "puredaisy"; - public static final String SUBTILE_MANASTAR = "manastar"; + public static final String SUBTILE_PUREDAISY = "puredaisy"; + public static final String SUBTILE_MANASTAR = "manastar"; - public static final String SUBTILE_DAYBLOOM = "daybloom"; - public static final String SUBTILE_DAYBLOOM_PRIME = "daybloomPrime"; - public static final String SUBTILE_ENDOFLAME = "endoflame"; - public static final String SUBTILE_HYDROANGEAS = "hydroangeas"; - public static final String SUBTILE_THERMALILY = "thermalily"; - public static final String SUBTILE_NIGHTSHADE = "nightshade"; - public static final String SUBTILE_NIGHTSHADE_PRIME = "nightshadePrime"; - public static final String SUBTILE_ARCANE_ROSE = "arcanerose"; - public static final String SUBTILE_MUNCHDEW = "munchdew"; - public static final String SUBTILE_ENTROPINNYUM = "entropinnyum"; - public static final String SUBTILE_KEKIMURUS = "kekimurus"; - public static final String SUBTILE_GOURMARYLLIS = "gourmaryllis"; - public static final String SUBTILE_NARSLIMMUS = "narslimmus"; - public static final String SUBTILE_SPECTROLUS = "spectrolus"; - public static final String SUBTILE_DANDELIFEON = "dandelifeon"; - public static final String SUBTILE_RAFFLOWSIA = "rafflowsia"; + public static final String SUBTILE_DAYBLOOM = "daybloom"; + public static final String SUBTILE_DAYBLOOM_PRIME = "daybloomPrime"; + public static final String SUBTILE_ENDOFLAME = "endoflame"; + public static final String SUBTILE_HYDROANGEAS = "hydroangeas"; + public static final String SUBTILE_THERMALILY = "thermalily"; + public static final String SUBTILE_NIGHTSHADE = "nightshade"; + public static final String SUBTILE_NIGHTSHADE_PRIME = "nightshadePrime"; + public static final String SUBTILE_ARCANE_ROSE = "arcanerose"; + public static final String SUBTILE_MUNCHDEW = "munchdew"; + public static final String SUBTILE_ENTROPINNYUM = "entropinnyum"; + public static final String SUBTILE_KEKIMURUS = "kekimurus"; + public static final String SUBTILE_GOURMARYLLIS = "gourmaryllis"; + public static final String SUBTILE_NARSLIMMUS = "narslimmus"; + public static final String SUBTILE_SPECTROLUS = "spectrolus"; + public static final String SUBTILE_DANDELIFEON = "dandelifeon"; + public static final String SUBTILE_RAFFLOWSIA = "rafflowsia"; - public static final String SUBTILE_BELLETHORN = "bellethorn"; - public static final String SUBTILE_DREADTHORN = "dreadthorn"; - public static final String SUBTILE_HEISEI_DREAM = "heiseiDream"; - public static final String SUBTILE_TIGERSEYE = "tigerseye"; - public static final String SUBTILE_JADED_AMARANTHUS = "jadedAmaranthus"; - public static final String SUBTILE_ORECHID = "orechid"; - public static final String SUBTILE_FALLEN_KANADE = "fallenKanade"; - public static final String SUBTILE_EXOFLAME = "exoflame"; - public static final String SUBTILE_AGRICARNATION = "agricarnation"; - public static final String SUBTILE_HOPPERHOCK = "hopperhock"; - public static final String SUBTILE_TANGLEBERRIE = "tangleberrie"; - public static final String SUBTILE_JIYUULIA = "jiyuulia"; - public static final String SUBTILE_RANNUNCARPUS = "rannuncarpus"; - public static final String SUBTILE_HYACIDUS = "hyacidus"; - public static final String SUBTILE_POLLIDISIAC = "pollidisiac"; - public static final String SUBTILE_CLAYCONIA = "clayconia"; - public static final String SUBTILE_LOONIUM = "loonium"; - public static final String SUBTILE_DAFFOMILL = "daffomill"; - public static final String SUBTILE_VINCULOTUS = "vinculotus"; - public static final String SUBTILE_SPECTRANTHEMUM = "spectranthemum"; - public static final String SUBTILE_MEDUMONE = "medumone"; - public static final String SUBTILE_MARIMORPHOSIS = "marimorphosis"; - public static final String SUBTILE_BUBBELL = "bubbell"; - public static final String SUBTILE_SOLEGNOLIA = "solegnolia"; - public static final String SUBTILE_ORECHID_IGNEM = "orechidIgnem"; + public static final String SUBTILE_BELLETHORN = "bellethorn"; + public static final String SUBTILE_DREADTHORN = "dreadthorn"; + public static final String SUBTILE_HEISEI_DREAM = "heiseiDream"; + public static final String SUBTILE_TIGERSEYE = "tigerseye"; + public static final String SUBTILE_JADED_AMARANTHUS = "jadedAmaranthus"; + public static final String SUBTILE_ORECHID = "orechid"; + public static final String SUBTILE_FALLEN_KANADE = "fallenKanade"; + public static final String SUBTILE_EXOFLAME = "exoflame"; + public static final String SUBTILE_AGRICARNATION = "agricarnation"; + public static final String SUBTILE_HOPPERHOCK = "hopperhock"; + public static final String SUBTILE_TANGLEBERRIE = "tangleberrie"; + public static final String SUBTILE_JIYUULIA = "jiyuulia"; + public static final String SUBTILE_RANNUNCARPUS = "rannuncarpus"; + public static final String SUBTILE_HYACIDUS = "hyacidus"; + public static final String SUBTILE_POLLIDISIAC = "pollidisiac"; + public static final String SUBTILE_CLAYCONIA = "clayconia"; + public static final String SUBTILE_LOONIUM = "loonium"; + public static final String SUBTILE_DAFFOMILL = "daffomill"; + public static final String SUBTILE_VINCULOTUS = "vinculotus"; + public static final String SUBTILE_SPECTRANTHEMUM = "spectranthemum"; + public static final String SUBTILE_MEDUMONE = "medumone"; + public static final String SUBTILE_MARIMORPHOSIS = "marimorphosis"; + public static final String SUBTILE_BUBBELL = "bubbell"; + public static final String SUBTILE_SOLEGNOLIA = "solegnolia"; + public static final String SUBTILE_ORECHID_IGNEM = "orechidIgnem"; + + public static final String QUARTZ_DARK = "Dark"; + public static final String QUARTZ_MANA = "Mana"; + public static final String QUARTZ_BLAZE = "Blaze"; + public static final String QUARTZ_LAVENDER = "Lavender"; + public static final String QUARTZ_RED = "Red"; + public static final String QUARTZ_ELF = "Elf"; + public static final String QUARTZ_SUNNY = "Sunny"; - public static final String QUARTZ_DARK = "Dark"; - public static final String QUARTZ_MANA = "Mana"; - public static final String QUARTZ_BLAZE = "Blaze"; - public static final String QUARTZ_LAVENDER = "Lavender"; - public static final String QUARTZ_RED = "Red"; - public static final String QUARTZ_ELF = "Elf"; - public static final String QUARTZ_SUNNY = "Sunny"; } diff --git a/src/main/java/vazkii/botania/common/lib/LibBrewNames.java b/src/main/java/vazkii/botania/common/lib/LibBrewNames.java index d3af45ca03..e4219171bc 100644 --- a/src/main/java/vazkii/botania/common/lib/LibBrewNames.java +++ b/src/main/java/vazkii/botania/common/lib/LibBrewNames.java @@ -2,37 +2,38 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Nov 1, 2014, 7:03:57 PM (GMT)] */ package vazkii.botania.common.lib; public final class LibBrewNames { - public static final String SPEED = "speed"; - public static final String STRENGTH = "strength"; - public static final String HASTE = "haste"; - public static final String HEALING = "healing"; - public static final String JUMP_BOOST = "jumpBoost"; - public static final String REGEN = "regen"; - public static final String REGEN_WEAK = "regenWeak"; - public static final String RESISTANCE = "resistance"; - public static final String FIRE_RESISTANCE = "fireResistance"; - public static final String WATER_BREATHING = "waterBreathing"; - public static final String INVISIBILITY = "invisibility"; - public static final String NIGHT_VISION = "nightVision"; - public static final String ABSORPTION = "absorption"; + public static final String SPEED = "speed"; + public static final String STRENGTH = "strength"; + public static final String HASTE = "haste"; + public static final String HEALING = "healing"; + public static final String JUMP_BOOST = "jumpBoost"; + public static final String REGEN = "regen"; + public static final String REGEN_WEAK = "regenWeak"; + public static final String RESISTANCE = "resistance"; + public static final String FIRE_RESISTANCE = "fireResistance"; + public static final String WATER_BREATHING = "waterBreathing"; + public static final String INVISIBILITY = "invisibility"; + public static final String NIGHT_VISION = "nightVision"; + public static final String ABSORPTION = "absorption"; - public static final String SOUL_CROSS = "soulCross"; - public static final String FEATHER_FEET = "featherFeet"; - public static final String EMPTINESS = "emptiness"; - public static final String BLOODTHIRST = "bloodthirst"; - public static final String OVERLOAD = "overload"; - public static final String ALLURE = "allure"; - public static final String CLEAR = "clear"; + public static final String SOUL_CROSS = "soulCross"; + public static final String FEATHER_FEET = "featherFeet"; + public static final String EMPTINESS = "emptiness"; + public static final String BLOODTHIRST = "bloodthirst"; + public static final String OVERLOAD = "overload"; + public static final String ALLURE = "allure"; + public static final String CLEAR = "clear"; + + public static final String WARP_WARD = "warpWard"; - public static final String WARP_WARD = "warpWard"; } diff --git a/src/main/java/vazkii/botania/common/lib/LibEntityNames.java b/src/main/java/vazkii/botania/common/lib/LibEntityNames.java index 6d6ed2d716..e36c7aa78d 100644 --- a/src/main/java/vazkii/botania/common/lib/LibEntityNames.java +++ b/src/main/java/vazkii/botania/common/lib/LibEntityNames.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jan 26, 2014, 5:30:03 PM (GMT)] */ package vazkii.botania.common.lib; @@ -14,23 +14,24 @@ public final class LibEntityNames { - public static final String MANA_BURST = LibResources.PREFIX_MOD + "manaBurst"; - public static final String SIGNAL_FLARE = LibResources.PREFIX_MOD + "signalFlare"; - public static final String PIXIE = LibResources.PREFIX_MOD + "pixie"; - public static final String FLAME_RING = LibResources.PREFIX_MOD + "flameRing"; - public static final String VINE_BALL = LibResources.PREFIX_MOD + "vineBall"; - public static final String DOPPLEGANGER = LibResources.PREFIX_MOD + "doppleganger"; - public static final String MAGIC_LANDMINE = LibResources.PREFIX_MOD + "magicLandmine"; - public static final String SPARK = LibResources.PREFIX_MOD + "spark"; - public static final String THROWN_ITEM = LibResources.PREFIX_MOD + "thrownItem"; - public static final String MAGIC_MISSILE = LibResources.PREFIX_MOD + "magicMissile"; - public static final String THORN_CHAKRAM = LibResources.PREFIX_MOD + "thornChakram"; - public static final String CORPOREA_SPARK = LibResources.PREFIX_MOD + "corporeaSpark"; - public static final String ENDER_AIR_BOTTLE = LibResources.PREFIX_MOD + "enderAirBottle"; - public static final String POOL_MINECART = LibResources.PREFIX_MOD + "poolMinecart"; - public static final String PINK_WITHER = LibResources.PREFIX_MOD + "pinkWither"; - public static final String PLAYER_MOVER = LibResources.PREFIX_MOD + "playerMover"; - public static final String MANA_STORM = LibResources.PREFIX_MOD + "manaStorm"; - public static final String BABYLON_WEAPON = LibResources.PREFIX_MOD + "babylonWeapon"; - public static final String FALLING_STAR = LibResources.PREFIX_MOD + "fallingStar"; + public static final String MANA_BURST = LibResources.PREFIX_MOD + "manaBurst"; + public static final String SIGNAL_FLARE = LibResources.PREFIX_MOD + "signalFlare"; + public static final String PIXIE = LibResources.PREFIX_MOD + "pixie"; + public static final String FLAME_RING = LibResources.PREFIX_MOD + "flameRing"; + public static final String VINE_BALL = LibResources.PREFIX_MOD + "vineBall"; + public static final String DOPPLEGANGER = LibResources.PREFIX_MOD + "doppleganger"; + public static final String MAGIC_LANDMINE = LibResources.PREFIX_MOD + "magicLandmine"; + public static final String SPARK = LibResources.PREFIX_MOD + "spark"; + public static final String THROWN_ITEM = LibResources.PREFIX_MOD + "thrownItem"; + public static final String MAGIC_MISSILE = LibResources.PREFIX_MOD + "magicMissile"; + public static final String THORN_CHAKRAM = LibResources.PREFIX_MOD + "thornChakram"; + public static final String CORPOREA_SPARK = LibResources.PREFIX_MOD + "corporeaSpark"; + public static final String ENDER_AIR_BOTTLE = LibResources.PREFIX_MOD + "enderAirBottle"; + public static final String POOL_MINECART = LibResources.PREFIX_MOD + "poolMinecart"; + public static final String PINK_WITHER = LibResources.PREFIX_MOD + "pinkWither"; + public static final String PLAYER_MOVER = LibResources.PREFIX_MOD + "playerMover"; + public static final String MANA_STORM = LibResources.PREFIX_MOD + "manaStorm"; + public static final String BABYLON_WEAPON = LibResources.PREFIX_MOD + "babylonWeapon"; + public static final String FALLING_STAR = LibResources.PREFIX_MOD + "fallingStar"; + } diff --git a/src/main/java/vazkii/botania/common/lib/LibGuiIDs.java b/src/main/java/vazkii/botania/common/lib/LibGuiIDs.java index b6265b99f5..fefcb749a0 100644 --- a/src/main/java/vazkii/botania/common/lib/LibGuiIDs.java +++ b/src/main/java/vazkii/botania/common/lib/LibGuiIDs.java @@ -2,18 +2,19 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jan 14, 2014, 6:50:36 PM (GMT)] */ package vazkii.botania.common.lib; public final class LibGuiIDs { - public static final int LEXICON = 0; - public static final int CRAFTING_HALO = 1; - public static final int FLOWER_BAG = 2; - public static final int BAUBLE_BOX = 3; + public static final int LEXICON = 0; + public static final int CRAFTING_HALO = 1; + public static final int FLOWER_BAG = 2; + public static final int BAUBLE_BOX = 3; + } diff --git a/src/main/java/vazkii/botania/common/lib/LibItemNames.java b/src/main/java/vazkii/botania/common/lib/LibItemNames.java index 934b974f69..98f2643f7e 100644 --- a/src/main/java/vazkii/botania/common/lib/LibItemNames.java +++ b/src/main/java/vazkii/botania/common/lib/LibItemNames.java @@ -2,215 +2,215 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jan 14, 2014, 5:49:06 PM (GMT)] */ package vazkii.botania.common.lib; public final class LibItemNames { - public static final String LEXICON = "lexicon"; - public static final String PETAL = "petal"; - public static final String DYE = "dye"; - public static final String PESTLE_AND_MORTAR = "pestleAndMortar"; - public static final String TWIG_WAND = "twigWand"; - public static final String MANA_RESOURCE = "manaResource"; - public static final String LENS = "lens"; - public static final String MANA_PETAL = "manaPetal"; - public static final String RUNE = "rune"; - public static final String SIGNAL_FLARE = "signalFlare"; - public static final String MANA_TABLET = "manaTablet"; - public static final String MANA_GUN = "manaGun"; - public static final String MANA_COOKIE = "manaCookie"; - public static final String FERTILIZER = "fertilizer"; - public static final String GRASS_SEEDS = "grassSeeds"; - public static final String DIRT_ROD = "dirtRod"; - public static final String TERRAFORM_ROD = "terraformRod"; - public static final String MANA_MIRROR = "manaMirror"; - public static final String MANASTEEL_HELM = "manasteelHelm"; - public static final String MANASTEEL_CHEST = "manasteelChest"; - public static final String MANASTEEL_LEGS = "manasteelLegs"; - public static final String MANASTEEL_BOOTS = "manasteelBoots"; - public static final String MANASTEEL_PICK = "manasteelPick"; - public static final String MANASTEEL_SHOVEL = "manasteelShovel"; - public static final String MANASTEEL_AXE = "manasteelAxe"; - public static final String MANASTEEL_SWORD = "manasteelSword"; - public static final String MANASTEEL_SHEARS = "manasteelShears"; - public static final String GRASS_HORN = "grassHorn"; - public static final String TERRASTEEL_HELM = "terrasteelHelm"; - public static final String TERRASTEEL_CHEST = "terrasteelChest"; - public static final String TERRASTEEL_LEGS = "terrasteelLegs"; - public static final String TERRASTEEL_BOOTS = "terrasteelBoots"; - public static final String TERRA_SWORD = "terraSword"; - public static final String TINY_PLANET = "tinyPlanet"; - public static final String MANA_RING = "manaRing"; - public static final String AURA_RING = "auraRing"; - public static final String MANA_RING_GREATER = "manaRingGreater"; - public static final String AURA_RING_GREATER = "auraRingGreater"; - public static final String TRAVEL_BELT = "travelBelt"; - public static final String KNOCKBACK_BELT = "knockbackBelt"; - public static final String ICE_PENDANT = "icePendant"; - public static final String LAVA_PENDANT = "lavaPendant"; - public static final String GOLDEN_LAUREL = "goldenLaurel"; - public static final String MAGNET_RING = "magnetRing"; - public static final String WATER_RING = "waterRing"; - public static final String MINING_RING = "miningRing"; - public static final String TERRA_PICK = "terraPick"; - public static final String DIVA_CHARM = "divaCharm"; - public static final String FLIGHT_TIARA = "flightTiara"; - public static final String ENDER_DAGGER = "enderDagger"; - public static final String QUARTZ = "quartz"; - public static final String WATER_ROD = "waterRod"; - public static final String ELEMENTIUM_HELM = "elementiumHelm"; - public static final String ELEMENTIUM_CHEST = "elementiumChest"; - public static final String ELEMENTIUM_LEGS = "elementiumLegs"; - public static final String ELEMENTIUM_BOOTS = "elementiumBoots"; - public static final String ELEMENTIUM_PICK = "elementiumPick"; - public static final String ELEMENTIUM_SHOVEL = "elementiumShovel"; - public static final String ELEMENTIUM_AXE = "elementiumAxe"; - public static final String ELEMENTIUM_SWORD = "elementiumSword"; - public static final String ELEMENTIUM_SHEARS = "elementiumShears"; - public static final String OPEN_BUCKET = "openBucket"; - public static final String SPAWNER_MOVER = "spawnerMover"; - public static final String PIXIE_RING = "pixieRing"; - public static final String SUPER_TRAVEL_BELT = "superTravelBelt"; - public static final String RAINBOW_ROD = "rainbowRod"; - public static final String TORNADO_ROD = "tornadoRod"; - public static final String FIRE_ROD = "fireRod"; - public static final String VINE_BALL = "vineBall"; - public static final String SLINGSHOT = "slingshot"; - public static final String MANA_BOTTLE = "manaBottle"; - public static final String LAPUTA_SHARD = "laputaShard"; - public static final String VIRUS = "virus"; - public static final String REACH_RING = "reachRing"; - public static final String SKY_DIRT_ROD = "skyDirtRod"; - public static final String MANASTEEL_HELM_R = "manasteelHelmReveal"; - public static final String TERRASTEEL_HELM_R = "terrasteelHelmReveal"; - public static final String ELEMENTIUM_HELM_R = "elementiumHelmReveal"; - public static final String ITEM_FINDER = "itemFinder"; - public static final String SUPER_LAVA_PENDANT = "superLavaPendant"; - public static final String ENDER_HAND = "enderHand"; - public static final String GLASS_PICK = "glassPick"; - public static final String SPARK = "spark"; - public static final String SPARK_UPGRADE = "sparkUpgrade"; - public static final String DIVINING_ROD = "diviningRod"; - public static final String GRAVITY_ROD = "gravityRod"; - public static final String REGEN_IVY = "regenIvy"; - public static final String MANA_INKWELL = "manaInkwell"; - public static final String VIAL = "vial"; - public static final String FLASK = "flask"; - public static final String BREW_VIAL = "brewVial"; - public static final String BREW_FLASK = "brewFlask"; - public static final String BLOOD_PENDANT = "bloodPendant"; - public static final String MISSILE_ROD = "missileRod"; - public static final String HOLY_CLOAK = "holyCloak"; - public static final String UNHOLY_CLOAK = "unholyCloak"; - public static final String CRAFTING_HALO = "craftingHalo"; - public static final String BLACK_LOTUS = "blackLotus"; - public static final String MONOCLE = "monocle"; - public static final String CLIP = "clip"; - public static final String COBBLE_ROD = "cobbleRod"; - public static final String SMELT_ROD = "smeltRod"; - public static final String WORLD_SEED = "worldSeed"; - public static final String SPELL_CLOTH = "spellCloth"; - public static final String THORN_CHAKRAM = "thornChakram"; - public static final String OVERGROWTH_SEED = "overgrowthSeed"; - public static final String CRAFT_PATTERN = "craftPattern"; - public static final String ANCIENT_WILL = "ancientWill"; - public static final String CORPOREA_SPARK = "corporeaSpark"; - public static final String LIVINGWOOD_BOW = "livingwoodBow"; - public static final String CRYSTAL_BOW = "crystalBow"; - public static final String COSMETIC = "cosmetic"; - public static final String SWAP_RING = "swapRing"; - public static final String FLOWER_BAG = "flowerBag"; - public static final String PHANTOM_INK = "phantomInk"; - public static final String POOL_MINECART = "poolMinecart"; - public static final String PINKINATOR = "pinkinator"; - public static final String INFINITE_FRUIT = "infiniteFruit"; - public static final String KING_KEY = "kingKey"; - public static final String FLUGEL_EYE = "flugelEye"; - public static final String THOR_RING = "thorRing"; - public static final String ODIN_RING = "odinRing"; - public static final String LOKI_RING = "lokiRing"; - public static final String AESIR_RING = "aesirRing"; - public static final String DICE = "dice"; - public static final String KEEP_IVY = "keepIvy"; - public static final String BLACK_HOLE_TALISMAN = "blackHoleTalisman"; - public static final String RECORD_GAIA1 = "recordGaia1"; - public static final String RECORD_GAIA2 = "recordGaia2"; - public static final String TEMPERANCE_STONE = "temperanceStone"; - public static final String INCENSE_STICK = "incenseStick"; - public static final String TERRA_AXE = "terraAxe"; - public static final String WATER_BOWL = "waterBowl"; - public static final String OBEDIENCE_STICK = "obedienceStick"; - public static final String CACOPHONIUM = "cacophonium"; - public static final String SLIME_BOTTLE = "slimeBottle"; - public static final String STAR_SWORD = "starSword"; - public static final String EXCHANGE_ROD = "exchangeRod"; - public static final String MAGNET_RING_GREATER = "magnetRingGreater"; - public static final String THUNDER_SWORD = "thunderSword"; - public static final String MANAWEAVE_HELM = "manaweaveHelm"; - public static final String MANAWEAVE_CHEST = "manaweaveChest"; - public static final String MANAWEAVE_LEGS = "manaweaveLegs"; - public static final String MANAWEAVE_BOOTS = "manaweaveBoots"; - public static final String AUTOCRAFTING_HALO = "autocraftingHalo"; - public static final String GAIA_HEAD = "gaiaHead"; - public static final String SEXTANT = "sextant"; - public static final String SPEED_UP_BELT = "speedUpBelt"; - public static final String BAUBLE_BOX = "baubleBox"; + public static final String LEXICON = "lexicon"; + public static final String PETAL = "petal"; + public static final String DYE = "dye"; + public static final String PESTLE_AND_MORTAR = "pestleAndMortar"; + public static final String TWIG_WAND = "twigWand"; + public static final String MANA_RESOURCE = "manaResource"; + public static final String LENS = "lens"; + public static final String MANA_PETAL = "manaPetal"; + public static final String RUNE = "rune"; + public static final String SIGNAL_FLARE = "signalFlare"; + public static final String MANA_TABLET = "manaTablet"; + public static final String MANA_GUN = "manaGun"; + public static final String MANA_COOKIE = "manaCookie"; + public static final String FERTILIZER = "fertilizer"; + public static final String GRASS_SEEDS = "grassSeeds"; + public static final String DIRT_ROD = "dirtRod"; + public static final String TERRAFORM_ROD = "terraformRod"; + public static final String MANA_MIRROR = "manaMirror"; + public static final String MANASTEEL_HELM = "manasteelHelm"; + public static final String MANASTEEL_CHEST = "manasteelChest"; + public static final String MANASTEEL_LEGS = "manasteelLegs"; + public static final String MANASTEEL_BOOTS = "manasteelBoots"; + public static final String MANASTEEL_PICK = "manasteelPick"; + public static final String MANASTEEL_SHOVEL = "manasteelShovel"; + public static final String MANASTEEL_AXE = "manasteelAxe"; + public static final String MANASTEEL_SWORD = "manasteelSword"; + public static final String MANASTEEL_SHEARS = "manasteelShears"; + public static final String GRASS_HORN = "grassHorn"; + public static final String TERRASTEEL_HELM = "terrasteelHelm"; + public static final String TERRASTEEL_CHEST = "terrasteelChest"; + public static final String TERRASTEEL_LEGS = "terrasteelLegs"; + public static final String TERRASTEEL_BOOTS = "terrasteelBoots"; + public static final String TERRA_SWORD = "terraSword"; + public static final String TINY_PLANET = "tinyPlanet"; + public static final String MANA_RING = "manaRing"; + public static final String AURA_RING = "auraRing"; + public static final String MANA_RING_GREATER = "manaRingGreater"; + public static final String AURA_RING_GREATER = "auraRingGreater"; + public static final String TRAVEL_BELT = "travelBelt"; + public static final String KNOCKBACK_BELT = "knockbackBelt"; + public static final String ICE_PENDANT = "icePendant"; + public static final String LAVA_PENDANT = "lavaPendant"; + public static final String GOLDEN_LAUREL = "goldenLaurel"; + public static final String MAGNET_RING = "magnetRing"; + public static final String WATER_RING = "waterRing"; + public static final String MINING_RING = "miningRing"; + public static final String TERRA_PICK = "terraPick"; + public static final String DIVA_CHARM = "divaCharm"; + public static final String FLIGHT_TIARA = "flightTiara"; + public static final String ENDER_DAGGER = "enderDagger"; + public static final String QUARTZ = "quartz"; + public static final String WATER_ROD = "waterRod"; + public static final String ELEMENTIUM_HELM = "elementiumHelm"; + public static final String ELEMENTIUM_CHEST = "elementiumChest"; + public static final String ELEMENTIUM_LEGS = "elementiumLegs"; + public static final String ELEMENTIUM_BOOTS = "elementiumBoots"; + public static final String ELEMENTIUM_PICK = "elementiumPick"; + public static final String ELEMENTIUM_SHOVEL = "elementiumShovel"; + public static final String ELEMENTIUM_AXE = "elementiumAxe"; + public static final String ELEMENTIUM_SWORD = "elementiumSword"; + public static final String ELEMENTIUM_SHEARS = "elementiumShears"; + public static final String OPEN_BUCKET = "openBucket"; + public static final String SPAWNER_MOVER = "spawnerMover"; + public static final String PIXIE_RING = "pixieRing"; + public static final String SUPER_TRAVEL_BELT = "superTravelBelt"; + public static final String RAINBOW_ROD = "rainbowRod"; + public static final String TORNADO_ROD = "tornadoRod"; + public static final String FIRE_ROD = "fireRod"; + public static final String VINE_BALL = "vineBall"; + public static final String SLINGSHOT = "slingshot"; + public static final String MANA_BOTTLE = "manaBottle"; + public static final String LAPUTA_SHARD = "laputaShard"; + public static final String VIRUS = "virus"; + public static final String REACH_RING = "reachRing"; + public static final String SKY_DIRT_ROD = "skyDirtRod"; + public static final String MANASTEEL_HELM_R = "manasteelHelmReveal"; + public static final String TERRASTEEL_HELM_R = "terrasteelHelmReveal"; + public static final String ELEMENTIUM_HELM_R = "elementiumHelmReveal"; + public static final String ITEM_FINDER = "itemFinder"; + public static final String SUPER_LAVA_PENDANT = "superLavaPendant"; + public static final String ENDER_HAND = "enderHand"; + public static final String GLASS_PICK = "glassPick"; + public static final String SPARK = "spark"; + public static final String SPARK_UPGRADE = "sparkUpgrade"; + public static final String DIVINING_ROD = "diviningRod"; + public static final String GRAVITY_ROD = "gravityRod"; + public static final String REGEN_IVY = "regenIvy"; + public static final String MANA_INKWELL = "manaInkwell"; + public static final String VIAL = "vial"; + public static final String FLASK = "flask"; + public static final String BREW_VIAL = "brewVial"; + public static final String BREW_FLASK = "brewFlask"; + public static final String BLOOD_PENDANT = "bloodPendant"; + public static final String MISSILE_ROD = "missileRod"; + public static final String HOLY_CLOAK = "holyCloak"; + public static final String UNHOLY_CLOAK = "unholyCloak"; + public static final String CRAFTING_HALO = "craftingHalo"; + public static final String BLACK_LOTUS = "blackLotus"; + public static final String MONOCLE = "monocle"; + public static final String CLIP = "clip"; + public static final String COBBLE_ROD = "cobbleRod"; + public static final String SMELT_ROD = "smeltRod"; + public static final String WORLD_SEED = "worldSeed"; + public static final String SPELL_CLOTH = "spellCloth"; + public static final String THORN_CHAKRAM = "thornChakram"; + public static final String OVERGROWTH_SEED = "overgrowthSeed"; + public static final String CRAFT_PATTERN = "craftPattern"; + public static final String ANCIENT_WILL = "ancientWill"; + public static final String CORPOREA_SPARK = "corporeaSpark"; + public static final String LIVINGWOOD_BOW = "livingwoodBow"; + public static final String CRYSTAL_BOW = "crystalBow"; + public static final String COSMETIC = "cosmetic"; + public static final String SWAP_RING = "swapRing"; + public static final String FLOWER_BAG = "flowerBag"; + public static final String PHANTOM_INK = "phantomInk"; + public static final String POOL_MINECART = "poolMinecart"; + public static final String PINKINATOR = "pinkinator"; + public static final String INFINITE_FRUIT = "infiniteFruit"; + public static final String KING_KEY = "kingKey"; + public static final String FLUGEL_EYE = "flugelEye"; + public static final String THOR_RING = "thorRing"; + public static final String ODIN_RING = "odinRing"; + public static final String LOKI_RING = "lokiRing"; + public static final String AESIR_RING = "aesirRing"; + public static final String DICE = "dice"; + public static final String KEEP_IVY = "keepIvy"; + public static final String BLACK_HOLE_TALISMAN = "blackHoleTalisman"; + public static final String RECORD_GAIA1 = "recordGaia1"; + public static final String RECORD_GAIA2 = "recordGaia2"; + public static final String TEMPERANCE_STONE = "temperanceStone"; + public static final String INCENSE_STICK = "incenseStick"; + public static final String TERRA_AXE = "terraAxe"; + public static final String WATER_BOWL = "waterBowl"; + public static final String OBEDIENCE_STICK = "obedienceStick"; + public static final String CACOPHONIUM = "cacophonium"; + public static final String SLIME_BOTTLE = "slimeBottle"; + public static final String STAR_SWORD = "starSword"; + public static final String EXCHANGE_ROD = "exchangeRod"; + public static final String MAGNET_RING_GREATER = "magnetRingGreater"; + public static final String THUNDER_SWORD = "thunderSword"; + public static final String MANAWEAVE_HELM = "manaweaveHelm"; + public static final String MANAWEAVE_CHEST = "manaweaveChest"; + public static final String MANAWEAVE_LEGS = "manaweaveLegs"; + public static final String MANAWEAVE_BOOTS = "manaweaveBoots"; + public static final String AUTOCRAFTING_HALO = "autocraftingHalo"; + public static final String GAIA_HEAD = "gaiaHead"; + public static final String SEXTANT = "sextant"; + public static final String SPEED_UP_BELT = "speedUpBelt"; + public static final String BAUBLE_BOX = "baubleBox"; - public static final String[] LENS_NAMES = new String[] { - "lensNormal", - "lensSpeed", - "lensPower", - "lensTime", - "lensEfficiency", - "lensBounce", - "lensGravity", - "lensMine", - "lensDamage", - "lensPhantom", - "lensMagnet", - "lensExplosive", - "lensInfluence", - "lensWeight", - "lensPaint", - "lensFire", - "lensPiston", - "lensLight", - "lensWarp", - "lensRedirect", - "lensFirework", - "lensFlare" - }; + public static final String[] LENS_NAMES = new String[] { + "lensNormal", + "lensSpeed", + "lensPower", + "lensTime", + "lensEfficiency", + "lensBounce", + "lensGravity", + "lensMine", + "lensDamage", + "lensPhantom", + "lensMagnet", + "lensExplosive", + "lensInfluence", + "lensWeight", + "lensPaint", + "lensFire", + "lensPiston", + "lensLight", + "lensWarp", + "lensRedirect", + "lensFirework", + "lensFlare" + }; - public static final String[] MANA_RESOURCE_NAMES = new String[] { - "manasteel", - "manaPearl", - "manaDiamond", - "livingwoodTwig", - "terrasteel", - "lifeEssence", - "redstoneRoot", - "elementium", - "pixieDust", - "dragonstone", - "prismarineShard", - "placeholder", - "redString", - "dreamwoodTwig", - "gaiaIngot", - "enderAirBottle", - "manaString", - "manasteelNugget", - "terrasteelNugget", - "elementiumNugget", - "root", - "pebble", - "manaweaveCloth", - "manaPowder" - }; + public static final String[] MANA_RESOURCE_NAMES = new String[] { + "manasteel", + "manaPearl", + "manaDiamond", + "livingwoodTwig", + "terrasteel", + "lifeEssence", + "redstoneRoot", + "elementium", + "pixieDust", + "dragonstone", + "prismarineShard", + "placeholder", + "redString", + "dreamwoodTwig", + "gaiaIngot", + "enderAirBottle", + "manaString", + "manasteelNugget", + "terrasteelNugget", + "elementiumNugget", + "root", + "pebble", + "manaweaveCloth", + "manaPowder" + }; } diff --git a/src/main/java/vazkii/botania/common/lib/LibLexicon.java b/src/main/java/vazkii/botania/common/lib/LibLexicon.java index 54353f5d5e..8b6013961a 100644 --- a/src/main/java/vazkii/botania/common/lib/LibLexicon.java +++ b/src/main/java/vazkii/botania/common/lib/LibLexicon.java @@ -2,266 +2,268 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jan 14, 2014, 9:14:08 PM (GMT)] */ package vazkii.botania.common.lib; public final class LibLexicon { - public static final String CATEGORY_PREFIX = "botania.category."; + public static final String CATEGORY_PREFIX = "botania.category."; - public static final String CATEGORY_BASICS = "basics"; - public static final String CATEGORY_MANA = "mana"; - public static final String CATEGORY_FUNCTIONAL_FLOWERS = "functionalFlowers"; - public static final String CATEGORY_GENERATION_FLOWERS = "generationFlowers"; - public static final String CATEGORY_DEVICES = "devices"; - public static final String CATEGORY_TOOLS = "tools"; - public static final String CATEGORY_BAUBLES = "baubles"; - public static final String CATEGORY_ENDER = "ender"; - public static final String CATEGORY_ALFHOMANCY = "alfhomancy"; - public static final String CATEGORY_MISC = "misc"; + public static final String CATEGORY_BASICS = "basics"; + public static final String CATEGORY_MANA = "mana"; + public static final String CATEGORY_FUNCTIONAL_FLOWERS = "functionalFlowers"; + public static final String CATEGORY_GENERATION_FLOWERS = "generationFlowers"; + public static final String CATEGORY_DEVICES = "devices"; + public static final String CATEGORY_TOOLS = "tools"; + public static final String CATEGORY_BAUBLES = "baubles"; + public static final String CATEGORY_ENDER = "ender"; + public static final String CATEGORY_ALFHOMANCY = "alfhomancy"; + public static final String CATEGORY_MISC = "misc"; - public static final String BASICS_WELCOME = "welcome"; - public static final String BASICS_TUTORIAL = "tutorial"; - public static final String BASICS_INTRO_VIDEO = "introVideo"; + public static final String BASICS_WELCOME = "welcome"; + public static final String BASICS_TUTORIAL = "tutorial"; + public static final String BASICS_INTRO_VIDEO = "introVideo"; - public static final String BASICS_FLOWERS = "flowers"; - public static final String BASICS_APOTHECARY = "apothecary"; - public static final String BASICS_LEXICON = "lexicon"; - public static final String BASICS_WAND = "wand"; - public static final String BASICS_PURE_DAISY = "pureDaisy"; - public static final String BASICS_RUNE_ALTAR = "runeAltar"; - public static final String BASICS_TERRASTEEL = "terrasteel"; - public static final String BASICS_BLACK_LOTUS = "blackLotus"; - public static final String BASICS_FLOWER_BAG = "flowerBag"; - public static final String BASICS_GARDEN_OF_GLASS = "gardenOfGlass"; + public static final String BASICS_FLOWERS = "flowers"; + public static final String BASICS_APOTHECARY = "apothecary"; + public static final String BASICS_LEXICON = "lexicon"; + public static final String BASICS_WAND = "wand"; + public static final String BASICS_PURE_DAISY = "pureDaisy"; + public static final String BASICS_RUNE_ALTAR = "runeAltar"; + public static final String BASICS_TERRASTEEL = "terrasteel"; + public static final String BASICS_BLACK_LOTUS = "blackLotus"; + public static final String BASICS_FLOWER_BAG = "flowerBag"; + public static final String BASICS_GARDEN_OF_GLASS = "gardenOfGlass"; - public static final String MANA_INTRO = "mIntro"; - public static final String MANA_SPREADER = "spreader"; - public static final String MANA_POOL = "pool"; - public static final String MANA_DISTRIBUTOR = "distributor"; - public static final String MANA_LENSES = "lens"; - public static final String MANA_VOID = "manaVoid"; - public static final String MANA_RF_GENERATOR = "rfGenerator"; - public static final String MANA_TABLET = "manaTablet"; - public static final String MANA_MIRROR = "manaMirror"; - public static final String MANA_DETECTOR = "manaDetector"; - public static final String MANA_COMPOSITE_LENS = "compositeLens"; - public static final String MANA_REDSTONE_SPREADER = "redstoneSpreader"; - public static final String MANA_MANASTAR = "manastar"; - public static final String MANA_DREAMWOOD_SPREADER = "dreamwoodSpreader"; - public static final String MANA_ELVEN_LENSES = "elvenLenses"; - public static final String MANA_SPARKS = "sparks"; - public static final String MANA_SPARK_UPGRADES = "sparkUpgrades"; - public static final String MANA_PRISM = "prism"; - public static final String MANA_POOL_CART = "poolCart"; - public static final String MANA_SPARK_CHANGER = "sparkChanger"; - public static final String MANA_BELLOWS = "bellows"; + public static final String MANA_INTRO = "mIntro"; + public static final String MANA_SPREADER = "spreader"; + public static final String MANA_POOL = "pool"; + public static final String MANA_DISTRIBUTOR = "distributor"; + public static final String MANA_LENSES = "lens"; + public static final String MANA_VOID = "manaVoid"; + public static final String MANA_RF_GENERATOR = "rfGenerator"; + public static final String MANA_TABLET = "manaTablet"; + public static final String MANA_MIRROR = "manaMirror"; + public static final String MANA_DETECTOR = "manaDetector"; + public static final String MANA_COMPOSITE_LENS = "compositeLens"; + public static final String MANA_REDSTONE_SPREADER = "redstoneSpreader"; + public static final String MANA_MANASTAR = "manastar"; + public static final String MANA_DREAMWOOD_SPREADER = "dreamwoodSpreader"; + public static final String MANA_ELVEN_LENSES = "elvenLenses"; + public static final String MANA_SPARKS = "sparks"; + public static final String MANA_SPARK_UPGRADES = "sparkUpgrades"; + public static final String MANA_PRISM = "prism"; + public static final String MANA_POOL_CART = "poolCart"; + public static final String MANA_SPARK_CHANGER = "sparkChanger"; + public static final String MANA_BELLOWS = "bellows"; - public static final String FFLOWER_INTRO = "fIntro"; - public static final String FFLOWER_SHRINKING = "flowerShrinking"; - public static final String FFLOWER_SPEED = "flowerSpeed"; - public static final String FFLOWER_JADED_AMARANTHUS = "jadedAmaranthus"; - public static final String FFLOWER_BELLETHORNE = "bellethorne"; - public static final String FFLOWER_DREADTHORNE = "dreadthorne"; - public static final String FFLOWER_HEISEI_DREAM = "heiseiDream"; - public static final String FFLOWER_TIGERSEYE = "tigerseye"; - public static final String FFLOWER_ORECHID = "orechid"; - public static final String FFLOWER_ORECHID_IGNEM = "orechidIgnem"; - public static final String FFLOWER_FALLEN_KANADE = "fallenKanade"; - public static final String FFLOWER_EXOFLAME = "exoflame"; - public static final String FFLOWER_AGRICARNATION = "agricarnation"; - public static final String FFLOWER_HOPPERHOCK = "hopperhock"; - public static final String FFLOWER_TANGLEBERRIE = "tangleberrie"; - public static final String FFLOWER_JIYUULIA = "jiyuulia"; - public static final String FFLOWER_RANNUNCARPUS = "rannuncarpus"; - public static final String FFLOWER_HYACIDUS = "hyacidus"; - public static final String FFLOWER_POLLIDISIAC = "pollidisiac"; - public static final String FFLOWER_CLAYCONIA = "clayconia"; - public static final String FFLOWER_LOONIUM = "loonium"; - public static final String FFLOWER_DAFFOMILL = "daffomill"; - public static final String FFLOWER_VINCULOTUS = "vinculotus"; - public static final String FFLOWER_SPECTRANTHEMUN = "spectranthemum"; - public static final String FFLOWER_MEDUMONE = "medumone"; - public static final String FFLOWER_MARIMORPHOSIS = "marimorphosis"; - public static final String FFLOWER_BUBBELL = "bubbell"; - public static final String FFLOWER_SOLEGNOLIA = "solegnolia"; + public static final String FFLOWER_INTRO = "fIntro"; + public static final String FFLOWER_SHRINKING = "flowerShrinking"; + public static final String FFLOWER_SPEED = "flowerSpeed"; + public static final String FFLOWER_JADED_AMARANTHUS = "jadedAmaranthus"; + public static final String FFLOWER_BELLETHORNE = "bellethorne"; + public static final String FFLOWER_DREADTHORNE = "dreadthorne"; + public static final String FFLOWER_HEISEI_DREAM = "heiseiDream"; + public static final String FFLOWER_TIGERSEYE = "tigerseye"; + public static final String FFLOWER_ORECHID = "orechid"; + public static final String FFLOWER_ORECHID_IGNEM = "orechidIgnem"; + public static final String FFLOWER_FALLEN_KANADE = "fallenKanade"; + public static final String FFLOWER_EXOFLAME = "exoflame"; + public static final String FFLOWER_AGRICARNATION = "agricarnation"; + public static final String FFLOWER_HOPPERHOCK = "hopperhock"; + public static final String FFLOWER_TANGLEBERRIE = "tangleberrie"; + public static final String FFLOWER_JIYUULIA = "jiyuulia"; + public static final String FFLOWER_RANNUNCARPUS = "rannuncarpus"; + public static final String FFLOWER_HYACIDUS = "hyacidus"; + public static final String FFLOWER_POLLIDISIAC = "pollidisiac"; + public static final String FFLOWER_CLAYCONIA = "clayconia"; + public static final String FFLOWER_LOONIUM = "loonium"; + public static final String FFLOWER_DAFFOMILL = "daffomill"; + public static final String FFLOWER_VINCULOTUS = "vinculotus"; + public static final String FFLOWER_SPECTRANTHEMUN = "spectranthemum"; + public static final String FFLOWER_MEDUMONE = "medumone"; + public static final String FFLOWER_MARIMORPHOSIS = "marimorphosis"; + public static final String FFLOWER_BUBBELL = "bubbell"; + public static final String FFLOWER_SOLEGNOLIA = "solegnolia"; - public static final String GFLOWER_INTRO = "gIntro"; - public static final String GFLOWER_PASSIVE_GENERATION = "passiveGen"; - public static final String GFLOWER_PRIMUS_LOCI = "primusLoci"; - public static final String GFLOWER_DAYBLOOM = "daybloom"; - public static final String GFLOWER_NIGHTSHADE = "nightshade"; - public static final String GFLOWER_ENDOFLAME = "endoflame"; - public static final String GFLOWER_HYDROANGEAS = "hydroangeas"; - public static final String GFLOWER_THERMALILY = "thermalily"; - public static final String GFLOWER_ARCANE_ROSE = "arcanerose"; - public static final String GFLOWER_MUNCHDEW = "munchdew"; - public static final String GFLOWER_ENTROPINNYUM = "entropinnyum"; - public static final String GFLOWER_KEKIMURUS = "kekimurus"; - public static final String GFLOWER_GOURMARYLLIS = "gourmaryllis"; - public static final String GFLOWER_NARSLIMMUS = "narslimmus"; - public static final String GFLOWER_SPECTROLUS = "spectrolus"; - public static final String GFLOWER_RAFFLOWSIA = "rafflowsia"; - public static final String GFLOWER_DANDELIFEON = "dandelifeon"; + public static final String GFLOWER_INTRO = "gIntro"; + public static final String GFLOWER_PASSIVE_GENERATION = "passiveGen"; + public static final String GFLOWER_PRIMUS_LOCI = "primusLoci"; + public static final String GFLOWER_DAYBLOOM = "daybloom"; + public static final String GFLOWER_NIGHTSHADE = "nightshade"; + public static final String GFLOWER_ENDOFLAME = "endoflame"; + public static final String GFLOWER_HYDROANGEAS = "hydroangeas"; + public static final String GFLOWER_THERMALILY = "thermalily"; + public static final String GFLOWER_ARCANE_ROSE = "arcanerose"; + public static final String GFLOWER_MUNCHDEW = "munchdew"; + public static final String GFLOWER_ENTROPINNYUM = "entropinnyum"; + public static final String GFLOWER_KEKIMURUS = "kekimurus"; + public static final String GFLOWER_GOURMARYLLIS = "gourmaryllis"; + public static final String GFLOWER_NARSLIMMUS = "narslimmus"; + public static final String GFLOWER_SPECTROLUS = "spectrolus"; + public static final String GFLOWER_RAFFLOWSIA = "rafflowsia"; + public static final String GFLOWER_DANDELIFEON = "dandelifeon"; - public static final String DEVICE_PYLON = "pylon"; - public static final String DEVICE_MANA_ENCHANTING = "manaEnchanting"; - public static final String DEVICE_TURNTABLE = "turntable"; - public static final String DEVICE_ALCHEMY = "manaAlchemy"; - public static final String DEVICE_OPEN_CRATE = "openCrate"; - public static final String DEVICE_FOREST_EYE = "forestEye"; - public static final String DEVICE_FOREST_DRUM = "forestDrum"; - public static final String DEVICE_PLATFORM = "platform"; - public static final String DEVICE_MANA_CONJURATION = "manaConjuration"; - public static final String DEVICE_SPECTRAL_PLATFORM = "spectralPlatform"; - public static final String DEVICE_GATHER_DRUM = "gatherDrum"; - public static final String DEVICE_CRAFT_CRATE = "craftCrate"; - public static final String DEVICE_BREWERY = "brewery"; - public static final String DEVICE_FLASKS = "flasks"; - public static final String DEVICE_COMPLEX_BREWS = "complexBrews"; - public static final String DEVICE_INCENSE = "incense"; - public static final String DEVICE_HOURGLASS = "hourglass"; - public static final String DEVICE_GHOST_RAIL = "ghostRail"; - public static final String DEVICE_CANOPY_DRUM = "canopyDrum"; - public static final String DEVICE_COCOON = "cocoon"; - public static final String DEVICE_MANA_BOMB = "manaBomb"; - public static final String DEVICE_TERU_TERU_BOZU = "teruTeruBozu"; - public static final String DEVICE_AVATAR = "avatar"; - public static final String DEVICE_FEL_PUMPKIN = "felPumpkin"; + public static final String DEVICE_PYLON = "pylon"; + public static final String DEVICE_MANA_ENCHANTING = "manaEnchanting"; + public static final String DEVICE_TURNTABLE = "turntable"; + public static final String DEVICE_ALCHEMY = "manaAlchemy"; + public static final String DEVICE_OPEN_CRATE = "openCrate"; + public static final String DEVICE_FOREST_EYE = "forestEye"; + public static final String DEVICE_FOREST_DRUM = "forestDrum"; + public static final String DEVICE_PLATFORM = "platform"; + public static final String DEVICE_MANA_CONJURATION = "manaConjuration"; + public static final String DEVICE_SPECTRAL_PLATFORM = "spectralPlatform"; + public static final String DEVICE_GATHER_DRUM = "gatherDrum"; + public static final String DEVICE_CRAFT_CRATE = "craftCrate"; + public static final String DEVICE_BREWERY = "brewery"; + public static final String DEVICE_FLASKS = "flasks"; + public static final String DEVICE_COMPLEX_BREWS = "complexBrews"; + public static final String DEVICE_INCENSE = "incense"; + public static final String DEVICE_HOURGLASS = "hourglass"; + public static final String DEVICE_GHOST_RAIL = "ghostRail"; + public static final String DEVICE_CANOPY_DRUM = "canopyDrum"; + public static final String DEVICE_COCOON = "cocoon"; + public static final String DEVICE_MANA_BOMB = "manaBomb"; + public static final String DEVICE_TERU_TERU_BOZU = "teruTeruBozu"; + public static final String DEVICE_AVATAR = "avatar"; + public static final String DEVICE_FEL_PUMPKIN = "felPumpkin"; - public static final String TOOL_MANA_BLASTER = "manaBlaster"; - public static final String TOOL_GRASS_SEEDS = "grassSeeds"; - public static final String TOOL_DIRT_ROD = "dirtRod"; - public static final String TOOL_TERRAFORM_ROD = "terraformRod"; - public static final String TOOL_MANASTEEL_GEAR = "manaGear"; - public static final String TOOL_TERRASTEEL_ARMOR = "terrasteelArmor"; - public static final String TOOL_GRASS_HORN = "grassHorn"; - public static final String TOOL_TERRA_SWORD = "terraSword"; - public static final String TOOL_TERRA_PICK = "terraPick"; - public static final String TOOL_WATER_ROD = "waterRod"; - public static final String TOOL_ELF_GEAR = "elfGear"; - public static final String TOOL_OPEN_BUCKET = "openBucket"; - public static final String TOOL_RAINBOW_ROD = "rainbowRod"; - public static final String TOOL_TORNADO_ROD = "tornadoRod"; - public static final String TOOL_FIRE_ROD = "fireRod"; - public static final String TOOL_VINE_BALL = "vineBall"; - public static final String TOOL_LAPUTA_SHARD = "laputaShard"; - public static final String TOOL_VIRUS = "virus"; - public static final String TOOL_SKY_DIRT_ROD = "skyDirtRod"; - public static final String TOOL_GLASS_PICK = "glassPick"; - public static final String TOOL_DIVINING_ROD = "diviningRod"; - public static final String TOOL_GRAVITY_ROD = "gravityRod"; - public static final String TOOL_REGEN_IVY = "regenIvy"; - public static final String TOOL_MISSILE_ROD = "missileRod"; - public static final String TOOL_CRAFTING_HALO = "craftingHalo"; - public static final String TOOL_CLIP = "clip"; - public static final String TOOL_COBBLE_ROD = "cobbleRod"; - public static final String TOOL_SMELT_ROD = "smeltRod"; - public static final String TOOL_WORLD_SEED = "worldSeed"; - public static final String TOOL_SPELL_CLOTH = "spellCloth"; - public static final String TOOL_THORN_CHAKRAM = "thornChakram"; - public static final String TOOL_FIRE_CHAKRAM = "fireChakram"; - public static final String TOOL_OVERGROWTH_SEED = "overgrowthSeed"; - public static final String TOOL_LIVINGWOOD_BOW = "livingwoodBow"; - public static final String TOOL_CRYSTAL_BOW = "crystalBow"; - public static final String TOOL_TEMPERANCE_STONE = "temperanceStone"; - public static final String TOOL_TERRA_AXE = "terraAxe"; - public static final String TOOL_OBEDIENCE_STICK = "obedienceStick"; - public static final String TOOL_SLIME_BOTTLE = "slimeBottle"; - public static final String TOOL_EXCHANGE_ROD = "exchangeRod"; - public static final String TOOL_MANAWEAVE = "manaweave"; - public static final String TOOL_AUTOCRAFTING_HALO = "autocraftingHalo"; - public static final String TOOL_SEXTANT = "sextant"; + public static final String TOOL_MANA_BLASTER = "manaBlaster"; + public static final String TOOL_GRASS_SEEDS = "grassSeeds"; + public static final String TOOL_DIRT_ROD = "dirtRod"; + public static final String TOOL_TERRAFORM_ROD = "terraformRod"; + public static final String TOOL_MANASTEEL_GEAR = "manaGear"; + public static final String TOOL_TERRASTEEL_ARMOR = "terrasteelArmor"; + public static final String TOOL_GRASS_HORN = "grassHorn"; + public static final String TOOL_TERRA_SWORD = "terraSword"; + public static final String TOOL_TERRA_PICK = "terraPick"; + public static final String TOOL_WATER_ROD = "waterRod"; + public static final String TOOL_ELF_GEAR = "elfGear"; + public static final String TOOL_OPEN_BUCKET = "openBucket"; + public static final String TOOL_RAINBOW_ROD = "rainbowRod"; + public static final String TOOL_TORNADO_ROD = "tornadoRod"; + public static final String TOOL_FIRE_ROD = "fireRod"; + public static final String TOOL_VINE_BALL = "vineBall"; + public static final String TOOL_LAPUTA_SHARD = "laputaShard"; + public static final String TOOL_VIRUS = "virus"; + public static final String TOOL_SKY_DIRT_ROD = "skyDirtRod"; + public static final String TOOL_GLASS_PICK = "glassPick"; + public static final String TOOL_DIVINING_ROD = "diviningRod"; + public static final String TOOL_GRAVITY_ROD = "gravityRod"; + public static final String TOOL_REGEN_IVY = "regenIvy"; + public static final String TOOL_MISSILE_ROD = "missileRod"; + public static final String TOOL_CRAFTING_HALO = "craftingHalo"; + public static final String TOOL_CLIP = "clip"; + public static final String TOOL_COBBLE_ROD = "cobbleRod"; + public static final String TOOL_SMELT_ROD = "smeltRod"; + public static final String TOOL_WORLD_SEED = "worldSeed"; + public static final String TOOL_SPELL_CLOTH = "spellCloth"; + public static final String TOOL_THORN_CHAKRAM = "thornChakram"; + public static final String TOOL_FIRE_CHAKRAM = "fireChakram"; + public static final String TOOL_OVERGROWTH_SEED = "overgrowthSeed"; + public static final String TOOL_LIVINGWOOD_BOW = "livingwoodBow"; + public static final String TOOL_CRYSTAL_BOW = "crystalBow"; + public static final String TOOL_TEMPERANCE_STONE = "temperanceStone"; + public static final String TOOL_TERRA_AXE = "terraAxe"; + public static final String TOOL_OBEDIENCE_STICK = "obedienceStick"; + public static final String TOOL_SLIME_BOTTLE = "slimeBottle"; + public static final String TOOL_EXCHANGE_ROD = "exchangeRod"; + public static final String TOOL_MANAWEAVE = "manaweave"; + public static final String TOOL_AUTOCRAFTING_HALO = "autocraftingHalo"; + public static final String TOOL_SEXTANT = "sextant"; - public static final String ENDER_AIR = "enderAir"; - public static final String ENDER_ENDER_EYE_BLOCK = "enderEyeBlock"; - public static final String ENDER_PISTON_RELAY = "pistonRelay"; - public static final String ENDER_ENDER_HAND = "enderHand"; - public static final String ENDER_ENDER_DAGGER = "enderDagger"; - public static final String ENDER_SPAWNER_CLAW = "spawnerClaw"; - public static final String ENDER_RED_STRING = "redString"; - public static final String ENDER_FLIGHT_TIARA = "flightTiara"; - public static final String ENDER_CORPOREA = "corporea"; - public static final String ENDER_CORPOREA_INDEX = "corporeaIndex"; - public static final String ENDER_CORPOREA_FUNNEL = "corporeaFunnel"; - public static final String ENDER_CORPOREA_INTERCEPTOR = "corporeaInterceptor"; - public static final String ENDER_END_STONE_DECOR = "endStoneDecor"; - public static final String ENDER_SPAWNER_MOVER = "spawnerMover"; - public static final String ENDER_KEEP_IVY = "keepIvy"; - public static final String ENDER_BLACK_HOLE_TALISMAN = "blackHoleTalisman"; - public static final String ENDER_CORPOREA_CRYSTAL_CUBE = "corporeaCrystalCube"; - public static final String ENDER_LUMINIZER_TRANSPORT = "luminizerTransport"; - public static final String ENDER_STAR_SWORD = "starSword"; - public static final String ENDER_THUNDER_SWORD = "thunderSword"; - public static final String ENDER_CORPOREA_RETAINER = "corporeaRetainer"; + public static final String ENDER_AIR = "enderAir"; + public static final String ENDER_ENDER_EYE_BLOCK = "enderEyeBlock"; + public static final String ENDER_PISTON_RELAY = "pistonRelay"; + public static final String ENDER_ENDER_HAND = "enderHand"; + public static final String ENDER_ENDER_DAGGER = "enderDagger"; + public static final String ENDER_SPAWNER_CLAW = "spawnerClaw"; + public static final String ENDER_RED_STRING = "redString"; + public static final String ENDER_FLIGHT_TIARA = "flightTiara"; + public static final String ENDER_CORPOREA = "corporea"; + public static final String ENDER_CORPOREA_INDEX = "corporeaIndex"; + public static final String ENDER_CORPOREA_FUNNEL = "corporeaFunnel"; + public static final String ENDER_CORPOREA_INTERCEPTOR = "corporeaInterceptor"; + public static final String ENDER_END_STONE_DECOR = "endStoneDecor"; + public static final String ENDER_SPAWNER_MOVER = "spawnerMover"; + public static final String ENDER_KEEP_IVY = "keepIvy"; + public static final String ENDER_BLACK_HOLE_TALISMAN = "blackHoleTalisman"; + public static final String ENDER_CORPOREA_CRYSTAL_CUBE = "corporeaCrystalCube"; + public static final String ENDER_LUMINIZER_TRANSPORT = "luminizerTransport"; + public static final String ENDER_STAR_SWORD = "starSword"; + public static final String ENDER_THUNDER_SWORD = "thunderSword"; + public static final String ENDER_CORPOREA_RETAINER = "corporeaRetainer"; - public static final String BAUBLE_INTRO = "bIntro"; - public static final String BAUBLE_COSMETIC = "cosmeticBaubles"; - public static final String BAUBLE_TINY_PLANET = "tinyPlanet"; - public static final String BAUBLE_MANA_RING = "manaRing"; - public static final String BAUBLE_AURA_RING = "auraRing"; - public static final String BAUBLE_TRAVEL_BELT = "travelBelt"; - public static final String BAUBLE_KNOCKBACK_BELT = "knockbackBelt"; - public static final String BAUBLE_ICE_PENDANT = "icePendant"; - public static final String BAUBLE_LAVA_PENDANT = "lavaPendant"; - public static final String BAUBLE_GOLDEN_LAUREL = "goldenLaurel"; - public static final String BAUBLE_WATER_RING = "waterRing"; - public static final String BAUBLE_MINING_RING = "miningRing"; - public static final String BAUBLE_MAGNET_RING = "magnetRing"; - public static final String BAUBLE_DIVA_CHARM = "divaCharm"; - public static final String BAUBLE_PIXIE_RING = "pixieRing"; - public static final String BAUBLE_SUPER_TRAVEL_BELT = "superTravelBelt"; - public static final String BAUBLE_REACH_RING = "reachRing"; - public static final String BAUBLE_ITEM_FINDER = "itemFinder"; - public static final String BAUBLE_SUPER_LAVA_PENDANT = "superLavaPendant"; - public static final String BAUBLE_BLOOD_PENDANT = "bloodPendant"; - public static final String BAUBLE_JUDGEMENT_CLOAKS = "judgementCloaks"; - public static final String BAUBLE_MONOCLE = "monocle"; - public static final String BAUBLE_SWAP_RING = "swapRing"; - public static final String BAUBLE_SPEED_UP_BELT = "speedUpBelt"; - public static final String BAUBLE_BOX = "baubleBox"; + public static final String BAUBLE_INTRO = "bIntro"; + public static final String BAUBLE_COSMETIC = "cosmeticBaubles"; + public static final String BAUBLE_TINY_PLANET = "tinyPlanet"; + public static final String BAUBLE_MANA_RING = "manaRing"; + public static final String BAUBLE_AURA_RING = "auraRing"; + public static final String BAUBLE_TRAVEL_BELT = "travelBelt"; + public static final String BAUBLE_KNOCKBACK_BELT = "knockbackBelt"; + public static final String BAUBLE_ICE_PENDANT = "icePendant"; + public static final String BAUBLE_LAVA_PENDANT = "lavaPendant"; + public static final String BAUBLE_GOLDEN_LAUREL = "goldenLaurel"; + public static final String BAUBLE_WATER_RING = "waterRing"; + public static final String BAUBLE_MINING_RING = "miningRing"; + public static final String BAUBLE_MAGNET_RING = "magnetRing"; + public static final String BAUBLE_DIVA_CHARM = "divaCharm"; + public static final String BAUBLE_PIXIE_RING = "pixieRing"; + public static final String BAUBLE_SUPER_TRAVEL_BELT = "superTravelBelt"; + public static final String BAUBLE_REACH_RING = "reachRing"; + public static final String BAUBLE_ITEM_FINDER = "itemFinder"; + public static final String BAUBLE_SUPER_LAVA_PENDANT = "superLavaPendant"; + public static final String BAUBLE_BLOOD_PENDANT = "bloodPendant"; + public static final String BAUBLE_JUDGEMENT_CLOAKS = "judgementCloaks"; + public static final String BAUBLE_MONOCLE = "monocle"; + public static final String BAUBLE_SWAP_RING = "swapRing"; + public static final String BAUBLE_SPEED_UP_BELT = "speedUpBelt"; + public static final String BAUBLE_BOX = "baubleBox"; - public static final String ALF_INTRO = "aIntro"; - public static final String ALF_MESSAGE = "elfMessage"; - public static final String ALF_RESOURCES = "elfResources"; - public static final String ALF_GAIA_RITUAL = "gaiaRitual"; - public static final String ALF_GAIA_RITUAL_HARDMODE = "gaiaRitualHardmode"; - public static final String ALF_LORE = "elvenLore"; - public static final String ALF_RELICS = "relics"; - public static final String ALF_RELIC_INFO = "relicInfo"; - public static final String ALF_INFINITE_FRUIT = "infiniteFruit"; - public static final String ALF_KING_KEY = "kingKey"; - public static final String ALF_FLUGEL_EYE = "flugelEye"; - public static final String ALF_THOR_RING = "thorRing"; - public static final String ALF_LOKI_RING = "lokiRing"; - public static final String ALF_ODIN_RING = "odinRing"; + public static final String ALF_INTRO = "aIntro"; + public static final String ALF_MESSAGE = "elfMessage"; + public static final String ALF_RESOURCES = "elfResources"; + public static final String ALF_GAIA_RITUAL = "gaiaRitual"; + public static final String ALF_GAIA_RITUAL_HARDMODE = "gaiaRitualHardmode"; + public static final String ALF_LORE = "elvenLore"; + public static final String ALF_RELICS = "relics"; + public static final String ALF_RELIC_INFO = "relicInfo"; + public static final String ALF_INFINITE_FRUIT = "infiniteFruit"; + public static final String ALF_KING_KEY = "kingKey"; + public static final String ALF_FLUGEL_EYE = "flugelEye"; + public static final String ALF_THOR_RING = "thorRing"; + public static final String ALF_LOKI_RING = "lokiRing"; + public static final String ALF_ODIN_RING = "odinRing"; - public static final String MISC_UNSTABLE_BLOCKS = "unstableBlocks"; - public static final String MISC_DECORATIVE_BLOCKS = "decorativeBlocks"; - public static final String MISC_DISPENSER_TWEAKS = "dispenserTweaks"; - public static final String MISC_SHINY_FLOWERS = "shinyFlowers"; - public static final String MISC_PRISMARINE = "prismarine"; - public static final String MISC_SHEDDING = "shedding"; - public static final String MISC_TINY_POTATO = "tinyPotato"; - public static final String MISC_HEAD_CREATING = "headCreating"; - public static final String MISC_AZULEJO = "azulejo"; - public static final String MISC_STARFIELD = "starfield"; - public static final String MISC_DIRT_PATH = "dirtPath"; - public static final String MISC_MUSHROOMS = "mushrooms"; - public static final String MISC_PHANTOM_INK = "phantomInk"; - public static final String MISC_STONE_ALCHEMY = "stoneAlchemy"; - public static final String MISC_BLAZE_BLOCK = "blazeBlock"; - public static final String MISC_CHALLENGES = "challenges"; - public static final String MISC_CACOPHONIUM = "cacophonium"; - public static final String MISC_PAVEMENT = "pavement"; - public static final String MISC_PRENTING_DECAY = "preventingDecay"; + public static final String MISC_UNSTABLE_BLOCKS = "unstableBlocks"; + public static final String MISC_DECORATIVE_BLOCKS = "decorativeBlocks"; + public static final String MISC_DISPENSER_TWEAKS = "dispenserTweaks"; + public static final String MISC_SHINY_FLOWERS = "shinyFlowers"; + public static final String MISC_PRISMARINE = "prismarine"; + public static final String MISC_SHEDDING = "shedding"; + public static final String MISC_TINY_POTATO = "tinyPotato"; + public static final String MISC_HEAD_CREATING = "headCreating"; + public static final String MISC_AZULEJO = "azulejo"; + public static final String MISC_STARFIELD = "starfield"; + public static final String MISC_DIRT_PATH = "dirtPath"; + public static final String MISC_MUSHROOMS = "mushrooms"; + public static final String MISC_PHANTOM_INK = "phantomInk"; + public static final String MISC_STONE_ALCHEMY = "stoneAlchemy"; + public static final String MISC_BLAZE_BLOCK = "blazeBlock"; + public static final String MISC_CHALLENGES = "challenges"; + public static final String MISC_CACOPHONIUM = "cacophonium"; + public static final String MISC_PAVEMENT = "pavement"; + public static final String MISC_PRENTING_DECAY = "preventingDecay"; + + public static final String MISC_TC_INTEGRATION = "tcIntegration"; + public static final String MISC_BC_INTEGRATION = "bcIntegration"; + public static final String MISC_BANNERS = "banners"; - public static final String MISC_TC_INTEGRATION = "tcIntegration"; - public static final String MISC_BC_INTEGRATION = "bcIntegration"; - public static final String MISC_BANNERS = "banners"; } + diff --git a/src/main/java/vazkii/botania/common/lib/LibMisc.java b/src/main/java/vazkii/botania/common/lib/LibMisc.java index 3bfcb530ca..2bbc98d156 100644 --- a/src/main/java/vazkii/botania/common/lib/LibMisc.java +++ b/src/main/java/vazkii/botania/common/lib/LibMisc.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jan 13, 2014, 6:32:05 PM (GMT)] */ package vazkii.botania.common.lib; @@ -14,30 +14,32 @@ public final class LibMisc { - // Mod Constants - public static final String MOD_ID = "Botania"; - public static final String MOD_NAME = MOD_ID; - public static final String VERSION = "GRADLETOKEN_VERSION"; - public static final String DEPENDENCIES = "required-after:Baubles;after:Thaumcraft"; + // Mod Constants + public static final String MOD_ID = "Botania"; + public static final String MOD_NAME = MOD_ID; + public static final String VERSION = "GRADLETOKEN_VERSION"; + public static final String DEPENDENCIES = "required-after:Baubles;after:Thaumcraft"; - // Network Contants - public static final String NETWORK_CHANNEL = MOD_ID; + // Network Contants + public static final String NETWORK_CHANNEL = MOD_ID; - // Proxy Constants - public static final String PROXY_COMMON = "vazkii.botania.common.core.proxy.CommonProxy"; - public static final String PROXY_CLIENT = "vazkii.botania.client.core.proxy.ClientProxy"; - public static final String GUI_FACTORY = "vazkii.botania.client.core.proxy.GuiFactory"; + // Proxy Constants + public static final String PROXY_COMMON = "vazkii.botania.common.core.proxy.CommonProxy"; + public static final String PROXY_CLIENT = "vazkii.botania.client.core.proxy.ClientProxy"; + public static final String GUI_FACTORY = "vazkii.botania.client.core.proxy.GuiFactory"; - // IMC Keys - public static final String BLACKLIST_ITEM = "blackListItem"; + // IMC Keys + public static final String BLACKLIST_ITEM = "blackListItem"; - public static final ForgeDirection[] CARDINAL_DIRECTIONS = - new ForgeDirection[] {ForgeDirection.NORTH, ForgeDirection.SOUTH, ForgeDirection.EAST, ForgeDirection.WEST}; + public static final ForgeDirection[] CARDINAL_DIRECTIONS = new ForgeDirection[] { + ForgeDirection.NORTH, ForgeDirection.SOUTH, ForgeDirection.EAST, ForgeDirection.WEST + }; + + public static final int[] CONTROL_CODE_COLORS = new int[] { + 0x000000, 0x0000AA, 0x00AA00, 0x00AAAA, + 0xAA0000, 0xAA00AA, 0xFFAA00, 0xAAAAAA, + 0x555555, 0x5555FF, 0x55FF55, 0x55FFFF, + 0xFF5555, 0xFF55FF, 0xFFFF55, 0xFFFFFF + }; - public static final int[] CONTROL_CODE_COLORS = new int[] { - 0x000000, 0x0000AA, 0x00AA00, 0x00AAAA, - 0xAA0000, 0xAA00AA, 0xFFAA00, 0xAAAAAA, - 0x555555, 0x5555FF, 0x55FF55, 0x55FFFF, - 0xFF5555, 0xFF55FF, 0xFFFF55, 0xFFFFFF - }; } diff --git a/src/main/java/vazkii/botania/common/lib/LibObfuscation.java b/src/main/java/vazkii/botania/common/lib/LibObfuscation.java index 8e3c9d4972..44f27a3c61 100644 --- a/src/main/java/vazkii/botania/common/lib/LibObfuscation.java +++ b/src/main/java/vazkii/botania/common/lib/LibObfuscation.java @@ -2,90 +2,91 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jan 17, 2014, 4:52:15 PM (GMT)] */ package vazkii.botania.common.lib; public final class LibObfuscation { - // EffectRenderer - public static final String[] PARTICLE_TEXTURES = new String[] {"particleTextures", "field_110737_b", "b"}; + // EffectRenderer + public static final String[] PARTICLE_TEXTURES = new String[] { "particleTextures", "field_110737_b", "b" }; - // EntityAINearestAttackableTarget - public static final String[] TARGET_CLASS = new String[] {"targetClass", "field_75307_b", "a"}; - public static final String[] TARGET_ENTITY = new String[] {"targetEntity", "field_75309_a", "g"}; + // EntityAINearestAttackableTarget + public static final String[] TARGET_CLASS = new String[] { "targetClass", "field_75307_b", "a" }; + public static final String[] TARGET_ENTITY = new String[] { "targetEntity", "field_75309_a", "g" }; - // EntityAIAttackOnCollide - public static final String[] CLASS_TARGET = new String[] {"classTarget", "field_75444_h", "g"}; + // EntityAIAttackOnCollide + public static final String[] CLASS_TARGET = new String[] { "classTarget", "field_75444_h", "g" }; - // EntityAIAvoidEntity - public static final String[] TARGET_ENTITY_CLASS = new String[] {"targetEntityClass", "field_75381_h", "i"}; + // EntityAIAvoidEntity + public static final String[] TARGET_ENTITY_CLASS = new String[] { "targetEntityClass", "field_75381_h", "i" }; - // EntityCreeper - public static final String[] TIME_SINCE_IGNITED = new String[] {"timeSinceIgnited", "field_70833_d", "bq"}; + // EntityCreeper + public static final String[] TIME_SINCE_IGNITED = new String[] { "timeSinceIgnited", "field_70833_d", "bq" }; - // ThreadDownloadImageData - public static final String[] TEXTURE_UPLOADED = new String[] {"textureUploaded", "field_110559_g", "i"}; - public static final String[] BUFFERED_IMAGE = new String[] {"bufferedImage", "field_110560_d", "g"}; + // ThreadDownloadImageData + public static final String[] TEXTURE_UPLOADED = new String[] { "textureUploaded", "field_110559_g", "i" }; + public static final String[] BUFFERED_IMAGE = new String[] { "bufferedImage", "field_110560_d", "g" }; - // Entity - public static final String[] IS_IMMUNE_TO_FIRE = new String[] {"isImmuneToFire", "field_70178_ae", "ag"}; + // Entity + public static final String[] IS_IMMUNE_TO_FIRE = new String[] { "isImmuneToFire", "field_70178_ae", "ag" }; - // ItemReed - public static final String[] REED_ITEM = new String[] {"field_150935_a", "a"}; + // ItemReed + public static final String[] REED_ITEM = new String[] { "field_150935_a", "a" }; - // EntityAnimal - public static final String[] IN_LOVE = new String[] {"inLove", "field_70881_d", "bp"}; + // EntityAnimal + public static final String[] IN_LOVE = new String[] { "inLove", "field_70881_d", "bp" }; - // EntityPlayer - public static final String[] ITEM_IN_USE = new String[] {"itemInUse", "field_71074_e", "f"}; - public static final String[] ITEM_IN_USE_COUNT = new String[] {"itemInUseCount", "field_71072_f", "g"}; + // EntityPlayer + public static final String[] ITEM_IN_USE = new String[] { "itemInUse", "field_71074_e", "f" }; + public static final String[] ITEM_IN_USE_COUNT = new String[] { "itemInUseCount", "field_71072_f", "g" }; - // Potion - public static final String[] IS_BAD_EFFECT = new String[] {"isBadEffect", "field_76418_K", "J"}; + // Potion + public static final String[] IS_BAD_EFFECT = new String[] { "isBadEffect", "field_76418_K", "J" }; - // EntityHorse - public static final String[] HORSE_JUMP_STRENGTH = new String[] {"horseJumpStrength", "field_110271_bv", "bv"}; - public static final String[] HORSE_CHEST = new String[] {"horseChest", "field_110296_bG", "bG"}; + // EntityHorse + public static final String[] HORSE_JUMP_STRENGTH = new String[] { "horseJumpStrength", "field_110271_bv", "bv" }; + public static final String[] HORSE_CHEST = new String[] { "horseChest", "field_110296_bG", "bG" }; - // PlayerControllerMP - public static final String[] NET_CLIENT_HANDLER = new String[] {"netClientHandler", "field_78774_b", "b"}; - public static final String[] CURRENT_GAME_TYPE = new String[] {"currentGameType", "field_78779_k", "k"}; + // PlayerControllerMP + public static final String[] NET_CLIENT_HANDLER = new String[] { "netClientHandler", "field_78774_b", "b" }; + public static final String[] CURRENT_GAME_TYPE = new String[] { "currentGameType", "field_78779_k", "k" }; - // MobSpawnerBaseLogic - public static final String[] SPAWN_RANGE = new String[] {"spawnRange", "field_98290_m", "m"}; - public static final String[] SPAWN_COUNT = new String[] {"spawnCount", "field_98294_i", "i"}; - public static final String[] MAX_NEARBY_ENTITIES = new String[] {"maxNearbyEntities", "field_98292_k", "k"}; - public static final String[] MAX_SPAWN_DELAY = new String[] {"maxSpawnDelay", "field_98293_h", "h"}; - public static final String[] MIN_SPAWN_DELAY = new String[] {"minSpawnDelay", "field_98283_g", "g"}; - public static final String[] POTENTIAL_ENTITY_SPAWNS = new String[] {"potentialEntitySpawns", "field_98285_e", "e"}; + // MobSpawnerBaseLogic + public static final String[] SPAWN_RANGE = new String[] { "spawnRange", "field_98290_m", "m" }; + public static final String[] SPAWN_COUNT = new String[] { "spawnCount", "field_98294_i", "i" }; + public static final String[] MAX_NEARBY_ENTITIES = new String[] { "maxNearbyEntities", "field_98292_k", "k" }; + public static final String[] MAX_SPAWN_DELAY = new String[] { "maxSpawnDelay", "field_98293_h", "h" }; + public static final String[] MIN_SPAWN_DELAY = new String[] { "minSpawnDelay", "field_98283_g", "g" }; + public static final String[] POTENTIAL_ENTITY_SPAWNS = new String[] { "potentialEntitySpawns", "field_98285_e", "e" }; - // GuiIngame - public static final String[] REMAINING_HIGHLIGHT_TICKS = - new String[] {"remainingHighlightTicks", "field_92017_k", "r"}; + // GuiIngame + public static final String[] REMAINING_HIGHLIGHT_TICKS = new String[] { "remainingHighlightTicks", "field_92017_k", "r" }; - // EntityThrowable - public static final String[] THROWER = new String[] {"thrower", "field_70192_c", "g"}; + // EntityThrowable + public static final String[] THROWER = new String[] { "thrower", "field_70192_c", "g" }; - // GuiContainer - public static final String[] THE_SLOT = new String[] {"theSlot", "field_147006_u", "u"}; + // GuiContainer + public static final String[] THE_SLOT = new String[] { "theSlot", "field_147006_u", "u" }; - // GuiChat - public static final String[] INPUT_FIELD = new String[] {"inputField", "field_146415_a", "a"}; - public static final String[] COMPLETE_FLAG = new String[] {"field_146414_r", "r"}; + // GuiChat + public static final String[] INPUT_FIELD = new String[] { "inputField", "field_146415_a", "a" }; + public static final String[] COMPLETE_FLAG = new String[] { "field_146414_r", "r" }; - // Entityliving - public static final String[] GET_LIVING_SOUND = new String[] {"getLivingSound", "func_70639_aQ", "t"}; + // Entityliving + public static final String[] GET_LIVING_SOUND = new String[] { "getLivingSound", "func_70639_aQ", "t" }; - // TextureAtlasSprite - public static final String[] ANIMATION_METADATA = new String[] {"animationMetadata", "field_110982_k", "j"}; + // TextureAtlasSprite + public static final String[] ANIMATION_METADATA = new String[] { "animationMetadata", "field_110982_k", "j" }; + + // RenderGlobal + public static final String[] STAR_GL_CALL_LIST = new String[] { "starGLCallList", "field_72772_v", "F" }; + public static final String[] GL_SKY_LIST = new String[] { "glSkyList", "field_72771_w", "G" }; + public static final String[] GL_SKY_LIST2 = new String[] { "glSkyList2", "field_72781_x", "H" }; + - // RenderGlobal - public static final String[] STAR_GL_CALL_LIST = new String[] {"starGLCallList", "field_72772_v", "F"}; - public static final String[] GL_SKY_LIST = new String[] {"glSkyList", "field_72771_w", "G"}; - public static final String[] GL_SKY_LIST2 = new String[] {"glSkyList2", "field_72781_x", "H"}; } diff --git a/src/main/java/vazkii/botania/common/lib/LibOreDict.java b/src/main/java/vazkii/botania/common/lib/LibOreDict.java index b08bb208fc..145ed48279 100644 --- a/src/main/java/vazkii/botania/common/lib/LibOreDict.java +++ b/src/main/java/vazkii/botania/common/lib/LibOreDict.java @@ -2,97 +2,97 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jan 19, 2014, 4:30:32 PM (GMT)] */ package vazkii.botania.common.lib; public final class LibOreDict { - public static final String LEXICON = "lexicaBotania"; - public static final String PESTLE_AND_MORTAR = "pestleAndMortar"; - public static final String TWIG_WAND = "twigWand"; - public static final String LIVING_WOOD = "livingwood"; - public static final String LIVING_ROCK = "livingrock"; - public static final String MANA_STEEL = "ingotManasteel"; - public static final String MANA_PEARL = "manaPearl"; - public static final String MANA_DIAMOND = "manaDiamond"; - public static final String LIVINGWOOD_TWIG = "livingwoodTwig"; - public static final String TERRA_STEEL = "ingotTerrasteel"; - public static final String LIFE_ESSENCE = "eternalLifeEssence"; - public static final String REDSTONE_ROOT = "redstoneRoot"; - public static final String DREAM_WOOD = "dreamwood"; - public static final String ELEMENTIUM = "ingotElvenElementium"; - public static final String PIXIE_DUST = "elvenPixieDust"; - public static final String DRAGONSTONE = "elvenDragonstone"; - public static final String PRISMARINE_SHARD = "shardPrismarine"; - public static final String PLACEHOLDER = "bPlaceholder"; - public static final String RED_STRING = "bRedString"; - public static final String DREAMWOOD_TWIG = "dreamwoodTwig"; - public static final String GAIA_INGOT = "gaiaIngot"; - public static final String ENDER_AIR_BOTTLE = "bEnderAirBottle"; - public static final String MANA_STRING = "manaString"; - public static final String MANASTEEL_NUGGET = "nuggetManasteel"; - public static final String TERRASTEEL_NUGGET = "nuggetTerrasteel"; - public static final String ELEMENTIUM_NUGGET = "nuggetElvenElementium"; - public static final String ROOT = "livingRoot"; - public static final String PEBBLE = "pebble"; - public static final String MANAWEAVE_CLOTH = "clothManaweave"; - public static final String MANA_POWDER = "powderMana"; + public static final String LEXICON = "lexicaBotania"; + public static final String PESTLE_AND_MORTAR = "pestleAndMortar"; + public static final String TWIG_WAND = "twigWand"; + public static final String LIVING_WOOD = "livingwood"; + public static final String LIVING_ROCK = "livingrock"; + public static final String MANA_STEEL = "ingotManasteel"; + public static final String MANA_PEARL = "manaPearl"; + public static final String MANA_DIAMOND = "manaDiamond"; + public static final String LIVINGWOOD_TWIG = "livingwoodTwig"; + public static final String TERRA_STEEL = "ingotTerrasteel"; + public static final String LIFE_ESSENCE = "eternalLifeEssence"; + public static final String REDSTONE_ROOT = "redstoneRoot"; + public static final String DREAM_WOOD = "dreamwood"; + public static final String ELEMENTIUM = "ingotElvenElementium"; + public static final String PIXIE_DUST = "elvenPixieDust"; + public static final String DRAGONSTONE = "elvenDragonstone"; + public static final String PRISMARINE_SHARD = "shardPrismarine"; + public static final String PLACEHOLDER = "bPlaceholder"; + public static final String RED_STRING = "bRedString"; + public static final String DREAMWOOD_TWIG = "dreamwoodTwig"; + public static final String GAIA_INGOT = "gaiaIngot"; + public static final String ENDER_AIR_BOTTLE = "bEnderAirBottle"; + public static final String MANA_STRING = "manaString"; + public static final String MANASTEEL_NUGGET = "nuggetManasteel"; + public static final String TERRASTEEL_NUGGET = "nuggetTerrasteel"; + public static final String ELEMENTIUM_NUGGET = "nuggetElvenElementium"; + public static final String ROOT = "livingRoot"; + public static final String PEBBLE = "pebble"; + public static final String MANAWEAVE_CLOTH = "clothManaweave"; + public static final String MANA_POWDER = "powderMana"; - public static final String VIAL = "bVial"; - public static final String FLASK = "bFlask"; + public static final String VIAL = "bVial"; + public static final String FLASK = "bFlask"; - public static final String PRISMARINE_BLOCK = "blockPrismarine"; - public static final String BLAZE_BLOCK = "blockBlaze"; + public static final String PRISMARINE_BLOCK = "blockPrismarine"; + public static final String BLAZE_BLOCK = "blockBlaze"; - public static final String[] FLOWER = new String[] { - "mysticFlowerWhite", "mysticFlowerOrange", "mysticFlowerMagenta", "mysticFlowerLightBlue", - "mysticFlowerYellow", "mysticFlowerLime", "mysticFlowerPink", "mysticFlowerGray", - "mysticFlowerLightGray", "mysticFlowerCyan", "mysticFlowerPurple", "mysticFlowerBlue", - "mysticFlowerBrown", "mysticFlowerGreen", "mysticFlowerRed", "mysticFlowerBlack" - }; + public static final String[] FLOWER = new String[] { + "mysticFlowerWhite", "mysticFlowerOrange", "mysticFlowerMagenta", "mysticFlowerLightBlue", + "mysticFlowerYellow", "mysticFlowerLime", "mysticFlowerPink", "mysticFlowerGray", + "mysticFlowerLightGray", "mysticFlowerCyan", "mysticFlowerPurple", "mysticFlowerBlue", + "mysticFlowerBrown", "mysticFlowerGreen", "mysticFlowerRed", "mysticFlowerBlack" + }; - public static final String[] DOUBLE_FLOWER = new String[] { - "mysticFlowerWhiteDouble", "mysticFlowerOrangeDouble", "mysticFlowerMagentaDouble", - "mysticFlowerLightBlueDouble", - "mysticFlowerYellowDouble", "mysticFlowerLimeDouble", "mysticFlowerPinkDouble", "mysticFlowerGrayDouble", - "mysticFlowerLightGrayDouble", "mysticFlowerCyanDouble", "mysticFlowerPurpleDouble", "mysticFlowerBlueDouble", - "mysticFlowerBrownDouble", "mysticFlowerGreenDouble", "mysticFlowerRedDouble", "mysticFlowerBlackDouble" - }; + public static final String[] DOUBLE_FLOWER = new String[] { + "mysticFlowerWhiteDouble", "mysticFlowerOrangeDouble", "mysticFlowerMagentaDouble", "mysticFlowerLightBlueDouble", + "mysticFlowerYellowDouble", "mysticFlowerLimeDouble", "mysticFlowerPinkDouble", "mysticFlowerGrayDouble", + "mysticFlowerLightGrayDouble", "mysticFlowerCyanDouble", "mysticFlowerPurpleDouble", "mysticFlowerBlueDouble", + "mysticFlowerBrownDouble", "mysticFlowerGreenDouble", "mysticFlowerRedDouble", "mysticFlowerBlackDouble" + }; - public static final String[] PETAL = new String[] { - "petalWhite", "petalOrange", "petalMagenta", "petalLightBlue", - "petalYellow", "petalLime", "petalPink", "petalGray", - "petalLightGray", "petalCyan", "petalPurple", "petalBlue", - "petalBrown", "petalGreen", "petalRed", "petalBlack" - }; + public static final String[] PETAL = new String[] { + "petalWhite", "petalOrange", "petalMagenta", "petalLightBlue", + "petalYellow", "petalLime", "petalPink", "petalGray", + "petalLightGray", "petalCyan", "petalPurple", "petalBlue", + "petalBrown", "petalGreen", "petalRed", "petalBlack" + }; - public static final String[] DYE = new String[] { - "dyeWhite", "dyeOrange", "dyeMagenta", "dyeLightBlue", - "dyeYellow", "dyeLime", "dyePink", "dyeGray", - "dyeLightGray", "dyeCyan", "dyePurple", "dyeBlue", - "dyeBrown", "dyeGreen", "dyeRed", "dyeBlack" - }; + public static final String[] DYE = new String[] { + "dyeWhite", "dyeOrange", "dyeMagenta", "dyeLightBlue", + "dyeYellow", "dyeLime", "dyePink", "dyeGray", + "dyeLightGray", "dyeCyan", "dyePurple", "dyeBlue", + "dyeBrown", "dyeGreen", "dyeRed", "dyeBlack" + }; - public static final String[] RUNE = new String[] { - "runeWaterB", "runeFireB", "runeEarthB", "runeAirB", - "runeSpringB", "runeSummerB", "runeAutumnB", "runeWinterB", - "runeManaB", "runeLustB", "runeGluttonyB", "runeGreedB", - "runeSlothB", "runeWrathB", "runeEnvyB", "runePrideB" - }; + public static final String[] RUNE = new String[] { + "runeWaterB", "runeFireB", "runeEarthB", "runeAirB", + "runeSpringB", "runeSummerB", "runeAutumnB", "runeWinterB", + "runeManaB", "runeLustB", "runeGluttonyB", "runeGreedB", + "runeSlothB", "runeWrathB", "runeEnvyB", "runePrideB" + }; - public static final String[] STONE_18_VARIANTS = new String[] { - "stoneAndesite", "stoneBasalt", "stoneDiorite", "stoneGranite", - "stoneAndesitePolished", "stoneBasaltPolished", "stoneDioritePolished", "stoneGranitePolished", - "stoneAndesiteBricks", "stoneBasaltBricks", "stoneDioriteBricks", "stoneGraniteBricks", - "stoneAndesiteChiseled", "stoneBasaltChiseled", "stoneDioriteChiseled", "stoneGraniteChiseled" - }; + public static final String[] STONE_18_VARIANTS = new String[] { + "stoneAndesite", "stoneBasalt", "stoneDiorite", "stoneGranite", + "stoneAndesitePolished", "stoneBasaltPolished", "stoneDioritePolished", "stoneGranitePolished", + "stoneAndesiteBricks", "stoneBasaltBricks", "stoneDioriteBricks", "stoneGraniteBricks", + "stoneAndesiteChiseled", "stoneBasaltChiseled", "stoneDioriteChiseled", "stoneGraniteChiseled" + }; - public static final String[] QUARTZ = new String[] { - "quartzDark", "quartzMana", "quartzBlaze", "quartzLavender", "quartzRed", "quartzElven", "quartzSunny" - }; + public static final String[] QUARTZ = new String[] { + "quartzDark", "quartzMana", "quartzBlaze", + "quartzLavender", "quartzRed", "quartzElven", "quartzSunny" + }; } diff --git a/src/main/java/vazkii/botania/common/lib/LibPotionNames.java b/src/main/java/vazkii/botania/common/lib/LibPotionNames.java index 048b169197..049ca9abb0 100644 --- a/src/main/java/vazkii/botania/common/lib/LibPotionNames.java +++ b/src/main/java/vazkii/botania/common/lib/LibPotionNames.java @@ -2,20 +2,21 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Nov 2, 2014, 10:33:37 PM (GMT)] */ package vazkii.botania.common.lib; public final class LibPotionNames { - public static final String SOUL_CROSS = "soulCross"; - public static final String FEATHER_FEET = "featherFeet"; - public static final String EMPTINESS = "emptiness"; - public static final String BLOODTHIRST = "bloodthirst"; - public static final String ALLURE = "allure"; - public static final String CLEAR = "clear"; + public static final String SOUL_CROSS = "soulCross"; + public static final String FEATHER_FEET = "featherFeet"; + public static final String EMPTINESS = "emptiness"; + public static final String BLOODTHIRST = "bloodthirst"; + public static final String ALLURE = "allure"; + public static final String CLEAR = "clear"; + } diff --git a/src/main/java/vazkii/botania/common/lib/LibTriggerNames.java b/src/main/java/vazkii/botania/common/lib/LibTriggerNames.java index 28863fed0a..6fc99c6bb9 100644 --- a/src/main/java/vazkii/botania/common/lib/LibTriggerNames.java +++ b/src/main/java/vazkii/botania/common/lib/LibTriggerNames.java @@ -1,10 +1,12 @@ package vazkii.botania.common.lib; + public class LibTriggerNames { - public static final String TRIGGER_PREFIX = "botania.triggers."; + public static final String TRIGGER_PREFIX = "botania.triggers."; + + public static final String TRIGGER_MANA_PREFIX = TRIGGER_PREFIX + "mana"; + public static final String TRIGGER_MANA_DETECTOR = TRIGGER_PREFIX + "manaDetector"; + public static final String TRIGGER_RUNE_ALTAR_CAN_CRAFT = TRIGGER_PREFIX + "runeAltarCanCraft"; - public static final String TRIGGER_MANA_PREFIX = TRIGGER_PREFIX + "mana"; - public static final String TRIGGER_MANA_DETECTOR = TRIGGER_PREFIX + "manaDetector"; - public static final String TRIGGER_RUNE_ALTAR_CAN_CRAFT = TRIGGER_PREFIX + "runeAltarCanCraft"; } diff --git a/src/main/java/vazkii/botania/common/network/GuiHandler.java b/src/main/java/vazkii/botania/common/network/GuiHandler.java index bcced2a0c7..0dd9fea9f4 100644 --- a/src/main/java/vazkii/botania/common/network/GuiHandler.java +++ b/src/main/java/vazkii/botania/common/network/GuiHandler.java @@ -2,15 +2,14 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jan 14, 2014, 6:50:15 PM (GMT)] */ package vazkii.botania.common.network; -import cpw.mods.fml.common.network.IGuiHandler; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.world.World; import vazkii.botania.client.gui.bag.ContainerFlowerBag; @@ -21,37 +20,39 @@ import vazkii.botania.client.gui.crafting.GuiCraftingHalo; import vazkii.botania.client.gui.lexicon.GuiLexicon; import vazkii.botania.common.lib.LibGuiIDs; +import cpw.mods.fml.common.network.IGuiHandler; public class GuiHandler implements IGuiHandler { - @Override - public Object getServerGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) { - switch (ID) { - case LibGuiIDs.CRAFTING_HALO: - return new ContainerCraftingHalo(player.inventory, world); - case LibGuiIDs.FLOWER_BAG: - return new ContainerFlowerBag(player); - case LibGuiIDs.BAUBLE_BOX: - return new ContainerBaubleBox(player); - } + @Override + public Object getServerGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) { + switch(ID) { + case LibGuiIDs.CRAFTING_HALO : + return new ContainerCraftingHalo(player.inventory, world); + case LibGuiIDs.FLOWER_BAG : + return new ContainerFlowerBag(player); + case LibGuiIDs.BAUBLE_BOX : + return new ContainerBaubleBox(player); + } + + return null; + } - return null; - } + @Override + public Object getClientGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) { + switch(ID) { + case LibGuiIDs.LEXICON : + GuiLexicon lex = GuiLexicon.currentOpenLexicon; + return lex; + case LibGuiIDs.CRAFTING_HALO : + return new GuiCraftingHalo(player.inventory, world); + case LibGuiIDs.FLOWER_BAG : + return new GuiFlowerBag(player); + case LibGuiIDs.BAUBLE_BOX : + return new GuiBaubleBox(player); + } - @Override - public Object getClientGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) { - switch (ID) { - case LibGuiIDs.LEXICON: - GuiLexicon lex = GuiLexicon.currentOpenLexicon; - return lex; - case LibGuiIDs.CRAFTING_HALO: - return new GuiCraftingHalo(player.inventory, world); - case LibGuiIDs.FLOWER_BAG: - return new GuiFlowerBag(player); - case LibGuiIDs.BAUBLE_BOX: - return new GuiBaubleBox(player); - } + return null; + } - return null; - } } diff --git a/src/main/java/vazkii/botania/common/world/SkyblockWorldEvents.java b/src/main/java/vazkii/botania/common/world/SkyblockWorldEvents.java index b746e607c9..5d84c82333 100644 --- a/src/main/java/vazkii/botania/common/world/SkyblockWorldEvents.java +++ b/src/main/java/vazkii/botania/common/world/SkyblockWorldEvents.java @@ -2,18 +2,19 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jul 7, 2015, 6:14:18 PM (GMT)] */ package vazkii.botania.common.world; -import cpw.mods.fml.common.eventhandler.SubscribeEvent; import java.awt.Color; + import net.minecraft.block.Block; import net.minecraft.block.material.Material; +import net.minecraft.client.Minecraft; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayerMP; import net.minecraft.init.Blocks; @@ -23,180 +24,167 @@ import net.minecraft.util.ChunkCoordinates; import net.minecraft.util.MovingObjectPosition; import net.minecraft.world.World; +import net.minecraftforge.client.event.RenderWorldEvent; import net.minecraftforge.event.entity.living.LivingEvent.LivingUpdateEvent; import net.minecraftforge.event.entity.player.PlayerInteractEvent; import net.minecraftforge.event.entity.player.PlayerInteractEvent.Action; import net.minecraftforge.event.world.BlockEvent.HarvestDropsEvent; +import vazkii.botania.client.render.world.SkyblockSkyRenderer; import vazkii.botania.common.block.ModBlocks; import vazkii.botania.common.block.tile.TileManaFlame; import vazkii.botania.common.item.ModItems; import vazkii.botania.common.item.equipment.tool.ToolCommons; +import cpw.mods.fml.common.eventhandler.SubscribeEvent; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; public final class SkyblockWorldEvents { - private static final String TAG_MADE_ISLAND = "Botania-MadeIsland"; - private static final String TAG_HAS_OWN_ISLAND = "Botania-HasOwnIsland"; - private static final String TAG_ISLAND_X = "Botania-IslandX"; - private static final String TAG_ISLAND_Y = "Botania-IslandY"; - private static final String TAG_ISLAND_Z = "Botania-IslandZ"; - - @SubscribeEvent - public void onPlayerUpdate(LivingUpdateEvent event) { - if (event.entityLiving instanceof EntityPlayer && !event.entity.worldObj.isRemote) { - EntityPlayer player = (EntityPlayer) event.entityLiving; - NBTTagCompound data = player.getEntityData(); - if (!data.hasKey(EntityPlayer.PERSISTED_NBT_TAG)) - data.setTag(EntityPlayer.PERSISTED_NBT_TAG, new NBTTagCompound()); - - NBTTagCompound persist = data.getCompoundTag(EntityPlayer.PERSISTED_NBT_TAG); - if (player.ticksExisted > 3 && !persist.getBoolean(TAG_MADE_ISLAND)) { - World world = player.worldObj; - if (WorldTypeSkyblock.isWorldSkyblock(world)) { - ChunkCoordinates coords = world.getSpawnPoint(); - if (world.getBlock(coords.posX, coords.posY - 4, coords.posZ) != Blocks.bedrock - && world.provider.dimensionId == 0) - spawnPlayer(player, coords.posX, coords.posY, coords.posZ, false); - } - - persist.setBoolean(TAG_MADE_ISLAND, true); - } - } - } - - @SubscribeEvent - public void onPlayerInteract(PlayerInteractEvent event) { - if (WorldTypeSkyblock.isWorldSkyblock(event.world)) { - ItemStack equipped = event.entityPlayer.getCurrentEquippedItem(); - if (event.action == Action.RIGHT_CLICK_BLOCK && equipped == null && event.entityPlayer.isSneaking()) { - Block block = event.world.getBlock(event.x, event.y, event.z); - if (block == Blocks.grass || block == Blocks.dirt) { - if (event.world.isRemote) event.entityPlayer.swingItem(); - else { - event.world.playSoundEffect( - event.x + 0.5, - event.y + 0.5, - event.z + 0.5, - block.stepSound.getBreakSound(), - block.stepSound.getVolume() * 0.4F, - block.stepSound.getPitch() + (float) (Math.random() * 0.2 - 0.1)); - if (Math.random() < 0.8) - event.entityPlayer.dropPlayerItemWithRandomChoice( - new ItemStack(ModItems.manaResource, 1, 21), false); - } - } - } else if (equipped != null - && equipped.getItem() == Items.bowl - && event.action == Action.RIGHT_CLICK_BLOCK - && !event.world.isRemote) { - MovingObjectPosition movingobjectposition = - ToolCommons.raytraceFromEntity(event.world, event.entityPlayer, true, 4.5F); - - if (movingobjectposition != null) { - if (movingobjectposition.typeOfHit == MovingObjectPosition.MovingObjectType.BLOCK - && !event.world.isRemote) { - int i = movingobjectposition.blockX; - int j = movingobjectposition.blockY; - int k = movingobjectposition.blockZ; - - if (event.world.getBlock(i, j, k).getMaterial() == Material.water) { - --equipped.stackSize; - - if (equipped.stackSize <= 0) - event.entityPlayer.inventory.setInventorySlotContents( - event.entityPlayer.inventory.currentItem, new ItemStack(ModItems.waterBowl)); - else - event.entityPlayer.dropPlayerItemWithRandomChoice( - new ItemStack(ModItems.waterBowl), false); - } - } - } - } - } - } - - @SubscribeEvent - public void onDrops(HarvestDropsEvent event) { - if (WorldTypeSkyblock.isWorldSkyblock(event.world) && event.block == Blocks.tallgrass) { - ItemStack stackToRemove = null; - for (ItemStack stack : event.drops) - if (stack.getItem() == Items.wheat_seeds && event.world.rand.nextInt(4) == 0) { - stackToRemove = stack; - break; - } - - if (stackToRemove != null) { - event.drops.remove(stackToRemove); - event.drops.add( - new ItemStack(event.world.rand.nextBoolean() ? Items.pumpkin_seeds : Items.melon_seeds)); - } - } - } - - public static void spawnPlayer(EntityPlayer player, int x, int y, int z, boolean fabricated) { - NBTTagCompound data = player.getEntityData(); - if (!data.hasKey(EntityPlayer.PERSISTED_NBT_TAG)) - data.setTag(EntityPlayer.PERSISTED_NBT_TAG, new NBTTagCompound()); - NBTTagCompound persist = data.getCompoundTag(EntityPlayer.PERSISTED_NBT_TAG); - - final boolean test = false; - - if (test || !persist.getBoolean(TAG_HAS_OWN_ISLAND)) { - createSkyblock(player.worldObj, x, y, z); - - if (player instanceof EntityPlayerMP) { - EntityPlayerMP pmp = (EntityPlayerMP) player; - pmp.setPositionAndUpdate(x + 0.5, y + 1.6, z + 0.5); - pmp.setSpawnChunk(new ChunkCoordinates(x, y, z), true); - player.inventory.addItemStackToInventory(new ItemStack(ModItems.lexicon)); - } - - if (fabricated) { - persist.setBoolean(TAG_HAS_OWN_ISLAND, true); - persist.setDouble(TAG_ISLAND_X, player.posX); - persist.setDouble(TAG_ISLAND_Y, player.posY); - persist.setDouble(TAG_ISLAND_Z, player.posZ); - } - } else { - double posX = persist.getDouble(TAG_ISLAND_X); - double posY = persist.getDouble(TAG_ISLAND_Y); - double posZ = persist.getDouble(TAG_ISLAND_Z); - - if (player instanceof EntityPlayerMP) { - EntityPlayerMP pmp = (EntityPlayerMP) player; - pmp.setPositionAndUpdate(posX, posY, posZ); - } - } - } - - public static void createSkyblock(World world, int x, int y, int z) { - for (int i = 0; i < 3; i++) - for (int j = 0; j < 4; j++) - for (int k = 0; k < 3; k++) - world.setBlock(x - 1 + i, y - 1 - j, z - 1 + k, j == 0 ? Blocks.grass : Blocks.dirt); - world.setBlock(x - 1, y - 2, z, Blocks.flowing_water); - world.setBlock(x + 1, y + 2, z + 1, ModBlocks.manaFlame); - ((TileManaFlame) world.getTileEntity(x + 1, y + 2, z + 1)) - .setColor(new Color( - 70 + world.rand.nextInt(185), - 70 + world.rand.nextInt(185), - 70 + world.rand.nextInt(185)) - .getRGB()); - - int[][] rootPositions = new int[][] { - {-1, -3, -1}, - {-2, -4, -1}, - {-2, -4, -2}, - {+1, -4, -1}, - {+1, -5, -1}, - {+2, -5, -1}, - {+2, -6, +0}, - {+0, -4, +2}, - {+0, -5, +2}, - {+0, -5, +3}, - {+0, -6, +3}, - }; - for (int[] root : rootPositions) world.setBlock(x + root[0], y + root[1], z + root[2], ModBlocks.root); - - world.setBlock(x, y - 4, z, Blocks.bedrock); - } + private static final String TAG_MADE_ISLAND = "Botania-MadeIsland"; + private static final String TAG_HAS_OWN_ISLAND = "Botania-HasOwnIsland"; + private static final String TAG_ISLAND_X = "Botania-IslandX"; + private static final String TAG_ISLAND_Y = "Botania-IslandY"; + private static final String TAG_ISLAND_Z = "Botania-IslandZ"; + + @SubscribeEvent + public void onPlayerUpdate(LivingUpdateEvent event) { + if(event.entityLiving instanceof EntityPlayer && !event.entity.worldObj.isRemote) { + EntityPlayer player = (EntityPlayer) event.entityLiving; + NBTTagCompound data = player.getEntityData(); + if(!data.hasKey(EntityPlayer.PERSISTED_NBT_TAG)) + data.setTag(EntityPlayer.PERSISTED_NBT_TAG, new NBTTagCompound()); + + NBTTagCompound persist = data.getCompoundTag(EntityPlayer.PERSISTED_NBT_TAG); + if(player.ticksExisted > 3 && !persist.getBoolean(TAG_MADE_ISLAND)) { + World world = player.worldObj; + if(WorldTypeSkyblock.isWorldSkyblock(world)) { + ChunkCoordinates coords = world.getSpawnPoint(); + if(world.getBlock(coords.posX, coords.posY - 4, coords.posZ) != Blocks.bedrock && world.provider.dimensionId == 0) + spawnPlayer(player, coords.posX, coords.posY, coords.posZ, false); + } + + + persist.setBoolean(TAG_MADE_ISLAND, true); + } + } + } + + @SubscribeEvent + public void onPlayerInteract(PlayerInteractEvent event) { + if(WorldTypeSkyblock.isWorldSkyblock(event.world)) { + ItemStack equipped = event.entityPlayer.getCurrentEquippedItem(); + if(event.action == Action.RIGHT_CLICK_BLOCK && equipped == null && event.entityPlayer.isSneaking()) { + Block block = event.world.getBlock(event.x, event.y, event.z); + if(block == Blocks.grass || block == Blocks.dirt) { + if(event.world.isRemote) + event.entityPlayer.swingItem(); + else { + event.world.playSoundEffect(event.x + 0.5, event.y + 0.5, event.z + 0.5, block.stepSound.getBreakSound(), block.stepSound.getVolume() * 0.4F, block.stepSound.getPitch() + (float) (Math.random() * 0.2 - 0.1)); + if(Math.random() < 0.8) + event.entityPlayer.dropPlayerItemWithRandomChoice(new ItemStack(ModItems.manaResource, 1, 21), false); + } + } + } else if(equipped != null && equipped.getItem() == Items.bowl && event.action == Action.RIGHT_CLICK_BLOCK && !event.world.isRemote) { + MovingObjectPosition movingobjectposition = ToolCommons.raytraceFromEntity(event.world, event.entityPlayer, true, 4.5F); + + if(movingobjectposition != null) { + if (movingobjectposition.typeOfHit == MovingObjectPosition.MovingObjectType.BLOCK && !event.world.isRemote) { + int i = movingobjectposition.blockX; + int j = movingobjectposition.blockY; + int k = movingobjectposition.blockZ; + + if(event.world.getBlock(i, j, k).getMaterial() == Material.water) { + --equipped.stackSize; + + if(equipped.stackSize <= 0) + event.entityPlayer.inventory.setInventorySlotContents(event.entityPlayer.inventory.currentItem, new ItemStack(ModItems.waterBowl)); + else event.entityPlayer.dropPlayerItemWithRandomChoice(new ItemStack(ModItems.waterBowl), false); + } + } + } + } + } + } + + @SubscribeEvent + public void onDrops(HarvestDropsEvent event) { + if(WorldTypeSkyblock.isWorldSkyblock(event.world) && event.block == Blocks.tallgrass) { + ItemStack stackToRemove = null; + for(ItemStack stack : event.drops) + if(stack.getItem() == Items.wheat_seeds && event.world.rand.nextInt(4) == 0) { + stackToRemove = stack; + break; + } + + if(stackToRemove != null) { + event.drops.remove(stackToRemove); + event.drops.add(new ItemStack(event.world.rand.nextBoolean() ? Items.pumpkin_seeds : Items.melon_seeds)); + } + } + } + + public static void spawnPlayer(EntityPlayer player, int x, int y, int z, boolean fabricated) { + NBTTagCompound data = player.getEntityData(); + if(!data.hasKey(EntityPlayer.PERSISTED_NBT_TAG)) + data.setTag(EntityPlayer.PERSISTED_NBT_TAG, new NBTTagCompound()); + NBTTagCompound persist = data.getCompoundTag(EntityPlayer.PERSISTED_NBT_TAG); + + final boolean test = false; + + if(test || !persist.getBoolean(TAG_HAS_OWN_ISLAND)) { + createSkyblock(player.worldObj, x, y, z); + + if(player instanceof EntityPlayerMP) { + EntityPlayerMP pmp = (EntityPlayerMP) player; + pmp.setPositionAndUpdate(x + 0.5, y + 1.6, z + 0.5); + pmp.setSpawnChunk(new ChunkCoordinates(x, y, z), true); + player.inventory.addItemStackToInventory(new ItemStack(ModItems.lexicon)); + } + + if(fabricated) { + persist.setBoolean(TAG_HAS_OWN_ISLAND, true); + persist.setDouble(TAG_ISLAND_X, player.posX); + persist.setDouble(TAG_ISLAND_Y, player.posY); + persist.setDouble(TAG_ISLAND_Z, player.posZ); + } + } else { + double posX = persist.getDouble(TAG_ISLAND_X); + double posY = persist.getDouble(TAG_ISLAND_Y); + double posZ = persist.getDouble(TAG_ISLAND_Z); + + if(player instanceof EntityPlayerMP) { + EntityPlayerMP pmp = (EntityPlayerMP) player; + pmp.setPositionAndUpdate(posX, posY, posZ); + } + } + } + + public static void createSkyblock(World world, int x, int y, int z) { + for(int i = 0; i < 3; i++) + for(int j = 0; j < 4; j++) + for(int k = 0; k < 3; k++) + world.setBlock(x - 1 + i, y - 1 - j, z - 1 + k, j == 0 ? Blocks.grass : Blocks.dirt); + world.setBlock(x - 1, y - 2, z, Blocks.flowing_water); + world.setBlock(x + 1, y + 2, z + 1, ModBlocks.manaFlame); + ((TileManaFlame) world.getTileEntity(x + 1, y + 2, z + 1)).setColor(new Color(70 + world.rand.nextInt(185), 70 + world.rand.nextInt(185), 70 + world.rand.nextInt(185)).getRGB()); + + int[][] rootPositions = new int[][] { + { -1, -3, -1 }, + { -2, -4, -1 }, + { -2, -4, -2 }, + { +1, -4, -1 }, + { +1, -5, -1 }, + { +2, -5, -1 }, + { +2, -6, +0 }, + { +0, -4, +2 }, + { +0, -5, +2 }, + { +0, -5, +3 }, + { +0, -6, +3 }, + }; + for(int[] root : rootPositions) + world.setBlock(x + root[0], y + root[1], z + root[2], ModBlocks.root); + + world.setBlock(x, y - 4, z, Blocks.bedrock); + } + } diff --git a/src/main/java/vazkii/botania/common/world/WorldTypeSkyblock.java b/src/main/java/vazkii/botania/common/world/WorldTypeSkyblock.java index f3127a8595..98d7f4ee51 100644 --- a/src/main/java/vazkii/botania/common/world/WorldTypeSkyblock.java +++ b/src/main/java/vazkii/botania/common/world/WorldTypeSkyblock.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + * * File Created @ [Jul 7, 2015, 2:06:01 AM (GMT)] */ package vazkii.botania.common.world; @@ -14,44 +14,46 @@ import net.minecraft.world.WorldType; import net.minecraft.world.chunk.IChunkProvider; import net.minecraft.world.gen.ChunkProviderFlat; +import net.minecraftforge.common.MinecraftForge; public class WorldTypeSkyblock extends WorldType { - public WorldTypeSkyblock() { - super("botania-skyblock"); - } - - public static boolean isWorldSkyblock(World world) { - return world.getWorldInfo().getTerrainType() instanceof WorldTypeSkyblock; - } - - @Override - public boolean showWorldInfoNotice() { - return true; - } - - @Override - public boolean hasVoidParticles(boolean flag) { - return false; - } - - @Override - public int getMinimumSpawnHeight(World world) { - return 86; - } - - @Override - public int getSpawnFuzz() { - return 1; - } - - @Override - public float getCloudHeight() { - return 260f; - } - - @Override - public IChunkProvider getChunkGenerator(World world, String generatorOptions) { - return new ChunkProviderFlat(world, world.getSeed(), false, "2;1x0;"); - } + public WorldTypeSkyblock() { + super("botania-skyblock"); + } + + public static boolean isWorldSkyblock(World world) { + return world.getWorldInfo().getTerrainType() instanceof WorldTypeSkyblock; + } + + @Override + public boolean showWorldInfoNotice() { + return true; + } + + @Override + public boolean hasVoidParticles(boolean flag) { + return false; + } + + @Override + public int getMinimumSpawnHeight(World world) { + return 86; + } + + @Override + public int getSpawnFuzz() { + return 1; + } + + @Override + public float getCloudHeight() { + return 260f; + } + + @Override + public IChunkProvider getChunkGenerator(World world, String generatorOptions) { + return new ChunkProviderFlat(world, world.getSeed(), false, "2;1x0;"); + } + } From c6f94fabc9125c955c407b149626ed33e0a24a48 Mon Sep 17 00:00:00 2001 From: miozune Date: Fri, 19 Aug 2022 17:53:25 +0900 Subject: [PATCH 4/5] updateBuildScript & disableSpotless --- build.gradle | 341 +++++++++++++++++++++++++++++++++++++--------- gradle.properties | 8 ++ settings.gradle | 10 ++ 3 files changed, 294 insertions(+), 65 deletions(-) create mode 100644 settings.gradle diff --git a/build.gradle b/build.gradle index 5ea36f38c9..f482abad18 100644 --- a/build.gradle +++ b/build.gradle @@ -1,22 +1,27 @@ -//version: 1644612407 +//version: 1660899027 /* -DO NOT CHANGE THIS FILE! + DO NOT CHANGE THIS FILE! + Also, you may replace this file at any time if there is an update available. + Please check https://github.com/GTNewHorizons/ExampleMod1.7.10/blob/main/build.gradle for updates. + */ -Also, you may replace this file at any time if there is an update available. -Please check https://github.com/GTNewHorizons/ExampleMod1.7.10/blob/main/build.gradle for updates. -*/ - -import org.gradle.internal.logging.text.StyledTextOutput -import org.gradle.internal.logging.text.StyledTextOutputFactory -import org.gradle.internal.logging.text.StyledTextOutput.Style import com.github.jengelman.gradle.plugins.shadow.tasks.ConfigureShadowRelocation import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar +import org.gradle.internal.logging.text.StyledTextOutput.Style +import org.gradle.internal.logging.text.StyledTextOutputFactory +import java.nio.file.Files +import java.nio.file.Paths import java.util.concurrent.TimeUnit +import java.util.zip.ZipEntry +import java.util.zip.ZipInputStream +import java.util.zip.ZipOutputStream buildscript { repositories { + mavenCentral() + maven { name 'forge' url 'https://maven.minecraftforge.net' @@ -38,22 +43,30 @@ buildscript { classpath 'com.github.GTNewHorizons:ForgeGradle:1.2.7' } } - plugins { id 'java-library' id 'idea' id 'eclipse' id 'scala' id 'maven-publish' - id 'org.jetbrains.kotlin.jvm' version '1.5.30' apply false - id 'org.jetbrains.kotlin.kapt' version '1.5.30' apply false + id 'org.jetbrains.kotlin.jvm' version '1.5.30' apply false + id 'org.jetbrains.kotlin.kapt' version '1.5.30' apply false + id 'com.google.devtools.ksp' version '1.5.30-1.0.0' apply false id 'org.ajoberstar.grgit' version '4.1.1' id 'com.github.johnrengelman.shadow' version '4.0.4' - id 'com.palantir.git-version' version '0.13.0' apply false + id 'com.palantir.git-version' version '0.13.0' apply false id 'de.undercouch.download' version '5.0.1' - id 'com.github.gmazzo.buildconfig' version '3.0.3' apply false + id 'com.github.gmazzo.buildconfig' version '3.0.3' apply false + id 'com.diffplug.spotless' version '6.7.2' apply false +} +verifySettingsGradle() + +dependencies { + implementation 'com.diffplug:blowdryer:1.6.0' } +apply plugin: 'com.diffplug.blowdryer' + if (project.file('.git/HEAD').isFile()) { apply plugin: 'com.palantir.git-version' } @@ -78,6 +91,13 @@ idea { } } +boolean disableSpotless = project.hasProperty("disableSpotless") ? project.disableSpotless.toBoolean() : false + +if (!disableSpotless) { + apply plugin: 'com.diffplug.spotless' + apply from: Blowdryer.file('spotless.gradle') +} + if(JavaVersion.current() != JavaVersion.VERSION_1_8) { throw new GradleException("This project requires Java 8, but it's running on " + JavaVersion.current()) } @@ -103,8 +123,11 @@ checkPropertyExists("containsMixinsAndOrCoreModOnly") checkPropertyExists("usesShadowedDependencies") checkPropertyExists("developmentEnvironmentUserName") -boolean noPublishedSources = project.findProperty("noPublishedSources") ? project.noPublishedSources.toBoolean() : false - +boolean noPublishedSources = project.hasProperty("noPublishedSources") ? project.noPublishedSources.toBoolean() : false +boolean usesMixinDebug = project.hasProperty('usesMixinDebug') ?: project.usesMixins.toBoolean() +boolean forceEnableMixins = project.hasProperty('forceEnableMixins') ? project.forceEnableMixins.toBoolean() : false +String channel = project.hasProperty('channel') ? project.channel : 'stable' +String mappingsVersion = project.hasProperty('mappingsVersion') ? project.mappingsVersion : '12' String javaSourceDir = "src/main/java/" String scalaSourceDir = "src/main/scala/" String kotlinSourceDir = "src/main/kotlin/" @@ -175,7 +198,7 @@ configurations.all { try { 'git config core.fileMode false'.execute() } -catch (Exception e) { +catch (Exception ignored) { out.style(Style.Failure).println("git isn't installed at all") } @@ -185,11 +208,11 @@ String versionOverride = System.getenv("VERSION") ?: null try { identifiedVersion = versionOverride == null ? gitVersion() : versionOverride } -catch (Exception e) { +catch (Exception ignored) { out.style(Style.Failure).text( - 'This mod must be version controlled by Git AND the repository must provide at least one tag,\n' + - 'or the VERSION override must be set! ').style(Style.SuccessHeader).text('(Do NOT download from GitHub using the ZIP option, instead\n' + - 'clone the repository, see ').style(Style.Info).text('https://gtnh.miraheze.org/wiki/Development').style(Style.SuccessHeader).println(' for details.)' + 'This mod must be version controlled by Git AND the repository must provide at least one tag,\n' + + 'or the VERSION override must be set! ').style(Style.SuccessHeader).text('(Do NOT download from GitHub using the ZIP option, instead\n' + + 'clone the repository, see ').style(Style.Info).text('https://gtnh.miraheze.org/wiki/Development').style(Style.SuccessHeader).println(' for details.)' ) versionOverride = 'NO-GIT-TAG-SET' identifiedVersion = versionOverride @@ -199,7 +222,7 @@ ext { modVersion = identifiedVersion } -if( identifiedVersion.equals(versionOverride) ) { +if(identifiedVersion == versionOverride) { out.style(Style.Failure).text('Override version to ').style(Style.Identifier).text(modVersion).style(Style.Failure).println('!\7') } @@ -214,13 +237,17 @@ else { def arguments = [] def jvmArguments = [] -if(usesMixins.toBoolean()) { +if (usesMixins.toBoolean() || forceEnableMixins) { arguments += [ "--tweakClass org.spongepowered.asm.launch.MixinTweaker" ] - jvmArguments += [ - "-Dmixin.debug.countInjections=true", "-Dmixin.debug.verbose=true", "-Dmixin.debug.export=true" - ] + if (usesMixinDebug.toBoolean()) { + jvmArguments += [ + "-Dmixin.debug.countInjections=true", + "-Dmixin.debug.verbose=true", + "-Dmixin.debug.export=true" + ] + } } minecraft { @@ -275,7 +302,7 @@ repositories { name 'Overmind forge repo mirror' url 'https://gregtech.overminddl1.com/' } - if(usesMixins.toBoolean()) { + if(usesMixins.toBoolean() || forceEnableMixins) { maven { name 'sponge' url 'https://repo.spongepowered.org/repository/maven-public' @@ -292,6 +319,8 @@ dependencies { annotationProcessor('com.google.guava:guava:24.1.1-jre') annotationProcessor('com.google.code.gson:gson:2.8.6') annotationProcessor('org.spongepowered:mixin:0.8-SNAPSHOT') + } + if(usesMixins.toBoolean() || forceEnableMixins) { // using 0.8 to workaround a issue in 0.7 which fails mixin application compile('com.github.GTNewHorizons:SpongePoweredMixin:0.7.12-GTNH') { // Mixin includes a lot of dependencies that are too up-to-date @@ -312,18 +341,23 @@ def refMap = "${tasks.compileJava.temporaryDir}" + File.separator + mixingConfig def mixinSrg = "${tasks.reobf.temporaryDir}" + File.separator + "mixins.srg" task generateAssets { - if(usesMixins.toBoolean()) { - getFile("/src/main/resources/mixins." + modId + ".json").text = """{ + if (usesMixins.toBoolean()) { + def mixinConfigFile = getFile("/src/main/resources/mixins." + modId + ".json"); + if (!mixinConfigFile.exists()) { + mixinConfigFile.text = """{ "required": true, "minVersion": "0.7.11", "package": "${modGroup}.${mixinsPackage}", "plugin": "${modGroup}.${mixinPlugin}", "refmap": "${mixingConfigRefMap}", "target": "@env(DEFAULT)", - "compatibilityLevel": "JAVA_8" + "compatibilityLevel": "JAVA_8", + "mixins": [], + "client": [], + "server": [] } - """ + } } } @@ -344,7 +378,10 @@ shadowJar { } minimize() // This will only allow shading for actually used classes - configurations = [project.configurations.shadowImplementation, project.configurations.shadowCompile] + configurations = [ + project.configurations.shadowImplementation, + project.configurations.shadowCompile + ] dependsOn(relocateShadowJar) } @@ -366,7 +403,7 @@ jar { } reobf { - if(usesMixins.toBoolean()) { + if(usesMixins.toBoolean() && file(mixinSrg).exists()) { addExtraSrgFile mixinSrg } } @@ -415,6 +452,7 @@ processResources { // this will ensure that this task is redone when the versions change. inputs.property "version", project.version inputs.property "mcversion", project.minecraft.version + exclude("spotless.gradle") // replace stuff in mcmod.info, nothing else from(sourceSets.main.resources.srcDirs) { @@ -422,9 +460,9 @@ processResources { // replace modVersion and minecraftVersion expand "minecraftVersion": project.minecraft.version, - "modVersion": modVersion, - "modId": modId, - "modName": modName + "modVersion": modVersion, + "modId": modId, + "modName": modName } if(usesMixins.toBoolean()) { @@ -434,12 +472,13 @@ processResources { // copy everything else that's not the mcmod.info from(sourceSets.main.resources.srcDirs) { exclude 'mcmod.info' + exclude 'spotless.gradle' } } def getManifestAttributes() { def manifestAttributes = [:] - if(containsMixinsAndOrCoreModOnly.toBoolean() == false && (usesMixins.toBoolean() || coreModClass)) { + if(!containsMixinsAndOrCoreModOnly.toBoolean() && (usesMixins.toBoolean() || coreModClass)) { manifestAttributes += ["FMLCorePluginContainsFMLMod": true] } @@ -455,14 +494,14 @@ def getManifestAttributes() { manifestAttributes += [ "TweakClass" : "org.spongepowered.asm.launch.MixinTweaker", "MixinConfigs" : "mixins." + modId + ".json", - "ForceLoadAsMod" : containsMixinsAndOrCoreModOnly.toBoolean() == false + "ForceLoadAsMod" : !containsMixinsAndOrCoreModOnly.toBoolean() ] } return manifestAttributes } task sourcesJar(type: Jar) { - from (sourceSets.main.allJava) + from (sourceSets.main.allSource) from (file("$projectDir/LICENSE")) getArchiveClassifier().set('sources') } @@ -482,7 +521,10 @@ task shadowDevJar(type: ShadowJar) { } minimize() // This will only allow shading for actually used classes - configurations = [project.configurations.shadowImplementation, project.configurations.shadowCompile] + configurations = [ + project.configurations.shadowImplementation, + project.configurations.shadowCompile + ] } task relocateShadowDevJar(type: ConfigureShadowRelocation) { @@ -517,7 +559,7 @@ task devJar(type: Jar) { } task apiJar(type: Jar) { - from (sourceSets.main.allJava) { + from (sourceSets.main.allSource) { include modGroup.toString().replaceAll("\\.", "/") + "/" + apiPackage.toString().replaceAll("\\.", "/") + '/**' } @@ -548,6 +590,9 @@ tasks.withType(GenerateModuleMetadata) { enabled = false } +// workaround variable hiding in pom processing +def projectConfigs = project.configurations + publishing { publications { maven(MavenPublication) { @@ -556,7 +601,7 @@ publishing { artifact source: shadowJar, classifier: "" } if(!noPublishedSources) { - artifact source: sourcesJar, classifier: "src" + artifact source: sourcesJar, classifier: "sources" } artifact source: usesShadowedDependencies.toBoolean() ? shadowDevJar : devJar, classifier: "dev" if (apiPackage) { @@ -568,16 +613,23 @@ publishing { // Using the identified version, not project.version as it has the prepended 1.7.10 version = System.getenv("RELEASE_VERSION") ?: identifiedVersion - // remove extra garbage from who knows where + // remove extra garbage from minecraft and minecraftDeps configuration pom.withXml { - def badPomGroup = ['net.minecraft', 'com.google.code.findbugs', 'org.ow2.asm', 'com.typesafe.akka', 'com.typesafe', 'org.scala-lang', - 'org.scala-lang.plugins', 'net.sf.jopt-simple', 'lzma', 'com.mojang', 'org.apache.commons', 'org.apache.httpcomponents', - 'commons-logging', 'java3d', 'net.sf.trove4j', 'com.ibm.icu', 'com.paulscode', 'io.netty', 'com.google.guava', - 'commons-io', 'commons-codec', 'net.java.jinput', 'net.java.jutils', 'com.google.code.gson', 'org.apache.logging.log4j', - 'org.lwjgl.lwjgl', 'tv.twitch', 'org.jetbrains.kotlin', ''] + def badArtifacts = [:].withDefault {[] as Set} + for (configuration in [ + projectConfigs.minecraft, + projectConfigs.minecraftDeps + ]) { + for (dependency in configuration.allDependencies) { + badArtifacts[dependency.group == null ? "" : dependency.group] += dependency.name + } + } + // example for specifying extra stuff to ignore + // badArtifacts["org.example.group"] += "artifactName" + Node pomNode = asNode() pomNode.dependencies.'*'.findAll() { - badPomGroup.contains(it.groupId.text()) + badArtifacts[it.groupId.text()].contains(it.artifactId.text()) }.each() { it.parent().remove(it) } @@ -605,7 +657,7 @@ task updateBuildScript { } } -if (isNewBuildScriptVersionAvailable(projectDir.toString())) { +if (!project.getGradle().startParameter.isOffline() && isNewBuildScriptVersionAvailable(projectDir.toString())) { if (autoUpdateBuildScript.toBoolean()) { performBuildScriptUpdate(projectDir.toString()) } else { @@ -616,12 +668,26 @@ if (isNewBuildScriptVersionAvailable(projectDir.toString())) { static URL availableBuildScriptUrl() { new URL("https://raw.githubusercontent.com/GTNewHorizons/ExampleMod1.7.10/main/build.gradle") } +static URL exampleSettingsGradleUrl() { + new URL("https://raw.githubusercontent.com/GTNewHorizons/ExampleMod1.7.10/main/settings.gradle.example") +} + + +def verifySettingsGradle() { + def settingsFile = getFile("settings.gradle") + if (!settingsFile.exists()) { + println("Downloading default settings.gradle") + exampleSettingsGradleUrl().withInputStream { i -> settingsFile.withOutputStream { it << i } } + throw new GradleException("Settings.gradle has been updated, please re-run task.") + } +} boolean performBuildScriptUpdate(String projectDir) { if (isNewBuildScriptVersionAvailable(projectDir)) { def buildscriptFile = getFile("build.gradle") availableBuildScriptUrl().withInputStream { i -> buildscriptFile.withOutputStream { it << i } } out.style(Style.Success).print("Build script updated. Please REIMPORT the project or RESTART your IDE!") + verifySettingsGradle() return true } return false @@ -652,7 +718,103 @@ configure(updateBuildScript) { description = 'Updates the build script to the latest version' } -// Deobfuscation +// Parameter Deobfuscation + +task deobfParams { + doLast { + + String mcpDir = "$project.gradle.gradleUserHomeDir/caches/minecraft/de/oceanlabs/mcp/mcp_$channel/$mappingsVersion" + String mcpZIP = "$mcpDir/mcp_$channel-$mappingsVersion-${minecraftVersion}.zip" + String paramsCSV = "$mcpDir/params.csv" + + download.run { + src "https://maven.minecraftforge.net/de/oceanlabs/mcp/mcp_$channel/$mappingsVersion-$minecraftVersion/mcp_$channel-$mappingsVersion-${minecraftVersion}.zip" + dest mcpZIP + overwrite false + } + + if(!file(paramsCSV).exists()) { + println("Extracting MCP archive ...") + unzip(mcpZIP, mcpDir) + } + + println("Parsing params.csv ...") + Map params = new HashMap<>() + Files.lines(Paths.get(paramsCSV)).forEach{line -> + String[] cells = line.split(",") + if(cells.length > 2 && cells[0].matches("p_i?\\d+_\\d+_")) { + params.put(cells[0], cells[1]) + } + } + + out.style(Style.Success).println("Modified ${replaceParams(file("$projectDir/src/main/java"), params)} files!") + out.style(Style.Failure).println("Don't forget to verify that the code still works as before!\n It could be broken due to duplicate variables existing now\n or parameters taking priority over other variables.") + } +} + +static int replaceParams(File file, Map params) { + int fileCount = 0 + + if(file.isDirectory()) { + for(File f : file.listFiles()) { + fileCount += replaceParams(f, params) + } + return fileCount + } + println("Visiting ${file.getName()} ...") + try { + String content = new String(Files.readAllBytes(file.toPath())) + int hash = content.hashCode() + params.forEach{key, value -> + content = content.replaceAll(key, value) + } + if(hash != content.hashCode()) { + Files.write(file.toPath(), content.getBytes("UTF-8")) + return 1 + } + } catch(Exception e) { + e.printStackTrace() + } + return 0 +} + +// Credit: bitsnaps (https://gist.github.com/bitsnaps/00947f2dce66f4bbdabc67d7e7b33681) +static unzip(String zipFileName, String outputDir) { + byte[] buffer = new byte[16384] + ZipInputStream zis = new ZipInputStream(new FileInputStream(zipFileName)) + ZipEntry zipEntry = zis.getNextEntry() + while (zipEntry != null) { + File newFile = new File(outputDir + File.separator, zipEntry.name) + if (zipEntry.isDirectory()) { + if (!newFile.isDirectory() && !newFile.mkdirs()) { + throw new IOException("Failed to create directory $newFile") + } + } else { + // fix for Windows-created archives + File parent = newFile.parentFile + if (!parent.isDirectory() && !parent.mkdirs()) { + throw new IOException("Failed to create directory $parent") + } + // write file content + FileOutputStream fos = new FileOutputStream(newFile) + int len = 0 + while ((len = zis.read(buffer)) > 0) { + fos.write(buffer, 0, len) + } + fos.close() + } + zipEntry = zis.getNextEntry() + } + zis.closeEntry() + zis.close() +} + +configure(deobfParams) { + group = 'forgegradle' + description = 'Rename all obfuscated parameter names inherited from Minecraft classes' +} + +// Dependency Deobfuscation def deobf(String sourceURL) { try { @@ -665,7 +827,7 @@ def deobf(String sourceURL) { fileName = fileName.substring(lastSlash + 1) } //get rid of extension: - if(fileName.endsWith(".jar")) { + if(fileName.endsWith(".jar") || fileName.endsWith(".litemod")) { fileName = fileName.substring(0, fileName.lastIndexOf(".")) } @@ -677,26 +839,41 @@ def deobf(String sourceURL) { Collections.reverse(parts) hostName = String.join(".", parts) - return deobf(sourceURL, hostName + "/" + fileName) + return deobf(sourceURL, "$hostName/$fileName") } catch(Exception e) { - return deobf(sourceURL, "deobf/" + String.valueOf(sourceURL.hashCode())) + return deobf(sourceURL, "deobf/${sourceURL.hashCode()}") } } // The method above is to be preferred. Use this method if the filename is not at the end of the URL. -def deobf(String sourceURL, String fileName) { - String cacheDir = System.getProperty("user.home") + "/.gradle/caches/" - String bon2Dir = cacheDir + "forge_gradle/deobf" - String bon2File = bon2Dir + "/BON2-2.5.0.jar" - String obfFile = cacheDir + "modules-2/files-2.1/" + fileName + ".jar" - String deobfFile = cacheDir + "modules-2/files-2.1/" + fileName + "-deobf.jar" +def deobf(String sourceURL, String rawFileName) { + String bon2Version = "2.5.1" + String fileName = URLDecoder.decode(rawFileName, "UTF-8") + String cacheDir = "$project.gradle.gradleUserHomeDir/caches" + String bon2Dir = "$cacheDir/forge_gradle/deobf" + String bon2File = "$bon2Dir/BON2-${bon2Version}.jar" + String obfFile = "$cacheDir/modules-2/files-2.1/${fileName}.jar" + String deobfFile = "$cacheDir/modules-2/files-2.1/${fileName}-deobf.jar" if(file(deobfFile).exists()) { return files(deobfFile) } + String mappingsVer + String remoteMappings = project.hasProperty('remoteMappings') ? project.remoteMappings : 'https://raw.githubusercontent.com/MinecraftForge/FML/1.7.10/conf/' + if(remoteMappings) { + String id = "${forgeVersion.split("\\.")[3]}-$minecraftVersion" + String mappingsZIP = "$cacheDir/forge_gradle/maven_downloader/de/oceanlabs/mcp/mcp_snapshot_nodoc/$id/mcp_snapshot_nodoc-${id}.zip" + + zipMappings(mappingsZIP, remoteMappings, bon2Dir) + + mappingsVer = "snapshot_$id" + } else { + mappingsVer = "${channel}_$mappingsVersion" + } + download.run { - src 'https://github.com/GTNewHorizons/BON2/releases/download/2.5.0/BON2-2.5.0.CUSTOM-all.jar' + src "http://jenkins.usrv.eu:8081/nexus/content/repositories/releases/com/github/parker8283/BON2/$bon2Version-CUSTOM/BON2-$bon2Version-CUSTOM-all.jar" dest bon2File quiet true overwrite false @@ -710,22 +887,56 @@ def deobf(String sourceURL, String fileName) { } exec { - commandLine 'java', '-jar', bon2File, '--inputJar', obfFile, '--outputJar', deobfFile, '--mcVer', '1.7.10', '--mappingsVer', 'stable_12', '--notch' + commandLine 'java', '-jar', bon2File, '--inputJar', obfFile, '--outputJar', deobfFile, '--mcVer', minecraftVersion, '--mappingsVer', mappingsVer, '--notch' workingDir bon2Dir - standardOutput = new ByteArrayOutputStream() + standardOutput = new FileOutputStream("${deobfFile}.log") } return files(deobfFile) } +def zipMappings(String zipPath, String url, String bon2Dir) { + File zipFile = new File(zipPath) + if(zipFile.exists()) { + return + } + + String fieldsCache = "$bon2Dir/data/fields.csv" + String methodsCache = "$bon2Dir/data/methods.csv" + + download.run { + src "${url}fields.csv" + dest fieldsCache + quiet true + } + download.run { + src "${url}methods.csv" + dest methodsCache + quiet true + } + + zipFile.getParentFile().mkdirs() + ZipOutputStream zos = new ZipOutputStream(new FileOutputStream(zipFile)) + + zos.putNextEntry(new ZipEntry("fields.csv")) + Files.copy(Paths.get(fieldsCache), zos) + zos.closeEntry() + + zos.putNextEntry(new ZipEntry("methods.csv")) + Files.copy(Paths.get(methodsCache), zos) + zos.closeEntry() + + zos.close() +} + // Helper methods def checkPropertyExists(String propertyName) { - if (project.hasProperty(propertyName) == false) { + if (!project.hasProperty(propertyName)) { throw new GradleException("This project requires a property \"" + propertyName + "\"! Please add it your \"gradle.properties\". You can find all properties and their description here: https://github.com/GTNewHorizons/ExampleMod1.7.10/blob/main/gradle.properties") } } def getFile(String relativePath) { return new File(projectDir, relativePath) -} +} \ No newline at end of file diff --git a/gradle.properties b/gradle.properties index 04695e351a..e38c371693 100644 --- a/gradle.properties +++ b/gradle.properties @@ -62,3 +62,11 @@ usesShadowedDependencies = false # Optional parameter to customize the produced artifacts. Use this to preserver artifact naming when migrating older # projects. New projects should not use this parameter. #customArchiveBaseName = + +# Optional parameter to prevent the source code from being published +# noPublishedSources = + +# Uncomment this to disable spotless checks +# This should only be uncommented to keep it easier to sync with upstream/other forks. +# That is, if there is no other active fork/upstream, NEVER change this. +disableSpotless = true diff --git a/settings.gradle b/settings.gradle new file mode 100644 index 0000000000..97d8f71c52 --- /dev/null +++ b/settings.gradle @@ -0,0 +1,10 @@ +plugins { + id 'com.diffplug.blowdryerSetup' version '1.6.0' +} + +apply plugin: 'com.diffplug.blowdryerSetup' + +blowdryerSetup { + github('GTNewHorizons/ExampleMod1.7.10', 'tag', '0.1.4') + //devLocal '.' // Use this when testing config updates locally +} From 528a9a401018131ae178541802dde1d4f6b101a6 Mon Sep 17 00:00:00 2001 From: Martin Robertz Date: Fri, 19 Aug 2022 13:19:10 +0200 Subject: [PATCH 5/5] Update settings.gradle --- settings.gradle | 1 + 1 file changed, 1 insertion(+) diff --git a/settings.gradle b/settings.gradle index 97d8f71c52..c4cf340211 100644 --- a/settings.gradle +++ b/settings.gradle @@ -5,6 +5,7 @@ plugins { apply plugin: 'com.diffplug.blowdryerSetup' blowdryerSetup { +// Pulls the spotless config from the example mod repository github('GTNewHorizons/ExampleMod1.7.10', 'tag', '0.1.4') //devLocal '.' // Use this when testing config updates locally }